wise-2.4.1/0000755000175000001440000000000010670453645012063 5ustar philippuserswise-2.4.1/src/0000755000175000001440000000000010670453632012646 5ustar philippuserswise-2.4.1/src/api/0000755000175000001440000000000010670453554013422 5ustar philippuserswise-2.4.1/src/api/libs/0000755000175000001440000000000010670453554014353 5ustar philippuserswise-2.4.1/src/api/libs/makefile0000644000175000001440000000020607313404531016040 0ustar philippusers apilibs : cp ../../base/libwisebase.a . cp ../../dynlibsrc/libdyna.a . cp ../../models/libmodel.a . cp ../../HMMer2/libhmmer.a . wise-2.4.1/src/api/README0000644000175000001440000000011007313404530014260 0ustar philippusers This is the directory for the External API calls for the Wise2 package wise-2.4.1/src/api/examples/0000755000175000001440000000000010670453554015240 5ustar philippuserswise-2.4.1/src/api/examples/revcomp.c0000644000175000001440000000116107313404530017044 0ustar philippusers#include "dyna_api.h" int main(int argc,char ** argv) { Wise2_Sequence * seq; Wise2_Sequence * rev; if( argc != 2 ) { fprintf(stderr,"have to give an argument for a file\n"); exit(1); } seq = Wise2_read_fasta_file_Sequence(argv[1]); if( seq == NULL ) { fprintf(stderr,"Unable to read fasta file in %s\n",argv[1]); exit(1); } rev = Wise2_reverse_complement_Sequence(seq); printf("Original sequence\n\n"); Wise2_write_fasta_Sequence(seq,stdout); printf("Revcomp sequence\n\n"); Wise2_write_fasta_Sequence(rev,stdout); Wise2_free_Sequence(seq); Wise2_free_Sequence(rev); } wise-2.4.1/src/api/examples/sw.c0000644000175000001440000000261707313404530016031 0ustar philippusers#include "model_api.h" int main(int argc,char ** argv) { Wise2_Sequence * temp; Wise2_Protein * one; Wise2_Protein * two; Wise2_CompMat * comp; Wise2_AlnBlock * alb; if( argc != 3 ) { fprintf(stderr,"sw \n"); exit(1); } /** read into generic sequence object */ temp = Wise2_read_fasta_file_Sequence(argv[1]); if( temp == NULL ) { fprintf(stderr,"Unable to read fasta file in %s\n",argv[1]); exit(1); } /* make into a protein - makes sure the entire sequence looks ok for protein */ one = Wise2_Protein_from_Sequence(temp); if( one == NULL ) { fprintf(stderr,"Could not make a protein from sequence %s",Wise2_access_name_Sequence(temp)); exit(1); } /* the same for the second sequence */ temp = Wise2_read_fasta_file_Sequence(argv[2]); if( temp == NULL ) { fprintf(stderr,"Unable to read fasta file in %s\n",argv[2]); exit(1); } two = Wise2_Protein_from_Sequence(temp); if( two == NULL ) { fprintf(stderr,"Could not make a protein from sequence %s",Wise2_access_name_Sequence(temp)); exit(1); } /* blosum matrix reading */ comp = Wise2_read_Blast_file_CompMat("blosum62.bla"); alb = Wise2_Align_Proteins_SmithWaterman(one,two,comp,-12,-2); fprintf(stdout,"Score is %d\n",Wise2_access_score_AlnBlock(alb)); Wise2_write_pretty_Protein_align(alb,one,two,15,50,stdout); } wise-2.4.1/src/api/examples/README0000644000175000001440000000052007313404530016103 0ustar philippusers README for api examples. The documentation is found in the /docs directory as wise2api.ps to make the examples go make all in this directory, once you have done a make api in the root (../..) directory. To run revcomp go revcomp est.dna To run sw go sw road.pep roac.pep To see the source code, look at revcomp.c and sw.c wise-2.4.1/src/api/examples/roac.pep0000644000175000001440000000057307313404530016665 0ustar philippusers>Q22037 this here we go! MTDVEIKAENGSGDASLEPENLRKIFVGGLTSNTTDDLMREFYSQFGEITDIIVMRDPTT KRSRGFGFVTFSGKTEVDAAMKQRPHIIDGKTVDPKRAVPRDDKNRSESNVSTKRLYVSG VREDHTEDMLTEYFTKYGTVTKSEIILDKATQKPRGFGFVTFDDHDSVDQCVLQKSHMVN GHRCDVRKGLSKDEMSKAQMNRDRETRGGRSRDGQRGGYNGGGGGGGGWGGPAQRGGPGA YGGPGGGGQGGYGGDYGGGWGQQGGGGQGGWGGPQQQQGGGGWGQQGGGGQGGWGGPQQQ QQGGWGGPQQGGGGGGWGGQGQQQGGWGGQSGAQQWAHAQGGNRNY wise-2.4.1/src/api/examples/road.pep0000644000175000001440000000060107313404530016656 0ustar philippusers>roa1_drome MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGLDYRTTDENLKAH FEKWGNIVDVVVMKDPRTKRSRGFGFITYSHSSMIDEAQKSRPHKIDGRV VEPKRAVPRQDIDSPNAGATVKKLFVGALKDDHDEQSIRDYFQHFGNIVD INIVIDKETGKKRGFAFVEFDDYDPVDKVVLQKQHQLNGKMVDVKKALPK QNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGNQNGGGNWNNGGNNWGNNR GGNDNWGNNSFGGGGGGGGGYGGGNNSWGNNNPWDNGNGGGNFGGGGNNW NNGGNDFGGYQQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGNYG GNNQGFNNGGNNRRY wise-2.4.1/src/api/examples/makefile0000644000175000001440000000042307313404530016725 0ustar philippusers CC = cc CFLAGS = -c -I../include LIBDIRS = -L../libs all : revcomp sw revcomp : revcomp.o $(CC) -o revcomp revcomp.o $(LIBDIRS) -ldyna -lwisebase -lm sw : sw.o $(CC) -o sw sw.o $(LIBDIRS) -lmodel -ldyna -lwisebase -lm clean : rm -f *.o .c.o : $(CC) $(CFLAGS) $? wise-2.4.1/src/api/examples/est.dna0000644000175000001440000000075707313404530016516 0ustar philippusers>hs_est GAGAGGGCGAAGGTAGGCTGGCAGATACGTTCGTCAGCTTGCTCCTTTCTGCCCGTGGAC GCCGCCGAAGAAGCATCGTTAAAGTCTCTCTTCACCCTGCCGTCATGTCTAAGTCAGAGT CTCCTAAAGAGCCCGAACAGCTGAGGAAGCTCTTCATTGGAGGGTTGAGCTTTGAAACAA CTGATGAGAGCCTGAGGAGCCATTTTGAGCAATGGGGAACGCTCACGGACTGTGTGGTAA GAGAGATCCAAACACCAAGCGCTCTAGGGGCTTTGGGTTTGTCACATATGCCACTGTGG AGGAGGTGGATGCAGCTATGAATGCAAGGCCACACAAGGTGGATGGAAGAGTTGTGGAAC CAAAGAGAGCTGTCTCCAGAGAAGATTCTCAAAGACCAGGTGCCCACTTAACTGTGAAAA AGATATTTGTTGGTGGCATTAAAGAAGACACTGAAGAACATCACCTAAGAGATTATTTTG wise-2.4.1/src/api/include/0000755000175000001440000000000010670453554015045 5ustar philippuserswise-2.4.1/src/api/include/wisebase_api.h0000644000175000001440000000607307313404531017646 0ustar philippusers #include typedef char aa; typedef int base; typedef double Probability; typedef double Bits; typedef int Score; typedef int codon; typedef int boolean; #define WISE2_FATAL 1 #define WISE2_WARNING 2 #define WISE2_INFO 8 #define WISE2_REPORT 16 /* Function: Wise2_error_off(type) * * Descrip: Really for the API. Wraps some * of the error concepts.. * * * Arg: type [UNKN ] Undocumented argument [int] * */ void Wise2_error_off(int type); /* Function: Wise2_error_on(type) * * Descrip: Really for the API. Wraps some * of the error concepts.. * * * Arg: type [UNKN ] Undocumented argument [int] * */ void Wise2_error_on(int type); /* These functions are not associated with an object */ /* Function: Wise2_catch_errors(catch) * * Descrip: This is a wrapper for the error handling * system. It does the following things * * Sets function as the function to process errors * * Switches the INFO,ERROR and FATAL flags off on STDERR * and on to ERROR CALL. * * * Arg: catch [void (*catch] * * Returns Undocumented return value [boolean] * */ boolean Wise2_catch_errors( void (*catch)(char *,int)); /* Function: Wise2_stop_catching_errors(void) * * Descrip: Switches off error catching, * putting flags back on to STDERR * * * * Returns Undocumented return value [boolean] * */ boolean Wise2_stop_catching_errors(); /* Function: Wise2_warn(msg,) * * Descrip: Produces a 'warn' error message. * * * Arg: msg Undocumented argument [char *] * Arg: Undocumented argument [Wise2_.] * * Returns Undocumented return value [void] * */ void Wise2_warn( char * msg, ... ); /* Function: Wise2_info(msg,) * * Descrip: Produces a 'info' error message. * * * Arg: msg Undocumented argument [char *] * Arg: Undocumented argument [Wise2_.] * * Returns Undocumented return value [void] * */ void Wise2_info( char * msg, ... ); /* Function: Wise2_fatal(msg,) * * Descrip: Produces a 'fatal' error message. * * * Arg: msg Undocumented argument [char *] * Arg: Undocumented argument [Wise2_.] * * Returns Undocumented return value [void] * */ void Wise2_fatal( char * msg, ... ); /* These functions are not associated with an object */ /* Function: Wise2_openfile(filename,passedprot) * * Descrip: Every file open goes through this. * * It opens for reading in the following order * . * WISEPERSONALDIR * WISECONFIGDIR * * For writing it opens in . * * Filenames with ~'s are expanded to HOME/filename * * * Arg: filename filename to open for read/writing [const char *] * Arg: passedprot string representing standard fopen attributes [const char *] * * Returns open'd filehandle, NULL on error [FILE *] * */ FILE * Wise2_openfile( const char * filename,const char * passedprot); wise-2.4.1/src/api/include/models.head0000644000175000001440000000002707313404531017141 0ustar philippusers #include "dyna_api.h" wise-2.4.1/src/api/include/makefile0000644000175000001440000000023207313404531016531 0ustar philippusers apih : cat dyna.head ../../dynlibsrc/*api.t ../../dynlibsrc/*api.h > dyna_api.h cat models.head ../../models/*api.t ../../models/*api.h > model_api.h wise-2.4.1/src/api/include/basic.h0000644000175000001440000000041307313404531016264 0ustar philippusers #include typedef char aa; typedef int base; typedef double Probability; typedef double Bits; typedef int Score; typedef int codon; typedef int boolean; #define WISE2_FATAL 1 #define WISE2_WARNING 2 #define WISE2_INFO 8 #define WISE2_REPORT 16 wise-2.4.1/src/api/include/dyna.head0000644000175000001440000000003307313404530016605 0ustar philippusers #include "wisebase_api.h" wise-2.4.1/src/dyc/0000755000175000001440000000000010670453715013427 5ustar philippuserswise-2.4.1/src/dyc/kbestsearch.dy0000644000175000001440000003437207313404534016267 0ustar philippusers %{ #include "dyna2.h" #include "dynafunc.h" #include "optimiser.h" #define TransitionSetLISTLENGTH 24 #define Transition_from_special(trans) (trans->trans_type == TRANSITION_FROM_SPECIAL || trans->trans_type == TRANSITION_FROM_START ? 1 : 0) #define TRANSITION_NORMAL 0 #define TRANSITION_FROM_SPECIAL 1 #define TRANSITION_FROM_START 2 %} struct Transition char * to char * from int offi int offj char * calc int trans_type !def="TRANSITION_NORMAL" ExprTree * expr; ExprTree * expr_state; %info This is the data structure for one transition - it will probably replace the generic matrix type data structure eventually, but as we need this for kbest type systems, we do it here %% struct TransitionSet Transition ** trans !list %info Data for an entire DP matrix- just being the transitions at the moment Sometime this - or something similar to this - will replace the generic matrix datastructure, but for the moment, this suffices! %% %{ #include "kbestsearch.h" %func Produces a kbest search type single score function kbest algorithm used here is that each cell is reduced to a single score + state number that it came from. The kbest heuristic is to provide only k paths onto the next position in the sequence. In our case we have k = length of model / number of states. This sort of kbest heurisitc is good because it cuts down on excessive book keeping of the alignments, by being able to store information of the state only %% void write_kbest_score_GenericMatrix(DYNFILE * dfp,GenericMatrix * gm,Scope * sc,MethodTypeSet * mts,DPImplementation * dpi) { char subexpr_buffer[MAXLINE]; int i,j; FuncInfo * fi; char * arg_str; char * chain_str; CommonSubExpressionSet * cses; cses = find_CommonSubExpressions(gm,TRUE); show_CommonSubExpressionSet(cses,stdout); for(j=0;jspec_len;j++) if( gm->special[j]->is_start == TRUE ) break; /*** prepare function information ***/ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"kbest_score_only_%s",gm->name); add_line_to_Ftext(fi->ft,"This function just calculates the score for the matrix",gm->name); add_line_to_Ftext(fi->ft,"It uses a kbest style algorithm to compute the score"); add_line_to_Ftext(fi->ft,"It calls /allocate_%s_only",gm->name); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"int kbest_score_only_%s(%s)",gm->name,arg_str); /*** clean up ***/ ckfree(arg_str); /*** into function body ***/ expr(dfp,"int bestscore = NEGI;"); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"%s * mat",gm->name); expr(dfp,"int * score_mat[%d];",gm->window_j+1); expr(dfp,"char * state_mat;",gm->window_j+1); expr(dfp,"int score_special[%d][%d];",gm->window_j+1,gm->spec_len); /** for the moment, ignore the possibility of static allocation */ if( 0 && gm->qtype != NULL && gm->qtype->maxlen != NULL) { expr(dfp,"int internal_matrix[%d][(%s+%d) * %d];",gm->window_j+1,gm->qtype->maxlen,gm->window_i,gm->len); expr(dfp,"int internal_specials[%d][%d];",gm->window_j+1,gm->spec_len); } if(0 && dpi->largemem == TRUE ) { expr(dfp,"int * internal_pointer_db;"); expr(dfp,"int * internal_special_db;"); } /** kbest optimisation stuff **/ if( dpi->dokbestcse == TRUE ) { for(i=0;ilen;i++) { expr(dfp,"int subexpr%d;",i); } } add_break(dfp); chain_str = get_chainstr_GenericMatrix(gm); expr(dfp,"mat = allocate_%s_only(%s);",gm->name,chain_str); ckfree(chain_str); expr(dfp,"if( mat == NULL )"); startbrace(dfp); warn_expr(dfp,"Memory allocation error in the db search - unable to communicate to calling function. this spells DISASTER!"); expr(dfp,"return NEGI"); closebrace(dfp); /* if(0 && gm->qtype != NULL && gm->qtype->maxlen != NULL) { add_block_comment(dfp,"Ok,don't need to allocate matrix as it is internal, because we have a max length"); } else { expr(dfp,"if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(%d,(mat->leni + %d)*2,%d,%d)) == NULL)",gm->window_j+1,gm->window_i,gm->window_j+1,gm->spec_len); startbrace(dfp); expr(dfp,"warn(\"Score only matrix for %s cannot be allocated, (asking for %d by %%d cells)\",mat->leni);",gm->name,gm->window_j); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return NEGI;"); closebrace(dfp); expr(dfp,"mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL;"); } */ add_block_comment(dfp,"Allocate memory for matrix"); expr(dfp,"for(j=0;j<%d;j++)",gm->window_j+1); startbrace(dfp); expr(dfp,"score_mat[j] = (int *) ckalloc (sizeof(int) * (mat->leni+%d));",gm->window_i); closebrace(dfp); expr(dfp,"state_mat = (char *) ckalloc (sizeof(char) * (mat->leni+%d)*%d *%d);",gm->window_i,gm->len,gm->window_j+1); add_break(dfp); add_block_comment(dfp,"Now, initiate matrix"); expr(dfp,"for(j=0;j<%d;j++)",gm->window_j+2); startbrace(dfp); expr(dfp,"for(i=(-%d);ileni;i++)",gm->window_i); startbrace(dfp); expr(dfp,"%s_KBEST_MATRIX_SCORE(mat,i,j,KBEST_SCORE) = NEGI;",gm->name); for(i=0;ispec_len;i++) { expr(dfp,"%s_KBEST_SPECIAL(mat,0,j,%s) = %s;",gm->name,gm->special[i]->name,gm->special[i]->def_score); } closebrace(dfp); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Ok, lets do-o-o-o-o it"); add_break(dfp); if( dpi->dokbestcse == TRUE ) { for(i=0;ilen;i++) { if( IS_NON_IJ_DEP_CSE(cses->cse[i]) ) { subexpr_buffer[0]='\0'; strcat_ExprTree_Scoped(cses->cse[i]->expr,subexpr_buffer,sc,mts,dpi->dycw,NULL,NULL); expr(dfp,"subexpr%d = %s;",i,subexpr_buffer); } } } expr(dfp,"for(j=0;jlenj;j++)"); startbrace_tag(dfp,"for all target positions"); expr(dfp,"auto int score"); expr(dfp,"auto int temp"); expr(dfp,"auto int state"); expr(dfp,"auto int temp_state"); if( dpi->dokbestcse == TRUE ) { for(i=0;ilen;i++) { if( IS_J_DEP_CSE(cses->cse[i]) == TRUE && IS_I_DEP_CSE(cses->cse[i]) == FALSE ) { subexpr_buffer[0]='\0'; strcat_ExprTree_Scoped(cses->cse[i]->expr,subexpr_buffer,sc,mts,dpi->dycw,NULL,NULL); expr(dfp,"subexpr%d = %s;",i,subexpr_buffer); } } } add_break(dfp); add_block_comment(dfp,"Initialise these specials"); for(i=0;ispec_len;i++) { expr(dfp,"%s_KBEST_SPECIAL(mat,0,j,%s) = %s;",gm->name,gm->special[i]->name,gm->special[i]->def_score); } expr(dfp,"for(i=0;ileni;i++)"); startbrace_tag(dfp,"for all query positions"); /** kbest cse optimisations **/ if( dpi->dokbestcse == TRUE ) { for(i=0;ilen;i++) { if( IS_J_DEP_CSE(cses->cse[i]) == TRUE && IS_I_DEP_CSE(cses->cse[i]) == TRUE ) { subexpr_buffer[0]='\0'; strcat_ExprTree_Scoped(cses->cse[i]->expr,subexpr_buffer,sc,mts,dpi->dycw,NULL,NULL); expr(dfp,"subexpr%d = %s;",i,subexpr_buffer); } } } write_kbest_block(dfp,gm,"KBEST_MATRIX","mat","KBEST_SPECIAL",TRUE,cses,mts,dpi); closebrace(dfp); add_break(dfp); write_special_block(dfp,gm,"KBEST_MATRIX","KBEST_SPECIAL","bestscore"); closebrace(dfp); add_break(dfp); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return bestscore;"); close_function(dfp); add_break(dfp); } %func Produces the actual kbest scoring inner loop %% void write_kbest_block(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointertag,char * specialtag,boolean use_special,CommonSubExpressionSet * cses,MethodTypeSet * mts,DPImplementation * dpi) { char buffer[MAXLINE]; register int i; register int j; register int k; TransitionSet * ts; int current_i_off; int current_j_off; ts = TransitionSet_from_GenericMatrix(gm); sort_TransitionSet_offset(ts); /* show_TransitionSet(ts,stderr); */ add_break(dfp); expr(dfp,"score = NEGI;"); expr(dfp,"state = 300;"); add_break(dfp); /* do switch statements from specials first */ for(k=0;klen && Transition_from_special(ts->trans[k]) == 1;k++) { if( ts->trans[k]->trans_type == TRANSITION_FROM_START ) { add_block_comment(dfp,"Source is the start state, and hence no need to look, must be 0"); expr(dfp,"temp = %s", ts->trans[k]->calc ); } else { expr(dfp,"temp = %s_KBEST_SPECIAL(mat,i-%d,j-%d,%s) + %s",gm->name, ts->trans[k]->offi, ts->trans[k]->offj, ts->trans[k]->from, ts->trans[k]->calc ); } expr(dfp,"if(temp > score)"); startbrace(dfp); expr(dfp,"score = temp;"); expr(dfp,"state = %s;",ts->trans[k]->to); closebrace(dfp); } /* do switch statements over the possibilities for each i,j offset */ for(;klen;) { current_i_off = ts->trans[k]->offi; current_j_off = ts->trans[k]->offj; expr(dfp,"switch ( %s_KBEST_MATRIX_STATE(mat,i-%d,j-%d,DUMMY_KBEST_STATE) )",gm->name,current_i_off,current_j_off); startbrace(dfp); for(;k < ts->len && ts->trans[k]->offi == current_i_off && ts->trans[k]->offj == current_j_off;k++) { expr(dfp,"case %s :",ts->trans[k]->from); startcase(dfp); if( dpi->dokbestcse == TRUE ) { buffer[0] = '\0'; strcat(buffer,"("); strcat_cses_ExprTree(ts->trans[k]->expr,buffer,gm->sc,mts,dpi); strcat(buffer,")"); if( ts->trans[k]->expr_state != NULL ) { strcat(buffer,"+ ("); strcat_cses_ExprTree(ts->trans[k]->expr_state,buffer,gm->sc,mts,dpi); strcat(buffer,")"); } expr(dfp,"temp = %s;",buffer); } else { expr(dfp,"temp = %s;",ts->trans[k]->calc); } expr(dfp,"temp_state = %s;",ts->trans[k]->to); expr(dfp,"break;"); closecase(dfp); } expr(dfp,"default :"); startcase(dfp); expr(dfp,"temp = NEGI;"); expr(dfp,"temp_state = (200);"); expr(dfp,"break;"); closecase(dfp); closebrace(dfp); /* close switch statement */ add_break(dfp); expr(dfp,"if( temp > NEGI )"); startbrace(dfp); expr(dfp,"temp += %s_KBEST_MATRIX_SCORE(mat,i-%d,j-%d,KBEST_SCORE);",gm->name,current_i_off,current_j_off); expr(dfp,"if( temp > score )"); startbrace(dfp); expr(dfp,"score = temp;"); expr(dfp,"state = temp_state;"); closebrace(dfp); closebrace(dfp); add_break(dfp); } expr(dfp,"%s_KBEST_MATRIX_SCORE(mat,i,j,KBEST_SCORE) = score;",gm->name); expr(dfp,"%s_KBEST_MATRIX_STATE(mat,i,j,KBEST_STATE) = state;",gm->name); add_break(dfp); add_block_comment(dfp,"Now do any potential main to special movements"); for(i=0;ispec_len;i++) { for(j=0;jspecial[i]->len;j++) { if( gm->special[i]->source[j]->isspecial == FALSE ) { expr(dfp,"if( state == %s)",gm->special[i]->source[j]->state_source); startbrace(dfp); expr(dfp,"temp = score + (%s) + (%s);", gm->special[i]->source[j]->calc_expr, gm->special[i]->calc_expr == NULL ? "0" : gm->special[i]->calc_expr); expr(dfp,"if( temp > %s_KBEST_SPECIAL(mat,i,j,%s) )",gm->name,gm->special[i]->name); hang_expr(dfp,"%s_KBEST_SPECIAL(mat,i,j,%s) = temp;",gm->name,gm->special[i]->name); closebrace(dfp); } } } } %func Makes a transition set from a generic matrix %% TransitionSet * TransitionSet_from_GenericMatrix(GenericMatrix * gm) { TransitionSet *out; int i,j,k; Transition * trans; char buffer[1024]; out = TransitionSet_alloc_std(); for(i=0;ilen;i++) for(j=0;jstate[i]->len;j++) { trans = Transition_alloc(); trans->offi = gm->state[i]->source[j]->offi; trans->offj = gm->state[i]->source[j]->offj; trans->to = stringalloc(gm->state[i]->name); trans->from = stringalloc(gm->state[i]->source[j]->state_source); trans->expr = gm->state[i]->source[j]->etr; trans->expr_state = gm->state[i]->etr; /* if it is from a special, see if it is from start */ if( gm->state[i]->source[j]->isspecial ) { /* this is painful, but because I hadn't got the previous data structure right! */ for(k=0;kspec_len;k++) { if( gm->special[k]->is_start == TRUE && strcmp(gm->state[i]->source[j]->state_source,gm->special[k]->name) == 0) { trans->trans_type = TRANSITION_FROM_START; break; } } if( k == gm->spec_len ) { trans->trans_type = TRANSITION_FROM_SPECIAL; } } if( gm->state[i]->calc_expr != NULL ) { sprintf(buffer,"(%s) + (%s)",gm->state[i]->source[j]->calc_expr,gm->state[i]->calc_expr); } else { sprintf(buffer,"%s",gm->state[i]->source[j]->calc_expr); } trans->calc = stringalloc(buffer); add_TransitionSet(out,trans); } return out; } %func sees whether the generic matrix is suitable for kbest optimisations %% boolean can_kbest_GenericMatrix(GenericMatrix * gm) { int i,j; int k,l; /* have to find cases in which the source,i,j is the same twice */ for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; for(j=0;jlen;j++) { /* now loop over all other transitions in this state */ for(l=j+1;llen;l++) if( state->source[j]->offi == state->source[l]->offi && state->source[j]->offj == state->source[l]->offj && strcmp(state->source[j]->state_source,state->source[l]->state_source) == 0 ) return FALSE; /* now loop over all other states */ for(k=i+1;klen;k++) { for(l=0;lstate[k]->len;l++) if( state->source[j]->offi == gm->state[k]->source[l]->offi && state->source[j]->offj == gm->state[k]->source[l]->offj && strcmp(state->source[j]->state_source,gm->state[k]->source[l]->state_source) == 0 ) return FALSE; }/* all other states */ } /* all transitions in this particular i'th state */ }/* all states */ return TRUE; } %func Sorts by offi then offj %% void sort_TransitionSet_offset(TransitionSet * ts) { sort_TransitionSet(ts,comp_Transition); } %func comparison by offi/offj %% int comp_Transition(Transition * two,Transition * one) { if( Transition_from_special(one) != Transition_from_special(two) ) { if( Transition_from_special(two) ) { return -1; } else { return 1; } } if( one->offi == two->offi ) { return one->offj - two->offj; } return one->offi - two->offi; } %func Shows a transition set %% void show_TransitionSet(TransitionSet * tset,FILE * ofp) { int i; for(i=0;ilen;i++) show_Transition(tset->trans[i],ofp); } %func Shows a transition %type internal %% void show_Transition(Transition * trans,FILE * ofp) { fprintf(ofp,"Transition [%s %d %d %s]\n",trans->from,trans->offi,trans->offj,trans->to); fprintf(ofp," calc %s\n",trans->calc); } wise-2.4.1/src/dyc/dbmpi.c0000644000175000001440000003313610670453715014674 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dbmpi.h" /* Function: write_MPI_master_loop(dfp,dpi,gm) * * Descrip: The master mpi process loop. * * The essential idea here is that there is a queue of processes waiting * for jobs; they indicate their readiness by sending a message to the master. * The master then reads in the score (if necessary), and sends off a job to * the slave (if there are more jobs to be done). * * Here is the pseudo code: * * check number of processes, and allocate space for (n-1) datascore objects * * initialize the databases * * forever { * * Receive a message * if the message contains data * process it * * if there are no more jobs to be done * send a message to the slave, telling it to die * * if all the slaves have been notified * Terminate MPI and return. * * if we have not done everything * Pack data, and dispatch; do bookkeeping, reload next target * } * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 45 "dbmpi.dy" boolean write_MPI_master_loop(DYNFILE * dfp,DPImplementation * dpi,GenericMatrix * gm) { FuncInfo * fi; boolean tdb = FALSE; boolean qdb = FALSE; char buffer[MAXLINE]; int i; if( gm->qtype != NULL && gm->qtype->is_database == TRUE) qdb = TRUE; if( gm->ttype != NULL && gm->ttype->is_database == TRUE) tdb = TRUE; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"MPI_master_loop_%s",gm->name); add_line_to_Ftext(fi->ft,"Infinite loop code for MPI master for %s",gm->name); if (qdb == FALSE || tdb == FALSE) { warn("Currently no way of dealing with non-databased calls in MPI"); return FALSE; } macro(dfp,"#ifdef MPI"); if (qdb == TRUE) sprintf(buffer,"Search_Return_Type MPI_master_loop_%s(Hscore *out, %s querydb,", gm->name, gm->qtype->database_type); else sprintf(buffer,"Search_Return_Type MPI_master_loop_%s(Hscore *out, %s %s,", gm->name, gm->query->element_type, gm->query->name); if (tdb == TRUE) { strcat(buffer,gm->ttype->database_type); strcat(buffer," targetdb "); } else { strcat(buffer,gm->target->element_type); strcat(buffer," "); strcat(buffer,gm->target->name); strcat(buffer," "); } for (i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,gm->resource[i]->element_type); strcat(buffer," "); strcat(buffer,gm->resource[i]->name); } strcat(buffer,")"); start_function_FuncInfo(fi,dfp,buffer); if (qdb == TRUE) expr(dfp,"%s %s",gm->query->element_type,gm->query->name); if (tdb == TRUE) expr(dfp,"%s %s",gm->target->element_type,gm->target->name); expr(dfp, "int db_status;"); expr(dfp, "Score score;"); expr(dfp, "DataScore ** ds_arr;"); expr(dfp, "int done_targets = 0;"); expr(dfp, "int done_queries = 0;"); expr(dfp, "int all_done = 0;"); add_break(dfp); expr(dfp, "int slave_nr;"); expr(dfp, "int i, j;"); expr(dfp, "int size;"); expr(dfp, "int *working_arr;"); expr(dfp, "MPI_Status status;"); expr(dfp, "size_t buflen;"); expr(dfp, "char *buf;"); expr(dfp, "char *buforig;"); add_break(dfp); add_block_comment(dfp, "Init"); expr(dfp, "MPI_Comm_size(MPI_COMM_WORLD, &size);"); expr(dfp, "ds_arr = ckcalloc(1,sizeof(DataScore*) * size);"); expr(dfp, "working_arr = ckcalloc(1,sizeof(int) * size);"); add_break(dfp); /* FIXME: non-databased calls */ if (qdb == TRUE) { expr(dfp, "%s = %s(querydb, &db_status);", gm->query->name, gm->qtype->init_func); expr(dfp, "if(db_status == DB_RETURN_ERROR)"); hang_expr(dfp, "return SEARCH_ERROR;"); } else { warn("Don't yet know how to deal with non-databased MPI"); } if (tdb == TRUE) { expr(dfp, "%s = %s(targetdb, &db_status);", gm->target->name, gm->ttype->init_func); expr(dfp, "if(db_status == DB_RETURN_ERROR)"); hang_expr(dfp, "return SEARCH_ERROR;"); } else { warn("Don't yet know how to deal with non-databased MPI"); } expr(dfp, "for(;;)"); startbrace(dfp); expr(dfp, "MPI_Recv(&score, sizeof(Score), MPI_BYTE, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);"); expr(dfp, "slave_nr = status.MPI_SOURCE"); expr(dfp, "info(\"received(%%d). score = %%d\\n\", slave_nr, score);"); add_block_comment(dfp, "bookkeeping"); expr(dfp, "working_arr[slave_nr] = 0;"); expr(dfp, "switch (status.MPI_TAG)"); startbrace_tag(dfp, "What we do is based on what the tag of the message was"); expr(dfp, "case MPI_DATA_TAG :"); startcase(dfp); add_block_comment(dfp, "process incoming data"); expr(dfp, "if (should_store_Hscore(out,score) == TRUE)"); startbrace(dfp); expr(dfp, "info(\"saving score(%%d)\", score);"); expr(dfp, "ds_arr[slave_nr]->score = score;"); expr(dfp, "add_Hscore(out,ds_arr[slave_nr]);"); closebrace(dfp); expr(dfp, "else"); startbrace(dfp); expr(dfp, "free_DataScore(ds_arr[slave_nr]);"); closebrace(dfp); /* Fall through. This is not an error */ add_block_comment(dfp, "We fall through here, since the next case is for sending data out only."); closecase(dfp); expr(dfp, "case MPI_READY_TAG :"); startcase(dfp); expr(dfp, "if (!done_queries)"); startbrace(dfp); expr(dfp, "if (done_targets)"); startbrace_tag(dfp, "so get next query object"); if (qdb == TRUE) { expr(dfp, "%s = %s(%s,querydb,&db_status);", gm->query->name, gm->qtype->reload_func, gm->query->name); expr(dfp, "if( db_status == DB_RETURN_ERROR)"); hang_expr(dfp, "return SEARCH_ERROR;"); expr(dfp, "if( db_status == DB_RETURN_END )"); startbrace(dfp); expr(dfp, "info(\"no more queries\");"); expr(dfp, "done_queries=1;"); expr(dfp, "%s(%s,querydb);", gm->qtype->close_func, gm->query->name); closebrace(dfp); expr(dfp, "else"); startbrace_tag(dfp, "need new targets"); expr(dfp, "%s = %s(targetdb,&db_status);", gm->target->name, gm->ttype->init_func); expr(dfp, "if (db_status == DB_RETURN_ERROR)"); hang_expr(dfp, "return SEARCH_ERROR"); expr(dfp, "done_targets = 0;"); closebrace(dfp); } else { warn("Don't yet know how to deal with non-databased MPI"); } closebrace(dfp); add_block_comment(dfp, "if (done_targets)"); closebrace(dfp); add_block_comment(dfp, "if (!done_queries)"); add_break(dfp); expr(dfp, "if (done_queries)"); startbrace(dfp); expr(dfp, "info(\"sending dietag2 to %%d\", slave_nr);"); expr(dfp, "MPI_Send(NULL, 0, MPI_BYTE, slave_nr, MPI_DIE_TAG, MPI_COMM_WORLD);"); add_break(dfp); expr(dfp, "working_arr[slave_nr] = 0;"); expr(dfp, "all_done = 1;"); expr(dfp, "for (i=1; iquery,%s,querydb);", gm->qtype->dataentry_add, gm->query->name); expr(dfp, "%s(ds_arr[slave_nr]->target,%s,targetdb);", gm->ttype->dataentry_add, gm->target->name); add_block_comment(dfp, "Send job"); /* FIXME -- this won't work for gm->qtype = NULL */ if ((gm->qtype != NULL) && (gm->ttype != NULL)) { expr(dfp, "buflen = %s(%s) + %s(%s);", gm->qtype->buf_len_func, gm->query->name, gm->ttype->buf_len_func, gm->target->name); /* FIXME -- should reuse static buffer to reduce memory fragmentation */ expr(dfp, "buf = buforig = ckalloc(buflen);"); expr(dfp, "buf = %s(buf, %s);", gm->qtype->pack_func, gm->query->name); expr(dfp, "buf = %s(buf, %s);", gm->ttype->pack_func, gm->target->name); } expr(dfp, "MPI_Send(&buflen, sizeof(size_t), MPI_BYTE, slave_nr, MPI_WORK_TAG, MPI_COMM_WORLD);"); expr(dfp, "MPI_Send(buforig, buflen, MPI_BYTE, slave_nr, MPI_WORK_TAG, MPI_COMM_WORLD);"); expr(dfp, "ckfree(buforig);"); add_block_comment(dfp, "bookkeeping"); /* FIXME -- here, and elsewhere, this should really be boolean */ expr(dfp, "working_arr[slave_nr] = 1;"); add_break(dfp); expr(dfp, "info(\"loading target obj\");"); if (tdb == TRUE) { expr(dfp, "%s = %s(%s,targetdb,&db_status);", gm->target->name, gm->ttype->reload_func, gm->target->name); expr(dfp, "if(db_status == DB_RETURN_ERROR)"); hang_expr(dfp, "return SEARCH_ERROR;"); expr(dfp, "if(db_status == DB_RETURN_END)"); startbrace(dfp); expr(dfp, "%s(%s,targetdb);", gm->ttype->close_func, gm->target->name); expr(dfp, "done_targets = 1;"); closebrace(dfp); } else { warn("Don't yet know how to deal with non-databased MPI"); } expr(dfp, "break;"); closecase(dfp); expr(dfp, "default :"); startcase(dfp); expr(dfp, "fatal(\"Oops. Invalid MPI tag received. Blammo.\");"); expr(dfp, "break;"); closecase(dfp); closebrace(dfp); add_block_comment(dfp, "switch(status.MPI_TAG)"); closebrace(dfp); add_block_comment(dfp, "for (;;)"); close_function(dfp); macro(dfp, "#endif /* MPI */"); return TRUE; } # line 282 "dbmpi.dy" boolean write_MPI_slave_loop(DYNFILE * dfp,DPImplementation * dpi,GenericMatrix * gm) { FuncInfo * fi; boolean qdb = FALSE; boolean tdb = FALSE; char buffer[MAXLINE]; int i; if( gm->qtype != NULL && gm->qtype->is_database == TRUE) qdb = TRUE; if( gm->ttype != NULL && gm->ttype->is_database == TRUE) tdb = TRUE; if ((qdb == FALSE) || (tdb == FALSE)) { warn("Currently no way of dealing with non-databased calls in MPI"); return FALSE; } fi = FuncInfo_named_from_varstr(FI_INTERNAL,"MPI_slave_loop_%s",gm->name); add_line_to_Ftext(fi->ft,"Infinite loop code for MPI slave for %s",gm->name); macro(dfp,"#ifdef MPI"); sprintf(buffer,"Search_Return_Type MPI_slave_loop_%s(generic_search_%s routine", gm->name, gm->name); for (i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,gm->resource[i]->element_type); strcat(buffer," "); strcat(buffer,gm->resource[i]->name); } strcat(buffer,")"); start_function_FuncInfo(fi,dfp,buffer); /* FIXME: What if gm->query->element_type is not a pointer */ expr(dfp,"%s %s = NULL",gm->query->element_type,gm->query->name); expr(dfp,"%s %s = NULL",gm->target->element_type,gm->target->name); expr(dfp, "char *buf;"); expr(dfp, "char *buforig;"); expr(dfp, "Score score;"); expr(dfp, "size_t buflen, tmp;"); expr(dfp, "int data_offset;"); expr(dfp, "int i, j;"); expr(dfp, "MPI_Status status;"); add_break(dfp); add_block_comment(dfp, "allocate some of the structures"); /* This is almost certainly not right (explicitly calling the thing Sequence, that is */ expr(dfp, "buflen = DEFAULT_BUF_LEN;"); expr(dfp, "buforig = buf = ckcalloc(1,buflen);"); add_break(dfp); add_block_comment(dfp, "Initial Send"); expr(dfp, "MPI_Send(NULL, 0, MPI_BYTE, 0, MPI_READY_TAG, MPI_COMM_WORLD);"); add_break(dfp); expr(dfp, "while(1)"); startbrace(dfp); expr(dfp, "buf = buforig;"); add_block_comment(dfp, "get job from master (0) process"); expr(dfp, "MPI_Recv(buf, sizeof(size_t), MPI_BYTE, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &status);"); add_block_comment(dfp, "if MPI_DIE_TAG, break and wait for barrier, then exit"); expr(dfp, "switch(status.MPI_TAG)"); startbrace(dfp); expr(dfp, "case MPI_WORK_TAG :"); startcase(dfp); expr(dfp, "tmp = *((int*)buf);"); expr(dfp, "if (tmp > buflen)"); startbrace(dfp); expr(dfp, "buflen = tmp;"); add_block_comment(dfp, "reallocate"); expr(dfp, "ckfree(buforig);"); expr(dfp, "buforig = buf = ckcalloc(1,buflen);"); closebrace(dfp); expr(dfp, "MPI_Recv(buf, buflen, MPI_BYTE, 0, MPI_WORK_TAG, MPI_COMM_WORLD, &status);"); add_break(dfp); if(gm->qtype != NULL) { expr(dfp, "buf = %s(buf, &%s);", gm->qtype->unpack_func, gm->query->name); } else { expr(dfp, "info(\"This really isn't going to work -- don't try\");"); } if(gm->ttype != NULL) { expr(dfp, "buf = %s(buf, &%s);", gm->ttype->unpack_func, gm->target->name); } else { expr(dfp, "info(\"This really isn't going to work -- don't try\");"); } add_break(dfp); add_block_comment(dfp, "Actually do the work"); sprintf(buffer, "score = (*routine)(%s, %s", gm->query->name, gm->target->name); for (i=0;ires_len;i++) { strcat(buffer,", "); strcat(buffer,gm->resource[i]->name); } strcat(buffer,")"); expr(dfp, buffer); expr(dfp, "MPI_Send(&score, sizeof(Score), MPI_BYTE, 0, MPI_DATA_TAG, MPI_COMM_WORLD);"); expr(dfp, "break;"); closecase(dfp); expr(dfp, "case MPI_DIE_TAG :"); startcase(dfp); expr(dfp, "info(\"got dietag\");"); expr(dfp, "if (NULL != %s) %s(%s);", gm->query->name, gm->qtype->free_func, gm->query->name); expr(dfp, "if (NULL != %s) %s(%s);", gm->target->name, gm->ttype->free_func, gm->target->name); expr(dfp, "ckfree(buforig);"); expr(dfp, "return SEARCH_OK;"); closecase(dfp); expr(dfp, "default :"); startcase(dfp); add_block_comment(dfp, "Ooo. This is really bad if we get to here"); expr(dfp, "return SEARCH_ERROR;"); closecase(dfp); closebrace(dfp); closebrace(dfp); close_function(dfp); macro(dfp, "#endif /* MPI */"); return TRUE; } # line 419 "dbmpi.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/dbmpi.h0000644000175000001440000000440510670453715014676 0ustar philippusers#ifndef DYNAMITEdbmpiHEADERFILE #define DYNAMITEdbmpiHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna2.h" #include "dpimpl.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: write_MPI_master_loop(dfp,dpi,gm) * * Descrip: The master mpi process loop. * * The essential idea here is that there is a queue of processes waiting * for jobs; they indicate their readiness by sending a message to the master. * The master then reads in the score (if necessary), and sends off a job to * the slave (if there are more jobs to be done). * * Here is the pseudo code: * * check number of processes, and allocate space for (n-1) datascore objects * * initialize the databases * * forever { * * Receive a message * if the message contains data * process it * * if there are no more jobs to be done * send a message to the slave, telling it to die * * if all the slaves have been notified * Terminate MPI and return. * * if we have not done everything * Pack data, and dispatch; do bookkeeping, reload next target * } * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean write_MPI_master_loop(DYNFILE * dfp,DPImplementation * dpi,GenericMatrix * gm); /* Unplaced functions */ /* There has been no indication of the use of these functions */ boolean write_MPI_slave_loop(DYNFILE * dfp,DPImplementation * dpi,GenericMatrix * gm); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/linkmap.dy0000644000175000001440000000243007313404534015412 0ustar philippusers %{ #include "wisebase.h" %} struct LinkMap char * word char * urltail char * text struct LinkSet LinkMap ** lm !list %{ #include "linkmap.h" char * update_links_LinkMap(char * line,char * startid,char * stopid,char * nolinkstr,LinkSet * ls) { char buffer[MAXLINE]; char * run; char c; char * end; LinkMap * lm; for(end=line,run=line;(run = strstr(run,startid)) != NULL;) { /*** strcat the previous string ***/ c = *run; *run = '\0'; strcat(buffer,end); /*** now put in the link system ***/ end = strstr(run,stopid); c = *end; *end = '\0'; if( (lm = LinkMap_from_word(run,ls)) == NULL ) { } } } LinkMap * new_std_LinkMap(char * word,char * urlstub,char * textstub) { char buffer[128]; char * run; LinkMap * out; out= LinkMap_alloc(); push_scan_and_replace_pair("$LINK",word); strcpy(buffer,urlstub); run = scan_and_replace_line(buffer); out->urltail = stringalloc(run); strcpy(buffer,textstub); run = scan_and_replace_line(buffer); out->text = stringalloc(textstub); pop_scan_and_replace_pair(); return out; } LinkMap * LinkMap_from_word(char * word,LinkSet * ls) { int i; for(i=0;ilen;i++) { if( strcmp(ls->lm[i]->word,word) == 0 ) return lm[i]; } return NULL; } wise-2.4.1/src/dyc/display.c0000644000175000001440000020304610670453715015245 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "display.h" # line 97 "display.dy" void write_Aln2Display_header(DYNFILE * dfp,Aln2Display * a2d) { return; } # line 103 "display.dy" void write_Aln2Display_function(DYNFILE * dfp,Aln2Display * a2d) { write_Aln2Display_convert_func(dfp,a2d); } # line 111 "display.dy" void write_Aln2Display_convert_func(DYNFILE * dfp,Aln2Display * a2d) { register int i; register int j; register int k; char buffer[MAXLINE]; /*** assume file is already loaded into writec ***/ sprintf(buffer,"AlnDisplay * convert_AlnBlock_to_AlnDisplay_%s(AlnBlock * alb ",a2d->name); for(i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,a2d->a2dr[i]->type); strcat(buffer,a2d->a2dr[i]->name); } strcat(buffer,")"); start_function(dfp,buffer); expr(dfp,"AlnDisplay * out"); expr(dfp,"AlnDisplayColumn * adc;"); expr(dfp,"AlnDisplayUnit * adu;"); expr(dfp,"AlnDisplayField * adf;"); expr(dfp,"AlnDisplayNameBlock * adnb;"); expr(dfp,"AlnDisplayNameUnit * adnu;"); expr(dfp,"AlnIndexField * aif;"); expr(dfp,"AlnDisplayIndexUnit * adiu;"); expr(dfp,"AlnDisplayIndex * adi;"); expr(dfp,"AlnColumn * alc;"); expr(dfp,"AlnUnit * alu;"); expr(dfp,"char tempbuf[512]"); add_break(dfp); expr(dfp,"out = new_AlnDisplay(alb->len)"); add_break(dfp); for(i=0;ilen;i++) { expr(dfp,"adnb = AlnDisplayNameBlock_no_get(out,%d);",i); expr(dfp,"adnb->direction = ALN_DISPLAY_%s",a2d->s2d[i]->direction); expr(dfp,"adnu = get_next_AlnDisplayNameUnit(adnb);"); if( a2d->s2d[i]->name_str != NULL) { expr(dfp,"adnu->name = %s;",a2d->s2d[i]->name_str); expr(dfp,"adnu->should_free = %s;",a2d->s2d[i]->is_static == TRUE ? "FALSE" : "TRUE"); } else { expr(dfp,"adnu->name = \"NoName\";"); expr(dfp,"adnu->should_free = FALSE;"); } if( a2d->s2d[i]->ind_len > 0 ) { /* get the index */ add_break(dfp); add_block_comment(dfp,"This sequence has got an index, get the alndisplayindex"); expr(dfp,"adi = AlnDisplayIndex_no_get(out,%d);",i); expr(dfp,"adi->direction = ALN_DISPLAY_%s",a2d->s2d[i]->direction); for(j=0;j< a2d->s2d[i]->ind_len;j++) { auto Index2Display * i2d; i2d = a2d->s2d[i]->i2d[j]; expr(dfp,"adiu = get_next_AlnDisplayIndexUnit(adi);"); expr(dfp,"adiu->start = %s",i2d->eval == NULL ? "0" : i2d->eval); add_break(dfp); } } /* end of if index*/ } /* end of for */ expr(dfp,"for(alc = alb->start;alc != NULL;alc = alc->next)"); startbrace_tag(dfp,"all columns in AlnBlock"); expr(dfp,"adc = new_terminal_AlnDisplayColumn(out);"); /*** go over each sequence, and move the labels across ***/ for(i=0;ilen;i++) { j = 0; expr(dfp,"adu = AlnDisplayUnit_no_get(adc,%d)",i); expr(dfp,"alu = alc->alu[%d]",i); /*** start of the labels ***/ for(j=0;js2d[i]->len;j++) { expr(dfp,"%s if(alu->text_label != NULL && strcmp(alu->text_label,\"%s\") == 0) ",j == 0 ? "" : "else",a2d->s2d[i]->l2d[j]->label); startbrace_tag(dfp,"if this label"); /*** add the index if it is there ***/ for(k=0;ks2d[i]->l2d[j]->ind_len;k++) { expr(dfp,"aif = get_next_AlnIndexField(adu)"); expr(dfp,"aif->index_no = %d;",a2d->s2d[i]->l2d[j]->i2d[k]->number); expr(dfp,"aif->length = %s;",a2d->s2d[i]->l2d[j]->i2d[k]->eval); } if(a2d->s2d[i]->l2d[j]->is_lone == TRUE ) { expr(dfp,"adc->is_lone = TRUE;"); } expr(dfp,"adu->direction = ALN_DISPLAY_%s;",a2d->s2d[i]->l2d[j]->direction == NULL ? "DOWN" : a2d->s2d[i]->l2d[j]->direction); for(k=0;ks2d[i]->l2d[j]->len;k++) { auto Aln2DisplayField * a2df; a2df = a2d->s2d[i]->l2d[j]->a2df[k]; expr(dfp,"adf = get_next_AlnDisplayField(adu);"); if( a2df->is_sub == TRUE ) { expr(dfp,"sprintf(tempbuf,\"%%d\",alu->start);"); expr(dfp,"push_scan_and_replace_pair(\"%%START\",tempbuf);"); expr(dfp,"sprintf(tempbuf,\"%%d\",alu->end);"); expr(dfp,"push_scan_and_replace_pair(\"%%END\",tempbuf);"); } if( a2df->is_string == TRUE ) expr(dfp,"adf->characters = \"%s\";",a2df->string); else if( a2df->is_single == TRUE ) expr(dfp,"adf->single = %s;",a2df->string); else if( a2df->is_sub == TRUE) { expr(dfp,"strcpy(tempbuf,\"%s\");",a2df->string); expr(dfp,"adf->characters = stringalloc(scan_and_replace_line(tempbuf))"); expr(dfp,"pop_scan_and_replace_pair();"); expr(dfp,"pop_scan_and_replace_pair();"); } else expr(dfp,"adf->characters = %s",a2df->string); if( a2df->is_sub == TRUE ) expr(dfp,"adf->length = strlen(adf->characters)"); else expr(dfp,"adf->length = %s",a2df->length == NULL ? "1" : a2df->length); expr(dfp,"adf->direction = ALN_DISPLAY_%s",a2df->direction == NULL ? "RIGHT" : a2df->direction); expr(dfp,"adf->should_free = %s",a2df->is_static == TRUE ? "FALSE" : "TRUE"); if( a2df->convert != NULL ) expr(dfp,"adf->convert_func = %s;",a2df->convert); } closebrace(dfp); } expr(dfp,"else "); startbrace(dfp); expr(dfp,"warn(\"In AlnBlock to AlnDisplay %s, got unintretable label [%%s] for sequence %d\",alc->alu[%d]->text_label);",a2d->name,i,i); expr(dfp,"adf = get_next_AlnDisplayField(adu);"); expr(dfp,"adf->characters = \"?\";"); expr(dfp,"adf->length = 1"); expr(dfp,"adf->direction = ALN_DISPLAY_RIGHT"); expr(dfp,"adf->should_free = FALSE"); closebrace(dfp); } closebrace(dfp); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } /*************************/ /* Access/checking func */ /*************************/ # line 278 "display.dy" boolean prepare_Aln2Display(Aln2Display * a2d) { boolean ret = TRUE; number_up_Sequence_Index2Display(a2d); if( crosslink_Index(a2d) == FALSE ){ warn("Unable to crosslink Display %s: probably you have not got one of the indexes in the sequence block",a2d->name); ret = FALSE; } return ret; } # line 295 "display.dy" void number_up_Sequence_Index2Display(Aln2Display * a2d) { register int i; register int j; for(i=0;ilen;i++) for(j=0;js2d[i]->ind_len;j++) a2d->s2d[i]->i2d[j]->number = j; } # line 305 "display.dy" boolean crosslink_Index(Aln2Display * a2d) { register int i; register int j; boolean ret = TRUE; for(i=0;ilen;i++) for(j=0;js2d[i]->len;j++) { if( crosslink_Label2Display_Index(a2d->s2d[i]->l2d[j],a2d->s2d[i]) == FALSE ) ret = FALSE; } return ret; } # line 323 "display.dy" boolean crosslink_Label2Display_Index(Label2Display * l2d,Sequence2Display * s2d) { register int i; Index2Display * temp; boolean ret = TRUE; for(i=0;iind_len;i++) { temp = Index2Display_from_name(s2d,l2d->i2d[i]->name); if( temp == NULL ) { warn("In Label %s of Sequence number %d, could not crosslink index name %s",l2d->label,s2d->number,l2d->i2d[i]->name); ret = FALSE; } else l2d->i2d[i]->number = temp->number; } return ret; } # line 342 "display.dy" Index2Display * Index2Display_from_name(Sequence2Display * s2d,char * name) { register int i; for(i=0;iind_len;i++) { if( strcmp(s2d->i2d[i]->name,name) == 0 ) return s2d->i2d[i]; } return NULL; } /**************************/ /* I/O functions */ /**************************/ # line 364 "display.dy" Aln2Display * read_Aln2Display_line(char * line,FILE * ifp) { Sequence2Display * temp; Aln2DisplayResource * tempres; Aln2Display * out; char buffer[MAXLINE]; char * runner; runner = strtok(line,spacestr); if( runner == NULL ) { warn("In read_Aln2Display_line, got completely blank line!"); return NULL; } if( strcmp(runner,"display") != 0 ) { warn("In read_Aln2Display_line, got non display line... [%s]",line); return NULL; } runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("In read_Sequence2Display_line, got no display name... cannot process!"); return NULL; } out = Aln2Display_alloc_std(); if( out == NULL) return NULL; out->name = stringalloc(runner); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strwhitestartcmp(buffer,"enddisplay",spacestr) == 0 ) break; if( strwhitestartcmp(buffer,"sequence",spacestr) == 0 ) { temp = read_Sequence2Display_line(buffer,ifp); if( temp == NULL ) warn("In display number %d.. got bad sequence",out->name); else add_Aln2Display(out,temp); } else if ( strwhitestartcmp(buffer,"resource",spacestr) == 0 ) { tempres = read_Aln2DisplayResource_line(buffer); if( tempres == NULL ) warn("In display %s.. got bad resource",out->name); else add_res_Aln2Display(out,tempres); } else { warn("In aln2display read.. got uninterpretable line [%s]",buffer); } } return out; } # line 423 "display.dy" Sequence2Display * read_Sequence2Display_line(char * line,FILE * ifp) { Sequence2Display * out; Label2Display * temp; Index2Display * ind; char buffer[MAXLINE]; char * runner; runner = strtok(line,spacestr); if( runner == NULL ) { warn("In read_Label2Display_line, got completely blank line!"); return NULL; } if( strcmp(runner,"sequence") != 0 ) { warn("In read_Sequecne2Display_line, got non sequence line... [%s]",line); return NULL; } runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("In read_Sequence2Display_line, got no sequence number... cannot process!"); return NULL; } out = Sequence2Display_alloc_std(); if( out == NULL) return NULL; if( strcmp(runner,"ALLOTHERS") == 0) out->number = ALL_OTHER_NUMBER; else out->number = atoi(runner); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strwhitestartcmp(buffer,"endsequence",spacestr) == 0 ) break; else if( strwhitestartcmp(buffer,"name",spacestr) == 0 ) read_name_line(out,buffer); else if( strwhitestartcmp(buffer,"label",spacestr) == 0 ) { temp = read_Label2Display_line(buffer,ifp); if( temp == NULL ) warn("In sequence number %d.. got bad label",out->number); else add_Sequence2Display(out,temp); } else if ( strwhitestartcmp(buffer,"index",spacestr) == 0 ) { ind = read_Index2Display_line(buffer); if( ind == NULL ) warn("In sequence number %d, unable to read Index line ",out->number); else add_ind_Sequence2Display(out,ind); } else { warn("In sequence2display.. got uninterpretable line [%s]",buffer); } } return out; } # line 486 "display.dy" Label2Display * read_Label2Display_line(char * line,FILE * ifp) { Label2Display * out; Aln2DisplayField * temp; Index2Display * ind; char * runner; char buffer[MAXLINE]; runner = strtok(line,spacestr); if( runner == NULL ) { warn("In read_Label2Display_line, got completely blank line!"); return NULL; } if( strcmp(runner,"label") != 0 ) { warn("In read_Label2Display_line, got non label line... [%s]",line); return NULL; } runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("In read_Label2Display_line, got no label name... cannot process!"); return NULL; } out = Label2Display_alloc_std(); if( out == NULL) return NULL; out->label = stringalloc(runner); runner = strtok(NULL,spacestr); while( runner != NULL ) { if( strcmp(runner,"!lone") == 0 ) { out->is_lone = TRUE; } else { warn("Could not understand label modifier %s",runner); } runner = strtok(NULL,spacestr); } while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strwhitestartcmp(buffer,"endlabel",spacestr) == 0) break; if( strwhitestartcmp(buffer,"field",spacestr) == 0 ) { temp = read_Aln2DisplayField_line(buffer,ifp); if( temp == NULL ) warn("In label %s, unable to read field lines...",out->label); else add_Label2Display(out,temp); } else if( strwhitestartcmp(buffer,"index",spacestr) == 0 ) { ind = read_Index2Display_line(buffer); if( ind == NULL ) warn("In label %s, unable to read Index line ",out->label); else add_ind_Label2Display(out,ind); } else if( strwhitestartcmp(buffer,"direction",spacestr) == 0 ) { runner = strtok(buffer,spacestr); out->direction = string_from_quoted_equality(runner); } else { warn("In reading label [%s], unable to interpret [%s]",out->label,buffer); } } return out; } # line 569 "display.dy" Aln2DisplayField * read_Aln2DisplayField_line(char * line,FILE * ifp) { Aln2DisplayField * out; char ** base; char ** bkstr; char buffer[MAXLINE]; out = Aln2DisplayField_alloc(); if( out == NULL) return NULL; base = bkstr = breakstring(line,spacestr); for(bkstr++;*bkstr != NULL;bkstr++) { put_away_Aln2DisplayField_strpair(out,*bkstr); } ckfree(base); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '#') continue; if( strwhitestartcmp(buffer,"endfield",spacestr) == 0) break; base = bkstr = breakstring(buffer,spacestr); for(;*bkstr != NULL;bkstr++) { put_away_Aln2DisplayField_strpair(out,*bkstr); } ckfree(base); } return out; } # line 608 "display.dy" boolean read_name_line(Sequence2Display * s2d,char * name_line) { char ** base; char ** bkstr; if( strwhitestartcmp(name_line,"name",spacestr) != 0 ) { warn("Passed a non name line to read name line... [%s]",name_line); return FALSE; } base = bkstr = breakstring(name_line,spacestr); for(bkstr++;*bkstr != NULL;bkstr++) { if( strstartcmp(*bkstr,"string") == 0 ) { s2d->name_str = string_from_quoted_equality(*bkstr); } else if( strstartcmp(*bkstr,"!static") == 0 ) { s2d->is_static = TRUE; } else if( strstartcmp(*bkstr,"length=") == 0 ) { s2d->length = number_from_quoted_equality(*bkstr); if( s2d->length < 0 || s2d->length > 512 ) { warn("sequence[%d] name length [%d] is ridiculous... setting to 20",s2d->number,s2d->length); s2d->length = 20; } } else if( strstartcmp(*bkstr,"direction=") ==0 ) { s2d->direction = string_from_quoted_equality(*bkstr); } else { warn("In reading sequence name line for sequence number %d, unable to interpret [%s]",s2d->number,*bkstr); } } if( s2d->direction == NULL ) s2d->direction = stringalloc("DOWN"); return TRUE; } # line 652 "display.dy" boolean put_away_Aln2DisplayField_strpair(Aln2DisplayField * a2df,char * pair) { char buffer[20]; if( strstartcmp(pair,"string=") == 0) { if( a2df->string != NULL) { warn("Already a string or eval state ment in this Aln2DisplayField, overriding %s",a2df->string); ckfree(a2df->string); } a2df->string = string_from_quoted_equality(pair); a2df->is_string = TRUE; sprintf(buffer,"%d",(int)strlen(a2df->string)); a2df->length = stringalloc(buffer); a2df->is_static = TRUE; } else if( strstartcmp(pair,"eval") == 0 ) { if( a2df->string != NULL) { warn("Already a string or eval state ment in this Aln2DisplayField, overriding %s",a2df->string); ckfree(a2df->string); } a2df->string = string_from_quoted_equality(pair); } else if( strstartcmp(pair,"substring") == 0 ) { if( a2df->string != NULL) { warn("Already a string or eval state ment in this Aln2DisplayField, overriding %s",a2df->string); ckfree(a2df->string); } a2df->string = string_from_quoted_equality(pair); a2df->is_sub = TRUE; a2df->is_static = FALSE; } else if( strstartcmp(pair,"length=") == 0 ) { a2df->length = string_from_quoted_equality(pair); } else if( strstartcmp(pair,"direction=") == 0) { a2df->direction = string_from_quoted_equality(pair); } else if( strstartcmp(pair,"convert=") == 0 ) { a2df->convert = string_from_quoted_equality(pair); } else if( strstartcmp(pair,"!static") == 0) { a2df->is_static = TRUE; } else if( strstartcmp(pair,"!single") == 0) { a2df->is_single = TRUE; } else { warn("Unable to interpret [%s] as a valid Aln2DisplayField tag",pair); return FALSE; } return TRUE; } # line 707 "display.dy" Aln2DisplayResource * read_Aln2DisplayResource_line(char * line) { Aln2DisplayResource * out; char ** base; char ** bkstr; out = Aln2DisplayResource_alloc(); if( out == NULL) return NULL; base = bkstr = breakstring(line,spacestr); for(bkstr++;*bkstr != NULL;bkstr++) { if( strstartcmp(*bkstr,"type=") == 0) { out->type = string_from_quoted_equality(*bkstr); } else if( strstartcmp(*bkstr,"name=") == 0 ) { out->name = string_from_quoted_equality(*bkstr); } else if( strstartcmp(*bkstr,"arg=") == 0) { out->arg = string_from_quoted_equality(*bkstr); } else { warn("Got strange tag [%s] in resource line..., while reading display... ignoring",*bkstr); } } ckfree(base); return out; } # line 746 "display.dy" Index2Display * read_Index2Display_line(char * line) { Index2Display * out; char ** bkstr; char ** base; if( strwhitestartcmp(line,"index",spacestr) != 0 ) { warn("Tried to read an Index2Display line with no index! Bad news!"); return NULL; } base = bkstr = breakstring(line,spacestr); out = Index2Display_alloc(); if( out == NULL ) return NULL; bkstr++; out->name = stringalloc(*bkstr); for(bkstr++;*bkstr != NULL;bkstr++) { if( strstartcmp(*bkstr,"start") == 0 ) { if( out->eval != NULL ) { warn("you are replacing an index evaluation. Remember that each index can only have one length [or start if in sequence]"); ckfree(out->eval); } out->eval = string_from_quoted_equality(*bkstr); out->is_start = TRUE; } else if( strstartcmp(*bkstr,"length") == 0 ) { if( out->eval != NULL ) { warn("you are replacing an index evaluation. Remember that each index can only have one length [or start if in sequence]"); ckfree(out->eval); } out->eval = string_from_quoted_equality(*bkstr); } else { warn("Found an uninterpretable tag [%s] in index %s",out->name,*bkstr); } } ckfree(base); return out; } # line 799 "display.dy" void show_Aln2Display(Aln2Display * a2d,FILE * ofp) { register int i; fprintf(ofp,"Display %s\n",a2d->name); for(i=0;ires_len;i++) show_Aln2DisplayResource(a2d->a2dr[i],ofp); for(i=0;ilen;i++) show_Sequence2Display(a2d->s2d[i],ofp); } # line 810 "display.dy" void show_Aln2DisplayResource(Aln2DisplayResource * a2dr,FILE * ofp) { fprintf(ofp,"Resource [%s] Type [%s] Argument [%s]\n",a2dr->type,a2dr->name,a2dr->arg); } # line 815 "display.dy" void show_Sequence2Display(Sequence2Display * s2d,FILE * ofp) { register int i; fprintf(ofp,"Sequence %d\n",s2d->number); for(i=0;ilen;i++) show_Label2Display(s2d->l2d[i],ofp); } # line 823 "display.dy" void show_Label2Display(Label2Display * l2d,FILE * ofp) { register int i; fprintf(ofp,"\tLabel %s\n",l2d->label); for(i=0;ilen;i++) { fprintf(ofp,"\t Field %d",i); show_Aln2DisplayField(l2d->a2df[i],ofp); } } # line 833 "display.dy" void show_Aln2DisplayField(Aln2DisplayField * a2df,FILE * ofp) { fprintf(ofp," String = [%s], Length [%s], Direction [%s]\n",a2df->string,a2df->length,a2df->direction); } # line 772 "display.c" /* Function: hard_link_Aln2DisplayField(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Aln2DisplayField *] * * Return [UNKN ] Undocumented return value [Aln2DisplayField *] * */ Aln2DisplayField * hard_link_Aln2DisplayField(Aln2DisplayField * obj) { if( obj == NULL ) { warn("Trying to hard link to a Aln2DisplayField object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Aln2DisplayField_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Aln2DisplayField *] * */ Aln2DisplayField * Aln2DisplayField_alloc(void) { Aln2DisplayField * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Aln2DisplayField *) ckalloc (sizeof(Aln2DisplayField))) == NULL) { warn("Aln2DisplayField_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->string = NULL; out->length = NULL; out->direction = NULL; out->convert = NULL; out->is_static = FALSE; out->is_string = FALSE; out->is_single = FALSE; out->is_sub = FALSE; return out; } /* Function: free_Aln2DisplayField(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Aln2DisplayField *] * * Return [UNKN ] Undocumented return value [Aln2DisplayField *] * */ Aln2DisplayField * free_Aln2DisplayField(Aln2DisplayField * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Aln2DisplayField obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->string != NULL) ckfree(obj->string); if( obj->length != NULL) ckfree(obj->length); if( obj->direction != NULL) ckfree(obj->direction); if( obj->convert != NULL) ckfree(obj->convert); ckfree(obj); return NULL; } /* Function: hard_link_Index2Display(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Index2Display *] * * Return [UNKN ] Undocumented return value [Index2Display *] * */ Index2Display * hard_link_Index2Display(Index2Display * obj) { if( obj == NULL ) { warn("Trying to hard link to a Index2Display object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Index2Display_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Index2Display *] * */ Index2Display * Index2Display_alloc(void) { Index2Display * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Index2Display *) ckalloc (sizeof(Index2Display))) == NULL) { warn("Index2Display_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->eval = NULL; out->is_start = FALSE; out->number = 0; return out; } /* Function: free_Index2Display(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Index2Display *] * * Return [UNKN ] Undocumented return value [Index2Display *] * */ Index2Display * free_Index2Display(Index2Display * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Index2Display obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->eval != NULL) ckfree(obj->eval); ckfree(obj); return NULL; } /* Function: swap_Label2Display(list,i,j) * * Descrip: swap function: an internal for qsort_Label2Display * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Aln2DisplayField **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Label2Display(Aln2DisplayField ** list,int i,int j) { Aln2DisplayField * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Label2Display(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Label2Display which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Aln2DisplayField **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Label2Display(Aln2DisplayField ** list,int left,int right,int (*comp)(Aln2DisplayField * ,Aln2DisplayField * )) { int i,last; if( left >= right ) return; swap_Label2Display(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Label2Display (list,++last,i); } swap_Label2Display (list,left,last); qsort_Label2Display(list,left,last-1,comp); qsort_Label2Display(list,last+1,right,comp); } /* Function: sort_Label2Display(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Label2Display * * * Arg: obj [UNKN ] Object containing list [Label2Display *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Label2Display(Label2Display * obj,int (*comp)(Aln2DisplayField *, Aln2DisplayField *)) { qsort_Label2Display(obj->a2df,0,obj->len-1,comp); return; } /* Function: expand_Label2Display(obj,len) * * Descrip: Really an internal function for add_Label2Display * * * Arg: obj [UNKN ] Object which contains the list [Label2Display *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Label2Display(Label2Display * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Label2Display called with no need"); return TRUE; } if( (obj->a2df = (Aln2DisplayField ** ) ckrealloc (obj->a2df,sizeof(Aln2DisplayField *)*len)) == NULL) { warn("ckrealloc failed for expand_Label2Display, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Label2Display(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Label2Display *] * Arg: add [OWNER] Object to add to the list [Aln2DisplayField *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Label2Display(Label2Display * obj,Aln2DisplayField * add) { if( obj->len >= obj->maxlen) { if( expand_Label2Display(obj,obj->len + Label2DisplayLISTLENGTH) == FALSE) return FALSE; } obj->a2df[obj->len++]=add; return TRUE; } /* Function: flush_Label2Display(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Label2Display *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Label2Display(Label2Display * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->a2df[i] != NULL) { free_Aln2DisplayField(obj->a2df[i]); obj->a2df[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: swap_ind_Label2Display(list,i,j) * * Descrip: swap function: an internal for qsort_ind_Label2Display * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Index2Display **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ind_Label2Display(Index2Display ** list,int i,int j) { Index2Display * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ind_Label2Display(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ind_Label2Display which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Index2Display **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ind_Label2Display(Index2Display ** list,int left,int right,int (*comp)(Index2Display * ,Index2Display * )) { int i,last; if( left >= right ) return; swap_ind_Label2Display(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ind_Label2Display (list,++last,i); } swap_ind_Label2Display (list,left,last); qsort_ind_Label2Display(list,left,last-1,comp); qsort_ind_Label2Display(list,last+1,right,comp); } /* Function: sort_ind_Label2Display(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ind_Label2Display * * * Arg: obj [UNKN ] Object containing list [Label2Display *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ind_Label2Display(Label2Display * obj,int (*comp)(Index2Display *, Index2Display *)) { qsort_ind_Label2Display(obj->i2d,0,obj->ind_len-1,comp); return; } /* Function: expand_ind_Label2Display(obj,len) * * Descrip: Really an internal function for add_ind_Label2Display * * * Arg: obj [UNKN ] Object which contains the list [Label2Display *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ind_Label2Display(Label2Display * obj,int len) { if( obj->ind_maxlen > obj->ind_len ) { warn("expand_Label2Displayind_ called with no need"); return TRUE; } if( (obj->i2d = (Index2Display ** ) ckrealloc (obj->i2d,sizeof(Index2Display *)*len)) == NULL) { warn("ckrealloc failed for expand_Label2Display, returning FALSE"); return FALSE; } obj->ind_maxlen = len; return TRUE; } /* Function: add_ind_Label2Display(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Label2Display *] * Arg: add [OWNER] Object to add to the list [Index2Display *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ind_Label2Display(Label2Display * obj,Index2Display * add) { if( obj->ind_len >= obj->ind_maxlen) { if( expand_ind_Label2Display(obj,obj->ind_len + Label2DisplayLISTLENGTH) == FALSE) return FALSE; } obj->i2d[obj->ind_len++]=add; return TRUE; } /* Function: flush_ind_Label2Display(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Label2Display *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ind_Label2Display(Label2Display * obj) { int i; for(i=0;iind_len;i++) { /*for i over list length*/ if( obj->i2d[i] != NULL) { free_Index2Display(obj->i2d[i]); obj->i2d[i] = NULL; } } /* end of for i over list length */ obj->ind_len = 0; return i; } /* Function: Label2Display_alloc_std(void) * * Descrip: Equivalent to Label2Display_alloc_len(Label2DisplayLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Label2Display *] * */ Label2Display * Label2Display_alloc_std(void) { return Label2Display_alloc_len(Label2DisplayLISTLENGTH); } /* Function: Label2Display_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Label2Display *] * */ Label2Display * Label2Display_alloc_len(int len) { Label2Display * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Label2Display_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->a2df = (Aln2DisplayField ** ) ckcalloc (len,sizeof(Aln2DisplayField *))) == NULL) { warn("Warning, ckcalloc failed in Label2Display_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; if((out->i2d = (Index2Display ** ) ckcalloc (len,sizeof(Index2Display *))) == NULL) { warn("Warning, ckcalloc failed in Label2Display_alloc_len"); return NULL; } out->ind_len = 0; out->ind_maxlen = len; return out; } /* Function: hard_link_Label2Display(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Label2Display *] * * Return [UNKN ] Undocumented return value [Label2Display *] * */ Label2Display * hard_link_Label2Display(Label2Display * obj) { if( obj == NULL ) { warn("Trying to hard link to a Label2Display object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Label2Display_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Label2Display *] * */ Label2Display * Label2Display_alloc(void) { Label2Display * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Label2Display *) ckalloc (sizeof(Label2Display))) == NULL) { warn("Label2Display_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->label = NULL; out->direction = NULL; out->a2df = NULL; out->len = out->maxlen = 0; out->i2d = NULL; out->ind_len = out->ind_maxlen = 0; out->is_lone = FALSE; return out; } /* Function: free_Label2Display(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Label2Display *] * * Return [UNKN ] Undocumented return value [Label2Display *] * */ Label2Display * free_Label2Display(Label2Display * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Label2Display obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->label != NULL) ckfree(obj->label); if( obj->direction != NULL) ckfree(obj->direction); if( obj->a2df != NULL) { for(i=0;ilen;i++) { if( obj->a2df[i] != NULL) free_Aln2DisplayField(obj->a2df[i]); } ckfree(obj->a2df); } if( obj->i2d != NULL) { for(i=0;iind_len;i++) { if( obj->i2d[i] != NULL) free_Index2Display(obj->i2d[i]); } ckfree(obj->i2d); } ckfree(obj); return NULL; } /* Function: swap_Sequence2Display(list,i,j) * * Descrip: swap function: an internal for qsort_Sequence2Display * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Label2Display **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Sequence2Display(Label2Display ** list,int i,int j) { Label2Display * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Sequence2Display(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Sequence2Display which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Label2Display **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Sequence2Display(Label2Display ** list,int left,int right,int (*comp)(Label2Display * ,Label2Display * )) { int i,last; if( left >= right ) return; swap_Sequence2Display(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Sequence2Display (list,++last,i); } swap_Sequence2Display (list,left,last); qsort_Sequence2Display(list,left,last-1,comp); qsort_Sequence2Display(list,last+1,right,comp); } /* Function: sort_Sequence2Display(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Sequence2Display * * * Arg: obj [UNKN ] Object containing list [Sequence2Display *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Sequence2Display(Sequence2Display * obj,int (*comp)(Label2Display *, Label2Display *)) { qsort_Sequence2Display(obj->l2d,0,obj->len-1,comp); return; } /* Function: expand_Sequence2Display(obj,len) * * Descrip: Really an internal function for add_Sequence2Display * * * Arg: obj [UNKN ] Object which contains the list [Sequence2Display *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Sequence2Display(Sequence2Display * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Sequence2Display called with no need"); return TRUE; } if( (obj->l2d = (Label2Display ** ) ckrealloc (obj->l2d,sizeof(Label2Display *)*len)) == NULL) { warn("ckrealloc failed for expand_Sequence2Display, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Sequence2Display(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Sequence2Display *] * Arg: add [OWNER] Object to add to the list [Label2Display *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Sequence2Display(Sequence2Display * obj,Label2Display * add) { if( obj->len >= obj->maxlen) { if( expand_Sequence2Display(obj,obj->len + Sequence2DisplayLISTLENGTH) == FALSE) return FALSE; } obj->l2d[obj->len++]=add; return TRUE; } /* Function: flush_Sequence2Display(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Sequence2Display *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Sequence2Display(Sequence2Display * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->l2d[i] != NULL) { free_Label2Display(obj->l2d[i]); obj->l2d[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: swap_ind_Sequence2Display(list,i,j) * * Descrip: swap function: an internal for qsort_ind_Sequence2Display * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Index2Display **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ind_Sequence2Display(Index2Display ** list,int i,int j) { Index2Display * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ind_Sequence2Display(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ind_Sequence2Display which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Index2Display **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ind_Sequence2Display(Index2Display ** list,int left,int right,int (*comp)(Index2Display * ,Index2Display * )) { int i,last; if( left >= right ) return; swap_ind_Sequence2Display(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ind_Sequence2Display (list,++last,i); } swap_ind_Sequence2Display (list,left,last); qsort_ind_Sequence2Display(list,left,last-1,comp); qsort_ind_Sequence2Display(list,last+1,right,comp); } /* Function: sort_ind_Sequence2Display(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ind_Sequence2Display * * * Arg: obj [UNKN ] Object containing list [Sequence2Display *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ind_Sequence2Display(Sequence2Display * obj,int (*comp)(Index2Display *, Index2Display *)) { qsort_ind_Sequence2Display(obj->i2d,0,obj->ind_len-1,comp); return; } /* Function: expand_ind_Sequence2Display(obj,len) * * Descrip: Really an internal function for add_ind_Sequence2Display * * * Arg: obj [UNKN ] Object which contains the list [Sequence2Display *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ind_Sequence2Display(Sequence2Display * obj,int len) { if( obj->ind_maxlen > obj->ind_len ) { warn("expand_Sequence2Displayind_ called with no need"); return TRUE; } if( (obj->i2d = (Index2Display ** ) ckrealloc (obj->i2d,sizeof(Index2Display *)*len)) == NULL) { warn("ckrealloc failed for expand_Sequence2Display, returning FALSE"); return FALSE; } obj->ind_maxlen = len; return TRUE; } /* Function: add_ind_Sequence2Display(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Sequence2Display *] * Arg: add [OWNER] Object to add to the list [Index2Display *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ind_Sequence2Display(Sequence2Display * obj,Index2Display * add) { if( obj->ind_len >= obj->ind_maxlen) { if( expand_ind_Sequence2Display(obj,obj->ind_len + Sequence2DisplayLISTLENGTH) == FALSE) return FALSE; } obj->i2d[obj->ind_len++]=add; return TRUE; } /* Function: flush_ind_Sequence2Display(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Sequence2Display *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ind_Sequence2Display(Sequence2Display * obj) { int i; for(i=0;iind_len;i++) { /*for i over list length*/ if( obj->i2d[i] != NULL) { free_Index2Display(obj->i2d[i]); obj->i2d[i] = NULL; } } /* end of for i over list length */ obj->ind_len = 0; return i; } /* Function: Sequence2Display_alloc_std(void) * * Descrip: Equivalent to Sequence2Display_alloc_len(Sequence2DisplayLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Sequence2Display *] * */ Sequence2Display * Sequence2Display_alloc_std(void) { return Sequence2Display_alloc_len(Sequence2DisplayLISTLENGTH); } /* Function: Sequence2Display_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Sequence2Display *] * */ Sequence2Display * Sequence2Display_alloc_len(int len) { Sequence2Display * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Sequence2Display_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->l2d = (Label2Display ** ) ckcalloc (len,sizeof(Label2Display *))) == NULL) { warn("Warning, ckcalloc failed in Sequence2Display_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; if((out->i2d = (Index2Display ** ) ckcalloc (len,sizeof(Index2Display *))) == NULL) { warn("Warning, ckcalloc failed in Sequence2Display_alloc_len"); return NULL; } out->ind_len = 0; out->ind_maxlen = len; return out; } /* Function: hard_link_Sequence2Display(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Sequence2Display *] * * Return [UNKN ] Undocumented return value [Sequence2Display *] * */ Sequence2Display * hard_link_Sequence2Display(Sequence2Display * obj) { if( obj == NULL ) { warn("Trying to hard link to a Sequence2Display object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Sequence2Display_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Sequence2Display *] * */ Sequence2Display * Sequence2Display_alloc(void) { Sequence2Display * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Sequence2Display *) ckalloc (sizeof(Sequence2Display))) == NULL) { warn("Sequence2Display_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->number = 0; out->l2d = NULL; out->len = out->maxlen = 0; out->i2d = NULL; out->ind_len = out->ind_maxlen = 0; out->name_str = NULL; out->length = 0; out->is_static = FALSE; out->direction = NULL; return out; } /* Function: free_Sequence2Display(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Sequence2Display *] * * Return [UNKN ] Undocumented return value [Sequence2Display *] * */ Sequence2Display * free_Sequence2Display(Sequence2Display * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Sequence2Display obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->l2d != NULL) { for(i=0;ilen;i++) { if( obj->l2d[i] != NULL) free_Label2Display(obj->l2d[i]); } ckfree(obj->l2d); } if( obj->i2d != NULL) { for(i=0;iind_len;i++) { if( obj->i2d[i] != NULL) free_Index2Display(obj->i2d[i]); } ckfree(obj->i2d); } if( obj->name_str != NULL) ckfree(obj->name_str); if( obj->direction != NULL) ckfree(obj->direction); ckfree(obj); return NULL; } /* Function: hard_link_Aln2DisplayResource(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Aln2DisplayResource *] * * Return [UNKN ] Undocumented return value [Aln2DisplayResource *] * */ Aln2DisplayResource * hard_link_Aln2DisplayResource(Aln2DisplayResource * obj) { if( obj == NULL ) { warn("Trying to hard link to a Aln2DisplayResource object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Aln2DisplayResource_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Aln2DisplayResource *] * */ Aln2DisplayResource * Aln2DisplayResource_alloc(void) { Aln2DisplayResource * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Aln2DisplayResource *) ckalloc (sizeof(Aln2DisplayResource))) == NULL) { warn("Aln2DisplayResource_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = NULL; out->name = NULL; out->arg = NULL; return out; } /* Function: free_Aln2DisplayResource(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Aln2DisplayResource *] * * Return [UNKN ] Undocumented return value [Aln2DisplayResource *] * */ Aln2DisplayResource * free_Aln2DisplayResource(Aln2DisplayResource * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Aln2DisplayResource obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->type != NULL) ckfree(obj->type); if( obj->name != NULL) ckfree(obj->name); if( obj->arg != NULL) ckfree(obj->arg); ckfree(obj); return NULL; } /* Function: swap_res_Aln2Display(list,i,j) * * Descrip: swap function: an internal for qsort_res_Aln2Display * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Aln2DisplayResource **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_res_Aln2Display(Aln2DisplayResource ** list,int i,int j) { Aln2DisplayResource * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_res_Aln2Display(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_res_Aln2Display which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Aln2DisplayResource **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_res_Aln2Display(Aln2DisplayResource ** list,int left,int right,int (*comp)(Aln2DisplayResource * ,Aln2DisplayResource * )) { int i,last; if( left >= right ) return; swap_res_Aln2Display(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_res_Aln2Display (list,++last,i); } swap_res_Aln2Display (list,left,last); qsort_res_Aln2Display(list,left,last-1,comp); qsort_res_Aln2Display(list,last+1,right,comp); } /* Function: sort_res_Aln2Display(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_res_Aln2Display * * * Arg: obj [UNKN ] Object containing list [Aln2Display *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_res_Aln2Display(Aln2Display * obj,int (*comp)(Aln2DisplayResource *, Aln2DisplayResource *)) { qsort_res_Aln2Display(obj->a2dr,0,obj->res_len-1,comp); return; } /* Function: expand_res_Aln2Display(obj,len) * * Descrip: Really an internal function for add_res_Aln2Display * * * Arg: obj [UNKN ] Object which contains the list [Aln2Display *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_res_Aln2Display(Aln2Display * obj,int len) { if( obj->res_maxlen > obj->res_len ) { warn("expand_Aln2Displayres_ called with no need"); return TRUE; } if( (obj->a2dr = (Aln2DisplayResource ** ) ckrealloc (obj->a2dr,sizeof(Aln2DisplayResource *)*len)) == NULL) { warn("ckrealloc failed for expand_Aln2Display, returning FALSE"); return FALSE; } obj->res_maxlen = len; return TRUE; } /* Function: add_res_Aln2Display(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Aln2Display *] * Arg: add [OWNER] Object to add to the list [Aln2DisplayResource *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_res_Aln2Display(Aln2Display * obj,Aln2DisplayResource * add) { if( obj->res_len >= obj->res_maxlen) { if( expand_res_Aln2Display(obj,obj->res_len + Aln2DisplayLISTLENGTH) == FALSE) return FALSE; } obj->a2dr[obj->res_len++]=add; return TRUE; } /* Function: flush_res_Aln2Display(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Aln2Display *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_res_Aln2Display(Aln2Display * obj) { int i; for(i=0;ires_len;i++) { /*for i over list length*/ if( obj->a2dr[i] != NULL) { free_Aln2DisplayResource(obj->a2dr[i]); obj->a2dr[i] = NULL; } } /* end of for i over list length */ obj->res_len = 0; return i; } /* Function: swap_Aln2Display(list,i,j) * * Descrip: swap function: an internal for qsort_Aln2Display * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Sequence2Display **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Aln2Display(Sequence2Display ** list,int i,int j) { Sequence2Display * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Aln2Display(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Aln2Display which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Sequence2Display **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Aln2Display(Sequence2Display ** list,int left,int right,int (*comp)(Sequence2Display * ,Sequence2Display * )) { int i,last; if( left >= right ) return; swap_Aln2Display(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Aln2Display (list,++last,i); } swap_Aln2Display (list,left,last); qsort_Aln2Display(list,left,last-1,comp); qsort_Aln2Display(list,last+1,right,comp); } /* Function: sort_Aln2Display(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Aln2Display * * * Arg: obj [UNKN ] Object containing list [Aln2Display *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Aln2Display(Aln2Display * obj,int (*comp)(Sequence2Display *, Sequence2Display *)) { qsort_Aln2Display(obj->s2d,0,obj->len-1,comp); return; } /* Function: expand_Aln2Display(obj,len) * * Descrip: Really an internal function for add_Aln2Display * * * Arg: obj [UNKN ] Object which contains the list [Aln2Display *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Aln2Display(Aln2Display * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Aln2Display called with no need"); return TRUE; } if( (obj->s2d = (Sequence2Display ** ) ckrealloc (obj->s2d,sizeof(Sequence2Display *)*len)) == NULL) { warn("ckrealloc failed for expand_Aln2Display, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Aln2Display(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Aln2Display *] * Arg: add [OWNER] Object to add to the list [Sequence2Display *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Aln2Display(Aln2Display * obj,Sequence2Display * add) { if( obj->len >= obj->maxlen) { if( expand_Aln2Display(obj,obj->len + Aln2DisplayLISTLENGTH) == FALSE) return FALSE; } obj->s2d[obj->len++]=add; return TRUE; } /* Function: flush_Aln2Display(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Aln2Display *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Aln2Display(Aln2Display * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->s2d[i] != NULL) { free_Sequence2Display(obj->s2d[i]); obj->s2d[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: Aln2Display_alloc_std(void) * * Descrip: Equivalent to Aln2Display_alloc_len(Aln2DisplayLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Aln2Display *] * */ Aln2Display * Aln2Display_alloc_std(void) { return Aln2Display_alloc_len(Aln2DisplayLISTLENGTH); } /* Function: Aln2Display_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Aln2Display *] * */ Aln2Display * Aln2Display_alloc_len(int len) { Aln2Display * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Aln2Display_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->a2dr = (Aln2DisplayResource ** ) ckcalloc (len,sizeof(Aln2DisplayResource *))) == NULL) { warn("Warning, ckcalloc failed in Aln2Display_alloc_len"); return NULL; } out->res_len = 0; out->res_maxlen = len; if((out->s2d = (Sequence2Display ** ) ckcalloc (len,sizeof(Sequence2Display *))) == NULL) { warn("Warning, ckcalloc failed in Aln2Display_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_Aln2Display(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Aln2Display *] * * Return [UNKN ] Undocumented return value [Aln2Display *] * */ Aln2Display * hard_link_Aln2Display(Aln2Display * obj) { if( obj == NULL ) { warn("Trying to hard link to a Aln2Display object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Aln2Display_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Aln2Display *] * */ Aln2Display * Aln2Display_alloc(void) { Aln2Display * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Aln2Display *) ckalloc (sizeof(Aln2Display))) == NULL) { warn("Aln2Display_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->a2dr = NULL; out->res_len = out->res_maxlen = 0; out->s2d = NULL; out->len = out->maxlen = 0; out->other = NULL; return out; } /* Function: free_Aln2Display(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Aln2Display *] * * Return [UNKN ] Undocumented return value [Aln2Display *] * */ Aln2Display * free_Aln2Display(Aln2Display * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Aln2Display obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->a2dr != NULL) { for(i=0;ires_len;i++) { if( obj->a2dr[i] != NULL) free_Aln2DisplayResource(obj->a2dr[i]); } ckfree(obj->a2dr); } if( obj->s2d != NULL) { for(i=0;ilen;i++) { if( obj->s2d[i] != NULL) free_Sequence2Display(obj->s2d[i]); } ckfree(obj->s2d); } if( obj->other != NULL) free_Sequence2Display(obj->other); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/display.h0000644000175000001440000005140110670453715015246 0ustar philippusers#ifndef DYNAMITEdisplayHEADERFILE #define DYNAMITEdisplayHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "dynfile.h" /********************************************************/ /* Wisetools version 3 file */ /* */ /* this file is copyright (c) Ewan Birney 1996 */ /* this file is part of the wisetools sequence analysis */ /* package */ /********************************************************/ /********************************************************/ /* Display is an internal module for dynamite itself */ /* to manage the display tag found in dynamite files */ /* */ /* */ /********************************************************/ /***** RCS Info *****************************************/ /* $Id: $Log: */ /*********************************************************/ #define Label2DisplayLISTLENGTH 32 #define Sequence2DisplayLISTLENGTH 32 #define Aln2DisplayLISTLENGTH 32 #define ALL_OTHER_NUMBER (-10) struct Aln2DisplayField { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * string; char * length; char * direction; char * convert; boolean is_static; boolean is_string; boolean is_single; boolean is_sub; } ; /* Aln2DisplayField defined */ #ifndef DYNAMITE_DEFINED_Aln2DisplayField typedef struct Aln2DisplayField Aln2DisplayField; #define DYNAMITE_DEFINED_Aln2DisplayField #endif struct Index2Display { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; char * eval; boolean is_start; int number; } ; /* Index2Display defined */ #ifndef DYNAMITE_DEFINED_Index2Display typedef struct Index2Display Index2Display; #define DYNAMITE_DEFINED_Index2Display #endif struct Label2Display { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * label; char * direction; Aln2DisplayField ** a2df; int len;/* len for above a2df */ int maxlen; /* maxlen for above a2df */ Index2Display ** i2d; int ind_len;/* len for above i2d */ int ind_maxlen; /* maxlen for above i2d */ boolean is_lone; } ; /* Label2Display defined */ #ifndef DYNAMITE_DEFINED_Label2Display typedef struct Label2Display Label2Display; #define DYNAMITE_DEFINED_Label2Display #endif struct Sequence2Display { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int number; Label2Display ** l2d; int len;/* len for above l2d */ int maxlen; /* maxlen for above l2d */ Index2Display ** i2d; int ind_len;/* len for above i2d */ int ind_maxlen; /* maxlen for above i2d */ char * name_str; int length; /* of name */ boolean is_static; char * direction; } ; /* Sequence2Display defined */ #ifndef DYNAMITE_DEFINED_Sequence2Display typedef struct Sequence2Display Sequence2Display; #define DYNAMITE_DEFINED_Sequence2Display #endif struct Aln2DisplayResource { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * type; char * name; char * arg; } ; /* Aln2DisplayResource defined */ #ifndef DYNAMITE_DEFINED_Aln2DisplayResource typedef struct Aln2DisplayResource Aln2DisplayResource; #define DYNAMITE_DEFINED_Aln2DisplayResource #endif struct Aln2Display { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; Aln2DisplayResource ** a2dr; int res_len;/* len for above a2dr */ int res_maxlen; /* maxlen for above a2dr */ Sequence2Display ** s2d; int len;/* len for above s2d */ int maxlen; /* maxlen for above s2d */ Sequence2Display * other; } ; /* Aln2Display defined */ #ifndef DYNAMITE_DEFINED_Aln2Display typedef struct Aln2Display Aln2Display; #define DYNAMITE_DEFINED_Aln2Display #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_Aln2DisplayField(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Aln2DisplayField *] * * Return [UNKN ] Undocumented return value [Aln2DisplayField *] * */ Aln2DisplayField * hard_link_Aln2DisplayField(Aln2DisplayField * obj); /* Function: Aln2DisplayField_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Aln2DisplayField *] * */ Aln2DisplayField * Aln2DisplayField_alloc(void); /* Function: free_Aln2DisplayField(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Aln2DisplayField *] * * Return [UNKN ] Undocumented return value [Aln2DisplayField *] * */ Aln2DisplayField * free_Aln2DisplayField(Aln2DisplayField * obj); /* Function: hard_link_Index2Display(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Index2Display *] * * Return [UNKN ] Undocumented return value [Index2Display *] * */ Index2Display * hard_link_Index2Display(Index2Display * obj); /* Function: Index2Display_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Index2Display *] * */ Index2Display * Index2Display_alloc(void); /* Function: free_Index2Display(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Index2Display *] * * Return [UNKN ] Undocumented return value [Index2Display *] * */ Index2Display * free_Index2Display(Index2Display * obj); /* Function: add_Label2Display(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Label2Display *] * Arg: add [OWNER] Object to add to the list [Aln2DisplayField *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_Label2Display(Label2Display * obj,Aln2DisplayField * add); /* Function: flush_Label2Display(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Label2Display *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Label2Display(Label2Display * obj); /* Function: add_ind_Label2Display(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Label2Display *] * Arg: add [OWNER] Object to add to the list [Index2Display *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_ind_Label2Display(Label2Display * obj,Index2Display * add); /* Function: flush_ind_Label2Display(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Label2Display *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ind_Label2Display(Label2Display * obj); /* Function: Label2Display_alloc_std(void) * * Descrip: Equivalent to Label2Display_alloc_len(Label2DisplayLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Label2Display *] * */ Label2Display * Label2Display_alloc_std(void); /* Function: Label2Display_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Label2Display *] * */ Label2Display * Label2Display_alloc_len(int len); /* Function: hard_link_Label2Display(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Label2Display *] * * Return [UNKN ] Undocumented return value [Label2Display *] * */ Label2Display * hard_link_Label2Display(Label2Display * obj); /* Function: Label2Display_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Label2Display *] * */ Label2Display * Label2Display_alloc(void); /* Function: free_Label2Display(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Label2Display *] * * Return [UNKN ] Undocumented return value [Label2Display *] * */ Label2Display * free_Label2Display(Label2Display * obj); /* Function: add_Sequence2Display(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Sequence2Display *] * Arg: add [OWNER] Object to add to the list [Label2Display *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_Sequence2Display(Sequence2Display * obj,Label2Display * add); /* Function: flush_Sequence2Display(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Sequence2Display *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Sequence2Display(Sequence2Display * obj); /* Function: add_ind_Sequence2Display(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Sequence2Display *] * Arg: add [OWNER] Object to add to the list [Index2Display *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_ind_Sequence2Display(Sequence2Display * obj,Index2Display * add); /* Function: flush_ind_Sequence2Display(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Sequence2Display *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ind_Sequence2Display(Sequence2Display * obj); /* Function: Sequence2Display_alloc_std(void) * * Descrip: Equivalent to Sequence2Display_alloc_len(Sequence2DisplayLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Sequence2Display *] * */ Sequence2Display * Sequence2Display_alloc_std(void); /* Function: Sequence2Display_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Sequence2Display *] * */ Sequence2Display * Sequence2Display_alloc_len(int len); /* Function: hard_link_Sequence2Display(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Sequence2Display *] * * Return [UNKN ] Undocumented return value [Sequence2Display *] * */ Sequence2Display * hard_link_Sequence2Display(Sequence2Display * obj); /* Function: Sequence2Display_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Sequence2Display *] * */ Sequence2Display * Sequence2Display_alloc(void); /* Function: free_Sequence2Display(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Sequence2Display *] * * Return [UNKN ] Undocumented return value [Sequence2Display *] * */ Sequence2Display * free_Sequence2Display(Sequence2Display * obj); /* Function: hard_link_Aln2DisplayResource(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Aln2DisplayResource *] * * Return [UNKN ] Undocumented return value [Aln2DisplayResource *] * */ Aln2DisplayResource * hard_link_Aln2DisplayResource(Aln2DisplayResource * obj); /* Function: Aln2DisplayResource_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Aln2DisplayResource *] * */ Aln2DisplayResource * Aln2DisplayResource_alloc(void); /* Function: free_Aln2DisplayResource(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Aln2DisplayResource *] * * Return [UNKN ] Undocumented return value [Aln2DisplayResource *] * */ Aln2DisplayResource * free_Aln2DisplayResource(Aln2DisplayResource * obj); /* Function: add_res_Aln2Display(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Aln2Display *] * Arg: add [OWNER] Object to add to the list [Aln2DisplayResource *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_res_Aln2Display(Aln2Display * obj,Aln2DisplayResource * add); /* Function: flush_res_Aln2Display(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Aln2Display *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_res_Aln2Display(Aln2Display * obj); /* Function: add_Aln2Display(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Aln2Display *] * Arg: add [OWNER] Object to add to the list [Sequence2Display *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_Aln2Display(Aln2Display * obj,Sequence2Display * add); /* Function: flush_Aln2Display(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Aln2Display *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Aln2Display(Aln2Display * obj); /* Function: Aln2Display_alloc_std(void) * * Descrip: Equivalent to Aln2Display_alloc_len(Aln2DisplayLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Aln2Display *] * */ Aln2Display * Aln2Display_alloc_std(void); /* Function: Aln2Display_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Aln2Display *] * */ Aln2Display * Aln2Display_alloc_len(int len); /* Function: hard_link_Aln2Display(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Aln2Display *] * * Return [UNKN ] Undocumented return value [Aln2Display *] * */ Aln2Display * hard_link_Aln2Display(Aln2Display * obj); /* Function: Aln2Display_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Aln2Display *] * */ Aln2Display * Aln2Display_alloc(void); /* Function: free_Aln2Display(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Aln2Display *] * * Return [UNKN ] Undocumented return value [Aln2Display *] * */ Aln2Display * free_Aln2Display(Aln2Display * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ void write_Aln2Display_header(DYNFILE * dfp,Aln2Display * a2d); void write_Aln2Display_function(DYNFILE * dfp,Aln2Display * a2d); void write_Aln2Display_convert_func(DYNFILE * dfp,Aln2Display * a2d); boolean prepare_Aln2Display(Aln2Display * a2d); void number_up_Sequence_Index2Display(Aln2Display * a2d); boolean crosslink_Index(Aln2Display * a2d); boolean crosslink_Label2Display_Index(Label2Display * l2d,Sequence2Display * s2d); Index2Display * Index2Display_from_name(Sequence2Display * s2d,char * name); Aln2Display * read_Aln2Display_line(char * line,FILE * ifp); Sequence2Display * read_Sequence2Display_line(char * line,FILE * ifp); Label2Display * read_Label2Display_line(char * line,FILE * ifp); Aln2DisplayField * read_Aln2DisplayField_line(char * line,FILE * ifp); boolean read_name_line(Sequence2Display * s2d,char * name_line); boolean put_away_Aln2DisplayField_strpair(Aln2DisplayField * a2df,char * pair); Aln2DisplayResource * read_Aln2DisplayResource_line(char * line); Index2Display * read_Index2Display_line(char * line); void show_Aln2Display(Aln2Display * a2d,FILE * ofp); void show_Aln2DisplayResource(Aln2DisplayResource * a2dr,FILE * ofp); void show_Sequence2Display(Sequence2Display * s2d,FILE * ofp); void show_Label2Display(Label2Display * l2d,FILE * ofp); void show_Aln2DisplayField(Aln2DisplayField * a2df,FILE * ofp); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void swap_Label2Display(Aln2DisplayField ** list,int i,int j) ; void qsort_Label2Display(Aln2DisplayField ** list,int left,int right,int (*comp)(Aln2DisplayField * ,Aln2DisplayField * )); void sort_Label2Display(Label2Display * obj,int (*comp)(Aln2DisplayField *, Aln2DisplayField *)); boolean expand_Label2Display(Label2Display * obj,int len); void swap_ind_Label2Display(Index2Display ** list,int i,int j) ; void qsort_ind_Label2Display(Index2Display ** list,int left,int right,int (*comp)(Index2Display * ,Index2Display * )); void sort_ind_Label2Display(Label2Display * obj,int (*comp)(Index2Display *, Index2Display *)); boolean expand_ind_Label2Display(Label2Display * obj,int len); void swap_Sequence2Display(Label2Display ** list,int i,int j) ; void qsort_Sequence2Display(Label2Display ** list,int left,int right,int (*comp)(Label2Display * ,Label2Display * )); void sort_Sequence2Display(Sequence2Display * obj,int (*comp)(Label2Display *, Label2Display *)); boolean expand_Sequence2Display(Sequence2Display * obj,int len); void swap_ind_Sequence2Display(Index2Display ** list,int i,int j) ; void qsort_ind_Sequence2Display(Index2Display ** list,int left,int right,int (*comp)(Index2Display * ,Index2Display * )); void sort_ind_Sequence2Display(Sequence2Display * obj,int (*comp)(Index2Display *, Index2Display *)); boolean expand_ind_Sequence2Display(Sequence2Display * obj,int len); void swap_res_Aln2Display(Aln2DisplayResource ** list,int i,int j) ; void qsort_res_Aln2Display(Aln2DisplayResource ** list,int left,int right,int (*comp)(Aln2DisplayResource * ,Aln2DisplayResource * )); void sort_res_Aln2Display(Aln2Display * obj,int (*comp)(Aln2DisplayResource *, Aln2DisplayResource *)); boolean expand_res_Aln2Display(Aln2Display * obj,int len); void swap_Aln2Display(Sequence2Display ** list,int i,int j) ; void qsort_Aln2Display(Sequence2Display ** list,int left,int right,int (*comp)(Sequence2Display * ,Sequence2Display * )); void sort_Aln2Display(Aln2Display * obj,int (*comp)(Sequence2Display *, Sequence2Display *)); boolean expand_Aln2Display(Aln2Display * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/method.c0000644000175000001440000012624310670453715015063 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "method.h" /* Function: Type_from_name(mts,name) * * Descrip: gets a type by its name * * * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * Arg: name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Type *] * */ # line 61 "method.dy" Type * Type_from_name(MethodTypeSet * mts,char * name) { int i; Type * out = NULL; if( mts == NULL ) { warn("Attempting to get a type name from a null mts. Nope!"); return NULL; } for(i=0;ity_len;i++) { if( strcmp(mts->ty[i]->logical,name) == 0 ) { if( out == NULL ) { out = mts->ty[i]; } else { warn("Multiple definitions for %s - taking the last one\n",name); out = mts->ty[i]; } } } return out; } /* Function: compare_type(s,t) * * Descrip: Essentially compares two strings, disregarding white space * * Not ideal!!! * * * Arg: s [UNKN ] Undocumented argument [char *] * Arg: t [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 93 "method.dy" boolean compare_type(char * s,char * t) { for(;*s && isspace(*s);s++) ; for(;*t && isspace(*t);t++) ; for(;*s && *t && *s == *t;) { for(s++;*s && isspace(*s);s++) ; for(t++;*t && isspace(*t);t++) ; } if( *s == '\0' && *t == '\0' ) return TRUE; return FALSE; } /* Function: Method_from_name(mts,name) * * Descrip: gets a Method by its name * * * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * Arg: name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Method *] * */ # line 117 "method.dy" Method * Method_from_name(MethodTypeSet * mts,char * name) { int i; if( mts == NULL) { warn("Attempting to get a method name from a null mts. Nope!"); return NULL; } for(i=0;ime_len;i++) { if( strcmp(mts->me[i]->logical,name) == 0 ) return mts->me[i]; } return NULL; } /*** I/O on methods/types ***/ # line 137 "method.dy" void show_MethodTypeSet(MethodTypeSet * mts,FILE * ofp) { int i; for(i=0;ime_len;i++) show_Method(mts->me[i],ofp); for(i=0;ity_len;i++) show_Type(mts->ty[i],ofp); } # line 149 "method.dy" void show_Method(Method * m,FILE * ofp) { int i; fprintf(ofp,"Method [%s] map [%s]\n",m->logical,m->real); for(i=0;ilen;i++) show_MethodArg(m->ma[i],ofp); } # line 158 "method.dy" void show_MethodArg(MethodArg * ma,FILE * ofp) { fprintf(ofp,"Argument: %s\n",ma->type); } # line 163 "method.dy" void show_Type(Type * ty,FILE * ofp) { fprintf(ofp,"Type: Logial %s Real %s\n",ty->logical,ty->real); } /* Function: StructElement_from_MethodTypeSet(name,type,mts) * * Descrip: function which handles the logical->real mapping * * At the moment "unmappable" types get assummed to be C types, * trigger a warning and return the correct thing. * * * Arg: name [UNKN ] Undocumented argument [char *] * Arg: type [UNKN ] Undocumented argument [char *] * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [StructElement *] * */ # line 174 "method.dy" StructElement * StructElement_from_MethodTypeSet(char * name,char * type,MethodTypeSet * mts) { Type * ty; if( (ty = Type_from_name(mts,type)) == NULL ) { warn("Type [%s] is not recognised as a logical Dynamite type. Assumming it is a real C type",type); return StructElement_from_nameandtype(name,type); } return StructElement_from_nameandtype(name,ty->real); } /* Function: StructElement_from_nameandtype(name,type) * * Descrip: an internal for StructElement_from_MethodTypeSet. don't use otherwise please! * * * Arg: name [UNKN ] Undocumented argument [char *] * Arg: type [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [StructElement *] * */ # line 191 "method.dy" StructElement * StructElement_from_nameandtype(char * name,char * type) { StructElement * out; out = StructElement_alloc(); out->name = stringalloc(name); out->element_type = stringalloc(type); out->islinked = TRUE; return out; } # line 207 "method.dy" MethodTypeSet * read_MethodTypeSet_filename(char * filename) { FILE * ifp; MethodTypeSet * mts; ifp=openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open [%s] for MethodTypeSet reading",filename); return FALSE; } mts = read_MethodTypeSet(ifp); fclose(ifp); return mts; } # line 226 "method.dy" boolean read_into_MethodTypeSet_filename(MethodTypeSet * mts,char * filename) { FILE * ifp; boolean ret; ifp=openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open [%s] for MethodTypeSet reading",filename); return FALSE; } ret = read_into_MethodTypeSet(mts,ifp); fclose(ifp); return ret; } # line 245 "method.dy" MethodTypeSet * standard_dynamite_MethodTypeSet(void) { MethodTypeSet * mts; Type * temp; mts = empty_MethodTypeSet(); temp = Type_alloc(); temp->logical=stringalloc("int"); temp->real=stringalloc("int"); add_ty_MethodTypeSet(mts,temp); temp = Type_alloc(); temp->logical=stringalloc("double"); temp->real=stringalloc("double"); add_ty_MethodTypeSet(mts,temp); temp = Type_alloc(); temp->logical=stringalloc("Score"); temp->real=stringalloc("Score"); add_ty_MethodTypeSet(mts,temp); return mts; } # line 272 "method.dy" MethodTypeSet * empty_MethodTypeSet(void) { return MethodTypeSet_alloc_std(); } # line 277 "method.dy" MethodTypeSet * read_MethodTypeSet(FILE * ifp) { MethodTypeSet * mts; mts = empty_MethodTypeSet(); read_into_MethodTypeSet(mts,ifp); return mts; } # line 288 "method.dy" boolean read_into_MethodTypeSet(MethodTypeSet * mts,FILE * ifp) { char buffer[MAXLINE]; Method * me; Type * ty; Input * in; while( fgets(buffer,MAXLINE,ifp) != NULL) { chop_newline(buffer); if( buffer[0] == '#' || strwhitestartcmp(buffer,"#",spacestr) == 0 ) continue; if( only_whitespace(buffer,spacestr) == TRUE) continue; if( strstartcmp(buffer,"method") == 0 ) { if( (me=read_Method_line(buffer,ifp)) == NULL ) { warn("Unable to read method in line [%s] ",buffer); } else { add_me_MethodTypeSet(mts,me); } } else if ( strstartcmp(buffer,"type") == 0 ) { if( (ty=read_Type_line(buffer,ifp)) == NULL ) { warn("Unable to read type in line [%s] ",buffer); } else { add_ty_MethodTypeSet(mts,ty); } } else if ( strstartcmp(buffer,"input") == 0 ) { if( (in = read_Input_line(buffer,ifp)) == NULL ) { warn("Unable to read type in line [%s]",buffer); } else { add_in_MethodTypeSet(mts,in); } } else { warn("In reading only method/types got an impossible line [%s]",buffer); } } return TRUE; } # line 331 "method.dy" boolean is_database_type(Type * ty) { if( ty->database_type == NULL || ty->reload_func == NULL || ty->init_func == NULL || ty->close_func == NULL) return FALSE; return TRUE; } /* Function: read_Type_line(line,ifp) * * Descrip: reads in a type structure from a line starting * * type * etc * * * Arg: line [UNKN ] first line with type [char *] * Arg: ifp [UNKN ] read file [FILE *] * * Return [UNKN ] Undocumented return value [Type *] * */ # line 349 "method.dy" Type * read_Type_line(char * line,FILE * ifp) { Type * out; char * temp; char buffer[MAXLINE]; if( strstartcmp(line,"type") != 0 ) { warn("Attempting to read a method with no method line!"); return NULL; } out = Type_alloc(); out->logical = second_word_alloc(line,spacestr); while( fgets(buffer,MAXLINE,ifp) != NULL ) { chop_newline(buffer); if( strstartcmp(buffer,"end") == 0 ) break; else if( strstartcmp(buffer,"real") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->real != NULL ) { warn("For type [%s], second real replacing [%s] with [%s]",out->logical,out->real,temp); ckfree(out->real); } out->real = temp; } else if( strstartcmp(buffer,"threadsafe") == 0 ) { out->is_thread_safe = TRUE; } else if ( strstartcmp(buffer,"dbtype") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->database_type != NULL ) { warn("For type [%s], second database type replacing [%s] with [%s]",out->logical,out->database_type,temp); ckfree(out->database_type); } out->database_type = temp; } else if ( strstartcmp(buffer,"init") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->init_func != NULL ) { warn("For type [%s], second init replacing [%s] with [%s]",out->logical,out->init_func,temp); ckfree(out->init_func); } out->init_func = temp; } else if ( strstartcmp(buffer,"maxlen") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->maxlen != NULL ) { warn("For type [%s], second maxlen replacing [%s] with [%s]",out->logical,out->maxlen,temp); ckfree(out->maxlen); } out->maxlen = temp; } else if ( strstartcmp(buffer,"reload") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->reload_func != NULL ) { warn("For type [%s], second reload function replacing [%s] with [%s]",out->logical,out->reload_func,temp); ckfree(out->reload_func); } out->reload_func = temp; } else if ( strstartcmp(buffer,"addentry") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->dataentry_add != NULL ) { warn("For type [%s], second dataentry_add function replacing [%s] with [%s]",out->logical,out->dataentry_add,temp); ckfree(out->dataentry_add); } out->dataentry_add = temp; } else if ( strstartcmp(buffer,"close") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->close_func != NULL ) { warn("For type [%s], second close func replacing [%s] with [%s]",out->logical,out->close_func,temp); ckfree(out->close_func); } out->close_func = temp; } else if ( strstartcmp(buffer,"hardlink") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->hard_link_func != NULL ) { warn("For type [%s], second hard_link func replacing [%s] with [%s]",out->logical,out->hard_link_func,temp); ckfree(out->hard_link_func); } out->hard_link_func = temp; } else if ( strstartcmp(buffer,"free") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->free_func != NULL ) { warn("For type [%s], second free func replacing [%s] with [%s]",out->logical,out->free_func,temp); ckfree(out->free_func); } out->free_func = temp; } else if ( strstartcmp(buffer,"name") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->get_id_func != NULL ) { warn("For type [%s], second get name func replacing [%s] with [%s]",out->logical,out->get_id_func,temp); ckfree(out->get_id_func); } out->get_id_func = temp; } else { warn("In reading type [%s] did not understand [%s]",out->logical,buffer); } } if( out->is_thread_safe == TRUE ) { if( out->hard_link_func == NULL || out->free_func == NULL ) { warn("Trying to make type %s threadsafe but have not supplied hardlink and free functions",out->logical); out->is_thread_safe = FALSE; } } out->is_database = is_database_type(out); return out; } # line 455 "method.dy" Method * read_Method_line(char * line,FILE * ifp) { Method * out; char buffer[MAXLINE]; char * temp; MethodArg * m; if( strstartcmp(line,"method") != 0 ) { warn("Attempting to read a method with no method line!"); return NULL; } out = Method_alloc_std(); out->logical = second_word_alloc(line,spacestr); while( fgets(buffer,MAXLINE,ifp) != NULL ) { chop_newline(buffer); if( strstartcmp(buffer,"end") == 0 ) break; else if( strstartcmp(buffer,"map") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->real != NULL ) { warn("For method [%s], second map replacing [%s] with [%s]",out->logical,out->real,temp); ckfree(out->real); } out->real = temp; } else if ( strstartcmp(buffer,"arg") == 0 ) { m = MethodArg_from_line(buffer); if( m == NULL ) { warn("Got a NULL method arg. Yikes!"); } else { add_Method(out,m); } } else if ( strstartcmp(buffer,"return") == 0 ) { out->retstr = second_word_alloc(buffer,spacestr); } else { warn("In method [%s] did not understand %s",out->logical,buffer); } } return out; } /* Function: MethodArg_from_line(line) * * Descrip: reads in from line like * * arg PROTEIN * * * Arg: line [UNKN ] pointer to buffer [char *] * * Return [UNKN ] Undocumented return value [MethodArg *] * */ # line 507 "method.dy" MethodArg * MethodArg_from_line(char * line) { MethodArg * out; if( strstartcmp(line,"arg") != 0 ) { warn("Attempting to read a method argument with no arg line!"); return NULL; } out = MethodArg_alloc(); out->type = second_word_alloc(line,spacestr); return out; } # line 527 "method.c" /* Function: hard_link_MethodArg(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MethodArg *] * * Return [UNKN ] Undocumented return value [MethodArg *] * */ MethodArg * hard_link_MethodArg(MethodArg * obj) { if( obj == NULL ) { warn("Trying to hard link to a MethodArg object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: MethodArg_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MethodArg *] * */ MethodArg * MethodArg_alloc(void) { MethodArg * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(MethodArg *) ckalloc (sizeof(MethodArg))) == NULL) { warn("MethodArg_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = NULL; return out; } /* Function: free_MethodArg(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MethodArg *] * * Return [UNKN ] Undocumented return value [MethodArg *] * */ MethodArg * free_MethodArg(MethodArg * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a MethodArg obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->type != NULL) ckfree(obj->type); ckfree(obj); return NULL; } /* Function: swap_Method(list,i,j) * * Descrip: swap function: an internal for qsort_Method * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [MethodArg **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Method(MethodArg ** list,int i,int j) { MethodArg * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Method(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Method which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [MethodArg **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Method(MethodArg ** list,int left,int right,int (*comp)(MethodArg * ,MethodArg * )) { int i,last; if( left >= right ) return; swap_Method(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Method (list,++last,i); } swap_Method (list,left,last); qsort_Method(list,left,last-1,comp); qsort_Method(list,last+1,right,comp); } /* Function: sort_Method(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Method * * * Arg: obj [UNKN ] Object containing list [Method *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Method(Method * obj,int (*comp)(MethodArg *, MethodArg *)) { qsort_Method(obj->ma,0,obj->len-1,comp); return; } /* Function: expand_Method(obj,len) * * Descrip: Really an internal function for add_Method * * * Arg: obj [UNKN ] Object which contains the list [Method *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Method(Method * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Method called with no need"); return TRUE; } if( (obj->ma = (MethodArg ** ) ckrealloc (obj->ma,sizeof(MethodArg *)*len)) == NULL) { warn("ckrealloc failed for expand_Method, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Method(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Method *] * Arg: add [OWNER] Object to add to the list [MethodArg *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Method(Method * obj,MethodArg * add) { if( obj->len >= obj->maxlen) { if( expand_Method(obj,obj->len + MethodLISTLENGTH) == FALSE) return FALSE; } obj->ma[obj->len++]=add; return TRUE; } /* Function: flush_Method(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Method *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Method(Method * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->ma[i] != NULL) { free_MethodArg(obj->ma[i]); obj->ma[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: Method_alloc_std(void) * * Descrip: Equivalent to Method_alloc_len(MethodLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Method *] * */ Method * Method_alloc_std(void) { return Method_alloc_len(MethodLISTLENGTH); } /* Function: Method_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Method *] * */ Method * Method_alloc_len(int len) { Method * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Method_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->ma = (MethodArg ** ) ckcalloc (len,sizeof(MethodArg *))) == NULL) { warn("Warning, ckcalloc failed in Method_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_Method(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Method *] * * Return [UNKN ] Undocumented return value [Method *] * */ Method * hard_link_Method(Method * obj) { if( obj == NULL ) { warn("Trying to hard link to a Method object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Method_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Method *] * */ Method * Method_alloc(void) { Method * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Method *) ckalloc (sizeof(Method))) == NULL) { warn("Method_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->logical = NULL; out->real = NULL; out->retstr = NULL; out->ma = NULL; out->len = out->maxlen = 0; out->cugen_map = NULL; out->cugen_type = CUGEN_METHOD_UNKNOWN; return out; } /* Function: free_Method(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Method *] * * Return [UNKN ] Undocumented return value [Method *] * */ Method * free_Method(Method * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Method obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->logical != NULL) ckfree(obj->logical); if( obj->real != NULL) ckfree(obj->real); if( obj->retstr != NULL) ckfree(obj->retstr); if( obj->ma != NULL) { for(i=0;ilen;i++) { if( obj->ma[i] != NULL) free_MethodArg(obj->ma[i]); } ckfree(obj->ma); } if( obj->cugen_map != NULL) ckfree(obj->cugen_map); ckfree(obj); return NULL; } /* Function: hard_link_Type(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Type *] * * Return [UNKN ] Undocumented return value [Type *] * */ Type * hard_link_Type(Type * obj) { if( obj == NULL ) { warn("Trying to hard link to a Type object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Type_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Type *] * */ Type * Type_alloc(void) { Type * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Type *) ckalloc (sizeof(Type))) == NULL) { warn("Type_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->is_database = FALSE; out->is_thread_safe = FALSE; out->logical = NULL; out->real = NULL; out->database_type = NULL; out->get_id_func = NULL; out->init_func = NULL; out->reload_func = NULL; out->close_func = NULL; out->dataentry_add = NULL; out->maxlen = NULL; out->hard_link_func = NULL; out->free_func = NULL; out->in = NULL; return out; } /* Function: free_Type(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Type *] * * Return [UNKN ] Undocumented return value [Type *] * */ Type * free_Type(Type * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Type obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->logical != NULL) ckfree(obj->logical); if( obj->real != NULL) ckfree(obj->real); if( obj->database_type != NULL) ckfree(obj->database_type); if( obj->get_id_func != NULL) ckfree(obj->get_id_func); if( obj->init_func != NULL) ckfree(obj->init_func); if( obj->reload_func != NULL) ckfree(obj->reload_func); if( obj->close_func != NULL) ckfree(obj->close_func); if( obj->dataentry_add != NULL) ckfree(obj->dataentry_add); if( obj->maxlen != NULL) ckfree(obj->maxlen); if( obj->hard_link_func != NULL) ckfree(obj->hard_link_func); if( obj->free_func != NULL) ckfree(obj->free_func); if( obj->in != NULL) free_Input(obj->in); ckfree(obj); return NULL; } /* Function: swap_me_MethodTypeSet(list,i,j) * * Descrip: swap function: an internal for qsort_me_MethodTypeSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Method **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_me_MethodTypeSet(Method ** list,int i,int j) { Method * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_me_MethodTypeSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_me_MethodTypeSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Method **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_me_MethodTypeSet(Method ** list,int left,int right,int (*comp)(Method * ,Method * )) { int i,last; if( left >= right ) return; swap_me_MethodTypeSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_me_MethodTypeSet (list,++last,i); } swap_me_MethodTypeSet (list,left,last); qsort_me_MethodTypeSet(list,left,last-1,comp); qsort_me_MethodTypeSet(list,last+1,right,comp); } /* Function: sort_me_MethodTypeSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_me_MethodTypeSet * * * Arg: obj [UNKN ] Object containing list [MethodTypeSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_me_MethodTypeSet(MethodTypeSet * obj,int (*comp)(Method *, Method *)) { qsort_me_MethodTypeSet(obj->me,0,obj->me_len-1,comp); return; } /* Function: expand_me_MethodTypeSet(obj,len) * * Descrip: Really an internal function for add_me_MethodTypeSet * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_me_MethodTypeSet(MethodTypeSet * obj,int len) { if( obj->me_maxlen > obj->me_len ) { warn("expand_MethodTypeSetme_ called with no need"); return TRUE; } if( (obj->me = (Method ** ) ckrealloc (obj->me,sizeof(Method *)*len)) == NULL) { warn("ckrealloc failed for expand_MethodTypeSet, returning FALSE"); return FALSE; } obj->me_maxlen = len; return TRUE; } /* Function: add_me_MethodTypeSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * Arg: add [OWNER] Object to add to the list [Method *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_me_MethodTypeSet(MethodTypeSet * obj,Method * add) { if( obj->me_len >= obj->me_maxlen) { if( expand_me_MethodTypeSet(obj,obj->me_len + MethodTypeSetLISTLENGTH) == FALSE) return FALSE; } obj->me[obj->me_len++]=add; return TRUE; } /* Function: flush_me_MethodTypeSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_me_MethodTypeSet(MethodTypeSet * obj) { int i; for(i=0;ime_len;i++) { /*for i over list length*/ if( obj->me[i] != NULL) { free_Method(obj->me[i]); obj->me[i] = NULL; } } /* end of for i over list length */ obj->me_len = 0; return i; } /* Function: swap_ty_MethodTypeSet(list,i,j) * * Descrip: swap function: an internal for qsort_ty_MethodTypeSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Type **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ty_MethodTypeSet(Type ** list,int i,int j) { Type * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ty_MethodTypeSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ty_MethodTypeSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Type **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ty_MethodTypeSet(Type ** list,int left,int right,int (*comp)(Type * ,Type * )) { int i,last; if( left >= right ) return; swap_ty_MethodTypeSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ty_MethodTypeSet (list,++last,i); } swap_ty_MethodTypeSet (list,left,last); qsort_ty_MethodTypeSet(list,left,last-1,comp); qsort_ty_MethodTypeSet(list,last+1,right,comp); } /* Function: sort_ty_MethodTypeSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ty_MethodTypeSet * * * Arg: obj [UNKN ] Object containing list [MethodTypeSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ty_MethodTypeSet(MethodTypeSet * obj,int (*comp)(Type *, Type *)) { qsort_ty_MethodTypeSet(obj->ty,0,obj->ty_len-1,comp); return; } /* Function: expand_ty_MethodTypeSet(obj,len) * * Descrip: Really an internal function for add_ty_MethodTypeSet * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ty_MethodTypeSet(MethodTypeSet * obj,int len) { if( obj->ty_maxlen > obj->ty_len ) { warn("expand_MethodTypeSetty_ called with no need"); return TRUE; } if( (obj->ty = (Type ** ) ckrealloc (obj->ty,sizeof(Type *)*len)) == NULL) { warn("ckrealloc failed for expand_MethodTypeSet, returning FALSE"); return FALSE; } obj->ty_maxlen = len; return TRUE; } /* Function: add_ty_MethodTypeSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * Arg: add [OWNER] Object to add to the list [Type *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ty_MethodTypeSet(MethodTypeSet * obj,Type * add) { if( obj->ty_len >= obj->ty_maxlen) { if( expand_ty_MethodTypeSet(obj,obj->ty_len + MethodTypeSetLISTLENGTH) == FALSE) return FALSE; } obj->ty[obj->ty_len++]=add; return TRUE; } /* Function: flush_ty_MethodTypeSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ty_MethodTypeSet(MethodTypeSet * obj) { int i; for(i=0;ity_len;i++) { /*for i over list length*/ if( obj->ty[i] != NULL) { free_Type(obj->ty[i]); obj->ty[i] = NULL; } } /* end of for i over list length */ obj->ty_len = 0; return i; } /* Function: swap_in_MethodTypeSet(list,i,j) * * Descrip: swap function: an internal for qsort_in_MethodTypeSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Input **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_in_MethodTypeSet(Input ** list,int i,int j) { Input * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_in_MethodTypeSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_in_MethodTypeSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Input **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_in_MethodTypeSet(Input ** list,int left,int right,int (*comp)(Input * ,Input * )) { int i,last; if( left >= right ) return; swap_in_MethodTypeSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_in_MethodTypeSet (list,++last,i); } swap_in_MethodTypeSet (list,left,last); qsort_in_MethodTypeSet(list,left,last-1,comp); qsort_in_MethodTypeSet(list,last+1,right,comp); } /* Function: sort_in_MethodTypeSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_in_MethodTypeSet * * * Arg: obj [UNKN ] Object containing list [MethodTypeSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_in_MethodTypeSet(MethodTypeSet * obj,int (*comp)(Input *, Input *)) { qsort_in_MethodTypeSet(obj->in,0,obj->in_len-1,comp); return; } /* Function: expand_in_MethodTypeSet(obj,len) * * Descrip: Really an internal function for add_in_MethodTypeSet * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_in_MethodTypeSet(MethodTypeSet * obj,int len) { if( obj->in_maxlen > obj->in_len ) { warn("expand_MethodTypeSetin_ called with no need"); return TRUE; } if( (obj->in = (Input ** ) ckrealloc (obj->in,sizeof(Input *)*len)) == NULL) { warn("ckrealloc failed for expand_MethodTypeSet, returning FALSE"); return FALSE; } obj->in_maxlen = len; return TRUE; } /* Function: add_in_MethodTypeSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * Arg: add [OWNER] Object to add to the list [Input *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_in_MethodTypeSet(MethodTypeSet * obj,Input * add) { if( obj->in_len >= obj->in_maxlen) { if( expand_in_MethodTypeSet(obj,obj->in_len + MethodTypeSetLISTLENGTH) == FALSE) return FALSE; } obj->in[obj->in_len++]=add; return TRUE; } /* Function: flush_in_MethodTypeSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_in_MethodTypeSet(MethodTypeSet * obj) { int i; for(i=0;iin_len;i++) { /*for i over list length*/ if( obj->in[i] != NULL) { free_Input(obj->in[i]); obj->in[i] = NULL; } } /* end of for i over list length */ obj->in_len = 0; return i; } /* Function: MethodTypeSet_alloc_std(void) * * Descrip: Equivalent to MethodTypeSet_alloc_len(MethodTypeSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [MethodTypeSet *] * */ MethodTypeSet * MethodTypeSet_alloc_std(void) { return MethodTypeSet_alloc_len(MethodTypeSetLISTLENGTH); } /* Function: MethodTypeSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [MethodTypeSet *] * */ MethodTypeSet * MethodTypeSet_alloc_len(int len) { MethodTypeSet * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = MethodTypeSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->me = (Method ** ) ckcalloc (len,sizeof(Method *))) == NULL) { warn("Warning, ckcalloc failed in MethodTypeSet_alloc_len"); return NULL; } out->me_len = 0; out->me_maxlen = len; if((out->ty = (Type ** ) ckcalloc (len,sizeof(Type *))) == NULL) { warn("Warning, ckcalloc failed in MethodTypeSet_alloc_len"); return NULL; } out->ty_len = 0; out->ty_maxlen = len; if((out->in = (Input ** ) ckcalloc (len,sizeof(Input *))) == NULL) { warn("Warning, ckcalloc failed in MethodTypeSet_alloc_len"); return NULL; } out->in_len = 0; out->in_maxlen = len; return out; } /* Function: hard_link_MethodTypeSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [MethodTypeSet *] * */ MethodTypeSet * hard_link_MethodTypeSet(MethodTypeSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a MethodTypeSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: MethodTypeSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MethodTypeSet *] * */ MethodTypeSet * MethodTypeSet_alloc(void) { MethodTypeSet * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(MethodTypeSet *) ckalloc (sizeof(MethodTypeSet))) == NULL) { warn("MethodTypeSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->me = NULL; out->me_len = out->me_maxlen = 0; out->ty = NULL; out->ty_len = out->ty_maxlen = 0; out->in = NULL; out->in_len = out->in_maxlen = 0; return out; } /* Function: free_MethodTypeSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [MethodTypeSet *] * */ MethodTypeSet * free_MethodTypeSet(MethodTypeSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a MethodTypeSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->me != NULL) { for(i=0;ime_len;i++) { if( obj->me[i] != NULL) free_Method(obj->me[i]); } ckfree(obj->me); } if( obj->ty != NULL) { for(i=0;ity_len;i++) { if( obj->ty[i] != NULL) free_Type(obj->ty[i]); } ckfree(obj->ty); } if( obj->in != NULL) { for(i=0;iin_len;i++) { if( obj->in[i] != NULL) free_Input(obj->in[i]); } ckfree(obj->in); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/method.h0000644000175000001440000003347610670453715015075 0ustar philippusers#ifndef DYNAMITEmethodHEADERFILE #define DYNAMITEmethodHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "input.h" #include "wisec.h" #define MethodLISTLENGTH 16 #define MethodTypeSetLISTLENGTH 16 enum COMPUGEN_METHOD_MAP { CUGEN_METHOD_UNKNOWN = 78, CUGEN_METHOD_TSEQ, CUGEN_METHOD_WINDEX }; struct MethodArg { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * type; } ; /* MethodArg defined */ #ifndef DYNAMITE_DEFINED_MethodArg typedef struct MethodArg MethodArg; #define DYNAMITE_DEFINED_MethodArg #endif struct Method { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * logical; char * real; char * retstr; MethodArg ** ma; int len;/* len for above ma */ int maxlen; /* maxlen for above ma */ char * cugen_map; int cugen_type; } ; /* Method defined */ #ifndef DYNAMITE_DEFINED_Method typedef struct Method Method; #define DYNAMITE_DEFINED_Method #endif struct Type { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif boolean is_database; boolean is_thread_safe; char * logical; char * real; char * database_type; char * get_id_func; char * init_func; char * reload_func; char * close_func; char * dataentry_add; char * maxlen; char * hard_link_func; char * free_func; Input * in; } ; /* Type defined */ #ifndef DYNAMITE_DEFINED_Type typedef struct Type Type; #define DYNAMITE_DEFINED_Type #endif struct MethodTypeSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Method ** me; int me_len; /* len for above me */ int me_maxlen; /* maxlen for above me */ Type ** ty; int ty_len; /* len for above ty */ int ty_maxlen; /* maxlen for above ty */ Input ** in; int in_len; /* len for above in */ int in_maxlen; /* maxlen for above in */ } ; /* MethodTypeSet defined */ #ifndef DYNAMITE_DEFINED_MethodTypeSet typedef struct MethodTypeSet MethodTypeSet; #define DYNAMITE_DEFINED_MethodTypeSet #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: StructElement_from_MethodTypeSet(name,type,mts) * * Descrip: function which handles the logical->real mapping * * At the moment "unmappable" types get assummed to be C types, * trigger a warning and return the correct thing. * * * Arg: name [UNKN ] Undocumented argument [char *] * Arg: type [UNKN ] Undocumented argument [char *] * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [StructElement *] * */ StructElement * StructElement_from_MethodTypeSet(char * name,char * type,MethodTypeSet * mts); /* Function: read_Type_line(line,ifp) * * Descrip: reads in a type structure from a line starting * * type * etc * * * Arg: line [UNKN ] first line with type [char *] * Arg: ifp [UNKN ] read file [FILE *] * * Return [UNKN ] Undocumented return value [Type *] * */ Type * read_Type_line(char * line,FILE * ifp); /* Function: MethodArg_from_line(line) * * Descrip: reads in from line like * * arg PROTEIN * * * Arg: line [UNKN ] pointer to buffer [char *] * * Return [UNKN ] Undocumented return value [MethodArg *] * */ MethodArg * MethodArg_from_line(char * line); /* Function: hard_link_MethodArg(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MethodArg *] * * Return [UNKN ] Undocumented return value [MethodArg *] * */ MethodArg * hard_link_MethodArg(MethodArg * obj); /* Function: MethodArg_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MethodArg *] * */ MethodArg * MethodArg_alloc(void); /* Function: free_MethodArg(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MethodArg *] * * Return [UNKN ] Undocumented return value [MethodArg *] * */ MethodArg * free_MethodArg(MethodArg * obj); /* Function: add_Method(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Method *] * Arg: add [OWNER] Object to add to the list [MethodArg *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_Method(Method * obj,MethodArg * add); /* Function: flush_Method(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Method *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Method(Method * obj); /* Function: Method_alloc_std(void) * * Descrip: Equivalent to Method_alloc_len(MethodLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Method *] * */ Method * Method_alloc_std(void); /* Function: Method_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Method *] * */ Method * Method_alloc_len(int len); /* Function: hard_link_Method(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Method *] * * Return [UNKN ] Undocumented return value [Method *] * */ Method * hard_link_Method(Method * obj); /* Function: Method_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Method *] * */ Method * Method_alloc(void); /* Function: free_Method(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Method *] * * Return [UNKN ] Undocumented return value [Method *] * */ Method * free_Method(Method * obj); /* Function: hard_link_Type(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Type *] * * Return [UNKN ] Undocumented return value [Type *] * */ Type * hard_link_Type(Type * obj); /* Function: Type_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Type *] * */ Type * Type_alloc(void); /* Function: free_Type(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Type *] * * Return [UNKN ] Undocumented return value [Type *] * */ Type * free_Type(Type * obj); /* Function: add_me_MethodTypeSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * Arg: add [OWNER] Object to add to the list [Method *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_me_MethodTypeSet(MethodTypeSet * obj,Method * add); /* Function: flush_me_MethodTypeSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_me_MethodTypeSet(MethodTypeSet * obj); /* Function: add_ty_MethodTypeSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * Arg: add [OWNER] Object to add to the list [Type *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_ty_MethodTypeSet(MethodTypeSet * obj,Type * add); /* Function: flush_ty_MethodTypeSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ty_MethodTypeSet(MethodTypeSet * obj); /* Function: add_in_MethodTypeSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * Arg: add [OWNER] Object to add to the list [Input *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_in_MethodTypeSet(MethodTypeSet * obj,Input * add); /* Function: flush_in_MethodTypeSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_in_MethodTypeSet(MethodTypeSet * obj); /* Function: MethodTypeSet_alloc_std(void) * * Descrip: Equivalent to MethodTypeSet_alloc_len(MethodTypeSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [MethodTypeSet *] * */ MethodTypeSet * MethodTypeSet_alloc_std(void); /* Function: MethodTypeSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [MethodTypeSet *] * */ MethodTypeSet * MethodTypeSet_alloc_len(int len); /* Function: hard_link_MethodTypeSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [MethodTypeSet *] * */ MethodTypeSet * hard_link_MethodTypeSet(MethodTypeSet * obj); /* Function: MethodTypeSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MethodTypeSet *] * */ MethodTypeSet * MethodTypeSet_alloc(void); /* Function: free_MethodTypeSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [MethodTypeSet *] * */ MethodTypeSet * free_MethodTypeSet(MethodTypeSet * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ void show_MethodTypeSet(MethodTypeSet * mts,FILE * ofp); void show_Method(Method * m,FILE * ofp); void show_MethodArg(MethodArg * ma,FILE * ofp); void show_Type(Type * ty,FILE * ofp); MethodTypeSet * read_MethodTypeSet_filename(char * filename); boolean read_into_MethodTypeSet_filename(MethodTypeSet * mts,char * filename); MethodTypeSet * standard_dynamite_MethodTypeSet(void); MethodTypeSet * empty_MethodTypeSet(void); MethodTypeSet * read_MethodTypeSet(FILE * ifp); boolean read_into_MethodTypeSet(MethodTypeSet * mts,FILE * ifp); boolean is_database_type(Type * ty); Method * read_Method_line(char * line,FILE * ifp); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ Type * Type_from_name(MethodTypeSet * mts,char * name); boolean compare_type(char * s,char * t); Method * Method_from_name(MethodTypeSet * mts,char * name); StructElement * StructElement_from_nameandtype(char * name,char * type); void swap_Method(MethodArg ** list,int i,int j) ; void qsort_Method(MethodArg ** list,int left,int right,int (*comp)(MethodArg * ,MethodArg * )); void sort_Method(Method * obj,int (*comp)(MethodArg *, MethodArg *)); boolean expand_Method(Method * obj,int len); void swap_me_MethodTypeSet(Method ** list,int i,int j) ; void qsort_me_MethodTypeSet(Method ** list,int left,int right,int (*comp)(Method * ,Method * )); void sort_me_MethodTypeSet(MethodTypeSet * obj,int (*comp)(Method *, Method *)); boolean expand_me_MethodTypeSet(MethodTypeSet * obj,int len); void swap_ty_MethodTypeSet(Type ** list,int i,int j) ; void qsort_ty_MethodTypeSet(Type ** list,int left,int right,int (*comp)(Type * ,Type * )); void sort_ty_MethodTypeSet(MethodTypeSet * obj,int (*comp)(Type *, Type *)); boolean expand_ty_MethodTypeSet(MethodTypeSet * obj,int len); void swap_in_MethodTypeSet(Input ** list,int i,int j) ; void qsort_in_MethodTypeSet(Input ** list,int left,int right,int (*comp)(Input * ,Input * )); void sort_in_MethodTypeSet(MethodTypeSet * obj,int (*comp)(Input *, Input *)); boolean expand_in_MethodTypeSet(MethodTypeSet * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/friend.dy0000644000175000001440000000211707313404534015230 0ustar philippusers %{ #include "dynfile.h" %} struct Friend char * name %{ #include "friend.h" Friend * read_Friend_line(char * line,FILE * ifp) { Friend * out; char * runner; if( strstartcmp(line,"friend") != 0 ) { warn("Trying to read [%s] as a friend line? I think not!"); } runner = strtok(line,spacestr); runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("Could not find any friend for a friend line. Sad!"); } out = Friend_alloc(); out->name = stringalloc(runner); return out; } void write_Friend_header(DYNFILE * dfp,Friend * fr) { if( dfp->package_name != NULL ) { fprintf(dfp->head,"#ifndef DYNAMITE_DEFINED_%s\n",fr->name); fprintf(dfp->head,"typedef struct %s%s %s%s;\n",dfp->package_name,fr->name,dfp->package_name,fr->name); fprintf(dfp->head,"#define %s %s%s\n",fr->name,dfp->package_name,fr->name); fprintf(dfp->head,"#define DYNAMITE_DEFINED_%s\n#endif\n\n",fr->name); } else fprintf(dfp->head,"#ifndef DYNAMITE_DEFINED_%s\ntypedef struct %s %s;\n#define DYNAMITE_DEFINED_%s\n#endif\n\n",fr->name,fr->name,fr->name,fr->name); } wise-2.4.1/src/dyc/variable.c0000644000175000001440000000510610670453715015362 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "variable.h" # line 7 "variable.c" /* Function: hard_link_MatrixVariable(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MatrixVariable *] * * Return [UNKN ] Undocumented return value [MatrixVariable *] * */ MatrixVariable * hard_link_MatrixVariable(MatrixVariable * obj) { if( obj == NULL ) { warn("Trying to hard link to a MatrixVariable object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: MatrixVariable_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MatrixVariable *] * */ MatrixVariable * MatrixVariable_alloc(void) { MatrixVariable * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(MatrixVariable *) ckalloc (sizeof(MatrixVariable))) == NULL) { warn("MatrixVariable_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->type = 0; out->dim1 = 0; out->dim2 = 0; out->source = NULL; return out; } /* Function: free_MatrixVariable(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MatrixVariable *] * * Return [UNKN ] Undocumented return value [MatrixVariable *] * */ MatrixVariable * free_MatrixVariable(MatrixVariable * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a MatrixVariable obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->source != NULL) ckfree(obj->source); /* obj->data is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/variable.h0000644000175000001440000000670410670453715015374 0ustar philippusers#ifndef DYNAMITEvariableHEADERFILE #define DYNAMITEvariableHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" /********************************************************/ /* Wisetools version 3 file */ /* */ /* this file is copyright (c) Ewan Birney 1996 */ /* this file is part of the wisetools sequence analysis */ /* package */ /********************************************************/ /********************************************************/ /* Variable is a structure which is shared between */ /* compile and runtime dynamite for managing variables */ /* for fast code. The data line is only present in */ /* the run-time version */ /********************************************************/ /***** RCS Info *****************************************/ /* $Id: variable.dy,v 1.1.1.1 2001/06/18 13:59:57 birney Exp $ $Log: variable.dy,v $ Revision 1.1.1.1 2001/06/18 13:59:57 birney moved wise2 to ensembl cvs repository Revision 1.1.1.1 1998/08/28 09:30:58 birney Wise2 * Revision 1.1 1996/05/02 15:29:32 birney * Initial revision * */ /********************************************************/ #define ZERO_DIMENSION 152 #define ONE_FIXED_DIMENSION 153 #define ONE_QUERY_DIMENSION 154 #define TWO_FIXED_DIMENSION 155 #define TWO_QUERY_DIMENSION 156 struct MatrixVariable { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; int type; int dim1; int dim2; char * source; void * data; } ; /* MatrixVariable defined */ #ifndef DYNAMITE_DEFINED_MatrixVariable typedef struct MatrixVariable MatrixVariable; #define DYNAMITE_DEFINED_MatrixVariable #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_MatrixVariable(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MatrixVariable *] * * Return [UNKN ] Undocumented return value [MatrixVariable *] * */ MatrixVariable * hard_link_MatrixVariable(MatrixVariable * obj); /* Function: MatrixVariable_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MatrixVariable *] * */ MatrixVariable * MatrixVariable_alloc(void); /* Function: free_MatrixVariable(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MatrixVariable *] * * Return [UNKN ] Undocumented return value [MatrixVariable *] * */ MatrixVariable * free_MatrixVariable(MatrixVariable * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/moduleinfo.dy0000644000175000001440000000017307313404534016122 0ustar philippusers %{ #include "ftext.h" %} struct ModuleInfo Ftext * ft // description of module %{ #include "moduleinfo.h" %} wise-2.4.1/src/dyc/dyshatter.c0000644000175000001440000003357310670453715015615 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dyshatter.h" /* Function: write_shatter_functions(dfp,gm,dpi) * * Descrip: Writes shatter functions * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ # line 19 "dyshatter.dy" void write_shatter_functions(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { macro(dfp,"#define %s_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j]",gm->name); macro(dfp,"#define %s_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE)",gm->name); add_break(dfp); write_shatter_read_func(dfp,gm); write_shatter_access_funcs(dfp,gm); matrix_calculate_shatter_func(dfp,gm); } # line 37 "dyshatter.dy" void write_shatter_access_funcs(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"%s_shatter_access_main",gm->name); start_function_FuncInfo(fi,dfp,"int %s_shatter_access_main(%s * mat,int i,int j,int state)",gm->name,gm->name); expr(dfp,"return %s_SHATTER_MATRIX(mat,i,j,state);",gm->name); close_function(dfp); add_break(dfp); fi = FuncInfo_named_from_varstr(FI_INTERNAL,"%s_shatter_access_special",gm->name); start_function_FuncInfo(fi,dfp,"int %s_shatter_access_special(%s * mat,int i,int j,int state)",gm->name,gm->name); expr(dfp,"return %s_SHATTER_SPECIAL(mat,i,j,state);",gm->name); close_function(dfp); add_break(dfp); } # line 55 "dyshatter.dy" void write_shatter_read_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"PackAln_read_Shatter_%s",gm->name); add_line_to_Ftext(fi->ft,"Reads off PackAln from shatter matrix structure",gm->name); start_function_FuncInfo(fi,dfp,"PackAln * PackAln_read_Shatter_%s(%s * mat)",gm->name,gm->name); expr(dfp,"%s_access_func_holder holder",gm->name); add_break(dfp); expr(dfp,"holder.access_main = %s_shatter_access_main;",gm->name); expr(dfp,"holder.access_special = %s_shatter_access_special;",gm->name); expr(dfp,"assert(mat)"); expr(dfp,"assert(mat->shatter)"); expr(dfp,"return PackAln_read_generic_%s(mat,holder);",gm->name); close_function(dfp); add_break(dfp); } /* Function: matrix_calculate_shatter_func(dfp,gm) * * Descrip: for shatter * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ # line 82 "dyshatter.dy" void matrix_calculate_shatter_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; ArgInfo * ai; CellSignatureSet * csig; int i; int j; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"calculate_shatter_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates the %s matrix when in shatter mode",gm->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); start_function_FuncInfo(fi,dfp,"boolean calculate_shatter_%s(%s * mat,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"int should_calc"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int tot;"); expr(dfp,"int num;"); expr(dfp,"int starti;"); expr(dfp,"int startj;"); expr(dfp,"int endi;"); expr(dfp,"int endj;"); add_break(dfp); csig = CellSignatureSet_from_GenericMatrix(gm); expr(dfp,"int * SIG_0_0;"); for(i=0;ilen;i++) { expr(dfp,"int * SIG_%d_%d;",csig->sig[i]->offi,csig->sig[i]->offj); } add_break(dfp); expr(dfp,"leni = mat->leni;"); expr(dfp,"lenj = mat->lenj;"); add_break(dfp); expr(dfp,"mat->shatter = new_ShatterMatrix(dpenv,%d,lenj,%d);",gm->len,gm->spec_len); expr(dfp,"prepare_DPEnvelope(dpenv)"); expr(dfp,"starti = dpenv->starti"); expr(dfp,"if( starti < 0 )"); hang_expr(dfp,"starti = 0"); expr(dfp,"startj = dpenv->startj"); expr(dfp,"if( startj < 0 )"); hang_expr(dfp,"startj = 0"); expr(dfp,"endi = dpenv->endi"); expr(dfp,"if( endi > mat->leni )"); hang_expr(dfp,"endi = mat->leni"); expr(dfp,"endj = dpenv->endj"); expr(dfp,"if( endj > mat->lenj )"); hang_expr(dfp,"endj = mat->lenj"); expr(dfp,"tot = (endi-starti) * (endj-startj);"); expr(dfp,"num = 0;"); /*** see if there any specials to specials to do ***/ add_break(dfp); expr(dfp,"start_reporting(\"%s Matrix calculation: \");",gm->name); expr(dfp,"for(j=startj;jlen;k++)"); startbrace(dfp); expr(dfp,"auto DPUnit * u;"); expr(dfp,"u = dpenv->dpu[k];"); expr(dfp,"switch(u->type)"); startbrace(dfp); expr(dfp,"case DPENV_RECT :"); startcase(dfp); expr(dfp,"if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length))"); hang_expr(dfp,"should_calc = 1"); expr(dfp,"break;"); closecase(dfp); expr(dfp,"case DPENV_DIAG :"); startcase(dfp); expr(dfp,"if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj)"); hang_expr(dfp,"should_calc = 1"); expr(dfp,"break;"); closecase(dfp); closebrace(dfp); expr(dfp,"if( should_calc == 1 )"); hang_expr(dfp,"break;"); closebrace(dfp); expr(dfp,"if( should_calc == 0)"); hang_expr(dfp,"continue;"); add_break(dfp); expr(dfp,"SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j);"); for(i=0;ilen;i++) { expr(dfp,"SIG_%d_%d = fetch_cell_from_ShatterMatrix(mat->shatter,i-%d,j-%d);",csig->sig[i]->offi,csig->sig[i]->offj,csig->sig[i]->offi,csig->sig[i]->offj); } add_break(dfp); write_score_block_shatter(dfp,gm,"SHATTER_","mat","SHATTER_SPECIAL",TRUE); closebrace(dfp); /**** if there are any specials do them here ****/ write_special_block(dfp,gm,"SHATTER_","SHATTER_SPECIAL",NULL); closebrace(dfp); /*** stop reporting ***/ expr(dfp,"stop_reporting()"); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } # line 229 "dyshatter.dy" void write_score_block_shatter(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointertag,char * specialtag,boolean use_special) { register int i; register int j; register int k; for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; add_break(dfp); if( state->footprint_start > 1 || state->footprint_end < 0) { add_block_comment(dfp,"State %s has a footprint of %d - %d",state->name,state->footprint_start,state->footprint_end); expr(dfp,"if( SEQENDWITHIN(%d) != TRUE || SEQSTARTWITHIN(%d) != TRUE )",state->footprint_end,state->footprint_start); startbrace_tag(dfp,"Footprint exists"); } add_block_comment(dfp,"For state %s",state->name); add_block_comment(dfp,"setting first movement to score",state->name); if( state->source[0]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(state->source[0]->position,state->source[0]->offi,state->source[0]->offj)); startbrace(dfp); } /*********************************************************************/ /* this line looks like */ /* score = ProteinMatrix_EXPL_MATRIX(mat,i-1,j-1,MATCH) + xxxxx */ /*********************************************************************/ expr(dfp,"score = SIG_%d_%d[%s] + %s",state->source[0]->offi,state->source[0]->offj, state->source[0]->state_source,state->source[0]->calc_expr); if( state->source[0]->isspecial == TRUE ) { fatal("Cannot have a special to matrix transition as the first transition"); } if( state->source[0]->position != SOURCE_POS_ALL) { closebrace(dfp); } if( dfp->code_debug_level > 5) { expr(dfp,"if( score > IMPOSSIBLY_HIGH_SCORE )"); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] State %s source %s Impossibly high score [%%d]\",i,j,score);",state->name,state->source[0]->state_source); } if( dfp->code_debug_level > 100 ) { expr(dfp,"fprintf(stderr,\"MATRIX: [%%4d][%%4d] State %s source %s got score %%d\\n\",i,j,score);",state->name,state->source[0]->state_source); } /**** ok this is to stop underflow, but is v.v.v. hacky ****/ /*** removing underflow hack expr(dfp,"if(score < (-10000000) )"); hang_expr(dfp,"score = (-10000000)"); ****/ /****************************************/ /* now we do if then on score and temp */ /****************************************/ for(j=1;jlen;j++) { if( use_special == FALSE && state->source[j]->isspecial == TRUE ) continue; /** don't use the special! **/ if( state->source[j]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(state->source[j]->position,state->source[j]->offi,state->source[j]->offj)); startbrace(dfp); } add_block_comment(dfp,"From state %s to state %s",state->source[j]->state_source, state->name); if( state->source[j]->isspecial == TRUE ) expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,specialtag,pointertag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr); else expr(dfp,"temp = SIG_%d_%d[%s] + %s", state->source[j]->offi,state->source[j]->offj, state->source[j]->state_source, state->source[j]->calc_expr); if( dfp->code_debug_level > 5) { expr(dfp,"if( temp > IMPOSSIBLY_HIGH_SCORE )"); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] State %s source %s Impossibly high score [%%d]\",i,j,temp);",state->name,state->source[j]->state_source); } if( dfp->code_debug_level > 100 ) { expr(dfp,"fprintf(stderr,\"MATRIX: [%%4d][%%4d] State %s source %s got score %%d\\n\",i,j,temp);",state->name,state->source[0]->state_source); } /**** ok this is to stop underflow, but is v.v.v. hacky ****/ /**** removing underflow hack expr(dfp,"if(score < (-10000000) )"); hang_expr(dfp,"score = (-10000000)"); ****/ /** if we have a specified calcfunc - use it here **/ if(gm->calcfunc != NULL ) { expr(dfp,"score = %s(score,temp);",gm->calcfunc); } else{ expr(dfp,"if( temp > score )"); startbrace(dfp); expr(dfp,"score = temp;"); /** ok for shadow matrix should put things in here */ closebrace(dfp); } if( state->source[j]->position != SOURCE_POS_ALL) { closebrace(dfp); } } /************************/ /* finished blocks */ /* put in global calc */ /************************/ add_break(dfp); add_block_comment(dfp,"Ok - finished max calculation for %s",state->name); add_block_comment(dfp,"Add any movement independant score and put away"); if( state->calc_expr != NULL) expr(dfp," score += %s",state->calc_expr); /***************************/ /* put away score */ /***************************/ expr(dfp," SIG_0_0[%s] = score;",state->name); if( use_special == FALSE ) { add_block_comment(dfp,"Finished calculating state %s",state->name); continue; } /************************/ /* for each special */ /* thats has this as */ /* source we have to */ /* update */ /************************/ for(j=0;jspec_len;j++) { auto CellState * specstate; specstate = gm->special[j]; for(k=0;klen;k++) { if( strcmp(specstate->source[k]->state_source,state->name) == 0) { /********************************/ /* is a special source! */ /********************************/ add_break(dfp); add_block_comment(dfp,"state %s is a source for special %s",state->name,specstate->name); if( specstate->source[k]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(specstate->source[k]->position,specstate->source[k]->offi,specstate->source[k]->offj)); startbrace(dfp); } expr(dfp,"temp = score + (%s) + (%s) ",specstate->source[k]->calc_expr,specstate->calc_expr == NULL ? "0" : specstate->calc_expr ); if(gm->calcfunc != NULL ) { expr(dfp,"%s_%s(%s,i,j,%s) = %s(%s_%s(%s,i,j,%s),temp);", gm->name,specialtag,pointertag,specstate->name, gm->calcfunc, gm->name,specialtag,pointertag,specstate->name); } else{ expr(dfp,"if( temp > %s_%s(%s,i,j,%s) ) ",gm->name,specialtag,pointertag,specstate->name); startbrace(dfp); expr(dfp,"%s_%s(%s,i,j,%s) = temp",gm->name,specialtag,pointertag,specstate->name); closebrace(dfp); add_break(dfp); } if( specstate->source[k]->position != SOURCE_POS_ALL) { closebrace(dfp); } } /* end of if this special state was a source for previous guy */ } /* end for each source of the special state */ if( dfp->code_debug_level > 4) { expr(dfp,"if( %s_%s(mat,0,j,%s) > IMPOSSIBLY_HIGH_SCORE )",gm->name,specialtag,specstate->name); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] Special state %s Impossibly high score [%%d] found\",i,j,%s_%s(mat,0,j,%s));",specstate->name,gm->name,specialtag,specstate->name); } } /* end for each special state */ if( state->footprint_start < 0 || state->footprint_end > 1 ) { closebrace(dfp); } add_break(dfp); add_block_comment(dfp,"Finished calculating state %s",state->name); } /* end of for each state */ } # line 469 "dyshatter.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/dyshatter.h0000644000175000001440000000323610670453715015613 0ustar philippusers#ifndef DYNAMITEdyshatterHEADERFILE #define DYNAMITEdyshatterHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dynafunc.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: write_shatter_functions(dfp,gm,dpi) * * Descrip: Writes shatter functions * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ void write_shatter_functions(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi); /* Function: matrix_calculate_shatter_func(dfp,gm) * * Descrip: for shatter * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ void matrix_calculate_shatter_func(DYNFILE * dfp,GenericMatrix * gm); /* Unplaced functions */ /* There has been no indication of the use of these functions */ void write_shatter_access_funcs(DYNFILE * dfp,GenericMatrix * gm); void write_shatter_read_func(DYNFILE * dfp,GenericMatrix * gm); void write_score_block_shatter(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointertag,char * specialtag,boolean use_special); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/LICENSE0000644000175000001440000000403707313404532014431 0ustar philippusersAll of the documentation and software included in the dyc directory of the Wise2 package directory is copyrighted by Genome Research Limited (GRL) and other individuals where appropiate. This license is modelled after the 'BSD' style license and is appropiate for use by both academic and commerical sites, without placing any restriction on the distribution of source code from other sources with this software. Copyright 1998, 1999, GRL and others. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2.Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3.Neither the name GRL nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. It is considered polite to indicate where appropiate that software which is developed using this source code includes a statement that it was developed using the Wise2 soure code. This is not a requirement however. THIS SOFTWARE IS PROVIDED BY THE GRL AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GRL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. wise-2.4.1/src/dyc/api.c0000644000175000001440000015557310670453715014364 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "api.h" # line 42 "api.dy" boolean write_pfdoc_dynAPI(dynAPI * api,char * package_name,FILE * ofp) { int i,j; for(i=0;ilen;i++) { auto APIObject * obj; obj = api->obj[i]; fprintf(ofp,":object %s\n",obj->name); for(j=0;jlen;j++) { fprintf(ofp,"\t:func %s\n",obj->member[j]->name); } fprintf(ofp,"\t:des %s\n",obj->destructor->name); fprintf(ofp,"\n\n"); } for(j=0;jnon_len;j++) { fprintf(ofp,":func %s\n",api->non_obj[j]->name); } fprintf(ofp,"\n\n"); for(i=0;ilen;i++) { auto APIObject * obj; obj = api->obj[i]; if( obj->info != NULL ) { fprintf(ofp,"\n:define %s\n",obj->name); fprintf(ofp,":desc\n"); dump_Ftext(obj->info->ft,ofp); fprintf(ofp,"!desc\n!defined\n\n"); } for(j=0;jlen;j++) { write_pfdoc_func_def(obj->member[j]->fi,ofp); fprintf(ofp,"\n\n"); } write_pfdoc_func_def(obj->destructor->fi,ofp); fprintf(ofp,"\n\n"); } for(i=0;inon_len;i++) { write_pfdoc_func_def(api->non_obj[i]->fi,ofp); fprintf(ofp,"\n\n"); } return TRUE; } # line 90 "api.dy" boolean write_pfdoc_func_def(FuncInfo * fi,FILE * ofp) { int i; fprintf(ofp,":define %s\n",fi->name); fprintf(ofp,":desc\n"); dump_Ftext(fi->ft,ofp); fprintf(ofp,"!desc\n"); fprintf(ofp,":arg\n"); for(i=0;ilen;i++) { fprintf(ofp,"%s [%s] %s\n",fi->arg[i]->name,fi->arg[i]->type,fi->arg[i]->desc); } fprintf(ofp,"!arg\n"); fprintf(ofp,":return\n"); fprintf(ofp,"%s [%s] %s\n",fi->ret->name,fi->ret->type,fi->ret->desc); fprintf(ofp,"!return\n"); fprintf(ofp,"!define"); return TRUE; } # line 112 "api.dy" boolean write_latex_dynAPI(dynAPI * api,char * module,char * package,FILE * ofp) { int i,j; fprintf(ofp,"\\section{%s}\n",module); fprintf(ofp,"\\label{module_%s}\n",module); if( api->len == 0 ) { fprintf(ofp,"This module only contains factory methods\n\n"); } else { fprintf(ofp,"This module contains the following objects\n\n\\begin{itemize}\n"); for(i=0;ilen;i++) fprintf(ofp,"\\item \\ref{object_%s} %s\n\n",api->obj[i]->name,api->obj[i]->name); if( api->non_len > 0 ) { fprintf(ofp,"\\item This module also contains some factory methods\n"); } fprintf(ofp,"\\end{itemize}\n"); } if( api->non_len > 0) { fprintf(ofp,"\\subsection{%s factory methods}\n",module); for(i=0;inon_len;i++) { fprintf(ofp,"\\subsubsection{%s}\n",api->non_obj[i]->name); write_latex_APIfunc(api->non_obj[i],package,FALSE,NULL,ofp); } fprintf(ofp,"\n\n"); } for(i=0;ilen;i++) { fprintf(ofp,"\\subsection{Object %s}\n\n",api->obj[i]->name); fprintf(ofp,"\\label{object_%s}\n\n",api->obj[i]->name); fprintf(ofp,"The %s object has the following fields. To see how to access them refer to \\ref{accessing_fields}\n",api->obj[i]->name); fprintf(ofp,"\\begin{description}\n"); for(j=0;jobj[i]->sh->len;j++) { fprintf(ofp,"\\item{%s} Type [%s : %s] %s\n\n",api->obj[i]->sh->el[j]->name,api->obj[i]->sh->el[j]->element_type,api->obj[i]->sh->el[j]->islist == TRUE ? "List" : "Scalar",api->obj[i]->sh->el[j]->comment == NULL ? "No documentation" : api->obj[i]->sh->el[j]->comment); } fprintf(ofp,"\\end{description}\n"); if( api->obj[i]->info == NULL ) { fprintf(ofp,"No documentation for %s\n\n",api->obj[i]->name); } else { latex_Ftext(api->obj[i]->info->ft,ofp); fprintf(ofp,"\n\n"); } fprintf(ofp,"Member functions of %s\n\n",api->obj[i]->name); for(j=0;jobj[i]->len;j++) { if( api->obj[i]->member[j]->fi->is_hand_written == TRUE) { fprintf(ofp,"\\subsubsection{%s}\n\n",api->obj[i]->member[j]->name); write_latex_APIfunc(api->obj[i]->member[j],package,TRUE,api->obj[i]->name,ofp); } } } return TRUE; } # line 170 "api.dy" boolean write_latex_APIfunc(APIfunc * f,char * package,boolean isobj,char * objectname,FILE * ofp) { FuncInfo * fi; int i; fi = f->fi; if( fi == NULL ) { warn("Could not make latex non API function due to no info!"); return FALSE; } fprintf(ofp,"\\begin{description}\n"); fprintf(ofp,"\\item[External C] {\\tt %s_%s (%s",package,fi->name,fi->len == 0 ? "void" : fi->arg[0]->name); if( f->only_C == TRUE ) { fprintf(ofp,"(This function is only available in the C api)"); } else { for(i=1;ilen;i++) fprintf(ofp,",%s",fi->arg[i]->name); fprintf(ofp,")}\n"); if( isobj == TRUE ) { fprintf(ofp,"\\item[Perl] {\\tt &%s::%s::%s (%s",package,objectname,fi->simple == NULL ? fi->name : fi->simple,fi->len == 0 ? "" : fi->arg[0]->name); } else { fprintf(ofp,"\\item[Perl] {\\tt &%s::%s (%s",package,fi->simple == NULL ? fi->name : fi->simple,fi->len == 0 ? "" : fi->arg[0]->name); } for(i=1;ilen;i++) { if( fi->arg[i]->should_NULL == TRUE ) continue; /* skip it out */ fprintf(ofp,",%s",fi->arg[i]->name); } fprintf(ofp,")}\n\n"); if( isobj == TRUE ) { if( fi->len == 0 ) { warn("Trying to indicate that %s is an object method when it doesn't have an argument",fi->name); } else { fprintf(ofp,"\\item[Perl-OOP call] {\\tt $obj->%s(%s",fi->simple == NULL ? fi->name : fi->simple,fi->len == 1 ? "" : fi->arg[1]->name); for(i=2;ilen;i++) { if( fi->arg[i]->should_NULL == TRUE ) continue; /* skip it out */ fprintf(ofp,",%s",fi->arg[i]->name); } fprintf(ofp,")}\n\n"); } } } /* end of is an non C based function */ fprintf(ofp,"\\end{description}\n"); fprintf(ofp,"Arguments\n\\begin{description}\n"); for(i=0;ilen;i++) { auto ArgInfo * ai; ai = fi->arg[i]; if( ai->should_NULL == TRUE ) fprintf(ofp,"\\item[%s] \\em{only for C api} [%s] %s [%s]\n",ai->name,ArgType_to_string(ai->argtype),ai->desc,CKS(ai->type)); else { fprintf(ofp,"\\item[%s] [%s] %s [%s]\n",ai->name,ArgType_to_string(ai->argtype),ai->desc,CKS(ai->type)); } } if( strcmp(fi->ret->type,"void") == 0 ) { fprintf(ofp,"\\item[returns] Nothing - no return value\n"); } else { fprintf(ofp,"\\item[returns] [%s] %s [%s]\n",ArgType_to_string(fi->ret->argtype),fi->ret->desc,CKS(fi->ret->type)); } fprintf(ofp,"\\end{description}\n"); latex_Ftext(fi->ft,ofp); return TRUE; } # line 244 "api.dy" boolean write_pod_dynAPI(dynAPI * api,char * module,char * package,FILE * ofp) { int i,j; fprintf(ofp,"=head1 NAME\n\n%s module - part of the %s package\n\n",module,package); if( api->len == 0 ) { fprintf(ofp,"=head1 SYNOPSIS\n\nThis module contains helper functions for the %s package\n\n",package); } else { fprintf(ofp,"=head1 SYNOPSIS\n\nThis module contains the following objects\n\n=over\n\n"); for(i=0;ilen;i++) fprintf(ofp,"=item %s\n\n",api->obj[i]->name); fprintf(ofp,"\n=back\n\n"); } fprintf(ofp,"=head1 DESCRIPTION\n\n"); for(i=0;ilen;i++) { fprintf(ofp,"=head2 Object %s\n\n=over\n\n",api->obj[i]->name); for(j=0;jobj[i]->sh->len;j++) { fprintf(ofp,"=item %s\n\n Type [%s] %s %s\n\n",api->obj[i]->sh->el[j]->name,api->obj[i]->sh->el[j]->element_type,api->obj[i]->sh->el[j]->islist == TRUE ? "List" : "Scalar",api->obj[i]->sh->el[j]->comment == NULL ? "No documentation" : api->obj[i]->sh->el[j]->comment); } fprintf(ofp,"\n\n=back\n\n"); if( api->obj[i]->info == NULL ) { fprintf(ofp,"No documentation for %s\n\n",api->obj[i]->name); } else { dump_Ftext(api->obj[i]->info->ft,ofp); fprintf(ofp,"\n\n"); } fprintf(ofp,"=head2 Member functions of %s\n\n",api->obj[i]->name); fprintf(ofp,"=over\n\n"); for(j=0;jobj[i]->len;j++) { fprintf(ofp,"=item %s\n\n",api->obj[i]->member[j]->fi->simple == NULL ? api->obj[i]->member[j]->name : api->obj[i]->member[j]->fi->simple); write_pod_obj_APIfunc(api->obj[i]->member[j],package,api->obj[i]->name,ofp); } fprintf(ofp,"=back\n\n"); } if( api->non_len > 0) { fprintf(ofp,"=over\n\n"); for(i=0;inon_len;i++) { fprintf(ofp,"=item %s\n\n",api->non_obj[i]->name); write_pod_non_APIfunc(api->non_obj[i],package,ofp); } fprintf(ofp,"=back\n\n"); } return TRUE; } # line 290 "api.dy" void write_pod_obj_APIfunc(APIfunc * f,char * package,char * obj,FILE * ofp) { FuncInfo * fi; int i; fi = f->fi; fprintf(ofp,"&%s::%s::%s(%s",package,obj,fi->simple == NULL ? fi->name : fi->simple ,fi->len == 0 ? "void" : fi->arg[0]->name); for(i=1;ilen;i++) fprintf(ofp,",%s",fi->arg[i]->name); fprintf(ofp,")\n\n"); dump_Ftext_pre(" ",fi->ft,ofp); fprintf(ofp,"\n\n"); for(i=0;ilen;i++) { auto ArgInfo * ai; ai = fi->arg[i]; if( ai->should_NULL == TRUE ) { continue; } fprintf(ofp," Argument %-12s [%s] %s [%s]\n",ai->name,ArgType_to_string(ai->argtype),ai->desc,CKS(ai->type)); } fprintf(ofp," Return [%s] %s [%s]\n",ArgType_to_string(fi->ret->argtype),fi->ret->desc,CKS(fi->ret->type)); fprintf(ofp,"\n\n"); } # line 319 "api.dy" void write_pod_non_APIfunc(APIfunc * f,char * package,FILE * ofp) { FuncInfo * fi; int i; fi = f->fi; fprintf(ofp,"&%s::%s(%s",package,fi->simple == NULL ? fi->name : fi->simple ,fi->len == 0 ? "void" : fi->arg[0]->name); for(i=1;ilen;i++) fprintf(ofp,",%s",fi->arg[i]->name); fprintf(ofp,")\n\n"); dump_Ftext_pre(" ",fi->ft,ofp); fprintf(ofp,"\n\n"); for(i=0;ilen;i++) { auto ArgInfo * ai; ai = fi->arg[i]; fprintf(ofp," Argument %-12s [%s] %s [%s]\n",ai->name,ArgType_to_string(ai->argtype),ai->desc,CKS(ai->type)); } fprintf(ofp," Return [%s] %s [%s]\n",ArgType_to_string(fi->ret->argtype),fi->ret->desc,CKS(fi->ret->type)); fprintf(ofp,"\n\n"); } # line 349 "api.dy" boolean write_type_C_dynAPI(dynAPI * api,char * package_name,FILE * ofp) { int i; for(i=0;ilen;i++) { auto APIObject * obj; obj = api->obj[i]; fprintf(ofp,"typedef struct %s%s %s%s;\n\n",package_name,obj->name,package_name,obj->name); } return TRUE; } # line 363 "api.dy" boolean write_C_dynAPI(dynAPI * api,char * package_name,FILE * ofp) { int i,j; for(i=0;ilen;i++) { auto APIObject * obj; obj = api->obj[i]; fprintf(ofp,"\n\n/* Functions that create, manipulate or act on %s\n *\n",obj->name); for(j=0;jlen;j++) { fprintf(ofp," * %s%s\n",package_name,obj->member[j]->name); } fprintf(ofp," * %s%s [destructor]\n",package_name,obj->destructor->name); fprintf(ofp," *\n */\n\n"); } if( api->non_len > 0 ) { fprintf(ofp,"\n\n/* Helper functions in the module\n *\n"); for(i=0;inon_len;i++) { fprintf(ofp," * %s%s\n",package_name,api->non_obj[i]->name); } fprintf(ofp," *\n\n"); } for(i=0;ilen;i++) { auto APIObject * obj; obj = api->obj[i]; fprintf(ofp,"/* API for object %s */\n",obj->name); for(j=0;jlen;j++) { write_C_APIfunc(obj->member[j],package_name,ofp); } fprintf(ofp,"/* This is the destructor function, ie, call this to free object*/\n"); write_C_APIfunc(obj->destructor,package_name,ofp); } if( api->non_len > 0 ) fprintf(ofp,"\n\n/* These functions are not associated with an object */\n"); for(i=0;inon_len;i++) { write_C_APIfunc(api->non_obj[i],package_name,ofp); } return TRUE; } # line 405 "api.dy" boolean write_C_APIfunc(APIfunc * api,char * package_name,FILE * ofp) { int i; FuncInfo * fi; fi = api->fi; fprintf(ofp,"/* Function: %s%s(%s",package_name,CKS(fi->name),fi->len == 0 ? "void" : fi->arg[0]->name); for(i=1;ilen;i++) fprintf(ofp,",%s",fi->arg[i]->name); fprintf(ofp,")\n *\n"); show_eddystyle_Ftext(fi->ft,"Descrip:",15,ofp,"No Description"); fprintf(ofp," *\n"); for(i=0;ilen;i++) fprintf(ofp," * %*s%-12s %s [%s%s]\n",-12,"Arg:",fi->arg[i]->name,fi->arg[i]->desc,is_basic_type_API(fi->arg[i]->type) == TRUE ? "" : package_name,fi->arg[i]->type); fprintf(ofp," *\n"); fprintf(ofp," * Returns %s [%s%s]\n",fi->ret->desc,is_basic_type_API(fi->ret->type) == TRUE ? "" : package_name,fi->ret->type); fprintf(ofp," *\n */\n"); fprintf(ofp,"%s%s ",is_basic_type_API(fi->ret->type) == TRUE ? "" : package_name,fi->ret->type); fprintf(ofp,"%s%s(",package_name,fi->name); for(i=0;ilen;i++) { if( fi->arg[i]->argtype == ARGTYPE_P2FUNC ) { fprintf(ofp,"%c%s",i == 0 ? ' ' : ',',fi->arg[i]->func_decl); } else { fprintf(ofp,"%c%s%s %s",i == 0 ? ' ' : ',',is_basic_type_API(fi->arg[i]->type) == TRUE ? "" : package_name,fi->arg[i]->type,fi->arg[i]->name); } } fprintf(ofp,");\n\n"); return TRUE; } # line 442 "api.dy" boolean is_membasic_type_API(char * type) { char * temp; if( is_basic_type_API(type) == FALSE) return FALSE; if( strstartcmp(type,"char") == 0 ) { if( (temp=strchr(type,'*')) != NULL ) { if( strchr(++temp,'*') != NULL ) { warn("Can't cope with char **'s or above!"); return TRUE; } else { return FALSE; /* char *'s are not membasic */ } } } return TRUE; /* default */ } # line 465 "api.dy" boolean is_basic_type_API(char * type) { if( strstartcmp(type,"const") == 0 ) return TRUE; /*** oops! ***/ if( strstartcmp(type,"char") == 0 ) return TRUE; if( strstartcmp(type,"FILE") == 0 ) return TRUE; if( strstartcmp(type,"double") == 0 ) return TRUE; if( strstartcmp(type,"float") == 0 ) return TRUE; if( strstartcmp(type,"short") == 0 ) return TRUE; if( strstartcmp(type,"long") == 0 ) return TRUE; if( strstartcmp(type,"int") == 0 ) return TRUE; if( strstartcmp(type,"void") == 0 ) return TRUE; if( strstartcmp(type,"boolean") == 0 ) return TRUE; if( strstartcmp(type,"Score") == 0 ) return TRUE; if( strstartcmp(type,"Probability") == 0 ) return TRUE; if( strstartcmp(type,"Bits") == 0 ) return TRUE; if( strstartcmp(type,"base") == 0 ) return TRUE; if( strstartcmp(type,"codon") == 0 ) return TRUE; if( strstartcmp(type,"aa") == 0 ) return TRUE; return FALSE; } # line 505 "api.dy" dynAPI * read_dynAPI_line(char * line,FILE * ifp) { char buffer[MAXLINE]; dynAPI * out; APIfunc * func; APIObject * obj; if( strstartcmp(line,"api") != 0 ) { warn("In building dynAPI, passed in a non api [%s]",line); return NULL; } out = dynAPI_alloc_std(); while( get_watched_line(buffer,MAXLINE,ifp) != NULL ) { if ( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"endapi") == 0 ) { break; } if( strstartcmp(buffer,"end") == 0 ) { warn("Got an end line but not endapi in api section. Don't like it [%s]",buffer); break; } if( strstartcmp(buffer,"func") == 0 ) { func = APIfunc_from_buffer(buffer); if( func == NULL ) continue; add_non_dynAPI(out,func); } else if ( strstartcmp(buffer,"object") == 0 ) { obj = APIObject_from_line(buffer,MAXLINE,ifp); if( obj == NULL ) continue; add_dynAPI(out,obj); } else { warn("In reading an api specification, [%s] not understood\n",buffer); } } return out; } # line 551 "api.dy" boolean write_perl_XS_accessor_functions(APIObject * obj,char * package,FILE * ofp) { int j; StructHolder * sh; char strippack[64]; char * listappend; char * runner; /* HACK coming up! */ strcpy(strippack,package); if( strippack[strlen(strippack)-1] == '_') strippack[strlen(strippack)-1] = '\0'; sh = obj->sh; for(j=0;jlen;j++) { auto StructElement * temp; temp = sh->el[j]; if( temp->ishidden == TRUE ) continue; /* skip it! */ if( temp->islist == TRUE ) { listappend=CKN(temp->len_append); runner = depointer_element(temp->element_type); runner = depointer_element(runner); while ( !isalpha(runner[strlen(runner)-1]) ) { runner[strlen(runner)-1] = '\0'; } fprintf(ofp,"void\neach_%s(obj)\n",temp->name); fprintf(ofp,"\t%s%s * obj\n",package,sh->name); fprintf(ofp,"\tPPCODE:\n\tint i=0;\n\tint len;\n\tSV* temp;\n\tlen = %s_length_%s_%s(obj);\n\tfor(i=0;iname,obj->name); fprintf(ofp,"\t temp = sv_newmortal();\n"); fprintf(ofp,"\t sv_setref_pv(temp, \"%s::%s\", (void*) (%shard_link_%s(%s_access_%s_%s(obj,i))));\n",strippack,runner,package,runner,strippack,temp->name,obj->name); fprintf(ofp,"\t XPUSHs(temp);\n"); fprintf(ofp,"\t }\n"); fprintf(ofp,"\tXSRETURN(len);\n\n"); } } return TRUE; } # line 598 "api.dy" boolean write_dynAPI_accessor_functions(DYNFILE * dfp,dynAPI * api) { int i,j; FuncInfo * fi; ArgInfo * ai; APIfunc * af; boolean islist; char * runner; char * listappend; /* Ngggg! We have to check if there is a list or not. this was bad API design in wisec.dy sometime ago. (like - years ago ) Yuk! yuk! */ for(i=0;ilen;i++) { auto APIObject * obj; auto StructHolder * sh; obj = api->obj[i]; sh = obj->sh; islist = FALSE; for(j=0;jlen;j++) { if( sh->el[j]->islist == TRUE ) { islist = TRUE; } } /* promote hard link into API */ af = APIfunc_alloc(); af->name = stringallocf("hard_link_%s",sh->name); add_APIObject(obj,af); /* promote alloc into API */ /* yuk. stupid is list problem! */ af = APIfunc_alloc(); af->name = stringallocf("%s_alloc%s",sh->name,islist == TRUE ? "_std" : ""); af->only_C = TRUE; add_APIObject(obj,af); for(j=0;jlen;j++) { auto StructElement * temp; temp = sh->el[j]; if( temp->ishidden == TRUE ) continue; /* skip it! */ if( temp->islist == TRUE ) { listappend=CKN(temp->len_append); runner = depointer_element(temp->element_type); /* make a "access element" function */ /* build the function documentation. hide it from the C header file */ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"access_%s_%s",temp->name,sh->name); fi->simple = stringalloc(temp->name); add_line_to_Ftext(fi->ft,"Access members stored in the %s list",temp->name); add_line_to_Ftext(fi->ft,"For use principly by API functions",temp->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc = stringalloc("Object holding the list"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"i"); ai->desc = stringalloc("Position in the list"); ai = ArgInfo_alloc(); ai->name = stringalloc("return"); ai->desc = stringalloc("Element of the list"); ai->argtype = ARGTYPE_STATIC; fi->ret = ai; /* promote it into API */ af = APIfunc_alloc(); af->name = stringalloc(fi->name); add_APIObject(obj,af); /* build the function */ start_function_FuncInfo(fi,dfp,"%s access_%s_%s(%s * obj,int i)",runner,temp->name,sh->name,sh->name); expr(dfp,"if( obj == NULL) "); startbrace(dfp); warn_expr(dfp,"In accessor function %s for object %s, got a NULL object",temp->name,sh->name); expr(dfp,"return %s",def_from_element(runner)); closebrace(dfp); expr(dfp,"if( obj->%slen <= i )",listappend); startbrace(dfp); expr(dfp,"warn(\"In accessor function %s for object %s, index %%%%d is greater than list length %%%%d\",i,obj->len);",temp->name,sh->name); expr(dfp,"return %s",def_from_element(runner)); closebrace(dfp); expr(dfp,"return obj->%s[i]",temp->name); close_function(dfp); add_break(dfp); /* make a "length" function */ /* build the function documentation. hide it from the C header file */ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"length_%s_%s",temp->name,sh->name); fi->simple=stringallocf("length_%s",temp->name); add_line_to_Ftext(fi->ft,"discover the length of the list",temp->name); add_line_to_Ftext(fi->ft,"For use principly by API functions",temp->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc = stringalloc("Object holding the list"); ai = ArgInfo_alloc(); ai->name = stringalloc("return"); ai->desc = stringalloc("length of the list"); fi->ret = ai; /* promote it into API */ af = APIfunc_alloc(); af->name = stringalloc(fi->name); add_APIObject(obj,af); /* build the function */ start_function_FuncInfo(fi,dfp,"int length_%s_%s(%s * obj)",temp->name,sh->name,sh->name); expr(dfp,"if( obj == NULL) "); startbrace(dfp); warn_expr(dfp,"In length function %s for object %s, got a NULL object",temp->name,sh->name); expr(dfp,"return -1"); closebrace(dfp); expr(dfp,"return obj->%slen",listappend); close_function(dfp); add_break(dfp); /* promote flush and add to api */ af = APIfunc_alloc(); af->name = stringallocf("flush_%s%s",listappend,sh->name); add_APIObject(obj,af); af = APIfunc_alloc(); af->name = stringallocf("add_%s%s",listappend,sh->name); add_APIObject(obj,af); } else if ( temp->ismatrix == TRUE ) { warn("Cannot make matrix accessor functions yet!"); } else if ( temp->isfunc == TRUE ) { warn("Cannot make pointer to functions accessor functions yet (if at all!)"); } else { if ( strchr(temp->name,'[') != NULL ) { /* should be a compiler option */ /* warn("Cannot build accessor for %s, as is an array",temp->name); */ continue; } /* simple replace guy */ /* build the function documentation. hide it from the C header file */ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"replace_%s_%s",temp->name,sh->name); fi->simple = stringallocf("set_%s",temp->name); add_line_to_Ftext(fi->ft,"Replace member variable %s",temp->name); add_line_to_Ftext(fi->ft,"For use principly by API functions",temp->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc = stringalloc("Object holding the variable"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,temp->name); ai->argtype = ARGTYPE_OWNER; ai->desc = stringalloc("New value of the variable"); ai = ArgInfo_alloc(); ai->name = stringalloc("return"); ai->desc = stringallocf("member variable %s",temp->name); ai->argtype = ARGTYPE_STATIC; fi->ret =ai; /* promote it into API */ af = APIfunc_alloc(); af->name = stringalloc(fi->name); add_APIObject(obj,af); /* build the function */ start_function_FuncInfo(fi,dfp,"boolean replace_%s_%s(%s * obj,%s %s)",temp->name,sh->name,sh->name,temp->element_type,temp->name); expr(dfp,"if( obj == NULL) "); startbrace(dfp); warn_expr(dfp,"In replacement function %s for object %s, got a NULL object",temp->name,sh->name); expr(dfp,"return FALSE"); closebrace(dfp); expr(dfp,"obj->%s = %s;",temp->name,temp->name); expr(dfp,"return TRUE;"); close_function(dfp); add_break(dfp); /* simple accessor */ /* build the function documentation. hide it from the C header file */ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"access_%s_%s",temp->name,sh->name); fi->simple = stringalloc(temp->name); add_line_to_Ftext(fi->ft,"Access member variable %s",temp->name); add_line_to_Ftext(fi->ft,"For use principly by API functions",temp->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc = stringalloc("Object holding the variable"); ai = ArgInfo_alloc(); ai->name = stringalloc("return"); ai->desc = stringallocf("member variable %s",temp->name); ai->argtype = ARGTYPE_STATIC; fi->ret =ai; /* promote it into API */ af = APIfunc_alloc(); af->name = stringalloc(fi->name); add_APIObject(obj,af); /* build the function */ start_function_FuncInfo(fi,dfp,"%s access_%s_%s(%s * obj)",temp->element_type,temp->name,sh->name,sh->name); expr(dfp,"if( obj == NULL) "); startbrace(dfp); warn_expr(dfp,"In accessor function %s for object %s, got a NULL object",temp->name,sh->name); expr(dfp,"return %s",def_from_element(temp->element_type)); closebrace(dfp); expr(dfp,"return obj->%s",temp->name); close_function(dfp); add_break(dfp); } } } return TRUE; } # line 839 "api.dy" boolean write_XS_typemap_dynAPI(dynAPI * api,char * package_name,FILE * ofp) { int i; char strip_package[64]; /* HACK coming up! */ strcpy(strip_package,package_name); if( strip_package[strlen(strip_package)-1] == '_') strip_package[strlen(strip_package)-1] = '\0'; for(i=0;ilen;i++) { fprintf(ofp,"\nTYPEMAP\n%s%s * T_%s_%s\n",package_name,api->obj[i]->name,strip_package,api->obj[i]->name); fprintf(ofp,"\nINPUT\nT_%s_%s\n\t$var = ($type) (SvROK($arg) == 0 ? NULL : (%s_%s *) SvIV((SV*)SvRV($arg)))\n",strip_package,api->obj[i]->name,strip_package,api->obj[i]->name); fprintf(ofp,"\nOUTPUT\nT_%s_%s\n\tsv_setref_pv($arg, \"%s::%s\", (void*) $var);\n",strip_package,api->obj[i]->name,strip_package,api->obj[i]->name); } return TRUE; } # line 860 "api.dy" boolean write_XS_dynAPI(dynAPI * api,char * package_name,FILE * ofp) { int i; char strip_package[64]; /* HACK coming up! */ strcpy(strip_package,package_name); if( strip_package[strlen(strip_package)-1] == '_') strip_package[strlen(strip_package)-1] = '\0'; for(i=0;ilen;i++) { write_XS_header_APIObject(api,package_name,api->obj[i],ofp); write_perl_XS_accessor_functions(api->obj[i],package_name,ofp); } fprintf(ofp,"\n\nMODULE = %s PACKAGE = %s\n\n",strip_package,strip_package); for(i=0;inon_len;i++) { write_XS_APIfunc(api->non_obj[i],package_name,ofp); } return TRUE; } # line 884 "api.dy" boolean write_XS_header_APIObject(dynAPI * api,char * package_name,APIObject * obj,FILE * ofp) { int i; boolean islist; char strip_package[64]; /* HACK coming up! */ strcpy(strip_package,package_name); if( strip_package[strlen(strip_package)-1] == '_') strip_package[strlen(strip_package)-1] = '\0'; fprintf(ofp,"\n\nMODULE = %s PACKAGE = %s::%s\n\n",strip_package,strip_package,obj->name); for(i=0;ilen;i++) { write_XS_APIfunc(obj->member[i],package_name,ofp); } /* now to write a simple constructor */ /* Ngggg! We have to check if there is a list or not. this was bad API design in wisec.dy sometime ago. (like - years ago ) Yuk! yuk! */ islist = FALSE; for(i=0;ish->len;i++) { if( obj->sh->el[i]->islist == TRUE ) { islist = TRUE; } } fprintf(ofp,"\n%s%s *\nnew(class)\n\tchar * class\n\tPPCODE:\n\t%s%s * out;\n\tout = %s%s_alloc%s();\n\tST(0) = sv_newmortal();\n\tsv_setref_pv(ST(0),class,(void*)out);\n\tXSRETURN(1);\n",package_name,obj->name,package_name,obj->name,package_name,obj->name,islist == TRUE ? "_std" : ""); /* now to write the destructor */ fprintf(ofp,"\nvoid\nDESTROY(obj)\n\t%s%s * obj\n\tCODE:\n\t%s%s(obj);\n\n",package_name,obj->name,package_name,obj->destructor->name); return TRUE; } # line 923 "api.dy" boolean write_XS_APIfunc(APIfunc * fu,char * package_name,FILE * ofp) { int j; boolean is_basic; /* return statement */ is_basic = is_basic_type_API(fu->fi->ret->type); if( is_basic == TRUE ) fprintf(ofp,"%s\n",fu->fi->ret->type); else fprintf(ofp,"%s%s\n",(is_basic == TRUE ? "" : package_name),fu->fi->ret->type); /* if we have a simple specification use that - the package will protect us from nasty name clashes! */ if( fu->fi->simple != NULL ) { fprintf(ofp,"%s(",fu->fi->simple); } else { /* function name - we do need the package stuff...*/ fprintf(ofp,"%s(",fu->name); } for(j=0;jfi->len;j++) { if( fu->fi->arg[j]->should_NULL == TRUE) { continue; /* don't put it into the Perl prototype */ } fprintf(ofp,"%s%s",j == 0 ? "" : ",",fu->fi->arg[j]->name); } fprintf(ofp,")\n"); /* each arguments */ for(j=0;jfi->len;j++) { if( fu->fi->arg[j]->should_NULL == TRUE) { continue; /* don't put it into the Perl prototype */ } is_basic = is_basic_type_API(fu->fi->arg[j]->type); if( is_basic == TRUE) fprintf(ofp,"\t%s %s\n",fu->fi->arg[j]->type,fu->fi->arg[j]->name); else fprintf(ofp,"\t%s%s %s\n",(is_basic == TRUE ? "" : package_name),fu->fi->arg[j]->type,fu->fi->arg[j]->name); } /* ok - now lets do the glue */ if( strcmp(fu->fi->ret->type,"void") != 0 ) { if( fu->fi->ret->argtype == ARGTYPE_STATIC && is_basic_type_API(fu->fi->ret->type) == FALSE) { /* we need to put in the memory handler... */ /* * Horrible hack. We assumme the the C type MyType * means dynamite type MyType. * * YUK!!!! Also - v.v.v.v.v bad hard coded Wise2 * */ fprintf(ofp,"\tINIT:\nWise2_%s temp;\n\tCODE:\n\ttemp = Wise2_hard_link_%s(%s%s(",fu->fi->ret->type,c2dyn_type(fu->fi->ret->type),package_name,fu->name); } else if(fu->fi->ret->argtype == ARGTYPE_STATIC && strcmp(fu->fi->ret->type,"char *") == 0 ) { fprintf(ofp,"\tINIT:\n\t%s temp;\n\tCODE:\n\ttemp = Wise2_stringalloc(%s%s(",fu->fi->ret->type,package_name,fu->name); } else { /* a basic type - don't need to handle, despite STATIC linkage */ fprintf(ofp,"\tCODE:\n\tRETVAL = %s%s(",package_name,fu->name); } } /* end of is not void */ else { /* if it is void */ fprintf(ofp,"\tCODE:\n\t%s%s(",package_name,fu->name); } for(j=0;jfi->len;j++) { if( fu->fi->arg[j]->argtype == ARGTYPE_OWNER && is_membasic_type_API(fu->fi->arg[j]->type) == FALSE && fu->fi->arg[j]->should_NULL == FALSE ) { if( (strcmp(fu->fi->arg[j]->type,"char*") == 0) || (strcmp(fu->fi->arg[j]->type,"char *") == 0) ) { fprintf(ofp,"%sWise2_stringalloc(%s)",j == 0 ? "" : ",",fu->fi->arg[j]->name); } else { fprintf(ofp,"%sWise2_hard_link_%s(%s)",j == 0 ? "" : ",",c2dyn_type(fu->fi->arg[j]->type),fu->fi->arg[j]->name); } } else { fprintf(ofp,"%s%s",j == 0 ? "" : ",",fu->fi->arg[j]->should_NULL == TRUE ? "NULL" : fu->fi->arg[j]->name); } } if( fu->fi->ret->argtype == ARGTYPE_STATIC && (is_basic_type_API(fu->fi->ret->type) == FALSE || strcmp(fu->fi->ret->type,"char *") == 0) ) { fprintf(ofp,"));\n\tRETVAL = temp;\n\tOUTPUT:\n\tRETVAL\n\n"); } else { if( strcmp(fu->fi->ret->type,"void") != 0 ) { fprintf(ofp,");\n\tOUTPUT:\n\tRETVAL\n\n"); } else { fprintf(ofp,");\n\n"); } } fprintf(ofp,"\n\n"); return TRUE; } static char statbuf[128]; /* Function: c2dyn_type(c) * * Descrip: internal thing that maps C * types to dynamite types * * * Arg: c [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 1029 "api.dy" char * c2dyn_type(char * c) { strcpy(statbuf,c); c = statbuf + strlen(statbuf)-1; for(;c != statbuf && *c != '*';c--) ; c--; for(;c != statbuf && isspace(*c);c--) ; c++; *c = '\0'; return statbuf; } # line 1046 "api.dy" boolean reconcile_dynAPI_with_FuncInfo(dynAPI * api,DYNFILE * dfp) { int i; int j; boolean ret = TRUE; FuncInfo * fi; for(i=0;ilen;i++) { for(j=0;jobj[i]->len;j++) { if( (fi= FuncInfo_from_name_DYNFILE(dfp,api->obj[i]->member[j]->name)) == NULL ) { warn("Cannot find any documentation for %s\n",api->obj[i]->member[j]->name); ret = FALSE; } else { api->obj[i]->member[j]->fi = fi; } } if(api->obj[i]->destructor != NULL) { if( (fi= FuncInfo_from_name_DYNFILE(dfp,api->obj[i]->destructor->name)) == NULL ) { warn("Cannot find any documentation for %s (destructor!)\n",api->obj[i]->destructor->name); ret = FALSE; } else { api->obj[i]->destructor->fi = fi; } } } for(j=0;jnon_len;j++) { if( (fi= FuncInfo_from_name_DYNFILE(dfp,api->non_obj[j]->name)) == NULL ) { warn("Cannot find any documentation for %s\n",api->non_obj[j]->name); ret = FALSE; } else { api->non_obj[j]->fi = fi; } } return ret; } # line 1084 "api.dy" APIObject * APIObject_from_line(char * line,int maxline,FILE * ifp) { APIObject * out; APIfunc * func; char * runner; if( strstartcmp(line,"object") != 0 ) { warn("In building APIObject, passed in a non object line [%s]",line); return NULL; } (void) strtok(line,spacestr); if( (runner=strtok(NULL,spacestr)) == NULL ) { warn("In building APIObject, no name for object",line); /* should skip to endobject ? */ return NULL; } out = APIObject_alloc_std(); out->name = stringalloc(runner); while( get_watched_line(line,maxline,ifp) != NULL ) { if( line[0] == '#' ) continue; if( strstartcmp(line,"endobject") == 0 ) { break; } if( strstartcmp(line,"end") == 0 ) { warn("Got an end line [%s] but not an end object line. Don't like!"); break; } if( strstartcmp(line,"func") == 0 ) { func = APIfunc_from_buffer(line); if( func == NULL ) continue; add_APIObject(out,func); } else if ( strstartcmp(line,"des") == 0 ) { func = APIfunc_from_buffer(line); if( func == NULL ) continue; out->destructor= func; } else { warn("Did not understand [%s] as an APIObject line",line); } } return out; } # line 1143 "api.dy" APIfunc * APIfunc_from_buffer(char * line) { APIfunc * out; if( line == NULL ) { warn("Passed in a NULL line to APIfunc_from_buffer"); return NULL; } if( strstartcmp(line,"func") != 0 && strstartcmp(line,"des") != 0 ) { warn("Passed a non function line to APIfunc_from_buffer"); return NULL; } (void)strtok(line,spacestr); if( (line = strtok(NULL,spacestr)) == NULL ) { warn("line to APIfunc_from_buffer was empty. Yikes"); return NULL; } out = APIfunc_alloc(); if( out == NULL) return NULL; out->name = stringalloc(line); return out; } # line 1164 "api.c" /* Function: hard_link_APIfunc(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [APIfunc *] * * Return [UNKN ] Undocumented return value [APIfunc *] * */ APIfunc * hard_link_APIfunc(APIfunc * obj) { if( obj == NULL ) { warn("Trying to hard link to a APIfunc object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: APIfunc_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [APIfunc *] * */ APIfunc * APIfunc_alloc(void) { APIfunc * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(APIfunc *) ckalloc (sizeof(APIfunc))) == NULL) { warn("APIfunc_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->fi = NULL; out->only_C = FALSE; return out; } /* Function: free_APIfunc(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [APIfunc *] * * Return [UNKN ] Undocumented return value [APIfunc *] * */ APIfunc * free_APIfunc(APIfunc * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a APIfunc obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->fi != NULL) free_FuncInfo(obj->fi); ckfree(obj); return NULL; } /* Function: swap_APIObject(list,i,j) * * Descrip: swap function: an internal for qsort_APIObject * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [APIfunc **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_APIObject(APIfunc ** list,int i,int j) { APIfunc * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_APIObject(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_APIObject which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [APIfunc **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_APIObject(APIfunc ** list,int left,int right,int (*comp)(APIfunc * ,APIfunc * )) { int i,last; if( left >= right ) return; swap_APIObject(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_APIObject (list,++last,i); } swap_APIObject (list,left,last); qsort_APIObject(list,left,last-1,comp); qsort_APIObject(list,last+1,right,comp); } /* Function: sort_APIObject(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_APIObject * * * Arg: obj [UNKN ] Object containing list [APIObject *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_APIObject(APIObject * obj,int (*comp)(APIfunc *, APIfunc *)) { qsort_APIObject(obj->member,0,obj->len-1,comp); return; } /* Function: expand_APIObject(obj,len) * * Descrip: Really an internal function for add_APIObject * * * Arg: obj [UNKN ] Object which contains the list [APIObject *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_APIObject(APIObject * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_APIObject called with no need"); return TRUE; } if( (obj->member = (APIfunc ** ) ckrealloc (obj->member,sizeof(APIfunc *)*len)) == NULL) { warn("ckrealloc failed for expand_APIObject, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_APIObject(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [APIObject *] * Arg: add [OWNER] Object to add to the list [APIfunc *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_APIObject(APIObject * obj,APIfunc * add) { if( obj->len >= obj->maxlen) { if( expand_APIObject(obj,obj->len + APIObjectLISTLENGTH) == FALSE) return FALSE; } obj->member[obj->len++]=add; return TRUE; } /* Function: flush_APIObject(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [APIObject *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_APIObject(APIObject * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->member[i] != NULL) { free_APIfunc(obj->member[i]); obj->member[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: APIObject_alloc_std(void) * * Descrip: Equivalent to APIObject_alloc_len(APIObjectLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [APIObject *] * */ APIObject * APIObject_alloc_std(void) { return APIObject_alloc_len(APIObjectLISTLENGTH); } /* Function: APIObject_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [APIObject *] * */ APIObject * APIObject_alloc_len(int len) { APIObject * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = APIObject_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->member = (APIfunc ** ) ckcalloc (len,sizeof(APIfunc *))) == NULL) { warn("Warning, ckcalloc failed in APIObject_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_APIObject(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [APIObject *] * * Return [UNKN ] Undocumented return value [APIObject *] * */ APIObject * hard_link_APIObject(APIObject * obj) { if( obj == NULL ) { warn("Trying to hard link to a APIObject object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: APIObject_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [APIObject *] * */ APIObject * APIObject_alloc(void) { APIObject * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(APIObject *) ckalloc (sizeof(APIObject))) == NULL) { warn("APIObject_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->destructor = NULL; out->hard_linker = NULL; out->member = NULL; out->len = out->maxlen = 0; out->info = NULL; out->sh = NULL; return out; } /* Function: free_APIObject(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [APIObject *] * * Return [UNKN ] Undocumented return value [APIObject *] * */ APIObject * free_APIObject(APIObject * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a APIObject obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->destructor != NULL) free_APIfunc(obj->destructor); if( obj->hard_linker != NULL) free_APIfunc(obj->hard_linker); if( obj->member != NULL) { for(i=0;ilen;i++) { if( obj->member[i] != NULL) free_APIfunc(obj->member[i]); } ckfree(obj->member); } if( obj->info != NULL) free_ObjectInfo(obj->info); if( obj->sh != NULL) free_StructHolder(obj->sh); ckfree(obj); return NULL; } /* Function: swap_non_dynAPI(list,i,j) * * Descrip: swap function: an internal for qsort_non_dynAPI * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [APIfunc **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_non_dynAPI(APIfunc ** list,int i,int j) { APIfunc * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_non_dynAPI(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_non_dynAPI which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [APIfunc **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_non_dynAPI(APIfunc ** list,int left,int right,int (*comp)(APIfunc * ,APIfunc * )) { int i,last; if( left >= right ) return; swap_non_dynAPI(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_non_dynAPI (list,++last,i); } swap_non_dynAPI (list,left,last); qsort_non_dynAPI(list,left,last-1,comp); qsort_non_dynAPI(list,last+1,right,comp); } /* Function: sort_non_dynAPI(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_non_dynAPI * * * Arg: obj [UNKN ] Object containing list [dynAPI *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_non_dynAPI(dynAPI * obj,int (*comp)(APIfunc *, APIfunc *)) { qsort_non_dynAPI(obj->non_obj,0,obj->non_len-1,comp); return; } /* Function: expand_non_dynAPI(obj,len) * * Descrip: Really an internal function for add_non_dynAPI * * * Arg: obj [UNKN ] Object which contains the list [dynAPI *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_non_dynAPI(dynAPI * obj,int len) { if( obj->non_maxlen > obj->non_len ) { warn("expand_dynAPInon_ called with no need"); return TRUE; } if( (obj->non_obj = (APIfunc ** ) ckrealloc (obj->non_obj,sizeof(APIfunc *)*len)) == NULL) { warn("ckrealloc failed for expand_dynAPI, returning FALSE"); return FALSE; } obj->non_maxlen = len; return TRUE; } /* Function: add_non_dynAPI(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [dynAPI *] * Arg: add [OWNER] Object to add to the list [APIfunc *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_non_dynAPI(dynAPI * obj,APIfunc * add) { if( obj->non_len >= obj->non_maxlen) { if( expand_non_dynAPI(obj,obj->non_len + dynAPILISTLENGTH) == FALSE) return FALSE; } obj->non_obj[obj->non_len++]=add; return TRUE; } /* Function: flush_non_dynAPI(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [dynAPI *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_non_dynAPI(dynAPI * obj) { int i; for(i=0;inon_len;i++) { /*for i over list length*/ if( obj->non_obj[i] != NULL) { free_APIfunc(obj->non_obj[i]); obj->non_obj[i] = NULL; } } /* end of for i over list length */ obj->non_len = 0; return i; } /* Function: swap_dynAPI(list,i,j) * * Descrip: swap function: an internal for qsort_dynAPI * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [APIObject **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_dynAPI(APIObject ** list,int i,int j) { APIObject * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_dynAPI(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_dynAPI which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [APIObject **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_dynAPI(APIObject ** list,int left,int right,int (*comp)(APIObject * ,APIObject * )) { int i,last; if( left >= right ) return; swap_dynAPI(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_dynAPI (list,++last,i); } swap_dynAPI (list,left,last); qsort_dynAPI(list,left,last-1,comp); qsort_dynAPI(list,last+1,right,comp); } /* Function: sort_dynAPI(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_dynAPI * * * Arg: obj [UNKN ] Object containing list [dynAPI *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_dynAPI(dynAPI * obj,int (*comp)(APIObject *, APIObject *)) { qsort_dynAPI(obj->obj,0,obj->len-1,comp); return; } /* Function: expand_dynAPI(obj,len) * * Descrip: Really an internal function for add_dynAPI * * * Arg: obj [UNKN ] Object which contains the list [dynAPI *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_dynAPI(dynAPI * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_dynAPI called with no need"); return TRUE; } if( (obj->obj = (APIObject ** ) ckrealloc (obj->obj,sizeof(APIObject *)*len)) == NULL) { warn("ckrealloc failed for expand_dynAPI, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_dynAPI(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [dynAPI *] * Arg: add [OWNER] Object to add to the list [APIObject *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_dynAPI(dynAPI * obj,APIObject * add) { if( obj->len >= obj->maxlen) { if( expand_dynAPI(obj,obj->len + dynAPILISTLENGTH) == FALSE) return FALSE; } obj->obj[obj->len++]=add; return TRUE; } /* Function: flush_dynAPI(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [dynAPI *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_dynAPI(dynAPI * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->obj[i] != NULL) { free_APIObject(obj->obj[i]); obj->obj[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: dynAPI_alloc_std(void) * * Descrip: Equivalent to dynAPI_alloc_len(dynAPILISTLENGTH) * * * * Return [UNKN ] Undocumented return value [dynAPI *] * */ dynAPI * dynAPI_alloc_std(void) { return dynAPI_alloc_len(dynAPILISTLENGTH); } /* Function: dynAPI_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [dynAPI *] * */ dynAPI * dynAPI_alloc_len(int len) { dynAPI * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = dynAPI_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->non_obj = (APIfunc ** ) ckcalloc (len,sizeof(APIfunc *))) == NULL) { warn("Warning, ckcalloc failed in dynAPI_alloc_len"); return NULL; } out->non_len = 0; out->non_maxlen = len; if((out->obj = (APIObject ** ) ckcalloc (len,sizeof(APIObject *))) == NULL) { warn("Warning, ckcalloc failed in dynAPI_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_dynAPI(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [dynAPI *] * * Return [UNKN ] Undocumented return value [dynAPI *] * */ dynAPI * hard_link_dynAPI(dynAPI * obj) { if( obj == NULL ) { warn("Trying to hard link to a dynAPI object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: dynAPI_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [dynAPI *] * */ dynAPI * dynAPI_alloc(void) { dynAPI * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(dynAPI *) ckalloc (sizeof(dynAPI))) == NULL) { warn("dynAPI_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->non_obj = NULL; out->non_len = out->non_maxlen = 0; out->obj = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_dynAPI(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [dynAPI *] * * Return [UNKN ] Undocumented return value [dynAPI *] * */ dynAPI * free_dynAPI(dynAPI * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a dynAPI obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->non_obj != NULL) { for(i=0;inon_len;i++) { if( obj->non_obj[i] != NULL) free_APIfunc(obj->non_obj[i]); } ckfree(obj->non_obj); } if( obj->obj != NULL) { for(i=0;ilen;i++) { if( obj->obj[i] != NULL) free_APIObject(obj->obj[i]); } ckfree(obj->obj); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/api.h0000644000175000001440000002500610670453715014354 0ustar philippusers#ifndef DYNAMITEapiHEADERFILE #define DYNAMITEapiHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dynfile.h" #include "objectinfo.h" #include "wisec.h" #define APIObjectLISTLENGTH 64 #define dynAPILISTLENGTH 64 struct APIfunc { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; FuncInfo * fi; /* hard linked */ boolean only_C; } ; /* APIfunc defined */ #ifndef DYNAMITE_DEFINED_APIfunc typedef struct APIfunc APIfunc; #define DYNAMITE_DEFINED_APIfunc #endif struct APIObject { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; APIfunc * destructor; APIfunc * hard_linker; APIfunc ** member; int len;/* len for above member */ int maxlen; /* maxlen for above member */ ObjectInfo * info; StructHolder * sh; } ; /* APIObject defined */ #ifndef DYNAMITE_DEFINED_APIObject typedef struct APIObject APIObject; #define DYNAMITE_DEFINED_APIObject #endif /* Object dynAPI * * Descrip: This Object contains the api definition * for the module. The api is used to * generate a name-space clear C api and * a Perl interface at the moment. * * */ struct dynAPI { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif APIfunc ** non_obj; int non_len;/* len for above non_obj */ int non_maxlen; /* maxlen for above non_obj */ APIObject ** obj; int len;/* len for above obj */ int maxlen; /* maxlen for above obj */ } ; /* dynAPI defined */ #ifndef DYNAMITE_DEFINED_dynAPI typedef struct dynAPI dynAPI; #define DYNAMITE_DEFINED_dynAPI #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_APIfunc(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [APIfunc *] * * Return [UNKN ] Undocumented return value [APIfunc *] * */ APIfunc * hard_link_APIfunc(APIfunc * obj); /* Function: APIfunc_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [APIfunc *] * */ APIfunc * APIfunc_alloc(void); /* Function: free_APIfunc(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [APIfunc *] * * Return [UNKN ] Undocumented return value [APIfunc *] * */ APIfunc * free_APIfunc(APIfunc * obj); /* Function: add_APIObject(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [APIObject *] * Arg: add [OWNER] Object to add to the list [APIfunc *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_APIObject(APIObject * obj,APIfunc * add); /* Function: flush_APIObject(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [APIObject *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_APIObject(APIObject * obj); /* Function: APIObject_alloc_std(void) * * Descrip: Equivalent to APIObject_alloc_len(APIObjectLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [APIObject *] * */ APIObject * APIObject_alloc_std(void); /* Function: APIObject_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [APIObject *] * */ APIObject * APIObject_alloc_len(int len); /* Function: hard_link_APIObject(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [APIObject *] * * Return [UNKN ] Undocumented return value [APIObject *] * */ APIObject * hard_link_APIObject(APIObject * obj); /* Function: APIObject_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [APIObject *] * */ APIObject * APIObject_alloc(void); /* Function: free_APIObject(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [APIObject *] * * Return [UNKN ] Undocumented return value [APIObject *] * */ APIObject * free_APIObject(APIObject * obj); /* Function: add_non_dynAPI(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [dynAPI *] * Arg: add [OWNER] Object to add to the list [APIfunc *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_non_dynAPI(dynAPI * obj,APIfunc * add); /* Function: flush_non_dynAPI(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [dynAPI *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_non_dynAPI(dynAPI * obj); /* Function: add_dynAPI(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [dynAPI *] * Arg: add [OWNER] Object to add to the list [APIObject *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_dynAPI(dynAPI * obj,APIObject * add); /* Function: flush_dynAPI(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [dynAPI *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_dynAPI(dynAPI * obj); /* Function: dynAPI_alloc_std(void) * * Descrip: Equivalent to dynAPI_alloc_len(dynAPILISTLENGTH) * * * * Return [UNKN ] Undocumented return value [dynAPI *] * */ dynAPI * dynAPI_alloc_std(void); /* Function: dynAPI_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [dynAPI *] * */ dynAPI * dynAPI_alloc_len(int len); /* Function: hard_link_dynAPI(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [dynAPI *] * * Return [UNKN ] Undocumented return value [dynAPI *] * */ dynAPI * hard_link_dynAPI(dynAPI * obj); /* Function: dynAPI_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [dynAPI *] * */ dynAPI * dynAPI_alloc(void); /* Function: free_dynAPI(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [dynAPI *] * * Return [UNKN ] Undocumented return value [dynAPI *] * */ dynAPI * free_dynAPI(dynAPI * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ boolean write_pfdoc_dynAPI(dynAPI * api,char * package_name,FILE * ofp); boolean write_pfdoc_func_def(FuncInfo * fi,FILE * ofp); boolean write_latex_dynAPI(dynAPI * api,char * module,char * package,FILE * ofp); boolean write_latex_APIfunc(APIfunc * f,char * package,boolean isobj,char * objectname,FILE * ofp); boolean write_pod_dynAPI(dynAPI * api,char * module,char * package,FILE * ofp); void write_pod_obj_APIfunc(APIfunc * f,char * package,char * obj,FILE * ofp); void write_pod_non_APIfunc(APIfunc * f,char * package,FILE * ofp); boolean write_type_C_dynAPI(dynAPI * api,char * package_name,FILE * ofp); boolean write_C_dynAPI(dynAPI * api,char * package_name,FILE * ofp); boolean write_C_APIfunc(APIfunc * api,char * package_name,FILE * ofp); boolean is_membasic_type_API(char * type); boolean is_basic_type_API(char * type); dynAPI * read_dynAPI_line(char * line,FILE * ifp); boolean write_perl_XS_accessor_functions(APIObject * obj,char * package,FILE * ofp); boolean write_dynAPI_accessor_functions(DYNFILE * dfp,dynAPI * api); boolean write_XS_typemap_dynAPI(dynAPI * api,char * package_name,FILE * ofp); boolean write_XS_dynAPI(dynAPI * api,char * package_name,FILE * ofp); boolean write_XS_header_APIObject(dynAPI * api,char * package_name,APIObject * obj,FILE * ofp); boolean write_XS_APIfunc(APIfunc * fu,char * package_name,FILE * ofp); boolean reconcile_dynAPI_with_FuncInfo(dynAPI * api,DYNFILE * dfp); APIObject * APIObject_from_line(char * line,int maxline,FILE * ifp); APIfunc * APIfunc_from_buffer(char * line); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ char * c2dyn_type(char * c); void swap_APIObject(APIfunc ** list,int i,int j) ; void qsort_APIObject(APIfunc ** list,int left,int right,int (*comp)(APIfunc * ,APIfunc * )); void sort_APIObject(APIObject * obj,int (*comp)(APIfunc *, APIfunc *)); boolean expand_APIObject(APIObject * obj,int len); void swap_non_dynAPI(APIfunc ** list,int i,int j) ; void qsort_non_dynAPI(APIfunc ** list,int left,int right,int (*comp)(APIfunc * ,APIfunc * )); void sort_non_dynAPI(dynAPI * obj,int (*comp)(APIfunc *, APIfunc *)); boolean expand_non_dynAPI(dynAPI * obj,int len); void swap_dynAPI(APIObject ** list,int i,int j) ; void qsort_dynAPI(APIObject ** list,int left,int right,int (*comp)(APIObject * ,APIObject * )); void sort_dynAPI(dynAPI * obj,int (*comp)(APIObject *, APIObject *)); boolean expand_dynAPI(dynAPI * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/dbthread.dy0000644000175000001440000004325407566425446015564 0ustar philippusers %{ #include "dyna2.h" #include "dpimpl.h" %} %{ #include "dbthread.h" %func writes out thread structure for the use in the loop code %% boolean write_thread_struct(DYNFILE * dfp,DPImplementation * dpi,GenericMatrix * gm) { int i; boolean qdb = FALSE; boolean tdb = FALSE; if( gm->qtype != NULL && gm->qtype->is_database == TRUE) { if( gm->qtype->is_thread_safe == FALSE ) { warn("Query is a database but not using a thread safe library. Can't use it!"); return FALSE; } else { qdb = TRUE; } } if( gm->ttype != NULL && gm->ttype->is_database == TRUE) { if( gm->ttype->is_thread_safe == FALSE) { warn("Target is a database but not using a thread safe library. Can't use it!"); return FALSE; } else { tdb = TRUE; } } fprintf(dfp->head,"#ifdef PTHREAD\n"); start_struct(dfp,"struct thread_pool_holder_%s",gm->name); if( qdb == FALSE ) { /* static query data structure common to all */ struct_expr(dfp,"%s %s;",gm->query->element_type,gm->query->name); add_end_comment_header(dfp,"Static query data: never free'd"); } else { struct_expr(dfp,"%s %s;",gm->qtype->real,gm->query->name); add_end_comment_header(dfp,"Query object placeholder"); struct_expr(dfp,"%s querydb;",gm->qtype->database_type); add_end_comment_header(dfp,"Query database object"); struct_expr(dfp,"boolean query_init;"); } if( tdb == FALSE ) { /* static query data structure common to all */ struct_expr(dfp,"%s %s;",gm->target->element_type,gm->target->name); add_end_comment_header(dfp,"Static target data: never free'd"); } else { struct_expr(dfp,"%s %s;",gm->ttype->real,gm->target->name); add_end_comment_header(dfp,"Target object placeholder"); struct_expr(dfp,"%s targetdb;",gm->ttype->database_type); add_end_comment_header(dfp,"Target database object"); struct_expr(dfp,"boolean target_init;"); } /* now add all the resources */ for(i=0;ires_len;i++) { struct_expr(dfp,"%s %s",gm->resource[i]->element_type,gm->resource[i]->name); } /* now add mutex's */ struct_expr(dfp,"pthread_mutex_t input_lock"); struct_expr(dfp,"pthread_mutex_t output_lock"); /* add output */ struct_expr(dfp,"Hscore * out"); /* add pthread_t */ struct_expr(dfp,"pthread_t * pool;"); struct_expr(dfp,"int number_of_threads;"); struct_expr(dfp,"boolean search_has_ended;"); if( dpi->db_trace_level > 0 ) { struct_expr(dfp,"DBSearchImpl * dbsi"); } /* close structure */ close_struct(dfp,";"); fprintf(dfp->head,"#endif /* PTHREAD */\n"); return TRUE; } %func Major loop for each thread. This function is really complicated by the way dynamite databases work - in particular the init function returns an object, so we have to keep track for each database if we need to init or not. Secondly we have to get out the information for each query and target regardless of whether they will score over the default or not. To do this we need to rely on the datascore storage allocator to be able to accept frees (annoying or what!). Here is the pseudo code for both a query or target db forever { get input lock if( search ended ) { unlock input lock break; } get datascore datatstructure if( query not init ) init query hard link query read query info into datastructure if( target not init ) init target else reload target if ( end of the target database ) free query data structure -- we have got it hard_linked! reload query database into holder if( end of the query database ) flag search finished unlock input lock else close target database set target to be initiated -- by next thread unlock input lock else unlock input lock do score if( should store ) get output lock add data score else get input lock (otherwise clash with datascore storage allocator) return data score back to storage unlock input lock } %% boolean write_thread_loop(DYNFILE * dfp,DPImplementation * dpi,GenericMatrix * gm) { FuncInfo * fi; boolean tdb,qdb; char * pre; int do_dummy = 0; tdb= qdb = FALSE; if( gm->qtype == NULL || gm->ttype == NULL ) { warn("No database types - must have dbtypes for pthreads support"); do_dummy =1 ; } if( gm->qtype != NULL && gm->qtype->is_database == TRUE) if( gm->qtype->is_thread_safe == FALSE) { warn("Query is a database but not using a thread safe library. Can't use it!"); do_dummy = 1; } else { qdb = TRUE; } if( gm->ttype != NULL && gm->ttype->is_database == TRUE) if( gm->ttype->is_thread_safe == FALSE) { warn("Target is a database but not using a thread safe library. Can't use it!"); do_dummy = 1; } else { tdb = TRUE; } if( do_dummy == 1 ) { fi = FuncInfo_named_from_varstr(FI_INTERNAL,"thread_loop_%s",gm->name); add_line_to_Ftext(fi->ft,"dummy loop code foreach thread for %s",gm->name); start_function_FuncInfo(fi,dfp,"void * thread_loop_%s(void * ptr)",gm->name); expr(dfp,"fatal(\"dummy thread loop function\");"); close_function(dfp); add_break(dfp); return FALSE; } fi = FuncInfo_named_from_varstr(FI_INTERNAL,"thread_loop_%s",gm->name); add_line_to_Ftext(fi->ft,"Infinite loop code foreach thread for %s",gm->name); macro(dfp,"#ifdef PTHREAD"); start_function_FuncInfo(fi,dfp,"void * thread_loop_%s(void * ptr)",gm->name); expr(dfp,"struct thread_pool_holder_%s * holder",gm->name); expr(dfp,"int db_status"); expr(dfp,"int score"); expr(dfp,"DataScore * ds;"); expr(dfp,"%s %s",gm->query->element_type,gm->query->name); expr(dfp,"%s %s",gm->target->element_type,gm->target->name); add_break(dfp); expr(dfp,"holder = (struct thread_pool_holder_%s *) ptr;",gm->name); if( dpi->db_trace_level >= 1 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 1 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Entering infinite loop for thread...\\n\");"); } add_break(dfp); expr(dfp,"while(1)"); startbrace_tag(dfp,"Infinite loop over all models"); add_block_comment(dfp,"Get input lock"); add_break(dfp); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"About to get input lock for main reload\\n\");"); } expr(dfp,"if( pthread_mutex_lock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error on getting input lock for %s\");",gm->name); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Got input lock for main reload\\n\");"); } add_break(dfp); expr(dfp,"if( holder->search_has_ended == TRUE )"); startbrace(dfp); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Database search finished for me!...\\n\");"); } expr(dfp,"if( pthread_mutex_unlock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error in releasing input lock for %s\");",gm->name); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Released lock and broken out of loop\\n\");"); } expr(dfp,"break;"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Get storage space now, as we have to read in the info for the db now"); if( dpi->db_trace_level >= 3 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 3 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Getting new DataScore from storage...\\n\");"); } expr(dfp,"ds = new_DataScore();"); /* if there is a target database, read from it */ if( tdb == TRUE ) { if( qdb == TRUE ) { /* both query and target db */ add_break(dfp); add_block_comment(dfp,"We need to get our query object"); if( dpi->db_trace_level >= 3 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 3 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Starting query database...\\n\");"); } add_break(dfp); expr(dfp,"if( holder->query_init == FALSE)"); startbrace(dfp); expr(dfp,"holder->%s = %s(holder->querydb,&db_status);",gm->query->name,gm->qtype->init_func); expr(dfp,"holder->query_init = TRUE;"); expr(dfp,"if( db_status == DB_RETURN_ERROR )"); hang_expr(dfp,"fatal(\"Unable to initalise query database in %s search\");",gm->name); closebrace(dfp); expr(dfp,"%s = %s(holder->%s);",gm->query->name,gm->qtype->hard_link_func,gm->query->name); add_block_comment(dfp,"get query information into datascore"); expr(dfp,"%s(ds->query,%s,holder->querydb);",gm->qtype->dataentry_add,gm->query->name); } add_break(dfp); expr(dfp,"if( holder->target_init == FALSE )"); startbrace_tag(dfp,"if the db has not been init'd"); if( dpi->db_trace_level >= 3 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 3 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Starting target database...\\n\");"); } expr(dfp,"%s = %s(holder->targetdb,&db_status);",gm->target->name,gm->ttype->init_func); expr(dfp,"holder->target_init = TRUE;"); closebrace(dfp); expr(dfp,"else"); startbrace_tag(dfp,"Normal reload"); expr(dfp," %s = %s(NULL,holder->targetdb,&db_status)",gm->target->name,gm->ttype->reload_func); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Check to see what the reload is like"); add_break(dfp); expr(dfp,"if( db_status == DB_RETURN_ERROR )"); startbrace(dfp); expr(dfp,"fatal(\"In searching %s, Reload error on database %s, in threads\");",gm->name,gm->target->name); closebrace(dfp); if( qdb == TRUE ) { /* both query and target db */ add_break(dfp); expr(dfp,"if( db_status == DB_RETURN_END)"); startbrace_tag(dfp,"End of target database"); add_block_comment(dfp,"close target database and schedule it for initalisation by next thread"); expr(dfp,"%s(NULL,holder->targetdb);",gm->ttype->close_func); expr(dfp,"holder->target_init = FALSE;"); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Target Database to be reloaded...\\n\");"); } add_break(dfp); add_block_comment(dfp,"free'ing the query object"); expr(dfp,"%s(holder->%s);",gm->qtype->free_func,gm->query->name); add_block_comment(dfp,"get the next query object for the next thread"); expr(dfp,"holder->%s = %s(NULL,holder->querydb,&db_status);",gm->query->name,gm->qtype->reload_func); expr(dfp,"if( db_status == DB_RETURN_ERROR )"); hang_expr(dfp,"fatal(\"In searching %s, reload error on database %s, in threads\");",gm->name,gm->query->name); expr(dfp,"if( db_status == DB_RETURN_END )"); startbrace_tag(dfp,"last load!"); add_block_comment(dfp,"End of target and query database - finished search!"); expr(dfp,"%s(NULL,holder->querydb);",gm->qtype->close_func); expr(dfp,"holder->search_has_ended = TRUE;"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"release input mutex"); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Releasing input lock after end of target\\n\");"); } expr(dfp,"if( pthread_mutex_unlock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error in releasing input lock for %s\");",gm->name); expr(dfp,"continue;"); closebrace(dfp); /* end of if at end ! */ expr(dfp,"else "); startbrace_tag(dfp,"Normal reload"); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Releasing input lock for normal reload\\n\");"); } expr(dfp,"if( pthread_mutex_unlock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error in releasing input lock for %s\");",gm->name); closebrace(dfp); /* end of if at end ! */ add_block_comment(dfp,"get target information into datascore"); expr(dfp,"%s(ds->target,%s,holder->targetdb);",gm->ttype->dataentry_add,gm->target->name); } else { /* targetdb but no querydb */ expr(dfp,"if( db_status == DB_RETURN_END)"); startbrace_tag(dfp,"End of target database"); expr(dfp,"holder->search_has_ended = TRUE;"); expr(dfp,"%s(NULL,holder->targetdb)",gm->ttype->close_func); add_block_comment(dfp,"release input mutex"); expr(dfp,"if( pthread_mutex_unlock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error in releasing input lock for %s\");",gm->name); closebrace(dfp); /* end of if at end ! */ } } else { /* querydb but no targetdb */ expr(dfp,"if( holder->query_init == FALSE )"); startbrace_tag(dfp,"if the db has not been init'd"); expr(dfp,"%s = %s(holder->querydb,&db_status);",gm->query->name,gm->qtype->init_func); expr(dfp,"holder->query_init = TRUE;"); closebrace(dfp); expr(dfp,"else"); startbrace_tag(dfp,"Normal reload"); expr(dfp," %s = %s(NULL,holder->querydb,&db_status)",gm->query->name,gm->qtype->reload_func); closebrace(dfp); add_block_comment(dfp,"Check to see what the reload is like"); expr(dfp,"if( db_status == DB_RETURN_ERROR )"); startbrace(dfp); expr(dfp,"fatal(\"In searching %s, Reload error on database %s, in threads\");",gm->name,gm->query->name); closebrace(dfp); expr(dfp,"if( db_status == DB_RETURN_END)"); startbrace_tag(dfp,"End of query database"); expr(dfp,"holder->search_has_ended = TRUE;"); expr(dfp,"%s(NULL,holder->querydb)",gm->qtype->close_func); add_block_comment(dfp,"release input mutex"); expr(dfp,"if( pthread_mutex_unlock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error in releasing input lock for %s\");",gm->name); closebrace(dfp); /* end of if at end ! */ add_block_comment(dfp,"get query information into datascore"); expr(dfp,"%s(ds->query,%s,holder->querydb);",gm->qtype->dataentry_add,gm->query->name); } add_break(dfp); add_block_comment(dfp,"Now there is a new query/target pair ready for comparison"); if( dpi->db_trace_level >= 1 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 1 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"A new pair to be compared...\\n\");"); } pre = get_pre_chainstr_GenericMatrix("holder->",gm); expr(dfp,"score = score_only_%s(%s)",gm->name,pre); ckfree(pre); add_break(dfp); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Getting output lock\\n\");"); } add_block_comment(dfp,"Getting lock on output"); expr(dfp,"if( pthread_mutex_lock(&(holder->output_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error on getting output lock for %s\");",gm->name); add_block_comment(dfp,"If the score is less than cutoff, schedule the datascore for reuse"); expr(dfp,"if( should_store_Hscore(holder->out,score) != TRUE)"); startbrace(dfp); expr(dfp,"free_DataScore(ds)"); closebrace(dfp); expr(dfp,"else"); startbrace_tag(dfp,"storing score"); expr(dfp,"ds->score = score"); expr(dfp,"add_Hscore(holder->out,ds)"); closebrace(dfp); expr(dfp,"if( pthread_mutex_unlock(&(holder->output_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error on releasing output lock for %s\");",gm->name); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Released output lock\\n\");"); } add_break(dfp); add_block_comment(dfp,"Now free database objects"); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"About to get input lock for free func\\n\");"); } expr(dfp,"if( pthread_mutex_lock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error on getting input lock for %s\");",gm->name); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Got input lock for free func\\n\");"); } if( qdb == TRUE ) { expr(dfp,"%s(%s);",gm->qtype->free_func,gm->query->name); } if( tdb == TRUE ) { expr(dfp,"%s(%s);",gm->ttype->free_func,gm->target->name); } if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Releasing input lock after free'ing\\n\");"); } expr(dfp,"if( pthread_mutex_unlock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error in releasing input lock for %s\");",gm->name); closebrace(dfp); /* back to while */ add_break(dfp); if( dpi->db_trace_level >= 1 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 1 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Exiting forever loop\\n\");"); } expr(dfp,"return NULL;"); close_function(dfp); add_break(dfp); macro(dfp,"#endif /* PTHREAD */"); return 1; } %func makes an the argument calling string which is compatible with the arg_str from get_argstr_GenericMatrix, but with a pre placement in it eg "query,target,holder->comp_mat" %arg gm r structure holding generic matrix return allocated string (must free) with chained-args %% char * get_pre_chainstr_GenericMatrix(const char * pre,const GenericMatrix * gm) { char buffer[MAXLINE]; int i; sprintf(buffer,"%s, %s ",gm->query->name,gm->target->name); for(i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,pre); strcat(buffer,gm->resource[i]->name); } return stringalloc(buffer); } %} wise-2.4.1/src/dyc/dyc.c0000644000175000001440000004566207344635454014375 0ustar philippusers/* Last edited: Apr 29 10:16 1997 (birney) */ #include "module.h" #include "dyna2.h" #include "telegraph.h" #include "dynafunc.h" #include "modulefunc.h" #include "api.h" /* remove this #define if you don't want to link to compugen conversion code */ #define COMPUGEN #ifdef COMPUGEN #include "compugen.h" #endif char * program_name = "Dynamite Compiler"; char * description = "This takes a Dynamite source file to make .c and .h files"; char * version = "1.1"; char * author = "Ewan Birney"; char * email = "birney@sanger.ac.uk"; FILE * tele_file =NULL; /*boolean do_compugen = FALSE;*/ typedef int FailureType; #define FailureType_dyc_All 01 #define FailureType_dyc_UF 02 DPImplementation * dpi; void show_usage(FILE * ofp) { fprintf(ofp,"%s %s\nWritten by %s <%s>\nUSAGE: dyc [options] \n",program_name,version,author,email); fprintf(ofp,"OPTIONS:\n"); fprintf(ofp," -u -h Show this message \n\n"); /* fprintf(ofp," -i produce information on STDOUT of Dynamite types\n"); fprintf(ofp," -m file containing method information\n"); fprintf(ofp," -U Do not load configured method information, only -m options\n"); */ fprintf(ofp," -I Overrides WISECONFIGDIR\n"); /* arve */ fprintf(ofp," -n package name for file\n"); fprintf(ofp," -P [no] Protection level of the code (run-time warning checks)\n\n Advanced dy compiler options for Dynamite development\n"); fprintf(ofp," -l hard link option \n"); fprintf(ofp," -F Fail on incomplete modules \n"); fprintf(ofp," -D Warn on undocumented funcs \n"); fprintf(ofp,"API layer options\n"); fprintf(ofp," -perl Generate perl xs and stubs from api\n"); fprintf(ofp," -latex Generate latex section\n"); fprintf(ofp," -tele generate telegraph pseudo-grammar\n"); show_help_DPImplementation(ofp); } /*** Error system: to be registered in wiseerror.c Will give line and position of error'd file. ***/ char * parsed_file = NULL; static char pbuff[1024]; char * parse_line_error(void) { sprintf(pbuff,"%s:%d:",parsed_file,get_watched_linecount()); /* arve */ return pbuff; } /*** parse function parses the function section of the file, returning NULL on error. input is the pointer to the .dy stream, dfp is the DYNFILE (found in dynfile.dy) output structure. ModuleFunction * is going to have a list of all the Modules which have constructor or deconstructor functions like Module_alloc() and free_Module() if they are in place, then we will write out different cons/decons in the function files ****/ ModuleFunctionList * parse_function_section(FILE * input,DYNFILE * dfp,FailureType * ft,boolean addnumbers) { ModuleFunctionList * out; boolean outoffunction=TRUE; char * name; boolean next_line_alloc = FALSE; boolean next_line_free = FALSE; char buffer[MAXLINE]; char * tempb; ModuleFunction * mf; FuncInfo * fi = NULL; out = ModuleFunctionList_alloc_std(); while( get_watched_line(buffer,MAXLINE,input) != NULL) { chop_newline(buffer); if( strstartcmp(buffer,"%}") == 0) break; if( strstartcmp(buffer,"%func") == 0 ) { /* fprintf(stderr,"Getting info line!\n"); */ fi = read_FuncInfo_line(buffer,input); fi->is_hand_written = TRUE; if( fi == NULL ) { warn("Unable to read function info line at %s. Probably going to give a parse error",buffer); } else add_DYNFILE(dfp,fi); continue; } if( outoffunction == TRUE ) { if( buffer[0] == '{' ) { outoffunction = FALSE; fputs_func_DYNFILE(buffer,dfp); continue; } /* fprintf(stderr,"Got here [%s]\n",buffer); */ if( buffer[0] == '\0' || isspace(buffer[0]) || strstartcmp(buffer,"static") == 0 || buffer[0] == '#' || buffer[0] == '/' || buffer[0] == '*' ) { next_line_alloc = next_line_free = FALSE; fputs_func_DYNFILE(buffer,dfp); continue; } /*** if the line starts with a ! we want to interpret it ***/ /*** as a dynamite specific tag ***/ if( strstartcmp(buffer,"!constructor") == 0 ) { next_line_alloc = TRUE; continue; } if( strstartcmp(buffer,"!deconstructor") == 0 ) { next_line_free = TRUE; continue; } if ( buffer[0] == '!' ) { next_line_alloc = next_line_free = FALSE; continue; } /*fprintf(stderr,"Got here again [%s]\n",buffer);*/ /*** ok this should be a function! ****/ if( next_line_alloc == TRUE || next_line_free == TRUE ) { tempb = stringalloc(buffer); name = parse_and_get_module_name_from_func(tempb,next_line_alloc); if(name == NULL) { warn("Function [%s] specified as cons/decons, but no module name parsed...",buffer); } else { if( (mf=get_ModuleFunction_from_name(out,name)) == NULL ) mf = new_ModuleFunction(out,name); if( next_line_alloc == TRUE ) { if( mf->has_cons == TRUE ) warn("Module %s already has a constructor... double overload!",name); else mf->has_cons = TRUE; } else { if( mf->has_decons == TRUE ) warn("Module %s already has a deconstructor... double overload",name); else mf->has_decons = TRUE; } ckfree(name); } ckfree(tempb); } /*** end of if cons/decons ***/ next_line_alloc = next_line_free = FALSE; /*** reconcile with fi if any ***/ if( fi != NULL ) { reconcile_FuncInfo_with_funcstr(fi,buffer); dfp->funcpos += show_eddystyle_FuncInfo(fi,dfp->func); /** already added to DYNFILE **/ } else { /* fprintf(stderr,"Using [%s] as an unknown function\n",buffer); */ fi = unknown_user_FuncInfo(buffer); /* fprintf(stderr,"Unknown function %s...\n",fi->name);*/ add_DYNFILE(dfp,fi); } /*** put #line compiler information ***/ /*** using global parsed file which is also used for errors... sort of yukky. ***/ if( addnumbers == TRUE) { fprintf(dfp->func,"# line %d \"%s\"\n",get_watched_linecount(),parsed_file); dfp->funcpos++; } /*** put line ***/ fi->line_in_c = dfp->funcpos; fi = NULL; fputs_func_DYNFILE(buffer,dfp); /*** put away function now ***/ /*** header information will be put away in dfp call ***/ } else { /*** actually inside a function ***/ if( buffer[0] == '}' ) outoffunction = TRUE; fputs_func_DYNFILE(buffer,dfp); } } return out; } /*** basic top-level loop over the file sourcename. mts = method scope file write_html_now does not currently work! ***/ typedef struct { char * c_extension_name; char * t_extension_name; char * pfdoc_ext; char * xs_ext; char * typemap_ext; char * pod_ext; char * latex_ext; boolean make_perl; boolean make_latex; boolean all_callable; } APIpara; boolean should_make_API(APIpara * api) { if( api->c_extension_name != NULL ) { if( api->t_extension_name == NULL ) { warn("You can't specifiy a c extension name without a type extension name as well!"); return FALSE; } return TRUE; } if( api->make_perl == TRUE ) { return TRUE; } return FALSE; } boolean make_API(DYNFILE * dfp,Dynamite * dyn,APIpara * api_para) { int i; dynAPI * api = NULL; char buffer[512]; char strpack[64]; FILE * ofp; strcpy(strpack,dfp->package_name); if( strpack[strlen(strpack)-1] == '_') { strpack[strlen(strpack)-1] = '\0'; } if( api_para->all_callable == TRUE) { api = promote_all_callable_dynAPI(dyn,dfp); } else { for(i=0;ilen;i++) { if( dyn->list[i]->type == DYNAMITETYPEAPI ) { if( api == NULL ) api = (dynAPI*)dyn->list[i]->data; else { warn("You have got more than one API defintion for this module. Currently not handled\n"); return FALSE; } } } if( api == NULL ) { return TRUE; } hard_link_dynAPI(api); crosslink_to_StructHolder_dynAPI(api,dyn); } if( api_para->make_perl == TRUE ) { write_dynAPI_accessor_functions(dfp,api); } if( prepare_dynAPI(api,dfp,dyn) == FALSE ) { warn("Could not prepare API"); return FALSE; } sprintf(buffer,"%s%s",dfp->sourceroot,api_para->c_extension_name); ofp = openfile(buffer,"w"); if( ofp == NULL ){ warn("Could not open [%s] as a API file",buffer); return FALSE; } write_C_dynAPI(api,dfp->package_name,ofp); fclose(ofp); sprintf(buffer,"%s%s",dfp->sourceroot,api_para->t_extension_name); ofp = openfile(buffer,"w"); if( ofp == NULL ){ warn("Could not open [%s] as a API file",buffer); return FALSE; } write_type_C_dynAPI(api,dfp->package_name,ofp); fclose(ofp); if( api_para->make_latex == TRUE ) { if( api_para->latex_ext == NULL ) { api_para->latex_ext = "tex"; } sprintf(buffer,"%s.%s",dfp->sourceroot,api_para->latex_ext); ofp = openfile(buffer,"w"); if( ofp == NULL ){ warn("Could not open [%s] as a API file",buffer); return FALSE; } write_latex_dynAPI(api,dfp->sourceroot,strpack,ofp); fclose(ofp); } if( api_para->pfdoc_ext != NULL ) { sprintf(buffer,"%s%s",dfp->sourceroot,api_para->pfdoc_ext); ofp = openfile(buffer,"w"); if( ofp == NULL ){ warn("Could not open [%s] as a API file",buffer); return FALSE; } fprintf(ofp,"\n:Module %s\n\n",dfp->sourceroot); write_pfdoc_dynAPI(api,dfp->package_name,ofp); fprintf(ofp,"\n\n!Module\n\n"); fclose(ofp); } if( api_para->make_perl == TRUE ) { sprintf(buffer,"%s%s",dfp->sourceroot,api_para->pod_ext); ofp = openfile(buffer,"w"); if( ofp == NULL ){ warn("Could not open [%s] as a API file",buffer); return FALSE; } write_pod_dynAPI(api,dfp->sourceroot,strpack,ofp); fclose(ofp); sprintf(buffer,"%s%s",dfp->sourceroot,api_para->xs_ext); ofp = openfile(buffer,"w"); if( ofp == NULL ){ warn("Could not open [%s] as a API file",buffer); return FALSE; } write_XS_dynAPI(api,dfp->package_name,ofp); fclose(ofp); sprintf(buffer,"%s%s",dfp->sourceroot,api_para->typemap_ext); ofp = openfile(buffer,"w"); if( ofp == NULL ){ warn("Could not open [%s] as a API file",buffer); return FALSE; } write_XS_typemap_dynAPI(api,dfp->package_name,ofp); fclose(ofp); } /* free_dynAPI(api); */ return TRUE; } boolean do_a_file(char * sourcename,MethodTypeSet * mts,boolean write_html_now,int c_protection_level,boolean should_hard_link,boolean should_warn_undocs,boolean addnumbers,char * package,APIpara * api_para,FailureType * ft) { FILE * ifp = NULL; DYNFILE * dfp = NULL; char * outputname = NULL; char * runner; char * rt; char c; char buffer[MAXLINE]; Dynamite * dyn; ModuleFunctionList * mfl = NULL; boolean end_of_file; ParseError pfail; int no; int i; #ifdef COMPUGEN OneModel * om; #endif /* Read first block */ /* read_plain_scan_and_replace("test.kar"); */ /*** open source ***/ ifp = openfile(sourcename,"r"); if( ifp == NULL ){ warn("Could not open [%s] as Dynamite source",sourcename); return FALSE; } open_watch_file(ifp); parsed_file = stringalloc(sourcename); push_errormsg_stack_call(parse_line_error); /*** open DYNFILE ***/ runner = strrchr(sourcename,'.'); if( runner == NULL ) { warn("Source %s has no . character. Not critical, but worrying...",sourcename); runner = sourcename + strlen(sourcename); } /*** hard coding debug for the moment ***/ c = *runner; *runner = '\0'; if( (dfp = open_std_no_html_dynfile(sourcename)) == NULL) { warn("Could not open DYNFILE system for output %s\n",outputname); goto error; } dfp->code_debug_level = c_protection_level; dfp->should_hard_link = should_hard_link; if( package != NULL ) { dfp->package_name = stringalloc(package); } *runner = c; /* Skip to %{ */ while( (rt=get_watched_line(buffer,MAXLINE,ifp)) != NULL) { if(strstartcmp(buffer,"%{") == 0) break; } if( rt == NULL) { log_full_error(WARNING,0,"Exhausted dynamite source [%s] without reading any blocks - consult man/help pages!",sourcename); goto error; } /* * Header region * Dump until next block %} * */ while( (rt=get_watched_line(buffer,MAXLINE,ifp)) != NULL) { if(strstartcmp(buffer,"%}") == 0) break; fputs(buffer,dfp->head); } if( rt == NULL) { warn("had only header information in dynamite file, no close header %}"); goto error; } /* Load in Dynamite */ dyn = read_Dynamite(ifp,"%{",&end_of_file,mts); if( dyn == NULL ) { log_full_error(WARNING,0,"Unable to read Dynamite models. Parse error."); goto error; } /* probably should check it now! */ pop_errormsg_stack(); pfail = (PERR_ARG_MISTYPE | PERR_ARG_NUM_MIS | PERR_SYNTAX); if( prepare_Dynamite(dyn,mts,dpi->dycw,pfail) == FALSE ) { log_full_error(FATAL,0,"A Dynamite blueprint fails semantic checks. Please refer to previous errors for the precise problem"); goto error; } if( tele_file != NULL ) { for(i=0;ilen;i++) { if( dyn->list[i]->type == DYNAMITETYPEGENERICMATRIX ) { write_Telegraph_grammar((GenericMatrix*)dyn->list[i]->data,tele_file); } } } /*** writes out user functions ***/ if( end_of_file == FALSE) { push_errormsg_stack_call(parse_line_error); mfl = parse_function_section(ifp,dfp,ft,addnumbers); pop_errormsg_stack(); } else { write_Dynamite_minimal_func(dfp); mfl = NULL; } /*** write out the header ***/ write_Dynamite_header(dyn,dpi,dfp); /*** writes out dynamite functions ***/ /*** should write line number now ***/ fprintf(dfp->func,"# line %d \"%s.c\"\n",dfp->funcpos,dfp->sourceroot); dfp->funcpos++; write_Dynamite_func(dyn,mfl,dpi,dfp); #ifdef COMPUGEN if( dyn->len > 0 && dyn->list[0]->type == DYNAMITETYPEGENERICMATRIX && dpi->doone == TRUE) { om = OneModel_from_GenericMatrix((GenericMatrix *) dyn->list[0]->data); if( om == NULL ) { warn("Cannot built Compugen port!"); } else { write_cugen_funcs(om,mts,dfp); } } #endif positionify_DYNFILE(dfp); /* check errors... could fail here */ if( have_got_unknown_func_DYNFILE(dfp,&no,should_warn_undocs) == TRUE) { *ft = (*ft | FailureType_dyc_UF); warn("You have %d undocumented functions",no); } if( should_make_API(api_para) == TRUE ) make_API(dfp,dyn,api_para); place_declarations_DYNFILE(dfp,FO_CUI_POSITION); /*** close Dynfile ***/ if(dyn != NULL) free_Dynamite(dyn); if( mfl != NULL ) free_ModuleFunctionList(mfl); close_dynfile(dfp); close_watch_file(); fclose(ifp); return TRUE; error : if( ifp != NULL) { fclose(ifp); close_watch_file(); } if( dfp != NULL) close_dynfile(dfp); return FALSE; } int main(int argc,char * argv[]) { FailureType fail = 0 ; FailureType should_fail_on = 0; int i; boolean doinfo = FALSE; boolean noaddnumbers = FALSE; MethodTypeSet * mts; MethodTypeSet * cp; boolean no_config_mts = FALSE; int prot_level = 0; int should_hard_link = 0; boolean should_warn_undoc = FALSE; char * prot_str; char * runner; char *config_dir=NULL; char buffer[64]; /** really for removing files **/ char * telegraph; APIpara api; char * pack; /** we no longer read in configs **/ mts = standard_dynamite_MethodTypeSet(); if( strip_out_boolean_argument(&argc,argv,"h") == TRUE || strip_out_boolean_argument(&argc,argv,"u") == TRUE /* arve */ || argc == 1 ) { show_usage(stdout); exit(1); } noaddnumbers = strip_out_boolean_argument(&argc,argv,"m"); doinfo = strip_out_boolean_argument(&argc,argv,"i"); no_config_mts = strip_out_boolean_argument(&argc,argv,"U"); should_hard_link = strip_out_boolean_argument(&argc,argv,"l"); prot_str = strip_out_assigned_argument(&argc,argv,"P"); should_warn_undoc = strip_out_boolean_argument(&argc,argv,"D"); telegraph = strip_out_assigned_argument(&argc,argv,"tele"); pack = strip_out_assigned_argument(&argc,argv,"n"); api.xs_ext = NULL; api.typemap_ext = NULL; api.pod_ext = NULL; api.c_extension_name = strip_out_assigned_argument(&argc,argv,"a"); api.t_extension_name = strip_out_assigned_argument(&argc,argv,"b"); api.pfdoc_ext = strip_out_assigned_argument(&argc,argv,"p"); api.xs_ext = strip_out_assigned_argument(&argc,argv,"x"); api.typemap_ext = strip_out_assigned_argument(&argc,argv,"tym"); api.all_callable = strip_out_boolean_argument(&argc,argv,"c"); api.make_perl = strip_out_boolean_argument(&argc,argv,"perl"); api.latex_ext = strip_out_assigned_argument(&argc,argv,"exttex"); api.make_latex = strip_out_boolean_argument(&argc,argv,"latex"); if( api.make_perl == TRUE) { if( api.xs_ext == NULL ) { api.xs_ext = ".xs"; } if( api.typemap_ext == NULL ) { api.typemap_ext = ".typemap"; } if( api.pod_ext == NULL ) { api.pod_ext = ".pod"; } } if( strip_out_boolean_argument(&argc,argv,"F") == TRUE) { should_fail_on = FailureType_dyc_All; } /* do DPImplementation */ dpi = new_DPImplementation_from_argstr(&argc,argv); if( prot_str != NULL ) { if( is_integer_string(prot_str,&prot_level) == FALSE ) { warn("Protection level %s is no integer!"); prot_level = 0; } } /* Override/set WISECONFIGDIR on the cmdline. (arve) */ config_dir = strip_out_assigned_argument(&argc, argv, "I"); if (config_dir != NULL) { set_config_dir(config_dir); } if( read_into_MethodTypeSet_filename(mts,"methods") == FALSE){ warn("You have no config file called 'methods'. This is bad news for dynamite matrices. I will attempt to compile, but you cannot use logical types. 'methods' should be either in the current directory, the $WISECONFIGDIR or your $WISEPERSONALDIR"); } /*** ok,loop over and do it ***/ if( argc < 1 ) { warn("You must have at least one dynamite source file to compile!"); show_usage(stdout); exit(1); } if( telegraph != NULL ) { tele_file= fopen(telegraph,"w"); } for(i=1;i argv[i] && *runner != '.';runner--) ; if( runner != argv[i] ) { *runner = '\0'; sprintf(buffer,"%s.c",argv[i]); if( remove_file(buffer) == FALSE ) { warn("Could not remove file %s from filesystem",buffer); } sprintf(buffer,"%s.h",argv[i]); if( remove_file(buffer) == FALSE ) { warn("Could not remove file %s from filesystem",buffer); } } /* else - well - something bad has happened */ fatal("Failed on file %s due to user defined fails",argv[i]); } if( mts != NULL ) { free_MethodTypeSet(mts); mts = cp; } } free_MethodTypeSet(mts); return 0; } wise-2.4.1/src/dyc/dpimpl.c0000644000175000001440000002231110670453715015057 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dpimpl.h" /* Function: show_help_DycWarning(ofp) * * Descrip: Shows to stdout the list of options * used by DycWarning * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 38 "dpimpl.dy" void show_help_DycWarning(FILE * ofp) { fprintf(ofp,"Dyc Compiler Warnings\n"); fprintf(ofp," -[no]cwarn Global switch to put on/off all warnings about C constructs\n"); fprintf(ofp," -[no]extern Warning about extern scope of names\n"); fprintf(ofp," -[no]methods Warning about extern methods not being scoped/typed\n"); fprintf(ofp," -[no]ctype Warning about non logical (C) types\n"); } /* Function: show_help_DPImplementation(ofp) * * Descrip: Shows to stdout the list options used * by DPImplementation * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 51 "dpimpl.dy" void show_help_DPImplementation(FILE * ofp) { fprintf(ofp,"Dynamic Programming debugging options\n"); fprintf(ofp," -g generate dynamic programming debugging\n"); fprintf(ofp,"Dynamic Programming Optimisations\n"); fprintf(ofp," -O switch all optimisations on\n"); fprintf(ofp," -[no]largemem Assume large malloc chunks ok (default no)\n"); fprintf(ofp,"Database search implementation options\n"); fprintf(ofp," -pthreads generate pthread code\n"); fprintf(ofp," -dbtrace database trace level code production\n"); fprintf(ofp," -onemodel generate onemodel (bioxl/g) port\n"); fprintf(ofp,"Additional generated routines\n"); fprintf(ofp," -prob all probabilistic routines\n"); fprintf(ofp," -logsum function to use for summing log'd scores\n"); show_help_DycWarning(ofp); } /* Function: new_DycWarning_from_argstr(argc,argv) * * Descrip: Processes the argstring into the DycWarning stuff * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [DycWarning *] * */ # line 72 "dpimpl.dy" DycWarning * new_DycWarning_from_argstr(int * argc,char ** argv) { DycWarning * out; boolean cwarn = TRUE; out = DycWarning_alloc(); strip_out_boolean_def_argument(argc,argv,"cwarn",&cwarn); if( cwarn == TRUE ) { out->warn_extern = TRUE; out->warn_extern_method = TRUE; out->warn_c_type = TRUE; } else { out->warn_extern = FALSE; out->warn_c_type = FALSE; out->warn_extern_method = FALSE; } strip_out_boolean_def_argument(argc,argv,"extern",&out->warn_extern); strip_out_boolean_def_argument(argc,argv,"ctype",&out->warn_c_type); strip_out_boolean_def_argument(argc,argv,"methods",&out->warn_extern_method); return out; } /* Function: new_DPImplementation_from_argstr(argc,argv) * * Descrip: Processes the argstring into the DPImplementation * datastructure. * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [DPImplementation *] * */ # line 103 "dpimpl.dy" DPImplementation * new_DPImplementation_from_argstr(int * argc,char ** argv) { DPImplementation * out; char * temp; out = DPImplementation_alloc(); if( (strip_out_boolean_argument(argc,argv,"pthreads")) == TRUE ) { out->do_threads = TRUE; } if( (temp=strip_out_assigned_argument(argc,argv,"dbtrace")) != NULL ) { if( is_integer_string(temp,&out->db_trace_level) == FALSE ) { warn("%s is not an integer argument for dbtrace",temp); } } if( strip_out_boolean_argument(argc,argv,"O") == TRUE ) { out->largemem= TRUE; /* other optimisations */ } strip_out_boolean_def_argument(argc,argv,"largemem",&out->largemem); strip_out_boolean_def_argument(argc,argv,"onemodel",&out->doone); if( strip_out_boolean_argument(argc,argv,"prob") == TRUE ) { out->doprob = TRUE; } if( strip_out_boolean_argument(argc,argv,"g") == TRUE ) { out->dydebug = TRUE; } if( (temp=strip_out_assigned_argument(argc,argv,"logsum")) != NULL ) { out->calcfunc = stringalloc(temp); } else { out->calcfunc = stringalloc("Probability_logsum"); } out->dycw = new_DycWarning_from_argstr(argc,argv); /* fprintf(stderr,"And %d is extern warning",out->dycw->warn_extern);*/ return out; } # line 141 "dpimpl.c" /* Function: hard_link_DycWarning(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DycWarning *] * * Return [UNKN ] Undocumented return value [DycWarning *] * */ DycWarning * hard_link_DycWarning(DycWarning * obj) { if( obj == NULL ) { warn("Trying to hard link to a DycWarning object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DycWarning_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DycWarning *] * */ DycWarning * DycWarning_alloc(void) { DycWarning * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DycWarning *) ckalloc (sizeof(DycWarning))) == NULL) { warn("DycWarning_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->warn_extern = TRUE; out->warn_extern_method = TRUE; out->warn_c_type = TRUE; return out; } /* Function: free_DycWarning(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DycWarning *] * * Return [UNKN ] Undocumented return value [DycWarning *] * */ DycWarning * free_DycWarning(DycWarning * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DycWarning obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_DPImplementation(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DPImplementation *] * * Return [UNKN ] Undocumented return value [DPImplementation *] * */ DPImplementation * hard_link_DPImplementation(DPImplementation * obj) { if( obj == NULL ) { warn("Trying to hard link to a DPImplementation object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DPImplementation_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DPImplementation *] * */ DPImplementation * DPImplementation_alloc(void) { DPImplementation * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DPImplementation *) ckalloc (sizeof(DPImplementation))) == NULL) { warn("DPImplementation_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->do_threads = FALSE; out->protect_level = 0; out->db_trace_level = 0; out->doprob = FALSE; out->doone = FALSE; out->calcfunc = NULL; out->largemem = FALSE; out->dycw = NULL; out->dydebug = FALSE; return out; } /* Function: free_DPImplementation(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DPImplementation *] * * Return [UNKN ] Undocumented return value [DPImplementation *] * */ DPImplementation * free_DPImplementation(DPImplementation * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DPImplementation obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->calcfunc != NULL) ckfree(obj->calcfunc); if( obj->dycw != NULL) free_DycWarning(obj->dycw); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/dpimpl.h0000644000175000001440000001154610670453715015074 0ustar philippusers#ifndef DYNAMITEdpimplHEADERFILE #define DYNAMITEdpimplHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" struct DycWarning { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif boolean warn_extern; boolean warn_extern_method; boolean warn_c_type; } ; /* DycWarning defined */ #ifndef DYNAMITE_DEFINED_DycWarning typedef struct DycWarning DycWarning; #define DYNAMITE_DEFINED_DycWarning #endif /* Object DPImplementation * * Descrip: No Description * */ struct DPImplementation { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif boolean do_threads; int protect_level; int db_trace_level; boolean doprob; boolean doone; char * calcfunc; boolean largemem; DycWarning * dycw; boolean dydebug; } ; /* DPImplementation defined */ #ifndef DYNAMITE_DEFINED_DPImplementation typedef struct DPImplementation DPImplementation; #define DYNAMITE_DEFINED_DPImplementation #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: show_help_DycWarning(ofp) * * Descrip: Shows to stdout the list of options * used by DycWarning * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void show_help_DycWarning(FILE * ofp); /* Function: show_help_DPImplementation(ofp) * * Descrip: Shows to stdout the list options used * by DPImplementation * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void show_help_DPImplementation(FILE * ofp); /* Function: new_DycWarning_from_argstr(argc,argv) * * Descrip: Processes the argstring into the DycWarning stuff * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [DycWarning *] * */ DycWarning * new_DycWarning_from_argstr(int * argc,char ** argv); /* Function: new_DPImplementation_from_argstr(argc,argv) * * Descrip: Processes the argstring into the DPImplementation * datastructure. * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [DPImplementation *] * */ DPImplementation * new_DPImplementation_from_argstr(int * argc,char ** argv); /* Function: hard_link_DycWarning(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DycWarning *] * * Return [UNKN ] Undocumented return value [DycWarning *] * */ DycWarning * hard_link_DycWarning(DycWarning * obj); /* Function: DycWarning_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DycWarning *] * */ DycWarning * DycWarning_alloc(void); /* Function: free_DycWarning(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DycWarning *] * * Return [UNKN ] Undocumented return value [DycWarning *] * */ DycWarning * free_DycWarning(DycWarning * obj); /* Function: hard_link_DPImplementation(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DPImplementation *] * * Return [UNKN ] Undocumented return value [DPImplementation *] * */ DPImplementation * hard_link_DPImplementation(DPImplementation * obj); /* Function: DPImplementation_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DPImplementation *] * */ DPImplementation * DPImplementation_alloc(void); /* Function: free_DPImplementation(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DPImplementation *] * * Return [UNKN ] Undocumented return value [DPImplementation *] * */ DPImplementation * free_DPImplementation(DPImplementation * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/dbmpi.dy0000644000175000001440000003166307502704705015067 0ustar philippusers %{ #include "dyna2.h" #include "dpimpl.h" %} %{ #include "dbmpi.h" %func The master mpi process loop. The essential idea here is that there is a queue of processes waiting for jobs; they indicate their readiness by sending a message to the master. The master then reads in the score (if necessary), and sends off a job to the slave (if there are more jobs to be done). Here is the pseudo code: check number of processes, and allocate space for (n-1) datascore objects initialize the databases forever { Receive a message if the message contains data process it if there are no more jobs to be done send a message to the slave, telling it to die if all the slaves have been notified Terminate MPI and return. if we have not done everything Pack data, and dispatch; do bookkeeping, reload next target } %% boolean write_MPI_master_loop(DYNFILE * dfp,DPImplementation * dpi,GenericMatrix * gm) { FuncInfo * fi; boolean tdb = FALSE; boolean qdb = FALSE; char buffer[MAXLINE]; int i; if( gm->qtype != NULL && gm->qtype->is_database == TRUE) qdb = TRUE; if( gm->ttype != NULL && gm->ttype->is_database == TRUE) tdb = TRUE; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"MPI_master_loop_%s",gm->name); add_line_to_Ftext(fi->ft,"Infinite loop code for MPI master for %s",gm->name); if (qdb == FALSE || tdb == FALSE) { warn("Currently no way of dealing with non-databased calls in MPI"); return FALSE; } macro(dfp,"#ifdef MPI"); if (qdb == TRUE) sprintf(buffer,"Search_Return_Type MPI_master_loop_%s(Hscore *out, %s querydb,", gm->name, gm->qtype->database_type); else sprintf(buffer,"Search_Return_Type MPI_master_loop_%s(Hscore *out, %s %s,", gm->name, gm->query->element_type, gm->query->name); if (tdb == TRUE) { strcat(buffer,gm->ttype->database_type); strcat(buffer," targetdb "); } else { strcat(buffer,gm->target->element_type); strcat(buffer," "); strcat(buffer,gm->target->name); strcat(buffer," "); } for (i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,gm->resource[i]->element_type); strcat(buffer," "); strcat(buffer,gm->resource[i]->name); } strcat(buffer,")"); start_function_FuncInfo(fi,dfp,buffer); if (qdb == TRUE) expr(dfp,"%s %s",gm->query->element_type,gm->query->name); if (tdb == TRUE) expr(dfp,"%s %s",gm->target->element_type,gm->target->name); expr(dfp, "int db_status;"); expr(dfp, "Score score;"); expr(dfp, "DataScore ** ds_arr;"); expr(dfp, "int done_targets = 0;"); expr(dfp, "int done_queries = 0;"); expr(dfp, "int all_done = 0;"); add_break(dfp); expr(dfp, "int slave_nr;"); expr(dfp, "int i, j;"); expr(dfp, "int size;"); expr(dfp, "int *working_arr;"); expr(dfp, "MPI_Status status;"); expr(dfp, "size_t buflen;"); expr(dfp, "char *buf;"); expr(dfp, "char *buforig;"); add_break(dfp); add_block_comment(dfp, "Init"); expr(dfp, "MPI_Comm_size(MPI_COMM_WORLD, &size);"); expr(dfp, "ds_arr = ckcalloc(1,sizeof(DataScore*) * size);"); expr(dfp, "working_arr = ckcalloc(1,sizeof(int) * size);"); add_break(dfp); /* FIXME: non-databased calls */ if (qdb == TRUE) { expr(dfp, "%s = %s(querydb, &db_status);", gm->query->name, gm->qtype->init_func); expr(dfp, "if(db_status == DB_RETURN_ERROR)"); hang_expr(dfp, "return SEARCH_ERROR;"); } else { warn("Don't yet know how to deal with non-databased MPI"); } if (tdb == TRUE) { expr(dfp, "%s = %s(targetdb, &db_status);", gm->target->name, gm->ttype->init_func); expr(dfp, "if(db_status == DB_RETURN_ERROR)"); hang_expr(dfp, "return SEARCH_ERROR;"); } else { warn("Don't yet know how to deal with non-databased MPI"); } expr(dfp, "for(;;)"); startbrace(dfp); expr(dfp, "MPI_Recv(&score, sizeof(Score), MPI_BYTE, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);"); expr(dfp, "slave_nr = status.MPI_SOURCE"); expr(dfp, "info(\"received(%%d). score = %%d\\n\", slave_nr, score);"); add_block_comment(dfp, "bookkeeping"); expr(dfp, "working_arr[slave_nr] = 0;"); expr(dfp, "switch (status.MPI_TAG)"); startbrace_tag(dfp, "What we do is based on what the tag of the message was"); expr(dfp, "case MPI_DATA_TAG :"); startcase(dfp); add_block_comment(dfp, "process incoming data"); expr(dfp, "if (should_store_Hscore(out,score) == TRUE)"); startbrace(dfp); expr(dfp, "info(\"saving score(%%d)\", score);"); expr(dfp, "ds_arr[slave_nr]->score = score;"); expr(dfp, "add_Hscore(out,ds_arr[slave_nr]);"); closebrace(dfp); expr(dfp, "else"); startbrace(dfp); expr(dfp, "free_DataScore(ds_arr[slave_nr]);"); closebrace(dfp); /* Fall through. This is not an error */ add_block_comment(dfp, "We fall through here, since the next case is for sending data out only."); closecase(dfp); expr(dfp, "case MPI_READY_TAG :"); startcase(dfp); expr(dfp, "if (!done_queries)"); startbrace(dfp); expr(dfp, "if (done_targets)"); startbrace_tag(dfp, "so get next query object"); if (qdb == TRUE) { expr(dfp, "%s = %s(%s,querydb,&db_status);", gm->query->name, gm->qtype->reload_func, gm->query->name); expr(dfp, "if( db_status == DB_RETURN_ERROR)"); hang_expr(dfp, "return SEARCH_ERROR;"); expr(dfp, "if( db_status == DB_RETURN_END )"); startbrace(dfp); expr(dfp, "info(\"no more queries\");"); expr(dfp, "done_queries=1;"); expr(dfp, "%s(%s,querydb);", gm->qtype->close_func, gm->query->name); closebrace(dfp); expr(dfp, "else"); startbrace_tag(dfp, "need new targets"); expr(dfp, "%s = %s(targetdb,&db_status);", gm->target->name, gm->ttype->init_func); expr(dfp, "if (db_status == DB_RETURN_ERROR)"); hang_expr(dfp, "return SEARCH_ERROR"); expr(dfp, "done_targets = 0;"); closebrace(dfp); } else { warn("Don't yet know how to deal with non-databased MPI"); } closebrace(dfp); add_block_comment(dfp, "if (done_targets)"); closebrace(dfp); add_block_comment(dfp, "if (!done_queries)"); add_break(dfp); expr(dfp, "if (done_queries)"); startbrace(dfp); expr(dfp, "info(\"sending dietag2 to %%d\", slave_nr);"); expr(dfp, "MPI_Send(NULL, 0, MPI_BYTE, slave_nr, MPI_DIE_TAG, MPI_COMM_WORLD);"); add_break(dfp); expr(dfp, "working_arr[slave_nr] = 0;"); expr(dfp, "all_done = 1;"); expr(dfp, "for (i=1; iquery,%s,querydb);", gm->qtype->dataentry_add, gm->query->name); expr(dfp, "%s(ds_arr[slave_nr]->target,%s,targetdb);", gm->ttype->dataentry_add, gm->target->name); add_block_comment(dfp, "Send job"); /* FIXME -- this won't work for gm->qtype = NULL */ if ((gm->qtype != NULL) && (gm->ttype != NULL)) { expr(dfp, "buflen = %s(%s) + %s(%s);", gm->qtype->buf_len_func, gm->query->name, gm->ttype->buf_len_func, gm->target->name); /* FIXME -- should reuse static buffer to reduce memory fragmentation */ expr(dfp, "buf = buforig = ckalloc(buflen);"); expr(dfp, "buf = %s(buf, %s);", gm->qtype->pack_func, gm->query->name); expr(dfp, "buf = %s(buf, %s);", gm->ttype->pack_func, gm->target->name); } expr(dfp, "MPI_Send(&buflen, sizeof(size_t), MPI_BYTE, slave_nr, MPI_WORK_TAG, MPI_COMM_WORLD);"); expr(dfp, "MPI_Send(buforig, buflen, MPI_BYTE, slave_nr, MPI_WORK_TAG, MPI_COMM_WORLD);"); expr(dfp, "ckfree(buforig);"); add_block_comment(dfp, "bookkeeping"); /* FIXME -- here, and elsewhere, this should really be boolean */ expr(dfp, "working_arr[slave_nr] = 1;"); add_break(dfp); expr(dfp, "info(\"loading target obj\");"); if (tdb == TRUE) { expr(dfp, "%s = %s(%s,targetdb,&db_status);", gm->target->name, gm->ttype->reload_func, gm->target->name); expr(dfp, "if(db_status == DB_RETURN_ERROR)"); hang_expr(dfp, "return SEARCH_ERROR;"); expr(dfp, "if(db_status == DB_RETURN_END)"); startbrace(dfp); expr(dfp, "%s(%s,targetdb);", gm->ttype->close_func, gm->target->name); expr(dfp, "done_targets = 1;"); closebrace(dfp); } else { warn("Don't yet know how to deal with non-databased MPI"); } expr(dfp, "break;"); closecase(dfp); expr(dfp, "default :"); startcase(dfp); expr(dfp, "fatal(\"Oops. Invalid MPI tag received. Blammo.\");"); expr(dfp, "break;"); closecase(dfp); closebrace(dfp); add_block_comment(dfp, "switch(status.MPI_TAG)"); closebrace(dfp); add_block_comment(dfp, "for (;;)"); close_function(dfp); macro(dfp, "#endif /* MPI */"); return TRUE; } boolean write_MPI_slave_loop(DYNFILE * dfp,DPImplementation * dpi,GenericMatrix * gm) { FuncInfo * fi; boolean qdb = FALSE; boolean tdb = FALSE; char buffer[MAXLINE]; int i; if( gm->qtype != NULL && gm->qtype->is_database == TRUE) qdb = TRUE; if( gm->ttype != NULL && gm->ttype->is_database == TRUE) tdb = TRUE; if ((qdb == FALSE) || (tdb == FALSE)) { warn("Currently no way of dealing with non-databased calls in MPI"); return FALSE; } fi = FuncInfo_named_from_varstr(FI_INTERNAL,"MPI_slave_loop_%s",gm->name); add_line_to_Ftext(fi->ft,"Infinite loop code for MPI slave for %s",gm->name); macro(dfp,"#ifdef MPI"); sprintf(buffer,"Search_Return_Type MPI_slave_loop_%s(generic_search_%s routine", gm->name, gm->name); for (i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,gm->resource[i]->element_type); strcat(buffer," "); strcat(buffer,gm->resource[i]->name); } strcat(buffer,")"); start_function_FuncInfo(fi,dfp,buffer); /* FIXME: What if gm->query->element_type is not a pointer */ expr(dfp,"%s %s = NULL",gm->query->element_type,gm->query->name); expr(dfp,"%s %s = NULL",gm->target->element_type,gm->target->name); expr(dfp, "char *buf;"); expr(dfp, "char *buforig;"); expr(dfp, "Score score;"); expr(dfp, "size_t buflen, tmp;"); expr(dfp, "int data_offset;"); expr(dfp, "int i, j;"); expr(dfp, "MPI_Status status;"); add_break(dfp); add_block_comment(dfp, "allocate some of the structures"); /* This is almost certainly not right (explicitly calling the thing Sequence, that is */ expr(dfp, "buflen = DEFAULT_BUF_LEN;"); expr(dfp, "buforig = buf = ckcalloc(1,buflen);"); add_break(dfp); add_block_comment(dfp, "Initial Send"); expr(dfp, "MPI_Send(NULL, 0, MPI_BYTE, 0, MPI_READY_TAG, MPI_COMM_WORLD);"); add_break(dfp); expr(dfp, "while(1)"); startbrace(dfp); expr(dfp, "buf = buforig;"); add_block_comment(dfp, "get job from master (0) process"); expr(dfp, "MPI_Recv(buf, sizeof(size_t), MPI_BYTE, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &status);"); add_block_comment(dfp, "if MPI_DIE_TAG, break and wait for barrier, then exit"); expr(dfp, "switch(status.MPI_TAG)"); startbrace(dfp); expr(dfp, "case MPI_WORK_TAG :"); startcase(dfp); expr(dfp, "tmp = *((int*)buf);"); expr(dfp, "if (tmp > buflen)"); startbrace(dfp); expr(dfp, "buflen = tmp;"); add_block_comment(dfp, "reallocate"); expr(dfp, "ckfree(buforig);"); expr(dfp, "buforig = buf = ckcalloc(1,buflen);"); closebrace(dfp); expr(dfp, "MPI_Recv(buf, buflen, MPI_BYTE, 0, MPI_WORK_TAG, MPI_COMM_WORLD, &status);"); add_break(dfp); if(gm->qtype != NULL) { expr(dfp, "buf = %s(buf, &%s);", gm->qtype->unpack_func, gm->query->name); } else { expr(dfp, "info(\"This really isn't going to work -- don't try\");"); } if(gm->ttype != NULL) { expr(dfp, "buf = %s(buf, &%s);", gm->ttype->unpack_func, gm->target->name); } else { expr(dfp, "info(\"This really isn't going to work -- don't try\");"); } add_break(dfp); add_block_comment(dfp, "Actually do the work"); sprintf(buffer, "score = (*routine)(%s, %s", gm->query->name, gm->target->name); for (i=0;ires_len;i++) { strcat(buffer,", "); strcat(buffer,gm->resource[i]->name); } strcat(buffer,")"); expr(dfp, buffer); expr(dfp, "MPI_Send(&score, sizeof(Score), MPI_BYTE, 0, MPI_DATA_TAG, MPI_COMM_WORLD);"); expr(dfp, "break;"); closecase(dfp); expr(dfp, "case MPI_DIE_TAG :"); startcase(dfp); expr(dfp, "info(\"got dietag\");"); expr(dfp, "if (NULL != %s) %s(%s);", gm->query->name, gm->qtype->free_func, gm->query->name); expr(dfp, "if (NULL != %s) %s(%s);", gm->target->name, gm->ttype->free_func, gm->target->name); expr(dfp, "ckfree(buforig);"); expr(dfp, "return SEARCH_OK;"); closecase(dfp); expr(dfp, "default :"); startcase(dfp); add_block_comment(dfp, "Ooo. This is really bad if we get to here"); expr(dfp, "return SEARCH_ERROR;"); closecase(dfp); closebrace(dfp); closebrace(dfp); close_function(dfp); macro(dfp, "#endif /* MPI */"); return TRUE; } %} wise-2.4.1/src/dyc/optimiser.dy0000644000175000001440000001401207313404535015772 0ustar philippusers %{ #include "dyna2.h" #include "type.h" #define CommonSubExpressionSetLISTLENGTH 512 #define CSE_I_DEP 1 #define CSE_J_DEP 2 #define IS_I_DEP_CSE(cse) ((cse->type & CSE_I_DEP) == CSE_I_DEP ? TRUE : FALSE) #define IS_J_DEP_CSE(cse) ((cse->type & CSE_J_DEP) == CSE_J_DEP ? TRUE : FALSE) #define IS_NON_IJ_DEP_CSE(cse) (cse->type == 0 ? TRUE : FALSE) %} struct CommonSubExpression ExprTree * expr; !link int id; // able to set things as being 1,2,3 etc int type; // is i or j or i,j or no dependent int number; !def="0" // number of times this sub expression is used struct CommonSubExpressionSet CommonSubExpression ** cse !list // list of common sub expressions %{ #include "optimiser.h" %func figures out whether this cse is i or j dependent %% void expr_ij_dependence(ExprTree * expr,int * ijdep) { int i; if( expr->type == ETR_NAME ) { if( strcmp(expr->word,"i") == 0 ) { *ijdep = (*ijdep | CSE_I_DEP); } if( strcmp(expr->word,"j") == 0 ) { *ijdep = (*ijdep | CSE_J_DEP); } } for(i=0;inochild;i++) { expr_ij_dependence(expr->child[i],ijdep); } } %func Writes code with sub expressions in the correct places %% void strcat_cses_ExprTree(ExprTree * epr,char * buffer,Scope * sc,MethodTypeSet * mts,DPImplementation * dpi) { strcat_ExprTree_Scoped(epr,buffer,sc,mts,dpi->dycw,cses_expr_placer,NULL); } %func pointer to function that does the magic on the cses placer system %type internal %% boolean cses_expr_placer(ExprTree * etr,char * buffer,void * data) { char b[20]; /* fprintf(stdout,"Getting into scoping, but with %d and %d\n",etr->type,etr->cse);*/ if( etr->cse == NULL ) return FALSE; strcat(buffer,"subexpr"); sprintf(b,"%d",etr->cse->id); strcat(buffer,b); return TRUE; } %func Places ids into the cses %type internal %% void id_CommonSubExpressionSet(CommonSubExpressionSet * cses) { int i; for(i=0;ilen;i++) cses->cse[i]->id = i; } %func Shows common sub expression set %% void show_CommonSubExpressionSet(CommonSubExpressionSet * cses,FILE * ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,"Sub Expression %d - Number of times seen %d IJdep %d\n ",i,cses->cse[i]->number,cses->cse[i]->type); print_ExprTree(cses->cse[i]->expr,ofp); fprintf(ofp,"\n"); } } %func Makes a CommonSubExpressionSet from the GenericMatrix structure. if source_ind_promote is true, then source_independent type systems are automatically promoted as a common sub expression, regardless of number of subexpressions found %% CommonSubExpressionSet * find_CommonSubExpressions(GenericMatrix * gm,boolean source_ind_promote) { int i,j; ExprTree * exlist[512]; int notags =0; CommonSubExpressionSet * out; CommonSubExpression * temp; out = CommonSubExpressionSet_alloc_std(); for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { attach_expressions_to_list(exlist,¬ags,gm->state[i]->source[j]->etr); } if( source_ind_promote == TRUE && gm->state[i]->etr != NULL) { temp = CommonSubExpression_alloc(); temp->expr = gm->state[i]->etr; gm->state[i]->etr->cse = temp; temp->number = 1; add_CommonSubExpressionSet(out,temp); } else { attach_expressions_to_list(exlist,¬ags,gm->state[i]->etr); } } for(i=0;ispec_len;i++) { for(j=0;jspecial[i]->len;j++) { attach_expressions_to_list(exlist,¬ags,gm->special[i]->source[j]->etr); } attach_expressions_to_list(exlist,¬ags,gm->special[i]->etr); } for(i=0;icse != NULL ) continue; temp = NULL; for(j=i+1;jcse != NULL ) continue; if( identical_ExprTree(exlist[i],exlist[j]) == TRUE ) { if( temp == NULL ) { temp = CommonSubExpression_alloc(); temp->expr = exlist[i]; exlist[i]->cse = temp; temp->number = 1; add_CommonSubExpressionSet(out,temp); } /* we do this for every subexpression that we find */ exlist[j]->cse = temp; temp->number++; } } } /* find i,j dependence */ for(i=0;ilen;i++) { expr_ij_dependence(out->cse[i]->expr,&out->cse[i]->type); } id_CommonSubExpressionSet(out); return out; } %func whether we should consider this a possible common sub expression or not %type internal %% boolean should_store_ExprTree_cse(ExprTree * start) { if( start->type == ETR_EXPRESSION || start->type == ETR_METHOD ) return TRUE; if( start->type == ETR_TAG || start->type == ETR_ARRAY || start->type == ETR_STRUCTREF || start->type == ETR_REFERENCE ) { if( start->parent->type == ETR_EXPRESSION || start->parent->type == ETR_STATEMENT) { return TRUE; } } return FALSE; } %func Attaches only ETR_EXPRESSIONS into the list. Really a subroutine for find_CommonSubExpressions %% void attach_expressions_to_list(ExprTree ** list,int * no,ExprTree * start) { int i; if( start == NULL ) return; /* fprintf(stderr,"Looking at expression %d... to %d\n",start->type,ETR_EXPRESSION); */ if( should_store_ExprTree_cse(start) == TRUE ) { list[*no] = start; *no = *no +1; } if( start->type == ETR_METHOD && start->nochild == 2) { for(i=0;ichild[1]->nochild;i++) attach_expressions_to_list(list,no,start->child[1]->child[i]); } else { for(i=0;inochild;i++) attach_expressions_to_list(list,no,start->child[i]); } } %func Says whether two ExprTrees are completely identical - ie, same trees with same tags in the same order. %type internal %% boolean identical_ExprTree(ExprTree * one,ExprTree * two) { int i; if( one->type != two->type ) return FALSE; if( one->word != NULL || two->word != NULL ) { if( strcmp(one->word,two->word) != 0 ) return FALSE; } if( one->nochild != two->nochild ) return FALSE; for(i=0;inochild;i++ ) { if( identical_ExprTree(one->child[i],two->child[i]) == FALSE ) { return FALSE; } } return TRUE; } %} wise-2.4.1/src/dyc/dynadebug.c0000644000175000001440000003770010670453715015544 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dynadebug.h" # line 20 "dynadebug.dy" void write_debug_funcs(DYNFILE * dfp,GenericMatrix * gm) { explicit_debug_func(dfp,gm); transition_debug_func(dfp,gm); make_debug_struct_func(dfp,gm); state_debug_func(dfp,gm); } # line 33 "dynadebug.dy" ExprSet * build_ExprSet(ExprTree * root) { ExprSet * out; assert(root); assert(root->type == ETR_STATEMENT); assert(root->child[0]); out = ExprSet_alloc_std(); /* deal with simple cases: number,tag, method */ if( root->child[0]->type != ETR_EXPRESSION ) { /* only one child */ add_ExprSet(out,hard_link_ExprTree(root->child[0])); } else { if( descend_ExprTree_for_ExprSet(out,root->child[0]) == FALSE ) { free_ExprSet(out); return NULL; } } return out; } # line 61 "dynadebug.dy" boolean descend_ExprTree_for_ExprSet(ExprSet * set,ExprTree * t) { boolean ret = TRUE; assert(set); assert(t); if( t->type != ETR_EXPRESSION ) { warn("In descending ExprTree for making an ExprSet, failed!"); return FALSE; } if( t->child[0]->type == ETR_EXPRESSION ) { if( descend_ExprTree_for_ExprSet(set,t->child[0]) == FALSE ) { ret = FALSE; } } else { add_ExprSet(set,hard_link_ExprTree(t->child[0])); } if( t->child[2]->type == ETR_EXPRESSION ) { if( descend_ExprTree_for_ExprSet(set,t->child[2]) == FALSE ) { ret = FALSE; } } else { add_ExprSet(set,hard_link_ExprTree(t->child[2])); } return ret; } # line 92 "dynadebug.dy" void make_debug_struct_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; int k,l,m; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"create_debug_%s",gm->name); start_function_FuncInfo(fi,dfp,"DebugMatrix * create_debug_%s(void)",gm->name); expr(dfp,"DebugMatrix * out;"); expr(dfp,"DebugState * st;"); expr(dfp,"DebugTransition * tr;"); add_break(dfp); expr(dfp,"out = std_DebugMatrix();"); expr(dfp,"out->show_cell = cell_debug_%s;",gm->name); add_break(dfp); for(k=0;klen;k++) { expr(dfp,"st = DebugState_alloc_std();"); expr(dfp,"st->statename = \"%s\";",gm->state[k]->name); expr(dfp,"st->state_num = %d",k); expr(dfp,"st->show_state = state_debug_%s_%s;",gm->name,gm->state[k]->name); expr(dfp,"add_DebugMatrix(out,st);"); for(l=0;lstate[k]->len;l++) { expr(dfp,"tr = DebugTransition_alloc();"); expr(dfp,"tr->fromstate = \"%s\";",gm->state[k]->source[l]->state_source); expr(dfp,"tr->from_state_num = %d;",gm->state[k]->source[l]->from_state_no); expr(dfp,"tr->show_transition = transition_debug_%s_%s_%s_%d_%d;",gm->name,gm->state[k]->name,gm->state[k]->source[l]->state_source,gm->state[k]->source[l]->offi,gm->state[k]->source[l]->offj); expr(dfp,"add_DebugState(st,tr);"); } } expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } # line 133 "dynadebug.dy" void state_debug_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; int k,l; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"cell_debug_%s",gm->name); start_function_FuncInfo(fi,dfp,"void cell_debug_%s(void * matrixpoi,int i,int j,FILE * ofp)",gm->name); expr(dfp,"%s * mat",gm->name); add_break(dfp); expr(dfp,"mat = (%s *) matrixpoi;",gm->name); add_break(dfp); for(k=0;klen;k++) { expr(dfp,"fprintf(ofp,\"State %9s %%d\\n\",%s_EXPL_MATRIX(mat,i,j,%s));",gm->state[k]->name,gm->name,gm->state[k]->name); } close_function(dfp); add_break(dfp); for(k=0;klen;k++) { fi = FuncInfo_named_from_varstr(FI_INTERNAL,"state_debug_%s_%s",gm->name,gm->state[k]->name); start_function_FuncInfo(fi,dfp,"void state_debug_%s_%s(void * matrixpoi,int i,int j,FILE * ofp)",gm->name,gm->state[k]->name); expr(dfp,"%s * mat",gm->name); add_break(dfp); expr(dfp,"mat = (%s *) matrixpoi;",gm->name); add_break(dfp); expr(dfp,"fprintf(ofp,\"State %s Score %%d\\n\",%s_EXPL_MATRIX(mat,i,j,%s));",gm->state[k]->name,gm->name,gm->state[k]->name); for(l=0;lstate[k]->len;l++) { auto CellSource * source; source = gm->state[k]->source[l]; expr(dfp,"fprintf(ofp,\" From %8s Matrix %%5d Score %%d\\n\",%s_EXPL_%s(mat,i-%d,j-%d,%s),%s);",source->state_source,gm->name,source->isspecial == TRUE ? "SPECIAL" : "MATRIX",source->offi,source->offj,source->state_source,source->calc_expr); } close_function(dfp); add_break; } } # line 174 "dynadebug.dy" void transition_debug_func(DYNFILE * dfp,GenericMatrix * gm) { int k,l,m; FuncInfo * fi; ExprSet * set; char buffer[512]; assert(dfp); assert(gm); for(k=0;klen;k++) { for(l=0;lstate[k]->len;l++) { auto CellSource * source; source = gm->state[k]->source[l]; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"transition_debug_%s_%s_%s_%d_%d",gm->name,gm->state[k]->name,source->state_source,source->offi,source->offj); start_function_FuncInfo(fi,dfp,"void transition_debug_%s_%s_%s_%d_%d(void * matrixpoi,int i,int j,FILE * ofp)",gm->name,gm->state[k]->name,source->state_source,source->offi,source->offj); expr(dfp,"%s * mat;",gm->name); add_break(dfp); expr(dfp,"mat = (%s *) matrixpoi;",gm->name); add_break(dfp); set = build_ExprSet(source->etr); for(m=0;mlen;m++) { buffer[0] = '\0'; strcat_ExprTree_Scoped(set->expr[m],buffer,gm->sc,gm->mts,NULL,NULL,NULL); expr(dfp,"fprintf(ofp,\"%s : %%d\\n\",%s);",buffer,buffer); } free_ExprSet(set); close_function(dfp); add_break(dfp); } } } # line 211 "dynadebug.dy" void explicit_debug_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; ArgInfo * ai; char * arg_str; char * chainstr; int k,l; /*** prepare function information ***/ fi = FuncInfo_named_from_varstr(FI_CALLABLE,"explicit_debug_%s",gm->name); add_line_to_Ftext(fi->ft,"This function provides debugging support",gm->name); add_line_to_Ftext(fi->ft,"for the dynamic programming models"); add_break_to_Ftext(fi->ft); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); ai->desc=stringallocf("%s which contains explicit basematrix memory",gm->name); start_function_FuncInfo(fi,dfp,"boolean explicit_debug_%s(DebugMatrix * de,boolean do_one_cell)",gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int num;"); expr(dfp,"%s * mat;",gm->name); add_break(dfp); expr(dfp,"mat = (%s *) de->matrix;",gm->name); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT )"); startbrace(dfp); warn_expr(dfp,"in explicit_debug_%s, passed a non Explicit matrix type, cannot calculate!",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); expr(dfp,"leni = mat->leni;"); expr(dfp,"lenj = mat->lenj;"); /*** see if there any specials to specials to do ***/ add_break(dfp); add_block_comment(dfp,"Enter debug matrix before matrix, reset"); expr(dfp,"user_DebugMatrix(de);"); add_break(dfp); expr(dfp,"if( de->reset == FALSE)"); startbrace(dfp); expr(dfp,"de->currenti = de->currentj = 0;"); closebrace(dfp); expr(dfp,"for(j=de->currentj;jcurrenti;ireset == TRUE )"); startbrace(dfp); expr(dfp,"i = de->currenti;"); expr(dfp,"j = de->currentj;"); expr(dfp,"continue;"); closebrace(dfp); closebrace(dfp); write_score_block(dfp,gm,"EXPL_MATRIX","mat","EXPL_SPECIAL",TRUE); add_break(dfp); add_block_comment(dfp,"Now update DebugMatrix datastructure."); add_break(dfp); for(k=0;klen;k++) { expr(dfp,"if( %s_EXPL_MATRIX(mat,i,j,%s) > de->max_score )",gm->name,gm->state[k]->name); startbrace(dfp); expr(dfp,"de->max_score = %s_EXPL_MATRIX(mat,i,j,%s);",gm->name,gm->state[k]->name); expr(dfp,"de->max_score_i = i;"); expr(dfp,"de->max_score_j = j;"); expr(dfp,"de->max_score_cell = %s;",gm->state[k]->name); closebrace(dfp); add_break(dfp); } expr(dfp,"de->currenti = i;"); expr(dfp,"de->currentj = j;"); add_break(dfp); closebrace(dfp); write_special_block(dfp,gm,"EXPL_MATRIX","EXPL_SPECIAL",NULL); add_block_comment(dfp,"Update currenti"); expr(dfp,"de->currenti = 0;"); add_break(dfp); closebrace(dfp); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } # line 326 "dynadebug.c" /* Function: swap_ExprSet(list,i,j) * * Descrip: swap function: an internal for qsort_ExprSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ExprTree **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ExprSet(ExprTree ** list,int i,int j) { ExprTree * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ExprSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ExprSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ExprTree **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ExprSet(ExprTree ** list,int left,int right,int (*comp)(ExprTree * ,ExprTree * )) { int i,last; if( left >= right ) return; swap_ExprSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ExprSet (list,++last,i); } swap_ExprSet (list,left,last); qsort_ExprSet(list,left,last-1,comp); qsort_ExprSet(list,last+1,right,comp); } /* Function: sort_ExprSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ExprSet * * * Arg: obj [UNKN ] Object containing list [ExprSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ExprSet(ExprSet * obj,int (*comp)(ExprTree *, ExprTree *)) { qsort_ExprSet(obj->expr,0,obj->len-1,comp); return; } /* Function: expand_ExprSet(obj,len) * * Descrip: Really an internal function for add_ExprSet * * * Arg: obj [UNKN ] Object which contains the list [ExprSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ExprSet(ExprSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_ExprSet called with no need"); return TRUE; } if( (obj->expr = (ExprTree ** ) ckrealloc (obj->expr,sizeof(ExprTree *)*len)) == NULL) { warn("ckrealloc failed for expand_ExprSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_ExprSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ExprSet *] * Arg: add [OWNER] Object to add to the list [ExprTree *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ExprSet(ExprSet * obj,ExprTree * add) { if( obj->len >= obj->maxlen) { if( expand_ExprSet(obj,obj->len + ExprSetLISTLENGTH) == FALSE) return FALSE; } obj->expr[obj->len++]=add; return TRUE; } /* Function: flush_ExprSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ExprSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ExprSet(ExprSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->expr[i] != NULL) { free_ExprTree(obj->expr[i]); obj->expr[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: ExprSet_alloc_std(void) * * Descrip: Equivalent to ExprSet_alloc_len(ExprSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ExprSet *] * */ ExprSet * ExprSet_alloc_std(void) { return ExprSet_alloc_len(ExprSetLISTLENGTH); } /* Function: ExprSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ExprSet *] * */ ExprSet * ExprSet_alloc_len(int len) { ExprSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = ExprSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->expr = (ExprTree ** ) ckcalloc (len,sizeof(ExprTree *))) == NULL) { warn("Warning, ckcalloc failed in ExprSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_ExprSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ExprSet *] * * Return [UNKN ] Undocumented return value [ExprSet *] * */ ExprSet * hard_link_ExprSet(ExprSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a ExprSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ExprSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ExprSet *] * */ ExprSet * ExprSet_alloc(void) { ExprSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ExprSet *) ckalloc (sizeof(ExprSet))) == NULL) { warn("ExprSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->expr = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_ExprSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ExprSet *] * * Return [UNKN ] Undocumented return value [ExprSet *] * */ ExprSet * free_ExprSet(ExprSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ExprSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->expr != NULL) { for(i=0;ilen;i++) { if( obj->expr[i] != NULL) free_ExprTree(obj->expr[i]); } ckfree(obj->expr); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/dynadebug.h0000644000175000001440000000763010670453715015550 0ustar philippusers#ifndef DYNAMITEdynadebugHEADERFILE #define DYNAMITEdynadebugHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna2.h" #include "dynafunc.h" #include "dpimpl.h" #define ExprSetLISTLENGTH 50 struct ExprSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ExprTree ** expr; int len;/* len for above expr */ int maxlen; /* maxlen for above expr */ } ; /* ExprSet defined */ #ifndef DYNAMITE_DEFINED_ExprSet typedef struct ExprSet ExprSet; #define DYNAMITE_DEFINED_ExprSet #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: add_ExprSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ExprSet *] * Arg: add [OWNER] Object to add to the list [ExprTree *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_ExprSet(ExprSet * obj,ExprTree * add); /* Function: flush_ExprSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ExprSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ExprSet(ExprSet * obj); /* Function: ExprSet_alloc_std(void) * * Descrip: Equivalent to ExprSet_alloc_len(ExprSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ExprSet *] * */ ExprSet * ExprSet_alloc_std(void); /* Function: ExprSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ExprSet *] * */ ExprSet * ExprSet_alloc_len(int len); /* Function: hard_link_ExprSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ExprSet *] * * Return [UNKN ] Undocumented return value [ExprSet *] * */ ExprSet * hard_link_ExprSet(ExprSet * obj); /* Function: ExprSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ExprSet *] * */ ExprSet * ExprSet_alloc(void); /* Function: free_ExprSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ExprSet *] * * Return [UNKN ] Undocumented return value [ExprSet *] * */ ExprSet * free_ExprSet(ExprSet * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ void write_debug_funcs(DYNFILE * dfp,GenericMatrix * gm); ExprSet * build_ExprSet(ExprTree * root); boolean descend_ExprTree_for_ExprSet(ExprSet * set,ExprTree * t); void make_debug_struct_func(DYNFILE * dfp,GenericMatrix * gm); void state_debug_func(DYNFILE * dfp,GenericMatrix * gm); void transition_debug_func(DYNFILE * dfp,GenericMatrix * gm); void explicit_debug_func(DYNFILE * dfp,GenericMatrix * gm); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void swap_ExprSet(ExprTree ** list,int i,int j) ; void qsort_ExprSet(ExprTree ** list,int left,int right,int (*comp)(ExprTree * ,ExprTree * )); void sort_ExprSet(ExprSet * obj,int (*comp)(ExprTree *, ExprTree *)); boolean expand_ExprSet(ExprSet * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/dyshatter.dy0000644000175000001440000003236107640307573016004 0ustar philippusers %{ #include "dynafunc.h" %} %{ #include "dyshatter.h" %func Writes shatter functions %% void write_shatter_functions(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { macro(dfp,"#define %s_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j]",gm->name); macro(dfp,"#define %s_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE)",gm->name); add_break(dfp); write_shatter_read_func(dfp,gm); write_shatter_access_funcs(dfp,gm); matrix_calculate_shatter_func(dfp,gm); } void write_shatter_access_funcs(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"%s_shatter_access_main",gm->name); start_function_FuncInfo(fi,dfp,"int %s_shatter_access_main(%s * mat,int i,int j,int state)",gm->name,gm->name); expr(dfp,"return %s_SHATTER_MATRIX(mat,i,j,state);",gm->name); close_function(dfp); add_break(dfp); fi = FuncInfo_named_from_varstr(FI_INTERNAL,"%s_shatter_access_special",gm->name); start_function_FuncInfo(fi,dfp,"int %s_shatter_access_special(%s * mat,int i,int j,int state)",gm->name,gm->name); expr(dfp,"return %s_SHATTER_SPECIAL(mat,i,j,state);",gm->name); close_function(dfp); add_break(dfp); } void write_shatter_read_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"PackAln_read_Shatter_%s",gm->name); add_line_to_Ftext(fi->ft,"Reads off PackAln from shatter matrix structure",gm->name); start_function_FuncInfo(fi,dfp,"PackAln * PackAln_read_Shatter_%s(%s * mat)",gm->name,gm->name); expr(dfp,"%s_access_func_holder holder",gm->name); add_break(dfp); expr(dfp,"holder.access_main = %s_shatter_access_main;",gm->name); expr(dfp,"holder.access_special = %s_shatter_access_special;",gm->name); expr(dfp,"assert(mat)"); expr(dfp,"assert(mat->shatter)"); expr(dfp,"return PackAln_read_generic_%s(mat,holder);",gm->name); close_function(dfp); add_break(dfp); } %func for shatter %% void matrix_calculate_shatter_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; ArgInfo * ai; CellSignatureSet * csig; int i; int j; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"calculate_shatter_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates the %s matrix when in shatter mode",gm->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); start_function_FuncInfo(fi,dfp,"boolean calculate_shatter_%s(%s * mat,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"int should_calc"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int tot;"); expr(dfp,"int num;"); expr(dfp,"int starti;"); expr(dfp,"int startj;"); expr(dfp,"int endi;"); expr(dfp,"int endj;"); add_break(dfp); csig = CellSignatureSet_from_GenericMatrix(gm); expr(dfp,"int * SIG_0_0;"); for(i=0;ilen;i++) { expr(dfp,"int * SIG_%d_%d;",csig->sig[i]->offi,csig->sig[i]->offj); } add_break(dfp); expr(dfp,"leni = mat->leni;"); expr(dfp,"lenj = mat->lenj;"); add_break(dfp); expr(dfp,"mat->shatter = new_ShatterMatrix(dpenv,%d,lenj,%d);",gm->len,gm->spec_len); expr(dfp,"prepare_DPEnvelope(dpenv)"); expr(dfp,"starti = dpenv->starti"); expr(dfp,"if( starti < 0 )"); hang_expr(dfp,"starti = 0"); expr(dfp,"startj = dpenv->startj"); expr(dfp,"if( startj < 0 )"); hang_expr(dfp,"startj = 0"); expr(dfp,"endi = dpenv->endi"); expr(dfp,"if( endi > mat->leni )"); hang_expr(dfp,"endi = mat->leni"); expr(dfp,"endj = dpenv->endj"); expr(dfp,"if( endj > mat->lenj )"); hang_expr(dfp,"endj = mat->lenj"); expr(dfp,"tot = (endi-starti) * (endj-startj);"); expr(dfp,"num = 0;"); /*** see if there any specials to specials to do ***/ add_break(dfp); expr(dfp,"start_reporting(\"%s Matrix calculation: \");",gm->name); expr(dfp,"for(j=startj;jlen;k++)"); startbrace(dfp); expr(dfp,"auto DPUnit * u;"); expr(dfp,"u = dpenv->dpu[k];"); expr(dfp,"switch(u->type)"); startbrace(dfp); expr(dfp,"case DPENV_RECT :"); startcase(dfp); expr(dfp,"if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length))"); hang_expr(dfp,"should_calc = 1"); expr(dfp,"break;"); closecase(dfp); expr(dfp,"case DPENV_DIAG :"); startcase(dfp); expr(dfp,"if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj)"); hang_expr(dfp,"should_calc = 1"); expr(dfp,"break;"); closecase(dfp); closebrace(dfp); expr(dfp,"if( should_calc == 1 )"); hang_expr(dfp,"break;"); closebrace(dfp); expr(dfp,"if( should_calc == 0)"); hang_expr(dfp,"continue;"); add_break(dfp); expr(dfp,"SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j);"); for(i=0;ilen;i++) { expr(dfp,"SIG_%d_%d = fetch_cell_from_ShatterMatrix(mat->shatter,i-%d,j-%d);",csig->sig[i]->offi,csig->sig[i]->offj,csig->sig[i]->offi,csig->sig[i]->offj); } add_break(dfp); write_score_block_shatter(dfp,gm,"SHATTER_","mat","SHATTER_SPECIAL",TRUE); closebrace(dfp); /**** if there are any specials do them here ****/ write_special_block(dfp,gm,"SHATTER_","SHATTER_SPECIAL",NULL); closebrace(dfp); /*** stop reporting ***/ expr(dfp,"stop_reporting()"); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } void write_score_block_shatter(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointertag,char * specialtag,boolean use_special) { register int i; register int j; register int k; for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; add_break(dfp); if( state->footprint_start > 1 || state->footprint_end < 0) { add_block_comment(dfp,"State %s has a footprint of %d - %d",state->name,state->footprint_start,state->footprint_end); expr(dfp,"if( SEQENDWITHIN(%d) != TRUE || SEQSTARTWITHIN(%d) != TRUE )",state->footprint_end,state->footprint_start); startbrace_tag(dfp,"Footprint exists"); } add_block_comment(dfp,"For state %s",state->name); add_block_comment(dfp,"setting first movement to score",state->name); if( state->source[0]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(state->source[0]->position,state->source[0]->offi,state->source[0]->offj)); startbrace(dfp); } /*********************************************************************/ /* this line looks like */ /* score = ProteinMatrix_EXPL_MATRIX(mat,i-1,j-1,MATCH) + xxxxx */ /*********************************************************************/ expr(dfp,"score = SIG_%d_%d[%s] + %s",state->source[0]->offi,state->source[0]->offj, state->source[0]->state_source,state->source[0]->calc_expr); if( state->source[0]->isspecial == TRUE ) { fatal("Cannot have a special to matrix transition as the first transition"); } if( state->source[0]->position != SOURCE_POS_ALL) { closebrace(dfp); } if( dfp->code_debug_level > 5) { expr(dfp,"if( score > IMPOSSIBLY_HIGH_SCORE )"); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] State %s source %s Impossibly high score [%%d]\",i,j,score);",state->name,state->source[0]->state_source); } if( dfp->code_debug_level > 100 ) { expr(dfp,"fprintf(stderr,\"MATRIX: [%%4d][%%4d] State %s source %s got score %%d\\n\",i,j,score);",state->name,state->source[0]->state_source); } /**** ok this is to stop underflow, but is v.v.v. hacky ****/ /*** removing underflow hack expr(dfp,"if(score < (-10000000) )"); hang_expr(dfp,"score = (-10000000)"); ****/ /****************************************/ /* now we do if then on score and temp */ /****************************************/ for(j=1;jlen;j++) { if( use_special == FALSE && state->source[j]->isspecial == TRUE ) continue; /** don't use the special! **/ if( state->source[j]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(state->source[j]->position,state->source[j]->offi,state->source[j]->offj)); startbrace(dfp); } add_block_comment(dfp,"From state %s to state %s",state->source[j]->state_source, state->name); if( state->source[j]->isspecial == TRUE ) expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,specialtag,pointertag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr); else expr(dfp,"temp = SIG_%d_%d[%s] + %s", state->source[j]->offi,state->source[j]->offj, state->source[j]->state_source, state->source[j]->calc_expr); if( dfp->code_debug_level > 5) { expr(dfp,"if( temp > IMPOSSIBLY_HIGH_SCORE )"); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] State %s source %s Impossibly high score [%%d]\",i,j,temp);",state->name,state->source[j]->state_source); } if( dfp->code_debug_level > 100 ) { expr(dfp,"fprintf(stderr,\"MATRIX: [%%4d][%%4d] State %s source %s got score %%d\\n\",i,j,temp);",state->name,state->source[0]->state_source); } /**** ok this is to stop underflow, but is v.v.v. hacky ****/ /**** removing underflow hack expr(dfp,"if(score < (-10000000) )"); hang_expr(dfp,"score = (-10000000)"); ****/ /** if we have a specified calcfunc - use it here **/ if(gm->calcfunc != NULL ) { expr(dfp,"score = %s(score,temp);",gm->calcfunc); } else{ expr(dfp,"if( temp > score )"); startbrace(dfp); expr(dfp,"score = temp;"); /** ok for shadow matrix should put things in here */ closebrace(dfp); } if( state->source[j]->position != SOURCE_POS_ALL) { closebrace(dfp); } } /************************/ /* finished blocks */ /* put in global calc */ /************************/ add_break(dfp); add_block_comment(dfp,"Ok - finished max calculation for %s",state->name); add_block_comment(dfp,"Add any movement independant score and put away"); if( state->calc_expr != NULL) expr(dfp," score += %s",state->calc_expr); /***************************/ /* put away score */ /***************************/ expr(dfp," SIG_0_0[%s] = score;",state->name); if( use_special == FALSE ) { add_block_comment(dfp,"Finished calculating state %s",state->name); continue; } /************************/ /* for each special */ /* thats has this as */ /* source we have to */ /* update */ /************************/ for(j=0;jspec_len;j++) { auto CellState * specstate; specstate = gm->special[j]; for(k=0;klen;k++) { if( strcmp(specstate->source[k]->state_source,state->name) == 0) { /********************************/ /* is a special source! */ /********************************/ add_break(dfp); add_block_comment(dfp,"state %s is a source for special %s",state->name,specstate->name); if( specstate->source[k]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(specstate->source[k]->position,specstate->source[k]->offi,specstate->source[k]->offj)); startbrace(dfp); } expr(dfp,"temp = score + (%s) + (%s) ",specstate->source[k]->calc_expr,specstate->calc_expr == NULL ? "0" : specstate->calc_expr ); if(gm->calcfunc != NULL ) { expr(dfp,"%s_%s(%s,i,j,%s) = %s(%s_%s(%s,i,j,%s),temp);", gm->name,specialtag,pointertag,specstate->name, gm->calcfunc, gm->name,specialtag,pointertag,specstate->name); } else{ expr(dfp,"if( temp > %s_%s(%s,i,j,%s) ) ",gm->name,specialtag,pointertag,specstate->name); startbrace(dfp); expr(dfp,"%s_%s(%s,i,j,%s) = temp",gm->name,specialtag,pointertag,specstate->name); closebrace(dfp); add_break(dfp); } if( specstate->source[k]->position != SOURCE_POS_ALL) { closebrace(dfp); } } /* end of if this special state was a source for previous guy */ } /* end for each source of the special state */ if( dfp->code_debug_level > 4) { expr(dfp,"if( %s_%s(mat,0,j,%s) > IMPOSSIBLY_HIGH_SCORE )",gm->name,specialtag,specstate->name); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] Special state %s Impossibly high score [%%d] found\",i,j,%s_%s(mat,0,j,%s));",specstate->name,gm->name,specialtag,specstate->name); } } /* end for each special state */ if( state->footprint_start < 0 || state->footprint_end > 1 ) { closebrace(dfp); } add_break(dfp); add_block_comment(dfp,"Finished calculating state %s",state->name); } /* end of for each state */ } wise-2.4.1/src/dyc/funcinfo.c0000644000175000001440000010056410670453715015410 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "funcinfo.h" # line 71 "funcinfo.dy" void dump_FuncInfo(FuncInfo * fi,FILE * ofp ) { int i; fprintf(ofp,"Function info of %s\n",CKS(fi->name)); dump_Ftext(fi->ft,ofp); for(i=0;ilen;i++) { fprintf(ofp,"Argument %s type [%s] Desc %s\n",fi->arg[i]->name,fi->arg[i]->type,fi->arg[i]->desc); } } /* Function: show_eddystyle_FuncInfo(fi,ofp) * * Descrip: shows functions in * * *Function: * * * *des * * * * Arg * * * * Returns number of lines printed * * * Arg: fi [UNKN ] Undocumented argument [FuncInfo *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [int] * */ # line 96 "funcinfo.dy" int show_eddystyle_FuncInfo(FuncInfo * fi,FILE * ofp) { int i; int len=0; int maxn; maxn = max_argame(fi ); fprintf(ofp,"/* Function: %s(%s",CKS(fi->name),fi->len == 0 ? "void" : fi->arg[0]->name); for(i=1;ilen;i++) fprintf(ofp,",%s",fi->arg[i]->name); fprintf(ofp,")\n *\n"); len++; len += show_eddystyle_Ftext(fi->ft,"Descrip:",15,ofp,"No Description"); fprintf(ofp," *\n"); for(i=0;ilen;i++) len += show_eddystyle_ArgInfo(fi->arg[i],15,maxn,ofp); if( fi->ret != NULL && strcmp(fi->ret->type,"void") != 0 ) { fprintf(ofp," *\n * Return [%s] %s [%s]\n",ArgType_to_string(fi->ret->argtype),fi->ret->desc,CKS(fi->ret->type)); len +=2; } len += 2; fprintf(ofp," *\n */\n"); return len; } # line 125 "funcinfo.dy" char * ArgType_to_string(int type) { switch(type) { case ARGTYPE_READ : return "READ "; case ARGTYPE_WRITE : return "WRITE"; case ARGTYPE_READWRITE : return "RW "; case ARGTYPE_P2FUNC : return "FUNCP"; case ARGTYPE_OWNER: return "OWNER"; case ARGTYPE_STATIC : return "SOFT "; default : return "UNKN "; } } # line 145 "funcinfo.dy" int max_argame(FuncInfo * fi ) { int i; int max; if(fi->len == 0 ) { return 0; } for(i=1,max=strlen(fi->arg[0]->name);i < fi->len;i++) { if( max < strlen(fi->arg[i]->name) ) { max = strlen(fi->arg[i]->name); } } return max; } # line 163 "funcinfo.dy" int show_eddystyle_ArgInfo(ArgInfo * ai,int depth,int namedepth,FILE * ofp) { fprintf(ofp," * %*s%*s [%s] %s [%s]\n",-(depth-3),"Arg:",namedepth,ai->name,ArgType_to_string(ai->argtype),ai->desc,CKS(ai->type)); return 1; } # line 170 "funcinfo.dy" void sort_FuncInfo_by_position(FuncInfo * fi) { sort_FuncInfo(fi,compare_ArgInfo_pos); return; } # line 176 "funcinfo.dy" int compare_ArgInfo_pos(ArgInfo * one,ArgInfo * two) { return one->argpos- two->argpos; } # line 181 "funcinfo.dy" boolean reconcile_FuncInfo_with_funcstr(FuncInfo * fi,char * pass_str) { /** ok, stupid parsing for the moment **/ boolean ret = TRUE; char * runner; char * run2; char * arg; char ** base; char ** brk; char * fstr; int count; fstr = stringalloc(pass_str); if( fi->complete_name == NULL ) { fi->complete_name = stringalloc(fstr); } /** get the return type **/ if( strstartcmp(fstr,"const") == 0 ) { runner = fstr+5; for(;isspace(*runner);runner++) ; } else { runner = fstr; } if( strstartcmp(runner,"signed") == 0 ) { runner = fstr+6; for(;isspace(*runner);runner++) ; } if( strstartcmp(runner,"long") == 0 ) { runner = fstr+6; for(;isspace(*runner);runner++) ; } if( strstartcmp(runner,"struct") == 0 ) { runner = fstr+6; for(;isspace(*runner);runner++) ; } for(;isalnum(*runner) || *runner == '_' ;runner++) ; for(run2=runner;isspace(*runner);runner++) ; if( *runner == '*' ) { for(;*runner == '*';runner++) ; } else { runner = run2; } *runner = '\0'; if( fi->ret == NULL ) { fi->ret = ArgInfo_alloc(); fi->ret->name = stringalloc("return"); fi->ret->desc = stringalloc("Undocumented return value"); } fi->ret->type = stringalloc(fstr); /** got to the end of the return value **/ for(run2=runner+1;isspace(*run2);run2++) ; fi->stripped_return = stringalloc(run2); /** get the name of the function ***/ runner = strchr(run2,'(') ; if( runner == NULL ) { warn("reconciling function [%s] - no bracket!",pass_str); return FALSE; } arg = runner+1; *(runner) = '\0'; /** run2 now at the name **/ if( fi->name != NULL ) { if( strcmp(fi->name,run2) != 0 ) { warn("In reconciling function different names [%s] [%s]",fi->name,run2); } }else { fi->name = stringalloc(run2); } /*** now, process the argument list ***/ runner = arg + strlen(arg) -1; for(;runner > arg && *runner != ')';runner--) ; *runner = '\0'; base = brk = breakstring_protect(arg,",","()"); if( *brk != NULL && strcmp(*brk,"void") != 0 ) { for(count=0;*brk != NULL;brk++) { if( reconcile_FuncInfo_with_argstr(fi,*brk,count++) == FALSE ) ret = FALSE; } } ckfree(base); ckfree(fstr); sort_FuncInfo_by_position(fi); return ret; } # line 309 "funcinfo.dy" boolean reconcile_FuncInfo_with_pfunc(FuncInfo * fi,char * str,int pos) { char * runner; char * name; ArgInfo * temp; char * held; /** This is a HUGE kludge. V.v.v. embarrasing ***/ /** assumme type (*name)(type,type,type) ***/ held = stringalloc(str); name = runner = strchr(str,'('); name = runner = strchr(runner,'*'); name++; for(runner++;!isspace(*runner) && *runner != ')' ;runner++) ; *runner = '\0'; if( (temp=get_ArgInfo_by_name(fi,name)) == NULL ) { temp = ArgInfo_alloc(); add_FuncInfo(fi,temp); temp->name = stringalloc(name); temp->desc = stringalloc("Undocumented argument"); temp->func_decl = held; } else { temp->type = stringalloc(str); temp->argtype = ARGTYPE_P2FUNC; temp->argpos = pos; temp->func_decl = held; } return TRUE; } # line 353 "funcinfo.dy" FuncInfo * unknown_user_FuncInfo(char * funcstr) { FuncInfo * fi; fi = FuncInfo_from_str("Unknown user-defined function"); if( reconcile_FuncInfo_with_funcstr(fi,funcstr) == FALSE ) { warn("Could not reconcile [%s]... bad internal error.",funcstr); } return fi; } # line 366 "funcinfo.dy" boolean reconcile_FuncInfo_with_argstr(FuncInfo * fi,char * str,int pos) { char * runner; char * name; ArgInfo * temp; if( strchr(str,'(') != NULL ) return reconcile_FuncInfo_with_pfunc(fi,str,pos); for(;isspace(*str);str++) ; runner = str + strlen(str) -1; for(;runner > str && isspace(*runner);runner--) ; *(runner+1) = '\0'; for(;runner > str && !isspace(*runner);runner--) ; name = runner+1; if( strcmp(name,"void") == 0 ) return TRUE; for(;runner > str && isspace(*runner);runner--) ; *(runner+1) = '\0'; if( (temp=get_ArgInfo_by_name(fi,name)) == NULL ) { temp = ArgInfo_alloc(); add_FuncInfo(fi,temp); temp->name = stringalloc(name); temp->desc = stringalloc("Undocumented argument"); } temp->type = stringalloc(str); temp->argpos = pos; return TRUE; } # line 414 "funcinfo.dy" ArgInfo * get_ArgInfo_by_name(FuncInfo * fi,char * str) { int i; for(i=0;ilen;i++) if( strcmp(fi->arg[i]->name,str) == 0 ) return fi->arg[i]; return NULL; } # line 425 "funcinfo.dy" ArgInfo * ArgInfo_in_FuncInfo_from_varstr(FuncInfo * fi,char * str,...) { char buffer[MAXLINE]; ArgInfo * out; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); out = ArgInfo_alloc(); out->name = stringalloc(buffer); add_FuncInfo(fi,out); return out; } # line 443 "funcinfo.dy" FuncInfo * FuncInfo_named_from_varstr(int type,char * str, ...) { char buffer[MAXLINE]; FuncInfo * out; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); out = FuncInfo_alloc_std(); out->functype = type; out->name = stringalloc(buffer); out->ft = Ftext_alloc_std(); add_Ftext(out->ft,Fblock_alloc_std()); return out; } # line 463 "funcinfo.dy" FuncInfo * FuncInfo_from_str(char * str) { FuncInfo * fi; fi = FuncInfo_alloc_std(); fi->ft = single_Ftext_from_str(str); return fi; } /** I/O from user **/ # line 477 "funcinfo.dy" ModuleInfo * read_ModuleInfo_line(char * line,FILE * ifp) { ModuleInfo * out; char buffer[MAXLINE]; if( strstartcmp(line,"%module") != 0 ) { warn("Attempting to read module help with line starting [%30s] not %module",line); return NULL; } out = ModuleInfo_alloc(); out->ft = read_Ftext(buffer,MAXLINE,ifp,"%",fgets); return out; } # line 494 "funcinfo.dy" FuncInfo * read_FuncInfo_line(char * line,FILE * ifp) { FuncInfo * out; ArgInfo * ari; char buffer[MAXLINE]; char * runner; if( strstartcmp(line,"%func") != 0 ) { warn("Attempting to read in-line function help with line starting [%30s] not %func",line); return NULL; } out = FuncInfo_alloc_std(); out->functype = FI_CALLABLE; out->ft = read_Ftext(buffer,MAXLINE,ifp,"%",get_watched_line); if( strstartcmp(buffer,"%%") == 0 ) return out; /*** could be in any order ***/ for(;;) { /* fprintf(stderr,"Looking at [%s]\n",buffer); */ if( feof(ifp) || ferror(ifp) ) { warn("End of file or file read error while in FuncInfo read. Not good!"); break; } else if ( strstartcmp(buffer,"%%") == 0 ) { break; } else if ( strstartcmp(buffer,"%simple") == 0 ) { if( (runner=strtok(buffer+7,spacestr)) == NULL ) { warn("Got a simple name specification, but no name!"); } else { out->simple = stringalloc(runner); } get_watched_line(buffer,MAXLINE,ifp); } else if( strstartcmp(buffer,"%arg") == 0) { while( get_watched_line(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '%' ) break; ari = read_ArgInfo_line(buffer); if( strcmp(ari->name,"return") == 0 ) { out->ret = ari; } else if( ari != NULL ) { add_FuncInfo(out,ari); } } } else if ( strstartcmp(buffer,"%short") == 0 ) { for(runner=buffer;*runner && !isspace(*runner);runner++) ; for(;*runner && isspace(*runner);runner++) ; out->sdesc=stringalloc(runner); get_watched_line(buffer,MAXLINE,ifp); } else if ( strstartcmp(buffer,"%type") == 0 ) { if( strstr(buffer,"call") != NULL ) { out->functype = FI_CALLABLE; } else if ( strstr(buffer,"int") != NULL ) { out->functype = FI_INTERNAL; } get_watched_line(buffer,MAXLINE,ifp); } else { warn("Cannot understand %% tag %20s\n",buffer); while( get_watched_line(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '%' ) break; } } if( buffer[0] == '%') continue; /*** back to for(;;) ***/ /* else */ warn("In funcinfo line, could not understand [%s], going to skip to next %% tag",buffer); while( get_watched_line(buffer,MAXLINE,ifp) != NULL ) { chop_newline(buffer); if( buffer[0] == '%' ) break; else { warn("Did not interpret line [%s]\n",buffer); } } } return out; } # line 586 "funcinfo.dy" int get_arg_type(char * line,boolean * should_NULL) { char * runner; *should_NULL = FALSE; for(runner=line;*runner && !isspace(*runner);runner++) ; runner--; if( runner-line < 3 && *runner == 'N') { *should_NULL = TRUE; *runner=' '; } if ( strwordcmp(line,"rw",spacestr) == 0 ) return ARGTYPE_READWRITE; if( strwordcmp(line,"r",spacestr) == 0 ) return ARGTYPE_READ; if( strwordcmp(line,"o",spacestr) == 0 ) return ARGTYPE_OWNER; if( strwordcmp(line,"s",spacestr) == 0 ) return ARGTYPE_STATIC; if( strwordcmp(line,"f",spacestr) == 0 ) return ARGTYPE_P2FUNC; else if ( strwordcmp(line,"w",spacestr) == 0 ) return ARGTYPE_WRITE; else return ARGTYPE_UNKNOWN; } # line 620 "funcinfo.dy" ArgInfo * read_ArgInfo_line(char * line) { ArgInfo * out; char * runner; char * fix; out = ArgInfo_alloc(); for(runner=line;*runner && !isalpha(*runner) ;runner++) ; fix = runner; for(runner=line;*runner && iscword(*runner);runner++) ; /*** got first word ***/ *runner = '\0'; out->name = stringalloc(fix); /*** next word ***/ for(runner++;*runner && !isalpha(*runner);runner++) ; /*** if it is a valid arg type, get it and move on ***/ if( (out->argtype=get_arg_type(runner,&out->should_NULL)) != ARGTYPE_UNKNOWN) { for(;*runner && isalnum(*runner);runner++) ; for(;*runner && isspace(*runner);runner++) ; } fix = runner; for(;*runner && *runner != '\n';runner++) ; *runner = '\0'; out->desc = stringalloc(fix); return out; } # line 624 "funcinfo.c" /* Function: hard_link_ArgInfo(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ArgInfo *] * * Return [UNKN ] Undocumented return value [ArgInfo *] * */ ArgInfo * hard_link_ArgInfo(ArgInfo * obj) { if( obj == NULL ) { warn("Trying to hard link to a ArgInfo object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ArgInfo_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ArgInfo *] * */ ArgInfo * ArgInfo_alloc(void) { ArgInfo * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ArgInfo *) ckalloc (sizeof(ArgInfo))) == NULL) { warn("ArgInfo_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->argtype = ARGTYPE_UNKNOWN; out->should_NULL = FALSE; out->name = NULL; out->type = NULL; out->desc = NULL; out->argpos = 0; out->func_decl = NULL; return out; } /* Function: free_ArgInfo(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ArgInfo *] * * Return [UNKN ] Undocumented return value [ArgInfo *] * */ ArgInfo * free_ArgInfo(ArgInfo * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ArgInfo obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->type != NULL) ckfree(obj->type); if( obj->desc != NULL) ckfree(obj->desc); if( obj->func_decl != NULL) ckfree(obj->func_decl); ckfree(obj); return NULL; } /* Function: hard_link_ErrorInfo(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ErrorInfo *] * * Return [UNKN ] Undocumented return value [ErrorInfo *] * */ ErrorInfo * hard_link_ErrorInfo(ErrorInfo * obj) { if( obj == NULL ) { warn("Trying to hard link to a ErrorInfo object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ErrorInfo_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ErrorInfo *] * */ ErrorInfo * ErrorInfo_alloc(void) { ErrorInfo * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ErrorInfo *) ckalloc (sizeof(ErrorInfo))) == NULL) { warn("ErrorInfo_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->value = NULL; out->desc = NULL; return out; } /* Function: free_ErrorInfo(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ErrorInfo *] * * Return [UNKN ] Undocumented return value [ErrorInfo *] * */ ErrorInfo * free_ErrorInfo(ErrorInfo * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ErrorInfo obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->value != NULL) ckfree(obj->value); if( obj->desc != NULL) ckfree(obj->desc); ckfree(obj); return NULL; } /* Function: swap_FuncInfo(list,i,j) * * Descrip: swap function: an internal for qsort_FuncInfo * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ArgInfo **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_FuncInfo(ArgInfo ** list,int i,int j) { ArgInfo * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_FuncInfo(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_FuncInfo which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ArgInfo **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_FuncInfo(ArgInfo ** list,int left,int right,int (*comp)(ArgInfo * ,ArgInfo * )) { int i,last; if( left >= right ) return; swap_FuncInfo(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_FuncInfo (list,++last,i); } swap_FuncInfo (list,left,last); qsort_FuncInfo(list,left,last-1,comp); qsort_FuncInfo(list,last+1,right,comp); } /* Function: sort_FuncInfo(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_FuncInfo * * * Arg: obj [UNKN ] Object containing list [FuncInfo *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_FuncInfo(FuncInfo * obj,int (*comp)(ArgInfo *, ArgInfo *)) { qsort_FuncInfo(obj->arg,0,obj->len-1,comp); return; } /* Function: expand_FuncInfo(obj,len) * * Descrip: Really an internal function for add_FuncInfo * * * Arg: obj [UNKN ] Object which contains the list [FuncInfo *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_FuncInfo(FuncInfo * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_FuncInfo called with no need"); return TRUE; } if( (obj->arg = (ArgInfo ** ) ckrealloc (obj->arg,sizeof(ArgInfo *)*len)) == NULL) { warn("ckrealloc failed for expand_FuncInfo, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_FuncInfo(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FuncInfo *] * Arg: add [OWNER] Object to add to the list [ArgInfo *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_FuncInfo(FuncInfo * obj,ArgInfo * add) { if( obj->len >= obj->maxlen) { if( expand_FuncInfo(obj,obj->len + FuncInfoLISTLENGTH) == FALSE) return FALSE; } obj->arg[obj->len++]=add; return TRUE; } /* Function: flush_FuncInfo(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FuncInfo *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_FuncInfo(FuncInfo * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->arg[i] != NULL) { free_ArgInfo(obj->arg[i]); obj->arg[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: swap_err_FuncInfo(list,i,j) * * Descrip: swap function: an internal for qsort_err_FuncInfo * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ErrorInfo **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_err_FuncInfo(ErrorInfo ** list,int i,int j) { ErrorInfo * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_err_FuncInfo(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_err_FuncInfo which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ErrorInfo **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_err_FuncInfo(ErrorInfo ** list,int left,int right,int (*comp)(ErrorInfo * ,ErrorInfo * )) { int i,last; if( left >= right ) return; swap_err_FuncInfo(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_err_FuncInfo (list,++last,i); } swap_err_FuncInfo (list,left,last); qsort_err_FuncInfo(list,left,last-1,comp); qsort_err_FuncInfo(list,last+1,right,comp); } /* Function: sort_err_FuncInfo(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_err_FuncInfo * * * Arg: obj [UNKN ] Object containing list [FuncInfo *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_err_FuncInfo(FuncInfo * obj,int (*comp)(ErrorInfo *, ErrorInfo *)) { qsort_err_FuncInfo(obj->err,0,obj->err_len-1,comp); return; } /* Function: expand_err_FuncInfo(obj,len) * * Descrip: Really an internal function for add_err_FuncInfo * * * Arg: obj [UNKN ] Object which contains the list [FuncInfo *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_err_FuncInfo(FuncInfo * obj,int len) { if( obj->err_maxlen > obj->err_len ) { warn("expand_FuncInfoerr_ called with no need"); return TRUE; } if( (obj->err = (ErrorInfo ** ) ckrealloc (obj->err,sizeof(ErrorInfo *)*len)) == NULL) { warn("ckrealloc failed for expand_FuncInfo, returning FALSE"); return FALSE; } obj->err_maxlen = len; return TRUE; } /* Function: add_err_FuncInfo(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FuncInfo *] * Arg: add [OWNER] Object to add to the list [ErrorInfo *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_err_FuncInfo(FuncInfo * obj,ErrorInfo * add) { if( obj->err_len >= obj->err_maxlen) { if( expand_err_FuncInfo(obj,obj->err_len + FuncInfoLISTLENGTH) == FALSE) return FALSE; } obj->err[obj->err_len++]=add; return TRUE; } /* Function: flush_err_FuncInfo(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FuncInfo *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_err_FuncInfo(FuncInfo * obj) { int i; for(i=0;ierr_len;i++) { /*for i over list length*/ if( obj->err[i] != NULL) { free_ErrorInfo(obj->err[i]); obj->err[i] = NULL; } } /* end of for i over list length */ obj->err_len = 0; return i; } /* Function: FuncInfo_alloc_std(void) * * Descrip: Equivalent to FuncInfo_alloc_len(FuncInfoLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FuncInfo *] * */ FuncInfo * FuncInfo_alloc_std(void) { return FuncInfo_alloc_len(FuncInfoLISTLENGTH); } /* Function: FuncInfo_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FuncInfo *] * */ FuncInfo * FuncInfo_alloc_len(int len) { FuncInfo * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = FuncInfo_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->arg = (ArgInfo ** ) ckcalloc (len,sizeof(ArgInfo *))) == NULL) { warn("Warning, ckcalloc failed in FuncInfo_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; if((out->err = (ErrorInfo ** ) ckcalloc (len,sizeof(ErrorInfo *))) == NULL) { warn("Warning, ckcalloc failed in FuncInfo_alloc_len"); return NULL; } out->err_len = 0; out->err_maxlen = len; return out; } /* Function: hard_link_FuncInfo(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FuncInfo *] * * Return [UNKN ] Undocumented return value [FuncInfo *] * */ FuncInfo * hard_link_FuncInfo(FuncInfo * obj) { if( obj == NULL ) { warn("Trying to hard link to a FuncInfo object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: FuncInfo_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FuncInfo *] * */ FuncInfo * FuncInfo_alloc(void) { FuncInfo * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FuncInfo *) ckalloc (sizeof(FuncInfo))) == NULL) { warn("FuncInfo_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->type = NULL; out->complete_name = NULL; out->stripped_return = NULL; out->ft = NULL; out->error = NULL; out->arg = NULL; out->len = out->maxlen = 0; out->err = NULL; out->err_len = out->err_maxlen = 0; out->sdesc = NULL; out->ret = NULL; out->functype = FI_UNKNOWN; out->line_in_c = 0; out->infopos = 0; out->simple = NULL; out->is_hand_written = FALSE; return out; } /* Function: free_FuncInfo(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FuncInfo *] * * Return [UNKN ] Undocumented return value [FuncInfo *] * */ FuncInfo * free_FuncInfo(FuncInfo * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FuncInfo obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->type != NULL) ckfree(obj->type); if( obj->complete_name != NULL) ckfree(obj->complete_name); if( obj->stripped_return != NULL) ckfree(obj->stripped_return); if( obj->ft != NULL) free_Ftext(obj->ft); if( obj->error != NULL) ckfree(obj->error); if( obj->arg != NULL) { for(i=0;ilen;i++) { if( obj->arg[i] != NULL) free_ArgInfo(obj->arg[i]); } ckfree(obj->arg); } if( obj->err != NULL) { for(i=0;ierr_len;i++) { if( obj->err[i] != NULL) free_ErrorInfo(obj->err[i]); } ckfree(obj->err); } if( obj->sdesc != NULL) ckfree(obj->sdesc); if( obj->ret != NULL) free_ArgInfo(obj->ret); if( obj->simple != NULL) ckfree(obj->simple); ckfree(obj); return NULL; } /* Function: hard_link_ModuleInfo(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ModuleInfo *] * * Return [UNKN ] Undocumented return value [ModuleInfo *] * */ ModuleInfo * hard_link_ModuleInfo(ModuleInfo * obj) { if( obj == NULL ) { warn("Trying to hard link to a ModuleInfo object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ModuleInfo_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ModuleInfo *] * */ ModuleInfo * ModuleInfo_alloc(void) { ModuleInfo * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ModuleInfo *) ckalloc (sizeof(ModuleInfo))) == NULL) { warn("ModuleInfo_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->ft = NULL; return out; } /* Function: free_ModuleInfo(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ModuleInfo *] * * Return [UNKN ] Undocumented return value [ModuleInfo *] * */ ModuleInfo * free_ModuleInfo(ModuleInfo * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ModuleInfo obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->ft != NULL) free_Ftext(obj->ft); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/funcinfo.h0000644000175000001440000002502110670453715015407 0ustar philippusers#ifndef DYNAMITEfuncinfoHEADERFILE #define DYNAMITEfuncinfoHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "ftext.h" #include "inputfile.h" #define FuncInfoLISTLENGTH 32 enum argtype { ARGTYPE_UNKNOWN = 43, ARGTYPE_READ, ARGTYPE_WRITE, ARGTYPE_READWRITE, ARGTYPE_P2FUNC, ARGTYPE_OWNER, ARGTYPE_STATIC }; enum FI_TYPE { FI_CALLABLE = 12, FI_UNKNOWN, FI_INTERNAL }; #define iscword(c) (c == '_' ? 1 : isalnum(c)) struct ArgInfo { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int argtype; boolean should_NULL; char * name; char * type; char * desc; int argpos; char * func_decl; /* for pointers to functions, so we can get declaration correct */ } ; /* ArgInfo defined */ #ifndef DYNAMITE_DEFINED_ArgInfo typedef struct ArgInfo ArgInfo; #define DYNAMITE_DEFINED_ArgInfo #endif struct ErrorInfo { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * value; char * desc; } ; /* ErrorInfo defined */ #ifndef DYNAMITE_DEFINED_ErrorInfo typedef struct ErrorInfo ErrorInfo; #define DYNAMITE_DEFINED_ErrorInfo #endif struct FuncInfo { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; char * type; char * complete_name; char * stripped_return; Ftext * ft; char * error; ArgInfo ** arg; int len;/* len for above arg */ int maxlen; /* maxlen for above arg */ ErrorInfo ** err; int err_len;/* len for above err */ int err_maxlen; /* maxlen for above err */ char * sdesc; ArgInfo * ret; int functype; int line_in_c; int infopos; char * simple; boolean is_hand_written; } ; /* FuncInfo defined */ #ifndef DYNAMITE_DEFINED_FuncInfo typedef struct FuncInfo FuncInfo; #define DYNAMITE_DEFINED_FuncInfo #endif struct ModuleInfo { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Ftext * ft; } ; /* ModuleInfo defined */ #ifndef DYNAMITE_DEFINED_ModuleInfo typedef struct ModuleInfo ModuleInfo; #define DYNAMITE_DEFINED_ModuleInfo #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: show_eddystyle_FuncInfo(fi,ofp) * * Descrip: shows functions in * * *Function: * * * *des * * * * Arg * * * * Returns number of lines printed * * * Arg: fi [UNKN ] Undocumented argument [FuncInfo *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [int] * */ int show_eddystyle_FuncInfo(FuncInfo * fi,FILE * ofp) ; /* Function: hard_link_ArgInfo(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ArgInfo *] * * Return [UNKN ] Undocumented return value [ArgInfo *] * */ ArgInfo * hard_link_ArgInfo(ArgInfo * obj); /* Function: ArgInfo_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ArgInfo *] * */ ArgInfo * ArgInfo_alloc(void); /* Function: free_ArgInfo(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ArgInfo *] * * Return [UNKN ] Undocumented return value [ArgInfo *] * */ ArgInfo * free_ArgInfo(ArgInfo * obj); /* Function: hard_link_ErrorInfo(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ErrorInfo *] * * Return [UNKN ] Undocumented return value [ErrorInfo *] * */ ErrorInfo * hard_link_ErrorInfo(ErrorInfo * obj); /* Function: ErrorInfo_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ErrorInfo *] * */ ErrorInfo * ErrorInfo_alloc(void); /* Function: free_ErrorInfo(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ErrorInfo *] * * Return [UNKN ] Undocumented return value [ErrorInfo *] * */ ErrorInfo * free_ErrorInfo(ErrorInfo * obj); /* Function: add_FuncInfo(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FuncInfo *] * Arg: add [OWNER] Object to add to the list [ArgInfo *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_FuncInfo(FuncInfo * obj,ArgInfo * add); /* Function: flush_FuncInfo(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FuncInfo *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_FuncInfo(FuncInfo * obj); /* Function: add_err_FuncInfo(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FuncInfo *] * Arg: add [OWNER] Object to add to the list [ErrorInfo *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_err_FuncInfo(FuncInfo * obj,ErrorInfo * add); /* Function: flush_err_FuncInfo(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FuncInfo *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_err_FuncInfo(FuncInfo * obj); /* Function: FuncInfo_alloc_std(void) * * Descrip: Equivalent to FuncInfo_alloc_len(FuncInfoLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FuncInfo *] * */ FuncInfo * FuncInfo_alloc_std(void); /* Function: FuncInfo_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FuncInfo *] * */ FuncInfo * FuncInfo_alloc_len(int len); /* Function: hard_link_FuncInfo(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FuncInfo *] * * Return [UNKN ] Undocumented return value [FuncInfo *] * */ FuncInfo * hard_link_FuncInfo(FuncInfo * obj); /* Function: FuncInfo_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FuncInfo *] * */ FuncInfo * FuncInfo_alloc(void); /* Function: free_FuncInfo(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FuncInfo *] * * Return [UNKN ] Undocumented return value [FuncInfo *] * */ FuncInfo * free_FuncInfo(FuncInfo * obj); /* Function: hard_link_ModuleInfo(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ModuleInfo *] * * Return [UNKN ] Undocumented return value [ModuleInfo *] * */ ModuleInfo * hard_link_ModuleInfo(ModuleInfo * obj); /* Function: ModuleInfo_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ModuleInfo *] * */ ModuleInfo * ModuleInfo_alloc(void); /* Function: free_ModuleInfo(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ModuleInfo *] * * Return [UNKN ] Undocumented return value [ModuleInfo *] * */ ModuleInfo * free_ModuleInfo(ModuleInfo * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ void dump_FuncInfo(FuncInfo * fi,FILE * ofp ) ; char * ArgType_to_string(int type); int max_argame(FuncInfo * fi ); int show_eddystyle_ArgInfo(ArgInfo * ai,int depth,int namedepth,FILE * ofp); void sort_FuncInfo_by_position(FuncInfo * fi); int compare_ArgInfo_pos(ArgInfo * one,ArgInfo * two); boolean reconcile_FuncInfo_with_funcstr(FuncInfo * fi,char * pass_str); boolean reconcile_FuncInfo_with_pfunc(FuncInfo * fi,char * str,int pos); FuncInfo * unknown_user_FuncInfo(char * funcstr); boolean reconcile_FuncInfo_with_argstr(FuncInfo * fi,char * str,int pos) ; ArgInfo * get_ArgInfo_by_name(FuncInfo * fi,char * str); ArgInfo * ArgInfo_in_FuncInfo_from_varstr(FuncInfo * fi,char * str,...); FuncInfo * FuncInfo_named_from_varstr(int type,char * str, ...); FuncInfo * FuncInfo_from_str(char * str); ModuleInfo * read_ModuleInfo_line(char * line,FILE * ifp); FuncInfo * read_FuncInfo_line(char * line,FILE * ifp); int get_arg_type(char * line,boolean * should_NULL); ArgInfo * read_ArgInfo_line(char * line); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void swap_FuncInfo(ArgInfo ** list,int i,int j) ; void qsort_FuncInfo(ArgInfo ** list,int left,int right,int (*comp)(ArgInfo * ,ArgInfo * )); void sort_FuncInfo(FuncInfo * obj,int (*comp)(ArgInfo *, ArgInfo *)); boolean expand_FuncInfo(FuncInfo * obj,int len); void swap_err_FuncInfo(ErrorInfo ** list,int i,int j) ; void qsort_err_FuncInfo(ErrorInfo ** list,int left,int right,int (*comp)(ErrorInfo * ,ErrorInfo * )); void sort_err_FuncInfo(FuncInfo * obj,int (*comp)(ErrorInfo *, ErrorInfo *)); boolean expand_err_FuncInfo(FuncInfo * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/dy2om.c0000644000175000001440000011207310670453715014631 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dy2om.h" /*** Globals used to communicate with yacc parser These are defined in type.dy. Here we will define them as externs. ***/ extern char * calc_lex_string; extern int stringpos; extern ExprTree * root; /* Conversion functions from internal dynamite datastruct to OneModel structure */ # line 93 "dy2om.dy" OneModel * OneModel_from_GenericMatrix(GenericMatrix * gm,MethodTypeSet * mts) { OneModel * out; OmTrans * trans; Scope * sc; int i,j; out = OneModel_alloc_std(); sc = std_Dynamite_Scope(); add_GenericMatrix_Scope(sc,gm); /*** add states ***/ for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { trans = OmTrans_from_CellSource(0,gm->state[i]->source[j],mts,sc); add_OneModel(out,trans); /* adds trans to out->trans list */ } } /*** should now do specials ***/ free_Scope(sc); return out; } # line 129 "dy2om.dy" OmTrans * OmTrans_from_CellSource(int base_point,CellSource * s,MethodTypeSet * mts,Scope * sc) { OmTrans * out; ExprTree * et; CugenYaccReturn ret; out = OmTrans_alloc(); out->dx = s->offi; out->dy = s->offj; /** this is the tricky part **/ /** copied from type.dy allocd_calc_line **/ /*** set globals that we share with lex/yacc ***/ calc_lex_string = s->source_expr; stringpos= 0; root = NULL; /*** parse it ***/ yyparse(); /*** check root, if NULL... otta here ***/ if( root == NULL ) { fatal("Nasty error, we cannot parse this calc line in making OneModel transition"); } find_toplevel_name(root); /** debugging stuff for now **/ printf("Doing calc line [%s]\n",s->source_expr); print_ExprTree(root); /** ok, just enter the function correctly **/ ret = descend_ExprTree_Cugen(root,mts,TRUE,sc,out); if( ret.is_doable == 0 ) { printf("Can't do this calc"); } else { printf("Can do this calc"); } printf("End\n\n"); return out; } # line 190 "dy2om.dy" OmState * OmState_from_CellState(CellState * cs) { OmState * out; out = OmState_alloc(); /* warn if NULL...oops! */ out->name = stringalloc(cs->name); if( cs->is_special_i == TRUE ) out->type = OmState_TYPE_MIDSTATE; else out->type = OmState_TYPE_STATE; return out; } /* Descent of yacc grammar to get Compugen model */ /* Function: descend_ExprTree_Cugen(et,mts,is_attachable,sc,ot) * * Descrip: Recursive parser of the yacc grammar for * compugen. * * If it is impossible for compugen to do, then * is_doable == 0 and the descent should abort asap. * * If not, at the lowest level of being able to map * to a compugen number, it is mapped. * * targetname should be entire scope. * * * Arg: et [UNKN ] Undocumented argument [ExprTree *] * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * Arg: is_attachable [UNKN ] Undocumented argument [boolean] * Arg: sc [UNKN ] Undocumented argument [Scope *] * Arg: ot [UNKN ] Undocumented argument [OmTrans *] * * Return [UNKN ] Undocumented return value [CugenYaccReturn] * */ # line 223 "dy2om.dy" CugenYaccReturn descend_ExprTree_Cugen(ExprTree * et,MethodTypeSet * mts,boolean is_attachable,Scope * sc,OmTrans * ot) { int i; CugenYaccReturn out; CugenYaccReturn child; ScopeUnit * su; OmUnit * unit; set_CugenYaccReturn(&out); switch(et->type) { case ETR_STATEMENT : /** descend into grammar **/ for(i=0;inochild;i++) { child = descend_ExprTree_Cugen(et->child[i],mts,is_attachable,sc,ot); if( child.is_doable == 0 ) { out.is_doable = 0; return out; /** get out of here now! **/ } } /** nothing else, if we are here, then we are ok! **/ out.is_doable = 1; return out; case ETR_EXPRESSION : /** expression is *at the moment* only 3 things wide **/ if( et->nochild != 3) { warn("Annoying. Sadly we have written the compugen parser to only have 3 piece expressions. You have %d piece ones. So... have to fail",et->nochild); out.is_doable = 0; return out; } /** we can only handle pluses **/ if( et->child[1]->type != ETR_OPERATOR || et->child[1]->word[0] != '+' ) { warn("Sadly the compugen parser can only handle simple plus expressions. you have a middle expression of type [%d] with character [%s]",et->child[1]->type,CKS(et->child[1]->word)); out.is_doable = 0; return out; } /** ok, now descend into 0 and 2 child **/ child = descend_ExprTree_Cugen(et->child[0],mts,is_attachable,sc,ot); if( child.is_doable == 0 ) { out.is_doable = 0; return out; /** get out of here now! **/ } child = descend_ExprTree_Cugen(et->child[2],mts,is_attachable,sc,ot); if( child.is_doable == 0 ) { out.is_doable = 0; return out; /** get out of here now! **/ } /** fine! **/ out.is_doable = 1; return out; /** end of ETR_EXPRESSION **/ case ETR_NUMBER : /** too easy. This is a non-index, query associated thing **/ out.is_doable = 1; out.is_index = 0; out.is_query = 1; if( is_attachable == FALSE ) { /** we are in an array/method call, just chain out for them to know **/ return out; } /** ok, lets attach it now! **/ if( ot->tprf_unit != NULL ) { warn("This is annoying problem. We have a very simple grammar involved in compugen things, and can't cope with 2 tprfs. We should!!"); out.is_doable = 0; return out; } unit = OmUnit_alloc(); /*** should put away C loop now ***/ unit->base = (-1); /** unassigned for the moment **/ unit->length = 1; unit->is_tprf = 1; out.unit = unit; ot->tprf_unit = unit; return out; /*** end of NUMBER ***/ case ETR_NAME : /** If it is top level, need to scope to query/target/resource/extern **/ if( (et->attrib & IS_TOPLEVEL) == IS_TOPLEVEL) { su = ScopeUnit_from_Scope(sc,et->word); if( su == NULL ) { warn("Currently we can't cope with implicit externs in compugen funcs"); out.is_doable = 0; return out; } if( su->scope_type == SCOPE_TARGET ) { out.is_doable = 1; out.is_variable = 1; out.is_query = 0; return out; } /*** otherwise, if this attachable, then - lets attach to tprf **/ out.is_doable = 1; out.is_index = 0; out.is_variable = 0; out.is_query = 1; if( is_attachable == FALSE ) { /** we are in an array/method call, just chain out for them to know **/ out.is_variable = 1; return out; } /** we should look at the type here... is this really something we can "add"**/ /** ok, lets attach it now! **/ if( ot->tprf_unit != NULL ) { warn("This is annoying problem. We have a very simple grammar involved in compugen things, and can't cope with 2 tprfs. We should!!"); out.is_doable = 0; return out; } unit = OmUnit_alloc(); /*** should put away C loop now ***/ unit->base = (-1); /** unassigned for the moment **/ unit->length = 1; unit->is_tprf = 1; out.unit = unit; ot->tprf_unit = unit; return out; /*** end of if TOP_LEVEL ***/ } /** is not top level... do we care? **/ if( is_attachable == TRUE ) { warn("I feel bad about this: we have a non-top level name which you claim is attachable. Should not be!"); } return out; /** end of ETR_NAME **/ case ETR_TAG : /** right... need to loop into tag... **/ /** for the moment, handle only 1 length tags. Should be most **/ if( et->nochild > 1 ) { warn("Can't currently cope with tags with more than one child. Yikes!"); out.is_doable = 0; return out; } child = descend_ExprTree_Cugen(et->child[0],mts,is_attachable,sc,ot); return child; /** get out of here now! **/ case ETR_ARRAY : /** ok, lets see the first part of the array **/ child = descend_ExprTree_Cugen(et->child[0],mts,FALSE,sc,ot); if( child.is_doable == 0 ) return child; if( child.is_query == 0 ) { /** is a target type. No! **/ warn("Certainly can't array into target type for compugen port"); out.is_doable = 0; return out; } /** should be a query type, not indexed. Lets hope so! **/ /** ok, now the expression into the array. Lets see what it is **/ child = descend_ExprTree_Cugen(et->child[1],mts,FALSE,sc,ot); printf("Child of array into is %d\n",child.is_doable); if( child.is_doable == 0 ) return child; /** if child is query ... then we have a tprf ***/ if( child.is_query == 1 ) { if( ot->tprf_unit != NULL ) { warn("This is annoying problem. We have a very simple grammar involved in compugen things, and can't cope with 2 tprfs. We should!!"); out.is_doable = 0; return out; } unit = OmUnit_alloc(); /*** should put away C loop now ***/ unit->base = (-1); /** unassigned for the moment **/ unit->length = 1; unit->is_tprf = 1; out.unit = unit; ot->tprf_unit = unit; out.is_doable = 1; return out; } else { warn("Not sure what to do with non query typed array expressions"); return out; } warn("Should not have got here!!!!"); return out; default : warn("Fell into an uncatched ETR_ type [%d]. Does not look good for you!",et->type); out.is_doable = 0; return out; } /* end of switch */ } # line 484 "dy2om.dy" void set_CugenYaccReturn(CugenYaccReturn * ret) { ret->is_doable = 0; ret->is_index = 0; ret->is_query = 0; ret->unit = NULL; } /* Debugging/test functions, not going to be used in final port */ /* Function: write_OneModel(om,ofp) * * Descrip: writes the model definition * * * Arg: om [UNKN ] Undocumented argument [OneModel *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 507 "dy2om.dy" void write_OneModel(OneModel * om,FILE * ofp) { int i; fprintf(ofp,"FILE_TYPE=MODEL;\n"); /*** boring stuff ***/ fprintf(ofp,"transition_name from to dx dy t_prf dprf t_seq dseq w_base w_seq dwx dwy\n"); for(i=0;ilen;i++) { write_OmTrans(i,om->trans[i],ofp); } } /* Function: write_OmTrans(number,ot,ofp) * * Descrip: writes one transition line * * * Arg: number [UNKN ] Undocumented argument [int] * Arg: ot [UNKN ] Undocumented argument [OmTrans *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 528 "dy2om.dy" void write_OmTrans(int number,OmTrans * ot,FILE * ofp) { fprintf(ofp,"Trans%d %s %s %d %d %d %d %d %d %d %d %d %d\n",number, ot->from->name, ot->to->name, ot->dx, ot->dy, ot->t_prf, ot->dprf, ot->t_seq, ot->dseq, ot->w_base, ot->w_seq, ot->dwx, ot->dwy ); } # line 501 "dy2om.c" /* Function: hard_link_OmState(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [OmState *] * * Return [UNKN ] Undocumented return value [OmState *] * */ OmState * hard_link_OmState(OmState * obj) { if( obj == NULL ) { warn("Trying to hard link to a OmState object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: OmState_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [OmState *] * */ OmState * OmState_alloc(void) { OmState * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(OmState *) ckalloc (sizeof(OmState))) == NULL) { warn("OmState_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->type = OmState_TYPE_UNKNOWN; return out; } /* Function: free_OmState(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [OmState *] * * Return [UNKN ] Undocumented return value [OmState *] * */ OmState * free_OmState(OmState * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a OmState obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: hard_link_OmUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [OmUnit *] * * Return [UNKN ] Undocumented return value [OmUnit *] * */ OmUnit * hard_link_OmUnit(OmUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a OmUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: OmUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [OmUnit *] * */ OmUnit * OmUnit_alloc(void) { OmUnit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(OmUnit *) ckalloc (sizeof(OmUnit))) == NULL) { warn("OmUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->c_string = NULL; out->base = 0; out->length = 0; out->is_tprf = 0; return out; } /* Function: free_OmUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [OmUnit *] * * Return [UNKN ] Undocumented return value [OmUnit *] * */ OmUnit * free_OmUnit(OmUnit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a OmUnit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->c_string != NULL) ckfree(obj->c_string); ckfree(obj); return NULL; } /* Function: hard_link_OmTrans(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [OmTrans *] * * Return [UNKN ] Undocumented return value [OmTrans *] * */ OmTrans * hard_link_OmTrans(OmTrans * obj) { if( obj == NULL ) { warn("Trying to hard link to a OmTrans object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: OmTrans_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [OmTrans *] * */ OmTrans * OmTrans_alloc(void) { OmTrans * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(OmTrans *) ckalloc (sizeof(OmTrans))) == NULL) { warn("OmTrans_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->dx = 0; out->dy = 0; out->t_prf = -1; out->dprf = 0; out->t_seq = -1; out->dseq = 0; out->w_base = -1; out->w_seq = 0; out->dwx = 0; out->dwy = 0; out->tprf_unit = NULL; out->wbase_unit = NULL; out->current_base = 0; return out; } /* Function: free_OmTrans(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [OmTrans *] * * Return [UNKN ] Undocumented return value [OmTrans *] * */ OmTrans * free_OmTrans(OmTrans * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a OmTrans obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->from is linked in */ /* obj->to is linked in */ if( obj->tprf_unit != NULL) free_OmUnit(obj->tprf_unit); if( obj->wbase_unit != NULL) free_OmUnit(obj->wbase_unit); ckfree(obj); return NULL; } /* Function: hard_link_OmTransFunc(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [OmTransFunc *] * * Return [UNKN ] Undocumented return value [OmTransFunc *] * */ OmTransFunc * hard_link_OmTransFunc(OmTransFunc * obj) { if( obj == NULL ) { warn("Trying to hard link to a OmTransFunc object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: OmTransFunc_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [OmTransFunc *] * */ OmTransFunc * OmTransFunc_alloc(void) { OmTransFunc * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(OmTransFunc *) ckalloc (sizeof(OmTransFunc))) == NULL) { warn("OmTransFunc_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->me = NULL; return out; } /* Function: free_OmTransFunc(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [OmTransFunc *] * * Return [UNKN ] Undocumented return value [OmTransFunc *] * */ OmTransFunc * free_OmTransFunc(OmTransFunc * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a OmTransFunc obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->me != NULL) free_Method(obj->me); ckfree(obj); return NULL; } /* Function: swap_OneModel(list,i,j) * * Descrip: swap function: an internal for qsort_OneModel * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [OmTrans **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_OneModel(OmTrans ** list,int i,int j) { OmTrans * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_OneModel(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_OneModel which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [OmTrans **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_OneModel(OmTrans ** list,int left,int right,int (*comp)(OmTrans * ,OmTrans * )) { int i,last; if( left >= right ) return; swap_OneModel(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_OneModel (list,++last,i); } swap_OneModel (list,left,last); qsort_OneModel(list,left,last-1,comp); qsort_OneModel(list,last+1,right,comp); } /* Function: sort_OneModel(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_OneModel * * * Arg: obj [UNKN ] Object containing list [OneModel *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_OneModel(OneModel * obj,int (*comp)(OmTrans *, OmTrans *)) { qsort_OneModel(obj->trans,0,obj->len-1,comp); return; } /* Function: expand_OneModel(obj,len) * * Descrip: Really an internal function for add_OneModel * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_OneModel(OneModel * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_OneModel called with no need"); return TRUE; } if( (obj->trans = (OmTrans ** ) ckrealloc (obj->trans,sizeof(OmTrans *)*len)) == NULL) { warn("ckrealloc failed for expand_OneModel, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_OneModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * Arg: add [OWNER] Object to add to the list [OmTrans *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_OneModel(OneModel * obj,OmTrans * add) { if( obj->len >= obj->maxlen) { if( expand_OneModel(obj,obj->len + OneModelLISTLENGTH) == FALSE) return FALSE; } obj->trans[obj->len++]=add; return TRUE; } /* Function: flush_OneModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_OneModel(OneModel * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->trans[i] != NULL) { free_OmTrans(obj->trans[i]); obj->trans[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: swap_st_OneModel(list,i,j) * * Descrip: swap function: an internal for qsort_st_OneModel * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [OmState **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_st_OneModel(OmState ** list,int i,int j) { OmState * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_st_OneModel(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_st_OneModel which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [OmState **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_st_OneModel(OmState ** list,int left,int right,int (*comp)(OmState * ,OmState * )) { int i,last; if( left >= right ) return; swap_st_OneModel(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_st_OneModel (list,++last,i); } swap_st_OneModel (list,left,last); qsort_st_OneModel(list,left,last-1,comp); qsort_st_OneModel(list,last+1,right,comp); } /* Function: sort_st_OneModel(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_st_OneModel * * * Arg: obj [UNKN ] Object containing list [OneModel *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_st_OneModel(OneModel * obj,int (*comp)(OmState *, OmState *)) { qsort_st_OneModel(obj->state,0,obj->st_len-1,comp); return; } /* Function: expand_st_OneModel(obj,len) * * Descrip: Really an internal function for add_st_OneModel * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_st_OneModel(OneModel * obj,int len) { if( obj->st_maxlen > obj->st_len ) { warn("expand_OneModelst_ called with no need"); return TRUE; } if( (obj->state = (OmState ** ) ckrealloc (obj->state,sizeof(OmState *)*len)) == NULL) { warn("ckrealloc failed for expand_OneModel, returning FALSE"); return FALSE; } obj->st_maxlen = len; return TRUE; } /* Function: add_st_OneModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * Arg: add [OWNER] Object to add to the list [OmState *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_st_OneModel(OneModel * obj,OmState * add) { if( obj->st_len >= obj->st_maxlen) { if( expand_st_OneModel(obj,obj->st_len + OneModelLISTLENGTH) == FALSE) return FALSE; } obj->state[obj->st_len++]=add; return TRUE; } /* Function: flush_st_OneModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_st_OneModel(OneModel * obj) { int i; for(i=0;ist_len;i++) { /*for i over list length*/ if( obj->state[i] != NULL) { free_OmState(obj->state[i]); obj->state[i] = NULL; } } /* end of for i over list length */ obj->st_len = 0; return i; } /* Function: swap_tf_OneModel(list,i,j) * * Descrip: swap function: an internal for qsort_tf_OneModel * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [OmTransFunc **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_tf_OneModel(OmTransFunc ** list,int i,int j) { OmTransFunc * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_tf_OneModel(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_tf_OneModel which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [OmTransFunc **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_tf_OneModel(OmTransFunc ** list,int left,int right,int (*comp)(OmTransFunc * ,OmTransFunc * )) { int i,last; if( left >= right ) return; swap_tf_OneModel(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_tf_OneModel (list,++last,i); } swap_tf_OneModel (list,left,last); qsort_tf_OneModel(list,left,last-1,comp); qsort_tf_OneModel(list,last+1,right,comp); } /* Function: sort_tf_OneModel(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_tf_OneModel * * * Arg: obj [UNKN ] Object containing list [OneModel *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_tf_OneModel(OneModel * obj,int (*comp)(OmTransFunc *, OmTransFunc *)) { qsort_tf_OneModel(obj->tfunc,0,obj->tf_len-1,comp); return; } /* Function: expand_tf_OneModel(obj,len) * * Descrip: Really an internal function for add_tf_OneModel * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_tf_OneModel(OneModel * obj,int len) { if( obj->tf_maxlen > obj->tf_len ) { warn("expand_OneModeltf_ called with no need"); return TRUE; } if( (obj->tfunc = (OmTransFunc ** ) ckrealloc (obj->tfunc,sizeof(OmTransFunc *)*len)) == NULL) { warn("ckrealloc failed for expand_OneModel, returning FALSE"); return FALSE; } obj->tf_maxlen = len; return TRUE; } /* Function: add_tf_OneModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * Arg: add [OWNER] Object to add to the list [OmTransFunc *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_tf_OneModel(OneModel * obj,OmTransFunc * add) { if( obj->tf_len >= obj->tf_maxlen) { if( expand_tf_OneModel(obj,obj->tf_len + OneModelLISTLENGTH) == FALSE) return FALSE; } obj->tfunc[obj->tf_len++]=add; return TRUE; } /* Function: flush_tf_OneModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_tf_OneModel(OneModel * obj) { int i; for(i=0;itf_len;i++) { /*for i over list length*/ if( obj->tfunc[i] != NULL) { free_OmTransFunc(obj->tfunc[i]); obj->tfunc[i] = NULL; } } /* end of for i over list length */ obj->tf_len = 0; return i; } /* Function: OneModel_alloc_std(void) * * Descrip: Equivalent to OneModel_alloc_len(OneModelLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [OneModel *] * */ OneModel * OneModel_alloc_std(void) { return OneModel_alloc_len(OneModelLISTLENGTH); } /* Function: OneModel_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [OneModel *] * */ OneModel * OneModel_alloc_len(int len) { OneModel * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = OneModel_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->trans = (OmTrans ** ) ckcalloc (len,sizeof(OmTrans *))) == NULL) { warn("Warning, ckcalloc failed in OneModel_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; if((out->state = (OmState ** ) ckcalloc (len,sizeof(OmState *))) == NULL) { warn("Warning, ckcalloc failed in OneModel_alloc_len"); return NULL; } out->st_len = 0; out->st_maxlen = len; if((out->tfunc = (OmTransFunc ** ) ckcalloc (len,sizeof(OmTransFunc *))) == NULL) { warn("Warning, ckcalloc failed in OneModel_alloc_len"); return NULL; } out->tf_len = 0; out->tf_maxlen = len; return out; } /* Function: hard_link_OneModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [OneModel *] * * Return [UNKN ] Undocumented return value [OneModel *] * */ OneModel * hard_link_OneModel(OneModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a OneModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: OneModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [OneModel *] * */ OneModel * OneModel_alloc(void) { OneModel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(OneModel *) ckalloc (sizeof(OneModel))) == NULL) { warn("OneModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->state_num = 0; out->semistate_num = 0; out->midstate_num = 0; out->profile_line_size = 0; out->trans = NULL; out->len = out->maxlen = 0; out->state = NULL; out->st_len = out->st_maxlen = 0; out->tfunc = NULL; out->tf_len = out->tf_maxlen = 0; return out; } /* Function: free_OneModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [OneModel *] * * Return [UNKN ] Undocumented return value [OneModel *] * */ OneModel * free_OneModel(OneModel * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a OneModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->trans != NULL) { for(i=0;ilen;i++) { if( obj->trans[i] != NULL) free_OmTrans(obj->trans[i]); } ckfree(obj->trans); } if( obj->state != NULL) { for(i=0;ist_len;i++) { if( obj->state[i] != NULL) free_OmState(obj->state[i]); } ckfree(obj->state); } if( obj->tfunc != NULL) { for(i=0;itf_len;i++) { if( obj->tfunc[i] != NULL) free_OmTransFunc(obj->tfunc[i]); } ckfree(obj->tfunc); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/dy2om.h0000644000175000001440000003270710670453715014643 0ustar philippusers#ifndef DYNAMITEdy2omHEADERFILE #define DYNAMITEdy2omHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna2.h" #include "exprtree.h" enum OmStateType { OmState_TYPE_UNKNOWN = 67, OmState_TYPE_STATE, OmState_TYPE_SEMISTATE, OmState_TYPE_MIDSTATE }; #define OneModelLISTLENGTH 64 typedef struct descent_return { int is_doable; /* 1 is yes, 0 cannot be handled by Compugen */ int is_index; /* 1 is yes, 0 is it is a float/number */ int is_query; /* when is index, 1 means in query, 0 in target */ int is_variable; struct OmUnit * unit; /* if non-NULL, this is the "done" unit */ } CugenYaccReturn; struct OmState { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; int type; } ; /* OmState defined */ #ifndef DYNAMITE_DEFINED_OmState typedef struct OmState OmState; #define DYNAMITE_DEFINED_OmState #endif struct OmUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * c_string; /* string of the actual C to use in making profile line */ int base; /* offset in profile line, must be the same as t_prf or w_base */ int length; /* 1 for t_prf lines. Longer for w_base lines. */ int is_tprf; } ; /* OmUnit defined */ #ifndef DYNAMITE_DEFINED_OmUnit typedef struct OmUnit OmUnit; #define DYNAMITE_DEFINED_OmUnit #endif struct OmTrans { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif OmState * from; OmState * to; int dx; int dy; int t_prf; int dprf; int t_seq; int dseq; int w_base; int w_seq; int dwx; int dwy; OmUnit * tprf_unit; OmUnit * wbase_unit; int current_base; } ; /* OmTrans defined */ #ifndef DYNAMITE_DEFINED_OmTrans typedef struct OmTrans OmTrans; #define DYNAMITE_DEFINED_OmTrans #endif struct OmTransFunc { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; Method * me; } ; /* OmTransFunc defined */ #ifndef DYNAMITE_DEFINED_OmTransFunc typedef struct OmTransFunc OmTransFunc; #define DYNAMITE_DEFINED_OmTransFunc #endif struct OneModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; int state_num; int semistate_num; int midstate_num; int profile_line_size; OmTrans ** trans; int len;/* len for above trans */ int maxlen; /* maxlen for above trans */ OmState ** state; int st_len; /* len for above state */ int st_maxlen; /* maxlen for above state */ OmTransFunc ** tfunc; int tf_len; /* len for above tfunc */ int tf_maxlen; /* maxlen for above tfunc */ } ; /* OneModel defined */ #ifndef DYNAMITE_DEFINED_OneModel typedef struct OneModel OneModel; #define DYNAMITE_DEFINED_OneModel #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: descend_ExprTree_Cugen(et,mts,is_attachable,sc,ot) * * Descrip: Recursive parser of the yacc grammar for * compugen. * * If it is impossible for compugen to do, then * is_doable == 0 and the descent should abort asap. * * If not, at the lowest level of being able to map * to a compugen number, it is mapped. * * targetname should be entire scope. * * * Arg: et [UNKN ] Undocumented argument [ExprTree *] * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * Arg: is_attachable [UNKN ] Undocumented argument [boolean] * Arg: sc [UNKN ] Undocumented argument [Scope *] * Arg: ot [UNKN ] Undocumented argument [OmTrans *] * * Return [UNKN ] Undocumented return value [CugenYaccReturn] * */ CugenYaccReturn descend_ExprTree_Cugen(ExprTree * et,MethodTypeSet * mts,boolean is_attachable,Scope * sc,OmTrans * ot); /* Function: write_OneModel(om,ofp) * * Descrip: writes the model definition * * * Arg: om [UNKN ] Undocumented argument [OneModel *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void write_OneModel(OneModel * om,FILE * ofp); /* Function: write_OmTrans(number,ot,ofp) * * Descrip: writes one transition line * * * Arg: number [UNKN ] Undocumented argument [int] * Arg: ot [UNKN ] Undocumented argument [OmTrans *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void write_OmTrans(int number,OmTrans * ot,FILE * ofp); /* Function: hard_link_OmState(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [OmState *] * * Return [UNKN ] Undocumented return value [OmState *] * */ OmState * hard_link_OmState(OmState * obj); /* Function: OmState_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [OmState *] * */ OmState * OmState_alloc(void); /* Function: free_OmState(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [OmState *] * * Return [UNKN ] Undocumented return value [OmState *] * */ OmState * free_OmState(OmState * obj); /* Function: hard_link_OmUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [OmUnit *] * * Return [UNKN ] Undocumented return value [OmUnit *] * */ OmUnit * hard_link_OmUnit(OmUnit * obj); /* Function: OmUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [OmUnit *] * */ OmUnit * OmUnit_alloc(void); /* Function: free_OmUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [OmUnit *] * * Return [UNKN ] Undocumented return value [OmUnit *] * */ OmUnit * free_OmUnit(OmUnit * obj); /* Function: hard_link_OmTrans(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [OmTrans *] * * Return [UNKN ] Undocumented return value [OmTrans *] * */ OmTrans * hard_link_OmTrans(OmTrans * obj); /* Function: OmTrans_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [OmTrans *] * */ OmTrans * OmTrans_alloc(void); /* Function: free_OmTrans(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [OmTrans *] * * Return [UNKN ] Undocumented return value [OmTrans *] * */ OmTrans * free_OmTrans(OmTrans * obj); /* Function: hard_link_OmTransFunc(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [OmTransFunc *] * * Return [UNKN ] Undocumented return value [OmTransFunc *] * */ OmTransFunc * hard_link_OmTransFunc(OmTransFunc * obj); /* Function: OmTransFunc_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [OmTransFunc *] * */ OmTransFunc * OmTransFunc_alloc(void); /* Function: free_OmTransFunc(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [OmTransFunc *] * * Return [UNKN ] Undocumented return value [OmTransFunc *] * */ OmTransFunc * free_OmTransFunc(OmTransFunc * obj); /* Function: add_OneModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * Arg: add [OWNER] Object to add to the list [OmTrans *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_OneModel(OneModel * obj,OmTrans * add); /* Function: flush_OneModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_OneModel(OneModel * obj); /* Function: add_st_OneModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * Arg: add [OWNER] Object to add to the list [OmState *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_st_OneModel(OneModel * obj,OmState * add); /* Function: flush_st_OneModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_st_OneModel(OneModel * obj); /* Function: add_tf_OneModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * Arg: add [OWNER] Object to add to the list [OmTransFunc *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_tf_OneModel(OneModel * obj,OmTransFunc * add); /* Function: flush_tf_OneModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [OneModel *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_tf_OneModel(OneModel * obj); /* Function: OneModel_alloc_std(void) * * Descrip: Equivalent to OneModel_alloc_len(OneModelLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [OneModel *] * */ OneModel * OneModel_alloc_std(void); /* Function: OneModel_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [OneModel *] * */ OneModel * OneModel_alloc_len(int len); /* Function: hard_link_OneModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [OneModel *] * * Return [UNKN ] Undocumented return value [OneModel *] * */ OneModel * hard_link_OneModel(OneModel * obj); /* Function: OneModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [OneModel *] * */ OneModel * OneModel_alloc(void); /* Function: free_OneModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [OneModel *] * * Return [UNKN ] Undocumented return value [OneModel *] * */ OneModel * free_OneModel(OneModel * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ OneModel * OneModel_from_GenericMatrix(GenericMatrix * gm,MethodTypeSet * mts); OmTrans * OmTrans_from_CellSource(int base_point,CellSource * s,MethodTypeSet * mts,Scope * sc); OmState * OmState_from_CellState(CellState * cs); void set_CugenYaccReturn(CugenYaccReturn * ret); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void swap_OneModel(OmTrans ** list,int i,int j) ; void qsort_OneModel(OmTrans ** list,int left,int right,int (*comp)(OmTrans * ,OmTrans * )); void sort_OneModel(OneModel * obj,int (*comp)(OmTrans *, OmTrans *)); boolean expand_OneModel(OneModel * obj,int len); void swap_st_OneModel(OmState ** list,int i,int j) ; void qsort_st_OneModel(OmState ** list,int left,int right,int (*comp)(OmState * ,OmState * )); void sort_st_OneModel(OneModel * obj,int (*comp)(OmState *, OmState *)); boolean expand_st_OneModel(OneModel * obj,int len); void swap_tf_OneModel(OmTransFunc ** list,int i,int j) ; void qsort_tf_OneModel(OmTransFunc ** list,int left,int right,int (*comp)(OmTransFunc * ,OmTransFunc * )); void sort_tf_OneModel(OneModel * obj,int (*comp)(OmTransFunc *, OmTransFunc *)); boolean expand_tf_OneModel(OneModel * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/dynadebug.dy0000644000175000001440000002104207415352650015725 0ustar philippusers %{ #include "dyna2.h" #include "dynafunc.h" #include "dpimpl.h" #define ExprSetLISTLENGTH 50 %} struct ExprSet ExprTree ** expr !list %{ #include "dynadebug.h" void write_debug_funcs(DYNFILE * dfp,GenericMatrix * gm) { explicit_debug_func(dfp,gm); transition_debug_func(dfp,gm); make_debug_struct_func(dfp,gm); state_debug_func(dfp,gm); } ExprSet * build_ExprSet(ExprTree * root) { ExprSet * out; assert(root); assert(root->type == ETR_STATEMENT); assert(root->child[0]); out = ExprSet_alloc_std(); /* deal with simple cases: number,tag, method */ if( root->child[0]->type != ETR_EXPRESSION ) { /* only one child */ add_ExprSet(out,hard_link_ExprTree(root->child[0])); } else { if( descend_ExprTree_for_ExprSet(out,root->child[0]) == FALSE ) { free_ExprSet(out); return NULL; } } return out; } boolean descend_ExprTree_for_ExprSet(ExprSet * set,ExprTree * t) { boolean ret = TRUE; assert(set); assert(t); if( t->type != ETR_EXPRESSION ) { warn("In descending ExprTree for making an ExprSet, failed!"); return FALSE; } if( t->child[0]->type == ETR_EXPRESSION ) { if( descend_ExprTree_for_ExprSet(set,t->child[0]) == FALSE ) { ret = FALSE; } } else { add_ExprSet(set,hard_link_ExprTree(t->child[0])); } if( t->child[2]->type == ETR_EXPRESSION ) { if( descend_ExprTree_for_ExprSet(set,t->child[2]) == FALSE ) { ret = FALSE; } } else { add_ExprSet(set,hard_link_ExprTree(t->child[2])); } return ret; } void make_debug_struct_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; int k,l,m; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"create_debug_%s",gm->name); start_function_FuncInfo(fi,dfp,"DebugMatrix * create_debug_%s(void)",gm->name); expr(dfp,"DebugMatrix * out;"); expr(dfp,"DebugState * st;"); expr(dfp,"DebugTransition * tr;"); add_break(dfp); expr(dfp,"out = std_DebugMatrix();"); expr(dfp,"out->show_cell = cell_debug_%s;",gm->name); add_break(dfp); for(k=0;klen;k++) { expr(dfp,"st = DebugState_alloc_std();"); expr(dfp,"st->statename = \"%s\";",gm->state[k]->name); expr(dfp,"st->state_num = %d",k); expr(dfp,"st->show_state = state_debug_%s_%s;",gm->name,gm->state[k]->name); expr(dfp,"add_DebugMatrix(out,st);"); for(l=0;lstate[k]->len;l++) { expr(dfp,"tr = DebugTransition_alloc();"); expr(dfp,"tr->fromstate = \"%s\";",gm->state[k]->source[l]->state_source); expr(dfp,"tr->from_state_num = %d;",gm->state[k]->source[l]->from_state_no); expr(dfp,"tr->show_transition = transition_debug_%s_%s_%s_%d_%d;",gm->name,gm->state[k]->name,gm->state[k]->source[l]->state_source,gm->state[k]->source[l]->offi,gm->state[k]->source[l]->offj); expr(dfp,"add_DebugState(st,tr);"); } } expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } void state_debug_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; int k,l; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"cell_debug_%s",gm->name); start_function_FuncInfo(fi,dfp,"void cell_debug_%s(void * matrixpoi,int i,int j,FILE * ofp)",gm->name); expr(dfp,"%s * mat",gm->name); add_break(dfp); expr(dfp,"mat = (%s *) matrixpoi;",gm->name); add_break(dfp); for(k=0;klen;k++) { expr(dfp,"fprintf(ofp,\"State %9s %%d\\n\",%s_EXPL_MATRIX(mat,i,j,%s));",gm->state[k]->name,gm->name,gm->state[k]->name); } close_function(dfp); add_break(dfp); for(k=0;klen;k++) { fi = FuncInfo_named_from_varstr(FI_INTERNAL,"state_debug_%s_%s",gm->name,gm->state[k]->name); start_function_FuncInfo(fi,dfp,"void state_debug_%s_%s(void * matrixpoi,int i,int j,FILE * ofp)",gm->name,gm->state[k]->name); expr(dfp,"%s * mat",gm->name); add_break(dfp); expr(dfp,"mat = (%s *) matrixpoi;",gm->name); add_break(dfp); expr(dfp,"fprintf(ofp,\"State %s Score %%d\\n\",%s_EXPL_MATRIX(mat,i,j,%s));",gm->state[k]->name,gm->name,gm->state[k]->name); for(l=0;lstate[k]->len;l++) { auto CellSource * source; source = gm->state[k]->source[l]; expr(dfp,"fprintf(ofp,\" From %8s Matrix %%5d Score %%d\\n\",%s_EXPL_%s(mat,i-%d,j-%d,%s),%s);",source->state_source,gm->name,source->isspecial == TRUE ? "SPECIAL" : "MATRIX",source->offi,source->offj,source->state_source,source->calc_expr); } close_function(dfp); add_break; } } void transition_debug_func(DYNFILE * dfp,GenericMatrix * gm) { int k,l,m; FuncInfo * fi; ExprSet * set; char buffer[512]; assert(dfp); assert(gm); for(k=0;klen;k++) { for(l=0;lstate[k]->len;l++) { auto CellSource * source; source = gm->state[k]->source[l]; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"transition_debug_%s_%s_%s_%d_%d",gm->name,gm->state[k]->name,source->state_source,source->offi,source->offj); start_function_FuncInfo(fi,dfp,"void transition_debug_%s_%s_%s_%d_%d(void * matrixpoi,int i,int j,FILE * ofp)",gm->name,gm->state[k]->name,source->state_source,source->offi,source->offj); expr(dfp,"%s * mat;",gm->name); add_break(dfp); expr(dfp,"mat = (%s *) matrixpoi;",gm->name); add_break(dfp); set = build_ExprSet(source->etr); for(m=0;mlen;m++) { buffer[0] = '\0'; strcat_ExprTree_Scoped(set->expr[m],buffer,gm->sc,gm->mts,NULL,NULL,NULL); expr(dfp,"fprintf(ofp,\"%s : %%d\\n\",%s);",buffer,buffer); } free_ExprSet(set); close_function(dfp); add_break(dfp); } } } void explicit_debug_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; ArgInfo * ai; char * arg_str; char * chainstr; int k,l; /*** prepare function information ***/ fi = FuncInfo_named_from_varstr(FI_CALLABLE,"explicit_debug_%s",gm->name); add_line_to_Ftext(fi->ft,"This function provides debugging support",gm->name); add_line_to_Ftext(fi->ft,"for the dynamic programming models"); add_break_to_Ftext(fi->ft); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); ai->desc=stringallocf("%s which contains explicit basematrix memory",gm->name); start_function_FuncInfo(fi,dfp,"boolean explicit_debug_%s(DebugMatrix * de,boolean do_one_cell)",gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int num;"); expr(dfp,"%s * mat;",gm->name); add_break(dfp); expr(dfp,"mat = (%s *) de->matrix;",gm->name); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT )"); startbrace(dfp); warn_expr(dfp,"in explicit_debug_%s, passed a non Explicit matrix type, cannot calculate!",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); expr(dfp,"leni = mat->leni;"); expr(dfp,"lenj = mat->lenj;"); /*** see if there any specials to specials to do ***/ add_break(dfp); add_block_comment(dfp,"Enter debug matrix before matrix, reset"); expr(dfp,"user_DebugMatrix(de);"); add_break(dfp); expr(dfp,"if( de->reset == FALSE)"); startbrace(dfp); expr(dfp,"de->currenti = de->currentj = 0;"); closebrace(dfp); expr(dfp,"for(j=de->currentj;jcurrenti;ireset == TRUE )"); startbrace(dfp); expr(dfp,"i = de->currenti;"); expr(dfp,"j = de->currentj;"); expr(dfp,"continue;"); closebrace(dfp); closebrace(dfp); write_score_block(dfp,gm,"EXPL_MATRIX","mat","EXPL_SPECIAL",TRUE); add_break(dfp); add_block_comment(dfp,"Now update DebugMatrix datastructure."); add_break(dfp); for(k=0;klen;k++) { expr(dfp,"if( %s_EXPL_MATRIX(mat,i,j,%s) > de->max_score )",gm->name,gm->state[k]->name); startbrace(dfp); expr(dfp,"de->max_score = %s_EXPL_MATRIX(mat,i,j,%s);",gm->name,gm->state[k]->name); expr(dfp,"de->max_score_i = i;"); expr(dfp,"de->max_score_j = j;"); expr(dfp,"de->max_score_cell = %s;",gm->state[k]->name); closebrace(dfp); add_break(dfp); } expr(dfp,"de->currenti = i;"); expr(dfp,"de->currentj = j;"); add_break(dfp); closebrace(dfp); write_special_block(dfp,gm,"EXPL_MATRIX","EXPL_SPECIAL",NULL); add_block_comment(dfp,"Update currenti"); expr(dfp,"de->currenti = 0;"); add_break(dfp); closebrace(dfp); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } %} wise-2.4.1/src/dyc/dyna2.c0000644000175000001440000032174710670453715014626 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dyna2.h" /*********************************/ /* Access and checking functions */ /*********************************/ # line 147 "dyna2.dy" CellSignatureSet * CellSignatureSet_from_GenericMatrix(GenericMatrix * gm) { int i; int j; int k; CellSignatureSet * out; CellSignature * sig; out = CellSignatureSet_alloc_std(); for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { for(k=0;klen;k++) { if( gm->state[i]->source[j]->offi == out->sig[k]->offi && gm->state[i]->source[j]->offj == out->sig[k]->offj) { break; } } if( k >= out->len ) { /* new */ sig = CellSignature_alloc(); sig->offi = gm->state[i]->source[j]->offi; sig->offj = gm->state[i]->source[j]->offj; add_CellSignatureSet(out,sig); } } } return out; } # line 179 "dyna2.dy" boolean can_do_threads(GenericMatrix * gm) { if( gm->qtype != NULL ) { if( gm->qtype->is_thread_safe == FALSE ) return FALSE; } if( gm->ttype != NULL ) { if( gm->ttype->is_thread_safe == FALSE ) return FALSE; } return TRUE; } # line 195 "dyna2.dy" CellState * CellState_from_str(GenericMatrix * gm,char * str) { register int i; for(i=0;ilen;i++) if( strcmp(gm->state[i]->name,str) == 0) return gm->state[i]; for(i=0;ispec_len;i++) if( strcmp(gm->special[i]->name,str) == 0) return gm->special[i]; return NULL; } /* Function: prepare_matrix(gm,mts,dycw,failing_errors) * * Descrip: main function to check GenericMatrix onced parsed * * checks * state defaults * state/source cross references * labels * calc epxressions * types and type migration * calc parsing * * * Arg: gm [RW ] GenericMatrix to be checked [GenericMatrix *] * Arg: mts [READ ] Type and Method Scope [MethodTypeSet *] * Arg: dycw [UNKN ] Undocumented argument [DycWarning *] * Arg: failing_errors [READ ] Calc line parser on which errors fail [ParseError] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 228 "dyna2.dy" boolean prepare_matrix(GenericMatrix * gm,MethodTypeSet * mts,DycWarning * dycw,ParseError failing_errors) { boolean ret = TRUE; ParseError pe; push_errormsg_stack("In preparing matrix %s",gm->name); (void) calc_footprint(gm); /* this must happen first */ if( cross_reference_state_and_source(gm) == FALSE ) { warn("Unable to cross reference state and source"); ret = FALSE; } /* now this to provide score setting */ if( check_start_end(gm) == FALSE ) { warn("Start/End points are faulty"); ret = FALSE; } /* set global score */ gm->defscore_all_states = stringalloc("NEGI"); if( perculate_state_defaults(gm) == FALSE ) { warn("Unable to perculate state defaults"); ret = FALSE; } if( assign_source_no(gm) == FALSE ) { warn("Weird! unable to assign source numbers!"); ret = FALSE; } if( prepare_labels(gm) == FALSE ) { warn("Unable to prepare labels"); ret = FALSE; } if( handle_names(gm) == FALSE ) { warn("Unable to handle all the resource/query/target objects"); ret = FALSE; } if( check_source_positions(gm) == FALSE ) { warn("Unable to resolve positions"); ret = FALSE; } if( calc_window(gm) == FALSE ) { warn("Unable to calculate window"); ret = FALSE; } if( check_cell_refs(gm) == FALSE ) { warn("Unable to resolve all the cell offset refs into correct offsets"); ret = FALSE; } if( make_StructHolder_for_GenericMatrix(gm,mts) == FALSE ) { warn("Unable to build structure holder for GenericMatrix"); ret = FALSE; } if( ret == FALSE ) { warn("Failing simple cross-checks, aborting before calc-line parsing"); pop_errormsg_stack(); return FALSE; } pe = parse_calc_line_GenericMatrix(gm,mts,dycw); if( pe & failing_errors ) { warn("Failed to parse calc lines"); fprintf(stderr,"\nThe following parser errors were considered fatal:\n"); complain_ParseError_to_file(pe & failing_errors,stderr); if( (pe & (~failing_errors)) != 0 ) { fprintf(stderr,"\nThe following parser errors are only warnings:\n"); complain_ParseError_to_file(pe & (~failing_errors),stderr); } fprintf(stderr,"\n"); ret = FALSE; } gm->mts = hard_link_MethodTypeSet(mts); /*** Very hacky to conform to old gm code: type migration moves logical types to real. This is ok for now, but it does mean that in the function writing code we have lost the logical type information. So... probably should have the mts in the middle of function code. ***/ if( ret == TRUE ) handle_type_migration(gm,mts); pop_errormsg_stack(); return ret; } /* Function: assign_source_no(gm) * * Descrip: Adds a unique transition number for CellSource * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 346 "dyna2.dy" boolean assign_source_no(GenericMatrix * gm) { int i,j; int no = 0; for(i=0;ilen;i++) for(j=0;jstate[i]->len;j++) gm->state[i]->source[j]->trans_no = no++; for(i=0;ispec_len;i++) for(j=0;jspecial[i]->len;j++) gm->special[i]->source[j]->trans_no = no++; return TRUE; } /* Function: add_GenericMatrix_Scope(sc,gm) * * Descrip: Adds the current generic matrix variables to the scope with * "mat->" as scope resolver * * * Arg: sc [UNKN ] Undocumented argument [Scope *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ # line 367 "dyna2.dy" void add_GenericMatrix_Scope(Scope * sc,GenericMatrix * gm) { int i; ScopeUnit * su; su = ScopeUnit_from_nat(NULL,"i","","int"); su->no_accept = stringalloc(gm->target->name); add_Scope(sc,su); su = ScopeUnit_from_nat(NULL,"j","","int"); su->no_accept = stringalloc(gm->query->name); add_Scope(sc,su); su = ScopeUnit_from_nat(NULL,"mat","","*Matrix*"); add_Scope(sc,su); su = ScopeUnit_from_nat(NULL,gm->query->name,"mat->",gm->query->element_type); su->no_accept = stringalloc("j"); add_Scope(sc,su); su = ScopeUnit_from_nat(NULL,gm->target->name,"mat->",gm->target->element_type); su->no_accept = stringalloc("i"); add_Scope(sc,su); for(i=0;ires_len;i++) { su = ScopeUnit_from_nat(NULL,gm->resource[i]->name,"mat->",gm->resource[i]->element_type); add_Scope(sc,su); } for(i=0;iev_len;i++) { su = ScopeUnit_from_nat(NULL,gm->ev[i]->name,"",gm->ev[i]->type); add_Scope(sc,su); } } /* Function: parse_calc_line_GenericMatrix(gm,mts,dycw) * * Descrip: Function which actually does the loop over calc lines. * Importantly calls /allocd_calc_line from type.dy for * the main parsing * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * Arg: dycw [UNKN ] Undocumented argument [DycWarning *] * * Return [UNKN ] Undocumented return value [ParseError] * */ # line 410 "dyna2.dy" ParseError parse_calc_line_GenericMatrix(GenericMatrix * gm,MethodTypeSet * mts,DycWarning * dycw) { ParseError pe = 0; char * temp; int i; int j; Scope * sc; ExprTree * expr; sc = std_Dynamite_Scope(); add_GenericMatrix_Scope(sc,gm); gm->sc = sc; for(i=0;ilen;i++) { if( gm->state[i]->calc_expr != NULL ) { push_errormsg_stack("In parsing calc line for state [%s] (source ind.)",gm->state[i]->name); temp = allocd_calc_line(gm->state[i]->calc_expr,sc,mts,dycw,&pe,&expr); if( temp == NULL ) { temp = stringalloc(gm->state[i]->calc_expr); } gm->state[i]->source_expr = gm->state[i]->calc_expr; gm->state[i]->calc_expr = temp; gm->state[i]->etr = expr; pop_errormsg_stack(); } for(j=0;jstate[i]->len;j++) { push_errormsg_stack("In parsing calc line for state [%s] source [%s]",gm->state[i]->name,gm->state[i]->source[j]->state_source); temp = allocd_calc_line(gm->state[i]->source[j]->calc_expr,sc,mts,dycw,&pe,&expr); if( temp == NULL ) { temp = stringalloc(gm->state[i]->source[j]->calc_expr); } gm->state[i]->source[j]->source_expr = gm->state[i]->source[j]->calc_expr; gm->state[i]->source[j]->calc_expr = temp; gm->state[i]->source[j]->etr = expr; pop_errormsg_stack(); } } for(i=0;ispec_len;i++) { if( gm->special[i]->calc_expr != NULL ) { push_errormsg_stack("In parsing calc line for state [%s] (source ind.)",gm->special[i]->name); temp = allocd_calc_line(gm->special[i]->calc_expr,sc,mts,dycw,&pe,&expr); if( temp == NULL ) { temp = stringalloc(gm->special[i]->calc_expr); } gm->special[i]->source_expr = gm->special[i]->calc_expr; gm->special[i]->calc_expr = temp; gm->special[i]->etr = expr; pop_errormsg_stack(); } for(j=0;jspecial[i]->len;j++) { push_errormsg_stack("In parsing calc line for state [%s] source [%s]",gm->special[i]->name,gm->special[i]->source[j]->state_source); temp = allocd_calc_line(gm->special[i]->source[j]->calc_expr,sc,mts,dycw,&pe,&expr); if( temp == NULL ) { temp = stringalloc(gm->special[i]->source[j]->calc_expr); } gm->special[i]->source[j]->source_expr = gm->special[i]->source[j]->calc_expr; gm->special[i]->source[j]->calc_expr = temp; gm->special[i]->source[j]->etr = expr; pop_errormsg_stack(); } } return pe; } /* Function: calc_window(gm) * * Descrip: calculates window_i and window_j * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 497 "dyna2.dy" boolean calc_window(GenericMatrix * gm) { register int i; register int j; int ilen = 0; int jlen = 0; for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; for(j=0;jlen;j++) { if( state->source[j]->offi > ilen ) ilen = state->source[j]->offi; if( state->source[j]->offj > jlen ) jlen = state->source[j]->offj; } } gm->window_i = ilen; gm->window_j = jlen; return TRUE; } /* Function: check_start_end(gm) * * Descrip: checks we have a start + end (and only 1 each!) * and sets start's defscore to 0 * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 529 "dyna2.dy" boolean check_start_end(GenericMatrix * gm) { int i; int j; boolean ret = TRUE; for(i=0;ispec_len;i++) { if( gm->special[i]->is_end == TRUE ) { if( gm->special[i]->is_start == TRUE ) { warn("Trying to make state %s both the start and the end!",gm->special[i]->name); ret = FALSE; } break; } } if( i == gm->spec_len ) { for(i=0;ispec_len;i++) { if( strcmp(gm->special[i]->name,"END") == 0 ) { warn("You have not got a !end special, but you do have a END special state. Presuming that you wanted to make that the END ;)"); gm->special[i]->is_end = TRUE; break; } } if( i == gm->spec_len) { warn("You have no end special state. Impossible matrix"); ret = FALSE; } } else { /*** check there are no more end states ***/ for(j=i+1;jspec_len;j++) { if( gm->special[j]->is_end == TRUE ) { warn("Special state %s is also end (as well as %s)",gm->special[j]->name,gm->special[i]->name); } } } /*** end of else ***/ /*** done end, do start ***/ for(i=0;ispec_len;i++) { if( gm->special[i]->is_start == TRUE ) { if( gm->special[i]->is_end == TRUE ) { warn("Trying to make state %s both the start and the end!",gm->special[i]->name); ret = FALSE; } break; } } if( i == gm->spec_len ) { for(i=0;ispec_len;i++) { if( strcmp(gm->special[i]->name,"START") == 0 ) { warn("You have not got a !start special, but you do have a START special state. Presuming that you wanted to make that the START ;)"); gm->special[i]->is_start = TRUE; break; } } if( i == gm->spec_len) { warn("You have no start special state. Impossible matrix"); ret = FALSE; } } else { /*** check there are no more start states ***/ for(j=i+1;jspec_len;j++) { if( gm->special[j]->is_start == TRUE ) { warn("Special state %s is also start (as well as %s)",gm->special[j]->name,gm->special[i]->name); } } /*** set score for start = 0 **/ gm->special[i]->def_score = stringalloc("0"); } /*** end of else ***/ return ret; } /* Function: check_source_positions(gm) * * Descrip: checks the top/bottom/left/right source * positions * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 613 "dyna2.dy" boolean check_source_positions(GenericMatrix * gm) { int i; int j; boolean ret = TRUE; for(i=0;ilen;i++){ auto CellState * s; s = gm->state[i]; for(j=0;jlen;j++) { if( j == 0 && s->source[0]->isspecial == TRUE ) { warn("For [%s] source [%s] your first transition is from a special. This is not allowed currently to make code generation easier. There must be a non-special transition to place here. could you rearrange your dy file?",s->name,s->source[0]->state_source); ret = FALSE; } if( s->source[j]->position < 16 ) { ret = FALSE; warn("For [%s] source [%s] you have an impossible position vector (top/left/bottom/right 1/2/4/8) %d",s->name,s->source[j]->state_source,s->source[j]->position); } else { if( s->source[j]->position == SOURCE_POS_ALL ) continue; /* fine */ if( s->source[j]->isspecial == FALSE ) { warn("For [%s] source [%s] you have indicated an edge to calculate on, but it is a non special source",s->name,s->source[j]->state_source); ret = FALSE; } else if( s->source[j]->position != SOURCE_POS_TOPLEFT && s->source[j]->position != SOURCE_POS_TOPLEFT ) { /*** allow? ***/ /* warn("Really sorry, you have a lone top bottem left or right source which is not yet implemented. talk to Ewan for a work around"); ret = FALSE; */ } } } } for(i=0;ispec_len;i++){ auto CellState * s; s = gm->special[i]; for(j=0;jlen;j++) { if( s->source[j]->position < 16 ) { ret = FALSE; warn("For [%s] source [%s] you have an impossible position vector (top/left/bottom/right 1/2/4/8) %d",s->name,s->source[j]->state_source,s->source[j]->position); } else { if( s->source[j]->position == SOURCE_POS_ALL ) continue; /* fine */ else if( (s->source[j]->position == SOURCE_POS_TOPLEFT || s->source[j]->position == SOURCE_POS_TOP || s->source[j]->position == SOURCE_POS_BOTTOM || s->source[j]->position == SOURCE_POS_BOTTOMRIGHT) && s->source[j]->isspecial == TRUE) { warn("State [%s] source [%s] has top/bottom tags - but it is a special to special. Surely you only mean left (no top/bottom concept to specials)",s->name,s->source[j]->state_source); ret = FALSE; } } } } return ret; } /* Function: calc_footprint(gm) * * Descrip: calculates footprint * * now useless * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 680 "dyna2.dy" boolean calc_footprint(GenericMatrix * gm) { register int i; register int foot = 1; for(i=0;ilen;i++) if( gm->state[i]->footprint_end > foot ) foot = gm->state[i]->footprint_end; gm->footprint = foot; return TRUE; } /* Function: cross_reference_state_and_source(gm) * * Descrip: makes sure each source has a state * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 698 "dyna2.dy" boolean cross_reference_state_and_source(GenericMatrix * gm) { register int i; register int j; for(i=0;ilen;i++) { gm->state[i]->state_number = i; } j = gm->len; for(i=0;ispec_len;i++) { gm->special[i]->state_number = i+j; } for(i=0;ilen;i++) { auto CellState * state; auto CellState * temp; state = gm->state[i]; for(j=0;jlen;j++) { if( (temp=CellState_from_str(gm,state->source[j]->state_source)) == NULL){ warn("In matrix %s - State %s asks for source %s but there is no State of that name",gm->name,state->name,state->source[j]->state_source); return FALSE; } if( temp->is_special_i == TRUE || temp->is_special_j == TRUE) state->source[j]->isspecial = TRUE; state->source[j]->from_state_no = temp->state_number; } } for(i=0;ispec_len;i++) { auto CellState * state; auto CellState * temp; state = gm->special[i]; for(j=0;jlen;j++) { if( (temp=CellState_from_str(gm,state->source[j]->state_source)) == NULL) { warn("In matrix %s - State %s asks for source %s but there is no State of that name",gm->name,state->name,state->source[j]->state_source); return FALSE; } if( temp->is_special_i == TRUE || temp->is_special_j == TRUE) { state->source[j]->isspecial = TRUE; state->specialtospecial = TRUE; gm->specialtospecial = TRUE; } } } return TRUE; } # line 750 "dyna2.dy" boolean check_cell_refs(GenericMatrix * gm) { boolean ret = TRUE; register int i; register int j; for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { if( gm->state[i]->source[j]->offi == 0 && gm->state[i]->source[j]->offj == 0 ) { warn("In state %s (source %s), both offi and offj are zero: dynamite cannot currently handle cell internal references",gm->state[i]->name,gm->state[i]->source[j]->state_source); ret = FALSE; } if( gm->state[i]->source[j]->offi < 0 || gm->state[i]->source[j]->offj < 0 ) { warn("In state %s, offi,offj [%d][%d] has some negative indices: offi and offj are always positive, probably you should just strip off the negative signs",gm->state[i]->name,gm->state[i]->source[j]->offi,gm->state[i]->source[j]->offj); ret = FALSE; } } } for(i=0;ispec_len;i++) { for(j=0;jspecial[i]->len;j++) { if( gm->special[i]->source[j]->isspecial == TRUE ) { if( gm->special[i]->source[j]->offj == 0 ) { warn("In special state %s, source %s (also special) got a offj of zero, an impossible reference",gm->special[i]->name,gm->special[i]->source[j]->state_source); ret = FALSE; } } else { if( gm->special[i]->source[j]->offj != 0 ) { warn("In special state %s, source %s (a main matrix cell) got an offset of non zero (%d). This cannot be modelled at the moment",gm->special[i]->name,gm->special[i]->source[j]->state_source, gm->special[i]->source[j]->offj); ret = FALSE; } } if( gm->special[i]->source[j]->offj < 0 ) { warn("In special state %s, source %s, offj is %d (Negative!), and you can't have negative offsets", gm->special[i]->name,gm->special[i]->source[j]->state_source); ret = FALSE; } } } return ret; } # line 795 "dyna2.dy" boolean prepare_labels(GenericMatrix * gm) { boolean all_labelled = TRUE; boolean ret = TRUE; register int i; register int j; for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; for(j=0;jlen;j++) { if( state->source[j]->query_label == NULL ) { warn("For state %s, source %s, missing a query_label",state->name,state->source[j]->state_source); ret = FALSE; } if( state->source[j]->target_label == NULL ) { warn("For state %s, source %s, missing a target_label",state->name,state->source[j]->state_source); ret = FALSE; } } } for(i=0;ispec_len;i++) { auto CellState * state; state = gm->special[i]; for(j=0;jlen;j++) { if( state->source[j]->query_label == NULL ) { warn("For state %s, source %s, missing a query_label",state->name,state->source[j]->state_source); ret = FALSE; } if( state->source[j]->target_label == NULL ) { warn("For state %s, source %s, missing a target_label",state->name,state->source[j]->state_source); ret = FALSE; } } } gm->canlabel = all_labelled; return ret; } # line 837 "dyna2.dy" boolean handle_names(GenericMatrix * gm) { boolean ret = TRUE; register int i; if( gm->query->name == NULL ) { warn("Your query [type %s] had no name: calling it 'query'",CKS(gm->query->element_type)); gm->query->name = stringalloc("query"); } if( gm->target->name == NULL ) { warn("Your target [type %s] had no name: calling it 'target'",CKS(gm->target->element_type)); gm->target->name = stringalloc("target"); } for(i=0;ires_len;i++) { if( gm->resource[i]->name == NULL ) { warn("Resource number %d had no name... cannot process",i); ret = FALSE; } if( gm->resource[i]->element_type == NULL ) { warn("Resource number %d had no type... cannot process",i); ret = FALSE; } } return ret; } # line 869 "dyna2.dy" boolean handle_type_migration(GenericMatrix * gm,MethodTypeSet * mts) { register int i; Type * t; if( gm->query_len == NULL ) { gm->query_len = length_string_from_GenericMatrix_type(gm->query->element_type); } if( gm->target_len == NULL ) { gm->target_len = length_string_from_GenericMatrix_type(gm->target->element_type); } if( (t = Type_from_name(mts,gm->query->element_type)) != NULL) { ckfree(gm->query->element_type); gm->query->element_type = stringalloc(t->real); gm->qtype = t; } if( (t = Type_from_name(mts,gm->target->element_type)) != NULL) { ckfree(gm->target->element_type); gm->target->element_type = stringalloc(t->real); gm->ttype = t; } for(i=0;ires_len;i++) { if( (t = Type_from_name(mts,gm->resource[i]->element_type)) != NULL) { ckfree(gm->resource[i]->element_type); gm->resource[i]->element_type = stringalloc(t->real); } } return TRUE; } # line 905 "dyna2.dy" boolean perculate_state_defaults(GenericMatrix * gm) { register int i; register int j; boolean ret = TRUE; for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; if( state->def_score == NULL) { if( gm->defscore_all_states == NULL ) { warn("State %s has no specific default score and you have not specified a global default score",state->name); ret = FALSE; } state->def_score = stringalloc( gm->defscore_all_states); } for(j=0;jlen;j++) { if( state->source[j]->offi == -1 ) state->source[j]->offi = state->offi; if( state->source[j]->offj == -1 ) state->source[j]->offj = state->offj; /*** now do labels ***/ if( state->source[j]->query_label == NULL && state->query_label != NULL ) state->source[j]->query_label = stringalloc(state->query_label); if( state->source[j]->target_label == NULL && state->target_label != NULL ) state->source[j]->target_label = stringalloc(state->target_label); } } for(i=0;ispec_len;i++) { auto CellState * state; state = gm->special[i]; gm->special[i]->is_special_i = TRUE; if( state->def_score == NULL) { if( gm->defscore_all_states == NULL ) { warn("State %s has no specific default score and you have not specified a global default score",state->name); ret = FALSE; } state->def_score = stringalloc( gm->defscore_all_states); } for(j=0;jlen;j++) { if( state->source[j]->offi == -1 ) state->source[j]->offi = state->offi; if( state->source[j]->offj == -1 ) state->source[j]->offj = state->offj; /*** now do labels ***/ if( state->source[j]->query_label == NULL && state->query_label != NULL ) state->source[j]->query_label = stringalloc(state->query_label); if( state->source[j]->target_label == NULL && state->target_label != NULL ) state->source[j]->target_label = stringalloc(state->target_label); } } return ret; } # line 976 "dyna2.dy" boolean make_StructHolder_for_GenericMatrix(GenericMatrix * gm,MethodTypeSet * mts) { StructHolder * out; StructElement * temp; register int i; out = StructHolder_alloc_std(); if( out == NULL ) { warn("Unable to build generic matrix %s's structure",gm->name); return FALSE; } out->name = stringalloc(gm->name); temp = basic_add_StructElement(out,"basematrix","BaseMatrix *"); temp->def=stringalloc("NULL"); if( temp == NULL ) { warn("Serious problem - unable to add one of the structelements in make_StructHolder_for_GenericMatrix"); return FALSE; } temp = basic_add_StructElement(out,"shatter","ShatterMatrix *"); temp->def=stringalloc("NULL"); temp = basic_add_StructElement(out,"leni","int"); temp->def=stringalloc("0"); if( temp == NULL ) { warn("Serious problem - unable to add one of the structelements in make_StructHolder_for_GenericMatrix"); return FALSE; } temp = basic_add_StructElement(out,"lenj","int"); temp->def=stringalloc("0"); if( temp == NULL ) { warn("Serious problem - unable to add one of the structelements in make_StructHolder_for_GenericMatrix"); return FALSE; } /*** ok... this is now typed! ***/ temp = StructElement_from_MethodTypeSet(gm->query->name,gm->query->element_type,mts); add_StructHolder(out,temp); temp = StructElement_from_MethodTypeSet(gm->target->name,gm->target->element_type,mts); add_StructHolder(out,temp); for(i=0;ires_len;i++) { temp = StructElement_from_MethodTypeSet(gm->resource[i]->name,gm->resource[i]->element_type,mts); temp->isfunc = gm->resource[i]->isfunc; add_StructHolder(out,temp); } gm->sh = out; return TRUE; } # line 1039 "dyna2.dy" StructElement * StructElement_for_GenericMatrix_type(char * name,char * element) { StructElement * out; if( name == NULL || element == NULL ) { warn("In trying to make a struct element for GenericMatrix type, got some NULL fields... this is not good"); return NULL; } out = (StructElement *) ckalloc (sizeof(StructElement)); if( strcmp(element,"PROTEIN") == 0 || strcmp(element,"GENOMIC") == 0 || strcmp(element,"CDNA") == 0 ) { out->element_type = stringalloc("ComplexSequence *"); } else { out->element_type = stringalloc(element); } out->name = stringalloc(name); out->islinked = TRUE; return out; } # line 1065 "dyna2.dy" char * length_string_from_GenericMatrix_type(char * element) { if( strcmp(element,"PROTEIN") == 0 ) return stringalloc("seq->len"); if( strcmp(element,"GENOMIC") == 0 || strcmp(element,"CDNA") == 0 || strcmp(element,"DNA") == 0) return stringalloc("seq->len"); else { warn("Cannot automatically find length string for element type [%s] (perhaps it is not a logical type). You" " should have a field:len in this line if it is not a logical type. Assuming [len] anyway",element); return stringalloc("len"); } } # line 1079 "dyna2.dy" boolean can_interpret_type(char * type) { if( strcmp(type,"PROTEIN") == 0 || strcmp(type,"GENOMIC") == 0 || strcmp(type,"CDNA") == 0) return TRUE; return FALSE; } # line 1086 "dyna2.dy" char * interpret_type(char * type) { if( strcmp(type,"PROTEIN") == 0 || strcmp(type,"GENOMIC") == 0 || strcmp(type,"CDNA") == 0) return stringalloc("ComplexSequence *"); return NULL; } # line 1095 "dyna2.dy" CellState * start_CellState_from_GenericMatrix(GenericMatrix * gm) { register int i; for(i=0;ispec_len;i++) { if(gm->special[i]->is_start == TRUE ) return gm->special[i]; } return NULL; } # line 1107 "dyna2.dy" CellState * end_CellState_from_GenericMatrix(GenericMatrix * gm) { register int i; for(i=0;ispec_len;i++) { if(gm->special[i]->is_end == TRUE ) return gm->special[i]; } return NULL; } /***************************/ /* noddy display functions */ /***************************/ # line 1123 "dyna2.dy" void show_GenericMatrix(GenericMatrix * gm,char padchar,FILE * ofp) { register int i; fprintf(ofp,"Matrix: %s\n",gm->name); fprintf(ofp,"Query Type [%s] Name [%s]\n",gm->query->element_type,gm->query->name); fprintf(ofp,"Target Type [%s] Name [%s]\n",gm->target->element_type,gm->target->name); for(i=0;ires_len;i++) fprintf(ofp,"Resource Type[%s] Name [%s]\n",gm->resource[i]->element_type,gm->resource[i]->name); for(i=0;ilen;i++) show_CellState(gm->state[i],padchar,1,ofp); } # line 1141 "dyna2.dy" void show_CellState(CellState * cell,char padchar,int num,FILE * ofp) { register int i; fprintf(ofp,"\nFor state %s\n",cell->name); for(i=0;idef_score == NULL ? "ANY [NULL STRING]" : cell->def_score); for(i=0;icalc_expr)); for(i=0;ioffi); for(i=0;ioffj); for(i=0;ilen;i++) show_CellSource(cell->source[i],padchar,num+1,ofp); } # line 1166 "dyna2.dy" void show_CellSource(CellSource * cell,char padchar,int num,FILE * ofp) { register int i; for(i=0;istate_source == NULL ? "ANY [NULL STRING]" : cell->state_source); for(i=0;ioffi); for(i=0;ioffj); } /*********************/ /* Parsing functions */ /*********************/ # line 1189 "dyna2.dy" GenericMatrix * read_GenericMatrix(FILE * ifp) { char buffer[MAXLINE]; GenericMatrix * out = NULL; while( get_watched_line(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"matrix") == 0) { out = read_GenericMatrix_line(buffer,ifp); break; } } if( out == NULL ) warn("Unable to read GenericMatrix"); while( get_watched_line(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"%{") == 0) break; } return out; } # line 1216 "dyna2.dy" GenericMatrix * read_GenericMatrix_line(char * line,FILE * ifp) { GenericMatrix * out; ExternVariable * ev; CellState * temp; char buffer[MAXLINE]; char ** base; char ** splitstr; char * runner; StructElement * res_temp; boolean isspecial = FALSE; CollapsableLabel * cal; base=splitstr=breakstring(line,spacestr); if( strcmp(*splitstr,"matrix") != 0) { log_full_error(WARNING,0,"In parsing the line starting %s it had no matrix tag!",line); return NULL; } splitstr++; if( *splitstr == NULL ) { log_full_error(WARNING,0,"In parsing the first matrix line there was no matrix name: must have matrix ",line); return NULL; } out = GenericMatrix_alloc_std(); if( out == NULL ) return NULL; out->name = stringalloc(*splitstr); push_errormsg_stack("In reading matrix definition for %s",out->name); ckfree(base); while( get_watched_line(buffer,MAXLINE,ifp) != NULL) { chop_newline(buffer); if( strwhitestartcmp(buffer,"#",spacestr) == 0 ) continue; if( only_whitespace(buffer,spacestr) == TRUE) continue; if( strstartcmp(buffer,"endmatrix") == 0) break; if( strwhitestartcmp(buffer,"endmatrix",spacestr) == 0 ) { warn("endmatrix tag not flush to the start of the line. Ok, but not in the specification"); break; } if( strstartcmp(buffer,"end") == 0 ) { warn("got an 'end' tag [%s] but expecting a 'endmatrix'. Considering this a parse failure"); goto error; } /*** ok, proper parsing now ****/ if( strwhitestartcmp(buffer,"collapse",spacestr) == 0 ) { cal = read_CollapsableLabel_line(buffer); if( cal == NULL ) { warn("Cannot read Collapsable label line. Ignoring collapsed label"); continue; } add_cal_GenericMatrix(out,cal); continue; } else if( strwhitestartcmp(buffer,"extern",spacestr) == 0 ){ ev = read_ExternVariable_line(buffer); if( ev == NULL ) { warn("unable to read an Extern line"); } else add_ev_GenericMatrix(out,ev); continue; } else if( strwhitestartcmp(buffer,"state",spacestr) == 0) { if( strstr(buffer,"!special") != NULL ) isspecial = TRUE; else if ( strstr(buffer,"SPECIAL") != NULL ) { warn("In state [%s], got a SPECIAL tag. This has been replaced with !special for consistency. Please change ;)",buffer); isspecial = TRUE; } else isspecial = FALSE; /*********************************************/ /* this function actually reads in the state */ /* block */ /*********************************************/ temp = read_CellState_line(buffer,ifp); /* read in state */ if( temp == NULL ) { /* warning already issued, just chain */ /* warn("unable to read line for CellState in GenericMatrix %s - going to fail",out->name); */ goto error; } if( isspecial == FALSE) { if( add_GenericMatrix(out,temp) == FALSE ) { warn("Able to read - but unable to add - line for CellState in GeericMatrix %s - going to return now",out->name); goto error; } } else { if( add_spec_GenericMatrix(out,temp) == FALSE ) { warn("Able to read - but unable to add - line for CellState in GeericMatrix %s - going to return now",out->name); goto error; } } continue; /* should not chop up line! */ } /**** OK not a state line, hence a "processed" line ****/ /* split up line, look at first word, decide what to do */ /* - probably loop through the rest of the words to */ /* to read out - these are the for(splitstr++; etc loops*/ base=splitstr=breakstring(buffer,spacestr); /* NB, base free'd at the end of the if/else switch */ if( strwhitestartcmp(*splitstr,"query",spacestr) == 0) { if( out->query_name != NULL ) { log_full_error(WARNING,0,"This is the second time to specify a query - only one allowed: ignoring [%s]",buffer); continue; } /*** allocate's memory etc ready */ out->query = StructElement_alloc(); for(splitstr++;*splitstr;splitstr++) { if( (runner=string_from_quoted_equality(*splitstr)) == NULL ) { warn("You have specified a modifier [%s] to query but it has either no '=' sign or no quoted argument. The '=' character should be flush to both the tag and the quoted (using \") argument",CKS(*splitstr)); continue; } if( strstartcmp(*splitstr,"name") == 0 ) { out->query->name = runner; } else if ( strstartcmp(*splitstr,"field:name") == 0) { out->query_name = runner; } else if ( strstartcmp(*splitstr,"field:len") == 0) { out->query_len = runner; } else if ( strstartcmp(*splitstr,"type") == 0) { out->query->element_type = runner; } else { warn("Got modify %s=%s fine for tag query - but don't know what to do with it!",*splitstr,runner); ckfree(runner); } } /* end of query modifers */ } /* end of query if */ else if( strwhitestartcmp(*splitstr,"target",spacestr) == 0) { if( out->target_name != NULL ) { log_full_error(WARNING,0,"This is the second time to specify a target - only one allowed Ignoring [%s]",buffer); } /*** allocate's memory etc ready */ out->target = StructElement_alloc(); for(splitstr++;*splitstr;splitstr++) { if( (runner=string_from_quoted_equality(*splitstr)) == NULL ) { warn("You have specified a modifier [%s] to target but it has either no '=' sign or no quoted argument. The '=' character should be flush to both the tag and the quoted (using \") argument",CKS(*splitstr)); continue; } if( strstartcmp(*splitstr,"name") == 0 ) { out->target->name = runner; } else if ( strstartcmp(*splitstr,"field:name") == 0) { out->target_name = runner; } else if ( strstartcmp(*splitstr,"field:len") == 0) { out->target_len = runner; } else if ( strstartcmp(*splitstr,"type") == 0) { out->target->element_type = runner; } else { warn("Got modify %s=%s fine for tag target - but don't know what to do with it!",*splitstr,runner); ckfree(runner); } } /* end of target modifers */ } /* end of target if */ else if( strstartcmp(*splitstr,"resource") == 0) { /*** allocate's memory etc ready */ res_temp = StructElement_alloc(); add_res_GenericMatrix(out,res_temp); for(splitstr++;*splitstr;splitstr++) { if( (runner=string_from_quoted_equality(*splitstr)) == NULL ) { warn("You have specified a modifier [%s] to resource but it has either no '=' sign or no quoted argument. The '=' character should be flush to both the tag and the quoted (using \") argument",CKS(*splitstr)); continue; } if( strstartcmp(*splitstr,"name") == 0 ) { res_temp->name = runner; } else if ( strstartcmp(*splitstr,"type") == 0) { res_temp->element_type = runner; } else { warn("Got modifier %s=%s fine for tag resource - but don't know what to do with it!",*splitstr,runner); ckfree(runner); } } /* end of resource modifers */ } /* end of resource if */ else if( strstartcmp(*splitstr,"globaldefaultscore") == 0) { warn("No need for globaldefaultscore lines anymore"); } else if ( strstartcmp(*splitstr,"calcfunc") == 0) { if( *++splitstr == NULL ) { warn("Got a calcfunc tag with no function!"); } else { out->calcfunc = stringalloc(*splitstr); } } else { warn("Could not understand line in matrix parse"); } ckfree(base); } pop_errormsg_stack(); return out; error : pop_errormsg_stack(); out = free_GenericMatrix(out); return NULL; } /* Function: read_ExternVariable_line(line) * * Descrip: reads line like extern name="xxx" type="xxx" * * * Arg: line [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ExternVariable *] * */ # line 1481 "dyna2.dy" ExternVariable * read_ExternVariable_line(char * line) { ExternVariable * out; char ** base; char ** brk; char * nameq = NULL; char * tq = NULL; if( strwhitestartcmp(line,"extern",spacestr) != 0 ) { warn("Tried to pass read_ExternVariable_line without an extern tag. Nope!"); return NULL; } base = brk = breakstring(line,spacestr); for(;*brk != NULL;brk++) { if( strcmp(*brk,"extern") == 0 ) continue; if( strstartcmp(*brk,"name") == 0 ) { if( (nameq = string_from_quoted_equality(*brk)) == NULL) { warn("In reading extern line, got a name tag, but no argument. The tag should have no whitespace between aname and equals"); continue; } } else if ( strstartcmp(*brk,"type") == 0 ) { if( (tq = string_from_quoted_equality(*brk)) == NULL) { warn("In reading extern line, got a type tag, but no argument. The tag should have no whitespace between the type and ="); continue; } } else { warn("Did not understand tag [%s] in extern line",*brk); } } ckfree(base); out = ExternVariable_alloc(); out->name = nameq; out->type = tq; return out; } # line 1526 "dyna2.dy" CollapsableLabel * read_CollapsableLabel_line(char * line) { CollapsableLabel * out; char * runner; char * run2; if( strwhitestartcmp(line,"collapse",spacestr) != 0 ) { warn("Tried to pass read_CollapsableLabel_line a no collapse line. Problem!"); return NULL; } runner = strtok(line,spacestr); runner = strtok(NULL,spacestr); run2 = strtok(NULL,spacestr); if( runner == NULL || run2 == NULL) { warn("Collapsable line has no collapsable label. Ooops"); return NULL; } out = CollapsableLabel_alloc(); if( out == NULL) return NULL; out->query = stringalloc(runner); out->target = stringalloc(run2); return out; } # line 1557 "dyna2.dy" CellState * read_CellState_line(char * line,FILE * ifp) { CellState * out; CellSource * temp; char buffer[MAXLINE]; char ** base; char ** splitstr; char * runner; /*** allocate and die if no memory ***/ /*** warnings should be issued in ***/ /*** alloc ***/ /*** check state and name and Loop through the current line given ****/ base=splitstr=breakstring(line,spacestr); if( strcmp(*splitstr,"state") != 0) { log_full_error(WARNING,0,"In parsing the line starting %s it had no state tag!",line); return NULL; } splitstr++; if( *splitstr == NULL ) { log_full_error(WARNING,0,"In parsing the line source [%s] there was no state name",line); return NULL; } out = CellState_alloc_std(); if( out == NULL ) return NULL; out->name = stringalloc(*splitstr); push_errormsg_stack("In Reading state %s",out->name); /*** looping through first line ***/ for(splitstr++;*splitstr;splitstr++) { if( strstartcmp(*splitstr,"offi") == 0) { runner=string_from_quoted_equality(*splitstr); if( runner == NULL ) { warn("Unable to read offi in state %s. The tag should look like offi=\"\" with no whitespace",out->name); continue; } out->offi = atoi(runner); ckfree(runner); } else if ( strstartcmp(*splitstr,"offj") == 0) { runner=string_from_quoted_equality(*splitstr); if( runner == NULL ) { warn("Unable to read offj in state %s. The tag should look like offj=\"\" with no whitespace",out->name); continue; } out->offj = atoi(runner); ckfree(runner); } else if ( strstartcmp(*splitstr,"defscore") == 0) { warn("No need for defscore lines anymore"); } else if ( strstartcmp(*splitstr,"calc") == 0) { runner=string_from_quoted_equality(*splitstr); if( runner == NULL ) { warn("Unable to read source independent calc line in state %s. Remember that there should be no white space between calc and the \"string\", ie calc=\"gap\" ",out->name); continue; } out->calc_expr=runner; } else if ( strstartcmp(*splitstr,"!special") == 0) { out->is_special_i=TRUE; } else if ( strstartcmp(*splitstr,"SPECIAL") == 0) { out->is_special_i=TRUE; } else if ( strstartcmp(*splitstr,"!end") == 0) { out->is_end = TRUE; } else if ( strstartcmp(*splitstr,"!start") == 0) { out->is_start = TRUE; } else { warn("Parse error in state %s - cannot make sense of %s",out->name,*splitstr); } } ckfree(base); while( get_watched_line(buffer,MAXLINE,ifp) != NULL) { chop_newline(buffer); if( strwhitestartcmp(buffer,"#",spacestr) == 0 ) continue; if( strwhitestartcmp(buffer,"endstate",spacestr) == 0 ) break; if( only_whitespace(buffer,spacestr) == TRUE) continue; if( strwhitestartcmp(buffer,"end",spacestr) == 0 ) { warn("Got an end line [%s] but expecting endstate. Will fail.",buffer); goto error; } if( strwhitestartcmp(buffer,"state",spacestr) == 0 ) { warn("Got the line [%s], a state start line inside a state. Expect you forgot an endstate.",buffer); goto error; } if( strwhitestartcmp(buffer,"query_label",spacestr) == 0 ) { base = splitstr = breakstring(buffer,spacestr); splitstr++; if( *splitstr == NULL ) { warn("Picked up query_label tag but no query label in state %s",out->name); } else out->query_label = stringalloc(*splitstr); ckfree(base); continue; } if( strwhitestartcmp(buffer,"target_label",spacestr) == 0 ) { base = splitstr = breakstring(buffer,spacestr); splitstr++; if( *splitstr == NULL ) { warn("Picked up target_label tag but no target label in state %s",out->name); } else out->target_label = stringalloc(*splitstr); ckfree(base); continue; } if( strwhitestartcmp(buffer,"calc",spacestr) == 0 ) { base = splitstr = breakstring(buffer,spacestr); if( out->calc_expr != NULL ) { warn("Already picked up a calc line [%s]. Replacing with %s\n",out->calc_expr,runner); ckfree(out->calc_expr); } out->calc_expr = string_from_quoted_equality(*splitstr); ckfree(base); continue; } else if( strstr(buffer,"source") == NULL) { warn("Parse error in reading state %s - cannot interpret [%s]",out->name,buffer); continue; } temp = read_CellSource_line(buffer,ifp); /* fprintf(stderr,"Have read source line!\n"); */ if( temp == NULL ) { /* warning already issued, just chain back up */ /* warn("unable to read line for CellSource in CellState %s - going to fail parser",out->name); */ goto error; } if( add_CellState(out,temp) == FALSE ) { warn("Able to read - but unable to add - line for CellSource in CellState %s - going to return now",out->name); goto error; } } pop_errormsg_stack(); return out; error : pop_errormsg_stack(); out = free_CellState(out); return NULL; } # line 1747 "dyna2.dy" int source_bit2pos(int bit) { if( bit == 0 ) return SOURCE_POS_ALL; if( (bit & SOURCE_TOP_BIT) ) { if( (bit & SOURCE_LEFT_BIT) ) { return SOURCE_POS_TOPLEFT; } if( (bit & ~SOURCE_TOP_BIT) != 0 ) { return bit; } else return SOURCE_POS_TOP; } if( (bit & SOURCE_LEFT_BIT) ) { if( (bit & ~SOURCE_LEFT_BIT) != 0 ) return bit; else return SOURCE_POS_LEFT; } if( (bit & SOURCE_BOTTOM_BIT) ) { if( (bit & SOURCE_RIGHT_BIT) ) { return SOURCE_POS_BOTTOMRIGHT; } if( (bit & ~SOURCE_BOTTOM_BIT) != 0 ) { return bit; } else return SOURCE_POS_BOTTOM; } if( (bit & SOURCE_RIGHT_BIT) ) { if( (bit & ~SOURCE_RIGHT_BIT) != 0 ) return bit; else return SOURCE_POS_RIGHT; } warn("Got a HIDEOUS error in source_bit2pos"); return SOURCE_POS_ALL; } # line 1794 "dyna2.dy" CellSource * read_CellSource_line(char * line,FILE * ifp) { CellSource * out; char buffer[MAXLINE]; char * runner; char * temp; char ** base; char ** splitstr; int posbits = 0; /** use with SOURCE_TOP_BIT etc **/ /* parse first line */ base=splitstr=breakstring(line,spacestr); if( strcmp(*splitstr,"source") != 0) { warn("In parsing the line starting %s it had no source tag!",line); return NULL; } splitstr++; if( *splitstr == NULL ) { warn("In parsing the line source [%s] there was no source tag",line); return NULL; } out = CellSource_alloc(); if( out == NULL) return NULL; out->state_source = stringalloc(*splitstr); push_errormsg_stack("In reading source %s",out->state_source); for(splitstr++;*splitstr;splitstr++) { if( strstartcmp(*splitstr,"offi") == 0) { runner=string_from_quoted_equality(*splitstr); if( runner == NULL ) { warn("Unable to read offi in Source %s",line); continue; } out->offi = atoi(runner); ckfree(runner); } else if ( strstartcmp(*splitstr,"offj") == 0) { runner=string_from_quoted_equality(*splitstr); if( runner == NULL ) { warn("Unable to read offi in Source %s",line); continue; } out->offj = atoi(runner); ckfree(runner); } else if ( strcmp(*splitstr,"!top") == 0 ) { posbits = (posbits | SOURCE_TOP_BIT); } else if ( strcmp(*splitstr,"!left") == 0 ) { posbits = (posbits | SOURCE_LEFT_BIT); } else if ( strcmp(*splitstr,"!right") == 0 ) { posbits = (posbits | SOURCE_RIGHT_BIT); } else if ( strcmp(*splitstr,"!bottom") == 0 ) { posbits = (posbits | SOURCE_BOTTOM_BIT); } else { warn("Parse error in source %s - cannot make sense of %s",line,*splitstr); } } out->position = source_bit2pos(posbits); ckfree(base); while( get_watched_line(buffer,MAXLINE,ifp) != NULL) { chop_newline(buffer); if( strwhitestartcmp(buffer,"#",spacestr) == 0 ) continue; if( only_whitespace(buffer,spacestr) == TRUE) continue; if( strwhitestartcmp(buffer,"endsource",spacestr) == 0 ) break; if( strwhitestartcmp(buffer,"end",spacestr) == 0 ) { warn("you have a end line [%s] but expecting an endsource line. Will fail",buffer); goto error; } if( strwhitestartcmp(buffer,"source",spacestr) == 0 ) { warn("In reading a source, got a source tag [%s]. Expect you forgot an endsource. Will fail",buffer); goto error; } if( strwhitestartcmp(buffer,"query_label",spacestr) == 0 ) { base = splitstr = breakstring(buffer,spacestr); splitstr++; if( *splitstr == NULL ) { warn("Picked up query_label tag but no query label in source %s",out->state_source); } else out->query_label = stringalloc(*splitstr); ckfree(base); continue; } else if( strwhitestartcmp(buffer,"target_label",spacestr) == 0 ) { base = splitstr = breakstring(buffer,spacestr); splitstr++; if( *splitstr == NULL ) { warn("Picked up target_label tag but no target label in source %s",out->state_source); } else out->target_label = stringalloc(*splitstr); ckfree(base); continue; } else if( strwhitestartcmp(buffer,"calc",spacestr) == 0 ) { temp = read_calc_line(buffer); if( temp == NULL ) { warn("unable to read calc line in Source %s - going to return now",out->state_source); return NULL; } out->calc_expr = stringalloc(temp); } else { warn("Cannot understand the line [%s] on CellSource",buffer); } } pop_errormsg_stack(); return out; error : pop_errormsg_stack(); out = free_CellSource(out); return NULL; } # line 1948 "dyna2.dy" char * read_calc_line(char * buffer) { char * runner; /* get to = */ for(;*buffer && *buffer != '=';buffer++) ; /* get to " */ for(;*buffer && *buffer != '"';buffer++) ; if( *buffer == '\0' ) { warn("In reading calc line string, got to the end of the buffer without gettint to a \""); return NULL; } runner = buffer+1; for(buffer++;*buffer && *buffer != '"';buffer++) ; *buffer='\0'; return runner; } # line 1913 "dyna2.c" /* Function: hard_link_CellSignature(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CellSignature *] * * Return [UNKN ] Undocumented return value [CellSignature *] * */ CellSignature * hard_link_CellSignature(CellSignature * obj) { if( obj == NULL ) { warn("Trying to hard link to a CellSignature object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CellSignature_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CellSignature *] * */ CellSignature * CellSignature_alloc(void) { CellSignature * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CellSignature *) ckalloc (sizeof(CellSignature))) == NULL) { warn("CellSignature_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->offi = 0; out->offj = 0; return out; } /* Function: free_CellSignature(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CellSignature *] * * Return [UNKN ] Undocumented return value [CellSignature *] * */ CellSignature * free_CellSignature(CellSignature * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CellSignature obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_CellSignatureSet(list,i,j) * * Descrip: swap function: an internal for qsort_CellSignatureSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [CellSignature **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_CellSignatureSet(CellSignature ** list,int i,int j) { CellSignature * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_CellSignatureSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_CellSignatureSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [CellSignature **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_CellSignatureSet(CellSignature ** list,int left,int right,int (*comp)(CellSignature * ,CellSignature * )) { int i,last; if( left >= right ) return; swap_CellSignatureSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_CellSignatureSet (list,++last,i); } swap_CellSignatureSet (list,left,last); qsort_CellSignatureSet(list,left,last-1,comp); qsort_CellSignatureSet(list,last+1,right,comp); } /* Function: sort_CellSignatureSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_CellSignatureSet * * * Arg: obj [UNKN ] Object containing list [CellSignatureSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_CellSignatureSet(CellSignatureSet * obj,int (*comp)(CellSignature *, CellSignature *)) { qsort_CellSignatureSet(obj->sig,0,obj->len-1,comp); return; } /* Function: expand_CellSignatureSet(obj,len) * * Descrip: Really an internal function for add_CellSignatureSet * * * Arg: obj [UNKN ] Object which contains the list [CellSignatureSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_CellSignatureSet(CellSignatureSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_CellSignatureSet called with no need"); return TRUE; } if( (obj->sig = (CellSignature ** ) ckrealloc (obj->sig,sizeof(CellSignature *)*len)) == NULL) { warn("ckrealloc failed for expand_CellSignatureSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_CellSignatureSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [CellSignatureSet *] * Arg: add [OWNER] Object to add to the list [CellSignature *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_CellSignatureSet(CellSignatureSet * obj,CellSignature * add) { if( obj->len >= obj->maxlen) { if( expand_CellSignatureSet(obj,obj->len + CellSignatureSetLISTLENGTH) == FALSE) return FALSE; } obj->sig[obj->len++]=add; return TRUE; } /* Function: flush_CellSignatureSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [CellSignatureSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_CellSignatureSet(CellSignatureSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->sig[i] != NULL) { free_CellSignature(obj->sig[i]); obj->sig[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: CellSignatureSet_alloc_std(void) * * Descrip: Equivalent to CellSignatureSet_alloc_len(CellSignatureSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [CellSignatureSet *] * */ CellSignatureSet * CellSignatureSet_alloc_std(void) { return CellSignatureSet_alloc_len(CellSignatureSetLISTLENGTH); } /* Function: CellSignatureSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [CellSignatureSet *] * */ CellSignatureSet * CellSignatureSet_alloc_len(int len) { CellSignatureSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = CellSignatureSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->sig = (CellSignature ** ) ckcalloc (len,sizeof(CellSignature *))) == NULL) { warn("Warning, ckcalloc failed in CellSignatureSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_CellSignatureSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CellSignatureSet *] * * Return [UNKN ] Undocumented return value [CellSignatureSet *] * */ CellSignatureSet * hard_link_CellSignatureSet(CellSignatureSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a CellSignatureSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CellSignatureSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CellSignatureSet *] * */ CellSignatureSet * CellSignatureSet_alloc(void) { CellSignatureSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CellSignatureSet *) ckalloc (sizeof(CellSignatureSet))) == NULL) { warn("CellSignatureSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->sig = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_CellSignatureSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CellSignatureSet *] * * Return [UNKN ] Undocumented return value [CellSignatureSet *] * */ CellSignatureSet * free_CellSignatureSet(CellSignatureSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CellSignatureSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->sig != NULL) { for(i=0;ilen;i++) { if( obj->sig[i] != NULL) free_CellSignature(obj->sig[i]); } ckfree(obj->sig); } ckfree(obj); return NULL; } /* Function: hard_link_CellSource(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CellSource *] * * Return [UNKN ] Undocumented return value [CellSource *] * */ CellSource * hard_link_CellSource(CellSource * obj) { if( obj == NULL ) { warn("Trying to hard link to a CellSource object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CellSource_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CellSource *] * */ CellSource * CellSource_alloc(void) { CellSource * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CellSource *) ckalloc (sizeof(CellSource))) == NULL) { warn("CellSource_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->state_source = NULL; out->offi = -1; out->offj = -1; out->calc_expr = NULL; out->source_expr = NULL; out->etr = NULL; out->isspecial = FALSE; out->query_label = NULL; out->target_label = NULL; out->position = SOURCE_POS_ALL; out->trans_no = 0; out->from_state_no = 0; return out; } /* Function: free_CellSource(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CellSource *] * * Return [UNKN ] Undocumented return value [CellSource *] * */ CellSource * free_CellSource(CellSource * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CellSource obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->state_source != NULL) ckfree(obj->state_source); if( obj->calc_expr != NULL) ckfree(obj->calc_expr); if( obj->source_expr != NULL) ckfree(obj->source_expr); if( obj->etr != NULL) free_ExprTree(obj->etr); if( obj->query_label != NULL) ckfree(obj->query_label); if( obj->target_label != NULL) ckfree(obj->target_label); ckfree(obj); return NULL; } /* Function: swap_CellState(list,i,j) * * Descrip: swap function: an internal for qsort_CellState * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [CellSource **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_CellState(CellSource ** list,int i,int j) { CellSource * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_CellState(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_CellState which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [CellSource **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_CellState(CellSource ** list,int left,int right,int (*comp)(CellSource * ,CellSource * )) { int i,last; if( left >= right ) return; swap_CellState(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_CellState (list,++last,i); } swap_CellState (list,left,last); qsort_CellState(list,left,last-1,comp); qsort_CellState(list,last+1,right,comp); } /* Function: sort_CellState(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_CellState * * * Arg: obj [UNKN ] Object containing list [CellState *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_CellState(CellState * obj,int (*comp)(CellSource *, CellSource *)) { qsort_CellState(obj->source,0,obj->len-1,comp); return; } /* Function: expand_CellState(obj,len) * * Descrip: Really an internal function for add_CellState * * * Arg: obj [UNKN ] Object which contains the list [CellState *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_CellState(CellState * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_CellState called with no need"); return TRUE; } if( (obj->source = (CellSource ** ) ckrealloc (obj->source,sizeof(CellSource *)*len)) == NULL) { warn("ckrealloc failed for expand_CellState, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_CellState(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [CellState *] * Arg: add [OWNER] Object to add to the list [CellSource *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_CellState(CellState * obj,CellSource * add) { if( obj->len >= obj->maxlen) { if( expand_CellState(obj,obj->len + CellStateLISTLENGTH) == FALSE) return FALSE; } obj->source[obj->len++]=add; return TRUE; } /* Function: flush_CellState(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [CellState *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_CellState(CellState * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->source[i] != NULL) { free_CellSource(obj->source[i]); obj->source[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: CellState_alloc_std(void) * * Descrip: Equivalent to CellState_alloc_len(CellStateLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [CellState *] * */ CellState * CellState_alloc_std(void) { return CellState_alloc_len(CellStateLISTLENGTH); } /* Function: CellState_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [CellState *] * */ CellState * CellState_alloc_len(int len) { CellState * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = CellState_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->source = (CellSource ** ) ckcalloc (len,sizeof(CellSource *))) == NULL) { warn("Warning, ckcalloc failed in CellState_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_CellState(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CellState *] * * Return [UNKN ] Undocumented return value [CellState *] * */ CellState * hard_link_CellState(CellState * obj) { if( obj == NULL ) { warn("Trying to hard link to a CellState object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CellState_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CellState *] * */ CellState * CellState_alloc(void) { CellState * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CellState *) ckalloc (sizeof(CellState))) == NULL) { warn("CellState_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->def_score = NULL; out->calc_expr = NULL; out->source_expr = NULL; out->offi = 0; out->offj = 0; out->is_special_i = FALSE; out->is_special_j = FALSE; out->is_end = FALSE; out->is_start = FALSE; out->specialtospecial = FALSE; out->source = NULL; out->len = out->maxlen = 0; out->query_char = NULL; out->target_char = NULL; out->footprint_start = 0; out->footprint_end = 1; out->query_label = NULL; out->target_label = NULL; out->position = SOURCE_POS_ALL; out->etr = NULL; out->state_number = -1; return out; } /* Function: free_CellState(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CellState *] * * Return [UNKN ] Undocumented return value [CellState *] * */ CellState * free_CellState(CellState * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CellState obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->def_score != NULL) ckfree(obj->def_score); if( obj->calc_expr != NULL) ckfree(obj->calc_expr); if( obj->source_expr != NULL) ckfree(obj->source_expr); if( obj->source != NULL) { for(i=0;ilen;i++) { if( obj->source[i] != NULL) free_CellSource(obj->source[i]); } ckfree(obj->source); } if( obj->query_char != NULL) ckfree(obj->query_char); if( obj->target_char != NULL) ckfree(obj->target_char); if( obj->query_label != NULL) ckfree(obj->query_label); if( obj->target_label != NULL) ckfree(obj->target_label); if( obj->etr != NULL) free_ExprTree(obj->etr); ckfree(obj); return NULL; } /* Function: hard_link_CollapsableLabel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CollapsableLabel *] * * Return [UNKN ] Undocumented return value [CollapsableLabel *] * */ CollapsableLabel * hard_link_CollapsableLabel(CollapsableLabel * obj) { if( obj == NULL ) { warn("Trying to hard link to a CollapsableLabel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CollapsableLabel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CollapsableLabel *] * */ CollapsableLabel * CollapsableLabel_alloc(void) { CollapsableLabel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CollapsableLabel *) ckalloc (sizeof(CollapsableLabel))) == NULL) { warn("CollapsableLabel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->query = NULL; out->target = NULL; return out; } /* Function: free_CollapsableLabel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CollapsableLabel *] * * Return [UNKN ] Undocumented return value [CollapsableLabel *] * */ CollapsableLabel * free_CollapsableLabel(CollapsableLabel * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CollapsableLabel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->query != NULL) ckfree(obj->query); if( obj->target != NULL) ckfree(obj->target); ckfree(obj); return NULL; } /* Function: hard_link_ExternVariable(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ExternVariable *] * * Return [UNKN ] Undocumented return value [ExternVariable *] * */ ExternVariable * hard_link_ExternVariable(ExternVariable * obj) { if( obj == NULL ) { warn("Trying to hard link to a ExternVariable object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ExternVariable_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ExternVariable *] * */ ExternVariable * ExternVariable_alloc(void) { ExternVariable * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ExternVariable *) ckalloc (sizeof(ExternVariable))) == NULL) { warn("ExternVariable_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->type = NULL; return out; } /* Function: free_ExternVariable(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ExternVariable *] * * Return [UNKN ] Undocumented return value [ExternVariable *] * */ ExternVariable * free_ExternVariable(ExternVariable * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ExternVariable obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->type != NULL) ckfree(obj->type); ckfree(obj); return NULL; } /* Function: swap_GenericMatrix(list,i,j) * * Descrip: swap function: an internal for qsort_GenericMatrix * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [CellState **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_GenericMatrix(CellState ** list,int i,int j) { CellState * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_GenericMatrix(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_GenericMatrix which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [CellState **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_GenericMatrix(CellState ** list,int left,int right,int (*comp)(CellState * ,CellState * )) { int i,last; if( left >= right ) return; swap_GenericMatrix(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_GenericMatrix (list,++last,i); } swap_GenericMatrix (list,left,last); qsort_GenericMatrix(list,left,last-1,comp); qsort_GenericMatrix(list,last+1,right,comp); } /* Function: sort_GenericMatrix(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_GenericMatrix * * * Arg: obj [UNKN ] Object containing list [GenericMatrix *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_GenericMatrix(GenericMatrix * obj,int (*comp)(CellState *, CellState *)) { qsort_GenericMatrix(obj->state,0,obj->len-1,comp); return; } /* Function: expand_GenericMatrix(obj,len) * * Descrip: Really an internal function for add_GenericMatrix * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_GenericMatrix(GenericMatrix * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_GenericMatrix called with no need"); return TRUE; } if( (obj->state = (CellState ** ) ckrealloc (obj->state,sizeof(CellState *)*len)) == NULL) { warn("ckrealloc failed for expand_GenericMatrix, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_GenericMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: add [OWNER] Object to add to the list [CellState *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_GenericMatrix(GenericMatrix * obj,CellState * add) { if( obj->len >= obj->maxlen) { if( expand_GenericMatrix(obj,obj->len + GenericMatrixLISTLENGTH) == FALSE) return FALSE; } obj->state[obj->len++]=add; return TRUE; } /* Function: flush_GenericMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GenericMatrix(GenericMatrix * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->state[i] != NULL) { free_CellState(obj->state[i]); obj->state[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: swap_spec_GenericMatrix(list,i,j) * * Descrip: swap function: an internal for qsort_spec_GenericMatrix * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [CellState **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_spec_GenericMatrix(CellState ** list,int i,int j) { CellState * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_spec_GenericMatrix(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_spec_GenericMatrix which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [CellState **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_spec_GenericMatrix(CellState ** list,int left,int right,int (*comp)(CellState * ,CellState * )) { int i,last; if( left >= right ) return; swap_spec_GenericMatrix(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_spec_GenericMatrix (list,++last,i); } swap_spec_GenericMatrix (list,left,last); qsort_spec_GenericMatrix(list,left,last-1,comp); qsort_spec_GenericMatrix(list,last+1,right,comp); } /* Function: sort_spec_GenericMatrix(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_spec_GenericMatrix * * * Arg: obj [UNKN ] Object containing list [GenericMatrix *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_spec_GenericMatrix(GenericMatrix * obj,int (*comp)(CellState *, CellState *)) { qsort_spec_GenericMatrix(obj->special,0,obj->spec_len-1,comp); return; } /* Function: expand_spec_GenericMatrix(obj,len) * * Descrip: Really an internal function for add_spec_GenericMatrix * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_spec_GenericMatrix(GenericMatrix * obj,int len) { if( obj->spec_maxlen > obj->spec_len ) { warn("expand_GenericMatrixspec_ called with no need"); return TRUE; } if( (obj->special = (CellState ** ) ckrealloc (obj->special,sizeof(CellState *)*len)) == NULL) { warn("ckrealloc failed for expand_GenericMatrix, returning FALSE"); return FALSE; } obj->spec_maxlen = len; return TRUE; } /* Function: add_spec_GenericMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: add [OWNER] Object to add to the list [CellState *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_spec_GenericMatrix(GenericMatrix * obj,CellState * add) { if( obj->spec_len >= obj->spec_maxlen) { if( expand_spec_GenericMatrix(obj,obj->spec_len + GenericMatrixLISTLENGTH) == FALSE) return FALSE; } obj->special[obj->spec_len++]=add; return TRUE; } /* Function: flush_spec_GenericMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_spec_GenericMatrix(GenericMatrix * obj) { int i; for(i=0;ispec_len;i++) { /*for i over list length*/ if( obj->special[i] != NULL) { free_CellState(obj->special[i]); obj->special[i] = NULL; } } /* end of for i over list length */ obj->spec_len = 0; return i; } /* Function: swap_res_GenericMatrix(list,i,j) * * Descrip: swap function: an internal for qsort_res_GenericMatrix * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [StructElement **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_res_GenericMatrix(StructElement ** list,int i,int j) { StructElement * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_res_GenericMatrix(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_res_GenericMatrix which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [StructElement **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_res_GenericMatrix(StructElement ** list,int left,int right,int (*comp)(StructElement * ,StructElement * )) { int i,last; if( left >= right ) return; swap_res_GenericMatrix(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_res_GenericMatrix (list,++last,i); } swap_res_GenericMatrix (list,left,last); qsort_res_GenericMatrix(list,left,last-1,comp); qsort_res_GenericMatrix(list,last+1,right,comp); } /* Function: sort_res_GenericMatrix(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_res_GenericMatrix * * * Arg: obj [UNKN ] Object containing list [GenericMatrix *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_res_GenericMatrix(GenericMatrix * obj,int (*comp)(StructElement *, StructElement *)) { qsort_res_GenericMatrix(obj->resource,0,obj->res_len-1,comp); return; } /* Function: expand_res_GenericMatrix(obj,len) * * Descrip: Really an internal function for add_res_GenericMatrix * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_res_GenericMatrix(GenericMatrix * obj,int len) { if( obj->res_maxlen > obj->res_len ) { warn("expand_GenericMatrixres_ called with no need"); return TRUE; } if( (obj->resource = (StructElement ** ) ckrealloc (obj->resource,sizeof(StructElement *)*len)) == NULL) { warn("ckrealloc failed for expand_GenericMatrix, returning FALSE"); return FALSE; } obj->res_maxlen = len; return TRUE; } /* Function: add_res_GenericMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: add [OWNER] Object to add to the list [StructElement *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_res_GenericMatrix(GenericMatrix * obj,StructElement * add) { if( obj->res_len >= obj->res_maxlen) { if( expand_res_GenericMatrix(obj,obj->res_len + GenericMatrixLISTLENGTH) == FALSE) return FALSE; } obj->resource[obj->res_len++]=add; return TRUE; } /* Function: flush_res_GenericMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_res_GenericMatrix(GenericMatrix * obj) { int i; for(i=0;ires_len;i++) { /*for i over list length*/ if( obj->resource[i] != NULL) { free_StructElement(obj->resource[i]); obj->resource[i] = NULL; } } /* end of for i over list length */ obj->res_len = 0; return i; } /* Function: swap_cal_GenericMatrix(list,i,j) * * Descrip: swap function: an internal for qsort_cal_GenericMatrix * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [CollapsableLabel **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_cal_GenericMatrix(CollapsableLabel ** list,int i,int j) { CollapsableLabel * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_cal_GenericMatrix(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_cal_GenericMatrix which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [CollapsableLabel **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_cal_GenericMatrix(CollapsableLabel ** list,int left,int right,int (*comp)(CollapsableLabel * ,CollapsableLabel * )) { int i,last; if( left >= right ) return; swap_cal_GenericMatrix(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_cal_GenericMatrix (list,++last,i); } swap_cal_GenericMatrix (list,left,last); qsort_cal_GenericMatrix(list,left,last-1,comp); qsort_cal_GenericMatrix(list,last+1,right,comp); } /* Function: sort_cal_GenericMatrix(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_cal_GenericMatrix * * * Arg: obj [UNKN ] Object containing list [GenericMatrix *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_cal_GenericMatrix(GenericMatrix * obj,int (*comp)(CollapsableLabel *, CollapsableLabel *)) { qsort_cal_GenericMatrix(obj->cal,0,obj->cal_len-1,comp); return; } /* Function: expand_cal_GenericMatrix(obj,len) * * Descrip: Really an internal function for add_cal_GenericMatrix * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_cal_GenericMatrix(GenericMatrix * obj,int len) { if( obj->cal_maxlen > obj->cal_len ) { warn("expand_GenericMatrixcal_ called with no need"); return TRUE; } if( (obj->cal = (CollapsableLabel ** ) ckrealloc (obj->cal,sizeof(CollapsableLabel *)*len)) == NULL) { warn("ckrealloc failed for expand_GenericMatrix, returning FALSE"); return FALSE; } obj->cal_maxlen = len; return TRUE; } /* Function: add_cal_GenericMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: add [OWNER] Object to add to the list [CollapsableLabel *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_cal_GenericMatrix(GenericMatrix * obj,CollapsableLabel * add) { if( obj->cal_len >= obj->cal_maxlen) { if( expand_cal_GenericMatrix(obj,obj->cal_len + GenericMatrixLISTLENGTH) == FALSE) return FALSE; } obj->cal[obj->cal_len++]=add; return TRUE; } /* Function: flush_cal_GenericMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_cal_GenericMatrix(GenericMatrix * obj) { int i; for(i=0;ical_len;i++) { /*for i over list length*/ if( obj->cal[i] != NULL) { free_CollapsableLabel(obj->cal[i]); obj->cal[i] = NULL; } } /* end of for i over list length */ obj->cal_len = 0; return i; } /* Function: swap_ev_GenericMatrix(list,i,j) * * Descrip: swap function: an internal for qsort_ev_GenericMatrix * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ExternVariable **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ev_GenericMatrix(ExternVariable ** list,int i,int j) { ExternVariable * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ev_GenericMatrix(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ev_GenericMatrix which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ExternVariable **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ev_GenericMatrix(ExternVariable ** list,int left,int right,int (*comp)(ExternVariable * ,ExternVariable * )) { int i,last; if( left >= right ) return; swap_ev_GenericMatrix(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ev_GenericMatrix (list,++last,i); } swap_ev_GenericMatrix (list,left,last); qsort_ev_GenericMatrix(list,left,last-1,comp); qsort_ev_GenericMatrix(list,last+1,right,comp); } /* Function: sort_ev_GenericMatrix(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ev_GenericMatrix * * * Arg: obj [UNKN ] Object containing list [GenericMatrix *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ev_GenericMatrix(GenericMatrix * obj,int (*comp)(ExternVariable *, ExternVariable *)) { qsort_ev_GenericMatrix(obj->ev,0,obj->ev_len-1,comp); return; } /* Function: expand_ev_GenericMatrix(obj,len) * * Descrip: Really an internal function for add_ev_GenericMatrix * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ev_GenericMatrix(GenericMatrix * obj,int len) { if( obj->ev_maxlen > obj->ev_len ) { warn("expand_GenericMatrixev_ called with no need"); return TRUE; } if( (obj->ev = (ExternVariable ** ) ckrealloc (obj->ev,sizeof(ExternVariable *)*len)) == NULL) { warn("ckrealloc failed for expand_GenericMatrix, returning FALSE"); return FALSE; } obj->ev_maxlen = len; return TRUE; } /* Function: add_ev_GenericMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: add [OWNER] Object to add to the list [ExternVariable *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ev_GenericMatrix(GenericMatrix * obj,ExternVariable * add) { if( obj->ev_len >= obj->ev_maxlen) { if( expand_ev_GenericMatrix(obj,obj->ev_len + GenericMatrixLISTLENGTH) == FALSE) return FALSE; } obj->ev[obj->ev_len++]=add; return TRUE; } /* Function: flush_ev_GenericMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ev_GenericMatrix(GenericMatrix * obj) { int i; for(i=0;iev_len;i++) { /*for i over list length*/ if( obj->ev[i] != NULL) { free_ExternVariable(obj->ev[i]); obj->ev[i] = NULL; } } /* end of for i over list length */ obj->ev_len = 0; return i; } /* Function: GenericMatrix_alloc_std(void) * * Descrip: Equivalent to GenericMatrix_alloc_len(GenericMatrixLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GenericMatrix *] * */ GenericMatrix * GenericMatrix_alloc_std(void) { return GenericMatrix_alloc_len(GenericMatrixLISTLENGTH); } /* Function: GenericMatrix_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GenericMatrix *] * */ GenericMatrix * GenericMatrix_alloc_len(int len) { GenericMatrix * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = GenericMatrix_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->state = (CellState ** ) ckcalloc (len,sizeof(CellState *))) == NULL) { warn("Warning, ckcalloc failed in GenericMatrix_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; if((out->special = (CellState ** ) ckcalloc (len,sizeof(CellState *))) == NULL) { warn("Warning, ckcalloc failed in GenericMatrix_alloc_len"); return NULL; } out->spec_len = 0; out->spec_maxlen = len; if((out->resource = (StructElement ** ) ckcalloc (len,sizeof(StructElement *))) == NULL) { warn("Warning, ckcalloc failed in GenericMatrix_alloc_len"); return NULL; } out->res_len = 0; out->res_maxlen = len; if((out->cal = (CollapsableLabel ** ) ckcalloc (len,sizeof(CollapsableLabel *))) == NULL) { warn("Warning, ckcalloc failed in GenericMatrix_alloc_len"); return NULL; } out->cal_len = 0; out->cal_maxlen = len; if((out->ev = (ExternVariable ** ) ckcalloc (len,sizeof(ExternVariable *))) == NULL) { warn("Warning, ckcalloc failed in GenericMatrix_alloc_len"); return NULL; } out->ev_len = 0; out->ev_maxlen = len; return out; } /* Function: hard_link_GenericMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenericMatrix *] * * Return [UNKN ] Undocumented return value [GenericMatrix *] * */ GenericMatrix * hard_link_GenericMatrix(GenericMatrix * obj) { if( obj == NULL ) { warn("Trying to hard link to a GenericMatrix object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GenericMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenericMatrix *] * */ GenericMatrix * GenericMatrix_alloc(void) { GenericMatrix * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenericMatrix *) ckalloc (sizeof(GenericMatrix))) == NULL) { warn("GenericMatrix_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->type = 0; out->state = NULL; out->len = out->maxlen = 0; out->special = NULL; out->spec_len = out->spec_maxlen = 0; out->query = NULL; out->query_name = NULL; out->query_len = NULL; out->target = NULL; out->target_name = NULL; out->target_len = NULL; out->resource = NULL; out->res_len = out->res_maxlen = 0; out->cal = NULL; out->cal_len = out->cal_maxlen = 0; out->ev = NULL; out->ev_len = out->ev_maxlen = 0; out->defscore_all_states = NULL; out->window_i = 0; out->window_j = 0; out->footprint = 1; out->cansearch = FALSE; out->canlabel = FALSE; out->specialtospecial = FALSE; out->sh = NULL; out->calcfunc = FALSE; out->sc = FALSE; out->mts = NULL; return out; } /* Function: free_GenericMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenericMatrix *] * * Return [UNKN ] Undocumented return value [GenericMatrix *] * */ GenericMatrix * free_GenericMatrix(GenericMatrix * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GenericMatrix obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->state != NULL) { for(i=0;ilen;i++) { if( obj->state[i] != NULL) free_CellState(obj->state[i]); } ckfree(obj->state); } if( obj->special != NULL) { for(i=0;ispec_len;i++) { if( obj->special[i] != NULL) free_CellState(obj->special[i]); } ckfree(obj->special); } if( obj->query != NULL) free_StructElement(obj->query); if( obj->query_name != NULL) ckfree(obj->query_name); if( obj->query_len != NULL) ckfree(obj->query_len); /* obj->qtype is linked in */ if( obj->target != NULL) free_StructElement(obj->target); if( obj->target_name != NULL) ckfree(obj->target_name); if( obj->target_len != NULL) ckfree(obj->target_len); /* obj->ttype is linked in */ if( obj->resource != NULL) { for(i=0;ires_len;i++) { if( obj->resource[i] != NULL) free_StructElement(obj->resource[i]); } ckfree(obj->resource); } if( obj->cal != NULL) { for(i=0;ical_len;i++) { if( obj->cal[i] != NULL) free_CollapsableLabel(obj->cal[i]); } ckfree(obj->cal); } if( obj->ev != NULL) { for(i=0;iev_len;i++) { if( obj->ev[i] != NULL) free_ExternVariable(obj->ev[i]); } ckfree(obj->ev); } if( obj->defscore_all_states != NULL) ckfree(obj->defscore_all_states); if( obj->sh != NULL) free_StructHolder(obj->sh); if( obj->calcfunc != NULL) ckfree(obj->calcfunc); if( obj->sc != NULL) free_Scope(obj->sc); if( obj->mts != NULL) free_MethodTypeSet(obj->mts); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/dyna2.h0000644000175000001440000006430710670453715014627 0ustar philippusers#ifndef DYNAMITEdyna2HEADERFILE #define DYNAMITEdyna2HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "wisec.h" #include "exprtree.h" #include "type.h" #define CellSourceLISTLENGTH 64 #define CellStateLISTLENGTH 64 #define GenericMatrixLISTLENGTH 64 #define CellExprLISTLENGTH 64 #define CellSignatureSetLISTLENGTH 64 #define STANDARDGENERICMATRIX 231 #define SEARCHGENERICMATRIX 232 #define VARIABLEGENERICMATRIX 234 enum calc_unit { GENERICMATRIX_IDEPCALCUNIT = 214, GENERICMATRIX_JDEPCALCUNIT, GENERICMATRIX_IJDEPCALCUNIT } ; /* * Ok, gets a bit weird: if position is less * than 21 then it has the bit number from the * bit positions so it can be warned properely * Look at source_bit2position function. */ enum source_positon { SOURCE_POS_ALL = 16, SOURCE_POS_TOPLEFT = 32, SOURCE_POS_TOP = 64, SOURCE_POS_LEFT = 128, SOURCE_POS_BOTTOM = 256, SOURCE_POS_RIGHT = 512, SOURCE_POS_BOTTOMRIGHT = 1024 }; #define SOURCE_TOP_BIT 1 #define SOURCE_LEFT_BIT 2 #define SOURCE_BOTTOM_BIT 4 #define SOURCE_RIGHT_BIT 8 struct CellSignature { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int offi; int offj; } ; /* CellSignature defined */ #ifndef DYNAMITE_DEFINED_CellSignature typedef struct CellSignature CellSignature; #define DYNAMITE_DEFINED_CellSignature #endif struct CellSignatureSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif CellSignature ** sig; int len;/* len for above sig */ int maxlen; /* maxlen for above sig */ } ; /* CellSignatureSet defined */ #ifndef DYNAMITE_DEFINED_CellSignatureSet typedef struct CellSignatureSet CellSignatureSet; #define DYNAMITE_DEFINED_CellSignatureSet #endif struct CellSource { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * state_source; int offi; int offj; char * calc_expr; /* going to replace CellExpr list possibly */ char * source_expr; ExprTree * etr; boolean isspecial; char * query_label; char * target_label; int position; int trans_no; /* unique number for this transition */ int from_state_no; } ; /* CellSource defined */ #ifndef DYNAMITE_DEFINED_CellSource typedef struct CellSource CellSource; #define DYNAMITE_DEFINED_CellSource #endif struct CellState { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; char * def_score; char * calc_expr; char * source_expr; int offi; int offj; boolean is_special_i; boolean is_special_j; boolean is_end; boolean is_start; boolean specialtospecial; CellSource ** source; int len;/* len for above source */ int maxlen; /* maxlen for above source */ char * query_char; char * target_char; int footprint_start; int footprint_end; char * query_label; char * target_label; int position; ExprTree * etr; int state_number; } ; /* CellState defined */ #ifndef DYNAMITE_DEFINED_CellState typedef struct CellState CellState; #define DYNAMITE_DEFINED_CellState #endif struct CollapsableLabel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * query; char * target; } ; /* CollapsableLabel defined */ #ifndef DYNAMITE_DEFINED_CollapsableLabel typedef struct CollapsableLabel CollapsableLabel; #define DYNAMITE_DEFINED_CollapsableLabel #endif struct ExternVariable { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; char * type; } ; /* ExternVariable defined */ #ifndef DYNAMITE_DEFINED_ExternVariable typedef struct ExternVariable ExternVariable; #define DYNAMITE_DEFINED_ExternVariable #endif struct GenericMatrix { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; int type; CellState ** state; int len;/* len for above state */ int maxlen; /* maxlen for above state */ CellState ** special; int spec_len; /* len for above special */ int spec_maxlen;/* maxlen for above special */ StructElement * query; char * query_name; char * query_len; Type * qtype; StructElement * target; char * target_name; char * target_len; Type * ttype; StructElement ** resource; int res_len;/* len for above resource */ int res_maxlen; /* maxlen for above resource */ CollapsableLabel ** cal; int cal_len;/* len for above cal */ int cal_maxlen; /* maxlen for above cal */ ExternVariable ** ev; int ev_len; /* len for above ev */ int ev_maxlen; /* maxlen for above ev */ char * defscore_all_states; int window_i; int window_j; int footprint; boolean cansearch; boolean canlabel; boolean specialtospecial; StructHolder * sh; /* where structure for matrix is placed */ char * calcfunc; Scope * sc; MethodTypeSet * mts; } ; /* GenericMatrix defined */ #ifndef DYNAMITE_DEFINED_GenericMatrix typedef struct GenericMatrix GenericMatrix; #define DYNAMITE_DEFINED_GenericMatrix #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: prepare_matrix(gm,mts,dycw,failing_errors) * * Descrip: main function to check GenericMatrix onced parsed * * checks * state defaults * state/source cross references * labels * calc epxressions * types and type migration * calc parsing * * * Arg: gm [RW ] GenericMatrix to be checked [GenericMatrix *] * Arg: mts [READ ] Type and Method Scope [MethodTypeSet *] * Arg: dycw [UNKN ] Undocumented argument [DycWarning *] * Arg: failing_errors [READ ] Calc line parser on which errors fail [ParseError] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean prepare_matrix(GenericMatrix * gm,MethodTypeSet * mts,DycWarning * dycw,ParseError failing_errors); /* Function: assign_source_no(gm) * * Descrip: Adds a unique transition number for CellSource * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean assign_source_no(GenericMatrix * gm); /* Function: check_start_end(gm) * * Descrip: checks we have a start + end (and only 1 each!) * and sets start's defscore to 0 * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean check_start_end(GenericMatrix * gm); /* Function: check_source_positions(gm) * * Descrip: checks the top/bottom/left/right source * positions * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean check_source_positions(GenericMatrix * gm); /* Function: read_ExternVariable_line(line) * * Descrip: reads line like extern name="xxx" type="xxx" * * * Arg: line [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ExternVariable *] * */ ExternVariable * read_ExternVariable_line(char * line); /* Function: hard_link_CellSignature(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CellSignature *] * * Return [UNKN ] Undocumented return value [CellSignature *] * */ CellSignature * hard_link_CellSignature(CellSignature * obj); /* Function: CellSignature_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CellSignature *] * */ CellSignature * CellSignature_alloc(void); /* Function: free_CellSignature(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CellSignature *] * * Return [UNKN ] Undocumented return value [CellSignature *] * */ CellSignature * free_CellSignature(CellSignature * obj); /* Function: add_CellSignatureSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [CellSignatureSet *] * Arg: add [OWNER] Object to add to the list [CellSignature *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_CellSignatureSet(CellSignatureSet * obj,CellSignature * add); /* Function: flush_CellSignatureSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [CellSignatureSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_CellSignatureSet(CellSignatureSet * obj); /* Function: CellSignatureSet_alloc_std(void) * * Descrip: Equivalent to CellSignatureSet_alloc_len(CellSignatureSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [CellSignatureSet *] * */ CellSignatureSet * CellSignatureSet_alloc_std(void); /* Function: CellSignatureSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [CellSignatureSet *] * */ CellSignatureSet * CellSignatureSet_alloc_len(int len); /* Function: hard_link_CellSignatureSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CellSignatureSet *] * * Return [UNKN ] Undocumented return value [CellSignatureSet *] * */ CellSignatureSet * hard_link_CellSignatureSet(CellSignatureSet * obj); /* Function: CellSignatureSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CellSignatureSet *] * */ CellSignatureSet * CellSignatureSet_alloc(void); /* Function: free_CellSignatureSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CellSignatureSet *] * * Return [UNKN ] Undocumented return value [CellSignatureSet *] * */ CellSignatureSet * free_CellSignatureSet(CellSignatureSet * obj); /* Function: hard_link_CellSource(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CellSource *] * * Return [UNKN ] Undocumented return value [CellSource *] * */ CellSource * hard_link_CellSource(CellSource * obj); /* Function: CellSource_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CellSource *] * */ CellSource * CellSource_alloc(void); /* Function: free_CellSource(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CellSource *] * * Return [UNKN ] Undocumented return value [CellSource *] * */ CellSource * free_CellSource(CellSource * obj); /* Function: add_CellState(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [CellState *] * Arg: add [OWNER] Object to add to the list [CellSource *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_CellState(CellState * obj,CellSource * add); /* Function: flush_CellState(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [CellState *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_CellState(CellState * obj); /* Function: CellState_alloc_std(void) * * Descrip: Equivalent to CellState_alloc_len(CellStateLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [CellState *] * */ CellState * CellState_alloc_std(void); /* Function: CellState_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [CellState *] * */ CellState * CellState_alloc_len(int len); /* Function: hard_link_CellState(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CellState *] * * Return [UNKN ] Undocumented return value [CellState *] * */ CellState * hard_link_CellState(CellState * obj); /* Function: CellState_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CellState *] * */ CellState * CellState_alloc(void); /* Function: free_CellState(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CellState *] * * Return [UNKN ] Undocumented return value [CellState *] * */ CellState * free_CellState(CellState * obj); /* Function: hard_link_CollapsableLabel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CollapsableLabel *] * * Return [UNKN ] Undocumented return value [CollapsableLabel *] * */ CollapsableLabel * hard_link_CollapsableLabel(CollapsableLabel * obj); /* Function: CollapsableLabel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CollapsableLabel *] * */ CollapsableLabel * CollapsableLabel_alloc(void); /* Function: free_CollapsableLabel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CollapsableLabel *] * * Return [UNKN ] Undocumented return value [CollapsableLabel *] * */ CollapsableLabel * free_CollapsableLabel(CollapsableLabel * obj); /* Function: hard_link_ExternVariable(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ExternVariable *] * * Return [UNKN ] Undocumented return value [ExternVariable *] * */ ExternVariable * hard_link_ExternVariable(ExternVariable * obj); /* Function: ExternVariable_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ExternVariable *] * */ ExternVariable * ExternVariable_alloc(void); /* Function: free_ExternVariable(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ExternVariable *] * * Return [UNKN ] Undocumented return value [ExternVariable *] * */ ExternVariable * free_ExternVariable(ExternVariable * obj); /* Function: add_GenericMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: add [OWNER] Object to add to the list [CellState *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_GenericMatrix(GenericMatrix * obj,CellState * add); /* Function: flush_GenericMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GenericMatrix(GenericMatrix * obj); /* Function: add_spec_GenericMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: add [OWNER] Object to add to the list [CellState *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_spec_GenericMatrix(GenericMatrix * obj,CellState * add); /* Function: flush_spec_GenericMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_spec_GenericMatrix(GenericMatrix * obj); /* Function: add_res_GenericMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: add [OWNER] Object to add to the list [StructElement *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_res_GenericMatrix(GenericMatrix * obj,StructElement * add); /* Function: flush_res_GenericMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_res_GenericMatrix(GenericMatrix * obj); /* Function: add_cal_GenericMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: add [OWNER] Object to add to the list [CollapsableLabel *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_cal_GenericMatrix(GenericMatrix * obj,CollapsableLabel * add); /* Function: flush_cal_GenericMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_cal_GenericMatrix(GenericMatrix * obj); /* Function: add_ev_GenericMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * Arg: add [OWNER] Object to add to the list [ExternVariable *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_ev_GenericMatrix(GenericMatrix * obj,ExternVariable * add); /* Function: flush_ev_GenericMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenericMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ev_GenericMatrix(GenericMatrix * obj); /* Function: GenericMatrix_alloc_std(void) * * Descrip: Equivalent to GenericMatrix_alloc_len(GenericMatrixLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GenericMatrix *] * */ GenericMatrix * GenericMatrix_alloc_std(void); /* Function: GenericMatrix_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GenericMatrix *] * */ GenericMatrix * GenericMatrix_alloc_len(int len); /* Function: hard_link_GenericMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenericMatrix *] * * Return [UNKN ] Undocumented return value [GenericMatrix *] * */ GenericMatrix * hard_link_GenericMatrix(GenericMatrix * obj); /* Function: GenericMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenericMatrix *] * */ GenericMatrix * GenericMatrix_alloc(void); /* Function: free_GenericMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenericMatrix *] * * Return [UNKN ] Undocumented return value [GenericMatrix *] * */ GenericMatrix * free_GenericMatrix(GenericMatrix * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ CellSignatureSet * CellSignatureSet_from_GenericMatrix(GenericMatrix * gm); boolean can_do_threads(GenericMatrix * gm); CellState * CellState_from_str(GenericMatrix * gm,char * str); boolean check_cell_refs(GenericMatrix * gm); boolean prepare_labels(GenericMatrix * gm); boolean handle_names(GenericMatrix * gm); boolean handle_type_migration(GenericMatrix * gm,MethodTypeSet * mts); boolean perculate_state_defaults(GenericMatrix * gm); boolean make_StructHolder_for_GenericMatrix(GenericMatrix * gm,MethodTypeSet * mts); StructElement * StructElement_for_GenericMatrix_type(char * name,char * element); char * length_string_from_GenericMatrix_type(char * element); boolean can_interpret_type(char * type); char * interpret_type(char * type); CellState * start_CellState_from_GenericMatrix(GenericMatrix * gm); CellState * end_CellState_from_GenericMatrix(GenericMatrix * gm); void show_GenericMatrix(GenericMatrix * gm,char padchar,FILE * ofp); void show_CellState(CellState * cell,char padchar,int num,FILE * ofp); void show_CellSource(CellSource * cell,char padchar,int num,FILE * ofp); GenericMatrix * read_GenericMatrix(FILE * ifp); GenericMatrix * read_GenericMatrix_line(char * line,FILE * ifp); CollapsableLabel * read_CollapsableLabel_line(char * line); CellState * read_CellState_line(char * line,FILE * ifp); int source_bit2pos(int bit); CellSource * read_CellSource_line(char * line,FILE * ifp); char * read_calc_line(char * buffer); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void add_GenericMatrix_Scope(Scope * sc,GenericMatrix * gm); ParseError parse_calc_line_GenericMatrix(GenericMatrix * gm,MethodTypeSet * mts,DycWarning * dycw); boolean calc_window(GenericMatrix * gm); boolean calc_footprint(GenericMatrix * gm); boolean cross_reference_state_and_source(GenericMatrix * gm); void swap_CellSignatureSet(CellSignature ** list,int i,int j) ; void qsort_CellSignatureSet(CellSignature ** list,int left,int right,int (*comp)(CellSignature * ,CellSignature * )); void sort_CellSignatureSet(CellSignatureSet * obj,int (*comp)(CellSignature *, CellSignature *)); boolean expand_CellSignatureSet(CellSignatureSet * obj,int len); void swap_CellState(CellSource ** list,int i,int j) ; void qsort_CellState(CellSource ** list,int left,int right,int (*comp)(CellSource * ,CellSource * )); void sort_CellState(CellState * obj,int (*comp)(CellSource *, CellSource *)); boolean expand_CellState(CellState * obj,int len); void swap_GenericMatrix(CellState ** list,int i,int j) ; void qsort_GenericMatrix(CellState ** list,int left,int right,int (*comp)(CellState * ,CellState * )); void sort_GenericMatrix(GenericMatrix * obj,int (*comp)(CellState *, CellState *)); boolean expand_GenericMatrix(GenericMatrix * obj,int len); void swap_spec_GenericMatrix(CellState ** list,int i,int j) ; void qsort_spec_GenericMatrix(CellState ** list,int left,int right,int (*comp)(CellState * ,CellState * )); void sort_spec_GenericMatrix(GenericMatrix * obj,int (*comp)(CellState *, CellState *)); boolean expand_spec_GenericMatrix(GenericMatrix * obj,int len); void swap_res_GenericMatrix(StructElement ** list,int i,int j) ; void qsort_res_GenericMatrix(StructElement ** list,int left,int right,int (*comp)(StructElement * ,StructElement * )); void sort_res_GenericMatrix(GenericMatrix * obj,int (*comp)(StructElement *, StructElement *)); boolean expand_res_GenericMatrix(GenericMatrix * obj,int len); void swap_cal_GenericMatrix(CollapsableLabel ** list,int i,int j) ; void qsort_cal_GenericMatrix(CollapsableLabel ** list,int left,int right,int (*comp)(CollapsableLabel * ,CollapsableLabel * )); void sort_cal_GenericMatrix(GenericMatrix * obj,int (*comp)(CollapsableLabel *, CollapsableLabel *)); boolean expand_cal_GenericMatrix(GenericMatrix * obj,int len); void swap_ev_GenericMatrix(ExternVariable ** list,int i,int j) ; void qsort_ev_GenericMatrix(ExternVariable ** list,int left,int right,int (*comp)(ExternVariable * ,ExternVariable * )); void sort_ev_GenericMatrix(GenericMatrix * obj,int (*comp)(ExternVariable *, ExternVariable *)); boolean expand_ev_GenericMatrix(GenericMatrix * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/module.c0000644000175000001440000003650407313404534015063 0ustar philippusers/* Last edited: Apr 29 10:12 1997 (birney) */ /********************************************************/ /* Wisetools version 3 file */ /* */ /* this file is copyright (c) Ewan Birney 1996 */ /* this file is part of the wisetools sequence analysis */ /* package */ /********************************************************/ /********************************************************/ /* Dynamite structure - a wrapper for the variety of */ /* of different Dynamite inputs possible */ /* */ /* */ /********************************************************/ /***** RCS Info *****************************************/ /* $Id: module.c,v 1.1.1.1 2001/06/18 13:59:56 birney Exp $ $Log: module.c,v $ Revision 1.1.1.1 2001/06/18 13:59:56 birney moved wise2 to ensembl cvs repository Revision 1.5 1999/05/03 14:52:58 birney added in alot of fixes to dyanmite. added in def boolean's in commandline added in seqalign/pwmdna stuff and linked it to hmmer bridge. Revision 1.4 1998/12/15 10:04:25 birney parsing '#' as comments now in dynamite files * Revision 1.3 1998/12/03 23:01:28 birney * getting the latex from teh api docs * * Revision 1.2 1998/11/16 15:24:59 birney * started the threads .... ;) * * Revision 1.1.1.1 1998/08/28 09:30:57 birney * Wise2 * * Revision 1.8 1998/07/27 11:39:36 birney * before compugen merge * * Revision 1.7 1998/01/09 15:12:45 birney * Added api handling, namespace protection and pdoc production. Lots of bugs * out from the main matrix construction including start point errors on * packaln * * Revision 1.6 1997/07/24 15:40:48 birney * added MethodTypeSet support for on-the-fly methods * * Revision 1.5 1997/06/10 13:55:37 birney * Lots of things: moved to teh dynfile system of keeping files around, addedfunction information, started to remodelled the matrix part * * Revision 1.4 1996/12/06 11:17:23 birney * added prepare display * * Revision 1.3 1996/10/14 10:38:37 birney * added display handling * * Revision 1.2 1996/10/04 16:41:42 birney * added cons/decons control for basic structures * * Revision 1.1 1996/03/04 12:15:33 birney * Initial revision * */ /********************************************************/ #include "module.h" #define WRITECHEADER #include "dyna2.h" #include "wisec.h" boolean prepare_dynAPI(dynAPI * api,DYNFILE * dfp,Dynamite * dyn) { int i,j; boolean ret = TRUE; StructHolder * sh; for(i=0;ilen;i++) { if(api->obj[i]->destructor == NULL ){ warn("Dynamite object %s does not have a deconstructor. Yikes!",api->obj[i]->name); ret = FALSE; } } if ( reconcile_dynAPI_with_FuncInfo(api,dfp) == FALSE) ret = FALSE; for(i=0;ilen;i++) { for(j=0;jlen;j++) { if( dyn->list[j]->type == DYNAMITETYPESTRUCT ) { sh = (StructHolder *)dyn->list[j]->data; if( strcmp(sh->name,api->obj[i]->name) == 0 ) { if( sh->oi != NULL ) api->obj[i]->info = hard_link_ObjectInfo(sh->oi); break; } } } if( j == dyn->len ) { warn("Dynamite api object %s has no actual physical object!\n",api->obj[i]->name); ret = FALSE; } } return ret; } boolean crosslink_to_StructHolder_dynAPI(dynAPI * api,Dynamite * dyn) { int i,j; StructHolder * sh; for(j=0;jlen;j++) { for(i=0;ilen;i++) { if( dyn->list[i]->type != DYNAMITETYPESTRUCT ) continue; sh = (StructHolder *)dyn->list[i]->data; if( strcmp(api->obj[j]->name,sh->name) == 0 ) { break; } } if( i == dyn->len ) { warn("Api object %s is not supported by a dynamite object. Weird!",api->obj[j]->name); continue; } api->obj[j]->sh = hard_link_StructHolder(sh); } return TRUE; /* should error check! Nggggg!*/ } dynAPI * promote_all_callable_dynAPI(Dynamite * dyn,DYNFILE * dfp) { int i,j; StructHolder * sh; dynAPI * out; char buffer[512]; char * first; APIObject * obj; APIfunc * func; out = dynAPI_alloc_std(); /*** ok - promote each struct to an object ***/ for(i=0;ilen;i++) if( dyn->list[i]->type == DYNAMITETYPESTRUCT ) { sh = (StructHolder *)dyn->list[i]->data; obj = APIObject_alloc_std(); obj->name = stringalloc(sh->name); sprintf(buffer,"free_%s",sh->name); obj->destructor = APIfunc_alloc(); obj->destructor->name = stringalloc(buffer); obj->sh = hard_link_StructHolder(sh); add_dynAPI(out,obj); } for(i=0;ilen;i++) { if( dfp->info[i]->functype != FI_CALLABLE ) { continue; } func = APIfunc_alloc(); func->name = stringalloc(dfp->info[i]->name); if( dfp->info[i]->len > 0 ) { first = dfp->info[i]->arg[0]->type; for(j=0;jlen;j++) { if( strstartcmp(first,out->obj[j]->name) == 0 ) { add_APIObject(out->obj[j],func); break; } } if( j >= out->len ) { /* no object */ add_non_dynAPI(out,func); } } else { add_non_dynAPI(out,func); } } return out; } void write_Dynamite_func(Dynamite * dyn,ModuleFunctionList * mfl,DPImplementation * dpi,DYNFILE * dfp) { register int i; for(i=0;ilen;i++) { switch ( dyn->list[i]->type ) { case DYNAMITETYPEGENERICMATRIX : write_GenericMatrix_func(dfp,(GenericMatrix *)dyn->list[i]->data,dpi); break; case DYNAMITETYPESTRUCT : write_StructHolder_function(dfp,(StructHolder *)dyn->list[i]->data,mfl); break; case DYNAMITETYPEDISPLAY : write_Aln2Display_function(dfp,(Aln2Display *) dyn->list[i]->data); break; case DYNAMITETYPEFRIEND : break; case DYNAMITETYPEAPI : break; default : log_full_error(WARNING,0,"Cannot not currently write dynamite type %d\n",dyn->list[i]->type); } } } void write_Dynamite_header(Dynamite * dyn,DPImplementation * dpi,DYNFILE * dfp) { register int i; for(i=0;ilen;i++) { switch ( dyn->list[i]->type ) { case DYNAMITETYPEGENERICMATRIX : write_GenericMatrix_header (dfp,(GenericMatrix *)dyn->list[i]->data,dpi); break; case DYNAMITETYPESTRUCT : write_StructHolder_header (dfp,(StructHolder *)dyn->list[i]->data); break; case DYNAMITETYPEDISPLAY : write_Aln2Display_header (dfp,(Aln2Display *) dyn->list[i]->data); break; case DYNAMITETYPEFRONTEND : break; case DYNAMITETYPEFRIEND : write_Friend_header(dfp,(Friend *) dyn->list[i]->data); break; case DYNAMITETYPEAPI : break; /*** API's produce *different* header files ***/ default : log_full_error(WARNING,0,"Cannot not currently write dynamite type %d\n",dyn->list[i]->type); } } } boolean prepare_Dynamite(Dynamite * dyn,MethodTypeSet * mts,DycWarning * dycw,ParseError fail) { register int i; boolean ret = TRUE; boolean temp; for(i=0;ilen;i++) { switch( dyn->list[i]->type ) { case DYNAMITETYPEGENERICMATRIX : temp = prepare_matrix( (GenericMatrix *) dyn->list[i]->data,mts,dycw,fail); if( temp == FALSE ) ret = FALSE; break; case DYNAMITETYPEDISPLAY : if( prepare_Aln2Display( (Aln2Display *) dyn->list[i]->data) == FALSE) ret = FALSE; break; case DYNAMITETYPEAPI : break; /* maybe something in here */ default : break; } } return ret; } Dynamite * read_Dynamite(FILE * ifp,char * fend,boolean * end_of_file,MethodTypeSet * mts) { char buffer[MAXLINE]; char * runner; GenericMatrix * gm; StructHolder * sh; Aln2Display * dis; Friend * fr; dynAPI * api; Dynamite * out; boolean ret = TRUE; *end_of_file = FALSE; out = Dynamite_alloc_std(); while( get_watched_line(buffer,MAXLINE,ifp) != NULL) { if( strstr(buffer,fend) != NULL) break; chop_newline(buffer); if( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"struct") == 0) { runner=strtok(buffer,spacestr); runner=strtok(NULL,spacestr); if( runner == NULL) { log_full_error(WARNING,0,"Picked up a line called struct but no name - can't read struct!"); ret = FALSE; continue; } sh = StructHolder_alloc_std(); sh->name=stringalloc(runner); if(read_StructHolder_elements(sh,ifp) == FALSE) { log_full_error(WARNING,0,"Unable to read structure --- problemo!"); sh = free_StructHolder(sh); ret = FALSE; continue; } add_Dynamite(out,wrap_StructHolder(sh)); } else if ( strstartcmp(buffer,"matrix") == 0) { gm = read_GenericMatrix_line(buffer,ifp); if( gm == NULL ) { ret = FALSE; warn("Could not read GenericMatrix in line [%s]",buffer); continue; } add_Dynamite(out,wrap_GenericMatrix(gm)); } else if ( strstartcmp(buffer,"display") == 0 ) { dis = read_Aln2Display_line(buffer,ifp); if( dis == NULL ) { ret = FALSE; warn("Could not read Display in line [%s]",buffer); continue; } add_Dynamite(out,wrap_Aln2Display(dis)); } else if ( strstartcmp(buffer,"friend") == 0 ) { fr = read_Friend_line(buffer,ifp); if( fr == NULL ) { warn("Could not read friend line"); continue; } add_Dynamite(out,wrap_Friend(fr)); } else if ( strstartcmp(buffer,"api") == 0 ) { api = read_dynAPI_line(buffer,ifp); if( api == NULL ){ warn("Could not read API lines"); continue; } add_Dynamite(out,wrap_dynAPI(api)); } else if ( strstartcmp(buffer,"method") == 0 ) { add_me_MethodTypeSet(mts,read_Method_line(buffer,ifp)); } else if ( strstartcmp(buffer,"type") == 0 ) { add_ty_MethodTypeSet(mts,read_Type_line(buffer,ifp)); } else if( only_whitespace(buffer,spacestr) == TRUE ) { continue; } else { fatal("[Dynamite Level] Did not understand line [%s]. Probably a run-away parsing error, so failing now",buffer); } } if( feof(ifp) || ferror(ifp) ) { *end_of_file = TRUE; } else *end_of_file = FALSE; if( ret == FALSE ) log_full_error(FATAL,0,"Could not read Dynamite instances"); return out; } DynamiteHolder * wrap_Aln2Display(Aln2Display * dis) { DynamiteHolder * out; out = DynamiteHolder_alloc(); out->data = dis; out->type = DYNAMITETYPEDISPLAY; return out; } DynamiteHolder * wrap_Friend(Friend * fr) { DynamiteHolder * out; out = DynamiteHolder_alloc(); out->data = fr; out->type = DYNAMITETYPEFRIEND; return out; } DynamiteHolder * wrap_dynAPI(dynAPI * api) { DynamiteHolder * out; out = DynamiteHolder_alloc(); out->data = api; out->type = DYNAMITETYPEAPI; return out; } DynamiteHolder * wrap_GenericMatrix(GenericMatrix * wm) { DynamiteHolder * out; out = DynamiteHolder_alloc(); out->data = wm; out->type = DYNAMITETYPEGENERICMATRIX; return out; } DynamiteHolder * wrap_StructHolder(StructHolder * wm) { DynamiteHolder * out; out = DynamiteHolder_alloc(); out->data = wm; out->type = DYNAMITETYPESTRUCT; return out; } /* ************************************************* */ /* Memory allocation functions written by mite on */ /* Wed Nov 15 20:14:23 1995 */ /* */ /* ************************************************* */ /* Simple alloc function for DynamiteHolder */ DynamiteHolder * DynamiteHolder_alloc(void) { DynamiteHolder * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DynamiteHolder *) ckalloc (sizeof(DynamiteHolder))) == NULL) { log_full_error(WARNING,0,"DynamiteHolder_alloc failed "); return NULL; /* calling function should respond! */ } out->data = NULL; out->type = 0; return out; } /* Free function for DynamiteHolder */ DynamiteHolder * free_DynamiteHolder(DynamiteHolder * obj) { if( obj == NULL) return NULL; ckfree(obj); return NULL; } /* swap function for qsort function */ void swap_Dynamite(DynamiteHolder ** list,int i,int j) { register DynamiteHolder * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* qsort - lifted from K&R - for Dynamite */ void qsort_Dynamite(DynamiteHolder ** list,int left,int right,int (*comp)(DynamiteHolder * ,DynamiteHolder * )) { int i,last; if( left >= right ) return; swap_Dynamite(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Dynamite (list,++last,i); } swap_Dynamite (list,left,last); qsort_Dynamite(list,left,last-1,comp); qsort_Dynamite(list,last+1,right,comp); } /* sort function to be called */ void sort_Dynamite(Dynamite * obj,int (*comp)(DynamiteHolder *, DynamiteHolder *)) { qsort_Dynamite(obj->list,0,obj->len-1,comp); return; } /* will expand function if necessary */ boolean add_Dynamite(Dynamite * obj,DynamiteHolder * add) { if( obj->len >= obj->maxlen) { if( expand_Dynamite(obj,obj->len + DynamiteLISTLENGTH) == FALSE) return FALSE; } obj->list[obj->len++]=add; return TRUE; } /* Expander function for Dynamite */ boolean expand_Dynamite(Dynamite * obj,int len) { if( obj->maxlen > len ) { log_full_error(PEDANTIC,0,"expand_Dynamite called with no need"); return TRUE; } if( (obj->list = (DynamiteHolder ** ) ckrealloc (obj->list,sizeof(DynamiteHolder *)*len)) == NULL) { log_full_error(WARNING,0,"ckrealloc failed for expand_Dynamite, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } Dynamite * Dynamite_alloc_std(void) { return Dynamite_alloc_len(DynamiteLISTLENGTH); } /* Alloc length function for Dynamite */ /* This function automatically allocates memory for list components */ Dynamite * Dynamite_alloc_len(int len) { Dynamite * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Dynamite_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->list = (DynamiteHolder ** ) ckcalloc (len,sizeof(DynamiteHolder *))) == NULL) { log_full_error(WARNING,0,"Warning, ckcalloc failed in Dynamite_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Simple alloc function for Dynamite */ Dynamite * Dynamite_alloc(void) { Dynamite * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Dynamite *) ckalloc (sizeof(Dynamite))) == NULL) { log_full_error(WARNING,0,"Dynamite_alloc failed "); return NULL; /* calling function should respond! */ } out->list = NULL; out->len = out->maxlen = 0; out->name = NULL; return out; } /* Free function for Dynamite */ Dynamite * free_Dynamite(Dynamite * obj) { register int i; if( obj == NULL) return NULL; if( obj->list != NULL) { for(i=0;ilen;i++) { if( obj->list[i] != NULL) free_DynamiteHolder(obj->list[i]); } } if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } wise-2.4.1/src/dyc/module.h0000644000175000001440000001100507313404534015055 0ustar philippusers/* Last edited: Apr 29 10:15 1997 (birney) */ /********************************************************/ /* Wisetools version 3 file */ /* */ /* this file is copyright (c) Ewan Birney 1996 */ /* this file is part of the wisetools sequence analysis */ /* package */ /********************************************************/ /********************************************************/ /* Header file for Dynamite structure - a wrapper around*/ /* Dynamite structures */ /* */ /* */ /********************************************************/ /***** RCS Info *****************************************/ /* $Id: module.h,v 1.1.1.1 2001/06/18 13:59:56 birney Exp $ $Log: module.h,v $ Revision 1.1.1.1 2001/06/18 13:59:56 birney moved wise2 to ensembl cvs repository Revision 1.3 1999/05/03 14:52:59 birney added in alot of fixes to dyanmite. added in def boolean's in commandline added in seqalign/pwmdna stuff and linked it to hmmer bridge. Revision 1.2 1998/11/16 15:25:00 birney started the threads .... ;) * Revision 1.1.1.1 1998/08/28 09:30:58 birney * Wise2 * * Revision 1.7 1998/07/27 11:39:36 birney * before compugen merge * * Revision 1.6 1998/01/09 15:12:45 birney * Added api handling, namespace protection and pdoc production. Lots of bugs * out from the main matrix construction including start point errors on * packaln * * Revision 1.5 1997/07/24 15:40:48 birney * added MethodTypeSet support for on-the-fly methods * * Revision 1.4 1997/06/10 13:55:37 birney * Lots of things: moved to teh dynfile system of keeping files around, addedfunction information, started to remodelled the matrix part * * Revision 1.3 1996/10/14 10:38:44 birney * added display handling * * Revision 1.2 1996/10/04 16:42:00 birney * added cons/decons control for basic structures * * Revision 1.1 1996/03/04 12:15:52 birney * Initial revision * */ /********************************************************/ #ifndef MODULEHEADER #define MODULEHEADER #define WRITECHEADER #include "wisec.h" #include "dyna2.h" #include "display.h" #include "dynafunc.h" #include "friend.h" #include "api.h" typedef struct { void * data; int type; } DynamiteHolder; /* DynamiteHolder defined */ typedef struct { DynamiteHolder ** list; int len; /* len for above list */ int maxlen; /* maxlen for above list */ char * name; } Dynamite; /* Dynamite defined */ #define DynamiteLISTLENGTH 32 #define DYNAMITETYPEGENERICMATRIX 56 #define DYNAMITETYPESTRUCT 57 #define DYNAMITETYPEFRONTEND 58 #define DYNAMITETYPEPARSER 59 #define DYNAMITETYPEDISPLAY 60 #define DYNAMITETYPEFRIEND 61 #define DYNAMITETYPEAPI 62 /* prototypes */ boolean prepare_Dynamite(Dynamite * dyn,MethodTypeSet * mts,DycWarning * dycw,ParseError fail); dynAPI * promote_all_callable_dynAPI(Dynamite * dyn,DYNFILE * dfp); boolean crosslink_to_StructHolder_dynAPI(dynAPI * api,Dynamite * dyn); boolean prepare_dynAPI(dynAPI * api,DYNFILE * dfp,Dynamite * dyn); void write_Dynamite_func(Dynamite * dyn,ModuleFunctionList * mfl,DPImplementation * dpi,DYNFILE * dfp); void write_Dynamite_header(Dynamite * dyn,DPImplementation * dpi,DYNFILE * dfp); Dynamite * read_Dynamite(FILE * ifp,char * fend,boolean * end_of_file,MethodTypeSet * mts); DynamiteHolder * wrap_Aln2Display(Aln2Display * dis); DynamiteHolder * wrap_Friend(Friend * fr); DynamiteHolder * wrap_GenericMatrix(GenericMatrix * wm); DynamiteHolder * wrap_StructHolder(StructHolder * wm); DynamiteHolder * wrap_dynAPI(dynAPI * api); DynamiteHolder * DynamiteHolder_alloc(void) ; DynamiteHolder * free_DynamiteHolder(DynamiteHolder * obj) ; void swap_Dynamite(DynamiteHolder ** list,int i,int j) ; void qsort_Dynamite(DynamiteHolder ** list,int left,int right,int (*comp)(DynamiteHolder * ,DynamiteHolder * )) ; void sort_Dynamite(Dynamite * obj,int (*comp)(DynamiteHolder *, DynamiteHolder *)) ; boolean add_Dynamite(Dynamite * obj,DynamiteHolder * add) ; boolean expand_Dynamite(Dynamite * obj,int len) ; Dynamite * Dynamite_alloc_std(void) ; Dynamite * Dynamite_alloc_len(int len) ; Dynamite * Dynamite_alloc(void) ; Dynamite * free_Dynamite(Dynamite * obj) ; #endif /* module loaded */ wise-2.4.1/src/dyc/exprtree.c0000644000175000001440000002667710670453715015453 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "exprtree.h" # line 99 "exprtree.dy" void parentfy_ExprTree(ExprTree * et) { int i; for(i=0;inochild;i++) { et->child[i]->parent = et; et->child[i]->position_in_parent = i; parentfy_ExprTree(et->child[i]); } } # line 112 "exprtree.dy" void declared_ExprTree(ExprTree * et) { fprintf(stderr,"Declaring..."); et->attrib = et->attrib | IS_DECLARED; } # line 122 "exprtree.dy" void find_toplevel_name(ExprTree * et) { /** et should be an expression or a tag **/ int i; for(i=0;inochild;i++) { switch(et->child[i]->type) { case ETR_NAME : if( et->position_in_parent == 0 || !(et->parent->type == ETR_REFERENCE || et->parent->type == ETR_STRUCTREF) ) { /* printf("Found as a name -> [%d][%d]",et->parent->position_in_parent,et->parent->type); print_ExprTree(et->child[i]); printf("\n"); */ et->child[i]->attrib |= IS_TOPLEVEL; } else { /* printf("Ignoring name %d,%d",et->parent->position_in_parent,et->parent->type); print_ExprTree(et->child[i]); printf("\n"); */ et->child[i]->attrib &= ~IS_TOPLEVEL; } break; default : /* printf("Going into"); print_ExprTree(et->child[i]); printf("\n"); */ find_toplevel_name(et->child[i]); break; } } } # line 161 "exprtree.dy" void strcat_ExprTree(ExprTree * ExprTree,char * buffer) { int i; switch(ExprTree->type) { case ETR_NUMBER : strcat(buffer,ExprTree->word); return; case ETR_OPERATOR : strcat(buffer,ExprTree->word); return; case ETR_EXPRESSION : strcat(buffer,"("); for(i=0;i< ExprTree->nochild;i++) strcat_ExprTree(ExprTree->child[i],buffer); strcat(buffer,")"); return; case ETR_STATEMENT : for(i=0;i< ExprTree->nochild;i++) strcat_ExprTree(ExprTree->child[i],buffer); return; case ETR_NAME : strcat(buffer,ExprTree->word); return; case ETR_ARRAY : strcat_ExprTree(ExprTree->child[0],buffer); strcat(buffer,"["); strcat_ExprTree(ExprTree->child[1],buffer); strcat(buffer,"]"); return; case ETR_TAG : for(i=0;i< ExprTree->nochild;i++) strcat_ExprTree(ExprTree->child[i],buffer); return; case ETR_STRUCTREF : strcat_ExprTree(ExprTree->child[0],buffer); strcat(buffer,ExprTree->child[1]->word); strcat_ExprTree(ExprTree->child[2],buffer); return; case ETR_REFERENCE : strcat(buffer,ExprTree->child[0]->word); strcat_ExprTree(ExprTree->child[1],buffer); return; case ETR_METHOD : fprintf(stderr,"So buffer is now [%s]\n",buffer); strcat_ExprTree(ExprTree->child[0],buffer); strcat(buffer,"("); fprintf(stderr,"So buffer is now [%s]\n",buffer); strcat_ExprTree(ExprTree->child[1],buffer); /* for(i=0;ichild[1]->nochild;i++) strcat_ExprTree(ExprTree->child[1]->child[i],buffer); */ strcat(buffer,")"); return; case ETR_COMMALIST : for(i=0;inochild;i++) { strcat_ExprTree(ExprTree->child[i],buffer); if( i != ExprTree->nochild-1) strcat(buffer,","); } return; default : warn("In trying to make Expr string, got unobtainable type!"); } } # line 224 "exprtree.dy" void print_ExprTree(ExprTree * ExprTree) { int i; switch(ExprTree->type) { case ETR_NUMBER : printf("#{%s}",ExprTree->word); return; case ETR_OPERATOR : printf("Op{%s}",ExprTree->word); return; case ETR_EXPRESSION : printf("Expression ("); for(i=0;i< ExprTree->nochild;i++) print_ExprTree(ExprTree->child[i]); printf(")"); return; case ETR_STATEMENT : printf("Top level:"); for(i=0;i< ExprTree->nochild;i++) print_ExprTree(ExprTree->child[i]); printf("\n"); return; case ETR_NAME : printf("N{%s}",ExprTree->word); for(i=0;i< ExprTree->nochild;i++) print_ExprTree(ExprTree->child[i]); return; case ETR_ARRAY : printf("{ArrayInto{"); print_ExprTree(ExprTree->child[0]); printf("} of ["); print_ExprTree(ExprTree->child[1]); printf("]}"); return; case ETR_TAG : printf("Tag{"); for(i=0;i< ExprTree->nochild;i++) print_ExprTree(ExprTree->child[i]); printf("}"); return; case ETR_STRUCTREF : printf("struct{%s}(",ExprTree->child[1]->word); print_ExprTree(ExprTree->child[0]); printf(":"); print_ExprTree(ExprTree->child[2]); printf(")"); return; case ETR_REFERENCE : printf("Ref{"); puts(ExprTree->child[0]->word); print_ExprTree(ExprTree->child[1]); printf("}\n"); return; case ETR_METHOD : if( ExprTree->attrib & IS_DECLARED ) printf("DEC:"); printf("Method{"); for(i=0;ichild[0]->nochild;i++) print_ExprTree(ExprTree->child[0]->child[i]); if( ExprTree->nochild == 1 ) printf("}(void)"); else { printf("}("); for(i=0;ichild[1]->nochild;i++) print_ExprTree(ExprTree->child[1]->child[i]); printf(")"); } return; case ETR_COMMALIST : printf("List{"); for(i=0;inochild;i++) print_ExprTree(ExprTree->child[i]); printf("}"); return; default : printf("Unprintable!"); } } /*** declarations ***/ # line 301 "exprtree.dy" ExprTree * new_ExprTree_decl_method(ExprTree * name,ExprTree * list) { ExprTree * out; out = new_ExprTree(); out->type = ETR_DECL_METHOD; out->child[0]=name; out->child[1]=list; out->nochild = 2; return out; } # line 315 "exprtree.dy" ExprTree * new_ExprTree_decl_variable(ExprTree * type,ExprTree * name) { ExprTree * out; out = new_ExprTree(); out->type = ETR_DECL_VARIABLE; out->child[0]=type; out->child[1]=name; out->nochild = 2; return out; } # line 329 "exprtree.dy" ExprTree * add_to_decl_list_ExprTree(ExprTree * list,ExprTree * add) { if( list->type != ETR_DECL_LIST ) { warn("Attempting to add to a non commalist %d",list->type); return list; } add_ExprTree(list,add); return list; } # line 341 "exprtree.dy" ExprTree * new_ExprTree_decl_list(ExprTree * start) { ExprTree * out; out = new_ExprTree(); out->type = ETR_DECL_LIST; add_ExprTree(out,start); return out; } # line 353 "exprtree.dy" ExprTree * new_ExprTree_struct_ref(ExprTree * left, ExprTree * ref,ExprTree * right) { ExprTree * out; out = new_ExprTree(); out->type = ETR_STRUCTREF; out->child[0]=left; out->child[1]=ref; out->child[2]=right; out->nochild = 3; return out; } # line 368 "exprtree.dy" ExprTree * new_ExprTree_ref(char op,ExprTree * right) { ExprTree * out; out = new_ExprTree(); out->type = ETR_REFERENCE; out->child[0]=new_ExprTree_token(op); out->child[1]=right; out->nochild = 2; return out; } # line 382 "exprtree.dy" ExprTree * add_to_commalist_ExprTree(ExprTree * list,ExprTree * add) { if( list->type != ETR_COMMALIST ) { warn("Attempting to add to a non commalist %d",list->type); return list; } add_ExprTree(list,add); return list; } # line 394 "exprtree.dy" ExprTree * new_ExprTree_commalist(ExprTree * start) { ExprTree * out; out = new_ExprTree(); out->type = ETR_COMMALIST; add_ExprTree(out,start); return out; } # line 406 "exprtree.dy" ExprTree * new_ExprTree_method(ExprTree * one,ExprTree * other) { ExprTree * out; out = ExprTree_alloc(); out->type = ETR_METHOD; /* printf("This one %d\n",one->nochild); */ add_ExprTree(out,one); if(other == NULL) { return out; } if(other->type != ETR_COMMALIST ) { warn("Attempting to have a non commalist argument for a method"); } add_ExprTree(out,other); return out; } # line 430 "exprtree.dy" ExprTree * new_ExprTree_tag_from_name(ExprTree * name) { ExprTree * out; out= new_ExprTree(); out->type = ETR_TAG; add_ExprTree(out,name); return out; } # line 444 "exprtree.dy" ExprTree * new_ExprTree_array(ExprTree * tag,ExprTree * expr) { ExprTree * out; out = new_ExprTree(); out->type = ETR_ARRAY; out->child[0] = tag; out->child[1] = expr; out->nochild = 2; return out; } # line 456 "exprtree.dy" ExprTree * new_ExprTree_binary_expr(ExprTree * left,char op,ExprTree * rgt) { ExprTree * out; out = new_ExprTree(); out->type = ETR_EXPRESSION; out->child[0] = left; out->child[1] = new_ExprTree_token(op); out->child[2] = rgt; out->nochild = 3; return out; } # line 472 "exprtree.dy" ExprTree * new_ExprTree_token(char t) { ExprTree * out; char buf[2]; buf[0] = t; buf[1] = '\0'; out= new_ExprTree(); out->type= ETR_OPERATOR; out->token = t; out->word = stringalloc(buf); return out; } # line 488 "exprtree.dy" boolean add_ExprTree(ExprTree * one,ExprTree * child) { if( one->nochild+1 > EXPRTREE_MAXCHILD ) { warn("Overflow in ExprTree at %d children",EXPRTREE_MAXCHILD); return FALSE; } one->child[one->nochild++] = child; return TRUE; } # line 499 "exprtree.dy" ExprTree * new_ExprTree(void) { int i; ExprTree * out; out = ExprTree_alloc(); for(i=0;i<128;i++) out->child[i]= NULL; return out; } # line 440 "exprtree.c" /* Function: hard_link_ExprTree(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ExprTree *] * * Return [UNKN ] Undocumented return value [ExprTree *] * */ ExprTree * hard_link_ExprTree(ExprTree * obj) { if( obj == NULL ) { warn("Trying to hard link to a ExprTree object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ExprTree_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ExprTree *] * */ ExprTree * ExprTree_alloc(void) { ExprTree * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ExprTree *) ckalloc (sizeof(ExprTree))) == NULL) { warn("ExprTree_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* child[EXPRTREE_MAXCHILD] is an array: no default possible */ out->nochild = 0; out->token = 'u'; out->word = NULL; out->type = 0; out->attrib = 0; out->parent = NULL; out->position_in_parent = 0; return out; } /* Function: free_ExprTree(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ExprTree *] * * Return [UNKN ] Undocumented return value [ExprTree *] * */ ExprTree * free_ExprTree(ExprTree * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ExprTree obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* Unable to make free function for obj->child[EXPRTREE_MAXCHILD] */ if( obj->word != NULL) ckfree(obj->word); /* Unable to make free function for obj->parent */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/exprtree.h0000644000175000001440000001242610670453715015443 0ustar philippusers#ifndef DYNAMITEexprtreeHEADERFILE #define DYNAMITEexprtreeHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" /* * Expr Tree is about the yacc parse tree. Each node in the tree is going to be ExprTree *. The children of each node are in the child array, the number of children are in the nochild field. Each node has a type, and this is the critical layout of the node. Each type will layout its children in a particular way: ETR_NUMBER - has no children. The number is word ETR_OPERATOR - has no children. The operator character is in word ETR_EXPRESSION - has potentially any number of children, but the yacc parser restricts it to (possible_tag) (operator) (possible_tag). Don't rely on this though. Generally allowed types in possible_tag are NUMBEr, TAG, METHOD or EXPRESSION ETR_STATEMENT - is the top level tag. It only has one child which must be an ETR_EXPRESSION ETR_NAME - is for absolute variable names (or method names). It has no children. The actual name is in the word ETR_ARRAY - has 2 children. The first must be a "TAG" type and is what is indexed, the second must be an EXPRESSION and is what indexes it. ETR_TAG - has any number of children to build up a TAG from NAMES, ->,. (struct refs) or * (REFERNECES). ETR_STRUCTREF - -> or . constructions. It has 3 children: 1st is the TAG to the left of the STRUCTREF, second holds either . or -> in word and third is the tag to the right. ETR_REFERENCE - * or & constructions. It has two children. 1st is * or & in word, the second is the tag which is it is acting on. ETR_METHOD - function calls. It has one or two children. The first is a tag (hence could be a pointer to a function, or similar). If it is a void function it has no other children the second is a commalist. ETR_COMMALIST - can only be found in methods. Any number of children, each being an argument of the method */ enum types { ETR_NUMBER = 0, ETR_OPERATOR, ETR_EXPRESSION, ETR_STATEMENT, ETR_ARRAY, ETR_NAME, ETR_REFERENCE, ETR_STRUCTREF, ETR_METHOD, ETR_COMMALIST, ETR_DECL_VARIABLE, ETR_DECL_METHOD, ETR_DECL_LIST, ETR_TAG }; #define EXPRTREE_MAXCHILD 128 #define IS_DECLARED 2 #define IS_TOPLEVEL 4 struct ExprTree { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif struct ExprTree * child[EXPRTREE_MAXCHILD]; int nochild; char token; char * word; int type; int attrib; struct ExprTree * parent; int position_in_parent; } ; /* ExprTree defined */ #ifndef DYNAMITE_DEFINED_ExprTree typedef struct ExprTree ExprTree; #define DYNAMITE_DEFINED_ExprTree #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_ExprTree(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ExprTree *] * * Return [UNKN ] Undocumented return value [ExprTree *] * */ ExprTree * hard_link_ExprTree(ExprTree * obj); /* Function: ExprTree_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ExprTree *] * */ ExprTree * ExprTree_alloc(void); /* Function: free_ExprTree(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ExprTree *] * * Return [UNKN ] Undocumented return value [ExprTree *] * */ ExprTree * free_ExprTree(ExprTree * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ void parentfy_ExprTree(ExprTree * et); void declared_ExprTree(ExprTree * et); void find_toplevel_name(ExprTree * et); void strcat_ExprTree(ExprTree * ExprTree,char * buffer); void print_ExprTree(ExprTree * ExprTree); ExprTree * new_ExprTree_decl_method(ExprTree * name,ExprTree * list); ExprTree * new_ExprTree_decl_variable(ExprTree * type,ExprTree * name); ExprTree * add_to_decl_list_ExprTree(ExprTree * list,ExprTree * add); ExprTree * new_ExprTree_decl_list(ExprTree * start); ExprTree * new_ExprTree_struct_ref(ExprTree * left, ExprTree * ref,ExprTree * right); ExprTree * new_ExprTree_ref(char op,ExprTree * right); ExprTree * add_to_commalist_ExprTree(ExprTree * list,ExprTree * add); ExprTree * new_ExprTree_commalist(ExprTree * start); ExprTree * new_ExprTree_method(ExprTree * one,ExprTree * other); ExprTree * new_ExprTree_tag_from_name(ExprTree * name); ExprTree * new_ExprTree_array(ExprTree * tag,ExprTree * expr) ; ExprTree * new_ExprTree_binary_expr(ExprTree * left,char op,ExprTree * rgt); ExprTree * new_ExprTree_token(char t); boolean add_ExprTree(ExprTree * one,ExprTree * child); ExprTree * new_ExprTree(void); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/dynashadow.dy0000644000175000001440000027112510414205303016116 0ustar philippusers/* Last edited: Apr 27 18:16 1997 (birney) */ %{ #include "dyna2.h" %} %{ #include "dynashadow.h" #include "dynafunc.h" void write_dc_functions(DYNFILE * dfp,GenericMatrix * gm) { write_shadow_dc_macros(dfp,gm); alloc_small_func_GenericMatrix(dfp,gm); make_small_calculate_func(dfp,gm); one_shot_AlnRangeSet_func(dfp,gm); write_AlnRangeSet_build_func(dfp,gm); write_AlnRange_build_func(dfp,gm); /* write_dc_PackAln_build_func(dfp,gm); */ write_hidden_read_func(dfp,gm); write_hidden_max_func(dfp,gm); write_special_strip_read_func(dfp,gm); write_special_strip_max_func(dfp,gm); write_matrix_to_special_max_func(dfp,gm); write_hidden_calc_func(dfp,gm); write_hidden_init_func(dfp,gm); write_full_dc_func(dfp,gm); write_single_dc_pass_func(dfp,gm); write_push_dc_func(dfp,gm); write_follow_on_dc_func(dfp,gm); write_up_to_dc_func(dfp,gm); write_init_dc_func(dfp,gm); /* write_shadow_dc_alloc(dfp,gm); */ /* write_start_end_macros(dfp,gm); */ /* write_shadow_start_end_alloc(dfp,gm); */ /* write_start_end_build(dfp,gm);*/ write_start_end_find_end(dfp,gm); optimised_shadow_GenericMatrix(dfp,gm); /* heavy_optimised_shadow_GenericMatrix(dfp,gm);*/ write_start_end_init(dfp,gm); } %func makes the allocate_Small_xxx function. This calls allocate_xxx_only function (made by /write_safe_alloc_function) and then allocates basematrix stuff as well. %arg dfp dynamite file pointer gm r generic matrix structure %% void alloc_small_func_GenericMatrix(DYNFILE * dfp,const GenericMatrix * gm) { char * arg_str; char * chain_str; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"allocate_Small_%s",gm->name); /*** prepare function information ***/ add_line_to_Ftext(fi->ft,"This function allocates the %s structure",gm->name); add_line_to_Ftext(fi->ft,"and the basematrix area for a small memory implementations"); add_line_to_Ftext(fi->ft,"It calls /allocate_%s_only",gm->name); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"%s * allocate_Small_%s(%s)",gm->name,gm->name,arg_str); /*** clean up ***/ ckfree(arg_str); /*** into function body ***/ expr(dfp,"%s * out;",gm->name); add_break(dfp); chain_str = get_chainstr_GenericMatrix(gm); expr(dfp,"out = allocate_%s_only(%s);",gm->name,chain_str); ckfree(chain_str); expr(dfp,"if( out == NULL )"); hang_expr(dfp,"return NULL;"); expr(dfp,"out->basematrix = BaseMatrix_alloc_matrix_and_specials(%d,(out->leni + %d) * %d,%d,out->lenj+%d)",(gm->window_j+1)*8,gm->window_i,gm->len,gm->spec_len*8,gm->window_j); expr(dfp,"if(out == NULL) "); startbrace(dfp); expr(dfp,"warn(\"Small shadow matrix %s cannot be allocated, (asking for %d by %%d main cells)\",out->leni+%d);",gm->name,gm->window_j+1,gm->window_i+1); expr(dfp,"free_%s(out)",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"out->basematrix->type = BASEMATRIX_TYPE_SHADOW;"); expr(dfp,"return out"); close_function(dfp); add_break(dfp); } %func make the calculate function for small PackAln system %% void make_small_calculate_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; register int s; int ss; /*** yawn. There are better ways to do this! ***/ for(s=0;sspec_len;s++) if( gm->special[s]->is_end == TRUE ) break; for(ss=0;ssspec_len;ss++) if( gm->special[ss]->is_start == TRUE) break; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"PackAln_calculate_Small_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates an alignment for %s structure in linear space",gm->name); add_line_to_Ftext(fi->ft,"If you want only the start/end points"); add_line_to_Ftext(fi->ft,"use /AlnRangeSet_calculate_Small_%s ",gm->name); add_break_to_Ftext(fi->ft); add_line_to_Ftext(fi->ft,"The function basically"); add_line_to_Ftext(fi->ft," finds start/end points "); add_line_to_Ftext(fi->ft," foreach start/end point "); add_line_to_Ftext(fi->ft," calls /full_dc_%s ",gm->name); start_function_FuncInfo(fi,dfp,"PackAln * PackAln_calculate_Small_%s(%s * mat,DPEnvelope * dpenv)",gm->name,gm->name); /*** function body ***/ expr(dfp,"int endj;"); expr(dfp,"int score;"); expr(dfp,"PackAln * out;"); expr(dfp,"PackAlnUnit * pau;"); expr(dfp,"int starti;"); expr(dfp,"int startj;"); expr(dfp,"int startstate;"); expr(dfp,"int stopi;"); expr(dfp,"int stopj;"); expr(dfp,"int stopstate;"); expr(dfp,"int temp;"); expr(dfp,"int donej;"); add_end_comment(dfp,"This is for reporting, will be passed as a & arg in"); expr(dfp,"int totalj;"); add_end_comment(dfp,"This also is for reporting, but as is not changed, can be passed by value"); add_break(dfp); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW )"); startbrace(dfp); warn_expr(dfp,"Could not calculate packaln small for %s due to wrong type of matrix",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); expr(dfp,"out = PackAln_alloc_std();"); add_break(dfp); /** got to figure out start/end first **/ expr(dfp,"start_reporting(\"Find start end points: \");"); expr(dfp,"dc_optimised_start_end_calc_%s(mat,dpenv);",gm->name); expr(dfp,"score = start_end_find_end_%s(mat,&endj);",gm->name); expr(dfp,"out->score = score;"); expr(dfp,"stopstate = %s;\n",gm->special[s]->name); /*** ok, life is different if we have special to specials. ***/ if( gm->specialtospecial == FALSE) { add_block_comment(dfp,"No special to specials: one matrix alignment: simply remove and get"); expr(dfp,"starti = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,0);",gm->name,gm->special[s]->name); expr(dfp,"startj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,1);",gm->name,gm->special[s]->name); expr(dfp,"startstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,2);",gm->name,gm->special[s]->name); expr(dfp,"stopi = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,3);",gm->name,gm->special[s]->name); expr(dfp,"stopj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,4);",gm->name,gm->special[s]->name); expr(dfp,"stopstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,5);",gm->name,gm->special[s]->name); expr(dfp,"temp = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,6);",gm->name,gm->special[s]->name); expr(dfp,"log_full_error(REPORT,0,\"[%%d,%%d][%%d,%%d] Score %%d\",starti,startj,stopi,stopj,score);"); expr(dfp,"stop_reporting();"); expr(dfp,"start_reporting(\"Recovering alignment: \");"); add_break(dfp); add_block_comment(dfp,"Figuring how much j we have to align for reporting purposes"); expr(dfp,"donej = 0;"); expr(dfp,"totalj = stopj - startj;"); expr(dfp,"full_dc_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv);",gm->name); add_break(dfp); add_block_comment(dfp,"Although we have no specials, need to get start. Better to check than assume"); add_break(dfp); expr(dfp,"max_matrix_to_special_%s(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL);",gm->name); expr(dfp,"if( stopi == %s_READ_OFF_ERROR || stopstate != %s )",gm->name,gm->special[ss]->name); startbrace(dfp); warn_expr(dfp,"Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); expr(dfp,"invert_PackAln(out);"); expr(dfp,"recalculate_PackAln_%s(out,mat);",gm->name); expr(dfp,"return out;"); closebrace(dfp); add_break(dfp); /*** Need to add PackUnit alloc etc... ***/ add_block_comment(dfp,"Ok. Put away start start..."); expr(dfp,"pau = PackAlnUnit_alloc()"); expr(dfp,"pau->i = stopi;"); expr(dfp,"pau->j = stopj;"); expr(dfp,"pau->state = stopstate + %d;",gm->len); expr(dfp,"add_PackAln(out,pau)"); add_break(dfp); expr(dfp,"log_full_error(REPORT,0,\"Alignment recovered\");"); expr(dfp,"stop_reporting();"); } else { add_block_comment(dfp,"Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits"); expr(dfp,"log_full_error(REPORT,0,\"End at %%d Score %%d\",endj,score);"); expr(dfp,"stop_reporting();"); expr(dfp,"for(;;)"); startbrace_tag(dfp,"while there are more special bits to recover"); expr(dfp,"start_reporting(\"Special cell aln end %%d:\",endj)"); expr(dfp,"if( read_special_strip_%s(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE )",gm->name); startbrace(dfp); warn_expr(dfp,"Problem in reading off special state system... going to return partial alignment"); expr(dfp,"break;"); closebrace(dfp); expr(dfp,"if( startstate == %s || endj <= 0)",gm->special[ss]->name); startbrace(dfp); expr(dfp,"log_full_error(REPORT,0,\"Recovered complete alignment\");"); expr(dfp,"stop_reporting();"); expr(dfp,"break;"); closebrace(dfp); add_break(dfp); expr(dfp,"log_full_error(REPORT,0,\"Finished to %%d\",endj);"); expr(dfp,"stop_reporting();"); add_break(dfp); add_block_comment(dfp,"Ok... have to eat up another piece of matrix "); expr(dfp,"temp = startstate;"); expr(dfp,"starti = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0);",gm->name); expr(dfp,"startj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1);",gm->name); expr(dfp,"startstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2);",gm->name); expr(dfp,"stopi = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3);",gm->name); expr(dfp,"stopj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4);",gm->name); expr(dfp,"stopstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5);",gm->name); add_break(dfp); add_block_comment(dfp,"Get out the score of this block. V. important!"); expr(dfp,"temp = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6);",gm->name); expr(dfp,"totalj = stopj - startj;"); expr(dfp,"donej = 0;"); expr(dfp,"start_reporting(\"Main matrix aln [%%d,%%d]:\",startj,stopj)"); expr(dfp,"if(full_dc_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In the alignment %s [%%d,%%d][%%d,%%d], got a problem. Please report bug ... giving you back a partial alignment\",starti,startj,stopi,stopj);",gm->name); expr(dfp,"return out;"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"now have to figure out which special we came from... yikes"); expr(dfp,"max_matrix_to_special_%s(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL);",gm->name); expr(dfp,"if( stopi == %s_READ_OFF_ERROR)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In %s read off ending at %%d ... got a bad matrix to special read off... returning partial alignment\",startj);",gm->name); expr(dfp,"invert_PackAln(out);"); expr(dfp,"recalculate_PackAln_%s(out,mat);",gm->name); expr(dfp,"return out;"); closebrace(dfp); add_block_comment(dfp,"if at start, break, otherwise, back to eat another strip"); expr(dfp,"if( stopstate == %s)",gm->special[ss]->name); startbrace(dfp); expr(dfp,"log_full_error(REPORT,0,\"Recovered complete alignment \");"); expr(dfp,"stop_reporting()"); expr(dfp,"break;"); closebrace(dfp); expr(dfp,"log_full_error(REPORT,0,\"Finished alignment to %%d \",startj);"); expr(dfp,"stop_reporting();"); expr(dfp,"endj = stopj;"); add_block_comment(dfp,"stopstate is correct as it is"); closebrace(dfp); } /*** clean up ***/ expr(dfp,"invert_PackAln(out);"); expr(dfp,"recalculate_PackAln_%s(out,mat);",gm->name); expr(dfp,"return out;"); add_break(dfp); close_function(dfp); add_break(dfp); } %func makes AlnRangeSet from small memory %% void one_shot_AlnRangeSet_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"AlnRangeSet_calculate_Small_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates an alignment for %s structure in linear space",gm->name); add_line_to_Ftext(fi->ft,"If you want the full alignment, use /PackAln_calculate_Small_%s ",gm->name); add_line_to_Ftext(fi->ft,"If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_%s",gm->name); add_line_to_Ftext(fi->ft,"If you have got the small matrix but not the alignment, use /AlnRangeSet_from_%s ",gm->name); start_function_FuncInfo(fi,dfp,"AlnRangeSet * AlnRangeSet_calculate_Small_%s(%s * mat)",gm->name,gm->name); /*** function body ***/ expr(dfp,"AlnRangeSet * out;"); add_break(dfp); expr(dfp,"start_reporting(\"Find start end points: \");"); expr(dfp,"dc_optimised_start_end_calc_%s(mat,NULL);",gm->name); expr(dfp,"log_full_error(REPORT,0,\"Calculated\");"); add_break(dfp); expr(dfp,"out = AlnRangeSet_from_%s(mat);",gm->name); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } void write_AlnRangeSet_build_func(DYNFILE * dfp,GenericMatrix * gm) { register int s; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"AlnRangeSet_from_%s",gm->name); add_line_to_Ftext(fi->ft,"This function reads off a start/end structure"); add_line_to_Ftext(fi->ft,"for %s structure in linear space",gm->name); add_line_to_Ftext(fi->ft,"If you want the full alignment use"); add_line_to_Ftext(fi->ft,"/PackAln_calculate_Small_%s ",gm->name); add_line_to_Ftext(fi->ft,"If you have not calculated the matrix use"); add_line_to_Ftext(fi->ft,"/AlnRange_calculate_Small_%s",gm->name); for(s=0;sspec_len;s++) if( gm->special[s]->is_end == TRUE ) break; start_function_FuncInfo(fi,dfp,"AlnRangeSet * AlnRangeSet_from_%s(%s * mat)",gm->name,gm->name); expr(dfp,"AlnRangeSet * out;"); expr(dfp,"AlnRange * temp;"); expr(dfp,"int jpos;"); expr(dfp,"int state;"); add_break(dfp); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW)"); startbrace(dfp); warn_expr(dfp,"Bad error! - non shadow matrix type in AlnRangeSet_from_%s",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); expr(dfp,"out = AlnRangeSet_alloc_std();"); add_block_comment(dfp,"Find the end position"); expr(dfp,"out->score = start_end_find_end_%s(mat,&jpos);",gm->name); expr(dfp,"state = %s;",gm->special[s]->name); add_break(dfp); expr(dfp,"while( (temp = AlnRange_build_%s(mat,jpos,state,&jpos,&state)) != NULL)",gm->name); hang_expr(dfp,"add_AlnRangeSet(out,temp);"); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } void write_AlnRange_build_func(DYNFILE * dfp,GenericMatrix * gm) { register int s; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"AlnRange_build_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates a single start/end set in linear space",gm->name); add_line_to_Ftext(fi->ft,"Really a sub-routine for /AlnRangeSet_from_PackAln_%s",gm->name); for(s=0;sspec_len;s++) if( gm->special[s]->is_start == TRUE ) break; if( s == gm->spec_len ) { warn("Ok... problem... the special length has no start. Unhappy!"); } start_function_FuncInfo(fi,dfp,"AlnRange * AlnRange_build_%s(%s * mat,int stopj,int stopspecstate,int * startj,int * startspecstate)",gm->name,gm->name); expr(dfp,"AlnRange * out;"); expr(dfp,"int jpos;"); expr(dfp,"int state;"); add_break(dfp); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW)"); startbrace(dfp); warn_expr(dfp,"Bad error! - non shadow matrix type in AlnRangeSet_from_%s",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Assumme that we have specials (we should!). Read back along the specials till we have the finish point"); expr(dfp,"if( read_special_strip_%s(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In AlnRanger_build_%s alignment ending at %%d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!\",stopj);",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"if( state == %s || jpos <= 0)",gm->special[s]->name); hang_expr(dfp,"return NULL;"); add_break(dfp); expr(dfp,"out = AlnRange_alloc();"); add_break(dfp); expr(dfp,"out->starti = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0);",gm->name); expr(dfp,"out->startj = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1);",gm->name); expr(dfp,"out->startstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2);",gm->name); expr(dfp,"out->stopi = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3);",gm->name); expr(dfp,"out->stopj = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4);",gm->name); expr(dfp,"out->stopstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5);",gm->name); expr(dfp,"out->startscore = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6);",gm->name); expr(dfp,"out->stopscore = %s_DC_SHADOW_SPECIAL(mat,0,jpos,state);",gm->name); add_break(dfp); add_block_comment(dfp,"Now, we have to figure out where this state came from in the specials"); expr(dfp,"max_matrix_to_special_%s(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL);",gm->name); expr(dfp,"if( jpos == %s_READ_OFF_ERROR)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In AlnRange_build_%s alignment ending at %%d, with aln range between %%d-%%d in j, unable to find source special, returning this range, but this could get tricky!\",stopj,out->startj,out->stopj);",gm->name); expr(dfp,"return out;"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Put in the correct score for startstate, from the special"); expr(dfp,"out->startscore = %s_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate);",gm->name); add_block_comment(dfp,"The correct j coords have been put into startj, startspecstate... so just return out"); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } %func This functions is now defunct %% void write_dc_PackAln_build_func(DYNFILE * dfp,GenericMatrix * gm) { register int i; register int s; int ss; char buffer[MAXLINE]; /*** yawn. There are better ways to do this! ***/ for(s=0;sspec_len;s++) if( gm->special[s]->is_end == TRUE ) break; for(ss=0;ssspec_len;ss++) if( gm->special[ss]->is_start == TRUE) break; sprintf(buffer,"PackAln * PackAln_dc_build_%s(%s %s, %s %s ",gm->name, gm->query->element_type,gm->query->name, gm->target->element_type,gm->target->name); for(i=0;ires_len;i++) { strcat(buffer,", "); strcat(buffer,gm->resource[i]->element_type); if( gm->resource[i]->isfunc == TRUE ) { continue; } strcat(buffer," "); strcat(buffer,gm->resource[i]->name); } strcat(buffer,")"); start_function(dfp,buffer); expr(dfp,"int endj;"); expr(dfp,"%s * mat;",gm->name); expr(dfp,"int score;"); expr(dfp,"PackAln * out;"); expr(dfp,"int starti;"); expr(dfp,"int startj;"); expr(dfp,"int startstate;"); expr(dfp,"int stopi;"); expr(dfp,"int stopj;"); expr(dfp,"int stopstate;"); expr(dfp,"int temp;"); expr(dfp,"int donej;"); add_end_comment(dfp,"This is for reporting, will be passed as a & arg in"); expr(dfp,"int totalj;"); add_end_comment(dfp,"This also is for reporting, but as is not changed, can be passed by value"); add_break(dfp); expr(dfp,"out = PackAln_alloc_std();"); expr(dfp,"mat = shadow_dc_alloc_%s(%s->%s,%s->%s);",gm->name,gm->query->name,gm->query_len,gm->target->name,gm->target_len); expr(dfp,"if(mat == NULL)"); startbrace(dfp); warn_expr(dfp,"Unable to build test dc linear matrix for %s, unable to allocate memory",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); expr(dfp,"mat->%s = %s;",gm->query->name,gm->query->name); expr(dfp,"mat->%s = %s;",gm->target->name,gm->target->name); for(i=0;ires_len;i++) expr(dfp,"mat->%s = %s;",gm->resource[i]->name,gm->resource[i]->name); add_break(dfp); /** got to figure out start/end first **/ expr(dfp,"start_reporting(\"Find start end points: \");"); expr(dfp,"dc_optimised_start_end_calc_%s(mat);",gm->name); expr(dfp,"score = start_end_find_end_%s(mat,&endj);",gm->name); expr(dfp,"out->score = score;"); expr(dfp,"stopstate = %s;\n",gm->special[s]->name); /*** ok, life is different if we have special to specials. ***/ if( gm->specialtospecial == FALSE) { add_block_comment(dfp,"No special to specials: one matrix alignment: simply remove and get"); expr(dfp,"starti = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,0);",gm->name,gm->special[s]->name); expr(dfp,"startj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,1);",gm->name,gm->special[s]->name); expr(dfp,"startstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,2);",gm->name,gm->special[s]->name); expr(dfp,"stopi = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,3);",gm->name,gm->special[s]->name); expr(dfp,"stopj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,4);",gm->name,gm->special[s]->name); expr(dfp,"stopstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,5);",gm->name,gm->special[s]->name); expr(dfp,"log_full_error(REPORT,0,\"[%%d,%%d][%%d,%%d] Score %%d\",starti,startj,stopi,stopj,score);"); expr(dfp,"stop_reporting();"); expr(dfp,"start_reporting(\"Recovering alignment: \");"); add_break(dfp); add_block_comment(dfp,"Figuring how much j we have to align for reporting purposes"); expr(dfp,"donej = 0;"); expr(dfp,"totalj = stopj - startj;"); expr(dfp,"full_dc_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv);",gm->name); expr(dfp,"log_full_error(REPORT,0,\"Alignment recovered\");"); expr(dfp,"stop_reporting();"); } else { add_block_comment(dfp,"Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits"); expr(dfp,"log_full_error(REPORT,0,\"End at %%d Score %%d\",endj,score);"); expr(dfp,"stop_reporting();"); expr(dfp,"for(;;)"); startbrace_tag(dfp,"while there are more special bits to recover"); expr(dfp,"start_reporting(\"Special cell aln end %%d:\",endj)"); expr(dfp,"if( read_special_strip_%s(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE )",gm->name); startbrace(dfp); warn_expr(dfp,"Problem in reading off special state system... going to return partial alignment"); expr(dfp,"break;"); closebrace(dfp); expr(dfp,"if( startstate == %s || endj <= 0)",gm->special[ss]->name); startbrace(dfp); expr(dfp,"log_full_error(REPORT,0,\"Recovered complete alignment\");"); expr(dfp,"stop_reporting();"); expr(dfp,"break;"); closebrace(dfp); add_break(dfp); expr(dfp,"log_full_error(REPORT,0,\"Finished to %%d\",endj);"); expr(dfp,"stop_reporting();"); add_break(dfp); add_block_comment(dfp,"Ok... have to eat up another piece of matrix "); expr(dfp,"temp = startstate;"); expr(dfp,"starti = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0);",gm->name); expr(dfp,"startj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1);",gm->name); expr(dfp,"startstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2);",gm->name); expr(dfp,"stopi = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3);",gm->name); expr(dfp,"stopj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4);",gm->name); expr(dfp,"stopstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5);",gm->name); add_break(dfp); add_block_comment(dfp,"Get out the score of this block. V. important!"); expr(dfp,"temp = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6);",gm->name); expr(dfp,"totalj = stopj - startj;"); expr(dfp,"donej = 0;"); expr(dfp,"start_reporting(\"Main matrix aln [%%d,%%d]:\",startj,stopj)"); expr(dfp,"if(full_dc_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In the alignment %s [%%d,%%d][%%d,%%d], got a problem. Please report bug ... giving you back a partial alignment\",starti,startj,stopi,stopj);",gm->name); expr(dfp,"return out;"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"now have to figure out which special we came from... yikes"); expr(dfp,"max_matrix_to_special_%s(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL);",gm->name); expr(dfp,"if( stopi == %s_READ_OFF_ERROR);",gm->name); startbrace(dfp); expr(dfp,"warn(\"In %s read off ending at %%d ... got a bad matrix to special read off... returning partial alignment\",startj);",gm->name); expr(dfp,"invert_PackAln(out);"); expr(dfp,"return out;"); closebrace(dfp); add_block_comment(dfp,"if at start, break, otherwise, back to eat another strip"); expr(dfp,"if( stopstate == %s)",gm->special[ss]->name); startbrace(dfp); expr(dfp,"log_full_error(REPORT,0,\"Recovered complete alignment \");"); expr(dfp,"stop_reporting()"); expr(dfp,"break;"); closebrace(dfp); expr(dfp,"log_full_error(REPORT,0,\"Finished alignment to %%d \",startj);"); expr(dfp,"stop_reporting();"); expr(dfp,"endj = stopj;"); add_block_comment(dfp,"stopstate is correct as it is"); closebrace(dfp); } expr(dfp,"invert_PackAln(out);"); expr(dfp,"free_%s(mat);",gm->name); expr(dfp,"return out;"); add_break(dfp); close_function(dfp); add_break(dfp); } %func writes the main divide and conquor routine %% void write_full_dc_func(DYNFILE * dfp,GenericMatrix * gm) { ArgInfo * ai; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"full_dc_%s",gm->name); add_line_to_Ftext(fi->ft,"The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_%s",gm->name); add_line_to_Ftext(fi->ft,"Not this function, which is pretty hard core. "); add_line_to_Ftext(fi->ft,"Function is given start/end points (in main matrix) for alignment"); add_line_to_Ftext(fi->ft,"It does some checks, decides whether start/end in j is small enough for explicit calc"); add_line_to_Ftext(fi->ft," - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE"); add_line_to_Ftext(fi->ft," - if no, uses /do_dc_single_pass_%s to get mid-point",gm->name); add_line_to_Ftext(fi->ft," saves midpoint, and calls itself to do right portion then left portion"); add_line_to_Ftext(fi->ft,"right then left ensures PackAln is added the 'right' way, ie, back-to-front"); add_line_to_Ftext(fi->ft,"returns FALSE on any error, with a warning"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); ai->desc=stringalloc("Matrix with small memory implementation"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"starti"); ai->desc=stringalloc("Start position in i"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"startj"); ai->desc=stringalloc("Start position in j"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"startstate"); ai->desc=stringalloc("Start position state number"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"stopi"); ai->desc=stringalloc("Stop position in i"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"stopj"); ai->desc=stringalloc("Stop position in j"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"stopstate"); ai->desc=stringalloc("Stop position state number"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"out"); ai->desc=stringalloc("PackAln structure to put alignment into"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"donej"); ai->desc=stringalloc("pointer to a number with the amount of alignment done"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"totalj"); ai->desc=stringalloc("total amount of alignment to do (in j coordinates)"); start_function_FuncInfo(fi,dfp,"boolean full_dc_%s(%s * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"int lstarti;"); expr(dfp,"int lstartj;"); expr(dfp,"int lstate;"); add_break(dfp); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW)"); startbrace(dfp); warn_expr(dfp,"*Very* bad error! - non shadow matrix type in full_dc_%s",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); expr(dfp,"if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1)"); startbrace(dfp); expr(dfp,"warn(\"In full dc program, passed bad indices, indices passed were %%d:%%d[%%d] to %%d:%%d[%%d]\\n\",starti,startj,startstate,stopi,stopj,stopstate);"); expr(dfp,"return FALSE"); closebrace(dfp); add_break(dfp); /*** expr(dfp,"fprintf(stdout,\"Calling with %%d,%%d[%%d] to %%d,%%d[%%d]\\n\",starti,startj,startstate,stopi,stopj,stopstate);"); ***/ expr(dfp,"if( stopj - startj < %d)",gm->window_j*5); startbrace(dfp); /** expr(dfp,"fprintf(stdout,\"Got to stopping point at %%d:%%d %%d:%%d\\n\",starti,startj,stopi,stopj);"); **/ expr(dfp,"log_full_error(REPORT,0,\"[%%d,%%d][%%d,%%d] Explicit read off\",starti,startj,stopi,stopj);"); add_end_comment(dfp,"Build hidden explicit matrix"); expr(dfp,"calculate_hidden_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv)",gm->name); expr(dfp,"*donej += (stopj - startj);"); add_end_comment(dfp,"Now read it off into out"); expr(dfp,"if( read_hidden_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In full dc, at %%d:%%d,%%d:%%d got a bad hidden explicit read off... \",starti,startj,stopi,stopj);"); expr(dfp,"return FALSE"); closebrace(dfp); expr(dfp,"return TRUE;"); closebrace(dfp); add_break(dfp); add_end_comment(dfp,"In actual divide and conquor"); expr(dfp,"if( do_dc_single_pass_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In divide and conquor for %s, at bound %%d:%%d to %%d:%%d, unable to calculate midpoint. Problem!\",starti,startj,stopi,stopj);",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); /*** expr(dfp,"for(i=0;i<6;i++)"); startbrace(dfp); expr(dfp,"printf(\"[%%d:%%d,%%d:%%d] %%d: %%d\\n\",starti,startj,stopi,stopj,i,%s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,i));",gm->name); closebrace(dfp); ***/ add_break(dfp); add_end_comment(dfp,"Ok... now we have to call on each side of the matrix"); add_end_comment(dfp,"We have to retrieve left hand side positions, as they will be vapped by the time we call LHS"); expr(dfp,"lstarti= %s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0)",gm->name); expr(dfp,"lstartj= %s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1)",gm->name); expr(dfp,"lstate = %s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2)",gm->name); add_break(dfp); add_end_comment(dfp,"Call on right hand side: this lets us do the correct read off"); expr(dfp,"if( full_dc_%s(mat,%s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),%s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),%s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE)",gm->name,gm->name,gm->name,gm->name); startbrace(dfp); add_end_comment(dfp,"Warning already issued, simply chained back up to top"); expr(dfp,"return FALSE"); closebrace(dfp); add_end_comment(dfp,"Call on left hand side"); expr(dfp,"if( full_dc_%s(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE)",gm->name); startbrace(dfp); add_end_comment(dfp,"Warning already issued, simply chained back up to top"); expr(dfp,"return FALSE"); closebrace(dfp); add_break(dfp); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } void write_single_dc_pass_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"do_dc_single_pass_%s",gm->name); start_function_FuncInfo(fi,dfp,"boolean do_dc_single_pass_%s(%s * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done)",gm->name,gm->name); expr(dfp,"int halfj;"); expr(dfp,"halfj = startj + ((stopj - startj)/2);"); /** expr(dfp,"fprintf(stdout,\"Pass with %%d,%%d[%%d] %%d,%%d[%%d] halfj %%d\\n\",starti,startj,startstate,stopi,stopj,stopstate,halfj);"); **/ add_break(dfp); expr(dfp,"init_dc_%s(mat);",gm->name); add_break(dfp); expr(dfp,"%s_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0;",gm->name); expr(dfp,"run_up_dc_%s(mat,starti,stopi,startj,halfj-1,dpenv,perc_done)",gm->name); expr(dfp,"push_dc_at_merge_%s(mat,starti,stopi,halfj,&halfj,dpenv)",gm->name); expr(dfp,"follow_on_dc_%s(mat,starti,stopi,halfj,stopj,dpenv,perc_done)",gm->name); expr(dfp,"return TRUE;"); close_function(dfp); add_break(dfp); } void write_push_dc_func(DYNFILE * dfp,GenericMatrix * gm) { int s; int r; int i; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"push_dc_at_merge_%s",gm->name); start_function_FuncInfo(fi,dfp,"void push_dc_at_merge_%s(%s * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"register int k;"); expr(dfp,"register int count;"); expr(dfp,"register int mergej;"); add_end_comment(dfp,"Sources below this j will be stamped by triples"); expr(dfp,"register int score;"); expr(dfp,"register int temp;"); add_break(dfp); expr(dfp,"mergej = startj -1"); expr(dfp,"for(count=0,j=startj;count<%d;count++,j++)",gm->window_j); startbrace(dfp); expr(dfp,"for(i=starti;i<=stopi;i++)"); startbrace(dfp); expr(dfp,"if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE )"); startbrace_tag(dfp,"Is not in envelope"); for(i=0;ilen;i++) { expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,0) = (-100);",gm->name,gm->state[i]->name); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,1) = (-100);",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); for(s=0;slen;s++) { auto CellState * state; state = gm->state[s]; add_break(dfp); add_block_comment(dfp,"For state %s, pushing when j - offj <= mergej",state->name); expr(dfp,"score = %s_DC_SHADOW_%s(mat,i-%d,j-%d,%s) + %s",gm->name,state->source[0]->isspecial == TRUE ? "SPECIAL" : "MATRIX", state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source,state->source[0]->calc_expr); expr(dfp,"if( j - %d <= mergej)",state->source[0]->offj); startbrace(dfp); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,0) = i-%d;",gm->name,state->name,state->source[0]->offi); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,1) = j-%d;",gm->name,state->name,state->source[0]->offj); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,2) = %s;",gm->name,state->name,state->source[0]->state_source); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,3) = i;",gm->name,state->name,state->source[0]->offi); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,4) = j;",gm->name,state->name,state->source[0]->offj); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,5) = %s;",gm->name,state->name,state->name); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"for(k=0;k<7;k++)"); hang_expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,k) = %s_DC_SHADOW_%s_SP(mat,i - %d,j - %d,%s,k);",gm->name, state->name,gm->name,state->source[0]->isspecial == TRUE ? "SPECIAL" : "MATRIX", state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source); closebrace(dfp); for(r=1;rlen;r++) { if( state->source[r]->isspecial == TRUE ) continue; add_break(dfp); expr(dfp,"temp = %s_DC_SHADOW_%s(mat,i-%d,j-%d,%s) + %s",gm->name,state->source[r]->isspecial == TRUE ? "SPECIAL" : "MATRIX", state->source[r]->offi,state->source[r]->offj,state->source[r]->state_source,state->source[r]->calc_expr); expr(dfp,"if( temp > score)"); startbrace(dfp); expr(dfp,"score = temp;"); add_break(dfp); expr(dfp,"if( j - %d <= mergej)",state->source[r]->offj); startbrace(dfp); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,0) = i-%d;",gm->name,state->name,state->source[r]->offi); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,1) = j-%d;",gm->name,state->name,state->source[r]->offj); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,2) = %s;",gm->name,state->name,state->source[r]->state_source); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,3) = i;",gm->name,state->name,state->source[r]->offi); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,4) = j;",gm->name,state->name,state->source[r]->offj); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,5) = %s;",gm->name,state->name,state->name); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"for(k=0;k<7;k++)"); hang_expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,k) = %s_DC_SHADOW_%s_SP(mat,i - %d,j - %d,%s,k);",gm->name, state->name,gm->name,state->source[r]->isspecial == TRUE ? "SPECIAL" : "MATRIX", state->source[r]->offi,state->source[r]->offj,state->source[r]->state_source); closebrace(dfp); closebrace(dfp); } /** ok, put in source independent score (if any!) **/ add_block_comment(dfp,"Add any movement independant score"); if( state->calc_expr != NULL ) expr(dfp,"score += %s",state->calc_expr); expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = score",gm->name,state->name); /*** I don't need to look at specials ***/ /*** for(r=0;rspec_len;r++) { auto CellState * spec; spec = gm->special[r]; for(t=0;tlen;t++) { if( strcmp(spec->source[t]->state_source,state->name) == 0 ) { add_break(dfp); add_block_comment(dfp,"state %s is a source for special %s... better update",state->name,spec->name); expr(dfp,"temp = score + (%s) + (%s) ",spec->source[t]->calc_expr,spec->calc_expr == NULL ? "0" : spec->calc_expr); expr(dfp,"if( temp > %s_DC_SHADOW_SPECIAL(mat,i,j,%s) )",gm->name,spec->name); startbrace(dfp); expr(dfp,"%s_DC_SHADOW_SPECIAL(mat,i,j,%s) = temp",gm->name,spec->name); expr(dfp,"for(k=0;k<7;k++)"); hang_expr(dfp,"%s_DC_SHADOW_SPECIAL_SP(mat,i,j,%s,k) = %s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,k);",gm->name, spec->name,gm->name,state->name); closebrace(dfp); } end of if this is a special source }end of t over all sources for this special }end of r over all specials ***/ add_block_comment(dfp,"Finished with state %s",state->name); } /* end of s over state */ closebrace(dfp); /* close i */ closebrace(dfp); /* close j */ add_block_comment(dfp,"Put back j into * stop j so that calling function gets it correct"); expr(dfp,"if( stopj == NULL)"); hang_expr(dfp,"warn(\"Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!\");"); expr(dfp,"else"); hang_expr(dfp,"*stopj = j"); add_break(dfp); expr(dfp,"return"); close_function(dfp); add_break(dfp); } void write_init_dc_func(DYNFILE * dfp,GenericMatrix * gm) { int s; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"init_dc_%s",gm->name); start_function_FuncInfo(fi,dfp,"void init_dc_%s(%s * mat)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"register int k;"); add_break(dfp); expr(dfp,"for(j=0;j<%d;j++)",gm->window_j+2); startbrace(dfp); expr(dfp,"for(i=(-%d);i%s->%s;i++)",gm->window_i,gm->query->name,gm->query_len); startbrace(dfp); for(s=0;slen;s++) { expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = %s;",gm->name,gm->state[s]->name,gm->state[s]->def_score); } expr(dfp,"for(k=0;k<7;k++)"); startbrace(dfp); for(s=0;slen;s++) { expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,k) = (-1);",gm->name,gm->state[s]->name); } closebrace(dfp); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"return"); close_function(dfp); add_break(dfp); } void write_up_to_dc_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; int i; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"run_up_dc_%s",gm->name); start_function_FuncInfo(fi,dfp,"void run_up_dc_%s(%s * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"register int score;"); expr(dfp,"register int temp;"); expr(dfp,"long int total;"); expr(dfp,"long int num;"); add_break(dfp); expr(dfp,"total = (stopi - starti+1) * (stopj - startj+1);"); expr(dfp,"if( total <= 0 )"); hang_expr(dfp,"total = 1;"); expr(dfp,"num = 0"); add_break(dfp); expr(dfp,"for(j=startj;j<=stopj;j++)"); startbrace_tag(dfp,"for each valid j column"); expr(dfp,"for(i=starti;i<=stopi;i++)"); startbrace_tag(dfp,"this is strip"); expr(dfp,"if( j == startj && i == starti)"); hang_expr(dfp,"continue;"); expr(dfp,"num++;"); expr(dfp,"if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE )"); startbrace_tag(dfp,"Is not in envelope"); for(i=0;ilen;i++) { expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); expr(dfp,"if( num %% 1000 == 0 )"); hang_expr(dfp,"log_full_error(REPORT,0,\"[%%d%%%%%%%% done]Before mid-j %%5d Cells done %%d%%%%%%%%\",perc_done,stopj,(num*100)/total)"); /** don't use specials, as we are guarenteed an alignment outisde them **/ write_score_block(dfp,gm,"DC_SHADOW_MATRIX","mat","DC_SHADOW_SPECIAL",FALSE); closebrace(dfp); closebrace(dfp); add_break(dfp); close_function(dfp); } void write_follow_on_dc_func(DYNFILE * dfp,GenericMatrix * gm) { int i; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"follow_on_dc_%s",gm->name); start_function_FuncInfo(fi,dfp,"void follow_on_dc_%s(%s * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"int score;"); expr(dfp,"int temp;"); expr(dfp,"int localshadow[7];"); expr(dfp,"long int total;"); expr(dfp,"long int num;"); add_break(dfp); expr(dfp,"total = (stopi - starti+1) * (stopj - startj+1);"); expr(dfp,"num = 0"); add_break(dfp); expr(dfp,"for(j=startj;j<=stopj;j++)"); startbrace_tag(dfp,"for each valid j column"); expr(dfp,"for(i=starti;i<=stopi;i++)"); startbrace_tag(dfp,"this is strip"); expr(dfp,"num++;"); expr(dfp,"if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE )"); startbrace_tag(dfp,"Is not in envelope"); for(i=0;ilen;i++) { expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); expr(dfp,"if( num %% 1000 == 0 )"); hang_expr(dfp,"log_full_error(REPORT,0,\"[%%d%%%%%%%% done]After mid-j %%5d Cells done %%d%%%%%%%%\",perc_done,startj,(num*100)/total)"); write_main_shadow_block(dfp,gm,"DC_SHADOW_MATRIX","mat","DC_SHADOW_SPECIAL","DC_SHADOW_MATRIX_SP","DC_SHADOW_SPECIAL_SP",7,FALSE,FALSE,0,FALSE); closebrace(dfp); /** no specials, as we are guarenteed to be outside them **/ closebrace(dfp); add_break(dfp); close_function(dfp); } void write_special_strip_read_func(DYNFILE * dfp,GenericMatrix * gm) { int ss; FuncInfo * fi; for(ss=0;ssspec_len;ss++) if( gm->special[ss]->is_start == TRUE) break; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"read_special_strip_%s",gm->name); start_function_FuncInfo(fi,dfp,"boolean read_special_strip_%s(%s * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int state;"); expr(dfp,"int cellscore;"); expr(dfp,"int isspecial;"); expr(dfp,"PackAlnUnit * pau;"); add_break(dfp); add_block_comment(dfp,"stop position is on the path"); expr(dfp,"i = stopi;"); expr(dfp,"j = stopj;"); expr(dfp,"state= stopstate;"); expr(dfp,"isspecial = TRUE;"); add_break(dfp); add_block_comment(dfp,"Loop until state has the same j as its stop in shadow pointers"); add_block_comment(dfp,"This will be the state is came out from, OR it has hit !start"); add_block_comment(dfp,"We may not want to get the alignment, in which case out will be NULL"); expr(dfp,"while( j > %s_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != %s)",gm->name,gm->special[ss]->name); startbrace_tag(dfp,"while more specials to eat up"); add_block_comment(dfp,"Put away current state, if we should"); expr(dfp,"if(out != NULL)"); startbrace(dfp); expr(dfp,"pau = PackAlnUnit_alloc();"); add_end_comment(dfp,"Should deal with memory overflow"); expr(dfp,"pau->i = i;"); expr(dfp,"pau->j = j;"); expr(dfp,"pau->state = state + %d;",gm->len); expr(dfp,"add_PackAln(out,pau);"); closebrace(dfp); add_break(dfp); expr(dfp,"max_special_strip_%s(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore);",gm->name); expr(dfp,"if( i == %s_READ_OFF_ERROR)",gm->name); startbrace(dfp); warn_expr(dfp,"In special strip read %s, got a bad read off error. Sorry!",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"check to see we have not gone too far!"); expr(dfp,"if( state != %s && j < %s_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4))",gm->special[ss]->name,gm->name); startbrace(dfp); expr(dfp,"warn(\"In special strip read %s, at special [%%d] state [%%d] overshot!\",j,state);",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_block_comment(dfp,"Put away last state"); expr(dfp,"if(out != NULL)"); startbrace(dfp); expr(dfp,"pau = PackAlnUnit_alloc();"); add_end_comment(dfp,"Should deal with memory overflow"); expr(dfp,"pau->i = i;"); expr(dfp,"pau->j = j;"); expr(dfp,"pau->state = state + %d;",gm->len); expr(dfp,"add_PackAln(out,pau);"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Put away where we are in startj and startstate"); expr(dfp,"*startj = j;"); expr(dfp,"*startstate = state;"); expr(dfp,"return TRUE;"); close_function(dfp); add_break(dfp); } void write_hidden_read_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"read_hidden_%s",gm->name); start_function_FuncInfo(fi,dfp,"boolean read_hidden_%s(%s * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int state;"); expr(dfp,"int cellscore;"); expr(dfp,"int isspecial;"); add_block_comment(dfp,"We don't need hiddenj here, 'cause matrix access handled by max funcs"); expr(dfp,"PackAlnUnit * pau;"); add_break(dfp); add_block_comment(dfp,"stop position is on the path"); expr(dfp,"i = stopi;"); expr(dfp,"j = stopj;"); expr(dfp,"state= stopstate;"); expr(dfp,"isspecial = FALSE;"); add_break(dfp); expr(dfp,"while( i >= starti && j >= startj)"); startbrace(dfp); add_block_comment(dfp,"Put away current i,j,state"); expr(dfp,"pau = PackAlnUnit_alloc();"); add_end_comment(dfp,"Should deal with memory overflow"); expr(dfp,"pau->i = i;"); expr(dfp,"pau->j = j;"); expr(dfp,"pau->state = state;"); /** expr(dfp,"fprintf(stdout,\"\\tPau unit %%d,%%d,%%d\\n\",i,j,state);"); **/ expr(dfp,"add_PackAln(out,pau);"); add_break(dfp); expr(dfp,"max_hidden_%s(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore);",gm->name); add_break(dfp); expr(dfp,"if( i == %s_READ_OFF_ERROR)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In %s hidden read off, between %%d:%%d,%%d:%%d - at got bad read off. Problem!\",starti,startj,stopi,stopj);",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); expr(dfp,"if( i == starti && j == startj && state == startstate)"); startbrace(dfp); add_end_comment(dfp,"Put away final state (start of this block)"); expr(dfp,"pau = PackAlnUnit_alloc();"); add_end_comment(dfp,"Should deal with memory overflow"); expr(dfp,"pau->i = i;"); expr(dfp,"pau->j = j;"); expr(dfp,"pau->state = state;"); expr(dfp,"add_PackAln(out,pau);"); hang_expr(dfp,"return TRUE;"); closebrace(dfp); expr(dfp,"if( i == starti && j == startj)"); startbrace(dfp); expr(dfp,"warn(\"In %s hidden read off, between %%d:%%d,%%d:%%d - hit start cell, but not in start state. Can't be good!.\",starti,startj,stopi,stopj);",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); closebrace(dfp); /* back to while */ expr(dfp,"warn(\"In %s hidden read off, between %%d:%%d,%%d:%%d - gone past start cell (now in %%d,%%d,%%d), can't be good news!.\",starti,startj,stopi,stopj,i,j,state);",gm->name); expr(dfp,"return FALSE;"); close_function(dfp); add_break(dfp); } void write_hidden_calc_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; int i; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"calculate_hidden_%s",gm->name); start_function_FuncInfo(fi,dfp,"void calculate_hidden_%s(%s * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"register int score;"); expr(dfp,"register int temp;"); expr(dfp,"register int hiddenj;"); add_break(dfp); expr(dfp,"hiddenj = startj;"); add_break(dfp); expr(dfp,"init_hidden_%s(mat,starti,startj,stopi,stopj)",gm->name); add_break(dfp); expr(dfp,"%s_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0;",gm->name); add_break(dfp); expr(dfp,"for(j=startj;j<=stopj;j++)"); startbrace(dfp); expr(dfp,"for(i=starti;i<=stopi;i++)"); startbrace(dfp); add_block_comment(dfp,"Should *not* do very first cell as this is the one set to zero in one state!"); expr(dfp,"if( i == starti && j == startj )"); hang_expr(dfp,"continue;"); expr(dfp,"if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE )"); startbrace_tag(dfp,"Is not in envelope"); for(i=0;ilen;i++) { expr(dfp,"%s_HIDDEN_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); write_score_block(dfp,gm,"HIDDEN_MATRIX","mat","HIDDEN_SPECIAL",FALSE); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"return;"); close_function(dfp); add_break(dfp); } void write_hidden_init_func(DYNFILE * dfp,GenericMatrix * gm) { register int s; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"init_hidden_%s",gm->name); start_function_FuncInfo(fi,dfp,"void init_hidden_%s(%s * mat,int starti,int startj,int stopi,int stopj)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"register int hiddenj;"); add_break(dfp); expr(dfp,"hiddenj = startj;"); expr(dfp,"for(j=(startj-%d);j<=stopj;j++)",gm->window_j); startbrace(dfp); expr(dfp,"for(i=(starti-%d);i<=stopi;i++)",gm->window_i); startbrace(dfp); for(s=0;slen;s++) { expr(dfp,"%s_HIDDEN_MATRIX(mat,i,j,%s) = %s;\n",gm->name,gm->state[s]->name,gm->state[s]->def_score); } closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"return"); close_function(dfp); add_break(dfp); } void write_hidden_max_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"max_hidden_%s",gm->name); start_function_FuncInfo(fi,dfp,"int max_hidden_%s(%s * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore)",gm->name,gm->name); expr(dfp,"register int temp;"); expr(dfp,"register int cscore;"); add_break(dfp); expr(dfp,"*reti = (*retj) = (*retstate) = %s_READ_OFF_ERROR;",gm->name); add_break(dfp); expr(dfp,"if( i < 0 || j < 0 || i > mat->%s->%s || j > mat->%s->%s)",gm->query->name, gm->query_len,gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"warn(\"In %s matrix special read off - out of bounds on matrix [i,j is %%d,%%d state %%d in standard matrix]\",i,j,state);",gm->name); expr(dfp,"return -1;"); closebrace(dfp); write_max_calc_block(dfp,gm,"HIDDEN_MATRIX","HIDDEN_SPECIAL",FALSE,FALSE); close_function(dfp); add_break(dfp); return; } void write_matrix_to_special_max_func(DYNFILE * dfp,GenericMatrix * gm) { register int i; register int j; FuncInfo * fi; char * special_tag = "DC_SHADOW_SPECIAL"; char * matrix_tag = "DC_SHADOW_MATRIX"; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"max_matrix_to_special_%s",gm->name); start_function_FuncInfo(fi,dfp,"int max_matrix_to_special_%s(%s * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore)",gm->name,gm->name); expr(dfp,"int temp"); expr(dfp,"*reti = (*retj) = (*retstate) = %s_READ_OFF_ERROR;",gm->name); add_break(dfp); expr(dfp,"if( j < 0 || j > mat->lenj)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"warn(\"In %s matrix to special read off - out of bounds on matrix [j is %%d in special]\",j);",gm->name); expr(dfp,"return -1;"); closebrace(dfp); add_break(dfp); expr(dfp,"switch(state)"); startbrace_tag(dfp,"Switch state "); for(i=0;ilen;i++) { auto CellState * cell; cell = gm->state[i]; expr(dfp,"case %s : ",cell->name); startcase(dfp); for(j=cell->len-1;j>=0;j--) { if( cell->source[j]->isspecial == FALSE) { add_block_comment(dfp,"Source %s is not a special, should not get here!",cell->source[j]->state_source); continue; } expr(dfp,"temp = cscore - (%s) - (%s)",cell->source[j]->calc_expr, cell->calc_expr == NULL ? "0" : cell->calc_expr); if( cell->source[j]->isspecial == TRUE) expr(dfp,"if( temp == %s_%s(mat,i - %d,j - %d,%s) )",gm->name,special_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); else expr(dfp,"if( temp == %s_%s(mat,i - %d,j - %d,%s) )",gm->name,matrix_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); startbrace(dfp); expr(dfp,"*reti = i - %d;",cell->source[j]->offi); expr(dfp,"*retj = j - %d;",cell->source[j]->offj); expr(dfp,"*retstate = %s;",cell->source[j]->state_source); if( cell->source[j]->isspecial == TRUE) expr(dfp,"*retspecial = TRUE;"); else expr(dfp,"*retspecial = FALSE;"); /*** if they want the score, calc the difference in the number and give it back ***/ expr(dfp,"if( cellscore != NULL)"); startbrace(dfp); expr(dfp,"*cellscore = cscore - %s_%s(mat,i-%d,j-%d,%s)",gm->name, cell->source[j]->isspecial == TRUE ? special_tag : matrix_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); expr(dfp,"return %s_%s(mat,i - %d,j - %d,%s) ",gm->name,matrix_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); } expr(dfp,"warn(\"Major problem (!) - in %s matrix to special read off, position %%d,%%d state %%d no source found!\",i,j,state);",gm->name); expr(dfp,"return (-1);"); closecase(dfp); } expr(dfp,"default:"); startcase(dfp); expr(dfp,"warn(\"Major problem (!) - in %s read off, position %%d,%%d state %%d no source found!\",i,j,state);",gm->name); expr(dfp,"return (-1);"); closecase(dfp); closebrace(dfp); add_break(dfp); close_function(dfp); add_break(dfp); } void write_special_strip_max_func(DYNFILE * dfp,GenericMatrix * gm) { register int i; register int j; char * matrix_tag = "DC_SHADOW_MATRIX"; char * special_tag = "DC_SHADOW_SPECIAL"; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"max_special_strip_%s",gm->name); add_line_to_Ftext(fi->ft,"A pretty intense internal function. Deals with read-off only in specials"); start_function_FuncInfo(fi,dfp,"int max_special_strip_%s(%s * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore)",gm->name,gm->name); expr(dfp,"int temp;"); expr(dfp,"int cscore;"); add_break(dfp); expr(dfp,"*reti = (*retj) = (*retstate) = %s_READ_OFF_ERROR;",gm->name); expr(dfp,"if( isspecial == FALSE )"); startbrace(dfp); warn_expr(dfp,"In special strip max function for %s, got a non special start point. Problem! (bad!)",gm->name); expr(dfp,"return (-1);"); closebrace(dfp); add_break(dfp); expr(dfp,"if( j < 0 || j > mat->%s->%s)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"warn(\"In %s matrix special read off - out of bounds on matrix [j is %%d in special]\",j);",gm->name); expr(dfp,"return -1;"); closebrace(dfp); add_break(dfp); expr(dfp,"cscore = %s_%s(mat,i,j,state);",gm->name,special_tag); expr(dfp,"switch(state)"); startbrace_tag(dfp,"switch on special states"); for(i=0;ispec_len;i++) { auto CellState * cell; cell = gm->special[i]; expr(dfp,"case %s : ",cell->name); startcase(dfp); /*** ok, we are only interested in specials to specials, otherwise we should not be here ***/ for(j=cell->len-1;j>=0;j--) { if( cell->source[j]->isspecial == FALSE ) { add_block_comment(dfp,"Source %s is not a special",cell->source[j]->state_source); continue; } else { add_block_comment(dfp,"source %s is a special",cell->source[j]->state_source); expr(dfp,"temp = cscore - (%s) - (%s)",cell->source[j]->calc_expr, cell->calc_expr == NULL ? "0" : cell->calc_expr); expr(dfp,"if( temp == %s_%s(mat,i - %d,j - %d,%s) )",gm->name,special_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); startbrace(dfp); expr(dfp,"*reti = i - %d;",cell->source[j]->offi); expr(dfp,"*retj = j - %d;",cell->source[j]->offj); expr(dfp,"*retstate = %s;",cell->source[j]->state_source); if( cell->source[j]->isspecial == TRUE) expr(dfp,"*retspecial = TRUE;"); else expr(dfp,"*retspecial = FALSE;"); /*** if they want the score, calc the difference in the number and give it back ***/ expr(dfp,"if( cellscore != NULL)"); startbrace(dfp); expr(dfp,"*cellscore = cscore - %s_%s(mat,i-%d,j-%d,%s)",gm->name,special_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); expr(dfp,"return %s_%s(mat,i - %d,j - %d,%s) ",gm->name,matrix_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); } } closecase(dfp); } expr(dfp,"default:"); startcase(dfp); expr(dfp,"warn(\"Major problem (!) - in %s special strip read off, position %%d,%%d state %%d no source found dropped into default on source switch!\",i,j,state);",gm->name); expr(dfp,"return (-1);"); closecase(dfp); closebrace(dfp); close_function(dfp); add_break(dfp); } void write_shadow_dc_macros(DYNFILE * dfp,GenericMatrix * gm) { int steve_space; macro(dfp,"#define %s_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+%d)][(i+%d)*%d+state])",gm->name,gm->window_j,gm->window_i,gm->len); macro(dfp,"#define %s_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+%d)*8) %% %d][(i+%d)*%d+state])",gm->name,gm->window_j+1,(gm->window_j+1)*8,gm->window_i,gm->len); macro(dfp,"#define %s_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+%d)])",gm->name,gm->window_j); macro(dfp,"#define %s_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+%d)])",gm->name,gm->window_j); macro(dfp,"#define %s_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+%d)*8)+(shadow+1)) %% %d)][(i+%d)*%d + state])",gm->name,gm->window_j+1,(gm->window_j+1)*8,gm->window_i,gm->len); macro(dfp,"#define %s_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+%d)])",gm->name,gm->window_j); /* we need 8 shadow pointers per matrix cell; one for the score 7 for different shadow implementations*/ steve_space = gm->len * 8; macro(dfp,"#define %s_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+%d)%% %d) * (leni+1) * %d) + ((i+%d) * %d) + (state)])",gm->name,gm->window_j,gm->window_j,gm->len,gm->window_i,gm->len); /* the +1 is because + 0 is the score */ macro(dfp,"#define %s_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+%d)%% %d) * (leni+1) * %d) + ((i+%d) * %d) + (state * %d) + shadow+1])",gm->name,gm->window_j,gm->window_j,steve_space,gm->window_i,steve_space,8); /* currently for the optimised shadow we use the same special matrix layout */ macro(dfp,"#define %s_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+%d)])",gm->name,gm->window_j); macro(dfp,"#define %s_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+%d)])",gm->name,gm->window_j); } %func Defunct (I think) %% void write_shadow_dc_alloc(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"do_dc_sin_%s",gm->name); start_function(dfp,"%s * shadow_dc_alloc_%s(int leni,int lenj)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register %s * out",gm->name); add_break(dfp); add_block_comment(dfp,"Have to have enough memory to hold i,j,state triple *3 for each state"); add_block_comment(dfp,"This memory will also be used for the explicit memory use at end of r"); add_break(dfp); add_block_comment(dfp,"This means we need (window_j+1)*8 top line pointers by cell number * leni"); add_break(dfp); expr(dfp,"out = %s_alloc()",gm->name); expr(dfp,"if(out == NULL)"); hang_expr(dfp,"return NULL;"); add_end_comment(dfp,"warning already issued"); add_break(dfp); expr(dfp,"out->basematrix = BaseMatrix_alloc_matrix_and_specials(%d,(leni + %d) * %d,%d,lenj+%d)",(gm->window_j+1)*8,gm->window_i,gm->len,gm->spec_len*8,gm->window_j); expr(dfp,"if(out->basematrix == NULL)"); startbrace(dfp); expr(dfp,"warn(\"In shadow_dc_alloc_%s unable to allocate basematrix with main matrix %d by %%d ints\",(leni+%d)*%d);",gm->name,(gm->window_j+1)*8,gm->window_i,gm->len); expr(dfp,"free_%s(out)",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } /*** Start End Stuff ***/ void write_start_end_init(DYNFILE * dfp,GenericMatrix * gm) { register int s; register int i; FuncInfo * fi; for(i=0;ispec_len;i++) if( gm->special[i]->is_start == TRUE) break; if( i >= gm->spec_len ) { log_full_error(WARNING,0,"Cannot build start/end init function due to lack of start state"); return; } fi = FuncInfo_named_from_varstr(FI_INTERNAL,"init_start_end_linear_%s",gm->name); start_function_FuncInfo(fi,dfp,"void init_start_end_linear_%s(%s * mat)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"for(j=0;j<%d;j++)",gm->window_j+2); startbrace(dfp); expr(dfp,"for(i=(-%d);i%s->%s;i++)",gm->window_i,gm->query->name,gm->query_len); startbrace(dfp); for(s=0;slen;s++) { expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = %s;",gm->name,gm->state[s]->name,gm->state[s]->def_score); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,0) = (-1);",gm->name,gm->state[s]->name); } closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"for(j=(-%d);j%s->%s;j++)",gm->window_j,gm->target->name,gm->target_len); startbrace(dfp); for(s=0;sspec_len;s++) { expr(dfp,"%s_DC_SHADOW_SPECIAL(mat,0,j,%s) = %s;",gm->name,gm->special[s]->name,gm->special[s]->def_score); if( s == i ) /** is start **/ expr(dfp,"%s_DC_SHADOW_SPECIAL_SP(mat,0,j,%s,0) = j;",gm->name,gm->special[s]->name); else expr(dfp,"%s_DC_SHADOW_SPECIAL_SP(mat,0,j,%s,0) = (-1);",gm->name,gm->special[s]->name); } closebrace(dfp); add_break(dfp); expr(dfp,"return"); close_function(dfp); add_break(dfp); } void write_start_end_find_end(DYNFILE * dfp,GenericMatrix * gm) { register int i; ArgInfo * ai; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"start_end_find_end_%s",gm->name); add_line_to_Ftext(fi->ft,"First function used to find end of the best path in the special state !end"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); ai->desc = stringalloc("Matrix in small mode"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"endj"); ai->desc = stringalloc("position of end in j (meaningless in i)"); ai->argtype = ARGTYPE_WRITE; for(i=0;ispec_len;i++) if( gm->special[i]->is_end == TRUE) break; if( i >= gm->spec_len ) { log_full_error(WARNING,0,"Cannot build start/end find end function due to lack of end state. YIKES!"); return; } start_function_FuncInfo(fi,dfp,"int start_end_find_end_%s(%s * mat,int * endj)",gm->name,gm->name); expr(dfp,"register int j"); expr(dfp,"register int max;"); expr(dfp,"register int maxj"); add_break(dfp); expr(dfp,"max = %s_DC_SHADOW_SPECIAL(mat,0,mat->%s->%s-1,%s);",gm->name,gm->target->name,gm->target_len,gm->special[i]->name); expr(dfp,"maxj = mat->%s->%s-1",gm->target->name,gm->target_len); expr(dfp,"for(j= mat->%s->%s-2 ;j >= 0 ;j--)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"if( %s_DC_SHADOW_SPECIAL(mat,0,j,%s) > max )",gm->name,gm->special[i]->name); startbrace(dfp); expr(dfp,"max = %s_DC_SHADOW_SPECIAL(mat,0,j,%s);",gm->name,gm->special[i]->name); expr(dfp,"maxj = j;"); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"if( endj != NULL)"); hang_expr(dfp,"*endj = maxj;"); add_break(dfp); expr(dfp,"return max"); close_function(dfp); add_break(dfp); } %func heavily optimised start end calc function %% void heavy_optimised_shadow_GenericMatrix(DYNFILE * dfp,GenericMatrix * gm) { int i; int j; int k; FuncInfo * fi; char * matrixtag = "DC_OPT_SHADOW_MATRIX"; char * shadow_main_tag = "DC_OPT_SHADOW_MATRIX_SP"; char * shadow_special_tag = "DC_OPT_SHADOW_SPECIAL_SP"; char * specialtag = "DC_OPT_SHADOW_SPECIAL"; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"dc_heavy_optimised_start_end_calc_%s",gm->name); add_line_to_Ftext(fi->ft,"Calculates special strip, leaving start/end/score points in shadow matrix"); add_line_to_Ftext(fi->ft,"Works off specially laid out memory from steve searle"); start_function_FuncInfo(fi,dfp,"boolean dc_heavy_optimised_start_end_calc_%s(%s *mat,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int localshadow[7]"); expr(dfp,"long int total"); expr(dfp,"long int num=0"); expr(dfp,"int * score_pointers"); expr(dfp,"int * shadow_pointers"); for(i=0;ilen;i++) { expr(dfp,"int score_%s;",gm->state[i]->name); expr(dfp,"int temp_%s;",gm->state[i]->name); expr(dfp,"int * localsp_%s;",gm->state[i]->name); for(j=0;jstate[i]->len;j++) { expr(dfp,"int score_%s_%d;",gm->state[i]->name,j); } } add_break(dfp); expr(dfp,"leni = mat->%s->%s;",gm->query->name,gm->query_len); expr(dfp,"lenj = mat->%s->%s;",gm->target->name,gm->target_len); add_break(dfp); expr(dfp,"score_pointers = (int *) calloc (%d * (leni + %d) * %d,sizeof(int));",gm->window_j,gm->window_i,gm->len); expr(dfp,"shadow_pointers = (int *) calloc (%d * (leni + %d) * %d * 8,sizeof(int));",gm->window_j,gm->window_i,gm->len); add_break(dfp); expr(dfp,"for(j=0;jlen;i++) { expr(dfp,"%s_DC_OPT_SHADOW_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); expr(dfp,"if( num%%1000 == 0)"); hang_expr(dfp,"log_full_error(REPORT,0,\"%%6d Cells done [%%2d%%%%%%%%]\",num,num*100/total);"); add_break(dfp); /* main block */ add_block_comment(dfp,"Retrieve all the calculations first, and put into local variables"); for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { expr(dfp,"score_%s_%d = %s_%s(mat,i-%d,j-%d,%s) + %s + (%s)", gm->state[i]->name,j, gm->name, gm->state[i]->source[j]->isspecial == TRUE ? specialtag : matrixtag, gm->state[i]->source[j]->offi,gm->state[i]->source[j]->offj, gm->state[i]->source[j]->state_source, gm->state[i]->source[j]->calc_expr, gm->state[i]->calc_expr == NULL ? "0" : gm->state[i]->calc_expr ); } } add_break(dfp); add_block_comment(dfp,"now do the if/then/else store"); for(i=0;ilen;i++) { add_block_comment(dfp,"handling state %s",gm->state[i]->name); expr(dfp,"score_%s = score_%s_0;",gm->state[i]->name,gm->state[i]->name); expr(dfp,"localsp_%s = &(%s_%s(mat,i - %d,j - %d,%s,0));",gm->state[i]->name, gm->name,gm->state[i]->source[0]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, gm->state[i]->source[0]->offi,gm->state[i]->source[0]->offj,gm->state[i]->source[0]->state_source); for(j=1;jstate[i]->len;j++) { expr(dfp,"if( score_%s_%d > score_%s)",gm->state[i]->name,j,gm->state[i]->name); startbrace(dfp); expr(dfp,"score_%s = score_%s_%d;",gm->state[i]->name,gm->state[i]->name,j); if( gm->state[i]->source[j]->isspecial == TRUE ) { add_block_comment(dfp,"This source is a special, push top shadow pointers"); expr(dfp,"localshadow[0] = i;"); expr(dfp,"localshadow[1] = j;"); expr(dfp,"localshadow[2] = %s;",gm->state[i]->name); expr(dfp,"localshadow[3] = -1;"); expr(dfp,"localshadow[4] = -1;"); expr(dfp,"localshadow[5] = -1;"); expr(dfp,"localshadow[6] = score_%s;",gm->state[i]->name); expr(dfp,"localsp_%s = localshadow;",gm->state[i]->name); } else { expr(dfp,"localsp_%s = &(%s_%s(mat,i -%d,j - %d,%s,0));",gm->state[i]->name, gm->name,shadow_main_tag, gm->state[i]->source[j]->offi,gm->state[i]->source[j]->offj,gm->state[i]->source[j]->state_source); } closebrace(dfp); } /* end of loop over all sources */ expr(dfp,"%s_%s(mat,i,j,%s) = score_%s",gm->name,matrixtag,gm->state[i]->name,gm->state[i]->name); expr(dfp,"for(k=0;k<7;k++)"); hang_expr(dfp,"%s_%s(mat,i,j,%s,k) = localsp_%s[k]",gm->name,shadow_main_tag,gm->state[i]->name,gm->state[i]->name); for(j=0;jspec_len;j++) { auto CellState * specstate; specstate = gm->special[j]; for(k=0;klen;k++) { if( strcmp(specstate->source[k]->state_source,gm->state[i]->name) == 0) { /********************************/ /* is a special source! */ /********************************/ add_break(dfp); add_block_comment(dfp,"state %s is a source for special %s",gm->state[i]->name,specstate->name); expr(dfp,"temp_%s = score_%s + (%s) + (%s) ",gm->state[i]->name,gm->state[i]->name,specstate->source[k]->calc_expr,specstate->calc_expr == NULL ? "0" : specstate->calc_expr ); expr(dfp,"if( temp_%s > %s_%s(mat,i,j,%s) ) ",gm->state[i]->name,gm->name,specialtag,specstate->name); startbrace(dfp); expr(dfp,"%s_%s(mat,i,j,%s) = temp_%s",gm->name,specialtag,specstate->name,gm->state[i]->name); add_block_comment(dfp,"Have to push only bottem half of system here"); expr(dfp,"for(k=0;k<3;k++)"); hang_expr(dfp,"%s_%s(mat,i,j,%s,k) = %s_%s(mat,i,j,%s,k);", gm->name,shadow_special_tag, specstate->name, gm->name, specstate->source[k]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, gm->state[i]->name); /*** sort of hacky ***/ expr(dfp,"%s_%s(mat,i,j,%s,6) = temp_%s;", gm->name,shadow_special_tag, specstate->name, gm->state[i]->name); expr(dfp,"%s_%s(mat,i,j,%s,3) = i;",gm->name,shadow_special_tag,specstate->name); expr(dfp,"%s_%s(mat,i,j,%s,4) = j;",gm->name,shadow_special_tag,specstate->name); expr(dfp,"%s_%s(mat,i,j,%s,5) = %s;",gm->name,shadow_special_tag,specstate->name,gm->state[i]->name); closebrace(dfp); } } } /* end of loop over all special states */ add_block_comment(dfp,"Finished if/then/else loop for state %s",gm->state[i]->name); } /* end of loop over states */ add_break(dfp); closebrace(dfp); if( gm->specialtospecial == TRUE ) write_special_shadow_block(dfp,gm,"DC_OPT_SHADOW_MATRIX","mat","DC_OPT_SHADOW_SPECIAL","DC_OPT_SHADOW_MATRIX_SP","DC_OPT_SHADOW_SPECIAL_SP",7,TRUE,0); closebrace(dfp); add_break; expr(dfp,"free(score_pointers);"); expr(dfp,"free(shadow_pointers);"); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } %func Makes the optimised shadow matrix routine, worked out by Steve Searle - memory access is put into one array so that the routine is faster %% void optimised_shadow_GenericMatrix(DYNFILE * dfp,const GenericMatrix *gm) { int i; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"dc_optimised_start_end_calc_%s",gm->name); add_line_to_Ftext(fi->ft,"Calculates special strip, leaving start/end/score points in shadow matrix"); add_line_to_Ftext(fi->ft,"Works off specially laid out memory from steve searle"); start_function_FuncInfo(fi,dfp,"boolean dc_optimised_start_end_calc_%s(%s *mat,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"int score;"); expr(dfp,"int temp;"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int localshadow[7]"); expr(dfp,"long int total"); expr(dfp,"long int num=0"); expr(dfp,"int * score_pointers"); expr(dfp,"int * shadow_pointers"); expr(dfp,"int * localsp;"); expr(dfp,"leni = mat->%s->%s;",gm->query->name,gm->query_len); expr(dfp,"lenj = mat->%s->%s;",gm->target->name,gm->target_len); expr(dfp,"total = leni * lenj;"); add_break(dfp); expr(dfp,"score_pointers = (int *) calloc (%d * (leni + %d) * %d,sizeof(int));",gm->window_j,gm->window_i,gm->len); expr(dfp,"shadow_pointers = (int *) calloc (%d * (leni + %d) * %d * 8,sizeof(int));",gm->window_j,gm->window_i,gm->len); add_break(dfp); expr(dfp,"for(j=0;jlen;i++) { expr(dfp,"%s_DC_OPT_SHADOW_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); expr(dfp,"if( num%%1000 == 0)"); hang_expr(dfp,"log_full_error(REPORT,0,\"%%6d Cells done [%%2d%%%%%%%%]\",num,num*100/total);"); add_break(dfp); write_main_shadow_block(dfp,gm,"DC_OPT_SHADOW_MATRIX","mat","DC_OPT_SHADOW_SPECIAL","DC_OPT_SHADOW_MATRIX_SP","DC_OPT_SHADOW_SPECIAL_SP",7,TRUE,TRUE,0,TRUE); add_break(dfp); closebrace(dfp); if( gm->specialtospecial == TRUE ) write_special_shadow_block(dfp,gm,"DC_OPT_SHADOW_MATRIX","mat","DC_OPT_SHADOW_SPECIAL","DC_OPT_SHADOW_MATRIX_SP","DC_OPT_SHADOW_SPECIAL_SP",7,TRUE,0); closebrace(dfp); add_break; expr(dfp,"free(score_pointers);"); expr(dfp,"free(shadow_pointers);"); /* expr(dfp,"free(mat->basematrix->optimised_shadow);"); */ expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } void write_start_end_build(DYNFILE * dfp,GenericMatrix * gm) { int i; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"dc_start_end_calculate_%s",gm->name); add_line_to_Ftext(fi->ft,"Calculates special strip, leaving start/end/score points in the shadow matrix "); add_line_to_Ftext(fi->ft,"One tricky thing is that we need to add score-independent calcs in the states"); add_line_to_Ftext(fi->ft,"As we have to evaluate them then. This is not ideally implemented therefore "); add_line_to_Ftext(fi->ft,"In fact it is *definitely* not ideal. Will have to do for now"); start_function_FuncInfo(fi,dfp,"boolean dc_start_end_calculate_%s(%s * mat,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"int score;"); expr(dfp,"int temp;"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int localshadow[7]"); expr(dfp,"long int total"); expr(dfp,"long int num=0"); add_break(dfp); expr(dfp,"init_start_end_linear_%s(mat)",gm->name); add_break(dfp); expr(dfp,"leni = mat->%s->%s;",gm->query->name,gm->query_len); expr(dfp,"lenj = mat->%s->%s;",gm->target->name,gm->target_len); expr(dfp,"total = leni * lenj;"); add_break(dfp); expr(dfp,"for(j=0;jlen;i++) { expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); expr(dfp,"if( num%%1000 == 0)"); hang_expr(dfp,"log_full_error(REPORT,0,\"%%6d Cells done [%%2d%%%%%%%%]\",num,num*100/total);"); add_break(dfp); write_main_shadow_block(dfp,gm,"DC_SHADOW_MATRIX","mat","DC_SHADOW_SPECIAL","DC_SHADOW_MATRIX_SP","DC_SHADOW_SPECIAL_SP",7,TRUE,TRUE,0,FALSE); add_break(dfp); closebrace(dfp); if( gm->specialtospecial == TRUE ) write_special_shadow_block(dfp,gm,"DC_SHADOW_MATRIX","mat","DC_SHADOW_SPECIAL","DC_SHADOW_MATRIX_SP","DC_SHADOW_SPECIAL_SP",7,TRUE,0); closebrace(dfp); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } void write_start_end_macros(DYNFILE * dfp,GenericMatrix * gm) { macro(dfp,"#define %s_SE_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+%d)*2) %% %d][(i+%d)*%d+state])",gm->name,gm->window_j+1,(gm->window_j+1)*2,gm->window_i,gm->len); macro(dfp,"#define %s_SE_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*2][(j+%d)])",gm->name,gm->window_j); macro(dfp,"#define %s_SE_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[( (((j+%d)*2)+(shadow+1)) %% %d)][(i+%d)*%d + state])",gm->name,gm->window_j+1,(gm->window_j+1)*2,gm->window_i,gm->len); macro(dfp,"#define %s_SE_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*2 +(shadow+1)][(j+%d)])",gm->name,gm->window_j); add_break(dfp); } void write_shadow_start_end_alloc(DYNFILE * dfp,GenericMatrix * gm) { start_function(dfp,"%s * shadow_se_alloc_%s(int leni,int lenj)",gm->name,gm->name); expr(dfp,"register %s * out",gm->name); add_break(dfp); add_block_comment(dfp,"Have to have enough memory to hold start for each state"); add_break(dfp); add_block_comment(dfp,"This means we need (window_j+1)*2 top line pointers by cell number * leni"); add_break(dfp); expr(dfp,"out = %s_alloc()",gm->name); expr(dfp,"if(out == NULL)"); hang_expr(dfp,"return NULL;"); add_end_comment(dfp,"warning already issued"); add_break(dfp); expr(dfp,"out->basematrix = BaseMatrix_alloc_matrix_and_specials(%d,(leni + %d) * %d,%d,lenj+%d)",(gm->window_j+1)*2,gm->window_i,gm->len,gm->spec_len*2,gm->window_j); expr(dfp,"if(out->basematrix == NULL)"); startbrace(dfp); expr(dfp,"warn(\"In shadow_dc_alloc_%s unable to allocate basematrix with main matrix %d by %%d ints\",(leni+%d)*%d);",gm->name,(gm->window_j+1)*2,gm->window_i,gm->len); expr(dfp,"free_%s(out)",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } %func The core inner loop for shadow methods. Pretty terrifying stuff in here. Shadow is considered to be in the memory shadow_main_tag and shadow_special_tag and usually has the form MATRIX_TYPE_MAIN/SPECIAL_SP. shadow has positions 0-length-1, as defined by shadow_length. These are indexed by k. Either shadow_on_special is false Some other routine has to place the shadow pointers. This routine just propagates the shadow pointers around Or if shadow_on_special is true This routines pushes when it leaves special and also pushes when it enters special. This way, special states have the necessary information to know where in the main matrix they were made from. Means there must be 7 shadow positions. In addition, as a complete mess, shadow on special needs to have score independent calcs added onto each movement, otherwise the scores are incorrect. So... this is not *IDEAL* in the slightest!!! %% void write_main_shadow_block(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointer_tag,char * specialtag,char * shadow_main_tag,char * shadow_special_tag,int shadow_length,boolean shadow_on_special,boolean use_special,int debug,int use_shadow_pointer) { register int i; register int j; register int k; /*** this function assummes the following local variables int score int temp int k int localshadow[SHADOW_LENGTH] int * localsp ***/ if( shadow_on_special == TRUE && shadow_length != 7) warn("In writing main shadow block [main matrix tag %s], attempting to push on specials, and yet shadow_length is %d",matrixtag,shadow_length); if( shadow_on_special == TRUE && use_special == FALSE ) { fatal("Look, you can't shaodw on special but not being using the specials... get otta here"); } for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; add_break(dfp); add_block_comment(dfp,"For state %s",state->name); add_block_comment(dfp,"setting first movement to score",state->name); /*********************************************************************/ /* this line looks like */ /* score = ProteinMatrix_EXPL_MATRIX(mat,i-1,j-1,MATCH) + xxxxx */ /*********************************************************************/ if( shadow_on_special ) expr(dfp,"score = %s_%s(%s,i-%d,j-%d,%s) + %s + (%s)",gm->name,matrixtag,pointer_tag, state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source, state->source[0]->calc_expr,state->calc_expr == NULL ? "0" : state->calc_expr); else expr(dfp,"score = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,matrixtag,pointer_tag, state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source, state->source[0]->calc_expr); /*** must also shift shadown positions ***/ if( use_shadow_pointer == FALSE ) { add_block_comment(dfp,"shift first shadow numbers"); expr(dfp,"for(k=0;k<%d;k++)",shadow_length); hang_expr(dfp,"localshadow[k] = %s_%s(mat,i - %d,j - %d,%s,k);", gm->name,state->source[0]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source); } else { add_block_comment(dfp,"assign local shadown pointer"); expr(dfp,"localsp = &(%s_%s(mat,i - %d,j - %d,%s,0));", gm->name,state->source[0]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source); } /**** ok this is to stop underflow, but is v.v.v. hacky ****/ /*** removing underflow hack expr(dfp,"if(score < (-10000000) )"); hang_expr(dfp,"score = (-10000000)"); ****/ /****************************************/ /* now we do if then on score and temp */ /****************************************/ for(j=1;jlen;j++) { if( use_special == FALSE && state->source[j]->isspecial == TRUE ) continue; add_block_comment(dfp,"From state %s to state %s",state->source[j]->state_source, state->name); /*** ok, really nasty piece coming up: The expr is going to change wrt to things a) using special or not (which will require source independent score to be added) b) special source or not. Hence the nested if. Ugh. ***/ if( shadow_on_special ) { /** add in source-independent score **/ if( state->source[j]->isspecial == TRUE ) expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s + (%s)",gm->name,specialtag,pointer_tag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr,state->calc_expr == NULL ? "0" : state->calc_expr); else expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s +(%s)",gm->name,matrixtag,pointer_tag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr,state->calc_expr == NULL ? "0" : state->calc_expr); } else { if( state->source[j]->isspecial == TRUE ) expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,specialtag,pointer_tag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr); else expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,matrixtag,pointer_tag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr); } /**** ok this is to stop underflow, but is v.v.v. hacky ****/ /**** removing underflow hack expr(dfp,"if(score < (-10000000) )"); hang_expr(dfp,"score = (-10000000)"); ****/ if( debug == 2 ) expr(dfp,"fprintf(stderr,\"[%%4d,%%4d] Score of %s from %s gets %%d\\n\",i,j,temp)",state->name,state->source[j]->state_source ); expr(dfp,"if( temp > score )"); startbrace(dfp); expr(dfp,"score = temp;"); /** ok for shadow matrix should put things in here */ if( shadow_on_special == TRUE && state->source[j]->isspecial == TRUE) { add_block_comment(dfp,"This state [%s] is a special for %s... push top shadow pointers here",state->source[j]->state_source,state->name); expr(dfp,"localshadow[0]= i;"); expr(dfp,"localshadow[1]= j;"); expr(dfp,"localshadow[2]= %s;",state->name); expr(dfp,"localshadow[3]= (-1);"); expr(dfp,"localshadow[4]= (-1);"); expr(dfp,"localshadow[5]= (-1);"); expr(dfp,"localshadow[6]= score;"); if( use_shadow_pointer == TRUE ) { expr(dfp,"localsp = localshadow;"); } } else { if( use_shadow_pointer == FALSE ) { expr(dfp,"for(k=0;k<%d;k++)",shadow_length); hang_expr(dfp,"localshadow[k] = %s_%s(mat,i - %d,j - %d,%s,k);", gm->name,state->source[0]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source); /*** now using local shadow system hang_expr(dfp,"%s_%s(%s,i,j,%s,k) = %s_%s(%s,i - %d,j - %d,%s,k);", gm->name,shadow_main_tag,pointer_tag,state->name, gm->name,state->source[j]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag,pointer_tag,state->source[j]->offi, state->source[j]->offj,state->source[j]->state_source); ***/ } else { add_block_comment(dfp,"assign local shadown pointer"); expr(dfp,"localsp = &(%s_%s(mat,i - %d,j - %d,%s,0));", gm->name,state->source[j]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source); } } /*** end if score > temp ***/ closebrace(dfp); } /************************/ /* finished blocks */ /* put in global calc */ /************************/ add_break(dfp); add_block_comment(dfp,"Ok - finished max calculation for %s",state->name); add_block_comment(dfp,"Add any movement independant score and put away"); if( shadow_on_special ) add_block_comment(dfp,"Actually, already done inside scores"); else if( state->calc_expr != NULL) expr(dfp," score += %s",state->calc_expr); /***************************/ /* put away score */ /***************************/ expr(dfp," %s_%s(%s,i,j,%s) = score;",gm->name,matrixtag,pointer_tag,state->name); /***************************/ /* put away localshadow */ /***************************/ if( use_shadow_pointer == FALSE ) { expr(dfp,"for(k=0;k<%d;k++)",shadow_length); hang_expr(dfp,"%s_%s(%s,i,j,%s,k) = localshadow[k];",gm->name,shadow_main_tag,pointer_tag,state->name); } else { expr(dfp,"for(k=0;k<%d;k++)",shadow_length); hang_expr(dfp,"%s_%s(%s,i,j,%s,k) = localsp[k];",gm->name,shadow_main_tag,pointer_tag,state->name); } add_block_comment(dfp,"Now figure out if any specials need this score"); if( use_special == FALSE ) { add_block_comment(dfp,"Finished calculating state %s",state->name); continue; /** back to for i over state **/ } /************************/ /* for each special */ /* thats has this as */ /* source we have to */ /* update */ /************************/ for(j=0;jspec_len;j++) { auto CellState * specstate; specstate = gm->special[j]; for(k=0;klen;k++) { if( strcmp(specstate->source[k]->state_source,state->name) == 0) { /********************************/ /* is a special source! */ /********************************/ add_break(dfp); add_block_comment(dfp,"state %s is a source for special %s",state->name,specstate->name); expr(dfp,"temp = score + (%s) + (%s) ",specstate->source[k]->calc_expr,specstate->calc_expr == NULL ? "0" : specstate->calc_expr ); expr(dfp,"if( temp > %s_%s(%s,i,j,%s) ) ",gm->name,specialtag,pointer_tag,specstate->name); startbrace(dfp); expr(dfp,"%s_%s(%s,i,j,%s) = temp",gm->name,specialtag,pointer_tag,specstate->name); if(shadow_on_special == TRUE ) { add_block_comment(dfp,"Have to push only bottem half of system here"); expr(dfp,"for(k=0;k<3;k++)"); hang_expr(dfp,"%s_%s(%s,i,j,%s,k) = %s_%s(%s,i,j,%s,k);", gm->name,shadow_special_tag,pointer_tag, specstate->name, gm->name, specstate->source[k]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, pointer_tag,state->name); /*** sort of hacky ***/ expr(dfp,"%s_%s(%s,i,j,%s,6) = %s_%s(%s,i,j,%s,6);", gm->name,shadow_special_tag,pointer_tag, specstate->name, gm->name, specstate->source[k]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, pointer_tag,state->name); expr(dfp,"%s_%s(%s,i,j,%s,3) = i;",gm->name,shadow_special_tag,pointer_tag,specstate->name); expr(dfp,"%s_%s(%s,i,j,%s,4) = j;",gm->name,shadow_special_tag,pointer_tag,specstate->name); expr(dfp,"%s_%s(%s,i,j,%s,5) = %s;",gm->name,shadow_special_tag,pointer_tag,specstate->name,state->name); } else { /** not pushing on specials, pushing elsewhere **/ expr(dfp,"for(k=0;k<%d;k++)",shadow_length); hang_expr(dfp,"%s_%s(%s,i,j,%s,k) = %s_%s(%s,i,j,%s,k);",gm->name,shadow_special_tag,pointer_tag, specstate->name, gm->name,specstate->source[k]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, pointer_tag,state->name); } closebrace(dfp); add_break(dfp); } } } add_break(dfp); add_block_comment(dfp,"Finished calculating state %s",state->name); } /* end of for each state */ } void write_special_shadow_block(DYNFILE * dfp,GenericMatrix * gm,char * matrix,char * pointer_tag,char * special,char * shadow_main_tag,char * shadow_special_tag,int shadow_length,boolean shadow_on_special,int debug) { register int i; register int j; for(i=0;ispec_len;i++) { auto CellState * state; state = gm->special[i]; add_break(dfp); if( state->specialtospecial == FALSE ) { add_block_comment(dfp,"Special state %s has no special to special movements",state->name); continue; } add_block_comment(dfp,"Special state %s has special to speical",state->name); add_block_comment(dfp,"Set score to current score (remember, state probably updated during main loop"); expr(dfp,"score = %s_%s(mat,0,j,%s);",gm->name,special,state->name); add_break(dfp); for(j=0;j < state->len;j++) { auto CellSource * source; source = state->source[j]; if( source->isspecial == FALSE ) { add_block_comment(dfp,"Source %s for state %s is not special... already calculated",source->state_source,state->name); continue; /** back to for j **/ } add_block_comment(dfp,"Source %s is a special source for %s",source->state_source,state->name); expr(dfp,"temp = %s_%s(%s,0,j - %d,%s) + (%s) + (%s)",gm->name,special,pointer_tag,source->offj,source->state_source, source->calc_expr,state->calc_expr == NULL ? "0" : state->calc_expr); expr(dfp,"if( temp > score )"); startbrace(dfp); expr(dfp,"score = temp"); add_block_comment(dfp,"Also got to propagate shadows "); expr(dfp,"for(k=0;k<%d;k++)",shadow_length); hang_expr(dfp,"%s_%s(%s,i,j,%s,k) = %s_%s(%s,i - %d,j - %d,%s,k);", gm->name,shadow_special_tag,pointer_tag,state->name, gm->name,shadow_special_tag,pointer_tag,state->source[j]->offi, state->source[j]->offj,state->source[j]->state_source); closebrace(dfp); add_break(dfp); } add_block_comment(dfp,"Put back score... (now updated!)"); expr(dfp,"%s_%s(mat,0,j,%s) = score;",gm->name,special,state->name); add_block_comment(dfp,"Finished updating state %s",state->name); add_break(dfp); } } %} wise-2.4.1/src/dyc/makefile0000644000175000001440000000274710413710424015125 0ustar philippusers .SUFFIXES : .dy WISECOBJ = dyna2.o dynfile.o wisec.o dynafunc.o module.o type.o method.o dynadb.o friend.o \ inputfile.o variable.o modulefunc.o api.o display.o dynashadow.o labelmaster.o ftext.o funcinfo.o \ objectinfo.o exprtree.o compugen.o docugen.o input.o dpimpl.o dbthread.o probal.o telegraph.o dynadebug.o dyshatter.o test : calc.y calc.l exprtree.o type.o yacc -d -t calc.y lex calc.l cc $(CFLAGS) y.tab.c cc $(CFLAGS) lex.yy.c cc -o test y.tab.o lex.yy.o type.o exprtree.o -ll -ly -lwisebase $(LFLAGS) # module.o sometime! # frontend.o taken out # CFLAGS = -c -g -DUNIX -I ~/local/prog/hmmer-1.8.1/ CC = cc CFLAGS = -pthread -c -g -DUNIX -I../base/ #CFLAGS = -c -g -DUNIX -DNOERROR -DLINUX -I../base/ #CFLAGS = -c -DNOERROR INCFLAGS = -I../base/ LFLAGS = -g -lm -L../base/ -lpthread AR_OPTIONS = ru RANLIB_NEEDED = 0 # # Base library build - call wisebase # linux : dyc.o $(WISECOBJ) flex calc.l $(CC) -DLINUX -c -I../base/ y.tab.c $(CC) -DLINUX -c -I../base/ lex.yy.c $(CC) -o dyc dyc.o $(WISECOBJ) y.tab.o lex.yy.o -lwisebase $(LFLAGS) dyc : dyc.o $(WISECOBJ) y.tab.o lex.yy.o $(CC) -o dyc dyc.o $(WISECOBJ) y.tab.o lex.yy.o -ll -lwisebase $(LFLAGS) yacc : yacc -d -t calc.y lex calc.l # # Suffix rules. # DFLAGS = -l .c.o : $(CC) $(CFLAGS) $(INCFLAGS) $? .dy.o : dyc $(DFLAGS) $< $(CC) $(CFLAGS) $*.c .dy.c : dyc $(DFLAGS) $< init : dyc $(DFLAGS) *.dy # # pro2DNAmatrix.c pro2DNAmatrix.h : pro2DNAmatrix.dy # dy pro2DNAmatrix.dy wise-2.4.1/src/dyc/dbthread.c0000644000175000001440000004656610670453715015371 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dbthread.h" /* Function: write_thread_struct(dfp,dpi,gm) * * Descrip: writes out thread structure * for the use in the loop code * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 21 "dbthread.dy" boolean write_thread_struct(DYNFILE * dfp,DPImplementation * dpi,GenericMatrix * gm) { int i; boolean qdb = FALSE; boolean tdb = FALSE; if( gm->qtype != NULL && gm->qtype->is_database == TRUE) { if( gm->qtype->is_thread_safe == FALSE ) { warn("Query is a database but not using a thread safe library. Can't use it!"); return FALSE; } else { qdb = TRUE; } } if( gm->ttype != NULL && gm->ttype->is_database == TRUE) { if( gm->ttype->is_thread_safe == FALSE) { warn("Target is a database but not using a thread safe library. Can't use it!"); return FALSE; } else { tdb = TRUE; } } fprintf(dfp->head,"#ifdef PTHREAD\n"); start_struct(dfp,"struct thread_pool_holder_%s",gm->name); if( qdb == FALSE ) { /* static query data structure common to all */ struct_expr(dfp,"%s %s;",gm->query->element_type,gm->query->name); add_end_comment_header(dfp,"Static query data: never free'd"); } else { struct_expr(dfp,"%s %s;",gm->qtype->real,gm->query->name); add_end_comment_header(dfp,"Query object placeholder"); struct_expr(dfp,"%s querydb;",gm->qtype->database_type); add_end_comment_header(dfp,"Query database object"); struct_expr(dfp,"boolean query_init;"); } if( tdb == FALSE ) { /* static query data structure common to all */ struct_expr(dfp,"%s %s;",gm->target->element_type,gm->target->name); add_end_comment_header(dfp,"Static target data: never free'd"); } else { struct_expr(dfp,"%s %s;",gm->ttype->real,gm->target->name); add_end_comment_header(dfp,"Target object placeholder"); struct_expr(dfp,"%s targetdb;",gm->ttype->database_type); add_end_comment_header(dfp,"Target database object"); struct_expr(dfp,"boolean target_init;"); } /* now add all the resources */ for(i=0;ires_len;i++) { struct_expr(dfp,"%s %s",gm->resource[i]->element_type,gm->resource[i]->name); } /* now add mutex's */ struct_expr(dfp,"pthread_mutex_t input_lock"); struct_expr(dfp,"pthread_mutex_t output_lock"); /* add output */ struct_expr(dfp,"Hscore * out"); /* add pthread_t */ struct_expr(dfp,"pthread_t * pool;"); struct_expr(dfp,"int number_of_threads;"); struct_expr(dfp,"boolean search_has_ended;"); if( dpi->db_trace_level > 0 ) { struct_expr(dfp,"DBSearchImpl * dbsi"); } /* close structure */ close_struct(dfp,";"); fprintf(dfp->head,"#endif /* PTHREAD */\n"); return TRUE; } /* Function: write_thread_loop(dfp,dpi,gm) * * Descrip: Major loop for each thread. * * This function is really complicated by the way * dynamite databases work - in particular the init * function returns an object, so we have to keep * track for each database if we need to init or not. * * Secondly we have to get out the information for * each query and target regardless of whether they will * score over the default or not. To do this we need * to rely on the datascore storage allocator to be * able to accept frees (annoying or what!). * * Here is the pseudo code for both a query or target db * * forever { * get input lock * if( search ended ) { * unlock input lock * break; * } * * get datascore datatstructure * * if( query not init ) * init query * hard link query * read query info into datastructure * * if( target not init ) * init target * else * reload target * * if ( end of the target database ) * free query data structure -- we have got it hard_linked! * reload query database into holder * if( end of the query database ) * flag search finished * unlock input lock * else * close target database * set target to be initiated -- by next thread * unlock input lock * else * unlock input lock * * do score * * if( should store ) * get output lock * add data score * else * get input lock (otherwise clash with datascore storage allocator) * return data score back to storage * unlock input lock * } * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 165 "dbthread.dy" boolean write_thread_loop(DYNFILE * dfp,DPImplementation * dpi,GenericMatrix * gm) { FuncInfo * fi; boolean tdb,qdb; char * pre; int do_dummy = 0; tdb= qdb = FALSE; if( gm->qtype == NULL || gm->ttype == NULL ) { warn("No database types - must have dbtypes for pthreads support"); do_dummy =1 ; } if( gm->qtype != NULL && gm->qtype->is_database == TRUE) if( gm->qtype->is_thread_safe == FALSE) { warn("Query is a database but not using a thread safe library. Can't use it!"); do_dummy = 1; } else { qdb = TRUE; } if( gm->ttype != NULL && gm->ttype->is_database == TRUE) if( gm->ttype->is_thread_safe == FALSE) { warn("Target is a database but not using a thread safe library. Can't use it!"); do_dummy = 1; } else { tdb = TRUE; } if( do_dummy == 1 ) { fi = FuncInfo_named_from_varstr(FI_INTERNAL,"thread_loop_%s",gm->name); add_line_to_Ftext(fi->ft,"dummy loop code foreach thread for %s",gm->name); start_function_FuncInfo(fi,dfp,"void * thread_loop_%s(void * ptr)",gm->name); expr(dfp,"fatal(\"dummy thread loop function\");"); close_function(dfp); add_break(dfp); return FALSE; } fi = FuncInfo_named_from_varstr(FI_INTERNAL,"thread_loop_%s",gm->name); add_line_to_Ftext(fi->ft,"Infinite loop code foreach thread for %s",gm->name); macro(dfp,"#ifdef PTHREAD"); start_function_FuncInfo(fi,dfp,"void * thread_loop_%s(void * ptr)",gm->name); expr(dfp,"struct thread_pool_holder_%s * holder",gm->name); expr(dfp,"int db_status"); expr(dfp,"int score"); expr(dfp,"DataScore * ds;"); expr(dfp,"%s %s",gm->query->element_type,gm->query->name); expr(dfp,"%s %s",gm->target->element_type,gm->target->name); add_break(dfp); expr(dfp,"holder = (struct thread_pool_holder_%s *) ptr;",gm->name); if( dpi->db_trace_level >= 1 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 1 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Entering infinite loop for thread...\\n\");"); } add_break(dfp); expr(dfp,"while(1)"); startbrace_tag(dfp,"Infinite loop over all models"); add_block_comment(dfp,"Get input lock"); add_break(dfp); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"About to get input lock for main reload\\n\");"); } expr(dfp,"if( pthread_mutex_lock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error on getting input lock for %s\");",gm->name); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Got input lock for main reload\\n\");"); } add_break(dfp); expr(dfp,"if( holder->search_has_ended == TRUE )"); startbrace(dfp); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Database search finished for me!...\\n\");"); } expr(dfp,"if( pthread_mutex_unlock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error in releasing input lock for %s\");",gm->name); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Released lock and broken out of loop\\n\");"); } expr(dfp,"break;"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Get storage space now, as we have to read in the info for the db now"); if( dpi->db_trace_level >= 3 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 3 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Getting new DataScore from storage...\\n\");"); } expr(dfp,"ds = new_DataScore();"); /* if there is a target database, read from it */ if( tdb == TRUE ) { if( qdb == TRUE ) { /* both query and target db */ add_break(dfp); add_block_comment(dfp,"We need to get our query object"); if( dpi->db_trace_level >= 3 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 3 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Starting query database...\\n\");"); } add_break(dfp); expr(dfp,"if( holder->query_init == FALSE)"); startbrace(dfp); expr(dfp,"holder->%s = %s(holder->querydb,&db_status);",gm->query->name,gm->qtype->init_func); expr(dfp,"holder->query_init = TRUE;"); expr(dfp,"if( db_status == DB_RETURN_ERROR )"); hang_expr(dfp,"fatal(\"Unable to initalise query database in %s search\");",gm->name); closebrace(dfp); expr(dfp,"%s = %s(holder->%s);",gm->query->name,gm->qtype->hard_link_func,gm->query->name); add_block_comment(dfp,"get query information into datascore"); expr(dfp,"%s(ds->query,%s,holder->querydb);",gm->qtype->dataentry_add,gm->query->name); } add_break(dfp); expr(dfp,"if( holder->target_init == FALSE )"); startbrace_tag(dfp,"if the db has not been init'd"); if( dpi->db_trace_level >= 3 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 3 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Starting target database...\\n\");"); } expr(dfp,"%s = %s(holder->targetdb,&db_status);",gm->target->name,gm->ttype->init_func); expr(dfp,"holder->target_init = TRUE;"); closebrace(dfp); expr(dfp,"else"); startbrace_tag(dfp,"Normal reload"); expr(dfp," %s = %s(NULL,holder->targetdb,&db_status)",gm->target->name,gm->ttype->reload_func); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Check to see what the reload is like"); add_break(dfp); expr(dfp,"if( db_status == DB_RETURN_ERROR )"); startbrace(dfp); expr(dfp,"fatal(\"In searching %s, Reload error on database %s, in threads\");",gm->name,gm->target->name); closebrace(dfp); if( qdb == TRUE ) { /* both query and target db */ add_break(dfp); expr(dfp,"if( db_status == DB_RETURN_END)"); startbrace_tag(dfp,"End of target database"); add_block_comment(dfp,"close target database and schedule it for initalisation by next thread"); expr(dfp,"%s(NULL,holder->targetdb);",gm->ttype->close_func); expr(dfp,"holder->target_init = FALSE;"); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Target Database to be reloaded...\\n\");"); } add_break(dfp); add_block_comment(dfp,"free'ing the query object"); expr(dfp,"%s(holder->%s);",gm->qtype->free_func,gm->query->name); add_block_comment(dfp,"get the next query object for the next thread"); expr(dfp,"holder->%s = %s(NULL,holder->querydb,&db_status);",gm->query->name,gm->qtype->reload_func); expr(dfp,"if( db_status == DB_RETURN_ERROR )"); hang_expr(dfp,"fatal(\"In searching %s, reload error on database %s, in threads\");",gm->name,gm->query->name); expr(dfp,"if( db_status == DB_RETURN_END )"); startbrace_tag(dfp,"last load!"); add_block_comment(dfp,"End of target and query database - finished search!"); expr(dfp,"%s(NULL,holder->querydb);",gm->qtype->close_func); expr(dfp,"holder->search_has_ended = TRUE;"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"release input mutex"); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Releasing input lock after end of target\\n\");"); } expr(dfp,"if( pthread_mutex_unlock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error in releasing input lock for %s\");",gm->name); expr(dfp,"continue;"); closebrace(dfp); /* end of if at end ! */ expr(dfp,"else "); startbrace_tag(dfp,"Normal reload"); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Releasing input lock for normal reload\\n\");"); } expr(dfp,"if( pthread_mutex_unlock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error in releasing input lock for %s\");",gm->name); closebrace(dfp); /* end of if at end ! */ add_block_comment(dfp,"get target information into datascore"); expr(dfp,"%s(ds->target,%s,holder->targetdb);",gm->ttype->dataentry_add,gm->target->name); } else { /* targetdb but no querydb */ expr(dfp,"if( db_status == DB_RETURN_END)"); startbrace_tag(dfp,"End of target database"); expr(dfp,"holder->search_has_ended = TRUE;"); expr(dfp,"%s(NULL,holder->targetdb)",gm->ttype->close_func); add_block_comment(dfp,"release input mutex"); expr(dfp,"if( pthread_mutex_unlock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error in releasing input lock for %s\");",gm->name); closebrace(dfp); /* end of if at end ! */ } } else { /* querydb but no targetdb */ expr(dfp,"if( holder->query_init == FALSE )"); startbrace_tag(dfp,"if the db has not been init'd"); expr(dfp,"%s = %s(holder->querydb,&db_status);",gm->query->name,gm->qtype->init_func); expr(dfp,"holder->query_init = TRUE;"); closebrace(dfp); expr(dfp,"else"); startbrace_tag(dfp,"Normal reload"); expr(dfp," %s = %s(NULL,holder->querydb,&db_status)",gm->query->name,gm->qtype->reload_func); closebrace(dfp); add_block_comment(dfp,"Check to see what the reload is like"); expr(dfp,"if( db_status == DB_RETURN_ERROR )"); startbrace(dfp); expr(dfp,"fatal(\"In searching %s, Reload error on database %s, in threads\");",gm->name,gm->query->name); closebrace(dfp); expr(dfp,"if( db_status == DB_RETURN_END)"); startbrace_tag(dfp,"End of query database"); expr(dfp,"holder->search_has_ended = TRUE;"); expr(dfp,"%s(NULL,holder->querydb)",gm->qtype->close_func); add_block_comment(dfp,"release input mutex"); expr(dfp,"if( pthread_mutex_unlock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error in releasing input lock for %s\");",gm->name); closebrace(dfp); /* end of if at end ! */ add_block_comment(dfp,"get query information into datascore"); expr(dfp,"%s(ds->query,%s,holder->querydb);",gm->qtype->dataentry_add,gm->query->name); } add_break(dfp); add_block_comment(dfp,"Now there is a new query/target pair ready for comparison"); if( dpi->db_trace_level >= 1 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 1 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"A new pair to be compared...\\n\");"); } pre = get_pre_chainstr_GenericMatrix("holder->",gm); expr(dfp,"score = score_only_%s(%s)",gm->name,pre); ckfree(pre); add_break(dfp); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Getting output lock\\n\");"); } add_block_comment(dfp,"Getting lock on output"); expr(dfp,"if( pthread_mutex_lock(&(holder->output_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error on getting output lock for %s\");",gm->name); add_block_comment(dfp,"If the score is less than cutoff, schedule the datascore for reuse"); expr(dfp,"if( should_store_Hscore(holder->out,score) != TRUE)"); startbrace(dfp); expr(dfp,"free_DataScore(ds)"); closebrace(dfp); expr(dfp,"else"); startbrace_tag(dfp,"storing score"); expr(dfp,"ds->score = score"); expr(dfp,"add_Hscore(holder->out,ds)"); closebrace(dfp); expr(dfp,"if( pthread_mutex_unlock(&(holder->output_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error on releasing output lock for %s\");",gm->name); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Released output lock\\n\");"); } add_break(dfp); add_block_comment(dfp,"Now free database objects"); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"About to get input lock for free func\\n\");"); } expr(dfp,"if( pthread_mutex_lock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error on getting input lock for %s\");",gm->name); if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Got input lock for free func\\n\");"); } if( qdb == TRUE ) { expr(dfp,"%s(%s);",gm->qtype->free_func,gm->query->name); } if( tdb == TRUE ) { expr(dfp,"%s(%s);",gm->ttype->free_func,gm->target->name); } if( dpi->db_trace_level >= 2 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 2 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Releasing input lock after free'ing\\n\");"); } expr(dfp,"if( pthread_mutex_unlock(&(holder->input_lock))!= 0 )"); hang_expr(dfp,"fatal(\"Error in releasing input lock for %s\");",gm->name); closebrace(dfp); /* back to while */ add_break(dfp); if( dpi->db_trace_level >= 1 ) { expr(dfp,"if ( holder->dbsi->trace_level >= 1 )"); hang_expr(dfp,"fprintf(holder->dbsi->trace_file,\"Exiting forever loop\\n\");"); } expr(dfp,"return NULL;"); close_function(dfp); add_break(dfp); macro(dfp,"#endif /* PTHREAD */"); return 1; } /* Function: get_pre_chainstr_GenericMatrix(pre,gm) * * Descrip: makes an the argument calling string which * is compatible with the arg_str from * get_argstr_GenericMatrix, but with a * pre placement in it * * eg "query,target,holder->comp_mat" * * * Arg: pre [UNKN ] Undocumented argument [const char *] * Arg: gm [READ ] structure holding generic matrix [const GenericMatrix *] * * Return [UNKN ] allocated string (must free) with chained-args [char *] * */ # line 545 "dbthread.dy" char * get_pre_chainstr_GenericMatrix(const char * pre,const GenericMatrix * gm) { char buffer[MAXLINE]; int i; sprintf(buffer,"%s, %s ",gm->query->name,gm->target->name); for(i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,pre); strcat(buffer,gm->resource[i]->name); } return stringalloc(buffer); } # line 579 "dbthread.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/dbthread.h0000644000175000001440000001044210670453715015356 0ustar philippusers#ifndef DYNAMITEdbthreadHEADERFILE #define DYNAMITEdbthreadHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna2.h" #include "dpimpl.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: write_thread_struct(dfp,dpi,gm) * * Descrip: writes out thread structure * for the use in the loop code * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean write_thread_struct(DYNFILE * dfp,DPImplementation * dpi,GenericMatrix * gm); /* Function: write_thread_loop(dfp,dpi,gm) * * Descrip: Major loop for each thread. * * This function is really complicated by the way * dynamite databases work - in particular the init * function returns an object, so we have to keep * track for each database if we need to init or not. * * Secondly we have to get out the information for * each query and target regardless of whether they will * score over the default or not. To do this we need * to rely on the datascore storage allocator to be * able to accept frees (annoying or what!). * * Here is the pseudo code for both a query or target db * * forever { * get input lock * if( search ended ) { * unlock input lock * break; * } * * get datascore datatstructure * * if( query not init ) * init query * hard link query * read query info into datastructure * * if( target not init ) * init target * else * reload target * * if ( end of the target database ) * free query data structure -- we have got it hard_linked! * reload query database into holder * if( end of the query database ) * flag search finished * unlock input lock * else * close target database * set target to be initiated -- by next thread * unlock input lock * else * unlock input lock * * do score * * if( should store ) * get output lock * add data score * else * get input lock (otherwise clash with datascore storage allocator) * return data score back to storage * unlock input lock * } * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean write_thread_loop(DYNFILE * dfp,DPImplementation * dpi,GenericMatrix * gm); /* Function: get_pre_chainstr_GenericMatrix(pre,gm) * * Descrip: makes an the argument calling string which * is compatible with the arg_str from * get_argstr_GenericMatrix, but with a * pre placement in it * * eg "query,target,holder->comp_mat" * * * Arg: pre [UNKN ] Undocumented argument [const char *] * Arg: gm [READ ] structure holding generic matrix [const GenericMatrix *] * * Return [UNKN ] allocated string (must free) with chained-args [char *] * */ char * get_pre_chainstr_GenericMatrix(const char * pre,const GenericMatrix * gm); /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/docugen.c0000644000175000001440000001735407313404533015223 0ustar philippusers#include "compugen.h" /* * This function is passed in as a pointer to a function to * strcat_ExprTree_Scoped found in type.c * * It terminates the parse in the node which statisifies the * k position (the range looping system) * */ boolean place_k_loop(ExprTree * node,char * buffer,void * data) { OneModelTrans * trans; trans = (OneModelTrans * )data; if( trans->wseq_node_to_replace == node ) { if( trans->map_func == NULL ) { strcat(buffer,"k"); } else { strcat(buffer,trans->map_func); strcat(buffer,"(k)"); } return TRUE; } return FALSE; } boolean write_cugen_model(OneModel *om,DYNFILE * dfp) { FuncInfo * fi; char tprf[CUGEN_MAX_PRF_NUM_LEN+1], w_base[CUGEN_MAX_PRF_NUM_LEN+1]; char * tseq, * wseq; int i; /*** prepare function information ***/ fi = FuncInfo_named_from_varstr(FI_CALLABLE,"write_OneModel_model_%s",om->name); add_line_to_Ftext(fi->ft,"This function writes the onemodel datastructure",om->name); add_break_to_Ftext(fi->ft); add_break_to_Ftext(fi->ft); start_function_FuncInfo(fi,dfp,"boolean write_OneModel_model_%s(FILE * ofp)",om->name); add_break(dfp); expr(dfp,"fprintf(ofp,\"DY_MODEL : %s;\\n\");",om->name); expr(dfp,"fprintf(ofp,\"data_types : %s;\\n\");",om->datatype_str); if ( om->statenames[0] == NULL ) { warn ( "There are no states in the model" ); return FALSE; } expr(dfp,"fprintf(ofp,\"state_names = { %s\");",om->statenames[0]); for ( i = 1; (i < CUGEN_MAX_STATE_NAMES) && (om->statenames[i] != NULL); i++ ) expr(dfp,"fprintf(ofp,\", %s\");",om->statenames[i]); expr(dfp,"fprintf(ofp,\" };\\n\");"); if ( om->semistatenames[0] != NULL ) { expr(dfp,"fprintf(ofp,\"semistate_names = { %s\");",om->semistatenames[0]); for ( i = 1; (i < CUGEN_MAX_STATE_NAMES) && (om->semistatenames[i] != NULL); i++ ) expr(dfp,"fprintf(ofp,\", %s\");",om->semistatenames[i]); expr(dfp,"fprintf(ofp,\" };\\n\");"); } if ( om->midstatenames[0] != NULL ) { expr(dfp,"fprintf(ofp,\"midstate_names = { %s\");",om->midstatenames[0]); for ( i = 1; (i < CUGEN_MAX_STATE_NAMES) && (om->midstatenames[i] != NULL); i++ ) expr(dfp,"fprintf(ofp,\", %s\");",om->midstatenames[i]); expr(dfp,"fprintf(ofp,\" };\\n\");"); } expr(dfp,"fprintf(ofp,\"nat_query = genprof;\\n\");"); expr(dfp,"fprintf(ofp,\"line_size = %d;\\n\");", om->prof_line_len); if ( om->seqfuncs[0] != NULL ) { expr(dfp,"fprintf(ofp,\"sequence : %s\");",om->seqfuncs[0]); for ( i = 1; (i < CUGEN_MAX_FUNCS) && (om->seqfuncs[i] != NULL); i++ ) expr(dfp,"fprintf(ofp,\", %s\");",om->seqfuncs[i]); expr(dfp,"fprintf(ofp,\";\\n\");"); } expr(dfp,"fprintf(ofp,\"dy_transition from to dx dy t_prf dprf t_seq dseq w_base w_seq dwx dwy xlabel ylabel\\n\");"); for ( i = 0; (i < CUGEN_MAX_ONEMODEL_TRANS) && (om->trans[i] != NULL); i++ ) { if ( (om->trans[i]->tprf != NULL) || (om->trans[i]->tpos_tprf == om->prof_line_len - 1) ) sprintf ( tprf, "%d", om->trans[i]->tpos_tprf ); else strcpy ( tprf, "-" ); if ( om->trans[i]->tseq == NULL ) tseq = "-"; else tseq = om->trans[i]->tseq; if ( om->trans[i]->wprf == NULL ) strcpy ( w_base, "-" ); else sprintf ( w_base, "%d", om->trans[i]->tpos_wprf ); if ( om->trans[i]->wseq == NULL ) wseq = "-"; else wseq = om->trans[i]->wseq; expr(dfp,"fprintf(ofp,\"%-13s %-10s %-10s %2d %2d %-5s %4d %-10s %4d %-6s %-10s %3d %3d %-10s %-10s\\n\");", om->trans[i]->name, om->trans[i]->from_state, om->trans[i]->to_state, om->trans[i]->dx, om->trans[i]->dy, tprf, om->trans[i]->dprf, tseq, om->trans[i]->dseq, w_base, wseq, om->trans[i]->dwx, om->trans[i]->dwy, om->trans[i]->xlabel, om->trans[i]->ylabel); } expr(dfp,"fprintf(ofp,\"end_transition\\n\");"); expr(dfp,"fprintf(ofp,\"endmodel\\n\");"); close_function(dfp); add_break(dfp); return TRUE; } boolean write_cugen_profile(OneModel * om,MethodTypeSet * mts,DYNFILE * dfp) { FuncInfo * fi; char buffer[MAXLINE]; /* place to put strcat function */ int i; int range; /*** prepare function information ***/ fi = FuncInfo_named_from_varstr(FI_CALLABLE,"write_OneModel_profile_%s",om->name); add_line_to_Ftext(fi->ft,"This function writes the onemodel datastructure",om->name); add_break_to_Ftext(fi->ft); add_break_to_Ftext(fi->ft); /* add_args_GenericMatrix_FuncInfo(fi,om->arg_str); */ start_function_FuncInfo(fi,dfp,"boolean write_OneModel_profile_%s(%s * mat,FILE * ofp)",om->name,om->name); /* expr(dfp,"%s * mat",om->name); */ expr(dfp,"int genericprofile[%d];", om->prof_line_len); expr(dfp,"int i,j,k;"); /** started function, now see what basematrix says about memory **/ add_break(dfp); /* expr(dfp,"mat = allocate_%s_only(%s);",om->name,om->chain_str); */ expr(dfp,"fprintf(ofp,\"#DYNAMITE\\n\");"); expr(dfp,"fprintf(ofp,\"%d\\n\");", om->prof_line_len); expr(dfp,"for(i=0;ileni;i++)"); startbrace_tag(dfp,"Over all positions in query"); /* Filling in the 4*states_num first places of the profile */ expr(dfp,"genericprofile [%d] = %d;", OM_TMPSTART, 0); expr(dfp,"genericprofile [%d] = %d;", OM_TMPSTART+1, 0); expr(dfp,"genericprofile [%d] = %d;", OM_TMPSTART+2, CUGEN_MININF); expr(dfp,"genericprofile [%d] = %d;", OM_TMPSTART+3, CUGEN_MININF); expr(dfp,"genericprofile [%d] = %d;", OM_TMPEND*4, CUGEN_MININF); expr(dfp,"genericprofile [%d] = %d;", OM_TMPEND*4+1, CUGEN_MININF); expr(dfp,"genericprofile [%d] = %d;", OM_TMPEND*4+2, 0); expr(dfp,"genericprofile [%d] = %d;", OM_TMPEND*4+3, 0); expr(dfp,"for(j=%d;j<%d;j++)", 4 * OM_TMP_STATES_NUM, 4 * (om->states_num + om->semistates_num)); hang_expr(dfp,"genericprofile [j] = %d;", CUGEN_MININF); for(i=0;om->trans[i] != NULL;i++) { auto OneModelTrans * trans = om->trans[i]; add_block_comment(dfp,"Doing state %s to %s",trans->from_state,trans->to_state); /* we already have the component parts! Hurray! */ if( trans->tprf != NULL ) { buffer[0] ='\0'; if(strcat_ExprTree_Scoped(trans->tprf,buffer,om->sc,mts,NULL,NULL,NULL) == 1 ) { warn("Parse error in building compugen generic profile structure"); return FALSE; } /* if( range != 1 ) { warn("You have a tprf line with a range != 1. Ooops! [%d]",range); } */ /* simply allocate it to this tpos */ expr(dfp,"genericprofile [%d] = %s;",trans->tpos_tprf,buffer); } buffer[0]='\0'; range = -1; if( trans->wprf != NULL ) { if( strcat_ExprTree_Scoped(trans->wprf,buffer,om->sc,mts,NULL,place_k_loop,(void *)trans) == 1 ) { warn("Parse error in building compugen generic profile structure"); return FALSE; } /* loop over the range. It has already been entered as k */ expr(dfp,"for(k=0;k<%d;k++)",trans->range); hang_expr(dfp,"genericprofile [%d+k] = %s;",trans->tpos_wprf,buffer); } } expr(dfp,"genericprofile [%d] = %d;", om->prof_line_len - 1, CUGEN_MININF); expr(dfp,"fprintf(ofp,\"a\");"); expr(dfp,"for(j=0;j<%d;j++)", om->prof_line_len); startbrace(dfp); expr(dfp,"fprintf(ofp,\" %%.2f\", (float)(genericprofile[j]));"); expr(dfp,"if( j%%20 == 0 && j != 0)"); hang_expr(dfp,"fprintf(ofp,\"\\n\");"); closebrace(dfp); /* loop over the print out */ expr(dfp,"fprintf(ofp,\"\\n\");"); closebrace(dfp); /* the loop over i */ close_function(dfp); add_break(dfp); return TRUE; } boolean write_cugen_funcs(OneModel * om,MethodTypeSet * mts,DYNFILE * dfp) { boolean ret = TRUE; Scope * sc; sc = std_Dynamite_Scope(); if( write_cugen_model(om,dfp) == FALSE ) { ret = FALSE; } if( write_cugen_profile(om,mts,dfp) == FALSE ) { ret = FALSE; } return ret; } wise-2.4.1/src/dyc/y.tab.c0000644000175000001440000004556010413710424014606 0ustar philippusers # line 3 "calc.y" #include #include "exprtree.h" extern ExprTree * root; extern char * calc_lex_string; extern int stringpos; # line 12 "calc.y" typedef union { double dval; struct ExprTree * tr; } YYSTYPE; # define NAME 257 # define NUMBER 258 # define STRUCTREF 259 # define DEREFERENCE 260 #define yyclearin yychar = -1 #define yyerrok yyerrflag = 0 extern int yychar; extern int yyerrflag; #ifndef YYMAXDEPTH #define YYMAXDEPTH 150 #endif YYSTYPE yylval, yyval; typedef int yytabelem; # define YYERRCODE 256 # line 72 "calc.y" #ifdef YYWRAP_NEEDED void yywrap(void) { fprintf(stderr,"In yywrap... going to exit badly"); exit(1); } #endif void yyerror(char * s) { /*** stringpos is position along the string ***/ int i; warn("Calc line parser error: [%s]",s); fprintf(stderr,"Occured at:\n"); fprintf(stderr,"%s\n",calc_lex_string); for(i=0;i= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ {\ yyerror( "syntax error - cannot backup" );\ goto yyerrlab;\ }\ yychar = newtoken;\ yystate = *yyps;\ yylval = newvalue;\ goto yynewstate;\ } #define YYRECOVERING() (!!yyerrflag) #ifndef YYDEBUG # define YYDEBUG 1 /* make debugging available */ #endif /* ** user known globals */ int yydebug; /* set to 1 to get debugging */ /* ** driver internal defines */ #define YYFLAG (-1000) #ifdef YYSPLIT # define YYSCODE { \ extern int (*yyf[])(); \ register int yyret; \ if (yyf[yytmp]) \ if ((yyret=(*yyf[yytmp])()) == -2) \ goto yyerrlab; \ else if (yyret>=0) return(yyret); \ } #endif /* ** local variables used by the parser * these should be static in order to support * multiple parsers in a single executable program. POSIX 1003.2-1993 */ static YYSTYPE yyv[ YYMAXDEPTH ]; /* value stack */ static int yys[ YYMAXDEPTH ]; /* state stack */ static YYSTYPE *yypv; /* top of value stack */ static YYSTYPE *yypvt; /* top of value stack for $vars */ static int *yyps; /* top of state stack */ static int yystate; /* current state */ static int yytmp; /* extra var (lasts between blocks) */ /* ** global variables used by the parser - renamed as a result of -p */ int yynerrs; /* number of errors */ int yyerrflag; /* error recovery flag */ int yychar; /* current input token number */ /* ** yyparse - return 0 if worked, 1 if syntax error not recovered from */ int yyparse() { /* ** Initialize externals - yyparse may be called more than once */ yypv = &yyv[-1]; yyps = &yys[-1]; yystate = 0; yytmp = 0; yynerrs = 0; yyerrflag = 0; yychar = -1; goto yystack; { register YYSTYPE *yy_pv; /* top of value stack */ register int *yy_ps; /* top of state stack */ register int yy_state; /* current state */ register int yy_n; /* internal state number info */ /* ** get globals into registers. ** branch to here only if YYBACKUP was called. */ yynewstate: yy_pv = yypv; yy_ps = yyps; yy_state = yystate; goto yy_newstate; /* ** get globals into registers. ** either we just started, or we just finished a reduction */ yystack: yy_pv = yypv; yy_ps = yyps; yy_state = yystate; /* ** top of for (;;) loop while no reductions done */ yy_stack: /* ** put a state and value onto the stacks */ #if YYDEBUG /* ** if debugging, look up token value in list of value vs. ** name pairs. 0 and negative (-1) are special values. ** Note: linear search is used since time is not a real ** consideration while debugging. */ if ( yydebug ) { register int yy_i; printf( "State %d, token ", yy_state ); if ( yychar == 0 ) printf( "end-of-file\n" ); else if ( yychar < 0 ) printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) break; } printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ++yy_ps >= &yys[ YYMAXDEPTH ] ) /* room on stack? */ { yyerror( "yacc stack overflow" ); YYABORT; } *yy_ps = yy_state; *++yy_pv = yyval; /* ** we have a new state - find out what to do */ yy_newstate: if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) goto yydefault; /* simple state */ #if YYDEBUG /* ** if debugging, need to mark whether new token grabbed */ yytmp = yychar < 0; #endif if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) yychar = 0; /* reached EOF */ #if YYDEBUG if ( yydebug && yytmp ) { register int yy_i; printf( "Received token " ); if ( yychar == 0 ) printf( "end-of-file\n" ); else if ( yychar < 0 ) printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) break; } printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) || (yyact[yy_n ] < 0)) goto yydefault; if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ { yychar = -1; yyval = yylval; yy_state = yy_n; if ( yyerrflag > 0 ) yyerrflag--; goto yy_stack; } yydefault: if ( ( yy_n = yydef[ yy_state ] ) == -2 ) { #if YYDEBUG yytmp = yychar < 0; #endif if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) yychar = 0; /* reached EOF */ #if YYDEBUG if ( yydebug && yytmp ) { register int yy_i; printf( "Received token " ); if ( yychar == 0 ) printf( "end-of-file\n" ); else if ( yychar < 0 ) printf( "-none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) { break; } } printf( "%s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ /* ** look through exception table */ { register const int *yyxi = yyexca; while ( ( *yyxi != -1 ) || ( yyxi[1] != yy_state ) ) { yyxi += 2; } while ( ( *(yyxi += 2) >= 0 ) && ( *yyxi != yychar ) ) ; if ( ( yy_n = yyxi[1] ) < 0 ) YYACCEPT; } } /* ** check for syntax error */ if ( yy_n == 0 ) /* have an error */ { /* no worry about speed here! */ switch ( yyerrflag ) { case 0: /* new error */ yyerror( "syntax error" ); goto skip_init; yyerrlab: /* ** get globals into registers. ** we have a user generated syntax type error */ yy_pv = yypv; yy_ps = yyps; yy_state = yystate; yynerrs++; skip_init: case 1: case 2: /* incompletely recovered error */ /* try again... */ yyerrflag = 3; /* ** find state where "error" is a legal ** shift action */ while ( yy_ps >= yys ) { yy_n = yypact[ *yy_ps ] + YYERRCODE; if ( yy_n >= 0 && yy_n < YYLAST && yychk[yyact[yy_n]] == YYERRCODE) { /* ** simulate shift of "error" */ yy_state = yyact[ yy_n ]; goto yy_stack; } /* ** current state has no shift on ** "error", pop stack */ #if YYDEBUG # define _POP_ "Error recovery pops state %d, uncovers state %d\n" if ( yydebug ) printf( _POP_, *yy_ps, yy_ps[-1] ); # undef _POP_ #endif yy_ps--; yy_pv--; } /* ** there is no state on stack with "error" as ** a valid shift. give up. */ YYABORT; case 3: /* no shift yet; eat a token */ #if YYDEBUG /* ** if debugging, look up token in list of ** pairs. 0 and negative shouldn't occur, ** but since timing doesn't matter when ** debugging, it doesn't hurt to leave the ** tests here. */ if ( yydebug ) { register int yy_i; printf( "Error recovery discards " ); if ( yychar == 0 ) printf( "token end-of-file\n" ); else if ( yychar < 0 ) printf( "token -none-\n" ); else { for ( yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++ ) { if ( yytoks[yy_i].t_val == yychar ) { break; } } printf( "token %s\n", yytoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( yychar == 0 ) /* reached EOF. quit */ YYABORT; yychar = -1; goto yy_newstate; } }/* end if ( yy_n == 0 ) */ /* ** reduction by production yy_n ** put stack tops, etc. so things right after switch */ #if YYDEBUG /* ** if debugging, print the string that is the user's ** specification of the reduction which is just about ** to be done. */ if ( yydebug ) printf( "Reduce by (%d) \"%s\"\n", yy_n, yyreds[ yy_n ] ); #endif yytmp = yy_n; /* value to switch over */ yypvt = yy_pv; /* $vars top of value stack */ /* ** Look in goto table for next state ** Sorry about using yy_state here as temporary ** register variable, but why not, if it works... ** If yyr2[ yy_n ] doesn't have the low order bit ** set, then there is no action to be done for ** this reduction. So, no saving & unsaving of ** registers done. The only difference between the ** code just after the if and the body of the if is ** the goto yy_stack in the body. This way the test ** can be made before the choice of what to do is needed. */ { /* length of production doubled with extra bit */ register int yy_len = yyr2[ yy_n ]; if ( !( yy_len & 01 ) ) { yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } goto yy_stack; } yy_len >>= 1; yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) { yy_state = yyact[ yypgo[ yy_n ] ]; } } /* save until reenter driver code */ yystate = yy_state; yyps = yy_ps; yypv = yy_pv; } /* ** code supplied by user is placed in this switch */ switch(yytmp){ case 1: /* statement : expression */ # line 25 "calc.y" { yyval.tr = new_ExprTree(); yyval.tr->type = ETR_STATEMENT; yyval.tr->child[0] = yypvt[-0].tr; yyval.tr->nochild=1; root = yyval.tr; parentfy_ExprTree(root); } /*NOTREACHED*/ break; case 2: /* method : tag '(' commalist ')' */ # line 36 "calc.y" { yyval.tr = new_ExprTree_method(yypvt[-3].tr,yypvt[-1].tr); } /*NOTREACHED*/ break; case 3: /* method : tag '(' ')' */ # line 39 "calc.y" { yyval.tr = new_ExprTree_method(yypvt[-2].tr,NULL); } /*NOTREACHED*/ break; case 4: /* expression : expression '+' expression */ # line 44 "calc.y" { yyval.tr = new_ExprTree_binary_expr(yypvt[-2].tr,'+',yypvt[-0].tr); } /*NOTREACHED*/ break; case 5: /* expression : expression '-' expression */ # line 47 "calc.y" { yyval.tr = new_ExprTree_binary_expr(yypvt[-2].tr,'-',yypvt[-0].tr); } /*NOTREACHED*/ break; case 6: /* expression : expression '*' expression */ # line 50 "calc.y" { yyval.tr = new_ExprTree_binary_expr(yypvt[-2].tr,'*',yypvt[-0].tr); } /*NOTREACHED*/ break; case 7: /* expression : expression '/' expression */ # line 53 "calc.y" { yyval.tr = new_ExprTree_binary_expr(yypvt[-2].tr,'/',yypvt[-0].tr); } /*NOTREACHED*/ break; case 8: /* expression : '(' expression ')' */ # line 56 "calc.y" { yyval.tr = yypvt[-1].tr; } /*NOTREACHED*/ break; case 9: /* expression : NUMBER */ # line 57 "calc.y" { yyval.tr = yypvt[-0].tr; } /*NOTREACHED*/ break; case 10: /* expression : tag */ # line 58 "calc.y" { yyval.tr = yypvt[-0].tr; } /*NOTREACHED*/ break; case 11: /* expression : method */ # line 59 "calc.y" { yyval.tr = yypvt[-0].tr; } /*NOTREACHED*/ break; case 12: /* commalist : commalist ',' expression */ # line 62 "calc.y" { yyval.tr = add_to_commalist_ExprTree(yypvt[-2].tr,yypvt[-0].tr); } /*NOTREACHED*/ break; case 13: /* commalist : expression */ # line 63 "calc.y" { yyval.tr = new_ExprTree_commalist(yypvt[-0].tr); } /*NOTREACHED*/ break; case 14: /* tag : NAME */ # line 66 "calc.y" { yyval.tr = new_ExprTree_tag_from_name(yypvt[-0].tr); } /*NOTREACHED*/ break; case 15: /* tag : tag STRUCTREF tag */ # line 67 "calc.y" { yyval.tr = new_ExprTree_struct_ref(yypvt[-2].tr,yypvt[-1].tr,yypvt[-0].tr); } /*NOTREACHED*/ break; case 16: /* tag : tag '[' expression ']' */ # line 68 "calc.y" { yyval.tr = new_ExprTree_array(yypvt[-3].tr,yypvt[-1].tr); } /*NOTREACHED*/ break; case 17: /* tag : '&' tag */ # line 69 "calc.y" { yyval.tr = new_ExprTree_ref('*',yypvt[-0].tr); } /*NOTREACHED*/ break; case 18: /* tag : '*' tag */ # line 70 "calc.y" { yyval.tr = new_ExprTree_ref('*',yypvt[-0].tr); } /*NOTREACHED*/ break; } goto yystack; /* reset registers in driver code */ } wise-2.4.1/src/dyc/y.tab.h0000644000175000001440000000026007644512135014612 0ustar philippusers typedef union { double dval; struct ExprTree * tr; } YYSTYPE; extern YYSTYPE yylval; # define NAME 257 # define NUMBER 258 # define STRUCTREF 259 # define DEREFERENCE 260 wise-2.4.1/src/dyc/telegraph.dy0000644000175000001440000000171607313404535015741 0ustar philippusers %{ #include "dyna2.h" %} %{ #include "telegraph.h" %func Write out a telegraph pseudo-grammar %% void write_Telegraph_grammar(GenericMatrix *gm,FILE *ofp) { int i; int j; int k; fprintf(ofp,"/* pseudo-grammar generated from dynamite */\n"); fprintf(ofp,"\n"); fprintf(ofp,"grammar %s {\n\n",gm->name); for(i=0;ilen;i++) { fprintf(ofp," state %s;\n",gm->state[i]->name); } fprintf(ofp,"\n\n"); for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { fprintf(ofp," %12s -> ",gm->state[i]->source[j]->state_source); for(k=0;k < gm->state[i]->source[j]->offi;k++) { fprintf(ofp,"Q"); } fprintf(ofp," "); for(k=0;k < gm->state[i]->source[j]->offj;k++) { fprintf(ofp,"T"); } fprintf(ofp," %12s { %s + %s};\n",gm->state[i]->name,gm->state[i]->source[j]->source_expr,gm->state[i]->source_expr == NULL ? "0" : gm->state[i]->source_expr); } } fprintf(ofp,"\n\n}\n\n"); } wise-2.4.1/src/dyc/labelmaster.c0000644000175000001440000006363310670453715016101 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "labelmaster.h" # line 43 "labelmaster.dy" char * quoted_string_from_Label(Label ** list,int len) { char buf[512]; char buffer[2048]; int i; sprintf(buffer,"\"%s\"",list[0]->name); for(i=1;iname); strcat(buffer,buf); } return stringalloc(buffer); } # line 60 "labelmaster.dy" char * query_quoted_string_from_LabelMaster(LabelMaster * lm) { return quoted_string_from_Label(lm->query,lm->query_len); } # line 65 "labelmaster.dy" char * target_quoted_string_from_LabelMaster(LabelMaster * lm) { return quoted_string_from_Label(lm->target,lm->target_len); } # line 71 "labelmaster.dy" int index_for_label(char * name,Label ** list,int len) { int i; for(i=0;iname,name) == 0) return i; } return -1; } # line 84 "labelmaster.dy" int index_for_query_label(char * name,LabelMaster * lm) { return index_for_label(name,lm->query,lm->query_len); } # line 89 "labelmaster.dy" int index_for_target_label(char * name,LabelMaster * lm) { return index_for_label(name,lm->target,lm->target_len); } # line 95 "labelmaster.dy" Label * target_Label_from_name(LabelMaster * lm,char * name) { register int i; for(i=0;itarget_len;i++) { if( strcmp(name,lm->target[i]->name) == 0 ) return lm->target[i]; } return NULL; } # line 107 "labelmaster.dy" Label * query_Label_from_name(LabelMaster * lm,char * name) { register int i; for(i=0;iquery_len;i++) { if( strcmp(name,lm->query[i]->name) == 0 ) return lm->query[i]; } return NULL; } # line 120 "labelmaster.dy" LabelMaster * LabelMaster_from_GenericMatrix(GenericMatrix * gm) { register int i; register int j; CellState * state; LabelMaster * out; out = LabelMaster_alloc_std(); for(i=0;ilen;i++) { state = gm->state[i]; for(j=0;jlen;j++) add_CellSource_to_LabelMaster(out,state->source[j],state->name); } for(i=0;ispec_len;i++) { state = gm->special[i]; for(j=0;jlen;j++) add_CellSource_to_LabelMaster(out,state->source[j],state->name); } return out; } # line 148 "labelmaster.dy" boolean add_CellSource_to_LabelMaster(LabelMaster * lm,CellSource * cs,char * state) { Label * temp; LabelInstance * li; li = LabelInstance_from_CellSource(state,cs); if( cs->query_label != NULL ) { if( (temp=query_Label_from_name(lm,cs->query_label)) == NULL ) { temp = new_query_Label(cs->query_label); add_query_LabelMaster(lm,temp); } add_Label(temp,li); } li = LabelInstance_from_CellSource(state,cs); if( cs->target_label != NULL ) { if( (temp=target_Label_from_name(lm,cs->target_label)) == NULL ) { temp = new_target_Label(cs->target_label); add_target_LabelMaster(lm,temp); } add_Label(temp,li); } return TRUE; } # line 181 "labelmaster.dy" Label * new_query_Label(char * name) { Label * out; out = Label_alloc_std(); out->name = stringalloc(name); out->type = LMQUERYTYPE; return out; } # line 193 "labelmaster.dy" Label * new_target_Label(char * name) { Label * out; out = Label_alloc_std(); out->name = stringalloc(name); out->type = LMTARGETTYPE; return out; } # line 206 "labelmaster.dy" LabelInstance * LabelInstance_from_CellSource(char * state,CellSource * cs) { LabelInstance * out; out = LabelInstance_alloc(); out->state = stringalloc(state); out->source = cs->state_source; out->offi = cs->offi; out->offj = cs->offj; return out; } # line 202 "labelmaster.c" /* Function: hard_link_LabelInstance(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LabelInstance *] * * Return [UNKN ] Undocumented return value [LabelInstance *] * */ LabelInstance * hard_link_LabelInstance(LabelInstance * obj) { if( obj == NULL ) { warn("Trying to hard link to a LabelInstance object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LabelInstance_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LabelInstance *] * */ LabelInstance * LabelInstance_alloc(void) { LabelInstance * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LabelInstance *) ckalloc (sizeof(LabelInstance))) == NULL) { warn("LabelInstance_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->state = NULL; out->source = NULL; out->offi = 0; out->offj = 0; out->calc_line = NULL; return out; } /* Function: free_LabelInstance(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LabelInstance *] * * Return [UNKN ] Undocumented return value [LabelInstance *] * */ LabelInstance * free_LabelInstance(LabelInstance * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LabelInstance obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->state != NULL) ckfree(obj->state); if( obj->source != NULL) ckfree(obj->source); if( obj->calc_line != NULL) ckfree(obj->calc_line); ckfree(obj); return NULL; } /* Function: swap_Label(list,i,j) * * Descrip: swap function: an internal for qsort_Label * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [LabelInstance **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Label(LabelInstance ** list,int i,int j) { LabelInstance * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Label(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Label which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [LabelInstance **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Label(LabelInstance ** list,int left,int right,int (*comp)(LabelInstance * ,LabelInstance * )) { int i,last; if( left >= right ) return; swap_Label(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Label (list,++last,i); } swap_Label (list,left,last); qsort_Label(list,left,last-1,comp); qsort_Label(list,last+1,right,comp); } /* Function: sort_Label(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Label * * * Arg: obj [UNKN ] Object containing list [Label *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Label(Label * obj,int (*comp)(LabelInstance *, LabelInstance *)) { qsort_Label(obj->li,0,obj->len-1,comp); return; } /* Function: expand_Label(obj,len) * * Descrip: Really an internal function for add_Label * * * Arg: obj [UNKN ] Object which contains the list [Label *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Label(Label * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Label called with no need"); return TRUE; } if( (obj->li = (LabelInstance ** ) ckrealloc (obj->li,sizeof(LabelInstance *)*len)) == NULL) { warn("ckrealloc failed for expand_Label, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Label(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Label *] * Arg: add [OWNER] Object to add to the list [LabelInstance *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Label(Label * obj,LabelInstance * add) { if( obj->len >= obj->maxlen) { if( expand_Label(obj,obj->len + LabelLISTLENGTH) == FALSE) return FALSE; } obj->li[obj->len++]=add; return TRUE; } /* Function: flush_Label(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Label *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Label(Label * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->li[i] != NULL) { free_LabelInstance(obj->li[i]); obj->li[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: Label_alloc_std(void) * * Descrip: Equivalent to Label_alloc_len(LabelLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Label *] * */ Label * Label_alloc_std(void) { return Label_alloc_len(LabelLISTLENGTH); } /* Function: Label_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Label *] * */ Label * Label_alloc_len(int len) { Label * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Label_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->li = (LabelInstance ** ) ckcalloc (len,sizeof(LabelInstance *))) == NULL) { warn("Warning, ckcalloc failed in Label_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_Label(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Label *] * * Return [UNKN ] Undocumented return value [Label *] * */ Label * hard_link_Label(Label * obj) { if( obj == NULL ) { warn("Trying to hard link to a Label object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Label_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Label *] * */ Label * Label_alloc(void) { Label * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Label *) ckalloc (sizeof(Label))) == NULL) { warn("Label_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->type = 0; out->li = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_Label(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Label *] * * Return [UNKN ] Undocumented return value [Label *] * */ Label * free_Label(Label * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Label obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->li != NULL) { for(i=0;ilen;i++) { if( obj->li[i] != NULL) free_LabelInstance(obj->li[i]); } ckfree(obj->li); } ckfree(obj); return NULL; } /* Function: swap_query_LabelMaster(list,i,j) * * Descrip: swap function: an internal for qsort_query_LabelMaster * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Label **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_query_LabelMaster(Label ** list,int i,int j) { Label * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_query_LabelMaster(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_query_LabelMaster which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Label **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_query_LabelMaster(Label ** list,int left,int right,int (*comp)(Label * ,Label * )) { int i,last; if( left >= right ) return; swap_query_LabelMaster(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_query_LabelMaster (list,++last,i); } swap_query_LabelMaster (list,left,last); qsort_query_LabelMaster(list,left,last-1,comp); qsort_query_LabelMaster(list,last+1,right,comp); } /* Function: sort_query_LabelMaster(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_query_LabelMaster * * * Arg: obj [UNKN ] Object containing list [LabelMaster *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_query_LabelMaster(LabelMaster * obj,int (*comp)(Label *, Label *)) { qsort_query_LabelMaster(obj->query,0,obj->query_len-1,comp); return; } /* Function: expand_query_LabelMaster(obj,len) * * Descrip: Really an internal function for add_query_LabelMaster * * * Arg: obj [UNKN ] Object which contains the list [LabelMaster *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_query_LabelMaster(LabelMaster * obj,int len) { if( obj->query_maxlen > obj->query_len ) { warn("expand_LabelMasterquery_ called with no need"); return TRUE; } if( (obj->query = (Label ** ) ckrealloc (obj->query,sizeof(Label *)*len)) == NULL) { warn("ckrealloc failed for expand_LabelMaster, returning FALSE"); return FALSE; } obj->query_maxlen = len; return TRUE; } /* Function: add_query_LabelMaster(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LabelMaster *] * Arg: add [OWNER] Object to add to the list [Label *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_query_LabelMaster(LabelMaster * obj,Label * add) { if( obj->query_len >= obj->query_maxlen) { if( expand_query_LabelMaster(obj,obj->query_len + LabelMasterLISTLENGTH) == FALSE) return FALSE; } obj->query[obj->query_len++]=add; return TRUE; } /* Function: flush_query_LabelMaster(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LabelMaster *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_query_LabelMaster(LabelMaster * obj) { int i; for(i=0;iquery_len;i++) { /*for i over list length*/ if( obj->query[i] != NULL) { free_Label(obj->query[i]); obj->query[i] = NULL; } } /* end of for i over list length */ obj->query_len = 0; return i; } /* Function: swap_target_LabelMaster(list,i,j) * * Descrip: swap function: an internal for qsort_target_LabelMaster * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Label **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_target_LabelMaster(Label ** list,int i,int j) { Label * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_target_LabelMaster(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_target_LabelMaster which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Label **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_target_LabelMaster(Label ** list,int left,int right,int (*comp)(Label * ,Label * )) { int i,last; if( left >= right ) return; swap_target_LabelMaster(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_target_LabelMaster (list,++last,i); } swap_target_LabelMaster (list,left,last); qsort_target_LabelMaster(list,left,last-1,comp); qsort_target_LabelMaster(list,last+1,right,comp); } /* Function: sort_target_LabelMaster(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_target_LabelMaster * * * Arg: obj [UNKN ] Object containing list [LabelMaster *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_target_LabelMaster(LabelMaster * obj,int (*comp)(Label *, Label *)) { qsort_target_LabelMaster(obj->target,0,obj->target_len-1,comp); return; } /* Function: expand_target_LabelMaster(obj,len) * * Descrip: Really an internal function for add_target_LabelMaster * * * Arg: obj [UNKN ] Object which contains the list [LabelMaster *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_target_LabelMaster(LabelMaster * obj,int len) { if( obj->target_maxlen > obj->target_len ) { warn("expand_LabelMastertarget_ called with no need"); return TRUE; } if( (obj->target = (Label ** ) ckrealloc (obj->target,sizeof(Label *)*len)) == NULL) { warn("ckrealloc failed for expand_LabelMaster, returning FALSE"); return FALSE; } obj->target_maxlen = len; return TRUE; } /* Function: add_target_LabelMaster(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LabelMaster *] * Arg: add [OWNER] Object to add to the list [Label *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_target_LabelMaster(LabelMaster * obj,Label * add) { if( obj->target_len >= obj->target_maxlen) { if( expand_target_LabelMaster(obj,obj->target_len + LabelMasterLISTLENGTH) == FALSE) return FALSE; } obj->target[obj->target_len++]=add; return TRUE; } /* Function: flush_target_LabelMaster(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LabelMaster *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_target_LabelMaster(LabelMaster * obj) { int i; for(i=0;itarget_len;i++) { /*for i over list length*/ if( obj->target[i] != NULL) { free_Label(obj->target[i]); obj->target[i] = NULL; } } /* end of for i over list length */ obj->target_len = 0; return i; } /* Function: LabelMaster_alloc_std(void) * * Descrip: Equivalent to LabelMaster_alloc_len(LabelMasterLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [LabelMaster *] * */ LabelMaster * LabelMaster_alloc_std(void) { return LabelMaster_alloc_len(LabelMasterLISTLENGTH); } /* Function: LabelMaster_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [LabelMaster *] * */ LabelMaster * LabelMaster_alloc_len(int len) { LabelMaster * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = LabelMaster_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->query = (Label ** ) ckcalloc (len,sizeof(Label *))) == NULL) { warn("Warning, ckcalloc failed in LabelMaster_alloc_len"); return NULL; } out->query_len = 0; out->query_maxlen = len; if((out->target = (Label ** ) ckcalloc (len,sizeof(Label *))) == NULL) { warn("Warning, ckcalloc failed in LabelMaster_alloc_len"); return NULL; } out->target_len = 0; out->target_maxlen = len; return out; } /* Function: hard_link_LabelMaster(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LabelMaster *] * * Return [UNKN ] Undocumented return value [LabelMaster *] * */ LabelMaster * hard_link_LabelMaster(LabelMaster * obj) { if( obj == NULL ) { warn("Trying to hard link to a LabelMaster object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LabelMaster_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LabelMaster *] * */ LabelMaster * LabelMaster_alloc(void) { LabelMaster * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LabelMaster *) ckalloc (sizeof(LabelMaster))) == NULL) { warn("LabelMaster_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->query = NULL; out->query_len = out->query_maxlen = 0; out->target = NULL; out->target_len = out->target_maxlen = 0; return out; } /* Function: free_LabelMaster(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LabelMaster *] * * Return [UNKN ] Undocumented return value [LabelMaster *] * */ LabelMaster * free_LabelMaster(LabelMaster * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LabelMaster obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->query != NULL) { for(i=0;iquery_len;i++) { if( obj->query[i] != NULL) free_Label(obj->query[i]); } ckfree(obj->query); } if( obj->target != NULL) { for(i=0;itarget_len;i++) { if( obj->target[i] != NULL) free_Label(obj->target[i]); } ckfree(obj->target); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/labelmaster.h0000644000175000001440000002355510670453715016105 0ustar philippusers#ifndef DYNAMITElabelmasterHEADERFILE #define DYNAMITElabelmasterHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "dyna2.h" #define LabelLISTLENGTH 64 #define LabelMasterLISTLENGTH 64 #define LMNOTYPE 213 #define LMQUERYTYPE 214 #define LMTARGETTYPE 215 struct LabelInstance { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * state; char * source; int offi; int offj; char * calc_line; } ; /* LabelInstance defined */ #ifndef DYNAMITE_DEFINED_LabelInstance typedef struct LabelInstance LabelInstance; #define DYNAMITE_DEFINED_LabelInstance #endif struct Label { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; int type; LabelInstance ** li; int len;/* len for above li */ int maxlen; /* maxlen for above li */ } ; /* Label defined */ #ifndef DYNAMITE_DEFINED_Label typedef struct Label Label; #define DYNAMITE_DEFINED_Label #endif struct LabelMaster { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Label ** query; int query_len; /* len for above query */ int query_maxlen; /* maxlen for above query */ Label ** target; int target_len; /* len for above target */ int target_maxlen; /* maxlen for above target */ } ; /* LabelMaster defined */ #ifndef DYNAMITE_DEFINED_LabelMaster typedef struct LabelMaster LabelMaster; #define DYNAMITE_DEFINED_LabelMaster #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_LabelInstance(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LabelInstance *] * * Return [UNKN ] Undocumented return value [LabelInstance *] * */ LabelInstance * hard_link_LabelInstance(LabelInstance * obj); /* Function: LabelInstance_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LabelInstance *] * */ LabelInstance * LabelInstance_alloc(void); /* Function: free_LabelInstance(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LabelInstance *] * * Return [UNKN ] Undocumented return value [LabelInstance *] * */ LabelInstance * free_LabelInstance(LabelInstance * obj); /* Function: add_Label(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Label *] * Arg: add [OWNER] Object to add to the list [LabelInstance *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_Label(Label * obj,LabelInstance * add); /* Function: flush_Label(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Label *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Label(Label * obj); /* Function: Label_alloc_std(void) * * Descrip: Equivalent to Label_alloc_len(LabelLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Label *] * */ Label * Label_alloc_std(void); /* Function: Label_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Label *] * */ Label * Label_alloc_len(int len); /* Function: hard_link_Label(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Label *] * * Return [UNKN ] Undocumented return value [Label *] * */ Label * hard_link_Label(Label * obj); /* Function: Label_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Label *] * */ Label * Label_alloc(void); /* Function: free_Label(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Label *] * * Return [UNKN ] Undocumented return value [Label *] * */ Label * free_Label(Label * obj); /* Function: add_query_LabelMaster(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LabelMaster *] * Arg: add [OWNER] Object to add to the list [Label *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_query_LabelMaster(LabelMaster * obj,Label * add); /* Function: flush_query_LabelMaster(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LabelMaster *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_query_LabelMaster(LabelMaster * obj); /* Function: add_target_LabelMaster(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LabelMaster *] * Arg: add [OWNER] Object to add to the list [Label *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_target_LabelMaster(LabelMaster * obj,Label * add); /* Function: flush_target_LabelMaster(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LabelMaster *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_target_LabelMaster(LabelMaster * obj); /* Function: LabelMaster_alloc_std(void) * * Descrip: Equivalent to LabelMaster_alloc_len(LabelMasterLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [LabelMaster *] * */ LabelMaster * LabelMaster_alloc_std(void); /* Function: LabelMaster_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [LabelMaster *] * */ LabelMaster * LabelMaster_alloc_len(int len); /* Function: hard_link_LabelMaster(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LabelMaster *] * * Return [UNKN ] Undocumented return value [LabelMaster *] * */ LabelMaster * hard_link_LabelMaster(LabelMaster * obj); /* Function: LabelMaster_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LabelMaster *] * */ LabelMaster * LabelMaster_alloc(void); /* Function: free_LabelMaster(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LabelMaster *] * * Return [UNKN ] Undocumented return value [LabelMaster *] * */ LabelMaster * free_LabelMaster(LabelMaster * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ char * quoted_string_from_Label(Label ** list,int len); char * query_quoted_string_from_LabelMaster(LabelMaster * lm); char * target_quoted_string_from_LabelMaster(LabelMaster * lm); int index_for_label(char * name,Label ** list,int len); int index_for_query_label(char * name,LabelMaster * lm); int index_for_target_label(char * name,LabelMaster * lm); Label * target_Label_from_name(LabelMaster * lm,char * name); Label * query_Label_from_name(LabelMaster * lm,char * name); LabelMaster * LabelMaster_from_GenericMatrix(GenericMatrix * gm); boolean add_CellSource_to_LabelMaster(LabelMaster * lm,CellSource * cs,char * state); Label * new_query_Label(char * name); Label * new_target_Label(char * name); LabelInstance * LabelInstance_from_CellSource(char * state,CellSource * cs); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void swap_Label(LabelInstance ** list,int i,int j) ; void qsort_Label(LabelInstance ** list,int left,int right,int (*comp)(LabelInstance * ,LabelInstance * )); void sort_Label(Label * obj,int (*comp)(LabelInstance *, LabelInstance *)); boolean expand_Label(Label * obj,int len); void swap_query_LabelMaster(Label ** list,int i,int j) ; void qsort_query_LabelMaster(Label ** list,int left,int right,int (*comp)(Label * ,Label * )); void sort_query_LabelMaster(LabelMaster * obj,int (*comp)(Label *, Label *)); boolean expand_query_LabelMaster(LabelMaster * obj,int len); void swap_target_LabelMaster(Label ** list,int i,int j) ; void qsort_target_LabelMaster(Label ** list,int left,int right,int (*comp)(Label * ,Label * )); void sort_target_LabelMaster(LabelMaster * obj,int (*comp)(Label *, Label *)); boolean expand_target_LabelMaster(LabelMaster * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/objectinfo.dy0000644000175000001440000000100507313404535016077 0ustar philippusers %{ #include "dynfile.h" #include "ftext.h" %} struct ObjectInfo Ftext * ft // description of Object %{ #include "objectinfo.h" int write_C_ObjectInfo(ObjectInfo * oi,FILE * ofp) { return show_eddystyle_Ftext(oi->ft,"Descrip:",10,ofp,"No Description"); } ObjectInfo * read_ObjectInfo_line_func(char * line,int maxline,FILE * ifp,char * (fgets_func)(char *,int,FILE*)) { ObjectInfo * out; out = ObjectInfo_alloc(); out->ft = read_Ftext(line,maxline,ifp,"%%",fgets_func); return out; } %} wise-2.4.1/src/dyc/api.dy0000644000175000001440000010156007313404532014532 0ustar philippusers %{ #include "dynfile.h" #include "objectinfo.h" #include "wisec.h" #define APIObjectLISTLENGTH 64 #define dynAPILISTLENGTH 64 %} struct APIfunc char * name FuncInfo * fi // hard linked boolean only_C !def="FALSE" struct APIObject char * name APIfunc * destructor APIfunc * hard_linker APIfunc ** member !list ObjectInfo * info StructHolder * sh struct dynAPI APIfunc ** non_obj !list !len="non_" APIObject ** obj !list %info This Object contains the api definition for the module. The api is used to generate a name-space clear C api and a Perl interface at the moment. %% %{ #include "api.h" boolean write_pfdoc_dynAPI(dynAPI * api,char * package_name,FILE * ofp) { int i,j; for(i=0;ilen;i++) { auto APIObject * obj; obj = api->obj[i]; fprintf(ofp,":object %s\n",obj->name); for(j=0;jlen;j++) { fprintf(ofp,"\t:func %s\n",obj->member[j]->name); } fprintf(ofp,"\t:des %s\n",obj->destructor->name); fprintf(ofp,"\n\n"); } for(j=0;jnon_len;j++) { fprintf(ofp,":func %s\n",api->non_obj[j]->name); } fprintf(ofp,"\n\n"); for(i=0;ilen;i++) { auto APIObject * obj; obj = api->obj[i]; if( obj->info != NULL ) { fprintf(ofp,"\n:define %s\n",obj->name); fprintf(ofp,":desc\n"); dump_Ftext(obj->info->ft,ofp); fprintf(ofp,"!desc\n!defined\n\n"); } for(j=0;jlen;j++) { write_pfdoc_func_def(obj->member[j]->fi,ofp); fprintf(ofp,"\n\n"); } write_pfdoc_func_def(obj->destructor->fi,ofp); fprintf(ofp,"\n\n"); } for(i=0;inon_len;i++) { write_pfdoc_func_def(api->non_obj[i]->fi,ofp); fprintf(ofp,"\n\n"); } return TRUE; } boolean write_pfdoc_func_def(FuncInfo * fi,FILE * ofp) { int i; fprintf(ofp,":define %s\n",fi->name); fprintf(ofp,":desc\n"); dump_Ftext(fi->ft,ofp); fprintf(ofp,"!desc\n"); fprintf(ofp,":arg\n"); for(i=0;ilen;i++) { fprintf(ofp,"%s [%s] %s\n",fi->arg[i]->name,fi->arg[i]->type,fi->arg[i]->desc); } fprintf(ofp,"!arg\n"); fprintf(ofp,":return\n"); fprintf(ofp,"%s [%s] %s\n",fi->ret->name,fi->ret->type,fi->ret->desc); fprintf(ofp,"!return\n"); fprintf(ofp,"!define"); return TRUE; } boolean write_latex_dynAPI(dynAPI * api,char * module,char * package,FILE * ofp) { int i,j; fprintf(ofp,"\\section{%s}\n",module); fprintf(ofp,"\\label{module_%s}\n",module); if( api->len == 0 ) { fprintf(ofp,"This module only contains factory methods\n\n"); } else { fprintf(ofp,"This module contains the following objects\n\n\\begin{itemize}\n"); for(i=0;ilen;i++) fprintf(ofp,"\\item \\ref{object_%s} %s\n\n",api->obj[i]->name,api->obj[i]->name); if( api->non_len > 0 ) { fprintf(ofp,"\\item This module also contains some factory methods\n"); } fprintf(ofp,"\\end{itemize}\n"); } if( api->non_len > 0) { fprintf(ofp,"\\subsection{%s factory methods}\n",module); for(i=0;inon_len;i++) { fprintf(ofp,"\\subsubsection{%s}\n",api->non_obj[i]->name); write_latex_APIfunc(api->non_obj[i],package,FALSE,NULL,ofp); } fprintf(ofp,"\n\n"); } for(i=0;ilen;i++) { fprintf(ofp,"\\subsection{Object %s}\n\n",api->obj[i]->name); fprintf(ofp,"\\label{object_%s}\n\n",api->obj[i]->name); fprintf(ofp,"The %s object has the following fields. To see how to access them refer to \\ref{accessing_fields}\n",api->obj[i]->name); fprintf(ofp,"\\begin{description}\n"); for(j=0;jobj[i]->sh->len;j++) { fprintf(ofp,"\\item{%s} Type [%s : %s] %s\n\n",api->obj[i]->sh->el[j]->name,api->obj[i]->sh->el[j]->element_type,api->obj[i]->sh->el[j]->islist == TRUE ? "List" : "Scalar",api->obj[i]->sh->el[j]->comment == NULL ? "No documentation" : api->obj[i]->sh->el[j]->comment); } fprintf(ofp,"\\end{description}\n"); if( api->obj[i]->info == NULL ) { fprintf(ofp,"No documentation for %s\n\n",api->obj[i]->name); } else { latex_Ftext(api->obj[i]->info->ft,ofp); fprintf(ofp,"\n\n"); } fprintf(ofp,"Member functions of %s\n\n",api->obj[i]->name); for(j=0;jobj[i]->len;j++) { if( api->obj[i]->member[j]->fi->is_hand_written == TRUE) { fprintf(ofp,"\\subsubsection{%s}\n\n",api->obj[i]->member[j]->name); write_latex_APIfunc(api->obj[i]->member[j],package,TRUE,api->obj[i]->name,ofp); } } } return TRUE; } boolean write_latex_APIfunc(APIfunc * f,char * package,boolean isobj,char * objectname,FILE * ofp) { FuncInfo * fi; int i; fi = f->fi; if( fi == NULL ) { warn("Could not make latex non API function due to no info!"); return FALSE; } fprintf(ofp,"\\begin{description}\n"); fprintf(ofp,"\\item[External C] {\\tt %s_%s (%s",package,fi->name,fi->len == 0 ? "void" : fi->arg[0]->name); if( f->only_C == TRUE ) { fprintf(ofp,"(This function is only available in the C api)"); } else { for(i=1;ilen;i++) fprintf(ofp,",%s",fi->arg[i]->name); fprintf(ofp,")}\n"); if( isobj == TRUE ) { fprintf(ofp,"\\item[Perl] {\\tt &%s::%s::%s (%s",package,objectname,fi->simple == NULL ? fi->name : fi->simple,fi->len == 0 ? "" : fi->arg[0]->name); } else { fprintf(ofp,"\\item[Perl] {\\tt &%s::%s (%s",package,fi->simple == NULL ? fi->name : fi->simple,fi->len == 0 ? "" : fi->arg[0]->name); } for(i=1;ilen;i++) { if( fi->arg[i]->should_NULL == TRUE ) continue; /* skip it out */ fprintf(ofp,",%s",fi->arg[i]->name); } fprintf(ofp,")}\n\n"); if( isobj == TRUE ) { if( fi->len == 0 ) { warn("Trying to indicate that %s is an object method when it doesn't have an argument",fi->name); } else { fprintf(ofp,"\\item[Perl-OOP call] {\\tt $obj->%s(%s",fi->simple == NULL ? fi->name : fi->simple,fi->len == 1 ? "" : fi->arg[1]->name); for(i=2;ilen;i++) { if( fi->arg[i]->should_NULL == TRUE ) continue; /* skip it out */ fprintf(ofp,",%s",fi->arg[i]->name); } fprintf(ofp,")}\n\n"); } } } /* end of is an non C based function */ fprintf(ofp,"\\end{description}\n"); fprintf(ofp,"Arguments\n\\begin{description}\n"); for(i=0;ilen;i++) { auto ArgInfo * ai; ai = fi->arg[i]; if( ai->should_NULL == TRUE ) fprintf(ofp,"\\item[%s] \\em{only for C api} [%s] %s [%s]\n",ai->name,ArgType_to_string(ai->argtype),ai->desc,CKS(ai->type)); else { fprintf(ofp,"\\item[%s] [%s] %s [%s]\n",ai->name,ArgType_to_string(ai->argtype),ai->desc,CKS(ai->type)); } } if( strcmp(fi->ret->type,"void") == 0 ) { fprintf(ofp,"\\item[returns] Nothing - no return value\n"); } else { fprintf(ofp,"\\item[returns] [%s] %s [%s]\n",ArgType_to_string(fi->ret->argtype),fi->ret->desc,CKS(fi->ret->type)); } fprintf(ofp,"\\end{description}\n"); latex_Ftext(fi->ft,ofp); return TRUE; } boolean write_pod_dynAPI(dynAPI * api,char * module,char * package,FILE * ofp) { int i,j; fprintf(ofp,"=head1 NAME\n\n%s module - part of the %s package\n\n",module,package); if( api->len == 0 ) { fprintf(ofp,"=head1 SYNOPSIS\n\nThis module contains helper functions for the %s package\n\n",package); } else { fprintf(ofp,"=head1 SYNOPSIS\n\nThis module contains the following objects\n\n=over\n\n"); for(i=0;ilen;i++) fprintf(ofp,"=item %s\n\n",api->obj[i]->name); fprintf(ofp,"\n=back\n\n"); } fprintf(ofp,"=head1 DESCRIPTION\n\n"); for(i=0;ilen;i++) { fprintf(ofp,"=head2 Object %s\n\n=over\n\n",api->obj[i]->name); for(j=0;jobj[i]->sh->len;j++) { fprintf(ofp,"=item %s\n\n Type [%s] %s %s\n\n",api->obj[i]->sh->el[j]->name,api->obj[i]->sh->el[j]->element_type,api->obj[i]->sh->el[j]->islist == TRUE ? "List" : "Scalar",api->obj[i]->sh->el[j]->comment == NULL ? "No documentation" : api->obj[i]->sh->el[j]->comment); } fprintf(ofp,"\n\n=back\n\n"); if( api->obj[i]->info == NULL ) { fprintf(ofp,"No documentation for %s\n\n",api->obj[i]->name); } else { dump_Ftext(api->obj[i]->info->ft,ofp); fprintf(ofp,"\n\n"); } fprintf(ofp,"=head2 Member functions of %s\n\n",api->obj[i]->name); fprintf(ofp,"=over\n\n"); for(j=0;jobj[i]->len;j++) { fprintf(ofp,"=item %s\n\n",api->obj[i]->member[j]->fi->simple == NULL ? api->obj[i]->member[j]->name : api->obj[i]->member[j]->fi->simple); write_pod_obj_APIfunc(api->obj[i]->member[j],package,api->obj[i]->name,ofp); } fprintf(ofp,"=back\n\n"); } if( api->non_len > 0) { fprintf(ofp,"=over\n\n"); for(i=0;inon_len;i++) { fprintf(ofp,"=item %s\n\n",api->non_obj[i]->name); write_pod_non_APIfunc(api->non_obj[i],package,ofp); } fprintf(ofp,"=back\n\n"); } return TRUE; } void write_pod_obj_APIfunc(APIfunc * f,char * package,char * obj,FILE * ofp) { FuncInfo * fi; int i; fi = f->fi; fprintf(ofp,"&%s::%s::%s(%s",package,obj,fi->simple == NULL ? fi->name : fi->simple ,fi->len == 0 ? "void" : fi->arg[0]->name); for(i=1;ilen;i++) fprintf(ofp,",%s",fi->arg[i]->name); fprintf(ofp,")\n\n"); dump_Ftext_pre(" ",fi->ft,ofp); fprintf(ofp,"\n\n"); for(i=0;ilen;i++) { auto ArgInfo * ai; ai = fi->arg[i]; if( ai->should_NULL == TRUE ) { continue; } fprintf(ofp," Argument %-12s [%s] %s [%s]\n",ai->name,ArgType_to_string(ai->argtype),ai->desc,CKS(ai->type)); } fprintf(ofp," Return [%s] %s [%s]\n",ArgType_to_string(fi->ret->argtype),fi->ret->desc,CKS(fi->ret->type)); fprintf(ofp,"\n\n"); } void write_pod_non_APIfunc(APIfunc * f,char * package,FILE * ofp) { FuncInfo * fi; int i; fi = f->fi; fprintf(ofp,"&%s::%s(%s",package,fi->simple == NULL ? fi->name : fi->simple ,fi->len == 0 ? "void" : fi->arg[0]->name); for(i=1;ilen;i++) fprintf(ofp,",%s",fi->arg[i]->name); fprintf(ofp,")\n\n"); dump_Ftext_pre(" ",fi->ft,ofp); fprintf(ofp,"\n\n"); for(i=0;ilen;i++) { auto ArgInfo * ai; ai = fi->arg[i]; fprintf(ofp," Argument %-12s [%s] %s [%s]\n",ai->name,ArgType_to_string(ai->argtype),ai->desc,CKS(ai->type)); } fprintf(ofp," Return [%s] %s [%s]\n",ArgType_to_string(fi->ret->argtype),fi->ret->desc,CKS(fi->ret->type)); fprintf(ofp,"\n\n"); } boolean write_type_C_dynAPI(dynAPI * api,char * package_name,FILE * ofp) { int i; for(i=0;ilen;i++) { auto APIObject * obj; obj = api->obj[i]; fprintf(ofp,"typedef struct %s%s %s%s;\n\n",package_name,obj->name,package_name,obj->name); } return TRUE; } boolean write_C_dynAPI(dynAPI * api,char * package_name,FILE * ofp) { int i,j; for(i=0;ilen;i++) { auto APIObject * obj; obj = api->obj[i]; fprintf(ofp,"\n\n/* Functions that create, manipulate or act on %s\n *\n",obj->name); for(j=0;jlen;j++) { fprintf(ofp," * %s%s\n",package_name,obj->member[j]->name); } fprintf(ofp," * %s%s [destructor]\n",package_name,obj->destructor->name); fprintf(ofp," *\n */\n\n"); } if( api->non_len > 0 ) { fprintf(ofp,"\n\n/* Helper functions in the module\n *\n"); for(i=0;inon_len;i++) { fprintf(ofp," * %s%s\n",package_name,api->non_obj[i]->name); } fprintf(ofp," *\n\n"); } for(i=0;ilen;i++) { auto APIObject * obj; obj = api->obj[i]; fprintf(ofp,"/* API for object %s */\n",obj->name); for(j=0;jlen;j++) { write_C_APIfunc(obj->member[j],package_name,ofp); } fprintf(ofp,"/* This is the destructor function, ie, call this to free object*/\n"); write_C_APIfunc(obj->destructor,package_name,ofp); } if( api->non_len > 0 ) fprintf(ofp,"\n\n/* These functions are not associated with an object */\n"); for(i=0;inon_len;i++) { write_C_APIfunc(api->non_obj[i],package_name,ofp); } return TRUE; } boolean write_C_APIfunc(APIfunc * api,char * package_name,FILE * ofp) { int i; FuncInfo * fi; fi = api->fi; fprintf(ofp,"/* Function: %s%s(%s",package_name,CKS(fi->name),fi->len == 0 ? "void" : fi->arg[0]->name); for(i=1;ilen;i++) fprintf(ofp,",%s",fi->arg[i]->name); fprintf(ofp,")\n *\n"); show_eddystyle_Ftext(fi->ft,"Descrip:",15,ofp,"No Description"); fprintf(ofp," *\n"); for(i=0;ilen;i++) fprintf(ofp," * %*s%-12s %s [%s%s]\n",-12,"Arg:",fi->arg[i]->name,fi->arg[i]->desc,is_basic_type_API(fi->arg[i]->type) == TRUE ? "" : package_name,fi->arg[i]->type); fprintf(ofp," *\n"); fprintf(ofp," * Returns %s [%s%s]\n",fi->ret->desc,is_basic_type_API(fi->ret->type) == TRUE ? "" : package_name,fi->ret->type); fprintf(ofp," *\n */\n"); fprintf(ofp,"%s%s ",is_basic_type_API(fi->ret->type) == TRUE ? "" : package_name,fi->ret->type); fprintf(ofp,"%s%s(",package_name,fi->name); for(i=0;ilen;i++) { if( fi->arg[i]->argtype == ARGTYPE_P2FUNC ) { fprintf(ofp,"%c%s",i == 0 ? ' ' : ',',fi->arg[i]->func_decl); } else { fprintf(ofp,"%c%s%s %s",i == 0 ? ' ' : ',',is_basic_type_API(fi->arg[i]->type) == TRUE ? "" : package_name,fi->arg[i]->type,fi->arg[i]->name); } } fprintf(ofp,");\n\n"); return TRUE; } boolean is_membasic_type_API(char * type) { char * temp; if( is_basic_type_API(type) == FALSE) return FALSE; if( strstartcmp(type,"char") == 0 ) { if( (temp=strchr(type,'*')) != NULL ) { if( strchr(++temp,'*') != NULL ) { warn("Can't cope with char **'s or above!"); return TRUE; } else { return FALSE; /* char *'s are not membasic */ } } } return TRUE; /* default */ } boolean is_basic_type_API(char * type) { if( strstartcmp(type,"const") == 0 ) return TRUE; /*** oops! ***/ if( strstartcmp(type,"char") == 0 ) return TRUE; if( strstartcmp(type,"FILE") == 0 ) return TRUE; if( strstartcmp(type,"double") == 0 ) return TRUE; if( strstartcmp(type,"float") == 0 ) return TRUE; if( strstartcmp(type,"short") == 0 ) return TRUE; if( strstartcmp(type,"long") == 0 ) return TRUE; if( strstartcmp(type,"int") == 0 ) return TRUE; if( strstartcmp(type,"void") == 0 ) return TRUE; if( strstartcmp(type,"boolean") == 0 ) return TRUE; if( strstartcmp(type,"Score") == 0 ) return TRUE; if( strstartcmp(type,"Probability") == 0 ) return TRUE; if( strstartcmp(type,"Bits") == 0 ) return TRUE; if( strstartcmp(type,"base") == 0 ) return TRUE; if( strstartcmp(type,"codon") == 0 ) return TRUE; if( strstartcmp(type,"aa") == 0 ) return TRUE; return FALSE; } dynAPI * read_dynAPI_line(char * line,FILE * ifp) { char buffer[MAXLINE]; dynAPI * out; APIfunc * func; APIObject * obj; if( strstartcmp(line,"api") != 0 ) { warn("In building dynAPI, passed in a non api [%s]",line); return NULL; } out = dynAPI_alloc_std(); while( get_watched_line(buffer,MAXLINE,ifp) != NULL ) { if ( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"endapi") == 0 ) { break; } if( strstartcmp(buffer,"end") == 0 ) { warn("Got an end line but not endapi in api section. Don't like it [%s]",buffer); break; } if( strstartcmp(buffer,"func") == 0 ) { func = APIfunc_from_buffer(buffer); if( func == NULL ) continue; add_non_dynAPI(out,func); } else if ( strstartcmp(buffer,"object") == 0 ) { obj = APIObject_from_line(buffer,MAXLINE,ifp); if( obj == NULL ) continue; add_dynAPI(out,obj); } else { warn("In reading an api specification, [%s] not understood\n",buffer); } } return out; } boolean write_perl_XS_accessor_functions(APIObject * obj,char * package,FILE * ofp) { int j; StructHolder * sh; char strippack[64]; char * listappend; char * runner; /* HACK coming up! */ strcpy(strippack,package); if( strippack[strlen(strippack)-1] == '_') strippack[strlen(strippack)-1] = '\0'; sh = obj->sh; for(j=0;jlen;j++) { auto StructElement * temp; temp = sh->el[j]; if( temp->ishidden == TRUE ) continue; /* skip it! */ if( temp->islist == TRUE ) { listappend=CKN(temp->len_append); runner = depointer_element(temp->element_type); runner = depointer_element(runner); while ( !isalpha(runner[strlen(runner)-1]) ) { runner[strlen(runner)-1] = '\0'; } fprintf(ofp,"void\neach_%s(obj)\n",temp->name); fprintf(ofp,"\t%s%s * obj\n",package,sh->name); fprintf(ofp,"\tPPCODE:\n\tint i=0;\n\tint len;\n\tSV* temp;\n\tlen = %s_length_%s_%s(obj);\n\tfor(i=0;iname,obj->name); fprintf(ofp,"\t temp = sv_newmortal();\n"); fprintf(ofp,"\t sv_setref_pv(temp, \"%s::%s\", (void*) (%shard_link_%s(%s_access_%s_%s(obj,i))));\n",strippack,runner,package,runner,strippack,temp->name,obj->name); fprintf(ofp,"\t XPUSHs(temp);\n"); fprintf(ofp,"\t }\n"); fprintf(ofp,"\tXSRETURN(len);\n\n"); } } return TRUE; } boolean write_dynAPI_accessor_functions(DYNFILE * dfp,dynAPI * api) { int i,j; FuncInfo * fi; ArgInfo * ai; APIfunc * af; boolean islist; char * runner; char * listappend; /* Ngggg! We have to check if there is a list or not. this was bad API design in wisec.dy sometime ago. (like - years ago ) Yuk! yuk! */ for(i=0;ilen;i++) { auto APIObject * obj; auto StructHolder * sh; obj = api->obj[i]; sh = obj->sh; islist = FALSE; for(j=0;jlen;j++) { if( sh->el[j]->islist == TRUE ) { islist = TRUE; } } /* promote hard link into API */ af = APIfunc_alloc(); af->name = stringallocf("hard_link_%s",sh->name); add_APIObject(obj,af); /* promote alloc into API */ /* yuk. stupid is list problem! */ af = APIfunc_alloc(); af->name = stringallocf("%s_alloc%s",sh->name,islist == TRUE ? "_std" : ""); af->only_C = TRUE; add_APIObject(obj,af); for(j=0;jlen;j++) { auto StructElement * temp; temp = sh->el[j]; if( temp->ishidden == TRUE ) continue; /* skip it! */ if( temp->islist == TRUE ) { listappend=CKN(temp->len_append); runner = depointer_element(temp->element_type); /* make a "access element" function */ /* build the function documentation. hide it from the C header file */ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"access_%s_%s",temp->name,sh->name); fi->simple = stringalloc(temp->name); add_line_to_Ftext(fi->ft,"Access members stored in the %s list",temp->name); add_line_to_Ftext(fi->ft,"For use principly by API functions",temp->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc = stringalloc("Object holding the list"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"i"); ai->desc = stringalloc("Position in the list"); ai = ArgInfo_alloc(); ai->name = stringalloc("return"); ai->desc = stringalloc("Element of the list"); ai->argtype = ARGTYPE_STATIC; fi->ret = ai; /* promote it into API */ af = APIfunc_alloc(); af->name = stringalloc(fi->name); add_APIObject(obj,af); /* build the function */ start_function_FuncInfo(fi,dfp,"%s access_%s_%s(%s * obj,int i)",runner,temp->name,sh->name,sh->name); expr(dfp,"if( obj == NULL) "); startbrace(dfp); warn_expr(dfp,"In accessor function %s for object %s, got a NULL object",temp->name,sh->name); expr(dfp,"return %s",def_from_element(runner)); closebrace(dfp); expr(dfp,"if( obj->%slen <= i )",listappend); startbrace(dfp); expr(dfp,"warn(\"In accessor function %s for object %s, index %%%%d is greater than list length %%%%d\",i,obj->len);",temp->name,sh->name); expr(dfp,"return %s",def_from_element(runner)); closebrace(dfp); expr(dfp,"return obj->%s[i]",temp->name); close_function(dfp); add_break(dfp); /* make a "length" function */ /* build the function documentation. hide it from the C header file */ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"length_%s_%s",temp->name,sh->name); fi->simple=stringallocf("length_%s",temp->name); add_line_to_Ftext(fi->ft,"discover the length of the list",temp->name); add_line_to_Ftext(fi->ft,"For use principly by API functions",temp->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc = stringalloc("Object holding the list"); ai = ArgInfo_alloc(); ai->name = stringalloc("return"); ai->desc = stringalloc("length of the list"); fi->ret = ai; /* promote it into API */ af = APIfunc_alloc(); af->name = stringalloc(fi->name); add_APIObject(obj,af); /* build the function */ start_function_FuncInfo(fi,dfp,"int length_%s_%s(%s * obj)",temp->name,sh->name,sh->name); expr(dfp,"if( obj == NULL) "); startbrace(dfp); warn_expr(dfp,"In length function %s for object %s, got a NULL object",temp->name,sh->name); expr(dfp,"return -1"); closebrace(dfp); expr(dfp,"return obj->%slen",listappend); close_function(dfp); add_break(dfp); /* promote flush and add to api */ af = APIfunc_alloc(); af->name = stringallocf("flush_%s%s",listappend,sh->name); add_APIObject(obj,af); af = APIfunc_alloc(); af->name = stringallocf("add_%s%s",listappend,sh->name); add_APIObject(obj,af); } else if ( temp->ismatrix == TRUE ) { warn("Cannot make matrix accessor functions yet!"); } else if ( temp->isfunc == TRUE ) { warn("Cannot make pointer to functions accessor functions yet (if at all!)"); } else { if ( strchr(temp->name,'[') != NULL ) { /* should be a compiler option */ /* warn("Cannot build accessor for %s, as is an array",temp->name); */ continue; } /* simple replace guy */ /* build the function documentation. hide it from the C header file */ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"replace_%s_%s",temp->name,sh->name); fi->simple = stringallocf("set_%s",temp->name); add_line_to_Ftext(fi->ft,"Replace member variable %s",temp->name); add_line_to_Ftext(fi->ft,"For use principly by API functions",temp->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc = stringalloc("Object holding the variable"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,temp->name); ai->argtype = ARGTYPE_OWNER; ai->desc = stringalloc("New value of the variable"); ai = ArgInfo_alloc(); ai->name = stringalloc("return"); ai->desc = stringallocf("member variable %s",temp->name); ai->argtype = ARGTYPE_STATIC; fi->ret =ai; /* promote it into API */ af = APIfunc_alloc(); af->name = stringalloc(fi->name); add_APIObject(obj,af); /* build the function */ start_function_FuncInfo(fi,dfp,"boolean replace_%s_%s(%s * obj,%s %s)",temp->name,sh->name,sh->name,temp->element_type,temp->name); expr(dfp,"if( obj == NULL) "); startbrace(dfp); warn_expr(dfp,"In replacement function %s for object %s, got a NULL object",temp->name,sh->name); expr(dfp,"return FALSE"); closebrace(dfp); expr(dfp,"obj->%s = %s;",temp->name,temp->name); expr(dfp,"return TRUE;"); close_function(dfp); add_break(dfp); /* simple accessor */ /* build the function documentation. hide it from the C header file */ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"access_%s_%s",temp->name,sh->name); fi->simple = stringalloc(temp->name); add_line_to_Ftext(fi->ft,"Access member variable %s",temp->name); add_line_to_Ftext(fi->ft,"For use principly by API functions",temp->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc = stringalloc("Object holding the variable"); ai = ArgInfo_alloc(); ai->name = stringalloc("return"); ai->desc = stringallocf("member variable %s",temp->name); ai->argtype = ARGTYPE_STATIC; fi->ret =ai; /* promote it into API */ af = APIfunc_alloc(); af->name = stringalloc(fi->name); add_APIObject(obj,af); /* build the function */ start_function_FuncInfo(fi,dfp,"%s access_%s_%s(%s * obj)",temp->element_type,temp->name,sh->name,sh->name); expr(dfp,"if( obj == NULL) "); startbrace(dfp); warn_expr(dfp,"In accessor function %s for object %s, got a NULL object",temp->name,sh->name); expr(dfp,"return %s",def_from_element(temp->element_type)); closebrace(dfp); expr(dfp,"return obj->%s",temp->name); close_function(dfp); add_break(dfp); } } } return TRUE; } boolean write_XS_typemap_dynAPI(dynAPI * api,char * package_name,FILE * ofp) { int i; char strip_package[64]; /* HACK coming up! */ strcpy(strip_package,package_name); if( strip_package[strlen(strip_package)-1] == '_') strip_package[strlen(strip_package)-1] = '\0'; for(i=0;ilen;i++) { fprintf(ofp,"\nTYPEMAP\n%s%s * T_%s_%s\n",package_name,api->obj[i]->name,strip_package,api->obj[i]->name); fprintf(ofp,"\nINPUT\nT_%s_%s\n\t$var = ($type) (SvROK($arg) == 0 ? NULL : (%s_%s *) SvIV((SV*)SvRV($arg)))\n",strip_package,api->obj[i]->name,strip_package,api->obj[i]->name); fprintf(ofp,"\nOUTPUT\nT_%s_%s\n\tsv_setref_pv($arg, \"%s::%s\", (void*) $var);\n",strip_package,api->obj[i]->name,strip_package,api->obj[i]->name); } return TRUE; } boolean write_XS_dynAPI(dynAPI * api,char * package_name,FILE * ofp) { int i; char strip_package[64]; /* HACK coming up! */ strcpy(strip_package,package_name); if( strip_package[strlen(strip_package)-1] == '_') strip_package[strlen(strip_package)-1] = '\0'; for(i=0;ilen;i++) { write_XS_header_APIObject(api,package_name,api->obj[i],ofp); write_perl_XS_accessor_functions(api->obj[i],package_name,ofp); } fprintf(ofp,"\n\nMODULE = %s PACKAGE = %s\n\n",strip_package,strip_package); for(i=0;inon_len;i++) { write_XS_APIfunc(api->non_obj[i],package_name,ofp); } return TRUE; } boolean write_XS_header_APIObject(dynAPI * api,char * package_name,APIObject * obj,FILE * ofp) { int i; boolean islist; char strip_package[64]; /* HACK coming up! */ strcpy(strip_package,package_name); if( strip_package[strlen(strip_package)-1] == '_') strip_package[strlen(strip_package)-1] = '\0'; fprintf(ofp,"\n\nMODULE = %s PACKAGE = %s::%s\n\n",strip_package,strip_package,obj->name); for(i=0;ilen;i++) { write_XS_APIfunc(obj->member[i],package_name,ofp); } /* now to write a simple constructor */ /* Ngggg! We have to check if there is a list or not. this was bad API design in wisec.dy sometime ago. (like - years ago ) Yuk! yuk! */ islist = FALSE; for(i=0;ish->len;i++) { if( obj->sh->el[i]->islist == TRUE ) { islist = TRUE; } } fprintf(ofp,"\n%s%s *\nnew(class)\n\tchar * class\n\tPPCODE:\n\t%s%s * out;\n\tout = %s%s_alloc%s();\n\tST(0) = sv_newmortal();\n\tsv_setref_pv(ST(0),class,(void*)out);\n\tXSRETURN(1);\n",package_name,obj->name,package_name,obj->name,package_name,obj->name,islist == TRUE ? "_std" : ""); /* now to write the destructor */ fprintf(ofp,"\nvoid\nDESTROY(obj)\n\t%s%s * obj\n\tCODE:\n\t%s%s(obj);\n\n",package_name,obj->name,package_name,obj->destructor->name); return TRUE; } boolean write_XS_APIfunc(APIfunc * fu,char * package_name,FILE * ofp) { int j; boolean is_basic; /* return statement */ is_basic = is_basic_type_API(fu->fi->ret->type); if( is_basic == TRUE ) fprintf(ofp,"%s\n",fu->fi->ret->type); else fprintf(ofp,"%s%s\n",(is_basic == TRUE ? "" : package_name),fu->fi->ret->type); /* if we have a simple specification use that - the package will protect us from nasty name clashes! */ if( fu->fi->simple != NULL ) { fprintf(ofp,"%s(",fu->fi->simple); } else { /* function name - we do need the package stuff...*/ fprintf(ofp,"%s(",fu->name); } for(j=0;jfi->len;j++) { if( fu->fi->arg[j]->should_NULL == TRUE) { continue; /* don't put it into the Perl prototype */ } fprintf(ofp,"%s%s",j == 0 ? "" : ",",fu->fi->arg[j]->name); } fprintf(ofp,")\n"); /* each arguments */ for(j=0;jfi->len;j++) { if( fu->fi->arg[j]->should_NULL == TRUE) { continue; /* don't put it into the Perl prototype */ } is_basic = is_basic_type_API(fu->fi->arg[j]->type); if( is_basic == TRUE) fprintf(ofp,"\t%s %s\n",fu->fi->arg[j]->type,fu->fi->arg[j]->name); else fprintf(ofp,"\t%s%s %s\n",(is_basic == TRUE ? "" : package_name),fu->fi->arg[j]->type,fu->fi->arg[j]->name); } /* ok - now lets do the glue */ if( strcmp(fu->fi->ret->type,"void") != 0 ) { if( fu->fi->ret->argtype == ARGTYPE_STATIC && is_basic_type_API(fu->fi->ret->type) == FALSE) { /* we need to put in the memory handler... */ /* * Horrible hack. We assumme the the C type MyType * means dynamite type MyType. * * YUK!!!! Also - v.v.v.v.v bad hard coded Wise2 * */ fprintf(ofp,"\tINIT:\nWise2_%s temp;\n\tCODE:\n\ttemp = Wise2_hard_link_%s(%s%s(",fu->fi->ret->type,c2dyn_type(fu->fi->ret->type),package_name,fu->name); } else if(fu->fi->ret->argtype == ARGTYPE_STATIC && strcmp(fu->fi->ret->type,"char *") == 0 ) { fprintf(ofp,"\tINIT:\n\t%s temp;\n\tCODE:\n\ttemp = Wise2_stringalloc(%s%s(",fu->fi->ret->type,package_name,fu->name); } else { /* a basic type - don't need to handle, despite STATIC linkage */ fprintf(ofp,"\tCODE:\n\tRETVAL = %s%s(",package_name,fu->name); } } /* end of is not void */ else { /* if it is void */ fprintf(ofp,"\tCODE:\n\t%s%s(",package_name,fu->name); } for(j=0;jfi->len;j++) { if( fu->fi->arg[j]->argtype == ARGTYPE_OWNER && is_membasic_type_API(fu->fi->arg[j]->type) == FALSE && fu->fi->arg[j]->should_NULL == FALSE ) { if( (strcmp(fu->fi->arg[j]->type,"char*") == 0) || (strcmp(fu->fi->arg[j]->type,"char *") == 0) ) { fprintf(ofp,"%sWise2_stringalloc(%s)",j == 0 ? "" : ",",fu->fi->arg[j]->name); } else { fprintf(ofp,"%sWise2_hard_link_%s(%s)",j == 0 ? "" : ",",c2dyn_type(fu->fi->arg[j]->type),fu->fi->arg[j]->name); } } else { fprintf(ofp,"%s%s",j == 0 ? "" : ",",fu->fi->arg[j]->should_NULL == TRUE ? "NULL" : fu->fi->arg[j]->name); } } if( fu->fi->ret->argtype == ARGTYPE_STATIC && (is_basic_type_API(fu->fi->ret->type) == FALSE || strcmp(fu->fi->ret->type,"char *") == 0) ) { fprintf(ofp,"));\n\tRETVAL = temp;\n\tOUTPUT:\n\tRETVAL\n\n"); } else { if( strcmp(fu->fi->ret->type,"void") != 0 ) { fprintf(ofp,");\n\tOUTPUT:\n\tRETVAL\n\n"); } else { fprintf(ofp,");\n\n"); } } fprintf(ofp,"\n\n"); return TRUE; } static char statbuf[128]; %func internal thing that maps C * types to dynamite types %type internal %% char * c2dyn_type(char * c) { strcpy(statbuf,c); c = statbuf + strlen(statbuf)-1; for(;c != statbuf && *c != '*';c--) ; c--; for(;c != statbuf && isspace(*c);c--) ; c++; *c = '\0'; return statbuf; } boolean reconcile_dynAPI_with_FuncInfo(dynAPI * api,DYNFILE * dfp) { int i; int j; boolean ret = TRUE; FuncInfo * fi; for(i=0;ilen;i++) { for(j=0;jobj[i]->len;j++) { if( (fi= FuncInfo_from_name_DYNFILE(dfp,api->obj[i]->member[j]->name)) == NULL ) { warn("Cannot find any documentation for %s\n",api->obj[i]->member[j]->name); ret = FALSE; } else { api->obj[i]->member[j]->fi = fi; } } if(api->obj[i]->destructor != NULL) { if( (fi= FuncInfo_from_name_DYNFILE(dfp,api->obj[i]->destructor->name)) == NULL ) { warn("Cannot find any documentation for %s (destructor!)\n",api->obj[i]->destructor->name); ret = FALSE; } else { api->obj[i]->destructor->fi = fi; } } } for(j=0;jnon_len;j++) { if( (fi= FuncInfo_from_name_DYNFILE(dfp,api->non_obj[j]->name)) == NULL ) { warn("Cannot find any documentation for %s\n",api->non_obj[j]->name); ret = FALSE; } else { api->non_obj[j]->fi = fi; } } return ret; } APIObject * APIObject_from_line(char * line,int maxline,FILE * ifp) { APIObject * out; APIfunc * func; char * runner; if( strstartcmp(line,"object") != 0 ) { warn("In building APIObject, passed in a non object line [%s]",line); return NULL; } (void) strtok(line,spacestr); if( (runner=strtok(NULL,spacestr)) == NULL ) { warn("In building APIObject, no name for object",line); /* should skip to endobject ? */ return NULL; } out = APIObject_alloc_std(); out->name = stringalloc(runner); while( get_watched_line(line,maxline,ifp) != NULL ) { if( line[0] == '#' ) continue; if( strstartcmp(line,"endobject") == 0 ) { break; } if( strstartcmp(line,"end") == 0 ) { warn("Got an end line [%s] but not an end object line. Don't like!"); break; } if( strstartcmp(line,"func") == 0 ) { func = APIfunc_from_buffer(line); if( func == NULL ) continue; add_APIObject(out,func); } else if ( strstartcmp(line,"des") == 0 ) { func = APIfunc_from_buffer(line); if( func == NULL ) continue; out->destructor= func; } else { warn("Did not understand [%s] as an APIObject line",line); } } return out; } APIfunc * APIfunc_from_buffer(char * line) { APIfunc * out; if( line == NULL ) { warn("Passed in a NULL line to APIfunc_from_buffer"); return NULL; } if( strstartcmp(line,"func") != 0 && strstartcmp(line,"des") != 0 ) { warn("Passed a non function line to APIfunc_from_buffer"); return NULL; } (void)strtok(line,spacestr); if( (line = strtok(NULL,spacestr)) == NULL ) { warn("line to APIfunc_from_buffer was empty. Yikes"); return NULL; } out = APIfunc_alloc(); if( out == NULL) return NULL; out->name = stringalloc(line); return out; } wise-2.4.1/src/dyc/calc.l0000644000175000001440000000323207313404532014477 0ustar philippusers %{ #include "y.tab.h" #include "exprtree.h" #ifdef LINUX #undef YY_INPUT #define YY_INPUT(b, r, ms) (r = my_yyinput(b, ms)) #undef yywrap #endif extern char * calc_lex_string; extern int stringpos; #ifndef LINUX #undef input #undef unput #endif %} %% [ \t] ; [0-9]+ { yylval.tr = new_ExprTree(); yylval.tr->type = ETR_NUMBER; yylval.tr->word = stringalloc((char * )yytext); /* printf("Got a number %s\n",yytext); */ return NUMBER; } [A-Za-z][A-Za-z0-9_]* { yylval.tr = new_ExprTree(); yylval.tr->type = ETR_NAME; yylval.tr->word = stringalloc((char * )yytext); /* printf("Got a name %s \n",yytext);*/ return NAME; } \-> { yylval.tr = new_ExprTree(); yylval.tr->word = stringalloc((char * )yytext); yylval.tr->type = ETR_OPERATOR; return STRUCTREF; } \. { yylval.tr = new_ExprTree(); yylval.tr->word = stringalloc((char * )yytext); yylval.tr->type = ETR_OPERATOR; return STRUCTREF; } . { /* printf("operator\n"); */ return yytext[0]; } \n return 0; %% #ifdef LINUX int my_yyinput(char * buf,int max_size) { int i; /* fprintf(stderr,"[%s] Got into yyinput, calling %d and with %d in string\n",calc_lex_string,max_size,stringpos); */ if( calc_lex_string[stringpos] == '\0') { /* fprintf(stderr,"Going to return 0\n"); */ buf[0] = EOF; return 0; } for(i=0;i< max_size && calc_lex_string[stringpos] != '\0';i++,stringpos++) { buf[i] = calc_lex_string[stringpos]; } buf[i] = EOF; /* fprintf(stderr,"Returning %d\n",i); */ return i; } int yywrap(void) { return 1; } #else char input(void) { return calc_lex_string[stringpos++]; } void unput(char c) { calc_lex_string[--stringpos] = c; } #endif wise-2.4.1/src/dyc/calc.y0000644000175000001440000000365707313404532014527 0ustar philippusers %{ #include #include "exprtree.h" extern ExprTree * root; extern char * calc_lex_string; extern int stringpos; %} %union { double dval; struct ExprTree * tr; } %token NAME NUMBER STRUCTREF %type expression statement tag method commalist %left '-' '+' %left '*' '/' %left '&' DEREFERENCE %left STRUCTREF '[' ']' %% statement : expression { $$ = new_ExprTree(); $$->type = ETR_STATEMENT; $$->child[0] = $1; $$->nochild=1; root = $$; parentfy_ExprTree(root); } ; method : tag '(' commalist ')' { $$ = new_ExprTree_method($1,$3); } | tag '(' ')' { $$ = new_ExprTree_method($1,NULL); } ; expression : expression '+' expression { $$ = new_ExprTree_binary_expr($1,'+',$3); } | expression '-' expression { $$ = new_ExprTree_binary_expr($1,'-',$3); } | expression '*' expression { $$ = new_ExprTree_binary_expr($1,'*',$3); } | expression '/' expression { $$ = new_ExprTree_binary_expr($1,'/',$3); } | '(' expression ')' { $$ = $2; } | NUMBER { $$ = $1; } | tag { $$ = $1; } | method { $$ = $1; } ; commalist : commalist ',' expression { $$ = add_to_commalist_ExprTree($1,$3); } | expression { $$ = new_ExprTree_commalist($1); } ; tag : NAME { $$ = new_ExprTree_tag_from_name($1); } | tag STRUCTREF tag { $$ = new_ExprTree_struct_ref($1,$2,$3); } | tag '[' expression ']' { $$ = new_ExprTree_array($1,$3); } | '&' tag { $$ = new_ExprTree_ref('*',$2); } | '*' tag %prec DEREFERENCE { $$ = new_ExprTree_ref('*',$2); } ; %% #ifdef YYWRAP_NEEDED void yywrap(void) { fprintf(stderr,"In yywrap... going to exit badly"); exit(1); } #endif void yyerror(char * s) { /*** stringpos is position along the string ***/ int i; warn("Calc line parser error: [%s]",s); fprintf(stderr,"Occured at:\n"); fprintf(stderr,"%s\n",calc_lex_string); for(i=0;i (b) ? (a) : (b)) #endif static void update_state_names(GenericMatrix * gm, OneModel * om, char ** start_state_name, char ** end_state_name); static char * copy_str(char * in_str); static compugen_rc_t update_transitions(GenericMatrix * gm, OneModel * om, char * start_state_name, char * end_state_name); static OneModelTrans * update_transition_fields(CellSource * from_state, CellState * to_state, int transition_num, char * start_state_name, char * end_state_name, int to_semistate); static OneModelTrans * update_transition_from_semistate(CellState * state, int transition_num); static compugen_rc_t parse_calc_line(ExprTree * expr_tree, OneModel * om, int transition_num, seq_func_table_t seq_func_table, char * query_name, char * target_name); static compugen_rc_t update_calc_om_data(ExprTree * tree, OneModel * om, int transition_num, seq_func_table_t seq_func_table, char * query_name, char * target_name); static compugen_rc_t update_tseq(ExprTree * tree, OneModel * om, int transition_num, seq_func_table_t seq_func_table); static compugen_rc_t update_tprf(ExprTree * tree, OneModel * om, int transition_num); static compugen_rc_t update_tprf(ExprTree * tree, OneModel * om, int transition_num); static compugen_rc_t update_w(ExprTree * tree, OneModel * om, int transition_num, seq_func_table_t seq_func_table, char * target_name); static compugen_rc_t update_wseq(ExprTree * tree, OneModel * om, int transition_num, seq_func_table_t seq_func_table); static ExprTree * find_wseq(ExprTree * tree, char * target_name); static int get_seq_diff(ExprTree * tree); static int is_word(ExprTree * tree, char * str); static int is_diff(ExprTree * tree); static char * get_seq_func_name(ExprTree * tree); static int get_seq_func_index(char * dy_func_name, seq_func_table_t seq_func_table); static int find_trees_num(ExprTree * tree); static int divide_expr_tree(ExprTree * tree, ExprTree * trees_array[], int trees_num); static calc_type_t find_calc_type(ExprTree * tree, char * query_name, char * target_name); static void find_prf_seq(ExprTree * tree, int * is_prf, int * is_seq, char * query_name, char * target_name); static compugen_rc_t add_seqfunc(char * new_seqfunc, char * seq_funcs[]); static OneModelTrans * OneModelTrans_alloc(void); static OneModel * OneModel_alloc(void); static void make_seq_func_table ( seq_func_table_t * table ); static char * find_datatypes(char * target_type); static char * create_semistate_name ( char * state_name ); static int tpos; /*************************************************************************** * * FUNCTION : OneModel_from_GenericMatrix * * DESCRIPTION : Filling One Model structure according to generic matrix. * * INPUT : GenericMatrix * gm * * OUTPUT : None. * * RETURN : OneModel * - The One Model structure. * ***************************************************************************/ OneModel * OneModel_from_GenericMatrix(GenericMatrix * gm) { OneModel * out; char * start_state_name = NULL; char * end_state_name = NULL; out = OneModel_alloc(); /* Updating model name */ out->name = copy_str ( gm->name ); /* Updating data typs */ if ( (out->datatype_str = find_datatypes(gm->ttype->logical)) == NULL ) return NULL; /* Updating states and midstates names */ update_state_names ( gm, out, &start_state_name, &end_state_name ); /* Updating states number */ out->states_num = gm->len + OM_TMP_STATES_NUM; tpos = 4 * (out->states_num + out->semistates_num); out->arg_str = get_argstr_GenericMatrix(gm); out->chain_str = get_chainstr_GenericMatrix(gm); out->sc = gm->sc; /* Updating transition table */ if ( update_transitions ( gm, out, start_state_name, end_state_name ) != COMPUGEN_OK ) return NULL; out->prof_line_len = tpos; if ( start_state_name != NULL ) free ( start_state_name ); if ( end_state_name != NULL ) free ( end_state_name ); return out; } /*************************************************************************** * * FUNCTION : update_state_names * * DESCRIPTION : Updating states semistates and midstates names in One Model * structure. * * INPUT : GenericMatrix * gm * * OUTPUT : OneModel * om * char ** start_state_name * char ** end_state_name * * RETURN : None. * ***************************************************************************/ static void update_state_names(GenericMatrix * gm, OneModel * om, char ** start_state_name, char ** end_state_name) { int midstates_num = 0; int i; /* Updating TMPSTART and TMPEND state names */ om->statenames[OM_TMPSTART] = copy_str ( "TMPSTART" ); om->statenames[OM_TMPEND] = copy_str ( "TMPEND" ); /* Updating regular state names */ for ( i = 0; i < gm->len; i++ ) { om->statenames[OM_TMP_STATES_NUM+i] = copy_str ( gm->state[i]->name ); /* Updating semistate name if exists */ if ( gm->state[i]->etr != NULL ) { om->semistatenames[om->semistates_num] = create_semistate_name ( gm->state[i]->name ); (om->semistates_num)++; } } /* Updating midstate names */ for ( i = 0; i < gm->spec_len; i++ ) { if ( gm->special[i]->is_start ) *start_state_name = copy_str ( gm->special[i]->name ); else if ( gm->special[i]->is_end ) *end_state_name = copy_str ( gm->special[i]->name ); else { om->midstatenames[midstates_num] = copy_str ( gm->special[i]->name ); midstates_num++; /* Updating semistate name if exists */ if ( gm->special[i]->etr != NULL ) { om->semistatenames[om->semistates_num] = create_semistate_name ( gm->special[i]->name ); (om->semistates_num)++; } } } } /*************************************************************************** * * FUNCTION : copy_str * * DESCRIPTION : Allocating a string with the length of the input string, * and copying the input string to the new string. * * INPUT : char * in_str * * OUTPUT : None. * * RETURN : char * - The new string. * ***************************************************************************/ static char * copy_str(char * in_str) { char * out_str; if ( (out_str = (char *)malloc(strlen(in_str) + 1)) == NULL ) { perror ( "copy_str : malloc" ); exit ( 1 ); } strcpy ( out_str, in_str ); return out_str; } /*************************************************************************** * * FUNCTION : update_transitions * * DESCRIPTION : Updating One Model transition structure for all the * transitions. * * INPUT : GenericMatrix * gm * char * start_state_name * char * end_state_name * * OUTPUT : OneModel * om * * RETURN : compugen_rc_t * ***************************************************************************/ static compugen_rc_t update_transitions(GenericMatrix * gm, OneModel * om, char * start_state_name, char * end_state_name) { int i, j; seq_func_table_t seq_func_table; compugen_rc_t rc; int transition_num = OM_TMP_STATES_NUM; char temp_name[20]; int to_semistate; make_seq_func_table ( &seq_func_table ); /* Updating transition START -> TMPSTART and TMPEND -> END */ om->trans[OM_TMPSTART] = OneModelTrans_alloc(); om->trans[OM_TMPSTART]->from_state = copy_str ( "START" ); om->trans[OM_TMPSTART]->to_state = copy_str ( "TMPSTART" ); om->trans[OM_TMPSTART]->name = copy_str ( "trans0" ); om->trans[OM_TMPSTART]->xlabel = copy_str ( "-" ); om->trans[OM_TMPSTART]->ylabel = copy_str ( "-" ); om->trans[OM_TMPEND] = OneModelTrans_alloc(); om->trans[OM_TMPEND]->from_state = copy_str ( "TMPEND" ); om->trans[OM_TMPEND]->to_state = copy_str ( "END" ); om->trans[OM_TMPEND]->name = copy_str ( "trans1" ); om->trans[OM_TMPEND]->xlabel = copy_str ( "-" ); om->trans[OM_TMPEND]->ylabel = copy_str ( "-" ); /* Updating all transitions */ /* Transitions to states */ for ( i = 0; i < gm->len; i++ ) { /* Checking if there is a semistate - if it is adding a transition semistate -> state */ if ( gm->state[i]->etr != NULL ) { om->trans[transition_num] = update_transition_from_semistate(gm->state[i], transition_num); if ( (rc = parse_calc_line(gm->state[i]->etr, om, transition_num, seq_func_table, gm->query->name, gm->target->name)) != COMPUGEN_OK ) return rc; transition_num++; to_semistate = TRUE; } else to_semistate = FALSE; /* Adding all transitions to state */ for ( j = 0; j < gm->state[i]->len; j++ ) { push_errormsg_stack("Reconciling Compugen functions for %s to %s", gm->state[i]->source[j]->state_source,gm->state[i]->name); om->trans[transition_num] = update_transition_fields ( gm->state[i]->source[j], gm->state[i], transition_num, start_state_name, end_state_name, to_semistate ); if ( (rc = parse_calc_line(gm->state[i]->source[j]->etr, om, transition_num, seq_func_table, gm->query->name, gm->target->name)) != COMPUGEN_OK ) return rc; pop_errormsg_stack(); transition_num++; } } /* Transitions to midstates */ for ( i = 0; i < gm->spec_len; i++ ) { /* Checking if there is a semistate - if it is adding a transition semistate -> state */ if ( gm->special[i]->etr != NULL ) { om->trans[transition_num] = update_transition_from_semistate(gm->special[i], transition_num); if ( (rc = parse_calc_line(gm->special[i]->etr, om, transition_num, seq_func_table, gm->query->name, gm->target->name)) != COMPUGEN_OK ) return rc; transition_num++; to_semistate = TRUE; } else to_semistate = FALSE; /* Adding all transitions to state */ for ( j = 0; j < gm->special[i]->len; j++ ) { push_errormsg_stack("Reconciling Compugen functions for %s to %s", gm->special[i]->source[j]->state_source,gm->special[i]->name); om->trans[transition_num] = update_transition_fields ( gm->special[i]->source[j], gm->special[i], transition_num, start_state_name, end_state_name, to_semistate ); if ( (rc = parse_calc_line(gm->special[i]->source[j]->etr, om, transition_num, seq_func_table, gm->query->name, gm->target->name)) != COMPUGEN_OK ) return rc; pop_errormsg_stack(); transition_num++; } } /* A transition TMPSTART -> TMPSTART - needed for One Model */ om->trans[transition_num] = OneModelTrans_alloc(); om->trans[transition_num]->from_state = copy_str ( "TMPSTART" ); om->trans[transition_num]->to_state = copy_str ( "TMPSTART" ); sprintf ( temp_name, "trans%d", transition_num ); om->trans[transition_num]->name = copy_str ( temp_name ); om->trans[transition_num]->xlabel = copy_str ( "-" ); om->trans[transition_num]->ylabel = copy_str ( "-" ); om->trans[transition_num]->dx = om->trans[transition_num]->dy = 1; om->trans[transition_num]->tpos_tprf = tpos; tpos++; return COMPUGEN_OK; } /*************************************************************************** * * FUNCTION : update_transition_fields * * DESCRIPTION : Allocating a One Model transition structure and filling in * all the fields that don't depend on the calc expression. * * INPUT : CellSource * from_state * CellState * to_state * int transition_num * char * start_state_name * char * end_state_name * int to_semistate * * OUTPUT : None. * * RETURN : OneModelTrans * * ***************************************************************************/ static OneModelTrans * update_transition_fields(CellSource * from_state, CellState * to_state, int transition_num, char * start_state_name, char * end_state_name, int to_semistate) { char temp_name[20]; OneModelTrans * out; out = OneModelTrans_alloc(); if ( (start_state_name != NULL) && (strcmp(from_state->state_source, start_state_name) == 0) ) out->from_state = copy_str ( "TMPSTART" ); else out->from_state = copy_str ( from_state->state_source ); if ( to_semistate ) out->to_state = create_semistate_name ( to_state->name ); else if ( (end_state_name != NULL) && (strcmp(to_state->name, end_state_name) == 0) ) out->to_state = copy_str ( "TMPEND" ); else out->to_state = copy_str ( to_state->name ); sprintf ( temp_name, "trans%d", transition_num ); out->name = copy_str ( temp_name ); out->dx = (from_state->offj < 0) ? MAX(to_state->offj, 0) : from_state->offj; out->dy = (from_state->offi < 0) ? MAX(to_state->offi, 0) : from_state->offi; out->xlabel = copy_str ( "sequence" ); out->ylabel = copy_str ( "sequence" ); return out; } /*************************************************************************** * * FUNCTION : update_transition_from_semistate * * DESCRIPTION : Allocating a One Model transition structure for a * transition from a semistate to a state, and filling in all * the fields that don't depend on the calc expression. * * INPUT : CellState * state * int transition_num * * OUTPUT : None. * * RETURN : OneModelTrans * * ***************************************************************************/ static OneModelTrans * update_transition_from_semistate(CellState * state, int transition_num) { char temp_name[20]; OneModelTrans * out; out = OneModelTrans_alloc(); out->from_state = create_semistate_name ( state->name ); out->to_state = copy_str ( state->name ); sprintf ( temp_name, "trans%d", transition_num ); out->name = copy_str ( temp_name ); out->dx = 0; out->dy = 0; out->xlabel = copy_str ( "-" ); out->ylabel = copy_str ( "-" ); return out; } /*************************************************************************** * * FUNCTION : parse_calc_line * * DESCRIPTION : * * INPUT : ExprTree * expr_tree * int transition_num * seq_func_table_t seq_func_table * char * query_name * char * target_name * * OUTPUT : OneModel * om * * RETURN : compugen_rc_t * ***************************************************************************/ static compugen_rc_t parse_calc_line(ExprTree * expr_tree, OneModel * om, int transition_num, seq_func_table_t seq_func_table, char * query_name, char * target_name) { int i; ExprTree ** trees; int trees_num; compugen_rc_t rc; /* If root is not a statement - error */ if ( (expr_tree->type != ETR_STATEMENT) || (expr_tree->nochild != 1) ) { fprintf ( stderr, "parse_calc_line : Expression tree root has illegal type\n" ); exit ( 1 ); } /* Finding trees number and allocating trees */ trees_num = find_trees_num(expr_tree->child[0]); if ( trees_num == 0 ) return COMPUGEN_OK; if ( trees_num > MAX_CALC_TYPES ) { /* Until we handle this */ warn ( "Too many trees in calc expression" ); return COMPUGEN_TOO_MANY_CALC_FUNCS; } if ( (trees = (ExprTree **)calloc(trees_num, sizeof(ExprTree *))) == NULL ) { perror ( "parse_calc_line : calloc" ); exit ( 1 ); } /* Dividing expression tree into sub-trees */ divide_expr_tree ( expr_tree->child[0], trees, 0 ); /* Updating OM data */ for ( i = 0; i < trees_num; i++ ) { if ( (rc = update_calc_om_data(trees[i], om, transition_num, seq_func_table, query_name, target_name)) != COMPUGEN_OK ) return rc; } free ( trees ); return COMPUGEN_OK; } /*************************************************************************** * * FUNCTION : update_calc_om_data * * DESCRIPTION : * * INPUT : ExprTree * tree * OneModel * om * int transition_num * seq_func_table_t seq_func_table * * OUTPUT : None. * * RETURN : compugen_rc_t - OK / error code. * ***************************************************************************/ static compugen_rc_t update_calc_om_data(ExprTree * tree, OneModel * om, int transition_num, seq_func_table_t seq_func_table, char * query_name, char * target_name) { switch ( find_calc_type(tree, query_name, target_name) ) { case CALC_SEQ: return update_tseq(tree, om, transition_num, seq_func_table); break; case CALC_PRF: return update_tprf(tree, om, transition_num); break; case CALC_W: return update_w(tree, om, transition_num, seq_func_table, target_name); break; } } /*************************************************************************** * * FUNCTION : update_tseq * * DESCRIPTION : * * INPUT : ExprTree * tree * OneModel * om * int transition_num * seq_func_table_t seq_func_table * * OUTPUT : None. * * RETURN : compugen_rc_t - OK / error code. * ***************************************************************************/ static compugen_rc_t update_tseq(ExprTree * tree, OneModel * om, int transition_num, seq_func_table_t seq_func_table) { int index; char * dy_tseq_name; if ( om->trans[transition_num]->tseq != NULL ) { warn ( "More than one tseq" ); return COMPUGEN_TOO_MANY_CALC_FUNCS; } if ( (dy_tseq_name = get_seq_func_name(tree)) == NULL ) { warn ( "tseq name was not found in tree" ); return COMPUGEN_ILLEGAL_SEQ_EXPR; } if ( (index = get_seq_func_index(dy_tseq_name, seq_func_table)) == -1 ) { warn ( "tseq name was not found in tseq table %s", dy_tseq_name ); return COMPUGEN_ILLEGAL_SEQ_EXPR; } om->trans[transition_num]->tseq = copy_str ( seq_func_table.func[index].om_func_name ); om->trans[transition_num]->dseq = get_seq_diff ( tree ); add_seqfunc ( om->trans[transition_num]->tseq, om->seqfuncs ); return COMPUGEN_OK; } /*************************************************************************** * * FUNCTION : update_tprf * * DESCRIPTION : * * INPUT : ExprTree * tree * OneModel * om * int transition_num * * OUTPUT : None. * * RETURN : compugen_rc_t - OK / error code. * ***************************************************************************/ static compugen_rc_t update_tprf(ExprTree * tree, OneModel * om, int transition_num) { if ( om->trans[transition_num]->tprf != NULL ) { warn ( "more than one tprf" ); return COMPUGEN_TOO_MANY_CALC_FUNCS; } om->trans[transition_num]->tprf = tree; om->trans[transition_num]->tpos_tprf = tpos; om->trans[transition_num]->range = 1; tpos++; return COMPUGEN_OK; } /*************************************************************************** * * FUNCTION : update_tprf * * DESCRIPTION : * * INPUT : ExprTree * tree * OneModel * om * int transition_num * seq_func_table_t seq_func_table * * OUTPUT : None. * * RETURN : compugen_rc_t - OK / error code. * ***************************************************************************/ static compugen_rc_t update_w(ExprTree * tree, OneModel * om, int transition_num, seq_func_table_t seq_func_table, char * target_name) { compugen_rc_t rc; ExprTree * wseq_tree; if ( om->trans[transition_num]->wprf != NULL ) { warn ( "more than one wprf" ); return COMPUGEN_TOO_MANY_CALC_FUNCS; } om->trans[transition_num]->wprf = tree; om->trans[transition_num]->tpos_wprf = tpos; if ( (wseq_tree = find_wseq(tree, target_name)) == NULL ) { warn ( "No wseq was found" ); return COMPUGEN_NO_WSEQ; } if ( (rc = update_wseq(wseq_tree, om, transition_num, seq_func_table)) != COMPUGEN_OK ) return rc; tpos += om->trans[transition_num]->range; return COMPUGEN_OK; } /*************************************************************************** * * FUNCTION : update_wseq * * DESCRIPTION : * * INPUT : ExprTree * tree * OneModel * om * int transition_num * seq_func_table_t seq_func_table * * OUTPUT : None. * * RETURN : compugen_rc_t - OK / error code. * ***************************************************************************/ static compugen_rc_t update_wseq(ExprTree * tree, OneModel * om, int transition_num, seq_func_table_t seq_func_table) { int index; char * dy_wseq_name; if ( om->trans[transition_num]->wseq != NULL ) { warn ( "More than one wseq" ); return COMPUGEN_TOO_MANY_CALC_FUNCS; } if ( (dy_wseq_name = get_seq_func_name(tree)) == NULL ) { warn ( "wseq name was not found in tree"); return COMPUGEN_ILLEGAL_SEQ_EXPR; } if ( (index = get_seq_func_index(dy_wseq_name, seq_func_table)) == -1 ) { warn ( "wseq name was not found in table %s", dy_wseq_name ); return COMPUGEN_ILLEGAL_SEQ_EXPR; } om->trans[transition_num]->wseq = copy_str ( seq_func_table.func[index].om_func_name ); om->trans[transition_num]->wseq_node_to_replace = tree; om->trans[transition_num]->dwx = get_seq_diff ( tree ); om->trans[transition_num]->range = seq_func_table.func[index].range; if( seq_func_table.func[index].map_func != NULL ) om->trans[transition_num]->map_func = copy_str(seq_func_table.func[index].map_func); add_seqfunc ( om->trans[transition_num]->wseq, om->seqfuncs ); return COMPUGEN_OK; } /*************************************************************************** * * FUNCTION : find_wseq * * DESCRIPTION : * * INPUT : ExprTree * tree * * OUTPUT : None. * * RETURN : ExprTree * - wseq expression tree. * ***************************************************************************/ static ExprTree * find_wseq ( ExprTree * tree, char * target_name ) { ExprTree * wseq_tree; int i; if ( (tree->type == ETR_METHOD) && (tree->nochild == 2) && (tree->child[1]->type == ETR_COMMALIST) ) { for ( i = 0; i < tree->child[1]->nochild; i++ ) { if ( is_word(tree->child[1]->child[i], target_name) ) return tree; } } for ( i = 0; i < tree->nochild; i++ ) { if ( (wseq_tree = find_wseq(tree->child[i], target_name)) != NULL ) return wseq_tree; } return NULL; } /*************************************************************************** * * FUNCTION : get_seq_diff * * DESCRIPTION : * * INPUT : ExprTree * tree * * OUTPUT : None. * * RETURN : int - Sequence index difference. * ***************************************************************************/ static int get_seq_diff ( ExprTree * tree ) { int i; if ( (tree->type != ETR_METHOD) || (tree->nochild < 2) || (tree->child[1]->type != ETR_COMMALIST) ) { warn ( "Illegal tseq/wseq expression" ); return 0; } for ( i = 0; i < tree->child[1]->nochild; i++ ) { if ( is_word(tree->child[1]->child[i], "j") ) return 0; else if ( is_diff(tree->child[1]->child[i]) && is_word(tree->child[1]->child[i]->child[0], "j") && (tree->child[1]->child[i]->child[2]->type == ETR_NUMBER) ) return (atoi(tree->child[1]->child[i]->child[2]->word)); } return 0; } /*************************************************************************** * * FUNCTION : is_word * * DESCRIPTION : * * INPUT : ExprTree * tree * char * str * * OUTPUT : None. * * RETURN : int - TRUE / FALSE. * ***************************************************************************/ static int is_word ( ExprTree * tree, char * str ) { return ( (tree->type == ETR_TAG) && (tree->nochild == 1) && (tree->child[0]->type == ETR_NAME) && (strcmp(tree->child[0]->word, str) == 0) ); } /*************************************************************************** * * FUNCTION : is_diff * * DESCRIPTION : * * INPUT : ExprTree * tree * * OUTPUT : None. * * RETURN : int - TRUE / FALSE. * ***************************************************************************/ static int is_diff ( ExprTree * tree ) { return ( (tree->type == ETR_EXPRESSION) && (tree->nochild == 3) && (tree->child[1]->type == ETR_OPERATOR) && (strcmp(tree->child[1]->word, "-") == 0) ); } /*************************************************************************** * * FUNCTION : get_seq_func_name * * DESCRIPTION : * * INPUT : ExprTree * tree * * OUTPUT : None. * * RETURN : char * - Sequence function name. * ***************************************************************************/ static char * get_seq_func_name ( ExprTree * tree ) { if ( (tree->type != ETR_METHOD) || (tree->nochild < 1) || (tree->child[0]->type != ETR_TAG) || (tree->child[0]->nochild != 1) || (tree->child[0]->child[0]->type != ETR_NAME) ) return NULL; return tree->child[0]->child[0]->word; } /*************************************************************************** * * FUNCTION : get_seq_func_index * * DESCRIPTION : * * INPUT : char * dy_func_name * seq_func_table_t seq_func_table * * OUTPUT : None. * * RETURN : int - The index of the sequence function in the table. * ***************************************************************************/ static int get_seq_func_index ( char * dy_func_name, seq_func_table_t seq_func_table ) { int i; for ( i = 0; i < seq_func_table.funcs_num; i++ ) { if ( strcmp(seq_func_table.func[i].dy_func_name, dy_func_name) == 0 ) return i; } return -1; } /*************************************************************************** * * FUNCTION : find_trees_num * * DESCRIPTION : Finding the number of sub-trees separated by '+'. * * INPUT : ExprTree * tree * * OUTPUT : None. * * RETURN : int - The number of trees. * ***************************************************************************/ static int find_trees_num ( ExprTree * tree ) { if ( (tree == NULL) || ((tree->type == ETR_NUMBER) && (strcmp(tree->word, "0") == 0)) ) return 0; if ( is_sum_tree(tree) ) return ( find_trees_num(tree->child[0]) + find_trees_num(tree->child[2]) ); return 1; } /*************************************************************************** * * FUNCTION : divide_expr_tree * * DESCRIPTION : Dividing expression tree to sub-trees of the parts of the * expression separated by '+'. * * INPUT : ExprTree * tree * int trees_num * * OUTPUT : ExprTree * trees_array[] * * RETURN : int - New number of trees. * ***************************************************************************/ static int divide_expr_tree ( ExprTree * tree, ExprTree * trees_array[], int trees_num ) { if ( (tree == NULL) || ((tree->type == ETR_NUMBER) && (strcmp(tree->word, "0") == 0)) ) return trees_num; if ( is_sum_tree(tree) ) { trees_num = divide_expr_tree ( tree->child[0], trees_array, trees_num ); trees_num = divide_expr_tree ( tree->child[2], trees_array, trees_num ); } else { trees_array[trees_num] = tree; trees_num++; } return trees_num; } /*************************************************************************** * * FUNCTION : find_calc_type * * DESCRIPTION : Checking if the expression depends on profile, sequence, or * both. * * INPUT : ExprTree * tree * * OUTPUT : None. * * RETURN : calc_type_t - CALC_PRF / CALC_SEQ / CALC_W. * ***************************************************************************/ static calc_type_t find_calc_type(ExprTree * tree, char * query_name, char * target_name) { int is_prf = FALSE; int is_seq = FALSE; find_prf_seq ( tree, &is_prf, &is_seq, query_name, target_name ); if ( is_seq ) { if ( is_prf ) return CALC_W; else return CALC_SEQ; } return CALC_PRF; } /*************************************************************************** * * FUNCTION : find_prf_seq * * DESCRIPTION : Looking for query_name, target_name, "i" and "j" in the * expression tree. * * INPUT : ExprTree * tree * * OUTPUT : int * is_prf * int * is_seq * * RETURN : None. * ***************************************************************************/ static void find_prf_seq(ExprTree * tree, int * is_prf, int * is_seq, char * query_name, char * target_name) { int i; if ( tree == NULL ) return; if ( is_word(tree, query_name) || is_word(tree, "i") ) *is_prf = TRUE; else if ( is_word(tree, target_name) || is_word(tree, "j") ) *is_seq = TRUE; for ( i = 0; i < tree->nochild; i++ ) find_prf_seq ( tree->child[i], is_prf, is_seq, query_name, target_name ); } /*************************************************************************** * * FUNCTION : add_seqfunc * * DESCRIPTION : * * INPUT : char * new_seqfunc * char * seq_funcs[] * * OUTPUT : None. * * RETURN : compugen_rc_t * ***************************************************************************/ static compugen_rc_t add_seqfunc ( char * new_seqfunc, char * seq_funcs[] ) { int i; for ( i = 0; i < CUGEN_MAX_FUNCS; i++ ) { if ( seq_funcs[i] == NULL ) { seq_funcs[i] = copy_str ( new_seqfunc ); return COMPUGEN_OK; } else if ( strcmp(seq_funcs[i], new_seqfunc) == 0 ) return COMPUGEN_OK; } warn ( "More than %d seqfuncs", CUGEN_MAX_FUNCS ); return COMPUGEN_TOO_MANY_CALC_FUNCS; } /*************************************************************************** * * FUNCTION : * * DESCRIPTION : * * INPUT : * * OUTPUT : * * RETURN : * ***************************************************************************/ static OneModelTrans * OneModelTrans_alloc(void) { OneModelTrans * out; out = (OneModelTrans *) malloc(sizeof(OneModelTrans)); out->tprf = out->wprf = out->wseq_node_to_replace = NULL; out->tseq = out->wseq = out->from_state = out->to_state = out->name = out->map_func = NULL; out->tpos_tprf = out->tpos_wprf = out->range = out->dseq = out->dwx = out->dwy = out->dprf = 0; return out; } /*************************************************************************** * * FUNCTION : OneModel_alloc * * DESCRIPTION : * * INPUT : None. * * OUTPUT : None. * * RETURN : OneModel * * ***************************************************************************/ static OneModel * OneModel_alloc(void) { int i; OneModel * out; out= (OneModel * ) malloc(sizeof(OneModel)); for(i=0;istatenames[i] = out->semistatenames[i] = out->midstatenames[i] = NULL; } for(i=0;iseqfuncs[i] = NULL; } for(i=0;itrans[i] = NULL; } out->name = NULL; out->datatype_str = NULL; out->states_num = out->semistates_num = 0; return out; } /*************************************************************************** * * FUNCTION : make_seq_func_table * * DESCRIPTION : * * INPUT : None. * * OUTPUT : seq_func_table_t * table * * RETURN : None. * ***************************************************************************/ static void make_seq_func_table ( seq_func_table_t * table ) { table->funcs_num = 3; table->func = (seq_func_t *)calloc(3, sizeof(seq_func_t)); table->func[0].dy_func_name = copy_str ( "AMINOACID" ); table->func[0].om_func_name = copy_str ( "ID_SEQ" ); table->func[0].range = 32; table->func[0].map_func = copy_str ( "map_onemodel_aa" ); table->func[1].dy_func_name = copy_str ( "CDNA_BASE" ); table->func[1].om_func_name = copy_str ( "ID_SEQ" ); table->func[1].range = 32; table->func[0].map_func = copy_str ( "map_onemodel_base" ); table->func[2].dy_func_name = copy_str ( "CDNA_CODON" ); table->func[2].om_func_name = copy_str ( "TRIPLETS_SEQ" ); table->func[2].range = 125; table->func[0].map_func = NULL; } /*************************************************************************** * * FUNCTION : find_datatypes * * DESCRIPTION : * * INPUT : char * target_type * * OUTPUT : None. * * RETURN : char * - One model data types. * ***************************************************************************/ static char * find_datatypes(char * target_type) { if ( target_type == NULL ) return NULL; if ( strcmp(target_type, "PROTEIN") == 0 ) return "PP"; if ( (strcmp(target_type, "DNA") == 0) || (strcmp(target_type, "CDNA") == 0) || (strcmp(target_type, "GENOMIC") == 0) ) return "PN"; } /*************************************************************************** * * FUNCTION : create_semistate_name * * DESCRIPTION : * * INPUT : char * state_name * * OUTPUT : None. * * RETURN : char * - The semistate name. * ***************************************************************************/ static char * create_semistate_name ( char * state_name ) { char * semistate_name; if ( (semistate_name = (char *)malloc(strlen(state_name) + 5)) == NULL ) { perror ( "create_semistate_name : malloc" ); exit ( 1 ); } strcpy ( semistate_name, "SEMI" ); strcat ( semistate_name, state_name ); return semistate_name; } wise-2.4.1/src/dyc/compugen.h0000644000175000001440000000353507313404532015414 0ustar philippusers #ifndef COMPUGEN_HEADER #define COMPUGEN_HEADER #include "dyna2.h" #define CUGEN_MAX_ONEMODEL_TRANS 1024 #define CUGEN_MAX_STATE_NAMES 128 #define CUGEN_MAX_FUNCS 128 #define CUGEN_MAX_PRF_NUM_LEN 20 #define CUGEN_MININF -1000000 typedef struct OneModelTrans { ExprTree * tprf; ExprTree * wprf; char * tseq; ExprTree * wseq_node_to_replace; char *wseq; int tpos_tprf; int tpos_wprf; int range; int dseq; int dwx; int dwy; int dprf; char * from_state; char * to_state; char * name; int dx; int dy; char * xlabel; char * ylabel; char * map_func; } OneModelTrans; typedef struct OneModel { char *name; char * datatype_str; char * statenames [CUGEN_MAX_STATE_NAMES]; char * semistatenames[CUGEN_MAX_STATE_NAMES]; char * midstatenames [CUGEN_MAX_STATE_NAMES]; char * seqfuncs [CUGEN_MAX_FUNCS]; OneModelTrans * trans[CUGEN_MAX_ONEMODEL_TRANS]; Scope * sc; char * arg_str; char * chain_str; int states_num; int semistates_num; int prof_line_len; } OneModel; typedef enum { CALC_PRF, CALC_SEQ, CALC_W, MAX_CALC_TYPES }calc_type_t; typedef enum { COMPUGEN_OK, COMPUGEN_TOO_MANY_CALC_FUNCS, COMPUGEN_ILLEGAL_SEQ_EXPR, COMPUGEN_NO_WSEQ } compugen_rc_t; typedef struct { char * dy_func_name; char * om_func_name; int range; char * map_func; } seq_func_t; typedef struct { int funcs_num; seq_func_t * func; } seq_func_table_t; enum { OM_TMPSTART, OM_TMPEND, OM_TMP_STATES_NUM }; #define is_sum_tree(tree) \ ((tree->type == ETR_EXPRESSION) && (tree->nochild == 3) && \ (tree->child[1]->type == ETR_OPERATOR) && (strcmp(tree->child[1]->word, "+") == 0)) OneModel * OneModel_from_GenericMatrix(GenericMatrix * gm); boolean write_cugen_funcs(OneModel * om,MethodTypeSet * mts,DYNFILE * dfp); #endif wise-2.4.1/src/dyc/dynfile.dy0000644000175000001440000005023107570655062015424 0ustar philippusers/* Last edited: Apr 29 10:02 1997 (birney) */ %{ #include "wisebase.h" #include "funcinfo.h" #include "inputfile.h" #define DYNFILELISTLENGTH 1024 enum desctype { DYN_DESC_EDDY = 56 }; typedef int FuncOrderType; enum fotype { FO_CUI_ALPHABETICAL = 83, FO_CUI_POSITION }; %} struct DYNFILE int desc_type !def="DYN_DESC_EDDY" char line[1024] char *tag[128] !link int commentstart; int bracelevel !def="0" boolean infunc !def="FALSE" char * sourceroot; FILE * func !link FILE * head !link FILE * html !link FuncInfo ** info !list ModuleInfo * mi int funcpos !def="0" int code_debug_level !def="0" boolean should_hard_link !def="FALSE" char * package_name !def="NULL" %{ #include "dynfile.h" #include "linesubs.h" %func makes a pdoc for this file. %arg dfp DYNFILE object %% boolean make_pdoc_output(DYNFILE * dfp,char * mod_name,FILE * ofp) { /*int i;*/ /*** first thing is to add the module name as a link to this file ***/ fprintf(ofp,"&%s\n",mod_name); /*** at the moment we don't handle module info ***/ /*** ok - now write out a head-list for functions ***/ return TRUE; } %func reports back whether there are any undocumented file. if should_complain is TRUE, will issue warnings through warn. Writes the number of undocumented functions into no %arg dfp DYNFILE object no w pointer to some memory for the number of undoc'd funcs should_complain if TRUE, will issue warn statements %% boolean have_got_unknown_func_DYNFILE(DYNFILE * dfp,int * no,boolean should_complain) { int i; boolean ret = FALSE; *no =0; for(i=0;ilen;i++) if( dfp->info[i]->functype == FI_UNKNOWN) { ret = TRUE; (*no)++; if( should_complain == TRUE) { warn("You have not documented %s",dfp->info[i]->name); } } return ret; } %func writes basically just the #include "self.h" line in the dynamite file %% void write_Dynamite_minimal_func(DYNFILE * dfp) { fprintf(dfp->func,"#include \"%s.h\"\n\n",dfp->sourceroot); dfp->funcpos+=2; return; } %func Finds a funcinfo with name. returns NULL if it cant find them %% FuncInfo * FuncInfo_from_name_DYNFILE(DYNFILE * dfp,char * name) { int i; for(i=0;ilen;i++) if( strcmp(dfp->info[i]->name,name) == 0 ) return dfp->info[i]; return NULL; } %func Deprecated - use pdoc %type internal %% void show_html_DYNFILE(DYNFILE * dfp,FILE * ofp,FuncOrderType type) { int i; sort_DYNFILE_FuncOrderType(dfp,type); if( is_separated_types(type) == TRUE) { fprintf(ofp,"Externally called functions functions\n
    "); for(i=0;ilen;i++) { if( dfp->info[i]->functype != FI_CALLABLE) { break; } fprintf(ofp,"
  • %s \n",dfp->info[i]->name,dfp->info[i]->complete_name); } fprintf(ofp,"

Unplaced (no information about calling) functions\n

    "); for(;ilen;i++) { if( dfp->info[i]->functype != FI_UNKNOWN) { break; } fprintf(ofp,"
  • %s \n",dfp->info[i]->name,dfp->info[i]->complete_name); } fprintf(ofp,"

Internal (unlikely to be called directly) functions\n

    "); for(;ilen;i++) { fprintf(ofp,"
  • %s \n",dfp->info[i]->name,dfp->info[i]->complete_name); } fprintf(ofp,"

Externally called functions

\n"); for(i=0;ilen;i++) { if( dfp->info[i]->functype != FI_CALLABLE) { break; } fprintf(ofp," %s

Description

\n",dfp->info[i]->name,dfp->info[i]->complete_name);
      dump_Ftext(dfp->info[i]->ft,ofp);
      fprintf(ofp,"
\n"); } fprintf(ofp,"
Unplaced functions

\n"); for(;ilen;i++) { if( dfp->info[i]->functype != FI_UNKNOWN) { break; } fprintf(ofp," %s

Description

\n",dfp->info[i]->name,dfp->info[i]->complete_name);
      dump_Ftext(dfp->info[i]->ft,ofp);
      fprintf(ofp,"
\n"); } fprintf(ofp,"
Internal functions

\n"); for(;ilen;i++) { fprintf(ofp," %s

Description

\n",dfp->info[i]->name,dfp->info[i]->complete_name);
      dump_Ftext(dfp->info[i]->ft,ofp);
      fprintf(ofp,"
\n"); } } else { warn("Can't currently handle no CUI sorted Html functions, yikes"); } } %func Places the function declaration potential with package protection %type internal %% int place_func_decl(DYNFILE * dfp,FuncInfo * fi) { fprintf(dfp->head,"%s ",fi->ret->type); fprintf(dfp->head,"%s%s;\n",dfp->package_name == NULL ? "" : dfp->package_name,fi->stripped_return); if( dfp->package_name != NULL ) { fprintf(dfp->head,"#define %s %s%s\n",fi->name,dfp->package_name,fi->name); return 2; } else { return 1; } } %func writes the header declarations of functions into the header file, with documentation. The FuncOrderType is either the more common, usual order or alphabetical %% void place_declarations_DYNFILE(DYNFILE * dfp,FuncOrderType type) { int i; sort_DYNFILE_FuncOrderType(dfp,type); if( is_separated_types(type) == TRUE) { fprintf(dfp->head,"\n\n /***************************************************/\n"); fprintf(dfp->head, " /* Callable functions */\n"); fprintf(dfp->head, " /* These are the functions you are expected to use */\n"); fprintf(dfp->head, " /***************************************************/\n\n"); for(i=0;ilen;i++) { if( dfp->info[i]->functype != FI_CALLABLE) { break; } fprintf(dfp->head,"\n\n"); show_eddystyle_FuncInfo(dfp->info[i],dfp->head); place_func_decl(dfp,dfp->info[i]); } fprintf(dfp->head,"\n\n /* Unplaced functions */\n"); fprintf(dfp->head," /* There has been no indication of the use of these functions */\n"); for(;ilen;i++) { if( dfp->info[i]->functype != FI_UNKNOWN) { break; } place_func_decl(dfp,dfp->info[i]); } fprintf(dfp->head,"\n\n /***************************************************/\n"); fprintf(dfp->head, " /* Internal functions */\n"); fprintf(dfp->head, " /* you are not expected to have to call these */\n"); fprintf(dfp->head, " /***************************************************/\n"); for(;ilen;i++) { place_func_decl(dfp,dfp->info[i]); } } /*** not separated types ***/ else { for(i=0;ilen;i++) { fprintf(dfp->head,"\n\n"); show_eddystyle_FuncInfo(dfp->info[i],dfp->head); place_func_decl(dfp,dfp->info[i]); } } } %func really a sub-routine. Sorts by the FuncOrderType which can be alphabetical or by original position %type internal %% void sort_DYNFILE_FuncOrderType(DYNFILE * dfp,FuncOrderType type) { switch (type) { case FO_CUI_ALPHABETICAL : sort_DYNFILE(dfp,compare_two_FuncInfo_alpha); break; case FO_CUI_POSITION : sort_DYNFILE(dfp,compare_two_FuncInfo_pos); break; default : warn("Got an unnw FuncOrderType %d",type); } return; } %func Tells whether this sorting will separate things into Callable/unknown/internal. All sorts currently do %type internal %% boolean is_separated_types(FuncOrderType type) { if( type == FO_CUI_ALPHABETICAL || type == FO_CUI_POSITION) return TRUE; return FALSE; } %func comparison function for sorting by functype then alphabetical %type internal %% int compare_two_FuncInfo_alpha(FuncInfo * one,FuncInfo * two) { if( one->functype != two->functype ) { return one->functype - two->functype; } return strcmp(one->name,two->name); } %func comparison function for sorting by functype then by file position %type internal %% int compare_two_FuncInfo_pos(FuncInfo * one,FuncInfo * two) { if( one->functype != two->functype ) { return one->functype - two->functype; } return one->infopos - two->infopos; } %func places the positions of functions as read in the file (hopefully) into the funcinfos so can be sorted on them (and rearranged potentially) %% void positionify_DYNFILE(DYNFILE * dfp) { int i; for(i=0;ilen;i++) dfp->info[i]->infopos = i; } void show_FuncInfo_DYNFILE(DYNFILE * dfp,FuncInfo * fi) { switch (dfp->desc_type) { case DYN_DESC_EDDY : dfp->funcpos += show_eddystyle_FuncInfo(fi,dfp->func); break; default : warn("No func descirption like %d",dfp->desc_type); break; } } /** FuncInfo * find_FuncInfo_from_name_end(DYNFILE * dfp,char * name) { int i; for(i=dfp->len-1;i >= 0;i--) if( strcmp(dfp->info[i]->name,name) == 0 ) return dfp->info[i]; return NULL; } **/ /*** really for output ***/ %func complex function, better written with regex's. Tests whether the probe is actually a in a "open" string, ie. complete string outside of " or other things. this is mainly for use of finding if's and for's in C statements it is a horrible kludge, and hopefully now not used %type internal %% char * strinopen(char * target,char * probe) { register char * p; register char * t; register char * start; start = target; for(;*target;target++) { if( *target == '"') { for(target++;*target && *target != '"';target++) ; if( *target != '"' ) break; target++; } if( *target == *probe ) { if( target != start ) if( isalpha(*(target-1)) ) continue; for(p=probe,t=target;*p && *t;p++,t++) if( *p != *t ) break; if( isalpha(*(t)) ) continue; if( *p == '\0') return target; } } return NULL; } boolean real_is_unfinished_expression(char * str) { char * runner; runner = str+strlen(str)-1; while( isspace(*runner) && runner >= str ) runner--; if( runner == str) return FALSE; if( strinopen(str,"if") != NULL || strinopen(str,"for") != NULL || strinopen(str,"while") != NULL || strinopen(str,"switch") != NULL || strinopen(str,"case") != NULL || strinopen(str,"default") ) return FALSE; if( *str == '#' ) return FALSE; if( *runner == ';') return FALSE; if( (runner=strinopen(str,"else")) != NULL) { for(;isalpha(*runner) && *runner;runner++) ; for(;!isalnum(*runner) && *runner;runner++) ; if( *runner == '\0') return FALSE; else return TRUE; } return TRUE; } void flush_line(DYNFILE * dfp) { register char * temp; if( *dfp->line != '\0') { temp = scan_and_replace_line(dfp->line); fprintf(dfp->func,"%s \n",temp); strcpy(dfp->line,""); dfp->funcpos++; } } void flush_line_to_header(DYNFILE * dfp) { register char * temp; if( *dfp->line != '\0') { temp = scan_and_replace_line(dfp->line); fprintf(dfp->head,"%s \n",temp); strcpy(dfp->line,""); } } /*** this function is going to "pad" the line with spaces to the next comment block level ***/ void pad_line(DYNFILE * dfp) { register int i; int len; int nlen; if(dfp->commentstart == 0 || strlen(dfp->line)+1 > dfp->commentstart) { /** ok, have to find the new level **/ len = strlen(dfp->line); nlen = len + (len%4 == 0 ? 0 : 4-len%4); for(i=len;iline[i] = ' '; dfp->line[i]='\0'; } else { for(i=strlen(dfp->line);icommentstart;i++) dfp->line[i] = ' '; dfp->line[i]='\0'; } } /** puts in a double break **/ void add_break(DYNFILE * dfp) { flush_line(dfp); fprintf(dfp->func,"\n\n"); dfp->commentstart=0; dfp->funcpos+=2; } void start_function(DYNFILE * dfp,char * str, ...) { FuncInfo * fi; char buffer[MAXLINE]; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); /** we have no FuncInfo - make a dummy! **/ fi = FuncInfo_from_str("Undocumented function from internal dynamite code"); start_function_FuncInfo(fi,dfp,buffer); } void start_function_FuncInfo(FuncInfo * fi,DYNFILE * dfp,char * str, ... ) { char buffer[MAXLINE]; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); if( reconcile_FuncInfo_with_funcstr(fi,buffer) == FALSE ) { warn("Internal error with function [%s]: Not reconciled with documentation"); add_break_to_Ftext(fi->ft); add_line_to_Ftext(fi->ft,"WARNING: This function's internal documentation was not reconciled with its argument list"); } show_FuncInfo_DYNFILE(dfp,fi); fi->line_in_c = dfp->funcpos; fi->complete_name = stringalloc(buffer); add_DYNFILE(dfp,fi); true_start_function(dfp,buffer); } void true_start_function(DYNFILE * dfp,char * str, ... ) { va_list ap; register int i; /** put away whatever was there before **/ flush_line(dfp); for(i=0;i<128;i++) dfp->tag[i]=NULL; va_start(ap,str); vsprintf(dfp->line,str,ap); va_end(ap); if( dfp->bracelevel > 0 ) { warn("In dynfile... you are attempting to start a function [%s] inside a separate brace syste. Bad bad news!",dfp->line); } flush_line(dfp); /*** start function ***/ fprintf(dfp->func,"{\n"); dfp->funcpos++; dfp->bracelevel++; dfp->infunc = TRUE; return; } void close_function(DYNFILE * dfp) { if( dfp->infunc == FALSE ){ warn("Attempting to close a function when you are not even in one... problem surely!"); } flush_line(dfp); dfp->bracelevel--; strcpy(dfp->line,"} "); dfp->commentstart=0; pad_line(dfp); } void hang_expr(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line(dfp); dfp->bracelevel++; current_indent(dfp); dfp->bracelevel--; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); strcat(dfp->line,buffer); if( real_is_unfinished_expression(buffer) ) strcat(dfp->line,"; "); pad_line(dfp); } void expr(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line(dfp); current_indent(dfp); va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); strcat(dfp->line,buffer); if( real_is_unfinished_expression(buffer) ) strcat(dfp->line,"; "); pad_line(dfp); } void macro(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line(dfp); va_start(ap,str); vsprintf(buffer,str,ap); if(buffer[0] != '#') warn("asking for macro without # as first letter"); /** no ident! **/ strcat(dfp->line,buffer); pad_line(dfp); } void warn_expr(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; char buf2[MAXLINE]; va_list ap; flush_line(dfp); current_indent(dfp); va_start(ap,str); vsprintf(buffer,str,ap); sprintf(buf2,"warn(\"%s\");",buffer); strcat(dfp->line,buf2); pad_line(dfp); } void start_struct(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line_to_header(dfp); va_start(ap,str); vsprintf(buffer,str,ap); strcat(dfp->line,buffer); strcat(dfp->line," { "); flush_line_to_header(dfp); dfp->bracelevel=1; } void close_struct(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line_to_header(dfp); va_start(ap,str); vsprintf(buffer,str,ap); current_indent(dfp); strcat(dfp->line,"} "); strcat(dfp->line,buffer); pad_line(dfp); dfp->bracelevel--; flush_line_to_header(dfp); } void struct_macro(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line_to_header(dfp); va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); strcat(dfp->line,buffer); pad_line(dfp); } void struct_expr(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line_to_header(dfp); current_indent(dfp); va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); strcat(dfp->line,buffer); if( real_is_unfinished_expression(buffer) ) strcat(dfp->line,"; "); pad_line(dfp); } /*** Comments ***/ void add_block_comment(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line(dfp); va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); current_indent(dfp); strcat(dfp->line,"/* "); strcat(dfp->line,buffer); strcat(dfp->line," */"); dfp->commentstart=0; } void add_end_comment(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); strcat(dfp->line,"/* "); strcat(dfp->line,buffer); strcat(dfp->line," */"); flush_line(dfp); } void add_end_comment_header(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); strcat(dfp->line,"/* "); strcat(dfp->line,buffer); strcat(dfp->line," */"); flush_line_to_header(dfp); } void set_commentstart(DYNFILE * dfp,int s) { dfp->commentstart=s; } void current_indent(DYNFILE * dfp) { register int i; dfp->line[0] = '\0'; if( dfp->bracelevel == 0) return; strcat(dfp->line," "); for(i=0;ibracelevel;i++ ){ strcat(dfp->line," "); } } void startcase(DYNFILE * dfp) { flush_line(dfp); dfp->bracelevel++; } void closecase(DYNFILE * dfp) { flush_line(dfp); dfp->bracelevel--; } void startbrace_tag(DYNFILE * dfp,char * str) { strcat(dfp->line," { "); dfp->bracelevel++; strcat(dfp->line,"/*"); strcat(dfp->line,str); strcat(dfp->line,"*/"); flush_line(dfp); if( dfp->tag[dfp->bracelevel] != NULL) { warn("Missalgined tags in tag brace. Bad bad bug"); dfp->tag[dfp->bracelevel] = NULL; } dfp->tag[dfp->bracelevel]=stringalloc(str); } void startbrace(DYNFILE * dfp) { strcat(dfp->line," { "); flush_line(dfp); dfp->bracelevel++; } void closebrace(DYNFILE * dfp) { flush_line(dfp); current_indent(dfp); strcat(dfp->line,"} "); if( dfp->tag[dfp->bracelevel] != NULL) { add_end_comment(dfp,"end of %s",dfp->tag[dfp->bracelevel]); dfp->tag[dfp->bracelevel]=ckfree(dfp->tag[dfp->bracelevel]); } flush_line(dfp); dfp->bracelevel--; dfp->commentstart=0; } void fputs_func_DYNFILE(char * str,DYNFILE * dfp) { fputs(str,dfp->func); fputc('\n',dfp->func); dfp->funcpos++; } /** I/O stuff **/ DYNFILE * open_std_no_html_dynfile(char * name) { return open_std_dynfile(name,NULL); } DYNFILE * open_std_dynfile(char * name,char * html_directory) { DYNFILE * dfp; char func_buf[512]; char head_buf[512]; char html_buf[1024]; int len; if( (len=strlen(name)) > 509 ) { warn("I can't believe this, but you are attempting to open a DYNFILE with a name longer than 509 letter. Surely not! [%s]",name); return NULL; } if( html_directory != NULL && strlen(html_directory) + len > 1020 ) { warn("I can't believe this, but a combination of the html directory path and the dynamite name is over 1020 letters. Can't handle it [%s][%s]",html_directory,name); return NULL; } sprintf(func_buf,"%s.c",name); sprintf(head_buf,"%s.h",name); if( html_directory != NULL ) sprintf(html_buf,"%s/%s.html",html_directory,name); dfp = DYNFILE_alloc_std(); dfp->func = openfile(func_buf,"W"); if( dfp->func == NULL ) { close_dynfile(dfp); warn("Could not open %s as a function file",func_buf); return NULL; } dfp->head = openfile(head_buf,"W"); if( dfp->head == NULL ) { close_dynfile(dfp); warn("Could not open %s as a header file",head_buf); return NULL; } if( html_directory != NULL ) { dfp->html = openfile(html_buf,"W"); if( dfp->html == NULL ) { close_dynfile(dfp); warn("Could not open %s as a html file",html_buf); return NULL; } } /*** put in "standard" headers etc ****/ fprintf(dfp->head,"#ifndef DYNAMITE%sHEADERFILE\n#define DYNAMITE%sHEADERFILE\n",name,name); fprintf(dfp->head,"#ifdef _cplusplus\nextern \"C\" {\n#endif\n"); fprintf(dfp->func,"#ifdef _cplusplus\nextern \"C\" {\n#endif\n"); dfp->sourceroot = stringalloc(name); /*** put in standard header ***/ dfp->funcpos = 3; /* function file on its 3rd line */ return dfp; } void close_dynfile(DYNFILE * dfp) { /*** finish C function file ***/ flush_line(dfp); /*** finish C header file ***/ fprintf(dfp->func,"\n#ifdef _cplusplus\n}\n#endif\n"); fprintf(dfp->head,"\n#ifdef _cplusplus\n}\n#endif\n"); fprintf(dfp->head,"\n#endif\n"); if( dfp->html != NULL) fclose(dfp->html); if( dfp->head != NULL) fclose(dfp->head); if( dfp->func != NULL) fclose(dfp->func); dfp = free_DYNFILE(dfp); } %} wise-2.4.1/src/dyc/lex.yy.c0000644000175000001440000011204610414205303015007 0ustar philippusers/* A lexical scanner generated by flex */ /* Scanner skeleton version: * $Header: /nfs/ensembl/cvsroot/wise2/src/dyc/lex.yy.c,v 1.38 2006/04/03 11:45:07 birney Exp $ */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #include /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ #ifdef c_plusplus #ifndef __cplusplus #define __cplusplus #endif #endif #ifdef __cplusplus #include #include /* Use prototypes in function declarations. */ #define YY_USE_PROTOS /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ #if __STDC__ #define YY_USE_PROTOS #define YY_USE_CONST #endif /* __STDC__ */ #endif /* ! __cplusplus */ #ifdef __TURBOC__ #pragma warn -rch #pragma warn -use #include #include #define YY_USE_CONST #define YY_USE_PROTOS #endif #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif #ifdef YY_USE_PROTOS #define YY_PROTO(proto) proto #else #define YY_PROTO(proto) () #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yy_start - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #define YY_BUF_SIZE 16384 typedef struct yy_buffer_state *YY_BUFFER_STATE; extern int yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 /* The funky do-while in the following #define is used to turn the definition * int a single C statement (which needs a semi-colon terminator). This * avoids problems with code like: * * if ( condition_holds ) * yyless( 5 ); * else * do_something_else(); * * Prior to using the do-while the compiler would get upset at the * "else" because it interpreted the "if" statement as being all * done when it reached the ';' after the yyless() call. */ /* Return all but the first 'n' matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ *yy_cp = yy_hold_char; \ YY_RESTORE_YY_MORE_OFFSET \ yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, yytext_ptr ) /* The following is because we cannot portably get our hands on size_t * (without autoconf's help, which isn't available because we want * flex-generated scanners to compile on their own). */ typedef unsigned int yy_size_t; struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; static YY_BUFFER_STATE yy_current_buffer = 0; /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". */ #define YY_CURRENT_BUFFER yy_current_buffer /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; static int yy_init = 1; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ /* Flag which is used to allow yywrap()'s to do buffer switches * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; void yyrestart YY_PROTO(( FILE *input_file )); void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); void yy_load_buffer_state YY_PROTO(( void )); YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); static void *yy_flex_alloc YY_PROTO(( yy_size_t )); static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); static void yy_flex_free YY_PROTO(( void * )); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! yy_current_buffer ) \ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ yy_current_buffer->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! yy_current_buffer ) \ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ yy_current_buffer->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (yy_current_buffer->yy_at_bol) typedef unsigned char YY_CHAR; FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; extern char *yytext; #define yytext_ptr yytext static yy_state_type yy_get_previous_state YY_PROTO(( void )); static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); static int yy_get_next_buffer YY_PROTO(( void )); static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ yytext_ptr = yy_bp; \ yyleng = (int) (yy_cp - yy_bp); \ yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yy_c_buf_p = yy_cp; #define YY_NUM_RULES 8 #define YY_END_OF_BUFFER 9 static yyconst short int yy_accept[15] = { 0, 0, 0, 9, 6, 1, 7, 6, 5, 2, 3, 4, 2, 3, 0 } ; static yyconst int yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5, 1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1, 7, 1, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, 1, 9, 1, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst int yy_meta[10] = { 0, 1, 1, 1, 1, 1, 2, 1, 2, 2 } ; static yyconst short int yy_base[16] = { 0, 0, 0, 14, 15, 15, 15, 6, 15, 6, 0, 15, 5, 0, 15, 8 } ; static yyconst short int yy_def[16] = { 0, 14, 1, 14, 14, 14, 14, 14, 14, 14, 15, 14, 14, 15, 0, 14 } ; static yyconst short int yy_nxt[25] = { 0, 4, 5, 6, 7, 8, 9, 4, 10, 4, 13, 12, 12, 11, 14, 3, 14, 14, 14, 14, 14, 14, 14, 14, 14 } ; static yyconst short int yy_chk[25] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 15, 12, 9, 7, 3, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 } ; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; #line 1 "calc.l" #define INITIAL 0 #line 3 "calc.l" #include "y.tab.h" #include "exprtree.h" #ifdef LINUX #undef YY_INPUT #define YY_INPUT(b, r, ms) (r = my_yyinput(b, ms)) #undef yywrap #endif extern char * calc_lex_string; extern int stringpos; #ifndef LINUX #undef input #undef unput #endif #line 388 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int yywrap YY_PROTO(( void )); #else extern int yywrap YY_PROTO(( void )); #endif #endif #ifndef YY_NO_UNPUT static void yyunput YY_PROTO(( int c, char *buf_ptr )); #endif #ifndef yytext_ptr static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen YY_PROTO(( yyconst char * )); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput YY_PROTO(( void )); #else static int input YY_PROTO(( void )); #endif #endif #if YY_STACK_USED static int yy_start_stack_ptr = 0; static int yy_start_stack_depth = 0; static int *yy_start_stack = 0; #ifndef YY_NO_PUSH_STATE static void yy_push_state YY_PROTO(( int new_state )); #endif #ifndef YY_NO_POP_STATE static void yy_pop_state YY_PROTO(( void )); #endif #ifndef YY_NO_TOP_STATE static int yy_top_state YY_PROTO(( void )); #endif #else #define YY_NO_PUSH_STATE 1 #define YY_NO_POP_STATE 1 #define YY_NO_TOP_STATE 1 #endif #ifdef YY_MALLOC_DECL YY_MALLOC_DECL #else #if __STDC__ #ifndef __cplusplus #include #endif #else /* Just try to get by without declaring the routines. This will fail * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) * or sizeof(void*) != sizeof(int). */ #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ if ( yy_current_buffer->yy_is_interactive ) \ { \ int c = '*', n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL int yylex YY_PROTO(( void )) #endif /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ YY_USER_ACTION YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; #line 24 "calc.l" #line 541 "lex.yy.c" if ( yy_init ) { yy_init = 0; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! yy_start ) yy_start = 1; /* first start state */ if ( ! yyin ) yyin = stdin; if ( ! yyout ) yyout = stdout; if ( ! yy_current_buffer ) yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); yy_load_buffer_state(); } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = yy_c_buf_p; /* Support of yytext. */ *yy_cp = yy_hold_char; /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = yy_start; yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 15 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 15 ); yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ yy_cp = yy_last_accepting_cpos; yy_current_state = yy_last_accepting_state; yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = yy_hold_char; yy_cp = yy_last_accepting_cpos; yy_current_state = yy_last_accepting_state; goto yy_find_action; case 1: YY_RULE_SETUP #line 25 "calc.l" ; YY_BREAK case 2: YY_RULE_SETUP #line 26 "calc.l" { yylval.tr = new_ExprTree(); yylval.tr->type = ETR_NUMBER; yylval.tr->word = stringalloc((char * )yytext); /* printf("Got a number %s\n",yytext); */ return NUMBER; } YY_BREAK case 3: YY_RULE_SETUP #line 32 "calc.l" { yylval.tr = new_ExprTree(); yylval.tr->type = ETR_NAME; yylval.tr->word = stringalloc((char * )yytext); /* printf("Got a name %s \n",yytext);*/ return NAME; } YY_BREAK case 4: YY_RULE_SETUP #line 38 "calc.l" { yylval.tr = new_ExprTree(); yylval.tr->word = stringalloc((char * )yytext); yylval.tr->type = ETR_OPERATOR; return STRUCTREF; } YY_BREAK case 5: YY_RULE_SETUP #line 43 "calc.l" { yylval.tr = new_ExprTree(); yylval.tr->word = stringalloc((char * )yytext); yylval.tr->type = ETR_OPERATOR; return STRUCTREF; } YY_BREAK case 6: YY_RULE_SETUP #line 49 "calc.l" { /* printf("operator\n"); */ return yytext[0]; } YY_BREAK case 7: YY_RULE_SETUP #line 53 "calc.l" return 0; YY_BREAK case 8: YY_RULE_SETUP #line 54 "calc.l" ECHO; YY_BREAK #line 683 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = yy_hold_char; YY_RESTORE_YY_MORE_OFFSET if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure * consistency between yy_current_buffer and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ yy_n_chars = yy_current_buffer->yy_n_chars; yy_current_buffer->yy_input_file = yyin; yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) { /* This was really a NUL. */ yy_state_type yy_next_state; yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state(); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = yytext_ptr + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++yy_c_buf_p; yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = yy_c_buf_p; goto yy_find_action; } } else switch ( yy_get_next_buffer() ) { case EOB_ACT_END_OF_FILE: { yy_did_buffer_switch_on_eof = 0; if ( yywrap() ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state(); yy_cp = yy_c_buf_p; yy_bp = yytext_ptr + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: yy_c_buf_p = &yy_current_buffer->yy_ch_buf[yy_n_chars]; yy_current_state = yy_get_previous_state(); yy_cp = yy_c_buf_p; yy_bp = yytext_ptr + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer() { register char *dest = yy_current_buffer->yy_ch_buf; register char *source = yytext_ptr; register int number_to_move, i; int ret_val; if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( yy_current_buffer->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ yy_current_buffer->yy_n_chars = yy_n_chars = 0; else { int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ #ifdef YY_USES_REJECT YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); #else /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = yy_current_buffer; int yy_c_buf_p_offset = (int) (yy_c_buf_p - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ yy_flex_realloc( (void *) b->yy_ch_buf, b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1; #endif } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), yy_n_chars, num_to_read ); yy_current_buffer->yy_n_chars = yy_n_chars; } if ( yy_n_chars == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart( yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; yy_current_buffer->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; yy_n_chars += number_to_move; yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state() { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = yy_start; for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 15 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ #ifdef YY_USE_PROTOS static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) #else static yy_state_type yy_try_NUL_trans( yy_current_state ) yy_state_type yy_current_state; #endif { register int yy_is_jam; register char *yy_cp = yy_c_buf_p; register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yy_last_accepting_state = yy_current_state; yy_last_accepting_cpos = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 15 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 14); return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_UNPUT #ifdef YY_USE_PROTOS static void yyunput( int c, register char *yy_bp ) #else static void yyunput( c, yy_bp ) int c; register char *yy_bp; #endif { register char *yy_cp = yy_c_buf_p; /* undo effects of setting up yytext */ *yy_cp = yy_hold_char; if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ register int number_to_move = yy_n_chars + 2; register char *dest = &yy_current_buffer->yy_ch_buf[ yy_current_buffer->yy_buf_size + 2]; register char *source = &yy_current_buffer->yy_ch_buf[number_to_move]; while ( source > yy_current_buffer->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); yy_current_buffer->yy_n_chars = yy_n_chars = yy_current_buffer->yy_buf_size; if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; yytext_ptr = yy_bp; yy_hold_char = *yy_cp; yy_c_buf_p = yy_cp; } #endif /* ifndef YY_NO_UNPUT */ #ifdef __cplusplus static int yyinput() #else static int input() #endif { int c; *yy_c_buf_p = yy_hold_char; if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) /* This was really a NUL. */ *yy_c_buf_p = '\0'; else { /* need more input */ int offset = yy_c_buf_p - yytext_ptr; ++yy_c_buf_p; switch ( yy_get_next_buffer() ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart( yyin ); /* fall through */ case EOB_ACT_END_OF_FILE: { if ( yywrap() ) return EOF; if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: yy_c_buf_p = yytext_ptr + offset; break; } } } c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ *yy_c_buf_p = '\0'; /* preserve yytext */ yy_hold_char = *++yy_c_buf_p; return c; } #ifdef YY_USE_PROTOS void yyrestart( FILE *input_file ) #else void yyrestart( input_file ) FILE *input_file; #endif { if ( ! yy_current_buffer ) yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); yy_init_buffer( yy_current_buffer, input_file ); yy_load_buffer_state(); } #ifdef YY_USE_PROTOS void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) #else void yy_switch_to_buffer( new_buffer ) YY_BUFFER_STATE new_buffer; #endif { if ( yy_current_buffer == new_buffer ) return; if ( yy_current_buffer ) { /* Flush out information for old buffer. */ *yy_c_buf_p = yy_hold_char; yy_current_buffer->yy_buf_pos = yy_c_buf_p; yy_current_buffer->yy_n_chars = yy_n_chars; } yy_current_buffer = new_buffer; yy_load_buffer_state(); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ yy_did_buffer_switch_on_eof = 1; } #ifdef YY_USE_PROTOS void yy_load_buffer_state( void ) #else void yy_load_buffer_state() #endif { yy_n_chars = yy_current_buffer->yy_n_chars; yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; yyin = yy_current_buffer->yy_input_file; yy_hold_char = *yy_c_buf_p; } #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) #else YY_BUFFER_STATE yy_create_buffer( file, size ) FILE *file; int size; #endif { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; yy_init_buffer( b, file ); return b; } #ifdef YY_USE_PROTOS void yy_delete_buffer( YY_BUFFER_STATE b ) #else void yy_delete_buffer( b ) YY_BUFFER_STATE b; #endif { if ( ! b ) return; if ( b == yy_current_buffer ) yy_current_buffer = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) yy_flex_free( (void *) b->yy_ch_buf ); yy_flex_free( (void *) b ); } #ifndef YY_ALWAYS_INTERACTIVE #ifndef YY_NEVER_INTERACTIVE extern int isatty YY_PROTO(( int )); #endif #endif #ifdef YY_USE_PROTOS void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) #else void yy_init_buffer( b, file ) YY_BUFFER_STATE b; FILE *file; #endif { yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; #if YY_ALWAYS_INTERACTIVE b->yy_is_interactive = 1; #else #if YY_NEVER_INTERACTIVE b->yy_is_interactive = 0; #else b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; #endif #endif } #ifdef YY_USE_PROTOS void yy_flush_buffer( YY_BUFFER_STATE b ) #else void yy_flush_buffer( b ) YY_BUFFER_STATE b; #endif { if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == yy_current_buffer ) yy_load_buffer_state(); } #ifndef YY_NO_SCAN_BUFFER #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) #else YY_BUFFER_STATE yy_scan_buffer( base, size ) char *base; yy_size_t size; #endif { YY_BUFFER_STATE b; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; yy_switch_to_buffer( b ); return b; } #endif #ifndef YY_NO_SCAN_STRING #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) #else YY_BUFFER_STATE yy_scan_string( yy_str ) yyconst char *yy_str; #endif { int len; for ( len = 0; yy_str[len]; ++len ) ; return yy_scan_bytes( yy_str, len ); } #endif #ifndef YY_NO_SCAN_BYTES #ifdef YY_USE_PROTOS YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) #else YY_BUFFER_STATE yy_scan_bytes( bytes, len ) yyconst char *bytes; int len; #endif { YY_BUFFER_STATE b; char *buf; yy_size_t n; int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = len + 2; buf = (char *) yy_flex_alloc( n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < len; ++i ) buf[i] = bytes[i]; buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; b = yy_scan_buffer( buf, n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ b->yy_is_our_buffer = 1; return b; } #endif #ifndef YY_NO_PUSH_STATE #ifdef YY_USE_PROTOS static void yy_push_state( int new_state ) #else static void yy_push_state( new_state ) int new_state; #endif { if ( yy_start_stack_ptr >= yy_start_stack_depth ) { yy_size_t new_size; yy_start_stack_depth += YY_START_STACK_INCR; new_size = yy_start_stack_depth * sizeof( int ); if ( ! yy_start_stack ) yy_start_stack = (int *) yy_flex_alloc( new_size ); else yy_start_stack = (int *) yy_flex_realloc( (void *) yy_start_stack, new_size ); if ( ! yy_start_stack ) YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); } yy_start_stack[yy_start_stack_ptr++] = YY_START; BEGIN(new_state); } #endif #ifndef YY_NO_POP_STATE static void yy_pop_state() { if ( --yy_start_stack_ptr < 0 ) YY_FATAL_ERROR( "start-condition stack underflow" ); BEGIN(yy_start_stack[yy_start_stack_ptr]); } #endif #ifndef YY_NO_TOP_STATE static int yy_top_state() { return yy_start_stack[yy_start_stack_ptr - 1]; } #endif #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif #ifdef YY_USE_PROTOS static void yy_fatal_error( yyconst char msg[] ) #else static void yy_fatal_error( msg ) char msg[]; #endif { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ yytext[yyleng] = yy_hold_char; \ yy_c_buf_p = yytext + n; \ yy_hold_char = *yy_c_buf_p; \ *yy_c_buf_p = '\0'; \ yyleng = n; \ } \ while ( 0 ) /* Internal utility routines. */ #ifndef yytext_ptr #ifdef YY_USE_PROTOS static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) #else static void yy_flex_strncpy( s1, s2, n ) char *s1; yyconst char *s2; int n; #endif { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN #ifdef YY_USE_PROTOS static int yy_flex_strlen( yyconst char *s ) #else static int yy_flex_strlen( s ) yyconst char *s; #endif { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif #ifdef YY_USE_PROTOS static void *yy_flex_alloc( yy_size_t size ) #else static void *yy_flex_alloc( size ) yy_size_t size; #endif { return (void *) malloc( size ); } #ifdef YY_USE_PROTOS static void *yy_flex_realloc( void *ptr, yy_size_t size ) #else static void *yy_flex_realloc( ptr, size ) void *ptr; yy_size_t size; #endif { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } #ifdef YY_USE_PROTOS static void yy_flex_free( void *ptr ) #else static void yy_flex_free( ptr ) void *ptr; #endif { free( ptr ); } #if YY_MAIN int main() { yylex(); return 0; } #endif #line 54 "calc.l" #ifdef LINUX int my_yyinput(char * buf,int max_size) { int i; /* fprintf(stderr,"[%s] Got into yyinput, calling %d and with %d in string\n",calc_lex_string,max_size,stringpos); */ if( calc_lex_string[stringpos] == '\0') { /* fprintf(stderr,"Going to return 0\n"); */ buf[0] = EOF; return 0; } for(i=0;i< max_size && calc_lex_string[stringpos] != '\0';i++,stringpos++) { buf[i] = calc_lex_string[stringpos]; } buf[i] = EOF; /* fprintf(stderr,"Returning %d\n",i); */ return i; } int yywrap(void) { return 1; } #else char input(void) { return calc_lex_string[stringpos++]; } void unput(char c) { calc_lex_string[--stringpos] = c; } #endif wise-2.4.1/src/dyc/dymain.c0000644000175000001440000000015310670453715015053 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dymain.h" # line 5 "dymain.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/dymain.h0000644000175000001440000000130410670453715015057 0ustar philippusers#ifndef DYNAMITEdymainHEADERFILE #define DYNAMITEdymainHEADERFILE #ifdef _cplusplus extern "C" { #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/dyna2.dy0000644000175000001440000014370007553750750015014 0ustar philippusers/* Last edited: Apr 24 11:36 1997 (birney) */ Dynamite GenericMatrix I/O file %{ #include "wisebase.h" #include "wisec.h" #include "exprtree.h" #include "type.h" #define CellSourceLISTLENGTH 64 #define CellStateLISTLENGTH 64 #define GenericMatrixLISTLENGTH 64 #define CellExprLISTLENGTH 64 #define CellSignatureSetLISTLENGTH 64 #define STANDARDGENERICMATRIX 231 #define SEARCHGENERICMATRIX 232 #define VARIABLEGENERICMATRIX 234 enum calc_unit { GENERICMATRIX_IDEPCALCUNIT = 214, GENERICMATRIX_JDEPCALCUNIT, GENERICMATRIX_IJDEPCALCUNIT } ; /* * Ok, gets a bit weird: if position is less * than 21 then it has the bit number from the * bit positions so it can be warned properely * Look at source_bit2position function. */ enum source_positon { SOURCE_POS_ALL = 16, SOURCE_POS_TOPLEFT = 32, SOURCE_POS_TOP = 64, SOURCE_POS_LEFT = 128, SOURCE_POS_BOTTOM = 256, SOURCE_POS_RIGHT = 512, SOURCE_POS_BOTTOMRIGHT = 1024 }; #define SOURCE_TOP_BIT 1 #define SOURCE_LEFT_BIT 2 #define SOURCE_BOTTOM_BIT 4 #define SOURCE_RIGHT_BIT 8 %} struct CellSignature int offi int offj struct CellSignatureSet CellSignature ** sig !list struct CellSource char * state_source; int offi; !def="-1" int offj; !def="-1" char * calc_expr // going to replace CellExpr list possibly char * source_expr ExprTree * etr; boolean isspecial !def="FALSE" char * query_label; char * target_label; int position; !def="SOURCE_POS_ALL" int trans_no; // unique number for this transition int from_state_no; struct CellState char * name; !def="NULL" char * def_score; !def="NULL" char * calc_expr; !def="NULL" char * source_expr; !def="NULL" int offi; !def="0" int offj; !def="0" boolean is_special_i !def="FALSE" boolean is_special_j !def="FALSE" boolean is_end !def="FALSE" boolean is_start !def="FALSE" boolean specialtospecial !def="FALSE" CellSource ** source !list char * query_char; !def="NULL" char * target_char; !def="NULL" int footprint_start !def="0" int footprint_end !def="1" char * query_label !def="NULL" char * target_label !def="NULL" int position; !def="SOURCE_POS_ALL" ExprTree * etr !def="NULL" int state_number !def="-1" struct CollapsableLabel char * query; !def="NULL" char * target; !def="NULL" struct ExternVariable char * name; char * type; struct GenericMatrix char * name; int type; CellState ** state !list CellState ** special !list !len="spec_" StructElement * query; char * query_name; char * query_len; Type * qtype; !link StructElement * target; char * target_name; char * target_len; Type * ttype !link StructElement ** resource !list !len="res_" CollapsableLabel ** cal !list !len="cal_" ExternVariable ** ev !list !len="ev_" char * defscore_all_states; int window_i; int window_j; int footprint; !def="1" boolean cansearch !def="FALSE" boolean canlabel !def="FALSE" boolean specialtospecial !def="FALSE" StructHolder * sh; // where structure for matrix is placed char * calcfunc !def="FALSE" Scope * sc !def="FALSE" MethodTypeSet * mts !def="NULL" %{ #include "dyna2.h" /*********************************/ /* Access and checking functions */ /*********************************/ CellSignatureSet * CellSignatureSet_from_GenericMatrix(GenericMatrix * gm) { int i; int j; int k; CellSignatureSet * out; CellSignature * sig; out = CellSignatureSet_alloc_std(); for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { for(k=0;klen;k++) { if( gm->state[i]->source[j]->offi == out->sig[k]->offi && gm->state[i]->source[j]->offj == out->sig[k]->offj) { break; } } if( k >= out->len ) { /* new */ sig = CellSignature_alloc(); sig->offi = gm->state[i]->source[j]->offi; sig->offj = gm->state[i]->source[j]->offj; add_CellSignatureSet(out,sig); } } } return out; } boolean can_do_threads(GenericMatrix * gm) { if( gm->qtype != NULL ) { if( gm->qtype->is_thread_safe == FALSE ) return FALSE; } if( gm->ttype != NULL ) { if( gm->ttype->is_thread_safe == FALSE ) return FALSE; } return TRUE; } CellState * CellState_from_str(GenericMatrix * gm,char * str) { register int i; for(i=0;ilen;i++) if( strcmp(gm->state[i]->name,str) == 0) return gm->state[i]; for(i=0;ispec_len;i++) if( strcmp(gm->special[i]->name,str) == 0) return gm->special[i]; return NULL; } %func main function to check GenericMatrix onced parsed checks state defaults state/source cross references labels calc epxressions types and type migration calc parsing %arg gm rw GenericMatrix to be checked mts r Type and Method Scope failing_errors r Calc line parser on which errors fail %% boolean prepare_matrix(GenericMatrix * gm,MethodTypeSet * mts,DycWarning * dycw,ParseError failing_errors) { boolean ret = TRUE; ParseError pe; push_errormsg_stack("In preparing matrix %s",gm->name); (void) calc_footprint(gm); /* this must happen first */ if( cross_reference_state_and_source(gm) == FALSE ) { warn("Unable to cross reference state and source"); ret = FALSE; } /* now this to provide score setting */ if( check_start_end(gm) == FALSE ) { warn("Start/End points are faulty"); ret = FALSE; } /* set global score */ gm->defscore_all_states = stringalloc("NEGI"); if( perculate_state_defaults(gm) == FALSE ) { warn("Unable to perculate state defaults"); ret = FALSE; } if( assign_source_no(gm) == FALSE ) { warn("Weird! unable to assign source numbers!"); ret = FALSE; } if( prepare_labels(gm) == FALSE ) { warn("Unable to prepare labels"); ret = FALSE; } if( handle_names(gm) == FALSE ) { warn("Unable to handle all the resource/query/target objects"); ret = FALSE; } if( check_source_positions(gm) == FALSE ) { warn("Unable to resolve positions"); ret = FALSE; } if( calc_window(gm) == FALSE ) { warn("Unable to calculate window"); ret = FALSE; } if( check_cell_refs(gm) == FALSE ) { warn("Unable to resolve all the cell offset refs into correct offsets"); ret = FALSE; } if( make_StructHolder_for_GenericMatrix(gm,mts) == FALSE ) { warn("Unable to build structure holder for GenericMatrix"); ret = FALSE; } if( ret == FALSE ) { warn("Failing simple cross-checks, aborting before calc-line parsing"); pop_errormsg_stack(); return FALSE; } pe = parse_calc_line_GenericMatrix(gm,mts,dycw); if( pe & failing_errors ) { warn("Failed to parse calc lines"); fprintf(stderr,"\nThe following parser errors were considered fatal:\n"); complain_ParseError_to_file(pe & failing_errors,stderr); if( (pe & (~failing_errors)) != 0 ) { fprintf(stderr,"\nThe following parser errors are only warnings:\n"); complain_ParseError_to_file(pe & (~failing_errors),stderr); } fprintf(stderr,"\n"); ret = FALSE; } gm->mts = hard_link_MethodTypeSet(mts); /*** Very hacky to conform to old gm code: type migration moves logical types to real. This is ok for now, but it does mean that in the function writing code we have lost the logical type information. So... probably should have the mts in the middle of function code. ***/ if( ret == TRUE ) handle_type_migration(gm,mts); pop_errormsg_stack(); return ret; } %func Adds a unique transition number for CellSource %% boolean assign_source_no(GenericMatrix * gm) { int i,j; int no = 0; for(i=0;ilen;i++) for(j=0;jstate[i]->len;j++) gm->state[i]->source[j]->trans_no = no++; for(i=0;ispec_len;i++) for(j=0;jspecial[i]->len;j++) gm->special[i]->source[j]->trans_no = no++; return TRUE; } %func Adds the current generic matrix variables to the scope with "mat->" as scope resolver %type internal %% void add_GenericMatrix_Scope(Scope * sc,GenericMatrix * gm) { int i; ScopeUnit * su; su = ScopeUnit_from_nat(NULL,"i","","int"); su->no_accept = stringalloc(gm->target->name); add_Scope(sc,su); su = ScopeUnit_from_nat(NULL,"j","","int"); su->no_accept = stringalloc(gm->query->name); add_Scope(sc,su); su = ScopeUnit_from_nat(NULL,"mat","","*Matrix*"); add_Scope(sc,su); su = ScopeUnit_from_nat(NULL,gm->query->name,"mat->",gm->query->element_type); su->no_accept = stringalloc("j"); add_Scope(sc,su); su = ScopeUnit_from_nat(NULL,gm->target->name,"mat->",gm->target->element_type); su->no_accept = stringalloc("i"); add_Scope(sc,su); for(i=0;ires_len;i++) { su = ScopeUnit_from_nat(NULL,gm->resource[i]->name,"mat->",gm->resource[i]->element_type); add_Scope(sc,su); } for(i=0;iev_len;i++) { su = ScopeUnit_from_nat(NULL,gm->ev[i]->name,"",gm->ev[i]->type); add_Scope(sc,su); } } %func Function which actually does the loop over calc lines. Importantly calls /allocd_calc_line from type.dy for the main parsing %type internal %% ParseError parse_calc_line_GenericMatrix(GenericMatrix * gm,MethodTypeSet * mts,DycWarning * dycw) { ParseError pe = 0; char * temp; int i; int j; Scope * sc; ExprTree * expr; sc = std_Dynamite_Scope(); add_GenericMatrix_Scope(sc,gm); gm->sc = sc; for(i=0;ilen;i++) { if( gm->state[i]->calc_expr != NULL ) { push_errormsg_stack("In parsing calc line for state [%s] (source ind.)",gm->state[i]->name); temp = allocd_calc_line(gm->state[i]->calc_expr,sc,mts,dycw,&pe,&expr); if( temp == NULL ) { temp = stringalloc(gm->state[i]->calc_expr); } gm->state[i]->source_expr = gm->state[i]->calc_expr; gm->state[i]->calc_expr = temp; gm->state[i]->etr = expr; pop_errormsg_stack(); } for(j=0;jstate[i]->len;j++) { push_errormsg_stack("In parsing calc line for state [%s] source [%s]",gm->state[i]->name,gm->state[i]->source[j]->state_source); temp = allocd_calc_line(gm->state[i]->source[j]->calc_expr,sc,mts,dycw,&pe,&expr); if( temp == NULL ) { temp = stringalloc(gm->state[i]->source[j]->calc_expr); } gm->state[i]->source[j]->source_expr = gm->state[i]->source[j]->calc_expr; gm->state[i]->source[j]->calc_expr = temp; gm->state[i]->source[j]->etr = expr; pop_errormsg_stack(); } } for(i=0;ispec_len;i++) { if( gm->special[i]->calc_expr != NULL ) { push_errormsg_stack("In parsing calc line for state [%s] (source ind.)",gm->special[i]->name); temp = allocd_calc_line(gm->special[i]->calc_expr,sc,mts,dycw,&pe,&expr); if( temp == NULL ) { temp = stringalloc(gm->special[i]->calc_expr); } gm->special[i]->source_expr = gm->special[i]->calc_expr; gm->special[i]->calc_expr = temp; gm->special[i]->etr = expr; pop_errormsg_stack(); } for(j=0;jspecial[i]->len;j++) { push_errormsg_stack("In parsing calc line for state [%s] source [%s]",gm->special[i]->name,gm->special[i]->source[j]->state_source); temp = allocd_calc_line(gm->special[i]->source[j]->calc_expr,sc,mts,dycw,&pe,&expr); if( temp == NULL ) { temp = stringalloc(gm->special[i]->source[j]->calc_expr); } gm->special[i]->source[j]->source_expr = gm->special[i]->source[j]->calc_expr; gm->special[i]->source[j]->calc_expr = temp; gm->special[i]->source[j]->etr = expr; pop_errormsg_stack(); } } return pe; } %func calculates window_i and window_j %type internal %% boolean calc_window(GenericMatrix * gm) { register int i; register int j; int ilen = 0; int jlen = 0; for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; for(j=0;jlen;j++) { if( state->source[j]->offi > ilen ) ilen = state->source[j]->offi; if( state->source[j]->offj > jlen ) jlen = state->source[j]->offj; } } gm->window_i = ilen; gm->window_j = jlen; return TRUE; } %func checks we have a start + end (and only 1 each!) and sets start's defscore to 0 %% boolean check_start_end(GenericMatrix * gm) { int i; int j; boolean ret = TRUE; for(i=0;ispec_len;i++) { if( gm->special[i]->is_end == TRUE ) { if( gm->special[i]->is_start == TRUE ) { warn("Trying to make state %s both the start and the end!",gm->special[i]->name); ret = FALSE; } break; } } if( i == gm->spec_len ) { for(i=0;ispec_len;i++) { if( strcmp(gm->special[i]->name,"END") == 0 ) { warn("You have not got a !end special, but you do have a END special state. Presuming that you wanted to make that the END ;)"); gm->special[i]->is_end = TRUE; break; } } if( i == gm->spec_len) { warn("You have no end special state. Impossible matrix"); ret = FALSE; } } else { /*** check there are no more end states ***/ for(j=i+1;jspec_len;j++) { if( gm->special[j]->is_end == TRUE ) { warn("Special state %s is also end (as well as %s)",gm->special[j]->name,gm->special[i]->name); } } } /*** end of else ***/ /*** done end, do start ***/ for(i=0;ispec_len;i++) { if( gm->special[i]->is_start == TRUE ) { if( gm->special[i]->is_end == TRUE ) { warn("Trying to make state %s both the start and the end!",gm->special[i]->name); ret = FALSE; } break; } } if( i == gm->spec_len ) { for(i=0;ispec_len;i++) { if( strcmp(gm->special[i]->name,"START") == 0 ) { warn("You have not got a !start special, but you do have a START special state. Presuming that you wanted to make that the START ;)"); gm->special[i]->is_start = TRUE; break; } } if( i == gm->spec_len) { warn("You have no start special state. Impossible matrix"); ret = FALSE; } } else { /*** check there are no more start states ***/ for(j=i+1;jspec_len;j++) { if( gm->special[j]->is_start == TRUE ) { warn("Special state %s is also start (as well as %s)",gm->special[j]->name,gm->special[i]->name); } } /*** set score for start = 0 **/ gm->special[i]->def_score = stringalloc("0"); } /*** end of else ***/ return ret; } %func checks the top/bottom/left/right source positions %% boolean check_source_positions(GenericMatrix * gm) { int i; int j; boolean ret = TRUE; for(i=0;ilen;i++){ auto CellState * s; s = gm->state[i]; for(j=0;jlen;j++) { if( j == 0 && s->source[0]->isspecial == TRUE ) { warn("For [%s] source [%s] your first transition is from a special. This is not allowed currently to make code generation easier. There must be a non-special transition to place here. could you rearrange your dy file?",s->name,s->source[0]->state_source); ret = FALSE; } if( s->source[j]->position < 16 ) { ret = FALSE; warn("For [%s] source [%s] you have an impossible position vector (top/left/bottom/right 1/2/4/8) %d",s->name,s->source[j]->state_source,s->source[j]->position); } else { if( s->source[j]->position == SOURCE_POS_ALL ) continue; /* fine */ if( s->source[j]->isspecial == FALSE ) { warn("For [%s] source [%s] you have indicated an edge to calculate on, but it is a non special source",s->name,s->source[j]->state_source); ret = FALSE; } else if( s->source[j]->position != SOURCE_POS_TOPLEFT && s->source[j]->position != SOURCE_POS_TOPLEFT ) { /*** allow? ***/ /* warn("Really sorry, you have a lone top bottem left or right source which is not yet implemented. talk to Ewan for a work around"); ret = FALSE; */ } } } } for(i=0;ispec_len;i++){ auto CellState * s; s = gm->special[i]; for(j=0;jlen;j++) { if( s->source[j]->position < 16 ) { ret = FALSE; warn("For [%s] source [%s] you have an impossible position vector (top/left/bottom/right 1/2/4/8) %d",s->name,s->source[j]->state_source,s->source[j]->position); } else { if( s->source[j]->position == SOURCE_POS_ALL ) continue; /* fine */ else if( (s->source[j]->position == SOURCE_POS_TOPLEFT || s->source[j]->position == SOURCE_POS_TOP || s->source[j]->position == SOURCE_POS_BOTTOM || s->source[j]->position == SOURCE_POS_BOTTOMRIGHT) && s->source[j]->isspecial == TRUE) { warn("State [%s] source [%s] has top/bottom tags - but it is a special to special. Surely you only mean left (no top/bottom concept to specials)",s->name,s->source[j]->state_source); ret = FALSE; } } } } return ret; } %func calculates footprint now useless %type internal %% boolean calc_footprint(GenericMatrix * gm) { register int i; register int foot = 1; for(i=0;ilen;i++) if( gm->state[i]->footprint_end > foot ) foot = gm->state[i]->footprint_end; gm->footprint = foot; return TRUE; } %func makes sure each source has a state %type internal %% boolean cross_reference_state_and_source(GenericMatrix * gm) { register int i; register int j; for(i=0;ilen;i++) { gm->state[i]->state_number = i; } j = gm->len; for(i=0;ispec_len;i++) { gm->special[i]->state_number = i+j; } for(i=0;ilen;i++) { auto CellState * state; auto CellState * temp; state = gm->state[i]; for(j=0;jlen;j++) { if( (temp=CellState_from_str(gm,state->source[j]->state_source)) == NULL){ warn("In matrix %s - State %s asks for source %s but there is no State of that name",gm->name,state->name,state->source[j]->state_source); return FALSE; } if( temp->is_special_i == TRUE || temp->is_special_j == TRUE) state->source[j]->isspecial = TRUE; state->source[j]->from_state_no = temp->state_number; } } for(i=0;ispec_len;i++) { auto CellState * state; auto CellState * temp; state = gm->special[i]; for(j=0;jlen;j++) { if( (temp=CellState_from_str(gm,state->source[j]->state_source)) == NULL) { warn("In matrix %s - State %s asks for source %s but there is no State of that name",gm->name,state->name,state->source[j]->state_source); return FALSE; } if( temp->is_special_i == TRUE || temp->is_special_j == TRUE) { state->source[j]->isspecial = TRUE; state->specialtospecial = TRUE; gm->specialtospecial = TRUE; } } } return TRUE; } boolean check_cell_refs(GenericMatrix * gm) { boolean ret = TRUE; register int i; register int j; for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { if( gm->state[i]->source[j]->offi == 0 && gm->state[i]->source[j]->offj == 0 ) { warn("In state %s (source %s), both offi and offj are zero: dynamite cannot currently handle cell internal references",gm->state[i]->name,gm->state[i]->source[j]->state_source); ret = FALSE; } if( gm->state[i]->source[j]->offi < 0 || gm->state[i]->source[j]->offj < 0 ) { warn("In state %s, offi,offj [%d][%d] has some negative indices: offi and offj are always positive, probably you should just strip off the negative signs",gm->state[i]->name,gm->state[i]->source[j]->offi,gm->state[i]->source[j]->offj); ret = FALSE; } } } for(i=0;ispec_len;i++) { for(j=0;jspecial[i]->len;j++) { if( gm->special[i]->source[j]->isspecial == TRUE ) { if( gm->special[i]->source[j]->offj == 0 ) { warn("In special state %s, source %s (also special) got a offj of zero, an impossible reference",gm->special[i]->name,gm->special[i]->source[j]->state_source); ret = FALSE; } } else { if( gm->special[i]->source[j]->offj != 0 ) { warn("In special state %s, source %s (a main matrix cell) got an offset of non zero (%d). This cannot be modelled at the moment",gm->special[i]->name,gm->special[i]->source[j]->state_source, gm->special[i]->source[j]->offj); ret = FALSE; } } if( gm->special[i]->source[j]->offj < 0 ) { warn("In special state %s, source %s, offj is %d (Negative!), and you can't have negative offsets", gm->special[i]->name,gm->special[i]->source[j]->state_source); ret = FALSE; } } } return ret; } boolean prepare_labels(GenericMatrix * gm) { boolean all_labelled = TRUE; boolean ret = TRUE; register int i; register int j; for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; for(j=0;jlen;j++) { if( state->source[j]->query_label == NULL ) { warn("For state %s, source %s, missing a query_label",state->name,state->source[j]->state_source); ret = FALSE; } if( state->source[j]->target_label == NULL ) { warn("For state %s, source %s, missing a target_label",state->name,state->source[j]->state_source); ret = FALSE; } } } for(i=0;ispec_len;i++) { auto CellState * state; state = gm->special[i]; for(j=0;jlen;j++) { if( state->source[j]->query_label == NULL ) { warn("For state %s, source %s, missing a query_label",state->name,state->source[j]->state_source); ret = FALSE; } if( state->source[j]->target_label == NULL ) { warn("For state %s, source %s, missing a target_label",state->name,state->source[j]->state_source); ret = FALSE; } } } gm->canlabel = all_labelled; return ret; } boolean handle_names(GenericMatrix * gm) { boolean ret = TRUE; register int i; if( gm->query->name == NULL ) { warn("Your query [type %s] had no name: calling it 'query'",CKS(gm->query->element_type)); gm->query->name = stringalloc("query"); } if( gm->target->name == NULL ) { warn("Your target [type %s] had no name: calling it 'target'",CKS(gm->target->element_type)); gm->target->name = stringalloc("target"); } for(i=0;ires_len;i++) { if( gm->resource[i]->name == NULL ) { warn("Resource number %d had no name... cannot process",i); ret = FALSE; } if( gm->resource[i]->element_type == NULL ) { warn("Resource number %d had no type... cannot process",i); ret = FALSE; } } return ret; } boolean handle_type_migration(GenericMatrix * gm,MethodTypeSet * mts) { register int i; Type * t; if( gm->query_len == NULL ) { gm->query_len = length_string_from_GenericMatrix_type(gm->query->element_type); } if( gm->target_len == NULL ) { gm->target_len = length_string_from_GenericMatrix_type(gm->target->element_type); } if( (t = Type_from_name(mts,gm->query->element_type)) != NULL) { ckfree(gm->query->element_type); gm->query->element_type = stringalloc(t->real); gm->qtype = t; } if( (t = Type_from_name(mts,gm->target->element_type)) != NULL) { ckfree(gm->target->element_type); gm->target->element_type = stringalloc(t->real); gm->ttype = t; } for(i=0;ires_len;i++) { if( (t = Type_from_name(mts,gm->resource[i]->element_type)) != NULL) { ckfree(gm->resource[i]->element_type); gm->resource[i]->element_type = stringalloc(t->real); } } return TRUE; } boolean perculate_state_defaults(GenericMatrix * gm) { register int i; register int j; boolean ret = TRUE; for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; if( state->def_score == NULL) { if( gm->defscore_all_states == NULL ) { warn("State %s has no specific default score and you have not specified a global default score",state->name); ret = FALSE; } state->def_score = stringalloc( gm->defscore_all_states); } for(j=0;jlen;j++) { if( state->source[j]->offi == -1 ) state->source[j]->offi = state->offi; if( state->source[j]->offj == -1 ) state->source[j]->offj = state->offj; /*** now do labels ***/ if( state->source[j]->query_label == NULL && state->query_label != NULL ) state->source[j]->query_label = stringalloc(state->query_label); if( state->source[j]->target_label == NULL && state->target_label != NULL ) state->source[j]->target_label = stringalloc(state->target_label); } } for(i=0;ispec_len;i++) { auto CellState * state; state = gm->special[i]; gm->special[i]->is_special_i = TRUE; if( state->def_score == NULL) { if( gm->defscore_all_states == NULL ) { warn("State %s has no specific default score and you have not specified a global default score",state->name); ret = FALSE; } state->def_score = stringalloc( gm->defscore_all_states); } for(j=0;jlen;j++) { if( state->source[j]->offi == -1 ) state->source[j]->offi = state->offi; if( state->source[j]->offj == -1 ) state->source[j]->offj = state->offj; /*** now do labels ***/ if( state->source[j]->query_label == NULL && state->query_label != NULL ) state->source[j]->query_label = stringalloc(state->query_label); if( state->source[j]->target_label == NULL && state->target_label != NULL ) state->source[j]->target_label = stringalloc(state->target_label); } } return ret; } boolean make_StructHolder_for_GenericMatrix(GenericMatrix * gm,MethodTypeSet * mts) { StructHolder * out; StructElement * temp; register int i; out = StructHolder_alloc_std(); if( out == NULL ) { warn("Unable to build generic matrix %s's structure",gm->name); return FALSE; } out->name = stringalloc(gm->name); temp = basic_add_StructElement(out,"basematrix","BaseMatrix *"); temp->def=stringalloc("NULL"); if( temp == NULL ) { warn("Serious problem - unable to add one of the structelements in make_StructHolder_for_GenericMatrix"); return FALSE; } temp = basic_add_StructElement(out,"shatter","ShatterMatrix *"); temp->def=stringalloc("NULL"); temp = basic_add_StructElement(out,"leni","int"); temp->def=stringalloc("0"); if( temp == NULL ) { warn("Serious problem - unable to add one of the structelements in make_StructHolder_for_GenericMatrix"); return FALSE; } temp = basic_add_StructElement(out,"lenj","int"); temp->def=stringalloc("0"); if( temp == NULL ) { warn("Serious problem - unable to add one of the structelements in make_StructHolder_for_GenericMatrix"); return FALSE; } /*** ok... this is now typed! ***/ temp = StructElement_from_MethodTypeSet(gm->query->name,gm->query->element_type,mts); add_StructHolder(out,temp); temp = StructElement_from_MethodTypeSet(gm->target->name,gm->target->element_type,mts); add_StructHolder(out,temp); for(i=0;ires_len;i++) { temp = StructElement_from_MethodTypeSet(gm->resource[i]->name,gm->resource[i]->element_type,mts); temp->isfunc = gm->resource[i]->isfunc; add_StructHolder(out,temp); } gm->sh = out; return TRUE; } StructElement * StructElement_for_GenericMatrix_type(char * name,char * element) { StructElement * out; if( name == NULL || element == NULL ) { warn("In trying to make a struct element for GenericMatrix type, got some NULL fields... this is not good"); return NULL; } out = (StructElement *) ckalloc (sizeof(StructElement)); if( strcmp(element,"PROTEIN") == 0 || strcmp(element,"GENOMIC") == 0 || strcmp(element,"CDNA") == 0 ) { out->element_type = stringalloc("ComplexSequence *"); } else { out->element_type = stringalloc(element); } out->name = stringalloc(name); out->islinked = TRUE; return out; } char * length_string_from_GenericMatrix_type(char * element) { if( strcmp(element,"PROTEIN") == 0 ) return stringalloc("seq->len"); if( strcmp(element,"GENOMIC") == 0 || strcmp(element,"CDNA") == 0 || strcmp(element,"DNA") == 0) return stringalloc("seq->len"); else { warn("Cannot automatically find length string for element type [%s] (perhaps it is not a logical type). You" " should have a field:len in this line if it is not a logical type. Assuming [len] anyway",element); return stringalloc("len"); } } boolean can_interpret_type(char * type) { if( strcmp(type,"PROTEIN") == 0 || strcmp(type,"GENOMIC") == 0 || strcmp(type,"CDNA") == 0) return TRUE; return FALSE; } char * interpret_type(char * type) { if( strcmp(type,"PROTEIN") == 0 || strcmp(type,"GENOMIC") == 0 || strcmp(type,"CDNA") == 0) return stringalloc("ComplexSequence *"); return NULL; } CellState * start_CellState_from_GenericMatrix(GenericMatrix * gm) { register int i; for(i=0;ispec_len;i++) { if(gm->special[i]->is_start == TRUE ) return gm->special[i]; } return NULL; } CellState * end_CellState_from_GenericMatrix(GenericMatrix * gm) { register int i; for(i=0;ispec_len;i++) { if(gm->special[i]->is_end == TRUE ) return gm->special[i]; } return NULL; } /***************************/ /* noddy display functions */ /***************************/ void show_GenericMatrix(GenericMatrix * gm,char padchar,FILE * ofp) { register int i; fprintf(ofp,"Matrix: %s\n",gm->name); fprintf(ofp,"Query Type [%s] Name [%s]\n",gm->query->element_type,gm->query->name); fprintf(ofp,"Target Type [%s] Name [%s]\n",gm->target->element_type,gm->target->name); for(i=0;ires_len;i++) fprintf(ofp,"Resource Type[%s] Name [%s]\n",gm->resource[i]->element_type,gm->resource[i]->name); for(i=0;ilen;i++) show_CellState(gm->state[i],padchar,1,ofp); } void show_CellState(CellState * cell,char padchar,int num,FILE * ofp) { register int i; fprintf(ofp,"\nFor state %s\n",cell->name); for(i=0;idef_score == NULL ? "ANY [NULL STRING]" : cell->def_score); for(i=0;icalc_expr)); for(i=0;ioffi); for(i=0;ioffj); for(i=0;ilen;i++) show_CellSource(cell->source[i],padchar,num+1,ofp); } void show_CellSource(CellSource * cell,char padchar,int num,FILE * ofp) { register int i; for(i=0;istate_source == NULL ? "ANY [NULL STRING]" : cell->state_source); for(i=0;ioffi); for(i=0;ioffj); } /*********************/ /* Parsing functions */ /*********************/ GenericMatrix * read_GenericMatrix(FILE * ifp) { char buffer[MAXLINE]; GenericMatrix * out = NULL; while( get_watched_line(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"matrix") == 0) { out = read_GenericMatrix_line(buffer,ifp); break; } } if( out == NULL ) warn("Unable to read GenericMatrix"); while( get_watched_line(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"%{") == 0) break; } return out; } GenericMatrix * read_GenericMatrix_line(char * line,FILE * ifp) { GenericMatrix * out; ExternVariable * ev; CellState * temp; char buffer[MAXLINE]; char ** base; char ** splitstr; char * runner; StructElement * res_temp; boolean isspecial = FALSE; CollapsableLabel * cal; base=splitstr=breakstring(line,spacestr); if( strcmp(*splitstr,"matrix") != 0) { log_full_error(WARNING,0,"In parsing the line starting %s it had no matrix tag!",line); return NULL; } splitstr++; if( *splitstr == NULL ) { log_full_error(WARNING,0,"In parsing the first matrix line there was no matrix name: must have matrix ",line); return NULL; } out = GenericMatrix_alloc_std(); if( out == NULL ) return NULL; out->name = stringalloc(*splitstr); push_errormsg_stack("In reading matrix definition for %s",out->name); ckfree(base); while( get_watched_line(buffer,MAXLINE,ifp) != NULL) { chop_newline(buffer); if( strwhitestartcmp(buffer,"#",spacestr) == 0 ) continue; if( only_whitespace(buffer,spacestr) == TRUE) continue; if( strstartcmp(buffer,"endmatrix") == 0) break; if( strwhitestartcmp(buffer,"endmatrix",spacestr) == 0 ) { warn("endmatrix tag not flush to the start of the line. Ok, but not in the specification"); break; } if( strstartcmp(buffer,"end") == 0 ) { warn("got an 'end' tag [%s] but expecting a 'endmatrix'. Considering this a parse failure"); goto error; } /*** ok, proper parsing now ****/ if( strwhitestartcmp(buffer,"collapse",spacestr) == 0 ) { cal = read_CollapsableLabel_line(buffer); if( cal == NULL ) { warn("Cannot read Collapsable label line. Ignoring collapsed label"); continue; } add_cal_GenericMatrix(out,cal); continue; } else if( strwhitestartcmp(buffer,"extern",spacestr) == 0 ){ ev = read_ExternVariable_line(buffer); if( ev == NULL ) { warn("unable to read an Extern line"); } else add_ev_GenericMatrix(out,ev); continue; } else if( strwhitestartcmp(buffer,"state",spacestr) == 0) { if( strstr(buffer,"!special") != NULL ) isspecial = TRUE; else if ( strstr(buffer,"SPECIAL") != NULL ) { warn("In state [%s], got a SPECIAL tag. This has been replaced with !special for consistency. Please change ;)",buffer); isspecial = TRUE; } else isspecial = FALSE; /*********************************************/ /* this function actually reads in the state */ /* block */ /*********************************************/ temp = read_CellState_line(buffer,ifp); /* read in state */ if( temp == NULL ) { /* warning already issued, just chain */ /* warn("unable to read line for CellState in GenericMatrix %s - going to fail",out->name); */ goto error; } if( isspecial == FALSE) { if( add_GenericMatrix(out,temp) == FALSE ) { warn("Able to read - but unable to add - line for CellState in GeericMatrix %s - going to return now",out->name); goto error; } } else { if( add_spec_GenericMatrix(out,temp) == FALSE ) { warn("Able to read - but unable to add - line for CellState in GeericMatrix %s - going to return now",out->name); goto error; } } continue; /* should not chop up line! */ } /**** OK not a state line, hence a "processed" line ****/ /* split up line, look at first word, decide what to do */ /* - probably loop through the rest of the words to */ /* to read out - these are the for(splitstr++; etc loops*/ base=splitstr=breakstring(buffer,spacestr); /* NB, base free'd at the end of the if/else switch */ if( strwhitestartcmp(*splitstr,"query",spacestr) == 0) { if( out->query_name != NULL ) { log_full_error(WARNING,0,"This is the second time to specify a query - only one allowed: ignoring [%s]",buffer); continue; } /*** allocate's memory etc ready */ out->query = StructElement_alloc(); for(splitstr++;*splitstr;splitstr++) { if( (runner=string_from_quoted_equality(*splitstr)) == NULL ) { warn("You have specified a modifier [%s] to query but it has either no '=' sign or no quoted argument. The '=' character should be flush to both the tag and the quoted (using \") argument",CKS(*splitstr)); continue; } if( strstartcmp(*splitstr,"name") == 0 ) { out->query->name = runner; } else if ( strstartcmp(*splitstr,"field:name") == 0) { out->query_name = runner; } else if ( strstartcmp(*splitstr,"field:len") == 0) { out->query_len = runner; } else if ( strstartcmp(*splitstr,"type") == 0) { out->query->element_type = runner; } else { warn("Got modify %s=%s fine for tag query - but don't know what to do with it!",*splitstr,runner); ckfree(runner); } } /* end of query modifers */ } /* end of query if */ else if( strwhitestartcmp(*splitstr,"target",spacestr) == 0) { if( out->target_name != NULL ) { log_full_error(WARNING,0,"This is the second time to specify a target - only one allowed Ignoring [%s]",buffer); } /*** allocate's memory etc ready */ out->target = StructElement_alloc(); for(splitstr++;*splitstr;splitstr++) { if( (runner=string_from_quoted_equality(*splitstr)) == NULL ) { warn("You have specified a modifier [%s] to target but it has either no '=' sign or no quoted argument. The '=' character should be flush to both the tag and the quoted (using \") argument",CKS(*splitstr)); continue; } if( strstartcmp(*splitstr,"name") == 0 ) { out->target->name = runner; } else if ( strstartcmp(*splitstr,"field:name") == 0) { out->target_name = runner; } else if ( strstartcmp(*splitstr,"field:len") == 0) { out->target_len = runner; } else if ( strstartcmp(*splitstr,"type") == 0) { out->target->element_type = runner; } else { warn("Got modify %s=%s fine for tag target - but don't know what to do with it!",*splitstr,runner); ckfree(runner); } } /* end of target modifers */ } /* end of target if */ else if( strstartcmp(*splitstr,"resource") == 0) { /*** allocate's memory etc ready */ res_temp = StructElement_alloc(); add_res_GenericMatrix(out,res_temp); for(splitstr++;*splitstr;splitstr++) { if( (runner=string_from_quoted_equality(*splitstr)) == NULL ) { warn("You have specified a modifier [%s] to resource but it has either no '=' sign or no quoted argument. The '=' character should be flush to both the tag and the quoted (using \") argument",CKS(*splitstr)); continue; } if( strstartcmp(*splitstr,"name") == 0 ) { res_temp->name = runner; } else if ( strstartcmp(*splitstr,"type") == 0) { res_temp->element_type = runner; } else { warn("Got modifier %s=%s fine for tag resource - but don't know what to do with it!",*splitstr,runner); ckfree(runner); } } /* end of resource modifers */ } /* end of resource if */ else if( strstartcmp(*splitstr,"globaldefaultscore") == 0) { warn("No need for globaldefaultscore lines anymore"); } else if ( strstartcmp(*splitstr,"calcfunc") == 0) { if( *++splitstr == NULL ) { warn("Got a calcfunc tag with no function!"); } else { out->calcfunc = stringalloc(*splitstr); } } else { warn("Could not understand line in matrix parse"); } ckfree(base); } pop_errormsg_stack(); return out; error : pop_errormsg_stack(); out = free_GenericMatrix(out); return NULL; } %func reads line like extern name="xxx" type="xxx" %% ExternVariable * read_ExternVariable_line(char * line) { ExternVariable * out; char ** base; char ** brk; char * nameq = NULL; char * tq = NULL; if( strwhitestartcmp(line,"extern",spacestr) != 0 ) { warn("Tried to pass read_ExternVariable_line without an extern tag. Nope!"); return NULL; } base = brk = breakstring(line,spacestr); for(;*brk != NULL;brk++) { if( strcmp(*brk,"extern") == 0 ) continue; if( strstartcmp(*brk,"name") == 0 ) { if( (nameq = string_from_quoted_equality(*brk)) == NULL) { warn("In reading extern line, got a name tag, but no argument. The tag should have no whitespace between aname and equals"); continue; } } else if ( strstartcmp(*brk,"type") == 0 ) { if( (tq = string_from_quoted_equality(*brk)) == NULL) { warn("In reading extern line, got a type tag, but no argument. The tag should have no whitespace between the type and ="); continue; } } else { warn("Did not understand tag [%s] in extern line",*brk); } } ckfree(base); out = ExternVariable_alloc(); out->name = nameq; out->type = tq; return out; } CollapsableLabel * read_CollapsableLabel_line(char * line) { CollapsableLabel * out; char * runner; char * run2; if( strwhitestartcmp(line,"collapse",spacestr) != 0 ) { warn("Tried to pass read_CollapsableLabel_line a no collapse line. Problem!"); return NULL; } runner = strtok(line,spacestr); runner = strtok(NULL,spacestr); run2 = strtok(NULL,spacestr); if( runner == NULL || run2 == NULL) { warn("Collapsable line has no collapsable label. Ooops"); return NULL; } out = CollapsableLabel_alloc(); if( out == NULL) return NULL; out->query = stringalloc(runner); out->target = stringalloc(run2); return out; } CellState * read_CellState_line(char * line,FILE * ifp) { CellState * out; CellSource * temp; char buffer[MAXLINE]; char ** base; char ** splitstr; char * runner; /*** allocate and die if no memory ***/ /*** warnings should be issued in ***/ /*** alloc ***/ /*** check state and name and Loop through the current line given ****/ base=splitstr=breakstring(line,spacestr); if( strcmp(*splitstr,"state") != 0) { log_full_error(WARNING,0,"In parsing the line starting %s it had no state tag!",line); return NULL; } splitstr++; if( *splitstr == NULL ) { log_full_error(WARNING,0,"In parsing the line source [%s] there was no state name",line); return NULL; } out = CellState_alloc_std(); if( out == NULL ) return NULL; out->name = stringalloc(*splitstr); push_errormsg_stack("In Reading state %s",out->name); /*** looping through first line ***/ for(splitstr++;*splitstr;splitstr++) { if( strstartcmp(*splitstr,"offi") == 0) { runner=string_from_quoted_equality(*splitstr); if( runner == NULL ) { warn("Unable to read offi in state %s. The tag should look like offi=\"\" with no whitespace",out->name); continue; } out->offi = atoi(runner); ckfree(runner); } else if ( strstartcmp(*splitstr,"offj") == 0) { runner=string_from_quoted_equality(*splitstr); if( runner == NULL ) { warn("Unable to read offj in state %s. The tag should look like offj=\"\" with no whitespace",out->name); continue; } out->offj = atoi(runner); ckfree(runner); } else if ( strstartcmp(*splitstr,"defscore") == 0) { warn("No need for defscore lines anymore"); } else if ( strstartcmp(*splitstr,"calc") == 0) { runner=string_from_quoted_equality(*splitstr); if( runner == NULL ) { warn("Unable to read source independent calc line in state %s. Remember that there should be no white space between calc and the \"string\", ie calc=\"gap\" ",out->name); continue; } out->calc_expr=runner; } else if ( strstartcmp(*splitstr,"!special") == 0) { out->is_special_i=TRUE; } else if ( strstartcmp(*splitstr,"SPECIAL") == 0) { out->is_special_i=TRUE; } else if ( strstartcmp(*splitstr,"!end") == 0) { out->is_end = TRUE; } else if ( strstartcmp(*splitstr,"!start") == 0) { out->is_start = TRUE; } else { warn("Parse error in state %s - cannot make sense of %s",out->name,*splitstr); } } ckfree(base); while( get_watched_line(buffer,MAXLINE,ifp) != NULL) { chop_newline(buffer); if( strwhitestartcmp(buffer,"#",spacestr) == 0 ) continue; if( strwhitestartcmp(buffer,"endstate",spacestr) == 0 ) break; if( only_whitespace(buffer,spacestr) == TRUE) continue; if( strwhitestartcmp(buffer,"end",spacestr) == 0 ) { warn("Got an end line [%s] but expecting endstate. Will fail.",buffer); goto error; } if( strwhitestartcmp(buffer,"state",spacestr) == 0 ) { warn("Got the line [%s], a state start line inside a state. Expect you forgot an endstate.",buffer); goto error; } if( strwhitestartcmp(buffer,"query_label",spacestr) == 0 ) { base = splitstr = breakstring(buffer,spacestr); splitstr++; if( *splitstr == NULL ) { warn("Picked up query_label tag but no query label in state %s",out->name); } else out->query_label = stringalloc(*splitstr); ckfree(base); continue; } if( strwhitestartcmp(buffer,"target_label",spacestr) == 0 ) { base = splitstr = breakstring(buffer,spacestr); splitstr++; if( *splitstr == NULL ) { warn("Picked up target_label tag but no target label in state %s",out->name); } else out->target_label = stringalloc(*splitstr); ckfree(base); continue; } if( strwhitestartcmp(buffer,"calc",spacestr) == 0 ) { base = splitstr = breakstring(buffer,spacestr); if( out->calc_expr != NULL ) { warn("Already picked up a calc line [%s]. Replacing with %s\n",out->calc_expr,runner); ckfree(out->calc_expr); } out->calc_expr = string_from_quoted_equality(*splitstr); ckfree(base); continue; } else if( strstr(buffer,"source") == NULL) { warn("Parse error in reading state %s - cannot interpret [%s]",out->name,buffer); continue; } temp = read_CellSource_line(buffer,ifp); /* fprintf(stderr,"Have read source line!\n"); */ if( temp == NULL ) { /* warning already issued, just chain back up */ /* warn("unable to read line for CellSource in CellState %s - going to fail parser",out->name); */ goto error; } if( add_CellState(out,temp) == FALSE ) { warn("Able to read - but unable to add - line for CellSource in CellState %s - going to return now",out->name); goto error; } } pop_errormsg_stack(); return out; error : pop_errormsg_stack(); out = free_CellState(out); return NULL; } int source_bit2pos(int bit) { if( bit == 0 ) return SOURCE_POS_ALL; if( (bit & SOURCE_TOP_BIT) ) { if( (bit & SOURCE_LEFT_BIT) ) { return SOURCE_POS_TOPLEFT; } if( (bit & ~SOURCE_TOP_BIT) != 0 ) { return bit; } else return SOURCE_POS_TOP; } if( (bit & SOURCE_LEFT_BIT) ) { if( (bit & ~SOURCE_LEFT_BIT) != 0 ) return bit; else return SOURCE_POS_LEFT; } if( (bit & SOURCE_BOTTOM_BIT) ) { if( (bit & SOURCE_RIGHT_BIT) ) { return SOURCE_POS_BOTTOMRIGHT; } if( (bit & ~SOURCE_BOTTOM_BIT) != 0 ) { return bit; } else return SOURCE_POS_BOTTOM; } if( (bit & SOURCE_RIGHT_BIT) ) { if( (bit & ~SOURCE_RIGHT_BIT) != 0 ) return bit; else return SOURCE_POS_RIGHT; } warn("Got a HIDEOUS error in source_bit2pos"); return SOURCE_POS_ALL; } CellSource * read_CellSource_line(char * line,FILE * ifp) { CellSource * out; char buffer[MAXLINE]; char * runner; char * temp; char ** base; char ** splitstr; int posbits = 0; /** use with SOURCE_TOP_BIT etc **/ /* parse first line */ base=splitstr=breakstring(line,spacestr); if( strcmp(*splitstr,"source") != 0) { warn("In parsing the line starting %s it had no source tag!",line); return NULL; } splitstr++; if( *splitstr == NULL ) { warn("In parsing the line source [%s] there was no source tag",line); return NULL; } out = CellSource_alloc(); if( out == NULL) return NULL; out->state_source = stringalloc(*splitstr); push_errormsg_stack("In reading source %s",out->state_source); for(splitstr++;*splitstr;splitstr++) { if( strstartcmp(*splitstr,"offi") == 0) { runner=string_from_quoted_equality(*splitstr); if( runner == NULL ) { warn("Unable to read offi in Source %s",line); continue; } out->offi = atoi(runner); ckfree(runner); } else if ( strstartcmp(*splitstr,"offj") == 0) { runner=string_from_quoted_equality(*splitstr); if( runner == NULL ) { warn("Unable to read offi in Source %s",line); continue; } out->offj = atoi(runner); ckfree(runner); } else if ( strcmp(*splitstr,"!top") == 0 ) { posbits = (posbits | SOURCE_TOP_BIT); } else if ( strcmp(*splitstr,"!left") == 0 ) { posbits = (posbits | SOURCE_LEFT_BIT); } else if ( strcmp(*splitstr,"!right") == 0 ) { posbits = (posbits | SOURCE_RIGHT_BIT); } else if ( strcmp(*splitstr,"!bottom") == 0 ) { posbits = (posbits | SOURCE_BOTTOM_BIT); } else { warn("Parse error in source %s - cannot make sense of %s",line,*splitstr); } } out->position = source_bit2pos(posbits); ckfree(base); while( get_watched_line(buffer,MAXLINE,ifp) != NULL) { chop_newline(buffer); if( strwhitestartcmp(buffer,"#",spacestr) == 0 ) continue; if( only_whitespace(buffer,spacestr) == TRUE) continue; if( strwhitestartcmp(buffer,"endsource",spacestr) == 0 ) break; if( strwhitestartcmp(buffer,"end",spacestr) == 0 ) { warn("you have a end line [%s] but expecting an endsource line. Will fail",buffer); goto error; } if( strwhitestartcmp(buffer,"source",spacestr) == 0 ) { warn("In reading a source, got a source tag [%s]. Expect you forgot an endsource. Will fail",buffer); goto error; } if( strwhitestartcmp(buffer,"query_label",spacestr) == 0 ) { base = splitstr = breakstring(buffer,spacestr); splitstr++; if( *splitstr == NULL ) { warn("Picked up query_label tag but no query label in source %s",out->state_source); } else out->query_label = stringalloc(*splitstr); ckfree(base); continue; } else if( strwhitestartcmp(buffer,"target_label",spacestr) == 0 ) { base = splitstr = breakstring(buffer,spacestr); splitstr++; if( *splitstr == NULL ) { warn("Picked up target_label tag but no target label in source %s",out->state_source); } else out->target_label = stringalloc(*splitstr); ckfree(base); continue; } else if( strwhitestartcmp(buffer,"calc",spacestr) == 0 ) { temp = read_calc_line(buffer); if( temp == NULL ) { warn("unable to read calc line in Source %s - going to return now",out->state_source); return NULL; } out->calc_expr = stringalloc(temp); } else { warn("Cannot understand the line [%s] on CellSource",buffer); } } pop_errormsg_stack(); return out; error : pop_errormsg_stack(); out = free_CellSource(out); return NULL; } char * read_calc_line(char * buffer) { char * runner; /* get to = */ for(;*buffer && *buffer != '=';buffer++) ; /* get to " */ for(;*buffer && *buffer != '"';buffer++) ; if( *buffer == '\0' ) { warn("In reading calc line string, got to the end of the buffer without gettint to a \""); return NULL; } runner = buffer+1; for(buffer++;*buffer && *buffer != '"';buffer++) ; *buffer='\0'; return runner; } %} wise-2.4.1/src/dyc/dynadb.c0000644000175000001440000002532310670453715015041 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dynadb.h" /* Function: make_search_loop_function(dfp,gm) * * Descrip: Makes the serial search function, which loops * over databases * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ # line 20 "dynadb.dy" void make_search_loop_function(DYNFILE * dfp,GenericMatrix * gm) { int i; char buffer[MAXLINE]; FuncInfo * fi; boolean qdb = FALSE; boolean tdb = FALSE; char * cstr; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"serial_search_%s",gm->name); add_line_to_Ftext(fi->ft,"This function makes a database search of %s",gm->name); add_line_to_Ftext(fi->ft,"It is a single processor implementation"); if( gm->qtype != NULL && gm->qtype->is_database == TRUE) qdb = TRUE; if( gm->ttype != NULL && gm->ttype->is_database == TRUE) tdb = TRUE; if( qdb == TRUE) sprintf(buffer,"Search_Return_Type serial_search_%s(Hscore * out,%s querydb,",gm->name,gm->qtype->database_type); else sprintf(buffer,"Search_Return_Type serial_search_%s(Hscore * out,%s %s,",gm->name,gm->query->element_type,gm->query->name); if( tdb == TRUE) { strcat(buffer,gm->ttype->database_type); strcat(buffer," targetdb "); } else { strcat(buffer,gm->target->element_type); strcat(buffer," "); strcat(buffer,gm->target->name); strcat(buffer," "); } for(i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,gm->resource[i]->element_type); strcat(buffer," "); strcat(buffer,gm->resource[i]->name); } strcat(buffer,")"); start_function_FuncInfo(fi,dfp,buffer); if( qdb == TRUE ) expr(dfp,"%s %s",gm->query->element_type,gm->query->name); if( tdb == TRUE ) expr(dfp,"%s %s",gm->target->element_type,gm->target->name); expr(dfp,"int db_status"); expr(dfp,"int score"); expr(dfp,"int query_pos = 0;"); expr(dfp,"int target_pos = 0;"); expr(dfp,"DataScore * ds;"); add_break(dfp); expr(dfp,"push_errormsg_stack(\"Before any actual search in db searching\");"); if( qdb == TRUE) { expr(dfp,"%s = %s(querydb,&db_status);",gm->query->name,gm->qtype->init_func); expr(dfp,"if( db_status == DB_RETURN_ERROR ) "); startbrace(dfp); warn_expr(dfp,"In searching %s, got a database reload error on the query [%s] database",gm->name,gm->query->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); expr(dfp,"for(;;)"); startbrace_tag(dfp,"For all query entries"); } add_break(dfp); expr(dfp,"target_pos = 0"); add_break(dfp); if( tdb == TRUE) { expr(dfp,"%s = %s(targetdb,&db_status);",gm->target->name,gm->ttype->init_func); expr(dfp,"if( db_status == DB_RETURN_ERROR ) "); startbrace(dfp); warn_expr(dfp,"In searching %s, got a database init error on the target [%s] database",gm->name,gm->target->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); expr(dfp,"for(;;)"); startbrace_tag(dfp,"For all target entries"); } add_break(dfp); cstr = get_chainstr_GenericMatrix(gm); if(gm->qtype != NULL && gm->qtype->maxlen != NULL) { add_block_comment(dfp,"Maximum length to search - should check"); expr(dfp,"if( %s->%s > %s ) ",gm->query->name,gm->query_len,gm->qtype->maxlen); startbrace_tag(dfp,"if over length"); warn_expr(dfp,"A query over the length when maxlen provided. Problem!"); expr(dfp,"score = -10000;\n"); closebrace(dfp); expr(dfp,"else"); hang_expr(dfp,"score = score_only_%s(%s)",gm->name,cstr); } else { add_block_comment(dfp,"No maximum length - allocated on-the-fly"); expr(dfp,"score = score_only_%s(%s)",gm->name,cstr); } ckfree(cstr); expr(dfp,"if( should_store_Hscore(out,score) == TRUE ) "); startbrace_tag(dfp,"if storing datascore"); expr(dfp,"ds = new_DataScore_from_storage(out)"); expr(dfp,"if( ds == NULL ) "); startbrace(dfp); warn_expr(dfp,"%s search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure",gm->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); add_block_comment(dfp,"Now: add query/target information to the entry"); if( qdb == TRUE) expr(dfp,"%s(ds->query,%s,querydb)",gm->qtype->dataentry_add,gm->query->name); if( tdb == TRUE) expr(dfp,"%s(ds->target,%s,targetdb)",gm->ttype->dataentry_add,gm->target->name); expr(dfp,"ds->score = score"); expr(dfp,"add_Hscore(out,ds);"); closebrace(dfp); /* end of if stores */ expr(dfp,"pop_errormsg_stack()"); expr(dfp,"push_errormsg_stack(\"DB searching: just finished [Query Pos: %%d] [Target Pos: %%d]\",query_pos,target_pos);"); add_break(dfp); if( tdb == TRUE ) { expr(dfp," %s = %s(%s,targetdb,&db_status)",gm->target->name,gm->ttype->reload_func,gm->target->name); expr(dfp,"if( db_status == DB_RETURN_ERROR )"); startbrace(dfp); expr(dfp,"warn(\"In searching %s, Reload error on database %s, position %%d,%%d\",query_pos,target_pos);",gm->name,gm->target->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); expr(dfp,"if( db_status == DB_RETURN_END )"); hang_expr(dfp,"break;"); add_end_comment(dfp,"Out of target loop"); expr(dfp,"target_pos++;"); closebrace(dfp); expr(dfp,"%s(%s,targetdb)",gm->ttype->close_func,gm->target->name); } if( qdb == TRUE ) { expr(dfp," %s = %s(%s,querydb,&db_status)",gm->query->name,gm->qtype->reload_func,gm->query->name); expr(dfp,"if( db_status == DB_RETURN_ERROR)"); startbrace(dfp); expr(dfp,"warn(\"In searching %s, Reload error on database %s, position %%d,%%d\",query_pos,target_pos);",gm->name,gm->query->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); expr(dfp,"if( db_status == DB_RETURN_END)"); hang_expr(dfp,"break;"); add_end_comment(dfp,"Out of query loop"); expr(dfp,"query_pos++;"); closebrace(dfp); expr(dfp,"%s(%s,querydb)",gm->qtype->close_func,gm->query->name); } expr(dfp,"pop_errormsg_stack()"); expr(dfp,"return SEARCH_OK;"); close_function(dfp); add_break(dfp); } /* Function: write_one_score_GenericMatrix(dfp,gm,dpi) * * Descrip: Makes the score only function, which gives the score * for two objects. Used in the serial and the pthreads * ports * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ # line 191 "dynadb.dy" void write_one_score_GenericMatrix(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { int i,j; FuncInfo * fi; char * arg_str; char * chain_str; for(j=0;jspec_len;j++) if( gm->special[j]->is_start == TRUE ) break; /*** prepare function information ***/ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"score_only_%s",gm->name); add_line_to_Ftext(fi->ft,"This function just calculates the score for the matrix",gm->name); add_line_to_Ftext(fi->ft,"I am pretty sure we can do this better, but hey, for the moment..."); add_line_to_Ftext(fi->ft,"It calls /allocate_%s_only",gm->name); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"int score_only_%s(%s)",gm->name,arg_str); /*** clean up ***/ ckfree(arg_str); /*** into function body ***/ expr(dfp,"int bestscore = NEGI;"); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"%s * mat",gm->name); if(gm->qtype != NULL && gm->qtype->maxlen != NULL) { expr(dfp,"int internal_matrix[%d][(%s+%d) * %d];",gm->window_j+1,gm->qtype->maxlen,gm->window_i,gm->len); expr(dfp,"int internal_specials[%d][%d];",gm->window_j+1,gm->spec_len); } if( dpi->largemem == TRUE ) { expr(dfp,"int * internal_pointer_db;"); expr(dfp,"int * internal_special_db;"); } add_break(dfp); chain_str = get_chainstr_GenericMatrix(gm); expr(dfp,"mat = allocate_%s_only(%s);",gm->name,chain_str); ckfree(chain_str); expr(dfp,"if( mat == NULL )"); startbrace(dfp); warn_expr(dfp,"Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); expr(dfp,"return NEGI"); closebrace(dfp); if(gm->qtype != NULL && gm->qtype->maxlen != NULL) { add_block_comment(dfp,"Ok,don't need to allocate matrix as it is internal, because we have a max length"); } else if ( dpi->largemem == TRUE ) { expr(dfp,"if( (internal_pointer_db = (int *)ckcalloc(((mat->leni+%d) * %d),sizeof(int))) == NULL)", gm->window_i,((gm->window_j+1)*gm->len)); hang_expr(dfp,"fatal(\"could not allocate internal matrix in long mode\");"); expr(dfp,"if( (internal_special_db = (int *)ckcalloc(%d,sizeof(int))) == NULL)", ((gm->window_j+1)*gm->spec_len)); hang_expr(dfp,"fatal(\"could not allocate internal matrix in long mode\");"); } else { expr(dfp,"if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(%d,(mat->leni + %d) * %d,%d,%d)) == NULL)",gm->window_j+1,gm->window_i,gm->len,gm->window_j+1,gm->spec_len); startbrace(dfp); expr(dfp,"warn(\"Score only matrix for %s cannot be allocated, (asking for %d by %%d cells)\",mat->leni*%d);",gm->name,gm->window_j,gm->len); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return 0;"); closebrace(dfp); expr(dfp,"mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL;"); } add_break(dfp); add_block_comment(dfp,"Now, initiate matrix"); expr(dfp,"for(j=0;j<%d;j++)",gm->window_j+2); startbrace(dfp); expr(dfp,"for(i=(-%d);ileni;i++)",gm->window_i); startbrace(dfp); expr(dfp,"for(k=0;k<%d;k++)",gm->len); hang_expr(dfp,"%s_VSMALL_MATRIX(mat,i,j,k) = NEGI;",gm->name); closebrace(dfp); for(i=0;ispec_len;i++) { expr(dfp,"%s_VSMALL_SPECIAL(mat,i,j,%s) = %s;",gm->name,gm->special[i]->name,gm->special[i]->def_score); } closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Ok, lets do-o-o-o-o it"); add_break(dfp); expr(dfp,"for(j=0;jlenj;j++)"); startbrace_tag(dfp,"for all target positions"); expr(dfp,"auto int score"); expr(dfp,"auto int temp"); if( dpi->largemem == TRUE ) { add_block_comment(dfp,"Need to reset START to 0"); expr(dfp,"%s_VSMALL_SPECIAL(mat,0,j,%s) = 0",gm->name,gm->special[j]->name); } expr(dfp,"for(i=0;ileni;i++)"); startbrace_tag(dfp,"for all query positions"); write_score_block(dfp,gm,"VSMALL_MATRIX","mat","VSMALL_SPECIAL",TRUE); closebrace(dfp); add_break(dfp); write_special_block(dfp,gm,"VSMALL_MATRIX","VSMALL_SPECIAL","bestscore"); closebrace(dfp); add_break(dfp); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return bestscore;"); close_function(dfp); add_break(dfp); } # line 341 "dynadb.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/dynadb.h0000644000175000001440000000315110670453715015041 0ustar philippusers#ifndef DYNAMITEdynadbHEADERFILE #define DYNAMITEdynadbHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna2.h" #include "dynafunc.h" #include "dpimpl.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: make_search_loop_function(dfp,gm) * * Descrip: Makes the serial search function, which loops * over databases * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ void make_search_loop_function(DYNFILE * dfp,GenericMatrix * gm); /* Function: write_one_score_GenericMatrix(dfp,gm,dpi) * * Descrip: Makes the score only function, which gives the score * for two objects. Used in the serial and the pthreads * ports * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ void write_one_score_GenericMatrix(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi); /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/ftext.c0000644000175000001440000005357710670453715014746 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "ftext.h" /* Function: add_line_to_Ftext(ft,str,) * * Descrip: adds a vsprintf'd line (below MAXLINE length!) to * the Ftext. * * * Arg: ft [UNKN ] Undocumented argument [Ftext *] * Arg: str [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 26 "ftext.dy" boolean add_line_to_Ftext(Ftext * ft,char * str,...) { char buffer[MAXLINE]; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); return add_Fblock(ft->fb[ft->len-1],stringalloc(buffer)); } /* Function: add_break_to_Ftext(ft) * * Descrip: puts in a break into the Ftext * * * Arg: ft [UNKN ] Undocumented argument [Ftext *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 42 "ftext.dy" boolean add_break_to_Ftext(Ftext * ft) { Fblock * temp; temp = Fblock_alloc_std(); return add_Ftext(ft,temp); } /* Function: single_Ftext_from_str(str) * * Descrip: Makes a complete Ftext from just this string: * * * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Ftext *] * */ # line 53 "ftext.dy" Ftext * single_Ftext_from_str(char * str) { Fblock * temp; Ftext * out; out = Ftext_alloc_len(1); temp = Fblock_alloc_len(1); add_Fblock(temp,stringalloc(str)); add_Ftext(out,temp); return out; } /* Function: show_eddystyle_Ftext(ft,header,depth,ofp,blank_text) * * Descrip: shows Ftext as a C style comment with * * * * * * * indenting: * * will return number of lines printed. * * * Arg: ft [READ ] Ftext to be shown [Ftext *] * Arg: header [READ ] Header for the first line, eg, "description:" [char *] * Arg: depth [READ ] depth of from * to text [int] * Arg: ofp [UNKN ] output file [FILE *] * Arg: blank_text [READ ] if non NULL, what to put if ft is empty, Can be NULL. [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 83 "ftext.dy" int show_eddystyle_Ftext(Ftext * ft,char * header,int depth,FILE * ofp,char * blank_text) { int len = 0; int i; int j; int st = 1; char space[]=" "; if( ft == NULL || ft->len == 0 || ft->fb[0]->len == 0) { fprintf(ofp," * %*s %s\n",depth-9,header,blank_text == NULL ? "No text" : blank_text); return 1; } fprintf(ofp," * %*s %s\n",-(depth-4),header,ft->fb[0]->line[0]); len++; for(i=0;ilen;i++) { for(j=0;jfb[i]->len;j++) { if( st == 1 ) { st =0; continue; } fprintf(ofp," *%.*s%s\n",depth-2,space,ft->fb[i]->line[j]); len++; } fprintf(ofp," *\n"); len++; } return len; } /* Function: latex_Ftext(ft,ofp) * * Descrip: Provides a latex dump of some text. * * Lines that start flush to the left * are given as paragraphs * * Line that are indented are made verbatim * * * Arg: ft [UNKN ] Undocumented argument [Ftext *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 125 "ftext.dy" void latex_Ftext(Ftext * ft,FILE * ofp) { int i,j; boolean inverbatim = FALSE; for(i=0;ilen;i++) { for(j=0;jfb[i]->len;j++) { if( isspace(ft->fb[i]->line[j][0]) ) { if( inverbatim == FALSE ) { fprintf(ofp,"\\begin{verbatim}\n"); inverbatim = TRUE; } } else if ( inverbatim == TRUE ) { fprintf(ofp,"\\end{verbatim}\n"); inverbatim = FALSE; } fprintf(ofp,"%s\n",ft->fb[i]->line[j]); } fprintf(ofp,"\n\n"); } /* if we are in verbatim - get out! */ if ( inverbatim == TRUE ) fprintf(ofp,"\\end{verbatim}\n"); } /* Function: dump_Ftext(ft,*ofp) * * Descrip: stupid function which gives flat dump of ftext * * * Arg: ft [UNKN ] Undocumented argument [Ftext *] * Arg: *ofp [UNKN ] Undocumented argument [FILE] * */ # line 157 "ftext.dy" void dump_Ftext(Ftext * ft,FILE *ofp) { int i; for(i=0;ilen;i++) { dump_Fblock_str("",ft->fb[i],ofp); fprintf(ofp,"\n"); } } /* Function: dump_Ftext_pre(pre,ft,*ofp) * * Descrip: stupid function which gives flat dump of ftext, * with a start of pre * * * Arg: pre [UNKN ] Undocumented argument [char *] * Arg: ft [UNKN ] Undocumented argument [Ftext *] * Arg: *ofp [UNKN ] Undocumented argument [FILE] * */ # line 172 "ftext.dy" void dump_Ftext_pre(char * pre,Ftext * ft,FILE *ofp) { int i; for(i=0;ilen;i++) { dump_Fblock_str(pre,ft->fb[i],ofp); fprintf(ofp,"\n"); } } /* Function: dump_Fblock_str(pre,fb,ofp) * * Descrip: sub of /dump_Ftext * * * Arg: pre [UNKN ] Undocumented argument [char *] * Arg: fb [UNKN ] Undocumented argument [Fblock *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 187 "ftext.dy" void dump_Fblock_str(char * pre,Fblock * fb,FILE * ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,"%s%s\n",pre,fb->line[i]); } } /* Function: read_Ftext(buffer,fgets_func,maxlen,ifp,endpoint) * * Descrip: reads in lines until it hits endpoint. * A bit of an internal: is going to use buffer and maxlen * as its buffer (this is so it is not fixed to one length of * buffer). You probably have abuffer in your calling function. * * * Arg: buffer [WRITE] pointer to a char * buffer of maxlen that can be written in [char *] * Arg: fgets_func [UNKN ] Undocumented argument [NullString] * Arg: maxlen [READ ] maximum size of buffer to read [int] * Arg: ifp [UNKN ] input file [FILE *] * Arg: endpoint [READ ] a string which is used (using /strstartcmp) as a tag for the end of text [char *] * * Return [UNKN ] Undocumented return value [Ftext *] * */ # line 207 "ftext.dy" Ftext * read_Ftext(char * buffer,int maxlen,FILE * ifp,char * endpoint,char * (*fgets_func)(char *,int,FILE *)) { Ftext * out; Fblock * temp; out = Ftext_alloc_std(); if( fgets_func == NULL ) fgets_func = fgets; while((temp= read_Fblock(buffer,maxlen,ifp,endpoint,fgets_func)) != NULL ) { add_Ftext(out,temp); if( strstartcmp(buffer,endpoint) == 0 ) return out; } warn("Got a NULL Fblock in reading a Ftext. Not good news!"); return out; } /* Function: read_Fblock(buffer,fgets_func,maxlen,ifp,endpoint) * * Descrip: Really an internal for read_Ftext * * * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: fgets_func [UNKN ] Undocumented argument [NullString] * Arg: maxlen [UNKN ] Undocumented argument [int] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * Arg: endpoint [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Fblock *] * */ # line 232 "ftext.dy" Fblock * read_Fblock(char * buffer,int maxlen,FILE * ifp,char * endpoint,char * (*fgets_func)(char *,int,FILE *)) { Fblock * out; out = Fblock_alloc_std(); while((*fgets_func)(buffer,maxlen,ifp) != NULL ) { if( strstartcmp(buffer,endpoint) == 0 ) return out; if( strstartcmp(buffer,"\n") == 0 ) return out; buffer[strlen(buffer)-1] ='\0'; /*** strips off '\n' ***/ /* fprintf(stderr,"Adding %s",buffer); */ add_Fblock(out,stringalloc(buffer)); } warn("Got to then end of the file in reading a Fblock. Not a good sign!"); return out; } # line 301 "ftext.c" /* Function: swap_Fblock(list,i,j) * * Descrip: swap function: an internal for qsort_Fblock * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [char **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Fblock(char ** list,int i,int j) { char * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Fblock(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Fblock which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [char **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Fblock(char ** list,int left,int right,int (*comp)(char * ,char * )) { int i,last; if( left >= right ) return; swap_Fblock(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Fblock (list,++last,i); } swap_Fblock (list,left,last); qsort_Fblock(list,left,last-1,comp); qsort_Fblock(list,last+1,right,comp); } /* Function: sort_Fblock(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Fblock * * * Arg: obj [UNKN ] Object containing list [Fblock *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Fblock(Fblock * obj,int (*comp)(char *, char *)) { qsort_Fblock(obj->line,0,obj->len-1,comp); return; } /* Function: expand_Fblock(obj,len) * * Descrip: Really an internal function for add_Fblock * * * Arg: obj [UNKN ] Object which contains the list [Fblock *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Fblock(Fblock * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Fblock called with no need"); return TRUE; } if( (obj->line = (char ** ) ckrealloc (obj->line,sizeof(char *)*len)) == NULL) { warn("ckrealloc failed for expand_Fblock, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Fblock(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Fblock *] * Arg: add [OWNER] Object to add to the list [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Fblock(Fblock * obj,char * add) { if( obj->len >= obj->maxlen) { if( expand_Fblock(obj,obj->len + FblockLISTLENGTH) == FALSE) return FALSE; } obj->line[obj->len++]=add; return TRUE; } /* Function: flush_Fblock(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Fblock *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Fblock(Fblock * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->line[i] != NULL) { ckfree(obj->line[i]); obj->line[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: Fblock_alloc_std(void) * * Descrip: Equivalent to Fblock_alloc_len(FblockLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Fblock *] * */ Fblock * Fblock_alloc_std(void) { return Fblock_alloc_len(FblockLISTLENGTH); } /* Function: Fblock_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Fblock *] * */ Fblock * Fblock_alloc_len(int len) { Fblock * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Fblock_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->line = (char ** ) ckcalloc (len,sizeof(char *))) == NULL) { warn("Warning, ckcalloc failed in Fblock_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_Fblock(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Fblock *] * * Return [UNKN ] Undocumented return value [Fblock *] * */ Fblock * hard_link_Fblock(Fblock * obj) { if( obj == NULL ) { warn("Trying to hard link to a Fblock object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Fblock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Fblock *] * */ Fblock * Fblock_alloc(void) { Fblock * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Fblock *) ckalloc (sizeof(Fblock))) == NULL) { warn("Fblock_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->line = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_Fblock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Fblock *] * * Return [UNKN ] Undocumented return value [Fblock *] * */ Fblock * free_Fblock(Fblock * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Fblock obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->line != NULL) { for(i=0;ilen;i++) { if( obj->line[i] != NULL) ckfree(obj->line[i]); } ckfree(obj->line); } ckfree(obj); return NULL; } /* Function: swap_Ftext(list,i,j) * * Descrip: swap function: an internal for qsort_Ftext * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Fblock **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Ftext(Fblock ** list,int i,int j) { Fblock * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Ftext(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Ftext which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Fblock **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Ftext(Fblock ** list,int left,int right,int (*comp)(Fblock * ,Fblock * )) { int i,last; if( left >= right ) return; swap_Ftext(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Ftext (list,++last,i); } swap_Ftext (list,left,last); qsort_Ftext(list,left,last-1,comp); qsort_Ftext(list,last+1,right,comp); } /* Function: sort_Ftext(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Ftext * * * Arg: obj [UNKN ] Object containing list [Ftext *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Ftext(Ftext * obj,int (*comp)(Fblock *, Fblock *)) { qsort_Ftext(obj->fb,0,obj->len-1,comp); return; } /* Function: expand_Ftext(obj,len) * * Descrip: Really an internal function for add_Ftext * * * Arg: obj [UNKN ] Object which contains the list [Ftext *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Ftext(Ftext * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Ftext called with no need"); return TRUE; } if( (obj->fb = (Fblock ** ) ckrealloc (obj->fb,sizeof(Fblock *)*len)) == NULL) { warn("ckrealloc failed for expand_Ftext, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Ftext(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Ftext *] * Arg: add [OWNER] Object to add to the list [Fblock *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Ftext(Ftext * obj,Fblock * add) { if( obj->len >= obj->maxlen) { if( expand_Ftext(obj,obj->len + FtextLISTLENGTH) == FALSE) return FALSE; } obj->fb[obj->len++]=add; return TRUE; } /* Function: flush_Ftext(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Ftext *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Ftext(Ftext * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->fb[i] != NULL) { free_Fblock(obj->fb[i]); obj->fb[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: Ftext_alloc_std(void) * * Descrip: Equivalent to Ftext_alloc_len(FtextLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Ftext *] * */ Ftext * Ftext_alloc_std(void) { return Ftext_alloc_len(FtextLISTLENGTH); } /* Function: Ftext_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Ftext *] * */ Ftext * Ftext_alloc_len(int len) { Ftext * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Ftext_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->fb = (Fblock ** ) ckcalloc (len,sizeof(Fblock *))) == NULL) { warn("Warning, ckcalloc failed in Ftext_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_Ftext(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Ftext *] * * Return [UNKN ] Undocumented return value [Ftext *] * */ Ftext * hard_link_Ftext(Ftext * obj) { if( obj == NULL ) { warn("Trying to hard link to a Ftext object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Ftext_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Ftext *] * */ Ftext * Ftext_alloc(void) { Ftext * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Ftext *) ckalloc (sizeof(Ftext))) == NULL) { warn("Ftext_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->fb = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_Ftext(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Ftext *] * * Return [UNKN ] Undocumented return value [Ftext *] * */ Ftext * free_Ftext(Ftext * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Ftext obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->fb != NULL) { for(i=0;ilen;i++) { if( obj->fb[i] != NULL) free_Fblock(obj->fb[i]); } ckfree(obj->fb); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/ftext.h0000644000175000001440000002354610670453715014744 0ustar philippusers#ifndef DYNAMITEftextHEADERFILE #define DYNAMITEftextHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #define FblockLISTLENGTH 64 #define FtextLISTLENGTH 64 struct Fblock { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char ** line; int len;/* len for above line */ int maxlen; /* maxlen for above line */ } ; /* Fblock defined */ #ifndef DYNAMITE_DEFINED_Fblock typedef struct Fblock Fblock; #define DYNAMITE_DEFINED_Fblock #endif struct Ftext { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Fblock ** fb; int len;/* len for above fb */ int maxlen; /* maxlen for above fb */ } ; /* Ftext defined */ #ifndef DYNAMITE_DEFINED_Ftext typedef struct Ftext Ftext; #define DYNAMITE_DEFINED_Ftext #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: add_line_to_Ftext(ft,str,) * * Descrip: adds a vsprintf'd line (below MAXLINE length!) to * the Ftext. * * * Arg: ft [UNKN ] Undocumented argument [Ftext *] * Arg: str [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_line_to_Ftext(Ftext * ft,char * str,...); /* Function: add_break_to_Ftext(ft) * * Descrip: puts in a break into the Ftext * * * Arg: ft [UNKN ] Undocumented argument [Ftext *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_break_to_Ftext(Ftext * ft); /* Function: single_Ftext_from_str(str) * * Descrip: Makes a complete Ftext from just this string: * * * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Ftext *] * */ Ftext * single_Ftext_from_str(char * str); /* Function: show_eddystyle_Ftext(ft,header,depth,ofp,blank_text) * * Descrip: shows Ftext as a C style comment with * * * * * * * indenting: * * will return number of lines printed. * * * Arg: ft [READ ] Ftext to be shown [Ftext *] * Arg: header [READ ] Header for the first line, eg, "description:" [char *] * Arg: depth [READ ] depth of from * to text [int] * Arg: ofp [UNKN ] output file [FILE *] * Arg: blank_text [READ ] if non NULL, what to put if ft is empty, Can be NULL. [char *] * * Return [UNKN ] Undocumented return value [int] * */ int show_eddystyle_Ftext(Ftext * ft,char * header,int depth,FILE * ofp,char * blank_text); /* Function: latex_Ftext(ft,ofp) * * Descrip: Provides a latex dump of some text. * * Lines that start flush to the left * are given as paragraphs * * Line that are indented are made verbatim * * * Arg: ft [UNKN ] Undocumented argument [Ftext *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void latex_Ftext(Ftext * ft,FILE * ofp); /* Function: dump_Ftext(ft,*ofp) * * Descrip: stupid function which gives flat dump of ftext * * * Arg: ft [UNKN ] Undocumented argument [Ftext *] * Arg: *ofp [UNKN ] Undocumented argument [FILE] * */ void dump_Ftext(Ftext * ft,FILE *ofp); /* Function: dump_Ftext_pre(pre,ft,*ofp) * * Descrip: stupid function which gives flat dump of ftext, * with a start of pre * * * Arg: pre [UNKN ] Undocumented argument [char *] * Arg: ft [UNKN ] Undocumented argument [Ftext *] * Arg: *ofp [UNKN ] Undocumented argument [FILE] * */ void dump_Ftext_pre(char * pre,Ftext * ft,FILE *ofp); /* Function: read_Ftext(buffer,fgets_func,maxlen,ifp,endpoint) * * Descrip: reads in lines until it hits endpoint. * A bit of an internal: is going to use buffer and maxlen * as its buffer (this is so it is not fixed to one length of * buffer). You probably have abuffer in your calling function. * * * Arg: buffer [WRITE] pointer to a char * buffer of maxlen that can be written in [char *] * Arg: fgets_func [UNKN ] Undocumented argument [NullString] * Arg: maxlen [READ ] maximum size of buffer to read [int] * Arg: ifp [UNKN ] input file [FILE *] * Arg: endpoint [READ ] a string which is used (using /strstartcmp) as a tag for the end of text [char *] * * Return [UNKN ] Undocumented return value [Ftext *] * */ Ftext * read_Ftext(char * buffer,int maxlen,FILE * ifp,char * endpoint,char * (*fgets_func)(char *,int,FILE *)); /* Function: add_Fblock(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Fblock *] * Arg: add [OWNER] Object to add to the list [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_Fblock(Fblock * obj,char * add); /* Function: flush_Fblock(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Fblock *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Fblock(Fblock * obj); /* Function: Fblock_alloc_std(void) * * Descrip: Equivalent to Fblock_alloc_len(FblockLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Fblock *] * */ Fblock * Fblock_alloc_std(void); /* Function: Fblock_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Fblock *] * */ Fblock * Fblock_alloc_len(int len); /* Function: hard_link_Fblock(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Fblock *] * * Return [UNKN ] Undocumented return value [Fblock *] * */ Fblock * hard_link_Fblock(Fblock * obj); /* Function: Fblock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Fblock *] * */ Fblock * Fblock_alloc(void); /* Function: free_Fblock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Fblock *] * * Return [UNKN ] Undocumented return value [Fblock *] * */ Fblock * free_Fblock(Fblock * obj); /* Function: add_Ftext(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Ftext *] * Arg: add [OWNER] Object to add to the list [Fblock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_Ftext(Ftext * obj,Fblock * add); /* Function: flush_Ftext(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Ftext *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Ftext(Ftext * obj); /* Function: Ftext_alloc_std(void) * * Descrip: Equivalent to Ftext_alloc_len(FtextLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Ftext *] * */ Ftext * Ftext_alloc_std(void); /* Function: Ftext_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Ftext *] * */ Ftext * Ftext_alloc_len(int len); /* Function: hard_link_Ftext(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Ftext *] * * Return [UNKN ] Undocumented return value [Ftext *] * */ Ftext * hard_link_Ftext(Ftext * obj); /* Function: Ftext_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Ftext *] * */ Ftext * Ftext_alloc(void); /* Function: free_Ftext(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Ftext *] * * Return [UNKN ] Undocumented return value [Ftext *] * */ Ftext * free_Ftext(Ftext * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void dump_Fblock_str(char * pre,Fblock * fb,FILE * ofp); Fblock * read_Fblock(char * buffer,int maxlen,FILE * ifp,char * endpoint,char * (*fgets_func)(char *,int,FILE *)); void swap_Fblock(char ** list,int i,int j) ; void qsort_Fblock(char ** list,int left,int right,int (*comp)(char * ,char * )); void sort_Fblock(Fblock * obj,int (*comp)(char *, char *)); boolean expand_Fblock(Fblock * obj,int len); void swap_Ftext(Fblock ** list,int i,int j) ; void qsort_Ftext(Fblock ** list,int left,int right,int (*comp)(Fblock * ,Fblock * )); void sort_Ftext(Ftext * obj,int (*comp)(Fblock *, Fblock *)); boolean expand_Ftext(Ftext * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/friend.c0000644000175000001440000000640010670453715015042 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "friend.h" # line 15 "friend.dy" Friend * read_Friend_line(char * line,FILE * ifp) { Friend * out; char * runner; if( strstartcmp(line,"friend") != 0 ) { warn("Trying to read [%s] as a friend line? I think not!"); } runner = strtok(line,spacestr); runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("Could not find any friend for a friend line. Sad!"); } out = Friend_alloc(); out->name = stringalloc(runner); return out; } # line 39 "friend.dy" void write_Friend_header(DYNFILE * dfp,Friend * fr) { if( dfp->package_name != NULL ) { fprintf(dfp->head,"#ifndef DYNAMITE_DEFINED_%s\n",fr->name); fprintf(dfp->head,"typedef struct %s%s %s%s;\n",dfp->package_name,fr->name,dfp->package_name,fr->name); fprintf(dfp->head,"#define %s %s%s\n",fr->name,dfp->package_name,fr->name); fprintf(dfp->head,"#define DYNAMITE_DEFINED_%s\n#endif\n\n",fr->name); } else fprintf(dfp->head,"#ifndef DYNAMITE_DEFINED_%s\ntypedef struct %s %s;\n#define DYNAMITE_DEFINED_%s\n#endif\n\n",fr->name,fr->name,fr->name,fr->name); } # line 42 "friend.c" /* Function: hard_link_Friend(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Friend *] * * Return [UNKN ] Undocumented return value [Friend *] * */ Friend * hard_link_Friend(Friend * obj) { if( obj == NULL ) { warn("Trying to hard link to a Friend object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Friend_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Friend *] * */ Friend * Friend_alloc(void) { Friend * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Friend *) ckalloc (sizeof(Friend))) == NULL) { warn("Friend_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; return out; } /* Function: free_Friend(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Friend *] * * Return [UNKN ] Undocumented return value [Friend *] * */ Friend * free_Friend(Friend * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Friend obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/friend.h0000644000175000001440000000366110670453715015055 0ustar philippusers#ifndef DYNAMITEfriendHEADERFILE #define DYNAMITEfriendHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dynfile.h" struct Friend { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; } ; /* Friend defined */ #ifndef DYNAMITE_DEFINED_Friend typedef struct Friend Friend; #define DYNAMITE_DEFINED_Friend #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_Friend(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Friend *] * * Return [UNKN ] Undocumented return value [Friend *] * */ Friend * hard_link_Friend(Friend * obj); /* Function: Friend_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Friend *] * */ Friend * Friend_alloc(void); /* Function: free_Friend(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Friend *] * * Return [UNKN ] Undocumented return value [Friend *] * */ Friend * free_Friend(Friend * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ Friend * read_Friend_line(char * line,FILE * ifp); void write_Friend_header(DYNFILE * dfp,Friend * fr); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/dymain.dy0000644000175000001440000000001607313404533015235 0ustar philippusers %{ %} wise-2.4.1/src/dyc/type.dy0000644000175000001440000002733207346730056014757 0ustar philippusers %{ #include "wisebase.h" #include "wisec.h" #include "exprtree.h" #include "y.tab.h" #include "method.h" #include "input.h" #include "dpimpl.h" #define ScopeLISTLENGTH 16 typedef unsigned int ParseError; enum ParseErrorType { PERR_SYNTAX = 1, PERR_COMPLEXMETHOD = 2, PERR_ARG_NUM_MIS = 4, PERR_ARG_UNTYPED = 8, PERR_ARG_MISTYPE = 16, PERR_OUT_OF_SCOPE = 32, PERR_METHOD_SCOPE = 64 }; enum SCOPE_TYPE { SCOPE_RESOURCE = 82, SCOPE_QUERY, SCOPE_TARGET, SCOPE_EXTERN }; /*** declare yyparse ****/ void yyparse(void); %} struct ScopeUnit char * name char * app char * type boolean isglobbed !def="FALSE" int scope_type !def="SCOPE_EXTERN" char * no_accept // for guys which don't like other arguments struct Scope ScopeUnit ** su; !list %{ #include "type.h" char * calc_lex_string; int stringpos =0; ExprTree * root = NULL; %func copies MethodTypeSet by hard-linking list members %% MethodTypeSet * copy_MethodTypeSet(MethodTypeSet * mts) { int i; MethodTypeSet * out; out = MethodTypeSet_alloc_std(); for(i=0;ime_len;i++) add_me_MethodTypeSet(out,hard_link_Method(mts->me[i])); for(i=0;ity_len;i++) add_ty_MethodTypeSet(out,hard_link_Type(mts->ty[i])); return out; } %func sets up "standard" dynamite scope. %% Scope * std_Dynamite_Scope(void) { Scope * sc; sc = Scope_alloc_std(); /*** std set up code has moved to dyna2.dy ***/ return sc; } %func Main function used to access the parser. This parses the calc_line (without damaging it). Errors will be placed normally: You should stack errors or catch them if you want to do something funky. At the end of the day, if there was parser syntax error then you will get NULL, and pe & PERR_SYNTAX will be set. Otherwise you will get a char * (stringalloc'd). Potentially any number of PERRs could be set, including unscoped variables or methods etc. %arg calc_line r line to be parsed sc r scope system to use for this area mts r method and type information (method scope) for this area pe w returned parser errors return stringalloc'd expanded string %% char * allocd_calc_line(char * calc_line,Scope * sc,MethodTypeSet * mts,DycWarning * dycw,ParseError * pe,ExprTree ** expr) { char buffer[MAXLINE]; /** ouch - watch overflows **/ /*** set globals that we share with lex/yacc ***/ if( calc_line == NULL ) { warn("Got a NULL calc line - can hardly parse it!"); return NULL; } calc_lex_string = calc_line; stringpos= 0; root = NULL; /*** parse it ***/ yyparse(); /*** check root, if NULL... otta here ***/ if( root == NULL ) { /* silent fail. already been warned */ (*pe) |= PERR_SYNTAX; return NULL; } /*** make top-level name which could be ***/ find_toplevel_name(root); /*** make string, checking semantics this time ***/ buffer[0]='\0'; (*pe) |= strcat_ExprTree_Scoped(root,buffer,sc,mts,dycw,NULL,NULL); if( expr != NULL ) { *expr = root; } else { /* should free... don't at the moment */ } return stringalloc(buffer); } void complain_ParseError_to_file(ParseError pe,FILE * ofp) { if( pe & PERR_SYNTAX ) fprintf(ofp,"Parser Syntax error on calc line\n"); if( pe & PERR_COMPLEXMETHOD) fprintf(ofp,"Complex methods (ie, pointer-functions) which cannot be typed\n"); if( pe & PERR_ARG_NUM_MIS ) fprintf(ofp,"Argument number mismatches\n"); if( pe & PERR_ARG_UNTYPED ) fprintf(ofp,"Un-typable arguments, due to array or structure deferences\n"); if( pe & PERR_ARG_MISTYPE ) fprintf(ofp,"Mistyped arguments\n"); if( pe & PERR_OUT_OF_SCOPE) fprintf(ofp,"Variable out of scope\n"); if( pe & PERR_METHOD_SCOPE) fprintf(ofp,"Method out of scope\n"); } char * type_from_ExprTree(ExprTree * et,Scope * sc,MethodTypeSet * mts) { ScopeUnit * su; Method * me; switch( et->type ) { case ETR_EXPRESSION : /*** for the moment, return NULL... could return "int" quite ok.. ***/ return NULL; case ETR_NAME : su = ScopeUnit_from_Scope(sc,et->word); if( su == NULL ) { return NULL; } else { return su->type; } break; case ETR_TAG : if( et->nochild == 1 && et->child[0]->type == ETR_NAME) { return type_from_ExprTree(et->child[0],sc,mts); } return NULL; break; case ETR_METHOD : if( et->child[0]->nochild != 1 || et->child[0]->child[0]->type != ETR_NAME ) { return NULL; } me = Method_from_name(mts,et->child[0]->child[0]->word); if( me == NULL) { return NULL; } else { return me->retstr; } break; case ETR_STRUCTREF : case ETR_REFERENCE : return NULL; default : warn("Unable to type a Expr Node [%d]. Returing a 'blank' type",et->type); return NULL; } } %func Main internal recursive functions that descends the Expr tree. Should at the start be given the root node: buffer is written in the final expression, mapped etc. %type internal %% ParseError strcat_ExprTree_Scoped(ExprTree * ExprTree,char * buffer,Scope * sc,MethodTypeSet * mts,DycWarning * dycw,boolean (*finish_parsing)(struct ExprTree *,char *,void *),void * data) { ParseError pe = 0; ScopeUnit * su; Method * me; char tempbuf[512]; int i; if( finish_parsing != NULL ) { if( (*finish_parsing)(ExprTree,buffer,data) == TRUE ) { return pe; } } switch(ExprTree->type) { case ETR_NUMBER : strcat(buffer,ExprTree->word); break; case ETR_OPERATOR : strcat(buffer,ExprTree->word); break; case ETR_EXPRESSION : strcat(buffer,"("); for(i=0;i< ExprTree->nochild;i++) pe |= strcat_ExprTree_Scoped(ExprTree->child[i],buffer,sc,mts,dycw,finish_parsing,data); strcat(buffer,")"); break; case ETR_STATEMENT : for(i=0;i< ExprTree->nochild;i++) pe |= strcat_ExprTree_Scoped(ExprTree->child[i],buffer,sc,mts,dycw,finish_parsing,data); break; case ETR_NAME : if( (ExprTree->attrib & IS_TOPLEVEL) == IS_TOPLEVEL) { /* fprintf(stderr,"Got a top level name %s\n",ExprTree->word);*/ su = ScopeUnit_from_Scope(sc,ExprTree->word); if( su == NULL ) { pe |= PERR_OUT_OF_SCOPE; if( dycw == NULL || dycw->warn_extern == TRUE ) warn("Name [%s] is out of scope: assumming extern",ExprTree->word); } else { /* fprintf(stderr,"Ok.[%d] for name %s, going to add %s\n",ExprTree->attrib,ExprTree->word,su->app);*/ strcat(buffer,su->app); } } strcat(buffer,ExprTree->word); break; case ETR_ARRAY : pe |= strcat_ExprTree_Scoped(ExprTree->child[0],buffer,sc,mts,dycw,finish_parsing,data); strcat(buffer,"["); pe |= strcat_ExprTree_Scoped(ExprTree->child[1],buffer,sc,mts,dycw,finish_parsing,data); strcat(buffer,"]"); break; case ETR_TAG : for(i=0;i< ExprTree->nochild;i++) pe |= strcat_ExprTree_Scoped(ExprTree->child[i],buffer,sc,mts,dycw,finish_parsing,data); break; case ETR_STRUCTREF : pe |= strcat_ExprTree_Scoped(ExprTree->child[0],buffer,sc,mts,dycw,finish_parsing,data); strcat(buffer,ExprTree->child[1]->word); pe |= strcat_ExprTree_Scoped(ExprTree->child[2],buffer,sc,mts,dycw,finish_parsing,data); break; case ETR_REFERENCE : strcat(buffer,ExprTree->child[0]->word); pe |= strcat_ExprTree_Scoped(ExprTree->child[1],buffer,sc,mts,dycw,finish_parsing,data); break; case ETR_METHOD : if( ExprTree->child[0]->nochild != 1 || ExprTree->child[0]->child[0]->type != ETR_NAME ) { pe |= PERR_COMPLEXMETHOD; /*** generate error ***/ tempbuf[0]='\0'; strcat_ExprTree(ExprTree->child[0],tempbuf); warn("Method [%s] is not a pure name [%d]: this tolerated in the parser but can't be checked",tempbuf,ExprTree->child[0]->type); pe |= strcat_ExprTree_Scoped(ExprTree->child[0],buffer,sc,mts,dycw,finish_parsing,data); } else { me = Method_from_name(mts,ExprTree->child[0]->child[0]->word); if( me == NULL ) { pe |= PERR_METHOD_SCOPE; if( dycw == NULL || dycw->warn_extern_method == TRUE ) warn("Implied method [%s] has not been typed, and hence can't be type-checked or logical-mapped",ExprTree->child[0]->child[0]->word); pe |= strcat_ExprTree_Scoped(ExprTree->child[0],buffer,sc,mts,dycw,finish_parsing,data); } else { pe |= typecheck_method(ExprTree->child[1],me,sc,mts); strcat(buffer,me->real); /* do nothing at the moment */ } } strcat(buffer,"("); pe |= strcat_ExprTree_Scoped(ExprTree->child[1],buffer,sc,mts,dycw,finish_parsing,data); strcat(buffer,")"); break; case ETR_COMMALIST : for(i=0;inochild;i++) { pe |= strcat_ExprTree_Scoped(ExprTree->child[i],buffer,sc,mts,dycw,finish_parsing,data); if( i != ExprTree->nochild-1) strcat(buffer,","); } break; default : pe |= PERR_SYNTAX; warn("In trying to make Expr string, got unobtainable type!"); } return pe; } ParseError typecheck_method(ExprTree * et,Method * me,Scope * sc,MethodTypeSet * mts) { int i; char * t; int ret = 0; int j; ScopeUnit * sunit = NULL; if( et->type != ETR_COMMALIST ) { warn("Trying to typecheck with a non-comma list system %d --- internal parser error and v.bad",et->type); } if( me->len != et->nochild ) { ret |= PERR_ARG_NUM_MIS; warn("In method [%s], expect %d arguments, given %d arguments",me->logical,me->len,et->nochild); return ret; } for(i=0;ilen;i++) { t = type_from_ExprTree(et->child[i],sc,mts); if( t == NULL ) { ret |= PERR_ARG_UNTYPED; /* warn("For argument %d, of %s, no type information",i,me->logical); */ } else { if ( compare_type(t,me->ma[i]->type) == FALSE ) { warn("Mis-type in argument %d of %s: wanted [%s] got [%s]",i+1,me->logical,me->ma[i]->type,t); ret |= PERR_ARG_MISTYPE; } } } /** do forbidden pairs if appropiate **/ for(i=0;ilen;i++) { auto char * test_argument; if( et->child[i]->type == ETR_NAME ) { test_argument = et->child[i]->word; if( (sunit = ScopeUnit_from_Scope(sc,et->child[i]->word)) == NULL ) continue; /** ugh - unscoped **/ } else if ( et->child[i]->type == ETR_TAG && et->child[i]->nochild == 1 && et->child[i]->child[0]->type == ETR_NAME ) { test_argument = et->child[i]->child[0]->word; if( (sunit = ScopeUnit_from_Scope(sc,et->child[i]->child[0]->word)) == NULL ) continue; /** ugh - unscoped **/ } if( sunit == NULL ) { continue; } /** we have scope. Continue if it has no forbiddens **/ if( sunit->no_accept == NULL ) continue; for(j=i+1;jlen;j++) { auto char * word; word = NULL; if( et->child[j]->type == ETR_NAME ) { word = et->child[j]->word; } else if ( et->child[i]->type == ETR_TAG && et->child[i]->nochild == 1 && et->child[i]->child[0]->type == ETR_NAME ) { word = et->child[j]->child[0]->word; } if( word != NULL && strcmp(word,sunit->no_accept) == 0 && 0) warn("For function %s, you have arguments %s and %s, which do not expect to paired directly in a function. This is just a warning that you can ignore",me->logical,word,test_argument); } } /*** end of forbidden pairs code ***/ return ret; } %func gets a ScopeUnit from the name %type internal %% ScopeUnit * ScopeUnit_from_Scope(Scope * sc,char * word) { int i; for(i=0;ilen;i++) { if( sc->su[i]->isglobbed == TRUE) { /*** hacky ***/ if( strstartcmp(word,sc->su[i]->name) == 0 ) { return sc->su[i]; } } else { if( strcmp(sc->su[i]->name,word) == 0 ) return sc->su[i]; } } return NULL; } ScopeUnit * ScopeUnit_from_nat(MethodTypeSet * mts,char * name,char * app,char * type) { ScopeUnit * su; su = ScopeUnit_alloc(); if( name[strlen(name)-1] == '*') { name[strlen(name)-1] = '\0'; su->isglobbed = TRUE; } su->name = stringalloc(name); su->app = stringalloc(app); su->type = stringalloc(type); return su; } %} wise-2.4.1/src/dyc/labelmaster.dy0000644000175000001440000000720007313404534016252 0ustar philippusers/* Last edited: Mar 11 13:22 1997 (birney) */ %{ #include "wisebase.h" #include "dyna2.h" #define LabelLISTLENGTH 64 #define LabelMasterLISTLENGTH 64 #define LMNOTYPE 213 #define LMQUERYTYPE 214 #define LMTARGETTYPE 215 %} struct LabelInstance char * state char * source int offi int offj char * calc_line struct Label char * name int type LabelInstance ** li !list struct LabelMaster Label ** query !list !len="query_" Label ** target !list !len="target_" %{ #include "labelmaster.h" char * quoted_string_from_Label(Label ** list,int len) { char buf[512]; char buffer[2048]; int i; sprintf(buffer,"\"%s\"",list[0]->name); for(i=1;iname); strcat(buffer,buf); } return stringalloc(buffer); } char * query_quoted_string_from_LabelMaster(LabelMaster * lm) { return quoted_string_from_Label(lm->query,lm->query_len); } char * target_quoted_string_from_LabelMaster(LabelMaster * lm) { return quoted_string_from_Label(lm->target,lm->target_len); } int index_for_label(char * name,Label ** list,int len) { int i; for(i=0;iname,name) == 0) return i; } return -1; } int index_for_query_label(char * name,LabelMaster * lm) { return index_for_label(name,lm->query,lm->query_len); } int index_for_target_label(char * name,LabelMaster * lm) { return index_for_label(name,lm->target,lm->target_len); } Label * target_Label_from_name(LabelMaster * lm,char * name) { register int i; for(i=0;itarget_len;i++) { if( strcmp(name,lm->target[i]->name) == 0 ) return lm->target[i]; } return NULL; } Label * query_Label_from_name(LabelMaster * lm,char * name) { register int i; for(i=0;iquery_len;i++) { if( strcmp(name,lm->query[i]->name) == 0 ) return lm->query[i]; } return NULL; } LabelMaster * LabelMaster_from_GenericMatrix(GenericMatrix * gm) { register int i; register int j; CellState * state; LabelMaster * out; out = LabelMaster_alloc_std(); for(i=0;ilen;i++) { state = gm->state[i]; for(j=0;jlen;j++) add_CellSource_to_LabelMaster(out,state->source[j],state->name); } for(i=0;ispec_len;i++) { state = gm->special[i]; for(j=0;jlen;j++) add_CellSource_to_LabelMaster(out,state->source[j],state->name); } return out; } boolean add_CellSource_to_LabelMaster(LabelMaster * lm,CellSource * cs,char * state) { Label * temp; LabelInstance * li; li = LabelInstance_from_CellSource(state,cs); if( cs->query_label != NULL ) { if( (temp=query_Label_from_name(lm,cs->query_label)) == NULL ) { temp = new_query_Label(cs->query_label); add_query_LabelMaster(lm,temp); } add_Label(temp,li); } li = LabelInstance_from_CellSource(state,cs); if( cs->target_label != NULL ) { if( (temp=target_Label_from_name(lm,cs->target_label)) == NULL ) { temp = new_target_Label(cs->target_label); add_target_LabelMaster(lm,temp); } add_Label(temp,li); } return TRUE; } Label * new_query_Label(char * name) { Label * out; out = Label_alloc_std(); out->name = stringalloc(name); out->type = LMQUERYTYPE; return out; } Label * new_target_Label(char * name) { Label * out; out = Label_alloc_std(); out->name = stringalloc(name); out->type = LMTARGETTYPE; return out; } LabelInstance * LabelInstance_from_CellSource(char * state,CellSource * cs) { LabelInstance * out; out = LabelInstance_alloc(); out->state = stringalloc(state); out->source = cs->state_source; out->offi = cs->offi; out->offj = cs->offj; return out; } %} wise-2.4.1/src/dyc/telegraph.c0000644000175000001440000000234010670453715015545 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "telegraph.h" /* Function: write_Telegraph_grammar(*gm,*ofp) * * Descrip: Write out a telegraph pseudo-grammar * * * Arg: *gm [UNKN ] Undocumented argument [GenericMatrix] * Arg: *ofp [UNKN ] Undocumented argument [FILE] * */ # line 17 "telegraph.dy" void write_Telegraph_grammar(GenericMatrix *gm,FILE *ofp) { int i; int j; int k; fprintf(ofp,"/* pseudo-grammar generated from dynamite */\n"); fprintf(ofp,"\n"); fprintf(ofp,"grammar %s {\n\n",gm->name); for(i=0;ilen;i++) { fprintf(ofp," state %s;\n",gm->state[i]->name); } fprintf(ofp,"\n\n"); for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { fprintf(ofp," %12s -> ",gm->state[i]->source[j]->state_source); for(k=0;k < gm->state[i]->source[j]->offi;k++) { fprintf(ofp,"Q"); } fprintf(ofp," "); for(k=0;k < gm->state[i]->source[j]->offj;k++) { fprintf(ofp,"T"); } fprintf(ofp," %12s { %s + %s};\n",gm->state[i]->name,gm->state[i]->source[j]->source_expr,gm->state[i]->source_expr == NULL ? "0" : gm->state[i]->source_expr); } } fprintf(ofp,"\n\n}\n\n"); } # line 51 "telegraph.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/telegraph.h0000644000175000001440000000201010670453715015544 0ustar philippusers#ifndef DYNAMITEtelegraphHEADERFILE #define DYNAMITEtelegraphHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna2.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: write_Telegraph_grammar(*gm,*ofp) * * Descrip: Write out a telegraph pseudo-grammar * * * Arg: *gm [UNKN ] Undocumented argument [GenericMatrix] * Arg: *ofp [UNKN ] Undocumented argument [FILE] * */ void write_Telegraph_grammar(GenericMatrix *gm,FILE *ofp); /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/objectinfo.c0000644000175000001440000000533710670453715015725 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "objectinfo.h" # line 16 "objectinfo.dy" int write_C_ObjectInfo(ObjectInfo * oi,FILE * ofp) { return show_eddystyle_Ftext(oi->ft,"Descrip:",10,ofp,"No Description"); } # line 21 "objectinfo.dy" ObjectInfo * read_ObjectInfo_line_func(char * line,int maxline,FILE * ifp,char * (fgets_func)(char *,int,FILE*)) { ObjectInfo * out; out = ObjectInfo_alloc(); out->ft = read_Ftext(line,maxline,ifp,"%%",fgets_func); return out; } # line 24 "objectinfo.c" /* Function: hard_link_ObjectInfo(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ObjectInfo *] * * Return [UNKN ] Undocumented return value [ObjectInfo *] * */ ObjectInfo * hard_link_ObjectInfo(ObjectInfo * obj) { if( obj == NULL ) { warn("Trying to hard link to a ObjectInfo object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ObjectInfo_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ObjectInfo *] * */ ObjectInfo * ObjectInfo_alloc(void) { ObjectInfo * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ObjectInfo *) ckalloc (sizeof(ObjectInfo))) == NULL) { warn("ObjectInfo_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->ft = NULL; return out; } /* Function: free_ObjectInfo(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ObjectInfo *] * * Return [UNKN ] Undocumented return value [ObjectInfo *] * */ ObjectInfo * free_ObjectInfo(ObjectInfo * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ObjectInfo obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->ft != NULL) free_Ftext(obj->ft); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/objectinfo.h0000644000175000001440000000417210670453715015726 0ustar philippusers#ifndef DYNAMITEobjectinfoHEADERFILE #define DYNAMITEobjectinfoHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dynfile.h" #include "ftext.h" struct ObjectInfo { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Ftext * ft; /* description of Object */ } ; /* ObjectInfo defined */ #ifndef DYNAMITE_DEFINED_ObjectInfo typedef struct ObjectInfo ObjectInfo; #define DYNAMITE_DEFINED_ObjectInfo #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_ObjectInfo(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ObjectInfo *] * * Return [UNKN ] Undocumented return value [ObjectInfo *] * */ ObjectInfo * hard_link_ObjectInfo(ObjectInfo * obj); /* Function: ObjectInfo_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ObjectInfo *] * */ ObjectInfo * ObjectInfo_alloc(void); /* Function: free_ObjectInfo(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ObjectInfo *] * * Return [UNKN ] Undocumented return value [ObjectInfo *] * */ ObjectInfo * free_ObjectInfo(ObjectInfo * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ int write_C_ObjectInfo(ObjectInfo * oi,FILE * ofp); ObjectInfo * read_ObjectInfo_line_func(char * line,int maxline,FILE * ifp,char * (fgets_func)(char *,int,FILE*)); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/probal.dy0000644000175000001440000001333507313404535015245 0ustar philippusers %{ #include "dyna2.h" #include "dynafunc.h" %} %{ #include "probal.h" %func Makes all the probabilistic routines %% void write_probabilistic_models(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { write_score_only_sum(dfp,gm,dpi); write_expl_mat_sum(dfp,gm,dpi); } %func Makes the explicit matrix over all paths construction method %% void write_expl_mat_sum(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { FuncInfo * fi; char * arg_str; char * chainstr; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"matrix_logsum_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates the matrix over all paths"); add_line_to_Ftext(fi->ft,"This is using a logsum method to sort it all out"); arg_str = get_argstr_GenericMatrix(gm); chainstr = get_chainstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"%s * matrix_logsum_%s(%s)",gm->name,gm->name,arg_str); ckfree(arg_str); expr(dfp,"%s * mat;",gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int tot;"); expr(dfp,"int num;"); add_break(dfp); expr(dfp,"if( (mat=allocate_Expl_%s(%s)) == NULL )",gm->name,chainstr); startbrace(dfp); warn_expr(dfp,"Unable to allocate large %s version",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"leni = mat->leni;"); expr(dfp,"lenj = mat->lenj;"); /*** make num and tot ***/ expr(dfp,"tot = leni * lenj;"); expr(dfp,"num = 0;"); /*** see if there any specials to specials to do ***/ add_break(dfp); expr(dfp,"start_reporting(\"%s Matrix calculation: \");",gm->name); expr(dfp,"for(j=0;jname); **/ expr(dfp,"num++;"); gm->calcfunc = dpi->calcfunc; write_score_block(dfp,gm,"EXPL_MATRIX","mat","EXPL_SPECIAL",TRUE); closebrace(dfp); write_special_block(dfp,gm,"EXPL_MATRIX","EXPL_SPECIAL",NULL); gm->calcfunc = NULL; closebrace(dfp); /*** stop reporting ***/ expr(dfp,"stop_reporting()"); expr(dfp,"return mat"); close_function(dfp); add_break(dfp); } %func Makes the single one-on-one over all paths searching method %% void write_score_only_sum(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { int i; FuncInfo * fi; char * arg_str; char * chain_str; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"score_only_logsum_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates the score over all paths"); add_line_to_Ftext(fi->ft,"This is using a logsum method to sort it all out"); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"Score score_only_logsum_%s(%s)",gm->name,arg_str); ckfree(arg_str); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int bestscore = 0;"); expr(dfp,"int k;"); expr(dfp,"%s * mat",gm->name); if(gm->qtype != NULL && gm->qtype->maxlen != NULL) { expr(dfp,"int internal_matrix[%d][(%s+%d) * %d];",gm->window_j+1,gm->qtype->maxlen,gm->window_i,gm->len); expr(dfp,"int internal_specials[%d][%d];",gm->window_j+1,gm->spec_len); } add_break(dfp); chain_str = get_chainstr_GenericMatrix(gm); expr(dfp,"mat = allocate_%s_only(%s);",gm->name,chain_str); ckfree(chain_str); expr(dfp,"if( mat == NULL )"); startbrace(dfp); warn_expr(dfp,"Memory allocation error in the db search - unable to communicate to calling function. this spells DISASTER!"); expr(dfp,"return NEGI"); closebrace(dfp); if(gm->qtype != NULL && gm->qtype->maxlen != NULL) { add_block_comment(dfp,"Ok,don't need to allocate matrix as it is internal, because we have a max length"); } else { expr(dfp,"if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(%d,(mat->leni + %d) * %d,%d,%d)) == NULL)",gm->window_j+1,gm->window_i,gm->len,gm->window_j+1,gm->spec_len); startbrace(dfp); expr(dfp,"warn(\"Score only matrix for %s cannot be allocated, (asking for %d by %%d cells)\",mat->leni*%d);",gm->name,gm->window_j,gm->len); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return 0;"); closebrace(dfp); expr(dfp,"mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL;"); } add_break(dfp); add_block_comment(dfp,"Now, initiate matrix"); expr(dfp,"for(j=0;j<%d;j++)",gm->window_j+2); startbrace(dfp); expr(dfp,"for(i=(-%d);ileni;i++)",gm->window_i); startbrace(dfp); expr(dfp,"for(k=0;k<%d;k++)",gm->len); hang_expr(dfp,"%s_VSMALL_MATRIX(mat,i,j,k) = NEGI;",gm->name); closebrace(dfp); for(i=0;ispec_len;i++) { expr(dfp,"%s_VSMALL_SPECIAL(mat,i,j,%s) = %s;",gm->name,gm->special[i]->name,gm->special[i]->def_score); } closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Ok, lets do-o-o-o-o it"); add_break(dfp); expr(dfp,"for(j=0;jlenj;j++)"); startbrace_tag(dfp,"for all target positions"); expr(dfp,"auto int score"); expr(dfp,"auto int temp"); expr(dfp,"for(i=0;ileni;i++)"); startbrace_tag(dfp,"for all query positions"); gm->calcfunc = dpi->calcfunc; write_score_block(dfp,gm,"VSMALL_MATRIX","mat","VSMALL_SPECIAL",TRUE); gm->calcfunc = NULL; closebrace(dfp); add_break(dfp); gm->calcfunc = dpi->calcfunc; write_special_block(dfp,gm,"VSMALL_MATRIX","VSMALL_SPECIAL",NULL); gm->calcfunc = NULL; closebrace(dfp); add_break(dfp); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return bestscore;"); close_function(dfp); add_break(dfp); } wise-2.4.1/src/dyc/exprtree.dy0000644000175000001440000002532007345165740015630 0ustar philippusers %{ #include "wisebase.h" /* * Expr Tree is about the yacc parse tree. Each node in the tree is going to be ExprTree *. The children of each node are in the child array, the number of children are in the nochild field. Each node has a type, and this is the critical layout of the node. Each type will layout its children in a particular way: ETR_NUMBER - has no children. The number is word ETR_OPERATOR - has no children. The operator character is in word ETR_EXPRESSION - has potentially any number of children, but the yacc parser restricts it to (possible_tag) (operator) (possible_tag). Don't rely on this though. Generally allowed types in possible_tag are NUMBEr, TAG, METHOD or EXPRESSION ETR_STATEMENT - is the top level tag. It only has one child which must be an ETR_EXPRESSION ETR_NAME - is for absolute variable names (or method names). It has no children. The actual name is in the word ETR_ARRAY - has 2 children. The first must be a "TAG" type and is what is indexed, the second must be an EXPRESSION and is what indexes it. ETR_TAG - has any number of children to build up a TAG from NAMES, ->,. (struct refs) or * (REFERNECES). ETR_STRUCTREF - -> or . constructions. It has 3 children: 1st is the TAG to the left of the STRUCTREF, second holds either . or -> in word and third is the tag to the right. ETR_REFERENCE - * or & constructions. It has two children. 1st is * or & in word, the second is the tag which is it is acting on. ETR_METHOD - function calls. It has one or two children. The first is a tag (hence could be a pointer to a function, or similar). If it is a void function it has no other children the second is a commalist. ETR_COMMALIST - can only be found in methods. Any number of children, each being an argument of the method */ enum types { ETR_NUMBER = 0, ETR_OPERATOR, ETR_EXPRESSION, ETR_STATEMENT, ETR_ARRAY, ETR_NAME, ETR_REFERENCE, ETR_STRUCTREF, ETR_METHOD, ETR_COMMALIST, ETR_DECL_VARIABLE, ETR_DECL_METHOD, ETR_DECL_LIST, ETR_TAG }; #define EXPRTREE_MAXCHILD 128 #define IS_DECLARED 2 #define IS_TOPLEVEL 4 %} struct ExprTree struct ExprTree * child[EXPRTREE_MAXCHILD]; int nochild; !def="0" char token; char * word; int type; int attrib; !def="0" struct ExprTree * parent; int position_in_parent; %{ #include "exprtree.h" void parentfy_ExprTree(ExprTree * et) { int i; for(i=0;inochild;i++) { et->child[i]->parent = et; et->child[i]->position_in_parent = i; parentfy_ExprTree(et->child[i]); } } void declared_ExprTree(ExprTree * et) { fprintf(stderr,"Declaring..."); et->attrib = et->attrib | IS_DECLARED; } void find_toplevel_name(ExprTree * et) { /** et should be an expression or a tag **/ int i; for(i=0;inochild;i++) { switch(et->child[i]->type) { case ETR_NAME : if( et->position_in_parent == 0 || !(et->parent->type == ETR_REFERENCE || et->parent->type == ETR_STRUCTREF) ) { /* printf("Found as a name -> [%d][%d]",et->parent->position_in_parent,et->parent->type); print_ExprTree(et->child[i]); printf("\n"); */ et->child[i]->attrib |= IS_TOPLEVEL; } else { /* printf("Ignoring name %d,%d",et->parent->position_in_parent,et->parent->type); print_ExprTree(et->child[i]); printf("\n"); */ et->child[i]->attrib &= ~IS_TOPLEVEL; } break; default : /* printf("Going into"); print_ExprTree(et->child[i]); printf("\n"); */ find_toplevel_name(et->child[i]); break; } } } void strcat_ExprTree(ExprTree * ExprTree,char * buffer) { int i; switch(ExprTree->type) { case ETR_NUMBER : strcat(buffer,ExprTree->word); return; case ETR_OPERATOR : strcat(buffer,ExprTree->word); return; case ETR_EXPRESSION : strcat(buffer,"("); for(i=0;i< ExprTree->nochild;i++) strcat_ExprTree(ExprTree->child[i],buffer); strcat(buffer,")"); return; case ETR_STATEMENT : for(i=0;i< ExprTree->nochild;i++) strcat_ExprTree(ExprTree->child[i],buffer); return; case ETR_NAME : strcat(buffer,ExprTree->word); return; case ETR_ARRAY : strcat_ExprTree(ExprTree->child[0],buffer); strcat(buffer,"["); strcat_ExprTree(ExprTree->child[1],buffer); strcat(buffer,"]"); return; case ETR_TAG : for(i=0;i< ExprTree->nochild;i++) strcat_ExprTree(ExprTree->child[i],buffer); return; case ETR_STRUCTREF : strcat_ExprTree(ExprTree->child[0],buffer); strcat(buffer,ExprTree->child[1]->word); strcat_ExprTree(ExprTree->child[2],buffer); return; case ETR_REFERENCE : strcat(buffer,ExprTree->child[0]->word); strcat_ExprTree(ExprTree->child[1],buffer); return; case ETR_METHOD : fprintf(stderr,"So buffer is now [%s]\n",buffer); strcat_ExprTree(ExprTree->child[0],buffer); strcat(buffer,"("); fprintf(stderr,"So buffer is now [%s]\n",buffer); strcat_ExprTree(ExprTree->child[1],buffer); /* for(i=0;ichild[1]->nochild;i++) strcat_ExprTree(ExprTree->child[1]->child[i],buffer); */ strcat(buffer,")"); return; case ETR_COMMALIST : for(i=0;inochild;i++) { strcat_ExprTree(ExprTree->child[i],buffer); if( i != ExprTree->nochild-1) strcat(buffer,","); } return; default : warn("In trying to make Expr string, got unobtainable type!"); } } void print_ExprTree(ExprTree * ExprTree) { int i; switch(ExprTree->type) { case ETR_NUMBER : printf("#{%s}",ExprTree->word); return; case ETR_OPERATOR : printf("Op{%s}",ExprTree->word); return; case ETR_EXPRESSION : printf("Expression ("); for(i=0;i< ExprTree->nochild;i++) print_ExprTree(ExprTree->child[i]); printf(")"); return; case ETR_STATEMENT : printf("Top level:"); for(i=0;i< ExprTree->nochild;i++) print_ExprTree(ExprTree->child[i]); printf("\n"); return; case ETR_NAME : printf("N{%s}",ExprTree->word); for(i=0;i< ExprTree->nochild;i++) print_ExprTree(ExprTree->child[i]); return; case ETR_ARRAY : printf("{ArrayInto{"); print_ExprTree(ExprTree->child[0]); printf("} of ["); print_ExprTree(ExprTree->child[1]); printf("]}"); return; case ETR_TAG : printf("Tag{"); for(i=0;i< ExprTree->nochild;i++) print_ExprTree(ExprTree->child[i]); printf("}"); return; case ETR_STRUCTREF : printf("struct{%s}(",ExprTree->child[1]->word); print_ExprTree(ExprTree->child[0]); printf(":"); print_ExprTree(ExprTree->child[2]); printf(")"); return; case ETR_REFERENCE : printf("Ref{"); puts(ExprTree->child[0]->word); print_ExprTree(ExprTree->child[1]); printf("}\n"); return; case ETR_METHOD : if( ExprTree->attrib & IS_DECLARED ) printf("DEC:"); printf("Method{"); for(i=0;ichild[0]->nochild;i++) print_ExprTree(ExprTree->child[0]->child[i]); if( ExprTree->nochild == 1 ) printf("}(void)"); else { printf("}("); for(i=0;ichild[1]->nochild;i++) print_ExprTree(ExprTree->child[1]->child[i]); printf(")"); } return; case ETR_COMMALIST : printf("List{"); for(i=0;inochild;i++) print_ExprTree(ExprTree->child[i]); printf("}"); return; default : printf("Unprintable!"); } } /*** declarations ***/ ExprTree * new_ExprTree_decl_method(ExprTree * name,ExprTree * list) { ExprTree * out; out = new_ExprTree(); out->type = ETR_DECL_METHOD; out->child[0]=name; out->child[1]=list; out->nochild = 2; return out; } ExprTree * new_ExprTree_decl_variable(ExprTree * type,ExprTree * name) { ExprTree * out; out = new_ExprTree(); out->type = ETR_DECL_VARIABLE; out->child[0]=type; out->child[1]=name; out->nochild = 2; return out; } ExprTree * add_to_decl_list_ExprTree(ExprTree * list,ExprTree * add) { if( list->type != ETR_DECL_LIST ) { warn("Attempting to add to a non commalist %d",list->type); return list; } add_ExprTree(list,add); return list; } ExprTree * new_ExprTree_decl_list(ExprTree * start) { ExprTree * out; out = new_ExprTree(); out->type = ETR_DECL_LIST; add_ExprTree(out,start); return out; } ExprTree * new_ExprTree_struct_ref(ExprTree * left, ExprTree * ref,ExprTree * right) { ExprTree * out; out = new_ExprTree(); out->type = ETR_STRUCTREF; out->child[0]=left; out->child[1]=ref; out->child[2]=right; out->nochild = 3; return out; } ExprTree * new_ExprTree_ref(char op,ExprTree * right) { ExprTree * out; out = new_ExprTree(); out->type = ETR_REFERENCE; out->child[0]=new_ExprTree_token(op); out->child[1]=right; out->nochild = 2; return out; } ExprTree * add_to_commalist_ExprTree(ExprTree * list,ExprTree * add) { if( list->type != ETR_COMMALIST ) { warn("Attempting to add to a non commalist %d",list->type); return list; } add_ExprTree(list,add); return list; } ExprTree * new_ExprTree_commalist(ExprTree * start) { ExprTree * out; out = new_ExprTree(); out->type = ETR_COMMALIST; add_ExprTree(out,start); return out; } ExprTree * new_ExprTree_method(ExprTree * one,ExprTree * other) { ExprTree * out; out = ExprTree_alloc(); out->type = ETR_METHOD; /* printf("This one %d\n",one->nochild); */ add_ExprTree(out,one); if(other == NULL) { return out; } if(other->type != ETR_COMMALIST ) { warn("Attempting to have a non commalist argument for a method"); } add_ExprTree(out,other); return out; } ExprTree * new_ExprTree_tag_from_name(ExprTree * name) { ExprTree * out; out= new_ExprTree(); out->type = ETR_TAG; add_ExprTree(out,name); return out; } ExprTree * new_ExprTree_array(ExprTree * tag,ExprTree * expr) { ExprTree * out; out = new_ExprTree(); out->type = ETR_ARRAY; out->child[0] = tag; out->child[1] = expr; out->nochild = 2; return out; } ExprTree * new_ExprTree_binary_expr(ExprTree * left,char op,ExprTree * rgt) { ExprTree * out; out = new_ExprTree(); out->type = ETR_EXPRESSION; out->child[0] = left; out->child[1] = new_ExprTree_token(op); out->child[2] = rgt; out->nochild = 3; return out; } ExprTree * new_ExprTree_token(char t) { ExprTree * out; char buf[2]; buf[0] = t; buf[1] = '\0'; out= new_ExprTree(); out->type= ETR_OPERATOR; out->token = t; out->word = stringalloc(buf); return out; } boolean add_ExprTree(ExprTree * one,ExprTree * child) { if( one->nochild+1 > EXPRTREE_MAXCHILD ) { warn("Overflow in ExprTree at %d children",EXPRTREE_MAXCHILD); return FALSE; } one->child[one->nochild++] = child; return TRUE; } ExprTree * new_ExprTree(void) { int i; ExprTree * out; out = ExprTree_alloc(); for(i=0;i<128;i++) out->child[i]= NULL; return out; } %} wise-2.4.1/src/dyc/type.c0000644000175000001440000005514310670453715014564 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "type.h" char * calc_lex_string; int stringpos =0; ExprTree * root = NULL; /* Function: copy_MethodTypeSet(mts) * * Descrip: copies MethodTypeSet by hard-linking list * members * * * * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [MethodTypeSet *] * */ # line 67 "type.dy" MethodTypeSet * copy_MethodTypeSet(MethodTypeSet * mts) { int i; MethodTypeSet * out; out = MethodTypeSet_alloc_std(); for(i=0;ime_len;i++) add_me_MethodTypeSet(out,hard_link_Method(mts->me[i])); for(i=0;ity_len;i++) add_ty_MethodTypeSet(out,hard_link_Type(mts->ty[i])); return out; } /* Function: std_Dynamite_Scope(void) * * Descrip: sets up "standard" dynamite scope. * * * * * Return [UNKN ] Undocumented return value [Scope *] * */ # line 88 "type.dy" Scope * std_Dynamite_Scope(void) { Scope * sc; sc = Scope_alloc_std(); /*** std set up code has moved to dyna2.dy ***/ return sc; } /* Function: allocd_calc_line(calc_line,sc,mts,dycw,pe,expr) * * Descrip: Main function used to access the parser. * * This parses the calc_line (without damaging it). Errors will * be placed normally: You should stack errors or catch them if * you want to do something funky. * * At the end of the day, if there was parser syntax error then you * will get NULL, and pe & PERR_SYNTAX will be set. Otherwise you * will get a char * (stringalloc'd). Potentially any number of * PERRs could be set, including unscoped variables or methods etc. * * * Arg: calc_line [READ ] line to be parsed [char *] * Arg: sc [READ ] scope system to use for this area [Scope *] * Arg: mts [READ ] method and type information (method scope) for this area [MethodTypeSet *] * Arg: dycw [UNKN ] Undocumented argument [DycWarning *] * Arg: pe [WRITE] returned parser errors [ParseError *] * Arg: expr [UNKN ] Undocumented argument [ExprTree **] * * Return [UNKN ] stringalloc'd expanded string [char *] * */ # line 117 "type.dy" char * allocd_calc_line(char * calc_line,Scope * sc,MethodTypeSet * mts,DycWarning * dycw,ParseError * pe,ExprTree ** expr) { char buffer[MAXLINE]; /** ouch - watch overflows **/ /*** set globals that we share with lex/yacc ***/ if( calc_line == NULL ) { warn("Got a NULL calc line - can hardly parse it!"); return NULL; } calc_lex_string = calc_line; stringpos= 0; root = NULL; /*** parse it ***/ yyparse(); /*** check root, if NULL... otta here ***/ if( root == NULL ) { /* silent fail. already been warned */ (*pe) |= PERR_SYNTAX; return NULL; } /*** make top-level name which could be ***/ find_toplevel_name(root); /*** make string, checking semantics this time ***/ buffer[0]='\0'; (*pe) |= strcat_ExprTree_Scoped(root,buffer,sc,mts,dycw,NULL,NULL); if( expr != NULL ) { *expr = root; } else { /* should free... don't at the moment */ } return stringalloc(buffer); } # line 164 "type.dy" void complain_ParseError_to_file(ParseError pe,FILE * ofp) { if( pe & PERR_SYNTAX ) fprintf(ofp,"Parser Syntax error on calc line\n"); if( pe & PERR_COMPLEXMETHOD) fprintf(ofp,"Complex methods (ie, pointer-functions) which cannot be typed\n"); if( pe & PERR_ARG_NUM_MIS ) fprintf(ofp,"Argument number mismatches\n"); if( pe & PERR_ARG_UNTYPED ) fprintf(ofp,"Un-typable arguments, due to array or structure deferences\n"); if( pe & PERR_ARG_MISTYPE ) fprintf(ofp,"Mistyped arguments\n"); if( pe & PERR_OUT_OF_SCOPE) fprintf(ofp,"Variable out of scope\n"); if( pe & PERR_METHOD_SCOPE) fprintf(ofp,"Method out of scope\n"); } # line 183 "type.dy" char * type_from_ExprTree(ExprTree * et,Scope * sc,MethodTypeSet * mts) { ScopeUnit * su; Method * me; switch( et->type ) { case ETR_EXPRESSION : /*** for the moment, return NULL... could return "int" quite ok.. ***/ return NULL; case ETR_NAME : su = ScopeUnit_from_Scope(sc,et->word); if( su == NULL ) { return NULL; } else { return su->type; } break; case ETR_TAG : if( et->nochild == 1 && et->child[0]->type == ETR_NAME) { return type_from_ExprTree(et->child[0],sc,mts); } return NULL; break; case ETR_METHOD : if( et->child[0]->nochild != 1 || et->child[0]->child[0]->type != ETR_NAME ) { return NULL; } me = Method_from_name(mts,et->child[0]->child[0]->word); if( me == NULL) { return NULL; } else { return me->retstr; } break; case ETR_STRUCTREF : case ETR_REFERENCE : return NULL; default : warn("Unable to type a Expr Node [%d]. Returing a 'blank' type",et->type); return NULL; } } /* Function: strcat_ExprTree_Scoped(ExprTree,finish_parsing,buffer,sc,mts,dycw,data) * * Descrip: Main internal recursive functions that * descends the Expr tree. Should at the * start be given the root node: buffer * is written in the final expression, mapped * etc. * * * Arg: ExprTree [UNKN ] Undocumented argument [ExprTree *] * Arg: finish_parsing [UNKN ] Undocumented argument [NullString] * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: sc [UNKN ] Undocumented argument [Scope *] * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * Arg: dycw [UNKN ] Undocumented argument [DycWarning *] * Arg: data [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [ParseError] * */ # line 236 "type.dy" ParseError strcat_ExprTree_Scoped(ExprTree * ExprTree,char * buffer,Scope * sc,MethodTypeSet * mts,DycWarning * dycw,boolean (*finish_parsing)(struct ExprTree *,char *,void *),void * data) { ParseError pe = 0; ScopeUnit * su; Method * me; char tempbuf[512]; int i; if( finish_parsing != NULL ) { if( (*finish_parsing)(ExprTree,buffer,data) == TRUE ) { return pe; } } switch(ExprTree->type) { case ETR_NUMBER : strcat(buffer,ExprTree->word); break; case ETR_OPERATOR : strcat(buffer,ExprTree->word); break; case ETR_EXPRESSION : strcat(buffer,"("); for(i=0;i< ExprTree->nochild;i++) pe |= strcat_ExprTree_Scoped(ExprTree->child[i],buffer,sc,mts,dycw,finish_parsing,data); strcat(buffer,")"); break; case ETR_STATEMENT : for(i=0;i< ExprTree->nochild;i++) pe |= strcat_ExprTree_Scoped(ExprTree->child[i],buffer,sc,mts,dycw,finish_parsing,data); break; case ETR_NAME : if( (ExprTree->attrib & IS_TOPLEVEL) == IS_TOPLEVEL) { /* fprintf(stderr,"Got a top level name %s\n",ExprTree->word);*/ su = ScopeUnit_from_Scope(sc,ExprTree->word); if( su == NULL ) { pe |= PERR_OUT_OF_SCOPE; if( dycw == NULL || dycw->warn_extern == TRUE ) warn("Name [%s] is out of scope: assumming extern",ExprTree->word); } else { /* fprintf(stderr,"Ok.[%d] for name %s, going to add %s\n",ExprTree->attrib,ExprTree->word,su->app);*/ strcat(buffer,su->app); } } strcat(buffer,ExprTree->word); break; case ETR_ARRAY : pe |= strcat_ExprTree_Scoped(ExprTree->child[0],buffer,sc,mts,dycw,finish_parsing,data); strcat(buffer,"["); pe |= strcat_ExprTree_Scoped(ExprTree->child[1],buffer,sc,mts,dycw,finish_parsing,data); strcat(buffer,"]"); break; case ETR_TAG : for(i=0;i< ExprTree->nochild;i++) pe |= strcat_ExprTree_Scoped(ExprTree->child[i],buffer,sc,mts,dycw,finish_parsing,data); break; case ETR_STRUCTREF : pe |= strcat_ExprTree_Scoped(ExprTree->child[0],buffer,sc,mts,dycw,finish_parsing,data); strcat(buffer,ExprTree->child[1]->word); pe |= strcat_ExprTree_Scoped(ExprTree->child[2],buffer,sc,mts,dycw,finish_parsing,data); break; case ETR_REFERENCE : strcat(buffer,ExprTree->child[0]->word); pe |= strcat_ExprTree_Scoped(ExprTree->child[1],buffer,sc,mts,dycw,finish_parsing,data); break; case ETR_METHOD : if( ExprTree->child[0]->nochild != 1 || ExprTree->child[0]->child[0]->type != ETR_NAME ) { pe |= PERR_COMPLEXMETHOD; /*** generate error ***/ tempbuf[0]='\0'; strcat_ExprTree(ExprTree->child[0],tempbuf); warn("Method [%s] is not a pure name [%d]: this tolerated in the parser but can't be checked",tempbuf,ExprTree->child[0]->type); pe |= strcat_ExprTree_Scoped(ExprTree->child[0],buffer,sc,mts,dycw,finish_parsing,data); } else { me = Method_from_name(mts,ExprTree->child[0]->child[0]->word); if( me == NULL ) { pe |= PERR_METHOD_SCOPE; if( dycw == NULL || dycw->warn_extern_method == TRUE ) warn("Implied method [%s] has not been typed, and hence can't be type-checked or logical-mapped",ExprTree->child[0]->child[0]->word); pe |= strcat_ExprTree_Scoped(ExprTree->child[0],buffer,sc,mts,dycw,finish_parsing,data); } else { pe |= typecheck_method(ExprTree->child[1],me,sc,mts); strcat(buffer,me->real); /* do nothing at the moment */ } } strcat(buffer,"("); pe |= strcat_ExprTree_Scoped(ExprTree->child[1],buffer,sc,mts,dycw,finish_parsing,data); strcat(buffer,")"); break; case ETR_COMMALIST : for(i=0;inochild;i++) { pe |= strcat_ExprTree_Scoped(ExprTree->child[i],buffer,sc,mts,dycw,finish_parsing,data); if( i != ExprTree->nochild-1) strcat(buffer,","); } break; default : pe |= PERR_SYNTAX; warn("In trying to make Expr string, got unobtainable type!"); } return pe; } # line 348 "type.dy" ParseError typecheck_method(ExprTree * et,Method * me,Scope * sc,MethodTypeSet * mts) { int i; char * t; int ret = 0; int j; ScopeUnit * sunit = NULL; if( et->type != ETR_COMMALIST ) { warn("Trying to typecheck with a non-comma list system %d --- internal parser error and v.bad",et->type); } if( me->len != et->nochild ) { ret |= PERR_ARG_NUM_MIS; warn("In method [%s], expect %d arguments, given %d arguments",me->logical,me->len,et->nochild); return ret; } for(i=0;ilen;i++) { t = type_from_ExprTree(et->child[i],sc,mts); if( t == NULL ) { ret |= PERR_ARG_UNTYPED; /* warn("For argument %d, of %s, no type information",i,me->logical); */ } else { if ( compare_type(t,me->ma[i]->type) == FALSE ) { warn("Mis-type in argument %d of %s: wanted [%s] got [%s]",i+1,me->logical,me->ma[i]->type,t); ret |= PERR_ARG_MISTYPE; } } } /** do forbidden pairs if appropiate **/ for(i=0;ilen;i++) { auto char * test_argument; if( et->child[i]->type == ETR_NAME ) { test_argument = et->child[i]->word; if( (sunit = ScopeUnit_from_Scope(sc,et->child[i]->word)) == NULL ) continue; /** ugh - unscoped **/ } else if ( et->child[i]->type == ETR_TAG && et->child[i]->nochild == 1 && et->child[i]->child[0]->type == ETR_NAME ) { test_argument = et->child[i]->child[0]->word; if( (sunit = ScopeUnit_from_Scope(sc,et->child[i]->child[0]->word)) == NULL ) continue; /** ugh - unscoped **/ } if( sunit == NULL ) { continue; } /** we have scope. Continue if it has no forbiddens **/ if( sunit->no_accept == NULL ) continue; for(j=i+1;jlen;j++) { auto char * word; word = NULL; if( et->child[j]->type == ETR_NAME ) { word = et->child[j]->word; } else if ( et->child[i]->type == ETR_TAG && et->child[i]->nochild == 1 && et->child[i]->child[0]->type == ETR_NAME ) { word = et->child[j]->child[0]->word; } if( word != NULL && strcmp(word,sunit->no_accept) == 0 && 0) warn("For function %s, you have arguments %s and %s, which do not expect to paired directly in a function. This is just a warning that you can ignore",me->logical,word,test_argument); } } /*** end of forbidden pairs code ***/ return ret; } /* Function: ScopeUnit_from_Scope(sc,word) * * Descrip: gets a ScopeUnit from the name * * * Arg: sc [UNKN ] Undocumented argument [Scope *] * Arg: word [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ScopeUnit *] * */ # line 427 "type.dy" ScopeUnit * ScopeUnit_from_Scope(Scope * sc,char * word) { int i; for(i=0;ilen;i++) { if( sc->su[i]->isglobbed == TRUE) { /*** hacky ***/ if( strstartcmp(word,sc->su[i]->name) == 0 ) { return sc->su[i]; } } else { if( strcmp(sc->su[i]->name,word) == 0 ) return sc->su[i]; } } return NULL; } # line 446 "type.dy" ScopeUnit * ScopeUnit_from_nat(MethodTypeSet * mts,char * name,char * app,char * type) { ScopeUnit * su; su = ScopeUnit_alloc(); if( name[strlen(name)-1] == '*') { name[strlen(name)-1] = '\0'; su->isglobbed = TRUE; } su->name = stringalloc(name); su->app = stringalloc(app); su->type = stringalloc(type); return su; } # line 452 "type.c" /* Function: hard_link_ScopeUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ScopeUnit *] * * Return [UNKN ] Undocumented return value [ScopeUnit *] * */ ScopeUnit * hard_link_ScopeUnit(ScopeUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a ScopeUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ScopeUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ScopeUnit *] * */ ScopeUnit * ScopeUnit_alloc(void) { ScopeUnit * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ScopeUnit *) ckalloc (sizeof(ScopeUnit))) == NULL) { warn("ScopeUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->app = NULL; out->type = NULL; out->isglobbed = FALSE; out->scope_type = SCOPE_EXTERN; out->no_accept = NULL; return out; } /* Function: free_ScopeUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ScopeUnit *] * * Return [UNKN ] Undocumented return value [ScopeUnit *] * */ ScopeUnit * free_ScopeUnit(ScopeUnit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ScopeUnit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->app != NULL) ckfree(obj->app); if( obj->type != NULL) ckfree(obj->type); if( obj->no_accept != NULL) ckfree(obj->no_accept); ckfree(obj); return NULL; } /* Function: swap_Scope(list,i,j) * * Descrip: swap function: an internal for qsort_Scope * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ScopeUnit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Scope(ScopeUnit ** list,int i,int j) { ScopeUnit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Scope(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Scope which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ScopeUnit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Scope(ScopeUnit ** list,int left,int right,int (*comp)(ScopeUnit * ,ScopeUnit * )) { int i,last; if( left >= right ) return; swap_Scope(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Scope (list,++last,i); } swap_Scope (list,left,last); qsort_Scope(list,left,last-1,comp); qsort_Scope(list,last+1,right,comp); } /* Function: sort_Scope(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Scope * * * Arg: obj [UNKN ] Object containing list [Scope *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Scope(Scope * obj,int (*comp)(ScopeUnit *, ScopeUnit *)) { qsort_Scope(obj->su,0,obj->len-1,comp); return; } /* Function: expand_Scope(obj,len) * * Descrip: Really an internal function for add_Scope * * * Arg: obj [UNKN ] Object which contains the list [Scope *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Scope(Scope * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Scope called with no need"); return TRUE; } if( (obj->su = (ScopeUnit ** ) ckrealloc (obj->su,sizeof(ScopeUnit *)*len)) == NULL) { warn("ckrealloc failed for expand_Scope, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Scope(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Scope *] * Arg: add [OWNER] Object to add to the list [ScopeUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Scope(Scope * obj,ScopeUnit * add) { if( obj->len >= obj->maxlen) { if( expand_Scope(obj,obj->len + ScopeLISTLENGTH) == FALSE) return FALSE; } obj->su[obj->len++]=add; return TRUE; } /* Function: flush_Scope(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Scope *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Scope(Scope * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->su[i] != NULL) { free_ScopeUnit(obj->su[i]); obj->su[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: Scope_alloc_std(void) * * Descrip: Equivalent to Scope_alloc_len(ScopeLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Scope *] * */ Scope * Scope_alloc_std(void) { return Scope_alloc_len(ScopeLISTLENGTH); } /* Function: Scope_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Scope *] * */ Scope * Scope_alloc_len(int len) { Scope * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Scope_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->su = (ScopeUnit ** ) ckcalloc (len,sizeof(ScopeUnit *))) == NULL) { warn("Warning, ckcalloc failed in Scope_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_Scope(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Scope *] * * Return [UNKN ] Undocumented return value [Scope *] * */ Scope * hard_link_Scope(Scope * obj) { if( obj == NULL ) { warn("Trying to hard link to a Scope object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Scope_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Scope *] * */ Scope * Scope_alloc(void) { Scope * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Scope *) ckalloc (sizeof(Scope))) == NULL) { warn("Scope_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->su = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_Scope(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Scope *] * * Return [UNKN ] Undocumented return value [Scope *] * */ Scope * free_Scope(Scope * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Scope obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->su != NULL) { for(i=0;ilen;i++) { if( obj->su[i] != NULL) free_ScopeUnit(obj->su[i]); } ckfree(obj->su); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/type.h0000644000175000001440000001677710670453715014603 0ustar philippusers#ifndef DYNAMITEtypeHEADERFILE #define DYNAMITEtypeHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "wisec.h" #include "exprtree.h" #include "y.tab.h" #include "method.h" #include "input.h" #include "dpimpl.h" #define ScopeLISTLENGTH 16 typedef unsigned int ParseError; enum ParseErrorType { PERR_SYNTAX = 1, PERR_COMPLEXMETHOD = 2, PERR_ARG_NUM_MIS = 4, PERR_ARG_UNTYPED = 8, PERR_ARG_MISTYPE = 16, PERR_OUT_OF_SCOPE = 32, PERR_METHOD_SCOPE = 64 }; enum SCOPE_TYPE { SCOPE_RESOURCE = 82, SCOPE_QUERY, SCOPE_TARGET, SCOPE_EXTERN }; /*** declare yyparse ****/ void yyparse(void); struct ScopeUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; char * app; char * type; boolean isglobbed; int scope_type; char * no_accept; /* for guys which don't like other arguments */ } ; /* ScopeUnit defined */ #ifndef DYNAMITE_DEFINED_ScopeUnit typedef struct ScopeUnit ScopeUnit; #define DYNAMITE_DEFINED_ScopeUnit #endif struct Scope { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ScopeUnit ** su; int len;/* len for above su */ int maxlen; /* maxlen for above su */ } ; /* Scope defined */ #ifndef DYNAMITE_DEFINED_Scope typedef struct Scope Scope; #define DYNAMITE_DEFINED_Scope #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: copy_MethodTypeSet(mts) * * Descrip: copies MethodTypeSet by hard-linking list * members * * * * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * * Return [UNKN ] Undocumented return value [MethodTypeSet *] * */ MethodTypeSet * copy_MethodTypeSet(MethodTypeSet * mts); /* Function: std_Dynamite_Scope(void) * * Descrip: sets up "standard" dynamite scope. * * * * * Return [UNKN ] Undocumented return value [Scope *] * */ Scope * std_Dynamite_Scope(void); /* Function: allocd_calc_line(calc_line,sc,mts,dycw,pe,expr) * * Descrip: Main function used to access the parser. * * This parses the calc_line (without damaging it). Errors will * be placed normally: You should stack errors or catch them if * you want to do something funky. * * At the end of the day, if there was parser syntax error then you * will get NULL, and pe & PERR_SYNTAX will be set. Otherwise you * will get a char * (stringalloc'd). Potentially any number of * PERRs could be set, including unscoped variables or methods etc. * * * Arg: calc_line [READ ] line to be parsed [char *] * Arg: sc [READ ] scope system to use for this area [Scope *] * Arg: mts [READ ] method and type information (method scope) for this area [MethodTypeSet *] * Arg: dycw [UNKN ] Undocumented argument [DycWarning *] * Arg: pe [WRITE] returned parser errors [ParseError *] * Arg: expr [UNKN ] Undocumented argument [ExprTree **] * * Return [UNKN ] stringalloc'd expanded string [char *] * */ char * allocd_calc_line(char * calc_line,Scope * sc,MethodTypeSet * mts,DycWarning * dycw,ParseError * pe,ExprTree ** expr); /* Function: hard_link_ScopeUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ScopeUnit *] * * Return [UNKN ] Undocumented return value [ScopeUnit *] * */ ScopeUnit * hard_link_ScopeUnit(ScopeUnit * obj); /* Function: ScopeUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ScopeUnit *] * */ ScopeUnit * ScopeUnit_alloc(void); /* Function: free_ScopeUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ScopeUnit *] * * Return [UNKN ] Undocumented return value [ScopeUnit *] * */ ScopeUnit * free_ScopeUnit(ScopeUnit * obj); /* Function: add_Scope(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Scope *] * Arg: add [OWNER] Object to add to the list [ScopeUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_Scope(Scope * obj,ScopeUnit * add); /* Function: flush_Scope(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Scope *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Scope(Scope * obj); /* Function: Scope_alloc_std(void) * * Descrip: Equivalent to Scope_alloc_len(ScopeLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Scope *] * */ Scope * Scope_alloc_std(void); /* Function: Scope_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Scope *] * */ Scope * Scope_alloc_len(int len); /* Function: hard_link_Scope(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Scope *] * * Return [UNKN ] Undocumented return value [Scope *] * */ Scope * hard_link_Scope(Scope * obj); /* Function: Scope_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Scope *] * */ Scope * Scope_alloc(void); /* Function: free_Scope(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Scope *] * * Return [UNKN ] Undocumented return value [Scope *] * */ Scope * free_Scope(Scope * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ void complain_ParseError_to_file(ParseError pe,FILE * ofp); char * type_from_ExprTree(ExprTree * et,Scope * sc,MethodTypeSet * mts); ParseError typecheck_method(ExprTree * et,Method * me,Scope * sc,MethodTypeSet * mts); ScopeUnit * ScopeUnit_from_nat(MethodTypeSet * mts,char * name,char * app,char * type); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ ParseError strcat_ExprTree_Scoped(ExprTree * ExprTree,char * buffer,Scope * sc,MethodTypeSet * mts,DycWarning * dycw,boolean (*finish_parsing)(struct ExprTree *,char *,void *),void * data); ScopeUnit * ScopeUnit_from_Scope(Scope * sc,char * word); void swap_Scope(ScopeUnit ** list,int i,int j) ; void qsort_Scope(ScopeUnit ** list,int left,int right,int (*comp)(ScopeUnit * ,ScopeUnit * )); void sort_Scope(Scope * obj,int (*comp)(ScopeUnit *, ScopeUnit *)); boolean expand_Scope(Scope * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/dynafunc.c0000644000175000001440000023167210670453715015415 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dynafunc.h" # line 25 "dynafunc.dy" void one_shot_aln_func(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { FuncInfo * fi; char * arg_str; char * chainstr; /*** prepare function information ***/ fi = FuncInfo_named_from_varstr(FI_CALLABLE,"PackAln_bestmemory_%s",gm->name); add_line_to_Ftext(fi->ft,"This function chooses the best memory set-up for the alignment",gm->name); add_line_to_Ftext(fi->ft,"using calls to basematrix, and then implements either a large"); add_line_to_Ftext(fi->ft,"or small memory model."); add_break_to_Ftext(fi->ft); add_line_to_Ftext(fi->ft,"It is the best function to use if you just want an alignment",gm->name); add_break_to_Ftext(fi->ft); add_line_to_Ftext(fi->ft,"If you want a label alignment, you will need"); add_line_to_Ftext(fi->ft,"/convert_PackAln_to_AlnBlock_%s",gm->name); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"PackAln * PackAln_bestmemory_%s(%s,DPEnvelope * dpenv,DPRunImpl * dpri)",gm->name,arg_str); /*** clean up ***/ ckfree(arg_str); chainstr= get_chainstr_GenericMatrix(gm); /** started function, now see what basematrix says about memory **/ expr(dfp,"long long total;"); expr(dfp,"%s * mat;",gm->name); expr(dfp,"PackAln * out;"); expr(dfp,"DebugMatrix * de"); expr(dfp,"DPRunImplMemory strategy;"); expr(dfp,"assert(dpri);"); add_break(dfp); expr(dfp,"total = %s->%s * %s->%s",gm->query->name,gm->query_len,gm->target->name,gm->target_len); expr(dfp,"if( dpri->memory == DPIM_Default ) "); startbrace(dfp); expr(dfp,"if( (total * %d * sizeof(int)) > 1000*dpri->kbyte_size)",gm->len); startbrace(dfp); expr(dfp,"strategy = DPIM_Linear;"); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"strategy = DPIM_Explicit;"); closebrace(dfp); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"strategy = dpri->memory;"); closebrace(dfp); add_break(dfp); expr(dfp,"if( dpenv != NULL )"); startbrace(dfp); expr(dfp,"if( strategy == DPIM_Explicit)"); startbrace(dfp); expr(dfp,"if( (mat=allocate_Expl_%s(%s,dpri)) == NULL )",gm->name,chainstr); startbrace(dfp); warn_expr(dfp,"Unable to allocate large %s version",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"calculate_dpenv_%s(mat,dpenv)",gm->name); expr(dfp,"out = PackAln_read_Expl_%s(mat);",gm->name); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"mat = allocate_%s_only(%s)",gm->name,chainstr); expr(dfp,"calculate_shatter_%s(mat,dpenv)",gm->name); expr(dfp,"out = PackAln_read_Shatter_%s(mat)",gm->name); closebrace(dfp); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"if( strategy == DPIM_Linear )",gm->len); startbrace(dfp); add_block_comment(dfp,"use small implementation"); expr(dfp,"if( (mat=allocate_Small_%s(%s)) == NULL )",gm->name,chainstr); startbrace(dfp); warn_expr(dfp,"Unable to allocate small %s version",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"out = PackAln_calculate_Small_%s(mat,dpenv)",gm->name); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); add_block_comment(dfp,"use Large implementation"); expr(dfp,"if( (mat=allocate_Expl_%s(%s,dpri)) == NULL )",gm->name,chainstr); startbrace(dfp); warn_expr(dfp,"Unable to allocate large %s version",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"if( dpri->debug == TRUE)"); startbrace(dfp); if( dpi->dydebug == TRUE ) { expr(dfp,"de = create_debug_%s();",gm->name); expr(dfp,"de->matrix = (void*) mat;"); expr(dfp,"explicit_debug_%s(de,0);",gm->name); expr(dfp,"out = PackAln_read_Expl_%s(mat);",gm->name); expr(dfp,"if( dpri->paldebug == TRUE ) "); hang_expr(dfp,"show_PackAln_Debug(de,out,stdout);"); expr(dfp,"free_DebugMatrix(de);"); } else { expr(dfp,"fatal(\"Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source\");"); } closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"calculate_%s(mat)",gm->name); expr(dfp,"out = PackAln_read_Expl_%s(mat);",gm->name); closebrace(dfp); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); ckfree(chainstr); } /* Function: recalculate_PackAln_func(dfp,gm) * * Descrip: makes the recalculate packaln function * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [const GenericMatrix *] * */ # line 165 "dynafunc.dy" void recalculate_PackAln_func(DYNFILE * dfp,const GenericMatrix * gm) { FuncInfo * fi; /* ArgInfo * ai; */ int i; int j; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"recalculate_PackAln_%s",gm->name); add_line_to_Ftext(fi->ft,"This function recalculates the PackAln structure produced by %s",gm->name); add_line_to_Ftext(fi->ft,"For example, in linear space methods this is used to score them",gm->name); start_function_FuncInfo(fi,dfp,"void recalculate_PackAln_%s(PackAln * pal,%s * mat)",gm->name,gm->name); expr(dfp,"int i,j,k,offi,offj;"); expr(dfp,"PackAlnUnit * prev;"); expr(dfp,"PackAlnUnit * pau;"); add_break(dfp); expr(dfp,"for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau)"); startbrace(dfp); expr(dfp,"pau = pal->pau[k];"); expr(dfp,"i = pau->i;"); expr(dfp,"j = pau->j;"); expr(dfp,"offi = pau->i - prev->i"); expr(dfp,"offj = pau->j - prev->j"); expr(dfp,"switch(pau->state)"); startbrace(dfp); for(i=0;ilen;i++) { expr(dfp,"case %s : ",gm->state[i]->name); startcase(dfp); /*** about to move to if statements... ***/ for(j=0;jstate[i]->len;j++) { if( gm->state[i]->source[j]->isspecial == TRUE) expr(dfp,"if( offj == %d && prev->state == (%s+%d) )",gm->state[i]->source[j]->offj,gm->state[i]->source[j]->state_source,gm->len); else expr(dfp,"if( offi == %d && offj == %d && prev->state == %s )",gm->state[i]->source[j]->offi,gm->state[i]->source[j]->offj,gm->state[i]->source[j]->state_source); startbrace(dfp); expr(dfp,"pau->score = %s + (%s)",gm->state[i]->source[j]->calc_expr,gm->state[i]->calc_expr == NULL ? "0" : gm->state[i]->calc_expr); expr(dfp,"continue;"); closebrace(dfp); } expr(dfp,"warn(\"In recaluclating PackAln with state %s, from [%%d,%%d,%%d], got a bad source state. Error!\",offi,offj,prev->state);",gm->state[i]->name); expr(dfp,"break;"); closecase(dfp); } for(i=0;ispec_len;i++) { expr(dfp,"case (%s+%d) : ",gm->special[i]->name,gm->len); startcase(dfp); for(j=0;jspecial[i]->len;j++) { if( gm->special[i]->source[j]->isspecial == TRUE) expr(dfp,"if( offj == %d && prev->state == (%s+%d) )",gm->special[i]->source[j]->offj,gm->special[i]->source[j]->state_source,gm->len); else expr(dfp,"if( offj == %d && prev->state == %s )",gm->special[i]->source[j]->offj,gm->special[i]->source[j]->state_source); startbrace(dfp); if( gm->special[i]->source[j]->isspecial == FALSE) { add_block_comment(dfp,"i here comes from the previous state ;) - not the real one"); expr(dfp,"i = prev->i;"); } expr(dfp,"pau->score = %s + (%s)",gm->special[i]->source[j]->calc_expr,gm->special[i]->calc_expr == NULL ? "0" : gm->special[i]->calc_expr); expr(dfp,"continue;"); closebrace(dfp); } warn_expr(dfp,"In recaluclating PackAln with state %s, got a bad source state. Error!",gm->special[i]->name); expr(dfp,"break;"); closecase(dfp); } expr(dfp,"default : "); startcase(dfp); warn_expr(dfp,"In recaluclating PackAln got a bad recipient state. Error!"); closecase(dfp); closebrace(dfp); /* end of switch on pau->state */ expr(dfp,"prev = pau;"); closebrace(dfp); expr(dfp,"return;"); close_function(dfp); } /* Function: alloc_expl_func_GenericMatrix(dfp,gm) * * Descrip: makes the allocate_Expl_xxx function. * This calls allocate_xxx_only function * (made by /write_safe_alloc_function) * and then allocates basematrix stuff as well. * * * Arg: dfp [UNKN ] dynamite file pointer [DYNFILE *] * Arg: gm [READ ] generic matrix structure [const GenericMatrix *] * */ # line 266 "dynafunc.dy" void alloc_expl_func_GenericMatrix(DYNFILE * dfp,const GenericMatrix * gm) { FuncInfo * fi; char * arg_str; char * chain_str; /*** prepare function information ***/ fi = FuncInfo_named_from_varstr(FI_CALLABLE,"allocate_Expl_%s",gm->name); add_line_to_Ftext(fi->ft,"This function allocates the %s structure",gm->name); add_line_to_Ftext(fi->ft,"and the basematrix area for explicit memory implementations"); add_line_to_Ftext(fi->ft,"It calls /allocate_%s_only",gm->name); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"%s * allocate_Expl_%s(%s,DPRunImpl * dpri)",gm->name,gm->name,arg_str); /*** clean up ***/ ckfree(arg_str); /*** into function body ***/ expr(dfp,"%s * out;",gm->name); add_break(dfp); chain_str = get_chainstr_GenericMatrix(gm); expr(dfp,"out = allocate_%s_only(%s);",gm->name,chain_str); ckfree(chain_str); expr(dfp,"if( out == NULL )"); hang_expr(dfp,"return NULL;"); expr(dfp,"if( dpri->should_cache == TRUE )"); startbrace(dfp); expr(dfp,"if( dpri->cache != NULL )"); startbrace(dfp); expr(dfp,"if( dpri->cache->maxleni >= (out->lenj+%d)*%d && dpri->cache->maxlenj >= (out->leni+%d))",gm->window_j,gm->len,gm->window_i); hang_expr(dfp,"out->basematrix = hard_link_BaseMatrix(dpri->cache)"); expr(dfp,"else"); hang_expr(dfp,"dpri->cache = free_BaseMatrix(dpri->cache)"); closebrace(dfp); closebrace(dfp); expr(dfp,"if( out->basematrix == NULL )"); startbrace(dfp); expr(dfp,"if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+%d)*%d,(out->leni+%d),%d,out->lenj+%d)) == NULL)",gm->window_j,gm->len,gm->window_i,gm->spec_len,gm->window_j); startbrace(dfp); expr(dfp,"warn(\"Explicit matrix %s cannot be allocated, (asking for %%d by %%d main cells)\",out->leni,out->lenj);",gm->name); expr(dfp,"free_%s(out)",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); closebrace(dfp); expr(dfp,"if( dpri->should_cache == TRUE && dpri->cache == NULL)"); hang_expr(dfp,"dpri->cache = hard_link_BaseMatrix(out->basematrix)"); expr(dfp,"out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT;"); expr(dfp,"init_%s(out)",gm->name); expr(dfp,"return out"); close_function(dfp); add_break(dfp); } /* Function: write_safe_alloc_function(dfp,gm) * * Descrip: produces the allocate_xxx_only function, * which allocates the matrix structure, checks * resources which it can check, but does NOT * allocate basematrix area * * This function will be called by allocate_Expl_xxxx * and allocate_Small_xxxx etc. * * * Arg: dfp [UNKN ] dynmaite file pointer to func/head [DYNFILE *] * Arg: gm [UNKN ] generic matrix structure [GenericMatrix *] * */ # line 357 "dynafunc.dy" void write_safe_alloc_function(DYNFILE * dfp,GenericMatrix * gm) { int i; FuncInfo * fi; char * arg_str; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"allocate_%s_only",gm->name); add_line_to_Ftext(fi->ft,"This function only allocates the %s structure",gm->name); add_line_to_Ftext(fi->ft,"checks types where possible and determines leni and lenj"); add_line_to_Ftext(fi->ft,"The basematrix area is delt with elsewhere"); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"%s * allocate_%s_only(%s)",gm->name,gm->name,arg_str); /*** clean up ***/ ckfree(arg_str); expr(dfp,"%s * out",gm->name); add_break(dfp); expr(dfp,"if((out= %s_alloc()) == NULL)",gm->name); startbrace(dfp); warn_expr(dfp,"Allocation of basic %s structure failed...",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); expr(dfp,"out->%s = %s",gm->query->name,gm->query->name); expr(dfp,"out->%s = %s",gm->target->name,gm->target->name); for(i=0;ires_len;i++) { expr(dfp,"out->%s = %s",gm->resource[i]->name,gm->resource[i]->name); } expr(dfp,"out->leni = %s->%s",gm->query->name,gm->query_len); expr(dfp,"out->lenj = %s->%s",gm->target->name,gm->target_len); expr(dfp,"return out"); close_function(dfp); add_break(dfp); } /* Function: add_args_GenericMatrix_FuncInfo(fi,gm) * * Descrip: Information partner to /get_argstr_GenericMatrix. * Loads up the arglist information for the GenericMatrix, * ie query-type query-name "what information" etc. * * * * Arg: fi [WRITE] FuncInfo structure to add ArgInfo to [FuncInfo *] * Arg: gm [READ ] generic matrix structure to read from [const GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 415 "dynafunc.dy" boolean add_args_GenericMatrix_FuncInfo(FuncInfo * fi,const GenericMatrix * gm) { int i; ArgInfo * ai; /** ArgInfo_in_FuncInfo_from_varstr automatically adds ai to fi **/ ai = ArgInfo_in_FuncInfo_from_varstr(fi,gm->query->name); ai->desc=stringalloc("query data structure"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,gm->target->name); ai->desc=stringalloc("target data structure"); for(i=0;ires_len;i++) { ai = ArgInfo_in_FuncInfo_from_varstr(fi,gm->resource[i]->name); ai->desc=stringalloc("Resource"); } return TRUE; } /* Function: get_chainstr_GenericMatrix(gm) * * Descrip: makes an the argument calling string which * is compatible with the arg_str from * /get_argstr_GenericMatrix * * eg "query,target,comp_mat" * * * Arg: gm [READ ] structure holding generic matrix [const GenericMatrix *] * * Return [UNKN ] allocated string (must free) with chained-args [char *] * */ # line 447 "dynafunc.dy" char * get_chainstr_GenericMatrix(const GenericMatrix * gm) { char buffer[MAXLINE]; int i; sprintf(buffer,"%s, %s ",gm->query->name,gm->target->name); for(i=0;ires_len;i++) { strcat(buffer,", "); strcat(buffer,gm->resource[i]->name); } return stringalloc(buffer); } /* Function: get_argstr_GenericMatrix(gm) * * Descrip: makes the argument list for a generic matrix alloc, ie * query-type query-name,target-type target-name etc * * To load up info, use /add_arg_GenericMatrix_FuncInfo * To chain up along function calls, use /get_chainstr_GenericMatrix * * * Arg: gm [READ ] structure holding generic matrix [const GenericMatrix *] * * Return [UNKN ] allocated string (must free) with args [char *] * */ # line 473 "dynafunc.dy" char * get_argstr_GenericMatrix(const GenericMatrix * gm) { char buffer[MAXLINE]; int i; sprintf(buffer,"%s %s,%s %s ",gm->query->element_type,gm->query->name,gm->target->element_type,gm->target->name); for(i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,gm->resource[i]->element_type); strcat(buffer," "); strcat(buffer,gm->resource[i]->name); } return stringalloc(buffer); } # line 490 "dynafunc.dy" void write_dotter_dump(DYNFILE * dfp,GenericMatrix * gm) { start_function(dfp,"void dump_dotter_%s(%s * mat,FILE * ofp)",gm->name,gm->name); expr(dfp,"register int i"); expr(dfp,"register int j"); expr(dfp,"register int k"); expr(dfp,"int hlen"); expr(dfp,"int vlen"); expr(dfp,"char form = 1;"); expr(dfp,"int zoom = 1;"); expr(dfp,"register int max = (-1000000)"); /*** expr(dfp,"fprintf(ofp,\"fileformat 1\\nzoomfactor 10\\nhorizontal_len %%d\\nvertical_len %%d\\n\",mat->%s->%s + (4-((mat->%s->%s)%%4)),mat->%s->%s + (4-((mat->%s->%s)%%4)));", gm->query->name,gm->query_len,gm->query->name,gm->query_len,gm->target->name,gm->target_len,gm->target->name,gm->target_len); ***/ expr(dfp,"hlen = mat->%s->%s",gm->query->name,gm->query_len); expr(dfp,"if( hlen%%4 != 0 ) "); hang_expr(dfp,"hlen += 4 - hlen%%4;"); expr(dfp,"vlen = mat->%s->%s",gm->target->name,gm->target_len); expr(dfp,"if( vlen%%4 != 0 ) "); hang_expr(dfp,"vlen += 4 - hlen%%4;"); expr(dfp,"fwrite(&form,sizeof(char),1,ofp)"); expr(dfp,"fwrite(&zoom,sizeof(int),1,ofp)"); expr(dfp,"fwrite(&hlen,sizeof(int),1,ofp)"); expr(dfp,"fwrite(&vlen,sizeof(int),1,ofp)"); expr(dfp,"for(i=0;i%s->%s;i++)",gm->query->name,gm->query_len); startbrace(dfp); expr(dfp,"for(j=0;j%s->%s;j++)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"if( %s_EXPL_MATRIX(mat,i,j,1) > max )",gm->name); expr(dfp,"max = %s_EXPL_MATRIX(mat,i,j,1)",gm->name); closebrace(dfp); closebrace(dfp); expr(dfp,"for(i=0;i%s->%s;i++)",gm->query->name,gm->query_len); startbrace(dfp); expr(dfp,"for(j=0;j%s->%s;j++)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"fputc( (char) (%s_EXPL_MATRIX(mat,i,j,1)*256 / max),ofp )",gm->name); closebrace(dfp); closebrace(dfp); close_function(dfp); } # line 547 "dynafunc.dy" void write_memory_macros(DYNFILE * dfp,GenericMatrix * gm) { register int i; for(i=0;ilen;i++) macro(dfp,"#define %s %d",gm->state[i]->name,i); add_break(dfp); for(i=0;ispec_len;i++) macro(dfp,"#define %s %d",gm->special[i]->name,i); add_break(dfp); macro(dfp,"#define %s_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+%d)*%d)+STATE][i+%d]",gm->name,gm->window_j,gm->len,gm->window_i); macro(dfp,"#define %s_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+%d]",gm->name,gm->window_j); macro(dfp,"#define %s_READ_OFF_ERROR -%d\n",gm->name,gm->window_i+gm->window_j+1); add_break(dfp); } # line 564 "dynafunc.dy" void write_search_macros(DYNFILE * dfp,const GenericMatrix * gm,DPImplementation * dpi) { if(gm->qtype != NULL && gm->qtype->maxlen != NULL) { macro(dfp,"#define %s_VSMALL_MATRIX(mat,i,j,STATE) internal_matrix[(j+%d)%%%d][((i+%d)*%d)+STATE]",gm->name,gm->window_j+1,gm->window_j+1,gm->window_i,gm->len); macro(dfp,"#define %s_VSMALL_SPECIAL(mat,i,j,STATE) internal_specials[(j+%d)%%%d][STATE]",gm->name,gm->window_j+1,gm->window_j+1); } else { if( dpi->largemem == TRUE ) { macro(dfp,"#define %s_VSMALL_MATRIX(mat,i,j,STATE) internal_pointer_db[((j+%d)%%%d * (mat->leni+%d) * %d) +((i+%d)*%d)+STATE]",gm->name,gm->window_j+1,gm->window_j+1,gm->window_i,gm->len,gm->window_i,gm->len); macro(dfp,"#define %s_VSMALL_SPECIAL(mat,i,j,STATE) internal_special_db[((j+%d)%%%d * %d)+ STATE]",gm->name,gm->window_j+1,gm->window_j+1,gm->spec_len); } else { macro(dfp,"#define %s_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+%d)%%%d][((i+%d)*%d)+STATE]",gm->name,gm->window_j+1,gm->window_j+1,gm->window_i,gm->len); macro(dfp,"#define %s_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+%d)%%%d][STATE]",gm->name,gm->window_j+1,gm->window_j+1); } } add_break(dfp); } # line 584 "dynafunc.dy" void write_expl_access_funcs(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"%s_explicit_access_main",gm->name); start_function_FuncInfo(fi,dfp,"int %s_explicit_access_main(%s * mat,int i,int j,int state)",gm->name,gm->name); expr(dfp,"return %s_EXPL_MATRIX(mat,i,j,state);",gm->name); close_function(dfp); add_break(dfp); fi = FuncInfo_named_from_varstr(FI_INTERNAL,"%s_explicit_access_special",gm->name); start_function_FuncInfo(fi,dfp,"int %s_explicit_access_special(%s * mat,int i,int j,int state)",gm->name,gm->name); expr(dfp,"return %s_EXPL_SPECIAL(mat,i,j,state);",gm->name); close_function(dfp); add_break(dfp); } # line 602 "dynafunc.dy" void write_expl_read_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"PackAln_read_Expl_%s",gm->name); add_line_to_Ftext(fi->ft,"Reads off PackAln from explicit matrix structure",gm->name); start_function_FuncInfo(fi,dfp,"PackAln * PackAln_read_Expl_%s(%s * mat)",gm->name,gm->name); expr(dfp,"%s_access_func_holder holder",gm->name); add_break(dfp); expr(dfp,"holder.access_main = %s_explicit_access_main;",gm->name); expr(dfp,"holder.access_special = %s_explicit_access_special;",gm->name); expr(dfp,"return PackAln_read_generic_%s(mat,holder);",gm->name); close_function(dfp); add_break(dfp); } # line 623 "dynafunc.dy" void write_basic_read_func(DYNFILE * dfp,GenericMatrix * gm) { register int i; register int st; FuncInfo * fi; for(i=0;ispec_len;i++) if( gm->special[i]->is_start == TRUE ) break; if( i >= gm->spec_len ) log_full_error(FATAL,0,"Cannot make matrix with no !start state (must be a special)"); st = i; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"PackAln_read_generic_%s",gm->name); add_line_to_Ftext(fi->ft,"Reads off PackAln from explicit matrix structure",gm->name); start_function_FuncInfo(fi,dfp,"PackAln * PackAln_read_generic_%s(%s * mat,%s_access_func_holder h)",gm->name,gm->name,gm->name); expr(dfp,"register PackAln * out;"); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int state;"); expr(dfp,"int cellscore = (-1);"); expr(dfp,"boolean isspecial"); expr(dfp,"PackAlnUnit * pau = NULL;"); expr(dfp,"PackAlnUnit * prev = NULL;"); add_break(dfp); expr(dfp,"assert(mat)"); expr(dfp,"assert(h.access_main)"); expr(dfp,"assert(h.access_special)"); add_break(dfp); expr(dfp,"out = PackAln_alloc_std()"); expr(dfp,"if( out == NULL )"); hang_expr(dfp,"return NULL;"); add_break(dfp); /*** Find the end of the matrix ***/ expr(dfp,"out->score = find_end_%s(mat,&i,&j,&state,&isspecial,h);",gm->name); add_break(dfp); add_block_comment(dfp,"Add final end transition (at the moment we have not got the score!"); expr(dfp,"if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE )"); startbrace(dfp); expr(dfp,"warn(\"Failed the first PackAlnUnit alloc, %%d length of Alignment in %s_basic_read, returning a mess.(Sorry!)\",out->len);",gm->name); expr(dfp,"return out;"); closebrace(dfp); add_break(dfp); /** put in numbers from block **/ add_block_comment(dfp,"Put in positions for end trans. Remember that coordinates in C style"); expr(dfp,"pau->i = i;"); expr(dfp,"pau->j = j;"); expr(dfp,"if( isspecial != TRUE) "); hang_expr(dfp,"pau->state = state;"); expr(dfp,"else pau->state = state + %d",gm->len); /*** expr(dfp,"pau->score = cellscore"); ***/ expr(dfp,"prev=pau;"); /**** do the loop ****/ /*** expr(dfp,"start_reporting(\"Alignment [Score %%d]:\",out->score);"); ***/ expr(dfp,"while( state != %s || isspecial != TRUE)",gm->special[st]->name); startbrace_tag(dfp,"while state != START"); add_break(dfp); expr(dfp,"if( isspecial == TRUE )"); hang_expr(dfp,"max_calc_special_%s(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h)",gm->name); expr(dfp,"else"); hang_expr(dfp,"max_calc_%s(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h)",gm->name); /*** check we haven't boobied ***/ expr(dfp,"if(i == %s_READ_OFF_ERROR || j == %s_READ_OFF_ERROR || state == %s_READ_OFF_ERROR )",gm->name,gm->name,gm->name); startbrace(dfp); expr(dfp,"warn(\"Problem - hit bad read off system, exiting now\");"); expr(dfp,"break;"); closebrace(dfp); /** allocate position **/ expr(dfp,"if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE )"); startbrace(dfp); expr(dfp,"warn(\"Failed a PackAlnUnit alloc, %%d length of Alignment in %s_basic_read, returning partial alignment\",out->len);",gm->name); expr(dfp,"break;"); closebrace(dfp); add_break(dfp); /** put in numbers from block **/ add_block_comment(dfp,"Put in positions for block. Remember that coordinates in C style"); expr(dfp,"pau->i = i;"); expr(dfp,"pau->j = j;"); expr(dfp,"if( isspecial != TRUE) "); hang_expr(dfp,"pau->state = state;"); expr(dfp,"else pau->state = state + %d",gm->len); expr(dfp,"prev->score = cellscore"); expr(dfp,"prev = pau;"); closebrace(dfp); /**** Add in alignment flips (or do I need to do that later!) ****/ add_break(dfp); /*** expr(dfp,"stop_reporting()"); ***/ expr(dfp,"invert_PackAln(out);"); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } # line 751 "dynafunc.dy" void write_pal_to_ars_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"AlnRangeSet_from_PackAln_%s",gm->name); add_line_to_Ftext(fi->ft,"Converts a PackAln (full alignment) to start/stop range"); add_line_to_Ftext(fi->ft,"The point being that you may have the PackAln and someone wants a range",gm->name); start_function_FuncInfo(fi,dfp,"AlnRangeSet * AlnRangeSet_from_PackAln_%s(PackAln * pal)",gm->name); expr(dfp,"int unit;"); expr(dfp,"int cum_score = 0;"); expr(dfp,"AlnRangeSet * out;"); expr(dfp,"AlnRange * temp;"); add_break(dfp); expr(dfp,"out = AlnRangeSet_alloc_std();"); expr(dfp,"for(unit = 0;unit < pal->len;unit++)"); startbrace_tag(dfp,"while there are more units"); expr(dfp,"cum_score += pal->pau[unit]->score;"); expr(dfp,"if( pal->pau[unit]->state < %d)",gm->len); startbrace(dfp); add_block_comment(dfp,"It is out of the specials"); expr(dfp,"temp = AlnRange_alloc();"); expr(dfp,"temp->starti = pal->pau[unit]->i;"); expr(dfp,"temp->startj = pal->pau[unit]->j;"); expr(dfp,"temp->startstate = pal->pau[unit]->state;"); expr(dfp,"temp->startscore = cum_score;"); expr(dfp,"for(;unit < pal->len && pal->pau[unit]->state < %d;unit++)",gm->len); hang_expr(dfp,"cum_score += pal->pau[unit]->score;"); expr(dfp,"temp->stopi = pal->pau[unit-1]->i;"); expr(dfp,"temp->stopj = pal->pau[unit-1]->j;"); expr(dfp,"temp->stopstate = pal->pau[unit-1]->state;"); expr(dfp,"temp->stopscore = cum_score;"); expr(dfp,"add_AlnRangeSet(out,temp)"); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"return out"); close_function(dfp); add_break(dfp); } # line 802 "dynafunc.dy" void write_alncconvert_make_func(DYNFILE * dfp,GenericMatrix * gm) { int i; int j; LabelMaster * lm; char * qs; char * ts; int qlabel; int tlabel; FuncInfo * fi; lm = LabelMaster_from_GenericMatrix(gm); qs = query_quoted_string_from_LabelMaster(lm); ts = target_quoted_string_from_LabelMaster(lm); expr(dfp," static char * query_label[] = { %s };",qs); expr(dfp," static char * target_label[] = { %s };",ts); ckfree(qs); ckfree(ts); fi = FuncInfo_named_from_varstr(FI_INTERNAL,"AlnConvertSet_%s",gm->name); start_function_FuncInfo(fi,dfp,"AlnConvertSet * AlnConvertSet_%s(void)",gm->name); expr(dfp,"AlnConvertUnit * acu;"); expr(dfp,"AlnConvertSet * out;"); add_break(dfp); expr(dfp,"out = AlnConvertSet_alloc_std();"); add_break(dfp); for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { qlabel = index_for_query_label(gm->state[i]->source[j]->query_label,lm); if( qlabel == (-1) ) { warn("Query label [%s] unfound. Consider this a bad compiler bug!",gm->state[i]->source[j]->query_label); qlabel = 0; } tlabel = index_for_target_label(gm->state[i]->source[j]->target_label,lm); if( tlabel == (-1) ) { warn("Query label [%s] unfound. Consider this a bad compiler bug!",gm->state[i]->source[j]->target_label); tlabel = 0; } expr(dfp,"acu = AlnConvertUnit_alloc();"); expr(dfp,"add_AlnConvertSet(out,acu);"); if( gm->state[i]->source[j]->isspecial == FALSE ) { expr(dfp,"acu->state1 = %s;",gm->state[i]->source[j]->state_source); } else { expr(dfp,"acu->state1 = %s + %d;",gm->state[i]->source[j]->state_source,gm->len); expr(dfp,"acu->is_from_special = TRUE;"); } expr(dfp,"acu->state2 = %s",gm->state[i]->name); if( gm->state[i]->source[j]->isspecial == FALSE ) expr(dfp,"acu->offi = %d;",gm->state[i]->source[j]->offi); else expr(dfp,"acu->offi = (-1);"); expr(dfp,"acu->offj = %d;",gm->state[i]->source[j]->offj); expr(dfp,"acu->label1 = query_label[%d];",qlabel); expr(dfp,"acu->label2 = target_label[%d];",tlabel); } } for(i=0;ispec_len;i++) { for(j=0;jspecial[i]->len;j++) { qlabel = index_for_query_label(gm->special[i]->source[j]->query_label,lm); if( qlabel == (-1) ) { warn("Query label [%s] unfound. Consider this a bad compiler bug!",gm->special[i]->source[j]->query_label); qlabel = 0; } tlabel = index_for_target_label(gm->special[i]->source[j]->target_label,lm); if( tlabel == (-1) ) { warn("Query label [%s] unfound. Consider this a bad compiler bug!",gm->special[i]->source[j]->target_label); tlabel = 0; } expr(dfp,"acu = AlnConvertUnit_alloc();"); expr(dfp,"add_AlnConvertSet(out,acu);"); if( gm->special[i]->source[j]->isspecial == FALSE ) expr(dfp,"acu->state1 = %s;",gm->special[i]->source[j]->state_source); else expr(dfp,"acu->state1 = %s + %d;",gm->special[i]->source[j]->state_source,gm->len); expr(dfp,"acu->state2 = %s + %d",gm->special[i]->name,gm->len); expr(dfp,"acu->offi = (-1);"); expr(dfp,"acu->offj = %d;",gm->special[i]->source[j]->offj); expr(dfp,"acu->label1 = query_label[%d];",qlabel); expr(dfp,"acu->label2 = target_label[%d];",tlabel); } } for(i=0;ical_len;i++) { expr(dfp,"add_collapse_label_AlnConvertSet(out,\"%s\",\"%s\");",gm->cal[i]->query,gm->cal[i]->target); } expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } # line 907 "dynafunc.dy" void write_aln_conversion_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"convert_PackAln_to_AlnBlock_%s",gm->name); add_line_to_Ftext(fi->ft,"Converts a path alignment to a label alignment"); add_line_to_Ftext(fi->ft,"The label alignment is probably much more useful than the path",gm->name); start_function_FuncInfo(fi,dfp,"AlnBlock * convert_PackAln_to_AlnBlock_%s(PackAln * pal)",gm->name,gm->name); expr(dfp,"AlnConvertSet * acs;"); expr(dfp,"AlnBlock * alb;"); add_break(dfp); expr(dfp,"acs = AlnConvertSet_%s();",gm->name); expr(dfp,"alb = AlnBlock_from_PackAln(acs,pal);"); expr(dfp,"free_AlnConvertSet(acs);"); expr(dfp,"return alb;"); close_function(dfp); add_break(dfp); } /* Function: init_matrix_func(dfp,gm) * * Descrip: init explicit matrix * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ # line 932 "dynafunc.dy" void init_matrix_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; ArgInfo * ai; register int i; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"init_%s",gm->name); add_line_to_Ftext(fi->ft,"This function initates %s matrix when in explicit mode",gm->name); add_line_to_Ftext(fi->ft,"Called in /allocate_Expl_%s",gm->name); /** ArgInfo_in_FuncInfo_from_varstr automatically adds ai to fi **/ ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); ai->desc=stringallocf("%s which contains explicit basematrix memory",gm->name); start_function_FuncInfo(fi,dfp,"void init_%s(%s * mat)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT)"); startbrace(dfp); warn_expr(dfp,"Cannot iniate matrix, is not an explicit memory type and you have assummed that"); expr(dfp,"return"); closebrace(dfp); add_break(dfp); expr(dfp,"for(i= (-%d);i%s->%s;i++)",gm->window_i,gm->query->name,gm->query_len); startbrace(dfp); expr(dfp,"for(j= (-%d);j<%d;j++)",gm->window_j,gm->window_j+1); startbrace(dfp); for(i=0;ilen;i++) { expr(dfp,"%s_EXPL_MATRIX(mat,i,j,%s) = %s;",gm->name,gm->state[i]->name,gm->state[i]->def_score); } closebrace(dfp); closebrace(dfp); expr(dfp,"for(j= (-%d);j%s->%s;j++)",gm->window_j,gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"for(i= (-%d);i<%d;i++)",gm->window_i,gm->window_i+1); startbrace(dfp); for(i=0;ilen;i++) { expr(dfp,"%s_EXPL_MATRIX(mat,i,j,%s) = %s;",gm->name,gm->state[i]->name,gm->state[i]->def_score); } closebrace(dfp); for(i=0;ispec_len;i++) { expr(dfp,"%s_EXPL_SPECIAL(mat,i,j,%s) = %s;",gm->name,gm->special[i]->name,gm->special[i]->def_score); } closebrace(dfp); expr(dfp,"return"); close_function(dfp); add_break(dfp); } # line 993 "dynafunc.dy" void find_end_func(DYNFILE * dfp,GenericMatrix * gm) { register int i; FuncInfo * fi; for(i=0;ispec_len;i++) if( gm->special[i]->is_end == TRUE) break; if( i >= gm->spec_len ) { log_full_error(WARNING,0,"Cannot build find end function due to lack of end state"); return; } fi = FuncInfo_named_from_varstr(FI_INTERNAL,"find_end_%s",gm->name); start_function_FuncInfo(fi,dfp,"int find_end_%s(%s * mat,int * ri,int * rj,int * state,boolean * isspecial,%s_access_func_holder h)",gm->name,gm->name,gm->name); expr(dfp,"int j"); expr(dfp,"int max;"); expr(dfp,"int maxj"); expr(dfp,"int temp"); add_break(dfp); expr(dfp,"max = (*h.access_special)(mat,0,mat->%s->%s-1,%s);",gm->target->name,gm->target_len,gm->special[i]->name); expr(dfp,"maxj = mat->%s->%s-1",gm->target->name,gm->target_len); expr(dfp,"for(j= mat->%s->%s-2 ;j >= 0 ;j--)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"if( (temp =(*h.access_special)(mat,0,j,%s)) > max )",gm->special[i]->name); startbrace(dfp); expr(dfp,"max = temp;"); expr(dfp,"maxj = j;"); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"if( ri != NULL)"); hang_expr(dfp," *ri = 0; "); expr(dfp,"if( rj != NULL)"); hang_expr(dfp," *rj = maxj; "); expr(dfp,"if( state != NULL)"); hang_expr(dfp," *state = %s;",gm->special[i]->name); expr(dfp,"if( isspecial != NULL)"); hang_expr(dfp," *isspecial = TRUE;"); add_break(dfp); expr(dfp,"return max"); close_function(dfp); add_break(dfp); } # line 1054 "dynafunc.dy" void debug_func(DYNFILE * dfp,GenericMatrix * gm) { register int i; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"%s_debug_show_matrix",gm->name); start_function_FuncInfo(fi,dfp,"void %s_debug_show_matrix(%s * mat,int starti,int stopi,int startj,int stopj,FILE * ofp)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); add_break(dfp); expr(dfp,"for(i=starti;i%s->%s;i++)",gm->query->name,gm->query_len); startbrace(dfp); expr(dfp,"for(j=startj;j%s->%s;j++)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"fprintf(ofp,\"Cell [%%d - %%d]\\n\",i,j)"); for(i=0;ilen;i++) expr(dfp,"fprintf(ofp,\"State %s %%d\\n\",%s_EXPL_MATRIX(mat,i,j,%s));",gm->state[i]->name,gm->name,gm->state[i]->name); expr(dfp,"fprintf(ofp,\"\\n\\n\");"); closebrace(dfp); closebrace(dfp); add_break(dfp); close_function(dfp); add_break(dfp); return; } # line 1085 "dynafunc.dy" void write_special_max_calc_func_debug(DYNFILE * dfp,GenericMatrix * gm,int debug) { register int i; register int j; FuncInfo * fi; char * matrix_tag = "EXPL_MATRIX"; char * special_tag = "EXPL_SPECIAL"; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"max_calc_special_%s",gm->name); start_function_FuncInfo(fi,dfp,"int max_calc_special_%s(%s * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,%s_access_func_holder h)",gm->name,gm->name,gm->name); expr(dfp,"register int temp;"); expr(dfp,"register int cscore;"); add_break(dfp); expr(dfp,"*reti = (*retj) = (*retstate) = %s_READ_OFF_ERROR;",gm->name); add_break(dfp); expr(dfp,"if( j < 0 || j > mat->%s->%s)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"warn(\"In %s matrix special read off - out of bounds on matrix [j is %%d in special]\",j);",gm->name); expr(dfp,"return -1"); closebrace(dfp); add_break(dfp); expr(dfp,"cscore = (*h.access_special)(mat,i,j,state);"); if( debug) expr(dfp,"fprintf(stderr,\"Looking for score %%d\\n\",cscore);"); expr(dfp,"switch(state)"); startbrace_tag(dfp,"switch on special states"); for(i=0;ispec_len;i++) { auto CellState * cell; cell = gm->special[i]; expr(dfp,"case %s : ",cell->name); startcase(dfp); /*** ok, this is a problem. probably should do special to special first, ***/ /*** the others. Hmmm.,.. ***/ for(j=cell->len-1;j>=0;j--) { if( cell->source[j]->isspecial == FALSE ) { add_block_comment(dfp,"source %s is from main matrix",cell->source[j]->state_source); expr(dfp,"for(i= mat->%s->%s-1;i >= 0 ;i--)",gm->query->name,gm->query_len); startbrace_tag(dfp,"for i >= 0"); expr(dfp,"temp = cscore - (%s) - (%s)",cell->source[j]->calc_expr, cell->calc_expr == NULL ? "0" : cell->calc_expr); if( debug ) expr(dfp,"fprintf(stderr,\"Trying %%d for case %s\\n\",temp)",cell->source[j]->state_source); expr(dfp,"if( temp == (*h.access_main)(mat,i - %d,j - %d,%s) )",cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); startbrace(dfp); expr(dfp,"*reti = i - %d;",cell->source[j]->offi); expr(dfp,"*retj = j - %d;",cell->source[j]->offj); expr(dfp,"*retstate = %s;",cell->source[j]->state_source); if( cell->source[j]->isspecial == TRUE) expr(dfp,"*retspecial = TRUE;"); else expr(dfp,"*retspecial = FALSE;"); /*** if they want the score, calc the difference in the number and give it back ***/ expr(dfp,"if( cellscore != NULL)"); startbrace(dfp); expr(dfp,"*cellscore = cscore - (*h.access_main)(mat,i-%d,j-%d,%s)",cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); expr(dfp,"return (*h.access_main)(mat,i - %d,j - %d,%s) ",cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); closebrace(dfp); /** this closes the for brace ***/ } else { add_block_comment(dfp,"source %s is a special",cell->source[j]->state_source); expr(dfp,"temp = cscore - (%s) - (%s)",cell->source[j]->calc_expr, cell->calc_expr == NULL ? "0" : cell->calc_expr); if( debug ) expr(dfp,"fprintf(stderr,\"Trying %%d for case %s\\n\",temp)",cell->source[j]->state_source); expr(dfp,"if( temp == (*h.access_special)(mat,i - %d,j - %d,%s) )",cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); startbrace(dfp); expr(dfp,"*reti = i - %d;",cell->source[j]->offi); expr(dfp,"*retj = j - %d;",cell->source[j]->offj); expr(dfp,"*retstate = %s;",cell->source[j]->state_source); if( cell->source[j]->isspecial == TRUE) expr(dfp,"*retspecial = TRUE;"); else expr(dfp,"*retspecial = FALSE;"); /*** if they want the score, calc the difference in the number and give it back ***/ expr(dfp,"if( cellscore != NULL)"); startbrace(dfp); expr(dfp,"*cellscore = cscore - (*h.access_special)(mat,i-%d,j-%d,%s)",cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); expr(dfp,"return (*h.access_special)(mat,i - %d,j - %d,%s) ",cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); } } closecase(dfp); } expr(dfp,"default:"); startcase(dfp); expr(dfp,"warn(\"Major problem (!) - in %s read off, position %%d,%%d state %%d no source found dropped into default on source switch!\",i,j,state);",gm->name); expr(dfp,"return (-1);"); closecase(dfp); closebrace(dfp); close_function(dfp); add_break(dfp); } # line 1225 "dynafunc.dy" void write_special_max_calc_func(DYNFILE * dfp,GenericMatrix * gm) { write_special_max_calc_func_debug(dfp,gm,0); } /**** This function requires alot of stuff assummed. int * reti, int *retj and *retstate *retspecial as parameters which will be set by this block. This block is really to facillate different underlying memory structures which can be used. Please see functions write_max_calc_func and write_hidden_max_func (dynashadow.dy) to see how it is used ***/ # line 1244 "dynafunc.dy" void write_max_calc_block(DYNFILE * dfp,GenericMatrix * gm,char * matrix_tag,char * special_tag,boolean use_special,boolean use_holder) { register int i; register int j; char matrix_access[128]; char special_access[128]; if( use_holder == TRUE ) { sprintf(matrix_access,"(*h.access_main)"); sprintf(special_access,"(*h.access_special)"); } else { sprintf(matrix_access,"%s_%s",gm->name,matrix_tag); sprintf(special_access,"%s_%s",gm->name,special_tag); } add_break(dfp); add_block_comment(dfp,"Then you have to select the correct switch statement to figure out the readoff "); add_block_comment(dfp,"Somewhat odd - reverse the order of calculation and return as soon as it is correct"); expr(dfp,"cscore = %s(mat,i,j,state);",matrix_access); expr(dfp,"switch(state)"); startbrace_tag(dfp,"Switch state "); for(i=0;ilen;i++) { auto CellState * cell; cell = gm->state[i]; expr(dfp,"case %s : ",cell->name); startcase(dfp); for(j=cell->len-1;j>=0;j--) { if( use_special == FALSE && cell->source[j]->isspecial == TRUE ) { add_block_comment(dfp,"Not allowing special sources.. skipping %s",cell->source[j]->state_source); continue; } if( cell->source[j]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(cell->source[j]->position,cell->source[j]->offi,cell->source[j]->offj)); startbrace(dfp); } expr(dfp,"temp = cscore - (%s) - (%s);",cell->source[j]->calc_expr, cell->calc_expr == NULL ? "0" : cell->calc_expr); if( cell->source[j]->isspecial == TRUE) expr(dfp,"if( temp == %s(mat,i - %d,j - %d,%s) )",special_access,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); else expr(dfp,"if( temp == %s(mat,i - %d,j - %d,%s) )",matrix_access,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); startbrace(dfp); expr(dfp,"*reti = i - %d;",cell->source[j]->offi); expr(dfp,"*retj = j - %d;",cell->source[j]->offj); expr(dfp,"*retstate = %s;",cell->source[j]->state_source); if( cell->source[j]->isspecial == TRUE) expr(dfp,"*retspecial = TRUE;"); else expr(dfp,"*retspecial = FALSE;"); /*** if they want the score, calc the difference in the number and give it back ***/ expr(dfp,"if( cellscore != NULL)"); startbrace(dfp); expr(dfp,"*cellscore = cscore - %s(mat,i-%d,j-%d,%s);", cell->source[j]->isspecial == TRUE ? special_access : matrix_access,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); expr(dfp,"return %s(mat,i - %d,j - %d,%s); ",matrix_access,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); if( cell->source[j]->position != SOURCE_POS_ALL) { closebrace(dfp); } closebrace(dfp); } expr(dfp,"warn(\"Major problem (!) - in %s read off, position %%d,%%d state %%d no source found!\",i,j,state);",gm->name); expr(dfp,"return (-1);"); closecase(dfp); } expr(dfp,"default:"); startcase(dfp); expr(dfp,"warn(\"Major problem (!) - in %s read off, position %%d,%%d state %%d no source found!\",i,j,state);",gm->name); expr(dfp,"return (-1);"); closecase(dfp); closebrace(dfp); } # line 1340 "dynafunc.dy" void write_max_calc_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"max_calc_%s",gm->name); start_function_FuncInfo(fi,dfp,"int max_calc_%s(%s * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,%s_access_func_holder h)",gm->name,gm->name,gm->name); expr(dfp,"register int temp;"); expr(dfp,"register int cscore;"); add_break(dfp); expr(dfp,"*reti = (*retj) = (*retstate) = %s_READ_OFF_ERROR;",gm->name); add_break(dfp); expr(dfp,"if( i < 0 || j < 0 || i > mat->%s->%s || j > mat->%s->%s)",gm->query->name, gm->query_len,gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"warn(\"In %s matrix special read off - out of bounds on matrix [i,j is %%d,%%d state %%d in standard matrix]\",i,j,state);",gm->name); expr(dfp,"return -1"); closebrace(dfp); write_max_calc_block(dfp,gm,"EXPL_MATRIX","EXPL_SPECIAL",TRUE,TRUE); close_function(dfp); add_break(dfp); return; } static char source_buffer[125]; # line 1377 "dynafunc.dy" char * source_allowed_statement(int position,int offi,int offj) { switch(position) { case SOURCE_POS_ALL : warn("Bad point in source to - you have an ALL source positions. Hmmmmm"); return "1"; case SOURCE_POS_TOPLEFT : sprintf(source_buffer,"(i-%d) == 0 && (j-%d) == 0",offi,offj); return source_buffer; case SOURCE_POS_TOP : sprintf(source_buffer,"(i-%d) == 0 ",offi); return source_buffer; case SOURCE_POS_LEFT : sprintf(source_buffer,"(j-%d) == 0 ",offj); return source_buffer; case SOURCE_POS_RIGHT : return "j == mat->lenj-1"; case SOURCE_POS_BOTTOM : return "i == mat->leni-1"; case SOURCE_POS_BOTTOMRIGHT : return "i == mat->leni-1 && j == mat->lenj-1"; default : warn("Bad error, got an impossible source position %d",position); return("1"); } } # line 1406 "dynafunc.dy" void write_score_block_debug(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointertag,char * specialtag,boolean use_special,int debug) { register int i; register int j; register int k; for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; add_break(dfp); if( state->footprint_start > 1 || state->footprint_end < 0) { add_block_comment(dfp,"State %s has a footprint of %d - %d",state->name,state->footprint_start,state->footprint_end); expr(dfp,"if( SEQENDWITHIN(%d) != TRUE || SEQSTARTWITHIN(%d) != TRUE )",state->footprint_end,state->footprint_start); startbrace_tag(dfp,"Footprint exists"); } add_block_comment(dfp,"For state %s",state->name); add_block_comment(dfp,"setting first movement to score",state->name); if( state->source[0]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(state->source[0]->position,state->source[0]->offi,state->source[0]->offj)); startbrace(dfp); } /*********************************************************************/ /* this line looks like */ /* score = ProteinMatrix_EXPL_MATRIX(mat,i-1,j-1,MATCH) + xxxxx */ /*********************************************************************/ expr(dfp,"score = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,matrixtag,pointertag, state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source, state->source[0]->calc_expr); if( state->source[0]->isspecial == TRUE ) { fatal("Cannot have a special to matrix transition as the first transition"); } if( state->source[0]->position != SOURCE_POS_ALL) { closebrace(dfp); } if( dfp->code_debug_level > 5) { expr(dfp,"if( score > IMPOSSIBLY_HIGH_SCORE )"); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] State %s source %s Impossibly high score [%%d]\",i,j,score);",state->name,state->source[0]->state_source); } if( dfp->code_debug_level > 100 ) { expr(dfp,"fprintf(stderr,\"MATRIX: [%%4d][%%4d] State %s source %s got score %%d\\n\",i,j,score);",state->name,state->source[0]->state_source); } /**** ok this is to stop underflow, but is v.v.v. hacky ****/ /*** removing underflow hack expr(dfp,"if(score < (-10000000) )"); hang_expr(dfp,"score = (-10000000)"); ****/ if( debug == 2) expr(dfp,"fprintf(stderr,\"[%%4d,%%4d] First score of %s gets %%d\\n\",i,j,score)",state->name); /****************************************/ /* now we do if then on score and temp */ /****************************************/ for(j=1;jlen;j++) { if( use_special == FALSE && state->source[j]->isspecial == TRUE ) continue; /** don't use the special! **/ if( state->source[j]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(state->source[j]->position,state->source[j]->offi,state->source[j]->offj)); startbrace(dfp); } add_block_comment(dfp,"From state %s to state %s",state->source[j]->state_source, state->name); if( state->source[j]->isspecial == TRUE ) expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,specialtag,pointertag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr); else expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,matrixtag,pointertag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr); if( dfp->code_debug_level > 5) { expr(dfp,"if( temp > IMPOSSIBLY_HIGH_SCORE )"); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] State %s source %s Impossibly high score [%%d]\",i,j,temp);",state->name,state->source[j]->state_source); } if( dfp->code_debug_level > 100 ) { expr(dfp,"fprintf(stderr,\"MATRIX: [%%4d][%%4d] State %s source %s got score %%d\\n\",i,j,temp);",state->name,state->source[0]->state_source); } /**** ok this is to stop underflow, but is v.v.v. hacky ****/ /**** removing underflow hack expr(dfp,"if(score < (-10000000) )"); hang_expr(dfp,"score = (-10000000)"); ****/ if( debug == 2 ) expr(dfp,"fprintf(stderr,\"[%%4d,%%4d] Score of %s from %s gets %%d\\n\",i,j,temp)",state->name,state->source[j]->state_source ); /** if we have a specified calcfunc - use it here **/ if(gm->calcfunc != NULL ) { expr(dfp,"score = %s(score,temp);",gm->calcfunc); } else{ expr(dfp,"if( temp > score )"); startbrace(dfp); expr(dfp,"score = temp;"); /** ok for shadow matrix should put things in here */ closebrace(dfp); } if( state->source[j]->position != SOURCE_POS_ALL) { closebrace(dfp); } } /************************/ /* finished blocks */ /* put in global calc */ /************************/ add_break(dfp); add_block_comment(dfp,"Ok - finished max calculation for %s",state->name); add_block_comment(dfp,"Add any movement independant score and put away"); if( state->calc_expr != NULL) expr(dfp," score += %s",state->calc_expr); /***************************/ /* put away score */ /***************************/ expr(dfp," %s_%s(%s,i,j,%s) = score;",gm->name,matrixtag,pointertag,state->name); if( use_special == FALSE ) { add_block_comment(dfp,"Finished calculating state %s",state->name); continue; } /************************/ /* for each special */ /* thats has this as */ /* source we have to */ /* update */ /************************/ for(j=0;jspec_len;j++) { auto CellState * specstate; specstate = gm->special[j]; for(k=0;klen;k++) { if( strcmp(specstate->source[k]->state_source,state->name) == 0) { /********************************/ /* is a special source! */ /********************************/ add_break(dfp); add_block_comment(dfp,"state %s is a source for special %s",state->name,specstate->name); if( specstate->source[k]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(specstate->source[k]->position,specstate->source[k]->offi,specstate->source[k]->offj)); startbrace(dfp); } expr(dfp,"temp = score + (%s) + (%s) ",specstate->source[k]->calc_expr,specstate->calc_expr == NULL ? "0" : specstate->calc_expr ); if(gm->calcfunc != NULL ) { expr(dfp,"%s_%s(%s,i,j,%s) = %s(%s_%s(%s,i,j,%s),temp);", gm->name,specialtag,pointertag,specstate->name, gm->calcfunc, gm->name,specialtag,pointertag,specstate->name); } else{ expr(dfp,"if( temp > %s_%s(%s,i,j,%s) ) ",gm->name,specialtag,pointertag,specstate->name); startbrace(dfp); expr(dfp,"%s_%s(%s,i,j,%s) = temp",gm->name,specialtag,pointertag,specstate->name); if( debug >= 1 ) expr(dfp,"fprintf(stderr,\"[%%4d,%%4d] new score of %s is %%d\\n\",i,j,temp)",state->name); closebrace(dfp); add_break(dfp); } if( specstate->source[k]->position != SOURCE_POS_ALL) { closebrace(dfp); } } /* end of if this special state was a source for previous guy */ } /* end for each source of the special state */ if( dfp->code_debug_level > 4) { expr(dfp,"if( %s_%s(mat,0,j,%s) > IMPOSSIBLY_HIGH_SCORE )",gm->name,specialtag,specstate->name); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] Special state %s Impossibly high score [%%d] found\",i,j,%s_%s(mat,0,j,%s));",specstate->name,gm->name,specialtag,specstate->name); } } /* end for each special state */ if( state->footprint_start < 0 || state->footprint_end > 1 ) { closebrace(dfp); } add_break(dfp); add_block_comment(dfp,"Finished calculating state %s",state->name); } /* end of for each state */ } # line 1649 "dynafunc.dy" void write_score_block(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointertag,char * specialtag,boolean use_special) { write_score_block_debug(dfp,gm,matrixtag,pointertag,specialtag,use_special,0); } /* Function: matrix_calculate_func(dfp,gm) * * Descrip: makes calculate_xxx functions, which * is for explicit matrix implementations * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ # line 1659 "dynafunc.dy" void matrix_calculate_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; ArgInfo * ai; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"calculate_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates the %s matrix when in explicit mode",gm->name); add_line_to_Ftext(fi->ft,"To allocate the matrix use /allocate_Expl_%s",gm->name); /** ArgInfo_in_FuncInfo_from_varstr automatically adds ai to fi **/ ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); ai->desc=stringallocf("%s which contains explicit basematrix memory",gm->name); start_function_FuncInfo(fi,dfp,"boolean calculate_%s(%s * mat)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int tot;"); expr(dfp,"int num;"); add_break(dfp); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT )"); startbrace(dfp); warn_expr(dfp,"in calculate_%s, passed a non Explicit matrix type, cannot calculate!",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); expr(dfp,"leni = mat->leni;"); expr(dfp,"lenj = mat->lenj;"); /*** make num and tot ***/ expr(dfp,"tot = leni * lenj;"); expr(dfp,"num = 0;"); /*** see if there any specials to specials to do ***/ add_break(dfp); expr(dfp,"start_reporting(\"%s Matrix calculation: \");",gm->name); expr(dfp,"for(j=0;jname); **/ expr(dfp,"num++;"); write_score_block(dfp,gm,"EXPL_MATRIX","mat","EXPL_SPECIAL",TRUE); closebrace(dfp); /**** if there are any specials do them here ****/ write_special_block(dfp,gm,"EXPL_MATRIX","EXPL_SPECIAL",NULL); closebrace(dfp); /*** stop reporting ***/ expr(dfp,"stop_reporting()"); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } /* Function: matrix_calculate_func_dpenv(dfp,gm) * * Descrip: makes calculate_xxx functions, which * is for explicit matrix implementations * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ # line 1748 "dynafunc.dy" void matrix_calculate_func_dpenv(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; ArgInfo * ai; int i; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"calculate_dpenv_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates the %s matrix when in explicit mode, subject to the envelope",gm->name); /** ArgInfo_in_FuncInfo_from_varstr automatically adds ai to fi **/ ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); ai->desc=stringallocf("%s which contains explicit basematrix memory",gm->name); start_function_FuncInfo(fi,dfp,"boolean calculate_dpenv_%s(%s * mat,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"int starti;"); expr(dfp,"int startj;"); expr(dfp,"int endi;"); expr(dfp,"int endj;"); expr(dfp,"int tot;"); expr(dfp,"int num;"); expr(dfp,"int should_calc;"); add_break(dfp); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT )"); startbrace(dfp); warn_expr(dfp,"in calculate_%s, passed a non Explicit matrix type, cannot calculate!",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); /*** make num and tot ***/ expr(dfp,"prepare_DPEnvelope(dpenv)"); expr(dfp,"starti = dpenv->starti"); expr(dfp,"if( starti < 0 )"); hang_expr(dfp,"starti = 0"); expr(dfp,"startj = dpenv->startj"); expr(dfp,"if( startj < 0 )"); hang_expr(dfp,"startj = 0"); expr(dfp,"endi = dpenv->endi"); expr(dfp,"if( endi > mat->leni )"); hang_expr(dfp,"endi = mat->leni"); expr(dfp,"endj = dpenv->endj"); expr(dfp,"if( endj > mat->lenj )"); hang_expr(dfp,"endj = mat->lenj"); expr(dfp,"tot = (endi-starti) * (endj-startj);"); expr(dfp,"num = 0;"); add_break(dfp); expr(dfp,"for(j=startj-%d;jwindow_j); startbrace(dfp); expr(dfp,"for(i=%d;ileni;i++)",gm->window_i); startbrace(dfp); for(i=0;ilen;i++) { expr(dfp,"%s_EXPL_MATRIX(mat,i,j,%s) = %s;",gm->name,gm->state[i]->name,gm->state[i]->def_score); } closebrace(dfp); closebrace(dfp); expr(dfp,"for(j=-%d;jlenj;j++)",gm->window_j); startbrace(dfp); for(i=0;ispec_len;i++) { expr(dfp,"%s_EXPL_SPECIAL(mat,i,j,%s) = %s;",gm->name,gm->special[i]->name,gm->special[i]->def_score); } closebrace(dfp); /*** see if there any specials to specials to do ***/ add_break(dfp); expr(dfp,"start_reporting(\"%s Matrix calculation: \");",gm->name); expr(dfp,"for(j=startj;jlen;k++)"); startbrace(dfp); expr(dfp,"auto DPUnit * u;"); expr(dfp,"u = dpenv->dpu[k];"); expr(dfp,"switch(u->type)"); startbrace(dfp); expr(dfp,"case DPENV_RECT :"); startcase(dfp); expr(dfp,"if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length))"); hang_expr(dfp,"should_calc = 1"); expr(dfp,"break;"); closecase(dfp); expr(dfp,"case DPENV_DIAG :"); startcase(dfp); expr(dfp,"if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj)"); hang_expr(dfp,"should_calc = 1"); expr(dfp,"break;"); closecase(dfp); closebrace(dfp); expr(dfp,"if( should_calc == 1 )"); hang_expr(dfp,"break;"); closebrace(dfp); expr(dfp,"if( should_calc == 0)"); startbrace(dfp); for(i=0;ilen;i++) { expr(dfp,"%s_EXPL_MATRIX(mat,i,j,%s) = %s;",gm->name,gm->state[i]->name,gm->state[i]->def_score); } expr(dfp,"continue;"); closebrace(dfp); add_break(dfp); expr(dfp,"if( num%%1000 == 0 )"); hang_expr(dfp,"log_full_error(REPORT,0,\"[%%7d] Cells %%2d%%%%%%%%\",num,num*100/tot);"); /** expr(dfp,"(void) do_cell_%s(mat,i,j)",gm->name); **/ expr(dfp,"num++;"); write_score_block(dfp,gm,"EXPL_MATRIX","mat","EXPL_SPECIAL",TRUE); closebrace(dfp); /**** if there are any specials do them here ****/ write_special_block(dfp,gm,"EXPL_MATRIX","EXPL_SPECIAL",NULL); closebrace(dfp); /*** stop reporting ***/ expr(dfp,"stop_reporting()"); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } # line 1911 "dynafunc.dy" void do_special_function(DYNFILE * dfp,GenericMatrix * gm) { if( gm->specialtospecial == FALSE ) { warn("Cannot make special cell function if no special to special use"); return; } start_function(dfp,"void do_special_cells_%s(%s * mat,int j)",gm->name,gm->name); expr(dfp,"register int score"); expr(dfp,"register int temp"); write_special_block(dfp,gm,"EXPL_MATRIX","EXPL_SPECIAL",NULL); add_break(dfp); add_break(dfp); expr(dfp,"return;"); close_function(dfp); add_break(dfp); } /* Function: do_cell_function(dfp,gm) * * Descrip: useful function for debugging, but not * currently used * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ # line 1939 "dynafunc.dy" void do_cell_function(DYNFILE * dfp,GenericMatrix * gm) { start_function(dfp,"int do_cell_%s(%s * mat,int i,int j)",gm->name,gm->name); expr(dfp,"register int score;"); expr(dfp,"register int temp;"); expr(dfp,"register int state;"); write_score_block(dfp,gm,"EXPL_MATRIX","mat","EXPL_SPECIAL",TRUE); expr(dfp,"return 0"); close_function(dfp); add_break(dfp); } /* Function: write_special_block(dfp,gm,matrix,special,bestscore) * * Descrip: This writes the special to special block movements, if needed. * * If bestscore is not NULL, it assummes that this is the name of * an int variable which should hold the bestscore by updating * from the end state * * * Arg: dfp [UNKN ] dynfile output [DYNFILE *] * Arg: gm [READ ] matrix structure [GenericMatrix *] * Arg: matrix [READ ] name of main matrix tag eg EXPL_MATRIX [char *] * Arg: special [READ ] name of special tag eg EXPL_SPECIAL [char *] * Arg: bestscore [READ ] if not NULL, name of scoped variable for updating bestscore [char *] * */ # line 1971 "dynafunc.dy" void write_special_block(DYNFILE * dfp,GenericMatrix * gm,char * matrix,char * special,char * bestscore) { register int i; register int j; for(i=0;ispec_len;i++) { auto CellState * state; state = gm->special[i]; add_break(dfp); if( state->specialtospecial == FALSE ) { add_block_comment(dfp,"Special state %s has no special to special movements",state->name); continue; } add_block_comment(dfp,"Special state %s has special to speical",state->name); add_block_comment(dfp,"Set score to current score (remember, state probably updated during main loop"); expr(dfp,"score = %s_%s(mat,0,j,%s);",gm->name,special,state->name); add_break(dfp); for(j=0;j < state->len;j++) { auto CellSource * source; source = state->source[j]; if( source->isspecial == FALSE ) { add_block_comment(dfp,"Source %s for state %s is not special... already calculated",source->state_source,state->name); continue; /** back to for j **/ } add_block_comment(dfp,"Source %s is a special source for %s",source->state_source,state->name); if( state->source[j]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(state->source[j]->position,state->source[j]->offi,state->source[j]->offj)); startbrace(dfp); } expr(dfp,"temp = %s_%s(mat,0,j - %d,%s) + (%s) + (%s)",gm->name,special,source->offj,source->state_source, source->calc_expr,state->calc_expr == NULL ? "0" : state->calc_expr); if( gm->calcfunc != NULL ) { expr(dfp,"score = %s(score,temp);",gm->calcfunc); } else { expr(dfp,"if( temp > score )"); hang_expr(dfp,"score = temp"); } if( state->source[j]->position != SOURCE_POS_ALL) { closebrace(dfp); } add_break(dfp); } add_block_comment(dfp,"Put back score... (now updated!)"); expr(dfp,"%s_%s(mat,0,j,%s) = score;",gm->name,special,state->name); add_block_comment(dfp,"Finished updating state %s",state->name); add_break(dfp); if( dfp->code_debug_level > 5) { expr(dfp,"if( score > IMPOSSIBLY_HIGH_SCORE )"); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] Special state %s Impossibly high score [%%d] found\",i,j,score);",state->name); } } /* if( bestscore == NULL && gm->calcfunc == NULL ) return; */ /** ok - update of endscore stuff **/ for(i=0;ispec_len;i++) { auto CellState * state; state = gm->special[i]; if( state->is_end == TRUE ) { if( bestscore == NULL ) { /* means we have a calc func with no bestscore */ /*expr(dfp,"%s_%s(mat,0,j,%s) = %s(%s_%s(mat,0,j,%s),%s_%s(mat,0,j-1,%s));",gm->name,special,state->name,gm->calcfunc,gm->name,special,state->name,gm->name,special,state->name);*/ } else { /* we are in a database search routine */ if( gm->calcfunc != NULL ) { expr(dfp,"bestscore = %s(bestscore,%s_%s(mat,0,j,%s));",gm->calcfunc,gm->name,special,state->name); } else { expr(dfp,"if( bestscore < %s_%s(mat,0,j,%s) )",gm->name,special,state->name); hang_expr(dfp,"bestscore = %s_%s(mat,0,j,%s)",gm->name,special,state->name); } } break; } } } # line 2068 "dynafunc.dy" void write_search_distributor_func(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { int i; char buffer[MAXLINE]; FuncInfo * fi; boolean qdb = FALSE; boolean tdb = FALSE; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"search_%s",gm->name); add_line_to_Ftext(fi->ft,"This function makes a database search of %s",gm->name); add_line_to_Ftext(fi->ft,"It uses the dbsi structure to choose which implementation"); add_line_to_Ftext(fi->ft,"to use of the database searching. This way at run time you"); add_line_to_Ftext(fi->ft,"can switch between single threaded/multi-threaded or hardware"); if( gm->qtype != NULL && gm->qtype->is_database == TRUE) qdb = TRUE; if( gm->ttype != NULL && gm->ttype->is_database == TRUE) tdb = TRUE; if( qdb == TRUE) sprintf(buffer,"Search_Return_Type search_%s(DBSearchImpl * dbsi,Hscore * out,%s querydb,",gm->name,gm->qtype->database_type); else sprintf(buffer,"Search_Return_Type search_%s(DBSearchImpl * dbsi,Hscore * out,%s %s,",gm->name,gm->query->element_type,gm->query->name); if( tdb == TRUE) { strcat(buffer,gm->ttype->database_type); strcat(buffer," targetdb "); } else { strcat(buffer,gm->target->element_type); strcat(buffer," "); strcat(buffer,gm->target->name); strcat(buffer," "); } for(i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,gm->resource[i]->element_type); strcat(buffer," "); strcat(buffer,gm->resource[i]->name); } strcat(buffer,")"); start_function_FuncInfo(fi,dfp,buffer); if( dpi->do_threads == TRUE && can_do_threads(gm) == TRUE ) { macro(dfp,"#ifdef PTHREAD"); expr(dfp,"int i;"); expr(dfp,"int thr_no;"); expr(dfp,"pthread_attr_t pat;"); expr(dfp,"struct thread_pool_holder_%s * holder",gm->name); macro(dfp,"#endif"); } expr(dfp,"if( out == NULL )"); startbrace(dfp); warn_expr(dfp,"Passed in a null Hscore object into search_%s. Can't process results!",gm->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); expr(dfp,"if( dbsi == NULL )"); startbrace(dfp); warn_expr(dfp,"Passed in a null DBSearchImpl object into search_%s. Can't process results!",gm->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); if( dpi->db_trace_level == 0 ) { expr(dfp,"if( dbsi->trace_level > 0 ) "); hang_expr(dfp,"warn(\"Although you are asking at run-time for database tracing, the %s matrix was not compiled with database tracing. No tracing will be made\");",gm->name); } else { expr(dfp,"if( dbsi->trace_level > %d ) ",dpi->db_trace_level); hang_expr(dfp,"warn(\"Asking for trace level of %%d in database search for %s, but it was compiled with a trace level of %d. Not all trace statements can be shown\",dbsi->trace_level);",gm->name); } /* now to figure out what implementations should be run! */ expr(dfp,"switch(dbsi->type)"); startbrace_tag(dfp,"switch on implementation"); expr(dfp,"case DBSearchImpl_Serial :"); startcase(dfp); if( qdb == TRUE) sprintf(buffer,"return serial_search_%s(out,querydb,",gm->name); else sprintf(buffer,"return serial_search_%s(out,%s,",gm->name,gm->query->name); if( tdb == TRUE) { strcat(buffer," targetdb "); } else { strcat(buffer,gm->target->name); strcat(buffer," "); } for(i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,gm->resource[i]->name); } strcat(buffer,");"); expr(dfp,buffer); closecase(dfp); expr(dfp,"case DBSearchImpl_Pthreads :"); startcase(dfp); if( dpi->do_threads == TRUE && can_do_threads(gm) == TRUE ) { macro(dfp,"#ifdef PTHREAD"); expr(dfp,"holder = (struct thread_pool_holder_%s *) ckalloc(sizeof(struct thread_pool_holder_%s));",gm->name,gm->name); expr(dfp,"if( holder == NULL ) "); startbrace(dfp); warn_expr(dfp,"Unable to allocated thread pool datastructure..."); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); expr(dfp,"holder->out = out;"); if( dpi->db_trace_level > 0 ) expr(dfp,"holder->dbsi = dbsi;"); if( qdb == TRUE ) { expr(dfp,"holder->querydb = querydb;"); } else { expr(dfp,"holder->%s = %s;",gm->query->name,gm->query->name); } if( tdb == TRUE ) { expr(dfp,"holder->targetdb = targetdb;"); } else { expr(dfp,"holder->%s = %s;",gm->target->name,gm->target->name); } for(i=0;ires_len;i++) { expr(dfp,"holder->%s = %s;",gm->resource[i]->name,gm->resource[i]->name); } expr(dfp,"if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) "); expr(dfp,"fatal(\"Unable to iniated input mutex lock\");"); expr(dfp,"if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) "); expr(dfp,"fatal(\"Unable to iniated output mutex lock\");"); add_block_comment(dfp,"Let us rock!"); expr(dfp,"thr_no = number_of_threads_DBSearchImpl(dbsi);"); expr(dfp,"holder->pool = ckcalloc (thr_no,sizeof(pthread_t));"); expr(dfp,"if( holder->pool == NULL ) "); startbrace(dfp); warn_expr(dfp,"Unable to allocated thread pools"); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); add_block_comment(dfp,"Build a thread attribute to make sure we get the most out of SMP boxes"); expr(dfp,"pthread_attr_init(&pat)"); add_block_comment(dfp,"Give thread libraries a hint that threads should be kernel threads"); macro(dfp,"#ifndef __sgi /* SGI can't set system scope ... */"); macro(dfp,"#ifdef HAS_PTHREAD_SETSCOPE"); expr(dfp,"pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM);"); macro(dfp,"#endif /* set scope */"); macro(dfp,"#endif /* sgi */"); add_block_comment(dfp,"Give thread libraries a hint that there are num of threads to run"); macro(dfp,"#ifdef HAS_PTHREAD_SETCONCURRENCY"); expr(dfp,"pthread_setconcurrency(thr_no+1);"); macro(dfp,"#endif /* set concurrency */"); expr(dfp,"for(i=0;ipool+i,&pat,thread_loop_%s,(void *)holder) )",gm->name); hang_expr(dfp,"fatal(\"Unable to create a thread!\");"); closebrace(dfp); add_block_comment(dfp,"Now - wait for all the threads to exit"); expr(dfp,"for(i=0;ipool[i],NULL) != 0 )",gm->name); hang_expr(dfp,"fatal(\"Unable to join a thread!\");"); closebrace(dfp); /* expr(dfp,"pthread_attr_destroy(&pat);"); */ add_block_comment(dfp,"Deallocate the thread structures"); expr(dfp,"ckfree(holder->pool)"); expr(dfp,"ckfree(holder)"); expr(dfp,"return SEARCH_OK;"); macro(dfp,"#else /* not compiled with threads */"); warn_expr(dfp,"You did not specifiy the PTHREAD compile when compiled the C code for %s",gm->name); macro(dfp,"#endif /* finished threads */"); } else { warn_expr(dfp,"This matrix %s was not dyc compiled with thread support",gm->name); expr(dfp,"return SEARCH_ERROR;"); } closecase(dfp); expr(dfp,"default :"); startcase(dfp); expr(dfp,"warn(\"database search implementation %%s was not provided in the compiled dynamite file from %s\",impl_string_DBSearchImpl(dbsi));",gm->name); expr(dfp,"return SEARCH_ERROR;"); closecase(dfp); closebrace(dfp); add_break(dfp); close_function(dfp); add_break(dfp); } # line 2273 "dynafunc.dy" void write_GenericMatrix_header(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { StructHolder * temp; StructElement * se; char buffer[MAXLINE]; write_StructHolder_header(dfp,gm->sh); if( dpi->do_threads == TRUE ) { if( can_do_threads(gm) == FALSE ) { warn("Asking for threads, but the types in this matrix %s are not thread safe",gm->name); } else { write_thread_struct(dfp,dpi,gm); } } temp = StructHolder_alloc_std(); sprintf(buffer,"%s_access_func_holder",gm->name); temp->name = stringalloc(buffer); sprintf(buffer,"int (*access_main)(%s*,int,int,int)",gm->name); se = basic_add_StructElement(temp,"access_main","int"); se->element_type = stringalloc(buffer); se->isfunc = TRUE; sprintf(buffer,"int (*access_special)(%s*,int,int,int)",gm->name); se = basic_add_StructElement(temp,"access_special","int"); se->element_type = stringalloc(buffer); se->isfunc = TRUE; write_StructHolder_header(dfp,temp); free_StructHolder(temp); /** write_StructHolder_header(gm->search_sh,ofp); **/ /** load_file(ofp); write_memory_macros(gm); close_file(); **/ } /***************************************** this function writes the C functions themselves it does not load up ofp into the header part of writec, and you must do that first if you want the function prototypes to be put into the header files ******************************************/ # line 2328 "dynafunc.dy" void write_GenericMatrix_func(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { fprintf(dfp->func,"\n\n /***************** C functions ****************/\n"); fprintf(dfp->func," /* Written using dynamite */\n"); fprintf(dfp->func," /* %s */\n",now_string()); fprintf(dfp->func," /* email birney@sanger.ac.uk */\n"); fprintf(dfp->func," /* http://www.sanger.ac.uk/Users/birney/dynamite */\n"); fprintf(dfp->func," /*************************************************/\n"); fprintf(dfp->func,"\n\n"); fprintf(dfp->func," /* Please report any problems or bugs to */\n"); fprintf(dfp->func," /* Ewan Birney, birney@sanger.ac.uk */\n"); fprintf(dfp->func,"\n\n"); add_block_comment(dfp,"basic set of macros to map states to numbers"); write_memory_macros(dfp,gm); write_search_macros(dfp,gm,dpi); add_break(dfp); if( dpi->dydebug == TRUE ) { write_debug_funcs(dfp,gm); } write_shatter_functions(dfp,gm,dpi); write_search_distributor_func(dfp,gm,dpi); if( dpi->do_threads == TRUE && can_do_threads(gm) ) { write_thread_loop(dfp,dpi,gm); } if( dpi->doprob == TRUE ) { write_probabilistic_models(dfp,gm,dpi); } make_search_loop_function(dfp,gm); write_one_score_GenericMatrix(dfp,gm,dpi); /** write_database_scan_function(gm); **/ /** if( make_Compugen_functions_if_possible(gm) == TRUE) { log_full_error(INFO,0,"Able to make Compugen functions"); } **/ /*** testing ***/ one_shot_aln_func(dfp,gm,dpi); write_safe_alloc_function(dfp,gm); alloc_expl_func_GenericMatrix(dfp,gm); init_matrix_func(dfp,gm); recalculate_PackAln_func(dfp,gm); /*** this is found in dynshadow.dy ***/ add_block_comment(dfp,"divide and conquor macros are next"); write_dc_functions(dfp,gm); /*write_pal_to_ars_func(dfp,gm);*/ write_aln_conversion_func(dfp,gm); write_alncconvert_make_func(dfp,gm); write_expl_read_func(dfp,gm); write_expl_access_funcs(dfp,gm); write_basic_read_func(dfp,gm); find_end_func(dfp,gm); debug_func(dfp,gm); write_max_calc_func(dfp,gm); write_special_max_calc_func(dfp,gm); matrix_calculate_func(dfp,gm); matrix_calculate_func_dpenv(dfp,gm); write_simplealloc_function(dfp,gm->sh); write_free_function(dfp,gm->sh); add_break(dfp); return; } # line 2480 "dynafunc.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/dynafunc.h0000644000175000001440000001605410670453715015415 0ustar philippusers#ifndef DYNAMITEdynafuncHEADERFILE #define DYNAMITEdynafuncHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dynfile.h" #include "dyna2.h" #include "labelmaster.h" #include "linesubs.h" #include "dynashadow.h" #include "dynadb.h" #include "dpimpl.h" #include "dbthread.h" #include "probal.h" #include "dynadebug.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: recalculate_PackAln_func(dfp,gm) * * Descrip: makes the recalculate packaln function * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [const GenericMatrix *] * */ void recalculate_PackAln_func(DYNFILE * dfp,const GenericMatrix * gm); /* Function: alloc_expl_func_GenericMatrix(dfp,gm) * * Descrip: makes the allocate_Expl_xxx function. * This calls allocate_xxx_only function * (made by /write_safe_alloc_function) * and then allocates basematrix stuff as well. * * * Arg: dfp [UNKN ] dynamite file pointer [DYNFILE *] * Arg: gm [READ ] generic matrix structure [const GenericMatrix *] * */ void alloc_expl_func_GenericMatrix(DYNFILE * dfp,const GenericMatrix * gm); /* Function: write_safe_alloc_function(dfp,gm) * * Descrip: produces the allocate_xxx_only function, * which allocates the matrix structure, checks * resources which it can check, but does NOT * allocate basematrix area * * This function will be called by allocate_Expl_xxxx * and allocate_Small_xxxx etc. * * * Arg: dfp [UNKN ] dynmaite file pointer to func/head [DYNFILE *] * Arg: gm [UNKN ] generic matrix structure [GenericMatrix *] * */ void write_safe_alloc_function(DYNFILE * dfp,GenericMatrix * gm); /* Function: add_args_GenericMatrix_FuncInfo(fi,gm) * * Descrip: Information partner to /get_argstr_GenericMatrix. * Loads up the arglist information for the GenericMatrix, * ie query-type query-name "what information" etc. * * * * Arg: fi [WRITE] FuncInfo structure to add ArgInfo to [FuncInfo *] * Arg: gm [READ ] generic matrix structure to read from [const GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_args_GenericMatrix_FuncInfo(FuncInfo * fi,const GenericMatrix * gm); /* Function: get_chainstr_GenericMatrix(gm) * * Descrip: makes an the argument calling string which * is compatible with the arg_str from * /get_argstr_GenericMatrix * * eg "query,target,comp_mat" * * * Arg: gm [READ ] structure holding generic matrix [const GenericMatrix *] * * Return [UNKN ] allocated string (must free) with chained-args [char *] * */ char * get_chainstr_GenericMatrix(const GenericMatrix * gm); /* Function: get_argstr_GenericMatrix(gm) * * Descrip: makes the argument list for a generic matrix alloc, ie * query-type query-name,target-type target-name etc * * To load up info, use /add_arg_GenericMatrix_FuncInfo * To chain up along function calls, use /get_chainstr_GenericMatrix * * * Arg: gm [READ ] structure holding generic matrix [const GenericMatrix *] * * Return [UNKN ] allocated string (must free) with args [char *] * */ char * get_argstr_GenericMatrix(const GenericMatrix * gm); /* Function: init_matrix_func(dfp,gm) * * Descrip: init explicit matrix * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ void init_matrix_func(DYNFILE * dfp,GenericMatrix * gm); /* Function: matrix_calculate_func(dfp,gm) * * Descrip: makes calculate_xxx functions, which * is for explicit matrix implementations * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ void matrix_calculate_func(DYNFILE * dfp,GenericMatrix * gm); /* Function: matrix_calculate_func_dpenv(dfp,gm) * * Descrip: makes calculate_xxx functions, which * is for explicit matrix implementations * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ void matrix_calculate_func_dpenv(DYNFILE * dfp,GenericMatrix * gm); /* Function: do_cell_function(dfp,gm) * * Descrip: useful function for debugging, but not * currently used * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ void do_cell_function(DYNFILE * dfp,GenericMatrix * gm); /* Unplaced functions */ /* There has been no indication of the use of these functions */ void one_shot_aln_func(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi); void write_dotter_dump(DYNFILE * dfp,GenericMatrix * gm); void write_memory_macros(DYNFILE * dfp,GenericMatrix * gm); void write_search_macros(DYNFILE * dfp,const GenericMatrix * gm,DPImplementation * dpi); void write_expl_access_funcs(DYNFILE * dfp,GenericMatrix * gm); void write_expl_read_func(DYNFILE * dfp,GenericMatrix * gm); void write_basic_read_func(DYNFILE * dfp,GenericMatrix * gm); void write_pal_to_ars_func(DYNFILE * dfp,GenericMatrix * gm); void write_alncconvert_make_func(DYNFILE * dfp,GenericMatrix * gm); void write_aln_conversion_func(DYNFILE * dfp,GenericMatrix * gm); void find_end_func(DYNFILE * dfp,GenericMatrix * gm); void debug_func(DYNFILE * dfp,GenericMatrix * gm); void write_special_max_calc_func_debug(DYNFILE * dfp,GenericMatrix * gm,int debug); void write_special_max_calc_func(DYNFILE * dfp,GenericMatrix * gm); void write_max_calc_block(DYNFILE * dfp,GenericMatrix * gm,char * matrix_tag,char * special_tag,boolean use_special,boolean use_holder); void write_max_calc_func(DYNFILE * dfp,GenericMatrix * gm); char * source_allowed_statement(int position,int offi,int offj); void write_score_block_debug(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointertag,char * specialtag,boolean use_special,int debug); void write_score_block(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointertag,char * specialtag,boolean use_special); void do_special_function(DYNFILE * dfp,GenericMatrix * gm); void write_search_distributor_func(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi); void write_GenericMatrix_header(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi); void write_GenericMatrix_func(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void write_special_block(DYNFILE * dfp,GenericMatrix * gm,char * matrix,char * special,char * bestscore); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/wisec.dy0000644000175000001440000011555407732117165015113 0ustar philippusers %{ #include "wisebase.h" #include "modulefunc.h" #include "dynfile.h" #include "objectinfo.h" #define StructHolderLISTLENGTH 64 #define CKN(s) (s == NULL ? "" : s) %} struct StructElement char * name char * element_type char * comment char * def boolean isapointer boolean islinked boolean islist boolean ismatrix char * len_append boolean isfunc boolean islocal boolean ishidden !def="FALSE" struct StructHolder StructElement ** el !list char * name char * placing_function ObjectInfo * oi %info This structure (which is now v. old) holds the information for a single 'struct' blueprint from dynamite. %% %{ #include "wisec.h" char * name_from_func_type(char * ty) { char buffer[MAXLINE]; char * runner; char * type = ty; for(;*type && *type != '(';type++) ; for(;*type && *type != '*';type++) ; type++; for(;*type && isspace(*type);type++) ; if( *type == '\0') { warn("Cannot make %s into a function name. not good",ty); return NULL; } for(runner=buffer;!isspace(*type) && *type && *type != ')' ;type++,runner++) *runner = (*type); *runner = '\0'; return stringalloc(buffer); } void write_StructHolder_header (DYNFILE * dfp,StructHolder * sh) { if( sh->oi != NULL ) { fprintf(dfp->head,"/* Object %s\n *\n",sh->name); write_C_ObjectInfo(sh->oi,dfp->head); fprintf(dfp->head," *\n */\n"); } write_StructHolder_typedef(dfp,sh,NULL); } void write_StructHolder_function(DYNFILE * dfp,StructHolder * sh,ModuleFunctionList * mfl) { register int j; ModuleFunction * mf; boolean is_hard_link = FALSE; is_hard_link = dfp->should_hard_link; if( sh == NULL || sh->name == NULL ) { warn("Very bad problem. You are trying to build a struct holder function without a valid structholder object or holder"); } mf = get_ModuleFunction_from_name(mfl,sh->name); if( is_listfunc(sh) == TRUE) { for(j=0;jlen;j++) if( sh->el[j]->islist == TRUE) { write_list_sort_function(dfp,sh,sh->el[j]); write_list_expand_function(dfp,sh,sh->el[j]); write_list_add_function(dfp,sh,sh->el[j]); write_list_flush_function(dfp,sh,sh->el[j]); } write_alloc_std_function(dfp,sh); write_alloc_len_function(dfp,sh); } else if( is_matrixfunc(sh) == TRUE) { write_alloc_matrix_function(dfp,sh); write_expand_matrix_function(dfp,sh); } /*** currently disabled write_binary_dump_function(sh); write_binary_read_function(sh); ****/ if( is_hard_link == TRUE) write_hard_link_function(dfp,sh); if( mf == NULL || mf->has_cons == FALSE) write_simplealloc_function(dfp,sh); if( mf == NULL || mf->has_decons == FALSE) write_free_function(dfp,sh); } void write_StructHolder_typedef(DYNFILE * dfp,StructHolder * sh,FILE * ofp) { register int i; boolean is_hard_link = FALSE; is_hard_link = dfp->should_hard_link; start_struct(dfp,"struct %s%s",dfp->package_name == NULL ? "" : dfp->package_name,sh->name); if( is_hard_link == TRUE ) { struct_expr(dfp,"int dynamite_hard_link;"); struct_macro(dfp,"#ifdef PTHREAD"); struct_expr(dfp,"pthread_mutex_t dynamite_mutex"); struct_macro(dfp,"#endif"); } for(i=0;ilen;i++) write_StructElement_typedef(dfp,sh->el[i]); close_struct(dfp,"; ",sh->name); add_end_comment_header(dfp,"%s defined",sh->name); fprintf(dfp->head,"#ifndef DYNAMITE_DEFINED_%s\n",sh->name); if( dfp->package_name != NULL ) { fprintf(dfp->head,"typedef struct %s%s %s%s;\n",dfp->package_name,sh->name,dfp->package_name,sh->name); fprintf(dfp->head,"#define %s %s%s\n",sh->name,dfp->package_name,sh->name); } else { fprintf(dfp->head,"typedef struct %s %s;\n",sh->name,sh->name); } fprintf(dfp->head,"#define DYNAMITE_DEFINED_%s\n",sh->name); fprintf(dfp->head,"#endif\n"); fprintf(dfp->head,"\n\n"); } void write_StructElement_typedef(DYNFILE * dfp,StructElement * se) { if( se->isfunc == TRUE ) { struct_expr(dfp,"%s;",se->element_type); return; } struct_expr(dfp,"%s %s; ",se->element_type,se->name); striptoprint(se->comment); if( se->comment != NULL) add_end_comment_header(dfp,se->comment); if( se->islist == TRUE) { struct_expr(dfp,"int %slen;",CKN(se->len_append)); add_end_comment_header(dfp,"len for above %s ",se->name); struct_expr(dfp,"int %smaxlen;",CKN(se->len_append)); add_end_comment_header(dfp,"maxlen for above %s",se->name); } else if( se->ismatrix == TRUE) { struct_expr(dfp,"int leni"); add_end_comment_header(dfp,"leni for above %s ",se->name); struct_expr(dfp,"int maxleni;"); add_end_comment_header(dfp,"max length for above pointer set"); struct_expr(dfp,"int lenj"); add_end_comment_header(dfp,"lenj for above %s ",se->name); struct_expr(dfp,"int maxlenj;"); add_end_comment_header(dfp,"max length for above pointer set"); } } char * free_function(char * type) { char * runner; char * temp; char buffer[MAXLINE]; temp = depointer_element(type); if( temp == NULL ) { warn("Unable to depointer %s",type); return NULL; } if( strchr(temp,'*') != NULL) return stringalloc("ckfree"); if( strstr(temp,"struct") != NULL) return NULL; if( (runner=strtok(temp," *\t\n")) == NULL) return NULL; if( is_simple_type_string(temp) == TRUE) return stringalloc("ckfree"); strcpy(buffer,"free_"); strcat(buffer,runner); free(temp); return stringalloc(buffer); } void write_hard_link_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; ArgInfo * ai; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"hard_link_%s",sh->name); add_line_to_Ftext(fi->ft,"Bumps up the reference count of the object"); add_line_to_Ftext(fi->ft,"Meaning that multiple pointers can 'own' it"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc=stringalloc("Object to be hard linked"); start_function_FuncInfo(fi,dfp,"%s * hard_link_%s(%s * obj)",sh->name,sh->name,sh->name); expr(dfp,"if( obj == NULL ) "); startbrace(dfp); warn_expr(dfp,"Trying to hard link to a %s object: passed a NULL object",sh->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"obj->dynamite_hard_link++;"); expr(dfp,"return obj;"); close_function(dfp); add_break(dfp); } void write_free_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; ArgInfo * ai; StructElement * temp; register int i; register int islist=FALSE; register int ismat =FALSE; char * run; char * run2; boolean is_hard_link = FALSE; is_hard_link = dfp->should_hard_link; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"free_%s",sh->name); add_line_to_Ftext(fi->ft,"Free Function: removes the memory held by obj"); add_line_to_Ftext(fi->ft,"Will chain up to owned members and clear all lists"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc=stringalloc("Object that is free'd"); start_function_FuncInfo(fi,dfp,"%s * free_%s(%s * obj)",sh->name,sh->name,sh->name); expr(dfp,"int return_early = 0;"); if( (islist=is_listfunc(sh)) == TRUE) { expr(dfp,"int i;"); } else if ( (ismat=is_matrixfunc(sh)) == TRUE) { expr(dfp,"int i;"); expr(dfp,"int j;"); } add_break(dfp); expr(dfp,"if( obj == NULL)"); startbrace(dfp); warn_expr(dfp,"Attempting to free a NULL pointer to a %s obj. Should be trappable",sh->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); if( is_hard_link == TRUE ) { macro(dfp,"#ifdef PTHREAD"); expr(dfp,"assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0);"); macro(dfp,"#endif"); expr(dfp,"if( obj->dynamite_hard_link > 1) "); startbrace(dfp); expr(dfp,"return_early = 1;"); expr(dfp,"obj->dynamite_hard_link--;"); closebrace(dfp); macro(dfp,"#ifdef PTHREAD"); expr(dfp,"assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0);"); macro(dfp,"#endif"); expr(dfp,"if( return_early == 1)"); hang_expr(dfp,"return NULL;"); } for(i=0;ilen;i++) { temp = sh->el[i]; if( temp->islist == TRUE) { run = depointer_element(temp->element_type); if((run2 = free_function(run)) == NULL) { log_full_error(WARNING,0,"Unable to make function for %s (%s)",temp->name,temp->element_type); add_block_comment(dfp,"Unable to make function for %s",temp->name); continue; } expr(dfp,"if( obj->%s != NULL)",temp->name); startbrace(dfp); expr(dfp,"for(i=0;i%slen;i++)",CKN(temp->len_append)); startbrace(dfp); expr(dfp,"if( obj->%s[i] != NULL)",temp->name); hang_expr(dfp,"%s(obj->%s[i]);",run2,temp->name); ckfree(run); ckfree(run2); closebrace(dfp); expr(dfp,"ckfree(obj->%s);",temp->name); closebrace(dfp); } else if( temp->ismatrix == TRUE) { expr(dfp,"if( obj->%s != NULL)",temp->name); startbrace(dfp); expr(dfp,"for(i=0;ileni;i++)"); startbrace(dfp); expr(dfp,"if( obj->%s[i] != NULL)",temp->name); hang_expr(dfp,"ckfree(obj->%s[i]);",temp->name); closebrace(dfp); expr(dfp,"ckfree(obj->%s)",temp->name); closebrace(dfp); } else if( temp->islinked == TRUE) { add_block_comment(dfp,"obj->%s is linked in",temp->name); } else if( temp->isfunc == TRUE) { add_block_comment(dfp,"obj->%s is a function pointer",temp->name); } else { if( strchr(temp->element_type,'*') == NULL) continue; if( (run=free_function(temp->element_type)) == NULL) { add_block_comment(dfp,"Unable to make free function for obj->%s",temp->name); continue; } expr(dfp,"if( obj->%s != NULL)",temp->name); hang_expr(dfp,"%s(obj->%s)",run,temp->name); ckfree(run); } } add_break(dfp); expr(dfp,"ckfree(obj);"); expr(dfp,"return NULL;"); close_function(dfp); add_break(dfp); } boolean is_simple_type(StructElement * se) { if( se->isfunc == TRUE ) return FALSE; if( strchr(se->element_type,'*') != NULL ) return FALSE; return is_simple_type_string(se->element_type); } boolean is_simple_type_string(char * str) { if( strcmp(str,"int") == 0) return TRUE; if( strcmp(str,"char") == 0) return TRUE; if( strcmp(str,"float") == 0) return TRUE; if( strcmp(str,"double") == 0) return TRUE; if( strcmp(str,"boolean") == 0) return TRUE; return FALSE; } boolean is_string_type(StructElement * se) { if( se->isfunc == TRUE ) return FALSE; if( strcmp(se->element_type,"char *") == 0) return TRUE; return FALSE; } boolean is_binary_dump_type(StructElement * se) { if( se->isfunc == TRUE) return FALSE; if( strchr(se->element_type,'*') == NULL ) return FALSE; if( strstr(se->element_type,"**") != NULL) return FALSE; return TRUE; } void write_binary_dump_function(DYNFILE * dfp,StructHolder * sh) { register int i; start_function(dfp,"boolean binary_dump_%s(%s * obj,FILE * ofp)",sh->name,sh->name); if( is_listfunc(sh) == TRUE ) { expr(dfp,"register int i;"); } else if ( is_matrixfunc(sh) == TRUE ) { expr(dfp,"register int i;"); expr(dfp,"register int j;"); } expr(dfp,"char buffer[MAXBINARYDUMP]"); expr(dfp,"int strl;"); add_break(dfp); /*** first dump tag line ***/ expr(dfp,"memset(buffer,0,MAXBINARYDUMP)"); expr(dfp,"strcpy(buffer,\"DYN %s\")",sh->name); expr(dfp,"buffer[3] = '\\0';"); expr(dfp,"buffer[63] = '\\0';"); expr(dfp,"buffer[64] = '\\0';"); /*** dump ***/ expr(dfp,"fwrite(buffer,sizeof(char),64,ofp)"); add_break(dfp); add_block_comment(dfp,"written block tag, write out elements"); add_break(dfp); /*** ok - now chain to elements ***/ for(i=0;ilen;i++) { auto char * run; auto char * run2; auto StructElement * temp; temp = sh->el[i]; if( temp->isfunc == TRUE || temp->islinked == TRUE || temp->islocal == TRUE) continue; if( temp->islist == TRUE ) { run = depointer_element(temp->element_type); run2 = depointer_element(run); expr(dfp,"fwrite(&obj->%slen,sizeof(int),1,ofp)",CKN(temp->len_append)); expr(dfp,"for(i=0;i%slen;i++)",CKN(temp->len_append)); startbrace(dfp); expr(dfp,"binary_dump_%s(obj->%s[i],ofp)",run2,temp->name); closebrace(dfp); ckfree(run); ckfree(run2); continue; } if( is_simple_type(temp) == TRUE ) { expr(dfp,"fwrite(&obj->%s,sizeof(%s),1,ofp)",temp->name,temp->element_type); } else if( is_string_type(temp) == TRUE ) { expr(dfp,"strl = strlen(obj->%s)",temp->name); expr(dfp,"fwrite(&strl,sizeof(int),1,ofp);"); expr(dfp,"fwrite(obj->%s,sizeof(char),strlen(obj->%s),ofp)",temp->name,temp->name); } else if( is_binary_dump_type(temp) == TRUE ) { run = depointer_element(temp->element_type); /** call binary dump func **/ expr(dfp,"if( obj->%s == NULL )",temp->name); hang_expr(dfp,"strl = 0;"); expr(dfp,"else strl = 1;"); expr(dfp,"fwrite(&strl,sizeof(int),1,ofp)"); expr(dfp,"if( obj->%s != NULL )",temp->name); hang_expr(dfp,"binary_dump_%s(obj->%s,ofp)",run,temp->name); ckfree(run); } else { warn("Unable to handle binary dump for %s element of %s",temp->name,sh->name); } } expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } void write_binary_read_function(DYNFILE * dfp,StructHolder * sh) { register int i; char * lenapp; start_function(dfp,"%s * binary_read_%s(FILE * ifp)",sh->name,sh->name); if( is_listfunc(sh) == TRUE ) { expr(dfp,"register int i;"); expr(dfp,"int count"); } else if ( is_matrixfunc(sh) == TRUE ) { expr(dfp,"register int i;"); expr(dfp,"register int j;"); } expr(dfp,"char buffer[MAXBINARYDUMP]"); expr(dfp,"int strl;"); expr(dfp,"%s * obj",sh->name); add_break(dfp); /*** first read dump tag line ***/ expr(dfp,"fread(buffer,sizeof(char),64,ifp)"); expr(dfp,"if( strcmp(buffer,\"DYN\") != 0 )"); startbrace(dfp); warn_expr(dfp,"Unable to read DYN tag in binary read for %s",sh->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"if( strcmp(buffer+4,\"%s\") != 0 )",sh->name); startbrace(dfp); expr(dfp,"warn(\"Unable to pick up %s tag in reading binary dump, got %%s\",buffer+4)",sh->name); expr(dfp,"return NULL"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"read block tag,time to read in elements"); add_break(dfp); if( is_listfunc(sh) == TRUE) expr(dfp,"obj = %s_alloc_std()",sh->name); else expr(dfp,"obj = %s_alloc()",sh->name); expr(dfp,"if( obj == NULL )"); startbrace(dfp); warn_expr(dfp,"Memory allocation problem in %s binary read",sh->name); expr(dfp,"return NULL;"); closebrace(dfp); /*** ok - now chain to elements ***/ for(i=0;ilen;i++) { auto char * run; auto char * run2; auto StructElement * temp; temp = sh->el[i]; if( temp->isfunc == TRUE || temp->islinked == TRUE || temp->islocal == TRUE) continue; if( temp->islist == TRUE ) { if( temp->len_append == NULL) lenapp = ""; else lenapp = temp->len_append; run = depointer_element(temp->element_type); run2 = depointer_element(run); expr(dfp,"fread(&count,sizeof(int),1,ifp)"); expr(dfp,"for(;count > 0 ;count--)",temp->len_append); startbrace(dfp); expr(dfp,"add_%s%s(obj,binary_read_%s(ifp))",lenapp,temp->name,run2); closebrace(dfp); ckfree(run); ckfree(run2); continue; } if( is_simple_type(temp) == TRUE ) { expr(dfp,"fread(&obj->%s,sizeof(%s),1,ifp)",temp->name,temp->element_type); } else if( is_string_type(temp) == TRUE ) { expr(dfp,"memset(buffer,0,MAXBINARYDUMP)"); expr(dfp,"fread(&strl,sizeof(int),1,ifp)"); expr(dfp,"fread(buffer,sizeof(char),strl,ifp)"); expr(dfp,"obj->%s = stringalloc(buffer)",temp->name,temp->name); } else if( is_binary_dump_type(temp) == TRUE ) { run = depointer_element(temp->element_type); /** call binary dump func **/ expr(dfp,"fread(&strl,sizeof(int),1,ifp)"); expr(dfp,"if( strl == 1 )"); hang_expr(dfp,"obj->%s = binary_read_%s(ifp)",temp->name,run); ckfree(run); } else { warn("Unable to handle binary dump for %s element of %s",temp->name,sh->name); } } expr(dfp,"return obj"); close_function(dfp); add_break(dfp); } void write_expand_matrix_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; register int i; char * runner; char * run2; StructElement * temp; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"expand_%s",sh->name); add_line_to_Ftext(fi->ft,"Expands matrix. Rarely used"); start_function_FuncInfo(fi,dfp,"boolean expand_%s(%s * obj,int leni,int lenj)",sh->name,sh->name); for(i=0;ilen;i++) if(sh->el[i]->ismatrix == TRUE) break; if( i >= sh->len) return; temp=sh->el[i]; expr(dfp,"int i"); expr(dfp,"int actualj"); add_break(dfp); expr(dfp,"if( obj == NULL) "); startbrace(dfp); expr(dfp,"warn(\"Trying to expand a %s but is NULL!\");",sh->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); expr(dfp,"if( leni <= obj->maxleni && lenj <= obj->maxlenj)"); hang_expr(dfp,"return TRUE"); add_break(dfp); expr(dfp,"if( obj->maxleni < leni )"); startbrace(dfp); if( (runner = depointer_element(temp->element_type)) == NULL) log_full_error(WARNING,0,"Oooops"); if( (run2 = depointer_element(runner)) == NULL) log_full_error(WARNING,0,"Oooops"); expr(dfp,"if( (obj->%s=(%s) ckrealloc (obj->%s,sizeof(%s)*leni)) == NULL)",temp->name,temp->element_type,temp->name,runner); hang_expr(dfp,"return FALSE;"); expr(dfp,"obj->maxleni=obj->leni=leni"); closebrace(dfp); expr(dfp,"if( lenj > obj->maxlenj )"); hang_expr(dfp,"actualj = lenj"); expr(dfp,"else actualj = obj->maxlenj;"); expr(dfp,"for(i=0;ileni;i++)"); startbrace(dfp); expr(dfp,"if((obj->%s[i] = (%s) realloc (obj->%s[i],sizeof(%s) * actualj)) == NULL)",temp->name,runner,temp->name,run2) ; hang_expr(dfp,"return FALSE;"); closebrace(dfp); expr(dfp,"return TRUE"); close_function(dfp); ckfree(runner); ckfree(run2); add_break(dfp); return; } void write_alloc_matrix_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; ArgInfo * ai; register int i; char * run2; char * runner; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"%s_alloc_matrix",sh->name); add_line_to_Ftext(fi->ft,"Allocates structure and matrix"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"leni"); ai->desc=stringalloc("Length of first dimension of matrix"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"lenj"); ai->desc=stringalloc("Length of second dimension of matrix"); start_function_FuncInfo(fi,dfp,"%s * %s_alloc_matrix(int leni,int lenj)",sh->name,sh->name); expr(dfp,"%s * out",sh->name); add_end_comment(dfp,"out is exported "); expr(dfp,"register int i"); add_end_comment(dfp,"for stepping down matrix"); expr(dfp,"register int j"); add_end_comment(dfp,"for stepping across matrix"); add_break(dfp); add_block_comment(dfp,"Call alloc function, return NULL if NULL"); expr(dfp,"if((out = %s_alloc()) == NULL)",sh->name); hang_expr(dfp,"return NULL"); add_break(dfp); for(i=0;ilen;i++) if( sh->el[i]->ismatrix == TRUE) { if( (runner=depointer_element(sh->el[i]->element_type)) == NULL) continue; if( (run2=depointer_element(runner)) == NULL) continue; add_block_comment(dfp,"Allocate memory for %s ",sh->el[i]->name); expr(dfp,"if((out->%s = (%s) ckcalloc (leni,sizeof(%s))) == NULL)",sh->el[i]->name,sh->el[i]->element_type,runner); startbrace(dfp); expr(dfp,"warn(\"Memory allocation problem in matrix for %s %s, first pointer set\");",sh->name,sh->el[i]->name); expr(dfp,"ckfree(out)"); expr(dfp,"return NULL"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Add NULL to all matrix pointers so free can be called"); expr(dfp,"for(i=0;i%s[i] = NULL",sh->el[i]->name); add_break(dfp); add_block_comment(dfp,"Allocate each matrix row"); expr(dfp,"for(i=0;i%s[i] = (%s) ckcalloc (lenj,sizeof(%s))",sh->el[i]->name,runner,run2); expr(dfp,"if( out->%s[i] == NULL)",sh->el[i]->name); startbrace(dfp); expr(dfp,"warn(\"Failed alloc on %%d, calling free and returning NULL\",i);"); expr(dfp,"free_%s(out)",sh->name); expr(dfp,"return NULL"); closebrace(dfp); closebrace(dfp); add_break(dfp); if( sh->el[i]->def != NULL ) { expr(dfp,"for(i=0;i%s[i][j] = %s",sh->el[i]->name,sh->el[i]->def); closebrace(dfp); add_break(dfp); } expr(dfp,"out->leni=out->maxleni=leni"); expr(dfp,"out->lenj=out->maxlenj=lenj"); add_break(dfp); } expr(dfp,"return out"); close_function(dfp); add_break(dfp); } void write_list_sort_function(DYNFILE * dfp,StructHolder * sh,StructElement * temp) { FuncInfo * fi; ArgInfo * ai; register char * runner; char * listappend; listappend=CKN(temp->len_append); runner = depointer_element(temp->element_type); if( runner == NULL) { log_full_error(WARNING,0,"Unable to depointer %s",temp->element_type); return; } add_block_comment(dfp,"swap function for qsort function"); fi = FuncInfo_named_from_varstr(FI_INTERNAL,"swap_%s%s",listappend,sh->name); add_line_to_Ftext(fi->ft,"swap function: an internal for qsort_%s%s",listappend,sh->name); add_line_to_Ftext(fi->ft,"swaps two positions in the array"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"list"); ai->desc=stringalloc("List of structures to swap in"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"i"); ai->desc=stringalloc("swap position"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"j"); ai->desc=stringalloc("swap position"); start_function_FuncInfo(fi,dfp,"void swap_%s%s(%s list,int i,int j) ",listappend,sh->name,temp->element_type); expr(dfp,"%s temp;",runner); expr(dfp,"temp=list[i];"); expr(dfp,"list[i]=list[j];"); expr(dfp,"list[j]=temp;"); close_function(dfp); add_break(dfp); /*** sort function actual type ***/ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"qsort_%s%s",listappend,sh->name); add_line_to_Ftext(fi->ft,"qsort - lifted from K&R ",listappend,sh->name); add_line_to_Ftext(fi->ft,"sorts the array using quicksort"); add_line_to_Ftext(fi->ft,"Probably much better to call sort_%s%s which sorts from start to end",listappend,sh->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"list"); ai->desc=stringalloc("List of structures to swap in"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"left"); ai->desc=stringalloc("left position"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"right"); ai->desc=stringalloc("right position"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"comp"); ai->desc=stringalloc("Function which returns -1 or 1 to sort on"); start_function_FuncInfo(fi,dfp,"void qsort_%s%s(%s list,int left,int right,int (*comp)(%s ,%s ))",listappend,sh->name,temp->element_type,runner,runner); expr(dfp,"int i,last;"); expr(dfp,"if( left >= right )"); hang_expr(dfp,"return;"); add_break(dfp); expr(dfp,"swap_%s%s(list,left,(left+right)/2);",listappend,sh->name); expr(dfp,"last = left;"); expr(dfp,"for ( i=left+1; i <= right;i++)"); startbrace(dfp); expr(dfp,"if( (*comp)(list[i],list[left]) < 0)"); hang_expr(dfp,"swap_%s%s (list,++last,i);",listappend,sh->name); closebrace(dfp); expr(dfp,"swap_%s%s (list,left,last);",listappend,sh->name); expr(dfp,"qsort_%s%s(list,left,last-1,comp);",listappend,sh->name); expr(dfp,"qsort_%s%s(list,last+1,right,comp);",listappend,sh->name); close_function(dfp); add_break(dfp); /*** actual function to be called ***/ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"sort_%s%s",listappend,sh->name); add_line_to_Ftext(fi->ft,"sorts from start to end using comp ",listappend,sh->name); add_line_to_Ftext(fi->ft,"sorts the array using quicksort by calling qsort_%s%s",listappend,sh->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc=stringalloc("Object containing list"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"comp"); ai->desc=stringalloc("Function which returns -1 or 1 to sort on"); start_function_FuncInfo(fi,dfp,"void sort_%s%s(%s * obj,int (*comp)(%s, %s))",listappend,sh->name,sh->name,runner,runner); expr(dfp,"qsort_%s%s(obj->%s,0,obj->%slen-1,comp);",listappend,sh->name,temp->name,listappend); expr(dfp,"return;"); close_function(dfp); add_break(dfp); } void write_list_flush_function(DYNFILE * dfp,StructHolder * sh,StructElement * temp) { FuncInfo * fi; ArgInfo * ai; register char * runner; char * listapp; char * run2; listapp = CKN(temp->len_append); runner = depointer_element(temp->element_type); run2 = free_function(runner); fi = FuncInfo_named_from_varstr(FI_CALLABLE,"flush_%s%s",listapp,sh->name); add_line_to_Ftext(fi->ft,"Frees the list elements, sets length to 0"); add_line_to_Ftext(fi->ft,"If you want to save some elements, use hard_link_xxx"); add_line_to_Ftext(fi->ft,"to protect them from being actually destroyed in the free"); fi->simple= stringallocf("flush_%s",temp->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc=stringalloc("Object which contains the list "); start_function_FuncInfo(fi,dfp,"int flush_%s%s(%s * obj)",listapp,sh->name,sh->name); expr(dfp,"int i;"); add_break(dfp); expr(dfp,"for(i=0;i%slen;i++)",listapp); startbrace_tag(dfp,"for i over list length"); expr(dfp,"if( obj->%s[i] != NULL)",temp->name); startbrace(dfp); expr(dfp,"%s(obj->%s[i]);",run2,temp->name); expr(dfp,"obj->%s[i] = NULL;",temp->name); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"obj->%slen = 0;",listapp); expr(dfp,"return i;"); close_function(dfp); add_break(dfp); } void write_list_add_function(DYNFILE * dfp,StructHolder * sh,StructElement * temp) { FuncInfo * fi; ArgInfo * ai; register char * runner; char * listappend; listappend = CKN(temp->len_append); runner = depointer_element(temp->element_type); add_block_comment(dfp,"will expand function if necessary"); fi = FuncInfo_named_from_varstr(FI_CALLABLE,"add_%s%s",listappend,sh->name); add_line_to_Ftext(fi->ft,"Adds another object to the list. It will expand the list if necessary"); fi->simple = stringallocf("add_%s",temp->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc=stringalloc("Object which contains the list"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"add"); ai->desc=stringalloc("Object to add to the list"); ai->argtype = ARGTYPE_OWNER; start_function_FuncInfo(fi,dfp,"boolean add_%s%s(%s * obj,%s add)",listappend,sh->name,sh->name,runner); expr(dfp,"if( obj->%slen >= obj->%smaxlen)",listappend,listappend); startbrace(dfp); expr(dfp,"if( expand_%s%s(obj,obj->%slen + %sLISTLENGTH) == FALSE)",listappend,sh->name,listappend,sh->name); hang_expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); expr(dfp,"obj->%s[obj->%slen++]=add;",temp->name,listappend); expr(dfp,"return TRUE;"); close_function(dfp); add_break(dfp); } void write_list_expand_function(DYNFILE * dfp,StructHolder * sh,StructElement * temp) { FuncInfo * fi; ArgInfo * ai; register char * runner; char * listappend; listappend = CKN(temp->len_append); runner = depointer_element(temp->element_type); if( runner == NULL) { log_full_error(WARNING,0,"Unable to depointer %s",temp->element_type); return; } fi = FuncInfo_named_from_varstr(FI_INTERNAL,"expand_%s%s",listappend,sh->name); add_line_to_Ftext(fi->ft,"Really an internal function for add_%s%s",listappend,sh->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc=stringalloc("Object which contains the list"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"len"); ai->desc=stringalloc("Length to add one"); start_function_FuncInfo(fi,dfp,"boolean expand_%s%s(%s * obj,int len)",CKN(listappend),sh->name,sh->name); add_break(dfp); expr(dfp,"if( obj->%smaxlen > obj->%slen ) ",listappend,listappend); startbrace(dfp); expr(dfp,"warn(\"expand_%s%s called with no need\");",sh->name,CKN(listappend)); expr(dfp,"return TRUE;"); closebrace(dfp); add_break(dfp); expr(dfp,"if( (obj->%s = (%s ) ckrealloc (obj->%s,sizeof(%s)*len)) == NULL) ", temp->name,temp->element_type,temp->name,runner); startbrace(dfp); expr(dfp,"warn(\"ckrealloc failed for expand_%s, returning FALSE\");",sh->name); expr(dfp,"return FALSE;"); closebrace(dfp); expr(dfp,"obj->%smaxlen = len;",listappend,listappend); expr(dfp,"return TRUE;"); close_function(dfp); add_break(dfp); } void write_alloc_std_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"%s_alloc_std",sh->name); add_line_to_Ftext(fi->ft,"Equivalent to %s_alloc_len(%sLISTLENGTH)",sh->name,sh->name); start_function_FuncInfo(fi,dfp,"%s * %s_alloc_std(void)",sh->name,sh->name); expr(dfp,"return %s_alloc_len(%sLISTLENGTH);",sh->name,sh->name); close_function(dfp); add_break(dfp); } void write_alloc_len_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; ArgInfo * ai; register int i; char * runner; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"%s_alloc_len",sh->name); add_line_to_Ftext(fi->ft,"Allocates len length to all lists",sh->name,sh->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"len"); ai->desc=stringalloc("Length of lists to allocate"); start_function_FuncInfo(fi,dfp,"%s * %s_alloc_len(int len)",sh->name,sh->name); expr(dfp,"%s * out;",sh->name); add_end_comment(dfp,"out is exported at the end of function"); add_break(dfp); add_block_comment(dfp,"Call alloc function: return NULL if NULL"); add_block_comment(dfp,"Warning message alread in alloc function"); expr(dfp,"if((out = %s_alloc()) == NULL)",sh->name); hang_expr(dfp,"return NULL;"); add_break(dfp); add_block_comment(dfp,"Calling ckcalloc for list elements"); for(i=0;ilen;i++) { if( sh->el[i]->islist == FALSE) continue; if( (runner=depointer_element(sh->el[i]->element_type)) == NULL) continue; expr(dfp,"if((out->%s = (%s ) ckcalloc (len,sizeof(%s))) == NULL)",sh->el[i]->name,sh->el[i]->element_type,runner); free(runner); startbrace(dfp); expr(dfp,"warn(\"Warning, ckcalloc failed in %s_alloc_len\");",sh->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"out->%slen = 0;",CKN(sh->el[i]->len_append)); expr(dfp,"out->%smaxlen = len;",CKN(sh->el[i]->len_append)); add_break(dfp); } expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } char * depointer_element(char * element) { char buffer[MAXLINE]; char * runner; for(runner=buffer;*element && *element != '*';) *(runner++)=(*(element++)); if( *element == '\0') return NULL; element++; /* depointers it */ while( *element ) *(runner++)=(*(element++)); *(runner)='\0'; return stringalloc(buffer); } boolean isarray(StructElement * se) { if( strchr(se->name,'[') != NULL ) return TRUE; return FALSE; } void write_simplealloc_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; register int i; boolean is_hard_link = FALSE; is_hard_link = dfp->should_hard_link; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"%s_alloc",sh->name); add_line_to_Ftext(fi->ft,"Allocates structure: assigns defaults if given ",sh->name,sh->name); fi->simple = stringalloc("alloc"); start_function_FuncInfo(fi,dfp,"%s * %s_alloc(void)",sh->name,sh->name); expr(dfp,"%s * out;",sh->name); add_end_comment(dfp,"out is exported at end of function"); add_break(dfp); add_block_comment(dfp,"call ckalloc and see if NULL"); expr(dfp,"if((out=(%s *) ckalloc (sizeof(%s))) == NULL)", sh->name,sh->name); startbrace(dfp); expr(dfp,"warn(\"%s_alloc failed \");", sh->name); expr(dfp,"return NULL;"); add_end_comment(dfp,"calling function should respond!"); closebrace(dfp); if( is_hard_link == TRUE ) { expr(dfp,"out->dynamite_hard_link = 1;"); macro(dfp,"#ifdef PTHREAD"); expr(dfp,"pthread_mutex_init(&(out->dynamite_mutex),NULL)"); macro(dfp,"#endif"); } for(i=0;ilen;i++) { if( sh->el[i]->islinked == TRUE) continue; else if( isarray(sh->el[i]) == TRUE ) { add_block_comment(dfp,"%s is an array: no default possible",sh->el[i]->name); } else if( sh->el[i]->isfunc == TRUE) { expr(dfp,"out->%s = NULL;",sh->el[i]->name); } else if( sh->el[i]->islist == TRUE) { expr(dfp,"out->%s = NULL;",sh->el[i]->name); expr(dfp,"out->%slen = out->%smaxlen = 0;",CKN(sh->el[i]->len_append),CKN(sh->el[i]->len_append)); } else if( sh->el[i]->ismatrix == TRUE) { expr(dfp,"out->%s = NULL;",sh->el[i]->name); expr(dfp,"out->leni=out->maxleni=0;"); expr(dfp,"out->lenj=out->maxlenj=0;"); } else if( sh->el[i]->def != NULL) expr(dfp,"out->%s = %s;",sh->el[i]->name, sh->el[i]->def); else if( strcmp(sh->el[i]->element_type,"PSPosition") == 0) expr(dfp,"out->%s.x = out->%s.y = 0;",sh->el[i]->name,sh->el[i]->name); else add_block_comment(dfp,"Unable to find def for %s", sh->el[i]->name); } add_break(dfp); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } boolean is_listfunc(StructHolder * sh) { register int i; for(i=0;ilen;i++) if( sh->el[i]->islist == TRUE) return TRUE; return FALSE; } boolean is_matrixfunc(StructHolder * sh) { register int i; for(i=0;ilen;i++) if( sh->el[i]->ismatrix == TRUE) return TRUE; return FALSE; } /* IO */ char * def_from_element(char * str) { char * runner; if( strchr(str,'*') != NULL) return stringalloc("NULL"); if( (runner=strtok(str," \t*")) == NULL) return NULL; if( strcmp(str,"int") == 0 || strcmp(str,"float") == 0 || strcmp(str,"double") == 0) return stringalloc("0"); if( strcmp(str,"char") == 0) return stringalloc("'u'"); if( strcmp(str,"boolean") == 0 ) return stringalloc("FALSE"); if( strcmp(str,"Score") == 0 ) return stringalloc("0"); if( strcmp(str,"Probability") == 0 ) return stringalloc("0.0"); warn("For element %s - got no good default. Returning 0",str); return stringalloc("0"); } char * get_word_from_bang(char * str,char ** word) { if( str == NULL || *str == '\0') return NULL; while( *str != '\0' && *str != '!') str++; if( *str == '\0') { *word=NULL; return NULL; } *word=str+1; while( *str && !isspace(*str) ) str++; *str='\0'; str++; return str; } boolean read_StructHolder_elements(StructHolder * sh,FILE * ifp) { char buffer[MAXLINE]; char * runner; char * comment; boolean islink; boolean islist; boolean isfunc=FALSE; boolean ishidden=FALSE; boolean ismatrix; boolean islocal; char * def; char * lenapp; char * name; char ** base; char ** brk; StructElement * temp; ObjectInfo * oi; while( get_watched_line(buffer,MAXLINE,ifp) != NULL) { temp=NULL; comment=NULL; runner=NULL; def=NULL; lenapp=NULL; isfunc=islink=islist=ismatrix=islocal=FALSE; if( strstartcmp(buffer,"%info") == 0 ) { oi = read_ObjectInfo_line_func(buffer,MAXLINE,ifp,get_watched_line); if( oi == NULL ) { warn("In Object %s, bad info!",sh->name); continue; } sh->oi = oi; continue; } if( (runner=strstr(buffer,"//")) != NULL) { *(runner++)='\0'; while( *runner == '/') runner++; comment = stringalloc (runner); /* striptoprint(comment); */ } if((runner=strchr(buffer,'!')) != NULL) { *(runner-1)='\0'; base=brk=breakstring(runner,spacestr); for(;*brk != NULL;brk++) { if( strstartcmp(*brk,"!link") == 0) islink=TRUE; else if( strstartcmp(*brk,"!matrix") == 0) ismatrix=TRUE; else if( strstartcmp(*brk,"!func") == 0) isfunc=TRUE; else if( strstartcmp(*brk,"!list") == 0) islist=TRUE; else if( strstartcmp(*brk,"!local") == 0) islocal=TRUE; else if( strstartcmp(*brk,"!hidden") == 0) ishidden=TRUE; else if( strstartcmp(*brk,"!def") == 0) { def=string_from_quoted_equality(*brk); } else if( strstartcmp(*brk,"!len") == 0) { lenapp=string_from_quoted_equality(*brk); } } ckfree(base); } runner=buffer+strlen(buffer); while( runner != NULL && !isalnum(*runner) && *runner != ']' && *runner != ')' ) { if( runner == buffer) runner=NULL; else *(runner--) = '\0'; } if( runner == NULL) break; while( isalnum(*runner) || strchr("*_[])(",*runner) != NULL ) { if( *runner == ')') { while( *runner != '(' ) runner--; } else runner--; } name=runner+1; *runner='\0'; /* better not be flush! */ /* fprintf(stderr,"Adding %s and %s\n",name,buffer); */ if((temp=basic_add_StructElement( sh,name,buffer)) == NULL) fatal("Memeory problem... in adding struct element. Ugh!"); if( comment != NULL) temp->comment=comment; if( def != NULL) temp->def=def; else temp->def=def_from_element(temp->element_type); if( lenapp != NULL) temp->len_append=lenapp; if( islocal == TRUE) temp->islocal = TRUE; if( islist == TRUE) { temp->islist=TRUE; /*** make list components ***/ /*** disabled: handled in write sprintf(buf2,"%slen",temp->len_append == NULL ? "" : temp->len_append ); basic_add_StructElement(sh,buf2,"int"); sprintf(buf2,"%smaxlen",temp->len_append == NULL ? "" : temp->len_append ); basic_add_StructElement(sh,buf2,"int"); ***/ } if( islink == TRUE) temp->islinked = TRUE; if( ismatrix == TRUE) { temp->ismatrix = TRUE; /*** make matrix components ***/ /*** disabled: handled in write sprintf(buf2,"%sleni",temp->len_append == NULL ? "" : temp->len_append); basic_add_StructElement(sh,buf2,"int"); sprintf(buf2,"%smaxleni",temp->len_append == NULL ? "" : temp->len_append); basic_add_StructElement(sh,buf2,"int"); sprintf(buf2,"%slenj",temp->len_append == NULL ? "" : temp->len_append); basic_add_StructElement(sh,buf2,"int"); sprintf(buf2,"%smaxlenj",temp->len_append == NULL ? "" : temp->len_append); basic_add_StructElement(sh,buf2,"int"); ***/ } if( ishidden == TRUE ) { temp->ishidden = TRUE; } if( isfunc == TRUE ) { temp->isfunc = TRUE; runner = name_from_func_type(temp->name); sprintf(buffer,"%s %s",temp->element_type,temp->name); temp->element_type = stringalloc(buffer); temp->name = runner; } if( strchr(temp->element_type,'*') != NULL) temp->isapointer = TRUE; } return TRUE; } void show_StructElement(StructElement * se,FILE * ofp) { fprintf(ofp,"Name [%s] Type [%s]\n",se->name,se->element_type); } void show_StructHolder(StructHolder * sh,FILE * ofp) { register int i; for(i=0;ilen;i++) show_StructElement(sh->el[i],ofp); } StructElement * basic_add_StructElement(StructHolder * sh,char * name,char * element) { StructElement * se; se = StructElement_alloc(); /* fprintf(stderr,"allocating %s %s\n",name,element); */ se->name = stringalloc(name); se->element_type = stringalloc(element); add_StructHolder(sh,se); return se; } %} wise-2.4.1/src/dyc/inputfile.c0000644000175000001440000000164210670453715015575 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "inputfile.h" static FILE * watch_file = NULL; static linecount = 0; # line 18 "inputfile.dy" boolean open_watch_file(FILE * ifp) { if( watch_file != NULL ) { warn("Can't watch a new file, already set!"); return FALSE; } watch_file = ifp; linecount = 0; return TRUE; } # line 30 "inputfile.dy" boolean close_watch_file(void) { if( watch_file == NULL ) { warn("No watch file to close"); return FALSE; } watch_file = NULL; return TRUE; } # line 41 "inputfile.dy" char * get_watched_line(char * buffer,int max,FILE * ifp) { if( ifp != watch_file) { warn("Trying to get a watched line without watching the file!"); return fgets(buffer,max,ifp); } linecount++; return fgets(buffer,max,ifp); } # line 52 "inputfile.dy" int get_watched_linecount(void) { return linecount; } # line 54 "inputfile.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/inputfile.h0000644000175000001440000000160010670453715015574 0ustar philippusers#ifndef DYNAMITEinputfileHEADERFILE #define DYNAMITEinputfileHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Unplaced functions */ /* There has been no indication of the use of these functions */ boolean open_watch_file(FILE * ifp); boolean close_watch_file(void); char * get_watched_line(char * buffer,int max,FILE * ifp); int get_watched_linecount(void); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/dynafunc.dy0000644000175000001440000022373210150376555015604 0ustar philippusers %{ #include "dynfile.h" #include "dyna2.h" #include "labelmaster.h" #include "linesubs.h" #include "dynashadow.h" #include "dynadb.h" #include "dpimpl.h" #include "dbthread.h" #include "probal.h" #include "dynadebug.h" %} %{ #include "dynafunc.h" void one_shot_aln_func(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { FuncInfo * fi; char * arg_str; char * chainstr; /*** prepare function information ***/ fi = FuncInfo_named_from_varstr(FI_CALLABLE,"PackAln_bestmemory_%s",gm->name); add_line_to_Ftext(fi->ft,"This function chooses the best memory set-up for the alignment",gm->name); add_line_to_Ftext(fi->ft,"using calls to basematrix, and then implements either a large"); add_line_to_Ftext(fi->ft,"or small memory model."); add_break_to_Ftext(fi->ft); add_line_to_Ftext(fi->ft,"It is the best function to use if you just want an alignment",gm->name); add_break_to_Ftext(fi->ft); add_line_to_Ftext(fi->ft,"If you want a label alignment, you will need"); add_line_to_Ftext(fi->ft,"/convert_PackAln_to_AlnBlock_%s",gm->name); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"PackAln * PackAln_bestmemory_%s(%s,DPEnvelope * dpenv,DPRunImpl * dpri)",gm->name,arg_str); /*** clean up ***/ ckfree(arg_str); chainstr= get_chainstr_GenericMatrix(gm); /** started function, now see what basematrix says about memory **/ expr(dfp,"long long total;"); expr(dfp,"%s * mat;",gm->name); expr(dfp,"PackAln * out;"); expr(dfp,"DebugMatrix * de"); expr(dfp,"DPRunImplMemory strategy;"); expr(dfp,"assert(dpri);"); add_break(dfp); expr(dfp,"total = %s->%s * %s->%s",gm->query->name,gm->query_len,gm->target->name,gm->target_len); expr(dfp,"if( dpri->memory == DPIM_Default ) "); startbrace(dfp); expr(dfp,"if( (total * %d * sizeof(int)) > 1000*dpri->kbyte_size)",gm->len); startbrace(dfp); expr(dfp,"strategy = DPIM_Linear;"); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"strategy = DPIM_Explicit;"); closebrace(dfp); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"strategy = dpri->memory;"); closebrace(dfp); add_break(dfp); expr(dfp,"if( dpenv != NULL )"); startbrace(dfp); expr(dfp,"if( strategy == DPIM_Explicit)"); startbrace(dfp); expr(dfp,"if( (mat=allocate_Expl_%s(%s,dpri)) == NULL )",gm->name,chainstr); startbrace(dfp); warn_expr(dfp,"Unable to allocate large %s version",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"calculate_dpenv_%s(mat,dpenv)",gm->name); expr(dfp,"out = PackAln_read_Expl_%s(mat);",gm->name); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"mat = allocate_%s_only(%s)",gm->name,chainstr); expr(dfp,"calculate_shatter_%s(mat,dpenv)",gm->name); expr(dfp,"out = PackAln_read_Shatter_%s(mat)",gm->name); closebrace(dfp); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"if( strategy == DPIM_Linear )",gm->len); startbrace(dfp); add_block_comment(dfp,"use small implementation"); expr(dfp,"if( (mat=allocate_Small_%s(%s)) == NULL )",gm->name,chainstr); startbrace(dfp); warn_expr(dfp,"Unable to allocate small %s version",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"out = PackAln_calculate_Small_%s(mat,dpenv)",gm->name); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); add_block_comment(dfp,"use Large implementation"); expr(dfp,"if( (mat=allocate_Expl_%s(%s,dpri)) == NULL )",gm->name,chainstr); startbrace(dfp); warn_expr(dfp,"Unable to allocate large %s version",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"if( dpri->debug == TRUE)"); startbrace(dfp); if( dpi->dydebug == TRUE ) { expr(dfp,"de = create_debug_%s();",gm->name); expr(dfp,"de->matrix = (void*) mat;"); expr(dfp,"explicit_debug_%s(de,0);",gm->name); expr(dfp,"out = PackAln_read_Expl_%s(mat);",gm->name); expr(dfp,"if( dpri->paldebug == TRUE ) "); hang_expr(dfp,"show_PackAln_Debug(de,out,stdout);"); expr(dfp,"free_DebugMatrix(de);"); } else { expr(dfp,"fatal(\"Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source\");"); } closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"calculate_%s(mat)",gm->name); expr(dfp,"out = PackAln_read_Expl_%s(mat);",gm->name); closebrace(dfp); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); ckfree(chainstr); } %func makes the recalculate packaln function %% void recalculate_PackAln_func(DYNFILE * dfp,const GenericMatrix * gm) { FuncInfo * fi; /* ArgInfo * ai; */ int i; int j; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"recalculate_PackAln_%s",gm->name); add_line_to_Ftext(fi->ft,"This function recalculates the PackAln structure produced by %s",gm->name); add_line_to_Ftext(fi->ft,"For example, in linear space methods this is used to score them",gm->name); start_function_FuncInfo(fi,dfp,"void recalculate_PackAln_%s(PackAln * pal,%s * mat)",gm->name,gm->name); expr(dfp,"int i,j,k,offi,offj;"); expr(dfp,"PackAlnUnit * prev;"); expr(dfp,"PackAlnUnit * pau;"); add_break(dfp); expr(dfp,"for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau)"); startbrace(dfp); expr(dfp,"pau = pal->pau[k];"); expr(dfp,"i = pau->i;"); expr(dfp,"j = pau->j;"); expr(dfp,"offi = pau->i - prev->i"); expr(dfp,"offj = pau->j - prev->j"); expr(dfp,"switch(pau->state)"); startbrace(dfp); for(i=0;ilen;i++) { expr(dfp,"case %s : ",gm->state[i]->name); startcase(dfp); /*** about to move to if statements... ***/ for(j=0;jstate[i]->len;j++) { if( gm->state[i]->source[j]->isspecial == TRUE) expr(dfp,"if( offj == %d && prev->state == (%s+%d) )",gm->state[i]->source[j]->offj,gm->state[i]->source[j]->state_source,gm->len); else expr(dfp,"if( offi == %d && offj == %d && prev->state == %s )",gm->state[i]->source[j]->offi,gm->state[i]->source[j]->offj,gm->state[i]->source[j]->state_source); startbrace(dfp); expr(dfp,"pau->score = %s + (%s)",gm->state[i]->source[j]->calc_expr,gm->state[i]->calc_expr == NULL ? "0" : gm->state[i]->calc_expr); expr(dfp,"continue;"); closebrace(dfp); } expr(dfp,"warn(\"In recaluclating PackAln with state %s, from [%%d,%%d,%%d], got a bad source state. Error!\",offi,offj,prev->state);",gm->state[i]->name); expr(dfp,"break;"); closecase(dfp); } for(i=0;ispec_len;i++) { expr(dfp,"case (%s+%d) : ",gm->special[i]->name,gm->len); startcase(dfp); for(j=0;jspecial[i]->len;j++) { if( gm->special[i]->source[j]->isspecial == TRUE) expr(dfp,"if( offj == %d && prev->state == (%s+%d) )",gm->special[i]->source[j]->offj,gm->special[i]->source[j]->state_source,gm->len); else expr(dfp,"if( offj == %d && prev->state == %s )",gm->special[i]->source[j]->offj,gm->special[i]->source[j]->state_source); startbrace(dfp); if( gm->special[i]->source[j]->isspecial == FALSE) { add_block_comment(dfp,"i here comes from the previous state ;) - not the real one"); expr(dfp,"i = prev->i;"); } expr(dfp,"pau->score = %s + (%s)",gm->special[i]->source[j]->calc_expr,gm->special[i]->calc_expr == NULL ? "0" : gm->special[i]->calc_expr); expr(dfp,"continue;"); closebrace(dfp); } warn_expr(dfp,"In recaluclating PackAln with state %s, got a bad source state. Error!",gm->special[i]->name); expr(dfp,"break;"); closecase(dfp); } expr(dfp,"default : "); startcase(dfp); warn_expr(dfp,"In recaluclating PackAln got a bad recipient state. Error!"); closecase(dfp); closebrace(dfp); /* end of switch on pau->state */ expr(dfp,"prev = pau;"); closebrace(dfp); expr(dfp,"return;"); close_function(dfp); } %func makes the allocate_Expl_xxx function. This calls allocate_xxx_only function (made by /write_safe_alloc_function) and then allocates basematrix stuff as well. %arg dfp dynamite file pointer gm r generic matrix structure %% void alloc_expl_func_GenericMatrix(DYNFILE * dfp,const GenericMatrix * gm) { FuncInfo * fi; char * arg_str; char * chain_str; /*** prepare function information ***/ fi = FuncInfo_named_from_varstr(FI_CALLABLE,"allocate_Expl_%s",gm->name); add_line_to_Ftext(fi->ft,"This function allocates the %s structure",gm->name); add_line_to_Ftext(fi->ft,"and the basematrix area for explicit memory implementations"); add_line_to_Ftext(fi->ft,"It calls /allocate_%s_only",gm->name); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"%s * allocate_Expl_%s(%s,DPRunImpl * dpri)",gm->name,gm->name,arg_str); /*** clean up ***/ ckfree(arg_str); /*** into function body ***/ expr(dfp,"%s * out;",gm->name); add_break(dfp); chain_str = get_chainstr_GenericMatrix(gm); expr(dfp,"out = allocate_%s_only(%s);",gm->name,chain_str); ckfree(chain_str); expr(dfp,"if( out == NULL )"); hang_expr(dfp,"return NULL;"); expr(dfp,"if( dpri->should_cache == TRUE )"); startbrace(dfp); expr(dfp,"if( dpri->cache != NULL )"); startbrace(dfp); expr(dfp,"if( dpri->cache->maxleni >= (out->lenj+%d)*%d && dpri->cache->maxlenj >= (out->leni+%d))",gm->window_j,gm->len,gm->window_i); hang_expr(dfp,"out->basematrix = hard_link_BaseMatrix(dpri->cache)"); expr(dfp,"else"); hang_expr(dfp,"dpri->cache = free_BaseMatrix(dpri->cache)"); closebrace(dfp); closebrace(dfp); expr(dfp,"if( out->basematrix == NULL )"); startbrace(dfp); expr(dfp,"if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+%d)*%d,(out->leni+%d),%d,out->lenj+%d)) == NULL)",gm->window_j,gm->len,gm->window_i,gm->spec_len,gm->window_j); startbrace(dfp); expr(dfp,"warn(\"Explicit matrix %s cannot be allocated, (asking for %%d by %%d main cells)\",out->leni,out->lenj);",gm->name); expr(dfp,"free_%s(out)",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); closebrace(dfp); expr(dfp,"if( dpri->should_cache == TRUE && dpri->cache == NULL)"); hang_expr(dfp,"dpri->cache = hard_link_BaseMatrix(out->basematrix)"); expr(dfp,"out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT;"); expr(dfp,"init_%s(out)",gm->name); expr(dfp,"return out"); close_function(dfp); add_break(dfp); } %func produces the allocate_xxx_only function, which allocates the matrix structure, checks resources which it can check, but does NOT allocate basematrix area This function will be called by allocate_Expl_xxxx and allocate_Small_xxxx etc. %arg dfp dynmaite file pointer to func/head gm generic matrix structure %% void write_safe_alloc_function(DYNFILE * dfp,GenericMatrix * gm) { int i; FuncInfo * fi; char * arg_str; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"allocate_%s_only",gm->name); add_line_to_Ftext(fi->ft,"This function only allocates the %s structure",gm->name); add_line_to_Ftext(fi->ft,"checks types where possible and determines leni and lenj"); add_line_to_Ftext(fi->ft,"The basematrix area is delt with elsewhere"); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"%s * allocate_%s_only(%s)",gm->name,gm->name,arg_str); /*** clean up ***/ ckfree(arg_str); expr(dfp,"%s * out",gm->name); add_break(dfp); expr(dfp,"if((out= %s_alloc()) == NULL)",gm->name); startbrace(dfp); warn_expr(dfp,"Allocation of basic %s structure failed...",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); expr(dfp,"out->%s = %s",gm->query->name,gm->query->name); expr(dfp,"out->%s = %s",gm->target->name,gm->target->name); for(i=0;ires_len;i++) { expr(dfp,"out->%s = %s",gm->resource[i]->name,gm->resource[i]->name); } expr(dfp,"out->leni = %s->%s",gm->query->name,gm->query_len); expr(dfp,"out->lenj = %s->%s",gm->target->name,gm->target_len); expr(dfp,"return out"); close_function(dfp); add_break(dfp); } %func Information partner to /get_argstr_GenericMatrix. Loads up the arglist information for the GenericMatrix, ie query-type query-name "what information" etc. %arg fi w FuncInfo structure to add ArgInfo to gm r generic matrix structure to read from %% boolean add_args_GenericMatrix_FuncInfo(FuncInfo * fi,const GenericMatrix * gm) { int i; ArgInfo * ai; /** ArgInfo_in_FuncInfo_from_varstr automatically adds ai to fi **/ ai = ArgInfo_in_FuncInfo_from_varstr(fi,gm->query->name); ai->desc=stringalloc("query data structure"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,gm->target->name); ai->desc=stringalloc("target data structure"); for(i=0;ires_len;i++) { ai = ArgInfo_in_FuncInfo_from_varstr(fi,gm->resource[i]->name); ai->desc=stringalloc("Resource"); } return TRUE; } %func makes an the argument calling string which is compatible with the arg_str from /get_argstr_GenericMatrix eg "query,target,comp_mat" %arg gm r structure holding generic matrix return allocated string (must free) with chained-args %% char * get_chainstr_GenericMatrix(const GenericMatrix * gm) { char buffer[MAXLINE]; int i; sprintf(buffer,"%s, %s ",gm->query->name,gm->target->name); for(i=0;ires_len;i++) { strcat(buffer,", "); strcat(buffer,gm->resource[i]->name); } return stringalloc(buffer); } %func makes the argument list for a generic matrix alloc, ie query-type query-name,target-type target-name etc To load up info, use /add_arg_GenericMatrix_FuncInfo To chain up along function calls, use /get_chainstr_GenericMatrix %arg gm r structure holding generic matrix return allocated string (must free) with args %% char * get_argstr_GenericMatrix(const GenericMatrix * gm) { char buffer[MAXLINE]; int i; sprintf(buffer,"%s %s,%s %s ",gm->query->element_type,gm->query->name,gm->target->element_type,gm->target->name); for(i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,gm->resource[i]->element_type); strcat(buffer," "); strcat(buffer,gm->resource[i]->name); } return stringalloc(buffer); } void write_dotter_dump(DYNFILE * dfp,GenericMatrix * gm) { start_function(dfp,"void dump_dotter_%s(%s * mat,FILE * ofp)",gm->name,gm->name); expr(dfp,"register int i"); expr(dfp,"register int j"); expr(dfp,"register int k"); expr(dfp,"int hlen"); expr(dfp,"int vlen"); expr(dfp,"char form = 1;"); expr(dfp,"int zoom = 1;"); expr(dfp,"register int max = (-1000000)"); /*** expr(dfp,"fprintf(ofp,\"fileformat 1\\nzoomfactor 10\\nhorizontal_len %%d\\nvertical_len %%d\\n\",mat->%s->%s + (4-((mat->%s->%s)%%4)),mat->%s->%s + (4-((mat->%s->%s)%%4)));", gm->query->name,gm->query_len,gm->query->name,gm->query_len,gm->target->name,gm->target_len,gm->target->name,gm->target_len); ***/ expr(dfp,"hlen = mat->%s->%s",gm->query->name,gm->query_len); expr(dfp,"if( hlen%%4 != 0 ) "); hang_expr(dfp,"hlen += 4 - hlen%%4;"); expr(dfp,"vlen = mat->%s->%s",gm->target->name,gm->target_len); expr(dfp,"if( vlen%%4 != 0 ) "); hang_expr(dfp,"vlen += 4 - hlen%%4;"); expr(dfp,"fwrite(&form,sizeof(char),1,ofp)"); expr(dfp,"fwrite(&zoom,sizeof(int),1,ofp)"); expr(dfp,"fwrite(&hlen,sizeof(int),1,ofp)"); expr(dfp,"fwrite(&vlen,sizeof(int),1,ofp)"); expr(dfp,"for(i=0;i%s->%s;i++)",gm->query->name,gm->query_len); startbrace(dfp); expr(dfp,"for(j=0;j%s->%s;j++)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"if( %s_EXPL_MATRIX(mat,i,j,1) > max )",gm->name); expr(dfp,"max = %s_EXPL_MATRIX(mat,i,j,1)",gm->name); closebrace(dfp); closebrace(dfp); expr(dfp,"for(i=0;i%s->%s;i++)",gm->query->name,gm->query_len); startbrace(dfp); expr(dfp,"for(j=0;j%s->%s;j++)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"fputc( (char) (%s_EXPL_MATRIX(mat,i,j,1)*256 / max),ofp )",gm->name); closebrace(dfp); closebrace(dfp); close_function(dfp); } void write_memory_macros(DYNFILE * dfp,GenericMatrix * gm) { register int i; for(i=0;ilen;i++) macro(dfp,"#define %s %d",gm->state[i]->name,i); add_break(dfp); for(i=0;ispec_len;i++) macro(dfp,"#define %s %d",gm->special[i]->name,i); add_break(dfp); macro(dfp,"#define %s_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+%d)*%d)+STATE][i+%d]",gm->name,gm->window_j,gm->len,gm->window_i); macro(dfp,"#define %s_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+%d]",gm->name,gm->window_j); macro(dfp,"#define %s_READ_OFF_ERROR -%d\n",gm->name,gm->window_i+gm->window_j+1); add_break(dfp); } void write_search_macros(DYNFILE * dfp,const GenericMatrix * gm,DPImplementation * dpi) { if(gm->qtype != NULL && gm->qtype->maxlen != NULL) { macro(dfp,"#define %s_VSMALL_MATRIX(mat,i,j,STATE) internal_matrix[(j+%d)%%%d][((i+%d)*%d)+STATE]",gm->name,gm->window_j+1,gm->window_j+1,gm->window_i,gm->len); macro(dfp,"#define %s_VSMALL_SPECIAL(mat,i,j,STATE) internal_specials[(j+%d)%%%d][STATE]",gm->name,gm->window_j+1,gm->window_j+1); } else { if( dpi->largemem == TRUE ) { macro(dfp,"#define %s_VSMALL_MATRIX(mat,i,j,STATE) internal_pointer_db[((j+%d)%%%d * (mat->leni+%d) * %d) +((i+%d)*%d)+STATE]",gm->name,gm->window_j+1,gm->window_j+1,gm->window_i,gm->len,gm->window_i,gm->len); macro(dfp,"#define %s_VSMALL_SPECIAL(mat,i,j,STATE) internal_special_db[((j+%d)%%%d * %d)+ STATE]",gm->name,gm->window_j+1,gm->window_j+1,gm->spec_len); } else { macro(dfp,"#define %s_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+%d)%%%d][((i+%d)*%d)+STATE]",gm->name,gm->window_j+1,gm->window_j+1,gm->window_i,gm->len); macro(dfp,"#define %s_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+%d)%%%d][STATE]",gm->name,gm->window_j+1,gm->window_j+1); } } add_break(dfp); } void write_expl_access_funcs(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"%s_explicit_access_main",gm->name); start_function_FuncInfo(fi,dfp,"int %s_explicit_access_main(%s * mat,int i,int j,int state)",gm->name,gm->name); expr(dfp,"return %s_EXPL_MATRIX(mat,i,j,state);",gm->name); close_function(dfp); add_break(dfp); fi = FuncInfo_named_from_varstr(FI_INTERNAL,"%s_explicit_access_special",gm->name); start_function_FuncInfo(fi,dfp,"int %s_explicit_access_special(%s * mat,int i,int j,int state)",gm->name,gm->name); expr(dfp,"return %s_EXPL_SPECIAL(mat,i,j,state);",gm->name); close_function(dfp); add_break(dfp); } void write_expl_read_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"PackAln_read_Expl_%s",gm->name); add_line_to_Ftext(fi->ft,"Reads off PackAln from explicit matrix structure",gm->name); start_function_FuncInfo(fi,dfp,"PackAln * PackAln_read_Expl_%s(%s * mat)",gm->name,gm->name); expr(dfp,"%s_access_func_holder holder",gm->name); add_break(dfp); expr(dfp,"holder.access_main = %s_explicit_access_main;",gm->name); expr(dfp,"holder.access_special = %s_explicit_access_special;",gm->name); expr(dfp,"return PackAln_read_generic_%s(mat,holder);",gm->name); close_function(dfp); add_break(dfp); } void write_basic_read_func(DYNFILE * dfp,GenericMatrix * gm) { register int i; register int st; FuncInfo * fi; for(i=0;ispec_len;i++) if( gm->special[i]->is_start == TRUE ) break; if( i >= gm->spec_len ) log_full_error(FATAL,0,"Cannot make matrix with no !start state (must be a special)"); st = i; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"PackAln_read_generic_%s",gm->name); add_line_to_Ftext(fi->ft,"Reads off PackAln from explicit matrix structure",gm->name); start_function_FuncInfo(fi,dfp,"PackAln * PackAln_read_generic_%s(%s * mat,%s_access_func_holder h)",gm->name,gm->name,gm->name); expr(dfp,"register PackAln * out;"); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int state;"); expr(dfp,"int cellscore = (-1);"); expr(dfp,"boolean isspecial"); expr(dfp,"PackAlnUnit * pau = NULL;"); expr(dfp,"PackAlnUnit * prev = NULL;"); add_break(dfp); expr(dfp,"assert(mat)"); expr(dfp,"assert(h.access_main)"); expr(dfp,"assert(h.access_special)"); add_break(dfp); expr(dfp,"out = PackAln_alloc_std()"); expr(dfp,"if( out == NULL )"); hang_expr(dfp,"return NULL;"); add_break(dfp); /*** Find the end of the matrix ***/ expr(dfp,"out->score = find_end_%s(mat,&i,&j,&state,&isspecial,h);",gm->name); add_break(dfp); add_block_comment(dfp,"Add final end transition (at the moment we have not got the score!"); expr(dfp,"if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE )"); startbrace(dfp); expr(dfp,"warn(\"Failed the first PackAlnUnit alloc, %%d length of Alignment in %s_basic_read, returning a mess.(Sorry!)\",out->len);",gm->name); expr(dfp,"return out;"); closebrace(dfp); add_break(dfp); /** put in numbers from block **/ add_block_comment(dfp,"Put in positions for end trans. Remember that coordinates in C style"); expr(dfp,"pau->i = i;"); expr(dfp,"pau->j = j;"); expr(dfp,"if( isspecial != TRUE) "); hang_expr(dfp,"pau->state = state;"); expr(dfp,"else pau->state = state + %d",gm->len); /*** expr(dfp,"pau->score = cellscore"); ***/ expr(dfp,"prev=pau;"); /**** do the loop ****/ /*** expr(dfp,"start_reporting(\"Alignment [Score %%d]:\",out->score);"); ***/ expr(dfp,"while( state != %s || isspecial != TRUE)",gm->special[st]->name); startbrace_tag(dfp,"while state != START"); add_break(dfp); expr(dfp,"if( isspecial == TRUE )"); hang_expr(dfp,"max_calc_special_%s(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h)",gm->name); expr(dfp,"else"); hang_expr(dfp,"max_calc_%s(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h)",gm->name); /*** check we haven't boobied ***/ expr(dfp,"if(i == %s_READ_OFF_ERROR || j == %s_READ_OFF_ERROR || state == %s_READ_OFF_ERROR )",gm->name,gm->name,gm->name); startbrace(dfp); expr(dfp,"warn(\"Problem - hit bad read off system, exiting now\");"); expr(dfp,"break;"); closebrace(dfp); /** allocate position **/ expr(dfp,"if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE )"); startbrace(dfp); expr(dfp,"warn(\"Failed a PackAlnUnit alloc, %%d length of Alignment in %s_basic_read, returning partial alignment\",out->len);",gm->name); expr(dfp,"break;"); closebrace(dfp); add_break(dfp); /** put in numbers from block **/ add_block_comment(dfp,"Put in positions for block. Remember that coordinates in C style"); expr(dfp,"pau->i = i;"); expr(dfp,"pau->j = j;"); expr(dfp,"if( isspecial != TRUE) "); hang_expr(dfp,"pau->state = state;"); expr(dfp,"else pau->state = state + %d",gm->len); expr(dfp,"prev->score = cellscore"); expr(dfp,"prev = pau;"); closebrace(dfp); /**** Add in alignment flips (or do I need to do that later!) ****/ add_break(dfp); /*** expr(dfp,"stop_reporting()"); ***/ expr(dfp,"invert_PackAln(out);"); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } void write_pal_to_ars_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"AlnRangeSet_from_PackAln_%s",gm->name); add_line_to_Ftext(fi->ft,"Converts a PackAln (full alignment) to start/stop range"); add_line_to_Ftext(fi->ft,"The point being that you may have the PackAln and someone wants a range",gm->name); start_function_FuncInfo(fi,dfp,"AlnRangeSet * AlnRangeSet_from_PackAln_%s(PackAln * pal)",gm->name); expr(dfp,"int unit;"); expr(dfp,"int cum_score = 0;"); expr(dfp,"AlnRangeSet * out;"); expr(dfp,"AlnRange * temp;"); add_break(dfp); expr(dfp,"out = AlnRangeSet_alloc_std();"); expr(dfp,"for(unit = 0;unit < pal->len;unit++)"); startbrace_tag(dfp,"while there are more units"); expr(dfp,"cum_score += pal->pau[unit]->score;"); expr(dfp,"if( pal->pau[unit]->state < %d)",gm->len); startbrace(dfp); add_block_comment(dfp,"It is out of the specials"); expr(dfp,"temp = AlnRange_alloc();"); expr(dfp,"temp->starti = pal->pau[unit]->i;"); expr(dfp,"temp->startj = pal->pau[unit]->j;"); expr(dfp,"temp->startstate = pal->pau[unit]->state;"); expr(dfp,"temp->startscore = cum_score;"); expr(dfp,"for(;unit < pal->len && pal->pau[unit]->state < %d;unit++)",gm->len); hang_expr(dfp,"cum_score += pal->pau[unit]->score;"); expr(dfp,"temp->stopi = pal->pau[unit-1]->i;"); expr(dfp,"temp->stopj = pal->pau[unit-1]->j;"); expr(dfp,"temp->stopstate = pal->pau[unit-1]->state;"); expr(dfp,"temp->stopscore = cum_score;"); expr(dfp,"add_AlnRangeSet(out,temp)"); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"return out"); close_function(dfp); add_break(dfp); } void write_alncconvert_make_func(DYNFILE * dfp,GenericMatrix * gm) { int i; int j; LabelMaster * lm; char * qs; char * ts; int qlabel; int tlabel; FuncInfo * fi; lm = LabelMaster_from_GenericMatrix(gm); qs = query_quoted_string_from_LabelMaster(lm); ts = target_quoted_string_from_LabelMaster(lm); expr(dfp," static char * query_label[] = { %s };",qs); expr(dfp," static char * target_label[] = { %s };",ts); ckfree(qs); ckfree(ts); fi = FuncInfo_named_from_varstr(FI_INTERNAL,"AlnConvertSet_%s",gm->name); start_function_FuncInfo(fi,dfp,"AlnConvertSet * AlnConvertSet_%s(void)",gm->name); expr(dfp,"AlnConvertUnit * acu;"); expr(dfp,"AlnConvertSet * out;"); add_break(dfp); expr(dfp,"out = AlnConvertSet_alloc_std();"); add_break(dfp); for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { qlabel = index_for_query_label(gm->state[i]->source[j]->query_label,lm); if( qlabel == (-1) ) { warn("Query label [%s] unfound. Consider this a bad compiler bug!",gm->state[i]->source[j]->query_label); qlabel = 0; } tlabel = index_for_target_label(gm->state[i]->source[j]->target_label,lm); if( tlabel == (-1) ) { warn("Query label [%s] unfound. Consider this a bad compiler bug!",gm->state[i]->source[j]->target_label); tlabel = 0; } expr(dfp,"acu = AlnConvertUnit_alloc();"); expr(dfp,"add_AlnConvertSet(out,acu);"); if( gm->state[i]->source[j]->isspecial == FALSE ) { expr(dfp,"acu->state1 = %s;",gm->state[i]->source[j]->state_source); } else { expr(dfp,"acu->state1 = %s + %d;",gm->state[i]->source[j]->state_source,gm->len); expr(dfp,"acu->is_from_special = TRUE;"); } expr(dfp,"acu->state2 = %s",gm->state[i]->name); if( gm->state[i]->source[j]->isspecial == FALSE ) expr(dfp,"acu->offi = %d;",gm->state[i]->source[j]->offi); else expr(dfp,"acu->offi = (-1);"); expr(dfp,"acu->offj = %d;",gm->state[i]->source[j]->offj); expr(dfp,"acu->label1 = query_label[%d];",qlabel); expr(dfp,"acu->label2 = target_label[%d];",tlabel); } } for(i=0;ispec_len;i++) { for(j=0;jspecial[i]->len;j++) { qlabel = index_for_query_label(gm->special[i]->source[j]->query_label,lm); if( qlabel == (-1) ) { warn("Query label [%s] unfound. Consider this a bad compiler bug!",gm->special[i]->source[j]->query_label); qlabel = 0; } tlabel = index_for_target_label(gm->special[i]->source[j]->target_label,lm); if( tlabel == (-1) ) { warn("Query label [%s] unfound. Consider this a bad compiler bug!",gm->special[i]->source[j]->target_label); tlabel = 0; } expr(dfp,"acu = AlnConvertUnit_alloc();"); expr(dfp,"add_AlnConvertSet(out,acu);"); if( gm->special[i]->source[j]->isspecial == FALSE ) expr(dfp,"acu->state1 = %s;",gm->special[i]->source[j]->state_source); else expr(dfp,"acu->state1 = %s + %d;",gm->special[i]->source[j]->state_source,gm->len); expr(dfp,"acu->state2 = %s + %d",gm->special[i]->name,gm->len); expr(dfp,"acu->offi = (-1);"); expr(dfp,"acu->offj = %d;",gm->special[i]->source[j]->offj); expr(dfp,"acu->label1 = query_label[%d];",qlabel); expr(dfp,"acu->label2 = target_label[%d];",tlabel); } } for(i=0;ical_len;i++) { expr(dfp,"add_collapse_label_AlnConvertSet(out,\"%s\",\"%s\");",gm->cal[i]->query,gm->cal[i]->target); } expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } void write_aln_conversion_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"convert_PackAln_to_AlnBlock_%s",gm->name); add_line_to_Ftext(fi->ft,"Converts a path alignment to a label alignment"); add_line_to_Ftext(fi->ft,"The label alignment is probably much more useful than the path",gm->name); start_function_FuncInfo(fi,dfp,"AlnBlock * convert_PackAln_to_AlnBlock_%s(PackAln * pal)",gm->name,gm->name); expr(dfp,"AlnConvertSet * acs;"); expr(dfp,"AlnBlock * alb;"); add_break(dfp); expr(dfp,"acs = AlnConvertSet_%s();",gm->name); expr(dfp,"alb = AlnBlock_from_PackAln(acs,pal);"); expr(dfp,"free_AlnConvertSet(acs);"); expr(dfp,"return alb;"); close_function(dfp); add_break(dfp); } %func init explicit matrix %% void init_matrix_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; ArgInfo * ai; register int i; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"init_%s",gm->name); add_line_to_Ftext(fi->ft,"This function initates %s matrix when in explicit mode",gm->name); add_line_to_Ftext(fi->ft,"Called in /allocate_Expl_%s",gm->name); /** ArgInfo_in_FuncInfo_from_varstr automatically adds ai to fi **/ ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); ai->desc=stringallocf("%s which contains explicit basematrix memory",gm->name); start_function_FuncInfo(fi,dfp,"void init_%s(%s * mat)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT)"); startbrace(dfp); warn_expr(dfp,"Cannot iniate matrix, is not an explicit memory type and you have assummed that"); expr(dfp,"return"); closebrace(dfp); add_break(dfp); expr(dfp,"for(i= (-%d);i%s->%s;i++)",gm->window_i,gm->query->name,gm->query_len); startbrace(dfp); expr(dfp,"for(j= (-%d);j<%d;j++)",gm->window_j,gm->window_j+1); startbrace(dfp); for(i=0;ilen;i++) { expr(dfp,"%s_EXPL_MATRIX(mat,i,j,%s) = %s;",gm->name,gm->state[i]->name,gm->state[i]->def_score); } closebrace(dfp); closebrace(dfp); expr(dfp,"for(j= (-%d);j%s->%s;j++)",gm->window_j,gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"for(i= (-%d);i<%d;i++)",gm->window_i,gm->window_i+1); startbrace(dfp); for(i=0;ilen;i++) { expr(dfp,"%s_EXPL_MATRIX(mat,i,j,%s) = %s;",gm->name,gm->state[i]->name,gm->state[i]->def_score); } closebrace(dfp); for(i=0;ispec_len;i++) { expr(dfp,"%s_EXPL_SPECIAL(mat,i,j,%s) = %s;",gm->name,gm->special[i]->name,gm->special[i]->def_score); } closebrace(dfp); expr(dfp,"return"); close_function(dfp); add_break(dfp); } void find_end_func(DYNFILE * dfp,GenericMatrix * gm) { register int i; FuncInfo * fi; for(i=0;ispec_len;i++) if( gm->special[i]->is_end == TRUE) break; if( i >= gm->spec_len ) { log_full_error(WARNING,0,"Cannot build find end function due to lack of end state"); return; } fi = FuncInfo_named_from_varstr(FI_INTERNAL,"find_end_%s",gm->name); start_function_FuncInfo(fi,dfp,"int find_end_%s(%s * mat,int * ri,int * rj,int * state,boolean * isspecial,%s_access_func_holder h)",gm->name,gm->name,gm->name); expr(dfp,"int j"); expr(dfp,"int max;"); expr(dfp,"int maxj"); expr(dfp,"int temp"); add_break(dfp); expr(dfp,"max = (*h.access_special)(mat,0,mat->%s->%s-1,%s);",gm->target->name,gm->target_len,gm->special[i]->name); expr(dfp,"maxj = mat->%s->%s-1",gm->target->name,gm->target_len); expr(dfp,"for(j= mat->%s->%s-2 ;j >= 0 ;j--)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"if( (temp =(*h.access_special)(mat,0,j,%s)) > max )",gm->special[i]->name); startbrace(dfp); expr(dfp,"max = temp;"); expr(dfp,"maxj = j;"); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"if( ri != NULL)"); hang_expr(dfp," *ri = 0; "); expr(dfp,"if( rj != NULL)"); hang_expr(dfp," *rj = maxj; "); expr(dfp,"if( state != NULL)"); hang_expr(dfp," *state = %s;",gm->special[i]->name); expr(dfp,"if( isspecial != NULL)"); hang_expr(dfp," *isspecial = TRUE;"); add_break(dfp); expr(dfp,"return max"); close_function(dfp); add_break(dfp); } void debug_func(DYNFILE * dfp,GenericMatrix * gm) { register int i; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"%s_debug_show_matrix",gm->name); start_function_FuncInfo(fi,dfp,"void %s_debug_show_matrix(%s * mat,int starti,int stopi,int startj,int stopj,FILE * ofp)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); add_break(dfp); expr(dfp,"for(i=starti;i%s->%s;i++)",gm->query->name,gm->query_len); startbrace(dfp); expr(dfp,"for(j=startj;j%s->%s;j++)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"fprintf(ofp,\"Cell [%%d - %%d]\\n\",i,j)"); for(i=0;ilen;i++) expr(dfp,"fprintf(ofp,\"State %s %%d\\n\",%s_EXPL_MATRIX(mat,i,j,%s));",gm->state[i]->name,gm->name,gm->state[i]->name); expr(dfp,"fprintf(ofp,\"\\n\\n\");"); closebrace(dfp); closebrace(dfp); add_break(dfp); close_function(dfp); add_break(dfp); return; } void write_special_max_calc_func_debug(DYNFILE * dfp,GenericMatrix * gm,int debug) { register int i; register int j; FuncInfo * fi; char * matrix_tag = "EXPL_MATRIX"; char * special_tag = "EXPL_SPECIAL"; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"max_calc_special_%s",gm->name); start_function_FuncInfo(fi,dfp,"int max_calc_special_%s(%s * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,%s_access_func_holder h)",gm->name,gm->name,gm->name); expr(dfp,"register int temp;"); expr(dfp,"register int cscore;"); add_break(dfp); expr(dfp,"*reti = (*retj) = (*retstate) = %s_READ_OFF_ERROR;",gm->name); add_break(dfp); expr(dfp,"if( j < 0 || j > mat->%s->%s)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"warn(\"In %s matrix special read off - out of bounds on matrix [j is %%d in special]\",j);",gm->name); expr(dfp,"return -1"); closebrace(dfp); add_break(dfp); expr(dfp,"cscore = (*h.access_special)(mat,i,j,state);"); if( debug) expr(dfp,"fprintf(stderr,\"Looking for score %%d\\n\",cscore);"); expr(dfp,"switch(state)"); startbrace_tag(dfp,"switch on special states"); for(i=0;ispec_len;i++) { auto CellState * cell; cell = gm->special[i]; expr(dfp,"case %s : ",cell->name); startcase(dfp); /*** ok, this is a problem. probably should do special to special first, ***/ /*** the others. Hmmm.,.. ***/ for(j=cell->len-1;j>=0;j--) { if( cell->source[j]->isspecial == FALSE ) { add_block_comment(dfp,"source %s is from main matrix",cell->source[j]->state_source); expr(dfp,"for(i= mat->%s->%s-1;i >= 0 ;i--)",gm->query->name,gm->query_len); startbrace_tag(dfp,"for i >= 0"); expr(dfp,"temp = cscore - (%s) - (%s)",cell->source[j]->calc_expr, cell->calc_expr == NULL ? "0" : cell->calc_expr); if( debug ) expr(dfp,"fprintf(stderr,\"Trying %%d for case %s\\n\",temp)",cell->source[j]->state_source); expr(dfp,"if( temp == (*h.access_main)(mat,i - %d,j - %d,%s) )",cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); startbrace(dfp); expr(dfp,"*reti = i - %d;",cell->source[j]->offi); expr(dfp,"*retj = j - %d;",cell->source[j]->offj); expr(dfp,"*retstate = %s;",cell->source[j]->state_source); if( cell->source[j]->isspecial == TRUE) expr(dfp,"*retspecial = TRUE;"); else expr(dfp,"*retspecial = FALSE;"); /*** if they want the score, calc the difference in the number and give it back ***/ expr(dfp,"if( cellscore != NULL)"); startbrace(dfp); expr(dfp,"*cellscore = cscore - (*h.access_main)(mat,i-%d,j-%d,%s)",cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); expr(dfp,"return (*h.access_main)(mat,i - %d,j - %d,%s) ",cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); closebrace(dfp); /** this closes the for brace ***/ } else { add_block_comment(dfp,"source %s is a special",cell->source[j]->state_source); expr(dfp,"temp = cscore - (%s) - (%s)",cell->source[j]->calc_expr, cell->calc_expr == NULL ? "0" : cell->calc_expr); if( debug ) expr(dfp,"fprintf(stderr,\"Trying %%d for case %s\\n\",temp)",cell->source[j]->state_source); expr(dfp,"if( temp == (*h.access_special)(mat,i - %d,j - %d,%s) )",cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); startbrace(dfp); expr(dfp,"*reti = i - %d;",cell->source[j]->offi); expr(dfp,"*retj = j - %d;",cell->source[j]->offj); expr(dfp,"*retstate = %s;",cell->source[j]->state_source); if( cell->source[j]->isspecial == TRUE) expr(dfp,"*retspecial = TRUE;"); else expr(dfp,"*retspecial = FALSE;"); /*** if they want the score, calc the difference in the number and give it back ***/ expr(dfp,"if( cellscore != NULL)"); startbrace(dfp); expr(dfp,"*cellscore = cscore - (*h.access_special)(mat,i-%d,j-%d,%s)",cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); expr(dfp,"return (*h.access_special)(mat,i - %d,j - %d,%s) ",cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); } } closecase(dfp); } expr(dfp,"default:"); startcase(dfp); expr(dfp,"warn(\"Major problem (!) - in %s read off, position %%d,%%d state %%d no source found dropped into default on source switch!\",i,j,state);",gm->name); expr(dfp,"return (-1);"); closecase(dfp); closebrace(dfp); close_function(dfp); add_break(dfp); } void write_special_max_calc_func(DYNFILE * dfp,GenericMatrix * gm) { write_special_max_calc_func_debug(dfp,gm,0); } /**** This function requires alot of stuff assummed. int * reti, int *retj and *retstate *retspecial as parameters which will be set by this block. This block is really to facillate different underlying memory structures which can be used. Please see functions write_max_calc_func and write_hidden_max_func (dynashadow.dy) to see how it is used ***/ void write_max_calc_block(DYNFILE * dfp,GenericMatrix * gm,char * matrix_tag,char * special_tag,boolean use_special,boolean use_holder) { register int i; register int j; char matrix_access[128]; char special_access[128]; if( use_holder == TRUE ) { sprintf(matrix_access,"(*h.access_main)"); sprintf(special_access,"(*h.access_special)"); } else { sprintf(matrix_access,"%s_%s",gm->name,matrix_tag); sprintf(special_access,"%s_%s",gm->name,special_tag); } add_break(dfp); add_block_comment(dfp,"Then you have to select the correct switch statement to figure out the readoff "); add_block_comment(dfp,"Somewhat odd - reverse the order of calculation and return as soon as it is correct"); expr(dfp,"cscore = %s(mat,i,j,state);",matrix_access); expr(dfp,"switch(state)"); startbrace_tag(dfp,"Switch state "); for(i=0;ilen;i++) { auto CellState * cell; cell = gm->state[i]; expr(dfp,"case %s : ",cell->name); startcase(dfp); for(j=cell->len-1;j>=0;j--) { if( use_special == FALSE && cell->source[j]->isspecial == TRUE ) { add_block_comment(dfp,"Not allowing special sources.. skipping %s",cell->source[j]->state_source); continue; } if( cell->source[j]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(cell->source[j]->position,cell->source[j]->offi,cell->source[j]->offj)); startbrace(dfp); } expr(dfp,"temp = cscore - (%s) - (%s);",cell->source[j]->calc_expr, cell->calc_expr == NULL ? "0" : cell->calc_expr); if( cell->source[j]->isspecial == TRUE) expr(dfp,"if( temp == %s(mat,i - %d,j - %d,%s) )",special_access,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); else expr(dfp,"if( temp == %s(mat,i - %d,j - %d,%s) )",matrix_access,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); startbrace(dfp); expr(dfp,"*reti = i - %d;",cell->source[j]->offi); expr(dfp,"*retj = j - %d;",cell->source[j]->offj); expr(dfp,"*retstate = %s;",cell->source[j]->state_source); if( cell->source[j]->isspecial == TRUE) expr(dfp,"*retspecial = TRUE;"); else expr(dfp,"*retspecial = FALSE;"); /*** if they want the score, calc the difference in the number and give it back ***/ expr(dfp,"if( cellscore != NULL)"); startbrace(dfp); expr(dfp,"*cellscore = cscore - %s(mat,i-%d,j-%d,%s);", cell->source[j]->isspecial == TRUE ? special_access : matrix_access,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); expr(dfp,"return %s(mat,i - %d,j - %d,%s); ",matrix_access,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); if( cell->source[j]->position != SOURCE_POS_ALL) { closebrace(dfp); } closebrace(dfp); } expr(dfp,"warn(\"Major problem (!) - in %s read off, position %%d,%%d state %%d no source found!\",i,j,state);",gm->name); expr(dfp,"return (-1);"); closecase(dfp); } expr(dfp,"default:"); startcase(dfp); expr(dfp,"warn(\"Major problem (!) - in %s read off, position %%d,%%d state %%d no source found!\",i,j,state);",gm->name); expr(dfp,"return (-1);"); closecase(dfp); closebrace(dfp); } void write_max_calc_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"max_calc_%s",gm->name); start_function_FuncInfo(fi,dfp,"int max_calc_%s(%s * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,%s_access_func_holder h)",gm->name,gm->name,gm->name); expr(dfp,"register int temp;"); expr(dfp,"register int cscore;"); add_break(dfp); expr(dfp,"*reti = (*retj) = (*retstate) = %s_READ_OFF_ERROR;",gm->name); add_break(dfp); expr(dfp,"if( i < 0 || j < 0 || i > mat->%s->%s || j > mat->%s->%s)",gm->query->name, gm->query_len,gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"warn(\"In %s matrix special read off - out of bounds on matrix [i,j is %%d,%%d state %%d in standard matrix]\",i,j,state);",gm->name); expr(dfp,"return -1"); closebrace(dfp); write_max_calc_block(dfp,gm,"EXPL_MATRIX","EXPL_SPECIAL",TRUE,TRUE); close_function(dfp); add_break(dfp); return; } static char source_buffer[125]; char * source_allowed_statement(int position,int offi,int offj) { switch(position) { case SOURCE_POS_ALL : warn("Bad point in source to - you have an ALL source positions. Hmmmmm"); return "1"; case SOURCE_POS_TOPLEFT : sprintf(source_buffer,"(i-%d) == 0 && (j-%d) == 0",offi,offj); return source_buffer; case SOURCE_POS_TOP : sprintf(source_buffer,"(i-%d) == 0 ",offi); return source_buffer; case SOURCE_POS_LEFT : sprintf(source_buffer,"(j-%d) == 0 ",offj); return source_buffer; case SOURCE_POS_RIGHT : return "j == mat->lenj-1"; case SOURCE_POS_BOTTOM : return "i == mat->leni-1"; case SOURCE_POS_BOTTOMRIGHT : return "i == mat->leni-1 && j == mat->lenj-1"; default : warn("Bad error, got an impossible source position %d",position); return("1"); } } void write_score_block_debug(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointertag,char * specialtag,boolean use_special,int debug) { register int i; register int j; register int k; for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; add_break(dfp); if( state->footprint_start > 1 || state->footprint_end < 0) { add_block_comment(dfp,"State %s has a footprint of %d - %d",state->name,state->footprint_start,state->footprint_end); expr(dfp,"if( SEQENDWITHIN(%d) != TRUE || SEQSTARTWITHIN(%d) != TRUE )",state->footprint_end,state->footprint_start); startbrace_tag(dfp,"Footprint exists"); } add_block_comment(dfp,"For state %s",state->name); add_block_comment(dfp,"setting first movement to score",state->name); if( state->source[0]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(state->source[0]->position,state->source[0]->offi,state->source[0]->offj)); startbrace(dfp); } /*********************************************************************/ /* this line looks like */ /* score = ProteinMatrix_EXPL_MATRIX(mat,i-1,j-1,MATCH) + xxxxx */ /*********************************************************************/ expr(dfp,"score = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,matrixtag,pointertag, state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source, state->source[0]->calc_expr); if( state->source[0]->isspecial == TRUE ) { fatal("Cannot have a special to matrix transition as the first transition"); } if( state->source[0]->position != SOURCE_POS_ALL) { closebrace(dfp); } if( dfp->code_debug_level > 5) { expr(dfp,"if( score > IMPOSSIBLY_HIGH_SCORE )"); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] State %s source %s Impossibly high score [%%d]\",i,j,score);",state->name,state->source[0]->state_source); } if( dfp->code_debug_level > 100 ) { expr(dfp,"fprintf(stderr,\"MATRIX: [%%4d][%%4d] State %s source %s got score %%d\\n\",i,j,score);",state->name,state->source[0]->state_source); } /**** ok this is to stop underflow, but is v.v.v. hacky ****/ /*** removing underflow hack expr(dfp,"if(score < (-10000000) )"); hang_expr(dfp,"score = (-10000000)"); ****/ if( debug == 2) expr(dfp,"fprintf(stderr,\"[%%4d,%%4d] First score of %s gets %%d\\n\",i,j,score)",state->name); /****************************************/ /* now we do if then on score and temp */ /****************************************/ for(j=1;jlen;j++) { if( use_special == FALSE && state->source[j]->isspecial == TRUE ) continue; /** don't use the special! **/ if( state->source[j]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(state->source[j]->position,state->source[j]->offi,state->source[j]->offj)); startbrace(dfp); } add_block_comment(dfp,"From state %s to state %s",state->source[j]->state_source, state->name); if( state->source[j]->isspecial == TRUE ) expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,specialtag,pointertag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr); else expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,matrixtag,pointertag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr); if( dfp->code_debug_level > 5) { expr(dfp,"if( temp > IMPOSSIBLY_HIGH_SCORE )"); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] State %s source %s Impossibly high score [%%d]\",i,j,temp);",state->name,state->source[j]->state_source); } if( dfp->code_debug_level > 100 ) { expr(dfp,"fprintf(stderr,\"MATRIX: [%%4d][%%4d] State %s source %s got score %%d\\n\",i,j,temp);",state->name,state->source[0]->state_source); } /**** ok this is to stop underflow, but is v.v.v. hacky ****/ /**** removing underflow hack expr(dfp,"if(score < (-10000000) )"); hang_expr(dfp,"score = (-10000000)"); ****/ if( debug == 2 ) expr(dfp,"fprintf(stderr,\"[%%4d,%%4d] Score of %s from %s gets %%d\\n\",i,j,temp)",state->name,state->source[j]->state_source ); /** if we have a specified calcfunc - use it here **/ if(gm->calcfunc != NULL ) { expr(dfp,"score = %s(score,temp);",gm->calcfunc); } else{ expr(dfp,"if( temp > score )"); startbrace(dfp); expr(dfp,"score = temp;"); /** ok for shadow matrix should put things in here */ closebrace(dfp); } if( state->source[j]->position != SOURCE_POS_ALL) { closebrace(dfp); } } /************************/ /* finished blocks */ /* put in global calc */ /************************/ add_break(dfp); add_block_comment(dfp,"Ok - finished max calculation for %s",state->name); add_block_comment(dfp,"Add any movement independant score and put away"); if( state->calc_expr != NULL) expr(dfp," score += %s",state->calc_expr); /***************************/ /* put away score */ /***************************/ expr(dfp," %s_%s(%s,i,j,%s) = score;",gm->name,matrixtag,pointertag,state->name); if( use_special == FALSE ) { add_block_comment(dfp,"Finished calculating state %s",state->name); continue; } /************************/ /* for each special */ /* thats has this as */ /* source we have to */ /* update */ /************************/ for(j=0;jspec_len;j++) { auto CellState * specstate; specstate = gm->special[j]; for(k=0;klen;k++) { if( strcmp(specstate->source[k]->state_source,state->name) == 0) { /********************************/ /* is a special source! */ /********************************/ add_break(dfp); add_block_comment(dfp,"state %s is a source for special %s",state->name,specstate->name); if( specstate->source[k]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(specstate->source[k]->position,specstate->source[k]->offi,specstate->source[k]->offj)); startbrace(dfp); } expr(dfp,"temp = score + (%s) + (%s) ",specstate->source[k]->calc_expr,specstate->calc_expr == NULL ? "0" : specstate->calc_expr ); if(gm->calcfunc != NULL ) { expr(dfp,"%s_%s(%s,i,j,%s) = %s(%s_%s(%s,i,j,%s),temp);", gm->name,specialtag,pointertag,specstate->name, gm->calcfunc, gm->name,specialtag,pointertag,specstate->name); } else{ expr(dfp,"if( temp > %s_%s(%s,i,j,%s) ) ",gm->name,specialtag,pointertag,specstate->name); startbrace(dfp); expr(dfp,"%s_%s(%s,i,j,%s) = temp",gm->name,specialtag,pointertag,specstate->name); if( debug >= 1 ) expr(dfp,"fprintf(stderr,\"[%%4d,%%4d] new score of %s is %%d\\n\",i,j,temp)",state->name); closebrace(dfp); add_break(dfp); } if( specstate->source[k]->position != SOURCE_POS_ALL) { closebrace(dfp); } } /* end of if this special state was a source for previous guy */ } /* end for each source of the special state */ if( dfp->code_debug_level > 4) { expr(dfp,"if( %s_%s(mat,0,j,%s) > IMPOSSIBLY_HIGH_SCORE )",gm->name,specialtag,specstate->name); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] Special state %s Impossibly high score [%%d] found\",i,j,%s_%s(mat,0,j,%s));",specstate->name,gm->name,specialtag,specstate->name); } } /* end for each special state */ if( state->footprint_start < 0 || state->footprint_end > 1 ) { closebrace(dfp); } add_break(dfp); add_block_comment(dfp,"Finished calculating state %s",state->name); } /* end of for each state */ } void write_score_block(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointertag,char * specialtag,boolean use_special) { write_score_block_debug(dfp,gm,matrixtag,pointertag,specialtag,use_special,0); } %func makes calculate_xxx functions, which is for explicit matrix implementations %% void matrix_calculate_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; ArgInfo * ai; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"calculate_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates the %s matrix when in explicit mode",gm->name); add_line_to_Ftext(fi->ft,"To allocate the matrix use /allocate_Expl_%s",gm->name); /** ArgInfo_in_FuncInfo_from_varstr automatically adds ai to fi **/ ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); ai->desc=stringallocf("%s which contains explicit basematrix memory",gm->name); start_function_FuncInfo(fi,dfp,"boolean calculate_%s(%s * mat)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int tot;"); expr(dfp,"int num;"); add_break(dfp); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT )"); startbrace(dfp); warn_expr(dfp,"in calculate_%s, passed a non Explicit matrix type, cannot calculate!",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); expr(dfp,"leni = mat->leni;"); expr(dfp,"lenj = mat->lenj;"); /*** make num and tot ***/ expr(dfp,"tot = leni * lenj;"); expr(dfp,"num = 0;"); /*** see if there any specials to specials to do ***/ add_break(dfp); expr(dfp,"start_reporting(\"%s Matrix calculation: \");",gm->name); expr(dfp,"for(j=0;jname); **/ expr(dfp,"num++;"); write_score_block(dfp,gm,"EXPL_MATRIX","mat","EXPL_SPECIAL",TRUE); closebrace(dfp); /**** if there are any specials do them here ****/ write_special_block(dfp,gm,"EXPL_MATRIX","EXPL_SPECIAL",NULL); closebrace(dfp); /*** stop reporting ***/ expr(dfp,"stop_reporting()"); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } %func makes calculate_xxx functions, which is for explicit matrix implementations %% void matrix_calculate_func_dpenv(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; ArgInfo * ai; int i; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"calculate_dpenv_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates the %s matrix when in explicit mode, subject to the envelope",gm->name); /** ArgInfo_in_FuncInfo_from_varstr automatically adds ai to fi **/ ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); ai->desc=stringallocf("%s which contains explicit basematrix memory",gm->name); start_function_FuncInfo(fi,dfp,"boolean calculate_dpenv_%s(%s * mat,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"int starti;"); expr(dfp,"int startj;"); expr(dfp,"int endi;"); expr(dfp,"int endj;"); expr(dfp,"int tot;"); expr(dfp,"int num;"); expr(dfp,"int should_calc;"); add_break(dfp); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT )"); startbrace(dfp); warn_expr(dfp,"in calculate_%s, passed a non Explicit matrix type, cannot calculate!",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); /*** make num and tot ***/ expr(dfp,"prepare_DPEnvelope(dpenv)"); expr(dfp,"starti = dpenv->starti"); expr(dfp,"if( starti < 0 )"); hang_expr(dfp,"starti = 0"); expr(dfp,"startj = dpenv->startj"); expr(dfp,"if( startj < 0 )"); hang_expr(dfp,"startj = 0"); expr(dfp,"endi = dpenv->endi"); expr(dfp,"if( endi > mat->leni )"); hang_expr(dfp,"endi = mat->leni"); expr(dfp,"endj = dpenv->endj"); expr(dfp,"if( endj > mat->lenj )"); hang_expr(dfp,"endj = mat->lenj"); expr(dfp,"tot = (endi-starti) * (endj-startj);"); expr(dfp,"num = 0;"); add_break(dfp); expr(dfp,"for(j=startj-%d;jwindow_j); startbrace(dfp); expr(dfp,"for(i=%d;ileni;i++)",gm->window_i); startbrace(dfp); for(i=0;ilen;i++) { expr(dfp,"%s_EXPL_MATRIX(mat,i,j,%s) = %s;",gm->name,gm->state[i]->name,gm->state[i]->def_score); } closebrace(dfp); closebrace(dfp); expr(dfp,"for(j=-%d;jlenj;j++)",gm->window_j); startbrace(dfp); for(i=0;ispec_len;i++) { expr(dfp,"%s_EXPL_SPECIAL(mat,i,j,%s) = %s;",gm->name,gm->special[i]->name,gm->special[i]->def_score); } closebrace(dfp); /*** see if there any specials to specials to do ***/ add_break(dfp); expr(dfp,"start_reporting(\"%s Matrix calculation: \");",gm->name); expr(dfp,"for(j=startj;jlen;k++)"); startbrace(dfp); expr(dfp,"auto DPUnit * u;"); expr(dfp,"u = dpenv->dpu[k];"); expr(dfp,"switch(u->type)"); startbrace(dfp); expr(dfp,"case DPENV_RECT :"); startcase(dfp); expr(dfp,"if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length))"); hang_expr(dfp,"should_calc = 1"); expr(dfp,"break;"); closecase(dfp); expr(dfp,"case DPENV_DIAG :"); startcase(dfp); expr(dfp,"if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj)"); hang_expr(dfp,"should_calc = 1"); expr(dfp,"break;"); closecase(dfp); closebrace(dfp); expr(dfp,"if( should_calc == 1 )"); hang_expr(dfp,"break;"); closebrace(dfp); expr(dfp,"if( should_calc == 0)"); startbrace(dfp); for(i=0;ilen;i++) { expr(dfp,"%s_EXPL_MATRIX(mat,i,j,%s) = %s;",gm->name,gm->state[i]->name,gm->state[i]->def_score); } expr(dfp,"continue;"); closebrace(dfp); add_break(dfp); expr(dfp,"if( num%%1000 == 0 )"); hang_expr(dfp,"log_full_error(REPORT,0,\"[%%7d] Cells %%2d%%%%%%%%\",num,num*100/tot);"); /** expr(dfp,"(void) do_cell_%s(mat,i,j)",gm->name); **/ expr(dfp,"num++;"); write_score_block(dfp,gm,"EXPL_MATRIX","mat","EXPL_SPECIAL",TRUE); closebrace(dfp); /**** if there are any specials do them here ****/ write_special_block(dfp,gm,"EXPL_MATRIX","EXPL_SPECIAL",NULL); closebrace(dfp); /*** stop reporting ***/ expr(dfp,"stop_reporting()"); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } void do_special_function(DYNFILE * dfp,GenericMatrix * gm) { if( gm->specialtospecial == FALSE ) { warn("Cannot make special cell function if no special to special use"); return; } start_function(dfp,"void do_special_cells_%s(%s * mat,int j)",gm->name,gm->name); expr(dfp,"register int score"); expr(dfp,"register int temp"); write_special_block(dfp,gm,"EXPL_MATRIX","EXPL_SPECIAL",NULL); add_break(dfp); add_break(dfp); expr(dfp,"return;"); close_function(dfp); add_break(dfp); } %func useful function for debugging, but not currently used %% void do_cell_function(DYNFILE * dfp,GenericMatrix * gm) { start_function(dfp,"int do_cell_%s(%s * mat,int i,int j)",gm->name,gm->name); expr(dfp,"register int score;"); expr(dfp,"register int temp;"); expr(dfp,"register int state;"); write_score_block(dfp,gm,"EXPL_MATRIX","mat","EXPL_SPECIAL",TRUE); expr(dfp,"return 0"); close_function(dfp); add_break(dfp); } %func This writes the special to special block movements, if needed. If bestscore is not NULL, it assummes that this is the name of an int variable which should hold the bestscore by updating from the end state %type internal %arg dfp dynfile output gm r matrix structure matrix r name of main matrix tag eg EXPL_MATRIX special r name of special tag eg EXPL_SPECIAL bestscore r if not NULL, name of scoped variable for updating bestscore %% void write_special_block(DYNFILE * dfp,GenericMatrix * gm,char * matrix,char * special,char * bestscore) { register int i; register int j; for(i=0;ispec_len;i++) { auto CellState * state; state = gm->special[i]; add_break(dfp); if( state->specialtospecial == FALSE ) { add_block_comment(dfp,"Special state %s has no special to special movements",state->name); continue; } add_block_comment(dfp,"Special state %s has special to speical",state->name); add_block_comment(dfp,"Set score to current score (remember, state probably updated during main loop"); expr(dfp,"score = %s_%s(mat,0,j,%s);",gm->name,special,state->name); add_break(dfp); for(j=0;j < state->len;j++) { auto CellSource * source; source = state->source[j]; if( source->isspecial == FALSE ) { add_block_comment(dfp,"Source %s for state %s is not special... already calculated",source->state_source,state->name); continue; /** back to for j **/ } add_block_comment(dfp,"Source %s is a special source for %s",source->state_source,state->name); if( state->source[j]->position != SOURCE_POS_ALL) { add_block_comment(dfp,"Has restricted position"); expr(dfp,"if( %s )",source_allowed_statement(state->source[j]->position,state->source[j]->offi,state->source[j]->offj)); startbrace(dfp); } expr(dfp,"temp = %s_%s(mat,0,j - %d,%s) + (%s) + (%s)",gm->name,special,source->offj,source->state_source, source->calc_expr,state->calc_expr == NULL ? "0" : state->calc_expr); if( gm->calcfunc != NULL ) { expr(dfp,"score = %s(score,temp);",gm->calcfunc); } else { expr(dfp,"if( temp > score )"); hang_expr(dfp,"score = temp"); } if( state->source[j]->position != SOURCE_POS_ALL) { closebrace(dfp); } add_break(dfp); } add_block_comment(dfp,"Put back score... (now updated!)"); expr(dfp,"%s_%s(mat,0,j,%s) = score;",gm->name,special,state->name); add_block_comment(dfp,"Finished updating state %s",state->name); add_break(dfp); if( dfp->code_debug_level > 5) { expr(dfp,"if( score > IMPOSSIBLY_HIGH_SCORE )"); hang_expr(dfp,"log_full_error(WARNING,5,\"[%%4d][%%4d] Special state %s Impossibly high score [%%d] found\",i,j,score);",state->name); } } /* if( bestscore == NULL && gm->calcfunc == NULL ) return; */ /** ok - update of endscore stuff **/ for(i=0;ispec_len;i++) { auto CellState * state; state = gm->special[i]; if( state->is_end == TRUE ) { if( bestscore == NULL ) { /* means we have a calc func with no bestscore */ /*expr(dfp,"%s_%s(mat,0,j,%s) = %s(%s_%s(mat,0,j,%s),%s_%s(mat,0,j-1,%s));",gm->name,special,state->name,gm->calcfunc,gm->name,special,state->name,gm->name,special,state->name);*/ } else { /* we are in a database search routine */ if( gm->calcfunc != NULL ) { expr(dfp,"bestscore = %s(bestscore,%s_%s(mat,0,j,%s));",gm->calcfunc,gm->name,special,state->name); } else { expr(dfp,"if( bestscore < %s_%s(mat,0,j,%s) )",gm->name,special,state->name); hang_expr(dfp,"bestscore = %s_%s(mat,0,j,%s)",gm->name,special,state->name); } } break; } } } void write_search_distributor_func(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { int i; char buffer[MAXLINE]; FuncInfo * fi; boolean qdb = FALSE; boolean tdb = FALSE; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"search_%s",gm->name); add_line_to_Ftext(fi->ft,"This function makes a database search of %s",gm->name); add_line_to_Ftext(fi->ft,"It uses the dbsi structure to choose which implementation"); add_line_to_Ftext(fi->ft,"to use of the database searching. This way at run time you"); add_line_to_Ftext(fi->ft,"can switch between single threaded/multi-threaded or hardware"); if( gm->qtype != NULL && gm->qtype->is_database == TRUE) qdb = TRUE; if( gm->ttype != NULL && gm->ttype->is_database == TRUE) tdb = TRUE; if( qdb == TRUE) sprintf(buffer,"Search_Return_Type search_%s(DBSearchImpl * dbsi,Hscore * out,%s querydb,",gm->name,gm->qtype->database_type); else sprintf(buffer,"Search_Return_Type search_%s(DBSearchImpl * dbsi,Hscore * out,%s %s,",gm->name,gm->query->element_type,gm->query->name); if( tdb == TRUE) { strcat(buffer,gm->ttype->database_type); strcat(buffer," targetdb "); } else { strcat(buffer,gm->target->element_type); strcat(buffer," "); strcat(buffer,gm->target->name); strcat(buffer," "); } for(i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,gm->resource[i]->element_type); strcat(buffer," "); strcat(buffer,gm->resource[i]->name); } strcat(buffer,")"); start_function_FuncInfo(fi,dfp,buffer); if( dpi->do_threads == TRUE && can_do_threads(gm) == TRUE ) { macro(dfp,"#ifdef PTHREAD"); expr(dfp,"int i;"); expr(dfp,"int thr_no;"); expr(dfp,"pthread_attr_t pat;"); expr(dfp,"struct thread_pool_holder_%s * holder",gm->name); macro(dfp,"#endif"); } expr(dfp,"if( out == NULL )"); startbrace(dfp); warn_expr(dfp,"Passed in a null Hscore object into search_%s. Can't process results!",gm->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); expr(dfp,"if( dbsi == NULL )"); startbrace(dfp); warn_expr(dfp,"Passed in a null DBSearchImpl object into search_%s. Can't process results!",gm->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); if( dpi->db_trace_level == 0 ) { expr(dfp,"if( dbsi->trace_level > 0 ) "); hang_expr(dfp,"warn(\"Although you are asking at run-time for database tracing, the %s matrix was not compiled with database tracing. No tracing will be made\");",gm->name); } else { expr(dfp,"if( dbsi->trace_level > %d ) ",dpi->db_trace_level); hang_expr(dfp,"warn(\"Asking for trace level of %%d in database search for %s, but it was compiled with a trace level of %d. Not all trace statements can be shown\",dbsi->trace_level);",gm->name); } /* now to figure out what implementations should be run! */ expr(dfp,"switch(dbsi->type)"); startbrace_tag(dfp,"switch on implementation"); expr(dfp,"case DBSearchImpl_Serial :"); startcase(dfp); if( qdb == TRUE) sprintf(buffer,"return serial_search_%s(out,querydb,",gm->name); else sprintf(buffer,"return serial_search_%s(out,%s,",gm->name,gm->query->name); if( tdb == TRUE) { strcat(buffer," targetdb "); } else { strcat(buffer,gm->target->name); strcat(buffer," "); } for(i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,gm->resource[i]->name); } strcat(buffer,");"); expr(dfp,buffer); closecase(dfp); expr(dfp,"case DBSearchImpl_Pthreads :"); startcase(dfp); if( dpi->do_threads == TRUE && can_do_threads(gm) == TRUE ) { macro(dfp,"#ifdef PTHREAD"); expr(dfp,"holder = (struct thread_pool_holder_%s *) ckalloc(sizeof(struct thread_pool_holder_%s));",gm->name,gm->name); expr(dfp,"if( holder == NULL ) "); startbrace(dfp); warn_expr(dfp,"Unable to allocated thread pool datastructure..."); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); expr(dfp,"holder->out = out;"); if( dpi->db_trace_level > 0 ) expr(dfp,"holder->dbsi = dbsi;"); if( qdb == TRUE ) { expr(dfp,"holder->querydb = querydb;"); } else { expr(dfp,"holder->%s = %s;",gm->query->name,gm->query->name); } if( tdb == TRUE ) { expr(dfp,"holder->targetdb = targetdb;"); } else { expr(dfp,"holder->%s = %s;",gm->target->name,gm->target->name); } for(i=0;ires_len;i++) { expr(dfp,"holder->%s = %s;",gm->resource[i]->name,gm->resource[i]->name); } expr(dfp,"if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) "); expr(dfp,"fatal(\"Unable to iniated input mutex lock\");"); expr(dfp,"if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) "); expr(dfp,"fatal(\"Unable to iniated output mutex lock\");"); add_block_comment(dfp,"Let us rock!"); expr(dfp,"thr_no = number_of_threads_DBSearchImpl(dbsi);"); expr(dfp,"holder->pool = ckcalloc (thr_no,sizeof(pthread_t));"); expr(dfp,"if( holder->pool == NULL ) "); startbrace(dfp); warn_expr(dfp,"Unable to allocated thread pools"); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); add_block_comment(dfp,"Build a thread attribute to make sure we get the most out of SMP boxes"); expr(dfp,"pthread_attr_init(&pat)"); add_block_comment(dfp,"Give thread libraries a hint that threads should be kernel threads"); macro(dfp,"#ifndef __sgi /* SGI can't set system scope ... */"); macro(dfp,"#ifdef HAS_PTHREAD_SETSCOPE"); expr(dfp,"pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM);"); macro(dfp,"#endif /* set scope */"); macro(dfp,"#endif /* sgi */"); add_block_comment(dfp,"Give thread libraries a hint that there are num of threads to run"); macro(dfp,"#ifdef HAS_PTHREAD_SETCONCURRENCY"); expr(dfp,"pthread_setconcurrency(thr_no+1);"); macro(dfp,"#endif /* set concurrency */"); expr(dfp,"for(i=0;ipool+i,&pat,thread_loop_%s,(void *)holder) )",gm->name); hang_expr(dfp,"fatal(\"Unable to create a thread!\");"); closebrace(dfp); add_block_comment(dfp,"Now - wait for all the threads to exit"); expr(dfp,"for(i=0;ipool[i],NULL) != 0 )",gm->name); hang_expr(dfp,"fatal(\"Unable to join a thread!\");"); closebrace(dfp); /* expr(dfp,"pthread_attr_destroy(&pat);"); */ add_block_comment(dfp,"Deallocate the thread structures"); expr(dfp,"ckfree(holder->pool)"); expr(dfp,"ckfree(holder)"); expr(dfp,"return SEARCH_OK;"); macro(dfp,"#else /* not compiled with threads */"); warn_expr(dfp,"You did not specifiy the PTHREAD compile when compiled the C code for %s",gm->name); macro(dfp,"#endif /* finished threads */"); } else { warn_expr(dfp,"This matrix %s was not dyc compiled with thread support",gm->name); expr(dfp,"return SEARCH_ERROR;"); } closecase(dfp); expr(dfp,"default :"); startcase(dfp); expr(dfp,"warn(\"database search implementation %%s was not provided in the compiled dynamite file from %s\",impl_string_DBSearchImpl(dbsi));",gm->name); expr(dfp,"return SEARCH_ERROR;"); closecase(dfp); closebrace(dfp); add_break(dfp); close_function(dfp); add_break(dfp); } void write_GenericMatrix_header(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { StructHolder * temp; StructElement * se; char buffer[MAXLINE]; write_StructHolder_header(dfp,gm->sh); if( dpi->do_threads == TRUE ) { if( can_do_threads(gm) == FALSE ) { warn("Asking for threads, but the types in this matrix %s are not thread safe",gm->name); } else { write_thread_struct(dfp,dpi,gm); } } temp = StructHolder_alloc_std(); sprintf(buffer,"%s_access_func_holder",gm->name); temp->name = stringalloc(buffer); sprintf(buffer,"int (*access_main)(%s*,int,int,int)",gm->name); se = basic_add_StructElement(temp,"access_main","int"); se->element_type = stringalloc(buffer); se->isfunc = TRUE; sprintf(buffer,"int (*access_special)(%s*,int,int,int)",gm->name); se = basic_add_StructElement(temp,"access_special","int"); se->element_type = stringalloc(buffer); se->isfunc = TRUE; write_StructHolder_header(dfp,temp); free_StructHolder(temp); /** write_StructHolder_header(gm->search_sh,ofp); **/ /** load_file(ofp); write_memory_macros(gm); close_file(); **/ } /***************************************** this function writes the C functions themselves it does not load up ofp into the header part of writec, and you must do that first if you want the function prototypes to be put into the header files ******************************************/ void write_GenericMatrix_func(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { fprintf(dfp->func,"\n\n /***************** C functions ****************/\n"); fprintf(dfp->func," /* Written using dynamite */\n"); fprintf(dfp->func," /* %s */\n",now_string()); fprintf(dfp->func," /* email birney@sanger.ac.uk */\n"); fprintf(dfp->func," /* http://www.sanger.ac.uk/Users/birney/dynamite */\n"); fprintf(dfp->func," /*************************************************/\n"); fprintf(dfp->func,"\n\n"); fprintf(dfp->func," /* Please report any problems or bugs to */\n"); fprintf(dfp->func," /* Ewan Birney, birney@sanger.ac.uk */\n"); fprintf(dfp->func,"\n\n"); add_block_comment(dfp,"basic set of macros to map states to numbers"); write_memory_macros(dfp,gm); write_search_macros(dfp,gm,dpi); add_break(dfp); if( dpi->dydebug == TRUE ) { write_debug_funcs(dfp,gm); } write_shatter_functions(dfp,gm,dpi); write_search_distributor_func(dfp,gm,dpi); if( dpi->do_threads == TRUE && can_do_threads(gm) ) { write_thread_loop(dfp,dpi,gm); } if( dpi->doprob == TRUE ) { write_probabilistic_models(dfp,gm,dpi); } make_search_loop_function(dfp,gm); write_one_score_GenericMatrix(dfp,gm,dpi); /** write_database_scan_function(gm); **/ /** if( make_Compugen_functions_if_possible(gm) == TRUE) { log_full_error(INFO,0,"Able to make Compugen functions"); } **/ /*** testing ***/ one_shot_aln_func(dfp,gm,dpi); write_safe_alloc_function(dfp,gm); alloc_expl_func_GenericMatrix(dfp,gm); init_matrix_func(dfp,gm); recalculate_PackAln_func(dfp,gm); /*** this is found in dynshadow.dy ***/ add_block_comment(dfp,"divide and conquor macros are next"); write_dc_functions(dfp,gm); /*write_pal_to_ars_func(dfp,gm);*/ write_aln_conversion_func(dfp,gm); write_alncconvert_make_func(dfp,gm); write_expl_read_func(dfp,gm); write_expl_access_funcs(dfp,gm); write_basic_read_func(dfp,gm); find_end_func(dfp,gm); debug_func(dfp,gm); write_max_calc_func(dfp,gm); write_special_max_calc_func(dfp,gm); matrix_calculate_func(dfp,gm); matrix_calculate_func_dpenv(dfp,gm); write_simplealloc_function(dfp,gm->sh); write_free_function(dfp,gm->sh); add_break(dfp); return; } %} wise-2.4.1/src/dyc/kbestsearch.c0000644000175000001440000006457610670453715016113 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "kbestsearch.h" /* Function: write_kbest_score_GenericMatrix(dfp,gm,sc,mts,dpi) * * Descrip: Produces a kbest search type single score function * * kbest algorithm used here is that each cell is * reduced to a single score + state number that it * came from. The kbest heuristic is to provide only k paths * onto the next position in the sequence. In our case we * have k = length of model / number of states. This sort * of kbest heurisitc is good because it cuts down on excessive * book keeping of the alignments, by being able to store * information of the state only * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: sc [UNKN ] Undocumented argument [Scope *] * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ # line 63 "kbestsearch.dy" void write_kbest_score_GenericMatrix(DYNFILE * dfp,GenericMatrix * gm,Scope * sc,MethodTypeSet * mts,DPImplementation * dpi) { char subexpr_buffer[MAXLINE]; int i,j; FuncInfo * fi; char * arg_str; char * chain_str; CommonSubExpressionSet * cses; cses = find_CommonSubExpressions(gm,TRUE); show_CommonSubExpressionSet(cses,stdout); for(j=0;jspec_len;j++) if( gm->special[j]->is_start == TRUE ) break; /*** prepare function information ***/ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"kbest_score_only_%s",gm->name); add_line_to_Ftext(fi->ft,"This function just calculates the score for the matrix",gm->name); add_line_to_Ftext(fi->ft,"It uses a kbest style algorithm to compute the score"); add_line_to_Ftext(fi->ft,"It calls /allocate_%s_only",gm->name); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"int kbest_score_only_%s(%s)",gm->name,arg_str); /*** clean up ***/ ckfree(arg_str); /*** into function body ***/ expr(dfp,"int bestscore = NEGI;"); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"%s * mat",gm->name); expr(dfp,"int * score_mat[%d];",gm->window_j+1); expr(dfp,"char * state_mat;",gm->window_j+1); expr(dfp,"int score_special[%d][%d];",gm->window_j+1,gm->spec_len); /** for the moment, ignore the possibility of static allocation */ if( 0 && gm->qtype != NULL && gm->qtype->maxlen != NULL) { expr(dfp,"int internal_matrix[%d][(%s+%d) * %d];",gm->window_j+1,gm->qtype->maxlen,gm->window_i,gm->len); expr(dfp,"int internal_specials[%d][%d];",gm->window_j+1,gm->spec_len); } if(0 && dpi->largemem == TRUE ) { expr(dfp,"int * internal_pointer_db;"); expr(dfp,"int * internal_special_db;"); } /** kbest optimisation stuff **/ if( dpi->dokbestcse == TRUE ) { for(i=0;ilen;i++) { expr(dfp,"int subexpr%d;",i); } } add_break(dfp); chain_str = get_chainstr_GenericMatrix(gm); expr(dfp,"mat = allocate_%s_only(%s);",gm->name,chain_str); ckfree(chain_str); expr(dfp,"if( mat == NULL )"); startbrace(dfp); warn_expr(dfp,"Memory allocation error in the db search - unable to communicate to calling function. this spells DISASTER!"); expr(dfp,"return NEGI"); closebrace(dfp); /* if(0 && gm->qtype != NULL && gm->qtype->maxlen != NULL) { add_block_comment(dfp,"Ok,don't need to allocate matrix as it is internal, because we have a max length"); } else { expr(dfp,"if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(%d,(mat->leni + %d)*2,%d,%d)) == NULL)",gm->window_j+1,gm->window_i,gm->window_j+1,gm->spec_len); startbrace(dfp); expr(dfp,"warn(\"Score only matrix for %s cannot be allocated, (asking for %d by %%d cells)\",mat->leni);",gm->name,gm->window_j); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return NEGI;"); closebrace(dfp); expr(dfp,"mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL;"); } */ add_block_comment(dfp,"Allocate memory for matrix"); expr(dfp,"for(j=0;j<%d;j++)",gm->window_j+1); startbrace(dfp); expr(dfp,"score_mat[j] = (int *) ckalloc (sizeof(int) * (mat->leni+%d));",gm->window_i); closebrace(dfp); expr(dfp,"state_mat = (char *) ckalloc (sizeof(char) * (mat->leni+%d)*%d *%d);",gm->window_i,gm->len,gm->window_j+1); add_break(dfp); add_block_comment(dfp,"Now, initiate matrix"); expr(dfp,"for(j=0;j<%d;j++)",gm->window_j+2); startbrace(dfp); expr(dfp,"for(i=(-%d);ileni;i++)",gm->window_i); startbrace(dfp); expr(dfp,"%s_KBEST_MATRIX_SCORE(mat,i,j,KBEST_SCORE) = NEGI;",gm->name); for(i=0;ispec_len;i++) { expr(dfp,"%s_KBEST_SPECIAL(mat,0,j,%s) = %s;",gm->name,gm->special[i]->name,gm->special[i]->def_score); } closebrace(dfp); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Ok, lets do-o-o-o-o it"); add_break(dfp); if( dpi->dokbestcse == TRUE ) { for(i=0;ilen;i++) { if( IS_NON_IJ_DEP_CSE(cses->cse[i]) ) { subexpr_buffer[0]='\0'; strcat_ExprTree_Scoped(cses->cse[i]->expr,subexpr_buffer,sc,mts,dpi->dycw,NULL,NULL); expr(dfp,"subexpr%d = %s;",i,subexpr_buffer); } } } expr(dfp,"for(j=0;jlenj;j++)"); startbrace_tag(dfp,"for all target positions"); expr(dfp,"auto int score"); expr(dfp,"auto int temp"); expr(dfp,"auto int state"); expr(dfp,"auto int temp_state"); if( dpi->dokbestcse == TRUE ) { for(i=0;ilen;i++) { if( IS_J_DEP_CSE(cses->cse[i]) == TRUE && IS_I_DEP_CSE(cses->cse[i]) == FALSE ) { subexpr_buffer[0]='\0'; strcat_ExprTree_Scoped(cses->cse[i]->expr,subexpr_buffer,sc,mts,dpi->dycw,NULL,NULL); expr(dfp,"subexpr%d = %s;",i,subexpr_buffer); } } } add_break(dfp); add_block_comment(dfp,"Initialise these specials"); for(i=0;ispec_len;i++) { expr(dfp,"%s_KBEST_SPECIAL(mat,0,j,%s) = %s;",gm->name,gm->special[i]->name,gm->special[i]->def_score); } expr(dfp,"for(i=0;ileni;i++)"); startbrace_tag(dfp,"for all query positions"); /** kbest cse optimisations **/ if( dpi->dokbestcse == TRUE ) { for(i=0;ilen;i++) { if( IS_J_DEP_CSE(cses->cse[i]) == TRUE && IS_I_DEP_CSE(cses->cse[i]) == TRUE ) { subexpr_buffer[0]='\0'; strcat_ExprTree_Scoped(cses->cse[i]->expr,subexpr_buffer,sc,mts,dpi->dycw,NULL,NULL); expr(dfp,"subexpr%d = %s;",i,subexpr_buffer); } } } write_kbest_block(dfp,gm,"KBEST_MATRIX","mat","KBEST_SPECIAL",TRUE,cses,mts,dpi); closebrace(dfp); add_break(dfp); write_special_block(dfp,gm,"KBEST_MATRIX","KBEST_SPECIAL","bestscore"); closebrace(dfp); add_break(dfp); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return bestscore;"); close_function(dfp); add_break(dfp); } /* Function: write_kbest_block(dfp,gm,matrixtag,pointertag,specialtag,use_special,cses,mts,dpi) * * Descrip: Produces the actual kbest scoring inner loop * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: matrixtag [UNKN ] Undocumented argument [char *] * Arg: pointertag [UNKN ] Undocumented argument [char *] * Arg: specialtag [UNKN ] Undocumented argument [char *] * Arg: use_special [UNKN ] Undocumented argument [boolean] * Arg: cses [UNKN ] Undocumented argument [CommonSubExpressionSet *] * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ # line 258 "kbestsearch.dy" void write_kbest_block(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointertag,char * specialtag,boolean use_special,CommonSubExpressionSet * cses,MethodTypeSet * mts,DPImplementation * dpi) { char buffer[MAXLINE]; register int i; register int j; register int k; TransitionSet * ts; int current_i_off; int current_j_off; ts = TransitionSet_from_GenericMatrix(gm); sort_TransitionSet_offset(ts); /* show_TransitionSet(ts,stderr); */ add_break(dfp); expr(dfp,"score = NEGI;"); expr(dfp,"state = 300;"); add_break(dfp); /* do switch statements from specials first */ for(k=0;klen && Transition_from_special(ts->trans[k]) == 1;k++) { if( ts->trans[k]->trans_type == TRANSITION_FROM_START ) { add_block_comment(dfp,"Source is the start state, and hence no need to look, must be 0"); expr(dfp,"temp = %s", ts->trans[k]->calc ); } else { expr(dfp,"temp = %s_KBEST_SPECIAL(mat,i-%d,j-%d,%s) + %s",gm->name, ts->trans[k]->offi, ts->trans[k]->offj, ts->trans[k]->from, ts->trans[k]->calc ); } expr(dfp,"if(temp > score)"); startbrace(dfp); expr(dfp,"score = temp;"); expr(dfp,"state = %s;",ts->trans[k]->to); closebrace(dfp); } /* do switch statements over the possibilities for each i,j offset */ for(;klen;) { current_i_off = ts->trans[k]->offi; current_j_off = ts->trans[k]->offj; expr(dfp,"switch ( %s_KBEST_MATRIX_STATE(mat,i-%d,j-%d,DUMMY_KBEST_STATE) )",gm->name,current_i_off,current_j_off); startbrace(dfp); for(;k < ts->len && ts->trans[k]->offi == current_i_off && ts->trans[k]->offj == current_j_off;k++) { expr(dfp,"case %s :",ts->trans[k]->from); startcase(dfp); if( dpi->dokbestcse == TRUE ) { buffer[0] = '\0'; strcat(buffer,"("); strcat_cses_ExprTree(ts->trans[k]->expr,buffer,gm->sc,mts,dpi); strcat(buffer,")"); if( ts->trans[k]->expr_state != NULL ) { strcat(buffer,"+ ("); strcat_cses_ExprTree(ts->trans[k]->expr_state,buffer,gm->sc,mts,dpi); strcat(buffer,")"); } expr(dfp,"temp = %s;",buffer); } else { expr(dfp,"temp = %s;",ts->trans[k]->calc); } expr(dfp,"temp_state = %s;",ts->trans[k]->to); expr(dfp,"break;"); closecase(dfp); } expr(dfp,"default :"); startcase(dfp); expr(dfp,"temp = NEGI;"); expr(dfp,"temp_state = (200);"); expr(dfp,"break;"); closecase(dfp); closebrace(dfp); /* close switch statement */ add_break(dfp); expr(dfp,"if( temp > NEGI )"); startbrace(dfp); expr(dfp,"temp += %s_KBEST_MATRIX_SCORE(mat,i-%d,j-%d,KBEST_SCORE);",gm->name,current_i_off,current_j_off); expr(dfp,"if( temp > score )"); startbrace(dfp); expr(dfp,"score = temp;"); expr(dfp,"state = temp_state;"); closebrace(dfp); closebrace(dfp); add_break(dfp); } expr(dfp,"%s_KBEST_MATRIX_SCORE(mat,i,j,KBEST_SCORE) = score;",gm->name); expr(dfp,"%s_KBEST_MATRIX_STATE(mat,i,j,KBEST_STATE) = state;",gm->name); add_break(dfp); add_block_comment(dfp,"Now do any potential main to special movements"); for(i=0;ispec_len;i++) { for(j=0;jspecial[i]->len;j++) { if( gm->special[i]->source[j]->isspecial == FALSE ) { expr(dfp,"if( state == %s)",gm->special[i]->source[j]->state_source); startbrace(dfp); expr(dfp,"temp = score + (%s) + (%s);", gm->special[i]->source[j]->calc_expr, gm->special[i]->calc_expr == NULL ? "0" : gm->special[i]->calc_expr); expr(dfp,"if( temp > %s_KBEST_SPECIAL(mat,i,j,%s) )",gm->name,gm->special[i]->name); hang_expr(dfp,"%s_KBEST_SPECIAL(mat,i,j,%s) = temp;",gm->name,gm->special[i]->name); closebrace(dfp); } } } } /* Function: TransitionSet_from_GenericMatrix(gm) * * Descrip: Makes a transition set from a generic matrix * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [TransitionSet *] * */ # line 377 "kbestsearch.dy" TransitionSet * TransitionSet_from_GenericMatrix(GenericMatrix * gm) { TransitionSet *out; int i,j,k; Transition * trans; char buffer[1024]; out = TransitionSet_alloc_std(); for(i=0;ilen;i++) for(j=0;jstate[i]->len;j++) { trans = Transition_alloc(); trans->offi = gm->state[i]->source[j]->offi; trans->offj = gm->state[i]->source[j]->offj; trans->to = stringalloc(gm->state[i]->name); trans->from = stringalloc(gm->state[i]->source[j]->state_source); trans->expr = gm->state[i]->source[j]->etr; trans->expr_state = gm->state[i]->etr; /* if it is from a special, see if it is from start */ if( gm->state[i]->source[j]->isspecial ) { /* this is painful, but because I hadn't got the previous data structure right! */ for(k=0;kspec_len;k++) { if( gm->special[k]->is_start == TRUE && strcmp(gm->state[i]->source[j]->state_source,gm->special[k]->name) == 0) { trans->trans_type = TRANSITION_FROM_START; break; } } if( k == gm->spec_len ) { trans->trans_type = TRANSITION_FROM_SPECIAL; } } if( gm->state[i]->calc_expr != NULL ) { sprintf(buffer,"(%s) + (%s)",gm->state[i]->source[j]->calc_expr,gm->state[i]->calc_expr); } else { sprintf(buffer,"%s",gm->state[i]->source[j]->calc_expr); } trans->calc = stringalloc(buffer); add_TransitionSet(out,trans); } return out; } /* Function: can_kbest_GenericMatrix(gm) * * Descrip: sees whether the generic matrix is suitable for kbest optimisations * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 427 "kbestsearch.dy" boolean can_kbest_GenericMatrix(GenericMatrix * gm) { int i,j; int k,l; /* have to find cases in which the source,i,j is the same twice */ for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; for(j=0;jlen;j++) { /* now loop over all other transitions in this state */ for(l=j+1;llen;l++) if( state->source[j]->offi == state->source[l]->offi && state->source[j]->offj == state->source[l]->offj && strcmp(state->source[j]->state_source,state->source[l]->state_source) == 0 ) return FALSE; /* now loop over all other states */ for(k=i+1;klen;k++) { for(l=0;lstate[k]->len;l++) if( state->source[j]->offi == gm->state[k]->source[l]->offi && state->source[j]->offj == gm->state[k]->source[l]->offj && strcmp(state->source[j]->state_source,gm->state[k]->source[l]->state_source) == 0 ) return FALSE; }/* all other states */ } /* all transitions in this particular i'th state */ }/* all states */ return TRUE; } /* Function: sort_TransitionSet_offset(ts) * * Descrip: Sorts by offi then offj * * * Arg: ts [UNKN ] Undocumented argument [TransitionSet *] * */ # line 467 "kbestsearch.dy" void sort_TransitionSet_offset(TransitionSet * ts) { sort_TransitionSet(ts,comp_Transition); } /* Function: comp_Transition(two,one) * * Descrip: comparison by offi/offj * * * Arg: two [UNKN ] Undocumented argument [Transition *] * Arg: one [UNKN ] Undocumented argument [Transition *] * * Return [UNKN ] Undocumented return value [int] * */ # line 475 "kbestsearch.dy" int comp_Transition(Transition * two,Transition * one) { if( Transition_from_special(one) != Transition_from_special(two) ) { if( Transition_from_special(two) ) { return -1; } else { return 1; } } if( one->offi == two->offi ) { return one->offj - two->offj; } return one->offi - two->offi; } /* Function: show_TransitionSet(tset,ofp) * * Descrip: Shows a transition set * * * Arg: tset [UNKN ] Undocumented argument [TransitionSet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 496 "kbestsearch.dy" void show_TransitionSet(TransitionSet * tset,FILE * ofp) { int i; for(i=0;ilen;i++) show_Transition(tset->trans[i],ofp); } /* Function: show_Transition(trans,ofp) * * Descrip: Shows a transition * * * Arg: trans [UNKN ] Undocumented argument [Transition *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 508 "kbestsearch.dy" void show_Transition(Transition * trans,FILE * ofp) { fprintf(ofp,"Transition [%s %d %d %s]\n",trans->from,trans->offi,trans->offj,trans->to); fprintf(ofp," calc %s\n",trans->calc); } # line 526 "kbestsearch.c" /* Function: hard_link_Transition(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Transition *] * * Return [UNKN ] Undocumented return value [Transition *] * */ Transition * hard_link_Transition(Transition * obj) { if( obj == NULL ) { warn("Trying to hard link to a Transition object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Transition_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Transition *] * */ Transition * Transition_alloc(void) { Transition * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Transition *) ckalloc (sizeof(Transition))) == NULL) { warn("Transition_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->to = NULL; out->from = NULL; out->offi = 0; out->offj = 0; out->calc = NULL; out->trans_type = TRANSITION_NORMAL; out->expr = NULL; out->expr_state = NULL; return out; } /* Function: free_Transition(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Transition *] * * Return [UNKN ] Undocumented return value [Transition *] * */ Transition * free_Transition(Transition * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Transition obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->to != NULL) ckfree(obj->to); if( obj->from != NULL) ckfree(obj->from); if( obj->calc != NULL) ckfree(obj->calc); if( obj->expr != NULL) free_ExprTree(obj->expr); if( obj->expr_state != NULL) free_ExprTree(obj->expr_state); ckfree(obj); return NULL; } /* Function: swap_TransitionSet(list,i,j) * * Descrip: swap function: an internal for qsort_TransitionSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Transition **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_TransitionSet(Transition ** list,int i,int j) { Transition * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_TransitionSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_TransitionSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Transition **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_TransitionSet(Transition ** list,int left,int right,int (*comp)(Transition * ,Transition * )) { int i,last; if( left >= right ) return; swap_TransitionSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_TransitionSet (list,++last,i); } swap_TransitionSet (list,left,last); qsort_TransitionSet(list,left,last-1,comp); qsort_TransitionSet(list,last+1,right,comp); } /* Function: sort_TransitionSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_TransitionSet * * * Arg: obj [UNKN ] Object containing list [TransitionSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_TransitionSet(TransitionSet * obj,int (*comp)(Transition *, Transition *)) { qsort_TransitionSet(obj->trans,0,obj->len-1,comp); return; } /* Function: expand_TransitionSet(obj,len) * * Descrip: Really an internal function for add_TransitionSet * * * Arg: obj [UNKN ] Object which contains the list [TransitionSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_TransitionSet(TransitionSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_TransitionSet called with no need"); return TRUE; } if( (obj->trans = (Transition ** ) ckrealloc (obj->trans,sizeof(Transition *)*len)) == NULL) { warn("ckrealloc failed for expand_TransitionSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_TransitionSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransitionSet *] * Arg: add [OWNER] Object to add to the list [Transition *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_TransitionSet(TransitionSet * obj,Transition * add) { if( obj->len >= obj->maxlen) { if( expand_TransitionSet(obj,obj->len + TransitionSetLISTLENGTH) == FALSE) return FALSE; } obj->trans[obj->len++]=add; return TRUE; } /* Function: flush_TransitionSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransitionSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_TransitionSet(TransitionSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->trans[i] != NULL) { free_Transition(obj->trans[i]); obj->trans[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: TransitionSet_alloc_std(void) * * Descrip: Equivalent to TransitionSet_alloc_len(TransitionSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransitionSet *] * */ TransitionSet * TransitionSet_alloc_std(void) { return TransitionSet_alloc_len(TransitionSetLISTLENGTH); } /* Function: TransitionSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransitionSet *] * */ TransitionSet * TransitionSet_alloc_len(int len) { TransitionSet * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = TransitionSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->trans = (Transition ** ) ckcalloc (len,sizeof(Transition *))) == NULL) { warn("Warning, ckcalloc failed in TransitionSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_TransitionSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransitionSet *] * * Return [UNKN ] Undocumented return value [TransitionSet *] * */ TransitionSet * hard_link_TransitionSet(TransitionSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransitionSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransitionSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransitionSet *] * */ TransitionSet * TransitionSet_alloc(void) { TransitionSet * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransitionSet *) ckalloc (sizeof(TransitionSet))) == NULL) { warn("TransitionSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->trans = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_TransitionSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransitionSet *] * * Return [UNKN ] Undocumented return value [TransitionSet *] * */ TransitionSet * free_TransitionSet(TransitionSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransitionSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->trans != NULL) { for(i=0;ilen;i++) { if( obj->trans[i] != NULL) free_Transition(obj->trans[i]); } ckfree(obj->trans); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/kbestsearch.h0000644000175000001440000002305110670453715016077 0ustar philippusers#ifndef DYNAMITEkbestsearchHEADERFILE #define DYNAMITEkbestsearchHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna2.h" #include "dynafunc.h" #include "optimiser.h" #define TransitionSetLISTLENGTH 24 #define Transition_from_special(trans) (trans->trans_type == TRANSITION_FROM_SPECIAL || trans->trans_type == TRANSITION_FROM_START ? 1 : 0) #define TRANSITION_NORMAL 0 #define TRANSITION_FROM_SPECIAL 1 #define TRANSITION_FROM_START 2 /* Object Transition * * Descrip: This is the data structure for one * transition - it will probably replace * the generic matrix type data structure * eventually, but as we need this for * kbest type systems, we do it here * * */ struct Transition { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * to; char * from; int offi; int offj; char * calc; int trans_type; ExprTree * expr; ExprTree * expr_state; } ; /* Transition defined */ #ifndef DYNAMITE_DEFINED_Transition typedef struct Transition Transition; #define DYNAMITE_DEFINED_Transition #endif /* Object TransitionSet * * Descrip: Data for an entire DP matrix- just being the transitions * at the moment * * Sometime this - or something similar to this - will * replace the generic matrix datastructure, but for the * moment, this suffices! * * */ struct TransitionSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Transition ** trans; int len;/* len for above trans */ int maxlen; /* maxlen for above trans */ } ; /* TransitionSet defined */ #ifndef DYNAMITE_DEFINED_TransitionSet typedef struct TransitionSet TransitionSet; #define DYNAMITE_DEFINED_TransitionSet #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: write_kbest_score_GenericMatrix(dfp,gm,sc,mts,dpi) * * Descrip: Produces a kbest search type single score function * * kbest algorithm used here is that each cell is * reduced to a single score + state number that it * came from. The kbest heuristic is to provide only k paths * onto the next position in the sequence. In our case we * have k = length of model / number of states. This sort * of kbest heurisitc is good because it cuts down on excessive * book keeping of the alignments, by being able to store * information of the state only * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: sc [UNKN ] Undocumented argument [Scope *] * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ void write_kbest_score_GenericMatrix(DYNFILE * dfp,GenericMatrix * gm,Scope * sc,MethodTypeSet * mts,DPImplementation * dpi); /* Function: write_kbest_block(dfp,gm,matrixtag,pointertag,specialtag,use_special,cses,mts,dpi) * * Descrip: Produces the actual kbest scoring inner loop * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: matrixtag [UNKN ] Undocumented argument [char *] * Arg: pointertag [UNKN ] Undocumented argument [char *] * Arg: specialtag [UNKN ] Undocumented argument [char *] * Arg: use_special [UNKN ] Undocumented argument [boolean] * Arg: cses [UNKN ] Undocumented argument [CommonSubExpressionSet *] * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ void write_kbest_block(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointertag,char * specialtag,boolean use_special,CommonSubExpressionSet * cses,MethodTypeSet * mts,DPImplementation * dpi); /* Function: TransitionSet_from_GenericMatrix(gm) * * Descrip: Makes a transition set from a generic matrix * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [TransitionSet *] * */ TransitionSet * TransitionSet_from_GenericMatrix(GenericMatrix * gm); /* Function: can_kbest_GenericMatrix(gm) * * Descrip: sees whether the generic matrix is suitable for kbest optimisations * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean can_kbest_GenericMatrix(GenericMatrix * gm); /* Function: sort_TransitionSet_offset(ts) * * Descrip: Sorts by offi then offj * * * Arg: ts [UNKN ] Undocumented argument [TransitionSet *] * */ void sort_TransitionSet_offset(TransitionSet * ts); /* Function: comp_Transition(two,one) * * Descrip: comparison by offi/offj * * * Arg: two [UNKN ] Undocumented argument [Transition *] * Arg: one [UNKN ] Undocumented argument [Transition *] * * Return [UNKN ] Undocumented return value [int] * */ int comp_Transition(Transition * two,Transition * one); /* Function: show_TransitionSet(tset,ofp) * * Descrip: Shows a transition set * * * Arg: tset [UNKN ] Undocumented argument [TransitionSet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void show_TransitionSet(TransitionSet * tset,FILE * ofp); /* Function: hard_link_Transition(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Transition *] * * Return [UNKN ] Undocumented return value [Transition *] * */ Transition * hard_link_Transition(Transition * obj); /* Function: Transition_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Transition *] * */ Transition * Transition_alloc(void); /* Function: free_Transition(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Transition *] * * Return [UNKN ] Undocumented return value [Transition *] * */ Transition * free_Transition(Transition * obj); /* Function: add_TransitionSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransitionSet *] * Arg: add [OWNER] Object to add to the list [Transition *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_TransitionSet(TransitionSet * obj,Transition * add); /* Function: flush_TransitionSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransitionSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_TransitionSet(TransitionSet * obj); /* Function: TransitionSet_alloc_std(void) * * Descrip: Equivalent to TransitionSet_alloc_len(TransitionSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransitionSet *] * */ TransitionSet * TransitionSet_alloc_std(void); /* Function: TransitionSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransitionSet *] * */ TransitionSet * TransitionSet_alloc_len(int len); /* Function: hard_link_TransitionSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransitionSet *] * * Return [UNKN ] Undocumented return value [TransitionSet *] * */ TransitionSet * hard_link_TransitionSet(TransitionSet * obj); /* Function: TransitionSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransitionSet *] * */ TransitionSet * TransitionSet_alloc(void); /* Function: free_TransitionSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransitionSet *] * * Return [UNKN ] Undocumented return value [TransitionSet *] * */ TransitionSet * free_TransitionSet(TransitionSet * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void show_Transition(Transition * trans,FILE * ofp); void swap_TransitionSet(Transition ** list,int i,int j) ; void qsort_TransitionSet(Transition ** list,int left,int right,int (*comp)(Transition * ,Transition * )); void sort_TransitionSet(TransitionSet * obj,int (*comp)(Transition *, Transition *)); boolean expand_TransitionSet(TransitionSet * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/funcinfo.dy0000644000175000001440000003130107313404534015565 0ustar philippusers %{ #include "wisebase.h" #include "ftext.h" #include "inputfile.h" #define FuncInfoLISTLENGTH 32 enum argtype { ARGTYPE_UNKNOWN = 43, ARGTYPE_READ, ARGTYPE_WRITE, ARGTYPE_READWRITE, ARGTYPE_P2FUNC, ARGTYPE_OWNER, ARGTYPE_STATIC }; enum FI_TYPE { FI_CALLABLE = 12, FI_UNKNOWN, FI_INTERNAL }; #define iscword(c) (c == '_' ? 1 : isalnum(c)) %} struct ArgInfo int argtype; !def="ARGTYPE_UNKNOWN" boolean should_NULL !def="FALSE" char * name char * type char * desc int argpos; char * func_decl; // for pointers to functions, so we can get declaration correct struct ErrorInfo char * value char * desc struct FuncInfo char * name !def="NULL" char * type !def="NULL" char * complete_name; char * stripped_return; Ftext * ft; char * error ArgInfo ** arg !list ErrorInfo ** err !list !len="err_" char * sdesc; ArgInfo * ret !def="NULL" int functype !def="FI_UNKNOWN"; int line_in_c !def="0" int infopos; char * simple boolean is_hand_written !def="FALSE" struct ModuleInfo Ftext * ft %{ #include "funcinfo.h" void dump_FuncInfo(FuncInfo * fi,FILE * ofp ) { int i; fprintf(ofp,"Function info of %s\n",CKS(fi->name)); dump_Ftext(fi->ft,ofp); for(i=0;ilen;i++) { fprintf(ofp,"Argument %s type [%s] Desc %s\n",fi->arg[i]->name,fi->arg[i]->type,fi->arg[i]->desc); } } %func shows functions in *Function: * *des * * Arg * Returns number of lines printed %% int show_eddystyle_FuncInfo(FuncInfo * fi,FILE * ofp) { int i; int len=0; int maxn; maxn = max_argame(fi ); fprintf(ofp,"/* Function: %s(%s",CKS(fi->name),fi->len == 0 ? "void" : fi->arg[0]->name); for(i=1;ilen;i++) fprintf(ofp,",%s",fi->arg[i]->name); fprintf(ofp,")\n *\n"); len++; len += show_eddystyle_Ftext(fi->ft,"Descrip:",15,ofp,"No Description"); fprintf(ofp," *\n"); for(i=0;ilen;i++) len += show_eddystyle_ArgInfo(fi->arg[i],15,maxn,ofp); if( fi->ret != NULL && strcmp(fi->ret->type,"void") != 0 ) { fprintf(ofp," *\n * Return [%s] %s [%s]\n",ArgType_to_string(fi->ret->argtype),fi->ret->desc,CKS(fi->ret->type)); len +=2; } len += 2; fprintf(ofp," *\n */\n"); return len; } char * ArgType_to_string(int type) { switch(type) { case ARGTYPE_READ : return "READ "; case ARGTYPE_WRITE : return "WRITE"; case ARGTYPE_READWRITE : return "RW "; case ARGTYPE_P2FUNC : return "FUNCP"; case ARGTYPE_OWNER: return "OWNER"; case ARGTYPE_STATIC : return "SOFT "; default : return "UNKN "; } } int max_argame(FuncInfo * fi ) { int i; int max; if(fi->len == 0 ) { return 0; } for(i=1,max=strlen(fi->arg[0]->name);i < fi->len;i++) { if( max < strlen(fi->arg[i]->name) ) { max = strlen(fi->arg[i]->name); } } return max; } int show_eddystyle_ArgInfo(ArgInfo * ai,int depth,int namedepth,FILE * ofp) { fprintf(ofp," * %*s%*s [%s] %s [%s]\n",-(depth-3),"Arg:",namedepth,ai->name,ArgType_to_string(ai->argtype),ai->desc,CKS(ai->type)); return 1; } void sort_FuncInfo_by_position(FuncInfo * fi) { sort_FuncInfo(fi,compare_ArgInfo_pos); return; } int compare_ArgInfo_pos(ArgInfo * one,ArgInfo * two) { return one->argpos- two->argpos; } boolean reconcile_FuncInfo_with_funcstr(FuncInfo * fi,char * pass_str) { /** ok, stupid parsing for the moment **/ boolean ret = TRUE; char * runner; char * run2; char * arg; char ** base; char ** brk; char * fstr; int count; fstr = stringalloc(pass_str); if( fi->complete_name == NULL ) { fi->complete_name = stringalloc(fstr); } /** get the return type **/ if( strstartcmp(fstr,"const") == 0 ) { runner = fstr+5; for(;isspace(*runner);runner++) ; } else { runner = fstr; } if( strstartcmp(runner,"signed") == 0 ) { runner = fstr+6; for(;isspace(*runner);runner++) ; } if( strstartcmp(runner,"long") == 0 ) { runner = fstr+6; for(;isspace(*runner);runner++) ; } if( strstartcmp(runner,"struct") == 0 ) { runner = fstr+6; for(;isspace(*runner);runner++) ; } for(;isalnum(*runner) || *runner == '_' ;runner++) ; for(run2=runner;isspace(*runner);runner++) ; if( *runner == '*' ) { for(;*runner == '*';runner++) ; } else { runner = run2; } *runner = '\0'; if( fi->ret == NULL ) { fi->ret = ArgInfo_alloc(); fi->ret->name = stringalloc("return"); fi->ret->desc = stringalloc("Undocumented return value"); } fi->ret->type = stringalloc(fstr); /** got to the end of the return value **/ for(run2=runner+1;isspace(*run2);run2++) ; fi->stripped_return = stringalloc(run2); /** get the name of the function ***/ runner = strchr(run2,'(') ; if( runner == NULL ) { warn("reconciling function [%s] - no bracket!",pass_str); return FALSE; } arg = runner+1; *(runner) = '\0'; /** run2 now at the name **/ if( fi->name != NULL ) { if( strcmp(fi->name,run2) != 0 ) { warn("In reconciling function different names [%s] [%s]",fi->name,run2); } }else { fi->name = stringalloc(run2); } /*** now, process the argument list ***/ runner = arg + strlen(arg) -1; for(;runner > arg && *runner != ')';runner--) ; *runner = '\0'; base = brk = breakstring_protect(arg,",","()"); if( *brk != NULL && strcmp(*brk,"void") != 0 ) { for(count=0;*brk != NULL;brk++) { if( reconcile_FuncInfo_with_argstr(fi,*brk,count++) == FALSE ) ret = FALSE; } } ckfree(base); ckfree(fstr); sort_FuncInfo_by_position(fi); return ret; } boolean reconcile_FuncInfo_with_pfunc(FuncInfo * fi,char * str,int pos) { char * runner; char * name; ArgInfo * temp; char * held; /** This is a HUGE kludge. V.v.v. embarrasing ***/ /** assumme type (*name)(type,type,type) ***/ held = stringalloc(str); name = runner = strchr(str,'('); name = runner = strchr(runner,'*'); name++; for(runner++;!isspace(*runner) && *runner != ')' ;runner++) ; *runner = '\0'; if( (temp=get_ArgInfo_by_name(fi,name)) == NULL ) { temp = ArgInfo_alloc(); add_FuncInfo(fi,temp); temp->name = stringalloc(name); temp->desc = stringalloc("Undocumented argument"); temp->func_decl = held; } else { temp->type = stringalloc(str); temp->argtype = ARGTYPE_P2FUNC; temp->argpos = pos; temp->func_decl = held; } return TRUE; } FuncInfo * unknown_user_FuncInfo(char * funcstr) { FuncInfo * fi; fi = FuncInfo_from_str("Unknown user-defined function"); if( reconcile_FuncInfo_with_funcstr(fi,funcstr) == FALSE ) { warn("Could not reconcile [%s]... bad internal error.",funcstr); } return fi; } boolean reconcile_FuncInfo_with_argstr(FuncInfo * fi,char * str,int pos) { char * runner; char * name; ArgInfo * temp; if( strchr(str,'(') != NULL ) return reconcile_FuncInfo_with_pfunc(fi,str,pos); for(;isspace(*str);str++) ; runner = str + strlen(str) -1; for(;runner > str && isspace(*runner);runner--) ; *(runner+1) = '\0'; for(;runner > str && !isspace(*runner);runner--) ; name = runner+1; if( strcmp(name,"void") == 0 ) return TRUE; for(;runner > str && isspace(*runner);runner--) ; *(runner+1) = '\0'; if( (temp=get_ArgInfo_by_name(fi,name)) == NULL ) { temp = ArgInfo_alloc(); add_FuncInfo(fi,temp); temp->name = stringalloc(name); temp->desc = stringalloc("Undocumented argument"); } temp->type = stringalloc(str); temp->argpos = pos; return TRUE; } ArgInfo * get_ArgInfo_by_name(FuncInfo * fi,char * str) { int i; for(i=0;ilen;i++) if( strcmp(fi->arg[i]->name,str) == 0 ) return fi->arg[i]; return NULL; } ArgInfo * ArgInfo_in_FuncInfo_from_varstr(FuncInfo * fi,char * str,...) { char buffer[MAXLINE]; ArgInfo * out; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); out = ArgInfo_alloc(); out->name = stringalloc(buffer); add_FuncInfo(fi,out); return out; } FuncInfo * FuncInfo_named_from_varstr(int type,char * str, ...) { char buffer[MAXLINE]; FuncInfo * out; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); out = FuncInfo_alloc_std(); out->functype = type; out->name = stringalloc(buffer); out->ft = Ftext_alloc_std(); add_Ftext(out->ft,Fblock_alloc_std()); return out; } FuncInfo * FuncInfo_from_str(char * str) { FuncInfo * fi; fi = FuncInfo_alloc_std(); fi->ft = single_Ftext_from_str(str); return fi; } /** I/O from user **/ ModuleInfo * read_ModuleInfo_line(char * line,FILE * ifp) { ModuleInfo * out; char buffer[MAXLINE]; if( strstartcmp(line,"%module") != 0 ) { warn("Attempting to read module help with line starting [%30s] not %module",line); return NULL; } out = ModuleInfo_alloc(); out->ft = read_Ftext(buffer,MAXLINE,ifp,"%",fgets); return out; } FuncInfo * read_FuncInfo_line(char * line,FILE * ifp) { FuncInfo * out; ArgInfo * ari; char buffer[MAXLINE]; char * runner; if( strstartcmp(line,"%func") != 0 ) { warn("Attempting to read in-line function help with line starting [%30s] not %func",line); return NULL; } out = FuncInfo_alloc_std(); out->functype = FI_CALLABLE; out->ft = read_Ftext(buffer,MAXLINE,ifp,"%",get_watched_line); if( strstartcmp(buffer,"%%") == 0 ) return out; /*** could be in any order ***/ for(;;) { /* fprintf(stderr,"Looking at [%s]\n",buffer); */ if( feof(ifp) || ferror(ifp) ) { warn("End of file or file read error while in FuncInfo read. Not good!"); break; } else if ( strstartcmp(buffer,"%%") == 0 ) { break; } else if ( strstartcmp(buffer,"%simple") == 0 ) { if( (runner=strtok(buffer+7,spacestr)) == NULL ) { warn("Got a simple name specification, but no name!"); } else { out->simple = stringalloc(runner); } get_watched_line(buffer,MAXLINE,ifp); } else if( strstartcmp(buffer,"%arg") == 0) { while( get_watched_line(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '%' ) break; ari = read_ArgInfo_line(buffer); if( strcmp(ari->name,"return") == 0 ) { out->ret = ari; } else if( ari != NULL ) { add_FuncInfo(out,ari); } } } else if ( strstartcmp(buffer,"%short") == 0 ) { for(runner=buffer;*runner && !isspace(*runner);runner++) ; for(;*runner && isspace(*runner);runner++) ; out->sdesc=stringalloc(runner); get_watched_line(buffer,MAXLINE,ifp); } else if ( strstartcmp(buffer,"%type") == 0 ) { if( strstr(buffer,"call") != NULL ) { out->functype = FI_CALLABLE; } else if ( strstr(buffer,"int") != NULL ) { out->functype = FI_INTERNAL; } get_watched_line(buffer,MAXLINE,ifp); } else { warn("Cannot understand %% tag %20s\n",buffer); while( get_watched_line(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '%' ) break; } } if( buffer[0] == '%') continue; /*** back to for(;;) ***/ /* else */ warn("In funcinfo line, could not understand [%s], going to skip to next %% tag",buffer); while( get_watched_line(buffer,MAXLINE,ifp) != NULL ) { chop_newline(buffer); if( buffer[0] == '%' ) break; else { warn("Did not interpret line [%s]\n",buffer); } } } return out; } int get_arg_type(char * line,boolean * should_NULL) { char * runner; *should_NULL = FALSE; for(runner=line;*runner && !isspace(*runner);runner++) ; runner--; if( runner-line < 3 && *runner == 'N') { *should_NULL = TRUE; *runner=' '; } if ( strwordcmp(line,"rw",spacestr) == 0 ) return ARGTYPE_READWRITE; if( strwordcmp(line,"r",spacestr) == 0 ) return ARGTYPE_READ; if( strwordcmp(line,"o",spacestr) == 0 ) return ARGTYPE_OWNER; if( strwordcmp(line,"s",spacestr) == 0 ) return ARGTYPE_STATIC; if( strwordcmp(line,"f",spacestr) == 0 ) return ARGTYPE_P2FUNC; else if ( strwordcmp(line,"w",spacestr) == 0 ) return ARGTYPE_WRITE; else return ARGTYPE_UNKNOWN; } ArgInfo * read_ArgInfo_line(char * line) { ArgInfo * out; char * runner; char * fix; out = ArgInfo_alloc(); for(runner=line;*runner && !isalpha(*runner) ;runner++) ; fix = runner; for(runner=line;*runner && iscword(*runner);runner++) ; /*** got first word ***/ *runner = '\0'; out->name = stringalloc(fix); /*** next word ***/ for(runner++;*runner && !isalpha(*runner);runner++) ; /*** if it is a valid arg type, get it and move on ***/ if( (out->argtype=get_arg_type(runner,&out->should_NULL)) != ARGTYPE_UNKNOWN) { for(;*runner && isalnum(*runner);runner++) ; for(;*runner && isspace(*runner);runner++) ; } fix = runner; for(;*runner && *runner != '\n';runner++) ; *runner = '\0'; out->desc = stringalloc(fix); return out; } %} wise-2.4.1/src/dyc/optimiser.c0000644000175000001440000004551210670453715015615 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "optimiser.h" /* Function: expr_ij_dependence(expr,ijdep) * * Descrip: figures out whether this cse is i or j dependent * * * Arg: expr [UNKN ] Undocumented argument [ExprTree *] * Arg: ijdep [UNKN ] Undocumented argument [int *] * */ # line 33 "optimiser.dy" void expr_ij_dependence(ExprTree * expr,int * ijdep) { int i; if( expr->type == ETR_NAME ) { if( strcmp(expr->word,"i") == 0 ) { *ijdep = (*ijdep | CSE_I_DEP); } if( strcmp(expr->word,"j") == 0 ) { *ijdep = (*ijdep | CSE_J_DEP); } } for(i=0;inochild;i++) { expr_ij_dependence(expr->child[i],ijdep); } } /* Function: strcat_cses_ExprTree(epr,buffer,sc,mts,dpi) * * Descrip: Writes code with sub expressions in the correct places * * * Arg: epr [UNKN ] Undocumented argument [ExprTree *] * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: sc [UNKN ] Undocumented argument [Scope *] * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ # line 54 "optimiser.dy" void strcat_cses_ExprTree(ExprTree * epr,char * buffer,Scope * sc,MethodTypeSet * mts,DPImplementation * dpi) { strcat_ExprTree_Scoped(epr,buffer,sc,mts,dpi->dycw,cses_expr_placer,NULL); } /* Function: cses_expr_placer(etr,buffer,data) * * Descrip: pointer to function that does the magic on the cses placer system * * * Arg: etr [UNKN ] Undocumented argument [ExprTree *] * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: data [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 63 "optimiser.dy" boolean cses_expr_placer(ExprTree * etr,char * buffer,void * data) { char b[20]; /* fprintf(stdout,"Getting into scoping, but with %d and %d\n",etr->type,etr->cse);*/ if( etr->cse == NULL ) return FALSE; strcat(buffer,"subexpr"); sprintf(b,"%d",etr->cse->id); strcat(buffer,b); return TRUE; } /* Function: id_CommonSubExpressionSet(cses) * * Descrip: Places ids into the cses * * * Arg: cses [UNKN ] Undocumented argument [CommonSubExpressionSet *] * */ # line 81 "optimiser.dy" void id_CommonSubExpressionSet(CommonSubExpressionSet * cses) { int i; for(i=0;ilen;i++) cses->cse[i]->id = i; } /* Function: show_CommonSubExpressionSet(cses,ofp) * * Descrip: Shows common sub expression set * * * Arg: cses [UNKN ] Undocumented argument [CommonSubExpressionSet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 96 "optimiser.dy" void show_CommonSubExpressionSet(CommonSubExpressionSet * cses,FILE * ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,"Sub Expression %d - Number of times seen %d IJdep %d\n ",i,cses->cse[i]->number,cses->cse[i]->type); print_ExprTree(cses->cse[i]->expr,ofp); fprintf(ofp,"\n"); } } /* Function: find_CommonSubExpressions(gm,source_ind_promote) * * Descrip: Makes a CommonSubExpressionSet from the * GenericMatrix structure. * * if source_ind_promote is true, then source_independent type systems * are automatically promoted as a common sub expression, regardless of * number of subexpressions found * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: source_ind_promote [UNKN ] Undocumented argument [boolean] * * Return [UNKN ] Undocumented return value [CommonSubExpressionSet *] * */ # line 116 "optimiser.dy" CommonSubExpressionSet * find_CommonSubExpressions(GenericMatrix * gm,boolean source_ind_promote) { int i,j; ExprTree * exlist[512]; int notags =0; CommonSubExpressionSet * out; CommonSubExpression * temp; out = CommonSubExpressionSet_alloc_std(); for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { attach_expressions_to_list(exlist,¬ags,gm->state[i]->source[j]->etr); } if( source_ind_promote == TRUE && gm->state[i]->etr != NULL) { temp = CommonSubExpression_alloc(); temp->expr = gm->state[i]->etr; gm->state[i]->etr->cse = temp; temp->number = 1; add_CommonSubExpressionSet(out,temp); } else { attach_expressions_to_list(exlist,¬ags,gm->state[i]->etr); } } for(i=0;ispec_len;i++) { for(j=0;jspecial[i]->len;j++) { attach_expressions_to_list(exlist,¬ags,gm->special[i]->source[j]->etr); } attach_expressions_to_list(exlist,¬ags,gm->special[i]->etr); } for(i=0;icse != NULL ) continue; temp = NULL; for(j=i+1;jcse != NULL ) continue; if( identical_ExprTree(exlist[i],exlist[j]) == TRUE ) { if( temp == NULL ) { temp = CommonSubExpression_alloc(); temp->expr = exlist[i]; exlist[i]->cse = temp; temp->number = 1; add_CommonSubExpressionSet(out,temp); } /* we do this for every subexpression that we find */ exlist[j]->cse = temp; temp->number++; } } } /* find i,j dependence */ for(i=0;ilen;i++) { expr_ij_dependence(out->cse[i]->expr,&out->cse[i]->type); } id_CommonSubExpressionSet(out); return out; } /* Function: should_store_ExprTree_cse(start) * * Descrip: whether we should consider this a possible common sub expression or not * * * Arg: start [UNKN ] Undocumented argument [ExprTree *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 193 "optimiser.dy" boolean should_store_ExprTree_cse(ExprTree * start) { if( start->type == ETR_EXPRESSION || start->type == ETR_METHOD ) return TRUE; if( start->type == ETR_TAG || start->type == ETR_ARRAY || start->type == ETR_STRUCTREF || start->type == ETR_REFERENCE ) { if( start->parent->type == ETR_EXPRESSION || start->parent->type == ETR_STATEMENT) { return TRUE; } } return FALSE; } /* Function: attach_expressions_to_list(list,no,start) * * Descrip: Attaches only ETR_EXPRESSIONS into the list. * Really a subroutine for find_CommonSubExpressions * * * Arg: list [UNKN ] Undocumented argument [ExprTree **] * Arg: no [UNKN ] Undocumented argument [int *] * Arg: start [UNKN ] Undocumented argument [ExprTree *] * */ # line 212 "optimiser.dy" void attach_expressions_to_list(ExprTree ** list,int * no,ExprTree * start) { int i; if( start == NULL ) return; /* fprintf(stderr,"Looking at expression %d... to %d\n",start->type,ETR_EXPRESSION); */ if( should_store_ExprTree_cse(start) == TRUE ) { list[*no] = start; *no = *no +1; } if( start->type == ETR_METHOD && start->nochild == 2) { for(i=0;ichild[1]->nochild;i++) attach_expressions_to_list(list,no,start->child[1]->child[i]); } else { for(i=0;inochild;i++) attach_expressions_to_list(list,no,start->child[i]); } } /* Function: identical_ExprTree(one,two) * * Descrip: Says whether two ExprTrees are completely identical - ie, * same trees with same tags in the same order. * * * Arg: one [UNKN ] Undocumented argument [ExprTree *] * Arg: two [UNKN ] Undocumented argument [ExprTree *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 239 "optimiser.dy" boolean identical_ExprTree(ExprTree * one,ExprTree * two) { int i; if( one->type != two->type ) return FALSE; if( one->word != NULL || two->word != NULL ) { if( strcmp(one->word,two->word) != 0 ) return FALSE; } if( one->nochild != two->nochild ) return FALSE; for(i=0;inochild;i++ ) { if( identical_ExprTree(one->child[i],two->child[i]) == FALSE ) { return FALSE; } } return TRUE; } # line 290 "optimiser.c" /* Function: hard_link_CommonSubExpression(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CommonSubExpression *] * * Return [UNKN ] Undocumented return value [CommonSubExpression *] * */ CommonSubExpression * hard_link_CommonSubExpression(CommonSubExpression * obj) { if( obj == NULL ) { warn("Trying to hard link to a CommonSubExpression object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CommonSubExpression_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CommonSubExpression *] * */ CommonSubExpression * CommonSubExpression_alloc(void) { CommonSubExpression * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CommonSubExpression *) ckalloc (sizeof(CommonSubExpression))) == NULL) { warn("CommonSubExpression_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->id = 0; out->type = 0; out->number = 0; return out; } /* Function: free_CommonSubExpression(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CommonSubExpression *] * * Return [UNKN ] Undocumented return value [CommonSubExpression *] * */ CommonSubExpression * free_CommonSubExpression(CommonSubExpression * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CommonSubExpression obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->expr is linked in */ ckfree(obj); return NULL; } /* Function: swap_CommonSubExpressionSet(list,i,j) * * Descrip: swap function: an internal for qsort_CommonSubExpressionSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [CommonSubExpression **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_CommonSubExpressionSet(CommonSubExpression ** list,int i,int j) { CommonSubExpression * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_CommonSubExpressionSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_CommonSubExpressionSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [CommonSubExpression **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_CommonSubExpressionSet(CommonSubExpression ** list,int left,int right,int (*comp)(CommonSubExpression * ,CommonSubExpression * )) { int i,last; if( left >= right ) return; swap_CommonSubExpressionSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_CommonSubExpressionSet (list,++last,i); } swap_CommonSubExpressionSet (list,left,last); qsort_CommonSubExpressionSet(list,left,last-1,comp); qsort_CommonSubExpressionSet(list,last+1,right,comp); } /* Function: sort_CommonSubExpressionSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_CommonSubExpressionSet * * * Arg: obj [UNKN ] Object containing list [CommonSubExpressionSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_CommonSubExpressionSet(CommonSubExpressionSet * obj,int (*comp)(CommonSubExpression *, CommonSubExpression *)) { qsort_CommonSubExpressionSet(obj->cse,0,obj->len-1,comp); return; } /* Function: expand_CommonSubExpressionSet(obj,len) * * Descrip: Really an internal function for add_CommonSubExpressionSet * * * Arg: obj [UNKN ] Object which contains the list [CommonSubExpressionSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_CommonSubExpressionSet(CommonSubExpressionSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_CommonSubExpressionSet called with no need"); return TRUE; } if( (obj->cse = (CommonSubExpression ** ) ckrealloc (obj->cse,sizeof(CommonSubExpression *)*len)) == NULL) { warn("ckrealloc failed for expand_CommonSubExpressionSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_CommonSubExpressionSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [CommonSubExpressionSet *] * Arg: add [OWNER] Object to add to the list [CommonSubExpression *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_CommonSubExpressionSet(CommonSubExpressionSet * obj,CommonSubExpression * add) { if( obj->len >= obj->maxlen) { if( expand_CommonSubExpressionSet(obj,obj->len + CommonSubExpressionSetLISTLENGTH) == FALSE) return FALSE; } obj->cse[obj->len++]=add; return TRUE; } /* Function: flush_CommonSubExpressionSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [CommonSubExpressionSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_CommonSubExpressionSet(CommonSubExpressionSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->cse[i] != NULL) { free_CommonSubExpression(obj->cse[i]); obj->cse[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: CommonSubExpressionSet_alloc_std(void) * * Descrip: Equivalent to CommonSubExpressionSet_alloc_len(CommonSubExpressionSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [CommonSubExpressionSet *] * */ CommonSubExpressionSet * CommonSubExpressionSet_alloc_std(void) { return CommonSubExpressionSet_alloc_len(CommonSubExpressionSetLISTLENGTH); } /* Function: CommonSubExpressionSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [CommonSubExpressionSet *] * */ CommonSubExpressionSet * CommonSubExpressionSet_alloc_len(int len) { CommonSubExpressionSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = CommonSubExpressionSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->cse = (CommonSubExpression ** ) ckcalloc (len,sizeof(CommonSubExpression *))) == NULL) { warn("Warning, ckcalloc failed in CommonSubExpressionSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_CommonSubExpressionSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CommonSubExpressionSet *] * * Return [UNKN ] Undocumented return value [CommonSubExpressionSet *] * */ CommonSubExpressionSet * hard_link_CommonSubExpressionSet(CommonSubExpressionSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a CommonSubExpressionSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CommonSubExpressionSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CommonSubExpressionSet *] * */ CommonSubExpressionSet * CommonSubExpressionSet_alloc(void) { CommonSubExpressionSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CommonSubExpressionSet *) ckalloc (sizeof(CommonSubExpressionSet))) == NULL) { warn("CommonSubExpressionSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->cse = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_CommonSubExpressionSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CommonSubExpressionSet *] * * Return [UNKN ] Undocumented return value [CommonSubExpressionSet *] * */ CommonSubExpressionSet * free_CommonSubExpressionSet(CommonSubExpressionSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CommonSubExpressionSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->cse != NULL) { for(i=0;ilen;i++) { if( obj->cse[i] != NULL) free_CommonSubExpression(obj->cse[i]); } ckfree(obj->cse); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/optimiser.h0000644000175000001440000002133310670453715015615 0ustar philippusers#ifndef DYNAMITEoptimiserHEADERFILE #define DYNAMITEoptimiserHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna2.h" #include "type.h" #define CommonSubExpressionSetLISTLENGTH 512 #define CSE_I_DEP 1 #define CSE_J_DEP 2 #define IS_I_DEP_CSE(cse) ((cse->type & CSE_I_DEP) == CSE_I_DEP ? TRUE : FALSE) #define IS_J_DEP_CSE(cse) ((cse->type & CSE_J_DEP) == CSE_J_DEP ? TRUE : FALSE) #define IS_NON_IJ_DEP_CSE(cse) (cse->type == 0 ? TRUE : FALSE) struct CommonSubExpression { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ExprTree * expr; int id; /* able to set things as being 1,2,3 etc */ int type; /* is i or j or i,j or no dependent */ int number; /* number of times this sub expression is used */ } ; /* CommonSubExpression defined */ #ifndef DYNAMITE_DEFINED_CommonSubExpression typedef struct CommonSubExpression CommonSubExpression; #define DYNAMITE_DEFINED_CommonSubExpression #endif struct CommonSubExpressionSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif CommonSubExpression ** cse; /* list of common sub expressions */ int len;/* len for above cse */ int maxlen; /* maxlen for above cse */ } ; /* CommonSubExpressionSet defined */ #ifndef DYNAMITE_DEFINED_CommonSubExpressionSet typedef struct CommonSubExpressionSet CommonSubExpressionSet; #define DYNAMITE_DEFINED_CommonSubExpressionSet #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: expr_ij_dependence(expr,ijdep) * * Descrip: figures out whether this cse is i or j dependent * * * Arg: expr [UNKN ] Undocumented argument [ExprTree *] * Arg: ijdep [UNKN ] Undocumented argument [int *] * */ void expr_ij_dependence(ExprTree * expr,int * ijdep); /* Function: strcat_cses_ExprTree(epr,buffer,sc,mts,dpi) * * Descrip: Writes code with sub expressions in the correct places * * * Arg: epr [UNKN ] Undocumented argument [ExprTree *] * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: sc [UNKN ] Undocumented argument [Scope *] * Arg: mts [UNKN ] Undocumented argument [MethodTypeSet *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ void strcat_cses_ExprTree(ExprTree * epr,char * buffer,Scope * sc,MethodTypeSet * mts,DPImplementation * dpi); /* Function: show_CommonSubExpressionSet(cses,ofp) * * Descrip: Shows common sub expression set * * * Arg: cses [UNKN ] Undocumented argument [CommonSubExpressionSet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void show_CommonSubExpressionSet(CommonSubExpressionSet * cses,FILE * ofp); /* Function: find_CommonSubExpressions(gm,source_ind_promote) * * Descrip: Makes a CommonSubExpressionSet from the * GenericMatrix structure. * * if source_ind_promote is true, then source_independent type systems * are automatically promoted as a common sub expression, regardless of * number of subexpressions found * * * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: source_ind_promote [UNKN ] Undocumented argument [boolean] * * Return [UNKN ] Undocumented return value [CommonSubExpressionSet *] * */ CommonSubExpressionSet * find_CommonSubExpressions(GenericMatrix * gm,boolean source_ind_promote); /* Function: attach_expressions_to_list(list,no,start) * * Descrip: Attaches only ETR_EXPRESSIONS into the list. * Really a subroutine for find_CommonSubExpressions * * * Arg: list [UNKN ] Undocumented argument [ExprTree **] * Arg: no [UNKN ] Undocumented argument [int *] * Arg: start [UNKN ] Undocumented argument [ExprTree *] * */ void attach_expressions_to_list(ExprTree ** list,int * no,ExprTree * start); /* Function: hard_link_CommonSubExpression(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CommonSubExpression *] * * Return [UNKN ] Undocumented return value [CommonSubExpression *] * */ CommonSubExpression * hard_link_CommonSubExpression(CommonSubExpression * obj); /* Function: CommonSubExpression_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CommonSubExpression *] * */ CommonSubExpression * CommonSubExpression_alloc(void); /* Function: free_CommonSubExpression(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CommonSubExpression *] * * Return [UNKN ] Undocumented return value [CommonSubExpression *] * */ CommonSubExpression * free_CommonSubExpression(CommonSubExpression * obj); /* Function: add_CommonSubExpressionSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [CommonSubExpressionSet *] * Arg: add [OWNER] Object to add to the list [CommonSubExpression *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_CommonSubExpressionSet(CommonSubExpressionSet * obj,CommonSubExpression * add); /* Function: flush_CommonSubExpressionSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [CommonSubExpressionSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_CommonSubExpressionSet(CommonSubExpressionSet * obj); /* Function: CommonSubExpressionSet_alloc_std(void) * * Descrip: Equivalent to CommonSubExpressionSet_alloc_len(CommonSubExpressionSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [CommonSubExpressionSet *] * */ CommonSubExpressionSet * CommonSubExpressionSet_alloc_std(void); /* Function: CommonSubExpressionSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [CommonSubExpressionSet *] * */ CommonSubExpressionSet * CommonSubExpressionSet_alloc_len(int len); /* Function: hard_link_CommonSubExpressionSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CommonSubExpressionSet *] * * Return [UNKN ] Undocumented return value [CommonSubExpressionSet *] * */ CommonSubExpressionSet * hard_link_CommonSubExpressionSet(CommonSubExpressionSet * obj); /* Function: CommonSubExpressionSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CommonSubExpressionSet *] * */ CommonSubExpressionSet * CommonSubExpressionSet_alloc(void); /* Function: free_CommonSubExpressionSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CommonSubExpressionSet *] * * Return [UNKN ] Undocumented return value [CommonSubExpressionSet *] * */ CommonSubExpressionSet * free_CommonSubExpressionSet(CommonSubExpressionSet * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean cses_expr_placer(ExprTree * etr,char * buffer,void * data); void id_CommonSubExpressionSet(CommonSubExpressionSet * cses); boolean should_store_ExprTree_cse(ExprTree * start); boolean identical_ExprTree(ExprTree * one,ExprTree * two); void swap_CommonSubExpressionSet(CommonSubExpression ** list,int i,int j) ; void qsort_CommonSubExpressionSet(CommonSubExpression ** list,int left,int right,int (*comp)(CommonSubExpression * ,CommonSubExpression * )); void sort_CommonSubExpressionSet(CommonSubExpressionSet * obj,int (*comp)(CommonSubExpression *, CommonSubExpression *)); boolean expand_CommonSubExpressionSet(CommonSubExpressionSet * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/dy2om.dy0000644000175000001440000002636107313404533015021 0ustar philippusers %{ #include "dyna2.h" #include "exprtree.h" enum OmStateType { OmState_TYPE_UNKNOWN = 67, OmState_TYPE_STATE, OmState_TYPE_SEMISTATE, OmState_TYPE_MIDSTATE }; #define OneModelLISTLENGTH 64 typedef struct descent_return { int is_doable; /* 1 is yes, 0 cannot be handled by Compugen */ int is_index; /* 1 is yes, 0 is it is a float/number */ int is_query; /* when is index, 1 means in query, 0 in target */ int is_variable; struct OmUnit * unit; /* if non-NULL, this is the "done" unit */ } CugenYaccReturn; %} struct OmState char * name int type; !def="OmState_TYPE_UNKNOWN" struct OmUnit char * c_string // string of the actual C to use in making profile line int base // offset in profile line, must be the same as t_prf or w_base int length // 1 for t_prf lines. Longer for w_base lines. int is_tprf; struct OmTrans OmState * from !link OmState * to !link int dx int dy int t_prf !def="-1" int dprf int t_seq !def="-1" int dseq int w_base !def="-1" int w_seq int dwx int dwy OmUnit * tprf_unit OmUnit * wbase_unit int current_base; struct OmTransFunc char * name Method * me struct OneModel char * name int state_num int semistate_num int midstate_num int profile_line_size OmTrans ** trans !list OmState ** state !list !len="st_" OmTransFunc ** tfunc !list !len="tf_" %{ #include "dy2om.h" /*** Globals used to communicate with yacc parser These are defined in type.dy. Here we will define them as externs. ***/ extern char * calc_lex_string; extern int stringpos; extern ExprTree * root; /* Conversion functions from internal dynamite datastruct to OneModel structure */ OneModel * OneModel_from_GenericMatrix(GenericMatrix * gm,MethodTypeSet * mts) { OneModel * out; OmTrans * trans; Scope * sc; int i,j; out = OneModel_alloc_std(); sc = std_Dynamite_Scope(); add_GenericMatrix_Scope(sc,gm); /*** add states ***/ for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { trans = OmTrans_from_CellSource(0,gm->state[i]->source[j],mts,sc); add_OneModel(out,trans); /* adds trans to out->trans list */ } } /*** should now do specials ***/ free_Scope(sc); return out; } OmTrans * OmTrans_from_CellSource(int base_point,CellSource * s,MethodTypeSet * mts,Scope * sc) { OmTrans * out; ExprTree * et; CugenYaccReturn ret; out = OmTrans_alloc(); out->dx = s->offi; out->dy = s->offj; /** this is the tricky part **/ /** copied from type.dy allocd_calc_line **/ /*** set globals that we share with lex/yacc ***/ calc_lex_string = s->source_expr; stringpos= 0; root = NULL; /*** parse it ***/ yyparse(); /*** check root, if NULL... otta here ***/ if( root == NULL ) { fatal("Nasty error, we cannot parse this calc line in making OneModel transition"); } find_toplevel_name(root); /** debugging stuff for now **/ printf("Doing calc line [%s]\n",s->source_expr); print_ExprTree(root); /** ok, just enter the function correctly **/ ret = descend_ExprTree_Cugen(root,mts,TRUE,sc,out); if( ret.is_doable == 0 ) { printf("Can't do this calc"); } else { printf("Can do this calc"); } printf("End\n\n"); return out; } OmState * OmState_from_CellState(CellState * cs) { OmState * out; out = OmState_alloc(); /* warn if NULL...oops! */ out->name = stringalloc(cs->name); if( cs->is_special_i == TRUE ) out->type = OmState_TYPE_MIDSTATE; else out->type = OmState_TYPE_STATE; return out; } /* Descent of yacc grammar to get Compugen model */ %func Recursive parser of the yacc grammar for compugen. If it is impossible for compugen to do, then is_doable == 0 and the descent should abort asap. If not, at the lowest level of being able to map to a compugen number, it is mapped. targetname should be entire scope. %% CugenYaccReturn descend_ExprTree_Cugen(ExprTree * et,MethodTypeSet * mts,boolean is_attachable,Scope * sc,OmTrans * ot) { int i; CugenYaccReturn out; CugenYaccReturn child; ScopeUnit * su; OmUnit * unit; set_CugenYaccReturn(&out); switch(et->type) { case ETR_STATEMENT : /** descend into grammar **/ for(i=0;inochild;i++) { child = descend_ExprTree_Cugen(et->child[i],mts,is_attachable,sc,ot); if( child.is_doable == 0 ) { out.is_doable = 0; return out; /** get out of here now! **/ } } /** nothing else, if we are here, then we are ok! **/ out.is_doable = 1; return out; case ETR_EXPRESSION : /** expression is *at the moment* only 3 things wide **/ if( et->nochild != 3) { warn("Annoying. Sadly we have written the compugen parser to only have 3 piece expressions. You have %d piece ones. So... have to fail",et->nochild); out.is_doable = 0; return out; } /** we can only handle pluses **/ if( et->child[1]->type != ETR_OPERATOR || et->child[1]->word[0] != '+' ) { warn("Sadly the compugen parser can only handle simple plus expressions. you have a middle expression of type [%d] with character [%s]",et->child[1]->type,CKS(et->child[1]->word)); out.is_doable = 0; return out; } /** ok, now descend into 0 and 2 child **/ child = descend_ExprTree_Cugen(et->child[0],mts,is_attachable,sc,ot); if( child.is_doable == 0 ) { out.is_doable = 0; return out; /** get out of here now! **/ } child = descend_ExprTree_Cugen(et->child[2],mts,is_attachable,sc,ot); if( child.is_doable == 0 ) { out.is_doable = 0; return out; /** get out of here now! **/ } /** fine! **/ out.is_doable = 1; return out; /** end of ETR_EXPRESSION **/ case ETR_NUMBER : /** too easy. This is a non-index, query associated thing **/ out.is_doable = 1; out.is_index = 0; out.is_query = 1; if( is_attachable == FALSE ) { /** we are in an array/method call, just chain out for them to know **/ return out; } /** ok, lets attach it now! **/ if( ot->tprf_unit != NULL ) { warn("This is annoying problem. We have a very simple grammar involved in compugen things, and can't cope with 2 tprfs. We should!!"); out.is_doable = 0; return out; } unit = OmUnit_alloc(); /*** should put away C loop now ***/ unit->base = (-1); /** unassigned for the moment **/ unit->length = 1; unit->is_tprf = 1; out.unit = unit; ot->tprf_unit = unit; return out; /*** end of NUMBER ***/ case ETR_NAME : /** If it is top level, need to scope to query/target/resource/extern **/ if( (et->attrib & IS_TOPLEVEL) == IS_TOPLEVEL) { su = ScopeUnit_from_Scope(sc,et->word); if( su == NULL ) { warn("Currently we can't cope with implicit externs in compugen funcs"); out.is_doable = 0; return out; } if( su->scope_type == SCOPE_TARGET ) { out.is_doable = 1; out.is_variable = 1; out.is_query = 0; return out; } /*** otherwise, if this attachable, then - lets attach to tprf **/ out.is_doable = 1; out.is_index = 0; out.is_variable = 0; out.is_query = 1; if( is_attachable == FALSE ) { /** we are in an array/method call, just chain out for them to know **/ out.is_variable = 1; return out; } /** we should look at the type here... is this really something we can "add"**/ /** ok, lets attach it now! **/ if( ot->tprf_unit != NULL ) { warn("This is annoying problem. We have a very simple grammar involved in compugen things, and can't cope with 2 tprfs. We should!!"); out.is_doable = 0; return out; } unit = OmUnit_alloc(); /*** should put away C loop now ***/ unit->base = (-1); /** unassigned for the moment **/ unit->length = 1; unit->is_tprf = 1; out.unit = unit; ot->tprf_unit = unit; return out; /*** end of if TOP_LEVEL ***/ } /** is not top level... do we care? **/ if( is_attachable == TRUE ) { warn("I feel bad about this: we have a non-top level name which you claim is attachable. Should not be!"); } return out; /** end of ETR_NAME **/ case ETR_TAG : /** right... need to loop into tag... **/ /** for the moment, handle only 1 length tags. Should be most **/ if( et->nochild > 1 ) { warn("Can't currently cope with tags with more than one child. Yikes!"); out.is_doable = 0; return out; } child = descend_ExprTree_Cugen(et->child[0],mts,is_attachable,sc,ot); return child; /** get out of here now! **/ case ETR_ARRAY : /** ok, lets see the first part of the array **/ child = descend_ExprTree_Cugen(et->child[0],mts,FALSE,sc,ot); if( child.is_doable == 0 ) return child; if( child.is_query == 0 ) { /** is a target type. No! **/ warn("Certainly can't array into target type for compugen port"); out.is_doable = 0; return out; } /** should be a query type, not indexed. Lets hope so! **/ /** ok, now the expression into the array. Lets see what it is **/ child = descend_ExprTree_Cugen(et->child[1],mts,FALSE,sc,ot); printf("Child of array into is %d\n",child.is_doable); if( child.is_doable == 0 ) return child; /** if child is query ... then we have a tprf ***/ if( child.is_query == 1 ) { if( ot->tprf_unit != NULL ) { warn("This is annoying problem. We have a very simple grammar involved in compugen things, and can't cope with 2 tprfs. We should!!"); out.is_doable = 0; return out; } unit = OmUnit_alloc(); /*** should put away C loop now ***/ unit->base = (-1); /** unassigned for the moment **/ unit->length = 1; unit->is_tprf = 1; out.unit = unit; ot->tprf_unit = unit; out.is_doable = 1; return out; } else { warn("Not sure what to do with non query typed array expressions"); return out; } warn("Should not have got here!!!!"); return out; default : warn("Fell into an uncatched ETR_ type [%d]. Does not look good for you!",et->type); out.is_doable = 0; return out; } /* end of switch */ } void set_CugenYaccReturn(CugenYaccReturn * ret) { ret->is_doable = 0; ret->is_index = 0; ret->is_query = 0; ret->unit = NULL; } /* Debugging/test functions, not going to be used in final port */ %func writes the model definition %% void write_OneModel(OneModel * om,FILE * ofp) { int i; fprintf(ofp,"FILE_TYPE=MODEL;\n"); /*** boring stuff ***/ fprintf(ofp,"transition_name from to dx dy t_prf dprf t_seq dseq w_base w_seq dwx dwy\n"); for(i=0;ilen;i++) { write_OmTrans(i,om->trans[i],ofp); } } %func writes one transition line %% void write_OmTrans(int number,OmTrans * ot,FILE * ofp) { fprintf(ofp,"Trans%d %s %s %d %d %d %d %d %d %d %d %d %d\n",number, ot->from->name, ot->to->name, ot->dx, ot->dy, ot->t_prf, ot->dprf, ot->t_seq, ot->dseq, ot->w_base, ot->w_seq, ot->dwx, ot->dwy ); } %} wise-2.4.1/src/dyc/dynashadow.c0000644000175000001440000030051210670453715015735 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dynashadow.h" #include "dynafunc.h" # line 19 "dynashadow.dy" void write_dc_functions(DYNFILE * dfp,GenericMatrix * gm) { write_shadow_dc_macros(dfp,gm); alloc_small_func_GenericMatrix(dfp,gm); make_small_calculate_func(dfp,gm); one_shot_AlnRangeSet_func(dfp,gm); write_AlnRangeSet_build_func(dfp,gm); write_AlnRange_build_func(dfp,gm); /* write_dc_PackAln_build_func(dfp,gm); */ write_hidden_read_func(dfp,gm); write_hidden_max_func(dfp,gm); write_special_strip_read_func(dfp,gm); write_special_strip_max_func(dfp,gm); write_matrix_to_special_max_func(dfp,gm); write_hidden_calc_func(dfp,gm); write_hidden_init_func(dfp,gm); write_full_dc_func(dfp,gm); write_single_dc_pass_func(dfp,gm); write_push_dc_func(dfp,gm); write_follow_on_dc_func(dfp,gm); write_up_to_dc_func(dfp,gm); write_init_dc_func(dfp,gm); /* write_shadow_dc_alloc(dfp,gm); */ /* write_start_end_macros(dfp,gm); */ /* write_shadow_start_end_alloc(dfp,gm); */ /* write_start_end_build(dfp,gm);*/ write_start_end_find_end(dfp,gm); optimised_shadow_GenericMatrix(dfp,gm); /* heavy_optimised_shadow_GenericMatrix(dfp,gm);*/ write_start_end_init(dfp,gm); } /* Function: alloc_small_func_GenericMatrix(dfp,gm) * * Descrip: makes the allocate_Small_xxx function. * This calls allocate_xxx_only function * (made by /write_safe_alloc_function) * and then allocates basematrix stuff as well. * * * Arg: dfp [UNKN ] dynamite file pointer [DYNFILE *] * Arg: gm [READ ] generic matrix structure [const GenericMatrix *] * */ # line 91 "dynashadow.dy" void alloc_small_func_GenericMatrix(DYNFILE * dfp,const GenericMatrix * gm) { char * arg_str; char * chain_str; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"allocate_Small_%s",gm->name); /*** prepare function information ***/ add_line_to_Ftext(fi->ft,"This function allocates the %s structure",gm->name); add_line_to_Ftext(fi->ft,"and the basematrix area for a small memory implementations"); add_line_to_Ftext(fi->ft,"It calls /allocate_%s_only",gm->name); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"%s * allocate_Small_%s(%s)",gm->name,gm->name,arg_str); /*** clean up ***/ ckfree(arg_str); /*** into function body ***/ expr(dfp,"%s * out;",gm->name); add_break(dfp); chain_str = get_chainstr_GenericMatrix(gm); expr(dfp,"out = allocate_%s_only(%s);",gm->name,chain_str); ckfree(chain_str); expr(dfp,"if( out == NULL )"); hang_expr(dfp,"return NULL;"); expr(dfp,"out->basematrix = BaseMatrix_alloc_matrix_and_specials(%d,(out->leni + %d) * %d,%d,out->lenj+%d)",(gm->window_j+1)*8,gm->window_i,gm->len,gm->spec_len*8,gm->window_j); expr(dfp,"if(out == NULL) "); startbrace(dfp); expr(dfp,"warn(\"Small shadow matrix %s cannot be allocated, (asking for %d by %%d main cells)\",out->leni+%d);",gm->name,gm->window_j+1,gm->window_i+1); expr(dfp,"free_%s(out)",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"out->basematrix->type = BASEMATRIX_TYPE_SHADOW;"); expr(dfp,"return out"); close_function(dfp); add_break(dfp); } /* Function: make_small_calculate_func(dfp,gm) * * Descrip: make the calculate function for * small PackAln system * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ # line 153 "dynashadow.dy" void make_small_calculate_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; register int s; int ss; /*** yawn. There are better ways to do this! ***/ for(s=0;sspec_len;s++) if( gm->special[s]->is_end == TRUE ) break; for(ss=0;ssspec_len;ss++) if( gm->special[ss]->is_start == TRUE) break; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"PackAln_calculate_Small_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates an alignment for %s structure in linear space",gm->name); add_line_to_Ftext(fi->ft,"If you want only the start/end points"); add_line_to_Ftext(fi->ft,"use /AlnRangeSet_calculate_Small_%s ",gm->name); add_break_to_Ftext(fi->ft); add_line_to_Ftext(fi->ft,"The function basically"); add_line_to_Ftext(fi->ft," finds start/end points "); add_line_to_Ftext(fi->ft," foreach start/end point "); add_line_to_Ftext(fi->ft," calls /full_dc_%s ",gm->name); start_function_FuncInfo(fi,dfp,"PackAln * PackAln_calculate_Small_%s(%s * mat,DPEnvelope * dpenv)",gm->name,gm->name); /*** function body ***/ expr(dfp,"int endj;"); expr(dfp,"int score;"); expr(dfp,"PackAln * out;"); expr(dfp,"PackAlnUnit * pau;"); expr(dfp,"int starti;"); expr(dfp,"int startj;"); expr(dfp,"int startstate;"); expr(dfp,"int stopi;"); expr(dfp,"int stopj;"); expr(dfp,"int stopstate;"); expr(dfp,"int temp;"); expr(dfp,"int donej;"); add_end_comment(dfp,"This is for reporting, will be passed as a & arg in"); expr(dfp,"int totalj;"); add_end_comment(dfp,"This also is for reporting, but as is not changed, can be passed by value"); add_break(dfp); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW )"); startbrace(dfp); warn_expr(dfp,"Could not calculate packaln small for %s due to wrong type of matrix",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); expr(dfp,"out = PackAln_alloc_std();"); add_break(dfp); /** got to figure out start/end first **/ expr(dfp,"start_reporting(\"Find start end points: \");"); expr(dfp,"dc_optimised_start_end_calc_%s(mat,dpenv);",gm->name); expr(dfp,"score = start_end_find_end_%s(mat,&endj);",gm->name); expr(dfp,"out->score = score;"); expr(dfp,"stopstate = %s;\n",gm->special[s]->name); /*** ok, life is different if we have special to specials. ***/ if( gm->specialtospecial == FALSE) { add_block_comment(dfp,"No special to specials: one matrix alignment: simply remove and get"); expr(dfp,"starti = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,0);",gm->name,gm->special[s]->name); expr(dfp,"startj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,1);",gm->name,gm->special[s]->name); expr(dfp,"startstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,2);",gm->name,gm->special[s]->name); expr(dfp,"stopi = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,3);",gm->name,gm->special[s]->name); expr(dfp,"stopj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,4);",gm->name,gm->special[s]->name); expr(dfp,"stopstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,5);",gm->name,gm->special[s]->name); expr(dfp,"temp = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,6);",gm->name,gm->special[s]->name); expr(dfp,"log_full_error(REPORT,0,\"[%%d,%%d][%%d,%%d] Score %%d\",starti,startj,stopi,stopj,score);"); expr(dfp,"stop_reporting();"); expr(dfp,"start_reporting(\"Recovering alignment: \");"); add_break(dfp); add_block_comment(dfp,"Figuring how much j we have to align for reporting purposes"); expr(dfp,"donej = 0;"); expr(dfp,"totalj = stopj - startj;"); expr(dfp,"full_dc_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv);",gm->name); add_break(dfp); add_block_comment(dfp,"Although we have no specials, need to get start. Better to check than assume"); add_break(dfp); expr(dfp,"max_matrix_to_special_%s(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL);",gm->name); expr(dfp,"if( stopi == %s_READ_OFF_ERROR || stopstate != %s )",gm->name,gm->special[ss]->name); startbrace(dfp); warn_expr(dfp,"Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); expr(dfp,"invert_PackAln(out);"); expr(dfp,"recalculate_PackAln_%s(out,mat);",gm->name); expr(dfp,"return out;"); closebrace(dfp); add_break(dfp); /*** Need to add PackUnit alloc etc... ***/ add_block_comment(dfp,"Ok. Put away start start..."); expr(dfp,"pau = PackAlnUnit_alloc()"); expr(dfp,"pau->i = stopi;"); expr(dfp,"pau->j = stopj;"); expr(dfp,"pau->state = stopstate + %d;",gm->len); expr(dfp,"add_PackAln(out,pau)"); add_break(dfp); expr(dfp,"log_full_error(REPORT,0,\"Alignment recovered\");"); expr(dfp,"stop_reporting();"); } else { add_block_comment(dfp,"Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits"); expr(dfp,"log_full_error(REPORT,0,\"End at %%d Score %%d\",endj,score);"); expr(dfp,"stop_reporting();"); expr(dfp,"for(;;)"); startbrace_tag(dfp,"while there are more special bits to recover"); expr(dfp,"start_reporting(\"Special cell aln end %%d:\",endj)"); expr(dfp,"if( read_special_strip_%s(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE )",gm->name); startbrace(dfp); warn_expr(dfp,"Problem in reading off special state system... going to return partial alignment"); expr(dfp,"break;"); closebrace(dfp); expr(dfp,"if( startstate == %s || endj <= 0)",gm->special[ss]->name); startbrace(dfp); expr(dfp,"log_full_error(REPORT,0,\"Recovered complete alignment\");"); expr(dfp,"stop_reporting();"); expr(dfp,"break;"); closebrace(dfp); add_break(dfp); expr(dfp,"log_full_error(REPORT,0,\"Finished to %%d\",endj);"); expr(dfp,"stop_reporting();"); add_break(dfp); add_block_comment(dfp,"Ok... have to eat up another piece of matrix "); expr(dfp,"temp = startstate;"); expr(dfp,"starti = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0);",gm->name); expr(dfp,"startj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1);",gm->name); expr(dfp,"startstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2);",gm->name); expr(dfp,"stopi = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3);",gm->name); expr(dfp,"stopj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4);",gm->name); expr(dfp,"stopstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5);",gm->name); add_break(dfp); add_block_comment(dfp,"Get out the score of this block. V. important!"); expr(dfp,"temp = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6);",gm->name); expr(dfp,"totalj = stopj - startj;"); expr(dfp,"donej = 0;"); expr(dfp,"start_reporting(\"Main matrix aln [%%d,%%d]:\",startj,stopj)"); expr(dfp,"if(full_dc_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In the alignment %s [%%d,%%d][%%d,%%d], got a problem. Please report bug ... giving you back a partial alignment\",starti,startj,stopi,stopj);",gm->name); expr(dfp,"return out;"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"now have to figure out which special we came from... yikes"); expr(dfp,"max_matrix_to_special_%s(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL);",gm->name); expr(dfp,"if( stopi == %s_READ_OFF_ERROR)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In %s read off ending at %%d ... got a bad matrix to special read off... returning partial alignment\",startj);",gm->name); expr(dfp,"invert_PackAln(out);"); expr(dfp,"recalculate_PackAln_%s(out,mat);",gm->name); expr(dfp,"return out;"); closebrace(dfp); add_block_comment(dfp,"if at start, break, otherwise, back to eat another strip"); expr(dfp,"if( stopstate == %s)",gm->special[ss]->name); startbrace(dfp); expr(dfp,"log_full_error(REPORT,0,\"Recovered complete alignment \");"); expr(dfp,"stop_reporting()"); expr(dfp,"break;"); closebrace(dfp); expr(dfp,"log_full_error(REPORT,0,\"Finished alignment to %%d \",startj);"); expr(dfp,"stop_reporting();"); expr(dfp,"endj = stopj;"); add_block_comment(dfp,"stopstate is correct as it is"); closebrace(dfp); } /*** clean up ***/ expr(dfp,"invert_PackAln(out);"); expr(dfp,"recalculate_PackAln_%s(out,mat);",gm->name); expr(dfp,"return out;"); add_break(dfp); close_function(dfp); add_break(dfp); } /* Function: one_shot_AlnRangeSet_func(dfp,gm) * * Descrip: makes AlnRangeSet from small memory * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ # line 369 "dynashadow.dy" void one_shot_AlnRangeSet_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"AlnRangeSet_calculate_Small_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates an alignment for %s structure in linear space",gm->name); add_line_to_Ftext(fi->ft,"If you want the full alignment, use /PackAln_calculate_Small_%s ",gm->name); add_line_to_Ftext(fi->ft,"If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_%s",gm->name); add_line_to_Ftext(fi->ft,"If you have got the small matrix but not the alignment, use /AlnRangeSet_from_%s ",gm->name); start_function_FuncInfo(fi,dfp,"AlnRangeSet * AlnRangeSet_calculate_Small_%s(%s * mat)",gm->name,gm->name); /*** function body ***/ expr(dfp,"AlnRangeSet * out;"); add_break(dfp); expr(dfp,"start_reporting(\"Find start end points: \");"); expr(dfp,"dc_optimised_start_end_calc_%s(mat,NULL);",gm->name); expr(dfp,"log_full_error(REPORT,0,\"Calculated\");"); add_break(dfp); expr(dfp,"out = AlnRangeSet_from_%s(mat);",gm->name); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } # line 402 "dynashadow.dy" void write_AlnRangeSet_build_func(DYNFILE * dfp,GenericMatrix * gm) { register int s; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"AlnRangeSet_from_%s",gm->name); add_line_to_Ftext(fi->ft,"This function reads off a start/end structure"); add_line_to_Ftext(fi->ft,"for %s structure in linear space",gm->name); add_line_to_Ftext(fi->ft,"If you want the full alignment use"); add_line_to_Ftext(fi->ft,"/PackAln_calculate_Small_%s ",gm->name); add_line_to_Ftext(fi->ft,"If you have not calculated the matrix use"); add_line_to_Ftext(fi->ft,"/AlnRange_calculate_Small_%s",gm->name); for(s=0;sspec_len;s++) if( gm->special[s]->is_end == TRUE ) break; start_function_FuncInfo(fi,dfp,"AlnRangeSet * AlnRangeSet_from_%s(%s * mat)",gm->name,gm->name); expr(dfp,"AlnRangeSet * out;"); expr(dfp,"AlnRange * temp;"); expr(dfp,"int jpos;"); expr(dfp,"int state;"); add_break(dfp); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW)"); startbrace(dfp); warn_expr(dfp,"Bad error! - non shadow matrix type in AlnRangeSet_from_%s",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); expr(dfp,"out = AlnRangeSet_alloc_std();"); add_block_comment(dfp,"Find the end position"); expr(dfp,"out->score = start_end_find_end_%s(mat,&jpos);",gm->name); expr(dfp,"state = %s;",gm->special[s]->name); add_break(dfp); expr(dfp,"while( (temp = AlnRange_build_%s(mat,jpos,state,&jpos,&state)) != NULL)",gm->name); hang_expr(dfp,"add_AlnRangeSet(out,temp);"); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } # line 456 "dynashadow.dy" void write_AlnRange_build_func(DYNFILE * dfp,GenericMatrix * gm) { register int s; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"AlnRange_build_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates a single start/end set in linear space",gm->name); add_line_to_Ftext(fi->ft,"Really a sub-routine for /AlnRangeSet_from_PackAln_%s",gm->name); for(s=0;sspec_len;s++) if( gm->special[s]->is_start == TRUE ) break; if( s == gm->spec_len ) { warn("Ok... problem... the special length has no start. Unhappy!"); } start_function_FuncInfo(fi,dfp,"AlnRange * AlnRange_build_%s(%s * mat,int stopj,int stopspecstate,int * startj,int * startspecstate)",gm->name,gm->name); expr(dfp,"AlnRange * out;"); expr(dfp,"int jpos;"); expr(dfp,"int state;"); add_break(dfp); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW)"); startbrace(dfp); warn_expr(dfp,"Bad error! - non shadow matrix type in AlnRangeSet_from_%s",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Assumme that we have specials (we should!). Read back along the specials till we have the finish point"); expr(dfp,"if( read_special_strip_%s(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In AlnRanger_build_%s alignment ending at %%d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!\",stopj);",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"if( state == %s || jpos <= 0)",gm->special[s]->name); hang_expr(dfp,"return NULL;"); add_break(dfp); expr(dfp,"out = AlnRange_alloc();"); add_break(dfp); expr(dfp,"out->starti = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0);",gm->name); expr(dfp,"out->startj = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1);",gm->name); expr(dfp,"out->startstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2);",gm->name); expr(dfp,"out->stopi = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3);",gm->name); expr(dfp,"out->stopj = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4);",gm->name); expr(dfp,"out->stopstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5);",gm->name); expr(dfp,"out->startscore = %s_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6);",gm->name); expr(dfp,"out->stopscore = %s_DC_SHADOW_SPECIAL(mat,0,jpos,state);",gm->name); add_break(dfp); add_block_comment(dfp,"Now, we have to figure out where this state came from in the specials"); expr(dfp,"max_matrix_to_special_%s(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL);",gm->name); expr(dfp,"if( jpos == %s_READ_OFF_ERROR)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In AlnRange_build_%s alignment ending at %%d, with aln range between %%d-%%d in j, unable to find source special, returning this range, but this could get tricky!\",stopj,out->startj,out->stopj);",gm->name); expr(dfp,"return out;"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Put in the correct score for startstate, from the special"); expr(dfp,"out->startscore = %s_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate);",gm->name); add_block_comment(dfp,"The correct j coords have been put into startj, startspecstate... so just return out"); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } /* Function: write_dc_PackAln_build_func(dfp,gm) * * Descrip: This functions is now defunct * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ # line 538 "dynashadow.dy" void write_dc_PackAln_build_func(DYNFILE * dfp,GenericMatrix * gm) { register int i; register int s; int ss; char buffer[MAXLINE]; /*** yawn. There are better ways to do this! ***/ for(s=0;sspec_len;s++) if( gm->special[s]->is_end == TRUE ) break; for(ss=0;ssspec_len;ss++) if( gm->special[ss]->is_start == TRUE) break; sprintf(buffer,"PackAln * PackAln_dc_build_%s(%s %s, %s %s ",gm->name, gm->query->element_type,gm->query->name, gm->target->element_type,gm->target->name); for(i=0;ires_len;i++) { strcat(buffer,", "); strcat(buffer,gm->resource[i]->element_type); if( gm->resource[i]->isfunc == TRUE ) { continue; } strcat(buffer," "); strcat(buffer,gm->resource[i]->name); } strcat(buffer,")"); start_function(dfp,buffer); expr(dfp,"int endj;"); expr(dfp,"%s * mat;",gm->name); expr(dfp,"int score;"); expr(dfp,"PackAln * out;"); expr(dfp,"int starti;"); expr(dfp,"int startj;"); expr(dfp,"int startstate;"); expr(dfp,"int stopi;"); expr(dfp,"int stopj;"); expr(dfp,"int stopstate;"); expr(dfp,"int temp;"); expr(dfp,"int donej;"); add_end_comment(dfp,"This is for reporting, will be passed as a & arg in"); expr(dfp,"int totalj;"); add_end_comment(dfp,"This also is for reporting, but as is not changed, can be passed by value"); add_break(dfp); expr(dfp,"out = PackAln_alloc_std();"); expr(dfp,"mat = shadow_dc_alloc_%s(%s->%s,%s->%s);",gm->name,gm->query->name,gm->query_len,gm->target->name,gm->target_len); expr(dfp,"if(mat == NULL)"); startbrace(dfp); warn_expr(dfp,"Unable to build test dc linear matrix for %s, unable to allocate memory",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); expr(dfp,"mat->%s = %s;",gm->query->name,gm->query->name); expr(dfp,"mat->%s = %s;",gm->target->name,gm->target->name); for(i=0;ires_len;i++) expr(dfp,"mat->%s = %s;",gm->resource[i]->name,gm->resource[i]->name); add_break(dfp); /** got to figure out start/end first **/ expr(dfp,"start_reporting(\"Find start end points: \");"); expr(dfp,"dc_optimised_start_end_calc_%s(mat);",gm->name); expr(dfp,"score = start_end_find_end_%s(mat,&endj);",gm->name); expr(dfp,"out->score = score;"); expr(dfp,"stopstate = %s;\n",gm->special[s]->name); /*** ok, life is different if we have special to specials. ***/ if( gm->specialtospecial == FALSE) { add_block_comment(dfp,"No special to specials: one matrix alignment: simply remove and get"); expr(dfp,"starti = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,0);",gm->name,gm->special[s]->name); expr(dfp,"startj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,1);",gm->name,gm->special[s]->name); expr(dfp,"startstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,2);",gm->name,gm->special[s]->name); expr(dfp,"stopi = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,3);",gm->name,gm->special[s]->name); expr(dfp,"stopj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,4);",gm->name,gm->special[s]->name); expr(dfp,"stopstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,%s,5);",gm->name,gm->special[s]->name); expr(dfp,"log_full_error(REPORT,0,\"[%%d,%%d][%%d,%%d] Score %%d\",starti,startj,stopi,stopj,score);"); expr(dfp,"stop_reporting();"); expr(dfp,"start_reporting(\"Recovering alignment: \");"); add_break(dfp); add_block_comment(dfp,"Figuring how much j we have to align for reporting purposes"); expr(dfp,"donej = 0;"); expr(dfp,"totalj = stopj - startj;"); expr(dfp,"full_dc_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv);",gm->name); expr(dfp,"log_full_error(REPORT,0,\"Alignment recovered\");"); expr(dfp,"stop_reporting();"); } else { add_block_comment(dfp,"Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits"); expr(dfp,"log_full_error(REPORT,0,\"End at %%d Score %%d\",endj,score);"); expr(dfp,"stop_reporting();"); expr(dfp,"for(;;)"); startbrace_tag(dfp,"while there are more special bits to recover"); expr(dfp,"start_reporting(\"Special cell aln end %%d:\",endj)"); expr(dfp,"if( read_special_strip_%s(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE )",gm->name); startbrace(dfp); warn_expr(dfp,"Problem in reading off special state system... going to return partial alignment"); expr(dfp,"break;"); closebrace(dfp); expr(dfp,"if( startstate == %s || endj <= 0)",gm->special[ss]->name); startbrace(dfp); expr(dfp,"log_full_error(REPORT,0,\"Recovered complete alignment\");"); expr(dfp,"stop_reporting();"); expr(dfp,"break;"); closebrace(dfp); add_break(dfp); expr(dfp,"log_full_error(REPORT,0,\"Finished to %%d\",endj);"); expr(dfp,"stop_reporting();"); add_break(dfp); add_block_comment(dfp,"Ok... have to eat up another piece of matrix "); expr(dfp,"temp = startstate;"); expr(dfp,"starti = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0);",gm->name); expr(dfp,"startj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1);",gm->name); expr(dfp,"startstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2);",gm->name); expr(dfp,"stopi = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3);",gm->name); expr(dfp,"stopj = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4);",gm->name); expr(dfp,"stopstate = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5);",gm->name); add_break(dfp); add_block_comment(dfp,"Get out the score of this block. V. important!"); expr(dfp,"temp = %s_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6);",gm->name); expr(dfp,"totalj = stopj - startj;"); expr(dfp,"donej = 0;"); expr(dfp,"start_reporting(\"Main matrix aln [%%d,%%d]:\",startj,stopj)"); expr(dfp,"if(full_dc_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In the alignment %s [%%d,%%d][%%d,%%d], got a problem. Please report bug ... giving you back a partial alignment\",starti,startj,stopi,stopj);",gm->name); expr(dfp,"return out;"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"now have to figure out which special we came from... yikes"); expr(dfp,"max_matrix_to_special_%s(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL);",gm->name); expr(dfp,"if( stopi == %s_READ_OFF_ERROR);",gm->name); startbrace(dfp); expr(dfp,"warn(\"In %s read off ending at %%d ... got a bad matrix to special read off... returning partial alignment\",startj);",gm->name); expr(dfp,"invert_PackAln(out);"); expr(dfp,"return out;"); closebrace(dfp); add_block_comment(dfp,"if at start, break, otherwise, back to eat another strip"); expr(dfp,"if( stopstate == %s)",gm->special[ss]->name); startbrace(dfp); expr(dfp,"log_full_error(REPORT,0,\"Recovered complete alignment \");"); expr(dfp,"stop_reporting()"); expr(dfp,"break;"); closebrace(dfp); expr(dfp,"log_full_error(REPORT,0,\"Finished alignment to %%d \",startj);"); expr(dfp,"stop_reporting();"); expr(dfp,"endj = stopj;"); add_block_comment(dfp,"stopstate is correct as it is"); closebrace(dfp); } expr(dfp,"invert_PackAln(out);"); expr(dfp,"free_%s(mat);",gm->name); expr(dfp,"return out;"); add_break(dfp); close_function(dfp); add_break(dfp); } /* Function: write_full_dc_func(dfp,gm) * * Descrip: writes the main divide and conquor routine * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ # line 735 "dynashadow.dy" void write_full_dc_func(DYNFILE * dfp,GenericMatrix * gm) { ArgInfo * ai; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"full_dc_%s",gm->name); add_line_to_Ftext(fi->ft,"The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_%s",gm->name); add_line_to_Ftext(fi->ft,"Not this function, which is pretty hard core. "); add_line_to_Ftext(fi->ft,"Function is given start/end points (in main matrix) for alignment"); add_line_to_Ftext(fi->ft,"It does some checks, decides whether start/end in j is small enough for explicit calc"); add_line_to_Ftext(fi->ft," - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE"); add_line_to_Ftext(fi->ft," - if no, uses /do_dc_single_pass_%s to get mid-point",gm->name); add_line_to_Ftext(fi->ft," saves midpoint, and calls itself to do right portion then left portion"); add_line_to_Ftext(fi->ft,"right then left ensures PackAln is added the 'right' way, ie, back-to-front"); add_line_to_Ftext(fi->ft,"returns FALSE on any error, with a warning"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); ai->desc=stringalloc("Matrix with small memory implementation"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"starti"); ai->desc=stringalloc("Start position in i"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"startj"); ai->desc=stringalloc("Start position in j"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"startstate"); ai->desc=stringalloc("Start position state number"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"stopi"); ai->desc=stringalloc("Stop position in i"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"stopj"); ai->desc=stringalloc("Stop position in j"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"stopstate"); ai->desc=stringalloc("Stop position state number"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"out"); ai->desc=stringalloc("PackAln structure to put alignment into"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"donej"); ai->desc=stringalloc("pointer to a number with the amount of alignment done"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"totalj"); ai->desc=stringalloc("total amount of alignment to do (in j coordinates)"); start_function_FuncInfo(fi,dfp,"boolean full_dc_%s(%s * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"int lstarti;"); expr(dfp,"int lstartj;"); expr(dfp,"int lstate;"); add_break(dfp); expr(dfp,"if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW)"); startbrace(dfp); warn_expr(dfp,"*Very* bad error! - non shadow matrix type in full_dc_%s",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); expr(dfp,"if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1)"); startbrace(dfp); expr(dfp,"warn(\"In full dc program, passed bad indices, indices passed were %%d:%%d[%%d] to %%d:%%d[%%d]\\n\",starti,startj,startstate,stopi,stopj,stopstate);"); expr(dfp,"return FALSE"); closebrace(dfp); add_break(dfp); /*** expr(dfp,"fprintf(stdout,\"Calling with %%d,%%d[%%d] to %%d,%%d[%%d]\\n\",starti,startj,startstate,stopi,stopj,stopstate);"); ***/ expr(dfp,"if( stopj - startj < %d)",gm->window_j*5); startbrace(dfp); /** expr(dfp,"fprintf(stdout,\"Got to stopping point at %%d:%%d %%d:%%d\\n\",starti,startj,stopi,stopj);"); **/ expr(dfp,"log_full_error(REPORT,0,\"[%%d,%%d][%%d,%%d] Explicit read off\",starti,startj,stopi,stopj);"); add_end_comment(dfp,"Build hidden explicit matrix"); expr(dfp,"calculate_hidden_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv)",gm->name); expr(dfp,"*donej += (stopj - startj);"); add_end_comment(dfp,"Now read it off into out"); expr(dfp,"if( read_hidden_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In full dc, at %%d:%%d,%%d:%%d got a bad hidden explicit read off... \",starti,startj,stopi,stopj);"); expr(dfp,"return FALSE"); closebrace(dfp); expr(dfp,"return TRUE;"); closebrace(dfp); add_break(dfp); add_end_comment(dfp,"In actual divide and conquor"); expr(dfp,"if( do_dc_single_pass_%s(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In divide and conquor for %s, at bound %%d:%%d to %%d:%%d, unable to calculate midpoint. Problem!\",starti,startj,stopi,stopj);",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); /*** expr(dfp,"for(i=0;i<6;i++)"); startbrace(dfp); expr(dfp,"printf(\"[%%d:%%d,%%d:%%d] %%d: %%d\\n\",starti,startj,stopi,stopj,i,%s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,i));",gm->name); closebrace(dfp); ***/ add_break(dfp); add_end_comment(dfp,"Ok... now we have to call on each side of the matrix"); add_end_comment(dfp,"We have to retrieve left hand side positions, as they will be vapped by the time we call LHS"); expr(dfp,"lstarti= %s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0)",gm->name); expr(dfp,"lstartj= %s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1)",gm->name); expr(dfp,"lstate = %s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2)",gm->name); add_break(dfp); add_end_comment(dfp,"Call on right hand side: this lets us do the correct read off"); expr(dfp,"if( full_dc_%s(mat,%s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),%s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),%s_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE)",gm->name,gm->name,gm->name,gm->name); startbrace(dfp); add_end_comment(dfp,"Warning already issued, simply chained back up to top"); expr(dfp,"return FALSE"); closebrace(dfp); add_end_comment(dfp,"Call on left hand side"); expr(dfp,"if( full_dc_%s(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE)",gm->name); startbrace(dfp); add_end_comment(dfp,"Warning already issued, simply chained back up to top"); expr(dfp,"return FALSE"); closebrace(dfp); add_break(dfp); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } # line 873 "dynashadow.dy" void write_single_dc_pass_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"do_dc_single_pass_%s",gm->name); start_function_FuncInfo(fi,dfp,"boolean do_dc_single_pass_%s(%s * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done)",gm->name,gm->name); expr(dfp,"int halfj;"); expr(dfp,"halfj = startj + ((stopj - startj)/2);"); /** expr(dfp,"fprintf(stdout,\"Pass with %%d,%%d[%%d] %%d,%%d[%%d] halfj %%d\\n\",starti,startj,startstate,stopi,stopj,stopstate,halfj);"); **/ add_break(dfp); expr(dfp,"init_dc_%s(mat);",gm->name); add_break(dfp); expr(dfp,"%s_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0;",gm->name); expr(dfp,"run_up_dc_%s(mat,starti,stopi,startj,halfj-1,dpenv,perc_done)",gm->name); expr(dfp,"push_dc_at_merge_%s(mat,starti,stopi,halfj,&halfj,dpenv)",gm->name); expr(dfp,"follow_on_dc_%s(mat,starti,stopi,halfj,stopj,dpenv,perc_done)",gm->name); expr(dfp,"return TRUE;"); close_function(dfp); add_break(dfp); } # line 902 "dynashadow.dy" void write_push_dc_func(DYNFILE * dfp,GenericMatrix * gm) { int s; int r; int i; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"push_dc_at_merge_%s",gm->name); start_function_FuncInfo(fi,dfp,"void push_dc_at_merge_%s(%s * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"register int k;"); expr(dfp,"register int count;"); expr(dfp,"register int mergej;"); add_end_comment(dfp,"Sources below this j will be stamped by triples"); expr(dfp,"register int score;"); expr(dfp,"register int temp;"); add_break(dfp); expr(dfp,"mergej = startj -1"); expr(dfp,"for(count=0,j=startj;count<%d;count++,j++)",gm->window_j); startbrace(dfp); expr(dfp,"for(i=starti;i<=stopi;i++)"); startbrace(dfp); expr(dfp,"if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE )"); startbrace_tag(dfp,"Is not in envelope"); for(i=0;ilen;i++) { expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,0) = (-100);",gm->name,gm->state[i]->name); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,1) = (-100);",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); for(s=0;slen;s++) { auto CellState * state; state = gm->state[s]; add_break(dfp); add_block_comment(dfp,"For state %s, pushing when j - offj <= mergej",state->name); expr(dfp,"score = %s_DC_SHADOW_%s(mat,i-%d,j-%d,%s) + %s",gm->name,state->source[0]->isspecial == TRUE ? "SPECIAL" : "MATRIX", state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source,state->source[0]->calc_expr); expr(dfp,"if( j - %d <= mergej)",state->source[0]->offj); startbrace(dfp); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,0) = i-%d;",gm->name,state->name,state->source[0]->offi); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,1) = j-%d;",gm->name,state->name,state->source[0]->offj); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,2) = %s;",gm->name,state->name,state->source[0]->state_source); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,3) = i;",gm->name,state->name,state->source[0]->offi); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,4) = j;",gm->name,state->name,state->source[0]->offj); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,5) = %s;",gm->name,state->name,state->name); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"for(k=0;k<7;k++)"); hang_expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,k) = %s_DC_SHADOW_%s_SP(mat,i - %d,j - %d,%s,k);",gm->name, state->name,gm->name,state->source[0]->isspecial == TRUE ? "SPECIAL" : "MATRIX", state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source); closebrace(dfp); for(r=1;rlen;r++) { if( state->source[r]->isspecial == TRUE ) continue; add_break(dfp); expr(dfp,"temp = %s_DC_SHADOW_%s(mat,i-%d,j-%d,%s) + %s",gm->name,state->source[r]->isspecial == TRUE ? "SPECIAL" : "MATRIX", state->source[r]->offi,state->source[r]->offj,state->source[r]->state_source,state->source[r]->calc_expr); expr(dfp,"if( temp > score)"); startbrace(dfp); expr(dfp,"score = temp;"); add_break(dfp); expr(dfp,"if( j - %d <= mergej)",state->source[r]->offj); startbrace(dfp); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,0) = i-%d;",gm->name,state->name,state->source[r]->offi); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,1) = j-%d;",gm->name,state->name,state->source[r]->offj); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,2) = %s;",gm->name,state->name,state->source[r]->state_source); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,3) = i;",gm->name,state->name,state->source[r]->offi); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,4) = j;",gm->name,state->name,state->source[r]->offj); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,5) = %s;",gm->name,state->name,state->name); closebrace(dfp); expr(dfp,"else"); startbrace(dfp); expr(dfp,"for(k=0;k<7;k++)"); hang_expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,k) = %s_DC_SHADOW_%s_SP(mat,i - %d,j - %d,%s,k);",gm->name, state->name,gm->name,state->source[r]->isspecial == TRUE ? "SPECIAL" : "MATRIX", state->source[r]->offi,state->source[r]->offj,state->source[r]->state_source); closebrace(dfp); closebrace(dfp); } /** ok, put in source independent score (if any!) **/ add_block_comment(dfp,"Add any movement independant score"); if( state->calc_expr != NULL ) expr(dfp,"score += %s",state->calc_expr); expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = score",gm->name,state->name); /*** I don't need to look at specials ***/ /*** for(r=0;rspec_len;r++) { auto CellState * spec; spec = gm->special[r]; for(t=0;tlen;t++) { if( strcmp(spec->source[t]->state_source,state->name) == 0 ) { add_break(dfp); add_block_comment(dfp,"state %s is a source for special %s... better update",state->name,spec->name); expr(dfp,"temp = score + (%s) + (%s) ",spec->source[t]->calc_expr,spec->calc_expr == NULL ? "0" : spec->calc_expr); expr(dfp,"if( temp > %s_DC_SHADOW_SPECIAL(mat,i,j,%s) )",gm->name,spec->name); startbrace(dfp); expr(dfp,"%s_DC_SHADOW_SPECIAL(mat,i,j,%s) = temp",gm->name,spec->name); expr(dfp,"for(k=0;k<7;k++)"); hang_expr(dfp,"%s_DC_SHADOW_SPECIAL_SP(mat,i,j,%s,k) = %s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,k);",gm->name, spec->name,gm->name,state->name); closebrace(dfp); } end of if this is a special source }end of t over all sources for this special }end of r over all specials ***/ add_block_comment(dfp,"Finished with state %s",state->name); } /* end of s over state */ closebrace(dfp); /* close i */ closebrace(dfp); /* close j */ add_block_comment(dfp,"Put back j into * stop j so that calling function gets it correct"); expr(dfp,"if( stopj == NULL)"); hang_expr(dfp,"warn(\"Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!\");"); expr(dfp,"else"); hang_expr(dfp,"*stopj = j"); add_break(dfp); expr(dfp,"return"); close_function(dfp); add_break(dfp); } # line 1063 "dynashadow.dy" void write_init_dc_func(DYNFILE * dfp,GenericMatrix * gm) { int s; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"init_dc_%s",gm->name); start_function_FuncInfo(fi,dfp,"void init_dc_%s(%s * mat)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"register int k;"); add_break(dfp); expr(dfp,"for(j=0;j<%d;j++)",gm->window_j+2); startbrace(dfp); expr(dfp,"for(i=(-%d);i%s->%s;i++)",gm->window_i,gm->query->name,gm->query_len); startbrace(dfp); for(s=0;slen;s++) { expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = %s;",gm->name,gm->state[s]->name,gm->state[s]->def_score); } expr(dfp,"for(k=0;k<7;k++)"); startbrace(dfp); for(s=0;slen;s++) { expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,k) = (-1);",gm->name,gm->state[s]->name); } closebrace(dfp); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"return"); close_function(dfp); add_break(dfp); } # line 1099 "dynashadow.dy" void write_up_to_dc_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; int i; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"run_up_dc_%s",gm->name); start_function_FuncInfo(fi,dfp,"void run_up_dc_%s(%s * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"register int score;"); expr(dfp,"register int temp;"); expr(dfp,"long int total;"); expr(dfp,"long int num;"); add_break(dfp); expr(dfp,"total = (stopi - starti+1) * (stopj - startj+1);"); expr(dfp,"if( total <= 0 )"); hang_expr(dfp,"total = 1;"); expr(dfp,"num = 0"); add_break(dfp); expr(dfp,"for(j=startj;j<=stopj;j++)"); startbrace_tag(dfp,"for each valid j column"); expr(dfp,"for(i=starti;i<=stopi;i++)"); startbrace_tag(dfp,"this is strip"); expr(dfp,"if( j == startj && i == starti)"); hang_expr(dfp,"continue;"); expr(dfp,"num++;"); expr(dfp,"if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE )"); startbrace_tag(dfp,"Is not in envelope"); for(i=0;ilen;i++) { expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); expr(dfp,"if( num %% 1000 == 0 )"); hang_expr(dfp,"log_full_error(REPORT,0,\"[%%d%%%%%%%% done]Before mid-j %%5d Cells done %%d%%%%%%%%\",perc_done,stopj,(num*100)/total)"); /** don't use specials, as we are guarenteed an alignment outisde them **/ write_score_block(dfp,gm,"DC_SHADOW_MATRIX","mat","DC_SHADOW_SPECIAL",FALSE); closebrace(dfp); closebrace(dfp); add_break(dfp); close_function(dfp); } # line 1154 "dynashadow.dy" void write_follow_on_dc_func(DYNFILE * dfp,GenericMatrix * gm) { int i; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"follow_on_dc_%s",gm->name); start_function_FuncInfo(fi,dfp,"void follow_on_dc_%s(%s * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"int score;"); expr(dfp,"int temp;"); expr(dfp,"int localshadow[7];"); expr(dfp,"long int total;"); expr(dfp,"long int num;"); add_break(dfp); expr(dfp,"total = (stopi - starti+1) * (stopj - startj+1);"); expr(dfp,"num = 0"); add_break(dfp); expr(dfp,"for(j=startj;j<=stopj;j++)"); startbrace_tag(dfp,"for each valid j column"); expr(dfp,"for(i=starti;i<=stopi;i++)"); startbrace_tag(dfp,"this is strip"); expr(dfp,"num++;"); expr(dfp,"if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE )"); startbrace_tag(dfp,"Is not in envelope"); for(i=0;ilen;i++) { expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); expr(dfp,"if( num %% 1000 == 0 )"); hang_expr(dfp,"log_full_error(REPORT,0,\"[%%d%%%%%%%% done]After mid-j %%5d Cells done %%d%%%%%%%%\",perc_done,startj,(num*100)/total)"); write_main_shadow_block(dfp,gm,"DC_SHADOW_MATRIX","mat","DC_SHADOW_SPECIAL","DC_SHADOW_MATRIX_SP","DC_SHADOW_SPECIAL_SP",7,FALSE,FALSE,0,FALSE); closebrace(dfp); /** no specials, as we are guarenteed to be outside them **/ closebrace(dfp); add_break(dfp); close_function(dfp); } # line 1206 "dynashadow.dy" void write_special_strip_read_func(DYNFILE * dfp,GenericMatrix * gm) { int ss; FuncInfo * fi; for(ss=0;ssspec_len;ss++) if( gm->special[ss]->is_start == TRUE) break; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"read_special_strip_%s",gm->name); start_function_FuncInfo(fi,dfp,"boolean read_special_strip_%s(%s * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int state;"); expr(dfp,"int cellscore;"); expr(dfp,"int isspecial;"); expr(dfp,"PackAlnUnit * pau;"); add_break(dfp); add_block_comment(dfp,"stop position is on the path"); expr(dfp,"i = stopi;"); expr(dfp,"j = stopj;"); expr(dfp,"state= stopstate;"); expr(dfp,"isspecial = TRUE;"); add_break(dfp); add_block_comment(dfp,"Loop until state has the same j as its stop in shadow pointers"); add_block_comment(dfp,"This will be the state is came out from, OR it has hit !start"); add_block_comment(dfp,"We may not want to get the alignment, in which case out will be NULL"); expr(dfp,"while( j > %s_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != %s)",gm->name,gm->special[ss]->name); startbrace_tag(dfp,"while more specials to eat up"); add_block_comment(dfp,"Put away current state, if we should"); expr(dfp,"if(out != NULL)"); startbrace(dfp); expr(dfp,"pau = PackAlnUnit_alloc();"); add_end_comment(dfp,"Should deal with memory overflow"); expr(dfp,"pau->i = i;"); expr(dfp,"pau->j = j;"); expr(dfp,"pau->state = state + %d;",gm->len); expr(dfp,"add_PackAln(out,pau);"); closebrace(dfp); add_break(dfp); expr(dfp,"max_special_strip_%s(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore);",gm->name); expr(dfp,"if( i == %s_READ_OFF_ERROR)",gm->name); startbrace(dfp); warn_expr(dfp,"In special strip read %s, got a bad read off error. Sorry!",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"check to see we have not gone too far!"); expr(dfp,"if( state != %s && j < %s_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4))",gm->special[ss]->name,gm->name); startbrace(dfp); expr(dfp,"warn(\"In special strip read %s, at special [%%d] state [%%d] overshot!\",j,state);",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_block_comment(dfp,"Put away last state"); expr(dfp,"if(out != NULL)"); startbrace(dfp); expr(dfp,"pau = PackAlnUnit_alloc();"); add_end_comment(dfp,"Should deal with memory overflow"); expr(dfp,"pau->i = i;"); expr(dfp,"pau->j = j;"); expr(dfp,"pau->state = state + %d;",gm->len); expr(dfp,"add_PackAln(out,pau);"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Put away where we are in startj and startstate"); expr(dfp,"*startj = j;"); expr(dfp,"*startstate = state;"); expr(dfp,"return TRUE;"); close_function(dfp); add_break(dfp); } # line 1294 "dynashadow.dy" void write_hidden_read_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"read_hidden_%s",gm->name); start_function_FuncInfo(fi,dfp,"boolean read_hidden_%s(%s * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int state;"); expr(dfp,"int cellscore;"); expr(dfp,"int isspecial;"); add_block_comment(dfp,"We don't need hiddenj here, 'cause matrix access handled by max funcs"); expr(dfp,"PackAlnUnit * pau;"); add_break(dfp); add_block_comment(dfp,"stop position is on the path"); expr(dfp,"i = stopi;"); expr(dfp,"j = stopj;"); expr(dfp,"state= stopstate;"); expr(dfp,"isspecial = FALSE;"); add_break(dfp); expr(dfp,"while( i >= starti && j >= startj)"); startbrace(dfp); add_block_comment(dfp,"Put away current i,j,state"); expr(dfp,"pau = PackAlnUnit_alloc();"); add_end_comment(dfp,"Should deal with memory overflow"); expr(dfp,"pau->i = i;"); expr(dfp,"pau->j = j;"); expr(dfp,"pau->state = state;"); /** expr(dfp,"fprintf(stdout,\"\\tPau unit %%d,%%d,%%d\\n\",i,j,state);"); **/ expr(dfp,"add_PackAln(out,pau);"); add_break(dfp); expr(dfp,"max_hidden_%s(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore);",gm->name); add_break(dfp); expr(dfp,"if( i == %s_READ_OFF_ERROR)",gm->name); startbrace(dfp); expr(dfp,"warn(\"In %s hidden read off, between %%d:%%d,%%d:%%d - at got bad read off. Problem!\",starti,startj,stopi,stopj);",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); expr(dfp,"if( i == starti && j == startj && state == startstate)"); startbrace(dfp); add_end_comment(dfp,"Put away final state (start of this block)"); expr(dfp,"pau = PackAlnUnit_alloc();"); add_end_comment(dfp,"Should deal with memory overflow"); expr(dfp,"pau->i = i;"); expr(dfp,"pau->j = j;"); expr(dfp,"pau->state = state;"); expr(dfp,"add_PackAln(out,pau);"); hang_expr(dfp,"return TRUE;"); closebrace(dfp); expr(dfp,"if( i == starti && j == startj)"); startbrace(dfp); expr(dfp,"warn(\"In %s hidden read off, between %%d:%%d,%%d:%%d - hit start cell, but not in start state. Can't be good!.\",starti,startj,stopi,stopj);",gm->name); expr(dfp,"return FALSE;"); closebrace(dfp); closebrace(dfp); /* back to while */ expr(dfp,"warn(\"In %s hidden read off, between %%d:%%d,%%d:%%d - gone past start cell (now in %%d,%%d,%%d), can't be good news!.\",starti,startj,stopi,stopj,i,j,state);",gm->name); expr(dfp,"return FALSE;"); close_function(dfp); add_break(dfp); } # line 1373 "dynashadow.dy" void write_hidden_calc_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; int i; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"calculate_hidden_%s",gm->name); start_function_FuncInfo(fi,dfp,"void calculate_hidden_%s(%s * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"register int score;"); expr(dfp,"register int temp;"); expr(dfp,"register int hiddenj;"); add_break(dfp); expr(dfp,"hiddenj = startj;"); add_break(dfp); expr(dfp,"init_hidden_%s(mat,starti,startj,stopi,stopj)",gm->name); add_break(dfp); expr(dfp,"%s_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0;",gm->name); add_break(dfp); expr(dfp,"for(j=startj;j<=stopj;j++)"); startbrace(dfp); expr(dfp,"for(i=starti;i<=stopi;i++)"); startbrace(dfp); add_block_comment(dfp,"Should *not* do very first cell as this is the one set to zero in one state!"); expr(dfp,"if( i == starti && j == startj )"); hang_expr(dfp,"continue;"); expr(dfp,"if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE )"); startbrace_tag(dfp,"Is not in envelope"); for(i=0;ilen;i++) { expr(dfp,"%s_HIDDEN_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); write_score_block(dfp,gm,"HIDDEN_MATRIX","mat","HIDDEN_SPECIAL",FALSE); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"return;"); close_function(dfp); add_break(dfp); } # line 1426 "dynashadow.dy" void write_hidden_init_func(DYNFILE * dfp,GenericMatrix * gm) { register int s; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"init_hidden_%s",gm->name); start_function_FuncInfo(fi,dfp,"void init_hidden_%s(%s * mat,int starti,int startj,int stopi,int stopj)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"register int hiddenj;"); add_break(dfp); expr(dfp,"hiddenj = startj;"); expr(dfp,"for(j=(startj-%d);j<=stopj;j++)",gm->window_j); startbrace(dfp); expr(dfp,"for(i=(starti-%d);i<=stopi;i++)",gm->window_i); startbrace(dfp); for(s=0;slen;s++) { expr(dfp,"%s_HIDDEN_MATRIX(mat,i,j,%s) = %s;\n",gm->name,gm->state[s]->name,gm->state[s]->def_score); } closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"return"); close_function(dfp); add_break(dfp); } # line 1460 "dynashadow.dy" void write_hidden_max_func(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"max_hidden_%s",gm->name); start_function_FuncInfo(fi,dfp,"int max_hidden_%s(%s * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore)",gm->name,gm->name); expr(dfp,"register int temp;"); expr(dfp,"register int cscore;"); add_break(dfp); expr(dfp,"*reti = (*retj) = (*retstate) = %s_READ_OFF_ERROR;",gm->name); add_break(dfp); expr(dfp,"if( i < 0 || j < 0 || i > mat->%s->%s || j > mat->%s->%s)",gm->query->name, gm->query_len,gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"warn(\"In %s matrix special read off - out of bounds on matrix [i,j is %%d,%%d state %%d in standard matrix]\",i,j,state);",gm->name); expr(dfp,"return -1;"); closebrace(dfp); write_max_calc_block(dfp,gm,"HIDDEN_MATRIX","HIDDEN_SPECIAL",FALSE,FALSE); close_function(dfp); add_break(dfp); return; } # line 1492 "dynashadow.dy" void write_matrix_to_special_max_func(DYNFILE * dfp,GenericMatrix * gm) { register int i; register int j; FuncInfo * fi; char * special_tag = "DC_SHADOW_SPECIAL"; char * matrix_tag = "DC_SHADOW_MATRIX"; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"max_matrix_to_special_%s",gm->name); start_function_FuncInfo(fi,dfp,"int max_matrix_to_special_%s(%s * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore)",gm->name,gm->name); expr(dfp,"int temp"); expr(dfp,"*reti = (*retj) = (*retstate) = %s_READ_OFF_ERROR;",gm->name); add_break(dfp); expr(dfp,"if( j < 0 || j > mat->lenj)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"warn(\"In %s matrix to special read off - out of bounds on matrix [j is %%d in special]\",j);",gm->name); expr(dfp,"return -1;"); closebrace(dfp); add_break(dfp); expr(dfp,"switch(state)"); startbrace_tag(dfp,"Switch state "); for(i=0;ilen;i++) { auto CellState * cell; cell = gm->state[i]; expr(dfp,"case %s : ",cell->name); startcase(dfp); for(j=cell->len-1;j>=0;j--) { if( cell->source[j]->isspecial == FALSE) { add_block_comment(dfp,"Source %s is not a special, should not get here!",cell->source[j]->state_source); continue; } expr(dfp,"temp = cscore - (%s) - (%s)",cell->source[j]->calc_expr, cell->calc_expr == NULL ? "0" : cell->calc_expr); if( cell->source[j]->isspecial == TRUE) expr(dfp,"if( temp == %s_%s(mat,i - %d,j - %d,%s) )",gm->name,special_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); else expr(dfp,"if( temp == %s_%s(mat,i - %d,j - %d,%s) )",gm->name,matrix_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); startbrace(dfp); expr(dfp,"*reti = i - %d;",cell->source[j]->offi); expr(dfp,"*retj = j - %d;",cell->source[j]->offj); expr(dfp,"*retstate = %s;",cell->source[j]->state_source); if( cell->source[j]->isspecial == TRUE) expr(dfp,"*retspecial = TRUE;"); else expr(dfp,"*retspecial = FALSE;"); /*** if they want the score, calc the difference in the number and give it back ***/ expr(dfp,"if( cellscore != NULL)"); startbrace(dfp); expr(dfp,"*cellscore = cscore - %s_%s(mat,i-%d,j-%d,%s)",gm->name, cell->source[j]->isspecial == TRUE ? special_tag : matrix_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); expr(dfp,"return %s_%s(mat,i - %d,j - %d,%s) ",gm->name,matrix_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); } expr(dfp,"warn(\"Major problem (!) - in %s matrix to special read off, position %%d,%%d state %%d no source found!\",i,j,state);",gm->name); expr(dfp,"return (-1);"); closecase(dfp); } expr(dfp,"default:"); startcase(dfp); expr(dfp,"warn(\"Major problem (!) - in %s read off, position %%d,%%d state %%d no source found!\",i,j,state);",gm->name); expr(dfp,"return (-1);"); closecase(dfp); closebrace(dfp); add_break(dfp); close_function(dfp); add_break(dfp); } # line 1586 "dynashadow.dy" void write_special_strip_max_func(DYNFILE * dfp,GenericMatrix * gm) { register int i; register int j; char * matrix_tag = "DC_SHADOW_MATRIX"; char * special_tag = "DC_SHADOW_SPECIAL"; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"max_special_strip_%s",gm->name); add_line_to_Ftext(fi->ft,"A pretty intense internal function. Deals with read-off only in specials"); start_function_FuncInfo(fi,dfp,"int max_special_strip_%s(%s * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore)",gm->name,gm->name); expr(dfp,"int temp;"); expr(dfp,"int cscore;"); add_break(dfp); expr(dfp,"*reti = (*retj) = (*retstate) = %s_READ_OFF_ERROR;",gm->name); expr(dfp,"if( isspecial == FALSE )"); startbrace(dfp); warn_expr(dfp,"In special strip max function for %s, got a non special start point. Problem! (bad!)",gm->name); expr(dfp,"return (-1);"); closebrace(dfp); add_break(dfp); expr(dfp,"if( j < 0 || j > mat->%s->%s)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"warn(\"In %s matrix special read off - out of bounds on matrix [j is %%d in special]\",j);",gm->name); expr(dfp,"return -1;"); closebrace(dfp); add_break(dfp); expr(dfp,"cscore = %s_%s(mat,i,j,state);",gm->name,special_tag); expr(dfp,"switch(state)"); startbrace_tag(dfp,"switch on special states"); for(i=0;ispec_len;i++) { auto CellState * cell; cell = gm->special[i]; expr(dfp,"case %s : ",cell->name); startcase(dfp); /*** ok, we are only interested in specials to specials, otherwise we should not be here ***/ for(j=cell->len-1;j>=0;j--) { if( cell->source[j]->isspecial == FALSE ) { add_block_comment(dfp,"Source %s is not a special",cell->source[j]->state_source); continue; } else { add_block_comment(dfp,"source %s is a special",cell->source[j]->state_source); expr(dfp,"temp = cscore - (%s) - (%s)",cell->source[j]->calc_expr, cell->calc_expr == NULL ? "0" : cell->calc_expr); expr(dfp,"if( temp == %s_%s(mat,i - %d,j - %d,%s) )",gm->name,special_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); startbrace(dfp); expr(dfp,"*reti = i - %d;",cell->source[j]->offi); expr(dfp,"*retj = j - %d;",cell->source[j]->offj); expr(dfp,"*retstate = %s;",cell->source[j]->state_source); if( cell->source[j]->isspecial == TRUE) expr(dfp,"*retspecial = TRUE;"); else expr(dfp,"*retspecial = FALSE;"); /*** if they want the score, calc the difference in the number and give it back ***/ expr(dfp,"if( cellscore != NULL)"); startbrace(dfp); expr(dfp,"*cellscore = cscore - %s_%s(mat,i-%d,j-%d,%s)",gm->name,special_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); expr(dfp,"return %s_%s(mat,i - %d,j - %d,%s) ",gm->name,matrix_tag,cell->source[j]->offi, cell->source[j]->offj,cell->source[j]->state_source); closebrace(dfp); } } closecase(dfp); } expr(dfp,"default:"); startcase(dfp); expr(dfp,"warn(\"Major problem (!) - in %s special strip read off, position %%d,%%d state %%d no source found dropped into default on source switch!\",i,j,state);",gm->name); expr(dfp,"return (-1);"); closecase(dfp); closebrace(dfp); close_function(dfp); add_break(dfp); } # line 1708 "dynashadow.dy" void write_shadow_dc_macros(DYNFILE * dfp,GenericMatrix * gm) { int steve_space; macro(dfp,"#define %s_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+%d)][(i+%d)*%d+state])",gm->name,gm->window_j,gm->window_i,gm->len); macro(dfp,"#define %s_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+%d)*8) %% %d][(i+%d)*%d+state])",gm->name,gm->window_j+1,(gm->window_j+1)*8,gm->window_i,gm->len); macro(dfp,"#define %s_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+%d)])",gm->name,gm->window_j); macro(dfp,"#define %s_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+%d)])",gm->name,gm->window_j); macro(dfp,"#define %s_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+%d)*8)+(shadow+1)) %% %d)][(i+%d)*%d + state])",gm->name,gm->window_j+1,(gm->window_j+1)*8,gm->window_i,gm->len); macro(dfp,"#define %s_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+%d)])",gm->name,gm->window_j); /* we need 8 shadow pointers per matrix cell; one for the score 7 for different shadow implementations*/ steve_space = gm->len * 8; macro(dfp,"#define %s_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+%d)%% %d) * (leni+1) * %d) + ((i+%d) * %d) + (state)])",gm->name,gm->window_j,gm->window_j,gm->len,gm->window_i,gm->len); /* the +1 is because + 0 is the score */ macro(dfp,"#define %s_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+%d)%% %d) * (leni+1) * %d) + ((i+%d) * %d) + (state * %d) + shadow+1])",gm->name,gm->window_j,gm->window_j,steve_space,gm->window_i,steve_space,8); /* currently for the optimised shadow we use the same special matrix layout */ macro(dfp,"#define %s_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+%d)])",gm->name,gm->window_j); macro(dfp,"#define %s_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+%d)])",gm->name,gm->window_j); } /* Function: write_shadow_dc_alloc(dfp,gm) * * Descrip: Defunct (I think) * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ # line 1742 "dynashadow.dy" void write_shadow_dc_alloc(DYNFILE * dfp,GenericMatrix * gm) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"do_dc_sin_%s",gm->name); start_function(dfp,"%s * shadow_dc_alloc_%s(int leni,int lenj)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register %s * out",gm->name); add_break(dfp); add_block_comment(dfp,"Have to have enough memory to hold i,j,state triple *3 for each state"); add_block_comment(dfp,"This memory will also be used for the explicit memory use at end of r"); add_break(dfp); add_block_comment(dfp,"This means we need (window_j+1)*8 top line pointers by cell number * leni"); add_break(dfp); expr(dfp,"out = %s_alloc()",gm->name); expr(dfp,"if(out == NULL)"); hang_expr(dfp,"return NULL;"); add_end_comment(dfp,"warning already issued"); add_break(dfp); expr(dfp,"out->basematrix = BaseMatrix_alloc_matrix_and_specials(%d,(leni + %d) * %d,%d,lenj+%d)",(gm->window_j+1)*8,gm->window_i,gm->len,gm->spec_len*8,gm->window_j); expr(dfp,"if(out->basematrix == NULL)"); startbrace(dfp); expr(dfp,"warn(\"In shadow_dc_alloc_%s unable to allocate basematrix with main matrix %d by %%d ints\",(leni+%d)*%d);",gm->name,(gm->window_j+1)*8,gm->window_i,gm->len); expr(dfp,"free_%s(out)",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } /*** Start End Stuff ***/ # line 1789 "dynashadow.dy" void write_start_end_init(DYNFILE * dfp,GenericMatrix * gm) { register int s; register int i; FuncInfo * fi; for(i=0;ispec_len;i++) if( gm->special[i]->is_start == TRUE) break; if( i >= gm->spec_len ) { log_full_error(WARNING,0,"Cannot build start/end init function due to lack of start state"); return; } fi = FuncInfo_named_from_varstr(FI_INTERNAL,"init_start_end_linear_%s",gm->name); start_function_FuncInfo(fi,dfp,"void init_start_end_linear_%s(%s * mat)",gm->name,gm->name); expr(dfp,"register int i;"); expr(dfp,"register int j;"); expr(dfp,"for(j=0;j<%d;j++)",gm->window_j+2); startbrace(dfp); expr(dfp,"for(i=(-%d);i%s->%s;i++)",gm->window_i,gm->query->name,gm->query_len); startbrace(dfp); for(s=0;slen;s++) { expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = %s;",gm->name,gm->state[s]->name,gm->state[s]->def_score); expr(dfp,"%s_DC_SHADOW_MATRIX_SP(mat,i,j,%s,0) = (-1);",gm->name,gm->state[s]->name); } closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"for(j=(-%d);j%s->%s;j++)",gm->window_j,gm->target->name,gm->target_len); startbrace(dfp); for(s=0;sspec_len;s++) { expr(dfp,"%s_DC_SHADOW_SPECIAL(mat,0,j,%s) = %s;",gm->name,gm->special[s]->name,gm->special[s]->def_score); if( s == i ) /** is start **/ expr(dfp,"%s_DC_SHADOW_SPECIAL_SP(mat,0,j,%s,0) = j;",gm->name,gm->special[s]->name); else expr(dfp,"%s_DC_SHADOW_SPECIAL_SP(mat,0,j,%s,0) = (-1);",gm->name,gm->special[s]->name); } closebrace(dfp); add_break(dfp); expr(dfp,"return"); close_function(dfp); add_break(dfp); } # line 1842 "dynashadow.dy" void write_start_end_find_end(DYNFILE * dfp,GenericMatrix * gm) { register int i; ArgInfo * ai; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"start_end_find_end_%s",gm->name); add_line_to_Ftext(fi->ft,"First function used to find end of the best path in the special state !end"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"mat"); ai->desc = stringalloc("Matrix in small mode"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"endj"); ai->desc = stringalloc("position of end in j (meaningless in i)"); ai->argtype = ARGTYPE_WRITE; for(i=0;ispec_len;i++) if( gm->special[i]->is_end == TRUE) break; if( i >= gm->spec_len ) { log_full_error(WARNING,0,"Cannot build start/end find end function due to lack of end state. YIKES!"); return; } start_function_FuncInfo(fi,dfp,"int start_end_find_end_%s(%s * mat,int * endj)",gm->name,gm->name); expr(dfp,"register int j"); expr(dfp,"register int max;"); expr(dfp,"register int maxj"); add_break(dfp); expr(dfp,"max = %s_DC_SHADOW_SPECIAL(mat,0,mat->%s->%s-1,%s);",gm->name,gm->target->name,gm->target_len,gm->special[i]->name); expr(dfp,"maxj = mat->%s->%s-1",gm->target->name,gm->target_len); expr(dfp,"for(j= mat->%s->%s-2 ;j >= 0 ;j--)",gm->target->name,gm->target_len); startbrace(dfp); expr(dfp,"if( %s_DC_SHADOW_SPECIAL(mat,0,j,%s) > max )",gm->name,gm->special[i]->name); startbrace(dfp); expr(dfp,"max = %s_DC_SHADOW_SPECIAL(mat,0,j,%s);",gm->name,gm->special[i]->name); expr(dfp,"maxj = j;"); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"if( endj != NULL)"); hang_expr(dfp,"*endj = maxj;"); add_break(dfp); expr(dfp,"return max"); close_function(dfp); add_break(dfp); } /* Function: heavy_optimised_shadow_GenericMatrix(dfp,gm) * * Descrip: heavily optimised start end calc function * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ # line 1909 "dynashadow.dy" void heavy_optimised_shadow_GenericMatrix(DYNFILE * dfp,GenericMatrix * gm) { int i; int j; int k; FuncInfo * fi; char * matrixtag = "DC_OPT_SHADOW_MATRIX"; char * shadow_main_tag = "DC_OPT_SHADOW_MATRIX_SP"; char * shadow_special_tag = "DC_OPT_SHADOW_SPECIAL_SP"; char * specialtag = "DC_OPT_SHADOW_SPECIAL"; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"dc_heavy_optimised_start_end_calc_%s",gm->name); add_line_to_Ftext(fi->ft,"Calculates special strip, leaving start/end/score points in shadow matrix"); add_line_to_Ftext(fi->ft,"Works off specially laid out memory from steve searle"); start_function_FuncInfo(fi,dfp,"boolean dc_heavy_optimised_start_end_calc_%s(%s *mat,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int localshadow[7]"); expr(dfp,"long int total"); expr(dfp,"long int num=0"); expr(dfp,"int * score_pointers"); expr(dfp,"int * shadow_pointers"); for(i=0;ilen;i++) { expr(dfp,"int score_%s;",gm->state[i]->name); expr(dfp,"int temp_%s;",gm->state[i]->name); expr(dfp,"int * localsp_%s;",gm->state[i]->name); for(j=0;jstate[i]->len;j++) { expr(dfp,"int score_%s_%d;",gm->state[i]->name,j); } } add_break(dfp); expr(dfp,"leni = mat->%s->%s;",gm->query->name,gm->query_len); expr(dfp,"lenj = mat->%s->%s;",gm->target->name,gm->target_len); add_break(dfp); expr(dfp,"score_pointers = (int *) calloc (%d * (leni + %d) * %d,sizeof(int));",gm->window_j,gm->window_i,gm->len); expr(dfp,"shadow_pointers = (int *) calloc (%d * (leni + %d) * %d * 8,sizeof(int));",gm->window_j,gm->window_i,gm->len); add_break(dfp); expr(dfp,"for(j=0;jlen;i++) { expr(dfp,"%s_DC_OPT_SHADOW_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); expr(dfp,"if( num%%1000 == 0)"); hang_expr(dfp,"log_full_error(REPORT,0,\"%%6d Cells done [%%2d%%%%%%%%]\",num,num*100/total);"); add_break(dfp); /* main block */ add_block_comment(dfp,"Retrieve all the calculations first, and put into local variables"); for(i=0;ilen;i++) { for(j=0;jstate[i]->len;j++) { expr(dfp,"score_%s_%d = %s_%s(mat,i-%d,j-%d,%s) + %s + (%s)", gm->state[i]->name,j, gm->name, gm->state[i]->source[j]->isspecial == TRUE ? specialtag : matrixtag, gm->state[i]->source[j]->offi,gm->state[i]->source[j]->offj, gm->state[i]->source[j]->state_source, gm->state[i]->source[j]->calc_expr, gm->state[i]->calc_expr == NULL ? "0" : gm->state[i]->calc_expr ); } } add_break(dfp); add_block_comment(dfp,"now do the if/then/else store"); for(i=0;ilen;i++) { add_block_comment(dfp,"handling state %s",gm->state[i]->name); expr(dfp,"score_%s = score_%s_0;",gm->state[i]->name,gm->state[i]->name); expr(dfp,"localsp_%s = &(%s_%s(mat,i - %d,j - %d,%s,0));",gm->state[i]->name, gm->name,gm->state[i]->source[0]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, gm->state[i]->source[0]->offi,gm->state[i]->source[0]->offj,gm->state[i]->source[0]->state_source); for(j=1;jstate[i]->len;j++) { expr(dfp,"if( score_%s_%d > score_%s)",gm->state[i]->name,j,gm->state[i]->name); startbrace(dfp); expr(dfp,"score_%s = score_%s_%d;",gm->state[i]->name,gm->state[i]->name,j); if( gm->state[i]->source[j]->isspecial == TRUE ) { add_block_comment(dfp,"This source is a special, push top shadow pointers"); expr(dfp,"localshadow[0] = i;"); expr(dfp,"localshadow[1] = j;"); expr(dfp,"localshadow[2] = %s;",gm->state[i]->name); expr(dfp,"localshadow[3] = -1;"); expr(dfp,"localshadow[4] = -1;"); expr(dfp,"localshadow[5] = -1;"); expr(dfp,"localshadow[6] = score_%s;",gm->state[i]->name); expr(dfp,"localsp_%s = localshadow;",gm->state[i]->name); } else { expr(dfp,"localsp_%s = &(%s_%s(mat,i -%d,j - %d,%s,0));",gm->state[i]->name, gm->name,shadow_main_tag, gm->state[i]->source[j]->offi,gm->state[i]->source[j]->offj,gm->state[i]->source[j]->state_source); } closebrace(dfp); } /* end of loop over all sources */ expr(dfp,"%s_%s(mat,i,j,%s) = score_%s",gm->name,matrixtag,gm->state[i]->name,gm->state[i]->name); expr(dfp,"for(k=0;k<7;k++)"); hang_expr(dfp,"%s_%s(mat,i,j,%s,k) = localsp_%s[k]",gm->name,shadow_main_tag,gm->state[i]->name,gm->state[i]->name); for(j=0;jspec_len;j++) { auto CellState * specstate; specstate = gm->special[j]; for(k=0;klen;k++) { if( strcmp(specstate->source[k]->state_source,gm->state[i]->name) == 0) { /********************************/ /* is a special source! */ /********************************/ add_break(dfp); add_block_comment(dfp,"state %s is a source for special %s",gm->state[i]->name,specstate->name); expr(dfp,"temp_%s = score_%s + (%s) + (%s) ",gm->state[i]->name,gm->state[i]->name,specstate->source[k]->calc_expr,specstate->calc_expr == NULL ? "0" : specstate->calc_expr ); expr(dfp,"if( temp_%s > %s_%s(mat,i,j,%s) ) ",gm->state[i]->name,gm->name,specialtag,specstate->name); startbrace(dfp); expr(dfp,"%s_%s(mat,i,j,%s) = temp_%s",gm->name,specialtag,specstate->name,gm->state[i]->name); add_block_comment(dfp,"Have to push only bottem half of system here"); expr(dfp,"for(k=0;k<3;k++)"); hang_expr(dfp,"%s_%s(mat,i,j,%s,k) = %s_%s(mat,i,j,%s,k);", gm->name,shadow_special_tag, specstate->name, gm->name, specstate->source[k]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, gm->state[i]->name); /*** sort of hacky ***/ expr(dfp,"%s_%s(mat,i,j,%s,6) = temp_%s;", gm->name,shadow_special_tag, specstate->name, gm->state[i]->name); expr(dfp,"%s_%s(mat,i,j,%s,3) = i;",gm->name,shadow_special_tag,specstate->name); expr(dfp,"%s_%s(mat,i,j,%s,4) = j;",gm->name,shadow_special_tag,specstate->name); expr(dfp,"%s_%s(mat,i,j,%s,5) = %s;",gm->name,shadow_special_tag,specstate->name,gm->state[i]->name); closebrace(dfp); } } } /* end of loop over all special states */ add_block_comment(dfp,"Finished if/then/else loop for state %s",gm->state[i]->name); } /* end of loop over states */ add_break(dfp); closebrace(dfp); if( gm->specialtospecial == TRUE ) write_special_shadow_block(dfp,gm,"DC_OPT_SHADOW_MATRIX","mat","DC_OPT_SHADOW_SPECIAL","DC_OPT_SHADOW_MATRIX_SP","DC_OPT_SHADOW_SPECIAL_SP",7,TRUE,0); closebrace(dfp); add_break; expr(dfp,"free(score_pointers);"); expr(dfp,"free(shadow_pointers);"); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } /* Function: optimised_shadow_GenericMatrix(dfp,*gm) * * Descrip: Makes the optimised shadow matrix routine, * worked out by Steve Searle - memory access * is put into one array so that the routine * is faster * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: *gm [UNKN ] Undocumented argument [const GenericMatrix] * */ # line 2120 "dynashadow.dy" void optimised_shadow_GenericMatrix(DYNFILE * dfp,const GenericMatrix *gm) { int i; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"dc_optimised_start_end_calc_%s",gm->name); add_line_to_Ftext(fi->ft,"Calculates special strip, leaving start/end/score points in shadow matrix"); add_line_to_Ftext(fi->ft,"Works off specially laid out memory from steve searle"); start_function_FuncInfo(fi,dfp,"boolean dc_optimised_start_end_calc_%s(%s *mat,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"int score;"); expr(dfp,"int temp;"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int localshadow[7]"); expr(dfp,"long int total"); expr(dfp,"long int num=0"); expr(dfp,"int * score_pointers"); expr(dfp,"int * shadow_pointers"); expr(dfp,"int * localsp;"); expr(dfp,"leni = mat->%s->%s;",gm->query->name,gm->query_len); expr(dfp,"lenj = mat->%s->%s;",gm->target->name,gm->target_len); expr(dfp,"total = leni * lenj;"); add_break(dfp); expr(dfp,"score_pointers = (int *) calloc (%d * (leni + %d) * %d,sizeof(int));",gm->window_j,gm->window_i,gm->len); expr(dfp,"shadow_pointers = (int *) calloc (%d * (leni + %d) * %d * 8,sizeof(int));",gm->window_j,gm->window_i,gm->len); add_break(dfp); expr(dfp,"for(j=0;jlen;i++) { expr(dfp,"%s_DC_OPT_SHADOW_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); expr(dfp,"if( num%%1000 == 0)"); hang_expr(dfp,"log_full_error(REPORT,0,\"%%6d Cells done [%%2d%%%%%%%%]\",num,num*100/total);"); add_break(dfp); write_main_shadow_block(dfp,gm,"DC_OPT_SHADOW_MATRIX","mat","DC_OPT_SHADOW_SPECIAL","DC_OPT_SHADOW_MATRIX_SP","DC_OPT_SHADOW_SPECIAL_SP",7,TRUE,TRUE,0,TRUE); add_break(dfp); closebrace(dfp); if( gm->specialtospecial == TRUE ) write_special_shadow_block(dfp,gm,"DC_OPT_SHADOW_MATRIX","mat","DC_OPT_SHADOW_SPECIAL","DC_OPT_SHADOW_MATRIX_SP","DC_OPT_SHADOW_SPECIAL_SP",7,TRUE,0); closebrace(dfp); add_break; expr(dfp,"free(score_pointers);"); expr(dfp,"free(shadow_pointers);"); /* expr(dfp,"free(mat->basematrix->optimised_shadow);"); */ expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } # line 2208 "dynashadow.dy" void write_start_end_build(DYNFILE * dfp,GenericMatrix * gm) { int i; FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"dc_start_end_calculate_%s",gm->name); add_line_to_Ftext(fi->ft,"Calculates special strip, leaving start/end/score points in the shadow matrix "); add_line_to_Ftext(fi->ft,"One tricky thing is that we need to add score-independent calcs in the states"); add_line_to_Ftext(fi->ft,"As we have to evaluate them then. This is not ideally implemented therefore "); add_line_to_Ftext(fi->ft,"In fact it is *definitely* not ideal. Will have to do for now"); start_function_FuncInfo(fi,dfp,"boolean dc_start_end_calculate_%s(%s * mat,DPEnvelope * dpenv)",gm->name,gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"int score;"); expr(dfp,"int temp;"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int localshadow[7]"); expr(dfp,"long int total"); expr(dfp,"long int num=0"); add_break(dfp); expr(dfp,"init_start_end_linear_%s(mat)",gm->name); add_break(dfp); expr(dfp,"leni = mat->%s->%s;",gm->query->name,gm->query_len); expr(dfp,"lenj = mat->%s->%s;",gm->target->name,gm->target_len); expr(dfp,"total = leni * lenj;"); add_break(dfp); expr(dfp,"for(j=0;jlen;i++) { expr(dfp,"%s_DC_SHADOW_MATRIX(mat,i,j,%s) = NEGI",gm->name,gm->state[i]->name); } expr(dfp,"continue;"); closebrace(dfp); expr(dfp,"if( num%%1000 == 0)"); hang_expr(dfp,"log_full_error(REPORT,0,\"%%6d Cells done [%%2d%%%%%%%%]\",num,num*100/total);"); add_break(dfp); write_main_shadow_block(dfp,gm,"DC_SHADOW_MATRIX","mat","DC_SHADOW_SPECIAL","DC_SHADOW_MATRIX_SP","DC_SHADOW_SPECIAL_SP",7,TRUE,TRUE,0,FALSE); add_break(dfp); closebrace(dfp); if( gm->specialtospecial == TRUE ) write_special_shadow_block(dfp,gm,"DC_SHADOW_MATRIX","mat","DC_SHADOW_SPECIAL","DC_SHADOW_MATRIX_SP","DC_SHADOW_SPECIAL_SP",7,TRUE,0); closebrace(dfp); expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } # line 2286 "dynashadow.dy" void write_start_end_macros(DYNFILE * dfp,GenericMatrix * gm) { macro(dfp,"#define %s_SE_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+%d)*2) %% %d][(i+%d)*%d+state])",gm->name,gm->window_j+1,(gm->window_j+1)*2,gm->window_i,gm->len); macro(dfp,"#define %s_SE_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*2][(j+%d)])",gm->name,gm->window_j); macro(dfp,"#define %s_SE_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[( (((j+%d)*2)+(shadow+1)) %% %d)][(i+%d)*%d + state])",gm->name,gm->window_j+1,(gm->window_j+1)*2,gm->window_i,gm->len); macro(dfp,"#define %s_SE_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*2 +(shadow+1)][(j+%d)])",gm->name,gm->window_j); add_break(dfp); } # line 2297 "dynashadow.dy" void write_shadow_start_end_alloc(DYNFILE * dfp,GenericMatrix * gm) { start_function(dfp,"%s * shadow_se_alloc_%s(int leni,int lenj)",gm->name,gm->name); expr(dfp,"register %s * out",gm->name); add_break(dfp); add_block_comment(dfp,"Have to have enough memory to hold start for each state"); add_break(dfp); add_block_comment(dfp,"This means we need (window_j+1)*2 top line pointers by cell number * leni"); add_break(dfp); expr(dfp,"out = %s_alloc()",gm->name); expr(dfp,"if(out == NULL)"); hang_expr(dfp,"return NULL;"); add_end_comment(dfp,"warning already issued"); add_break(dfp); expr(dfp,"out->basematrix = BaseMatrix_alloc_matrix_and_specials(%d,(leni + %d) * %d,%d,lenj+%d)",(gm->window_j+1)*2,gm->window_i,gm->len,gm->spec_len*2,gm->window_j); expr(dfp,"if(out->basematrix == NULL)"); startbrace(dfp); expr(dfp,"warn(\"In shadow_dc_alloc_%s unable to allocate basematrix with main matrix %d by %%d ints\",(leni+%d)*%d);",gm->name,(gm->window_j+1)*2,gm->window_i,gm->len); expr(dfp,"free_%s(out)",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } /* Function: write_main_shadow_block(dfp,gm,matrixtag,pointer_tag,specialtag,shadow_main_tag,shadow_special_tag,shadow_length,shadow_on_special,use_special,debug,use_shadow_pointer) * * Descrip: The core inner loop for shadow methods. Pretty terrifying stuff in here. * * Shadow is considered to be in the memory shadow_main_tag and shadow_special_tag * and usually has the form MATRIX_TYPE_MAIN/SPECIAL_SP. * * shadow has positions 0-length-1, as defined by shadow_length. These are * indexed by k. * * Either shadow_on_special is false * Some other routine has to place the shadow pointers. This routine just * propagates the shadow pointers around * * Or if shadow_on_special is true * This routines pushes when it leaves special and also pushes when it * enters special. This way, special states have the necessary information * to know where in the main matrix they were made from. Means there must be 7 shadow * positions. * * In addition, as a complete mess, shadow on special needs to have score independent * calcs added onto each movement, otherwise the scores are incorrect. So... this * is not *IDEAL* in the slightest!!! * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: matrixtag [UNKN ] Undocumented argument [char *] * Arg: pointer_tag [UNKN ] Undocumented argument [char *] * Arg: specialtag [UNKN ] Undocumented argument [char *] * Arg: shadow_main_tag [UNKN ] Undocumented argument [char *] * Arg: shadow_special_tag [UNKN ] Undocumented argument [char *] * Arg: shadow_length [UNKN ] Undocumented argument [int] * Arg: shadow_on_special [UNKN ] Undocumented argument [boolean] * Arg: use_special [UNKN ] Undocumented argument [boolean] * Arg: debug [UNKN ] Undocumented argument [int] * Arg: use_shadow_pointer [UNKN ] Undocumented argument [int] * */ # line 2355 "dynashadow.dy" void write_main_shadow_block(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointer_tag,char * specialtag,char * shadow_main_tag,char * shadow_special_tag,int shadow_length,boolean shadow_on_special,boolean use_special,int debug,int use_shadow_pointer) { register int i; register int j; register int k; /*** this function assummes the following local variables int score int temp int k int localshadow[SHADOW_LENGTH] int * localsp ***/ if( shadow_on_special == TRUE && shadow_length != 7) warn("In writing main shadow block [main matrix tag %s], attempting to push on specials, and yet shadow_length is %d",matrixtag,shadow_length); if( shadow_on_special == TRUE && use_special == FALSE ) { fatal("Look, you can't shaodw on special but not being using the specials... get otta here"); } for(i=0;ilen;i++) { auto CellState * state; state = gm->state[i]; add_break(dfp); add_block_comment(dfp,"For state %s",state->name); add_block_comment(dfp,"setting first movement to score",state->name); /*********************************************************************/ /* this line looks like */ /* score = ProteinMatrix_EXPL_MATRIX(mat,i-1,j-1,MATCH) + xxxxx */ /*********************************************************************/ if( shadow_on_special ) expr(dfp,"score = %s_%s(%s,i-%d,j-%d,%s) + %s + (%s)",gm->name,matrixtag,pointer_tag, state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source, state->source[0]->calc_expr,state->calc_expr == NULL ? "0" : state->calc_expr); else expr(dfp,"score = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,matrixtag,pointer_tag, state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source, state->source[0]->calc_expr); /*** must also shift shadown positions ***/ if( use_shadow_pointer == FALSE ) { add_block_comment(dfp,"shift first shadow numbers"); expr(dfp,"for(k=0;k<%d;k++)",shadow_length); hang_expr(dfp,"localshadow[k] = %s_%s(mat,i - %d,j - %d,%s,k);", gm->name,state->source[0]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source); } else { add_block_comment(dfp,"assign local shadown pointer"); expr(dfp,"localsp = &(%s_%s(mat,i - %d,j - %d,%s,0));", gm->name,state->source[0]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, state->source[0]->offi,state->source[0]->offj,state->source[0]->state_source); } /**** ok this is to stop underflow, but is v.v.v. hacky ****/ /*** removing underflow hack expr(dfp,"if(score < (-10000000) )"); hang_expr(dfp,"score = (-10000000)"); ****/ /****************************************/ /* now we do if then on score and temp */ /****************************************/ for(j=1;jlen;j++) { if( use_special == FALSE && state->source[j]->isspecial == TRUE ) continue; add_block_comment(dfp,"From state %s to state %s",state->source[j]->state_source, state->name); /*** ok, really nasty piece coming up: The expr is going to change wrt to things a) using special or not (which will require source independent score to be added) b) special source or not. Hence the nested if. Ugh. ***/ if( shadow_on_special ) { /** add in source-independent score **/ if( state->source[j]->isspecial == TRUE ) expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s + (%s)",gm->name,specialtag,pointer_tag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr,state->calc_expr == NULL ? "0" : state->calc_expr); else expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s +(%s)",gm->name,matrixtag,pointer_tag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr,state->calc_expr == NULL ? "0" : state->calc_expr); } else { if( state->source[j]->isspecial == TRUE ) expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,specialtag,pointer_tag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr); else expr(dfp,"temp = %s_%s(%s,i-%d,j-%d,%s) + %s",gm->name,matrixtag,pointer_tag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source, state->source[j]->calc_expr); } /**** ok this is to stop underflow, but is v.v.v. hacky ****/ /**** removing underflow hack expr(dfp,"if(score < (-10000000) )"); hang_expr(dfp,"score = (-10000000)"); ****/ if( debug == 2 ) expr(dfp,"fprintf(stderr,\"[%%4d,%%4d] Score of %s from %s gets %%d\\n\",i,j,temp)",state->name,state->source[j]->state_source ); expr(dfp,"if( temp > score )"); startbrace(dfp); expr(dfp,"score = temp;"); /** ok for shadow matrix should put things in here */ if( shadow_on_special == TRUE && state->source[j]->isspecial == TRUE) { add_block_comment(dfp,"This state [%s] is a special for %s... push top shadow pointers here",state->source[j]->state_source,state->name); expr(dfp,"localshadow[0]= i;"); expr(dfp,"localshadow[1]= j;"); expr(dfp,"localshadow[2]= %s;",state->name); expr(dfp,"localshadow[3]= (-1);"); expr(dfp,"localshadow[4]= (-1);"); expr(dfp,"localshadow[5]= (-1);"); expr(dfp,"localshadow[6]= score;"); if( use_shadow_pointer == TRUE ) { expr(dfp,"localsp = localshadow;"); } } else { if( use_shadow_pointer == FALSE ) { expr(dfp,"for(k=0;k<%d;k++)",shadow_length); hang_expr(dfp,"localshadow[k] = %s_%s(mat,i - %d,j - %d,%s,k);", gm->name,state->source[0]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source); /*** now using local shadow system hang_expr(dfp,"%s_%s(%s,i,j,%s,k) = %s_%s(%s,i - %d,j - %d,%s,k);", gm->name,shadow_main_tag,pointer_tag,state->name, gm->name,state->source[j]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag,pointer_tag,state->source[j]->offi, state->source[j]->offj,state->source[j]->state_source); ***/ } else { add_block_comment(dfp,"assign local shadown pointer"); expr(dfp,"localsp = &(%s_%s(mat,i - %d,j - %d,%s,0));", gm->name,state->source[j]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, state->source[j]->offi,state->source[j]->offj,state->source[j]->state_source); } } /*** end if score > temp ***/ closebrace(dfp); } /************************/ /* finished blocks */ /* put in global calc */ /************************/ add_break(dfp); add_block_comment(dfp,"Ok - finished max calculation for %s",state->name); add_block_comment(dfp,"Add any movement independant score and put away"); if( shadow_on_special ) add_block_comment(dfp,"Actually, already done inside scores"); else if( state->calc_expr != NULL) expr(dfp," score += %s",state->calc_expr); /***************************/ /* put away score */ /***************************/ expr(dfp," %s_%s(%s,i,j,%s) = score;",gm->name,matrixtag,pointer_tag,state->name); /***************************/ /* put away localshadow */ /***************************/ if( use_shadow_pointer == FALSE ) { expr(dfp,"for(k=0;k<%d;k++)",shadow_length); hang_expr(dfp,"%s_%s(%s,i,j,%s,k) = localshadow[k];",gm->name,shadow_main_tag,pointer_tag,state->name); } else { expr(dfp,"for(k=0;k<%d;k++)",shadow_length); hang_expr(dfp,"%s_%s(%s,i,j,%s,k) = localsp[k];",gm->name,shadow_main_tag,pointer_tag,state->name); } add_block_comment(dfp,"Now figure out if any specials need this score"); if( use_special == FALSE ) { add_block_comment(dfp,"Finished calculating state %s",state->name); continue; /** back to for i over state **/ } /************************/ /* for each special */ /* thats has this as */ /* source we have to */ /* update */ /************************/ for(j=0;jspec_len;j++) { auto CellState * specstate; specstate = gm->special[j]; for(k=0;klen;k++) { if( strcmp(specstate->source[k]->state_source,state->name) == 0) { /********************************/ /* is a special source! */ /********************************/ add_break(dfp); add_block_comment(dfp,"state %s is a source for special %s",state->name,specstate->name); expr(dfp,"temp = score + (%s) + (%s) ",specstate->source[k]->calc_expr,specstate->calc_expr == NULL ? "0" : specstate->calc_expr ); expr(dfp,"if( temp > %s_%s(%s,i,j,%s) ) ",gm->name,specialtag,pointer_tag,specstate->name); startbrace(dfp); expr(dfp,"%s_%s(%s,i,j,%s) = temp",gm->name,specialtag,pointer_tag,specstate->name); if(shadow_on_special == TRUE ) { add_block_comment(dfp,"Have to push only bottem half of system here"); expr(dfp,"for(k=0;k<3;k++)"); hang_expr(dfp,"%s_%s(%s,i,j,%s,k) = %s_%s(%s,i,j,%s,k);", gm->name,shadow_special_tag,pointer_tag, specstate->name, gm->name, specstate->source[k]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, pointer_tag,state->name); /*** sort of hacky ***/ expr(dfp,"%s_%s(%s,i,j,%s,6) = %s_%s(%s,i,j,%s,6);", gm->name,shadow_special_tag,pointer_tag, specstate->name, gm->name, specstate->source[k]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, pointer_tag,state->name); expr(dfp,"%s_%s(%s,i,j,%s,3) = i;",gm->name,shadow_special_tag,pointer_tag,specstate->name); expr(dfp,"%s_%s(%s,i,j,%s,4) = j;",gm->name,shadow_special_tag,pointer_tag,specstate->name); expr(dfp,"%s_%s(%s,i,j,%s,5) = %s;",gm->name,shadow_special_tag,pointer_tag,specstate->name,state->name); } else { /** not pushing on specials, pushing elsewhere **/ expr(dfp,"for(k=0;k<%d;k++)",shadow_length); hang_expr(dfp,"%s_%s(%s,i,j,%s,k) = %s_%s(%s,i,j,%s,k);",gm->name,shadow_special_tag,pointer_tag, specstate->name, gm->name,specstate->source[k]->isspecial == TRUE ? shadow_special_tag : shadow_main_tag, pointer_tag,state->name); } closebrace(dfp); add_break(dfp); } } } add_break(dfp); add_block_comment(dfp,"Finished calculating state %s",state->name); } /* end of for each state */ } # line 2643 "dynashadow.dy" void write_special_shadow_block(DYNFILE * dfp,GenericMatrix * gm,char * matrix,char * pointer_tag,char * special,char * shadow_main_tag,char * shadow_special_tag,int shadow_length,boolean shadow_on_special,int debug) { register int i; register int j; for(i=0;ispec_len;i++) { auto CellState * state; state = gm->special[i]; add_break(dfp); if( state->specialtospecial == FALSE ) { add_block_comment(dfp,"Special state %s has no special to special movements",state->name); continue; } add_block_comment(dfp,"Special state %s has special to speical",state->name); add_block_comment(dfp,"Set score to current score (remember, state probably updated during main loop"); expr(dfp,"score = %s_%s(mat,0,j,%s);",gm->name,special,state->name); add_break(dfp); for(j=0;j < state->len;j++) { auto CellSource * source; source = state->source[j]; if( source->isspecial == FALSE ) { add_block_comment(dfp,"Source %s for state %s is not special... already calculated",source->state_source,state->name); continue; /** back to for j **/ } add_block_comment(dfp,"Source %s is a special source for %s",source->state_source,state->name); expr(dfp,"temp = %s_%s(%s,0,j - %d,%s) + (%s) + (%s)",gm->name,special,pointer_tag,source->offj,source->state_source, source->calc_expr,state->calc_expr == NULL ? "0" : state->calc_expr); expr(dfp,"if( temp > score )"); startbrace(dfp); expr(dfp,"score = temp"); add_block_comment(dfp,"Also got to propagate shadows "); expr(dfp,"for(k=0;k<%d;k++)",shadow_length); hang_expr(dfp,"%s_%s(%s,i,j,%s,k) = %s_%s(%s,i - %d,j - %d,%s,k);", gm->name,shadow_special_tag,pointer_tag,state->name, gm->name,shadow_special_tag,pointer_tag,state->source[j]->offi, state->source[j]->offj,state->source[j]->state_source); closebrace(dfp); add_break(dfp); } add_block_comment(dfp,"Put back score... (now updated!)"); expr(dfp,"%s_%s(mat,0,j,%s) = score;",gm->name,special,state->name); add_block_comment(dfp,"Finished updating state %s",state->name); add_break(dfp); } } # line 2759 "dynashadow.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/dynashadow.h0000644000175000001440000001700010670453715015737 0ustar philippusers#ifndef DYNAMITEdynashadowHEADERFILE #define DYNAMITEdynashadowHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna2.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: alloc_small_func_GenericMatrix(dfp,gm) * * Descrip: makes the allocate_Small_xxx function. * This calls allocate_xxx_only function * (made by /write_safe_alloc_function) * and then allocates basematrix stuff as well. * * * Arg: dfp [UNKN ] dynamite file pointer [DYNFILE *] * Arg: gm [READ ] generic matrix structure [const GenericMatrix *] * */ void alloc_small_func_GenericMatrix(DYNFILE * dfp,const GenericMatrix * gm); /* Function: make_small_calculate_func(dfp,gm) * * Descrip: make the calculate function for * small PackAln system * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ void make_small_calculate_func(DYNFILE * dfp,GenericMatrix * gm); /* Function: one_shot_AlnRangeSet_func(dfp,gm) * * Descrip: makes AlnRangeSet from small memory * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ void one_shot_AlnRangeSet_func(DYNFILE * dfp,GenericMatrix * gm); /* Function: write_dc_PackAln_build_func(dfp,gm) * * Descrip: This functions is now defunct * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ void write_dc_PackAln_build_func(DYNFILE * dfp,GenericMatrix * gm); /* Function: write_full_dc_func(dfp,gm) * * Descrip: writes the main divide and conquor routine * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ void write_full_dc_func(DYNFILE * dfp,GenericMatrix * gm); /* Function: write_shadow_dc_alloc(dfp,gm) * * Descrip: Defunct (I think) * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ void write_shadow_dc_alloc(DYNFILE * dfp,GenericMatrix * gm); /* Function: heavy_optimised_shadow_GenericMatrix(dfp,gm) * * Descrip: heavily optimised start end calc function * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * */ void heavy_optimised_shadow_GenericMatrix(DYNFILE * dfp,GenericMatrix * gm); /* Function: optimised_shadow_GenericMatrix(dfp,*gm) * * Descrip: Makes the optimised shadow matrix routine, * worked out by Steve Searle - memory access * is put into one array so that the routine * is faster * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: *gm [UNKN ] Undocumented argument [const GenericMatrix] * */ void optimised_shadow_GenericMatrix(DYNFILE * dfp,const GenericMatrix *gm); /* Function: write_main_shadow_block(dfp,gm,matrixtag,pointer_tag,specialtag,shadow_main_tag,shadow_special_tag,shadow_length,shadow_on_special,use_special,debug,use_shadow_pointer) * * Descrip: The core inner loop for shadow methods. Pretty terrifying stuff in here. * * Shadow is considered to be in the memory shadow_main_tag and shadow_special_tag * and usually has the form MATRIX_TYPE_MAIN/SPECIAL_SP. * * shadow has positions 0-length-1, as defined by shadow_length. These are * indexed by k. * * Either shadow_on_special is false * Some other routine has to place the shadow pointers. This routine just * propagates the shadow pointers around * * Or if shadow_on_special is true * This routines pushes when it leaves special and also pushes when it * enters special. This way, special states have the necessary information * to know where in the main matrix they were made from. Means there must be 7 shadow * positions. * * In addition, as a complete mess, shadow on special needs to have score independent * calcs added onto each movement, otherwise the scores are incorrect. So... this * is not *IDEAL* in the slightest!!! * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: matrixtag [UNKN ] Undocumented argument [char *] * Arg: pointer_tag [UNKN ] Undocumented argument [char *] * Arg: specialtag [UNKN ] Undocumented argument [char *] * Arg: shadow_main_tag [UNKN ] Undocumented argument [char *] * Arg: shadow_special_tag [UNKN ] Undocumented argument [char *] * Arg: shadow_length [UNKN ] Undocumented argument [int] * Arg: shadow_on_special [UNKN ] Undocumented argument [boolean] * Arg: use_special [UNKN ] Undocumented argument [boolean] * Arg: debug [UNKN ] Undocumented argument [int] * Arg: use_shadow_pointer [UNKN ] Undocumented argument [int] * */ void write_main_shadow_block(DYNFILE * dfp,GenericMatrix * gm,char * matrixtag,char * pointer_tag,char * specialtag,char * shadow_main_tag,char * shadow_special_tag,int shadow_length,boolean shadow_on_special,boolean use_special,int debug,int use_shadow_pointer); /* Unplaced functions */ /* There has been no indication of the use of these functions */ void write_dc_functions(DYNFILE * dfp,GenericMatrix * gm); void write_AlnRangeSet_build_func(DYNFILE * dfp,GenericMatrix * gm); void write_AlnRange_build_func(DYNFILE * dfp,GenericMatrix * gm); void write_single_dc_pass_func(DYNFILE * dfp,GenericMatrix * gm); void write_push_dc_func(DYNFILE * dfp,GenericMatrix * gm); void write_init_dc_func(DYNFILE * dfp,GenericMatrix * gm); void write_up_to_dc_func(DYNFILE * dfp,GenericMatrix * gm); void write_follow_on_dc_func(DYNFILE * dfp,GenericMatrix * gm); void write_special_strip_read_func(DYNFILE * dfp,GenericMatrix * gm); void write_hidden_read_func(DYNFILE * dfp,GenericMatrix * gm); void write_hidden_calc_func(DYNFILE * dfp,GenericMatrix * gm); void write_hidden_init_func(DYNFILE * dfp,GenericMatrix * gm); void write_hidden_max_func(DYNFILE * dfp,GenericMatrix * gm); void write_matrix_to_special_max_func(DYNFILE * dfp,GenericMatrix * gm); void write_special_strip_max_func(DYNFILE * dfp,GenericMatrix * gm); void write_shadow_dc_macros(DYNFILE * dfp,GenericMatrix * gm); void write_start_end_init(DYNFILE * dfp,GenericMatrix * gm); void write_start_end_find_end(DYNFILE * dfp,GenericMatrix * gm); void write_start_end_build(DYNFILE * dfp,GenericMatrix * gm); void write_start_end_macros(DYNFILE * dfp,GenericMatrix * gm); void write_shadow_start_end_alloc(DYNFILE * dfp,GenericMatrix * gm); void write_special_shadow_block(DYNFILE * dfp,GenericMatrix * gm,char * matrix,char * pointer_tag,char * special,char * shadow_main_tag,char * shadow_special_tag,int shadow_length,boolean shadow_on_special,int debug); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/modulefunc.dy0000644000175000001440000000667607313404534016140 0ustar philippusers/* Last edited: Oct 4 16:25 1996 (birney) */ %{ #include "wisebase.h" #define ModuleFunctionListLISTLENGTH 64 /********************************************************/ /* Wisetools version 3 file */ /* */ /* this file is copyright (c) Ewan Birney 1996 */ /* this file is part of the wisetools sequence analysis */ /* package */ /********************************************************/ /********************************************************/ /* This stores information about which modules do */ /* have constructors or deconstructors, such that */ /* they can be made correctly */ /* */ /********************************************************/ /***** RCS Info *****************************************/ /* $Id $Log */ /********************************************************/ %} struct ModuleFunction char * name boolean has_cons !def="FALSE" boolean has_decons !def="FALSE" boolean has_copy !def="FALSE" struct ModuleFunctionList ModuleFunction ** mf !list %{ #include "modulefunc.h" ModuleFunction * get_ModuleFunction_from_name(ModuleFunctionList * mfl,char * name) { register int i; for(i=0;ilen;i++) if( strcmp(mfl->mf[i]->name,name) == 0 ) return mfl->mf[i]; return NULL; } ModuleFunction * new_ModuleFunction(ModuleFunctionList * mfl,char * name) { ModuleFunction * out; out = ModuleFunction_alloc(); if( out == NULL ) return out; out->name = stringalloc(name); add_ModuleFunctionList(mfl,out); return out; } void show_ModuleFunctionList(ModuleFunctionList * mfl,FILE * ofp) { register int i; for(i=0;ilen;i++) show_ModuleFunction(mfl->mf[i],ofp); } void show_ModuleFunction(ModuleFunction * mf,FILE * ofp) { fprintf(ofp,"Module %s Constructor: %s Deconstructor %s\n",mf->name, mf->has_cons == TRUE ? "yes" : " no", mf->has_decons == TRUE ? "yes" : " no"); } char * parse_and_get_module_name_from_func(char * line,boolean isalloc) { char * name; char * next; char * func; char buffer[128]; /** max function name! **/ name = strtok(line," \t("); if( name == NULL ) { warn("Cannot even get first name from line [%s] in parse module_name_alloc",line); return NULL; } if( *(name + strlen(name) - 1) == '*' ) next = name + strlen(name) -1; else { next = strtok(NULL," \t("); if ( next == NULL ) { warn("Cannot get pointer ref from line [%s] in parse module_name_alloc [name %s]",line,name); return NULL; } } func = strtok(NULL," \t("); if( name == NULL ) { warn("Cannot get function from line [%s] in parse module_name_alloc [name %s]",line,name); return NULL; } if( strlen(next) > 1 || *next != '*' ) { warn("In parse_module_name, the pointer string [%s] was invalid for name [%s]",next,name); return NULL; } if( isalloc == TRUE ) { sprintf(buffer,"%s_alloc",name); if( strcmp(buffer,func) != 0 ) { warn("In parse_module_name, the function [%s] did not match the type-proto [%s]",func,buffer); return NULL; } } else { sprintf(buffer,"free_%s",name); if( strcmp(buffer,func) != 0 ) { warn("In parse_module_name, the function [%s] did not match the type-proto [%s]",func,buffer); return NULL; } } return stringalloc(name); } %} wise-2.4.1/src/dyc/dynadb.dy0000644000175000001440000002422407313404533015224 0ustar philippusers %{ #include "dyna2.h" #include "dynafunc.h" #include "dpimpl.h" %} %{ #include "dynadb.h" %func Makes the serial search function, which loops over databases %% void make_search_loop_function(DYNFILE * dfp,GenericMatrix * gm) { int i; char buffer[MAXLINE]; FuncInfo * fi; boolean qdb = FALSE; boolean tdb = FALSE; char * cstr; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"serial_search_%s",gm->name); add_line_to_Ftext(fi->ft,"This function makes a database search of %s",gm->name); add_line_to_Ftext(fi->ft,"It is a single processor implementation"); if( gm->qtype != NULL && gm->qtype->is_database == TRUE) qdb = TRUE; if( gm->ttype != NULL && gm->ttype->is_database == TRUE) tdb = TRUE; if( qdb == TRUE) sprintf(buffer,"Search_Return_Type serial_search_%s(Hscore * out,%s querydb,",gm->name,gm->qtype->database_type); else sprintf(buffer,"Search_Return_Type serial_search_%s(Hscore * out,%s %s,",gm->name,gm->query->element_type,gm->query->name); if( tdb == TRUE) { strcat(buffer,gm->ttype->database_type); strcat(buffer," targetdb "); } else { strcat(buffer,gm->target->element_type); strcat(buffer," "); strcat(buffer,gm->target->name); strcat(buffer," "); } for(i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,gm->resource[i]->element_type); strcat(buffer," "); strcat(buffer,gm->resource[i]->name); } strcat(buffer,")"); start_function_FuncInfo(fi,dfp,buffer); if( qdb == TRUE ) expr(dfp,"%s %s",gm->query->element_type,gm->query->name); if( tdb == TRUE ) expr(dfp,"%s %s",gm->target->element_type,gm->target->name); expr(dfp,"int db_status"); expr(dfp,"int score"); expr(dfp,"int query_pos = 0;"); expr(dfp,"int target_pos = 0;"); expr(dfp,"DataScore * ds;"); add_break(dfp); expr(dfp,"push_errormsg_stack(\"Before any actual search in db searching\");"); if( qdb == TRUE) { expr(dfp,"%s = %s(querydb,&db_status);",gm->query->name,gm->qtype->init_func); expr(dfp,"if( db_status == DB_RETURN_ERROR ) "); startbrace(dfp); warn_expr(dfp,"In searching %s, got a database reload error on the query [%s] database",gm->name,gm->query->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); expr(dfp,"for(;;)"); startbrace_tag(dfp,"For all query entries"); } add_break(dfp); expr(dfp,"target_pos = 0"); add_break(dfp); if( tdb == TRUE) { expr(dfp,"%s = %s(targetdb,&db_status);",gm->target->name,gm->ttype->init_func); expr(dfp,"if( db_status == DB_RETURN_ERROR ) "); startbrace(dfp); warn_expr(dfp,"In searching %s, got a database init error on the target [%s] database",gm->name,gm->target->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); expr(dfp,"for(;;)"); startbrace_tag(dfp,"For all target entries"); } add_break(dfp); cstr = get_chainstr_GenericMatrix(gm); if(gm->qtype != NULL && gm->qtype->maxlen != NULL) { add_block_comment(dfp,"Maximum length to search - should check"); expr(dfp,"if( %s->%s > %s ) ",gm->query->name,gm->query_len,gm->qtype->maxlen); startbrace_tag(dfp,"if over length"); warn_expr(dfp,"A query over the length when maxlen provided. Problem!"); expr(dfp,"score = -10000;\n"); closebrace(dfp); expr(dfp,"else"); hang_expr(dfp,"score = score_only_%s(%s)",gm->name,cstr); } else { add_block_comment(dfp,"No maximum length - allocated on-the-fly"); expr(dfp,"score = score_only_%s(%s)",gm->name,cstr); } ckfree(cstr); expr(dfp,"if( should_store_Hscore(out,score) == TRUE ) "); startbrace_tag(dfp,"if storing datascore"); expr(dfp,"ds = new_DataScore_from_storage(out)"); expr(dfp,"if( ds == NULL ) "); startbrace(dfp); warn_expr(dfp,"%s search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure",gm->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); add_block_comment(dfp,"Now: add query/target information to the entry"); if( qdb == TRUE) expr(dfp,"%s(ds->query,%s,querydb)",gm->qtype->dataentry_add,gm->query->name); if( tdb == TRUE) expr(dfp,"%s(ds->target,%s,targetdb)",gm->ttype->dataentry_add,gm->target->name); expr(dfp,"ds->score = score"); expr(dfp,"add_Hscore(out,ds);"); closebrace(dfp); /* end of if stores */ expr(dfp,"pop_errormsg_stack()"); expr(dfp,"push_errormsg_stack(\"DB searching: just finished [Query Pos: %%d] [Target Pos: %%d]\",query_pos,target_pos);"); add_break(dfp); if( tdb == TRUE ) { expr(dfp," %s = %s(%s,targetdb,&db_status)",gm->target->name,gm->ttype->reload_func,gm->target->name); expr(dfp,"if( db_status == DB_RETURN_ERROR )"); startbrace(dfp); expr(dfp,"warn(\"In searching %s, Reload error on database %s, position %%d,%%d\",query_pos,target_pos);",gm->name,gm->target->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); expr(dfp,"if( db_status == DB_RETURN_END )"); hang_expr(dfp,"break;"); add_end_comment(dfp,"Out of target loop"); expr(dfp,"target_pos++;"); closebrace(dfp); expr(dfp,"%s(%s,targetdb)",gm->ttype->close_func,gm->target->name); } if( qdb == TRUE ) { expr(dfp," %s = %s(%s,querydb,&db_status)",gm->query->name,gm->qtype->reload_func,gm->query->name); expr(dfp,"if( db_status == DB_RETURN_ERROR)"); startbrace(dfp); expr(dfp,"warn(\"In searching %s, Reload error on database %s, position %%d,%%d\",query_pos,target_pos);",gm->name,gm->query->name); expr(dfp,"return SEARCH_ERROR;"); closebrace(dfp); expr(dfp,"if( db_status == DB_RETURN_END)"); hang_expr(dfp,"break;"); add_end_comment(dfp,"Out of query loop"); expr(dfp,"query_pos++;"); closebrace(dfp); expr(dfp,"%s(%s,querydb)",gm->qtype->close_func,gm->query->name); } expr(dfp,"pop_errormsg_stack()"); expr(dfp,"return SEARCH_OK;"); close_function(dfp); add_break(dfp); } %func Makes the score only function, which gives the score for two objects. Used in the serial and the pthreads ports %% void write_one_score_GenericMatrix(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { int i,j; FuncInfo * fi; char * arg_str; char * chain_str; for(j=0;jspec_len;j++) if( gm->special[j]->is_start == TRUE ) break; /*** prepare function information ***/ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"score_only_%s",gm->name); add_line_to_Ftext(fi->ft,"This function just calculates the score for the matrix",gm->name); add_line_to_Ftext(fi->ft,"I am pretty sure we can do this better, but hey, for the moment..."); add_line_to_Ftext(fi->ft,"It calls /allocate_%s_only",gm->name); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"int score_only_%s(%s)",gm->name,arg_str); /*** clean up ***/ ckfree(arg_str); /*** into function body ***/ expr(dfp,"int bestscore = NEGI;"); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int k;"); expr(dfp,"%s * mat",gm->name); if(gm->qtype != NULL && gm->qtype->maxlen != NULL) { expr(dfp,"int internal_matrix[%d][(%s+%d) * %d];",gm->window_j+1,gm->qtype->maxlen,gm->window_i,gm->len); expr(dfp,"int internal_specials[%d][%d];",gm->window_j+1,gm->spec_len); } if( dpi->largemem == TRUE ) { expr(dfp,"int * internal_pointer_db;"); expr(dfp,"int * internal_special_db;"); } add_break(dfp); chain_str = get_chainstr_GenericMatrix(gm); expr(dfp,"mat = allocate_%s_only(%s);",gm->name,chain_str); ckfree(chain_str); expr(dfp,"if( mat == NULL )"); startbrace(dfp); warn_expr(dfp,"Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); expr(dfp,"return NEGI"); closebrace(dfp); if(gm->qtype != NULL && gm->qtype->maxlen != NULL) { add_block_comment(dfp,"Ok,don't need to allocate matrix as it is internal, because we have a max length"); } else if ( dpi->largemem == TRUE ) { expr(dfp,"if( (internal_pointer_db = (int *)ckcalloc(((mat->leni+%d) * %d),sizeof(int))) == NULL)", gm->window_i,((gm->window_j+1)*gm->len)); hang_expr(dfp,"fatal(\"could not allocate internal matrix in long mode\");"); expr(dfp,"if( (internal_special_db = (int *)ckcalloc(%d,sizeof(int))) == NULL)", ((gm->window_j+1)*gm->spec_len)); hang_expr(dfp,"fatal(\"could not allocate internal matrix in long mode\");"); } else { expr(dfp,"if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(%d,(mat->leni + %d) * %d,%d,%d)) == NULL)",gm->window_j+1,gm->window_i,gm->len,gm->window_j+1,gm->spec_len); startbrace(dfp); expr(dfp,"warn(\"Score only matrix for %s cannot be allocated, (asking for %d by %%d cells)\",mat->leni*%d);",gm->name,gm->window_j,gm->len); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return 0;"); closebrace(dfp); expr(dfp,"mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL;"); } add_break(dfp); add_block_comment(dfp,"Now, initiate matrix"); expr(dfp,"for(j=0;j<%d;j++)",gm->window_j+2); startbrace(dfp); expr(dfp,"for(i=(-%d);ileni;i++)",gm->window_i); startbrace(dfp); expr(dfp,"for(k=0;k<%d;k++)",gm->len); hang_expr(dfp,"%s_VSMALL_MATRIX(mat,i,j,k) = NEGI;",gm->name); closebrace(dfp); for(i=0;ispec_len;i++) { expr(dfp,"%s_VSMALL_SPECIAL(mat,i,j,%s) = %s;",gm->name,gm->special[i]->name,gm->special[i]->def_score); } closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Ok, lets do-o-o-o-o it"); add_break(dfp); expr(dfp,"for(j=0;jlenj;j++)"); startbrace_tag(dfp,"for all target positions"); expr(dfp,"auto int score"); expr(dfp,"auto int temp"); if( dpi->largemem == TRUE ) { add_block_comment(dfp,"Need to reset START to 0"); expr(dfp,"%s_VSMALL_SPECIAL(mat,0,j,%s) = 0",gm->name,gm->special[j]->name); } expr(dfp,"for(i=0;ileni;i++)"); startbrace_tag(dfp,"for all query positions"); write_score_block(dfp,gm,"VSMALL_MATRIX","mat","VSMALL_SPECIAL",TRUE); closebrace(dfp); add_break(dfp); write_special_block(dfp,gm,"VSMALL_MATRIX","VSMALL_SPECIAL","bestscore"); closebrace(dfp); add_break(dfp); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return bestscore;"); close_function(dfp); add_break(dfp); } wise-2.4.1/src/dyc/probal.c0000644000175000001440000001520410670453715015054 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "probal.h" /* Function: write_probabilistic_models(dfp,gm,dpi) * * Descrip: Makes all the probabilistic routines * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ # line 17 "probal.dy" void write_probabilistic_models(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { write_score_only_sum(dfp,gm,dpi); write_expl_mat_sum(dfp,gm,dpi); } /* Function: write_expl_mat_sum(dfp,gm,dpi) * * Descrip: Makes the explicit matrix over all paths * construction method * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ # line 28 "probal.dy" void write_expl_mat_sum(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { FuncInfo * fi; char * arg_str; char * chainstr; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"matrix_logsum_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates the matrix over all paths"); add_line_to_Ftext(fi->ft,"This is using a logsum method to sort it all out"); arg_str = get_argstr_GenericMatrix(gm); chainstr = get_chainstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"%s * matrix_logsum_%s(%s)",gm->name,gm->name,arg_str); ckfree(arg_str); expr(dfp,"%s * mat;",gm->name); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int leni;"); expr(dfp,"int lenj;"); expr(dfp,"int tot;"); expr(dfp,"int num;"); add_break(dfp); expr(dfp,"if( (mat=allocate_Expl_%s(%s)) == NULL )",gm->name,chainstr); startbrace(dfp); warn_expr(dfp,"Unable to allocate large %s version",gm->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"leni = mat->leni;"); expr(dfp,"lenj = mat->lenj;"); /*** make num and tot ***/ expr(dfp,"tot = leni * lenj;"); expr(dfp,"num = 0;"); /*** see if there any specials to specials to do ***/ add_break(dfp); expr(dfp,"start_reporting(\"%s Matrix calculation: \");",gm->name); expr(dfp,"for(j=0;jname); **/ expr(dfp,"num++;"); gm->calcfunc = dpi->calcfunc; write_score_block(dfp,gm,"EXPL_MATRIX","mat","EXPL_SPECIAL",TRUE); closebrace(dfp); write_special_block(dfp,gm,"EXPL_MATRIX","EXPL_SPECIAL",NULL); gm->calcfunc = NULL; closebrace(dfp); /*** stop reporting ***/ expr(dfp,"stop_reporting()"); expr(dfp,"return mat"); close_function(dfp); add_break(dfp); } /* Function: write_score_only_sum(dfp,gm,dpi) * * Descrip: Makes the single one-on-one over all paths * searching method * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ # line 117 "probal.dy" void write_score_only_sum(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi) { int i; FuncInfo * fi; char * arg_str; char * chain_str; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"score_only_logsum_%s",gm->name); add_line_to_Ftext(fi->ft,"This function calculates the score over all paths"); add_line_to_Ftext(fi->ft,"This is using a logsum method to sort it all out"); arg_str = get_argstr_GenericMatrix(gm); add_args_GenericMatrix_FuncInfo(fi,gm); start_function_FuncInfo(fi,dfp,"Score score_only_logsum_%s(%s)",gm->name,arg_str); ckfree(arg_str); expr(dfp,"int i;"); expr(dfp,"int j;"); expr(dfp,"int bestscore = 0;"); expr(dfp,"int k;"); expr(dfp,"%s * mat",gm->name); if(gm->qtype != NULL && gm->qtype->maxlen != NULL) { expr(dfp,"int internal_matrix[%d][(%s+%d) * %d];",gm->window_j+1,gm->qtype->maxlen,gm->window_i,gm->len); expr(dfp,"int internal_specials[%d][%d];",gm->window_j+1,gm->spec_len); } add_break(dfp); chain_str = get_chainstr_GenericMatrix(gm); expr(dfp,"mat = allocate_%s_only(%s);",gm->name,chain_str); ckfree(chain_str); expr(dfp,"if( mat == NULL )"); startbrace(dfp); warn_expr(dfp,"Memory allocation error in the db search - unable to communicate to calling function. this spells DISASTER!"); expr(dfp,"return NEGI"); closebrace(dfp); if(gm->qtype != NULL && gm->qtype->maxlen != NULL) { add_block_comment(dfp,"Ok,don't need to allocate matrix as it is internal, because we have a max length"); } else { expr(dfp,"if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(%d,(mat->leni + %d) * %d,%d,%d)) == NULL)",gm->window_j+1,gm->window_i,gm->len,gm->window_j+1,gm->spec_len); startbrace(dfp); expr(dfp,"warn(\"Score only matrix for %s cannot be allocated, (asking for %d by %%d cells)\",mat->leni*%d);",gm->name,gm->window_j,gm->len); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return 0;"); closebrace(dfp); expr(dfp,"mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL;"); } add_break(dfp); add_block_comment(dfp,"Now, initiate matrix"); expr(dfp,"for(j=0;j<%d;j++)",gm->window_j+2); startbrace(dfp); expr(dfp,"for(i=(-%d);ileni;i++)",gm->window_i); startbrace(dfp); expr(dfp,"for(k=0;k<%d;k++)",gm->len); hang_expr(dfp,"%s_VSMALL_MATRIX(mat,i,j,k) = NEGI;",gm->name); closebrace(dfp); for(i=0;ispec_len;i++) { expr(dfp,"%s_VSMALL_SPECIAL(mat,i,j,%s) = %s;",gm->name,gm->special[i]->name,gm->special[i]->def_score); } closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Ok, lets do-o-o-o-o it"); add_break(dfp); expr(dfp,"for(j=0;jlenj;j++)"); startbrace_tag(dfp,"for all target positions"); expr(dfp,"auto int score"); expr(dfp,"auto int temp"); expr(dfp,"for(i=0;ileni;i++)"); startbrace_tag(dfp,"for all query positions"); gm->calcfunc = dpi->calcfunc; write_score_block(dfp,gm,"VSMALL_MATRIX","mat","VSMALL_SPECIAL",TRUE); gm->calcfunc = NULL; closebrace(dfp); add_break(dfp); gm->calcfunc = dpi->calcfunc; write_special_block(dfp,gm,"VSMALL_MATRIX","VSMALL_SPECIAL",NULL); gm->calcfunc = NULL; closebrace(dfp); add_break(dfp); expr(dfp,"mat = free_%s(mat)",gm->name); expr(dfp,"return bestscore;"); close_function(dfp); add_break(dfp); } # line 239 "probal.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/probal.h0000644000175000001440000000375510670453715015071 0ustar philippusers#ifndef DYNAMITEprobalHEADERFILE #define DYNAMITEprobalHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna2.h" #include "dynafunc.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: write_probabilistic_models(dfp,gm,dpi) * * Descrip: Makes all the probabilistic routines * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ void write_probabilistic_models(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi); /* Function: write_expl_mat_sum(dfp,gm,dpi) * * Descrip: Makes the explicit matrix over all paths * construction method * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ void write_expl_mat_sum(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi); /* Function: write_score_only_sum(dfp,gm,dpi) * * Descrip: Makes the single one-on-one over all paths * searching method * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: gm [UNKN ] Undocumented argument [GenericMatrix *] * Arg: dpi [UNKN ] Undocumented argument [DPImplementation *] * */ void write_score_only_sum(DYNFILE * dfp,GenericMatrix * gm,DPImplementation * dpi); /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/inputfile.dy0000644000175000001440000000141407313404534015757 0ustar philippusers %{ #include "wisebase.h" %} %{ #include "inputfile.h" static FILE * watch_file = NULL; static linecount = 0; boolean open_watch_file(FILE * ifp) { if( watch_file != NULL ) { warn("Can't watch a new file, already set!"); return FALSE; } watch_file = ifp; linecount = 0; return TRUE; } boolean close_watch_file(void) { if( watch_file == NULL ) { warn("No watch file to close"); return FALSE; } watch_file = NULL; return TRUE; } char * get_watched_line(char * buffer,int max,FILE * ifp) { if( ifp != watch_file) { warn("Trying to get a watched line without watching the file!"); return fgets(buffer,max,ifp); } linecount++; return fgets(buffer,max,ifp); } int get_watched_linecount(void) { return linecount; } %} wise-2.4.1/src/dyc/linkmap.c0000644000175000001440000002554210670453715015236 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "linkmap.h" # line 18 "linkmap.dy" char * update_links_LinkMap(char * line,char * startid,char * stopid,char * nolinkstr,LinkSet * ls) { char buffer[MAXLINE]; char * run; char c; char * end; LinkMap * lm; for(end=line,run=line;(run = strstr(run,startid)) != NULL;) { /*** strcat the previous string ***/ c = *run; *run = '\0'; strcat(buffer,end); /*** now put in the link system ***/ end = strstr(run,stopid); c = *end; *end = '\0'; if( (lm = LinkMap_from_word(run,ls)) == NULL ) { } } } # line 47 "linkmap.dy" LinkMap * new_std_LinkMap(char * word,char * urlstub,char * textstub) { char buffer[128]; char * run; LinkMap * out; out= LinkMap_alloc(); push_scan_and_replace_pair("$LINK",word); strcpy(buffer,urlstub); run = scan_and_replace_line(buffer); out->urltail = stringalloc(run); strcpy(buffer,textstub); run = scan_and_replace_line(buffer); out->text = stringalloc(textstub); pop_scan_and_replace_pair(); return out; } # line 70 "linkmap.dy" LinkMap * LinkMap_from_word(char * word,LinkSet * ls) { int i; for(i=0;ilen;i++) { if( strcmp(ls->lm[i]->word,word) == 0 ) return lm[i]; } return NULL; } # line 76 "linkmap.c" /* Function: hard_link_LinkMap(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkMap *] * * Return [UNKN ] Undocumented return value [LinkMap *] * */ LinkMap * hard_link_LinkMap(LinkMap * obj) { if( obj == NULL ) { warn("Trying to hard link to a LinkMap object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LinkMap_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkMap *] * */ LinkMap * LinkMap_alloc(void) { LinkMap * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LinkMap *) ckalloc (sizeof(LinkMap))) == NULL) { warn("LinkMap_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->word = NULL; out->urltail = NULL; out->text = NULL; return out; } /* Function: free_LinkMap(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkMap *] * * Return [UNKN ] Undocumented return value [LinkMap *] * */ LinkMap * free_LinkMap(LinkMap * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LinkMap obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->word != NULL) ckfree(obj->word); if( obj->urltail != NULL) ckfree(obj->urltail); if( obj->text != NULL) ckfree(obj->text); ckfree(obj); return NULL; } /* Function: swap_LinkSet(list,i,j) * * Descrip: swap function: an internal for qsort_LinkSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [LinkMap **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_LinkSet(LinkMap ** list,int i,int j) { LinkMap * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_LinkSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_LinkSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [LinkMap **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_LinkSet(LinkMap ** list,int left,int right,int (*comp)(LinkMap * ,LinkMap * )) { int i,last; if( left >= right ) return; swap_LinkSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_LinkSet (list,++last,i); } swap_LinkSet (list,left,last); qsort_LinkSet(list,left,last-1,comp); qsort_LinkSet(list,last+1,right,comp); } /* Function: sort_LinkSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_LinkSet * * * Arg: obj [UNKN ] Object containing list [LinkSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_LinkSet(LinkSet * obj,int (*comp)(LinkMap *, LinkMap *)) { qsort_LinkSet(obj->lm,0,obj->len-1,comp); return; } /* Function: expand_LinkSet(obj,len) * * Descrip: Really an internal function for add_LinkSet * * * Arg: obj [UNKN ] Object which contains the list [LinkSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_LinkSet(LinkSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_LinkSet called with no need"); return TRUE; } if( (obj->lm = (LinkMap ** ) ckrealloc (obj->lm,sizeof(LinkMap *)*len)) == NULL) { warn("ckrealloc failed for expand_LinkSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_LinkSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LinkSet *] * Arg: add [OWNER] Object to add to the list [LinkMap *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_LinkSet(LinkSet * obj,LinkMap * add) { if( obj->len >= obj->maxlen) { if( expand_LinkSet(obj,obj->len + LinkSetLISTLENGTH) == FALSE) return FALSE; } obj->lm[obj->len++]=add; return TRUE; } /* Function: flush_LinkSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LinkSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_LinkSet(LinkSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->lm[i] != NULL) { free_LinkMap(obj->lm[i]); obj->lm[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: LinkSet_alloc_std(void) * * Descrip: Equivalent to LinkSet_alloc_len(LinkSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [LinkSet *] * */ LinkSet * LinkSet_alloc_std(void) { return LinkSet_alloc_len(LinkSetLISTLENGTH); } /* Function: LinkSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [LinkSet *] * */ LinkSet * LinkSet_alloc_len(int len) { LinkSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = LinkSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->lm = (LinkMap ** ) ckcalloc (len,sizeof(LinkMap *))) == NULL) { warn("Warning, ckcalloc failed in LinkSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_LinkSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkSet *] * * Return [UNKN ] Undocumented return value [LinkSet *] * */ LinkSet * hard_link_LinkSet(LinkSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a LinkSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LinkSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkSet *] * */ LinkSet * LinkSet_alloc(void) { LinkSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LinkSet *) ckalloc (sizeof(LinkSet))) == NULL) { warn("LinkSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->lm = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_LinkSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkSet *] * * Return [UNKN ] Undocumented return value [LinkSet *] * */ LinkSet * free_LinkSet(LinkSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LinkSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->lm != NULL) { for(i=0;ilen;i++) { if( obj->lm[i] != NULL) free_LinkMap(obj->lm[i]); } ckfree(obj->lm); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/linkmap.h0000644000175000001440000001147510670453715015243 0ustar philippusers#ifndef DYNAMITElinkmapHEADERFILE #define DYNAMITElinkmapHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" struct LinkMap { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * word; char * urltail; char * text; } ; /* LinkMap defined */ #ifndef DYNAMITE_DEFINED_LinkMap typedef struct LinkMap LinkMap; #define DYNAMITE_DEFINED_LinkMap #endif struct LinkSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif LinkMap ** lm; int len;/* len for above lm */ int maxlen; /* maxlen for above lm */ } ; /* LinkSet defined */ #ifndef DYNAMITE_DEFINED_LinkSet typedef struct LinkSet LinkSet; #define DYNAMITE_DEFINED_LinkSet #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_LinkMap(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkMap *] * * Return [UNKN ] Undocumented return value [LinkMap *] * */ LinkMap * hard_link_LinkMap(LinkMap * obj); /* Function: LinkMap_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkMap *] * */ LinkMap * LinkMap_alloc(void); /* Function: free_LinkMap(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkMap *] * * Return [UNKN ] Undocumented return value [LinkMap *] * */ LinkMap * free_LinkMap(LinkMap * obj); /* Function: add_LinkSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LinkSet *] * Arg: add [OWNER] Object to add to the list [LinkMap *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_LinkSet(LinkSet * obj,LinkMap * add); /* Function: flush_LinkSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LinkSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_LinkSet(LinkSet * obj); /* Function: LinkSet_alloc_std(void) * * Descrip: Equivalent to LinkSet_alloc_len(LinkSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [LinkSet *] * */ LinkSet * LinkSet_alloc_std(void); /* Function: LinkSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [LinkSet *] * */ LinkSet * LinkSet_alloc_len(int len); /* Function: hard_link_LinkSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkSet *] * * Return [UNKN ] Undocumented return value [LinkSet *] * */ LinkSet * hard_link_LinkSet(LinkSet * obj); /* Function: LinkSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkSet *] * */ LinkSet * LinkSet_alloc(void); /* Function: free_LinkSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkSet *] * * Return [UNKN ] Undocumented return value [LinkSet *] * */ LinkSet * free_LinkSet(LinkSet * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ char * update_links_LinkMap(char * line,char * startid,char * stopid,char * nolinkstr,LinkSet * ls); LinkMap * new_std_LinkMap(char * word,char * urlstub,char * textstub); LinkMap * LinkMap_from_word(char * word,LinkSet * ls); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void swap_LinkSet(LinkMap ** list,int i,int j) ; void qsort_LinkSet(LinkMap ** list,int left,int right,int (*comp)(LinkMap * ,LinkMap * )); void sort_LinkSet(LinkSet * obj,int (*comp)(LinkMap *, LinkMap *)); boolean expand_LinkSet(LinkSet * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/display.dy0000644000175000001440000005077707313404533015444 0ustar philippusers/* Last edited: Jan 13 16:56 1997 (birney) */ %{ #include "wisebase.h" #include "dynfile.h" /********************************************************/ /* Wisetools version 3 file */ /* */ /* this file is copyright (c) Ewan Birney 1996 */ /* this file is part of the wisetools sequence analysis */ /* package */ /********************************************************/ /********************************************************/ /* Display is an internal module for dynamite itself */ /* to manage the display tag found in dynamite files */ /* */ /* */ /********************************************************/ /***** RCS Info *****************************************/ /* $Id: $Log: */ /*********************************************************/ #define Label2DisplayLISTLENGTH 32 #define Sequence2DisplayLISTLENGTH 32 #define Aln2DisplayLISTLENGTH 32 #define ALL_OTHER_NUMBER (-10) %} struct Aln2DisplayField char * string char * length char * direction char * convert boolean is_static !def="FALSE" boolean is_string !def="FALSE" boolean is_single !def="FALSE" boolean is_sub !def="FALSE" struct Index2Display char * name; char * eval; boolean is_start; !def="FALSE" int number; struct Label2Display char * label char * direction Aln2DisplayField ** a2df !list Index2Display ** i2d !list !len="ind_" boolean is_lone !def="FALSE" struct Sequence2Display int number Label2Display ** l2d !list Index2Display ** i2d !list !len="ind_" char * name_str; int length; // of name boolean is_static !def="FALSE" char * direction struct Aln2DisplayResource char * type; char * name; char * arg; struct Aln2Display char * name Aln2DisplayResource ** a2dr !list !len="res_" Sequence2Display ** s2d !list Sequence2Display * other %{ #include "display.h" void write_Aln2Display_header(DYNFILE * dfp,Aln2Display * a2d) { return; } void write_Aln2Display_function(DYNFILE * dfp,Aln2Display * a2d) { write_Aln2Display_convert_func(dfp,a2d); } void write_Aln2Display_convert_func(DYNFILE * dfp,Aln2Display * a2d) { register int i; register int j; register int k; char buffer[MAXLINE]; /*** assume file is already loaded into writec ***/ sprintf(buffer,"AlnDisplay * convert_AlnBlock_to_AlnDisplay_%s(AlnBlock * alb ",a2d->name); for(i=0;ires_len;i++) { strcat(buffer,","); strcat(buffer,a2d->a2dr[i]->type); strcat(buffer,a2d->a2dr[i]->name); } strcat(buffer,")"); start_function(dfp,buffer); expr(dfp,"AlnDisplay * out"); expr(dfp,"AlnDisplayColumn * adc;"); expr(dfp,"AlnDisplayUnit * adu;"); expr(dfp,"AlnDisplayField * adf;"); expr(dfp,"AlnDisplayNameBlock * adnb;"); expr(dfp,"AlnDisplayNameUnit * adnu;"); expr(dfp,"AlnIndexField * aif;"); expr(dfp,"AlnDisplayIndexUnit * adiu;"); expr(dfp,"AlnDisplayIndex * adi;"); expr(dfp,"AlnColumn * alc;"); expr(dfp,"AlnUnit * alu;"); expr(dfp,"char tempbuf[512]"); add_break(dfp); expr(dfp,"out = new_AlnDisplay(alb->len)"); add_break(dfp); for(i=0;ilen;i++) { expr(dfp,"adnb = AlnDisplayNameBlock_no_get(out,%d);",i); expr(dfp,"adnb->direction = ALN_DISPLAY_%s",a2d->s2d[i]->direction); expr(dfp,"adnu = get_next_AlnDisplayNameUnit(adnb);"); if( a2d->s2d[i]->name_str != NULL) { expr(dfp,"adnu->name = %s;",a2d->s2d[i]->name_str); expr(dfp,"adnu->should_free = %s;",a2d->s2d[i]->is_static == TRUE ? "FALSE" : "TRUE"); } else { expr(dfp,"adnu->name = \"NoName\";"); expr(dfp,"adnu->should_free = FALSE;"); } if( a2d->s2d[i]->ind_len > 0 ) { /* get the index */ add_break(dfp); add_block_comment(dfp,"This sequence has got an index, get the alndisplayindex"); expr(dfp,"adi = AlnDisplayIndex_no_get(out,%d);",i); expr(dfp,"adi->direction = ALN_DISPLAY_%s",a2d->s2d[i]->direction); for(j=0;j< a2d->s2d[i]->ind_len;j++) { auto Index2Display * i2d; i2d = a2d->s2d[i]->i2d[j]; expr(dfp,"adiu = get_next_AlnDisplayIndexUnit(adi);"); expr(dfp,"adiu->start = %s",i2d->eval == NULL ? "0" : i2d->eval); add_break(dfp); } } /* end of if index*/ } /* end of for */ expr(dfp,"for(alc = alb->start;alc != NULL;alc = alc->next)"); startbrace_tag(dfp,"all columns in AlnBlock"); expr(dfp,"adc = new_terminal_AlnDisplayColumn(out);"); /*** go over each sequence, and move the labels across ***/ for(i=0;ilen;i++) { j = 0; expr(dfp,"adu = AlnDisplayUnit_no_get(adc,%d)",i); expr(dfp,"alu = alc->alu[%d]",i); /*** start of the labels ***/ for(j=0;js2d[i]->len;j++) { expr(dfp,"%s if(alu->text_label != NULL && strcmp(alu->text_label,\"%s\") == 0) ",j == 0 ? "" : "else",a2d->s2d[i]->l2d[j]->label); startbrace_tag(dfp,"if this label"); /*** add the index if it is there ***/ for(k=0;ks2d[i]->l2d[j]->ind_len;k++) { expr(dfp,"aif = get_next_AlnIndexField(adu)"); expr(dfp,"aif->index_no = %d;",a2d->s2d[i]->l2d[j]->i2d[k]->number); expr(dfp,"aif->length = %s;",a2d->s2d[i]->l2d[j]->i2d[k]->eval); } if(a2d->s2d[i]->l2d[j]->is_lone == TRUE ) { expr(dfp,"adc->is_lone = TRUE;"); } expr(dfp,"adu->direction = ALN_DISPLAY_%s;",a2d->s2d[i]->l2d[j]->direction == NULL ? "DOWN" : a2d->s2d[i]->l2d[j]->direction); for(k=0;ks2d[i]->l2d[j]->len;k++) { auto Aln2DisplayField * a2df; a2df = a2d->s2d[i]->l2d[j]->a2df[k]; expr(dfp,"adf = get_next_AlnDisplayField(adu);"); if( a2df->is_sub == TRUE ) { expr(dfp,"sprintf(tempbuf,\"%%d\",alu->start);"); expr(dfp,"push_scan_and_replace_pair(\"%%START\",tempbuf);"); expr(dfp,"sprintf(tempbuf,\"%%d\",alu->end);"); expr(dfp,"push_scan_and_replace_pair(\"%%END\",tempbuf);"); } if( a2df->is_string == TRUE ) expr(dfp,"adf->characters = \"%s\";",a2df->string); else if( a2df->is_single == TRUE ) expr(dfp,"adf->single = %s;",a2df->string); else if( a2df->is_sub == TRUE) { expr(dfp,"strcpy(tempbuf,\"%s\");",a2df->string); expr(dfp,"adf->characters = stringalloc(scan_and_replace_line(tempbuf))"); expr(dfp,"pop_scan_and_replace_pair();"); expr(dfp,"pop_scan_and_replace_pair();"); } else expr(dfp,"adf->characters = %s",a2df->string); if( a2df->is_sub == TRUE ) expr(dfp,"adf->length = strlen(adf->characters)"); else expr(dfp,"adf->length = %s",a2df->length == NULL ? "1" : a2df->length); expr(dfp,"adf->direction = ALN_DISPLAY_%s",a2df->direction == NULL ? "RIGHT" : a2df->direction); expr(dfp,"adf->should_free = %s",a2df->is_static == TRUE ? "FALSE" : "TRUE"); if( a2df->convert != NULL ) expr(dfp,"adf->convert_func = %s;",a2df->convert); } closebrace(dfp); } expr(dfp,"else "); startbrace(dfp); expr(dfp,"warn(\"In AlnBlock to AlnDisplay %s, got unintretable label [%%s] for sequence %d\",alc->alu[%d]->text_label);",a2d->name,i,i); expr(dfp,"adf = get_next_AlnDisplayField(adu);"); expr(dfp,"adf->characters = \"?\";"); expr(dfp,"adf->length = 1"); expr(dfp,"adf->direction = ALN_DISPLAY_RIGHT"); expr(dfp,"adf->should_free = FALSE"); closebrace(dfp); } closebrace(dfp); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } /*************************/ /* Access/checking func */ /*************************/ boolean prepare_Aln2Display(Aln2Display * a2d) { boolean ret = TRUE; number_up_Sequence_Index2Display(a2d); if( crosslink_Index(a2d) == FALSE ){ warn("Unable to crosslink Display %s: probably you have not got one of the indexes in the sequence block",a2d->name); ret = FALSE; } return ret; } void number_up_Sequence_Index2Display(Aln2Display * a2d) { register int i; register int j; for(i=0;ilen;i++) for(j=0;js2d[i]->ind_len;j++) a2d->s2d[i]->i2d[j]->number = j; } boolean crosslink_Index(Aln2Display * a2d) { register int i; register int j; boolean ret = TRUE; for(i=0;ilen;i++) for(j=0;js2d[i]->len;j++) { if( crosslink_Label2Display_Index(a2d->s2d[i]->l2d[j],a2d->s2d[i]) == FALSE ) ret = FALSE; } return ret; } boolean crosslink_Label2Display_Index(Label2Display * l2d,Sequence2Display * s2d) { register int i; Index2Display * temp; boolean ret = TRUE; for(i=0;iind_len;i++) { temp = Index2Display_from_name(s2d,l2d->i2d[i]->name); if( temp == NULL ) { warn("In Label %s of Sequence number %d, could not crosslink index name %s",l2d->label,s2d->number,l2d->i2d[i]->name); ret = FALSE; } else l2d->i2d[i]->number = temp->number; } return ret; } Index2Display * Index2Display_from_name(Sequence2Display * s2d,char * name) { register int i; for(i=0;iind_len;i++) { if( strcmp(s2d->i2d[i]->name,name) == 0 ) return s2d->i2d[i]; } return NULL; } /**************************/ /* I/O functions */ /**************************/ Aln2Display * read_Aln2Display_line(char * line,FILE * ifp) { Sequence2Display * temp; Aln2DisplayResource * tempres; Aln2Display * out; char buffer[MAXLINE]; char * runner; runner = strtok(line,spacestr); if( runner == NULL ) { warn("In read_Aln2Display_line, got completely blank line!"); return NULL; } if( strcmp(runner,"display") != 0 ) { warn("In read_Aln2Display_line, got non display line... [%s]",line); return NULL; } runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("In read_Sequence2Display_line, got no display name... cannot process!"); return NULL; } out = Aln2Display_alloc_std(); if( out == NULL) return NULL; out->name = stringalloc(runner); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strwhitestartcmp(buffer,"enddisplay",spacestr) == 0 ) break; if( strwhitestartcmp(buffer,"sequence",spacestr) == 0 ) { temp = read_Sequence2Display_line(buffer,ifp); if( temp == NULL ) warn("In display number %d.. got bad sequence",out->name); else add_Aln2Display(out,temp); } else if ( strwhitestartcmp(buffer,"resource",spacestr) == 0 ) { tempres = read_Aln2DisplayResource_line(buffer); if( tempres == NULL ) warn("In display %s.. got bad resource",out->name); else add_res_Aln2Display(out,tempres); } else { warn("In aln2display read.. got uninterpretable line [%s]",buffer); } } return out; } Sequence2Display * read_Sequence2Display_line(char * line,FILE * ifp) { Sequence2Display * out; Label2Display * temp; Index2Display * ind; char buffer[MAXLINE]; char * runner; runner = strtok(line,spacestr); if( runner == NULL ) { warn("In read_Label2Display_line, got completely blank line!"); return NULL; } if( strcmp(runner,"sequence") != 0 ) { warn("In read_Sequecne2Display_line, got non sequence line... [%s]",line); return NULL; } runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("In read_Sequence2Display_line, got no sequence number... cannot process!"); return NULL; } out = Sequence2Display_alloc_std(); if( out == NULL) return NULL; if( strcmp(runner,"ALLOTHERS") == 0) out->number = ALL_OTHER_NUMBER; else out->number = atoi(runner); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strwhitestartcmp(buffer,"endsequence",spacestr) == 0 ) break; else if( strwhitestartcmp(buffer,"name",spacestr) == 0 ) read_name_line(out,buffer); else if( strwhitestartcmp(buffer,"label",spacestr) == 0 ) { temp = read_Label2Display_line(buffer,ifp); if( temp == NULL ) warn("In sequence number %d.. got bad label",out->number); else add_Sequence2Display(out,temp); } else if ( strwhitestartcmp(buffer,"index",spacestr) == 0 ) { ind = read_Index2Display_line(buffer); if( ind == NULL ) warn("In sequence number %d, unable to read Index line ",out->number); else add_ind_Sequence2Display(out,ind); } else { warn("In sequence2display.. got uninterpretable line [%s]",buffer); } } return out; } Label2Display * read_Label2Display_line(char * line,FILE * ifp) { Label2Display * out; Aln2DisplayField * temp; Index2Display * ind; char * runner; char buffer[MAXLINE]; runner = strtok(line,spacestr); if( runner == NULL ) { warn("In read_Label2Display_line, got completely blank line!"); return NULL; } if( strcmp(runner,"label") != 0 ) { warn("In read_Label2Display_line, got non label line... [%s]",line); return NULL; } runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("In read_Label2Display_line, got no label name... cannot process!"); return NULL; } out = Label2Display_alloc_std(); if( out == NULL) return NULL; out->label = stringalloc(runner); runner = strtok(NULL,spacestr); while( runner != NULL ) { if( strcmp(runner,"!lone") == 0 ) { out->is_lone = TRUE; } else { warn("Could not understand label modifier %s",runner); } runner = strtok(NULL,spacestr); } while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strwhitestartcmp(buffer,"endlabel",spacestr) == 0) break; if( strwhitestartcmp(buffer,"field",spacestr) == 0 ) { temp = read_Aln2DisplayField_line(buffer,ifp); if( temp == NULL ) warn("In label %s, unable to read field lines...",out->label); else add_Label2Display(out,temp); } else if( strwhitestartcmp(buffer,"index",spacestr) == 0 ) { ind = read_Index2Display_line(buffer); if( ind == NULL ) warn("In label %s, unable to read Index line ",out->label); else add_ind_Label2Display(out,ind); } else if( strwhitestartcmp(buffer,"direction",spacestr) == 0 ) { runner = strtok(buffer,spacestr); out->direction = string_from_quoted_equality(runner); } else { warn("In reading label [%s], unable to interpret [%s]",out->label,buffer); } } return out; } Aln2DisplayField * read_Aln2DisplayField_line(char * line,FILE * ifp) { Aln2DisplayField * out; char ** base; char ** bkstr; char buffer[MAXLINE]; out = Aln2DisplayField_alloc(); if( out == NULL) return NULL; base = bkstr = breakstring(line,spacestr); for(bkstr++;*bkstr != NULL;bkstr++) { put_away_Aln2DisplayField_strpair(out,*bkstr); } ckfree(base); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '#') continue; if( strwhitestartcmp(buffer,"endfield",spacestr) == 0) break; base = bkstr = breakstring(buffer,spacestr); for(;*bkstr != NULL;bkstr++) { put_away_Aln2DisplayField_strpair(out,*bkstr); } ckfree(base); } return out; } boolean read_name_line(Sequence2Display * s2d,char * name_line) { char ** base; char ** bkstr; if( strwhitestartcmp(name_line,"name",spacestr) != 0 ) { warn("Passed a non name line to read name line... [%s]",name_line); return FALSE; } base = bkstr = breakstring(name_line,spacestr); for(bkstr++;*bkstr != NULL;bkstr++) { if( strstartcmp(*bkstr,"string") == 0 ) { s2d->name_str = string_from_quoted_equality(*bkstr); } else if( strstartcmp(*bkstr,"!static") == 0 ) { s2d->is_static = TRUE; } else if( strstartcmp(*bkstr,"length=") == 0 ) { s2d->length = number_from_quoted_equality(*bkstr); if( s2d->length < 0 || s2d->length > 512 ) { warn("sequence[%d] name length [%d] is ridiculous... setting to 20",s2d->number,s2d->length); s2d->length = 20; } } else if( strstartcmp(*bkstr,"direction=") ==0 ) { s2d->direction = string_from_quoted_equality(*bkstr); } else { warn("In reading sequence name line for sequence number %d, unable to interpret [%s]",s2d->number,*bkstr); } } if( s2d->direction == NULL ) s2d->direction = stringalloc("DOWN"); return TRUE; } boolean put_away_Aln2DisplayField_strpair(Aln2DisplayField * a2df,char * pair) { char buffer[20]; if( strstartcmp(pair,"string=") == 0) { if( a2df->string != NULL) { warn("Already a string or eval state ment in this Aln2DisplayField, overriding %s",a2df->string); ckfree(a2df->string); } a2df->string = string_from_quoted_equality(pair); a2df->is_string = TRUE; sprintf(buffer,"%d",(int)strlen(a2df->string)); a2df->length = stringalloc(buffer); a2df->is_static = TRUE; } else if( strstartcmp(pair,"eval") == 0 ) { if( a2df->string != NULL) { warn("Already a string or eval state ment in this Aln2DisplayField, overriding %s",a2df->string); ckfree(a2df->string); } a2df->string = string_from_quoted_equality(pair); } else if( strstartcmp(pair,"substring") == 0 ) { if( a2df->string != NULL) { warn("Already a string or eval state ment in this Aln2DisplayField, overriding %s",a2df->string); ckfree(a2df->string); } a2df->string = string_from_quoted_equality(pair); a2df->is_sub = TRUE; a2df->is_static = FALSE; } else if( strstartcmp(pair,"length=") == 0 ) { a2df->length = string_from_quoted_equality(pair); } else if( strstartcmp(pair,"direction=") == 0) { a2df->direction = string_from_quoted_equality(pair); } else if( strstartcmp(pair,"convert=") == 0 ) { a2df->convert = string_from_quoted_equality(pair); } else if( strstartcmp(pair,"!static") == 0) { a2df->is_static = TRUE; } else if( strstartcmp(pair,"!single") == 0) { a2df->is_single = TRUE; } else { warn("Unable to interpret [%s] as a valid Aln2DisplayField tag",pair); return FALSE; } return TRUE; } Aln2DisplayResource * read_Aln2DisplayResource_line(char * line) { Aln2DisplayResource * out; char ** base; char ** bkstr; out = Aln2DisplayResource_alloc(); if( out == NULL) return NULL; base = bkstr = breakstring(line,spacestr); for(bkstr++;*bkstr != NULL;bkstr++) { if( strstartcmp(*bkstr,"type=") == 0) { out->type = string_from_quoted_equality(*bkstr); } else if( strstartcmp(*bkstr,"name=") == 0 ) { out->name = string_from_quoted_equality(*bkstr); } else if( strstartcmp(*bkstr,"arg=") == 0) { out->arg = string_from_quoted_equality(*bkstr); } else { warn("Got strange tag [%s] in resource line..., while reading display... ignoring",*bkstr); } } ckfree(base); return out; } Index2Display * read_Index2Display_line(char * line) { Index2Display * out; char ** bkstr; char ** base; if( strwhitestartcmp(line,"index",spacestr) != 0 ) { warn("Tried to read an Index2Display line with no index! Bad news!"); return NULL; } base = bkstr = breakstring(line,spacestr); out = Index2Display_alloc(); if( out == NULL ) return NULL; bkstr++; out->name = stringalloc(*bkstr); for(bkstr++;*bkstr != NULL;bkstr++) { if( strstartcmp(*bkstr,"start") == 0 ) { if( out->eval != NULL ) { warn("you are replacing an index evaluation. Remember that each index can only have one length [or start if in sequence]"); ckfree(out->eval); } out->eval = string_from_quoted_equality(*bkstr); out->is_start = TRUE; } else if( strstartcmp(*bkstr,"length") == 0 ) { if( out->eval != NULL ) { warn("you are replacing an index evaluation. Remember that each index can only have one length [or start if in sequence]"); ckfree(out->eval); } out->eval = string_from_quoted_equality(*bkstr); } else { warn("Found an uninterpretable tag [%s] in index %s",out->name,*bkstr); } } ckfree(base); return out; } void show_Aln2Display(Aln2Display * a2d,FILE * ofp) { register int i; fprintf(ofp,"Display %s\n",a2d->name); for(i=0;ires_len;i++) show_Aln2DisplayResource(a2d->a2dr[i],ofp); for(i=0;ilen;i++) show_Sequence2Display(a2d->s2d[i],ofp); } void show_Aln2DisplayResource(Aln2DisplayResource * a2dr,FILE * ofp) { fprintf(ofp,"Resource [%s] Type [%s] Argument [%s]\n",a2dr->type,a2dr->name,a2dr->arg); } void show_Sequence2Display(Sequence2Display * s2d,FILE * ofp) { register int i; fprintf(ofp,"Sequence %d\n",s2d->number); for(i=0;ilen;i++) show_Label2Display(s2d->l2d[i],ofp); } void show_Label2Display(Label2Display * l2d,FILE * ofp) { register int i; fprintf(ofp,"\tLabel %s\n",l2d->label); for(i=0;ilen;i++) { fprintf(ofp,"\t Field %d",i); show_Aln2DisplayField(l2d->a2df[i],ofp); } } void show_Aln2DisplayField(Aln2DisplayField * a2df,FILE * ofp) { fprintf(ofp," String = [%s], Length [%s], Direction [%s]\n",a2df->string,a2df->length,a2df->direction); } %} wise-2.4.1/src/dyc/method.dy0000644000175000001440000002741207345165740015256 0ustar philippusers %{ #include "wisebase.h" #include "input.h" #include "wisec.h" #define MethodLISTLENGTH 16 #define MethodTypeSetLISTLENGTH 16 enum COMPUGEN_METHOD_MAP { CUGEN_METHOD_UNKNOWN = 78, CUGEN_METHOD_TSEQ, CUGEN_METHOD_WINDEX }; %} struct MethodArg char * type struct Method char * logical char * real char * retstr; MethodArg ** ma !list char * cugen_map int cugen_type !def="CUGEN_METHOD_UNKNOWN" struct Type boolean is_database !def="FALSE" boolean is_thread_safe !def="FALSE" char * logical; char * real; char * database_type; char * get_id_func; char * init_func; char * reload_func; char * close_func; char * dataentry_add; char * maxlen; char * hard_link_func; char * free_func; Input * in; struct MethodTypeSet Method ** me !list !len="me_" Type ** ty !list !len="ty_" Input ** in !list !len="in_" %{ #include "method.h" %func gets a type by its name %type internal %% Type * Type_from_name(MethodTypeSet * mts,char * name) { int i; Type * out = NULL; if( mts == NULL ) { warn("Attempting to get a type name from a null mts. Nope!"); return NULL; } for(i=0;ity_len;i++) { if( strcmp(mts->ty[i]->logical,name) == 0 ) { if( out == NULL ) { out = mts->ty[i]; } else { warn("Multiple definitions for %s - taking the last one\n",name); out = mts->ty[i]; } } } return out; } %func Essentially compares two strings, disregarding white space Not ideal!!! %type internal %% boolean compare_type(char * s,char * t) { for(;*s && isspace(*s);s++) ; for(;*t && isspace(*t);t++) ; for(;*s && *t && *s == *t;) { for(s++;*s && isspace(*s);s++) ; for(t++;*t && isspace(*t);t++) ; } if( *s == '\0' && *t == '\0' ) return TRUE; return FALSE; } %func gets a Method by its name %type internal %% Method * Method_from_name(MethodTypeSet * mts,char * name) { int i; if( mts == NULL) { warn("Attempting to get a method name from a null mts. Nope!"); return NULL; } for(i=0;ime_len;i++) { if( strcmp(mts->me[i]->logical,name) == 0 ) return mts->me[i]; } return NULL; } /*** I/O on methods/types ***/ void show_MethodTypeSet(MethodTypeSet * mts,FILE * ofp) { int i; for(i=0;ime_len;i++) show_Method(mts->me[i],ofp); for(i=0;ity_len;i++) show_Type(mts->ty[i],ofp); } void show_Method(Method * m,FILE * ofp) { int i; fprintf(ofp,"Method [%s] map [%s]\n",m->logical,m->real); for(i=0;ilen;i++) show_MethodArg(m->ma[i],ofp); } void show_MethodArg(MethodArg * ma,FILE * ofp) { fprintf(ofp,"Argument: %s\n",ma->type); } void show_Type(Type * ty,FILE * ofp) { fprintf(ofp,"Type: Logial %s Real %s\n",ty->logical,ty->real); } %func function which handles the logical->real mapping At the moment "unmappable" types get assummed to be C types, trigger a warning and return the correct thing. %% StructElement * StructElement_from_MethodTypeSet(char * name,char * type,MethodTypeSet * mts) { Type * ty; if( (ty = Type_from_name(mts,type)) == NULL ) { warn("Type [%s] is not recognised as a logical Dynamite type. Assumming it is a real C type",type); return StructElement_from_nameandtype(name,type); } return StructElement_from_nameandtype(name,ty->real); } %func an internal for StructElement_from_MethodTypeSet. don't use otherwise please! %type internal %% StructElement * StructElement_from_nameandtype(char * name,char * type) { StructElement * out; out = StructElement_alloc(); out->name = stringalloc(name); out->element_type = stringalloc(type); out->islinked = TRUE; return out; } MethodTypeSet * read_MethodTypeSet_filename(char * filename) { FILE * ifp; MethodTypeSet * mts; ifp=openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open [%s] for MethodTypeSet reading",filename); return FALSE; } mts = read_MethodTypeSet(ifp); fclose(ifp); return mts; } boolean read_into_MethodTypeSet_filename(MethodTypeSet * mts,char * filename) { FILE * ifp; boolean ret; ifp=openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open [%s] for MethodTypeSet reading",filename); return FALSE; } ret = read_into_MethodTypeSet(mts,ifp); fclose(ifp); return ret; } MethodTypeSet * standard_dynamite_MethodTypeSet(void) { MethodTypeSet * mts; Type * temp; mts = empty_MethodTypeSet(); temp = Type_alloc(); temp->logical=stringalloc("int"); temp->real=stringalloc("int"); add_ty_MethodTypeSet(mts,temp); temp = Type_alloc(); temp->logical=stringalloc("double"); temp->real=stringalloc("double"); add_ty_MethodTypeSet(mts,temp); temp = Type_alloc(); temp->logical=stringalloc("Score"); temp->real=stringalloc("Score"); add_ty_MethodTypeSet(mts,temp); return mts; } MethodTypeSet * empty_MethodTypeSet(void) { return MethodTypeSet_alloc_std(); } MethodTypeSet * read_MethodTypeSet(FILE * ifp) { MethodTypeSet * mts; mts = empty_MethodTypeSet(); read_into_MethodTypeSet(mts,ifp); return mts; } boolean read_into_MethodTypeSet(MethodTypeSet * mts,FILE * ifp) { char buffer[MAXLINE]; Method * me; Type * ty; Input * in; while( fgets(buffer,MAXLINE,ifp) != NULL) { chop_newline(buffer); if( buffer[0] == '#' || strwhitestartcmp(buffer,"#",spacestr) == 0 ) continue; if( only_whitespace(buffer,spacestr) == TRUE) continue; if( strstartcmp(buffer,"method") == 0 ) { if( (me=read_Method_line(buffer,ifp)) == NULL ) { warn("Unable to read method in line [%s] ",buffer); } else { add_me_MethodTypeSet(mts,me); } } else if ( strstartcmp(buffer,"type") == 0 ) { if( (ty=read_Type_line(buffer,ifp)) == NULL ) { warn("Unable to read type in line [%s] ",buffer); } else { add_ty_MethodTypeSet(mts,ty); } } else if ( strstartcmp(buffer,"input") == 0 ) { if( (in = read_Input_line(buffer,ifp)) == NULL ) { warn("Unable to read type in line [%s]",buffer); } else { add_in_MethodTypeSet(mts,in); } } else { warn("In reading only method/types got an impossible line [%s]",buffer); } } return TRUE; } boolean is_database_type(Type * ty) { if( ty->database_type == NULL || ty->reload_func == NULL || ty->init_func == NULL || ty->close_func == NULL) return FALSE; return TRUE; } %func reads in a type structure from a line starting type etc %arg line first line with type ifp read file %% Type * read_Type_line(char * line,FILE * ifp) { Type * out; char * temp; char buffer[MAXLINE]; if( strstartcmp(line,"type") != 0 ) { warn("Attempting to read a method with no method line!"); return NULL; } out = Type_alloc(); out->logical = second_word_alloc(line,spacestr); while( fgets(buffer,MAXLINE,ifp) != NULL ) { chop_newline(buffer); if( strstartcmp(buffer,"end") == 0 ) break; else if( strstartcmp(buffer,"real") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->real != NULL ) { warn("For type [%s], second real replacing [%s] with [%s]",out->logical,out->real,temp); ckfree(out->real); } out->real = temp; } else if( strstartcmp(buffer,"threadsafe") == 0 ) { out->is_thread_safe = TRUE; } else if ( strstartcmp(buffer,"dbtype") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->database_type != NULL ) { warn("For type [%s], second database type replacing [%s] with [%s]",out->logical,out->database_type,temp); ckfree(out->database_type); } out->database_type = temp; } else if ( strstartcmp(buffer,"init") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->init_func != NULL ) { warn("For type [%s], second init replacing [%s] with [%s]",out->logical,out->init_func,temp); ckfree(out->init_func); } out->init_func = temp; } else if ( strstartcmp(buffer,"maxlen") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->maxlen != NULL ) { warn("For type [%s], second maxlen replacing [%s] with [%s]",out->logical,out->maxlen,temp); ckfree(out->maxlen); } out->maxlen = temp; } else if ( strstartcmp(buffer,"reload") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->reload_func != NULL ) { warn("For type [%s], second reload function replacing [%s] with [%s]",out->logical,out->reload_func,temp); ckfree(out->reload_func); } out->reload_func = temp; } else if ( strstartcmp(buffer,"addentry") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->dataentry_add != NULL ) { warn("For type [%s], second dataentry_add function replacing [%s] with [%s]",out->logical,out->dataentry_add,temp); ckfree(out->dataentry_add); } out->dataentry_add = temp; } else if ( strstartcmp(buffer,"close") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->close_func != NULL ) { warn("For type [%s], second close func replacing [%s] with [%s]",out->logical,out->close_func,temp); ckfree(out->close_func); } out->close_func = temp; } else if ( strstartcmp(buffer,"hardlink") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->hard_link_func != NULL ) { warn("For type [%s], second hard_link func replacing [%s] with [%s]",out->logical,out->hard_link_func,temp); ckfree(out->hard_link_func); } out->hard_link_func = temp; } else if ( strstartcmp(buffer,"free") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->free_func != NULL ) { warn("For type [%s], second free func replacing [%s] with [%s]",out->logical,out->free_func,temp); ckfree(out->free_func); } out->free_func = temp; } else if ( strstartcmp(buffer,"name") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->get_id_func != NULL ) { warn("For type [%s], second get name func replacing [%s] with [%s]",out->logical,out->get_id_func,temp); ckfree(out->get_id_func); } out->get_id_func = temp; } else { warn("In reading type [%s] did not understand [%s]",out->logical,buffer); } } if( out->is_thread_safe == TRUE ) { if( out->hard_link_func == NULL || out->free_func == NULL ) { warn("Trying to make type %s threadsafe but have not supplied hardlink and free functions",out->logical); out->is_thread_safe = FALSE; } } out->is_database = is_database_type(out); return out; } Method * read_Method_line(char * line,FILE * ifp) { Method * out; char buffer[MAXLINE]; char * temp; MethodArg * m; if( strstartcmp(line,"method") != 0 ) { warn("Attempting to read a method with no method line!"); return NULL; } out = Method_alloc_std(); out->logical = second_word_alloc(line,spacestr); while( fgets(buffer,MAXLINE,ifp) != NULL ) { chop_newline(buffer); if( strstartcmp(buffer,"end") == 0 ) break; else if( strstartcmp(buffer,"map") == 0 ) { temp = second_word_alloc(buffer,spacestr); if( out->real != NULL ) { warn("For method [%s], second map replacing [%s] with [%s]",out->logical,out->real,temp); ckfree(out->real); } out->real = temp; } else if ( strstartcmp(buffer,"arg") == 0 ) { m = MethodArg_from_line(buffer); if( m == NULL ) { warn("Got a NULL method arg. Yikes!"); } else { add_Method(out,m); } } else if ( strstartcmp(buffer,"return") == 0 ) { out->retstr = second_word_alloc(buffer,spacestr); } else { warn("In method [%s] did not understand %s",out->logical,buffer); } } return out; } %func reads in from line like arg PROTEIN %arg line pointer to buffer %% MethodArg * MethodArg_from_line(char * line) { MethodArg * out; if( strstartcmp(line,"arg") != 0 ) { warn("Attempting to read a method argument with no arg line!"); return NULL; } out = MethodArg_alloc(); out->type = second_word_alloc(line,spacestr); return out; } %}wise-2.4.1/src/dyc/dynfile.c0000644000175000001440000007713410670453715015241 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dynfile.h" #include "linesubs.h" /* Function: make_pdoc_output(dfp,mod_name,ofp) * * Descrip: makes a pdoc for this file. * * * * Arg: dfp [UNKN ] DYNFILE object [DYNFILE *] * Arg: mod_name [UNKN ] Undocumented argument [char *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 56 "dynfile.dy" boolean make_pdoc_output(DYNFILE * dfp,char * mod_name,FILE * ofp) { /*int i;*/ /*** first thing is to add the module name as a link to this file ***/ fprintf(ofp,"&%s\n",mod_name); /*** at the moment we don't handle module info ***/ /*** ok - now write out a head-list for functions ***/ return TRUE; } /* Function: have_got_unknown_func_DYNFILE(dfp,no,should_complain) * * Descrip: reports back whether there are any undocumented * file. if should_complain is TRUE, will issue * warnings through warn. Writes the number of * undocumented functions into no * * * Arg: dfp [UNKN ] DYNFILE object [DYNFILE *] * Arg: no [WRITE] pointer to some memory for the number of undoc'd funcs [int *] * Arg: should_complain [UNKN ] if TRUE, will issue warn statements [boolean] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 82 "dynfile.dy" boolean have_got_unknown_func_DYNFILE(DYNFILE * dfp,int * no,boolean should_complain) { int i; boolean ret = FALSE; *no =0; for(i=0;ilen;i++) if( dfp->info[i]->functype == FI_UNKNOWN) { ret = TRUE; (*no)++; if( should_complain == TRUE) { warn("You have not documented %s",dfp->info[i]->name); } } return ret; } /* Function: write_Dynamite_minimal_func(dfp) * * Descrip: writes basically just the #include "self.h" line * in the dynamite file * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * */ # line 106 "dynfile.dy" void write_Dynamite_minimal_func(DYNFILE * dfp) { fprintf(dfp->func,"#include \"%s.h\"\n\n",dfp->sourceroot); dfp->funcpos+=2; return; } /* Function: FuncInfo_from_name_DYNFILE(dfp,name) * * Descrip: Finds a funcinfo with name. returns NULL * if it cant find them * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [FuncInfo *] * */ # line 118 "dynfile.dy" FuncInfo * FuncInfo_from_name_DYNFILE(DYNFILE * dfp,char * name) { int i; for(i=0;ilen;i++) if( strcmp(dfp->info[i]->name,name) == 0 ) return dfp->info[i]; return NULL; } /* Function: show_html_DYNFILE(dfp,ofp,type) * * Descrip: Deprecated - use pdoc * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * Arg: type [UNKN ] Undocumented argument [FuncOrderType] * */ # line 133 "dynfile.dy" void show_html_DYNFILE(DYNFILE * dfp,FILE * ofp,FuncOrderType type) { int i; sort_DYNFILE_FuncOrderType(dfp,type); if( is_separated_types(type) == TRUE) { fprintf(ofp,"Externally called functions functions\n
    "); for(i=0;ilen;i++) { if( dfp->info[i]->functype != FI_CALLABLE) { break; } fprintf(ofp,"
  • %s \n",dfp->info[i]->name,dfp->info[i]->complete_name); } fprintf(ofp,"

Unplaced (no information about calling) functions\n

    "); for(;ilen;i++) { if( dfp->info[i]->functype != FI_UNKNOWN) { break; } fprintf(ofp,"
  • %s \n",dfp->info[i]->name,dfp->info[i]->complete_name); } fprintf(ofp,"

Internal (unlikely to be called directly) functions\n

    "); for(;ilen;i++) { fprintf(ofp,"
  • %s \n",dfp->info[i]->name,dfp->info[i]->complete_name); } fprintf(ofp,"

Externally called functions

\n"); for(i=0;ilen;i++) { if( dfp->info[i]->functype != FI_CALLABLE) { break; } fprintf(ofp," %s

Description

\n",dfp->info[i]->name,dfp->info[i]->complete_name);
      dump_Ftext(dfp->info[i]->ft,ofp);
      fprintf(ofp,"
\n"); } fprintf(ofp,"
Unplaced functions

\n"); for(;ilen;i++) { if( dfp->info[i]->functype != FI_UNKNOWN) { break; } fprintf(ofp," %s

Description

\n",dfp->info[i]->name,dfp->info[i]->complete_name);
      dump_Ftext(dfp->info[i]->ft,ofp);
      fprintf(ofp,"
\n"); } fprintf(ofp,"
Internal functions

\n"); for(;ilen;i++) { fprintf(ofp," %s

Description

\n",dfp->info[i]->name,dfp->info[i]->complete_name);
      dump_Ftext(dfp->info[i]->ft,ofp);
      fprintf(ofp,"
\n"); } } else { warn("Can't currently handle no CUI sorted Html functions, yikes"); } } /* Function: place_func_decl(dfp,fi) * * Descrip: Places the function declaration potential with * package protection * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: fi [UNKN ] Undocumented argument [FuncInfo *] * * Return [UNKN ] Undocumented return value [int] * */ # line 196 "dynfile.dy" int place_func_decl(DYNFILE * dfp,FuncInfo * fi) { fprintf(dfp->head,"%s ",fi->ret->type); fprintf(dfp->head,"%s%s;\n",dfp->package_name == NULL ? "" : dfp->package_name,fi->stripped_return); if( dfp->package_name != NULL ) { fprintf(dfp->head,"#define %s %s%s\n",fi->name,dfp->package_name,fi->name); return 2; } else { return 1; } } /* Function: place_declarations_DYNFILE(dfp,type) * * Descrip: writes the header declarations of functions * into the header file, with documentation. * * The FuncOrderType is either the more common, * usual order or alphabetical * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: type [UNKN ] Undocumented argument [FuncOrderType] * */ # line 219 "dynfile.dy" void place_declarations_DYNFILE(DYNFILE * dfp,FuncOrderType type) { int i; sort_DYNFILE_FuncOrderType(dfp,type); if( is_separated_types(type) == TRUE) { fprintf(dfp->head,"\n\n /***************************************************/\n"); fprintf(dfp->head, " /* Callable functions */\n"); fprintf(dfp->head, " /* These are the functions you are expected to use */\n"); fprintf(dfp->head, " /***************************************************/\n\n"); for(i=0;ilen;i++) { if( dfp->info[i]->functype != FI_CALLABLE) { break; } fprintf(dfp->head,"\n\n"); show_eddystyle_FuncInfo(dfp->info[i],dfp->head); place_func_decl(dfp,dfp->info[i]); } fprintf(dfp->head,"\n\n /* Unplaced functions */\n"); fprintf(dfp->head," /* There has been no indication of the use of these functions */\n"); for(;ilen;i++) { if( dfp->info[i]->functype != FI_UNKNOWN) { break; } place_func_decl(dfp,dfp->info[i]); } fprintf(dfp->head,"\n\n /***************************************************/\n"); fprintf(dfp->head, " /* Internal functions */\n"); fprintf(dfp->head, " /* you are not expected to have to call these */\n"); fprintf(dfp->head, " /***************************************************/\n"); for(;ilen;i++) { place_func_decl(dfp,dfp->info[i]); } } /*** not separated types ***/ else { for(i=0;ilen;i++) { fprintf(dfp->head,"\n\n"); show_eddystyle_FuncInfo(dfp->info[i],dfp->head); place_func_decl(dfp,dfp->info[i]); } } } /* Function: sort_DYNFILE_FuncOrderType(dfp,type) * * Descrip: really a sub-routine. Sorts by the FuncOrderType * which can be alphabetical or by original position * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: type [UNKN ] Undocumented argument [FuncOrderType] * */ # line 279 "dynfile.dy" void sort_DYNFILE_FuncOrderType(DYNFILE * dfp,FuncOrderType type) { switch (type) { case FO_CUI_ALPHABETICAL : sort_DYNFILE(dfp,compare_two_FuncInfo_alpha); break; case FO_CUI_POSITION : sort_DYNFILE(dfp,compare_two_FuncInfo_pos); break; default : warn("Got an unnw FuncOrderType %d",type); } return; } /* Function: is_separated_types(type) * * Descrip: Tells whether this sorting will separate * things into Callable/unknown/internal. All * sorts currently do * * * Arg: type [UNKN ] Undocumented argument [FuncOrderType] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 303 "dynfile.dy" boolean is_separated_types(FuncOrderType type) { if( type == FO_CUI_ALPHABETICAL || type == FO_CUI_POSITION) return TRUE; return FALSE; } /* Function: compare_two_FuncInfo_alpha(one,two) * * Descrip: comparison function for sorting by functype then alphabetical * * * Arg: one [UNKN ] Undocumented argument [FuncInfo *] * Arg: two [UNKN ] Undocumented argument [FuncInfo *] * * Return [UNKN ] Undocumented return value [int] * */ # line 314 "dynfile.dy" int compare_two_FuncInfo_alpha(FuncInfo * one,FuncInfo * two) { if( one->functype != two->functype ) { return one->functype - two->functype; } return strcmp(one->name,two->name); } /* Function: compare_two_FuncInfo_pos(one,two) * * Descrip: comparison function for sorting by functype then by file position * * * Arg: one [UNKN ] Undocumented argument [FuncInfo *] * Arg: two [UNKN ] Undocumented argument [FuncInfo *] * * Return [UNKN ] Undocumented return value [int] * */ # line 327 "dynfile.dy" int compare_two_FuncInfo_pos(FuncInfo * one,FuncInfo * two) { if( one->functype != two->functype ) { return one->functype - two->functype; } return one->infopos - two->infopos; } /* Function: positionify_DYNFILE(dfp) * * Descrip: places the positions of functions as read in the file * (hopefully) into the funcinfos so can be sorted on * them (and rearranged potentially) * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * */ # line 340 "dynfile.dy" void positionify_DYNFILE(DYNFILE * dfp) { int i; for(i=0;ilen;i++) dfp->info[i]->infopos = i; } # line 349 "dynfile.dy" void show_FuncInfo_DYNFILE(DYNFILE * dfp,FuncInfo * fi) { switch (dfp->desc_type) { case DYN_DESC_EDDY : dfp->funcpos += show_eddystyle_FuncInfo(fi,dfp->func); break; default : warn("No func descirption like %d",dfp->desc_type); break; } } /** FuncInfo * find_FuncInfo_from_name_end(DYNFILE * dfp,char * name) { int i; for(i=dfp->len-1;i >= 0;i--) if( strcmp(dfp->info[i]->name,name) == 0 ) return dfp->info[i]; return NULL; } **/ /*** really for output ***/ /* Function: strinopen(target,probe) * * Descrip: complex function, better written with * regex's. Tests whether the probe is actually * a in a "open" string, ie. complete string * outside of " or other things. * * this is mainly for use of finding if's and for's * in C statements * * it is a horrible kludge, and hopefully now not used * * * Arg: target [UNKN ] Undocumented argument [char *] * Arg: probe [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 390 "dynfile.dy" char * strinopen(char * target,char * probe) { register char * p; register char * t; register char * start; start = target; for(;*target;target++) { if( *target == '"') { for(target++;*target && *target != '"';target++) ; if( *target != '"' ) break; target++; } if( *target == *probe ) { if( target != start ) if( isalpha(*(target-1)) ) continue; for(p=probe,t=target;*p && *t;p++,t++) if( *p != *t ) break; if( isalpha(*(t)) ) continue; if( *p == '\0') return target; } } return NULL; } # line 428 "dynfile.dy" boolean real_is_unfinished_expression(char * str) { char * runner; runner = str+strlen(str)-1; while( isspace(*runner) && runner >= str ) runner--; if( runner == str) return FALSE; if( strinopen(str,"if") != NULL || strinopen(str,"for") != NULL || strinopen(str,"while") != NULL || strinopen(str,"switch") != NULL || strinopen(str,"case") != NULL || strinopen(str,"default") ) return FALSE; if( *str == '#' ) return FALSE; if( *runner == ';') return FALSE; if( (runner=strinopen(str,"else")) != NULL) { for(;isalpha(*runner) && *runner;runner++) ; for(;!isalnum(*runner) && *runner;runner++) ; if( *runner == '\0') return FALSE; else return TRUE; } return TRUE; } # line 464 "dynfile.dy" void flush_line(DYNFILE * dfp) { register char * temp; if( *dfp->line != '\0') { temp = scan_and_replace_line(dfp->line); fprintf(dfp->func,"%s \n",temp); strcpy(dfp->line,""); dfp->funcpos++; } } # line 476 "dynfile.dy" void flush_line_to_header(DYNFILE * dfp) { register char * temp; if( *dfp->line != '\0') { temp = scan_and_replace_line(dfp->line); fprintf(dfp->head,"%s \n",temp); strcpy(dfp->line,""); } } /*** this function is going to "pad" the line with spaces to the next comment block level ***/ # line 492 "dynfile.dy" void pad_line(DYNFILE * dfp) { register int i; int len; int nlen; if(dfp->commentstart == 0 || strlen(dfp->line)+1 > dfp->commentstart) { /** ok, have to find the new level **/ len = strlen(dfp->line); nlen = len + (len%4 == 0 ? 0 : 4-len%4); for(i=len;iline[i] = ' '; dfp->line[i]='\0'; } else { for(i=strlen(dfp->line);icommentstart;i++) dfp->line[i] = ' '; dfp->line[i]='\0'; } } /** puts in a double break **/ # line 515 "dynfile.dy" void add_break(DYNFILE * dfp) { flush_line(dfp); fprintf(dfp->func,"\n\n"); dfp->commentstart=0; dfp->funcpos+=2; } # line 526 "dynfile.dy" void start_function(DYNFILE * dfp,char * str, ...) { FuncInfo * fi; char buffer[MAXLINE]; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); /** we have no FuncInfo - make a dummy! **/ fi = FuncInfo_from_str("Undocumented function from internal dynamite code"); start_function_FuncInfo(fi,dfp,buffer); } # line 544 "dynfile.dy" void start_function_FuncInfo(FuncInfo * fi,DYNFILE * dfp,char * str, ... ) { char buffer[MAXLINE]; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); if( reconcile_FuncInfo_with_funcstr(fi,buffer) == FALSE ) { warn("Internal error with function [%s]: Not reconciled with documentation"); add_break_to_Ftext(fi->ft); add_line_to_Ftext(fi->ft,"WARNING: This function's internal documentation was not reconciled with its argument list"); } show_FuncInfo_DYNFILE(dfp,fi); fi->line_in_c = dfp->funcpos; fi->complete_name = stringalloc(buffer); add_DYNFILE(dfp,fi); true_start_function(dfp,buffer); } # line 568 "dynfile.dy" void true_start_function(DYNFILE * dfp,char * str, ... ) { va_list ap; register int i; /** put away whatever was there before **/ flush_line(dfp); for(i=0;i<128;i++) dfp->tag[i]=NULL; va_start(ap,str); vsprintf(dfp->line,str,ap); va_end(ap); if( dfp->bracelevel > 0 ) { warn("In dynfile... you are attempting to start a function [%s] inside a separate brace syste. Bad bad news!",dfp->line); } flush_line(dfp); /*** start function ***/ fprintf(dfp->func,"{\n"); dfp->funcpos++; dfp->bracelevel++; dfp->infunc = TRUE; return; } # line 603 "dynfile.dy" void close_function(DYNFILE * dfp) { if( dfp->infunc == FALSE ){ warn("Attempting to close a function when you are not even in one... problem surely!"); } flush_line(dfp); dfp->bracelevel--; strcpy(dfp->line,"} "); dfp->commentstart=0; pad_line(dfp); } # line 620 "dynfile.dy" void hang_expr(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line(dfp); dfp->bracelevel++; current_indent(dfp); dfp->bracelevel--; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); strcat(dfp->line,buffer); if( real_is_unfinished_expression(buffer) ) strcat(dfp->line,"; "); pad_line(dfp); } # line 642 "dynfile.dy" void expr(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line(dfp); current_indent(dfp); va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); strcat(dfp->line,buffer); if( real_is_unfinished_expression(buffer) ) strcat(dfp->line,"; "); pad_line(dfp); } # line 663 "dynfile.dy" void macro(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line(dfp); va_start(ap,str); vsprintf(buffer,str,ap); if(buffer[0] != '#') warn("asking for macro without # as first letter"); /** no ident! **/ strcat(dfp->line,buffer); pad_line(dfp); } # line 684 "dynfile.dy" void warn_expr(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; char buf2[MAXLINE]; va_list ap; flush_line(dfp); current_indent(dfp); va_start(ap,str); vsprintf(buffer,str,ap); sprintf(buf2,"warn(\"%s\");",buffer); strcat(dfp->line,buf2); pad_line(dfp); } # line 707 "dynfile.dy" void start_struct(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line_to_header(dfp); va_start(ap,str); vsprintf(buffer,str,ap); strcat(dfp->line,buffer); strcat(dfp->line," { "); flush_line_to_header(dfp); dfp->bracelevel=1; } # line 727 "dynfile.dy" void close_struct(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line_to_header(dfp); va_start(ap,str); vsprintf(buffer,str,ap); current_indent(dfp); strcat(dfp->line,"} "); strcat(dfp->line,buffer); pad_line(dfp); dfp->bracelevel--; flush_line_to_header(dfp); } # line 750 "dynfile.dy" void struct_macro(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line_to_header(dfp); va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); strcat(dfp->line,buffer); pad_line(dfp); } # line 765 "dynfile.dy" void struct_expr(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line_to_header(dfp); current_indent(dfp); va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); strcat(dfp->line,buffer); if( real_is_unfinished_expression(buffer) ) strcat(dfp->line,"; "); pad_line(dfp); } /*** Comments ***/ # line 790 "dynfile.dy" void add_block_comment(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; flush_line(dfp); va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); current_indent(dfp); strcat(dfp->line,"/* "); strcat(dfp->line,buffer); strcat(dfp->line," */"); dfp->commentstart=0; } # line 811 "dynfile.dy" void add_end_comment(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); strcat(dfp->line,"/* "); strcat(dfp->line,buffer); strcat(dfp->line," */"); flush_line(dfp); } # line 828 "dynfile.dy" void add_end_comment_header(DYNFILE * dfp,char * str, ...) { char buffer[MAXLINE]; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); strcat(dfp->line,"/* "); strcat(dfp->line,buffer); strcat(dfp->line," */"); flush_line_to_header(dfp); } # line 846 "dynfile.dy" void set_commentstart(DYNFILE * dfp,int s) { dfp->commentstart=s; } # line 853 "dynfile.dy" void current_indent(DYNFILE * dfp) { register int i; dfp->line[0] = '\0'; if( dfp->bracelevel == 0) return; strcat(dfp->line," "); for(i=0;ibracelevel;i++ ){ strcat(dfp->line," "); } } # line 869 "dynfile.dy" void startcase(DYNFILE * dfp) { flush_line(dfp); dfp->bracelevel++; } # line 875 "dynfile.dy" void closecase(DYNFILE * dfp) { flush_line(dfp); dfp->bracelevel--; } # line 884 "dynfile.dy" void startbrace_tag(DYNFILE * dfp,char * str) { strcat(dfp->line," { "); dfp->bracelevel++; strcat(dfp->line,"/*"); strcat(dfp->line,str); strcat(dfp->line,"*/"); flush_line(dfp); if( dfp->tag[dfp->bracelevel] != NULL) { warn("Missalgined tags in tag brace. Bad bad bug"); dfp->tag[dfp->bracelevel] = NULL; } dfp->tag[dfp->bracelevel]=stringalloc(str); } # line 901 "dynfile.dy" void startbrace(DYNFILE * dfp) { strcat(dfp->line," { "); flush_line(dfp); dfp->bracelevel++; } # line 908 "dynfile.dy" void closebrace(DYNFILE * dfp) { flush_line(dfp); current_indent(dfp); strcat(dfp->line,"} "); if( dfp->tag[dfp->bracelevel] != NULL) { add_end_comment(dfp,"end of %s",dfp->tag[dfp->bracelevel]); dfp->tag[dfp->bracelevel]=ckfree(dfp->tag[dfp->bracelevel]); } flush_line(dfp); dfp->bracelevel--; dfp->commentstart=0; } # line 924 "dynfile.dy" void fputs_func_DYNFILE(char * str,DYNFILE * dfp) { fputs(str,dfp->func); fputc('\n',dfp->func); dfp->funcpos++; } /** I/O stuff **/ # line 935 "dynfile.dy" DYNFILE * open_std_no_html_dynfile(char * name) { return open_std_dynfile(name,NULL); } # line 940 "dynfile.dy" DYNFILE * open_std_dynfile(char * name,char * html_directory) { DYNFILE * dfp; char func_buf[512]; char head_buf[512]; char html_buf[1024]; int len; if( (len=strlen(name)) > 509 ) { warn("I can't believe this, but you are attempting to open a DYNFILE with a name longer than 509 letter. Surely not! [%s]",name); return NULL; } if( html_directory != NULL && strlen(html_directory) + len > 1020 ) { warn("I can't believe this, but a combination of the html directory path and the dynamite name is over 1020 letters. Can't handle it [%s][%s]",html_directory,name); return NULL; } sprintf(func_buf,"%s.c",name); sprintf(head_buf,"%s.h",name); if( html_directory != NULL ) sprintf(html_buf,"%s/%s.html",html_directory,name); dfp = DYNFILE_alloc_std(); dfp->func = openfile(func_buf,"W"); if( dfp->func == NULL ) { close_dynfile(dfp); warn("Could not open %s as a function file",func_buf); return NULL; } dfp->head = openfile(head_buf,"W"); if( dfp->head == NULL ) { close_dynfile(dfp); warn("Could not open %s as a header file",head_buf); return NULL; } if( html_directory != NULL ) { dfp->html = openfile(html_buf,"W"); if( dfp->html == NULL ) { close_dynfile(dfp); warn("Could not open %s as a html file",html_buf); return NULL; } } /*** put in "standard" headers etc ****/ fprintf(dfp->head,"#ifndef DYNAMITE%sHEADERFILE\n#define DYNAMITE%sHEADERFILE\n",name,name); fprintf(dfp->head,"#ifdef _cplusplus\nextern \"C\" {\n#endif\n"); fprintf(dfp->func,"#ifdef _cplusplus\nextern \"C\" {\n#endif\n"); dfp->sourceroot = stringalloc(name); /*** put in standard header ***/ dfp->funcpos = 3; /* function file on its 3rd line */ return dfp; } # line 1008 "dynfile.dy" void close_dynfile(DYNFILE * dfp) { /*** finish C function file ***/ flush_line(dfp); /*** finish C header file ***/ fprintf(dfp->func,"\n#ifdef _cplusplus\n}\n#endif\n"); fprintf(dfp->head,"\n#ifdef _cplusplus\n}\n#endif\n"); fprintf(dfp->head,"\n#endif\n"); if( dfp->html != NULL) fclose(dfp->html); if( dfp->head != NULL) fclose(dfp->head); if( dfp->func != NULL) fclose(dfp->func); dfp = free_DYNFILE(dfp); } # line 1095 "dynfile.c" /* Function: swap_DYNFILE(list,i,j) * * Descrip: swap function: an internal for qsort_DYNFILE * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [FuncInfo **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_DYNFILE(FuncInfo ** list,int i,int j) { FuncInfo * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_DYNFILE(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_DYNFILE which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [FuncInfo **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_DYNFILE(FuncInfo ** list,int left,int right,int (*comp)(FuncInfo * ,FuncInfo * )) { int i,last; if( left >= right ) return; swap_DYNFILE(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_DYNFILE (list,++last,i); } swap_DYNFILE (list,left,last); qsort_DYNFILE(list,left,last-1,comp); qsort_DYNFILE(list,last+1,right,comp); } /* Function: sort_DYNFILE(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_DYNFILE * * * Arg: obj [UNKN ] Object containing list [DYNFILE *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_DYNFILE(DYNFILE * obj,int (*comp)(FuncInfo *, FuncInfo *)) { qsort_DYNFILE(obj->info,0,obj->len-1,comp); return; } /* Function: expand_DYNFILE(obj,len) * * Descrip: Really an internal function for add_DYNFILE * * * Arg: obj [UNKN ] Object which contains the list [DYNFILE *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_DYNFILE(DYNFILE * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_DYNFILE called with no need"); return TRUE; } if( (obj->info = (FuncInfo ** ) ckrealloc (obj->info,sizeof(FuncInfo *)*len)) == NULL) { warn("ckrealloc failed for expand_DYNFILE, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_DYNFILE(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DYNFILE *] * Arg: add [OWNER] Object to add to the list [FuncInfo *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_DYNFILE(DYNFILE * obj,FuncInfo * add) { if( obj->len >= obj->maxlen) { if( expand_DYNFILE(obj,obj->len + DYNFILELISTLENGTH) == FALSE) return FALSE; } obj->info[obj->len++]=add; return TRUE; } /* Function: flush_DYNFILE(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DYNFILE *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_DYNFILE(DYNFILE * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->info[i] != NULL) { free_FuncInfo(obj->info[i]); obj->info[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: DYNFILE_alloc_std(void) * * Descrip: Equivalent to DYNFILE_alloc_len(DYNFILELISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DYNFILE *] * */ DYNFILE * DYNFILE_alloc_std(void) { return DYNFILE_alloc_len(DYNFILELISTLENGTH); } /* Function: DYNFILE_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DYNFILE *] * */ DYNFILE * DYNFILE_alloc_len(int len) { DYNFILE * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = DYNFILE_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->info = (FuncInfo ** ) ckcalloc (len,sizeof(FuncInfo *))) == NULL) { warn("Warning, ckcalloc failed in DYNFILE_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_DYNFILE(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DYNFILE *] * * Return [UNKN ] Undocumented return value [DYNFILE *] * */ DYNFILE * hard_link_DYNFILE(DYNFILE * obj) { if( obj == NULL ) { warn("Trying to hard link to a DYNFILE object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DYNFILE_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DYNFILE *] * */ DYNFILE * DYNFILE_alloc(void) { DYNFILE * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DYNFILE *) ckalloc (sizeof(DYNFILE))) == NULL) { warn("DYNFILE_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->desc_type = DYN_DESC_EDDY; /* line[1024] is an array: no default possible */ out->commentstart = 0; out->bracelevel = 0; out->infunc = FALSE; out->sourceroot = NULL; out->info = NULL; out->len = out->maxlen = 0; out->mi = NULL; out->funcpos = 0; out->code_debug_level = 0; out->should_hard_link = FALSE; out->package_name = NULL; return out; } /* Function: free_DYNFILE(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DYNFILE *] * * Return [UNKN ] Undocumented return value [DYNFILE *] * */ DYNFILE * free_DYNFILE(DYNFILE * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DYNFILE obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->*tag[128] is linked in */ if( obj->sourceroot != NULL) ckfree(obj->sourceroot); /* obj->func is linked in */ /* obj->head is linked in */ /* obj->html is linked in */ if( obj->info != NULL) { for(i=0;ilen;i++) { if( obj->info[i] != NULL) free_FuncInfo(obj->info[i]); } ckfree(obj->info); } if( obj->mi != NULL) free_ModuleInfo(obj->mi); if( obj->package_name != NULL) ckfree(obj->package_name); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/dynfile.h0000644000175000001440000002064710670453715015243 0ustar philippusers#ifndef DYNAMITEdynfileHEADERFILE #define DYNAMITEdynfileHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "funcinfo.h" #include "inputfile.h" #define DYNFILELISTLENGTH 1024 enum desctype { DYN_DESC_EDDY = 56 }; typedef int FuncOrderType; enum fotype { FO_CUI_ALPHABETICAL = 83, FO_CUI_POSITION }; struct DYNFILE { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int desc_type; char line[1024]; char *tag[128]; int commentstart; int bracelevel; boolean infunc; char * sourceroot; FILE * func; FILE * head; FILE * html; FuncInfo ** info; int len;/* len for above info */ int maxlen; /* maxlen for above info */ ModuleInfo * mi; int funcpos; int code_debug_level; boolean should_hard_link; char * package_name; } ; /* DYNFILE defined */ #ifndef DYNAMITE_DEFINED_DYNFILE typedef struct DYNFILE DYNFILE; #define DYNAMITE_DEFINED_DYNFILE #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: make_pdoc_output(dfp,mod_name,ofp) * * Descrip: makes a pdoc for this file. * * * * Arg: dfp [UNKN ] DYNFILE object [DYNFILE *] * Arg: mod_name [UNKN ] Undocumented argument [char *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean make_pdoc_output(DYNFILE * dfp,char * mod_name,FILE * ofp); /* Function: have_got_unknown_func_DYNFILE(dfp,no,should_complain) * * Descrip: reports back whether there are any undocumented * file. if should_complain is TRUE, will issue * warnings through warn. Writes the number of * undocumented functions into no * * * Arg: dfp [UNKN ] DYNFILE object [DYNFILE *] * Arg: no [WRITE] pointer to some memory for the number of undoc'd funcs [int *] * Arg: should_complain [UNKN ] if TRUE, will issue warn statements [boolean] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean have_got_unknown_func_DYNFILE(DYNFILE * dfp,int * no,boolean should_complain); /* Function: write_Dynamite_minimal_func(dfp) * * Descrip: writes basically just the #include "self.h" line * in the dynamite file * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * */ void write_Dynamite_minimal_func(DYNFILE * dfp); /* Function: FuncInfo_from_name_DYNFILE(dfp,name) * * Descrip: Finds a funcinfo with name. returns NULL * if it cant find them * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [FuncInfo *] * */ FuncInfo * FuncInfo_from_name_DYNFILE(DYNFILE * dfp,char * name); /* Function: place_declarations_DYNFILE(dfp,type) * * Descrip: writes the header declarations of functions * into the header file, with documentation. * * The FuncOrderType is either the more common, * usual order or alphabetical * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * Arg: type [UNKN ] Undocumented argument [FuncOrderType] * */ void place_declarations_DYNFILE(DYNFILE * dfp,FuncOrderType type); /* Function: positionify_DYNFILE(dfp) * * Descrip: places the positions of functions as read in the file * (hopefully) into the funcinfos so can be sorted on * them (and rearranged potentially) * * * Arg: dfp [UNKN ] Undocumented argument [DYNFILE *] * */ void positionify_DYNFILE(DYNFILE * dfp); /* Function: add_DYNFILE(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DYNFILE *] * Arg: add [OWNER] Object to add to the list [FuncInfo *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_DYNFILE(DYNFILE * obj,FuncInfo * add); /* Function: flush_DYNFILE(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DYNFILE *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_DYNFILE(DYNFILE * obj); /* Function: DYNFILE_alloc_std(void) * * Descrip: Equivalent to DYNFILE_alloc_len(DYNFILELISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DYNFILE *] * */ DYNFILE * DYNFILE_alloc_std(void); /* Function: DYNFILE_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DYNFILE *] * */ DYNFILE * DYNFILE_alloc_len(int len); /* Function: hard_link_DYNFILE(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DYNFILE *] * * Return [UNKN ] Undocumented return value [DYNFILE *] * */ DYNFILE * hard_link_DYNFILE(DYNFILE * obj); /* Function: DYNFILE_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DYNFILE *] * */ DYNFILE * DYNFILE_alloc(void); /* Function: free_DYNFILE(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DYNFILE *] * * Return [UNKN ] Undocumented return value [DYNFILE *] * */ DYNFILE * free_DYNFILE(DYNFILE * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ void show_FuncInfo_DYNFILE(DYNFILE * dfp,FuncInfo * fi); boolean real_is_unfinished_expression(char * str); void flush_line(DYNFILE * dfp); void flush_line_to_header(DYNFILE * dfp); void pad_line(DYNFILE * dfp); void add_break(DYNFILE * dfp); void start_function(DYNFILE * dfp,char * str, ...); void start_function_FuncInfo(FuncInfo * fi,DYNFILE * dfp,char * str, ... ); void true_start_function(DYNFILE * dfp,char * str, ... ); void close_function(DYNFILE * dfp); void hang_expr(DYNFILE * dfp,char * str, ...); void expr(DYNFILE * dfp,char * str, ...); void macro(DYNFILE * dfp,char * str, ...); void warn_expr(DYNFILE * dfp,char * str, ...); void start_struct(DYNFILE * dfp,char * str, ...); void close_struct(DYNFILE * dfp,char * str, ...); void struct_macro(DYNFILE * dfp,char * str, ...); void struct_expr(DYNFILE * dfp,char * str, ...); void add_block_comment(DYNFILE * dfp,char * str, ...); void add_end_comment(DYNFILE * dfp,char * str, ...); void add_end_comment_header(DYNFILE * dfp,char * str, ...); void set_commentstart(DYNFILE * dfp,int s); void current_indent(DYNFILE * dfp); void startcase(DYNFILE * dfp); void closecase(DYNFILE * dfp); void startbrace_tag(DYNFILE * dfp,char * str); void startbrace(DYNFILE * dfp); void closebrace(DYNFILE * dfp); void fputs_func_DYNFILE(char * str,DYNFILE * dfp); DYNFILE * open_std_no_html_dynfile(char * name); DYNFILE * open_std_dynfile(char * name,char * html_directory); void close_dynfile(DYNFILE * dfp); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void show_html_DYNFILE(DYNFILE * dfp,FILE * ofp,FuncOrderType type); int place_func_decl(DYNFILE * dfp,FuncInfo * fi); void sort_DYNFILE_FuncOrderType(DYNFILE * dfp,FuncOrderType type); boolean is_separated_types(FuncOrderType type); int compare_two_FuncInfo_alpha(FuncInfo * one,FuncInfo * two); int compare_two_FuncInfo_pos(FuncInfo * one,FuncInfo * two); char * strinopen(char * target,char * probe); void swap_DYNFILE(FuncInfo ** list,int i,int j) ; void qsort_DYNFILE(FuncInfo ** list,int left,int right,int (*comp)(FuncInfo * ,FuncInfo * )); void sort_DYNFILE(DYNFILE * obj,int (*comp)(FuncInfo *, FuncInfo *)); boolean expand_DYNFILE(DYNFILE * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/dpimpl.dy0000644000175000001440000000772607344635454015274 0ustar philippusers %{ #include "wisebase.h" %} struct DycWarning boolean warn_extern !def="TRUE" boolean warn_extern_method !def="TRUE" boolean warn_c_type !def="TRUE" struct DPImplementation boolean do_threads !def="FALSE" int protect_level !def="0" int db_trace_level !def="0" boolean doprob !def="FALSE" boolean doone !def="FALSE" char * calcfunc !def="NULL" boolean largemem !def="FALSE" DycWarning * dycw boolean dydebug !def="FALSE" %info This structure indicates what dynamic programming implementations should be written using dynamite %% %{ #include "dpimpl.h" %func Shows to stdout the list of options used by DycWarning %% void show_help_DycWarning(FILE * ofp) { fprintf(ofp,"Dyc Compiler Warnings\n"); fprintf(ofp," -[no]cwarn Global switch to put on/off all warnings about C constructs\n"); fprintf(ofp," -[no]extern Warning about extern scope of names\n"); fprintf(ofp," -[no]methods Warning about extern methods not being scoped/typed\n"); fprintf(ofp," -[no]ctype Warning about non logical (C) types\n"); } %func Shows to stdout the list options used by DPImplementation %% void show_help_DPImplementation(FILE * ofp) { fprintf(ofp,"Dynamic Programming debugging options\n"); fprintf(ofp," -g generate dynamic programming debugging\n"); fprintf(ofp,"Dynamic Programming Optimisations\n"); fprintf(ofp," -O switch all optimisations on\n"); fprintf(ofp," -[no]largemem Assume large malloc chunks ok (default no)\n"); fprintf(ofp,"Database search implementation options\n"); fprintf(ofp," -pthreads generate pthread code\n"); fprintf(ofp," -dbtrace database trace level code production\n"); fprintf(ofp," -onemodel generate onemodel (bioxl/g) port\n"); fprintf(ofp,"Additional generated routines\n"); fprintf(ofp," -prob all probabilistic routines\n"); fprintf(ofp," -logsum function to use for summing log'd scores\n"); show_help_DycWarning(ofp); } %func Processes the argstring into the DycWarning stuff %% DycWarning * new_DycWarning_from_argstr(int * argc,char ** argv) { DycWarning * out; boolean cwarn = TRUE; out = DycWarning_alloc(); strip_out_boolean_def_argument(argc,argv,"cwarn",&cwarn); if( cwarn == TRUE ) { out->warn_extern = TRUE; out->warn_extern_method = TRUE; out->warn_c_type = TRUE; } else { out->warn_extern = FALSE; out->warn_c_type = FALSE; out->warn_extern_method = FALSE; } strip_out_boolean_def_argument(argc,argv,"extern",&out->warn_extern); strip_out_boolean_def_argument(argc,argv,"ctype",&out->warn_c_type); strip_out_boolean_def_argument(argc,argv,"methods",&out->warn_extern_method); return out; } %func Processes the argstring into the DPImplementation datastructure. %% DPImplementation * new_DPImplementation_from_argstr(int * argc,char ** argv) { DPImplementation * out; char * temp; out = DPImplementation_alloc(); if( (strip_out_boolean_argument(argc,argv,"pthreads")) == TRUE ) { out->do_threads = TRUE; } if( (temp=strip_out_assigned_argument(argc,argv,"dbtrace")) != NULL ) { if( is_integer_string(temp,&out->db_trace_level) == FALSE ) { warn("%s is not an integer argument for dbtrace",temp); } } if( strip_out_boolean_argument(argc,argv,"O") == TRUE ) { out->largemem= TRUE; /* other optimisations */ } strip_out_boolean_def_argument(argc,argv,"largemem",&out->largemem); strip_out_boolean_def_argument(argc,argv,"onemodel",&out->doone); if( strip_out_boolean_argument(argc,argv,"prob") == TRUE ) { out->doprob = TRUE; } if( strip_out_boolean_argument(argc,argv,"g") == TRUE ) { out->dydebug = TRUE; } if( (temp=strip_out_assigned_argument(argc,argv,"logsum")) != NULL ) { out->calcfunc = stringalloc(temp); } else { out->calcfunc = stringalloc("Probability_logsum"); } out->dycw = new_DycWarning_from_argstr(argc,argv); /* fprintf(stderr,"And %d is extern warning",out->dycw->warn_extern);*/ return out; } %} wise-2.4.1/src/dyc/wisec.c0000644000175000001440000014355110670453715014716 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "wisec.h" # line 45 "wisec.dy" char * name_from_func_type(char * ty) { char buffer[MAXLINE]; char * runner; char * type = ty; for(;*type && *type != '(';type++) ; for(;*type && *type != '*';type++) ; type++; for(;*type && isspace(*type);type++) ; if( *type == '\0') { warn("Cannot make %s into a function name. not good",ty); return NULL; } for(runner=buffer;!isspace(*type) && *type && *type != ')' ;type++,runner++) *runner = (*type); *runner = '\0'; return stringalloc(buffer); } # line 75 "wisec.dy" void write_StructHolder_header (DYNFILE * dfp,StructHolder * sh) { if( sh->oi != NULL ) { fprintf(dfp->head,"/* Object %s\n *\n",sh->name); write_C_ObjectInfo(sh->oi,dfp->head); fprintf(dfp->head," *\n */\n"); } write_StructHolder_typedef(dfp,sh,NULL); } # line 86 "wisec.dy" void write_StructHolder_function(DYNFILE * dfp,StructHolder * sh,ModuleFunctionList * mfl) { register int j; ModuleFunction * mf; boolean is_hard_link = FALSE; is_hard_link = dfp->should_hard_link; if( sh == NULL || sh->name == NULL ) { warn("Very bad problem. You are trying to build a struct holder function without a valid structholder object or holder"); } mf = get_ModuleFunction_from_name(mfl,sh->name); if( is_listfunc(sh) == TRUE) { for(j=0;jlen;j++) if( sh->el[j]->islist == TRUE) { write_list_sort_function(dfp,sh,sh->el[j]); write_list_expand_function(dfp,sh,sh->el[j]); write_list_add_function(dfp,sh,sh->el[j]); write_list_flush_function(dfp,sh,sh->el[j]); } write_alloc_std_function(dfp,sh); write_alloc_len_function(dfp,sh); } else if( is_matrixfunc(sh) == TRUE) { write_alloc_matrix_function(dfp,sh); write_expand_matrix_function(dfp,sh); } /*** currently disabled write_binary_dump_function(sh); write_binary_read_function(sh); ****/ if( is_hard_link == TRUE) write_hard_link_function(dfp,sh); if( mf == NULL || mf->has_cons == FALSE) write_simplealloc_function(dfp,sh); if( mf == NULL || mf->has_decons == FALSE) write_free_function(dfp,sh); } # line 140 "wisec.dy" void write_StructHolder_typedef(DYNFILE * dfp,StructHolder * sh,FILE * ofp) { register int i; boolean is_hard_link = FALSE; is_hard_link = dfp->should_hard_link; start_struct(dfp,"struct %s%s",dfp->package_name == NULL ? "" : dfp->package_name,sh->name); if( is_hard_link == TRUE ) { struct_expr(dfp,"int dynamite_hard_link;"); struct_macro(dfp,"#ifdef PTHREAD"); struct_expr(dfp,"pthread_mutex_t dynamite_mutex"); struct_macro(dfp,"#endif"); } for(i=0;ilen;i++) write_StructElement_typedef(dfp,sh->el[i]); close_struct(dfp,"; ",sh->name); add_end_comment_header(dfp,"%s defined",sh->name); fprintf(dfp->head,"#ifndef DYNAMITE_DEFINED_%s\n",sh->name); if( dfp->package_name != NULL ) { fprintf(dfp->head,"typedef struct %s%s %s%s;\n",dfp->package_name,sh->name,dfp->package_name,sh->name); fprintf(dfp->head,"#define %s %s%s\n",sh->name,dfp->package_name,sh->name); } else { fprintf(dfp->head,"typedef struct %s %s;\n",sh->name,sh->name); } fprintf(dfp->head,"#define DYNAMITE_DEFINED_%s\n",sh->name); fprintf(dfp->head,"#endif\n"); fprintf(dfp->head,"\n\n"); } # line 178 "wisec.dy" void write_StructElement_typedef(DYNFILE * dfp,StructElement * se) { if( se->isfunc == TRUE ) { struct_expr(dfp,"%s;",se->element_type); return; } struct_expr(dfp,"%s %s; ",se->element_type,se->name); striptoprint(se->comment); if( se->comment != NULL) add_end_comment_header(dfp,se->comment); if( se->islist == TRUE) { struct_expr(dfp,"int %slen;",CKN(se->len_append)); add_end_comment_header(dfp,"len for above %s ",se->name); struct_expr(dfp,"int %smaxlen;",CKN(se->len_append)); add_end_comment_header(dfp,"maxlen for above %s",se->name); } else if( se->ismatrix == TRUE) { struct_expr(dfp,"int leni"); add_end_comment_header(dfp,"leni for above %s ",se->name); struct_expr(dfp,"int maxleni;"); add_end_comment_header(dfp,"max length for above pointer set"); struct_expr(dfp,"int lenj"); add_end_comment_header(dfp,"lenj for above %s ",se->name); struct_expr(dfp,"int maxlenj;"); add_end_comment_header(dfp,"max length for above pointer set"); } } # line 213 "wisec.dy" char * free_function(char * type) { char * runner; char * temp; char buffer[MAXLINE]; temp = depointer_element(type); if( temp == NULL ) { warn("Unable to depointer %s",type); return NULL; } if( strchr(temp,'*') != NULL) return stringalloc("ckfree"); if( strstr(temp,"struct") != NULL) return NULL; if( (runner=strtok(temp," *\t\n")) == NULL) return NULL; if( is_simple_type_string(temp) == TRUE) return stringalloc("ckfree"); strcpy(buffer,"free_"); strcat(buffer,runner); free(temp); return stringalloc(buffer); } # line 247 "wisec.dy" void write_hard_link_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; ArgInfo * ai; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"hard_link_%s",sh->name); add_line_to_Ftext(fi->ft,"Bumps up the reference count of the object"); add_line_to_Ftext(fi->ft,"Meaning that multiple pointers can 'own' it"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc=stringalloc("Object to be hard linked"); start_function_FuncInfo(fi,dfp,"%s * hard_link_%s(%s * obj)",sh->name,sh->name,sh->name); expr(dfp,"if( obj == NULL ) "); startbrace(dfp); warn_expr(dfp,"Trying to hard link to a %s object: passed a NULL object",sh->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"obj->dynamite_hard_link++;"); expr(dfp,"return obj;"); close_function(dfp); add_break(dfp); } # line 273 "wisec.dy" void write_free_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; ArgInfo * ai; StructElement * temp; register int i; register int islist=FALSE; register int ismat =FALSE; char * run; char * run2; boolean is_hard_link = FALSE; is_hard_link = dfp->should_hard_link; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"free_%s",sh->name); add_line_to_Ftext(fi->ft,"Free Function: removes the memory held by obj"); add_line_to_Ftext(fi->ft,"Will chain up to owned members and clear all lists"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc=stringalloc("Object that is free'd"); start_function_FuncInfo(fi,dfp,"%s * free_%s(%s * obj)",sh->name,sh->name,sh->name); expr(dfp,"int return_early = 0;"); if( (islist=is_listfunc(sh)) == TRUE) { expr(dfp,"int i;"); } else if ( (ismat=is_matrixfunc(sh)) == TRUE) { expr(dfp,"int i;"); expr(dfp,"int j;"); } add_break(dfp); expr(dfp,"if( obj == NULL)"); startbrace(dfp); warn_expr(dfp,"Attempting to free a NULL pointer to a %s obj. Should be trappable",sh->name); expr(dfp,"return NULL;"); closebrace(dfp); add_break(dfp); if( is_hard_link == TRUE ) { macro(dfp,"#ifdef PTHREAD"); expr(dfp,"assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0);"); macro(dfp,"#endif"); expr(dfp,"if( obj->dynamite_hard_link > 1) "); startbrace(dfp); expr(dfp,"return_early = 1;"); expr(dfp,"obj->dynamite_hard_link--;"); closebrace(dfp); macro(dfp,"#ifdef PTHREAD"); expr(dfp,"assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0);"); macro(dfp,"#endif"); expr(dfp,"if( return_early == 1)"); hang_expr(dfp,"return NULL;"); } for(i=0;ilen;i++) { temp = sh->el[i]; if( temp->islist == TRUE) { run = depointer_element(temp->element_type); if((run2 = free_function(run)) == NULL) { log_full_error(WARNING,0,"Unable to make function for %s (%s)",temp->name,temp->element_type); add_block_comment(dfp,"Unable to make function for %s",temp->name); continue; } expr(dfp,"if( obj->%s != NULL)",temp->name); startbrace(dfp); expr(dfp,"for(i=0;i%slen;i++)",CKN(temp->len_append)); startbrace(dfp); expr(dfp,"if( obj->%s[i] != NULL)",temp->name); hang_expr(dfp,"%s(obj->%s[i]);",run2,temp->name); ckfree(run); ckfree(run2); closebrace(dfp); expr(dfp,"ckfree(obj->%s);",temp->name); closebrace(dfp); } else if( temp->ismatrix == TRUE) { expr(dfp,"if( obj->%s != NULL)",temp->name); startbrace(dfp); expr(dfp,"for(i=0;ileni;i++)"); startbrace(dfp); expr(dfp,"if( obj->%s[i] != NULL)",temp->name); hang_expr(dfp,"ckfree(obj->%s[i]);",temp->name); closebrace(dfp); expr(dfp,"ckfree(obj->%s)",temp->name); closebrace(dfp); } else if( temp->islinked == TRUE) { add_block_comment(dfp,"obj->%s is linked in",temp->name); } else if( temp->isfunc == TRUE) { add_block_comment(dfp,"obj->%s is a function pointer",temp->name); } else { if( strchr(temp->element_type,'*') == NULL) continue; if( (run=free_function(temp->element_type)) == NULL) { add_block_comment(dfp,"Unable to make free function for obj->%s",temp->name); continue; } expr(dfp,"if( obj->%s != NULL)",temp->name); hang_expr(dfp,"%s(obj->%s)",run,temp->name); ckfree(run); } } add_break(dfp); expr(dfp,"ckfree(obj);"); expr(dfp,"return NULL;"); close_function(dfp); add_break(dfp); } # line 405 "wisec.dy" boolean is_simple_type(StructElement * se) { if( se->isfunc == TRUE ) return FALSE; if( strchr(se->element_type,'*') != NULL ) return FALSE; return is_simple_type_string(se->element_type); } # line 415 "wisec.dy" boolean is_simple_type_string(char * str) { if( strcmp(str,"int") == 0) return TRUE; if( strcmp(str,"char") == 0) return TRUE; if( strcmp(str,"float") == 0) return TRUE; if( strcmp(str,"double") == 0) return TRUE; if( strcmp(str,"boolean") == 0) return TRUE; return FALSE; } # line 432 "wisec.dy" boolean is_string_type(StructElement * se) { if( se->isfunc == TRUE ) return FALSE; if( strcmp(se->element_type,"char *") == 0) return TRUE; return FALSE; } # line 443 "wisec.dy" boolean is_binary_dump_type(StructElement * se) { if( se->isfunc == TRUE) return FALSE; if( strchr(se->element_type,'*') == NULL ) return FALSE; if( strstr(se->element_type,"**") != NULL) return FALSE; return TRUE; } # line 456 "wisec.dy" void write_binary_dump_function(DYNFILE * dfp,StructHolder * sh) { register int i; start_function(dfp,"boolean binary_dump_%s(%s * obj,FILE * ofp)",sh->name,sh->name); if( is_listfunc(sh) == TRUE ) { expr(dfp,"register int i;"); } else if ( is_matrixfunc(sh) == TRUE ) { expr(dfp,"register int i;"); expr(dfp,"register int j;"); } expr(dfp,"char buffer[MAXBINARYDUMP]"); expr(dfp,"int strl;"); add_break(dfp); /*** first dump tag line ***/ expr(dfp,"memset(buffer,0,MAXBINARYDUMP)"); expr(dfp,"strcpy(buffer,\"DYN %s\")",sh->name); expr(dfp,"buffer[3] = '\\0';"); expr(dfp,"buffer[63] = '\\0';"); expr(dfp,"buffer[64] = '\\0';"); /*** dump ***/ expr(dfp,"fwrite(buffer,sizeof(char),64,ofp)"); add_break(dfp); add_block_comment(dfp,"written block tag, write out elements"); add_break(dfp); /*** ok - now chain to elements ***/ for(i=0;ilen;i++) { auto char * run; auto char * run2; auto StructElement * temp; temp = sh->el[i]; if( temp->isfunc == TRUE || temp->islinked == TRUE || temp->islocal == TRUE) continue; if( temp->islist == TRUE ) { run = depointer_element(temp->element_type); run2 = depointer_element(run); expr(dfp,"fwrite(&obj->%slen,sizeof(int),1,ofp)",CKN(temp->len_append)); expr(dfp,"for(i=0;i%slen;i++)",CKN(temp->len_append)); startbrace(dfp); expr(dfp,"binary_dump_%s(obj->%s[i],ofp)",run2,temp->name); closebrace(dfp); ckfree(run); ckfree(run2); continue; } if( is_simple_type(temp) == TRUE ) { expr(dfp,"fwrite(&obj->%s,sizeof(%s),1,ofp)",temp->name,temp->element_type); } else if( is_string_type(temp) == TRUE ) { expr(dfp,"strl = strlen(obj->%s)",temp->name); expr(dfp,"fwrite(&strl,sizeof(int),1,ofp);"); expr(dfp,"fwrite(obj->%s,sizeof(char),strlen(obj->%s),ofp)",temp->name,temp->name); } else if( is_binary_dump_type(temp) == TRUE ) { run = depointer_element(temp->element_type); /** call binary dump func **/ expr(dfp,"if( obj->%s == NULL )",temp->name); hang_expr(dfp,"strl = 0;"); expr(dfp,"else strl = 1;"); expr(dfp,"fwrite(&strl,sizeof(int),1,ofp)"); expr(dfp,"if( obj->%s != NULL )",temp->name); hang_expr(dfp,"binary_dump_%s(obj->%s,ofp)",run,temp->name); ckfree(run); } else { warn("Unable to handle binary dump for %s element of %s",temp->name,sh->name); } } expr(dfp,"return TRUE"); close_function(dfp); add_break(dfp); } # line 552 "wisec.dy" void write_binary_read_function(DYNFILE * dfp,StructHolder * sh) { register int i; char * lenapp; start_function(dfp,"%s * binary_read_%s(FILE * ifp)",sh->name,sh->name); if( is_listfunc(sh) == TRUE ) { expr(dfp,"register int i;"); expr(dfp,"int count"); } else if ( is_matrixfunc(sh) == TRUE ) { expr(dfp,"register int i;"); expr(dfp,"register int j;"); } expr(dfp,"char buffer[MAXBINARYDUMP]"); expr(dfp,"int strl;"); expr(dfp,"%s * obj",sh->name); add_break(dfp); /*** first read dump tag line ***/ expr(dfp,"fread(buffer,sizeof(char),64,ifp)"); expr(dfp,"if( strcmp(buffer,\"DYN\") != 0 )"); startbrace(dfp); warn_expr(dfp,"Unable to read DYN tag in binary read for %s",sh->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"if( strcmp(buffer+4,\"%s\") != 0 )",sh->name); startbrace(dfp); expr(dfp,"warn(\"Unable to pick up %s tag in reading binary dump, got %%s\",buffer+4)",sh->name); expr(dfp,"return NULL"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"read block tag,time to read in elements"); add_break(dfp); if( is_listfunc(sh) == TRUE) expr(dfp,"obj = %s_alloc_std()",sh->name); else expr(dfp,"obj = %s_alloc()",sh->name); expr(dfp,"if( obj == NULL )"); startbrace(dfp); warn_expr(dfp,"Memory allocation problem in %s binary read",sh->name); expr(dfp,"return NULL;"); closebrace(dfp); /*** ok - now chain to elements ***/ for(i=0;ilen;i++) { auto char * run; auto char * run2; auto StructElement * temp; temp = sh->el[i]; if( temp->isfunc == TRUE || temp->islinked == TRUE || temp->islocal == TRUE) continue; if( temp->islist == TRUE ) { if( temp->len_append == NULL) lenapp = ""; else lenapp = temp->len_append; run = depointer_element(temp->element_type); run2 = depointer_element(run); expr(dfp,"fread(&count,sizeof(int),1,ifp)"); expr(dfp,"for(;count > 0 ;count--)",temp->len_append); startbrace(dfp); expr(dfp,"add_%s%s(obj,binary_read_%s(ifp))",lenapp,temp->name,run2); closebrace(dfp); ckfree(run); ckfree(run2); continue; } if( is_simple_type(temp) == TRUE ) { expr(dfp,"fread(&obj->%s,sizeof(%s),1,ifp)",temp->name,temp->element_type); } else if( is_string_type(temp) == TRUE ) { expr(dfp,"memset(buffer,0,MAXBINARYDUMP)"); expr(dfp,"fread(&strl,sizeof(int),1,ifp)"); expr(dfp,"fread(buffer,sizeof(char),strl,ifp)"); expr(dfp,"obj->%s = stringalloc(buffer)",temp->name,temp->name); } else if( is_binary_dump_type(temp) == TRUE ) { run = depointer_element(temp->element_type); /** call binary dump func **/ expr(dfp,"fread(&strl,sizeof(int),1,ifp)"); expr(dfp,"if( strl == 1 )"); hang_expr(dfp,"obj->%s = binary_read_%s(ifp)",temp->name,run); ckfree(run); } else { warn("Unable to handle binary dump for %s element of %s",temp->name,sh->name); } } expr(dfp,"return obj"); close_function(dfp); add_break(dfp); } # line 670 "wisec.dy" void write_expand_matrix_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; register int i; char * runner; char * run2; StructElement * temp; fi = FuncInfo_named_from_varstr(FI_INTERNAL,"expand_%s",sh->name); add_line_to_Ftext(fi->ft,"Expands matrix. Rarely used"); start_function_FuncInfo(fi,dfp,"boolean expand_%s(%s * obj,int leni,int lenj)",sh->name,sh->name); for(i=0;ilen;i++) if(sh->el[i]->ismatrix == TRUE) break; if( i >= sh->len) return; temp=sh->el[i]; expr(dfp,"int i"); expr(dfp,"int actualj"); add_break(dfp); expr(dfp,"if( obj == NULL) "); startbrace(dfp); expr(dfp,"warn(\"Trying to expand a %s but is NULL!\");",sh->name); expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); expr(dfp,"if( leni <= obj->maxleni && lenj <= obj->maxlenj)"); hang_expr(dfp,"return TRUE"); add_break(dfp); expr(dfp,"if( obj->maxleni < leni )"); startbrace(dfp); if( (runner = depointer_element(temp->element_type)) == NULL) log_full_error(WARNING,0,"Oooops"); if( (run2 = depointer_element(runner)) == NULL) log_full_error(WARNING,0,"Oooops"); expr(dfp,"if( (obj->%s=(%s) ckrealloc (obj->%s,sizeof(%s)*leni)) == NULL)",temp->name,temp->element_type,temp->name,runner); hang_expr(dfp,"return FALSE;"); expr(dfp,"obj->maxleni=obj->leni=leni"); closebrace(dfp); expr(dfp,"if( lenj > obj->maxlenj )"); hang_expr(dfp,"actualj = lenj"); expr(dfp,"else actualj = obj->maxlenj;"); expr(dfp,"for(i=0;ileni;i++)"); startbrace(dfp); expr(dfp,"if((obj->%s[i] = (%s) realloc (obj->%s[i],sizeof(%s) * actualj)) == NULL)",temp->name,runner,temp->name,run2) ; hang_expr(dfp,"return FALSE;"); closebrace(dfp); expr(dfp,"return TRUE"); close_function(dfp); ckfree(runner); ckfree(run2); add_break(dfp); return; } # line 750 "wisec.dy" void write_alloc_matrix_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; ArgInfo * ai; register int i; char * run2; char * runner; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"%s_alloc_matrix",sh->name); add_line_to_Ftext(fi->ft,"Allocates structure and matrix"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"leni"); ai->desc=stringalloc("Length of first dimension of matrix"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"lenj"); ai->desc=stringalloc("Length of second dimension of matrix"); start_function_FuncInfo(fi,dfp,"%s * %s_alloc_matrix(int leni,int lenj)",sh->name,sh->name); expr(dfp,"%s * out",sh->name); add_end_comment(dfp,"out is exported "); expr(dfp,"register int i"); add_end_comment(dfp,"for stepping down matrix"); expr(dfp,"register int j"); add_end_comment(dfp,"for stepping across matrix"); add_break(dfp); add_block_comment(dfp,"Call alloc function, return NULL if NULL"); expr(dfp,"if((out = %s_alloc()) == NULL)",sh->name); hang_expr(dfp,"return NULL"); add_break(dfp); for(i=0;ilen;i++) if( sh->el[i]->ismatrix == TRUE) { if( (runner=depointer_element(sh->el[i]->element_type)) == NULL) continue; if( (run2=depointer_element(runner)) == NULL) continue; add_block_comment(dfp,"Allocate memory for %s ",sh->el[i]->name); expr(dfp,"if((out->%s = (%s) ckcalloc (leni,sizeof(%s))) == NULL)",sh->el[i]->name,sh->el[i]->element_type,runner); startbrace(dfp); expr(dfp,"warn(\"Memory allocation problem in matrix for %s %s, first pointer set\");",sh->name,sh->el[i]->name); expr(dfp,"ckfree(out)"); expr(dfp,"return NULL"); closebrace(dfp); add_break(dfp); add_block_comment(dfp,"Add NULL to all matrix pointers so free can be called"); expr(dfp,"for(i=0;i%s[i] = NULL",sh->el[i]->name); add_break(dfp); add_block_comment(dfp,"Allocate each matrix row"); expr(dfp,"for(i=0;i%s[i] = (%s) ckcalloc (lenj,sizeof(%s))",sh->el[i]->name,runner,run2); expr(dfp,"if( out->%s[i] == NULL)",sh->el[i]->name); startbrace(dfp); expr(dfp,"warn(\"Failed alloc on %%d, calling free and returning NULL\",i);"); expr(dfp,"free_%s(out)",sh->name); expr(dfp,"return NULL"); closebrace(dfp); closebrace(dfp); add_break(dfp); if( sh->el[i]->def != NULL ) { expr(dfp,"for(i=0;i%s[i][j] = %s",sh->el[i]->name,sh->el[i]->def); closebrace(dfp); add_break(dfp); } expr(dfp,"out->leni=out->maxleni=leni"); expr(dfp,"out->lenj=out->maxlenj=lenj"); add_break(dfp); } expr(dfp,"return out"); close_function(dfp); add_break(dfp); } # line 848 "wisec.dy" void write_list_sort_function(DYNFILE * dfp,StructHolder * sh,StructElement * temp) { FuncInfo * fi; ArgInfo * ai; register char * runner; char * listappend; listappend=CKN(temp->len_append); runner = depointer_element(temp->element_type); if( runner == NULL) { log_full_error(WARNING,0,"Unable to depointer %s",temp->element_type); return; } add_block_comment(dfp,"swap function for qsort function"); fi = FuncInfo_named_from_varstr(FI_INTERNAL,"swap_%s%s",listappend,sh->name); add_line_to_Ftext(fi->ft,"swap function: an internal for qsort_%s%s",listappend,sh->name); add_line_to_Ftext(fi->ft,"swaps two positions in the array"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"list"); ai->desc=stringalloc("List of structures to swap in"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"i"); ai->desc=stringalloc("swap position"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"j"); ai->desc=stringalloc("swap position"); start_function_FuncInfo(fi,dfp,"void swap_%s%s(%s list,int i,int j) ",listappend,sh->name,temp->element_type); expr(dfp,"%s temp;",runner); expr(dfp,"temp=list[i];"); expr(dfp,"list[i]=list[j];"); expr(dfp,"list[j]=temp;"); close_function(dfp); add_break(dfp); /*** sort function actual type ***/ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"qsort_%s%s",listappend,sh->name); add_line_to_Ftext(fi->ft,"qsort - lifted from K&R ",listappend,sh->name); add_line_to_Ftext(fi->ft,"sorts the array using quicksort"); add_line_to_Ftext(fi->ft,"Probably much better to call sort_%s%s which sorts from start to end",listappend,sh->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"list"); ai->desc=stringalloc("List of structures to swap in"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"left"); ai->desc=stringalloc("left position"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"right"); ai->desc=stringalloc("right position"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"comp"); ai->desc=stringalloc("Function which returns -1 or 1 to sort on"); start_function_FuncInfo(fi,dfp,"void qsort_%s%s(%s list,int left,int right,int (*comp)(%s ,%s ))",listappend,sh->name,temp->element_type,runner,runner); expr(dfp,"int i,last;"); expr(dfp,"if( left >= right )"); hang_expr(dfp,"return;"); add_break(dfp); expr(dfp,"swap_%s%s(list,left,(left+right)/2);",listappend,sh->name); expr(dfp,"last = left;"); expr(dfp,"for ( i=left+1; i <= right;i++)"); startbrace(dfp); expr(dfp,"if( (*comp)(list[i],list[left]) < 0)"); hang_expr(dfp,"swap_%s%s (list,++last,i);",listappend,sh->name); closebrace(dfp); expr(dfp,"swap_%s%s (list,left,last);",listappend,sh->name); expr(dfp,"qsort_%s%s(list,left,last-1,comp);",listappend,sh->name); expr(dfp,"qsort_%s%s(list,last+1,right,comp);",listappend,sh->name); close_function(dfp); add_break(dfp); /*** actual function to be called ***/ fi = FuncInfo_named_from_varstr(FI_INTERNAL,"sort_%s%s",listappend,sh->name); add_line_to_Ftext(fi->ft,"sorts from start to end using comp ",listappend,sh->name); add_line_to_Ftext(fi->ft,"sorts the array using quicksort by calling qsort_%s%s",listappend,sh->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc=stringalloc("Object containing list"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"comp"); ai->desc=stringalloc("Function which returns -1 or 1 to sort on"); start_function_FuncInfo(fi,dfp,"void sort_%s%s(%s * obj,int (*comp)(%s, %s))",listappend,sh->name,sh->name,runner,runner); expr(dfp,"qsort_%s%s(obj->%s,0,obj->%slen-1,comp);",listappend,sh->name,temp->name,listappend); expr(dfp,"return;"); close_function(dfp); add_break(dfp); } # line 952 "wisec.dy" void write_list_flush_function(DYNFILE * dfp,StructHolder * sh,StructElement * temp) { FuncInfo * fi; ArgInfo * ai; register char * runner; char * listapp; char * run2; listapp = CKN(temp->len_append); runner = depointer_element(temp->element_type); run2 = free_function(runner); fi = FuncInfo_named_from_varstr(FI_CALLABLE,"flush_%s%s",listapp,sh->name); add_line_to_Ftext(fi->ft,"Frees the list elements, sets length to 0"); add_line_to_Ftext(fi->ft,"If you want to save some elements, use hard_link_xxx"); add_line_to_Ftext(fi->ft,"to protect them from being actually destroyed in the free"); fi->simple= stringallocf("flush_%s",temp->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc=stringalloc("Object which contains the list "); start_function_FuncInfo(fi,dfp,"int flush_%s%s(%s * obj)",listapp,sh->name,sh->name); expr(dfp,"int i;"); add_break(dfp); expr(dfp,"for(i=0;i%slen;i++)",listapp); startbrace_tag(dfp,"for i over list length"); expr(dfp,"if( obj->%s[i] != NULL)",temp->name); startbrace(dfp); expr(dfp,"%s(obj->%s[i]);",run2,temp->name); expr(dfp,"obj->%s[i] = NULL;",temp->name); closebrace(dfp); closebrace(dfp); add_break(dfp); expr(dfp,"obj->%slen = 0;",listapp); expr(dfp,"return i;"); close_function(dfp); add_break(dfp); } # line 996 "wisec.dy" void write_list_add_function(DYNFILE * dfp,StructHolder * sh,StructElement * temp) { FuncInfo * fi; ArgInfo * ai; register char * runner; char * listappend; listappend = CKN(temp->len_append); runner = depointer_element(temp->element_type); add_block_comment(dfp,"will expand function if necessary"); fi = FuncInfo_named_from_varstr(FI_CALLABLE,"add_%s%s",listappend,sh->name); add_line_to_Ftext(fi->ft,"Adds another object to the list. It will expand the list if necessary"); fi->simple = stringallocf("add_%s",temp->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc=stringalloc("Object which contains the list"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"add"); ai->desc=stringalloc("Object to add to the list"); ai->argtype = ARGTYPE_OWNER; start_function_FuncInfo(fi,dfp,"boolean add_%s%s(%s * obj,%s add)",listappend,sh->name,sh->name,runner); expr(dfp,"if( obj->%slen >= obj->%smaxlen)",listappend,listappend); startbrace(dfp); expr(dfp,"if( expand_%s%s(obj,obj->%slen + %sLISTLENGTH) == FALSE)",listappend,sh->name,listappend,sh->name); hang_expr(dfp,"return FALSE;"); closebrace(dfp); add_break(dfp); expr(dfp,"obj->%s[obj->%slen++]=add;",temp->name,listappend); expr(dfp,"return TRUE;"); close_function(dfp); add_break(dfp); } # line 1037 "wisec.dy" void write_list_expand_function(DYNFILE * dfp,StructHolder * sh,StructElement * temp) { FuncInfo * fi; ArgInfo * ai; register char * runner; char * listappend; listappend = CKN(temp->len_append); runner = depointer_element(temp->element_type); if( runner == NULL) { log_full_error(WARNING,0,"Unable to depointer %s",temp->element_type); return; } fi = FuncInfo_named_from_varstr(FI_INTERNAL,"expand_%s%s",listappend,sh->name); add_line_to_Ftext(fi->ft,"Really an internal function for add_%s%s",listappend,sh->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"obj"); ai->desc=stringalloc("Object which contains the list"); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"len"); ai->desc=stringalloc("Length to add one"); start_function_FuncInfo(fi,dfp,"boolean expand_%s%s(%s * obj,int len)",CKN(listappend),sh->name,sh->name); add_break(dfp); expr(dfp,"if( obj->%smaxlen > obj->%slen ) ",listappend,listappend); startbrace(dfp); expr(dfp,"warn(\"expand_%s%s called with no need\");",sh->name,CKN(listappend)); expr(dfp,"return TRUE;"); closebrace(dfp); add_break(dfp); expr(dfp,"if( (obj->%s = (%s ) ckrealloc (obj->%s,sizeof(%s)*len)) == NULL) ", temp->name,temp->element_type,temp->name,runner); startbrace(dfp); expr(dfp,"warn(\"ckrealloc failed for expand_%s, returning FALSE\");",sh->name); expr(dfp,"return FALSE;"); closebrace(dfp); expr(dfp,"obj->%smaxlen = len;",listappend,listappend); expr(dfp,"return TRUE;"); close_function(dfp); add_break(dfp); } # line 1093 "wisec.dy" void write_alloc_std_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"%s_alloc_std",sh->name); add_line_to_Ftext(fi->ft,"Equivalent to %s_alloc_len(%sLISTLENGTH)",sh->name,sh->name); start_function_FuncInfo(fi,dfp,"%s * %s_alloc_std(void)",sh->name,sh->name); expr(dfp,"return %s_alloc_len(%sLISTLENGTH);",sh->name,sh->name); close_function(dfp); add_break(dfp); } # line 1106 "wisec.dy" void write_alloc_len_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; ArgInfo * ai; register int i; char * runner; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"%s_alloc_len",sh->name); add_line_to_Ftext(fi->ft,"Allocates len length to all lists",sh->name,sh->name); ai = ArgInfo_in_FuncInfo_from_varstr(fi,"len"); ai->desc=stringalloc("Length of lists to allocate"); start_function_FuncInfo(fi,dfp,"%s * %s_alloc_len(int len)",sh->name,sh->name); expr(dfp,"%s * out;",sh->name); add_end_comment(dfp,"out is exported at the end of function"); add_break(dfp); add_block_comment(dfp,"Call alloc function: return NULL if NULL"); add_block_comment(dfp,"Warning message alread in alloc function"); expr(dfp,"if((out = %s_alloc()) == NULL)",sh->name); hang_expr(dfp,"return NULL;"); add_break(dfp); add_block_comment(dfp,"Calling ckcalloc for list elements"); for(i=0;ilen;i++) { if( sh->el[i]->islist == FALSE) continue; if( (runner=depointer_element(sh->el[i]->element_type)) == NULL) continue; expr(dfp,"if((out->%s = (%s ) ckcalloc (len,sizeof(%s))) == NULL)",sh->el[i]->name,sh->el[i]->element_type,runner); free(runner); startbrace(dfp); expr(dfp,"warn(\"Warning, ckcalloc failed in %s_alloc_len\");",sh->name); expr(dfp,"return NULL;"); closebrace(dfp); expr(dfp,"out->%slen = 0;",CKN(sh->el[i]->len_append)); expr(dfp,"out->%smaxlen = len;",CKN(sh->el[i]->len_append)); add_break(dfp); } expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } # line 1163 "wisec.dy" char * depointer_element(char * element) { char buffer[MAXLINE]; char * runner; for(runner=buffer;*element && *element != '*';) *(runner++)=(*(element++)); if( *element == '\0') return NULL; element++; /* depointers it */ while( *element ) *(runner++)=(*(element++)); *(runner)='\0'; return stringalloc(buffer); } # line 1184 "wisec.dy" boolean isarray(StructElement * se) { if( strchr(se->name,'[') != NULL ) return TRUE; return FALSE; } # line 1191 "wisec.dy" void write_simplealloc_function(DYNFILE * dfp,StructHolder * sh) { FuncInfo * fi; register int i; boolean is_hard_link = FALSE; is_hard_link = dfp->should_hard_link; fi = FuncInfo_named_from_varstr(FI_CALLABLE,"%s_alloc",sh->name); add_line_to_Ftext(fi->ft,"Allocates structure: assigns defaults if given ",sh->name,sh->name); fi->simple = stringalloc("alloc"); start_function_FuncInfo(fi,dfp,"%s * %s_alloc(void)",sh->name,sh->name); expr(dfp,"%s * out;",sh->name); add_end_comment(dfp,"out is exported at end of function"); add_break(dfp); add_block_comment(dfp,"call ckalloc and see if NULL"); expr(dfp,"if((out=(%s *) ckalloc (sizeof(%s))) == NULL)", sh->name,sh->name); startbrace(dfp); expr(dfp,"warn(\"%s_alloc failed \");", sh->name); expr(dfp,"return NULL;"); add_end_comment(dfp,"calling function should respond!"); closebrace(dfp); if( is_hard_link == TRUE ) { expr(dfp,"out->dynamite_hard_link = 1;"); macro(dfp,"#ifdef PTHREAD"); expr(dfp,"pthread_mutex_init(&(out->dynamite_mutex),NULL)"); macro(dfp,"#endif"); } for(i=0;ilen;i++) { if( sh->el[i]->islinked == TRUE) continue; else if( isarray(sh->el[i]) == TRUE ) { add_block_comment(dfp,"%s is an array: no default possible",sh->el[i]->name); } else if( sh->el[i]->isfunc == TRUE) { expr(dfp,"out->%s = NULL;",sh->el[i]->name); } else if( sh->el[i]->islist == TRUE) { expr(dfp,"out->%s = NULL;",sh->el[i]->name); expr(dfp,"out->%slen = out->%smaxlen = 0;",CKN(sh->el[i]->len_append),CKN(sh->el[i]->len_append)); } else if( sh->el[i]->ismatrix == TRUE) { expr(dfp,"out->%s = NULL;",sh->el[i]->name); expr(dfp,"out->leni=out->maxleni=0;"); expr(dfp,"out->lenj=out->maxlenj=0;"); } else if( sh->el[i]->def != NULL) expr(dfp,"out->%s = %s;",sh->el[i]->name, sh->el[i]->def); else if( strcmp(sh->el[i]->element_type,"PSPosition") == 0) expr(dfp,"out->%s.x = out->%s.y = 0;",sh->el[i]->name,sh->el[i]->name); else add_block_comment(dfp,"Unable to find def for %s", sh->el[i]->name); } add_break(dfp); expr(dfp,"return out;"); close_function(dfp); add_break(dfp); } # line 1274 "wisec.dy" boolean is_listfunc(StructHolder * sh) { register int i; for(i=0;ilen;i++) if( sh->el[i]->islist == TRUE) return TRUE; return FALSE; } # line 1286 "wisec.dy" boolean is_matrixfunc(StructHolder * sh) { register int i; for(i=0;ilen;i++) if( sh->el[i]->ismatrix == TRUE) return TRUE; return FALSE; } /* IO */ # line 1298 "wisec.dy" char * def_from_element(char * str) { char * runner; if( strchr(str,'*') != NULL) return stringalloc("NULL"); if( (runner=strtok(str," \t*")) == NULL) return NULL; if( strcmp(str,"int") == 0 || strcmp(str,"float") == 0 || strcmp(str,"double") == 0) return stringalloc("0"); if( strcmp(str,"char") == 0) return stringalloc("'u'"); if( strcmp(str,"boolean") == 0 ) return stringalloc("FALSE"); if( strcmp(str,"Score") == 0 ) return stringalloc("0"); if( strcmp(str,"Probability") == 0 ) return stringalloc("0.0"); warn("For element %s - got no good default. Returning 0",str); return stringalloc("0"); } # line 1324 "wisec.dy" char * get_word_from_bang(char * str,char ** word) { if( str == NULL || *str == '\0') return NULL; while( *str != '\0' && *str != '!') str++; if( *str == '\0') { *word=NULL; return NULL; } *word=str+1; while( *str && !isspace(*str) ) str++; *str='\0'; str++; return str; } # line 1354 "wisec.dy" boolean read_StructHolder_elements(StructHolder * sh,FILE * ifp) { char buffer[MAXLINE]; char * runner; char * comment; boolean islink; boolean islist; boolean isfunc=FALSE; boolean ishidden=FALSE; boolean ismatrix; boolean islocal; char * def; char * lenapp; char * name; char ** base; char ** brk; StructElement * temp; ObjectInfo * oi; while( get_watched_line(buffer,MAXLINE,ifp) != NULL) { temp=NULL; comment=NULL; runner=NULL; def=NULL; lenapp=NULL; isfunc=islink=islist=ismatrix=islocal=FALSE; if( strstartcmp(buffer,"%info") == 0 ) { oi = read_ObjectInfo_line_func(buffer,MAXLINE,ifp,get_watched_line); if( oi == NULL ) { warn("In Object %s, bad info!",sh->name); continue; } sh->oi = oi; continue; } if( (runner=strstr(buffer,"//")) != NULL) { *(runner++)='\0'; while( *runner == '/') runner++; comment = stringalloc (runner); /* striptoprint(comment); */ } if((runner=strchr(buffer,'!')) != NULL) { *(runner-1)='\0'; base=brk=breakstring(runner,spacestr); for(;*brk != NULL;brk++) { if( strstartcmp(*brk,"!link") == 0) islink=TRUE; else if( strstartcmp(*brk,"!matrix") == 0) ismatrix=TRUE; else if( strstartcmp(*brk,"!func") == 0) isfunc=TRUE; else if( strstartcmp(*brk,"!list") == 0) islist=TRUE; else if( strstartcmp(*brk,"!local") == 0) islocal=TRUE; else if( strstartcmp(*brk,"!hidden") == 0) ishidden=TRUE; else if( strstartcmp(*brk,"!def") == 0) { def=string_from_quoted_equality(*brk); } else if( strstartcmp(*brk,"!len") == 0) { lenapp=string_from_quoted_equality(*brk); } } ckfree(base); } runner=buffer+strlen(buffer); while( runner != NULL && !isalnum(*runner) && *runner != ']' && *runner != ')' ) { if( runner == buffer) runner=NULL; else *(runner--) = '\0'; } if( runner == NULL) break; while( isalnum(*runner) || strchr("*_[])(",*runner) != NULL ) { if( *runner == ')') { while( *runner != '(' ) runner--; } else runner--; } name=runner+1; *runner='\0'; /* better not be flush! */ /* fprintf(stderr,"Adding %s and %s\n",name,buffer); */ if((temp=basic_add_StructElement( sh,name,buffer)) == NULL) fatal("Memeory problem... in adding struct element. Ugh!"); if( comment != NULL) temp->comment=comment; if( def != NULL) temp->def=def; else temp->def=def_from_element(temp->element_type); if( lenapp != NULL) temp->len_append=lenapp; if( islocal == TRUE) temp->islocal = TRUE; if( islist == TRUE) { temp->islist=TRUE; /*** make list components ***/ /*** disabled: handled in write sprintf(buf2,"%slen",temp->len_append == NULL ? "" : temp->len_append ); basic_add_StructElement(sh,buf2,"int"); sprintf(buf2,"%smaxlen",temp->len_append == NULL ? "" : temp->len_append ); basic_add_StructElement(sh,buf2,"int"); ***/ } if( islink == TRUE) temp->islinked = TRUE; if( ismatrix == TRUE) { temp->ismatrix = TRUE; /*** make matrix components ***/ /*** disabled: handled in write sprintf(buf2,"%sleni",temp->len_append == NULL ? "" : temp->len_append); basic_add_StructElement(sh,buf2,"int"); sprintf(buf2,"%smaxleni",temp->len_append == NULL ? "" : temp->len_append); basic_add_StructElement(sh,buf2,"int"); sprintf(buf2,"%slenj",temp->len_append == NULL ? "" : temp->len_append); basic_add_StructElement(sh,buf2,"int"); sprintf(buf2,"%smaxlenj",temp->len_append == NULL ? "" : temp->len_append); basic_add_StructElement(sh,buf2,"int"); ***/ } if( ishidden == TRUE ) { temp->ishidden = TRUE; } if( isfunc == TRUE ) { temp->isfunc = TRUE; runner = name_from_func_type(temp->name); sprintf(buffer,"%s %s",temp->element_type,temp->name); temp->element_type = stringalloc(buffer); temp->name = runner; } if( strchr(temp->element_type,'*') != NULL) temp->isapointer = TRUE; } return TRUE; } # line 1530 "wisec.dy" void show_StructElement(StructElement * se,FILE * ofp) { fprintf(ofp,"Name [%s] Type [%s]\n",se->name,se->element_type); } # line 1535 "wisec.dy" void show_StructHolder(StructHolder * sh,FILE * ofp) { register int i; for(i=0;ilen;i++) show_StructElement(sh->el[i],ofp); } # line 1543 "wisec.dy" StructElement * basic_add_StructElement(StructHolder * sh,char * name,char * element) { StructElement * se; se = StructElement_alloc(); /* fprintf(stderr,"allocating %s %s\n",name,element); */ se->name = stringalloc(name); se->element_type = stringalloc(element); add_StructHolder(sh,se); return se; } # line 1556 "wisec.c" /* Function: hard_link_StructElement(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [StructElement *] * * Return [UNKN ] Undocumented return value [StructElement *] * */ StructElement * hard_link_StructElement(StructElement * obj) { if( obj == NULL ) { warn("Trying to hard link to a StructElement object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: StructElement_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [StructElement *] * */ StructElement * StructElement_alloc(void) { StructElement * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(StructElement *) ckalloc (sizeof(StructElement))) == NULL) { warn("StructElement_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->element_type = NULL; out->comment = NULL; out->def = NULL; out->isapointer = FALSE; out->islinked = FALSE; out->islist = FALSE; out->ismatrix = FALSE; out->len_append = NULL; out->isfunc = FALSE; out->islocal = FALSE; out->ishidden = FALSE; return out; } /* Function: free_StructElement(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [StructElement *] * * Return [UNKN ] Undocumented return value [StructElement *] * */ StructElement * free_StructElement(StructElement * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a StructElement obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->element_type != NULL) ckfree(obj->element_type); if( obj->comment != NULL) ckfree(obj->comment); if( obj->def != NULL) ckfree(obj->def); if( obj->len_append != NULL) ckfree(obj->len_append); ckfree(obj); return NULL; } /* Function: swap_StructHolder(list,i,j) * * Descrip: swap function: an internal for qsort_StructHolder * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [StructElement **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_StructHolder(StructElement ** list,int i,int j) { StructElement * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_StructHolder(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_StructHolder which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [StructElement **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_StructHolder(StructElement ** list,int left,int right,int (*comp)(StructElement * ,StructElement * )) { int i,last; if( left >= right ) return; swap_StructHolder(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_StructHolder (list,++last,i); } swap_StructHolder (list,left,last); qsort_StructHolder(list,left,last-1,comp); qsort_StructHolder(list,last+1,right,comp); } /* Function: sort_StructHolder(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_StructHolder * * * Arg: obj [UNKN ] Object containing list [StructHolder *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_StructHolder(StructHolder * obj,int (*comp)(StructElement *, StructElement *)) { qsort_StructHolder(obj->el,0,obj->len-1,comp); return; } /* Function: expand_StructHolder(obj,len) * * Descrip: Really an internal function for add_StructHolder * * * Arg: obj [UNKN ] Object which contains the list [StructHolder *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_StructHolder(StructHolder * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_StructHolder called with no need"); return TRUE; } if( (obj->el = (StructElement ** ) ckrealloc (obj->el,sizeof(StructElement *)*len)) == NULL) { warn("ckrealloc failed for expand_StructHolder, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_StructHolder(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [StructHolder *] * Arg: add [OWNER] Object to add to the list [StructElement *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_StructHolder(StructHolder * obj,StructElement * add) { if( obj->len >= obj->maxlen) { if( expand_StructHolder(obj,obj->len + StructHolderLISTLENGTH) == FALSE) return FALSE; } obj->el[obj->len++]=add; return TRUE; } /* Function: flush_StructHolder(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [StructHolder *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_StructHolder(StructHolder * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->el[i] != NULL) { free_StructElement(obj->el[i]); obj->el[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: StructHolder_alloc_std(void) * * Descrip: Equivalent to StructHolder_alloc_len(StructHolderLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [StructHolder *] * */ StructHolder * StructHolder_alloc_std(void) { return StructHolder_alloc_len(StructHolderLISTLENGTH); } /* Function: StructHolder_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [StructHolder *] * */ StructHolder * StructHolder_alloc_len(int len) { StructHolder * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = StructHolder_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->el = (StructElement ** ) ckcalloc (len,sizeof(StructElement *))) == NULL) { warn("Warning, ckcalloc failed in StructHolder_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_StructHolder(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [StructHolder *] * * Return [UNKN ] Undocumented return value [StructHolder *] * */ StructHolder * hard_link_StructHolder(StructHolder * obj) { if( obj == NULL ) { warn("Trying to hard link to a StructHolder object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: StructHolder_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [StructHolder *] * */ StructHolder * StructHolder_alloc(void) { StructHolder * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(StructHolder *) ckalloc (sizeof(StructHolder))) == NULL) { warn("StructHolder_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->el = NULL; out->len = out->maxlen = 0; out->name = NULL; out->placing_function = NULL; out->oi = NULL; return out; } /* Function: free_StructHolder(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [StructHolder *] * * Return [UNKN ] Undocumented return value [StructHolder *] * */ StructHolder * free_StructHolder(StructHolder * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a StructHolder obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->el != NULL) { for(i=0;ilen;i++) { if( obj->el[i] != NULL) free_StructElement(obj->el[i]); } ckfree(obj->el); } if( obj->name != NULL) ckfree(obj->name); if( obj->placing_function != NULL) ckfree(obj->placing_function); if( obj->oi != NULL) free_ObjectInfo(obj->oi); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/wisec.h0000644000175000001440000001706710670453715014725 0ustar philippusers#ifndef DYNAMITEwisecHEADERFILE #define DYNAMITEwisecHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "modulefunc.h" #include "dynfile.h" #include "objectinfo.h" #define StructHolderLISTLENGTH 64 #define CKN(s) (s == NULL ? "" : s) struct StructElement { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; char * element_type; char * comment; char * def; boolean isapointer; boolean islinked; boolean islist; boolean ismatrix; char * len_append; boolean isfunc; boolean islocal; boolean ishidden; } ; /* StructElement defined */ #ifndef DYNAMITE_DEFINED_StructElement typedef struct StructElement StructElement; #define DYNAMITE_DEFINED_StructElement #endif /* Object StructHolder * * Descrip: This structure (which is now v. old) * holds the information for a single * 'struct' blueprint from dynamite. * * */ struct StructHolder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif StructElement ** el; int len;/* len for above el */ int maxlen; /* maxlen for above el */ char * name; char * placing_function; ObjectInfo * oi; } ; /* StructHolder defined */ #ifndef DYNAMITE_DEFINED_StructHolder typedef struct StructHolder StructHolder; #define DYNAMITE_DEFINED_StructHolder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_StructElement(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [StructElement *] * * Return [UNKN ] Undocumented return value [StructElement *] * */ StructElement * hard_link_StructElement(StructElement * obj); /* Function: StructElement_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [StructElement *] * */ StructElement * StructElement_alloc(void); /* Function: free_StructElement(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [StructElement *] * * Return [UNKN ] Undocumented return value [StructElement *] * */ StructElement * free_StructElement(StructElement * obj); /* Function: add_StructHolder(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [StructHolder *] * Arg: add [OWNER] Object to add to the list [StructElement *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_StructHolder(StructHolder * obj,StructElement * add); /* Function: flush_StructHolder(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [StructHolder *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_StructHolder(StructHolder * obj); /* Function: StructHolder_alloc_std(void) * * Descrip: Equivalent to StructHolder_alloc_len(StructHolderLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [StructHolder *] * */ StructHolder * StructHolder_alloc_std(void); /* Function: StructHolder_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [StructHolder *] * */ StructHolder * StructHolder_alloc_len(int len); /* Function: hard_link_StructHolder(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [StructHolder *] * * Return [UNKN ] Undocumented return value [StructHolder *] * */ StructHolder * hard_link_StructHolder(StructHolder * obj); /* Function: StructHolder_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [StructHolder *] * */ StructHolder * StructHolder_alloc(void); /* Function: free_StructHolder(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [StructHolder *] * * Return [UNKN ] Undocumented return value [StructHolder *] * */ StructHolder * free_StructHolder(StructHolder * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ char * name_from_func_type(char * ty); void write_StructHolder_header (DYNFILE * dfp,StructHolder * sh); void write_StructHolder_function(DYNFILE * dfp,StructHolder * sh,ModuleFunctionList * mfl); void write_StructHolder_typedef(DYNFILE * dfp,StructHolder * sh,FILE * ofp); void write_StructElement_typedef(DYNFILE * dfp,StructElement * se); char * free_function(char * type); void write_hard_link_function(DYNFILE * dfp,StructHolder * sh); void write_free_function(DYNFILE * dfp,StructHolder * sh); boolean is_simple_type(StructElement * se); boolean is_simple_type_string(char * str); boolean is_string_type(StructElement * se); boolean is_binary_dump_type(StructElement * se); void write_binary_dump_function(DYNFILE * dfp,StructHolder * sh); void write_binary_read_function(DYNFILE * dfp,StructHolder * sh); void write_expand_matrix_function(DYNFILE * dfp,StructHolder * sh); void write_alloc_matrix_function(DYNFILE * dfp,StructHolder * sh); void write_list_sort_function(DYNFILE * dfp,StructHolder * sh,StructElement * temp); void write_list_flush_function(DYNFILE * dfp,StructHolder * sh,StructElement * temp); void write_list_add_function(DYNFILE * dfp,StructHolder * sh,StructElement * temp); void write_list_expand_function(DYNFILE * dfp,StructHolder * sh,StructElement * temp); void write_alloc_std_function(DYNFILE * dfp,StructHolder * sh); void write_alloc_len_function(DYNFILE * dfp,StructHolder * sh); char * depointer_element(char * element); boolean isarray(StructElement * se); void write_simplealloc_function(DYNFILE * dfp,StructHolder * sh); boolean is_listfunc(StructHolder * sh); boolean is_matrixfunc(StructHolder * sh); char * def_from_element(char * str); char * get_word_from_bang(char * str,char ** word); boolean read_StructHolder_elements(StructHolder * sh,FILE * ifp); void show_StructElement(StructElement * se,FILE * ofp); void show_StructHolder(StructHolder * sh,FILE * ofp); StructElement * basic_add_StructElement(StructHolder * sh,char * name,char * element); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void swap_StructHolder(StructElement ** list,int i,int j) ; void qsort_StructHolder(StructElement ** list,int left,int right,int (*comp)(StructElement * ,StructElement * )); void sort_StructHolder(StructHolder * obj,int (*comp)(StructElement *, StructElement *)); boolean expand_StructHolder(StructHolder * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/modulefunc.c0000644000175000001440000003170710670453715015744 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "modulefunc.h" # line 54 "modulefunc.dy" ModuleFunction * get_ModuleFunction_from_name(ModuleFunctionList * mfl,char * name) { register int i; for(i=0;ilen;i++) if( strcmp(mfl->mf[i]->name,name) == 0 ) return mfl->mf[i]; return NULL; } # line 65 "modulefunc.dy" ModuleFunction * new_ModuleFunction(ModuleFunctionList * mfl,char * name) { ModuleFunction * out; out = ModuleFunction_alloc(); if( out == NULL ) return out; out->name = stringalloc(name); add_ModuleFunctionList(mfl,out); return out; } # line 81 "modulefunc.dy" void show_ModuleFunctionList(ModuleFunctionList * mfl,FILE * ofp) { register int i; for(i=0;ilen;i++) show_ModuleFunction(mfl->mf[i],ofp); } # line 90 "modulefunc.dy" void show_ModuleFunction(ModuleFunction * mf,FILE * ofp) { fprintf(ofp,"Module %s Constructor: %s Deconstructor %s\n",mf->name, mf->has_cons == TRUE ? "yes" : " no", mf->has_decons == TRUE ? "yes" : " no"); } # line 97 "modulefunc.dy" char * parse_and_get_module_name_from_func(char * line,boolean isalloc) { char * name; char * next; char * func; char buffer[128]; /** max function name! **/ name = strtok(line," \t("); if( name == NULL ) { warn("Cannot even get first name from line [%s] in parse module_name_alloc",line); return NULL; } if( *(name + strlen(name) - 1) == '*' ) next = name + strlen(name) -1; else { next = strtok(NULL," \t("); if ( next == NULL ) { warn("Cannot get pointer ref from line [%s] in parse module_name_alloc [name %s]",line,name); return NULL; } } func = strtok(NULL," \t("); if( name == NULL ) { warn("Cannot get function from line [%s] in parse module_name_alloc [name %s]",line,name); return NULL; } if( strlen(next) > 1 || *next != '*' ) { warn("In parse_module_name, the pointer string [%s] was invalid for name [%s]",next,name); return NULL; } if( isalloc == TRUE ) { sprintf(buffer,"%s_alloc",name); if( strcmp(buffer,func) != 0 ) { warn("In parse_module_name, the function [%s] did not match the type-proto [%s]",func,buffer); return NULL; } } else { sprintf(buffer,"free_%s",name); if( strcmp(buffer,func) != 0 ) { warn("In parse_module_name, the function [%s] did not match the type-proto [%s]",func,buffer); return NULL; } } return stringalloc(name); } # line 109 "modulefunc.c" /* Function: hard_link_ModuleFunction(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ModuleFunction *] * * Return [UNKN ] Undocumented return value [ModuleFunction *] * */ ModuleFunction * hard_link_ModuleFunction(ModuleFunction * obj) { if( obj == NULL ) { warn("Trying to hard link to a ModuleFunction object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ModuleFunction_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ModuleFunction *] * */ ModuleFunction * ModuleFunction_alloc(void) { ModuleFunction * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ModuleFunction *) ckalloc (sizeof(ModuleFunction))) == NULL) { warn("ModuleFunction_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->has_cons = FALSE; out->has_decons = FALSE; out->has_copy = FALSE; return out; } /* Function: free_ModuleFunction(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ModuleFunction *] * * Return [UNKN ] Undocumented return value [ModuleFunction *] * */ ModuleFunction * free_ModuleFunction(ModuleFunction * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ModuleFunction obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: swap_ModuleFunctionList(list,i,j) * * Descrip: swap function: an internal for qsort_ModuleFunctionList * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ModuleFunction **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ModuleFunctionList(ModuleFunction ** list,int i,int j) { ModuleFunction * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ModuleFunctionList(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ModuleFunctionList which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ModuleFunction **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ModuleFunctionList(ModuleFunction ** list,int left,int right,int (*comp)(ModuleFunction * ,ModuleFunction * )) { int i,last; if( left >= right ) return; swap_ModuleFunctionList(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ModuleFunctionList (list,++last,i); } swap_ModuleFunctionList (list,left,last); qsort_ModuleFunctionList(list,left,last-1,comp); qsort_ModuleFunctionList(list,last+1,right,comp); } /* Function: sort_ModuleFunctionList(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ModuleFunctionList * * * Arg: obj [UNKN ] Object containing list [ModuleFunctionList *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ModuleFunctionList(ModuleFunctionList * obj,int (*comp)(ModuleFunction *, ModuleFunction *)) { qsort_ModuleFunctionList(obj->mf,0,obj->len-1,comp); return; } /* Function: expand_ModuleFunctionList(obj,len) * * Descrip: Really an internal function for add_ModuleFunctionList * * * Arg: obj [UNKN ] Object which contains the list [ModuleFunctionList *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ModuleFunctionList(ModuleFunctionList * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_ModuleFunctionList called with no need"); return TRUE; } if( (obj->mf = (ModuleFunction ** ) ckrealloc (obj->mf,sizeof(ModuleFunction *)*len)) == NULL) { warn("ckrealloc failed for expand_ModuleFunctionList, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_ModuleFunctionList(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ModuleFunctionList *] * Arg: add [OWNER] Object to add to the list [ModuleFunction *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ModuleFunctionList(ModuleFunctionList * obj,ModuleFunction * add) { if( obj->len >= obj->maxlen) { if( expand_ModuleFunctionList(obj,obj->len + ModuleFunctionListLISTLENGTH) == FALSE) return FALSE; } obj->mf[obj->len++]=add; return TRUE; } /* Function: flush_ModuleFunctionList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ModuleFunctionList *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ModuleFunctionList(ModuleFunctionList * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->mf[i] != NULL) { free_ModuleFunction(obj->mf[i]); obj->mf[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: ModuleFunctionList_alloc_std(void) * * Descrip: Equivalent to ModuleFunctionList_alloc_len(ModuleFunctionListLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ModuleFunctionList *] * */ ModuleFunctionList * ModuleFunctionList_alloc_std(void) { return ModuleFunctionList_alloc_len(ModuleFunctionListLISTLENGTH); } /* Function: ModuleFunctionList_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ModuleFunctionList *] * */ ModuleFunctionList * ModuleFunctionList_alloc_len(int len) { ModuleFunctionList * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = ModuleFunctionList_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->mf = (ModuleFunction ** ) ckcalloc (len,sizeof(ModuleFunction *))) == NULL) { warn("Warning, ckcalloc failed in ModuleFunctionList_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_ModuleFunctionList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ModuleFunctionList *] * * Return [UNKN ] Undocumented return value [ModuleFunctionList *] * */ ModuleFunctionList * hard_link_ModuleFunctionList(ModuleFunctionList * obj) { if( obj == NULL ) { warn("Trying to hard link to a ModuleFunctionList object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ModuleFunctionList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ModuleFunctionList *] * */ ModuleFunctionList * ModuleFunctionList_alloc(void) { ModuleFunctionList * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ModuleFunctionList *) ckalloc (sizeof(ModuleFunctionList))) == NULL) { warn("ModuleFunctionList_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->mf = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_ModuleFunctionList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ModuleFunctionList *] * * Return [UNKN ] Undocumented return value [ModuleFunctionList *] * */ ModuleFunctionList * free_ModuleFunctionList(ModuleFunctionList * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ModuleFunctionList obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->mf != NULL) { for(i=0;ilen;i++) { if( obj->mf[i] != NULL) free_ModuleFunction(obj->mf[i]); } ckfree(obj->mf); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/modulefunc.h0000644000175000001440000001517010670453715015745 0ustar philippusers#ifndef DYNAMITEmodulefuncHEADERFILE #define DYNAMITEmodulefuncHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #define ModuleFunctionListLISTLENGTH 64 /********************************************************/ /* Wisetools version 3 file */ /* */ /* this file is copyright (c) Ewan Birney 1996 */ /* this file is part of the wisetools sequence analysis */ /* package */ /********************************************************/ /********************************************************/ /* This stores information about which modules do */ /* have constructors or deconstructors, such that */ /* they can be made correctly */ /* */ /********************************************************/ /***** RCS Info *****************************************/ /* $Id $Log */ /********************************************************/ struct ModuleFunction { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; boolean has_cons; boolean has_decons; boolean has_copy; } ; /* ModuleFunction defined */ #ifndef DYNAMITE_DEFINED_ModuleFunction typedef struct ModuleFunction ModuleFunction; #define DYNAMITE_DEFINED_ModuleFunction #endif struct ModuleFunctionList { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ModuleFunction ** mf; int len;/* len for above mf */ int maxlen; /* maxlen for above mf */ } ; /* ModuleFunctionList defined */ #ifndef DYNAMITE_DEFINED_ModuleFunctionList typedef struct ModuleFunctionList ModuleFunctionList; #define DYNAMITE_DEFINED_ModuleFunctionList #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_ModuleFunction(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ModuleFunction *] * * Return [UNKN ] Undocumented return value [ModuleFunction *] * */ ModuleFunction * hard_link_ModuleFunction(ModuleFunction * obj); /* Function: ModuleFunction_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ModuleFunction *] * */ ModuleFunction * ModuleFunction_alloc(void); /* Function: free_ModuleFunction(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ModuleFunction *] * * Return [UNKN ] Undocumented return value [ModuleFunction *] * */ ModuleFunction * free_ModuleFunction(ModuleFunction * obj); /* Function: add_ModuleFunctionList(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ModuleFunctionList *] * Arg: add [OWNER] Object to add to the list [ModuleFunction *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_ModuleFunctionList(ModuleFunctionList * obj,ModuleFunction * add); /* Function: flush_ModuleFunctionList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ModuleFunctionList *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ModuleFunctionList(ModuleFunctionList * obj); /* Function: ModuleFunctionList_alloc_std(void) * * Descrip: Equivalent to ModuleFunctionList_alloc_len(ModuleFunctionListLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ModuleFunctionList *] * */ ModuleFunctionList * ModuleFunctionList_alloc_std(void); /* Function: ModuleFunctionList_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ModuleFunctionList *] * */ ModuleFunctionList * ModuleFunctionList_alloc_len(int len); /* Function: hard_link_ModuleFunctionList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ModuleFunctionList *] * * Return [UNKN ] Undocumented return value [ModuleFunctionList *] * */ ModuleFunctionList * hard_link_ModuleFunctionList(ModuleFunctionList * obj); /* Function: ModuleFunctionList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ModuleFunctionList *] * */ ModuleFunctionList * ModuleFunctionList_alloc(void); /* Function: free_ModuleFunctionList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ModuleFunctionList *] * * Return [UNKN ] Undocumented return value [ModuleFunctionList *] * */ ModuleFunctionList * free_ModuleFunctionList(ModuleFunctionList * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ ModuleFunction * get_ModuleFunction_from_name(ModuleFunctionList * mfl,char * name); ModuleFunction * new_ModuleFunction(ModuleFunctionList * mfl,char * name) ; void show_ModuleFunctionList(ModuleFunctionList * mfl,FILE * ofp); void show_ModuleFunction(ModuleFunction * mf,FILE * ofp); char * parse_and_get_module_name_from_func(char * line,boolean isalloc); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void swap_ModuleFunctionList(ModuleFunction ** list,int i,int j) ; void qsort_ModuleFunctionList(ModuleFunction ** list,int left,int right,int (*comp)(ModuleFunction * ,ModuleFunction * )); void sort_ModuleFunctionList(ModuleFunctionList * obj,int (*comp)(ModuleFunction *, ModuleFunction *)); boolean expand_ModuleFunctionList(ModuleFunctionList * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/ftext.dy0000644000175000001440000001146207313404534015116 0ustar philippusers %{ #include "wisebase.h" #define FblockLISTLENGTH 64 #define FtextLISTLENGTH 64 %} struct Fblock char ** line !list struct Ftext Fblock ** fb !list %{ #include "ftext.h" %func adds a vsprintf'd line (below MAXLINE length!) to the Ftext. %% boolean add_line_to_Ftext(Ftext * ft,char * str,...) { char buffer[MAXLINE]; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); return add_Fblock(ft->fb[ft->len-1],stringalloc(buffer)); } %func puts in a break into the Ftext %% boolean add_break_to_Ftext(Ftext * ft) { Fblock * temp; temp = Fblock_alloc_std(); return add_Ftext(ft,temp); } %func Makes a complete Ftext from just this string: %% Ftext * single_Ftext_from_str(char * str) { Fblock * temp; Ftext * out; out = Ftext_alloc_len(1); temp = Fblock_alloc_len(1); add_Fblock(temp,stringalloc(str)); add_Ftext(out,temp); return out; } %func shows Ftext as a C style comment with * * * indenting: will return number of lines printed. %arg ft r Ftext to be shown header r Header for the first line, eg, "description:" depth r depth of from * to text ofp output file blank_text r if non NULL, what to put if ft is empty, Can be NULL. %% int show_eddystyle_Ftext(Ftext * ft,char * header,int depth,FILE * ofp,char * blank_text) { int len = 0; int i; int j; int st = 1; char space[]=" "; if( ft == NULL || ft->len == 0 || ft->fb[0]->len == 0) { fprintf(ofp," * %*s %s\n",depth-9,header,blank_text == NULL ? "No text" : blank_text); return 1; } fprintf(ofp," * %*s %s\n",-(depth-4),header,ft->fb[0]->line[0]); len++; for(i=0;ilen;i++) { for(j=0;jfb[i]->len;j++) { if( st == 1 ) { st =0; continue; } fprintf(ofp," *%.*s%s\n",depth-2,space,ft->fb[i]->line[j]); len++; } fprintf(ofp," *\n"); len++; } return len; } %func Provides a latex dump of some text. Lines that start flush to the left are given as paragraphs Line that are indented are made verbatim %% void latex_Ftext(Ftext * ft,FILE * ofp) { int i,j; boolean inverbatim = FALSE; for(i=0;ilen;i++) { for(j=0;jfb[i]->len;j++) { if( isspace(ft->fb[i]->line[j][0]) ) { if( inverbatim == FALSE ) { fprintf(ofp,"\\begin{verbatim}\n"); inverbatim = TRUE; } } else if ( inverbatim == TRUE ) { fprintf(ofp,"\\end{verbatim}\n"); inverbatim = FALSE; } fprintf(ofp,"%s\n",ft->fb[i]->line[j]); } fprintf(ofp,"\n\n"); } /* if we are in verbatim - get out! */ if ( inverbatim == TRUE ) fprintf(ofp,"\\end{verbatim}\n"); } %func stupid function which gives flat dump of ftext %% void dump_Ftext(Ftext * ft,FILE *ofp) { int i; for(i=0;ilen;i++) { dump_Fblock_str("",ft->fb[i],ofp); fprintf(ofp,"\n"); } } %func stupid function which gives flat dump of ftext, with a start of pre %% void dump_Ftext_pre(char * pre,Ftext * ft,FILE *ofp) { int i; for(i=0;ilen;i++) { dump_Fblock_str(pre,ft->fb[i],ofp); fprintf(ofp,"\n"); } } %func sub of /dump_Ftext %type internal %% void dump_Fblock_str(char * pre,Fblock * fb,FILE * ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,"%s%s\n",pre,fb->line[i]); } } %func reads in lines until it hits endpoint. A bit of an internal: is going to use buffer and maxlen as its buffer (this is so it is not fixed to one length of buffer). You probably have abuffer in your calling function. %arg buffer w pointer to a char * buffer of maxlen that can be written in maxlen r maximum size of buffer to read ifp input file endpoint r a string which is used (using /strstartcmp) as a tag for the end of text %% Ftext * read_Ftext(char * buffer,int maxlen,FILE * ifp,char * endpoint,char * (*fgets_func)(char *,int,FILE *)) { Ftext * out; Fblock * temp; out = Ftext_alloc_std(); if( fgets_func == NULL ) fgets_func = fgets; while((temp= read_Fblock(buffer,maxlen,ifp,endpoint,fgets_func)) != NULL ) { add_Ftext(out,temp); if( strstartcmp(buffer,endpoint) == 0 ) return out; } warn("Got a NULL Fblock in reading a Ftext. Not good news!"); return out; } %func Really an internal for read_Ftext %type internal %% Fblock * read_Fblock(char * buffer,int maxlen,FILE * ifp,char * endpoint,char * (*fgets_func)(char *,int,FILE *)) { Fblock * out; out = Fblock_alloc_std(); while((*fgets_func)(buffer,maxlen,ifp) != NULL ) { if( strstartcmp(buffer,endpoint) == 0 ) return out; if( strstartcmp(buffer,"\n") == 0 ) return out; buffer[strlen(buffer)-1] ='\0'; /*** strips off '\n' ***/ /* fprintf(stderr,"Adding %s",buffer); */ add_Fblock(out,stringalloc(buffer)); } warn("Got to then end of the file in reading a Fblock. Not a good sign!"); return out; } %} wise-2.4.1/src/dyc/input.c0000644000175000001440000006433510670453715014745 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "input.h" # line 34 "input.dy" Input * read_Input_line(char * line,FILE * ifp) { Input * out; InRequire * re; InDeclare * de; char buffer[MAXLINE]; out = Input_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strwhitestartcmp(buffer,"#",spacestr) == 0 ) continue; if( strstartcmp(buffer,"declare") == 0 ) { de = InDeclare_from_line(buffer); if( de != NULL ) { add_decl_Input(out,de); } else { warn("Unreadable declaration line in input"); } } else if ( strstartcmp(buffer,"require") == 0 ) { re = InRequire_from_line(buffer); if( re != NULL ) { add_req_Input(out,re); } else { warn("Unreadable require line in input"); } } else if ( strstartcmp(buffer,"code") == 0 ) { if( out->code != NULL ) { warn("Two code segments in an input!"); out->code = free_Code(out->code); } out->code = read_Code_line(buffer,ifp); } else { warn("Could not understand line %s in input specification",buffer); } } return out; } # line 75 "input.dy" Code * read_Code_line(char * line,FILE * ifp) { char buffer[MAXLINE]; Code * out; out = Code_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"endcode") == 0 ) break; } return out; } # line 92 "input.dy" InRequire * InRequire_from_line(char * line) { InRequire * out; int i; char ** base; char ** brk; base = brk = breakstring(line,spacestr); if( *brk == NULL || strcmp(*brk,"require") == 0 ) { warn("In require - no require line!"); } for(i=1;i<5;i++) { if( brk[i] == NULL ) { warn("wrong number of arguments for require line [%s]",line); return NULL; } } out = InRequire_alloc(); out->name = stringalloc(brk[1]); out->type = stringalloc(brk[2]); strip_quote_chars(brk[3],"\""); out->help = stringalloc(brk[3]); out->tag = stringalloc(brk[4]); ckfree(base); return out; } # line 123 "input.dy" InDeclare * InDeclare_from_line(char * line) { InDeclare * out; char * runner; char * name; char * type; runner = strtok(line,spacestr); if( strcmp(runner,"declare") != 0 ) { warn("You don't have a declaration line in %s",line); return NULL; } name = strtok(NULL,spacestr); type = strtok(NULL,spacestr); if( type == NULL ) { warn("In reading the line %s, we have no type. format problem",line); return NULL; } out = InDeclare_alloc(); out->name = stringalloc(name); out->type = stringalloc(type); return out; } # line 131 "input.c" /* Function: swap_Code(list,i,j) * * Descrip: swap function: an internal for qsort_Code * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [char **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Code(char ** list,int i,int j) { char * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Code(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Code which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [char **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Code(char ** list,int left,int right,int (*comp)(char * ,char * )) { int i,last; if( left >= right ) return; swap_Code(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Code (list,++last,i); } swap_Code (list,left,last); qsort_Code(list,left,last-1,comp); qsort_Code(list,last+1,right,comp); } /* Function: sort_Code(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Code * * * Arg: obj [UNKN ] Object containing list [Code *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Code(Code * obj,int (*comp)(char *, char *)) { qsort_Code(obj->lines,0,obj->len-1,comp); return; } /* Function: expand_Code(obj,len) * * Descrip: Really an internal function for add_Code * * * Arg: obj [UNKN ] Object which contains the list [Code *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Code(Code * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Code called with no need"); return TRUE; } if( (obj->lines = (char ** ) ckrealloc (obj->lines,sizeof(char *)*len)) == NULL) { warn("ckrealloc failed for expand_Code, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Code(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Code *] * Arg: add [OWNER] Object to add to the list [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Code(Code * obj,char * add) { if( obj->len >= obj->maxlen) { if( expand_Code(obj,obj->len + CodeLISTLENGTH) == FALSE) return FALSE; } obj->lines[obj->len++]=add; return TRUE; } /* Function: flush_Code(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Code *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Code(Code * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->lines[i] != NULL) { ckfree(obj->lines[i]); obj->lines[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: Code_alloc_std(void) * * Descrip: Equivalent to Code_alloc_len(CodeLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Code *] * */ Code * Code_alloc_std(void) { return Code_alloc_len(CodeLISTLENGTH); } /* Function: Code_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Code *] * */ Code * Code_alloc_len(int len) { Code * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Code_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->lines = (char ** ) ckcalloc (len,sizeof(char *))) == NULL) { warn("Warning, ckcalloc failed in Code_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_Code(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Code *] * * Return [UNKN ] Undocumented return value [Code *] * */ Code * hard_link_Code(Code * obj) { if( obj == NULL ) { warn("Trying to hard link to a Code object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Code_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Code *] * */ Code * Code_alloc(void) { Code * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Code *) ckalloc (sizeof(Code))) == NULL) { warn("Code_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->lines = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_Code(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Code *] * * Return [UNKN ] Undocumented return value [Code *] * */ Code * free_Code(Code * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Code obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->lines != NULL) { for(i=0;ilen;i++) { if( obj->lines[i] != NULL) ckfree(obj->lines[i]); } ckfree(obj->lines); } ckfree(obj); return NULL; } /* Function: hard_link_InDeclare(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [InDeclare *] * * Return [UNKN ] Undocumented return value [InDeclare *] * */ InDeclare * hard_link_InDeclare(InDeclare * obj) { if( obj == NULL ) { warn("Trying to hard link to a InDeclare object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: InDeclare_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [InDeclare *] * */ InDeclare * InDeclare_alloc(void) { InDeclare * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(InDeclare *) ckalloc (sizeof(InDeclare))) == NULL) { warn("InDeclare_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->type = NULL; return out; } /* Function: free_InDeclare(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [InDeclare *] * * Return [UNKN ] Undocumented return value [InDeclare *] * */ InDeclare * free_InDeclare(InDeclare * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a InDeclare obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->type != NULL) ckfree(obj->type); ckfree(obj); return NULL; } /* Function: hard_link_InRequire(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [InRequire *] * * Return [UNKN ] Undocumented return value [InRequire *] * */ InRequire * hard_link_InRequire(InRequire * obj) { if( obj == NULL ) { warn("Trying to hard link to a InRequire object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: InRequire_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [InRequire *] * */ InRequire * InRequire_alloc(void) { InRequire * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(InRequire *) ckalloc (sizeof(InRequire))) == NULL) { warn("InRequire_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->type = NULL; out->help = NULL; out->tag = NULL; return out; } /* Function: free_InRequire(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [InRequire *] * * Return [UNKN ] Undocumented return value [InRequire *] * */ InRequire * free_InRequire(InRequire * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a InRequire obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->type != NULL) ckfree(obj->type); if( obj->help != NULL) ckfree(obj->help); if( obj->tag != NULL) ckfree(obj->tag); ckfree(obj); return NULL; } /* Function: swap_decl_Input(list,i,j) * * Descrip: swap function: an internal for qsort_decl_Input * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [InDeclare **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_decl_Input(InDeclare ** list,int i,int j) { InDeclare * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_decl_Input(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_decl_Input which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [InDeclare **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_decl_Input(InDeclare ** list,int left,int right,int (*comp)(InDeclare * ,InDeclare * )) { int i,last; if( left >= right ) return; swap_decl_Input(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_decl_Input (list,++last,i); } swap_decl_Input (list,left,last); qsort_decl_Input(list,left,last-1,comp); qsort_decl_Input(list,last+1,right,comp); } /* Function: sort_decl_Input(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_decl_Input * * * Arg: obj [UNKN ] Object containing list [Input *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_decl_Input(Input * obj,int (*comp)(InDeclare *, InDeclare *)) { qsort_decl_Input(obj->decl,0,obj->decl_len-1,comp); return; } /* Function: expand_decl_Input(obj,len) * * Descrip: Really an internal function for add_decl_Input * * * Arg: obj [UNKN ] Object which contains the list [Input *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_decl_Input(Input * obj,int len) { if( obj->decl_maxlen > obj->decl_len ) { warn("expand_Inputdecl_ called with no need"); return TRUE; } if( (obj->decl = (InDeclare ** ) ckrealloc (obj->decl,sizeof(InDeclare *)*len)) == NULL) { warn("ckrealloc failed for expand_Input, returning FALSE"); return FALSE; } obj->decl_maxlen = len; return TRUE; } /* Function: add_decl_Input(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Input *] * Arg: add [OWNER] Object to add to the list [InDeclare *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_decl_Input(Input * obj,InDeclare * add) { if( obj->decl_len >= obj->decl_maxlen) { if( expand_decl_Input(obj,obj->decl_len + InputLISTLENGTH) == FALSE) return FALSE; } obj->decl[obj->decl_len++]=add; return TRUE; } /* Function: flush_decl_Input(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Input *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_decl_Input(Input * obj) { int i; for(i=0;idecl_len;i++) { /*for i over list length*/ if( obj->decl[i] != NULL) { free_InDeclare(obj->decl[i]); obj->decl[i] = NULL; } } /* end of for i over list length */ obj->decl_len = 0; return i; } /* Function: swap_req_Input(list,i,j) * * Descrip: swap function: an internal for qsort_req_Input * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [InRequire **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_req_Input(InRequire ** list,int i,int j) { InRequire * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_req_Input(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_req_Input which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [InRequire **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_req_Input(InRequire ** list,int left,int right,int (*comp)(InRequire * ,InRequire * )) { int i,last; if( left >= right ) return; swap_req_Input(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_req_Input (list,++last,i); } swap_req_Input (list,left,last); qsort_req_Input(list,left,last-1,comp); qsort_req_Input(list,last+1,right,comp); } /* Function: sort_req_Input(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_req_Input * * * Arg: obj [UNKN ] Object containing list [Input *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_req_Input(Input * obj,int (*comp)(InRequire *, InRequire *)) { qsort_req_Input(obj->req,0,obj->req_len-1,comp); return; } /* Function: expand_req_Input(obj,len) * * Descrip: Really an internal function for add_req_Input * * * Arg: obj [UNKN ] Object which contains the list [Input *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_req_Input(Input * obj,int len) { if( obj->req_maxlen > obj->req_len ) { warn("expand_Inputreq_ called with no need"); return TRUE; } if( (obj->req = (InRequire ** ) ckrealloc (obj->req,sizeof(InRequire *)*len)) == NULL) { warn("ckrealloc failed for expand_Input, returning FALSE"); return FALSE; } obj->req_maxlen = len; return TRUE; } /* Function: add_req_Input(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Input *] * Arg: add [OWNER] Object to add to the list [InRequire *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_req_Input(Input * obj,InRequire * add) { if( obj->req_len >= obj->req_maxlen) { if( expand_req_Input(obj,obj->req_len + InputLISTLENGTH) == FALSE) return FALSE; } obj->req[obj->req_len++]=add; return TRUE; } /* Function: flush_req_Input(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Input *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_req_Input(Input * obj) { int i; for(i=0;ireq_len;i++) { /*for i over list length*/ if( obj->req[i] != NULL) { free_InRequire(obj->req[i]); obj->req[i] = NULL; } } /* end of for i over list length */ obj->req_len = 0; return i; } /* Function: Input_alloc_std(void) * * Descrip: Equivalent to Input_alloc_len(InputLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Input *] * */ Input * Input_alloc_std(void) { return Input_alloc_len(InputLISTLENGTH); } /* Function: Input_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Input *] * */ Input * Input_alloc_len(int len) { Input * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Input_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->decl = (InDeclare ** ) ckcalloc (len,sizeof(InDeclare *))) == NULL) { warn("Warning, ckcalloc failed in Input_alloc_len"); return NULL; } out->decl_len = 0; out->decl_maxlen = len; if((out->req = (InRequire ** ) ckcalloc (len,sizeof(InRequire *))) == NULL) { warn("Warning, ckcalloc failed in Input_alloc_len"); return NULL; } out->req_len = 0; out->req_maxlen = len; return out; } /* Function: hard_link_Input(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Input *] * * Return [UNKN ] Undocumented return value [Input *] * */ Input * hard_link_Input(Input * obj) { if( obj == NULL ) { warn("Trying to hard link to a Input object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Input_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Input *] * */ Input * Input_alloc(void) { Input * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Input *) ckalloc (sizeof(Input))) == NULL) { warn("Input_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->decl = NULL; out->decl_len = out->decl_maxlen = 0; out->req = NULL; out->req_len = out->req_maxlen = 0; out->code = NULL; return out; } /* Function: free_Input(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Input *] * * Return [UNKN ] Undocumented return value [Input *] * */ Input * free_Input(Input * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Input obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->decl != NULL) { for(i=0;idecl_len;i++) { if( obj->decl[i] != NULL) free_InDeclare(obj->decl[i]); } ckfree(obj->decl); } if( obj->req != NULL) { for(i=0;ireq_len;i++) { if( obj->req[i] != NULL) free_InRequire(obj->req[i]); } ckfree(obj->req); } if( obj->code != NULL) free_Code(obj->code); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/input.h0000644000175000001440000002344210670453715014744 0ustar philippusers#ifndef DYNAMITEinputHEADERFILE #define DYNAMITEinputHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #define CodeLISTLENGTH 128 #define InputLISTLENGTH 16 struct Code { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char ** lines; int len;/* len for above lines */ int maxlen; /* maxlen for above lines */ } ; /* Code defined */ #ifndef DYNAMITE_DEFINED_Code typedef struct Code Code; #define DYNAMITE_DEFINED_Code #endif struct InDeclare { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; char * type; } ; /* InDeclare defined */ #ifndef DYNAMITE_DEFINED_InDeclare typedef struct InDeclare InDeclare; #define DYNAMITE_DEFINED_InDeclare #endif struct InRequire { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; char * type; char * help; char * tag; } ; /* InRequire defined */ #ifndef DYNAMITE_DEFINED_InRequire typedef struct InRequire InRequire; #define DYNAMITE_DEFINED_InRequire #endif struct Input { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif InDeclare ** decl; int decl_len; /* len for above decl */ int decl_maxlen;/* maxlen for above decl */ InRequire ** req; int req_len;/* len for above req */ int req_maxlen; /* maxlen for above req */ Code * code; } ; /* Input defined */ #ifndef DYNAMITE_DEFINED_Input typedef struct Input Input; #define DYNAMITE_DEFINED_Input #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: add_Code(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Code *] * Arg: add [OWNER] Object to add to the list [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_Code(Code * obj,char * add); /* Function: flush_Code(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Code *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Code(Code * obj); /* Function: Code_alloc_std(void) * * Descrip: Equivalent to Code_alloc_len(CodeLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Code *] * */ Code * Code_alloc_std(void); /* Function: Code_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Code *] * */ Code * Code_alloc_len(int len); /* Function: hard_link_Code(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Code *] * * Return [UNKN ] Undocumented return value [Code *] * */ Code * hard_link_Code(Code * obj); /* Function: Code_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Code *] * */ Code * Code_alloc(void); /* Function: free_Code(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Code *] * * Return [UNKN ] Undocumented return value [Code *] * */ Code * free_Code(Code * obj); /* Function: hard_link_InDeclare(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [InDeclare *] * * Return [UNKN ] Undocumented return value [InDeclare *] * */ InDeclare * hard_link_InDeclare(InDeclare * obj); /* Function: InDeclare_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [InDeclare *] * */ InDeclare * InDeclare_alloc(void); /* Function: free_InDeclare(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [InDeclare *] * * Return [UNKN ] Undocumented return value [InDeclare *] * */ InDeclare * free_InDeclare(InDeclare * obj); /* Function: hard_link_InRequire(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [InRequire *] * * Return [UNKN ] Undocumented return value [InRequire *] * */ InRequire * hard_link_InRequire(InRequire * obj); /* Function: InRequire_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [InRequire *] * */ InRequire * InRequire_alloc(void); /* Function: free_InRequire(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [InRequire *] * * Return [UNKN ] Undocumented return value [InRequire *] * */ InRequire * free_InRequire(InRequire * obj); /* Function: add_decl_Input(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Input *] * Arg: add [OWNER] Object to add to the list [InDeclare *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_decl_Input(Input * obj,InDeclare * add); /* Function: flush_decl_Input(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Input *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_decl_Input(Input * obj); /* Function: add_req_Input(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Input *] * Arg: add [OWNER] Object to add to the list [InRequire *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean add_req_Input(Input * obj,InRequire * add); /* Function: flush_req_Input(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Input *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_req_Input(Input * obj); /* Function: Input_alloc_std(void) * * Descrip: Equivalent to Input_alloc_len(InputLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Input *] * */ Input * Input_alloc_std(void); /* Function: Input_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Input *] * */ Input * Input_alloc_len(int len); /* Function: hard_link_Input(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Input *] * * Return [UNKN ] Undocumented return value [Input *] * */ Input * hard_link_Input(Input * obj); /* Function: Input_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Input *] * */ Input * Input_alloc(void); /* Function: free_Input(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Input *] * * Return [UNKN ] Undocumented return value [Input *] * */ Input * free_Input(Input * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ Input * read_Input_line(char * line,FILE * ifp); Code * read_Code_line(char * line,FILE * ifp); InRequire * InRequire_from_line(char * line); InDeclare * InDeclare_from_line(char * line); /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void swap_Code(char ** list,int i,int j) ; void qsort_Code(char ** list,int left,int right,int (*comp)(char * ,char * )); void sort_Code(Code * obj,int (*comp)(char *, char *)); boolean expand_Code(Code * obj,int len); void swap_decl_Input(InDeclare ** list,int i,int j) ; void qsort_decl_Input(InDeclare ** list,int left,int right,int (*comp)(InDeclare * ,InDeclare * )); void sort_decl_Input(Input * obj,int (*comp)(InDeclare *, InDeclare *)); boolean expand_decl_Input(Input * obj,int len); void swap_req_Input(InRequire ** list,int i,int j) ; void qsort_req_Input(InRequire ** list,int left,int right,int (*comp)(InRequire * ,InRequire * )); void sort_req_Input(Input * obj,int (*comp)(InRequire *, InRequire *)); boolean expand_req_Input(Input * obj,int len); #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/moduleinfo.c0000644000175000001440000000445710670453715015746 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "moduleinfo.h" # line 6 "moduleinfo.c" /* Function: hard_link_ModuleInfo(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ModuleInfo *] * * Return [UNKN ] Undocumented return value [ModuleInfo *] * */ ModuleInfo * hard_link_ModuleInfo(ModuleInfo * obj) { if( obj == NULL ) { warn("Trying to hard link to a ModuleInfo object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ModuleInfo_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ModuleInfo *] * */ ModuleInfo * ModuleInfo_alloc(void) { ModuleInfo * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ModuleInfo *) ckalloc (sizeof(ModuleInfo))) == NULL) { warn("ModuleInfo_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->ft = NULL; return out; } /* Function: free_ModuleInfo(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ModuleInfo *] * * Return [UNKN ] Undocumented return value [ModuleInfo *] * */ ModuleInfo * free_ModuleInfo(ModuleInfo * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ModuleInfo obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->ft != NULL) free_Ftext(obj->ft); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dyc/moduleinfo.h0000644000175000001440000000370110670453715015742 0ustar philippusers#ifndef DYNAMITEmoduleinfoHEADERFILE #define DYNAMITEmoduleinfoHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "ftext.h" struct ModuleInfo { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Ftext * ft; /* description of module */ } ; /* ModuleInfo defined */ #ifndef DYNAMITE_DEFINED_ModuleInfo typedef struct ModuleInfo ModuleInfo; #define DYNAMITE_DEFINED_ModuleInfo #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_ModuleInfo(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ModuleInfo *] * * Return [UNKN ] Undocumented return value [ModuleInfo *] * */ ModuleInfo * hard_link_ModuleInfo(ModuleInfo * obj); /* Function: ModuleInfo_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ModuleInfo *] * */ ModuleInfo * ModuleInfo_alloc(void); /* Function: free_ModuleInfo(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ModuleInfo *] * * Return [UNKN ] Undocumented return value [ModuleInfo *] * */ ModuleInfo * free_ModuleInfo(ModuleInfo * obj); /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dyc/input.dy0000644000175000001440000000541307313404534015122 0ustar philippusers %{ #include "wisebase.h" #define CodeLISTLENGTH 128 #define InputLISTLENGTH 16 %} struct Code char ** lines !list struct InDeclare char * name; char * type; struct InRequire char * name char * type char * help char * tag struct Input InDeclare ** decl !list !len="decl_" InRequire ** req !list !len="req_" Code * code; %{ #include "input.h" Input * read_Input_line(char * line,FILE * ifp) { Input * out; InRequire * re; InDeclare * de; char buffer[MAXLINE]; out = Input_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strwhitestartcmp(buffer,"#",spacestr) == 0 ) continue; if( strstartcmp(buffer,"declare") == 0 ) { de = InDeclare_from_line(buffer); if( de != NULL ) { add_decl_Input(out,de); } else { warn("Unreadable declaration line in input"); } } else if ( strstartcmp(buffer,"require") == 0 ) { re = InRequire_from_line(buffer); if( re != NULL ) { add_req_Input(out,re); } else { warn("Unreadable require line in input"); } } else if ( strstartcmp(buffer,"code") == 0 ) { if( out->code != NULL ) { warn("Two code segments in an input!"); out->code = free_Code(out->code); } out->code = read_Code_line(buffer,ifp); } else { warn("Could not understand line %s in input specification",buffer); } } return out; } Code * read_Code_line(char * line,FILE * ifp) { char buffer[MAXLINE]; Code * out; out = Code_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"endcode") == 0 ) break; } return out; } InRequire * InRequire_from_line(char * line) { InRequire * out; int i; char ** base; char ** brk; base = brk = breakstring(line,spacestr); if( *brk == NULL || strcmp(*brk,"require") == 0 ) { warn("In require - no require line!"); } for(i=1;i<5;i++) { if( brk[i] == NULL ) { warn("wrong number of arguments for require line [%s]",line); return NULL; } } out = InRequire_alloc(); out->name = stringalloc(brk[1]); out->type = stringalloc(brk[2]); strip_quote_chars(brk[3],"\""); out->help = stringalloc(brk[3]); out->tag = stringalloc(brk[4]); ckfree(base); return out; } InDeclare * InDeclare_from_line(char * line) { InDeclare * out; char * runner; char * name; char * type; runner = strtok(line,spacestr); if( strcmp(runner,"declare") != 0 ) { warn("You don't have a declaration line in %s",line); return NULL; } name = strtok(NULL,spacestr); type = strtok(NULL,spacestr); if( type == NULL ) { warn("In reading the line %s, we have no type. format problem",line); return NULL; } out = InDeclare_alloc(); out->name = stringalloc(name); out->type = stringalloc(type); return out; } wise-2.4.1/src/dyc/variable.dy0000644000175000001440000000301407313404535015544 0ustar philippusers %{ #include "wisebase.h" /********************************************************/ /* Wisetools version 3 file */ /* */ /* this file is copyright (c) Ewan Birney 1996 */ /* this file is part of the wisetools sequence analysis */ /* package */ /********************************************************/ /********************************************************/ /* Variable is a structure which is shared between */ /* compile and runtime dynamite for managing variables */ /* for fast code. The data line is only present in */ /* the run-time version */ /********************************************************/ /***** RCS Info *****************************************/ /* $Id: variable.dy,v 1.1.1.1 2001/06/18 13:59:57 birney Exp $ $Log: variable.dy,v $ Revision 1.1.1.1 2001/06/18 13:59:57 birney moved wise2 to ensembl cvs repository Revision 1.1.1.1 1998/08/28 09:30:58 birney Wise2 * Revision 1.1 1996/05/02 15:29:32 birney * Initial revision * */ /********************************************************/ #define ZERO_DIMENSION 152 #define ONE_FIXED_DIMENSION 153 #define ONE_QUERY_DIMENSION 154 #define TWO_FIXED_DIMENSION 155 #define TWO_QUERY_DIMENSION 156 %} struct MatrixVariable char * name; int type; int dim1; int dim2; char * source; void * data; !link %{ #include "variable.h" %} wise-2.4.1/src/snp/0000755000175000001440000000000010670453617013451 5ustar philippuserswise-2.4.1/src/snp/test_est.c0000644000175000001440000000701110413710424015431 0ustar philippusers#include "genotype.h" #include "locus_model_estimators.h" int main(int argc,char ** argv) { int i,j; FILE * ifp; BiGenotypeSet * bgs; LocusGenotypeCountSet * lgsc; LocusGenotypeCount * new_lgc; int randomise = 1; double sm; ModelProbabilitySet * mps_normal; ModelProbabilitySet * mps_first; ModelProbabilitySet * mps_second; ModelProbabilitySet * mps_het; double central; bgs = new_BiGenotypeSet(); ifp = openfile(argv[1],"r"); read_hapmap_genotype_file(bgs,"CEPH",ifp); fprintf(stderr," read CEPHs\n"); ifp = openfile(argv[2],"r"); read_hapmap_genotype_file(bgs,"YRI",ifp); fprintf(stderr," read YRIs\n"); ifp = openfile(argv[3],"r"); read_hapmap_genotype_file(bgs,"JAP",ifp); fprintf(stderr," read JAPs\n"); ifp = openfile(argv[4],"r"); read_hapmap_genotype_file(bgs,"HAN",ifp); fprintf(stderr," read HANs\n"); fprintf(stderr,"Read in genotypes\n"); lgsc = LocusGenotypeCountSet_from_BiGenotypeSet(bgs); fprintf(stderr,"converted to counts\n"); /* free_BiGenotypeSet(bgs); */ for(i=0;ilen;i++) { fprintf(stderr,"handling locus %d\n",i); if( seen_each_genotype_in_all_populations_LocusGenotypeCount(lgsc->lgc[i]) == FALSE ) { fprintf(stdout,"Locus %s 0 genotypes in some population\n",lgsc->lgc[i]->bl->locus_id); continue; } if( (sm = smallest_minor_allele_LocusGenotypeCount(lgsc->lgc[i])) < 0.10 ) { fprintf(stdout,"Locus %s has too small minor allele (%f)\n",lgsc->lgc[i]->bl->locus_id, sm); continue; } if( randomise ) { new_lgc = resampled_LocusGenotypeCount(lgsc->lgc[i]); } else { new_lgc = hard_link_LocusGenotypeCount(lgsc->lgc[i]); } mps_normal = estimate_model_ModelProbabilitySet(new_lgc,0.2,10,LocusModel_Normal_Multi,0.4,20); mps_first = estimate_model_ModelProbabilitySet(new_lgc,0.2,10,LocusModel_SingleHomozygous_First_Selection,0.4,20); mps_second = estimate_model_ModelProbabilitySet(new_lgc,0.2,10,LocusModel_SingleHomozygous_Second_Selection,0.4,20); mps_het = estimate_model_ModelProbabilitySet(new_lgc,0.2,10,LocusModel_Hetrozygous_Selection,0.4,20); fprintf(stdout,"Locus %s\tN: %f %.3f %.2f\t%.3f\tFirst (%.2f %.2f) %.3f\tHet: (%.2f %.2f) %.3f\tSecond (%.2f %.2f) %.3f\n", new_lgc->bl->locus_id,Score2Bits(mps_normal->best->likelihood_score),sm, chisquared_stat_LocusGenotypeCount(new_lgc), mps_normal->best->estimate_first_freq[0], mps_first->best->estimate_selection_hemi, mps_first->best->estimate_first_freq[0], Score2Bits(mps_first->best->likelihood_score - mps_normal->best->likelihood_score), mps_het->best->estimate_selection_hemi, mps_het->best->estimate_first_freq[0], Score2Bits(mps_het->best->likelihood_score - mps_normal->best->likelihood_score), mps_second->best->estimate_selection_hemi, mps_first->best->estimate_first_freq[0], Score2Bits(mps_second->best->likelihood_score - mps_normal->best->likelihood_score)); fflush(stdout); free_ModelProbabilitySet(mps_normal); free_ModelProbabilitySet(mps_first); free_ModelProbabilitySet(mps_second); free_ModelProbabilitySet(mps_het); free_LocusGenotypeCount(new_lgc); /* fprintf(stdout,"Locus %s\t%f\t",new_lgc->bl->locus_id,Score2Bits(mps->best->likelihood_score)); for(j=0;jlen;j++) { central = central_first_frequency_PopulationGenotypeCount(new_lgc->pgc[j]); fprintf(stdout,"Central: %f\tEstimate: %f\t",central,mps->best->estimate_first_freq[j]); } */ } } wise-2.4.1/src/snp/frequency_count.dy0000644000175000001440000001154210235311406017205 0ustar philippusers %{ #include "genotype.h" #include "probability.h" #define LocusGenotypeCountSetLISTLENGTH 128 #define LocusGenotypeCountLISTLENGTH 128 %} struct PopulationGenotypeCount int count[BiGenotypeLength] int defined_total Population * pop !link struct LocusGenotypeCount BiLocus * bl !link PopulationGenotypeCount ** pgc !list struct LocusGenotypeCountSet LocusGenotypeCount ** lgc !list %{ #include "frequency_count.h" double chisquared_stat_LocusGenotypeCount(LocusGenotypeCount * lgc) { double ret = 0.0; int i; for(i=0;ilen;i++) { ret += chisquared_stat_PopulationGenotypeCount(lgc->pgc[i]); } return ret; } double chisquared_stat_PopulationGenotypeCount(PopulationGenotypeCount * pgc) { double first; double second; double ret = 0.0; double diff; double expec; assert(pgc->defined_total > 5); first = central_first_frequency_PopulationGenotypeCount(pgc); if( first < 0.0000000000000001 || first > 0.999999999999999 ) { warn("Problem in chisquared statistic with central first freq at %f, returning 0.0",first); return 0.0; } second = 1.0 - first; expec = (first*first * (double)pgc->defined_total); /* fprintf(stderr,"first is %.2f, totalis %d, expect is %f\n",first,pgc->defined_total,expec);*/ assert(expec > 0.0); diff = pgc->count[BiGenotypeHomozygousFirst] - expec; ret += (diff*diff)/expec; expec = (first*second*2 * (double)pgc->defined_total); assert(expec > 0.0); diff = pgc->count[BiGenotypeHetrozygous] - expec; ret += (diff*diff)/expec; expec = (second*second * (double)pgc->defined_total); assert(expec > 0.0); diff = pgc->count[BiGenotypeHetrozygous] - expec; ret += (diff*diff)/expec; return ret; } boolean seen_each_genotype_in_all_populations_LocusGenotypeCount(LocusGenotypeCount * lgc) { int i; for(i=0;ilen;i++) { if( lgc->pgc[i]->count[BiGenotypeHomozygousFirst] == 0 || lgc->pgc[i]->count[BiGenotypeHomozygousSecond] == 0 || lgc->pgc[i]->count[BiGenotypeHetrozygous] == 0 ) { return FALSE; } } return TRUE; } double central_first_frequency_PopulationGenotypeCount(PopulationGenotypeCount * pgc) { assert(pgc != NULL); assert(pgc->defined_total > 0); return ((double)(pgc->count[BiGenotypeHomozygousFirst]*2+pgc->count[BiGenotypeHetrozygous]))/ (2*(double)(pgc->defined_total)); } double smallest_minor_allele_LocusGenotypeCount(LocusGenotypeCount * lgc) { int i; double smallest = 0.5; double central; for(i=0;ilen;i++) { central = central_first_frequency_PopulationGenotypeCount(lgc->pgc[i]); if( central > 0.5 ) { if( smallest > (1.0 - central)) { smallest = (1.0 - central); } } else { if( smallest > central ) { smallest = central; } } } return smallest; } LocusGenotypeCount * resampled_LocusGenotypeCount(LocusGenotypeCount * lgc) { int i,j; LocusGenotypeCount * out; PopulationGenotypeCount * pgc; double rnd1; double rnd2; double central; assert(lgc != NULL); out = LocusGenotypeCount_alloc_len(lgc->len); out->bl = lgc->bl; for(i=0;ilen;i++) { pgc = PopulationGenotypeCount_alloc(); pgc->count[BiGenotypeHomozygousFirst] = 0; pgc->count[BiGenotypeHetrozygous] = 0; pgc->count[BiGenotypeHomozygousSecond] = 0; central = central_first_frequency_PopulationGenotypeCount(lgc->pgc[i]); for(j=0;jpgc[i]->defined_total;j++) { rnd1 = random_0_to_1(); rnd2 = random_0_to_1(); if( rnd1 < central && rnd2 < central ) { pgc->count[BiGenotypeHomozygousFirst]++; } else if ( rnd1 > central && rnd2 > central ) { pgc->count[BiGenotypeHomozygousSecond]++; } else { pgc->count[BiGenotypeHetrozygous]++; } } pgc->defined_total = lgc->pgc[i]->defined_total; add_LocusGenotypeCount(out,pgc); } return out; } LocusGenotypeCountSet * LocusGenotypeCountSet_from_BiGenotypeSet(BiGenotypeSet * bgs) { int i; int j; int p; LocusGenotypeCount * lgc; PopulationGenotypeCount* pgc; LocusGenotypeCountSet * out; out = LocusGenotypeCountSet_alloc_len(bgs->len); for(i=0;ilen;i++) { lgc = LocusGenotypeCount_alloc_len(bgs->ps->len); lgc->bl = bgs->locus[i]->locus; for(p=0;pps->len;p++) { pgc = PopulationGenotypeCount_alloc(); pgc->pop = bgs->ps->pop[p]; add_LocusGenotypeCount(lgc,pgc); pgc->count[BiGenotypeHomozygousFirst] = 0; pgc->count[BiGenotypeHomozygousSecond] = 0; pgc->count[BiGenotypeHetrozygous] = 0; pgc->count[BiGenotypeUnknown] = 0; pgc->defined_total = 0; for(j=0;jlocus[i]->len;j++) { if( bgs->locus[i]->big[j]->person->pop != pgc->pop ) { continue; } pgc->count[bgs->locus[i]->big[j]->type]++; if( bgs->locus[i]->big[j]->type != BiGenotypeUnknown ) { pgc->defined_total++; } } } add_LocusGenotypeCountSet(out,lgc); } return out; } %} wise-2.4.1/src/snp/genotype.dy0000644000175000001440000002426710235513175015645 0ustar philippusers %{ #include "locus_framework.h" #include "person.h" #define BiGenotypeSetLISTLENGTH 128 #define BiGenotypeLocusLISTLENGTH 128 #define MAX_HAPMAP_LINE 10000 typedef struct BiGenotype { BiGenotypeType type; Person * person; } BiGenotype; #define MAX_GENOTYPE_ALLOC 1000000 #define GENOTYPE_ALLOC_LINE 4096 typedef struct BiGenotypeAllocSlab { BiGenotype * alloc_array[MAX_GENOTYPE_ALLOC]; int array_pos; int array_y; } BiGenotypeAllocSlab; %} struct BiGenotypeLocus BiGenotype ** big !list BiLocus * locus !link struct BiGenotypeSet BiGenotypeLocus ** locus !list BiLocusFramework * framework PopulationSet * ps BiGenotypeAllocSlab * slab %{ #include "genotype.h" BiGenotype * BiGenotype_alloc_slab(BiGenotypeAllocSlab * slab) { if( slab->array_y < GENOTYPE_ALLOC_LINE ) { return &(slab->alloc_array[slab->array_pos][slab->array_y++]); } if( slab->array_pos >= MAX_GENOTYPE_ALLOC ) { fatal("Asking for more genotypes than the product of MAX_GENOTYPE_ALLOC and GENOTYPE_ALLOC_LINE. Not feasible"); } slab->array_pos++; slab->alloc_array[slab->array_pos] = calloc(GENOTYPE_ALLOC_LINE,sizeof(BiGenotype)); slab->array_y = 0; return &(slab->alloc_array[slab->array_pos][slab->array_y++]); } BiGenotypeAllocSlab * new_BiGenotypeAllocSlab(void) { BiGenotypeAllocSlab * out; out = malloc(sizeof(BiGenotypeAllocSlab)); out->array_pos = 0; out->array_y = 0; out->alloc_array[0] = calloc(GENOTYPE_ALLOC_LINE,sizeof(BiGenotype)); return out; } BiGenotypeAllocSlab * free_BiGenotypeAllocSlab(BiGenotypeAllocSlab * s) { int i; for(i=0;i<= s->array_pos;i++) { free(s->alloc_array[i]); } free(s); return NULL; } BiGenotype * BiGenotype_alloc(void) { BiGenotype * out; warn("You should be using a SLAB allocation now!"); out = malloc(sizeof(BiGenotype)); return out; } BiGenotype * free_BiGenotype(BiGenotype * bi) { if( bi == NULL ){ return NULL; } free(bi); return NULL; } void write_simple_genotype(BiGenotypeSet * bgs,FILE * ofp) { int i; int j; for(i=0;ilen;i++) { fprintf(ofp,"# Locus %s\n",bgs->locus[i]->locus->locus_id); for(j=0;jlocus[i]->len;j++) { fprintf(ofp,"%s\t%s\t%s\t",bgs->locus[i]->locus->locus_id, bgs->locus[i]->big[j]->person->person_id, bgs->locus[i]->big[j]->person->pop->pop_name); if( bgs->locus[i]->big[j]->type == BiGenotypeHomozygousFirst ) { fprintf(ofp,"%c\t%c\n",bgs->locus[i]->locus->first_allele_char, bgs->locus[i]->locus->first_allele_char ); } else if ( bgs->locus[i]->big[j]->type == BiGenotypeHomozygousSecond ) { fprintf(ofp,"%c\t%c\n",bgs->locus[i]->locus->second_allele_char, bgs->locus[i]->locus->second_allele_char ); } else if ( bgs->locus[i]->big[j]->type == BiGenotypeHetrozygous ) { fprintf(ofp,"%c\t%c\n",bgs->locus[i]->locus->first_allele_char, bgs->locus[i]->locus->second_allele_char ); } else { fprintf(ofp,"N\tN\n"); } } } } boolean read_hapmap_genotype_file(BiGenotypeSet * bgs,char * pop_name,FILE * ifp) { BiLocus * bi; BiGenotypeLocus * bgl; BiGenotype * big; Population * pop; Person * p; int report_number = 2000; int count = 0; int people_flag[1028]; Person * people[1028]; int people_total; char buffer[MAX_HAPMAP_LINE]; char * runner; char * allele; char * old_locus = NULL; int i; /* first line is description of columns */ fgets(buffer,MAX_HAPMAP_LINE,ifp); runner = strtok(buffer,spacestr); i = 1; for(;runner != NULL && i < 11;runner = strtok(NULL,spacestr)) { i++; } /* runner should be "QC_code" */ if( strcmp(runner,"QC_code") != 0 ) { warn("HapMap file - first line, column 11 is not QC_code!"); return FALSE; } pop = Population_alloc_std(); pop->pop_name = stringalloc(pop_name); add_PopulationSet(bgs->ps,pop); /* count people */ people_total = 0; while( (runner = strtok(NULL,spacestr)) != NULL ) { if( strstr(runner,".dup") != NULL ) { people_flag[people_total] = 0; } else { people_flag[people_total] = 1; people[people_total] = Person_alloc(); people[people_total]->person_id = stringalloc(runner); people[people_total]->pop = pop; add_Population(pop,people[people_total]); } people_total++; } /* loop over locus lines */ while( fgets(buffer,MAX_HAPMAP_LINE,ifp) != NULL ) { runner = strtok(buffer,spacestr); if( old_locus != NULL && strcmp(old_locus,runner) == 0 ) { /* only read a locus in once! Duplications for error checking */ continue; } if( count%report_number == 0 ) { fprintf(stderr,"Handled %d loci, %s\n",count,runner); } count++; allele = strtok(NULL,spacestr); if( allele[1] != '/' ) { warn("Allele string looks all wrong %s",allele); } bi = find_or_new_BiLocus_from_BiLocusFramework(bgs->framework,runner,allele[0],allele[2]); /* this way we don't need to track old_locus memory */ old_locus = bi->locus_id; bgl = find_or_new_BiGenotypeLocus_from_BiGenotypeSet(bgs,bi); i = 2; for(;runner != NULL && i < 11;runner = strtok(NULL,spacestr)) { i++; } /* this should have QC as first two letters */ if( runner[0] != 'Q' || runner[1] != 'C' ) { warn("Column 11 does not have QC ... %s",runner); } /* now we have the people genotypes */ i = 0; for(runner = strtok(NULL,spacestr);runner != NULL; runner = strtok(NULL,spacestr)) { if( people_flag[i] == 1 ) { big = BiGenotype_alloc_slab(bgs->slab); big->type = type_from_hapmap_string_BiLocus(bi,runner); big->person = people[i]; add_BiGenotypeLocus(bgl,big); } i++; } } return TRUE; } BiGenotypeLocus * find_or_new_BiGenotypeLocus_from_BiGenotypeSet(BiGenotypeSet * bgs,BiLocus * bi) { BiGenotypeLocus * bgl; int i; for(i=0;ilen;i++) { if( bgs->locus[i]->locus == bi ) { return bgs->locus[i]; } } bgl = BiGenotypeLocus_alloc_std(); bgl->locus = bi; add_BiGenotypeSet(bgs,bgl); return bgl; } BiGenotypeSet * read_simple_genotype_file(FILE * ifp) { char buffer[MAXLINE]; BiGenotypeSet * out; BiLocus * bi; BiGenotypeLocus * bgl; BiGenotype * bg; Population * pop; Person * p; char * runner; char * locus; char * person_id; char * population_id; char * oldlocus = NULL; char * allele1; char * allele2; int no_alleles = 0; BiGenotypeType gt; char first; char second; out = new_BiGenotypeSet(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '#' ) { continue; } runner = strtok(buffer,spacestr); locus = runner; runner = strtok(NULL,spacestr); person_id = runner; runner = strtok(NULL,spacestr); population_id = runner; runner = strtok(NULL,spacestr); allele1 = runner; runner = strtok(NULL,spacestr); allele2 = runner; fprintf(stderr,"Got locus %s person %s with old %s\n",locus,person_id,oldlocus); if ( allele2 == NULL ) { continue; } /* * locus-id * person-id * allele-1 * allele-2 */ fprintf(stderr,"comparing %s vs %s with %s - %s\n",oldlocus,locus,allele1,allele2); if( oldlocus == NULL || strcmp(locus,oldlocus) != 0 ) { fprintf(stderr,"new locus, %s\n",locus); if( oldlocus != NULL ) { fprintf(stderr,"switching locus\n"); if( no_alleles != 2 ) { warn("Not good. not 2 allele locus but a %d locus with %c %c\n",no_alleles,first,second); } else { bi->first_allele_char = first; bi->second_allele_char = second; /* add this bgl */ add_BiGenotypeSet(out,bgl); } } else { fprintf(stderr,"No switch\n"); } /* make new locus data */ bgl = BiGenotypeLocus_alloc_std(); bi = BiLocus_alloc(); bi->locus_id = stringalloc(locus); bgl->locus = bi; add_BiLocusFramework(out->framework,bi); oldlocus = bi->locus_id; no_alleles = 0; first = 'U'; second = 'U'; } /* check if we've seen these alleles yet */ if( no_alleles == 0 ) { first = allele1[0]; fprintf(stderr,"Assigning from 0 alleles %c %s\n",first,allele2); if( allele2[0] != first ) { fprintf(stderr,"Assigning second allele\n"); second = allele2[0]; no_alleles = 2; } else { no_alleles = 1; } } else if ( no_alleles == 1 ) { if( first != allele1[0] ) { second = allele1[0]; no_alleles = 2; if( allele2[0] != first && allele2[0] != second ) { warn("Mismatched alleles %s,%s with %c,%c",allele1,allele2,first,second); continue; } else { /* this is fine, allele2 is either first or second allele */ } } else if( first != allele2[0] ) { second = allele2[0]; no_alleles = 2; } } else if ( (allele1[0] != first && allele1[0] != second) || (allele2[0] != first && allele2[0] != second) ) { warn("More alleles than 2 for locus %s, allele %s,%s\n",locus,allele1,allele2); continue; } fprintf(stderr,"Currently got %d alleles, %c %c\n",no_alleles,first,second); /* now figure out what genotype we have */ if( allele1[0] == first && allele2[0] == first ) { gt = BiGenotypeHomozygousFirst; } else if ( allele1[0] == second && allele2[0] == second ) { gt = BiGenotypeHomozygousSecond; } else { /* as we have checked above that it is either first or second, must be a Het */ gt = BiGenotypeHetrozygous; } bg = BiGenotype_alloc_slab(out->slab); /* check we have this population */ pop = find_or_new_Population_in_PopulationSet(out->ps,population_id); bg->person = find_or_new_Person_in_Population(pop,person_id); bg->type = gt; add_BiGenotypeLocus(bgl,bg); } if( no_alleles != 2 ) { warn("Not good. not 2 allele locus"); } else { bi->first_allele_char = first; bi->second_allele_char = second; /* add this bgl */ add_BiGenotypeSet(out,bgl); } fprintf(stderr,"Returning with %d loci\n",out->len); return out; } BiGenotypeSet * new_BiGenotypeSet(void) { BiGenotypeSet * out; out = BiGenotypeSet_alloc_std(); out->framework = new_BiLocusFramework(); out->ps = PopulationSet_alloc_std(); out->slab = new_BiGenotypeAllocSlab(); return out; } %} wise-2.4.1/src/snp/makefile0000644000175000001440000000162310235513175015144 0ustar philippusers .SUFFIXES : .dy CC = cc #CFLAGS = -c -O2 -pg -I../base/ -I../dynlibsrc/ #CFLAGS = -c -O2 -DPTHREAD -DHAS_PTHREAD_SETSCOPE -DUNIX -I../base/ -I../dynlibsrc/ -I. CFLAGS = -c -g3 -O2 -DUNIX -I../base/ -I../dynlibsrc/ -I. -pthread `glib-config --cflags` LFLAGS = -g -L../base/ -L../dynlibsrc/ -lpthread `glib-config --libs` -lpthread -lm AR_OPTIONS = ru RANLIB_NEEDED = 0 .c.o : $(CC) $(CFLAGS) $(INCFLAGS) $? test_est : test_est.o genotype.o person.o locus_framework.o locus_model_estimators.o frequency_count.o $(CC) -o test_est test_est.o genotype.o person.o locus_framework.o locus_model_estimators.o frequency_count.o ../dynlibsrc/libdyna.a ../base/libwisebase.a $(LFLAGS) INCFLAGS = -I../base/ -I../dynlibsrc/ DFLAGS = -l -D -n Wise2_ -a _api.h -b _api.t -pthreads -dbtrace 5 -nocwarn .dy.c : dyc $(DFLAGS) $< .dy.o : dyc $(DFLAGS) $< $(CC) $(CFLAGS) $*.c init : dyc $(DFLAGS) *.dy wise-2.4.1/src/snp/locus_framework.dy0000644000175000001440000000342110235513175017202 0ustar philippusers %{ #include "wisebase.h" #include "glib.h" typedef enum BiGenotypeType { BiGenotypeHomozygousFirst = 0, BiGenotypeHetrozygous, BiGenotypeHomozygousSecond, BiGenotypeUnknown, BiGenotypeError, BiGenotypeLength } BiGenotypeType; #define BiLocusFrameworkLISTLENGTH 128 %} struct BiLocus char * locus_id char first_allele_char char second_allele_char struct BiLocusFramework BiLocus ** locus !list GHashTable * hash !link %{ #include "locus_framework.h" BiGenotypeType type_from_hapmap_string_BiLocus(BiLocus * bi,char * g) { if( g[0] == bi->first_allele_char && g[1] == bi->first_allele_char ) { return BiGenotypeHomozygousFirst; } if( g[0] == bi->first_allele_char && g[1] == bi->second_allele_char ) { return BiGenotypeHetrozygous; } if( g[1] == bi->first_allele_char && g[0] == bi->second_allele_char ) { return BiGenotypeHetrozygous; } if( g[0] == bi->second_allele_char && g[1] == bi->second_allele_char ) { return BiGenotypeHomozygousSecond; } if( g[0] == 'N' && g[1] == 'N' ) { return BiGenotypeUnknown; } return BiGenotypeError; } BiLocusFramework * new_BiLocusFramework(void) { BiLocusFramework * out; out = BiLocusFramework_alloc_std(); out->hash = g_hash_table_new(g_str_hash,g_str_equal); return out; } BiLocus * find_or_new_BiLocus_from_BiLocusFramework(BiLocusFramework * bgf,char * ref_id,char first,char second) { BiLocus * out; int i; if( (out = (BiLocus*) g_hash_table_lookup(bgf->hash,(gconstpointer)ref_id)) != NULL ) { return out; } out = BiLocus_alloc(); out->locus_id = stringalloc(ref_id); out->first_allele_char = first; out->second_allele_char = second; add_BiLocusFramework(bgf,out); g_hash_table_insert(bgf->hash,(gpointer)out->locus_id,(void*)out); return out; } %} wise-2.4.1/src/snp/locus_model_estimators.dy0000644000175000001440000002514510413710424020560 0ustar philippusers %{ #include "frequency_count.h" #define ModelProbabilitySetLISTLENGTH 500 typedef enum LocusModelType { LocusModel_Normal_One, LocusModel_Normal_Multi, LocusModel_SingleHomozygous_First_Selection, LocusModel_SingleHomozygous_Second_Selection, LocusModel_Hetrozygous_Selection, LocusModel_Hemi } LocusModelType; #define MAX_POP 6 %} struct ModelProbabilityPoint double estimate_selection_hemi double estimate_first_freq[MAX_POP] Score likelihood_score struct ModelProbabilitySet LocusGenotypeCount * data !link LocusModelType type boolean keep !def="0" ModelProbabilityPoint ** mpp !list ModelProbabilityPoint * best double total_likelihood %{ #include "locus_model_estimators.h" ModelProbabilitySet * estimate_model_ModelProbabilitySet(LocusGenotypeCount * lgc,double sweep,int points,LocusModelType type,double sel_sweep,int sweep_points) { int i; int pop = lgc->len-1; int pop_point[MAX_POP]; double central[MAX_POP]; double incr; ModelProbabilityPoint mpp; ModelProbabilityPoint submpp; int overflow; ModelProbabilitySet * mps; double sweep_incr; int ii; int k; mps = ModelProbabilitySet_alloc_std(); mps->keep = 0; mps->best = ModelProbabilityPoint_alloc(); mps->best->likelihood_score = NEGI; assert(lgc != NULL); assert(lgc->len > 0); assert(sweep > 0 && sweep < 1.0); assert(points > 2); /* fprintf(stderr,"Looking at locus %s with length %d\n",lgc->bl->locus_id,lgc->len);*/ for(i=0;ilen;i++) { pop_point[i] = 0; central[i] = central_first_frequency_PopulationGenotypeCount(lgc->pgc[i]); } incr = sweep*2 / points; sweep_incr = sel_sweep*2 / sweep_points; while( 1 ) { /* we test this position first */ overflow = 0; for(i=0;ilen;i++) { mpp.estimate_first_freq[i] = central[i] - sweep + (pop_point[i]*incr); if( mpp.estimate_first_freq[i] > 1.0 || mpp.estimate_first_freq[i] < 0.0 ) { overflow = 1; } } if( overflow == 0 ) { if( type == LocusModel_Normal_Multi ) { estimate_normal_multi(lgc,&mpp); add_and_update_ModelProbabilitySet(mps,&mpp); } else { for(k=0;k < sweep_points;k++) { for(ii=0;iilen;ii++) { submpp.estimate_first_freq[ii] = mpp.estimate_first_freq[ii]; } submpp.estimate_selection_hemi = 0.0 - sel_sweep + (sweep_incr*k); switch( type ) { case LocusModel_SingleHomozygous_First_Selection : estimate_homozygous_first_selection_multi(lgc,&submpp,0); break; case LocusModel_SingleHomozygous_Second_Selection : estimate_homozygous_second_selection_multi(lgc,&submpp); break; case LocusModel_Hetrozygous_Selection : estimate_hetreozygous_selection_multi(lgc,&submpp); break; default : fatal("No model for type %d yet",type); break; } add_and_update_ModelProbabilitySet(mps,&submpp); } /* end of for (k) selection sweep */ } /* end of else is a selection type */ } else { /* overflow */ } /* we end when all populations hit position */ for(i=0;ilen;i++) { if( pop_point[i] != points ) break; } if( i >= lgc->len ) { break; } /* if we have reached here - we need to update positions * start at the end add one; if it is at position, update * next to the left and set to zero - recurse to the end */ for(i=lgc->len-1;i >= 0;i--) { if( pop_point[i] != points ) { pop_point[i]++; break; } else { pop_point[i] = 0; /* return to for loop */ } } } return mps; } void estimate_normal_multi(LocusGenotypeCount * lgc,ModelProbabilityPoint * mpp) { int i; Score sc= 0; assert(lgc != NULL); assert(mpp != NULL); for(i=0;i < lgc->len;i++) { sc += (2*Probability2Score(mpp->estimate_first_freq[i]))*lgc->pgc[i]->count[BiGenotypeHomozygousFirst] + (2*Probability2Score(1.0-mpp->estimate_first_freq[i]))*lgc->pgc[i]->count[BiGenotypeHomozygousSecond] + (Probability2Score(2*mpp->estimate_first_freq[i]*(1.0-mpp->estimate_first_freq[i])))*lgc->pgc[i]->count[BiGenotypeHetrozygous]; } /* fprintf(stderr,"For model with %f and %f, got %d\n",mpp->estimate_first_freq[0],mpp->estimate_first_freq[1],sc);*/ mpp->likelihood_score = sc; return; } void estimate_homozygous_first_selection_multi(LocusGenotypeCount * lgc,ModelProbabilityPoint * mpp,int show) { int i; Score sc= 0; double sel_prob; double rem_prob; Score first; Score het; Score second; Score first_p; Score second_p; Score het_p; assert(lgc != NULL); assert(mpp != NULL); sel_prob = 1.0-mpp->estimate_selection_hemi; rem_prob = 1.0+mpp->estimate_selection_hemi; for(i=0;i < lgc->len;i++) { first = ((Probability2Score(sel_prob)+2*Probability2Score(mpp->estimate_first_freq[i]))*lgc->pgc[i]->count[BiGenotypeHomozygousFirst]); second = (Probability2Score(rem_prob)+2*Probability2Score(1.0-mpp->estimate_first_freq[i]))*lgc->pgc[i]->count[BiGenotypeHomozygousSecond]; het = (Probability2Score(rem_prob)+Probability2Score(2*mpp->estimate_first_freq[i]*(1.0-mpp->estimate_first_freq[i])))*lgc->pgc[i]->count[BiGenotypeHetrozygous]; first_p = ((Probability2Score(rem_prob)+2*Probability2Score(mpp->estimate_first_freq[i]))*lgc->pgc[i]->count[BiGenotypeHomozygousFirst]); second_p = (Probability2Score(sel_prob)+2*Probability2Score(1.0-mpp->estimate_first_freq[i]))*lgc->pgc[i]->count[BiGenotypeHomozygousSecond]; het_p = (Probability2Score(rem_prob)+Probability2Score(2*mpp->estimate_first_freq[i]*(1.0-mpp->estimate_first_freq[i])))*lgc->pgc[i]->count[BiGenotypeHetrozygous]; if( show) { fprintf(stderr,"In pop %d\t%d %d,\t%d %d,\t%d %d\n", i, first,lgc->pgc[i]->count[BiGenotypeHomozygousFirst], het,lgc->pgc[i]->count[BiGenotypeHetrozygous], second,lgc->pgc[i]->count[BiGenotypeHomozygousSecond]); fprintf(stderr,"Prime %d\t%d %d,\t%d %d,\t%d %d\n", i, first_p,lgc->pgc[i]->count[BiGenotypeHomozygousFirst], het_p,lgc->pgc[i]->count[BiGenotypeHetrozygous], second_p,lgc->pgc[i]->count[BiGenotypeHomozygousSecond]); } sc += first + second + het; } /* fprintf(stderr,"For model with %f and %f, sel, %f got %d\n",mpp->estimate_first_freq[0],mpp->estimate_first_freq[1],sel_prob,sc);*/ mpp->likelihood_score = sc; return; } void estimate_hetreozygous_selection_multi(LocusGenotypeCount * lgc,ModelProbabilityPoint * mpp) { int i; Score sc= 0; double sel_prob; double rem_prob; Score first; Score het; Score second; assert(lgc != NULL); assert(mpp != NULL); sel_prob = 1.0-mpp->estimate_selection_hemi; rem_prob = 1.0+mpp->estimate_selection_hemi; for(i=0;i < lgc->len;i++) { first = ((Probability2Score(rem_prob)+2*Probability2Score(mpp->estimate_first_freq[i]))*lgc->pgc[i]->count[BiGenotypeHomozygousFirst]); second = (Probability2Score(rem_prob)+2*Probability2Score(1.0-mpp->estimate_first_freq[i]))*lgc->pgc[i]->count[BiGenotypeHomozygousSecond]; het = (Probability2Score(sel_prob)+Probability2Score(2*mpp->estimate_first_freq[i]*(1.0-mpp->estimate_first_freq[i])))*lgc->pgc[i]->count[BiGenotypeHetrozygous]; sc += first + second + het; } mpp->likelihood_score = sc; return; } void estimate_homozygous_second_selection_multi(LocusGenotypeCount * lgc,ModelProbabilityPoint * mpp) { int i; Score sc= 0; double sel_prob; double rem_prob; Score first; Score second; Score het; assert(lgc != NULL); assert(mpp != NULL); sel_prob = 1.0-mpp->estimate_selection_hemi; rem_prob = 1.0+mpp->estimate_selection_hemi; for(i=0;i < lgc->len;i++) { first = ((Probability2Score(rem_prob)+2*Probability2Score(mpp->estimate_first_freq[i]))*lgc->pgc[i]->count[BiGenotypeHomozygousFirst]); second = (Probability2Score(sel_prob)+2*Probability2Score(1.0-mpp->estimate_first_freq[i]))*lgc->pgc[i]->count[BiGenotypeHomozygousSecond]; het = (Probability2Score(rem_prob)+Probability2Score(2*mpp->estimate_first_freq[i]*(1.0-mpp->estimate_first_freq[i])))*lgc->pgc[i]->count[BiGenotypeHetrozygous]; sc += first + second + het; } /* fprintf(stderr,"For model with %f and %f, got %d\n",mpp->estimate_first_freq[0],mpp->estimate_first_freq[1],sc);*/ mpp->likelihood_score = sc; return; } void add_and_update_ModelProbabilitySet(ModelProbabilitySet * out,ModelProbabilityPoint * mpp) { int i; if( out->best->likelihood_score < mpp->likelihood_score ) { out->best->estimate_selection_hemi = mpp->estimate_selection_hemi; out->best->likelihood_score = mpp->likelihood_score; for(i=0;ibest->estimate_first_freq[i] = mpp->estimate_first_freq[i]; } } } ModelProbabilitySet * estimate_normal_set(LocusGenotypeCount * lgc,double sweep, double points) { int i; int first_total = 0; int defined_total = 0; double central; double incr; ModelProbabilitySet * mps; ModelProbabilityPoint * mpp; mps = ModelProbabilitySet_alloc_std(); for(i=0;ilen;i++) { first_total += (lgc->pgc[i]->count[BiGenotypeHomozygousFirst]*2 + lgc->pgc[i]->count[BiGenotypeHetrozygous]); defined_total += lgc->pgc[i]->defined_total*2; } central = (double) first_total / (double) defined_total; incr = sweep/points; mps->best = NULL; for(i=0;ilikelihood_score)); add_ModelProbabilitySet(mps,mpp); if( mps->best == NULL || mps->best->likelihood_score < mpp->likelihood_score ) { mps->best = mpp; } } for(i=0;ibest == NULL || mps->best->likelihood_score < mpp->likelihood_score ) { mps->best = mpp; } } return mps; } ModelProbabilityPoint * estimate_normal(LocusGenotypeCount * lgc,double estimate_first_freq) { int i; Score sub_likelihood; ModelProbabilityPoint * mpp; mpp = ModelProbabilityPoint_alloc(); mpp->estimate_selection_hemi = 0.0; mpp->estimate_first_freq[0] = estimate_first_freq; /* likelihood is * Prob(Data|Model) */ sub_likelihood = 0; for(i=0;ilen;i++) { sub_likelihood += (2*Probability2Score(estimate_first_freq))*lgc->pgc[i]->count[BiGenotypeHomozygousFirst] + (2*Probability2Score(1.0-estimate_first_freq))*lgc->pgc[i]->count[BiGenotypeHomozygousSecond] + (Probability2Score(estimate_first_freq*(1.0-estimate_first_freq))*lgc->pgc[i]->count[BiGenotypeHetrozygous]); } mpp->likelihood_score = sub_likelihood; return mpp; } %} wise-2.4.1/src/snp/person.dy0000644000175000001440000000254610235311406015306 0ustar philippusers %{ #include "dyna.h" #define PopulationLISTLENGTH 128 #define PopulationSetLISTLENGTH 128 %} friend Population struct Person char * person_id Population * pop !link struct Population char * pop_name Person ** person !list struct PopulationSet Population ** pop !list %{ #include "person.h" boolean is_in_Population(Population * p,char * person_id) { int i; for(i=0;ilen;i++) { if( strcmp(p->person[i]->person_id,person_id) == 0 ) { return TRUE; } } return FALSE; } Population * find_or_new_Population_in_PopulationSet(PopulationSet * ps,char * pop_name) { int i; Population * pe = NULL; assert(ps != NULL); for(i=0;ilen;i++) { if( strcmp(ps->pop[i]->pop_name,pop_name) == 0 ) { pe = ps->pop[i]; break; } } if( pe != NULL ) { return pe; } pe = Population_alloc_std(); pe->pop_name = stringalloc(pop_name); add_PopulationSet(ps,pe); return pe; } Person * find_or_new_Person_in_Population(Population * p,char * person_id) { int i; Person * pe = NULL; assert(p != NULL); for(i=0;ilen;i++) { if( strcmp(p->person[i]->person_id,person_id) == 0 ) { pe = p->person[i]; break; } } if( pe != NULL ) { return pe; } pe = Person_alloc(); pe->person_id = stringalloc(person_id); pe->pop = p; add_Population(p,pe); return pe; } %} wise-2.4.1/src/base/0000755000175000001440000000000010670453712013557 5ustar philippuserswise-2.4.1/src/base/wisestring.dy0000644000175000001440000003624007313404532016314 0ustar philippusers %{ #include "wisebase.h" /**********************************************/ /* useful macros to put into fprintf lines... */ /* Makes sure you don't trash memory etc */ /**********************************************/ #define CHECKSTRING(str) (str == NULL ? "NullString" : str) #define CKS CHECKSTRING /**********************************************/ /* useful standard strings for parsing */ /* spacestr is general whitespace */ /* breakstr is general non alpha/num */ /* used alot in breakstring */ /**********************************************/ #define spacestr " \t\n\0" #define breakstr "!\"#$%^&*()-+={}[]@';:?/.,\\|~` \n\t" /**********************************************/ /* Not the nicest of macros. Stay away from it*/ /**********************************************/ #define NEXTWORD strtok(NULL,spacestr) %} %{ #include "wisestring.h" %func handy: pass a string like "xxx/yyy/zzz" and a query like yyy, will return 2 (ie, maps positions in slashed string with a number from start). Returns -1 if none %% int get_number_from_slashed_string(char * qstr,char * slashstr) { char * runner; char * stop; int ret; /*** if the qstr is not in there, then we can get out! **/ if( (stop=strstr(slashstr,qstr)) == NULL ) { return (-1); } /** ok, run through slashstr until we hit stop, counting slashes **/ for(ret = 0,runner=slashstr;*runner && runner < stop ;runner++) if( *runner == '/') ret++; return ret; } %func checks that strings are ints or doubles and then converts, storing value in val if val == NULL, will not store (!) Does use sensible library functions strtol... %% boolean is_integer_string(char * string,int * val) { int ret; char * end; ret = strtol(string,&end,10); if( val != NULL) *val = ret; if( isalpha(*end) ) return FALSE; return TRUE; } %func checks that strings are doubles and then converts, storing value in val if val == NULL, will not store (!) Does use sensible library functions strtod %% boolean is_double_string(char * string,double * val) { double ret; char * end; ret = strtod(string,&end); if( val != NULL) *val = ret; if( isalpha(*end) ) return FALSE; return TRUE; } %func Removes space characters around any words made soley from punc, for example this = "that" -> this="that" with space = spacestr and punc = "=" %% void compress_space_around_punc(char * buffer,char * punc,char * space) { char * runner; char * run2; runner = buffer; for(;;) { /*** find next position ***/ for(;*runner && strchr(punc,*runner) == NULL;runner++ ) ; if( *runner == '\0') break; /*** this is a puncation position ***/ /*** go back over any number of spaces ***/ for(run2 = runner - 1;run2 >= buffer && strchr(space,*run2) != NULL;run2--) ; /*** run2 now at first non space position after runner ***/ if( run2 != buffer && run2+1 < runner ) { /*** we have some spaces to remove ***/ strcpy(run2+1,runner); runner = run2+1; /** runner now at first punc position **/ } for(;*runner && strchr(punc,*runner) != NULL;runner++) ; if( *runner == '\0') break; run2 = runner; /*** run2 at position after last punc ***/ for(;*runner && strchr(space,*runner) != NULL;runner++) ; if( run2 != runner ) { strcpy(run2,runner); } runner = run2; } } %func useful strip functions to remove nasty chars does not allocate memory, simply uses given memory, but returns the line pointer so you can use it in nested function calls %% char * striptoprint(char * line) { char * run; char * base; if( line == NULL ) return NULL; base = run = line; for(;*line;line++) if( isprint(*line) ) *(run++) = *line; *run = '\0'; return base; } %func takes str's of type "xxxxx" and gives back xxxxxx . stringalloc'd piece so make sure you free it %% char * stringalloc_next_quoted_string(char * buffer) { char c; char * base; char * ret; for(;*buffer && *buffer != '"';buffer++) ; if( ! *buffer ) return NULL; for(base=buffer+1,buffer++;*buffer && *buffer != '"';buffer++) ; if( !*buffer ) return NULL; c = *buffer; *buffer = '\0'; ret = stringalloc (base); *buffer = c; return ret; } %func sees if line starts with str, ignoring whitespace returns 0 if they match, to look like strcmp %% int strwhitestartcmp(char * line,char * str,char * whitespace) { while( strchr(whitespace,*line) != NULL ) line++; if( *line == '\0') return -(int)(*str); for(;*line == *str && *line && *str;line++,str++) ; if( *str == '\0') return 0; else return (int)(*line - *str); } %func sees if buf matches str\s in perl regex, ie a word match space defined \s returns 0 if they match to look like strcmp %% int strwordcmp(char * buf,char * str,char * space) { for(;*buf && *str && *buf == *str;buf++,str++) ; /** end of buf... get out, buf not space, get out, not end of str **/ if( *str != '\0' || strchr(space,*buf) == NULL ) return 1; return 0; } %func sees if buf starts with str. returns 0 if so, to mimic strcmp %% int strstartcmp(char * buf,char * str) { for(;*buf && *str;str++,buf++) { if( *buf > *str) return 1; else if( *buf < *str) return -1; else continue; } if( !(*str) ) return 0; return 1; } %func prints lines like _1_________ %% void print_numbered_line(int num,FILE * ofp) { register int i; fprintf(ofp,"_%d",num); if( num < 10000 ) i=4; if( num < 1000 ) i=3; if( num < 100 ) i=2; if( num < 10 ) i=1; for(;i<68;i++) fputc('_',ofp); fputc('\n',ofp); return; } %func prints _______________ (70 chars) %% void print_line(FILE * ofp) { register int i; for(i=0;i<70;i++) fputc('_',ofp); fputc('\n',ofp); return; } %func returns true if str is only made from space. Deprecated %type internal %% boolean only_whitespace(char * str,char * space) { for(;*str && strchr(space,*str) != NULL;str++) ; if( *str != '\0') return FALSE; return TRUE; } %func removes trailing newline if present %% void chop_newline(char * str) { str += strlen(str) -1; if( *str == '\n' ) { *str = '\0'; } } %func Tries to find the last 'database name' type string from a string. Does not allocate memory %% char * good_datastring_fromend(char * str) { register char * base=str; str+=strlen(str); for(str--;str >= base;str--) if( !isalnum(*str) && *str != '_' && *str != '.') break; return str == base ? base : ++str; } %func not useful %type internal %% boolean looks_like_vms(const char * str) { if ( strchr(str,':') != NULL) return TRUE; else return FALSE; } %func not useful %type internal %% boolean looks_like_unix(const char * str) { if( strchr(str,'/') != NULL) return TRUE; else return FALSE; } %func returns strcmp on the captilalised one and two bufferers (doesn't touch them). %% int estrcasecmp(char * one,char * two) { char * tempone; char * temptwo; int out; tempone=stringalloc(one); temptwo=stringalloc(two); capitalise(tempone); capitalise(temptwo); out=strcmp(tempone,temptwo); free(tempone); free(temptwo); return out; } %func useless %type internal %% char * strend(char * bu,char * se) { register char * runner; runner=strstr(bu,se); if(runner == NULL) return NULL; runner+=strlen(se); return runner; } %func Useless %type internal %% char * string_before_equality(char * string) { char * base; char * runner; runner=base=stringalloc(string); for(;*runner && *runner != '=';runner++) ; if(*runner == '\0') { free(base); return NULL; } for(runner--;isspace(*runner);runner--) ; runner++; *runner='\0'; runner=stringalloc(base); free(base); return runner; } %func supposedly gets a number from a string like xxx="12" %% int number_from_quoted_equality(char * s) { char * st; int ret; char c; for(;*s && *s != '=';s++) ; if( !*s ) return 0; for(;*s && isspace(*s);s++) ; /*** start of the number now... ***/ st = s; for(;*s && isalnum(*s);s++) ; c = *s; *s = '\0'; ret = atoi(st); *s = c; return ret; } %func supposedly gets a number from xxxx=12 %% int number_from_equality(char * string) { char * st; for(;*string && *string != '=';string++) ; if(*string == '\0') return 0; for(;isspace(*string) && *string;string++) ; st=string; for(;!isspace(*string) && *string;string++) *string='\0'; return atoi(st); } %func deprecated %type internal %% char * sub_string(char * into,char * key,char * sub) { char buffer[MAXLINE]; char * runner; char * stop; runner=buffer; while( (stop=strstr(into,key)) != NULL) { while( into != stop ) *(runner++)=(*(into++)); *runner='\0'; strcat(buffer,sub); runner=buffer+strlen(buffer); into+=strlen(key); } while( *into ) *(runner++)=(*(into++)); *(runner)='\0'; return stringalloc(buffer); } %func gets the string from xxx="yyy". Returns yyy allocated, and messes around with string %% char * string_from_quoted_equality(char * string) { return string_from_charred_equality(string,'"'); } %func gets the string from xxx="yyy" ,where " comes from the quote argument Returns yyy allocated, and messes around with string %% char * string_from_charred_equality(char * string,char quote) { char * base; for(;*string && *string != '=';string++) ; if(*string == '\0') return NULL; for(;*string && *string != quote;string++) ; if(*string == '\0') return NULL; string++; base=string; for(;*string && *string != quote;string++) ; *string='\0'; return stringalloc(base); } %func A call to /breakstring_protect(string,parsestr,"\"") %% char ** breakstring(char * string,char * parsestr) { return breakstring_protect(string,parsestr,"\""); } %func will parse out words in string using parse as white space, like strtok, but strings enclosed in characters from strpair are not taken in parsed form. breakstring = breakstring_protect(string,parse,"\""); hence will not break in double quotes unlike strtok they return char ** which is a list of char * of words the last being NULL'd They returned an alloc'd char ** which you are expected to free. Standard idiom is base=brk=breakstring(buffer,spacestr) (NB - spacestr #defin'd above ) ... do stuff using brk eg *brk = first word *(++brk) = next word last word = NULL cleanup by ckfree(base) %% char ** breakstring_protect(char * string,char * parsestr,char * strpair) { char ** outstr; int index=1; outstr=(char **) ckcalloc (128,sizeof(char *)); while( strchr(parsestr,*string) != NULL) string++; outstr[0]=string; while(*string) { if( strchr(strpair,*string) != NULL ) { auto char c; c = *string; for(string++;strchr(strpair,*string) == NULL && *string;string++) if( *string == '\\' ) string++; if( *string == '\0') { log_full_error(WARNING,0,"In breakstring_protect, reached endofline in protected string [%s]",outstr[index]); outstr[++index]=NULL; return outstr; } string++; /* shifts on one past " */ } else if( strchr(parsestr,*string) != NULL) { while( *string && strchr(parsestr,*string) != NULL) *(string++)='\0'; if( *string == '\0') break; string--; *string='\0'; outstr[index++]=string+1; string++; } else string++; } outstr[index]=NULL; return outstr; } %func removes chars in quote %% void strip_quote_chars(char * string,char * quote) { char * base =string; char * run; if( strchr(quote,*string) != NULL ) { for(string++;*string;string++) *(string-1)= (*string); *(string-1) = '\0'; } run = base+strlen(base)-1; if( strchr(quote,*run) != NULL ) *run= '\0'; } %func copies string into buffer, and if under maxlen, adds spaces. Does *not* put in '\0' %% void padstring(char * buffer,char * string,int maxlen) { for(;*string && maxlen > 0;string++,buffer++,maxlen--) *buffer=(*string); if( maxlen > 0) for(;maxlen > 0;maxlen--,buffer++) *buffer=' '; return; } %func toupper's each char in word %% void capitalise(char * word) { for(;*word;word++) *word=toupper(*word); } %func This shouws line putting a new line in every max chars, not minding word boundaries %% void show_line(char * line,int max,FILE *ofp) { int i; for(i=0;*(line+i);i++) { if( (i%max) == 0 && i != 0) fputc('\n',ofp); fputc(*(line+i),ofp); } fputc('\n',ofp); return; } %func This shouws line putting a new line in every max chars, *minding* word boundaries %% void show_text(char * line,int max,FILE *ofp) { char push; char *pushpoi; char * runner; for(runner=line;;) { for(;(int)(runner-line) < max && *runner;) { pushpoi=runner; while( *(++runner) != ' ' && *runner) ; /* NB dodgy pre ++ in above line */ } if(*runner == '\0') { if((int)(runner-line) < max) fprintf(ofp,"%s\n",line); else { push=(*pushpoi); *pushpoi='\0'; fprintf(ofp,"%s\n",line); *pushpoi=push; line=pushpoi+1; fprintf(ofp,"%s\n",line); } break; } else { push=(*pushpoi); *pushpoi='\0'; fprintf(ofp,"%s\n",line); *pushpoi=push; line=pushpoi+1; runner=line; } } return; } %func returns the second word alloc'd for xxx yyyy returns yyyy. %% char * second_word_alloc(char * str,char * space) { char * out; char c; for(;*str && strchr(space,*str) == NULL;str++) ; if( *str == '\0') { warn("Can only find one word in [%s] - certainly can't alloc the second",str); return NULL; } for(str++;*str && strchr(space,*str) != NULL;str++) ; out=str; for(;*str && strchr(space,*str) == NULL;str++) ; c = *str; *str ='\0'; out = stringalloc(out); *str= c; return out; } %func Don't use this sprintf's then allocs %% char * stringallocf(char * str,...) { char buffer[1024]; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); return stringalloc(buffer); } %func returns the allocated copy of c. Usually called strdup in other packages %% char * stringalloc(char * c) { register int i; register char * temp; if(c == NULL) { warn("Passed stringalloc a NULL pointer"); return NULL; } i = strlen(c); if((temp=(char *)ckalloc(sizeof(char)*(i+1))) == NULL) { warn("stringalloc unable to allocate memory"); return NULL; } strcpy(temp,c); return temp; } %} wise-2.4.1/src/base/wiseoverlay.dy0000755000175000001440000000207107313404532016465 0ustar philippusers %{ #include "wisebase.h" %} %{ #include "wiseoverlay.h" static boolean isinuse=FALSE; static FILE * overlay = NULL; static int delete_len=0; %func actually starts on overlay system on the FILE*. Should really by stderr... nothing else makes sense. %% void start_overlay(FILE * over) { overlay=over; isinuse=TRUE; } %func finishes an overlay system by putting in a newline and clearing the static variables %% void stop_overlay(void) { fprintf(overlay,"\n"); delete_len=0; overlay=NULL; isinuse=FALSE; } %func Does the business. Deletes the previous message with \b and then prints the current one ontop. don't put in \n's otherwise this is going to look yukky ;) %% void print_overlay(char * msg, ... ) { char buffer[512]; va_list ap; register int i; if( isinuse == FALSE) /* error message */ return; va_start(ap,msg); for(i=0;i= *argc ) { warn("In processing command line [%s], tag [%s] expects an argument",argv[0],tag); return NULL; /* give 'em nothing */ } /* assign return value */ ret = argv[i+1]; /* ok, now remove both tag and argument from the line */ memmove(argv+i,argv+i+2,sizeof(char *)*(*argc - i -2)); *argc -= 2; /* return */ return ret; } } return NULL; } %func This removes argument in tag from the commandline if there, and looks at the argument as whether it is an int or not. No tag - returns FALSE and leaves value alone Tag but no integer value - issues warning, returns FALSE tag but integer value - sets value, returns true %arg argc argc from main declaration (call as &argc) argv argv from main declaration tag r -[string] argument to find value w int pointer to write value to %% boolean strip_out_integer_argument(int * argc,char ** argv,char * tag,int * value) { char * arg; if( (arg = strip_out_assigned_argument(argc,argv,tag)) == NULL ) return FALSE; if( is_integer_string(arg,value) == FALSE ) { warn("Argument [%s] to [%s] is not an integer. Not changing the value [%d]",arg,tag,value); return FALSE; } return TRUE; } %func This removes argument in tag from the commandline if there, and looks at the argument as whether it is a double or not. No tag - returns FALSE and leaves value alone Tag but no integer value - issues warning, returns FALSE tag but integer value - sets value, returns true %arg argc argc from main declaration (call as &argc) argv argv from main declaration tag r -[string] argument to find value w double pointer to write value to %% boolean strip_out_float_argument(int * argc,char ** argv,char * tag,double * value) { char * arg; if( (arg = strip_out_assigned_argument(argc,argv,tag)) == NULL ) return FALSE; if( is_double_string(arg,value) == FALSE ) { warn("Argument [%s] to [%s] is not a double. Not changing the value [%f]",arg,tag,value); return FALSE; } return TRUE; } %func Shows standard options %% void show_standard_options(FILE * ofp) { fprintf(ofp,"Standard options\n"); fprintf(ofp," -help help\n"); fprintf(ofp," -version show version and compile info\n"); fprintf(ofp," -silent No messages on stderr\n"); fprintf(ofp," -quiet No report/info on stderr\n"); fprintf(ofp," -erroroffstd No warning messages to stderr\n"); fprintf(ofp," -errorlog [file] Log warning messages to file\n"); fprintf(ofp," -errorstyle [server/program] style of error reporting (default program)\n"); } %func Handles default arguments correctly, setting help,version,errors handling %% void strip_out_standard_options(int * argc,char ** argv,void (*show_help)(FILE * ofp),void (*show_version)(FILE * ofp)) { char * errlog; char * temp; if( (strip_out_boolean_argument(argc,argv,"help")) == TRUE ) { (*show_help)(stdout); exit(1); } if( (strip_out_boolean_argument(argc,argv,"version")) == TRUE ) { (*show_version)(stdout); exit(1); } if( (strip_out_boolean_argument(argc,argv,"silent")) == TRUE ) { erroroff(REPORT); erroroff(INFO); erroroff(WARNING); } if( (strip_out_boolean_argument(argc,argv,"quiet")) == TRUE ) { erroroff(REPORT); erroroff(INFO); } if( (strip_out_boolean_argument(argc,argv,"erroroffstd")) == TRUE ) { errorstderroff(WARNING); } if( (temp = strip_out_assigned_argument(argc,argv,"errorstyle")) != NULL ) { if( strcmp(temp,"server") == 0 ) { set_error_display_style(ERROR_DISPLAY_SERVER); } else if ( strcmp(temp,"program") == 0 ) { set_error_display_style(ERROR_DISPLAY_PROGRAM); } else { fprintf(stderr,"Unknown errorstyle %s",temp); } } set_log_display_string(argv[0]); if( (errlog=strip_out_assigned_argument(argc,argv,"errlog")) != NULL ) { if( add_log_filename(errlog) == FALSE ) { fatal("Could not use %s as a error log file\n",errlog); } else { warn("Logging errors to %s as well as stderr",errlog); errorlogon(WARNING); } } } %} wise-2.4.1/src/base/wiseoverlay.c0000644000175000001440000000317110670453712016276 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "wiseoverlay.h" static boolean isinuse=FALSE; static FILE * overlay = NULL; static int delete_len=0; /* Function: start_overlay(over) * * Descrip: actually starts on overlay system * on the FILE*. Should really by stderr... * nothing else makes sense. * * * Arg: over [UNKN ] Undocumented argument [FILE *] * */ # line 22 "wiseoverlay.dy" void start_overlay(FILE * over) { overlay=over; isinuse=TRUE; } /* Function: stop_overlay(void) * * Descrip: finishes an overlay system by putting in a * newline and clearing the static variables * * * */ # line 32 "wiseoverlay.dy" void stop_overlay(void) { fprintf(overlay,"\n"); delete_len=0; overlay=NULL; isinuse=FALSE; } /* Function: print_overlay(msg,) * * Descrip: Does the business. Deletes the previous * message with \b and then prints the current * one ontop. * * don't put in \n's otherwise this is going to * look yukky ;) * * * Arg: msg [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * */ # line 48 "wiseoverlay.dy" void print_overlay(char * msg, ... ) { char buffer[512]; va_list ap; register int i; if( isinuse == FALSE) /* error message */ return; va_start(ap,msg); for(i=0;i /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: now_string(void) * * Descrip: returns a buffer * of the current date and time * * * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_now_string(void); #define now_string Wise2_now_string /* Function: time_stamp(ofp) * * Descrip: puts now_string into file, with * no newline * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_time_stamp(FILE * ofp); #define time_stamp Wise2_time_stamp /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/base/linesubs.c0000644000175000001440000000747710670453712015566 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "linesubs.h" /* this module is a little hacky... */ /* It has buffers for loading in lines */ /* and will edit them with the keys given */ #define MAXEDITLINE 512 #define MAXREPLACEMENT 256 static char input[MAXEDITLINE]; static char output[MAXEDITLINE]; static KeyandReplace kandr[MAXREPLACEMENT]; static int size = 0; static int nest=0; # line 33 "linesubs.dy" void scan_and_replace(KeyandReplace * kr) { char * runner; char * run2; char * o; if( (runner=strstr(input,kr->key)) == NULL) return; /* nothing to do */ if( nest > 100 ) { warn("scan and replaced one line more than 100 times; dropping out!"); return; } /*** copy upto runner in input ***/ for(run2=input,o=output; run2 < runner && *run2 != '\0';) *(o++)=(*(run2++)); /*** copy replace into output ***/ for(run2=kr->replace; *run2 != '\0';) *(o++)=(*(run2++)); /*** find end of key ***/ runner += strlen(kr->key); /*** copy rest of string into output ****/ for(run2=runner; *run2 != '\0';) *(o++)=(*(run2++)); /*** add terminal 0 ****/ *o = '\0'; /*** move back to input ***/ strcpy(input,output); /*** call again in case there are more to do ***/ nest++; scan_and_replace(kr); return; } # line 84 "linesubs.dy" char * scan_and_replace_line(char * line) { register int i; /*** load in line ***/ strcpy(input,line); for(i=0;i MAXREPLACEMENT ) { log_full_error(WARNING,0,"Scan and replace overflow for %s key\n",key); return FALSE; } kandr[size].key = stringalloc(key); kandr[size].replace = stringalloc(replace); size++; return TRUE; } # line 120 "linesubs.dy" boolean pop_scan_and_replace_pair(void) { if( size == 0 ) { warn("Attempting to pop an empty scan and replace stack"); return FALSE; } ckfree(kandr[size-1].key); ckfree(kandr[size-1].replace); size--; return TRUE; } # line 134 "linesubs.dy" void flush_scan_and_replace(void) { register int i; for(i=0;i < size;i++) { ckfree(kandr[i].key); ckfree(kandr[i].replace); } size = 0; return; } # line 148 "linesubs.dy" void read_plain_scan_and_replace(char * filename) { FILE * ifp; ifp = openfile(filename,"r"); if( ifp == NULL ) { log_full_error(WARNING,0,"Cannot open filename %s \n",filename); return; } read_scan_and_replace_file(ifp,"endofscanfile"); fclose(ifp); return; } # line 167 "linesubs.dy" void read_scan_and_replace_file(FILE * ifp,char * endstring) { char buffer[MAXLINE]; char ** base,**brk; char * key; char * runner; while( fgets(buffer,MAXLINE,ifp) != NULL) { /* fprintf(stderr,"Read line %s\n",buffer); */ if( endstring != NULL && endstring[0] != '\0' && strstartcmp(buffer,endstring) == 0) break; if( buffer[0] == '#' || buffer[0] == '!') continue; base = brk = breakstring_protect(buffer,spacestr,"@"); if( base == NULL || *brk == NULL ) { log_full_error(WARNING,0,"Picked up problem in read scan and replace file"); continue; } key = *brk; brk++; if( *brk == NULL ) { log_full_error(WARNING,0,"Picked up problem in read scan and replace file key %s has no replace",key); continue; } if( **brk == '@' ) (*brk)++; runner = (*brk) + strlen((*brk)); runner--; if( *runner == '@') *runner = '\0'; push_scan_and_replace_pair(key,*brk); ckfree(base); } return; } # line 225 "linesubs.c" #ifdef _cplusplus } #endif wise-2.4.1/src/base/linesubs.h0000644000175000001440000000312210670453712015552 0ustar philippusers#ifndef DYNAMITElinesubsHEADERFILE #define DYNAMITElinesubsHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" typedef struct { char * key; char * replace; } KeyandReplace; /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_scan_and_replace(KeyandReplace * kr); #define scan_and_replace Wise2_scan_and_replace char * Wise2_scan_and_replace_line(char * line); #define scan_and_replace_line Wise2_scan_and_replace_line boolean Wise2_push_scan_and_replace_pair(char * key,char * replace); #define push_scan_and_replace_pair Wise2_push_scan_and_replace_pair boolean Wise2_pop_scan_and_replace_pair(void); #define pop_scan_and_replace_pair Wise2_pop_scan_and_replace_pair void Wise2_flush_scan_and_replace(void); #define flush_scan_and_replace Wise2_flush_scan_and_replace void Wise2_read_plain_scan_and_replace(char * filename); #define read_plain_scan_and_replace Wise2_read_plain_scan_and_replace void Wise2_read_scan_and_replace_file(FILE * ifp,char * endstring); #define read_scan_and_replace_file Wise2_read_scan_and_replace_file /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/base/wisestreaminterface.c0000644000175000001440000001310210670453712017764 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "wisestreaminterface.h" /* Function: read_buffer_FILE_impl(handle,input_buffer,maxsize) * * Descrip: Implementation function for normal files for reading * * * Arg: handle [UNKN ] Undocumented argument [void *] * Arg: input_buffer [UNKN ] Undocumented argument [char *] * Arg: maxsize [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [char *] * */ # line 40 "wisestreaminterface.dy" char * read_buffer_FILE_impl(void * handle,char * input_buffer,int maxsize) { char * ret; FILE * ifp = (FILE *)handle; ret = fgets(input_buffer,maxsize,ifp); return ret; } /* Function: is_end_FILE_impl(handle) * * Descrip: Implementation function for normal files for end flag * * * Arg: handle [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 53 "wisestreaminterface.dy" boolean is_end_FILE_impl(void * handle) { FILE * ifp = (FILE *)handle; if( feof(ifp) ) { return TRUE; } else { return FALSE; } } /* Function: close_and_free_FILE_impl(handle) * * Descrip: Implementation function for normal files for closing. Works for both * reading and writing * * * Arg: handle [UNKN ] Undocumented argument [void *] * */ # line 68 "wisestreaminterface.dy" void close_and_free_FILE_impl(void * handle) { FILE * ifp = (FILE *)handle; fclose(ifp); } /* Function: ReadStream_from_FILE(ifp) * * Descrip: Makes a Wise2ReadStream interface from a normal C filehandle * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [Wise2ReadStreamInterface *] * */ # line 78 "wisestreaminterface.dy" Wise2ReadStreamInterface * ReadStream_from_FILE(FILE * ifp) { Wise2ReadStreamInterface * out; out = malloc(sizeof(Wise2ReadStreamInterface)); out->read_buffer = read_buffer_FILE_impl; out->is_end = is_end_FILE_impl; out->close_and_free_handle = close_and_free_FILE_impl; out->handle = (void*) ifp; return out; } /* Function: ReadStream_openfile(filename) * * Descrip: opens a file from filename and gives back a ReadStream, * NULL if unable to return * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Wise2ReadStreamInterface *] * */ # line 95 "wisestreaminterface.dy" Wise2ReadStreamInterface * ReadStream_openfile(char * filename) { FILE * ifp; assert(filename != NULL); ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Unable to open file %s",filename); return NULL; } return ReadStream_from_FILE(ifp); } /* Function: write_buffer_FILE_impl(handle,string) * * Descrip: implementation for normal C files for string writing * * * Arg: handle [UNKN ] Undocumented argument [void *] * Arg: string [UNKN ] Undocumented argument [char *] * */ # line 113 "wisestreaminterface.dy" void write_buffer_FILE_impl(void * handle,char * string) { FILE * ifp = (FILE *)handle; fputs(string,ifp); return; } /* Function: write_bufferf_FILE_impl(handle,format,) * * Descrip: implementation for normal C files for formatted writing * * * Arg: handle [UNKN ] Undocumented argument [void *] * Arg: format [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * */ # line 125 "wisestreaminterface.dy" void write_bufferf_FILE_impl(void * handle,char * format,...) { FILE * ifp = (FILE *)handle; char buffer[1024]; va_list ap; va_start(ap,format); vsprintf(buffer,format,ap); fputs(buffer,ifp); return; } /* Function: WriteStream_from_FILE(ofp) * * Descrip: makes a WriteStream from a normal C FILE structure * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [Wise2WriteStreamInterface *] * */ # line 143 "wisestreaminterface.dy" Wise2WriteStreamInterface * WriteStream_from_FILE(FILE * ofp) { Wise2WriteStreamInterface * out; out = malloc(sizeof(Wise2WriteStreamInterface)); out->write_buffer = write_buffer_FILE_impl; out->write_bufferf = write_bufferf_FILE_impl; out->close_and_free_handle = close_and_free_FILE_impl; out->handle = (void*) ofp; return out; } /* Function: WriteStream_openfile(filename) * * Descrip: opens a file from filename and gives back a WriteStream, * NULL if unable to return * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Wise2WriteStreamInterface *] * */ # line 160 "wisestreaminterface.dy" Wise2WriteStreamInterface * WriteStream_openfile(char * filename) { FILE * ofp; assert(filename != NULL); ofp = openfile(filename,"w"); if( ofp == NULL ) { warn("Unable to open file %s",filename); return NULL; } return WriteStream_from_FILE(ofp); } /* Function: cat_ReadStream_into_WriteStream(rs,ws) * * Descrip: helper function - cats one stream into another * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ # line 177 "wisestreaminterface.dy" void cat_ReadStream_into_WriteStream(Wise2ReadStreamInterface * rs,Wise2WriteStreamInterface * ws) { char str[1024]; while( (*rs->is_end)(rs->handle) != TRUE ) { if( (*rs->read_buffer)(rs->handle,str,1024) == NULL ) { return; } (*ws->write_buffer)(ws->handle,str); } } # line 220 "wisestreaminterface.c" #ifdef _cplusplus } #endif wise-2.4.1/src/base/wisestreaminterface.h0000644000175000001440000001267610670453712020010 0ustar philippusers#ifndef DYNAMITEwisestreaminterfaceHEADERFILE #define DYNAMITEwisestreaminterfaceHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" typedef struct Wise2_Stream_Read_Interface { char* (*read_buffer)(void *,char*,int); boolean (*is_end)(void*); void (*close_and_free_handle)(void *); void * handle; } Wise2ReadStreamInterface; typedef struct Wise2_Stream_Write_Interface { void (*write_buffer)(void *,char*); void (*write_bufferf)(void *,char*,...); void (*close_and_free_handle)(void *); void * handle; } Wise2WriteStreamInterface; #define WISE2_READ_BUFFER(buffer,length,ri) ((*ri->read_buffer)(ri->handle,buffer,length)) #define WISE2_WRITE_STRING(string,wi) ((*wi->write_buffer)(wi->handle,string)) /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: read_buffer_FILE_impl(handle,input_buffer,maxsize) * * Descrip: Implementation function for normal files for reading * * * Arg: handle [UNKN ] Undocumented argument [void *] * Arg: input_buffer [UNKN ] Undocumented argument [char *] * Arg: maxsize [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_read_buffer_FILE_impl(void * handle,char * input_buffer,int maxsize); #define read_buffer_FILE_impl Wise2_read_buffer_FILE_impl /* Function: is_end_FILE_impl(handle) * * Descrip: Implementation function for normal files for end flag * * * Arg: handle [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_end_FILE_impl(void * handle); #define is_end_FILE_impl Wise2_is_end_FILE_impl /* Function: close_and_free_FILE_impl(handle) * * Descrip: Implementation function for normal files for closing. Works for both * reading and writing * * * Arg: handle [UNKN ] Undocumented argument [void *] * */ void Wise2_close_and_free_FILE_impl(void * handle); #define close_and_free_FILE_impl Wise2_close_and_free_FILE_impl /* Function: ReadStream_from_FILE(ifp) * * Descrip: Makes a Wise2ReadStream interface from a normal C filehandle * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [Wise2ReadStreamInterface *] * */ Wise2ReadStreamInterface * Wise2_ReadStream_from_FILE(FILE * ifp); #define ReadStream_from_FILE Wise2_ReadStream_from_FILE /* Function: ReadStream_openfile(filename) * * Descrip: opens a file from filename and gives back a ReadStream, * NULL if unable to return * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Wise2ReadStreamInterface *] * */ Wise2ReadStreamInterface * Wise2_ReadStream_openfile(char * filename); #define ReadStream_openfile Wise2_ReadStream_openfile /* Function: write_buffer_FILE_impl(handle,string) * * Descrip: implementation for normal C files for string writing * * * Arg: handle [UNKN ] Undocumented argument [void *] * Arg: string [UNKN ] Undocumented argument [char *] * */ void Wise2_write_buffer_FILE_impl(void * handle,char * string); #define write_buffer_FILE_impl Wise2_write_buffer_FILE_impl /* Function: write_bufferf_FILE_impl(handle,format,) * * Descrip: implementation for normal C files for formatted writing * * * Arg: handle [UNKN ] Undocumented argument [void *] * Arg: format [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * */ void Wise2_write_bufferf_FILE_impl(void * handle,char * format,...); #define write_bufferf_FILE_impl Wise2_write_bufferf_FILE_impl /* Function: WriteStream_from_FILE(ofp) * * Descrip: makes a WriteStream from a normal C FILE structure * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [Wise2WriteStreamInterface *] * */ Wise2WriteStreamInterface * Wise2_WriteStream_from_FILE(FILE * ofp); #define WriteStream_from_FILE Wise2_WriteStream_from_FILE /* Function: WriteStream_openfile(filename) * * Descrip: opens a file from filename and gives back a WriteStream, * NULL if unable to return * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Wise2WriteStreamInterface *] * */ Wise2WriteStreamInterface * Wise2_WriteStream_openfile(char * filename); #define WriteStream_openfile Wise2_WriteStream_openfile /* Function: cat_ReadStream_into_WriteStream(rs,ws) * * Descrip: helper function - cats one stream into another * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ void Wise2_cat_ReadStream_into_WriteStream(Wise2ReadStreamInterface * rs,Wise2WriteStreamInterface * ws); #define cat_ReadStream_into_WriteStream Wise2_cat_ReadStream_into_WriteStream /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/base/wisestring.c0000644000175000001440000005612410670453712016131 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "wisestring.h" /* Function: get_number_from_slashed_string(qstr,slashstr) * * Descrip: handy: pass a string like "xxx/yyy/zzz" * and a query like yyy, will return 2 * (ie, maps positions in slashed string with * a number from start). Returns -1 if none * * * Arg: qstr [UNKN ] Undocumented argument [char *] * Arg: slashstr [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 41 "wisestring.dy" int get_number_from_slashed_string(char * qstr,char * slashstr) { char * runner; char * stop; int ret; /*** if the qstr is not in there, then we can get out! **/ if( (stop=strstr(slashstr,qstr)) == NULL ) { return (-1); } /** ok, run through slashstr until we hit stop, counting slashes **/ for(ret = 0,runner=slashstr;*runner && runner < stop ;runner++) if( *runner == '/') ret++; return ret; } /* Function: is_integer_string(string,val) * * Descrip: checks that strings are ints or doubles * and then converts, storing value in val * if val == NULL, will not store (!) * * Does use sensible library functions * strtol... * * * Arg: string [UNKN ] Undocumented argument [char *] * Arg: val [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 71 "wisestring.dy" boolean is_integer_string(char * string,int * val) { int ret; char * end; ret = strtol(string,&end,10); if( val != NULL) *val = ret; if( isalpha(*end) ) return FALSE; return TRUE; } /* Function: is_double_string(string,val) * * Descrip: checks that strings are doubles * and then converts, storing value in val * if val == NULL, will not store (!) * * Does use sensible library functions * strtod * * * Arg: string [UNKN ] Undocumented argument [char *] * Arg: val [UNKN ] Undocumented argument [double *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 95 "wisestring.dy" boolean is_double_string(char * string,double * val) { double ret; char * end; ret = strtod(string,&end); if( val != NULL) *val = ret; if( isalpha(*end) ) return FALSE; return TRUE; } /* Function: compress_space_around_punc(buffer,punc,space) * * Descrip: No Description * * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: punc [UNKN ] Undocumented argument [char *] * Arg: space [UNKN ] Undocumented argument [char *] * */ # line 118 "wisestring.dy" void compress_space_around_punc(char * buffer,char * punc,char * space) { char * runner; char * run2; runner = buffer; for(;;) { /*** find next position ***/ for(;*runner && strchr(punc,*runner) == NULL;runner++ ) ; if( *runner == '\0') break; /*** this is a puncation position ***/ /*** go back over any number of spaces ***/ for(run2 = runner - 1;run2 >= buffer && strchr(space,*run2) != NULL;run2--) ; /*** run2 now at first non space position after runner ***/ if( run2 != buffer && run2+1 < runner ) { /*** we have some spaces to remove ***/ strcpy(run2+1,runner); runner = run2+1; /** runner now at first punc position **/ } for(;*runner && strchr(punc,*runner) != NULL;runner++) ; if( *runner == '\0') break; run2 = runner; /*** run2 at position after last punc ***/ for(;*runner && strchr(space,*runner) != NULL;runner++) ; if( run2 != runner ) { strcpy(run2,runner); } runner = run2; } } /* Function: striptoprint(line) * * Descrip: useful strip functions to remove nasty chars * does not allocate memory, simply uses * given memory, but returns the line pointer * so you can use it in nested function calls * * * Arg: line [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 171 "wisestring.dy" char * striptoprint(char * line) { char * run; char * base; if( line == NULL ) return NULL; base = run = line; for(;*line;line++) if( isprint(*line) ) *(run++) = *line; *run = '\0'; return base; } /* Function: stringalloc_next_quoted_string(buffer) * * Descrip: takes str's of type "xxxxx" * and gives back xxxxxx . * stringalloc'd piece so make sure you free it * * * Arg: buffer [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 195 "wisestring.dy" char * stringalloc_next_quoted_string(char * buffer) { char c; char * base; char * ret; for(;*buffer && *buffer != '"';buffer++) ; if( ! *buffer ) return NULL; for(base=buffer+1,buffer++;*buffer && *buffer != '"';buffer++) ; if( !*buffer ) return NULL; c = *buffer; *buffer = '\0'; ret = stringalloc (base); *buffer = c; return ret; } /* Function: strwhitestartcmp(line,str,whitespace) * * Descrip: sees if line starts with str, ignoring whitespace * * returns 0 if they match, to look like strcmp * * * Arg: line [UNKN ] Undocumented argument [char *] * Arg: str [UNKN ] Undocumented argument [char *] * Arg: whitespace [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 226 "wisestring.dy" int strwhitestartcmp(char * line,char * str,char * whitespace) { while( strchr(whitespace,*line) != NULL ) line++; if( *line == '\0') return -(int)(*str); for(;*line == *str && *line && *str;line++,str++) ; if( *str == '\0') return 0; else return (int)(*line - *str); } /* Function: strwordcmp(buf,str,space) * * Descrip: sees if buf matches str\s in perl regex, ie * a word match * * space defined \s * * returns 0 if they match to look like strcmp * * * Arg: buf [UNKN ] Undocumented argument [char *] * Arg: str [UNKN ] Undocumented argument [char *] * Arg: space [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 251 "wisestring.dy" int strwordcmp(char * buf,char * str,char * space) { for(;*buf && *str && *buf == *str;buf++,str++) ; /** end of buf... get out, buf not space, get out, not end of str **/ if( *str != '\0' || strchr(space,*buf) == NULL ) return 1; return 0; } /* Function: strstartcmp(buf,str) * * Descrip: sees if buf starts with str. * * returns 0 if so, to mimic strcmp * * * Arg: buf [UNKN ] Undocumented argument [char *] * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 269 "wisestring.dy" int strstartcmp(char * buf,char * str) { for(;*buf && *str;str++,buf++) { if( *buf > *str) return 1; else if( *buf < *str) return -1; else continue; } if( !(*str) ) return 0; return 1; } /* Function: print_numbered_line(num,ofp) * * Descrip: prints lines like _1_________ * * * Arg: num [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 288 "wisestring.dy" void print_numbered_line(int num,FILE * ofp) { register int i; fprintf(ofp,"_%d",num); if( num < 10000 ) i=4; if( num < 1000 ) i=3; if( num < 100 ) i=2; if( num < 10 ) i=1; for(;i<68;i++) fputc('_',ofp); fputc('\n',ofp); return; } /* Function: print_line(ofp) * * Descrip: prints _______________ (70 chars) * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 310 "wisestring.dy" void print_line(FILE * ofp) { register int i; for(i=0;i<70;i++) fputc('_',ofp); fputc('\n',ofp); return; } /* Function: only_whitespace(str,space) * * Descrip: returns true if str is only made from space. * * Deprecated * * * Arg: str [UNKN ] Undocumented argument [char *] * Arg: space [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 325 "wisestring.dy" boolean only_whitespace(char * str,char * space) { for(;*str && strchr(space,*str) != NULL;str++) ; if( *str != '\0') return FALSE; return TRUE; } /* Function: chop_newline(str) * * Descrip: removes trailing newline if present * * * Arg: str [UNKN ] Undocumented argument [char *] * */ # line 337 "wisestring.dy" void chop_newline(char * str) { str += strlen(str) -1; if( *str == '\n' ) { *str = '\0'; } } /* Function: good_datastring_fromend(str) * * Descrip: Tries to find the last 'database name' * type string from a string. * * Does not allocate memory * * * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 352 "wisestring.dy" char * good_datastring_fromend(char * str) { register char * base=str; str+=strlen(str); for(str--;str >= base;str--) if( !isalnum(*str) && *str != '_' && *str != '.') break; return str == base ? base : ++str; } /* Function: looks_like_vms(str) * * Descrip: not useful * * * Arg: str [UNKN ] Undocumented argument [const char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 367 "wisestring.dy" boolean looks_like_vms(const char * str) { if ( strchr(str,':') != NULL) return TRUE; else return FALSE; } /* Function: looks_like_unix(str) * * Descrip: not useful * * * Arg: str [UNKN ] Undocumented argument [const char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 378 "wisestring.dy" boolean looks_like_unix(const char * str) { if( strchr(str,'/') != NULL) return TRUE; else return FALSE; } /* Function: estrcasecmp(one,two) * * Descrip: returns strcmp on the captilalised * one and two bufferers (doesn't touch them). * * * Arg: one [UNKN ] Undocumented argument [char *] * Arg: two [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 389 "wisestring.dy" int estrcasecmp(char * one,char * two) { char * tempone; char * temptwo; int out; tempone=stringalloc(one); temptwo=stringalloc(two); capitalise(tempone); capitalise(temptwo); out=strcmp(tempone,temptwo); free(tempone); free(temptwo); return out; } /* Function: strend(bu,se) * * Descrip: useless * * * Arg: bu [UNKN ] Undocumented argument [char *] * Arg: se [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 413 "wisestring.dy" char * strend(char * bu,char * se) { register char * runner; runner=strstr(bu,se); if(runner == NULL) return NULL; runner+=strlen(se); return runner; } /* Function: string_before_equality(string) * * Descrip: Useless * * * Arg: string [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 431 "wisestring.dy" char * string_before_equality(char * string) { char * base; char * runner; runner=base=stringalloc(string); for(;*runner && *runner != '=';runner++) ; if(*runner == '\0') { free(base); return NULL; } for(runner--;isspace(*runner);runner--) ; runner++; *runner='\0'; runner=stringalloc(base); free(base); return runner; } /* Function: number_from_quoted_equality(s) * * Descrip: supposedly gets a number from a * string like xxx="12" * * * Arg: s [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 461 "wisestring.dy" int number_from_quoted_equality(char * s) { char * st; int ret; char c; for(;*s && *s != '=';s++) ; if( !*s ) return 0; for(;*s && isspace(*s);s++) ; /*** start of the number now... ***/ st = s; for(;*s && isalnum(*s);s++) ; c = *s; *s = '\0'; ret = atoi(st); *s = c; return ret; } /* Function: number_from_equality(string) * * Descrip: supposedly gets a number from * xxxx=12 * * * Arg: string [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 493 "wisestring.dy" int number_from_equality(char * string) { char * st; for(;*string && *string != '=';string++) ; if(*string == '\0') return 0; for(;isspace(*string) && *string;string++) ; st=string; for(;!isspace(*string) && *string;string++) *string='\0'; return atoi(st); } /* Function: sub_string(into,key,sub) * * Descrip: deprecated * * * Arg: into [UNKN ] Undocumented argument [char *] * Arg: key [UNKN ] Undocumented argument [char *] * Arg: sub [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 518 "wisestring.dy" char * sub_string(char * into,char * key,char * sub) { char buffer[MAXLINE]; char * runner; char * stop; runner=buffer; while( (stop=strstr(into,key)) != NULL) { while( into != stop ) *(runner++)=(*(into++)); *runner='\0'; strcat(buffer,sub); runner=buffer+strlen(buffer); into+=strlen(key); } while( *into ) *(runner++)=(*(into++)); *(runner)='\0'; return stringalloc(buffer); } /* Function: string_from_quoted_equality(string) * * Descrip: gets the string from xxx="yyy". Returns * yyy allocated, and messes around with string * * * Arg: string [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 546 "wisestring.dy" char * string_from_quoted_equality(char * string) { return string_from_charred_equality(string,'"'); } /* Function: string_from_charred_equality(string,quote) * * Descrip: gets the string from xxx="yyy" ,where " comes * from the quote argument Returns * yyy allocated, and messes around with string * * * Arg: string [UNKN ] Undocumented argument [char *] * Arg: quote [UNKN ] Undocumented argument [char] * * Return [UNKN ] Undocumented return value [char *] * */ # line 556 "wisestring.dy" char * string_from_charred_equality(char * string,char quote) { char * base; for(;*string && *string != '=';string++) ; if(*string == '\0') return NULL; for(;*string && *string != quote;string++) ; if(*string == '\0') return NULL; string++; base=string; for(;*string && *string != quote;string++) ; *string='\0'; return stringalloc(base); } /* Function: breakstring(string,parsestr) * * Descrip: A call to /breakstring_protect(string,parsestr,"\"") * * * Arg: string [UNKN ] Undocumented argument [char *] * Arg: parsestr [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char **] * */ # line 586 "wisestring.dy" char ** breakstring(char * string,char * parsestr) { return breakstring_protect(string,parsestr,"\""); } /* Function: breakstring_protect(string,parsestr,strpair) * * Descrip: will parse out words in string using parse * as white space, like strtok, but strings * enclosed in characters from strpair are not * taken in parsed form. * breakstring = * breakstring_protect(string,parse,"\""); * hence will not break in double quotes * * unlike strtok they return char ** * which is a list of char * of words * the last being NULL'd * * * They returned an alloc'd char ** which you * are expected to free. Standard idiom is * base=brk=breakstring(buffer,spacestr) * (NB - spacestr #defin'd above ) * ... do stuff using brk * eg *brk = first word * *(++brk) = next word * last word = NULL * cleanup by ckfree(base) * * * Arg: string [UNKN ] Undocumented argument [char *] * Arg: parsestr [UNKN ] Undocumented argument [char *] * Arg: strpair [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char **] * */ # line 615 "wisestring.dy" char ** breakstring_protect(char * string,char * parsestr,char * strpair) { char ** outstr; int index=1; outstr=(char **) ckcalloc (128,sizeof(char *)); while( strchr(parsestr,*string) != NULL) string++; outstr[0]=string; while(*string) { if( strchr(strpair,*string) != NULL ) { auto char c; c = *string; for(string++;strchr(strpair,*string) == NULL && *string;string++) if( *string == '\\' ) string++; if( *string == '\0') { log_full_error(WARNING,0,"In breakstring_protect, reached endofline in protected string [%s]",outstr[index]); outstr[++index]=NULL; return outstr; } string++; /* shifts on one past " */ } else if( strchr(parsestr,*string) != NULL) { while( *string && strchr(parsestr,*string) != NULL) *(string++)='\0'; if( *string == '\0') break; string--; *string='\0'; outstr[index++]=string+1; string++; } else string++; } outstr[index]=NULL; return outstr; } /* Function: strip_quote_chars(string,quote) * * Descrip: removes chars in quote * * * Arg: string [UNKN ] Undocumented argument [char *] * Arg: quote [UNKN ] Undocumented argument [char *] * */ # line 670 "wisestring.dy" void strip_quote_chars(char * string,char * quote) { char * base =string; char * run; if( strchr(quote,*string) != NULL ) { for(string++;*string;string++) *(string-1)= (*string); *(string-1) = '\0'; } run = base+strlen(base)-1; if( strchr(quote,*run) != NULL ) *run= '\0'; } /* Function: padstring(buffer,string,maxlen) * * Descrip: copies string into buffer, and if under maxlen, * adds spaces. Does *not* put in '\0' * * * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: string [UNKN ] Undocumented argument [char *] * Arg: maxlen [UNKN ] Undocumented argument [int] * */ # line 693 "wisestring.dy" void padstring(char * buffer,char * string,int maxlen) { for(;*string && maxlen > 0;string++,buffer++,maxlen--) *buffer=(*string); if( maxlen > 0) for(;maxlen > 0;maxlen--,buffer++) *buffer=' '; return; } /* Function: capitalise(word) * * Descrip: toupper's each char in word * * * Arg: word [UNKN ] Undocumented argument [char *] * */ # line 707 "wisestring.dy" void capitalise(char * word) { for(;*word;word++) *word=toupper(*word); } /* Function: show_line(line,max,*ofp) * * Descrip: This shouws line putting a new line in every max * chars, not minding word boundaries * * * Arg: line [UNKN ] Undocumented argument [char *] * Arg: max [UNKN ] Undocumented argument [int] * Arg: *ofp [UNKN ] Undocumented argument [FILE] * */ # line 719 "wisestring.dy" void show_line(char * line,int max,FILE *ofp) { int i; for(i=0;*(line+i);i++) { if( (i%max) == 0 && i != 0) fputc('\n',ofp); fputc(*(line+i),ofp); } fputc('\n',ofp); return; } /* Function: show_text(line,max,*ofp) * * Descrip: This shouws line putting a new line in every max * chars, *minding* word boundaries * * * Arg: line [UNKN ] Undocumented argument [char *] * Arg: max [UNKN ] Undocumented argument [int] * Arg: *ofp [UNKN ] Undocumented argument [FILE] * */ # line 738 "wisestring.dy" void show_text(char * line,int max,FILE *ofp) { char push; char *pushpoi; char * runner; for(runner=line;;) { for(;(int)(runner-line) < max && *runner;) { pushpoi=runner; while( *(++runner) != ' ' && *runner) ; /* NB dodgy pre ++ in above line */ } if(*runner == '\0') { if((int)(runner-line) < max) fprintf(ofp,"%s\n",line); else { push=(*pushpoi); *pushpoi='\0'; fprintf(ofp,"%s\n",line); *pushpoi=push; line=pushpoi+1; fprintf(ofp,"%s\n",line); } break; } else { push=(*pushpoi); *pushpoi='\0'; fprintf(ofp,"%s\n",line); *pushpoi=push; line=pushpoi+1; runner=line; } } return; } /* Function: second_word_alloc(str,space) * * Descrip: returns the second word alloc'd for * * xxx yyyy * * returns yyyy. * * * Arg: str [UNKN ] Undocumented argument [char *] * Arg: space [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 786 "wisestring.dy" char * second_word_alloc(char * str,char * space) { char * out; char c; for(;*str && strchr(space,*str) == NULL;str++) ; if( *str == '\0') { warn("Can only find one word in [%s] - certainly can't alloc the second",str); return NULL; } for(str++;*str && strchr(space,*str) != NULL;str++) ; out=str; for(;*str && strchr(space,*str) == NULL;str++) ; c = *str; *str ='\0'; out = stringalloc(out); *str= c; return out; } /* Function: stringallocf(str,) * * Descrip: Don't use this * * sprintf's then allocs * * * Arg: str [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * * Return [UNKN ] Undocumented return value [char *] * */ # line 821 "wisestring.dy" char * stringallocf(char * str,...) { char buffer[1024]; va_list ap; va_start(ap,str); vsprintf(buffer,str,ap); va_end(ap); return stringalloc(buffer); } /* Function: stringalloc(c) * * Descrip: returns the allocated copy of c. * Usually called strdup in other packages * * * Arg: c [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 840 "wisestring.dy" char * stringalloc(char * c) { register int i; register char * temp; if(c == NULL) { warn("Passed stringalloc a NULL pointer"); return NULL; } i = strlen(c); if((temp=(char *)ckalloc(sizeof(char)*(i+1))) == NULL) { warn("stringalloc unable to allocate memory"); return NULL; } strcpy(temp,c); return temp; } # line 1036 "wisestring.c" #ifdef _cplusplus } #endif wise-2.4.1/src/base/wisestring.h0000644000175000001440000003652610670453712016142 0ustar philippusers#ifndef DYNAMITEwisestringHEADERFILE #define DYNAMITEwisestringHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" /**********************************************/ /* useful macros to put into fprintf lines... */ /* Makes sure you don't trash memory etc */ /**********************************************/ #define CHECKSTRING(str) (str == NULL ? "NullString" : str) #define CKS CHECKSTRING /**********************************************/ /* useful standard strings for parsing */ /* spacestr is general whitespace */ /* breakstr is general non alpha/num */ /* used alot in breakstring */ /**********************************************/ #define spacestr " \t\n\0" #define breakstr "!\"#$%^&*()-+={}[]@';:?/.,\\|~` \n\t" /**********************************************/ /* Not the nicest of macros. Stay away from it*/ /**********************************************/ #define NEXTWORD strtok(NULL,spacestr) /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: get_number_from_slashed_string(qstr,slashstr) * * Descrip: handy: pass a string like "xxx/yyy/zzz" * and a query like yyy, will return 2 * (ie, maps positions in slashed string with * a number from start). Returns -1 if none * * * Arg: qstr [UNKN ] Undocumented argument [char *] * Arg: slashstr [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_get_number_from_slashed_string(char * qstr,char * slashstr); #define get_number_from_slashed_string Wise2_get_number_from_slashed_string /* Function: is_integer_string(string,val) * * Descrip: checks that strings are ints or doubles * and then converts, storing value in val * if val == NULL, will not store (!) * * Does use sensible library functions * strtol... * * * Arg: string [UNKN ] Undocumented argument [char *] * Arg: val [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_integer_string(char * string,int * val); #define is_integer_string Wise2_is_integer_string /* Function: is_double_string(string,val) * * Descrip: checks that strings are doubles * and then converts, storing value in val * if val == NULL, will not store (!) * * Does use sensible library functions * strtod * * * Arg: string [UNKN ] Undocumented argument [char *] * Arg: val [UNKN ] Undocumented argument [double *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_double_string(char * string,double * val); #define is_double_string Wise2_is_double_string /* Function: compress_space_around_punc(buffer,punc,space) * * Descrip: No Description * * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: punc [UNKN ] Undocumented argument [char *] * Arg: space [UNKN ] Undocumented argument [char *] * */ void Wise2_compress_space_around_punc(char * buffer,char * punc,char * space); #define compress_space_around_punc Wise2_compress_space_around_punc /* Function: striptoprint(line) * * Descrip: useful strip functions to remove nasty chars * does not allocate memory, simply uses * given memory, but returns the line pointer * so you can use it in nested function calls * * * Arg: line [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_striptoprint(char * line); #define striptoprint Wise2_striptoprint /* Function: stringalloc_next_quoted_string(buffer) * * Descrip: takes str's of type "xxxxx" * and gives back xxxxxx . * stringalloc'd piece so make sure you free it * * * Arg: buffer [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_stringalloc_next_quoted_string(char * buffer); #define stringalloc_next_quoted_string Wise2_stringalloc_next_quoted_string /* Function: strwhitestartcmp(line,str,whitespace) * * Descrip: sees if line starts with str, ignoring whitespace * * returns 0 if they match, to look like strcmp * * * Arg: line [UNKN ] Undocumented argument [char *] * Arg: str [UNKN ] Undocumented argument [char *] * Arg: whitespace [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_strwhitestartcmp(char * line,char * str,char * whitespace); #define strwhitestartcmp Wise2_strwhitestartcmp /* Function: strwordcmp(buf,str,space) * * Descrip: sees if buf matches str\s in perl regex, ie * a word match * * space defined \s * * returns 0 if they match to look like strcmp * * * Arg: buf [UNKN ] Undocumented argument [char *] * Arg: str [UNKN ] Undocumented argument [char *] * Arg: space [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_strwordcmp(char * buf,char * str,char * space); #define strwordcmp Wise2_strwordcmp /* Function: strstartcmp(buf,str) * * Descrip: sees if buf starts with str. * * returns 0 if so, to mimic strcmp * * * Arg: buf [UNKN ] Undocumented argument [char *] * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_strstartcmp(char * buf,char * str); #define strstartcmp Wise2_strstartcmp /* Function: print_numbered_line(num,ofp) * * Descrip: prints lines like _1_________ * * * Arg: num [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_print_numbered_line(int num,FILE * ofp); #define print_numbered_line Wise2_print_numbered_line /* Function: print_line(ofp) * * Descrip: prints _______________ (70 chars) * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_print_line(FILE * ofp); #define print_line Wise2_print_line /* Function: chop_newline(str) * * Descrip: removes trailing newline if present * * * Arg: str [UNKN ] Undocumented argument [char *] * */ void Wise2_chop_newline(char * str); #define chop_newline Wise2_chop_newline /* Function: good_datastring_fromend(str) * * Descrip: Tries to find the last 'database name' * type string from a string. * * Does not allocate memory * * * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_good_datastring_fromend(char * str); #define good_datastring_fromend Wise2_good_datastring_fromend /* Function: estrcasecmp(one,two) * * Descrip: returns strcmp on the captilalised * one and two bufferers (doesn't touch them). * * * Arg: one [UNKN ] Undocumented argument [char *] * Arg: two [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_estrcasecmp(char * one,char * two); #define estrcasecmp Wise2_estrcasecmp /* Function: number_from_quoted_equality(s) * * Descrip: supposedly gets a number from a * string like xxx="12" * * * Arg: s [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_number_from_quoted_equality(char * s); #define number_from_quoted_equality Wise2_number_from_quoted_equality /* Function: number_from_equality(string) * * Descrip: supposedly gets a number from * xxxx=12 * * * Arg: string [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_number_from_equality(char * string); #define number_from_equality Wise2_number_from_equality /* Function: string_from_quoted_equality(string) * * Descrip: gets the string from xxx="yyy". Returns * yyy allocated, and messes around with string * * * Arg: string [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_string_from_quoted_equality(char * string); #define string_from_quoted_equality Wise2_string_from_quoted_equality /* Function: string_from_charred_equality(string,quote) * * Descrip: gets the string from xxx="yyy" ,where " comes * from the quote argument Returns * yyy allocated, and messes around with string * * * Arg: string [UNKN ] Undocumented argument [char *] * Arg: quote [UNKN ] Undocumented argument [char] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_string_from_charred_equality(char * string,char quote); #define string_from_charred_equality Wise2_string_from_charred_equality /* Function: breakstring(string,parsestr) * * Descrip: A call to /breakstring_protect(string,parsestr,"\"") * * * Arg: string [UNKN ] Undocumented argument [char *] * Arg: parsestr [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char **] * */ char ** Wise2_breakstring(char * string,char * parsestr); #define breakstring Wise2_breakstring /* Function: breakstring_protect(string,parsestr,strpair) * * Descrip: will parse out words in string using parse * as white space, like strtok, but strings * enclosed in characters from strpair are not * taken in parsed form. * breakstring = * breakstring_protect(string,parse,"\""); * hence will not break in double quotes * * unlike strtok they return char ** * which is a list of char * of words * the last being NULL'd * * * They returned an alloc'd char ** which you * are expected to free. Standard idiom is * base=brk=breakstring(buffer,spacestr) * (NB - spacestr #defin'd above ) * ... do stuff using brk * eg *brk = first word * *(++brk) = next word * last word = NULL * cleanup by ckfree(base) * * * Arg: string [UNKN ] Undocumented argument [char *] * Arg: parsestr [UNKN ] Undocumented argument [char *] * Arg: strpair [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char **] * */ char ** Wise2_breakstring_protect(char * string,char * parsestr,char * strpair); #define breakstring_protect Wise2_breakstring_protect /* Function: strip_quote_chars(string,quote) * * Descrip: removes chars in quote * * * Arg: string [UNKN ] Undocumented argument [char *] * Arg: quote [UNKN ] Undocumented argument [char *] * */ void Wise2_strip_quote_chars(char * string,char * quote); #define strip_quote_chars Wise2_strip_quote_chars /* Function: padstring(buffer,string,maxlen) * * Descrip: copies string into buffer, and if under maxlen, * adds spaces. Does *not* put in '\0' * * * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: string [UNKN ] Undocumented argument [char *] * Arg: maxlen [UNKN ] Undocumented argument [int] * */ void Wise2_padstring(char * buffer,char * string,int maxlen); #define padstring Wise2_padstring /* Function: capitalise(word) * * Descrip: toupper's each char in word * * * Arg: word [UNKN ] Undocumented argument [char *] * */ void Wise2_capitalise(char * word); #define capitalise Wise2_capitalise /* Function: show_line(line,max,*ofp) * * Descrip: This shouws line putting a new line in every max * chars, not minding word boundaries * * * Arg: line [UNKN ] Undocumented argument [char *] * Arg: max [UNKN ] Undocumented argument [int] * Arg: *ofp [UNKN ] Undocumented argument [FILE] * */ void Wise2_show_line(char * line,int max,FILE *ofp); #define show_line Wise2_show_line /* Function: show_text(line,max,*ofp) * * Descrip: This shouws line putting a new line in every max * chars, *minding* word boundaries * * * Arg: line [UNKN ] Undocumented argument [char *] * Arg: max [UNKN ] Undocumented argument [int] * Arg: *ofp [UNKN ] Undocumented argument [FILE] * */ void Wise2_show_text(char * line,int max,FILE *ofp); #define show_text Wise2_show_text /* Function: second_word_alloc(str,space) * * Descrip: returns the second word alloc'd for * * xxx yyyy * * returns yyyy. * * * Arg: str [UNKN ] Undocumented argument [char *] * Arg: space [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_second_word_alloc(char * str,char * space); #define second_word_alloc Wise2_second_word_alloc /* Function: stringallocf(str,) * * Descrip: Don't use this * * sprintf's then allocs * * * Arg: str [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_stringallocf(char * str,...); #define stringallocf Wise2_stringallocf /* Function: stringalloc(c) * * Descrip: returns the allocated copy of c. * Usually called strdup in other packages * * * Arg: c [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_stringalloc(char * c); #define stringalloc Wise2_stringalloc /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_only_whitespace(char * str,char * space); #define only_whitespace Wise2_only_whitespace boolean Wise2_looks_like_vms(const char * str); #define looks_like_vms Wise2_looks_like_vms boolean Wise2_looks_like_unix(const char * str); #define looks_like_unix Wise2_looks_like_unix char * Wise2_strend(char * bu,char * se); #define strend Wise2_strend char * Wise2_string_before_equality(char * string); #define string_before_equality Wise2_string_before_equality char * Wise2_sub_string(char * into,char * key,char * sub); #define sub_string Wise2_sub_string #ifdef _cplusplus } #endif #endif wise-2.4.1/src/base/wisememman.c0000644000175000001440000001342610670453712016073 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "wisememman.h" #ifdef WISE_MEMORY_WATCH struct wise_memory_watcher { void * position; int amount; int has_freed; char * file; int lineno; }; static struct wise_memory_watcher mempool[WISE_MEMORY_WATCH_MAX]; static int nextpool = 0; /* Function: display_allocated_memory(tag,ofp) * * Descrip: Displays to filehandle all non freed memory * * * Arg: tag [UNKN ] Undocumented argument [char *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 31 "wisememman.dy" void display_allocated_memory(char * tag,FILE * ofp) { int i; for(i=0;i < nextpool && i= WISE_MEMORY_WATCH_MAX ) { warn("Memory allocation over limits for watching"); return malloc(no_bytes); } mempool[nextpool].position = malloc(no_bytes); mempool[nextpool].amount = no_bytes; mempool[nextpool].has_freed = FALSE; mempool[nextpool].file = file; mempool[nextpool].lineno = lineno; nextpool++; return mempool[nextpool-1].position; } /* Function: allocate_watched_memory(no_bytes) * * Descrip: Only if compiled with WISE_MEMORY_WATCH * * Allocates memory and watches the usage of it * * * Arg: no_bytes [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [void *] * */ # line 77 "wisememman.dy" void * allocate_watched_memory(int no_bytes) { if( nextpool >= WISE_MEMORY_WATCH_MAX ) { warn("Memory allocation over limits for watching"); return malloc(no_bytes); } mempool[nextpool].position = malloc(no_bytes); mempool[nextpool].amount = no_bytes; mempool[nextpool].has_freed = FALSE; mempool[nextpool].file = NULL; mempool[nextpool].lineno = -1; nextpool++; return mempool[nextpool-1].position; } /* Function: free_watched_memory(mem) * * Descrip: Only if compiled with WISE_MEMORY_WATCH * * frees memory that has been watched * * * Arg: mem [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ # line 100 "wisememman.dy" void * free_watched_memory(void * mem) { int i; for(i=0;i < nextpool && i #include %} %{ #include "wiserandom.h" static boolean isinit = FALSE; %func initates the random generator to time byte... %% void init_random(void) { srandom((long) time(NULL)); isinit = TRUE; } %func returns an integer between 0 and l though I don't think we will get 0 very often. Hmmm. %% int random_integer(int l) { double rand; rand = random_0_to_1(); return (int) (l*rand); } %func returns a random number between 0 and 1 %% double random_0_to_1(void) { double ret; long rnd; if( isinit == FALSE) init_random(); isinit = TRUE; rnd = random(); ret = (double)rnd / (double)LONG_MAX; /* fprintf(stderr," got... %D %f\n",rnd,ret);*/ return ret; } wise-2.4.1/src/base/wisefile_api.h0000644000175000001440000000142510670453712016372 0ustar philippusers /* Helper functions in the module * * Wise2_openfile * /* These functions are not associated with an object */ /* Function: Wise2_openfile(filename,passedprot) * * Descrip: Every file open goes through this. * * It opens for reading in the following order * . * WISEPERSONALDIR * WISECONFIGDIR * * For writing it opens in . * * Filenames with ~'s are expanded to HOME/filename * * * Arg: filename filename to open for read/writing [const char *] * Arg: passedprot string representing standard fopen attributes [const char *] * * Returns open'd filehandle, NULL on error [FILE *] * */ FILE * Wise2_openfile( const char * filename,const char * passedprot); wise-2.4.1/src/base/wisefile_api.t0000644000175000001440000000000010670453712016372 0ustar philippuserswise-2.4.1/src/base/wiseerror.dy0000644000175000001440000002413310345025225016132 0ustar philippusers/* Last edited: Nov 8 13:51 1996 (birney) */ %{ #include "wisebase.h" typedef int Flag; #define MAXERROR 256 #define MAXERRORCALL 32 #define MAXMSGSTACKERROR 64 /* flags on errors */ #define ERRORUSE 1 #define ERRORTOSTDERR 2 #define ERRORTOLOG 4 #define ERRORTOCALL 8 #define LONGERROR 16 /* not used */ /* types of error */ #define FATAL 1 #define WARNING 2 #define PEDANTIC 4 /* deprecated */ #define INFO 8 #define REPORT 16 #define erroroff(type) error_flag_off(type,ERRORUSE) #define erroron(type) error_flag_on (type,ERRORUSE) #define errorcallon(type) error_flag_on (type,ERRORTOCALL) #define errorcalloff(type) error_flag_off(type,ERRORTOCALL) #define errorstderron(type) error_flag_on (type,ERRORTOSTDERR) #define errorstderroff(type) error_flag_off(type,ERRORTOSTDERR) #define errorlogon(type) error_flag_on (type,ERRORTOLOG) #define errorlogoff(type) error_flag_off(type,ERRORTOLOG) typedef enum Error_Display_Type { ERROR_DISPLAY_PROGRAM = 36, ERROR_DISPLAY_SERVER } ErrorDisplayType; %} api func catch_errors func stop_catching_errors func warn func info func fatal endapi %{ #include "wiseerror.h" static Flag fatal_flag = 3; static Flag warning_flag = 3; static Flag info_flag = 3; static Flag report_flag = 3; static ErrorDisplayType display_type = ERROR_DISPLAY_PROGRAM; static char * log_display_string = NULL; #define flag_of_type(c) (c == FATAL ? fatal_flag : c == WARNING ? warning_flag :c == INFO ? info_flag : report_flag ) static int eventc=0; static FILE * errlog=NULL; static void (*error_call)(char *,int)= NULL; static char * error_msg_stack[MAXMSGSTACKERROR]; static char * (*((error_msg_call)[MAXMSGSTACKERROR]))(void); static int msg_stack_no=0; %func sets error display style %% void set_error_display_style(ErrorDisplayType t) { display_type = t; } %func sets string for log display type %% void set_log_display_string(char * str) { if( log_display_string != NULL ) { ckfree(log_display_string); } log_display_string = stringalloc(str); } %func This adds a function onto the error message stack for stacking errors. this is for decent parsers etc for allowing 'error scope' to be propagated down. It is very very bad form to push an errormsg stack and not pop it at the end. %type internal %% boolean push_errormsg_stack(char * msg, ...) { char buffer[1024]; va_list ap; va_start(ap,msg); vsprintf(buffer,msg,ap); if( msg_stack_no >= MAXMSGSTACKERROR ) { warn("Too many messages held on stack, [%s] discarded\n",buffer); /*** still should up the number ***/ msg_stack_no++; return FALSE; } error_msg_call[msg_stack_no] = NULL; error_msg_stack[msg_stack_no++] = stringalloc(buffer); return TRUE; } %func This adds a function call for people who want to register error handling functions Probably best wrapped by a separate function %% boolean push_errormsg_stack_call( char * (*ecall)(void)) { if( msg_stack_no >= MAXMSGSTACKERROR ) { warn("Too many messages held on stack, Error message call discarded\n"); /*** still should up the number ***/ msg_stack_no++; return FALSE; } error_msg_call[msg_stack_no] = ecall; error_msg_stack[msg_stack_no++] = NULL; return TRUE; } %func This removes a error message from the stack %% void pop_errormsg_stack(void) { if( msg_stack_no < MAXMSGSTACKERROR && msg_stack_no > 0 && error_msg_stack[msg_stack_no-1] != NULL) ckfree(error_msg_stack[msg_stack_no-1]); if( msg_stack_no > 0) msg_stack_no--; } %func This shows the error message set to everyone %type internal %% void show_message_stack(FILE * ofp) { register int i; register int j; register int count; for(i=0;i 0 ) show_message_stack(stderr); fputs("\t",stderr); if( type == FATAL ) fputs(othermsg,stderr); else show_text(othermsg,70,stderr); } } if( flag&ERRORTOLOG && errlog != NULL) { fputs(type_to_error(type),errlog); fputc('\n',stderr); if( msg_stack_no > 0 ) show_message_stack(errlog); fputs("\n\t",errlog); show_text(othermsg,70,errlog); } if( flag&ERRORTOCALL && error_call != NULL) { (*(error_call))(othermsg,type); } return; } %} wise-2.4.1/src/base/commandline.c0000644000175000001440000002241310670453712016213 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "commandline.h" /* Function: strip_out_remaining_options_with_warning(argc,argv) * * Descrip: This removes all remaining options, issuing warnings * through warn * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 33 "commandline.dy" boolean strip_out_remaining_options_with_warning(int * argc,char ** argv) { register int i; boolean ret = FALSE; for(i=0;i<*argc;i++) { if( argv[i][0] != '-' ) continue; /*** ignore bare '-' - could be arguments ***/ if( argv[i][1] == '\0') continue; warn("You have an unrecognised argument, %s, removing",argv[i]); memmove(argv+i,argv+i+1,sizeof(char *)*(*argc - i -1)); *argc -= 1; ret = TRUE; } return ret; } /* Function: strip_out_boolean_argument(argc,argv,tag) * * Descrip: This removes argument in tag from the commandline if there and * returns TRUE * * otherwise returns FALSE * * * Arg: argc [UNKN ] argc from main declaration (call as &argc) [int *] * Arg: argv [UNKN ] argv from main declaration [char **] * Arg: tag [READ ] -[string] argument to find [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 69 "commandline.dy" boolean strip_out_boolean_argument(int * argc,char ** argv,char * tag) { register int i; for(i=0;i<*argc;i++) { if( argv[i][0] != '-' ) continue; /** ignore '-' by themselves **/ if( argv[i][1] == '\0') continue; /** try to strcmp with tag **/ if( strcmp(tag,argv[i]+1) == 0 ) { memmove(argv+i,argv+i+1,sizeof(char *)*(*argc - i -1)); *argc -= 1; /* return */ return TRUE; } } return FALSE; } /* Function: strip_out_boolean_def_argument(argc,argv,tag,value) * * Descrip: This sets a boolean argument as * -tag == TRUE * -notag == FALSE * * This is probably better than strip_out_boolean_argument * as * defaults can be provided * user can switch either on or off * * * Arg: argc [UNKN ] argc from main declaration (call as &argc) [int *] * Arg: argv [UNKN ] argv from main declaration [char **] * Arg: tag [READ ] -[string] argument to find [char *] * Arg: value [WRITE] boolean pointer to write value to [boolean *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 113 "commandline.dy" boolean strip_out_boolean_def_argument(int * argc,char ** argv,char * tag,boolean * value) { int arg; char buffer[64]; if( (arg = strip_out_boolean_argument(argc,argv,tag)) == TRUE ) { *value = TRUE; } sprintf(buffer,"no%s",tag); if( (arg = strip_out_boolean_argument(argc,argv,buffer)) == TRUE ) { *value = FALSE; } return TRUE; } /* Function: strip_out_assigned_argument(argc,argv,tag) * * Descrip: This removes argument in tag from the commandline if there and * returns the argument to it (in -tag arg - ie with a space). * * otherwise returns NULL * * * Arg: argc [UNKN ] argc from main declaration (call as &argc) [int *] * Arg: argv [UNKN ] argv from main declaration [char **] * Arg: tag [READ ] -[string] argument to find [char *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 140 "commandline.dy" char * strip_out_assigned_argument(int * argc,char ** argv,char * tag) { register int i; register char * ret; for(i=0;i<*argc;i++) { if( argv[i][0] != '-' ) continue; /** ignore '-' by themselves **/ if( argv[i][1] == '\0') continue; /** try to strcmp with tag **/ if( strcmp(tag,argv[i]+1) == 0 ) { /* pick up next argument: if it has a '-' treat that as the argument. */ if( i+1 >= *argc ) { warn("In processing command line [%s], tag [%s] expects an argument",argv[0],tag); return NULL; /* give 'em nothing */ } /* assign return value */ ret = argv[i+1]; /* ok, now remove both tag and argument from the line */ memmove(argv+i,argv+i+2,sizeof(char *)*(*argc - i -2)); *argc -= 2; /* return */ return ret; } } return NULL; } /* Function: strip_out_integer_argument(argc,argv,tag,value) * * Descrip: This removes argument in tag from the commandline if there, and * looks at the argument as whether it is an int or not. * * No tag - returns FALSE and leaves value alone * Tag but no integer value - issues warning, returns FALSE * tag but integer value - sets value, returns true * * * Arg: argc [UNKN ] argc from main declaration (call as &argc) [int *] * Arg: argv [UNKN ] argv from main declaration [char **] * Arg: tag [READ ] -[string] argument to find [char *] * Arg: value [WRITE] int pointer to write value to [int *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 199 "commandline.dy" boolean strip_out_integer_argument(int * argc,char ** argv,char * tag,int * value) { char * arg; if( (arg = strip_out_assigned_argument(argc,argv,tag)) == NULL ) return FALSE; if( is_integer_string(arg,value) == FALSE ) { warn("Argument [%s] to [%s] is not an integer. Not changing the value [%d]",arg,tag,value); return FALSE; } return TRUE; } /* Function: strip_out_float_argument(argc,argv,tag,value) * * Descrip: This removes argument in tag from the commandline if there, and * looks at the argument as whether it is a double or not. * * No tag - returns FALSE and leaves value alone * Tag but no integer value - issues warning, returns FALSE * tag but integer value - sets value, returns true * * * Arg: argc [UNKN ] argc from main declaration (call as &argc) [int *] * Arg: argv [UNKN ] argv from main declaration [char **] * Arg: tag [READ ] -[string] argument to find [char *] * Arg: value [WRITE] double pointer to write value to [double *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 227 "commandline.dy" boolean strip_out_float_argument(int * argc,char ** argv,char * tag,double * value) { char * arg; if( (arg = strip_out_assigned_argument(argc,argv,tag)) == NULL ) return FALSE; if( is_double_string(arg,value) == FALSE ) { warn("Argument [%s] to [%s] is not a double. Not changing the value [%f]",arg,tag,value); return FALSE; } return TRUE; } /* Function: show_standard_options(ofp) * * Descrip: Shows standard options * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 245 "commandline.dy" void show_standard_options(FILE * ofp) { fprintf(ofp,"Standard options\n"); fprintf(ofp," -help help\n"); fprintf(ofp," -version show version and compile info\n"); fprintf(ofp," -silent No messages on stderr\n"); fprintf(ofp," -quiet No report/info on stderr\n"); fprintf(ofp," -erroroffstd No warning messages to stderr\n"); fprintf(ofp," -errorlog [file] Log warning messages to file\n"); fprintf(ofp," -errorstyle [server/program] style of error reporting (default program)\n"); } /* Function: strip_out_standard_options(argc,show_version,show_help,argv) * * Descrip: Handles default arguments correctly, setting help,version,errors * handling * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: show_version [UNKN ] Undocumented argument [NullString] * Arg: show_help [UNKN ] Undocumented argument [NullString] * Arg: argv [UNKN ] Undocumented argument [char **] * */ # line 262 "commandline.dy" void strip_out_standard_options(int * argc,char ** argv,void (*show_help)(FILE * ofp),void (*show_version)(FILE * ofp)) { char * errlog; char * temp; if( (strip_out_boolean_argument(argc,argv,"help")) == TRUE ) { (*show_help)(stdout); exit(1); } if( (strip_out_boolean_argument(argc,argv,"version")) == TRUE ) { (*show_version)(stdout); exit(1); } if( (strip_out_boolean_argument(argc,argv,"silent")) == TRUE ) { erroroff(REPORT); erroroff(INFO); erroroff(WARNING); } if( (strip_out_boolean_argument(argc,argv,"quiet")) == TRUE ) { erroroff(REPORT); erroroff(INFO); } if( (strip_out_boolean_argument(argc,argv,"erroroffstd")) == TRUE ) { errorstderroff(WARNING); } if( (temp = strip_out_assigned_argument(argc,argv,"errorstyle")) != NULL ) { if( strcmp(temp,"server") == 0 ) { set_error_display_style(ERROR_DISPLAY_SERVER); } else if ( strcmp(temp,"program") == 0 ) { set_error_display_style(ERROR_DISPLAY_PROGRAM); } else { fprintf(stderr,"Unknown errorstyle %s",temp); } } set_log_display_string(argv[0]); if( (errlog=strip_out_assigned_argument(argc,argv,"errlog")) != NULL ) { if( add_log_filename(errlog) == FALSE ) { fatal("Could not use %s as a error log file\n",errlog); } else { warn("Logging errors to %s as well as stderr",errlog); errorlogon(WARNING); } } } # line 331 "commandline.c" #ifdef _cplusplus } #endif wise-2.4.1/src/base/commandline.h0000644000175000001440000001420110670453712016214 0ustar philippusers#ifndef DYNAMITEcommandlineHEADERFILE #define DYNAMITEcommandlineHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: strip_out_remaining_options_with_warning(argc,argv) * * Descrip: This removes all remaining options, issuing warnings * through warn * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_strip_out_remaining_options_with_warning(int * argc,char ** argv); #define strip_out_remaining_options_with_warning Wise2_strip_out_remaining_options_with_warning /* Function: strip_out_boolean_argument(argc,argv,tag) * * Descrip: This removes argument in tag from the commandline if there and * returns TRUE * * otherwise returns FALSE * * * Arg: argc [UNKN ] argc from main declaration (call as &argc) [int *] * Arg: argv [UNKN ] argv from main declaration [char **] * Arg: tag [READ ] -[string] argument to find [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_strip_out_boolean_argument(int * argc,char ** argv,char * tag); #define strip_out_boolean_argument Wise2_strip_out_boolean_argument /* Function: strip_out_boolean_def_argument(argc,argv,tag,value) * * Descrip: This sets a boolean argument as * -tag == TRUE * -notag == FALSE * * This is probably better than strip_out_boolean_argument * as * defaults can be provided * user can switch either on or off * * * Arg: argc [UNKN ] argc from main declaration (call as &argc) [int *] * Arg: argv [UNKN ] argv from main declaration [char **] * Arg: tag [READ ] -[string] argument to find [char *] * Arg: value [WRITE] boolean pointer to write value to [boolean *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_strip_out_boolean_def_argument(int * argc,char ** argv,char * tag,boolean * value); #define strip_out_boolean_def_argument Wise2_strip_out_boolean_def_argument /* Function: strip_out_assigned_argument(argc,argv,tag) * * Descrip: This removes argument in tag from the commandline if there and * returns the argument to it (in -tag arg - ie with a space). * * otherwise returns NULL * * * Arg: argc [UNKN ] argc from main declaration (call as &argc) [int *] * Arg: argv [UNKN ] argv from main declaration [char **] * Arg: tag [READ ] -[string] argument to find [char *] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_strip_out_assigned_argument(int * argc,char ** argv,char * tag); #define strip_out_assigned_argument Wise2_strip_out_assigned_argument /* Function: strip_out_integer_argument(argc,argv,tag,value) * * Descrip: This removes argument in tag from the commandline if there, and * looks at the argument as whether it is an int or not. * * No tag - returns FALSE and leaves value alone * Tag but no integer value - issues warning, returns FALSE * tag but integer value - sets value, returns true * * * Arg: argc [UNKN ] argc from main declaration (call as &argc) [int *] * Arg: argv [UNKN ] argv from main declaration [char **] * Arg: tag [READ ] -[string] argument to find [char *] * Arg: value [WRITE] int pointer to write value to [int *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_strip_out_integer_argument(int * argc,char ** argv,char * tag,int * value); #define strip_out_integer_argument Wise2_strip_out_integer_argument /* Function: strip_out_float_argument(argc,argv,tag,value) * * Descrip: This removes argument in tag from the commandline if there, and * looks at the argument as whether it is a double or not. * * No tag - returns FALSE and leaves value alone * Tag but no integer value - issues warning, returns FALSE * tag but integer value - sets value, returns true * * * Arg: argc [UNKN ] argc from main declaration (call as &argc) [int *] * Arg: argv [UNKN ] argv from main declaration [char **] * Arg: tag [READ ] -[string] argument to find [char *] * Arg: value [WRITE] double pointer to write value to [double *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_strip_out_float_argument(int * argc,char ** argv,char * tag,double * value); #define strip_out_float_argument Wise2_strip_out_float_argument /* Function: show_standard_options(ofp) * * Descrip: Shows standard options * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_standard_options(FILE * ofp); #define show_standard_options Wise2_show_standard_options /* Function: strip_out_standard_options(argc,show_version,show_help,argv) * * Descrip: Handles default arguments correctly, setting help,version,errors * handling * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: show_version [UNKN ] Undocumented argument [NullString] * Arg: show_help [UNKN ] Undocumented argument [NullString] * Arg: argv [UNKN ] Undocumented argument [char **] * */ void Wise2_strip_out_standard_options(int * argc,char ** argv,void (*show_help)(FILE * ofp),void (*show_version)(FILE * ofp)); #define strip_out_standard_options Wise2_strip_out_standard_options /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/base/commandline_api.h0000644000175000001440000000703410670453712017053 0ustar philippusers /* Helper functions in the module * * Wise2_strip_out_remaining_options_with_warning * Wise2_strip_out_boolean_argument * Wise2_strip_out_assigned_argument * Wise2_strip_out_integer_argument * Wise2_strip_out_float_argument * /* These functions are not associated with an object */ /* Function: Wise2_strip_out_remaining_options_with_warning(argc,argv) * * Descrip: This removes all remaining options, issuing warnings * through warn * * * Arg: argc Undocumented argument [int *] * Arg: argv Undocumented argument [char **] * * Returns Undocumented return value [boolean] * */ boolean Wise2_strip_out_remaining_options_with_warning( int * argc,char ** argv); /* Function: Wise2_strip_out_boolean_argument(argc,argv,tag) * * Descrip: This removes argument in tag from the commandline if there and * returns TRUE * * otherwise returns FALSE * * * Arg: argc argc from main declaration (call as &argc) [int *] * Arg: argv argv from main declaration [char **] * Arg: tag -[string] argument to find [char *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_strip_out_boolean_argument( int * argc,char ** argv,char * tag); /* Function: Wise2_strip_out_assigned_argument(argc,argv,tag) * * Descrip: This removes argument in tag from the commandline if there and * returns the argument to it (in -tag arg - ie with a space). * * otherwise returns NULL * * * Arg: argc argc from main declaration (call as &argc) [int *] * Arg: argv argv from main declaration [char **] * Arg: tag -[string] argument to find [char *] * * Returns Undocumented return value [char *] * */ char * Wise2_strip_out_assigned_argument( int * argc,char ** argv,char * tag); /* Function: Wise2_strip_out_integer_argument(argc,argv,tag,value) * * Descrip: This removes argument in tag from the commandline if there, and * looks at the argument as whether it is an int or not. * * No tag - returns FALSE and leaves value alone * Tag but no integer value - issues warning, returns FALSE * tag but integer value - sets value, returns true * * * Arg: argc argc from main declaration (call as &argc) [int *] * Arg: argv argv from main declaration [char **] * Arg: tag -[string] argument to find [char *] * Arg: value int pointer to write value to [int *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_strip_out_integer_argument( int * argc,char ** argv,char * tag,int * value); /* Function: Wise2_strip_out_float_argument(argc,argv,tag,value) * * Descrip: This removes argument in tag from the commandline if there, and * looks at the argument as whether it is a double or not. * * No tag - returns FALSE and leaves value alone * Tag but no integer value - issues warning, returns FALSE * tag but integer value - sets value, returns true * * * Arg: argc argc from main declaration (call as &argc) [int *] * Arg: argv argv from main declaration [char **] * Arg: tag -[string] argument to find [char *] * Arg: value double pointer to write value to [double *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_strip_out_float_argument( int * argc,char ** argv,char * tag,double * value); wise-2.4.1/src/base/commandline_api.t0000644000175000001440000000000010670453712017051 0ustar philippuserswise-2.4.1/src/base/wiseerror.c0000644000175000001440000003307010670453712015747 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "wiseerror.h" static Flag fatal_flag = 3; static Flag warning_flag = 3; static Flag info_flag = 3; static Flag report_flag = 3; static ErrorDisplayType display_type = ERROR_DISPLAY_PROGRAM; static char * log_display_string = NULL; #define flag_of_type(c) (c == FATAL ? fatal_flag : c == WARNING ? warning_flag :c == INFO ? info_flag : report_flag ) static int eventc=0; static FILE * errlog=NULL; static void (*error_call)(char *,int)= NULL; static char * error_msg_stack[MAXMSGSTACKERROR]; static char * (*((error_msg_call)[MAXMSGSTACKERROR]))(void); static int msg_stack_no=0; /* Function: set_error_display_style(t) * * Descrip: sets error display style * * * Arg: t [UNKN ] Undocumented argument [ErrorDisplayType] * */ # line 85 "wiseerror.dy" void set_error_display_style(ErrorDisplayType t) { display_type = t; } /* Function: set_log_display_string(str) * * Descrip: sets string for log display type * * * Arg: str [UNKN ] Undocumented argument [char *] * */ # line 93 "wiseerror.dy" void set_log_display_string(char * str) { if( log_display_string != NULL ) { ckfree(log_display_string); } log_display_string = stringalloc(str); } /* Function: push_errormsg_stack(msg,) * * Descrip: This adds a function onto the error message * stack for stacking errors. this is for * decent parsers etc for allowing 'error scope' * to be propagated down. * * It is very very bad form to push an errormsg * stack and not pop it at the end. * * * Arg: msg [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 113 "wiseerror.dy" boolean push_errormsg_stack(char * msg, ...) { char buffer[1024]; va_list ap; va_start(ap,msg); vsprintf(buffer,msg,ap); if( msg_stack_no >= MAXMSGSTACKERROR ) { warn("Too many messages held on stack, [%s] discarded\n",buffer); /*** still should up the number ***/ msg_stack_no++; return FALSE; } error_msg_call[msg_stack_no] = NULL; error_msg_stack[msg_stack_no++] = stringalloc(buffer); return TRUE; } /* Function: push_errormsg_stack_call(ecall) * * Descrip: This adds a function call for people who want * to register error handling functions * * Probably best wrapped by a separate function * * * Arg: ecall [UNKN ] Undocumented argument [NullString] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 142 "wiseerror.dy" boolean push_errormsg_stack_call( char * (*ecall)(void)) { if( msg_stack_no >= MAXMSGSTACKERROR ) { warn("Too many messages held on stack, Error message call discarded\n"); /*** still should up the number ***/ msg_stack_no++; return FALSE; } error_msg_call[msg_stack_no] = ecall; error_msg_stack[msg_stack_no++] = NULL; return TRUE; } /* Function: pop_errormsg_stack(void) * * Descrip: This removes a error message from the stack * * * */ # line 159 "wiseerror.dy" void pop_errormsg_stack(void) { if( msg_stack_no < MAXMSGSTACKERROR && msg_stack_no > 0 && error_msg_stack[msg_stack_no-1] != NULL) ckfree(error_msg_stack[msg_stack_no-1]); if( msg_stack_no > 0) msg_stack_no--; } /* Function: show_message_stack(ofp) * * Descrip: This shows the error message set to * everyone * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 172 "wiseerror.dy" void show_message_stack(FILE * ofp) { register int i; register int j; register int count; for(i=0;i 0 ) show_message_stack(stderr); fputs("\t",stderr); if( type == FATAL ) fputs(othermsg,stderr); else show_text(othermsg,70,stderr); } } if( flag&ERRORTOLOG && errlog != NULL) { fputs(type_to_error(type),errlog); fputc('\n',stderr); if( msg_stack_no > 0 ) show_message_stack(errlog); fputs("\n\t",errlog); show_text(othermsg,70,errlog); } if( flag&ERRORTOCALL && error_call != NULL) { (*(error_call))(othermsg,type); } return; } # line 604 "wiseerror.c" #ifdef _cplusplus } #endif wise-2.4.1/src/base/wiseerror.h0000644000175000001440000002067410670453712015762 0ustar philippusers#ifndef DYNAMITEwiseerrorHEADERFILE #define DYNAMITEwiseerrorHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" typedef int Flag; #define MAXERROR 256 #define MAXERRORCALL 32 #define MAXMSGSTACKERROR 64 /* flags on errors */ #define ERRORUSE 1 #define ERRORTOSTDERR 2 #define ERRORTOLOG 4 #define ERRORTOCALL 8 #define LONGERROR 16 /* not used */ /* types of error */ #define FATAL 1 #define WARNING 2 #define PEDANTIC 4 /* deprecated */ #define INFO 8 #define REPORT 16 #define erroroff(type) error_flag_off(type,ERRORUSE) #define erroron(type) error_flag_on (type,ERRORUSE) #define errorcallon(type) error_flag_on (type,ERRORTOCALL) #define errorcalloff(type) error_flag_off(type,ERRORTOCALL) #define errorstderron(type) error_flag_on (type,ERRORTOSTDERR) #define errorstderroff(type) error_flag_off(type,ERRORTOSTDERR) #define errorlogon(type) error_flag_on (type,ERRORTOLOG) #define errorlogoff(type) error_flag_off(type,ERRORTOLOG) typedef enum Error_Display_Type { ERROR_DISPLAY_PROGRAM = 36, ERROR_DISPLAY_SERVER } ErrorDisplayType; /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: set_error_display_style(t) * * Descrip: sets error display style * * * Arg: t [UNKN ] Undocumented argument [ErrorDisplayType] * */ void Wise2_set_error_display_style(ErrorDisplayType t); #define set_error_display_style Wise2_set_error_display_style /* Function: set_log_display_string(str) * * Descrip: sets string for log display type * * * Arg: str [UNKN ] Undocumented argument [char *] * */ void Wise2_set_log_display_string(char * str); #define set_log_display_string Wise2_set_log_display_string /* Function: push_errormsg_stack_call(ecall) * * Descrip: This adds a function call for people who want * to register error handling functions * * Probably best wrapped by a separate function * * * Arg: ecall [UNKN ] Undocumented argument [NullString] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_push_errormsg_stack_call( char * (*ecall)(void)); #define push_errormsg_stack_call Wise2_push_errormsg_stack_call /* Function: pop_errormsg_stack(void) * * Descrip: This removes a error message from the stack * * * */ void Wise2_pop_errormsg_stack(void); #define pop_errormsg_stack Wise2_pop_errormsg_stack /* Function: add_log_filename(filename) * * Descrip: Opens filename as the log file. * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_log_filename(char * filename); #define add_log_filename Wise2_add_log_filename /* Function: error_off(type) * * Descrip: Really for the API. Wraps some * of the error concepts.. * * * Arg: type [UNKN ] Undocumented argument [int] * */ void Wise2_error_off(int type); #define error_off Wise2_error_off /* Function: error_on(type) * * Descrip: Really for the API. Wraps some * of the error concepts.. * * * Arg: type [UNKN ] Undocumented argument [int] * */ void Wise2_error_on(int type); #define error_on Wise2_error_on /* Function: error_flag_on(type,f) * * Descrip: Turns on the particular type of error flag * (eg, STDERR etc). * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: f [UNKN ] Undocumented argument [Flag] * */ void Wise2_error_flag_on(int type,Flag f); #define error_flag_on Wise2_error_flag_on /* Function: error_flag_off(type,f) * * Descrip: Turns off the particular type of error flag * (eg, STDERR etc). * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: f [UNKN ] Undocumented argument [Flag] * */ void Wise2_error_flag_off(int type,Flag f); #define error_flag_off Wise2_error_flag_off /* Function: catch_errors(catch) * * Descrip: This is a wrapper for the error handling * system. It does the following things * * Sets function as the function to process errors * * Switches the INFO,ERROR and FATAL flags off on STDERR * and on to ERROR CALL. * * * Arg: catch [FUNCP] [void (*catch] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_catch_errors(void (*catch)(char *,int)); #define catch_errors Wise2_catch_errors /* Function: stop_catching_errors(void) * * Descrip: Switches off error catching, * putting flags back on to STDERR * * * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_stop_catching_errors(void); #define stop_catching_errors Wise2_stop_catching_errors /* Function: push_error_call() * * Descrip: Registers this function for dealing with errors * * Try to use catch_errors instead * * * * Arg: [UNKN ] Undocumented argument [NullString] * */ void Wise2_push_error_call(void (* func)(char *,int)); #define push_error_call Wise2_push_error_call /* Function: pop_error_call(void) * * Descrip: Discards current function for dealing with errors * * * */ void Wise2_pop_error_call(void); #define pop_error_call Wise2_pop_error_call /* Function: type_to_error(type) * * Descrip: Turns int error types to Names * for display purposes. * * * Arg: type [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_type_to_error(int type); #define type_to_error Wise2_type_to_error /* Function: info(msg,) * * Descrip: Produces a 'info' error message. * * * Arg: msg [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * */ void Wise2_info(char * msg, ...); #define info Wise2_info /* Function: debug_report(msg,) * * Descrip: Produces a 'debug report' error message. * * * Arg: msg [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * */ void Wise2_debug_report(char * msg, ...); #define debug_report Wise2_debug_report /* Function: warn(msg,) * * Descrip: Produces a 'warn' error message. * * * Arg: msg [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * */ void Wise2_warn(char * msg, ...); #define warn Wise2_warn /* Function: fatal(msg,) * * Descrip: Produces a 'fatal' error message. * * * Arg: msg [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * */ void Wise2_fatal(char * msg, ...); #define fatal Wise2_fatal /* Function: log_full_error(type,location,msg,) * * Descrip: Deprecated * * produces any of the error types * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: location [UNKN ] Undocumented argument [int] * Arg: msg [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * */ void Wise2_log_full_error(int type,int location,char * msg, ...); #define log_full_error Wise2_log_full_error /* Function: start_reporting(msg,) * * Descrip: Starts a % reporting run. This is the header message * * * Arg: msg [UNKN ] Undocumented argument [char *] * Arg: [UNKN ] Undocumented argument [.] * */ void Wise2_start_reporting(char * msg,...); #define start_reporting Wise2_start_reporting /* Function: stop_reporting(void) * * Descrip: Stops a % reporting run. * * * */ void Wise2_stop_reporting(void); #define stop_reporting Wise2_stop_reporting /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_push_errormsg_stack(char * msg, ...); #define push_errormsg_stack Wise2_push_errormsg_stack void Wise2_show_message_stack(FILE * ofp); #define show_message_stack Wise2_show_message_stack void Wise2_add_log_file(FILE * ofp); #define add_log_file Wise2_add_log_file void Wise2_show_error(Flag flag,char * othermsg,int type); #define show_error Wise2_show_error #ifdef _cplusplus } #endif #endif wise-2.4.1/src/base/wisefile.dy0000755000175000001440000001525207723613465015744 0ustar philippusers %{ #include "wisebase.h" #ifndef MAXPATHLEN #define MAXPATHLEN 1024 #endif #ifdef FILE_DEBUG #define fclose myfclose #endif /* define here for the moment, as we always compile with it */ #define NOERROR #ifdef NOERROR #define ERRORSTR "No error available" #else #define ERRORSTR strerror(errno) #endif %} api func openfile endapi %{ #include "wisefile.h" #ifdef UNIX static boolean isvms = FALSE; #else static boolean isvms= TRUE; #endif static char * systemconfigdir=NULL; static char * personaldir=NULL; static char * homedir=NULL; static boolean hasloaded=FALSE; %func Programmatically set systemconfigdir to override any value set (or not) by env.var. WISECONFIGDIR. Added by arve. %arg path path that WISECONFIGDIR is set to %% void set_config_dir(char *path) { if (systemconfigdir != NULL ) { ckfree(systemconfigdir); } systemconfigdir = stringalloc(path); } %func reports the fclose type etc %% int myfclose(FILE * ofp) { fprintf(stderr,"Closing %d\n",ofp); #undef fclose fclose(ofp); return 1; } %func Loads up 'standard' path places %type internal %% void try_to_load(void) { char * runner; char buffer[256]; if( hasloaded == TRUE) log_full_error(PEDANTIC,0,"Trying to reload configdirs"); if( (runner=getenv("WISECONFIGDIR")) != NULL) { if( runner[strlen(runner)-1] == '/' ) systemconfigdir=stringalloc(runner); else { sprintf(buffer,"%s/",runner); systemconfigdir=stringalloc(buffer); } } if( (runner=getenv("WISEPERSONALDIR")) != NULL) { personaldir=stringalloc(runner); } if( (runner=getenv("HOME")) != NULL) { homedir=stringalloc(runner); } hasloaded=TRUE; } %func silly function to provide a boolean wrapper around remove. %% boolean remove_file(char * filename) { if( remove(filename) == 0) return TRUE; else return FALSE; } %func silly function to provide a boolean wrapper around rename %% boolean move_file(char * from,char * to) { if( rename(from,to) == 0) return TRUE; else return FALSE; } %func Appends file onto path in buffer %type internal %% boolean append_file_to_path(char * buffer,int len,const char * file,char * path) { char * runner; if( 1+strlen(file)+strlen(path) > len) { warn("Unable to expand %s with %s due to lack of buffer space",path,file); return FALSE; } strcpy(buffer,path); runner=buffer+strlen(buffer); #ifdef UNIX if( *runner != '/') { *(runner++)='/'; *runner='\0'; } #endif strcat(buffer,file); return TRUE; } %func sees if filename exists %% boolean touchfile(char * filename) { FILE * temp; boolean retval; if( filename == NULL ) { warn("Tried to touch a NULL filename"); return FALSE; } if( (temp=openfile(filename,"r")) == NULL) { retval=FALSE; } else { fclose(temp); retval=TRUE; } return retval; } %func Every file open goes through this. It opens for reading in the following order . WISEPERSONALDIR WISECONFIGDIR For writing it opens in . Filenames with ~'s are expanded to HOME/filename %arg filename filename to open for read/writing passedprot string representing standard fopen attributes return open'd filehandle, NULL on error %% FILE * openfile(const char * filename,const char * passedprot) { FILE * ifp; char buffer[MAXPATHLEN]; char prot[12]; /* protection string longer than 12 ! */ boolean shouldreporterror=FALSE; strncpy(prot,passedprot,12); if( *prot == 'R' ) { shouldreporterror=TRUE; *prot = 'r'; } if( *prot == 'W' ){ shouldreporterror=TRUE; *prot = 'w'; } if( filename == NULL) { if( shouldreporterror ) info("Open for file failed due to NULL filename"); return NULL; } if( strcmp(filename,"-") == 0 ) { if( *prot == 'r' ) return stdin; else return stdout; } if( (ifp=fopen(filename,prot)) != NULL) { #ifdef FILE_DEBUG fprintf(stderr,"Succeeded in opening %s. Filehandle is %d\n",filename,ifp); #endif return ifp; } if( shouldreporterror ) { info("Direct open for [%s,%s] failed: Error message is %s",filename,prot, ERRORSTR); } if( hasloaded == FALSE) try_to_load(); if( isvms != TRUE && homedir != NULL && filename[0]== '~' && filename[1] == '/') if( append_file_to_path(buffer,MAXPATHLEN,filename+2,homedir) != FALSE ) { /*fprintf(stderr,"Trying to load %s\n",buffer);*/ if( (ifp=fopen(buffer,prot)) != NULL) return ifp; else if( shouldreporterror ) info("Expanded tilda open for[%s,%s], expanded to %s failed: Error message is %s",filename,prot,buffer, ERRORSTR); } if( strchr(prot,'w') != NULL) return NULL; /* next line ABSOLUTELY relies on order of evaluation */ if( personaldir != NULL && append_file_to_path(buffer,MAXPATHLEN,filename,personaldir) != FALSE && (ifp=fopen(buffer,prot)) != NULL) return ifp; else if ( shouldreporterror ) log_full_error(INFO,0,"Expanded personal direcotry open for[%s,%s], expanded to %s failed: Error message is %s",filename,prot,buffer,ERRORSTR); /* next line ABSOLUTELY relies on order of evaluation */ if( systemconfigdir != NULL && append_file_to_path(buffer,MAXPATHLEN,filename,systemconfigdir) != FALSE && (ifp=fopen(buffer,prot)) != NULL) return ifp; else if ( shouldreporterror ) log_full_error(INFO,0,"Expanded system directory open for[%s,%s], expanded to %s failed: Error message is %s",filename,prot,buffer, ERRORSTR); #ifdef CAREFUL if( looks_like_vms(filename) && isvms == FALSE) log_full_error(WARNING,0,"Filename %s looks like a VMS " "file to me, and you've compiled as UNIX",filename); if( looks_like_unix(filename) && isvms == TRUE) log_full_error(WARNING,0,"Filename %s looks like a UNIX " "file to me, and you've compiled as VMS",filename); #endif return NULL; } %func This function basically mirrors the function in file.c in HMMer2. You call it as fp = Envfile(filename,envname); where envname looks like "BLASTDB" etc. %arg name r filename to open envname r enviroment variable to read from return a valid file pointer or NULL %% FILE * envopenfile(char * filename,char * env) { char * envp; char path [512]; if( filename == NULL || env == NULL ) { warn("Passed a NULL filename or enviroment name into Envfile. Should trap this elsewhere"); return NULL; } if( (envp = getenv(env)) == NULL ) { /* fail gracefully - somebody might query a number of enviroment variables */ return NULL; } if( strlen(filename) + strlen(envp) < 490 ) { warn("Really long filename/enviroment variables [%s] [%s] Can't cope!",filename,envp); return NULL; } sprintf(path,"%s/%s",filename,envp); return fopen(path,"r"); } %} wise-2.4.1/src/base/wisetime.dy0000755000175000001440000000077607313404532015754 0ustar philippusers%{ #include "wisebase.h" #include %} %{ #include "wisetime.h" %func returns a buffer of the current date and time %% char * now_string(void) { char * temp; char * runner; time_t now; now=time(NULL); temp=ctime(&now); runner=temp+strlen(temp); runner--; *runner='\0'; /* got rid of annoying new line */ return temp; } %func puts now_string into file, with no newline %% void time_stamp(FILE * ofp) { time_t now; now=time(NULL); fputs(ctime(&now),ofp); return; } %} wise-2.4.1/src/base/wisememman.dy0000755000175000001440000000760407313404532016265 0ustar philippusers%{ #define CKALLOC_GUARD #include "wisebase.h" #undef CKALLOC_GUARD #define WISE_MEMORY_WATCH_MAX 4096 %} %{ #include "wisememman.h" #ifdef WISE_MEMORY_WATCH struct wise_memory_watcher { void * position; int amount; int has_freed; char * file; int lineno; }; static struct wise_memory_watcher mempool[WISE_MEMORY_WATCH_MAX]; static int nextpool = 0; %func Displays to filehandle all non freed memory %% void display_allocated_memory(char * tag,FILE * ofp) { int i; for(i=0;i < nextpool && i= WISE_MEMORY_WATCH_MAX ) { warn("Memory allocation over limits for watching"); return malloc(no_bytes); } mempool[nextpool].position = malloc(no_bytes); mempool[nextpool].amount = no_bytes; mempool[nextpool].has_freed = FALSE; mempool[nextpool].file = file; mempool[nextpool].lineno = lineno; nextpool++; return mempool[nextpool-1].position; } %func Only if compiled with WISE_MEMORY_WATCH Allocates memory and watches the usage of it %% void * allocate_watched_memory(int no_bytes) { if( nextpool >= WISE_MEMORY_WATCH_MAX ) { warn("Memory allocation over limits for watching"); return malloc(no_bytes); } mempool[nextpool].position = malloc(no_bytes); mempool[nextpool].amount = no_bytes; mempool[nextpool].has_freed = FALSE; mempool[nextpool].file = NULL; mempool[nextpool].lineno = -1; nextpool++; return mempool[nextpool-1].position; } %func Only if compiled with WISE_MEMORY_WATCH frees memory that has been watched %% void * free_watched_memory(void * mem) { int i; for(i=0;i < nextpool && i boolean read_set_config(void); char ** filename_list(int * retval); int config_is_key(char * key); /* if keyword is present in list then return 1 else return 0 */ char * config_string_from_key(char * key); /* if keyword is present then return string: if no keyword */ /* will return NULL: however, string could be NULL: a NULL */ /* return could mean either no keyword or NULL string */ /* associated with keyword. Test with config_is_key */ char * config_single_from_key(char * key); /* if keyword is present, returns the a string whith the first word */ /* all packed up: string has been alloced... so free it if you like*/ int config_number_from_key(char * key,int * pass); /* will put the value of the first word associated with key */ /* into *pass using atoi: will return 0 if success, and */ /* 1 if not */ int read_config_file(char * filename); /* reads in a config file */ /* internal functions: don't call 'em !!! */ char * read_config_string(char * base,char * string,FILE * ifp); int index_from_keyword(char * key); #endif /* of EWANCONFIG */ wise-2.4.1/src/base/linesubs.dy0000644000175000001440000000723507313404531015743 0ustar philippusers%{ #include "wisebase.h" typedef struct { char * key; char * replace; } KeyandReplace; %} %{ #include "linesubs.h" /* this module is a little hacky... */ /* It has buffers for loading in lines */ /* and will edit them with the keys given */ #define MAXEDITLINE 512 #define MAXREPLACEMENT 256 static char input[MAXEDITLINE]; static char output[MAXEDITLINE]; static KeyandReplace kandr[MAXREPLACEMENT]; static int size = 0; static int nest=0; void scan_and_replace(KeyandReplace * kr) { char * runner; char * run2; char * o; if( (runner=strstr(input,kr->key)) == NULL) return; /* nothing to do */ if( nest > 100 ) { warn("scan and replaced one line more than 100 times; dropping out!"); return; } /*** copy upto runner in input ***/ for(run2=input,o=output; run2 < runner && *run2 != '\0';) *(o++)=(*(run2++)); /*** copy replace into output ***/ for(run2=kr->replace; *run2 != '\0';) *(o++)=(*(run2++)); /*** find end of key ***/ runner += strlen(kr->key); /*** copy rest of string into output ****/ for(run2=runner; *run2 != '\0';) *(o++)=(*(run2++)); /*** add terminal 0 ****/ *o = '\0'; /*** move back to input ***/ strcpy(input,output); /*** call again in case there are more to do ***/ nest++; scan_and_replace(kr); return; } char * scan_and_replace_line(char * line) { register int i; /*** load in line ***/ strcpy(input,line); for(i=0;i MAXREPLACEMENT ) { log_full_error(WARNING,0,"Scan and replace overflow for %s key\n",key); return FALSE; } kandr[size].key = stringalloc(key); kandr[size].replace = stringalloc(replace); size++; return TRUE; } boolean pop_scan_and_replace_pair(void) { if( size == 0 ) { warn("Attempting to pop an empty scan and replace stack"); return FALSE; } ckfree(kandr[size-1].key); ckfree(kandr[size-1].replace); size--; return TRUE; } void flush_scan_and_replace(void) { register int i; for(i=0;i < size;i++) { ckfree(kandr[i].key); ckfree(kandr[i].replace); } size = 0; return; } void read_plain_scan_and_replace(char * filename) { FILE * ifp; ifp = openfile(filename,"r"); if( ifp == NULL ) { log_full_error(WARNING,0,"Cannot open filename %s \n",filename); return; } read_scan_and_replace_file(ifp,"endofscanfile"); fclose(ifp); return; } void read_scan_and_replace_file(FILE * ifp,char * endstring) { char buffer[MAXLINE]; char ** base,**brk; char * key; char * runner; while( fgets(buffer,MAXLINE,ifp) != NULL) { /* fprintf(stderr,"Read line %s\n",buffer); */ if( endstring != NULL && endstring[0] != '\0' && strstartcmp(buffer,endstring) == 0) break; if( buffer[0] == '#' || buffer[0] == '!') continue; base = brk = breakstring_protect(buffer,spacestr,"@"); if( base == NULL || *brk == NULL ) { log_full_error(WARNING,0,"Picked up problem in read scan and replace file"); continue; } key = *brk; brk++; if( *brk == NULL ) { log_full_error(WARNING,0,"Picked up problem in read scan and replace file key %s has no replace",key); continue; } if( **brk == '@' ) (*brk)++; runner = (*brk) + strlen((*brk)); runner--; if( *runner == '@') *runner = '\0'; push_scan_and_replace_pair(key,*brk); ckfree(base); } return; } wise-2.4.1/src/base/wiserandom.c0000644000175000001440000000232510670453712016075 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "wiserandom.h" static boolean isinit = FALSE; /* Function: init_random(void) * * Descrip: initates the random generator to * time byte... * * * */ # line 20 "wiserandom.dy" void init_random(void) { srandom((long) time(NULL)); isinit = TRUE; } /* Function: random_integer(l) * * Descrip: returns an integer between 0 and l * though I don't think we will get 0 * very often. Hmmm. * * * Arg: l [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ # line 31 "wiserandom.dy" int random_integer(int l) { double rand; rand = random_0_to_1(); return (int) (l*rand); } /* Function: random_0_to_1(void) * * Descrip: returns a random number between * 0 and 1 * * * * Return [UNKN ] Undocumented return value [double] * */ # line 44 "wiserandom.dy" double random_0_to_1(void) { double ret; long rnd; if( isinit == FALSE) init_random(); isinit = TRUE; rnd = random(); ret = (double)rnd / (double)LONG_MAX; /* fprintf(stderr," got... %D %f\n",rnd,ret);*/ return ret; } # line 67 "wiserandom.c" #ifdef _cplusplus } #endif wise-2.4.1/src/base/wiserandom.h0000644000175000001440000000306710670453712016106 0ustar philippusers#ifndef DYNAMITEwiserandomHEADERFILE #define DYNAMITEwiserandomHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include #include /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: init_random(void) * * Descrip: initates the random generator to * time byte... * * * */ void Wise2_init_random(void); #define init_random Wise2_init_random /* Function: random_integer(l) * * Descrip: returns an integer between 0 and l * though I don't think we will get 0 * very often. Hmmm. * * * Arg: l [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_random_integer(int l); #define random_integer Wise2_random_integer /* Function: random_0_to_1(void) * * Descrip: returns a random number between * 0 and 1 * * * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_random_0_to_1(void); #define random_0_to_1 Wise2_random_0_to_1 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/base/wiseerror_api.h0000644000175000001440000000345310670453712016607 0ustar philippusers /* Helper functions in the module * * Wise2_catch_errors * Wise2_stop_catching_errors * Wise2_warn * Wise2_info * Wise2_fatal * /* These functions are not associated with an object */ /* Function: Wise2_catch_errors(catch) * * Descrip: This is a wrapper for the error handling * system. It does the following things * * Sets function as the function to process errors * * Switches the INFO,ERROR and FATAL flags off on STDERR * and on to ERROR CALL. * * * Arg: catch [void (*catch] * * Returns Undocumented return value [boolean] * */ boolean Wise2_catch_errors( void (*catch)(char *,int)); /* Function: Wise2_stop_catching_errors(void) * * Descrip: Switches off error catching, * putting flags back on to STDERR * * * * Returns Undocumented return value [boolean] * */ boolean Wise2_stop_catching_errors(); /* Function: Wise2_warn(msg,) * * Descrip: Produces a 'warn' error message. * * * Arg: msg Undocumented argument [char *] * Arg: Undocumented argument [Wise2_.] * * Returns Undocumented return value [void] * */ void Wise2_warn( char * msg,Wise2_. ); /* Function: Wise2_info(msg,) * * Descrip: Produces a 'info' error message. * * * Arg: msg Undocumented argument [char *] * Arg: Undocumented argument [Wise2_.] * * Returns Undocumented return value [void] * */ void Wise2_info( char * msg,Wise2_. ); /* Function: Wise2_fatal(msg,) * * Descrip: Produces a 'fatal' error message. * * * Arg: msg Undocumented argument [char *] * Arg: Undocumented argument [Wise2_.] * * Returns Undocumented return value [void] * */ void Wise2_fatal( char * msg,Wise2_. ); wise-2.4.1/src/base/wiseerror_api.t0000644000175000001440000000000010670453712016604 0ustar philippuserswise-2.4.1/src/base/wisebase.h0000644000175000001440000000260710416533675015544 0ustar philippusers #ifndef TOPBASEHEADER #define TOPBASEHEADER #include #include #include #include #include #include #include #include #include #include #include #ifdef COMPILE_VERBOSITY #define COMPILE_VERBOSITY_FLAG 1 #else #define COMPILE_VERBOSITY_FLAG 0 #endif #define VERBOSITY_CHECK(level,verbosity) ((COMPILE_VERBOSITY_FLAG == 1)&(verbosity > level)) #define PTHREAD /**** OK some system wide defines now - used all over the place ****/ #define MAXLINE 512 /* generalised maximum input line */ #define MAXBINARYDUMP 1024 /*** ok could be tricky here... ****/ #ifndef BOOLEANDEFINED typedef int boolean; #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #define BOOLEANDEFINED #endif #ifdef PTHREAD #include #endif /**** include the rest of the base files ****/ #include "wisestring.h" #include "wisefile.h" #include "wiseconfig.h" #include "wisetime.h" #include "wiserandom.h" #include "wisememman.h" /* memory manager - ckalloc/ckfree etc */ #include "wiseerror.h" #include "wiseoverlay.h" #include "commandline.h" /* stream wrappers */ #include "wisestreaminterface.h" #ifdef WISE_MEMORY_WATCH #ifndef CKALLOC_GUARD #undef ckalloc #define ckalloc(byte) allocate_watched_memory_file(__FILE__,__LINE__,byte) #endif #endif #define error warn #endif /* TOP_BASE.H loaded */ wise-2.4.1/src/base/wisestreaminterface.dy0000644000175000001440000000715107734316543020174 0ustar philippusers %{ #include "wisebase.h" typedef struct Wise2_Stream_Read_Interface { char* (*read_buffer)(void *,char*,int); boolean (*is_end)(void*); void (*close_and_free_handle)(void *); void * handle; } Wise2ReadStreamInterface; typedef struct Wise2_Stream_Write_Interface { void (*write_buffer)(void *,char*); void (*write_bufferf)(void *,char*,...); void (*close_and_free_handle)(void *); void * handle; } Wise2WriteStreamInterface; #define WISE2_READ_BUFFER(buffer,length,ri) ((*ri->read_buffer)(ri->handle,buffer,length)) #define WISE2_WRITE_STRING(string,wi) ((*wi->write_buffer)(wi->handle,string)) %} %{ #include "wisestreaminterface.h" %func Implementation function for normal files for reading %% char * read_buffer_FILE_impl(void * handle,char * input_buffer,int maxsize) { char * ret; FILE * ifp = (FILE *)handle; ret = fgets(input_buffer,maxsize,ifp); return ret; } %func Implementation function for normal files for end flag %% boolean is_end_FILE_impl(void * handle) { FILE * ifp = (FILE *)handle; if( feof(ifp) ) { return TRUE; } else { return FALSE; } } %func Implementation function for normal files for closing. Works for both reading and writing %% void close_and_free_FILE_impl(void * handle) { FILE * ifp = (FILE *)handle; fclose(ifp); } %func Makes a Wise2ReadStream interface from a normal C filehandle %% Wise2ReadStreamInterface * ReadStream_from_FILE(FILE * ifp) { Wise2ReadStreamInterface * out; out = malloc(sizeof(Wise2ReadStreamInterface)); out->read_buffer = read_buffer_FILE_impl; out->is_end = is_end_FILE_impl; out->close_and_free_handle = close_and_free_FILE_impl; out->handle = (void*) ifp; return out; } %func opens a file from filename and gives back a ReadStream, NULL if unable to return %% Wise2ReadStreamInterface * ReadStream_openfile(char * filename) { FILE * ifp; assert(filename != NULL); ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Unable to open file %s",filename); return NULL; } return ReadStream_from_FILE(ifp); } %func implementation for normal C files for string writing %% void write_buffer_FILE_impl(void * handle,char * string) { FILE * ifp = (FILE *)handle; fputs(string,ifp); return; } %func implementation for normal C files for formatted writing %% void write_bufferf_FILE_impl(void * handle,char * format,...) { FILE * ifp = (FILE *)handle; char buffer[1024]; va_list ap; va_start(ap,format); vsprintf(buffer,format,ap); fputs(buffer,ifp); return; } %func makes a WriteStream from a normal C FILE structure %% Wise2WriteStreamInterface * WriteStream_from_FILE(FILE * ofp) { Wise2WriteStreamInterface * out; out = malloc(sizeof(Wise2WriteStreamInterface)); out->write_buffer = write_buffer_FILE_impl; out->write_bufferf = write_bufferf_FILE_impl; out->close_and_free_handle = close_and_free_FILE_impl; out->handle = (void*) ofp; return out; } %func opens a file from filename and gives back a WriteStream, NULL if unable to return %% Wise2WriteStreamInterface * WriteStream_openfile(char * filename) { FILE * ofp; assert(filename != NULL); ofp = openfile(filename,"w"); if( ofp == NULL ) { warn("Unable to open file %s",filename); return NULL; } return WriteStream_from_FILE(ofp); } %func helper function - cats one stream into another %% void cat_ReadStream_into_WriteStream(Wise2ReadStreamInterface * rs,Wise2WriteStreamInterface * ws) { char str[1024]; while( (*rs->is_end)(rs->handle) != TRUE ) { if( (*rs->read_buffer)(rs->handle,str,1024) == NULL ) { return; } (*ws->write_buffer)(ws->handle,str); } } %} wise-2.4.1/src/base/wisefile.c0000644000175000001440000002105210670453712015532 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "wisefile.h" #ifdef UNIX static boolean isvms = FALSE; #else static boolean isvms= TRUE; #endif static char * systemconfigdir=NULL; static char * personaldir=NULL; static char * homedir=NULL; static boolean hasloaded=FALSE; /* Function: set_config_dir(path,*path) * * Descrip: Programmatically set systemconfigdir to override * any value set (or not) by env.var. WISECONFIGDIR. * * Added by arve. * * * Arg: path [UNKN ] path that WISECONFIGDIR is set to [NullString] * Arg: *path [UNKN ] Undocumented argument [char] * */ # line 58 "wisefile.dy" void set_config_dir(char *path) { if (systemconfigdir != NULL ) { ckfree(systemconfigdir); } systemconfigdir = stringalloc(path); } /* Function: myfclose(ofp) * * Descrip: reports the fclose type etc * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [int] * */ # line 70 "wisefile.dy" int myfclose(FILE * ofp) { fprintf(stderr,"Closing %d\n",ofp); #undef fclose fclose(ofp); return 1; } /* Function: try_to_load(void) * * Descrip: Loads up 'standard' path places * * * */ # line 83 "wisefile.dy" void try_to_load(void) { char * runner; char buffer[256]; if( hasloaded == TRUE) log_full_error(PEDANTIC,0,"Trying to reload configdirs"); if( (runner=getenv("WISECONFIGDIR")) != NULL) { if( runner[strlen(runner)-1] == '/' ) systemconfigdir=stringalloc(runner); else { sprintf(buffer,"%s/",runner); systemconfigdir=stringalloc(buffer); } } if( (runner=getenv("WISEPERSONALDIR")) != NULL) { personaldir=stringalloc(runner); } if( (runner=getenv("HOME")) != NULL) { homedir=stringalloc(runner); } hasloaded=TRUE; } /* Function: remove_file(filename) * * Descrip: silly function to provide a boolean wrapper * around remove. * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 117 "wisefile.dy" boolean remove_file(char * filename) { if( remove(filename) == 0) return TRUE; else return FALSE; } /* Function: move_file(from,to) * * Descrip: silly function to provide a boolean wrapper * around rename * * * Arg: from [UNKN ] Undocumented argument [char *] * Arg: to [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 128 "wisefile.dy" boolean move_file(char * from,char * to) { if( rename(from,to) == 0) return TRUE; else return FALSE; } /* Function: append_file_to_path(buffer,len,file,path) * * Descrip: Appends file onto path in buffer * * * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: len [UNKN ] Undocumented argument [int] * Arg: file [UNKN ] Undocumented argument [const char *] * Arg: path [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 139 "wisefile.dy" boolean append_file_to_path(char * buffer,int len,const char * file,char * path) { char * runner; if( 1+strlen(file)+strlen(path) > len) { warn("Unable to expand %s with %s due to lack of buffer space",path,file); return FALSE; } strcpy(buffer,path); runner=buffer+strlen(buffer); #ifdef UNIX if( *runner != '/') { *(runner++)='/'; *runner='\0'; } #endif strcat(buffer,file); return TRUE; } /* Function: touchfile(filename) * * Descrip: sees if filename exists * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 166 "wisefile.dy" boolean touchfile(char * filename) { FILE * temp; boolean retval; if( filename == NULL ) { warn("Tried to touch a NULL filename"); return FALSE; } if( (temp=openfile(filename,"r")) == NULL) { retval=FALSE; } else { fclose(temp); retval=TRUE; } return retval; } /* Function: openfile(filename,passedprot) * * Descrip: Every file open goes through this. * * It opens for reading in the following order * . * WISEPERSONALDIR * WISECONFIGDIR * * For writing it opens in . * * Filenames with ~'s are expanded to HOME/filename * * * Arg: filename [UNKN ] filename to open for read/writing [const char *] * Arg: passedprot [UNKN ] string representing standard fopen attributes [const char *] * * Return [UNKN ] open'd filehandle, NULL on error [FILE *] * */ # line 205 "wisefile.dy" FILE * openfile(const char * filename,const char * passedprot) { FILE * ifp; char buffer[MAXPATHLEN]; char prot[12]; /* protection string longer than 12 ! */ boolean shouldreporterror=FALSE; strncpy(prot,passedprot,12); if( *prot == 'R' ) { shouldreporterror=TRUE; *prot = 'r'; } if( *prot == 'W' ){ shouldreporterror=TRUE; *prot = 'w'; } if( filename == NULL) { if( shouldreporterror ) info("Open for file failed due to NULL filename"); return NULL; } if( strcmp(filename,"-") == 0 ) { if( *prot == 'r' ) return stdin; else return stdout; } if( (ifp=fopen(filename,prot)) != NULL) { #ifdef FILE_DEBUG fprintf(stderr,"Succeeded in opening %s. Filehandle is %d\n",filename,ifp); #endif return ifp; } if( shouldreporterror ) { info("Direct open for [%s,%s] failed: Error message is %s",filename,prot, ERRORSTR); } if( hasloaded == FALSE) try_to_load(); if( isvms != TRUE && homedir != NULL && filename[0]== '~' && filename[1] == '/') if( append_file_to_path(buffer,MAXPATHLEN,filename+2,homedir) != FALSE ) { /*fprintf(stderr,"Trying to load %s\n",buffer);*/ if( (ifp=fopen(buffer,prot)) != NULL) return ifp; else if( shouldreporterror ) info("Expanded tilda open for[%s,%s], expanded to %s failed: Error message is %s",filename,prot,buffer, ERRORSTR); } if( strchr(prot,'w') != NULL) return NULL; /* next line ABSOLUTELY relies on order of evaluation */ if( personaldir != NULL && append_file_to_path(buffer,MAXPATHLEN,filename,personaldir) != FALSE && (ifp=fopen(buffer,prot)) != NULL) return ifp; else if ( shouldreporterror ) log_full_error(INFO,0,"Expanded personal direcotry open for[%s,%s], expanded to %s failed: Error message is %s",filename,prot,buffer,ERRORSTR); /* next line ABSOLUTELY relies on order of evaluation */ if( systemconfigdir != NULL && append_file_to_path(buffer,MAXPATHLEN,filename,systemconfigdir) != FALSE && (ifp=fopen(buffer,prot)) != NULL) return ifp; else if ( shouldreporterror ) log_full_error(INFO,0,"Expanded system directory open for[%s,%s], expanded to %s failed: Error message is %s",filename,prot,buffer, ERRORSTR); #ifdef CAREFUL if( looks_like_vms(filename) && isvms == FALSE) log_full_error(WARNING,0,"Filename %s looks like a VMS " "file to me, and you've compiled as UNIX",filename); if( looks_like_unix(filename) && isvms == TRUE) log_full_error(WARNING,0,"Filename %s looks like a UNIX " "file to me, and you've compiled as VMS",filename); #endif return NULL; } /* Function: envopenfile(envname,filename,name,env) * * Descrip: This function basically mirrors the function in file.c * in HMMer2. You call it as * * fp = Envfile(filename,envname); * * where envname looks like "BLASTDB" etc. * * * * Arg: envname [READ ] enviroment variable to read from [NullString] * Arg: filename [UNKN ] Undocumented argument [char *] * Arg: name [READ ] filename to open [NullString] * Arg: env [UNKN ] Undocumented argument [char *] * * Return [UNKN ] a valid file pointer or NULL [FILE *] * */ # line 308 "wisefile.dy" FILE * envopenfile(char * filename,char * env) { char * envp; char path [512]; if( filename == NULL || env == NULL ) { warn("Passed a NULL filename or enviroment name into Envfile. Should trap this elsewhere"); return NULL; } if( (envp = getenv(env)) == NULL ) { /* fail gracefully - somebody might query a number of enviroment variables */ return NULL; } if( strlen(filename) + strlen(envp) < 490 ) { warn("Really long filename/enviroment variables [%s] [%s] Can't cope!",filename,envp); return NULL; } sprintf(path,"%s/%s",filename,envp); return fopen(path,"r"); } # line 347 "wisefile.c" #ifdef _cplusplus } #endif wise-2.4.1/src/base/wisefile.h0000644000175000001440000001046110670453712015541 0ustar philippusers#ifndef DYNAMITEwisefileHEADERFILE #define DYNAMITEwisefileHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #ifndef MAXPATHLEN #define MAXPATHLEN 1024 #endif #ifdef FILE_DEBUG #define fclose myfclose #endif /* define here for the moment, as we always compile with it */ #define NOERROR #ifdef NOERROR #define ERRORSTR "No error available" #else #define ERRORSTR strerror(errno) #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: set_config_dir(path,*path) * * Descrip: Programmatically set systemconfigdir to override * any value set (or not) by env.var. WISECONFIGDIR. * * Added by arve. * * * Arg: path [UNKN ] path that WISECONFIGDIR is set to [NullString] * Arg: *path [UNKN ] Undocumented argument [char] * */ void Wise2_set_config_dir(char *path) ; #define set_config_dir Wise2_set_config_dir /* Function: myfclose(ofp) * * Descrip: reports the fclose type etc * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_myfclose(FILE * ofp); #define myfclose Wise2_myfclose /* Function: remove_file(filename) * * Descrip: silly function to provide a boolean wrapper * around remove. * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_remove_file(char * filename); #define remove_file Wise2_remove_file /* Function: move_file(from,to) * * Descrip: silly function to provide a boolean wrapper * around rename * * * Arg: from [UNKN ] Undocumented argument [char *] * Arg: to [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_move_file(char * from,char * to); #define move_file Wise2_move_file /* Function: touchfile(filename) * * Descrip: sees if filename exists * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_touchfile(char * filename); #define touchfile Wise2_touchfile /* Function: openfile(filename,passedprot) * * Descrip: Every file open goes through this. * * It opens for reading in the following order * . * WISEPERSONALDIR * WISECONFIGDIR * * For writing it opens in . * * Filenames with ~'s are expanded to HOME/filename * * * Arg: filename [UNKN ] filename to open for read/writing [const char *] * Arg: passedprot [UNKN ] string representing standard fopen attributes [const char *] * * Return [UNKN ] open'd filehandle, NULL on error [FILE *] * */ FILE * Wise2_openfile(const char * filename,const char * passedprot); #define openfile Wise2_openfile /* Function: envopenfile(envname,filename,name,env) * * Descrip: This function basically mirrors the function in file.c * in HMMer2. You call it as * * fp = Envfile(filename,envname); * * where envname looks like "BLASTDB" etc. * * * * Arg: envname [READ ] enviroment variable to read from [NullString] * Arg: filename [UNKN ] Undocumented argument [char *] * Arg: name [READ ] filename to open [NullString] * Arg: env [UNKN ] Undocumented argument [char *] * * Return [UNKN ] a valid file pointer or NULL [FILE *] * */ FILE * Wise2_envopenfile(char * filename,char * env); #define envopenfile Wise2_envopenfile /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_try_to_load(void); #define try_to_load Wise2_try_to_load boolean Wise2_append_file_to_path(char * buffer,int len,const char * file,char * path); #define append_file_to_path Wise2_append_file_to_path #ifdef _cplusplus } #endif #endif wise-2.4.1/src/perl/0000755000175000001440000000000010670453617013613 5ustar philippuserswise-2.4.1/src/perl/basic.typemap0000644000175000001440000000033407313404550016265 0ustar philippusersTYPEMAP void T_IV boolean T_IV aa T_CHAR codon T_IV base T_IV Score T_IV float T_DOUBLE Probability T_DOUBLE Bits T_DOUBLE wise-2.4.1/src/perl/makelib.pl0000755000175000001440000000234107313404550015547 0ustar philippusers#!/usr/local/bin/perl %dontcopy = ( 'psw' => 1, 'pswdb' => 1, 'dyc' => 1, 'genewisedb' => 1, 'estwisedb' => 1, 'genewise' => 1, 'estwise' => 1, 'oldpostwise' => 1, 'dba' => 1, 'hmmalign' => 1, 'hmmsearch' => 1, 'hmmconvert' => 1, 'hmmpfam' => 1, 'hmmbuild' => 1, ); @dirs = ( '../base' , '../dynlibsrc' , '../models' , '../HMMer2' ); foreach $dir ( @dirs ) { opendir(DIR,$dir) || die "Cannot open $dir"; @files = readdir(DIR); closedir(DIR); shift @files; shift @files; foreach ( @files ) { /^(\S+).o$/ || next; $name = $1; if( exists $dontcopy{$name} ) { next; } $dest = "$dir"; $dest =~ s/^.*\///g; $dest .= "_"; $dest .= $_; push(@objs,$dest); ©_file_if_needed("$dir/$_","Wise2/libs/$dest"); } } open(MA,">Wise2/libs/Makefile"); $files = join("\\\n\t",@objs); print MA "\nOBJS = $files\n\nlibwise2.a : \$(OBJS)\n\tar -ru libwise2.a \$(OBJS)\n"; sub copy_file_if_needed { my $file = shift; my $dest = shift; if(!(-e $dest) || (-M $file) < (-M $dest) ) { print STDERR "Updating $dest\n"; system("cp $file $dest"); } else { print STDERR "Skipping $dest\n"; } } wise-2.4.1/src/perl/Makefile0000644000175000001440000000057407313404550015251 0ustar philippusers int : cat top.xs ../dynlibsrc/*.xs ../models/*.xs > Wise2/Wise2.xs cat basic.typemap ../dynlibsrc/*.typemap ../models/*.typemap > Wise2/typemap cat basic.h ../dynlibsrc/*api.t ../models/*api.t ../dynlibsrc/*api.h ../models/*api.h > Wise2/libs/wise2.h cp ../dynlibsrc/*.pod Wise2 cp ../models/*.pod Wise2 libs : perl ./makelib.pl cd Wise2/libs ; make libwise2.a wise-2.4.1/src/perl/Wise2/0000755000175000001440000000000010670453617014604 5ustar philippuserswise-2.4.1/src/perl/Wise2/libs/0000755000175000001440000000000010670453617015535 5ustar philippuserswise-2.4.1/src/perl/Wise2/libs/README0000644000175000001440000000015507313404551016407 0ustar philippusers This directory is filled using the perl script makelib.pl two directories above. use the make libs for it wise-2.4.1/src/perl/Wise2/test.pl0000644000175000001440000001361007313404551016112 0ustar philippusers#!/usr/local/bin/perl print "1..1\n"; use Wise2; &Wise2::change_max_BaseMatrix_kbytes(20000); $cm = &Wise2::CompMat::read_Blast_file_CompMat("blosum62.bla"); $seq1 = &Wise2::new_Sequence_from_strings("one","WLGQRNLVSSTGGNLLNVWLKDW"); $seq2 = &Wise2::new_Sequence_from_strings("two","WMGNRNVVNLLNVWFRDW"); $alb = &Wise2::Align_Sequences_ProteinSmithWaterman($seq1,$seq2,$cm,-12,-2); &Wise2::write_pretty_str_align($alb,$seq1->name,$seq1->seq,$seq2->name,$seq2->seq,15,50,STDERR); $gene = new Wise2::Gene; $gene->set_start(140); $gene->set_end(180); $tr = new Wise2::Transcript; $ex = new Wise2::Exon; $ex->set_start(0); $ex->set_end(12); $tra = new Wise2::Translation; $tra->set_start(3); $tra->set_end(9); $tr->add_exon($ex); $tr->add_translation($tra); $gene->add_transcript($tr); $gene->add_transcript($tr); $gene->show_pretty_Gene(\*STDOUT); foreach $tr ( $gene->each_transcript() ) { print STDERR sprintf(" Tr was $tr with exons %d\n",$tr->length_exon()); } # # build a sequence from raw memory # $seq = &Wise2::new_Sequence_from_strings("A1-drome","MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGLDYRTTDENLKAHFEKWGNIVDVVVMKDPRTKRSRGFGFITYSHSSMIDEAQKSRPHKIDGRVVEPKRAVPRQDIDSPNAGATVKKLFVGALKDDHDEQSIRDYFQHFGNIVDINIVIDKETGKKRGFAFVEFDDYDPVDKVVLQKQHQLNGKMVDVKKALPKQNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGNQNGGGNWNNGGNNWGNNRGGNDNWGNNSFGGGGGGGGGYGGGNNSWGNNNPWDNGNGGGNFGGGGNNWNNGGNDFGGYQQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGNYGGNNQGFNNGGNNRRY"); # # Map it to a 'typed' sequence object # $pro = &Wise2::Protein::Protein_from_Sequence($seq); # # read a sequence file from a file - inbuilt data file handle! # $seq2 = &Wise2::Sequence::read_fasta_Sequence(DATA); # # Map to 'typed' sequence object # $gen = &Wise2::Genomic_from_Sequence($seq2); # # Make necessary gene object things for algorithm. There should be # an easier way of doing this. # # these are for the gene model $gf = &Wise2::read_GeneFrequency21_file("human.gf"); $ct = &Wise2::CodonTable::read_CodonTable_file("codon.table"); $rmd = &Wise2::RandomModelDNA_std(); # $gp = &Wise2::GeneParameter21_wrap($gf,0.00001,0.000001,$rmd,0,1,1,$ct,0.999,0.99,0.8,0.99,0.4); $gf = 0; &Wise2::error_on(16); #these are for the proteins... $rm = &Wise2::default_RandomModel(); $type = &Wise2::gwrap_alg_type_from_string("623"); $seq2 = $pro->baseseq(); # gets base sequence class $seq2->set_name("NewName"); # print STDERR "Comp mat is $cm and gf is $gf\n"; $pg = new Wise2::PotentialGene; $alb = &Wise2::AlnBlock_from_protein_genewise_wrap($pro,$gen,$cm,-12,-2,$gp,$rmd,$rmd,$type,0,1,$rm,0.9,$pg); &Wise2::protein2genomic_ascii_display($alb,$pro,$gen,$ct,15,50,STDERR); for($alc=$alb->start();1;) { print STDERR sprintf("Got %s at %d-%d\n",$alc->alu(1)->text_label,$alc->alu(1)->start,$alc->alu(1)->end); if( $alc->at_end() == 1) { last; } $alc2 = $alc->next(); $alc = $alc2; } __END__ >HSHNRNPA TCGCCATTTTACTACACGTGCGGTCAACAAGAGTTCATTGCAAAAAAATTGTTACCTCCT AGCTGCTTGTCTAATACATAGTGTTAATCATGCTTTGCCAAGCGACTTGACTGTAATATT TGCGCGTGGAAGATTAAAAAGATGTTAAACACCCAAGGTAGATTCAAATGTGAATGATTG GTCGGTTGGCCAATCAGACTGGTTAACAATAACATTACTCGGGAACCAATGGACTCCAAG GGGTGGAGACGGCGTAGAACGACCGAAGGAATGACGTTACACAGCAATGTGGCACCACAG GCCAATAGCAGGGGGAAGCGATTTCAAGTATCCAATCAGAGCTGTTCTAGGGCGGAGTCT ACCAATGCCGAAAGCGAGGAGGCGGGGTAAAAAAGAGAGGGCGAAGGTAGGCTGGCAGAT ACGTTCGTCAGCTTGCTCCTTTCTGCCCGTGGACGCCGCCGAAGAAGCATCGTTAAAGTC TCTCTTCACCCTGCCGTCATGTCTAAGTCAGAGGTGAGTTAGGCGCGCTTTCCCACTTGA ATTTTTTCCTCTCCCTTTCCTGAATCGGTAAGATGCTGCTGGGTTTCGTTCCTTGCACCA GCCCATTCTACAGTTCCTTCGGTCGCTGCCACGGCCTACCCCTCCCAAAGTTCAAGTCGC CATTTTGTCCTCTTGATCGCCATGAGGCCGCTCTCCGCCAACCATGTGTTATCATGCGGG ACTCGTTACTCGTAGCAAAATTCTTAGGCACACAGGATCTTTGTCTTTTTTTAAACCTTG CCTTGGTGAGCGAGTTTTCTAAAGAGCGATTAGTCCCATTGTGGAGATGCACCCCTACCG CCCAAGCCTTTGTTGCGCGTGCGTCGGAAGGCGACTAGGGACGCATGCGCTTGCGATTTC CTAGCACTCCCAACTCCAGCATACGGCCTCCCTTGATAGGCAGAAGCACGTGTCTTGTTG CGACCTGAACGAACAATAAGTGCTAGGTACACAGTTGGTGTCTAGTTTTTCTTTTCCTCG ATGGAAATTGTTTCGTGTTGTAGCCCATTTAACACTTCCCCCTCCCCCCACTCTAGTCTC CTAAAGAGCCCGAACAGCTGAGGAAGCTCTTCATTGGAGGGTTGAGCTTTGAAACAACTG ATGAGAGCCTGAGGAGCCATTTTGAGCAATGGGGAACGCTCACGGACTGTGTGGTAAGAT TTGGAAGGGACAAAGCAGTAAAACAGCCGATTTCCTTGGCTTATCTTGGTGCAGTCTTCT CCGAATGCTTATGAAAGTAGTTAATAGCATTATAGTTAGAGCTTTGTTGGCAAAGGAACG TCCTGCTTTGATTTTAAAAGCTAACCTCTTAAATCTAAGGGTAGTGGGAAACTGGACGAA CTTTTTATAAAAGGCTGGTGTAAAGTTTCCTATTGCCCTATTCAAAGTTAAAATAACAAA AGCTTTTGCGGTCAGACTTTGTGTTACATAAATTAACACTGTTCTCAGGTAATGAGAGAT CCAAACACCAAGCGCTCTAGGGGCTTTGGGTTTGTCACATATGCCACTGTGGAGGAGGTG GATGCAGCTATGAATGCAAGGCCACACAAGGTGGATGGAAGAGTTGTGGAACCAAAGAGA GCTGTCTCCAGAGAAGTGAGTGGGTTTTTTTTCTTCTTCTTCTTAAACTTACTTGGATAT GTGCTGCTATGAACTTAAGATTCGGGAGTTTTCTAAACTTACCAAAATTTTTTATTCGAG TATAGGCTTTGCTAATCTAAACCTATGGTTTTTCTCCTATTAGGATTCTCAAAGACCAGG TGCCCACTTAACTGTGAAAAAGATATTTGTTGGTGGCATTAAAGAAGACACTGAAGAACA TCACCTAAGAGATTATTTTGAACAGTATGGAAAAATTGAAGTGATTGAAATCATGACTGA CCGAGGCAGTGGCAAGAAAAGGGGCTTTGCCTTTGTAACCTTTGACGACCATGACTCCGT GGATAAGATTGTCAGTAAGTATCAGATAGTGGCATTTAGTAAGGGTTCCACAATCTGTAT GGCATTCTAAACCCTGATACCATGTTGTATCTATGTTTTTTTTTTAGTTCAGAAATACCA TACTGTGAATGGCCACAACTGTGAAGTTAGAAAAGCCCTGTCAAAGCAAGAGATGGCTAG TGCTTCATCCAGCCAAAGAGGTATGCTTGTTGCTTAATTAAACCTTAAAGGTAACTTTGA GTTACTCCAGTATGAATGATTTAATGCTTAAACTTCATGTCTTAAGGTCGAAGTGGTTCT GGAAACTTTGGTGGTGGTCGTGGAGGTGGTTTCGGTGGGAATGACAACTTCGGTCGTGGA GGAAACTTCAGTGGTCGTGGTATGTATGGTTTATCTACATGTAGTTCTGACTTCTCACCA TCTTTGCTATGAAGATTTTACAGTACGGGAACTGCATTCAGAATGTCACTTTAAGTCCAA GTCATACTTAAAACTTGAAACTTTTTCTTACAGGTGGCTTTGGTGGCAGCCGTGGTGGTG GTGGATATGGTGGCAGTGGGGATGGCTATAATGGATTTGGCAATGATGGTAAGTTTTTTA GGAATAAGTAGAGAAAAATTCCTGGCAACCTGGATCTTTAGAATAGGTTAGTAGAGACTA AAATTCTGGTGCATGTCAAACTCAACTTTGCCCATAACACGCATGCTGTGAGCAGGCCTT CAGCCGTTACACTTGCACAAGTTTTCATTGTCAAATACTTTTGTCTTATTGAGAAGAATT GTATTCTTGTAGGTGGTTATGGAGGAGGCGGCCCTGGTTACTCTGGAGGAAGCAGAGGCT ATGGAAGTGGTGGACAGGGTTATGGAAACCAGGGCAGTGGCTATGGCGGGAGTGGCAGCT ATGACAGCTATAACAACGGAGGCGGAGGCGGCTTTGGCGGTGGTAGTGGTAGGTATCCAG TGATCCAAGTACTTGGTGTGACAGCTAGATTAGCCTTTTAGAGCTTGGGTTCTGGTGCTG TTGAAGCATTGTGTGGTACACTGCATGGTATATTAAAAACAAATGGGCTTGCTATGCTAC wise-2.4.1/src/perl/Wise2/Wise2.pm0000644000175000001440000000245507313404550016131 0ustar philippusers # # Perl Module for Aceclient # # Cared for by Ewan Birney/ACeDB team # #Copyright Genome Research Limited (1997). Please see information on licensing in LICENSE # package Wise2; use vars qw($AUTOLOAD @ISA @EXPORT_OK $dl_debug); use Exporter; use Carp; use strict; use DynaLoader; use AutoLoader; @ISA = qw(Exporter DynaLoader); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant() # XS function. If a constant is not found then control is passed # to the AUTOLOAD in AutoLoader. my $constname; ($constname = $AUTOLOAD) =~ s/.*:://; my $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { if ($! =~ /Invalid/) { $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } else { croak "Your vendor has not defined Test macro $constname"; } } eval "sub $AUTOLOAD { $val }"; goto &$AUTOLOAD; } BEGIN { $dl_debug = 40; } bootstrap Wise2; # Preloaded methods go here. # Autoload methods go after __END__, and are processed by the autosplit program. 1; __END__ wise-2.4.1/src/perl/Wise2/Makefile.PL0000644000175000001440000000064307313404550016551 0ustar philippusersuse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'Wise2', 'VERSION' => '0.1', 'LIBS' => ['-lm'], # e.g., '-lm' 'DEFINE' => '-DPOSIX -DNOERROR', # e.g., '-DHAVE_SOMETHING' 'INC' => '-I./libs', # e.g., '-I/usr/include/other' 'MYEXTLIB' => 'libs/libwise2$(LIB_EXT)' ); wise-2.4.1/src/perl/Wise2/blosum62.bla0000644000175000001440000000403007313404551016723 0ustar philippusers# Matrix made by matblas from blosum62.iij # * column uses minimum score # BLOSUM Clustered Scoring Matrix in 1/2 Bit Units # Blocks Database = /data/blocks_5.0/blocks.dat # Cluster Percentage: >= 62 # Entropy = 0.6979, Expected = -0.5209 A R N D C Q E G H I L K M F P S T W Y V B Z X * 4 -1 -2 -2 0 -1 -1 0 -2 -1 -1 -1 -1 -2 -1 1 0 -3 -2 0 -2 -1 0 -4 -1 5 0 -2 -3 1 0 -2 0 -3 -2 2 -1 -3 -2 -1 -1 -3 -2 -3 -1 0 -1 -4 -2 0 6 1 -3 0 0 0 1 -3 -3 0 -2 -3 -2 1 0 -4 -2 -3 3 0 -1 -4 -2 -2 1 6 -3 0 2 -1 -1 -3 -4 -1 -3 -3 -1 0 -1 -4 -3 -3 4 1 -1 -4 0 -3 -3 -3 9 -3 -4 -3 -3 -1 -1 -3 -1 -2 -3 -1 -1 -2 -2 -1 -3 -3 -2 -4 -1 1 0 0 -3 5 2 -2 0 -3 -2 1 0 -3 -1 0 -1 -2 -1 -2 0 3 -1 -4 -1 0 0 2 -4 2 5 -2 0 -3 -3 1 -2 -3 -1 0 -1 -3 -2 -2 1 4 -1 -4 0 -2 0 -1 -3 -2 -2 6 -2 -4 -4 -2 -3 -3 -2 0 -2 -2 -3 -3 -1 -2 -1 -4 -2 0 1 -1 -3 0 0 -2 8 -3 -3 -1 -2 -1 -2 -1 -2 -2 2 -3 0 0 -1 -4 -1 -3 -3 -3 -1 -3 -3 -4 -3 4 2 -3 1 0 -3 -2 -1 -3 -1 3 -3 -3 -1 -4 -1 -2 -3 -4 -1 -2 -3 -4 -3 2 4 -2 2 0 -3 -2 -1 -2 -1 1 -4 -3 -1 -4 -1 2 0 -1 -3 1 1 -2 -1 -3 -2 5 -1 -3 -1 0 -1 -3 -2 -2 0 1 -1 -4 -1 -1 -2 -3 -1 0 -2 -3 -2 1 2 -1 5 0 -2 -1 -1 -1 -1 1 -3 -1 -1 -4 -2 -3 -3 -3 -2 -3 -3 -3 -1 0 0 -3 0 6 -4 -2 -2 1 3 -1 -3 -3 -1 -4 -1 -2 -2 -1 -3 -1 -1 -2 -2 -3 -3 -1 -2 -4 7 -1 -1 -4 -3 -2 -2 -1 -2 -4 1 -1 1 0 -1 0 0 0 -1 -2 -2 0 -1 -2 -1 4 1 -3 -2 -2 0 0 0 -4 0 -1 0 -1 -1 -1 -1 -2 -2 -1 -1 -1 -1 -2 -1 1 5 -2 -2 0 -1 -1 0 -4 -3 -3 -4 -4 -2 -2 -3 -2 -2 -3 -2 -3 -1 1 -4 -3 -2 11 2 -3 -4 -3 -2 -4 -2 -2 -2 -3 -2 -1 -2 -3 2 -1 -1 -2 -1 3 -3 -2 -2 2 7 -1 -3 -2 -1 -4 0 -3 -3 -3 -1 -2 -2 -3 -3 3 1 -2 1 -1 -2 -2 0 -3 -1 4 -3 -2 -1 -4 -2 -1 3 4 -3 0 1 -1 0 -3 -4 0 -3 -3 -2 0 -1 -4 -3 -3 4 1 -1 -4 -1 0 0 1 -3 3 4 -2 0 -3 -3 1 -1 -3 -1 0 -1 -3 -2 -2 1 4 -1 -4 0 -1 -1 -1 -2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 0 0 -2 -1 -1 -1 -1 -1 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 1 wise-2.4.1/src/perl/scripts/0000755000175000001440000000000010670453617015302 5ustar philippuserswise-2.4.1/src/perl/scripts/blastwise.pl0000755000175000001440000001702407313404551017634 0ustar philippusers#!/usr/local/bin/perl -w =head1 NAME blastwise =head1 SYNOPSIS blastwise swiss myseq.fa Blasts your fasta dna sequence against swissprot, reads in the results and then uses the GeneWise algorithm to make matches in the correct place =head1 OPTIONS To get other output options, please edit this script to your own needs. This script is really just to seed the process for your own site: I cant second guess all the things you want to do with the output, so you give it a go. This assummes that the database you are searching *is* swissprot and you have SRS indexed it into the database called swissprot. If you are running it on different database with a different indexer you will need to change the executable used to retrieve the sequence =cut use strict; no strict 'subs'; my $db = shift; my $seqfile = shift; if( !defined $seqfile ) { system("pod2text $0"); exit(1); } my $BLASTEXE = 'blastx'; # might be different on your system of course! my $TEMPFILE = "temp.bw"; # feel free to change this! my $genefile = "human.gf"; # for debugging @sanger centre use lib '/nfs/disk92/PerlSource/Bioperl/Releases/bioperl-0.05/'; BEGIN { eval { require Wise2; }; if ( $@ ) { print STDERR ("\nThe C-compiled engine for Wise2 has not been installed.\n Please read the installation instructions for Wise2 for building it\n\n - bascially make perl at the top level\n\n"); exit(1); } eval { require Bio::Tools::Blast; }; if ( $@ ) { print STDERR ("\nThe bioperl Blast object is not installed. Please install it from http://bio.perl.org/\n"); exit(1); } } my ($blast); # make genewise parameter objects # before we try to make blast my $gf = &Wise2::read_GeneFrequency21_file($genefile) || die "Could not read $genefile for parameters" ; my $ct = &Wise2::CodonTable::read_CodonTable_file("codon.table") || die "Could not read codon table"; my $rmd = &Wise2::RandomModelDNA_std() || die "Could not make standard random model (weird!)"; my $alg = &Wise2::gwrap_alg_type_from_string("623") || die "Could not make algorithm"; my $gp = &Wise2::GeneParameter21_wrap($gf,0.00001,0.000001,$rmd,0,1,1,$ct,0.999,0.99,0.8,0.99,0.4) || die "Could not make gene parameters"; # sets memory amount for main memory &Wise2::change_max_BaseMatrix_kbytes(100000); # 10 Megabytes. # # these are for the protein part of the comparison # my $cm = &Wise2::CompMat::read_Blast_file_CompMat("blosum62.bla"); my $rm = &Wise2::default_RandomModel(); # # read in the DNA sequence before anything goes wrong! # open(DNA,$seqfile) || die "Could not open $seqfile!"; my $seq = &Wise2::Sequence::read_fasta_Sequence(\*DNA); my $gen = &Wise2::Genomic_from_Sequence($seq); close(DNA); if( $gen == 0 ) { # can't interpolate function calls die sprintf("Could not genomic from sequence %s!",$seq->name()); } # we try to run blast if( ! -e $TEMPFILE ) { if ( system("$BLASTEXE $db $seqfile > $TEMPFILE") != 0 ) { die("Could not run blast [$BLASTEXE $db $seqfile > $TEMPFILE] $! $?"); } } else { print STDERR "Skipping making blast"; } # read it into Blast object. We have to catch an exception if there # is nothing on old versions of bioperl. eval { $blast = Bio::Tools::Blast->new( -file => "$TEMPFILE", -parse => 1, -signif => '1e-3', -strict => 1, ); }; if( $@ ) { print "#No hits found in the blast search\n"; exit; } # get rid of TEMPFILE now. # comment this out for debugging. unlink($TEMPFILE); # # Ok. Ready to rock and roll. Loop over blast hits. Take the hit # out - ask whether its highest HSP is already in a region which has a gene. # # If not, build genewise object. # # # This is the data structure which we will store all the genes in as we make # them # my $mother = &Wise2::GenomicRegion::new_GenomicRegion($gen); my ($make_aln,$hit,@hsps,$hsp,$pgl,$pg,$name,@genes,$pro); # # This is the main loop. Each time around it selects a single protein # to add into the # # # $make_aln = 0; foreach $hit ( $blast->hits ) { $name = $hit->name(); @hsps = sort { $b->score <=> $a->score } $hit->hsps(); $hsp = shift @hsps; if( $make_aln > 10 ) { last; } $make_aln++; if( &covered_by_genes($hsp,@genes) ) { next; } # ok - run genewise # we need the protein... # Here is the pipe you should change if you are not using getz open(PRO,"getz -sf fasta -d '[swissprot-id:$name]' |") || die "Could not fork getz pipe"; $seq = &Wise2::Sequence::read_fasta_Sequence(\*PRO); close(PRO) || die "Could not open pipe to getz with [getz -sf fasta -d '[swissprot-id:$name]' |].\n Perhaps you want a different indexing executable?"; if( $seq ) { $pro = &Wise2::Protein::Protein_from_Sequence($seq); } else { warn("Could not read $name"); next; } $pgl = new Wise2::PotentialGeneList; # empty list. $pg = new Wise2::PotentialGene; # empty potential gene $pgl->add_pg($pg); $pg->set_homolog($pro); # # These should be changed to be the start/end point # in the DNA sequence. # @hsps = sort { $a->start('query') <=> $b->start('query') } $hit->hsps(); $hsp = shift @hsps; my $dstart = $hsp->start('query'); if( ($dstart - 500) > 0 ) { $dstart -= 500; } else { $dstart = 0; } @hsps = sort { $b->end('query') <=> $a->end('query') } $hit->hsps(); $hsp = shift @hsps; my $dend = $hsp->end('query'); if( $dend + 500 < $gen->baseseq->len ) { $dend += 500; } else { $dend = $gen->baseseq->len; } if( $hsp->strand('query') eq 'Plus' ) { $pg->set_guess_start($dstart); $pg->set_guess_end($dend); } else { $pg->set_guess_end($dstart); $pg->set_guess_start($dend); } &Wise2::resolve_PotentialGenes_on_GenomicRegion($mother,$pgl,$alg,$alg,20,20,$cm,-12,-2,$gp,$rmd,$rmd," ",0,25); # transfer genes into hash. @genes = (); foreach my $gene ( $mother->each_gene() ) { push(@genes,$gene); } # get out alignment my $alb = $pgl->pg(0)->alb; # alignment coordinates are relative to the truncated genomic DNA # sequence, not the absolute. So we need to truncate the genomic # DNA before we put it into the system # print STDERR "Truncating ", $pgl->pg(0)->guess_start, ":", $pgl->pg(0)->guess_end, "\n"; # mystic -1's to map from bio coordinates to C coordinates my $gent; if( $pgl->pg(0)->guess_start < $pgl->pg(0)->guess_end ) { $gent = $gen->truncate_Genomic($pgl->pg(0)->guess_start-1,$pgl->pg(0)->guess_end); } else { $gent = $gen->truncate_Genomic($pgl->pg(0)->guess_start,$pgl->pg(0)->guess_end-1); } &Wise2::protein2genomic_ascii_display($alb,$pro,$gent,$ct,15,50,STDOUT); } # # show all the genes? # $mother->show_ace_GenomicRegion($gen->baseseq->name(),STDOUT); #### sub routines #### # # Determines is this hsp is actually already covered. # sub covered_by_genes { my $hsp = shift; my (@genes) = @_; my ($start,$end,$gene,$strand,$mid); ($start,$end) = $hsp->range('query'); ($strand) = $hsp->strand('query'); $mid = $start + ($end - $start)/2; foreach $gene ( @genes ) { if( $gene->start > $gene->end ) { if( $strand eq 'Plus' ) { next; } } else { if( $strand eq 'Minus' ) { next; } } # now look for internal overlap if( $strand eq 'Plus' ) { if( $mid > $gene->start && $mid < $gene->end ) { # is covered return 1; } } else { if( $mid > $gene->end && $mid < $gene->start ) { # is covered return 1; } } } # not covered by any gene - get out! return 0; } wise-2.4.1/src/perl/scripts/README0000644000175000001440000000014407313404551016152 0ustar philippusers These are some very simple scripts to be playing with once you have installed the Wise2 Perl port. wise-2.4.1/src/perl/scripts/estwise.pl0000644000175000001440000000733407313404551017322 0ustar philippusers#!/usr/local/bin/perl =head1 NAME estwise.pl =head1 SYNOPSIS estwise.pl =head1 DESCRIPTION compares a protein sequence to a DNA database, allowing for frame shift errors =head1 OPTIONS This perl script is just an example. For more options you should read the perl script and customise it for your own applications =cut use Wise2; use strict; # so we can use STDOUT as a bare word. no strict 'subs'; my $pro_file = shift; my $dna_file = shift; if( !defined $dna_file ) { system("perldoc $0"); exit(1); } # read in the protein file open(PRO,$pro_file) || die "Could not open $pro_file!"; my $seq = &Wise2::Sequence::read_fasta_Sequence(PRO); my $pro = &Wise2::Protein::Protein_from_Sequence($seq); # Convert the protein to a profile-HMM (called a threestatemodel in wise2 speak) my $comp = &Wise2::CompMat::read_Blast_file_CompMat("blosum62.bla"); my $rm = &Wise2::default_RandomModel(); my $tsm = &Wise2::ThreeStateModel::ThreeStateModel_from_half_bit_Sequence($pro,$comp,$rm,-12,-2); # make a profile-HMM database from the single profile-HMM my $tdb = &Wise2::ThreeStateDB::new_single_ThreeStateDB($tsm,$rm); # destroy tsm memory... $tsm = 0; # load up dna file for as a simple sequence db my $sdb = &Wise2::single_fasta_SequenceDB($dna_file); if( $sdb == 0 ) { die "Could not read in $dna_file!"; } # convert to a typed (cDNA) db my $cdb = &Wise2::new_cDNADB($sdb); # load parameters to the estwise search # this is the indel rate my $cp = &Wise2::flat_cDNAParser(0.001); # codon table my $ct = &Wise2::CodonTable::read_CodonTable_file("codon.table"); #this means we are not using any codon bias my $cm = &Wise2::flat_CodonMapper($ct); # this is the substitution error $cm->sprinkle_errors_over_CodonMapper(0.001); # random model needed if we are not using syn my $rmd = &Wise2::RandomModelDNA_std(); # means estwise3 algorithm my $alg = &Wise2::alg_estwrap_from_string("333"); my $dbsi = &Wise2::new_serial_DBSearchImpl(); #print STDERR "Launching ($tdb,$cdb,$cp,$cm,$rmd,1,$alg,0) \n"; my $hs = &Wise2::Hscore_from_TSM_estwise($tdb,$cdb,$cp,$cm,$rmd,1,$alg,0,0.9,-1,1,$dbsi); # simple basic show #$hs->show(STDOUT); $hs->sort_Hscore_by_score(); # # This is how to loop over hscore object. Notice # that we don't make a DataScore object until we really have # to - this is because the memory managment in hscore is # customised - meaning retrieval of a DataScore means an entire # allocation and copy of contents (usually it is just up'ing a reference count) # # Do not EVER loop over hs->datascore(...) putting everything into # an array (for a nice foreach call). It will kill your machine for # large databases. # my $len = $hs->length(); my($i,$ds,$alb,$cdna); for($i=0;$i<$len;$i++) { if( &Wise2::Score2Bits($hs->score($i)) < 25 ) { last; } $ds = $hs->datascore($i); print STDERR sprintf("$i %12s %12s [%s] %4.2f\n",$ds->query()->name(),$ds->target()->name,$ds->target->is_reversed == 1 ? "-" : "+",&Wise2::Score2Bits($ds->score())); } # # Get out the sequence of the first ones up to 5 # # Align them and report back # for($i=0;$i<$len && $i < 5;$i++) { if( &Wise2::Score2Bits($hs->score($i)) < 25 ) { last; } $ds = $hs->datascore($i); $cdna = $cdb->get_entry($ds->target); if( ! $cdna ) { warn("Can't get entry!"); next; } $alb= &Wise2::AlnBlock_from_Protein_estwise_wrap($pro,$cdna,$cp,$cm,$ct,$comp,-12,-2,0,$rmd,0,$rm,0.9,1); &Wise2::protcdna_ascii_display($alb,$pro->baseseq->seq,$pro->baseseq->name,$pro->baseseq->offset,$cdna,$ct,15,50,0,STDOUT); } #explicitly reap memory - helps bug tracking! $tsm = 0; $hs = 0; $ds = 0; #$tdb =0; #$seq =0; $pro = 0; $comp = 0; $rm = 0; $cp = 0; $ct = 0; print STDERR "Finished!\n"; wise-2.4.1/src/perl/scripts/postwise.pl0000644000175000001440000000767307313404551017522 0ustar philippusers#!/usr/local/bin/perl # # Skeleton script to emulate postwise # written by Ewan - expecting major hacking from other people ;) # # use Wise2; # # By intialising objects to 0, the Wise2 libraries have # an outside chance of catching unintialised variables. # also delibrately 'non-blesses' them, making them uncovertable # for some functions... # my $pgl = 0; # potential gene list my $gen = 0; # genomic object my $genr= 0; # genomic region object my $gf= 0; # gene frequencies my $comp=0; # comparison matrix my $gpara=0; # holder for all gene parameters my $rmd=0; # dna random model my $rm=0; # protein random model my $pro_file = shift; my $dna_file = shift; if( !defined $dna_file ) { die "postwise.pl \n"; } # # read in inputs # $gen = &Wise2::Genomic::read_fasta_file_Genomic($dna_file); if( $gen == 0 ) { die "Could not read $dna_file as a Genomic Sequence"; } # if you want to get at the sequence, here it is... # $seq = $gen->baseseq(); # $seq->write_fasta(STDOUT); # # Allocate an empty PotentialGeneList # $pgl = new Wise2::PotentialGeneList; open(PRO,$pro_file) || die "Could not open $pro_file!"; while (1) { $seq = &Wise2::Sequence::read_fasta_Sequence(\*PRO); if( $seq == 0 ) { last; # end of file } $pro = &Wise2::Protein::Protein_from_Sequence($seq); if( $pro == 0 ) { # can't interpolate function calls die sprintf("Could not make protein from sequence %s!",seq->name()); } $pg = new Wise2::PotentialGene; $pg->set_homolog($pro); # sets this protein as a homolog to be used # # This should be set - obviously - to where you think the gene should start/end # if end < start then it is on the opposite strand. # $pg->set_guess_start(1); # good OOP... but - descending 3 func calls to get out # a simple attribute. *don't* do this in major loops $pg->set_guess_end ($gen->baseseq()->end()); # # add this to potential gene list # $pgl->add_pg($pg); } # # these are for the gene model # # # We should have a short cut for this in Wise2.pm probably. # $gf = &Wise2::GeneFrequency21::read_GeneFrequency21_file("human.gf"); $ct = &Wise2::CodonTable::read_CodonTable_file("codon.table"); $rmd = &Wise2::RandomModelDNA::RandomModelDNA_std(); $alg = &Wise2::gwrap_alg_type_from_string("623"); $gp = &Wise2::GeneParameter21_wrap($gf,0.00001,0.000001,$rmd,0,1,1,$ct,0.999,0.99,0.8,0.99,0.4); #destroy memory held by Gene frequency object # sets memory amount for main memory &Wise2::change_max_BaseMatrix_kbytes(10000); # 10 Megabytes. $gf = 0; # # these are for the protein part of the comparison # $cm = &Wise2::CompMat::read_Blast_file_CompMat("blosum62.bla"); $rm = &Wise2::RandomModel::default_RandomModel(); # # Make a new genomic region from the Genomic object # GenomicRegion is like a 'GenomeSequence' (vaguely) in ACeDB - it is # our outer-layer context of a region of genome, hopefully containing some # sequence ;) # $gr = &Wise2::GenomicRegion::new_GenomicRegion($gen); # print STDERR "Going to resolve! $gr $g2 $gen $pgl $alg $comp $gp $rmd\n"; # # resolve those genes! # # This is the major call -> into the gwrap package... # $count = &Wise2::resolve_PotentialGenes_on_GenomicRegion($gr,$pgl,$alg,$alg,0,0,$cm,-12,-2,$gp,$rmd,$rmd," ",0,20); # # shows as ascii text # $gr->show_pretty_GenomicRegion(STDOUT); # # shows as ACeDB objects # $gr->show_ace_GenomicRegion($gen->baseseq->name,STDOUT); # # Gets out the alignments. Shows them. # foreach $pg ( $pgl->each_pg() ) { $alb = $pg->alb(); $pro = $pg->homolog(); if( $alb == 0 ) { warn sprintf("At potential gene %s - no alignment",$pg->homolog()->baseseq()->name()); next; } $gtemp = $gr->genomic(); $gtemp = $gtemp->truncate_Genomic($pg->guess_start,$pg->guess_end); &Wise2::protein2genomic_ascii_display($alb,$pro,$gtemp,$ct,15,50,STDOUT); print "\n\n//\n"; } # # Finished! # wise-2.4.1/src/perl/scripts/genewise.pl0000644000175000001440000000361607313404551017444 0ustar philippusers#!/usr/local/bin/perl use Wise2; my $pro_file = shift; # first argument from @ARGV my $dna_file = shift; # second argument @ARGV if( !defined $dna_file ) { die "genewise.pl \n"; } # # read in inputs. Read in first as generic 'Sequence' objects # and then converted to specific 'Protein' or 'Genomic' type # objects # open(PRO,$pro_file) || die "Could not open $pro_file!"; $seq = &Wise2::Sequence::read_fasta_Sequence(\*PRO); $pro = &Wise2::Protein::Protein_from_Sequence($seq); if( $pro == 0 ) { # can't interpolate function calls die sprintf("Could not make protein from sequence %s!",$seq->name()); } open(DNA,$dna_file) || die "Could not open $pro_file!"; $seq = &Wise2::Sequence::read_fasta_Sequence(\*DNA); $gen = &Wise2::Genomic_from_Sequence($seq); if( $gen == 0 ) { # can't interpolate function calls die sprintf("Could not genomic from sequence %s!",$seq->name()); } # # Read in data structures needed for # genewise type algorthim # # These will be automatically read from WISECONFIGDIR if necessary. # # $gf = &Wise2::read_GeneFrequency21_file("human.gf"); $ct = &Wise2::CodonTable::read_CodonTable_file("codon.table"); $rmd = &Wise2::RandomModelDNA_std(); $alg = &Wise2::gwrap_alg_type_from_string("623"); $gp = &Wise2::GeneParameter21_wrap($gf,0.00001,0.000001,$rmd,0,1,1,$ct,0.999,0.99,0.8,0.99,0.4); # sets memory amount for main memory &Wise2::change_max_BaseMatrix_kbytes(10000); # 10 Megabytes. # # these are for the protein part of the comparison # $cm = &Wise2::CompMat::read_Blast_file_CompMat("blosum62.bla"); $rm = &Wise2::default_RandomModel(); # do it! $pg = new Wise2::PotentialGene; # empty potential gene $alb = &Wise2::AlnBlock_from_protein_genewise_wrap($pro,$gen,$cm,-12,-2,$gp,$rmd,$rmd,$alg,0,1,$rm,0.9,$pg); &Wise2::protein2genomic_ascii_display($alb,$pro,$gen,$ct,15,50,STDOUT); wise-2.4.1/src/perl/scripts/protestwise.pl0000755000175000001440000000717507313404551020235 0ustar philippusers#!/usr/local/bin/perl # # protestwise.pl \n # produces on STDOUT a new protein sequence which is the # DNA sequence 'fixed' by the comparison to the protein sequence. # in particular frameshift errors get mapped to X # written by James cuff (james@ebi.ac.uk) # Hacked by Ewan (birney@sanger.ac.uk). Talk to ewan # first about the script. use Wise2; my $pro_file = shift; # first argument from @ARGV my $dna_file = shift; # second argument @ARGV if( !defined $dna_file ) { die "ProtESTwise.pl \nProduces output of the DNA sequence\n'fixed' by the comparison on stdout"; } # read in inputs. Read in first as generic 'Sequence' objects # and then converted to specific 'Protein' or 'cdna' type # objects open(PRO,$pro_file) || die "Could not open $pro_file!"; $seq = &Wise2::Sequence::read_fasta_Sequence(\*PRO); $pro = &Wise2::Protein::Protein_from_Sequence($seq); if( $pro == 0 ) { # can't interpolate function calls die sprintf("Could not make protein from sequence %s!",$seq->name()); } open(DNA,$dna_file) || die "Could not open $pro_file!"; $seq = &Wise2::Sequence::read_fasta_Sequence(\*DNA); $cdna = &Wise2::cDNA::cDNA_from_Sequence($seq); if( $cdna == 0 ) { # can't interpolate function calls die sprintf("Could not genomic from sequence %s!",$seq->name()); } # Read in data structures needed for # estwise type algorthim # # These will be automatically read from WISECONFIGDIR if necessary. # this is the indel rate $cp = &Wise2::flat_cDNAParser(0.001); # codon table $ct = &Wise2::CodonTable::read_CodonTable_file("codon.table"); #this means we are not using any codon bias $cm = &Wise2::flat_CodonMapper($ct); # this is the substitution error $cm->sprinkle_errors_over_CodonMapper(0.001); # random model needed if we are not using syn $rmd = &Wise2::RandomModelDNA_std(); # means estwise3 algorithm. Not obvious! $alg = 0; # sets memory amount for main memory &Wise2::change_max_BaseMatrix_kbytes(100000); # 10 Megabytes. # these are for the protein part of the comparison $comp = &Wise2::CompMat::read_Blast_file_CompMat("blosum62.bla"); $rm = &Wise2::default_RandomModel(); # do it! $alb = &Wise2::AlnBlock_from_Protein_estwise_wrap($pro,$cdna,$cp,$cm,$ct,$comp,-12,-2,0,$rmd,$alg,$rm,1,0.9); $proseq = ""; # # This is where we get clever! # # The for loops across the alignments. The protein sequence is in $alc->alu(0). The # DNA sequence is in $alc->alu(1). We are interested in codons in the DNA sequence # and turns those into amino acids. Sequence insertions or deletions become X's # for($alc=$alb->start();$alc->at_end() != 1;$alc = $alc->next()) { if( $alc->alu(1)->text_label() =~ /^INSERT$/ ) { next; # skip protein inserts relative to the DNA sequence # NB different from SEQUENCE_INSERTION. } if( $alc->alu(1)->text_label() =~ /CODON/ ) { # get out sequence from $start to $end # $start and $end are in bio coordinates $start = $alc->alu(1)->start+1; $end = $alc->alu(1)->end+1; $dnatemp = ""; for($x=$start;$x < $end;$x++){ $tmp = &Wise2::cDNA::cDNA_seqchar($cdna,$x); $dnatemp=$dnatemp.$tmp; } $temp = $ct->aminoacid_from_seq($dnatemp); # if codon has an N, then set the residue to unk X, # we could be clever about this and work out what # it is likely to be, but hell... $temp =~ s/x/X/; $proseq .= $temp; } else { # deletion or insertion of a base $proseq .= 'X'; } } # make the new protein sequence and # dump it to stdout $namecdna = $cdna->baseseq()->name(); $new = &Wise2::new_Sequence_from_strings($namecdna,$proseq); $new->write_fasta(STDOUT); wise-2.4.1/src/perl/scripts/halfwise.pl0000755000175000001440000001774307313404551017451 0ustar philippusers#!/usr/local/bin/perl # # These are the things you might want to change. Scroll down for docs on the program # or preferable go pod2text halfwise.pl # # so that the testing works at sanger centre. You could change this obviously # on your site, though it may be easier to install bioperl correctly use lib '/nfs/disk92/PerlSource/Bioperl/Releases/bioperl-0.04.2/'; BEGIN { eval { use Bio::Tools::Blast; }; if ( $@ ) { print STDERR ("\nThe bioperl distribution has not be installed.\n Read the installation instructions at the top of this script going pod2text halfwise.pl\nThe bioperl distribution can be found from http://bio.perl.org/\nThe halfwise script has been tested with 0.04.x releases\n"); exit(1); } } $defopts = "-init wing -cace -cut 25 -aln 200 -quiet"; $half_db = "/somewhere/halfwise.db"; # this is for testing @sanger #$half_db = "/nfs/disk21/birney/prog/wise2/perl/scripts/halfwise.db"; $hmmfetch = "hmmfetch"; $genewise = "genewisedb"; $hmmdb = "Pfam"; # # The documentation is written as pod. # to view it nicely use pod2text halfwise.pl # or to make html use pod2html # =head1 NAME - halfwise halfwise is a script designed to compare a large DNA sequence to Pfam sensibly. It does the following steps: =over =item blast search Compares the DNA sequence to a representive database of protein sequences from Pfam =item HMM retrieval Retrieves the Pfam HMMs to compare to the DNA sequence using a liberal threshold =item GeneWise comparison Retrieves those HMMs and uses genewisedb to compare the DNA sequence to the Pfam HMMs. =back The blast search drastically reduces the number of HMMs needed to be considered while not losing much sensitive due to a relatively comprehensive protein database and a liberal cutoff =head1 USAGE Once everything is installed properely, using halfwise should be quite simple. Go halfwise.pl to get basic help and halfwise.pl -help for more detailed options. The basic mode of running is just to take a DNA sequence file and write to stdout, like halfwise.pl cosmid.fasta > cosmid.hlf For more description of the options you can use with the genewisedb program (and this includes a large number of output options) go halfwise.pl -help and also read the postscript documentation (wise2.ps) that came in this distribution =head1 INSTALLATION For halfwise to work you need a number of different software packages installed. This means that halfwise is a very robust and working script (and didnt take long to write!) but, you are going to have to hop around installing things first. Sorry! Everything installs very easily! All the components required for halfwise can be found at ftp://ftp.sanger.ac.uk/pub/birney/wise2/halfwise, so you can make a one stop shop! You need =over =item Wise2.1.16 or higher level in the 2.1 release series You should have it now, as you are reading this! =item HMMer2.1.1 or higher This is for the HMM retrieval system. Available from http://hmmer.wustl.edu or the above ftp site (the HMMer2 directory in the Wise2 package does not have the correct facilities). =item bioperl central distribution, 0.04.2 or higher in the 0.04 release series This is available from http://bio.perl.org or the above ftp site =item The blast executables available from http://ncbi.nlm.nih.gov or http://blast.wustl.edu/ (I did not make these available from the ftp site as you probably have them already installed!) =item Pfam and halfwise databases available from the above ftp site =back For the software packages, follow the instructions for how to install them. Briefly =over =item Wise2.1.16 type 'make all' in the wise2.1.16 directory and then copy the contents of the bin directory to /usr/local/bin or somewhere on your path =item HMMer2.1.1 type './configure' followed by 'make' in the hmmer-2.1.1 directory and then 'make install' (assumming you want to install in /usr/local/bin) =item bioperl-0.04.2 It is a standard CPAN type module. Go 'perl Makefile.PL', 'make', 'make install' in the bioperl-0.04.2 directory. you do not need to install the Compiled extension, but if you want to use other parts of bioperl, you may need them, so there is no reason not to ;) =back For the databases, pick up the Pfam database and the halfwise.db. Put them somewhere where you usually put databases. setdb or pressdb the halfwise.db ready for blast (depending on what flavour of blast you are using - your database manager should know this). Also the easiest thing to do is to setenv HMMERDB to the directory where the Pfam database is. You then need to index the Pfam database going 'hmmindex Pfam'. finally you need to adjust the variables at the top the halfwise script so that everything works. This all seems complicated but its not so bad. Here is a check list. o pick up and install wise2.1.16 - make all in wise2.1.16 - cp bin/* /usr/local/bin - setenv WISECONFIGDIR to xxx/wise2.1.16/wisecfg o pick up and install hmmer2.1.1 - ./configure - make - make install o pick up and install bioperl - perl Makefile.PL - make - make install o check you have blast installed o pick up halfwise.db and Pfam - setdb halfwise.db - hmmindex Pfam - setenv HMMERDB /somewhere/data/ o change the location of the databases etc at the top of this script If you have any problems, just email me =cut # # Make sure halfwise is there... # $blast_db_dir = $ENV{'BLASTDB'}; if( ! -e $half_db && ! (defined $blast_db_dir && -e "$blast_db_dir/$half_db" )) { die("The halfwise database [$half_db] has not been correctly indicated.\nPlease read the installation instructions at the top of this script\n"); } $filename = shift; # dna sequence we hope! if( !defined $filename ) { print "halfwise genewisedb-options\n"; print "searches Pfam using initial blast followed by genewise\n"; print " The default genewise options are $defopts\n\n"; print "Genewisedb options are listed by going halfwise -help\n"; exit(1); } # if help - print the help out from genewisedb... if( $filename =~ "-help" ) { print "halfwise genewisedb-options\n"; print " The default genewise options are $defopts\nGenewisedb options\n\n"; open(GDB,"$genewise -help |"); while() { print; } close(GDB) || die "Could not close pipe to genewisedb executable [$genewise]. Installation problem?"; exit(1); } $verbose = 0; if( @ARGV > 0 ) { $opts = join(' ',@ARGV); } else { $opts = $defopts; } $verbose && print STDOUT "Doing Blast...\n"; # make the blast output # BLASTMAT=/nfs/disk100/pubseq/blastdb/ #$ENV{'BLASTMAT'} = "/nfs/disk100/pubseq/blastdb/"; if( system("blastx $half_db $filename -V=10000 -B=10000 > $filename.blx.$$") != 0 ) { die "There blastx search did not complete correctly\n"; } $verbose && print STDOUT "Done\n"; eval { $blast = Bio::Tools::Blast->new( -file => "$filename.blx.$$", -parse => 1, -signif => '1e-3', -strict => 1, ); }; if( $@ ) { print "#No hits found in the blast search\n"; exit; } # ok ... now loop over the HSPs and print them out! foreach $hit ( $blast->hits ) { $name = $hit->name; $verbose && print STDOUT "Reading $name\n"; if( !($name =~ /^([^\/]+)\//) ) { warn("Bad hit name $name"); } $acc = $1; $hash{$acc} = 1; } # build minidb of the HMMs open(TEMPDB,">$filename.dbhmm.$$"); $count = 0; foreach $acc ( keys %hash ) { $count++; $verbose && print STDOUT "Loading $acc\n"; open(GETZ,"$hmmfetch $hmmdb $acc |"); while() { print TEMPDB $_; } close(GETZ); } close(TEMPDB); $verbose && print STDOUT "Collected $count hmms\n"; # run genewisedb open(GDB,"$genewise -pfam $filename.dbhmm.$$ -dnas $filename $opts |") || die "Could not open genewise - ERROR! $!"; while() { print; } close(GDB) || die "Could not open genewise pipe (well close it anyway) $! $?"; unlink("$filename.dbhmm.$$"); unlink("$filename.blx.$$"); exit(0); # for james... wise-2.4.1/src/perl/top.xs0000644000175000001440000000123507313404550014762 0ustar philippusers #ifdef __cplusplus extern "C" { #endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #ifdef __cplusplus } #endif #include "wise2.h" static int not_here(s) char *s; { croak("%s not implemented on this architecture", s); return -1; } static double constant(name, arg) char *name; int arg; { errno = 0; switch (*name) { } errno = EINVAL; return 0; not_there: errno = ENOENT; return 0; } MODULE = Wise2 PACKAGE = Wise2 double constant(name,arg) char * name int arg PROTOTYPES: ENABLE void error_on(type) int type; CODE: Wise2_error_on(type); void error_off(type) int type; CODE: Wise2_error_off(type); wise-2.4.1/src/perl/basic.h0000644000175000001440000000056107313404550015037 0ustar philippusers #include typedef char aa; typedef int base; typedef double Probability; typedef double Bits; typedef int Score; typedef int codon; typedef int boolean; #define WISE2_FATAL 1 #define WISE2_WARNING 2 #define WISE2_INFO 8 #define WISE2_REPORT 16 char * Wise2_stringalloc(char *); void Wise2_error_off(int type); void Wise2_error_on(int type); wise-2.4.1/src/test/0000755000175000001440000000000010670453636013631 5ustar philippuserswise-2.4.1/src/test/human.genomic0000644000175000001440000001253407360366657016321 0ustar philippusers>HSHNRNPA GGGATTGAGAGTGATCACTCACGCTAACGTCTGCCCTGTTCCTGTATGGTGAGGCCGCAC CACAAGCCACCACCGCCGCCGCCTTCTGCGCAACGCCAACCGCCCGCCAAAACGGATCCT TCCCTGCGCCTGCGCAACCAATCTTGGGACCGGACCTTTTTTCTCCGCCCACTACGCATG CGCAAAGCTAGGACAAACTCCCGCCAACACGCAGGCGCCGTAGGTTCACTGCCTACTCCT GCCCGCCATTTCACGTGTTCTCAGAGGCAGGTGGAACTTCTTAATGCGCCTGCGCAAAAC TCGCCATTTTACTACACGTGCGGTCAACAAGAGTTCATTGCAAAAAAATTGTTACCTCCT AGCTGCTTGTCTAATACATAGTGTTAATCATGCTTTGCCAAGCGACTTGACTGTAATATT TGCGCGTGGAAGATTAAAAAGATGTTAAACACCCAAGGTAGATTCAAATGTGAATGATTG GTCGGTTGGCCAATCAGACTGGTTAACAATAACATTACTCGGGAACCAATGGACTCCAAG GGGTGGAGACGGCGTAGAACGACCGAAGGAATGACGTTACACAGCAATGTGGCACCACAG GCCAATAGCAGGGGGAAGCGATTTCAAGTATCCAATCAGAGCTGTTCTAGGGCGGAGTCT ACCAATGCCGAAAGCGAGGAGGCGGGGTAAAAAAGAGAGGGCGAAGGTAGGCTGGCAGAT ACGTTCGTCAGCTTGCTCCTTTCTGCCCGTGGACGCCGCCGAAGAAGCATCGTTAAAGTC TCTCTTCACCCTGCCGTCATGTCTAAGTCAGAGGTGAGTTAGGCGCGCTTTCCCACTTGA ATTTTTTCCTCTCCCTTTCCTGAATCGGTAAGATGCTGCTGGGTTTCGTTCCTTGCACCA GCCCATTCTACAGTTCCTTCGGTCGCTGCCACGGCCTACCCCTCCCAAAGTTCAAGTCGC CATTTTGTCCTCTTGATCGCCATGAGGCCGCTCTCCGCCAACCATGTGTTATCATGCGGG ACTCGTTACTCGTAGCAAAATTCTTAGGCACACAGGATCTTTGTCTTTTTTTAAACCTTG CCTTGGTGAGCGAGTTTTCTAAAGAGCGATTAGTCCCATTGTGGAGATGCACCCCTACCG CCCAAGCCTTTGTTGCGCGTGCGTCGGAAGGCGACTAGGGACGCATGCGCTTGCGATTTC CTAGCACTCCCAACTCCAGCATACGGCCTCCCTTGATAGGCAGAAGCACGTGTCTTGTTG CGACCTGAACGAACAATAAGTGCTAGGTACACAGTTGGTGTCTAGTTTTTCTTTTCCTCG ATGGAAATTGTTTCGTGTTGTAGCCCATTTAACACTTCCCCCTCCCCCCACTCTAGTCTC CTAAAGAGCCCGAACAGCTGAGGAAGCTCTTCATTGGAGGGTTGAGCTTTGAAACAACTG ATGAGAGCCTGAGGAGCCATTTTGAGCAATGGGGAACGCTCACGGACTGTGTGGTAAGAT TTGGAAGGGACAAAGCAGTAAAACAGCCGATTTCCTTGGCTTATCTTGGTGCAGTCTTCT CCGAATGCTTATGAAAGTAGTTAATAGCATTATAGTTAGAGCTTTGTTGGCAAAGGAACG TCCTGCTTTGATTTTAAAAGCTAACCTCTTAAATCTAAGGGTAGTGGGAAACTGGACGAA CTTTTTATAAAAGGCTGGTGTAAAGTTTCCTATTGCCCTATTCAAAGTTAAAATAACAAA AGCTTTTGCGGTCAGACTTTGTGTTACATAAATTAACACTGTTCTCAGGTAATGAGAGAT CCAAACACCAAGCGCTCTAGGGGCTTTGGGTTTGTCACATATGCCACTGTGGAGGAGGTG GATGCAGCTATGAATGCAAGGCCACACAAGGTGGATGGAAGAGTTGTGGAACCAAAGAGA GCTGTCTCCAGAGAAGTGAGTGGGTTTTTTTTCTTCTTCTTCTTAAACTTACTTGGATAT GTGCTGCTATGAACTTAAGATTCGGGAGTTTTCTAAACTTACCAAAATTTTTTATTCGAG TATAGGCTTTGCTAATCTAAACCTATGGTTTTTCTCCTATTAGGATTCTCAAAGACCAGG TGCCCACTTAACTGTGAAAAAGATATTTGTTGGTGGCATTAAAGAAGACACTGAAGAACA TCACCTAAGAGATTATTTTGAACAGTATGGAAAAATTGAAGTGATTGAAATCATGACTGA CCGAGGCAGTGGCAAGAAAAGGGGCTTTGCCTTTGTAACCTTTGACGACCATGACTCCGT GGATAAGATTGTCAGTAAGTATCAGATAGTGGCATTTAGTAAGGGTTCCACAATCTGTAT GGCATTCTAAACCCTGATACCATGTTGTATCTATGTTTTTTTTTTAGTTCAGAAATACCA TACTGTGAATGGCCACAACTGTGAAGTTAGAAAAGCCCTGTCAAAGCAAGAGATGGCTAG TGCTTCATCCAGCCAAAGAGGTATGCTTGTTGCTTAATTAAACCTTAAAGGTAACTTTGA GTTACTCCAGTATGAATGATTTAATGCTTAAACTTCATGTCTTAAGGTCGAAGTGGTTCT GGAAACTTTGGTGGTGGTCGTGGAGGTGGTTTCGGTGGGAATGACAACTTCGGTCGTGGA GGAAACTTCAGTGGTCGTGGTATGTATGGTTTATCTACATGTAGTTCTGACTTCTCACCA TCTTTGCTATGAAGATTTTACAGTACGGGAACTGCATTCAGAATGTCACTTTAAGTCCAA GTCATACTTAAAACTTGAAACTTTTTCTTACAGGTGGCTTTGGTGGCAGCCGTGGTGGTG GTGGATATGGTGGCAGTGGGGATGGCTATAATGGATTTGGCAATGATGGTAAGTTTTTTA GGAATAAGTAGAGAAAAATTCCTGGCAACCTGGATCTTTAGAATAGGTTAGTAGAGACTA AAATTCTGGTGCATGTCAAACTCAACTTTGCCCATAACACGCATGCTGTGAGCAGGCCTT CAGCCGTTACACTTGCACAAGTTTTCATTGTCAAATACTTTTGTCTTATTGAGAAGAATT GTATTCTTGTAGGTGGTTATGGAGGAGGCGGCCCTGGTTACTCTGGAGGAAGCAGAGGCT ATGGAAGTGGTGGACAGGGTTATGGAAACCAGGGCAGTGGCTATGGCGGGAGTGGCAGCT ATGACAGCTATAACAACGGAGGCGGAGGCGGCTTTGGCGGTGGTAGTGGTAGGTATCCAG TGATCCAAGTACTTGGTGTGACAGCTAGATTAGCCTTTTAGAGCTTGGGTTCTGGTGCTG TTGAAGCATTGTGTGGTACACTGCATGGTATATTAAAAACAAATGGGCTTGCTATGCTAC CTCCTCCTAGCTTTAAGCTGGGGCCGCCTCACTCCCAAATAGTAGAGATAAGTGGATAGT GTTGTCTTTGAGTTAGATTAGTATCATAGAAGGATTTAGTATTTTAACTCCTTTGGGACC TTAGGCGCTTAGTTGATGTATCCAAGATACTTCTGCTTGCTGTGGCCCTGGATCCGTGAA GGCCTTCAAGGCTGAAGGGTATGCTTGTGCCACTCTGAAAATCTCTTTATTTTATGTCAT GGTGAGTTAGGCCAGTTTTCTTTGTATTACTGGATTATTCAACTGAATGCCTTTCCCAGA GAATGAAATGCAAAGATTGGAGTCACCATAGTTTGGGAGAAAGGAAGGCTGATAACTCAA CCTTATTTTATTCTGACTGCTAAACAGAATTGGAAACTAACATCATCCTCAGGTAACAGA TAAAGGCCCTCTTTCCCATTCATAGGAAGCAATTTTGGAGGTGGTGGAAGCTACAATGAT TTTGGGAATTACAACAATCAGTCTTCAAATTTTGGACCCATGAAGGGAGGAAATTTTGGA GGCAGAAGCTCTGGCCCCTATGGCGGTGGAGGCCAATACTTTGCAAAACCACGAAACCAA GGTATGGTATCTATGTAATTTTGGATAATGTCAAAAGAGTGTCTGTAGCTACTGCTGGGA AGAAAGCCCTTTAACTGCTATGTCTGGGCAGCAAAACGTTTATAGTTTAGAACCTTCAGA AAGTGATAATTTGATCACAAATTAGAAAAATCATGGGACCTCTTTACCACCTCCCTTGTA GTAGGGCCATTTTTAAATGGCCAGACACTTGAATTTAACTTTTATTATCCCAAATATGAA AACATTACTGTTGGCACTTTGAAACTTTAAAAGAAAAATTGTACTTTTCAGGTGGCTATG GCGGTTCCAGCAGCAGCAGTAGCTATGGCAGTGGCAGAAGATTTTAATTAGGTAAGTAAG CACCTTTTTGTGTGTTGACATAATTTTTTAAATTGCTGATGAACCCAATAACCCTAATGT AGCTGAGCAGTGCAACATAGTTAACATTATAATTGCAGTAATTGTGGATATAAAGTTAAT ATTCAGATCAGCAAAATTTGTGGGAAACAAACTTGATATTGGATTGTAGCCTTGAGTCTT AATATGTTTAGATTAACAACTCTATTCCATATTGTTCAACAGGAAACAAAGCTTAGCAGG AGAGGAGAGCCAGAGAAGTGACAGGGAAGCTACAGGTTACAACAGATTTGTGAACTCAGC CAAGCACAGTGGTGGCAGGGCCTAGCTGCTACAAAGAAGACATGTTTTAGACAAATACTC ATGTGTATGGGCAAAAAACTCGAGGACTGTATTTGTGACTAATTGTATAACAGGTTATTT TAGTTTCTGTTCTGTGGAAAGTGTAAAGCATTCCAACAAAGGGTTTTAATGTAGATTTTT TTTTTTGCACCCCATGCTGTTGATTGCTAAATGTAACAGTCTGATCGTGACGCTGAATAA ATGTCTTTTTTTTAATGTGCTGTGTAAAGTTAGTCTACTCTTAAGCCATCTTGGTAAATT TCCCCAACAGTGTGAAGTTAGAATTCCTTCAGGGTGATGCCAGGTTCTATTTGGAATTTA TATACAACCTGCTTGGGTGGAGAAGCCATTGTCTTCGGAAACCTTGGTGTAGTTGAACTG ATAGTTACTGTTGTGACCTGAAGTTCACCATTAAAAGGGATTACCCAAGCAAAATCATGG AATGGTTATAAAAGTGATTGTTGGCACATCCTATGCAATATATCTAAATTGAATAATGGT ACCAGATAAAATTATAGATGGGAATGAAGCTTGTGTATCCATTATCATGTGTAATCAATA AACGATTTAATTCTCTTGAATGAAATGACAACTGTATGGATTTGGGACTGGCAGAGATTT GGACTTTCCCTACCCACTCCCCCTGATAATAATGTTGAATGCTTCTATCACAATTCAAGT TCAAAGCTCTGCTAGGGAATAGAAACTA wise-2.4.1/src/test/basic_dna.out0000644000175000001440000004140607313404552016263 0ustar philippuserspcwise 0.9 (unreleased release) This program is freely distributed under a GPL. See source directory Copyright (c) GRL limited: portions of the code are from separate copyrights Query protein: roa1_drome Comp Matrix: blosum62.bla Gap open: 12 Gap extension: 2 Start/End local Target Sequence HSHNCPA1 Strand: both Codon Table: codon.table Subs error: 1e-05 Indel error: 1e-05 Algorithm 333 pcwise output Score 128.54 bits over entire alignment Score reported as bits over a synchronised coding sequence model roa1_drome 23 KLFVGALKDDHDEQSIRDYFQHFGNIVDINIVIDKETGKKRGFAFVEFD K+FVG +K+D +E +RDYF+ +G I I I+ D+ +GKKRGFA+V FD KIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAxVTFD HSHNCPA1 14 aatgggaaggaggcccagttgctgaaggagaaagcgagaaagtgtgatg atttggtaaacaaaatgaataaagatattattcaggggaaggtcttcta gatttctaactaatcaatttagtaatagtacgtcactcgagctcNactc roa1_drome 72 DYDPVDKVVLQKQHQLNGKMVDVKKALPKQNDQQGGGGGRGGPGG-RAG D+D VDK+V+QK H +NG +V+KAL KQ RG G + G DHDSVDKIVIQKYHTVNGHNCEVRKALSKQEMASASSSQRGRSGSGNFG HSHNCPA1 161 gcgtggaagacatcagagcatggaagctacgagagttacagcagtgatg aaactaatttaaaactagaagatgactcaaatcgcccgagggggcgatg ctccgtgtctgacttgtccctataacgagaggtttaccaatatttactt roa1_drome 120 GNRGNMGGGNYGNQNGGGNWNNGGNNWGN G RG GGN N GGN++ G G+ GGRGGGFGGN-DNFGRGGNFSGRGxFGGS HSHNCPA1 308 ggcgggtgga gatgcggatagcgNtgga ggggggtgga aatggggatgggggtggg tttattctgt cccttaaccttttcttcc // Bits Query start end Target start end idels 128.54 roa1_drome 23 148 HSHNCPA1 14 391 0 // 2.29 [21:22 "MATCH_STATE" 794],[12:15 "CODON" 794] 1.04 [22:23 "MATCH_STATE" 361],[15:18 "CODON" 361] 3.11 [23:24 "MATCH_STATE" 1077],[18:21 "CODON" 1077] 2.01 [24:25 "MATCH_STATE" 697],[21:24 "CODON" 697] 2.67 [25:26 "MATCH_STATE" 926],[24:27 "CODON" 926] -0.14 [26:27 "MATCH_STATE" -50],[27:30 "CODON" -50] 1.04 [27:28 "MATCH_STATE" 361],[30:33 "CODON" 361] 2.24 [28:29 "MATCH_STATE" 778],[33:36 "CODON" 778] 0.92 [29:30 "MATCH_STATE" 318],[36:39 "CODON" 318] 2.92 [30:31 "MATCH_STATE" 1011],[39:42 "CODON" 1011] -1.29 [31:32 "MATCH_STATE" -447],[42:45 "CODON" -447] 0.92 [32:33 "MATCH_STATE" 318],[45:48 "CODON" 318] 2.37 [33:34 "MATCH_STATE" 823],[48:51 "CODON" 823] -0.07 [34:35 "MATCH_STATE" -23],[51:54 "CODON" -23] -0.68 [35:36 "MATCH_STATE" -236],[54:57 "CODON" -236] 1.10 [36:37 "MATCH_STATE" 380],[57:60 "CODON" 380] 2.53 [37:38 "MATCH_STATE" 876],[60:63 "CODON" 876] 2.92 [38:39 "MATCH_STATE" 1011],[63:66 "CODON" 1011] 3.45 [39:40 "MATCH_STATE" 1194],[66:69 "CODON" 1194] 3.11 [40:41 "MATCH_STATE" 1077],[69:72 "CODON" 1077] 0.93 [41:42 "MATCH_STATE" 322],[72:75 "CODON" 322] -0.29 [42:43 "MATCH_STATE" -100],[75:78 "CODON" -100] 1.61 [43:44 "MATCH_STATE" 558],[78:81 "CODON" 558] 2.67 [44:45 "MATCH_STATE" 926],[81:84 "CODON" 926] -0.15 [45:46 "MATCH_STATE" -53],[84:87 "CODON" -53] 2.10 [46:47 "MATCH_STATE" 727],[87:90 "CODON" 727] -0.99 [47:48 "MATCH_STATE" -342],[90:93 "CODON" -342] -1.58 [48:49 "MATCH_STATE" -548],[93:96 "CODON" -548] 2.10 [49:50 "MATCH_STATE" 727],[96:99 "CODON" 727] -0.15 [50:51 "MATCH_STATE" -53],[99:102 "CODON" -53] 2.10 [51:52 "MATCH_STATE" 727],[102:105 "CODON" 727] 0.51 [52:53 "MATCH_STATE" 177],[105:108 "CODON" 177] -0.40 [53:54 "MATCH_STATE" -139],[108:111 "CODON" -139] 2.92 [54:55 "MATCH_STATE" 1011],[111:114 "CODON" 1011] 0.74 [55:56 "MATCH_STATE" 258],[114:117 "CODON" 258] -1.12 [56:57 "MATCH_STATE" -389],[117:120 "CODON" -389] 0.37 [57:58 "MATCH_STATE" 127],[120:123 "CODON" 127] 2.67 [58:59 "MATCH_STATE" 926],[123:126 "CODON" 926] 2.24 [59:60 "MATCH_STATE" 778],[126:129 "CODON" 778] 2.24 [60:61 "MATCH_STATE" 778],[129:132 "CODON" 778] 2.53 [61:62 "MATCH_STATE" 876],[132:135 "CODON" 876] 2.67 [62:63 "MATCH_STATE" 926],[135:138 "CODON" 926] 3.11 [63:64 "MATCH_STATE" 1077],[138:141 "CODON" 1077] 1.85 [64:65 "MATCH_STATE" 642],[141:144 "CODON" 642] 2.45 [65:66 "MATCH_STATE" 850],[144:147 "CODON" 850] 2.01 [66:67 "MATCH_STATE" 697],[147:150 "CODON" 697] -0.62 [67:68 "MATCH_STATE" -216],[150:153 "CODON" -216] 3.11 [68:69 "MATCH_STATE" 1077],[153:156 "CODON" 1077] 2.92 [69:70 "MATCH_STATE" 1011],[156:159 "CODON" 1011] 2.92 [70:71 "MATCH_STATE" 1011],[159:162 "CODON" 1011] 0.95 [71:72 "MATCH_STATE" 328],[162:165 "CODON" 328] 2.92 [72:73 "MATCH_STATE" 1011],[165:168 "CODON" 1011] -0.68 [73:74 "MATCH_STATE" -235],[168:171 "CODON" -235] 2.01 [74:75 "MATCH_STATE" 697],[171:174 "CODON" 697] 2.92 [75:76 "MATCH_STATE" 1011],[174:177 "CODON" 1011] 2.24 [76:77 "MATCH_STATE" 778],[177:180 "CODON" 778] 1.51 [77:78 "MATCH_STATE" 524],[180:183 "CODON" 524] 2.01 [78:79 "MATCH_STATE" 697],[183:186 "CODON" 697] 1.04 [79:80 "MATCH_STATE" 361],[186:189 "CODON" 361] 2.43 [80:81 "MATCH_STATE" 842],[189:192 "CODON" 842] 2.24 [81:82 "MATCH_STATE" 778],[192:195 "CODON" 778] -0.57 [82:83 "MATCH_STATE" -197],[195:198 "CODON" -197] 3.71 [83:84 "MATCH_STATE" 1285],[198:201 "CODON" 1285] -0.57 [84:85 "MATCH_STATE" -197],[201:204 "CODON" -197] 0.54 [85:86 "MATCH_STATE" 188],[204:207 "CODON" 188] 2.84 [86:87 "MATCH_STATE" 986],[207:210 "CODON" 986] 2.67 [87:88 "MATCH_STATE" 926],[210:213 "CODON" 926] -0.75 [88:89 "MATCH_STATE" -261],[213:216 "CODON" -261] -0.89 [89:90 "MATCH_STATE" -310],[216:219 "CODON" -310] -0.48 [90:91 "MATCH_STATE" -168],[219:222 "CODON" -168] 0.92 [91:92 "MATCH_STATE" 318],[222:225 "CODON" 318] 2.01 [92:93 "MATCH_STATE" 697],[225:228 "CODON" 697] 0.74 [93:94 "MATCH_STATE" 258],[228:231 "CODON" 258] 2.24 [94:95 "MATCH_STATE" 778],[231:234 "CODON" 778] 1.85 [95:96 "MATCH_STATE" 642],[234:237 "CODON" 642] 2.04 [96:97 "MATCH_STATE" 708],[237:240 "CODON" 708] -0.68 [97:98 "MATCH_STATE" -235],[240:243 "CODON" -235] 2.24 [98:99 "MATCH_STATE" 778],[243:246 "CODON" 778] 2.43 [99:100 "MATCH_STATE" 842],[246:249 "CODON" 842] -0.15 [100:101 "MATCH_STATE" -53],[249:252 "CODON" -53] -1.58 [101:102 "MATCH_STATE" -548],[252:255 "CODON" -548] -0.57 [102:103 "MATCH_STATE" -197],[255:258 "CODON" -197] -0.07 [103:104 "MATCH_STATE" -23],[258:261 "CODON" -23] -0.33 [104:105 "MATCH_STATE" -113],[261:264 "CODON" -113] -0.33 [105:106 "MATCH_STATE" -113],[264:267 "CODON" -113] -0.33 [106:107 "MATCH_STATE" -113],[267:270 "CODON" -113] -0.33 [107:108 "MATCH_STATE" -113],[270:273 "CODON" -113] -1.33 [108:109 "MATCH_STATE" -460],[273:276 "CODON" -460] 2.53 [109:110 "MATCH_STATE" 876],[276:279 "CODON" 876] 2.67 [110:111 "MATCH_STATE" 926],[279:282 "CODON" 926] -1.33 [111:112 "MATCH_STATE" -460],[282:285 "CODON" -460] -0.68 [112:113 "MATCH_STATE" -235],[285:288 "CODON" -235] 2.67 [113:114 "MATCH_STATE" 926],[288:291 "CODON" 926] -0.33 [114:115 "MATCH_STATE" -113],[291:294 "CODON" -113] -3.26 [115:115 "INSERT_STATE" -1129],[294:297 "CODON" -1129] 0.05 [115:116 "MATCH_STATE" 18],[297:300 "CODON" 18] -1.15 [116:117 "MATCH_STATE" -397],[300:303 "CODON" -397] 2.67 [117:118 "MATCH_STATE" 926],[303:306 "CODON" 926] 2.67 [118:119 "MATCH_STATE" 926],[306:309 "CODON" 926] -0.15 [119:120 "MATCH_STATE" -53],[309:312 "CODON" -53] 2.53 [120:121 "MATCH_STATE" 876],[312:315 "CODON" 876] 2.67 [121:122 "MATCH_STATE" 926],[315:318 "CODON" 926] -0.15 [122:123 "MATCH_STATE" -53],[318:321 "CODON" -53] -1.39 [123:124 "MATCH_STATE" -483],[321:324 "CODON" -483] -1.83 [124:125 "MATCH_STATE" -633],[324:327 "CODON" -633] 2.67 [125:126 "MATCH_STATE" 926],[327:330 "CODON" 926] 2.67 [126:127 "MATCH_STATE" 926],[330:333 "CODON" 926] 2.84 [127:128 "MATCH_STATE" 986],[333:336 "CODON" 986] -5.98 [128:129 "DELETE_STATE" -2071],[336:336 "INSERT" -2071] -0.80 [129:130 "MATCH_STATE" -277],[336:339 "CODON" -277] 2.84 [130:131 "MATCH_STATE" 986],[339:342 "CODON" 986] -1.57 [131:132 "MATCH_STATE" -543],[342:345 "CODON" -543] -0.15 [132:133 "MATCH_STATE" -53],[345:348 "CODON" -53] -1.33 [133:134 "MATCH_STATE" -460],[348:351 "CODON" -460] 2.67 [134:135 "MATCH_STATE" 926],[351:354 "CODON" 926] 2.67 [135:136 "MATCH_STATE" 926],[354:357 "CODON" 926] 2.84 [136:137 "MATCH_STATE" 986],[357:360 "CODON" 986] 0.52 [137:138 "MATCH_STATE" 179],[360:363 "CODON" 179] 0.34 [138:139 "MATCH_STATE" 119],[363:366 "CODON" 119] -0.15 [139:140 "MATCH_STATE" -53],[366:369 "CODON" -53] -1.33 [140:141 "MATCH_STATE" -460],[369:372 "CODON" -460] 2.67 [141:142 "MATCH_STATE" 926],[372:375 "CODON" 926] -0.31 [142:143 "MATCH_STATE" -108],[375:378 "CODON" -108] -1.65 [143:144 "MATCH_STATE" -573],[378:381 "CODON" -573] -0.98 [144:145 "MATCH_STATE" -340],[381:384 "CODON" -340] 2.67 [145:146 "MATCH_STATE" 926],[384:387 "CODON" 926] 0.34 [146:147 "MATCH_STATE" 119],[387:390 "CODON" 119] 0.00 [147:0 "END" 0],[390:390 "END" 0] // Score 44549 Position i:[21] j:[12] State:[3] Score: 0 Position i:[22] j:[15] State:[0] Score: 794 Position i:[23] j:[18] State:[0] Score: 361 Position i:[24] j:[21] State:[0] Score: 1077 Position i:[25] j:[24] State:[0] Score: 697 Position i:[26] j:[27] State:[0] Score: 926 Position i:[27] j:[30] State:[0] Score: -50 Position i:[28] j:[33] State:[0] Score: 361 Position i:[29] j:[36] State:[0] Score: 778 Position i:[30] j:[39] State:[0] Score: 318 Position i:[31] j:[42] State:[0] Score: 1011 Position i:[32] j:[45] State:[0] Score: -447 Position i:[33] j:[48] State:[0] Score: 318 Position i:[34] j:[51] State:[0] Score: 823 Position i:[35] j:[54] State:[0] Score: -23 Position i:[36] j:[57] State:[0] Score: -236 Position i:[37] j:[60] State:[0] Score: 380 Position i:[38] j:[63] State:[0] Score: 876 Position i:[39] j:[66] State:[0] Score: 1011 Position i:[40] j:[69] State:[0] Score: 1194 Position i:[41] j:[72] State:[0] Score: 1077 Position i:[42] j:[75] State:[0] Score: 322 Position i:[43] j:[78] State:[0] Score: -100 Position i:[44] j:[81] State:[0] Score: 558 Position i:[45] j:[84] State:[0] Score: 926 Position i:[46] j:[87] State:[0] Score: -53 Position i:[47] j:[90] State:[0] Score: 727 Position i:[48] j:[93] State:[0] Score: -342 Position i:[49] j:[96] State:[0] Score: -548 Position i:[50] j:[99] State:[0] Score: 727 Position i:[51] j:[102] State:[0] Score: -53 Position i:[52] j:[105] State:[0] Score: 727 Position i:[53] j:[108] State:[0] Score: 177 Position i:[54] j:[111] State:[0] Score: -139 Position i:[55] j:[114] State:[0] Score: 1011 Position i:[56] j:[117] State:[0] Score: 258 Position i:[57] j:[120] State:[0] Score: -389 Position i:[58] j:[123] State:[0] Score: 127 Position i:[59] j:[126] State:[0] Score: 926 Position i:[60] j:[129] State:[0] Score: 778 Position i:[61] j:[132] State:[0] Score: 778 Position i:[62] j:[135] State:[0] Score: 876 Position i:[63] j:[138] State:[0] Score: 926 Position i:[64] j:[141] State:[0] Score: 1077 Position i:[65] j:[144] State:[0] Score: 642 Position i:[66] j:[147] State:[0] Score: 850 Position i:[67] j:[150] State:[0] Score: 697 Position i:[68] j:[153] State:[0] Score: -216 Position i:[69] j:[156] State:[0] Score: 1077 Position i:[70] j:[159] State:[0] Score: 1011 Position i:[71] j:[162] State:[0] Score: 1011 Position i:[72] j:[165] State:[0] Score: 328 Position i:[73] j:[168] State:[0] Score: 1011 Position i:[74] j:[171] State:[0] Score: -235 Position i:[75] j:[174] State:[0] Score: 697 Position i:[76] j:[177] State:[0] Score: 1011 Position i:[77] j:[180] State:[0] Score: 778 Position i:[78] j:[183] State:[0] Score: 524 Position i:[79] j:[186] State:[0] Score: 697 Position i:[80] j:[189] State:[0] Score: 361 Position i:[81] j:[192] State:[0] Score: 842 Position i:[82] j:[195] State:[0] Score: 778 Position i:[83] j:[198] State:[0] Score: -197 Position i:[84] j:[201] State:[0] Score: 1285 Position i:[85] j:[204] State:[0] Score: -197 Position i:[86] j:[207] State:[0] Score: 188 Position i:[87] j:[210] State:[0] Score: 986 Position i:[88] j:[213] State:[0] Score: 926 Position i:[89] j:[216] State:[0] Score: -261 Position i:[90] j:[219] State:[0] Score: -310 Position i:[91] j:[222] State:[0] Score: -168 Position i:[92] j:[225] State:[0] Score: 318 Position i:[93] j:[228] State:[0] Score: 697 Position i:[94] j:[231] State:[0] Score: 258 Position i:[95] j:[234] State:[0] Score: 778 Position i:[96] j:[237] State:[0] Score: 642 Position i:[97] j:[240] State:[0] Score: 708 Position i:[98] j:[243] State:[0] Score: -235 Position i:[99] j:[246] State:[0] Score: 778 Position i:[100] j:[249] State:[0] Score: 842 Position i:[101] j:[252] State:[0] Score: -53 Position i:[102] j:[255] State:[0] Score: -548 Position i:[103] j:[258] State:[0] Score: -197 Position i:[104] j:[261] State:[0] Score: -23 Position i:[105] j:[264] State:[0] Score: -113 Position i:[106] j:[267] State:[0] Score: -113 Position i:[107] j:[270] State:[0] Score: -113 Position i:[108] j:[273] State:[0] Score: -113 Position i:[109] j:[276] State:[0] Score: -460 Position i:[110] j:[279] State:[0] Score: 876 Position i:[111] j:[282] State:[0] Score: 926 Position i:[112] j:[285] State:[0] Score: -460 Position i:[113] j:[288] State:[0] Score: -235 Position i:[114] j:[291] State:[0] Score: 926 Position i:[115] j:[294] State:[0] Score: -113 Position i:[115] j:[297] State:[1] Score: -1129 Position i:[116] j:[300] State:[0] Score: 18 Position i:[117] j:[303] State:[0] Score: -397 Position i:[118] j:[306] State:[0] Score: 926 Position i:[119] j:[309] State:[0] Score: 926 Position i:[120] j:[312] State:[0] Score: -53 Position i:[121] j:[315] State:[0] Score: 876 Position i:[122] j:[318] State:[0] Score: 926 Position i:[123] j:[321] State:[0] Score: -53 Position i:[124] j:[324] State:[0] Score: -483 Position i:[125] j:[327] State:[0] Score: -633 Position i:[126] j:[330] State:[0] Score: 926 Position i:[127] j:[333] State:[0] Score: 926 Position i:[128] j:[336] State:[0] Score: 986 Position i:[129] j:[336] State:[2] Score: -2071 Position i:[130] j:[339] State:[0] Score: -277 Position i:[131] j:[342] State:[0] Score: 986 Position i:[132] j:[345] State:[0] Score: -543 Position i:[133] j:[348] State:[0] Score: -53 Position i:[134] j:[351] State:[0] Score: -460 Position i:[135] j:[354] State:[0] Score: 926 Position i:[136] j:[357] State:[0] Score: 926 Position i:[137] j:[360] State:[0] Score: 986 Position i:[138] j:[363] State:[0] Score: 179 Position i:[139] j:[366] State:[0] Score: 119 Position i:[140] j:[369] State:[0] Score: -53 Position i:[141] j:[372] State:[0] Score: -460 Position i:[142] j:[375] State:[0] Score: 926 Position i:[143] j:[378] State:[0] Score: -108 Position i:[144] j:[381] State:[0] Score: -573 Position i:[145] j:[384] State:[0] Score: -340 Position i:[146] j:[387] State:[0] Score: 926 Position i:[147] j:[390] State:[0] Score: 119 Position i:[0] j:[390] State:[4] Score: 0 // pcwise output Score 13.86 bits over entire alignment Score reported as bits over a synchronised coding sequence model roa1_drome 32 DHDEQSIRDYFQHFG DH QS++++F FG DH-HQSFQNHFDLFG HSHNCPA1 -314 gc ccatcactgctg aa aagtaaatattg cc catcgccccctc // Bits Query start end Target start end idels 13.86 roa1_drome 32 46 HSHNCPA1 314 271 0 // 2.96 [30:31 "MATCH_STATE" 1027],[100:103 "CODON" 1027] 3.71 [31:32 "MATCH_STATE" 1285],[103:106 "CODON" 1285] -5.98 [32:33 "DELETE_STATE" -2071],[106:106 "INSERT" -2071] -0.10 [33:34 "MATCH_STATE" -34],[106:109 "CODON" -34] 2.43 [34:35 "MATCH_STATE" 842],[109:112 "CODON" 842] 1.81 [35:36 "MATCH_STATE" 629],[112:115 "CODON" 629] 0.10 [36:37 "MATCH_STATE" 33],[115:118 "CODON" 33] 0.53 [37:38 "MATCH_STATE" 183],[118:121 "CODON" 183] 0.42 [38:39 "MATCH_STATE" 144],[121:124 "CODON" 144] 0.95 [39:40 "MATCH_STATE" 328],[124:127 "CODON" 328] 3.11 [40:41 "MATCH_STATE" 1077],[127:130 "CODON" 1077] -0.07 [41:42 "MATCH_STATE" -23],[130:133 "CODON" -23] -1.79 [42:43 "MATCH_STATE" -620],[133:136 "CODON" -620] 3.11 [43:44 "MATCH_STATE" 1077],[136:139 "CODON" 1077] 2.67 [44:45 "MATCH_STATE" 926],[139:142 "CODON" 926] 0.00 [45:0 "END" 0],[142:142 "END" 0] // Score 4803 Position i:[30] j:[100] State:[3] Score: 0 Position i:[31] j:[103] State:[0] Score: 1027 Position i:[32] j:[106] State:[0] Score: 1285 Position i:[33] j:[106] State:[2] Score: -2071 Position i:[34] j:[109] State:[0] Score: -34 Position i:[35] j:[112] State:[0] Score: 842 Position i:[36] j:[115] State:[0] Score: 629 Position i:[37] j:[118] State:[0] Score: 33 Position i:[38] j:[121] State:[0] Score: 183 Position i:[39] j:[124] State:[0] Score: 144 Position i:[40] j:[127] State:[0] Score: 328 Position i:[41] j:[130] State:[0] Score: 1077 Position i:[42] j:[133] State:[0] Score: -23 Position i:[43] j:[136] State:[0] Score: -620 Position i:[44] j:[139] State:[0] Score: 1077 Position i:[45] j:[142] State:[0] Score: 926 Position i:[0] j:[142] State:[4] Score: 0 // wise-2.4.1/src/test/scanwisep.out0000644000175000001440000001344507652043207016360 0ustar philippusersBLASTP 2.1.2 Reference: Wise2 Package, Ewan Birney BLAST like format to play well with existing parsers. Other options are available See help on the program that generated this for other options Statistics from : Mott R (2000) Accurate Formula for P-values of gapped local sequence and profile alignments J. Mol Biol. 300:649-659 Query= Not specified Search.................................done Score E Sequences producing significant alignments: (bits) Value ROA1_HUMAN 416.50 1.9e-53 SW:ROA1_XENLA 364.50 2e-46 Q22037 287.00 1.1e-37 >ROA1_HUMAN Length = 371 Reversed 0 Score = 416.5 bits (833), Expect = 1.85161e-53 Query: 22 DSITEPEHMRKLFIGGLDYRTTDENLKAHFEKWGNIVDVVVMKDPRTKR +S EPE +RKLFIGGL + TTDE+L++HFE+WG + D VVM+DP TKR Sbjct: 4 ESPKEPEQLRKLFIGGLSFETTDESLRSHFEQWGTLTDCVVMRDPNTKR Query: 71 SRGFGFITYSHSSMIDEAQKSRPHKIDGRVVEPKRAVPRQDIDSPNAGA SRGFGF+TY+ +D A +RPHK+DGRVVEPKRAV R+D P A Sbjct: 53 SRGFGFVTYATVEEVDAAMNARPHKVDGRVVEPKRAVSREDSQRPGAHL Query: 120 TVKKLFVGALKDDHDEQSIRDYFQHFGNIVDINIVIDKETGKKRGFAFV TVKK+FVG +K+D +E +RDYF+ +G I I I+ D+ +GKKRGFAFV Sbjct: 102 TVKKIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAFV Query: 169 EFDDYDPVDKVVLQKQHQLNGKMVDVKKALPKQ------NDQQGGGGGR FDD+D VDK+V+QK H +NG +V+KAL KQ + Q+G G Sbjct: 151 TFDDHDSVDKIVIQKYHTVNGHNCEVRKALSKQEMASASSSQRGRSGSG Query: 212 GGPGGRAGGNRGNMGGGNYGNQNGGGNW--NNGGNNWGNNRGGNDNWGN GGR GG GN G GN +G G + + GG +G + G + +GN Sbjct: 200 NFGGGRGGGFGGNDNFGRGGNFSGRGGFGGSRGGGGYGGSGDGYNGFGN Query: 259 NS-FGGGG----GGGGGYGGGNNSWGNN----------NPWDNGNGGGN + +GGGG GG GYG G +GN + ++NG G G Sbjct: 249 DGGYGGGGPGYSGGSRGYGSGGQGYGNQGSGYGGSGSYDSYNNGGGRGF Query: 293 FGGGGNNWNNGG--NDFGGYQ-QNYGGGPQRGGGNFNNNRMQPYQGGGG GG G+N+ GG NDFG Y Q+ GP +GG NF PY GGG Sbjct: 298 GGGSGSNFGGGGSYNDFGNYNNQSSNFGPMKGG-NFGGRSSGPYGGGGQ Query: 339 FKAGGGNQGNYGGNNQGFNNGGNNR + A NQG YGG++ + G R Sbjct: 346 YFAKPRNQGGYGGSSSSSSYGSGRR >SW:ROA1_XENLA Length = 365 Reversed 0 Score = 364.5 bits (729), Expect = 1.95513e-46 Query: 26 EPEHMRKLFIGGLDYRTTDENLKAHFEKWGNIVDVVVMKDPRTKRSRGF EPE +RKLFIGGL + TTDE+L+ HFE+WG + D VVM+DP +KRSRGF Sbjct: 9 EPEQLRKLFIGGLSFETTDESLREHFEQWGTLTDCVVMRDPNSKRSRGF Query: 75 GFITYSHSSMIDEAQKSRPHKIDGRVVEPKRAVPRQDIDSPNAGATVKK GF+TY + +D A +RPHK+DGRVVEPKRAV R+D P A TVKK Sbjct: 58 GFVTYLSTDEVDAAMTARPHKVDGRVVEPKRAVSREDSSRPGAHLTVKK Query: 124 LFVGALKDDHDEQSIRDYFQHFGNIVDINIVIDKETGKKRGFAFVEFDD +FVG +K+D +E +R+YF+ +G I I I+ D+ +GKKRGFAFV F+D Sbjct: 107 IFVGGIKEDTEEDHLREYFEQYGKIEVIEIMTDRGSGKKRGFAFVTFED Query: 173 YDPVDKVVLQKQHQLNGKMVDVKKALPKQ-------NDQQGGGGGR--- +D VDK+V+QK H +N V+KAL KQ + ++ GG G Sbjct: 156 HDSVDKIVIQKYHTVNNHNSQVRKALSKQEMASVSGSQRERGGSGNYGS Query: 212 ---------GGPGGRAGGNRGNMGGGNYGNQNGGGNWNNG-GNNWGNNR GG GG GGNRG GGG +GN+ GG+ NG G W Sbjct: 205 RGGFGNDNFGGRGGNFGGNRG--GGGGFGNRGYGGDGYNGDGQLWWQPS Query: 251 --GGNDNWGNNSFGG-GGGGGGGYGGGNNS--WGNNNPWDNGNGGGN-F G N +G GG G G GGGYGGG +G N +D NGGG+ F Sbjct: 252 LLGWNRGYGAGQGGGYGAGQGGGYGGGGQGGGYGGNGGYDGYNGGGSGF Query: 294 GGGGNNWNNGG--NDFGGYQQ G G N+ + G NDFG Y Sbjct: 301 SGSGGNFGSSGGYNDFGNYNS >Q22037 Length = 346 Reversed 0 Score = 287.0 bits (574), Expect = 1.10211e-37 Query: 22 DSITEPEHMRKLFIGGLDYRTTDENLKAHFEKWGNIVDVVVMKDPRTKR D+ EPE++RK+F+GGL TTD+ ++ + ++G I D++VM+DP TKR Sbjct: 14 DASLEPENLRKIFVGGLTSNTTDDLMREFYSQFGEITDIIVMRDPTTKR Query: 71 SRGFGFITYSHSSMIDEAQKSRPHKIDGRVVEPKRAVPRQDIDSPNAGA SRGFGF+T+S + +D A K RPH IDG+ V+PKRAVPR D + + Sbjct: 63 SRGFGFVTFSGKTEVDAAMKQRPHIIDGKTVDPKRAVPRDDKNRSESNV Query: 120 TVKKLFVGALKDDHDEQSIRDYFQHFGNIVDINIVIDKETGKKRGFAFV + K+L+V +++DH E + +YF +G + I++DK T K RGF FV Sbjct: 112 STKRLYVSGVREDHTEDMLTEYFTKYGTVTKSEIILDKATQKPRGFGFV Query: 169 EFDDYDPVDKVVLQKQHQLNGKMVDVKKALPKQNDQQGGGGGRGGPGGR FDD+D VD+ VLQK H +NG DV+K L K D+ R Sbjct: 161 TFDDHDSVDQCVLQKSHMVNGHRCDVRKGLSK--DEMSKAQMNRDRETR Query: 218 AGGNRGNMGGGNYGNQNGGGNWNNGGNNWGNNRGGNDNWGNNSFGGGGG G +R GG G GGG W RGG +G GG GG Sbjct: 208 GGRSRDGQRGGYNGGGGGGGGWGGPAQ-----RGGPGAYGGPGGGGQGG Query: 267 GGGGYGGG GG YGGG Sbjct: 252 YGGDYGGG wise-2.4.1/src/test/estwise-db.out0000644000175000001440000005770507313404552016437 0ustar philippusers------------------------------------------------------------- Wise2 - database searching mode Program: estwisedb version: $Name: wise2-4-1 $ released: unreleased This program is freely distributed under a Gnu Public License. See -version for more info on copyright Bugs and credits to Ewan Birney ------------------------------------------------------------- Algorithm type: EstWise Search algorithm: 333 Implementation: Single Threaded processor (serial) Search mode: Single protein vs cdna db Protein info from: rrm.HMM Dna info from: dna.db Start/End local Codon Table: codon.table Subs error: 0.01 Indel error: 0.01 Null model: synchronous Protein Insertion: modelled Alignment Alg 333 [Warning: Can't fit histogram to a db smaller than 1,000] #High Score list #Protein ID DNA Str ID Bits Evalue -------------------------------------------------------------------------- Protein SEED DNA [+] MMD728 84.99 Protein SEED DNA [+] MMD729 84.99 Protein SEED DNA [+] MMFLI2X 84.99 Protein SEED DNA [+] SAHNRNPH 69.54 #Alignments ----------------------------------------------------------------------- >Results for SEED vs MMD728 (forward) [1] estwisedb output Score 84.99 bits over entire alignment. This will be different from per-alignment scores. See manual for details For computer parsable output, try estwisedb -help or read the manual Scores as bits over a synchronous coding model Alignment 1 Score 85.04 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF FVG++ +D+ E+ L+D+F+++G+I+ I+I++D + GK +GFAF IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTD-----RGSGKKRGFAF MMD728 343 atgggaaggaggccccgttgctgaaggagaaag agagaaagtgt tttggtaaacaaaatgaataaagatattattca ggggaaggtct ctttttaactaatcaatttggtggtagaatgtc actgaggcttt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+F+++++ +K + ++++G++++V VTFDDHDSVDKIVI-QKYHTVNGHNCEV MMD728 475 gatggcgtggaaga catcagagcatgg tctaaaactaattt aaaactagaagat tcttctctgtgttt gacttgtccctaa // -9.59 [-1:0 "MATCH_STATE" -3324],[341:344 "CODON" -3324] 3.14 [0:1 "MATCH_STATE" 1088],[344:347 "CODON" 1088] 3.05 [1:2 "MATCH_STATE" 1058],[347:350 "CODON" 1058] 2.39 [2:3 "MATCH_STATE" 827],[350:353 "CODON" 827] 1.72 [3:4 "MATCH_STATE" 596],[353:356 "CODON" 596] 0.58 [4:5 "MATCH_STATE" 202],[356:359 "CODON" 202] -0.64 [5:6 "MATCH_STATE" -221],[359:362 "CODON" -221] 0.56 [6:7 "MATCH_STATE" 193],[362:365 "CODON" 193] 2.33 [7:8 "MATCH_STATE" 807],[365:368 "CODON" 807] 1.65 [8:9 "MATCH_STATE" 572],[368:371 "CODON" 572] -1.23 [9:10 "MATCH_STATE" -428],[371:374 "CODON" -428] 2.40 [10:11 "MATCH_STATE" 833],[374:377 "CODON" 833] 0.44 [11:12 "MATCH_STATE" 154],[377:380 "CODON" 154] -0.91 [12:13 "MATCH_STATE" -314],[380:383 "CODON" -314] 2.74 [13:14 "MATCH_STATE" 951],[383:386 "CODON" 951] 1.71 [14:15 "MATCH_STATE" 593],[386:389 "CODON" 593] 2.05 [15:16 "MATCH_STATE" 710],[389:392 "CODON" 710] 1.12 [16:17 "MATCH_STATE" 387],[392:395 "CODON" 387] 4.13 [17:18 "MATCH_STATE" 1430],[395:398 "CODON" 1430] 0.90 [18:19 "MATCH_STATE" 311],[398:401 "CODON" 311] 1.64 [19:20 "MATCH_STATE" 568],[401:404 "CODON" 568] 2.74 [20:21 "MATCH_STATE" 949],[404:407 "CODON" 949] 3.43 [21:22 "MATCH_STATE" 1188],[407:410 "CODON" 1188] 1.26 [22:23 "MATCH_STATE" 436],[410:413 "CODON" 436] 2.63 [23:24 "MATCH_STATE" 913],[413:416 "CODON" 913] 1.12 [24:25 "MATCH_STATE" 388],[416:419 "CODON" 388] -2.39 [25:26 "MATCH_STATE" -827],[419:422 "CODON" -827] 2.14 [26:27 "MATCH_STATE" 742],[422:425 "CODON" 742] 0.45 [27:28 "MATCH_STATE" 156],[425:428 "CODON" 156] 2.09 [28:29 "MATCH_STATE" 724],[428:431 "CODON" 724] 1.87 [29:30 "MATCH_STATE" 647],[431:434 "CODON" 647] 0.71 [30:31 "MATCH_STATE" 245],[434:437 "CODON" 245] 2.89 [31:32 "MATCH_STATE" 1001],[437:440 "CODON" 1001] -0.11 [32:33 "DELETE_STATE" -38],[440:440 "INSERT" -38] -0.07 [33:34 "DELETE_STATE" -24],[440:440 "INSERT" -24] -0.05 [34:35 "DELETE_STATE" -18],[440:440 "INSERT" -18] -0.05 [35:36 "DELETE_STATE" -18],[440:440 "INSERT" -18] -0.05 [36:37 "DELETE_STATE" -19],[440:440 "INSERT" -19] 0.65 [37:38 "MATCH_STATE" 226],[440:443 "CODON" 226] -0.69 [38:39 "MATCH_STATE" -240],[443:446 "CODON" -240] -0.09 [39:40 "MATCH_STATE" -31],[446:449 "CODON" -31] 2.43 [40:41 "MATCH_STATE" 843],[449:452 "CODON" 843] 1.87 [41:42 "MATCH_STATE" 648],[452:455 "CODON" 648] -0.52 [42:43 "MATCH_STATE" -181],[455:458 "CODON" -181] 2.18 [43:44 "MATCH_STATE" 756],[458:461 "CODON" 756] 3.16 [44:45 "MATCH_STATE" 1095],[461:464 "CODON" 1095] 2.99 [45:46 "MATCH_STATE" 1035],[464:467 "CODON" 1035] 2.44 [46:47 "MATCH_STATE" 846],[467:470 "CODON" 846] 3.94 [47:48 "MATCH_STATE" 1367],[470:473 "CODON" 1367] 3.22 [48:49 "MATCH_STATE" 1115],[473:476 "CODON" 1115] 1.24 [49:50 "MATCH_STATE" 429],[476:479 "CODON" 429] 3.92 [50:51 "MATCH_STATE" 1359],[479:482 "CODON" 1359] 1.09 [51:52 "MATCH_STATE" 379],[482:485 "CODON" 379] 1.85 [52:53 "MATCH_STATE" 640],[485:488 "CODON" 640] 1.41 [53:54 "MATCH_STATE" 489],[488:491 "CODON" 489] 1.56 [54:55 "MATCH_STATE" 539],[491:494 "CODON" 539] 1.20 [55:56 "MATCH_STATE" 416],[494:497 "CODON" 416] -0.02 [56:57 "MATCH_STATE" -6],[497:500 "CODON" -6] 0.94 [57:58 "MATCH_STATE" 325],[500:503 "CODON" 325] 2.25 [58:59 "MATCH_STATE" 781],[503:506 "CODON" 781] -0.21 [59:60 "MATCH_STATE" -73],[506:509 "CODON" -73] 1.52 [60:61 "MATCH_STATE" 526],[509:512 "CODON" 526] -0.86 [61:62 "MATCH_STATE" -297],[512:515 "CODON" -297] -2.45 [62:63 "DELETE_STATE" -848],[515:515 "INSERT" -848] -0.46 [63:64 "MATCH_STATE" -159],[515:518 "CODON" -159] -0.37 [64:65 "MATCH_STATE" -127],[518:521 "CODON" -127] -0.68 [65:66 "MATCH_STATE" -236],[521:524 "CODON" -236] 0.88 [66:67 "MATCH_STATE" 304],[524:527 "CODON" 304] 0.64 [67:68 "MATCH_STATE" 223],[527:530 "CODON" 223] 1.19 [68:69 "MATCH_STATE" 412],[530:533 "CODON" 412] 1.63 [69:70 "MATCH_STATE" 565],[533:536 "CODON" 565] 2.67 [70:71 "MATCH_STATE" 925],[536:539 "CODON" 925] 1.82 [71:72 "MATCH_STATE" 630],[539:542 "CODON" 630] 0.16 [72:73 "MATCH_STATE" 55],[542:545 "CODON" 55] 0.81 [73:74 "MATCH_STATE" 282],[545:548 "CODON" 282] 0.28 [74:75 "MATCH_STATE" 98],[548:551 "CODON" 98] 2.67 [75:76 "MATCH_STATE" 926],[551:554 "CODON" 926] -0.06 [76:0 "END" -20],[554:554 "END" -20] // >Results for SEED vs MMD729 (forward) [2] estwisedb output Score 84.99 bits over entire alignment. This will be different from per-alignment scores. See manual for details For computer parsable output, try estwisedb -help or read the manual Scores as bits over a synchronous coding model Alignment 1 Score 85.04 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF FVG++ +D+ E+ L+D+F+++G+I+ I+I++D + GK +GFAF IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTD-----RGSGKKRGFAF MMD729 343 atgggaaggaggccccgttgctgaaggagaaag agagaaagtgt tttggtaaacaaaatgaataaagatattattca ggggaaggtct ctttttaactaatcaatttggtggtagaatgtc actgaggcttt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+F+++++ +K + ++++G++++V VTFDDHDSVDKIVI-QKYHTVNGHNCEV MMD729 475 gatggcgtggaaga catcagagcatgg tctaaaactaattt aaaactagaagat tcttctctgtgttt gacttgtccctaa // -9.59 [-1:0 "MATCH_STATE" -3324],[341:344 "CODON" -3324] 3.14 [0:1 "MATCH_STATE" 1088],[344:347 "CODON" 1088] 3.05 [1:2 "MATCH_STATE" 1058],[347:350 "CODON" 1058] 2.39 [2:3 "MATCH_STATE" 827],[350:353 "CODON" 827] 1.72 [3:4 "MATCH_STATE" 596],[353:356 "CODON" 596] 0.58 [4:5 "MATCH_STATE" 202],[356:359 "CODON" 202] -0.64 [5:6 "MATCH_STATE" -221],[359:362 "CODON" -221] 0.56 [6:7 "MATCH_STATE" 193],[362:365 "CODON" 193] 2.33 [7:8 "MATCH_STATE" 807],[365:368 "CODON" 807] 1.65 [8:9 "MATCH_STATE" 572],[368:371 "CODON" 572] -1.23 [9:10 "MATCH_STATE" -428],[371:374 "CODON" -428] 2.40 [10:11 "MATCH_STATE" 833],[374:377 "CODON" 833] 0.44 [11:12 "MATCH_STATE" 154],[377:380 "CODON" 154] -0.91 [12:13 "MATCH_STATE" -314],[380:383 "CODON" -314] 2.74 [13:14 "MATCH_STATE" 951],[383:386 "CODON" 951] 1.71 [14:15 "MATCH_STATE" 593],[386:389 "CODON" 593] 2.05 [15:16 "MATCH_STATE" 710],[389:392 "CODON" 710] 1.12 [16:17 "MATCH_STATE" 387],[392:395 "CODON" 387] 4.13 [17:18 "MATCH_STATE" 1430],[395:398 "CODON" 1430] 0.90 [18:19 "MATCH_STATE" 311],[398:401 "CODON" 311] 1.64 [19:20 "MATCH_STATE" 568],[401:404 "CODON" 568] 2.74 [20:21 "MATCH_STATE" 949],[404:407 "CODON" 949] 3.43 [21:22 "MATCH_STATE" 1188],[407:410 "CODON" 1188] 1.26 [22:23 "MATCH_STATE" 436],[410:413 "CODON" 436] 2.63 [23:24 "MATCH_STATE" 913],[413:416 "CODON" 913] 1.12 [24:25 "MATCH_STATE" 388],[416:419 "CODON" 388] -2.39 [25:26 "MATCH_STATE" -827],[419:422 "CODON" -827] 2.14 [26:27 "MATCH_STATE" 742],[422:425 "CODON" 742] 0.45 [27:28 "MATCH_STATE" 156],[425:428 "CODON" 156] 2.09 [28:29 "MATCH_STATE" 724],[428:431 "CODON" 724] 1.87 [29:30 "MATCH_STATE" 647],[431:434 "CODON" 647] 0.71 [30:31 "MATCH_STATE" 245],[434:437 "CODON" 245] 2.89 [31:32 "MATCH_STATE" 1001],[437:440 "CODON" 1001] -0.11 [32:33 "DELETE_STATE" -38],[440:440 "INSERT" -38] -0.07 [33:34 "DELETE_STATE" -24],[440:440 "INSERT" -24] -0.05 [34:35 "DELETE_STATE" -18],[440:440 "INSERT" -18] -0.05 [35:36 "DELETE_STATE" -18],[440:440 "INSERT" -18] -0.05 [36:37 "DELETE_STATE" -19],[440:440 "INSERT" -19] 0.65 [37:38 "MATCH_STATE" 226],[440:443 "CODON" 226] -0.69 [38:39 "MATCH_STATE" -240],[443:446 "CODON" -240] -0.09 [39:40 "MATCH_STATE" -31],[446:449 "CODON" -31] 2.43 [40:41 "MATCH_STATE" 843],[449:452 "CODON" 843] 1.87 [41:42 "MATCH_STATE" 648],[452:455 "CODON" 648] -0.52 [42:43 "MATCH_STATE" -181],[455:458 "CODON" -181] 2.18 [43:44 "MATCH_STATE" 756],[458:461 "CODON" 756] 3.16 [44:45 "MATCH_STATE" 1095],[461:464 "CODON" 1095] 2.99 [45:46 "MATCH_STATE" 1035],[464:467 "CODON" 1035] 2.44 [46:47 "MATCH_STATE" 846],[467:470 "CODON" 846] 3.94 [47:48 "MATCH_STATE" 1367],[470:473 "CODON" 1367] 3.22 [48:49 "MATCH_STATE" 1115],[473:476 "CODON" 1115] 1.24 [49:50 "MATCH_STATE" 429],[476:479 "CODON" 429] 3.92 [50:51 "MATCH_STATE" 1359],[479:482 "CODON" 1359] 1.09 [51:52 "MATCH_STATE" 379],[482:485 "CODON" 379] 1.85 [52:53 "MATCH_STATE" 640],[485:488 "CODON" 640] 1.41 [53:54 "MATCH_STATE" 489],[488:491 "CODON" 489] 1.56 [54:55 "MATCH_STATE" 539],[491:494 "CODON" 539] 1.20 [55:56 "MATCH_STATE" 416],[494:497 "CODON" 416] -0.02 [56:57 "MATCH_STATE" -6],[497:500 "CODON" -6] 0.94 [57:58 "MATCH_STATE" 325],[500:503 "CODON" 325] 2.25 [58:59 "MATCH_STATE" 781],[503:506 "CODON" 781] -0.21 [59:60 "MATCH_STATE" -73],[506:509 "CODON" -73] 1.52 [60:61 "MATCH_STATE" 526],[509:512 "CODON" 526] -0.86 [61:62 "MATCH_STATE" -297],[512:515 "CODON" -297] -2.45 [62:63 "DELETE_STATE" -848],[515:515 "INSERT" -848] -0.46 [63:64 "MATCH_STATE" -159],[515:518 "CODON" -159] -0.37 [64:65 "MATCH_STATE" -127],[518:521 "CODON" -127] -0.68 [65:66 "MATCH_STATE" -236],[521:524 "CODON" -236] 0.88 [66:67 "MATCH_STATE" 304],[524:527 "CODON" 304] 0.64 [67:68 "MATCH_STATE" 223],[527:530 "CODON" 223] 1.19 [68:69 "MATCH_STATE" 412],[530:533 "CODON" 412] 1.63 [69:70 "MATCH_STATE" 565],[533:536 "CODON" 565] 2.67 [70:71 "MATCH_STATE" 925],[536:539 "CODON" 925] 1.82 [71:72 "MATCH_STATE" 630],[539:542 "CODON" 630] 0.16 [72:73 "MATCH_STATE" 55],[542:545 "CODON" 55] 0.81 [73:74 "MATCH_STATE" 282],[545:548 "CODON" 282] 0.28 [74:75 "MATCH_STATE" 98],[548:551 "CODON" 98] 2.67 [75:76 "MATCH_STATE" 926],[551:554 "CODON" 926] -0.06 [76:0 "END" -20],[554:554 "END" -20] // >Results for SEED vs MMFLI2X (forward) [3] estwisedb output Score 84.99 bits over entire alignment. This will be different from per-alignment scores. See manual for details For computer parsable output, try estwisedb -help or read the manual Scores as bits over a synchronous coding model Alignment 1 Score 85.04 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF FVG++ +D+ E+ L+D+F+++G+I+ I+I++D + GK +GFAF IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTD-----RGSGKKRGFAF MMFLI2X 378 atgggaaggaggccccgttgctgaaggagaaag agagaaagtgt tttggtaaacaaaatgaataaagatattattca ggggaaggtct ctttttaactaatcaatttggtggtagaatgtc actgaggcttt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+F+++++ +K + ++++G++++V VTFDDHDSVDKIVI-QKYHTVNGHNCEV MMFLI2X 510 gatggcgtggaaga catcagagcatgg tctaaaactaattt aaaactagaagat tcttctctgtgttt gacttgtccctaa // -9.59 [-1:0 "MATCH_STATE" -3324],[376:379 "CODON" -3324] 3.14 [0:1 "MATCH_STATE" 1088],[379:382 "CODON" 1088] 3.05 [1:2 "MATCH_STATE" 1058],[382:385 "CODON" 1058] 2.39 [2:3 "MATCH_STATE" 827],[385:388 "CODON" 827] 1.72 [3:4 "MATCH_STATE" 596],[388:391 "CODON" 596] 0.58 [4:5 "MATCH_STATE" 202],[391:394 "CODON" 202] -0.64 [5:6 "MATCH_STATE" -221],[394:397 "CODON" -221] 0.56 [6:7 "MATCH_STATE" 193],[397:400 "CODON" 193] 2.33 [7:8 "MATCH_STATE" 807],[400:403 "CODON" 807] 1.65 [8:9 "MATCH_STATE" 572],[403:406 "CODON" 572] -1.23 [9:10 "MATCH_STATE" -428],[406:409 "CODON" -428] 2.40 [10:11 "MATCH_STATE" 833],[409:412 "CODON" 833] 0.44 [11:12 "MATCH_STATE" 154],[412:415 "CODON" 154] -0.91 [12:13 "MATCH_STATE" -314],[415:418 "CODON" -314] 2.74 [13:14 "MATCH_STATE" 951],[418:421 "CODON" 951] 1.71 [14:15 "MATCH_STATE" 593],[421:424 "CODON" 593] 2.05 [15:16 "MATCH_STATE" 710],[424:427 "CODON" 710] 1.12 [16:17 "MATCH_STATE" 387],[427:430 "CODON" 387] 4.13 [17:18 "MATCH_STATE" 1430],[430:433 "CODON" 1430] 0.90 [18:19 "MATCH_STATE" 311],[433:436 "CODON" 311] 1.64 [19:20 "MATCH_STATE" 568],[436:439 "CODON" 568] 2.74 [20:21 "MATCH_STATE" 949],[439:442 "CODON" 949] 3.43 [21:22 "MATCH_STATE" 1188],[442:445 "CODON" 1188] 1.26 [22:23 "MATCH_STATE" 436],[445:448 "CODON" 436] 2.63 [23:24 "MATCH_STATE" 913],[448:451 "CODON" 913] 1.12 [24:25 "MATCH_STATE" 388],[451:454 "CODON" 388] -2.39 [25:26 "MATCH_STATE" -827],[454:457 "CODON" -827] 2.14 [26:27 "MATCH_STATE" 742],[457:460 "CODON" 742] 0.45 [27:28 "MATCH_STATE" 156],[460:463 "CODON" 156] 2.09 [28:29 "MATCH_STATE" 724],[463:466 "CODON" 724] 1.87 [29:30 "MATCH_STATE" 647],[466:469 "CODON" 647] 0.71 [30:31 "MATCH_STATE" 245],[469:472 "CODON" 245] 2.89 [31:32 "MATCH_STATE" 1001],[472:475 "CODON" 1001] -0.11 [32:33 "DELETE_STATE" -38],[475:475 "INSERT" -38] -0.07 [33:34 "DELETE_STATE" -24],[475:475 "INSERT" -24] -0.05 [34:35 "DELETE_STATE" -18],[475:475 "INSERT" -18] -0.05 [35:36 "DELETE_STATE" -18],[475:475 "INSERT" -18] -0.05 [36:37 "DELETE_STATE" -19],[475:475 "INSERT" -19] 0.65 [37:38 "MATCH_STATE" 226],[475:478 "CODON" 226] -0.69 [38:39 "MATCH_STATE" -240],[478:481 "CODON" -240] -0.09 [39:40 "MATCH_STATE" -31],[481:484 "CODON" -31] 2.43 [40:41 "MATCH_STATE" 843],[484:487 "CODON" 843] 1.87 [41:42 "MATCH_STATE" 648],[487:490 "CODON" 648] -0.52 [42:43 "MATCH_STATE" -181],[490:493 "CODON" -181] 2.18 [43:44 "MATCH_STATE" 756],[493:496 "CODON" 756] 3.16 [44:45 "MATCH_STATE" 1095],[496:499 "CODON" 1095] 2.99 [45:46 "MATCH_STATE" 1035],[499:502 "CODON" 1035] 2.44 [46:47 "MATCH_STATE" 846],[502:505 "CODON" 846] 3.94 [47:48 "MATCH_STATE" 1367],[505:508 "CODON" 1367] 3.22 [48:49 "MATCH_STATE" 1115],[508:511 "CODON" 1115] 1.24 [49:50 "MATCH_STATE" 429],[511:514 "CODON" 429] 3.92 [50:51 "MATCH_STATE" 1359],[514:517 "CODON" 1359] 1.09 [51:52 "MATCH_STATE" 379],[517:520 "CODON" 379] 1.85 [52:53 "MATCH_STATE" 640],[520:523 "CODON" 640] 1.41 [53:54 "MATCH_STATE" 489],[523:526 "CODON" 489] 1.56 [54:55 "MATCH_STATE" 539],[526:529 "CODON" 539] 1.20 [55:56 "MATCH_STATE" 416],[529:532 "CODON" 416] -0.02 [56:57 "MATCH_STATE" -6],[532:535 "CODON" -6] 0.94 [57:58 "MATCH_STATE" 325],[535:538 "CODON" 325] 2.25 [58:59 "MATCH_STATE" 781],[538:541 "CODON" 781] -0.21 [59:60 "MATCH_STATE" -73],[541:544 "CODON" -73] 1.52 [60:61 "MATCH_STATE" 526],[544:547 "CODON" 526] -0.86 [61:62 "MATCH_STATE" -297],[547:550 "CODON" -297] -2.45 [62:63 "DELETE_STATE" -848],[550:550 "INSERT" -848] -0.46 [63:64 "MATCH_STATE" -159],[550:553 "CODON" -159] -0.37 [64:65 "MATCH_STATE" -127],[553:556 "CODON" -127] -0.68 [65:66 "MATCH_STATE" -236],[556:559 "CODON" -236] 0.88 [66:67 "MATCH_STATE" 304],[559:562 "CODON" 304] 0.64 [67:68 "MATCH_STATE" 223],[562:565 "CODON" 223] 1.19 [68:69 "MATCH_STATE" 412],[565:568 "CODON" 412] 1.63 [69:70 "MATCH_STATE" 565],[568:571 "CODON" 565] 2.67 [70:71 "MATCH_STATE" 925],[571:574 "CODON" 925] 1.82 [71:72 "MATCH_STATE" 630],[574:577 "CODON" 630] 0.16 [72:73 "MATCH_STATE" 55],[577:580 "CODON" 55] 0.81 [73:74 "MATCH_STATE" 282],[580:583 "CODON" 282] 0.28 [74:75 "MATCH_STATE" 98],[583:586 "CODON" 98] 2.67 [75:76 "MATCH_STATE" 926],[586:589 "CODON" 926] -0.06 [76:0 "END" -20],[589:589 "END" -20] // >Results for SEED vs SAHNRNPH (forward) [4] estwisedb output Score 69.54 bits over entire alignment. This will be different from per-alignment scores. See manual for details For computer parsable output, try estwisedb -help or read the manual Scores as bits over a synchronous coding model Alignment 1 Score 69.60 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF LF+G+L + +T+E LK++F++ G+IV++ +++D ++T++S+GF+F LFIGGLDYRTTDESLKQHFEQWGEIVDVVVMKD-----PKTKRSRGFGF SAHNRNPH 148 ctaggtgtaaaggtcacctgctggagggggaag caaaatagtgt tttggtaagccaactaaataaggattattttaa cacagcggtgt atttagctaatcgcagattaagtaattggtggc taggggagtgc SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV +++ ++A + ++++GR+++ ITYSRAHMVDDAQN-ARPHKVDGRVVEP SAHNRNPH 280 aattagcaggggca gcccagggcgggc tcacgcattaacaa cgcaataggttac atccaatggtttgt tcacatttttggg // -9.89 [-1:0 "MATCH_STATE" -3429],[146:149 "CODON" -3429] 3.14 [0:1 "MATCH_STATE" 1088],[149:152 "CODON" 1088] 2.22 [1:2 "MATCH_STATE" 769],[152:155 "CODON" 769] 2.39 [2:3 "MATCH_STATE" 827],[155:158 "CODON" 827] 1.72 [3:4 "MATCH_STATE" 595],[158:161 "CODON" 595] 2.86 [4:5 "MATCH_STATE" 992],[161:164 "CODON" 992] -0.47 [5:6 "MATCH_STATE" -162],[164:167 "CODON" -162] 1.89 [6:7 "MATCH_STATE" 654],[167:170 "CODON" 654] -1.86 [7:8 "MATCH_STATE" -643],[170:173 "CODON" -643] 1.65 [8:9 "MATCH_STATE" 572],[173:176 "CODON" 572] 2.86 [9:10 "MATCH_STATE" 992],[176:179 "CODON" 992] 1.02 [10:11 "MATCH_STATE" 355],[179:182 "CODON" 355] 1.97 [11:12 "MATCH_STATE" 683],[182:185 "CODON" 683] -0.26 [12:13 "MATCH_STATE" -90],[185:188 "CODON" -90] 2.74 [13:14 "MATCH_STATE" 951],[188:191 "CODON" 951] 1.70 [14:15 "MATCH_STATE" 589],[191:194 "CODON" 589] 1.43 [15:16 "MATCH_STATE" 494],[194:197 "CODON" 494] 0.82 [16:17 "MATCH_STATE" 284],[197:200 "CODON" 284] 4.13 [17:18 "MATCH_STATE" 1430],[200:203 "CODON" 1430] 0.90 [18:19 "MATCH_STATE" 311],[203:206 "CODON" 311] 1.64 [19:20 "MATCH_STATE" 568],[206:209 "CODON" 568] -0.35 [20:21 "MATCH_STATE" -121],[209:212 "CODON" -121] 3.43 [21:22 "MATCH_STATE" 1188],[212:215 "CODON" 1188] 0.83 [22:23 "MATCH_STATE" 288],[215:218 "CODON" 288] 2.63 [23:24 "MATCH_STATE" 913],[218:221 "CODON" 913] 1.20 [24:25 "MATCH_STATE" 417],[221:224 "CODON" 417] 1.10 [25:26 "MATCH_STATE" 382],[224:227 "CODON" 382] 1.47 [26:27 "MATCH_STATE" 509],[227:230 "CODON" 509] -0.13 [27:28 "MATCH_STATE" -45],[230:233 "CODON" -45] 1.87 [28:29 "MATCH_STATE" 649],[233:236 "CODON" 649] 1.87 [29:30 "MATCH_STATE" 647],[236:239 "CODON" 647] 0.93 [30:31 "MATCH_STATE" 324],[239:242 "CODON" 324] 2.89 [31:32 "MATCH_STATE" 1001],[242:245 "CODON" 1001] -0.11 [32:33 "DELETE_STATE" -38],[245:245 "INSERT" -38] -0.07 [33:34 "DELETE_STATE" -24],[245:245 "INSERT" -24] -0.05 [34:35 "DELETE_STATE" -18],[245:245 "INSERT" -18] -0.05 [35:36 "DELETE_STATE" -18],[245:245 "INSERT" -18] -0.05 [36:37 "DELETE_STATE" -19],[245:245 "INSERT" -19] 0.25 [37:38 "MATCH_STATE" 85],[245:248 "CODON" 85] 0.03 [38:39 "MATCH_STATE" 12],[248:251 "CODON" 12] 2.90 [39:40 "MATCH_STATE" 1005],[251:254 "CODON" 1005] 1.30 [40:41 "MATCH_STATE" 450],[254:257 "CODON" 450] 1.93 [41:42 "MATCH_STATE" 669],[257:260 "CODON" 669] 2.19 [42:43 "MATCH_STATE" 758],[260:263 "CODON" 758] 2.18 [43:44 "MATCH_STATE" 757],[263:266 "CODON" 757] 3.16 [44:45 "MATCH_STATE" 1094],[266:269 "CODON" 1094] 2.99 [45:46 "MATCH_STATE" 1035],[269:272 "CODON" 1035] 2.26 [46:47 "MATCH_STATE" 784],[272:275 "CODON" 784] 3.94 [47:48 "MATCH_STATE" 1367],[275:278 "CODON" 1367] 1.77 [48:49 "MATCH_STATE" 613],[278:281 "CODON" 613] 1.24 [49:50 "MATCH_STATE" 429],[281:284 "CODON" 429] 2.82 [50:51 "MATCH_STATE" 977],[284:287 "CODON" 977] -0.68 [51:52 "MATCH_STATE" -236],[287:290 "CODON" -236] -0.07 [52:53 "MATCH_STATE" -23],[290:293 "CODON" -23] -1.03 [53:54 "MATCH_STATE" -358],[293:296 "CODON" -358] -0.88 [54:55 "MATCH_STATE" -305],[296:299 "CODON" -305] -1.13 [55:56 "MATCH_STATE" -390],[299:302 "CODON" -390] -0.02 [56:57 "MATCH_STATE" -6],[302:305 "CODON" -6] 0.94 [57:58 "MATCH_STATE" 325],[305:308 "CODON" 325] 0.48 [58:59 "MATCH_STATE" 168],[308:311 "CODON" 168] 3.17 [59:60 "MATCH_STATE" 1099],[311:314 "CODON" 1099] -0.93 [60:61 "MATCH_STATE" -322],[314:317 "CODON" -322] 0.06 [61:62 "MATCH_STATE" 22],[317:320 "CODON" 22] -2.45 [62:63 "DELETE_STATE" -848],[320:320 "INSERT" -848] -0.51 [63:64 "MATCH_STATE" -177],[320:323 "CODON" -177] -0.99 [64:65 "MATCH_STATE" -344],[323:326 "CODON" -344] -4.60 [65:66 "MATCH_STATE" -1593],[326:329 "CODON" -1593] 0.88 [66:67 "MATCH_STATE" 304],[329:332 "CODON" 304] 0.94 [67:68 "MATCH_STATE" 327],[332:335 "CODON" 327] 1.20 [68:69 "MATCH_STATE" 416],[335:338 "CODON" 416] 0.84 [69:70 "MATCH_STATE" 292],[338:341 "CODON" 292] 2.67 [70:71 "MATCH_STATE" 925],[341:344 "CODON" 925] 2.40 [71:72 "MATCH_STATE" 833],[344:347 "CODON" 833] 0.35 [72:73 "MATCH_STATE" 123],[347:350 "CODON" 123] 1.10 [73:74 "MATCH_STATE" 382],[350:353 "CODON" 382] 0.28 [74:75 "MATCH_STATE" 98],[353:356 "CODON" 98] -1.42 [75:76 "MATCH_STATE" -492],[356:359 "CODON" -492] -0.06 [76:0 "END" -20],[359:359 "END" -20] // wise-2.4.1/src/test/basic_cdna.out0000644000175000001440000004040510076537057016433 0ustar philippusersestwise $Name: wise2-4-1 $ (unreleased release) This program is freely distributed under a GPL. See source directory Copyright (c) GRL limited: portions of the code are from separate copyrights Query protein: roa1_drome Comp Matrix: BLOSUM62.bla Gap open: 12 Gap extension: 2 Start/End default Target Sequence HSHNCPA1 Strand: both Codon Table: codon.table Subs error: 1e-05 Indel error: 1e-05 Algorithm 333 estwise output Score 123.64 bits over entire alignment Score reported as bits over a synchronised coding sequence model roa1_drome 23 KLFVGALKDDHDEQSIRDYFQHFGNIVDINIVIDKETGKKRGFAFVEFD K+FVG +K+D +E +RDYF+ +G I I I+ D+ +GKKRGFA+V FD KIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAxVTFD HSHNCPA1 14 aatgggaaggaggcccagttgctgaaggagaaagcgagaaagtgtgatg atttggtaaacaaaatgaataaagatattattcaggggaaggtcttcta gatttctaactaatcaatttagtaatagtacgtcactcgagctcNactc roa1_drome 72 DYDPVDKVVLQKQHQLNGKMVDVKKALPKQNDQQGGGGGRGGPGGRAGG D+D VDK+V+QK H +NG +V+KAL KQ RG G DHDSVDKIVIQKYHTVNGHNCEVRKALSKQEMASASSSQRGRSGS---- HSHNCPA1 161 gcgtggaagacatcagagcatggaagctacgagagttacagcagt aaactaatttaaaactagaagatgactcaaatcgcccgagggggc ctccgtgtctgacttgtccctataacgagaggtttaccaatattt roa1_drome 121 NRGNMGGGNYGNQNGGGNWNNGGN GN+GGG G G N+ GGN --GNFGGGRGGGFGGNDNFGRGGN HSHNCPA1 296 gatgggcgggtggagatgcgga gatgggggggtggaaatgggga actttttattctgtcccttaac // Bits Query start end Target start end idels 123.64 roa1_drome 23 144 HSHNCPA1 14 361 0 // 2.29 [21:22 "MATCH_STATE" 794],[12:15 "CODON" 794] 1.00 [22:23 "MATCH_STATE" 345],[15:18 "CODON" 345] 3.06 [23:24 "MATCH_STATE" 1061],[18:21 "CODON" 1061] 1.96 [24:25 "MATCH_STATE" 681],[21:24 "CODON" 681] 2.63 [25:26 "MATCH_STATE" 910],[24:27 "CODON" 910] -0.19 [26:27 "MATCH_STATE" -66],[27:30 "CODON" -66] 1.00 [27:28 "MATCH_STATE" 345],[30:33 "CODON" 345] 2.20 [28:29 "MATCH_STATE" 762],[33:36 "CODON" 762] 0.87 [29:30 "MATCH_STATE" 302],[36:39 "CODON" 302] 2.87 [30:31 "MATCH_STATE" 995],[39:42 "CODON" 995] -1.34 [31:32 "MATCH_STATE" -463],[42:45 "CODON" -463] 0.87 [32:33 "MATCH_STATE" 302],[45:48 "CODON" 302] 2.33 [33:34 "MATCH_STATE" 807],[48:51 "CODON" 807] -0.11 [34:35 "MATCH_STATE" -39],[51:54 "CODON" -39] -0.73 [35:36 "MATCH_STATE" -252],[54:57 "CODON" -252] 1.05 [36:37 "MATCH_STATE" 364],[57:60 "CODON" 364] 2.48 [37:38 "MATCH_STATE" 860],[60:63 "CODON" 860] 2.87 [38:39 "MATCH_STATE" 995],[63:66 "CODON" 995] 3.40 [39:40 "MATCH_STATE" 1178],[66:69 "CODON" 1178] 3.06 [40:41 "MATCH_STATE" 1061],[69:72 "CODON" 1061] 0.88 [41:42 "MATCH_STATE" 306],[72:75 "CODON" 306] -0.33 [42:43 "MATCH_STATE" -116],[75:78 "CODON" -116] 1.56 [43:44 "MATCH_STATE" 542],[78:81 "CODON" 542] 2.63 [44:45 "MATCH_STATE" 910],[81:84 "CODON" 910] -0.20 [45:46 "MATCH_STATE" -69],[84:87 "CODON" -69] 2.05 [46:47 "MATCH_STATE" 711],[87:90 "CODON" 711] -1.03 [47:48 "MATCH_STATE" -358],[90:93 "CODON" -358] -1.63 [48:49 "MATCH_STATE" -564],[93:96 "CODON" -564] 2.05 [49:50 "MATCH_STATE" 711],[96:99 "CODON" 711] -0.20 [50:51 "MATCH_STATE" -69],[99:102 "CODON" -69] 2.05 [51:52 "MATCH_STATE" 711],[102:105 "CODON" 711] 0.46 [52:53 "MATCH_STATE" 161],[105:108 "CODON" 161] -0.45 [53:54 "MATCH_STATE" -155],[108:111 "CODON" -155] 2.87 [54:55 "MATCH_STATE" 995],[111:114 "CODON" 995] 0.70 [55:56 "MATCH_STATE" 242],[114:117 "CODON" 242] -1.17 [56:57 "MATCH_STATE" -405],[117:120 "CODON" -405] 0.32 [57:58 "MATCH_STATE" 111],[120:123 "CODON" 111] 2.63 [58:59 "MATCH_STATE" 910],[123:126 "CODON" 910] 2.20 [59:60 "MATCH_STATE" 762],[126:129 "CODON" 762] 2.20 [60:61 "MATCH_STATE" 762],[129:132 "CODON" 762] 2.48 [61:62 "MATCH_STATE" 860],[132:135 "CODON" 860] 2.63 [62:63 "MATCH_STATE" 910],[135:138 "CODON" 910] 3.06 [63:64 "MATCH_STATE" 1061],[138:141 "CODON" 1061] 1.81 [64:65 "MATCH_STATE" 626],[141:144 "CODON" 626] 2.41 [65:66 "MATCH_STATE" 834],[144:147 "CODON" 834] 1.96 [66:67 "MATCH_STATE" 681],[147:150 "CODON" 681] -0.67 [67:68 "MATCH_STATE" -232],[150:153 "CODON" -232] 3.06 [68:69 "MATCH_STATE" 1061],[153:156 "CODON" 1061] 2.87 [69:70 "MATCH_STATE" 995],[156:159 "CODON" 995] 2.87 [70:71 "MATCH_STATE" 995],[159:162 "CODON" 995] 0.90 [71:72 "MATCH_STATE" 312],[162:165 "CODON" 312] 2.87 [72:73 "MATCH_STATE" 995],[165:168 "CODON" 995] -0.72 [73:74 "MATCH_STATE" -251],[168:171 "CODON" -251] 1.96 [74:75 "MATCH_STATE" 681],[171:174 "CODON" 681] 2.87 [75:76 "MATCH_STATE" 995],[174:177 "CODON" 995] 2.20 [76:77 "MATCH_STATE" 762],[177:180 "CODON" 762] 1.47 [77:78 "MATCH_STATE" 508],[180:183 "CODON" 508] 1.96 [78:79 "MATCH_STATE" 681],[183:186 "CODON" 681] 1.00 [79:80 "MATCH_STATE" 345],[186:189 "CODON" 345] 2.38 [80:81 "MATCH_STATE" 826],[189:192 "CODON" 826] 2.20 [81:82 "MATCH_STATE" 762],[192:195 "CODON" 762] -0.61 [82:83 "MATCH_STATE" -213],[195:198 "CODON" -213] 3.66 [83:84 "MATCH_STATE" 1269],[198:201 "CODON" 1269] -0.61 [84:85 "MATCH_STATE" -213],[201:204 "CODON" -213] 0.50 [85:86 "MATCH_STATE" 172],[204:207 "CODON" 172] 2.80 [86:87 "MATCH_STATE" 970],[207:210 "CODON" 970] 2.63 [87:88 "MATCH_STATE" 910],[210:213 "CODON" 910] -0.80 [88:89 "MATCH_STATE" -277],[213:216 "CODON" -277] -0.94 [89:90 "MATCH_STATE" -326],[216:219 "CODON" -326] -0.53 [90:91 "MATCH_STATE" -184],[219:222 "CODON" -184] 0.87 [91:92 "MATCH_STATE" 302],[222:225 "CODON" 302] 1.96 [92:93 "MATCH_STATE" 681],[225:228 "CODON" 681] 0.70 [93:94 "MATCH_STATE" 242],[228:231 "CODON" 242] 2.20 [94:95 "MATCH_STATE" 762],[231:234 "CODON" 762] 1.81 [95:96 "MATCH_STATE" 626],[234:237 "CODON" 626] 2.00 [96:97 "MATCH_STATE" 692],[237:240 "CODON" 692] -0.72 [97:98 "MATCH_STATE" -251],[240:243 "CODON" -251] 2.20 [98:99 "MATCH_STATE" 762],[243:246 "CODON" 762] 2.38 [99:100 "MATCH_STATE" 826],[246:249 "CODON" 826] -0.20 [100:101 "MATCH_STATE" -69],[249:252 "CODON" -69] -1.63 [101:102 "MATCH_STATE" -564],[252:255 "CODON" -564] -0.61 [102:103 "MATCH_STATE" -213],[255:258 "CODON" -213] -0.11 [103:104 "MATCH_STATE" -39],[258:261 "CODON" -39] -0.37 [104:105 "MATCH_STATE" -129],[261:264 "CODON" -129] -0.37 [105:106 "MATCH_STATE" -129],[264:267 "CODON" -129] -0.37 [106:107 "MATCH_STATE" -129],[267:270 "CODON" -129] -0.37 [107:108 "MATCH_STATE" -129],[270:273 "CODON" -129] -1.37 [108:109 "MATCH_STATE" -476],[273:276 "CODON" -476] 2.48 [109:110 "MATCH_STATE" 860],[276:279 "CODON" 860] 2.63 [110:111 "MATCH_STATE" 910],[279:282 "CODON" 910] -1.37 [111:112 "MATCH_STATE" -476],[282:285 "CODON" -476] -0.72 [112:113 "MATCH_STATE" -251],[285:288 "CODON" -251] 2.63 [113:114 "MATCH_STATE" 910],[288:291 "CODON" 910] -0.37 [114:115 "MATCH_STATE" -129],[291:294 "CODON" -129] -5.00 [115:116 "DELETE_STATE" -1732],[294:294 "INSERT" -1732] -1.00 [116:117 "DELETE_STATE" -346],[294:294 "INSERT" -346] -1.00 [117:118 "DELETE_STATE" -346],[294:294 "INSERT" -346] -1.00 [118:119 "DELETE_STATE" -346],[294:294 "INSERT" -346] -1.00 [119:120 "DELETE_STATE" -346],[294:294 "INSERT" -346] -1.00 [120:121 "DELETE_STATE" -346],[294:294 "INSERT" -346] 1.72 [121:122 "MATCH_STATE" 596],[294:297 "CODON" 596] 2.80 [122:123 "MATCH_STATE" 970],[297:300 "CODON" 970] 0.06 [123:124 "MATCH_STATE" 20],[300:303 "CODON" 20] 2.63 [124:125 "MATCH_STATE" 910],[303:306 "CODON" 910] 2.63 [125:126 "MATCH_STATE" 910],[306:309 "CODON" 910] 2.63 [126:127 "MATCH_STATE" 910],[309:312 "CODON" 910] -0.20 [127:128 "MATCH_STATE" -69],[312:315 "CODON" -69] -1.60 [128:129 "MATCH_STATE" -554],[315:318 "CODON" -554] 2.63 [129:130 "MATCH_STATE" 910],[318:321 "CODON" 910] -0.20 [130:131 "MATCH_STATE" -69],[321:324 "CODON" -69] -1.61 [131:132 "MATCH_STATE" -559],[324:327 "CODON" -559] -0.20 [132:133 "MATCH_STATE" -69],[327:330 "CODON" -69] 2.63 [133:134 "MATCH_STATE" 910],[330:333 "CODON" 910] -0.37 [134:135 "MATCH_STATE" -129],[333:336 "CODON" -129] -0.87 [135:136 "MATCH_STATE" -302],[336:339 "CODON" -302] 2.80 [136:137 "MATCH_STATE" 970],[339:342 "CODON" 970] 0.47 [137:138 "MATCH_STATE" 163],[342:345 "CODON" 163] -0.20 [138:139 "MATCH_STATE" -69],[345:348 "CODON" -69] -0.20 [139:140 "MATCH_STATE" -69],[348:351 "CODON" -69] 2.63 [140:141 "MATCH_STATE" 910],[351:354 "CODON" 910] 2.63 [141:142 "MATCH_STATE" 910],[354:357 "CODON" 910] 2.80 [142:143 "MATCH_STATE" 970],[357:360 "CODON" 970] 0.00 [143:0 "END" 0],[360:360 "END" 0] // Score 42852 Position i:[21] j:[12] State:[3] Score: 0 Position i:[22] j:[15] State:[0] Score: 794 Position i:[23] j:[18] State:[0] Score: 345 Position i:[24] j:[21] State:[0] Score: 1061 Position i:[25] j:[24] State:[0] Score: 681 Position i:[26] j:[27] State:[0] Score: 910 Position i:[27] j:[30] State:[0] Score: -66 Position i:[28] j:[33] State:[0] Score: 345 Position i:[29] j:[36] State:[0] Score: 762 Position i:[30] j:[39] State:[0] Score: 302 Position i:[31] j:[42] State:[0] Score: 995 Position i:[32] j:[45] State:[0] Score: -463 Position i:[33] j:[48] State:[0] Score: 302 Position i:[34] j:[51] State:[0] Score: 807 Position i:[35] j:[54] State:[0] Score: -39 Position i:[36] j:[57] State:[0] Score: -252 Position i:[37] j:[60] State:[0] Score: 364 Position i:[38] j:[63] State:[0] Score: 860 Position i:[39] j:[66] State:[0] Score: 995 Position i:[40] j:[69] State:[0] Score: 1178 Position i:[41] j:[72] State:[0] Score: 1061 Position i:[42] j:[75] State:[0] Score: 306 Position i:[43] j:[78] State:[0] Score: -116 Position i:[44] j:[81] State:[0] Score: 542 Position i:[45] j:[84] State:[0] Score: 910 Position i:[46] j:[87] State:[0] Score: -69 Position i:[47] j:[90] State:[0] Score: 711 Position i:[48] j:[93] State:[0] Score: -358 Position i:[49] j:[96] State:[0] Score: -564 Position i:[50] j:[99] State:[0] Score: 711 Position i:[51] j:[102] State:[0] Score: -69 Position i:[52] j:[105] State:[0] Score: 711 Position i:[53] j:[108] State:[0] Score: 161 Position i:[54] j:[111] State:[0] Score: -155 Position i:[55] j:[114] State:[0] Score: 995 Position i:[56] j:[117] State:[0] Score: 242 Position i:[57] j:[120] State:[0] Score: -405 Position i:[58] j:[123] State:[0] Score: 111 Position i:[59] j:[126] State:[0] Score: 910 Position i:[60] j:[129] State:[0] Score: 762 Position i:[61] j:[132] State:[0] Score: 762 Position i:[62] j:[135] State:[0] Score: 860 Position i:[63] j:[138] State:[0] Score: 910 Position i:[64] j:[141] State:[0] Score: 1061 Position i:[65] j:[144] State:[0] Score: 626 Position i:[66] j:[147] State:[0] Score: 834 Position i:[67] j:[150] State:[0] Score: 681 Position i:[68] j:[153] State:[0] Score: -232 Position i:[69] j:[156] State:[0] Score: 1061 Position i:[70] j:[159] State:[0] Score: 995 Position i:[71] j:[162] State:[0] Score: 995 Position i:[72] j:[165] State:[0] Score: 312 Position i:[73] j:[168] State:[0] Score: 995 Position i:[74] j:[171] State:[0] Score: -251 Position i:[75] j:[174] State:[0] Score: 681 Position i:[76] j:[177] State:[0] Score: 995 Position i:[77] j:[180] State:[0] Score: 762 Position i:[78] j:[183] State:[0] Score: 508 Position i:[79] j:[186] State:[0] Score: 681 Position i:[80] j:[189] State:[0] Score: 345 Position i:[81] j:[192] State:[0] Score: 826 Position i:[82] j:[195] State:[0] Score: 762 Position i:[83] j:[198] State:[0] Score: -213 Position i:[84] j:[201] State:[0] Score: 1269 Position i:[85] j:[204] State:[0] Score: -213 Position i:[86] j:[207] State:[0] Score: 172 Position i:[87] j:[210] State:[0] Score: 970 Position i:[88] j:[213] State:[0] Score: 910 Position i:[89] j:[216] State:[0] Score: -277 Position i:[90] j:[219] State:[0] Score: -326 Position i:[91] j:[222] State:[0] Score: -184 Position i:[92] j:[225] State:[0] Score: 302 Position i:[93] j:[228] State:[0] Score: 681 Position i:[94] j:[231] State:[0] Score: 242 Position i:[95] j:[234] State:[0] Score: 762 Position i:[96] j:[237] State:[0] Score: 626 Position i:[97] j:[240] State:[0] Score: 692 Position i:[98] j:[243] State:[0] Score: -251 Position i:[99] j:[246] State:[0] Score: 762 Position i:[100] j:[249] State:[0] Score: 826 Position i:[101] j:[252] State:[0] Score: -69 Position i:[102] j:[255] State:[0] Score: -564 Position i:[103] j:[258] State:[0] Score: -213 Position i:[104] j:[261] State:[0] Score: -39 Position i:[105] j:[264] State:[0] Score: -129 Position i:[106] j:[267] State:[0] Score: -129 Position i:[107] j:[270] State:[0] Score: -129 Position i:[108] j:[273] State:[0] Score: -129 Position i:[109] j:[276] State:[0] Score: -476 Position i:[110] j:[279] State:[0] Score: 860 Position i:[111] j:[282] State:[0] Score: 910 Position i:[112] j:[285] State:[0] Score: -476 Position i:[113] j:[288] State:[0] Score: -251 Position i:[114] j:[291] State:[0] Score: 910 Position i:[115] j:[294] State:[0] Score: -129 Position i:[116] j:[294] State:[2] Score: -1732 Position i:[117] j:[294] State:[2] Score: -346 Position i:[118] j:[294] State:[2] Score: -346 Position i:[119] j:[294] State:[2] Score: -346 Position i:[120] j:[294] State:[2] Score: -346 Position i:[121] j:[294] State:[2] Score: -346 Position i:[122] j:[297] State:[0] Score: 596 Position i:[123] j:[300] State:[0] Score: 970 Position i:[124] j:[303] State:[0] Score: 20 Position i:[125] j:[306] State:[0] Score: 910 Position i:[126] j:[309] State:[0] Score: 910 Position i:[127] j:[312] State:[0] Score: 910 Position i:[128] j:[315] State:[0] Score: -69 Position i:[129] j:[318] State:[0] Score: -554 Position i:[130] j:[321] State:[0] Score: 910 Position i:[131] j:[324] State:[0] Score: -69 Position i:[132] j:[327] State:[0] Score: -559 Position i:[133] j:[330] State:[0] Score: -69 Position i:[134] j:[333] State:[0] Score: 910 Position i:[135] j:[336] State:[0] Score: -129 Position i:[136] j:[339] State:[0] Score: -302 Position i:[137] j:[342] State:[0] Score: 970 Position i:[138] j:[345] State:[0] Score: 163 Position i:[139] j:[348] State:[0] Score: -69 Position i:[140] j:[351] State:[0] Score: -69 Position i:[141] j:[354] State:[0] Score: 910 Position i:[142] j:[357] State:[0] Score: 910 Position i:[143] j:[360] State:[0] Score: 970 Position i:[0] j:[360] State:[4] Score: 0 // estwise output Score 13.30 bits over entire alignment Score reported as bits over a synchronised coding sequence model roa1_drome 33 HDE-QSIRDYFQHFG HD QS++++F FG HDHHQSFQNHFDLFG HSHNCPA1 -317 cgcccatcactgctg aaaaagtaaatattg ccccatcgccccctc // Bits Query start end Target start end idels 13.30 roa1_drome 33 46 HSHNCPA1 317 271 0 // 3.75 [31:32 "MATCH_STATE" 1301],[97:100 "CODON" 1301] 2.87 [32:33 "MATCH_STATE" 995],[100:103 "CODON" 995] -0.17 [33:34 "MATCH_STATE" -59],[103:106 "CODON" -59] -5.00 [34:34 "INSERT_STATE" -1732],[106:109 "CODON" -1732] 1.48 [34:35 "MATCH_STATE" 512],[109:112 "CODON" 512] 1.77 [35:36 "MATCH_STATE" 613],[112:115 "CODON" 613] 0.05 [36:37 "MATCH_STATE" 17],[115:118 "CODON" 17] 0.48 [37:38 "MATCH_STATE" 167],[118:121 "CODON" 167] 0.37 [38:39 "MATCH_STATE" 128],[121:124 "CODON" 128] 0.90 [39:40 "MATCH_STATE" 312],[124:127 "CODON" 312] 3.06 [40:41 "MATCH_STATE" 1061],[127:130 "CODON" 1061] -0.11 [41:42 "MATCH_STATE" -39],[130:133 "CODON" -39] -1.84 [42:43 "MATCH_STATE" -636],[133:136 "CODON" -636] 3.06 [43:44 "MATCH_STATE" 1061],[136:139 "CODON" 1061] 2.63 [44:45 "MATCH_STATE" 910],[139:142 "CODON" 910] 0.00 [45:0 "END" 0],[142:142 "END" 0] // Score 4611 Position i:[31] j:[97] State:[3] Score: 0 Position i:[32] j:[100] State:[0] Score: 1301 Position i:[33] j:[103] State:[0] Score: 995 Position i:[34] j:[106] State:[0] Score: -59 Position i:[34] j:[109] State:[1] Score: -1732 Position i:[35] j:[112] State:[0] Score: 512 Position i:[36] j:[115] State:[0] Score: 613 Position i:[37] j:[118] State:[0] Score: 17 Position i:[38] j:[121] State:[0] Score: 167 Position i:[39] j:[124] State:[0] Score: 128 Position i:[40] j:[127] State:[0] Score: 312 Position i:[41] j:[130] State:[0] Score: 1061 Position i:[42] j:[133] State:[0] Score: -39 Position i:[43] j:[136] State:[0] Score: -636 Position i:[44] j:[139] State:[0] Score: 1061 Position i:[45] j:[142] State:[0] Score: 910 Position i:[0] j:[142] State:[4] Score: 0 // wise-2.4.1/src/test/testman.pl0000755000175000001440000000500107313404553015632 0ustar philippusers#!/usr/local/bin/perl if( $opt eq 'cf' ) { $conf = shift; $ENV{'WISECONFIGDIR'} = $conf; } # # Reads in test files with test name, do and diff directives for each unit # @testarr = &read_all_testset(\*STDIN); open(RES,">test.results"); $error = &do_all_testset(\@testarr,\*RES,\*STDERR); if( $error == 1 ) { print STDERR "Tests failed\nPLEASE: email ewan birney (birney\@sanger.ac.uk) with the test.results file\n\n"; } else { print STDERR "Tests passed\n"; } sub do_all_testset { my $testarr = shift; my $results_file = shift; my $talk_file = shift; my @array; my $error = 0; @array = @{$testarr}; foreach $test (@array) { if( &do_testset($test,$results_file,$talk_file) == 1 ) { $error = 1; } } return $error; } sub do_testset { my $test = shift; my $result_file = shift; my $talk_file = shift; my ($name,$do,$diff,$desc); my $error =0; $name = $test->{'name'}; $do = $test->{'do'}; $do = "../bin/$do"; $diff = $test->{'diff'}; $desc = $test->{'desc'}; if( $talk_file ) { print $talk_file ">>> Doing $name $desc\n>>> Calling [$do]\n"; } if( ($exit = system($do)) != 0 ) { print $talk_file ">>> Bad exit status - $exit (system - $!)\n"; $error =1; } else { open(DIFF,"diff $diff|"); while() { chop; if( /^[><].*wise.*\d/ ) { next; } if( /^[><].*\$[nN]ame\$/ ) { next; } if( /unreleased/ ) { next; } if( /^[<>]/ ) { print $result_file "Error in $name: $_\n"; $error =1; } } } if( $talk_file ) { if( $error ) { print $talk_file ">>> $name ... Failed\n"; } else { print $talk_file ">>> $name ... Passed\n"; } } return $error; } sub read_all_testset { my $file = shift; my @array; my $h; while( ($h = &read_testset($file)) ) { push(@array,$h); } return @array; } sub read_testset { my $file = shift; my $hash = {}; my ($name,$do,$diff,$desc); while(<$file>) { chop; /^#/ && next; /^\/\// && last; /^name\s+(\S+)/ && do { $name = $1; next; }; /^desc\s+(.*)$/ && do { $desc = $1; next; }; /^do\s+(.*)$/ && do { $do = $1; next; }; /^diff\s+(\S+\s+\S+)/ && do { $diff = $1; next; }; /^\s+$/ && next; warn("Could not understand $_"); } if( defined $name && defined $do && defined $diff) { $hash->{'name'} = $name; $hash->{'do'} = $do; $hash->{'diff'} = $diff; $hash->{'desc'} = $desc; return $hash; } else { return undef; } } wise-2.4.1/src/test/rrm.HMM0000755000175000001440000007040607313404553015000 0ustar philippusersHMMER2.0 NAME SEED DESC LENG 77 ALPH Amino RF no CS no COM hmmbuild -F HMM SEED COM hmmcalibrate --seed 0 HMM NSEQ 90 DATE Tue Jul 28 13:08:41 1998 XT -8455 -4 -1000 -1000 -8455 -4 -8455 -4 NULT -4 -8455 NULE 595 -1558 85 338 -294 453 -1158 197 249 902 -1085 -142 -21 -313 45 531 201 384 -1998 -644 EVD -46.934628 0.231361 HMM A C D E F G H I K L M N P Q R S T V W Y m->m m->i m->d i->m i->i d->m d->d b->m m->e -16 * -6492 1 -1085 390 -8597 -8255 -5793 -8424 -8268 2395 -8202 2081 -1198 -8080 -8115 -8020 -8297 -7789 -5911 1826 -7524 -7140 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -10 -11651 -12693 -894 -1115 -701 -1378 -16 * 2 -2141 -3785 -6293 -2252 3225 -2495 -727 -639 -2421 -540 -675 -5146 -5554 -4879 -1183 -2536 -1929 266 75 3171 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -10 -11651 -12693 -894 -1115 -701 -1378 * * 3 -2542 457 -8584 -8273 -6055 -8452 -8531 2304 -8255 -320 101 -8104 -8170 -8220 -8440 -7840 -5878 3144 -7857 -7333 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -10 -11651 -12694 -894 -1115 -701 -1378 * * 4 -1506 -5144 -1922 -559 -1843 2471 -3303 -2213 1099 -5160 -4233 371 -4738 -531 1150 168 497 -4766 -5327 -1476 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -10 -11651 -12694 -894 -1115 -701 -1378 * * 5 -3724 -5184 300 -3013 -1656 1803 -3353 -5245 -1569 -2686 -4276 3495 -1963 -1331 -1055 -1472 -3664 -4803 -5369 -2 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -10 -11652 -12694 -894 -1115 -701 -1378 * * 6 -1569 -6106 -8967 -8363 555 -8530 -7279 653 -8092 2953 -79 -8220 -7908 -1643 -7682 -7771 -6460 -60 -6191 -6283 - -151 -504 230 45 -380 399 101 -621 211 -470 -713 278 399 48 91 360 113 -364 -299 -254 - -188 -3120 -12694 -1602 -577 -701 -1378 * * 7 -410 -5129 -216 -2987 -1709 -957 689 -5188 -396 -5144 -4224 729 3053 -2862 -3409 354 1293 -1368 -5321 -4644 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 8 -3674 -5118 -992 638 420 -4652 175 -2051 404 -1039 -936 15 1755 167 146 -275 197 -1473 1889 1976 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 9 -408 -5134 2416 1299 -951 -67 -768 -1296 -2889 -1844 -4224 1083 -969 -1439 -1854 540 -315 -2305 -5320 -60 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 10 586 1804 -6294 -623 -1627 -1671 -4374 1029 -2223 -162 1172 -5147 -5554 -1870 -5058 -2327 1741 1687 -4242 686 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 11 -2134 -5144 845 -1187 -1652 -1667 -3303 -5216 -514 -795 -4233 1026 -1874 -543 -620 574 2956 -4766 -5327 -4644 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 12 -3671 -5144 1091 2489 -1652 -2235 -614 -2170 736 -1364 -4233 -448 -197 1030 -116 -639 -1350 -4766 1408 -424 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 13 -139 -5144 1643 2050 -5465 -1429 503 -5216 529 -3223 -1448 -672 -4738 1874 72 318 -2111 -4766 -5327 -4644 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 14 -122 -5142 2117 1852 -5462 -1085 -933 -2288 33 -526 -556 -741 -4738 1222 -3392 -175 -13 -2228 -371 -4643 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 15 -7174 -6526 -9596 -9028 -233 -9481 -8154 1634 -8870 2831 -817 -9215 -8388 -7557 -8326 -8917 -7014 708 -6536 -6798 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -29 -11652 -6305 -894 -1115 -701 -1378 * * 16 -654 -5013 -1860 728 725 -2293 -688 -1185 1801 -278 -4116 -790 -4754 -2884 1825 -463 -1785 -443 -228 1361 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11634 -12676 -894 -1115 -1520 -619 * * 17 156 -5127 2135 1476 -5448 -1490 -3286 -5199 301 -1956 -539 -894 -1058 1509 523 -467 301 -4749 -5310 -4627 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11634 -12676 -894 -1115 -355 -2197 * * 18 -49 -3785 -6295 -483 1590 -5504 919 1218 -2312 1809 48 -5147 -5554 -4880 -2068 -1575 -765 -208 -55 1201 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12695 -894 -1115 -701 -1378 * * 19 -2248 972 -6369 -5735 4218 -2298 -4439 -1757 -5331 -309 167 -5219 -5618 -4948 -5129 -4658 -1929 -3250 -4292 -388 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11653 -12695 -894 -1115 -701 -1378 * * 20 255 -5143 -3519 977 -5463 1064 -3304 -2365 1047 -2653 -4232 -150 -4738 556 446 1868 -1288 -2163 -5326 -1696 - -147 -500 232 42 -381 398 105 -627 212 -464 -721 275 393 45 95 360 117 -367 -295 -250 - -30 -6298 -12695 -2206 -352 -701 -1378 * * 21 -1055 -5144 363 870 -1814 -296 88 -2404 1818 -5160 -4233 811 1390 1737 -1608 -672 -664 -2375 -5327 -1696 - -149 -500 232 45 -377 398 105 -627 212 -467 -721 278 393 45 98 358 117 -370 -295 -250 - -101 -4064 -12695 -35 -5398 -701 -1378 * * 22 -394 1434 -6258 -2307 2972 -2527 18 850 -2195 -1152 -2991 -1854 -5549 -852 -5045 -2353 -3896 -124 -189 2915 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11653 -12695 -894 -1115 -701 -1378 * * 23 -686 -7736 -1743 -713 -8353 3518 -5401 -8354 -5879 -8207 -7642 -312 -61 -5106 -6911 -1501 -6164 -7685 -8411 -7292 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11653 -12695 -894 -1115 -701 -1378 * * 24 -1108 -5144 202 908 -1789 -9 -90 -1263 1341 -1905 -4233 -889 1908 170 58 -98 -240 -190 -5327 -4644 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11653 -12695 -894 -1115 -701 -1378 * * 25 -3958 -549 -6303 -1346 278 -5505 -4377 2725 -2224 -925 -753 -5151 -2077 -4885 -5062 -2366 -1362 2525 -4242 -488 - -147 -500 232 45 -381 398 105 -627 212 -466 -721 275 396 45 95 359 117 -370 -295 -250 - -181 -4722 -3786 -436 -1938 -701 -1378 * * 26 -1474 -441 -3586 1371 -4982 -2414 -3303 -26 1318 142 13 193 -4719 -534 -233 -510 590 1465 -5027 -4420 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -30 -11544 -6304 -894 -1115 -978 -1022 * * 27 -252 -5076 1198 1096 -5397 75 696 -1292 -903 -5092 -4165 1380 -4669 -1298 633 1609 -628 -2391 -5259 -408 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11580 -12622 -894 -1115 -146 -3376 * * 28 1071 1843 -6303 -5667 722 -2648 -4376 2229 -2340 233 704 -1807 -5555 -4884 -5062 -1098 -1943 1558 -4241 -1380 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11653 -12695 -894 -1115 -701 -1378 * * 29 -3674 -5121 814 520 -935 -4651 -961 -1319 1431 -346 -888 797 -4744 589 1471 -313 15 -53 -490 25 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11653 -12696 -894 -1115 -701 -1378 * * 30 -1650 -3784 -6302 -5666 -660 -5505 -883 2173 -2226 1326 2112 -5150 -2048 -4884 -1867 -1552 -1875 1962 -4242 -3899 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11654 -12696 -894 -1115 -701 -1378 * * 31 -1062 1014 -6187 -2356 294 -5488 -892 1176 270 -8 1951 -1951 1337 -4822 -158 103 -2109 1363 -4252 -389 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11654 -12696 -894 -1115 -701 -1378 * * 32 -2113 -485 -887 -660 -313 -2330 4 216 1012 -767 -210 897 318 -1357 1259 -194 786 -575 -384 1141 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -385 -11654 -2146 -894 -1115 -701 -1378 * * 33 -3418 -4896 3351 -318 -5215 -38 -454 -4967 425 -1472 -3988 1322 -4470 -2584 -1616 -1737 -3359 -1060 -5078 -4391 - -149 -500 233 43 -381 398 105 -627 210 -466 -710 275 396 48 96 359 117 -370 -295 -250 - -6445 -6022 -52 -1512 -623 -3426 -141 * * 34 -917 -1040 -1721 -1348 -308 -2080 3449 2217 -869 -531 -149 -1289 -2221 -942 -992 -1266 -896 -117 -927 -176 - -149 -500 233 43 -381 398 112 -626 210 -466 -721 275 394 49 96 359 117 -370 -295 -250 - -1925 -466 -7803 -81 -4198 -4405 -70 * * 35 -967 -1693 -1132 1236 -1732 -2031 -688 1976 1397 -1583 -848 -833 -2123 -387 -642 -1032 -898 -1161 -1951 1843 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -22 -7816 -8858 -894 -1115 -4785 -53 * * 36 -956 -2397 1003 1096 1076 -1925 -592 -2444 1146 -2406 -1491 1168 -2022 -138 -688 -841 883 -2011 -2588 1366 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -8245 -9287 -894 -1115 -4786 -53 * * 37 -1195 -2633 -1023 1475 -2947 -2157 1927 -2685 1620 -219 -1727 1082 -2254 -361 -866 -1079 1430 -2252 -2815 -2147 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -8564 -9606 -894 -1115 -4748 -55 * * 38 148 -2828 622 702 -3148 140 -984 -2899 -575 -2845 -1922 -943 1895 1141 -1086 298 1312 -2450 -3015 -2329 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -8826 -9868 -894 -1115 -1050 -952 * * 39 -728 -4361 -876 -277 -4682 -1609 -2520 -1531 1841 -4377 528 -738 1309 667 1725 185 220 -1588 -4544 -799 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -47 -10802 -5465 -894 -1115 -1242 -792 * * 40 260 -4712 -766 1352 182 -593 -2877 -1008 128 -553 -3801 1185 -530 1095 -445 -108 -231 124 -4896 -1159 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11194 -12236 -894 -1115 -2259 -338 * * 41 -3332 -4804 -266 -1353 -1285 -574 1070 -1856 94 -1034 -3893 692 -712 -1013 -797 -43 2997 -4426 -4988 -4305 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11291 -12333 -894 -1115 -2412 -300 * * 42 -700 -4862 333 -817 -5182 2524 -526 -1783 1384 -1745 -1075 843 -4458 -1046 -289 -1110 -1656 -1990 -5046 -1079 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11354 -12396 -894 -1115 -1798 -489 * * 43 -1173 -4941 -1557 -979 -604 -1468 897 -5013 1954 -1803 138 307 -249 945 2036 159 -396 -2175 -5125 -1380 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11438 -12480 -894 -1115 -2153 -367 * * 44 -761 520 -3503 -1614 -70 -1372 716 -1913 -458 -751 -273 1054 1094 -2810 -251 2278 206 -4308 -4988 -4372 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11480 -12522 -894 -1115 -924 -1080 * * 45 -1321 -5058 -425 -2897 -779 -2289 -317 -5123 2371 -1002 9 253 -678 -469 2287 -733 -567 -1327 -5244 -1405 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11573 -12615 -894 -1115 -133 -3507 * * 46 -3719 -474 -1497 -3192 -1667 3251 -869 -2155 -912 -2777 -3939 410 137 -1344 -4 -3684 -3658 -1329 -5082 -4493 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11655 -12697 -894 -1115 -701 -1378 * * 47 -3885 489 -2062 -1402 3077 -5253 102 -857 -811 -1171 40 -1665 -5319 82 -1004 -890 -625 -88 -201 2651 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11655 -12698 -894 -1115 -701 -1378 * * 48 2530 2194 -7362 -7062 -5394 2351 -5850 -614 -6668 -2653 -4600 -5981 -6144 -6241 -6416 -2409 -2154 -359 -5895 -5591 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11656 -12698 -894 -1115 -701 -1378 * * 49 -2230 -3786 -6302 -5666 4039 -5506 -4377 -646 -2109 -1078 -2988 -5151 -5556 -4884 -1887 -2366 -1143 -672 -4243 1795 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11656 -12698 -894 -1115 -701 -1378 * * 50 -1604 877 -8576 -8264 -6059 -8440 -8511 1855 -8244 -398 -860 -8092 -8163 -8212 -8428 -7826 -5871 3314 -7851 -7323 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11656 -12698 -894 -1115 -701 -1378 * * 51 -580 -5144 386 2159 -5465 -4645 -873 -1019 675 -3028 -4233 265 -4738 606 423 -82 1329 -935 -5327 -1448 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11656 -12698 -894 -1115 -701 -1378 * * 52 -7789 -427 -8717 -8877 4014 -8544 -4968 -5805 -8477 -2591 903 -7303 -8291 -7255 -7885 -7792 -7647 -1406 -4199 2905 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11656 -12698 -894 -1115 -701 -1378 * * 53 294 -5144 1172 1873 -905 -1521 942 -1481 948 -2782 -4233 -271 -458 -130 -424 -612 571 -932 -5327 -4644 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11656 -12698 -894 -1115 -701 -1378 * * 54 -3672 -5145 1936 61 -5467 -4646 -792 -5217 217 -5161 -4234 1953 -4739 -97 -7 1513 1248 -2330 -5329 -1478 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11656 -12698 -894 -1115 -701 -1378 * * 55 -1002 -5136 -1209 1439 -1656 -2269 1514 -739 1051 -828 10 -1550 1188 501 -508 130 -1282 403 -5321 13 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11656 -12699 -894 -1115 -701 -1378 * * 56 -141 -5143 1634 2314 -5463 -1920 -848 -1167 -1176 -2873 -1145 -776 -610 -1383 1036 196 -1750 -567 -388 -1421 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11657 -12699 -894 -1115 -701 -1378 * * 57 397 -643 2370 785 -1819 93 -852 -2168 -2927 -2707 -1041 -291 -2126 422 -3428 1295 -683 -1543 -5269 -636 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11657 -12699 -894 -1115 -701 -1378 * * 58 3055 -3784 -6300 -5664 -618 -5504 -4376 -1075 -5259 -1172 1495 -5149 -5554 -1856 -2150 -501 -298 32 -4242 -1298 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11657 -12699 -894 -1115 -701 -1378 * * 59 209 -573 1015 1604 -5465 -1967 -792 -304 1161 -1413 -4233 571 -1837 1303 -112 -2225 746 -2280 -5327 -4644 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11657 -12699 -894 -1115 -701 -1378 * * 60 993 -5141 565 -83 -1740 -4645 693 -2288 2343 -1443 -1038 178 -4739 -566 595 -98 -1095 -1488 -5325 -378 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11657 -12699 -894 -1115 -701 -1378 * * 61 3262 2020 -6694 -6082 -688 -5928 -4850 -126 -5698 -2502 -659 -5582 -5963 -5332 -5512 -1610 -4263 -115 -4698 -4352 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11657 -12700 -894 -1115 -701 -1378 * * 62 -1537 -3785 -6300 -5664 -787 -5505 -4376 2170 652 1595 832 -5150 -5555 -869 -1636 -2575 -3898 1605 -4242 -1299 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11658 -12700 -894 -1115 -701 -1378 * * 63 57 -5144 1386 1323 -5465 -2265 -3303 -780 812 -1898 -4233 131 -4738 1747 1061 108 -1766 -898 -5327 -793 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -326 -11658 -2388 -894 -1115 -701 -1378 * * 64 1233 705 146 1044 -1391 -414 -504 -4926 814 -1850 -873 617 -4450 472 -255 605 234 -2178 137 -4356 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -11349 -12391 -894 -1115 -123 -3612 * * 65 -376 872 -6218 -1442 516 -5480 -4348 -3270 -294 2248 2716 -5104 -5531 -342 -2307 -4562 -1171 -333 -4233 564 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -11642 -12685 -894 -1115 -382 -2105 * * 66 -2168 -5145 1779 -1715 -5466 -1556 1109 -5217 -347 -5161 -4234 3166 -102 1099 -928 -614 -1767 -4767 -5328 -411 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -11658 -12700 -894 -1115 -701 -1378 * * 67 -1458 -5144 -1823 269 -984 2974 159 -5216 311 -5160 -4233 840 -4738 -1432 -954 -817 -981 -4766 -5328 -610 - -148 -501 232 42 -379 397 104 -627 216 -467 -722 274 395 48 95 358 116 -365 -296 -251 - -173 -3301 -12701 -21 -6139 -701 -1378 * * 68 -674 -5080 -1102 -629 453 -1645 1132 200 1615 -1342 445 -3310 -4756 952 1120 -19 662 -1561 -5281 955 - -149 -500 232 43 -381 398 105 -627 210 -466 -721 275 396 45 95 359 120 -366 -295 -250 - -36 -6244 -12701 -1519 -619 -701 -1378 * * 69 -3696 -785 -17 1147 150 -1499 -3377 542 1043 -698 460 -737 -351 445 -584 -975 753 88 793 482 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -11659 -12701 -894 -1115 -701 -1378 * * 70 -3956 -3787 -1147 -2465 2322 -2554 -4371 1615 -2185 1495 -818 -5139 -2094 -4870 -2110 -2380 -1416 1282 -4244 800 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -11659 -12701 -894 -1115 -701 -1378 * * 71 -1015 -904 926 187 -880 1153 -650 -5215 676 -787 923 1723 -676 247 420 -1029 -1336 -4766 -5327 275 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -11659 -12701 -894 -1115 -701 -1378 * * 72 -2168 -5150 604 -1055 -5471 2762 -702 -5222 -918 -2141 -4239 1981 -4742 -142 -1740 262 -2027 -4772 -5333 -4650 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -11660 -12702 -894 -1115 -701 -1378 * * 73 -1412 853 -3523 -1170 -883 -4647 1925 -5199 1786 -1944 -937 587 -4740 633 2508 -313 -306 -4755 -5321 -528 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -11660 -12702 -894 -1115 -701 -1378 * * 74 -302 -498 -1750 1022 -866 -4653 -3313 -1357 1140 -1447 -4209 233 1336 -200 700 -1400 1160 451 -5307 -378 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -11660 -12702 -894 -1115 -701 -1378 * * 75 -1686 925 -1227 -5667 -1443 -2425 -4376 2317 -5261 1910 668 -5151 -2133 -1674 -5061 -2536 -2111 1191 -5 -3899 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -11660 -12702 -894 -1115 -701 -1378 * * 76 -2255 -5128 -302 363 -784 -2353 1397 -2058 1512 -314 -275 -1693 -1201 -571 1807 -524 252 -175 -256 793 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -11660 -12703 -894 -1115 -701 -1378 * * 77 -626 879 -2198 -5620 -1457 -5498 -4367 1846 -2705 -312 -2992 -5128 -1361 -1689 -695 -1594 53 2770 -4246 -3903 - * * * * * * * * * * * * * * * * * * * * - * * * * * * * * 0 // wise-2.4.1/src/test/road.pep0000644000175000001440000000060107313404553015253 0ustar philippusers>roa1_drome MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGLDYRTTDENLKAH FEKWGNIVDVVVMKDPRTKRSRGFGFITYSHSSMIDEAQKSRPHKIDGRV VEPKRAVPRQDIDSPNAGATVKKLFVGALKDDHDEQSIRDYFQHFGNIVD INIVIDKETGKKRGFAFVEFDDYDPVDKVVLQKQHQLNGKMVDVKKALPK QNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGNQNGGGNWNNGGNNWGNNR GGNDNWGNNSFGGGGGGGGGYGGGNNSWGNNNPWDNGNGGGNFGGGGNNW NNGGNDFGGYQQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGNYG GNNQGFNNGGNNRRY wise-2.4.1/src/test/hmm_genomic.out0000644000175000001440000004331710414205303016632 0ustar philippusersgenewise $Name: wise2-4-1 $ (unreleased release) This program is freely distributed under a GPL. See source directory Copyright (c) GRL limited: portions of the code are from separate copyright Query model: unnamed Start/End local Target Sequence HSHNCPA1 Strand: forward Start/End (protein) local Gene Parameter file: gene.stat Splice site model: GT/AG only GT/AG bits penalty -9.96 Codon Table: codon.table Subs error: 1e-06 Indel error: 1e-06 Null model syn Algorithm 623L genewise output Score 112.25 bits over entire alignment Scores as bits over a synchronous coding model Alignment 1 Score 112.25 (Bits) unnamed 1 KLFVGNLPPDTTEEELRELFSQFGEIESVKVMRDEPKTGKSRGFGFVTF K+FVG++ +DT E +LR++F+Q+G+IE +++M+D +++GK+RGF+ VTF KIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTD-RGSGKKRGFAxVTF HSHNCPA1 14 aatgggaaggaggcccagttgctgaaggagaaag cgagaaagtgtgat atttggtaaacaaaatgaataaagatattattca ggggaaggtcttct gatttctaactaatcaatttagtaatagtacgtc actcgagctcNact unnamed 50 ESEEDAEKAIEALNGKVLGGRVLRVKAAQKKEERQ +++++++K++ +++++V+G++++++KA +K+E++ DDHDSVDKIVIQKYHTVNGHNCEVRKALSKQEMAS HSHNCPA1 158 ggcgtggaagacatcagagcatggaagctacgaga aaaactaatttaaaactagaagatgactcaaatcg cctccgtgtctgacttgtccctataacgagaggtt // Bits Query start end Target start end idels introns 112.25 unnamed 1 84 HSHNCPA1 14 262 0 0 // Gene 1 Gene 14 262 Exon 14 262 phase 0 // >HSHNCPA1.[14:262].sp.tr KIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAxVTFDDHDSVDKIVIQ KYHTVNGHNCEVRKALSKQEMAS // >HSHNCPA1.[14:262].sp AAGATATTTGTTGGTGGCATTAAAGAAGACACTGAAGAACATCACCTAAGAGATTATTTT GAACAGTATGGAAAAATTGAAGTGATTGAAATCATGACTGACCGAGGCAGTGGCAAGAAA AGGGGCTTTGCCTTNGTAACCTTTGACGACCATGACTCCGTGGATAAGATTGTCATTCAG AAATACCATACTGTGAATGGCCACAACTGTGAAGTTAGAAAAGCCCTGTCAAAGCAAGAG ATGGCTAGT // Sequence HSHNCPA1 subsequence HSHNCPA1.1 14 262 Sequence HSHNCPA1.1 CDS Start_not_found End_not_found CDS_predicted_by genewise 112.25 source_Exons 1 249 // Gene 0 Gene 13 - 262 Transcript 0 Exon 0-249 Translation 0 - 249 // 0.00 [-1:-1 "LOOP_STATE" 0],[0:12 "RANDOM_SEQUENCE" 0] -18.25 [-1:0 "MATCH_STATE" -6326],[12:15 "CODON" -6326] 2.11 [0:1 "MATCH_STATE" 730],[15:18 "CODON" 730] 3.60 [1:2 "MATCH_STATE" 1249],[18:21 "CODON" 1249] 3.15 [2:3 "MATCH_STATE" 1090],[21:24 "CODON" 1090] 2.67 [3:4 "MATCH_STATE" 924],[24:27 "CODON" 924] 2.08 [4:5 "MATCH_STATE" 720],[27:30 "CODON" 720] 0.82 [5:6 "MATCH_STATE" 285],[30:33 "CODON" 285] -0.43 [6:7 "MATCH_STATE" -150],[33:36 "CODON" -150] 1.14 [7:8 "MATCH_STATE" 395],[36:39 "CODON" 395] 2.26 [8:9 "MATCH_STATE" 783],[39:42 "CODON" 783] 2.01 [9:10 "MATCH_STATE" 696],[42:45 "CODON" 696] -0.21 [10:11 "MATCH_STATE" -74],[45:48 "CODON" -74] 2.64 [11:12 "MATCH_STATE" 914],[48:51 "CODON" 914] -0.01 [12:13 "MATCH_STATE" -3],[51:54 "CODON" -3] 1.05 [13:14 "MATCH_STATE" 364],[54:57 "CODON" 364] 2.82 [14:15 "MATCH_STATE" 976],[57:60 "CODON" 976] 2.36 [15:16 "MATCH_STATE" 819],[60:63 "CODON" 819] 1.57 [16:17 "MATCH_STATE" 543],[63:66 "CODON" 543] 2.33 [17:18 "MATCH_STATE" 808],[66:69 "CODON" 808] 4.24 [18:19 "MATCH_STATE" 1468],[69:72 "CODON" 1468] 1.47 [19:20 "MATCH_STATE" 511],[72:75 "CODON" 511] 2.06 [20:21 "MATCH_STATE" 715],[75:78 "CODON" 715] 2.33 [21:22 "MATCH_STATE" 808],[78:81 "CODON" 808] 3.34 [22:23 "MATCH_STATE" 1159],[81:84 "CODON" 1159] 0.92 [23:24 "MATCH_STATE" 320],[84:87 "CODON" 320] 2.71 [24:25 "MATCH_STATE" 938],[87:90 "CODON" 938] 1.57 [25:26 "MATCH_STATE" 544],[90:93 "CODON" 544] -0.06 [26:27 "MATCH_STATE" -22],[93:96 "CODON" -22] 1.75 [27:28 "MATCH_STATE" 605],[96:99 "CODON" 605] 1.01 [28:29 "MATCH_STATE" 349],[99:102 "CODON" 349] 1.92 [29:30 "MATCH_STATE" 664],[102:105 "CODON" 664] 2.97 [30:31 "MATCH_STATE" 1029],[105:108 "CODON" 1029] 1.03 [31:32 "MATCH_STATE" 358],[108:111 "CODON" 358] 3.21 [32:33 "MATCH_STATE" 1114],[111:114 "CODON" 1114] -0.56 [33:34 "DELETE_STATE" -193],[114:114 "INSERT" -193] 0.85 [34:35 "MATCH_STATE" 295],[114:117 "CODON" 295] 0.37 [35:36 "MATCH_STATE" 128],[117:120 "CODON" 128] 1.02 [36:37 "MATCH_STATE" 352],[120:123 "CODON" 352] 2.79 [37:38 "MATCH_STATE" 968],[123:126 "CODON" 968] 2.50 [38:39 "MATCH_STATE" 865],[126:129 "CODON" 865] 0.39 [39:40 "MATCH_STATE" 135],[129:132 "CODON" 135] 2.80 [40:41 "MATCH_STATE" 970],[132:135 "CODON" 970] 3.33 [41:42 "MATCH_STATE" 1154],[135:138 "CODON" 1154] 3.41 [42:43 "MATCH_STATE" 1183],[138:141 "CODON" 1183] 2.13 [43:44 "MATCH_STATE" 739],[141:144 "CODON" 739] -3.04 [44:45 "MATCH_STATE" -1053],[144:147 "CODON" -1053] 3.23 [45:46 "MATCH_STATE" 1120],[147:150 "CODON" 1120] 2.25 [46:47 "MATCH_STATE" 780],[150:153 "CODON" 780] 3.95 [47:48 "MATCH_STATE" 1368],[153:156 "CODON" 1368] 1.26 [48:49 "MATCH_STATE" 436],[156:159 "CODON" 436] 1.45 [49:50 "MATCH_STATE" 503],[159:162 "CODON" 503] 2.08 [50:51 "MATCH_STATE" 722],[162:165 "CODON" 722] 1.57 [51:52 "MATCH_STATE" 543],[165:168 "CODON" 543] 0.84 [52:53 "MATCH_STATE" 292],[168:171 "CODON" 292] 1.71 [53:54 "MATCH_STATE" 593],[171:174 "CODON" 593] 1.39 [54:55 "MATCH_STATE" 481],[174:177 "CODON" 481] 2.50 [55:56 "MATCH_STATE" 867],[177:180 "CODON" 867] 0.82 [56:57 "MATCH_STATE" 285],[180:183 "CODON" 285] 1.49 [57:58 "MATCH_STATE" 517],[183:186 "CODON" 517] -0.49 [58:59 "MATCH_STATE" -169],[186:189 "CODON" -169] 1.25 [59:60 "MATCH_STATE" 432],[189:192 "CODON" 432] 1.33 [60:61 "MATCH_STATE" 460],[192:195 "CODON" 460] 1.13 [61:62 "MATCH_STATE" 393],[195:198 "CODON" 393] 3.10 [62:63 "MATCH_STATE" 1073],[198:201 "CODON" 1073] 1.22 [63:64 "MATCH_STATE" 424],[201:204 "CODON" 424] 1.39 [64:65 "MATCH_STATE" 482],[204:207 "CODON" 482] 0.78 [65:66 "MATCH_STATE" 269],[207:210 "CODON" 269] 1.58 [66:67 "MATCH_STATE" 547],[210:213 "CODON" 547] 1.05 [67:68 "MATCH_STATE" 364],[213:216 "CODON" 364] 0.88 [68:69 "MATCH_STATE" 306],[216:219 "CODON" 306] 2.57 [69:70 "MATCH_STATE" 891],[219:222 "CODON" 891] 1.37 [70:71 "MATCH_STATE" 475],[222:225 "CODON" 475] 0.68 [71:72 "MATCH_STATE" 236],[225:228 "CODON" 236] 0.47 [72:73 "MATCH_STATE" 164],[228:231 "CODON" 164] 1.27 [73:74 "MATCH_STATE" 439],[231:234 "CODON" 439] 1.60 [74:75 "MATCH_STATE" 553],[234:237 "CODON" 553] -0.53 [75:76 "MATCH_STATE" -182],[237:240 "CODON" -182] 0.77 [76:77 "MATCH_STATE" 268],[240:243 "CODON" 268] 2.12 [77:78 "MATCH_STATE" 734],[243:246 "CODON" 734] 0.94 [78:79 "MATCH_STATE" 326],[246:249 "CODON" 326] 1.07 [79:80 "MATCH_STATE" 372],[249:252 "CODON" 372] 1.54 [80:81 "MATCH_STATE" 533],[252:255 "CODON" 533] 0.66 [81:82 "MATCH_STATE" 229],[255:258 "CODON" 229] -0.20 [82:83 "MATCH_STATE" -68],[258:261 "CODON" -68] 0.00 [83:0 "LOOP_STATE" 0],[261:413 "RANDOM_SEQUENCE" 0] 0.00 [0:0 "END" 0],[413:414 "END" 0] // Score 38904 Position i:[-1] j:[0] State:[7] Score: 0 Position i:[-1] j:[1] State:[6] Score: 0 Position i:[-1] j:[2] State:[6] Score: 0 Position i:[-1] j:[3] State:[6] Score: 0 Position i:[-1] j:[4] State:[6] Score: 0 Position i:[-1] j:[5] State:[6] Score: 0 Position i:[-1] j:[6] State:[6] Score: 0 Position i:[-1] j:[7] State:[6] Score: 0 Position i:[-1] j:[8] State:[6] Score: 0 Position i:[-1] j:[9] State:[6] Score: 0 Position i:[-1] j:[10] State:[6] Score: 0 Position i:[-1] j:[11] State:[6] Score: 0 Position i:[-1] j:[12] State:[6] Score: 0 Position i:[0] j:[15] State:[0] Score: -6326 Position i:[1] j:[18] State:[0] Score: 730 Position i:[2] j:[21] State:[0] Score: 1249 Position i:[3] j:[24] State:[0] Score: 1090 Position i:[4] j:[27] State:[0] Score: 924 Position i:[5] j:[30] State:[0] Score: 720 Position i:[6] j:[33] State:[0] Score: 285 Position i:[7] j:[36] State:[0] Score: -150 Position i:[8] j:[39] State:[0] Score: 395 Position i:[9] j:[42] State:[0] Score: 783 Position i:[10] j:[45] State:[0] Score: 696 Position i:[11] j:[48] State:[0] Score: -74 Position i:[12] j:[51] State:[0] Score: 914 Position i:[13] j:[54] State:[0] Score: -3 Position i:[14] j:[57] State:[0] Score: 364 Position i:[15] j:[60] State:[0] Score: 976 Position i:[16] j:[63] State:[0] Score: 819 Position i:[17] j:[66] State:[0] Score: 543 Position i:[18] j:[69] State:[0] Score: 808 Position i:[19] j:[72] State:[0] Score: 1468 Position i:[20] j:[75] State:[0] Score: 511 Position i:[21] j:[78] State:[0] Score: 715 Position i:[22] j:[81] State:[0] Score: 808 Position i:[23] j:[84] State:[0] Score: 1159 Position i:[24] j:[87] State:[0] Score: 320 Position i:[25] j:[90] State:[0] Score: 938 Position i:[26] j:[93] State:[0] Score: 544 Position i:[27] j:[96] State:[0] Score: -22 Position i:[28] j:[99] State:[0] Score: 605 Position i:[29] j:[102] State:[0] Score: 349 Position i:[30] j:[105] State:[0] Score: 664 Position i:[31] j:[108] State:[0] Score: 1029 Position i:[32] j:[111] State:[0] Score: 358 Position i:[33] j:[114] State:[0] Score: 1114 Position i:[34] j:[114] State:[2] Score: -193 Position i:[35] j:[117] State:[0] Score: 295 Position i:[36] j:[120] State:[0] Score: 128 Position i:[37] j:[123] State:[0] Score: 352 Position i:[38] j:[126] State:[0] Score: 968 Position i:[39] j:[129] State:[0] Score: 865 Position i:[40] j:[132] State:[0] Score: 135 Position i:[41] j:[135] State:[0] Score: 970 Position i:[42] j:[138] State:[0] Score: 1154 Position i:[43] j:[141] State:[0] Score: 1183 Position i:[44] j:[144] State:[0] Score: 739 Position i:[45] j:[147] State:[0] Score: -1053 Position i:[46] j:[150] State:[0] Score: 1120 Position i:[47] j:[153] State:[0] Score: 780 Position i:[48] j:[156] State:[0] Score: 1368 Position i:[49] j:[159] State:[0] Score: 436 Position i:[50] j:[162] State:[0] Score: 503 Position i:[51] j:[165] State:[0] Score: 722 Position i:[52] j:[168] State:[0] Score: 543 Position i:[53] j:[171] State:[0] Score: 292 Position i:[54] j:[174] State:[0] Score: 593 Position i:[55] j:[177] State:[0] Score: 481 Position i:[56] j:[180] State:[0] Score: 867 Position i:[57] j:[183] State:[0] Score: 285 Position i:[58] j:[186] State:[0] Score: 517 Position i:[59] j:[189] State:[0] Score: -169 Position i:[60] j:[192] State:[0] Score: 432 Position i:[61] j:[195] State:[0] Score: 460 Position i:[62] j:[198] State:[0] Score: 393 Position i:[63] j:[201] State:[0] Score: 1073 Position i:[64] j:[204] State:[0] Score: 424 Position i:[65] j:[207] State:[0] Score: 482 Position i:[66] j:[210] State:[0] Score: 269 Position i:[67] j:[213] State:[0] Score: 547 Position i:[68] j:[216] State:[0] Score: 364 Position i:[69] j:[219] State:[0] Score: 306 Position i:[70] j:[222] State:[0] Score: 891 Position i:[71] j:[225] State:[0] Score: 475 Position i:[72] j:[228] State:[0] Score: 236 Position i:[73] j:[231] State:[0] Score: 164 Position i:[74] j:[234] State:[0] Score: 439 Position i:[75] j:[237] State:[0] Score: 553 Position i:[76] j:[240] State:[0] Score: -182 Position i:[77] j:[243] State:[0] Score: 268 Position i:[78] j:[246] State:[0] Score: 734 Position i:[79] j:[249] State:[0] Score: 326 Position i:[80] j:[252] State:[0] Score: 372 Position i:[81] j:[255] State:[0] Score: 533 Position i:[82] j:[258] State:[0] Score: 229 Position i:[83] j:[261] State:[0] Score: -68 Position i:[0] j:[261] State:[6] Score: 0 Position i:[0] j:[262] State:[6] Score: 0 Position i:[0] j:[263] State:[6] Score: 0 Position i:[0] j:[264] State:[6] Score: 0 Position i:[0] j:[265] State:[6] Score: 0 Position i:[0] j:[266] State:[6] Score: 0 Position i:[0] j:[267] State:[6] Score: 0 Position i:[0] j:[268] State:[6] Score: 0 Position i:[0] j:[269] State:[6] Score: 0 Position i:[0] j:[270] State:[6] Score: 0 Position i:[0] j:[271] State:[6] Score: 0 Position i:[0] j:[272] State:[6] Score: 0 Position i:[0] j:[273] State:[6] Score: 0 Position i:[0] j:[274] State:[6] Score: 0 Position i:[0] j:[275] State:[6] Score: 0 Position i:[0] j:[276] State:[6] Score: 0 Position i:[0] j:[277] State:[6] Score: 0 Position i:[0] j:[278] State:[6] Score: 0 Position i:[0] j:[279] State:[6] Score: 0 Position i:[0] j:[280] State:[6] Score: 0 Position i:[0] j:[281] State:[6] Score: 0 Position i:[0] j:[282] State:[6] Score: 0 Position i:[0] j:[283] State:[6] Score: 0 Position i:[0] j:[284] State:[6] Score: 0 Position i:[0] j:[285] State:[6] Score: 0 Position i:[0] j:[286] State:[6] Score: 0 Position i:[0] j:[287] State:[6] Score: 0 Position i:[0] j:[288] State:[6] Score: 0 Position i:[0] j:[289] State:[6] Score: 0 Position i:[0] j:[290] State:[6] Score: 0 Position i:[0] j:[291] State:[6] Score: 0 Position i:[0] j:[292] State:[6] Score: 0 Position i:[0] j:[293] State:[6] Score: 0 Position i:[0] j:[294] State:[6] Score: 0 Position i:[0] j:[295] State:[6] Score: 0 Position i:[0] j:[296] State:[6] Score: 0 Position i:[0] j:[297] State:[6] Score: 0 Position i:[0] j:[298] State:[6] Score: 0 Position i:[0] j:[299] State:[6] Score: 0 Position i:[0] j:[300] State:[6] Score: 0 Position i:[0] j:[301] State:[6] Score: 0 Position i:[0] j:[302] State:[6] Score: 0 Position i:[0] j:[303] State:[6] Score: 0 Position i:[0] j:[304] State:[6] Score: 0 Position i:[0] j:[305] State:[6] Score: 0 Position i:[0] j:[306] State:[6] Score: 0 Position i:[0] j:[307] State:[6] Score: 0 Position i:[0] j:[308] State:[6] Score: 0 Position i:[0] j:[309] State:[6] Score: 0 Position i:[0] j:[310] State:[6] Score: 0 Position i:[0] j:[311] State:[6] Score: 0 Position i:[0] j:[312] State:[6] Score: 0 Position i:[0] j:[313] State:[6] Score: 0 Position i:[0] j:[314] State:[6] Score: 0 Position i:[0] j:[315] State:[6] Score: 0 Position i:[0] j:[316] State:[6] Score: 0 Position i:[0] j:[317] State:[6] Score: 0 Position i:[0] j:[318] State:[6] Score: 0 Position i:[0] j:[319] State:[6] Score: 0 Position i:[0] j:[320] State:[6] Score: 0 Position i:[0] j:[321] State:[6] Score: 0 Position i:[0] j:[322] State:[6] Score: 0 Position i:[0] j:[323] State:[6] Score: 0 Position i:[0] j:[324] State:[6] Score: 0 Position i:[0] j:[325] State:[6] Score: 0 Position i:[0] j:[326] State:[6] Score: 0 Position i:[0] j:[327] State:[6] Score: 0 Position i:[0] j:[328] State:[6] Score: 0 Position i:[0] j:[329] State:[6] Score: 0 Position i:[0] j:[330] State:[6] Score: 0 Position i:[0] j:[331] State:[6] Score: 0 Position i:[0] j:[332] State:[6] Score: 0 Position i:[0] j:[333] State:[6] Score: 0 Position i:[0] j:[334] State:[6] Score: 0 Position i:[0] j:[335] State:[6] Score: 0 Position i:[0] j:[336] State:[6] Score: 0 Position i:[0] j:[337] State:[6] Score: 0 Position i:[0] j:[338] State:[6] Score: 0 Position i:[0] j:[339] State:[6] Score: 0 Position i:[0] j:[340] State:[6] Score: 0 Position i:[0] j:[341] State:[6] Score: 0 Position i:[0] j:[342] State:[6] Score: 0 Position i:[0] j:[343] State:[6] Score: 0 Position i:[0] j:[344] State:[6] Score: 0 Position i:[0] j:[345] State:[6] Score: 0 Position i:[0] j:[346] State:[6] Score: 0 Position i:[0] j:[347] State:[6] Score: 0 Position i:[0] j:[348] State:[6] Score: 0 Position i:[0] j:[349] State:[6] Score: 0 Position i:[0] j:[350] State:[6] Score: 0 Position i:[0] j:[351] State:[6] Score: 0 Position i:[0] j:[352] State:[6] Score: 0 Position i:[0] j:[353] State:[6] Score: 0 Position i:[0] j:[354] State:[6] Score: 0 Position i:[0] j:[355] State:[6] Score: 0 Position i:[0] j:[356] State:[6] Score: 0 Position i:[0] j:[357] State:[6] Score: 0 Position i:[0] j:[358] State:[6] Score: 0 Position i:[0] j:[359] State:[6] Score: 0 Position i:[0] j:[360] State:[6] Score: 0 Position i:[0] j:[361] State:[6] Score: 0 Position i:[0] j:[362] State:[6] Score: 0 Position i:[0] j:[363] State:[6] Score: 0 Position i:[0] j:[364] State:[6] Score: 0 Position i:[0] j:[365] State:[6] Score: 0 Position i:[0] j:[366] State:[6] Score: 0 Position i:[0] j:[367] State:[6] Score: 0 Position i:[0] j:[368] State:[6] Score: 0 Position i:[0] j:[369] State:[6] Score: 0 Position i:[0] j:[370] State:[6] Score: 0 Position i:[0] j:[371] State:[6] Score: 0 Position i:[0] j:[372] State:[6] Score: 0 Position i:[0] j:[373] State:[6] Score: 0 Position i:[0] j:[374] State:[6] Score: 0 Position i:[0] j:[375] State:[6] Score: 0 Position i:[0] j:[376] State:[6] Score: 0 Position i:[0] j:[377] State:[6] Score: 0 Position i:[0] j:[378] State:[6] Score: 0 Position i:[0] j:[379] State:[6] Score: 0 Position i:[0] j:[380] State:[6] Score: 0 Position i:[0] j:[381] State:[6] Score: 0 Position i:[0] j:[382] State:[6] Score: 0 Position i:[0] j:[383] State:[6] Score: 0 Position i:[0] j:[384] State:[6] Score: 0 Position i:[0] j:[385] State:[6] Score: 0 Position i:[0] j:[386] State:[6] Score: 0 Position i:[0] j:[387] State:[6] Score: 0 Position i:[0] j:[388] State:[6] Score: 0 Position i:[0] j:[389] State:[6] Score: 0 Position i:[0] j:[390] State:[6] Score: 0 Position i:[0] j:[391] State:[6] Score: 0 Position i:[0] j:[392] State:[6] Score: 0 Position i:[0] j:[393] State:[6] Score: 0 Position i:[0] j:[394] State:[6] Score: 0 Position i:[0] j:[395] State:[6] Score: 0 Position i:[0] j:[396] State:[6] Score: 0 Position i:[0] j:[397] State:[6] Score: 0 Position i:[0] j:[398] State:[6] Score: 0 Position i:[0] j:[399] State:[6] Score: 0 Position i:[0] j:[400] State:[6] Score: 0 Position i:[0] j:[401] State:[6] Score: 0 Position i:[0] j:[402] State:[6] Score: 0 Position i:[0] j:[403] State:[6] Score: 0 Position i:[0] j:[404] State:[6] Score: 0 Position i:[0] j:[405] State:[6] Score: 0 Position i:[0] j:[406] State:[6] Score: 0 Position i:[0] j:[407] State:[6] Score: 0 Position i:[0] j:[408] State:[6] Score: 0 Position i:[0] j:[409] State:[6] Score: 0 Position i:[0] j:[410] State:[6] Score: 0 Position i:[0] j:[411] State:[6] Score: 0 Position i:[0] j:[412] State:[6] Score: 0 Position i:[0] j:[413] State:[6] Score: 0 Position i:[0] j:[414] State:[8] Score: 0 // wise-2.4.1/src/test/pswdb.out0000644000175000001440000001462710345263436015507 0ustar philippusers------------------------------------------------------------- Wise2 - Protein vs. Protein Program: pswdb version: $Name: wise2-4-1 $ released: unreleased This program is freely distributed under a Gnu Public License. See -version for more info on copyright Bugs and credits to: Richard Copley Ewan Birney ------------------------------------------------------------- Algorithm type: Smith/Waterman Gap open: 12 Gap extension: 2 Query info from: road.pep Database info from: pep.fa Comp Matrix: BLOSUM62.bla [Warning: Can't fit histogram to a db smaller than 1,000] #High Score list ------------------------------------------------------------- Probe roa1_drome Dbase ROA1_HUMAN + 833 0 Probe roa1_drome Dbase SW:ROA1_XENLA + 773 0 Probe roa1_drome Dbase Q22037 + 662 0 #Alignments ------------------------------------------------------------- >roa1_drome vs ROA1_HUMAN [1] P: 0 Sc: 833 aln_len: 368 p_len: 365 t_len: 371 match: 93.7% ID: 47.8% probe: 22 DSITEPEHMRKLFIGGLDYRTTDENLKAHFEKWGNIVDVVVMKDPRTKR +S EPE +RKLFIGGL + TTDE+L++HFE+WG + D VVM+DP TKR target: 4 ESPKEPEQLRKLFIGGLSFETTDESLRSHFEQWGTLTDCVVMRDPNTKR probe: 71 SRGFGFITYSHSSMIDEAQKSRPHKIDGRVVEPKRAVPRQDIDSPNAGA SRGFGF+TY+ +D A +RPHK+DGRVVEPKRAV R+D P A target: 53 SRGFGFVTYATVEEVDAAMNARPHKVDGRVVEPKRAVSREDSQRPGAHL probe: 120 TVKKLFVGALKDDHDEQSIRDYFQHFGNIVDINIVIDKETGKKRGFAFV TVKK+FVG +K+D +E +RDYF+ +G I I I+ D+ +GKKRGFAFV target: 102 TVKKIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAFV probe: 169 EFDDYDPVDKVVLQKQHQLNGKMVDVKKALPKQ------NDQQGGGGGR FDD+D VDK+V+QK H +NG +V+KAL KQ + Q+G G target: 151 TFDDHDSVDKIVIQKYHTVNGHNCEVRKALSKQEMASASSSQRGRSGSG probe: 212 GGPGGRAGGNRGNMGGGNYGNQNGGGNW--NNGGNNWGNNRGGNDNWGN GGR GG GN G GN +G G + + GG +G + G + +GN target: 200 NFGGGRGGGFGGNDNFGRGGNFSGRGGFGGSRGGGGYGGSGDGYNGFGN probe: 259 NS-FGGGG----GGGGGYGGGNNSWGNN----------NPWDNGNGGGN + +GGGG GG GYG G +GN + ++NG G G target: 249 DGGYGGGGPGYSGGSRGYGSGGQGYGNQGSGYGGSGSYDSYNNGGGRGF probe: 293 FGGGGNNWNNGG--NDFGGYQ-QNYGGGPQRGGGNFNNNRMQPYQGGGG GG G+N+ GG NDFG Y Q+ GP +GG NF PY GGG target: 298 GGGSGSNFGGGGSYNDFGNYNNQSSNFGPMKGG-NFGGRSSGPYGGGGQ probe: 339 FKAGGGNQGNYGGNNQGFNNGGNNR + A NQG YGG++ + G R target: 346 YFAKPRNQGGYGGSSSSSSYGSGRR ------------------------------------------------------------- >roa1_drome vs SW:ROA1_XENLA [2] P: 0 Sc: 773 aln_len: 359 p_len: 365 t_len: 365 match: 90.1% ID: 47.4% probe: 26 EPEHMRKLFIGGLDYRTTDENLKAHFEKWGNIVDVVVMKDPRTKRSRGF EPE +RKLFIGGL + TTDE+L+ HFE+WG + D VVM+DP +KRSRGF target: 9 EPEQLRKLFIGGLSFETTDESLREHFEQWGTLTDCVVMRDPNSKRSRGF probe: 75 GFITYSHSSMIDEAQKSRPHKIDGRVVEPKRAVPRQDIDSPNAGATVKK GF+TY + +D A +RPHK+DGRVVEPKRAV R+D P A TVKK target: 58 GFVTYLSTDEVDAAMTARPHKVDGRVVEPKRAVSREDSSRPGAHLTVKK probe: 124 LFVGALKDDHDEQSIRDYFQHFGNIVDINIVIDKETGKKRGFAFVEFDD +FVG +K+D +E +R+YF+ +G I I I+ D+ +GKKRGFAFV F+D target: 107 IFVGGIKEDTEEDHLREYFEQYGKIEVIEIMTDRGSGKKRGFAFVTFED probe: 173 YDPVDKVVLQKQHQLNGKMVDVKKALPKQ-------NDQQGGGGGR--- +D VDK+V+QK H +N V+KAL KQ + ++ GG G target: 156 HDSVDKIVIQKYHTVNNHNSQVRKALSKQEMASVSGSQRERGGSGNYGS probe: 212 ---------GGPGGRAGGNRGNMGGGNYGNQNGGGNWNNG-GNNWGNNR GG GG GGNRG GGG +GN+ GG+ NG G W target: 205 RGGFGNDNFGGRGGNFGGNRG--GGGGFGNRGYGGDGYNGDGQLWWQPS probe: 251 --GGNDNWGNNSFGG-GGGGGGGYGGGNNS--WGNNNPWDNGNGGGN-F G N +G GG G G GGGYGGG +G N +D NGGG+ F target: 252 LLGWNRGYGAGQGGGYGAGQGGGYGGGGQGGGYGGNGGYDGYNGGGSGF probe: 294 GGGGNNWNNGG--NDFGGY--QQNYGGGPQRGGGNFNNNRMQPYQGGGG G G N+ + G NDFG Y Q + GP +GG PY GG G target: 301 SGSGGNFGSSGGYNDFGNYNSQSSSNFGPMKGGNYGGGRNSGPYGGGYG probe: 339 FKAGGGNQGNYGGNNQ + + G YGG + target: 350 GGSASSSSG-YGGGRR ------------------------------------------------------------- >roa1_drome vs Q22037 [3] P: 0 Sc: 662 aln_len: 338 p_len: 365 t_len: 346 match: 91.8% ID: 40.2% probe: 22 DSITEPEHMRKLFIGGLDYRTTDENLKAHFEKWGNIVDVVVMKDPRTKR D+ EPE++RK+F+GGL TTD+ ++ + ++G I D++VM+DP TKR target: 14 DASLEPENLRKIFVGGLTSNTTDDLMREFYSQFGEITDIIVMRDPTTKR probe: 71 SRGFGFITYSHSSMIDEAQKSRPHKIDGRVVEPKRAVPRQDIDSPNAGA SRGFGF+T+S + +D A K RPH IDG+ V+PKRAVPR D + + target: 63 SRGFGFVTFSGKTEVDAAMKQRPHIIDGKTVDPKRAVPRDDKNRSESNV probe: 120 TVKKLFVGALKDDHDEQSIRDYFQHFGNIVDINIVIDKETGKKRGFAFV + K+L+V +++DH E + +YF +G + I++DK T K RGF FV target: 112 STKRLYVSGVREDHTEDMLTEYFTKYGTVTKSEIILDKATQKPRGFGFV probe: 169 EFDDYDPVDKVVLQKQHQLNGKMVDVKKALPKQNDQQGGGGGRGGPGGR FDD+D VD+ VLQK H +NG DV+K L K D+ R target: 161 TFDDHDSVDQCVLQKSHMVNGHRCDVRKGLSK--DEMSKAQMNRDRETR probe: 218 AGGNRGNMGGGNYGNQNGGGNWNNGGNNWGNNR-GGNDNWGNNSFGGGG G +R GG G GGG W G GG G +GG target: 208 GGRSRDGQRGGYNGGGGGGGGWGGPAQRGGPGAYGGPGGGGQGGYGGDY probe: 266 GGGGGY--GGGNNSWGNNNPWDNGNGGGNFGGGGNNWNNGGNDFGGYQQ GGG G GGG WG G G G GGGG G QQ target: 257 GGGWGQQGGGGQGGWGGPQQQQGGGGWGQQGGGGQGGWGGPQQ---QQQ probe: 313 NYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGNYGGNNQGF GGPQ+GGG QGG G ++G + G N+ + target: 303 GGWGGPQQGGGGGGWGGQGQQQGGWGGQSGAQQWAHAQGGNRNY ------------------------------------------------------------- wise-2.4.1/src/test/dna.db0000644000175000001440000001562407313404552014703 0ustar philippusers>SAHNRNPH gaattccgagtagcgtcgttagggaagtagggaaacttgtactgtgggtatttgtaggta gaagttgtcccagtaaagaaaaattcattcaagatggtgaatatggatcgtgagaatgat cacggtgagccagagcatgttagaaaactatttattggtggattggactatagaacaact gacgagtccctaaagcaacattttgaacaatggggtgaaatagttgatgtggtggttatg aaggaccctaaaacgaagaggtcgagagggtttgggttcataacttactccagagcacat atggtggatgatgctcagaatgctcgcccacacaaagttgatggtcgtgttgtggagccg aaaagagctgttcctcgcacggagattggtaggccagaagcgggagcgactgtgaaaaag ctatttgttggtggaattaaggaagagatggaagaaaacgatctgcgcgattatttcaaa cagtatggcactgtcgtctctgctgcaatcgtcgttgacaaggagactcgcaagaagcgt ggcttcgctttcgtagaatttgacgattatgatccagttgacaaaatatgtttgagtcgc aatcaccagatccgtgggaagcatatagatgtcaaaaaagccttacccaaaggtgatgct ccaggaggccgtggaggtggaggcagaggtggggttggtggtggcgcaggtggtggctgg ggcggaggacgtggtgactggggtggaagtgctggtggcggtggaggtggtggctgggga ggtgctgatccatgggagaatggccgtggtggtggcggtgaccgatggggaggtggtggt ggcggtatgggtggtggagataggtggggtgggggtggtggaatgggagggggtgacagg tacggtggtggcggtggacgcagtggtggatggtccaatgatggttacaatagtggacca cagtctgacggattcggtggcggctacaagcaaagctatggaggaggtgcagttcgtggt tctagtggttatggtggaagccggtctgctccatactctgatagaggatctcgaggtggt ggaggtggcggttacggttccggtggtggccgcaggtattaagtgctgtggcactccttt ccttcctgtgcaggtgtcgcctatttctgatacttcgctataagtagctgaggctgtcag atgtaggagacaggcaaagtcagagcacaggagaggcaggcaggcaggtttaaccttgag cagagacagaagagcaaatgagcagaacaggacatggatcagttcgttgctagagcaatc gtgtgtactgcatcatcagtcattccattttaaacaatctcacccttgacaccattatca gttagtgaagtagtctacatcctatgtcttgtgtaattatcttcgactttttaagatgtg taattttattgtagttgctcaatagttgtcagatacagttctggaaatcttggcctgaaa atataaaccatttacaaattatgatcaaaaatgcctgtagttttgaggaatgagtacaaa tgttttggaaagttaactttttgtccagtatctgattgataatgccgagaaaccagttgt atgaacttttataggtcattgtatttatttagctggctctcacattttgtataggtttta agtggtcatacaccttagtctttgtgagaaggaatccagttttcttttgagggaccaaat cataagtgcgaaactgcaggcttgtaggtgttcaaaggtaccctcactaatttattgtag ttcttgccattttatcatataaaagcagttttagtatattgcattgaaagttaagtgaat gaggaattgatctgtatgcttagaacttcatgcagtaaataattagtgagtacaaagatc tgtaatcccaacgtgtcactaattactggtttctttgttctctctcttcccctccgtttc tttttggatccgagtttttggatgtttggaagacattcaagtgagtttttggtatcctga accaagggctcacctgcataaaaggtcagttgctggtgactgtatatctttaattttaaa aagcccccatttttgtactttccaacacaataggccatgtgaaatgcatttatgtattat aattttcctatgttctaaataaactttttctaataaaaaaaaaaaaaaaaggaattc >MMD728 tctagctctcatcatcctaccgtcatgtctaagtccgagtctcccaaggagccagaacag ctgcggaagctcttcatcggagggctgagcttcgaaacaaccgacgagagtctgaggagc cattttgagcaatggggaacactaacagactgtgtggtaatgagagatccaaacaccaag agatccaggggctttgggtttgtcacatatgccactgtggaagaagtggatgctgccatg aatgcaagaccacacaaggtggatggaagagttgtggaacctaagagagctgtctcaaga gaagattctcagcgaccaggtgcccacttaactgtgaaaaagatctttgttggtggtatt aaagaagacactgaagaacatcacctacgagattattttgagcagtatgggaagattgaa gtgatagaaattatgactgacagaggcagtgggaaaaagaggggctttgcttttgttacc tttgatgaccatgactctgtggataagattgttattcagaaataccatactgtgaatggc cacaactgtgaagtaagaaaggctctgtcgaagcaagagatggctagtgcttcatccagt cagagaggtcgcagtggttctggaaactttggtggtggtcgtggaggcggttttggtggc aatgacaattttggtcgaggagggaacttcagtggtcgtggtggctttggtggcagccgt ggtggtggtggatatggtggcagtggggatggctataatggatttggcaatgatggtggc tatggcggttctagcagcagcagtagctatggcagtggcaggaggttctaattacataca gccaggaaacaaagcttagcaggagaggagagccagagaagtgacagggaagctacaggt tacaacagatttgtgaactcagccaagcacagtggtggcagggcctagctgctacaaaga agacatgttttagacaatactcatgtgtgtgggcaaaaactccaggactgtatttgtgac taattgtataacaggttattttagtttctgttctgtggaaagtgtaaagcattccaacaa aaggttttactgtagacctttttcacccatgctgttgattgctaaatgtaatagtctgat catgacgctgaataaatgtgtcttttttttttttttttttaaatgtgctgtgtaaagtta gtctattctgaagccatcttggtaaacttccccaacagtgtgaagttagaattccttcag ggtggtgccaagttccatttggaatttatttatggttgcttgggtggagaagccattgtc ttcaaaaaccttgatgtcgttaaactgccagttactattgtaacttttaatgagtttcac cattgaaagggtcatccaagcaaggtcacaatttggttataaaatggttgttggcacacc ctatgcaatatcaaaattgaataacggtatcagataaaataacagatgggaatgaagctt atgtatccattatcatgtgtactcaataaacgatttaattctcttg >MMD729 tctagctctcatcatcctaccgtcatgtctaagtccgagtctcccaaggagccagaacag ctgcggaagctcttcatcggagggctgagcttcgaaacaaccgacgagagtctgaggagc cattttgagcaatggggaacactaacagactgtgtggtaatgagagatccaaacaccaag agatccaggggctttgggtttgtcacatatgccactgtggaagaagtggatgctgccatg aatgcaagaccacacaaggtggatggaagagttgtggaacctaagagagctgtctcaaga gaagattctcagcgaccaggtgcccacttaactgtgaaaaagatctttgttggtggtatt aaagaagacactgaagaacatcacctacgagattattttgagcagtatgggaagattgaa gtgatagaaattatgactgacagaggcagtgggaaaaagaggggctttgcttttgttacc tttgatgaccatgactctgtggataagattgttattcagaaataccatactgtgaatggc cacaactgtgaagtaagaaaggctctgtcgaagcaagagatggctagtgcttcatccagt cagagaggtcgcagtggttctggaaactttggtggtggtcgtggaggcggttttggtggc aatgacaattttggtcgaggagggaacttcagtggtcgtggtggctttggtggcagccgt ggtggtggtggatatggtggcagtggggatggctataatggatttggcaatgatggaagc aattttggaggtggtggaagctacaatgattttggcaattacaacaatcagtcttccaat tttgggccgatgaagggaggaaactttggaggcaggagctctggcccttatggtggtgga ggccagtactttgctaaaccacggaaccaaggtggctatggcggttccagcagcagcagt agctatggcagtggcaggaggttctaattacatacagccaggaaacaaagcttagcagga gaggagagccagagaagtgacagggaagctacaggttacaacagatttgtgaactcagcc aagcacagtggtggcagggcctagctgctacaaagaagacatgttttagacaatactcat gtgtgtgggcaaaaactccaggactgtatttgtgactaattgtataacaggttattttag tttctgttctgtggaaagtgtaaagcattccaacaaaaggttttactgtagacctttttc acccatgctgttgattgctaaatgtaatagtctgatcatgacgctgaataaatgtgtctt ttttttttttttttttaaatgtgctgtgtaaagttagtctattctgaagccatcttggta aacttccccaacagtgtgaagttagaattccttcagggtggtgccaagttccatttggaa tttatttatggttgcttgggtggagaagccattgtcttcaaaaaccttgatgtcgttaaa ctgccagttactattgtaacttttaatgagtttcaccattgaaagggtcatccaagcaag gtcacaatttggttataaaatggttgttggcacaccctatgcaatatcaaaattgaataa cggtatcagataaaataacagatgggaatgaagcttatgtatccattatcatgtgtactc aataaacgatttaattctcttg >MMFLI2X cttttgctctttgacgctgccgaggaagcatcgctgaaggctctcgtaactctaccgtca tgtctaagtccgagtctcccaaggagccagaacagctgcggaagctcttcatcggagggc tgagcttcgaaacaaccgacgagagtctgaggagccattttgagcaatggggaacactaa cagactgtgtggtaatgagagatccaaacaccaagagatccaggggctttgggtttgtca catatgccactgtggaagaagtggatgctgccatgaatgcaagaccacacaaggtggatg gaagagttgtggaacctaagagagctgtctcaagagaagattctcagcgaccaggtgccc acttaactgtgaaaaagatctttgttggtggtattaaagaagacactgaagaacatcacc tacgagattattttgagcagtatgggaagattgaagtgatagaaattatgactgacagag gcagtgggaaaaagaggggctttgcttttgttacctttgatgaccatgactctgtggata agattgttattcagaaataccatactgtgaatggccacaactgtgaagtaagaaaggctc tgtcgaagcaagagatggctagtgcttcatccagtcagagaggtcgcagtggttctggaa actttggtggtggtcgtggaggcggttttggtggcaatgacaattttggtcgaggaggga acttcagtggtcgtggtggctttggtggcagccgtggtggtggtggatatggtggcagtg gggatggctataatggatttggcaatgatggaagcaattttggaggtggtggaagctaca atgattttggcaattacaacaatcagtcttccaattttgggccgatgaagggaggaaact ttggaggcaggagctctggcccttatggtggtggaggccagtactttgctaaaccacgga accaaggtggctatggcggttccagcagcagcagtagctatggcagtggcaggaggttct aattacatacagccaggaaacaaagcttagcaggagaggagagccagagaagtgacaggg aagctacaggttacaacagatttgtgaactcagccaagcacagtggtggcagggcctagc tgctacaaagaagacatgttttagacaatactcatgtgtgtgggcaaaaactccaggact gtatttgtgactaattgtataacaggttattttagtttctgttctgtggaaagtgtaaag cattccaacaaaaggttttactgtagacctttttcacccatgctgttgattgctaaatgt aatagtctgatcatgacgctgaataaatgtgtcttttttttttttttttaaatgtgctgt gtaaagttagtctattctgaagccatcttggtaaacttccccaacagtgtgaagttagaa ttc wise-2.4.1/src/test/go.evi0000644000175000001440000000007407362335215014740 0ustar philippusersexon 1404 1493 exon 1789 1947 exon 2120 2294 exon 2388 2461 wise-2.4.1/src/test/go.out0000644000175000001440000000070407362164761014772 0ustar philippusersGene 1 Gene 1401 2461 Exon 1401 1493 phase 0 Exon 1789 1947 phase 0 Exon 2120 2294 phase 0 Exon 2388 2461 phase 1 // >HSHNRNPA.[1401:2461].sp.tr RKLFIGGLSFETTDESLRSHFEQWGTLTDCVVMRDPNTKRSRGFGFVTYATVEEVDAAMN ARPHKVDGRVVEPKRAVSREVSGFKIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRG SGKKRGFAFVTFDDHDSVDKIVIQKYHTVNGHNCEVRKALSKQEMAS // Gene utr5 1400 1400 cds 1401 1493 phase 0 cds 1789 1947 phase 0 cds 2120 2294 phase 0 cds 2388 2461 phase 1 End // wise-2.4.1/src/test/wrong_est.out0000644000175000001440000000105707313404554016367 0ustar philippusersScore 1088 Position i:[-1] j:[287] State:[3] Score: 0 Position i:[0] j:[290] State:[0] Score: 1722 Position i:[1] j:[293] State:[0] Score: 1106 Position i:[2] j:[296] State:[0] Score: 584 Position i:[3] j:[299] State:[0] Score: 211 Position i:[0] j:[299] State:[4] Score: -2535 // Score 1290 Position i:[74] j:[7] State:[3] Score: 0 Position i:[75] j:[10] State:[0] Score: -1590 Position i:[76] j:[13] State:[0] Score: 386 Position i:[77] j:[16] State:[0] Score: 1414 Position i:[78] j:[19] State:[0] Score: 1100 Position i:[0] j:[19] State:[4] Score: -20 // wise-2.4.1/src/test/short.dna0000644000175000001440000000066007313404553015450 0ustar philippusers>HSHNCPA1 CACTTAACTGTGAAAGATATTTGTTGGTGGCATTAAAGAAGACACTGAAGAACATCAC CTAAGAGATTATTTTGAACAGTATGGAAAAATTGAAGTGATTGAAATCATGACTGACCGA GGCAGTGGCAAGAAAAGGGGCTTTGCCTTRGTAACCTTTGACGACCATGACTCCGTGGAT AAGATTGTCATTCAGAAATACCATACTGTGAATGGCCACAACTGTGAAGTTAGAAAAGCC CTGTCAAAGCAAGAGATGGCTAGTGCTTCATCCAGCCAAAGAGGTCGAAGTGGTTCTGGA AACTTTGGTGGTGGTCGTGGAGGTGGTTTCGGTGGGAATGACAACTTCGGTCGTGGAGGA AACTTCAGTGGTCGTGGTYGCTTTGGTGGCAGCCGTGGTGGTGGTGGATATGGTGGC wise-2.4.1/src/test/short.pep0000644000175000001440000000024507313404553015471 0ustar philippusers>roa1_drome VEPKRAVPRQDIDSPNAGATVKKLFVGALKDDHDEQSIRDYFQHFGNIVD INIVIDKETGKKRGFAFVEFDDYDPVDKVVLQKQHQLNGKMVDVKKALPK QNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGNQNGGGNWNNGGNNWGNNR wise-2.4.1/src/test/genewisedb-pfam.out0000644000175000001440000001613207313404552017413 0ustar philippusersWise2 - database searching mode Program: genewisedb version: $Name: wise2-4-1 $ released: unreleased This program is freely distributed under a Gnu Public License. See -version for more info on copyright Bugs and credits to Ewan Birney ----------------------------------------------------- Algorithm type: GeneWise Search algorithm used: 623 Implementation: Single Threaded processor (serial) Search mode: Single genomic vs protein db Protein info from: rrm.HMM Dna info from: short.dna Start/End (protein) default Gene Paras: human.gf Codon Table: codon.table Subs error: 1e-05 Indel error: 1e-05 Model splice? model Model codon bias? flat Model intron bias? tied Null model syn Alignment Alg 623L # #WARNING! # # Your alignment algorithm is different from your search algorithm. # This is probably quite sensible but will lead to differing scores. # Use the search score as an indicator of the significance of the match # Read the docs for more information # #High Score list #Protein ID DNA Str ID Bits Evalue -------------------------------------------------------------------------- Protein SEED DNA [+] HSHNCPA1 100.94 #Alignments ----------------------------------------------------------------------- >Results for SEED vs HSHNCPA1 (forward) [0] genewisedb output Score 92.71 bits over entire alignment. This will be different from per-alignment scores. See manual for details For computer parsable output, try genewisedb -help or read the manual Scores as bits over a synchronous coding model Alignment 1 Score 92.71 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF FVG++ +D+ E+ L+D+F+++G+I+ I+I++D + GK +GFA+ IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTD-----RGSGKKRGFAx HSHNCPA1 17 atgggaaggaggcccagttgctgaaggagaaag cgagaaagtgt tttggtaaacaaaatgaataaagatattattca ggggaaggtct atttctaactaatcaatttagtaatagtacgtc actcgagctcN SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+F+++++++K + ++++G++++V VTFDDHDSVDKIVI-QKYHTVNGHNCEV HSHNCPA1 149 gatggcgtggaaga catcagagcatgg tctaaaactaattt aaaactagaagat actcctccgtgtct gacttgtccctat // 0.00 [-1:-1 "LOOP_STATE" 0],[0:15 "RANDOM_SEQUENCE" 0] -5.85 [-1:0 "MATCH_STATE" -2026],[15:18 "CODON" -2026] 3.21 [0:1 "MATCH_STATE" 1114],[18:21 "CODON" 1114] 3.13 [1:2 "MATCH_STATE" 1086],[21:24 "CODON" 1086] 2.46 [2:3 "MATCH_STATE" 853],[24:27 "CODON" 853] 1.79 [3:4 "MATCH_STATE" 621],[27:30 "CODON" 621] 0.64 [4:5 "MATCH_STATE" 223],[30:33 "CODON" 223] -0.58 [5:6 "MATCH_STATE" -202],[33:36 "CODON" -202] 0.63 [6:7 "MATCH_STATE" 218],[36:39 "CODON" 218] 2.41 [7:8 "MATCH_STATE" 834],[39:42 "CODON" 834] 1.73 [8:9 "MATCH_STATE" 600],[42:45 "CODON" 600] -1.19 [9:10 "MATCH_STATE" -414],[45:48 "CODON" -414] 2.48 [10:11 "MATCH_STATE" 859],[48:51 "CODON" 859] 0.49 [11:12 "MATCH_STATE" 171],[51:54 "CODON" 171] -0.94 [12:13 "MATCH_STATE" -326],[54:57 "CODON" -326] 2.82 [13:14 "MATCH_STATE" 978],[57:60 "CODON" 978] 1.79 [14:15 "MATCH_STATE" 622],[60:63 "CODON" 622] 2.12 [15:16 "MATCH_STATE" 736],[63:66 "CODON" 736] 1.19 [16:17 "MATCH_STATE" 413],[66:69 "CODON" 413] 4.21 [17:18 "MATCH_STATE" 1458],[69:72 "CODON" 1458] 0.97 [18:19 "MATCH_STATE" 335],[72:75 "CODON" 335] 1.71 [19:20 "MATCH_STATE" 591],[75:78 "CODON" 591] 2.81 [20:21 "MATCH_STATE" 975],[78:81 "CODON" 975] 3.51 [21:22 "MATCH_STATE" 1215],[81:84 "CODON" 1215] 1.33 [22:23 "MATCH_STATE" 460],[84:87 "CODON" 460] 2.71 [23:24 "MATCH_STATE" 940],[87:90 "CODON" 940] 1.19 [24:25 "MATCH_STATE" 413],[90:93 "CODON" 413] -2.42 [25:26 "MATCH_STATE" -838],[93:96 "CODON" -838] 2.22 [26:27 "MATCH_STATE" 768],[96:99 "CODON" 768] 0.51 [27:28 "MATCH_STATE" 176],[99:102 "CODON" 176] 2.16 [28:29 "MATCH_STATE" 749],[102:105 "CODON" 749] 1.94 [29:30 "MATCH_STATE" 672],[105:108 "CODON" 672] 0.77 [30:31 "MATCH_STATE" 268],[108:111 "CODON" 268] 2.97 [31:32 "MATCH_STATE" 1028],[111:114 "CODON" 1028] -0.05 [32:33 "DELETE_STATE" -18],[114:114 "INSERT" -18] -0.07 [33:34 "DELETE_STATE" -24],[114:114 "INSERT" -24] -0.05 [34:35 "DELETE_STATE" -18],[114:114 "INSERT" -18] -0.05 [35:36 "DELETE_STATE" -18],[114:114 "INSERT" -18] -0.05 [36:37 "DELETE_STATE" -19],[114:114 "INSERT" -19] 0.68 [37:38 "MATCH_STATE" 234],[114:117 "CODON" 234] -0.64 [38:39 "MATCH_STATE" -221],[117:120 "CODON" -221] -0.05 [39:40 "MATCH_STATE" -18],[120:123 "CODON" -18] 2.51 [40:41 "MATCH_STATE" 870],[123:126 "CODON" 870] 1.94 [41:42 "MATCH_STATE" 673],[126:129 "CODON" 673] -0.47 [42:43 "MATCH_STATE" -162],[129:132 "CODON" -162] 2.27 [43:44 "MATCH_STATE" 788],[132:135 "CODON" 788] 3.24 [44:45 "MATCH_STATE" 1122],[135:138 "CODON" 1122] 3.06 [45:46 "MATCH_STATE" 1062],[138:141 "CODON" 1062] 2.52 [46:47 "MATCH_STATE" 872],[141:144 "CODON" 872] 3.24 [47:48 "MATCH_STATE" 1122],[144:147 "CODON" 1122] 3.30 [48:49 "MATCH_STATE" 1144],[147:150 "CODON" 1144] 1.31 [49:50 "MATCH_STATE" 455],[150:153 "CODON" 455] 4.00 [50:51 "MATCH_STATE" 1386],[153:156 "CODON" 1386] 1.16 [51:52 "MATCH_STATE" 401],[156:159 "CODON" 401] 1.92 [52:53 "MATCH_STATE" 665],[159:162 "CODON" 665] 1.50 [53:54 "MATCH_STATE" 519],[162:165 "CODON" 519] 1.62 [54:55 "MATCH_STATE" 561],[165:168 "CODON" 561] 1.28 [55:56 "MATCH_STATE" 443],[168:171 "CODON" 443] 0.02 [56:57 "MATCH_STATE" 6],[171:174 "CODON" 6] 1.00 [57:58 "MATCH_STATE" 346],[174:177 "CODON" 346] 2.33 [58:59 "MATCH_STATE" 807],[177:180 "CODON" 807] -0.14 [59:60 "MATCH_STATE" -48],[180:183 "CODON" -48] 1.59 [60:61 "MATCH_STATE" 551],[183:186 "CODON" 551] -0.79 [61:62 "MATCH_STATE" -275],[186:189 "CODON" -275] -2.39 [62:63 "DELETE_STATE" -827],[189:189 "INSERT" -827] -0.46 [63:64 "MATCH_STATE" -160],[189:192 "CODON" -160] -0.36 [64:65 "MATCH_STATE" -125],[192:195 "CODON" -125] -0.62 [65:66 "MATCH_STATE" -216],[195:198 "CODON" -216] 0.96 [66:67 "MATCH_STATE" 333],[198:201 "CODON" 333] 0.72 [67:68 "MATCH_STATE" 248],[201:204 "CODON" 248] 1.26 [68:69 "MATCH_STATE" 438],[204:207 "CODON" 438] 1.71 [69:70 "MATCH_STATE" 591],[207:210 "CODON" 591] 2.74 [70:71 "MATCH_STATE" 951],[210:213 "CODON" 951] 1.91 [71:72 "MATCH_STATE" 661],[213:216 "CODON" 661] 0.21 [72:73 "MATCH_STATE" 74],[216:219 "CODON" 74] 0.91 [73:74 "MATCH_STATE" 314],[219:222 "CODON" 314] 0.34 [74:75 "MATCH_STATE" 119],[222:225 "CODON" 119] 2.75 [75:76 "MATCH_STATE" 954],[225:228 "CODON" 954] 0.00 [76:0 "LOOP_STATE" 0],[228:413 "RANDOM_SEQUENCE" 0] 0.00 [0:0 "END" 0],[413:414 "END" 0] // wise-2.4.1/src/test/pep.fa0000644000175000001440000000244207313404553014721 0ustar philippusers>ROA1_HUMAN SKSESPKEPEQLRKLFIGGLSFETTDESLRSHFEQWGTLTDCVVMRDPNT KRSRGFGFVTYATVEEVDAAMNARPHKVDGRVVEPKRAVSREDSQRPGAH LTVKKIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAFV TFDDHDSVDKIVIQKYHTVNGHNCEVRKALSKQEMASASSSQRGRSGSGN FGGGRGGGFGGNDNFGRGGNFSGRGGFGGSRGGGGYGGSGDGYNGFGNDG GYGGGGPGYSGGSRGYGSGGQGYGNQGSGYGGSGSYDSYNNGGGRGFGGG SGSNFGGGGSYNDFGNYNNQSSNFGPMKGGNFGGRSSGPYGGGGQYFAKP RNQGGYGGSSSSSSYGSGRRF >Q22037 this here we go! MTDVEIKAENGSGDASLEPENLRKIFVGGLTSNTTDDLMREFYSQFGEITDIIVMRDPTT KRSRGFGFVTFSGKTEVDAAMKQRPHIIDGKTVDPKRAVPRDDKNRSESNVSTKRLYVSG VREDHTEDMLTEYFTKYGTVTKSEIILDKATQKPRGFGFVTFDDHDSVDQCVLQKSHMVN GHRCDVRKGLSKDEMSKAQMNRDRETRGGRSRDGQRGGYNGGGGGGGGWGGPAQRGGPGA YGGPGGGGQGGYGGDYGGGWGQQGGGGQGGWGGPQQQQGGGGWGQQGGGGQGGWGGPQQQ QQGGWGGPQQGGGGGGWGGQGQQQGGWGGQSGAQQWAHAQGGNRNY >SW:ROA1_XENLA P17130 HETEROGENEOUS NUCLEAR RIBONUCLEOPROTEINS A1 HOMOLOG (HNRNP A1) (HELIX-DESTABILIZING PROTEIN) (SINGLE-STRAND BINDING PROTEIN) (HNRNP CORE PROTEIN A1). MHKSEAPNEPEQLRKLFIGGLSFETTDESLREHFEQWGTLTDCVVMRDPNSKRSRGFGFV TYLSTDEVDAAMTARPHKVDGRVVEPKRAVSREDSSRPGAHLTVKKIFVGGIKEDTEEDH LREYFEQYGKIEVIEIMTDRGSGKKRGFAFVTFEDHDSVDKIVIQKYHTVNNHNSQVRKA LSKQEMASVSGSQRERGGSGNYGSRGGFGNDNFGGRGGNFGGNRGGGGGFGNRGYGGDGY NGDGQLWWQPSLLGWNRGYGAGQGGGYGAGQGGGYGGGGQGGGYGGNGGYDGYNGGGSGF SGSGGNFGSSGGYNDFGNYNSQSSSNFGPMKGGNYGGGRNSGPYGGGYGGGSASSSSGYG GGRRF wise-2.4.1/src/test/HMM.ascii0000644000175000001440000036726507313404551015277 0ustar philippusers# HMM v1.7 84 # M -- length of model 20 # alphabet length 3 # alphabet type ACDEFGHIKLMNPQRSTVWY # alphabet no # Optional reference line annotation? no # Optional consensus structure annotation? ###MATCH_STATE 0 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.000000 # Symbol A probability 0.000000 # Symbol C probability 0.000000 # Symbol D probability 0.000000 # Symbol E probability 0.000000 # Symbol F probability 0.000000 # Symbol G probability 0.000000 # Symbol H probability 0.000000 # Symbol I probability 0.000000 # Symbol K probability 0.000000 # Symbol L probability 0.000000 # Symbol M probability 0.000000 # Symbol N probability 0.000000 # Symbol P probability 0.000000 # Symbol Q probability 0.000000 # Symbol R probability 0.000000 # Symbol S probability 0.000000 # Symbol T probability 0.000000 # Symbol V probability 0.000000 # Symbol W probability 0.000000 # Symbol Y probability ###DELETE_STATE 0 0.000000 # t_m1 0.000000 # t_d1 0.000000 # t_i0 ###INSERT_STATE 0 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 1 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.022682 # Symbol A probability 0.016178 # Symbol C probability 0.005681 # Symbol D probability 0.006004 # Symbol E probability 0.004821 # Symbol F probability 0.010741 # Symbol G probability 0.022257 # Symbol H probability 0.040835 # Symbol I probability 0.227937 # Symbol K probability 0.010347 # Symbol L probability 0.001788 # Symbol M probability 0.192779 # Symbol N probability 0.012204 # Symbol P probability 0.010698 # Symbol Q probability 0.114048 # Symbol R probability 0.062979 # Symbol S probability 0.164671 # Symbol T probability 0.056330 # Symbol V probability 0.001272 # Symbol W probability 0.015748 # Symbol Y probability ###DELETE_STATE 1 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 1 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 2 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.028743 # Symbol A probability 0.016178 # Symbol C probability 0.005681 # Symbol D probability 0.006004 # Symbol E probability 0.010881 # Symbol F probability 0.010741 # Symbol G probability 0.004075 # Symbol H probability 0.246896 # Symbol I probability 0.009755 # Symbol K probability 0.440650 # Symbol L probability 0.007848 # Symbol M probability 0.004901 # Symbol N probability 0.006143 # Symbol P probability 0.004638 # Symbol Q probability 0.004958 # Symbol R probability 0.008434 # Symbol S probability 0.007096 # Symbol T probability 0.171481 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 2 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 2 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 3 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.010561 # Symbol A probability 0.004057 # Symbol C probability 0.005681 # Symbol D probability 0.006004 # Symbol E probability 0.495730 # Symbol F probability 0.010741 # Symbol G probability 0.034378 # Symbol H probability 0.040835 # Symbol I probability 0.009755 # Symbol K probability 0.046710 # Symbol L probability 0.001788 # Symbol M probability 0.004901 # Symbol N probability 0.006143 # Symbol P probability 0.004638 # Symbol Q probability 0.011018 # Symbol R probability 0.014495 # Symbol S probability 0.013156 # Symbol T probability 0.038148 # Symbol V probability 0.001272 # Symbol W probability 0.239990 # Symbol Y probability ###DELETE_STATE 3 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 3 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 4 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.022682 # Symbol A probability 0.016178 # Symbol C probability 0.005681 # Symbol D probability 0.006004 # Symbol E probability 0.010881 # Symbol F probability 0.022862 # Symbol G probability 0.004075 # Symbol H probability 0.186290 # Symbol I probability 0.009755 # Symbol K probability 0.083074 # Symbol L probability 0.007848 # Symbol M probability 0.010961 # Symbol N probability 0.006143 # Symbol P probability 0.004638 # Symbol Q probability 0.004958 # Symbol R probability 0.008434 # Symbol S probability 0.007096 # Symbol T probability 0.577542 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 4 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 4 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 5 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.034804 # Symbol A probability 0.004057 # Symbol C probability 0.005681 # Symbol D probability 0.030246 # Symbol E probability 0.004821 # Symbol F probability 0.434983 # Symbol G probability 0.004075 # Symbol H probability 0.004472 # Symbol I probability 0.173392 # Symbol K probability 0.010347 # Symbol L probability 0.001788 # Symbol M probability 0.047325 # Symbol N probability 0.006143 # Symbol P probability 0.010698 # Symbol Q probability 0.053442 # Symbol R probability 0.075101 # Symbol S probability 0.061641 # Symbol T probability 0.013905 # Symbol V probability 0.001272 # Symbol W probability 0.021808 # Symbol Y probability ###DELETE_STATE 5 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 5 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 6 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.010561 # Symbol A probability 0.004057 # Symbol C probability 0.054166 # Symbol D probability 0.012064 # Symbol E probability 0.004821 # Symbol F probability 0.289528 # Symbol G probability 0.004075 # Symbol H probability 0.010532 # Symbol I probability 0.021876 # Symbol K probability 0.016407 # Symbol L probability 0.001788 # Symbol M probability 0.477628 # Symbol N probability 0.018264 # Symbol P probability 0.004638 # Symbol Q probability 0.017079 # Symbol R probability 0.014495 # Symbol S probability 0.007096 # Symbol T probability 0.007845 # Symbol V probability 0.001272 # Symbol W probability 0.021808 # Symbol Y probability ###DELETE_STATE 6 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 6 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 7 ( ) ( ) 0.952095 # t_m1 0.000203 # t_d1 0.047703 # t_i0 0.010561 # Symbol A probability 0.004057 # Symbol C probability 0.005681 # Symbol D probability 0.006004 # Symbol E probability 0.035124 # Symbol F probability 0.010741 # Symbol G probability 0.004075 # Symbol H probability 0.101441 # Symbol I probability 0.009755 # Symbol K probability 0.713377 # Symbol L probability 0.013909 # Symbol M probability 0.004901 # Symbol N probability 0.006143 # Symbol P probability 0.004638 # Symbol Q probability 0.004958 # Symbol R probability 0.008434 # Symbol S probability 0.007096 # Symbol T probability 0.044208 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 7 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 7 0.797273 # t_m1 0.005455 # t_d1 0.197273 # t_i0 0.087123 # Symbol A probability 0.033467 # Symbol C probability 0.046866 # Symbol D probability 0.049536 # Symbol E probability 0.039767 # Symbol F probability 0.088613 # Symbol G probability 0.033617 # Symbol H probability 0.036887 # Symbol I probability 0.080484 # Symbol K probability 0.085353 # Symbol L probability 0.014749 # Symbol M probability 0.040477 # Symbol N probability 0.050676 # Symbol P probability 0.038257 # Symbol Q probability 0.040897 # Symbol R probability 0.069574 # Symbol S probability 0.058535 # Symbol T probability 0.064715 # Symbol V probability 0.010489 # Symbol W probability 0.029918 # Symbol Y probability ###MATCH_STATE 8 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.052985 # Symbol A probability 0.004057 # Symbol C probability 0.114772 # Symbol D probability 0.018125 # Symbol E probability 0.016942 # Symbol F probability 0.028922 # Symbol G probability 0.022257 # Symbol H probability 0.010532 # Symbol I probability 0.046119 # Symbol K probability 0.016407 # Symbol L probability 0.001788 # Symbol M probability 0.053385 # Symbol N probability 0.272810 # Symbol P probability 0.010698 # Symbol Q probability 0.023139 # Symbol R probability 0.214495 # Symbol S probability 0.061641 # Symbol T probability 0.019966 # Symbol V probability 0.001272 # Symbol W probability 0.009687 # Symbol Y probability ###DELETE_STATE 8 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 8 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 9 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.034804 # Symbol A probability 0.004057 # Symbol C probability 0.072348 # Symbol D probability 0.139337 # Symbol E probability 0.071487 # Symbol F probability 0.010741 # Symbol G probability 0.016196 # Symbol H probability 0.016593 # Symbol I probability 0.058240 # Symbol K probability 0.028528 # Symbol L probability 0.001788 # Symbol M probability 0.017022 # Symbol N probability 0.187961 # Symbol P probability 0.047062 # Symbol Q probability 0.029200 # Symbol R probability 0.044798 # Symbol S probability 0.031338 # Symbol T probability 0.026027 # Symbol V probability 0.067938 # Symbol W probability 0.094536 # Symbol Y probability ###DELETE_STATE 9 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 9 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 10 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.065107 # Symbol A probability 0.004057 # Symbol C probability 0.254166 # Symbol D probability 0.169640 # Symbol E probability 0.016942 # Symbol F probability 0.059225 # Symbol G probability 0.004075 # Symbol H probability 0.010532 # Symbol I probability 0.046119 # Symbol K probability 0.010347 # Symbol L probability 0.001788 # Symbol M probability 0.065507 # Symbol N probability 0.018264 # Symbol P probability 0.022819 # Symbol Q probability 0.029200 # Symbol R probability 0.135707 # Symbol S probability 0.049520 # Symbol T probability 0.013905 # Symbol V probability 0.001272 # Symbol W probability 0.021808 # Symbol Y probability ###DELETE_STATE 10 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 10 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 11 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.089349 # Symbol A probability 0.022239 # Symbol C probability 0.005681 # Symbol D probability 0.012064 # Symbol E probability 0.016942 # Symbol F probability 0.016801 # Symbol G probability 0.022257 # Symbol H probability 0.162047 # Symbol I probability 0.027937 # Symbol K probability 0.028528 # Symbol L probability 0.062394 # Symbol M probability 0.010961 # Symbol N probability 0.018264 # Symbol P probability 0.010698 # Symbol Q probability 0.004958 # Symbol R probability 0.020555 # Symbol S probability 0.231338 # Symbol T probability 0.219966 # Symbol V probability 0.001272 # Symbol W probability 0.015748 # Symbol Y probability ###DELETE_STATE 11 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 11 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 12 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.010561 # Symbol A probability 0.004057 # Symbol C probability 0.181439 # Symbol D probability 0.054488 # Symbol E probability 0.004821 # Symbol F probability 0.016801 # Symbol G probability 0.004075 # Symbol H probability 0.016593 # Symbol I probability 0.027937 # Symbol K probability 0.028528 # Symbol L probability 0.001788 # Symbol M probability 0.065507 # Symbol N probability 0.048567 # Symbol P probability 0.010698 # Symbol Q probability 0.011018 # Symbol R probability 0.105404 # Symbol S probability 0.382853 # Symbol T probability 0.019966 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 12 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 12 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 13 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.016622 # Symbol A probability 0.004057 # Symbol C probability 0.181439 # Symbol D probability 0.393882 # Symbol E probability 0.010881 # Symbol F probability 0.010741 # Symbol G probability 0.010136 # Symbol H probability 0.004472 # Symbol I probability 0.040058 # Symbol K probability 0.022468 # Symbol L probability 0.001788 # Symbol M probability 0.071567 # Symbol N probability 0.012204 # Symbol P probability 0.047062 # Symbol Q probability 0.017079 # Symbol R probability 0.044798 # Symbol S probability 0.037399 # Symbol T probability 0.026027 # Symbol V probability 0.031575 # Symbol W probability 0.015748 # Symbol Y probability ###DELETE_STATE 13 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 13 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 14 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.071167 # Symbol A probability 0.004057 # Symbol C probability 0.151136 # Symbol D probability 0.357519 # Symbol E probability 0.016942 # Symbol F probability 0.028922 # Symbol G probability 0.022257 # Symbol H probability 0.004472 # Symbol I probability 0.100664 # Symbol K probability 0.028528 # Symbol L probability 0.013909 # Symbol M probability 0.010961 # Symbol N probability 0.012204 # Symbol P probability 0.071304 # Symbol Q probability 0.011018 # Symbol R probability 0.062979 # Symbol S probability 0.013156 # Symbol T probability 0.013905 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 14 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 14 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 15 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.095410 # Symbol A probability 0.016178 # Symbol C probability 0.126893 # Symbol D probability 0.181761 # Symbol E probability 0.004821 # Symbol F probability 0.034983 # Symbol G probability 0.046499 # Symbol H probability 0.010532 # Symbol I probability 0.112785 # Symbol K probability 0.052771 # Symbol L probability 0.050273 # Symbol M probability 0.004901 # Symbol N probability 0.006143 # Symbol P probability 0.034941 # Symbol Q probability 0.047382 # Symbol R probability 0.062979 # Symbol S probability 0.067702 # Symbol T probability 0.032087 # Symbol V probability 0.007332 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 15 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 15 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 16 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.010561 # Symbol A probability 0.004057 # Symbol C probability 0.005681 # Symbol D probability 0.006004 # Symbol E probability 0.035124 # Symbol F probability 0.010741 # Symbol G probability 0.004075 # Symbol H probability 0.137805 # Symbol I probability 0.009755 # Symbol K probability 0.658832 # Symbol L probability 0.026030 # Symbol M probability 0.004901 # Symbol N probability 0.006143 # Symbol P probability 0.004638 # Symbol Q probability 0.004958 # Symbol R probability 0.008434 # Symbol S probability 0.007096 # Symbol T probability 0.050269 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 16 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 16 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 17 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.028743 # Symbol A probability 0.010118 # Symbol C probability 0.017802 # Symbol D probability 0.084792 # Symbol E probability 0.029063 # Symbol F probability 0.010741 # Symbol G probability 0.028318 # Symbol H probability 0.028714 # Symbol I probability 0.221876 # Symbol K probability 0.040650 # Symbol L probability 0.007848 # Symbol M probability 0.010961 # Symbol N probability 0.006143 # Symbol P probability 0.034941 # Symbol Q probability 0.265564 # Symbol R probability 0.050858 # Symbol S probability 0.013156 # Symbol T probability 0.026027 # Symbol V probability 0.019453 # Symbol W probability 0.064233 # Symbol Y probability ###DELETE_STATE 17 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 17 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 18 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.052985 # Symbol A probability 0.004057 # Symbol C probability 0.157196 # Symbol D probability 0.321155 # Symbol E probability 0.004821 # Symbol F probability 0.016801 # Symbol G probability 0.010136 # Symbol H probability 0.010532 # Symbol I probability 0.064301 # Symbol K probability 0.010347 # Symbol L probability 0.026030 # Symbol M probability 0.035204 # Symbol N probability 0.018264 # Symbol P probability 0.101607 # Symbol Q probability 0.029200 # Symbol R probability 0.062979 # Symbol S probability 0.049520 # Symbol T probability 0.013905 # Symbol V probability 0.001272 # Symbol W probability 0.009687 # Symbol Y probability ###DELETE_STATE 18 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 18 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 19 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.071167 # Symbol A probability 0.004057 # Symbol C probability 0.011742 # Symbol D probability 0.048428 # Symbol E probability 0.035124 # Symbol F probability 0.016801 # Symbol G probability 0.052560 # Symbol H probability 0.071138 # Symbol I probability 0.033998 # Symbol K probability 0.270953 # Symbol L probability 0.026030 # Symbol M probability 0.004901 # Symbol N probability 0.006143 # Symbol P probability 0.004638 # Symbol Q probability 0.004958 # Symbol R probability 0.038737 # Symbol S probability 0.073762 # Symbol T probability 0.062390 # Symbol V probability 0.001272 # Symbol W probability 0.161202 # Symbol Y probability ###DELETE_STATE 19 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 19 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 20 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.016622 # Symbol A probability 0.010118 # Symbol C probability 0.005681 # Symbol D probability 0.006004 # Symbol E probability 0.768457 # Symbol F probability 0.028922 # Symbol G probability 0.010136 # Symbol H probability 0.028714 # Symbol I probability 0.009755 # Symbol K probability 0.040650 # Symbol L probability 0.007848 # Symbol M probability 0.004901 # Symbol N probability 0.006143 # Symbol P probability 0.004638 # Symbol Q probability 0.011018 # Symbol R probability 0.008434 # Symbol S probability 0.007096 # Symbol T probability 0.013905 # Symbol V probability 0.001272 # Symbol W probability 0.009687 # Symbol Y probability ###DELETE_STATE 20 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 20 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 21 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.083288 # Symbol A probability 0.010118 # Symbol C probability 0.017802 # Symbol D probability 0.175701 # Symbol E probability 0.010881 # Symbol F probability 0.180438 # Symbol G probability 0.004075 # Symbol H probability 0.004472 # Symbol I probability 0.076422 # Symbol K probability 0.034589 # Symbol L probability 0.001788 # Symbol M probability 0.059446 # Symbol N probability 0.006143 # Symbol P probability 0.022819 # Symbol Q probability 0.035261 # Symbol R probability 0.232676 # Symbol S probability 0.013156 # Symbol T probability 0.013905 # Symbol V probability 0.001272 # Symbol W probability 0.015748 # Symbol Y probability ###DELETE_STATE 21 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 21 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 22 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.065107 # Symbol A probability 0.004057 # Symbol C probability 0.054166 # Symbol D probability 0.109034 # Symbol E probability 0.004821 # Symbol F probability 0.077407 # Symbol G probability 0.016196 # Symbol H probability 0.016593 # Symbol I probability 0.149149 # Symbol K probability 0.010347 # Symbol L probability 0.007848 # Symbol M probability 0.035204 # Symbol N probability 0.121295 # Symbol P probability 0.168274 # Symbol Q probability 0.023139 # Symbol R probability 0.056919 # Symbol S probability 0.019217 # Symbol T probability 0.056330 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 22 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 22 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 23 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.083288 # Symbol A probability 0.010118 # Symbol C probability 0.011742 # Symbol D probability 0.018125 # Symbol E probability 0.362396 # Symbol F probability 0.016801 # Symbol G probability 0.028318 # Symbol H probability 0.052956 # Symbol I probability 0.021876 # Symbol K probability 0.034589 # Symbol L probability 0.007848 # Symbol M probability 0.017022 # Symbol N probability 0.012204 # Symbol P probability 0.028880 # Symbol Q probability 0.011018 # Symbol R probability 0.032676 # Symbol S probability 0.007096 # Symbol T probability 0.044208 # Symbol V probability 0.037635 # Symbol W probability 0.161202 # Symbol Y probability ###DELETE_STATE 23 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 23 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 24 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.046925 # Symbol A probability 0.010118 # Symbol C probability 0.011742 # Symbol D probability 0.006004 # Symbol E probability 0.041184 # Symbol F probability 0.695589 # Symbol G probability 0.004075 # Symbol H probability 0.010532 # Symbol I probability 0.009755 # Symbol K probability 0.016407 # Symbol L probability 0.001788 # Symbol M probability 0.010961 # Symbol N probability 0.042507 # Symbol P probability 0.004638 # Symbol Q probability 0.011018 # Symbol R probability 0.014495 # Symbol S probability 0.025278 # Symbol T probability 0.032087 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 24 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 24 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 25 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.052985 # Symbol A probability 0.004057 # Symbol C probability 0.060227 # Symbol D probability 0.157519 # Symbol E probability 0.029063 # Symbol F probability 0.083468 # Symbol G probability 0.010136 # Symbol H probability 0.010532 # Symbol I probability 0.112785 # Symbol K probability 0.028528 # Symbol L probability 0.001788 # Symbol M probability 0.065507 # Symbol N probability 0.139476 # Symbol P probability 0.034941 # Symbol Q probability 0.041321 # Symbol R probability 0.044798 # Symbol S probability 0.098005 # Symbol T probability 0.019966 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 25 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 25 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 26 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.046925 # Symbol A probability 0.010118 # Symbol C probability 0.011742 # Symbol D probability 0.018125 # Symbol E probability 0.035124 # Symbol F probability 0.010741 # Symbol G probability 0.004075 # Symbol H probability 0.374169 # Symbol I probability 0.027937 # Symbol K probability 0.040650 # Symbol L probability 0.007848 # Symbol M probability 0.004901 # Symbol N probability 0.024325 # Symbol P probability 0.010698 # Symbol Q probability 0.004958 # Symbol R probability 0.038737 # Symbol S probability 0.007096 # Symbol T probability 0.310875 # Symbol V probability 0.001272 # Symbol W probability 0.009687 # Symbol Y probability ###DELETE_STATE 26 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 26 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 27 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.028743 # Symbol A probability 0.010118 # Symbol C probability 0.017802 # Symbol D probability 0.187822 # Symbol E probability 0.010881 # Symbol F probability 0.022862 # Symbol G probability 0.010136 # Symbol H probability 0.065078 # Symbol I probability 0.094604 # Symbol K probability 0.119438 # Symbol L probability 0.019970 # Symbol M probability 0.029143 # Symbol N probability 0.012204 # Symbol P probability 0.016759 # Symbol Q probability 0.047382 # Symbol R probability 0.062979 # Symbol S probability 0.110126 # Symbol T probability 0.129057 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 27 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 27 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 28 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.046925 # Symbol A probability 0.004057 # Symbol C probability 0.126893 # Symbol D probability 0.090852 # Symbol E probability 0.004821 # Symbol F probability 0.034983 # Symbol G probability 0.004075 # Symbol H probability 0.034775 # Symbol I probability 0.033998 # Symbol K probability 0.028528 # Symbol L probability 0.013909 # Symbol M probability 0.065507 # Symbol N probability 0.006143 # Symbol P probability 0.022819 # Symbol Q probability 0.041321 # Symbol R probability 0.305404 # Symbol S probability 0.043459 # Symbol T probability 0.062390 # Symbol V probability 0.001272 # Symbol W probability 0.027869 # Symbol Y probability ###DELETE_STATE 28 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 28 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 29 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.156016 # Symbol A probability 0.125269 # Symbol C probability 0.011742 # Symbol D probability 0.006004 # Symbol E probability 0.023002 # Symbol F probability 0.028922 # Symbol G probability 0.010136 # Symbol H probability 0.192350 # Symbol I probability 0.021876 # Symbol K probability 0.070953 # Symbol L probability 0.001788 # Symbol M probability 0.004901 # Symbol N probability 0.030385 # Symbol P probability 0.004638 # Symbol Q probability 0.023139 # Symbol R probability 0.056919 # Symbol S probability 0.013156 # Symbol T probability 0.201784 # Symbol V probability 0.001272 # Symbol W probability 0.015748 # Symbol Y probability ###DELETE_STATE 29 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 29 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 30 ( ) ( ) 0.992635 # t_m1 0.006959 # t_d1 0.000405 # t_i0 0.028743 # Symbol A probability 0.004057 # Symbol C probability 0.048105 # Symbol D probability 0.127216 # Symbol E probability 0.029063 # Symbol F probability 0.010741 # Symbol G probability 0.022257 # Symbol H probability 0.028714 # Symbol I probability 0.203695 # Symbol K probability 0.046710 # Symbol L probability 0.013909 # Symbol M probability 0.041264 # Symbol N probability 0.018264 # Symbol P probability 0.034941 # Symbol Q probability 0.150412 # Symbol R probability 0.050858 # Symbol S probability 0.031338 # Symbol T probability 0.104815 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 30 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 30 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 31 ( ) ( ) 0.992585 # t_m1 0.007007 # t_d1 0.000408 # t_i0 0.016723 # Symbol A probability 0.004082 # Symbol C probability 0.024009 # Symbol D probability 0.018235 # Symbol E probability 0.010948 # Symbol F probability 0.010806 # Symbol G probability 0.010198 # Symbol H probability 0.217913 # Symbol I probability 0.022010 # Symbol K probability 0.144556 # Symbol L probability 0.050579 # Symbol M probability 0.029321 # Symbol N probability 0.012278 # Symbol P probability 0.010763 # Symbol Q probability 0.023280 # Symbol R probability 0.020680 # Symbol S probability 0.025432 # Symbol T probability 0.343259 # Symbol V probability 0.001279 # Symbol W probability 0.003649 # Symbol Y probability ###DELETE_STATE 31 0.697500 # t_m1 0.287500 # t_d1 0.015000 # t_i0 ###INSERT_STATE 31 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 32 ( ) ( ) 0.992534 # t_m1 0.007055 # t_d1 0.000411 # t_i0 0.035231 # Symbol A probability 0.034782 # Symbol C probability 0.024156 # Symbol D probability 0.012212 # Symbol E probability 0.035555 # Symbol F probability 0.010872 # Symbol G probability 0.016395 # Symbol H probability 0.108821 # Symbol I probability 0.040550 # Symbol K probability 0.084093 # Symbol L probability 0.185859 # Symbol M probability 0.023366 # Symbol N probability 0.098243 # Symbol P probability 0.010829 # Symbol Q probability 0.035693 # Symbol R probability 0.039212 # Symbol S probability 0.019453 # Symbol T probability 0.167450 # Symbol V probability 0.001287 # Symbol W probability 0.015941 # Symbol Y probability ###DELETE_STATE 32 0.558000 # t_m1 0.430000 # t_d1 0.012000 # t_i0 ###INSERT_STATE 32 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 33 ( ) ( ) 0.937310 # t_m1 0.062276 # t_d1 0.000414 # t_i0 0.010757 # Symbol A probability 0.022651 # Symbol C probability 0.024305 # Symbol D probability 0.043152 # Symbol E probability 0.060465 # Symbol F probability 0.035631 # Symbol G probability 0.010323 # Symbol H probability 0.029246 # Symbol I probability 0.096356 # Symbol K probability 0.029057 # Symbol L probability 0.088241 # Symbol M probability 0.042028 # Symbol N probability 0.055640 # Symbol P probability 0.017069 # Symbol Q probability 0.140852 # Symbol R probability 0.051800 # Symbol S probability 0.118338 # Symbol T probability 0.057373 # Symbol V probability 0.007468 # Symbol W probability 0.059249 # Symbol Y probability ###DELETE_STATE 33 0.631667 # t_m1 0.358333 # t_d1 0.010000 # t_i0 ###INSERT_STATE 33 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 34 ( ) ( ) 0.320511 # t_m1 0.679051 # t_d1 0.000438 # t_i0 0.017809 # Symbol A probability 0.004347 # Symbol C probability 0.525568 # Symbol D probability 0.058381 # Symbol E probability 0.005165 # Symbol F probability 0.082936 # Symbol G probability 0.010860 # Symbol H probability 0.011284 # Symbol I probability 0.049413 # Symbol K probability 0.017579 # Symbol L probability 0.014903 # Symbol M probability 0.063692 # Symbol N probability 0.013075 # Symbol P probability 0.011462 # Symbol Q probability 0.018299 # Symbol R probability 0.015530 # Symbol S probability 0.040070 # Symbol T probability 0.034379 # Symbol V probability 0.001362 # Symbol W probability 0.003886 # Symbol Y probability ###DELETE_STATE 34 0.199286 # t_m1 0.796429 # t_d1 0.004286 # t_i0 ###INSERT_STATE 34 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 35 ( ) ( ) 0.066136 # t_m1 0.887045 # t_d1 0.046818 # t_i0 0.094141 # Symbol A probability 0.010974 # Symbol C probability 0.064548 # Symbol D probability 0.130993 # Symbol E probability 0.013039 # Symbol F probability 0.061839 # Symbol G probability 0.027416 # Symbol H probability 0.012095 # Symbol I probability 0.108354 # Symbol K probability 0.060774 # Symbol L probability 0.054016 # Symbol M probability 0.013256 # Symbol N probability 0.082190 # Symbol P probability 0.045331 # Symbol Q probability 0.046197 # Symbol R probability 0.088387 # Symbol S probability 0.019193 # Symbol T probability 0.054007 # Symbol V probability 0.003439 # Symbol W probability 0.009810 # Symbol Y probability ###DELETE_STATE 35 0.502710 # t_m1 0.431308 # t_d1 0.065981 # t_i0 ###INSERT_STATE 35 0.283421 # t_m1 0.001579 # t_d1 0.715000 # t_i0 0.087130 # Symbol A probability 0.033458 # Symbol C probability 0.046894 # Symbol D probability 0.049523 # Symbol E probability 0.039766 # Symbol F probability 0.088599 # Symbol G probability 0.033628 # Symbol H probability 0.036897 # Symbol I probability 0.080472 # Symbol K probability 0.085340 # Symbol L probability 0.014755 # Symbol M probability 0.040426 # Symbol N probability 0.050682 # Symbol P probability 0.038277 # Symbol Q probability 0.040906 # Symbol R probability 0.069576 # Symbol S probability 0.058550 # Symbol T probability 0.064717 # Symbol V probability 0.010486 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 36 ( ) ( ) 0.998571 # t_m1 0.000476 # t_d1 0.000952 # t_i0 0.021783 # Symbol A probability 0.008368 # Symbol C probability 0.049218 # Symbol D probability 0.024883 # Symbol E probability 0.034943 # Symbol F probability 0.034653 # Symbol G probability 0.008405 # Symbol H probability 0.009223 # Symbol I probability 0.170120 # Symbol K probability 0.033840 # Symbol L probability 0.003688 # Symbol M probability 0.085108 # Symbol N probability 0.212670 # Symbol P probability 0.034565 # Symbol Q probability 0.172725 # Symbol R probability 0.017395 # Symbol S probability 0.039635 # Symbol T probability 0.016180 # Symbol V probability 0.002623 # Symbol W probability 0.019980 # Symbol Y probability ###DELETE_STATE 36 0.247614 # t_m1 0.751705 # t_d1 0.000682 # t_i0 ###INSERT_STATE 36 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 37 ( ) ( ) 0.998902 # t_m1 0.000366 # t_d1 0.000732 # t_i0 0.058006 # Symbol A probability 0.006762 # Symbol C probability 0.090277 # Symbol D probability 0.111016 # Symbol E probability 0.008034 # Symbol F probability 0.088608 # Symbol G probability 0.016893 # Symbol H probability 0.047857 # Symbol I probability 0.177875 # Symbol K probability 0.047547 # Symbol L probability 0.002980 # Symbol M probability 0.068774 # Symbol N probability 0.010238 # Symbol P probability 0.078436 # Symbol Q probability 0.038566 # Symbol R probability 0.044360 # Symbol S probability 0.052230 # Symbol T probability 0.043378 # Symbol V probability 0.002119 # Symbol W probability 0.006044 # Symbol Y probability ###DELETE_STATE 37 0.330290 # t_m1 0.668841 # t_d1 0.000870 # t_i0 ###INSERT_STATE 37 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 38 ( ) ( ) 0.999118 # t_m1 0.000294 # t_d1 0.000588 # t_i0 0.023047 # Symbol A probability 0.005625 # Symbol C probability 0.058297 # Symbol D probability 0.033534 # Symbol E probability 0.006684 # Symbol F probability 0.014892 # Symbol G probability 0.014054 # Symbol H probability 0.023007 # Symbol I probability 0.047139 # Symbol K probability 0.056363 # Symbol L probability 0.002479 # Symbol M probability 0.057215 # Symbol N probability 0.016921 # Symbol P probability 0.031640 # Symbol Q probability 0.040487 # Symbol R probability 0.146148 # Symbol S probability 0.396393 # Symbol T probability 0.019281 # Symbol V probability 0.001763 # Symbol W probability 0.005029 # Symbol Y probability ###DELETE_STATE 38 0.240612 # t_m1 0.758163 # t_d1 0.001224 # t_i0 ###INSERT_STATE 38 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 39 ( ) ( ) 0.999189 # t_m1 0.000270 # t_d1 0.000541 # t_i0 0.013614 # Symbol A probability 0.005230 # Symbol C probability 0.030761 # Symbol D probability 0.031177 # Symbol E probability 0.006214 # Symbol F probability 0.474783 # Symbol G probability 0.013066 # Symbol H probability 0.013577 # Symbol I probability 0.075075 # Symbol K probability 0.013338 # Symbol L probability 0.017930 # Symbol M probability 0.146942 # Symbol N probability 0.007919 # Symbol P probability 0.013791 # Symbol Q probability 0.061078 # Symbol R probability 0.034309 # Symbol S probability 0.024772 # Symbol T probability 0.010112 # Symbol V probability 0.001639 # Symbol W probability 0.004675 # Symbol Y probability ###DELETE_STATE 39 0.344750 # t_m1 0.653750 # t_d1 0.001500 # t_i0 ###INSERT_STATE 39 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 40 ( ) ( ) 0.999262 # t_m1 0.000246 # t_d1 0.000492 # t_i0 0.019731 # Symbol A probability 0.004816 # Symbol C probability 0.013938 # Symbol D probability 0.007127 # Symbol E probability 0.005722 # Symbol F probability 0.041527 # Symbol G probability 0.004837 # Symbol H probability 0.005308 # Symbol I probability 0.335321 # Symbol K probability 0.019476 # Symbol L probability 0.009317 # Symbol M probability 0.056177 # Symbol N probability 0.014486 # Symbol P probability 0.063059 # Symbol Q probability 0.264878 # Symbol R probability 0.067565 # Symbol S probability 0.022812 # Symbol T probability 0.030895 # Symbol V probability 0.001509 # Symbol W probability 0.011499 # Symbol Y probability ###DELETE_STATE 40 0.441034 # t_m1 0.556897 # t_d1 0.002069 # t_i0 ###INSERT_STATE 40 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 41 ( ) ( ) 0.999318 # t_m1 0.000227 # t_d1 0.000455 # t_i0 0.025118 # Symbol A probability 0.024627 # Symbol C probability 0.013003 # Symbol D probability 0.006648 # Symbol E probability 0.012050 # Symbol F probability 0.025317 # Symbol G probability 0.031358 # Symbol H probability 0.004952 # Symbol I probability 0.077917 # Symbol K probability 0.031592 # Symbol L probability 0.008691 # Symbol M probability 0.059118 # Symbol N probability 0.060494 # Symbol P probability 0.005136 # Symbol Q probability 0.112872 # Symbol R probability 0.452293 # Symbol S probability 0.027992 # Symbol T probability 0.015399 # Symbol V probability 0.001408 # Symbol W probability 0.004016 # Symbol Y probability ###DELETE_STATE 41 0.620526 # t_m1 0.376316 # t_d1 0.003158 # t_i0 ###INSERT_STATE 41 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 42 ( ) ( ) 0.999362 # t_m1 0.000213 # t_d1 0.000426 # t_i0 0.017358 # Symbol A probability 0.004237 # Symbol C probability 0.037578 # Symbol D probability 0.006270 # Symbol E probability 0.011363 # Symbol F probability 0.023875 # Symbol G probability 0.029572 # Symbol H probability 0.004670 # Symbol I probability 0.326643 # Symbol K probability 0.055109 # Symbol L probability 0.020854 # Symbol M probability 0.011447 # Symbol N probability 0.012744 # Symbol P probability 0.017501 # Symbol Q probability 0.359608 # Symbol R probability 0.027795 # Symbol S probability 0.013739 # Symbol T probability 0.014522 # Symbol V probability 0.001328 # Symbol W probability 0.003787 # Symbol Y probability ###DELETE_STATE 42 0.979000 # t_m1 0.015000 # t_d1 0.006000 # t_i0 ###INSERT_STATE 42 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 43 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.010561 # Symbol A probability 0.010118 # Symbol C probability 0.035984 # Symbol D probability 0.012064 # Symbol E probability 0.016942 # Symbol F probability 0.689529 # Symbol G probability 0.004075 # Symbol H probability 0.004472 # Symbol I probability 0.040058 # Symbol K probability 0.010347 # Symbol L probability 0.001788 # Symbol M probability 0.047325 # Symbol N probability 0.030385 # Symbol P probability 0.010698 # Symbol Q probability 0.017079 # Symbol R probability 0.020555 # Symbol S probability 0.013156 # Symbol T probability 0.019966 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 43 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 43 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 44 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.010561 # Symbol A probability 0.034360 # Symbol C probability 0.005681 # Symbol D probability 0.012064 # Symbol E probability 0.435124 # Symbol F probability 0.016801 # Symbol G probability 0.010136 # Symbol H probability 0.052956 # Symbol I probability 0.027937 # Symbol K probability 0.034589 # Symbol L probability 0.019970 # Symbol M probability 0.010961 # Symbol N probability 0.006143 # Symbol P probability 0.047062 # Symbol Q probability 0.011018 # Symbol R probability 0.026616 # Symbol S probability 0.019217 # Symbol T probability 0.032087 # Symbol V probability 0.001272 # Symbol W probability 0.185445 # Symbol Y probability ###DELETE_STATE 44 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 44 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 45 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.331773 # Symbol A probability 0.070724 # Symbol C probability 0.005681 # Symbol D probability 0.006004 # Symbol E probability 0.004821 # Symbol F probability 0.441044 # Symbol G probability 0.004075 # Symbol H probability 0.004472 # Symbol I probability 0.009755 # Symbol K probability 0.016407 # Symbol L probability 0.001788 # Symbol M probability 0.004901 # Symbol N probability 0.006143 # Symbol P probability 0.004638 # Symbol Q probability 0.011018 # Symbol R probability 0.020555 # Symbol S probability 0.013156 # Symbol T probability 0.038148 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 45 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 45 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 46 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.016622 # Symbol A probability 0.004057 # Symbol C probability 0.005681 # Symbol D probability 0.006004 # Symbol E probability 0.677548 # Symbol F probability 0.016801 # Symbol G probability 0.004075 # Symbol H probability 0.028714 # Symbol I probability 0.009755 # Symbol K probability 0.058832 # Symbol L probability 0.007848 # Symbol M probability 0.004901 # Symbol N probability 0.006143 # Symbol P probability 0.004638 # Symbol Q probability 0.004958 # Symbol R probability 0.008434 # Symbol S probability 0.013156 # Symbol T probability 0.032087 # Symbol V probability 0.001272 # Symbol W probability 0.088475 # Symbol Y probability ###DELETE_STATE 46 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 46 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 47 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.016622 # Symbol A probability 0.010118 # Symbol C probability 0.005681 # Symbol D probability 0.012064 # Symbol E probability 0.004821 # Symbol F probability 0.010741 # Symbol G probability 0.004075 # Symbol H probability 0.234775 # Symbol I probability 0.009755 # Symbol K probability 0.034589 # Symbol L probability 0.001788 # Symbol M probability 0.004901 # Symbol N probability 0.006143 # Symbol P probability 0.004638 # Symbol Q probability 0.004958 # Symbol R probability 0.008434 # Symbol S probability 0.007096 # Symbol T probability 0.613905 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 47 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 47 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 48 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.034804 # Symbol A probability 0.034360 # Symbol C probability 0.054166 # Symbol D probability 0.212064 # Symbol E probability 0.004821 # Symbol F probability 0.016801 # Symbol G probability 0.040439 # Symbol H probability 0.010532 # Symbol I probability 0.058240 # Symbol K probability 0.010347 # Symbol L probability 0.001788 # Symbol M probability 0.071567 # Symbol N probability 0.006143 # Symbol P probability 0.047062 # Symbol Q probability 0.047382 # Symbol R probability 0.044798 # Symbol S probability 0.273762 # Symbol T probability 0.019966 # Symbol V probability 0.007332 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 48 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 48 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 49 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.010561 # Symbol A probability 0.004057 # Symbol C probability 0.005681 # Symbol D probability 0.012064 # Symbol E probability 0.629063 # Symbol F probability 0.010741 # Symbol G probability 0.004075 # Symbol H probability 0.004472 # Symbol I probability 0.009755 # Symbol K probability 0.034589 # Symbol L probability 0.074515 # Symbol M probability 0.004901 # Symbol N probability 0.006143 # Symbol P probability 0.004638 # Symbol Q probability 0.004958 # Symbol R probability 0.008434 # Symbol S probability 0.007096 # Symbol T probability 0.013905 # Symbol V probability 0.001272 # Symbol W probability 0.149081 # Symbol Y probability ###DELETE_STATE 49 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 49 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 50 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.089349 # Symbol A probability 0.004057 # Symbol C probability 0.126893 # Symbol D probability 0.199943 # Symbol E probability 0.010881 # Symbol F probability 0.016801 # Symbol G probability 0.016196 # Symbol H probability 0.010532 # Symbol I probability 0.118846 # Symbol K probability 0.028528 # Symbol L probability 0.007848 # Symbol M probability 0.041264 # Symbol N probability 0.024325 # Symbol P probability 0.022819 # Symbol Q probability 0.011018 # Symbol R probability 0.147828 # Symbol S probability 0.061641 # Symbol T probability 0.044208 # Symbol V probability 0.001272 # Symbol W probability 0.015748 # Symbol Y probability ###DELETE_STATE 50 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 50 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 51 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.016622 # Symbol A probability 0.010118 # Symbol C probability 0.145075 # Symbol D probability 0.090852 # Symbol E probability 0.004821 # Symbol F probability 0.028922 # Symbol G probability 0.010136 # Symbol H probability 0.010532 # Symbol I probability 0.088543 # Symbol K probability 0.010347 # Symbol L probability 0.007848 # Symbol M probability 0.113992 # Symbol N probability 0.012204 # Symbol P probability 0.041001 # Symbol Q probability 0.041321 # Symbol R probability 0.214495 # Symbol S probability 0.134368 # Symbol T probability 0.007845 # Symbol V probability 0.001272 # Symbol W probability 0.009687 # Symbol Y probability ###DELETE_STATE 51 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 51 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 52 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.065107 # Symbol A probability 0.004057 # Symbol C probability 0.017802 # Symbol D probability 0.248428 # Symbol E probability 0.016942 # Symbol F probability 0.016801 # Symbol G probability 0.094984 # Symbol H probability 0.010532 # Symbol I probability 0.070361 # Symbol K probability 0.028528 # Symbol L probability 0.032091 # Symbol M probability 0.004901 # Symbol N probability 0.109173 # Symbol P probability 0.041001 # Symbol Q probability 0.047382 # Symbol R probability 0.044798 # Symbol S probability 0.037399 # Symbol T probability 0.062390 # Symbol V probability 0.001272 # Symbol W probability 0.046051 # Symbol Y probability ###DELETE_STATE 52 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 52 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 53 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.071167 # Symbol A probability 0.004057 # Symbol C probability 0.157196 # Symbol D probability 0.399943 # Symbol E probability 0.004821 # Symbol F probability 0.028922 # Symbol G probability 0.016196 # Symbol H probability 0.034775 # Symbol I probability 0.027937 # Symbol K probability 0.028528 # Symbol L probability 0.007848 # Symbol M probability 0.023082 # Symbol N probability 0.024325 # Symbol P probability 0.034941 # Symbol Q probability 0.035261 # Symbol R probability 0.038737 # Symbol S probability 0.019217 # Symbol T probability 0.032087 # Symbol V probability 0.001272 # Symbol W probability 0.009687 # Symbol Y probability ###DELETE_STATE 53 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 53 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 54 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.131773 # Symbol A probability 0.010118 # Symbol C probability 0.217802 # Symbol D probability 0.175701 # Symbol E probability 0.004821 # Symbol F probability 0.034983 # Symbol G probability 0.004075 # Symbol H probability 0.016593 # Symbol I probability 0.009755 # Symbol K probability 0.022468 # Symbol L probability 0.013909 # Symbol M probability 0.017022 # Symbol N probability 0.090992 # Symbol P probability 0.047062 # Symbol Q probability 0.004958 # Symbol R probability 0.129646 # Symbol S probability 0.019217 # Symbol T probability 0.038148 # Symbol V probability 0.001272 # Symbol W probability 0.009687 # Symbol Y probability ###DELETE_STATE 54 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 54 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 55 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.513592 # Symbol A probability 0.004057 # Symbol C probability 0.011742 # Symbol D probability 0.006004 # Symbol E probability 0.016942 # Symbol F probability 0.022862 # Symbol G probability 0.004075 # Symbol H probability 0.028714 # Symbol I probability 0.009755 # Symbol K probability 0.046710 # Symbol L probability 0.044212 # Symbol M probability 0.004901 # Symbol N probability 0.006143 # Symbol P probability 0.004638 # Symbol Q probability 0.011018 # Symbol R probability 0.032676 # Symbol S probability 0.013156 # Symbol T probability 0.213905 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 55 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 55 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 56 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.077228 # Symbol A probability 0.016178 # Symbol C probability 0.139015 # Symbol D probability 0.199943 # Symbol E probability 0.004821 # Symbol F probability 0.028922 # Symbol G probability 0.010136 # Symbol H probability 0.016593 # Symbol I probability 0.137028 # Symbol K probability 0.034589 # Symbol L probability 0.007848 # Symbol M probability 0.065507 # Symbol N probability 0.012204 # Symbol P probability 0.077365 # Symbol Q probability 0.035261 # Symbol R probability 0.020555 # Symbol S probability 0.079823 # Symbol T probability 0.032087 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 56 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 56 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 57 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.131773 # Symbol A probability 0.010118 # Symbol C probability 0.060227 # Symbol D probability 0.066610 # Symbol E probability 0.004821 # Symbol F probability 0.010741 # Symbol G probability 0.028318 # Symbol H probability 0.028714 # Symbol I probability 0.337028 # Symbol K probability 0.022468 # Symbol L probability 0.019970 # Symbol M probability 0.059446 # Symbol N probability 0.006143 # Symbol P probability 0.047062 # Symbol Q probability 0.059503 # Symbol R probability 0.038737 # Symbol S probability 0.037399 # Symbol T probability 0.019966 # Symbol V probability 0.001272 # Symbol W probability 0.009687 # Symbol Y probability ###DELETE_STATE 57 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 57 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 58 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.640864 # Symbol A probability 0.028299 # Symbol C probability 0.005681 # Symbol D probability 0.006004 # Symbol E probability 0.004821 # Symbol F probability 0.010741 # Symbol G probability 0.004075 # Symbol H probability 0.101441 # Symbol I probability 0.009755 # Symbol K probability 0.034589 # Symbol L probability 0.013909 # Symbol M probability 0.010961 # Symbol N probability 0.006143 # Symbol P probability 0.004638 # Symbol Q probability 0.004958 # Symbol R probability 0.026616 # Symbol S probability 0.013156 # Symbol T probability 0.068451 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 58 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 58 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 59 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.022682 # Symbol A probability 0.034360 # Symbol C probability 0.005681 # Symbol D probability 0.012064 # Symbol E probability 0.023002 # Symbol F probability 0.016801 # Symbol G probability 0.004075 # Symbol H probability 0.222653 # Symbol I probability 0.082482 # Symbol K probability 0.204286 # Symbol L probability 0.098758 # Symbol M probability 0.004901 # Symbol N probability 0.006143 # Symbol P probability 0.016759 # Symbol Q probability 0.023139 # Symbol R probability 0.020555 # Symbol S probability 0.007096 # Symbol T probability 0.183602 # Symbol V probability 0.001272 # Symbol W probability 0.009687 # Symbol Y probability ###DELETE_STATE 59 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 59 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 60 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.113592 # Symbol A probability 0.004057 # Symbol C probability 0.114772 # Symbol D probability 0.242367 # Symbol E probability 0.010881 # Symbol F probability 0.010741 # Symbol G probability 0.004075 # Symbol H probability 0.040835 # Symbol I probability 0.064301 # Symbol K probability 0.058832 # Symbol L probability 0.001788 # Symbol M probability 0.083688 # Symbol N probability 0.006143 # Symbol P probability 0.053122 # Symbol Q probability 0.059503 # Symbol R probability 0.032676 # Symbol S probability 0.055581 # Symbol T probability 0.032087 # Symbol V probability 0.001272 # Symbol W probability 0.009687 # Symbol Y probability ###DELETE_STATE 60 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 60 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 61 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.180258 # Symbol A probability 0.004057 # Symbol C probability 0.017802 # Symbol D probability 0.133276 # Symbol E probability 0.004821 # Symbol F probability 0.041044 # Symbol G probability 0.034378 # Symbol H probability 0.016593 # Symbol I probability 0.112785 # Symbol K probability 0.052771 # Symbol L probability 0.026030 # Symbol M probability 0.035204 # Symbol N probability 0.006143 # Symbol P probability 0.095547 # Symbol Q probability 0.023139 # Symbol R probability 0.105404 # Symbol S probability 0.055581 # Symbol T probability 0.032087 # Symbol V probability 0.001272 # Symbol W probability 0.021808 # Symbol Y probability ###DELETE_STATE 61 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 61 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 62 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.022682 # Symbol A probability 0.040421 # Symbol C probability 0.017802 # Symbol D probability 0.018125 # Symbol E probability 0.016942 # Symbol F probability 0.016801 # Symbol G probability 0.028318 # Symbol H probability 0.010532 # Symbol I probability 0.149149 # Symbol K probability 0.325498 # Symbol L probability 0.147242 # Symbol M probability 0.029143 # Symbol N probability 0.018264 # Symbol P probability 0.004638 # Symbol Q probability 0.053442 # Symbol R probability 0.014495 # Symbol S probability 0.025278 # Symbol T probability 0.038148 # Symbol V probability 0.001272 # Symbol W probability 0.021808 # Symbol Y probability ###DELETE_STATE 62 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 62 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 63 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.022682 # Symbol A probability 0.004057 # Symbol C probability 0.090530 # Symbol D probability 0.048428 # Symbol E probability 0.047245 # Symbol F probability 0.047104 # Symbol G probability 0.034378 # Symbol H probability 0.004472 # Symbol I probability 0.021876 # Symbol K probability 0.010347 # Symbol L probability 0.001788 # Symbol M probability 0.380658 # Symbol N probability 0.048567 # Symbol P probability 0.077365 # Symbol Q probability 0.017079 # Symbol R probability 0.032676 # Symbol S probability 0.031338 # Symbol T probability 0.007845 # Symbol V probability 0.001272 # Symbol W probability 0.070293 # Symbol Y probability ###DELETE_STATE 63 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 63 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 64 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.010561 # Symbol A probability 0.004057 # Symbol C probability 0.042045 # Symbol D probability 0.036307 # Symbol E probability 0.016942 # Symbol F probability 0.410741 # Symbol G probability 0.191954 # Symbol H probability 0.010532 # Symbol I probability 0.052179 # Symbol K probability 0.028528 # Symbol L probability 0.001788 # Symbol M probability 0.053385 # Symbol N probability 0.006143 # Symbol P probability 0.028880 # Symbol Q probability 0.011018 # Symbol R probability 0.038737 # Symbol S probability 0.019217 # Symbol T probability 0.007845 # Symbol V probability 0.001272 # Symbol W probability 0.027869 # Symbol Y probability ###DELETE_STATE 64 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 64 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 65 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.034804 # Symbol A probability 0.004057 # Symbol C probability 0.023863 # Symbol D probability 0.042367 # Symbol E probability 0.053305 # Symbol F probability 0.041044 # Symbol G probability 0.022257 # Symbol H probability 0.046896 # Symbol I probability 0.167331 # Symbol K probability 0.022468 # Symbol L probability 0.068455 # Symbol M probability 0.047325 # Symbol N probability 0.006143 # Symbol P probability 0.095547 # Symbol Q probability 0.059503 # Symbol R probability 0.044798 # Symbol S probability 0.134368 # Symbol T probability 0.038148 # Symbol V probability 0.001272 # Symbol W probability 0.046051 # Symbol Y probability ###DELETE_STATE 65 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 65 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 66 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.016622 # Symbol A probability 0.010118 # Symbol C probability 0.060227 # Symbol D probability 0.121155 # Symbol E probability 0.004821 # Symbol F probability 0.016801 # Symbol G probability 0.004075 # Symbol H probability 0.107502 # Symbol I probability 0.082482 # Symbol K probability 0.119438 # Symbol L probability 0.038152 # Symbol M probability 0.023082 # Symbol N probability 0.042507 # Symbol P probability 0.028880 # Symbol Q probability 0.035261 # Symbol R probability 0.038737 # Symbol S probability 0.049520 # Symbol T probability 0.171481 # Symbol V probability 0.013393 # Symbol W probability 0.015748 # Symbol Y probability ###DELETE_STATE 66 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 66 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 67 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.022682 # Symbol A probability 0.004057 # Symbol C probability 0.048105 # Symbol D probability 0.006004 # Symbol E probability 0.089669 # Symbol F probability 0.059225 # Symbol G probability 0.004075 # Symbol H probability 0.186290 # Symbol I probability 0.040058 # Symbol K probability 0.192165 # Symbol L probability 0.038152 # Symbol M probability 0.077628 # Symbol N probability 0.042507 # Symbol P probability 0.004638 # Symbol Q probability 0.023139 # Symbol R probability 0.032676 # Symbol S probability 0.013156 # Symbol T probability 0.098754 # Symbol V probability 0.001272 # Symbol W probability 0.015748 # Symbol Y probability ###DELETE_STATE 67 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 67 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 68 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.059046 # Symbol A probability 0.004057 # Symbol C probability 0.102651 # Symbol D probability 0.048428 # Symbol E probability 0.029063 # Symbol F probability 0.204680 # Symbol G probability 0.016196 # Symbol H probability 0.010532 # Symbol I probability 0.064301 # Symbol K probability 0.089135 # Symbol L probability 0.001788 # Symbol M probability 0.144295 # Symbol N probability 0.006143 # Symbol P probability 0.022819 # Symbol Q probability 0.047382 # Symbol R probability 0.062979 # Symbol S probability 0.031338 # Symbol T probability 0.019966 # Symbol V probability 0.001272 # Symbol W probability 0.033930 # Symbol Y probability ###DELETE_STATE 68 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 68 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 69 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.016622 # Symbol A probability 0.004057 # Symbol C probability 0.060227 # Symbol D probability 0.042367 # Symbol E probability 0.010881 # Symbol F probability 0.331953 # Symbol G probability 0.046499 # Symbol H probability 0.010532 # Symbol I probability 0.082482 # Symbol K probability 0.046710 # Symbol L probability 0.001788 # Symbol M probability 0.077628 # Symbol N probability 0.024325 # Symbol P probability 0.022819 # Symbol Q probability 0.059503 # Symbol R probability 0.117525 # Symbol S probability 0.025278 # Symbol T probability 0.013905 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 69 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 69 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 70 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.040864 # Symbol A probability 0.010118 # Symbol C probability 0.029924 # Symbol D probability 0.042367 # Symbol E probability 0.016942 # Symbol F probability 0.028922 # Symbol G probability 0.022257 # Symbol H probability 0.010532 # Symbol I probability 0.227937 # Symbol K probability 0.010347 # Symbol L probability 0.013909 # Symbol M probability 0.083688 # Symbol N probability 0.012204 # Symbol P probability 0.022819 # Symbol Q probability 0.265564 # Symbol R probability 0.044798 # Symbol S probability 0.061641 # Symbol T probability 0.044208 # Symbol V probability 0.001272 # Symbol W probability 0.009687 # Symbol Y probability ###DELETE_STATE 70 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 70 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 71 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.077228 # Symbol A probability 0.101027 # Symbol C probability 0.011742 # Symbol D probability 0.054488 # Symbol E probability 0.010881 # Symbol F probability 0.034983 # Symbol G probability 0.022257 # Symbol H probability 0.059017 # Symbol I probability 0.070361 # Symbol K probability 0.040650 # Symbol L probability 0.007848 # Symbol M probability 0.041264 # Symbol N probability 0.121295 # Symbol P probability 0.059183 # Symbol Q probability 0.041321 # Symbol R probability 0.062979 # Symbol S probability 0.049520 # Symbol T probability 0.129057 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 71 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 71 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 72 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.028743 # Symbol A probability 0.034360 # Symbol C probability 0.078408 # Symbol D probability 0.163579 # Symbol E probability 0.016942 # Symbol F probability 0.016801 # Symbol G probability 0.016196 # Symbol H probability 0.143865 # Symbol I probability 0.027937 # Symbol K probability 0.192165 # Symbol L probability 0.026030 # Symbol M probability 0.004901 # Symbol N probability 0.012204 # Symbol P probability 0.034941 # Symbol Q probability 0.011018 # Symbol R probability 0.026616 # Symbol S probability 0.025278 # Symbol T probability 0.122996 # Symbol V probability 0.013393 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 72 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 72 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 73 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.010561 # Symbol A probability 0.016178 # Symbol C probability 0.017802 # Symbol D probability 0.018125 # Symbol E probability 0.029063 # Symbol F probability 0.010741 # Symbol G probability 0.016196 # Symbol H probability 0.077199 # Symbol I probability 0.082482 # Symbol K probability 0.070953 # Symbol L probability 0.026030 # Symbol M probability 0.017022 # Symbol N probability 0.121295 # Symbol P probability 0.022819 # Symbol Q probability 0.162533 # Symbol R probability 0.026616 # Symbol S probability 0.061641 # Symbol T probability 0.104815 # Symbol V probability 0.007332 # Symbol W probability 0.100596 # Symbol Y probability ###DELETE_STATE 73 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 73 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 74 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.022682 # Symbol A probability 0.028299 # Symbol C probability 0.011742 # Symbol D probability 0.030246 # Symbol E probability 0.004821 # Symbol F probability 0.010741 # Symbol G probability 0.004075 # Symbol H probability 0.107502 # Symbol I probability 0.197634 # Symbol K probability 0.095195 # Symbol L probability 0.001788 # Symbol M probability 0.004901 # Symbol N probability 0.018264 # Symbol P probability 0.004638 # Symbol Q probability 0.071624 # Symbol R probability 0.020555 # Symbol S probability 0.043459 # Symbol T probability 0.304815 # Symbol V probability 0.001272 # Symbol W probability 0.015748 # Symbol Y probability ###DELETE_STATE 74 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 74 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 75 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.071167 # Symbol A probability 0.004057 # Symbol C probability 0.048105 # Symbol D probability 0.042367 # Symbol E probability 0.023002 # Symbol F probability 0.095589 # Symbol G probability 0.010136 # Symbol H probability 0.034775 # Symbol I probability 0.143088 # Symbol K probability 0.010347 # Symbol L probability 0.032091 # Symbol M probability 0.089749 # Symbol N probability 0.030385 # Symbol P probability 0.010698 # Symbol Q probability 0.095867 # Symbol R probability 0.069040 # Symbol S probability 0.025278 # Symbol T probability 0.116936 # Symbol V probability 0.007332 # Symbol W probability 0.039990 # Symbol Y probability ###DELETE_STATE 75 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 75 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 76 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.228743 # Symbol A probability 0.010118 # Symbol C probability 0.011742 # Symbol D probability 0.018125 # Symbol E probability 0.071487 # Symbol F probability 0.022862 # Symbol G probability 0.016196 # Symbol H probability 0.052956 # Symbol I probability 0.021876 # Symbol K probability 0.083074 # Symbol L probability 0.013909 # Symbol M probability 0.017022 # Symbol N probability 0.042507 # Symbol P probability 0.016759 # Symbol Q probability 0.077685 # Symbol R probability 0.038737 # Symbol S probability 0.025278 # Symbol T probability 0.080572 # Symbol V probability 0.092181 # Symbol W probability 0.058172 # Symbol Y probability ###DELETE_STATE 76 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 76 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 77 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.240864 # Symbol A probability 0.004057 # Symbol C probability 0.048105 # Symbol D probability 0.018125 # Symbol E probability 0.083608 # Symbol F probability 0.041044 # Symbol G probability 0.016196 # Symbol H probability 0.028714 # Symbol I probability 0.082482 # Symbol K probability 0.064892 # Symbol L probability 0.038152 # Symbol M probability 0.010961 # Symbol N probability 0.018264 # Symbol P probability 0.077365 # Symbol Q probability 0.017079 # Symbol R probability 0.105404 # Symbol S probability 0.043459 # Symbol T probability 0.050269 # Symbol V probability 0.001272 # Symbol W probability 0.009687 # Symbol Y probability ###DELETE_STATE 77 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 77 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 78 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.113592 # Symbol A probability 0.022239 # Symbol C probability 0.011742 # Symbol D probability 0.042367 # Symbol E probability 0.059366 # Symbol F probability 0.059225 # Symbol G probability 0.004075 # Symbol H probability 0.016593 # Symbol I probability 0.076422 # Symbol K probability 0.028528 # Symbol L probability 0.001788 # Symbol M probability 0.010961 # Symbol N probability 0.109173 # Symbol P probability 0.131910 # Symbol Q probability 0.065564 # Symbol R probability 0.123585 # Symbol S probability 0.067702 # Symbol T probability 0.038148 # Symbol V probability 0.001272 # Symbol W probability 0.015748 # Symbol Y probability ###DELETE_STATE 78 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 78 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 79 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.046925 # Symbol A probability 0.004057 # Symbol C probability 0.017802 # Symbol D probability 0.090852 # Symbol E probability 0.004821 # Symbol F probability 0.022862 # Symbol G probability 0.022257 # Symbol H probability 0.004472 # Symbol I probability 0.258240 # Symbol K probability 0.028528 # Symbol L probability 0.001788 # Symbol M probability 0.041264 # Symbol N probability 0.090992 # Symbol P probability 0.022819 # Symbol Q probability 0.180715 # Symbol R probability 0.111464 # Symbol S probability 0.025278 # Symbol T probability 0.019966 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 79 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 79 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 80 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.046925 # Symbol A probability 0.010118 # Symbol C probability 0.060227 # Symbol D probability 0.121155 # Symbol E probability 0.004821 # Symbol F probability 0.047104 # Symbol G probability 0.010136 # Symbol H probability 0.016593 # Symbol I probability 0.221876 # Symbol K probability 0.010347 # Symbol L probability 0.007848 # Symbol M probability 0.047325 # Symbol N probability 0.078870 # Symbol P probability 0.077365 # Symbol Q probability 0.126170 # Symbol R probability 0.075101 # Symbol S probability 0.025278 # Symbol T probability 0.007845 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 80 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 80 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 81 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.089349 # Symbol A probability 0.004057 # Symbol C probability 0.066287 # Symbol D probability 0.133276 # Symbol E probability 0.010881 # Symbol F probability 0.101650 # Symbol G probability 0.028318 # Symbol H probability 0.010532 # Symbol I probability 0.058240 # Symbol K probability 0.040650 # Symbol L probability 0.013909 # Symbol M probability 0.029143 # Symbol N probability 0.103113 # Symbol P probability 0.071304 # Symbol Q probability 0.023139 # Symbol R probability 0.105404 # Symbol S probability 0.037399 # Symbol T probability 0.062390 # Symbol V probability 0.007332 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 81 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 81 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 82 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.083288 # Symbol A probability 0.004057 # Symbol C probability 0.048105 # Symbol D probability 0.139337 # Symbol E probability 0.010881 # Symbol F probability 0.028922 # Symbol G probability 0.028318 # Symbol H probability 0.034775 # Symbol I probability 0.070361 # Symbol K probability 0.022468 # Symbol L probability 0.068455 # Symbol M probability 0.047325 # Symbol N probability 0.066749 # Symbol P probability 0.053122 # Symbol Q probability 0.035261 # Symbol R probability 0.129646 # Symbol S probability 0.025278 # Symbol T probability 0.038148 # Symbol V probability 0.001272 # Symbol W probability 0.064233 # Symbol Y probability ###DELETE_STATE 82 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 82 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 83 ( ) ( ) 0.999392 # t_m1 0.000203 # t_d1 0.000405 # t_i0 0.119652 # Symbol A probability 0.004057 # Symbol C probability 0.035984 # Symbol D probability 0.036307 # Symbol E probability 0.029063 # Symbol F probability 0.077407 # Symbol G probability 0.004075 # Symbol H probability 0.028714 # Symbol I probability 0.076422 # Symbol K probability 0.070953 # Symbol L probability 0.013909 # Symbol M probability 0.035204 # Symbol N probability 0.042507 # Symbol P probability 0.131910 # Symbol Q probability 0.174655 # Symbol R probability 0.075101 # Symbol S probability 0.025278 # Symbol T probability 0.013905 # Symbol V probability 0.001272 # Symbol W probability 0.003627 # Symbol Y probability ###DELETE_STATE 83 0.930000 # t_m1 0.050000 # t_d1 0.020000 # t_i0 ###INSERT_STATE 83 0.590000 # t_m1 0.020000 # t_d1 0.390000 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability ###MATCH_STATE 84 ( ) ( ) 0.999595 # t_m1 0.000000 # t_d1 0.000405 # t_i0 0.101470 # Symbol A probability 0.004057 # Symbol C probability 0.035984 # Symbol D probability 0.078731 # Symbol E probability 0.016942 # Symbol F probability 0.083468 # Symbol G probability 0.010136 # Symbol H probability 0.034775 # Symbol I probability 0.040058 # Symbol K probability 0.070953 # Symbol L probability 0.026030 # Symbol M probability 0.053385 # Symbol N probability 0.048567 # Symbol P probability 0.150092 # Symbol Q probability 0.138291 # Symbol R probability 0.062979 # Symbol S probability 0.019217 # Symbol T probability 0.013905 # Symbol V probability 0.001272 # Symbol W probability 0.009687 # Symbol Y probability ###DELETE_STATE 84 0.978947 # t_m1 0.000000 # t_d1 0.021053 # t_i0 ###INSERT_STATE 84 0.602041 # t_m1 0.000000 # t_d1 0.397959 # t_i0 0.087130 # Symbol A probability 0.033470 # Symbol C probability 0.046870 # Symbol D probability 0.049530 # Symbol E probability 0.039770 # Symbol F probability 0.088610 # Symbol G probability 0.033620 # Symbol H probability 0.036890 # Symbol I probability 0.080480 # Symbol K probability 0.085360 # Symbol L probability 0.014750 # Symbol M probability 0.040430 # Symbol N probability 0.050680 # Symbol P probability 0.038260 # Symbol Q probability 0.040900 # Symbol R probability 0.069580 # Symbol S probability 0.058540 # Symbol T probability 0.064720 # Symbol V probability 0.010490 # Symbol W probability 0.029920 # Symbol Y probability wise-2.4.1/src/test/pw.human0000644000175000001440000000147407627664202015320 0ustar philippusers>EM:HSKER101 [2995-3735] M24842 Human keratin 18 (K18) gene, complete cds. AGGTAAGGGGTAGGAGGGACCTCAACTCCCAGCCTTGTCTGACCCTCCAATTATACACTCC TTTGCCTCTTTCCGTCATTCCATAACCACCCCAACCCCTACTCCACCGGGAGGGGGTTGG GCATACCTGGATTTCCATCCGCGCACCTAGCCACAGGGTCCCTAAGAGCAGCAGCAGCTA GGCATGGGAGGGCTCTTTCCCAGGAGAGAGGGGGAAGGGGACAGGGTTGAGAGCTTTACA GAGGAAGTGGACAGCATGGAGGGAGGTAAGGAAAGGCCTGTAAAGAGGAGGAGACACTGG CTCTGGCGGAATGGGGACTATTGGAGGGTTAAGCGGATGTGGCTAAGGCTGAGTCATCTA GGAGTAAACAAGAGGCCTTCCTTTGGGAGGAGCCAATCCAGGGTGTAGGGGGCCCAGAGT GACCAGGTGCACTAGGGAAAAAATGCCAGGAGAGGGCCAGGAAGAGGACTTGTTAGTAGC GACTCACTTCTGGGCAGGCAGGCCAGCCAGCTAGCCAGCCTGCTGAGGCTTCCCAAGAGG GGCAGAGTGCTGGGATCTGGGAATCCAGGAAAGGAGGGAATGGGGTGGGGCTAGATGAAA AGGGATAGGTGTCCAGGGAGAGCCTCTGGCTATTCCTGGGACCAGGAAGTTTTCACTAGG ATACATAACACTTTTTACACACTCACCCCACCCATCCCTGGCTTTCTATTCATGGAACAA CCTCTCTCTACAATCCCTCCwise-2.4.1/src/test/pw.mouse0000644000175000001440000000157707627664202015344 0ustar philippusers>EM:MMENDOBA [2729-3525] M22832 Mus musculus cytokeratin (endoB) gene, complete cds. ACCTGAGGGCTCAGGTAAGGGGCCTAAGGGGGGAGGGGCAGTAGCTCCGGGCTGTTCTGTC TATCCAGTGTGCCCACACCCCCAAACTTCAATAGAGTGTGGGCTGTTGACTCCCTCCACT CTTTCCACATTCACCACATCCCCCCACACACACTCTATGGGACGGAGTTAGGAATACTCT GGACTCTCACCCACAACCTGTAGGAATTCCAAGCGTAGTGGTTACACACGCGAGCCGGCT TCCCCCAAGCAGTGTAGTGGGAAGAGAACAGGATTGGAAAAAAAATAAAATAAAAAGGTG TGTGTGGGGGAATCATAAAATGAACTCAGACACTCACTTCTTTTCCAGTAGGAACAGTTA GAGGGTTAAGCGGATGTGGCTAAGGGTGAGTCATCTAGGAGTAAACAGGAGCTTACCTGT AGGAGGGGCCAGCGGGACAAGTGGGGGGGGGGCGCGTCCCAGGACGGGGGGGGGGGGGGG GGGGGTTAGCAGGTGCACCTGGAGAAGATGCCAGGAGAGGATCAGAGAAATCTTGTTGGA AGCTGCTCTTTTGTAAGCAATCCAGATAGTGCAGGCCCTGGCAGAGGGGCAAGGAATCCA GGAAGGGAGAGGAGGCTCAGGTGGGAAGGGAAGACAGAAATACACGCCTCTGACTGTTCC TGGGACTGGGATGGATTCACTGAAACACAAGACGTGTTTTCTCATCCCCCACTTCTCCAC ACACACACACACACACACACACACACACACACCCTCATGTGACCCGGAACTCTCAAAGCG ACTCTCTCCACTTTAAwise-2.4.1/src/test/genewise-db-lite.out0000644000175000001440000004334007345677446017526 0ustar philippusersWise2 - database searching mode Program: genewisedb version: $Name: wise2-4-1 $ released: unreleased This program is freely distributed under a Gnu Public License. See -version for more info on copyright Bugs and credits to Ewan Birney ----------------------------------------------------- Algorithm type: GeneWise Search algorithm used: 6LITE Implementation: Single Threaded processor (serial) Search mode: Single protein vs genomic db Protein info from: rrm.HMM Dna info from: dna.db Start/End (protein) global Gene Paras: human.gf Codon Table: codon.table Subs error: 1e-05 Indel error: 1e-05 Model splice? model Model codon bias? flat Model intron bias? tied Null model syn Alignment Alg 623L [Warning: Can't fit histogram to a db smaller than 1,000] # #WARNING! # # Your alignment algorithm is different from your search algorithm. # This is probably quite sensible but will lead to differing scores. # Use the search score as an indicator of the significance of the match # Read the docs for more information # #High Score list #Protein ID DNA Str ID Bits Evalue -------------------------------------------------------------------------- Protein SEED DNA [+] MMD728 101.74 Protein SEED DNA [+] MMD729 101.74 Protein SEED DNA [+] MMFLI2X 101.74 Protein SEED DNA [+] SAHNRNPH 86.11 #Alignments ----------------------------------------------------------------------- >Results for SEED vs MMD728 (forward) [0] genewisedb output Score 179.66 bits over entire alignment. This will be different from per-alignment scores. See manual for details For computer parsable output, try genewisedb -help or read the manual Scores as bits over a synchronous coding model Alignment 1 Score 86.15 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF LF+G+L++++T+E L+ +F++ G +++ ++RD ++T++S+GF+F LFIGGLSFETTDESLRSHFEQWGTLTDCVVMRD-----PNTKRSRGFGF MMD728 70 ctaggcatgaaggacaactgctgacagtggaag caaaatagtgt tttggtgtaccaagtggataaggctcagtttga cacagcggtgt cccaggccaaccgtggcttgagaaaactgagat accgacgctgt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+++++E++++A++ ++++GR+++ VTYATVEEVDAAMN-ARPHKVDGRVVEP MMD728 202 gatgagggggggaa gaccagggagggc tcacctaataccta cgcaataggttac catctgaagttcgt aaacggtaatgat Alignment 2 Score 93.51 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF FVG++ +D+ E+ L+D+F+++G+I+ I+I++D + GK +GFAF IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTD-----RGSGKKRGFAF MMD728 343 atgggaaggaggccccgttgctgaaggagaaag agagaaagtgt tttggtaaacaaaatgaataaagatattattca ggggaaggtct ctttttaactaatcaatttggtggtagaatgtc actgaggcttt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+F+++++++K + ++++G++++V VTFDDHDSVDKIVI-QKYHTVNGHNCEV MMD728 475 gatggcgtggaaga catcagagcatgg tctaaaactaattt aaaactagaagat tcttctctgtgttt gacttgtccctaa // Gene 1 Gene 70 282 Exon 70 282 phase 0 Gene 2 Gene 343 555 Exon 343 555 phase 0 // >MMD728.[70:282].sp.tr LFIGGLSFETTDESLRSHFEQWGTLTDCVVMRDPNTKRSRGFGFVTYATVEEVDAAMNAR PHKVDGRVVEP >MMD728.[343:555].sp.tr IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAFVTFDDHDSVDKIVIQK YHTVNGHNCEV // >MMD728.[70:282].sp CTCTTCATCGGAGGGCTGAGCTTCGAAACAACCGACGAGAGTCTGAGGAGCCATTTTGAG CAATGGGGAACACTAACAGACTGTGTGGTAATGAGAGATCCAAACACCAAGAGATCCAGG GGCTTTGGGTTTGTCACATATGCCACTGTGGAAGAAGTGGATGCTGCCATGAATGCAAGA CCACACAAGGTGGATGGAAGAGTTGTGGAACCT >MMD728.[343:555].sp ATCTTTGTTGGTGGTATTAAAGAAGACACTGAAGAACATCACCTACGAGATTATTTTGAG CAGTATGGGAAGATTGAAGTGATAGAAATTATGACTGACAGAGGCAGTGGGAAAAAGAGG GGCTTTGCTTTTGTTACCTTTGATGACCATGACTCTGTGGATAAGATTGTTATTCAGAAA TACCATACTGTGAATGGCCACAACTGTGAAGTA // Sequence MMD728 subsequence MMD728.1 70 282 Sequence MMD728.1 CDS Start_not_found End_not_found CDS_predicted_by genewise 86.15 source_Exons 1 213 Sequence MMD728 subsequence MMD728.2 343 555 Sequence MMD728.2 CDS Start_not_found End_not_found CDS_predicted_by genewise 93.51 source_Exons 1 213 // Gene 0 Gene 69 - 282 Transcript 0 Exon 0-213 Translation 0 - 213 Gene 1 Gene 342 - 555 Transcript 0 Exon 0-213 Translation 0 - 213 // >Results for SEED vs MMD729 (forward) [1] genewisedb output Score 179.66 bits over entire alignment. This will be different from per-alignment scores. See manual for details For computer parsable output, try genewisedb -help or read the manual Scores as bits over a synchronous coding model Alignment 1 Score 86.15 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF LF+G+L++++T+E L+ +F++ G +++ ++RD ++T++S+GF+F LFIGGLSFETTDESLRSHFEQWGTLTDCVVMRD-----PNTKRSRGFGF MMD729 70 ctaggcatgaaggacaactgctgacagtggaag caaaatagtgt tttggtgtaccaagtggataaggctcagtttga cacagcggtgt cccaggccaaccgtggcttgagaaaactgagat accgacgctgt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+++++E++++A++ ++++GR+++ VTYATVEEVDAAMN-ARPHKVDGRVVEP MMD729 202 gatgagggggggaa gaccagggagggc tcacctaataccta cgcaataggttac catctgaagttcgt aaacggtaatgat Alignment 2 Score 93.51 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF FVG++ +D+ E+ L+D+F+++G+I+ I+I++D + GK +GFAF IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTD-----RGSGKKRGFAF MMD729 343 atgggaaggaggccccgttgctgaaggagaaag agagaaagtgt tttggtaaacaaaatgaataaagatattattca ggggaaggtct ctttttaactaatcaatttggtggtagaatgtc actgaggcttt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+F+++++++K + ++++G++++V VTFDDHDSVDKIVI-QKYHTVNGHNCEV MMD729 475 gatggcgtggaaga catcagagcatgg tctaaaactaattt aaaactagaagat tcttctctgtgttt gacttgtccctaa // Gene 1 Gene 70 282 Exon 70 282 phase 0 Gene 2 Gene 343 555 Exon 343 555 phase 0 // >MMD729.[70:282].sp.tr LFIGGLSFETTDESLRSHFEQWGTLTDCVVMRDPNTKRSRGFGFVTYATVEEVDAAMNAR PHKVDGRVVEP >MMD729.[343:555].sp.tr IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAFVTFDDHDSVDKIVIQK YHTVNGHNCEV // >MMD729.[70:282].sp CTCTTCATCGGAGGGCTGAGCTTCGAAACAACCGACGAGAGTCTGAGGAGCCATTTTGAG CAATGGGGAACACTAACAGACTGTGTGGTAATGAGAGATCCAAACACCAAGAGATCCAGG GGCTTTGGGTTTGTCACATATGCCACTGTGGAAGAAGTGGATGCTGCCATGAATGCAAGA CCACACAAGGTGGATGGAAGAGTTGTGGAACCT >MMD729.[343:555].sp ATCTTTGTTGGTGGTATTAAAGAAGACACTGAAGAACATCACCTACGAGATTATTTTGAG CAGTATGGGAAGATTGAAGTGATAGAAATTATGACTGACAGAGGCAGTGGGAAAAAGAGG GGCTTTGCTTTTGTTACCTTTGATGACCATGACTCTGTGGATAAGATTGTTATTCAGAAA TACCATACTGTGAATGGCCACAACTGTGAAGTA // Sequence MMD729 subsequence MMD729.1 70 282 Sequence MMD729.1 CDS Start_not_found End_not_found CDS_predicted_by genewise 86.15 source_Exons 1 213 Sequence MMD729 subsequence MMD729.2 343 555 Sequence MMD729.2 CDS Start_not_found End_not_found CDS_predicted_by genewise 93.51 source_Exons 1 213 // Gene 0 Gene 69 - 282 Transcript 0 Exon 0-213 Translation 0 - 213 Gene 1 Gene 342 - 555 Transcript 0 Exon 0-213 Translation 0 - 213 // >Results for SEED vs MMFLI2X (forward) [2] genewisedb output Score 179.66 bits over entire alignment. This will be different from per-alignment scores. See manual for details For computer parsable output, try genewisedb -help or read the manual Scores as bits over a synchronous coding model Alignment 1 Score 86.15 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF LF+G+L++++T+E L+ +F++ G +++ ++RD ++T++S+GF+F LFIGGLSFETTDESLRSHFEQWGTLTDCVVMRD-----PNTKRSRGFGF MMFLI2X 105 ctaggcatgaaggacaactgctgacagtggaag caaaatagtgt tttggtgtaccaagtggataaggctcagtttga cacagcggtgt cccaggccaaccgtggcttgagaaaactgagat accgacgctgt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+++++E++++A++ ++++GR+++ VTYATVEEVDAAMN-ARPHKVDGRVVEP MMFLI2X 237 gatgagggggggaa gaccagggagggc tcacctaataccta cgcaataggttac catctgaagttcgt aaacggtaatgat Alignment 2 Score 93.51 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF FVG++ +D+ E+ L+D+F+++G+I+ I+I++D + GK +GFAF IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTD-----RGSGKKRGFAF MMFLI2X 378 atgggaaggaggccccgttgctgaaggagaaag agagaaagtgt tttggtaaacaaaatgaataaagatattattca ggggaaggtct ctttttaactaatcaatttggtggtagaatgtc actgaggcttt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+F+++++++K + ++++G++++V VTFDDHDSVDKIVI-QKYHTVNGHNCEV MMFLI2X 510 gatggcgtggaaga catcagagcatgg tctaaaactaattt aaaactagaagat tcttctctgtgttt gacttgtccctaa // Gene 1 Gene 105 317 Exon 105 317 phase 0 Gene 2 Gene 378 590 Exon 378 590 phase 0 // >MMFLI2X.[105:317].sp.tr LFIGGLSFETTDESLRSHFEQWGTLTDCVVMRDPNTKRSRGFGFVTYATVEEVDAAMNAR PHKVDGRVVEP >MMFLI2X.[378:590].sp.tr IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAFVTFDDHDSVDKIVIQK YHTVNGHNCEV // >MMFLI2X.[105:317].sp CTCTTCATCGGAGGGCTGAGCTTCGAAACAACCGACGAGAGTCTGAGGAGCCATTTTGAG CAATGGGGAACACTAACAGACTGTGTGGTAATGAGAGATCCAAACACCAAGAGATCCAGG GGCTTTGGGTTTGTCACATATGCCACTGTGGAAGAAGTGGATGCTGCCATGAATGCAAGA CCACACAAGGTGGATGGAAGAGTTGTGGAACCT >MMFLI2X.[378:590].sp ATCTTTGTTGGTGGTATTAAAGAAGACACTGAAGAACATCACCTACGAGATTATTTTGAG CAGTATGGGAAGATTGAAGTGATAGAAATTATGACTGACAGAGGCAGTGGGAAAAAGAGG GGCTTTGCTTTTGTTACCTTTGATGACCATGACTCTGTGGATAAGATTGTTATTCAGAAA TACCATACTGTGAATGGCCACAACTGTGAAGTA // Sequence MMFLI2X subsequence MMFLI2X.1 105 317 Sequence MMFLI2X.1 CDS Start_not_found End_not_found CDS_predicted_by genewise 86.15 source_Exons 1 213 Sequence MMFLI2X subsequence MMFLI2X.2 378 590 Sequence MMFLI2X.2 CDS Start_not_found End_not_found CDS_predicted_by genewise 93.51 source_Exons 1 213 // Gene 0 Gene 104 - 317 Transcript 0 Exon 0-213 Translation 0 - 213 Gene 1 Gene 377 - 590 Transcript 0 Exon 0-213 Translation 0 - 213 // >Results for SEED vs SAHNRNPH (forward) [3] genewisedb output Score 150.47 bits over entire alignment. This will be different from per-alignment scores. See manual for details For computer parsable output, try genewisedb -help or read the manual Scores as bits over a synchronous coding model Alignment 1 Score 77.89 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF LF+G+L + +T+E LK++F++ G+IV++ +++D ++T++S+GF+F LFIGGLDYRTTDESLKQHFEQWGEIVDVVVMKD-----PKTKRSRGFGF SAHNRNPH 148 ctaggtgtaaaggtcacctgctggagggggaag caaaatagtgt tttggtaagccaactaaataaggattattttaa cacagcggtgt atttagctaatcgcagattaagtaattggtggc taggggagtgc SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV +++ +++A + ++++GR+++ ITYSRAHMVDDAQN-ARPHKVDGRVVEP SAHNRNPH 280 aattagcaggggca gcccagggcgggc tcacgcattaacaa cgcaataggttac atccaatggtttgt tcacatttttggg Alignment 2 Score 72.58 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF LFVG++ +++ E DL+D+F+++G +VS+ IV D KET K +GFAF LFVGGIKEEMEENDLRDYFKQYGTVVSAAIVVD-----KETRKKRGFAF SAHNRNPH 421 ctgggaaggaggagccgttactgaggtggaggg agacaacgtgt tttggtaaataaaatgaataaagcttcccttta aacgaaggtct atttatgaggaactgcttcagtctccttacctc ggtcggtcctc SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV VEF++ + ++K +++++G+ + V VEFDDYDPVDKICL-SRNHQIRGKHIDV SAHNRNPH 553 ggtggtgcggaatt acaccacgacagg tataaaactaatgt ggaaatggaatat aatctttatcaatg tctcgctggtatc // Gene 1 Gene 148 360 Exon 148 360 phase 0 Gene 2 Gene 421 633 Exon 421 633 phase 0 // >SAHNRNPH.[148:360].sp.tr LFIGGLDYRTTDESLKQHFEQWGEIVDVVVMKDPKTKRSRGFGFITYSRAHMVDDAQNAR PHKVDGRVVEP >SAHNRNPH.[421:633].sp.tr LFVGGIKEEMEENDLRDYFKQYGTVVSAAIVVDKETRKKRGFAFVEFDDYDPVDKICLSR NHQIRGKHIDV // >SAHNRNPH.[148:360].sp CTATTTATTGGTGGATTGGACTATAGAACAACTGACGAGTCCCTAAAGCAACATTTTGAA CAATGGGGTGAAATAGTTGATGTGGTGGTTATGAAGGACCCTAAAACGAAGAGGTCGAGA GGGTTTGGGTTCATAACTTACTCCAGAGCACATATGGTGGATGATGCTCAGAATGCTCGC CCACACAAAGTTGATGGTCGTGTTGTGGAGCCG >SAHNRNPH.[421:633].sp CTATTTGTTGGTGGAATTAAGGAAGAGATGGAAGAAAACGATCTGCGCGATTATTTCAAA CAGTATGGCACTGTCGTCTCTGCTGCAATCGTCGTTGACAAGGAGACTCGCAAGAAGCGT GGCTTCGCTTTCGTAGAATTTGACGATTATGATCCAGTTGACAAAATATGTTTGAGTCGC AATCACCAGATCCGTGGGAAGCATATAGATGTC // Sequence SAHNRNPH subsequence SAHNRNPH.1 148 360 Sequence SAHNRNPH.1 CDS Start_not_found End_not_found CDS_predicted_by genewise 77.89 source_Exons 1 213 Sequence SAHNRNPH subsequence SAHNRNPH.2 421 633 Sequence SAHNRNPH.2 CDS Start_not_found End_not_found CDS_predicted_by genewise 72.58 source_Exons 1 213 // Gene 0 Gene 147 - 360 Transcript 0 Exon 0-213 Translation 0 - 213 Gene 1 Gene 420 - 633 Transcript 0 Exon 0-213 Translation 0 - 213 // wise-2.4.1/src/test/wrong.hmm0000755000175000001440000007264007313404554015477 0ustar philippusersHMMER2.0 NAME SEED LENG 79 ALPH Amino RF no CS no MAP yes COM hmmbuild -f HMM SEED COM hmmcalibrate --seed 0 /nfs/disk100/pubseq/Pfam/NEWDB/SH2/HMM NSEQ 58 DATE Thu Feb 4 21:23:04 1999 CKSUM 2627 XT -8455 -4 -1000 -1000 -8455 -4 -8455 -4 NULT -4 -8455 NULE 595 -1558 85 338 -294 453 -1158 197 249 902 -1085 -142 -21 -313 45 531 201 384 -1998 -644 EVD -7.995505 0.798968 HMM A C D E F G H I K L M N P Q R S T V W Y m->m m->i m->d i->m i->i d->m d->d b->m m->e -33 * -5459 1 -7236 -6151 -7608 -1460 211 -7493 -3675 -6106 -7520 -1974 -5505 -6101 -7346 -6241 -6882 -6742 -7084 -6270 6026 1349 1 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -1033 -7285 2 -1694 -5990 -7523 -7809 3279 -7334 -3682 282 -7382 -5323 -5353 -320 -7232 -6178 -6788 -6576 -6786 -5989 -2936 3857 2 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7276 3 -1302 98 -302 -4672 2259 -4519 4007 -858 -4269 -1175 1007 -1278 -4569 -3894 -4073 -1737 -2913 -213 1776 1102 3 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7267 4 -1696 -5051 -1085 -1251 -5397 3225 -3063 -5159 694 -5078 -4201 -2854 22 -2636 677 -1556 -3503 -4700 -5232 -4522 4 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7257 5 16 -4184 262 -814 686 -2174 695 -4255 2139 -1932 -3273 1337 235 -780 -442 312 -973 -1583 -4367 294 5 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7248 6 -3550 -3310 -5950 -5356 -3371 -5229 -4181 3204 -4991 1046 1310 -771 -5242 -4638 -4821 -2099 -1439 979 -4012 -3662 6 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7238 7 -2712 -4184 -952 -320 -4505 -53 -2345 -4255 -151 -1260 -7 122 424 329 -2433 2301 1640 -3806 -4368 -3685 7 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7229 8 -2074 -5958 -6742 -4882 -7054 976 -3718 -6264 677 -5853 -5216 -4634 -5822 -3300 3805 -5334 -5090 -6045 -101 -5632 8 - -150 -501 233 42 -373 399 104 -628 211 -467 -722 276 392 44 100 359 116 -365 -296 -251 - -212 -3659 -4304 -1684 -538 -701 -1378 -7319 -7219 9 647 -4118 -298 1003 -4439 -788 741 -1079 1215 -4134 -3207 215 -1589 1630 -317 470 -4 -623 802 -3619 14 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10524 -11566 -894 -1115 -243 -2690 -7319 -7209 10 -1509 -4188 1622 2632 -4509 -1418 -2347 -667 267 -4204 -3278 -1373 -3781 2005 -1030 -1440 -2654 -3810 -4372 -559 15 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7200 11 3325 -4216 -6178 -5845 -6062 -4560 -5158 -5689 -1206 -5929 -5126 -4938 -5244 -5024 -1017 -446 -2008 749 -6204 -6003 16 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7190 12 -1811 -4188 -1167 3438 -935 -3728 73 -4223 -1996 -4194 -3284 -657 -3829 375 -2502 -2650 -1029 -811 -4383 -529 17 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11642 -894 -1115 -701 -1378 -7319 -7180 13 -496 -4184 676 1029 -4505 -1418 679 -4256 1517 -4200 -300 198 -3778 1201 1830 -183 -513 -1882 -4367 -868 18 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11642 -894 -1115 -701 -1378 -7319 -7170 14 -633 -2957 -4427 -3832 -2932 -4370 432 156 -476 2332 1704 -3697 -4430 1065 326 -1384 -2885 -2383 -3393 519 19 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10600 -11642 -894 -1115 -701 -1378 -7319 -7160 15 -6143 -5498 -8565 -8001 -3625 -8435 -7123 -268 -7843 3292 -2382 -8182 -7357 -6530 -7298 -7874 -5985 -1460 -5506 -5762 20 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10600 -11642 -894 -1115 -701 -1378 -7319 -7150 16 -2729 -4016 -928 -2106 -4264 -1062 -2402 -1320 896 1300 2084 281 -3826 1390 1151 -481 -78 -1536 -4244 111 21 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -49 -10600 -5282 -894 -1115 -701 -1378 -7319 -7140 17 267 -4150 -221 505 -4471 -122 -2311 -1514 507 -860 -622 1535 -501 1422 -287 677 -38 -1869 -4334 -287 22 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -1583 -10562 -603 -894 -1115 -1507 -626 -7319 -7129 18 -109 -2533 -1496 134 -2721 1006 -1191 102 -852 -2495 -1669 -1223 2296 -798 26 619 -1402 -2084 -2815 1321 23 - -149 -483 232 46 -381 398 105 -624 210 -467 -714 275 393 45 95 358 120 -370 -295 -250 - -169 -3284 -10036 -1922 -442 -1039 -962 -7319 -7119 19 -168 -3624 -295 1199 -68 1871 -1823 -1063 -354 -3635 -461 -1803 -3256 291 846 -810 564 -165 -3816 -3141 28 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -9980 -11023 -894 -1115 -504 -1762 -7319 -7109 20 -1395 -4051 -278 -723 -4371 1575 -2211 -4122 1514 -681 767 1742 550 344 -150 -1256 -852 -1749 -4234 -3551 29 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10448 -11490 -894 -1115 -1525 -616 -7319 -7098 21 -1303 -4079 -2464 700 -1602 -3589 1433 -694 1661 -4094 597 -972 1666 751 1030 -190 142 -1149 -4265 -3584 30 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10489 -11531 -894 -1115 -186 -3045 -7319 -7087 22 -1296 -4184 2519 951 -4505 -3685 848 -4256 -726 -1766 -3273 1051 594 -300 418 -432 122 -826 -4367 -3685 31 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10600 -11642 -894 -1115 -701 -1378 -7319 -7077 23 -5971 427 -7965 -8333 -7548 3798 -7312 -8622 -8266 -8444 -7920 -7298 -6954 -7936 -7776 -6253 -6413 -7608 623 -7381 32 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10600 -11642 -894 -1115 -701 -1378 -7319 -7066 24 657 -23 1098 -699 -4418 -941 -364 -4149 -290 -417 -126 -2348 -3794 -1913 -2458 1590 2151 -3731 -4324 -3658 33 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10600 -11642 -894 -1115 -701 -1378 -7319 -7055 25 -7274 -6182 -7628 -7991 4417 -7490 -3715 -6170 -7556 -5469 -5569 -6138 -7360 -6280 -6916 -6780 -7127 -6327 -2962 1866 34 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10600 -11643 -894 -1115 -701 -1378 -7319 -7044 26 -6133 -5488 -8556 -7989 -3625 -8436 -7117 159 -7831 3112 1066 -8170 -7353 -6525 -7290 -7870 -5974 105 -5506 -5766 35 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10600 -11643 -894 -1115 -701 -1378 -7319 -7033 27 -946 -4360 -7581 -7272 -5013 -7453 -7549 2420 -7258 687 -3691 -7109 -7162 -7212 -7441 -6846 -4873 2920 -6837 -6329 36 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10601 -11643 -894 -1115 -701 -1378 -7319 -7022 28 -8779 -7380 -8290 -8499 -8796 -7334 -7688 -9818 -7760 -9142 -9056 -8481 -7754 -8187 4273 -9233 -8869 -9515 -7500 -8689 37 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10601 -11643 -894 -1115 -701 -1378 -7319 -7011 29 -1430 -4182 1605 2386 1016 -3701 -2364 -1877 554 -1404 -3274 -2340 988 1341 -2456 -2613 -2669 -3799 -4371 -3693 38 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10601 -11643 -894 -1115 -701 -1378 -7319 -7000 30 -811 1038 -6983 -7288 -6924 -4490 -6231 -6742 -6774 -7000 -6027 -5325 -5305 -6315 906 3454 -1341 -5420 -7134 -7122 39 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10601 -11643 -894 -1115 -701 -1378 -7319 -6989 31 -1497 -4184 1338 2327 -4504 -3685 -435 -1510 -466 -1266 -3273 -861 -3778 218 805 1115 -421 -1387 -4367 -3684 40 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -229 -10601 -2852 -894 -1115 -701 -1378 -7319 -6977 32 -2544 -4015 -2384 -207 -4338 -151 -43 -4087 -120 -4031 -3105 966 -911 -1712 1160 2073 1899 -3638 -4197 -3516 41 - -149 -500 233 43 -381 398 105 -627 212 -466 -721 277 393 45 96 360 117 -370 -295 -250 - -233 -3704 -3951 -63 -4547 -114 -3722 -7319 -6966 33 -572 309 -784 245 -317 -1172 1400 -1251 1429 -2572 -3199 630 -3705 832 -810 678 1524 -3732 -4294 193 43 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10518 -11560 -894 -1115 -635 -1490 -7319 -6954 34 -550 -4118 -110 249 -4419 -3673 -2333 9 941 -272 -3212 -2316 2854 1226 -1206 -2581 -941 -990 -4313 -3642 44 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -76 -10574 -4563 -894 -1115 -411 -2013 -7319 -6943 35 -1439 -5086 -697 -3749 -7091 3546 -4834 -7007 -5343 -7054 -6292 1125 -5310 -4596 -6061 -1596 -4536 -5954 -7225 -6509 45 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10540 -11582 -894 -1115 -275 -2526 -7319 -6931 36 -277 615 2110 1083 -4505 976 321 -4256 -946 -1376 -3273 -1051 -3778 930 -2432 1066 -474 -3806 -4368 -3685 46 - -149 -500 233 43 -381 398 105 -627 210 -466 -721 275 396 45 98 360 117 -370 -295 -250 - -45 -5474 -11643 -1505 -626 -701 -1378 -7319 -6919 37 -6384 -5646 -7740 -7748 2831 -7543 -4219 635 -7397 -853 -3608 -6441 -7203 -6242 -6861 -6801 -6258 -1299 -3431 4057 50 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10601 -11644 -894 -1115 -701 -1378 -7319 -6907 38 1171 -293 -6607 -6454 -4954 -4640 -5327 -1155 -6079 -4711 -4106 -5174 -5272 -5638 -5815 1859 2339 1756 -5487 -5205 51 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10602 -11644 -894 -1115 -701 -1378 -7319 -6895 39 -5548 726 -8073 -7590 265 -7859 -6933 1805 -7445 2761 -2626 -7548 -7172 -6550 -7142 -7215 -5460 267 -5654 -5732 52 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10602 -11644 -894 -1115 -701 -1378 -7319 -6883 40 -607 1053 -6978 -7296 -6850 -1653 -6236 -6659 -6912 -6927 -5967 -5324 -5300 -6345 -6517 3325 1269 -5383 -7086 -517 53 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10602 -11644 -894 -1115 -701 -1378 -7319 -6870 41 -3195 -3008 -5527 -4904 1429 -1639 -23 -442 -4502 808 -2142 -4377 -4782 -4107 -4296 -3834 -3134 2949 2848 -2915 54 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10602 -11644 -894 -1115 -701 -1378 -7319 -6858 42 -1468 248 -5289 -4655 407 -4516 -283 -988 1333 256 638 -4153 -4566 -3884 2425 -64 -2912 892 1339 25 55 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10602 -11644 -894 -1115 -701 -1378 -7319 -6845 43 -6 776 1857 -226 1013 -3780 1648 -1280 -813 -1628 -340 -865 -3870 -505 211 -788 658 -590 1629 781 56 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10602 -11644 -894 -1115 -701 -1378 -7319 -6833 44 -2711 -4184 1808 311 563 1017 -2343 -1202 727 -4200 -3273 1521 -1611 1203 -208 -676 -2650 -3806 1464 -1375 57 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10602 -11644 -894 -1115 -701 -1378 -7319 -6820 45 -444 -4183 1973 -338 -1263 2075 -2344 -4253 -89 -4198 -177 192 -3778 -545 -302 260 -1633 -176 -4366 -3684 58 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -1303 -10602 -773 -894 -1115 -701 -1378 -7319 -6807 46 -1654 -3126 892 585 -3447 -681 1000 -197 297 -3142 -2215 839 1662 1550 22 -1534 288 -630 -3309 -2627 59 - -153 -497 237 44 -390 408 102 -627 214 -471 -725 275 395 55 92 362 115 -376 -303 -254 - -2642 -353 -4387 -2167 -363 -31 -5570 -7319 -6794 47 -971 -13 -81 370 -4479 -1026 1314 -1276 1291 -1680 -3248 646 -3753 1074 1578 140 -359 295 -4342 -3659 68 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10574 -11616 -894 -1115 -1351 -718 -7319 -6781 48 -1452 -432 -5317 -4685 672 -4530 -3411 1174 -4285 -2655 -2016 885 -180 -3912 -1700 -3617 -1465 3088 -3280 -2937 69 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10574 -11616 -894 -1115 -406 -2028 -7319 -6768 49 -2712 -4179 -2561 170 -1276 -1378 783 -1651 2633 -1190 -3269 -721 -3779 1595 924 -1219 376 -3800 -4364 94 70 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10603 -11645 -894 -1115 -701 -1378 -7319 -6755 50 -4519 -5497 -4305 -1190 -5973 -5163 5152 -5554 -2301 -1967 -4630 -909 -1026 -1110 -725 -4396 -4332 -5267 762 -4996 71 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -79 -10603 -4520 -894 -1115 -701 -1378 -7319 -6741 51 -4742 2555 -6657 -6333 2540 -6098 -3678 1238 -5936 -4026 -3628 -967 -6082 -5296 -5631 -5238 -4678 -460 -3072 3759 72 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10539 -11581 -894 -1115 -267 -2566 -7319 -6728 52 -2757 -3861 -754 -2226 -4050 -3797 1181 712 1918 -607 -367 -2504 -1264 691 2362 -2720 -284 20 -4128 -3537 73 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10603 -11645 -894 -1115 -701 -1378 -7319 -6714 53 -4514 -4096 -7081 -6634 -723 -6661 -6001 3505 152 -1714 -3321 -6310 -1202 -6188 -6387 -5894 -4487 1567 -5642 -5244 74 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10603 -11645 -894 -1115 -701 -1378 -7319 -6700 54 -2716 1077 -1059 -351 -948 -3699 838 -636 1214 -274 745 1226 -1112 2092 1332 -1343 -2655 -1397 -4330 -270 75 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10603 -11646 -894 -1115 -701 -1378 -7319 -6687 55 -907 54 -2567 146 6 -3690 -192 -4224 970 -2095 -3257 392 -378 993 1394 1190 674 -768 338 -98 76 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10604 -11646 -894 -1115 -701 -1378 -7319 -6672 56 -878 -4177 1291 47 -4495 -3687 116 -4243 -878 1318 314 174 -3780 101 -388 -279 1620 -188 -4362 -3681 77 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -10604 -11646 -894 -1115 -701 -1378 -7319 -6658 57 332 189 1866 1165 -4505 773 -2343 -4255 197 -1252 -463 423 626 549 -809 -1409 -1018 -3806 -4367 -1198 78 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -10604 -11646 -894 -1115 -701 -1378 -7319 -6644 58 -892 -4184 1591 318 -4505 149 -2343 -4256 -126 -4200 -968 2412 -1002 438 227 -172 944 -3806 -4368 -3685 79 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -246 -10604 -2777 -894 -1115 -701 -1378 -7319 -6629 59 -1329 174 -757 767 -525 2620 -2154 -3997 337 -1733 798 -682 -3586 -1699 10 -197 -1000 -3565 -4143 -1070 80 - -147 -503 230 42 -379 400 102 -621 212 -463 -713 275 398 42 93 358 117 -372 -298 -252 - -1238 -2595 -1320 -1857 -466 -1204 -821 -7319 -6615 60 -2057 -3525 -1901 -329 -3850 2119 1363 -3597 2009 -3538 -2614 31 -3118 745 -334 -879 654 -3149 -3701 -3025 88 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -9783 -10825 -894 -1115 -268 -2562 -7319 -6600 61 -2879 -2722 -5113 -4484 1276 -4414 111 -726 -386 437 -50 -1066 -4465 -709 -1083 -567 -2819 801 569 3513 89 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -10506 -11548 -894 -1115 -203 -2932 -7319 -6585 62 -748 210 -33 -4661 2244 -4517 -3387 -154 -1257 -1249 -79 -4156 -4567 -3888 -4068 -270 -499 -393 -3259 3581 90 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -10605 -11647 -894 -1115 -701 -1378 -7319 -6570 63 -2973 218 -5314 -4678 -1099 -467 -3391 2396 -1381 1000 153 -899 -4570 -3897 1386 -3604 -2913 1112 -3257 275 91 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -10605 -11647 -894 -1115 -701 -1378 -7319 -6555 64 712 -2898 -660 -4025 1011 361 -3235 260 -1186 -326 1009 -963 -432 -3491 -3780 856 1583 -803 -3342 273 92 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -10605 -11647 -894 -1115 -701 -1378 -7319 -6539 65 -549 -4184 645 1588 -4504 1660 -2343 -4255 -796 -1102 -3273 -31 7 -633 -121 -737 680 -1389 1630 -3684 93 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -83 -10605 -4486 -894 -1115 -701 -1378 -7319 -6524 66 -298 -4130 161 1056 -4451 1605 -2289 -4202 438 -4146 -3219 1419 -3723 -486 1808 -200 -2596 -1076 -4313 -3630 94 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -10539 -11581 -894 -1115 -263 -2587 -7319 -6508 67 -303 -4160 360 616 -4470 -3691 1917 -168 227 -456 -107 -2331 414 761 868 -549 38 706 -4350 -821 95 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -44 -10605 -5784 -894 -1115 -701 -1378 -7319 -6492 68 -324 4 -2598 -866 -1217 -822 -2358 -1795 1616 -1175 -3151 -812 -534 59 1409 -76 1405 -857 -4263 1318 96 - -147 -500 232 42 -381 398 105 -627 210 -464 -721 280 393 45 95 358 119 -370 -295 -250 - -168 -3344 -11621 -393 -2067 -419 -1990 -7319 -6476 69 -1440 109 -6019 -5504 4127 -5317 790 -1078 -5097 -1202 -2848 -900 -5345 -4612 -4854 -4418 -3802 -3095 -3088 1330 99 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -10606 -11648 -894 -1115 -701 -1378 -7319 -6459 70 70 1646 1226 358 -4499 205 -2344 -1253 -1926 -1839 -967 1545 818 358 611 882 -2650 -3801 -4364 -3683 100 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -10606 -11648 -894 -1115 -701 -1378 -7319 -6443 71 -1218 -638 414 -2097 -4295 -423 60 -1827 -2008 -1801 -3145 661 -3822 -1962 -1116 2452 1944 -3625 -4262 -3621 101 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -10606 -11648 -894 -1115 -701 -1378 -7319 -6426 72 -5783 -5235 -8195 -7617 -622 -7885 -6643 2054 -7396 2608 728 -7587 -377 -6310 -6953 -7193 -5650 329 -5352 -5508 102 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -10606 -11648 -894 -1115 -701 -1378 -7319 -6409 73 565 -4171 -705 -967 -4486 -776 593 -4232 -547 -1032 481 806 1543 1630 -2437 396 -601 -211 1435 480 103 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -10607 -11649 -894 -1115 -701 -1378 -7319 -6392 74 -124 -4175 1926 2547 -4488 -3694 34 -4234 -1939 -1173 -965 -2332 -1002 1851 -2445 -2602 -968 -3793 -4363 -558 104 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -10607 -11649 -894 -1115 -701 -1378 -7319 -6375 75 -6325 -5649 -8690 -8081 -1212 -8579 -7091 722 -7904 3142 1192 -8327 -7377 -6484 -7287 -8024 -6133 -3977 -5433 -5722 105 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -10607 -11649 -894 -1115 -701 -1378 -7319 -6358 76 -4820 1167 -7506 -7182 -5010 -7339 -7316 2750 -1473 -382 -3707 -6991 -7082 -7096 -7302 -6706 -4811 2854 -6723 -6200 106 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -10607 -11649 -894 -1115 -701 -1378 -7319 -6340 77 -637 -4183 785 1664 -4504 -1528 1202 -4255 -758 -1224 539 723 -3778 1529 -403 388 -89 -1208 373 418 107 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -10607 -11650 -894 -1115 -701 -1378 -7319 -6322 78 -1788 -3481 -1154 -1203 1121 -5023 4200 -3007 -4546 -831 -2689 -4410 -5074 -4179 -4480 -4114 -3550 -1166 -3181 3272 108 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -20 -10608 -11650 -894 -1115 -701 -1378 -7319 -6304 79 -7240 -6153 -7608 -7964 271 -7493 3287 -6121 -7510 -1085 -5521 -6100 -7346 -1027 -6876 -6742 -7088 -6279 -2920 4367 109 - * * * * * * * * * * * * * * * * * * * * - * * * * * * * -7319 0 // wise-2.4.1/src/test/wrong.out0000644000175000001440000000043107646501704015513 0ustar philippusersScore 1197 Position i:[-1] j:[287] State:[6] Score: 0 Position i:[0] j:[290] State:[0] Score: 1730 Position i:[1] j:[293] State:[0] Score: 1133 Position i:[2] j:[296] State:[0] Score: 612 Position i:[3] j:[299] State:[0] Score: 237 Position i:[0] j:[299] State:[7] Score: -2515 // wise-2.4.1/src/test/promoterwise.out0000644000175000001440000000755210414205303017110 0ustar philippusersBLASTP 2.1.2 Reference: Wise2 Package, Ewan Birney BLAST like format to play well with existing parsers. Other options are available See help on the program that generated this for other options Query= Not specified Search.................................done Score E Sequences producing significant alignments: (bits) Value EM:MMENDOBA 9.59 0 EM:MMENDOBA [2729-3525] M22832 Mus musculus cytokeratin (endoB 15.07 0 EM:MMENDOBA 12.70 0 EM:MMENDOBA [2729-3525] M22832 Mus musculus cytokeratin (endoB 76.75 0 EM:MMENDOBA 11.37 0 EM:MMENDOBA [2729-3525] M22832 Mus musculus cytokeratin (endoB 32.05 0 >EM:MMENDOBA Length = 797 Reversed 1 Score = 9.6 bits (3322), Expect = 0 Query: 165 AAGAGCAGC 173 D AAGAGCAGC Sbjct: -551 AAGAGCAGC -542 >EM:MMENDOBA [2729-3525] M22832 Mus musculus cytokeratin (endoB) gene, complete cds. Length = 797 Reversed 0 Score = 15.1 bits (5223), Expect = 0 Query: 187 GGGAGGGCTCTTTCCCAGGAGAGAGGGGGAAGGGGACAGGGTT 229 B GGG GGGC C T CCCAGGA G GGGGG GGGG GGGTT Sbjct: 447 GGGGGGGCGCGT-CCCAGGACGGGGGGGGGGGGGGGGGGGGTT 488 >EM:MMENDOBA Length = 797 Reversed 1 Score = 12.7 bits (4400), Expect = 0 Query: 245 GAA-GTGGACAGCATGGAGGGAG 266 C GAA GTGGA AG TGGAGGGAG Sbjct: -133 GAATGTGGAAAGAGTGGAGGGAG -110 >EM:MMENDOBA [2729-3525] M22832 Mus musculus cytokeratin (endoB) gene, complete cds. Length = 797 Reversed 0 Score = 76.8 bits (26601), Expect = 0 Query: 322 TTGGAGGGTTAAGCGGATGTGGCTAAGGCTGAGTCATCTAGGAGTAAAC 370 C TT GAGGGTTAAGCGGATGTGGCTAAGG TGAGTCATCTAGGAGTAAAC Sbjct: 359 TTAGAGGGTTAAGCGGATGTGGCTAAGGGTGAGTCATCTAGGAGTAAAC 407 Query: 371 AAGAGGCCTTCCTTTGGGAGGAGCCA 396 C A GAG C T CCT T GGAGG GCCA Sbjct: 408 AGGAG-CTTACCTGTAGGAGGGGCCA 432 >EM:MMENDOBA Length = 797 Reversed 1 Score = 11.4 bits (3941), Expect = 0 Query: 424 CCAGGTGCAC 433 D CCAGGTGCAC Sbjct: -503 CCAGGTGCAC -493 >EM:MMENDOBA [2729-3525] M22832 Mus musculus cytokeratin (endoB) gene, complete cds. Length = 797 Reversed 0 Score = 32.0 bits (11107), Expect = 0 Query: 561 GGAATCCAGGAAAGGAG-GGA 580 D GGAATCCAGGAA GGAG GGA Sbjct: 594 GGAATCCAGGAAGGGAGAGGA 614 >-----------< Query: 623 GCCTCTGGCTATTCCTGGGACCAGGAAGTTTTCACTAGGATACATAACA 671 B GCCTCTG CT TTCCTGGGAC GGA G TTCACT G A ACA AA A Sbjct: 647 GCCTCTGACTGTTCCTGGGACTGGGATGGATTCACT-GAA-ACACAAGA 693 Query: 672 CTT-TTTACACACTCACCCCAC 692 B C T TTT C CA TC CCCCAC Sbjct: 694 CGTGTTTTCTCA-TC-CCCCAC 713 wise-2.4.1/src/test/HMM.binary0000644000175000001440000004047407313404552015462 0ustar philippusersèíí³TACDEFGHIKLMNPQRSTVWY?Ø&9TŒ—9ÔŒ—? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9|Ò@<Ô>áœ×<–ï; •D;ÉKz;—öÏ;¢s*< .‚;胈>/˜Æ:¦¨ù;m­`?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ýÐGuÀ?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9>º<Ô=ª"«<–î<3–¨;ÉKy;—öÎ;¢s)< .‚;胇?ÙÈ:¦¨ø;m­_?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9Þ¶;…ˆÙ;’…Ê>1Œ<)…:êWA=A׳;ÉKyÇ®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9”=;…ˆÚ<,Žì<³6<†hŒ:êWC>ô‹¦<•žå;—öÏ<‹èÒÇ®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9JÜ=²m= =?öÓ=JæM="âˆ=µz°= ²N=à=¤Ô‘=®Í¥‹­¶[¤v=|{<£Ý:¦¨ø<·^?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9®Z=’gë@xç=@Ãå<ï4Ö=7}ª=\w<Õ5á=‹#,=Á›÷?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9‚">-¶<ŠÉ’=r–c;…ˆÙ<,Žë=<ç<)…:êWA=†(\<•žä<ºï½<ï4Ö> ö°=JÕ|Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9%ï¹<äÜ<é´’=Ê<3–¨<•žälãê>a>È:¦¨ø<²?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ99Ë=_/Q;ö-<‰¢²;…ˆÙ<‡íy<äÜ<é´’:êWA=†(\=Fî{ÄZ<£Ý:¦¨ø;m­_?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ99Ë>ɪõ<2GÇ®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ÃV>· µ<ŠÉ“<ìîº<¶TA;’…Ë=Î)<é´“Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ðT>:;ö-=J^=>v&<,Žë=æü=X&O=MêÇ; •C;ÉKy=â=Bp=€ûW=Ч@=mò;ðBJ;m­_?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9 ¸<Ô?(©0<Õ=‚; •D;ÉKz;—öÏ;¢s*< .‚;胈=Mæø:¦¨ù;m­`?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9c3=&€L<–î<3–¨;ÉKy=â>‡÷õ=PP«Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9 ø>¤ns;ö-<‰¢²<&s<,Žë=ƒ° <)…<Õ==1°<•žä=Ðy<ï4Ö=€ûW=JÕ|Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ŠºQ<Õ=; •C;ÉKy;—öÎ;¢s)=ª¨=—Á=Œú:¦¨ø>%@?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ93êÜ<2G>8Ä¡;…ˆÙ;’…Ê=œƒ = ­J:êWA=s}·;ÉKy<ºï½=mm>nB·Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ºŠ<)…<–î=1°=øiF>,P<½ŽÔ=i#¬Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9¹Œ<‰¢²<çúC=XèÅ<³6= ­J<–î<‹qW%@?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9!L›<î˜=ªñ5<&s<,Žë=æü<é´’:êWA=†(\>Òä=â=)@n=7}ª=ȶÃ<£Ý:¦¨ø;m­_?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9¿“<äÜ=&€L<–î; •C<ÇDçŸ+:¦¨ø<·^?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9@T]<2G<»H¶<&s=…Gd=Á¿=ô›¯<£—~<î½]'‚:¦¨ø;m­_?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ðS=º¬;ö,=J];…ˆØ=oÀ= A <é´œ]Ý=2y=Œø:¦¨÷<äM·?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9˜>FŠ<@`Á;ĺ'<¼o•<ìî¹<&s>D÷{<³6=‘Oª:êWA; •C<øêê;—öÎ<½ŽÔ=i#¬N ‡:¦¨ø<²?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9DÙ<î˜P•N=?SN£=PP«=\w=Ö©:¦¨ø;m­_?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9_$²<´MÎ>ƒ=O,5<ð2¯¿•:§­;o a?2\>“33Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9>QË<¿iO=É3˜<1mÿ=3= <Ÿ[e>+x:¨´w<‚–ì?Ù>Ü(öÇ®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9;x=T,<=ò[U=jÿÉ;ôµL=r¯{?!´è>·wx<#× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9¤?-ÖK9å|<‘ä_;Žo5?‹˜=o i;©>ž=©ÚŠ<1í <8âE=JeF<LLŽ?Kâ¾;Œo-? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9#$ÜÔu=‡!5>‘:Îô­?7 <=²pô= =@}=JØH="áÂ=µsc= ½Á=!f=¤Îk=®ÆÎ.3ð= ›Ð;q©û=®L×>YÆ*= ”>0ÞÒ<Žö="XO<„‹ë;+Þ@<£­>}Žo?@o¶:2¼ ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9>6$Ë=BÁ#;CHµ=ŒÙ><'¾ä= £>=÷=5²h=Uïq=1¬å; â$;Æy>©Á?+9#:cóˆ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9§Ë>Êô<ò€:çP;¤Æ·>vc?Bý: ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ó¼x<½¥°ƒ?'\):Ä›¦? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9«¯-<ŸŒ­<¤n=fÕ‡ž =Š_Ã<ºß4<ýp:ÅÕx<áÏF?Æ;—{? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ç’æ<åO^<|J§:¸Žq;ƒ™?ÚÐ>À¬w;Nô®? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9§=Â=a¹Ô<ªÖé<;‹‚¸}<ã²5Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ÞȆ<‰¢²<&r=XèÄ<äÜ= ­J<£—}<3–¦;ÉKx=@Ãä<4…š<Ú I=å@?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9©Þ3=×;º)w;ĺ(;ö.>áÐz;…ˆÚ;’…Ë<Ô<†hŒ:êWC; •D;ÉKz;—öÏ<4…œ<¨cHÇ®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ph½<Ô= ­J:êWA; •C;ÉKy;—öÎ;¢s)< .‚;胇?(é:¦¨ø;m­_?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9Y'_;ö-<‰¢²=%£$<,Žë=n<)…:êWA=’‘Ý;ÉKy=@Ãå=Bp=7}ª>Œ*–<£Ý;ðBJ;m­_?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9¨¿?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ðT>L½Þ<2G<‰¢²<„®=<,Žë=óe<é´’<–î=)²<ÇDç<ºï½<4…›>`1=|{=5õ:¦¨ø<²?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9Ž•=º­;ö-<ìî¹<&s<,Žë=µV <)…<–î=étb[¤v> —ä<‡®:¦¨ø<·^?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9~cá<ŠÉ’<‰¢²=‡<,Žë=Š<é´’=qÂ; •C=ß–D='ðã=Bp=7}ª=/y=Œú:¦¨ø=<Ÿá?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9 ø>ÌÅW;ö.<ìîº<„®==oÂ<äÜ<é´“<–ï<½[<ÇDè=ã=mm=ª©Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ï–<%Ä0>_š>3êÜ;ö-=J^;…ˆÙ<‡íy<Ô<¸ÁðÇ®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9[ :¦¨÷;m­]?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9YÕ>L½Þ;ö-<ìî¹<&s<‡íy> Q = ­J<–î=†(\Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ï—<%Ä1=v°>=ˆj«;ö.¬Žì<¸<£—=s}¹;ÉKz=@Ãæ=s¹t=ª©=/z<£Þ:¦¨ù<·_?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9cÿ==¨ìŒ>Q0]=ÊAj; •C;ÉKy<‰Iº<½ŽÔ<¨cG;胇><F:¦¨ø<·^?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9x/!<2GÇ®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ98•š;„ðT<‘Öc>yš;ö-=(_= Ð#<‡íy=æü=X&O<Õ==1°;ÉKy=íø<½ŽÔ=×ÝÜ=c¨~=mò:¦¨ø<²§¶?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9º‹>¦§³>ƹ<î½_<•žå;—öÏ=ZæsÇ®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9Âå =Fîy=žqu<‹èÐ=צ=\w<‡­:¦¨÷=õó?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ÒL™>D”<,Žì=Uº<é´“:êWC=Zª·;ÉKz<ì•Â<4…œ=ª©Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9+XË<¸=Œ1æ=A׳;ÉKy=íø=s¹s=7}ª> —ä=@ô:¦¨ø=<Ÿá?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9/˜Å<[m+<²?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9>º=$ >DÆÜ=DÃ=žû^=.x;—öÎ<½ŽÔ=×§Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9Q—£<„®=<,Žë=ƒ° =¶Œ,:êWA>Áó;ÉKy<ºï½=Bp=€ûW=\w<£Ý:¦¨ø= ùÞ?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9©õ¶=>v&<,Žë=¨ìŒ=?SN:êWA=žû^<ÇDç<ºï½=s¹s=ð°Þ<ÏìÇ®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9ihO<)…‡÷õ=7}ª=|{=5õ:¦¨ø<·^?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9'‚:¦¨ø;m­_?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9'\<ŠÉ’<‰¢²<„®=>Qw<äÜ>DÆÜ<Õ=; •CÇ®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9&o$<Ú J=|{=Ö©;ðBJ=Îw?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9J`=Âõ­:êWA; •C<•žä;—öÎ=’¯»<¨cG=2{>œ§:¦¨ø<²?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9…Ê<)…=qÂ=·Î_<øêêÇ®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9j;<%Ä0<@`Á<”z=’gë<»H¶<„®==XèÅ<³6=ª"«Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9v¥;„ðT=E 9<”z=«:í=(_<„®=<ë9=¨ìŒ=„æ)=DÃ<3–¨<•žä=žqv<‹èÑ=×ÝÜ=2{=Mæ÷:¦¨ø<·^?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9~=†F:=ý_=Ч@=@ô:¦¨ø<²?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9„8 <é´’:êWA=)²=ºYÃ<ºï½>9 e=äG]<Ïì<£Ý:¦¨ø;m­_?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9c3<)…<–î=A׳=¡†Á=žqv>2¡=™ÎX<Ïì<‡®:¦¨ø;m­_?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9yš<2G=Ð-·<çúC<,Žë=n=&€LÇ®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9®Z<2G<ìî¹<çúC=oÁ=Š<¸=Œ1æ=A׳=ˆ³À=Y–æ=mm>Áð<Ïì=@ô:¦¨ø=ƒŒs?n{=LÌÍ<£× ? =<£× >Ç®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9~>2ؤ=™ÎX<ÏìÇ®=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9±À> œ"=€ûWËÁN=²q7= ×=?úÂ=Jßø="åÞ=µy)= µ =ø=¤Ò³=®Ñ9 ----------------------------------------------------- Algorithm type: GeneWise Search algorithm used: 623 Implementation: Single Threaded processor (serial) Search mode: Single protein vs genomic db Protein info from: rrm.HMM Dna info from: dna.db Start/End (protein) global Gene Paras: human.gf Codon Table: codon.table Subs error: 1e-05 Indel error: 1e-05 Model splice? model Model codon bias? flat Model intron bias? tied Null model syn Alignment Alg 623L [Warning: Can't fit histogram to a db smaller than 1,000] # #WARNING! # # Your alignment algorithm is different from your search algorithm. # This is probably quite sensible but will lead to differing scores. # Use the search score as an indicator of the significance of the match # Read the docs for more information # #High Score list #Protein ID DNA Str ID Bits Evalue -------------------------------------------------------------------------- Protein SEED DNA [+] MMD728 101.74 Protein SEED DNA [+] MMD729 101.74 Protein SEED DNA [+] MMFLI2X 101.74 Protein SEED DNA [+] SAHNRNPH 86.11 #Alignments ----------------------------------------------------------------------- >Results for SEED vs MMD728 (forward) [0] genewisedb output Score 179.66 bits over entire alignment. This will be different from per-alignment scores. See manual for details For computer parsable output, try genewisedb -help or read the manual Scores as bits over a synchronous coding model Alignment 1 Score 86.15 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF LF+G+L++++T+E L+ +F++ G +++ ++RD ++T++S+GF+F LFIGGLSFETTDESLRSHFEQWGTLTDCVVMRD-----PNTKRSRGFGF MMD728 70 ctaggcatgaaggacaactgctgacagtggaag caaaatagtgt tttggtgtaccaagtggataaggctcagtttga cacagcggtgt cccaggccaaccgtggcttgagaaaactgagat accgacgctgt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+++++E++++A++ ++++GR+++ VTYATVEEVDAAMN-ARPHKVDGRVVEP MMD728 202 gatgagggggggaa gaccagggagggc tcacctaataccta cgcaataggttac catctgaagttcgt aaacggtaatgat Alignment 2 Score 93.51 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF FVG++ +D+ E+ L+D+F+++G+I+ I+I++D + GK +GFAF IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTD-----RGSGKKRGFAF MMD728 343 atgggaaggaggccccgttgctgaaggagaaag agagaaagtgt tttggtaaacaaaatgaataaagatattattca ggggaaggtct ctttttaactaatcaatttggtggtagaatgtc actgaggcttt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+F+++++++K + ++++G++++V VTFDDHDSVDKIVI-QKYHTVNGHNCEV MMD728 475 gatggcgtggaaga catcagagcatgg tctaaaactaattt aaaactagaagat tcttctctgtgttt gacttgtccctaa // Gene 1 Gene 70 282 Exon 70 282 phase 0 Gene 2 Gene 343 555 Exon 343 555 phase 0 // >MMD728.[70:282].sp.tr LFIGGLSFETTDESLRSHFEQWGTLTDCVVMRDPNTKRSRGFGFVTYATVEEVDAAMNAR PHKVDGRVVEP >MMD728.[343:555].sp.tr IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAFVTFDDHDSVDKIVIQK YHTVNGHNCEV // >MMD728.[70:282].sp CTCTTCATCGGAGGGCTGAGCTTCGAAACAACCGACGAGAGTCTGAGGAGCCATTTTGAG CAATGGGGAACACTAACAGACTGTGTGGTAATGAGAGATCCAAACACCAAGAGATCCAGG GGCTTTGGGTTTGTCACATATGCCACTGTGGAAGAAGTGGATGCTGCCATGAATGCAAGA CCACACAAGGTGGATGGAAGAGTTGTGGAACCT >MMD728.[343:555].sp ATCTTTGTTGGTGGTATTAAAGAAGACACTGAAGAACATCACCTACGAGATTATTTTGAG CAGTATGGGAAGATTGAAGTGATAGAAATTATGACTGACAGAGGCAGTGGGAAAAAGAGG GGCTTTGCTTTTGTTACCTTTGATGACCATGACTCTGTGGATAAGATTGTTATTCAGAAA TACCATACTGTGAATGGCCACAACTGTGAAGTA // Sequence MMD728 subsequence MMD728.1 70 282 Sequence MMD728.1 CDS Start_not_found End_not_found CDS_predicted_by genewise 86.15 source_Exons 1 213 Sequence MMD728 subsequence MMD728.2 343 555 Sequence MMD728.2 CDS Start_not_found End_not_found CDS_predicted_by genewise 93.51 source_Exons 1 213 // Gene 0 Gene 69 - 282 Transcript 0 Exon 0-213 Translation 0 - 213 Gene 1 Gene 342 - 555 Transcript 0 Exon 0-213 Translation 0 - 213 // >Results for SEED vs MMD729 (forward) [1] genewisedb output Score 179.66 bits over entire alignment. This will be different from per-alignment scores. See manual for details For computer parsable output, try genewisedb -help or read the manual Scores as bits over a synchronous coding model Alignment 1 Score 86.15 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF LF+G+L++++T+E L+ +F++ G +++ ++RD ++T++S+GF+F LFIGGLSFETTDESLRSHFEQWGTLTDCVVMRD-----PNTKRSRGFGF MMD729 70 ctaggcatgaaggacaactgctgacagtggaag caaaatagtgt tttggtgtaccaagtggataaggctcagtttga cacagcggtgt cccaggccaaccgtggcttgagaaaactgagat accgacgctgt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+++++E++++A++ ++++GR+++ VTYATVEEVDAAMN-ARPHKVDGRVVEP MMD729 202 gatgagggggggaa gaccagggagggc tcacctaataccta cgcaataggttac catctgaagttcgt aaacggtaatgat Alignment 2 Score 93.51 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF FVG++ +D+ E+ L+D+F+++G+I+ I+I++D + GK +GFAF IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTD-----RGSGKKRGFAF MMD729 343 atgggaaggaggccccgttgctgaaggagaaag agagaaagtgt tttggtaaacaaaatgaataaagatattattca ggggaaggtct ctttttaactaatcaatttggtggtagaatgtc actgaggcttt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+F+++++++K + ++++G++++V VTFDDHDSVDKIVI-QKYHTVNGHNCEV MMD729 475 gatggcgtggaaga catcagagcatgg tctaaaactaattt aaaactagaagat tcttctctgtgttt gacttgtccctaa // Gene 1 Gene 70 282 Exon 70 282 phase 0 Gene 2 Gene 343 555 Exon 343 555 phase 0 // >MMD729.[70:282].sp.tr LFIGGLSFETTDESLRSHFEQWGTLTDCVVMRDPNTKRSRGFGFVTYATVEEVDAAMNAR PHKVDGRVVEP >MMD729.[343:555].sp.tr IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAFVTFDDHDSVDKIVIQK YHTVNGHNCEV // >MMD729.[70:282].sp CTCTTCATCGGAGGGCTGAGCTTCGAAACAACCGACGAGAGTCTGAGGAGCCATTTTGAG CAATGGGGAACACTAACAGACTGTGTGGTAATGAGAGATCCAAACACCAAGAGATCCAGG GGCTTTGGGTTTGTCACATATGCCACTGTGGAAGAAGTGGATGCTGCCATGAATGCAAGA CCACACAAGGTGGATGGAAGAGTTGTGGAACCT >MMD729.[343:555].sp ATCTTTGTTGGTGGTATTAAAGAAGACACTGAAGAACATCACCTACGAGATTATTTTGAG CAGTATGGGAAGATTGAAGTGATAGAAATTATGACTGACAGAGGCAGTGGGAAAAAGAGG GGCTTTGCTTTTGTTACCTTTGATGACCATGACTCTGTGGATAAGATTGTTATTCAGAAA TACCATACTGTGAATGGCCACAACTGTGAAGTA // Sequence MMD729 subsequence MMD729.1 70 282 Sequence MMD729.1 CDS Start_not_found End_not_found CDS_predicted_by genewise 86.15 source_Exons 1 213 Sequence MMD729 subsequence MMD729.2 343 555 Sequence MMD729.2 CDS Start_not_found End_not_found CDS_predicted_by genewise 93.51 source_Exons 1 213 // Gene 0 Gene 69 - 282 Transcript 0 Exon 0-213 Translation 0 - 213 Gene 1 Gene 342 - 555 Transcript 0 Exon 0-213 Translation 0 - 213 // >Results for SEED vs MMFLI2X (forward) [2] genewisedb output Score 179.66 bits over entire alignment. This will be different from per-alignment scores. See manual for details For computer parsable output, try genewisedb -help or read the manual Scores as bits over a synchronous coding model Alignment 1 Score 86.15 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF LF+G+L++++T+E L+ +F++ G +++ ++RD ++T++S+GF+F LFIGGLSFETTDESLRSHFEQWGTLTDCVVMRD-----PNTKRSRGFGF MMFLI2X 105 ctaggcatgaaggacaactgctgacagtggaag caaaatagtgt tttggtgtaccaagtggataaggctcagtttga cacagcggtgt cccaggccaaccgtggcttgagaaaactgagat accgacgctgt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+++++E++++A++ ++++GR+++ VTYATVEEVDAAMN-ARPHKVDGRVVEP MMFLI2X 237 gatgagggggggaa gaccagggagggc tcacctaataccta cgcaataggttac catctgaagttcgt aaacggtaatgat Alignment 2 Score 93.51 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF FVG++ +D+ E+ L+D+F+++G+I+ I+I++D + GK +GFAF IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTD-----RGSGKKRGFAF MMFLI2X 378 atgggaaggaggccccgttgctgaaggagaaag agagaaagtgt tttggtaaacaaaatgaataaagatattattca ggggaaggtct ctttttaactaatcaatttggtggtagaatgtc actgaggcttt SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV V+F+++++++K + ++++G++++V VTFDDHDSVDKIVI-QKYHTVNGHNCEV MMFLI2X 510 gatggcgtggaaga catcagagcatgg tctaaaactaattt aaaactagaagat tcttctctgtgttt gacttgtccctaa // Gene 1 Gene 105 317 Exon 105 317 phase 0 Gene 2 Gene 378 590 Exon 378 590 phase 0 // >MMFLI2X.[105:317].sp.tr LFIGGLSFETTDESLRSHFEQWGTLTDCVVMRDPNTKRSRGFGFVTYATVEEVDAAMNAR PHKVDGRVVEP >MMFLI2X.[378:590].sp.tr IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAFVTFDDHDSVDKIVIQK YHTVNGHNCEV // >MMFLI2X.[105:317].sp CTCTTCATCGGAGGGCTGAGCTTCGAAACAACCGACGAGAGTCTGAGGAGCCATTTTGAG CAATGGGGAACACTAACAGACTGTGTGGTAATGAGAGATCCAAACACCAAGAGATCCAGG GGCTTTGGGTTTGTCACATATGCCACTGTGGAAGAAGTGGATGCTGCCATGAATGCAAGA CCACACAAGGTGGATGGAAGAGTTGTGGAACCT >MMFLI2X.[378:590].sp ATCTTTGTTGGTGGTATTAAAGAAGACACTGAAGAACATCACCTACGAGATTATTTTGAG CAGTATGGGAAGATTGAAGTGATAGAAATTATGACTGACAGAGGCAGTGGGAAAAAGAGG GGCTTTGCTTTTGTTACCTTTGATGACCATGACTCTGTGGATAAGATTGTTATTCAGAAA TACCATACTGTGAATGGCCACAACTGTGAAGTA // Sequence MMFLI2X subsequence MMFLI2X.1 105 317 Sequence MMFLI2X.1 CDS Start_not_found End_not_found CDS_predicted_by genewise 86.15 source_Exons 1 213 Sequence MMFLI2X subsequence MMFLI2X.2 378 590 Sequence MMFLI2X.2 CDS Start_not_found End_not_found CDS_predicted_by genewise 93.51 source_Exons 1 213 // Gene 0 Gene 104 - 317 Transcript 0 Exon 0-213 Translation 0 - 213 Gene 1 Gene 377 - 590 Transcript 0 Exon 0-213 Translation 0 - 213 // >Results for SEED vs SAHNRNPH (forward) [3] genewisedb output Score 150.47 bits over entire alignment. This will be different from per-alignment scores. See manual for details For computer parsable output, try genewisedb -help or read the manual Scores as bits over a synchronous coding model Alignment 1 Score 77.89 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF LF+G+L + +T+E LK++F++ G+IV++ +++D ++T++S+GF+F LFIGGLDYRTTDESLKQHFEQWGEIVDVVVMKD-----PKTKRSRGFGF SAHNRNPH 148 ctaggtgtaaaggtcacctgctggagggggaag caaaatagtgt tttggtaagccaactaaataaggattattttaa cacagcggtgt atttagctaatcgcagattaagtaattggtggc taggggagtgc SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV +++ +++A + ++++GR+++ ITYSRAHMVDDAQN-ARPHKVDGRVVEP SAHNRNPH 280 aattagcaggggca gcccagggcgggc tcacgcattaacaa cgcaataggttac atccaatggtttgt tcacatttttggg Alignment 2 Score 72.58 (Bits) SEED 1 LFVGNLPPDVTEEDLKDLFSKFGPIVSIKIVRDIIEKPKETGKSKGFAF LFVG++ +++ E DL+D+F+++G +VS+ IV D KET K +GFAF LFVGGIKEEMEENDLRDYFKQYGTVVSAAIVVD-----KETRKKRGFAF SAHNRNPH 421 ctgggaaggaggagccgttactgaggtggaggg agacaacgtgt tttggtaaataaaatgaataaagcttcccttta aacgaaggtct atttatgaggaactgcttcagtctccttacctc ggtcggtcctc SEED 50 VEFESEEDAEKALEALNGKELGGRKLRV VEF++ + ++K +++++G+ + V VEFDDYDPVDKICL-SRNHQIRGKHIDV SAHNRNPH 553 ggtggtgcggaatt acaccacgacagg tataaaactaatgt ggaaatggaatat aatctttatcaatg tctcgctggtatc // Gene 1 Gene 148 360 Exon 148 360 phase 0 Gene 2 Gene 421 633 Exon 421 633 phase 0 // >SAHNRNPH.[148:360].sp.tr LFIGGLDYRTTDESLKQHFEQWGEIVDVVVMKDPKTKRSRGFGFITYSRAHMVDDAQNAR PHKVDGRVVEP >SAHNRNPH.[421:633].sp.tr LFVGGIKEEMEENDLRDYFKQYGTVVSAAIVVDKETRKKRGFAFVEFDDYDPVDKICLSR NHQIRGKHIDV // >SAHNRNPH.[148:360].sp CTATTTATTGGTGGATTGGACTATAGAACAACTGACGAGTCCCTAAAGCAACATTTTGAA CAATGGGGTGAAATAGTTGATGTGGTGGTTATGAAGGACCCTAAAACGAAGAGGTCGAGA GGGTTTGGGTTCATAACTTACTCCAGAGCACATATGGTGGATGATGCTCAGAATGCTCGC CCACACAAAGTTGATGGTCGTGTTGTGGAGCCG >SAHNRNPH.[421:633].sp CTATTTGTTGGTGGAATTAAGGAAGAGATGGAAGAAAACGATCTGCGCGATTATTTCAAA CAGTATGGCACTGTCGTCTCTGCTGCAATCGTCGTTGACAAGGAGACTCGCAAGAAGCGT GGCTTCGCTTTCGTAGAATTTGACGATTATGATCCAGTTGACAAAATATGTTTGAGTCGC AATCACCAGATCCGTGGGAAGCATATAGATGTC // Sequence SAHNRNPH subsequence SAHNRNPH.1 148 360 Sequence SAHNRNPH.1 CDS Start_not_found End_not_found CDS_predicted_by genewise 77.89 source_Exons 1 213 Sequence SAHNRNPH subsequence SAHNRNPH.2 421 633 Sequence SAHNRNPH.2 CDS Start_not_found End_not_found CDS_predicted_by genewise 72.58 source_Exons 1 213 // Gene 0 Gene 147 - 360 Transcript 0 Exon 0-213 Translation 0 - 213 Gene 1 Gene 420 - 633 Transcript 0 Exon 0-213 Translation 0 - 213 // wise-2.4.1/src/test/short.test0000644000175000001440000000441710406570001015656 0ustar philippusers# # # # name promoterwise desc promoterwise standard test do promoterwise -silent pw.human pw.mouse > TEMP-PW diff TEMP-PW promoterwise.out // name basic-cdna desc cdna test case (protein v cdna), all outputs do estwise short.pep short.dna -indel 1e-5 -subs 1e-5 -pretty -para -sum -alb -pal -silent -alg 333 > TEMP diff TEMP basic_cdna.out // name basic-genomic desc genomic test case (protein v genomic), all outputs do genewise short.pep short.dna -pretty -para -genes -sum -cdna -trans -ace -gener -alb -pal -quiet -dymem linear > TEMP diff TEMP basic_genomic.out // name hmm-binary-cdna desc cdna test case (protein v cdna), all outputs do estwise HMM.binary -indel 1e-5 -subs 1e-5 -hmmer short.dna -pretty -para -sum -alb -pal -quiet -alg 333L > TEMP diff TEMP hmm_cdna.out // name hmm-wrong-dna desc HMMs vs DNA sequence when there is no match do genewise wrong.hmm -hmmer short.dna -alg 623 -pal > TEMP diff TEMP wrong.out // name hmm-wrong-dna-est desc HMMs vs DNA sequence when there is no match do estwise wrong.hmm -hmmer short.dna -alg 333 -pal > TEMP diff TEMP wrong_est.out // name hmm-ascii-genomic desc cdna test case (protein v cdna), all outputs do genewise -init local HMM.ascii -hmmer short.dna -pretty -para -genes -sum -cdna -trans -ace -gener -alb -pal -quiet > TEMP diff TEMP hmm_genomic.out // name genewise-db desc genewisedb hmm vs DNA sequences. Could take a while do genewisedb rrm.HMM -hmmer dna.db -pretty -para -gener -genes -cdna -trans -ace -quiet -init global > TEMP diff TEMP genewise-db.out // name genewise-db-lite desc genewisedb hmm vs DNA sequences, using GWLITE. Could take a while do genewisedb rrm.HMM -hmmer dna.db -pretty -para -gener -genes -cdna -trans -ace -quiet -init global -alg 6LITE > TEMP diff TEMP genewise-db-lite.out // name estwise-db desc estwisedb hmm vs DNA sequences. Could take a while do estwisedb -init local rrm.HMM -hmmer dna.db -pretty -para -alb -quiet -alg 333 -aalg 333 > TEMP diff TEMP estwise-db.out // name pswdb desc Protein smith waterman db search do pswdb road.pep pep.fa -quiet > TEMP diff TEMP pswdb.out // name genewisedb-pfam-mode desc genewisedb designed for Pfam searching do genewisedb -pfam rrm.HMM -dnas short.dna -pretty -para -alb -quiet -alg 623 -aalg 623L > TEMP diff TEMP genewisedb-pfam.out // wise-2.4.1/src/test/hmm_cdna.out0000644000175000001440000010413207313404553016123 0ustar philippusersestwise $Name: wise2-4-1 $ (unreleased release) This program is freely distributed under a GPL. See source directory Copyright (c) GRL limited: portions of the code are from separate copyrights Query model: unnamed Start/End default Target Sequence HSHNCPA1 Strand: both Codon Table: codon.table Subs error: 1e-05 Indel error: 1e-05 Algorithm 333L estwise output Score 138.76 bits over entire alignment Score reported as bits over a synchronised coding sequence model Alignment 1 Score 138.76 (Bits) unnamed 1 KLFVGNLPPDTTEEELRELFSQFGEIESVKVMRDEPKTGKSRGFGFVTF K+FVG++ +DT E +LR++F+Q+G+IE +++M+D +++GK+RGF++VTF KIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTD-RGSGKKRGFAxVTF HSHNCPA1 14 aatgggaaggaggcccagttgctgaaggagaaag cgagaaagtgtgat atttggtaaacaaaatgaataaagatattattca ggggaaggtcttct gatttctaactaatcaatttagtaatagtacgtc actcgagctcNact unnamed 50 ESEEDAEKAIEALNGKVLGGRVLRVKAAQKKEERQ +++++++K++ +++++V+G++++++KA +K+E++ DDHDSVDKIVIQKYHTVNGHNCEVRKALSKQEMAS HSHNCPA1 158 ggcgtggaagacatcagagcatggaagctacgaga aaaactaatttaaaactagaagatgactcaaatcg cctccgtgtctgacttgtccctataacgagaggtt // Bits Query start end Target start end idels 138.76 unnamed 1 84 HSHNCPA1 14 262 0 // 1.94 [-1:0 "MATCH_STATE" 672],[12:15 "CODON" 672] 2.11 [0:1 "MATCH_STATE" 730],[15:18 "CODON" 730] 3.60 [1:2 "MATCH_STATE" 1249],[18:21 "CODON" 1249] 3.15 [2:3 "MATCH_STATE" 1090],[21:24 "CODON" 1090] 2.67 [3:4 "MATCH_STATE" 924],[24:27 "CODON" 924] 2.08 [4:5 "MATCH_STATE" 720],[27:30 "CODON" 720] 0.82 [5:6 "MATCH_STATE" 285],[30:33 "CODON" 285] -0.43 [6:7 "MATCH_STATE" -150],[33:36 "CODON" -150] 1.14 [7:8 "MATCH_STATE" 395],[36:39 "CODON" 395] 2.26 [8:9 "MATCH_STATE" 783],[39:42 "CODON" 783] 2.01 [9:10 "MATCH_STATE" 696],[42:45 "CODON" 696] -0.21 [10:11 "MATCH_STATE" -74],[45:48 "CODON" -74] 2.64 [11:12 "MATCH_STATE" 914],[48:51 "CODON" 914] -0.01 [12:13 "MATCH_STATE" -3],[51:54 "CODON" -3] 1.05 [13:14 "MATCH_STATE" 364],[54:57 "CODON" 364] 2.82 [14:15 "MATCH_STATE" 976],[57:60 "CODON" 976] 2.36 [15:16 "MATCH_STATE" 819],[60:63 "CODON" 819] 1.57 [16:17 "MATCH_STATE" 543],[63:66 "CODON" 543] 2.33 [17:18 "MATCH_STATE" 808],[66:69 "CODON" 808] 4.24 [18:19 "MATCH_STATE" 1468],[69:72 "CODON" 1468] 1.47 [19:20 "MATCH_STATE" 511],[72:75 "CODON" 511] 2.06 [20:21 "MATCH_STATE" 715],[75:78 "CODON" 715] 2.33 [21:22 "MATCH_STATE" 808],[78:81 "CODON" 808] 3.34 [22:23 "MATCH_STATE" 1159],[81:84 "CODON" 1159] 0.92 [23:24 "MATCH_STATE" 320],[84:87 "CODON" 320] 2.71 [24:25 "MATCH_STATE" 938],[87:90 "CODON" 938] 1.57 [25:26 "MATCH_STATE" 544],[90:93 "CODON" 544] -0.06 [26:27 "MATCH_STATE" -22],[93:96 "CODON" -22] 1.75 [27:28 "MATCH_STATE" 605],[96:99 "CODON" 605] 1.01 [28:29 "MATCH_STATE" 349],[99:102 "CODON" 349] 1.92 [29:30 "MATCH_STATE" 664],[102:105 "CODON" 664] 2.97 [30:31 "MATCH_STATE" 1029],[105:108 "CODON" 1029] 1.03 [31:32 "MATCH_STATE" 358],[108:111 "CODON" 358] 3.21 [32:33 "MATCH_STATE" 1114],[111:114 "CODON" 1114] -0.56 [33:34 "DELETE_STATE" -193],[114:114 "INSERT" -193] 0.85 [34:35 "MATCH_STATE" 295],[114:117 "CODON" 295] 0.37 [35:36 "MATCH_STATE" 128],[117:120 "CODON" 128] 1.02 [36:37 "MATCH_STATE" 352],[120:123 "CODON" 352] 2.79 [37:38 "MATCH_STATE" 968],[123:126 "CODON" 968] 2.50 [38:39 "MATCH_STATE" 865],[126:129 "CODON" 865] 0.39 [39:40 "MATCH_STATE" 135],[129:132 "CODON" 135] 2.80 [40:41 "MATCH_STATE" 970],[132:135 "CODON" 970] 3.33 [41:42 "MATCH_STATE" 1154],[135:138 "CODON" 1154] 3.41 [42:43 "MATCH_STATE" 1183],[138:141 "CODON" 1183] 2.13 [43:44 "MATCH_STATE" 739],[141:144 "CODON" 739] 3.27 [44:45 "MATCH_STATE" 1135],[144:147 "CODON" 1135] 3.23 [45:46 "MATCH_STATE" 1120],[147:150 "CODON" 1120] 2.25 [46:47 "MATCH_STATE" 780],[150:153 "CODON" 780] 3.95 [47:48 "MATCH_STATE" 1368],[153:156 "CODON" 1368] 1.26 [48:49 "MATCH_STATE" 436],[156:159 "CODON" 436] 1.45 [49:50 "MATCH_STATE" 503],[159:162 "CODON" 503] 2.08 [50:51 "MATCH_STATE" 722],[162:165 "CODON" 722] 1.57 [51:52 "MATCH_STATE" 543],[165:168 "CODON" 543] 0.84 [52:53 "MATCH_STATE" 292],[168:171 "CODON" 292] 1.71 [53:54 "MATCH_STATE" 593],[171:174 "CODON" 593] 1.39 [54:55 "MATCH_STATE" 481],[174:177 "CODON" 481] 2.50 [55:56 "MATCH_STATE" 867],[177:180 "CODON" 867] 0.82 [56:57 "MATCH_STATE" 285],[180:183 "CODON" 285] 1.49 [57:58 "MATCH_STATE" 517],[183:186 "CODON" 517] -0.49 [58:59 "MATCH_STATE" -169],[186:189 "CODON" -169] 1.25 [59:60 "MATCH_STATE" 432],[189:192 "CODON" 432] 1.33 [60:61 "MATCH_STATE" 460],[192:195 "CODON" 460] 1.13 [61:62 "MATCH_STATE" 393],[195:198 "CODON" 393] 3.10 [62:63 "MATCH_STATE" 1073],[198:201 "CODON" 1073] 1.22 [63:64 "MATCH_STATE" 424],[201:204 "CODON" 424] 1.39 [64:65 "MATCH_STATE" 482],[204:207 "CODON" 482] 0.78 [65:66 "MATCH_STATE" 269],[207:210 "CODON" 269] 1.58 [66:67 "MATCH_STATE" 547],[210:213 "CODON" 547] 1.05 [67:68 "MATCH_STATE" 364],[213:216 "CODON" 364] 0.88 [68:69 "MATCH_STATE" 306],[216:219 "CODON" 306] 2.57 [69:70 "MATCH_STATE" 891],[219:222 "CODON" 891] 1.37 [70:71 "MATCH_STATE" 475],[222:225 "CODON" 475] 0.68 [71:72 "MATCH_STATE" 236],[225:228 "CODON" 236] 0.47 [72:73 "MATCH_STATE" 164],[228:231 "CODON" 164] 1.27 [73:74 "MATCH_STATE" 439],[231:234 "CODON" 439] 1.60 [74:75 "MATCH_STATE" 553],[234:237 "CODON" 553] -0.53 [75:76 "MATCH_STATE" -182],[237:240 "CODON" -182] 0.77 [76:77 "MATCH_STATE" 268],[240:243 "CODON" 268] 2.12 [77:78 "MATCH_STATE" 734],[243:246 "CODON" 734] 0.94 [78:79 "MATCH_STATE" 326],[246:249 "CODON" 326] 1.07 [79:80 "MATCH_STATE" 372],[249:252 "CODON" 372] 1.54 [80:81 "MATCH_STATE" 532],[252:255 "CODON" 532] 0.66 [81:82 "MATCH_STATE" 229],[255:258 "CODON" 229] -0.20 [82:83 "MATCH_STATE" -68],[258:261 "CODON" -68] 0.00 [83:-1 "LOOP" 0],[261:413 "RANDOM_SEQUENCE" 0] 0.00 [-1:0 "END" 0],[413:414 "END" 0] // Score 48089 Position i:[-1] j:[12] State:[4] Score: 0 Position i:[0] j:[15] State:[0] Score: 672 Position i:[1] j:[18] State:[0] Score: 730 Position i:[2] j:[21] State:[0] Score: 1249 Position i:[3] j:[24] State:[0] Score: 1090 Position i:[4] j:[27] State:[0] Score: 924 Position i:[5] j:[30] State:[0] Score: 720 Position i:[6] j:[33] State:[0] Score: 285 Position i:[7] j:[36] State:[0] Score: -150 Position i:[8] j:[39] State:[0] Score: 395 Position i:[9] j:[42] State:[0] Score: 783 Position i:[10] j:[45] State:[0] Score: 696 Position i:[11] j:[48] State:[0] Score: -74 Position i:[12] j:[51] State:[0] Score: 914 Position i:[13] j:[54] State:[0] Score: -3 Position i:[14] j:[57] State:[0] Score: 364 Position i:[15] j:[60] State:[0] Score: 976 Position i:[16] j:[63] State:[0] Score: 819 Position i:[17] j:[66] State:[0] Score: 543 Position i:[18] j:[69] State:[0] Score: 808 Position i:[19] j:[72] State:[0] Score: 1468 Position i:[20] j:[75] State:[0] Score: 511 Position i:[21] j:[78] State:[0] Score: 715 Position i:[22] j:[81] State:[0] Score: 808 Position i:[23] j:[84] State:[0] Score: 1159 Position i:[24] j:[87] State:[0] Score: 320 Position i:[25] j:[90] State:[0] Score: 938 Position i:[26] j:[93] State:[0] Score: 544 Position i:[27] j:[96] State:[0] Score: -22 Position i:[28] j:[99] State:[0] Score: 605 Position i:[29] j:[102] State:[0] Score: 349 Position i:[30] j:[105] State:[0] Score: 664 Position i:[31] j:[108] State:[0] Score: 1029 Position i:[32] j:[111] State:[0] Score: 358 Position i:[33] j:[114] State:[0] Score: 1114 Position i:[34] j:[114] State:[2] Score: -193 Position i:[35] j:[117] State:[0] Score: 295 Position i:[36] j:[120] State:[0] Score: 128 Position i:[37] j:[123] State:[0] Score: 352 Position i:[38] j:[126] State:[0] Score: 968 Position i:[39] j:[129] State:[0] Score: 865 Position i:[40] j:[132] State:[0] Score: 135 Position i:[41] j:[135] State:[0] Score: 970 Position i:[42] j:[138] State:[0] Score: 1154 Position i:[43] j:[141] State:[0] Score: 1183 Position i:[44] j:[144] State:[0] Score: 739 Position i:[45] j:[147] State:[0] Score: 1135 Position i:[46] j:[150] State:[0] Score: 1120 Position i:[47] j:[153] State:[0] Score: 780 Position i:[48] j:[156] State:[0] Score: 1368 Position i:[49] j:[159] State:[0] Score: 436 Position i:[50] j:[162] State:[0] Score: 503 Position i:[51] j:[165] State:[0] Score: 722 Position i:[52] j:[168] State:[0] Score: 543 Position i:[53] j:[171] State:[0] Score: 292 Position i:[54] j:[174] State:[0] Score: 593 Position i:[55] j:[177] State:[0] Score: 481 Position i:[56] j:[180] State:[0] Score: 867 Position i:[57] j:[183] State:[0] Score: 285 Position i:[58] j:[186] State:[0] Score: 517 Position i:[59] j:[189] State:[0] Score: -169 Position i:[60] j:[192] State:[0] Score: 432 Position i:[61] j:[195] State:[0] Score: 460 Position i:[62] j:[198] State:[0] Score: 393 Position i:[63] j:[201] State:[0] Score: 1073 Position i:[64] j:[204] State:[0] Score: 424 Position i:[65] j:[207] State:[0] Score: 482 Position i:[66] j:[210] State:[0] Score: 269 Position i:[67] j:[213] State:[0] Score: 547 Position i:[68] j:[216] State:[0] Score: 364 Position i:[69] j:[219] State:[0] Score: 306 Position i:[70] j:[222] State:[0] Score: 891 Position i:[71] j:[225] State:[0] Score: 475 Position i:[72] j:[228] State:[0] Score: 236 Position i:[73] j:[231] State:[0] Score: 164 Position i:[74] j:[234] State:[0] Score: 439 Position i:[75] j:[237] State:[0] Score: 553 Position i:[76] j:[240] State:[0] Score: -182 Position i:[77] j:[243] State:[0] Score: 268 Position i:[78] j:[246] State:[0] Score: 734 Position i:[79] j:[249] State:[0] Score: 326 Position i:[80] j:[252] State:[0] Score: 372 Position i:[81] j:[255] State:[0] Score: 532 Position i:[82] j:[258] State:[0] Score: 229 Position i:[83] j:[261] State:[0] Score: -68 Position i:[-1] j:[261] State:[3] Score: 0 Position i:[-1] j:[262] State:[3] Score: 0 Position i:[-1] j:[263] State:[3] Score: 0 Position i:[-1] j:[264] State:[3] Score: 0 Position i:[-1] j:[265] State:[3] Score: 0 Position i:[-1] j:[266] State:[3] Score: 0 Position i:[-1] j:[267] State:[3] Score: 0 Position i:[-1] j:[268] State:[3] Score: 0 Position i:[-1] j:[269] State:[3] Score: 0 Position i:[-1] j:[270] State:[3] Score: 0 Position i:[-1] j:[271] State:[3] Score: 0 Position i:[-1] j:[272] State:[3] Score: 0 Position i:[-1] j:[273] State:[3] Score: 0 Position i:[-1] j:[274] State:[3] Score: 0 Position i:[-1] j:[275] State:[3] Score: 0 Position i:[-1] j:[276] State:[3] Score: 0 Position i:[-1] j:[277] State:[3] Score: 0 Position i:[-1] j:[278] State:[3] Score: 0 Position i:[-1] j:[279] State:[3] Score: 0 Position i:[-1] j:[280] State:[3] Score: 0 Position i:[-1] j:[281] State:[3] Score: 0 Position i:[-1] j:[282] State:[3] Score: 0 Position i:[-1] j:[283] State:[3] Score: 0 Position i:[-1] j:[284] State:[3] Score: 0 Position i:[-1] j:[285] State:[3] Score: 0 Position i:[-1] j:[286] State:[3] Score: 0 Position i:[-1] j:[287] State:[3] Score: 0 Position i:[-1] j:[288] State:[3] Score: 0 Position i:[-1] j:[289] State:[3] Score: 0 Position i:[-1] j:[290] State:[3] Score: 0 Position i:[-1] j:[291] State:[3] Score: 0 Position i:[-1] j:[292] State:[3] Score: 0 Position i:[-1] j:[293] State:[3] Score: 0 Position i:[-1] j:[294] State:[3] Score: 0 Position i:[-1] j:[295] State:[3] Score: 0 Position i:[-1] j:[296] State:[3] Score: 0 Position i:[-1] j:[297] State:[3] Score: 0 Position i:[-1] j:[298] State:[3] Score: 0 Position i:[-1] j:[299] State:[3] Score: 0 Position i:[-1] j:[300] State:[3] Score: 0 Position i:[-1] j:[301] State:[3] Score: 0 Position i:[-1] j:[302] State:[3] Score: 0 Position i:[-1] j:[303] State:[3] Score: 0 Position i:[-1] j:[304] State:[3] Score: 0 Position i:[-1] j:[305] State:[3] Score: 0 Position i:[-1] j:[306] State:[3] Score: 0 Position i:[-1] j:[307] State:[3] Score: 0 Position i:[-1] j:[308] State:[3] Score: 0 Position i:[-1] j:[309] State:[3] Score: 0 Position i:[-1] j:[310] State:[3] Score: 0 Position i:[-1] j:[311] State:[3] Score: 0 Position i:[-1] j:[312] State:[3] Score: 0 Position i:[-1] j:[313] State:[3] Score: 0 Position i:[-1] j:[314] State:[3] Score: 0 Position i:[-1] j:[315] State:[3] Score: 0 Position i:[-1] j:[316] State:[3] Score: 0 Position i:[-1] j:[317] State:[3] Score: 0 Position i:[-1] j:[318] State:[3] Score: 0 Position i:[-1] j:[319] State:[3] Score: 0 Position i:[-1] j:[320] State:[3] Score: 0 Position i:[-1] j:[321] State:[3] Score: 0 Position i:[-1] j:[322] State:[3] Score: 0 Position i:[-1] j:[323] State:[3] Score: 0 Position i:[-1] j:[324] State:[3] Score: 0 Position i:[-1] j:[325] State:[3] Score: 0 Position i:[-1] j:[326] State:[3] Score: 0 Position i:[-1] j:[327] State:[3] Score: 0 Position i:[-1] j:[328] State:[3] Score: 0 Position i:[-1] j:[329] State:[3] Score: 0 Position i:[-1] j:[330] State:[3] Score: 0 Position i:[-1] j:[331] State:[3] Score: 0 Position i:[-1] j:[332] State:[3] Score: 0 Position i:[-1] j:[333] State:[3] Score: 0 Position i:[-1] j:[334] State:[3] Score: 0 Position i:[-1] j:[335] State:[3] Score: 0 Position i:[-1] j:[336] State:[3] Score: 0 Position i:[-1] j:[337] State:[3] Score: 0 Position i:[-1] j:[338] State:[3] Score: 0 Position i:[-1] j:[339] State:[3] Score: 0 Position i:[-1] j:[340] State:[3] Score: 0 Position i:[-1] j:[341] State:[3] Score: 0 Position i:[-1] j:[342] State:[3] Score: 0 Position i:[-1] j:[343] State:[3] Score: 0 Position i:[-1] j:[344] State:[3] Score: 0 Position i:[-1] j:[345] State:[3] Score: 0 Position i:[-1] j:[346] State:[3] Score: 0 Position i:[-1] j:[347] State:[3] Score: 0 Position i:[-1] j:[348] State:[3] Score: 0 Position i:[-1] j:[349] State:[3] Score: 0 Position i:[-1] j:[350] State:[3] Score: 0 Position i:[-1] j:[351] State:[3] Score: 0 Position i:[-1] j:[352] State:[3] Score: 0 Position i:[-1] j:[353] State:[3] Score: 0 Position i:[-1] j:[354] State:[3] Score: 0 Position i:[-1] j:[355] State:[3] Score: 0 Position i:[-1] j:[356] State:[3] Score: 0 Position i:[-1] j:[357] State:[3] Score: 0 Position i:[-1] j:[358] State:[3] Score: 0 Position i:[-1] j:[359] State:[3] Score: 0 Position i:[-1] j:[360] State:[3] Score: 0 Position i:[-1] j:[361] State:[3] Score: 0 Position i:[-1] j:[362] State:[3] Score: 0 Position i:[-1] j:[363] State:[3] Score: 0 Position i:[-1] j:[364] State:[3] Score: 0 Position i:[-1] j:[365] State:[3] Score: 0 Position i:[-1] j:[366] State:[3] Score: 0 Position i:[-1] j:[367] State:[3] Score: 0 Position i:[-1] j:[368] State:[3] Score: 0 Position i:[-1] j:[369] State:[3] Score: 0 Position i:[-1] j:[370] State:[3] Score: 0 Position i:[-1] j:[371] State:[3] Score: 0 Position i:[-1] j:[372] State:[3] Score: 0 Position i:[-1] j:[373] State:[3] Score: 0 Position i:[-1] j:[374] State:[3] Score: 0 Position i:[-1] j:[375] State:[3] Score: 0 Position i:[-1] j:[376] State:[3] Score: 0 Position i:[-1] j:[377] State:[3] Score: 0 Position i:[-1] j:[378] State:[3] Score: 0 Position i:[-1] j:[379] State:[3] Score: 0 Position i:[-1] j:[380] State:[3] Score: 0 Position i:[-1] j:[381] State:[3] Score: 0 Position i:[-1] j:[382] State:[3] Score: 0 Position i:[-1] j:[383] State:[3] Score: 0 Position i:[-1] j:[384] State:[3] Score: 0 Position i:[-1] j:[385] State:[3] Score: 0 Position i:[-1] j:[386] State:[3] Score: 0 Position i:[-1] j:[387] State:[3] Score: 0 Position i:[-1] j:[388] State:[3] Score: 0 Position i:[-1] j:[389] State:[3] Score: 0 Position i:[-1] j:[390] State:[3] Score: 0 Position i:[-1] j:[391] State:[3] Score: 0 Position i:[-1] j:[392] State:[3] Score: 0 Position i:[-1] j:[393] State:[3] Score: 0 Position i:[-1] j:[394] State:[3] Score: 0 Position i:[-1] j:[395] State:[3] Score: 0 Position i:[-1] j:[396] State:[3] Score: 0 Position i:[-1] j:[397] State:[3] Score: 0 Position i:[-1] j:[398] State:[3] Score: 0 Position i:[-1] j:[399] State:[3] Score: 0 Position i:[-1] j:[400] State:[3] Score: 0 Position i:[-1] j:[401] State:[3] Score: 0 Position i:[-1] j:[402] State:[3] Score: 0 Position i:[-1] j:[403] State:[3] Score: 0 Position i:[-1] j:[404] State:[3] Score: 0 Position i:[-1] j:[405] State:[3] Score: 0 Position i:[-1] j:[406] State:[3] Score: 0 Position i:[-1] j:[407] State:[3] Score: 0 Position i:[-1] j:[408] State:[3] Score: 0 Position i:[-1] j:[409] State:[3] Score: 0 Position i:[-1] j:[410] State:[3] Score: 0 Position i:[-1] j:[411] State:[3] Score: 0 Position i:[-1] j:[412] State:[3] Score: 0 Position i:[-1] j:[413] State:[3] Score: 0 Position i:[0] j:[414] State:[5] Score: 0 // estwise output Score 0.00 bits over entire alignment Score reported as bits over a synchronised coding sequence model // Bits Query start end Target start end idels // 0.00 [-1:-1 "LOOP" 0],[0:413 "RANDOM_SEQUENCE" 0] 0.00 [-1:0 "END" 0],[413:414 "END" 0] // Score 0 Position i:[-1] j:[0] State:[4] Score: 0 Position i:[-1] j:[1] State:[3] Score: 0 Position i:[-1] j:[2] State:[3] Score: 0 Position i:[-1] j:[3] State:[3] Score: 0 Position i:[-1] j:[4] State:[3] Score: 0 Position i:[-1] j:[5] State:[3] Score: 0 Position i:[-1] j:[6] State:[3] Score: 0 Position i:[-1] j:[7] State:[3] Score: 0 Position i:[-1] j:[8] State:[3] Score: 0 Position i:[-1] j:[9] State:[3] Score: 0 Position i:[-1] j:[10] State:[3] Score: 0 Position i:[-1] j:[11] State:[3] Score: 0 Position i:[-1] j:[12] State:[3] Score: 0 Position i:[-1] j:[13] State:[3] Score: 0 Position i:[-1] j:[14] State:[3] Score: 0 Position i:[-1] j:[15] State:[3] Score: 0 Position i:[-1] j:[16] State:[3] Score: 0 Position i:[-1] j:[17] State:[3] Score: 0 Position i:[-1] j:[18] State:[3] Score: 0 Position i:[-1] j:[19] State:[3] Score: 0 Position i:[-1] j:[20] State:[3] Score: 0 Position i:[-1] j:[21] State:[3] Score: 0 Position i:[-1] j:[22] State:[3] Score: 0 Position i:[-1] j:[23] State:[3] Score: 0 Position i:[-1] j:[24] State:[3] Score: 0 Position i:[-1] j:[25] State:[3] Score: 0 Position i:[-1] j:[26] State:[3] Score: 0 Position i:[-1] j:[27] State:[3] Score: 0 Position i:[-1] j:[28] State:[3] Score: 0 Position i:[-1] j:[29] State:[3] Score: 0 Position i:[-1] j:[30] State:[3] Score: 0 Position i:[-1] j:[31] State:[3] Score: 0 Position i:[-1] j:[32] State:[3] Score: 0 Position i:[-1] j:[33] State:[3] Score: 0 Position i:[-1] j:[34] State:[3] Score: 0 Position i:[-1] j:[35] State:[3] Score: 0 Position i:[-1] j:[36] State:[3] Score: 0 Position i:[-1] j:[37] State:[3] Score: 0 Position i:[-1] j:[38] State:[3] Score: 0 Position i:[-1] j:[39] State:[3] Score: 0 Position i:[-1] j:[40] State:[3] Score: 0 Position i:[-1] j:[41] State:[3] Score: 0 Position i:[-1] j:[42] State:[3] Score: 0 Position i:[-1] j:[43] State:[3] Score: 0 Position i:[-1] j:[44] State:[3] Score: 0 Position i:[-1] j:[45] State:[3] Score: 0 Position i:[-1] j:[46] State:[3] Score: 0 Position i:[-1] j:[47] State:[3] Score: 0 Position i:[-1] j:[48] State:[3] Score: 0 Position i:[-1] j:[49] State:[3] Score: 0 Position i:[-1] j:[50] State:[3] Score: 0 Position i:[-1] j:[51] State:[3] Score: 0 Position i:[-1] j:[52] State:[3] Score: 0 Position i:[-1] j:[53] State:[3] Score: 0 Position i:[-1] j:[54] State:[3] Score: 0 Position i:[-1] j:[55] State:[3] Score: 0 Position i:[-1] j:[56] State:[3] Score: 0 Position i:[-1] j:[57] State:[3] Score: 0 Position i:[-1] j:[58] State:[3] Score: 0 Position i:[-1] j:[59] State:[3] Score: 0 Position i:[-1] j:[60] State:[3] Score: 0 Position i:[-1] j:[61] State:[3] Score: 0 Position i:[-1] j:[62] State:[3] Score: 0 Position i:[-1] j:[63] State:[3] Score: 0 Position i:[-1] j:[64] State:[3] Score: 0 Position i:[-1] j:[65] State:[3] Score: 0 Position i:[-1] j:[66] State:[3] Score: 0 Position i:[-1] j:[67] State:[3] Score: 0 Position i:[-1] j:[68] State:[3] Score: 0 Position i:[-1] j:[69] State:[3] Score: 0 Position i:[-1] j:[70] State:[3] Score: 0 Position i:[-1] j:[71] State:[3] Score: 0 Position i:[-1] j:[72] State:[3] Score: 0 Position i:[-1] j:[73] State:[3] Score: 0 Position i:[-1] j:[74] State:[3] Score: 0 Position i:[-1] j:[75] State:[3] Score: 0 Position i:[-1] j:[76] State:[3] Score: 0 Position i:[-1] j:[77] State:[3] Score: 0 Position i:[-1] j:[78] State:[3] Score: 0 Position i:[-1] j:[79] State:[3] Score: 0 Position i:[-1] j:[80] State:[3] Score: 0 Position i:[-1] j:[81] State:[3] Score: 0 Position i:[-1] j:[82] State:[3] Score: 0 Position i:[-1] j:[83] State:[3] Score: 0 Position i:[-1] j:[84] State:[3] Score: 0 Position i:[-1] j:[85] State:[3] Score: 0 Position i:[-1] j:[86] State:[3] Score: 0 Position i:[-1] j:[87] State:[3] Score: 0 Position i:[-1] j:[88] State:[3] Score: 0 Position i:[-1] j:[89] State:[3] Score: 0 Position i:[-1] j:[90] State:[3] Score: 0 Position i:[-1] j:[91] State:[3] Score: 0 Position i:[-1] j:[92] State:[3] Score: 0 Position i:[-1] j:[93] State:[3] Score: 0 Position i:[-1] j:[94] State:[3] Score: 0 Position i:[-1] j:[95] State:[3] Score: 0 Position i:[-1] j:[96] State:[3] Score: 0 Position i:[-1] j:[97] State:[3] Score: 0 Position i:[-1] j:[98] State:[3] Score: 0 Position i:[-1] j:[99] State:[3] Score: 0 Position i:[-1] j:[100] State:[3] Score: 0 Position i:[-1] j:[101] State:[3] Score: 0 Position i:[-1] j:[102] State:[3] Score: 0 Position i:[-1] j:[103] State:[3] Score: 0 Position i:[-1] j:[104] State:[3] Score: 0 Position i:[-1] j:[105] State:[3] Score: 0 Position i:[-1] j:[106] State:[3] Score: 0 Position i:[-1] j:[107] State:[3] Score: 0 Position i:[-1] j:[108] State:[3] Score: 0 Position i:[-1] j:[109] State:[3] Score: 0 Position i:[-1] j:[110] State:[3] Score: 0 Position i:[-1] j:[111] State:[3] Score: 0 Position i:[-1] j:[112] State:[3] Score: 0 Position i:[-1] j:[113] State:[3] Score: 0 Position i:[-1] j:[114] State:[3] Score: 0 Position i:[-1] j:[115] State:[3] Score: 0 Position i:[-1] j:[116] State:[3] Score: 0 Position i:[-1] j:[117] State:[3] Score: 0 Position i:[-1] j:[118] State:[3] Score: 0 Position i:[-1] j:[119] State:[3] Score: 0 Position i:[-1] j:[120] State:[3] Score: 0 Position i:[-1] j:[121] State:[3] Score: 0 Position i:[-1] j:[122] State:[3] Score: 0 Position i:[-1] j:[123] State:[3] Score: 0 Position i:[-1] j:[124] State:[3] Score: 0 Position i:[-1] j:[125] State:[3] Score: 0 Position i:[-1] j:[126] State:[3] Score: 0 Position i:[-1] j:[127] State:[3] Score: 0 Position i:[-1] j:[128] State:[3] Score: 0 Position i:[-1] j:[129] State:[3] Score: 0 Position i:[-1] j:[130] State:[3] Score: 0 Position i:[-1] j:[131] State:[3] Score: 0 Position i:[-1] j:[132] State:[3] Score: 0 Position i:[-1] j:[133] State:[3] Score: 0 Position i:[-1] j:[134] State:[3] Score: 0 Position i:[-1] j:[135] State:[3] Score: 0 Position i:[-1] j:[136] State:[3] Score: 0 Position i:[-1] j:[137] State:[3] Score: 0 Position i:[-1] j:[138] State:[3] Score: 0 Position i:[-1] j:[139] State:[3] Score: 0 Position i:[-1] j:[140] State:[3] Score: 0 Position i:[-1] j:[141] State:[3] Score: 0 Position i:[-1] j:[142] State:[3] Score: 0 Position i:[-1] j:[143] State:[3] Score: 0 Position i:[-1] j:[144] State:[3] Score: 0 Position i:[-1] j:[145] State:[3] Score: 0 Position i:[-1] j:[146] State:[3] Score: 0 Position i:[-1] j:[147] State:[3] Score: 0 Position i:[-1] j:[148] State:[3] Score: 0 Position i:[-1] j:[149] State:[3] Score: 0 Position i:[-1] j:[150] State:[3] Score: 0 Position i:[-1] j:[151] State:[3] Score: 0 Position i:[-1] j:[152] State:[3] Score: 0 Position i:[-1] j:[153] State:[3] Score: 0 Position i:[-1] j:[154] State:[3] Score: 0 Position i:[-1] j:[155] State:[3] Score: 0 Position i:[-1] j:[156] State:[3] Score: 0 Position i:[-1] j:[157] State:[3] Score: 0 Position i:[-1] j:[158] State:[3] Score: 0 Position i:[-1] j:[159] State:[3] Score: 0 Position i:[-1] j:[160] State:[3] Score: 0 Position i:[-1] j:[161] State:[3] Score: 0 Position i:[-1] j:[162] State:[3] Score: 0 Position i:[-1] j:[163] State:[3] Score: 0 Position i:[-1] j:[164] State:[3] Score: 0 Position i:[-1] j:[165] State:[3] Score: 0 Position i:[-1] j:[166] State:[3] Score: 0 Position i:[-1] j:[167] State:[3] Score: 0 Position i:[-1] j:[168] State:[3] Score: 0 Position i:[-1] j:[169] State:[3] Score: 0 Position i:[-1] j:[170] State:[3] Score: 0 Position i:[-1] j:[171] State:[3] Score: 0 Position i:[-1] j:[172] State:[3] Score: 0 Position i:[-1] j:[173] State:[3] Score: 0 Position i:[-1] j:[174] State:[3] Score: 0 Position i:[-1] j:[175] State:[3] Score: 0 Position i:[-1] j:[176] State:[3] Score: 0 Position i:[-1] j:[177] State:[3] Score: 0 Position i:[-1] j:[178] State:[3] Score: 0 Position i:[-1] j:[179] State:[3] Score: 0 Position i:[-1] j:[180] State:[3] Score: 0 Position i:[-1] j:[181] State:[3] Score: 0 Position i:[-1] j:[182] State:[3] Score: 0 Position i:[-1] j:[183] State:[3] Score: 0 Position i:[-1] j:[184] State:[3] Score: 0 Position i:[-1] j:[185] State:[3] Score: 0 Position i:[-1] j:[186] State:[3] Score: 0 Position i:[-1] j:[187] State:[3] Score: 0 Position i:[-1] j:[188] State:[3] Score: 0 Position i:[-1] j:[189] State:[3] Score: 0 Position i:[-1] j:[190] State:[3] Score: 0 Position i:[-1] j:[191] State:[3] Score: 0 Position i:[-1] j:[192] State:[3] Score: 0 Position i:[-1] j:[193] State:[3] Score: 0 Position i:[-1] j:[194] State:[3] Score: 0 Position i:[-1] j:[195] State:[3] Score: 0 Position i:[-1] j:[196] State:[3] Score: 0 Position i:[-1] j:[197] State:[3] Score: 0 Position i:[-1] j:[198] State:[3] Score: 0 Position i:[-1] j:[199] State:[3] Score: 0 Position i:[-1] j:[200] State:[3] Score: 0 Position i:[-1] j:[201] State:[3] Score: 0 Position i:[-1] j:[202] State:[3] Score: 0 Position i:[-1] j:[203] State:[3] Score: 0 Position i:[-1] j:[204] State:[3] Score: 0 Position i:[-1] j:[205] State:[3] Score: 0 Position i:[-1] j:[206] State:[3] Score: 0 Position i:[-1] j:[207] State:[3] Score: 0 Position i:[-1] j:[208] State:[3] Score: 0 Position i:[-1] j:[209] State:[3] Score: 0 Position i:[-1] j:[210] State:[3] Score: 0 Position i:[-1] j:[211] State:[3] Score: 0 Position i:[-1] j:[212] State:[3] Score: 0 Position i:[-1] j:[213] State:[3] Score: 0 Position i:[-1] j:[214] State:[3] Score: 0 Position i:[-1] j:[215] State:[3] Score: 0 Position i:[-1] j:[216] State:[3] Score: 0 Position i:[-1] j:[217] State:[3] Score: 0 Position i:[-1] j:[218] State:[3] Score: 0 Position i:[-1] j:[219] State:[3] Score: 0 Position i:[-1] j:[220] State:[3] Score: 0 Position i:[-1] j:[221] State:[3] Score: 0 Position i:[-1] j:[222] State:[3] Score: 0 Position i:[-1] j:[223] State:[3] Score: 0 Position i:[-1] j:[224] State:[3] Score: 0 Position i:[-1] j:[225] State:[3] Score: 0 Position i:[-1] j:[226] State:[3] Score: 0 Position i:[-1] j:[227] State:[3] Score: 0 Position i:[-1] j:[228] State:[3] Score: 0 Position i:[-1] j:[229] State:[3] Score: 0 Position i:[-1] j:[230] State:[3] Score: 0 Position i:[-1] j:[231] State:[3] Score: 0 Position i:[-1] j:[232] State:[3] Score: 0 Position i:[-1] j:[233] State:[3] Score: 0 Position i:[-1] j:[234] State:[3] Score: 0 Position i:[-1] j:[235] State:[3] Score: 0 Position i:[-1] j:[236] State:[3] Score: 0 Position i:[-1] j:[237] State:[3] Score: 0 Position i:[-1] j:[238] State:[3] Score: 0 Position i:[-1] j:[239] State:[3] Score: 0 Position i:[-1] j:[240] State:[3] Score: 0 Position i:[-1] j:[241] State:[3] Score: 0 Position i:[-1] j:[242] State:[3] Score: 0 Position i:[-1] j:[243] State:[3] Score: 0 Position i:[-1] j:[244] State:[3] Score: 0 Position i:[-1] j:[245] State:[3] Score: 0 Position i:[-1] j:[246] State:[3] Score: 0 Position i:[-1] j:[247] State:[3] Score: 0 Position i:[-1] j:[248] State:[3] Score: 0 Position i:[-1] j:[249] State:[3] Score: 0 Position i:[-1] j:[250] State:[3] Score: 0 Position i:[-1] j:[251] State:[3] Score: 0 Position i:[-1] j:[252] State:[3] Score: 0 Position i:[-1] j:[253] State:[3] Score: 0 Position i:[-1] j:[254] State:[3] Score: 0 Position i:[-1] j:[255] State:[3] Score: 0 Position i:[-1] j:[256] State:[3] Score: 0 Position i:[-1] j:[257] State:[3] Score: 0 Position i:[-1] j:[258] State:[3] Score: 0 Position i:[-1] j:[259] State:[3] Score: 0 Position i:[-1] j:[260] State:[3] Score: 0 Position i:[-1] j:[261] State:[3] Score: 0 Position i:[-1] j:[262] State:[3] Score: 0 Position i:[-1] j:[263] State:[3] Score: 0 Position i:[-1] j:[264] State:[3] Score: 0 Position i:[-1] j:[265] State:[3] Score: 0 Position i:[-1] j:[266] State:[3] Score: 0 Position i:[-1] j:[267] State:[3] Score: 0 Position i:[-1] j:[268] State:[3] Score: 0 Position i:[-1] j:[269] State:[3] Score: 0 Position i:[-1] j:[270] State:[3] Score: 0 Position i:[-1] j:[271] State:[3] Score: 0 Position i:[-1] j:[272] State:[3] Score: 0 Position i:[-1] j:[273] State:[3] Score: 0 Position i:[-1] j:[274] State:[3] Score: 0 Position i:[-1] j:[275] State:[3] Score: 0 Position i:[-1] j:[276] State:[3] Score: 0 Position i:[-1] j:[277] State:[3] Score: 0 Position i:[-1] j:[278] State:[3] Score: 0 Position i:[-1] j:[279] State:[3] Score: 0 Position i:[-1] j:[280] State:[3] Score: 0 Position i:[-1] j:[281] State:[3] Score: 0 Position i:[-1] j:[282] State:[3] Score: 0 Position i:[-1] j:[283] State:[3] Score: 0 Position i:[-1] j:[284] State:[3] Score: 0 Position i:[-1] j:[285] State:[3] Score: 0 Position i:[-1] j:[286] State:[3] Score: 0 Position i:[-1] j:[287] State:[3] Score: 0 Position i:[-1] j:[288] State:[3] Score: 0 Position i:[-1] j:[289] State:[3] Score: 0 Position i:[-1] j:[290] State:[3] Score: 0 Position i:[-1] j:[291] State:[3] Score: 0 Position i:[-1] j:[292] State:[3] Score: 0 Position i:[-1] j:[293] State:[3] Score: 0 Position i:[-1] j:[294] State:[3] Score: 0 Position i:[-1] j:[295] State:[3] Score: 0 Position i:[-1] j:[296] State:[3] Score: 0 Position i:[-1] j:[297] State:[3] Score: 0 Position i:[-1] j:[298] State:[3] Score: 0 Position i:[-1] j:[299] State:[3] Score: 0 Position i:[-1] j:[300] State:[3] Score: 0 Position i:[-1] j:[301] State:[3] Score: 0 Position i:[-1] j:[302] State:[3] Score: 0 Position i:[-1] j:[303] State:[3] Score: 0 Position i:[-1] j:[304] State:[3] Score: 0 Position i:[-1] j:[305] State:[3] Score: 0 Position i:[-1] j:[306] State:[3] Score: 0 Position i:[-1] j:[307] State:[3] Score: 0 Position i:[-1] j:[308] State:[3] Score: 0 Position i:[-1] j:[309] State:[3] Score: 0 Position i:[-1] j:[310] State:[3] Score: 0 Position i:[-1] j:[311] State:[3] Score: 0 Position i:[-1] j:[312] State:[3] Score: 0 Position i:[-1] j:[313] State:[3] Score: 0 Position i:[-1] j:[314] State:[3] Score: 0 Position i:[-1] j:[315] State:[3] Score: 0 Position i:[-1] j:[316] State:[3] Score: 0 Position i:[-1] j:[317] State:[3] Score: 0 Position i:[-1] j:[318] State:[3] Score: 0 Position i:[-1] j:[319] State:[3] Score: 0 Position i:[-1] j:[320] State:[3] Score: 0 Position i:[-1] j:[321] State:[3] Score: 0 Position i:[-1] j:[322] State:[3] Score: 0 Position i:[-1] j:[323] State:[3] Score: 0 Position i:[-1] j:[324] State:[3] Score: 0 Position i:[-1] j:[325] State:[3] Score: 0 Position i:[-1] j:[326] State:[3] Score: 0 Position i:[-1] j:[327] State:[3] Score: 0 Position i:[-1] j:[328] State:[3] Score: 0 Position i:[-1] j:[329] State:[3] Score: 0 Position i:[-1] j:[330] State:[3] Score: 0 Position i:[-1] j:[331] State:[3] Score: 0 Position i:[-1] j:[332] State:[3] Score: 0 Position i:[-1] j:[333] State:[3] Score: 0 Position i:[-1] j:[334] State:[3] Score: 0 Position i:[-1] j:[335] State:[3] Score: 0 Position i:[-1] j:[336] State:[3] Score: 0 Position i:[-1] j:[337] State:[3] Score: 0 Position i:[-1] j:[338] State:[3] Score: 0 Position i:[-1] j:[339] State:[3] Score: 0 Position i:[-1] j:[340] State:[3] Score: 0 Position i:[-1] j:[341] State:[3] Score: 0 Position i:[-1] j:[342] State:[3] Score: 0 Position i:[-1] j:[343] State:[3] Score: 0 Position i:[-1] j:[344] State:[3] Score: 0 Position i:[-1] j:[345] State:[3] Score: 0 Position i:[-1] j:[346] State:[3] Score: 0 Position i:[-1] j:[347] State:[3] Score: 0 Position i:[-1] j:[348] State:[3] Score: 0 Position i:[-1] j:[349] State:[3] Score: 0 Position i:[-1] j:[350] State:[3] Score: 0 Position i:[-1] j:[351] State:[3] Score: 0 Position i:[-1] j:[352] State:[3] Score: 0 Position i:[-1] j:[353] State:[3] Score: 0 Position i:[-1] j:[354] State:[3] Score: 0 Position i:[-1] j:[355] State:[3] Score: 0 Position i:[-1] j:[356] State:[3] Score: 0 Position i:[-1] j:[357] State:[3] Score: 0 Position i:[-1] j:[358] State:[3] Score: 0 Position i:[-1] j:[359] State:[3] Score: 0 Position i:[-1] j:[360] State:[3] Score: 0 Position i:[-1] j:[361] State:[3] Score: 0 Position i:[-1] j:[362] State:[3] Score: 0 Position i:[-1] j:[363] State:[3] Score: 0 Position i:[-1] j:[364] State:[3] Score: 0 Position i:[-1] j:[365] State:[3] Score: 0 Position i:[-1] j:[366] State:[3] Score: 0 Position i:[-1] j:[367] State:[3] Score: 0 Position i:[-1] j:[368] State:[3] Score: 0 Position i:[-1] j:[369] State:[3] Score: 0 Position i:[-1] j:[370] State:[3] Score: 0 Position i:[-1] j:[371] State:[3] Score: 0 Position i:[-1] j:[372] State:[3] Score: 0 Position i:[-1] j:[373] State:[3] Score: 0 Position i:[-1] j:[374] State:[3] Score: 0 Position i:[-1] j:[375] State:[3] Score: 0 Position i:[-1] j:[376] State:[3] Score: 0 Position i:[-1] j:[377] State:[3] Score: 0 Position i:[-1] j:[378] State:[3] Score: 0 Position i:[-1] j:[379] State:[3] Score: 0 Position i:[-1] j:[380] State:[3] Score: 0 Position i:[-1] j:[381] State:[3] Score: 0 Position i:[-1] j:[382] State:[3] Score: 0 Position i:[-1] j:[383] State:[3] Score: 0 Position i:[-1] j:[384] State:[3] Score: 0 Position i:[-1] j:[385] State:[3] Score: 0 Position i:[-1] j:[386] State:[3] Score: 0 Position i:[-1] j:[387] State:[3] Score: 0 Position i:[-1] j:[388] State:[3] Score: 0 Position i:[-1] j:[389] State:[3] Score: 0 Position i:[-1] j:[390] State:[3] Score: 0 Position i:[-1] j:[391] State:[3] Score: 0 Position i:[-1] j:[392] State:[3] Score: 0 Position i:[-1] j:[393] State:[3] Score: 0 Position i:[-1] j:[394] State:[3] Score: 0 Position i:[-1] j:[395] State:[3] Score: 0 Position i:[-1] j:[396] State:[3] Score: 0 Position i:[-1] j:[397] State:[3] Score: 0 Position i:[-1] j:[398] State:[3] Score: 0 Position i:[-1] j:[399] State:[3] Score: 0 Position i:[-1] j:[400] State:[3] Score: 0 Position i:[-1] j:[401] State:[3] Score: 0 Position i:[-1] j:[402] State:[3] Score: 0 Position i:[-1] j:[403] State:[3] Score: 0 Position i:[-1] j:[404] State:[3] Score: 0 Position i:[-1] j:[405] State:[3] Score: 0 Position i:[-1] j:[406] State:[3] Score: 0 Position i:[-1] j:[407] State:[3] Score: 0 Position i:[-1] j:[408] State:[3] Score: 0 Position i:[-1] j:[409] State:[3] Score: 0 Position i:[-1] j:[410] State:[3] Score: 0 Position i:[-1] j:[411] State:[3] Score: 0 Position i:[-1] j:[412] State:[3] Score: 0 Position i:[-1] j:[413] State:[3] Score: 0 Position i:[0] j:[414] State:[5] Score: 0 // wise-2.4.1/src/test/basic_genomic.out0000644000175000001440000003735310414205303017135 0ustar philippusersgenewise $Name: wise2-4-1 $ (unreleased release) This program is freely distributed under a GPL. See source directory Copyright (c) GRL limited: portions of the code are from separate copyright Query protein: roa1_drome Comp Matrix: BLOSUM62.bla Gap open: 12 Gap extension: 2 Start/End default Target Sequence HSHNCPA1 Strand: forward Start/End (protein) default Gene Parameter file: gene.stat Splice site model: GT/AG only GT/AG bits penalty -9.96 Codon Table: codon.table Subs error: 1e-06 Indel error: 1e-06 Null model syn Algorithm 623 genewise output Score 108.92 bits over entire alignment Scores as bits over a synchronous coding model Warning: The bits scores is not probablistically correct for single seqs See WWW help for more info roa1_drome 23 KLFVGALKDDHDEQSIRDYFQHFGNIVDINIVIDKETGKKRGFAFVEFD K+FVG +K+D +E +RDYF+ +G I I I+ D+ +GKKRGFA V FD KIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAxVTFD HSHNCPA1 14 aatgggaaggaggcccagttgctgaaggagaaagcgagaaagtgtgatg atttggtaaacaaaatgaataaagatattattcaggggaaggtcttcta gatttctaactaatcaatttagtaatagtacgtcactcgagctcNactc roa1_drome 72 DYDPVDKVVLQKQHQLNGKMVDVKKALPKQNDQQGGGGGRGGPG-GRAG D+D VDK+V+QK H +NG +V+KAL KQ RG G G G DHDSVDKIVIQKYHTVNGHNCEVRKALSKQEMASASSSQRGRSGSGNFG HSHNCPA1 161 gcgtggaagacatcagagcatggaagctacgagagttacagcagtgatg aaactaatttaaaactagaagatgactcaaatcgcccgagggggcgatg ctccgtgtctgacttgtccctataacgagaggtttaccaatatttactt roa1_drome 120 GNRGNMGGGNYGNQNGGGNWNNGGNNWGNNR G RG GGN N GGN++ G G +R GGRGGGFGGN-DNFGRGGNFSGRGx-FGGSR HSHNCPA1 308 ggcgggtgga gatgcggatagcgN tggac ggggggtgga aatggggatggggg tgggg tttattctgt cccttaaccttttc ttcct // Bits Query start end Target start end idels introns 108.92 roa1_drome 23 150 HSHNCPA1 14 394 0 0 // Gene 1 Gene 14 394 Exon 14 394 phase 0 // >HSHNCPA1.[14:394].sp.tr KIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAxVTFDDHDSVDKIVIQ KYHTVNGHNCEVRKALSKQEMASASSSQRGRSGSGNFGGGRGGGFGGNDNFGRGGNFSGR GxFGGSR // >HSHNCPA1.[14:394].sp AAGATATTTGTTGGTGGCATTAAAGAAGACACTGAAGAACATCACCTAAGAGATTATTTT GAACAGTATGGAAAAATTGAAGTGATTGAAATCATGACTGACCGAGGCAGTGGCAAGAAA AGGGGCTTTGCCTTNGTAACCTTTGACGACCATGACTCCGTGGATAAGATTGTCATTCAG AAATACCATACTGTGAATGGCCACAACTGTGAAGTTAGAAAAGCCCTGTCAAAGCAAGAG ATGGCTAGTGCTTCATCCAGCCAAAGAGGTCGAAGTGGTTCTGGAAACTTTGGTGGTGGT CGTGGAGGTGGTTTCGGTGGGAATGACAACTTCGGTCGTGGAGGAAACTTCAGTGGTCGT GGTNGCTTTGGTGGCAGCCGT // Sequence HSHNCPA1 subsequence HSHNCPA1.1 14 394 Sequence HSHNCPA1.1 CDS Start_not_found End_not_found CDS_predicted_by genewise 108.92 source_Exons 1 381 // Gene 0 Gene 13 - 394 Transcript 0 Exon 0-381 Translation 0 - 381 // -5.21 [21:22 "MATCH_STATE" -1805],[12:15 "CODON" -1805] 1.00 [22:23 "MATCH_STATE" 345],[15:18 "CODON" 345] 3.06 [23:24 "MATCH_STATE" 1061],[18:21 "CODON" 1061] 1.96 [24:25 "MATCH_STATE" 681],[21:24 "CODON" 681] 2.63 [25:26 "MATCH_STATE" 910],[24:27 "CODON" 910] -0.19 [26:27 "MATCH_STATE" -66],[27:30 "CODON" -66] 1.00 [27:28 "MATCH_STATE" 345],[30:33 "CODON" 345] 2.20 [28:29 "MATCH_STATE" 762],[33:36 "CODON" 762] 0.87 [29:30 "MATCH_STATE" 302],[36:39 "CODON" 302] 2.87 [30:31 "MATCH_STATE" 995],[39:42 "CODON" 995] -1.34 [31:32 "MATCH_STATE" -463],[42:45 "CODON" -463] 0.87 [32:33 "MATCH_STATE" 302],[45:48 "CODON" 302] 2.33 [33:34 "MATCH_STATE" 807],[48:51 "CODON" 807] -0.11 [34:35 "MATCH_STATE" -39],[51:54 "CODON" -39] -0.73 [35:36 "MATCH_STATE" -252],[54:57 "CODON" -252] 1.05 [36:37 "MATCH_STATE" 364],[57:60 "CODON" 364] 2.48 [37:38 "MATCH_STATE" 860],[60:63 "CODON" 860] 2.87 [38:39 "MATCH_STATE" 995],[63:66 "CODON" 995] 3.40 [39:40 "MATCH_STATE" 1178],[66:69 "CODON" 1178] 3.06 [40:41 "MATCH_STATE" 1061],[69:72 "CODON" 1061] 0.88 [41:42 "MATCH_STATE" 306],[72:75 "CODON" 306] -0.33 [42:43 "MATCH_STATE" -116],[75:78 "CODON" -116] 1.56 [43:44 "MATCH_STATE" 542],[78:81 "CODON" 542] 2.63 [44:45 "MATCH_STATE" 910],[81:84 "CODON" 910] -0.20 [45:46 "MATCH_STATE" -69],[84:87 "CODON" -69] 2.05 [46:47 "MATCH_STATE" 711],[87:90 "CODON" 711] -1.03 [47:48 "MATCH_STATE" -358],[90:93 "CODON" -358] -1.63 [48:49 "MATCH_STATE" -564],[93:96 "CODON" -564] 2.05 [49:50 "MATCH_STATE" 711],[96:99 "CODON" 711] -0.20 [50:51 "MATCH_STATE" -69],[99:102 "CODON" -69] 2.05 [51:52 "MATCH_STATE" 711],[102:105 "CODON" 711] 0.46 [52:53 "MATCH_STATE" 161],[105:108 "CODON" 161] -0.45 [53:54 "MATCH_STATE" -155],[108:111 "CODON" -155] 2.87 [54:55 "MATCH_STATE" 995],[111:114 "CODON" 995] 0.70 [55:56 "MATCH_STATE" 242],[114:117 "CODON" 242] -1.17 [56:57 "MATCH_STATE" -405],[117:120 "CODON" -405] 0.32 [57:58 "MATCH_STATE" 111],[120:123 "CODON" 111] 2.63 [58:59 "MATCH_STATE" 910],[123:126 "CODON" 910] 2.20 [59:60 "MATCH_STATE" 762],[126:129 "CODON" 762] 2.20 [60:61 "MATCH_STATE" 762],[129:132 "CODON" 762] 2.48 [61:62 "MATCH_STATE" 860],[132:135 "CODON" 860] 2.63 [62:63 "MATCH_STATE" 910],[135:138 "CODON" 910] 3.06 [63:64 "MATCH_STATE" 1061],[138:141 "CODON" 1061] 1.81 [64:65 "MATCH_STATE" 626],[141:144 "CODON" 626] -3.96 [65:66 "MATCH_STATE" -1372],[144:147 "CODON" -1372] 1.96 [66:67 "MATCH_STATE" 681],[147:150 "CODON" 681] -0.67 [67:68 "MATCH_STATE" -232],[150:153 "CODON" -232] 3.06 [68:69 "MATCH_STATE" 1061],[153:156 "CODON" 1061] 2.87 [69:70 "MATCH_STATE" 995],[156:159 "CODON" 995] 2.87 [70:71 "MATCH_STATE" 995],[159:162 "CODON" 995] 0.90 [71:72 "MATCH_STATE" 312],[162:165 "CODON" 312] 2.87 [72:73 "MATCH_STATE" 995],[165:168 "CODON" 995] -0.72 [73:74 "MATCH_STATE" -251],[168:171 "CODON" -251] 1.96 [74:75 "MATCH_STATE" 681],[171:174 "CODON" 681] 2.87 [75:76 "MATCH_STATE" 995],[174:177 "CODON" 995] 2.20 [76:77 "MATCH_STATE" 762],[177:180 "CODON" 762] 1.47 [77:78 "MATCH_STATE" 508],[180:183 "CODON" 508] 1.96 [78:79 "MATCH_STATE" 681],[183:186 "CODON" 681] 1.00 [79:80 "MATCH_STATE" 345],[186:189 "CODON" 345] 2.38 [80:81 "MATCH_STATE" 826],[189:192 "CODON" 826] 2.20 [81:82 "MATCH_STATE" 762],[192:195 "CODON" 762] -0.61 [82:83 "MATCH_STATE" -213],[195:198 "CODON" -213] 3.66 [83:84 "MATCH_STATE" 1269],[198:201 "CODON" 1269] -0.61 [84:85 "MATCH_STATE" -213],[201:204 "CODON" -213] 0.50 [85:86 "MATCH_STATE" 172],[204:207 "CODON" 172] 2.80 [86:87 "MATCH_STATE" 970],[207:210 "CODON" 970] 2.63 [87:88 "MATCH_STATE" 910],[210:213 "CODON" 910] -0.80 [88:89 "MATCH_STATE" -277],[213:216 "CODON" -277] -0.94 [89:90 "MATCH_STATE" -326],[216:219 "CODON" -326] -0.53 [90:91 "MATCH_STATE" -184],[219:222 "CODON" -184] 0.87 [91:92 "MATCH_STATE" 302],[222:225 "CODON" 302] 1.96 [92:93 "MATCH_STATE" 681],[225:228 "CODON" 681] 0.70 [93:94 "MATCH_STATE" 242],[228:231 "CODON" 242] 2.20 [94:95 "MATCH_STATE" 762],[231:234 "CODON" 762] 1.81 [95:96 "MATCH_STATE" 626],[234:237 "CODON" 626] 2.00 [96:97 "MATCH_STATE" 692],[237:240 "CODON" 692] -0.72 [97:98 "MATCH_STATE" -251],[240:243 "CODON" -251] 2.20 [98:99 "MATCH_STATE" 762],[243:246 "CODON" 762] 2.38 [99:100 "MATCH_STATE" 826],[246:249 "CODON" 826] -0.20 [100:101 "MATCH_STATE" -69],[249:252 "CODON" -69] -1.63 [101:102 "MATCH_STATE" -564],[252:255 "CODON" -564] -0.61 [102:103 "MATCH_STATE" -213],[255:258 "CODON" -213] -0.11 [103:104 "MATCH_STATE" -39],[258:261 "CODON" -39] -0.37 [104:105 "MATCH_STATE" -129],[261:264 "CODON" -129] -0.37 [105:106 "MATCH_STATE" -129],[264:267 "CODON" -129] -0.37 [106:107 "MATCH_STATE" -129],[267:270 "CODON" -129] -0.37 [107:108 "MATCH_STATE" -129],[270:273 "CODON" -129] -1.37 [108:109 "MATCH_STATE" -476],[273:276 "CODON" -476] 2.48 [109:110 "MATCH_STATE" 860],[276:279 "CODON" 860] 2.63 [110:111 "MATCH_STATE" 910],[279:282 "CODON" 910] -1.37 [111:112 "MATCH_STATE" -476],[282:285 "CODON" -476] -0.72 [112:113 "MATCH_STATE" -251],[285:288 "CODON" -251] 2.63 [113:114 "MATCH_STATE" 910],[288:291 "CODON" 910] -5.00 [114:114 "INSERT_STATE" -1732],[291:294 "CODON" -1732] 1.72 [114:115 "MATCH_STATE" 596],[294:297 "CODON" 596] -0.02 [115:116 "MATCH_STATE" -6],[297:300 "CODON" -6] -1.19 [116:117 "MATCH_STATE" -413],[300:303 "CODON" -413] 2.63 [117:118 "MATCH_STATE" 910],[303:306 "CODON" 910] 2.63 [118:119 "MATCH_STATE" 910],[306:309 "CODON" 910] -0.20 [119:120 "MATCH_STATE" -69],[309:312 "CODON" -69] 2.48 [120:121 "MATCH_STATE" 860],[312:315 "CODON" 860] 2.63 [121:122 "MATCH_STATE" 910],[315:318 "CODON" 910] -0.20 [122:123 "MATCH_STATE" -69],[318:321 "CODON" -69] -1.44 [123:124 "MATCH_STATE" -499],[321:324 "CODON" -499] -1.87 [124:125 "MATCH_STATE" -649],[324:327 "CODON" -649] 2.63 [125:126 "MATCH_STATE" 910],[327:330 "CODON" 910] 2.63 [126:127 "MATCH_STATE" 910],[330:333 "CODON" 910] 2.80 [127:128 "MATCH_STATE" 970],[333:336 "CODON" 970] -5.00 [128:129 "DELETE_STATE" -1732],[336:336 "INSERT" -1732] -1.78 [129:130 "MATCH_STATE" -616],[336:339 "CODON" -616] 2.80 [130:131 "MATCH_STATE" 970],[339:342 "CODON" 970] -1.61 [131:132 "MATCH_STATE" -559],[342:345 "CODON" -559] -0.20 [132:133 "MATCH_STATE" -69],[345:348 "CODON" -69] -1.37 [133:134 "MATCH_STATE" -476],[348:351 "CODON" -476] 2.63 [134:135 "MATCH_STATE" 910],[351:354 "CODON" 910] 2.63 [135:136 "MATCH_STATE" 910],[354:357 "CODON" 910] 2.80 [136:137 "MATCH_STATE" 970],[357:360 "CODON" 970] 0.47 [137:138 "MATCH_STATE" 163],[360:363 "CODON" 163] 0.30 [138:139 "MATCH_STATE" 103],[363:366 "CODON" 103] -0.20 [139:140 "MATCH_STATE" -69],[366:369 "CODON" -69] -1.37 [140:141 "MATCH_STATE" -476],[369:372 "CODON" -476] 2.63 [141:142 "MATCH_STATE" 910],[372:375 "CODON" 910] -0.34 [142:143 "MATCH_STATE" -117],[375:378 "CODON" -117] -5.00 [143:144 "DELETE_STATE" -1732],[378:378 "INSERT" -1732] -0.44 [144:145 "MATCH_STATE" -151],[378:381 "CODON" -151] 2.63 [145:146 "MATCH_STATE" 910],[381:384 "CODON" 910] -0.20 [146:147 "MATCH_STATE" -69],[384:387 "CODON" -69] 0.30 [147:148 "MATCH_STATE" 103],[387:390 "CODON" 103] 2.48 [148:149 "MATCH_STATE" 860],[390:393 "CODON" 860] // Score 37750 Position i:[21] j:[12] State:[6] Score: 0 Position i:[22] j:[15] State:[0] Score: -1805 Position i:[23] j:[18] State:[0] Score: 345 Position i:[24] j:[21] State:[0] Score: 1061 Position i:[25] j:[24] State:[0] Score: 681 Position i:[26] j:[27] State:[0] Score: 910 Position i:[27] j:[30] State:[0] Score: -66 Position i:[28] j:[33] State:[0] Score: 345 Position i:[29] j:[36] State:[0] Score: 762 Position i:[30] j:[39] State:[0] Score: 302 Position i:[31] j:[42] State:[0] Score: 995 Position i:[32] j:[45] State:[0] Score: -463 Position i:[33] j:[48] State:[0] Score: 302 Position i:[34] j:[51] State:[0] Score: 807 Position i:[35] j:[54] State:[0] Score: -39 Position i:[36] j:[57] State:[0] Score: -252 Position i:[37] j:[60] State:[0] Score: 364 Position i:[38] j:[63] State:[0] Score: 860 Position i:[39] j:[66] State:[0] Score: 995 Position i:[40] j:[69] State:[0] Score: 1178 Position i:[41] j:[72] State:[0] Score: 1061 Position i:[42] j:[75] State:[0] Score: 306 Position i:[43] j:[78] State:[0] Score: -116 Position i:[44] j:[81] State:[0] Score: 542 Position i:[45] j:[84] State:[0] Score: 910 Position i:[46] j:[87] State:[0] Score: -69 Position i:[47] j:[90] State:[0] Score: 711 Position i:[48] j:[93] State:[0] Score: -358 Position i:[49] j:[96] State:[0] Score: -564 Position i:[50] j:[99] State:[0] Score: 711 Position i:[51] j:[102] State:[0] Score: -69 Position i:[52] j:[105] State:[0] Score: 711 Position i:[53] j:[108] State:[0] Score: 161 Position i:[54] j:[111] State:[0] Score: -155 Position i:[55] j:[114] State:[0] Score: 995 Position i:[56] j:[117] State:[0] Score: 242 Position i:[57] j:[120] State:[0] Score: -405 Position i:[58] j:[123] State:[0] Score: 111 Position i:[59] j:[126] State:[0] Score: 910 Position i:[60] j:[129] State:[0] Score: 762 Position i:[61] j:[132] State:[0] Score: 762 Position i:[62] j:[135] State:[0] Score: 860 Position i:[63] j:[138] State:[0] Score: 910 Position i:[64] j:[141] State:[0] Score: 1061 Position i:[65] j:[144] State:[0] Score: 626 Position i:[66] j:[147] State:[0] Score: -1372 Position i:[67] j:[150] State:[0] Score: 681 Position i:[68] j:[153] State:[0] Score: -232 Position i:[69] j:[156] State:[0] Score: 1061 Position i:[70] j:[159] State:[0] Score: 995 Position i:[71] j:[162] State:[0] Score: 995 Position i:[72] j:[165] State:[0] Score: 312 Position i:[73] j:[168] State:[0] Score: 995 Position i:[74] j:[171] State:[0] Score: -251 Position i:[75] j:[174] State:[0] Score: 681 Position i:[76] j:[177] State:[0] Score: 995 Position i:[77] j:[180] State:[0] Score: 762 Position i:[78] j:[183] State:[0] Score: 508 Position i:[79] j:[186] State:[0] Score: 681 Position i:[80] j:[189] State:[0] Score: 345 Position i:[81] j:[192] State:[0] Score: 826 Position i:[82] j:[195] State:[0] Score: 762 Position i:[83] j:[198] State:[0] Score: -213 Position i:[84] j:[201] State:[0] Score: 1269 Position i:[85] j:[204] State:[0] Score: -213 Position i:[86] j:[207] State:[0] Score: 172 Position i:[87] j:[210] State:[0] Score: 970 Position i:[88] j:[213] State:[0] Score: 910 Position i:[89] j:[216] State:[0] Score: -277 Position i:[90] j:[219] State:[0] Score: -326 Position i:[91] j:[222] State:[0] Score: -184 Position i:[92] j:[225] State:[0] Score: 302 Position i:[93] j:[228] State:[0] Score: 681 Position i:[94] j:[231] State:[0] Score: 242 Position i:[95] j:[234] State:[0] Score: 762 Position i:[96] j:[237] State:[0] Score: 626 Position i:[97] j:[240] State:[0] Score: 692 Position i:[98] j:[243] State:[0] Score: -251 Position i:[99] j:[246] State:[0] Score: 762 Position i:[100] j:[249] State:[0] Score: 826 Position i:[101] j:[252] State:[0] Score: -69 Position i:[102] j:[255] State:[0] Score: -564 Position i:[103] j:[258] State:[0] Score: -213 Position i:[104] j:[261] State:[0] Score: -39 Position i:[105] j:[264] State:[0] Score: -129 Position i:[106] j:[267] State:[0] Score: -129 Position i:[107] j:[270] State:[0] Score: -129 Position i:[108] j:[273] State:[0] Score: -129 Position i:[109] j:[276] State:[0] Score: -476 Position i:[110] j:[279] State:[0] Score: 860 Position i:[111] j:[282] State:[0] Score: 910 Position i:[112] j:[285] State:[0] Score: -476 Position i:[113] j:[288] State:[0] Score: -251 Position i:[114] j:[291] State:[0] Score: 910 Position i:[114] j:[294] State:[1] Score: -1732 Position i:[115] j:[297] State:[0] Score: 596 Position i:[116] j:[300] State:[0] Score: -6 Position i:[117] j:[303] State:[0] Score: -413 Position i:[118] j:[306] State:[0] Score: 910 Position i:[119] j:[309] State:[0] Score: 910 Position i:[120] j:[312] State:[0] Score: -69 Position i:[121] j:[315] State:[0] Score: 860 Position i:[122] j:[318] State:[0] Score: 910 Position i:[123] j:[321] State:[0] Score: -69 Position i:[124] j:[324] State:[0] Score: -499 Position i:[125] j:[327] State:[0] Score: -649 Position i:[126] j:[330] State:[0] Score: 910 Position i:[127] j:[333] State:[0] Score: 910 Position i:[128] j:[336] State:[0] Score: 970 Position i:[129] j:[336] State:[2] Score: -1732 Position i:[130] j:[339] State:[0] Score: -616 Position i:[131] j:[342] State:[0] Score: 970 Position i:[132] j:[345] State:[0] Score: -559 Position i:[133] j:[348] State:[0] Score: -69 Position i:[134] j:[351] State:[0] Score: -476 Position i:[135] j:[354] State:[0] Score: 910 Position i:[136] j:[357] State:[0] Score: 910 Position i:[137] j:[360] State:[0] Score: 970 Position i:[138] j:[363] State:[0] Score: 163 Position i:[139] j:[366] State:[0] Score: 103 Position i:[140] j:[369] State:[0] Score: -69 Position i:[141] j:[372] State:[0] Score: -476 Position i:[142] j:[375] State:[0] Score: 910 Position i:[143] j:[378] State:[0] Score: -117 Position i:[144] j:[378] State:[2] Score: -1732 Position i:[145] j:[381] State:[0] Score: -151 Position i:[146] j:[384] State:[0] Score: 910 Position i:[147] j:[387] State:[0] Score: -69 Position i:[148] j:[390] State:[0] Score: 103 Position i:[149] j:[393] State:[0] Score: 860 // wise-2.4.1/src/dynamite_examples/0000755000175000001440000000000010670453571016360 5ustar philippuserswise-2.4.1/src/dynamite_examples/est2gen.c0000644000175000001440000001320207313404536020066 0ustar philippusers/** * This file is part of Dynamite It is copyright (c) 1998 by Ewan Birney and the Sanger Centre. The dynamite source code is distributed under a GNU public license. Please seee GNULICENSE file in the root directory for this package. None of this code has any implied use or warranty. Please read the license carefully for explanations about re-distribution. Please get in contact with Ewan at birney@sanger.ac.uk This file was part of the 1.0 release, Tue Jan 20 14:53:11 1998 * **/ /* * include cdna2genomic.h - will include the dynamite * produced declarations provided */ #include "cdna2genomic.h" /* * fancy display */ #include "estgendisplay.h" void show_help(FILE * ofp) { fprintf(ofp,"\nest2gen est-seq genomic-seq\nBoth sequences in fasta format\n" "\tOPTIONS\n" "\t-g gap penalty (default 2)\n" "\t-e ext penatly (default 1)\n" "\t-m match score (default 4)\n" "\t-n mismatch score (default -3)\n" "\t-r show raw output\n" "\t-l show label output\n" "\t-f show fancy output\n" "\t (default, -f, all outputs can be shown together\n)" ); } int main(int argc,char ** argv) { Sequence * query; Sequence * target; ComplexSequence * query_cs; ComplexSequence * target_cs; int gap = (2); int ext = (1); int match = (4); int mismatch = (-3); Score cdna_open,cdna_ext,gen_open,gen_ext,intron_open; DnaMatrix * dm; ComplexSequenceEvalSet * cses_g; ComplexSequenceEvalSet * cses_c; boolean show_raw_output = FALSE; boolean show_label_output = FALSE; boolean show_fancy_output = FALSE; boolean has_outputted = FALSE; PackAln * pal; AlnBlock * alb; /* * Process command line options * * Use calls to commandline.h functions * */ if( strip_out_boolean_argument(&argc,argv,"h") == TRUE || strip_out_boolean_argument(&argc,argv,"-help") == TRUE) { show_help(stdout); exit(1); } show_raw_output = strip_out_boolean_argument(&argc,argv,"r"); show_label_output = strip_out_boolean_argument(&argc,argv,"l"); show_fancy_output = strip_out_boolean_argument(&argc,argv,"f"); /** if all FALSE, set fancy to TRUE **/ if( show_raw_output == FALSE && show_label_output == FALSE ) show_fancy_output = TRUE; (void) strip_out_integer_argument(&argc,argv,"g",&gap); (void) strip_out_integer_argument(&argc,argv,"e",&ext); (void) strip_out_integer_argument(&argc,argv,"m",&match); (void) strip_out_integer_argument(&argc,argv,"n",&mismatch); if( argc != 3 ) { warn("Must have two arguments for sequence 1 and sequence 2 %d",argc); show_help(stdout); exit(1); } /* * Read in two sequences */ if( (query=read_fasta_file_Sequence(argv[1])) == NULL ) { fatal("Unable to read the sequence in file %s",argv[1]); } if( (target=read_fasta_file_Sequence(argv[2])) == NULL ) { fatal("Unable to read the sequence in file %s",argv[2]); } /* * build dna matrix */ dm = identity_DnaMatrix(match,mismatch); /* * Convert sequences to ComplexSequences: * To do this we need a cdna ComplexSequenceEvalSet and a genomic one * * Really our genomic model should be alot more complex. The 'default' one * has 0 at GT----AG for 5' and 3' splice sites, and NEGI (= -infinity) * elsewhere. * * We could build up something much better, using complexconsensi and * other machinery, but not for now . See the genewise code if you * want to get scared. */ cses_g = default_genomic_ComplexSequenceEvalSet(); cses_c = default_cDNA_ComplexSequenceEvalSet(); query_cs = new_ComplexSequence(query,cses_c); if( query_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",query->name); } target_cs = new_ComplexSequence(target,cses_g); if( target_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",target->name); } free_ComplexSequenceEvalSet(cses_g); free_ComplexSequenceEvalSet(cses_c); /* * Make an alignment using best memory * * cDNA2Gen has alot more parameter space than the parameters to this * program. Firstly we are treating errors similarly on each side of the * sequences (? correct). * * Secondly there is a rather complex interaction between the gap/extension * of what is thought to be sequencing error and the introns. Here we have * one more parameter, and intron open penalty, which can be set, to prevent * the more permissive use of introns to 'cheat' gaps. * * One good way to parameterise all this would be to have a probabilistic * model of the processes, derive probabilities and then map them to ints * (probability.h has got these mappings, such as Probability2Score). * * but this is not done here... */ pal = PackAln_bestmemory_cDNA2Gen(query_cs,target_cs,dm,gap,-ext,-gap,-ext,0,NULL); if( pal == NULL ) { fatal("Unable to make an alignment from %s and %s",query->name,target->name); } /* * ok, make other alignment forms, and be ready to show */ alb = convert_PackAln_to_AlnBlock_cDNA2Gen(pal); /* * show output. If multiple outputs, divide using // */ if( show_raw_output == TRUE ) { show_simple_PackAln(pal,stdout); puts("//\n"); } if( show_label_output == TRUE ) { show_flat_AlnBlock(alb,stdout); puts("//\n"); } if( show_fancy_output == TRUE ) { write_pretty_estgen_seq_align(alb,query,target,15,50,stdout); puts("//\n"); } /* * Destroy the memory. */ free_Sequence(query); free_Sequence(target); free_DnaMatrix(dm); free_ComplexSequence(query_cs); free_ComplexSequence(target_cs); free_PackAln(pal); free_AlnBlock(alb); return 0; } wise-2.4.1/src/dynamite_examples/estgendisplay.dy0000644000175000001440000001075307313404536021574 0ustar philippusers %{ #include "dyna.h" %} %{ #include "seqaligndisplay.h" %func This gives an interface into the alignment display using sequences and files. A more generic function is write_pretty_str_align %% boolean write_pretty_estgen_seq_align(AlnBlock * alb,Sequence * q,Sequence * t,int name,int main,FILE * ofp) { char qname[64]; char tname[64]; btCanvas * btc; char * temp; if( name > 64 ) { warn("Sorry - hard coded limited, can't have names longer than 64"); return FALSE; } if( strlen(q->name) > name ) { warn("Name %s is longer than allowed name block (%d). Truncating\n",q->name,name); strncpy(qname,q->name,name); qname[name] = '\0'; } else { strcpy(qname,q->name); } if( strlen(t->name) > name ) { warn("Name %s is longer than allowed name block (%d). Truncating\n",t->name,name); strncpy(tname,t->name,name); tname[name] = '\0'; } else { strcpy(tname,t->name); } btc = new_Ascii_btCanvas(ofp,name+6,main,0,3); /*+6 in case we want to put in numbers */ write_pretty_estgen_align(alb,qname,q->seq,q->offset,tname,t->seq,t->offset,name,btc); /** destroy btc canvas **/ free_btCanvas(btc); return TRUE; } %func This is tied to the labels in cdna2genomic.dy Notice the use of start/end points. %% boolean write_pretty_estgen_align(AlnBlock * alb,char * qname,char * query,int q_start,char * tname,char * target,int t_start,int name,btCanvas * btc) { char buffer[512]; AlnColumn * alc; AlnUnit * q; AlnUnit * t; int start; /* for introns */ int end; btPasteArea * btp; for(alc=alb->start;alc != NULL;) { /** put names in **/ btp = get_reserved_left_btCanvas(btc); paste_string_btPasteArea(btp,0,0,qname,BC_RIGHT,0); paste_string_btPasteArea(btp,0,2,tname,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[0]->start+q_start+1); paste_string_btPasteArea(btp,name+1,0,buffer,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[1]->start+t_start+1); paste_string_btPasteArea(btp,name+1,2,buffer,BC_RIGHT,0); free_btPasteArea(btp); /** now loop over this block **/ for(;alc != NULL && can_get_paste_area_btCanvas(btc,1) == TRUE;alc=alc->next) { q = alc->alu[0]; t = alc->alu[1]; /* * at the end, break */ if( strcmp(q->text_label,"END") == 0 ) { alc = NULL; break; } /* * If this is an intron, do something special * */ if( strcmp(t->text_label,"5SS") == 0 ) { if( can_get_paste_area_btCanvas(btc,13) == FALSE ) { break; /* will advance line, then we can get back to here */ } start = t->start; alc=alc->next; /* moves to central intron segment */ end = alc->alu[1]->end; btp = get_paste_area_btCanvas(btc,13); sprintf(buffer,"<-%4d:%4d->",start+1+t_start,end+t_start); paste_string_btPasteArea(btp,0,2,buffer,BC_RIGHT,0); free_btPasteArea(btp); continue; /* next column */ } /* * Get the paste area, length 1, depth will be 3 */ btp = get_paste_area_btCanvas(btc,1); /* * Write in the query sequence * */ if( strcmp(q->text_label,"SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,0,query[q->start+1],0); } else { /** is insert- we could check **/ if( strcmp(q->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",q->text_label); paste_char_btPasteArea(btp,0,0,'?',0); } else { paste_char_btPasteArea(btp,0,0,'-',0); } } /* * Write in the target sequence * */ if( strcmp(t->text_label,"SEQUENCE") == 0 || strcmp(t->text_label,"3SS") == 0) { paste_char_btPasteArea(btp,0,2,target[t->start+1],0); } else { /** is insert- we could check **/ if( strcmp(t->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",t->text_label); paste_char_btPasteArea(btp,0,2,'?',0); } else { paste_char_btPasteArea(btp,0,2,'-',0); } } /* * Match line */ if( strcmp(q->text_label,"SEQUENCE") == 0 && (strcmp(t->text_label,"SEQUENCE") == 0 || strcmp(t->text_label,"3SS") == 0) ) { if( q->score[0] > 0 ) { if( query[q->start+1] == target[t->start+1] ) { paste_char_btPasteArea(btp,0,1,target[t->start+1],0); } else { paste_char_btPasteArea(btp,0,1,'+',0); } } } else paste_char_btPasteArea(btp,0,1,' ',0); free_btPasteArea(btp); } /* end of for this block */ advance_line_btCanvas(btc); } /* end of for the alignment */ return TRUE; /* we never returned false. Ooops! */ } %} wise-2.4.1/src/dynamite_examples/genomic.dna0000644000175000001440000001253407313404536020467 0ustar philippusers>HSHNRNPA GGGATTGAGAGTGATCACTCACGCTAACGTCTGCCCTGTTCCTGTATGGTGAGGCCGCAC CACAAGCCACCACCGCCGCCGCCTTCTGCGCAACGCCAACCGCCCGCCAAAACGGATCCT TCCCTGCGCCTGCGCAACCAATCTTGGGACCGGACCTTTTTTCTCCGCCCACTACGCATG CGCAAAGCTAGGACAAACTCCCGCCAACACGCAGGCGCCGTAGGTTCACTGCCTACTCCT GCCCGCCATTTCACGTGTTCTCAGAGGCAGGTGGAACTTCTTAATGCGCCTGCGCAAAAC TCGCCATTTTACTACACGTGCGGTCAACAAGAGTTCATTGCAAAAAAATTGTTACCTCCT AGCTGCTTGTCTAATACATAGTGTTAATCATGCTTTGCCAAGCGACTTGACTGTAATATT TGCGCGTGGAAGATTAAAAAGATGTTAAACACCCAAGGTAGATTCAAATGTGAATGATTG GTCGGTTGGCCAATCAGACTGGTTAACAATAACATTACTCGGGAACCAATGGACTCCAAG GGGTGGAGACGGCGTAGAACGACCGAAGGAATGACGTTACACAGCAATGTGGCACCACAG GCCAATAGCAGGGGGAAGCGATTTCAAGTATCCAATCAGAGCTGTTCTAGGGCGGAGTCT ACCAATGCCGAAAGCGAGGAGGCGGGGTAAAAAAGAGAGGGCGAAGGTAGGCTGGCAGAT ACGTTCGTCAGCTTGCTCCTTTCTGCCCGTGGACGCCGCCGAAGAAGCATCGTTAAAGTC TCTCTTCACCCTGCCGTCATGTCTAAGTCAGAGGTGAGTTAGGCGCGCTTTCCCACTTGA ATTTTTTCCTCTCCCTTTCCTGAATCGGTAAGATGCTGCTGGGTTTCGTTCCTTGCACCA GCCCATTCTACAGTTCCTTCGGTCGCTGCCACGGCCTACCCCTCCCAAAGTTCAAGTCGC CATTTTGTCCTCTTGATCGCCATGAGGCCGCTCTCCGCCAACCATGTGTTATCATGCGGG ACTCGTTACTCGTAGCAAAATTCTTAGGCACACAGGATCTTTGTCTTTTTTTAAACCTTG CCTTGGTGAGCGAGTTTTCTAAAGAGCGATTAGTCCCATTGTGGAGATGCACCCCTACCG CCCAAGCCTTTGTTGCGCGTGCGTCGGAAGGCGACTAGGGACGCATGCGCTTGCGATTTC CTAGCACTCCCAACTCCAGCATACGGCCTCCCTTGATAGGCAGAAGCACGTGTCTTGTTG CGACCTGAACGAACAATAAGTGCTAGGTACACAGTTGGTGTCTAGTTTTTCTTTTCCTCG ATGGAAATTGTTTCGTGTTGTAGCCCATTTAACACTTCCCCCTCCCCCCACTCTAGTCTC CTAAAGAGCCCGAACAGCTGAGGAAGCTCTTCATTGGAGGGTTGAGCTTTGAAACAACTG ATGAGAGCCTGAGGAGCCATTTTGAGCAATGGGGAACGCTCACGGACTGTGTGGTAAGAT TTGGAAGGGACAAAGCAGTAAAACAGCCGATTTCCTTGGCTTATCTTGGTGCAGTCTTCT CCGAATGCTTATGAAAGTAGTTAATAGCATTATAGTTAGAGCTTTGTTGGCAAAGGAACG TCCTGCTTTGATTTTAAAAGCTAACCTCTTAAATCTAAGGGTAGTGGGAAACTGGACGAA CTTTTTATAAAAGGCTGGTGTAAAGTTTCCTATTGCCCTATTCAAAGTTAAAATAACAAA AGCTTTTGCGGTCAGACTTTGTGTTACATAAATTAACACTGTTCTCAGGTAATGAGAGAT CCAAACACCAAGCGCTCTAGGGGCTTTGGGTTTGTCACATATGCCACTGTGGAGGAGGTG GATGCAGCTATGAATGCAAGGCCACACAAGGTGGATGGAAGAGTTGTGGAACCAAAGAGA GCTGTCTCCAGAGAAGTGAGTGGGTTTTTTTTCTTCTTCTTCTTAAACTTACTTGGATAT GTGCTGCTATGAACTTAAGATTCGGGAGTTTTCTAAACTTACCAAAATTTTTTATTCGAG TATAGGCTTTGCTAATCTAAACCTATGGTTTTTCTCCTATTAGGATTCTCAAAGACCAGG TGCCCACTTAACTGTGAAAAAGATATTTGTTGGTGGCATTAAAGAAGACACTGAAGAACA TCACCTAAGAGATTATTTTGAACAGTATGGAAAAATTGAAGTGATTGAAATCATGACTGA CCGAGGCAGTGGCAAGAAAAGGGGCTTTGCCTTTGTAACCTTTGACGACCATGACTCCGT GGATAAGATTGTCAGTAAGTATCAGATAGTGGCATTTAGTAAGGGTTCCACAATCTGTAT GGCATTCTAAACCCTGATACCATGTTGTATCTATGTTTTTTTTTTAGTTCAGAAATACCA TACTGTGAATGGCCACAACTGTGAAGTTAGAAAAGCCCTGTCAAAGCAAGAGATGGCTAG TGCTTCATCCAGCCAAAGAGGTATGCTTGTTGCTTAATTAAACCTTAAAGGTAACTTTGA GTTACTCCAGTATGAATGATTTAATGCTTAAACTTCATGTCTTAAGGTCGAAGTGGTTCT GGAAACTTTGGTGGTGGTCGTGGAGGTGGTTTCGGTGGGAATGACAACTTCGGTCGTGGA GGAAACTTCAGTGGTCGTGGTATGTATGGTTTATCTACATGTAGTTCTGACTTCTCACCA TCTTTGCTATGAAGATTTTACAGTACGGGAACTGCATTCAGAATGTCACTTTAAGTCCAA GTCATACTTAAAACTTGAAACTTTTTCTTACAGGTGGCTTTGGTGGCAGCCGTGGTGGTG GTGGATATGGTGGCAGTGGGGATGGCTATAATGGATTTGGCAATGATGGTAAGTTTTTTA GGAATAAGTAGAGAAAAATTCCTGGCAACCTGGATCTTTAGAATAGGTTAGTAGAGACTA AAATTCTGGTGCATGTCAAACTCAACTTTGCCCATAACACGCATGCTGTGAGCAGGCCTT CAGCCGTTACACTTGCACAAGTTTTCATTGTCAAATACTTTTGTCTTATTGAGAAGAATT GTATTCTTGTAGGTGGTTATGGAGGAGGCGGCCCTGGTTACTCTGGAGGAAGCAGAGGCT ATGGAAGTGGTGGACAGGGTTATGGAAACCAGGGCAGTGGCTATGGCGGGAGTGGCAGCT ATGACAGCTATAACAACGGAGGCGGAGGCGGCTTTGGCGGTGGTAGTGGTAGGTATCCAG TGATCCAAGTACTTGGTGTGACAGCTAGATTAGCCTTTTAGAGCTTGGGTTCTGGTGCTG TTGAAGCATTGTGTGGTACACTGCATGGTATATTAAAAACAAATGGGCTTGCTATGCTAC CTCCTCCTAGCTTTAAGCTGGGGCCGCCTCACTCCCAAATAGTAGAGATAAGTGGATAGT GTTGTCTTTGAGTTAGATTAGTATCATAGAAGGATTTAGTATTTTAACTCCTTTGGGACC TTAGGCGCTTAGTTGATGTATCCAAGATACTTCTGCTTGCTGTGGCCCTGGATCCGTGAA GGCCTTCAAGGCTGAAGGGTATGCTTGTGCCACTCTGAAAATCTCTTTATTTTATGTCAT GGTGAGTTAGGCCAGTTTTCTTTGTATTACTGGATTATTCAACTGAATGCCTTTCCCAGA GAATGAAATGCAAAGATTGGAGTCACCATAGTTTGGGAGAAAGGAAGGCTGATAACTCAA CCTTATTTTATTCTGACTGCTAAACAGAATTGGAAACTAACATCATCCTCAGGTAACAGA TAAAGGCCCTCTTTCCCATTCATAGGAAGCAATTTTGGAGGTGGTGGAAGCTACAATGAT TTTGGGAATTACAACAATCAGTCTTCAAATTTTGGACCCATGAAGGGAGGAAATTTTGGA GGCAGAAGCTCTGGCCCCTATGGCGGTGGAGGCCAATACTTTGCAAAACCACGAAACCAA GGTATGGTATCTATGTAATTTTGGATAATGTCAAAAGAGTGTCTGTAGCTACTGCTGGGA AGAAAGCCCTTTAACTGCTATGTCTGGGCAGCAAAACGTTTATAGTTTAGAACCTTCAGA AAGTGATAATTTGATCACAAATTAGAAAAATCATGGGACCTCTTTACCACCTCCCTTGTA GTAGGGCCATTTTTAAATGGCCAGACACTTGAATTTAACTTTTATTATCCCAAATATGAA AACATTACTGTTGGCACTTTGAAACTTTAAAAGAAAAATTGTACTTTTCAGGTGGCTATG GCGGTTCCAGCAGCAGCAGTAGCTATGGCAGTGGCAGAAGATTTTAATTAGGTAAGTAAG CACCTTTTTGTGTGTTGACATAATTTTTTAAATTGCTGATGAACCCAATAACCCTAATGT AGCTGAGCAGTGCAACATAGTTAACATTATAATTGCAGTAATTGTGGATATAAAGTTAAT ATTCAGATCAGCAAAATTTGTGGGAAACAAACTTGATATTGGATTGTAGCCTTGAGTCTT AATATGTTTAGATTAACAACTCTATTCCATATTGTTCAACAGGAAACAAAGCTTAGCAGG AGAGGAGAGCCAGAGAAGTGACAGGGAAGCTACAGGTTACAACAGATTTGTGAACTCAGC CAAGCACAGTGGTGGCAGGGCCTAGCTGCTACAAAGAAGACATGTTTTAGACAAATACTC ATGTGTATGGGCAAAAAACTCGAGGACTGTATTTGTGACTAATTGTATAACAGGTTATTT TAGTTTCTGTTCTGTGGAAAGTGTAAAGCATTCCAACAAAGGGTTTTAATGTAGATTTTT TTTTTTGCACCCCATGCTGTTGATTGCTAAATGTAACAGTCTGATCGTGACGCTGAATAA ATGTCTTTTTTTTAATGTGCTGTGTAAAGTTAGTCTACTCTTAAGCCATCTTGGTAAATT TCCCCAACAGTGTGAAGTTAGAATTCCTTCAGGGTGATGCCAGGTTCTATTTGGAATTTA TATACAACCTGCTTGGGTGGAGAAGCCATTGTCTTCGGAAACCTTGGTGTAGTTGAACTG ATAGTTACTGTTGTGACCTGAAGTTCACCATTAAAAGGGATTACCCAAGCAAAATCATGG AATGGTTATAAAAGTGATTGTTGGCACATCCTATGCAATATATCTAAATTGAATAATGGT ACCAGATAAAATTATAGATGGGAATGAAGCTTGTGTATCCATTATCATGTGTAATCAATA AACGATTTAATTCTCTTGAATGAAATGACAACTGTATGGATTTGGGACTGGCAGAGATTT GGACTTTCCCTACCCACTCCCCCTGATAATAATGTTGAATGCTTCTATCACAATTCAAGT TCAAAGCTCTGCTAGGGAATAGAAACTA wise-2.4.1/src/dynamite_examples/dbsearch.c0000644000175000001440000000707507313404535020304 0ustar philippusers #include "proteinsw.h" void show_help (void) { fprintf(stdout,"dbsearch [options] \n"); fprintf(stdout,"Valid options are\n"); /** add more options here sometime, eg comp matrix and gap penalty*/ /** print out dbsearch options. We don't know here what implementations are either possible or how they are specified. Of course, there is the problem that we could clash our options with the dbsearchimpl options, but that is not too likely, and this makes this program future proof wrt to new implementations */ show_help_DBSearchImpl(stdout); } int main ( int argc, char ** argv) { Hscore * out; DBSearchImpl * dbsi; Protein * temp; Sequence * query; ProteinDB * querydb; ProteinDB * prodb; CompMat * mat; ComplexSequence * query_cs; ComplexSequence * target_cs; ComplexSequenceEvalSet * evalfunc; PackAln * pal; AlnBlock * alb; int i; /* * processes the command line, removing options * that it wants to in order to make the new DBSearchImpl * * The great thing about this is that this programs does not * care about which implementation is used, and does not know either (!) * */ dbsi = new_DBSearchImpl_from_argv(&argc,argv); if( argc != 3 ) { show_help(); exit(1); } /* * first argument is a single sequence. Read it in and make it * into a database */ query = read_fasta_file_Sequence(argv[1]); if( query == NULL ) fatal("Cannot read sequence in %s\n",argv[1]); querydb = new_ProteinDB_from_single_seq(query); /* * Second argument is a real database. This call is * a nice short cut for doing this. */ prodb = single_fasta_ProteinDB(argv[2]); if( prodb == NULL ) fatal("Cannot read protein database in %s\n",argv[2]); /* * This is where all the results are stored. It also * on-the-fly stores distribution information ready * to be fitted by a extreme value distribution */ /* 10 means a score cutoff of 10, -1 means don't report on stderr search progress */ out = std_score_Hscore(10,400); mat = read_Blast_file_CompMat("blosum62.bla"); if( search_ProteinSW(dbsi,out,querydb,prodb,mat,-12,-2) != SEARCH_OK ) fatal("Some sort of error in the database search. Dieing ungracefully"); sort_Hscore_by_score(out); evalfunc = default_aminoacid_ComplexSequenceEvalSet(); query_cs = new_ComplexSequence(query,evalfunc); if( query_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",query->name); } for(i=0;i<10 && i < out->len;i++) { fprintf(stdout,"Comparison to %s was %d score\n",out->ds[i]->target->name,out->ds[i]->score); /* * Retrieve the protein from the database */ temp = get_Protein_from_ProteinDB(prodb,out->ds[i]->target); /* * Make a complex sequence of it - see psw for info on this */ target_cs = new_ComplexSequence(temp->baseseq,evalfunc); if( target_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",temp->baseseq->name); } /* * Actually align it */ pal = PackAln_bestmemory_ProteinSW(query_cs,target_cs,mat,-12,-2,NULL); if( pal == NULL ) { fatal("Unable to make an alignment from %s and %s",query->name,temp->baseseq->name); } alb = convert_PackAln_to_AlnBlock_ProteinSW(pal); write_pretty_seq_align(alb,query,temp->baseseq,15,50,stdout); puts("//\n"); free_Protein(temp); free_ComplexSequence(target_cs); } return 0; } wise-2.4.1/src/dynamite_examples/psw.c0000644000175000001440000001113307313404536017331 0ustar philippusers /* * include proteinsw.h - will include the dynamite * produced declarations provided */ #include "proteinsw.h" /* * seqaligndisplay - fancy display * */ #include "seqaligndisplay.h" void show_help(FILE * ofp) { fprintf(ofp,"\npsw seq1 seq2\nBoth sequences in fasta format\n" "\tOPTIONS\n" "\t-g gap penalty (default 12)\n" "\t-e ext penatly (default 2)\n" "\t-m comp matrix (default blosum62.bla)\n" "\t-r show raw output\n" "\t-l show label output\n" "\t-f show fancy output\n" "\t (default, -f, all outputs can be shown together\n" ); } int main(int argc,char ** argv) { Sequence * query; Sequence * target; ComplexSequence * query_cs; ComplexSequence * target_cs; ComplexSequenceEvalSet * evalfunc; CompMat * comp; char * comp_file; int gap = (12); int ext = (2); boolean show_raw_output = FALSE; boolean show_label_output = FALSE; boolean show_fancy_output = FALSE; boolean has_outputted = FALSE; PackAln * pal; AlnBlock * alb; /* * Process command line options * -h or -help gives us help * -g for gap value (an int) - rely on commandline error processing * -e for ext value (an int) - rely on commandline error processing * -m for matrix (a char) * -r - raw matrix output * -l - label output * -f - fancy output * * * Use calls to commandline.h functions * */ if( strip_out_boolean_argument(&argc,argv,"h") == TRUE || strip_out_boolean_argument(&argc,argv,"-help") == TRUE) { show_help(stdout); exit(1); } show_raw_output = strip_out_boolean_argument(&argc,argv,"r"); show_label_output = strip_out_boolean_argument(&argc,argv,"l"); show_fancy_output = strip_out_boolean_argument(&argc,argv,"f"); /** if all FALSE, set fancy to TRUE **/ if( show_raw_output == FALSE && show_label_output == FALSE ) show_fancy_output = TRUE; (void) strip_out_integer_argument(&argc,argv,"g",&gap); (void) strip_out_integer_argument(&argc,argv,"e",&ext); comp_file = strip_out_assigned_argument(&argc,argv,"m"); if( comp_file == NULL) comp_file = "blosum62.bla"; if( argc != 3 ) { warn("Must have two arguments for sequence 1 and sequence 2 %d",argc); show_help(stdout); exit(1); } /* * Read in two sequences */ if( (query=read_fasta_file_Sequence(argv[1])) == NULL ) { fatal("Unable to read the sequence in file %s",argv[1]); } if( (target=read_fasta_file_Sequence(argv[2])) == NULL ) { fatal("Unable to read the sequence in file %s",argv[2]); } /* * Open a blosum matrix. This will be opened from WISECONFIGDIR * or WISEPERSONALDIR if it is not present in the current directory. */ comp = read_Blast_file_CompMat(comp_file); if( comp == NULL ) { fatal("unable to read file %s",comp_file); } /* * Convert sequences to ComplexSequences: * To do this we need an protein ComplexSequenceEvalSet * */ evalfunc = default_aminoacid_ComplexSequenceEvalSet(); query_cs = new_ComplexSequence(query,evalfunc); if( query_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",query->name); } target_cs = new_ComplexSequence(target,evalfunc); if( target_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",target->name); } /* * Make an alignment. I don't care about the implementation: * If the sequences are small enough then it should use explicit memory. * Long sequences should use divide and conquor methods. * * Calling PackAln_bestmemory_ProteinSW is the answer * This function decides on the best method considering the * memory and changes accordingly. It frees the matrix memory * at the end as well. * */ pal = PackAln_bestmemory_ProteinSW(query_cs,target_cs,comp,-gap,-ext,NULL); if( pal == NULL ) { fatal("Unable to make an alignment from %s and %s",query->name,target->name); } /* * ok, make other alignment forms, and be ready to show */ alb = convert_PackAln_to_AlnBlock_ProteinSW(pal); /* * show output. If multiple outputs, divide using // */ if( show_raw_output == TRUE ) { show_simple_PackAln(pal,stdout); puts("//\n"); } if( show_label_output == TRUE ) { show_flat_AlnBlock(alb,stdout); } if( show_fancy_output == TRUE ) { write_pretty_seq_align(alb,query,target,15,50,stdout); puts("//\n"); } /* * Destroy the memory. */ free_Sequence(query); free_Sequence(target); free_CompMat(comp); free_ComplexSequence(query_cs); free_ComplexSequence(target_cs); free_PackAln(pal); free_AlnBlock(alb); return 0; } wise-2.4.1/src/dynamite_examples/README0000644000175000001440000000041207313404535017231 0ustar philippusers This directory contains examples to use the Dynamite compiler with. For better documentation about these examples, read the documentation in docs To make go make psw and then psw roac.pep road.pep and make est2gen and then est2gen est.dna genomic.dna wise-2.4.1/src/dynamite_examples/seqaligndisplay.dy0000644000175000001440000000734407313404536022114 0ustar philippusers %{ #include "dyna.h" %} %{ #include "seqaligndisplay.h" %func This gives an interface into the alignment display using sequences and files. A more generic function is write_pretty_str_align %% boolean write_pretty_seq_align(AlnBlock * alb,Sequence * q,Sequence * t,int name,int main,FILE * ofp) { char qname[64]; char tname[64]; btCanvas * btc; char * temp; if( name > 64 ) { warn("Sorry - hard coded limited, can't have names longer than 64"); return FALSE; } if( strlen(q->name) > name ) { warn("Name %s is longer than allowed name block (%d). Truncating\n",q->name,name); strncpy(qname,q->name,name); qname[name] = '\0'; } else { strcpy(qname,q->name); } if( strlen(t->name) > name ) { warn("Name %s is longer than allowed name block (%d). Truncating\n",t->name,name); strncpy(tname,t->name,name); tname[name] = '\0'; } else { strcpy(tname,t->name); } btc = new_Ascii_btCanvas(ofp,name+6,main,0,3); /*+6 in case we want to put in numbers */ write_pretty_str_align(alb,qname,q->seq,tname,t->seq,btc); /** destroy btc canvas **/ free_btCanvas(btc); return TRUE; } %func This function writes precisely what you expect for a a simple alignment. We can reuse this routine all over the place because we dont use any hard coded structure for the query or the target sequence letters. Also we use a generic btCanvas that could have any implementation underneath (eg, ASCII, postscript etc). %% boolean write_pretty_str_align(AlnBlock * alb,char * qname,char * query,char * tname,char * target,btCanvas * btc) { AlnColumn * alc; AlnUnit * q; AlnUnit * t; btPasteArea * btp; for(alc=alb->start;alc != NULL;) { /** put names in **/ btp = get_reserved_left_btCanvas(btc); paste_string_btPasteArea(btp,0,0,qname,BC_RIGHT,0); paste_string_btPasteArea(btp,0,2,tname,BC_RIGHT,0); free_btPasteArea(btp); /** now loop over this block **/ for(;alc != NULL && can_get_paste_area_btCanvas(btc,1) == TRUE;alc=alc->next) { q = alc->alu[0]; t = alc->alu[1]; /* * at the end, break */ if( strcmp(q->text_label,"END") == 0 ) { alc = NULL; break; } /* * Get the paste area, length 1, depth will be 3 */ btp = get_paste_area_btCanvas(btc,1); /* * Write in the query sequence * */ if( strcmp(q->text_label,"SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,0,query[q->start+1],0); } else { /** is insert- we could check **/ if( strcmp(q->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",q->text_label); paste_char_btPasteArea(btp,0,0,'?',0); } else { paste_char_btPasteArea(btp,0,0,'-',0); } } /* * Write in the target sequence * */ if( strcmp(t->text_label,"SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,2,target[t->start+1],0); } else { /** is insert- we could check **/ if( strcmp(t->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",t->text_label); paste_char_btPasteArea(btp,0,2,'?',0); } else { paste_char_btPasteArea(btp,0,2,'-',0); } } /* * Match line */ if( strcmp(q->text_label,"SEQUENCE") == 0 && strcmp(t->text_label,"SEQUENCE") == 0 ) { if( q->score[0] > 0 ) { if( query[q->start+1] == target[t->start+1] ) { paste_char_btPasteArea(btp,0,1,target[t->start+1],0); } else { paste_char_btPasteArea(btp,0,1,'+',0); } } } else paste_char_btPasteArea(btp,0,1,' ',0); free_btPasteArea(btp); } /* end of for this block */ advance_line_btCanvas(btc); } /* end of for the alignment */ return TRUE; /* we never returned false. Ooops! */ } %} wise-2.4.1/src/dynamite_examples/cdna2genomic.dy0000644000175000001440000000335407313404535021250 0ustar philippusers %{ #include "dyna.h" #define DnaMatrix_Score(dnamat,base1,base2) (dnamat->score[base1][base2]) %} type DNAMAT real DnaMatrix* endtype method DNA_MAT_SCORE map DnaMatrix_Score arg DNAMAT arg base arg base return int endmethod matrix cDNA2Gen query type="CDNA" name="query" target type="GENOMIC" name="target" resource type="DNAMAT" name="dm" resource type="Score" name="cdna_open" resource type="Score" name="cdna_ext" resource type="Score" name="gen_open" resource type="Score" name="gen_ext" resource type="Score" name="intron_open" state MATCH offi="1" offj="1" calc="DNA_MAT_SCORE(dm,CDNA_BASE(query,i),GENOMIC_BASE(target,j))" source MATCH calc="0" endsource source CDNA_INSERT calc="0" endsource source START calc="0" endsource source GENOMIC_INSERT calc="0" endsource source GENOMIC_INTRON calc="GENOMIC_3SS(target,j-1)" target_label 3SS endsource query_label SEQUENCE target_label SEQUENCE endstate state CDNA_INSERT offi="1" offj="0" source MATCH calc="cdna_open" endsource source CDNA_INSERT calc="cdna_ext" endsource query_label SEQUENCE target_label INSERT endstate state GENOMIC_INSERT offi="0" offj="1" source MATCH calc="gen_open" endsource source GENOMIC_INSERT calc="gen_ext" endsource query_label INSERT target_label SEQUENCE endstate state GENOMIC_INTRON offi="0" offj="1" source MATCH offj="1" calc="GENOMIC_5SS(target,j) + intron_open" target_label 5SS endsource source GENOMIC_INTRON calc="0" endsource query_label INSERT target_label CENTRAL_INTRON endstate state START !special !start endstate state END !special !end source MATCH calc="0" endsource query_label END target_label END endstate collapse INSERT CENTRAL_INTRON endmatrix wise-2.4.1/src/dynamite_examples/roac.pep0000644000175000001440000000057307313404536020014 0ustar philippusers>Q22037 this here we go! MTDVEIKAENGSGDASLEPENLRKIFVGGLTSNTTDDLMREFYSQFGEITDIIVMRDPTT KRSRGFGFVTFSGKTEVDAAMKQRPHIIDGKTVDPKRAVPRDDKNRSESNVSTKRLYVSG VREDHTEDMLTEYFTKYGTVTKSEIILDKATQKPRGFGFVTFDDHDSVDQCVLQKSHMVN GHRCDVRKGLSKDEMSKAQMNRDRETRGGRSRDGQRGGYNGGGGGGGGWGGPAQRGGPGA YGGPGGGGQGGYGGDYGGGWGQQGGGGQGGWGGPQQQQGGGGWGQQGGGGQGGWGGPQQQ QQGGWGGPQQGGGGGGWGGQGQQQGGWGGQSGAQQWAHAQGGNRNY wise-2.4.1/src/dynamite_examples/road.pep0000644000175000001440000000060107313404536020005 0ustar philippusers>roa1_drome MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGLDYRTTDENLKAH FEKWGNIVDVVVMKDPRTKRSRGFGFITYSHSSMIDEAQKSRPHKIDGRV VEPKRAVPRQDIDSPNAGATVKKLFVGALKDDHDEQSIRDYFQHFGNIVD INIVIDKETGKKRGFAFVEFDDYDPVDKVVLQKQHQLNGKMVDVKKALPK QNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGNQNGGGNWNNGGNNWGNNR GGNDNWGNNSFGGGGGGGGGYGGGNNSWGNNNPWDNGNGGGNFGGGGNNW NNGGNDFGGYQQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGNYG GNNQGFNNGGNNRRY wise-2.4.1/src/dynamite_examples/makefile0000644000175000001440000000152207313404536020055 0ustar philippusers # # Minimal dynamite makefile # set suffix rules .dy->.c .c->.o # # # CC = cc CFLAGS = -O -I../dynlibsrc/ -I../base LFLAGS = -L../dynlibsrc/ -L../base/ -ldyna -lwisebase -lm .SUFFIXES : .dy .dy.c : ../dyc/dyc $< .dy.o : ../dyc/dyc $< $(CC) -c $(CFLAGS) $*.c .c.o : $(CC) -c $(CFLAGS) $< psw : proteinsw.o seqaligndisplay.o psw.o $(CC) -o psw psw.o proteinsw.o seqaligndisplay.o $(LFLAGS) est2gen : cdna2genomic.o estgendisplay.o est2gen.o $(CC) -o est2gen est2gen.o cdna2genomic.o estgendisplay.o $(LFLAGS) dbsearch : proteinsw.o dbsearch.o seqaligndisplay.o $(CC) -o dbsearch dbsearch.o proteinsw.o seqaligndisplay.o $(LFLAGS) dbthread : dbsearch.o seqaligndisplay.o ../dyc/dyc -pthreads proteinsw.dy $(CC) -c $(CFLAGS) -DPTHREAD proteinsw.c $(CC) -o dbsearch dbsearch.o proteinsw.o seqaligndisplay.o $(LFLAGS) -lpthread wise-2.4.1/src/dynamite_examples/est.dna0000644000175000001440000000075707313404536017645 0ustar philippusers>hs_est GAGAGGGCGAAGGTAGGCTGGCAGATACGTTCGTCAGCTTGCTCCTTTCTGCCCGTGGAC GCCGCCGAAGAAGCATCGTTAAAGTCTCTCTTCACCCTGCCGTCATGTCTAAGTCAGAGT CTCCTAAAGAGCCCGAACAGCTGAGGAAGCTCTTCATTGGAGGGTTGAGCTTTGAAACAA CTGATGAGAGCCTGAGGAGCCATTTTGAGCAATGGGGAACGCTCACGGACTGTGTGGTAA GAGAGATCCAAACACCAAGCGCTCTAGGGGCTTTGGGTTTGTCACATATGCCACTGTGG AGGAGGTGGATGCAGCTATGAATGCAAGGCCACACAAGGTGGATGGAAGAGTTGTGGAAC CAAAGAGAGCTGTCTCCAGAGAAGATTCTCAAAGACCAGGTGCCCACTTAACTGTGAAAA AGATATTTGTTGGTGGCATTAAAGAAGACACTGAAGAACATCACCTAAGAGATTATTTTG wise-2.4.1/src/dynamite_examples/proteinsw.dy0000644000175000001440000000202307313404536020742 0ustar philippusers %{ #include "dyna.h" %} matrix ProteinSW query type="PROTEIN" name="query" target type="PROTEIN" name="target" resource type="COMPMAT" name="comp" resource type="int" name="gap" resource type="int" name="ext" state MATCH offi="1" offj="1" calc="AAMATCH(comp,AMINOACID(query,i),AMINOACID(target,j))" source MATCH calc="0" endsource source INSERT calc="0" endsource source DELETE calc="0" endsource source START calc="0" endsource query_label SEQUENCE target_label SEQUENCE endstate state INSERT offi="0" offj="1" source MATCH calc="gap" endsource source INSERT calc="ext" endsource query_label INSERT target_label SEQUENCE endstate state DELETE offi="1" offj="0" source MATCH calc="gap" endsource source DELETE calc="ext" endsource query_label SEQUENCE target_label INSERT endstate state START !special !start query_label START target_label START endstate state END !special !end source MATCH calc="0" endsource query_label END target_label END endstate endmatrix wise-2.4.1/src/dynamite_examples/estgendisplay.c0000644000175000001440000001347207313404536021403 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "seqaligndisplay.h" /* Function: write_pretty_estgen_seq_align(alb,q,t,name,main,ofp) * * Descrip: This gives an interface into the alignment * display using sequences and files. A more * generic function is write_pretty_str_align * * * Arg: alb Undocumented argument [AlnBlock *] * Arg: q Undocumented argument [Sequence *] * Arg: t Undocumented argument [Sequence *] * Arg: name Undocumented argument [int] * Arg: main Undocumented argument [int] * Arg: ofp Undocumented argument [FILE *] * * Return Undocumented return value [boolean] * */ # line 18 "estgendisplay.dy" boolean write_pretty_estgen_seq_align(AlnBlock * alb,Sequence * q,Sequence * t,int name,int main,FILE * ofp) { char qname[64]; char tname[64]; btCanvas * btc; char * temp; if( name > 64 ) { warn("Sorry - hard coded limited, can't have names longer than 64"); return FALSE; } if( strlen(q->name) > name ) { warn("Name %s is longer than allowed name block (%d). Truncating\n",q->name,name); strncpy(qname,q->name,name); qname[name] = '\0'; } else { strcpy(qname,q->name); } if( strlen(t->name) > name ) { warn("Name %s is longer than allowed name block (%d). Truncating\n",t->name,name); strncpy(tname,t->name,name); tname[name] = '\0'; } else { strcpy(tname,t->name); } btc = new_Ascii_btCanvas(ofp,name+6,main,0,3); /*+6 in case we want to put in numbers */ write_pretty_estgen_align(alb,qname,q->seq,q->offset,tname,t->seq,t->offset,name,btc); /** destroy btc canvas **/ free_btCanvas(btc); return TRUE; } /* Function: write_pretty_estgen_align(alb,qname,query,q_start,tname,target,t_start,name,btc) * * Descrip: This is tied to the labels in cdna2genomic.dy * * Notice the use of start/end points. * * * Arg: alb Undocumented argument [AlnBlock *] * Arg: qname Undocumented argument [char *] * Arg: query Undocumented argument [char *] * Arg: q_start Undocumented argument [int] * Arg: tname Undocumented argument [char *] * Arg: target Undocumented argument [char *] * Arg: t_start Undocumented argument [int] * Arg: name Undocumented argument [int] * Arg: btc Undocumented argument [btCanvas *] * * Return Undocumented return value [boolean] * */ # line 65 "estgendisplay.dy" boolean write_pretty_estgen_align(AlnBlock * alb,char * qname,char * query,int q_start,char * tname,char * target,int t_start,int name,btCanvas * btc) { char buffer[512]; AlnColumn * alc; AlnUnit * q; AlnUnit * t; int start; /* for introns */ int end; btPasteArea * btp; for(alc=alb->start;alc != NULL;) { /** put names in **/ btp = get_reserved_left_btCanvas(btc); paste_string_btPasteArea(btp,0,0,qname,BC_RIGHT,0); paste_string_btPasteArea(btp,0,2,tname,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[0]->start+q_start+1); paste_string_btPasteArea(btp,name+1,0,buffer,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[1]->start+t_start+1); paste_string_btPasteArea(btp,name+1,2,buffer,BC_RIGHT,0); free_btPasteArea(btp); /** now loop over this block **/ for(;alc != NULL && can_get_paste_area_btCanvas(btc,1) == TRUE;alc=alc->next) { q = alc->alu[0]; t = alc->alu[1]; /* * at the end, break */ if( strcmp(q->text_label,"END") == 0 ) { alc = NULL; break; } /* * If this is an intron, do something special * */ if( strcmp(t->text_label,"5SS") == 0 ) { if( can_get_paste_area_btCanvas(btc,13) == FALSE ) { break; /* will advance line, then we can get back to here */ } start = t->start; alc=alc->next; /* moves to central intron segment */ end = alc->alu[1]->end; btp = get_paste_area_btCanvas(btc,13); sprintf(buffer,"<-%4d:%4d->",start+1+t_start,end+t_start); paste_string_btPasteArea(btp,0,2,buffer,BC_RIGHT,0); free_btPasteArea(btp); continue; /* next column */ } /* * Get the paste area, length 1, depth will be 3 */ btp = get_paste_area_btCanvas(btc,1); /* * Write in the query sequence * */ if( strcmp(q->text_label,"SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,0,query[q->start+1],0); } else { /** is insert- we could check **/ if( strcmp(q->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",q->text_label); paste_char_btPasteArea(btp,0,0,'?',0); } else { paste_char_btPasteArea(btp,0,0,'-',0); } } /* * Write in the target sequence * */ if( strcmp(t->text_label,"SEQUENCE") == 0 || strcmp(t->text_label,"3SS") == 0) { paste_char_btPasteArea(btp,0,2,target[t->start+1],0); } else { /** is insert- we could check **/ if( strcmp(t->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",t->text_label); paste_char_btPasteArea(btp,0,2,'?',0); } else { paste_char_btPasteArea(btp,0,2,'-',0); } } /* * Match line */ if( strcmp(q->text_label,"SEQUENCE") == 0 && (strcmp(t->text_label,"SEQUENCE") == 0 || strcmp(t->text_label,"3SS") == 0) ) { if( q->score[0] > 0 ) { if( query[q->start+1] == target[t->start+1] ) { paste_char_btPasteArea(btp,0,1,target[t->start+1],0); } else { paste_char_btPasteArea(btp,0,1,'+',0); } } } else paste_char_btPasteArea(btp,0,1,' ',0); free_btPasteArea(btp); } /* end of for this block */ advance_line_btCanvas(btc); } /* end of for the alignment */ return TRUE; /* we never returned false. Ooops! */ } # line 216 "estgendisplay.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dynamite_examples/estgendisplay.h0000644000175000001440000000466207313404536021411 0ustar philippusers#ifndef DYNAMITEestgendisplayHEADERFILE #define DYNAMITEestgendisplayHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: write_pretty_estgen_seq_align(alb,q,t,name,main,ofp) * * Descrip: This gives an interface into the alignment * display using sequences and files. A more * generic function is write_pretty_str_align * * * Arg: alb Undocumented argument [AlnBlock *] * Arg: q Undocumented argument [Sequence *] * Arg: t Undocumented argument [Sequence *] * Arg: name Undocumented argument [int] * Arg: main Undocumented argument [int] * Arg: ofp Undocumented argument [FILE *] * * Return Undocumented return value [boolean] * */ boolean write_pretty_estgen_seq_align(AlnBlock * alb,Sequence * q,Sequence * t,int name,int main,FILE * ofp); /* Function: write_pretty_estgen_align(alb,qname,query,q_start,tname,target,t_start,name,btc) * * Descrip: This is tied to the labels in cdna2genomic.dy * * Notice the use of start/end points. * * * Arg: alb Undocumented argument [AlnBlock *] * Arg: qname Undocumented argument [char *] * Arg: query Undocumented argument [char *] * Arg: q_start Undocumented argument [int] * Arg: tname Undocumented argument [char *] * Arg: target Undocumented argument [char *] * Arg: t_start Undocumented argument [int] * Arg: name Undocumented argument [int] * Arg: btc Undocumented argument [btCanvas *] * * Return Undocumented return value [boolean] * */ boolean write_pretty_estgen_align(AlnBlock * alb,char * qname,char * query,int q_start,char * tname,char * target,int t_start,int name,btCanvas * btc); /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynamite_examples/seqaligndisplay.c0000644000175000001440000001167707313404536021726 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "seqaligndisplay.h" /* Function: write_pretty_seq_align(alb,q,t,name,main,ofp) * * Descrip: This gives an interface into the alignment * display using sequences and files. A more * generic function is write_pretty_str_align * * * Arg: alb Undocumented argument [AlnBlock *] * Arg: q Undocumented argument [Sequence *] * Arg: t Undocumented argument [Sequence *] * Arg: name Undocumented argument [int] * Arg: main Undocumented argument [int] * Arg: ofp Undocumented argument [FILE *] * * Return Undocumented return value [boolean] * */ # line 18 "seqaligndisplay.dy" boolean write_pretty_seq_align(AlnBlock * alb,Sequence * q,Sequence * t,int name,int main,FILE * ofp) { char qname[64]; char tname[64]; btCanvas * btc; char * temp; if( name > 64 ) { warn("Sorry - hard coded limited, can't have names longer than 64"); return FALSE; } if( strlen(q->name) > name ) { warn("Name %s is longer than allowed name block (%d). Truncating\n",q->name,name); strncpy(qname,q->name,name); qname[name] = '\0'; } else { strcpy(qname,q->name); } if( strlen(t->name) > name ) { warn("Name %s is longer than allowed name block (%d). Truncating\n",t->name,name); strncpy(tname,t->name,name); tname[name] = '\0'; } else { strcpy(tname,t->name); } btc = new_Ascii_btCanvas(ofp,name+6,main,0,3); /*+6 in case we want to put in numbers */ write_pretty_str_align(alb,qname,q->seq,tname,t->seq,btc); /** destroy btc canvas **/ free_btCanvas(btc); return TRUE; } /* Function: write_pretty_str_align(alb,qname,query,tname,target,btc) * * Descrip: This function writes precisely * what you expect for a a simple alignment. * * We can reuse this routine all over the place because * we dont use any hard coded structure for the * query or the target sequence letters. * * Also we use a generic btCanvas that could have * any implementation underneath (eg, ASCII, postscript etc). * * * Arg: alb Undocumented argument [AlnBlock *] * Arg: qname Undocumented argument [char *] * Arg: query Undocumented argument [char *] * Arg: tname Undocumented argument [char *] * Arg: target Undocumented argument [char *] * Arg: btc Undocumented argument [btCanvas *] * * Return Undocumented return value [boolean] * */ # line 71 "seqaligndisplay.dy" boolean write_pretty_str_align(AlnBlock * alb,char * qname,char * query,char * tname,char * target,btCanvas * btc) { AlnColumn * alc; AlnUnit * q; AlnUnit * t; btPasteArea * btp; for(alc=alb->start;alc != NULL;) { /** put names in **/ btp = get_reserved_left_btCanvas(btc); paste_string_btPasteArea(btp,0,0,qname,BC_RIGHT,0); paste_string_btPasteArea(btp,0,2,tname,BC_RIGHT,0); free_btPasteArea(btp); /** now loop over this block **/ for(;alc != NULL && can_get_paste_area_btCanvas(btc,1) == TRUE;alc=alc->next) { q = alc->alu[0]; t = alc->alu[1]; /* * at the end, break */ if( strcmp(q->text_label,"END") == 0 ) { alc = NULL; break; } /* * Get the paste area, length 1, depth will be 3 */ btp = get_paste_area_btCanvas(btc,1); /* * Write in the query sequence * */ if( strcmp(q->text_label,"SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,0,query[q->start+1],0); } else { /** is insert- we could check **/ if( strcmp(q->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",q->text_label); paste_char_btPasteArea(btp,0,0,'?',0); } else { paste_char_btPasteArea(btp,0,0,'-',0); } } /* * Write in the target sequence * */ if( strcmp(t->text_label,"SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,2,target[t->start+1],0); } else { /** is insert- we could check **/ if( strcmp(t->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",t->text_label); paste_char_btPasteArea(btp,0,2,'?',0); } else { paste_char_btPasteArea(btp,0,2,'-',0); } } /* * Match line */ if( strcmp(q->text_label,"SEQUENCE") == 0 && strcmp(t->text_label,"SEQUENCE") == 0 ) { if( q->score[0] > 0 ) { if( query[q->start+1] == target[t->start+1] ) { paste_char_btPasteArea(btp,0,1,target[t->start+1],0); } else { paste_char_btPasteArea(btp,0,1,'+',0); } } } else paste_char_btPasteArea(btp,0,1,' ',0); free_btPasteArea(btp); } /* end of for this block */ advance_line_btCanvas(btc); } /* end of for the alignment */ return TRUE; /* we never returned false. Ooops! */ } # line 187 "seqaligndisplay.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dynamite_examples/seqaligndisplay.h0000644000175000001440000000477307313404537021733 0ustar philippusers#ifndef DYNAMITEseqaligndisplayHEADERFILE #define DYNAMITEseqaligndisplayHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: write_pretty_seq_align(alb,q,t,name,main,ofp) * * Descrip: This gives an interface into the alignment * display using sequences and files. A more * generic function is write_pretty_str_align * * * Arg: alb Undocumented argument [AlnBlock *] * Arg: q Undocumented argument [Sequence *] * Arg: t Undocumented argument [Sequence *] * Arg: name Undocumented argument [int] * Arg: main Undocumented argument [int] * Arg: ofp Undocumented argument [FILE *] * * Return Undocumented return value [boolean] * */ boolean write_pretty_seq_align(AlnBlock * alb,Sequence * q,Sequence * t,int name,int main,FILE * ofp); /* Function: write_pretty_str_align(alb,qname,query,tname,target,btc) * * Descrip: This function writes precisely * what you expect for a a simple alignment. * * We can reuse this routine all over the place because * we dont use any hard coded structure for the * query or the target sequence letters. * * Also we use a generic btCanvas that could have * any implementation underneath (eg, ASCII, postscript etc). * * * Arg: alb Undocumented argument [AlnBlock *] * Arg: qname Undocumented argument [char *] * Arg: query Undocumented argument [char *] * Arg: tname Undocumented argument [char *] * Arg: target Undocumented argument [char *] * Arg: btc Undocumented argument [btCanvas *] * * Return Undocumented return value [boolean] * */ boolean write_pretty_str_align(AlnBlock * alb,char * qname,char * query,char * tname,char * target,btCanvas * btc); /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/HMMer2/0000755000175000001440000000000010670453554013703 5ustar philippuserswise-2.4.1/src/HMMer2/revcomp.c0000644000175000001440000000221307313404526015513 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* revcomp.c * * Reverse complement of a IUPAC character string * */ #include #include #include #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif char * revcomp(char *comp, char *seq) { long bases; char *bckp, *fwdp; int idx; long pos; int c; if (comp == NULL) return NULL; if (seq == NULL) return NULL; bases = strlen(seq); fwdp = comp; bckp = seq + bases -1; for (pos = 0; pos < bases; pos++) { c = *bckp; c = sre_toupper(c); for (idx = 0; c != iupac[idx].sym && idx < IUPACSYMNUM; idx++); if (idx == IUPACSYMNUM) { Warn("Can't reverse complement an %c, pal. Using N.", c); *fwdp = 'N'; } else *fwdp = iupac[idx].symcomp; if (islower((int) *bckp)) *fwdp = sre_tolower((int) *fwdp); fwdp++; bckp--; } *fwdp = '\0'; return comp; } wise-2.4.1/src/HMMer2/debug.c0000644000175000001440000002340407313404524015131 0ustar philippusers/* debug.c * Thu Nov 21 09:58:05 1996 * * Printing out or naming various useful things from HMMER * innards. * * RCS $Id: debug.c,v 1.1.1.1 2001/06/18 13:59:48 birney Exp $ */ #include #include #include #include #include "structs.h" #include "config.h" #include "funcs.h" #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Function: VerboseWorry() * * Purpose: A warning from inside the package, conditional * on the compile-time setting of the debug level. * Print an error message and return. The arguments * are formatted exactly like arguments to printf(). * * This is usually called by the macro Worry() which * adds the __FILE__ and __LINE__ information. See * structs.h. * * Return: (void) */ /* VARARGS0 */ void VerboseWorry(int level, char *file, int line, char *format, ...) { va_list argp; /* format the error mesg */ if (DEBUGLEVEL >= level) { fprintf(stderr, "WORRY: (%s line %d): ", file, line); va_start(argp, format); vfprintf(stderr, format, argp); va_end(argp); fprintf(stderr, "\n"); fflush(stderr); } } /* Function: Panic() * * Purpose: Die from a lethal error that's not my problem, * but instead a failure of a StdC/POSIX call that * shouldn't fail. Call perror() to get the * errno flag, then die. * * Usually called by the PANIC macro which adds * the __FILE__ and __LINE__ information; see * structs.h. * * Inspired by code in Donald Lewine's book, _POSIX * Programmer's Guide_. */ void Panic(char *file, int line) { (void) fprintf(stderr, "\nPANIC [%s line %d] ", file, line); (void) perror("Unusual error"); exit(EXIT_FAILURE); } /* Function: Statetype() * * Purpose: Returns the state type in text. * Example: Statetype(S) = "S" */ char * Statetype(enum p7stype st) { switch (st) { case STS: return "S"; case STN: return "N"; case STB: return "B"; case STM: return "M"; case STD: return "D"; case STI: return "I"; case STE: return "E"; case STJ: return "J"; case STC: return "C"; case STT: return "T"; default: return "BOGUS"; } } /* Function: P7PrintTrace() * * Purpose: Print out a traceback structure. * If hmm is non-NULL, also print transition and emission scores. * * Args: fp - stderr or stdout, often * tr - trace structure to print * hmm - NULL or hmm containing scores to print * dsq - NULL or digitized sequence trace refers to. */ void P7PrintTrace(FILE *fp, struct p7trace_s *tr, struct plan7_s *hmm, char *dsq) { int tpos; /* counter for trace position */ int sym; int sc; if (hmm == NULL) { fprintf(fp, "st node rpos - traceback len %d\n", tr->tlen); fprintf(fp, "-- ---- ------\n"); for (tpos = 0; tpos < tr->tlen; tpos++) { fprintf(fp, "%1s %4d %6d\n", Statetype(tr->statetype[tpos]), tr->nodeidx[tpos], tr->pos[tpos]); } } else { if (!(hmm->flags & PLAN7_HASBITS)) Die("oi, you can't print scores from that hmm, it's not ready."); sc = 0; fprintf(fp, "st node rpos transit emission - traceback len %d\n", tr->tlen); fprintf(fp, "-- ---- ------ ------- --------\n"); for (tpos = 0; tpos < tr->tlen; tpos++) { sym = (int) dsq[tr->pos[tpos]]; fprintf(fp, "%1s %4d %6d %7d", Statetype(tr->statetype[tpos]), tr->nodeidx[tpos], tr->pos[tpos], (tpos < tr->tlen-1) ? TransitionScoreLookup(hmm, tr->statetype[tpos], tr->nodeidx[tpos], tr->statetype[tpos+1], tr->nodeidx[tpos+1]) : 0); if (tpos < tr->tlen-1) sc += TransitionScoreLookup(hmm, tr->statetype[tpos], tr->nodeidx[tpos], tr->statetype[tpos+1], tr->nodeidx[tpos+1]); if (tr->statetype[tpos] == STM) { fprintf(fp, " %8d %c", hmm->msc[sym][tr->nodeidx[tpos]], Alphabet[sym]); sc += hmm->msc[sym][tr->nodeidx[tpos]]; } else if (tr->statetype[tpos] == STI) { fprintf(fp, " %8d %c", hmm->isc[sym][tr->nodeidx[tpos]], tolower(Alphabet[sym])); sc += hmm->isc[sym][tr->nodeidx[tpos]]; } else if ((tr->statetype[tpos] == STN && tr->statetype[tpos-1] == STN) || (tr->statetype[tpos] == STC && tr->statetype[tpos-1] == STC) || (tr->statetype[tpos] == STJ && tr->statetype[tpos-1] == STJ)) { fprintf(fp, " %8d %c", 0, tolower(Alphabet[sym])); } fputs("\n", fp); } fprintf(fp, " ------- --------\n"); fprintf(fp, " total: %6d\n\n", sc); } } /* Function: P7PrintPrior() * * Purpose: Print out a Plan 7 prior structure. */ void P7PrintPrior(FILE *fp, struct p7prior_s *pri) { int q, x; /* counters for mixture component, element */ if (pri->strategy == PRI_DCHLET) fputs("Dirichlet\n", fp); else if (pri->strategy == PRI_PAM) fputs("PAM\n", fp); else Die("No such strategy."); if (Alphabet_type == hmmAMINO) fputs("Amino\n", fp); else if (Alphabet_type == hmmNUCLEIC) fputs("Nucleic\n", fp); /* Transitions */ fprintf(fp, "\n%d\n", pri->tnum); for (q = 0; q < pri->tnum; q++) { fprintf(fp, "%.4f\n", pri->tq[q]); for (x = 0; x < 7; x++) fprintf(fp, "%.4f ", pri->t[q][x]); fputs("\n", fp); } /* Match emissions */ fprintf(fp, "\n%d\n", pri->mnum); for (q = 0; q < pri->mnum; q++) { fprintf(fp, "%.4f\n", pri->mq[q]); for (x = 0; x < Alphabet_size; x++) fprintf(fp, "%.4f ", pri->m[q][x]); fputs("\n", fp); } /* Insert emissions */ fprintf(fp, "\n%d\n", pri->inum); for (q = 0; q < pri->inum; q++) { fprintf(fp, "%.4f\n", pri->iq[q]); for (x = 0; x < Alphabet_size; x++) fprintf(fp, "%.4f ", pri->i[q][x]); fputs("\n", fp); } } /* Function: TraceVerify() * Date: SRE, Mon Feb 2 07:48:52 1998 [St. Louis] * * Purpose: Check a traceback structure for internal consistency. * Used in Shiva testsuite, for example. * * Args: tr - traceback to verify * M - length of HMM * N - length of sequence * * Returns: 1 if OK. 0 if not. */ int TraceVerify(struct p7trace_s *tr, int M, int N) { int tpos; /* position in trace */ int k; /* current position in HMM nodes 1..M */ int i; /* current position in seq 1..N */ int nn, nc, nj; /* number of STN's, STC's, STJ's seen */ int nm; /* number of STM's seen */ /* Basic checks on ends. */ if (tr->statetype[0] != STS) return 0; if (tr->statetype[1] != STN) return 0; if (tr->statetype[tr->tlen-2] != STC) return 0; if (tr->statetype[tr->tlen-1] != STT) return 0; if (tr->pos[1] != 0) return 0; /* Check for consistency throughout trace */ k = i = nn = nc = nj = nm = 0; for (tpos = 0; tpos < tr->tlen; tpos++) { switch (tr->statetype[tpos]) { case STS: if (tr->nodeidx[tpos] != 0) return 0; if (tr->pos[tpos] != 0) return 0; if (k != 0) return 0; if (i != 0) return 0; if (tpos != 0) return 0; break; case STN: /* first N doesn't emit. */ if (tr->nodeidx[tpos] != 0) return 0; if (k != 0) return 0; if (nn > 0) { if (tr->pos[tpos] != i+1) return 0; i++; } else { if (tr->pos[tpos] != 0) return 0; if (i != 0) return 0; } nn++; break; case STB: if (tr->nodeidx[tpos] != 0) return 0; if (tr->pos[tpos] != 0) return 0; nm = 0; break; case STM: /* can enter anywhere on first M */ if (tr->pos[tpos] != i+1) return 0; if (tr->nodeidx[tpos] < 1 || tr->nodeidx[tpos] > M) return 0; i++; if (nm == 0) k = tr->nodeidx[tpos]; else { if (tr->nodeidx[tpos] != k+1) return 0; k++; } nm++; break; case STI: if (tr->pos[tpos] != i+1) return 0; if (tr->nodeidx[tpos] != k) return 0; if (tr->nodeidx[tpos] < 1 || tr->nodeidx[tpos] > M-1) return 0; if (k >= M) return 0; i++; break; case STD: if (tr->pos[tpos] != 0) return 0; if (tr->nodeidx[tpos] != k+1) return 0; if (tr->nodeidx[tpos] < 1 || tr->nodeidx[tpos] > M) return 0; k++; break; case STE: if (tr->nodeidx[tpos] != 0) return 0; if (tr->pos[tpos] != 0) return 0; nj = 0; break; case STJ: if (tr->nodeidx[tpos] != 0) return 0; if (nj > 0) { if (tr->pos[tpos] != i+1) return 0; i++; } else if (tr->pos[tpos] != 0) return 0; nj++; break; case STC: if (tr->nodeidx[tpos] != 0) return 0; if (nc > 0) { if (tr->pos[tpos] != i+1) return 0; i++; } else if (tr->pos[tpos] != 0) return 0; nc++; break; case STT: if (tpos != tr->tlen - 1) return 0; if (tr->nodeidx[tpos] != 0) return 0; if (tr->pos[tpos] != 0) return 0; if (i != N) return 0; break; case STBOGUS: default: return 0; } /* end switch over statetypes */ } /* end loop over trace positions */ return 1; } /* Function: TraceCompare() * Date: SRE, Wed Mar 4 17:26:49 1998 [St. Louis] * * Purpose: Compare two tracebacks; return 1 if they're * identical, else 0. Written for Shiva testsuite. * * Args: t1 - first trace * t2 - second trace * * Returns: 1 if identical; 0 elsewise */ int TraceCompare(struct p7trace_s *t1, struct p7trace_s *t2) { int tpos; if (t1->tlen != t2->tlen) return 0; for (tpos = 0; tpos < t1->tlen; tpos++) { if (t1->statetype[tpos] != t2->statetype[tpos]) return 0; if (t1->nodeidx[tpos] != t2->nodeidx[tpos]) return 0; if (t1->pos[tpos] != t2->pos[tpos]) return 0; } return 1; } wise-2.4.1/src/HMMer2/hmmconvert.c0000644000175000001440000001675307313404525016237 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Sean R. Eddy * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* hmmconvert.c * SRE, Thu Oct 30 08:56:22 1997; St. Louis * * main() for converting between HMM file formats, and * for converting HMMs to other software formats like GCG profiles. * */ #include #include #include "structs.h" /* data structures, macros, #define's */ #include "config.h" /* compile-time configuration constants */ #include "funcs.h" /* function declarations */ #include "globals.h" /* alphabet global variables */ #include "squid.h" /* general sequence analysis library */ #ifdef MEMDEBUG #include "dbmalloc.h" #endif static char banner[] = "hmmconvert - convert between profile HMM file formats"; static char usage[] = "\ Usage: hmmconvert [-options] \n\ Available options are:\n\ -h : help; print brief help on version and usage\n\ \n\ -a : convert to HMMER ASCII file (the default)\n\ -b : convert to HMMER binary file\n\ -p : convert to GCG Profile .prf format\n\ -P : convert to Compugen extended .eprf profile format\n\ \n\ -A : append mode; append to \n\ -F : force mode; allow overwriting of existing files\n\ "; static char experts[] = "\ \n"; static struct opt_s OPTIONS[] = { { "-a", TRUE, sqdARG_NONE }, { "-b", TRUE, sqdARG_NONE }, { "-h", TRUE, sqdARG_NONE }, { "-p", TRUE, sqdARG_NONE }, { "-A", TRUE, sqdARG_NONE }, { "-F", TRUE, sqdARG_NONE }, { "-P", TRUE, sqdARG_NONE }, }; #define NOPTIONS (sizeof(OPTIONS) / sizeof(struct opt_s)) int main(int argc, char **argv) { char *infile; /* name of input HMM file */ char *outfile; /* name of output HMM file */ HMMFILE *infp; /* input HMM file ptr */ FILE *outfp; /* output HMM file ptr */ char *mode; /* mode to open file in */ struct plan7_s *hmm; /* a profile HMM structure */ int nhmm; /* number of HMMs converted */ char *optname; /* name of option found by Getopt() */ char *optarg; /* argument found by Getopt() */ int optind; /* index in argv[] */ int do_append; /* TRUE to append to existing outfile */ int do_force; /* TRUE to allow overwriting */ enum hmmfmt_e { P7ASCII, P7BINARY, GCGPROFILE, BICPROFILE } outfmt; /* output format */ #ifdef MEMDEBUG unsigned long histid1, histid2, orig_size, current_size; orig_size = malloc_inuse(&histid1); fprintf(stderr, "[... memory debugging is ON ...]\n"); #endif /*********************************************** * Parse command line ***********************************************/ outfmt = P7ASCII; do_append = FALSE; do_force = FALSE; while (Getopt(argc, argv, OPTIONS, NOPTIONS, usage, &optind, &optname, &optarg)) { if (strcmp(optname, "-a") == 0) { outfmt = P7ASCII; } else if (strcmp(optname, "-b") == 0) { outfmt = P7BINARY; } else if (strcmp(optname, "-p") == 0) { outfmt = GCGPROFILE; } else if (strcmp(optname, "-A") == 0) { do_append = TRUE; } else if (strcmp(optname, "-F") == 0) { do_force = TRUE; } else if (strcmp(optname, "-P") == 0) { outfmt = BICPROFILE; } else if (strcmp(optname, "-h") == 0) { Banner(stdout, banner); puts(usage); puts(experts); exit(0); } } if (argc - optind != 2) Die("Incorrect number of arguments.\n%s\n", usage); infile = argv[optind++]; outfile = argv[optind++]; /*********************************************** * Open input HMM database (might be in HMMERDB or current directory) ***********************************************/ if ((infp = HMMFileOpen(infile, "HMMERDB")) == NULL) Die("Failed to open HMM database %s\n%s", infile, usage); /*********************************************** * Open output HMM file ***********************************************/ if (do_append) { /* If we're appending to a file, it needs to be Plan7 format */ HMMFILE *test; if (FileExists(outfile)) { test = HMMFileOpen(outfile, NULL); if (test == NULL) Die("%s not an HMM file; I refuse to append to it; using stdout instead", outfile); HMMFileClose(test); } switch (outfmt) { case P7ASCII: mode = "a"; break; case P7BINARY: mode = "ab"; break; case GCGPROFILE: Die("You cannot append GCG profiles"); case BICPROFILE: Die("You cannot append Compugen extended profiles"); default: Die("unexpected format"); } } else { /* else, we're writing a new file */ if (! do_force && FileExists(outfile)) Die("Output HMM file %s already exists. Please rename or delete it.", outfile); switch (outfmt) { case P7ASCII: mode = "w"; break; case P7BINARY: mode = "wb"; break; case GCGPROFILE: mode = "w"; break; case BICPROFILE: mode = "w"; break; default: Die("unexpected format"); } } if ((outfp = fopen(outfile, mode)) == NULL) Die("Failed to open output file %s for writing", outfile); /*********************************************** * Show the banner ***********************************************/ Banner(stdout, banner); printf( "Input HMM file: %s\n", infile); printf( "Output HMM file: %s\n", outfile); printf( "Converting to: "); switch (outfmt) { case P7ASCII: puts("HMMER Plan7 ASCII"); break; case P7BINARY: puts("HMMER Plan7 binary"); break; case GCGPROFILE: puts("GCG Profile .prf"); break; case BICPROFILE: puts("Compugen .eprf profile"); break; default: Die("unexpected fault"); } printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n"); /*********************************************** * Do the conversion ***********************************************/ nhmm = 0; while (HMMFileRead(infp, &hmm)) { if (hmm == NULL) Die("HMM file %s may be corrupt or in incorrect format; parse failed", infile); switch(outfmt) { case P7ASCII: WriteAscHMM(outfp, hmm); break; case P7BINARY: WriteBinHMM(outfp, hmm); break; case GCGPROFILE: WriteProfile(outfp, hmm, FALSE); break; case BICPROFILE: WriteProfile(outfp, hmm, TRUE); break; default: Die("unexpected format"); } printf(" - converted %s\n", hmm->name); FreePlan7(hmm); nhmm++; } printf("\n%d HMM(s) converted and written to %s\n", nhmm, outfile); /*********************************************** * Clean-up and exit. ***********************************************/ HMMFileClose(infp); fclose(outfp); SqdClean(); #ifdef MEMDEBUG current_size = malloc_inuse(&histid2); if (current_size != orig_size) malloc_list(2, histid1, histid2); else fprintf(stderr, "[No memory leaks.]\n"); #endif return EXIT_SUCCESS; } wise-2.4.1/src/HMMer2/sre_ctype.c0000644000175000001440000000122507313404527016040 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* sre_ctype.c * * For portability. Some systems have functions tolower, toupper * as macros (for instance, MIPS M-2000 RISC/os!) */ #include #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif int sre_tolower(int c) { if (isupper(c)) return tolower(c); else return c; } int sre_toupper(int c) { if (islower(c)) return toupper(c); else return c; } wise-2.4.1/src/HMMer2/GNULICENSE0000644000175000001440000004307607313404523015264 0ustar philippusers GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. wise-2.4.1/src/HMMer2/Makefile0000644000175000001440000001034707313404523015340 0ustar philippusers# Makefile for HMMER: Source directory # RCS $Id: Makefile,v 1.1.1.1 2001/06/18 13:59:47 birney Exp $ ########## # HMMER - Biological sequence analysis with HMMs # Copyright (C) 1992-1998 Sean R. Eddy # # This source code is distributed under the terms of the # GNU General Public License. See the files COPYING and # LICENSE for details. # ########### ## your compiler and compiler flags # CC = cc CFLAGS = -g ## machine specific definitions # MDEFS = ## archiving command, and ranlib command if you need one. # In general, you shouldn't need to change these, and they're # only used for building the Shiva testsuite anyway. # AR = ar rcv RANLIB = ranlib ####### ## You should not need to modify below this line ####### SHELL = /bin/sh LIBS = -lm PROGS = hmmalign hmmbuild hmmcalibrate hmmconvert hmmemit hmmpfam hmmsearch HDRS = config.h funcs.h globals.h structs.h version.h SQUIDHDRS = gnuregex.h squid.h sqfuncs.h SRC = hmmalign.c hmmbuild.c hmmcalibrate.c hmmconvert.c\ hmmpfam.c hmmsearch.c\ alphabet.c core_algorithms.c debug.c emit.c\ emulation.c histogram.c hmmio.c mathsupport.c\ masks.c misc.c modelmakers.c plan7.c\ plan9.c prior.c tophits.c trace.c SQUIDSRC = aligneval.c alignio.c cluster.c dayhoff.c\ file.c getopt.c gnuregex.c interleaved.c\ iupac.c msf.c revcomp.c selex.c\ sqerror.c sqio.c sre_ctype.c sre_math.c\ sre_string.c stack.c translate.c types.c\ weight.c OBJ = alphabet.o core_algorithms.o debug.o emit.o\ emulation.o histogram.o hmmio.o mathsupport.o\ masks.o misc.o modelmakers.o plan7.o\ plan9.o prior.o tophits.o trace.o\ aligneval.o alignio.o cluster.o dayhoff.o\ file.o getopt.o gnuregex.o interleaved.o\ iupac.o msf.o revcomp.o selex.o\ sqerror.o sqio.o sre_ctype.o sre_math.o\ sre_string.o stack.o translate.o types.o\ weight.o .c.o: $(CC) $(CFLAGS) $(MDEFS) -c $< ####### ## Targets defining how to make HMMER executables. ####### all: $(PROGS) hmmalign: $(OBJ) hmmalign.o $(CC) $(CFLAGS) $(MDEFS) -o $@ hmmalign.o $(OBJ) $(LIBS) hmmbuild: $(OBJ) hmmbuild.o $(CC) $(CFLAGS) $(MDEFS) -o $@ hmmbuild.o $(OBJ) $(LIBS) hmmcalibrate: $(OBJ) hmmcalibrate.o $(CC) $(CFLAGS) $(MDEFS) -o $@ hmmcalibrate.o $(OBJ) $(LIBS) hmmconvert: $(OBJ) hmmconvert.o $(CC) $(CFLAGS) $(MDEFS) -o $@ hmmconvert.o $(OBJ) $(LIBS) hmmemit: $(OBJ) hmmemit.o $(CC) $(CFLAGS) $(MDEFS) -o $@ hmmemit.o $(OBJ) $(LIBS) hmmpfam: $(OBJ) hmmpfam.o $(CC) $(CFLAGS) $(MDEFS) -o $@ hmmpfam.o $(OBJ) $(LIBS) hmmsearch: $(OBJ) hmmsearch.o $(CC) $(CFLAGS) $(MDEFS) -o $@ hmmsearch.o $(OBJ) $(LIBS) ####### ## Target used in making Shiva test suite ####### libhmmer.a: $(OBJ) $(AR) libhmmer.a $(OBJ) -if test -x /bin/ranlib; then /bin/ranlib libhmmer.a; else exit 0; fi -if test -x /usr/bin/ranlib; then /usr/bin/ranlib libhmmer.a; else exit 0; fi -if test -x $(RANLIB); then $(RANLIB) libhmmer.a; else exit 0; fi chmod 644 libhmmer.a ####### ## Targets defining different build styles; ####### # Make a "production" copy prodv: make clean make CFLAGS="-O2" MDEFS="" LIBS="-lm" # Make a debugging copy dbv: make clean make CFLAGS="-g -Wall -pedantic" MDEFS="" LIBS="-lm" # Make a memory debugging copy memv: make clean make CFLAGS="-g -Wall" MDEFS="-DMEMDEBUG -L." LIBS="-lm -ldbmalloc" # Make an Electric Fence version efencev: make clean make CFLAGS="-g -Wall" MDEFS="" LIBS="-lm -lefence" # Make a gprof version gprofv: make clean make CFLAGS="-pg" MDEFS="" LIBS="-lm" ####### ## Targets only used in development, irrelevant to distribution copy ####### # Extract squid files from RCS. squid: for file in $(SQUIDHDRS); do\ co $(HOME)/src/squid/RCS/$$file,v $$file;\ done for file in $(SQUIDSRC); do\ co $(HOME)/src/squid/RCS/$$file,v $$file;\ done ####### ## Miscellaneous ####### clean: -rm -f *.o *~ Makefile.bak core $(PROGS) TAGS gmon.out libhmmer.a tags: etags -t $(SRC) $(HDRS) $(READMES) lint: lint $(MDEFS) $(SRC) wise-2.4.1/src/HMMer2/dayhoff.c0000644000175000001440000001224707313404524015466 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* dayhoff.c * * Routines for dealing with PAM matrices. * * Includes: * ParsePAMFile() -- read a PAM matrix from disk. * * * SRE - Fri Apr 2 11:23:45 1993 */ #include #include #include #include #include #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Function: ParsePAMFile() * * Purpose: Given a pointer to an open file containing a PAM matrix, * parse the file and allocate and fill a 2D array of * floats containing the matrix. The PAM file is * assumed to be in the format that NCBI distributes * with BLAST. BLOSUM matrices also work fine, as * produced by Henikoff's program "MATBLAS". * * Parses both old format and new format BLAST matrices. * Old format just had rows of integers. * New format includes a leading character on each row. * * The PAM matrix is a 27x27 matrix, 0=A..25=Z,26=*. * Note that it's not a 20x20 matrix as you might expect; * this is for speed of indexing as well as the ability * to deal with ambiguous characters. * * Args: fp - open PAM file * ret_pam - RETURN: pam matrix, integers * ret_scale - RETURN: scale factor for converting * to real Sij. For instance, PAM120 is * given in units of ln(2)/2. This may * be passed as NULL if the caller * doesn't care. * * Returns: 1 on success; 0 on failure and sets squid_errno to * indicate the cause. ret_pam is allocated here and * must be freed by the caller (use FreePAM). */ int ParsePAMFile(FILE *fp, int ***ret_pam, float *ret_scale) { int **pam; char buffer[512]; /* input buffer from fp */ int order[27]; /* order of fields, obtained from header */ int nsymbols; /* total number of symbols in matrix */ char *sptr; int idx; int row, col; float scale; int gotscale = FALSE; if (fp == NULL) { squid_errno = SQERR_NODATA; return 0; } /* Look at the first non-blank, non-comment line in the file. * It gives single-letter codes in the order the PAM matrix * is arrayed in the file. */ do { if (fgets(buffer, 512, fp) == NULL) { squid_errno = SQERR_NODATA; return 0; } /* Get the scale factor from the header. * For BLOSUM files, we assume the line looks like: * BLOSUM Clustered Scoring Matrix in 1/2 Bit Units * and we assume that the fraction is always 1/x; * * For PAM files, we assume the line looks like: * PAM 120 substitution matrix, scale = ln(2)/2 = 0.346574 * and we assume that the number following the final '=' is our scale */ if (strstr(buffer, "BLOSUM Clustered Scoring Matrix") != NULL && (sptr = strchr(buffer, '/')) != NULL) { sptr++; if (! isdigit(*sptr)) { squid_errno = SQERR_FORMAT; return 0; } scale = (float) (log(2.0) / atof(sptr)); gotscale = TRUE; } else if (strstr(buffer, "substitution matrix,") != NULL) { while ((sptr = strrchr(buffer, '=')) != NULL) { sptr += 2; if (IsReal(sptr)) { scale = atof(sptr); gotscale = TRUE; break; } } } } while ((sptr = strtok(buffer, " \t\n")) == NULL || *sptr == '#'); idx = 0; do { order[idx] = (int) *sptr - (int) 'A'; if (order[idx] < 0 || order[idx] > 25) order[idx] = 26; idx++; } while ((sptr = strtok(NULL, " \t\n")) != NULL); nsymbols = idx; /* Allocate a pam matrix. For speed of indexing, we use * a 27x27 matrix so we can do lookups using the ASCII codes * of amino acid single-letter representations, plus one * extra field to deal with the "*" (terminators). */ if ((pam = (int **) calloc (27, sizeof(int *))) == NULL) Die("calloc failed"); for (idx = 0; idx < 27; idx++) if ((pam[idx] = (int *) calloc (27, sizeof(int))) == NULL) Die("calloc failed"); /* Parse the rest of the file. */ for (row = 0; row < nsymbols; row++) { if (fgets(buffer, 512, fp) == NULL) { squid_errno = SQERR_NODATA; return 0; } if ((sptr = strtok(buffer, " \t\n")) == NULL) { squid_errno = SQERR_NODATA; return 0; } for (col = 0; col < nsymbols; col++) { if (sptr == NULL) { squid_errno = SQERR_NODATA; return 0; } /* Watch out for new BLAST format, with leading characters */ if (*sptr == '*' || isalpha((int) *sptr)) col--; /* hack hack */ else pam [order[row]] [order[col]] = atoi(sptr); sptr = strtok(NULL, " \t\n"); } } /* Return */ if (ret_scale != NULL) { if (gotscale) *ret_scale = scale; else { Warn("Failed to parse PAM matrix scale factor. Defaulting to ln(2)/2!"); *ret_scale = log(2.0) / 2.0; } } *ret_pam = pam; return 1; } wise-2.4.1/src/HMMer2/histogram.c0000644000175000001440000012404107313404525016040 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Sean R. Eddy * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* histogram.c * SRE, Sat Jan 20 16:16:17 1996 * * Accumulation, printing, and fitting of score histograms * from database searches. * * RCS $Id: histogram.c,v 1.1.1.1 2001/06/18 13:59:49 birney Exp $ ************************************************************ * Basic API: * * struct histogram_s *h; * * h = AllocHistogram(min_hint, max_hint, lumpsize); * * while (getting scores x) AddToHistogram(h, x); * * ExtremeValueFitHistogram(h, high_hint); * PrintASCIIHistogram(fp, h); * FreeHistogram(h); */ #include #include #include #include #include "squid.h" #include "config.h" #include "structs.h" #include "funcs.h" #include /* Function: AllocHistogram() * * Purpose: Allocate and return a histogram structure. * min and max are your best guess. They need * not be absolutely correct; the histogram * will expand dynamically to accomodate scores * that exceed these suggested bounds. The amount * that the histogram grows by is set by "lumpsize". * * Args: min: minimum score (integer) * max: maximum score (integer) * lumpsize: when reallocating histogram, pad the reallocation * by this much (saves excessive reallocation) */ struct histogram_s * AllocHistogram(int min, int max, int lumpsize) { struct histogram_s *h; int newsize; int i; newsize = max - min + 1; h = (struct histogram_s *) MallocOrDie(sizeof(struct histogram_s)); h->min = min; h->max = max; h->total = 0; h->lowscore = INT_MAX; h->highscore = INT_MIN; h->lumpsize = lumpsize; h->histogram = (int *) MallocOrDie (sizeof(int) * newsize); for (i = 0; i < newsize; i++) h->histogram[i] = 0; h->expect = NULL; h->fit_type = HISTFIT_NONE; h->param[EVD_WONKA] = 1.0; /* just in case, make sure this initializes */ return h; } /* Function: FreeHistogram() * * Purpose: free a histogram structure. */ void FreeHistogram(struct histogram_s *h) { free(h->histogram); if (h->expect != NULL) free(h->expect); free(h); } /* Function: UnfitHistogram() * * Purpose: Free only the theoretical fit part of a histogram. */ void UnfitHistogram(struct histogram_s *h) { if (h->expect != NULL) free(h->expect); h->expect = NULL; h->fit_type = HISTFIT_NONE; } /* Function: AddToHistogram() * * Purpose: Bump the appropriate counter in a histogram * structure, given a score. The score is * rounded off from float precision to the * next lower integer. */ void AddToHistogram(struct histogram_s *h, float sc) { int score; int moveby; int prevsize; int newsize; int i; /* Adding to a histogram conflicts with existing fit: * prohibit this. */ if (h->fit_type != HISTFIT_NONE) Die("AddToHistogram(): Can't add to a fitted histogram\n"); /* histogram bins are defined as: score >= bin value, < bin+1 * -1.9 -> -2 -0.4 -> -1 1.9 -> 1 * -2.1 -> -3 0.4 -> 0 2.1 -> 2 */ score = (int) floor(sc); /* Check to see if we must reallocate the histogram. */ if (score < h->min) { prevsize = h->max - h->min + 1; moveby = (h->min - score) + h->lumpsize; newsize = prevsize + moveby; h->min -= moveby; h->histogram = (int *) ReallocOrDie(h->histogram, sizeof(int) * newsize); memmove(h->histogram+moveby, h->histogram, sizeof(int) * prevsize); for (i = 0; i < moveby; i++) h->histogram[i] = 0; } else if (score > h->max) { prevsize = h->max - h->min + 1; h->max = h->lumpsize + score; newsize = h->max - h->min + 1; h->histogram = (int *) ReallocOrDie(h->histogram, sizeof(int) * newsize); for (i = prevsize; i < newsize; i++) h->histogram[i] = 0; } /* Bump the correct bin. * The bin number is score - h->min */ h->histogram[score - h->min]++; h->total++; if (score < h->lowscore) h->lowscore = score; if (score > h->highscore) h->highscore = score; #if DEBUGLEVEL >= DEBUG_AGGRESSIVE fprintf(stderr, "AddToHistogram(): added %.1f; rounded to %d; in bin %d (%d-%d)\n", sc, score, score-h->min, h->min, h->max); #endif return; } /* Function: PrintASCIIHistogram() * * Purpose: Print a "prettified" histogram to a file pointer. * Deliberately a look-and-feel clone of Bill Pearson's * excellent FASTA output. * * Args: fp - open file to print to (stdout works) * h - histogram to print */ void PrintASCIIHistogram(FILE *fp, struct histogram_s *h) { int units; int maxbar; int num; int i, idx; char buffer[81]; /* output line buffer */ int pos; /* position in output line buffer */ int lowbound, lowcount; /* cutoffs on the low side */ int highbound, highcount; /* cutoffs on the high side */ int emptybins = 3; /* Find out how we'll scale the histogram. * We have 59 characters to play with on a * standard 80-column terminal display: * leading "%5d %6d %6d|" occupies 20 chars. * Save the peak position, we'll use it later. */ maxbar = 0; for (i = h->lowscore - h->min; i <= h->highscore - h->min; i++) if (h->histogram[i] > maxbar) { maxbar = h->histogram[i]; /* max height */ lowbound = i + h->min; /* peak position */ } /* Truncate histogram display on both sides, ad hoc fashion. * Start from the peak; then move out until we see empty bins, * and stop. */ highbound = lowbound; /* start at peak position */ for (num = 0; lowbound > h->lowscore; lowbound--) { i = lowbound - h->min; if (h->histogram[i] > 0) { num = 0; continue; } /* reset */ if (++num == emptybins) { lowbound += emptybins; break; } /* stop */ } for (num = 0; highbound < h->highscore; highbound++) { i = highbound - h->min; if (h->histogram[i] > 0) { num = 0; continue; } /* reset */ if (++num == emptybins) { highbound -= emptybins; break; } /* stop */ } /* collect counts outside of bounds */ for (lowcount = 0, i = h->lowscore - h->min; i <= lowbound - h->min; i++) lowcount += h->histogram[i]; for (highcount = 0, i = h->highscore - h->min; i >= highbound - h->min; i--) highcount += h->histogram[i]; /* maxbar might need raised now; then set our units */ if (lowcount > maxbar) maxbar = lowcount; if (highcount > maxbar) maxbar = highcount; units = ((maxbar-1)/ 59) + 1; /* Print the histogram */ fprintf(fp, "%5s %6s %6s (one = represents %d sequences)\n", "score", "obs", "exp", units); fprintf(fp, "%5s %6s %6s\n", "-----", "---", "---"); buffer[80] = '\0'; buffer[79] = '\n'; for (i = h->lowscore; i <= h->highscore; i++) { memset(buffer, ' ', 79 * sizeof(char)); idx = i - h->min; /* Deal with special cases at edges */ if (i < lowbound) continue; else if (i > highbound) continue; else if (i == lowbound && i != h->lowscore) { sprintf(buffer, "<%4d %6d %6s|", i+1, lowcount, "-"); if (lowcount > 0) { num = 1+(lowcount-1) / units; if (num > 60) Die("oops"); for (pos = 20; num > 0; num--) buffer[pos++] = '='; } fputs(buffer, fp); continue; } else if (i == highbound && i != h->highscore) { sprintf(buffer, ">%4d %6d %6s|", i, highcount, "-"); if (highcount > 0) { num = 1+(highcount-1) / units; for (pos = 20; num > 0; num--) buffer[pos++] = '='; } fputs(buffer, fp); continue; } /* Deal with most cases */ if (h->fit_type != HISTFIT_NONE) sprintf(buffer, "%5d %6d %6d|", i, h->histogram[idx], (int) h->expect[idx]); else sprintf(buffer, "%5d %6d %6s|", i, h->histogram[idx], "-"); buffer[20] = ' '; /* sprintf writes a null char */ /* Mark the histogram bar for observed hits */ if (h->histogram[idx] > 0) { num = 1 + (h->histogram[idx]-1) / units; for (pos = 20; num > 0; num--) buffer[pos++] = '='; } /* Mark the theoretically expected value */ if (h->fit_type != HISTFIT_NONE && (int) h->expect[idx] > 0) { /* "corrected" line */ #ifdef SRE_REMOVED if (h->fit_type == HISTFIT_EVD) { pos = 20 + (int)(h->param[EVD_WONKA] * h->expect[idx] - 1) / units; if (pos >= 78) pos = 78; /* be careful of buffer bounds */ buffer[pos] = 'o'; } #endif /* true (uncorrected) line */ pos = 20 + (int)(h->expect[idx]-1) / units; if (pos >= 78) pos = 78; /* be careful of buffer bounds */ buffer[pos] = '*'; } /* Print the line */ fputs(buffer, fp); } /* Print details about the statistics */ switch (h->fit_type) { case HISTFIT_NONE: fprintf(fp, "\n\n%% No statistical fit available\n"); break; case HISTFIT_EVD: fprintf(fp, "\n\n%% Statistical details of theoretical EVD fit:\n"); fprintf(fp, " mu = %10.4f\n", h->param[EVD_MU]); fprintf(fp, " lambda = %10.4f\n", h->param[EVD_LAMBDA]); #ifdef SRE_REMOVED fprintf(fp, " fraction fit = %10.4f\n", h->param[EVD_WONKA]); #endif fprintf(fp, "chi-sq statistic = %10.4f\n", h->chisq); fprintf(fp, " P(chi-square) = %10.4g\n", h->chip); break; case HISTFIT_GAUSSIAN: fprintf(fp, "\n\n%% Statistical details of theoretical Gaussian fit:\n"); fprintf(fp, " mean = %10.4f\n", h->param[GAUSS_MEAN]); fprintf(fp, " sd = %10.4f\n", h->param[GAUSS_SD]); fprintf(fp, "chi-sq statistic = %10.4f\n", h->chisq); fprintf(fp, " P(chi-square) = %10.4g\n", h->chip); break; } return; } /* Function: PrintXMGRHistogram() * Date: SRE, Wed Nov 12 11:02:00 1997 [St. Louis] * * Purpose: Print an XMGR data file that contains two data sets: * - xy data for the observed histogram * - xy data for the theoretical histogram */ void PrintXMGRHistogram(FILE *fp, struct histogram_s *h) { int sc; /* integer score in histogram structure */ double val; /* First data set is the observed histogram */ for (sc = h->lowscore; sc <= h->highscore; sc++) if (h->histogram[sc - h->min] > 0) fprintf(fp, "%-6d %f\n", sc, (float) h->histogram[sc - h->min]/ (float) h->total); fprintf(fp, "&\n"); /* Second data set is the theoretical histogram */ if (h->fit_type != HISTFIT_NONE) { for (sc = h->lowscore; sc <= h->highscore; sc++) { val = (1. - ExtremeValueP((float)sc+1, h->param[EVD_MU], h->param[EVD_LAMBDA]))- (1. - ExtremeValueP((float)sc, h->param[EVD_MU], h->param[EVD_LAMBDA])); fprintf(fp, "%-6d %f\n", sc, val); } fprintf(fp, "&\n"); } } /* Function: PrintXMGRDistribution() * Date: SRE, Wed Nov 12 11:02:09 1997 [St. Louis] * * Purpose: Print an XMGR data file that contains two data sets: * - xy data for the observed distribution P(Slowscore; sc <= h->highscore; sc++) { cum += h->histogram[sc - h->min]; fprintf(fp, "%-6d %f\n", sc + 1, (float) cum / (float) h->total); } fprintf(fp, "&\n"); /* Second data set is the theoretical histogram */ if (h->fit_type != HISTFIT_NONE) { for (sc = h->lowscore; sc <= h->highscore; sc++) { val = (1. - ExtremeValueP((float) sc, h->param[EVD_MU], h->param[EVD_LAMBDA])); fprintf(fp, "%-6d %f\n", sc, val); } fprintf(fp, "&\n"); } } /* Function: PrintXMGRRegressionLine() * Date: SRE, Wed Nov 12 11:02:19 1997 [St. Louis] * * Purpose: Print an XMGR data file that contains two data sets: * - xy data for log log transform of observed distribution P(Slowscore; sc <= h->highscore; sc++) { cum += h->histogram[sc - h->min]; val = log (-1. * log((double) cum / (double) h->total)); if (cum < h->total) fprintf(fp, "%-6d %f\n", sc + 1, val); } fprintf(fp, "&\n"); /* Second data set is the theoretical histogram */ if (h->fit_type != HISTFIT_NONE) { for (sc = h->lowscore; sc <= h->highscore; sc++) { val = log(-1. * log(1. - ExtremeValueP((float) sc, h->param[EVD_MU], h->param[EVD_LAMBDA]))); fprintf(fp, "%-6d %f\n", sc, val); } fprintf(fp, "&\n"); } } /* Function: EVDBasicFit() * Date: SRE, Wed Nov 12 11:02:27 1997 [St. Louis] * * Purpose: Fit a score histogram to the extreme value * distribution. Set the parameters lambda * and mu in the histogram structure. Fill in the * expected values in the histogram. Calculate * a chi-square test as a measure of goodness of fit. * * This is the basic version of ExtremeValueFitHistogram(), * in a nonrobust form: simple linear regression with no * outlier pruning. * * Methods: Uses a linear regression fitting method [Collins88,Lawless82] * * Args: h - histogram to fit * * Return: (void) */ void EVDBasicFit(struct histogram_s *h) { float *d; /* distribution P(S < x) */ float *x; /* x-axis of P(Smin */ float slope, intercept; /* m,b fit from Linefit() */ float corr; /* correlation coeff of line fit, not used */ float lambda, mu; /* slope, intercept converted to EVD params */ /* Allocations for x, y axes * distribution d runs from min..max with indices 0..max-min * i.e. score - min = index into d, x, histogram, and expect */ hsize = h->highscore - h->lowscore + 1; d = (float *) MallocOrDie(sizeof(float) * hsize); x = (float *) MallocOrDie(sizeof(float) * hsize); for (idx = 0; idx < hsize; idx++) d[idx] = x[idx] = 0.; /* Calculate P(S < x) distribution from histogram. * note off-by-one of sc, because histogram bin contains scores between * x and x+1. */ sum = 0; for (sc = h->lowscore; sc <= h->highscore; sc++) { sum += h->histogram[sc - h->min]; d[sc - h->lowscore] = (float) sum / (float) h->total; x[sc - h->lowscore] = (float) (sc + 1); } /* Do a linear regression fit to the log[-log(P(Sx))] = -lambda * x + lambda * mu * so lambda = -m and mu = b/lambda */ /* convert y axis to log[-log(P(Slowscore; sc < h->highscore; sc++) d[sc - h->lowscore] = log(-1. * log(d[sc - h->lowscore])); /* do the linear regression */ Linefit(x, d, hsize-1, &intercept, &slope, &corr); /* calc mu, lambda */ lambda = -1. * slope; mu = intercept / lambda; /* Set the EVD parameters in the histogram; * pass 2 for additional lost degrees of freedom because we fit mu, lambda. */ ExtremeValueSetHistogram(h, mu, lambda, h->lowscore, h->highscore, 1.0, 2); free(x); free(d); return; } /* Function: ExtremeValueFitHistogram() * Date: SRE, Sat Nov 15 17:16:15 1997 [St. Louis] * * Purpose: Fit a score histogram to the extreme value * distribution. Set the parameters lambda * and mu in the histogram structure. Calculate * a chi-square test as a measure of goodness of fit. * * Methods: Uses a maximum likelihood method [Lawless82]. * Lower outliers are removed by censoring the data below the peak. * Upper outliers are removed iteratively using method * described by [Mott92]. * * Args: h - histogram to fit * censor - TRUE to censor data left of the peak * high_hint - score cutoff; above this are `real' hits that aren't fit * * Return: 1 if fit is judged to be valid. * else 0 if fit is invalid (too few seqs.) */ int ExtremeValueFitHistogram(struct histogram_s *h, int censor, float high_hint) { float *x; /* array of EVD samples to fit */ int *y; /* histogram counts */ int n; /* number of observed samples */ int z; /* number of censored samples */ int hsize; /* size of histogram */ float lambda, mu; /* new estimates of lambda, mu */ int sc; /* loop index for score */ int lowbound; /* lower bound of fitted region*/ int highbound; /* upper bound of fitted region*/ int new_highbound; int iteration; /* Determine lower bound on fitted region; * if we're censoring the data, choose the peak of the histogram. * if we're not, then we take the whole histogram. */ lowbound = h->lowscore; if (censor) { int max = -1; for (sc = h->lowscore; sc <= h->highscore; sc++) if (h->histogram[sc - h->min] > max) { max = h->histogram[sc - h->min]; lowbound = sc; } } /* Determine initial upper bound on fitted region. */ highbound = MIN(high_hint, h->highscore); /* Now, iteratively converge on our lambda, mu: */ for (iteration = 0; iteration < 100; iteration++) { /* Construct x, y vectors. */ x = NULL; y = NULL; hsize = highbound - lowbound + 1; if (hsize < 5) goto FITFAILED; /* require at least 5 bins or we don't fit */ x = MallocOrDie(sizeof(float) * hsize); y = MallocOrDie(sizeof(int) * hsize); n = 0; for (sc = lowbound; sc <= highbound; sc++) { x[sc-lowbound] = (float) sc + 0.5; /* crude, but tests OK */ y[sc-lowbound] = h->histogram[sc - h->min]; n += h->histogram[sc - h->min]; } if (n < 100) goto FITFAILED; /* require fitting to at least 100 points */ /* If we're censoring, estimate z, the number of censored guys * left of the bound. Our initial estimate is crudely that we're * missing e^-1 of the total distribution (which would be exact * if we censored exactly at mu; but we censored at the observed peak). * Subsequent estimates are more exact based on our current estimate of mu. */ if (censor) { if (iteration == 0) z = MIN(h->total-n, (int) (0.58198 * (float) n)); else { double psx; psx = EVDDistribution((float) lowbound, mu, lambda); z = MIN(h->total-n, (int) ((double) n * psx / (1. - psx))); } } /* Do an ML fit */ if (censor) { if (! EVDCensoredFit(x, y, hsize, z, (float) lowbound, &mu, &lambda)) goto FITFAILED; } else if (! EVDMaxLikelyFit(x, y, hsize, &mu, &lambda)) goto FITFAILED; /* Find the Eval = 1 point as a new highbound; * the total number of samples estimated to "belong" to the EVD is n+z */ new_highbound = (int) (mu - (log (-1. * log((double) (n+z-1) / (double)(n+z))) / lambda)); free(x); free(y); if (new_highbound >= highbound) break; highbound = new_highbound; } /* Set the histogram parameters; * - the wonka factor is n+z / h->total : e.g. that's the fraction of the * hits that we expect to match the EVD, others are generally lower * - we fit from lowbound to highbound; thus we lose 2 degrees of freedom * for fitting mu, lambda, but we get 1 back because we're unnormalized * in this interval, hence we pass 2-1 = 1 as ndegrees. * * Mon Jan 19 06:18:14 1998: wonka = 1.0, temporarily disabled. */ ExtremeValueSetHistogram(h, mu, lambda, lowbound, highbound, 1.0, 1); return 1; FITFAILED: UnfitHistogram(h); if (x != NULL) free(x); if (y != NULL) free(y); return 0; } /* Function: ExtremeValueSetHistogram() * * Purpose: Instead of fitting the histogram to an EVD, * simply set the EVD parameters from an external source. * * Note that the fudge factor "wonka" is used /only/ * for prettification of expected/theoretical curves * in PrintASCIIHistogram displays. * * Args: h - the histogram to set * mu - mu location parameter * lambda - lambda scale parameter * lowbound - low bound of the histogram that was fit * highbound- high bound of histogram that was fit * wonka - fudge factor; fraction of hits estimated to be "EVD-like" * ndegrees - extra degrees of freedom to subtract in X^2 test: * typically 0 if mu, lambda are parametric, * else 2 if mu, lambda are estimated from data */ void ExtremeValueSetHistogram(struct histogram_s *h, float mu, float lambda, float lowbound, float highbound, float wonka, int ndegrees) { int sc; int hsize, idx; int nbins; float delta; UnfitHistogram(h); h->fit_type = HISTFIT_EVD; h->param[EVD_LAMBDA] = lambda; h->param[EVD_MU] = mu; h->param[EVD_WONKA] = wonka; hsize = h->max - h->min + 1; h->expect = (float *) MallocOrDie(sizeof(float) * hsize); for (idx = 0; idx < hsize; idx++) h->expect[idx] = 0.; /* Calculate the expected values for the histogram. */ for (sc = h->min; sc <= h->max; sc++) h->expect[sc - h->min] = ExtremeValueE((float)(sc), h->param[EVD_MU], h->param[EVD_LAMBDA], h->total) - ExtremeValueE((float)(sc+1), h->param[EVD_MU], h->param[EVD_LAMBDA], h->total); /* Calculate the goodness-of-fit (within whole region) */ h->chisq = 0.; nbins = 0; for (sc = lowbound; sc <= highbound; sc++) if (h->expect[sc-h->min] >= 5. && h->histogram[sc-h->min] >= 5) { delta = (float) h->histogram[sc-h->min] - h->expect[sc-h->min]; h->chisq += delta * delta / h->expect[sc-h->min]; nbins++; } /* Since we fit the whole histogram, there is at least * one constraint on chi-square: the normalization to h->total. */ if (nbins > 1 + ndegrees) h->chip = (float) IncompleteGamma((double)(nbins-1-ndegrees)/2., (double) h->chisq/2.); else h->chip = 0.; } /* Function: GaussianFitHistogram() * * Purpose: Fit a score histogram to a Gaussian distribution. * Set the parameters mean and sd in the histogram * structure, as well as a chi-squared test for * goodness of fit. * * Args: h - histogram to fit * high_hint - score cutoff; above this are `real' hits that aren't fit * * Return: 1 if fit is judged to be valid. * else 0 if fit is invalid (too few seqs.) */ int GaussianFitHistogram(struct histogram_s *h, float high_hint) { float sum; float sqsum; float delta; int sc; int nbins; int hsize, idx; /* Clear any previous fitting from the histogram. */ UnfitHistogram(h); /* Determine if we have enough hits to fit the histogram; * arbitrarily require 1000. */ if (h->total < 1000) { h->fit_type = HISTFIT_NONE; return 0; } /* Simplest algorithm for mean and sd; * no outlier detection yet (not even using high_hint) * * Magic 0.5 correction is because our histogram is for * scores between x and x+1; we estimate the expectation * (roughly) as x + 0.5. */ sum = sqsum = 0.; for (sc = h->lowscore; sc <= h->highscore; sc++) { delta = (float) sc + 0.5; sum += (float) h->histogram[sc-h->min] * delta; sqsum += (float) h->histogram[sc-h->min] * delta * delta; } h->fit_type = HISTFIT_GAUSSIAN; h->param[GAUSS_MEAN] = sum / (float) h->total; h->param[GAUSS_SD] = sqrt((sqsum - (sum*sum/(float)h->total)) / (float)(h->total-1)); /* Calculate the expected values for the histogram. * Note that the magic 0.5 correction appears again. * Calculating difference between distribution functions for Gaussian * would be correct but hard. */ hsize = h->max - h->min + 1; h->expect = (float *) MallocOrDie(sizeof(float) * hsize); for (idx = 0; idx < hsize; idx++) h->expect[idx] = 0.; for (sc = h->min; sc <= h->max; sc++) { delta = (float) sc + 0.5 - h->param[GAUSS_MEAN]; h->expect[sc - h->min] = (float) h->total * ((1. / (h->param[GAUSS_SD] * sqrt(2.*3.14159))) * (exp(-1.* delta*delta / (2. * h->param[GAUSS_SD] * h->param[GAUSS_SD])))); } /* Calculate the goodness-of-fit (within region that was fitted) */ h->chisq = 0.; nbins = 0; for (sc = h->lowscore; sc <= h->highscore; sc++) if (h->expect[sc-h->min] >= 5. && h->histogram[sc-h->min] >= 5) { delta = (float) h->histogram[sc-h->min] - h->expect[sc-h->min]; h->chisq += delta * delta / h->expect[sc-h->min]; nbins++; } /* -1 d.f. for normalization; -2 d.f. for two free parameters */ if (nbins > 3) h->chip = (float) IncompleteGamma((double)(nbins-3)/2., (double) h->chisq/2.); else h->chip = 0.; return 1; } /* Function: GaussianSetHistogram() * * Purpose: Instead of fitting the histogram to a Gaussian, * simply set the Gaussian parameters from an external source. */ void GaussianSetHistogram(struct histogram_s *h, float mean, float sd) { int sc; int hsize, idx; int nbins; float delta; UnfitHistogram(h); h->fit_type = HISTFIT_GAUSSIAN; h->param[GAUSS_MEAN] = mean; h->param[GAUSS_SD] = sd; /* Calculate the expected values for the histogram. */ hsize = h->max - h->min + 1; h->expect = (float *) MallocOrDie(sizeof(float) * hsize); for (idx = 0; idx < hsize; idx++) h->expect[idx] = 0.; /* Note: ideally we'd use the Gaussian distribution function * to find the histogram occupancy in the window sc..sc+1. * However, the distribution function is hard to calculate. * Instead, estimate the histogram by taking the density at sc+0.5. */ for (sc = h->min; sc <= h->max; sc++) { delta = ((float)sc + 0.5) - h->param[GAUSS_MEAN]; h->expect[sc - h->min] = (float) h->total * ((1. / (h->param[GAUSS_SD] * sqrt(2.*3.14159))) * (exp(-1.*delta*delta / (2. * h->param[GAUSS_SD] * h->param[GAUSS_SD])))); } /* Calculate the goodness-of-fit (within whole region) */ h->chisq = 0.; nbins = 0; for (sc = h->lowscore; sc <= h->highscore; sc++) if (h->expect[sc-h->min] >= 5. && h->histogram[sc-h->min] >= 5) { delta = (float) h->histogram[sc-h->min] - h->expect[sc-h->min]; h->chisq += delta * delta / h->expect[sc-h->min]; nbins++; } /* -1 d.f. for normalization */ if (nbins > 1) h->chip = (float) IncompleteGamma((double)(nbins-1)/2., (double) h->chisq/2.); else h->chip = 0.; } /* Function: EVDDensity() * Date: SRE, Sat Nov 15 19:37:52 1997 [St. Louis] * * Purpose: Return the extreme value density P(S=x) at * a given point x, for an EVD controlled by * parameters mu and lambda. */ double EVDDensity(float x, float mu, float lambda) { return (lambda * exp(-1. * lambda * (x - mu) - exp(-1. * lambda * (x - mu)))); } /* Function: EVDDistribution() * Date: SRE, Tue Nov 18 08:02:22 1997 [St. Louis] * * Purpose: Returns the extreme value distribution P(S < x) * evaluated at x, for an EVD controlled by parameters * mu and lambda. */ double EVDDistribution(float x, float mu, float lambda) { return (exp(-1. * exp(-1. * lambda * (x - mu)))); } /* Function: ExtremeValueP() * * Purpose: Calculate P(S>x) according to an extreme * value distribution, given x and the parameters * of the distribution (characteristic * value mu, decay constant lambda). * * Args: x = score * mu = characteristic value of extreme value distribution * lambda = decay constant of extreme value distribution * * Return: P(S>x) */ double ExtremeValueP(float x, float mu, float lambda) { double y; /* a roundoff issue arises; use 1 - e^-x --> x for small x */ y = exp(-1. * lambda * (x - mu)); if (y < 1e-7) return y; else return (1.0 - exp(-1. * y)); } /* Function: ExtremeValueP2() * * Purpose: Calculate P(S>x) in a database of size N, * using P(S>x) for a single sequence, according * to a Poisson distribution. * * Args: x = score * mu = characteristic value of extreme value distribution * lambda = decay constant of extreme value distribution * N = number of trials (number of sequences) * * Return: P(S>x) for database of size N */ double ExtremeValueP2(float x, float mu, float lambda, int N) { double y; y = N * ExtremeValueP(x,mu,lambda); if (y < 1e-7) return y; else return (1.0 - exp(-1. * y)); } /* Function: ExtremeValueE() * * Purpose: Calculate E(S>x) in a database of size N, * using P(S>x) for a single sequence: simply np. * * Args: x = score * mu = characteristic value of extreme value distribution * lambda = decay constant of extreme value distribution * N = number of trials (number of sequences) * * Return: E(S>x) for database of size N */ double ExtremeValueE(float x, float mu, float lambda, int N) { return (double)N * ExtremeValueP(x,mu,lambda); } /* Function: EVDrandom() * * Purpose: Randomly sample an x from an EVD. * Trivially done by the transformation method, since * the distribution is analytical: * x = \mu - \frac{\log \left[ -\log P(S= c * lambda - a lambda to test * ret_f - RETURN: 4.2.2 evaluated at lambda * ret_df - RETURN: first derivative of 4.2.2 evaluated at lambda * * Return: (void) */ void Lawless422(float *x, int *y, int n, int z, float c, float lambda, float *ret_f, float *ret_df) { double esum; /* \sum e^(-lambda xi) + z term */ double xesum; /* \sum xi e^(-lambda xi) + z term */ double xxesum; /* \sum xi^2 e^(-lambda xi) + z term */ double xsum; /* \sum xi (no z term) */ double mult; /* histogram count multiplier */ double total; /* total samples */ int i; esum = xesum = xsum = xxesum = total = 0.; for (i = 0; i < n; i++) { mult = (y == NULL) ? 1. : (double) y[i]; xsum += mult * x[i]; esum += mult * exp(-1. * lambda * x[i]); xesum += mult * x[i] * exp(-1. * lambda * x[i]); xxesum += mult * x[i] * x[i] * exp(-1. * lambda * x[i]); total += mult; } /* Add z terms for censored data */ esum += (double) z * exp(-1. * lambda * c); xesum += (double) z * c * exp(-1. * lambda * c); xxesum += (double) z * c * c * exp(-1. * lambda * c); *ret_f = 1./lambda - xsum / total + xesum / esum; *ret_df = ((xesum / esum) * (xesum / esum)) - (xxesum / esum) - (1. / (lambda * lambda)); return; } /* Function: EVDMaxLikelyFit() * Date: SRE, Fri Nov 14 07:56:29 1997 [St. Louis] * * Purpose: Given a list or a histogram of EVD-distributed samples, * find maximum likelihood parameters lambda and * mu. * * Algorithm: Uses approach described in [Lawless82]. Solves * for lambda using Newton/Raphson iterations; * then substitutes lambda into Lawless' equation 4.1.5 * to get mu. * * Newton/Raphson algorithm developed from description in * Numerical Recipes in C [Press88]. * * Args: x - list of EVD distributed samples or x-axis of histogram * c - NULL, or y-axis of histogram * n - number of samples, or number of histogram bins * ret_mu : RETURN: ML estimate of mu * ret_lambda : RETURN: ML estimate of lambda * * Return: 1 on success; 0 on any failure */ int EVDMaxLikelyFit(float *x, int *c, int n, float *ret_mu, float *ret_lambda) { float lambda, mu; float fx; /* f(x) */ float dfx; /* f'(x) */ double esum; /* \sum e^(-lambda xi) */ double mult; double total; float tol = 1e-5; int i; /* 1. Find an initial guess at lambda: linear regression here? */ lambda = 0.2; /* 2. Use Newton/Raphson to solve Lawless 4.1.6 and find ML lambda */ for (i = 0; i < 100; i++) { Lawless416(x, c, n, lambda, &fx, &dfx); if (fabs(fx) < tol) break; /* success */ lambda = lambda - fx / dfx; /* Newton/Raphson is simple */ if (lambda <= 0.) lambda = 0.001; /* but be a little careful */ } /* 2.5: If we did 100 iterations but didn't converge, Newton/Raphson failed. * Resort to a bisection search. Worse convergence speed * but guaranteed to converge (unlike Newton/Raphson). * We assume (!?) that fx is a monotonically decreasing function of x; * i.e. fx > 0 if we are left of the root, fx < 0 if we * are right of the root. */ if (i == 100) { float left, right, mid; Worry(DEBUG_LIGHT, "Newton/Raphson failed; switchover to bisection"); /* First we need to bracket the root */ lambda = right = left = 0.2; Lawless416(x, c, n, lambda, &fx, &dfx); if (fx < 0.) { /* fix right; search left. */ do { left -= 0.1; if (left < 0.) { Worry(DEBUG_LIGHT, "failed to bracket root"); return 0; } Lawless416(x, c, n, left, &fx, &dfx); } while (fx < 0.); } else { /* fix left; search right. */ do { right += 0.1; Lawless416(x, c, n, right, &fx, &dfx); if (right > 100.) { Worry(DEBUG_LIGHT, "failed to bracket root"); return 0; } } while (fx > 0.); } /* now we bisection search in left/right interval */ for (i = 0; i < 100; i++) { mid = (left + right) / 2.; Lawless416(x, c, n, mid, &fx, &dfx); if (fabs(fx) < tol) break; /* success */ if (fx > 0.) left = mid; else right = mid; } if (i == 100) { Worry(DEBUG_LIGHT, "even the bisection search failed"); return 0; } lambda = mid; } /* 3. Substitute into Lawless 4.1.5 to find mu */ esum = 0.; for (i = 0; i < n; i++) { mult = (c == NULL) ? 1. : (double) c[i]; esum += mult * exp(-1 * lambda * x[i]); total += mult; } mu = -1. * log(esum / total) / lambda; *ret_lambda = lambda; *ret_mu = mu; return 1; } /* Function: EVDCensoredFit() * Date: SRE, Mon Nov 17 10:01:05 1997 [St. Louis] * * Purpose: Given a /left-censored/ list or histogram of EVD-distributed * samples, as well as the number of censored samples z and the * censoring value c, * find maximum likelihood parameters lambda and * mu. * * Algorithm: Uses approach described in [Lawless82]. Solves * for lambda using Newton/Raphson iterations; * then substitutes lambda into Lawless' equation 4.2.3 * to get mu. * * Newton/Raphson algorithm developed from description in * Numerical Recipes in C [Press88]. * * Args: x - list of EVD distributed samples or x-axis of histogram * y - NULL, or y-axis of histogram * n - number of observed samples,or number of histogram bins * z - number of censored samples * c - censoring value (all x_i >= c) * ret_mu : RETURN: ML estimate of mu * ret_lambda : RETURN: ML estimate of lambda * * Return: (void) */ int EVDCensoredFit(float *x, int *y, int n, int z, float c, float *ret_mu, float *ret_lambda) { float lambda, mu; float fx; /* f(x) */ float dfx; /* f'(x) */ double esum; /* \sum e^(-lambda xi) */ double mult; double total; float tol = 1e-5; int i; /* 1. Find an initial guess at lambda: linear regression here? */ lambda = 0.2; /* 2. Use Newton/Raphson to solve Lawless 4.2.2 and find ML lambda */ for (i = 0; i < 100; i++) { Lawless422(x, y, n, z, c, lambda, &fx, &dfx); if (fabs(fx) < tol) break; /* success */ lambda = lambda - fx / dfx; /* Newton/Raphson is simple */ if (lambda <= 0.) lambda = 0.001; /* but be a little careful */ } /* 2.5: If we did 100 iterations but didn't converge, Newton/Raphson failed. * Resort to a bisection search. Worse convergence speed * but guaranteed to converge (unlike Newton/Raphson). * We assume (!?) that fx is a monotonically decreasing function of x; * i.e. fx > 0 if we are left of the root, fx < 0 if we * are right of the root. */ if (i == 100) { float left, right, mid; /* First we need to bracket the root */ Worry(DEBUG_LIGHT, "Newton/Raphson failed; switched to bisection"); lambda = right = left = 0.2; Lawless422(x, y, n, z, c, lambda, &fx, &dfx); if (fx < 0.) { /* fix right; search left. */ do { left -= 0.03; if (left < 0.) { Worry(DEBUG_LIGHT, "failed to bracket root"); return 0; } Lawless422(x, y, n, z, c, left, &fx, &dfx); } while (fx < 0.); } else { /* fix left; search right. */ do { right += 0.1; Lawless422(x, y, n, z, c, left, &fx, &dfx); if (right > 100.) { Worry(DEBUG_LIGHT, "failed to bracket root"); return 0; } } while (fx > 0.); } /* now we bisection search in left/right interval */ for (i = 0; i < 100; i++) { mid = (left + right) / 2.; Lawless422(x, y, n, z, c, left, &fx, &dfx); if (fabs(fx) < tol) break; /* success */ if (fx > 0.) left = mid; else right = mid; } if (i == 100) { Worry(DEBUG_LIGHT, "even the bisection search failed"); return 0; } lambda = mid; } /* 3. Substitute into Lawless 4.2.3 to find mu */ esum = total = 0.; for (i = 0; i < n; i++) { mult = (y == NULL) ? 1. : (double) y[i]; esum += mult * exp(-1. * lambda * x[i]); total += mult; } esum += (double) z * exp(-1. * lambda * c); /* term from censored data */ mu = -1. * log(esum / total) / lambda; *ret_lambda = lambda; *ret_mu = mu; return 1; } wise-2.4.1/src/HMMer2/msf.c0000644000175000001440000000677407313404526014645 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* msf.c * SRE, Sun Jul 11 16:17:32 1993 * * Export of GCG MSF multiple sequence alignment * formatted files. * */ #include #include #include #include #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Function: WriteMSF() * * Purpose: Write aseqs, names, weights to an open fp, * in GCG MSF format. The alignment must * be flushed (all aseqs the same length, padded * with gaps) * * Return: (void) */ void WriteMSF(FILE *fp, /* open fp for writing */ char **aseqs, /* aligned sequences */ AINFO *ainfo) { int still_going; /* True if writing another block */ int idx; /* counter for sequences */ int pos; /* position counter */ int namelen; /* maximum name length used */ int len; /* tmp variable for name lengths */ char buffer[51]; /* buffer for writing seq */ char **sqptr; /* ptrs into each sequence */ int charcount; /* num. symbols we're writing */ /* allocate seq pointers that we'll move across each sequence */ sqptr = (char **) MallocOrDie (ainfo->nseq * sizeof(char *)); /* set sqptrs to start of each seq */ for (idx = 0; idx < ainfo->nseq; idx++) sqptr[idx] = aseqs[idx]; /* calculate max namelen used */ namelen = 0; for (idx = 0; idx < ainfo->nseq; idx++) if ((len = strlen(ainfo->sqinfo[idx].name)) > namelen) namelen = len; /***************************************************** * Write the title line *****************************************************/ fprintf(fp, "\n"); /* ack! we're writing bullshit here */ fprintf(fp, " MSF: 000 Type: X Check: 0000 ..\n"); fprintf(fp, "\n"); /***************************************************** * Write the names *****************************************************/ for (idx = 0; idx < ainfo->nseq; idx++) { fprintf(fp, " Name: %-*.*s Len: %5d Check: %5d Weight: %.4f\n", namelen, namelen, ainfo->sqinfo[idx].name, ainfo->alen, GCGchecksum(aseqs[idx], ainfo->alen), ainfo->wgt[idx]); } fprintf(fp, "\n"); fprintf(fp, "//\n"); fprintf(fp, "\n"); /***************************************************** * Write the sequences *****************************************************/ still_going = 1; while (still_going) { still_going = 0; for (idx = 0; idx < ainfo->nseq; idx++) { fprintf(fp, "%-*.*s ", namelen, namelen, ainfo->sqinfo[idx].name); /* get next line's worth of 50 from seq */ strncpy(buffer, sqptr[idx], 50); buffer[50] = '\0'; charcount = strlen(buffer); /* is there still more to go? */ if (charcount == 50 && sqptr[idx][50] != '\0') still_going = 1; /* shift the seq ptr by a line */ sqptr[idx] += charcount; /* draw the sequence line */ pos = 0; while (pos < charcount) { if (isgap(buffer[pos])) fputc('.', fp); else fputc(buffer[pos], fp); pos++; if (!(pos % 10)) fputc(' ', fp); } fputc('\n', fp); } /* put blank line between blocks */ fputc('\n', fp); } free(sqptr); } wise-2.4.1/src/HMMer2/selex.c0000644000175000001440000005713307313404526015173 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* selex.c * * Fri Dec 4 17:43:24 1992, SRE: * Reading and writing aligned sequences to/from disk files. * Implements a new, broader specification of SELEX format * and supercedes alignio.c. * * SRE, Tue Nov 9 17:40:50 1993: * major revision. #= special comments and aliinfo_s optional * alignment info support added. Support for #=CS (consensus * secondary structure), #=SS (individual secondary structure), * #=RF (reference coordinate system), #=SQ (per-sequence header info), * and #=AU ("author") added. * * SRE, Mon Jan 30 14:41:49 1995: * #=SA side chain % surface accessibility annotation supported * * SELEX format is documented in Docs/formats.tex. **************************************************************************** */ #include #include #include #include #include #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif static void homogenize_gapsym(char *s, char gapsym); static int copy_alignment_line(char *aseq, int apos, int name_rcol, char *buffer, int lcol, int rcol, char gapsym); static char commentsyms[] = "%#"; /* Function: ReadSELEX() * * Read multiple aligned sequences from the file seqfile. * Store aligned sequences in aseqs, names in names, and * the number of sequences in num. * * Memory is allocated for aseqs and names, and they must be * free'd by the caller. * * If optional information is desired, a non-NULL ainfo * pointer is passed. * * Returns 1 on success. Returns 0 on failure and sets * squid_errno to indicate the cause of the failure. */ int ReadSELEX(char *seqfile, char ***ret_aseqs, AINFO *ainfo) { FILE *fp; /* ptr to opened seqfile */ char **aseqs; /* aligned seqs */ int num; /* number of seqs read */ char buffer[LINEBUFLEN]; /* input buffer for lines */ char bufcpy[LINEBUFLEN]; /* strtok'able copy of buffer */ struct block_struc { /** alignment data for a block: */ int lcol; /* furthest left aligned sym */ int rcol; /* furthest right aligned sym */ } *blocks; int blocknum; /* number of blocks in file */ char *nptr; /* ptr to start of name on line */ char *sptr; /* ptr into sequence on line */ int currnum; /* num. seqs in given block */ int currblock; /* index for blocks */ int i; /* loop counter */ int seqidx; /* counter for seqs */ int alen; /* length of alignment */ int warn_names; /* becomes TRUE if names don't match between blocks */ int headnum; /* seqidx in per-sequence header info */ int currlen; int count; /*************************************************** * First pass across file. * Count seqs, get names, determine column info * Determine what sorts of info are active in this file. ***************************************************/ ainfo->flags = 0; /* open the file for reading */ fp = fopen(seqfile, "r"); if (fp == NULL) { squid_errno = SQERR_NOFILE; return 0; } /* get first line of the block * (non-comment, non-blank) */ do { if (fgets(buffer, LINEBUFLEN, fp) == NULL) { squid_errno = SQERR_NODATA; return 0; } strcpy(bufcpy, buffer); if (*buffer == '#') { if (strncmp(buffer, "#=CS", 4) == 0) ainfo->flags |= AINFO_CS; else if (strncmp(buffer, "#=RF", 4) == 0) ainfo->flags |= AINFO_RF; } } while ((nptr = strtok(bufcpy, WHITESPACE)) == NULL || (strchr(commentsyms, *nptr) != NULL)); blocknum = 0; warn_names = FALSE; while (!feof(fp)) { /* allocate for info about this block. */ if (blocknum == 0) blocks = (struct block_struc *) MallocOrDie (sizeof(struct block_struc)); else blocks = (struct block_struc *) ReallocOrDie (blocks, (blocknum+1) * sizeof(struct block_struc)); blocks[blocknum].lcol = LINEBUFLEN+1; blocks[blocknum].rcol = -1; currnum = 0; while (nptr != NULL) /* becomes NULL when this block ends. */ { /* First block only: save names */ if (blocknum == 0) { if (currnum == 0) ainfo->sqinfo = (SQINFO *) MallocOrDie (sizeof(SQINFO)); else ainfo->sqinfo = (SQINFO *) ReallocOrDie (ainfo->sqinfo, (currnum + 1) * sizeof(SQINFO)); ainfo->sqinfo[currnum].flags = 0; SetSeqinfoString(&(ainfo->sqinfo[currnum]), nptr, SQINFO_NAME); } else /* in each additional block: check names */ { if (strcmp(ainfo->sqinfo[currnum].name, nptr) != 0) warn_names = TRUE; } currnum++; /* check rcol, lcol */ if ((sptr = strtok(NULL, WHITESPACE)) != NULL) { /* is this the furthest left we've seen word 2 in this block? */ if (sptr - bufcpy < blocks[blocknum].lcol) blocks[blocknum].lcol = sptr - bufcpy; /* look for right side in buffer */ for (sptr = buffer + strlen(buffer) - 1; strchr(WHITESPACE, *sptr) != NULL; sptr --) /* do nothing */ ; if (sptr - buffer > blocks[blocknum].rcol) blocks[blocknum].rcol = sptr - buffer; } /* get the next line; blank line means end of block */ do { if (fgets(buffer, LINEBUFLEN, fp) == NULL) { nptr = NULL; break; } strcpy(bufcpy, buffer); if (strncmp(buffer, "#=SS", 4) == 0) ainfo->sqinfo[currnum-1].flags |= SQINFO_SS; else if (strncmp(buffer, "#=SA", 4) == 0) ainfo->sqinfo[currnum-1].flags |= SQINFO_SA; else if (strncmp(buffer, "#=CS", 4) == 0) ainfo->flags |= AINFO_CS; else if (strncmp(buffer, "#=RF", 4) == 0) ainfo->flags |= AINFO_RF; if ((nptr = strtok(bufcpy, WHITESPACE)) == NULL) break; } while (strchr(commentsyms, *nptr) != NULL); } /* check that number of sequences matches expected */ if (blocknum == 0) num = currnum; else if (currnum != num) { squid_errno = SQERR_FORMAT; return 0; } blocknum++; /* get first line of next block * (non-comment, non-blank) */ do { if (fgets(buffer, LINEBUFLEN, fp) == NULL) { nptr = NULL; break; } strcpy(bufcpy, buffer); } while ((nptr = strtok(bufcpy, WHITESPACE)) == NULL || (strchr(commentsyms, *nptr) != NULL)); } /*************************************************** * Get ready for second pass: * figure out the length of the alignment * malloc space * rewind the file ***************************************************/ alen = 0; for (currblock = 0; currblock < blocknum; currblock++) alen += blocks[currblock].rcol - blocks[currblock].lcol + 1; rewind(fp); /* allocations */ aseqs = (char **) MallocOrDie (num * sizeof(char *)); if (ainfo->flags & AINFO_CS) ainfo->cs = (char *) MallocOrDie ((alen+1) * sizeof(char)); if (ainfo->flags & AINFO_RF) ainfo->rf = (char *) MallocOrDie ((alen+1) * sizeof(char)); for (i = 0; i < num; i++) { aseqs[i] = (char *) MallocOrDie ((alen+1) * sizeof(char)); if (ainfo->sqinfo[i].flags & SQINFO_SS) ainfo->sqinfo[i].ss = (char *) MallocOrDie ((alen+1) * sizeof(char)); if (ainfo->sqinfo[i].flags & SQINFO_SA) ainfo->sqinfo[i].sa = (char *) MallocOrDie ((alen+1) * sizeof(char)); } ainfo->alen = alen; ainfo->nseq = num; ainfo->wgt = (float *) MallocOrDie (sizeof(float) * num); FSet(ainfo->wgt, num, 1.0); /*************************************************** * Second pass across file. Parse header; assemble sequences ***************************************************/ /* We've now made a complete first pass over the file. We know how * many blocks it contains, we know the number of seqs in the first * block, and we know every block has the same number of blocks; * so we can be a bit more cavalier about error-checking as we * make the second pass. */ /* Look for header */ headnum = 0; for (;;) { if (fgets(buffer, LINEBUFLEN, fp) == NULL) { squid_errno = SQERR_NODATA; return 0; } strcpy(bufcpy, buffer); if ((nptr = strtok(bufcpy, WHITESPACE)) == NULL) continue; /* skip blank lines */ if (strcmp(nptr, "#=AU") == 0 && /* "author" info */ (sptr = strtok(NULL, "\n")) != NULL) { strncpy(ainfo->au,sptr,63); ainfo->au[63] = '\0'; ainfo->flags |= AINFO_AUTH; } else if (strcmp(nptr, "#=SQ") == 0) /* per-sequence header info */ { /* first field is the name */ if ((sptr = strtok(NULL, WHITESPACE)) == NULL) { squid_errno = SQERR_FORMAT; return 0; } if (strcmp(sptr, ainfo->sqinfo[headnum].name) != 0) warn_names = TRUE; /* second field is the weight */ if ((sptr = strtok(NULL, WHITESPACE)) == NULL) { squid_errno = SQERR_FORMAT; return 0; } if (!IsReal(sptr)) { squid_errno = SQERR_FORMAT; return 0; } ainfo->wgt[headnum] = atof(sptr); /* third field is database source id */ if ((sptr = strtok(NULL, WHITESPACE)) == NULL) { squid_errno = SQERR_FORMAT; return 0; } SetSeqinfoString(&(ainfo->sqinfo[headnum]), sptr, SQINFO_ID); /* fourth field is database accession number */ if ((sptr = strtok(NULL, WHITESPACE)) == NULL) { squid_errno = SQERR_FORMAT; return 0; } SetSeqinfoString(&(ainfo->sqinfo[headnum]), sptr, SQINFO_ACC); /* fifth field is start..stop::olen */ if ((sptr = strtok(NULL, ".:")) == NULL) { squid_errno = SQERR_FORMAT; return 0; } SetSeqinfoString(&(ainfo->sqinfo[headnum]), sptr, SQINFO_START); if ((sptr = strtok(NULL, ".:")) == NULL) { squid_errno = SQERR_FORMAT; return 0; } SetSeqinfoString(&(ainfo->sqinfo[headnum]), sptr, SQINFO_STOP); if ((sptr = strtok(NULL, ":\t ")) == NULL) { squid_errno = SQERR_FORMAT; return 0; } SetSeqinfoString(&(ainfo->sqinfo[headnum]), sptr, SQINFO_OLEN); /* rest of line is optional description */ if ((sptr = strtok(NULL, "\n")) != NULL) SetSeqinfoString(&(ainfo->sqinfo[headnum]), sptr, SQINFO_DESC); headnum++; } else if (strcmp(nptr, "#=CS") == 0) break; else if (strcmp(nptr, "#=RF") == 0) break; else if (strchr(commentsyms, *nptr) == NULL) break; /* non-comment, non-header */ } currlen = 0; for (currblock = 0 ; currblock < blocknum; currblock++) { /* parse the block */ seqidx = 0; while (nptr != NULL) { /* Consensus structure */ if (strcmp(nptr, "#=CS") == 0) { if (! copy_alignment_line(ainfo->cs, currlen, strlen(nptr)-1, buffer, blocks[currblock].lcol, blocks[currblock].rcol, (char) '.')) { squid_errno = SQERR_FORMAT; return 0; } } /* Reference coordinates */ else if (strcmp(nptr, "#=RF") == 0) { if (! copy_alignment_line(ainfo->rf, currlen, strlen(nptr)-1, buffer, blocks[currblock].lcol, blocks[currblock].rcol, (char) ' ')) { squid_errno = SQERR_FORMAT; return 0; } } /* Individual secondary structure */ else if (strcmp(nptr, "#=SS") == 0) { if (! copy_alignment_line(ainfo->sqinfo[seqidx-1].ss, currlen, strlen(nptr)-1, buffer, blocks[currblock].lcol, blocks[currblock].rcol, (char) '.')) { squid_errno = SQERR_FORMAT; return 0; } } /* Side chain % surface accessibility code */ else if (strcmp(nptr, "#=SA") == 0) { if (! copy_alignment_line(ainfo->sqinfo[seqidx-1].sa, currlen, strlen(nptr)-1, buffer, blocks[currblock].lcol, blocks[currblock].rcol, (char) '.')) { squid_errno = SQERR_FORMAT; return 0; } } /* Aligned sequence; avoid unparsed machine comments */ else if (strncmp(nptr, "#=", 2) != 0) { if (! copy_alignment_line(aseqs[seqidx], currlen, strlen(nptr)-1, buffer, blocks[currblock].lcol, blocks[currblock].rcol, (char) '.')) { squid_errno = SQERR_FORMAT; return 0; } seqidx++; } /* get next line */ for (;;) { nptr = NULL; if (fgets(buffer, LINEBUFLEN, fp) == NULL) break; /* EOF */ strcpy(bufcpy, buffer); if ((nptr = strtok(bufcpy, WHITESPACE)) == NULL) break; /* blank */ if (strncmp(buffer, "#=", 2) == 0) break; /* machine comment */ if (strchr(commentsyms, *nptr) == NULL) break; /* data */ } } /* end of a block */ currlen += blocks[currblock].rcol - blocks[currblock].lcol + 1; /* get line 1 of next block */ for (;;) { if (fgets(buffer, LINEBUFLEN, fp) == NULL) break; /* no data */ strcpy(bufcpy, buffer); if ((nptr = strtok(bufcpy, WHITESPACE)) == NULL) continue; /* blank */ if (strncmp(buffer, "#=", 2) == 0) break; /* machine comment */ if (strchr(commentsyms, *nptr) == NULL) break; /* non-comment */ } } /* end of the file */ /* Lengths in sqinfo are for raw sequence (ungapped), * and SS, SA are 0..rlen-1 not 0..alen-1. * Only the seqs with structures come out of here with lengths set. */ for (seqidx = 0; seqidx < num; seqidx++) { int apos, rpos; /* secondary structures */ if (ainfo->sqinfo[seqidx].flags & SQINFO_SS) { for (apos = rpos = 0; apos < alen; apos++) if (! isgap(aseqs[seqidx][apos])) { ainfo->sqinfo[seqidx].ss[rpos] = ainfo->sqinfo[seqidx].ss[apos]; rpos++; } ainfo->sqinfo[seqidx].ss[rpos] = '\0'; homogenize_gapsym(ainfo->sqinfo[seqidx].ss, (char) '.'); } /* Surface accessibility */ if (ainfo->sqinfo[seqidx].flags & SQINFO_SA) { for (apos = rpos = 0; apos < alen; apos++) if (! isgap(aseqs[seqidx][apos])) { ainfo->sqinfo[seqidx].sa[rpos] = ainfo->sqinfo[seqidx].sa[apos]; rpos++; } ainfo->sqinfo[seqidx].sa[rpos] = '\0'; homogenize_gapsym(ainfo->sqinfo[seqidx].sa, (char) '.'); } } /* NULL-terminate all the strings */ if (ainfo->flags & AINFO_RF) ainfo->rf[alen] = '\0'; if (ainfo->flags & AINFO_CS) { ainfo->cs[alen] = '\0'; homogenize_gapsym(ainfo->cs, (char) '.'); } for (seqidx = 0; seqidx < num; seqidx++) { aseqs[seqidx][alen] = '\0'; homogenize_gapsym(aseqs[seqidx], (char) '.'); } /* find raw sequence lengths for sqinfo */ for (seqidx = 0; seqidx < num; seqidx++) { count = 0; for (sptr = aseqs[seqidx]; *sptr != '\0'; sptr++) if (!isgap(*sptr)) count++; ainfo->sqinfo[seqidx].len = count; ainfo->sqinfo[seqidx].flags |= SQINFO_LEN; } /*************************************************** * Garbage collection and return ***************************************************/ fclose(fp); free(blocks); if (warn_names) Warn("sequences may be in different orders in blocks of %s?", seqfile); *ret_aseqs = aseqs; return 1; } /* Function: WriteSELEX() * * Write aligned sequences to an open file pointer, * breaking into multiple blocks if the sequences are * long. Number of symbols written per line is set by cpl. * The alignment must be flushed (all aseqs the same length). * * cpl cannot exceed 32767. * * May also write optional information from ainfo; * ainfo may be NULL. * * Return: (void) */ void WriteSELEX(FILE *fp, char **aseqs, AINFO *ainfo, int cpl) { int idx; /* counter for sequences */ int namelen; /* maximum name length used */ int len; /* tmp variable for name lengths */ char buffer[32768]; /* buffer for writing seq */ int currpos; char **ss; /* aligned secondary structure strings */ char **sa; /* aligned accessibility strings */ if (cpl > 32767) Die("You can't WriteSELEX() with lines as long as %d, pal.\n", cpl); /* calculate max namelen used */ namelen = 0; for (idx = 0; idx < ainfo->nseq; idx++) if ((len = strlen(ainfo->sqinfo[idx].name)) > namelen) namelen = len; if (namelen < 6) namelen = 6; /* Make aligned secondary structure strings */ ss = (char **) MallocOrDie(sizeof(char *) * ainfo->nseq); sa = (char **) MallocOrDie(sizeof(char *) * ainfo->nseq); for (idx = 0; idx < ainfo->nseq; idx++) { if (ainfo->sqinfo[idx].flags & SQINFO_SS) MakeAlignedString(aseqs[idx], ainfo->alen, ainfo->sqinfo[idx].ss, &(ss[idx])); if (ainfo->sqinfo[idx].flags & SQINFO_SA) MakeAlignedString(aseqs[idx], ainfo->alen, ainfo->sqinfo[idx].sa, &(sa[idx])); } /* Write header info */ if (ainfo->flags & AINFO_AUTH) fprintf(fp, "#=AU %s\n", ainfo->au); for (idx = 0; idx < ainfo->nseq; idx++) fprintf(fp, "#=SQ %-*.*s %6.4f %s %s %d..%d::%d %s\n", namelen, namelen, ainfo->sqinfo[idx].name, ainfo->wgt[idx], (ainfo->sqinfo[idx].flags & SQINFO_ID) ? ainfo->sqinfo[idx].id : "-", (ainfo->sqinfo[idx].flags & SQINFO_ACC) ? ainfo->sqinfo[idx].id : "-", (ainfo->sqinfo[idx].flags & SQINFO_START) ? ainfo->sqinfo[idx].start : 0, (ainfo->sqinfo[idx].flags & SQINFO_STOP) ? ainfo->sqinfo[idx].stop : 0, (ainfo->sqinfo[idx].flags & SQINFO_OLEN) ? ainfo->sqinfo[idx].olen : 0, (ainfo->sqinfo[idx].flags & SQINFO_DESC) ? ainfo->sqinfo[idx].desc : "-"); fprintf(fp, "\n"); /* main loop: write seqs in blocks. */ for (currpos = 0; currpos < ainfo->alen; currpos += cpl) { /* Reference coord system */ if (ainfo->flags & AINFO_RF) { strncpy(buffer, ainfo->rf + currpos, cpl); buffer[cpl] = '\0'; fprintf(fp, "%-*.*s %s\n", namelen, namelen, "#=RF", buffer); } /* Consensus secondary structure */ if (ainfo->flags & AINFO_CS) { strncpy(buffer, ainfo->cs + currpos, cpl); buffer[cpl] = '\0'; fprintf(fp, "%-*.*s %s\n", namelen, namelen, "#=CS", buffer); } for (idx = 0; idx < ainfo->nseq; idx++) { /* Aligned sequence */ strncpy(buffer, aseqs[idx] + currpos, cpl); buffer[cpl] = '\0'; fprintf(fp, "%-*.*s %s\n", namelen, namelen, ainfo->sqinfo[idx].name, buffer); /* Individual secondary structure */ if (ainfo->sqinfo[idx].flags & SQINFO_SS) { strncpy(buffer, ss[idx] + currpos, cpl); buffer[cpl] = '\0'; fprintf(fp, "%-*.*s %s\n", namelen, namelen, "#=SS", buffer); } /* Surface accessibility */ if (ainfo->sqinfo[idx].flags & SQINFO_SA) { strncpy(buffer, sa[idx] + currpos, cpl); buffer[cpl] = '\0'; fprintf(fp, "%-*.*s %s\n", namelen, namelen, "#=SA", buffer); } } /* put blank line between blocks */ fprintf(fp, "\n"); } /* Garbage collection */ for (idx = 0; idx < ainfo->nseq; idx++) { if (ainfo->sqinfo[idx].flags & SQINFO_SS) free(ss[idx]); if (ainfo->sqinfo[idx].flags & SQINFO_SA) free(sa[idx]); } free(ss); free(sa); } /* Function: homogenize_gapsym() * * Purpose: Make gap symbols homogeneous. */ static void homogenize_gapsym(char *s, char gapsym) { for (; *s != '\0'; s++) if (isgap(*s)) *s = gapsym; } /* Function: copy_alignment_line() * * Purpose: Given a line from an alignment file, and bounds lcol,rcol * on what part of it may be sequence, save the alignment into * aseq starting at position apos. * * name_rcol is set to the rightmost column this aseqs's name * occupies; if name_rcol >= lcol, we have a special case in * which the name intrudes into the sequence zone. */ static int copy_alignment_line(char *aseq, int apos, int name_rcol, char *buffer, int lcol, int rcol, char gapsym) { char *s1, *s2; int i; s1 = aseq + apos; s2 = buffer; /* be careful that buffer doesn't end before lcol! */ for (i = 0; i < lcol; i++) if (*s2) s2++; for (i = lcol; i <= rcol; i++) { if (*s2 == '\t') { Warn("TAB characters will corrupt a SELEX alignment! Please remove them first."); return 0; } if (name_rcol >= i) /* name intrusion special case: pad left w/ gaps */ *s1 = gapsym; /* short buffer special case: pad right w/ gaps */ else if (*s2 == '\0' || *s2 == '\n') *s1 = gapsym; else /* normal case: copy buffer into aseq */ *s1 = *s2; s1++; if (*s2) s2++; } return 1; } /* Function: DealignAseqs() * * Given an array of (num) aligned sequences aseqs, * strip the gaps, represented by ' ' space characters. * Store the raw sequences in a new allocated array. * * Caller is responsible for free'ing the memory allocated to * rseqs. * * Returns 1 on success. Returns 0 and sets squid_errno on * failure. */ int DealignAseqs(char **aseqs, int num, char ***ret_rseqs) { char **rseqs; /* de-aligned sequence array */ int idx; /* counter for sequences */ int depos; /* position counter for dealigned seq*/ int apos; /* position counter for aligned seq */ int seqlen; /* length of aligned seq */ /* alloc space */ rseqs = (char **) MallocOrDie (num * sizeof(char *)); /* main loop */ for (idx = 0; idx < num; idx++) { seqlen = strlen(aseqs[idx]); /* alloc space */ rseqs[idx] = (char *) MallocOrDie ((seqlen + 1) * sizeof(char)); /* strip gaps */ depos = 0; for (apos = 0; aseqs[idx][apos] != '\0'; apos++) if (!isgap(aseqs[idx][apos])) { rseqs[idx][depos] = aseqs[idx][apos]; depos++; } rseqs[idx][depos] = '\0'; } *ret_rseqs = rseqs; return 1; } /* Function: IsSELEXFormat() * * Return TRUE if filename may be in SELEX format. * * Accuracy is sacrificed for speed; a TRUE return does * *not* guarantee that the file will pass the stricter * error-checking of ReadSELEX(). All it checks is that * the first 500 non-comment lines of a file are * blank, or if there's a second "word" on the line * it looks like sequence (i.e., it's not kOtherSeq). * * Returns TRUE or FALSE. */ int IsSELEXFormat(char *filename) { FILE *fp; /* ptr to open sequence file */ char buffer[LINEBUFLEN]; char *sptr; /* ptr to first word */ int linenum; if ((fp = fopen(filename, "r")) == NULL) { squid_errno = SQERR_NOFILE; return 0; } linenum = 0; while (linenum < 500 && fgets(buffer, LINEBUFLEN, fp) != NULL) { linenum++; /* dead giveaways for extended SELEX */ if (strncmp(buffer, "#=AU", 4) == 0) goto DONE; else if (strncmp(buffer, "#=SQ", 4) == 0) goto DONE; else if (strncmp(buffer, "#=SS", 4) == 0) goto DONE; else if (strncmp(buffer, "#=CS", 4) == 0) goto DONE; else if (strncmp(buffer, "#=RF", 4) == 0) goto DONE; /* a comment? */ if (strchr(commentsyms, *buffer) != NULL) continue; /* a blank line? */ if ((sptr = strtok(buffer, WHITESPACE)) == NULL) continue; /* a one-word line (name only) is possible, though rare */ if ((sptr = strtok(NULL, "\n")) == NULL) continue; if (Seqtype(sptr) == kOtherSeq) {fclose(fp); return 0;} } DONE: fclose(fp); return 1; } /* Function: TruncateNames() * * Make sure all names are a single word. * - if they are blank, make a name up (use the number of the sequence) * - if it's already one word, leave it alone * - if it's more than one word, put a terminator '\0' after the * first word * * Used to check an array of names before writing a SELEX-format file. * * Returns 1 on success. Returns 0 on failure and sets squid_errno * to indicate the cause. */ int TruncateNames(char **names, int N) { int idx; char newname[32]; for (idx = 0; idx < N; idx++) if (names[idx] == NULL || strtok(names[idx], " \t\n") == NULL) { (void) sprintf(newname, "%d", idx); if (names[idx] != NULL) free(names[idx]); names[idx] = Strdup(newname); } return 1; } wise-2.4.1/src/HMMer2/hmmalign.c0000644000175000001440000001653207313404525015644 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Washington University School of Medicine * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* hmmalign.c * SRE, Thu Dec 18 16:05:29 1997 [St. Louis] * * main() for aligning a set of sequences to an HMM. * RCS $Id: hmmalign.c,v 1.1.1.1 2001/06/18 13:59:49 birney Exp $ */ #include #include #include "structs.h" /* data structures, macros, #define's */ #include "config.h" /* compile-time configuration constants */ #include "funcs.h" /* function declarations */ #include "globals.h" /* alphabet global variables */ #include "squid.h" /* general sequence analysis library */ #ifdef MEMDEBUG #include "dbmalloc.h" #endif static char banner[] = "hmmalign - align sequences to an HMM profile"; static char usage[] = "\ Usage: hmmalign [-options] \n\ Available options are:\n\ -h : help; print brief help on version and usage\n\ -m : only print symbols aligned to match states\n\ -o : save alignment in file in SELEX format\n\ -q : quiet - suppress verbose banner\n\ "; static char experts[] = "\ \n"; static struct opt_s OPTIONS[] = { { "-h", TRUE, sqdARG_NONE }, { "-m", TRUE, sqdARG_NONE } , { "-o", TRUE, sqdARG_STRING }, { "-q", TRUE, sqdARG_NONE }, }; #define NOPTIONS (sizeof(OPTIONS) / sizeof(struct opt_s)) int main(int argc, char **argv) { char *hmmfile; /* file to read HMMs from */ HMMFILE *hmmfp; /* opened hmmfile for reading */ char *seqfile; /* file to read target sequence from */ int format; /* format of seqfile */ char **rseq; /* raw, unaligned sequences */ SQINFO *sqinfo; /* info associated with sequences */ char **dsq; /* digitized raw sequences */ int nseq; /* number of sequences */ char **aseq; /* aligned sequences */ AINFO ainfo; /* alignment information */ float *wgt; /* per-sequence weights */ int i; struct plan7_s *hmm; /* HMM to align to */ struct p7trace_s **tr; /* traces for aligned sequences */ char *optname; /* name of option found by Getopt() */ char *optarg; /* argument found by Getopt() */ int optind; /* index in argv[] */ int be_quiet; /* TRUE to suppress verbose banner */ int matchonly; /* TRUE to show only match state syms */ char *outfile; /* optional alignment output file */ FILE *ofp; /* handle on alignment output file */ #ifdef MEMDEBUG unsigned long histid1, histid2, orig_size, current_size; orig_size = malloc_inuse(&histid1); fprintf(stderr, "[... memory debugging is ON ...]\n"); #endif /*********************************************** * Parse command line ***********************************************/ matchonly = FALSE; outfile = NULL; be_quiet = FALSE; while (Getopt(argc, argv, OPTIONS, NOPTIONS, usage, &optind, &optname, &optarg)) { if (strcmp(optname, "-m") == 0) matchonly= TRUE; else if (strcmp(optname, "-o") == 0) outfile = optarg; else if (strcmp(optname, "-q") == 0) be_quiet = TRUE; else if (strcmp(optname, "-h") == 0) { Banner(stdout, banner); puts(usage); puts(experts); exit(0); } } if (argc - optind != 2) Die("Incorrect number of arguments.\n%s\n", usage); hmmfile = argv[optind++]; seqfile = argv[optind++]; /*********************************************** * Open HMM file (might be in HMMERDB or current directory). * Read a single HMM from it. ***********************************************/ if ((hmmfp = HMMFileOpen(hmmfile, "HMMERDB")) == NULL) Die("Failed to open HMM file %s\n%s", hmmfile, usage); if (!HMMFileRead(hmmfp, &hmm)) Die("Failed to read any HMMs from %s\n", hmmfile); HMMFileClose(hmmfp); if (hmm == NULL) Die("HMM file %s corrupt or in incorrect format? Parse failed", hmmfile); P7Logoddsify(hmm, TRUE); /*********************************************** * Open sequence file in current directory. * Read all seqs from it. ***********************************************/ if (! SeqfileFormat(seqfile, &format, NULL)) switch (squid_errno) { case SQERR_NOFILE: Die("Sequence file %s could not be opened for reading", seqfile); /*FALLTHRU*/ case SQERR_FORMAT: default: Die("Failed to determine format of sequence file %s", seqfile); } if (! ReadMultipleRseqs(seqfile, format, &rseq, &sqinfo, &nseq)) Die("Failed to read any sequences from file %s", seqfile); /*********************************************** * Show the banner ***********************************************/ if (! be_quiet) { Banner(stdout, banner); printf( "HMM file: %s\n", hmmfile); printf( "Sequence file: %s\n", seqfile); printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n"); } /*********************************************** * Do the work ***********************************************/ /* Allocations and initializations. */ dsq = MallocOrDie(sizeof(char *) * nseq); tr = MallocOrDie(sizeof(struct p7trace_s *) * nseq); wgt = MallocOrDie(sizeof(float) * nseq); FSet(wgt, nseq, 1.0); /* Align each sequence to the model, collect traces */ for (i = 0; i < nseq; i++) { dsq[i] = DigitizeSequence(rseq[i], sqinfo[i].len); if (P7ViterbiSize(sqinfo[i].len, hmm->M) <= RAMLIMIT) (void) P7Viterbi(dsq[i], sqinfo[i].len, hmm, &(tr[i])); else (void) P7SmallViterbi(dsq[i], sqinfo[i].len, hmm, &(tr[i])); } /* Turn traces into a multiple alignment */ P7Traces2Alignment(dsq, sqinfo, wgt, nseq, hmm->M, tr, matchonly, &aseq, &ainfo); /*********************************************** * Output the alignment ***********************************************/ if (outfile != NULL && (ofp = fopen(outfile, "w")) != NULL) { WriteSELEX(ofp, aseq, &ainfo, 50); printf("Alignment saved in file %s\n", outfile); fclose(ofp); } else WriteSELEX(stdout, aseq, &ainfo, 50); /*********************************************** * Cleanup and exit ***********************************************/ for (i = 0; i < nseq; i++) { P7FreeTrace(tr[i]); FreeSequence(rseq[i], &(sqinfo[i])); free(dsq[i]); } FreeAlignment(aseq, &ainfo); FreePlan7(hmm); free(sqinfo); free(dsq); free(wgt); free(tr); SqdClean(); #ifdef MEMDEBUG current_size = malloc_inuse(&histid2); if (current_size != orig_size) malloc_list(2, histid1, histid2); else fprintf(stderr, "[No memory leaks.]\n"); #endif return 0; } wise-2.4.1/src/HMMer2/sre_string.c0000644000175000001440000002100707313404527016222 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1998 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* sre_string.c * * my library of extra string functions. Some for portability * across UNIXes */ #include #include #include #include #include "gnuregex.h" #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* global sqd_parse[] are managed by Strparse(). */ char *sqd_parse[10]; /* Function: Strdup() * * Purpose: Implementation of the common (but non-ANSI) function * strdup(). Robust against being passed a NULL pointer. * */ char * Strdup(char *s) { char *new; if (s == NULL) return NULL; if ((new = (char *) malloc (strlen(s) +1)) == NULL) return NULL; strcpy(new, s); return new; } /* Function: StringChop() * Date: SRE, Wed Oct 29 12:10:02 1997 [TWA 721] * * Purpose: Chop trailing whitespace off of a string. */ void StringChop(char *s) { char *ptr; ptr = s; while (*ptr != '\0') ptr++; ptr--; while (isspace(*ptr)) ptr--; *(ptr+1) = '\0'; } int Strinsert(char *s1, /* string to insert a char into */ char c, /* char to insert */ int pos) /* position in s1 to insert c at */ { char oldc; char *s; for (s = s1 + pos; c; s++) { /* swap current char for inserted one */ oldc = *s; /* pick up current */ *s = c; /* put down inserted one */ c = oldc; /* old becomes next to insert */ } *s = '\0'; return 1; } int Strdelete(char *s1, /* string to delete a char from */ int pos) /* position of char to delete 0..n-1 */ { char *s; for (s = s1 + pos; *s; s++) *s = *(s + 1); return 1; } void s2lower(char *s) { for (; *s != '\0'; s++) *s = sre_tolower((int) *s); } void s2upper(char *s) { for (; *s != '\0'; s++) *s = sre_toupper((int) *s); } void * MallocOrDie(size_t size) { void *ptr; if ((ptr = malloc (size)) == NULL) Die("malloc failed"); return ptr; } void * ReallocOrDie(void *p, size_t size) { void *ptr; if ((ptr = realloc(p, size)) == NULL) Die("realloc failed"); return ptr; } /* Function: Strparse() * * Purpose: Match a regexp to a string. * Return 0 if it matches, REG_NOMATCH if it doesn't. * * Much like Perl, Strparse() makes copies of the matching * substrings available via globals, sqd_parse[]. * sqd_parse[0] contains a copy of the complete matched * text. sqd_parse[1-9] contain copies of up to nine * different substrings matched within parentheses. * The memory for these strings is internally managed and * volatile; the next call to Strparse() may destroy them. * If the caller needs the matched substrings to persist * beyond a new Strparse() call, it must make its own * copies. * * A minor drawback of the memory management is that * there will be a small amount of unfree'd memory being * managed by Strparse() when a program exits; this may * confuse memory debugging (Purify, dbmalloc). The * general cleanup function SqdClean() is provided; * you can call this before exiting. * * Uses an extended POSIX regular expression interface. * A copylefted GNU implementation is included in the squid * implementation (gnuregex.c) for use on non-POSIX compliant * systems. POSIX 1003.2-compliant systems (all UNIX, * some WinNT, I believe) can omit the GNU code if necessary. * * I built this for ease of use, not speed nor efficiency. * * Example: Strparse("foo-...-baz", "foo-bar-baz") returns 0 * Strparse("foo-(...)-baz", "foo-bar-baz") * returns 0; sqd_parse[0] is "foo-bar-baz"; * sqd_parse[1] is "bar". * * Args: rexp - regular expression, extended POSIX form * s - string to match against * ntok - number of () substrings we will save (maximum 9) * * Return: 0 on match, REG_NOMATCH on failure to match */ int Strparse(char *rexp, char *s, int ntok) { regex_t pat; int code; regmatch_t *pmatch; int len; int i; /* sanity check */ if (ntok > 9) Die("Strparse(): ntok must be <= 9"); /* Free previous global substring buffers */ for (i = 0; i <= ntok; i++) if (sqd_parse[i] != NULL) { free(sqd_parse[i]); sqd_parse[i] = NULL; } /* Compile and match the pattern */ if ((code = regcomp(&pat, rexp, REG_EXTENDED)) != 0) Die("POSIX regex compilation failed."); pmatch = (regmatch_t *) MallocOrDie (sizeof(regmatch_t) * 10); code = regexec(&pat, s, 10, pmatch, 0); /* Fill the global substring buffers */ if (code == 0) for (i = 0; i <= ntok; i++) { len = pmatch[i].rm_eo - pmatch[i].rm_so; sqd_parse[i] = (char *) MallocOrDie(sizeof(char) * (len+1)); strncpy(sqd_parse[i], s+pmatch[i].rm_so, len); sqd_parse[i][len] = '\0'; } free(pmatch); regfree(&pat); return code; } /* Function: SqdClean() * Date: SRE, Wed Oct 29 12:52:08 1997 [TWA 721] * * Purpose: Clean up any squid library allocations before exiting * a program, so we don't leave unfree'd memory around * and confuse a malloc debugger like Purify or dbmalloc. */ void SqdClean(void) { int i; /* Free global substring buffers that Strparse() uses */ for (i = 0; i <= 9; i++) if (sqd_parse[i] != NULL) { free(sqd_parse[i]); sqd_parse[i] = NULL; } } /* Function: StrShuffle() * * Purpose: Returns a shuffled version of s2, in s1. * (s1 and s2 can be identical, to shuffle in place.) * * Args: s1 - allocated space for shuffled string. * s2 - string to shuffle. * * Return: void */ void StrShuffle(char *s1, char *s2) { int len; int pos; char c; if (s1 != s2) strcpy(s1, s2); for (len = strlen(s1); len > 1; len--) { pos = CHOOSE(len); c = s1[pos]; s1[pos] = s1[len-1]; s1[len-1] = c; } } /* Function: StrReverse() * Date: SRE, Thu Nov 20 10:54:52 1997 [St. Louis] * * Purpose: Returns a reversed version of s2, in s1. * (s1 and s2 can be identical, to reverse in place) * * Args: s1 - allocated space for reversed string. * s2 - string to reverse. * * Return: (void) */ void StrReverse(char *s1, char *s2) { int len; int pos; char c; if (s1 != s2) strcpy(s1, s2); len = strlen(s1); for (pos = 0; pos < len/2; pos++) { /* swap ends */ c = s1[len-pos-1]; s1[len-pos-1] = s1[pos]; s1[pos] = c; } } /* Function: StrRegionalShuffle() * Date: SRE, Thu Nov 20 11:02:34 1997 [St. Louis] * * Purpose: Returns a regionally shuffled version of s2, in s1. * (s1 and s2 can be identical to regionally * shuffle in place.) See [Pearson88]. * * Args: s1 - allocated space for regionally shuffled string. * s2 - string to regionally shuffle * w - window size (typically 10 or 20) * * Return: (void) */ void StrRegionalShuffle(char *s1, char *s2, int w) { int len; char c; int pos; int i, j; if (s1 != s2) strcpy(s1, s2); len = strlen(s1); for (i = 0; i < len; i += w) for (j = MIN(len-1, i+w-1); j > i; j--) { pos = i + CHOOSE(j-i); c = s1[pos]; s1[pos] = s1[j]; s1[j] = c; } } /* Function: RandomSequence() * * Purpose: Generate an iid symbol sequence according * to some alphabet, alphabet_size, probability * distribution, and length. Return the * sequence. * * Args: alphabet - e.g. "ACGT" * p - probability distribution [0..n-1] * n - number of symbols in alphabet * len - length of generated sequence * * Return: ptr to random sequence, or NULL on failure. */ char * RandomSequence(char *alphabet, float *p, int n, int len) { char *s; int x; s = (char *) MallocOrDie (sizeof(char) * (len+1)); for (x = 0; x < len; x++) s[x] = alphabet[FChoose(p,n)]; s[x] = '\0'; return s; } wise-2.4.1/src/HMMer2/structs.h0000644000175000001440000004375310670453705015575 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Washington University School of Medicine * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* structs.h * * Data structures used in HMMER. * Also, a few miscellaneous macros and global variable declarations. * * RCS $Id: structs.h,v 1.1.1.1 2001/06/18 13:59:51 birney Exp $ */ #ifndef STRUCTSH_INCLUDED #define STRUCTSH_INCLUDED #include "squid.h" #include "config.h" /* Miscellaneous math macros used in the package */ #define sreLOG2(x) ((x) > 0 ? log(x) * 1.44269504 : -9999.) #define sreEXP2(x) (exp((x) * 0.69314718 )) #define SQR(x) ((x) * (x)) /* an idiom for determining a symbol's position in the array * by pointer arithmetic. * does no error checking, so caller must already be damned sure x is * valid in the alphabet! */ #define SYMIDX(x) (strchr(Alphabet, (x)) - Alphabet) /* Worry() is a conditional warning macro, used for debugging; * it inserts file name and line number information and * calls VerboseWorry(). See debug.c. * * PANIC is called for failures of Std C/POSIX functions, * instead of my own functions. It calls perror() and exits * abnormally. */ #define Worry(x,s) VerboseWorry(x, __FILE__, __LINE__, s) #define PANIC (Panic(__FILE__, __LINE__)) /* The symbol alphabet. * Must deal with IUPAC degeneracies. Nondegenerate symbols * come first in Alphabet[], followed by degenerate symbols. * Nucleic alphabet also must deal with other common symbols * like U (in RNA) and X (often misused for N). * Example: * Nucleic: "ACGTUNRYMKSWHBVDX" size=4 iupac=17 * Amino: "ACDEFGHIKLMNPQRSTVWYBZX" size=20 iupac=23 * * Parts of the code assume that the last symbol is a * symbol for an unknown residue, i.e. 'X'. * * MAXCODE and MAXABET constants are defined in config.h */ extern char Alphabet[MAXCODE+1]; /* "ACDEFGHIKLMNPQRSTVWYBZX" for example */ extern int Alphabet_type; /* hmmNUCLEIC or hmmAMINO */ extern int Alphabet_size; /* uniq alphabet size: 4 or 20 */ extern int Alphabet_iupac; /* total size of alphabet + IUPAC degen. */ extern char Degenerate[MAXCODE][MAXABET]; extern int DegenCount[MAXCODE]; #define hmmNOTSETYET 0 #define hmmNUCLEIC 2 /* compatibility with squid's kDNA */ #define hmmAMINO 3 /* compatibility with squid's kAmino */ /********************************************************************** * * Plan7 * Implementation of the new Plan7 HMM architecture. * Fully probabilistic even for hmmsw, hmmls, and hmmfs; * No insert->delete or delete->insert transitions; * Improved structure layout. * * The strategy is to infiltrate plan7 code into HMMER in * an evolutionary rather than revolutionary manner. * **********************************************************************/ /* Plan 7 construction strategies. */ enum p7_construction { P7_MAP_CONSTRUCTION, /* maximum a posteriori architecture */ P7_HAND_CONSTRUCTION, /* hand specified architecture */ P7_FAST_CONSTRUCTION /* fast ad hoc architecture */ }; /* Plan 7 parameter optimization strategies */ enum p7_param { P7_MAP_PARAM, /* standard maximum a posteriori */ P7_MD_PARAM, /* maximum discrimination */ P7_MRE_PARAM, /* maximum relative entropy */ P7_WMAP_PARAM /* ad hoc weighted MAP */ }; /* Structure: plan7_s * * Declaration of a Plan 7 profile-HMM. */ struct plan7_s { /* Annotation on the model. A name is mandatory. * Other fields are optional; whether they are present is * flagged in the stateflags bit array. * * desc is only valid if PLAN7_DESC is set. * rf is only valid if PLAN7_RF is set. * cs is only valid if PLAN7_CS is set. */ char *name; /* name of the model +*/ char *desc; /* brief description of model +*/ char *rf; /* reference line from alignment 0..M +*/ char *cs; /* consensus structure line 0..M +*/ char *comlog; /* command line(s) that built model +*/ int nseq; /* number of training sequences +*/ char *ctime; /* creation date +*/ /* The main model in probability form: data-dependent probabilities. * This is the core Krogh/Haussler model. * Transition probabilities are usually accessed as a * two-D array: hmm->t[k][TMM], for instance. They are allocated * such that they can also be stepped through in 1D by pointer * manipulations, for efficiency in DP algorithms. */ int M; /* length of the model (# nodes) +*/ float **t; /* transition prob's. t[1..M-1][0..6] +*/ float **mat; /* match emissions. mat[1..M][0..19] +*/ float **ins; /* insert emissions. ins[1..M-1][0..19] +*/ float tbd1; /* B->D1 prob (data dependent) +*/ /* The unique states of Plan 7 in probability form. * These are the algorithm-dependent, data-independent probabilities. */ float xt[4][2]; /* N,E,C,J extra states: 2 transitions +*/ float *begin; /* 1..M B->M state transitions +*/ float *end; /* 1..M M->E state transitions (!= a dist!) +*/ /* The null model probabilities. */ float null[MAXABET]; /* "random sequence" emission prob's +*/ float p1; /* null model loop probability +*/ /* The model in log-odds score form. * These are created from the probabilities by LogoddsifyHMM(). * By definition, null[] emission scores are all zero. * Note that emission distributions are over 26 upper-case letters, * not just the unambiguous protein or DNA alphabet: we * precalculate the scores for all IUPAC degenerate symbols we * may see. Non-IUPAC symbols simply have a -INFTY score. * Note the reversed indexing on msc and isc -- for efficiency reasons. * * Only valid if PLAN7_HASBITS is set. */ int **tsc; /* transition scores [1.M-1][0.6] -*/ int **msc; /* match emission scores [0.MAXCODE-1][1.M] -*/ int **isc; /* ins emission scores [0.MAXCODE-1][1.M-1] -*/ int xsc[4][2]; /* N,E,C,J transitions -*/ int *bsc; /* begin transitions [1.M] -*/ int *esc; /* end transitions [1.M] -*/ /* DNA translation scoring parameters * For aligning protein Plan7 models to DNA sequence. * Lookup value for a codon is calculated by pos1 * 16 + pos2 * 4 + pos3, * where 'pos1' is the digitized value of the first nucleotide position; * if any of the positions are ambiguous codes, lookup value 64 is used * (which will generally have a score of zero) * * Only valid if PLAN7_HASDNA is set. */ int **dnam; /* triplet match scores [0.64][1.M] -*/ int **dnai; /* triplet insert scores [0.64][1.M] -*/ int dna2; /* -1 frameshift, doublet emission, M or I -*/ int dna4; /* +1 frameshift, doublet emission, M or I -*/ /* P-value and E-value statistical parameters * Only valid if PLAN7_STATS is set. */ float mu; /* EVD mu +*/ float lambda; /* EVD lambda +*/ float wonka; /* EVD fit display fudge factor +*/ int flags; /* bit flags indicating state of HMM +*/ }; /* Flags for plan7->flags. * Note: Some models have scores but no probabilities (for instance, * after reading from an HMM save file). Other models have * probabilities but no scores (for instance, during training * or building). Since it costs time to convert either way, * I use PLAN7_HASBITS and PLAN7_HASPROB flags to defer conversion * until absolutely necessary. This means I have to be careful * about keeping these flags set properly when I fiddle a model. */ #define PLAN7_HASBITS (1<<0) /* raised if model has log-odds scores */ #define PLAN7_DESC (1<<1) /* raised if description exists */ #define PLAN7_RF (1<<2) /* raised if #RF annotation available */ #define PLAN7_CS (1<<3) /* raised if #CS annotation available */ #define PLAN7_XRAY (1<<4) /* raised if structural data available */ #define PLAN7_HASPROB (1<<5) /* raised if model has probabilities */ #define PLAN7_HASDNA (1<<6) /* raised if protein HMM->DNA seq params set*/ #define PLAN7_STATS (1<<7) /* raised if EVD parameters are available */ /* Indices for special state types, I: used for dynamic programming xmx[][] * mnemonic: eXtra Matrix for B state = XMB */ #define XMB 0 #define XME 1 #define XMC 2 #define XMJ 3 #define XMN 4 /* Indices for special state types, II: used for hmm->xt[] indexing * mnemonic: eXtra Transition for N state = XTN */ #define XTN 0 #define XTE 1 #define XTC 2 #define XTJ 3 /* Indices for Plan7 main model state transitions. * Used for indexing hmm->t[k][] * mnemonic: Transition from Match to Match = TMM */ #define TMM 0 #define TMI 1 #define TMD 2 #define TIM 3 #define TII 4 #define TDM 5 #define TDD 6 /* Indices for extra state transitions * Used for indexing hmm->xt[][]. */ #define MOVE 0 /* trNB, trEC, trCT, trJB */ #define LOOP 1 /* trNN, trEJ, trCC, trJJ */ /* Declaration of Plan7 dynamic programming matrix structure. */ struct dpmatrix_s { int **xmx; /* special scores [0.1..N][BECJN] */ int **mmx; /* match scores [0.1..N][0.1..M] */ int **imx; /* insert scores [0.1..N][0.1..M-1.M] */ int **dmx; /* delete scores [0.1..N][0.1..M-1.M] */ }; /* Structure: HMMFILE * * Purpose: An open HMM file or HMM library. See hmmio.c. */ struct hmmfile_s { FILE *f; /* pointer to file opened for reading */ int (*parser)(struct hmmfile_s *, struct plan7_s **); /* parsing function*/ int is_binary; /* TRUE if format is a binary one */ int byteswap; /* TRUE if binary and byteswapped */ }; typedef struct hmmfile_s HMMFILE; /* Plan 7 model state types * used in traceback structure */ enum p7stype { STM, STD, STI, STS, STN, STB, STE, STC, STT, STJ, STBOGUS }; /* Structure: p7trace_s * * Traceback structure for alignments of model to sequence. * Each array in a trace_s is 0..tlen-1. * Element 0 is always to STATE_S. Element tlen-1 is always to STATE_T. */ struct p7trace_s { int tlen; /* length of traceback */ enum p7stype *statetype; /* state type used for alignment */ int *nodeidx; /* index of aligned node, 1..M (if M,D,I) */ int *pos; /* position in dsq, 1..L or -1 */ }; /* Structure: p7prior_s * * Dirichlet priors on HMM parameters. */ struct p7prior_s { int strategy; /* PRI_DCHLET, etc. */ int tnum; /* number of transition Dirichlet mixtures */ float tq[MAXDCHLET]; /* probabilities of tnum components */ float t[MAXDCHLET][7]; /* transition terms per mix component */ int mnum; /* number of mat emission Dirichlet mixtures */ float mq[MAXDCHLET]; /* probabilities of mnum components */ float m[MAXDCHLET][MAXABET]; /* match emission terms per mix component */ int inum; /* number of insert emission Dirichlet mixes */ float iq[MAXDCHLET]; /* probabilities of inum components */ float i[MAXDCHLET][MAXABET]; /* insert emission terms */ }; #define PRI_DCHLET 0 /* simple or mixture Dirichlets */ #define PRI_PAM 1 /* PAM prior hack */ /********************************************************************** * Other structures, not having to do with HMMs. **********************************************************************/ /* Structure: histogram_s * * Keep a score histogram. * * The main implementation issue here is that the range of * scores is unknown, and will go negative. histogram is * a 0..max-min array that represents the range min..max. * A given score is indexed in histogram array as score-min. * The AddToHistogram() function deals with dynamically * resizing the histogram array when necessary. */ struct histogram_s { int *histogram; /* counts of hits */ int min; /* elem 0 of histogram == min */ int max; /* last elem of histogram == max */ int highscore; /* highest active elem has this score */ int lowscore; /* lowest active elem has this score */ int lumpsize; /* when resizing, overalloc by this */ int total; /* total # of hits counted */ float *expect; /* expected counts of hits */ int fit_type; /* flag indicating distribution type */ float param[3]; /* parameters used for fits */ float chisq; /* chi-squared val for goodness of fit*/ float chip; /* P value for chisquared */ }; #define HISTFIT_NONE 0 /* no fit done yet */ #define HISTFIT_EVD 1 /* fit type = extreme value dist */ #define HISTFIT_GAUSSIAN 2 /* fit type = Gaussian */ #define EVD_MU 0 /* EVD fit parameter mu */ #define EVD_LAMBDA 1 /* EVD fit parameter lambda */ #define EVD_WONKA 2 /* EVD fit fudge factor */ #define GAUSS_MEAN 0 /* Gaussian parameter mean */ #define GAUSS_SD 1 /* Gaussian parameter std. dev. */ /* Structure: fancyali_s * * Alignment of a hit to an HMM, for printing. */ struct fancyali_s { char *rfline; /* reference coord info */ char *csline; /* consensus structure info */ char *model; /* aligned query consensus sequence */ char *mline; /* "identities", conservation +'s, etc. */ char *aseq; /* aligned target sequence */ int len; /* length of strings */ char *query; /* name of query HMM */ char *target; /* name of target sequence */ int sqfrom; /* start position on sequence (1..L) */ int sqto; /* end position on sequence (1..L) */ }; /* Structure: hit_s * * Info about a high-scoring database hit. * We keep this info in memory, so we can output a * sorted list of high hits at the end. * * sqfrom and sqto are the coordinates that will be shown * in the results, not coords in arrays... therefore, reverse * complements have sqfrom > sqto */ struct hit_s { double sortkey; /* number to sort by; big is better */ float score; /* score of the hit */ double pvalue; /* P-value of the hit */ float mothersc; /* score of whole sequence */ double motherp; /* P-value of whole sequence */ char *name; /* name of the database seq */ char *desc; /* description of database seq */ int sqfrom; /* start position in seq (1..N) */ int sqto; /* end position in seq (1..N) */ int sqlen; /* length of sequence (N) */ int hmmfrom; /* start position in HMM (1..M) */ int hmmto; /* end position in HMM (1..M) */ int hmmlen; /* length of HMM (M) */ int domidx; /* index of this domain */ int ndom; /* total # of domains in this seq */ struct fancyali_s *ali; /* ptr to optional alignment info */ }; /* Structure: tophit_s * * Array of high scoring hits, suitable for efficient sorting * when we prepare to output results. "hit" list is NULL and * unavailable until after we do a sort. */ struct tophit_s { struct hit_s **hit; /* array of ptrs to top scoring hits */ struct hit_s *unsrt; /* unsorted array */ int alloc; /* current allocation size */ int num; /* number of hits in list now */ int lump; /* allocation lumpsize */ }; /********************************************************** * Plan 9: obsolete HMMER1.x code. We still need these structures * for reading old HMM files (e.g. reverse compatibility) **********************************************************/ /* We define a "basic" state, which covers the basic match, insert, and * delete states from the Haussler paper. Numbers are stored as * pre-calculated negative logs. */ struct basic_state { float t[3]; /* state transitions to +1 M, +0 I, +1 D */ float p[MAXABET]; /* symbol emission probabilities */ }; /* A complete hidden Markov model */ struct plan9_s { int M; /* length of the model */ struct basic_state *ins; /* insert states 0..M+1 */ struct basic_state *mat; /* match 0..M+1; 0 = BEGIN, M+1 = END */ struct basic_state *del; /* delete 0..M+1 */ float null[MAXABET]; /* the *suggested* null model */ /* Optional annotation on the HMM, taken from alignment */ char *name; /* a name for the HMM */ char *ref; /* reference coords and annotation */ char *cs; /* consensus structure annotation */ float *xray; /* Structural annotation: xray[0..M+1][NINPUTS], indexed manually */ int flags; /* flags for what optional info is in HMM */ }; /* Flags for optional info in an HMM structure */ #define HMM_REF (1<<0) #define HMM_CS (1<<1) #define HMM_XRAY (1<<2) #define MATCH 0 #define INSERT 1 #define DELETE 2 #define BEGIN MATCH #define END MATCH #endif /* STRUCTSH_INCLUDED */ wise-2.4.1/src/HMMer2/emulation.c0000644000175000001440000002200007313404524016027 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Sean R. Eddy * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* emulation.c * SRE, Wed Jan 21 07:50:01 1998 * * Interfaces between HMMER and other software packages. * * RCS $Id: emulation.c,v 1.1.1.1 2001/06/18 13:59:48 birney Exp $ */ #include #include #include "squid.h" #include "config.h" #include "structs.h" #include "funcs.h" #include "version.h" /* Function: WriteProfile() * Date: SRE, Wed Jan 21 07:58:09 1998 [St. Louis] * * Purpose: Given an HMM, write a GCG profile .prf file as * output. Based on examination of Michael Gribskov's Fortran * source in GCG 9.1; on reverse engineering * by examination of GCG 9.1 output from "profilemake" * and how the .prf file is used by "profilesearch"; * and on the GCG 9.0 documentation. * * See notes 28 Jan 98 for detail; in brief, the conversion goes like: * * PROF(i,k) = match score = msc(i,k) + TMM(k-1) * * GAP(k) = cost per insertion = TMI(k-1) + TIM(k-1) - TMM(k-1) - TII(k-1) * LEN(k) = cost per inserted x = TII(k-1) * * QGAP(k) = cost per deletion = TDM(k-1) + TMD(unknown) - TMM(k-1) - TDD(k-1) * QLEN(k) = cost per deleted k = TDD(k-1) * * Note that GCG affine gaps are GAP + n * LEN; * HMMER affine gaps count (n-1) * gap-extend, thus an * extra TII gets taken away from GAP (and TDD from QGAP), * since GCG will charge it. * * Also note how the TMM transitions, which have no equivalent * in a profile, get smuggled in OK. * * Also note that GCG charges gaps using the profile position * /after/ the gap, not preceding the gap as HMMER does. * * Also note the TMD(unknown) in the QGAP calculation. HMMER * distinguishes between gap-open and gap-close, but GCG does not, * so there is a fundamental incompatibility here. Here * we use an upper (best-scoring, minimum-cost) bound. * * And finally note that GCG's implementation forces GAP=QGAP and * LEN=QLEN. Here, we upper bound again. Compugen's implementation * allows an "extended profile" format which distinguishes between * the two. * * The upper bound approach to these scores means that a * score given by an emulated profile is an upper bound: the HMMER * score (for a single Smith/Waterman style local alignment) * cannot be better than this. This is intentional, so that * the Compugen BIC can be used for rapid prefiltering of * the database. * * To get a close approximation of hmmsw scores, call * profilesearch as * profilesearch -noave -nonor -gap 10 -len 1 * On the Compugen BIC, using extended profiles, you want: * om -model=xsw.model -gapop=10 -gapext=1 -qgapop=10 -qgapext=1 -noave -nonor * * Args: fp - open FILE to write to (or stdout, possibly) * hmm - the HMM to write * do_xsw - TRUE to write Compugen's experimental extended profile format * * Returns: (void) */ void WriteProfile(FILE *fp, struct plan7_s *hmm, int do_xsw) { int k; /* position in model */ int x; /* symbol index */ int sc; /* a score to print */ float nx; /* expected # of symbol x */ int gap, len, qgap, qlen; /* penalties to charge */ P7Logoddsify(hmm, TRUE); /* GCG can't deal with long profiles. Their limit is 1000 * positions. However, Compugen can. Therefore we warn, * but don't die. */ if (hmm->M > 1000 && !do_xsw) Warn("Profile %s will have more than 1000 positions. GCG won't read it; Compugen will.", hmm->name); /* Header information. * GCG will look for sequence type and length of model. * Other than this, nothing is parsed until we get to the * Cons line that has a ".." on it. * Lines that begin with "!" are comments. */ if (Alphabet_type == hmmAMINO) fprintf(fp, "!!AA_PROFILE 1.0\n"); else if (Alphabet_type == hmmNUCLEIC) fprintf(fp, "!!NA_PROFILE 1.0\n"); else Die("No support for profiles with non-biological alphabets"); if (Alphabet_type == hmmAMINO) fprintf(fp, "(Peptide) "); else if (Alphabet_type == hmmNUCLEIC) fprintf(fp, "(Nucleotide) "); fprintf(fp, "HMMCONVERT v%s of: %s Length: %d\n", RELEASE, hmm->name, hmm->M); /* Insert some HMMER-specific commentary */ if (do_xsw) { fprintf(fp, " Profile converted from a profile HMM using HMMER v%s emulation.\n", RELEASE); fprintf(fp, " Compugen XSW extended profile format.\n"); fprintf(fp, " Use -model=xsw.model -nonor -noave -gapop=10 -gapext=1 -qgapop=10 -qgapext=1\n"); fprintf(fp, " with om on the Compugen BIC to get the closest approximation to HMMER bit scores.\n"); fprintf(fp, " WARNING: There is a loss of information in this conversion.\n"); fprintf(fp, " Neither the scores nor even the rank order of hits will be precisely\n"); fprintf(fp, " preserved in a comparison of HMMER hmmsearch to GCG profilesearch.\n"); fprintf(fp, " The profile score is an upper bound on the (single-hit) HMMER score.\n\n"); } else { fprintf(fp, " Profile converted from a profile HMM using HMMER v%s emulation.\n", RELEASE); fprintf(fp, " Use -nonor -noave -gap=10 -len=1 with profilesearch and friends\n"); fprintf(fp, " to get the closest approximation to HMMER bit scores.\n"); fprintf(fp, " WARNING: There is a loss of information in this conversion.\n"); fprintf(fp, " Neither the scores nor even the rank order of hits will be precisely\n"); fprintf(fp, " preserved in a comparison of HMMER hmmsearch to GCG profilesearch.\n"); fprintf(fp, " The profile score is an upper bound on the (single-hit) HMMER score.\n\n"); } /* Do the CONS line, which gives the valid IUPAC symbols and their order */ fprintf(fp, "Cons"); for (x = 0; x < Alphabet_iupac; x++) fprintf(fp, " %c ", Alphabet[x]); if (do_xsw) fprintf(fp, " Gap Len QGap Qlen ..\n"); else fprintf(fp, " Gap Len ..\n"); /* Now, the profile; for each position in the HMM, write a line of profile. */ for (k = 1; k <= hmm->M; k++) { /* GCG adds some indexing as comments */ if ((k-1)%10 == 0 && k > 10) fprintf(fp, "! %d\n", k); /* find consensus residue by max prob */ x = FMax(hmm->mat[k], Alphabet_size); fprintf(fp, " %c ", Alphabet[x]); /* generate emission score profile; * Profiles are scaled by a factor of 100 */ for (x = 0; x < Alphabet_iupac; x++) { sc = hmm->msc[x][k]; if (k < hmm->M) sc += hmm->tsc[k][TMM]; sc = sc * 100 / INTSCALE; fprintf(fp, "%5d ", sc); } /* Generate gap open, gap extend penalties; note we will force profilesearch to weights of 10, 1, and that GCG profile values are percentages of these base penalties, 0..100.*/ /* gap open (insertion)*/ if (k > 1) { gap = -1 * (hmm->tsc[k-1][TMI] + hmm->tsc[k-1][TIM] - hmm->tsc[k-1][TMM] - hmm->tsc[k-1][TII]); gap = gap * 100 / (10.0 * INTSCALE); } else gap = 100; /* doesn't matter because GAP_1 is never used */ /* gap extend (insertion)*/ if (k > 1) { len = -1 * hmm->tsc[k-1][TII]; len = len * 100 / (1.0 * INTSCALE); } else len = 100; /* again, doesn't matter because LEN_1 is never used */ /* gap open (deletion) */ if (k > 1) { qgap = -1 * (hmm->tsc[k-1][TDM] + hmm->tsc[k-1][TMD] - hmm->tsc[k-1][TMM] - hmm->tsc[k-1][TDD]); qgap = qgap * 100 / (10.0 * INTSCALE); } else qgap = 100; /* gap extend (deletion) */ if (k > 1) { qlen = -1 * hmm->tsc[k-1][TDD]; qlen = qlen * 100 / (1.0 * INTSCALE); } else qlen = 100; if (do_xsw) fprintf(fp, "%5d %5d %5d %5d\n", gap, len, qgap, qlen); else fprintf(fp, "%5d %5d\n", gap, len); /* assume insertions >= deletions */ } /* The final line of the profile is a count of the observed * residues in the training sequences. This information is not * available in an HMM, and I'm not sure that GCG ever uses it. * Approximate it by calculating a /very/ rough expectation. */ fprintf(fp, " * "); for (x = 0; x < Alphabet_size; x++) { nx = 0.0; for (k = 1; k <= hmm->M; k++) nx += hmm->mat[k][x]; nx *= hmm->nseq; fprintf(fp, "%5d ", (int) nx); } for (; x < Alphabet_iupac; x++) fprintf(fp, "%5d ", 0); fprintf(fp, "\n"); return; } wise-2.4.1/src/HMMer2/tophits.c0000644000175000001440000002650707313404527015547 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile HMMs * Copyright (C) 1992-1997 Sean R. Eddy * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* tophits.c * * Routines for storing, sorting, displaying high scoring hits * and alignments. * ***************************************************************************** * * main API: * * AllocTophits() - allocation * FreeTophits() - free'ing * RegisterHit() - put information about a hit in the list * GetRankedHit() - recovers information about a hit * FullSortTophits() - sorts the top H hits. * ***************************************************************************** * Brief example of use: * * struct tophit_s *yourhits; // list of hits * struct fancyali_s *ali; // (optional structure) alignment of a hit * * yourhits = AllocTophits(200); * (for every hit in a search) { * if (do_alignments) * ali = Trace2FancyAli(); // You provide a function/structure here * if (score > threshold) * RegisterHit(yourhits, ...) * } * * FullSortTophits(yourhits); // Sort hits by evalue * for (i = 0; i < 100; i++) // Recover hits out in ranked order * { * GetRankedHit(yourhits, i, ...); * // Presumably you'd print here... * } * FreeTophits(yourhits); *************************************************************************** * * Estimated storage per hit: * coords: 16 bytes * scores: 8 bytes * name/desc: 192 bytes * alignment: 1000 bytes total = ~1200 bytes with alignment; * = ~200 bytes without * Designed for: 10^5 hits (20 MB) or 10^4 alignments (10 MB) */ #include #include #include #include "structs.h" #include "funcs.h" /* Function: AllocTophits() * * Purpose: Allocate a struct tophit_s, for maintaining * a list of top-scoring hits in a database search. * * Args: lumpsize - allocation lumpsize * * Return: An allocated struct hit_s. Caller must free. */ struct tophit_s * AllocTophits(int lumpsize) { struct tophit_s *hitlist; hitlist = MallocOrDie (sizeof(struct tophit_s)); hitlist->hit = NULL; hitlist->unsrt = MallocOrDie (lumpsize * sizeof(struct hit_s)); hitlist->alloc = lumpsize; hitlist->num = 0; hitlist->lump = lumpsize; return hitlist; } void GrowTophits(struct tophit_s *h) { h->unsrt = ReallocOrDie(h->unsrt,(h->alloc + h->lump) * sizeof(struct hit_s)); h->alloc += h->lump; } void FreeTophits(struct tophit_s *h) { int pos; for (pos = 0; pos < h->num; pos++) { if (h->unsrt[pos].ali != NULL) FreeFancyAli(h->unsrt[pos].ali); if (h->unsrt[pos].name != NULL) free(h->unsrt[pos].name); if (h->unsrt[pos].desc != NULL) free(h->unsrt[pos].desc); } free(h->unsrt); if (h->hit != NULL) free(h->hit); free(h); } struct fancyali_s * AllocFancyAli(void) { struct fancyali_s *ali; ali = MallocOrDie (sizeof(struct fancyali_s)); ali->rfline = ali->csline = ali->model = ali->mline = ali->aseq = NULL; ali->query = ali->target = NULL; ali->sqfrom = ali->sqto = 0; return ali; } void FreeFancyAli(struct fancyali_s *ali) { if (ali != NULL) { if (ali->rfline != NULL) free(ali->rfline); if (ali->csline != NULL) free(ali->csline); if (ali->model != NULL) free(ali->model); if (ali->mline != NULL) free(ali->mline); if (ali->aseq != NULL) free(ali->aseq); if (ali->query != NULL) free(ali->query); if (ali->target != NULL) free(ali->target); free(ali); } } /* Function: RegisterHit() * * Purpose: Add a new hit to a list of top hits. * * "ali", if provided, is a pointer to allocated memory * for an alignment output structure. * Management is turned over to the top hits structure. * Caller should not free them; they will be free'd by * the FreeTophits() call. * * In contrast, "name" and "desc" are copied, so caller * is still responsible for these. * * Number of args is unwieldy. * * Args: h - active top hit list * key - value to sort by: bigger is better * pvalue - P-value of this hit * score - score of this hit * motherp - P-value of parent whole sequence * mothersc - score of parent whole sequence * name - name of target sequence * desc - description of target sequence * sqfrom - 1..L pos in target seq of start * sqto - 1..L pos; sqfrom > sqto if rev comp * sqlen - length of sequence, L * hmmfrom - 0..M+1 pos in HMM of start * hmmto - 0..M+1 pos in HMM of end * hmmlen - length of HMM, M * domidx - number of this domain * ndom - total # of domains in sequence * ali - optional printable alignment info * * Return: (void) * hitlist is modified and possibly reallocated internally. */ void RegisterHit(struct tophit_s *h, double key, double pvalue, float score, double motherp, float mothersc, char *name, char *desc, int sqfrom, int sqto, int sqlen, int hmmfrom, int hmmto, int hmmlen, int domidx, int ndom, struct fancyali_s *ali) { /* Check to see if list is full and we must realloc. */ if (h->num == h->alloc) GrowTophits(h); h->unsrt[h->num].name = Strdup(name); h->unsrt[h->num].desc = Strdup(desc); h->unsrt[h->num].sortkey = key; h->unsrt[h->num].pvalue = pvalue; h->unsrt[h->num].score = score; h->unsrt[h->num].motherp = motherp; h->unsrt[h->num].mothersc= mothersc; h->unsrt[h->num].sqfrom = sqfrom; h->unsrt[h->num].sqto = sqto; h->unsrt[h->num].sqlen = sqlen; h->unsrt[h->num].hmmfrom = hmmfrom; h->unsrt[h->num].hmmto = hmmto; h->unsrt[h->num].hmmlen = hmmlen; h->unsrt[h->num].domidx = domidx; h->unsrt[h->num].ndom = ndom; h->unsrt[h->num].ali = ali; h->num++; return; } /* Function: GetRankedHit() * Date: SRE, Tue Oct 28 10:06:48 1997 [Newton Institute, Cambridge UK] * * Purpose: Recover the data from the i'th ranked hit. * Any of the data ptrs may be passed as NULL for fields * you don't want. hitlist must have been sorted first. * * name, desc, and ali are returned as pointers, not copies; * don't free them! */ void GetRankedHit(struct tophit_s *h, int rank, double *r_pvalue, float *r_score, double *r_motherp, float *r_mothersc, char **r_name, char **r_desc, int *r_sqfrom, int *r_sqto, int *r_sqlen, int *r_hmmfrom, int *r_hmmto, int *r_hmmlen, int *r_domidx, int *r_ndom, struct fancyali_s **r_ali) { if (r_pvalue != NULL) *r_pvalue = h->hit[rank]->pvalue; if (r_score != NULL) *r_score = h->hit[rank]->score; if (r_motherp != NULL) *r_motherp = h->hit[rank]->motherp; if (r_mothersc!= NULL) *r_mothersc= h->hit[rank]->mothersc; if (r_name != NULL) *r_name = h->hit[rank]->name; if (r_desc != NULL) *r_desc = h->hit[rank]->desc; if (r_sqfrom != NULL) *r_sqfrom = h->hit[rank]->sqfrom; if (r_sqto != NULL) *r_sqto = h->hit[rank]->sqto; if (r_sqlen != NULL) *r_sqlen = h->hit[rank]->sqlen; if (r_hmmfrom != NULL) *r_hmmfrom = h->hit[rank]->hmmfrom; if (r_hmmto != NULL) *r_hmmto = h->hit[rank]->hmmto; if (r_hmmlen != NULL) *r_hmmlen = h->hit[rank]->hmmlen; if (r_domidx != NULL) *r_domidx = h->hit[rank]->domidx; if (r_ndom != NULL) *r_ndom = h->hit[rank]->ndom; if (r_ali != NULL) *r_ali = h->hit[rank]->ali; } /* Function: TophitsMaxName() * * Purpose: Returns the maximum name length in a top hits list; * doesn't need to be sorted yet. */ int TophitsMaxName(struct tophit_s *h) { int i; int len, maxlen; maxlen = 0; for (i = 0; i < h->num; i++) { len = strlen(h->unsrt[i].name); if (len > maxlen) maxlen = len; } return maxlen; } /* Function: FullSortTophits() * * Purpose: Completely sort the top hits list. Calls * qsort() to do the sorting, and uses * hit_comparison() to do the comparison. * * Args: h - top hits structure */ int hit_comparison(const void *vh1, const void *vh2) { /* don't ask. don't change. and, Don't Panic. */ struct hit_s *h1 = *((struct hit_s **) vh1); struct hit_s *h2 = *((struct hit_s **) vh2); if (h1->sortkey < h2->sortkey) return 1; else if (h1->sortkey > h2->sortkey) return -1; else if (h1->sortkey == h2->sortkey) return 0; /*NOTREACHED*/ return 0; } void FullSortTophits(struct tophit_s *h) { int i; /* If we don't have /any/ hits, then don't * bother. */ if (h->num == 0) return; /* Assign the ptrs in h->hit. */ h->hit = MallocOrDie(h->num * sizeof(struct hit_s *)); for (i = 0; i < h->num; i++) h->hit[i] = &(h->unsrt[i]); /* Sort the pointers. Don't bother if we've only got one. */ if (h->num > 1) qsort(h->hit, h->num, sizeof(struct hit_s *), hit_comparison); } /* Function: TophitsReport() * Date: Thu Dec 18 13:19:18 1997 * * Purpose: Generate a printout summarizing how much * memory is used by a tophits structure, * how many hits are stored, and how much * waste there is from not knowing nseqs. * * Args: h - the sorted tophits list * E - the cutoff in Evalue * nseq - the final number of seqs used for Eval * * Return: (void) * Prints information on stdout */ void TophitsReport(struct tophit_s *h, double E, int nseq) { int i; int memused; int x; int n; /* Count up how much memory is used * in the whole list. */ memused = sizeof(struct hit_s) * h->alloc + sizeof(struct tophit_s); for (i = 0; i < h->num; i++) { if (h->unsrt[i].name != NULL) memused += strlen(h->unsrt[i].name) + 1; if (h->unsrt[i].desc != NULL) memused += strlen(h->unsrt[i].desc) + 1; if (h->unsrt[i].ali != NULL) { memused += sizeof(struct fancyali_s); x = 0; if (h->unsrt[i].ali->rfline != NULL) x++; if (h->unsrt[i].ali->csline != NULL) x++; if (h->unsrt[i].ali->model != NULL) x++; if (h->unsrt[i].ali->mline != NULL) x++; if (h->unsrt[i].ali->aseq != NULL) x++; memused += x * (h->unsrt[i].ali->len + 1); if (h->unsrt[i].ali->query != NULL) memused += strlen(h->unsrt[i].ali->query) + 1; if (h->unsrt[i].ali->target != NULL) memused += strlen(h->unsrt[i].ali->target) + 1; } } /* Count how many hits actually satisfy the E cutoff. */ n = 0; for (i = 0; i < h->num; i++) { if (h->hit[i]->pvalue * (double) nseq >= E) break; n++; } /* Format and print a summary */ printf("tophits_s report:\n"); printf(" Total hits: %d\n", h->num); printf(" Satisfying E cutoff: %d\n", n); printf(" Total memory: %dK\n", memused / 1000); } wise-2.4.1/src/HMMer2/masks.c0000644000175000001440000001554707313404526015174 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Sean R. Eddy * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* masks.c * SRE, Tue Nov 18 10:12:28 1997 * * Sequence masking routines: XNU, SEG. * * RCS $Id: masks.c,v 1.1.1.1 2001/06/18 13:59:50 birney Exp $ */ #include #include #include "squid.h" #include "config.h" #include "structs.h" #include "funcs.h" /* The PAM120 score matrix, in HMMER's AMINO_ALPHABET alphabetic order */ static int xpam120[23][23] = { { 3, -3, 0, 0, -4, 1, -3, -1, -2, -3, -2, -1, 1, -1, -3, 1, 1, 0, -7, -4, 1, 0, 0 }, {-3, 9, -7, -7, -6, -4, -4, -3, -7, -7, -6, -5, -4, -7, -4, 0, -3, -3, -8, -1, -4, -6, 0 }, { 0, -7, 5, 3, -7, 0, 0, -3, -1, -5, -4, 2, -3, 1, -3, 0, -1, -3, -8, -5, 5, 3, 0 }, { 0, -7, 3, 5, -7, -1, -1, -3, -1, -4, -3, 1, -2, 2, -3, -1, -2, -3, -8, -5, 3, 5, 0 }, {-4, -6, -7, -7, 8, -5, -3, 0, -7, 0, -1, -4, -5, -6, -5, -3, -4, -3, -1, 4, -4, -5, 0 }, { 1, -4, 0, -1, -5, 5, -4, -4, -3, -5, -4, 0, -2, -3, -4, 1, -1, -2, -8, -6, 1, -1, 0 }, {-3, -4, 0, -1, -3, -4, 7, -4, -2, -3, -4, 2, -1, 3, 1, -2, -3, -3, -3, -1, 2, 2, 0 }, {-1, -3, -3, -3, 0, -4, -4, 6, -3, 1, 1, -2, -3, -3, -2, -2, 0, 3, -6, -2, -2, -2, 0 }, {-2, -7, -1, -1, -7, -3, -2, -3, 5, -4, 0, 1, -2, 0, 2, -1, -1, -4, -5, -5, 1, 0, 0 }, {-3, -7, -5, -4, 0, -5, -3, 1, -4, 5, 3, -4, -3, -2, -4, -4, -3, 1, -3, -2, -3, -2, 0 }, {-2, -6, -4, -3, -1, -4, -4, 1, 0, 3, 8, -3, -3, -1, -1, -2, -1, 1, -6, -4, -3, -1, 0 }, {-1, -5, 2, 1, -4, 0, 2, -2, 1, -4, -3, 4, -2, 0, -1, 1, 0, -3, -4, -2, 4, 1, 0 }, { 1, -4, -3, -2, -5, -2, -1, -3, -2, -3, -3, -2, 6, 0, -1, 1, -1, -2, -7, -6, -1, 0, 0 }, {-1, -7, 1, 2, -6, -3, 3, -3, 0, -2, -1, 0, 0, 6, 1, -2, -2, -3, -6, -5, 1, 5, 0 }, {-3, -4, -3, -3, -5, -4, 1, -2, 2, -4, -1, -1, -1, 1, 6, -1, -2, -3, 1, -5, -1, 0, 0 }, { 1, 0, 0, -1, -3, 1, -2, -2, -1, -4, -2, 1, 1, -2, -1, 3, 2, -2, -2, -3, 1, 0, 0 }, { 1, -3, -1, -2, -4, -1, -3, 0, -1, -3, -1, 0, -1, -2, -2, 2, 4, 0, -6, -3, 1, -1, 0 }, { 0, -3, -3, -3, -3, -2, -3, 3, -4, 1, 1, -3, -2, -3, -3, -2, 0, 5, -8, -3, -2, -2, 0 }, {-7, -8, -8, -8, -1, -8, -3, -6, -5, -3, -6, -4, -7, -6, 1, -2, -6, -8, 12, -2, -5, -6, 0 }, {-4, -1, -5, -5, 4, -6, -1, -2, -5, -2, -4, -2, -6, -5, -5, -3, -3, -3, -2, 8, -2, -4, 0 }, { 1, -4, 5, 3, -4, 1, 2, -2, 1, -3, -3, 4, -1, 1, -1, 1, 1, -2, -5, -2, 6, 4, 0 }, { 0, -6, 3, 5, -5, -1, 2, -2, 0, -2, -1, 1, 0, 5, 0, 0, -1, -2, -6, -4, 4, 6, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, }; /* Function: XNU() * Date: 18 Nov 1997 [StL] * * Purpose: x-out of repetitive sequence. XNU tends to be * good at x'ing out short period tandem repeats. * * Note: Apply /only/ to protein sequence. * * Args: dsq: 1..len digitized sequence * len: length of dsq * * Return: number of characters x'ed out. */ int XNU(char *dsq, int len) { int i,k,off,sum,beg,end,top; int topcut,fallcut; double s0; int noff = 4; /* maximum search offset */ int mcut = 1; double pcut = 0.01; int *hit; double lambda = 0.346574; double K = 0.2; double H = 0.664; int xnum = 0; if (len == 0) return 0; hit = MallocOrDie(sizeof(int) * (len+1)); for (i=1; i<=len; i++) hit[i]=0; /* ** Determine the score cutoff so that pcut will be the fraction ** of random sequence eliminated assuming lambda, K, and H are ** characteristic of the database as a whole */ s0 = - log( pcut*H / (noff*K) ) / lambda; if (s0>0) topcut = floor(s0 + log(s0)/lambda + 0.5); else topcut = 0; fallcut = (int)log(K/0.001)/lambda; for (off=mcut; off<=noff; off++) { sum=top=0; beg=off; end=0; for (i=off+1; i<=len; i++) { sum += xpam120[(int) dsq[i]][(int) dsq[i-off]]; if (sum>top) { top=sum; end=i; } if (top>=topcut && top-sum>fallcut) { for (k=beg; k<=end; k++) hit[k] = hit[k-off] = 1; sum=top=0; beg=end=i+1; } else if (top-sum>fallcut) { sum=top=0; beg=end=i+1; } if (sum<0) { beg=end=i+1; sum=top=0; } } if (top>=topcut) { for (k=beg; k<=end; k++) hit[k] = hit[k-off] = 1; } } /* Now mask off detected repeats */ for (i=1; i<=len; i++) if (hit[i]) { xnum++; dsq[i] = Alphabet_iupac-1;} /* e.g. 'X' */ free(hit); return xnum; } /* Function: TraceScoreCorrection() * Date: Sun Dec 21 12:05:47 1997 [StL] * * Purpose: Calculate a correction (in integer log_2 odds) to be * applied to a sequence, using a second null model, * based on a traceback. M/I emissions are corrected; * C/N/J are not -- as if the nonmatching part and * matching part were each generated by the best null model. * The null model is constructed /post hoc/ as the * average over all the M,I distributions used by the trace. * * Return: the log_2-odds score correction. */ float TraceScoreCorrection(struct plan7_s *hmm, struct p7trace_s *tr, char *dsq) { float p[MAXABET]; /* null model distribution */ int sc[MAXCODE]; /* null model scores */ int x; int tpos; int score; /* Set up model: average over the emission distributions of * all M, I states that appear in the trace. Ad hoc? Sure, you betcha. */ FSet(p, Alphabet_size, 0.0); for (tpos = 0; tpos < tr->tlen; tpos++) if (tr->statetype[tpos] == STM) FAdd(p, hmm->mat[tr->nodeidx[tpos]], Alphabet_size); else if (tr->statetype[tpos] == STI) FAdd(p, hmm->ins[tr->nodeidx[tpos]], Alphabet_size); FNorm(p, Alphabet_size); for (x = 0; x < Alphabet_size; x++) sc[x] = Prob2Score(p[x], hmm->null[x]); /* could avoid this chunk if we knew we didn't need any degenerate char scores */ for (x = Alphabet_size; x < Alphabet_iupac; x++) sc[x] = DegenerateSymbolScore(p, hmm->null, x); /* Score all the M,I state emissions that appear in the trace. */ score = 0; for (tpos = 0; tpos < tr->tlen; tpos++) if (tr->statetype[tpos] == STM || tr->statetype[tpos] == STI) score += sc[(int) dsq[tr->pos[tpos]]]; /* Apply an ad hoc 8 bit fudge factor penalty; * interpreted as a prior, saying that the second null model is * 1/2^8 (1/256) as likely as the standard null model */ score -= 8 * INTSCALE; /* Return the correction to the bit score. */ return Scorify(ILogsum(0, score)); } wise-2.4.1/src/HMMer2/squid.h0000644000175000001440000003636507313404527015212 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ #ifndef SQUIDH_INCLUDED #define SQUIDH_INCLUDED /* squid.h * last modified Sun Aug 15 12:05:58 1993 * * Header file for my library of sequence functions. * */ #include #include #include #include /* only for ntohl() and friends. */ #include /* only for ntohl() and friends. */ /* Library version info is made available as a global to * any interested program. These are defined in iupac.c * with the other globals. */ extern char squid_version[]; /* version number */ extern char squid_date[]; /* date of release */ extern int squid_errno; /* error codes */ /**************************************************** * Error codes returned by squid library functions (squid_errno) ****************************************************/ #define SQERR_OK 0 /* no error */ #define SQERR_UNKNOWN 1 /* generic error, unidentified */ #define SQERR_NODATA 2 /* unexpectedly NULL stream */ #define SQERR_MEM 3 /* malloc or realloc failed */ #define SQERR_NOFILE 4 /* file not found */ #define SQERR_FORMAT 5 /* file format not recognized */ #define SQERR_PARAMETER 6 /* bad parameter passed to func */ #define SQERR_DIVZERO 7 /* error in sre_math.c */ /**************************************************** * Single sequence information ****************************************************/ #define SQINFO_NAMELEN 64 #define SQINFO_DESCLEN 128 struct seqinfo_s { int flags; /* what extra data are available */ char name[SQINFO_NAMELEN];/* up to 63 characters of name */ char id[SQINFO_NAMELEN]; /* up to 63 char of database identifier */ char acc[SQINFO_NAMELEN]; /* up to 63 char of database accession # */ char desc[SQINFO_DESCLEN];/* up to 127 char of description */ int len; /* length of this seq */ int start; /* (1..len) start position on source seq */ int stop; /* (1..len) end position on source seq */ int olen; /* original length of source seq */ int type; /* kRNA, kDNA, kAmino, or kOther */ char *ss; /* 0..len-1 secondary structure string */ char *sa; /* 0..len-1 % side chain surface access. */ }; typedef struct seqinfo_s SQINFO; #define SQINFO_NAME (1 << 0) #define SQINFO_ID (1 << 1) #define SQINFO_ACC (1 << 2) #define SQINFO_DESC (1 << 3) #define SQINFO_START (1 << 4) #define SQINFO_STOP (1 << 5) #define SQINFO_LEN (1 << 6) #define SQINFO_TYPE (1 << 7) #define SQINFO_OLEN (1 << 8) #define SQINFO_SS (1 << 9) #define SQINFO_SA (1 << 10) /**************************************************** * Database indexing (GSI index file format) ****************************************************/ /* A GSI (generic sequence index) file is composed of * recnum + nfiles + 1 records. Each record contains * three fields; key, file number, and disk offset. * Record 0 contains: * [ "GSI" ] [ nfiles ] [ recnum ] * Records 1..nfiles map file names to file numbers, and contain: * [ filename ] [ file number, 1..nfiles ] [ 0 (unused) ] * Records nfiles+1 to recnum+nfiles+1 provide disk offset * and file number indices for every key: * [ key ] [ file number ] [ offset] */ typedef unsigned int sqd_uint32; /* 32 bit integer. */ typedef unsigned short sqd_uint16; /* 16 bit integer. */ struct gsi_s { FILE *gsifp; /* open GSI index file */ sqd_uint16 nfiles; /* number of files = 16 bit int */ sqd_uint32 recnum; /* number of records = 32 bit int */ }; typedef struct gsi_s GSIFILE; #define GSI_KEYSIZE 32 /* keys are 32 bytes long */ #define GSI_RECSIZE 38 /* 32 + 2 + 4 bytes */ /* if ntohl() and friends are not available, you * can slip replacements in by providing sre_ntohl() * functions. (i.e., there is a possible portability problem here.) */ #define sre_ntohl(x) ntohl(x); #define sre_ntohs(x) ntohs(x); /**************************************************** * Sequence alphabet: see also iupac.c ****************************************************/ /* IUPAC symbols defined globally in iupac.c */ struct iupactype { char sym; /* character representation */ char symcomp; /* complement (regular char */ char code; /* my binary rep */ char comp; /* binary encoded complement */ }; extern struct iupactype iupac[]; #define IUPACSYMNUM 17 extern char *stdcode1[]; /* 1-letter amino acid translation code */ extern char *stdcode3[]; /* 3-letter amino acid translation code */ extern float aafq[]; /* amino acid occurrence frequencies */ extern char aa_alphabet[]; /* amino acid alphabet */ extern int aa_index[]; /* convert 0..19 indices to 0..26 */ /* valid symbols in IUPAC code */ #define NUCLEOTIDES "ACGTUNRYMKSWHBVDacgtunrymkswhbvd" #define AMINO_ALPHABET "ACDEFGHIKLMNPQRSTVWY" #define DNA_ALPHABET "ACGT" #define RNA_ALPHABET "ACGU" #define WHITESPACE " \t\n" #define isgap(c) ((c) == ' ' || (c) == '.' || (c) == '_' || (c) == '-') /**************************************************** * Alignment information ****************************************************/ /* Structure: aliinfo_s * * Purpose: Optional information returned from an alignment file. * * flags: always used. Flags for which info is valid/alloced. * * alen: mandatory. Alignments are always flushed right * with gaps so that all aseqs are the same length, alen. * Available for all alignment formats. * * nseq: mandatory. Aligned seqs are indexed 0..nseq-1. * * wgt: 0..nseq-1 vector of sequence weights. Mandatory. * If not explicitly set, weights are initialized to 1.0. * * cs: 0..alen-1, just like the alignment. Contains single-letter * secondary structure codes for consensus structure; "<>^+" * for RNA, "EHL." for protein. May be NULL if unavailable * from seqfile. Only available for SELEX format files. * * rf: 0..alen-1, just like the alignment. rf is an arbitrary string * of characters, used for annotating columns. Blanks are * interpreted as non-canonical columns and anything else is * considered canonical. Only available from SELEX files. * * sqinfo: mandatory. Array of 0..nseq-1 * per-sequence information structures, carrying * name, id, accession, coords. * */ struct aliinfo_s { int flags; /* flags for what info is valid */ int alen; /* length of alignment (columns) */ int nseq; /* number of seqs in alignment */ char au[64]; /* "author" information */ float *wgt; /* sequence weights [0..nseq-1] */ char *cs; /* consensus secondary structure string */ char *rf; /* reference coordinate system */ struct seqinfo_s *sqinfo; /* name, id, coord info for each sequence */ }; typedef struct aliinfo_s AINFO; #define AINFO_AUTH (1 << 0) #define AINFO_CS (1 << 1) #define AINFO_RF (1 << 2) /**************************************************** * Sequence i/o: originally from Don Gilbert's readseq ****************************************************/ /* buffer size for reading in lines from sequence files*/ #define LINEBUFLEN 4096 /* sequence types parsed by Seqtype() */ /* note that these must match hmmAMINO and hmmNUCLEIC in HMMER */ #define kOtherSeq 0 #define kDNA 1 #define kRNA 2 #define kAmino 3 /* Sequence file formats recognized */ #define kUnknown 0 /* format not determinable */ #define kIG 1 #define kGenBank 2 #define kA2M 3 /* aligned FASTA (A2M is UCSC's terminology) */ #define kEMBL 4 #define kGCG 5 #define kStrider 6 #define kPearson 7 #define kZuker 8 #define kIdraw 9 /* idraw-style PostScript (write only) */ #define kSelex 10 /* my flat text alignment format */ #define kMSF 11 /* GCG MSF multiple alignment format */ #define kPIR 12 /* PIR-CODATA format */ #define kRaw 13 /* unformatted, raw sequence (output only) */ #define kSquid 14 /* my sequence database format */ /* 15 was kXPearson, extended Pearson */ #define kGCGdata 16 /* GCG data library format */ #define kClustal 17 /* Clustal V or W multiple alignment format */ #define kMinFormat 1 /* SRE: kUnknown doesn't count */ #define kMaxFormat 17 #define kNumFormats (kMaxFormat + 1) #define kNoformat -1 /* format not tested */ struct ReadSeqVars { FILE *f; char sbuffer[LINEBUFLEN]; /* current line we're working on */ char *seq; SQINFO *sqinfo; /* name, id, etc. */ char *sp; int seqlen; int maxseq; int longline; /* TRUE if last fgets() didn't have a \n */ int dash_equals_n; /* a hack - affects EMBL reading, to deal with Staden experiment files */ int do_gzip; /* TRUE if f is a pipe from gzip -dc */ int do_stdin; /* TRUE if f is stdin */ int format; /* format of seqfile we're reading */ /* The ali_ section of the structure is a hack for sequential access * of multiple alignment files: we read the whole alignment in, * and then copy it one sequence at a time into seq and sqinfo. * It is active if ali_num > 0. Because we keep it in the SQFILE structure, * ReadSeq() and friends are always reentrant for multiple seqfiles. */ char **ali_aseqs; AINFO ali_ainfo; int ali_curridx; /* next index to copy and return [0..ali_num-1]*/ }; typedef struct ReadSeqVars SQFILE; /**************************************************** * Cluster analysis and phylogenetic tree support ****************************************************/ /* struct phylo_s - a phylogenetic tree * * For N sequences, there will generally be an array of 0..N-2 * phylo_s structures representing the nodes of a tree. * [0] is the root. The indexes of left and * right children are somewhat confusing so be careful. The * indexes can have values of 0..2N-2. If they are 0..N-1, they * represent pointers to individual sequences. If they are * >= N, they represent pointers to a phylo_s structure * at (index - N). */ struct phylo_s { int parent; /* index of parent, N..2N-2, or -1 for root */ int left; /* index of one of the branches, 0..2N-2 */ int right; /* index of other branch, 0..2N-2 */ float diff; /* difference score between seqs */ float lblen; /* left branch length */ float rblen; /* right branch length */ char *is_in; /* 0..N-1 flag array, 1 if seq included */ int incnum; /* number of seqs included at this node */ }; /* Strategies for cluster analysis; cluster by mean distance, * minimum distance, or maximum distance. */ enum clust_strategy { CLUSTER_MEAN, CLUSTER_MAX, CLUSTER_MIN }; /**************************************************** * Generic data structure support ****************************************************/ /* a struct intstack_s implements a pushdown stack for storing * single integers. */ struct intstack_s { int data; struct intstack_s *nxt; }; /**************************************************** * Binary nucleotide alphabet support ****************************************************/ /* Binary encoding of the IUPAC code for nucleotides * * four-bit "word", permitting rapid degenerate matching * A C G T/U * 0 0 1 0 */ #define NTA 8 #define NTC 4 #define NTG 2 #define NTT 1 #define NTU 1 #define NTN 15 /* A|C|G|T */ #define NTR 10 /* A|G */ #define NTY 5 /* C|T */ #define NTM 12 /* A|C */ #define NTK 3 /* G|T */ #define NTS 6 /* C|G */ #define NTW 9 /* A|T */ #define NTH 13 /* A|C|T */ #define NTB 7 /* C|G|T */ #define NTV 14 /* A|C|G */ #define NTD 11 /* A|G|T */ #define NTGAP 16 /* GAP */ #define NTEND 0 /* null string terminator */ /* ntmatch(): bitwise comparison of two nuc's * note that it's sensitive to the order; * probe may be degenerate but target should not be */ #define ntmatch(probe, target) ((probe & target) == target) /**************************************************** * Support for a portable, flexible Getopt() ****************************************************/ /* Structure: opt_s * * Structure for declaring options to a main(). */ struct opt_s { char *name; /* name of option, e.g. "--option1" or "-o" */ int single; /* TRUE if a single letter option */ int argtype; /* for typechecking, e.g. sqdARG_INT */ }; /* acceptable argtype's... */ #define sqdARG_NONE 0 /* no argument */ #define sqdARG_INT 1 /* something that atoi() can grok */ #define sqdARG_FLOAT 2 /* something that atof() can grok */ #define sqdARG_CHAR 3 /* require single character or digit */ #define sqdARG_STRING 4 /* anything goes */ /**************************************************** * Support for convenient Perl-y regexp matching * * Strparse() defines and manages these. * sqd_parse[0] contains the substring that matched the pattern. * sqd_parse[1-9] contain substrings matched with ()'s. ****************************************************/ extern char *sqd_parse[10]; /**************************************************** * Miscellaneous macros and defines ****************************************************/ #define CHOOSE(a) ((int) (sre_random() * (a))) /* must declare swapfoo to use SWAP() */ #define SWAP(a,b) {swapfoo = b; b = a; a = swapfoo;} #define Free2DArray(ptr, n) \ { int fooidx;\ if (ptr != NULL) { \ for (fooidx = 0; fooidx < (n); fooidx++) if (ptr[fooidx] != NULL) free(ptr[fooidx]);\ free(ptr);\ } } #define ScalarsEqual(a,b) (fabs((a)-(b)) < 1e-7) #ifndef MIN #define MIN(a,b) ((ab)?a:b) #endif /* For convenience and (one hopes) clarity in boolean tests: */ #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif /* Somewhere, there is a universe in which Unix vendors comply * with the ANSI C standard. Unfortunately, it is not ours: */ #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 #endif #ifndef EXIT_FAILURE #define EXIT_FAILURE 1 #endif #include "sqfuncs.h" /* squid function declarations */ #endif /* SQUIDH_INCLUDED */ wise-2.4.1/src/HMMer2/hmmcalibrate.c0000644000175000001440000002406207313404525016475 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Washington University School of Medicine * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* hmmcalibrate.c * SRE, Fri Oct 31 09:25:21 1997 [St. Louis] * * Score an HMM against random sequence data sets; * set histogram fitting parameters. * * RCS $Id: hmmcalibrate.c,v 1.1.1.1 2001/06/18 13:59:49 birney Exp $ */ #include #include #include #include #include #include #include #include #include "squid.h" #include "config.h" #include "structs.h" #include "funcs.h" #include "version.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif #include "globals.h" static char banner[] = "hmmcalibrate -- calibrate HMM search statistics"; static char usage[] = "\ Usage: hmmcalibrate [-options] \n\ Available options are:\n\ -h : print short usage and version info, then exit\n\ "; static char experts[] = "\ --fixed : fix random sequence length at \n\ --histfile : save histogram(s) to file \n\ --mean : set random seq length mean at [350]\n\ --num : set number of sampled seqs to [5000]\n\ --sd : set random seq length std. dev to [350]\n\ --seed : set random seed to [time()]\n\ "; static struct opt_s OPTIONS[] = { { "-h", TRUE, sqdARG_NONE }, { "--fixed", FALSE, sqdARG_INT }, { "--histfile", FALSE, sqdARG_STRING }, { "--mean", FALSE, sqdARG_FLOAT }, { "--num", FALSE, sqdARG_INT }, { "--sd", FALSE, sqdARG_FLOAT }, { "--seed", FALSE, sqdARG_INT}, }; #define NOPTIONS (sizeof(OPTIONS) / sizeof(struct opt_s)) int main(int argc, char **argv) { char *hmmfile; /* HMM file to open */ char *tmpfile; /* temporary calibrated HMM file */ HMMFILE *hmmfp; /* opened hmm file pointer */ FILE *outfp; /* for writing HMM(s) into tmpfile */ char *mode; /* write mode, "w" or "wb" */ struct plan7_s *hmm; /* the hidden Markov model */ struct histogram_s *hist; /* score histogram */ int idx; /* counter over sequences */ char *seq; /* a random sequence */ char *dsq; /* seq, digitized for alignment */ float randomseq[MAXABET]; /* random sequence model */ float p1; /* random sequence model p1 */ float score; /* score of an alignment */ float max; /* maximum score */ int sqlen; /* length of sampled sequences */ sigset_t blocksigs; /* list of signals to protect from */ int fitok; /* TRUE if the EVD fit went ok */ int nsample; /* number of random seqs to sample */ int seed; /* random number seed */ int fixedlen; /* fixed length, or 0 if unused */ float lenmean; /* mean of length distribution */ float lensd; /* std dev of length distribution */ char *histfile; /* histogram save file */ FILE *hfp; /* open file pointer for histfile */ char *optname; /* name of option found by Getopt() */ char *optarg; /* argument found by Getopt() */ int optind; /* index in argv[] */ #ifdef MEMDEBUG unsigned long histid1, histid2, orig_size, current_size; orig_size = malloc_inuse(&histid1); fprintf(stderr, "[... memory debugging is ON ...]\n"); #endif /*********************************************** * Parse the command line ***********************************************/ nsample = 5000; fixedlen = 0; lenmean = 325.; lensd = 200.; seed = (int) time ((time_t *) NULL); histfile = NULL; while (Getopt(argc, argv, OPTIONS, NOPTIONS, usage, &optind, &optname, &optarg)) { if (strcmp(optname, "--fixed") == 0) fixedlen = atoi(optarg); else if (strcmp(optname, "--histfile") == 0) histfile = optarg; else if (strcmp(optname, "--mean") == 0) lenmean = atof(optarg); else if (strcmp(optname, "--num") == 0) nsample = atoi(optarg); else if (strcmp(optname, "--sd") == 0) lensd = atof(optarg); else if (strcmp(optname, "--seed") == 0) seed = atoi(optarg); else if (strcmp(optname, "-h") == 0) { Banner(stdout, banner); puts(usage); puts(experts); exit(0); } } if (argc - optind != 1) Die("Incorrect number of arguments.\n%s\n", usage); hmmfile = argv[optind++]; sre_srandom(seed); /*********************************************** * Open our i/o file pointers, make sure all is well ***********************************************/ if ((hmmfp = HMMFileOpen(hmmfile, "HMMERDB")) == NULL) Die("failed to open HMM file %s for reading.", hmmfile); /* Generate calibrated HMM(s) in a tmp file in the current * directory. When we're finished, we delete the original * HMM file and rename() this one. That way, the worst * effect of a catastrophic failure should be that we * leave a tmp file lying around, but the original HMM * file remains uncorrupted. tmpnam() doesn't work here, * because it'll put the file in /tmp and we won't * necessarily be able to rename() it from there. */ tmpfile = MallocOrDie(strlen(hmmfile) + 5); strcpy(tmpfile, hmmfile); strcat(tmpfile, ".xxx"); /* could be more inventive here... */ if (FileExists(tmpfile)) Die("temporary file %s already exists; please delete it first", tmpfile); if (hmmfp->is_binary) mode = "wb"; else mode = "w"; if ((outfp = fopen(tmpfile, mode)) == NULL) Die("temporary file %s couldn't be opened for writing", tmpfile); /* histogram file */ if (histfile != NULL) { if ((hfp = fopen(histfile, "w")) == NULL) Die("Failed to open histogram save file %s for writing\n", histfile); } /*********************************************** * Show the banner ***********************************************/ Banner(stdout, banner); printf("HMM file: %s\n", hmmfile); if (fixedlen) printf("Length fixed to: %d\n", fixedlen); else { printf("Length distribution mean: %.0f\n", lenmean); printf("Length distribution s.d.: %.0f\n", lensd); } printf("Number of samples: %d\n", nsample); printf("random seed: %d\n", seed); printf("histogram(s) saved to: %s\n", histfile != NULL ? histfile : "[not saved]"); printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n"); /*********************************************** * Calibrate each model in turn ***********************************************/ while (HMMFileRead(hmmfp, &hmm)) { if (hmm == NULL) Die("HMM file %s may be corrupt or in incorrect format; parse failed", hmmfile); P7Logoddsify(hmm, TRUE); /* we could use the null model in the HMM? */ P7DefaultNullModel(randomseq, &p1); hist = AllocHistogram(-200, 200, 100); max = -FLT_MAX; for (idx = 0; idx < nsample; idx++) { /* choose length of random sequence */ if (fixedlen) sqlen = fixedlen; else do sqlen = (int) Gaussrandom(lenmean, lensd); while (sqlen < 1); seq = RandomSequence(Alphabet, randomseq, Alphabet_size, sqlen); dsq = DigitizeSequence(seq, sqlen); if (P7ViterbiSize(sqlen, hmm->M) <= RAMLIMIT) score = P7Viterbi(dsq, sqlen, hmm, NULL); else score = P7SmallViterbi(dsq, sqlen, hmm, NULL); AddToHistogram(hist, score); if (score > max) max = score; free(dsq); free(seq); } /* Fit an EVD to the observed histogram. * The TRUE left-censors and fits only the right slope of the histogram. * The 9999. is an arbitrary high number that means we won't trim outliers * on the right. */ fitok = ExtremeValueFitHistogram(hist, TRUE, 9999.); /* Set HMM EVD parameters */ if (fitok) { hmm->mu = hist->param[EVD_MU]; hmm->lambda = hist->param[EVD_LAMBDA]; hmm->flags |= PLAN7_STATS; } else printf(" -- fit failed; -n may be set too small?\n"); /* Record command line in comlog */ Plan7ComlogAppend(hmm, argc, argv); /* Save HMM to tmpfile */ if (hmmfp->is_binary) WriteBinHMM(outfp, hmm); else WriteAscHMM(outfp, hmm); /* Output results */ printf("HMM : %s\n", hmm->name); if (fitok) { printf("mu : %12f\n", hmm->mu); printf("lambda : %12f\n", hmm->lambda); } else { printf("mu : [undetermined]\n"); printf("lambda : [undetermined]\n"); } printf("max : %12f\n", max); printf("//\n"); if (histfile != NULL) { fprintf(hfp, "HMM: %s\n", hmm->name); PrintASCIIHistogram(hfp, hist); fprintf(hfp, "//\n"); } FreePlan7(hmm); FreeHistogram(hist); } /* Now, carefully remove original file and replace it * with the tmpfile. Note the protection from signals; * we wouldn't want a user to ctrl-C just as we've deleted * their HMM but before the new one is moved. */ HMMFileClose(hmmfp); if (fclose(outfp) != 0) PANIC; if (sigemptyset(&blocksigs) != 0) PANIC; if (sigaddset(&blocksigs, SIGINT) != 0) PANIC; if (sigprocmask(SIG_BLOCK, &blocksigs, NULL) != 0) PANIC; if (remove(hmmfile) != 0) PANIC; if (rename(tmpfile, hmmfile) != 0) PANIC; if (sigprocmask(SIG_UNBLOCK, &blocksigs, NULL) != 0) PANIC; /*********************************************** * Exit ***********************************************/ free(tmpfile); SqdClean(); #ifdef MEMDEBUG current_size = malloc_size(&histid2); if (current_size != orig_size) malloc_list(2, histid1, histid2); else fprintf(stderr, "[No memory leaks]\n"); #endif return 0; } wise-2.4.1/src/HMMer2/stack.c0000644000175000001440000000441607313404527015155 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* stack.c * SRE, Thu Mar 3 10:08:48 1994 * * Implementation of generic stack structures. */ #include #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /************************************************************ * intstack_s implementation. * * Functions: InitIntStack() - returns ptr to new stack * PushIntStack() - (void) * PopIntStack() - returns 1 on success, 0 if stack empty * FreeIntStack() - returns number of elements free'd, or 0 if * stack was empty. * * Implementation of the pushdown stack for storing single * integers. *************************************************************/ struct intstack_s * InitIntStack(void) { struct intstack_s *stack; if ((stack = (struct intstack_s *) malloc (sizeof(struct intstack_s))) == NULL) Die("Memory allocation failure at %s line %d", __FILE__, __LINE__); stack->nxt = NULL; return stack; } void PushIntStack(struct intstack_s *stack, int data) { struct intstack_s *new; if ((new = (struct intstack_s *) malloc (sizeof(struct intstack_s))) == NULL) Die("Memory allocation failure at %s line %d", __FILE__, __LINE__); new->data = data; new->nxt = stack->nxt; stack->nxt = new; } int PopIntStack(struct intstack_s *stack, int *ret_data) { struct intstack_s *old; if (stack->nxt == NULL) return 0; old = stack->nxt; stack->nxt = old->nxt; *ret_data = old->data; free(old); return 1; } void ReverseIntStack(struct intstack_s *stack) { struct intstack_s *old; struct intstack_s *new; old = stack->nxt; stack->nxt = NULL; while (old != NULL) { new = old; /* remove one from top of old stack */ old = old->nxt; new->nxt = stack->nxt; /* push it onto new stack */ stack->nxt = new; } } int FreeIntStack( struct intstack_s *stack ) { int data; int count = 0; while (PopIntStack(stack, &data)) count++; free(stack); return count; } wise-2.4.1/src/HMMer2/config.h0000644000175000001440000000434707313404524015322 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1997 Sean R. Eddy * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* config.h * * Configurable compile-time parameters in HMMER. */ #ifndef CONFIGH_INCLUDED #define CONFIGH_INCLUDED /* RAMLIMIT determines the point at which we switch from fast, * full dynamic programming to slow, linear-memory divide and conquer * dynamic programming algorithms. It is the minimum amount of available * RAM on the systems the package will run on. It can be overridden * from the Makefile. By default, we assume we have 32 Mb RAM available. */ #ifndef RAMLIMIT #define RAMLIMIT 32 #endif #define INTSCALE 1000.0 /* scaling constant for floats to integer scores */ #define MAXABET 20 /* maximum size of alphabet (4 or 20) */ #define MAXCODE 23 /* maximum degenerate alphabet size (17 or 23) */ #define MAXDCHLET 200 /* maximum # Dirichlet components in mixture prior */ #define NINPUTS 4 /* number of inputs into structural prior */ #define INFTY 987654321 /* infinity for purposes of integer DP cells */ #define NXRAY 4 /* number of structural inputs */ #define LOGSUM_TBL 20000 /* controls precision of Logsum() */ #define ALILENGTH 50 /* length of displayed alignment lines */ /* Debugging levels in HMMER are controlled by conditional preprocessing */ #ifndef DEBUGLEVEL #define DEBUGLEVEL 0 #endif #define DEBUG_NONE 0 /* no debugging output */ #define DEBUG_LIGHT 1 /* turn on most assertions */ #define DEBUG_SOME 2 /* turn on some output; low verbosity */ #define DEBUG_AGGRESSIVE 3 /* turn on all assertions; mild verbosity */ #define DEBUG_LOTS 4 /* turn on most output; moderate/high verbosity */ #define DEBUG_EXTREME 5 /* turn on all output; intolerable verbosity */ #endif /*CONFIGH_INCLUDED*/ wise-2.4.1/src/HMMer2/emit.c0000644000175000001440000001071607313404524015003 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Washington University School of Medicine * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* emit.c * SRE, Sun Mar 8 12:26:58 1998 * RCS $Id: emit.c,v 1.1.1.1 2001/06/18 13:59:48 birney Exp $ * * Generation of sequences/traces from an HMM. */ #include "structs.h" #include "config.h" #include "funcs.h" #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Function: EmitSequence() * Date: SRE, Sun Mar 8 12:28:03 1998 [St. Louis] * * Purpose: Given a model, sample a sequence and/or traceback. * * Args: hmm - the model * ret_dsq - RETURN: generated digitized sequence (pass NULL if unwanted) * ret_L - RETURN: length of generated sequence * ret_tr - RETURN: generated trace (pass NULL if unwanted) * * Returns: void */ void EmitSequence(struct plan7_s *hmm, char **ret_dsq, int *ret_L, struct p7trace_s **ret_tr) { struct p7trace_s *tr; enum p7stype type; /* current state type */ int k; /* current node index */ char *dsq; /* generated sequence, digitized */ int L; /* length of sequence */ int alloc_tlen; /* allocated space for traceback */ int alloc_L; /* allocated space for sequence */ int tpos; /* position in traceback */ int sym; /* a generated symbol index */ float t[4]; /* little array for choosing M transition from */ /* Initialize; allocations */ P7AllocTrace(64, &tr); alloc_tlen = 64; dsq = MallocOrDie(sizeof(char) * 64); alloc_L = 64; TraceSet(tr, 0, STS, 0, 0); TraceSet(tr, 1, STN, 0, 0); dsq[0] = (char) Alphabet_iupac; L = 1; k = 0; type = STN; tpos = 2; while (type != STT) { /* Deal with state transition */ switch (type) { case STB: type = STM; k = FChoose(hmm->begin+1, hmm->M) + 1; break; case STI: type = (FChoose(hmm->t[k]+TIM, 2) == 0) ? STM : STI; if (type == STM) k++; break; case STN: type = (FChoose(hmm->xt[XTN], 2) == LOOP) ? STN : STB; k = 0; break; case STE: type = (FChoose(hmm->xt[XTE], 2) == LOOP) ? STJ : STC; k = 0; break; case STC: type = (FChoose(hmm->xt[XTC], 2) == LOOP) ? STC : STT; k = 0; break; case STJ: type = (FChoose(hmm->xt[XTJ], 2) == LOOP) ? STJ : STB; k = 0; break; case STD: if (k < hmm->M) { type = (FChoose(hmm->t[k]+TDM, 2) == 0) ? STM : STD; k++; } else { type = STE; k = 0; } break; case STM: if (k < hmm->M) { FCopy(t, hmm->t[k], 3); t[3] = hmm->end[k]; switch (FChoose(t,4)) { case 0: k++; type = STM; break; case 1: type = STI; break; case 2: k++; type = STD; break; case 3: k=0; type = STE; break; default: Die("never happens"); } } else { k = 0; type = STE; } break; case STT: case STBOGUS: default: Die("can't happen."); } /* Choose a symbol emission, if necessary */ sym = -1; if (type == STM) sym = FChoose(hmm->mat[k], Alphabet_size); else if (type == STI) sym = FChoose(hmm->ins[k], Alphabet_size); else if ((type == STN && tr->statetype[tpos-1] == STN) || (type == STC && tr->statetype[tpos-1] == STC) || (type == STJ && tr->statetype[tpos-1] == STJ)) sym = FChoose(hmm->null, Alphabet_size); /* Add to the traceback; deal with realloc if necessary */ TraceSet(tr, tpos, type, k, (sym != -1) ? L : 0); tpos++; if (tpos == alloc_tlen) { alloc_tlen += 64; P7ReallocTrace(tr, alloc_tlen); } /* Add to the digitized seq; deal with realloc, if necessary */ if (sym != -1) { dsq[L] = (char) sym; L++; if (L+1 == alloc_L) { /* L+1 leaves room for sentinel byte + \0 */ alloc_L += 64; dsq = ReallocOrDie(dsq, sizeof(char) * alloc_L); } } } /* Finish off the trace */ tr->tlen = tpos; /* Finish off the dsq with sentinel byte and null terminator. * Emitted Sequence length is L-1. */ dsq[L] = (char) Alphabet_iupac; dsq[L+1] = '\0'; L--; /* Return */ if (ret_dsq != NULL) *ret_dsq = dsq; else free(dsq); if (ret_L != NULL) *ret_L = L; if (ret_tr != NULL) *ret_tr = tr; else P7FreeTrace(tr); return; } wise-2.4.1/src/HMMer2/hmmsearch.c0000644000175000001440000004527607313404526016027 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Washington University School of Medicine * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* hmmsearch.c * SRE, Tue Jan 7 17:19:20 1997 * * Search a sequence database with a profile HMM. * RCS $Id: hmmsearch.c,v 1.1.1.1 2001/06/18 13:59:50 birney Exp $ */ #include #include #include #include #include #include "structs.h" /* data structures, macros, #define's */ #include "config.h" /* compile-time configuration constants */ #include "funcs.h" /* function declarations */ #include "globals.h" /* alphabet global variables */ #include "squid.h" /* general sequence analysis library */ #ifdef MEMDEBUG #include "dbmalloc.h" #endif static char banner[] = "hmmsearch - search a sequence database with a profile HMM"; static char usage[] = "\ Usage: hmmsearch [-options] \n\ Available options are:\n\ -h : help; print brief help on version and usage\n\ -A : sets alignment output limit to best domain alignments\n\ -E : sets E value cutoff (globE) to \n\ -T : sets T bit threshold (globT) to \n\ -Z : sets Z (# seqs) for E-value calculation\n\ "; static char experts[] = "\ --domE : sets domain Eval cutoff (2nd threshold) to \n\ --domT : sets domain T bit thresh (2nd threshold) to \n\ --forward : use the full Forward() algorithm instead of Viterbi\n\ --null2 : turn OFF the post hoc second null model\n\ --xnu : turn ON XNU filtering of target protein sequences\n\ "; static struct opt_s OPTIONS[] = { { "-h", TRUE, sqdARG_NONE }, { "-A", TRUE, sqdARG_INT }, { "-E", TRUE, sqdARG_FLOAT}, { "-T", TRUE, sqdARG_FLOAT}, { "-Z", TRUE, sqdARG_INT }, { "--domE", FALSE, sqdARG_FLOAT}, { "--domT", FALSE, sqdARG_FLOAT}, { "--forward", FALSE, sqdARG_NONE }, { "--null2", FALSE, sqdARG_NONE }, { "--xnu", FALSE, sqdARG_NONE }, }; #define NOPTIONS (sizeof(OPTIONS) / sizeof(struct opt_s)) static void record_domains(struct tophit_s *h, struct plan7_s *hmm, char *dsq, SQINFO *sqinfo, struct p7trace_s *tr, double whole_pval, float whole_sc, int do_null2); int main(int argc, char **argv) { char *hmmfile; /* file to read HMM(s) from */ HMMFILE *hmmfp; /* opened hmmfile for reading */ char *seqfile; /* file to read target sequence(s) from */ SQFILE *sqfp; /* opened seqfile for reading */ int format; /* format of seqfile */ char *seq; /* target sequence */ SQINFO sqinfo; /* optional info for seq */ char *dsq; /* digitized target sequence */ int i; struct plan7_s *hmm; /* HMM to search with */ struct histogram_s *histogram;/* histogram of all scores */ struct p7trace_s *tr; /* traceback */ struct fancyali_s *ali; /* displayed alignment info */ struct tophit_s *ghit; /* list of top hits for whole sequences */ struct tophit_s *dhit; /* list of top hits for domains */ float sc; /* score of an HMM search */ double pvalue; /* pvalue of an HMM score */ double evalue; /* evalue of an HMM score */ double motherp; /* pvalue of a whole seq HMM score */ float mothersc; /* score of a whole seq parent of domain */ int sqfrom, sqto; /* coordinates in sequence */ int hmmfrom, hmmto; /* coordinate in HMM */ char *name, *desc; /* hit sequence name and description */ int sqlen; /* length of seq that was hit */ int nseq; /* number of sequences searched */ int Z; /* # of seqs for purposes of E-val calc */ int domidx; /* number of this domain */ int ndom; /* total # of domains in this seq */ int namewidth; /* max width of sequence name */ int Alimit; /* A parameter limiting output alignments */ float globT; /* T parameter: keep only hits > globT bits */ double globE; /* E parameter: keep hits < globE E-value */ float domT; /* T parameter for individual domains */ double domE; /* E parameter for individual domains */ char *optname; /* name of option found by Getopt() */ char *optarg; /* argument found by Getopt() */ int optind; /* index in argv[] */ int do_null2; /* TRUE to adjust scores with null model #2 */ int do_forward; /* TRUE to use Forward() not Viterbi() */ int do_xnu; /* TRUE to filter sequences thru XNU */ #ifdef MEMDEBUG unsigned long histid1, histid2, orig_size, current_size; orig_size = malloc_inuse(&histid1); fprintf(stderr, "[... memory debugging is ON ...]\n"); #endif /*********************************************** * Parse command line ***********************************************/ do_forward = FALSE; do_null2 = TRUE; do_xnu = FALSE; Z = 0; Alimit = INT_MAX; /* no limit on alignment output */ globE = 10.0; /* use a reasonable Eval threshold; */ globT = -FLT_MAX; /* but no bit threshold, */ domT = -FLT_MAX; /* no domain bit threshold, */ domE = FLT_MAX; /* and no domain Eval threshold. */ while (Getopt(argc, argv, OPTIONS, NOPTIONS, usage, &optind, &optname, &optarg)) { if (strcmp(optname, "-A") == 0) Alimit = atoi(optarg); else if (strcmp(optname, "-E") == 0) globE = atof(optarg); else if (strcmp(optname, "-T") == 0) globT = atof(optarg); else if (strcmp(optname, "-Z") == 0) Z = atoi(optarg); else if (strcmp(optname, "--domE") == 0) domE = atof(optarg); else if (strcmp(optname, "--domT") == 0) domT = atof(optarg); else if (strcmp(optname, "--forward") == 0) do_forward = TRUE; else if (strcmp(optname, "--null2") == 0) do_null2 = FALSE; else if (strcmp(optname, "--xnu") == 0) do_xnu = TRUE; else if (strcmp(optname, "-h") == 0) { Banner(stdout, banner); puts(usage); puts(experts); exit(0); } } if (argc - optind != 2) Die("Incorrect number of arguments.\n%s\n", usage); hmmfile = argv[optind++]; seqfile = argv[optind++]; /*********************************************** * Open sequence database (might be in BLASTDB or current directory) ***********************************************/ if (! SeqfileFormat(seqfile, &format, "BLASTDB")) switch (squid_errno) { case SQERR_NOFILE: Die("Sequence file %s could not be opened for reading", seqfile); break; case SQERR_FORMAT: default: Die("Failed to determine format of sequence file %s", seqfile); } if ((sqfp = SeqfileOpen(seqfile, format, "BLASTDB")) == NULL) Die("Failed to open sequence database file %s\n%s\n", seqfile, usage); /*********************************************** * Open HMM file (might be in HMMERDB or current directory). * Read a single HMM from it. (Config HMM, if necessary). ***********************************************/ if ((hmmfp = HMMFileOpen(hmmfile, "HMMERDB")) == NULL) Die("Failed to open HMM file %s\n%s", hmmfile, usage); if (!HMMFileRead(hmmfp, &hmm)) Die("Failed to read any HMMs from %s\n", hmmfile); if (hmm == NULL) Die("HMM file %s corrupt or in incorrect format? Parse failed", hmmfile); P7Logoddsify(hmm, !do_forward); /*********************************************** * Show the banner ***********************************************/ Banner(stdout, banner); printf( "HMM file: %s [%s]\n", hmmfile, hmm->name); printf( "Sequence database: %s\n", seqfile); printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"); /*********************************************** * Search HMM against each sequence ***********************************************/ /* set up structures for storing output */ histogram = AllocHistogram(-200, 200, 100); /* keeps full histogram */ ghit = AllocTophits(200); /* per-seq hits: 200=lumpsize */ dhit = AllocTophits(200); /* domain hits: 200=lumpsize */ nseq = 0; while (ReadSeq(sqfp, format, &seq, &sqinfo)) { /* Silently skip empty sequences, which, God help us, appear * sometimes in wormpep. (AGB bug) */ if (sqinfo.len == 0) continue; nseq++; dsq = DigitizeSequence(seq, sqinfo.len); if (do_xnu) XNU(dsq, sqinfo.len); /* 1. Recover a trace by Viterbi. */ if (P7ViterbiSize(sqinfo.len, hmm->M) <= RAMLIMIT) sc = P7Viterbi(dsq, sqinfo.len, hmm, &tr); else sc = P7SmallViterbi(dsq, sqinfo.len, hmm, &tr); /* 2. If we're using Forward scores, do another DP * to get it; else, we already have a Viterbi score * in sc. */ if (do_forward) sc = P7Forward(dsq, sqinfo.len, hmm, NULL); if (do_null2) sc -= TraceScoreCorrection(hmm, tr, dsq); #if DEBUGLEVEL >= DEBUG_LOTS P7PrintTrace(stdout, tr, hmm, dsq); #endif /* 2. Store score/pvalue for global alignment; will sort on score. * Keep all domains in a significant sequence hit. * We can only make a lower bound estimate of E-value since * we don't know the final value of nseq yet. */ pvalue = PValue(hmm, sc); evalue = Z ? (double) Z * pvalue : (double) nseq * pvalue; if (sc > globT && evalue < globE) { RegisterHit(ghit, sc, pvalue, sc, 0., 0., /* no mother seq */ sqinfo.name, sqinfo.flags & SQINFO_DESC ? sqinfo.desc : NULL, 0,0,0, /* seq positions */ 0,0,0, /* HMM positions */ 0, TraceDomainNumber(tr), /* domain info */ NULL); /* alignment info */ record_domains(dhit, hmm, dsq, &sqinfo, tr, pvalue, sc, do_null2); } AddToHistogram(histogram, sc); FreeSequence(seq, &sqinfo); P7FreeTrace(tr); free(dsq); } /* We're done searching an HMM over the whole sequence database. * Set the theoretical EVD curve in our histogram using * calibration in the HMM, if available. */ if (hmm->flags & PLAN7_STATS) ExtremeValueSetHistogram(histogram, hmm->mu, hmm->lambda, histogram->lowscore, histogram->highscore, 1.0, 0); if (!Z) Z = nseq; /* set Z for good now that we're done. */ /* Now format and report our output */ /* 1. Report overall sequence hits (sorted on E-value) */ printf("\nQuery HMM: %s %s\n", hmm->name, hmm->desc != NULL ? hmm->desc : ""); if (hmm->flags & PLAN7_STATS) printf(" [HMM has been calibrated; E-values are empirical estimates]\n"); else printf(" [No calibration for HMM; E-values are upper bounds]\n"); FullSortTophits(ghit); namewidth = MAX(8, TophitsMaxName(ghit)); printf("\nScores for complete sequences (score includes all domains):\n"); printf("%-*s %-*s %7s %10s %3s\n", namewidth, "Sequence", 52-namewidth, "Description", "Score", "E-value", " N "); printf("%-*s %-*s %7s %10s %3s\n", namewidth, "--------", 52-namewidth, "-----------", "-----", "-------", "---"); for (i = 0; i < ghit->num; i++) { GetRankedHit(ghit, i, &pvalue, &sc, NULL, NULL, &name, &desc, NULL, NULL, NULL, /* sequence positions */ NULL, NULL, NULL, /* HMM positions */ NULL, &ndom, /* domain info */ NULL); /* alignment info */ evalue = pvalue * (double) Z; if (evalue < globE && sc > globT) printf("%-*s %-*.*s %7.1f %10.2g %3d\n", namewidth, name, 52-namewidth, 52-namewidth, desc != NULL ? desc : "", sc, evalue, ndom); else if (evalue >= globE) { if (i > 0) printf("\t[no more scores below E threshold]\n"); break; } else if (sc <= globT) { if (i > 0) printf("\t[no more scores above T threshold]"); break; } } if (i == 0) printf("\t[no hits above thresholds]\n"); /* 2. Report domain hits (also sorted on E-value) */ FullSortTophits(dhit); namewidth = MAX(8, TophitsMaxName(dhit)); printf("\nParsed for domains:\n"); printf("%-*s %7s %5s %5s %5s %5s %7s %8s\n", namewidth, "Sequence", "Domain ", "seq-f", "seq-t", "hmm-f", "hmm-t", "score", "E-value"); printf("%-*s %7s %5s %5s %5s %5s %7s %8s\n", namewidth, "--------", "-------", "-----", "-----", "-----", "-----", "-----", "-------"); for (i = 0; i < dhit->num; i++) { GetRankedHit(dhit, i, &pvalue, &sc, &motherp, &mothersc, &name, NULL, &sqfrom, &sqto, &sqlen, /* seq position info */ &hmmfrom, &hmmto, NULL, /* HMM position info */ &domidx, &ndom, /* domain info */ NULL); /* alignment info */ evalue = pvalue * (double) Z; if (motherp * (double) Z >= globE || mothersc <= globT) continue; else if (evalue < domE && sc > domT) printf("%-*s %3d/%-3d %5d %5d %c%c %5d %5d %c%c %7.1f %8.2g\n", namewidth, name, domidx, ndom, sqfrom, sqto, sqfrom == 1 ? '[' : '.', sqto == sqlen ? ']' : '.', hmmfrom, hmmto, hmmfrom == 1 ? '[':'.', hmmto == hmm->M ? ']' : '.', sc, evalue); else if (evalue >= domE) { if (i > 0) printf("\t[no more scores below domE threshold]\n"); break; } else if (sc <= domT) { if (i > 0) printf("\t[no more scores above domT threshold]\n"); break; } } if (i == 0) printf("\t[no hits above thresholds\n"); /* 3. Alignment output, also by domain. * dhits is already sorted and namewidth is set, from above code. * Number of displayed alignments is limited by Alimit parameter; * also by domE (evalue threshold), domT (score theshold). */ if (Alimit != 0) { printf("\nAlignments of top-scoring domains:\n"); for (i = 0; i < dhit->num; i++) { if (i == Alimit) break; /* limit to Alimit output alignments */ GetRankedHit(dhit, i, &pvalue, &sc, &motherp, &mothersc, &name, NULL, &sqfrom, &sqto, &sqlen, /* seq position info */ &hmmfrom, &hmmto, NULL, /* HMM position info */ &domidx, &ndom, /* domain info */ &ali); /* alignment info */ evalue = pvalue * (double) Z; if (motherp * (double) Z >= globE || mothersc <= globT) continue; else if (evalue < domE && sc > domT) { printf("%s: domain %d of %d, from %d to %d: score %.1f, E = %.2g\n", name, domidx, ndom, sqfrom, sqto, sc, evalue); PrintFancyAli(stdout, ali); } else if (evalue >= domE) { if (i > 0) printf("\t[no more alignments below domE threshold\n"); break; } else if (sc <= domT) { if (i > 0) printf("\t[no more alignments above domT threshold\n"); break; } } if (i == 0) printf("\t[no hits above thresholds\n"); if (i == Alimit) printf("\t[output cut off at A = %d top alignments]\n", Alimit); } /* 4. Histogram output */ printf("\nHistogram of all scores:\n"); PrintASCIIHistogram(stdout, histogram); /* 5. Tophits summaries, while developing... */ printf("\nWhole sequence top hits:\n"); TophitsReport(ghit, globE, nseq); printf("\nDomain top hits:\n"); TophitsReport(dhit, domE, nseq); /*********************************************** * Clean-up and exit. ***********************************************/ FreeHistogram(histogram); HMMFileClose(hmmfp); SeqfileClose(sqfp); FreeTophits(ghit); FreeTophits(dhit); FreePlan7(hmm); SqdClean(); #ifdef MEMDEBUG current_size = malloc_inuse(&histid2); if (current_size != orig_size) malloc_list(2, histid1, histid2); else fprintf(stderr, "[No memory leaks.]\n"); #endif return 0; } /* Function: record_domains() * Date: SRE, Tue Nov 4 11:25:14 1997 [St. Louis] * * Purpose: Decompose a trace, and register scores, P-values, alignments, * etc. for individual domains in a hitlist. * * Args: hmm - the HMM structure * dsq - digitized sequence 1..L * sqinfo - contains name of sequence, etc. * tr - traceback of the whole sequence aligned to HMM * whole_pval - P-value of complete alignment * whole_sc - score of complete alignment (bits) * do_null2 - TRUE to use post hoc null model correction * * Return: (void) */ static void record_domains(struct tophit_s *h, struct plan7_s *hmm, char *dsq, SQINFO *sqinfo, struct p7trace_s *tr, double whole_pval, float whole_sc, int do_null2) { struct p7trace_s **tarr; /* array of per-domain traces */ struct fancyali_s *ali; /* alignment of a domain */ int ntr; /* number of domain traces */ int idx; /* index for traces */ int k1, k2; /* start, stop coord in model */ int i1, i2; /* start, stop in sequence */ float score; double pvalue; TraceDecompose(tr, &tarr, &ntr); if (ntr == 0) Die("TraceDecompose() screwup"); /* "can't happen" (!) */ for (idx = 0; idx < ntr; idx++) { /* Get the score and bounds of the match. */ score = P7TraceScore(hmm, dsq, tarr[idx]); if (do_null2) score -= TraceScoreCorrection(hmm, tarr[idx], dsq); pvalue = PValue(hmm, score); TraceSimpleBounds(tarr[idx], &i1, &i2, &k1, &k2); #if DEBUGLEVEL >= DEBUG_LOTS P7PrintTrace(stdout, tarr[idx], hmm, dsq); #endif /* Record the match. Use score as the sort key. */ ali = CreateFancyAli(tarr[idx], hmm, dsq, sqinfo->name); RegisterHit(h, score, pvalue, score, whole_pval, whole_sc, sqinfo->name, sqinfo->flags & SQINFO_DESC ? sqinfo->desc : NULL, i1,i2, sqinfo->len, k1,k2, hmm->M, idx+1, ntr, ali); } for (idx = 0; idx < ntr; idx++) P7FreeTrace(tarr[idx]); free(tarr); return; } wise-2.4.1/src/HMMer2/file.c0000644000175000001440000001222407313404524014760 0ustar philippusers/* file.c * SRE, Wed Jun 19 11:19:22 1996 * * File operation utilities, dealing with pathnames, directories, * and environment variables. * * The goal is to have these be platform-independent but they * currently are UNIX-specific: i.e. this file is currently POSIX compliant * but it is NOT ANSI C compliant. (The sole offender is getenv().) */ #include #include #include #include "squid.h" #include "sqfuncs.h" /* * VMS: #define DIRSLASH ']' * MacOS: #define DIRSLASH ':' * DOS: #define DIRSLASH '\\' * * The code assumes that '.' is used for file name extensions, * such as "foo.bar". */ #define DIRSLASH '/' /* UNIX directory paths have /foo/bar */ /* Function: FileDirname() * * Purpose: Returns the path from a filename: * "/foo/bar/baz" -> "/foo/bar" * "foo/bar" -> "foo" * "foo" -> "." * "/" -> "/" * i.e. the string will be non-NULL; it will * contain the string up to but not including the * last '/' character; returns "." if * there are no '/' characters, and returns "/" * if the last slash is the first character. * Modeled on Tcl's "file dirname" command. * * Args: file - name of file "/foo/bar/baz". * * Return: ptr to malloc'ed string "/foo/bar". */ char * FileDirname(char *file) { char *dirname; char *lastslash; int len; lastslash = strrchr(file, DIRSLASH); len = (lastslash == NULL) ? 0 : (int) (lastslash - file); dirname = (char *) MallocOrDie (sizeof(char) * (len+2)); if (len > 0) strncpy(dirname, file, len); else if (*file != DIRSLASH) { *dirname = '.'; len = 1; } else { *dirname = DIRSLASH; len = 1; } dirname[len] = '\0'; return dirname; } /* Function: FileTail() * * Purpose: Return everything after the DIRSLASH: * "/foo/bar/baz.1" -> "baz.1" * "foo/bar" -> "bar" * "foo" -> "foo" * "/" -> "" * If noextension is TRUE, removes a trailing ".foo" extension * too. * * Args: file - name of file "/foo/bar/baz.1" * noextension - TRUE to also remove extensions * * Return: ptr to malloc'ed string "baz.1" */ char * FileTail(char *file, int noextension) { char *tail; char *lastslash; char *lastdot; /* remove directory prefix */ lastslash = strrchr(file, DIRSLASH); tail = (char *) MallocOrDie (sizeof(char) * (strlen(file)+1)); if (lastslash == NULL) strcpy(tail, file); else strcpy(tail, lastslash+1); /* remove trailing suffix */ if (noextension) { if ((lastdot = strrchr(tail, '.')) != NULL) *lastdot = '\0'; } return tail; } /* Function: FileConcat() * * Purpose: Concatenate a directory path and a file name, * returning a pointer to a malloc'ed string with the * full filename. */ char * FileConcat(char *dir, char *file) { char *full; full = (char *) MallocOrDie (sizeof(char) * (strlen(dir)+strlen(file)+2)); if (*file == DIRSLASH) strcpy(full, file); /* file = "/foo", ignore directory. */ else sprintf(full, "%s%c%s", dir, DIRSLASH, file); return full; } /* Function: EnvFileOpen() * Date: Sun Feb 12 10:55:29 1995 * * Purpose: Open a file, given a file name and an environment * variable that contains a directory path. Files * are opened read-only. Does not look at current directory * unless "." is explicitly in the path specified by env. * * For instance: * fp = EnvFileOpen("BLOSUM45", "BLASTMAT"); * or: * fp = EnvFileOpen("swiss", "BLASTDB"); * * Environment variables may contain a colon-delimited * list of more than one path; e.g. * setenv BLASTDB /nfs/databases/foo:/nfs/databases/bar * * Args: fname - name of file to open * env - name of environment variable containing path * * Return: FILE * to open file, or NULL on failure -- same as fopen() */ FILE * EnvFileOpen(char *fname, char *env) { FILE *fp; char *path; char *s; /* ptr to indiv element in env list */ char full[1024]; /* constructed file name */ if (env == NULL) return NULL; if ((path = Strdup(getenv(env))) == NULL) return NULL; s = strtok(path, ":"); while (s != NULL) { if (((int) strlen(fname) + (int) strlen(s) + 2) > 1024) { free(path); return NULL; } sprintf(full, "%s%c%s", s, DIRSLASH, fname); if ((fp = fopen(full, "r")) != NULL) break; s = strtok(NULL, ":"); } free(path); return fp; } /* Function: FileExists() * * Purpose: Return TRUE if filename exists. * Testing fopen() is the only possible platform-independent test * I'm aware of. */ int FileExists(char *filename) { FILE *fp; if ((fp = fopen(filename, "r"))) { fclose(fp); return TRUE; } return FALSE; } wise-2.4.1/src/HMMer2/getopt.c0000644000175000001440000001654407313404525015355 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ #include #include #include #include "squid.h" /* Function: Getopt() * * Purpose: Portable command line option parsing with abbreviated * option switches. Replaces UNIX getopt(). Using UNIX getopt() * hinders portability to non-UNIX platforms, and getopt() * is also limited to single letter options. * * Getopt() implements a superset of UNIX getopt(). * All of getopt()'s single-character switch behavior * is emulated, and "--" by itself terminates the options. * Additionally, Getopt() provides extended switches * like "--youroptionhere", and Getopt() type checks * arguments. * * Extended options must start with "--", as in "--option1". * Normal options must start with "-", as in "-o". * Normal options may be concatenated, as in "-a -b" == "-ab". * * See bottom of this .c file after #fdef GETOPT_TESTDRIVER * for an example of calling Getopt(). * * Args: argc - from main(). number of elems in argv. * argv - from main(). argv[0] is the name of the command. * opt - array of opt_s structures, defining option switches * nopts - number of switches in opt * usage - a (possibly long) string to print if usage error. * ret_optind - RETURN: the index in argv[] of the next * valid command-line token. * ret_optname- RETURN: ptr to the name of option switch * seen, or NULL if no option was seen. * ret_optarg - RETURN: ptr to the optional argument, if any; * NULL if option takes no argument. * * Return: 1 if a valid option was parsed. * 0 if no option was found, and command-line parsing is complete. * Die()'s here if an error is detected. */ int Getopt(int argc, char **argv, struct opt_s *opt, int nopts, char *usage, int *ret_optind, char **ret_optname, char **ret_optarg) { int i; int arglen; int nmatch; static int optind = 1; /* init to 1 on first call */ static char *optptr = NULL; /* ptr to next valid switch */ int opti; /* Check to see if we've run out of options. * A '-' by itself is an argument (e.g. "read from stdin") * not an option. */ if (optind >= argc || argv[optind][0] != '-' || strcmp(argv[optind], "-") == 0) { *ret_optind = optind; *ret_optarg = NULL; *ret_optname = NULL; return 0; } /* Check to see if we're being told that this is the end * of the options with the special "--" flag. */ if (strcmp(argv[optind], "--") == 0) { optind++; *ret_optind = optind; *ret_optname = NULL; *ret_optarg = NULL; return 0; } /* We have a real option. Find which one it is. * We handle single letter switches "-o" separately * from full switches "--option", based on the "-" vs. "--" * prefix -- single letter switches can be concatenated * as long as they don't have arguments. */ /* full option */ if (optptr == NULL && strncmp(argv[optind], "--", 2) == 0) { /* Use optptr to parse argument in options of form "--foo=666" */ if ((optptr = strchr(argv[optind], '=')) != NULL) { *optptr = '\0'; optptr++; } arglen = strlen(argv[optind]); nmatch = 0; for (i = 0; i < nopts; i++) if (opt[i].single == FALSE && strncmp(opt[i].name, argv[optind], arglen) == 0) { nmatch++; opti = i; if (arglen == strlen(opt[i].name)) break; /* exact match, stop now */ } if (nmatch > 1 && arglen != strlen(opt[i].name)) Die("Option \"%s\" is ambiguous; please be more specific.\n%s", argv[optind], usage); if (nmatch == 0) Die("No such option \"%s\".\n%s", argv[optind], usage); *ret_optname = opt[opti].name; /* Set the argument, if there is one */ if (opt[opti].argtype != sqdARG_NONE) { if (optptr != NULL) { /* --foo=666 style */ *ret_optarg = optptr; optptr = NULL; optind++; } else if (optind+1 >= argc) Die("Option %s requires an argument\n%s", opt[opti].name, usage); else /* "--foo 666" style */ { *ret_optarg = argv[optind+1]; optind+=2; } } else /* sqdARG_NONE */ { if (optptr != NULL) Die("Option %s does not take an argument\n%s", opt[opti].name, usage); *ret_optarg = NULL; optind++; } } else /* else, a single letter option "-o" */ { /* find the option */ if (optptr == NULL) optptr = argv[optind]+1; for (opti = -1, i = 0; i < nopts; i++) if (opt[i].single == TRUE && *optptr == opt[i].name[1]) { opti = i; break; } if (opti == -1) Die("No such option \"%c\".\n%s", *optptr, usage); *ret_optname = opt[opti].name; /* set the argument, if there is one */ if (opt[opti].argtype != sqdARG_NONE) { if (*(optptr+1) != '\0') /* attached argument */ { *ret_optarg = optptr+1; optind++; } else if (optind+1 < argc) /* unattached argument */ { *ret_optarg = argv[optind+1]; optind+=2; } else Die("Option %s requires an argument\n%s", opt[opti].name, usage); optptr = NULL; /* can't concatenate after an argument */ } else /* sqdARG_NONE */ { *ret_optarg = NULL; if (*(optptr+1) != '\0') /* concatenation */ optptr++; else { optind++; /* move to next field */ optptr = NULL; } } } /* Type check the argument, if there is one */ if (opt[opti].argtype != sqdARG_NONE) { if (opt[opti].argtype == sqdARG_INT && ! IsInt(*ret_optarg)) Die("Option %s requires an integer argument\n%s", opt[opti].name, usage); else if (opt[opti].argtype == sqdARG_FLOAT && ! IsReal(*ret_optarg)) Die("Option %s requires a numerical argument\n%s", opt[opti].name, usage); else if (opt[opti].argtype == sqdARG_CHAR && strlen(*ret_optarg) != 1) Die("Option %s requires a single-character argument\n%s", opt[opti].name, usage); /* sqdARG_STRING is always ok, no type check necessary */ } *ret_optind = optind; return 1; } #ifdef GETOPT_TESTDRIVER /* cc -DGETOPT_TESTDRIVER -L ~/lib/squid.linux/ getopt.c -lsquid */ struct opt_s OPTIONS[] = { { "--test1", FALSE, sqdARG_INT }, { "--test2", FALSE, sqdARG_FLOAT }, { "--test3", FALSE, sqdARG_STRING }, { "--test4", FALSE, sqdARG_CHAR }, { "-a", TRUE, sqdARG_NONE }, { "-b", TRUE, sqdARG_INT }, }; #define NOPTIONS (sizeof(OPTIONS) / sizeof(struct opt_s)) int main(int argc, char **argv) { int optind; char *optarg; char *optname; while (Getopt(argc, argv, OPTIONS, NOPTIONS, "Usage/help here", &optind, &optname, &optarg)) { printf("Option: index: %d name: %s argument: %s\n", optind, optname, optarg); } while (optind < argc) { printf("Argument: index: %d name: %s\n", optind, argv[optind]); optind++; } } #endif /*GETOPT_TESTDRIVER*/ wise-2.4.1/src/HMMer2/hmmbuild.c0000644000175000001440000011306407313404525015647 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Sean R. Eddy * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* hmmbuild.c * SRE, Mon Nov 18 12:41:29 1996 * * main() for HMM construction from an alignment. * RCS $Id: hmmbuild.c,v 1.1.1.1 2001/06/18 13:59:49 birney Exp $ */ #include #include #include #include "structs.h" /* data structures, macros, #define's */ #include "config.h" /* compile-time configuration constants */ #include "funcs.h" /* function declarations */ #include "globals.h" /* alphabet global variables */ #include "squid.h" /* general sequence analysis library */ #ifdef MEMDEBUG #include "dbmalloc.h" #endif static char banner[] = "hmmbuild - build a hidden Markov model from an alignment"; static char usage[] = "\ Usage: hmmbuild [-options] \n\ Available options are:\n\ -h : help; print brief help on version and usage\n\ -n : name; name this HMM \n\ -o : re-save annotated alignment to \n\ -A : append; append this HMM to \n\ -F : force; allow overwriting of \n\ \n\ Alternative search algorithm styles: (default: hmmls domain alignment)\n\ -f : multi-hit local (hmmfs style)\n\ -g : global alignment (hmms style, Needleman/Wunsch)\n\ -s : local alignment (hmmsw style, Smith/Waterman)\n\ "; static char experts[] = "\ Alternative model construction strategies: (default: MAP)\n\ --fast : Krogh/Haussler fast heuristic construction (see --gapmax)\n\ --hand : manual construction (requires SELEX file, #=RF annotation)\n\ \n\ Expert customization of parameters and priors:\n\ --null : read null (random sequence) model from \n\ --pam : heuristic PAM-based prior, using BLAST PAM matrix in \n\ --prior : read Dirichlet prior parameters from \n\ \n\ Alternative sequence weighting strategies: (default: GSC weights)\n\ --wblosum : Henikoff simple filter weights (see --idlevel)\n\ --wgsc : Gerstein/Sonnhammer/Chothia tree weights (default)\n\ --wme : maximum entropy (ME)\n\ --wvoronoi : Sibbald/Argos Voronoi weights\n\ --wnone : don't do any weighting\n\ --noeff : don't use effective sequence number; just use nseq\n\ \n\ Forcing an alphabet: (normally autodetected)\n\ --amino : override autodetection, assert that seqs are protein\n\ --nucleic : override autodetection, assert that seqs are DNA/RNA\n\ \n\ Other expert options:\n\ --archpri : set architecture size prior to {0.85} [0..1]\n\ --binary : save the model in binary format, not ASCII text\n\ --cfile : save count vectors to \n\ --gapmax : max fraction of gaps in mat column {0.50} [0..1]\n\ --idlevel : set frac. id level used by eff. nseq and --wblosum {0.62}\n\ --pamwgt : set weight on PAM-based prior to {20.}[>=0]\n\ --swentry : set S/W aggregate entry prob. to {0.5}\n\ --swexit : set S/W aggregate exit prob. to {0.5}\n\ --verbose : print a lot of boring information\n\ \n"; static struct opt_s OPTIONS[] = { { "-f", TRUE, sqdARG_NONE }, { "-g", TRUE, sqdARG_NONE }, { "-h", TRUE, sqdARG_NONE }, { "-n", TRUE, sqdARG_STRING}, { "-o", TRUE, sqdARG_STRING}, { "-s", TRUE, sqdARG_NONE }, { "-A", TRUE, sqdARG_NONE }, { "-F", TRUE, sqdARG_NONE }, { "--amino", FALSE, sqdARG_NONE }, { "--archpri", FALSE, sqdARG_FLOAT }, { "--binary", FALSE, sqdARG_NONE }, { "--cfile", FALSE, sqdARG_STRING}, { "--fast", FALSE, sqdARG_NONE}, { "--gapmax", FALSE, sqdARG_FLOAT }, { "--hand", FALSE, sqdARG_NONE}, { "--idlevel", FALSE, sqdARG_FLOAT }, { "--noeff", FALSE, sqdARG_NONE }, { "--nucleic", FALSE, sqdARG_NONE }, { "--null", FALSE, sqdARG_STRING }, { "--pam", FALSE, sqdARG_STRING }, { "--pamwgt", FALSE, sqdARG_FLOAT }, { "--prior", FALSE, sqdARG_STRING }, { "--swentry", FALSE, sqdARG_FLOAT }, { "--swexit", FALSE, sqdARG_FLOAT }, { "--verbose", FALSE, sqdARG_NONE }, { "--wgsc", FALSE, sqdARG_NONE }, { "--wblosum", FALSE, sqdARG_NONE }, { "--wme", FALSE, sqdARG_NONE }, { "--wnone", FALSE, sqdARG_NONE }, { "--wvoronoi",FALSE, sqdARG_NONE }, }; #define NOPTIONS (sizeof(OPTIONS) / sizeof(struct opt_s)) static void save_model(struct plan7_s *hmm, char *hmmfile, int do_append, int do_binary); static void print_all_scores(FILE *fp, struct plan7_s *hmm, AINFO *ainfo, char **dsq, int nseq, struct p7trace_s **tr); static void save_countvectors(char *cfile, struct plan7_s *hmm); static void position_average_score(struct plan7_s *hmm, char **seq, float *wgt, int nseq, struct p7trace_s **tr, float *pernode, float *ret_avg); static float frag_trace_score(struct plan7_s *hmm, char *dsq, struct p7trace_s *tr, float *pernode, float expected); static void maximum_entropy(struct plan7_s *hmm, char **dsq, AINFO *ainfo, int nseq, float eff_nseq, struct p7prior_s *prior, struct p7trace_s **tr); int main(int argc, char **argv) { char *seqfile; /* seqfile to read alignment from */ int format; /* format of seqfile */ char **aseq; /* aligned sequences. [0.nseq-1][0.alen-1] */ AINFO ainfo; /* optional info attached to aseq's */ char **dsq; /* digitized unaligned aseq's */ struct plan7_s *hmm; /* constructed HMM; written to hmmfile */ struct p7prior_s *pri; /* Dirichlet priors to use */ struct p7trace_s **tr; /* fake tracebacks for aseq's */ char *hmmfile; /* file to write HMM to */ FILE *fp; /* OUTPUT file handle (misc.) */ char *name; /* name of the HMM */ int idx; /* counter for sequences */ float randomseq[MAXABET]; /* null sequence model */ float p1; /* null sequence model p1 transition */ char *optname; /* name of option found by Getopt() */ char *optarg; /* argument found by Getopt() */ int optind; /* index in argv[] */ enum p7_construction c_strategy; /* construction strategy choice */ enum p7_weight { /* weighting strategy */ WGT_NONE, WGT_GSC, WGT_BLOSUM, WGT_VORONOI, WGT_ME} w_strategy; enum p7_config { /* algorithm configuration strategy */ P7_BASE_CONFIG, P7_LS_CONFIG, P7_FS_CONFIG, P7_SW_CONFIG } cfg_strategy; float gapmax; /* max frac gaps in mat col for -k */ int overwrite_protect; /* TRUE to prevent overwriting HMM file */ int verbose; /* TRUE to show a lot of output */ char *align_ofile; /* name of output alignment file */ char *rndfile; /* random sequence model file to read */ char *prifile; /* Dirichlet prior file to read */ char *pamfile; /* PAM matrix file for heuristic prior */ char *cfile; /* output file for count vectors */ float archpri; /* "architecture" prior on model size */ float pamwgt; /* weight on PAM for heuristic prior */ int do_append; /* TRUE to append to hmmfile */ int do_binary; /* TRUE to write in binary format */ float blosumlevel; /* BLOSUM frac id filtering level [0.62] */ float swentry; /* S/W aggregate entry probability */ float swexit; /* S/W aggregate exit probability */ int do_eff; /* TRUE to set an effective seq number */ float eff_nseq; /* effective sequence number */ #ifdef MEMDEBUG unsigned long histid1, histid2; size_t orig_size, current_size; orig_size = malloc_inuse(&histid1); fprintf(stderr, "[... memory debugging is ON ...]\n"); #endif /*********************************************** * Parse command line ***********************************************/ c_strategy = P7_MAP_CONSTRUCTION; w_strategy = WGT_GSC; blosumlevel = 0.62; cfg_strategy = P7_LS_CONFIG; gapmax = 0.5; overwrite_protect = TRUE; verbose = FALSE; align_ofile = NULL; rndfile = NULL; prifile = NULL; pamfile = NULL; cfile = NULL; archpri = 0.85; pamwgt = 20.; Alphabet_type = hmmNOTSETYET; /* initially unknown */ name = NULL; do_append = FALSE; swentry = 0.5; swexit = 0.5; do_eff = TRUE; do_binary = FALSE; while (Getopt(argc, argv, OPTIONS, NOPTIONS, usage, &optind, &optname, &optarg)) { if (strcmp(optname, "-f") == 0) cfg_strategy = P7_FS_CONFIG; else if (strcmp(optname, "-g") == 0) cfg_strategy = P7_BASE_CONFIG; else if (strcmp(optname, "-n") == 0) name = Strdup(optarg); else if (strcmp(optname, "-o") == 0) align_ofile = optarg; else if (strcmp(optname, "-r") == 0) rndfile = optarg; else if (strcmp(optname, "-s") == 0) cfg_strategy = P7_SW_CONFIG; if (strcmp(optname, "-A") == 0) do_append = TRUE; else if (strcmp(optname, "-F") == 0) overwrite_protect = FALSE; else if (strcmp(optname, "--amino") == 0) SetAlphabet(hmmAMINO); else if (strcmp(optname, "--archpri") == 0) archpri = atof(optarg); else if (strcmp(optname, "--binary") == 0) do_binary = TRUE; else if (strcmp(optname, "--cfile") == 0) cfile = optarg; else if (strcmp(optname, "--fast") == 0) c_strategy = P7_FAST_CONSTRUCTION; else if (strcmp(optname, "--hand") == 0) c_strategy = P7_HAND_CONSTRUCTION; else if (strcmp(optname, "--gapmax") == 0) gapmax = atof(optarg); else if (strcmp(optname, "--idlevel") == 0) blosumlevel = atof(optarg); else if (strcmp(optname, "--noeff") == 0) do_eff = FALSE; else if (strcmp(optname, "--nucleic") == 0) SetAlphabet(hmmNUCLEIC); else if (strcmp(optname, "--pam") == 0) pamfile = optarg; else if (strcmp(optname, "--pamwgt") == 0) pamwgt = atof(optarg); else if (strcmp(optname, "--prior") == 0) prifile = optarg; else if (strcmp(optname, "--swentry") == 0) swentry = atof(optarg); else if (strcmp(optname, "--swexit") == 0) swexit = atof(optarg); else if (strcmp(optname, "--verbose") == 0) verbose = TRUE; else if (strcmp(optname, "--wgsc") == 0) w_strategy = WGT_GSC; else if (strcmp(optname, "--wblosum") == 0) w_strategy = WGT_BLOSUM; else if (strcmp(optname, "--wme") == 0) w_strategy = WGT_ME; else if (strcmp(optname, "--wnone") == 0) w_strategy = WGT_NONE; else if (strcmp(optname, "--wvoronoi")== 0) w_strategy = WGT_VORONOI; else if (strcmp(optname, "-h") == 0) { Banner(stdout, banner); puts(usage); puts(experts); exit(0); } } if (argc - optind != 2) Die("Incorrect number of arguments.\n%s\n", usage); hmmfile = argv[optind++]; seqfile = argv[optind++]; if (gapmax < 0. || gapmax > 1.) Die("--gapmax must be a value from 0 to 1\n%s\n", usage); if (archpri < 0. || archpri > 1.) Die("--archpri must be a value from 0 to 1\n%s\n", usage); if (overwrite_protect && !do_append && FileExists(hmmfile)) Die("HMM file %s already exists. Rename or delete it.", hmmfile); if (overwrite_protect && align_ofile != NULL && FileExists(align_ofile)) Die("Alignment resave file %s exists. Rename or delete it.", align_ofile); /*********************************************** * Get sequence data ***********************************************/ if (! SeqfileFormat(seqfile, &format, NULL)) switch (squid_errno) { case SQERR_NOFILE: Die("Alignment file %s could not be opened for reading", seqfile); /*FALLTHRU*/ /* a white lie to shut lint up */ case SQERR_FORMAT: default: Die("Failed to determine format of alignment file %s", seqfile); } /* read the alignment from file */ if (! ReadAlignment(seqfile, format, &aseq, &ainfo)) Die("Failed to read aligned sequence file %s", seqfile); for (idx = 0; idx < ainfo.nseq; idx++) s2upper(aseq[idx]); /* Set up the alphabet globals */ if (Alphabet_type == 0) DetermineAlphabet(aseq, ainfo.nseq); /* Set up Dirichlet priors */ if (prifile == NULL) pri = P7DefaultPrior(); else pri = P7ReadPrior(prifile); if (pamfile != NULL) PAMPrior(pamfile, pri, pamwgt); /* Set up the null/random seq model */ if (rndfile == NULL) P7DefaultNullModel(randomseq, &p1); else P7ReadNullModel(rndfile, randomseq, &p1); /* Prepare sequences for internal use */ DigitizeAlignment(aseq, &ainfo, &dsq); /* In some respects we treat DNA more crudely... */ if (Alphabet_type == hmmNUCLEIC) { do_eff = FALSE; /* don't do effective seq #; it's calibrated for protein */ } /*********************************************** * Show the banner ***********************************************/ Banner(stdout, banner); printf("Training alignment: %s\n", seqfile); printf("Number of sequences: %d\n", ainfo.nseq); printf("Search algorithm configuration: "); if (cfg_strategy == P7_BASE_CONFIG) puts("Global alignment (hmms)"); else if (cfg_strategy == P7_SW_CONFIG) { puts("Local (hmmsw)"); printf("S/W aggregate entry probability: %.2f\n", swentry); printf("S/W aggregate exit probability: %.2f\n", swexit); } else if (cfg_strategy == P7_LS_CONFIG) puts("Multiple domain (hmmls)"); else if (cfg_strategy == P7_FS_CONFIG) { puts("Multiple local (hmmfs)"); printf("S/W aggregate entry probability: %.2f\n", swentry); printf("S/W aggregate exit probability: %.2f\n", swexit); } printf("Model construction strategy: "); if (c_strategy == P7_HAND_CONSTRUCTION) puts("Manual, from #=RF annotation"); else if (c_strategy==P7_FAST_CONSTRUCTION) printf("Fast/ad hoc (gapmax %.2f)\n", gapmax); else printf("MAP (gapmax hint: %.2f)\n", gapmax); printf("Prior used: %s\n", (prifile == NULL) ? "(default)" : prifile); printf("Prior strategy: "); if (pri->strategy == PRI_DCHLET) puts("Dirichlet"); else if (pri->strategy == PRI_PAM) puts("PAM hack"); if (pri->strategy == PRI_PAM) printf("PAM prior weight: %.1f\n", pamwgt); printf("Sequence weighting method: "); if (w_strategy == WGT_NONE) puts("none"); else if (w_strategy == WGT_GSC) puts("G/S/C tree weights"); else if (w_strategy == WGT_BLOSUM) printf("BLOSUM filter at %.2f id\n", blosumlevel); else if (w_strategy == WGT_VORONOI)puts("Sibbald/Argos Voronoi"); else if (w_strategy == WGT_ME) puts("Maximum entropy"); printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"); /*********************************************** * Build an HMM ***********************************************/ /* Determine the effective sequence number to use (optional) */ eff_nseq = (float) ainfo.nseq; if (do_eff) { float *wgt; printf("%-40s ... ", "Determining effective sequence number"); fflush(stdout); /* protect weights */ wgt = MallocOrDie(sizeof(float) * ainfo.nseq); FCopy(wgt, ainfo.wgt, ainfo.nseq); /* use BlosumWeights for now... */ BlosumWeights(aseq, &ainfo, blosumlevel); eff_nseq = FSum(ainfo.wgt, ainfo.nseq); /* re-install old weights */ FCopy(ainfo.wgt, wgt, ainfo.nseq); free(wgt); printf("done. [%.0f]\n", eff_nseq); } /* Weight the sequences (optional), */ if (w_strategy == WGT_GSC || w_strategy == WGT_BLOSUM || w_strategy == WGT_VORONOI) { printf("%-40s ... ", "Weighting sequences heuristically"); fflush(stdout); } if (w_strategy == WGT_GSC) GSCWeights(aseq, &ainfo); else if (w_strategy == WGT_BLOSUM) BlosumWeights(aseq, &ainfo, blosumlevel); else if (w_strategy == WGT_VORONOI) VoronoiWeights(aseq, &ainfo); if (w_strategy == WGT_GSC || w_strategy == WGT_BLOSUM || w_strategy == WGT_VORONOI) printf("done.\n"); /* Set the effective sequence number (if do_eff is FALSE, eff_nseq * was set to nseq). */ FNorm(ainfo.wgt, ainfo.nseq); FScale(ainfo.wgt, ainfo.nseq, eff_nseq); /* Build a model architecture. * If we're not doing MD or ME, that's all we need to do. * We get an allocated, counts-based HMM back. */ printf("%-40s ... ", "Constructing model architecture"); fflush(stdout); if (c_strategy == P7_FAST_CONSTRUCTION) P7Fastmodelmaker(aseq, dsq, &ainfo, gapmax, &hmm, &tr); else if (c_strategy == P7_HAND_CONSTRUCTION) P7Handmodelmaker(aseq, dsq, &ainfo, &hmm, &tr); else P7Maxmodelmaker(aseq, dsq, &ainfo, gapmax, pri, randomseq, p1, archpri, &hmm, &tr); printf("done.\n"); /* Save the count vectors if asked. Used primarily for * making the data files for training priors. */ if (cfile != NULL) { printf("%-40s ... ", "Saving count vector file"); fflush(stdout); save_countvectors(cfile, hmm); printf("done. [%s]\n", cfile); } /* Record the null model in the HMM; * add prior contributions in pseudocounts and renormalize. */ printf("%-40s ... ", "Converting counts to probabilities"); fflush(stdout); Plan7SetNullModel(hmm, randomseq, p1); P7PriorifyHMM(hmm, pri); printf("done.\n"); /* Model configuration, temporary. * hmmbuild assumes that it's given an alignment of single domains, * and the alignment may contain fragments. So, for the purpose of * scoring the sequences (or, optionally, MD/ME weighting), * configure the model into hmmsw mode. Later we'll * configure the model according to how the user wants to * use it. */ Plan7SWConfig(hmm, 0.5, 0.5); /* Do model-dependent "weighting" strategies. */ if (w_strategy == WGT_ME) { printf("\n%-40s ...\n", "Maximum entropy weighting, iterative"); maximum_entropy(hmm, dsq, &ainfo, ainfo.nseq, eff_nseq, pri, tr); printf("----------------------------------------------\n\n"); } /* Give the model a name; by default, the name of the alignment file * without any filename extension (i.e. "globins.slx" becomes "globins" */ printf("%-40s ... ", "Setting model name, etc."); fflush(stdout); if (name == NULL) name = FileTail(seqfile, TRUE); Plan7SetName(hmm, name); Plan7ComlogAppend(hmm, argc, argv); Plan7SetCtime(hmm); hmm->nseq = ainfo.nseq; printf("done. [%s]\n", name); free(name); /* Print information for the user */ printf("\nConstructed a profile HMM (length %d)\n", hmm->M); PrintPlan7Stats(stdout, hmm, dsq, ainfo.nseq, tr); printf("\n"); /* Configure the model for chosen algorithm */ printf("%-40s ... ", "Finalizing model configuration"); fflush(stdout); switch (cfg_strategy) { case P7_BASE_CONFIG: Plan7GlobalConfig(hmm); break; case P7_SW_CONFIG: Plan7SWConfig(hmm, swentry, swexit); break; case P7_LS_CONFIG: Plan7LSConfig(hmm); break; case P7_FS_CONFIG: Plan7FSConfig(hmm, swentry, swexit); break; default: Die("bogus configuration choice"); } printf("done.\n"); /* Save new HMM to disk: open a file for appending or writing. */ printf("%-40s ... ", "Saving model to file"); fflush(stdout); save_model(hmm, hmmfile, do_append, do_binary); printf("done. [%s]\n", hmmfile); /* the annotated alignment may be resaved */ if (align_ofile != NULL) { char **new_aseq; AINFO new_ainfo; printf("%-40s ... ", "Saving annotated alignment"); fflush(stdout); P7Traces2Alignment(dsq, ainfo.sqinfo, ainfo.wgt, ainfo.nseq, hmm->M, tr, FALSE, &new_aseq, &new_ainfo); if ((fp = fopen(align_ofile, "w")) == NULL) { Warn("Failed to open alignment resave file %s; using stdout instead", align_ofile); fp = stdout; } WriteSELEX(fp, new_aseq, &new_ainfo, 50); if (fp != stdout) fclose(fp); FreeAlignment(new_aseq, &new_ainfo); printf("done. [%s]\n", align_ofile); } /* Verbose output; show scores for each sequence */ if (verbose) print_all_scores(stdout, hmm, &ainfo, dsq, ainfo.nseq, tr); /* Clean up and exit */ for (idx = 0; idx < ainfo.nseq; idx++) P7FreeTrace(tr[idx]); free(tr); FreePlan7(hmm); P7FreePrior(pri); FreeAlignment(aseq, &ainfo); Free2DArray(dsq, ainfo.nseq); SqdClean(); #ifdef MEMDEBUG current_size = malloc_inuse(&histid2); if (current_size != orig_size) { printf("** I have %d bytes still allocated, pal\n", current_size- orig_size); malloc_list(2, histid1, histid2); } else fprintf(stderr, "[No memory leaks.]\n"); #endif return 0; } /* Function: save_model() * * Purpose: Save the new model to a file. * * Args: hmm - model to save * hmmfile - file to save to (if NULL, use stdout) * do_append - TRUE to append to file * do_binary - TRUE to write a binary file * * Return: (void) */ static void save_model(struct plan7_s *hmm, char *hmmfile, int do_append, int do_binary) { FILE *fp; if (hmmfile == NULL) fp = stdout; else if (do_append) { /* check that it looks like an HMM file */ #ifdef REMOVED /* This code induces an unresolved Linux/SGI NFS bug! */ if (FileExists(hmmfile)) { HMMFILE *hmmfp; hmmfp = HMMFileOpen(hmmfile, NULL); if (hmmfp == NULL) { Warn("%s not an HMM file; can't append to it; using stdout instead", hmmfile); fp = stdout; puts(""); /* do a newline before stdout HMM starts */ } else { HMMFileClose(hmmfp); } } #endif if ((fp = fopen(hmmfile, "a")) == NULL) { Warn("hey, where'd your HMM file go? Using stdout instead."); fp = stdout; puts(""); /* do a newline before stdout HMM starts */ } } else { if ((fp = fopen(hmmfile, "w")) == NULL) { Warn("Failed to open HMM save file %s; using stdout instead", hmmfile); fp = stdout; puts(""); /* do a newline before stdout HMM starts */ } } if (do_binary) WriteBinHMM(fp, hmm); else WriteAscHMM(fp, hmm); if (fp != stdout) fclose(fp); return; } /* Function: print_all_scores() * * Purpose: For each training sequence, print its score under * the final model. * * Args: fp - where to print the output (usu. stdout) * hmm - newly constructed HMM, with prob's. * ainfo- info with aseq * dsq - digitized unaligned training sequences. * nseq - number of training sequences * tr - array of tracebacks * * Return: (void) */ static void print_all_scores(FILE *fp, struct plan7_s *hmm, AINFO *ainfo, char **dsq, int nseq, struct p7trace_s **tr) { int idx; /* counter for sequences */ /* make sure model scores are ready */ P7Logoddsify(hmm, TRUE); /* header */ fputs("**\n", fp); fputs("Individual training sequence scores:\n", fp); /* score for each sequence */ for (idx = 0; idx < nseq; idx++) { fprintf(fp, "%7.2f %-12s %s\n", P7TraceScore(hmm, dsq[idx], tr[idx]), ainfo->sqinfo[idx].name, (ainfo->sqinfo[idx].flags & SQINFO_DESC) ? ainfo->sqinfo[idx].desc : ""); P7PrintTrace(fp, tr[idx], hmm, dsq[idx]); } fputs("\n", fp); } /* Function: save_countvectors() * * Purpose: Save emission/transition count vectors to a file. * Used for gathering the data on which to train a * prior (e.g. mixture Dirichlet, etc.) * * The format of the file is one vector per line: * M ...: 20 match emission counts in order AC..WY. * I ...: 20 insert emission counts in order AC..WY. * T ...: 7 transition counts in order TMM, TMI, TMD, * TIM, TII, TDM, TDD. (see structs.h) * * Args: cfile - counts file to make * hmm - counts-based HMM */ static void save_countvectors(char *cfile, struct plan7_s *hmm) { FILE *fp; int k, x; if ((fp = fopen(cfile, "w")) == NULL) Die("failed to open count vector file %s for writing", cfile); /* match emission vectors */ for (k = 1; k <= hmm->M; k++) { fputs("M ", fp); for (x = 0; x < Alphabet_size; x++) fprintf(fp, "%.2f ", hmm->mat[k][x]); fputs("\n", fp); } /* insert emission vectors */ for (k = 1; k < hmm->M; k++) { fputs("I ", fp); for (x = 0; x < Alphabet_size; x++) fprintf(fp, "%.2f ", hmm->ins[k][x]); fputs("\n", fp); } /* transition vectors */ for (k = 1; k < hmm->M; k++) { fputs("T ", fp); for (x = 0; x < 7; x++) fprintf(fp, "%.2f ", hmm->t[k][x]); fputs("\n", fp); } fclose(fp); } /* Function: position_average_score() * Date: Wed Dec 31 09:36:35 1997 [StL] * * Purpose: Calculate scores from tracebacks, keeping them * in a position specific array. The final array * is normalized position-specifically too, according * to how many sequences contributed data to this * position. Used for compensating for sequence * fragments in ME and MD score optimization. * Very much ad hoc. * * Code related to (derived from) TraceScore(). * * Args: hmm - HMM structure, scores valid * dsq - digitized unaligned sequences * wgt - weights on the sequences * nseq - number of sequences * tr - array of nseq tracebacks that aligns each dsq to hmm * pernode - RETURN: [0]1..M array of position-specific avg scores * ret_avg - RETURN: overall average full-length, one-domain score * * Return: 1 on success, 0 on failure. * pernode is malloc'ed [0]1..M by CALLER and filled here. */ static void position_average_score(struct plan7_s *hmm, char **dsq, float *wgt, int nseq, struct p7trace_s **tr, float *pernode, float *ret_avg) { int pos; /* position in seq */ int sym; int tpos; /* position in trace/state sequence */ float *counts; /* counts at each position */ float avg; /* RETURN: average overall */ int k; /* counter for model position */ int idx; /* counter for sequence number */ /* Allocations */ counts = MallocOrDie ((hmm->M+1) * sizeof(float)); FSet(pernode, hmm->M+1, 0.); FSet(counts, hmm->M+1, 0.); /* Loop over traces, accumulate weighted scores per position */ for (idx = 0; idx < nseq; idx++) for (tpos = 0; tpos < tr[idx]->tlen; tpos++) { pos = tr[idx]->pos[tpos]; sym = (int) dsq[idx][tr[idx]->pos[tpos]]; k = tr[idx]->nodeidx[tpos]; /* Counts: how many times did we use this model position 1..M? * (weighted) */ if (tr[idx]->statetype[tpos] == STM || tr[idx]->statetype[tpos] == STD) counts[k] += wgt[idx]; /* Emission scores. */ if (tr[idx]->statetype[tpos] == STM) pernode[k] += wgt[idx] * Scorify(hmm->msc[sym][k]); else if (tr[idx]->statetype[tpos] == STI) pernode[k] += wgt[idx] * Scorify(hmm->isc[sym][k]); /* Transition scores. */ if (tr[idx]->statetype[tpos] == STM || tr[idx]->statetype[tpos] == STD || tr[idx]->statetype[tpos] == STI) pernode[k] += wgt[idx] * Scorify(TransitionScoreLookup(hmm, tr[idx]->statetype[tpos], tr[idx]->nodeidx[tpos], tr[idx]->statetype[tpos+1],tr[idx]->nodeidx[tpos+1])); } /* Divide accumulated scores by accumulated weighted counts */ avg = 0.; for (k = 1; k <= hmm->M; k++) { pernode[k] /= counts[k]; avg += pernode[k]; } free(counts); *ret_avg = avg; return; } /* Function: frag_trace_score() * Date: SRE, Wed Dec 31 10:03:47 1997 [StL] * * Purpose: Allow MD/ME optimization to be used for alignments * that include fragments and multihits -- estimate a full-length * per-domain score. * * * * Return: "corrected" score. */ static float frag_trace_score(struct plan7_s *hmm, char *dsq, struct p7trace_s *tr, float *pernode, float expected) { float sc; /* corrected score */ float fragexp; /* expected score for a trace like this */ int tpos; /* position in trace */ /* get uncorrected score */ sc = P7TraceScore(hmm, dsq, tr); /* calc expected score for trace like this */ fragexp = 0.; for (tpos = 0; tpos < tr->tlen; tpos++) if (tr->statetype[tpos] == STM || tr->statetype[tpos] == STD) fragexp += pernode[tr->nodeidx[tpos]]; /* correct for multihits */ fragexp /= (float) TraceDomainNumber(tr); /* extrapolate to full-length, one-hit score */ sc = sc * expected / fragexp; return sc; } /* Function: maximum_entropy() * Date: SRE, Fri Jan 2 10:56:00 1998 [StL] * * Purpose: Optimizes a model according to maximum entropy weighting. * See Krogh and Mitchison (1995). * * [Actually, we do minimum relative entropy, rather than * maximum entropy. Same thing, though we refer to "ME" * weights and models. The optimization is a steepest * descents minimization of the relative entropy.] * * Expects to be called shortly after a Maxmodelmaker() * or Handmodelmaker(), so that both a new model architecture * (with MAP parameters) and fake tracebacks are available. * * Prints a summary of optimization progress to stdout. * * Args: hmm - model. allocated, set with initial MAP parameters. * dsq - dealigned digitized seqs the model is based on * ainfo - extra info for aseqs * nseq - number of aseqs * eff_nseq- effective sequence number; weights normalize up to this. * prior - prior distributions for parameterizing model * tr - array of fake traces for each sequence * * Return: (void) * hmm changed to an ME HMM * ainfo changed, contains ME weights */ static void maximum_entropy(struct plan7_s *hmm, char **dsq, AINFO *ainfo, int nseq, float eff_nseq, struct p7prior_s *prior, struct p7trace_s **tr) { float *wgt; /* current best set of ME weights */ float *new_wgt; /* new set of ME weights to try */ float *sc; /* log-odds score of each sequence */ float *grad; /* gradient */ float epsilon; /* steepness of descent */ float relative_entropy; /* current best relative entropy */ float new_entropy; /* relative entropy at new weights */ float last_new_entropy; /* last new_entropy we calc'ed */ float use_epsilon; /* current epsilon value in use */ int idx; /* counter over sequences */ int i1, i2; /* counters for iterations */ float converge_criterion; float minw, maxw; /* min, max weight */ int posw, highw; /* number of positive weights */ float mins, maxs, avgs; /* min, max, avg score */ float *pernode; /* expected score per node of HMM */ float expscore; /* expected score of complete HMM */ int max_iter; /* bulletproof against infinite loop bugs */ epsilon = 0.2; /* works fine */ max_iter = 666; /* Allocations */ sc = MallocOrDie (sizeof(float) * nseq); wgt = MallocOrDie (sizeof(float) * nseq); new_wgt = MallocOrDie (sizeof(float) * nseq); grad = MallocOrDie (sizeof(float) * nseq); pernode = MallocOrDie (sizeof(float) * (hmm->M+1)); /* Initialization. Start with all weights == 1.0. * Find relative entropy and gradient. */ Plan7SWConfig(hmm, 0.5, 0.5); P7Logoddsify(hmm, TRUE); FSet(wgt, nseq, 1.0); position_average_score(hmm, dsq, wgt, nseq, tr, pernode, &expscore); for (idx = 0; idx < nseq; idx++) sc[idx] = frag_trace_score(hmm, dsq[idx], tr[idx], pernode, expscore); relative_entropy = FSum(sc, nseq) / (float) nseq; for (idx = 0; idx < nseq; idx++) grad[idx] = relative_entropy - sc[idx]; printf("iter avg-sc min-sc max-sc min-wgt max-wgt +wgt ++wgt rel.ent convergence\n"); printf("---- ------ ------ ------ ------- ------- ---- ----- ------- -----------\n"); mins = maxs = avgs = sc[0]; for (idx = 1; idx < nseq; idx++) { if (sc[idx] < mins) mins = sc[idx]; if (sc[idx] > maxs) maxs = sc[idx]; avgs += sc[idx]; } avgs /= nseq; printf("%4d %6.1f %6.1f %6.1f %7.2f %7.2f %4d %5d %7.2f %8s\n", 0, avgs, mins, maxs, 1.0, 1.0, nseq, 0, relative_entropy, "-"); /* Steepest descents optimization; * iterate until relative entropy converges. */ i1 = 0; while (++i1 < max_iter) { /* Gradient gives us a line of steepest descents. * (Roughly speaking, anyway. We actually have a constraint * that weights are nonnegative and normalized, and the * gradient doesn't take these into account.) * Look along this line, a distance of epsilon * gradient: * if new point is better, accept; if new point is worse, * move back along the line by half the distance and re-evaluate. */ use_epsilon = epsilon; new_entropy = relative_entropy + 1.0; /* just ensure new > old */ i2 = 0; while (new_entropy > relative_entropy && ++i2 < max_iter) { last_new_entropy = new_entropy; /* find a new point in weight space */ for (idx = 0; idx < nseq; idx++) { new_wgt[idx] = wgt[idx] + use_epsilon * grad[idx]; if (new_wgt[idx] < 0.) new_wgt[idx] = 0.0; } FNorm(new_wgt, nseq); FScale(new_wgt, nseq, (float) nseq); /* Make new HMM using these weights */ ZeroPlan7(hmm); for (idx = 0; idx < nseq; idx++) P7TraceCount(hmm, dsq[idx], new_wgt[idx], tr[idx]); P7PriorifyHMM(hmm, prior); /* Evaluate new point */ Plan7SWConfig(hmm, 0.5, 0.5); P7Logoddsify(hmm, TRUE); position_average_score(hmm, dsq, new_wgt, nseq, tr, pernode, &expscore); for (idx = 0; idx < nseq; idx++) sc[idx] = frag_trace_score(hmm, dsq[idx], tr[idx], pernode, expscore); new_entropy = FDot(sc, new_wgt, nseq) / nseq; use_epsilon /= 2.0; /* Failsafe: we're not converging. Set epsilon to zero, * do one more round. */ if (use_epsilon < 1e-6) use_epsilon = 0.0; if (use_epsilon == 0.0) break; /* Failsafe: avoid infinite loops. Sometimes the new entropy converges without ever being better than the previous point, probably as a result of minor roundoff error. */ if (last_new_entropy == new_entropy) break; } if (i2 == max_iter) printf(" -- exceeded maximum iterations; giving up --\n"); /* Evaluate convergence before accepting the new weights; * then, accept the new point and evaluate the gradient there. */ converge_criterion = fabs((relative_entropy-new_entropy)/relative_entropy); relative_entropy = new_entropy; FCopy(wgt, new_wgt, nseq); for (idx = 0; idx < nseq; idx++) grad[idx] = relative_entropy - sc[idx]; /* Print some statistics about this iteration */ mins = maxs = avgs = sc[0]; minw = maxw = wgt[0]; posw = (wgt[0] > 0.0) ? 1 : 0; highw = (wgt[0] > 1.0) ? 1 : 0; for (idx = 1; idx < nseq; idx++) { if (sc[idx] < mins) mins = sc[idx]; if (sc[idx] > maxs) maxs = sc[idx]; if (wgt[idx] < minw) minw = wgt[idx]; if (wgt[idx] > maxw) maxw = wgt[idx]; if (wgt[idx] > 0.0) posw++; if (wgt[idx] > 1.0) highw++; avgs += sc[idx]; } avgs /= nseq; printf("%4d %6.1f %6.1f %6.1f %7.2f %7.2f %4d %5d %7.2f %8.5f\n", i1, avgs, mins, maxs, minw, maxw, posw, highw, relative_entropy, converge_criterion); if (converge_criterion < 1e-5) break; } if (i1 == max_iter) printf(" -- exceeded maximum iterations; giving up --\n"); /* Renormalize weights to sum to eff_nseq, and save. */ FNorm(wgt, nseq); FScale(wgt, nseq, (float) eff_nseq); FCopy(ainfo->wgt, wgt, nseq); /* Make final HMM using these adjusted weights */ ZeroPlan7(hmm); for (idx = 0; idx < nseq; idx++) P7TraceCount(hmm, dsq[idx], wgt[idx], tr[idx]); P7PriorifyHMM(hmm, prior); /* Cleanup and return */ free(pernode); free(new_wgt); free(grad); free(wgt); free(sc); return; } wise-2.4.1/src/HMMer2/interleaved.c0000644000175000001440000003521407313404526016351 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* interleaved.c * I/O of interleaved format multiple alignments. * Modified from selex.c * * Fri Dec 4 17:43:24 1992, SRE: * Reading and writing aligned sequences to/from disk files. * Implements a new, broader specification of SELEX format * and supercedes alignio.c. * * SRE, Tue Nov 9 17:40:50 1993: * major revision. #= special comments and aliinfo_s optional * alignment info support added. Support for #=CS (consensus * secondary structure), #=SS (individual secondary structure), * #=RF (reference coordinate system), #=SQ (per-sequence header info), * and #=AU ("author") added. * * SRE, Mon Jan 30 14:41:49 1995: * #=SA side chain % surface accessibility annotation supported * * SRE, Mon Sep 11 09:20:08 1995 * selex.c generalized and simplified to make interleaved.c * * SELEX format is documented in Docs/formats.tex. **************************************************************************** */ #include #include #include #include #include #include /* SunOS 4.x isn't fully ANSI-compliant. */ #include "squid.h" #ifndef SEEK_SET #include /* indeed, may SunOS rot in hell */ #endif #ifdef MEMDEBUG #include "dbmalloc.h" #endif static void homogenize_gapsym(char *s, char gapsym); static int copy_alignment_line(char *aseq, int apos, int name_rcol, char *buffer, int lcol, int rcol); static char commentsyms[] = "#%"; int IsInterleavedFormat(int format) { if (format == kSelex || format == kClustal || format == kMSF) return 1; return 0; } /* Function: homogenize_gapsym() * * Purpose: Make gap symbols homogeneous. */ static void homogenize_gapsym(char *s, char gapsym) { for (; *s != '\0'; s++) if (isgap(*s)) *s = gapsym; } /* Function: copy_alignment_line() * * Purpose: Given a line from an alignment file, and bounds lcol,rcol * on what part of it may be sequence, save the alignment into * aseq starting at position apos. * * name_rcol is set to the rightmost column this aseqs's name * occupies; if name_rcol >= lcol, we have a special case in * which the name intrudes into the sequence zone. */ static int copy_alignment_line(char *aseq, int apos, int name_rcol, char *buffer, int lcol, int rcol) { char *s1, *s2; int i; s1 = aseq + apos; s2 = buffer; /* be careful that buffer doesn't end before lcol! */ for (i = 0; i < lcol; i++) if (*s2) s2++; for (i = lcol; i <= rcol; i++) { if (*s2 == '\t') { Warn("TAB characters will corrupt an alignment! Please remove them first."); return 0; } if (name_rcol >= i) *s1 = '.'; /* name intrusion: pad left w/ gaps */ else if (*s2 == '\0' || *s2 == '\n') *s1 = '.'; /* short buffer: pad right w/ gaps */ else *s1 = *s2; /* normal: copy buffer into aseq */ s1++; if (*s2) s2++; } return 1; } /* Function: is_blankline() * * Return TRUE if line is all whitespace. */ static int is_blankline(char *buffer) { for (; *buffer != '\0'; buffer++) if (! isspace(*buffer)) return 0; return 1; } /* CLUSTALV and CLUSTALW support * * skip_header(), parse_header(), is_dataline() functions for ClustalV/W * interleaved multiple alignment format. */ static int skip_clustal(FILE *fp) { char buffer[LINEBUFLEN]; do { if (fgets(buffer, LINEBUFLEN, fp) == NULL) { squid_errno = SQERR_FORMAT; return 0; } } while (strncmp(buffer, "CLUSTAL ", 8) != 0 || strstr(buffer, "multiple sequence alignment") == NULL); return 1; } /*ARGSUSED*/ static int parse_clustal(FILE *fp, AINFO *ainfo) { char buffer[LINEBUFLEN]; do { if (fgets(buffer, LINEBUFLEN, fp) == NULL) { squid_errno = SQERR_FORMAT; return 0; } } while (strncmp(buffer, "CLUSTAL ", 8) != 0 || strstr(buffer, "multiple sequence alignment") == NULL); return 1; } static int dataline_clustal(char *buf, char *expected_name) { while (*buf && isspace(*buf)) buf++; if (*buf == '\0' || strchr(commentsyms, *buf) != NULL) return 0; /* blank or comment */ if (expected_name != NULL && strncmp(buf, expected_name, strlen(expected_name) == 0)) return 1; /* matches expected seq name, definitely data */ for (; *buf != '\0'; buf++) { /* Clustal has no coord lines to worry about */ if (*buf == '*' || *buf == '.' || *buf == ':') continue; /* possible consensus line */ if (isalnum(*buf)) return 1; /* name or seq character */ if (*buf != ' ' && isgap(*buf)) return 1; /* possible all-gap line */ } return 0; } /* GCG MSF support * * skip_header(), parse_header(), is_dataline() routines for GCG MSF alignments */ static int skip_MSF(FILE *fp) { char buffer[LINEBUFLEN]; do { if (fgets(buffer, LINEBUFLEN, fp) == NULL) { squid_errno = SQERR_FORMAT; return 0; } } while (strncmp(buffer, "//", 2) != 0); return 1; } static int parse_MSF(FILE *fp, AINFO *ainfo) { char buffer[LINEBUFLEN]; char *sptr; int nseq; /* Get first dividing line. MSF format specifies ints after MSF: and Check: * but we don't make sure of this */ do { if (fgets(buffer, LINEBUFLEN, fp) == NULL) { squid_errno = SQERR_FORMAT; return 0; } } while (strstr(buffer, " MSF: ") == NULL || strstr(buffer, " Check: ") == NULL || strstr(buffer, " ..") == NULL); /* Get names, weights from header */ nseq = 0; /*CONSTCOND*/ while (1) { if (fgets(buffer, LINEBUFLEN, fp) == NULL) { squid_errno = SQERR_FORMAT; return 0; } if (is_blankline(buffer)) continue; if (strncmp(buffer, "//", 2) == 0) break; sptr = strtok(buffer, WHITESPACE); if (sptr == NULL || strcmp(sptr, "Name:") != 0 || strstr(sptr+5, "Weight:") != 0) { squid_errno = SQERR_FORMAT; return 0; } if ((sptr = strtok(NULL, WHITESPACE)) == NULL) {squid_errno=SQERR_FORMAT; return 0; } SetSeqinfoString(&(ainfo->sqinfo[nseq]), sptr, SQINFO_NAME); while (sptr != NULL && strcmp(sptr, "Weight:") != 0) sptr = strtok(NULL, WHITESPACE); if ((sptr = strtok(NULL, WHITESPACE)) == NULL) {squid_errno=SQERR_FORMAT; return 0; } if (! IsReal(sptr)) { squid_errno = SQERR_FORMAT; return 0; } ainfo->wgt[nseq] = atof(sptr); nseq++; } if (nseq != ainfo->nseq) { squid_errno = SQERR_FORMAT; return 0; } return 1; } static int dataline_MSF(char *buf, char *expected_name) { while (*buf && isspace(*buf)) buf++; if (*buf == '\0' || strchr(commentsyms, *buf) != NULL) return 0; /* blank or comment */ if (expected_name != NULL && strncmp(buf, expected_name, strlen(expected_name) == 0)) return 1; /* matches expected seq name, definitely data */ for (; *buf != '\0'; buf++) { /* MSF has coordinate lines to worry about */ if (isspace(*buf)) continue; /* no info from spaces */ if (isalpha(*buf)||isgap(*buf)) return 1; /* has data on it */ } return 0; } /* Function: ReadInterleaved() * * Purpose: Read multiple aligned sequences from the file seqfile. * Store the alignment in aseq, and the associated info * in ainfo. * * Args: seqfile: name of alignment file to read. * skip_header(): routine to skip the header of the file * parse_header(): routine to parse the header of the file * is_dataline(): routine to determine if a line contains data * ret_aseqs: RETURN: 2D array of aligned sequences * ainfo: RETURN: optional alignment information * * Return: Returns 1 on success. Returns 0 on failure and sets * squid_errno to indicate the cause of the failure. */ int ReadInterleaved(char *seqfile, int (*skip_header)(FILE *), int (*parse_header)(FILE *, AINFO *), int (*is_dataline)(char *, char *), char ***ret_aseqs, AINFO *ainfo) { FILE *fp; /* ptr to opened seqfile */ char buffer[LINEBUFLEN]; /* input buffer for lines */ char **aseqs; /* aligned seqs */ int nseq; /* number of seqs read */ int alen; /* width of alignment */ struct block_struc { /** alignment data for a block: */ int lcol; /* furthest left aligned sym */ int rcol; /* furthest right aligned sym */ } *blocks; int blocknum; /* number of blocks */ char *sptr; /* ptr into line during parsing */ int currblock; /* index for blocks */ int idx; /* counter for seqs */ int currlen; int inblock; /* TRUE if in a block of data */ int pos; /* open the file for reading; skip header*/ fp = fopen(seqfile, "r"); if (fp == NULL) { squid_errno = SQERR_NOFILE; return 0; } if (! (*skip_header) (fp)) return 0; /*************************************************** * First pass across file. * Determine # of seqs and width of alignment so we can alloc. ***************************************************/ blocknum = 0; nseq = 0; alen = 0; inblock = FALSE; while (!feof(fp)) { /* allocate for info about this block. */ if (blocknum == 0) blocks = (struct block_struc *) MallocOrDie (sizeof(struct block_struc)); else blocks = (struct block_struc *) ReallocOrDie (blocks, (blocknum+1) * sizeof(struct block_struc)); blocks[blocknum].lcol = LINEBUFLEN+1; blocks[blocknum].rcol = -1; idx = 0; /*CONSTCOND*/ while (1) /* breaks out when blank line or EOF is hit, see below */ { /* get a data line */ do { if (fgets(buffer, LINEBUFLEN, fp) == NULL) goto BREAKOUT; /* end of file */ if (inblock && is_blankline(buffer)) goto BREAKOUT; /* end of block */ } while (! (*is_dataline)(buffer, NULL)); inblock = TRUE; if (blocknum == 0) nseq++; /* count nseq in first block */ idx++; /* count # of seqs in subsequent blocks */ /* get rcol for this block */ for (sptr = buffer + strlen(buffer) - 1; isspace(*sptr); sptr --) ; if (sptr - buffer > blocks[blocknum].rcol) blocks[blocknum].rcol = sptr - buffer; /* get lcol for this block */ if ((sptr = strtok(buffer, WHITESPACE)) == NULL) /* name */ { squid_errno = SQERR_FORMAT; return 0; } if ((sptr = strtok(NULL, WHITESPACE)) == NULL) /* sequence */ { squid_errno = SQERR_FORMAT; return 0; } if (sptr - buffer < blocks[blocknum].lcol) blocks[blocknum].lcol = sptr - buffer; } BREAKOUT: /* end of a block */ if (inblock) { if (idx != nseq) { squid_errno = SQERR_FORMAT; return 0; } alen += blocks[blocknum].rcol - blocks[blocknum].lcol + 1; blocknum++; inblock = FALSE; } } /*************************************************** * Allocations; rewind file for second pass ***************************************************/ AllocAlignment(nseq, alen, &aseqs, ainfo); rewind(fp); /*************************************************** * Parse file header, if any. * Note that we needed to know the number of seqs * before attempting to parse the header, because we * needed to allocate the alignment and assoc. info. ***************************************************/ if (! (*parse_header)(fp, ainfo)) return 0; /*************************************************** * Second pass across file: parse in the names, aseqs. ***************************************************/ currlen = 0; for (currblock = 0 ; currblock < blocknum; currblock++) { for (idx = 0; idx < nseq; idx++) { /* get next data line */ do { if (fgets(buffer, LINEBUFLEN, fp) == NULL) { squid_errno = SQERR_FORMAT; return 0; } } while (! (*is_dataline)(buffer, ainfo->sqinfo[idx].flags & SQINFO_NAME ? ainfo->sqinfo[idx].name : NULL)); /* find right boundary of name */ sptr = buffer; while (*sptr && isspace(*sptr)) sptr++; if (ainfo->sqinfo[idx].flags & SQINFO_NAME) while (*sptr && !isspace(*sptr)) sptr++; else { /* first time we've seen name */ pos = 0; while (*sptr && !isspace(*sptr) && pos < SQINFO_NAMELEN-1) { ainfo->sqinfo[idx].name[pos++] = *sptr; sptr++; } ainfo->sqinfo[idx].name[pos] = '\0'; ainfo->sqinfo[idx].flags |= SQINFO_NAME; } /* parse alignment line */ if (! copy_alignment_line(aseqs[idx], currlen, sptr - buffer, buffer, blocks[currblock].lcol, blocks[currblock].rcol)) { squid_errno = SQERR_FORMAT; return 0; } } currlen += blocks[currblock].rcol - blocks[currblock].lcol + 1; } /* Tidy up. */ for (idx = 0; idx < nseq; idx++) { aseqs[idx][alen] = '\0'; homogenize_gapsym(aseqs[idx], (char) '.'); ainfo->sqinfo[idx].len = DealignedLength(aseqs[idx]); ainfo->sqinfo[idx].flags |= SQINFO_LEN; } MingapAlignment(aseqs, ainfo); /*************************************************** * Garbage collection and return ***************************************************/ fclose(fp); free(blocks); *ret_aseqs = aseqs; return 1; } /* Function: ReadAlignment() * * Purpose: Given a seqfile name and format, hand it off to appropriate * parser. * * Currently, squid can parse alignments from the following * interleaved multiple sequence alignment formats: * MSF (U. of Wisconsin GCG package MSF format) * SELEX (NeXagen/CU Boulder SELEX format) * CLUSTAL (Des Higgins' CLUSTALV and CLUSTALW programs) * and can sequentially read: * FASTA (aka UCSC's "a2m") * * Return: 1 on success; 0 on failure. * Returned data should be freed by caller with FreeAlignment() */ int ReadAlignment(char *seqfile, int format, char ***ret_aseqs, struct aliinfo_s *ret_ainfo) { switch (format) { case kMSF: if (! ReadInterleaved(seqfile, skip_MSF, parse_MSF, dataline_MSF, ret_aseqs, ret_ainfo)) return 0; break; case kSelex: if (! ReadSELEX(seqfile, ret_aseqs, ret_ainfo)) return 0; break; case kClustal: if (! ReadInterleaved(seqfile, skip_clustal, parse_clustal, dataline_clustal, ret_aseqs, ret_ainfo)) return 0; break; case kPearson: ReadAlignedFASTA(seqfile, NULL, ret_aseqs, ret_ainfo); break; default: squid_errno = SQERR_FORMAT; return 0; } return 1; } wise-2.4.1/src/HMMer2/trace.c0000644000175000001440000007241207313404527015147 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Washington University School of Medicine * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* trace.c * SRE, Sat Nov 16 12:34:57 1996 * RCS $Id: trace.c,v 1.1.1.1 2001/06/18 13:59:51 birney Exp $ * * Support for Plan 7 traceback data structure, p7trace_s. */ #include #include #include #include "structs.h" #include "config.h" #include "squid.h" #include "funcs.h" #include "version.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif static void rightjustify(char *s, int n); /* Function: P7AllocTrace(), P7ReallocTrace(), P7FreeTrace() * * Purpose: allocation and freeing of traceback structures */ void P7AllocTrace(int tlen, struct p7trace_s **ret_tr) { struct p7trace_s *tr; tr = (struct p7trace_s *) MallocOrDie (sizeof(struct p7trace_s)); tr->statetype = (enum p7stype *) MallocOrDie (sizeof(enum p7stype) * tlen); tr->nodeidx = (int *) MallocOrDie (sizeof(int) * tlen); tr->pos = (int *) MallocOrDie (sizeof(int) * tlen); *ret_tr = tr; } void P7ReallocTrace(struct p7trace_s *tr, int tlen) { tr->statetype = (enum p7stype *) ReallocOrDie (tr->statetype, tlen * sizeof(enum p7stype)); tr->nodeidx = (int *) ReallocOrDie (tr->nodeidx, tlen * sizeof(int)); tr->pos = (int *) ReallocOrDie (tr->pos, tlen * sizeof(int)); } void P7FreeTrace(struct p7trace_s *tr) { free(tr->pos); free(tr->nodeidx); free(tr->statetype); free(tr); } /* Function: TraceSet() * Date: SRE, Sun Mar 8 12:39:00 1998 [St. Louis] * * Purpose: Convenience function; set values at position tpos * in a trace. * * * Args: tr - trace object to write to * tpos - ptr to position in trace to set * type - statetype e.g. STS, etc. * idx - nodeidx 1..M or 0 * pos - seq position 1..L or 0 * * Returns: void */ void TraceSet(struct p7trace_s *tr, int tpos, enum p7stype type, int idx, int pos) { tr->statetype[tpos] = type; tr->nodeidx[tpos] = idx; tr->pos[tpos] = pos; } /* Function: P7ReverseTrace() * Date: SRE, Mon Aug 25 12:57:29 1997; Denver CO. * * Purpose: Reverse the arrays in a traceback structure. * Tracebacks from Forward() and Viterbi() are * collected backwards, and call this function * when they're done. * * It's possible to reverse the arrays in place * more efficiently; but the realloc/copy strategy * has the advantage of reallocating the trace * into the right size of memory. (Tracebacks * overallocate.) * * Args: tr - the traceback to reverse. tr->tlen must be set. * * Return: (void) * tr is modified. */ void P7ReverseTrace(struct p7trace_s *tr) { enum p7stype *statetype; int *nodeidx; int *pos; int opos, npos; /* Allocate */ statetype = (enum p7stype *) MallocOrDie (sizeof(enum p7stype) * tr->tlen); nodeidx = (int *) MallocOrDie (sizeof(int) * tr->tlen); pos = (int *) MallocOrDie (sizeof(int) * tr->tlen); /* Reverse the trace. */ for (opos = tr->tlen-1, npos = 0; npos < tr->tlen; npos++, opos--) { statetype[npos] = tr->statetype[opos]; nodeidx[npos] = tr->nodeidx[opos]; pos[npos] = tr->pos[opos]; } /* Swap old, new arrays. */ free(tr->statetype); free(tr->nodeidx); free(tr->pos); tr->statetype = statetype; tr->nodeidx = nodeidx; tr->pos = pos; } /* Function: P7TraceCount() * * Purpose: Count a traceback into a count-based HMM structure. * (Usually as part of a model parameter re-estimation.) * * Args: hmm - counts-based HMM * dsq - digitized sequence that traceback aligns to the HMM (1..L) * wt - weight on the sequence * tr - alignment of seq to HMM * * Return: (void) */ void P7TraceCount(struct plan7_s *hmm, char *dsq, float wt, struct p7trace_s *tr) { int tpos; /* position in tr */ int i; /* symbol position in seq */ for (tpos = 0; tpos < tr->tlen; tpos++) { i = tr->pos[tpos]; /* Emission counts. * Don't bother counting null states N,J,C. */ if (tr->statetype[tpos] == STM) P7CountSymbol(hmm->mat[tr->nodeidx[tpos]], dsq[i], wt); else if (tr->statetype[tpos] == STI) P7CountSymbol(hmm->ins[tr->nodeidx[tpos]], dsq[i], wt); /* State transition counts */ switch (tr->statetype[tpos]) { case STS: break; /* don't bother; P=1 */ case STN: switch (tr->statetype[tpos+1]) { case STB: hmm->xt[XTN][MOVE] += wt; break; case STN: hmm->xt[XTN][LOOP] += wt; break; default: Die("illegal state transition %s->%s in traceback", Statetype(tr->statetype[tpos]), Statetype(tr->statetype[tpos+1])); } break; case STB: switch (tr->statetype[tpos+1]) { case STM: hmm->begin[tr->nodeidx[tpos+1]] += wt; break; case STD: hmm->tbd1 += wt; break; default: Die("illegal state transition %s->%s in traceback", Statetype(tr->statetype[tpos]), Statetype(tr->statetype[tpos+1])); } break; case STM: switch (tr->statetype[tpos+1]) { case STM: hmm->t[tr->nodeidx[tpos]][TMM] += wt; break; case STI: hmm->t[tr->nodeidx[tpos]][TMI] += wt; break; case STD: hmm->t[tr->nodeidx[tpos]][TMD] += wt; break; case STE: hmm->end[tr->nodeidx[tpos]] += wt; break; default: Die("illegal state transition %s->%s in traceback", Statetype(tr->statetype[tpos]), Statetype(tr->statetype[tpos+1])); } break; case STI: switch (tr->statetype[tpos+1]) { case STM: hmm->t[tr->nodeidx[tpos]][TIM] += wt; break; case STI: hmm->t[tr->nodeidx[tpos]][TII] += wt; break; default: Die("illegal state transition %s->%s in traceback", Statetype(tr->statetype[tpos]), Statetype(tr->statetype[tpos+1])); } break; case STD: switch (tr->statetype[tpos+1]) { case STM: hmm->t[tr->nodeidx[tpos]][TDM] += wt; break; case STD: hmm->t[tr->nodeidx[tpos]][TDD] += wt; break; case STE: /* ignore; p(D->E) = 1.0 */ break; default: Die("illegal state transition %s->%s in traceback", Statetype(tr->statetype[tpos]), Statetype(tr->statetype[tpos+1])); } break; case STE: switch (tr->statetype[tpos+1]) { case STC: hmm->xt[XTE][MOVE] += wt; break; case STJ: hmm->xt[XTE][LOOP] += wt; break; default: Die("illegal state transition %s->%s in traceback", Statetype(tr->statetype[tpos]), Statetype(tr->statetype[tpos+1])); } break; case STJ: switch (tr->statetype[tpos+1]) { case STB: hmm->xt[XTJ][MOVE] += wt; break; case STJ: hmm->xt[XTJ][LOOP] += wt; break; default: Die("illegal state transition %s->%s in traceback", Statetype(tr->statetype[tpos]), Statetype(tr->statetype[tpos+1])); } break; case STC: switch (tr->statetype[tpos+1]) { case STT: hmm->xt[XTC][MOVE] += wt; break; case STC: hmm->xt[XTC][LOOP] += wt; break; default: Die("illegal state transition %s->%s in traceback", Statetype(tr->statetype[tpos]), Statetype(tr->statetype[tpos+1])); } break; case STT: break; /* T is the last. It makes no transitions. */ default: Die("illegal state %s in traceback", Statetype(tr->statetype[tpos])); } } } /* Function: P7TraceScore() * * Purpose: Score a traceback and return the score in scaled bits. * * Args: hmm - HMM with valid log odds scores. * dsq - digitized sequence that traceback aligns to the HMM (1..L) * tr - alignment of seq to HMM * * Return: (void) */ float P7TraceScore(struct plan7_s *hmm, char *dsq, struct p7trace_s *tr) { int score; /* total score as a scaled integer */ int tpos; /* position in tr */ int sym; /* digitized symbol in dsq */ /* P7PrintTrace(stdout, tr, hmm, dsq); */ score = 0; for (tpos = 0; tpos < tr->tlen-1; tpos++) { sym = (int) dsq[tr->pos[tpos]]; /* Emissions. * Don't bother counting null states N,J,C. */ if (tr->statetype[tpos] == STM) score += hmm->msc[sym][tr->nodeidx[tpos]]; else if (tr->statetype[tpos] == STI) score += hmm->isc[sym][tr->nodeidx[tpos]]; /* State transitions. */ score += TransitionScoreLookup(hmm, tr->statetype[tpos], tr->nodeidx[tpos], tr->statetype[tpos+1], tr->nodeidx[tpos+1]); } return Scorify(score); } /* Function: P7Traces2Alignment() * * Purpose: Convert an array of traceback structures for a set * of sequences into a new multiple alignment. * * Insertions are put into lower case and * are not aligned; instead, Nterm is right-justified, * Cterm is left-justified, and internal insertions * are split in half and the halves are justified in * each direction (the objective being to increase * the chances of getting insertions aligned well enough * for them to become a match). * * NOTE: Does not recognize J state. * * Args: dsq - digitized unaligned sequences * sqinfo - array of info about the sequences * wgt - weights on seqs * nseq - number of sequences * mlen - length of model (number of match states) * tr - array of tracebacks * matchonly - TRUE if we don't print insert-generated symbols at all * ret_aseqs - RETURN: multiple sequence alignment * ainfo - RETURN: optional info about alignment * * Return: 1 on success, 0 on failure. * ret_aseqs is alloc'ed here and ainfo is filled in; * FreeAlignment(aseqs, &ainfo). */ void P7Traces2Alignment(char **dsq, SQINFO *sqinfo, float *wgt, int nseq, int mlen, struct p7trace_s **tr, int matchonly, char ***ret_aseqs, AINFO *ainfo) { char **aseqs; /* RETURN: aligned sequence set */ int idx; /* counter for sequences */ int alen; /* width of alignment */ int *inserts; /* array of max gaps between aligned columns */ int *matmap; /* matmap[k] = apos of match k [1..M] */ int nins; /* counter for inserts */ int apos; /* position in aligned sequence (0..alen-1)*/ int rpos; /* position in raw digital sequence (1..L)*/ int tpos; /* position counter in traceback */ int statetype; /* type of current state, e.g. STM */ int k; /* counter over states in model */ /* Here's the problem. We want to align the match states in columns, * but some sequences have inserted symbols in them; we need some * sort of overall knowledge of where the inserts are and how long * they are in order to create the alignment. * * Here's our trick. inserts[] is a 0..hmm->M array; inserts[i] stores * the maximum number of times insert substate i was used. This * is the maximum number of gaps to insert between canonical * column i and i+1. inserts[0] is the N-term tail; inserts[M] is * the C-term tail. * * Remember that N and C emit on transition, hence the check for an * N->N or C->C transition before bumping nins. */ inserts = (int *) MallocOrDie (sizeof(int) * (mlen+1)); for (k = 0; k <= mlen; k++) inserts[k] = 0; for (idx = 0; idx < nseq; idx++) { nins = 0; for (tpos = 0; tpos < tr[idx]->tlen; tpos++) { switch (tr[idx]->statetype[tpos]) { case STI: nins++; break; case STN: if (tr[idx]->statetype[tpos-1] == STN) nins++; break; case STC: if (tr[idx]->statetype[tpos-1] == STC) nins++; break; case STM: case STD: /* M,D: record max. reset ctr. */ if (nins > inserts[tr[idx]->nodeidx[tpos]-1]) inserts[tr[idx]->nodeidx[tpos]-1] = nins; nins = 0; break; case STB: /* B; record N-tail max, reset ctr */ if (nins > inserts[0]) inserts[0] = nins; nins = 0; break; case STT: /* T: record C-tail max */ if (nins > inserts[mlen]) inserts[mlen] = nins; break; case STS: case STE: break; /* ignore other states */ case STJ: Die("yo! you don't support J in Traces2Alignment(), remember?"); default: Die("Traces2Alignment reports unrecognized statetype %c", Statetype(tr[idx]->statetype[tpos])); } } } /* Insert compression option. */ if (matchonly) for (k = 0; k <= mlen; k++) if (inserts[k] > 1) inserts[k] = 1; /*********************************************** * Construct the alignment ***********************************************/ /* calculate alignment length and matmap */ matmap= (int *) MallocOrDie (sizeof(int) * (mlen+1)); matmap[0] = -1; alen = inserts[0]; for (k = 1; k <= mlen ; k++) { matmap[k] = alen; alen += inserts[k] + 1; } /* allocations for new alignment */ AllocAlignment(nseq, alen, &aseqs, ainfo); for (idx = 0; idx < nseq; idx++) { /* blank an aseq */ for (apos = 0; apos < alen; apos++) aseqs[idx][apos] = '.'; aseqs[idx][alen] = '\0'; /* align the sequence */ apos = 0; for (tpos = 0; tpos < tr[idx]->tlen; tpos++) { statetype = tr[idx]->statetype[tpos]; /* just for clarity */ rpos = tr[idx]->pos[tpos]; k = tr[idx]->nodeidx[tpos]; if (statetype == STM) { apos = matmap[k]; aseqs[idx][apos] = Alphabet[(int) dsq[idx][rpos]]; apos++; } else if (statetype == STI) { if (matchonly) aseqs[idx][apos] = '*'; /* insert compression option */ else { aseqs[idx][apos] = tolower(Alphabet[(int) dsq[idx][rpos]]); apos++; } } else if ((statetype == STN || statetype == STC) && rpos > 0) { if (matchonly) aseqs[idx][apos] = '*'; /* insert compression option */ else { aseqs[idx][apos] = tolower(Alphabet[(int) dsq[idx][rpos]]); apos++; } } else if (statetype == STE) apos = matmap[mlen]+1; /* set position for C-term tail */ } /* N-terminal extension is right-justified. * Internal inserts are split in half, and C-term is right-justified. * C-terminal extension remains left-justified. */ if (! matchonly) { rightjustify(aseqs[idx], inserts[0]); for (k = 1; k < mlen; k++) if (inserts[k] > 1) { for (nins = 0, apos = matmap[k]+1; islower(aseqs[idx][apos]); apos++) nins++; nins /= 2; /* split the insertion in half */ rightjustify(aseqs[idx]+matmap[k]+1+nins, inserts[k]-nins); } } } /*********************************************** * Build ainfo ***********************************************/ sprintf(ainfo->au, "HMMER %s", RELEASE); ainfo->flags |= AINFO_AUTH; /* copy sqinfo array and weights */ for (idx = 0; idx < nseq; idx++) { SeqinfoCopy(&(ainfo->sqinfo[idx]), &(sqinfo[idx])); ainfo->wgt[idx] = wgt[idx]; } /* #=RF annotation: x for match column, . for insert column */ ainfo->flags |= AINFO_RF; ainfo->rf = (char *) MallocOrDie (sizeof(char) * (alen+1)); for (apos = 0; apos < alen; apos++) ainfo->rf[apos] = '.'; for (k = 1; k <= mlen; k++) ainfo->rf[matmap[k]] = 'x'; ainfo->rf[alen] = '\0'; /* Currently, we produce no consensus structure. * #=CS, generated from HMM structural annotation, would go here. */ free(inserts); free(matmap); *ret_aseqs = aseqs; return; } /* Function: TransitionScoreLookup() * * Purpose: Convenience function used in PrintTrace() and TraceScore(); * given state types and node indices for a transition, * return the integer score for that transition. */ int TransitionScoreLookup(struct plan7_s *hmm, enum p7stype st1, int k1, enum p7stype st2, int k2) { switch (st1) { case STS: return 0; /* S never pays */ case STN: switch (st2) { case STB: return hmm->xsc[XTN][MOVE]; case STN: return hmm->xsc[XTN][LOOP]; default: Die("illegal %s->%s transition", Statetype(st1), Statetype(st2)); } break; case STB: switch (st2) { case STM: return hmm->bsc[k2]; case STD: return Prob2Score(hmm->tbd1, 1.); default: Die("illegal %s->%s transition", Statetype(st1), Statetype(st2)); } break; case STM: switch (st2) { case STM: return hmm->tsc[k1][TMM]; case STI: return hmm->tsc[k1][TMI]; case STD: return hmm->tsc[k1][TMD]; case STE: return hmm->esc[k1]; default: Die("illegal %s->%s transition", Statetype(st1), Statetype(st2)); } break; case STI: switch (st2) { case STM: return hmm->tsc[k1][TIM]; case STI: return hmm->tsc[k1][TII]; default: Die("illegal %s->%s transition", Statetype(st1), Statetype(st2)); } break; case STD: switch (st2) { case STM: return hmm->tsc[k1][TDM]; case STD: return hmm->tsc[k1][TDD]; case STE: return 0; /* D_m->E has probability 1.0 by definition in Plan7 */ default: Die("illegal %s->%s transition", Statetype(st1), Statetype(st2)); } break; case STE: switch (st2) { case STC: return hmm->xsc[XTE][MOVE]; case STJ: return hmm->xsc[XTE][LOOP]; default: Die("illegal %s->%s transition", Statetype(st1), Statetype(st2)); } break; case STJ: switch (st2) { case STB: return hmm->xsc[XTJ][MOVE]; case STJ: return hmm->xsc[XTJ][LOOP]; default: Die("illegal %s->%s transition", Statetype(st1), Statetype(st2)); } break; case STC: switch (st2) { case STT: return hmm->xsc[XTC][MOVE]; case STC: return hmm->xsc[XTC][LOOP]; default: Die("illegal %s->%s transition", Statetype(st1), Statetype(st2)); } break; case STT: return 0; /* T makes no transitions */ default: Die("illegal state %s in traceback", Statetype(st1)); } /*NOTREACHED*/ return 0; } /* Function: CreateFancyAli() * Date: SRE, Mon Oct 27 06:49:44 1997 [Sanger Centre UK] * * Purpose: Output of an HMM/sequence alignment, using a * traceback structure. Deliberately similar to * the output of BLAST, to make it easier for * people to adapt their Perl parsers (or what have * you) from BLAST to HMMER. * * Args: tr - traceback structure that gives the alignment * hmm - the model * dsq - the sequence (digitized form) * name- name of the sequence * * Return: allocated, filled fancy alignment structure. */ struct fancyali_s * CreateFancyAli(struct p7trace_s *tr, struct plan7_s *hmm, char *dsq, char *name) { struct fancyali_s *ali; /* alignment to create */ int tpos; /* position in trace and alignment */ int bestsym; /* index of best symbol at this pos */ float mthresh; /* above this P(x), display uppercase */ /* Allocate and initialize the five lines of display */ ali = AllocFancyAli(); ali->rfline = NULL; ali->csline = NULL; ali->model = (char *) MallocOrDie (sizeof(char) * (tr->tlen+1)); ali->mline = (char *) MallocOrDie (sizeof(char) * (tr->tlen+1)); ali->aseq = (char *) MallocOrDie (sizeof(char) * (tr->tlen+1)); memset(ali->model, ' ', tr->tlen); memset(ali->mline, ' ', tr->tlen); memset(ali->aseq, ' ', tr->tlen); if (hmm->flags & PLAN7_RF) { ali->rfline = (char *) MallocOrDie (sizeof(char) * (tr->tlen+1)); memset(ali->rfline, ' ', tr->tlen); } if (hmm->flags & PLAN7_CS) { ali->csline = (char *) MallocOrDie (sizeof(char) * (tr->tlen+1)); memset(ali->csline, ' ', tr->tlen); } ali->query = Strdup(hmm->name); ali->target = Strdup(name); if (Alphabet_type == hmmAMINO) mthresh = 0.5; else mthresh = 0.9; /* Find first, last seq position * HMM start/end positions currently not recorded, because there * might be multiple HMM hits per sequence. */ for (tpos = 0; tpos < tr->tlen; tpos++) if (tr->pos[tpos] > 0) { ali->sqfrom = tr->pos[tpos]; break; } for (tpos = tr->tlen-1; tpos >= 0; tpos--) if (tr->pos[tpos] > 0) { ali->sqto = tr->pos[tpos]; break; } /* Fill in the five lines of display */ for (tpos = 0; tpos < tr->tlen; tpos++) { switch (tr->statetype[tpos]) { case STS: case STT: ali->model[tpos] = '*'; break; case STN: case STJ: case STC: ali->model[tpos] = '-'; if (tr->pos[tpos] > 0) { ali->aseq[tpos] = tolower(Alphabet[(int) dsq[tr->pos[tpos]]]); } break; case STB: ali->model[tpos] = '>'; break; case STE: ali->model[tpos] = '<'; break; case STM: if (hmm->flags & PLAN7_RF) ali->rfline[tpos] = hmm->rf[tr->nodeidx[tpos]]; if (hmm->flags & PLAN7_CS) ali->csline[tpos] = hmm->cs[tr->nodeidx[tpos]]; bestsym = FMax(hmm->mat[tr->nodeidx[tpos]], Alphabet_size); ali->model[tpos] = Alphabet[bestsym]; if (hmm->mat[tr->nodeidx[tpos]][bestsym] < mthresh) ali->model[tpos] = tolower(ali->model[tpos]); if (dsq[tr->pos[tpos]] == bestsym) { ali->mline[tpos] = Alphabet[(int) dsq[tr->pos[tpos]]]; if (hmm->mat[tr->nodeidx[tpos]][bestsym] < mthresh) ali->mline[tpos] = tolower(ali->mline[tpos]); } else if (hmm->msc[(int) dsq[tr->pos[tpos]]] [tr->nodeidx[tpos]] > 0) ali->mline[tpos] = '+'; ali->aseq[tpos] = Alphabet[(int) dsq[tr->pos[tpos]]]; break; case STD: if (hmm->flags & PLAN7_RF) ali->rfline[tpos] = hmm->rf[tr->nodeidx[tpos]]; if (hmm->flags & PLAN7_CS) ali->csline[tpos] = hmm->cs[tr->nodeidx[tpos]]; bestsym = FMax(hmm->mat[tr->nodeidx[tpos]], Alphabet_size); ali->model[tpos] = Alphabet[bestsym]; if (hmm->mat[tr->nodeidx[tpos]][bestsym] < mthresh) ali->model[tpos] = tolower(ali->model[tpos]); ali->aseq[tpos] = '-'; break; case STI: ali->model[tpos] = '.'; if (hmm->isc[(int) dsq[tr->pos[tpos]]] [tr->nodeidx[tpos]] > 0) ali->mline[tpos] = '+'; ali->aseq[tpos] = tolower(Alphabet[(int) dsq[tr->pos[tpos]]]); break; default: Die("bogus statetype"); } /* end switch over statetypes */ } /* end loop over tpos */ ali->len = tpos; if (hmm->flags & PLAN7_RF) ali->rfline[tpos] = '\0'; if (hmm->flags & PLAN7_CS) ali->csline[tpos] = '\0'; ali->model[tpos] = '\0'; ali->mline[tpos] = '\0'; ali->aseq[tpos] = '\0'; return ali; } /* Function: PrintFancyAli() * Date: SRE, Mon Oct 27 06:56:42 1997 [Sanger Centre UK] * * Purpose: Print an HMM/sequence alignment from a fancyali_s * structure. Line length controlled by ALILENGTH in * config.h (set to 50). * * Args: fp - where to print it (stdout or open FILE) * ali - alignment to print * * Return: (void) */ void PrintFancyAli(FILE *fp, struct fancyali_s *ali) { char buffer[ALILENGTH+1]; /* output line buffer */ int starti, endi; int pos; int i; buffer[ALILENGTH] = '\0'; endi = ali->sqfrom - 1; for (pos = 0; pos < ali->len; pos += ALILENGTH) { /* coords of target seq for this line */ starti = endi + 1; for (i = pos; ali->aseq[i] != '\0' && i < pos + ALILENGTH; i++) if (!isgap(ali->aseq[i])) endi++; if (ali->csline != NULL) { strncpy(buffer, ali->csline+pos, ALILENGTH); fprintf(fp, " %16s %s\n", "CS", buffer); } if (ali->rfline != NULL) { strncpy(buffer, ali->rfline+pos, ALILENGTH); fprintf(fp, " %16s %s\n", "RF", buffer); } if (ali->model != NULL) { strncpy(buffer, ali->model+pos, ALILENGTH); fprintf(fp, " %16s %s\n", " ", buffer); } if (ali->mline != NULL) { strncpy(buffer, ali->mline+pos, ALILENGTH); fprintf(fp, " %16s %s\n", " ", buffer); } if (ali->aseq != NULL) { strncpy(buffer, ali->aseq+pos, ALILENGTH); if (endi >= starti) fprintf(fp, " %10.10s %5d %s %-5d\n\n", ali->target, starti, buffer, endi); else fprintf(fp, " %10.10s %5s %s %-5s\n\n", ali->target, "-", buffer, "-"); } } /* Cleanup and return */ fflush(fp); return; } /* Function: TraceDecompose() * Date: Sat Aug 30 11:18:40 1997 (Denver CO) * * Purpose: Decompose a long multi-hit trace into zero or more * traces without N,C,J transitions: for consistent * scoring and statistical evaluation of single domain * hits. * * Args: otr - original trace structure * ret_tr - RETURN: array of simpler traces * ret_ntr- RETURN: number of traces. * * Return: (void) * ret_tr alloc'ed here; free individuals with FreeTrace(). */ void TraceDecompose(struct p7trace_s *otr, struct p7trace_s ***ret_tr, int *ret_ntr) { struct p7trace_s **tr; /* array of new traces */ int ntr; /* number of traces */ int i,j; /* position counters in traces */ int idx; /* index over ntr subtraces */ /* First pass: count begin states to get ntr. */ for (ntr = 0, i = 0; i < otr->tlen; i++) if (otr->statetype[i] == STB) ntr++; /* Allocations. */ if (ntr == 0) { *ret_ntr = 0; *ret_tr = NULL; return; } tr = (struct p7trace_s **) MallocOrDie (sizeof(struct p7trace_s *) * ntr); for (idx = 0, i = 0; i < otr->tlen; i++) /* i = position in old trace */ if (otr->statetype[i] == STB) { for (j = i+1; j < otr->tlen; j++) /* j = tmp; get length of subtrace */ if (otr->statetype[j] == STE) break; /* trace = S-N-(B..E)-C-T : len + 4 : j-i+1 + 4*/ P7AllocTrace(j-i+5, &(tr[idx])); tr[idx]->tlen = j-i+5; tr[idx]->statetype[0] = STS; tr[idx]->nodeidx[0] = 0; tr[idx]->pos[0] = 0; tr[idx]->statetype[1] = STN; tr[idx]->nodeidx[1] = 0; tr[idx]->pos[1] = 0; j = 2; /* now j = position in new subtrace */ while (1) /* copy subtrace */ { tr[idx]->statetype[j] = otr->statetype[i]; tr[idx]->nodeidx[j] = otr->nodeidx[i]; tr[idx]->pos[j] = otr->pos[i]; if (otr->statetype[i] == STE) break; i++; j++; } j++; tr[idx]->statetype[j] = STC; tr[idx]->nodeidx[j] = 0; tr[idx]->pos[j] = 0; j++; tr[idx]->statetype[j] = STT; tr[idx]->nodeidx[j] = 0; tr[idx]->pos[j] = 0; idx++; } *ret_tr = tr; *ret_ntr = ntr; return; } /* Function: TraceDomainNumber() * * Purpose: Count how many times we traverse the * model in a single Plan7 trace -- equivalent * to counting the number of domains. * * (A weakness is that we might discard some of * those domains because they have low scores * below E or T threshold.) */ int TraceDomainNumber(struct p7trace_s *tr) { int i; int ndom = 0; for (i = 0; i < tr->tlen; i++) if (tr->statetype[i] == STB) ndom++; return ndom; } /* Function: TraceSimpleBounds() * * Purpose: For a trace that contains only a single * traverse of the model (i.e. something that's * come from TraceDecompose(), or a global * alignment), determine the bounds of * the match on both the sequence [1..L] and the * model [1..M]. * * Args: tr - trace to look at * i1 - RETURN: start point in sequence [1..L] * i2 - RETURN: end point in sequence [1..L] * k1 - RETURN: start point in model [1..M] * k2 - RETURN: end point in model [1..M] */ void TraceSimpleBounds(struct p7trace_s *tr, int *ret_i1, int *ret_i2, int *ret_k1, int *ret_k2) { int i1, i2, k1, k2, tpos; i1 = k1 = i2 = k2 = -1; /* Look forwards to find start of match */ for (tpos = 0; tpos < tr->tlen; tpos++) { if (k1 == -1 && (tr->statetype[tpos] == STM || tr->statetype[tpos] == STD)) k1 = tr->nodeidx[tpos]; if (tr->statetype[tpos] == STM) { i1 = tr->pos[tpos]; break; } } if (tpos == tr->tlen || i1 == -1 || k1 == -1) Die("sanity check failed: didn't find a match state in trace"); /* Look backwards to find end of match */ for (tpos = tr->tlen-1; tpos >= 0; tpos--) { if (k2 == -1 && (tr->statetype[tpos] == STM || tr->statetype[tpos] == STD)) k2 = tr->nodeidx[tpos]; if (tr->statetype[tpos] == STM) { i2 = tr->pos[tpos]; break; } } if (tpos == tr->tlen || i2 == -1 || k2 == -1) Die("sanity check failed: didn't find a match state in trace"); *ret_k1 = k1; *ret_i1 = i1; *ret_k2 = k2; *ret_i2 = i2; } /* Function: rightjustify() * * Purpose: Given a gap-containing string of length n, * pull all the non-gap characters as far as * possible to the right, leaving gaps on the * left side. Used to rearrange the positions * of insertions in HMMER alignments. */ static void rightjustify(char *s, int n) { int npos; int opos; npos = n-1; opos = n-1; while (opos >= 0) { if (isgap(s[opos])) opos--; else s[npos--]=s[opos--]; } while (npos >= 0) s[npos--] = '.'; } wise-2.4.1/src/HMMer2/funcs.h0000644000175000001440000002743607313404524015177 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Washington University School of Medicine * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* funcs.h * RCS $Id: funcs.h,v 1.1.1.1 2001/06/18 13:59:48 birney Exp $ * * Declarations of external functions in HMMER. */ #ifndef FUNCSH_INCLUDED #define FUNCSH_INCLUDED #include "config.h" #include "structs.h" #include "squid.h" /* alphabet.c * Configuration of global alphabet information */ extern void DetermineAlphabet(char **rseqs, int nseq); extern void SetAlphabet(int type); extern int SymbolIndex(char sym); extern char *DigitizeSequence(char *seq, int L); extern char *DedigitizeSequence(char *dsq, int L); extern void DigitizeAlignment(char **aseqs, AINFO *ainfo, char ***ret_dsqs); extern void P7CountSymbol(float *counters, char sym, float wt); extern void DefaultGeneticCode(int *aacode); extern void DefaultCodonBias(float *codebias); /* from core_algorithms.c * Clean research/demonstration versions of basic algorithms. */ extern struct dpmatrix_s *AllocPlan7Matrix(int rows, int M, int ***xmx, int ***mmx, int ***imx, int ***dmx); extern void FreePlan7Matrix(struct dpmatrix_s *mx); extern int P7ViterbiSize(int L, int M); extern int P7SmallViterbiSize(int L, int M); extern int P7WeeViterbiSize(int L, int M); extern float P7Forward(char *dsq, int L, struct plan7_s *hmm, struct dpmatrix_s **ret_mx); extern float P7Viterbi(char *dsq, int L, struct plan7_s *hmm, struct p7trace_s **ret_tr); extern void P7ViterbiTrace(struct plan7_s *hmm, char *dsq, int L, struct dpmatrix_s *mx, struct p7trace_s **ret_tr); extern float P7SmallViterbi(char *dsq, int L, struct plan7_s *hmm, struct p7trace_s **ret_tr); extern float P7ParsingViterbi(char *dsq, int L, struct plan7_s *hmm, struct p7trace_s **ret_tr); extern float P7WeeViterbi(char *dsq, int L, struct plan7_s *hmm, struct p7trace_s **ret_tr); extern float Plan7ESTViterbi(char *dsq, int L, struct plan7_s *hmm, struct dpmatrix_s **ret_mx); /* from debug.c * Debugging output of various sorts. */ extern void VerboseWorry(int level, char *file, int line, char *fmt, ...); extern void Panic(char *file, int line); extern char *Statetype(enum p7stype st); extern void P7PrintTrace(FILE *fp, struct p7trace_s *tr, struct plan7_s *hmm, char *dsq); extern void P7PrintPrior(FILE *fp, struct p7prior_s *pri); extern int TraceCompare(struct p7trace_s *t1, struct p7trace_s *t2); extern int TraceVerify(struct p7trace_s *tr, int M, int N); /* from emit.c * Generation of sequences/traces from an HMM */ extern void EmitSequence(struct plan7_s *hmm, char **ret_dsq, int *ret_L, struct p7trace_s **ret_tr); /* from emulation.c * Interfaces between HMMER and other software packages */ extern void WriteProfile(FILE *fp, struct plan7_s *hmm, int do_xsw); /* from histogram.c * accumulation of scores */ extern struct histogram_s *AllocHistogram(int min, int max, int lumpsize); extern void FreeHistogram(struct histogram_s *h); extern void UnfitHistogram(struct histogram_s *h); extern void AddToHistogram(struct histogram_s *h, float sc); extern void PrintASCIIHistogram(FILE *fp, struct histogram_s *h); extern void PrintXMGRHistogram(FILE *fp, struct histogram_s *h); extern void PrintXMGRDistribution(FILE *fp, struct histogram_s *h); extern void PrintXMGRRegressionLine(FILE *fp, struct histogram_s *h); extern void EVDBasicFit(struct histogram_s *h); extern int ExtremeValueFitHistogram(struct histogram_s *h, int censor, float high_hint); extern void ExtremeValueSetHistogram(struct histogram_s *h, float mu, float lambda, float low, float high, float wonka, int ndegrees); extern int GaussianFitHistogram(struct histogram_s *h, float high_hint); extern void GaussianSetHistogram(struct histogram_s *h, float mean, float sd); extern double EVDDensity(float x, float mu, float lambda); extern double EVDDistribution(float x, float mu, float lambda); extern double ExtremeValueP (float x, float mu, float lambda); extern double ExtremeValueP2(float x, float mu, float lambda, int N); extern double ExtremeValueE (float x, float mu, float lambda, int N); extern float EVDrandom(float mu, float lambda); extern int EVDMaxLikelyFit(float *x, int *y, int n, float *ret_mu, float *ret_lambda); extern int EVDCensoredFit(float *x, int *y, int n, int z, float c, float *ret_mu, float *ret_lambda); extern void Lawless416(float *x, int *y, int n, float lambda, float *ret_f, float *ret_df); extern void Lawless422(float *x, int *y, int n, int z, float c, float lambda, float *ret_f, float *ret_df); /* from hmmio.c * Input/output (saving/reading) of models */ extern HMMFILE *HMMFileOpen(char *hmmfile, char *env); extern HMMFILE *HMMFileOpenFseek(char *hmmfile, char *env,int pos); extern int HMMFileRead(HMMFILE *hmmfp, struct plan7_s **ret_hmm); extern void HMMFileClose(HMMFILE *hmmfp); extern int HMMFileFormat(HMMFILE *hmmfp); extern void HMMFileRewind(HMMFILE *hmmfp); extern void WriteAscHMM(FILE *fp, struct plan7_s *hmm); extern void WriteBinHMM(FILE *fp, struct plan7_s *hmm); extern long HMMFtell(HMMFILE * hmmfp); extern int HMMFseek(HMMFILE * hmmfp,long pos); /* masks.c * Repetitive sequence masking. */ extern int XNU(char *dsq, int len); extern float TraceScoreCorrection(struct plan7_s *hmm, struct p7trace_s *tr, char *dsq); /* mathsupport.c * Much of this code deals with Dirichlet prior mathematics. */ extern int Prob2Score(float p, float null); extern float Score2Prob(int sc, float null); extern float Scorify(int sc); extern double PValue(struct plan7_s *hmm, float sc); extern float LogSum(float p1, float p2); extern int ILogsum(int p1, int p2); extern void LogNorm(float *vec, int n); extern float Logp_cvec(float *cvec, int n, float *alpha); extern void SampleDirichlet(float *alpha, int n, float *p); extern float SampleGamma(float alpha); extern void SampleCountvector(float *p, int n, int c, float *cvec); extern float P_PvecGivenDirichlet(float *p, int n, float *alpha); /* from misc.c * Miscellaneous functions with no home */ extern void Banner(FILE *fp, char *banner); extern char *Getword(FILE *fp, int type); extern char *Getline(char *s, int n, FILE *fp); /* from modelmakers.c * Model construction algorithms */ extern void P7Handmodelmaker(char **aseq, char **dsq, AINFO *ainfo, struct plan7_s **ret_hmm, struct p7trace_s ***ret_tr); extern void P7Fastmodelmaker(char **aseq, char **dsq, AINFO *ainfo, float maxgap, struct plan7_s **ret_hmm, struct p7trace_s ***ret_tr); extern void P7Maxmodelmaker(char **aseqs, char **dsq, AINFO *ainfo, float maxgap, struct p7prior_s *prior, float *null, float null_p1, float mpri, struct plan7_s **ret_hmm, struct p7trace_s ***ret_tr); /* from plan7.c * Plan7 HMM structure support */ extern struct plan7_s *AllocPlan7(int M); extern struct plan7_s *AllocPlan7Shell(void); extern void AllocPlan7Body(struct plan7_s *hmm, int M); extern void FreePlan7(struct plan7_s *hmm); extern void ZeroPlan7(struct plan7_s *hmm); extern void Plan7SetName(struct plan7_s *hmm, char *name); extern void Plan7SetDescription(struct plan7_s *hmm, char *desc); extern void Plan7ComlogAppend(struct plan7_s *hmm, int argc, char **argv); extern void Plan7SetCtime(struct plan7_s *hmm); extern void Plan7SetNullModel(struct plan7_s *hmm, float null[MAXABET], float p1); extern void P7Logoddsify(struct plan7_s *hmm, int viterbi_mode); extern void Plan7Renormalize(struct plan7_s *hmm); extern void Plan7NakedConfig(struct plan7_s *hmm); extern void Plan7GlobalConfig(struct plan7_s *hmm); extern void Plan7LSConfig(struct plan7_s *hmm); extern void Plan7SWConfig(struct plan7_s *hmm, float pentry, float pexit); extern void Plan7FSConfig(struct plan7_s *hmm, float pentry, float pexit); extern void PrintPlan7Stats(FILE *fp, struct plan7_s *hmm, char **dsq, int nseq, struct p7trace_s **tr); extern int DegenerateSymbolScore(float *p, float *null, int ambig); extern void Plan9toPlan7(struct plan9_s *hmm, struct plan7_s **ret_plan7); /* * from plan9.c * Backwards compatibility for the Plan 9 data structures of HMMER 1.x */ extern struct plan9_s *P9AllocHMM(int M); extern void P9ZeroHMM(struct plan9_s *hmm); extern int P9FreeHMM(struct plan9_s *hmm); extern void P9Renormalize(struct plan9_s *hmm); extern void P9DefaultNullModel(float *null); /* from prior.c * Dirichlet priors */ extern struct p7prior_s *P7AllocPrior(void); extern struct p7prior_s *P7LaplacePrior(void); extern struct p7prior_s *P7DefaultPrior(void); extern struct p7prior_s *P7ReadPrior(char *prifile); extern void P7FreePrior(struct p7prior_s *pri); extern void PAMPrior(char *pamfile, struct p7prior_s *pri, float pamwgt); extern void P7DefaultNullModel(float *null, float *ret_p1); extern void P7ReadNullModel(char *rndfile, float *null, float *ret_p1); extern void P7PriorifyHMM(struct plan7_s *hmm, struct p7prior_s *pri); extern void P7PriorifyTransitionVector(float *t, struct p7prior_s *prior); extern void P7PriorifyEmissionVector(float *vec, struct p7prior_s *pri, int num, float eq[MAXDCHLET], float e[MAXDCHLET][MAXABET], float *ret_mix); /* from tophits.c * Support for keeping/sorting top scoring hit/alignment lists */ extern struct tophit_s *AllocTophits(int lumpsize); extern void GrowTophits(struct tophit_s *h); extern void FreeTophits(struct tophit_s *h); extern struct fancyali_s *AllocFancyAli(void); extern void FreeFancyAli(struct fancyali_s *ali); extern void RegisterHit(struct tophit_s *h, double sortkey, double pvalue, float score, double motherp, float mothersc, char *name, char *desc, int sqfrom, int sqto, int sqlen, int hmmfrom, int hmmto, int hmmlen, int domidx, int ndom, struct fancyali_s *ali); extern void GetRankedHit(struct tophit_s *h, int rank, double *r_pvalue, float *r_score, double *r_motherp, float *r_mothersc, char **r_name, char **r_desc, int *r_sqfrom, int *r_sqto, int *r_sqlen, int *r_hmmfrom, int *r_hmmto, int *r_hmmlen, int *r_domidx, int *r_ndom, struct fancyali_s **r_ali); extern int TophitsMaxName(struct tophit_s *h); extern void FullSortTophits(struct tophit_s *h); extern void TophitsReport(struct tophit_s *h, double E, int nseq); /* from trace.c * Support for traceback (state path) structure */ extern void P7AllocTrace(int tlen, struct p7trace_s **ret_tr); extern void P7ReallocTrace(struct p7trace_s *tr, int tlen); extern void P7FreeTrace(struct p7trace_s *tr); extern void TraceSet(struct p7trace_s *tr, int tpos, enum p7stype type, int idx, int pos); extern void P7ReverseTrace(struct p7trace_s *tr); extern void P7TraceCount(struct plan7_s *hmm, char *dsq, float wt, struct p7trace_s *tr); extern float P7TraceScore(struct plan7_s *hmm, char *dsq, struct p7trace_s *tr); extern void P7Traces2Alignment(char **dsq, SQINFO *sqinfo, float *wgt, int nseq, int M, struct p7trace_s **tr, int matchonly, char ***ret_aseqs, AINFO *ainfo); extern int TransitionScoreLookup(struct plan7_s *hmm, enum p7stype st1, int k1, enum p7stype st2, int k2); extern struct fancyali_s *CreateFancyAli(struct p7trace_s *tr, struct plan7_s *hmm, char *dsq, char *name); extern void PrintFancyAli(FILE *fp, struct fancyali_s *ali); extern void TraceDecompose(struct p7trace_s *otr, struct p7trace_s ***ret_tr, int *ret_ntr); extern int TraceDomainNumber(struct p7trace_s *tr); extern void TraceSimpleBounds(struct p7trace_s *tr, int *ret_i1, int *ret_i2, int *ret_k1, int *ret_k2); #endif /*FUNCSH_INCLUDED*/ wise-2.4.1/src/HMMer2/sqerror.c0000644000175000001440000000262207313404527015542 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* sqerror.c * * error handling for the squid library */ /* a global errno equivalent */ int squid_errno; #include #include #include #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Function: Die() * * Purpose: Print an error message and die. The arguments * are formatted exactly like arguments to printf(). * * Return: None. Exits the program. */ /* VARARGS0 */ void Die(char *format, ...) { va_list argp; /* format the error mesg */ fprintf(stderr, "FATAL: "); va_start(argp, format); vfprintf(stderr, format, argp); va_end(argp); fprintf(stderr, "\n"); fflush(stderr); /* exit */ exit(1); } /* Function: Warn() * * Purpose: Print an error message and return. The arguments * are formatted exactly like arguments to printf(). * * Return: (void) */ /* VARARGS0 */ void Warn(char *format, ...) { va_list argp; /* format the error mesg */ fprintf(stderr, "WARNING: "); va_start(argp, format); vfprintf(stderr, format, argp); va_end(argp); fprintf(stderr, "\n"); fflush(stderr); } wise-2.4.1/src/HMMer2/misc.c0000644000175000001440000000602207313404526014775 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1997 Sean R. Eddy * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* misc.c * SRE, Thu Jul 15 18:49:19 1993 * * Functions that I don't know quite where to put yet. */ #include #include #include #include #include "squid.h" #include "config.h" #include "structs.h" #include "version.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Function: Banner() * * Purpose: Print the HMMER version and copyright banner. * Used by all the main()'s. */ void Banner(FILE *fp, char *banner) { fputs(banner, fp); fprintf(fp, "\nHMMER %s (%s)\n", RELEASE, RELEASEDATE); fprintf(fp, "Copyright (C) 1992-1998 Washington University School of Medicine\n"); fprintf(fp, "HMMER is freely distributed under the GNU General Public License (GPL).\n"); printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"); } /* Function: Getword() * * Purpose: little function used by ReadPrior() and ReadHMM() to parse * next valid field out of an open file, ignoring * comments. '#' marks the beginning of a comment. * * Arg: fp - open file for reading * type - sqdARG_INT, sqdARG_FLOAT, or sqdARG_STRING from squid.h */ char * Getword(FILE *fp, int type) { static char buffer[512]; static char *sptr = NULL; if (sptr != NULL) sptr = strtok(NULL, " \t\n"); while (sptr == NULL) { if ((sptr = fgets(buffer, 512, fp)) == NULL) return NULL; if ((sptr = strchr(buffer, '#')) != NULL) *sptr = '\0'; sptr = strtok(buffer, " \t\n"); } switch (type) { case sqdARG_STRING: if (strlen(sptr) == 0) { Warn("Parse failed: expected string, got nothing"); sptr = NULL; } break; case sqdARG_INT: if (!IsInt(sptr)) { Warn("Parse failed: expected integer, got %s", sptr); sptr = NULL; } break; case sqdARG_FLOAT: if (!IsReal(sptr)) { Warn("Parse failed: expected real value, got %s", sptr); sptr = NULL; } break; } return sptr; } /* Function: Getline() * * Purpose: Get the next non-blank, non-comment line from an open file. * A comment line has '#' as the first non-whitespace character. * Returns NULL if no line is found. * Syntax is the same as fgets(). * * Args: s - allocated storage for line * n - number of characters allocated for s * fp - open FILE * * * Return: Either s, or NULL if no new line is found. */ char * Getline(char *s, int n, FILE *fp) { char *first; do { if (fgets(s, n, fp) == NULL) return NULL; first = s; while (isspace(*first)) first++; } while (*first == '#' || *first == '\0'); return s; } wise-2.4.1/src/HMMer2/alignio.c0000644000175000001440000004253707313404524015475 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* alignio.c * SRE, Mon Jul 12 11:57:37 1993 * * Input/output of sequence alignments. */ #include #include #include #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Function: AllocAlignment() * * Purpose: Allocate space for an alignment, given the number * of sequences and the alignment length in columns. * * Args: nseq - number of sequences * alen - width of alignment * ret_aseq - RETURN: alignment itself * ainfo - RETURN: other info associated with alignment * * Return: (void) * aseq, ainfo free'd by caller: FreeAlignment(aseq, &ainfo). * note that ainfo itself is alloc'ed in caller, usually * just by a "AINFO ainfo" definition. */ void AllocAlignment(int nseq, int alen, char ***ret_aseq, AINFO *ainfo) { char **aseq; int idx; aseq = (char **) MallocOrDie (sizeof(char *) * nseq); for (idx = 0; idx < nseq; idx++) aseq[idx] = (char *) MallocOrDie (sizeof(char) * (alen+1)); ainfo->flags = 0; ainfo->alen = alen; ainfo->nseq = nseq; ainfo->wgt = (float *) MallocOrDie (sizeof(float) * nseq); FSet(ainfo->wgt, nseq, 1.0); ainfo->sqinfo = (SQINFO *) MallocOrDie (sizeof(SQINFO) * nseq); for (idx = 0; idx < nseq; idx++) ainfo->sqinfo[idx].flags = 0; *ret_aseq = aseq; } /* Function: FreeAlignment() * * Purpose: Free the space allocated to alignment, names, and optional * information. * * Args: aseqs - sequence alignment * ainfo - associated alignment data. */ void FreeAlignment(char **aseqs, AINFO *ainfo) { int i; for (i = 0; i < ainfo->nseq; i++) { if (ainfo->sqinfo[i].flags & SQINFO_SS) free(ainfo->sqinfo[i].ss); if (ainfo->sqinfo[i].flags & SQINFO_SA) free(ainfo->sqinfo[i].sa); } if (ainfo->flags & AINFO_CS) free(ainfo->cs); if (ainfo->flags & AINFO_RF) free(ainfo->rf); free(ainfo->sqinfo); free(ainfo->wgt); Free2DArray(aseqs, ainfo->nseq); } /* Function: ReadAlignedFASTA() * Date: SRE, Sun Feb 22 11:42:04 1998 [St. Louis] * * Purpose: Read an alignment file in "aligned FASTA" format; * gaps are allowed, and all sequences must be * the same length. * * We do this all via SeqfileOpen() interface to * get access to piped input and gzip'ed input. * Unlike most alignment files, we can read FASTA * alignments in a single, sequential-read pass. * * Args: filename - name of file to open ("-" for stdin; "foo.gz" for gzip) * env - env variable name for possible path (or NULL) * ret_aseq - RETURN: sequence alignment * ret_ainfo - RETURN: optional info on alignment (alloc'ed by caller) * * Returns: 1 on success. */ void ReadAlignedFASTA(char *filename, char *env, char ***ret_aseq, AINFO *ainfo) { SQFILE *sqfp; /* open file for reading */ char **aseq; /* aligned sequences */ char *seq; /* new sequence */ SQINFO sqinfo; /* info for new sequence */ if ((sqfp = SeqfileOpen(filename, kPearson, env)) == NULL) Die("Failed to open %s for reading as aligned FASTA", filename); ainfo->nseq = 0; while (ReadSeq(sqfp, kPearson, &seq, &sqinfo)) { if (ainfo->nseq == 0) { aseq = MallocOrDie(sizeof(char **)); ainfo->sqinfo = MallocOrDie(sizeof(struct seqinfo_s)); ainfo->alen = sqinfo.len; } else { if (sqinfo.len != ainfo->alen) Die("Aligned FASTA file %s has seqs of different length", filename); aseq = ReallocOrDie(aseq, sizeof(char **) * (ainfo->nseq+1)); ainfo->sqinfo = ReallocOrDie(ainfo->sqinfo, sizeof(struct seqinfo_s) * (ainfo->nseq+1)); } aseq[ainfo->nseq] = seq; ainfo->sqinfo[ainfo->nseq].flags = SQINFO_NAME | SQINFO_DESC | SQINFO_LEN; strcpy(ainfo->sqinfo[ainfo->nseq].name, sqinfo.name); strcpy(ainfo->sqinfo[ainfo->nseq].desc, sqinfo.desc); ainfo->sqinfo[ainfo->nseq].len = DealignedLength(seq); ainfo->nseq++; } *ret_aseq = aseq; ainfo->flags = 0; ainfo->wgt = MallocOrDie(sizeof(float) * ainfo->nseq); FSet(ainfo->wgt, ainfo->nseq, 1.); SeqfileClose(sqfp); return; } /* Function: WriteAlignedFASTA() * Date: SRE, Tue Mar 3 09:13:40 1998 [St. Louis] * * Purpose: Write an "aligned FASTA" (aka a2m, to UCSC) formatted * alignment. * * Args: fp - open FILE to write to. * aseqs - aligned seqs * AINFO - optional alignment info * * Returns: void */ void WriteAlignedFASTA(FILE *fp, char **aseqs, AINFO *ainfo) { int idx; /* sequence index */ int pos; /* position in sequence */ char buf[64]; /* buffer for individual lines */ int cpl = 60; /* char per line; must be < 64 unless buf is bigger */ buf[cpl] = '\0'; for (idx = 0; idx < ainfo->nseq; idx++) { fprintf(fp, ">%s %s\n", ainfo->sqinfo[idx].name, ainfo->sqinfo[idx].flags & SQINFO_DESC ? ainfo->sqinfo[idx].desc : ""); for (pos = 0; pos < ainfo->alen; pos+=cpl) { strncpy(buf, &(aseqs[idx][pos]), cpl); fprintf(fp, "%s\n", buf); } } } /* Function: MakeAlignedString() * * Purpose: Given a raw string of some type (secondary structure, say), * align it to a given aseq by putting gaps wherever the * aseq has gaps. * * Args: aseq: template for alignment * alen: length of aseq * ss: raw string to align to aseq * ret_s: RETURN: aligned ss * * Return: 1 on success, 0 on failure (and squid_errno is set.) * ret_ss is malloc'ed here and must be free'd by caller. */ int MakeAlignedString(char *aseq, int alen, char *ss, char **ret_s) { char *new; int apos, rpos; new = (char *) MallocOrDie ((alen+1) * sizeof(char)); for (apos = rpos = 0; apos < alen; apos++) if (! isgap(aseq[apos])) { new[apos] = ss[rpos]; rpos++; } else new[apos] = '.'; new[apos] = '\0'; if (rpos != strlen(ss)) { squid_errno = SQERR_PARAMETER; free(new); return 0; } *ret_s = new; return 1; } /* Function: MakeDealignedString() * * Purpose: Given an aligned string of some type (either sequence or * secondary structure, for instance), dealign it relative * to a given aseq. Return a ptr to the new string. * * Args: aseq : template alignment * alen : length of aseq * ss: : string to make dealigned copy of; same length as aseq * ret_s : RETURN: dealigned copy of ss * * Return: 1 on success, 0 on failure (and squid_errno is set) * ret_s is alloc'ed here and must be freed by caller */ int MakeDealignedString(char *aseq, int alen, char *ss, char **ret_s) { char *new; int apos, rpos; new = (char *) MallocOrDie ((alen+1) * sizeof(char)); for (apos = rpos = 0; apos < alen; apos++) if (! isgap(aseq[apos])) { new[rpos] = ss[apos]; rpos++; } new[rpos] = '\0'; if (alen != strlen(ss)) { squid_errno = SQERR_PARAMETER; free(new); return 0; } *ret_s = new; return 1; } /* Function: DealignedLength() * * Purpose: Count the number of non-gap symbols in seq. * (i.e. find the length of the unaligned sequence) * * Args: aseq - aligned sequence to count symbols in, \0 terminated * * Return: raw length of seq. */ int DealignedLength(char *aseq) { int rlen; for (rlen = 0; *aseq; aseq++) if (! isgap(*aseq)) rlen++; return rlen; } /* Function: WritePairwiseAlignment() * * Purpose: Write a nice formatted pairwise alignment out, * with a BLAST-style middle line showing identities * as themselves (single letter) and conservative * changes as '+'. * * Args: ofp - open fp to write to (stdout, perhaps) * aseq1, aseq2 - alignments to write (not necessarily * flushed right with gaps) * name1, name2 - names of sequences * spos1, spos2 - starting position in each (raw) sequence * pam - PAM matrix; positive values define * conservative changes * indent - how many extra spaces to print on left * * Return: 1 on success, 0 on failure */ int WritePairwiseAlignment(FILE *ofp, char *aseq1, char *name1, int spos1, char *aseq2, char *name2, int spos2, int **pam, int indent) { char sname1[11]; /* shortened name */ char sname2[11]; int still_going; /* True if writing another block */ char buf1[61]; /* buffer for writing seq1; CPL+1*/ char bufmid[61]; /* buffer for writing consensus */ char buf2[61]; char *s1, *s2; /* ptrs into each sequence */ int count1, count2; /* number of symbols we're writing */ int rpos1, rpos2; /* position in raw seqs */ int rawcount1, rawcount2; /* number of nongap symbols written */ int apos; strncpy(sname1, name1, 10); sname1[10] = '\0'; strtok(sname1, WHITESPACE); strncpy(sname2, name2, 10); sname2[10] = '\0'; strtok(sname2, WHITESPACE); s1 = aseq1; s2 = aseq2; rpos1 = spos1; rpos2 = spos2; still_going = TRUE; while (still_going) { still_going = FALSE; /* get next line's worth from both */ strncpy(buf1, s1, 60); buf1[60] = '\0'; strncpy(buf2, s2, 60); buf2[60] = '\0'; count1 = strlen(buf1); count2 = strlen(buf2); /* is there still more to go? */ if ((count1 == 60 && s1[60] != '\0') || (count2 == 60 && s2[60] != '\0')) still_going = TRUE; /* shift seq ptrs by a line */ s1 += count1; s2 += count2; /* assemble the consensus line */ for (apos = 0; apos < count1 && apos < count2; apos++) { if (!isgap(buf1[apos]) && !isgap(buf2[apos])) { if (buf1[apos] == buf2[apos]) bufmid[apos] = buf1[apos]; else if (pam[buf1[apos] - 'A'][buf2[apos] - 'A'] > 0) bufmid[apos] = '+'; else bufmid[apos] = ' '; } else bufmid[apos] = ' '; } bufmid[apos] = '\0'; rawcount1 = 0; for (apos = 0; apos < count1; apos++) if (!isgap(buf1[apos])) rawcount1++; rawcount2 = 0; for (apos = 0; apos < count2; apos++) if (!isgap(buf2[apos])) rawcount2++; (void) fprintf(ofp, "%*s%-10.10s %5d %s %5d\n", indent, "", sname1, rpos1, buf1, rpos1 + rawcount1 -1); (void) fprintf(ofp, "%*s %s\n", indent, "", bufmid); (void) fprintf(ofp, "%*s%-10.10s %5d %s %5d\n", indent, "", sname2, rpos2, buf2, rpos2 + rawcount2 -1); (void) fprintf(ofp, "\n"); rpos1 += rawcount1; rpos2 += rawcount2; } return 1; } /* Function: MingapAlignment() * * Purpose: Remove all-gap columns from a multiple sequence alignment * and its associated data. The alignment is assumed to be * flushed (all aseqs the same length). */ int MingapAlignment(char **aseqs, AINFO *ainfo) { int apos; /* position in original alignment */ int mpos; /* position in new alignment */ int idx; /* We overwrite aseqs, using its allocated memory. */ for (apos = 0, mpos = 0; aseqs[0][apos] != '\0'; apos++) { /* check for all-gap in column */ for (idx = 0; idx < ainfo->nseq; idx++) if (! isgap(aseqs[idx][apos])) break; if (idx == ainfo->nseq) continue; /* shift alignment and ainfo */ if (mpos != apos) { for (idx = 0; idx < ainfo->nseq; idx++) aseqs[idx][mpos] = aseqs[idx][apos]; if (ainfo->flags & AINFO_CS) ainfo->cs[mpos] = ainfo->cs[apos]; if (ainfo->flags & AINFO_RF) ainfo->rf[mpos] = ainfo->rf[apos]; } mpos++; } /* null terminate everything */ for (idx = 0; idx < ainfo->nseq; idx++) aseqs[idx][mpos] = '\0'; ainfo->alen = mpos; /* set new length */ if (ainfo->flags & AINFO_CS) ainfo->cs[mpos] = '\0'; if (ainfo->flags & AINFO_RF) ainfo->rf[mpos] = '\0'; return 1; } /* Function: RandomAlignment() * * Purpose: Create a random alignment from raw sequences. * * Ideally, we would like to sample an alignment from the * space of possible alignments according to its probability, * given a prior probability distribution for alignments. * I don't see how to describe such a distribution, let alone * sample it. * * This is a rough approximation that tries to capture some * desired properties. We assume the alignment is generated * by a simple HMM composed of match and insert states. * Given parameters (pop, pex) for the probability of opening * and extending an insertion, we can find the expected number * of match states, M, in the underlying model for each sequence. * We use an average M taken over all the sequences (this is * an approximation. The expectation of M given all the sequence * lengths is a nasty-looking summation.) * * M = len / ( 1 + pop ( 1 + 1/ (1-pex) ) ) * * Then, we assign positions in each raw sequence onto the M match * states and M+1 insert states of this "HMM", by rolling random * numbers and inserting the (rlen-M) inserted positions randomly * into the insert slots, taking into account the relative probability * of open vs. extend. * * The resulting alignment has two desired properties: insertions * tend to follow the HMM-like exponential distribution, and * the "sparseness" of the alignment is controllable through * pop and pex. * * Args: rseqs - raw sequences to "align", 0..nseq-1 * sqinfo - array of 0..nseq-1 info structures for the sequences * nseq - number of sequences * pop - probability to open insertion (0 minlen) M = minlen; /* make arrays that count insertions in M+1 possible insert states */ ins = (int **) MallocOrDie (sizeof(int *) * nseq); master_ins = (int *) MallocOrDie (sizeof(int) * (M+1)); for (idx = 0; idx < nseq; idx++) { ins[idx] = (int *) MallocOrDie (sizeof(int) * (M+1)); for (rpos = 0; rpos <= M; rpos++) ins[idx][rpos] = 0; } /* normalize */ pop = pop / (pop+pex); pex = 1.0 - pop; /* make insertions for individual sequences */ for (idx = 0; idx < nseq; idx++) { apos = -1; for (rpos = 0; rpos < rlen[idx]-M; rpos++) { if (sre_random() < pop || apos == -1) /* open insertion */ apos = CHOOSE(M+1); /* choose 0..M */ ins[idx][apos]++; } } /* calculate master_ins, max inserts */ alen = M; for (apos = 0; apos <= M; apos++) { master_ins[apos] = 0; for (idx = 0; idx < nseq; idx++) if (ins[idx][apos] > master_ins[apos]) master_ins[apos] = ins[idx][apos]; alen += master_ins[apos]; } /* Now, construct alignment */ aseqs = (char **) MallocOrDie (sizeof (char *) * nseq); for (idx = 0; idx < nseq; idx++) aseqs[idx] = (char *) MallocOrDie (sizeof(char) * (alen+1)); for (idx = 0; idx < nseq; idx++) { apos = rpos = 0; for (statepos = 0; statepos <= M; statepos++) { for (count = 0; count < ins[idx][statepos]; count++) aseqs[idx][apos++] = rseqs[idx][rpos++]; for (; count < master_ins[statepos]; count++) aseqs[idx][apos++] = ' '; if (statepos != M) aseqs[idx][apos++] = rseqs[idx][rpos++]; } aseqs[idx][alen] = '\0'; } ainfo->flags = 0; ainfo->alen = alen; ainfo->nseq = nseq; ainfo->sqinfo = (SQINFO *) MallocOrDie (sizeof(SQINFO) * nseq); for (idx = 0; idx < nseq; idx++) SeqinfoCopy(&(ainfo->sqinfo[idx]), &(sqinfo[idx])); free(rlen); free(master_ins); Free2DArray(ins, nseq); *ret_aseqs = aseqs; return 1; } wise-2.4.1/src/HMMer2/modelmakers.c0000644000175000001440000007354107313404526016357 0ustar philippusers/* modelmakers.c * SRE, Fri Nov 15 10:00:04 1996 * * Construction of models from multiple alignments. Three versions: * Handmodelmaker() -- use #=RF annotation to indicate match columns * Fastmodelmaker() -- Krogh/Haussler heuristic * Maxmodelmaker() -- MAP model construction algorithm (Eddy, * unpublished) * * The meat of the model construction code is in matassign2hmm(). * The three model construction strategies simply label which columns * are supposed to be match states, and then hand this info to * matassign2hmm(). * * Two wrinkles to watch for: * 1) The alignment is assumed to contain sequence fragments. Look in * fake_tracebacks() for how internal entry/exit points are handled. * 2) Plan7 disallows DI and ID transitions, but an alignment may * imply these. Look in trace_doctor() for how DI and ID transitions * are removed. */ #include #include #include #include #include #include "structs.h" #include "config.h" #include "funcs.h" #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* flags used for matassign[] arrays -- * assignment of aligned columns to match/insert states */ #define ASSIGN_MATCH (1<<0) #define FIRST_MATCH (1<<1) #define LAST_MATCH (1<<2) #define ASSIGN_INSERT (1<<3) #define EXTERNAL_INSERT_N (1<<4) #define EXTERNAL_INSERT_C (1<<5) static int build_cij(char **aseqs, int nseq, int *insopt, int i, int j, float *wgt, float *cij); static int estimate_model_length(AINFO *ainfo, float *wgt, int nseq); static void matassign2hmm(char **aseq, char **dsq, AINFO *ainfo, int *matassign, struct plan7_s **ret_hmm, struct p7trace_s ***ret_tr); static void fake_tracebacks(char **aseq, int nseq, int alen, int *matassign, struct p7trace_s ***ret_tr); static void trace_doctor(struct p7trace_s *tr, int M, int *ret_ndi, int *ret_nid); static void annotate_model(struct plan7_s *hmm, int *matassign, AINFO *ainfo); static void print_matassign(int *matassign, int alen); /* Function: P7Handmodelmaker() * * Purpose: Manual model construction: * Construct an HMM from an alignment, where the #=RF line * of a HMMER alignment file is given to indicate * the columns assigned to matches vs. inserts. * * NOTE: Handmodelmaker() will slightly revise the alignment * if necessary, if the assignment of columns implies * DI and ID transitions. * * Returns both the HMM in counts form (ready for applying * Dirichlet priors as the next step), and fake tracebacks * for each aligned sequence. * * Args: aseq - multiple sequence alignment * dsq - digitized unaligned aseq's * ainfo - optional info with aseq * ret_hmm - RETURN: counts-form HMM * ret_tr - RETURN: array of tracebacks for aseq's * * Return: (void) * ret_hmm and ret_tr alloc'ed here; FreeTrace(tr[i]), free(tr), * FreeHMM(hmm). */ void P7Handmodelmaker(char **aseq, char **dsq, AINFO *ainfo, struct plan7_s **ret_hmm, struct p7trace_s ***ret_tr) { int *matassign; /* MAT state assignments if 1; 1..alen */ int apos; /* counter for aligned columns */ /* Make sure we have all the info about the alignment that we need */ if (! (ainfo->flags & AINFO_RF)) Die("Alignment must have #=RF annotation to hand-build an HMM"); /* Allocation */ matassign = (int *) MallocOrDie (sizeof(int) * (ainfo->alen+1)); /* Determine match assignment from optional annotation */ matassign[0] = 0; for (apos = 0; apos < ainfo->alen; apos++) { matassign[apos+1] = 0; if (!isgap(ainfo->rf[apos])) matassign[apos+1] |= ASSIGN_MATCH; else matassign[apos+1] |= ASSIGN_INSERT; } /* Hand matassign off for remainder of model construction */ /* print_matassign(matassign, ainfo->alen); */ matassign2hmm(aseq, dsq, ainfo, matassign, ret_hmm, ret_tr); free(matassign); return; } /* Function: P7Fastmodelmaker() * * Purpose: Heuristic model construction: * Construct an HMM from an alignment using the original * Krogh/Haussler heuristic; any column with more * symbols in it than a given fraction is assigned to * match. * * NOTE: Fastmodelmaker() will slightly revise the * alignment if the assignment of columns implies * DI and ID transitions. * * Returns the HMM in counts form (ready for applying Dirichlet * priors as the next step). Also returns fake traceback * for each training sequence. * * Args: aseq - multiple sequence alignment to model * dsq - digitized unaligned aseq's * ainfo - optional info with aseq * maxgap - if more gaps than this, column becomes insert. * ret_hmm - RETURN: counts-form HMM * ret_tr - RETURN: array of tracebacks for aseq's * * Return: (void) * ret_hmm and ret_tr alloc'ed here; FreeTrace(tr[i]), free(tr), * FreeHMM(hmm). */ void P7Fastmodelmaker(char **aseq, char **dsq, AINFO *ainfo, float maxgap, struct plan7_s **ret_hmm, struct p7trace_s ***ret_tr) { int *matassign; /* MAT state assignments if 1; 1..alen */ int idx; /* counter over sequences */ int apos; /* counter for aligned columns */ int ngap; /* number of gaps in a column */ /* Allocations: matassign is 1..alen array of bit flags */ matassign = (int *) MallocOrDie (sizeof(int) * (ainfo->alen+1)); /* Determine match assignment by counting symbols in columns */ matassign[0] = 0; for (apos = 0; apos < ainfo->alen; apos++) { matassign[apos+1] = 0; ngap = 0; for (idx = 0; idx < ainfo->nseq; idx++) if (isgap(aseq[idx][apos])) ngap++; if ((float) ngap / (float) ainfo->nseq > maxgap) matassign[apos+1] |= ASSIGN_INSERT; else matassign[apos+1] |= ASSIGN_MATCH; } /* Once we have matassign calculated, all modelmakers behave * the same; matassign2hmm() does this stuff (traceback construction, * trace counting) and sets up ret_hmm and ret_tr. */ matassign2hmm(aseq, dsq, ainfo, matassign, ret_hmm, ret_tr); free(matassign); return; } /* Function: P7Maxmodelmaker() * * Purpose: The Unholy Beast of HMM model construction algorithms -- * maximum a posteriori construction. A tour de force and * probably overkill. MAP construction for Krogh * HMM-profiles is fairly straightforward, but MAP construction of * Plan 7 HMM-profiles is, er, intricate. * * Given a multiple alignment, construct an optimal (MAP) model * architecture. Return a counts-based HMM. * * Args: aseqs - multiple sequence alignment (flush) * dsq - digitized, unaligned seqs * ainfo - optional info about alignment * maxgap - above this, trailing columns are assigned to C * prior - priors on parameters to use for model construction * null - random sequence model emissions * null_p1 - random sequence model p1 transition * mpri - prior on architecture: probability of new match node * ret_hmm - RETURN: new hmm (counts form) * ret_tr - RETURN: array of tracebacks for aseq's * * Return: (void) * ret_hmm and ret_tr (if !NULL) must be free'd by the caller. */ void P7Maxmodelmaker(char **aseqs, char **dsq, AINFO *ainfo, float maxgap, struct p7prior_s *prior, float *null, float null_p1, float mpri, struct plan7_s **ret_hmm, struct p7trace_s ***ret_tr) { int idx; /* counter for seqs */ int i, j; /* positions in alignment */ int x; /* counter for syms or transitions */ float **matc; /* count vectors: [1..alen][0..19] */ float cij[8], tij[8]; /* count and score transit vectors */ float matp[MAXABET]; /* match emission vector */ float insp[MAXABET]; /* insert score vector */ float insc[MAXABET]; /* insert count vector */ float *sc; /* DP scores [0,1..alen,alen+1] */ int *tbck; /* traceback ptrs for sc */ int *matassign; /* match assignments [1..alen] */ int *insopt; /* number of inserted chars [0..nseq-1] */ int first, last; /* positions of first and last cols [1..alen] */ float bm1, bm2; /* estimates for start,internal b->m t's */ int est_M; /* estimate for the size of the model */ float t_me; /* estimate for an internal M->E transition */ float new, bestsc; /* new score, best score so far */ int code; /* optimization: return code from build_cij() */ int ngap; /* gap count in a column */ float wgtsum; /* sum of weights; do not assume it is nseq */ /* Allocations */ matc = (float **) MallocOrDie (sizeof(float *) * (ainfo->alen+1)); sc = (float *) MallocOrDie (sizeof(float) * (ainfo->alen+2)); tbck = (int *) MallocOrDie (sizeof(int) * (ainfo->alen+2)); matassign = (int *) MallocOrDie (sizeof(int) * (ainfo->alen+1)); insopt = (int *) MallocOrDie (sizeof(int) * ainfo->nseq); for (i = 0; i < ainfo->alen; i++) { matc[i+1] = (float *) MallocOrDie (Alphabet_size * sizeof(float)); FSet(matc[i+1], Alphabet_size, 0.); } /* Precalculations */ for (i = 0; i < ainfo->alen; i++) for (idx = 0; idx < ainfo->nseq; idx++) if (!isgap(aseqs[idx][i])) P7CountSymbol(matc[i+1], SymbolIndex(aseqs[idx][i]), ainfo->wgt[idx]); mpri = sreLOG2(mpri); FCopy(insp, prior->i[0], Alphabet_size); FNorm(insp, Alphabet_size); wgtsum = FSum(ainfo->wgt, ainfo->nseq); for (x = 0; x < Alphabet_size; x++) insp[x] = sreLOG2(insp[x] / null[x]); /* Estimate the relevant special transitions. */ est_M = estimate_model_length(ainfo, ainfo->wgt, ainfo->nseq); t_me = 0.5 / (float) (est_M-1); bm1 = 0.5; bm2 = 0.5 / (float) (est_M-1); bm1 = sreLOG2(bm1 / null_p1); bm2 = sreLOG2(bm2 / null_p1); /* Estimate the position of the last match-assigned column * by counting gap frequencies. */ maxgap = 0.5; for (last = ainfo->alen; last >= 1; last--) { ngap = 0; for (idx = 0; idx < ainfo->nseq; idx++) if (isgap(aseqs[idx][last-1])) ngap++; if ((float) ngap / (float) ainfo->nseq <= maxgap) break; } /* Initialization */ sc[last] = 0.; tbck[last] = 0; /* Set ME gaps to '_' */ for (idx = 0; idx < ainfo->nseq; idx++) for (i = last; i > 0 && isgap(aseqs[idx][i-1]); i--) aseqs[idx][i-1] = '_'; /* Main recursion moves from right to left. */ for (i = last-1; i > 0; i--) { /* Calculate match emission scores for i */ FCopy(matp, matc[i], Alphabet_size); P7PriorifyEmissionVector(matp, prior, prior->mnum, prior->mq, prior->m, NULL); for (x = 0; x < Alphabet_size; x++) matp[x] = sreLOG2(matp[x] / null[x]); /* Initialize insert counters to zero */ FSet(insc, Alphabet_size, 0.); for (idx = 0; idx < ainfo->nseq; idx++) insopt[idx] = 0; sc[i] = -FLT_MAX; for (j = i+1; j <= last; j++) { /* build transition matrix for column pair i,j */ code = build_cij(aseqs, ainfo->nseq, insopt, i, j, ainfo->wgt, cij); if (code == -1) break; /* no j to our right can work for us */ if (code == 1) { FCopy(tij, cij, 7); P7PriorifyTransitionVector(tij, prior); FNorm(tij, 3); tij[TMM] = sreLOG2(tij[TMM] / null_p1); tij[TMI] = sreLOG2(tij[TMI] / null_p1); tij[TMD] = sreLOG2(tij[TMD]); tij[TIM] = sreLOG2(tij[TIM] / null_p1); tij[TII] = sreLOG2(tij[TII] / null_p1); tij[TDM] = sreLOG2(tij[TDM] / null_p1); tij[TDD] = sreLOG2(tij[TDD]); /* calculate the score of using this j. */ new = sc[j] + FDot(tij, cij, 7) + FDot(insp, insc, Alphabet_size); /* printf("%3d %3d new=%6.2f m=%6.2f i=%6.2f t=%6.2f\n", i, j, new, FDot(matp, matc[i], Alphabet_size), FDot(insp, insc, Alphabet_size), FDot(tij, cij, 7)); */ /* keep it if it's better */ if (new > sc[i]) { sc[i] = new; tbck[i] = j; } } /* bump insc, insopt insert symbol counters */ FAdd(insc, matc[j], Alphabet_size); for (idx = 0; idx < ainfo->nseq; idx++) if (!isgap(aseqs[idx][j-1])) insopt[idx]++; } /* add in constant contributions for col i */ /* note ad hoc scaling of mpri by wgtsum (us. nseq)*/ sc[i] += FDot(matp, matc[i], Alphabet_size) + mpri * wgtsum; } /* end loop over start positions i */ /* Termination: place the begin state. * log odds score for S->N->B is all zero except for NB transition, which * is a constant. So we only have to evaluate BM transitions. */ bestsc = -FLT_MAX; for (i = 1; i <= last; i++) { new = sc[i]; for (idx = 0; idx < ainfo->nseq; idx++) { if (isgap(aseqs[idx][j-1])) new += bm2; /* internal B->M transition */ else new += bm1; /* B->M1 transition */ } if (new > bestsc) { bestsc = new; first = i; } } /* Traceback */ matassign[0] = 0; for (i = 1; i <= ainfo->alen; i++) matassign[i] = ASSIGN_INSERT; for (i = first; i != 0; i = tbck[i]) { matassign[i] &= ~ASSIGN_INSERT; matassign[i] |= ASSIGN_MATCH; } /* Hand matassign off for remainder of model construction */ /* print_matassign(matassign, ainfo->alen); */ matassign2hmm(aseqs, dsq, ainfo, matassign, ret_hmm, ret_tr); /* Clean up. */ for (i = 1; i <= ainfo->alen; i++) free(matc[i]); free(matc); free(sc); free(tbck); free(matassign); free(insopt); } /* Function: build_cij() * * Purpose: Construct a counts vector for transitions between * column i and column j in a multiple alignment. * * '_' gap characters indicate "external" gaps which * are to be dealt with by B->M and M->E transitions. * These characters must be placed by a preprocessor. * * insopt is an "insert optimization" -- an incrementor * which keeps track of the number of insert symbols * between i and j. * * Args: aseqs - multiple alignment. [0.nseq-1][0.alen-1] * nseq - number of seqs in aseqs * insopt - number of inserts per seq between i/j [0.nseq-1] * i - i column [1.alen], off by one from aseqs * j - j column [1.alen], off by one from aseqs * wgt - per-seq weights [0.nseq-1] * cij - transition count vectors [0..7] * * Return: -1 if an illegal transition was seen for this i/j assignment *and* * we are guaranteed that any j to the right will also * have illegal transitions. * 0 if an illegal transition was seen, but a j further to the * right may work. * 1 if all transitions were legal. */ static int build_cij(char **aseqs, int nseq, int *insopt, int i, int j, float *wgt, float *cij) { int idx; /* counter for seqs */ i--; /* make i,j relative to aseqs [0..alen-1] */ j--; FSet(cij, 8, 0.); /* zero cij */ for (idx = 0; idx < nseq; idx++) { if (insopt[idx] > 0) { if (isgap(aseqs[idx][i])) return -1; /* D->I prohibited. */ if (isgap(aseqs[idx][j])) return 0; /* I->D prohibited. */ cij[TMI] += wgt[idx]; cij[TII] += (insopt[idx]-1) * wgt[idx]; cij[TIM] += wgt[idx]; } else { if (!isgap(aseqs[idx][i])) { if (aseqs[idx][j] == '_') ; /* YO! what to do with trailer? */ else if (isgap(aseqs[idx][j])) cij[TMD] += wgt[idx]; else cij[TMM] += wgt[idx]; } else { /* ignores B->E possibility */ if (aseqs[idx][j] == '_') continue; else if (isgap(aseqs[idx][j])) cij[TDD] += wgt[idx]; else cij[TDM] += wgt[idx]; } } } return 1; } /* Function: estimate_model_length() * * Purpose: Return a decent guess about the length of the model, * based on the lengths of the sequences. * * Algorithm is dumb: use weighted average length. * * Don't assume that weights sum to nseq! */ static int estimate_model_length(AINFO *ainfo, float *wgt, int nseq) { int idx; float total = 0.; float wgtsum = 0.; for (idx = 0; idx < nseq; idx++) { total += wgt[idx] * (float) ainfo->sqinfo[idx].len; wgtsum += wgt[idx]; } return (int) (total / wgtsum); } /* Function: matassign2hmm() * * Purpose: Given an assignment of alignment columns to match vs. * insert, finish the final part of the model construction * calculation that is constant between model construction * algorithms. * * Args: aseq - multiple sequence alignment to model * dsq - digitized unaligned aseq's * ainfo - optional info with aseq * matassign - 1..alen bit flags for column assignments * ret_hmm - RETURN: counts-form HMM * ret_tr - RETURN: array of tracebacks for aseq's * * Return: (void) * ret_hmm and ret_tr alloc'ed here for the calling * modelmaker function. */ void matassign2hmm(char **aseq, char **dsq, AINFO *ainfo, int *matassign, struct plan7_s **ret_hmm, struct p7trace_s ***ret_tr) { struct plan7_s *hmm; /* RETURN: new hmm */ struct p7trace_s **tr; /* fake tracebacks for each seq */ int M; /* length of new model in match states */ int idx; /* counter over sequences */ int apos; /* counter for aligned columns */ /* how many match states in the HMM? */ M = 0; for (apos = 1; apos <= ainfo->alen; apos++) { if (matassign[apos] & ASSIGN_MATCH) M++; } /* delimit N-terminal tail */ for (apos=1; matassign[apos] & ASSIGN_INSERT && apos <= ainfo->alen; apos++) matassign[apos] |= EXTERNAL_INSERT_N; if (apos <= ainfo->alen) matassign[apos] |= FIRST_MATCH; /* delimit C-terminal tail */ for (apos=ainfo->alen; matassign[apos] & ASSIGN_INSERT && apos > 0; apos--) matassign[apos] |= EXTERNAL_INSERT_C; if (apos > 0) matassign[apos] |= LAST_MATCH; /* print_matassign(matassign, ainfo->alen); */ /* make fake tracebacks for each seq */ fake_tracebacks(aseq, ainfo->nseq, ainfo->alen, matassign, &tr); /* build model from tracebacks */ hmm = AllocPlan7(M); ZeroPlan7(hmm); for (idx = 0; idx < ainfo->nseq; idx++) { /* P7PrintTrace(stdout, tr[idx], NULL, NULL); */ P7TraceCount(hmm, dsq[idx], ainfo->wgt[idx], tr[idx]); } /* annotate new model */ annotate_model(hmm, matassign, ainfo); /* Set #=RF line of alignment to reflect our assignment * of match, delete. matassign is valid from 1..alen and is off * by one from ainfo->rf. */ if (ainfo->flags & AINFO_RF) free(ainfo->rf); ainfo->flags |= AINFO_RF; ainfo->rf = (char *) MallocOrDie (sizeof(char) * (ainfo->alen + 1)); for (apos = 0; apos < ainfo->alen; apos++) ainfo->rf[apos] = matassign[apos+1] & ASSIGN_MATCH ? 'x' : '.'; ainfo->rf[ainfo->alen] = '\0'; /* Cleanup and return. */ if (ret_tr != NULL) *ret_tr = tr; else { for (idx = 0; idx < ainfo->nseq; idx++) P7FreeTrace(tr[idx]); free(tr); } if (ret_hmm != NULL) *ret_hmm = hmm; else FreePlan7(hmm); return; } /* Function: fake_tracebacks() * * Purpose: From a consensus assignment of columns to MAT/INS, construct fake * tracebacks for each individual sequence. * * Note: Fragment tolerant by default. Internal entries are * B->M_x, instead of B->D1->D2->...->M_x; analogously * for internal exits. * * Args: aseqs - alignment [0..nseq-1][0..alen-1] * nseq - number of seqs in alignment * alen - length of alignment in columns * matassign - assignment of column; [1..alen] (off one from aseqs) * ret_tr - RETURN: array of tracebacks * * Return: (void) * ret_tr is alloc'ed here. Caller must free. */ static void fake_tracebacks(char **aseq, int nseq, int alen, int *matassign, struct p7trace_s ***ret_tr) { struct p7trace_s **tr; int idx; /* counter over sequences */ int i; /* position in raw sequence (1..L) */ int k; /* position in HMM */ int apos; /* position in alignment columns */ int tpos; /* position in traceback */ tr = (struct p7trace_s **) MallocOrDie (sizeof(struct p7trace_s *) * nseq); for (idx = 0; idx < nseq; idx++) { P7AllocTrace(alen+6, &tr[idx]); /* allow room for S,N,B,E,C,T */ /* all traces start with S state... */ tr[idx]->statetype[0] = STS; tr[idx]->nodeidx[0] = 0; tr[idx]->pos[0] = 0; /* ...and transit to N state; N-term tail is emitted on N->N transitions */ tr[idx]->statetype[1] = STN; tr[idx]->nodeidx[1] = 0; tr[idx]->pos[1] = 0; i = 1; k = 0; tpos = 2; for (apos = 0; apos < alen; apos++) { tr[idx]->statetype[tpos] = STBOGUS; /* bogus, deliberately, to debug */ if (matassign[apos+1] & FIRST_MATCH) { /* BEGIN */ tr[idx]->statetype[tpos] = STB; tr[idx]->nodeidx[tpos] = 0; tr[idx]->pos[tpos] = 0; tpos++; } if (matassign[apos+1] & ASSIGN_MATCH && ! isgap(aseq[idx][apos])) { /* MATCH */ k++; /* move to next model pos */ tr[idx]->statetype[tpos] = STM; tr[idx]->nodeidx[tpos] = k; tr[idx]->pos[tpos] = i; i++; tpos++; } else if (matassign[apos+1] & ASSIGN_MATCH) { /* DELETE */ /* being careful about S/W transitions; no B->D transitions */ k++; /* *always* move on model when ASSIGN_MATCH */ if (tr[idx]->statetype[tpos-1] != STB) { tr[idx]->statetype[tpos] = STD; tr[idx]->nodeidx[tpos] = k; tr[idx]->pos[tpos] = 0; tpos++; } } else if (matassign[apos+1] & EXTERNAL_INSERT_N && ! isgap(aseq[idx][apos])) { /* N-TERMINAL TAIL */ tr[idx]->statetype[tpos] = STN; tr[idx]->nodeidx[tpos] = 0; tr[idx]->pos[tpos] = i; i++; tpos++; } else if (matassign[apos+1] & EXTERNAL_INSERT_C && ! isgap(aseq[idx][apos])) { /* C-TERMINAL TAIL */ tr[idx]->statetype[tpos] = STC; tr[idx]->nodeidx[tpos] = 0; tr[idx]->pos[tpos] = i; i++; tpos++; } else if (! isgap(aseq[idx][apos])) { /* INSERT */ tr[idx]->statetype[tpos] = STI; tr[idx]->nodeidx[tpos] = k; tr[idx]->pos[tpos] = i; i++; tpos++; } if (matassign[apos+1] & LAST_MATCH) { /* END */ /* be careful about S/W transitions; may need to roll * back over some D's because there's no D->E transition */ while (tr[idx]->statetype[tpos-1] == STD) tpos--; tr[idx]->statetype[tpos] = STE; tr[idx]->nodeidx[tpos] = 0; tr[idx]->pos[tpos] = 0; tpos++; /* and then transit E->C; alignments that use J are undefined; C-term tail is emitted on C->C transitions */ tr[idx]->statetype[tpos] = STC; tr[idx]->nodeidx[tpos] = 0; tr[idx]->pos[tpos] = 0; tpos++; } } /* all traces end with T state */ tr[idx]->statetype[tpos] = STT; tr[idx]->nodeidx[tpos] = 0; tr[idx]->pos[tpos] = 0; tr[idx]->tlen = ++tpos; /* deal with DI, ID transitions */ /* k == M here */ trace_doctor(tr[idx], k, NULL, NULL); } /* end for sequence # idx */ *ret_tr = tr; return; } /* Function: trace_doctor() * * Purpose: Plan 7 disallows D->I and I->D "chatter" transitions. * However, these transitions may be implied by many * alignments for hand- or heuristic- built HMMs. * trace_doctor() collapses I->D or D->I into a * single M position in the trace. * Similarly, B->I and I->E transitions may be implied * by an alignment. * * trace_doctor does not examine any scores when it does * this. In ambiguous situations (D->I->D) the symbol * will be pulled arbitrarily to the left, regardless * of whether that's the best column to put it in or not. * * Args: tr - trace to doctor * M - length of model that traces are for * ret_ndi - number of DI transitions doctored * ret_nid - number of ID transitions doctored * * Return: (void) * tr is modified */ static void trace_doctor(struct p7trace_s *tr, int mlen, int *ret_ndi, int *ret_nid) { int opos; /* position in old trace */ int npos; /* position in new trace (<= opos) */ int ndi, nid; /* number of DI, ID transitions doctored */ /* overwrite the trace from left to right */ ndi = nid = 0; opos = npos = 0; while (opos < tr->tlen) { /* fix implied D->I transitions; D transforms to M, I pulled in */ if (tr->statetype[opos] == STD && tr->statetype[opos+1] == STI) { tr->statetype[npos] = STM; tr->nodeidx[npos] = tr->nodeidx[opos]; /* D transforms to M */ tr->pos[npos] = tr->pos[opos+1]; /* insert char moves back */ opos += 2; npos += 1; ndi++; } /* fix implied I->D transitions; D transforms to M, I is pushed in */ else if (tr->statetype[opos]== STI && tr->statetype[opos+1]== STD) { tr->statetype[npos] = STM; tr->nodeidx[npos] = tr->nodeidx[opos+1];/* D transforms to M */ tr->pos[npos] = tr->pos[opos]; /* insert char moves up */ opos += 2; npos += 1; nid++; } /* fix implied B->I transitions; pull I back to its M */ else if (tr->statetype[opos]== STI && tr->statetype[opos-1]== STB) { tr->statetype[npos] = STM; tr->nodeidx[npos] = tr->nodeidx[opos]; /* offending I transforms to M */ tr->pos[npos] = tr->pos[opos]; opos++; npos++; } /* fix implied I->E transitions; push I to next M */ else if (tr->statetype[opos]== STI && tr->statetype[opos+1]== STE) { tr->statetype[npos] = STM; tr->nodeidx[npos] = tr->nodeidx[opos]+1;/* offending I transforms to M */ tr->pos[npos] = tr->pos[opos]; opos++; npos++; } /* rare: N-N-B-E becomes N-B-M_1-E (swap B,N) */ else if (tr->statetype[opos]==STB && tr->statetype[opos+1]==STE && tr->statetype[opos-1]==STN && tr->pos[opos-1] > 0) { tr->statetype[npos] = STM; tr->nodeidx[npos] = 1; tr->pos[npos] = tr->pos[opos-1]; tr->statetype[npos-1] = STB; tr->nodeidx[npos-1] = 0; tr->pos[npos-1] = 0; opos++; npos++; } /* rare: B-E-C-C-x becomes B-M_M-E-C-x (swap E,C) */ else if (tr->statetype[opos]==STE && tr->statetype[opos-1]==STB && tr->statetype[opos+1]==STC && tr->statetype[opos+2]==STC) { tr->statetype[npos] = STM; tr->nodeidx[npos] = mlen; tr->pos[npos] = tr->pos[opos+1]; tr->statetype[npos+1] = STE; tr->nodeidx[npos+1] = 0; tr->pos[npos+1] = 0; tr->statetype[npos+2] = STC; /* first C must be a nonemitter */ tr->nodeidx[npos+2] = 0; tr->pos[npos+2] = 0; opos+=3; npos+=3; } /* everything else is just copied */ else { tr->statetype[npos] = tr->statetype[opos]; tr->nodeidx[npos] = tr->nodeidx[opos]; tr->pos[npos] = tr->pos[opos]; opos++; npos++; } } tr->tlen = npos; if (ret_ndi != NULL) *ret_ndi = ndi; if (ret_nid != NULL) *ret_nid = nid; return; } /* Function: annotate_model() * * Purpose: Add rf, cs optional annotation to a new model. * * Args: hmm - new model * matassign - which alignment columns are MAT; [1..alen] * ainfo - optional alignment annotation * * Return: (void) */ static void annotate_model(struct plan7_s *hmm, int *matassign, AINFO *ainfo) { int apos; /* position in matassign, 1.alen */ int k; /* position in model, 1.M */ /* reference coord annotation */ if (ainfo->flags & AINFO_RF) { hmm->rf[0] = ' '; for (apos = k = 1; apos <= ainfo->alen; apos++) if (matassign[apos] & ASSIGN_MATCH) /* ainfo is off by one from HMM */ hmm->rf[k++] = (ainfo->rf[apos-1] == ' ') ? '.' : ainfo->rf[apos-1]; hmm->rf[k] = '\0'; hmm->flags |= PLAN7_RF; } /* consensus structure annotation */ if (ainfo->flags & AINFO_CS) { hmm->cs[0] = ' '; for (apos = k = 1; apos <= ainfo->alen; apos++) if (matassign[apos] & ASSIGN_MATCH) hmm->cs[k++] = (ainfo->cs[apos-1] == ' ') ? '.' : ainfo->cs[apos-1]; hmm->cs[k] = '\0'; hmm->flags |= PLAN7_CS; } } static void print_matassign(int *matassign, int alen) { int apos; for (apos = 0; apos <= alen; apos++) { printf("%3d %c %c %c\n", apos, (matassign[apos] & ASSIGN_MATCH) ? 'x':' ', (matassign[apos] & FIRST_MATCH || matassign[apos] & LAST_MATCH) ? '<' : ' ', (matassign[apos] & EXTERNAL_INSERT_N || matassign[apos] & EXTERNAL_INSERT_C) ? '|':' '); } } wise-2.4.1/src/HMMer2/cluster.c0000644000175000001440000004204107313404524015522 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* cluster.c * SRE, Sun Jul 18 09:49:47 1993 * moved to squid Thu Mar 3 08:42:57 1994 * almost identical to bord.c, from fd * also now contains routines for constructing difference matrices * from alignments * * "branch ordering": Input a symmetric or upper-right-diagonal * NxN difference matrix (usually constructed by pairwise alignment * and similarity calculations for N sequences). Use the simple * cluster analysis part of the Fitch/Margoliash tree-building algorithm * (as described by Fitch and Margoliash 1967 as well as Feng * and Doolittle 1987) to calculate the topology of an "evolutionary * tree" consistent with the difference matrix. Returns an array * which represents the tree. * * The input difference matrix is just an NxN matrix of floats. * A good match is a small difference score (the algorithm is going * to search for minima among the difference scores). The original difference * matrix remains unchanged by the calculations. * * The output requires some explanation. A phylogenetic * tree is a binary tree, with N "leaves" and N-1 "nodes". The * topology of the tree may be completely described by N-1 structures * containing two pointers; each pointer points to either a leaf * or another node. Here, this is implemented with integer indices * rather than pointers. An array of N-1 pairs of ints is returned. * If the index is in the range (0..N-1), it is a "leaf" -- the * number of one of the sequences. If the index is in the range * (N..2N-2), it is another "node" -- (index-N) is the index * of the node in the returned array. * * If both indices of a member of the returned array point to * nodes, the tree is "compound": composed of more than one * cluster of related sequences. * * The higher-numbered elements of the returned array were the * first constructed, and hence represent the distal tips * of the tree -- the most similar sequences. The root * is node 0. ****************************************************************** * * Algorithm * * INITIALIZATIONS: * - copy the difference matrix (otherwise the caller's copy would * get destroyed by the operations of this algorithm). If * it's asymmetric, make it symmetric. * - make a (0..N-1) array of ints to keep track of the indices in * the difference matrix as they get swapped around. Initialize * this matrix to 0..N-1. * - make a (0..N-2) array of int[2] to store the results (the tree * topology). Doesn't need to be initialized. * - keep track of a "N'", the current size of the difference * matrix being operated on. * * PROCESSING THE DIFFERENCE MATRIX: * - for N' = N down to N' = 2 (N-1 steps): * - in the half-diagonal N'xN' matrix, find the indices i,j at which * there's the minimum difference score * * Store the results: * - at position N'-2 of the result array, store coords[i] and * coords[j]. * * Move i,j rows, cols to the outside edges of the matrix: * - swap row i and row N'-2 * - swap row j and row N'-1 * - swap column i and column N'-2 * - swap column j and column N'-1 * - swap indices i, N'-2 in the index array * - swap indices j, N'-1 in the index array * * Build a average difference score for differences to i,j: * - for all columns, find avg difference between rows i and j and store in row i: * row[i][col] = (row[i][col] + row[j][col]) / 2.0 * - copy the contents of row i to column i (it's a symmetric * matrix, no need to recalculate) * - store an index N'+N-2 at position N'-2 of the index array: means * that this row/column is now a node rather than a leaf, and * contains minimum values * * Continue: * - go to the next N' * * GARBAGE COLLECTION & RETURN. * ********************************************************************** * * References: * * Feng D-F and R.F. Doolittle. "Progressive sequence alignment as a * prerequisite to correct phylogenetic trees." J. Mol. Evol. * 25:351-360, 1987. * * Fitch W.M. and Margoliash E. "Construction of phylogenetic trees." * Science 155:279-284, 1967. * ********************************************************************** * * SRE, 18 March 1992 (bord.c) * SRE, Sun Jul 18 09:52:14 1993 (cluster.c) * added to squid Thu Mar 3 09:13:56 1994 ********************************************************************** * Mon May 4 09:47:02 1992: keep track of difference scores at each node */ #include #include #include #include "squid.h" #include "sqfuncs.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Function: Cluster() * * Purpose: Cluster analysis on a distance matrix. Constructs a * phylogenetic tree which contains the topology * and info for each node: branch lengths, how many * sequences are included under the node, and which * sequences are included under the node. * * Args: dmx - the NxN distance matrix ( >= 0.0, larger means more diverged) * N - size of mx (number of sequences) * mode - CLUSTER_MEAN, CLUSTER_MAX, or CLUSTER_MIN * ret_tree- RETURN: the tree * * Return: 1 on success, 0 on failure. * The caller is responsible for freeing the tree's memory, * by calling FreePhylo(tree, N). */ int Cluster(float **dmx, int N, enum clust_strategy mode, struct phylo_s **ret_tree) { struct phylo_s *tree; /* (0..N-2) phylogenetic tree */ float **mx; /* copy of difference matrix */ int *coord; /* (0..N-1), indices for matrix coords */ int i, j; /* coords of minimum difference */ int idx; /* counter over seqs */ int Np; /* N', a working copy of N */ int row, col; /* loop variables */ float min; /* best minimum score found */ float *trow; /* tmp pointer for swapping rows */ float tcol; /* tmp storage for swapping cols */ float *diff; /* (0..N-2) difference scores at nodes */ int swapfoo; /* for SWAP() macro */ /************************** * Initializations. **************************/ /* We destroy the matrix we work on, so make a copy of dmx. */ if ((mx = (float **) malloc (sizeof(float *) * N)) == NULL) Die("malloc failed"); for (i = 0; i < N; i++) { if ((mx[i] = (float *) malloc (sizeof(float) * N)) == NULL) Die("malloc failed"); for (j = 0; j < N; j++) mx[i][j] = dmx[i][j]; } /* coord array alloc, (0..N-1) */ if ((coord = (int *) malloc (N * sizeof(int))) == NULL || (diff = (float *) malloc ((N-1) * sizeof(float))) == NULL) Die("malloc failed"); /* init the coord array to 0..N-1 */ for (col = 0; col < N; col++) coord[col] = col; for (i = 0; i < N-1; i++) diff[i] = 0.0; /* tree array alloc, (0..N-2) */ if ((tree = AllocPhylo(N)) == NULL) Die("AllocPhylo() failed"); /********************************* * Process the difference matrix *********************************/ /* N-prime, for an NxN down to a 2x2 diffmx */ for (Np = N; Np >= 2; Np--) { /* find a minimum on the N'xN' matrix*/ min = 999999.; for (row = 0; row < Np; row++) for (col = row+1; col < Np; col++) if (mx[row][col] < min) { min = mx[row][col]; i = row; j = col; } /* We're clustering row i with col j. write necessary * data into a node on the tree */ /* topology info */ tree[Np-2].left = coord[i]; tree[Np-2].right = coord[j]; if (coord[i] >= N) tree[coord[i]-N].parent = N + Np - 2; if (coord[j] >= N) tree[coord[j]-N].parent = N + Np - 2; /* keep score info */ diff[Np-2] = tree[Np-2].diff = min; /* way-simple branch length estimation */ tree[Np-2].lblen = tree[Np-2].rblen = min; if (coord[i] >= N) tree[Np-2].lblen -= diff[coord[i]-N]; if (coord[j] >= N) tree[Np-2].rblen -= diff[coord[j]-N]; /* number seqs included at node */ if (coord[i] < N) { tree[Np-2].incnum ++; tree[Np-2].is_in[coord[i]] = 1; } else { tree[Np-2].incnum += tree[coord[i]-N].incnum; for (idx = 0; idx < N; idx++) tree[Np-2].is_in[idx] |= tree[coord[i]-N].is_in[idx]; } if (coord[j] < N) { tree[Np-2].incnum ++; tree[Np-2].is_in[coord[j]] = 1; } else { tree[Np-2].incnum += tree[coord[j]-N].incnum; for (idx = 0; idx < N; idx++) tree[Np-2].is_in[idx] |= tree[coord[j]-N].is_in[idx]; } /* Now build a new matrix, by merging row i with row j and * column i with column j; see Fitch and Margoliash */ /* Row and column swapping. */ /* watch out for swapping i, j away: */ if (i == Np-1 || j == Np-2) SWAP(i,j); if (i != Np-2) { /* swap row i, row N'-2 */ trow = mx[Np-2]; mx[Np-2] = mx[i]; mx[i] = trow; /* swap col i, col N'-2 */ for (row = 0; row < Np; row++) { tcol = mx[row][Np-2]; mx[row][Np-2] = mx[row][i]; mx[row][i] = tcol; } /* swap coord i, coord N'-2 */ SWAP(coord[i], coord[Np-2]); } if (j != Np-1) { /* swap row j, row N'-1 */ trow = mx[Np-1]; mx[Np-1] = mx[j]; mx[j] = trow; /* swap col j, col N'-1 */ for (row = 0; row < Np; row++) { tcol = mx[row][Np-1]; mx[row][Np-1] = mx[row][j]; mx[row][j] = tcol; } /* swap coord j, coord N'-1 */ SWAP(coord[j], coord[Np-1]); } /* average i and j together; they're now at Np-2 and Np-1 though */ i = Np-2; j = Np-1; /* merge by saving avg of cols of row i and row j */ for (col = 0; col < Np; col++) { switch (mode) { case CLUSTER_MEAN: mx[i][col] =(mx[i][col]+ mx[j][col]) / 2.0; break; case CLUSTER_MIN: mx[i][col] = MIN(mx[i][col], mx[j][col]); break; case CLUSTER_MAX: mx[i][col] = MAX(mx[i][col], mx[j][col]); break; default: mx[i][col] =(mx[i][col]+ mx[j][col]) / 2.0; break; } } /* copy those rows to columns */ for (col = 0; col < Np; col++) mx[col][i] = mx[i][col]; /* store the node index in coords */ coord[Np-2] = Np+N-2; } /************************** * Garbage collection and return **************************/ Free2DArray(mx, N); free(coord); free(diff); *ret_tree = tree; return 1; } /* Function: AllocPhylo() * * Purpose: Allocate space for a phylo_s array. N-1 structures * are allocated, one for each node; in each node, a 0..N * is_in flag array is also allocated and initialized to * all zeros. * * Args: N - size; number of sequences being clustered * * Return: pointer to the allocated array * */ struct phylo_s * AllocPhylo(int N) { struct phylo_s *tree; int i; if ((tree = (struct phylo_s *) malloc ((N-1) * sizeof(struct phylo_s))) == NULL) return NULL; for (i = 0; i < N-1; i++) { tree[i].diff = 0.0; tree[i].lblen = tree[i].rblen = 0.0; tree[i].left = tree[i].right = tree[i].parent = -1; tree[i].incnum = 0; if ((tree[i].is_in = (char *) calloc (N, sizeof(char))) == NULL) return NULL; } return tree; } /* Function: FreePhylo() * * Purpose: Free a clustree array that was built to cluster N sequences. * * Args: tree - phylogenetic tree to free * N - size of clustree; number of sequences it clustered * * Return: (void) */ void FreePhylo(struct phylo_s *tree, int N) { int idx; for (idx = 0; idx < N-1; idx++) free(tree[idx].is_in); free(tree); } /* Function: MakeDiffMx() * * Purpose: Given a set of aligned sequences, construct * an NxN fractional difference matrix. (i.e. 1.0 is * completely different, 0.0 is exactly identical). * * Args: aseqs - flushed, aligned sequences * num - number of aseqs * ret_dmx - RETURN: difference matrix * * Return: 1 on success, 0 on failure. * Caller must free diff matrix with FMX2Free(dmx) */ void MakeDiffMx(char **aseqs, int num, float ***ret_dmx) { float **dmx; /* RETURN: distance matrix */ int i,j; /* counters over sequences */ /* Allocate 2D float matrix */ dmx = FMX2Alloc(num, num); /* Calculate distances; symmetric matrix * record difference, not identity (1 - identity) */ for (i = 0; i < num; i++) for (j = i; j < num; j++) dmx[i][j] = dmx[j][i] = 1.0 - PairwiseIdentity(aseqs[i], aseqs[j]); *ret_dmx = dmx; return; } /* Function: MakeIdentityMx() * * Purpose: Given a set of aligned sequences, construct * an NxN fractional identity matrix. (i.e. 1.0 is * completely identical, 0.0 is completely different). * Virtually identical to MakeDiffMx(). It's * less confusing to have two distinct functions, I find. * * Args: aseqs - flushed, aligned sequences * num - number of aseqs * ret_imx - RETURN: identity matrix (caller must free) * * Return: 1 on success, 0 on failure. * Caller must free imx using FMX2Free(imx) */ void MakeIdentityMx(char **aseqs, int num, float ***ret_imx) { float **imx; /* RETURN: identity matrix */ int i,j; /* counters over sequences */ /* Allocate 2D float matrix */ imx = FMX2Alloc(num, num); /* Calculate distances, symmetric matrix */ for (i = 0; i < num; i++) for (j = i; j < num; j++) imx[i][j] = imx[j][i] = PairwiseIdentity(aseqs[i], aseqs[j]); *ret_imx = imx; return; } /* Function: PrintNewHampshireTree() * * Purpose: Print out a tree in the "New Hampshire" standard * format. See PHYLIP's draw.doc for a definition of * the New Hampshire format. * * Like a CFG, we generate the format string left to * right by a preorder tree traversal. * * Args: fp - file to print to * ainfo- alignment info, including sequence names * tree - tree to print * N - number of leaves * */ void PrintNewHampshireTree(FILE *fp, AINFO *ainfo, struct phylo_s *tree, int N) { struct intstack_s *stack; int code; float *blen; int docomma; blen = (float *) MallocOrDie (sizeof(float) * (2*N-1)); stack = InitIntStack(); PushIntStack(stack, N); /* push root on stack */ docomma = FALSE; /* node index code: * 0..N-1 = leaves; indexes of sequences. * N..2N-2 = interior nodes; node-N = index of node in tree structure. * code N is the root. * 2N..3N-2 = special flags for closing interior nodes; node-2N = index in tree */ while (PopIntStack(stack, &code)) { if (code < N) /* we're a leaf. */ { /* 1) print name:branchlength */ if (docomma) fputs(",", fp); fprintf(fp, "%s:%.5f", ainfo->sqinfo[code].name, blen[code]); docomma = TRUE; } else if (code < 2*N) /* we're an interior node */ { /* 1) print a '(' */ if (docomma) fputs(",\n", fp); fputs("(", fp); /* 2) push on stack: ), rchild, lchild */ PushIntStack(stack, code+N); PushIntStack(stack, tree[code-N].right); PushIntStack(stack, tree[code-N].left); /* 3) record branch lengths */ blen[tree[code-N].right] = tree[code-N].rblen; blen[tree[code-N].left] = tree[code-N].lblen; docomma = FALSE; } else /* we're closing an interior node */ { /* print a ):branchlength */ if (code == 2*N) fprintf(fp, ");\n"); else fprintf(fp, "):%.5f", blen[code-N]); docomma = TRUE; } } FreeIntStack(stack); free(blen); return; } /* Function: PrintPhylo() * * Purpose: Debugging output of a phylogenetic tree structure. */ void PrintPhylo(FILE *fp, AINFO *ainfo, struct phylo_s *tree, int N) { int idx; for (idx = 0; idx < N-1; idx++) { fprintf(fp, "Interior node %d (code %d)\n", idx, idx+N); fprintf(fp, "\tParent: %d (code %d)\n", tree[idx].parent-N, tree[idx].parent); fprintf(fp, "\tLeft: %d (%s) %f\n", tree[idx].left < N ? tree[idx].left-N : tree[idx].left, tree[idx].left < N ? ainfo->sqinfo[tree[idx].left].name : "interior", tree[idx].lblen); fprintf(fp, "\tRight: %d (%s) %f\n", tree[idx].right < N ? tree[idx].right-N : tree[idx].right, tree[idx].right < N ? ainfo->sqinfo[tree[idx].right].name : "interior", tree[idx].rblen); fprintf(fp, "\tHeight: %f\n", tree[idx].diff); fprintf(fp, "\tIncludes:%d seqs\n", tree[idx].incnum); } } wise-2.4.1/src/HMMer2/mathsupport.c0000644000175000001440000002106107313404526016430 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1997 Sean R. Eddy * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* mathsupport.c * SRE, Mon Nov 11 15:07:33 1996 * * Miscellaneous mathematical functions. * General functions are in the SQUID library sre_math.c. * These functions are too HMM-specific to warrant being in the * SQUID library. * */ #include #include "funcs.h" #include "config.h" #include "structs.h" #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Function: Prob2Score() * * Purpose: Convert a probability to a scaled integer log_2 odds score. * Round to nearest integer (i.e. note use of +0.5 and floor()) * Return the score. */ int Prob2Score(float p, float null) { if (p == 0.0) return -INFTY; else return (int) floor(0.5 + INTSCALE * sreLOG2(p/null)); } /* Function: Score2Prob() * * Purpose: Convert an integer log_2 odds score back to a probability; * needs the null model probability, if any, to do the conversion. */ float Score2Prob(int sc, float null) { if (sc == -INFTY) return 0.; else return (null * sreEXP2((float) sc / INTSCALE)); } /* Function: Scorify() * * Purpose: Convert a scaled integer log-odds score to a floating * point score for output. (could be a macro but who cares.) */ float Scorify(int sc) { return ((float) sc / INTSCALE); } /* Function: PValue() * Date: SRE, Mon Oct 27 12:21:02 1997 [Sanger Centre, UK] * * Purpose: Convert an HMM score to a P-value. * We know P(S>x) is bounded by 1 / (1 + exp_2^x) for a bit score of x. * We can also use EVD parameters for a tighter bound if we have * them available. * * Args: hmm - model structure, contains EVD parameters * sc - score in bits * * Returns: P value for score significance. */ double PValue(struct plan7_s *hmm, float sc) { double pval; double pval2; /* the bound from Bayes */ pval = 1. / (1.+sreEXP2(sc)); /* try for a better estimate from EVD fit */ if (hmm != NULL && (hmm->flags & PLAN7_STATS)) { pval2 = ExtremeValueP(sc, hmm->mu, hmm->lambda); if (pval2 < pval) pval = pval2; } return pval; } /* Function: LogSum() * * Purpose: Returns the log of the sum of two log probabilities. * log(exp(p1)+exp(p2)) = p1 + log(1 + exp(p2-p1)) for p1 > p2 */ float LogSum(float p1, float p2) { if (p1 > p2) return p1 + log(1. + exp(p2-p1)); else return p2 + log(1. + exp(p1-p2)); } /* Function: ILogsum() * * Purpose: Return the scaled integer log probability of * the sum of two probabilities p1 and p2, where * p1 and p2 are also given as scaled log probabilities. * * log(exp(p1)+exp(p2)) = p1 + log(1 + exp(p2-p1)) for p1 > p2 * * For speed, builds a lookup table the first time it's called. * * Args: p1,p2 -- scaled integer log_2 probabilities to be summed * in probability space. * * Return: scaled integer log_2 probability of the sum. */ int ILogsum(int p1, int p2) { static int firsttime = 1; static int lookup[LOGSUM_TBL]; int diff; int i; if (firsttime) { for (i = 0; i < LOGSUM_TBL; i++) lookup[i] = (int) (INTSCALE * 1.44269504 * (log(1.+exp(0.69314718 * (float) -i/INTSCALE)))); firsttime = 0; } diff = p1-p2; if (diff >= LOGSUM_TBL) return p1; else if (diff <= -LOGSUM_TBL) return p2; else if (diff > 0) return p1 + lookup[diff]; else return p2 + lookup[-diff]; } /* Function: LogNorm() * * Purpose: Normalize a vector of log likelihoods, changing it * to a probability vector. Be careful of overflowing exp(). * Implementation adapted from Graeme Mitchison. * * Args: vec - vector destined to become log probabilities * n - length of vec */ void LogNorm(float *vec, int n) { int x; float max = -1.0e30; float denom = 0.; for (x = 0; x < n; x++) if (vec[x] > max) max = vec[x]; for (x = 0; x < n; x++) if (vec[x] > max - 50.) denom += exp(vec[x] - max); for (x = 0; x < n; x++) if (vec[x] > max - 50.) vec[x] = exp(vec[x] - max) / denom; else vec[x] = 0.0; } /* Function: Logp_cvec() * * Purpose: Calculates ln P(cvec|dirichlet), the log probability of a * count vector given a Dirichlet distribution. Adapted * from an implementation by Graeme Mitchison. * * Args: cvec - count vector * n - length of cvec * alpha - Dirichlet alpha terms * * Return: log P(cvec|dirichlet) */ float Logp_cvec(float *cvec, int n, float *alpha) { float lnp; /* log likelihood of P(cvec | Dirichlet) */ float sum1, sum2, sum3; int x; sum1 = sum2 = sum3 = lnp = 0.0; for (x = 0; x < n; x++) { sum1 += cvec[x] + alpha[x]; sum2 += alpha[x]; sum3 += cvec[x]; lnp += Gammln(alpha[x] + cvec[x]); lnp -= Gammln(cvec[x] + 1.); lnp -= Gammln(alpha[x]); } lnp -= Gammln(sum1); lnp += Gammln(sum2); lnp += Gammln(sum3 + 1.); return lnp; } /* Function: SampleDirichlet() * * Purpose: Given a Dirichlet distribution defined by * a vector of n alpha terms, sample of probability * distribution of dimension n. * * This code was derived from source provided * by Betty Lazareva, from Gary Churchill's group. * * Args: alpha - vector of Dirichlet alphas components * n - number of components * ret_p - RETURN: sampled probability vector. * * Return: (void) * ret_p, an n-dimensional array alloced by the caller, * is filled. */ void SampleDirichlet(float *alpha, int n, float *p) { int x; for (x = 0; x < n; x++) p[x] = SampleGamma(alpha[x]); FNorm(p, n); } /* Function: SampleGamma() * * Purpose: Return a random deviate distributed as Gamma(alpha, 1.0). * Uses two different accept/reject algorithms, one * for 0= 1.0) { /*CONSTCOND*/ while (1) { lambda = sqrt(2.0*alpha -1.0); U = sre_random(); V = U/(1-U); X = alpha * pow(V, 1/lambda); W = .25*exp(-X+alpha)*pow(V,1.0+alpha/lambda)*pow(1.0+1.0/V, 2.0); if (sre_random() <= W) return X; } } else if (alpha > 0.0) { /*CONSTCOND*/ while (1) { U = sre_random(); V = U*(1+ alpha/exp(1.0)); if (V > 1.0) { X = -log( (1-V+alpha/exp(1.0))/alpha); if (sre_random() <= pow(X, alpha-1.0)) return X; } else { X = pow(V,1.0/alpha); if (sre_random() <= exp(-X)) return X; } } } Die("Invalid argument alpha < 0.0 to SampleGamma()"); /*NOTREACHED*/ return 0.0; } /* Function: SampleCountvector() * * Purpose: Given a probability vector p of dimensionality * n, sample c counts and store them in cvec. * cvec is n-dimensional and is alloced by the caller. */ void SampleCountvector(float *p, int n, int c, float *cvec) { int i; FSet(cvec, n, 0.0); for (i = 0; i < c; i++) cvec[FChoose(p,n)] += 1.0; } /* Function: P_PvecGivenDirichlet() * * Purpose: Calculate the log probability of a probability * vector given a single Dirichlet component, alpha. * Follows Sjolander (1996) appendix, lemma 2. * * Return: log P(p | alpha) */ float P_PvecGivenDirichlet(float *p, int n, float *alpha) { float sum; /* for Gammln(|alpha|) in Z */ float logp; /* RETURN: log P(p|alpha) */ int x; sum = logp = 0.0; for (x = 0; x < n; x++) if (p[x] > 0.0) /* any param that is == 0.0 doesn't exist */ { logp += (alpha[x]-1.0) * log(p[x]); logp -= Gammln(alpha[x]); sum += alpha[x]; } logp += Gammln(sum); return logp; } wise-2.4.1/src/HMMer2/types.c0000644000175000001440000000614107313404530015203 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* file: types.c * * Finicky type checkers for strings. Return 1 (TRUE) if ok, 0 elsewise. * Also, finicky type converters (ntohl() and friends) */ #include #include #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Function: IsInt() * * Returns TRUE if s points to something that atoi() will parse * completely and convert to an integer. */ int IsInt(char *s) { int hex = 0; if (s == NULL) {squid_errno = SQERR_PARAMETER; return 0; } /* skip whitespace */ while (isspace(*s)) s++; /* skip leading sign */ if (*s == '-' || *s == '+') s++; /* skip leading conversion signals */ if ((strncmp(s, "0x", 2) == 0 && (int) strlen(s) > 2) || (strncmp(s, "0X", 2) == 0 && (int) strlen(s) > 2)) { s += 2; hex = 1; } else if (*s == '0' && (int) strlen(s) > 1) s++; /* examine remainder for garbage chars */ if (!hex) while (*s != '\0') { if (!isdigit(*s)) return 0; s++; } else while (*s != '\0') { if (!isxdigit(*s)) return 0; s++; } return 1; } /* Function: IsReal() * * Purpose: Returns TRUE if s is a string representation * of a valid floating point number. */ int IsReal(char *s) { int gotdecimal = 0; int gotexp = 0; int gotreal = 0; if (s == NULL) return 0; while (isspace(*s)) s++; /* skip leading whitespace */ if (*s == '-' || *s == '+') s++; /* skip leading sign */ /* Examine remainder for garbage. Allowed one '.' and * one 'e' or 'E'; if both '.' and e/E occur, '.' * must be first. */ while (*s != '\0') { if (isdigit(*s)) gotreal++; else if (*s == '.') { if (gotdecimal) return 0; /* can't have two */ if (gotexp) return 0; /* e/E preceded . */ else gotdecimal++; } else if (*s == 'e' || *s == 'E') { if (gotexp) return 0; /* can't have two */ else gotexp++; } else if (isspace(*s)) break; s++; } while (isspace(*s)) s++; /* skip trailing whitespace */ if (*s == '\0' && gotreal) return 1; else return 0; } /* Function: Byteswap() * * Purpose: Swap between big-endian and little-endian. * For example: * int foo = 0x12345678; * byteswap((char *) &foo, sizeof(int)); * printf("%x\n", foo) * gives 78563412. * * I don't fully understand byte-swapping issues. * However, I have tested this on chars through floats, * on various machines: * SGI IRIX 4.0.5, SunOS 4.1.3, DEC Alpha OSF/1, Alliant * * Date: Sun Feb 12 10:26:22 1995 */ void Byteswap(char *swap, int nbytes) { int x; char byte; for (x = 0; x < nbytes / 2; x++) { byte = swap[nbytes - x - 1]; swap[nbytes - x - 1] = swap[x]; swap[x] = byte; } } wise-2.4.1/src/HMMer2/sqio.c0000644000175000001440000013156507313404527015031 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* File: sqio.c * From: ureadseq.c in Don Gilbert's sequence i/o package * * Reads and writes nucleic/protein sequence in various * formats. Data files may have multiple sequences. * * Heavily modified from READSEQ package * Copyright (C) 1990 by D.G. Gilbert * Biology Dept., Indiana University, Bloomington, IN 47405 * email: gilbertd@bio.indiana.edu * Thanks Don! * * SRE: Modifications as noted. Fri Jul 3 09:44:54 1992 * Packaged for squid, Thu Oct 1 10:07:11 1992 * ANSI conversion in full swing, Mon Jul 12 12:22:21 1993 */ #include #include #include #include #ifndef SEEK_SET #include /* may SunOS rot in hell */ #endif #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif #define kStartLength 500 static char *aminos = "ABCDEFGHIKLMNPQRSTVWXYZ*"; static char *primenuc = "ACGTUN"; static char *protonly = "EFIPQZ"; /* static char stdsymbols[6] = "_.-*?"; */ static char allsymbols[32] = "_.-*?<>{}[]()!@#$%^&=+;:'|`~\"\\"; static char *seqsymbols = allsymbols; /* use general form of isseqchar -- all chars + symbols. no formats except nbrf (?) use symbols in data area as anything other than sequence chars. (wrong. PIR-CODATA does. Remove /) */ void FreeSequence(char *seq, SQINFO *sqinfo) { if (seq != NULL) free(seq); if (sqinfo->flags & SQINFO_SS) free(sqinfo->ss); if (sqinfo->flags & SQINFO_SA) free(sqinfo->sa); } int SetSeqinfoString(SQINFO *sqinfo, char *sptr, int flag) { int len; int pos; while (*sptr == ' ') sptr++; /* ignore leading whitespace */ for (pos = strlen(sptr)-1; pos >= 0; pos--) if (! isspace(sptr[pos])) break; sptr[pos+1] = '\0'; /* ignore trailing whitespace */ switch (flag) { case SQINFO_NAME: if (*sptr != '-') { strncpy(sqinfo->name, sptr, SQINFO_NAMELEN-1); sqinfo->name[SQINFO_NAMELEN-1] = '\0'; sqinfo->flags |= SQINFO_NAME; } break; case SQINFO_ID: if (*sptr != '-') { strncpy(sqinfo->id, sptr, SQINFO_NAMELEN-1); sqinfo->id[SQINFO_NAMELEN-1] = '\0'; sqinfo->flags |= SQINFO_ID; } break; case SQINFO_ACC: if (*sptr != '-') { strncpy(sqinfo->acc, sptr, SQINFO_NAMELEN-1); sqinfo->acc[SQINFO_NAMELEN-1] = '\0'; sqinfo->flags |= SQINFO_ACC; } break; case SQINFO_DESC: if (*sptr != '-') { if (sqinfo->flags & SQINFO_DESC) /* append? */ { len = strlen(sqinfo->desc); if (len < SQINFO_DESCLEN-2) /* is there room? */ { strncat(sqinfo->desc, " ", SQINFO_DESCLEN-1-len); len++; strncat(sqinfo->desc, sptr, SQINFO_DESCLEN-1-len); } } else /* else copy */ strncpy(sqinfo->desc, sptr, SQINFO_DESCLEN-1); sqinfo->desc[SQINFO_DESCLEN-1] = '\0'; sqinfo->flags |= SQINFO_DESC; } break; case SQINFO_START: if (!IsInt(sptr)) { squid_errno = SQERR_FORMAT; return 0; } sqinfo->start = atoi(sptr); if (sqinfo->start != 0) sqinfo->flags |= SQINFO_START; break; case SQINFO_STOP: if (!IsInt(sptr)) { squid_errno = SQERR_FORMAT; return 0; } sqinfo->stop = atoi(sptr); if (sqinfo->stop != 0) sqinfo->flags |= SQINFO_STOP; break; case SQINFO_OLEN: if (!IsInt(sptr)) { squid_errno = SQERR_FORMAT; return 0; } sqinfo->olen = atoi(sptr); if (sqinfo->olen != 0) sqinfo->flags |= SQINFO_OLEN; break; default: Die("Invalid flag %d to SetSeqinfoString()", flag); } return 1; } void SeqinfoCopy(SQINFO *sq1, SQINFO *sq2) { sq1->flags = sq2->flags; if (sq2->flags & SQINFO_NAME) strcpy(sq1->name, sq2->name); if (sq2->flags & SQINFO_ID) strcpy(sq1->id, sq2->id); if (sq2->flags & SQINFO_ACC) strcpy(sq1->acc, sq2->acc); if (sq2->flags & SQINFO_DESC) strcpy(sq1->desc, sq2->desc); if (sq2->flags & SQINFO_LEN) sq1->len = sq2->len; if (sq2->flags & SQINFO_START) sq1->start = sq2->start; if (sq2->flags & SQINFO_STOP) sq1->stop = sq2->stop; if (sq2->flags & SQINFO_OLEN) sq1->olen = sq2->olen; if (sq2->flags & SQINFO_TYPE) sq1->type = sq2->type; if (sq2->flags & SQINFO_SS) sq1->ss = Strdup(sq2->ss); if (sq2->flags & SQINFO_SA) sq1->sa = Strdup(sq2->sa); } /* Function: ToDNA() * * Purpose: Convert a sequence to DNA. * U --> T */ void ToDNA(char *seq) { for (; *seq != '\0'; seq++) { if (*seq == 'U') *seq = 'T'; else if (*seq == 'u') *seq = 't'; } } /* Function: ToRNA() * * Purpose: Convert a sequence to RNA. * T --> U */ void ToRNA(char *seq) { for (; *seq != '\0'; seq++) { if (*seq == 'T') *seq = 'U'; else if (*seq == 't') *seq = 'u'; } } static int isSeqChar(int c) { if (c > 127) return 0; /* IRIX 4.0 bug! isascii(255) returns TRUE */ return (isalpha(c) || strchr(seqsymbols,c)); } static void readline(FILE *f, char *s) { char *cp; if (NULL == fgets(s, LINEBUFLEN, f)) *s = 0; else { cp = strchr(s, '\n'); if (cp != NULL) *cp = 0; } } /* Function: getline() * Date: SRE, Tue Mar 3 08:30:01 1998 [St. Louis] * * Purpose: read a line from a sequence file into V->sbuffer. * If the fgets() is NULL, V->sbuffer is NULL. * Trailing \n is chopped. * If a trailing \n is not there, raise the * lastlinelong flag in V; either we're at EOF or * we have a very long line, over our fgets() buffer * length. * * Args: V * * Returns: (void) */ static void getline(struct ReadSeqVars *V) { char *cp; if (fgets(V->sbuffer, LINEBUFLEN, V->f) == NULL) *(V->sbuffer) = '\0'; else { cp = strchr(V->sbuffer, '\n'); if (cp != NULL) { *cp = '\0'; V->longline = FALSE; } else V->longline = TRUE; } } /* Function: addseq() * * Purpose: Add a line of sequence to the growing string in V. */ static void addseq(char *s, struct ReadSeqVars *V) { while (*s != 0) { if (isSeqChar((int) *s)) { if (*s == '-' && V->dash_equals_n) *s = 'N'; if (V->seqlen >= V->maxseq) { V->maxseq += kStartLength; V->seq = (char*) ReallocOrDie (V->seq, V->maxseq+1); } V->seq[(V->seqlen)++] = *s; } s++; } } static void addstruc(char *s, struct ReadSeqVars *V) { char *sptr; if (! (V->sqinfo->flags & SQINFO_SS)) { V->sqinfo->ss = (char *) MallocOrDie ((V->maxseq+1) * sizeof(char)); V->sqinfo->flags |= SQINFO_SS; sptr = V->sqinfo->ss; } else { V->sqinfo->ss = (char *) ReallocOrDie (V->sqinfo->ss, (V->maxseq+1) * sizeof(char)); sptr = V->sqinfo->ss; while (*sptr != '\0') sptr++; } while (*s != 0) { if (isSeqChar((int)*s)) { *sptr = *s; sptr++; } s++; } *sptr = '\0'; } static void readLoop(int addfirst, int (*endTest)(char *,int *), struct ReadSeqVars *V) { int addend = 0; int done = 0; V->seqlen = 0; if (addfirst) addseq(V->sbuffer, V); do { getline(V); /* feof() alone is a bug; files not necessarily \n terminated */ if (*(V->sbuffer) == '\0' && feof(V->f)) done = TRUE; done |= (*endTest)(V->sbuffer, &addend); if (addend || !done) addseq(V->sbuffer, V); } while (!done); } static int endPIR(char *s, int *addend) { *addend = 0; if ((strncmp(s, "///", 3) == 0) || (strncmp(s, "ENTRY", 5) == 0)) return 1; else return 0; } static void readPIR(struct ReadSeqVars *V) { char *sptr; /* load first line of entry */ while (!feof(V->f) && strncmp(V->sbuffer, "ENTRY", 5) != 0) getline(V); if (feof(V->f)) return; if ((sptr = strtok(V->sbuffer + 15, "\n\t ")) != NULL) { SetSeqinfoString(V->sqinfo, sptr, SQINFO_NAME); SetSeqinfoString(V->sqinfo, sptr, SQINFO_ID); } do { getline(V); if (!feof(V->f) && strncmp(V->sbuffer, "TITLE", 5) == 0) SetSeqinfoString(V->sqinfo, V->sbuffer+15, SQINFO_DESC); else if (!feof(V->f) && strncmp(V->sbuffer, "ACCESSION", 9) == 0) { if ((sptr = strtok(V->sbuffer+15, " \t\n")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_ACC); } } while (! feof(V->f) && (strncmp(V->sbuffer,"SEQUENCE", 8) != 0)); getline(V); /* skip next line, coords */ readLoop(0, endPIR, V); /* reading a real PIR-CODATA database file, we keep the source coords */ V->sqinfo->start = 1; V->sqinfo->stop = V->seqlen; V->sqinfo->olen = V->seqlen; V->sqinfo->flags |= SQINFO_START | SQINFO_STOP | SQINFO_OLEN; /* get next line */ while (!feof(V->f) && strncmp(V->sbuffer, "ENTRY", 5) != 0) getline(V); } static int endIG(char *s, int *addend) { *addend = 1; /* 1 or 2 occur in line w/ bases */ return((strchr(s,'1')!=NULL) || (strchr(s,'2')!=NULL)); } static void readIG(struct ReadSeqVars *V) { char *nm; /* position past ';' comments */ do { getline(V); } while (! (feof(V->f) || ((*V->sbuffer != 0) && (*V->sbuffer != ';')) )); if (!feof(V->f)) { if ((nm = strtok(V->sbuffer, "\n\t ")) != NULL) SetSeqinfoString(V->sqinfo, nm, SQINFO_NAME); readLoop(0, endIG, V); } while (!(feof(V->f) || ((*V->sbuffer != '\0') && (*V->sbuffer == ';')))) getline(V); } static int endStrider(char *s, int *addend) { *addend = 0; return (strstr( s, "//") != NULL); } static void readStrider(struct ReadSeqVars *V) { char *nm; while ((!feof(V->f)) && (*V->sbuffer == ';')) { if (strncmp(V->sbuffer,"; DNA sequence", 14) == 0) { if ((nm = strtok(V->sbuffer+16, ",\n\t ")) != NULL) SetSeqinfoString(V->sqinfo, nm, SQINFO_NAME); } getline(V); } if (! feof(V->f)) readLoop(1, endStrider, V); /* load next line */ while ((!feof(V->f)) && (*V->sbuffer != ';')) getline(V); } static int endGB(char *s, int *addend) { *addend = 0; return ((strstr(s,"//") != NULL) || (strstr(s,"LOCUS") == s)); } static void readGenBank(struct ReadSeqVars *V) { char *sptr; int in_definition; while (strncmp(V->sbuffer, "LOCUS", 5) != 0) getline(V); if ((sptr = strtok(V->sbuffer+12, "\n\t ")) != NULL) { SetSeqinfoString(V->sqinfo, sptr, SQINFO_NAME); SetSeqinfoString(V->sqinfo, sptr, SQINFO_ID); } in_definition = FALSE; while (! feof(V->f)) { getline(V); if (! feof(V->f) && strstr(V->sbuffer, "DEFINITION") == V->sbuffer) { if ((sptr = strtok(V->sbuffer+12, "\n")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_DESC); in_definition = TRUE; } else if (! feof(V->f) && strstr(V->sbuffer, "ACCESSION") == V->sbuffer) { if ((sptr = strtok(V->sbuffer+12, "\n\t ")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_ACC); in_definition = FALSE; } else if (strncmp(V->sbuffer,"ORIGIN", 6) != 0) { if (in_definition) SetSeqinfoString(V->sqinfo, V->sbuffer, SQINFO_DESC); } else break; } readLoop(0, endGB, V); /* reading a real GenBank database file, we keep the source coords */ V->sqinfo->start = 1; V->sqinfo->stop = V->seqlen; V->sqinfo->olen = V->seqlen; V->sqinfo->flags |= SQINFO_START | SQINFO_STOP | SQINFO_OLEN; while (!(feof(V->f) || ((*V->sbuffer!=0) && (strstr(V->sbuffer,"LOCUS") == V->sbuffer)))) getline(V); /* SRE: V->s now holds "//", so sequential reads are wedged: fixed Tue Jul 13 1993 */ while (!feof(V->f) && strstr(V->sbuffer, "LOCUS ") != V->sbuffer) getline(V); } static int endGCGdata(char *s, int *addend) { *addend = 0; return (*s == '>'); } static void readGCGdata(struct ReadSeqVars *V) { int binary = FALSE; /* whether data are binary or not */ int blen; /* length of binary sequence */ /* first line contains ">>>>" followed by name */ if (Strparse(">>>>([^ ]+) .+2BIT +Len: ([0-9]+)", V->sbuffer, 2) == 0) { binary = TRUE; SetSeqinfoString(V->sqinfo, sqd_parse[1], SQINFO_NAME); blen = atoi(sqd_parse[2]); } else if (Strparse(">>>>([^ ]+) .+ASCII +Len: [0-9]+", V->sbuffer, 1) == 0) SetSeqinfoString(V->sqinfo, sqd_parse[1], SQINFO_NAME); else Die("bogus GCGdata format? %s", V->sbuffer); /* second line contains free text description */ getline(V); SetSeqinfoString(V->sqinfo, V->sbuffer, SQINFO_DESC); if (binary) { /* allocate for blen characters +3... (allow for 3 bytes of slop) */ if (blen >= V->maxseq) { V->maxseq = blen; if ((V->seq = (char *) realloc (V->seq, sizeof(char)*(V->maxseq+4)))==NULL) Die("malloc failed"); } /* read (blen+3)/4 bytes from file */ if (fread(V->seq, sizeof(char), (blen+3)/4, V->f) < (size_t) ((blen+3)/4)) Die("fread failed"); V->seqlen = blen; /* convert binary code to seq */ GCGBinaryToSequence(V->seq, blen); } else readLoop(0, endGCGdata, V); while (!(feof(V->f) || ((*V->sbuffer != 0) && (*V->sbuffer == '>')))) getline(V); } static int endPearson(char *s, int *addend) { *addend = 0; return(*s == '>'); } static void readPearson(struct ReadSeqVars *V) { char *sptr; if ((sptr = strtok(V->sbuffer+1, "\n\t ")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_NAME); if ((sptr = strtok(NULL, "\n")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_DESC); /* workaround for long NCBI NR lines */ while (V->longline && ! feof(V->f)) getline(V); readLoop(0, endPearson, V); while (!(feof(V->f) || ((*V->sbuffer != 0) && (*V->sbuffer == '>')))) getline(V); } static int endEMBL(char *s, int *addend) { *addend = 0; /* Some people (Berlin 5S rRNA database, f'r instance) use * an extended EMBL format that attaches extra data after * the sequence -- watch out for that. We use the fact that * real EMBL sequence lines begin with five spaces. * * We can use this as the sole end test because readEMBL() will * advance to the next ID line before starting to read again. */ return (strncmp(s," ",5) != 0); /* return ((strstr(s,"//") != NULL) || (strstr(s,"ID ") == s)); */ } static void readEMBL(struct ReadSeqVars *V) { char *sptr; /* make sure we have first line */ while (!feof(V->f) && strncmp(V->sbuffer, "ID ", 4) != 0) getline(V); if ((sptr = strtok(V->sbuffer+5, "\n\t ")) != NULL) { SetSeqinfoString(V->sqinfo, sptr, SQINFO_NAME); SetSeqinfoString(V->sqinfo, sptr, SQINFO_ID); } do { getline(V); if (!feof(V->f) && strstr(V->sbuffer, "AC ") == V->sbuffer) { if ((sptr = strtok(V->sbuffer+5, "; \t\n")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_ACC); } else if (!feof(V->f) && strstr(V->sbuffer, "DE ") == V->sbuffer) { if ((sptr = strtok(V->sbuffer+5, "\n")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_DESC); } } while (! feof(V->f) && strncmp(V->sbuffer,"SQ",2) != 0); readLoop(0, endEMBL, V); /* reading a real EMBL database file, we keep the source coords */ V->sqinfo->start = 1; V->sqinfo->stop = V->seqlen; V->sqinfo->olen = V->seqlen; V->sqinfo->flags |= SQINFO_START | SQINFO_STOP | SQINFO_OLEN; /* load next record's ID line */ while (!feof(V->f) && strncmp(V->sbuffer, "ID ", 4) != 0) getline(V); } static int endZuker(char *s, int *addend) { *addend = 0; return( *s == '(' ); } static void readZuker(struct ReadSeqVars *V) { char *sptr; getline(V); /*s == "seqLen seqid string..."*/ if ((sptr = strtok(V->sbuffer+6, " \t\n")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_NAME); if ((sptr = strtok(NULL, "\n")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_DESC); readLoop(0, endZuker, V); while (!(feof(V->f) | ((*V->sbuffer != '\0') & (*V->sbuffer == '(')))) getline(V); } static void readUWGCG(struct ReadSeqVars *V) { char *si; char *sptr; int done; V->seqlen = 0; /*writeseq: " %s Length: %d (today) Check: %d ..\n" */ /*drop above or ".." from id*/ if ((si = strstr(V->sbuffer," Length: ")) != NULL) *si = 0; else if ((si = strstr(V->sbuffer,"..")) != NULL) *si = 0; if ((sptr = strtok(V->sbuffer, "\n\t ")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_NAME); do { done = feof(V->f); getline(V); if (! done) addseq(V->sbuffer, V); } while (!done); } static void readSquid(struct ReadSeqVars *V) { char *sptr; int dostruc = FALSE; while (strncmp(V->sbuffer, "NAM ", 4) != 0) getline(V); if ((sptr = strtok(V->sbuffer+4, "\n\t ")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_NAME); /*CONSTCOND*/ while (1) { getline(V); if (feof(V->f)) {squid_errno = SQERR_FORMAT; return; } if (strncmp(V->sbuffer, "SRC ", 4) == 0) { if ((sptr = strtok(V->sbuffer+4, " \t\n")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_ID); if ((sptr = strtok(NULL, " \t\n")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_ACC); if ((sptr = strtok(NULL, ".")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_START); if ((sptr = strtok(NULL, ".:")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_STOP); if ((sptr = strtok(NULL, ": \t\n")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_OLEN); } else if (strncmp(V->sbuffer, "DES ", 4) == 0) { if ((sptr = strtok(V->sbuffer+4, "\n")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_DESC); } else if (strncmp(V->sbuffer,"SEQ", 3) == 0) break; } if (strstr(V->sbuffer, "+SS") != NULL) dostruc = TRUE; V->seqlen = 0; /*CONSTCOND*/ while (1) { /* sequence line */ getline(V); if (feof(V->f) || strncmp(V->sbuffer, "++", 2) == 0) break; addseq(V->sbuffer, V); /* structure line */ if (dostruc) { getline(V); if (feof(V->f)) { squid_errno = SQERR_FORMAT; return; } addstruc(V->sbuffer, V); } } while (!feof(V->f) && strncmp(V->sbuffer, "NAM ", 4) != 0) getline(V); } /* Function: SeqfileOpen() * * Purpose : Open a sequence database file and prepare for reading * sequentially. * * Args: filename - name of file to open * format - format of file * env - environment variable for path (e.g. BLASTDB) * * Returns opened SQFILE ptr, or NULL on failure. */ SQFILE * SeqfileOpen(char *filename, int format, char *env) { SQFILE *dbfp; dbfp = (SQFILE *) MallocOrDie (sizeof(SQFILE)); dbfp->format = format; dbfp->longline = FALSE; /* Open our file handle. * Three possibilities: * 1. normal file open * 2. filename = "-"; read from stdin * 3. filename = "*.gz"; read thru pipe from gzip * If we're reading from stdin or a pipe, we can't reliably * back up, so we can't do two-pass parsers like the interleaved alignment * formats. */ if (strcmp(filename, "-") == 0) { if (IsInterleavedFormat(format)) Die("Can't read interleaved alignment formats thru stdin, sorry"); dbfp->f = stdin; dbfp->do_stdin = TRUE; dbfp->do_gzip = FALSE; } else if (Strparse("^.*\\.gz$", filename, 0) == 0) { char cmd[256]; if (IsInterleavedFormat(format)) Die("Can't read interleaved alignment formats thru gunzip, sorry"); if (strlen(filename) + strlen("gzip -dc ") >= 256) { squid_errno = SQERR_PARAMETER; return NULL; } sprintf(cmd, "gzip -dc %s", filename); if ((dbfp->f = popen(cmd, "r")) == NULL) { squid_errno = SQERR_NOFILE; return NULL; } /* file (or gzip!) doesn't exist */ dbfp->do_stdin = FALSE; dbfp->do_gzip = TRUE; } else { if ((dbfp->f = fopen(filename, "r")) == NULL && (dbfp->f = EnvFileOpen(filename, env)) == NULL) { squid_errno = SQERR_NOFILE; return NULL; } dbfp->do_stdin = FALSE; dbfp->do_gzip = FALSE; } /* The hack for sequential access of an interleaved alignment file: * read the alignment in, we'll copy sequences out one at a time. */ dbfp->ali_aseqs = NULL; if (IsInterleavedFormat(format)) { if (! ReadAlignment(filename, format, &(dbfp->ali_aseqs), &(dbfp->ali_ainfo))) return NULL; dbfp->ali_curridx = 0; return dbfp; } /* Load the first line. */ getline(dbfp); return dbfp; } /* Function: SeqfilePosition() * * Purpose: Move to a particular offset in a seqfile. * Will not work on interleaved files (SELEX, MSF). */ void SeqfilePosition(SQFILE *sqfp, long offset) { if (sqfp->do_stdin || sqfp->do_gzip || IsInterleavedFormat(sqfp->format)) Die("SeqfilePosition() failed: in a nonrewindable data file or stream"); fseek(sqfp->f, offset, SEEK_SET); getline(sqfp); } /* Function: SeqfileRewind() * * Purpose: Set a sequence file back to the first sequence. * How to do this varies with whether the file is an * unaligned file, or an alignment file for which * we're hacking sequential access. */ void SeqfileRewind(SQFILE *sqfp) { if (sqfp->do_stdin || sqfp->do_gzip) Die("SeqfileRewind() failed: in a nonrewindable data file or stream"); if (sqfp->ali_aseqs != NULL) sqfp->ali_curridx = 0; else { rewind(sqfp->f); getline(sqfp); } } void SeqfileClose(SQFILE *sqfp) { /* free static ptrs if we used them */ if (sqfp->ali_aseqs != NULL) FreeAlignment(sqfp->ali_aseqs, &(sqfp->ali_ainfo)); if (sqfp->do_gzip) pclose(sqfp->f); else if (! sqfp->do_stdin) fclose(sqfp->f); free(sqfp); } /* Function: ReadSeq() * * Purpose: Read next sequence from an open database file. * Return the sequence and associated info. * * Args: fp - open sequence database file pointer * format - format of the file (previously determined * by call to SeqfileFormat()) * ret_seq - RETURN: sequence * sqinfo - RETURN: filled in w/ other information * * Return: 1 on success, 0 on failure. * ret_seq and some field of sqinfo are allocated here, * The preferred call mechanism to properly free the memory is: * * SQINFO sqinfo; * char *seq; * * ReadSeq(fp, format, &seq, &sqinfo); * ... do something... * FreeSequence(seq, &sqinfo); */ int ReadSeq(SQFILE *V, int format, char **ret_seq, SQINFO *sqinfo) { int gotuw; int apos, rpos; squid_errno = SQERR_OK; if (format < kMinFormat || format > kMaxFormat) { squid_errno = SQERR_FORMAT; *ret_seq = NULL; return 0; } /* Here's the hack for sequential access of sequences from * the multiple sequence alignment formats */ if (format == kMSF || format == kSelex || format == kClustal) { if (V->ali_curridx >= V->ali_ainfo.nseq) return 0; /* out of aseqs */ SeqinfoCopy(sqinfo, &(V->ali_ainfo.sqinfo[V->ali_curridx])); /* copy and dealign the appropriate aligned seq */ V->seq = MallocOrDie (sizeof(char) * (V->ali_ainfo.alen+1)); for (rpos = apos = 0; apos < V->ali_ainfo.alen; apos++) if (!isgap(V->ali_aseqs[V->ali_curridx][apos])) V->seq[rpos++] = V->ali_aseqs[V->ali_curridx][apos]; V->seq[rpos] = '\0'; V->seqlen = rpos; V->ali_curridx++; } else { if (feof(V->f)) return 0; V->seq = (char*) calloc (kStartLength+1, sizeof(char)); V->maxseq = kStartLength; V->seqlen = 0; V->sqinfo = sqinfo; V->sqinfo->flags = 0; V->dash_equals_n = (format == kEMBL) ? TRUE : FALSE; switch (format) { case kIG : readIG(V); break; case kStrider : readStrider(V); break; case kGenBank : readGenBank(V); break; case kPearson : readPearson(V); break; case kEMBL : readEMBL(V); break; case kZuker : readZuker(V); break; case kPIR : readPIR(V); break; case kSquid : readSquid(V); break; case kGCGdata : readGCGdata(V); break; case kGCG: do { /* skip leading comments on GCG file */ gotuw = (strstr(V->sbuffer,"..") != NULL); if (gotuw) readUWGCG(V); getline(V); } while (! feof(V->f)); break; case kIdraw: /* SRE: no attempt to read idraw postscript */ default: squid_errno = SQERR_FORMAT; free(V->seq); return 0; } V->seq[V->seqlen] = 0; /* stick a string terminator on it */ } /* Cleanup */ sqinfo->len = V->seqlen; sqinfo->flags |= SQINFO_LEN; *ret_seq = V->seq; if (squid_errno == SQERR_OK) return 1; else return 0; } /* Function: SeqfileFormat() * * Purpose: Determine format of seqfile, and return it * through ret_format. From Gilbert's seqFileFormat(). * * If filename is "-", we will read from stdin and * assume that the stream is coming in FASTA format -- * either unaligned or aligned. * * Args: filename - name of sequence file * ret_format - RETURN: format code for file, see squid.h * for codes. * env - name of environment variable containing * a directory path that filename might also be * found in. "BLASTDB", for example. Can be NULL. * * Return: 1 on success, 0 on failure. */ int SeqfileFormat(char *filename, int *ret_format, char *env) { int foundIG = 0; int foundStrider = 0; int foundGB = 0; int foundEMBL = 0; int foundPearson = 0; int foundZuker = 0; int gotGCGdata = 0; int gotPIR = 0; int gotSquid = 0; int gotuw = 0; int gotMSF = 0; int gotClustal = 0; int done = 0; int format = kUnknown; int nlines= 0, dnalines= 0; int splen = 0; char sp[LINEBUFLEN]; FILE *fseq; /* First check if filename is "-": special case indicating * a FASTA pipe. */ if (strcmp(filename, "-") == 0) { *ret_format = kPearson; return 1; } #define ReadOneLine(sp) \ { done |= (feof(fseq)); \ readline( fseq, sp); \ if (!done) { splen = (int) strlen(sp); ++nlines; } } if ((fseq = fopen(filename, "r")) == NULL && (fseq = EnvFileOpen(filename, env)) == NULL) { squid_errno = SQERR_NOFILE; return 0; } /* Look at a line at a time */ while ( !done ) { ReadOneLine(sp); if (sp==NULL || *sp=='\0') /*EMPTY*/ ; /* high probability identities: */ else if (strstr(sp, " MSF:") != NULL && strstr(sp, " Type:") != NULL && strstr(sp, " Check:") != NULL) gotMSF = 1; else if (strncmp(sp, "CLUSTAL ", 8) == 0 && strstr( sp, "multiple sequence alignment")) gotClustal = 1; else if (strstr(sp," Check: ") != NULL) gotuw= 1; else if (strncmp(sp, "///", 3) == 0 || strncmp(sp, "ENTRY ", 6) == 0) gotPIR = 1; else if (strncmp(sp, "++", 2) == 0 || strncmp(sp, "NAM ", 4) == 0) gotSquid = 1; else if (strncmp(sp, ">>>>", 4) == 0 && strstr(sp, "Len: ")) gotGCGdata = 1; /* uncertain identities: */ else if (*sp ==';') { if (strstr(sp,"Strider") !=NULL) foundStrider= 1; else foundIG= 1; } else if (strncmp(sp,"LOCUS",5) == 0 || strncmp(sp,"ORIGIN",5) == 0) foundGB= 1; else if (*sp == '>') { foundPearson = 1; } else if (strstr(sp,"ID ") == sp || strstr(sp,"SQ ") == sp) foundEMBL= 1; else if (*sp == '(') foundZuker= 1; else { switch (Seqtype( sp )) { case kDNA: case kRNA: if (splen>20) dnalines++; break; default: break; } } if (gotMSF) {format = kMSF; done = 1; } else if (gotClustal) {format = kClustal; done = 1; } else if (gotSquid) {format = kSquid; done = 1; } else if (gotPIR) {format = kPIR; done = 1; } else if (gotGCGdata) {format = kGCGdata; done = 1; } else if (gotuw) { if (foundIG) format= kIG; /* a TOIG file from GCG for certain */ else format= kGCG; done= 1; } else if ((dnalines > 1) || done || (nlines > 500)) { /* decide on most likely format */ /* multichar idents: */ if (foundStrider) format= kStrider; else if (foundGB) format= kGenBank; else if (foundEMBL) format= kEMBL; /* single char idents: */ else if (foundIG) format= kIG; else if (foundPearson) format= kPearson; else if (foundZuker) format= kZuker; /* spacing ident: */ else if (IsSELEXFormat(filename)) format= kSelex; /* no format chars: */ else { squid_errno = SQERR_FORMAT; return 0; } done= 1; } } if (fseq!=NULL) fclose(fseq); *ret_format = format; return 1; #undef ReadOneLine } /* Function: GCGBinaryToSequence() * * Purpose: Convert a GCG 2BIT binary string to DNA sequence. * 0 = C 1 = T 2 = A 3 = G * 4 nts/byte * * Args: seq - binary sequence. Converted in place to DNA. * len - length of DNA. binary is (len+3)/4 bytes */ int GCGBinaryToSequence(char *seq, int len) { int bpos; /* position in binary */ int spos; /* position in sequence */ char twobit; int i; for (bpos = (len-1)/4; bpos >= 0; bpos--) { twobit = seq[bpos]; spos = bpos*4; for (i = 3; i >= 0; i--) { switch (twobit & 0x3) { case 0: seq[spos+i] = 'C'; break; case 1: seq[spos+i] = 'T'; break; case 2: seq[spos+i] = 'A'; break; case 3: seq[spos+i] = 'G'; break; } twobit = twobit >> 2; } } seq[len] = '\0'; return 1; } int GCGchecksum(char *seq, int seqlen) { int check = 0, count = 0, i; for (i = 0; i < seqlen; i++) { count++; check += count * sre_toupper((int) seq[i]); if (count == 57) count = 0; } return (check % 10000); } /* Function: GCGMultchecksum() * * Purpose: Simple modification of GCGchecksum(), * to create a checksum for multiple sequences. * Gaps count. * * Args: seqs - sequences to be checksummed * nseq - number of sequences * * Return: the checksum, a number between 0 and 9999 */ int GCGMultchecksum(char **seqs, int nseq) { int check = 0; int count = 0; int idx; char *sptr; for (idx = 0; idx < nseq; idx++) for (sptr = seqs[idx]; *sptr; sptr++) { count++; check += count * sre_toupper((int) *sptr); if (count == 57) count = 0; } return (check % 10000); } /* Function: Seqtype() * * Purpose: Returns a (very good) guess about type of sequence: * kDNA, kRNA, kAmino, or kOtherSeq. * * Modified from, and replaces, Gilbert getseqtype(). */ int Seqtype(char *seq) { int saw; /* how many non-gap characters I saw */ char c; int po = 0; /* count of protein-only */ int nt = 0; /* count of t's */ int nu = 0; /* count of u's */ int na = 0; /* count of nucleotides */ int aa = 0; /* count of amino acids */ int no = 0; /* count of others */ /* Look at the first 300 non-gap characters */ for (saw = 0; *seq != '\0' && saw < 300; seq++) { c = sre_toupper((int) *seq); if (! isgap(c)) { if (strchr(protonly, c)) po++; else if (strchr(primenuc,c)) { na++; if (c == 'T') nt++; else if (c == 'U') nu++; } else if (strchr(aminos,c)) aa++; else if (isalpha(c)) no++; saw++; } } if (no > 0) return kOtherSeq; else if (po > 0) return kAmino; else if (na > aa) { if (nu > nt) return kRNA; else return kDNA; } else return kAmino; } int WriteSeq(FILE *outf, int outform, char *seq, SQINFO *sqinfo) { int numline = 0; int lines = 0, spacer = 0, width = 50, tab = 0; int i, j, l, l1, ibase; char endstr[10]; char s[100]; /* buffer for sequence */ char ss[100]; /* buffer for structure */ int checksum = 0; int seqlen; int which_case; /* 0 = do nothing. 1 = upper case. 2 = lower case */ int dostruc; /* TRUE to print structure lines*/ which_case = 0; dostruc = FALSE; seqlen = (sqinfo->flags & SQINFO_LEN) ? sqinfo->len : strlen(seq); /* intercept Selex-format requests - SRE */ if (outform == kSelex) { fprintf(outf, "%10s %s\n", sqinfo->name, seq); return 1; } if (outform == kClustal || outform == kMSF) { Warn("Tried to write Clustal or MSF with WriteSeq() -- bad, bad."); return 1; } strcpy( endstr,""); l1 = 0; /* 10Nov91: write this out in all possible formats: */ checksum = GCGchecksum(seq, seqlen); switch (outform) { case kUnknown: /* no header, just sequence */ strcpy(endstr,"\n"); /* end w/ extra blank line */ break; case kGenBank: fprintf(outf,"LOCUS %s %d bp\n", (sqinfo->flags & SQINFO_ID) ? sqinfo->id : sqinfo->name, seqlen); fprintf(outf,"DEFINITION %s\n", (sqinfo->flags & SQINFO_DESC) ? sqinfo->desc : "-"); fprintf(outf,"ACCESSION %s\n", (sqinfo->flags & SQINFO_ACC) ? sqinfo->acc : "-"); fprintf(outf,"ORIGIN \n"); spacer = 11; numline = 1; strcpy(endstr, "\n//"); break; case kGCGdata: fprintf(outf, ">>>>%s 9/95 ASCII Len: %d\n", sqinfo->name, seqlen); fprintf(outf, "%s\n", (sqinfo->flags & SQINFO_DESC) ? sqinfo->desc : "-"); break; case kPIR: fprintf(outf, "ENTRY %s\n", (sqinfo->flags & SQINFO_ID) ? sqinfo->id : sqinfo->name); fprintf(outf, "TITLE %s\n", (sqinfo->flags & SQINFO_DESC) ? sqinfo->desc : "-"); fprintf(outf, "ACCESSION %s\n", (sqinfo->flags & SQINFO_ACC) ? sqinfo->acc : "-"); fprintf(outf, "SUMMARY #Length %d #Checksum %d\n", sqinfo->len, checksum); fprintf(outf, "SEQUENCE\n"); fprintf(outf, " 5 10 15 20 25 30\n"); spacer = 2; /* spaces after every residue */ numline = 1; /* number lines w/ coords */ width = 30; /* 30 aa per line */ strcpy(endstr, "\n///"); break; case kSquid: fprintf(outf, "NAM %s\n", sqinfo->name); if (sqinfo->flags & (SQINFO_ID | SQINFO_ACC | SQINFO_START | SQINFO_STOP | SQINFO_OLEN)) fprintf(outf, "SRC %s %s %d..%d::%d\n", (sqinfo->flags & SQINFO_ID) ? sqinfo->id : "-", (sqinfo->flags & SQINFO_ACC) ? sqinfo->acc : "-", (sqinfo->flags & SQINFO_START) ? sqinfo->start : 0, (sqinfo->flags & SQINFO_STOP) ? sqinfo->stop : 0, (sqinfo->flags & SQINFO_OLEN) ? sqinfo->olen : 0); if (sqinfo->flags & SQINFO_DESC) fprintf(outf, "DES %s\n", sqinfo->desc); if (sqinfo->flags & SQINFO_SS) { fprintf(outf, "SEQ +SS\n"); dostruc = TRUE; /* print structure lines too */ } else fprintf(outf, "SEQ\n"); numline = 1; /* number seq lines w/ coords */ strcpy(endstr, "\n++"); break; case kEMBL: fprintf(outf,"ID %s\n", (sqinfo->flags & SQINFO_ID) ? sqinfo->id : sqinfo->name); fprintf(outf,"AC %s\n", (sqinfo->flags & SQINFO_ACC) ? sqinfo->acc : "-"); fprintf(outf,"DE %s\n", (sqinfo->flags & SQINFO_DESC) ? sqinfo->desc : "-"); fprintf(outf,"SQ %d BP\n", seqlen); strcpy(endstr, "\n//"); /* 11Oct90: bug fix*/ tab = 5; /** added 31jan91 */ spacer = 11; /** added 31jan91 */ break; case kGCG: fprintf(outf,"%s\n", sqinfo->name); if (sqinfo->flags & SQINFO_ACC) fprintf(outf,"ACCESSION %s\n", sqinfo->acc); if (sqinfo->flags & SQINFO_DESC) fprintf(outf,"DEFINITION %s\n", sqinfo->desc); fprintf(outf," %s Length: %d (today) Check: %d ..\n", sqinfo->name, seqlen, checksum); spacer = 11; numline = 1; strcpy(endstr, "\n"); /* this is insurance to help prevent misreads at eof */ break; case kStrider: /* ?? map ?*/ fprintf(outf,"; ### from DNA Strider ;-)\n"); fprintf(outf,"; DNA sequence %s, %d bases, %d checksum.\n;\n", sqinfo->name, seqlen, checksum); strcpy(endstr, "\n//"); break; /* SRE: Don had Zuker default to Pearson, which is not intuitive or helpful, since Zuker's MFOLD can't read Pearson format. More useful to use kIG */ case kZuker: which_case = 1; /* MFOLD requires upper case. */ /*FALLTHRU*/ case kIG: fprintf(outf,";%s %s\n", sqinfo->name, (sqinfo->flags & SQINFO_DESC) ? sqinfo->desc : ""); fprintf(outf,"%s\n", sqinfo->name); strcpy(endstr,"1"); /* == linear dna */ break; case kRaw: /* Raw: just print the whole sequence. */ fprintf(outf, "%s\n", seq); return 1; default : case kPearson: fprintf(outf,">%s %s\n", sqinfo->name, (sqinfo->flags & SQINFO_DESC) ? sqinfo->desc : ""); break; } if (which_case == 1) s2upper(seq); if (which_case == 2) s2lower(seq); width = MIN(width,100); for (i=0, l=0, ibase = 1, lines = 0; i < seqlen; ) { if (l1 < 0) l1 = 0; else if (l1 == 0) { if (numline) fprintf(outf,"%8d ",ibase); for (j=0; jflags & SQINFO_SS) ? sqinfo->ss[i] : '.'; l++; i++; l1++; /* don't count spaces for width*/ if (l1 == width || i == seqlen) { s[l] = ss[l] = '\0'; l = 0; l1 = 0; if (dostruc) { fprintf(outf, "%s\n", s); if (numline) fprintf(outf," "); for (j=0; jgsifp = fopen(gsifile, "r")) == NULL) { squid_errno = SQERR_NOFILE; return NULL; } if (! fread(magic, sizeof(char), GSI_KEYSIZE, gsi->gsifp)) { squid_errno = SQERR_NODATA; return NULL; } if (strcmp(magic, "GSI") != 0) { squid_errno = SQERR_FORMAT; return NULL; } if (! fread(&(gsi->nfiles), sizeof(sqd_uint16), 1, gsi->gsifp)) { squid_errno = SQERR_NODATA; return NULL; } if (! fread(&(gsi->recnum), sizeof(sqd_uint32), 1, gsi->gsifp)) { squid_errno = SQERR_NODATA; return NULL; } gsi->nfiles = sre_ntohs(gsi->nfiles); /* convert from network short */ gsi->recnum = sre_ntohl(gsi->recnum); /* convert from network long */ return gsi; } /* Function: GSIGetRecord() * * Purpose: Each non-header record of a GSI index files consists * of 38 bytes: 32 bytes of character string, a 2 byte * short, and a 4 byte long. This function returns the * three values. * * Args: gsi - open GSI index file, correctly positioned at a record * f1 - char[32], allocated by caller (or NULL if unwanted) * f2 - pointer to short (or NULL if unwanted) * f3 - pointer to long (or NULL if unwanted) * * Return: 0 on failure and sets squid_errno. */ static int GSIGetRecord(GSIFILE *gsi, char *f1, sqd_uint16 *f2, sqd_uint32 *f3) { if (f1 == NULL) fseek(gsi->gsifp, GSI_KEYSIZE, SEEK_CUR); else if (! fread(f1, GSI_KEYSIZE, 1, gsi->gsifp)) { squid_errno = SQERR_NODATA; return 0; } if (f2 == NULL) fseek(gsi->gsifp, sizeof(sqd_uint16), SEEK_CUR); else if (! fread(f2, sizeof(sqd_uint16), 1, gsi->gsifp)) { squid_errno = SQERR_NODATA; return 0; } if (f3 == NULL) fseek(gsi->gsifp, sizeof(sqd_uint32), SEEK_CUR); else if (! fread(f3, sizeof(sqd_uint32), 1, gsi->gsifp)) { squid_errno = SQERR_NODATA; return 0; } if (f2 != NULL) *f2 = sre_ntohs(*f2); if (f3 != NULL) *f3 = sre_ntohl(*f3); return 1; } /* Function: GSIGetOffset() * * Purpose: From a key (sequence name), find a disk offset * in an open general sequence index file by binary * search. Presumably GSI indexing could be even faster * if we used hashing. * * Args: gsi - GSI index file, opened by GSIOpen() * key - name of key to retrieve indices for * ret_seqfile - pre-alloced char[32] array for seqfile name * ret_fmt - format of seqfile * ret_offset - return: disk offset in seqfile. */ int GSIGetOffset(GSIFILE *gsi, char *key, char *ret_seqfile, int *ret_format, long *ret_offset) { sqd_uint32 left, right, mid; int cmp; char name[GSI_KEYSIZE + 1]; sqd_uint32 offset; sqd_uint16 filenum; sqd_uint32 fmt; name[GSI_KEYSIZE] = '\0'; left = gsi->nfiles + 1; right = gsi->nfiles + gsi->recnum; mid = (left + right) / 2; fseek(gsi->gsifp, mid * GSI_RECSIZE, SEEK_SET); while (GSIGetRecord(gsi, name, &filenum, &offset)) { cmp = strcmp(name, key); if (cmp == 0) break; /* found it! */ else if (left >= right) return 0; /* oops, missed it; fail. */ else if (cmp < 0) left = mid + 1; /* it's right of mid */ else if (cmp > 0) right = mid - 1; /* it's left of mid */ mid = (left + right) / 2; fseek(gsi->gsifp, mid * GSI_RECSIZE, SEEK_SET); } /* Using file number, look up the sequence file and format. */ fseek(gsi->gsifp, filenum * GSI_RECSIZE, SEEK_SET); GSIGetRecord(gsi, ret_seqfile, NULL, &fmt); *ret_format = (int) fmt; *ret_offset = (long) offset; return 1; } /* Function: GSIClose() * * Purpose: Close an open GSI sequence index file. */ void GSIClose(GSIFILE *gsi) { fclose(gsi->gsifp); free(gsi); } wise-2.4.1/src/HMMer2/alphabet.c0000644000175000001440000002665510670450317015637 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1997 Sean R. Eddy * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* alphabet.c * Configuration of the global symbol alphabet information. */ #include #include #include #include "config.h" #include "structs.h" #include "funcs.h" #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif static void set_degenerate(char iupac, char *syms); /* Function: DetermineAlphabet() * * Purpose: From a set of sequences (raw or aligned), make a good * guess whether they're Nucleic, Amino, or something * else, and set alphabet accordingly. * * If Alphabet_type is already set, that means our * autodetection was overridden from the command line, * and we just set the other globals accordingly. */ void DetermineAlphabet(char **rseqs, int nseq) { int idx; int other, nucleic, amino; /* Autodetection of alphabet type. */ other = nucleic = amino = 0; for (idx = 0; idx < nseq; idx++) { switch (Seqtype(rseqs[idx])) { case kRNA: nucleic++; break; case kDNA: nucleic++; break; case kAmino: amino++; break; case kOtherSeq: other++; break; default: Die("No such alphabet type"); } } if (nucleic == nseq) Alphabet_type = hmmNUCLEIC; else if (amino == nseq) Alphabet_type = hmmAMINO; else if (nucleic > amino && nucleic > other) { Warn("Looks like nucleic acid sequence, hope that's right"); Alphabet_type = hmmNUCLEIC; } else if (amino > nucleic && amino > other) { Warn("Looks like amino acid sequence, hope that's right"); Alphabet_type = hmmAMINO; } else Die("Sorry, I can't tell if that's protein or DNA"); /* Now set up the alphabet. */ SetAlphabet(Alphabet_type); } /* Function: SetAlphabet() * * Purpose: Set the alphabet globals, given an alphabet type * of either hmmAMINO or hmmNUCLEIC. */ void SetAlphabet(int type) { int x; switch(type) { /* Alphabet is not a string - careful! */ case hmmAMINO: Alphabet_type = type; /* Bug fix folded in from sean folded in from HMMER 2.3.1 */ strcpy(Alphabet, "ACDEFGHIKLMNPQRSTVWYBZX"); Alphabet_size = 20; Alphabet_iupac = 23; for (x = 0; x < Alphabet_iupac; x++) { memset(Degenerate[x], 0, Alphabet_size); } for (x = 0; x < Alphabet_size; x++) { Degenerate[x][x] = 1; DegenCount[x] = 1; } set_degenerate('B', "ND"); set_degenerate('Z', "QE"); set_degenerate('X', Alphabet); break; case hmmNUCLEIC: Alphabet_type = type; strncpy(Alphabet, "ACGTUNRYMKSWHBVDX", 17); Alphabet_size = 4; Alphabet_iupac = 17; for (x = 0; x < Alphabet_iupac; x++) { memset(Degenerate[x], 0, Alphabet_size); } for (x = 0; x < Alphabet_size; x++) { Degenerate[x][x] = 1; DegenCount[x] = 1; } set_degenerate('U', "T"); set_degenerate('N', Alphabet); set_degenerate('X', Alphabet); set_degenerate('R', "AG"); set_degenerate('Y', "CT"); set_degenerate('M', "AC"); set_degenerate('K', "GT"); set_degenerate('S', "CG"); set_degenerate('W', "AT"); set_degenerate('H', "ACT"); set_degenerate('B', "CGT"); set_degenerate('V', "ACG"); set_degenerate('D', "AGT"); break; default: Die("No support for non-nucleic or protein alphabets"); } } /* Function: SymbolIndex() * * Purpose: Convert a symbol to its index in Alphabet[]. * Bogus characters are converted to 'X'. * More robust than the SYMIDX() macro but * presumably slower. */ int SymbolIndex(char sym) { char *s; return ((s = strchr(Alphabet, toupper(sym))) == NULL) ? Alphabet_iupac-1 : s - Alphabet; } /* Function: DigitizeSequence() * * Purpose: Internal representation of a sequence in HMMER is * as a char array. 1..L are the indices * of seq symbols in Alphabet[]. 0,L+1 are sentinel * bytes, set to be Alphabet_iupac -- i.e. one more * than the maximum allowed index. * * Assumes that 'X', the fully degenerate character, * is the last character in the allowed alphabet. * * Args: seq - sequence to be digitized (0..L-1) * L - length of sequence * * Return: digitized sequence, dsq. * dsq is allocated here and must be free'd by caller. */ char * DigitizeSequence(char *seq, int L) { char *dsq; int i; dsq = MallocOrDie (sizeof(char) * (L+2)); dsq[0] = dsq[L+1] = (char) Alphabet_iupac; for (i = 1; i <= L; i++) dsq[i] = SymbolIndex(seq[i-1]); return dsq; } /* Function: DedigitizeSequence() * Date: SRE, Tue Dec 16 10:39:19 1997 [StL] * * Purpose: Returns a 0..L-1 character string, converting the * dsq back to the real alphabet. */ char * DedigitizeSequence(char *dsq, int L) { char *seq; int i; seq = MallocOrDie(sizeof(char) * (L+1)); for (i = 0; i < L; i++) seq[i] = Alphabet[(int) dsq[i+1]]; seq[L] = '\0'; return seq; } /* Function: DigitizeAlignment() * * Purpose: Given an alignment, return digitized unaligned * sequence array. (Tracebacks are always relative * to digitized unaligned seqs, even if they are * faked from an existing alignment in modelmakers.c.) * * Args: aseqs - alignment to digitize * ainfo - optional info on alignment * ret_dsqs - RETURN: array of digitized unaligned sequences * * Return: (void) * dsqs is alloced here. Free2DArray(dseqs, nseq). */ void DigitizeAlignment(char **aseqs, AINFO *ainfo, char ***ret_dsqs) { char **dsq; int idx; /* counter for sequences */ int dpos; /* position in digitized seq */ int apos; /* position in aligned seq */ dsq = (char **) MallocOrDie (sizeof(char *) * ainfo->nseq); for (idx = 0; idx < ainfo->nseq; idx++) { dsq[idx] = (char *) MallocOrDie (sizeof(char) * (ainfo->alen+2)); dsq[idx][0] = (char) Alphabet_iupac; /* sentinel byte at start */ for (apos = 0, dpos = 1; apos < ainfo->alen; apos++) { if (! isgap(aseqs[idx][apos])) /* skip gaps */ dsq[idx][dpos++] = SymbolIndex(aseqs[idx][apos]); } dsq[idx][dpos] = (char) Alphabet_iupac; /* sentinel byte at end */ if (! ainfo->sqinfo[idx].flags & SQINFO_LEN) { ainfo->sqinfo[idx].len = dpos - 1; ainfo->sqinfo[idx].flags |= SQINFO_LEN; } } *ret_dsqs = dsq; } /* Function: P7CountSymbol() * * Purpose: Given a possibly degenerate symbol code, increment * a symbol counter array (generally an emission * probability vector in counts form) appropriately. * * Args: counters: vector to count into. [0..Alphabet_size-1] * symidx: symbol index to count: [0..Alphabet_iupac-1] * wt: weight to use for the count; often 1.0 * * Return: (void) */ void P7CountSymbol(float *counters, char symidx, float wt) { int x; if (symidx < Alphabet_size) counters[symidx] += wt; else for (x = 0; x < Alphabet_size; x++) { if (Degenerate[(int) symidx][x]) counters[x] += wt / (float) DegenCount[(int) symidx]; } } /* Function: DefaultGeneticCode() * * Purpose: Configure aacode, mapping triplets to amino acids. * Triplet index: AAA = 0, AAC = 1, ... UUU = 63. * AA index: alphabetical: A=0,C=1... Y=19 * Stop codon: -1. * Uses the stdcode1[] global translation table from SQUID. * * Args: aacode - preallocated 0.63 array for genetic code * * Return: (void) */ void DefaultGeneticCode(int *aacode) { int x; for (x = 0; x < 64; x++) { if (*(stdcode1[x]) == '*') aacode[x] = -1; else aacode[x] = SYMIDX(*(stdcode1[x])); } } /* Function: DefaultCodonBias() * * Purpose: Configure a codonbias table, mapping triplets to * probability of using the triplet for the amino acid * it represents: P(triplet | aa). * The default is to assume codons are used equiprobably. * * Args: codebias: 0..63 array of P(triplet|aa), preallocated. * * Return: (void) */ void DefaultCodonBias(float *codebias) { codebias[0] = 1./2.; /* AAA Lys 2 */ codebias[1] = 1./2.; /* AAC Asn 2 */ codebias[2] = 1./2.; /* AAG Lys 2 */ codebias[3] = 1./2.; /* AAU Asn 2 */ codebias[4] = 1./4.; /* ACA Thr 4 */ codebias[5] = 1./4.; /* ACC Thr 4 */ codebias[6] = 1./4.; /* ACG Thr 4 */ codebias[7] = 1./4.; /* ACU Thr 4 */ codebias[8] = 1./6.; /* AGA Ser 6 */ codebias[9] = 1./6.; /* AGC Arg 6 */ codebias[10] = 1./6.; /* AGG Ser 6 */ codebias[11] = 1./6.; /* AGU Arg 6 */ codebias[12] = 1./3.; /* AUA Ile 3 */ codebias[13] = 1./3.; /* AUC Ile 3 */ codebias[14] = 1.; /* AUG Met 1 */ codebias[15] = 1./3.; /* AUU Ile 3 */ codebias[16] = 1./2.; /* CAA Gln 2 */ codebias[17] = 1./2.; /* CAC His 2 */ codebias[18] = 1./2.; /* CAG Gln 2 */ codebias[19] = 1./2.; /* CAU His 2 */ codebias[20] = 1./4.; /* CCA Pro 4 */ codebias[21] = 1./4.; /* CCC Pro 4 */ codebias[22] = 1./4.; /* CCG Pro 4 */ codebias[23] = 1./4.; /* CCU Pro 4 */ codebias[24] = 1./6.; /* CGA Arg 6 */ codebias[25] = 1./6.; /* CGC Arg 6 */ codebias[26] = 1./6.; /* CGG Arg 6 */ codebias[27] = 1./6.; /* CGU Arg 6 */ codebias[28] = 1./6.; /* CUA Leu 6 */ codebias[29] = 1./6.; /* CUC Leu 6 */ codebias[30] = 1./6.; /* CUG Leu 6 */ codebias[31] = 1./6.; /* CUU Leu 6 */ codebias[32] = 1./2.; /* GAA Glu 2 */ codebias[33] = 1./2.; /* GAC Asp 2 */ codebias[34] = 1./2.; /* GAG Glu 2 */ codebias[35] = 1./2.; /* GAU Asp 2 */ codebias[36] = 1./4.; /* GCA Ala 4 */ codebias[37] = 1./4.; /* GCC Ala 4 */ codebias[38] = 1./4.; /* GCG Ala 4 */ codebias[39] = 1./4.; /* GCU Ala 4 */ codebias[40] = 1./4.; /* GGA Gly 4 */ codebias[41] = 1./4.; /* GGC Gly 4 */ codebias[42] = 1./4.; /* GGG Gly 4 */ codebias[43] = 1./4.; /* GGU Gly 4 */ codebias[44] = 1./4.; /* GUA Val 4 */ codebias[45] = 1./4.; /* GUC Val 4 */ codebias[46] = 1./4.; /* GUG Val 4 */ codebias[47] = 1./4.; /* GUU Val 4 */ codebias[48] = 0.; /* UAA och - */ codebias[49] = 1./2.; /* UAC Tyr 2 */ codebias[50] = 0.; /* UAG amb - */ codebias[51] = 1./2.; /* UAU Tyr 2 */ codebias[52] = 1./6.; /* UCA Ser 6 */ codebias[53] = 1./6.; /* UCC Ser 6 */ codebias[54] = 1./6.; /* UCG Ser 6 */ codebias[55] = 1./6.; /* UCU Ser 6 */ codebias[56] = 0.; /* UGA opa - */ codebias[57] = 1./2.; /* UGC Cys 2 */ codebias[58] = 1.; /* UGG Trp 1 */ codebias[59] = 1./2.; /* UGU Cys 2 */ codebias[60] = 1./6.; /* UUA Leu 6 */ codebias[61] = 1./2.; /* UUC Phe 2 */ codebias[62] = 1./6.; /* UUG Leu 6 */ codebias[63] = 1./2.; /* UUU Phe 2 */ } /* Function: set_degenerate() * * Purpose: convenience function for setting up * Degenerate[][] global for the alphabet. */ static void set_degenerate(char iupac, char *syms) { DegenCount[strchr(Alphabet,iupac)-Alphabet] = strlen(syms); while (*syms) { Degenerate[strchr(Alphabet,iupac)-Alphabet] [strchr(Alphabet,*syms)-Alphabet] = 1; syms++; } } wise-2.4.1/src/HMMer2/hmmemit.c0000644000175000001440000001771007313404525015507 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998, Washington University School of Medicine * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* hmmemit.c * SRE, Sun Mar 8 14:11:24 1998 [St. Louis] * * main() for generating sequences from an HMM * RCS $Id: hmmemit.c,v 1.1.1.1 2001/06/18 13:59:49 birney Exp $ */ #include #include #include #include "structs.h" /* data structures, macros, #define's */ #include "config.h" /* compile-time configuration constants */ #include "funcs.h" /* function declarations */ #include "globals.h" /* alphabet global variables */ #include "squid.h" /* general sequence analysis library */ #ifdef MEMDEBUG #include "dbmalloc.h" #endif static char banner[] = "hmmemit - generate sequences from a profile HMM"; static char usage[] = "\ Usage: hmmemit [-options] \n\ Available options are:\n\ -a : write generated sequences as an alignment, not FASTA\n\ -h : help; print brief help on version and usage\n\ -n : emit sequences (default 10)\n\ -o : save sequences in file \n\ -q : quiet - suppress verbose banner\n\ "; static char experts[] = "\ --seed : set random number seed to \n\ "; static struct opt_s OPTIONS[] = { { "-a", TRUE, sqdARG_NONE }, { "-h", TRUE, sqdARG_NONE }, { "-n", TRUE, sqdARG_INT}, { "-o", TRUE, sqdARG_STRING}, { "-q", TRUE, sqdARG_NONE}, { "--seed", FALSE, sqdARG_INT}, }; #define NOPTIONS (sizeof(OPTIONS) / sizeof(struct opt_s)) int main(int argc, char **argv) { char *hmmfile; /* file to read HMMs from */ FILE *fp; /* output file handle */ HMMFILE *hmmfp; /* opened hmmfile for reading */ struct plan7_s *hmm; /* HMM to generate from */ int L; /* length of a sequence */ int i; /* counter over sequences */ char *ofile; /* output sequence file */ int nseq; /* number of seqs to sample */ int seed; /* random number generator seed */ int be_quiet; /* TRUE to silence header/footer */ int do_alignment;/* TRUE to output in aligned format */ char *optname; /* name of option found by Getopt() */ char *optarg; /* argument found by Getopt() */ int optind; /* index in argv[] */ #ifdef MEMDEBUG unsigned long histid1, histid2, orig_size, current_size; orig_size = malloc_inuse(&histid1); fprintf(stderr, "[... memory debugging is ON ...]\n"); #endif /*********************************************** * Parse command line ***********************************************/ nseq = 10; seed = time ((time_t *) NULL); be_quiet = FALSE; do_alignment = FALSE; ofile = NULL; while (Getopt(argc, argv, OPTIONS, NOPTIONS, usage, &optind, &optname, &optarg)) { if (strcmp(optname, "-a") == 0) do_alignment = TRUE; else if (strcmp(optname, "-n") == 0) nseq = atoi(optarg); else if (strcmp(optname, "-o") == 0) ofile = optarg; else if (strcmp(optname, "-q") == 0) be_quiet = TRUE; else if (strcmp(optname, "--seed") == 0) seed = atoi(optarg); else if (strcmp(optname, "-h") == 0) { Banner(stdout, banner); puts(usage); puts(experts); exit(0); } } if (argc - optind != 1) Die("Incorrect number of arguments.\n%s\n", usage); hmmfile = argv[optind++]; sre_srandom(seed); /*********************************************** * Open HMM file (might be in HMMERDB or current directory). * Read a single HMM from it. ***********************************************/ if ((hmmfp = HMMFileOpen(hmmfile, "HMMERDB")) == NULL) Die("Failed to open HMM file %s\n%s", hmmfile, usage); if (!HMMFileRead(hmmfp, &hmm)) Die("Failed to read any HMMs from %s\n", hmmfile); HMMFileClose(hmmfp); if (hmm == NULL) Die("HMM file %s corrupt or in incorrect format? Parse failed", hmmfile); /* Configure the HMM to shut off N,J,C emission: so we * do a simple single pass through the model. */ Plan7NakedConfig(hmm); Plan7Renormalize(hmm); /*********************************************** * Open the output file, or stdout ***********************************************/ if (ofile == NULL) fp = stdout; else { if ((fp = fopen(ofile, "w")) == NULL) Die("Failed to open output file %s for writing", ofile); } /*********************************************** * Show the options banner ***********************************************/ if (! be_quiet) { Banner(stdout, banner); printf("HMM file: %s\n", hmmfile); printf("Random seed: %d\n", seed); printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n"); } /*********************************************** * Do the work. * If we're generating an alignment, we have to collect * all our traces, then output. If we're generating unaligned * sequences, we can emit one at a time. ***********************************************/ if (do_alignment) { struct p7trace_s **tr; /* traces for aligned sequences */ char **dsq; /* digitized sequences */ SQINFO *sqinfo; /* info about sequences (name/desc) */ char **aseq; /* sequence alignment */ AINFO ainfo; /* optional alignment info */ float *wgt; dsq = MallocOrDie(sizeof(char *) * nseq); tr = MallocOrDie(sizeof(struct p7trace_s *) * nseq); sqinfo = MallocOrDie(sizeof(SQINFO) * nseq); wgt = MallocOrDie(sizeof(float) * nseq); FSet(wgt, nseq, 1.0); for (i = 0; i < nseq; i++) { EmitSequence(hmm, &(dsq[i]), &L, &(tr[i])); sprintf(sqinfo[i].name, "seq%d", i+1); sqinfo[i].len = L; sqinfo[i].flags = SQINFO_NAME | SQINFO_LEN; } P7Traces2Alignment(dsq, sqinfo, wgt, nseq, hmm->M, tr, FALSE, &aseq, &ainfo); /* Output the alignment */ WriteSELEX(fp, aseq, &ainfo, 50); if (ofile != NULL && !be_quiet) printf("Alignment saved in file %s\n", ofile); /* Free memory */ for (i = 0; i < nseq; i++) { P7FreeTrace(tr[i]); free(dsq[i]); } FreeAlignment(aseq, &ainfo); free(sqinfo); free(dsq); free(wgt); free(tr); } else /* unaligned sequence output */ { struct p7trace_s *tr; /* generated trace */ char *dsq; /* digitized sequence */ char *seq; /* alphabetic sequence */ SQINFO sqinfo; /* info about sequence (name/len) */ for (i = 0; i < nseq; i++) { EmitSequence(hmm, &dsq, &L, &tr); sprintf(sqinfo.name, "seq%d", i+1); sqinfo.len = L; sqinfo.flags = SQINFO_NAME | SQINFO_LEN; seq = DedigitizeSequence(dsq, L); WriteSeq(fp, kPearson, seq, &sqinfo); P7FreeTrace(tr); free(dsq); free(seq); } } if (ofile != NULL) fclose(fp); FreePlan7(hmm); SqdClean(); #ifdef MEMDEBUG current_size = malloc_inuse(&histid2); if (current_size != orig_size) malloc_list(2, histid1, histid2); else fprintf(stderr, "[No memory leaks.]\n"); #endif return 0; } wise-2.4.1/src/HMMer2/core_algorithms.c0000644000175000001440000015714207313404524017233 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Washington University School of Medicine * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* core_algorithms.c * SRE, Mon Nov 11 15:58:52 1996 * RCS $Id: core_algorithms.c,v 1.1.1.1 2001/06/18 13:59:48 birney Exp $ * * Simple and robust "research" implementations of Forward, Backward, * and Viterbi for Plan7. */ #include "structs.h" #include "config.h" #include "funcs.h" #include "squid.h" #include #ifdef MEMDEBUG #include "dbmalloc.h" #endif static float get_wee_midpt(struct plan7_s *hmm, char *dsq, int L, int k1, enum p7stype t1, int s1, int k3, enum p7stype t3, int s3, int *ret_k2, enum p7stype *ret_t2, int *ret_s2); /* Function: AllocPlan7Matrix() * * Purpose: Allocate a dynamic programming matrix for standard Forward, * Backward, or Viterbi, with scores kept as scaled log-odds * integers. Keeps 2D arrays compact in RAM in an attempt * to maximize cache hits. Sets up individual ptrs to the * four matrix components as a convenience. * * Args: rows - number of rows to allocate; typically L+1 * M - size of model * xmx, mmx, imx, dmx * - RETURN: ptrs to four mx components as a convenience * * Return: mx * mx is allocated here. Caller frees with FreeDPMatrix(mx). */ struct dpmatrix_s * AllocPlan7Matrix(int rows, int M, int ***xmx, int ***mmx, int ***imx, int ***dmx) { struct dpmatrix_s *mx; int i; mx = (struct dpmatrix_s *) MallocOrDie (sizeof(struct dpmatrix_s)); mx->xmx = (int **) MallocOrDie (sizeof(int *) * rows); mx->mmx = (int **) MallocOrDie (sizeof(int *) * rows); mx->imx = (int **) MallocOrDie (sizeof(int *) * rows); mx->dmx = (int **) MallocOrDie (sizeof(int *) * rows); mx->xmx[0] = (int *) MallocOrDie (sizeof(int) * (rows*5)); mx->mmx[0] = (int *) MallocOrDie (sizeof(int) * (rows*(M+2))); mx->imx[0] = (int *) MallocOrDie (sizeof(int) * (rows*(M+2))); mx->dmx[0] = (int *) MallocOrDie (sizeof(int) * (rows*(M+2))); for (i = 1; i < rows; i++) { mx->xmx[i] = mx->xmx[0] + (i*5); mx->mmx[i] = mx->mmx[0] + (i*(M+2)); mx->imx[i] = mx->imx[0] + (i*(M+2)); mx->dmx[i] = mx->dmx[0] + (i*(M+2)); } if (xmx != NULL) *xmx = mx->xmx; if (mmx != NULL) *mmx = mx->mmx; if (imx != NULL) *imx = mx->imx; if (dmx != NULL) *dmx = mx->dmx; return mx; } /* Function: FreePlan7Matrix() * * Purpose: Free a dynamic programming matrix allocated by AllocPlan7Matrix(). * * Return: (void) */ void FreePlan7Matrix(struct dpmatrix_s *mx) { free (mx->xmx[0]); free (mx->mmx[0]); free (mx->imx[0]); free (mx->dmx[0]); free (mx->xmx); free (mx->mmx); free (mx->imx); free (mx->dmx); free (mx); } /* Function: P7ViterbiSize() * Date: SRE, Fri Mar 6 15:13:20 1998 [St. Louis] * * Purpose: Returns the ballpark predicted memory requirement for a * P7Viterbi() alignment, in MB. * * Args: L - length of sequence * M - length of HMM * * Returns: # of MB */ int P7ViterbiSize(int L, int M) { return ((sizeof(struct dpmatrix_s) + /* matrix structure */ 3 * (L+1) * (M+2) * sizeof(int) + /* main matrix is O(NM) */ 4 * (L+1) * sizeof(int *) + /* ptrs into rows of matrix */ 5 * (L+1) * sizeof(int)) /* 5 special states */ / 1000000); } /* Function: P7SmallViterbiSize() * Date: SRE, Fri Mar 6 15:20:04 1998 [St. Louis] * * Purpose: Returns the ballpark predicted memory requirement for * a P7SmallViterbi() alignment, in MB. * * P7SmallViterbi() is a wrapper, calling both P7ParsingViterbi() * and P7WeeViterbi(). P7ParsingViterbi() typically dominates * the memory requirement, so the value returned * is the P7ParsingViterbi() number. * * Args: L - length of sequence * M - length of HMM * * Returns: # of MB */ int P7SmallViterbiSize(int L, int M) { return ((2 * sizeof(struct dpmatrix_s) + 12 * (M+2) * sizeof(int) + /* 2 matrices w/ 2 rows */ 16 * sizeof(int *) + /* ptrs into rows of matrix */ 20 * sizeof(int) + /* 5 special states */ 2 * (L+1) * sizeof(int)) /* traceback indices */ / 1000000); } /* Function: P7WeeViterbiSize() * Date: SRE, Fri Mar 6 15:40:42 1998 [St. Louis] * * Purpose: Returns the ballpark predicted memory requirement for * a P7WeeViterbi() alignment, in MB. * * Args: L - length of sequence * M - length of HMM * * Returns: # of MB */ int P7WeeViterbiSize(int L, int M) { return ((2 * sizeof(struct dpmatrix_s) + 12 * (M+2) * sizeof(int) + /* 2 matrices w/ 2 rows */ 16 * sizeof(int *) + /* ptrs into rows of matrix */ 20 * sizeof(int) + /* 5 special states */ 2 * (L+2) * sizeof(int) + /* stacks for starts/ends (overkill) */ (L+2) * sizeof(int) + /* k assignments to seq positions */ (L+2) * sizeof(enum p7stype)) /* state assignments to seq positions */ / 1000000); } /* Function: P7Forward() * * Purpose: The Forward dynamic programming algorithm. * The scaling issue is dealt with by working in log space * and calling ILogsum(); this is a slow but robust approach. * * Args: dsq - sequence in digitized form * L - length of dsq * hmm - the model * ret_mx - RETURN: dp matrix; pass NULL if it's not wanted * * Return: log P(S|M)/P(S|R), as a bit score. */ float P7Forward(char *dsq, int L, struct plan7_s *hmm, struct dpmatrix_s **ret_mx) { struct dpmatrix_s *mx; int **xmx; int **mmx; int **imx; int **dmx; int i,k; int sc; /* Allocate a DP matrix with 0..L rows, 0..M-1 columns. */ mx = AllocPlan7Matrix(L+1, hmm->M, &xmx, &mmx, &imx, &dmx); /* Initialization of the zero row. * Note that xmx[i][stN] = 0 by definition for all i, * and xmx[i][stT] = xmx[i][stC], so neither stN nor stT need * to be calculated in DP matrices. */ xmx[0][XMN] = 0; /* S->N, p=1 */ xmx[0][XMB] = hmm->xsc[XTN][MOVE]; /* S->N->B, no N-tail */ xmx[0][XME] = xmx[0][XMC] = xmx[0][XMJ] = -INFTY; /* need seq to get here */ for (k = 0; k <= hmm->M; k++) mmx[0][k] = imx[0][k] = dmx[0][k] = -INFTY; /* need seq to get here */ /* Recursion. Done as a pull. * Note some slightly wasteful boundary conditions: * tsc[0] = -INFTY for all eight transitions (no node 0) * D_M and I_M are wastefully calculated (they don't exist) */ for (i = 1; i <= L; i++) { mmx[i][0] = imx[i][0] = dmx[i][0] = -INFTY; for (k = 1; k < hmm->M; k++) { mmx[i][k] = ILogsum(ILogsum(mmx[i-1][k-1] + hmm->tsc[k-1][TMM], imx[i-1][k-1] + hmm->tsc[k-1][TIM]), ILogsum(xmx[i-1][XMB] + hmm->bsc[k], dmx[i-1][k-1] + hmm->tsc[k-1][TDM])); mmx[i][k] += hmm->msc[(int) dsq[i]][k]; dmx[i][k] = ILogsum(mmx[i][k-1] + hmm->tsc[k-1][TMD], dmx[i][k-1] + hmm->tsc[k-1][TDD]); imx[i][k] = ILogsum(mmx[i-1][k] + hmm->tsc[k][TMI], imx[i-1][k] + hmm->tsc[k][TII]); imx[i][k] += hmm->isc[(int) dsq[i]][k]; } mmx[i][hmm->M] = ILogsum(ILogsum(mmx[i-1][hmm->M-1] + hmm->tsc[hmm->M-1][TMM], imx[i-1][hmm->M-1] + hmm->tsc[hmm->M-1][TIM]), ILogsum(xmx[i-1][XMB] + hmm->bsc[hmm->M-1], dmx[i-1][hmm->M-1] + hmm->tsc[hmm->M-1][TDM])); mmx[i][hmm->M] += hmm->msc[(int) dsq[i]][hmm->M]; /* Now the special states. * remember, C and J emissions are zero score by definition */ xmx[i][XMN] = xmx[i-1][XMN] + hmm->xsc[XTN][LOOP]; xmx[i][XME] = -INFTY; for (k = 1; k <= hmm->M; k++) xmx[i][XME] = ILogsum(xmx[i][XME], mmx[i][k] + hmm->esc[k]); xmx[i][XMJ] = ILogsum(xmx[i-1][XMJ] + hmm->xsc[XTJ][LOOP], xmx[i][XME] + hmm->xsc[XTE][LOOP]); xmx[i][XMB] = ILogsum(xmx[i][XMN] + hmm->xsc[XTN][MOVE], xmx[i][XMJ] + hmm->xsc[XTJ][MOVE]); xmx[i][XMC] = ILogsum(xmx[i-1][XMC] + hmm->xsc[XTC][LOOP], xmx[i][XME] + hmm->xsc[XTE][MOVE]); } sc = xmx[L][XMC] + hmm->xsc[XTC][MOVE]; if (ret_mx != NULL) *ret_mx = mx; else FreePlan7Matrix(mx); return Scorify(sc); /* the total Forward score. */ } /* Function: P7Viterbi() * * Purpose: The Viterbi dynamic programming algorithm. * Identical to Forward() except that max's * replace sum's. * * Args: dsq - sequence in digitized form * L - length of dsq * hmm - the model * ret_tr - RETURN: traceback; pass NULL if it's not wanted * * Return: log P(S|M)/P(S|R), as a bit score */ float P7Viterbi(char *dsq, int L, struct plan7_s *hmm, struct p7trace_s **ret_tr) { struct dpmatrix_s *mx; struct p7trace_s *tr; int **xmx; int **mmx; int **imx; int **dmx; int i,k; int sc; /* Allocate a DP matrix with 0..L rows, 0..M-1 columns. */ mx = AllocPlan7Matrix(L+1, hmm->M, &xmx, &mmx, &imx, &dmx); /* Initialization of the zero row. */ xmx[0][XMN] = 0; /* S->N, p=1 */ xmx[0][XMB] = hmm->xsc[XTN][MOVE]; /* S->N->B, no N-tail */ xmx[0][XME] = xmx[0][XMC] = xmx[0][XMJ] = -INFTY; /* need seq to get here */ for (k = 0; k <= hmm->M; k++) mmx[0][k] = imx[0][k] = dmx[0][k] = -INFTY; /* need seq to get here */ /* Recursion. Done as a pull. * Note some slightly wasteful boundary conditions: * tsc[0] = -INFTY for all eight transitions (no node 0) * D_M and I_M are wastefully calculated (they don't exist) */ for (i = 1; i <= L; i++) { mmx[i][0] = imx[i][0] = dmx[i][0] = -INFTY; for (k = 1; k <= hmm->M; k++) { /* match state */ mmx[i][k] = -INFTY; if ((sc = mmx[i-1][k-1] + hmm->tsc[k-1][TMM]) > mmx[i][k]) mmx[i][k] = sc; if ((sc = imx[i-1][k-1] + hmm->tsc[k-1][TIM]) > mmx[i][k]) mmx[i][k] = sc; if ((sc = xmx[i-1][XMB] + hmm->bsc[k]) > mmx[i][k]) mmx[i][k] = sc; if ((sc = dmx[i-1][k-1] + hmm->tsc[k-1][TDM]) > mmx[i][k]) mmx[i][k] = sc; if (hmm->msc[(int) dsq[i]][k] != -INFTY) mmx[i][k] += hmm->msc[(int) dsq[i]][k]; else mmx[i][k] = -INFTY; /* delete state */ dmx[i][k] = -INFTY; if ((sc = mmx[i][k-1] + hmm->tsc[k-1][TMD]) > dmx[i][k]) dmx[i][k] = sc; if ((sc = dmx[i][k-1] + hmm->tsc[k-1][TDD]) > dmx[i][k]) dmx[i][k] = sc; /* insert state */ if (k < hmm->M) { imx[i][k] = -INFTY; if ((sc = mmx[i-1][k] + hmm->tsc[k][TMI]) > imx[i][k]) imx[i][k] = sc; if ((sc = imx[i-1][k] + hmm->tsc[k][TII]) > imx[i][k]) imx[i][k] = sc; if (hmm->isc[(int)dsq[i]][k] != -INFTY) imx[i][k] += hmm->isc[(int) dsq[i]][k]; else imx[i][k] = -INFTY; } } /* Now the special states. Order is important here. * remember, C and J emissions are zero score by definition, */ /* N state */ xmx[i][XMN] = -INFTY; if ((sc = xmx[i-1][XMN] + hmm->xsc[XTN][LOOP]) > -INFTY) xmx[i][XMN] = sc; /* E state */ xmx[i][XME] = -INFTY; for (k = 1; k <= hmm->M; k++) if ((sc = mmx[i][k] + hmm->esc[k]) > xmx[i][XME]) xmx[i][XME] = sc; /* J state */ xmx[i][XMJ] = -INFTY; if ((sc = xmx[i-1][XMJ] + hmm->xsc[XTJ][LOOP]) > -INFTY) xmx[i][XMJ] = sc; if ((sc = xmx[i][XME] + hmm->xsc[XTE][LOOP]) > xmx[i][XMJ]) xmx[i][XMJ] = sc; /* B state */ xmx[i][XMB] = -INFTY; if ((sc = xmx[i][XMN] + hmm->xsc[XTN][MOVE]) > -INFTY) xmx[i][XMB] = sc; if ((sc = xmx[i][XMJ] + hmm->xsc[XTJ][MOVE]) > xmx[i][XMB]) xmx[i][XMB] = sc; /* C state */ xmx[i][XMC] = -INFTY; if ((sc = xmx[i-1][XMC] + hmm->xsc[XTC][LOOP]) > -INFTY) xmx[i][XMC] = sc; if ((sc = xmx[i][XME] + hmm->xsc[XTE][MOVE]) > xmx[i][XMC]) xmx[i][XMC] = sc; } /* T state (not stored) */ sc = xmx[L][XMC] + hmm->xsc[XTC][MOVE]; if (ret_tr != NULL) { P7ViterbiTrace(hmm, dsq, L, mx, &tr); *ret_tr = tr; } FreePlan7Matrix(mx); return Scorify(sc); /* the total Viterbi score. */ } /* Function: P7ViterbiTrace() * Date: SRE, Sat Aug 23 10:30:11 1997 (St. Louis Lambert Field) * * Purpose: Traceback of a Viterbi matrix: i.e. retrieval * of optimum alignment. * * Args: hmm - hmm, log odds form, used to make mx * dsq - sequence aligned to (digital form) 1..N * N - length of seq * mx - the matrix to trace back in, N x hmm->M * ret_tr - RETURN: traceback. * * Return: (void) * ret_tr is allocated here. Free using P7FreeTrace(). */ void P7ViterbiTrace(struct plan7_s *hmm, char *dsq, int N, struct dpmatrix_s *mx, struct p7trace_s **ret_tr) { struct p7trace_s *tr; int curralloc; /* current allocated length of trace */ int tpos; /* position in trace */ int i; /* position in seq (1..N) */ int k; /* position in model (1..M) */ int **xmx, **mmx, **imx, **dmx; int sc; /* temp var for pre-emission score */ /* Overallocate for the trace. * S-N-B- ... - E-C-T : 6 states + N is minimum trace; * add N more as buffer. */ curralloc = N * 2 + 6; P7AllocTrace(curralloc, &tr); xmx = mx->xmx; mmx = mx->mmx; imx = mx->imx; dmx = mx->dmx; /* Initialization of trace * We do it back to front; ReverseTrace() is called later. */ tr->statetype[0] = STT; tr->nodeidx[0] = 0; tr->pos[0] = 0; tr->statetype[1] = STC; tr->nodeidx[1] = 0; tr->pos[1] = 0; tpos = 2; i = N; /* current i (seq pos) we're trying to assign */ /* Traceback */ while (tr->statetype[tpos-1] != STS) { switch (tr->statetype[tpos-1]) { case STM: /* M connects from i-1,k-1, or B */ sc = mmx[i+1][k+1] - hmm->msc[(int) dsq[i+1]][k+1]; if (sc == xmx[i][XMB] + hmm->bsc[k+1]) { /* Check for wing unfolding */ if (Prob2Score(hmm->begin[k+1], hmm->p1) + 1 * INTSCALE <= hmm->bsc[k+1]) while (k > 0) { tr->statetype[tpos] = STD; tr->nodeidx[tpos] = k--; tr->pos[tpos] = 0; tpos++; if (tpos == curralloc) { /* grow trace if necessary */ curralloc += N; P7ReallocTrace(tr, curralloc); } } tr->statetype[tpos] = STB; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; } else if (sc == mmx[i][k] + hmm->tsc[k][TMM]) { tr->statetype[tpos] = STM; tr->nodeidx[tpos] = k--; tr->pos[tpos] = i--; } else if (sc == imx[i][k] + hmm->tsc[k][TIM]) { tr->statetype[tpos] = STI; tr->nodeidx[tpos] = k; tr->pos[tpos] = i--; } else if (sc == dmx[i][k] + hmm->tsc[k][TDM]) { tr->statetype[tpos] = STD; tr->nodeidx[tpos] = k--; tr->pos[tpos] = 0; } else Die("traceback failed"); break; case STD: /* D connects from M,D */ if (dmx[i][k+1] == mmx[i][k] + hmm->tsc[k][TMD]) { tr->statetype[tpos] = STM; tr->nodeidx[tpos] = k--; tr->pos[tpos] = i--; } else if (dmx[i][k+1] == dmx[i][k] + hmm->tsc[k][TDD]) { tr->statetype[tpos] = STD; tr->nodeidx[tpos] = k--; tr->pos[tpos] = 0; } else Die("traceback failed"); break; case STI: /* I connects from M,I */ sc = imx[i+1][k] - hmm->isc[(int) dsq[i+1]][k]; if (sc == mmx[i][k] + hmm->tsc[k][TMI]) { tr->statetype[tpos] = STM; tr->nodeidx[tpos] = k--; tr->pos[tpos] = i--; } else if (sc == imx[i][k] + hmm->tsc[k][TII]) { tr->statetype[tpos] = STI; tr->nodeidx[tpos] = k; tr->pos[tpos] = i--; } else Die("traceback failed"); break; case STN: /* N connects from S, N */ if (i == 0 && xmx[i][XMN] == 0) { tr->statetype[tpos] = STS; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; } else if (i > 0 && xmx[i+1][XMN] == xmx[i][XMN] + hmm->xsc[XTN][LOOP]) { tr->statetype[tpos] = STN; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; /* note convention adherence: */ tr->pos[tpos-1] = i--; /* first N doesn't emit */ } else Die("traceback failed"); break; case STB: /* B connects from N, J */ if (xmx[i][XMB] == xmx[i][XMN] + hmm->xsc[XTN][MOVE]) { tr->statetype[tpos] = STN; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; } else if (xmx[i][XMB] == xmx[i][XMJ] + hmm->xsc[XTJ][MOVE]) { tr->statetype[tpos] = STJ; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; } else Die("traceback failed"); break; case STE: /* E connects from any M state. k set here */ for (k = hmm->M; k >= 1; k--) if (xmx[i][XME] == mmx[i][k] + hmm->esc[k]) { /* check for wing unfolding */ if (Prob2Score(hmm->end[k], 1.) + 1*INTSCALE <= hmm->esc[k]) { int dk; /* need a tmp k while moving thru delete wing */ for (dk = hmm->M; dk > k; dk--) { tr->statetype[tpos] = STD; tr->nodeidx[tpos] = dk; tr->pos[tpos] = 0; tpos++; if (tpos == curralloc) { /* grow trace if necessary */ curralloc += N; P7ReallocTrace(tr, curralloc); } } } tr->statetype[tpos] = STM; tr->nodeidx[tpos] = k--; tr->pos[tpos] = i--; break; } if (k < 0) Die("traceback failed"); break; case STC: /* C comes from C, E */ if (xmx[i][XMC] == xmx[i-1][XMC] + hmm->xsc[XTC][LOOP]) { tr->statetype[tpos] = STC; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; /* note convention adherence: */ tr->pos[tpos-1] = i--; /* first C doesn't emit */ } else if (xmx[i][XMC] == xmx[i][XME] + hmm->xsc[XTE][MOVE]) { tr->statetype[tpos] = STE; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; /* E is a nonemitter */ } else Die("Traceback failed."); break; case STJ: /* J connects from E, J */ if (xmx[i][XMJ] == xmx[i-1][XMJ] + hmm->xsc[XTJ][LOOP]) { tr->statetype[tpos] = STJ; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; /* note convention adherence: */ tr->pos[tpos-1] = i--; /* first J doesn't emit */ } else if (xmx[i][XMJ] == xmx[i][XME] + hmm->xsc[XTE][LOOP]) { tr->statetype[tpos] = STE; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; /* E is a nonemitter */ } else Die("Traceback failed."); break; default: Die("traceback failed"); } /* end switch over statetype[tpos-1] */ tpos++; if (tpos == curralloc) { /* grow trace if necessary */ curralloc += N; P7ReallocTrace(tr, curralloc); } } /* end traceback, at S state; tpos == tlen now */ tr->tlen = tpos; P7ReverseTrace(tr); *ret_tr = tr; } /* Function: P7SmallViterbi() * Date: SRE, Fri Mar 6 15:29:41 1998 [St. Louis] * * Purpose: Wrapper function, for linear memory alignment * with same arguments as P7Viterbi(). * * Calls P7ParsingViterbi to break the sequence * into fragments. Then, based on size of fragments, * calls either P7Viterbi() or P7WeeViterbi() to * get traces for them. Finally, assembles all these * traces together to produce an overall optimal * trace for the sequence. * * If the trace isn't needed for some reason, * all we do is call P7ParsingViterbi. * * Args: dsq - sequence in digitized form * L - length of dsq * hmm - the model * ret_tr - RETURN: traceback; pass NULL if it's not wanted * * Returns: Score of optimal alignment in bits. */ float P7SmallViterbi(char *dsq, int L, struct plan7_s *hmm, struct p7trace_s **ret_tr) { struct p7trace_s *ctr; /* collapsed trace of optimal parse */ struct p7trace_s *tr; /* full trace of optimal alignment */ struct p7trace_s **tarr; /* trace array */ int ndom; /* number of subsequences */ int i; /* counter over domains */ int pos; /* position in sequence */ int tpos; /* position in trace */ int tlen; /* length of full trace */ int sqlen; /* length of a subsequence */ int totlen; /* length of L matched by model (as opposed to N/C/J) */ float sc; /* score of optimal alignment */ int t2; /* position in a subtrace */ /* Step 1. Call P7ParsingViterbi to calculate an optimal parse * of the sequence into single-hit subsequences; this parse * is returned in a "collapsed" trace */ sc = P7ParsingViterbi(dsq, L, hmm, &ctr); /* If we don't want full trace, we're done */ if (ret_tr == NULL) { P7FreeTrace(ctr); return sc; } /* Step 2. Call either P7Viterbi or P7WeeViterbi on each subsequence * to recover a full traceback of each, collecting them in * an array. */ ndom = ctr->tlen/2 - 1; tarr = MallocOrDie(sizeof(struct p7trace_s *) * ndom); tlen = totlen = 0; for (i = 0; i < ndom; i++) { sqlen = ctr->pos[i*2+2] - ctr->pos[i*2+1]; /* length of subseq */ if (P7ViterbiSize(sqlen, hmm->M) > RAMLIMIT) P7WeeViterbi(dsq + ctr->pos[i*2+1], sqlen, hmm, &(tarr[i])); else P7Viterbi(dsq + ctr->pos[i*2+1], sqlen, hmm, &(tarr[i])); tlen += tarr[i]->tlen - 4; /* not counting S->N,...,C->T */ totlen += sqlen; } /* Step 3. Compose the subtraces into one big final trace. * This is wasteful because we're going to TraceDecompose() * it again in both hmmsearch and hmmpfam to look at * individual domains; but we do it anyway so the P7SmallViterbi * interface looks exactly like the P7Viterbi interface. Maybe * long traces shouldn't include all the N/J/C states anyway, * since they're unambiguously implied. */ /* Calculate total trace len and alloc; * nonemitting SNCT + nonemitting J's + emitting NJC */ tlen += 4 + (ndom-1) + (L-totlen); P7AllocTrace(tlen, &tr); tr->tlen = tlen; /* Add N-terminal trace framework */ tr->statetype[0] = STS; tr->nodeidx[0] = 0; tr->pos[0] = 0; tr->statetype[1] = STN; tr->nodeidx[1] = 0; tr->pos[1] = 0; tpos = 2; /* add implied N's */ for (pos = 1; pos <= ctr->pos[1]; pos++) { tr->statetype[tpos] = STN; tr->nodeidx[tpos] = 0; tr->pos[tpos] = pos; tpos++; } /* Add each subseq trace in, with its appropriate * sequence offset derived from the collapsed trace */ for (i = 0; i < ndom; i++) { /* skip SN, CT framework at ends */ for (t2 = 2; t2 < tarr[i]->tlen-2; t2++) { tr->statetype[tpos] = tarr[i]->statetype[t2]; tr->nodeidx[tpos] = tarr[i]->nodeidx[t2]; if (tarr[i]->pos[t2] > 0) tr->pos[tpos] = tarr[i]->pos[t2] + ctr->pos[i*2+1]; else tr->pos[tpos] = 0; tpos++; } /* add nonemitting J or C */ tr->statetype[tpos] = (i == ndom-1) ? STC : STJ; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; tpos++; /* add implied emitting J's */ if (i != ndom-1) for (pos = ctr->pos[i*2+2]+1; pos <= ctr->pos[(i+1)*2+1]; pos++) { tr->statetype[tpos] = STJ; tr->nodeidx[tpos] = 0; tr->pos[tpos] = pos; tpos++; } } /* add implied C's */ for (pos = ctr->pos[ndom*2]+1; pos <= L; pos++) { tr->statetype[tpos] = STC; tr->nodeidx[tpos] = 0; tr->pos[tpos] = pos; tpos++; } /* add terminal T */ tr->statetype[tpos] = STT; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; tpos++; for (i = 0; i < ndom; i++) P7FreeTrace(tarr[i]); free(tarr); P7FreeTrace(ctr); *ret_tr = tr; return sc; } /* Function: P7ParsingViterbi() * Date: SRE, Wed Mar 4 14:07:31 1998 [St. Louis] * * Purpose: The "hmmfs" linear-memory algorithm for finding * the optimal alignment of a very long sequence to * a looping, multihit (e.g. Plan7) model, parsing it into * a series of nonoverlapping subsequences that match * the model once. Other algorithms (e.g. P7Viterbi() * or P7WeeViterbi()) are applied subsequently to * these subsequences to recover complete alignments. * * The hmmfs algorithm appears briefly in [Durbin98], * but is otherwise unpublished. * * The traceback structure returned is special: a * "collapsed" trace S->B->E->...->B->E->T, where * stateidx is unused and pos is used to indicate the * position of B and E in the sequence. The matched * subsequence is B_pos+1...E_pos. The number of * matches in the trace is (tlen/2)-1. * * Args: dsq - sequence in digitized form * L - length of dsq * hmm - the model (log odds scores ready) * ret_tr - RETURN: a collapsed traceback. * * Returns: Score of the optimal Viterbi alignment, in bits. */ float P7ParsingViterbi(char *dsq, int L, struct plan7_s *hmm, struct p7trace_s **ret_tr) { struct dpmatrix_s *mx; /* two rows of score matrix */ struct dpmatrix_s *tmx; /* two rows of misused score matrix: traceback ptrs */ struct p7trace_s *tr; /* RETURN: collapsed traceback */ int **xmx, **mmx, **dmx, **imx; /* convenience ptrs to score matrix */ int **xtr, **mtr, **dtr, **itr; /* convenience ptrs to traceback pointers */ int *btr, *etr; /* O(L) trace ptrs for B, E state pts in seq */ int sc; /* integer score of optimal alignment */ int i,k,tpos; /* index for seq, model, trace position */ int cur, prv; /* indices for rolling dp matrix */ int curralloc; /* size of allocation for tr */ /* Alloc a DP matrix and traceback pointers, two rows each, O(M). * Alloc two O(L) arrays to trace back through the sequence thru B and E. */ mx = AllocPlan7Matrix(2, hmm->M, &xmx, &mmx, &imx, &dmx); tmx = AllocPlan7Matrix(2, hmm->M, &xtr, &mtr, &itr, &dtr); btr = MallocOrDie(sizeof(int) * (L+1)); etr = MallocOrDie(sizeof(int) * (L+1)); /* Initialization of the zero row. */ xmx[0][XMN] = 0; /* S->N, p=1 */ xmx[0][XMB] = hmm->xsc[XTN][MOVE]; /* S->N->B, no N-tail */ btr[0] = 0; xmx[0][XME] = xmx[0][XMC] = xmx[0][XMJ] = -INFTY; /* need seq to get here */ etr[0] = -1; for (k = 0; k <= hmm->M; k++) mmx[0][k] = imx[0][k] = dmx[0][k] = -INFTY; /* need seq to get here */ /* Recursion. Done as a pull. Rolling index trick. Trace ptr propagation trick. * Note some slightly wasteful boundary conditions: * tsc[0] = -INFTY for all eight transitions (no node 0) * D_M and I_M are wastefully calculated (they don't exist) * * Notes on traceback pointer propagation. * - In the path B->E, we propagate the i that B was aligned to in the optimal * alignment, via mtr, dtr, and itr. * - When we reach an E, we record the i of the B it started from in etr. * - In a looping path E->J...->B or terminal path E->C...->T, we propagate * the i that E was aligned to in the optimal alignment via xtr[][XMC] * and xtr[][XMJ]. * - When we enter B, we record the i of the best previous E, or 0 if there * isn't one, in btr. */ for (i = 1; i <= L; i++) { cur = i % 2; prv = !cur; mmx[cur][0] = imx[cur][0] = dmx[cur][0] = -INFTY; for (k = 1; k <= hmm->M; k++) { /* match state */ mmx[cur][k] = -INFTY; if ((sc = mmx[prv][k-1] + hmm->tsc[k-1][TMM]) > -INFTY) { mmx[cur][k] = sc; mtr[cur][k] = mtr[prv][k-1]; } if ((sc = imx[prv][k-1] + hmm->tsc[k-1][TIM]) > mmx[cur][k]) { mmx[cur][k] = sc; mtr[cur][k] = itr[prv][k-1]; } if ((sc = xmx[prv][XMB] + hmm->bsc[k]) > mmx[cur][k]) { mmx[cur][k] = sc; mtr[cur][k] = i-1; } if ((sc = dmx[prv][k-1] + hmm->tsc[k-1][TDM]) > mmx[cur][k]) { mmx[cur][k] = sc; mtr[cur][k] = dtr[prv][k-1]; } if (hmm->msc[(int) dsq[i]][k] != -INFTY) mmx[cur][k] += hmm->msc[(int) dsq[i]][k]; else mmx[cur][k] = -INFTY; /* delete state */ dmx[cur][k] = -INFTY; if ((sc = mmx[cur][k-1] + hmm->tsc[k-1][TMD]) > -INFTY) { dmx[cur][k] = sc; dtr[cur][k] = mtr[cur][k-1]; } if ((sc = dmx[cur][k-1] + hmm->tsc[k-1][TDD]) > dmx[cur][k]) { dmx[cur][k] = sc; dtr[cur][k] = dtr[cur][k-1]; } /* insert state */ if (k < hmm->M) { imx[cur][k] = -INFTY; if ((sc = mmx[prv][k] + hmm->tsc[k][TMI]) > -INFTY) { imx[cur][k] = sc; itr[cur][k] = mtr[prv][k]; } if ((sc = imx[prv][k] + hmm->tsc[k][TII]) > imx[cur][k]) { imx[cur][k] = sc; itr[cur][k] = itr[prv][k]; } if (hmm->isc[(int) dsq[i]][k] != -INFTY) imx[cur][k] += hmm->isc[(int) dsq[i]][k]; else imx[cur][k] = -INFTY; } } /* Now the special states. Order is important here. * remember, C and J emissions are zero score by definition, */ /* N state */ xmx[cur][XMN] = -INFTY; if ((sc = xmx[prv][XMN] + hmm->xsc[XTN][LOOP]) > -INFTY) xmx[cur][XMN] = sc; /* E state */ xmx[cur][XME] = -INFTY; for (k = 1; k <= hmm->M; k++) if ((sc = mmx[cur][k] + hmm->esc[k]) > xmx[cur][XME]) { xmx[cur][XME] = sc; etr[i] = mtr[cur][k]; } /* J state */ xmx[cur][XMJ] = -INFTY; if ((sc = xmx[prv][XMJ] + hmm->xsc[XTJ][LOOP]) > -INFTY) { xmx[cur][XMJ] = sc; xtr[cur][XMJ] = xtr[prv][XMJ]; } if ((sc = xmx[cur][XME] + hmm->xsc[XTE][LOOP]) > xmx[cur][XMJ]) { xmx[cur][XMJ] = sc; xtr[cur][XMJ] = i; } /* B state */ xmx[cur][XMB] = -INFTY; if ((sc = xmx[cur][XMN] + hmm->xsc[XTN][MOVE]) > -INFTY) { xmx[cur][XMB] = sc; btr[i] = 0; } if ((sc = xmx[cur][XMJ] + hmm->xsc[XTJ][MOVE]) > xmx[cur][XMB]) { xmx[cur][XMB] = sc; btr[i] = xtr[cur][XMJ]; } /* C state */ xmx[cur][XMC] = -INFTY; if ((sc = xmx[prv][XMC] + hmm->xsc[XTC][LOOP]) > -INFTY) { xmx[cur][XMC] = sc; xtr[cur][XMC] = xtr[prv][XMC]; } if ((sc = xmx[cur][XME] + hmm->xsc[XTE][MOVE]) > xmx[cur][XMC]) { xmx[cur][XMC] = sc; xtr[cur][XMC] = i; } } /* T state (not stored) */ sc = xmx[cur][XMC] + hmm->xsc[XTC][MOVE]; /***************************************************************** * Collapsed traceback stage. * xtr[L%2][XMC] contains the position j of the previous E * etr[j] contains the position i of the previous B * btr[i] contains the position j of the previous E, or 0 * continue until btr[i] = 0. *****************************************************************/ curralloc = 2; /* minimum: no hits */ P7AllocTrace(curralloc, &tr); /* Init of collapsed trace. Back to front; we ReverseTrace() later. */ tpos = 0; tr->statetype[tpos] = STT; tr->pos[tpos] = 0; i = xtr[L%2][XMC]; while (i > 0) { curralloc += 2; P7ReallocTrace(tr, curralloc); tpos++; tr->statetype[tpos] = STE; tr->pos[tpos] = i; i = etr[i]; tpos++; tr->statetype[tpos] = STB; tr->pos[tpos] = i; i = btr[i]; } tpos++; tr->statetype[tpos] = STS; tr->pos[tpos] = 0; tr->tlen = tpos + 1; P7ReverseTrace(tr); FreePlan7Matrix(mx); FreePlan7Matrix(tmx); free(btr); free(etr); *ret_tr = tr; return Scorify(sc); } /* Function: P7WeeViterbi() * Date: SRE, Wed Mar 4 08:24:04 1998 [St. Louis] * * Purpose: Hirschberg/Myers/Miller linear memory alignment. * See [Hirschberg75,MyM-88a] for the idea of the algorithm. * Adapted to HMM implementation. * * Requires that you /know/ that there's only * one hit to the model in the sequence: either * because you're forcing single-hit, or you've * previously called P7ParsingViterbi to parse * the sequence into single-hit segments. The reason * for this is that a cyclic model (a la Plan7) * defeats the nice divide and conquer trick. * (I think some trickery with propagated trace pointers * could get around this but haven't explored it.) * This is implemented by ignoring transitions * to/from J state. * * Args: dsq - sequence in digitized form * L - length of dsq * hmm - the model * ret_tr - RETURN: traceback. * * Returns: Score of the optimal Viterbi alignment. */ float P7WeeViterbi(char *dsq, int L, struct plan7_s *hmm, struct p7trace_s **ret_tr) { struct p7trace_s *tr; /* RETURN: traceback */ int *kassign; /* 0..L+1, alignment of seq positions to model nodes */ enum p7stype *tassign; /* 0..L+1, alignment of seq positions to state types */ int *endlist; /* stack of end points on sequence to work on */ int *startlist; /* stack of start points on sequence to work on */ int lpos; /* position in endlist, startlist */ int k1, k2, k3; /* start, mid, end in model */ enum p7stype t1, t2, t3; /* start, mid, end in state type */ int s1, s2, s3; /* start, mid, end in sequence */ float sc; /* score of segment optimal alignment */ float ret_sc; /* optimal score over complete seq */ int tlen; /* length needed for trace */ int i, k, tpos; /* index in sequence, model, trace */ /* Initialize. */ kassign = MallocOrDie (sizeof(int) * (L+1)); tassign = MallocOrDie (sizeof(enum p7stype) * (L+1)); endlist = MallocOrDie (sizeof(int) * (L+1)); startlist = MallocOrDie (sizeof(int) * (L+1)); lpos = 0; startlist[lpos] = 1; endlist[lpos] = L; kassign[1] = 1; kassign[L] = hmm->M; tassign[1] = STS; tassign[L] = STT; /* Recursive divide-and-conquer alignment. */ while (lpos >= 0) { /* Pop a segment off the stack */ s1 = startlist[lpos]; k1 = kassign[s1]; t1 = tassign[s1]; s3 = endlist[lpos]; k3 = kassign[s3]; t3 = tassign[s3]; lpos--; /* find optimal midpoint of segment */ sc = get_wee_midpt(hmm, dsq, L, k1, t1, s1, k3, t3, s3, &k2, &t2, &s2); kassign[s2] = k2; tassign[s2] = t2; /* score is valid on first pass */ if (t1 == STS && t3 == STT) ret_sc = sc; /* push N-terminal segment on stack */ if (t2 != STN && (s2 - s1 > 1 || (s2 - s1 == 1 && t1 == STS))) { lpos++; startlist[lpos] = s1; endlist[lpos] = s2; } /* push C-terminal segment on stack */ if (t2 != STC && (s3 - s2 > 1 || (s3 - s2 == 1 && t3 == STT))) { lpos++; startlist[lpos] = s2; endlist[lpos] = s3; } if (t2 == STN) { /* if we see STN midpoint, we know the whole N-term is STN */ for (; s2 >= s1; s2--) { kassign[s2] = 1; tassign[s2] = STN; } } if (t2 == STC) { /* if we see STC midpoint, we know whole C-term is STC */ for (; s2 <= s3; s2++) { kassign[s2] = hmm->M; tassign[s2] = STC; } } } /***************************************************************** * Construct a traceback structure from kassign/tassign by interpolating * necessary states. * Trace allocation is as follows. We clearly need L emitting states. * We also need nonemitting states as follows: * STS,STN,STB,STE,STC,STT = 6 * STD: count k2-k1-1 in kassign M->M's * Also, count N->M's and M->C's (potential wing unfoldings), *****************************************************************/ tlen = L + 6; for (i = 1; i < L; i++) { if (tassign[i] == STM && tassign[i+1] == STM) tlen += kassign[i+1] - kassign[i] - 1; if (tassign[i] == STN && tassign[i+1] == STM) tlen += kassign[i+1] - 1; if (tassign[i] == STM && tassign[i+1] == STC) tlen += hmm->M - kassign[i]; } P7AllocTrace(tlen, &tr); tr->statetype[0] = STS; tr->nodeidx[0] = 0; tr->pos[0] = 0; tr->statetype[1] = STN; tr->nodeidx[1] = 0; tr->pos[1] = 0; tpos = 2; for (i = 1; i <= L; i++) { switch(tassign[i]) { case STM: /* check for first match state */ if (tr->statetype[tpos-1] == STN) { tr->statetype[tpos] = STB; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; tpos++; /* check for wing unfolding */ if (Prob2Score(hmm->begin[kassign[i]], hmm->p1) + INTSCALE <= hmm->bsc[kassign[i]]) for (k = 1; k < kassign[i]; k++) { tr->statetype[tpos] = STD; tr->nodeidx[tpos] = k; tr->pos[tpos] = 0; tpos++; } } /* do the match state itself */ tr->statetype[tpos] = STM; tr->nodeidx[tpos] = kassign[i]; tr->pos[tpos] = i; tpos++; /* do any deletes necessary 'til next match */ if (i < L && tassign[i+1] == STM && kassign[i+1] - kassign[i] > 1) for (k = kassign[i] + 1; k < kassign[i+1]; k++) { tr->statetype[tpos] = STD; tr->nodeidx[tpos] = k; tr->pos[tpos] = 0; tpos++; } /* check for last match state */ if (i == L || tassign[i+1] == STC) { /* check for wing unfolding */ if (Prob2Score(hmm->end[kassign[i-1]], 1.) + INTSCALE <= hmm->esc[kassign[i-1]]) for (k = kassign[i]+1; k <= hmm->M; k++) { tr->statetype[tpos] = STD; tr->nodeidx[tpos] = k; tr->pos[tpos] = 0; tpos++; } /* add on the end state */ tr->statetype[tpos] = STE; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; tpos++; /* and a nonemitting C state */ tr->statetype[tpos] = STC; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; tpos++; } break; case STI: tr->statetype[tpos] = STI; tr->nodeidx[tpos] = kassign[i]; tr->pos[tpos] = i; tpos++; break; case STN: tr->statetype[tpos] = STN; tr->nodeidx[tpos] = 0; tr->pos[tpos] = i; tpos++; break; case STC: tr->statetype[tpos] = STC; tr->nodeidx[tpos] = 0; tr->pos[tpos] = i; tpos++; break; default: Die("Bogus state %s", Statetype(tassign[i])); } } /* terminate the trace */ tr->statetype[tpos] = STT; tr->nodeidx[tpos] = 0; tr->pos[tpos] = 0; tr->tlen = tpos+1; *ret_tr = tr; free(kassign); free(tassign); free(startlist); free(endlist); return ret_sc; } /* Function: Plan7ESTViterbi() * * Purpose: Frameshift-tolerant alignment of protein model to cDNA EST. * * */ float Plan7ESTViterbi(char *dsq, int L, struct plan7_s *hmm, struct dpmatrix_s **ret_mx) { struct dpmatrix_s *mx; int **xmx; int **mmx; int **imx; int **dmx; int i,k; int sc; int codon; /* Allocate a DP matrix with 0..L rows, 0..M+1 columns. */ mx = AllocPlan7Matrix(L+1, hmm->M, &xmx, &mmx, &imx, &dmx); /* Initialization of the zero row (DNA sequence of length 0) * Note that xmx[i][stN] = 0 by definition for all i, * and xmx[i][stT] = xmx[i][stC], so neither stN nor stT need * to be calculated in DP matrices. */ xmx[0][XMN] = 0; /* S->N, p=1 */ xmx[0][XMB] = hmm->xsc[XTN][MOVE]; /* S->N->B, no N-tail */ xmx[0][XME] = xmx[0][XMC] = xmx[0][XMJ] = -INFTY; /* need seq to get here */ for (k = 0; k <= hmm->M; k++) mmx[0][k] = imx[0][k] = dmx[0][k] = -INFTY; /* need seq to get here */ /* Initialization of the first row (DNA sequence of length 1) * only N can make this nucleotide. */ xmx[1][XMN] = xmx[0][XMN] + hmm->xsc[XTN][LOOP]; xmx[1][XMB] = xmx[1][XMN] + hmm->xsc[XTN][MOVE]; xmx[0][XME] = xmx[0][XMC] = xmx[0][XMJ] = -INFTY; /* need 2 nt to get here */ for (k = 0; k <= hmm->M; k++) mmx[0][k] = imx[0][k] = dmx[0][k] = -INFTY; /* need 2 nt to get into model */ /* Recursion. Done as a pull. * Note some slightly wasteful boundary conditions: * tsc[0] = -INFTY for all eight transitions (no node 0) * D_M and I_M are wastefully calculated (they don't exist) */ for (i = 2; i <= L; i++) { mmx[i][0] = imx[i][0] = dmx[i][0] = -INFTY; /* crude calculation of lookup value for codon */ if (i > 2) { if (dsq[i-2] < 4 && dsq[i-1] < 4 && dsq[i] < 4) codon = dsq[i-2] * 16 + dsq[i-1] * 4 + dsq[i]; else codon = 64; /* ambiguous codon; punt */ } for (k = 1; k <= hmm->M; k++) { /* match state */ if (i > 2) { mmx[i][k] = mmx[i-3][k-1] + hmm->tsc[k-1][TMM]; if ((sc = imx[i-3][k-1] + hmm->tsc[k-1][TIM]) > mmx[i][k]) mmx[i][k] = sc; if ((sc = xmx[i-3][XMB] + hmm->bsc[k]) > mmx[i][k]) mmx[i][k] = sc; if ((sc = dmx[i-3][k-1] + hmm->tsc[k-1][TDM]) > mmx[i][k]) mmx[i][k] = sc; mmx[i][k] += hmm->dnam[codon][k]; } /* -1 frameshifts into match state */ if ((sc = mmx[i-2][k-1] + hmm->tsc[k-1][TMM] + hmm->dna2) > mmx[i][k]) mmx[i][k] = sc; if ((sc = imx[i-2][k-1] + hmm->tsc[k-1][TIM] + hmm->dna2) > mmx[i][k]) mmx[i][k] = sc; if ((sc = xmx[i-2][XMB] + hmm->bsc[k] + hmm->dna2) > mmx[i][k]) mmx[i][k] = sc; if ((sc = dmx[i-2][k-1] + hmm->tsc[k-1][TDM] + hmm->dna2) > mmx[i][k]) mmx[i][k] = sc; /* +1 frameshifts into match state */ if (i > 3) { if ((sc = mmx[i-4][k-1] + hmm->tsc[k-1][TMM] + hmm->dna4) > mmx[i][k]) mmx[i][k] = sc; if ((sc = imx[i-4][k-1] + hmm->tsc[k-1][TIM] + hmm->dna4) > mmx[i][k]) mmx[i][k] = sc; if ((sc = xmx[i-4][XMB] + hmm->bsc[k] + hmm->dna4) > mmx[i][k]) mmx[i][k] = sc; if ((sc = dmx[i-4][k-1] + hmm->tsc[k-1][TDM] + hmm->dna4) > mmx[i][k]) mmx[i][k] = sc; } /* delete state */ dmx[i][k] = mmx[i][k-1] + hmm->tsc[k-1][TMD]; if ((sc = dmx[i][k-1] + hmm->tsc[k-1][TDD]) > dmx[i][k]) dmx[i][k] = sc; /* insert state */ if (i > 2) { imx[i][k] = mmx[i-3][k] + hmm->tsc[k][TMI]; if ((sc = imx[i-3][k] + hmm->tsc[k][TII]) > imx[i][k]) imx[i][k] = sc; imx[i][k] += hmm->dnai[codon][k]; } /* -1 frameshifts into insert state */ if ((sc = mmx[i-2][k] + hmm->tsc[k][TMI] + hmm->dna2) > imx[i][k]) imx[i][k] = sc; if ((sc = imx[i-2][k] + hmm->tsc[k][TII] + hmm->dna2) > imx[i][k]) imx[i][k] = sc; /* +1 frameshifts into insert state */ if (i > 4) { if ((sc = mmx[i-4][k] + hmm->tsc[k][TMI] + hmm->dna4) > imx[i][k]) imx[i][k] = sc; if ((sc = imx[i-4][k] + hmm->tsc[k][TII] + hmm->dna4) > imx[i][k]) imx[i][k] = sc; } } /* Now the special states. Order is important here. * remember, C and J emissions are zero score by definition, */ /* N state: +1 nucleotide */ xmx[i][XMN] = xmx[i-1][XMN] + hmm->xsc[XTN][LOOP]; /* E state: collect from M's, and last D */ xmx[i][XME] = dmx[i][hmm->M]; /* transition prob from last D = 1.0 */ for (k = 1; k <= hmm->M; k++) if ((sc = mmx[i][k] + hmm->esc[k]) > xmx[i][XME]) xmx[i][XME] = sc; /* J state: +1 nucleotide */ xmx[i][XMJ] = xmx[i-1][XMJ] + hmm->xsc[XTJ][LOOP]; if ((sc = xmx[i][XME] + hmm->xsc[XTE][LOOP]) > xmx[i][XMJ]) xmx[i][XMJ] = sc; /* B state: collect from N,J */ xmx[i][XMB] = xmx[i][XMN] + hmm->xsc[XTN][MOVE]; if ((sc = xmx[i][XMJ] + hmm->xsc[XTJ][MOVE]) > xmx[i][XMB]) xmx[i][XMB] = sc; /* C state: +1 nucleotide */ xmx[i][XMC] = xmx[i-1][XMC] + hmm->xsc[XTC][LOOP]; if ((sc = xmx[i][XME] + hmm->xsc[XTE][MOVE]) > xmx[i][XMC]) xmx[i][XMC] = sc; } sc = xmx[L][XMC] + hmm->xsc[XTC][MOVE]; if (ret_mx != NULL) *ret_mx = mx; else FreePlan7Matrix(mx); return Scorify(sc); /* the total Viterbi score. */ } /* Function: get_wee_midpt() * Date: SRE, Wed Mar 4 08:27:11 1998 [St. Louis] * * Purpose: The heart of the divide and conquer algorithm * for P7WeeViterbi(). This function is called * recursively to find successive optimal midpoints * in the alignment matrix. See P7WeeViterbi() for * further comments on the assumptions of this algorithm. * * Args: hmm - the model, set up for integer scores * dsq - the sequence, digitized * L - length of the sequence * k1 - model node to start with, 1..M * t1 - state type to start with, STM | STI | STN | STC; STS to start * s1 - sequence position to start with, 1..L; 1 to start * k3 - model node to end with, 1..M * t3 - state type to end with, STM | STI | STN | STC; STT to start * s3 - sequence position to end with, 1..L; L to start * ret_k2 - RETURN: optimal midpoint, node position in model * ret_t2 - RETURN: optimal midpoint, state type * ret_s2 - RETURN: optimal midpoint, sequence position * * Returns: score of optimal alignment, in bits. */ static float get_wee_midpt(struct plan7_s *hmm, char *dsq, int L, int k1, enum p7stype t1, int s1, int k3, enum p7stype t3, int s3, int *ret_k2, enum p7stype *ret_t2, int *ret_s2) { struct dpmatrix_s *fwd; struct dpmatrix_s *bck; int **xmx; /* convenience ptr into special states */ int **mmx; /* convenience ptr into match states */ int **imx; /* convenience ptr into insert states */ int **dmx; /* convenience ptr into delete states */ int k2; enum p7stype t2; int s2; int cur, prv, nxt; /* current, previous, next row index (0 or 1)*/ int i,k; /* indices for seq, model */ int sc; /* integer score */ int max; /* maximum integer score */ int start; /* s1 to start at (need, for STS special case) */ /* Choose our midpoint. * Special cases: s1, s3 adjacent and t1 == STS: s2 = s1 * s1, s3 adjacent and t3 == STT: s2 = s3 * (where we must replace STS, STT eventually) */ s2 = s1 + (s3-s1) / 2; if (s3-s1 == 1 && t1 == STS) s2 = s1; if (s3-s1 == 1 && t3 == STT) s2 = s3; /* STS is a special case. STS aligns to row zero by convention, * but we'll be passed s1=1, t1=STS. We have to init on row * zero then start DP on row 1. */ start = (t1 == STS) ? 0 : s1; /* Allocate our forward two rows. * Initialize row zero. */ fwd = AllocPlan7Matrix(2, hmm->M, &xmx, &mmx, &imx, &dmx); cur = start%2; xmx[cur][XMN] = xmx[cur][XMB] = -INFTY; xmx[cur][XME] = xmx[cur][XMC] = -INFTY; for (k = k1; k <= k3; k++) mmx[cur][k] = imx[cur][k] = dmx[cur][k] = -INFTY; /* Where to put our zero for our start point... * (only possible to start on an emitting state; J disallowed) */ switch (t1) { case STM: mmx[cur][k1] = 0; break; case STI: imx[cur][k1] = 0; break; case STN: xmx[cur][XMN] = 0; break; case STC: xmx[cur][XMC] = 0; break; case STS: xmx[cur][XMN] = 0; break; default: Die("you can't init get_wee_midpt with a %s\n", Statetype(t1)); } /* Still initializing. * Deal with pulling horizontal matrix moves in initial row. * These are any transitions to nonemitters: * STM-> E, D * STI-> none * STN-> B * STC-> (T, but we never observe this in the forward pass of a d&c) * STE-> C * STS-> (N, already implied by setting xmx[cur][XMN] = 0) * STB-> M */ if (t1 == STM) { for (k = k1+1; k <= k3; k++) { /* transits into STD */ dmx[cur][k] = -INFTY; if ((sc = mmx[cur][k-1] + hmm->tsc[k-1][TMD]) > -INFTY) dmx[cur][k] = sc; if ((sc = dmx[cur][k-1] + hmm->tsc[k-1][TDD]) > dmx[cur][k]) dmx[cur][k] = sc; } /* transit into STE */ xmx[cur][XME] = -INFTY; if ((sc = mmx[cur][k1] + hmm->esc[k1]) > -INFTY) xmx[cur][XME] = sc; } /* transit into STB from STN */ xmx[cur][XMB] = -INFTY; if ((sc = xmx[cur][XMN] + hmm->xsc[XTN][MOVE]) > -INFTY) xmx[cur][XMB] = sc; /* transit into STC from STE */ xmx[cur][XMC] = -INFTY; if ((sc = xmx[cur][XME] + hmm->xsc[XTE][MOVE]) > -INFTY) xmx[cur][XMC] = sc; /* Done initializing. * Start recursive DP; sweep forward to chosen s2 midpoint. Done as a pull. */ for (i = start+1; i <= s2; i++) { cur = i % 2; prv = !cur; mmx[cur][k1] = imx[cur][k1] = dmx[cur][k1] = -INFTY; /* Insert state in column k1, and B->M transition in k1. */ if (k1 < hmm->M) { imx[cur][k1] = -INFTY; if ((sc = mmx[prv][k1] + hmm->tsc[k1][TMI]) > -INFTY) imx[cur][k1] = sc; if ((sc = imx[prv][k1] + hmm->tsc[k1][TII]) > imx[cur][k1]) imx[cur][k1] = sc; if (hmm->isc[(int) dsq[i]][k1] != -INFTY) imx[cur][k1] += hmm->isc[(int) dsq[i]][k1]; else imx[cur][k1] = -INFTY; } if ((sc = xmx[prv][XMB] + hmm->bsc[k1]) > -INFTY) mmx[cur][k1] = sc; if (hmm->msc[(int) dsq[i]][k1] != -INFTY) mmx[cur][k1] += hmm->msc[(int) dsq[i]][k1]; else mmx[cur][k1] = -INFTY; /* Main chunk of recursion across model positions */ for (k = k1+1; k <= k3; k++) { /* match state */ mmx[cur][k] = -INFTY; if ((sc = mmx[prv][k-1] + hmm->tsc[k-1][TMM]) > -INFTY) mmx[cur][k] = sc; if ((sc = imx[prv][k-1] + hmm->tsc[k-1][TIM]) > mmx[cur][k]) mmx[cur][k] = sc; if ((sc = xmx[prv][XMB] + hmm->bsc[k]) > mmx[cur][k]) mmx[cur][k] = sc; if ((sc = dmx[prv][k-1] + hmm->tsc[k-1][TDM]) > mmx[cur][k]) mmx[cur][k] = sc; if (hmm->msc[(int) dsq[i]][k] != -INFTY) mmx[cur][k] += hmm->msc[(int) dsq[i]][k]; else mmx[cur][k] = -INFTY; /* delete state */ dmx[cur][k] = -INFTY; if (k < hmm->M) { if ((sc = mmx[cur][k-1] + hmm->tsc[k-1][TMD]) > -INFTY) dmx[cur][k] = sc; if ((sc = dmx[cur][k-1] + hmm->tsc[k-1][TDD]) > dmx[cur][k]) dmx[cur][k] = sc; } /* insert state */ imx[cur][k] = -INFTY; if (k < hmm->M) { if ((sc = mmx[prv][k] + hmm->tsc[k][TMI]) > -INFTY) imx[cur][k] = sc; if ((sc = imx[prv][k] + hmm->tsc[k][TII]) > imx[cur][k]) imx[cur][k] = sc; if (hmm->isc[(int) dsq[i]][k] != -INFTY) imx[cur][k] += hmm->isc[(int) dsq[i]][k]; else imx[cur][k] = -INFTY; } } /* N state */ xmx[cur][XMN] = -INFTY; if ((sc = xmx[prv][XMN] + hmm->xsc[XTN][LOOP]) > -INFTY) xmx[cur][XMN] = sc; /* E state */ xmx[cur][XME] = -INFTY; for (k = k1; k <= k3 && k <= hmm->M; k++) if ((sc = mmx[cur][k] + hmm->esc[k]) > xmx[cur][XME]) xmx[cur][XME] = sc; /* B state */ xmx[cur][XMB] = -INFTY; if ((sc = xmx[cur][XMN] + hmm->xsc[XTN][MOVE]) > -INFTY) xmx[cur][XMB] = sc; /* C state */ xmx[cur][XMC] = -INFTY; if ((sc = xmx[prv][XMC] + hmm->xsc[XTC][LOOP]) > -INFTY) xmx[cur][XMC] = sc; if ((sc = xmx[cur][XME] + hmm->xsc[XTE][MOVE]) > xmx[cur][XMC]) xmx[cur][XMC] = sc; } /* Row s2%2 in fwd matrix now contains valid scores from s1 (start) to s2, * with J transitions disallowed (no cycles through model). */ /***************************************************************** * Backwards pass. *****************************************************************/ /* Allocate our backwards two rows. Init last row. */ bck = AllocPlan7Matrix(2, hmm->M, &xmx, &mmx, &imx, &dmx); nxt = s3%2; xmx[nxt][XMN] = xmx[nxt][XMB] = -INFTY; xmx[nxt][XME] = xmx[nxt][XMC] = -INFTY; for (k = k1; k <= k3 + 1; k++) mmx[nxt][k] = imx[nxt][k] = dmx[nxt][k] = -INFTY; cur = !nxt; mmx[cur][k3+1] = imx[cur][k3+1] = dmx[cur][k3+1] = -INFTY; /* Where to put the zero for our end point on last row. */ switch (t3) { case STM: mmx[nxt][k3] = 0; break; case STI: imx[nxt][k3] = 0; break; case STN: xmx[nxt][XMN] = 0; break; case STC: xmx[nxt][XMC] = 0; break; /* must be an emitting C */ case STT: xmx[nxt][XMC] = hmm->xsc[XTC][MOVE]; break; /* C->T implied */ default: Die("you can't init get_wee_midpt with a %s\n", Statetype(t3)); } /* Still initializing. * In the case t3==STT, there are a few horizontal moves possible * on row s3, because STT isn't an emitter. All other states are * emitters, so their connections have to be to the previous row s3-1. */ if (t3 == STT) { /* E->C */ xmx[nxt][XME] = xmx[nxt][XMC] + hmm->xsc[XTE][MOVE]; /* M->E */ for (k = k3; k >= k1; k--) { mmx[nxt][k] = xmx[nxt][XME] + hmm->esc[k]; if (s3 != s2) mmx[nxt][k] += hmm->msc[(int)dsq[s3]][k]; } } /* Start recursive DP; sweep backwards to chosen s2 midpoint. * Done as a pull. M, I scores at current row do /not/ include * emission scores. Be careful of integer underflow. */ for (i = s3-1; i >= s2; i--) { /* note i < L, so i+1 is always a legal index */ cur = i%2; nxt = !cur; /* C pulls from C (T is special cased) */ xmx[cur][XMC] = -INFTY; if ((sc = xmx[nxt][XMC] + hmm->xsc[XTC][LOOP]) > -INFTY) xmx[cur][XMC] = sc; /* B pulls from M's */ xmx[cur][XMB] = -INFTY; for (k = k1; k <= k3; k++) if ((sc = mmx[nxt][k] + hmm->bsc[k]) > xmx[cur][XMB]) xmx[cur][XMB] = sc; /* E pulls from C (J disallowed) */ xmx[cur][XME] = -INFTY; if ((sc = xmx[cur][XMC] + hmm->xsc[XTE][MOVE]) > -INFTY) xmx[cur][XME] = sc; /* N pulls from B, N */ xmx[cur][XMN] = -INFTY; if ((sc = xmx[cur][XMB] + hmm->xsc[XTN][MOVE]) > -INFTY) xmx[cur][XMN] = sc; if ((sc = xmx[nxt][XMN] + hmm->xsc[XTN][LOOP]) > xmx[cur][XMN]) xmx[cur][XMN] = sc; /* Main recursion across model */ for (k = k3; k >= k1; k--) { /* special case k == M */ if (k == hmm->M) { mmx[cur][k] = xmx[cur][XME]; /* p=1 transition to E by definition */ dmx[cur][k] = -INFTY; /* doesn't exist */ imx[cur][k] = -INFTY; /* doesn't exist */ if (i != s2) mmx[cur][k] += hmm->msc[(int)dsq[i]][k]; continue; } /* below this k < M, so k+1 is a legal index */ /* pull into match state */ mmx[cur][k] = -INFTY; if ((sc = xmx[cur][XME] + hmm->esc[k]) > -INFTY) mmx[cur][k] = sc; if ((sc = mmx[nxt][k+1] + hmm->tsc[k][TMM]) > mmx[cur][k]) mmx[cur][k] = sc; if ((sc = imx[nxt][k] + hmm->tsc[k][TMI]) > mmx[cur][k]) mmx[cur][k] = sc; if ((sc = dmx[cur][k+1] + hmm->tsc[k][TMD]) > mmx[cur][k]) mmx[cur][k] = sc; if (i != s2) mmx[cur][k] += hmm->msc[(int)dsq[i]][k]; /* pull into delete state */ dmx[cur][k] = -INFTY; if ((sc = mmx[nxt][k+1] + hmm->tsc[k][TDM]) > -INFTY) dmx[cur][k] = sc; if ((sc = dmx[cur][k+1] + hmm->tsc[k][TDD]) > dmx[cur][k]) dmx[cur][k] = sc; /* pull into insert state */ imx[cur][k] = -INFTY; if ((sc = mmx[nxt][k+1] + hmm->tsc[k][TIM]) > -INFTY) imx[cur][k] = sc; if ((sc = imx[nxt][k] + hmm->tsc[k][TII]) > imx[cur][k]) imx[cur][k] = sc; if (i != s2) imx[cur][k] += hmm->isc[(int)dsq[i]][k]; } } /***************************************************************** * DP complete; we have both forward and backward passes. Now we * look across the s2 row and find the optimal emitting state. *****************************************************************/ cur = s2%2; max = -INFTY; for (k = k1; k <= k3; k++) { if ((sc = fwd->mmx[cur][k] + bck->mmx[cur][k]) > max) { k2 = k; t2 = STM; max = sc; } if ((sc = fwd->imx[cur][k] + bck->imx[cur][k]) > max) { k2 = k; t2 = STI; max = sc; } } if ((sc = fwd->xmx[cur][XMN] + bck->xmx[cur][XMN]) > max) { k2 = 1; t2 = STN; max = sc; } if ((sc = fwd->xmx[cur][XMC] + bck->xmx[cur][XMC]) > max) { k2 = hmm->M; t2 = STC; max = sc; } /***************************************************************** * Garbage collection, return. *****************************************************************/ FreePlan7Matrix(fwd); FreePlan7Matrix(bck); *ret_k2 = k2; *ret_t2 = t2; *ret_s2 = s2; return Scorify(max); } wise-2.4.1/src/HMMer2/hmmio.c0000644000175000001440000015142307313404525015160 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Washington University School of Medicine * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* hmmio.c * * Input/output of HMMs. * * As of HMMER 2.0, HMMs are saved by default in a tabular ASCII format * as log-odds or log probabilities scaled to an integer. A binary save * file format is also available which is faster to access (a * consideration which might be important for HMM library applications). * HMMs can be concatenated into HMM libraries. * * A comment on loss of accuracy. Storing a number as a scaled log * probability guarantees us an error of about 0.035% or * less in the retrieved probability. We also are relatively invulnerable * to the truncation errors which HMMER 1.8 was vulnerable to. * * Magic numbers (both for the ASCII and binary save formats) are used * to label save files with a major version number. This simplifies the task of * backwards compatibility as new versions of the program are created. * Reverse but not forward compatibility is guaranteed. I.e. HMMER 2.0 * can read `1.7' save files, but not vice versa. Note that the major * version number in the save files is NOT the version of the software * that generated it; rather, the number of the last major version in which * save format changed. * ****************************************************************** * * The HMM input API: * * HMMFILE *hmmfp; * char *hmmfile; * struct plan7_s *hmm; * char env[] = "HMMERDB"; (a la BLASTDB) * * hmmfp = HMMFileOpen(hmmfile, env) NULL on failure * while (HMMFileRead(hmmfp, &hmm)) 0 if no more HMMs * if (hmm == NULL) Die(); NULL on file parse failure * whatever; * FreeHMM(hmm); * } * HMMFileClose(hmmfp); * ***************************************************************** * * The HMM output API: * * FILE *ofp; * struct plan7_s *hmm; * * WriteAscHMM(ofp, hmm); to write/append an HMM to open file * or WriteBinHMM(ofp, hmm); to write/append binary format HMM to open file * ***************************************************************** * * V1.0: original implementation * V1.1: regularizers removed from model structure * V1.7: ref and cs annotation lines added from alignment, one * char per match state 1..M * V1.9: null model and name added to HMM structure. ASCII format changed * to compact tabular one. * V2.0: Plan7. Essentially complete rewrite. */ #include #include #include #include #include #include /* to get SEEK_CUR definition on silly Suns */ #include "squid.h" #include "config.h" #include "structs.h" #include "funcs.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Magic numbers identifying binary formats. * Do not change the old magics! Necessary for backwards compatibility. */ static unsigned int v10magic = 0xe8ededb1; /* v1.0 binary: "hmm1" + 0x80808080 */ static unsigned int v10swap = 0xb1edede8; /* byteswapped v1.0 */ static unsigned int v11magic = 0xe8ededb2; /* v1.1 binary: "hmm2" + 0x80808080 */ static unsigned int v11swap = 0xb2edede8; /* byteswapped v1.1 */ static unsigned int v17magic = 0xe8ededb3; /* v1.7 binary: "hmm3" + 0x80808080 */ static unsigned int v17swap = 0xb3edede8; /* byteswapped v1.7 */ static unsigned int v19magic = 0xe8ededb4; /* V1.9 binary: "hmm4" + 0x80808080 */ static unsigned int v19swap = 0xb4edede8; /* V1.9 binary, byteswapped */ static unsigned int v20magic = 0xe8ededb5; /* V2.0 binary: "hmm5" + 0x80808080 */ static unsigned int v20swap = 0xb5edede8; /* V2.0 binary, byteswapped */ /* Old HMMER 1.x file formats. */ #define HMMER1_0B 1 /* binary HMMER 1.0 */ #define HMMER1_0F 2 /* flat ascii HMMER 1.0 */ #define HMMER1_1B 3 /* binary HMMER 1.1 */ #define HMMER1_1F 4 /* flat ascii HMMER 1.1 */ #define HMMER1_7B 5 /* binary HMMER 1.7 */ #define HMMER1_7F 6 /* flat ascii HMMER 1.7 */ #define HMMER1_9B 7 /* HMMER 1.9 binary */ #define HMMER1_9F 8 /* HMMER 1.9 flat ascii */ static int read_asc20hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm); static int read_bin20hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm); static int read_asc19hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm); static int read_bin19hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm); static int read_asc17hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm); static int read_bin17hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm); static int read_asc11hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm); static int read_bin11hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm); static int read_asc10hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm); static int read_bin10hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm); static void byteswap(char *swap, int nbytes); static char *prob2ascii(float p, float null); static float ascii2prob(char *s, float null); static void write_bin_string(FILE *fp, char *s); static int read_bin_string(FILE *fp, int doswap, char **ret_s); static void multiline(FILE *fp, char *pfx, char *s); static struct plan9_s *read_plan9_binhmm(FILE *fp, int version, int swapped); static struct plan9_s *read_plan9_aschmm(FILE *fp, int version); /***************************************************************** * HMM input API functions: * HMMFileOpen() * HMMFileRead() * HMMFileClose() * HMMFileRewind() *****************************************************************/ /* Function: HMMFileOpen() * * Purpose: Open an HMM file for reading. The file may be either * an index for a library of HMMs, or an HMM. If it's * a library, sets is_library flag to TRUE in the HMMFILE * structure. * * Args: hmmfile - name of file * env - NULL, or environment variable for HMM database. * * Return: Valid HMMFILE *, or NULL on failure. * hmmfp->f has been advanced beyond the first * line (for text files) or the magic number (for binaries). */ HMMFILE * HMMFileOpen(char *hmmfile, char *env) { return HMMFileOpenFseek(hmmfile,env,0); } /* Function: HMMFileOpenFseek() * * Purpose: Open an HMM file for reading at a byte offset * The file may be either * an index for a library of HMMs, or an HMM. If it's * a library, sets is_library flag to TRUE in the HMMFILE * structure. * * Adapted by Ewan * * Args: hmmfile - name of file * env - NULL, or environment variable for HMM database. * * Return: Valid HMMFILE *, or NULL on failure. * hmmfp->f has been advanced beyond the first * line (for text files) or the magic number (for binaries). */ HMMFILE * HMMFileOpenFseek(char *hmmfile, char *env,int byte_pos) { HMMFILE *hmmfp; unsigned int magic; char buf[512]; hmmfp = (HMMFILE *) MallocOrDie (sizeof(HMMFILE)); hmmfp->f = NULL; hmmfp->parser = NULL; hmmfp->is_binary = FALSE; hmmfp->byteswap = FALSE; /* Open the file. Look in current directory. * If that doesn't work, check environment var for * a second possible directory (usually the location * of a system-wide HMM library) */ if ((hmmfp->f = fopen(hmmfile, "r")) == NULL && (hmmfp->f = EnvFileOpen(hmmfile, env)) == NULL) return NULL; /* EWAN fseek to byte_pos to get the correct position in the file */ HMMFseek(hmmfp,byte_pos); /* Check for binary or byteswapped binary format * by peeking at first 4 bytes. */ if (! fread((char *) &magic, sizeof(unsigned int), 1, hmmfp->f)) { HMMFileClose(hmmfp); return NULL; } /*EWAN ok... this rewind should be back to the byte position */ HMMFseek(hmmfp,byte_pos); /* old code */ /* rewind(hmmfp->f); */ if (magic == v20magic) { hmmfp->parser = read_bin20hmm; hmmfp->is_binary = TRUE; return hmmfp; } else if (magic == v20swap) { hmmfp->parser = read_bin20hmm; hmmfp->is_binary = TRUE; hmmfp->byteswap = TRUE; return hmmfp; } else if (magic == v19magic) { hmmfp->parser = read_bin19hmm; hmmfp->is_binary = TRUE; return hmmfp; } else if (magic == v19swap) { hmmfp->parser = read_bin19hmm; hmmfp->is_binary = TRUE; hmmfp->byteswap = TRUE; return hmmfp; } else if (magic == v17magic) { hmmfp->parser = read_bin17hmm; hmmfp->is_binary = TRUE; return hmmfp; } else if (magic == v17swap) { hmmfp->parser = read_bin17hmm; hmmfp->is_binary = TRUE; hmmfp->byteswap = TRUE; return hmmfp; } else if (magic == v11magic) { hmmfp->parser = read_bin11hmm; hmmfp->is_binary = TRUE; return hmmfp; } else if (magic == v11swap) { hmmfp->parser = read_bin11hmm; hmmfp->is_binary = TRUE; hmmfp->byteswap = TRUE; return hmmfp; } else if (magic == v10magic) { hmmfp->parser = read_bin10hmm; hmmfp->is_binary = TRUE; return hmmfp; } else if (magic == v10swap) { hmmfp->parser = read_bin10hmm; hmmfp->is_binary = TRUE; hmmfp->byteswap = TRUE; return hmmfp; } /* else we fall thru; it may be an ASCII file. */ /* If magic looks binary but we don't recognize it, choke and die. */ if (magic & 0x80000000) { Warn("\ %s appears to be a binary but format is not recognized\n\ It may be from a HMMER version more recent than yours,\n\ or may be a different kind of binary altogether.\n", hmmfile); HMMFileClose(hmmfp); return NULL; } /* Check for ASCII format by peeking at first word. */ if (fgets(buf, 512, hmmfp->f) == NULL) { HMMFileClose(hmmfp); return NULL; } /*EWAN ok... this rewind should be back to the byte position */ HMMFseek(hmmfp,byte_pos); if (strncmp("HMMER2.0", buf, 8) == 0) { hmmfp->parser = read_asc20hmm; return hmmfp; } else if (strncmp("HMMER v1.9", buf, 10) == 0) { hmmfp->parser = read_asc19hmm; return hmmfp; } else if (strncmp("# HMM v1.7", buf, 10) == 0) { hmmfp->parser = read_asc17hmm; return hmmfp; } else if (strncmp("# HMM v1.1", buf, 10) == 0) { hmmfp->parser = read_asc11hmm; return hmmfp; } else if (strncmp("# HMM v1.0", buf, 10) == 0) { hmmfp->parser = read_asc10hmm; return hmmfp; } /* If we haven't recognized it yet, it's bogus. */ HMMFileClose(hmmfp); return NULL; } int HMMFileRead(HMMFILE *hmmfp, struct plan7_s **ret_hmm) { return (*hmmfp->parser)(hmmfp, ret_hmm); } void HMMFileClose(HMMFILE *hmmfp) { if (hmmfp->f != NULL) fclose(hmmfp->f); free(hmmfp); } void HMMFileRewind(HMMFILE *hmmfp) { rewind(hmmfp->f); } long HMMFtell(HMMFILE *hmmfp) { return ftell(hmmfp->f); } int HMMFseek(HMMFILE * hmmfp,long pos) { return fseek(hmmfp->f,pos,SEEK_SET); } /***************************************************************** * HMM output API: * WriteAscHMM() * WriteBinHMM() * *****************************************************************/ /* Function: WriteAscHMM() * * Purpose: Save an HMM in flat text ASCII format. * * Args: fp - open file for writing * hmm - HMM to save */ void WriteAscHMM(FILE *fp, struct plan7_s *hmm) { int k; /* counter for nodes */ int x; /* counter for symbols */ int ts; /* counter for state transitions */ fprintf(fp, "HMMER2.0\n"); /* magic header */ /* write header information */ fprintf(fp, "NAME %s\n", hmm->name); fprintf(fp, "DESC %s\n", (hmm->flags & PLAN7_DESC) ? hmm->desc : ""); fprintf(fp, "LENG %d\n", hmm->M); fprintf(fp, "ALPH %s\n", (Alphabet_type == hmmAMINO) ? "Amino":"Nucleic"); fprintf(fp, "RF %s\n", (hmm->flags & PLAN7_RF) ? "yes" : "no"); fprintf(fp, "CS %s\n", (hmm->flags & PLAN7_CS) ? "yes" : "no"); multiline(fp, "COM ", hmm->comlog); fprintf(fp, "NSEQ %d\n", hmm->nseq); fprintf(fp, "DATE %s\n", hmm->ctime); /* Specials */ fputs("XT ", fp); for (k = 0; k < 4; k++) for (x = 0; x < 2; x++) fprintf(fp, "%6s ", prob2ascii(hmm->xt[k][x], 1.0)); fputs("\n", fp); /* Save the null model first, so HMM readers can decode * log odds scores on the fly. Save as log odds probabilities * relative to 1/Alphabet_size (flat distribution) */ fprintf(fp, "NULT "); fprintf(fp, "%6s ", prob2ascii(hmm->p1, 1.0)); /* p1 */ fprintf(fp, "%6s\n", prob2ascii(1.0-hmm->p1, 1.0)); /* p2 */ fputs("NULE ", fp); for (x = 0; x < Alphabet_size; x++) fprintf(fp, "%6s ", prob2ascii(hmm->null[x], 1/(float)(Alphabet_size))); fputs("\n", fp); /* EVD statistics */ if (hmm->flags & PLAN7_STATS) fprintf(fp, "EVD %10f %10f\n", hmm->mu, hmm->lambda); /* Print header */ fprintf(fp, "HMM "); for (x = 0; x < Alphabet_size; x++) fprintf(fp, " %c ", Alphabet[x]); fprintf(fp, "\n"); fprintf(fp, " %6s %6s %6s %6s %6s %6s %6s %6s %6s\n", "m->m", "m->i", "m->d", "i->m", "i->i", "d->m", "d->d", "b->m", "m->e"); /* Print HMM parameters (main section of the save file) */ fprintf(fp, " %6s %6s ", prob2ascii(1-hmm->tbd1, 1.0), "*"); fprintf(fp, "%6s\n", prob2ascii(hmm->tbd1, 1.0)); for (k = 1; k <= hmm->M; k++) { /* Line 1: k and match emissions */ fprintf(fp, " %5d ", k); for (x = 0; x < Alphabet_size; x++) fprintf(fp, "%6s ", prob2ascii(hmm->mat[k][x], hmm->null[x])); fputs("\n", fp); /* Line 2: RF and insert emissions */ fprintf(fp, " %5c ", hmm->flags & PLAN7_RF ? hmm->rf[k] : '-'); for (x = 0; x < Alphabet_size; x++) fprintf(fp, "%6s ", (k < hmm->M) ? prob2ascii(hmm->ins[k][x], hmm->null[x]) : "*"); fputs("\n", fp); /* Line 3: CS and transition probs */ fprintf(fp, " %5c ", hmm->flags & PLAN7_CS ? hmm->cs[k] : '-'); for (ts = 0; ts < 7; ts++) fprintf(fp, "%6s ", (k < hmm->M) ? prob2ascii(hmm->t[k][ts], 1.0) : "*"); fprintf(fp, "%6s ", prob2ascii(hmm->begin[k], 1.0)); fprintf(fp, "%6s ", prob2ascii(hmm->end[k], 1.0)); fputs("\n", fp); } fputs("//\n", fp); } /* Function: WriteBinHMM() * * Purpose: Write an HMM in binary format. */ void WriteBinHMM(FILE *fp, struct plan7_s *hmm) { int k; /* ye olde magic number */ fwrite((char *) &(v20magic), sizeof(long), 1, fp); /* header section */ fwrite((char *) &(hmm->flags), sizeof(int), 1, fp); write_bin_string(fp, hmm->name); if (hmm->flags & PLAN7_DESC) write_bin_string(fp, hmm->desc); fwrite((char *) &(hmm->M), sizeof(int), 1, fp); fwrite((char *) &(Alphabet_type), sizeof(int), 1, fp); if (hmm->flags & PLAN7_RF) fwrite((char *) hmm->rf, sizeof(char), hmm->M+1, fp); if (hmm->flags & PLAN7_CS) fwrite((char *) hmm->cs, sizeof(char), hmm->M+1, fp); write_bin_string(fp, hmm->comlog); fwrite((char *) &(hmm->nseq), sizeof(int), 1, fp); write_bin_string(fp, hmm->ctime); /* Specials */ for (k = 0; k < 4; k++) fwrite((char *) hmm->xt[k], sizeof(float), 2, fp); /* Null model */ fwrite((char *)&(hmm->p1), sizeof(float), 1, fp); fwrite((char *) hmm->null, sizeof(float), Alphabet_size, fp); /* EVD stats */ if (hmm->flags & PLAN7_STATS) { fwrite((char *) &(hmm->mu), sizeof(float), 1, fp); fwrite((char *) &(hmm->lambda), sizeof(float), 1, fp); } /* entry/exit probabilities */ fwrite((char *)&(hmm->tbd1),sizeof(float), 1, fp); fwrite((char *) hmm->begin, sizeof(float), hmm->M+1, fp); fwrite((char *) hmm->end, sizeof(float), hmm->M+1, fp); /* main model */ for (k = 1; k <= hmm->M; k++) fwrite((char *) hmm->mat[k], sizeof(float), Alphabet_size, fp); for (k = 1; k < hmm->M; k++) fwrite((char *) hmm->ins[k], sizeof(float), Alphabet_size, fp); for (k = 1; k < hmm->M; k++) fwrite((char *) hmm->t[k], sizeof(float), 7, fp); } /***************************************************************** * * Internal: HMM file parsers for various releases of HMMER. * * read_{asc,bin}xxhmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm) * * Upon return, *ret_hmm is an allocated Plan7 HMM. * Return 0 if no more HMMs in the file (normal). * Return 1 and *ret_hmm = something if we got an HMM (normal) * Return 1 if an error occurs (meaning "I tried to * read something...") and *ret_hmm == NULL (meaning * "...but it wasn't an HMM"). I know, this is a funny * way to handle errors. * *****************************************************************/ static int read_asc20hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm) { struct plan7_s *hmm; char buffer[512]; char *s; int M; float p; int k, x; hmm = NULL; if (feof(hmmfp->f) || fgets(buffer, 512, hmmfp->f) == NULL) return 0; if (strncmp(buffer, "HMMER2.0", 8) != 0) goto FAILURE; /* Get the header information: tag/value pairs in any order, * ignore unknown tags, stop when "HMM" is reached (signaling * start of main model) */ hmm = AllocPlan7Shell(); M = -1; while (fgets(buffer, 512, hmmfp->f) != NULL) { if (strncmp(buffer, "NAME ", 5) == 0) Plan7SetName(hmm, buffer+6); else if (strncmp(buffer, "DESC ", 5) == 0) Plan7SetDescription(hmm, buffer+6); else if (strncmp(buffer, "LENG ", 5) == 0) M = atoi(buffer+6); else if (strncmp(buffer, "NSEQ ", 5) == 0) hmm->nseq = atoi(buffer+6); else if (strncmp(buffer, "ALPH ", 5) == 0) { /* Alphabet type */ s2upper(buffer+6); if (strncmp(buffer+6, "AMINO", 5) == 0) SetAlphabet(hmmAMINO); else if (strncmp(buffer+6, "NUCLEIC", 7) == 0) SetAlphabet(hmmNUCLEIC); else goto FAILURE; } else if (strncmp(buffer, "RF ", 5) == 0) { /* Reference annotation present? */ if (sre_toupper(*(buffer+6)) == 'Y') hmm->flags |= PLAN7_RF; } else if (strncmp(buffer, "CS ", 5) == 0) { /* Consensus annotation present? */ if (sre_toupper(*(buffer+6)) == 'Y') hmm->flags |= PLAN7_CS; } else if (strncmp(buffer, "COM ", 5) == 0) { /* Command line log */ StringChop(buffer+6); if (hmm->comlog == NULL) hmm->comlog = Strdup(buffer+6); else { hmm->comlog = ReallocOrDie(hmm->comlog, sizeof(char *) * (strlen(hmm->comlog) + 1 + strlen(buffer+6))); strcat(hmm->comlog, "\n"); strcat(hmm->comlog, buffer+6); } } else if (strncmp(buffer, "DATE ", 5) == 0) { /* Date file created */ StringChop(buffer+6); hmm->ctime= Strdup(buffer+6); } else if (strncmp(buffer, "XT ", 5) == 0) { /* Special transition section */ if ((s = strtok(buffer+6, " \t\n")) == NULL) goto FAILURE; for (k = 0; k < 4; k++) for (x = 0; x < 2; x++) { if (s == NULL) goto FAILURE; hmm->xt[k][x] = ascii2prob(s, 1.0); s = strtok(NULL, " \t\n"); } } else if (strncmp(buffer, "NULT ", 5) == 0) { /* Null model transitions */ if ((s = strtok(buffer+6, " \t\n")) == NULL) goto FAILURE; hmm->p1 = ascii2prob(s, 1.); if ((s = strtok(NULL, " \t\n")) == NULL) goto FAILURE; hmm->p1 = hmm->p1 / (hmm->p1 + ascii2prob(s, 1.0)); } else if (strncmp(buffer, "NULE ", 5) == 0) { /* Null model emissions */ if (Alphabet_type == hmmNOTSETYET) Die("ALPH must precede NULE in HMM save files"); s = strtok(buffer+6, " \t\n"); for (x = 0; x < Alphabet_size; x++) { if (s == NULL) goto FAILURE; hmm->null[x] = ascii2prob(s, 1./(float)Alphabet_size); s = strtok(NULL, " \t\n"); } } else if (strncmp(buffer, "EVD ", 5) == 0) { /* EVD parameters */ hmm->flags |= PLAN7_STATS; if ((s = strtok(buffer+6, " \t\n")) == NULL) goto FAILURE; hmm->mu = atof(s); if ((s = strtok(NULL, " \t\n")) == NULL) goto FAILURE; hmm->lambda = atof(s); } else if (strncmp(buffer, "HMM ", 5) == 0) break; } /* partial check for mandatory fields */ if (feof(hmmfp->f)) goto FAILURE; if (M < 1) goto FAILURE; if (hmm->name == NULL) goto FAILURE; if (Alphabet_type == hmmNOTSETYET) goto FAILURE; /* Main model section. Read as integer log odds, convert * to probabilities */ AllocPlan7Body(hmm, M); /* skip an annotation line */ if (fgets(buffer, 512, hmmfp->f) == NULL) goto FAILURE; /* parse tbd1 line */ if (fgets(buffer, 512, hmmfp->f) == NULL) goto FAILURE; if ((s = strtok(buffer, " \t\n")) == NULL) goto FAILURE; p = ascii2prob(s, 1.0); if ((s = strtok(NULL, " \t\n")) == NULL) goto FAILURE; if ((s = strtok(NULL, " \t\n")) == NULL) goto FAILURE; hmm->tbd1 = ascii2prob(s, 1.0); hmm->tbd1 = hmm->tbd1 / (p + hmm->tbd1); /* main model */ for (k = 1; k <= hmm->M; k++) { /* Line 1: k and match emissions */ if (fgets(buffer, 512, hmmfp->f) == NULL) goto FAILURE; if ((s = strtok(buffer, " \t\n")) == NULL) goto FAILURE; if (atoi(s) != k) goto FAILURE; for (x = 0; x < Alphabet_size; x++) { if ((s = strtok(NULL, " \t\n")) == NULL) goto FAILURE; hmm->mat[k][x] = ascii2prob(s, hmm->null[x]); } /* Line 2: RF and insert emissions */ if (fgets(buffer, 512, hmmfp->f) == NULL) goto FAILURE; if ((s = strtok(buffer, " \t\n")) == NULL) goto FAILURE; if (hmm->flags & PLAN7_RF) hmm->rf[k] = *s; if (k < hmm->M) { for (x = 0; x < Alphabet_size; x++) { if ((s = strtok(NULL, " \t\n")) == NULL) goto FAILURE; hmm->ins[k][x] = ascii2prob(s, hmm->null[x]); } } /* Line 3: CS and transitions */ if (fgets(buffer, 512, hmmfp->f) == NULL) goto FAILURE; if ((s = strtok(buffer, " \t\n")) == NULL) goto FAILURE; if (hmm->flags & PLAN7_CS) hmm->cs[k] = *s; for (x = 0; x < 7; x++) { if ((s = strtok(NULL, " \t\n")) == NULL) goto FAILURE; if (k < hmm->M) hmm->t[k][x] = ascii2prob(s, 1.0); } if ((s = strtok(NULL, " \t\n")) == NULL) goto FAILURE; hmm->begin[k] = ascii2prob(s, 1.0); if ((s = strtok(NULL, " \t\n")) == NULL) goto FAILURE; hmm->end[k] = ascii2prob(s, 1.0); } /* end loop over main model */ /* Advance to record separator */ while (fgets(buffer, 512, hmmfp->f) != NULL) if (strncmp(buffer, "//", 2) == 0) break; /* Set flags and return */ hmm->flags |= PLAN7_HASPROB; /* probabilities are valid */ hmm->flags &= ~PLAN7_HASBITS; /* scores are not valid */ *ret_hmm = hmm; return 1; FAILURE: if (hmm != NULL) FreePlan7(hmm); *ret_hmm = NULL; return 1; } static int read_bin20hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm) { struct plan7_s *hmm; int k,x; int type; unsigned long magic; hmm = NULL; /* Header section */ if (feof(hmmfp->f)) return 0; if (! fread((char *) &magic, sizeof(long), 1, hmmfp->f)) return 0; if (hmmfp->byteswap) byteswap((char *)&magic, sizeof(long)); if (magic != v20magic) goto FAILURE; /* allocate HMM shell for header info */ hmm = AllocPlan7Shell(); /* flags */ if (! fread((char *) &(hmm->flags), sizeof(int), 1, hmmfp->f)) goto FAILURE; if (hmmfp->byteswap) byteswap((char *)&(hmm->flags), sizeof(int)); /* name */ if (! read_bin_string(hmmfp->f, hmmfp->byteswap, &(hmm->name))) goto FAILURE; /* optional description */ if ((hmm->flags & PLAN7_DESC) && ! read_bin_string(hmmfp->f, hmmfp->byteswap, &(hmm->desc))) goto FAILURE; /* length of model */ if (! fread((char *) &hmm->M, sizeof(int), 1, hmmfp->f)) goto FAILURE; if (hmmfp->byteswap) byteswap((char *)&(hmm->M), sizeof(int)); /* alphabet type */ if (! fread((char *) &type, sizeof(int), 1, hmmfp->f)) goto FAILURE; if (hmmfp->byteswap) byteswap((char *)&type, sizeof(int)); if (Alphabet_type == 0) SetAlphabet(type); /* now allocate for rest of model */ AllocPlan7Body(hmm, hmm->M); /* optional #=RF alignment annotation */ if ((hmm->flags & PLAN7_RF) && !fread((char *) hmm->rf, sizeof(char), hmm->M+1, hmmfp->f)) goto FAILURE; hmm->rf[hmm->M+1] = '\0'; /* optional #=CS alignment annotation */ if ((hmm->flags & PLAN7_CS) && !fread((char *) hmm->cs, sizeof(char), hmm->M+1, hmmfp->f)) goto FAILURE; hmm->cs[hmm->M+1] = '\0'; /* command line log */ if (!read_bin_string(hmmfp->f, hmmfp->byteswap, &(hmm->comlog))) goto FAILURE; /* nseq */ if (!fread((char *) &(hmm->nseq),sizeof(int), 1, hmmfp->f)) goto FAILURE; /* creation time */ if (!read_bin_string(hmmfp->f, hmmfp->byteswap, &(hmm->ctime))) goto FAILURE; /* specials */ for (k = 0; k < 4; k++) if (! fread((char *) hmm->xt[k], sizeof(float), 2, hmmfp->f)) goto FAILURE; /* null model */ if (!fread((char *) &(hmm->p1),sizeof(float), 1, hmmfp->f)) goto FAILURE; if (!fread((char *)hmm->null,sizeof(float),Alphabet_size,hmmfp->f))goto FAILURE; /* EVD stats */ if (hmm->flags & PLAN7_STATS) { if (! fread((char *) &(hmm->mu), sizeof(float), 1, hmmfp->f))goto FAILURE; if (! fread((char *) &(hmm->lambda), sizeof(float), 1, hmmfp->f))goto FAILURE; if (hmmfp->byteswap) { byteswap((char *)&(hmm->mu), sizeof(float)); byteswap((char *)&(hmm->lambda), sizeof(float)); } } /* entry/exit probabilities */ if (! fread((char *)&(hmm->tbd1), sizeof(float), 1, hmmfp->f)) goto FAILURE; if (! fread((char *) hmm->begin, sizeof(float), hmm->M+1, hmmfp->f)) goto FAILURE; if (! fread((char *) hmm->end, sizeof(float), hmm->M+1, hmmfp->f)) goto FAILURE; /* main model */ for (k = 1; k <= hmm->M; k++) if (! fread((char *) hmm->mat[k], sizeof(float), Alphabet_size, hmmfp->f)) goto FAILURE; for (k = 1; k < hmm->M; k++) if (! fread((char *) hmm->ins[k], sizeof(float), Alphabet_size, hmmfp->f)) goto FAILURE; for (k = 1; k < hmm->M; k++) if (! fread((char *) hmm->t[k], sizeof(float), 7, hmmfp->f)) goto FAILURE; /* byteswapping */ if (hmmfp->byteswap) { for (x = 0; x < Alphabet_size; x++) byteswap((char *) &(hmm->null[x]), sizeof(float)); byteswap((char *)&(hmm->p1), sizeof(float)); byteswap((char *)&(hmm->tbd1), sizeof(float)); for (k = 1; k <= hmm->M; k++) { for (x = 0; x < Alphabet_size; x++) byteswap((char *)&(hmm->mat[k][x]), sizeof(float)); if (k < hmm->M) for (x = 0; x < Alphabet_size; x++) byteswap((char *)&(hmm->ins[k][x]), sizeof(float)); byteswap((char *)&(hmm->begin[k]), sizeof(float)); byteswap((char *)&(hmm->end[k]), sizeof(float)); for (x = 0; x < 7; x++) byteswap((char *)&(hmm->t[k][x]), sizeof(float)); } } /* set flags and return */ hmm->flags |= PLAN7_HASPROB; /* probabilities are valid */ hmm->flags &= ~PLAN7_HASBITS; /* scores are not yet valid */ *ret_hmm = hmm; return 1; FAILURE: if (hmm != NULL) FreePlan7(hmm); *ret_hmm = NULL; return 1; } /* Function: read_asc19hmm() * Date: Tue Apr 7 17:11:29 1998 [StL] * * Purpose: Read ASCII-format tabular (1.9 and later) save files. * * HMMER 1.9 was only used internally at WashU, as far as * I know, so this code shouldn't be terribly important * to anyone. */ static int read_asc19hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm) { struct plan7_s *hmm; FILE *fp; char buffer[512]; char *s; int M; /* length of model */ int k; /* state number */ int x; /* symbol number */ hmm = NULL; fp = hmmfp->f; if (feof(fp) || fgets(buffer, 512, fp) == NULL) return 0; if (strncmp(buffer, "HMMER v1.9", 10) != 0) goto FAILURE; hmm = AllocPlan7Shell(); /* read M from first line */ if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; M = atoi(s); /* model length */ if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; /* ignore alphabet size */ if ((s = Getword(fp, sqdARG_STRING)) == NULL) goto FAILURE; Plan7SetName(hmm, s); /* name */ if ((s = Getword(fp, sqdARG_STRING)) == NULL) goto FAILURE; s2upper(s); /* alphabet type */ if (strcmp(s, "AMINO") == 0) SetAlphabet(hmmAMINO); else if (strcmp(s, "NUCLEIC") == 0) SetAlphabet(hmmNUCLEIC); else goto FAILURE; /* read alphabet, make sure it's Plan7-compatible... */ if ((s = Getword(fp, sqdARG_STRING)) == NULL) goto FAILURE; if (strncmp(s, Alphabet, Alphabet_size) != 0) goto FAILURE; /* whether we have ref, cs info */ if ((s = Getword(fp, sqdARG_STRING)) == NULL) goto FAILURE; if (strcmp(s, "yes") == 0) hmm->flags |= PLAN7_RF; if ((s = Getword(fp, sqdARG_STRING)) == NULL) goto FAILURE; if (strcmp(s, "yes") == 0) hmm->flags |= PLAN7_CS; /* null model. 1.9 has emissions only. invent transitions. */ if ((s = Getword(fp, sqdARG_STRING)) == NULL) goto FAILURE; if (strcmp(s, "null") != 0) goto FAILURE; for (x = 0; x < Alphabet_size; x++) { if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; hmm->null[x] = ascii2prob(s, 1.0); } hmm->p1 = (Alphabet_type == hmmAMINO)? 350./351. : 1000./1001.; /* Done with header; check some stuff before proceeding */ if (feof(hmmfp->f)) goto FAILURE; if (M < 1) goto FAILURE; if (hmm->name == NULL) goto FAILURE; if (Alphabet_type == hmmNOTSETYET) goto FAILURE; /* Allocate the model. Set up the probabilities that Plan9 * doesn't set. */ AllocPlan7Body(hmm, M); ZeroPlan7(hmm); Plan7LSConfig(hmm); /* The zero row has: 4 or 20 unused scores for nonexistent M0 state * then: B->M, tbd1, a B->I that Plan7 doesn't have; * three unused D-> transitions; then three I0 transitions that Plan7 doesn't have; * then two unused rf, cs annotations. */ if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; /* position index ignored */ for (x = 0; x < Alphabet_size; x++) if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; /* emissions ignored */ if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; hmm->begin[1] = ascii2prob(s, 1.0); if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; hmm->tbd1 = ascii2prob(s, 1.0); /* renormalize */ hmm->begin[1] = hmm->begin[1] / (hmm->begin[1] + hmm->tbd1); hmm->tbd1 = hmm->tbd1 / (hmm->begin[1] + hmm->tbd1); /* skip rest of line, seven integer fields, two char fields */ for (x = 0; x < 7; x++) if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; if ((s = Getword(fp, sqdARG_STRING)) == NULL) goto FAILURE; if ((s = Getword(fp, sqdARG_STRING)) == NULL) goto FAILURE; /* main model: table of emissions, transitions, annotation */ for (k = 1; k <= hmm->M; k++) { /* position index ignored */ if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; /* match emissions */ for (x = 0; x < Alphabet_size; x++) { if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; hmm->mat[k][x] = ascii2prob(s, hmm->null[x]); } /* nine transitions; two are ignored */ if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; if (k < hmm->M) hmm->t[k][TMM] = ascii2prob(s, 1.0); if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; if (k < hmm->M) hmm->t[k][TMD] = (k == hmm->M) ? 0.0 : ascii2prob(s, 1.0); if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; if (k < hmm->M) hmm->t[k][TMI] = ascii2prob(s, 1.0); if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; if (k < hmm->M) hmm->t[k][TDM] = ascii2prob(s, 1.0); if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; if (k < hmm->M) hmm->t[k][TDD] = (k == hmm->M) ? 0.0 : ascii2prob(s, 1.0); if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE;/* TDI ignored. */ /* no insert state at k == M, be careful */ if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; if (k < hmm->M) hmm->t[k][TIM] = ascii2prob(s, 1.0); if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; /* TID ignored. */ if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; if (k < hmm->M) hmm->t[k][TII] = ascii2prob(s, 1.0); /* annotations */ if ((s = Getword(fp, sqdARG_STRING)) == NULL) goto FAILURE; if (hmm->flags & PLAN7_RF) hmm->rf[k] = *s; if ((s = Getword(fp, sqdARG_STRING)) == NULL) goto FAILURE; if (hmm->flags & PLAN7_CS) hmm->cs[k] = *s; } /* table of insert emissions; * Plan7 has no insert state at 0 or M */ for (k = 0; k <= hmm->M; k++) { if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; /* position index ignored */ for (x = 0; x < Alphabet_size; x++) { if ((s = Getword(fp, sqdARG_INT)) == NULL) goto FAILURE; if (k > 0 && k < hmm->M) hmm->ins[k][x] = ascii2prob(s, hmm->null[x]); } } /* Set flags and return */ hmm->flags |= PLAN7_HASPROB; /* probabilities are valid */ hmm->flags &= ~PLAN7_HASBITS; /* scores are not valid */ Plan7Renormalize(hmm); hmm->comlog = Strdup("[converted from an old Plan9 HMM]"); Plan7SetCtime(hmm); *ret_hmm = hmm; return 1; FAILURE: if (hmm != NULL) FreePlan7(hmm); *ret_hmm = NULL; return 1; } static int read_bin19hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm) { unsigned int magic; struct plan7_s *hmm; /* plan7 HMM */ struct plan9_s *p9hmm; /* old style 1.x HMM */ /* Read the magic number; if we don't see it, then we * must be out of data in the file. */ if (feof(hmmfp->f)) return 0; if (! fread((char *) &magic, sizeof(unsigned int), 1, hmmfp->f)) return 0; p9hmm = read_plan9_binhmm(hmmfp->f, HMMER1_9B, hmmfp->byteswap); if (p9hmm == NULL) { *ret_hmm = NULL; return 1; } Plan9toPlan7(p9hmm, &hmm); hmm->comlog = Strdup("[converted from an old Plan9 HMM]"); Plan7SetCtime(hmm); P9FreeHMM(p9hmm); *ret_hmm = hmm; return 1; } static int read_asc17hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm) { struct plan7_s *hmm; /* plan7 HMM */ struct plan9_s *p9hmm; /* old style 1.x HMM */ char buffer[512]; /* Read the magic header; if we don't see it, then * we must be out of data in the file. */ if (feof(hmmfp->f) || fgets(buffer, 512, hmmfp->f) == NULL) return 0; p9hmm = read_plan9_aschmm(hmmfp->f, HMMER1_7F); if (p9hmm == NULL) { *ret_hmm = NULL; return 1; } Plan9toPlan7(p9hmm, &hmm); hmm->comlog = Strdup("[converted from an old Plan9 HMM]"); Plan7SetCtime(hmm); P9FreeHMM(p9hmm); *ret_hmm = hmm; return 1; } static int read_bin17hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm) { unsigned int magic; struct plan7_s *hmm; /* plan7 HMM */ struct plan9_s *p9hmm; /* old style 1.x HMM */ /* Read the magic number; if we don't see it, then we * must be out of data in the file. */ if (feof(hmmfp->f)) return 0; if (! fread((char *) &magic, sizeof(unsigned int), 1, hmmfp->f)) return 0; p9hmm = read_plan9_binhmm(hmmfp->f, HMMER1_7B, hmmfp->byteswap); if (p9hmm == NULL) { *ret_hmm = NULL; return 1; } Plan9toPlan7(p9hmm, &hmm); hmm->comlog = Strdup("[converted from an old Plan9 HMM]"); Plan7SetCtime(hmm); P9FreeHMM(p9hmm); *ret_hmm = hmm; return 1; } static int read_asc11hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm) { Die("1.1 ASCII HMMs unsupported"); return 1; } static int read_bin11hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm) { unsigned int magic; struct plan7_s *hmm; /* plan7 HMM */ struct plan9_s *p9hmm; /* old style 1.x HMM */ /* Read the magic number; if we don't see it, then we * must be out of data in the file. */ if (feof(hmmfp->f)) return 0; if (! fread((char *) &magic, sizeof(unsigned int), 1, hmmfp->f)) return 0; p9hmm = read_plan9_binhmm(hmmfp->f, HMMER1_1B, hmmfp->byteswap); if (p9hmm == NULL) { *ret_hmm = NULL; return 1; } Plan9toPlan7(p9hmm, &hmm); hmm->comlog = Strdup("[converted from an old Plan9 HMM]"); Plan7SetCtime(hmm); P9FreeHMM(p9hmm); *ret_hmm = hmm; return 1; } static int read_asc10hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm) { Die("1.0 ASCII HMMs unsupported"); return 1; } static int read_bin10hmm(HMMFILE *hmmfp, struct plan7_s **ret_hmm) { unsigned int magic; struct plan7_s *hmm; /* plan7 HMM */ struct plan9_s *p9hmm; /* old style 1.x HMM */ /* Read the magic number; if we don't see it, then we * must be out of data in the file. */ if (feof(hmmfp->f)) return 0; if (! fread((char *) &magic, sizeof(unsigned int), 1, hmmfp->f)) return 0; p9hmm = read_plan9_binhmm(hmmfp->f, HMMER1_0B, hmmfp->byteswap); if (p9hmm == NULL) { *ret_hmm = NULL; return 1; } Plan9toPlan7(p9hmm, &hmm); hmm->comlog = Strdup("[converted from an old Plan9 HMM]"); Plan7SetCtime(hmm); P9FreeHMM(p9hmm); *ret_hmm = hmm; return 1; } /***************************************************************** * Some miscellaneous utility functions *****************************************************************/ /* Function: prob2ascii() * * Purpose: Format a probability for output to an ASCII save * file. Returns a ptr to a static internal buffer. * */ static char * prob2ascii(float p, float null) { static char buffer[8]; if (p == 0.0) return "*"; sprintf(buffer, "%6d", Prob2Score(p, null)); return buffer; } /* Function: ascii2prob() * * Purpose: Convert a saved string back to a probability. */ static float ascii2prob(char *s, float null) { return (*s == '*') ? 0. : Score2Prob(atoi(s), null); } /* Function: byteswap() * * Purpose: Swap between big-endian and little-endian. * For example: * int foo = 0x12345678; * byteswap((char *) &foo, sizeof(int)); * printf("%x\n", foo) * gives 78563412. * * I don't fully understand byte-swapping issues. * However, I have tested this on chars through floats, * on various machines: * SGI IRIX 4.0.5, SunOS 4.1.3, DEC Alpha OSF/1, Alliant * * Note: this is only a partial solution to the problem of * binary file portability. 32 bit integers are assumed by HMMER, * for instance. This should be true for all UNIX, VAX, and WinNT * platforms, I believe. * * Date: Sun Feb 12 10:26:22 1995 */ static void byteswap(char *swap, int nbytes) { int x; char byte; for (x = 0; x < nbytes / 2; x++) { byte = swap[nbytes - x - 1]; swap[nbytes - x - 1] = swap[x]; swap[x] = byte; } } /* Function: write_bin_string() * Date: SRE, Wed Oct 29 13:49:27 1997 [TWA 721 over Canada] * * Purpose: Write a string in binary save format: an integer * for the string length (including \0), followed by * the string. */ static void write_bin_string(FILE *fp, char *s) { int len; if (s != NULL) { len = strlen(s) + 1; fwrite((char *) &len, sizeof(int), 1, fp); fwrite((char *) s, sizeof(char), len, fp); } else { len = 0; fwrite((char *) &len, sizeof(int), 1, fp); } } /* Function: read_bin_string() * Date: SRE, Wed Oct 29 14:03:23 1997 [TWA 721] * * Purpose: Read in a string from a binary file, where * the first integer is the length (including '\0'). * * Args: fp - FILE to read from * doswap - TRUE to byteswap * ret_s - string to read into * * Return: 0 on failure. ret_s is malloc'ed here. */ static int read_bin_string(FILE *fp, int doswap, char **ret_s) { char *s; int len; if (! fread((char *) &len, sizeof(int), 1, fp)) return 0; if (doswap) byteswap((char *)&len, sizeof(int)); s = MallocOrDie (sizeof(char) * (len)); if (! fread((char *) s, sizeof(char), len, fp)) { free(s); return 0; } *ret_s = s; return 1; } /* Function: multiline() * Date: Mon Jan 5 14:57:50 1998 [StL] * * Purpose: Given a record (like the comlog) that contains * multiple lines, print it as multiple lines with * a given prefix. e.g.: * * given: "COM ", "foo\nbar\nbaz" * print: COM foo * COM bar * COM baz * * * Used to print the command log to ASCII save files. * * Args: fp: FILE to print to * pfx: prefix for each line * s: line to break up and print; tolerates a NULL * * Return: (void) */ static void multiline(FILE *fp, char *pfx, char *s) { char *buf; char *sptr; if (s == NULL) return; buf = Strdup(s); sptr = strtok(buf, "\n"); while (sptr != NULL) { fprintf(fp, "%s%s\n", pfx, sptr); sptr = strtok(NULL, "\n"); } free(buf); } /***************************************************************** * HMMER 1.x save file reading functions, modified from the * corpse of 1.9m. *****************************************************************/ /* Function: read_plan9_binhmm() * * Read old (Plan9) binary HMM save files from HMMER 1.9 and earlier. * V1.0 saved regularizer and sympvec info, which V1.1 ignores. * V1.7 and later may include optional ref, cs annotation lines. * V1.9 added name, null model. * * Returns pointer to the HMM on success; NULL * on failure. Sets global alphabet information based on * whether it reads 4 or 20 as alphabet size (don't rely * on ancient HMMER macro definitions). */ static struct plan9_s * read_plan9_binhmm(FILE *fp, int version, int swapped) { struct plan9_s *hmm; int M; /* length of model */ int k; /* state number */ int x; /* symbol or transition number */ int len; /* length of variable length string */ int asize; /* alphabet size */ int atype; /* alphabet type (read but ignored) */ char abet[20]; /* alphabet (read but ignored) */ /* read M and alphabet size */ if (! fread((char *) &(M), sizeof(int), 1, fp)) return NULL; if (! fread((char *) &asize, sizeof(int), 1, fp)) return NULL; if (swapped) { byteswap((char *) &M, sizeof(int)); byteswap((char *) &asize, sizeof(int)); } /* Set global alphabet information */ if (Alphabet_type == hmmNOTSETYET) { if (asize == 4) SetAlphabet(hmmNUCLEIC); else if (asize == 20) SetAlphabet(hmmAMINO); else Die("A nonbiological alphabet size of %d; so I can't convert plan9 to plan7", asize); } else { if (asize != Alphabet_size) Die("Plan9 model's alphabet size (%d) doesn't match previous setting (%d)", asize, Alphabet_size); } /* now, create space for hmm */ if ((hmm = P9AllocHMM(M)) == NULL) Die("malloc failed for reading hmm in\n"); /* version 1.9+ files have a name */ if (version == HMMER1_9B) { if (! fread((char *) &len, sizeof(int), 1, fp)) return NULL; if (swapped) byteswap((char *) &len, sizeof(int)); hmm->name = (char *) ReallocOrDie (hmm->name, sizeof(char) * (len+1)); if (! fread((char *) hmm->name, sizeof(char), len, fp)) return NULL; hmm->name[len] = '\0'; } /* read alphabet_type and alphabet, but ignore: we've already set them */ if (! fread((char *) &atype, sizeof(int), 1, fp)) return NULL; if (! fread((char *) abet, sizeof(char), Alphabet_size, fp)) return NULL; /* skip the random symbol frequencies in V1.0 */ if (version == HMMER1_0B) fseek(fp, (long) (sizeof(float) * Alphabet_size), SEEK_CUR); /* Get optional info in V1.7 and later */ if (version == HMMER1_7B || version == HMMER1_9B) { if (! fread((char *) &(hmm->flags), sizeof(int), 1, fp)) return NULL; if (swapped) byteswap((char *) &hmm->flags, sizeof(int)); if ((hmm->flags & HMM_REF) && ! fread((char *) hmm->ref, sizeof(char), hmm->M+1, fp)) return NULL; hmm->ref[hmm->M+1] = '\0'; if ((hmm->flags & HMM_CS) && ! fread((char *) hmm->cs, sizeof(char), hmm->M+1, fp)) return NULL; hmm->cs[hmm->M+1] = '\0'; } /* Get the null model in V1.9 and later */ if (version == HMMER1_9B) { if (! fread((char *) hmm->null, sizeof(float), Alphabet_size, fp)) return NULL; if (swapped) for (x = 0; x < Alphabet_size; x++) byteswap((char *) &(hmm->null[x]), sizeof(float)); } else P9DefaultNullModel(hmm->null); /* everything else is states */ for (k = 0; k <= hmm->M; k++) { /* get match state info */ if (! fread((char *) &(hmm->mat[k].t[MATCH]), sizeof(float), 1, fp)) return NULL; if (! fread((char *) &(hmm->mat[k].t[DELETE]), sizeof(float), 1, fp)) return NULL; if (! fread((char *) &(hmm->mat[k].t[INSERT]), sizeof(float), 1, fp)) return NULL; if (! fread((char *) hmm->mat[k].p, sizeof(float), Alphabet_size, fp)) return NULL ; if (swapped) { byteswap((char *) &(hmm->mat[k].t[MATCH]), sizeof(float)); byteswap((char *) &(hmm->mat[k].t[DELETE]), sizeof(float)); byteswap((char *) &(hmm->mat[k].t[INSERT]), sizeof(float)); for (x = 0; x < Alphabet_size; x++) byteswap((char *) &(hmm->mat[k].p[x]), sizeof(float)); } /* skip the regularizer info in V1.0 */ if (version == HMMER1_0B) fseek(fp, (long)(sizeof(float) * (3 + Alphabet_size)), SEEK_CUR); /* get delete state info */ if (! fread((char *) &(hmm->del[k].t[MATCH]), sizeof(float), 1, fp)) return NULL; if (! fread((char *) &(hmm->del[k].t[DELETE]), sizeof(float), 1, fp)) return NULL; if (! fread((char *) &(hmm->del[k].t[INSERT]), sizeof(float), 1, fp)) return NULL; if (swapped) { byteswap((char *) &(hmm->del[k].t[MATCH]), sizeof(float)); byteswap((char *) &(hmm->del[k].t[DELETE]), sizeof(float)); byteswap((char *) &(hmm->del[k].t[INSERT]), sizeof(float)); } /* skip the regularizer info in V1.0 */ if (version == HMMER1_0B) fseek(fp, (long)(sizeof(float) * 3), SEEK_CUR); /* get insert state info */ if (! fread((char *) &(hmm->ins[k].t[MATCH]), sizeof(float), 1, fp)) return NULL; if (! fread((char *) &(hmm->ins[k].t[DELETE]), sizeof(float), 1, fp)) return NULL; if (! fread((char *) &(hmm->ins[k].t[INSERT]), sizeof(float), 1, fp)) return NULL; if (! fread((char *) hmm->ins[k].p, sizeof(float), Alphabet_size, fp)) return NULL ; if (swapped) { byteswap((char *) &(hmm->ins[k].t[MATCH]), sizeof(float)); byteswap((char *) &(hmm->ins[k].t[DELETE]), sizeof(float)); byteswap((char *) &(hmm->ins[k].t[INSERT]), sizeof(float)); for (x = 0; x < Alphabet_size; x++) byteswap((char *) &(hmm->ins[k].p[x]), sizeof(float)); } /* skip the regularizer info in V1.0 */ if (version == HMMER1_0B) fseek(fp, (long)(sizeof(float) * (3 + Alphabet_size)), SEEK_CUR); } P9Renormalize(hmm); return hmm; } /* Function: read_plan9_aschmm() * * Purpose: Read ASCII-format save files from 1.8.4 and earlier. * V1.0 contained sympvec and regularizers; these are ignored * in V1.1 and later * V1.7 and later contain ref and cs annotation. * * Args: fp - open save file, header has been read already * version - HMMER1_7F, for instance * * Returns ptr to the (allocated) new HMM on success, * or NULL on failure. */ static struct plan9_s * read_plan9_aschmm(FILE *fp, int version) { struct plan9_s *hmm; int M; /* length of model */ char buffer[512]; char *statetype; char *s; int k; /* state number */ int i; /* symbol number */ int asize; /* read M from first line */ if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; if (!isdigit(*s)) return NULL; M = atoi(s); /* read alphabet_length */ if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; if (!isdigit(*s)) return NULL; asize = atoi(s); /* Set global alphabet information */ if (Alphabet_type == hmmNOTSETYET) { if (asize == 4) SetAlphabet(hmmNUCLEIC); else if (asize == 20) SetAlphabet(hmmAMINO); else Die("A nonbiological alphabet size of %d; so I can't convert plan9 to plan7", asize); } else { if (asize != Alphabet_size) Die("Plan9 model's alphabet size (%d) doesn't match previous setting (%d)", asize, Alphabet_size); } /* now, create space for hmm */ if ((hmm = P9AllocHMM(M)) == NULL) Die("malloc failed for reading hmm in\n"); /* read alphabet_type but ignore */ if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; if (!isdigit(*s)) return NULL; /* read alphabet but ignore */ if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; /* skip the random symbol frequencies in V1.0 files. now unused */ if (version == HMMER1_0F) for (i = 0; i < Alphabet_size; i++) if (fgets(buffer, 512, fp) == NULL) return NULL; /* V1.7 has lines for whether we have valid ref, cs info */ if (version == HMMER1_7F) { if (fgets(buffer, 512, fp) == NULL) return NULL; if (strncmp(buffer, "yes", 3) == 0) hmm->flags |= HMM_REF; if (fgets(buffer, 512, fp) == NULL) return NULL; if (strncmp(buffer, "yes", 3) == 0) hmm->flags |= HMM_CS; } /* everything else is states */ while (fgets(buffer, 512, fp) != NULL) { /* get state type and index info */ if ((statetype = strtok(buffer, " \t\n")) == NULL) return NULL; if ((s = strtok((char *) NULL, " \t\n")) == NULL) return NULL; if (!isdigit(*s)) return NULL; k = atoi(s); if (k < 0 || k > hmm->M+1) return NULL; if (strcmp(statetype, "###MATCH_STATE") == 0) { /* V1.7: get ref, cs info: */ /* ###MATCH_STATE 16 (x) (H) */ if (version == HMMER1_7F) { s = strtok(NULL, "\n"); while (*s != '(' && *s != '\0') s++; if (*s != '(') return NULL; hmm->ref[k] = *(s+1); while (*s != '(' && *s != '\0') s++; if (*s != '(') return NULL; hmm->cs[k] = *(s+1); } if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; hmm->mat[k].t[MATCH] = (float) atof(s); if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; hmm->mat[k].t[DELETE] = (float) atof(s); if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; hmm->mat[k].t[INSERT] = (float) atof(s); for (i = 0; i < Alphabet_size; i++) { if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; hmm->mat[k].p[i] = (float) atof(s); } /* Skip all regularizer info for V1.0 */ if (version == HMMER1_0F) for (i = 0; i < Alphabet_size + 3; i++) if (fgets(buffer, 512, fp) == NULL) return NULL; } else if (strcmp(statetype, "###INSERT_STATE") == 0) { if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; hmm->ins[k].t[MATCH] = (float) atof(s); if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; hmm->ins[k].t[DELETE] = (float) atof(s); if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; hmm->ins[k].t[INSERT] = (float) atof(s); for (i = 0; i < Alphabet_size; i++) { if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; hmm->ins[k].p[i] = (float) atof(s); } /* Skip all regularizer info in V1.0 files */ if (version == HMMER1_0F) for (i = 0; i < Alphabet_size + 3; i++) if (fgets(buffer, 512, fp) == NULL) return NULL; } else if (strcmp(statetype, "###DELETE_STATE") == 0) { if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; hmm->del[k].t[MATCH] = (float) atof(s); if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; hmm->del[k].t[DELETE] = (float) atof(s); if (fgets(buffer, 512, fp) == NULL) return NULL; if ((s = strtok(buffer, " \t\n")) == NULL) return NULL; hmm->del[k].t[INSERT] = (float) atof(s); /* Skip all regularizer info in V1.0 files*/ if (version == HMMER1_0F) for (i = 0; i < 3; i++) if (fgets(buffer, 512, fp) == NULL) return NULL; } else return NULL; } P9DefaultNullModel(hmm->null); P9Renormalize(hmm); return hmm; } wise-2.4.1/src/HMMer2/sqfuncs.h0000644000175000001440000002165607313404527015544 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ #ifndef SQFUNCSH_INCLUDED #define SQFUNCSH_INCLUDED /* sqfuncs.h * * Prototypes for squid library functions; * also makes a good reference list for what the package contains. * * Warning: squid is a slowly evolving beast. Some functions are * obsolete. Some functions are probably just wrong, dating to * a primordial era before I knew anything about what I was doing. * Some functions are both obsolete and wrong but still necessary * to get legacy code to compile. */ /* * from aligneval.c */ extern float ComparePairAlignments(char *known1, char *known2, char *calc1, char *calc2); extern float CompareRefPairAlignments(int *ref, char *known1, char *known2, char *calc1, char *calc2); extern float CompareMultAlignments(char **kseqs, char **tseqs, int N); extern float CompareRefMultAlignments(int *ref, char **kseqs, char **tseqs, int N); extern float PairwiseIdentity(char *s1, char *s2); /* * from alignio.c */ extern void AllocAlignment(int nseq, int alen, char ***ret_aseq, AINFO *ainfo); extern void FreeAlignment(char **aseqs, AINFO *ainfo); extern void ReadAlignedFASTA(char *filename, char *env, char ***ret_aseq, AINFO *ainfo); extern void WriteAlignedFASTA(FILE *fp, char **aseqs, AINFO *ainfo); extern int MakeAlignedString(char *aseq, int alen, char *ss, char **ret_s); extern int MakeDealignedString(char *aseq, int alen, char *ss, char **ret_s); extern int DealignedLength(char *aseq); extern int WritePairwiseAlignment(FILE *ofp, char *aseq1, char *name1, int spos1, char *aseq2, char *name2, int spos2, int **pam, int indent); extern int MingapAlignment(char **aseqs, AINFO *ainfo); extern int RandomAlignment(char **rseqs, SQINFO *sqinfo, int nseq, float pop, float pex, char ***ret_aseqs, AINFO *ainfo); /* from cluster.c */ extern int Cluster(float **mx, int N, enum clust_strategy mode, struct phylo_s **ret_tree); extern struct phylo_s *AllocPhylo(int N); extern void FreePhylo(struct phylo_s *tree, int N); extern void MakeDiffMx(char **aseqs, int num, float ***ret_dmx); extern void MakeIdentityMx(char **aseqs, int num, float ***ret_imx); extern void PrintNewHampshireTree(FILE *fp, AINFO *ainfo, struct phylo_s *tree, int N); extern void PrintPhylo(FILE *fp, AINFO *ainfo, struct phylo_s *tree, int N); /* * from dayhoff.c */ extern int ParsePAMFile(FILE *fp, int ***ret_pam, float *ret_scale); extern void ScalePAM(int **pam, int scale); /* from file.c */ extern char *FileDirname(char *filename); extern char *FileTail(char *file, int noextension); extern char *FileConcat(char *dir, char *file); extern FILE *EnvFileOpen(char *fname, char *env); extern int FileExists(char *filename); /* from getopt.c */ extern int Getopt(int argc, char **argv, struct opt_s *opt, int nopts, char *usage, int *ret_optind, char **ret_optname, char **ret_optarg); /* from interleaved.c */ extern int IsInterleavedFormat(int format); extern int ReadInterleaved(char *seqfile, int (*skip_header)(FILE *), int (*parse_header)(FILE *, AINFO *), int (*is_dataline)(char *, char *), char ***ret_aseqs, AINFO *ainfo); extern int ReadAlignment(char *seqfile, int format, char ***ret_aseqs, AINFO *ainfo); /* * from msf.c */ extern void WriteMSF(FILE *fp, char **aseqs, AINFO *ainfo); /* from revcomp.c */ extern char *revcomp(char *comp, char *seq); /* * from selex.c */ extern int ReadSELEX(char *seqfile, char ***ret_aseqs, AINFO *ret_aliinfo); extern void WriteSELEX(FILE *fp, char **aseqs, AINFO *ainfo, int cpl); extern int DealignAseqs(char **aseqs, int num, char ***ret_rseqs); extern int IsSELEXFormat(char *filename); extern int TruncateNames(char **names, int N); /* OBSOLETE? */ /* * from seqencode.c */ extern int seqcmp(char *s1, char *s2, int allow); extern int seqncmp(char *s1, char *s2, int n, int allow); extern int seqencode(char *codeseq,char *str); extern int coded_revcomp(char *comp, char *seq); extern int seqdecode(char *str, char *codeseq); extern int seqndecode(char *str, char *codeseq, int n); /* * from sqerror.c */ extern void Die(char *format, ...); extern void Warn(char *format, ...); /* * from sqio.c */ extern void FreeSequence(char *seq, SQINFO *sqinfo); extern int SetSeqinfoString(SQINFO *sqinfo, char *sptr, int flag); extern void SeqinfoCopy(SQINFO *sq1, SQINFO *sq2); extern void ToDNA(char *seq); extern void ToRNA(char *seq); extern int ReadMultipleRseqs(char *seqfile, int fformat, char ***ret_rseqs, SQINFO **ret_sqinfo, int *ret_num); extern SQFILE *SeqfileOpen(char *filename, int format, char *env); extern void SeqfilePosition(SQFILE *sqfp, long offset); extern void SeqfileRewind(SQFILE *sqfp); extern void SeqfileClose(SQFILE *sqfp); extern int ReadSeq(SQFILE *fp, int format, char **ret_seq, SQINFO *sqinfo); extern int GCGBinaryToSequence(char *seq, int len); extern int GCGchecksum(char *seq, int seqlen); extern int GCGMultchecksum(char **seqs, int nseq); extern int SeqfileFormat(char *filename, int *ret_format, char *env); extern int WriteSeq(FILE *outf, int outfmt, char *seq, SQINFO *sqinfo); extern int Seqtype(char *seq); extern char *SeqFormatString(int code); extern GSIFILE *GSIOpen(char *gsifile); extern int GSIGetOffset(GSIFILE *gsi, char *key, char *sqfile, int *fmt, long *ret_offset); extern void GSIClose(GSIFILE *gsi); /* from sre_ctype.c */ extern int sre_tolower(int c); extern int sre_toupper(int c); /* from sre_math.c */ extern float Gaussrandom(float mean, float stddev); extern int Linefit(float *x, float *y, int N, float *ret_a, float *ret_b, float *ret_r); extern void WeightedLinefit(float *x, float *y, float *var, int N, float *ret_m, float *ret_b); extern float Gammln(float xx); extern int DNorm(double *vec, int n); extern int FNorm(float *vec, int n); extern void DScale(double *vec, int n, double scale); extern void FScale(float *vec, int n, float scale); extern void DSet(double *vec, int n, double value); extern void FSet(float *vec, int n, float value); extern double DSum(double *vec, int n); extern float FSum(float *vec, int n); extern void DAdd(double *vec1, double *vec2, int n); extern void FAdd(float *vec1, float *vec2, int n); extern void DCopy(double *vec1, double *vec2, int n); extern void FCopy(float *vec1, float *vec2, int n); extern int DMax(double *vec, int n); extern int FMax(float *vec, int n); extern double DDot(double *vec1, double *vec2, int n); extern float FDot(float *vec1, float *vec2, int n); extern float **FMX2Alloc(int rows, int cols); extern void FMX2Free(float **mx); extern double **DMX2Alloc(int rows, int cols); extern void DMX2Free(double **mx); extern void FMX2Multiply(float **A, float **B, float **C, int m, int p, int n); extern float sre_random(void); extern void sre_srandom(int seed); extern int DChoose(double *p, int n); extern int FChoose(float *p, int n); extern double DLogSum(double *logp, int n); extern float FLogSum(float *logp, int n); extern double IncompleteGamma(double a, double x); /* from sre_string.c */ #ifdef NOSTR extern char *strstr(char *s, char *subs); #endif extern char *Strdup(char *s); extern void StringChop(char *s); extern int Strinsert(char *s1, char c, int pos); extern int Strdelete(char *s1, int pos); extern void s2lower(char *s); extern void s2upper(char *s); extern void *MallocOrDie(size_t size); extern void *ReallocOrDie(void *p, size_t size); extern int Strparse(char *rexp, char *s, int ntok); extern void SqdClean(void); extern void StrShuffle(char *s1, char *s2); extern void StrReverse(char *s1, char *s2); extern void StrRegionalShuffle(char *s1, char *s2, int w); extern char *RandomSequence(char *alphabet, float *p, int n, int len); /* from stack.c */ extern struct intstack_s *InitIntStack(void); extern void PushIntStack(struct intstack_s *stack, int data); extern int PopIntStack(struct intstack_s *stack, int *ret_data); extern void ReverseIntStack(struct intstack_s *stack); extern int FreeIntStack( struct intstack_s *stack ); /* * from translate.c */ extern char *Translate(char *seq, char **code); /* * from types.c */ extern int IsInt(char *s); extern int IsReal(char *s); extern void Byteswap(char *swap, int nbytes); /* * from weight.c */ extern void GSCWeights(char **aseq, AINFO *ainfo); extern void VoronoiWeights(char **aseq, AINFO *ainfo); extern void BlosumWeights(char **aseq, AINFO *ainfo, float blosumlevel); extern void FilterAlignment(char **aseq, int nseq, AINFO *ainfo, float cutoff, char ***ret_anew, int *ret_nnew, AINFO **ret_newinfo); extern void SampleAlignment(char **aseq, int nseq, AINFO *ainfo, int sample, char ***ret_anew, int *ret_nnew, AINFO **ret_newinfo); #endif /* SQFUNCSH_INCLUDED */ wise-2.4.1/src/HMMer2/translate.c0000644000175000001440000000435607313404527016050 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* * translate.c - functions for translating nucleic acid sequence * created Tue Jan 12 11:27:29 1993, SRE * */ #include #include #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Function: Translate(char *seq, char **code) * * Given a ptr to the start of a nucleic acid sequence, * and a genetic code, translate the sequence into * amino acid sequence. * * code is an array of 65 strings, representing * the translations of the 64 codons, arranged * in order AAA, AAC, AAG, AAU, ..., UUA, UUC, UUG, UUU. * '*' or '***' is used to represent termination * codons, usually. The final string, code[64], * is the code for an ambiguous amino acid. * * Because of the way space is allocated for the amino * acid sequence, the amino acid strings cannot be * longer than 3 letters each. (I don't foresee using * anything but the single- and triple- letter codes.) * * Returns a ptr to the translation string on success, * or NULL on failure. */ char * Translate(char *seq, char **code) { int codon; /* index for codon */ char *aaseq; /* RETURN: the translation */ char *aaptr; /* ptr into aaseq */ int i; if (seq == NULL) { squid_errno = SQERR_NODATA; return NULL; } if ((aaseq = (char *) calloc (strlen(seq) + 1, sizeof(char))) == NULL) Die("calloc failed"); aaptr = aaseq; for (; *seq != '\0' && *(seq+1) != '\0' && *(seq+2) != '\0'; seq += 3) { /* calculate the lookup value for this codon */ codon = 0; for (i = 0; i < 3; i++) { codon *= 4; switch (*(seq + i)) { case 'A': case 'a': break; case 'C': case 'c': codon += 1; break; case 'G': case 'g': codon += 2; break; case 'T': case 't': codon += 3; break; case 'U': case 'u': codon += 3; break; default: codon = 64; break; } if (codon == 64) break; } strcpy(aaptr, code[codon]); aaptr += strlen(code[codon]); } return aaseq; } wise-2.4.1/src/HMMer2/globals.h0000644000175000001440000000153310670450317015473 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1997 Sean R. Eddy * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* globals.h * Mon Nov 18 13:05:03 1996 * * Global variable definitions. * This file may only be included in a main() .c file. */ char Alphabet[MAXCODE+1]; /* ACGT, for instance */ int Alphabet_type; /* hmmNUCLEIC or hmmAMINO */ int Alphabet_size; /* uniq alphabet size: 4 or 20 */ int Alphabet_iupac; /* total size of alphabet + IUPAC degen. */ char Degenerate[MAXCODE][MAXABET]; int DegenCount[MAXCODE]; wise-2.4.1/src/HMMer2/gnuregex.c0000644000175000001440000047277007313404525015706 0ustar philippusers#ifndef lint /* SRE: lint *hates* this code! */ /* This is the GNU regular expression library. * I've modified it for portability and clarity (!). * "SRE" comments flag the changes I've made. * Thanks to the GNU folks for providing this code! * SRE, Sun Jan 7 09:48:26 1996 */ /* Extended regular expression matching and search library, version 0.12. (Implements POSIX draft P10003.2/D11.2, except for internationalization features.) Copyright (C) 1993 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* AIX requires this to be the first thing in the file. */ #if defined (_AIX) && !defined (REGEX_MALLOC) #pragma alloca #endif #define _GNU_SOURCE /* We need this for `regex.h', and perhaps for the Emacs include files. */ #include #ifdef HAVE_CONFIG_H #include "config.h" #endif /* SRE: removed ifdef emacs; removed if HAVE_STRING_H; removed STDC_HEADERS */ #include #include #ifndef bcmp #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) #endif #ifndef bcopy #define bcopy(s, d, n) memcpy ((d), (s), (n)) #endif #ifndef bzero #define bzero(s, n) memset ((s), 0, (n)) #endif /* Define the syntax stuff for \<, \>, etc. */ /* This must be nonzero for the wordchar and notwordchar pattern commands in re_match_2. */ #ifndef Sword #define Sword 1 #endif #ifdef SYNTAX_TABLE extern char *re_syntax_table; #else /* not SYNTAX_TABLE */ /* How many characters in the character set. */ #define CHAR_SET_SIZE 256 static char re_syntax_table[CHAR_SET_SIZE]; static void init_syntax_once () { register int c; static int done = 0; if (done) return; bzero (re_syntax_table, sizeof re_syntax_table); for (c = 'a'; c <= 'z'; c++) re_syntax_table[c] = Sword; for (c = 'A'; c <= 'Z'; c++) re_syntax_table[c] = Sword; for (c = '0'; c <= '9'; c++) re_syntax_table[c] = Sword; re_syntax_table['_'] = Sword; done = 1; } #endif /* not SYNTAX_TABLE */ #define SYNTAX(c) re_syntax_table[c] /* Get the interface, including the syntax bits. */ #include "gnuregex.h" /* isalpha etc. are used for the character classes. */ #include #ifndef isascii #define isascii(c) 1 #endif #ifdef isblank #define ISBLANK(c) (isascii (c) && isblank (c)) #else #define ISBLANK(c) ((c) == ' ' || (c) == '\t') #endif #ifdef isgraph #define ISGRAPH(c) (isascii (c) && isgraph (c)) #else #define ISGRAPH(c) (isascii (c) && isprint (c) && !isspace (c)) #endif #define ISPRINT(c) (isascii (c) && isprint (c)) #define ISDIGIT(c) (isascii (c) && isdigit (c)) #define ISALNUM(c) (isascii (c) && isalnum (c)) #define ISALPHA(c) (isascii (c) && isalpha (c)) #define ISCNTRL(c) (isascii (c) && iscntrl (c)) #define ISLOWER(c) (isascii (c) && islower (c)) #define ISPUNCT(c) (isascii (c) && ispunct (c)) #define ISSPACE(c) (isascii (c) && isspace (c)) #define ISUPPER(c) (isascii (c) && isupper (c)) #define ISXDIGIT(c) (isascii (c) && isxdigit (c)) #ifndef NULL #define NULL 0 #endif /* We remove any previous definition of `SIGN_EXTEND_CHAR', since ours (we hope) works properly with all combinations of machines, compilers, `char' and `unsigned char' argument types. (Per Bothner suggested the basic approach.) */ #undef SIGN_EXTEND_CHAR #if __STDC__ #define SIGN_EXTEND_CHAR(c) ((signed char) (c)) #else /* not __STDC__ */ /* As in Harbison and Steele. */ #define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128) #endif /* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we use `alloca' instead of `malloc'. This is because using malloc in re_search* or re_match* could cause memory leaks when C-g is used in Emacs; also, malloc is slower and causes storage fragmentation. On the other hand, malloc is more portable, and easier to debug. Because we sometimes use alloca, some routines have to be macros, not functions -- `alloca'-allocated space disappears at the end of the function it is called in. */ #define REGEX_MALLOC /* SRE -- alloca not portable? */ #ifdef REGEX_MALLOC #define REGEX_ALLOCATE malloc #define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize) #else /* not REGEX_MALLOC */ /* Emacs already defines alloca, sometimes. */ #ifndef alloca /* Make alloca work the best possible way. */ #ifdef __GNUC__ #define alloca __builtin_alloca #else /* not __GNUC__ */ #if HAVE_ALLOCA_H #include #else /* not __GNUC__ or HAVE_ALLOCA_H */ #ifndef _AIX /* Already did AIX, up at the top. */ char *alloca (); #endif /* not _AIX */ #endif /* not HAVE_ALLOCA_H */ #endif /* not __GNUC__ */ #endif /* not alloca */ #define REGEX_ALLOCATE alloca /* Assumes a `char *destination' variable. */ #define REGEX_REALLOCATE(source, osize, nsize) \ (destination = (char *) alloca (nsize), \ bcopy (source, destination, osize), \ destination) #endif /* not REGEX_MALLOC */ /* True if `size1' is non-NULL and PTR is pointing anywhere inside `string1' or just past its end. This works if PTR is NULL, which is a good thing. */ #define FIRST_STRING_P(ptr) \ (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) /* (Re)Allocate N items of type T using malloc, or fail. */ #define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t))) #define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t))) #define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t))) #define BYTEWIDTH 8 /* In bits. */ #define STREQ(s1, s2) ((strcmp (s1, s2) == 0)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) typedef char boolean; #define false 0 #define true 1 /* These are the command codes that appear in compiled regular expressions. Some opcodes are followed by argument bytes. A command code can specify any interpretation whatsoever for its arguments. Zero bytes may appear in the compiled regular expression. The value of `exactn' is needed in search.c (search_buffer) in Emacs. So regex.h defines a symbol `RE_EXACTN_VALUE' to be 1; the value of `exactn' we use here must also be 1. */ typedef enum { no_op = 0, /* Followed by one byte giving n, then by n literal bytes. */ exactn = 1, /* Matches any (more or less) character. */ anychar, /* Matches any one char belonging to specified set. First following byte is number of bitmap bytes. Then come bytes for a bitmap saying which chars are in. Bits in each byte are ordered low-bit-first. A character is in the set if its bit is 1. A character too large to have a bit in the map is automatically not in the set. */ charset, /* Same parameters as charset, but match any character that is not one of those specified. */ charset_not, /* Start remembering the text that is matched, for storing in a register. Followed by one byte with the register number, in the range 0 to one less than the pattern buffer's re_nsub field. Then followed by one byte with the number of groups inner to this one. (This last has to be part of the start_memory only because we need it in the on_failure_jump of re_match_2.) */ start_memory, /* Stop remembering the text that is matched and store it in a memory register. Followed by one byte with the register number, in the range 0 to one less than `re_nsub' in the pattern buffer, and one byte with the number of inner groups, just like `start_memory'. (We need the number of inner groups here because we don't have any easy way of finding the corresponding start_memory when we're at a stop_memory.) */ stop_memory, /* Match a duplicate of something remembered. Followed by one byte containing the register number. */ duplicate, /* Fail unless at beginning of line. */ begline, /* Fail unless at end of line. */ endline, /* Succeeds if at beginning of buffer (if emacs) or at beginning of string to be matched (if not). */ begbuf, /* Analogously, for end of buffer/string. */ endbuf, /* Followed by two byte relative address to which to jump. */ jump, /* Same as jump, but marks the end of an alternative. */ jump_past_alt, /* Followed by two-byte relative address of place to resume at in case of failure. */ on_failure_jump, /* Like on_failure_jump, but pushes a placeholder instead of the current string position when executed. */ on_failure_keep_string_jump, /* Throw away latest failure point and then jump to following two-byte relative address. */ pop_failure_jump, /* Change to pop_failure_jump if know won't have to backtrack to match; otherwise change to jump. This is used to jump back to the beginning of a repeat. If what follows this jump clearly won't match what the repeat does, such that we can be sure that there is no use backtracking out of repetitions already matched, then we change it to a pop_failure_jump. Followed by two-byte address. */ maybe_pop_jump, /* Jump to following two-byte address, and push a dummy failure point. This failure point will be thrown away if an attempt is made to use it for a failure. A `+' construct makes this before the first repeat. Also used as an intermediary kind of jump when compiling an alternative. */ dummy_failure_jump, /* Push a dummy failure point and continue. Used at the end of alternatives. */ push_dummy_failure, /* Followed by two-byte relative address and two-byte number n. After matching N times, jump to the address upon failure. */ succeed_n, /* Followed by two-byte relative address, and two-byte number n. Jump to the address N times, then fail. */ jump_n, /* Set the following two-byte relative address to the subsequent two-byte number. The address *includes* the two bytes of number. */ set_number_at, wordchar, /* Matches any word-constituent character. */ notwordchar, /* Matches any char that is not a word-constituent. */ wordbeg, /* Succeeds if at word beginning. */ wordend, /* Succeeds if at word end. */ wordbound, /* Succeeds if at a word boundary. */ notwordbound /* Succeeds if not at a word boundary. */ #ifdef emacs ,before_dot, /* Succeeds if before point. */ at_dot, /* Succeeds if at point. */ after_dot, /* Succeeds if after point. */ /* Matches any character whose syntax is specified. Followed by a byte which contains a syntax code, e.g., Sword. */ syntaxspec, /* Matches any character whose syntax is not that specified. */ notsyntaxspec #endif /* emacs */ } re_opcode_t; /* Common operations on the compiled pattern. */ /* Store NUMBER in two contiguous bytes starting at DESTINATION. */ #define STORE_NUMBER(destination, number) \ do { \ (destination)[0] = (number) & 0377; \ (destination)[1] = (number) >> 8; \ } while (0) /* Same as STORE_NUMBER, except increment DESTINATION to the byte after where the number is stored. Therefore, DESTINATION must be an lvalue. */ #define STORE_NUMBER_AND_INCR(destination, number) \ do { \ STORE_NUMBER (destination, number); \ (destination) += 2; \ } while (0) /* Put into DESTINATION a number stored in two contiguous bytes starting at SOURCE. */ #define EXTRACT_NUMBER(destination, source) \ do { \ (destination) = *(source) & 0377; \ (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \ } while (0) #ifdef DEBUG static void extract_number (dest, source) int *dest; unsigned char *source; { int temp = SIGN_EXTEND_CHAR (*(source + 1)); *dest = *source & 0377; *dest += temp << 8; } #ifndef EXTRACT_MACROS /* To debug the macros. */ #undef EXTRACT_NUMBER #define EXTRACT_NUMBER(dest, src) extract_number (&dest, src) #endif /* not EXTRACT_MACROS */ #endif /* DEBUG */ /* Same as EXTRACT_NUMBER, except increment SOURCE to after the number. SOURCE must be an lvalue. */ #define EXTRACT_NUMBER_AND_INCR(destination, source) \ do { \ EXTRACT_NUMBER (destination, source); \ (source) += 2; \ } while (0) #ifdef DEBUG static void extract_number_and_incr (destination, source) int *destination; unsigned char **source; { extract_number (destination, *source); *source += 2; } #ifndef EXTRACT_MACROS #undef EXTRACT_NUMBER_AND_INCR #define EXTRACT_NUMBER_AND_INCR(dest, src) \ extract_number_and_incr (&dest, &src) #endif /* not EXTRACT_MACROS */ #endif /* DEBUG */ /* If DEBUG is defined, Regex prints many voluminous messages about what it is doing (if the variable `debug' is nonzero). If linked with the main program in `iregex.c', you can enter patterns and strings interactively. And if linked with the main program in `main.c' and the other test files, you can run the already-written tests. */ #ifdef DEBUG /* We use standard I/O for debugging. */ #include /* It is useful to test things that ``must'' be true when debugging. */ #include static int debug = 0; #define DEBUG_STATEMENT(e) e #define DEBUG_PRINT1(x) if (debug) printf (x) #define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2) #define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3) #define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4) #define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ if (debug) print_partial_compiled_pattern (s, e) #define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ if (debug) print_double_string (w, s1, sz1, s2, sz2) extern void printchar (); /* Print the fastmap in human-readable form. */ void print_fastmap (fastmap) char *fastmap; { unsigned was_a_range = 0; unsigned i = 0; while (i < (1 << BYTEWIDTH)) { if (fastmap[i++]) { was_a_range = 0; printchar (i - 1); while (i < (1 << BYTEWIDTH) && fastmap[i]) { was_a_range = 1; i++; } if (was_a_range) { printf ("-"); printchar (i - 1); } } } putchar ('\n'); } /* Print a compiled pattern string in human-readable form, starting at the START pointer into it and ending just before the pointer END. */ void print_partial_compiled_pattern (start, end) unsigned char *start; unsigned char *end; { int mcnt, mcnt2; unsigned char *p = start; unsigned char *pend = end; if (start == NULL) { printf ("(null)\n"); return; } /* Loop over pattern commands. */ while (p < pend) { switch ((re_opcode_t) *p++) { case no_op: printf ("/no_op"); break; case exactn: mcnt = *p++; printf ("/exactn/%d", mcnt); do { putchar ('/'); printchar (*p++); } while (--mcnt); break; case start_memory: mcnt = *p++; printf ("/start_memory/%d/%d", mcnt, *p++); break; case stop_memory: mcnt = *p++; printf ("/stop_memory/%d/%d", mcnt, *p++); break; case duplicate: printf ("/duplicate/%d", *p++); break; case anychar: printf ("/anychar"); break; case charset: case charset_not: { register int c; printf ("/charset%s", (re_opcode_t) *(p - 1) == charset_not ? "_not" : ""); assert (p + *p < pend); for (c = 0; c < *p; c++) { unsigned bit; unsigned char map_byte = p[1 + c]; putchar ('/'); for (bit = 0; bit < BYTEWIDTH; bit++) if (map_byte & (1 << bit)) printchar (c * BYTEWIDTH + bit); } p += 1 + *p; break; } case begline: printf ("/begline"); break; case endline: printf ("/endline"); break; case on_failure_jump: extract_number_and_incr (&mcnt, &p); printf ("/on_failure_jump/0/%d", mcnt); break; case on_failure_keep_string_jump: extract_number_and_incr (&mcnt, &p); printf ("/on_failure_keep_string_jump/0/%d", mcnt); break; case dummy_failure_jump: extract_number_and_incr (&mcnt, &p); printf ("/dummy_failure_jump/0/%d", mcnt); break; case push_dummy_failure: printf ("/push_dummy_failure"); break; case maybe_pop_jump: extract_number_and_incr (&mcnt, &p); printf ("/maybe_pop_jump/0/%d", mcnt); break; case pop_failure_jump: extract_number_and_incr (&mcnt, &p); printf ("/pop_failure_jump/0/%d", mcnt); break; case jump_past_alt: extract_number_and_incr (&mcnt, &p); printf ("/jump_past_alt/0/%d", mcnt); break; case jump: extract_number_and_incr (&mcnt, &p); printf ("/jump/0/%d", mcnt); break; case succeed_n: extract_number_and_incr (&mcnt, &p); extract_number_and_incr (&mcnt2, &p); printf ("/succeed_n/0/%d/0/%d", mcnt, mcnt2); break; case jump_n: extract_number_and_incr (&mcnt, &p); extract_number_and_incr (&mcnt2, &p); printf ("/jump_n/0/%d/0/%d", mcnt, mcnt2); break; case set_number_at: extract_number_and_incr (&mcnt, &p); extract_number_and_incr (&mcnt2, &p); printf ("/set_number_at/0/%d/0/%d", mcnt, mcnt2); break; case wordbound: printf ("/wordbound"); break; case notwordbound: printf ("/notwordbound"); break; case wordbeg: printf ("/wordbeg"); break; case wordend: printf ("/wordend"); #ifdef emacs case before_dot: printf ("/before_dot"); break; case at_dot: printf ("/at_dot"); break; case after_dot: printf ("/after_dot"); break; case syntaxspec: printf ("/syntaxspec"); mcnt = *p++; printf ("/%d", mcnt); break; case notsyntaxspec: printf ("/notsyntaxspec"); mcnt = *p++; printf ("/%d", mcnt); break; #endif /* emacs */ case wordchar: printf ("/wordchar"); break; case notwordchar: printf ("/notwordchar"); break; case begbuf: printf ("/begbuf"); break; case endbuf: printf ("/endbuf"); break; default: printf ("?%d", *(p-1)); } } printf ("/\n"); } void print_compiled_pattern (bufp) struct re_pattern_buffer *bufp; { unsigned char *buffer = bufp->buffer; print_partial_compiled_pattern (buffer, buffer + bufp->used); printf ("%d bytes used/%d bytes allocated.\n", bufp->used, bufp->allocated); if (bufp->fastmap_accurate && bufp->fastmap) { printf ("fastmap: "); print_fastmap (bufp->fastmap); } printf ("re_nsub: %d\t", bufp->re_nsub); printf ("regs_alloc: %d\t", bufp->regs_allocated); printf ("can_be_null: %d\t", bufp->can_be_null); printf ("newline_anchor: %d\n", bufp->newline_anchor); printf ("no_sub: %d\t", bufp->no_sub); printf ("not_bol: %d\t", bufp->not_bol); printf ("not_eol: %d\t", bufp->not_eol); printf ("syntax: %d\n", bufp->syntax); /* Perhaps we should print the translate table? */ } void print_double_string (where, string1, size1, string2, size2) char *where; char *string1; char *string2; int size1; int size2; { unsigned this_char; if (where == NULL) printf ("(null)"); else { if (FIRST_STRING_P (where)) { for (this_char = where - string1; this_char < size1; this_char++) printchar (string1[this_char]); where = string2; } for (this_char = where - string2; this_char < size2; this_char++) printchar (string2[this_char]); } } #else /* not DEBUG */ #undef assert #define assert(e) #define DEBUG_STATEMENT(e) #define DEBUG_PRINT1(x) #define DEBUG_PRINT2(x1, x2) #define DEBUG_PRINT3(x1, x2, x3) #define DEBUG_PRINT4(x1, x2, x3, x4) #define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) #define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) #endif /* not DEBUG */ /* Set by `re_set_syntax' to the current regexp syntax to recognize. Can also be assigned to arbitrarily: each pattern buffer stores its own syntax, so it can be changed between regex compilations. */ reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS; /* Specify the precise syntax of regexps for compilation. This provides for compatibility for various utilities which historically have different, incompatible syntaxes. The argument SYNTAX is a bit mask comprised of the various bits defined in regex.h. We return the old syntax. */ reg_syntax_t re_set_syntax (syntax) reg_syntax_t syntax; { reg_syntax_t ret = re_syntax_options; re_syntax_options = syntax; return ret; } /* This table gives an error message for each of the error codes listed in regex.h. Obviously the order here has to be same as there. */ static char *re_error_msg[] = { NULL, /* REG_NOERROR */ "No match", /* REG_NOMATCH */ "Invalid regular expression", /* REG_BADPAT */ "Invalid collation character", /* REG_ECOLLATE */ "Invalid character class name", /* REG_ECTYPE */ "Trailing backslash", /* REG_EESCAPE */ "Invalid back reference", /* REG_ESUBREG */ "Unmatched [ or [^", /* REG_EBRACK */ "Unmatched ( or \\(", /* REG_EPAREN */ "Unmatched \\{", /* REG_EBRACE */ "Invalid content of \\{\\}", /* REG_BADBR */ "Invalid range end", /* REG_ERANGE */ "Memory exhausted", /* REG_ESPACE */ "Invalid preceding regular expression", /* REG_BADRPT */ "Premature end of regular expression", /* REG_EEND */ "Regular expression too big", /* REG_ESIZE */ "Unmatched ) or \\)", /* REG_ERPAREN */ }; /* Subroutine declarations and macros for regex_compile. */ static void store_op1 (), store_op2 (); static void insert_op1 (), insert_op2 (); static boolean at_begline_loc_p (), at_endline_loc_p (); static boolean group_in_compile_stack (); static reg_errcode_t compile_range (); /* Fetch the next character in the uncompiled pattern---translating it if necessary. Also cast from a signed character in the constant string passed to us by the user to an unsigned char that we can use as an array index (in, e.g., `translate'). */ #define PATFETCH(c) \ do {if (p == pend) return REG_EEND; \ c = (unsigned char) *p++; \ if (translate) c = translate[c]; \ } while (0) /* Fetch the next character in the uncompiled pattern, with no translation. */ #define PATFETCH_RAW(c) \ do {if (p == pend) return REG_EEND; \ c = (unsigned char) *p++; \ } while (0) /* Go backwards one character in the pattern. */ #define PATUNFETCH p-- /* If `translate' is non-null, return translate[D], else just D. We cast the subscript to translate because some data is declared as `char *', to avoid warnings when a string constant is passed. But when we use a character as a subscript we must make it unsigned. */ #define TRANSLATE(d) (translate ? translate[(unsigned char) (d)] : (d)) /* Macros for outputting the compiled pattern into `buffer'. */ /* If the buffer isn't allocated when it comes in, use this. */ #define INIT_BUF_SIZE 32 /* Make sure we have at least N more bytes of space in buffer. */ #define GET_BUFFER_SPACE(n) \ while (b - bufp->buffer + (n) > bufp->allocated) \ EXTEND_BUFFER () /* Make sure we have one more byte of buffer space and then add C to it. */ #define BUF_PUSH(c) \ do { \ GET_BUFFER_SPACE (1); \ *b++ = (unsigned char) (c); \ } while (0) /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ #define BUF_PUSH_2(c1, c2) \ do { \ GET_BUFFER_SPACE (2); \ *b++ = (unsigned char) (c1); \ *b++ = (unsigned char) (c2); \ } while (0) /* As with BUF_PUSH_2, except for three bytes. */ #define BUF_PUSH_3(c1, c2, c3) \ do { \ GET_BUFFER_SPACE (3); \ *b++ = (unsigned char) (c1); \ *b++ = (unsigned char) (c2); \ *b++ = (unsigned char) (c3); \ } while (0) /* Store a jump with opcode OP at LOC to location TO. We store a relative address offset by the three bytes the jump itself occupies. */ #define STORE_JUMP(op, loc, to) \ store_op1 (op, loc, (to) - (loc) - 3) /* Likewise, for a two-argument jump. */ #define STORE_JUMP2(op, loc, to, arg) \ store_op2 (op, loc, (to) - (loc) - 3, arg) /* Like `STORE_JUMP', but for inserting. Assume `b' is the buffer end. */ #define INSERT_JUMP(op, loc, to) \ insert_op1 (op, loc, (to) - (loc) - 3, b) /* Like `STORE_JUMP2', but for inserting. Assume `b' is the buffer end. */ #define INSERT_JUMP2(op, loc, to, arg) \ insert_op2 (op, loc, (to) - (loc) - 3, arg, b) /* This is not an arbitrary limit: the arguments which represent offsets into the pattern are two bytes long. So if 2^16 bytes turns out to be too small, many things would have to change. */ #define MAX_BUF_SIZE (1L << 16) /* Extend the buffer by twice its current size via realloc and reset the pointers that pointed into the old block to point to the correct places in the new one. If extending the buffer results in it being larger than MAX_BUF_SIZE, then flag memory exhausted. */ #define EXTEND_BUFFER() \ do { \ unsigned char *old_buffer = bufp->buffer; \ if (bufp->allocated == MAX_BUF_SIZE) \ return REG_ESIZE; \ bufp->allocated <<= 1; \ if (bufp->allocated > MAX_BUF_SIZE) \ bufp->allocated = MAX_BUF_SIZE; \ bufp->buffer = (unsigned char *) realloc (bufp->buffer, bufp->allocated);\ if (bufp->buffer == NULL) \ return REG_ESPACE; \ /* If the buffer moved, move all the pointers into it. */ \ if (old_buffer != bufp->buffer) \ { \ b = (b - old_buffer) + bufp->buffer; \ begalt = (begalt - old_buffer) + bufp->buffer; \ if (fixup_alt_jump) \ fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\ if (laststart) \ laststart = (laststart - old_buffer) + bufp->buffer; \ if (pending_exact) \ pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ } \ } while (0) /* Since we have one byte reserved for the register number argument to {start,stop}_memory, the maximum number of groups we can report things about is what fits in that byte. */ #define MAX_REGNUM 255 /* But patterns can have more than `MAX_REGNUM' registers. We just ignore the excess. */ typedef unsigned regnum_t; /* Macros for the compile stack. */ /* Since offsets can go either forwards or backwards, this type needs to be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */ typedef int pattern_offset_t; typedef struct { pattern_offset_t begalt_offset; pattern_offset_t fixup_alt_jump; pattern_offset_t inner_group_offset; pattern_offset_t laststart_offset; regnum_t regnum; } compile_stack_elt_t; typedef struct { compile_stack_elt_t *stack; unsigned size; unsigned avail; /* Offset of next open position. */ } compile_stack_type; #define INIT_COMPILE_STACK_SIZE 32 #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) /* The next available element. */ #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) /* Set the bit for character C in a list. */ #define SET_LIST_BIT(c) \ (b[((unsigned char) (c)) / BYTEWIDTH] \ |= 1 << (((unsigned char) c) % BYTEWIDTH)) /* Get the next unsigned number in the uncompiled pattern. */ #define GET_UNSIGNED_NUMBER(num) \ { if (p != pend) \ { \ PATFETCH (c); \ while (ISDIGIT (c)) \ { \ if (num < 0) \ num = 0; \ num = num * 10 + c - '0'; \ if (p == pend) \ break; \ PATFETCH (c); \ } \ } \ } #define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */ #define IS_CHAR_CLASS(string) \ (STREQ (string, "alpha") || STREQ (string, "upper") \ || STREQ (string, "lower") || STREQ (string, "digit") \ || STREQ (string, "alnum") || STREQ (string, "xdigit") \ || STREQ (string, "space") || STREQ (string, "print") \ || STREQ (string, "punct") || STREQ (string, "graph") \ || STREQ (string, "cntrl") || STREQ (string, "blank")) /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. Returns one of error codes defined in `regex.h', or zero for success. Assumes the `allocated' (and perhaps `buffer') and `translate' fields are set in BUFP on entry. If it succeeds, results are put in BUFP (if it returns an error, the contents of BUFP are undefined): `buffer' is the compiled pattern; `syntax' is set to SYNTAX; `used' is set to the length of the compiled pattern; `fastmap_accurate' is zero; `re_nsub' is the number of subexpressions in PATTERN; `not_bol' and `not_eol' are zero; The `fastmap' and `newline_anchor' fields are neither examined nor set. */ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) char *pattern; int size; reg_syntax_t syntax; struct re_pattern_buffer *bufp; { /* We fetch characters from PATTERN here. Even though PATTERN is `char *' (i.e., signed), we declare these variables as unsigned, so they can be reliably used as array indices. */ register unsigned char c, c1; /* A random tempory spot in PATTERN. */ char *p1; /* Points to the end of the buffer, where we should append. */ register unsigned char *b; /* Keeps track of unclosed groups. */ compile_stack_type compile_stack; /* Points to the current (ending) position in the pattern. */ char *p = pattern; char *pend = pattern + size; /* How to translate the characters in the pattern. */ char *translate = bufp->translate; /* Address of the count-byte of the most recently inserted `exactn' command. This makes it possible to tell if a new exact-match character can be added to that command or if the character requires a new `exactn' command. */ unsigned char *pending_exact = 0; /* Address of start of the most recently finished expression. This tells, e.g., postfix * where to find the start of its operand. Reset at the beginning of groups and alternatives. */ unsigned char *laststart = 0; /* Address of beginning of regexp, or inside of last group. */ unsigned char *begalt; /* Place in the uncompiled pattern (i.e., the {) to which to go back if the interval is invalid. */ char *beg_interval; /* Address of the place where a forward jump should go to the end of the containing expression. Each alternative of an `or' -- except the last -- ends with a forward jump of this sort. */ unsigned char *fixup_alt_jump = 0; /* Counts open-groups as they are encountered. Remembered for the matching close-group on the compile stack, so the same register number is put in the stop_memory as the start_memory. */ regnum_t regnum = 0; #ifdef DEBUG DEBUG_PRINT1 ("\nCompiling pattern: "); if (debug) { unsigned debug_count; for (debug_count = 0; debug_count < size; debug_count++) printchar (pattern[debug_count]); putchar ('\n'); } #endif /* DEBUG */ /* Initialize the compile stack. */ compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); if (compile_stack.stack == NULL) return REG_ESPACE; compile_stack.size = INIT_COMPILE_STACK_SIZE; compile_stack.avail = 0; /* Initialize the pattern buffer. */ bufp->syntax = syntax; bufp->fastmap_accurate = 0; bufp->not_bol = bufp->not_eol = 0; /* Set `used' to zero, so that if we return an error, the pattern printer (for debugging) will think there's no pattern. We reset it at the end. */ bufp->used = 0; /* Always count groups, whether or not bufp->no_sub is set. */ bufp->re_nsub = 0; #if !defined (emacs) && !defined (SYNTAX_TABLE) /* Initialize the syntax table. */ init_syntax_once (); #endif if (bufp->allocated == 0) { if (bufp->buffer) { /* If zero allocated, but buffer is non-null, try to realloc enough space. This loses if buffer's address is bogus, but that is the user's responsibility. */ RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); } else { /* Caller did not allocate a buffer. Do it for them. */ bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); } if (!bufp->buffer) return REG_ESPACE; bufp->allocated = INIT_BUF_SIZE; } begalt = b = bufp->buffer; /* Loop through the uncompiled pattern until we're at the end. */ while (p != pend) { PATFETCH (c); switch (c) { case '^': { if ( /* If at start of pattern, it's an operator. */ p == pattern + 1 /* If context independent, it's an operator. */ || syntax & RE_CONTEXT_INDEP_ANCHORS /* Otherwise, depends on what's come before. */ || at_begline_loc_p (pattern, p, syntax)) BUF_PUSH (begline); else goto normal_char; } break; case '$': { if ( /* If at end of pattern, it's an operator. */ p == pend /* If context independent, it's an operator. */ || syntax & RE_CONTEXT_INDEP_ANCHORS /* Otherwise, depends on what's next. */ || at_endline_loc_p (p, pend, syntax)) BUF_PUSH (endline); else goto normal_char; } break; case '+': case '?': if ((syntax & RE_BK_PLUS_QM) || (syntax & RE_LIMITED_OPS)) goto normal_char; handle_plus: case '*': /* If there is no previous pattern... */ if (!laststart) { if (syntax & RE_CONTEXT_INVALID_OPS) return REG_BADRPT; else if (!(syntax & RE_CONTEXT_INDEP_OPS)) goto normal_char; } { /* Are we optimizing this jump? */ boolean keep_string_p = false; /* 1 means zero (many) matches is allowed. */ char zero_times_ok = 0, many_times_ok = 0; /* If there is a sequence of repetition chars, collapse it down to just one (the right one). We can't combine interval operators with these because of, e.g., `a{2}*', which should only match an even number of `a's. */ for (;;) { zero_times_ok |= c != '+'; many_times_ok |= c != '?'; if (p == pend) break; PATFETCH (c); if (c == '*' || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?'))) ; else if (syntax & RE_BK_PLUS_QM && c == '\\') { if (p == pend) return REG_EESCAPE; PATFETCH (c1); if (!(c1 == '+' || c1 == '?')) { PATUNFETCH; PATUNFETCH; break; } c = c1; } else { PATUNFETCH; break; } /* If we get here, we found another repeat character. */ } /* Star, etc. applied to an empty pattern is equivalent to an empty pattern. */ if (!laststart) break; /* Now we know whether or not zero matches is allowed and also whether or not two or more matches is allowed. */ if (many_times_ok) { /* More than one repetition is allowed, so put in at the end a backward relative jump from `b' to before the next jump we're going to put in below (which jumps from laststart to after this jump). But if we are at the `*' in the exact sequence `.*\n', insert an unconditional jump backwards to the ., instead of the beginning of the loop. This way we only push a failure point once, instead of every time through the loop. */ assert (p - 1 > pattern); /* Allocate the space for the jump. */ GET_BUFFER_SPACE (3); /* We know we are not at the first character of the pattern, because laststart was nonzero. And we've already incremented `p', by the way, to be the character after the `*'. Do we have to do something analogous here for null bytes, because of RE_DOT_NOT_NULL? */ if (TRANSLATE (*(p - 2)) == TRANSLATE ('.') && zero_times_ok && p < pend && TRANSLATE (*p) == TRANSLATE ('\n') && !(syntax & RE_DOT_NEWLINE)) { /* We have .*\n. */ STORE_JUMP (jump, b, laststart); keep_string_p = true; } else /* Anything else. */ STORE_JUMP (maybe_pop_jump, b, laststart - 3); /* We've added more stuff to the buffer. */ b += 3; } /* On failure, jump from laststart to b + 3, which will be the end of the buffer after this jump is inserted. */ GET_BUFFER_SPACE (3); INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump : on_failure_jump, laststart, b + 3); pending_exact = 0; b += 3; if (!zero_times_ok) { /* At least one repetition is required, so insert a `dummy_failure_jump' before the initial `on_failure_jump' instruction of the loop. This effects a skip over that instruction the first time we hit that loop. */ GET_BUFFER_SPACE (3); INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); b += 3; } } break; case '.': laststart = b; BUF_PUSH (anychar); break; case '[': { boolean had_char_class = false; if (p == pend) return REG_EBRACK; /* Ensure that we have enough space to push a charset: the opcode, the length count, and the bitset; 34 bytes in all. */ GET_BUFFER_SPACE (34); laststart = b; /* We test `*p == '^' twice, instead of using an if statement, so we only need one BUF_PUSH. */ BUF_PUSH (*p == '^' ? charset_not : charset); if (*p == '^') p++; /* Remember the first position in the bracket expression. */ p1 = p; /* Push the number of bytes in the bitmap. */ BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); /* Clear the whole map. */ bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); /* charset_not matches newline according to a syntax bit. */ if ((re_opcode_t) b[-2] == charset_not && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) SET_LIST_BIT ('\n'); /* Read in characters and ranges, setting map bits. */ for (;;) { if (p == pend) return REG_EBRACK; PATFETCH (c); /* \ might escape characters inside [...] and [^...]. */ if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') { if (p == pend) return REG_EESCAPE; PATFETCH (c1); SET_LIST_BIT (c1); continue; } /* Could be the end of the bracket expression. If it's not (i.e., when the bracket expression is `[]' so far), the ']' character bit gets set way below. */ if (c == ']' && p != p1 + 1) break; /* Look ahead to see if it's a range when the last thing was a character class. */ if (had_char_class && c == '-' && *p != ']') return REG_ERANGE; /* Look ahead to see if it's a range when the last thing was a character: if this is a hyphen not at the beginning or the end of a list, then it's the range operator. */ if (c == '-' && !(p - 2 >= pattern && p[-2] == '[') && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') && *p != ']') { reg_errcode_t ret = compile_range (&p, pend, translate, syntax, b); if (ret != REG_NOERROR) return ret; } else if (p[0] == '-' && p[1] != ']') { /* This handles ranges made up of characters only. */ reg_errcode_t ret; /* Move past the `-'. */ PATFETCH (c1); ret = compile_range (&p, pend, translate, syntax, b); if (ret != REG_NOERROR) return ret; } /* See if we're at the beginning of a possible character class. */ else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') { /* Leave room for the null. */ char str[CHAR_CLASS_MAX_LENGTH + 1]; PATFETCH (c); c1 = 0; /* If pattern is `[[:'. */ if (p == pend) return REG_EBRACK; for (;;) { PATFETCH (c); if (c == ':' || c == ']' || p == pend || c1 == CHAR_CLASS_MAX_LENGTH) break; str[c1++] = c; } str[c1] = '\0'; /* If isn't a word bracketed by `[:' and:`]': undo the ending character, the letters, and leave the leading `:' and `[' (but set bits for them). */ if (c == ':' && *p == ']') { int ch; boolean is_alnum = STREQ (str, "alnum"); boolean is_alpha = STREQ (str, "alpha"); boolean is_blank = STREQ (str, "blank"); boolean is_cntrl = STREQ (str, "cntrl"); boolean is_digit = STREQ (str, "digit"); boolean is_graph = STREQ (str, "graph"); boolean is_lower = STREQ (str, "lower"); boolean is_print = STREQ (str, "print"); boolean is_punct = STREQ (str, "punct"); boolean is_space = STREQ (str, "space"); boolean is_upper = STREQ (str, "upper"); boolean is_xdigit = STREQ (str, "xdigit"); if (!IS_CHAR_CLASS (str)) return REG_ECTYPE; /* Throw away the ] at the end of the character class. */ PATFETCH (c); if (p == pend) return REG_EBRACK; for (ch = 0; ch < 1 << BYTEWIDTH; ch++) { if ( (is_alnum && ISALNUM (ch)) || (is_alpha && ISALPHA (ch)) || (is_blank && ISBLANK (ch)) || (is_cntrl && ISCNTRL (ch)) || (is_digit && ISDIGIT (ch)) || (is_graph && ISGRAPH (ch)) || (is_lower && ISLOWER (ch)) || (is_print && ISPRINT (ch)) || (is_punct && ISPUNCT (ch)) || (is_space && ISSPACE (ch)) || (is_upper && ISUPPER (ch)) || (is_xdigit && ISXDIGIT (ch))) SET_LIST_BIT (ch); } had_char_class = true; } else { c1++; while (c1--) PATUNFETCH; SET_LIST_BIT ('['); SET_LIST_BIT (':'); had_char_class = false; } } else { had_char_class = false; SET_LIST_BIT (c); } } /* Discard any (non)matching list bytes that are all 0 at the end of the map. Decrease the map-length byte too. */ while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) b[-1]--; b += b[-1]; } break; case '(': if (syntax & RE_NO_BK_PARENS) goto handle_open; else goto normal_char; case ')': if (syntax & RE_NO_BK_PARENS) goto handle_close; else goto normal_char; case '\n': if (syntax & RE_NEWLINE_ALT) goto handle_alt; else goto normal_char; case '|': if (syntax & RE_NO_BK_VBAR) goto handle_alt; else goto normal_char; case '{': if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) goto handle_interval; else goto normal_char; case '\\': if (p == pend) return REG_EESCAPE; /* Do not translate the character after the \, so that we can distinguish, e.g., \B from \b, even if we normally would translate, e.g., B to b. */ PATFETCH_RAW (c); switch (c) { case '(': if (syntax & RE_NO_BK_PARENS) goto normal_backslash; handle_open: bufp->re_nsub++; regnum++; if (COMPILE_STACK_FULL) { RETALLOC (compile_stack.stack, compile_stack.size << 1, compile_stack_elt_t); if (compile_stack.stack == NULL) return REG_ESPACE; compile_stack.size <<= 1; } /* These are the values to restore when we hit end of this group. They are all relative offsets, so that if the whole pattern moves because of realloc, they will still be valid. */ COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; COMPILE_STACK_TOP.fixup_alt_jump = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer; COMPILE_STACK_TOP.regnum = regnum; /* We will eventually replace the 0 with the number of groups inner to this one. But do not push a start_memory for groups beyond the last one we can represent in the compiled pattern. */ if (regnum <= MAX_REGNUM) { COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2; BUF_PUSH_3 (start_memory, regnum, 0); } compile_stack.avail++; fixup_alt_jump = 0; laststart = 0; begalt = b; /* If we've reached MAX_REGNUM groups, then this open won't actually generate any code, so we'll have to clear pending_exact explicitly. */ pending_exact = 0; break; case ')': if (syntax & RE_NO_BK_PARENS) goto normal_backslash; if (COMPILE_STACK_EMPTY) if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_backslash; else return REG_ERPAREN; handle_close: if (fixup_alt_jump) { /* Push a dummy failure point at the end of the alternative for a possible future `pop_failure_jump' to pop. See comments at `push_dummy_failure' in `re_match_2'. */ BUF_PUSH (push_dummy_failure); /* We allocated space for this jump when we assigned to `fixup_alt_jump', in the `handle_alt' case below. */ STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1); } /* See similar code for backslashed left paren above. */ if (COMPILE_STACK_EMPTY) if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_char; else return REG_ERPAREN; /* Since we just checked for an empty stack above, this ``can't happen''. */ assert (compile_stack.avail != 0); { /* We don't just want to restore into `regnum', because later groups should continue to be numbered higher, as in `(ab)c(de)' -- the second group is #2. */ regnum_t this_group_regnum; compile_stack.avail--; begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; fixup_alt_jump = COMPILE_STACK_TOP.fixup_alt_jump ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 : 0; laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; this_group_regnum = COMPILE_STACK_TOP.regnum; /* If we've reached MAX_REGNUM groups, then this open won't actually generate any code, so we'll have to clear pending_exact explicitly. */ pending_exact = 0; /* We're at the end of the group, so now we know how many groups were inside this one. */ if (this_group_regnum <= MAX_REGNUM) { unsigned char *inner_group_loc = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; *inner_group_loc = regnum - this_group_regnum; BUF_PUSH_3 (stop_memory, this_group_regnum, regnum - this_group_regnum); } } break; case '|': /* `\|'. */ if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) goto normal_backslash; handle_alt: if (syntax & RE_LIMITED_OPS) goto normal_char; /* Insert before the previous alternative a jump which jumps to this alternative if the former fails. */ GET_BUFFER_SPACE (3); INSERT_JUMP (on_failure_jump, begalt, b + 6); pending_exact = 0; b += 3; /* The alternative before this one has a jump after it which gets executed if it gets matched. Adjust that jump so it will jump to this alternative's analogous jump (put in below, which in turn will jump to the next (if any) alternative's such jump, etc.). The last such jump jumps to the correct final destination. A picture: _____ _____ | | | | | v | v a | b | c If we are at `b', then fixup_alt_jump right now points to a three-byte space after `a'. We'll put in the jump, set fixup_alt_jump to right after `b', and leave behind three bytes which we'll fill in when we get to after `c'. */ if (fixup_alt_jump) STORE_JUMP (jump_past_alt, fixup_alt_jump, b); /* Mark and leave space for a jump after this alternative, to be filled in later either by next alternative or when know we're at the end of a series of alternatives. */ fixup_alt_jump = b; GET_BUFFER_SPACE (3); b += 3; laststart = 0; begalt = b; break; case '{': /* If \{ is a literal. */ if (!(syntax & RE_INTERVALS) /* If we're at `\{' and it's not the open-interval operator. */ || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) || (p - 2 == pattern && p == pend)) goto normal_backslash; handle_interval: { /* If got here, then the syntax allows intervals. */ /* At least (most) this many matches must be made. */ int lower_bound = -1, upper_bound = -1; beg_interval = p - 1; if (p == pend) { if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else return REG_EBRACE; } GET_UNSIGNED_NUMBER (lower_bound); if (c == ',') { GET_UNSIGNED_NUMBER (upper_bound); if (upper_bound < 0) upper_bound = RE_DUP_MAX; } else /* Interval such as `{1}' => match exactly once. */ upper_bound = lower_bound; if (lower_bound < 0 || upper_bound > RE_DUP_MAX || lower_bound > upper_bound) { if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else return REG_BADBR; } if (!(syntax & RE_NO_BK_BRACES)) { if (c != '\\') return REG_EBRACE; PATFETCH (c); } if (c != '}') { if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else return REG_BADBR; } /* We just parsed a valid interval. */ /* If it's invalid to have no preceding re. */ if (!laststart) { if (syntax & RE_CONTEXT_INVALID_OPS) return REG_BADRPT; else if (syntax & RE_CONTEXT_INDEP_OPS) laststart = b; else goto unfetch_interval; } /* If the upper bound is zero, don't want to succeed at all; jump from `laststart' to `b + 3', which will be the end of the buffer after we insert the jump. */ if (upper_bound == 0) { GET_BUFFER_SPACE (3); INSERT_JUMP (jump, laststart, b + 3); b += 3; } /* Otherwise, we have a nontrivial interval. When we're all done, the pattern will look like: set_number_at set_number_at succeed_n jump_n (The upper bound and `jump_n' are omitted if `upper_bound' is 1, though.) */ else { /* If the upper bound is > 1, we need to insert more at the end of the loop. */ unsigned nbytes = 10 + (upper_bound > 1) * 10; GET_BUFFER_SPACE (nbytes); /* Initialize lower bound of the `succeed_n', even though it will be set during matching by its attendant `set_number_at' (inserted next), because `re_compile_fastmap' needs to know. Jump to the `jump_n' we might insert below. */ INSERT_JUMP2 (succeed_n, laststart, b + 5 + (upper_bound > 1) * 5, lower_bound); b += 5; /* Code to initialize the lower bound. Insert before the `succeed_n'. The `5' is the last two bytes of this `set_number_at', plus 3 bytes of the following `succeed_n'. */ insert_op2 (set_number_at, laststart, 5, lower_bound, b); b += 5; if (upper_bound > 1) { /* More than one repetition is allowed, so append a backward jump to the `succeed_n' that starts this interval. When we've reached this during matching, we'll have matched the interval once, so jump back only `upper_bound - 1' times. */ STORE_JUMP2 (jump_n, b, laststart + 5, upper_bound - 1); b += 5; /* The location we want to set is the second parameter of the `jump_n'; that is `b-2' as an absolute address. `laststart' will be the `set_number_at' we're about to insert; `laststart+3' the number to set, the source for the relative address. But we are inserting into the middle of the pattern -- so everything is getting moved up by 5. Conclusion: (b - 2) - (laststart + 3) + 5, i.e., b - laststart. We insert this at the beginning of the loop so that if we fail during matching, we'll reinitialize the bounds. */ insert_op2 (set_number_at, laststart, b - laststart, upper_bound - 1, b); b += 5; } } pending_exact = 0; beg_interval = NULL; } break; unfetch_interval: /* If an invalid interval, match the characters as literals. */ assert (beg_interval); p = beg_interval; beg_interval = NULL; /* normal_char and normal_backslash need `c'. */ PATFETCH (c); if (!(syntax & RE_NO_BK_BRACES)) { if (p > pattern && p[-1] == '\\') goto normal_backslash; } goto normal_char; #ifdef emacs /* There is no way to specify the before_dot and after_dot operators. rms says this is ok. --karl */ case '=': BUF_PUSH (at_dot); break; case 's': laststart = b; PATFETCH (c); BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); break; case 'S': laststart = b; PATFETCH (c); BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); break; #endif /* emacs */ case 'w': laststart = b; BUF_PUSH (wordchar); break; case 'W': laststart = b; BUF_PUSH (notwordchar); break; case '<': BUF_PUSH (wordbeg); break; case '>': BUF_PUSH (wordend); break; case 'b': BUF_PUSH (wordbound); break; case 'B': BUF_PUSH (notwordbound); break; case '`': BUF_PUSH (begbuf); break; case '\'': BUF_PUSH (endbuf); break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (syntax & RE_NO_BK_REFS) goto normal_char; c1 = c - '0'; if (c1 > regnum) return REG_ESUBREG; /* Can't back reference to a subexpression if inside of it. */ if (group_in_compile_stack (compile_stack, c1)) goto normal_char; laststart = b; BUF_PUSH_2 (duplicate, c1); break; case '+': case '?': if (syntax & RE_BK_PLUS_QM) goto handle_plus; else goto normal_backslash; default: normal_backslash: /* You might think it would be useful for \ to mean not to translate; but if we don't translate it it will never match anything. */ c = TRANSLATE (c); goto normal_char; } break; default: /* Expects the character in `c'. */ normal_char: /* If no exactn currently being built. */ if (!pending_exact /* If last exactn not at current position. */ || pending_exact + *pending_exact + 1 != b /* We have only one byte following the exactn for the count. */ || *pending_exact == (1 << BYTEWIDTH) - 1 /* If followed by a repetition operator. */ || *p == '*' || *p == '^' || ((syntax & RE_BK_PLUS_QM) ? *p == '\\' && (p[1] == '+' || p[1] == '?') : (*p == '+' || *p == '?')) || ((syntax & RE_INTERVALS) && ((syntax & RE_NO_BK_BRACES) ? *p == '{' : (p[0] == '\\' && p[1] == '{')))) { /* Start building a new exactn. */ laststart = b; BUF_PUSH_2 (exactn, 0); pending_exact = b - 1; } BUF_PUSH (c); (*pending_exact)++; break; } /* switch (c) */ } /* while p != pend */ /* Through the pattern now. */ if (fixup_alt_jump) STORE_JUMP (jump_past_alt, fixup_alt_jump, b); if (!COMPILE_STACK_EMPTY) return REG_EPAREN; free (compile_stack.stack); /* We have succeeded; set the length of the buffer. */ bufp->used = b - bufp->buffer; #ifdef DEBUG if (debug) { DEBUG_PRINT1 ("\nCompiled pattern: "); print_compiled_pattern (bufp); } #endif /* DEBUG */ return REG_NOERROR; } /* regex_compile */ /* Subroutines for `regex_compile'. */ /* Store OP at LOC followed by two-byte integer parameter ARG. */ static void store_op1 (op, loc, arg) re_opcode_t op; unsigned char *loc; int arg; { *loc = (unsigned char) op; STORE_NUMBER (loc + 1, arg); } /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ static void store_op2 (op, loc, arg1, arg2) re_opcode_t op; unsigned char *loc; int arg1, arg2; { *loc = (unsigned char) op; STORE_NUMBER (loc + 1, arg1); STORE_NUMBER (loc + 3, arg2); } /* Copy the bytes from LOC to END to open up three bytes of space at LOC for OP followed by two-byte integer parameter ARG. */ static void insert_op1 (op, loc, arg, end) re_opcode_t op; unsigned char *loc; int arg; unsigned char *end; { register unsigned char *pfrom = end; register unsigned char *pto = end + 3; while (pfrom != loc) *--pto = *--pfrom; store_op1 (op, loc, arg); } /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ static void insert_op2 (op, loc, arg1, arg2, end) re_opcode_t op; unsigned char *loc; int arg1, arg2; unsigned char *end; { register unsigned char *pfrom = end; register unsigned char *pto = end + 5; while (pfrom != loc) *--pto = *--pfrom; store_op2 (op, loc, arg1, arg2); } /* P points to just after a ^ in PATTERN. Return true if that ^ comes after an alternative or a begin-subexpression. We assume there is at least one character before the ^. */ static boolean at_begline_loc_p (pattern, p, syntax) char *pattern, *p; reg_syntax_t syntax; { char *prev = p - 2; boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\'; return /* After a subexpression? */ (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) /* After an alternative? */ || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); } /* The dual of at_begline_loc_p. This one is for $. We assume there is at least one character after the $, i.e., `P < PEND'. */ static boolean at_endline_loc_p (p, pend, syntax) char *p, *pend; int syntax; { char *next = p; boolean next_backslash = *next == '\\'; char *next_next = p + 1 < pend ? p + 1 : NULL; return /* Before a subexpression? */ (syntax & RE_NO_BK_PARENS ? *next == ')' : next_backslash && next_next && *next_next == ')') /* Before an alternative? */ || (syntax & RE_NO_BK_VBAR ? *next == '|' : next_backslash && next_next && *next_next == '|'); } /* Returns true if REGNUM is in one of COMPILE_STACK's elements and false if it's not. */ static boolean group_in_compile_stack (compile_stack, regnum) compile_stack_type compile_stack; regnum_t regnum; { int this_element; for (this_element = compile_stack.avail - 1; this_element >= 0; this_element--) if (compile_stack.stack[this_element].regnum == regnum) return true; return false; } /* Read the ending character of a range (in a bracket expression) from the uncompiled pattern *P_PTR (which ends at PEND). We assume the starting character is in `P[-2]'. (`P[-1]' is the character `-'.) Then we set the translation of all bits between the starting and ending characters (inclusive) in the compiled pattern B. Return an error code. We use these short variable names so we can use the same macros as `regex_compile' itself. */ static reg_errcode_t compile_range (p_ptr, pend, translate, syntax, b) char **p_ptr, *pend; char *translate; reg_syntax_t syntax; unsigned char *b; { unsigned this_char; char *p = *p_ptr; int range_start, range_end; if (p == pend) return REG_ERANGE; /* Even though the pattern is a signed `char *', we need to fetch with unsigned char *'s; if the high bit of the pattern character is set, the range endpoints will be negative if we fetch using a signed char *. We also want to fetch the endpoints without translating them; the appropriate translation is done in the bit-setting loop below. */ range_start = ((unsigned char *) p)[-2]; range_end = ((unsigned char *) p)[0]; /* Have to increment the pointer into the pattern string, so the caller isn't still at the ending character. */ (*p_ptr)++; /* If the start is after the end, the range is empty. */ if (range_start > range_end) return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; /* Here we see why `this_char' has to be larger than an `unsigned char' -- the range is inclusive, so if `range_end' == 0xff (assuming 8-bit characters), we would otherwise go into an infinite loop, since all characters <= 0xff. */ for (this_char = range_start; this_char <= range_end; this_char++) { SET_LIST_BIT (TRANSLATE (this_char)); } return REG_NOERROR; } /* Failure stack declarations and macros; both re_compile_fastmap and re_match_2 use a failure stack. These have to be macros because of REGEX_ALLOCATE. */ /* Number of failure points for which to initially allocate space when matching. If this number is exceeded, we allocate more space, so it is not a hard limit. */ #ifndef INIT_FAILURE_ALLOC #define INIT_FAILURE_ALLOC 5 #endif /* Roughly the maximum number of failure points on the stack. Would be exactly that if always used MAX_FAILURE_SPACE each time we failed. This is a variable only so users of regex can assign to it; we never change it ourselves. */ int re_max_failures = 2000; typedef unsigned char *fail_stack_elt_t; typedef struct { fail_stack_elt_t *stack; unsigned size; unsigned avail; /* Offset of next open position. */ } fail_stack_type; #define FAIL_STACK_EMPTY() (fail_stack.avail == 0) #define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0) #define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size) #define FAIL_STACK_TOP() (fail_stack.stack[fail_stack.avail]) /* Initialize `fail_stack'. Do `return -2' if the alloc fails. */ #define INIT_FAIL_STACK() \ do { \ fail_stack.stack = (fail_stack_elt_t *) \ REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \ \ if (fail_stack.stack == NULL) \ return -2; \ \ fail_stack.size = INIT_FAILURE_ALLOC; \ fail_stack.avail = 0; \ } while (0) /* Double the size of FAIL_STACK, up to approximately `re_max_failures' items. Return 1 if succeeds, and 0 if either ran out of memory allocating space for it or it was already too large. REGEX_REALLOCATE requires `destination' be declared. */ #define DOUBLE_FAIL_STACK(fail_stack) \ ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS \ ? 0 \ : ((fail_stack).stack = (fail_stack_elt_t *) \ REGEX_REALLOCATE ((fail_stack).stack, \ (fail_stack).size * sizeof (fail_stack_elt_t), \ ((fail_stack).size << 1) * sizeof (fail_stack_elt_t)), \ \ (fail_stack).stack == NULL \ ? 0 \ : ((fail_stack).size <<= 1, \ 1))) /* Push PATTERN_OP on FAIL_STACK. Return 1 if was able to do so and 0 if ran out of memory allocating space to do so. */ #define PUSH_PATTERN_OP(pattern_op, fail_stack) \ ((FAIL_STACK_FULL () \ && !DOUBLE_FAIL_STACK (fail_stack)) \ ? 0 \ : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \ 1)) /* This pushes an item onto the failure stack. Must be a four-byte value. Assumes the variable `fail_stack'. Probably should only be called from within `PUSH_FAILURE_POINT'. */ #define PUSH_FAILURE_ITEM(item) \ fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item /* The complement operation. Assumes `fail_stack' is nonempty. */ #define POP_FAILURE_ITEM() fail_stack.stack[--fail_stack.avail] /* Used to omit pushing failure point id's when we're not debugging. */ #ifdef DEBUG #define DEBUG_PUSH PUSH_FAILURE_ITEM #define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_ITEM () #else #define DEBUG_PUSH(item) #define DEBUG_POP(item_addr) #endif /* Push the information about the state we will need if we ever fail back to it. Requires variables fail_stack, regstart, regend, reg_info, and num_regs be declared. DOUBLE_FAIL_STACK requires `destination' be declared. Does `return FAILURE_CODE' if runs out of memory. */ #define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \ do { \ char *destination; \ /* Must be int, so when we don't save any registers, the arithmetic \ of 0 + -1 isn't done as unsigned. */ \ int this_reg; \ \ DEBUG_STATEMENT (failure_id++); \ DEBUG_STATEMENT (nfailure_points_pushed++); \ DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \ DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail);\ DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\ \ DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \ DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \ \ /* Ensure we have enough space allocated for what we will push. */ \ while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \ { \ if (!DOUBLE_FAIL_STACK (fail_stack)) \ return failure_code; \ \ DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \ (fail_stack).size); \ DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\ } \ \ /* Push the info, starting with the registers. */ \ DEBUG_PRINT1 ("\n"); \ \ for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \ this_reg++) \ { \ DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \ DEBUG_STATEMENT (num_regs_pushed++); \ \ DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ PUSH_FAILURE_ITEM (regstart[this_reg]); \ \ DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ PUSH_FAILURE_ITEM (regend[this_reg]); \ \ DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \ DEBUG_PRINT2 (" match_null=%d", \ REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ DEBUG_PRINT2 (" matched_something=%d", \ MATCHED_SOMETHING (reg_info[this_reg])); \ DEBUG_PRINT2 (" ever_matched=%d", \ EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ DEBUG_PRINT1 ("\n"); \ PUSH_FAILURE_ITEM (reg_info[this_reg].word); \ } \ \ DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\ PUSH_FAILURE_ITEM (lowest_active_reg); \ \ DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\ PUSH_FAILURE_ITEM (highest_active_reg); \ \ DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \ DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ PUSH_FAILURE_ITEM (pattern_place); \ \ DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \ DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \ size2); \ DEBUG_PRINT1 ("'\n"); \ PUSH_FAILURE_ITEM (string_place); \ \ DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \ DEBUG_PUSH (failure_id); \ } while (0) /* This is the number of items that are pushed and popped on the stack for each register. */ #define NUM_REG_ITEMS 3 /* Individual items aside from the registers. */ #ifdef DEBUG #define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ #else #define NUM_NONREG_ITEMS 4 #endif /* We push at most this many items on the stack. */ #define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS) /* We actually push this many items. */ #define NUM_FAILURE_ITEMS \ ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ + NUM_NONREG_ITEMS) /* How many items can still be added to the stack without overflowing it. */ #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) /* Pops what PUSH_FAIL_STACK pushes. We restore into the parameters, all of which should be lvalues: STR -- the saved data position. PAT -- the saved pattern position. LOW_REG, HIGH_REG -- the highest and lowest active registers. REGSTART, REGEND -- arrays of string positions. REG_INFO -- array of information about each subexpression. Also assumes the variables `fail_stack' and (if debugging), `bufp', `pend', `string1', `size1', `string2', and `size2'. */ #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\ { \ DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \ int this_reg; \ unsigned char *string_temp; \ \ assert (!FAIL_STACK_EMPTY ()); \ \ /* Remove failure points and point to how many regs pushed. */ \ DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \ DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \ DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \ \ assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ \ DEBUG_POP (&failure_id); \ DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \ \ /* If the saved string location is NULL, it came from an \ on_failure_keep_string_jump opcode, and we want to throw away the \ saved NULL, thus retaining our current position in the string. */ \ string_temp = POP_FAILURE_ITEM (); \ if (string_temp != NULL) \ str = (char *) string_temp; \ \ DEBUG_PRINT2 (" Popping string 0x%x: `", str); \ DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ DEBUG_PRINT1 ("'\n"); \ \ pat = (unsigned char *) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \ DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ \ /* Restore register info. */ \ high_reg = (unsigned) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ \ low_reg = (unsigned) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ \ for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ { \ DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ \ reg_info[this_reg].word = POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \ \ regend[this_reg] = (char *) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ \ regstart[this_reg] = (char *) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ } \ \ DEBUG_STATEMENT (nfailure_points_popped++); \ } /* POP_FAILURE_POINT */ /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible characters can start a string that matches the pattern. This fastmap is used by re_search to skip quickly over impossible starting points. The caller must supply the address of a (1 << BYTEWIDTH)-byte data area as BUFP->fastmap. We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in the pattern buffer. Returns 0 if we succeed, -2 if an internal error. */ int re_compile_fastmap (bufp) struct re_pattern_buffer *bufp; { int j, k; fail_stack_type fail_stack; #ifndef REGEX_MALLOC char *destination; #endif /* We don't push any register information onto the failure stack. */ unsigned num_regs = 0; register char *fastmap = bufp->fastmap; unsigned char *pattern = bufp->buffer; unsigned long size = bufp->used; unsigned char *p = pattern; register unsigned char *pend = pattern + size; /* Assume that each path through the pattern can be null until proven otherwise. We set this false at the bottom of switch statement, to which we get only if a particular path doesn't match the empty string. */ boolean path_can_be_null = true; /* We aren't doing a `succeed_n' to begin with. */ boolean succeed_n_p = false; assert (fastmap != NULL && p != NULL); INIT_FAIL_STACK (); bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */ bufp->fastmap_accurate = 1; /* It will be when we're done. */ bufp->can_be_null = 0; while (p != pend || !FAIL_STACK_EMPTY ()) { if (p == pend) { bufp->can_be_null |= path_can_be_null; /* Reset for next path. */ path_can_be_null = true; p = fail_stack.stack[--fail_stack.avail]; } /* We should never be about to go beyond the end of the pattern. */ assert (p < pend); #ifdef SWITCH_ENUM_BUG switch ((int) ((re_opcode_t) *p++)) #else switch ((re_opcode_t) *p++) #endif { /* I guess the idea here is to simply not bother with a fastmap if a backreference is used, since it's too hard to figure out the fastmap for the corresponding group. Setting `can_be_null' stops `re_search_2' from using the fastmap, so that is all we do. */ case duplicate: bufp->can_be_null = 1; return 0; /* Following are the cases which match a character. These end with `break'. */ case exactn: fastmap[p[1]] = 1; break; case charset: for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) fastmap[j] = 1; break; case charset_not: /* Chars beyond end of map must be allowed. */ for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) fastmap[j] = 1; for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) fastmap[j] = 1; break; case wordchar: for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) == Sword) fastmap[j] = 1; break; case notwordchar: for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) != Sword) fastmap[j] = 1; break; case anychar: /* `.' matches anything ... */ for (j = 0; j < (1 << BYTEWIDTH); j++) fastmap[j] = 1; /* ... except perhaps newline. */ if (!(bufp->syntax & RE_DOT_NEWLINE)) fastmap['\n'] = 0; /* Return if we have already set `can_be_null'; if we have, then the fastmap is irrelevant. Something's wrong here. */ else if (bufp->can_be_null) return 0; /* Otherwise, have to check alternative paths. */ break; #ifdef emacs case syntaxspec: k = *p++; for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) == (enum syntaxcode) k) fastmap[j] = 1; break; case notsyntaxspec: k = *p++; for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) != (enum syntaxcode) k) fastmap[j] = 1; break; /* All cases after this match the empty string. These end with `continue'. */ case before_dot: case at_dot: case after_dot: continue; #endif /* not emacs */ case no_op: case begline: case endline: case begbuf: case endbuf: case wordbound: case notwordbound: case wordbeg: case wordend: case push_dummy_failure: continue; case jump_n: case pop_failure_jump: case maybe_pop_jump: case jump: case jump_past_alt: case dummy_failure_jump: EXTRACT_NUMBER_AND_INCR (j, p); p += j; if (j > 0) continue; /* Jump backward implies we just went through the body of a loop and matched nothing. Opcode jumped to should be `on_failure_jump' or `succeed_n'. Just treat it like an ordinary jump. For a * loop, it has pushed its failure point already; if so, discard that as redundant. */ if ((re_opcode_t) *p != on_failure_jump && (re_opcode_t) *p != succeed_n) continue; p++; EXTRACT_NUMBER_AND_INCR (j, p); p += j; /* If what's on the stack is where we are now, pop it. */ if (!FAIL_STACK_EMPTY () && fail_stack.stack[fail_stack.avail - 1] == p) fail_stack.avail--; continue; case on_failure_jump: case on_failure_keep_string_jump: handle_on_failure_jump: EXTRACT_NUMBER_AND_INCR (j, p); /* For some patterns, e.g., `(a?)?', `p+j' here points to the end of the pattern. We don't want to push such a point, since when we restore it above, entering the switch will increment `p' past the end of the pattern. We don't need to push such a point since we obviously won't find any more fastmap entries beyond `pend'. Such a pattern can match the null string, though. */ if (p + j < pend) { if (!PUSH_PATTERN_OP (p + j, fail_stack)) return -2; } else bufp->can_be_null = 1; if (succeed_n_p) { EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ succeed_n_p = false; } continue; case succeed_n: /* Get to the number of times to succeed. */ p += 2; /* Increment p past the n for when k != 0. */ EXTRACT_NUMBER_AND_INCR (k, p); if (k == 0) { p -= 4; succeed_n_p = true; /* Spaghetti code alert. */ goto handle_on_failure_jump; } continue; case set_number_at: p += 4; continue; case start_memory: case stop_memory: p += 2; continue; default: abort (); /* We have listed all the cases. */ } /* switch *p++ */ /* Getting here means we have found the possible starting characters for one path of the pattern -- and that the empty string does not match. We need not follow this path further. Instead, look at the next alternative (remembered on the stack), or quit if no more. The test at the top of the loop does these things. */ path_can_be_null = false; p = pend; } /* while p */ /* Set `can_be_null' for the last path (also the first path, if the pattern is empty). */ bufp->can_be_null |= path_can_be_null; return 0; } /* re_compile_fastmap */ /* Set REGS to hold NUM_REGS registers, storing them in STARTS and ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use this memory for recording register information. STARTS and ENDS must be allocated using the malloc library routine, and must each be at least NUM_REGS * sizeof (regoff_t) bytes long. If NUM_REGS == 0, then subsequent matches should allocate their own register data. Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ void re_set_registers (bufp, regs, num_regs, starts, ends) struct re_pattern_buffer *bufp; struct re_registers *regs; unsigned num_regs; regoff_t *starts, *ends; { if (num_regs) { bufp->regs_allocated = REGS_REALLOCATE; regs->num_regs = num_regs; regs->start = starts; regs->end = ends; } else { bufp->regs_allocated = REGS_UNALLOCATED; regs->num_regs = 0; regs->start = regs->end = (regoff_t) 0; } } /* Searching routines. */ /* Like re_search_2, below, but only one string is specified, and doesn't let you say where to stop matching. */ int re_search (bufp, string, size, startpos, range, regs) struct re_pattern_buffer *bufp; char *string; int size, startpos, range; struct re_registers *regs; { return re_search_2 (bufp, NULL, 0, string, size, startpos, range, regs, size); } /* Using the compiled pattern in BUFP->buffer, first tries to match the virtual concatenation of STRING1 and STRING2, starting first at index STARTPOS, then at STARTPOS + 1, and so on. STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. RANGE is how far to scan while trying to match. RANGE = 0 means try only at STARTPOS; in general, the last start tried is STARTPOS + RANGE. In REGS, return the indices of the virtual concatenation of STRING1 and STRING2 that matched the entire BUFP->buffer and its contained subexpressions. Do not consider matching one past the index STOP in the virtual concatenation of STRING1 and STRING2. We return either the position in the strings at which the match was found, -1 if no match, or -2 if error (such as failure stack overflow). */ int re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) struct re_pattern_buffer *bufp; char *string1, *string2; int size1, size2; int startpos; int range; struct re_registers *regs; int stop; { int val; register char *fastmap = bufp->fastmap; register char *translate = bufp->translate; int total_size = size1 + size2; int endpos = startpos + range; /* Check for out-of-range STARTPOS. */ if (startpos < 0 || startpos > total_size) return -1; /* Fix up RANGE if it might eventually take us outside the virtual concatenation of STRING1 and STRING2. */ if (endpos < -1) range = -1 - startpos; else if (endpos > total_size) range = total_size - startpos; /* If the search isn't to be a backwards one, don't waste time in a search for a pattern that must be anchored. */ if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) { if (startpos > 0) return -1; else range = 1; } /* Update the fastmap now if not correct already. */ if (fastmap && !bufp->fastmap_accurate) if (re_compile_fastmap (bufp) == -2) return -2; /* Loop through the string, looking for a place to start matching. */ for (;;) { /* If a fastmap is supplied, skip quickly over characters that cannot be the start of a match. If the pattern can match the null string, however, we don't need to skip characters; we want the first null string. */ if (fastmap && startpos < total_size && !bufp->can_be_null) { if (range > 0) /* Searching forwards. */ { register char *d; register int lim = 0; int irange = range; if (startpos < size1 && startpos + range >= size1) lim = range - (size1 - startpos); d = (startpos >= size1 ? string2 - size1 : string1) + startpos; /* Written out as an if-else to avoid testing `translate' inside the loop. */ if (translate) while (range > lim && !fastmap[(unsigned char) translate[(unsigned char) *d++]]) range--; else while (range > lim && !fastmap[(unsigned char) *d++]) range--; startpos += irange - range; } else /* Searching backwards. */ { register char c = (size1 == 0 || startpos >= size1 ? string2[startpos - size1] : string1[startpos]); if (!fastmap[(unsigned char) TRANSLATE (c)]) goto advance; } } /* If can't match the null string, and that's all we have left, fail. */ if (range >= 0 && startpos == total_size && fastmap && !bufp->can_be_null) return -1; val = re_match_2 (bufp, string1, size1, string2, size2, startpos, regs, stop); if (val >= 0) return startpos; if (val == -2) return -2; advance: if (!range) break; else if (range > 0) { range--; startpos++; } else { range++; startpos--; } } return -1; } /* re_search_2 */ /* Declarations and macros for re_match_2. */ static int bcmp_translate (); static boolean alt_match_null_string_p (), common_op_match_null_string_p (), group_match_null_string_p (); /* Structure for per-register (a.k.a. per-group) information. This must not be longer than one word, because we push this value onto the failure stack. Other register information, such as the starting and ending positions (which are addresses), and the list of inner groups (which is a bits list) are maintained in separate variables. We are making a (strictly speaking) nonportable assumption here: that the compiler will pack our bit fields into something that fits into the type of `word', i.e., is something that fits into one item on the failure stack. */ typedef union { fail_stack_elt_t word; struct { /* This field is one if this group can match the empty string, zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ #define MATCH_NULL_UNSET_VALUE 3 unsigned match_null_string_p : 2; unsigned is_active : 1; unsigned matched_something : 1; unsigned ever_matched_something : 1; } bits; } register_info_type; #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) #define IS_ACTIVE(R) ((R).bits.is_active) #define MATCHED_SOMETHING(R) ((R).bits.matched_something) #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) /* Call this when have matched a real character; it sets `matched' flags for the subexpressions which we are currently inside. Also records that those subexprs have matched. */ #define SET_REGS_MATCHED() \ do \ { \ unsigned r; \ for (r = lowest_active_reg; r <= highest_active_reg; r++) \ { \ MATCHED_SOMETHING (reg_info[r]) \ = EVER_MATCHED_SOMETHING (reg_info[r]) \ = 1; \ } \ } \ while (0) /* This converts PTR, a pointer into one of the search strings `string1' and `string2' into an offset from the beginning of that string. */ #define POINTER_TO_OFFSET(ptr) \ (FIRST_STRING_P (ptr) ? (ptr) - string1 : (ptr) - string2 + size1) /* Registers are set to a sentinel when they haven't yet matched. */ #define REG_UNSET_VALUE ((char *) -1) #define REG_UNSET(e) ((e) == REG_UNSET_VALUE) /* Macros for dealing with the split strings in re_match_2. */ #define MATCHING_IN_FIRST_STRING (dend == end_match_1) /* Call before fetching a character with *d. This switches over to string2 if necessary. */ #define PREFETCH() \ while (d == dend) \ { \ /* End of string2 => fail. */ \ if (dend == end_match_2) \ goto fail; \ /* End of string1 => advance to string2. */ \ d = string2; \ dend = end_match_2; \ } /* Test if at very beginning or at very end of the virtual concatenation of `string1' and `string2'. If only one string, it's `string2'. */ #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) #define AT_STRINGS_END(d) ((d) == end2) /* Test if D points to a character which is word-constituent. We have two special cases to check for: if past the end of string1, look at the first character in string2; and if before the beginning of string2, look at the last character in string1. */ #define WORDCHAR_P(d) \ (SYNTAX ((d) == end1 ? *string2 \ : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \ == Sword) /* Test if the character before D and the one at D differ with respect to being word-constituent. */ #define AT_WORD_BOUNDARY(d) \ (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \ || WORDCHAR_P (d - 1) != WORDCHAR_P (d)) /* Free everything we malloc. */ #ifdef REGEX_MALLOC #define FREE_VAR(var) if (var) free (var); var = NULL #define FREE_VARIABLES() \ do { \ FREE_VAR (fail_stack.stack); \ FREE_VAR (regstart); \ FREE_VAR (regend); \ FREE_VAR (old_regstart); \ FREE_VAR (old_regend); \ FREE_VAR (best_regstart); \ FREE_VAR (best_regend); \ FREE_VAR (reg_info); \ FREE_VAR (reg_dummy); \ FREE_VAR (reg_info_dummy); \ } while (0) #else /* not REGEX_MALLOC */ /* Some MIPS systems (at least) want this to free alloca'd storage. */ #define FREE_VARIABLES() alloca (0) #endif /* not REGEX_MALLOC */ /* These values must meet several constraints. They must not be valid register values; since we have a limit of 255 registers (because we use only one byte in the pattern for the register number), we can use numbers larger than 255. They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value for the lowest register must be larger than the value for the highest register, so we do not try to actually save any registers when none are active. */ #define NO_HIGHEST_ACTIVE_REG (1 << BYTEWIDTH) #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) /* Matching routines. */ #ifndef emacs /* Emacs never uses this. */ /* re_match is like re_match_2 except it takes only a single string. */ int re_match (bufp, string, size, pos, regs) struct re_pattern_buffer *bufp; char *string; int size, pos; struct re_registers *regs; { return re_match_2 (bufp, NULL, 0, string, size, pos, regs, size); } #endif /* not emacs */ /* re_match_2 matches the compiled pattern in BUFP against the the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and SIZE2, respectively). We start matching at POS, and stop matching at STOP. If REGS is non-null and the `no_sub' field of BUFP is nonzero, we store offsets for the substring each group matched in REGS. See the documentation for exactly how many groups we fill. We return -1 if no match, -2 if an internal error (such as the failure stack overflowing). Otherwise, we return the length of the matched substring. */ int re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) struct re_pattern_buffer *bufp; char *string1, *string2; int size1, size2; int pos; struct re_registers *regs; int stop; { /* General temporaries. */ int mcnt; unsigned char *p1; /* Just past the end of the corresponding string. */ char *end1, *end2; /* Pointers into string1 and string2, just past the last characters in each to consider matching. */ char *end_match_1, *end_match_2; /* Where we are in the data, and the end of the current string. */ char *d, *dend; /* Where we are in the pattern, and the end of the pattern. */ unsigned char *p = bufp->buffer; register unsigned char *pend = p + bufp->used; /* We use this to map every character in the string. */ char *translate = bufp->translate; /* Failure point stack. Each place that can handle a failure further down the line pushes a failure point on this stack. It consists of restart, regend, and reg_info for all registers corresponding to the subexpressions we're currently inside, plus the number of such registers, and, finally, two char *'s. The first char * is where to resume scanning the pattern; the second one is where to resume scanning the strings. If the latter is zero, the failure point is a ``dummy''; if a failure happens and the failure point is a dummy, it gets discarded and the next next one is tried. */ fail_stack_type fail_stack; #ifdef DEBUG static unsigned failure_id = 0; unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0; #endif /* We fill all the registers internally, independent of what we return, for use in backreferences. The number here includes an element for register zero. */ unsigned num_regs = bufp->re_nsub + 1; /* The currently active registers. */ unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG; unsigned highest_active_reg = NO_HIGHEST_ACTIVE_REG; /* Information on the contents of registers. These are pointers into the input strings; they record just what was matched (on this attempt) by a subexpression part of the pattern, that is, the regnum-th regstart pointer points to where in the pattern we began matching and the regnum-th regend points to right after where we stopped matching the regnum-th subexpression. (The zeroth register keeps track of what the whole pattern matches.) */ char **regstart, **regend; /* If a group that's operated upon by a repetition operator fails to match anything, then the register for its start will need to be restored because it will have been set to wherever in the string we are when we last see its open-group operator. Similarly for a register's end. */ char **old_regstart, **old_regend; /* The is_active field of reg_info helps us keep track of which (possibly nested) subexpressions we are currently in. The matched_something field of reg_info[reg_num] helps us tell whether or not we have matched any of the pattern so far this time through the reg_num-th subexpression. These two fields get reset each time through any loop their register is in. */ register_info_type *reg_info; /* The following record the register info as found in the above variables when we find a match better than any we've seen before. This happens as we backtrack through the failure points, which in turn happens only if we have not yet matched the entire string. */ unsigned best_regs_set = false; char **best_regstart, **best_regend; /* Logically, this is `best_regend[0]'. But we don't want to have to allocate space for that if we're not allocating space for anything else (see below). Also, we never need info about register 0 for any of the other register vectors, and it seems rather a kludge to treat `best_regend' differently than the rest. So we keep track of the end of the best match so far in a separate variable. We initialize this to NULL so that when we backtrack the first time and need to test it, it's not garbage. */ char *match_end = NULL; /* Used when we pop values we don't care about. */ char **reg_dummy; register_info_type *reg_info_dummy; #ifdef DEBUG /* Counts the total number of registers pushed. */ unsigned num_regs_pushed = 0; #endif DEBUG_PRINT1 ("\n\nEntering re_match_2.\n"); INIT_FAIL_STACK (); /* Do not bother to initialize all the register variables if there are no groups in the pattern, as it takes a fair amount of time. If there are groups, we include space for register 0 (the whole pattern), even though we never use it, since it simplifies the array indexing. We should fix this. */ if (bufp->re_nsub) { regstart = REGEX_TALLOC (num_regs, char *); regend = REGEX_TALLOC (num_regs, char *); old_regstart = REGEX_TALLOC (num_regs, char *); old_regend = REGEX_TALLOC (num_regs, char *); best_regstart = REGEX_TALLOC (num_regs, char *); best_regend = REGEX_TALLOC (num_regs, char *); reg_info = REGEX_TALLOC (num_regs, register_info_type); reg_dummy = REGEX_TALLOC (num_regs, char *); reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); if (!(regstart && regend && old_regstart && old_regend && reg_info && best_regstart && best_regend && reg_dummy && reg_info_dummy)) { FREE_VARIABLES (); return -2; } } #ifdef REGEX_MALLOC else { /* We must initialize all our variables to NULL, so that `FREE_VARIABLES' doesn't try to free them. */ regstart = regend = old_regstart = old_regend = best_regstart = best_regend = reg_dummy = NULL; reg_info = reg_info_dummy = (register_info_type *) NULL; } #endif /* REGEX_MALLOC */ /* The starting position is bogus. */ if (pos < 0 || pos > size1 + size2) { FREE_VARIABLES (); return -1; } /* Initialize subexpression text positions to -1 to mark ones that no start_memory/stop_memory has been seen for. Also initialize the register information struct. */ for (mcnt = 1; mcnt < num_regs; mcnt++) { regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE; REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; IS_ACTIVE (reg_info[mcnt]) = 0; MATCHED_SOMETHING (reg_info[mcnt]) = 0; EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; } /* We move `string1' into `string2' if the latter's empty -- but not if `string1' is null. */ if (size2 == 0 && string1 != NULL) { string2 = string1; size2 = size1; string1 = 0; size1 = 0; } end1 = string1 + size1; end2 = string2 + size2; /* Compute where to stop matching, within the two strings. */ if (stop <= size1) { end_match_1 = string1 + stop; end_match_2 = string2; } else { end_match_1 = end1; end_match_2 = string2 + stop - size1; } /* `p' scans through the pattern as `d' scans through the data. `dend' is the end of the input string that `d' points within. `d' is advanced into the following input string whenever necessary, but this happens before fetching; therefore, at the beginning of the loop, `d' can be pointing at the end of a string, but it cannot equal `string2'. */ if (size1 > 0 && pos <= size1) { d = string1 + pos; dend = end_match_1; } else { d = string2 + pos - size1; dend = end_match_2; } DEBUG_PRINT1 ("The compiled pattern is: "); DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend); DEBUG_PRINT1 ("The string to match is: `"); DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); DEBUG_PRINT1 ("'\n"); /* This loops over pattern commands. It exits by returning from the function if the match is complete, or it drops through if the match fails at this starting point in the input data. */ for (;;) { DEBUG_PRINT2 ("\n0x%x: ", p); if (p == pend) { /* End of pattern means we might have succeeded. */ DEBUG_PRINT1 ("end of pattern ... "); /* If we haven't matched the entire string, and we want the longest match, try backtracking. */ if (d != end_match_2) { DEBUG_PRINT1 ("backtracking.\n"); if (!FAIL_STACK_EMPTY ()) { /* More failure points to try. */ boolean same_str_p = (FIRST_STRING_P (match_end) == MATCHING_IN_FIRST_STRING); /* If exceeds best match so far, save it. */ if (!best_regs_set || (same_str_p && d > match_end) || (!same_str_p && !MATCHING_IN_FIRST_STRING)) { best_regs_set = true; match_end = d; DEBUG_PRINT1 ("\nSAVING match as best so far.\n"); for (mcnt = 1; mcnt < num_regs; mcnt++) { best_regstart[mcnt] = regstart[mcnt]; best_regend[mcnt] = regend[mcnt]; } } goto fail; } /* If no failure points, don't restore garbage. */ else if (best_regs_set) { restore_best_regs: /* Restore best match. It may happen that `dend == end_match_1' while the restored d is in string2. For example, the pattern `x.*y.*z' against the strings `x-' and `y-z-', if the two strings are not consecutive in memory. */ DEBUG_PRINT1 ("Restoring best registers.\n"); d = match_end; dend = ((d >= string1 && d <= end1) ? end_match_1 : end_match_2); for (mcnt = 1; mcnt < num_regs; mcnt++) { regstart[mcnt] = best_regstart[mcnt]; regend[mcnt] = best_regend[mcnt]; } } } /* d != end_match_2 */ DEBUG_PRINT1 ("Accepting match.\n"); /* If caller wants register contents data back, do it. */ if (regs && !bufp->no_sub) { /* Have the register data arrays been allocated? */ if (bufp->regs_allocated == REGS_UNALLOCATED) { /* No. So allocate them with malloc. We need one extra element beyond `num_regs' for the `-1' marker GNU code uses. */ regs->num_regs = MAX (RE_NREGS, num_regs + 1); regs->start = TALLOC (regs->num_regs, regoff_t); regs->end = TALLOC (regs->num_regs, regoff_t); if (regs->start == NULL || regs->end == NULL) return -2; bufp->regs_allocated = REGS_REALLOCATE; } else if (bufp->regs_allocated == REGS_REALLOCATE) { /* Yes. If we need more elements than were already allocated, reallocate them. If we need fewer, just leave it alone. */ if (regs->num_regs < num_regs + 1) { regs->num_regs = num_regs + 1; RETALLOC (regs->start, regs->num_regs, regoff_t); RETALLOC (regs->end, regs->num_regs, regoff_t); if (regs->start == NULL || regs->end == NULL) return -2; } } else assert (bufp->regs_allocated == REGS_FIXED); /* Convert the pointer data in `regstart' and `regend' to indices. Register zero has to be set differently, since we haven't kept track of any info for it. */ if (regs->num_regs > 0) { regs->start[0] = pos; regs->end[0] = (MATCHING_IN_FIRST_STRING ? d - string1 : d - string2 + size1); } /* Go through the first `min (num_regs, regs->num_regs)' registers, since that is all we initialized. */ for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++) { if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt])) regs->start[mcnt] = regs->end[mcnt] = -1; else { regs->start[mcnt] = POINTER_TO_OFFSET (regstart[mcnt]); regs->end[mcnt] = POINTER_TO_OFFSET (regend[mcnt]); } } /* If the regs structure we return has more elements than were in the pattern, set the extra elements to -1. If we (re)allocated the registers, this is the case, because we always allocate enough to have at least one -1 at the end. */ for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++) regs->start[mcnt] = regs->end[mcnt] = -1; } /* regs && !bufp->no_sub */ FREE_VARIABLES (); DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", nfailure_points_pushed, nfailure_points_popped, nfailure_points_pushed - nfailure_points_popped); DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed); mcnt = d - pos - (MATCHING_IN_FIRST_STRING ? string1 : string2 - size1); DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt); return mcnt; } /* Otherwise match next pattern command. */ #ifdef SWITCH_ENUM_BUG switch ((int) ((re_opcode_t) *p++)) #else switch ((re_opcode_t) *p++) #endif { /* Ignore these. Used to ignore the n of succeed_n's which currently have n == 0. */ case no_op: DEBUG_PRINT1 ("EXECUTING no_op.\n"); break; /* Match the next n pattern characters exactly. The following byte in the pattern defines n, and the n bytes after that are the characters to match. */ case exactn: mcnt = *p++; DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt); /* This is written out as an if-else so we don't waste time testing `translate' inside the loop. */ if (translate) { do { PREFETCH (); if (translate[(unsigned char) *d++] != (char) *p++) goto fail; } while (--mcnt); } else { do { PREFETCH (); if (*d++ != (char) *p++) goto fail; } while (--mcnt); } SET_REGS_MATCHED (); break; /* Match any character except possibly a newline or a null. */ case anychar: DEBUG_PRINT1 ("EXECUTING anychar.\n"); PREFETCH (); if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n') || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000')) goto fail; SET_REGS_MATCHED (); DEBUG_PRINT2 (" Matched `%d'.\n", *d); d++; break; case charset: case charset_not: { register unsigned char c; boolean not = (re_opcode_t) *(p - 1) == charset_not; DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : ""); PREFETCH (); c = TRANSLATE (*d); /* The character to match. */ /* Cast to `unsigned' instead of `unsigned char' in case the bit list is a full 32 bytes long. */ if (c < (unsigned) (*p * BYTEWIDTH) && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) not = !not; p += 1 + *p; if (!not) goto fail; SET_REGS_MATCHED (); d++; break; } /* The beginning of a group is represented by start_memory. The arguments are the register number in the next byte, and the number of groups inner to this one in the next. The text matched within the group is recorded (in the internal registers data structure) under the register number. */ case start_memory: DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]); /* Find out if this group can match the empty string. */ p1 = p; /* To send to group_match_null_string_p. */ if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE) REG_MATCH_NULL_STRING_P (reg_info[*p]) = group_match_null_string_p (&p1, pend, reg_info); /* Save the position in the string where we were the last time we were at this open-group operator in case the group is operated upon by a repetition operator, e.g., with `(a*)*b' against `ab'; then we want to ignore where we are now in the string in case this attempt to match fails. */ old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) ? REG_UNSET (regstart[*p]) ? d : regstart[*p] : regstart[*p]; DEBUG_PRINT2 (" old_regstart: %d\n", POINTER_TO_OFFSET (old_regstart[*p])); regstart[*p] = d; DEBUG_PRINT2 (" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p])); IS_ACTIVE (reg_info[*p]) = 1; MATCHED_SOMETHING (reg_info[*p]) = 0; /* This is the new highest active register. */ highest_active_reg = *p; /* If nothing was active before, this is the new lowest active register. */ if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) lowest_active_reg = *p; /* Move past the register number and inner group count. */ p += 2; break; /* The stop_memory opcode represents the end of a group. Its arguments are the same as start_memory's: the register number, and the number of inner groups. */ case stop_memory: DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]); /* We need to save the string position the last time we were at this close-group operator in case the group is operated upon by a repetition operator, e.g., with `((a*)*(b*)*)*' against `aba'; then we want to ignore where we are now in the string in case this attempt to match fails. */ old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) ? REG_UNSET (regend[*p]) ? d : regend[*p] : regend[*p]; DEBUG_PRINT2 (" old_regend: %d\n", POINTER_TO_OFFSET (old_regend[*p])); regend[*p] = d; DEBUG_PRINT2 (" regend: %d\n", POINTER_TO_OFFSET (regend[*p])); /* This register isn't active anymore. */ IS_ACTIVE (reg_info[*p]) = 0; /* If this was the only register active, nothing is active anymore. */ if (lowest_active_reg == highest_active_reg) { lowest_active_reg = NO_LOWEST_ACTIVE_REG; highest_active_reg = NO_HIGHEST_ACTIVE_REG; } else { /* We must scan for the new highest active register, since it isn't necessarily one less than now: consider (a(b)c(d(e)f)g). When group 3 ends, after the f), the new highest active register is 1. */ unsigned char r = *p - 1; while (r > 0 && !IS_ACTIVE (reg_info[r])) r--; /* If we end up at register zero, that means that we saved the registers as the result of an `on_failure_jump', not a `start_memory', and we jumped to past the innermost `stop_memory'. For example, in ((.)*) we save registers 1 and 2 as a result of the *, but when we pop back to the second ), we are at the stop_memory 1. Thus, nothing is active. */ if (r == 0) { lowest_active_reg = NO_LOWEST_ACTIVE_REG; highest_active_reg = NO_HIGHEST_ACTIVE_REG; } else highest_active_reg = r; } /* If just failed to match something this time around with a group that's operated on by a repetition operator, try to force exit from the ``loop'', and restore the register information for this group that we had before trying this last match. */ if ((!MATCHED_SOMETHING (reg_info[*p]) || (re_opcode_t) p[-3] == start_memory) && (p + 2) < pend) { boolean is_a_jump_n = false; p1 = p + 2; mcnt = 0; switch ((re_opcode_t) *p1++) { case jump_n: is_a_jump_n = true; case pop_failure_jump: case maybe_pop_jump: case jump: case dummy_failure_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p1); if (is_a_jump_n) p1 += 2; break; default: /* do nothing */ ; } p1 += mcnt; /* If the next operation is a jump backwards in the pattern to an on_failure_jump right before the start_memory corresponding to this stop_memory, exit from the loop by forcing a failure after pushing on the stack the on_failure_jump's jump in the pattern, and d. */ if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump && (re_opcode_t) p1[3] == start_memory && p1[4] == *p) { /* If this group ever matched anything, then restore what its registers were before trying this last failed match, e.g., with `(a*)*b' against `ab' for regstart[1], and, e.g., with `((a*)*(b*)*)*' against `aba' for regend[3]. Also restore the registers for inner groups for, e.g., `((a*)(b*))*' against `aba' (register 3 would otherwise get trashed). */ if (EVER_MATCHED_SOMETHING (reg_info[*p])) { unsigned r; EVER_MATCHED_SOMETHING (reg_info[*p]) = 0; /* Restore this and inner groups' (if any) registers. */ for (r = *p; r < *p + *(p + 1); r++) { regstart[r] = old_regstart[r]; /* xx why this test? */ if ((int) old_regend[r] >= (int) regstart[r]) regend[r] = old_regend[r]; } } p1++; EXTRACT_NUMBER_AND_INCR (mcnt, p1); PUSH_FAILURE_POINT (p1 + mcnt, d, -2); goto fail; } } /* Move past the register number and the inner group count. */ p += 2; break; /* \ has been turned into a `duplicate' command which is followed by the numeric value of as the register number. */ case duplicate: { register char *d2, *dend2; int regno = *p++; /* Get which register to match against. */ DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno); /* Can't back reference a group which we've never matched. */ if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) goto fail; /* Where in input to try to start matching. */ d2 = regstart[regno]; /* Where to stop matching; if both the place to start and the place to stop matching are in the same string, then set to the place to stop, otherwise, for now have to use the end of the first string. */ dend2 = ((FIRST_STRING_P (regstart[regno]) == FIRST_STRING_P (regend[regno])) ? regend[regno] : end_match_1); for (;;) { /* If necessary, advance to next segment in register contents. */ while (d2 == dend2) { if (dend2 == end_match_2) break; if (dend2 == regend[regno]) break; /* End of string1 => advance to string2. */ d2 = string2; dend2 = regend[regno]; } /* At end of register contents => success */ if (d2 == dend2) break; /* If necessary, advance to next segment in data. */ PREFETCH (); /* How many characters left in this segment to match. */ mcnt = dend - d; /* Want how many consecutive characters we can match in one shot, so, if necessary, adjust the count. */ if (mcnt > dend2 - d2) mcnt = dend2 - d2; /* Compare that many; failure if mismatch, else move past them. */ if (translate ? bcmp_translate (d, d2, mcnt, translate) : bcmp (d, d2, mcnt)) goto fail; d += mcnt, d2 += mcnt; } } break; /* begline matches the empty string at the beginning of the string (unless `not_bol' is set in `bufp'), and, if `newline_anchor' is set, after newlines. */ case begline: DEBUG_PRINT1 ("EXECUTING begline.\n"); if (AT_STRINGS_BEG (d)) { if (!bufp->not_bol) break; } else if (d[-1] == '\n' && bufp->newline_anchor) { break; } /* In all other cases, we fail. */ goto fail; /* endline is the dual of begline. */ case endline: DEBUG_PRINT1 ("EXECUTING endline.\n"); if (AT_STRINGS_END (d)) { if (!bufp->not_eol) break; } /* We have to ``prefetch'' the next character. */ else if ((d == end1 ? *string2 : *d) == '\n' && bufp->newline_anchor) { break; } goto fail; /* Match at the very beginning of the data. */ case begbuf: DEBUG_PRINT1 ("EXECUTING begbuf.\n"); if (AT_STRINGS_BEG (d)) break; goto fail; /* Match at the very end of the data. */ case endbuf: DEBUG_PRINT1 ("EXECUTING endbuf.\n"); if (AT_STRINGS_END (d)) break; goto fail; /* on_failure_keep_string_jump is used to optimize `.*\n'. It pushes NULL as the value for the string on the stack. Then `pop_failure_point' will keep the current value for the string, instead of restoring it. To see why, consider matching `foo\nbar' against `.*\n'. The .* matches the foo; then the . fails against the \n. But the next thing we want to do is match the \n against the \n; if we restored the string value, we would be back at the foo. Because this is used only in specific cases, we don't need to check all the things that `on_failure_jump' does, to make sure the right things get saved on the stack. Hence we don't share its code. The only reason to push anything on the stack at all is that otherwise we would have to change `anychar's code to do something besides goto fail in this case; that seems worse than this. */ case on_failure_keep_string_jump: DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump"); EXTRACT_NUMBER_AND_INCR (mcnt, p); DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt); PUSH_FAILURE_POINT (p + mcnt, NULL, -2); break; /* Uses of on_failure_jump: Each alternative starts with an on_failure_jump that points to the beginning of the next alternative. Each alternative except the last ends with a jump that in effect jumps past the rest of the alternatives. (They really jump to the ending jump of the following alternative, because tensioning these jumps is a hassle.) Repeats start with an on_failure_jump that points past both the repetition text and either the following jump or pop_failure_jump back to this on_failure_jump. */ case on_failure_jump: on_failure: DEBUG_PRINT1 ("EXECUTING on_failure_jump"); EXTRACT_NUMBER_AND_INCR (mcnt, p); DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt); /* If this on_failure_jump comes right before a group (i.e., the original * applied to a group), save the information for that group and all inner ones, so that if we fail back to this point, the group's information will be correct. For example, in \(a*\)*\1, we need the preceding group, and in \(\(a*\)b*\)\2, we need the inner group. */ /* We can't use `p' to check ahead because we push a failure point to `p + mcnt' after we do this. */ p1 = p; /* We need to skip no_op's before we look for the start_memory in case this on_failure_jump is happening as the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 against aba. */ while (p1 < pend && (re_opcode_t) *p1 == no_op) p1++; if (p1 < pend && (re_opcode_t) *p1 == start_memory) { /* We have a new highest active register now. This will get reset at the start_memory we are about to get to, but we will have saved all the registers relevant to this repetition op, as described above. */ highest_active_reg = *(p1 + 1) + *(p1 + 2); if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) lowest_active_reg = *(p1 + 1); } DEBUG_PRINT1 (":\n"); PUSH_FAILURE_POINT (p + mcnt, d, -2); break; /* A smart repeat ends with `maybe_pop_jump'. We change it to either `pop_failure_jump' or `jump'. */ case maybe_pop_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p); DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); { register unsigned char *p2 = p; /* Compare the beginning of the repeat with what in the pattern follows its end. If we can establish that there is nothing that they would both match, i.e., that we would have to backtrack because of (as in, e.g., `a*a') then we can change to pop_failure_jump, because we'll never have to backtrack. This is not true in the case of alternatives: in `(a|ab)*' we do need to backtrack to the `ab' alternative (e.g., if the string was `ab'). But instead of trying to detect that here, the alternative has put on a dummy failure point which is what we will end up popping. */ /* Skip over open/close-group commands. */ while (p2 + 2 < pend && ((re_opcode_t) *p2 == stop_memory || (re_opcode_t) *p2 == start_memory)) p2 += 3; /* Skip over args, too. */ /* If we're at the end of the pattern, we can change. */ if (p2 == pend) { /* Consider what happens when matching ":\(.*\)" against ":/". I don't really understand this code yet. */ p[-3] = (unsigned char) pop_failure_jump; DEBUG_PRINT1 (" End of pattern: change to `pop_failure_jump'.\n"); } else if ((re_opcode_t) *p2 == exactn || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) { register unsigned char c = *p2 == (unsigned char) endline ? '\n' : p2[2]; p1 = p + mcnt; /* p1[0] ... p1[2] are the `on_failure_jump' corresponding to the `maybe_finalize_jump' of this case. Examine what follows. */ if ((re_opcode_t) p1[3] == exactn && p1[5] != c) { p[-3] = (unsigned char) pop_failure_jump; DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", c, p1[5]); } else if ((re_opcode_t) p1[3] == charset || (re_opcode_t) p1[3] == charset_not) { int not = (re_opcode_t) p1[3] == charset_not; if (c < (unsigned char) (p1[4] * BYTEWIDTH) && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) not = !not; /* `not' is equal to 1 if c would match, which means that we can't change to pop_failure_jump. */ if (!not) { p[-3] = (unsigned char) pop_failure_jump; DEBUG_PRINT1 (" No match => pop_failure_jump.\n"); } } } } p -= 2; /* Point at relative address again. */ if ((re_opcode_t) p[-1] != pop_failure_jump) { p[-1] = (unsigned char) jump; DEBUG_PRINT1 (" Match => jump.\n"); goto unconditional_jump; } /* Note fall through. */ /* The end of a simple repeat has a pop_failure_jump back to its matching on_failure_jump, where the latter will push a failure point. The pop_failure_jump takes off failure points put on by this pop_failure_jump's matching on_failure_jump; we got through the pattern to here from the matching on_failure_jump, so didn't fail. */ case pop_failure_jump: { /* We need to pass separate storage for the lowest and highest registers, even though we don't care about the actual values. Otherwise, we will restore only one register from the stack, since lowest will == highest in `pop_failure_point'. */ unsigned dummy_low_reg, dummy_high_reg; unsigned char *pdummy; char *sdummy; DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n"); POP_FAILURE_POINT (sdummy, pdummy, dummy_low_reg, dummy_high_reg, reg_dummy, reg_dummy, reg_info_dummy); } /* Note fall through. */ /* Unconditionally jump (without popping any failure points). */ case jump: unconditional_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); p += mcnt; /* Do the jump. */ DEBUG_PRINT2 ("(to 0x%x).\n", p); break; /* We need this opcode so we can detect where alternatives end in `group_match_null_string_p' et al. */ case jump_past_alt: DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n"); goto unconditional_jump; /* Normally, the on_failure_jump pushes a failure point, which then gets popped at pop_failure_jump. We will end up at pop_failure_jump, also, and with a pattern of, say, `a+', we are skipping over the on_failure_jump, so we have to push something meaningless for pop_failure_jump to pop. */ case dummy_failure_jump: DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n"); /* It doesn't matter what we push for the string here. What the code at `fail' tests is the value for the pattern. */ PUSH_FAILURE_POINT (0, 0, -2); goto unconditional_jump; /* At the end of an alternative, we need to push a dummy failure point in case we are followed by a `pop_failure_jump', because we don't want the failure point for the alternative to be popped. For example, matching `(a|ab)*' against `aab' requires that we match the `ab' alternative. */ case push_dummy_failure: DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n"); /* See comments just above at `dummy_failure_jump' about the two zeroes. */ PUSH_FAILURE_POINT (0, 0, -2); break; /* Have to succeed matching what follows at least n times. After that, handle like `on_failure_jump'. */ case succeed_n: EXTRACT_NUMBER (mcnt, p + 2); DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt); assert (mcnt >= 0); /* Originally, this is how many times we HAVE to succeed. */ if (mcnt > 0) { mcnt--; p += 2; STORE_NUMBER_AND_INCR (p, mcnt); DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p, mcnt); } else if (mcnt == 0) { DEBUG_PRINT2 (" Setting two bytes from 0x%x to no_op.\n", p+2); p[2] = (unsigned char) no_op; p[3] = (unsigned char) no_op; goto on_failure; } break; case jump_n: EXTRACT_NUMBER (mcnt, p + 2); DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt); /* Originally, this is how many times we CAN jump. */ if (mcnt) { mcnt--; STORE_NUMBER (p + 2, mcnt); goto unconditional_jump; } /* If don't have to jump any more, skip over the rest of command. */ else p += 4; break; case set_number_at: { DEBUG_PRINT1 ("EXECUTING set_number_at.\n"); EXTRACT_NUMBER_AND_INCR (mcnt, p); p1 = p + mcnt; EXTRACT_NUMBER_AND_INCR (mcnt, p); DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p1, mcnt); STORE_NUMBER (p1, mcnt); break; } case wordbound: DEBUG_PRINT1 ("EXECUTING wordbound.\n"); if (AT_WORD_BOUNDARY (d)) break; goto fail; case notwordbound: DEBUG_PRINT1 ("EXECUTING notwordbound.\n"); if (AT_WORD_BOUNDARY (d)) goto fail; break; case wordbeg: DEBUG_PRINT1 ("EXECUTING wordbeg.\n"); if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1))) break; goto fail; case wordend: DEBUG_PRINT1 ("EXECUTING wordend.\n"); if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1) && (!WORDCHAR_P (d) || AT_STRINGS_END (d))) break; goto fail; #ifdef emacs #ifdef emacs19 case before_dot: DEBUG_PRINT1 ("EXECUTING before_dot.\n"); if (PTR_CHAR_POS ((unsigned char *) d) >= point) goto fail; break; case at_dot: DEBUG_PRINT1 ("EXECUTING at_dot.\n"); if (PTR_CHAR_POS ((unsigned char *) d) != point) goto fail; break; case after_dot: DEBUG_PRINT1 ("EXECUTING after_dot.\n"); if (PTR_CHAR_POS ((unsigned char *) d) <= point) goto fail; break; #else /* not emacs19 */ case at_dot: DEBUG_PRINT1 ("EXECUTING at_dot.\n"); if (PTR_CHAR_POS ((unsigned char *) d) + 1 != point) goto fail; break; #endif /* not emacs19 */ case syntaxspec: DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt); mcnt = *p++; goto matchsyntax; case wordchar: DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n"); mcnt = (int) Sword; matchsyntax: PREFETCH (); if (SYNTAX (*d++) != (enum syntaxcode) mcnt) goto fail; SET_REGS_MATCHED (); break; case notsyntaxspec: DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt); mcnt = *p++; goto matchnotsyntax; case notwordchar: DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n"); mcnt = (int) Sword; matchnotsyntax: PREFETCH (); if (SYNTAX (*d++) == (enum syntaxcode) mcnt) goto fail; SET_REGS_MATCHED (); break; #else /* not emacs */ case wordchar: DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n"); PREFETCH (); if (!WORDCHAR_P (d)) goto fail; SET_REGS_MATCHED (); d++; break; case notwordchar: DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n"); PREFETCH (); if (WORDCHAR_P (d)) goto fail; SET_REGS_MATCHED (); d++; break; #endif /* not emacs */ default: abort (); } continue; /* Successfully executed one pattern command; keep going. */ /* We goto here if a matching operation fails. */ fail: if (!FAIL_STACK_EMPTY ()) { /* A restart point is known. Restore to that state. */ DEBUG_PRINT1 ("\nFAIL:\n"); POP_FAILURE_POINT (d, p, lowest_active_reg, highest_active_reg, regstart, regend, reg_info); /* If this failure point is a dummy, try the next one. */ if (!p) goto fail; /* If we failed to the end of the pattern, don't examine *p. */ assert (p <= pend); if (p < pend) { boolean is_a_jump_n = false; /* If failed to a backwards jump that's part of a repetition loop, need to pop this failure point and use the next one. */ switch ((re_opcode_t) *p) { case jump_n: is_a_jump_n = true; case maybe_pop_jump: case pop_failure_jump: case jump: p1 = p + 1; EXTRACT_NUMBER_AND_INCR (mcnt, p1); p1 += mcnt; if ((is_a_jump_n && (re_opcode_t) *p1 == succeed_n) || (!is_a_jump_n && (re_opcode_t) *p1 == on_failure_jump)) goto fail; break; default: /* do nothing */ ; } } if (d >= string1 && d <= end1) dend = end_match_1; } else break; /* Matching at this starting point really fails. */ } /* for (;;) */ if (best_regs_set) goto restore_best_regs; FREE_VARIABLES (); return -1; /* Failure to match. */ } /* re_match_2 */ /* Subroutine definitions for re_match_2. */ /* We are passed P pointing to a register number after a start_memory. Return true if the pattern up to the corresponding stop_memory can match the empty string, and false otherwise. If we find the matching stop_memory, sets P to point to one past its number. Otherwise, sets P to an undefined byte less than or equal to END. We don't handle duplicates properly (yet). */ static boolean group_match_null_string_p (p, end, reg_info) unsigned char **p, *end; register_info_type *reg_info; { int mcnt; /* Point to after the args to the start_memory. */ unsigned char *p1 = *p + 2; while (p1 < end) { /* Skip over opcodes that can match nothing, and return true or false, as appropriate, when we get to one that can't, or to the matching stop_memory. */ switch ((re_opcode_t) *p1) { /* Could be either a loop or a series of alternatives. */ case on_failure_jump: p1++; EXTRACT_NUMBER_AND_INCR (mcnt, p1); /* If the next operation is not a jump backwards in the pattern. */ if (mcnt >= 0) { /* Go through the on_failure_jumps of the alternatives, seeing if any of the alternatives cannot match nothing. The last alternative starts with only a jump, whereas the rest start with on_failure_jump and end with a jump, e.g., here is the pattern for `a|b|c': /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6 /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3 /exactn/1/c So, we have to first go through the first (n-1) alternatives and then deal with the last one separately. */ /* Deal with the first (n-1) alternatives, which start with an on_failure_jump (see above) that jumps to right past a jump_past_alt. */ while ((re_opcode_t) p1[mcnt-3] == jump_past_alt) { /* `mcnt' holds how many bytes long the alternative is, including the ending `jump_past_alt' and its number. */ if (!alt_match_null_string_p (p1, p1 + mcnt - 3, reg_info)) return false; /* Move to right after this alternative, including the jump_past_alt. */ p1 += mcnt; /* Break if it's the beginning of an n-th alternative that doesn't begin with an on_failure_jump. */ if ((re_opcode_t) *p1 != on_failure_jump) break; /* Still have to check that it's not an n-th alternative that starts with an on_failure_jump. */ p1++; EXTRACT_NUMBER_AND_INCR (mcnt, p1); if ((re_opcode_t) p1[mcnt-3] != jump_past_alt) { /* Get to the beginning of the n-th alternative. */ p1 -= 3; break; } } /* Deal with the last alternative: go back and get number of the `jump_past_alt' just before it. `mcnt' contains the length of the alternative. */ EXTRACT_NUMBER (mcnt, p1 - 2); if (!alt_match_null_string_p (p1, p1 + mcnt, reg_info)) return false; p1 += mcnt; /* Get past the n-th alternative. */ } /* if mcnt > 0 */ break; case stop_memory: assert (p1[1] == **p); *p = p1 + 2; return true; default: if (!common_op_match_null_string_p (&p1, end, reg_info)) return false; } } /* while p1 < end */ return false; } /* group_match_null_string_p */ /* Similar to group_match_null_string_p, but doesn't deal with alternatives: It expects P to be the first byte of a single alternative and END one byte past the last. The alternative can contain groups. */ static boolean alt_match_null_string_p (p, end, reg_info) unsigned char *p, *end; register_info_type *reg_info; { int mcnt; unsigned char *p1 = p; while (p1 < end) { /* Skip over opcodes that can match nothing, and break when we get to one that can't. */ switch ((re_opcode_t) *p1) { /* It's a loop. */ case on_failure_jump: p1++; EXTRACT_NUMBER_AND_INCR (mcnt, p1); p1 += mcnt; break; default: if (!common_op_match_null_string_p (&p1, end, reg_info)) return false; } } /* while p1 < end */ return true; } /* alt_match_null_string_p */ /* Deals with the ops common to group_match_null_string_p and alt_match_null_string_p. Sets P to one after the op and its arguments, if any. */ static boolean common_op_match_null_string_p (p, end, reg_info) unsigned char **p, *end; register_info_type *reg_info; { int mcnt; boolean ret; int reg_no; unsigned char *p1 = *p; switch ((re_opcode_t) *p1++) { case no_op: case begline: case endline: case begbuf: case endbuf: case wordbeg: case wordend: case wordbound: case notwordbound: #ifdef emacs case before_dot: case at_dot: case after_dot: #endif break; case start_memory: reg_no = *p1; assert (reg_no > 0 && reg_no <= MAX_REGNUM); ret = group_match_null_string_p (&p1, end, reg_info); /* Have to set this here in case we're checking a group which contains a group and a back reference to it. */ if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE) REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret; if (!ret) return false; break; /* If this is an optimized succeed_n for zero times, make the jump. */ case jump: EXTRACT_NUMBER_AND_INCR (mcnt, p1); if (mcnt >= 0) p1 += mcnt; else return false; break; case succeed_n: /* Get to the number of times to succeed. */ p1 += 2; EXTRACT_NUMBER_AND_INCR (mcnt, p1); if (mcnt == 0) { p1 -= 4; EXTRACT_NUMBER_AND_INCR (mcnt, p1); p1 += mcnt; } else return false; break; case duplicate: if (!REG_MATCH_NULL_STRING_P (reg_info[*p1])) return false; break; case set_number_at: p1 += 4; default: /* All other opcodes mean we cannot match the empty string. */ return false; } *p = p1; return true; } /* common_op_match_null_string_p */ /* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN bytes; nonzero otherwise. */ static int bcmp_translate (s1, s2, len, translate) unsigned char *s1, *s2; register int len; char *translate; { register unsigned char *p1 = s1, *p2 = s2; while (len) { if (translate[*p1++] != translate[*p2++]) return 1; len--; } return 0; } /* Entry points for GNU code. */ /* re_compile_pattern is the GNU regular expression compiler: it compiles PATTERN (of length SIZE) and puts the result in BUFP. Returns 0 if the pattern was valid, otherwise an error string. Assumes the `allocated' (and perhaps `buffer') and `translate' fields are set in BUFP on entry. We call regex_compile to do the actual compilation. */ char * re_compile_pattern (char *pattern, int length, struct re_pattern_buffer *bufp) { reg_errcode_t ret; /* GNU code is written to assume at least RE_NREGS registers will be set (and at least one extra will be -1). */ bufp->regs_allocated = REGS_UNALLOCATED; /* And GNU code determines whether or not to get register information by passing null for the REGS argument to re_match, etc., not by setting no_sub. */ bufp->no_sub = 0; /* Match anchors at newline. */ bufp->newline_anchor = 1; ret = regex_compile (pattern, length, re_syntax_options, bufp); return re_error_msg[(int) ret]; } /* Entry points compatible with 4.2 BSD regex library. We don't define them if this is an Emacs or POSIX compilation. */ #if !defined (emacs) && !defined (_POSIX_SOURCE) /* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer re_comp_buf; char * re_comp (s) char *s; { reg_errcode_t ret; if (!s) { if (!re_comp_buf.buffer) return "No previous regular expression"; return 0; } if (!re_comp_buf.buffer) { re_comp_buf.buffer = (unsigned char *) malloc (200); if (re_comp_buf.buffer == NULL) return "Memory exhausted"; re_comp_buf.allocated = 200; re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH); if (re_comp_buf.fastmap == NULL) return "Memory exhausted"; } /* Since `re_exec' always passes NULL for the `regs' argument, we don't need to initialize the pattern buffer fields which affect it. */ /* Match anchors at newlines. */ re_comp_buf.newline_anchor = 1; ret = regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf); /* Yes, we're discarding `const' here. */ return (char *) re_error_msg[(int) ret]; } int re_exec (s) char *s; { int len = strlen (s); return 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0); } #endif /* not emacs and not _POSIX_SOURCE */ /* POSIX.2 functions. Don't define these for Emacs. */ #ifndef emacs /* regcomp takes a regular expression as a string and compiles it. PREG is a regex_t *. We do not expect any fields to be initialized, since POSIX says we shouldn't. Thus, we set `buffer' to the compiled pattern; `used' to the length of the compiled pattern; `syntax' to RE_SYNTAX_POSIX_EXTENDED if the REG_EXTENDED bit in CFLAGS is set; otherwise, to RE_SYNTAX_POSIX_BASIC; `newline_anchor' to REG_NEWLINE being set in CFLAGS; `fastmap' and `fastmap_accurate' to zero; `re_nsub' to the number of subexpressions in PATTERN. PATTERN is the address of the pattern string. CFLAGS is a series of bits which affect compilation. If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we use POSIX basic syntax. If REG_NEWLINE is set, then . and [^...] don't match newline. Also, regexec will try a match beginning after every newline. If REG_ICASE is set, then we considers upper- and lowercase versions of letters to be equivalent when matching. If REG_NOSUB is set, then when PREG is passed to regexec, that routine will report only success or failure, and nothing about the registers. It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for the return codes and their meanings.) */ int regcomp (preg, pattern, cflags) regex_t *preg; char *pattern; int cflags; { reg_errcode_t ret; unsigned syntax = (cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; /* regex_compile will allocate the space for the compiled pattern. */ preg->buffer = 0; preg->allocated = 0; /* Don't bother to use a fastmap when searching. This simplifies the REG_NEWLINE case: if we used a fastmap, we'd have to put all the characters after newlines into the fastmap. This way, we just try every character. */ preg->fastmap = 0; if (cflags & REG_ICASE) { unsigned i; preg->translate = (char *) malloc (CHAR_SET_SIZE); if (preg->translate == NULL) return (int) REG_ESPACE; /* Map uppercase characters to corresponding lowercase ones. */ for (i = 0; i < CHAR_SET_SIZE; i++) preg->translate[i] = ISUPPER (i) ? tolower (i) : i; } else preg->translate = NULL; /* If REG_NEWLINE is set, newlines are treated differently. */ if (cflags & REG_NEWLINE) { /* REG_NEWLINE implies neither . nor [^...] match newline. */ syntax &= ~RE_DOT_NEWLINE; syntax |= RE_HAT_LISTS_NOT_NEWLINE; /* It also changes the matching behavior. */ preg->newline_anchor = 1; } else preg->newline_anchor = 0; preg->no_sub = !!(cflags & REG_NOSUB); /* POSIX says a null character in the pattern terminates it, so we can use strlen here in compiling the pattern. */ ret = regex_compile (pattern, strlen (pattern), syntax, preg); /* POSIX doesn't distinguish between an unmatched open-group and an unmatched close-group: both are REG_EPAREN. */ if (ret == REG_ERPAREN) ret = REG_EPAREN; return (int) ret; } /* regexec searches for a given pattern, specified by PREG, in the string STRING. If NMATCH is zero or REG_NOSUB was set in the cflags argument to `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at least NMATCH elements, and we set them to the offsets of the corresponding matched substrings. EFLAGS specifies `execution flags' which affect matching: if REG_NOTBOL is set, then ^ does not match at the beginning of the string; if REG_NOTEOL is set, then $ does not match at the end. We return 0 if we find a match and REG_NOMATCH if not. */ int regexec (preg, string, nmatch, pmatch, eflags) regex_t *preg; char *string; size_t nmatch; regmatch_t pmatch[]; int eflags; { int ret; struct re_registers regs; regex_t private_preg; int len = strlen (string); boolean want_reg_info = !preg->no_sub && nmatch > 0; private_preg = *preg; private_preg.not_bol = !!(eflags & REG_NOTBOL); private_preg.not_eol = !!(eflags & REG_NOTEOL); /* The user has told us exactly how many registers to return information about, via `nmatch'. We have to pass that on to the matching routines. */ private_preg.regs_allocated = REGS_FIXED; if (want_reg_info) { regs.num_regs = nmatch; regs.start = TALLOC (nmatch, regoff_t); regs.end = TALLOC (nmatch, regoff_t); if (regs.start == NULL || regs.end == NULL) return (int) REG_NOMATCH; } /* Perform the searching operation. */ ret = re_search (&private_preg, string, len, /* start: */ 0, /* range: */ len, want_reg_info ? ®s : (struct re_registers *) 0); /* Copy the register information to the POSIX structure. */ if (want_reg_info) { if (ret >= 0) { unsigned r; for (r = 0; r < nmatch; r++) { pmatch[r].rm_so = regs.start[r]; pmatch[r].rm_eo = regs.end[r]; } } /* If we needed the temporary register info, free the space now. */ free (regs.start); free (regs.end); } /* We want zero return to mean success, unlike `re_search'. */ return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH; } /* Returns a message corresponding to an error code, ERRCODE, returned from either regcomp or regexec. We don't use PREG here. */ size_t regerror (errcode, preg, errbuf, errbuf_size) int errcode; regex_t *preg; char *errbuf; size_t errbuf_size; { char *msg; size_t msg_size; if (errcode < 0 || errcode >= (sizeof (re_error_msg) / sizeof (re_error_msg[0]))) /* Only error codes returned by the rest of the code should be passed to this routine. If we are given anything else, or if other regex code generates an invalid error code, then the program has a bug. Dump core so we can fix it. */ abort (); msg = re_error_msg[errcode]; /* POSIX doesn't require that we do anything in this case, but why not be nice. */ if (! msg) msg = "Success"; msg_size = strlen (msg) + 1; /* Includes the null. */ if (errbuf_size != 0) { if (msg_size > errbuf_size) { strncpy (errbuf, msg, errbuf_size - 1); errbuf[errbuf_size - 1] = 0; } else strcpy (errbuf, msg); } return msg_size; } /* Free dynamically allocated space used by PREG. */ void regfree (preg) regex_t *preg; { if (preg->buffer != NULL) free (preg->buffer); preg->buffer = NULL; preg->allocated = 0; preg->used = 0; if (preg->fastmap != NULL) free (preg->fastmap); preg->fastmap = NULL; preg->fastmap_accurate = 0; if (preg->translate != NULL) free (preg->translate); preg->translate = NULL; } #endif /* not emacs */ /* Local variables: make-backup-files: t version-control: t trim-versions-without-asking: nil End: */ #endif /* not lint */ wise-2.4.1/src/HMMer2/gnuregex.h0000644000175000001440000004426507313404525015705 0ustar philippusers/* Definitions for data structures and routines for the regular expression library, version 0.12. Copyright (C) 1985,1989,1990,1991,1992,1993 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __REGEXP_LIBRARY_H__ #define __REGEXP_LIBRARY_H__ /* POSIX says that must be included (by the caller) before . */ #ifdef VMS /* VMS doesn't have `size_t' in , even though POSIX says it should be there. */ #include #endif /* The following bits are used to determine the regexp syntax we recognize. The set/not-set meanings are chosen so that Emacs syntax remains the value 0. The bits are given in alphabetical order, and the definitions shifted by one from the previous bit; thus, when we add or remove a bit, only one other definition need change. */ typedef unsigned reg_syntax_t; /* If this bit is not set, then \ inside a bracket expression is literal. If set, then such a \ quotes the following character. */ #define RE_BACKSLASH_ESCAPE_IN_LISTS (1) /* If this bit is not set, then + and ? are operators, and \+ and \? are literals. If set, then \+ and \? are operators and + and ? are literals. */ #define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) /* If this bit is set, then character classes are supported. They are: [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. If not set, then character classes are not supported. */ #define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) /* If this bit is set, then ^ and $ are always anchors (outside bracket expressions, of course). If this bit is not set, then it depends: ^ is an anchor if it is at the beginning of a regular expression or after an open-group or an alternation operator; $ is an anchor if it is at the end of a regular expression, or before a close-group or an alternation operator. This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because POSIX draft 11.2 says that * etc. in leading positions is undefined. We already implemented a previous draft which made those constructs invalid, though, so we haven't changed the code back. */ #define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) /* If this bit is set, then special characters are always special regardless of where they are in the pattern. If this bit is not set, then special characters are special only in some contexts; otherwise they are ordinary. Specifically, * + ? and intervals are only special when not after the beginning, open-group, or alternation operator. */ #define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) /* If this bit is set, then *, +, ?, and { cannot be first in an re or immediately after an alternation or begin-group operator. */ #define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) /* If this bit is set, then . matches newline. If not set, then it doesn't. */ #define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) /* If this bit is set, then . doesn't match NUL. If not set, then it does. */ #define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) /* If this bit is set, nonmatching lists [^...] do not match newline. If not set, they do. */ #define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) /* If this bit is set, either \{...\} or {...} defines an interval, depending on RE_NO_BK_BRACES. If not set, \{, \}, {, and } are literals. */ #define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) /* If this bit is set, +, ? and | aren't recognized as operators. If not set, they are. */ #define RE_LIMITED_OPS (RE_INTERVALS << 1) /* If this bit is set, newline is an alternation operator. If not set, newline is literal. */ #define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) /* If this bit is set, then `{...}' defines an interval, and \{ and \} are literals. If not set, then `\{...\}' defines an interval. */ #define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) /* If this bit is set, (...) defines a group, and \( and \) are literals. If not set, \(...\) defines a group, and ( and ) are literals. */ #define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) /* If this bit is set, then \ matches . If not set, then \ is a back-reference. */ #define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) /* If this bit is set, then | is an alternation operator, and \| is literal. If not set, then \| is an alternation operator, and | is literal. */ #define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) /* If this bit is set, then an ending range point collating higher than the starting range point, as in [z-a], is invalid. If not set, then when ending range point collates higher than the starting range point, the range is ignored. */ #define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) /* If this bit is set, then an unmatched ) is ordinary. If not set, then an unmatched ) is invalid. */ #define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) /* This global variable defines the particular regexp syntax to use (for some interfaces). When a regexp is compiled, the syntax used is stored in the pattern buffer, so changing this does not affect already-compiled regexps. */ extern reg_syntax_t re_syntax_options; /* Define combinations of the above bits for the standard possibilities. (The [[[ comments delimit what gets put into the Texinfo file, so don't delete them!) */ /* [[[begin syntaxes]]] */ #define RE_SYNTAX_EMACS 0 #define RE_SYNTAX_AWK \ (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ | RE_NO_BK_PARENS | RE_NO_BK_REFS \ | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ | RE_UNMATCHED_RIGHT_PAREN_ORD) #define RE_SYNTAX_POSIX_AWK \ (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) #define RE_SYNTAX_GREP \ (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ | RE_NEWLINE_ALT) #define RE_SYNTAX_EGREP \ (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ | RE_NO_BK_VBAR) #define RE_SYNTAX_POSIX_EGREP \ (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) /* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ #define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC #define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC /* Syntax bits common to both basic and extended POSIX regex syntax. */ #define _RE_SYNTAX_POSIX_COMMON \ (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ | RE_INTERVALS | RE_NO_EMPTY_RANGES) #define RE_SYNTAX_POSIX_BASIC \ (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) /* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this isn't minimal, since other operators, such as \`, aren't disabled. */ #define RE_SYNTAX_POSIX_MINIMAL_BASIC \ (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) #define RE_SYNTAX_POSIX_EXTENDED \ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ | RE_UNMATCHED_RIGHT_PAREN_ORD) /* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ #define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ | RE_NO_BK_PARENS | RE_NO_BK_REFS \ | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) /* [[[end syntaxes]]] */ /* Maximum number of duplicates an interval can allow. Some systems (erroneously) define this in other header files, but we want our value, so remove any previous define. */ #ifdef RE_DUP_MAX #undef RE_DUP_MAX #endif #define RE_DUP_MAX ((1 << 15) - 1) /* POSIX `cflags' bits (i.e., information for `regcomp'). */ /* If this bit is set, then use extended regular expression syntax. If not set, then use basic regular expression syntax. */ #define REG_EXTENDED 1 /* If this bit is set, then ignore case when matching. If not set, then case is significant. */ #define REG_ICASE (REG_EXTENDED << 1) /* If this bit is set, then anchors do not match at newline characters in the string. If not set, then anchors do match at newlines. */ #define REG_NEWLINE (REG_ICASE << 1) /* If this bit is set, then report only success or fail in regexec. If not set, then returns differ between not matching and errors. */ #define REG_NOSUB (REG_NEWLINE << 1) /* POSIX `eflags' bits (i.e., information for regexec). */ /* If this bit is set, then the beginning-of-line operator doesn't match the beginning of the string (presumably because it's not the beginning of a line). If not set, then the beginning-of-line operator does match the beginning of the string. */ #define REG_NOTBOL 1 /* Like REG_NOTBOL, except for the end-of-line. */ #define REG_NOTEOL (1 << 1) /* If any error codes are removed, changed, or added, update the `re_error_msg' table in regex.c. */ typedef enum { REG_NOERROR = 0, /* Success. */ REG_NOMATCH, /* Didn't find a match (for regexec). */ /* POSIX regcomp return error codes. (In the order listed in the standard.) */ REG_BADPAT, /* Invalid pattern. */ REG_ECOLLATE, /* Not implemented. */ REG_ECTYPE, /* Invalid character class name. */ REG_EESCAPE, /* Trailing backslash. */ REG_ESUBREG, /* Invalid back reference. */ REG_EBRACK, /* Unmatched left bracket. */ REG_EPAREN, /* Parenthesis imbalance. */ REG_EBRACE, /* Unmatched \{. */ REG_BADBR, /* Invalid contents of \{\}. */ REG_ERANGE, /* Invalid range end. */ REG_ESPACE, /* Ran out of memory. */ REG_BADRPT, /* No preceding re for repetition op. */ /* Error codes we've added. */ REG_EEND, /* Premature end. */ REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ } reg_errcode_t; /* This data structure represents a compiled pattern. Before calling the pattern compiler, the fields `buffer', `allocated', `fastmap', `translate', and `no_sub' can be set. After the pattern has been compiled, the `re_nsub' field is available. All other fields are private to the regex routines. */ struct re_pattern_buffer { /* [[[begin pattern_buffer]]] */ /* Space that holds the compiled pattern. It is declared as `unsigned char *' because its elements are sometimes used as array indexes. */ unsigned char *buffer; /* Number of bytes to which `buffer' points. */ unsigned long allocated; /* Number of bytes actually used in `buffer'. */ unsigned long used; /* Syntax setting with which the pattern was compiled. */ reg_syntax_t syntax; /* Pointer to a fastmap, if any, otherwise zero. re_search uses the fastmap, if there is one, to skip over impossible starting points for matches. */ char *fastmap; /* Either a translate table to apply to all characters before comparing them, or zero for no translation. The translation is applied to a pattern when it is compiled and to a string when it is matched. */ char *translate; /* Number of subexpressions found by the compiler. */ size_t re_nsub; /* Zero if this pattern cannot match the empty string, one else. Well, in truth it's used only in `re_search_2', to see whether or not we should use the fastmap, so we don't set this absolutely perfectly; see `re_compile_fastmap' (the `duplicate' case). */ unsigned can_be_null : 1; /* If REGS_UNALLOCATED, allocate space in the `regs' structure for `max (RE_NREGS, re_nsub + 1)' groups. If REGS_REALLOCATE, reallocate space if necessary. If REGS_FIXED, use what's there. */ #define REGS_UNALLOCATED 0 #define REGS_REALLOCATE 1 #define REGS_FIXED 2 unsigned regs_allocated : 2; /* Set to zero when `regex_compile' compiles a pattern; set to one by `re_compile_fastmap' if it updates the fastmap. */ unsigned fastmap_accurate : 1; /* If set, `re_match_2' does not return information about subexpressions. */ unsigned no_sub : 1; /* If set, a beginning-of-line anchor doesn't match at the beginning of the string. */ unsigned not_bol : 1; /* Similarly for an end-of-line anchor. */ unsigned not_eol : 1; /* If true, an anchor at a newline matches. */ unsigned newline_anchor : 1; /* [[[end pattern_buffer]]] */ }; typedef struct re_pattern_buffer regex_t; /* search.c (search_buffer) in Emacs needs this one opcode value. It is defined both in `regex.c' and here. */ #define RE_EXACTN_VALUE 1 /* Type for byte offsets within the string. POSIX mandates this. */ typedef int regoff_t; /* This is the structure we store register match data in. See regex.texinfo for a full description of what registers match. */ struct re_registers { unsigned num_regs; regoff_t *start; regoff_t *end; }; /* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, `re_match_2' returns information about at least this many registers the first time a `regs' structure is passed. */ #ifndef RE_NREGS #define RE_NREGS 30 #endif /* POSIX specification for registers. Aside from the different names than `re_registers', POSIX uses an array of structures, instead of a structure of arrays. */ typedef struct { regoff_t rm_so; /* Byte offset from string's start to substring's start. */ regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ } regmatch_t; /* Declarations for routines. */ /* To avoid duplicating every routine declaration -- once with a prototype (if we are ANSI), and once without (if we aren't) -- we use the following macro to declare argument types. This unfortunately clutters up the declarations a bit, but I think it's worth it. */ #if __STDC__ #define _RE_ARGS(args) args #else /* not __STDC__ */ #define _RE_ARGS(args) () #endif /* not __STDC__ */ /* Sets the current default syntax to SYNTAX, and return the old syntax. You can also simply assign to the `re_syntax_options' variable. */ extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); /* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ extern char *re_compile_pattern _RE_ARGS ((char *pattern, int length, struct re_pattern_buffer *buffer)); /* Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error. */ extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); /* Search in the string STRING (with length LENGTH) for the pattern compiled into BUFFER. Start searching at position START, for RANGE characters. Return the starting position of the match, -1 for no match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero). */ extern int re_search _RE_ARGS ((struct re_pattern_buffer *buffer, char *string, int length, int start, int range, struct re_registers *regs)); /* Like `re_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ extern int re_search_2 _RE_ARGS ((struct re_pattern_buffer *buffer, char *string1, int length1, char *string2, int length2, int start, int range, struct re_registers *regs, int stop)); /* Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ extern int re_match _RE_ARGS ((struct re_pattern_buffer *buffer, char *string, int length, int start, struct re_registers *regs)); /* Relates to `re_match' as `re_search_2' relates to `re_search'. */ extern int re_match_2 _RE_ARGS ((struct re_pattern_buffer *buffer, char *string1, int length1, char *string2, int length2, int start, struct re_registers *regs, int stop)); /* Set REGS to hold NUM_REGS registers, storing them in STARTS and ENDS. Subsequent matches using BUFFER and REGS will use this memory for recording register information. STARTS and ENDS must be allocated with malloc, and must each be at least `NUM_REGS * sizeof (regoff_t)' bytes long. If NUM_REGS == 0, then subsequent matches should allocate their own register data. Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ extern void re_set_registers _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, unsigned num_regs, regoff_t *starts, regoff_t *ends)); /* 4.2 bsd compatibility. */ extern char *re_comp _RE_ARGS ((char *)); extern int re_exec _RE_ARGS ((char *)); /* POSIX compatibility. */ extern int regcomp _RE_ARGS ((regex_t *preg, char *pattern, int cflags)); extern int regexec _RE_ARGS ((regex_t *preg, char *string, size_t nmatch, regmatch_t pmatch[], int eflags)); extern size_t regerror _RE_ARGS ((int errcode, regex_t *preg, char *errbuf, size_t errbuf_size)); extern void regfree _RE_ARGS ((regex_t *preg)); #endif /* not __REGEXP_LIBRARY_H__ */ /* Local variables: make-backup-files: t version-control: t trim-versions-without-asking: nil End: */ wise-2.4.1/src/HMMer2/hmmpfam.c0000644000175000001440000004175007313404525015475 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Washington University School of Medicine * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* hmmpfam.c * SRE, Mon Aug 25 17:03:14 1997: Denver * * Search a single sequence against an HMM database. * RCS $Id: hmmpfam.c,v 1.1.1.1 2001/06/18 13:59:49 birney Exp $ */ #include #include #include #include #include #include "structs.h" /* data structures, macros, #define's */ #include "config.h" /* compile-time configuration constants */ #include "funcs.h" /* function declarations */ #include "globals.h" /* alphabet global variables */ #include "squid.h" /* general sequence analysis library */ #ifdef MEMDEBUG #include "dbmalloc.h" #endif static void record_domains(struct tophit_s *h, struct plan7_s *hmm, char *dsq, SQINFO *sqinfo, struct p7trace_s *tr, double whole_pval, float whole_sc, int do_null2); static char banner[] = "hmmpfam - search a single seq against HMM database"; static char usage[] = "\ Usage: hmmpfam [-options] \n\ Available options are:\n\ -h : help; print brief help on version and usage\n\ -n : nucleic acid models/sequence (default protein)\n\ -A : sets alignment output limit to best domain alignments\n\ -E : sets E value cutoff (globE) to \n\ -T : sets T bit threshold (globT) to \n\ -Z : sets Z (# seqs) for E-value calculation\n\ "; static char experts[] = "\ --domE : sets domain Eval cutoff (2nd threshold) to \n\ --domT : sets domain T bit thresh (2nd threshold) to \n\ --forward : use the full Forward() algorithm instead of Viterbi\n\ --null2 : turn OFF the post hoc second null model\n\ --xnu : turn ON XNU filtering of query sequence\n\ \n"; static struct opt_s OPTIONS[] = { { "-h", TRUE, sqdARG_NONE }, { "-n", TRUE, sqdARG_NONE }, { "-A", TRUE, sqdARG_INT }, { "-E", TRUE, sqdARG_FLOAT}, { "-T", TRUE, sqdARG_FLOAT}, { "-Z", TRUE, sqdARG_INT }, { "--domE", FALSE, sqdARG_FLOAT}, { "--domT", FALSE, sqdARG_FLOAT}, { "--forward", FALSE, sqdARG_NONE }, { "--null2", FALSE, sqdARG_NONE }, { "--xnu", FALSE, sqdARG_NONE }, }; #define NOPTIONS (sizeof(OPTIONS) / sizeof(struct opt_s)) int main(int argc, char **argv) { char *hmmfile; /* file to read HMMs from */ HMMFILE *hmmfp; /* opened hmmfile for reading */ char *seqfile; /* file to read target sequence from */ SQFILE *sqfp; /* opened seqfile for reading */ int format; /* format of seqfile */ char *seq; /* target sequence */ SQINFO sqinfo; /* optional info for seq */ char *dsq; /* digitized target sequence */ struct plan7_s *hmm; /* current HMM to search with */ struct p7trace_s *tr; /* traceback of alignment */ struct fancyali_s *ali; /* an alignment for display */ struct tophit_s *ghit; /* list of top hits and alignments for seq */ struct tophit_s *dhit; /* list of top hits/alignments for domains */ float sc; /* log-odds score in bits */ double pvalue; /* pvalue of an HMM score */ double evalue; /* evalue of an HMM score */ double motherp; /* pvalue of a whole seq HMM score */ float mothersc; /* score of a whole seq parent of domain */ int sqfrom, sqto; /* coordinates in sequence */ int hmmfrom, hmmto; /* coordinate in HMM */ char *name, *desc; /* hit HMM name and description */ int hmmlen; /* length of HMM hit */ int nhmm; /* number of HMMs searched */ int domidx; /* number of this domain */ int ndom; /* total # of domains in this seq */ int namewidth; /* max width of sequence name */ int Alimit; /* A parameter limiting output alignments */ float globT; /* T parameter: keep only hits > globT bits */ double globE; /* E parameter: keep hits < globE E-value */ float domT; /* T parameter for individual domains */ double domE; /* E parameter for individual domains */ char *optname; /* name of option found by Getopt() */ char *optarg; /* argument found by Getopt() */ int optind; /* index in argv[] */ int do_forward; /* TRUE to use Forward() not Viterbi() */ int do_nucleic; /* TRUE to do DNA/RNA instead of protein */ int do_null2; /* TRUE to adjust scores with null model #2 */ int do_xnu; /* TRUE to do XNU filtering */ int Z; /* nseq to base E value calculation on */ int i; #ifdef MEMDEBUG unsigned long histid1, histid2, orig_size, current_size; orig_size = malloc_inuse(&histid1); fprintf(stderr, "[... memory debugging is ON ...]\n"); #endif /*********************************************** * Parse command line ***********************************************/ do_forward = FALSE; do_nucleic = FALSE; do_null2 = TRUE; do_xnu = FALSE; Z = 59021; /* default: nseq in Swissprot34 */ Alimit = INT_MAX; /* no limit on alignment output */ globE = 10.0; /* use a reasonable Eval threshold; */ globT = -FLT_MAX; /* but no bit threshold, */ domT = -FLT_MAX; /* no domain bit threshold, */ domE = FLT_MAX; /* and no domain Eval threshold. */ while (Getopt(argc, argv, OPTIONS, NOPTIONS, usage, &optind, &optname, &optarg)) { if (strcmp(optname, "-n") == 0) do_nucleic = TRUE; else if (strcmp(optname, "-A") == 0) Alimit = atoi(optarg); else if (strcmp(optname, "-E") == 0) globE = atof(optarg); else if (strcmp(optname, "-T") == 0) globT = atof(optarg); else if (strcmp(optname, "-Z") == 0) Z = atoi(optarg); else if (strcmp(optname, "--domE") == 0) domE = atof(optarg); else if (strcmp(optname, "--domT") == 0) domT = atof(optarg); else if (strcmp(optname, "--forward") == 0) do_forward = TRUE; else if (strcmp(optname, "--null2") == 0) do_null2 = FALSE; else if (strcmp(optname, "--xnu") == 0) do_xnu = TRUE; else if (strcmp(optname, "-h") == 0) { Banner(stdout, banner); puts(usage); puts(experts); exit(0); } } if (argc - optind != 2) Die("Incorrect number of arguments.\n%s\n", usage); hmmfile = argv[optind++]; seqfile = argv[optind++]; /*********************************************** * Open sequence database (must be in curr directory); * get target sequence. ***********************************************/ if (do_nucleic) SetAlphabet(hmmNUCLEIC); else SetAlphabet(hmmAMINO); if (! SeqfileFormat(seqfile, &format, NULL)) switch (squid_errno) { case SQERR_NOFILE: Die("Sequence file %s could not be opened for reading", seqfile); break; case SQERR_FORMAT: default: Die("Failed to determine format of sequence file %s", seqfile); } if ((sqfp = SeqfileOpen(seqfile, format, NULL)) == NULL) Die("Failed to open sequence file %s\n%s\n", seqfile, usage); /*********************************************** * Open HMM database (might be in HMMERDB or current directory) ***********************************************/ if ((hmmfp = HMMFileOpen(hmmfile, "HMMERDB")) == NULL) Die("Failed to open HMM database %s\n%s", hmmfile, usage); /*********************************************** * Show the banner ***********************************************/ Banner(stdout, banner); printf( "HMM file: %s\n", hmmfile); printf( "Sequence file: %s\n", seqfile); printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"); /*********************************************** * Search each HMM against each sequence ***********************************************/ while (ReadSeq(sqfp, format, &seq, &sqinfo)) { ghit = AllocTophits(20); /* keeps full seq scores */ dhit = AllocTophits(20); /* keeps domain scores */ /* 1. Search sequence against every HMM. */ dsq = DigitizeSequence(seq, sqinfo.len); if (do_xnu) XNU(dsq, sqinfo.len); nhmm = 0; while (HMMFileRead(hmmfp, &hmm)) { if (hmm == NULL) Die("HMM file %s may be corrupt or in incorrect format; parse failed", hmmfile); P7Logoddsify(hmm, TRUE); /* 1a. Score sequence, do alignment (Viterbi), recover trace */ if (P7ViterbiSize(sqinfo.len, hmm->M) <= RAMLIMIT) sc = P7Viterbi(dsq, sqinfo.len, hmm, &tr); else sc = P7SmallViterbi(dsq, sqinfo.len, hmm, &tr); if (do_forward) sc = P7Forward(dsq, sqinfo.len, hmm, NULL); if (do_null2) sc -= TraceScoreCorrection(hmm, tr, dsq); /* 1b. Store scores/pvalue for each HMM aligned to this sequence, overall */ pvalue = PValue(hmm, sc); if (sc > globT && pvalue * (float) Z < globE) { RegisterHit(ghit, sc, pvalue, sc, 0., 0., /* no mother seq */ hmm->name, hmm->desc, 0,0,0, /* seq positions */ 0,0,0, /* HMM positions */ 0, TraceDomainNumber(tr), /* domain info */ NULL); /* alignment info */ /* 1c. Store scores/evalue/position/alignment for each HMM * aligned to domains of this sequence; UNFINISHED */ record_domains(dhit, hmm, dsq, &sqinfo, tr, pvalue, sc, do_null2); } P7FreeTrace(tr); FreePlan7(hmm); nhmm++; } /* 2. (Done searching all HMMs for this query seq; start output) * Report the overall sequence hits, sorted by significance. */ printf("Query: %s %s\n", sqinfo.name, sqinfo.flags & SQINFO_DESC ? sqinfo.desc : ""); FullSortTophits(ghit); namewidth = MAX(8, TophitsMaxName(ghit)); printf("\nScores for sequence family classification (score includes all domains):\n"); printf("%-*s %-*s %7s %10s %3s\n", namewidth, "Sequence", 52-namewidth, "Description", "Score", "E-value", " N "); printf("%-*s %-*s %7s %10s %3s\n", namewidth, "--------", 52-namewidth, "-----------", "-----", "-------", "---"); for (i = 0; i < ghit->num; i++) { GetRankedHit(ghit, i, &pvalue, &sc, NULL, NULL, &name, &desc, NULL, NULL, NULL, /* seq positions */ NULL, NULL, NULL, /* HMM positions */ NULL, &ndom, /* domain info */ NULL); /* alignment info*/ evalue = pvalue * (double) Z; if (evalue < globE && sc >= globT) printf("%-*s %-*.*s %7.1f %10.2g %3d\n", namewidth, name, 52-namewidth, 52-namewidth, desc != NULL ? desc : "", sc, evalue, ndom); else if (evalue >= globE) { if (i > 0) printf("\t[no more scores below E threshold]\n"); break; } else if (sc <= globT) { if (i > 0) printf("\t[no more scores above T threshold]"); break; } } if (i == 0) printf("\t[no hits above thresholds]\n"); /* 3. Report domain hits (sorted on sqto coordinate) */ FullSortTophits(dhit); namewidth = MAX(8, TophitsMaxName(dhit)); printf("\nParsed for domains:\n"); printf("%-*s %7s %5s %5s %5s %5s %7s %8s\n", namewidth, "Sequence", "Domain ", "seq-f", "seq-t", "hmm-f", "hmm-t", "score", "E-value"); printf("%-*s %7s %5s %5s %5s %5s %7s %8s\n", namewidth, "--------", "-------", "-----", "-----", "-----", "-----", "-----", "-------"); for (i = 0; i < dhit->num; i++) { GetRankedHit(dhit, i, &pvalue, &sc, &motherp, &mothersc, &name, NULL, &sqfrom, &sqto, NULL, &hmmfrom, &hmmto, &hmmlen, &domidx, &ndom, NULL); evalue = pvalue * (double) Z; if (motherp * (double) Z >= globE || mothersc <= globT) continue; else if (evalue < domE && sc > domT) printf("%-*s %3d/%-3d %5d %5d %c%c %5d %5d %c%c %7.1f %8.2g\n", namewidth, name, domidx, ndom, sqfrom, sqto, sqfrom == 1 ? '[' : '.', sqto == sqinfo.len ? ']' : '.', hmmfrom, hmmto, hmmfrom == 1 ? '[':'.', hmmto == hmmlen ? ']' : '.', sc, evalue); else if (evalue >= domE) { if (i > 0) printf("\t[no more scores below domE threshold]\n"); break; } else if (sc <= domT) { if (i > 0) printf("\t[no more scores above domT threshold]\n"); break; } } if (i == 0) printf("\t[no hits above thresholds]\n"); /* 3. Alignment output, also by domain. * dhits is already sorted and namewidth is set, from above code. * Number of displayed alignments is limited by Alimit parameter; * also by domE (evalue threshold), domT (score theshold). */ if (Alimit != 0) { printf("\nAlignments of top-scoring domains:\n"); for (i = 0; i < dhit->num; i++) { if (i == Alimit) break; /* limit to Alimit output alignments */ GetRankedHit(dhit, i, &pvalue, &sc, &motherp, &mothersc, &name, NULL, &sqfrom, &sqto, NULL, /* seq position info */ &hmmfrom, &hmmto, &hmmlen, /* HMM position info */ &domidx, &ndom, /* domain info */ &ali); /* alignment info */ evalue = pvalue * (double) Z; if (motherp * (double) Z >= globE || mothersc <= globT) continue; else if (evalue < domE && sc > domT) { printf("%s: domain %d of %d, from %d to %d: score %.1f, E = %.2g\n", name, domidx, ndom, sqfrom, sqto, sc, evalue); PrintFancyAli(stdout, ali); } else if (evalue >= domE) { if (i > 0) printf("\t[no more alignments below E threshold]\n"); break; } else if (sc <= domT) { if (i > 0) printf("\t[no more alignments above T threshold]\n"); break; } } if (i == 0) printf("\t[no hits above thresholds]\n"); if (i == Alimit) printf("\t[output cut off at A = %d top alignments]\n", Alimit); } printf("//\n"); FreeSequence(seq, &sqinfo); FreeTophits(ghit); FreeTophits(dhit); free(dsq); HMMFileRewind(hmmfp); } /*********************************************** * Clean-up and exit. ***********************************************/ SeqfileClose(sqfp); HMMFileClose(hmmfp); SqdClean(); #ifdef MEMDEBUG current_size = malloc_inuse(&histid2); if (current_size != orig_size) malloc_list(2, histid1, histid2); else fprintf(stderr, "[No memory leaks.]\n"); #endif return 0; } /* Function: record_domains() * Date: SRE, Tue Oct 28 14:20:56 1997 [Cambridge UK] * * Purpose: Decompose a trace, and register scores, P-values, alignments, * etc. for individual domains in a hitlist. Almost a duplicate * of the eponymous function in hmmsearch, but we sort by * start position of the domain. * * Return: (void) */ static void record_domains(struct tophit_s *h, struct plan7_s *hmm, char *dsq, SQINFO *sqinfo, struct p7trace_s *tr, double whole_pval, float whole_sc, int do_null2) { struct p7trace_s **tarr; /* array of per-domain traces */ struct fancyali_s *ali; /* alignment of a domain */ int ntr; /* number of domain traces */ int idx; /* index for traces */ int k1, k2; /* start, stop coord in model */ int i1, i2; /* start, stop in sequence */ float score; double pvalue; TraceDecompose(tr, &tarr, &ntr); if (ntr == 0) Die("TraceDecompose() screwup"); /* "can't happen" (!) */ for (idx = 0; idx < ntr; idx++) { /* Get the score and bounds of the match. */ score = P7TraceScore(hmm, dsq, tarr[idx]); if (do_null2) score -= TraceScoreCorrection(hmm, tarr[idx], dsq); pvalue = PValue(hmm, score); TraceSimpleBounds(tarr[idx], &i1, &i2, &k1, &k2); /* Record the match */ ali = CreateFancyAli(tarr[idx], hmm, dsq, sqinfo->name); RegisterHit(h, -1.*(double)i2, /* sortkey= -(start) (so 1 comes first) */ pvalue, score, whole_pval, whole_sc, hmm->name, hmm->desc, i1,i2, sqinfo->len, k1,k2, hmm->M, idx+1,ntr, ali); } for (idx = 0; idx < ntr; idx++) P7FreeTrace(tarr[idx]); free(tarr); return; } wise-2.4.1/src/HMMer2/plan7.c0000644000175000001440000010245107313404526015066 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1997 Sean R. Eddy * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* plan7.c * SRE, Sat Nov 16 14:19:56 1996 * * Support for Plan 7 HMM data structure, plan7_s. */ #include #include #include #include #include "funcs.h" #include "config.h" #include "structs.h" #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif /* Functions: AllocPlan7(), AllocPlan7Shell(), AllocPlan7Body(), FreePlan7() * * Purpose: Allocate or free a Plan7 HMM structure. * Can either allocate all at one (AllocPlan7()) or * in two steps (AllocPlan7Shell(), AllocPlan7Body()). * The two step method is used in hmmio.c where we start * parsing the header of an HMM file but don't * see the size of the model 'til partway thru the header. */ struct plan7_s * AllocPlan7(int M) { struct plan7_s *hmm; int k, x; hmm = (struct plan7_s *) MallocOrDie (sizeof(struct plan7_s)); hmm->M = M; hmm->name = NULL; hmm->desc = NULL; hmm->rf = (char *) MallocOrDie ((M+2) * sizeof(char)); hmm->cs = (char *) MallocOrDie ((M+2) * sizeof(char)); hmm->comlog= NULL; hmm->nseq = 0; hmm->ctime = NULL; hmm->t = (float **) MallocOrDie (M * sizeof(float *)); hmm->tsc = (int **) MallocOrDie (M * sizeof(int *)); hmm->mat = (float **) MallocOrDie ((M+1) * sizeof(float *)); hmm->ins = (float **) MallocOrDie (M * sizeof(float *)); hmm->msc = (int **) MallocOrDie (MAXCODE * sizeof(int *)); hmm->isc = (int **) MallocOrDie (MAXCODE * sizeof(int *)); hmm->t[0] = (float *) MallocOrDie ((7*M) * sizeof(float)); hmm->tsc[0] = (int *) MallocOrDie ((7*M) * sizeof(int)); hmm->mat[0] = (float *) MallocOrDie ((MAXABET*(M+1)) * sizeof(float)); hmm->ins[0] = (float *) MallocOrDie ((MAXABET*M) * sizeof(float)); hmm->msc[0] = (int *) MallocOrDie ((MAXCODE*(M+1)) * sizeof(int)); hmm->isc[0] = (int *) MallocOrDie ((MAXCODE*M) * sizeof(int)); /* note allocation strategy for important 2D arrays -- trying * to keep locality as much as possible, cache efficiency etc. */ for (k = 1; k <= M; k++) { hmm->mat[k] = hmm->mat[0] + k * MAXABET; if (k < M) { hmm->ins[k] = hmm->ins[0] + k * MAXABET; hmm->t[k] = hmm->t[0] + k * 7; hmm->tsc[k] = hmm->tsc[0] + k * 7; } } for (x = 1; x < MAXCODE; x++) { hmm->msc[x] = hmm->msc[0] + x * (M+1); hmm->isc[x] = hmm->isc[0] + x * M; } /* tsc[0] is used as a boundary condition sometimes [Viterbi()], * so set to -inf always. */ for (x = 0; x < 7; x++) hmm->tsc[0][x] = -INFTY; hmm->begin = (float *) MallocOrDie ((M+1) * sizeof(float)); hmm->bsc = (int *) MallocOrDie ((M+1) * sizeof(int)); hmm->end = (float *) MallocOrDie ((M+1) * sizeof(float)); hmm->esc = (int *) MallocOrDie ((M+1) * sizeof(int)); /* DNA translation is not enabled by default */ hmm->dnam = NULL; hmm->dnai = NULL; hmm->dna2 = -INFTY; hmm->dna4 = -INFTY; /* statistical parameters set to innocuous empty values */ hmm->mu = 0.; hmm->lambda = 0.; hmm->flags = 0; return hmm; } struct plan7_s * AllocPlan7Shell(void) { struct plan7_s *hmm; hmm = (struct plan7_s *) MallocOrDie (sizeof(struct plan7_s)); hmm->M = 0; hmm->name = NULL; hmm->desc = NULL; hmm->rf = NULL; hmm->cs = NULL; hmm->comlog = NULL; hmm->nseq = 0; hmm->ctime = NULL; hmm->t = NULL; hmm->tsc = NULL; hmm->mat = NULL; hmm->ins = NULL; hmm->msc = NULL; hmm->isc = NULL; hmm->begin = NULL; hmm->bsc = NULL; hmm->end = NULL; hmm->esc = NULL; /* DNA translation is not enabled by default */ hmm->dnam = NULL; hmm->dnai = NULL; hmm->dna2 = -INFTY; hmm->dna4 = -INFTY; /* statistical parameters set to innocuous empty values */ hmm->mu = 0.; hmm->lambda = 0.; hmm->flags = 0; return hmm; } void AllocPlan7Body(struct plan7_s *hmm, int M) { int k, x; hmm->M = M; hmm->rf = (char *) MallocOrDie ((M+2) * sizeof(char)); hmm->cs = (char *) MallocOrDie ((M+2) * sizeof(char)); hmm->t = (float **) MallocOrDie (M * sizeof(float *)); hmm->tsc = (int **) MallocOrDie (M * sizeof(int *)); hmm->mat = (float **) MallocOrDie ((M+1) * sizeof(float *)); hmm->ins = (float **) MallocOrDie (M * sizeof(float *)); hmm->msc = (int **) MallocOrDie (MAXCODE * sizeof(int *)); hmm->isc = (int **) MallocOrDie (MAXCODE * sizeof(int *)); hmm->t[0] = (float *) MallocOrDie ((7*M) * sizeof(float)); hmm->tsc[0] = (int *) MallocOrDie ((7*M) * sizeof(int)); hmm->mat[0] = (float *) MallocOrDie ((MAXABET*(M+1)) * sizeof(float)); hmm->ins[0] = (float *) MallocOrDie ((MAXABET*M) * sizeof(float)); hmm->msc[0] = (int *) MallocOrDie ((MAXCODE*(M+1)) * sizeof(int)); hmm->isc[0] = (int *) MallocOrDie ((MAXCODE*M) * sizeof(int)); /* note allocation strategy for important 2D arrays -- trying * to keep locality as much as possible, cache efficiency etc. */ for (k = 1; k <= M; k++) { hmm->mat[k] = hmm->mat[0] + k * MAXABET; if (k < M) { hmm->ins[k] = hmm->ins[0] + k * MAXABET; hmm->t[k] = hmm->t[0] + k * 7; hmm->tsc[k] = hmm->tsc[0] + k * 7; } } for (x = 1; x < MAXCODE; x++) { hmm->msc[x] = hmm->msc[0] + x * (M+1); hmm->isc[x] = hmm->isc[0] + x * M; } /* tsc[0] is used as a boundary condition sometimes [Viterbi()], * so set to -inf always. */ for (x = 0; x < 7; x++) hmm->tsc[0][x] = -INFTY; hmm->begin = (float *) MallocOrDie ((M+1) * sizeof(float)); hmm->bsc = (int *) MallocOrDie ((M+1) * sizeof(int)); hmm->end = (float *) MallocOrDie ((M+1) * sizeof(float)); hmm->esc = (int *) MallocOrDie ((M+1) * sizeof(int)); return; } void FreePlan7(struct plan7_s *hmm) { if (hmm->name != NULL) free(hmm->name); if (hmm->desc != NULL) free(hmm->desc); if (hmm->rf != NULL) free(hmm->rf); if (hmm->cs != NULL) free(hmm->cs); if (hmm->comlog != NULL) free(hmm->comlog); if (hmm->ctime != NULL) free(hmm->ctime); if (hmm->bsc != NULL) free(hmm->bsc); if (hmm->begin != NULL) free(hmm->begin); if (hmm->esc != NULL) free(hmm->esc); if (hmm->end != NULL) free(hmm->end); if (hmm->msc != NULL) free(hmm->msc[0]); if (hmm->mat != NULL) free(hmm->mat[0]); if (hmm->isc != NULL) free(hmm->isc[0]); if (hmm->ins != NULL) free(hmm->ins[0]); if (hmm->tsc != NULL) free(hmm->tsc[0]); if (hmm->t != NULL) free(hmm->t[0]); if (hmm->msc != NULL) free(hmm->msc); if (hmm->mat != NULL) free(hmm->mat); if (hmm->isc != NULL) free(hmm->isc); if (hmm->ins != NULL) free(hmm->ins); if (hmm->tsc != NULL) free(hmm->tsc); if (hmm->t != NULL) free(hmm->t); if (hmm->dnam != NULL) free(hmm->dnam); if (hmm->dnai != NULL) free(hmm->dnai); free(hmm); } /* Function: ZeroPlan7() * * Purpose: Zeros the counts/probabilities fields in a model. * Leaves null model untouched. */ void ZeroPlan7(struct plan7_s *hmm) { int k; for (k = 1; k < hmm->M; k++) { FSet(hmm->t[k], 7, 0.); FSet(hmm->mat[k], Alphabet_size, 0.); FSet(hmm->ins[k], Alphabet_size, 0.); } FSet(hmm->mat[hmm->M], Alphabet_size, 0.); hmm->tbd1 = 0.; FSet(hmm->begin+1, hmm->M, 0.); FSet(hmm->end+1, hmm->M, 0.); for (k = 0; k < 4; k++) FSet(hmm->xt[k], 2, 0.); hmm->flags &= ~PLAN7_HASBITS; /* invalidates scores */ hmm->flags &= ~PLAN7_HASPROB; /* invalidates probabilities */ } /* Function: Plan7SetName() * * Purpose: Change the name of a Plan7 HMM. Convenience function. * * Note: Trailing whitespace and \n's are chopped. */ void Plan7SetName(struct plan7_s *hmm, char *name) { if (hmm->name != NULL) free(hmm->name); hmm->name = Strdup(name); StringChop(hmm->name); } /* Function: Plan7SetDescription() * * Purpose: Change the description line of a Plan7 HMM. Convenience function. * * Note: Trailing whitespace and \n's are chopped. */ void Plan7SetDescription(struct plan7_s *hmm, char *desc) { if (hmm->desc != NULL) free(hmm->desc); hmm->desc = Strdup(desc); StringChop(hmm->desc); } /* Function: Plan7ComlogAppend() * Date: SRE, Wed Oct 29 09:57:30 1997 [TWA 721 over Greenland] * * Purpose: Concatenate command line options and append to the * command line log. */ void Plan7ComlogAppend(struct plan7_s *hmm, int argc, char **argv) { int len; int i; /* figure out length of command line, w/ spaces and \n */ len = argc; for (i = 0; i < argc; i++) len += strlen(argv[i]); /* allocate */ if (hmm->comlog != NULL) { len += strlen(hmm->comlog); hmm->comlog = ReallocOrDie(hmm->comlog, sizeof(char)* (len+1)); } else { hmm->comlog = MallocOrDie(sizeof(char)* (len+1)); *(hmm->comlog) = '\0'; /* need this to make strcat work */ } /* append */ strcat(hmm->comlog, "\n"); for (i = 0; i < argc; i++) { strcat(hmm->comlog, argv[i]); if (i < argc-1) strcat(hmm->comlog, " "); } } /* Function: Plan7SetCtime() * Date: SRE, Wed Oct 29 11:53:19 1997 [TWA 721 over the Atlantic] * * Purpose: Set the ctime field in a new HMM to the current time. */ void Plan7SetCtime(struct plan7_s *hmm) { time_t date = time(NULL); if (hmm->ctime != NULL) free(hmm->ctime); hmm->ctime = Strdup(ctime(&date)); StringChop(hmm->ctime); } /* Function: Plan7SetNullModel() * * Purpose: Set the null model section of an HMM. * Convenience function. */ void Plan7SetNullModel(struct plan7_s *hmm, float null[MAXABET], float p1) { int x; for (x = 0; x < Alphabet_size; x++) hmm->null[x] = null[x]; hmm->p1 = p1; } /* Function: P7Logoddsify() * * Purpose: Take an HMM with valid probabilities, and * fill in the integer log-odds score section of the model. * * Notes on log-odds scores: * type of parameter probability score * ----------------- ----------- ------ * any emission p_x log_2 p_x/null_x * N,J,C /assume/ p_x = null_x so /always/ score zero. * transition to emitters t_x log_2 t_x/p1 * (M,I; N,C; J) * NN and CC loops are often equal to p1, so usu. score zero. * C->T transition t_x log_2 t_x/p2 * often zero, usu. C->T = p2. * all other transitions t_x log_2 t_x * (no null model counterpart, so null prob is 1) * * Notes on entry/exit scores, B->M and M->E: * The probability form model includes delete states 1 and M. * these states are removed from a search form model to * prevent B->D...D->E->J->B mute cycles, which would complicate * dynamic programming algorithms. The data-independent * S/W B->M and M->E transitions are folded together with * data-dependent B->D...D->M and M->D...D->E paths. * * This process is referred to in the code as "wing folding" * or "wing retraction"... the analogy is to a swept-wing * fighter in landing vs. high speed flight configuration. * * Note on Viterbi vs. forward flag: * Wing retraction must take forward vs. Viterbi * into account. If forward, sum two paths; if Viterbi, take * max. I tried to slide this by as a sum, without * the flag, but Alex detected it as a bug, because you can * then find cases where the Viterbi score doesn't match * the P7TraceScore(). * * Args: hmm - the hmm to calculate scores in. * viterbi_mode - TRUE to fold wings in Viterbi configuration. * * Return: (void) * hmm scores are filled in. */ void P7Logoddsify(struct plan7_s *hmm, int viterbi_mode) { int k; /* counter for model position */ int x; /* counter for symbols */ float accum; float tbm, tme; if (hmm->flags & PLAN7_HASBITS) return; /* Symbol emission scores */ for (k = 1; k <= hmm->M; k++) { /* match/insert emissions in main model */ for (x = 0; x < Alphabet_size; x++) { hmm->msc[x][k] = Prob2Score(hmm->mat[k][x], hmm->null[x]); if (k < hmm->M) hmm->isc[x][k] = Prob2Score(hmm->ins[k][x], hmm->null[x]); } /* degenerate match/insert emissions */ for (x = Alphabet_size; x < Alphabet_iupac; x++) { hmm->msc[x][k] = DegenerateSymbolScore(hmm->mat[k], hmm->null, x); if (k < hmm->M) hmm->isc[x][k] = DegenerateSymbolScore(hmm->ins[k], hmm->null, x); } } /* State transitions. * * A note on "folding" of D_1 and D_M. * These two delete states are folded out of search form models * in order to prevent null cycles in the dynamic programming * algorithms (see code below). However, we use their log transitions * when we save the model! So the following log transition probs * are used *only* in save files, *never* in search algorithms: * log (tbd1), D1 -> M1, D1 -> D2 * Mm-1 -> Dm, Dm-1 -> Dm * * In a search algorithm, these have to be interpreted as -INFTY * because their contributions are folded into bsc[] and esc[] * entry/exit scores. They can't be set to -INFTY here because * we need them in save files. */ for (k = 1; k < hmm->M; k++) { hmm->tsc[k][TMM] = Prob2Score(hmm->t[k][TMM], hmm->p1); hmm->tsc[k][TMI] = Prob2Score(hmm->t[k][TMI], hmm->p1); hmm->tsc[k][TMD] = Prob2Score(hmm->t[k][TMD], 1.0); hmm->tsc[k][TIM] = Prob2Score(hmm->t[k][TIM], hmm->p1); hmm->tsc[k][TII] = Prob2Score(hmm->t[k][TII], hmm->p1); hmm->tsc[k][TDM] = Prob2Score(hmm->t[k][TDM], hmm->p1); hmm->tsc[k][TDD] = Prob2Score(hmm->t[k][TDD], 1.0); } /* B->M entry transitions. Note how D_1 is folded out. * M1 is just B->M1 * M2 is sum (or max) of B->M2 and B->D1->M2 * M_k is sum (or max) of B->M_k and B->D1...D_k-1->M_k */ accum = hmm->tbd1; for (k = 1; k <= hmm->M; k++) { tbm = hmm->begin[k]; /* B->M_k part */ if (k > 1) { /* B->D1...D_k-1->M_k part we get from accum*/ if (viterbi_mode) tbm = MAX(tbm, accum * hmm->t[k-1][TDM]); else tbm += accum * hmm->t[k-1][TDM]; accum *= hmm->t[k-1][TDD]; } hmm->bsc[k] = Prob2Score(tbm, hmm->p1); /* entries are to emitters */ } /* M->E exit transitions. Note how D_M is folded out. * M_M is 1 by definition * M_M-1 is sum of M_M-1->E and M_M-1->D_M->E, where D_M->E is 1 by definition * M_k is sum of M_k->E and M_k->D_k+1...D_M->E */ hmm->esc[hmm->M] = 0; accum = 1.; for (k = hmm->M-1; k >= 1; k--) { if (viterbi_mode) tme = MAX(hmm->end[k], accum * hmm->t[k][TMD]); else tme = hmm->end[k] + accum * hmm->t[k][TMD]; accum *= hmm->t[k][TDD]; hmm->esc[k] = Prob2Score(tme, 1.); /* exits are to non-emitter */ } /* special transitions */ hmm->xsc[XTN][LOOP] = Prob2Score(hmm->xt[XTN][LOOP], hmm->p1); hmm->xsc[XTN][MOVE] = Prob2Score(hmm->xt[XTN][MOVE], 1.0); hmm->xsc[XTE][LOOP] = Prob2Score(hmm->xt[XTE][LOOP], 1.0); hmm->xsc[XTE][MOVE] = Prob2Score(hmm->xt[XTE][MOVE], 1.0); hmm->xsc[XTC][LOOP] = Prob2Score(hmm->xt[XTC][LOOP], hmm->p1); hmm->xsc[XTC][MOVE] = Prob2Score(hmm->xt[XTC][MOVE], 1.-hmm->p1); hmm->xsc[XTJ][LOOP] = Prob2Score(hmm->xt[XTJ][LOOP], hmm->p1); hmm->xsc[XTJ][MOVE] = Prob2Score(hmm->xt[XTJ][MOVE], 1.0); hmm->flags |= PLAN7_HASBITS; /* raise the log-odds ready flag */ } /* Function: Plan7Renormalize() * * Purpose: Take an HMM in counts form, and renormalize * all of its probability vectors. Also enforces * Plan7 restrictions on nonexistent transitions. * * Args: hmm - the model to renormalize. * * Return: (void) * hmm is changed. */ void Plan7Renormalize(struct plan7_s *hmm) { int k; /* counter for model position */ int st; /* counter for special states */ float d; /* denominator */ /* match emissions */ for (k = 1; k <= hmm->M; k++) FNorm(hmm->mat[k], Alphabet_size); /* insert emissions */ for (k = 1; k < hmm->M; k++) FNorm(hmm->ins[k], Alphabet_size); /* begin transitions */ d = FSum(hmm->begin+1, hmm->M) + hmm->tbd1; FScale(hmm->begin+1, hmm->M, 1./d); hmm->tbd1 /= d; /* main model transitions */ for (k = 1; k < hmm->M; k++) { d = FSum(hmm->t[k], 3) + hmm->end[k]; FScale(hmm->t[k], 3, 1./d); hmm->end[k] /= d; FNorm(hmm->t[k]+3, 2); /* insert */ FNorm(hmm->t[k]+5, 2); /* delete */ } /* null model emissions */ FNorm(hmm->null, Alphabet_size); /* special transitions */ for (st = 0; st < 4; st++) FNorm(hmm->xt[st], 2); /* enforce nonexistent transitions */ /* (is this necessary?) */ hmm->t[0][TDM] = hmm->t[0][TDD] = 0.0; hmm->flags &= ~PLAN7_HASBITS; /* clear the log-odds ready flag */ hmm->flags |= PLAN7_HASPROB; /* set the probabilities OK flag */ } /* Function: Plan7NakedConfig() * * Purpose: Set the alignment-independent, algorithm-dependent parameters * of a Plan7 model so that no special states (N,C,J) emit anything: * one simple, full global pass through the model. * * Args: hmm - the plan7 model * * Return: (void) * The HMM is modified; algorithm dependent parameters are set. * Previous scores are invalidated if they existed. */ void Plan7NakedConfig(struct plan7_s *hmm) { hmm->xt[XTN][MOVE] = 1.; /* disallow N-terminal tail */ hmm->xt[XTN][LOOP] = 0.; hmm->xt[XTE][MOVE] = 1.; /* only 1 domain/sequence ("global" alignment) */ hmm->xt[XTE][LOOP] = 0.; hmm->xt[XTC][MOVE] = 1.; /* disallow C-terminal tail */ hmm->xt[XTC][LOOP] = 0.; hmm->xt[XTJ][MOVE] = 0.; /* J state unused */ hmm->xt[XTJ][LOOP] = 1.; FSet(hmm->begin+2, hmm->M-1, 0.); /* disallow internal entries. */ hmm->begin[1] = 1. - hmm->tbd1; FSet(hmm->end+1, hmm->M-1, 0.); /* disallow internal exits. */ hmm->end[hmm->M] = 1.; hmm->flags &= ~PLAN7_HASBITS; /* reconfig invalidates log-odds scores */ } /* Function: Plan7GlobalConfig() * * Purpose: Set the alignment-independent, algorithm-dependent parameters * of a Plan7 model to global (Needleman/Wunsch) configuration. * * Like a non-looping hmmls, since we actually allow flanking * N and C terminal sequence. * * Args: hmm - the plan7 model * * Return: (void) * The HMM is modified; algorithm dependent parameters are set. * Previous scores are invalidated if they existed. */ void Plan7GlobalConfig(struct plan7_s *hmm) { hmm->xt[XTN][MOVE] = 1. - hmm->p1; /* allow N-terminal tail */ hmm->xt[XTN][LOOP] = hmm->p1; hmm->xt[XTE][MOVE] = 1.; /* only 1 domain/sequence ("global" alignment) */ hmm->xt[XTE][LOOP] = 0.; hmm->xt[XTC][MOVE] = 1. - hmm->p1; /* allow C-terminal tail */ hmm->xt[XTC][LOOP] = hmm->p1; hmm->xt[XTJ][MOVE] = 0.; /* J state unused */ hmm->xt[XTJ][LOOP] = 1.; FSet(hmm->begin+2, hmm->M-1, 0.); /* disallow internal entries. */ hmm->begin[1] = 1. - hmm->tbd1; FSet(hmm->end+1, hmm->M-1, 0.); /* disallow internal exits. */ hmm->end[hmm->M] = 1.; hmm->flags &= ~PLAN7_HASBITS; /* reconfig invalidates log-odds scores */ } /* Function: Plan7LSConfig() * * Purpose: Set the alignment independent parameters of a Plan7 model * to hmmls (global in HMM, local in sequence) configuration. * * Args: hmm - the plan7 model * * Return: (void); * the HMM probabilities are modified. */ void Plan7LSConfig(struct plan7_s *hmm) { hmm->xt[XTN][MOVE] = 1.-hmm->p1; /* allow N-terminal tail */ hmm->xt[XTN][LOOP] = hmm->p1; hmm->xt[XTE][MOVE] = 0.5; /* expectation 2 domains/seq */ hmm->xt[XTE][LOOP] = 0.5; hmm->xt[XTC][MOVE] = 1.-hmm->p1; /* allow C-terminal tail */ hmm->xt[XTC][LOOP] = hmm->p1; hmm->xt[XTJ][MOVE] = 1.-hmm->p1; /* allow J junction state */ hmm->xt[XTJ][LOOP] = hmm->p1; FSet(hmm->begin+2, hmm->M-1, 0.); /* start at M1/D1 */ hmm->begin[1] = 1. - hmm->tbd1; FSet(hmm->end+1, hmm->M-1, 0.); /* end at M_m/D_m */ hmm->end[hmm->M] = 1.; hmm->flags &= ~PLAN7_HASBITS; /* reconfig invalidates log-odds scores */ } /* Function: Plan7SWConfig() * * Purpose: Set the alignment independent parameters of * a Plan7 model to hmmsw (Smith/Waterman) configuration. * * Notes: entry/exit is asymmetric because of the left/right * nature of the HMM/profile. Entry probability is distributed * simply by assigning p_x = pentry / (M-1) to M-1 * internal match states. However, the same approach doesn't * lead to a flat distribution over exit points. Exit p's * must be corrected for the probability of a previous exit * from the model. Requiring a flat distribution over exit * points leads to an easily solved piece of algebra, giving: * p_1 = pexit / (M-1) * p_x = p_1 / (1 - (x-1) p_1) * * Args: hmm - the Plan7 model w/ data-dep prob's valid * pentry - probability of an internal entry somewhere; * will be evenly distributed over M-1 match states * pexit - probability of an internal exit somewhere; * will be distributed over M-1 match states. * * Return: (void) * HMM probabilities are modified. */ void Plan7SWConfig(struct plan7_s *hmm, float pentry, float pexit) { float basep; /* p1 for exits: the base p */ int k; /* counter over states */ float d; /* Configure special states. */ hmm->xt[XTN][MOVE] = 1-hmm->p1; /* allow N-terminal tail */ hmm->xt[XTN][LOOP] = hmm->p1; hmm->xt[XTE][MOVE] = 1.; /* disallow jump state */ hmm->xt[XTE][LOOP] = 0.; hmm->xt[XTC][MOVE] = 1-hmm->p1; /* allow C-terminal tail */ hmm->xt[XTC][LOOP] = hmm->p1; hmm->xt[XTJ][MOVE] = 1.; /* J is unused */ hmm->xt[XTJ][LOOP] = 0.; /* Configure entry. */ hmm->begin[1] = (1. - pentry) * (1. - hmm->tbd1); FSet(hmm->begin+2, hmm->M-1, (pentry * (1.- hmm->tbd1)) / (float)(hmm->M-1)); /* Configure exit. */ hmm->end[hmm->M] = 1.0; basep = pexit / (float) (hmm->M-1); for (k = 1; k < hmm->M; k++) hmm->end[k] = basep / (1. - basep * (float) (k-1)); /* Renormalize transitions to deal with new exits. */ for (k = 1; k < hmm->M; k++) { d = FSum(hmm->t[k], 3); FScale(hmm->t[k], 3, 1./(d + d*hmm->end[k])); } hmm->flags &= ~PLAN7_HASBITS; /* reconfig invalidates log-odds scores */ } /* Function: Plan7FSConfig() * Date: SRE, Fri Jan 2 15:34:40 1998 [StL] * * Purpose: Set the alignment independent parameters of * a Plan7 model to hmmfs (multihit Smith/Waterman) configuration. * * See comments on Plan7SWConfig() for explanation of * how pentry and pexit are used. * * Args: hmm - the Plan7 model w/ data-dep prob's valid * pentry - probability of an internal entry somewhere; * will be evenly distributed over M-1 match states * pexit - probability of an internal exit somewhere; * will be distributed over M-1 match states. * * Return: (void) * HMM probabilities are modified. */ void Plan7FSConfig(struct plan7_s *hmm, float pentry, float pexit) { float basep; /* p1 for exits: the base p */ int k; /* counter over states */ float d; /* Configure special states. */ hmm->xt[XTN][MOVE] = 1-hmm->p1; /* allow N-terminal tail */ hmm->xt[XTN][LOOP] = hmm->p1; hmm->xt[XTE][MOVE] = 0.5; /* allow loops / multihits */ hmm->xt[XTE][LOOP] = 0.5; hmm->xt[XTC][MOVE] = 1-hmm->p1; /* allow C-terminal tail */ hmm->xt[XTC][LOOP] = hmm->p1; hmm->xt[XTJ][MOVE] = 1.-hmm->p1; /* allow J junction between domains */ hmm->xt[XTJ][LOOP] = hmm->p1; /* Configure entry. */ hmm->begin[1] = (1. - pentry) * (1. - hmm->tbd1); FSet(hmm->begin+2, hmm->M-1, (pentry * (1.-hmm->tbd1)) / (float)(hmm->M-1)); /* Configure exit. */ hmm->end[hmm->M] = 1.0; basep = pexit / (float) (hmm->M-1); for (k = 1; k < hmm->M; k++) hmm->end[k] = basep / (1. - basep * (float) (k-1)); /* Renormalize transitions to deal with new exits. */ for (k = 1; k < hmm->M; k++) { d = FSum(hmm->t[k], 3); FScale(hmm->t[k], 3, 1./(d + d*hmm->end[k])); } hmm->flags &= ~PLAN7_HASBITS; /* reconfig invalidates log-odds scores */ } /* Function: Plan7ESTConfig() * * Purpose: Configure a Plan7 model for EST Smith/Waterman * analysis. * * OUTDATED; DO NOT USE WITHOUT RECHECKING * * Args: hmm - hmm to configure. * aacode - 0..63 vector mapping genetic code to amino acids * estmodel - 20x64 translation matrix, w/ codon bias and substitution error * dna2 - probability of a -1 frameshift in a triplet * dna4 - probability of a +1 frameshift in a triplet */ void Plan7ESTConfig(struct plan7_s *hmm, int *aacode, float **estmodel, float dna2, float dna4) { int k; int x; float p; float *tripnull; /* UNFINISHED!!! */ /* configure specials */ hmm->xt[XTN][MOVE] = 1./351.; hmm->xt[XTN][LOOP] = 350./351.; hmm->xt[XTE][MOVE] = 1.; hmm->xt[XTE][LOOP] = 0.; hmm->xt[XTC][MOVE] = 1./351.; hmm->xt[XTC][LOOP] = 350./351.; hmm->xt[XTJ][MOVE] = 1.; hmm->xt[XTJ][LOOP] = 0.; /* configure entry/exit */ hmm->begin[1] = 0.5; FSet(hmm->begin+2, hmm->M-1, 0.5 / ((float)hmm->M - 1.)); hmm->end[hmm->M] = 1.; FSet(hmm->end, hmm->M-1, 0.5 / ((float)hmm->M - 1.)); /* configure dna triplet/frameshift emissions */ for (k = 1; k <= hmm->M; k++) { /* translate aa to triplet probabilities */ for (x = 0; x < 64; x++) { p = hmm->mat[k][aacode[x]] * estmodel[aacode[x]][x] * (1.-dna2-dna4); hmm->dnam[x][k] = Prob2Score(p, tripnull[x]); p = hmm->ins[k][aacode[x]] * estmodel[aacode[x]][x] * (1.-dna2-dna4); hmm->dnai[x][k] = Prob2Score(p, tripnull[x]); } hmm->dnam[64][k] = 0; /* ambiguous codons score 0 (danger?) */ hmm->dna2 = Prob2Score(dna2, 1.); hmm->dna4 = Prob2Score(dna4, 1.); } } /* Function: PrintPlan7Stats() * * Purpose: Given a newly constructed HMM and the tracebacks * of the sequences it was trained on, print out all * the interesting information at the end of hmmb * and hmmt runs that convinces the user we actually * did something. * * Args: fp - where to send the output (stdout, usually) * hmm - the new HMM, probability form * dsq - digitized training seqs * nseq - number of dsq's * tr - array of tracebacks for dsq * * Return: (void) */ void PrintPlan7Stats(FILE *fp, struct plan7_s *hmm, char **dsq, int nseq, struct p7trace_s **tr) { int idx; /* counter for sequences */ float score; /* an individual trace score */ float total, best, worst; /* for the avg. and range of the scores */ float sqsum, stddev; /* for the std. deviation of the scores */ P7Logoddsify(hmm, TRUE); /* make sure model scores are ready */ /* find individual trace scores */ score = P7TraceScore(hmm, dsq[0], tr[0]); total = best = worst = score; sqsum = score * score; for (idx = 1; idx < nseq; idx++) { /* P7PrintTrace(stdout, tr[idx], hmm, dsq[idx]); */ score = P7TraceScore(hmm, dsq[idx], tr[idx]); total += score; sqsum += score * score; if (score > best) best = score; if (score < worst) worst = score; } if (nseq > 1) { stddev = (sqsum - (total * total / (float) nseq)) / ((float) nseq - 1.); stddev = (stddev > 0) ? sqrt(stddev) : 0.0; } else stddev = 0.0; /* print out stuff. */ fprintf(fp, "Average score: %10.2f bits\n", total / (float) nseq); fprintf(fp, "Minimum score: %10.2f bits\n", worst); fprintf(fp, "Maximum score: %10.2f bits\n", best); fprintf(fp, "Std. deviation: %10.2f bits\n", stddev); } /* Function: DegenerateSymbolScore() * * Purpose: Given a sequence character x and an hmm emission probability * vector, calculate the log-odds (base 2) score of * the symbol. * * Easy if x is in the emission alphabet, but not so easy * is x is a degenerate symbol. The "correct" Bayesian * philosophy is to calculate score(X) by summing over * p(x) for all x in the degenerate symbol X to get P(X), * doing the same sum over the prior to get F(X), and * doing log_2 (P(X)/F(X)). This gives an X a zero score, * for instance. * * Though this is correct in a formal Bayesian sense -- * we have no information on the sequence, so we can't * say if it's random or model, so it scores zero -- * it sucks, big time, for scoring biological sequences. * Sequences with lots of X's score near zero, while * real sequences have average scores that are negative -- * so the X-laden sequences appear to be lifted out * of the noise of a full histogram of a database search. * Correct or not, this is highly undesirable. * * So therefore we calculated the expected score of * the degenerate symbol by summing over all x in X: * e_x log_2 (p(x)/f(x)) * where the expectation of x, e_x, is calculated from * the random model. * * Empirically, this works; it also has a wooly hand-waving * probabilistic justification that I'm happy enough about. * * Args: p - probabilities of normal symbols * null - null emission model * ambig - index of the degenerate character in Alphabet[] * * Return: the integer log odds score of x given the emission * vector and the null model, scaled up by INTSCALE. */ int DegenerateSymbolScore(float *p, float *null, int ambig) { int x; float numer = 0.; float denom = 0.; for (x = 0; x < Alphabet_size; x++) { if (Degenerate[ambig][x]) { numer += null[x] * sreLOG2(p[x] / null[x]); denom += null[x]; } } return (int) (INTSCALE * numer / denom); } /***************************************************************** * * Plan9/Plan7 interface * * Very important code during the evolutionary takeover by Plan7 -- * convert between Krogh/Haussler and Plan7 models. *****************************************************************/ /* Function: Plan9toPlan7() * * Purpose: Convert an old HMM into Plan7. Configures it in * ls mode. * * Args: hmm - old ugly plan9 style HMM * ret_plan7 - new wonderful Plan7 HMM * * Return: (void) * Plan7 HMM is allocated here. Free w/ FreePlan7(). */ void Plan9toPlan7(struct plan9_s *hmm, struct plan7_s **ret_plan7) { struct plan7_s *plan7; int k, x; plan7 = AllocPlan7(hmm->M); for (k = 1; k < hmm->M; k++) { plan7->t[k][TMM] = hmm->mat[k].t[MATCH]; plan7->t[k][TMD] = hmm->mat[k].t[DELETE]; plan7->t[k][TMI] = hmm->mat[k].t[INSERT]; plan7->t[k][TDM] = hmm->del[k].t[MATCH]; plan7->t[k][TDD] = hmm->del[k].t[DELETE]; plan7->t[k][TIM] = hmm->ins[k].t[MATCH]; plan7->t[k][TII] = hmm->ins[k].t[INSERT]; } for (k = 1; k <= hmm->M; k++) for (x = 0; x < Alphabet_size; x++) plan7->mat[k][x] = hmm->mat[k].p[x]; for (k = 1; k < hmm->M; k++) for (x = 0; x < Alphabet_size; x++) plan7->ins[k][x] = hmm->ins[k].p[x]; plan7->tbd1 = hmm->mat[0].t[DELETE] / (hmm->mat[0].t[DELETE] + hmm->mat[0].t[MATCH]); /* We have to make up the null transition p1; use default */ P7DefaultNullModel(plan7->null, &(plan7->p1)); for (x = 0; x < Alphabet_size; x++) plan7->null[x] = hmm->null[x]; if (hmm->name != NULL) Plan7SetName(plan7, hmm->name); if (hmm->flags & HMM_REF) { strcpy(plan7->rf, hmm->ref); plan7->flags |= PLAN7_RF; } if (hmm->flags & HMM_CS) { strcpy(plan7->cs, hmm->cs); plan7->flags |= PLAN7_CS; } Plan7LSConfig(plan7); /* configure specials for ls-style alignment */ Plan7Renormalize(plan7); /* mainly to correct for missing ID and DI */ plan7->flags |= PLAN7_HASPROB; /* probabilities are valid */ plan7->flags &= ~PLAN7_HASBITS; /* scores are not valid */ *ret_plan7 = plan7; } wise-2.4.1/src/HMMer2/plan9.c0000644000175000001440000000676407313404526015102 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile-HMMs * Copyright (C) 1992-1998 Washington University School of Medicine * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* plan9.c * SRE, Wed Apr 8 07:35:30 1998 * * alloc, free, and initialization of old Plan9 (HMMER 1.x) functions. * Rescued from the wreckage of HMMER 1.9m code. */ #include #include #include #include #include "squid.h" #include "config.h" #include "structs.h" #include "funcs.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif struct plan9_s * P9AllocHMM(int M) /* length of model to make */ { struct plan9_s *hmm; /* RETURN: blank HMM */ hmm = (struct plan9_s *) MallocOrDie (sizeof(struct plan9_s)); hmm->ins = (struct basic_state *) MallocOrDie (sizeof(struct basic_state) * (M+2)); hmm->del = (struct basic_state *) MallocOrDie (sizeof(struct basic_state) * (M+2)); hmm->mat = (struct basic_state *) MallocOrDie (sizeof(struct basic_state) * (M+2)); hmm->ref = (char *) MallocOrDie ((M+2) * sizeof(char)); hmm->cs = (char *) MallocOrDie ((M+2) * sizeof(char)); hmm->xray = (float *) MallocOrDie ((M+2) * sizeof(float) * NINPUTS); hmm->M = M; hmm->name = Strdup("unnamed"); /* name is not optional. */ hmm->flags = 0; P9ZeroHMM(hmm); return hmm; } int P9FreeHMM(struct plan9_s *hmm) { if (hmm == NULL) return 0; free(hmm->ref); free(hmm->cs); free(hmm->xray); free(hmm->name); if (hmm->mat != NULL) free (hmm->mat); if (hmm->ins != NULL) free (hmm->ins); if (hmm->del != NULL) free (hmm->del); free(hmm); return 1; } /* Function: P9ZeroHMM() * * Purpose: Zero emission and transition counts in an HMM. */ void P9ZeroHMM(struct plan9_s *hmm) { int k, ts, idx; for (k = 0; k <= hmm->M+1; k++) { for (ts = 0; ts < 3; ts++) { hmm->mat[k].t[ts] = 0.0; hmm->ins[k].t[ts] = 0.0; hmm->del[k].t[ts] = 0.0; } for (idx = 0; idx < Alphabet_size; idx++) { hmm->mat[k].p[idx] = 0.0; hmm->ins[k].p[idx] = 0.0; hmm->del[k].p[idx] = 0.0; } } } /* Function: P9Renormalize() * * Normalize all P distributions so they sum to 1. * P distributions that are all 0, or contain negative * probabilities, are left untouched. * * Returns 1 on success, or 0 on failure. */ void P9Renormalize(struct plan9_s *hmm) { int k; /* counter for states */ for (k = 0; k <= hmm->M ; k++) { /* match state transition frequencies */ FNorm(hmm->mat[k].t, 3); FNorm(hmm->ins[k].t, 3); if (k > 0) FNorm(hmm->del[k].t, 3); if (k > 0) FNorm(hmm->mat[k].p, Alphabet_size); FNorm(hmm->ins[k].p, Alphabet_size); } } /* Function: P9DefaultNullModel() * * Purpose: Set up a default random sequence model, using * global aafq[]'s for protein or 0.25 for nucleic * acid. randomseq is alloc'ed in caller. Alphabet information * must already be known. */ void P9DefaultNullModel(float *null) { int x; if (Alphabet_type == hmmAMINO) for (x = 0; x < Alphabet_size; x++) null[x] = aafq[x]; else if (Alphabet_type == hmmNUCLEIC) for (x = 0; x < Alphabet_size; x++) null[x] = 0.25; else Die("No support for non-protein, non-nucleic acid alphabets."); } wise-2.4.1/src/HMMer2/aligneval.c0000644000175000001440000003252107313404524016005 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* aligneval.c * * Comparison of multiple alignments. Three functions are * provided, using subtly different scoring schemes: * CompareMultAlignments() - basic scoring scheme * CompareRefMultAlignments() - only certain "canonical" columns * are scored * * The similarity measure is a fractional alignment identity averaged * over all sequence pairs. The score for all pairs is: * (identically aligned symbols) / (total aligned columns in * known alignment) * * A column c is identically aligned for sequences i, j if: * 1) both i,j have a symbol aligned in column c, and the * same pair of symbols is aligned somewhere in the test * alignment * 2) S[i][c] is aligned to a gap in sequence j, and that symbol * is aligned to a gap in the test alignment * 3) converse of 2) * * * The algorithm is as follows: * 1) For each known/test aligned pair of sequences (k1,k2 and t1,t2) * construct a list for each sequence, in which for every * counted symbol we record the raw index of the symbol in * the other sequence that it aligns to, or -1 if it aligns * to a gap or uncounted symbol. * * 2) Compare the list for k1 to the list for t1 and count an identity * for each correct alignment. * * 3) Repeat 2) for comparing k2 to t2. Note that this means correct sym/sym * alignments count for 2; correct sym/gap alignments count for 1. * * 4) The score is (identities from 2 + identities from 3) / * (totals from 2 + totals from 3). * * Written originally for koala's ss2 pairwise alignment package. * * Sean Eddy, Sun Nov 1 12:45:11 1992 * SRE, Thu Jul 29 16:47:18 1993: major revision: all functions replaced by new algorithm */ #include #include #include #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif static int make_alilist(char *s1, char *s2, int **ret_s1_list, int *ret_listlen); static int make_ref_alilist(int *refcoords, char *k1, char *k2, char *s1, char *s2, int **ret_s1_list, int *ret_listlen); static int compare_lists(int *k1, int *k2, int *t1, int *t2, int len1, int len2, float *ret_sc); /* Function: ComparePairAlignments * * Purpose: Calculate and return a number representing how well two different alignments * of a pair of sequences compare. The number is, roughly speaking, * the fraction of columns which are identically aligned. * * For all columns c in which either known1[c] or known2[c] * is a non-gap, count an identity if those same symbols are * aligned somewhere in calc1/calc2. The score is identities/total * columns examined. (i.e. fully gapped columns don't count) * * more explicitly, identities come from: * both known and test aligned pairs have the same symbol in the first sequence aligned to * a gap in the second sequence; * both known and test aligned pairs have the same symbol in the second sequence * aligned to a gap in the first sequence; * the known alignment has symbols aligned at this column, and the test * alignment aligns the same two symbols. * * Args: known1, known2: trusted alignment of two sequences * calc1, calc2: test alignment of two sequences * * Return: Returns -1.0 on internal failure. */ float ComparePairAlignments(char *known1, char *known2, char *calc1, char *calc2) { int *klist1; int *klist2; int *tlist1; int *tlist2; int len1, len2; float score; if (! make_alilist(calc1, calc2, &tlist1, &len1)) return -1.0; if (! make_alilist(calc2, calc1, &tlist2, &len2)) return -1.0; if (! make_alilist(known1, known2, &klist1, &len1)) return -1.0; if (! make_alilist(known2, known1, &klist2, &len2)) return -1.0; if (! compare_lists(klist1, klist2, tlist1, tlist2, len1, len2, &score)) return -1.0; free(klist1); free(klist2); free(tlist1); free(tlist2); return score; } /* Function: CompareRefPairAlignments() * * Same as above, but the only columns that count are the ones * with indices in *refcoord. *refcoord and the known1, known2 * pair must be in sync with each other (come from the same * multiple sequence alignment) * * Args: ref - 0..alen-1 array of 1 or 0 * known1,known2 - trusted alignment * calc1, calc2 - test alignment * * Return: the fractional alignment identity on success, -1.0 on failure. */ float CompareRefPairAlignments(int *ref, char *known1, char *known2, char *calc1, char *calc2) { int *klist1; int *klist2; int *tlist1; int *tlist2; int len1, len2; float score; if (! make_ref_alilist(ref, known1, known2, calc1, calc2, &tlist1, &len1)) return -1.0; if (! make_ref_alilist(ref, known2, known1, calc2, calc1, &tlist2, &len2)) return -1.0; if (! make_ref_alilist(ref, known1, known2, known1, known2, &klist1, &len1)) return -1.0; if (! make_ref_alilist(ref, known2, known1, known2, known1, &klist2, &len2)) return -1.0; if (! compare_lists(klist1, klist2, tlist1, tlist2, len1, len2, &score)) return -1.0; free(klist1); free(klist2); free(tlist1); free(tlist2); return score; } /* Function: make_alilist() * * Purpose: Construct a list (array) mapping the raw symbols of s1 * onto the indexes of the aligned symbols in s2 (or -1 * for gaps in s2). The list (s1_list) will be of the * length of s1's raw sequence. * * Args: s1 - sequence to construct the list for * s2 - sequence s1 is aligned to * ret_s1_list - RETURN: the constructed list (caller must free) * ret_listlen - RETURN: length of the list * * Returns: 1 on success, 0 on failure */ static int make_alilist(char *s1, char *s2, int **ret_s1_list, int *ret_listlen) { int *s1_list; int col; /* column position in alignment */ int r1, r2; /* raw symbol index at current col in s1, s2 */ /* Malloc for s1_list. It can't be longer than s1 itself; we just malloc * for that (and waste a wee bit of space) */ s1_list = (int *) MallocOrDie (sizeof(int) * strlen(s1)); r1 = r2 = 0; for (col = 0; s1[col] != '\0'; col++) { /* symbol in s1? Record what it's aligned to, and bump * the r1 counter. */ if (! isgap(s1[col])) { s1_list[r1] = isgap(s2[col]) ? -1 : r2; r1++; } /* symbol in s2? bump the r2 counter */ if (! isgap(s2[col])) r2++; } *ret_listlen = r1; *ret_s1_list = s1_list; return 1; } /* Function: make_ref_alilist() * * Purpose: Construct a list (array) mapping the raw symbols of s1 * which are under canonical columns of the ref alignment * onto the indexes of the aligned symbols in s2 (or -1 * for gaps in s2 or noncanonical symbols in s2). * * Args: ref: - array of indices of canonical coords (1 canonical, 0 non) * k1 - s1's known alignment (w/ respect to refcoords) * k2 - s2's known alignment (w/ respect to refcoords) * s1 - sequence to construct the list for * s2 - sequence s1 is aligned to * ret_s1_list - RETURN: the constructed list (caller must free) * ret_listlen - RETURN: length of the list * * Returns: 1 on success, 0 on failure */ /*ARGSUSED*/ static int make_ref_alilist(int *ref, char *k1, char *k2, char *s1, char *s2, int **ret_s1_list, int *ret_listlen) { int *s1_list; int col; /* column position in alignment */ int r1, r2; /* raw symbol index at current col in s1, s2 */ int *canons1; /* flag array, 1 if position i in s1 raw seq is canonical */ int lpos; /* position in list */ /* Allocations. No arrays can exceed the length of their * appropriate parent (s1 or s2) */ s1_list = (int *) MallocOrDie (sizeof(int) * strlen(s1)); canons1 = (int *) MallocOrDie (sizeof(int) * strlen(s1)); /* First we use refcoords and k1,k2 to construct an array of 1's * and 0's, telling us whether s1's raw symbol number i is countable. * It's countable simply if it's under a canonical column. */ r1 = 0; for (col = 0; k1[col] != '\0'; col++) { if (! isgap(k1[col])) { canons1[r1] = ref[col] ? 1 : 0; r1++; } } /* Now we can construct the list. We don't count pairs if the sym in s1 * is non-canonical. * We have to keep separate track of our position in the list (lpos) * from our positions in the raw sequences (r1,r2) */ r1 = r2 = lpos = 0; for (col = 0; s1[col] != '\0'; col++) { if (! isgap(s1[col]) && canons1[r1]) { s1_list[lpos] = isgap(s2[col]) ? -1 : r2; lpos++; } if (! isgap(s1[col])) r1++; if (! isgap(s2[col])) r2++; } free(canons1); *ret_listlen = lpos; *ret_s1_list = s1_list; return 1; } /* Function: compare_lists() * * Purpose: Given four alignment lists (k1,k2, t1,t2), calculate the * alignment score. * * Args: k1 - list of k1's alignment to k2 * k2 - list of k2's alignment to k1 * t1 - list of t1's alignment to t2 * t2 - list of t2's alignment to t2 * len1 - length of k1, t1 lists (same by definition) * len2 - length of k2, t2 lists (same by definition) * ret_sc - RETURN: identity score of alignment * * Return: 1 on success, 0 on failure. */ static int compare_lists(int *k1, int *k2, int *t1, int *t2, int len1, int len2, float *ret_sc) { float id; float tot; int i; id = tot = 0.0; for (i = 0; i < len1; i++) { tot += 1.0; if (t1[i] == k1[i]) id += 1.0; } for ( i = 0; i < len2; i++) { tot += 1.0; if (k2[i] == t2[i]) id += 1.0; } *ret_sc = id / tot; return 1; } /* Function: CompareMultAlignments * * Purpose: Invokes pairwise alignment comparison for every possible pair, * and returns the average score over all N(N-1) of them or -1.0 * on an internal failure. * * Can be slow for large N, since it's quadratic. * * Args: kseqs - trusted multiple alignment * tseqs - test multiple alignment * N - number of sequences * * Return: average identity score, or -1.0 on failure. */ float CompareMultAlignments(char **kseqs, char **tseqs, int N) { int i, j; /* counters for sequences */ float score; float tot_score = 0.0; /* do all pairwise comparisons */ for (i = 0; i < N; i++) for (j = i+1; j < N; j++) { score = ComparePairAlignments(kseqs[i], kseqs[j], tseqs[i], tseqs[j]); if (score < 0.0) return -1.0; tot_score += score; } return ((tot_score * 2.0) / ((float) N * ((float) N - 1.0))); } /* Function: CompareRefMultAlignments() * * Purpose: Same as above, except an array of reference coords for * the canonical positions of the known alignment is also * provided. * * Args: ref : 0..alen-1 array of 1/0 flags, 1 if canon * kseqs : trusted alignment * tseqs : test alignment * N : number of sequences * * Return: average identity score, or -1.0 on failure */ float CompareRefMultAlignments(int *ref, char **kseqs, char **tseqs, int N) { int i, j; /* counters for sequences */ float score; float tot_score = 0.0; /* do all pairwise comparisons */ for (i = 0; i < N; i++) for (j = i+1; j < N; j++) { score = CompareRefPairAlignments(ref, kseqs[i], kseqs[j], tseqs[i], tseqs[j]); if (score < 0.0) return -1.0; tot_score += score; } return ((tot_score * 2.0)/ ((float) N * ((float) N - 1.0))); } /* Function: PairwiseIdentity() * * Purpose: Calculate the pairwise fractional identity between * two aligned sequences s1 and s2. This is simply * (idents / MIN(len1, len2)). * * Note how many ways there are to calculate pairwise identity, * because of the variety of choices for the denominator: * idents/(idents+mismat) has the disadvantage that artifactual * gappy alignments would have high "identities". * idents/(AVG|MAX)(len1+len2) both have the disadvantage that * alignments of fragments to longer sequences would have * artifactually low "identities". * * Watch out in nucleic acid alignments; U/T RNA/DNA alignments * will be counted as mismatches! */ float PairwiseIdentity(char *s1, char *s2) { int idents; /* total identical positions */ int len1, len2; /* lengths of seqs */ int x; /* position in aligned seqs */ idents = len1 = len2 = 0; for (x = 0; s1[x] != '\0' && s2[x] != '\0'; x++) { if (!isgap(s1[x])) { len1++; if (s1[x] == s2[x]) idents++; } if (!isgap(s2[x])) len2++; } if (len2 < len1) len1 = len2; return (len1 == 0 ? 0.0 : (float) idents / (float) len1); } wise-2.4.1/src/HMMer2/version.h0000644000175000001440000000201607313404530015526 0ustar philippusers/************************************************************ * HMMER - Biological sequence analysis with profile HMMs * Copyright (C) 1992-1998 Washington University School of Medicine * * This source code is distributed under the terms of the * GNU General Public License. See the files COPYING and * GNULICENSE for details. * ************************************************************/ /* version.h * Version and copyright stamp information for the package. * RCS $Header: /nfs/ensembl/cvsroot/wise2/src/HMMer2/version.h,v 1.1.1.1 2001/06/18 13:59:52 birney Exp $ */ #define RELEASE "2.0" #define RELEASEDATE "June 1998" #ifndef LINTING /* compiled-in stamp for all binaries */ static char *copyright = "\ HMMER -- Biological sequence analysis with profile HMMs.\n\ Copyright (C) 1992-1998 Washington University School of Medicine.\n\ \n\ HMMER is distributed under the terms of the GNU General Public\n\ License. See the files COPYING and GNULICENSE for details."; #endif /* LINTING */ wise-2.4.1/src/HMMer2/sre_math.c0000644000175000001440000004415707313404527015660 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* sre_math.c * * Portability for and extensions to C math library. * */ #include #include #include #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif static int sre_reseed = 0; /* TRUE to reinit sre_random() */ static int sre_randseed = 666; /* default seed for sre_random() */ /* Function: Gaussrandom() * * Pick a Gaussian-distributed random variable * with some mean and standard deviation, and * return it. * * Based on RANLIB.c public domain implementation. * Thanks to the authors, Barry W. Brown and James Lovato, * University of Texas, M.D. Anderson Cancer Center, Houston TX. * Their implementation is from Ahrens and Dieter, "Extensions * of Forsythe's method for random sampling from the normal * distribution", Math. Comput. 27:927-937 (1973). * * Impenetrability of the code is to be blamed on its FORTRAN/f2c lineage. * */ float Gaussrandom(float mean, float stddev) { static float a[32] = { 0.0,3.917609E-2,7.841241E-2,0.11777,0.1573107,0.1970991,0.2372021,0.2776904, 0.3186394,0.36013,0.4022501,0.4450965,0.4887764,0.5334097,0.5791322, 0.626099,0.6744898,0.7245144,0.7764218,0.8305109,0.8871466,0.9467818, 1.00999,1.077516,1.150349,1.229859,1.318011,1.417797,1.534121,1.67594, 1.862732,2.153875 }; static float d[31] = { 0.0,0.0,0.0,0.0,0.0,0.2636843,0.2425085,0.2255674,0.2116342,0.1999243, 0.1899108,0.1812252,0.1736014,0.1668419,0.1607967,0.1553497,0.1504094, 0.1459026,0.14177,0.1379632,0.1344418,0.1311722,0.128126,0.1252791, 0.1226109,0.1201036,0.1177417,0.1155119,0.1134023,0.1114027,0.1095039 }; static float t[31] = { 7.673828E-4,2.30687E-3,3.860618E-3,5.438454E-3,7.0507E-3,8.708396E-3, 1.042357E-2,1.220953E-2,1.408125E-2,1.605579E-2,1.81529E-2,2.039573E-2, 2.281177E-2,2.543407E-2,2.830296E-2,3.146822E-2,3.499233E-2,3.895483E-2, 4.345878E-2,4.864035E-2,5.468334E-2,6.184222E-2,7.047983E-2,8.113195E-2, 9.462444E-2,0.1123001,0.136498,0.1716886,0.2276241,0.330498,0.5847031 }; static float h[31] = { 3.920617E-2,3.932705E-2,3.951E-2,3.975703E-2,4.007093E-2,4.045533E-2, 4.091481E-2,4.145507E-2,4.208311E-2,4.280748E-2,4.363863E-2,4.458932E-2, 4.567523E-2,4.691571E-2,4.833487E-2,4.996298E-2,5.183859E-2,5.401138E-2, 5.654656E-2,5.95313E-2,6.308489E-2,6.737503E-2,7.264544E-2,7.926471E-2, 8.781922E-2,9.930398E-2,0.11556,0.1404344,0.1836142,0.2790016,0.7010474 }; static long i; static float snorm,u,s,ustar,aa,w,y,tt; u = sre_random(); s = 0.0; if(u > 0.5) s = 1.0; u += (u-s); u = 32.0*u; i = (long) (u); if(i == 32) i = 31; if(i == 0) goto S100; /* * START CENTER */ ustar = u-(float)i; aa = *(a+i-1); S40: if(ustar <= *(t+i-1)) goto S60; w = (ustar-*(t+i-1))**(h+i-1); S50: /* * EXIT (BOTH CASES) */ y = aa+w; snorm = y; if(s == 1.0) snorm = -y; return (stddev*snorm + mean); S60: /* * CENTER CONTINUED */ u = sre_random(); w = u*(*(a+i)-aa); tt = (0.5*w+aa)*w; goto S80; S70: tt = u; ustar = sre_random(); S80: if(ustar > tt) goto S50; u = sre_random(); if(ustar >= u) goto S70; ustar = sre_random(); goto S40; S100: /* * START TAIL */ i = 6; aa = *(a+31); goto S120; S110: aa += *(d+i-1); i += 1; S120: u += u; if(u < 1.0) goto S110; u -= 1.0; S140: w = u**(d+i-1); tt = (0.5*w+aa)*w; goto S160; S150: tt = u; S160: ustar = sre_random(); if(ustar > tt) goto S50; u = sre_random(); if(ustar >= u) goto S150; u = sre_random(); goto S140; } /* Function: Linefit() * * Purpose: Given points x[0..N-1] and y[0..N-1], fit to * a straight line y = a + bx. * a, b, and the linear correlation coefficient r * are filled in for return. * * Args: x - x values of data * y - y values of data * N - number of data points * ret_a - RETURN: intercept * ret_b - RETURN: slope * ret_r - RETURN: correlation coefficient * * Return: 1 on success, 0 on failure. */ int Linefit(float *x, float *y, int N, float *ret_a, float *ret_b, float *ret_r) { float xavg, yavg; float sxx, syy, sxy; int i; /* Calculate averages, xavg and yavg */ xavg = yavg = 0.0; for (i = 0; i < N; i++) { xavg += x[i]; yavg += y[i]; } xavg /= (float) N; yavg /= (float) N; sxx = syy = sxy = 0.0; for (i = 0; i < N; i++) { sxx += (x[i] - xavg) * (x[i] - xavg); syy += (y[i] - yavg) * (y[i] - xavg); sxy += (x[i] - xavg) * (y[i] - yavg); } *ret_b = sxy / sxx; *ret_a = yavg - xavg*(*ret_b); *ret_r = sxy / (sqrt(sxx) * sqrt(syy)); return 1; } /* Function: WeightedLinefit() * * Purpose: Given points x[0..N-1] and y[0..N-1] with * variances (measurement errors) var[0..N-1], * fit to a straight line y = mx + b. * * Method: Algorithm from Numerical Recipes in C, [Press88]. * * Return: (void) * ret_m contains slope; ret_b contains intercept */ void WeightedLinefit(float *x, float *y, float *var, int N, float *ret_m, float *ret_b) { int i; double s; double sx, sy; double sxx, sxy; double delta; double m, b; s = sx = sy = sxx = sxy = 0.; for (i = 0; i < N; i++) { s += 1./var[i]; sx += x[i] / var[i]; sy += y[i] / var[i]; sxx += x[i] * x[i] / var[i]; sxy += x[i] * y[i] / var[i]; } delta = s * sxx - (sx * sx); b = (sxx * sy - sx * sxy) / delta; m = (s * sxy - sx * sy) / delta; *ret_m = m; *ret_b = b; } /* Function: Gammln() * * Returns the natural log of the gamma function of x. * x is > 0.0. * * Adapted from a public domain implementation in the * NCBI core math library. Thanks to John Spouge and * the NCBI. (According to the NCBI, that's Dr. John * "Gammas Galore" Spouge to you, pal.) */ float Gammln(float x) { int i; double xx, tx; double tmp, value; static double cof[11] = { 4.694580336184385e+04, -1.560605207784446e+05, 2.065049568014106e+05, -1.388934775095388e+05, 5.031796415085709e+04, -9.601592329182778e+03, 8.785855930895250e+02, -3.155153906098611e+01, 2.908143421162229e-01, -2.319827630494973e-04, 1.251639670050933e-10 }; /* Protect against x=0. We see this in Dirichlet code, * for terms alpha = 0. This is a severe hack but it is effective * and safe. (due to GJM) */ if (x <= 0.0) return 999999.; xx = x - 1.0; tx = tmp = xx + 11.0; value = 1.0; for (i = 10; i >= 0; i--) /* sum least significant terms first */ { value += cof[i] / tmp; tmp -= 1.0; } value = log(value); tx += 0.5; value += 0.918938533 + (xx+0.5)*log(tx) - tx; return (float) value; } /* Vector operations for doubles and floats. * DNorm(), FNorm() -- normalize a probability vector of length n. * return 0 if all values were zero. * DScale(), FScale() -- multiply all items in vector by scale * DSet(), FSet() -- set all items in vector to value. * DAdd(), FAdd() -- add vec2 to vec1. * DDot(), FDot() -- calculate dot product of two vectors. * DCopy(), FCopy() -- set vec1 to be same as vec2. * DMax(), FMax() -- return index of maximum element in vec */ int DNorm(double *vec, int n) { int x; double sum; sum = 0.0; for (x = 0; x < n; x++) sum += vec[x]; if (sum != 0.0) for (x = 0; x < n; x++) vec[x] /= sum; else { squid_errno = SQERR_DIVZERO; return 0; } return 1; } int FNorm(float *vec, int n) { int x; float sum; sum = 0.0; for (x = 0; x < n; x++) sum += vec[x]; if (sum != 0.0) for (x = 0; x < n; x++) vec[x] /= sum; else { squid_errno = SQERR_DIVZERO; return 0; } return 1; } void DScale(double *vec, int n, double scale) { int x; for (x = 0; x < n; x++) vec[x] *= scale; } void FScale(float *vec, int n, float scale) { int x; for (x = 0; x < n; x++) vec[x] *= scale; } void DSet(double *vec, int n, double value) { int x; for (x = 0; x < n; x++) vec[x] = value; } void FSet(float *vec, int n, float value) { int x; for (x = 0; x < n; x++) vec[x] = value; } double DSum(double *vec, int n) { double sum = 0.; int x; for (x = 0; x < n; x++) sum += vec[x]; return sum; } float FSum(float *vec, int n) { float sum = 0.; int x; for (x = 0; x < n; x++) sum += vec[x]; return sum; } void DAdd(double *vec1, double *vec2, int n) { int x; for (x = 0; x < n; x++) vec1[x] += vec2[x]; } void FAdd(float *vec1, float *vec2, int n) { int x; for (x = 0; x < n; x++) vec1[x] += vec2[x]; } void DCopy(double *vec1, double *vec2, int n) { int x; for (x = 0; x < n; x++) vec1[x] = vec2[x]; } void FCopy(float *vec1, float *vec2, int n) { int x; for (x = 0; x < n; x++) vec1[x] = vec2[x]; } double DDot(double *vec1, double *vec2, int n) { double result = 0.; int x; for (x = 0; x < n; x++) result += vec1[x] * vec2[x]; return result; } float FDot(float *vec1, float *vec2, int n) { float result = 0.; int x; for (x = 0; x < n; x++) result += vec1[x] * vec2[x]; return result; } /* Functions: DMax(), FMax() * Date: SRE, Fri Aug 29 11:14:08 1997 (Denver CO) * * Purpose: return index of maximum element in vec. */ int DMax(double *vec, int n) { int i; int best = 0; for (i = 1; i < n; i++) if (vec[i] > vec[best]) best = i; return best; } int FMax(float *vec, int n) { int i; int best = 0; for (i = 1; i < n; i++) if (vec[i] > vec[best]) best = i; return best; } /* 2D matrix operations */ float ** FMX2Alloc(int rows, int cols) { float **mx; int r; mx = (float **) MallocOrDie(sizeof(float *) * rows); mx[0] = (float *) MallocOrDie(sizeof(float) * rows * cols); for (r = 1; r < rows; r++) mx[r] = mx[0] + r*cols; return mx; } void FMX2Free(float **mx) { free(mx[0]); free(mx); } double ** DMX2Alloc(int rows, int cols) { double **mx; int r; mx = (double **) MallocOrDie(sizeof(double *) * rows); mx[0] = (double *) MallocOrDie(sizeof(double) * rows * cols); for (r = 1; r < rows; r++) mx[r] = mx[0] + r*cols; return mx; } void DMX2Free(double **mx) { free(mx[0]); free(mx); } /* Function: FMX2Multiply() * * Purpose: Matrix multiplication. * Multiply an m x p matrix A by a p x n matrix B, * giving an m x n matrix C. * Matrix C must be a preallocated matrix of the right * size. */ void FMX2Multiply(float **A, float **B, float **C, int m, int p, int n) { int i, j, k; for (i = 0; i < m; i++) for (j = 0; j < n; j++) { C[i][j] = 0.; for (k = 0; k < p; k++) C[i][j] += A[i][p] * B[p][j]; } } /* Function: sre_random() * * Purpose: Return a uniform deviate from 0.0 to 1.0. * sre_randseed is a static variable, set * by sre_srandom(). sre_reseed is a static flag * raised by sre_srandom(), saying that we need * to re-initialize. * [0.0 <= x < 1.0] * * Uses a simple linear congruential generator with * period 2^28. Based on discussion in Robert Sedgewick's * _Algorithms in C_, Addison-Wesley, 1990. * * Requires that long int's have at least 32 bits. * * Reliable and portable, but slow. Benchmarks on wol, * using IRIX cc and IRIX C library rand() and random(): * sre_random(): 0.8 usec/call * random(): 0.3 usec/call * rand(): 0.3 usec/call */ #define RANGE 268435456 /* 2^28 */ #define DIV 16384 /* sqrt(RANGE) */ #define MULT 72530821 /* my/Cathy's birthdays, x21, x even (Knuth)*/ float sre_random(void) { static long rnd; static int firsttime = 1; long high1, low1; long high2, low2; if (sre_reseed || firsttime) { sre_reseed = firsttime = 0; if (sre_randseed <= 0) sre_randseed = 666; /* seeds of zero break me */ high1 = sre_randseed / DIV; low1 = sre_randseed % DIV; high2 = MULT / DIV; low2 = MULT % DIV; rnd = (((high2*low1 + high1*low2) % DIV)*DIV + low1*low2) % RANGE; } high1 = rnd / DIV; low1 = rnd % DIV; high2 = MULT / DIV; low2 = MULT % DIV; rnd = (((high2*low1 + high1*low2) % DIV)*DIV + low1*low2) % RANGE; return ((float) rnd / (float) RANGE); } #undef RANGE #undef DIV #undef MULT /* Function: sre_srandom() * * Purpose: Initialize with a random seed. Seed can be * any integer. */ void sre_srandom(int seed) { if (seed < 0) seed = -1 * seed; sre_reseed = 1; sre_randseed = seed; } /* Functions: DChoose(), FChoose() * * Purpose: Make a random choice from a normalized distribution. * DChoose() is for double-precision vectors; * FChoose() is for single-precision float vectors. * Returns the number of the choice. */ int DChoose(double *p, int N) { double roll; /* random fraction */ double sum; /* integrated prob */ int i; /* counter over the probs */ roll = sre_random(); sum = 0.0; for (i = 0; i < N; i++) { sum += p[i]; if (roll < sum) return i; } return (int) (sre_random() * N); /* bulletproof */ } int FChoose(float *p, int N) { float roll; /* random fraction */ float sum; /* integrated prob */ int i; /* counter over the probs */ roll = sre_random(); sum = 0.0; for (i = 0; i < N; i++) { sum += p[i]; if (roll < sum) return i; } return (int) (sre_random() * N); /* bulletproof */ } /* Functions: DLogSum(), FLogSum() * * Calculate the sum of a log vector * *in normal space*, and return the log of the sum. */ double DLogSum(double *logp, int n) { int x; double max = -1.0e30; double sum; for (x = 0; x < n; x++) if (logp[x] > max) max = logp[x]; sum = 0.0; for (x = 0; x < n; x++) if (logp[x] > max - 50.) sum += exp(logp[x] - max); sum = log(sum) + max; return sum; } float FLogSum(float *logp, int n) { int x; float max = -1.0e30; float sum; for (x = 0; x < n; x++) if (logp[x] > max) max = logp[x]; sum = 0.0; for (x = 0; x < n; x++) if (logp[x] > max - 50.) sum += exp(logp[x] - max); sum = log(sum) + max; return sum; } /* Function: IncompleteGamma() * * Purpose: Returns 1 - P(a,x) where: * P(a,x) = \frac{1}{\Gamma(a)} \int_{0}^{x} t^{a-1} e^{-t} dt * = \frac{\gamma(a,x)}{\Gamma(a)} * = 1 - \frac{\Gamma(a,x)}{\Gamma(a)} * * Used in a chi-squared test: for a X^2 statistic x * with v degrees of freedom, call: * p = IncompleteGamma(v/2., x/2.) * to get the probability p that a chi-squared value * greater than x could be obtained by chance even for * a correct model. (i.e. p should be large, say * 0.95 or more). * * Method: Based on ideas from Numerical Recipes in C, Press et al., * Cambridge University Press, 1988. * * Args: a - for instance, degrees of freedom / 2 [a > 0] * x - for instance, chi-squared statistic / 2 [x >= 0] * * Return: 1 - P(a,x). */ double IncompleteGamma(double a, double x) { int iter; /* iteration counter */ if (a <= 0.) Die("IncompleteGamma(): a must be > 0"); if (x < 0.) Die("IncompleteGamma(): x must be >= 0"); /* For x > a + 1 the following gives rapid convergence; * calculate 1 - P(a,x) = \frac{\Gamma(a,x)}{\Gamma(a)}: * use a continued fraction development for \Gamma(a,x). */ if (x > a+1) { double oldp; /* previous value of p */ double nu0, nu1; /* numerators for continued fraction calc */ double de0, de1; /* denominators for continued fraction calc */ nu0 = 0.; /* A_0 = 0 */ de0 = 1.; /* B_0 = 1 */ nu1 = 1.; /* A_1 = 1 */ de1 = x; /* B_1 = x */ oldp = nu1; for (iter = 1; iter < 100; iter++) { /* Continued fraction development: * set A_j = b_j A_j-1 + a_j A_j-2 * B_j = b_j B_j-1 + a_j B_j-2 * We start with A_2, B_2. */ /* j = even: a_j = iter-a, b_j = 1 */ /* A,B_j-2 are in nu0, de0; A,B_j-1 are in nu1,de1 */ nu0 = nu1 + ((double)iter - a) * nu0; de0 = de1 + ((double)iter - a) * de0; /* j = odd: a_j = iter, b_j = x */ /* A,B_j-2 are in nu1, de1; A,B_j-1 in nu0,de0 */ nu1 = x * nu0 + (double) iter * nu1; de1 = x * de0 + (double) iter * de1; /* rescale */ if (de1) { nu0 /= de1; de0 /= de1; nu1 /= de1; de1 = 1.; } /* check for convergence */ if (fabs((nu1-oldp)/nu1) < 1.e-7) return nu1 * exp(a * log(x) - x - Gammln(a)); oldp = nu1; } Die("IncompleteGamma(): failed to converge using continued fraction approx"); } else /* x <= a+1 */ { double p; /* current sum */ double val; /* current value used in sum */ /* For x <= a+1 we use a convergent series instead: * P(a,x) = \frac{\gamma(a,x)}{\Gamma(a)}, * where * \gamma(a,x) = e^{-x}x^a \sum_{n=0}{\infty} \frac{\Gamma{a}}{\Gamma{a+1+n}} x^n * which looks appalling but the sum is in fact rearrangeable to * a simple series without the \Gamma functions: * = \frac{1}{a} + \frac{x}{a(a+1)} + \frac{x^2}{a(a+1)(a+2)} ... * and it's obvious that this should converge nicely for x <= a+1. */ p = val = 1. / a; for (iter = 1; iter < 10000; iter++) { val *= x / (a+(double)iter); p += val; if (fabs(val/p) < 1.e-7) return 1. - p * exp(a * log(x) - x - Gammln(a)); } Die("IncompleteGamma(): failed to converge using series approx"); } /*NOTREACHED*/ return 0.; } wise-2.4.1/src/HMMer2/prior.c0000644000175000001440000005011007313404526015172 0ustar philippusers/* prior.c * SRE, Mon Nov 18 15:44:08 1996 * * Support for Dirichlet prior data structure, p7prior_s. */ #include "config.h" #include "structs.h" #include "funcs.h" #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif static struct p7prior_s *default_amino_prior(void); static struct p7prior_s *default_nucleic_prior(void); /* Function: P7AllocPrior(), P7FreePrior() * * Purpose: Allocation and free'ing of a prior structure. * Very simple, but might get more complex someday. */ struct p7prior_s * P7AllocPrior(void) { return (struct p7prior_s *) MallocOrDie (sizeof(struct p7prior_s)); } void P7FreePrior(struct p7prior_s *pri) { free(pri); } /* Function: P7LaplacePrior() * * Purpose: Create a Laplace plus-one prior. (single component Dirichlets). * Global alphabet info is assumed to have been set already. * * Args: (void) * * Return: prior. Allocated here; call FreePrior() to free it. */ struct p7prior_s * P7LaplacePrior(void) { struct p7prior_s *pri; pri = P7AllocPrior(); pri->strategy = PRI_DCHLET; pri->tnum = 1; pri->tq[0] = 1.; FSet(pri->t[0], 8, 1.); pri->mnum = 1; pri->mq[0] = 1.; FSet(pri->m[0], Alphabet_size, 1.); pri->inum = 1; pri->iq[0] = 1.; FSet(pri->i[0], Alphabet_size, 1.); return pri; } /* Function: P7DefaultPrior() * * Purpose: Set up a somewhat more realistic single component * Dirichlet prior than Laplace. */ struct p7prior_s * P7DefaultPrior(void) { switch (Alphabet_type) { case hmmAMINO: return default_amino_prior(); case hmmNUCLEIC: return default_nucleic_prior(); case hmmNOTSETYET: Die("Can't set prior; alphabet type not set yet"); } /*NOTREACHED*/ return NULL; } /* Function: P7ReadPrior() * * Purpose: Input a prior from disk file. */ struct p7prior_s * P7ReadPrior(char *prifile) { FILE *fp; struct p7prior_s *pri; char *sptr; int q, x; if ((fp = fopen(prifile, "r")) == NULL) Die("Failed to open HMMER prior file %s\n", prifile); pri = P7AllocPrior(); /* First entry is the strategy: * Only standard Dirichlet prior (simple or mixture) is supported in Plan7 so far */ sptr = Getword(fp, sqdARG_STRING); s2upper(sptr); if (strcmp(sptr, "DIRICHLET") == 0) pri->strategy = PRI_DCHLET; else Die("No such prior strategy %s; failed to parse file %s", sptr, prifile); /* Second entry is the alphabet type: * Amino or Nucleic */ sptr = Getword(fp, sqdARG_STRING); s2upper(sptr); if (strcmp(sptr, "AMINO") == 0) { if (Alphabet_type != hmmAMINO) Die("HMM and/or sequences are DNA/RNA; can't use protein prior %s", prifile); } else if (strcmp(sptr, "NUCLEIC") == 0) { if (Alphabet_type != hmmNUCLEIC) Die("HMM and/or sequences are protein; can't use DNA/RNA prior %s", prifile); } else Die("Alphabet \"%s\" in prior file %s isn't valid.", sptr, prifile); /* State transition priors: * # of mixtures. * then for each mixture: * prior P(q) * Dirichlet terms for Tmm, Tmi, Tmd, Tim, Tii, Tid, Tdm, Tdi, Tdd */ pri->tnum = atoi(Getword(fp, sqdARG_INT)); if (pri->tnum < 0) Die("%d is bad; need at least one state transition mixture component", pri->tnum); if (pri->tnum > MAXDCHLET) Die("%d is bad, too many transition components (MAXDCHLET = %d)\n", MAXDCHLET); for (q = 0; q < pri->tnum; q++) { pri->tq[q] = (float) atof(Getword(fp, sqdARG_FLOAT)); for (x = 0; x < 7; x++) pri->t[q][x] = (float) atof(Getword(fp, sqdARG_FLOAT)); } /* Match emission priors: * # of mixtures. * then for each mixture: * prior P(q) * Dirichlet terms for Alphabet_size symbols in Alphabet */ pri->mnum = atoi(Getword(fp, sqdARG_INT)); if (pri->mnum < 0) Die("%d is bad; need at least one match emission mixture component", pri->mnum); if (pri->mnum > MAXDCHLET) Die("%d is bad; too many match components (MAXDCHLET = %d)\n", pri->mnum, MAXDCHLET); for (q = 0; q < pri->mnum; q++) { pri->mq[q] = (float) atof(Getword(fp, sqdARG_FLOAT)); for (x = 0; x < Alphabet_size; x++) pri->m[q][x] = (float) atof(Getword(fp, sqdARG_FLOAT)); } /* Insert emission priors: * # of mixtures. * then for each mixture component: * prior P(q) * Dirichlet terms for Alphabet_size symbols in Alphabet */ pri->inum = atoi(Getword(fp, sqdARG_INT)); if (pri->inum < 0) Die("%d is bad; need at least one insert emission mixture component", pri->inum); if (pri->inum > MAXDCHLET) Die("%d is bad; too many insert components (MAXDCHLET = %d)\n", pri->inum, MAXDCHLET); for (q = 0; q < pri->inum; q++) { pri->iq[q] = (float) atof(Getword(fp, sqdARG_FLOAT)); for (x = 0; x < Alphabet_size; x++) pri->i[q][x] = (float) atof(Getword(fp, sqdARG_FLOAT)); } fclose(fp); return pri; } /* Function: PAMPrior() * * Purpose: Produces an ad hoc "Dirichlet mixture" prior for * match emissions, using a PAM matrix. * * Side effect notice: PAMPrior() replaces the match * emission section of an existing Dirichlet prior, * which is /expected/ to be a simple one-component * kind of prior. The insert emissions /must/ be a * one-component prior (because of details in how * PriorifyEmissionVector() is done). However, * the transitions /could/ be a mixture Dirichlet prior * without causing problems. In other words, the * -p and -P options of hmmb can coexist, but there * may be conflicts. PAMPrior() checks for these, * so there's no serious problem, except that the * error message from PAMPrior() might be confusing to * a user. */ void PAMPrior(char *pamfile, struct p7prior_s *pri, float wt) { FILE *fp; char *blastpamfile; /* BLAST looks in aa/ subdirectory of BLASTMAT */ int **pam; float scale; int xi, xj; int idx1, idx2; if (Alphabet_type != hmmAMINO) Die("PAM prior is only valid for protein sequences"); if (pri->strategy != PRI_DCHLET) Die("PAM prior may only be applied over an existing Dirichlet prior"); if (pri->inum != 1) Die("PAM prior requires that the insert emissions be a single Dirichlet"); if (MAXDCHLET < 20) Die("Whoa, code is misconfigured; MAXDCHLET must be >= 20 for PAM prior"); blastpamfile = FileConcat("aa", pamfile); if ((fp = fopen(pamfile, "r")) == NULL && (fp = EnvFileOpen(pamfile, "BLASTMAT")) == NULL && (fp = EnvFileOpen(blastpamfile, "BLASTMAT")) == NULL) Die("Failed to open PAM scoring matrix file %s", pamfile); if (! ParsePAMFile(fp, &pam, &scale)) Die("Failed to parse PAM scoring matrix file %s", pamfile); fclose(fp); free(blastpamfile); pri->strategy = PRI_PAM; pri->mnum = 20; /* Convert PAM entries back to conditional prob's P(xj | xi), * which we'll use as "pseudocounts" weighted by wt. */ for (xi = 0; xi < Alphabet_size; xi++) for (xj = 0; xj < Alphabet_size; xj++) { idx1 = Alphabet[xi] - 'A'; idx2 = Alphabet[xj] - 'A'; pri->m[xi][xj] = aafq[xj] * exp((float) pam[idx1][idx2] * scale); } /* Normalize so that rows add up to wt. * i.e. Sum(xj) mat[xi][xj] = wt for every row xi */ for (xi = 0; xi < Alphabet_size; xi++) { pri->mq[xi] = 1. / Alphabet_size; FNorm(pri->m[xi], Alphabet_size); FScale(pri->m[xi], Alphabet_size, wt); } Free2DArray(pam,27); } /* Function: P7DefaultNullModel() * * Purpose: Set up a default random sequence model, using * global aafq[]'s for protein or 1/Alphabet_size for anything * else. randomseq is alloc'ed in caller. Alphabet information * must already be known. */ void P7DefaultNullModel(float *null, float *ret_p1) { int x; if (Alphabet_type == hmmAMINO) { for (x = 0; x < Alphabet_size; x++) null[x] = aafq[x]; *ret_p1 = 350./351.; /* rationale: approx avg protein length. */ } else { for (x = 0; x < Alphabet_size; x++) null[x] = 1.0 / (float) Alphabet_size; *ret_p1 = 1000./1001.; /* rationale: approx inter-Alu distance. */ } } void P7ReadNullModel(char *rndfile, float *null, float *ret_p1) { FILE *fp; char *s; int x; int type = 0; if ((fp = fopen(rndfile, "r")) == NULL) Die("Failed to open null model file %s\n", rndfile); if ((s = Getword(fp, sqdARG_STRING)) == NULL) goto FAILURE; s2upper(s); if (strcmp(s, "NUCLEIC") == 0) type = hmmNUCLEIC; else if (strcmp(s, "AMINO") == 0) type = hmmAMINO; else goto FAILURE; /* check/set alphabet type */ if (Alphabet_type == 0) SetAlphabet(type); else if (Alphabet_type != type) Die("Alphabet type conflict; null model in %s is inappropriate\n", rndfile); /* parse the file */ for (x = 0; x < Alphabet_size; x++) { if ((s = Getword(fp, sqdARG_FLOAT)) == NULL) goto FAILURE; null[x] = atof(s); } if ((s = Getword(fp, sqdARG_FLOAT)) == NULL) goto FAILURE; *ret_p1 = atof(s); fclose(fp); return; FAILURE: fclose(fp); Die("%s is not in HMMER null model file format", rndfile); } /* Function: P7PriorifyHMM() * * Purpose: Add pseudocounts to an HMM using Dirichlet priors, * and renormalize the HMM. * * Args: hmm -- the HMM to add counts to (counts form) * pri -- the Dirichlet prior to use * * Return: (void) * HMM returns in probability form. */ void P7PriorifyHMM(struct plan7_s *hmm, struct p7prior_s *pri) { int k; /* counter for model position */ float d; /* a denominator */ /* Model-dependent transitions are handled simply; Laplace. */ FSet(hmm->begin+2, hmm->M-1, 0.); /* wipe internal BM entries */ FSet(hmm->end+1, hmm->M-1, 0.); /* wipe internal ME exits */ d = hmm->tbd1 + hmm->begin[1] + 2.; hmm->tbd1 = (hmm->tbd1 + 1.)/ d; hmm->begin[1] = (hmm->begin[1] + 1.)/ d; hmm->end[hmm->M] = 1.0; /* Main model transitions and emissions */ for (k = 1; k < hmm->M; k++) { P7PriorifyTransitionVector(hmm->t[k], pri); P7PriorifyEmissionVector(hmm->mat[k], pri, pri->mnum, pri->mq, pri->m, NULL); P7PriorifyEmissionVector(hmm->ins[k], pri, pri->inum, pri->iq, pri->i, NULL); } P7PriorifyEmissionVector(hmm->mat[hmm->M], pri, pri->mnum, pri->mq, pri->m, NULL); Plan7Renormalize(hmm); } /* Function: P7PriorifyEmissionVector() * * Purpose: Add prior pseudocounts to an observed * emission count vector and renormalize. * * Can return the posterior mixture probabilities * P(q | counts) if ret_mix[MAXDCHLET] is passed. * Else, pass NULL. * * Args: vec - the 4 or 20-long vector of counts to modify * pri - prior data structure * num - pri->mnum or pri->inum; # of mixtures * eq - pri->mq or pri->iq; prior mixture probabilities * e - pri->i or pri->m; Dirichlet components * ret_mix - filled with posterior mixture probabilities, or NULL * * Return: (void) * The counts in vec are changed and normalized to probabilities. */ void P7PriorifyEmissionVector(float *vec, struct p7prior_s *pri, int num, float eq[MAXDCHLET], float e[MAXDCHLET][MAXABET], float *ret_mix) { int x; /* counter over vec */ int q; /* counter over mixtures */ float mix[MAXDCHLET]; /* posterior distribution over mixtures */ float totc; /* total counts */ float tota; /* total alpha terms */ float xi; /* X_i term, Sjolander eq. 41 */ /* Calculate mix[], which is the posterior probability * P(q | n) of mixture component q given the count vector n * (side effect note: note that an insert vector in a PAM prior * is passed with num = 1, bypassing pam prior code; this means * that inserts cannot be mixture Dirichlets...) */ mix[0] = 1.0; if (pri->strategy == PRI_DCHLET && num > 1) { for (q = 0; q < num; q++) { mix[q] = eq[q] > 0.0 ? log(eq[q]) : -999.; mix[q] += Logp_cvec(vec, Alphabet_size, e[q]); } LogNorm(mix, num); /* now mix[q] is P(component_q | n) */ } else if (pri->strategy == PRI_PAM && num > 1) { /* pam prior uses aa frequencies as `P(q|n)' */ for (q = 0; q < Alphabet_size; q++) mix[q] = vec[q]; FNorm(mix, Alphabet_size); } /* Convert the counts to probabilities, following Sjolander (1996) */ totc = FSum(vec, Alphabet_size); for (x = 0; x < Alphabet_size; x++) { xi = 0.0; for (q = 0; q < num; q++) { tota = FSum(e[q], Alphabet_size); xi += mix[q] * (vec[x] + e[q][x]) / (totc + tota); } vec[x] = xi; } FNorm(vec, Alphabet_size); if (ret_mix != NULL) for (q = 0; q < num; q++) ret_mix[q] = mix[q]; } /* Function: P7PriorifyTransitionVector() * * Purpose: Add prior pseudocounts to transition vector, * which contains three different probability vectors * for m, d, and i. * * Args: t - state transitions, counts: 3 for M, 2 for I, 2 for D. * prior - Dirichlet prior information * * Return: (void) * t is changed, and renormalized -- comes back as * probability vectors. */ void P7PriorifyTransitionVector(float *t, struct p7prior_s *prior) { int ts; int q; float mix[MAXDCHLET]; float totm, totd, toti; /* total counts in three transition vecs */ float xi; /* Sjolander's X_i term */ mix[0] = 1.0; /* default is simple one component */ if ((prior->strategy == PRI_DCHLET || prior->strategy == PRI_PAM) && prior->mnum > 1) { for (q = 0; q < prior->tnum; q++) { mix[q] = prior->tq[q] > 0.0 ? log(prior->tq[q]) : -999.; mix[q] += Logp_cvec(t, 3, prior->t[q]); /* 3 match */ mix[q] += Logp_cvec(t+3, 2, prior->t[q]+3); /* 2 insert */ mix[q] += Logp_cvec(t+5, 2, prior->t[q]+5); /* 2 delete */ } LogNorm(mix, prior->tnum); /* mix[q] is now P(q | counts) */ } /* precalc some denominators */ totm = FSum(t,3); toti = t[TIM] + t[TII]; totd = t[TDM] + t[TDD]; for (ts = 0; ts < 7; ts++) { xi = 0.0; for (q = 0; q < prior->tnum; q++) { switch (ts) { case TMM: case TMI: case TMD: xi += mix[q] * (t[ts] + prior->t[q][ts]) / (totm + FSum(prior->t[q], 3)); break; case TIM: case TII: xi += mix[q] * (t[ts] + prior->t[q][ts]) / (toti + prior->t[q][TIM] + prior->t[q][TII]); break; case TDM: case TDD: xi += mix[q] * (t[ts] + prior->t[q][ts]) / (totd + prior->t[q][TDM] + prior->t[q][TDD]); break; } } t[ts] = xi; } FNorm(t, 3); /* match */ FNorm(t+3, 2); /* insert */ FNorm(t+5, 2); /* delete */ } /* Function: default_amino_prior() * * Purpose: Set the default protein prior. */ struct p7prior_s * default_amino_prior(void) { struct p7prior_s *pri; int q, x; /* default match mixture coefficients */ static float defmq[9] = { 0.178091, 0.056591, 0.0960191, 0.0781233, 0.0834977, 0.0904123, 0.114468, 0.0682132, 0.234585 }; /* default match mixture Dirichlet components */ static float defm[9][20] = { { 0.270671, 0.039848, 0.017576, 0.016415, 0.014268, 0.131916, 0.012391, 0.022599, 0.020358, 0.030727, 0.015315, 0.048298, 0.053803, 0.020662, 0.023612, 0.216147, 0.147226, 0.065438, 0.003758, 0.009621 }, { 0.021465, 0.010300, 0.011741, 0.010883, 0.385651, 0.016416, 0.076196, 0.035329, 0.013921, 0.093517, 0.022034, 0.028593, 0.013086, 0.023011, 0.018866, 0.029156, 0.018153, 0.036100, 0.071770, 0.419641 }, { 0.561459, 0.045448, 0.438366, 0.764167, 0.087364, 0.259114, 0.214940, 0.145928, 0.762204, 0.247320, 0.118662, 0.441564, 0.174822, 0.530840, 0.465529, 0.583402, 0.445586, 0.227050, 0.029510, 0.121090 }, { 0.070143, 0.011140, 0.019479, 0.094657, 0.013162, 0.048038, 0.077000, 0.032939, 0.576639, 0.072293, 0.028240, 0.080372, 0.037661, 0.185037, 0.506783, 0.073732, 0.071587, 0.042532, 0.011254, 0.028723 }, { 0.041103, 0.014794, 0.005610, 0.010216, 0.153602, 0.007797, 0.007175, 0.299635, 0.010849, 0.999446, 0.210189, 0.006127, 0.013021, 0.019798, 0.014509, 0.012049, 0.035799, 0.180085, 0.012744, 0.026466 }, { 0.115607, 0.037381, 0.012414, 0.018179, 0.051778, 0.017255, 0.004911, 0.796882, 0.017074, 0.285858, 0.075811, 0.014548, 0.015092, 0.011382, 0.012696, 0.027535, 0.088333, 0.944340, 0.004373, 0.016741 }, { 0.093461, 0.004737, 0.387252, 0.347841, 0.010822, 0.105877, 0.049776, 0.014963, 0.094276, 0.027761, 0.010040, 0.187869, 0.050018, 0.110039, 0.038668, 0.119471, 0.065802, 0.025430, 0.003215, 0.018742 }, { 0.452171, 0.114613, 0.062460, 0.115702, 0.284246, 0.140204, 0.100358, 0.550230, 0.143995, 0.700649, 0.276580, 0.118569, 0.097470, 0.126673, 0.143634, 0.278983, 0.358482, 0.661750, 0.061533, 0.199373 }, { 0.005193, 0.004039, 0.006722, 0.006121, 0.003468, 0.016931, 0.003647, 0.002184, 0.005019, 0.005990, 0.001473, 0.004158, 0.009055, 0.003630, 0.006583, 0.003172, 0.003690, 0.002967, 0.002772, 0.002686 }, }; pri = P7AllocPrior(); pri->strategy = PRI_DCHLET; /* Transition priors are subjective, but borrowed from GJM's estimations * on Pfam */ pri->tnum = 1; pri->tq[0] = 1.0; pri->t[0][TMM] = 0.7939; pri->t[0][TMI] = 0.0278; pri->t[0][TMD] = 0.0135; pri->t[0][TIM] = 0.1551; pri->t[0][TII] = 0.1331; pri->t[0][TDM] = 0.9002; pri->t[0][TDD] = 0.5630; /* Match emission priors are a mixture Dirichlet, * from Kimmen Sjolander (Blocks9) */ pri->mnum = 9; for (q = 0; q < pri->mnum; q++) { pri->mq[q] = defmq[q]; for (x = 0; x < 20; x++) pri->m[q][x] = defm[q][x]; } /* These insert emission priors are subjective. Observed frequencies * were obtained from PFAM 1.0, 10 Nov 96; * see ~/projects/plan7/InsertStatistics. * Inserts are slightly biased towards polar residues and away from * hydrophobic residues. */ pri->inum = 1; pri->iq[0] = 1.; pri->i[0][0] = 681.; /* A */ pri->i[0][1] = 120.; /* C */ pri->i[0][2] = 623.; /* D */ pri->i[0][3] = 651.; /* E */ pri->i[0][4] = 313.; /* F */ pri->i[0][5] = 902.; /* G */ pri->i[0][6] = 241.; /* H */ pri->i[0][7] = 371.; /* I */ pri->i[0][8] = 687.; /* K */ pri->i[0][9] = 676.; /* L */ pri->i[0][10] = 143.; /* M */ pri->i[0][11] = 548.; /* N */ pri->i[0][12] = 647.; /* P */ pri->i[0][13] = 415.; /* Q */ pri->i[0][14] = 551.; /* R */ pri->i[0][15] = 926.; /* S */ pri->i[0][16] = 623.; /* T */ pri->i[0][17] = 505.; /* V */ pri->i[0][18] = 102.; /* W */ pri->i[0][19] = 269.; /* Y */ return pri; } /* Function: default_nucleic_prior() * * Purpose: Set the default DNA prior. (for now, almost a Laplace) */ struct p7prior_s * default_nucleic_prior(void) { struct p7prior_s *pri; pri = P7AllocPrior(); pri->strategy = PRI_DCHLET; /* The use of the Pfam-trained amino acid transition priors * here is TOTALLY bogus. But it works better than a straight * Laplace, esp. for Maxmodelmaker(). For example, a Laplace * prior builds M=1 models for a single sequence GAATTC (at * one time an open "bug"). */ pri->tnum = 1; pri->tq[0] = 1.; pri->t[0][TMM] = 0.7939; pri->t[0][TMI] = 0.0278; pri->t[0][TMD] = 0.0135; pri->t[0][TIM] = 0.1551; pri->t[0][TII] = 0.1331; pri->t[0][TDM] = 0.9002; pri->t[0][TDD] = 0.5630; pri->mnum = 1; pri->mq[0] = 1.; FSet(pri->m[0], Alphabet_size, 1.); pri->inum = 1; pri->iq[0] = 1.; FSet(pri->i[0], Alphabet_size, 1.); return pri; } wise-2.4.1/src/HMMer2/iupac.c0000644000175000001440000001110507313404526015141 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* iupac.c * * Globally defines the IUPAC symbols for nucleic acid sequence * Slowly evolving into a repository of globals. Tue Apr 20 1993 */ #include "squid.h" #ifdef MEMDEBUG #include "dbmalloc.h" #endif char squid_version[] = "1.5m"; char squid_date[] = "Sept 1997"; /* Dayhoff f(i) amino acid occurrence frequencies. * From SwissProt 34: 21,210,388 residues * In alphabetic order by single-letter code. */ float aafq[20] = { 0.075520, /* A */ 0.016973, /* C */ 0.053029, /* D */ 0.063204, /* E */ 0.040762, /* F */ 0.068448, /* G */ 0.022406, /* H */ 0.057284, /* I */ 0.059398, /* K */ 0.093399, /* L */ 0.023569, /* M */ 0.045293, /* N */ 0.049262, /* P */ 0.040231, /* Q */ 0.051573, /* R */ 0.072214, /* S */ 0.057454, /* T */ 0.065252, /* V */ 0.012513, /* W */ 0.031985 /* Y */ }; char aa_alphabet[] = AMINO_ALPHABET; /* aa_index converts to pam's 27x27 scheme */ int aa_index[20] = { 0, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 19, 21, 22, 24 }; /* IUPAC code translations */ /* note: sequence chars are UPPER CASE */ struct iupactype iupac[] = { { 'A', 'T', NTA, NTT, }, { 'C', 'G', NTC, NTG, }, { 'G', 'C', NTG, NTC, }, { 'T', 'A', NTT, NTA, }, { 'U', 'A', NTU, NTA, }, { 'N', 'N', NTN, NTN, }, { ' ', ' ', NTGAP, NTGAP, }, { 'R', 'Y', NTR, NTY, }, { 'Y', 'R', NTY, NTR, }, { 'M', 'K', NTM, NTK, }, { 'K', 'M', NTK, NTM, }, { 'S', 'S', NTS, NTS, }, { 'W', 'W', NTW, NTW, }, { 'H', 'D', NTH, NTD, }, { 'B', 'V', NTB, NTV, }, { 'V', 'B', NTV, NTB, }, { 'D', 'H', NTD, NTH, }, }; char *stdcode1[65] = { "K", /* AAA */ "N", /* AAC */ "K", /* AAG */ "N", /* AAU */ "T", /* ACA */ "T", /* ACC */ "T", /* ACG */ "T", /* ACU */ "R", /* AGA */ "S", /* AGC */ "R", /* AGG */ "S", /* AGU */ "I", /* AUA */ "I", /* AUC */ "M", /* AUG */ "I", /* AUU */ "Q", /* CAA */ "H", /* CAC */ "Q", /* CAG */ "H", /* CAU */ "P", /* CCA */ "P", /* CCC */ "P", /* CCG */ "P", /* CCU */ "R", /* CGA */ "R", /* CGC */ "R", /* CGG */ "R", /* CGU */ "L", /* CUA */ "L", /* CUC */ "L", /* CUG */ "L", /* CUU */ "E", /* GAA */ "D", /* GAC */ "E", /* GAG */ "D", /* GAU */ "A", /* GCA */ "A", /* GCC */ "A", /* GCG */ "A", /* GCU */ "G", /* GGA */ "G", /* GGC */ "G", /* GGG */ "G", /* GGU */ "V", /* GUA */ "V", /* GUC */ "V", /* GUG */ "V", /* GUU */ "*", /* UAA */ "Y", /* UAC */ "*", /* UAG */ "Y", /* UAU */ "S", /* UCA */ "S", /* UCC */ "S", /* UCG */ "S", /* UCU */ "*", /* UGA */ "C", /* UGC */ "W", /* UGG */ "C", /* UGU */ "L", /* UUA */ "F", /* UUC */ "L", /* UUG */ "F", /* UUU */ "X", /* unknown */ }; char *stdcode3[65] = { "Lys", /* AAA */ "Asn", /* AAC */ "Lys", /* AAG */ "Asn", /* AAU */ "Thr", /* ACA */ "Thr", /* ACC */ "Thr", /* ACG */ "Thr", /* ACU */ "Arg", /* AGA */ "Ser", /* AGC */ "Arg", /* AGG */ "Ser", /* AGU */ "Ile", /* AUA */ "Ile", /* AUC */ "Met", /* AUG */ "Ile", /* AUU */ "Gln", /* CAA */ "His", /* CAC */ "Gln", /* CAG */ "His", /* CAU */ "Pro", /* CCA */ "Pro", /* CCC */ "Pro", /* CCG */ "Pro", /* CCU */ "Arg", /* CGA */ "Arg", /* CGC */ "Arg", /* CGG */ "Arg", /* CGU */ "Leu", /* CUA */ "Leu", /* CUC */ "Leu", /* CUG */ "Leu", /* CUU */ "Glu", /* GAA */ "Asp", /* GAC */ "Glu", /* GAG */ "Asp", /* GAU */ "Ala", /* GCA */ "Ala", /* GCC */ "Ala", /* GCG */ "Ala", /* GCU */ "Gly", /* GGA */ "Gly", /* GGC */ "Gly", /* GGG */ "Gly", /* GGU */ "Val", /* GUA */ "Val", /* GUC */ "Val", /* GUG */ "Val", /* GUU */ "***", /* UAA */ "Tyr", /* UAC */ "***", /* UAG */ "Tyr", /* UAU */ "Ser", /* UCA */ "Ser", /* UCC */ "Ser", /* UCG */ "Ser", /* UCU */ "***", /* UGA */ "Cys", /* UGC */ "Trp", /* UGG */ "Cys", /* UGU */ "Leu", /* UUA */ "Phe", /* UUC */ "Leu", /* UUG */ "Trp", /* UUU */ "XXX", /* unknown */ }; wise-2.4.1/src/HMMer2/weight.c0000644000175000001440000004555207313404530015337 0ustar philippusers/* SQUID - A C function library for biological sequence analysis * Copyright (C) 1992-1996 Sean R. Eddy * * This source code is distributed under terms of the * GNU General Public License. See the files COPYING * and GNULICENSE for further details. * */ /* weight.c * SRE, Thu Mar 3 07:56:01 1994 * * Calculate weights for sequences in an alignment. */ #include #include #include "squid.h" static void upweight(struct phylo_s *tree, int nseq, float *lwt, float *rwt, int node); static void downweight(struct phylo_s *tree, int nseq, float *lwt, float *rwt, float *fwt, int node); static float simple_distance(char *s1, char *s2); static int simple_diffmx(char **aseqs,int num, float ***ret_dmx); /* Function: GSCWeights() * * Purpose: Use Erik's tree-based algorithm to set weights for * sequences in an alignment. upweight() and downweight() * are derived from Graeme Mitchison's code. * * Args: aseq - array of (0..nseq-1) aligned sequences * ainfo - alignment info (including weights) * * Return: 1 on success, 0 on failure. * weights in ainfo are set. */ void GSCWeights(char **aseq, AINFO *ainfo) { float **dmx; /* distance (difference) matrix */ struct phylo_s *tree; float *lwt, *rwt; /* weight on left, right of this tree node */ float *fwt; /* final weight assigned to this node */ int i; /* Sanity check first */ if (ainfo->nseq == 1) { ainfo->wgt[0] = 1.0; return; } /* I use a simple fractional difference matrix derived by * pairwise identity. Perhaps I should include a Poisson * distance correction. */ MakeDiffMx(aseq, ainfo->nseq, &dmx); if (! Cluster(dmx, ainfo->nseq, CLUSTER_MIN, &tree)) Die("Cluster() failed"); /* Allocations */ if ((lwt = (float *) malloc (sizeof(float) * (2 * ainfo->nseq - 1))) == NULL || (rwt = (float *) malloc (sizeof(float) * (2 * ainfo->nseq - 1))) == NULL || (fwt = (float *) malloc (sizeof(float) * (2 * ainfo->nseq - 1))) == NULL) Die("malloc failed"); /* lwt and rwt are the total branch weight to the left and * right of a node or sequence. They are 0..2N-2. 0..N-1 are * the sequences; these have weight 0. N..2N-2 are the actual * tree nodes. */ for (i = 0; i < ainfo->nseq; i++) lwt[i] = rwt[i] = 0.0; /* recursively calculate rwt, lwt, starting at node nseq (the root) */ upweight(tree, ainfo->nseq, lwt, rwt, ainfo->nseq); /* recursively distribute weight across the tree */ fwt[ainfo->nseq] = ainfo->nseq; downweight(tree, ainfo->nseq, lwt, rwt, fwt, ainfo->nseq); /* collect the weights */ for (i = 0; i < ainfo->nseq; i++) ainfo->wgt[i] = fwt[i]; FMX2Free(dmx); FreePhylo(tree, ainfo->nseq); free(lwt); free(rwt); free(fwt); } static void upweight(struct phylo_s *tree, int nseq, float *lwt, float *rwt, int node) { int ld,rd; ld = tree[node-nseq].left; if (ld >= nseq) upweight(tree, nseq, lwt, rwt, ld); rd = tree[node-nseq].right; if (rd >= nseq) upweight(tree, nseq, lwt, rwt, rd); lwt[node] = lwt[ld] + rwt[ld] + tree[node-nseq].lblen; rwt[node] = lwt[rd] + rwt[rd] + tree[node-nseq].rblen; } static void downweight(struct phylo_s *tree, int nseq, float *lwt, float *rwt, float *fwt, int node) { int ld,rd; float lnum, rnum; ld = tree[node-nseq].left; rd = tree[node-nseq].right; if (lwt[node] + rwt[node] > 0.0) { fwt[ld] = fwt[node] * (lwt[node] / (lwt[node] + rwt[node])); fwt[rd] = fwt[node] * (rwt[node] / (lwt[node] + rwt[node])); } else { lnum = (ld >= nseq) ? tree[ld-nseq].incnum : 1.0; rnum = (rd >= nseq) ? tree[rd-nseq].incnum : 1.0; fwt[ld] = fwt[node] * lnum / (lnum + rnum); fwt[rd] = fwt[node] * rnum / (lnum + rnum); } if (ld >= nseq) downweight(tree, nseq, lwt, rwt, fwt, ld); if (rd >= nseq) downweight(tree, nseq, lwt, rwt, fwt, rd); } /* Function: VoronoiWeights() * * Purpose: Calculate weights using the scheme of Sibbald & * Argos (JMB 216:813-818 1990). The scheme is * slightly modified because the original algorithm * actually doesn't work on gapped alignments. * The sequences are assumed to be protein. * * Args: aseq - array of (0..nseq-1) aligned sequences * ainfo - info on the alignments, including weights * * Return: 1 on success, 0 on failure. * weights are set in ainfo */ void VoronoiWeights(char **aseq, AINFO *ainfo) { float **dmx; /* distance (difference) matrix */ float *halfmin; /* 1/2 minimum distance to other seqs */ char **psym; /* symbols seen in each column */ int *nsym; /* # syms seen in each column */ int symseen[27]; /* flags for observed syms */ char *randseq; /* randomly generated sequence */ int acol; /* pos in aligned columns */ int idx; /* index in sequences */ int symidx; /* 0..25 index for symbol */ int i; /* generic counter */ float min; /* minimum distance */ float dist; /* distance between random and real */ float challenge, champion; /* for resolving ties */ int itscale; /* how many iterations per seq */ int iteration; int best; /* index of nearest real sequence */ /* Sanity check first */ if (ainfo->nseq == 1) { ainfo->wgt[0] = 1.0; return; } itscale = 50; /* Precalculate 1/2 minimum distance to other * sequences for each sequence */ if (! simple_diffmx(aseq, ainfo->nseq, &dmx)) Die("simple_diffmx() failed"); if ((halfmin = (float *) malloc (sizeof(float) * ainfo->nseq)) == NULL) Die("malloc failed"); for (idx = 0; idx < ainfo->nseq; idx++) { for (min = 1.0, i = 0; i < ainfo->nseq; i++) { if (i == idx) continue; if (dmx[idx][i] < min) min = dmx[idx][i]; } halfmin[idx] = min / 2.0; } Free2DArray(dmx, ainfo->nseq); /* Set up the random sequence generating model. */ if ((psym = (char **) malloc (ainfo->alen * sizeof(char *))) == NULL || (nsym = (int *) malloc (ainfo->alen * sizeof(int))) == NULL) Die("malloc failed"); for (acol = 0; acol < ainfo->alen; acol++) if ((psym[acol] = (char *) malloc (27 * sizeof(char))) == NULL) Die("malloc failed"); /* #ifdef ORIGINAL_SIBBALD_ALGORITHM_IS_BROKEN */ for (acol = 0; acol < ainfo->alen; acol++) { memset(symseen, 0, sizeof(int) * 27); for (idx = 0; idx < ainfo->nseq; idx++) if (! isgap(aseq[idx][acol])) { if (isupper(aseq[idx][acol])) symidx = aseq[idx][acol] - 'A'; else symidx = aseq[idx][acol] - 'a'; if (symidx >= 0 && symidx < 26) symseen[symidx] = 1; } else symseen[26] = 1; /* a gap */ for (nsym[acol] = 0, i = 0; i < 26; i++) if (symseen[i]) { psym[acol][nsym[acol]] = 'A'+i; nsym[acol]++; } if (symseen[26]) { psym[acol][nsym[acol]] = ' '; nsym[acol]++; } } /* #endif ORIGINAL_SIBBALD_ALGORITHM_IS_BROKEN */ /* Note: the original Sibbald&Argos algorithm calls for * bounding the sampled space using a template-like random * sequence generator. However, this leads to one minor * and one major problem. The minor problem is that * exceptional amino acids in a column can have a * significant effect by altering the amount of sampled * sequence space; the larger the data set, the worse * this problem becomes. The major problem is that * there is no reasonable way to deal with gaps. * Gapped sequences simply inhabit a different dimensionality * and it's pretty painful to imagine calculating Voronoi * volumes when the N in your N-space is varying. * Note that all the examples shown by Sibbald and Argos * are *ungapped* examples. * * The best way I've found to circumvent this problem is * just not to bound the sampled space; count gaps as * symbols and generate completely random sequences. */ #ifdef ALL_SEQUENCE_SPACE for (acol = 0; acol < ainfo->alen; acol++) { strcpy(psym[acol], "ACDEFGHIKLMNPQRSTVWY "); nsym[acol] = 21; } #endif /* Sibbald and Argos algorithm: * 1) assign all seqs weight 0. * 2) generate a "random" sequence * 3) calculate distance to every other sequence * (if we get a distance < 1/2 minimum distance * to other real seqs, we can stop) * 4) if unique closest sequence, increment its weight 1. * if multiple closest seq, choose one randomly * 5) repeat 2-4 for lots of iterations * 6) normalize all weights to sum to nseq. */ if ((randseq = (char *) malloc ((ainfo->alen+1) * sizeof(char))) == NULL) Die("malloc failed"); FSet(ainfo->wgt, ainfo->nseq, 0.0); for (iteration = 0; iteration < itscale * ainfo->nseq; iteration++) { for (acol = 0; acol < ainfo->alen; acol++) randseq[acol] = (nsym[acol] == 0) ? ' ' : psym[acol][CHOOSE(nsym[acol])]; randseq[acol] = '\0'; champion = sre_random(); for (min = 1.0, idx = 0; idx < ainfo->nseq; idx++) { dist = simple_distance(aseq[idx], randseq); if (dist < halfmin[idx]) { best = idx; break; } if (dist < min) { champion = sre_random(); best = idx; min = dist; } else if (dist == min) { challenge = sre_random(); if (challenge > champion) { champion = challenge; best = idx; min = dist; } } } ainfo->wgt[best] += 1.0; } for (idx = 0; idx < ainfo->nseq; idx++) ainfo->wgt[idx] = ainfo->wgt[idx] / (float) itscale; free(randseq); free(nsym); free(halfmin); Free2DArray(psym, ainfo->alen); } /* Function: simple_distance() * * Purpose: For two identical-length null-terminated strings, return * the fractional difference between them. (0..1) * (Gaps don't count toward anything.) */ static float simple_distance(char *s1, char *s2) { int diff = 0; int valid = 0; for (; *s1 != '\0'; s1++, s2++) { if (isgap(*s1) || isgap(*s2)) continue; if (*s1 != *s2) diff++; valid++; } return (float) diff / (float) valid; } /* Function: simple_diffmx() * * Purpose: Given a set of flushed, aligned sequences, construct * an NxN fractional difference matrix using the * simple_distance rule. * * Args: aseqs - flushed, aligned sequences * num - number of aseqs * ret_dmx - RETURN: difference matrix (caller must free) * * Return: 1 on success, 0 on failure. */ static int simple_diffmx(char **aseqs, int num, float ***ret_dmx) { float **dmx; /* RETURN: distance matrix */ int i,j; /* counters over sequences */ /* Allocate */ if ((dmx = (float **) malloc (sizeof(float *) * num)) == NULL) Die("malloc failed"); for (i = 0; i < num; i++) if ((dmx[i] = (float *) malloc (sizeof(float) * num)) == NULL) Die("malloc failed"); /* Calculate distances, symmetric matrix */ for (i = 0; i < num; i++) for (j = i; j < num; j++) dmx[i][j] = dmx[j][i] = simple_distance(aseqs[i], aseqs[j]); /* Return */ *ret_dmx = dmx; return 1; } /* Function: BlosumWeights() * * Purpose: Assign weights to a set of aligned sequences * using the BLOSUM rule: * - do single linkage clustering at some pairwise identity * - in each cluster, give each sequence 1/clustsize * total weight. * * The clusters have no pairwise link >= maxid. * * Args: aseqs - alignment * ainfo - info on alignment, including weights * maxid - fractional identity (e.g. 0.62 for BLOSUM62) */ void BlosumWeights(char **aseqs, AINFO *ainfo, float maxid) { float **dmx; /* difference matrix */ struct phylo_s *tree; /* UPGMA tree */ float mindiff; /* minimum distance between clusters */ struct intstack_s *stack; int node; int i; /* Sanity check first */ if (ainfo->nseq == 1) { ainfo->wgt[0] = 1.0; return; } mindiff = 1.0 - maxid; /* first we do a difference matrix */ MakeDiffMx(aseqs, ainfo->nseq, &dmx); /* then we build a tree */ Cluster(dmx, ainfo->nseq, CLUSTER_MIN, &tree); /* Find clusters below mindiff. * The rule is: * -traverse the tree * -if the node has dropped below mindiff, then * make current node a cluster. */ FSet(ainfo->wgt, ainfo->nseq, 1.0); stack = InitIntStack(); PushIntStack(stack, 0); /* push root on stack to start */ while (PopIntStack(stack, &node)) { if (tree[node].diff < mindiff) { /* we're at a cluster */ for (i = 0; i < ainfo->nseq; i++) if (tree[node].is_in[i]) ainfo->wgt[i] = 1.0 / (float) tree[node].incnum; } else /* we're not a cluster, keep traversing */ { if (tree[node].right >= ainfo->nseq) PushIntStack(stack, tree[node].right - ainfo->nseq); if (tree[node].left >= ainfo->nseq) PushIntStack(stack, tree[node].left - ainfo->nseq); } } FreeIntStack(stack); FreePhylo(tree, ainfo->nseq); FMX2Free(dmx); return; } /* Function: FilterAlignment() * * Purpose: Constructs a new alignment by removing near-identical * sequences from a given alignment (where identity is * calculated *based on the alignment*). * Does not affect the given alignment. * Keeps earlier sequence, discards later one. * * Args: aseq -- given alignment * nseq -- number of seqs in alignment * ainfo -- associated info for aseq * ident -- [0.0-1.0] above this fractional identity, remove the seq * ret_anew -- RETURN: new alignment * ret_nnew -- RETURN: # seqs in new alignment * ret_newinfo - RETURN: info assoc with new alignment * * Return: (void) * ret_anew must be free'd by caller: FreeAlignment(). */ void FilterAlignment(char **aseq, int nseq, AINFO *ainfo, float cutoff, char ***ret_anew, int *ret_nnew, AINFO **ret_newinfo) { char **anew; int nnew; AINFO *newinfo; int *list; float ident; int i,j, idx; int remove; /* find which seqs to keep (list) */ /* diff matrix; allow ragged ends */ if ((list = (int *) malloc (sizeof(int) * nseq)) == NULL) Die("malloc failed"); nnew = 0; for (i = 0; i < nseq; i++) { remove = FALSE; for (j = 0; j < nnew; j++) { ident = PairwiseIdentity(aseq[i], aseq[list[j]]); if (ident > cutoff) { remove = TRUE; printf("removing %12s -- fractional identity %.2f to %s\n", ainfo->sqinfo[i].name, ident, ainfo->sqinfo[list[j]].name); break; } } if (remove == FALSE) list[nnew++] = i; } /* make new alignment */ newinfo = MallocOrDie(sizeof(AINFO)); AllocAlignment(nnew, ainfo->alen, &anew, newinfo); for (idx = 0; idx < nnew; idx++) strcpy(anew[idx], aseq[list[idx]]); for (idx = 0; idx < nnew; idx++) SeqinfoCopy(&(newinfo->sqinfo[idx]), &(ainfo->sqinfo[list[idx]])); /* copy optional info */ if (ainfo->flags & AINFO_RF) { newinfo->flags |= AINFO_RF; newinfo->rf = Strdup(ainfo->rf); } if (ainfo->flags & AINFO_CS) { newinfo->flags |= AINFO_CS; newinfo->cs = Strdup(ainfo->cs); } MingapAlignment(anew, newinfo); free(list); *ret_anew = anew; *ret_nnew = nnew; *ret_newinfo = newinfo; } /* Function: SampleAlignment() * * Purpose: Constructs a new, smaller alignment by sampling a given * number of sequences at random. Does not change the * alignment nor the order of the sequences. * * Not a weighting method, but this is as good a place * as any, since the code is borrowed from FilterAlignment(). * * If you ask for a sample that is larger than nseqs, * it silently returns the original alignment. * * Args: aseq -- given alignment * nseq -- number of seqs in alignment * ainfo -- associated info for aseq * sample -- number of seqs to sample * ret_anew -- RETURN: new alignment * ret_nnew -- RETURN: # seqs in new alignment * ret_newinfo - RETURN: info assoc with new alignment * * Return: (void) * ret_anew must be free'd by caller: FreeAlignment(). */ void SampleAlignment(char **aseq, int nseq, AINFO *ainfo, int sample, char ***ret_anew, int *ret_nnew, AINFO **ret_newinfo) { char **anew; int nnew; AINFO *newinfo; int *list; /* array for random selection w/o replace */ int *useme; /* array of flags 0..nseq-1: TRUE to use */ int i, idx; int len; /* Allocations */ list = (int *) MallocOrDie (sizeof(int) * nseq); useme = (int *) MallocOrDie (sizeof(int) * nseq); for (i = 0; i < nseq; i++) { list[i] = i; useme[i] = FALSE; } /* Sanity check. */ if (sample >= nseq) { /* use everything and don't complain */ for (i = 0; i < nseq; i++) useme[i] = TRUE; nnew = nseq; } else { /* random selection w/o replacement */ for (len = nseq, i = 0; i < sample; i++) { idx = CHOOSE(len); printf("chose %d: %s\n", list[idx], ainfo->sqinfo[list[idx]].name); useme[list[idx]] = TRUE; list[idx] = list[--len]; } nnew = sample; } /* make new alignment */ if ((anew = (char **) malloc (sizeof(char *) * nnew)) == NULL || (newinfo = (AINFO *) malloc (sizeof(AINFO))) == NULL) Die("malloc failed"); for (idx = 0; idx < nnew; idx++) if ((anew[idx] = (char *) malloc (ainfo->alen + 1)) == NULL) Die("malloc failed"); if ((newinfo->sqinfo = (SQINFO *) malloc (sizeof(SQINFO) * nnew)) == NULL) Die("malloc failed"); for (idx = i = 0; idx < nseq; idx++) if (useme[idx]) { anew[i] = Strdup(aseq[idx]); SeqinfoCopy(&(newinfo->sqinfo[i]), &(ainfo->sqinfo[idx])); i++; } newinfo->nseq = nnew; newinfo->alen = ainfo->alen; /* copy optional info */ if (ainfo->flags & AINFO_RF) { newinfo->flags |= AINFO_RF; newinfo->rf = Strdup(ainfo->rf); } if (ainfo->flags & AINFO_CS) { newinfo->flags |= AINFO_CS; newinfo->cs = Strdup(ainfo->cs); } MingapAlignment(anew, newinfo); free(list); free(useme); *ret_anew = anew; *ret_nnew = nnew; *ret_newinfo = newinfo; } wise-2.4.1/src/external/0000755000175000001440000000000010670453604014467 5ustar philippuserswise-2.4.1/src/external/mott/0000755000175000001440000000000010670453604015452 5ustar philippuserswise-2.4.1/src/external/mott/makefile0000644000175000001440000000074007627676322017167 0ustar philippusers all : libmott.a clean : rm -f *.[oa] libmott.a : mott_api.o gaplib.o wise2_mott_bridge.o ar $(AR_OPTIONS) libmott.a $? -if test -x /bin/ranlib; then /bin/ranlib libmott.a; else exit 0; fi -if test -x /usr/bin/ranlib; then /usr/bin/ranlib libmott.a; else exit 0; fi wise2_mott_bridge.o : wise2_mott_bridge.c $(CC) $(CFLAGS) -I../../dynlibsrc -I../../base wise2_mott_bridge.c CC = cc CFLAGS = -Wall -g3 -DPTHREAD -O2 -c LFLAGS = -g -L../base/ -lm AR_OPTIONS = ru wise-2.4.1/src/external/mott/mott_api.c0000755000175000001440000001601407627676322017453 0ustar philippusers#include #include #include #include"gapstat.h" double default_lambda0, default_K0, default_Kplus, default_H, default_r, default_s, default_alpha; int count=0; int gap_init=0; int gap_extend=0; int **matrix=NULL; double pval_threshold=0; int initialised=0; int KarlinAltschulStatistics2( int **matrix, double *freq1, double *freq2, double *lambda, double *Kminus, double *Kplus, double *H, double *r, double *s ); double * PseudoResidueFrequencies2( char *seq, int len, int pseudo_len ); double *RobinsonResidueFrequencies2 (void); double *GetHistogram( double *freq1, double *freq2, int **matrix, int *hmin, int *hmax, double *mean ); int InitPvaluesMott( int **Matrix, int Gap_init, int Gap_extend, double Pval_threshold ) { /* sets up the P-value calculation. Should be called once at the start of the program. The substitution matrix and gap penalties are passed in at this point and cached. Note the a gap of length k costs Gap_init + k*Gap_extend; Matrix is a **int for which matrix[i][j] is the substitution score for symbols i, j. Only uppercase letters 'A' through 'Z' matter. Pval_threshold should be a fairly small value such as 1.0e-5, such that pvalues greater than this are only evaluated relative to the default protein sequence composition. This speeds things up a lot. return value is an int: 0 => FAILURE, because mean substitution score is positive: You must change the substitutio matrix and re-evaluate InitPvaluesMott() 1 => SUCCESS, everything is OK to commence the search. 2 => WARNING: the computed P-values are likely to be inaccurate because the scoring scheme is lax. You are recommended to increase the gap penalty and re-evaluate InitPvaluesMott(). */ double *freq0 = RobinsonResidueFrequencies2(); matrix = Matrix; gap_init = Gap_init; gap_extend = Gap_extend; pval_threshold = Pval_threshold; if ( (initialised = KarlinAltschulStatistics2( matrix, freq0, freq0, &default_lambda0, &default_K0, &default_Kplus, &default_H, &default_r, &default_s )) ) { default_alpha = 2*default_s*exp(-default_lambda0*(gap_init+gap_extend))/(1-exp(-default_lambda0*gap_extend)); if ( default_alpha > 0.25 ) initialised = 2; } free(freq0); return initialised; } double SW_PValueMott( double SWScore, char *seqA, char *seqB, int lengthA, int lengthB, int *ok ) { /* returns the PValue for the SWScore, for the two sequences. ok == 1 means the P-value is reliable ok == 0 means a problem was encountered - most probably the mean symbol match was positive for the sequences, so no stats can be computed ok == 2 means the Pvalue was computed but is probably unreliable becuase the scoring scheme is too lax for this comparison ok == -1 means the initialisation was not performed, and so no pvalue was computed. */ double pval1, pval2; double theta, logkappa; double lambda0, K0, Kplus, H, r, s, alpha; *ok = -1; pval2 = 1.0; if ( initialised ) { pval1 = pval2 = EmpiricalGEM( default_lambda0, default_K0, default_H, default_alpha, lengthA, lengthB, &theta, &logkappa, SWScore ); count++; *ok = 1; /* printf ( "pval1 %e default_alpha %e threshold %e\n", pval1, default_alpha, pval_threshold ); */ if ( pval1 < pval_threshold ) { double *freqA = PseudoResidueFrequencies2( seqA, lengthA, 100 ); double *freqB = PseudoResidueFrequencies2( seqB, lengthB, 100 ); if ( KarlinAltschulStatistics2( matrix, freqA, freqB, &lambda0, &K0, &Kplus, &H, &r, &s ) ) { alpha = 2*s*exp(-lambda0*(gap_init+gap_extend))/(1-exp(-lambda0*gap_extend)); if ( alpha > 0.25 ) *ok = 2; else *ok = 1; pval2 = EmpiricalGEM( lambda0, K0, H, alpha, lengthA, lengthB, &theta, &logkappa, SWScore ); } else { *ok = 0; pval2 = 1.0; } free(freqA); free(freqB); } } return pval2; } int KarlinAltschulStatistics2( int **matrix, double *freq1, double *freq2, double *lambda, double *Kminus, double *Kplus, double *H, double *r, double *s ) { /* compute all necessary quantities for ungapped statistics inputs are the matrix and symbol frequencies freq1, freq2 outputs are lambda the exponential rate Kminus, Kplus bounds on K H the entropy (for edge corrections) r, s quantities needed for GEM gapped statistics */ double *h; int hmin, hmax; double R1, R2, R3; double mean; h = GetHistogram( freq1, freq2, matrix, &hmin, &hmax, &mean ); if ( mean < 0.0 && ( *lambda = solve_for_lambda( h, hmin, hmax )) > 0 ) { *H = entropy_H(h,hmin,hmax,*lambda); iglehart( h, hmin, hmax, *lambda, -1, 1, &R1, &R2, &R3, Kplus, Kminus ); *Kplus /= R3; *Kminus /= R3; *s = R1; *r = R2; free(h+hmin); /* fprintf(stderr, "lambda=%8.6f K-=%8.6f K+=%8.6f H=%8.4f r=%8.4f s=%8.4f\n", *lambda, *Kplus, *Kminus, *H, *r, *s); */ return 1; } else { int n; /* fprintf( stderr, "mean : %e h distribution:\n", mean); for(n=hmin;n<=hmax;n++){ fprintf(stderr, "%5d %e\n", n, h[n]); } */ free(h+hmin); return 0; } } double *GetHistogram( double *freq1, double *freq2, int **matrix, int *hmin, int *hmax, double *mean ) { int i, j, n; double *h; *hmin = INT_MAX; *hmax = INT_MIN; *mean = 0.0; for(i='A';i<='Z';i++) { for(j='A';j<='Z';j++) { if ( (n=matrix[i][j]) > *hmax ) *hmax = n; if ( (n=matrix[i][j]) < *hmin ) *hmin = n; } } h = (double*)calloc(*hmax-*hmin+1,sizeof(double))-*hmin; for(i='A';i<='Z';i++) for(j='A';j<='Z';j++) { h[matrix[i][j]]+=freq1[i]*freq2[j]; } for(j=*hmin;j<=*hmax;j++) *mean += h[j]*j; return h; } double * PseudoResidueFrequencies2( char *seq, int len, int pseudo_len ) { int n, c; double *freq = RobinsonResidueFrequencies2(); double t=0.0; if ( len > 0 ) { for(c='A';c<='Z';c++) freq[c] = pseudo_len*freq[c]; for(n=0;n 0 ) for(c='A';c<='Z';c++) { freq[c] /= t; } } return freq; } double * RobinsonResidueFrequencies2 (void) { /* these are are amino-acid frequencies used by blast, from Robinson & Robinson */ double *freq = (double*)calloc(256, sizeof(double)); int c; double t=0.0; freq['A'] = 35155; freq['R'] = 23105; freq['N'] = 20212; freq['D'] = 24161; freq['C'] = 8669; freq['Q'] = 19208; freq['E'] = 28354; freq['G'] = 33229; freq['H'] = 9906; freq['I'] = 23161; freq['L'] = 40625; freq['K'] = 25872; freq['M'] = 10101; freq['F'] = 17367; freq['P'] = 23435; freq['S'] = 32070; freq['T'] = 26311; freq['W'] = 5990; freq['Y'] = 14488; freq['V'] = 29012; freq['*'] = 0.00+0; freq['X'] = 0.00+0; freq['x'] = 0.00+0; freq['.'] = 0.0; t = 0.0; for(c='A';c<='Z';c++) t += freq[c]; for(c='A';c<='Z';c++){ freq[toupper(c)] = freq[c] /= t; } return freq; } wise-2.4.1/src/external/mott/mott_api.h0000755000175000001440000000027507627676322017462 0ustar philippusersint InitPvaluesMott( int **Matrix, int Gap_init, int Gap_extend, double Pval_threshold ); double SW_PValueMott( double SWScore, char *seqA, char *seqB, int lengthA, int lengthB, int *ok ); wise-2.4.1/src/external/mott/gapstat.h0000755000175000001440000000345607615515527017311 0ustar philippusersvoid init_lambda( double lambda ); double e2lk( int k); int KarlinAltschulStatistics( int **matrix, double *freq1, double *freq2, double *lambda, double *Kminus, double *Kplus, double *H, double *r, double *s ) ; double lambda_func( double lambda, double *h, int hmin, int hmax); double solve_for_lambda( double *h, int hmin, int hmax ); double entropy_H( double *h, int hmin, int hmax, double lambda ) ; double HSP_length_correction( double H, double K, double lambda, int len1, int len2); void iglehart( double *h, int hmin, int hmax, double lambda, double xmu, int delta, double *R1, double *R2, double *R3, double *Kplus, double *Kminus ); double *get_h( int **matrix, double *freq1, double *freq2, int *hmin, int *hmax, double *mean ); double associated_dam_eqn( double *distribution, int min, int max, double lambda, double **transient, int *cn); int gem_statistics( double gap_start, double gap_extend, double lambda, double s, double Kplus, double Kminus, double *alpha, double *theta1, double *theta2, double *K1, double *K2 ); double upper_objective( double alpha, double beta ); double lower_objective( double alpha, double beta ); double gapped_theta( double alpha, double (*objective)( double, double) ); double GEM_length_correction( double L_HSP, double alpha, int len1, int len2 ); double regression_coeffs( double lambda, double Kmin, double H, double alpha, int len1, int len2, double *theta, double *kappa, double score ); double empirical_GEM( double lambda0, double K0, double H, double alpha, int len1, int len2, double *theta, double *logkappa, double score ); double EmpiricalGEM( double lambda0, double K0, double H, double alpha, int len1, int len2, double *theta, double *logkappa, double score ); double AutoIncreaseGapPenalty( double s, double lambda0, double alpha_max, int *A, int *B ); wise-2.4.1/src/external/mott/wise2_mott_bridge.c0000644000175000001440000000307707627665626021256 0ustar philippusers #include "wise2_mott_bridge.h" #include "mott_api.h" #include "compmat.h" static boolean has_init = FALSE; static void init_mott_evalue_standard_sw(void) { CompMat * mat; int ** matrix; int i,j; matrix = calloc(100,sizeof(int*)); for(i='A';i<'Z'+1;i++) { matrix[i] = calloc(100,sizeof(int)); } mat = read_Blast_file_CompMat("blosum62.bla"); for(i='A';i<='Z';i++) { for(j='A';j<='Z';j++) { matrix[i][j] = mat->comp[i-'A'][j-'A']; } } if( (i=InitPvaluesMott(matrix,12,2,1.0e-5)) != 1 ) { fatal("Unable to initiate Mott scores. [%d] Have to bail!",i); } free_CompMat(mat); has_init = TRUE; } static double calc_evalue_Mott(void * data,Sequence * a,Sequence * b,int raw_score,int database_size) { double prob; int ok; if( has_init == FALSE ) { init_mott_evalue_standard_sw(); } prob = SW_PValueMott(raw_score,a->seq,b->seq,a->len,b->len,&ok); return prob * database_size; } static double calc_bits_Mott(void * data,int lengtha,int lengthb,int raw_score) { return (raw_score/2.0); } static char * attribution_Mott(void * data) { return "Mott R (2000) Accurate Formula for P-values of gapped local sequence\n and profile alignments J. Mol Biol. 300:649-659"; } static void free_data_noop(void * data) { return; } SearchStatInterface * new_Mott_SearchStatInterface(void) { SearchStatInterface * out; out = SearchStatInterface_alloc(); out->calc_evalue = calc_evalue_Mott; out->calc_bits = calc_bits_Mott; out->attribution = attribution_Mott; out->free_data = free_data_noop; return out; } wise-2.4.1/src/external/mott/wise2_mott_bridge.h0000644000175000001440000000023407627672465021252 0ustar philippusers #ifndef WISE2_MOTT_BRIDGE #define WISE2_MOTT_BRIDGE #include "searchstatinterface.h" SearchStatInterface * new_Mott_SearchStatInterface(void); #endif wise-2.4.1/src/external/mott/gaplib.c0000755000175000001440000003204607615515527017074 0ustar philippusers/* ARIADNE V.1.0 GAPSTAT - functions for calculating the statistics of gapped alignment scores Copyright Richard Mott 2000 Wellcome Trust Centre For Human Genetics Roosevelt Drive Oxford OX3 7AD */ #include #include #include #include #include"gapstat.h" /************************************************************************/ /* 1. */ /* Karlin-Altschul statistics for HSPs */ /************************************************************************/ int KarlinAltschulStatistics( int **matrix, double *freq1, double *freq2, double *lambda, double *Kminus, double *Kplus, double *H, double *r, double *s ) { /* compute all necessary quantities for ungapped statistics inputs are the matrix and symbol frequencies freq1, freq2 outputs are lambda the exponential rate Kminus, Kplus bounds on K H the entropy (for edge corrections) r, s quantities needed for GEM gapped statistics */ double *h; int hmin, hmax; double R1, R2, R3; double mean; h = get_h( matrix, freq1, freq2, &hmin, &hmax, &mean ); if ( (*lambda = solve_for_lambda( h, hmin, hmax )) > 0 ) { *H = entropy_H(h,hmin,hmax,*lambda); iglehart( h, hmin, hmax, *lambda, -1, 1, &R1, &R2, &R3, Kplus, Kminus ); *Kplus /= R3; *Kminus /= R3; *s = R1; *r = R2; /* printf("lambda=%8.6f K-=%8.6f K+=%8.6f H=%8.4f r=%8.4f s=%8.4f\n", *lambda, *Kplus, *Kminus, *H, *r, *s); */ return 1; } else return 0; /* error condition */ } double lambda_func( double lambda, double *h, int hmin, int hmax) { int c; double d, l; double f = 0.0; l = exp(lambda); d = exp(lambda*hmin); for(c=hmin;c<=hmax;c++) { f += d*h[c]; d *= l; } return f-1.0; } /* Solve the equation 1 = sum_{s} exp(lambda s) h(s) to get the exponential rate constant for HSPs */ double solve_for_lambda( double *h, int hmin, int hmax ) { double left=0.001, right=1.0, midpt; double fleft, fright; double fmidpt; /* lambda, f;*/ fleft = lambda_func( left, h, hmin, hmax ); fright = lambda_func( right, h, hmin, hmax ); if ( fleft*fright > 0.0 ) { fprintf(stderr, "ERROR could not bracket root, %g %g %g %g\n", left, fleft, right, fright); return -1.0; } while( right-left > 1.0e-6 ) { midpt = (left+right)/2.0; fmidpt = lambda_func( midpt, h, hmin, hmax ); if ( fmidpt < 0.0 ) { left = midpt; fleft = fmidpt; } else { right = midpt; fright = fmidpt; } } return midpt; } double entropy_H( double *h, int hmin, int hmax, double lambda ) { /* compute the entropy of a score */ int i; /*, j;*/ double H=0.0; double l = exp(lambda); double d = exp(lambda*hmin); for(i=hmin;i<=hmax;i++) { H += h[i]*d*i; d *= l; } return H; } double HSP_length_correction( double H, double K, double lambda, int len1, int len2 ) { /* Altschul-Gish length correction formula */ double L_HSP; L_HSP = log(K*len1*len2)/(H*lambda); /* printf("E_HSP %8.4f L_HSP %8.4f K_HSP %8.4f\n", H, L_HSP, log(K*len1*len2) ); */ return L_HSP; } /* gapped alignment statistics */ int gem_statistics( double gap_start, double gap_extend, double lambda, double s, double Kplus, double Kminus, double *alpha, double *theta1, double *theta2, double *K1, double *K2 ) { /* alpha and theta */ /* if *alpha > 0 then don't compute it */ if ( *alpha <= 0 ) { if ( lambda*gap_extend > 0.0 ) *alpha = 2*s*exp(-lambda*(gap_start+gap_extend))/(1-exp(-lambda*gap_extend)); else *alpha = 1.0e10; } if ( *alpha < 0.44 ) { /* logarithmic domain */ *theta2 = gapped_theta( *alpha, &upper_objective ); *theta1 = gapped_theta( *alpha, &lower_objective ); /* printf("theta1 = %.4f theta2 = %.4f\n", *theta1, *theta2 ); printf("lambda1 = %.4f lambda2 = %.4f\n", lambda* *theta1, lambda* *theta2 ); */ /* upper bound */ *K2 = Kplus * *theta2 * *theta2; /* lower bound */ if ( *theta1 < 1.0 ) *K1 = Kminus* *theta1 * *theta1 * (1-exp(- *alpha))/(1- *theta1); else *K1 = Kminus; return 1; } else { /* linear domain */ *theta2 = *theta1 = *K1 = *K2 = 1.0e-8; return 0; } } /************************************************************************/ /* 2. General Routines */ /************************************************************************/ /* compute the distribution h(x), the probablity that two residues have score x, given the current score matrix and residue frequency distributions */ double *get_h( int **matrix, double *freq1, double *freq2, int *hmin, int *hmax, double *mean ) { int m, n; double *distribution; *hmax = -10000; *hmin = +10000; *mean = 0.0; for(n=0;n<256;n++) for(m=0;m<256;m++) { if ( matrix[n][m] > *hmax ) *hmax = matrix[n][m]; if ( matrix[n][m] < *hmin ) *hmin = matrix[n][m]; } distribution = (double*)calloc((*hmax)- (*hmin)+1,sizeof(double))- *hmin; /* printf("min %d max %d\n", *hmin, *hmax ); */ for(n=0;n<256;n++) for(m=0;m<256;m++) distribution[matrix[m][n]] += freq1[n]*freq2[m]; for(n=*hmin;n<=*hmax;n++) *mean += distribution[n]*n; /* { double s=0.0; printf( "mean = %e\n", *mean ); for(n=*hmin;n<=*hmax;n++) { printf("%d dist %e %e\n", n, distribution[n], s=s+distribution[n]); } } */ return distribution; } /* Solve the Associated Dam Equation */ double associated_dam_eqn( double *distribution, int min, int max, double lambda, double **transient, int *cn) { int its=100; double *f = (double*)calloc(max-min+1,sizeof(double))-min; double **h = (double**)calloc(its,sizeof(double*)); double *converged; double x, r=0.0; int t, i, Max=0, Max1, k, hi; double d, l; h[1] = (double*)calloc(max+1,sizeof(double)); h[1][max] = 0.0; for(i=max-1;i>=0;i--) h[1][i] = h[1][i+1] + distribution[i+1]; r=0.0; d = exp(lambda*min); l = exp(lambda); for(i=min;i<=max;i++) { f[i] = distribution[i]*d; d *= l; r += f[i]; } d = 1.0; for(i=0;i<=max;i++){ h[1][i] *= d; d *= l; } for(k=2;k max ? max : t ; h[k][t] = t > max ? 0.0 : h[1][t] ; for(i=hi;i>=min && (t-i) <= Max1;i--) { h[k][t] += f[i]*h[k-1][t-i]; } } } r = 0.0; k--; *cn=0; for(t=0;t<=Max;t++) { if ( h[k][t] > 0.0 ) { x = h[k-1][t]/h[k][t]; if ( fabs(1.0-x) < 0.0001 ) { (*cn)++; /* printf("%5d %8.6f %8.6f converged\n", t, h[k][t], x ); */ } else break; } } converged = (double*)calloc((*cn)+1,sizeof(double)); for(t=0;t<=*cn;t++) converged[t] = h[k][t]; *transient = converged; while(t>0 && h[k][t] < h[k][t-1]) t--; r = h[k][t]; /* printf("t=%d r=%g\n", t, r); */ return r; } /* compute objective function for upper_bound */ double upper_objective( double alpha, double beta ) { double f = beta*log(alpha) + lgamma(1.0-beta); return f; } /* compute objective function for upper_bound */ double lower_objective( double alpha, double beta ) { double f = log(2.0) + beta*log(alpha/2.0) -log(1.0-beta) -log(2.0-beta); return f; } /* solve for theta(alpha) */ double gapped_theta( double alpha, double (*objective)( double, double) ) { /*double beta;*/ double left, right, midpt; double fleft, fright, fmidpt; left = 0.001; right = 0.999; fleft = (*objective)( alpha, left ); fright = (*objective)( alpha, right ); if ( fleft*fright >= 0.0 ) { if ( alpha < 1.0e-3 ) return 1.0; else { fprintf(stderr, "ERROR could not bracket root %e %e %e %e alpha %e\n", left, fleft, right, fright, alpha); return 0.0; } } while( right-left > 1.0e-6 ) { midpt = (left+right)/2.0; fmidpt = (*objective)( alpha, midpt ); if ( fleft < fright ) { if ( fmidpt < 0.0 ) { left = midpt; fleft = fmidpt; } else { right = midpt; fright = fmidpt; } } else { if ( fmidpt > 0.0 ) { left = midpt; fleft = fmidpt; } else { right = midpt; fright = fmidpt; } } /* printf("left %e right %e\n", left, right ); */ } return midpt; } void iglehart( double *h, int hmin, int hmax, double lambda, double xmu, int delta, double *R1, double *R2, double *R3, double *Kplus, double *Kminus ) { /* Use Igleharts formulae to compute the constants R1, R2, R3 for a random walk with negative drift If S(n) = sum_{1}^{n} X(i), then A = sum_{n} S(n) has asymptotic distribution P( A > t ) ~ R1 exp( -lambda t ) [R1 == s in GEM statistics ] If N is the time of first entry into negative values, then B = max{n=1}^{N} S(n) and P( B > t ) ~ R2 exp( -lambda t ) [R2 == s in GEM stats] Finally R3 = E(N), expected time before hitting negative values In what follows: Xmu = E( X exp(lambda X) ) ESN = 1 - E( exp( lambda S(N) ) ) EN = E(N) Then R1 = [ 1 - E( exp( lambda S(N) ) ) ] / [ L * Xmu * E(N) ] = ESN / ( lambda * Xmu * EN ) and R2 = R1 * [ 1 - E( exp( lambda S(N) ) ) ] = R1 * ESN R3 = E(N) also: L = lambda for cts distributions, or L = (exp(lambda*delta)-1)/delta for arithmetic distributions, where delta is the span EN = exp ( sum_{k>0} Pr( S(k)>=0 ) / k ) ESN = exp ( -sum_{k>0} E( exp( lambda S(k)) ; S(k)<0 ) / k ) */ double Xmu; double ESN; double EN; double SN; double last_EN=1.0e10; double last_ESN=1.0e10; double *s, *t; int n, k, i; int min, max; int min1, max1; double mean, expect, total; double d, eld, l=exp(lambda); double *s_ptr=NULL; double *t_ptr; /* Xmu */ if ( xmu > 0.0 ) { Xmu = xmu; } else { Xmu = 0.0; mean = 0.0; d = exp(lambda*hmin); for(k=hmin;k<=hmax;k++) { Xmu += h[k]*k*d; mean += h[k]*d; d *= l; } } /* EN and ESN */ t_ptr = (double*)calloc(hmax-hmin+1,sizeof(double)); t = t_ptr-hmin; for(k=hmin;k<=hmax;k++) t[k] = h[k]; SN = 0.0; for(k=0;k<=hmax;k++) SN += t[k]; EN = SN; ESN = 0.0; SN = 0.0; d = exp(lambda*hmin); for(k=hmin;k<0;k++) { SN += t[k]*d; d *= l; } ESN = SN; mean = 0.0; total=0.0; for(k=hmin;k<=hmax;k++) { mean += t[k]*k; total += t[k]; } for(n=2;n<100;n++) { min = n*hmin; max = n*hmax; s_ptr = (double*)calloc(max-min+1,sizeof(double)); s = s_ptr - min; for(k=min;k<=max;k++) { min1 = hmin; if ( k-min1 > (n-1)*hmax ) min1 = k-(n-1)*hmax; max1 = hmax; if ( k-max1 < (n-1)*hmin ) max1 = k-(n-1)*hmin; for(i=min1;i<=max1;i++) { s[k] += h[i]*t[k-i]; } } SN = 0.0; for(k=0;k<=max;k++) SN += s[k]; SN /= n; EN += SN; SN = 0.0; d = exp(lambda*min); for(k=min;k<0;k++){ SN += s[k]*d; d *= l; } SN /= n; ESN += SN; expect = 0.0; total =0.0; for(k=min;k<=max;k++) { expect += k*s[k]; total += s[k]; } if ( fabs(last_EN-EN) < 1.0e-4 && fabs(last_ESN-ESN) < 1.0e-4 ) { free(t_ptr); break; } last_EN = EN; last_ESN = ESN; free(t_ptr); t_ptr = s_ptr; t = s; } free(s_ptr); EN = exp(EN); ESN = exp(-ESN); eld = exp(lambda*delta); *Kplus = ESN / ( (1-1.0/eld) * Xmu * EN / delta ); /* K+ */ *Kminus = *R1 = ESN / ( (eld-1.0) * Xmu * EN / delta ); /* K- */ *R2 = *R1 *ESN; *Kplus *= ESN; *Kminus *= ESN; *R3 = EN; /* printf( "ESN %8.6f EN %8.6f Xmu %8.6f R1 %8.6f R2 %8.6f LD %8.6f\n", ESN, EN, Xmu, *R1, *R2, (exp(lambda*delta)-1)/delta ); */ } /* Empirical GEM statistics */ double EmpiricalGEM( double lambda0, double K0, double H, double alpha, int len1, int len2, double *theta, double *logkappa, double score ) { double alpha2 = alpha*alpha; double Kappa, Lambda, pval, x, f; double L = len1*len2; f = log(L)*(1.0/(double)len1 + 1.0/(double)len2); *theta = 1.013 -2.61*alpha + f*( -0.76 + 9.34*alpha +1.12/H); *logkappa = 0.26 -18.92*alpha + f*(-1.76 + 32.69*alpha + 192.52*alpha2 + 3.24/H ); Kappa = K0*exp(*logkappa); Lambda = lambda0*(*theta); x = Kappa*L*exp(-Lambda*score); if ( x < 1.0e-6 ) pval = x; else pval = 1.0-exp(-x); /* printf("alpha %.5f lambda0 %.5f K0 %.5f H %.5f f %.5f theta %.5f logkappa %.5f pval %e %5d %5d x %e\n", alpha, lambda0, K0, H, f, *theta, *logkappa, pval, len1, len2, x ); */ return pval; } double AutoIncreaseGapPenalty( double s, double lambda0, double alpha_max, int *A, int *B ) { double alpha = 2*s*exp(-lambda0*(*A + *B))/(1-exp(-lambda0* *B)); int its=0; while( its++ < 100 ) { (*A)++; alpha = 2*s*exp(-lambda0*(*A + *B))/(1-exp(-lambda0* *B)); if ( alpha < alpha_max ) break; (*B)++; alpha = 2*s*exp(-lambda0*(*A + *B))/(1-exp(-lambda0* *B)); if ( alpha < alpha_max ) break; } printf( "WARNING: gap penalty increased to %d+%dk\n", *A, *B ); return alpha; } wise-2.4.1/src/external/makefile0000644000175000001440000000013407627672424016200 0ustar philippusers all : (cd mott; make CC="$(CC)" CFLAGS="$(CFLAGS)" all) clean : (cd mott; make clean) wise-2.4.1/src/haplotype/0000755000175000001440000000000010670453604014652 5ustar philippuserswise-2.4.1/src/haplotype/haplotype.dy0000644000175000001440000000072607723613604017225 0ustar philippusers %{ #include "markerframework.h" #define PartialHaplotypeLISTLENGTH 1024 %} struct LocusAllele Locus * locus !link int allele friend PartialHaplotype struct PartialHaplotypeLink PartialHaplotype * left !link PartialHaplotype * right !link struct PartialHaplotype int marker_start int marker_end LocusAllele ** allele !list PartialHaplotypeLink ** left !list !len="_left" PartialHaplotypeLink ** right !list !len="_right" %{ #include "haplotype.h" %}wise-2.4.1/src/haplotype/markerframework.dy0000644000175000001440000000030607723613604020411 0ustar philippusers %{ #include "wisebase.h" #define LocusSetLISTLENGTH 1024 %} struct Locus int allele_number long int position struct LocusSet Locus ** locus !list %{ #include "markerframework.h" %}wise-2.4.1/src/haplotype/individual.dy0000644000175000001440000000033507723613604017344 0ustar philippusers %{ #include "markerframework.h" #define GenotypeLISTLENGTH 1024 %} struct LocusGenotype Locus * locus !link int allele_1 int allele_2 struct Genotype LocusGenotype ** locus !list %{ #include "individual.h" %}wise-2.4.1/src/corba/0000755000175000001440000000000010670453556013741 5ustar philippuserswise-2.4.1/src/corba/hspscan_corba_wrapper.c0000644000175000001440000000610607614546543020460 0ustar philippusers#include "hspscan_corba_wrapper.h" #include "hspscan_corba.h" typedef struct hspscan_corba_data { Wise2Corba_Singleton * sorb; Wise2HSP_HSPmanagerFactory hspf; Wise2_CompMat * mat; int verbose; } hspscan_corba_data; void corba_HSPScan_free_data(void * data) { hspscan_corba_data * corba = (hspscan_corba_data * ) data; CORBA_Object_release(corba->hspf,corba->sorb->ev); free(corba); return; } LinearHSPmanager * corba_HSPScan_scan_query_iterator(void * data,Sequence * query,HSPScanInterfacePara * para) { LinearHSPmanager * lm; HSPset * set; HSP * hsp; Wise2HSP_HSP_ts_iterator iter; Wise2HSP_HSPtargetset * ts; Wise2_Sequence * temp_target; Wise2HSP_Sequence corba_query; hspscan_corba_data * hsp_data = (hspscan_corba_data*) data; int i,j; if( hsp_data->verbose == 1 ) { fprintf(stderr,"Loading up query... %s\n",query->name); } corba_query.name = CORBA_string_dup(query->name); corba_query.seq = CORBA_string_dup(query->seq); iter = Wise2HSP_HSPmanagerFactory_scan_query_iterator(hsp_data->hspf,&corba_query,250,hsp_data->sorb->ev); if( hsp_data->verbose == 1 ) { fprintf(stderr,"Retrieved hsp iterator...\n"); } lm = LinearHSPmanager_alloc_std(); lm->query = hard_link_Sequence(query); lm->mat = hard_link_CompMat(hsp_data->mat); while( Wise2HSP_HSP_ts_iterator_is_more(iter,hsp_data->sorb->ev) ) { ts = Wise2HSP_HSP_ts_iterator_next(iter,hsp_data->sorb->ev); set = HSPset_alloc_std(); add_LinearHSPmanager(lm,set); set->score = 0; set->best_score= 0; temp_target = new_Sequence_from_strings(ts->target.name,ts->target.seq); for(j=0;jhsp._length;j++) { hsp = HSP_alloc(); hsp->query = hard_link_Sequence(query); hsp->target = hard_link_Sequence(temp_target); hsp->score = ts->hsp._buffer[j].score; hsp->query_start = ts->hsp._buffer[j].query_start; hsp->target_start = ts->hsp._buffer[j].target_start; hsp->length = ts->hsp._buffer[j].length; set->score += hsp->score; if( set->best_score < hsp->score ) { set->best_score = hsp->score; } add_HSPset(set,hsp); } free_Sequence(temp_target); } if( hsp_data->verbose == 1 ) { fprintf(stderr,"Built Wise2 hspmanager, going to return\n"); } return lm; } Wise2_HSPScanInterface * new_corba_HSPScan(Wise2Corba_Singleton * sorb,char * iorfile,CompMat * client_side_mat) { hspscan_corba_data * data; Wise2_HSPScanInterface * out; FILE * ifp; char buffer[1024]; assert(sorb); assert(iorfile); ifp = fopen(iorfile,"r"); if( ifp == NULL ) { fprintf(stderr,"Could not open file %s!",iorfile); return NULL; } fgets(buffer,1023,ifp); fclose(ifp); out = Wise2_HSPScanInterface_alloc(); data = g_new0(hspscan_corba_data,1); out->data = (void *) data; data->sorb = sorb; data->mat = hard_link_CompMat(client_side_mat); data->hspf = CORBA_ORB_string_to_object(sorb->orb, buffer, sorb->ev); data->verbose = 1; out->scan_query = corba_HSPScan_scan_query_iterator; out->free_data = corba_HSPScan_free_data; return out; } wise-2.4.1/src/corba/hspscan_corba_wrapper.h0000644000175000001440000000106107614546543020460 0ustar philippusers #ifndef HSPSCAN_CORBA_WRAPPER_HEADER #define HSPSCAN_CORBA_WRAPPER_HEADER #include "hspscan_corba.h" #include "corba_singleton.h" #include "hspscaninterface.h" /* * This method provides a hspscaninterface (ie, the Wise2 interface) * into the CORBA layer, abstracting out the calling convetion * of the ORB and remapping the results into the standard Wise2 * structures (the over the wire system is more compact) */ Wise2_HSPScanInterface * new_corba_HSPScan(Wise2Corba_Singleton * sorb,char * iorfile,Wise2_CompMat * client_side_compmat); #endif wise-2.4.1/src/corba/hspscan_corba.idl0000644000175000001440000000122407524226430017230 0ustar philippusers module Wise2HSP { struct Sequence { string name; string seq; }; struct HSPinfo { long query_start; long target_start; long length; long score; }; typedef sequence HSPinfoList; struct HSPtargetset { Sequence target; HSPinfoList hsp; }; typedef sequence HSPtargetlist; struct HSPmanager { HSPtargetlist target; }; interface HSP_ts_iterator { HSPtargetset next(); boolean is_more(); }; interface HSPmanagerFactory { HSPmanager scan_query(in Sequence query); HSP_ts_iterator scan_query_iterator(in Sequence query,in short max_size); }; }; wise-2.4.1/src/corba/scanwise_protein_index.c0000644000175000001440000001057607614546543020664 0ustar philippusers #include "hspscan_server_impl.h" #include "sequencedb.h" #include "seqlookup.h" #include "subseqhash.h" #include "subseqlookup.h" #include "hsplookupscan.h" #include "arrayseqlookup.h" #include "proteinstreamedindex.h" #include "../models/version.h" #include #include "corba_singleton.h" char * program_name = "scanwise_protein_index"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s sequence_file_fasta\n",program_name); fprintf(ofp,"\nThis program builds a in memory index of a protein database for use by \n"); fprintf(ofp,"the scanwise family of methods. It runs a CORBA server which is identified\n"); fprintf(ofp,"by the IOR file written out. For most databases you need around 10GB of memory\n\n"); fprintf(ofp," OPTIONS\n"); fprintf(ofp," -iorfile file to write IOR out to [hsp.ior]\n"); fprintf(ofp," -hash use glib hash not array (far slower, but easier on the memory for small DBs)\n"); fprintf(ofp," -streamed use streamed index (more compact, higher run-time)\n"); fprintf(ofp," -ocfile occupancy file for array/streamed indexes (large), for debugging\n"); show_help_SeqLookupLoadPara(ofp); show_standard_options(ofp); } int main(int argc, char* argv[]) { int i; Wise2Corba_Singleton * sorb; PortableServer_ObjectId* oid; Wise2HSP_HSPmanagerFactory hspf; Wise2_HSPScanInterface * hsi; SequenceDB * db; Sequence * seq; int ret; SeqLookupInterface * sli; CompMat * mat; FILE * ofp; PortableServer_POAManager pm; CORBA_char* objref; int count = 0; int is_array = 0; int waystation = 4; char * ior_file; char * oc_file = NULL; char * temp; SeqLookupLoadPara * slp; boolean use_hash = 0; boolean use_stream = 0; slp = new_SeqLookupLoadPara_from_argv(&argc,argv); use_hash = strip_out_boolean_argument(&argc,argv,"hash"); use_stream = strip_out_boolean_argument(&argc,argv,"streamed"); strip_out_integer_argument(&argc,argv,"waystation",&waystation); if( (temp = strip_out_assigned_argument(&argc,argv,"iorfile")) != NULL ) { ior_file = temp; } else { ior_file = "hsp.ior"; } oc_file = strip_out_assigned_argument(&argc,argv,"ocfile"); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 2 ) { show_help(stdout); exit(12); } ofp = fopen(ior_file,"w"); if( ofp == NULL ) { fatal("unable to open %s\n",ior_file); } fclose(ofp); sorb = get_Wise2Corba_Singleton(&argc,argv,"orbit-local-orb"); db = single_fasta_SequenceDB(argv[1]); mat = read_Blast_file_CompMat("blosum62.bla"); if( use_stream == 1 ) { sli = new_ProteinStreamedIndex_SeqLookupInterface(waystation); } else if( use_hash == 1 ) { sli = new_ghash_SeqLookupInterface(); } else { is_array = 1; sli = new_ArraySeq_SeqLookupInterface(26*26*26*26*26); } load_SequenceDB_SeqLookupLoadPara(slp,db,sli); if( (is_array == 1 || use_stream == 1) && oc_file != NULL) { ofp = fopen(oc_file,"w"); if( ofp != NULL ) { info("Printing index occupancy"); if( is_array == 1 ) { print_array_occuypancy_ArraySeq((ArraySeqLookup*)sli->data,ofp); } else { dump_ProteinStreamedIndex((ProteinStreamedIndex*)sli->data,ofp); } info("Finished index occupancy"); fclose(ofp); } } hsi = Wise2_new_one_off_HSPScanInterface(sli,mat,40,10); hspf = new_Wise2HSP_HSPmanagerFactory(sorb->poa,hsi,sorb->ev); objref = CORBA_ORB_object_to_string(sorb->orb,hspf, sorb->ev); ofp = fopen(ior_file,"w"); if( ofp == NULL ) { fatal("unable to open %s\n",ior_file); } fprintf(ofp, "%s", objref); fclose(ofp); pm = PortableServer_POA__get_the_POAManager(sorb->poa, sorb->ev); PortableServer_POAManager_activate(pm, sorb->ev); fprintf(stderr,"IOR written out to %s, serving...\n",ior_file); CORBA_ORB_run(sorb->orb, sorb->ev); return 0; } wise-2.4.1/src/corba/makefile0000644000175000001440000000377210302616603015434 0ustar philippusers CC = cc INCFLAGS = -I../base/ -I../dynlibsrc #gCFLAGS = -Wall -g -pedantic -c -DUNIX -I../base/ #CFLAGS = -O2 -c -DUNIX -I../base/ `glib-config --cflags` -I/usr/local/include/orbit-1.0/ CFLAGS = -pthread -c -DUNIX -I../base/ -I../dynlibsrc `orbit-config --cflags client` LFLAGS = -L../base/ -lm -lpthread AR_OPTIONS = ru hspscan_corba.c : hspscan_corba.idl orbit-idl hspscan_corba.idl test_server : test_server.o hspscan_server_impl.o hspscan_corba-common.o hspscan_corba-skels.o hspscan_corba-stubs.o corba_singleton.o cc -g -o test_server test_server.o hspscan_server_impl.o hspscan_corba-common.o hspscan_corba-skels.o hspscan_corba-stubs.o corba_singleton.o ../dynlibsrc/libdyna.a ../base/libwisebase.a ../dynlibsrc/hsp.o ../dynlibsrc/subseqhash.o ../dynlibsrc/linkedlist_lookpos.o ../dynlibsrc/libdyna_glib.a `glib-config --libs` -lm -lORBit -lIIOP -lORBitutil -lpthread scanwise_protein_index : scanwise_protein_index.o hspscan_server_impl.o hspscan_corba-common.o hspscan_corba-skels.o hspscan_corba-stubs.o corba_singleton.o cc -o scanwise_protein_index scanwise_protein_index.o hspscan_server_impl.o hspscan_corba-common.o hspscan_corba-skels.o hspscan_corba-stubs.o corba_singleton.o ../dynlibsrc/libdyna_glib.a ../dynlibsrc/libdyna.a ../base/libwisebase.a `glib-config --libs` -lm -lORBit -lIIOP -lORBitutil -lpthread test_client : test_client.o hspscan_corba-common.o hspscan_corba-stubs.o cc -g -o test_client test_client.o hspscan_corba-common.o hspscan_corba-stubs.o ../dynlibsrc/libdyna.a ../base/libwisebase.a `glib-config --libs` -lm -lORBit -lIIOP -lORBitutil -lpthread test_wrapper : test_wrapper.o hspscan_corba-common.o hspscan_corba-stubs.o hspscan_corba_wrapper.o corba_singleton.o cc -g -o test_wrapper test_wrapper.o hspscan_corba-common.o hspscan_corba-stubs.o corba_singleton.o hspscan_corba_wrapper.o ../dynlibsrc/hsp.o ../dynlibsrc/libdyna.a ../base/libwisebase.a `glib-config --libs` -lm -lORBit -lIIOP -lORBitutil -lpthread .c.o : $(CC) $(CFLAGS) $(INCFLAGS) $? wise-2.4.1/src/corba/hspscan_server_impl.c0000644000175000001440000002725407525246121020156 0ustar philippusers#include "hspscan_corba.h" #include "hspscaninterface.h" /*** App-specific servant structures ***/ typedef struct { POA_Wise2HSP_HSP_ts_iterator servant; PortableServer_POA poa; LinearHSPmanager * lm; int current_pos; int max_size; } impl_POA_Wise2HSP_HSP_ts_iterator; typedef struct { POA_Wise2HSP_HSPmanagerFactory servant; PortableServer_POA poa; HSPScanInterface * hsi; int is_verbose; } impl_POA_Wise2HSP_HSPmanagerFactory; /*** Implementation stub prototypes ***/ static void impl_Wise2HSP_HSP_ts_iterator__destroy(impl_POA_Wise2HSP_HSP_ts_iterator * servant, CORBA_Environment * ev); static Wise2HSP_HSPtargetset * impl_Wise2HSP_HSP_ts_iterator_next(impl_POA_Wise2HSP_HSP_ts_iterator * servant, CORBA_Environment * ev); static CORBA_boolean impl_Wise2HSP_HSP_ts_iterator_is_more(impl_POA_Wise2HSP_HSP_ts_iterator * servant, CORBA_Environment * ev); static void impl_Wise2HSP_HSPmanagerFactory__destroy(impl_POA_Wise2HSP_HSPmanagerFactory *servant, CORBA_Environment *ev); static Wise2HSP_HSPmanager* impl_Wise2HSP_HSPmanagerFactory_scan_query(impl_POA_Wise2HSP_HSPmanagerFactory *servant, Wise2HSP_Sequence* query, CORBA_Environment *ev); static Wise2HSP_HSP_ts_iterator impl_Wise2HSP_HSPmanagerFactory_scan_query_iterator(impl_POA_Wise2HSP_HSPmanagerFactory * servant, Wise2HSP_Sequence * query,CORBA_short max_size, CORBA_Environment * ev); /*** epv structures ***/ static PortableServer_ServantBase__epv impl_Wise2HSP_HSP_ts_iterator_base_epv = { NULL, /* _private data */ NULL, /* finalize routine */ NULL, /* default_POA routine */ }; static POA_Wise2HSP_HSP_ts_iterator__epv impl_Wise2HSP_HSP_ts_iterator_epv = { NULL, /* _private */ (gpointer) & impl_Wise2HSP_HSP_ts_iterator_next, (gpointer) & impl_Wise2HSP_HSP_ts_iterator_is_more, }; static PortableServer_ServantBase__epv impl_Wise2HSP_HSPmanagerFactory_base_epv = { NULL, /* _private data */ NULL, /* finalize routine */ NULL, /* default_POA routine */ }; static POA_Wise2HSP_HSPmanagerFactory__epv impl_Wise2HSP_HSPmanagerFactory_epv = { NULL, /* _private */ (gpointer) & impl_Wise2HSP_HSPmanagerFactory_scan_query, (gpointer) & impl_Wise2HSP_HSPmanagerFactory_scan_query_iterator, }; /*** vepv structures ***/ static POA_Wise2HSP_HSP_ts_iterator__vepv impl_Wise2HSP_HSP_ts_iterator_vepv = { &impl_Wise2HSP_HSP_ts_iterator_base_epv, &impl_Wise2HSP_HSP_ts_iterator_epv, }; static POA_Wise2HSP_HSPmanagerFactory__vepv impl_Wise2HSP_HSPmanagerFactory_vepv = { &impl_Wise2HSP_HSPmanagerFactory_base_epv, &impl_Wise2HSP_HSPmanagerFactory_epv, }; /*** iterator implementations ****/ /*** Stub implementations ***/ static Wise2HSP_HSP_ts_iterator impl_Wise2HSP_HSP_ts_iterator__create(PortableServer_POA poa, LinearHSPmanager * lm,int max_size,CORBA_Environment * ev) { Wise2HSP_HSP_ts_iterator retval; impl_POA_Wise2HSP_HSP_ts_iterator *newservant; PortableServer_ObjectId *objid; newservant = g_new0(impl_POA_Wise2HSP_HSP_ts_iterator, 1); newservant->servant.vepv = &impl_Wise2HSP_HSP_ts_iterator_vepv; newservant->poa = poa; newservant->lm = lm; newservant->max_size = max_size; newservant->current_pos = 0; POA_Wise2HSP_HSP_ts_iterator__init((PortableServer_Servant) newservant, ev); objid = PortableServer_POA_activate_object(poa, newservant, ev); CORBA_free(objid); retval = PortableServer_POA_servant_to_reference(poa, newservant, ev); return retval; } static void impl_Wise2HSP_HSP_ts_iterator__destroy(impl_POA_Wise2HSP_HSP_ts_iterator * servant, CORBA_Environment * ev) { PortableServer_ObjectId *objid; objid = PortableServer_POA_servant_to_id(servant->poa, servant, ev); PortableServer_POA_deactivate_object(servant->poa, objid, ev); CORBA_free(objid); POA_Wise2HSP_HSP_ts_iterator__fini((PortableServer_Servant) servant, ev); g_free(servant); } static Wise2HSP_HSPtargetset * impl_Wise2HSP_HSP_ts_iterator_next(impl_POA_Wise2HSP_HSP_ts_iterator * servant, CORBA_Environment * ev) { Wise2HSP_HSPtargetset *retval; HSPset * s; int i; s = servant->lm->set[servant->current_pos]; /* fprintf(stderr,"Going to pass to client %d block %s\n",servant->current_pos,s->hsp[0]->target->name);*/ retval = Wise2HSP_HSPtargetset__alloc(); /* do we need to worry about string dup's ... probably!*/ retval->target.name = CORBA_string_dup(s->hsp[0]->target->name); retval->target.seq = CORBA_string_dup(s->hsp[0]->target->seq); retval->hsp._buffer = CORBA_sequence_Wise2HSP_HSPinfo_allocbuf(s->len); retval->hsp._maximum = retval->hsp._length = s->len; for(i=0;ilen;i++) { retval->hsp._buffer[i].query_start = s->hsp[i]->query_start; retval->hsp._buffer[i].target_start = s->hsp[i]->target_start; retval->hsp._buffer[i].length = s->hsp[i]->length; retval->hsp._buffer[i].score = s->hsp[i]->score; } servant->current_pos++; /* fprintf(stderr,"Going to return with score %d length %d\n",s->score,s->len); */ return retval; } static CORBA_boolean impl_Wise2HSP_HSP_ts_iterator_is_more(impl_POA_Wise2HSP_HSP_ts_iterator * servant, CORBA_Environment * ev) { CORBA_boolean retval; if( servant->current_pos > servant->max_size ) { return FALSE; } if( servant->current_pos < servant->lm->len ) { retval = TRUE; } else { retval = FALSE; } return retval; } /*** factory implementations ****/ static Wise2HSP_HSPmanagerFactory impl_Wise2HSP_HSPmanagerFactory__create(PortableServer_POA poa, CORBA_Environment *ev) { Wise2HSP_HSPmanagerFactory retval; impl_POA_Wise2HSP_HSPmanagerFactory *newservant; PortableServer_ObjectId *objid; newservant = g_new0(impl_POA_Wise2HSP_HSPmanagerFactory, 1); newservant->servant.vepv = &impl_Wise2HSP_HSPmanagerFactory_vepv; newservant->poa = poa; POA_Wise2HSP_HSPmanagerFactory__init((PortableServer_Servant)newservant, ev); objid = PortableServer_POA_activate_object(poa, newservant, ev); CORBA_free(objid); retval = PortableServer_POA_servant_to_reference(poa, newservant, ev); return retval; } Wise2HSP_HSPmanagerFactory new_Wise2HSP_HSPmanagerFactory(PortableServer_POA poa, Wise2_HSPScanInterface * hsi,CORBA_Environment * ev) { Wise2HSP_HSPmanagerFactory retval; impl_POA_Wise2HSP_HSPmanagerFactory *newservant; PortableServer_ObjectId *objid; newservant = g_new0(impl_POA_Wise2HSP_HSPmanagerFactory, 1); newservant->servant.vepv = &impl_Wise2HSP_HSPmanagerFactory_vepv; newservant->poa = poa; newservant->hsi = hsi; newservant->is_verbose = 1; POA_Wise2HSP_HSPmanagerFactory__init((PortableServer_Servant)newservant, ev); objid = PortableServer_POA_activate_object(poa, newservant, ev); CORBA_free(objid); retval = PortableServer_POA_servant_to_reference(poa, newservant, ev); return retval; } static void impl_Wise2HSP_HSPmanagerFactory__destroy(impl_POA_Wise2HSP_HSPmanagerFactory *servant, CORBA_Environment *ev) { PortableServer_ObjectId *objid; objid = PortableServer_POA_servant_to_id(servant->poa, servant, ev); PortableServer_POA_deactivate_object(servant->poa, objid, ev); CORBA_free(objid); POA_Wise2HSP_HSPmanagerFactory__fini((PortableServer_Servant)servant, ev); g_free(servant); } static void remap_hsp(gpointer key,gpointer data,gpointer user_data) { HSPset * set = (HSPset*)data; Wise2HSP_HSPmanager* manager = (Wise2HSP_HSPmanager*) user_data; int pos; int i; pos = manager->target._length++; /* first off, allocate and store this target */ manager->target._buffer[pos].target.name = CORBA_string_dup(set->hsp[0]->target->name); manager->target._buffer[pos].target.seq = CORBA_string_dup(set->hsp[0]->target->seq); manager->target._buffer[pos].hsp._buffer = CORBA_sequence_Wise2HSP_HSPinfo_allocbuf(set->len); manager->target._buffer[pos].hsp._maximum =set->len; manager->target._buffer[pos].hsp._length =set->len; for(i=0;ilen;i++) { manager->target._buffer[pos].hsp._buffer[i].query_start = set->hsp[i]->query_start; manager->target._buffer[pos].hsp._buffer[i].target_start = set->hsp[i]->target_start; manager->target._buffer[pos].hsp._buffer[i].length = set->hsp[i]->length; manager->target._buffer[pos].hsp._buffer[i].score = set->hsp[i]->score; } return; } static Wise2HSP_HSPmanager * corba_manager_from_wise_manager(LinearHSPmanager * lm) { Wise2HSP_HSPmanager* retval; int size; int i; int pos; size = lm->len; /* ok, we need to build the return structure now */ retval = Wise2HSP_HSPmanager__alloc(); retval->target._buffer = CORBA_sequence_Wise2HSP_HSPtargetset_allocbuf(size); retval->target._length = 0; retval->target._maximum = size; for(pos=0;poslen;pos++) { auto HSPset * set = lm->set[pos]; retval->target._length++; /* first off, allocate and store this target */ retval->target._buffer[pos].target.name = CORBA_string_dup(set->hsp[0]->target->name); retval->target._buffer[pos].target.seq = CORBA_string_dup(set->hsp[0]->target->seq); retval->target._buffer[pos].hsp._buffer = CORBA_sequence_Wise2HSP_HSPinfo_allocbuf(set->len); retval->target._buffer[pos].hsp._maximum =set->len; retval->target._buffer[pos].hsp._length =set->len; for(i=0;ilen;i++) { retval->target._buffer[pos].hsp._buffer[i].query_start = set->hsp[i]->query_start; retval->target._buffer[pos].hsp._buffer[i].target_start = set->hsp[i]->target_start; retval->target._buffer[pos].hsp._buffer[i].length = set->hsp[i]->length; retval->target._buffer[pos].hsp._buffer[i].score = set->hsp[i]->score; } } return retval; } static Wise2HSP_HSPmanager* impl_Wise2HSP_HSPmanagerFactory_scan_query(impl_POA_Wise2HSP_HSPmanagerFactory *servant, Wise2HSP_Sequence* query, CORBA_Environment *ev) { Wise2HSP_HSPmanager* retval; Wise2_Sequence * wise2_seq; LinearHSPmanager * lm; HSPScanInterfacePara para; int size; if( servant->is_verbose == 1 ) { fprintf(stdout,"going to do %s\n",query->name); } wise2_seq = new_Sequence_from_strings(query->name,query->seq); para.max_results = 250; lm = (*servant->hsi->scan_query)(servant->hsi->data,wise2_seq,¶); retval = corba_manager_from_wise_manager(lm); if( servant->is_verbose == 1 ) { fprintf(stdout," ... remapped HSP manager\n"); } Wise2_free_LinearHSPmanager(lm); if( servant->is_verbose == 1 ) { fprintf(stdout," ... freed data, about to return\n"); } return retval; } static Wise2HSP_HSP_ts_iterator impl_Wise2HSP_HSPmanagerFactory_scan_query_iterator(impl_POA_Wise2HSP_HSPmanagerFactory * servant, Wise2HSP_Sequence * query,CORBA_short max_size, CORBA_Environment * ev) { Wise2HSP_HSP_ts_iterator retval; Wise2HSP_HSPmanager* corba_hspm; Wise2_Sequence * wise2_seq; LinearHSPmanager * lm; HSPScanInterfacePara para; int size; int i; if( servant->is_verbose == 1 ) { fprintf(stdout,"going to do %s\n",query->name); } wise2_seq = new_Sequence_from_strings(query->name,query->seq); para.max_results = max_size; lm = (*servant->hsi->scan_query)(servant->hsi->data,wise2_seq,¶); /* fprintf(stderr,"Sanity check in corba\n"); for(i=0;ilen;i++) { fprintf(stderr,"Got %s %d\n",lm->set[i]->hsp[0]->target->name,i); } */ if( servant->is_verbose == 1 ) { fprintf(stdout," ... retrieved HSP manager size %d\n",lm->len); } if( servant->is_verbose == 1 ) { fprintf(stdout," ... remapped HSP manager\n"); } if( servant->is_verbose == 1 ) { fprintf(stdout," ... freed data, about to return iterator\n"); } retval = impl_Wise2HSP_HSP_ts_iterator__create(servant->poa,lm,max_size,ev); return retval; } wise-2.4.1/src/corba/hspscan_server_impl.h0000644000175000001440000000042607524152763020162 0ustar philippusers #ifndef HSPSCAN_SERVER_IMPL_HEADER #define HSPSCAN_SERVER_IMPL_HEADER #include "hspscaninterface.h" #include "hspscan_corba.h" Wise2HSP_HSPmanagerFactory new_Wise2HSP_HSPmanagerFactory(PortableServer_POA poa, Wise2_HSPScanInterface * hsi,CORBA_Environment * ev); #endif wise-2.4.1/src/corba/test_wrapper.c0000644000175000001440000000132607525246121016617 0ustar philippusers#include "seqlookup.h" #include "sequencedb.h" #include "hspscan_corba_wrapper.h" #include "corba_singleton.h" #include "hitlist.h" int main(int argc,char ** argv) { Sequence * seq; HSPScanInterface * hsi; HSPScanInterfacePara p; LinearHSPmanager * lm; HitList * hl; CompMat * mat; int ret; Wise2Corba_Singleton * sorb; mat = read_Blast_file_CompMat("blosum62.bla"); sorb = get_Wise2Corba_Singleton(&argc,argv,"orbit-local-orb"); hsi = new_corba_HSPScan(sorb,"hsp.ior",mat); seq = read_fasta_file_Sequence(argv[1]); assert(seq); p.max_results = 30; lm = (*hsi->scan_query)(hsi->data,seq,&p); hl = HitList_from_LinearHSPmanager(lm); write_pseudoblast_HitList(hl,stdout); } wise-2.4.1/src/corba/test_server.c0000644000175000001440000000405207530470207016444 0ustar philippusers #include "hspscan_server_impl.h" #include "sequencedb.h" #include "seqlookup.h" #include "subseqhash.h" #include "subseqlookup.h" #include "hsplookupscan.h" #include "arrayseqlookup.h" #include #include "corba_singleton.h" int main(int argc, char* argv[]) { int i; Wise2Corba_Singleton * sorb; PortableServer_ObjectId* oid; Wise2HSP_HSPmanagerFactory hspf; Wise2_HSPScanInterface * hsi; SequenceDB * db; Sequence * seq; int ret; SeqLookupInterface * sli; CompMat * mat; FILE * ofp; PortableServer_POAManager pm; CORBA_char* objref; int count = 0; int is_array = 0; sorb = get_Wise2Corba_Singleton(&argc,argv,"orbit-local-orb"); db = single_fasta_SequenceDB(argv[1]); mat = read_Blast_file_CompMat("blosum62.bla"); if( strcmp(argv[2],"hash") == 0 ) { sli = new_ghash_SeqLookupInterface(); } else { is_array = 1; sli = new_ArraySeq_SeqLookupInterface(26*26*26*26*26); } count = 0; for(i=0,seq = init_SequenceDB(db,&ret); seq != NULL;seq = get_next_SequenceDB(db) ) { load_aa_flat_Sequence_SeqLookupInterface(sli,hard_link_Sequence(seq)); if( i % 1000 == 0 ) { printf("Loaded up to %d sequences...\n",i); } i++; /* if( i > 200000 ) { fprintf(stderr,"FOR TESTING - breaking after 200000 seqs\n"); break; } */ } if( is_array == 1 && 0) { ofp = fopen("array.oc","w"); fprintf(stderr,"Array occupany...\n"); print_array_occuypancy_ArraySeq((ArraySeqLookup*)sli->data,ofp); fprintf(stderr,"Finished write\n"); fclose(ofp); } hsi = new_one_off_HSPScanInterface(sli,mat,40,10); hspf = new_Wise2HSP_HSPmanagerFactory(sorb->poa,hsi,sorb->ev); objref = CORBA_ORB_object_to_string(sorb->orb,hspf, sorb->ev); ofp = fopen("hsp.ior","w"); fprintf(ofp, "%s", objref); fclose(ofp); pm = PortableServer_POA__get_the_POAManager(sorb->poa, sorb->ev); PortableServer_POAManager_activate(pm, sorb->ev); fprintf(stderr,"Going to start running...\n"); CORBA_ORB_run(sorb->orb, sorb->ev); return 0; } wise-2.4.1/src/corba/corba_singleton.c0000644000175000001440000000163007524153174017252 0ustar philippusers #include "corba_singleton.h" #include static Wise2Corba_Singleton singleton; static char * static_init_string = NULL; Wise2Corba_Singleton * get_Wise2Corba_Singleton(int * argc,char ** argv,char * init_string) { if( static_init_string != NULL ) { if( strcmp(static_init_string,init_string) == 0 ) { return &singleton; } else { fprintf(stderr,"Trouble! Asked for orbs of different types %s and %s",init_string,static_init_string); return NULL; } } /* else, initiate orb */ singleton.ev = g_new0(CORBA_Environment,1); CORBA_exception_init(singleton.ev); singleton.orb = CORBA_ORB_init(argc,argv,init_string,singleton.ev); /* FIXME: Exception check! */ singleton.poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references(singleton.orb, "RootPOA",singleton.ev); static_init_string = CORBA_string_dup(init_string); return &singleton; } wise-2.4.1/src/corba/corba_singleton.h0000644000175000001440000000050307524153174017255 0ustar philippusers #ifndef CORBA_SINGLETON_HEADER #define CORBA_SINGLETON_HEADER #include typedef struct Wise2Corba_Singleton { CORBA_Environment * ev; CORBA_ORB orb; PortableServer_POA poa; } Wise2Corba_Singleton; Wise2Corba_Singleton * get_Wise2Corba_Singleton(int * argc,char ** argv,char * init_string); #endif wise-2.4.1/src/corba/test_client.c0000644000175000001440000000360207614546543016426 0ustar philippusers#include #include "hspscan_corba.h" #include #include "sequence.h" Wise2HSP_HSPmanagerFactory hspf; Wise2HSP_HSPmanager * hspm; Wise2HSP_Sequence query; int main (int argc, char *argv[]) { CORBA_Environment ev; CORBA_ORB orb; Wise2_Sequence * seq; int i; int j; FILE * ifp; char * ior; char filebuffer[1024]; /* * Standard initalisation of the orb. Notice that * ORB_init 'eats' stuff off the command line */ CORBA_exception_init(&ev); orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev); /* * Get the IOR (object reference). It should be written out * by the echo-server into the file echo.ior. So - if you * are running the server in the same place as the client, * this should be fine! */ seq = read_fasta_file_Sequence(argv[1]); ifp = fopen("hsp.ior","r"); if( ifp == NULL ) { fprintf(stderr,"No echo.ior file!"); exit(-1); } fgets(filebuffer,1023,ifp); ior = g_strdup(filebuffer); fclose(ifp); /* * Actually get the object. So easy! */ hspf = CORBA_ORB_string_to_object(orb, ior, &ev); if (!hspf) { printf("Cannot bind to %s\n", ior); return 1; } query.name = CORBA_string_dup(seq->name); query.seq = CORBA_string_dup(seq->seq); hspm = Wise2HSP_HSPmanagerFactory_scan_query(hspf,&query,&ev); for(i=0;itarget._length;i++) { fprintf(stdout,"Sequence %s\n",hspm->target._buffer[i].target.name); for(j=0;jtarget._buffer[i].hsp._length;j++) { fprintf(stdout," hsp %d %d %d\n",hspm->target._buffer[i].hsp._buffer[j].query_start, hspm->target._buffer[i].hsp._buffer[j].target_start, hspm->target._buffer[i].hsp._buffer[j].length); } } /* Clean up */ CORBA_Object_release(hspf, &ev); CORBA_Object_release((CORBA_Object)orb, &ev); return 0; } wise-2.4.1/src/SOURCE_ROADMAP0000644000175000001440000001006507313404523014731 0ustar philippusers These directories have the source code for the Wise2 package and the Dynamite compiler. The directories are as follows. base - base memory, string and error reporting library dynlibsrc - bioinformatics library - sequences, genes, codon tables etc models - algorithms and more complex objects for the wise2 package dyc - dynamite compiler source code. HMMer2 - the HMMer2 package - used for hmmio in this case The source code here was provided by Sean Eddy perl - Integration into perl via an XS interface: makefile for the interface perl/Wise2 - the actual Perl 'directory' to compiled for it perl/Wise2/libs - where the libraries are copied into to build perl examples - examples for the Wise2 package dynamite_examples - examples for the Dynamite package. Source code files: There is a scary number of files in each directory. This is because the dynamite compiler generates alot files for each module here is an explanation of the files .dy - the dynamite source For each .dy files the following files are generated .h - C header file - contains documentation .c - C source file _api.t api 'type' file _api.h api header file .pod - pod documentation .xs - xs interface into perl More documentation occurs in a appropiate file. Read the .h files for each module base library wisestring - common string functions wisememman - memory management wiseerror - error functions wisetime - (small) time functions wiserandom - wrapper around random functions wiseconfig - almost defunct configuration dynlibsrc Sequence types sequence - base sequence object protein - typed protein sequence object genomic - typed genomic sequence object cdna - typed cdna object Sequence databases sequencedb - sequence database proteindb - protein database cdnadb - cdna database genomicdb - genomic database randommodel - protein+dna random models Central dogma types genomicregion - holder for gene structures on a genomic sequence gene - gene structure transcript - one transcript from a gene translation - one translation from a transcript Sequence accessories codon - codon table, base encoding and translation compmat - protein comparison matrix dnamat - dna comparison matrix codonmatrix - codon comparison matrix Dynamic programming libraries basematrix - underlying memory of DPs dpenvelope - a envelope over the dynamic programming packaln - low level alignment aln - high level alignment Alignment Output libraries asciibtcanvas - ascii class for outputs btcanvas - virtual class for outputs Database searching accessories hscore - high scores histogram - package for handling score distributions (from sean eddy) database.h - generic types for database looping Models Protein<->protein alignmetns proteinsw.dy - smith waterman protein alignments abc.dy - stephen altschul's 'generalised' gap penalties sw_wrap.dy - a clean API for the protein smith waterman HMM support wise2xhmmer2 - conversion from hmmer<->wise threestatemodel - internal wise2 profile-HMM object threestatedb - database of HMMs pfamhmmer1db - old-style HMM 1.x db (driectory)- new style done by wise2xhmmer2 GeneWise/EstWise algorithm support genewisemodel - extended HMM for genewise/estwise geneparameter - raw frequencies for gene model geneparser21 - probability model for 21:93 geneparser4 - probability model for 6/4 state models splicesitemodeler - splice site models GeneWise algorithms genewise4 - 421 algorithm genewise6 - 623 algorithm genewise21 - 2193 algorithm geneloop6 - 623 looping algorithm geneloop21 - 2193 looping algorithm EstWise algorithms estwise3 - 333 algorithm estloop3 - 333 looping algorithm estfrag3 - [not used] est fragment estslim3 - 312 algorithm Clean api into package gwrap - genewise algorithm API estwrap - estwise algorithm API dba support dba - dba algorithm Executable main functions genewise.c - genewise genewisedb.c estwise.c estwisedb.c psw - protein smith waterman dbac.c - dba calling function wise-2.4.1/src/makefile0000644000175000001440000001324710414207325014345 0ustar philippusers # # This is the top level makefile for Wise2. It drives the underlying # makefile - for normal usage you do not need to cd into the underlying # directories. # # # all is the target for the binaries in the system # # clean does remove all .o and .a files and moves the current # binaries over to oldbin # # # # You may want to change these lines if you have # a non ansi C compiler # Change the cc line to gcc if you get compiler errors # Most likely you have a non ANSI C compiler # CC = /opt/intel_cc_80/bin/icc CC = cc # These are the CFLAGS to use. These days Wise2 is inherently # pthreaded, and everything is compiled with threads. However # the main algorithms don't really take advantage of pthreads, # it is more about making sure the libaries are thread safe # Intel icc flags # CFLAGS = -c -O3 -axWK -ipo `glib-config --cflags` # alpha flags (-pthread) # CFLAGS = -c -O3 -pthread `glib-config --cflags` # normal linux/bsd/mac flags CFLAGS = -c -O3 `glib-config --cflags` EXTRALIBS = -lm # # To compile with a different version of HMMER, change the following # lines. This is not recommended, because sean and I diverged a while # back on indexing stratgies. At some point I will need to port the later # HMMer into Wise2 # HMMER_INCLUDE = ../HMMer2/ HMMER_LIBS = ../HMMer2/ HMMER_DEFINE = HMMER_INTERNAL #HMMER_DEFINE = HMMER_2_1_2=1 #HMMER_INCLUDE = /nfs/disk21/birney/prog/hmmer-2.1.2/src/ #HMMER_LIBS = /nfs/disk21/birney/prog/hmmer-2.1.2/src/ # # You shouldn't want to change anything below this. # start : @echo 'to make the wise2 development directory read INSTALL\n\nmake all will try to make the package\n' boot : cd bootstrap ; $(MAKE) dyc cd dyc ; ../bootstrap/dyc -l *.dy cd base ; ../bootstrap/dyc -n Wise2_ -l *.dy @echo '\n\nDon't worry about the above errors: now make newdyc' newdyc : (cd base ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" libwisebase.a ) (cd dyc ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" dyc ) @echo '\n\nNow move dyc/dyc to somewhere on your path' @echo 'setenv WISECONFIGDIR to wisecfg and make init followed by make all' all : realall $(MAKE) bin realall : (cd base ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" libwisebase.a ) (cd HMMer2 ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" libhmmer.a ) (cd dynlibsrc ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" libdyna.a ) (cd dynlibsrc ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" libdyna_glib.a ) (cd external ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" all ) (cd socket ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" libwisesocket.a ) (cd dnaindex ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" all ) (cd network ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" all ) (cd models ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" EXTRALIBS="$(EXTRALIBS)" HMMER_DEFINE="$(HMMER_DEFINE)" HMMER_INCLUDE="$(HMMER_INCLUDE)" HMMER_LIBS="$(HMMER_LIBS)" all ) strict : (cd base ; $(MAKE) CC="gcc" CFLAGS="-g -c -Wall -DNOERROR" libwisebase.a ) (cd HMMer2 ; $(MAKE) CC="gcc" CFLAGS="-g -c -Wall" libhmmer.a ) (cd dynlibsrc ; $(MAKE) CC="gcc" CFLAGS="-g -c -Wall" libdyna.a ) (cd models ; $(MAKE) CC="gcc" CFLAGS="-g -c -Wall" all ) debug : (cd base ; $(MAKE) CC="cc" CFLAGS="-g -c -DNOERROR" libwisebase.a ) (cd HMMer2 ; $(MAKE) CC="cc" CFLAGS="-g -c" libhmmer.a ) (cd dynlibsrc ; $(MAKE) CC="cc" CFLAGS="-g -c" libdyna.a ) (cd models ; $(MAKE) CC="cc" CFLAGS="-g -c" all ) bin : mkdir bin cp models/pswdb models/psw models/genewisedb models/estwisedb models/estwise models/genewise models/dba models/dnal models/promoterwise network/scanwise_server models/scanwise ./bin csh welcome.csh libs : (cd base ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" libwisebase.a ) (cd HMMer2 ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" libhmmer.a ) (cd dynlibsrc ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" libdyna.a ) (cd models ; $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" libmodel.a ) init : cd base ; $(MAKE) init cd dynlibsrc; $(MAKE) init cd models ; $(MAKE) init cd dyc ; $(MAKE) init cd socket ; $(MAKE) init cd dnaindex ; $(MAKE) init cd network; $(MAKE) init clean : cd external ; $(MAKE) clean -if test -d dynlibsrc; then cd dynlibsrc ; rm -f *.[oa]; fi -if test -d models; then cd models ; rm -f *.[oa]; fi -if test -d base; then cd base ; rm -f *.[oa]; fi -if test -d socket; then cd socket ; rm -f *.[oa]; fi -if test -d dnaindex; then cd dnaindex ; rm -f *.[oa]; fi -if test -d network; then cd network ; rm -f *.[oa]; fi -if test -d dyc; then cd dyc ; rm -f *.[oa]; fi -if test -d HMMer2; then cd HMMer2 ; rm -f *.[oa]; fi -if test -d perl; then cd perl/Wise2/libs ; rm -f *.[oa]; fi -if test -x perl/Wise2/Makefile; then cd perl/Wise2/ ; $(MAKE) clean; fi -if test -d oldbin; then rm -rf oldbin; fi -if test -d bin; then echo 'moving binaries to oldbin'; mv -f bin oldbin; fi api : libs apimake apimake : cd api/include ; $(MAKE) apih cd api/libs ; $(MAKE) apilibs @echo 'Now cd into api/examples and try some out!' perl : libs perlmake perlmake : cd perl ; $(MAKE) int libs cd perl/Wise2 ; perl Makefile.PL cd perl/Wise2 ; $(MAKE) @echo 'Now cd into perl/Wise2 and make install, once becoming root/perl master' test : test_dummy test_dummy : cd test ; perl testman.pl -cf ../wisecfg < short.test removedyc : (cd base ; rm -f *.dy) (cd dynlibsrc ; rm -f *.dy) (cd models ; rm -f *.dy) rm -rf dyc rm -rf bootstrap docs : realdocs realdocs : (cd docs ; $(MAKE) api) (cd docs ; $(MAKE) progdoc ) dycdist : (cd base ; rm -f *.dy) (cd dynlibsrc ; rm -f *.dy) (rm -rf models) (rm -rf api) (rm -rf HMMer2) (rm -rf perl) (rm -rf test) (rm -rf INSTALL) (rm welcome.csh) (rm -rf example) (cd dyc ; rm -f *.dy) (rm -rf bootstrap) (mv -f DYNAMITE_README README) (mv -f makefile.dynamite makefile) (mv dynamite_examples examples) wise-2.4.1/src/contig/0000755000175000001440000000000010670453556014136 5ustar philippuserswise-2.4.1/src/contig/makefile0000644000175000001440000000106407327243127015633 0ustar philippusers .SUFFIXES : .dy .c.o : $(CC) $(CFLAGS) $(INCFLAGS) $? INCFLAGS = -I../base/ -I../dynlibsrc/ DFLAGS = -l -D -n Wise2_ -a _api.h -b _api.t -latex -perl -pthreads -dbtrace 5 -nocwarn #DFLAGS = -l -O -D -n Wise2_ -a _api.h -b _api.t -latex -perl -pthreads -dbtrace 5 #DFLAGS = -l -n Wise2_ LFLAGS = -g -L../base/ -L../dynlibsrc/ OBJ = contig.o overlap.o testoverlap : testoverlap.o $(OBJ) $(CC) -o testoverlap testoverlap.o contig.o overlap.o -lwisebase -ldyna $(LFLAGS) CC = cc CFLAGS = -c -g -I../base/ -I../dynlibsrc/ .dy.c : dyc $(DFLAGS) $< wise-2.4.1/src/contig/contig.dy0000644000175000001440000000425707332745037015766 0ustar philippusers %{ #include "dyna.h" #define ContigCollectionLISTLENGTH 128 #define ContigLISTLENGTH 128 %} struct Contig char* id struct Wise2_Contig * real_5peer !link int golden_start struct Wise2_Contig * real_3peer !link int golden_end struct ContigCollection Contig ** contig !list %{ #include "contig.h" void Contig_agp(Contig * leftmost,char * ctg_name,FILE * ofp) { Contig * c; int ori = 1; int start = 1; int len; for(c=leftmost;c!= NULL;c = Contig_walk_right(c,&ori) ) { len = c->golden_end - c->golden_start +1; fprintf(ofp,"%s\t%d\t%d\t%s\t%d\t%d\t%d\n",ctg_name,start,start+len,c->id,c->golden_start,c->golden_end,ori); } } Contig * Contig_walk_right(Contig * p,int * ori) { if( *ori == 1 ) { /* normal - take the 3' peer */ if( p->real_3peer == NULL ) { /* finished */ *ori = 5; return NULL; } if( p->real_3peer->real_5peer == p ) { /* same orientation */ *ori = 1; return p->real_3peer; } else if ( p->real_3peer->real_3peer == p ) { *ori = -1; return p->real_3peer; } else { fatal("In walk at contig %s, failed to walk to my peer!",p->id); } } else if( *ori == -1 ) { /* take the 5' peer */ if( p->real_5peer == NULL ) { /* finished */ *ori = 5; return NULL; } if( p->real_5peer->real_5peer == p ) { /* orientation flips to 1 */ *ori = 1; return p->real_5peer; } else if ( p->real_5peer->real_3peer == p ) { *ori = -1; return p->real_5peer; } else { fatal("In walk at contig %s, failed to walk to my peer!",p->id); } } else { fatal("In walk at contig %s, got a weird orientation %d",p->id,*ori); } /* should not reach here */ } Contig * ContigCollection_find(ContigCollection * c,char * id) { int i; /* yup - should be a hash */ for(i=0;ilen;i++) { if( strcmp(c->contig[i]->id,id) == 0 ) { return c->contig[i]; } } return NULL; } Contig * Contig_from_line(char * line) { char * run1; char * run2; Contig * c; run1 = strtok(line,spacestr); run2 = strtok(line,spacestr); c = Contig_alloc(); c->id = stringalloc(run2); return c; } %} wise-2.4.1/src/contig/testoverlap.c0000644000175000001440000000043307327243127016646 0ustar philippusers#include "overlap.h" int main ( int argc, char ** argv) { ContigAssembly * ca; FILE * ifp; ifp = fopen(argv[1],"r"); ca = ContigAssembly_read(ifp); ContigAssembly_validate(ca); OverlapCollection_sort_by_score(ca->overlap); ContigAssembly_dump(ca,stdout); } wise-2.4.1/src/contig/overlap.dy0000644000175000001440000001270607337172606016152 0ustar philippusers %{ #include "dyna.h" #include "contig.h" #define OverlapCollectionLISTLENGTH 128 typedef enum OverlapTypeUsage { OVERLAP_TYPE_INIT, OVERLAP_TYPE_CIRCULAR, OVERLAP_TYPE_USED, OVERLAP_TYPE_UNUSED } OverlapType; %} struct Overlap char * leftid Contig * left int left_direction int left_switch char * rightid Contig * right int right_direction int right_switch double score int length OverlapType type !def="OVERLAP_TYPE_INIT" struct OverlapCollection Overlap ** overlap !list struct ContigAssembly ContigCollection * contig OverlapCollection * overlap Contig * leftmost !link %{ #include "overlap.h" void ContigAssembly_agp(ContigAssembly * ca,char * ctg_name,FILE *ofp) { int i; Contig ** processed_ends; /* find all the unsatisified ends */ } void ContigAssembly_assembl(ContigAssembly * ca) { Overlap * o; int i; /* * sort by score * for each overlap * if( left end is open and right end is open) * if ( left walk ends in no end or right walk ends in no end ) * assign circular * else * attach left contig to right contig with direction * assign overlap_used * else * assign overlap_unused */ OverlapCollection_sort_by_score(ca->overlap); for(i=0;ioverlap->len;i++) { o = ca->overlap->overlap[i]; if( o->left_direction == 1 ) { /* means we want to attach to 5' */ if( o->left->real_5peer != NULL ) { o->type = OVERLAP_TYPE_UNUSED; continue; } } else { if( o->left->real_3peer != NULL ) { o->type = OVERLAP_TYPE_UNUSED; continue; } } /* symmetrical about the right hand side */ if( o->right_direction == 1 ) { /* means we want to attach to 5' */ if( o->right->real_5peer != NULL ) { o->type = OVERLAP_TYPE_UNUSED; continue; } } else { if( o->right->real_3peer != NULL ) { o->type = OVERLAP_TYPE_UNUSED; continue; } } /* * NOT IMPLEMENTED YET - CIRCULARITY CHECK */ /* we can use the overlap */ o->type = OVERLAP_TYPE_USED; /* * attach underlying contigs * direction is implict ie * if( contig->real_5peer == contig->real_5peer->real_3peer ) * forward::forward overlap * is attached on the left or the right */ if( o->left_direction == 1 ) { o->left->real_5peer = o->right; o->left->golden_start = o->left_switch; } else { o->left->real_3peer = o->right; o->left->golden_end = o->left_switch; } if( o->right_direction == 1 ) { o->right->real_5peer = o->left; o->right->golden_start = o->right_switch; } else { o->right->real_3peer = o->left; o->right->golden_end = o->right_switch; } } /* done */ } void OverlapCollection_sort_by_score(OverlapCollection * oc) { sort_OverlapCollection(oc,Overlap_cmp_by_score); } int Overlap_cmp_by_score(Overlap * one,Overlap * two) { if( one->score > two->score ) { return -1; } else { return 1; } } boolean ContigAssembly_validate(ContigAssembly * ca) { int i; Contig * c; for(i=0;ioverlap->len;i++) { c = ContigCollection_find(ca->contig,ca->overlap->overlap[i]->leftid); if( c == NULL ) { return FALSE; } ca->overlap->overlap[i]->left = c; c = ContigCollection_find(ca->contig,ca->overlap->overlap[i]->rightid); if( c == NULL ) { return FALSE; } ca->overlap->overlap[i]->right = c; } return TRUE; } ContigAssembly * ContigAssembly_read(FILE * ifp) { char buffer[MAXLINE]; ContigAssembly * out; Contig * c; Overlap * o; out = ContigAssembly_alloc(); out->contig = ContigCollection_alloc_std(); out->overlap = OverlapCollection_alloc_std(); while( fgets(buffer,MAXLINE,ifp) ) { if( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"contig") == 0 ) { c = Contig_from_line(buffer); add_ContigCollection(out->contig,c); } else if ( strstartcmp(buffer,"overlap") == 0 ) { o = Overlap_from_line(buffer); add_OverlapCollection(out->overlap,o); } else { fprintf(stderr,"Unable to parse line %s",buffer); } } return out; } void ContigAssembly_dump(ContigAssembly * ca,FILE * ofp) { int i; for(i=0;icontig->len;i++) { fprintf(ofp,"Contig %s\n",ca->contig->contig[i]->id); } for(i=0;ioverlap->len;i++) { fprintf(ofp,"Overlap %s %s %f\n",ca->overlap->overlap[i]->leftid, ca->overlap->overlap[i]->rightid, ca->overlap->overlap[i]->score); } } Overlap * Overlap_from_line(char * line) { Overlap * out; char ** base; char ** brk; out = Overlap_alloc(); /* line is * overlap contig-a contig-b switch-a direction-a switch-b direction-b score length */ base=brk=breakstring(line,spacestr); brk++; out->leftid = stringalloc(*brk); brk++; out->rightid = stringalloc(*brk); brk++; if( is_integer_string(*brk,&out->left_switch) == FALSE ) { fatal("parsing error in overlap"); } brk++; if( is_integer_string(*brk,&out->left_direction) == FALSE ) { fatal("parsing error in overlap"); } brk++; if( is_integer_string(*brk,&out->right_switch) == FALSE ) { fatal("parsing error in overlap"); } brk++; if( is_integer_string(*brk,&out->right_direction) == FALSE ) { fatal("parsing error in overlap"); } brk++; is_double_string(*brk,&out->score); brk++; is_integer_string(*brk,&out->length); ckfree(base); return out; } %} wise-2.4.1/src/network/0000755000175000001440000000000010670453716014342 5ustar philippuserswise-2.4.1/src/network/README0000644000175000001440000000042207731657041015221 0ustar philippusers The network directory contains the main functions and interfaces that can draw information across all of the socket, dynlibsrc and model code to produce network servers and client interfaces Low level socket and marshalling framework is provided by the socket directory wise-2.4.1/src/network/wise_proteinindex_server.c0000644000175000001440000001610110421421617021617 0ustar philippusers#include "sequencedb.h" #include "seqlookup.h" #include "subseqhash.h" #include "subseqlookup.h" #include "hsplookupscan.h" #include "hsptwohitscan.h" #include "hsplookupthreaded.h" #include "hspthreadeddb.h" #include "hspscanruntime.h" #include "hsp2hitscan.h" #include "arrayseqlookup.h" #include "proteinstreamedindex.h" #include "compressed_protein_index.h" #include "kmer_direct.h" #include "../models/version.h" #include "net_hspscan.h" #include /* gettimeofday() */ char * program_name = "scanwise_server"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s sequence_file_fasta\n",program_name); fprintf(ofp,"\nThis program builds a in memory index of a protein database for use by \n"); fprintf(ofp,"the scanwise family of methods. It runs a wise-style server on the specified port\n"); fprintf(ofp,"For most databases you need around 10GB of memory\n\n"); fprintf(ofp," OPTIONS\n"); fprintf(ofp," -port port to bind to (default 4050)\n"); fprintf(ofp," -compress use compressed index, for large indexes\n"); fprintf(ofp," -hash use glib hash not array (far slower, but easier on the memory for small DBs)\n"); fprintf(ofp," -twohit use two hit seed HSP strategy (can be faster for big databases)\n"); fprintf(ofp," -streamed use streamed index (more compact, higher run-time)\n"); fprintf(ofp," -ocfile occupancy file for array/streamed indexes (large), for debugging\n"); fprintf(ofp,"Search Implementation (default is to provide runtime switch vanilla/threaded/twohit)\n"); fprintf(ofp," -usevanilla use a vanilla implementation only\n"); fprintf(ofp," -usethreads use a threaded query scan implementation only\n"); fprintf(ofp," -threadeddb use a threaded database scan implementation\n"); fprintf(ofp," -ordered use ordered access implementation\n"); fprintf(ofp," -threadno [2] number of threads for threaded scan implementation\n"); fprintf(ofp," -drop_off [40] hsp drop off parameter\n"); fprintf(ofp," -array_numb [1000000] hard array numb level in index building\n"); show_help_SeqLookupLoadPara(ofp); show_standard_options(ofp); } int main(int argc, char* argv[]) { int i; Wise2_HSPScanInterface * hsi; SequenceDB * db; Sequence * seq; int ret; SeqLookupInterface * sli; CompMat * mat; FILE * ofp; KmerIndexInterface * kii; int count = 0; int is_array = 0; int waystation = 4; int drop_off = 40; int score_cutoff = 20; char * ior_file; char * oc_file = NULL; char * temp; SeqLookupLoadPara * slp; boolean use_hash = 0; boolean use_stream = 0; boolean use_comp = 0; boolean use_ordered = 0; boolean use_threads = 0; boolean use_vanilla = 0; int threadno = 2; int array_numb_level = 1000000; boolean use_two_hit = 0; boolean use_threadeddb = 0; /* threaded database implementations are a bit special */ HSPThreadedDatabase * tdb; FunctionServer * fs; FunctionImplementation * impl; int port = 4050; struct timeval t0, t1; gettimeofday(&t0, NULL); slp = new_SeqLookupLoadPara_from_argv(&argc,argv); use_hash = strip_out_boolean_argument(&argc,argv,"hash"); use_stream = strip_out_boolean_argument(&argc,argv,"streamed"); use_comp = strip_out_boolean_argument(&argc,argv,"compress"); use_threadeddb = strip_out_boolean_argument(&argc,argv,"threadeddb"); strip_out_integer_argument(&argc,argv,"array_numb",&array_numb_level); use_threads = strip_out_boolean_argument(&argc,argv,"usethreads"); use_vanilla = strip_out_boolean_argument(&argc,argv,"usevanilla"); strip_out_integer_argument(&argc,argv,"threadno",&threadno); strip_out_integer_argument(&argc,argv,"drop_off",&drop_off); strip_out_integer_argument(&argc,argv,"hspext_cutoff",&score_cutoff); use_ordered = strip_out_boolean_argument(&argc,argv,"ordered"); use_two_hit = strip_out_boolean_argument(&argc,argv,"twohit"); strip_out_integer_argument(&argc,argv,"waystation",&waystation); oc_file = strip_out_assigned_argument(&argc,argv,"ocfile"); strip_out_integer_argument(&argc,argv,"port",&port); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 2 ) { show_help(stdout); exit(12); } fs = new_FunctionServer(port); db = single_fasta_SequenceDB(argv[1]); mat = read_Blast_file_CompMat("blosum62.bla"); if( use_stream == 1 ) { sli = new_ProteinStreamedIndex_SeqLookupInterface(waystation); } else if( use_hash == 1 ) { sli = new_ghash_SeqLookupInterface(); } else if ( use_comp == 1 ) { /* this is a little weird */ /* the kmer index system was originally designed for DNA */ /* 12mers in kmer space is about the same as 5mers in aa space */ kii = new_KmerDirectIndex(12); sli = new_CompressedProteinLookup(kii); } else if ( use_threadeddb == 1 ) { /* do nothing here, as we have to do this different */ } else { is_array = 1; sli = new_ArraySeq_SeqLookupInterface(26*26*26*26*26,array_numb_level); } if( use_threadeddb != 1 ) { load_SequenceDB_SeqLookupLoadPara(slp,db,sli); if( (is_array == 1 || use_stream == 1) && oc_file != NULL) { ofp = fopen(oc_file,"w"); if( ofp != NULL ) { info("Printing index occupancy"); if( is_array == 1 ) { print_array_occuypancy_ArraySeq((ArraySeqLookup*)sli->data,ofp); } else { dump_ProteinStreamedIndex((ProteinStreamedIndex*)sli->data,ofp); } info("Finished index occupancy"); fclose(ofp); } } if( use_ordered ) { hsi = new_ordered_HSPScanInterface(sli,mat,40,10); } else if( use_threads ) { hsi = new_threaded_HSPScanInterface(sli,mat,40,10,threadno); } else if( use_two_hit ) { hsi = new_twohit_one_off_HSPScanInterface(sli,mat,drop_off,score_cutoff); } else if ( use_vanilla ) { hsi = Wise2_new_one_off_HSPScanInterface(sli,mat,drop_off,score_cutoff); } else { /* provide runtime implementation */ hsi = new_runtime_HSPScanInterface(sli,mat,drop_off,score_cutoff,threadno); } } else { tdb = new_HSPThreadedDatabase(threadno,array_numb_level); load_HSPThreadedDatabase(tdb,db,slp,mat,drop_off,score_cutoff); hsi = new_HSPScanInterface_from_HSPThreadedDatabase(tdb); } impl = new_hspscan_protein_FunctionImplementation(hsi); add_FunctionServer(fs,impl); gettimeofday(&t1, NULL); info("[server stats] startup time (s): %f", (t1.tv_sec - t0.tv_sec) + (t1.tv_usec - t0.tv_usec) * 1e-6); info("Started server on port %d",port); main_loop_forking_FunctionServer(fs,1); return 0; } wise-2.4.1/src/network/makefile0000644000175000001440000000207410421463722016035 0ustar philippusers .SUFFIXES : .dy CC = cc INCFLAGS = -I../base/ -I../socket -I../dynlibsrc -I../dnaindex CFLAGS = -O2 -c -pthread -DUNIX -I../base/ -I../socket -I../dynlibsrc -I../dnaindex `glib-config --cflags` LFLAGS = -g -L../base/ -L../socket -L../dynlibsrc -L../dnaindex -lm `glib-config --libs` AR_OPTIONS = ru RANLIB_NEEDED = 0 all : scanwise_server client_multihspscan.o scanwise_server : wise_proteinindex_server.o net_hspscan.o ../dynlibsrc/libdyna.a ../dynlibsrc/libdyna_glib.a ../dnaindex/compressed_protein_index.o ../dnaindex/kmer_index_interface.o ../dnaindex/singleseqspace.o ../dnaindex/kmer_direct.o $(CC) -g -o scanwise_server wise_proteinindex_server.o net_hspscan.o ../dnaindex/compressed_protein_index.o ../dnaindex/kmer_index_interface.o ../dnaindex/singleseqspace.o ../dnaindex/kmer_direct.o -ldyna_glib -ldyna -lwisesocket -lwisebase $(LFLAGS) -lpthread .c.o : $(CC) $(CFLAGS) $(INCFLAGS) $? DFLAGS = -l -n Wise2_ -a _api.h -b _api.t -latex -perl .dy.c : dyc $(DFLAGS) $< .dy.o : dyc $(DFLAGS) $< $(CC) $(CFLAGS) $*.c init: dyc $(DFLAGS) *.dy wise-2.4.1/src/network/net_hspscan.c0000644000175000001440000001171610670453716017021 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "net_hspscan.h" # line 20 "net_hspscan.dy" HSPScanInterface * new_wise_transfer_HSPScanInterface(char * host,int port) { HSPScanInterface * out; FunctionProxyCoordinator * fpc; out = HSPScanInterface_alloc(); fpc = new_just_hspscan_FunctionProxyCoordinator(host,port); out->data = (void*) fpc; out->scan_query = dispatch_hspscan_FunctionProxyCoordinator; out->free_data = free_hspscan_FunctionProxyCoordinator; return out; } # line 36 "net_hspscan.dy" LinearHSPmanager * dispatch_hspscan_FunctionProxyCoordinator(void * h,Sequence * seq,HSPScanInterfacePara * para) { FunctionProxyCoordinator * fpc = (FunctionProxyCoordinator*) h; LinearHSPmanager * lm; AnonymousObject * ao; AnonymousObjectList * aol; aol = AnonymousObjectList_alloc_len(2); ao = AnonymousObject_alloc(); ao->obj = hard_link_Sequence(seq); ao->free_object = untyped_free_Sequence; add_AnonymousObjectList(aol,ao); ao = AnonymousObject_alloc(); ao->obj = hard_link_HSPScanInterfacePara(para); ao->free_object = untyped_HSPScanInterfacePara_free; add_AnonymousObjectList(aol,ao); ao = dispatch_FunctionProxy(fpc,"hspscan_protein",aol); free_AnonymousObjectList(aol); /* transfer memory ownership to typed return value */ lm = ao->obj; ao->obj = NULL; free_AnonymousObject(ao); return lm; } # line 70 "net_hspscan.dy" void free_hspscan_FunctionProxyCoordinator(void * h) { FunctionProxyCoordinator * fpc = (FunctionProxyCoordinator*) h; free_FunctionProxyCoordinator(fpc); } # line 78 "net_hspscan.dy" FunctionProxyCoordinator * new_just_hspscan_FunctionProxyCoordinator(char * host,int port) { FunctionProxyCoordinator * out; out = new_FunctionProxyCoordinator(host,port); add_FunctionProxyCoordinator(out,new_FunctionProxy(new_hspscan_protein_TransferedFunctionCall())); return out; } # line 89 "net_hspscan.dy" TransferedObjectMarshaller * HSPScanInterfacePara_TransferedObjectMarshaller(void) { TransferedObjectMarshaller * out; out = TransferedObjectMarshaller_alloc(); out->object_to_stream = untyped_HSPScanInterfacePara_to_Stream; out->stream_to_object = untyped_read_HSPScanInterfacePara_from_Stream; out->object_type = "HSPScanInterfacePara"; out->untyped_free_object = untyped_HSPScanInterfacePara_free; return out; } # line 103 "net_hspscan.dy" TransferedObjectMarshaller * Sequence_TransferedObjectMarshaller(void) { TransferedObjectMarshaller * out; out = TransferedObjectMarshaller_alloc(); out->object_to_stream = untyped_write_Sequence_to_Stream; out->stream_to_object = untyped_read_Sequence_from_Stream; out->object_type = "Sequence"; out->untyped_free_object = untyped_free_Sequence; return out; } # line 118 "net_hspscan.dy" TransferedObjectMarshaller * LinearHSPmanager_TransferedObjectMarshaller(void) { TransferedObjectMarshaller * out; out = TransferedObjectMarshaller_alloc(); out->object_to_stream = untyped_LinearHSPmanager_to_Stream; out->stream_to_object = untyped_LinearHSPmanager_from_Stream; out->object_type = "LinearHSPmanager"; out->untyped_free_object = untyped_free_LinearHSPmanager; return out; } # line 136 "net_hspscan.dy" TransferedFunctionCall * new_hspscan_protein_TransferedFunctionCall(void) { TransferedFunctionCall * out; out = TransferedFunctionCall_alloc_std(); out->name = stringalloc("hspscan_protein"); out->returned_type = LinearHSPmanager_TransferedObjectMarshaller(); add_TransferedFunctionCall(out,Sequence_TransferedObjectMarshaller()); add_TransferedFunctionCall(out,HSPScanInterfacePara_TransferedObjectMarshaller()); return out; } # line 151 "net_hspscan.dy" FunctionImplementation * new_hspscan_protein_FunctionImplementation(HSPScanInterface * hspi) { FunctionImplementation * out; out = FunctionImplementation_alloc(); out->transfer = new_hspscan_protein_TransferedFunctionCall(); out->implementation = hspscan_protein_simple_impl; out->handle = hspi; return out; } # line 164 "net_hspscan.dy" AnonymousObject * hspscan_protein_simple_impl(void * h,AnonymousObjectList * aol) { HSPScanInterface * hsi = (HSPScanInterface*) h; Sequence * seq ; LinearHSPmanager * lm; AnonymousObject * ao; HSPScanInterfacePara * para; assert(aol != NULL); assert(aol->len == 2); seq = (Sequence*)aol->anon[0]->obj; para = (HSPScanInterfacePara *)aol->anon[1]->obj; assert(seq != NULL); assert(para != NULL); lm = (*hsi->scan_query)(hsi->data,seq,para); lm->query = hard_link_Sequence(seq); ao = AnonymousObject_alloc(); ao->obj = lm; ao->type = "LinearHSPmanager"; ao->free_object = untyped_free_LinearHSPmanager; return ao; } # line 194 "net_hspscan.dy" void untyped_free_Sequence(void * h) { Sequence * s = (Sequence *) h; free_Sequence(s); } # line 201 "net_hspscan.dy" void untyped_free_LinearHSPmanager(void * h) { LinearHSPmanager * lm = (LinearHSPmanager *)h; free_LinearHSPmanager(lm); } # line 207 "net_hspscan.c" #ifdef _cplusplus } #endif wise-2.4.1/src/network/net_hspscan.h0000644000175000001440000000553310670453716017026 0ustar philippusers#ifndef DYNAMITEnet_hspscanHEADERFILE #define DYNAMITEnet_hspscanHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "hspscaninterface.h" #include "functionserver.h" #include "functionclient.h" #include "sequencestream.h" #include "hspstream.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Unplaced functions */ /* There has been no indication of the use of these functions */ HSPScanInterface * Wise2_new_wise_transfer_HSPScanInterface(char * host,int port); #define new_wise_transfer_HSPScanInterface Wise2_new_wise_transfer_HSPScanInterface LinearHSPmanager * Wise2_dispatch_hspscan_FunctionProxyCoordinator(void * h,Sequence * seq,HSPScanInterfacePara * para); #define dispatch_hspscan_FunctionProxyCoordinator Wise2_dispatch_hspscan_FunctionProxyCoordinator void Wise2_free_hspscan_FunctionProxyCoordinator(void * h); #define free_hspscan_FunctionProxyCoordinator Wise2_free_hspscan_FunctionProxyCoordinator FunctionProxyCoordinator * Wise2_new_just_hspscan_FunctionProxyCoordinator(char * host,int port); #define new_just_hspscan_FunctionProxyCoordinator Wise2_new_just_hspscan_FunctionProxyCoordinator TransferedObjectMarshaller * Wise2_HSPScanInterfacePara_TransferedObjectMarshaller(void); #define HSPScanInterfacePara_TransferedObjectMarshaller Wise2_HSPScanInterfacePara_TransferedObjectMarshaller TransferedObjectMarshaller * Wise2_Sequence_TransferedObjectMarshaller(void); #define Sequence_TransferedObjectMarshaller Wise2_Sequence_TransferedObjectMarshaller TransferedObjectMarshaller * Wise2_LinearHSPmanager_TransferedObjectMarshaller(void); #define LinearHSPmanager_TransferedObjectMarshaller Wise2_LinearHSPmanager_TransferedObjectMarshaller TransferedFunctionCall * Wise2_new_hspscan_protein_TransferedFunctionCall(void); #define new_hspscan_protein_TransferedFunctionCall Wise2_new_hspscan_protein_TransferedFunctionCall FunctionImplementation * Wise2_new_hspscan_protein_FunctionImplementation(HSPScanInterface * hspi); #define new_hspscan_protein_FunctionImplementation Wise2_new_hspscan_protein_FunctionImplementation AnonymousObject * Wise2_hspscan_protein_simple_impl(void * h,AnonymousObjectList * aol); #define hspscan_protein_simple_impl Wise2_hspscan_protein_simple_impl void Wise2_untyped_free_Sequence(void * h); #define untyped_free_Sequence Wise2_untyped_free_Sequence void Wise2_untyped_free_LinearHSPmanager(void * h); #define untyped_free_LinearHSPmanager Wise2_untyped_free_LinearHSPmanager /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/network/net_hspscan.dy0000644000175000001440000001130310364126067017177 0ustar philippusers %{ #include "hspscaninterface.h" #include "functionserver.h" #include "functionclient.h" #include "sequencestream.h" #include "hspstream.h" %} %{ #include "net_hspscan.h" HSPScanInterface * new_wise_transfer_HSPScanInterface(char * host,int port) { HSPScanInterface * out; FunctionProxyCoordinator * fpc; out = HSPScanInterface_alloc(); fpc = new_just_hspscan_FunctionProxyCoordinator(host,port); out->data = (void*) fpc; out->scan_query = dispatch_hspscan_FunctionProxyCoordinator; out->free_data = free_hspscan_FunctionProxyCoordinator; return out; } LinearHSPmanager * dispatch_hspscan_FunctionProxyCoordinator(void * h,Sequence * seq,HSPScanInterfacePara * para) { FunctionProxyCoordinator * fpc = (FunctionProxyCoordinator*) h; LinearHSPmanager * lm; AnonymousObject * ao; AnonymousObjectList * aol; aol = AnonymousObjectList_alloc_len(2); ao = AnonymousObject_alloc(); ao->obj = hard_link_Sequence(seq); ao->free_object = untyped_free_Sequence; add_AnonymousObjectList(aol,ao); ao = AnonymousObject_alloc(); ao->obj = hard_link_HSPScanInterfacePara(para); ao->free_object = untyped_HSPScanInterfacePara_free; add_AnonymousObjectList(aol,ao); ao = dispatch_FunctionProxy(fpc,"hspscan_protein",aol); free_AnonymousObjectList(aol); /* transfer memory ownership to typed return value */ lm = ao->obj; ao->obj = NULL; free_AnonymousObject(ao); return lm; } void free_hspscan_FunctionProxyCoordinator(void * h) { FunctionProxyCoordinator * fpc = (FunctionProxyCoordinator*) h; free_FunctionProxyCoordinator(fpc); } FunctionProxyCoordinator * new_just_hspscan_FunctionProxyCoordinator(char * host,int port) { FunctionProxyCoordinator * out; out = new_FunctionProxyCoordinator(host,port); add_FunctionProxyCoordinator(out,new_FunctionProxy(new_hspscan_protein_TransferedFunctionCall())); return out; } TransferedObjectMarshaller * HSPScanInterfacePara_TransferedObjectMarshaller(void) { TransferedObjectMarshaller * out; out = TransferedObjectMarshaller_alloc(); out->object_to_stream = untyped_HSPScanInterfacePara_to_Stream; out->stream_to_object = untyped_read_HSPScanInterfacePara_from_Stream; out->object_type = "HSPScanInterfacePara"; out->untyped_free_object = untyped_HSPScanInterfacePara_free; return out; } TransferedObjectMarshaller * Sequence_TransferedObjectMarshaller(void) { TransferedObjectMarshaller * out; out = TransferedObjectMarshaller_alloc(); out->object_to_stream = untyped_write_Sequence_to_Stream; out->stream_to_object = untyped_read_Sequence_from_Stream; out->object_type = "Sequence"; out->untyped_free_object = untyped_free_Sequence; return out; } TransferedObjectMarshaller * LinearHSPmanager_TransferedObjectMarshaller(void) { TransferedObjectMarshaller * out; out = TransferedObjectMarshaller_alloc(); out->object_to_stream = untyped_LinearHSPmanager_to_Stream; out->stream_to_object = untyped_LinearHSPmanager_from_Stream; out->object_type = "LinearHSPmanager"; out->untyped_free_object = untyped_free_LinearHSPmanager; return out; } TransferedFunctionCall * new_hspscan_protein_TransferedFunctionCall(void) { TransferedFunctionCall * out; out = TransferedFunctionCall_alloc_std(); out->name = stringalloc("hspscan_protein"); out->returned_type = LinearHSPmanager_TransferedObjectMarshaller(); add_TransferedFunctionCall(out,Sequence_TransferedObjectMarshaller()); add_TransferedFunctionCall(out,HSPScanInterfacePara_TransferedObjectMarshaller()); return out; } FunctionImplementation * new_hspscan_protein_FunctionImplementation(HSPScanInterface * hspi) { FunctionImplementation * out; out = FunctionImplementation_alloc(); out->transfer = new_hspscan_protein_TransferedFunctionCall(); out->implementation = hspscan_protein_simple_impl; out->handle = hspi; return out; } AnonymousObject * hspscan_protein_simple_impl(void * h,AnonymousObjectList * aol) { HSPScanInterface * hsi = (HSPScanInterface*) h; Sequence * seq ; LinearHSPmanager * lm; AnonymousObject * ao; HSPScanInterfacePara * para; assert(aol != NULL); assert(aol->len == 2); seq = (Sequence*)aol->anon[0]->obj; para = (HSPScanInterfacePara *)aol->anon[1]->obj; assert(seq != NULL); assert(para != NULL); lm = (*hsi->scan_query)(hsi->data,seq,para); lm->query = hard_link_Sequence(seq); ao = AnonymousObject_alloc(); ao->obj = lm; ao->type = "LinearHSPmanager"; ao->free_object = untyped_free_LinearHSPmanager; return ao; } void untyped_free_Sequence(void * h) { Sequence * s = (Sequence *) h; free_Sequence(s); } void untyped_free_LinearHSPmanager(void * h) { LinearHSPmanager * lm = (LinearHSPmanager *)h; free_LinearHSPmanager(lm); } %} wise-2.4.1/src/network/client_multihspscan.dy0000644000175000001440000000755010420650634020746 0ustar philippusers %{ #include "net_hspscan.h" #define MultiHSPScanClientLISTLENGTH 32 #define MAX_CLIENT_HSP_THREADS 128 %} struct HSPScanClient char * host int port HSPScanInterface * hspi !def="NULL" LinearHSPmanager * lm !def="NULL" Sequence * seq !link HSPScanInterfacePara * p !link struct MultiHSPScanClient HSPScanClient ** client !list %{ #include "client_multihspscan.h" LinearHSPmanager * scan_MultiHSPScanClient(void * data,Sequence * seq,HSPScanInterfacePara * para) { LinearHSPmanager * out; MultiHSPScanClient * mhsc; pthread_attr_t pat; pthread_t thread_pool[MAX_CLIENT_HSP_THREADS]; int i; int j; int total_len; int err; mhsc = (MultiHSPScanClient *) data; assert(mhsc != NULL); assert(seq != NULL); assert(mhsc->len < MAX_CLIENT_HSP_THREADS); pthread_attr_init(&pat); #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(mhsc->len+1); #endif /* set concurrency */ for(i=0,total_len = 0;ilen;i++) { mhsc->client[i]->seq = seq; mhsc->client[i]->p = para; if( (err = pthread_create(&(thread_pool[i]),&pat,client_hsp_thread_worker,(void*)mhsc->client[i])) ) { fatal("Unable to make thread %d with error %d",i,err); } } for(i=0;ilen;i++) { if( pthread_join(thread_pool[i],NULL) != 0 ) { fatal("Unable to join thread in client hsp"); } total_len += mhsc->client[i]->lm->len; } out = LinearHSPmanager_alloc_len(total_len); for(i=0;ilen;i++) { for(j=0;jclient[i]->lm->len;j++) { add_LinearHSPmanager(out,hard_link_HSPset(mhsc->client[i]->lm->set[j])); } } qsort(out->set,out->len,sizeof(HSPset*),compare_HSPset_score_qsort); return out; } void * client_hsp_thread_worker(void * d) { HSPScanClient * cl; cl = (HSPScanClient *) d; assert(cl != NULL); if( cl->p->verbosity > 4 ) { info("Client side thread starting for %s %d",cl->host,cl->port); } cl->lm = (*cl->hspi->scan_query)(cl->hspi->data,cl->seq,cl->p); if( cl->p->verbosity > 4 ) { info("Client side thread ending for %s %d",cl->host,cl->port); } return 0; } HSPScanInterface * new_multiclient_HSPScanInterface(char * filename) { HSPScanInterface * out; FILE * ifp; MultiHSPScanClient * mhsc; if( (ifp = openfile(filename,"r")) == NULL ) { warn("Unable to open %s as file for multi scan client",filename); return NULL; } mhsc = new_MultiHSPScanClient_from_file(ifp); assert(mhsc != NULL); out = HSPScanInterface_alloc(); out->data = (void *) mhsc; out->scan_query = scan_MultiHSPScanClient; out->free_data = free_multihspscanclient; } void free_multihspscanclient(void * data) { MultiHSPScanClient * d; d = (MultiHSPScanClient *) data; free_MultiHSPScanClient(d); } MultiHSPScanClient * new_MultiHSPScanClient_from_file(FILE * ifp) { MultiHSPScanClient * out; HSPScanClient * cl; char buffer[MAXLINE]; char * name; char * port; char * r; out = MultiHSPScanClient_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"//") == 0 ) { break; } name = buffer; for(r = buffer;*r && !isspace(*r);r++) { ; } *r = '\0'; r++; for(;*r && isspace(*r);r++) { ; } port = r; for(;*r && !isspace(*r);r++) { ; } *r = '\0'; cl = HSPScanClient_alloc(); cl->host = stringalloc(name); cl->port = strtol(port,NULL,0); cl->hspi = new_wise_transfer_HSPScanInterface(cl->host,cl->port); if( cl->hspi == NULL ) { warn("Unable to make client with %s host, %d port",cl->host,cl->port); free_MultiHSPScanClient(out); return NULL; } add_MultiHSPScanClient(out,cl); } return out; } %} wise-2.4.1/src/network/client_multihspscan.c0000644000175000001440000003474610670453716020574 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "client_multihspscan.h" # line 29 "client_multihspscan.dy" LinearHSPmanager * scan_MultiHSPScanClient(void * data,Sequence * seq,HSPScanInterfacePara * para) { LinearHSPmanager * out; MultiHSPScanClient * mhsc; pthread_attr_t pat; pthread_t thread_pool[MAX_CLIENT_HSP_THREADS]; int i; int j; int total_len; int err; mhsc = (MultiHSPScanClient *) data; assert(mhsc != NULL); assert(seq != NULL); assert(mhsc->len < MAX_CLIENT_HSP_THREADS); pthread_attr_init(&pat); #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(mhsc->len+1); #endif /* set concurrency */ for(i=0,total_len = 0;ilen;i++) { mhsc->client[i]->seq = seq; mhsc->client[i]->p = para; if( (err = pthread_create(&(thread_pool[i]),&pat,client_hsp_thread_worker,(void*)mhsc->client[i])) ) { fatal("Unable to make thread %d with error %d",i,err); } } for(i=0;ilen;i++) { if( pthread_join(thread_pool[i],NULL) != 0 ) { fatal("Unable to join thread in client hsp"); } total_len += mhsc->client[i]->lm->len; } out = LinearHSPmanager_alloc_len(total_len); for(i=0;ilen;i++) { for(j=0;jclient[i]->lm->len;j++) { add_LinearHSPmanager(out,hard_link_HSPset(mhsc->client[i]->lm->set[j])); } } qsort(out->set,out->len,sizeof(HSPset*),compare_HSPset_score_qsort); return out; } # line 83 "client_multihspscan.dy" void * client_hsp_thread_worker(void * d) { HSPScanClient * cl; cl = (HSPScanClient *) d; assert(cl != NULL); if( cl->p->verbosity > 4 ) { info("Client side thread starting for %s %d",cl->host,cl->port); } cl->lm = (*cl->hspi->scan_query)(cl->hspi->data,cl->seq,cl->p); if( cl->p->verbosity > 4 ) { info("Client side thread ending for %s %d",cl->host,cl->port); } return 0; } # line 107 "client_multihspscan.dy" HSPScanInterface * new_multiclient_HSPScanInterface(char * filename) { HSPScanInterface * out; FILE * ifp; MultiHSPScanClient * mhsc; if( (ifp = openfile(filename,"r")) == NULL ) { warn("Unable to open %s as file for multi scan client",filename); return NULL; } mhsc = new_MultiHSPScanClient_from_file(ifp); assert(mhsc != NULL); out = HSPScanInterface_alloc(); out->data = (void *) mhsc; out->scan_query = scan_MultiHSPScanClient; out->free_data = free_multihspscanclient; } # line 130 "client_multihspscan.dy" void free_multihspscanclient(void * data) { MultiHSPScanClient * d; d = (MultiHSPScanClient *) data; free_MultiHSPScanClient(d); } # line 140 "client_multihspscan.dy" MultiHSPScanClient * new_MultiHSPScanClient_from_file(FILE * ifp) { MultiHSPScanClient * out; HSPScanClient * cl; char buffer[MAXLINE]; char * name; char * port; char * r; out = MultiHSPScanClient_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"//") == 0 ) { break; } name = buffer; for(r = buffer;*r && !isspace(*r);r++) { ; } *r = '\0'; r++; for(;*r && isspace(*r);r++) { ; } port = r; for(;*r && !isspace(*r);r++) { ; } *r = '\0'; cl = HSPScanClient_alloc(); cl->host = stringalloc(name); cl->port = strtol(port,NULL,0); cl->hspi = new_wise_transfer_HSPScanInterface(cl->host,cl->port); if( cl->hspi == NULL ) { warn("Unable to make client with %s host, %d port",cl->host,cl->port); free_MultiHSPScanClient(out); return NULL; } add_MultiHSPScanClient(out,cl); } return out; } # line 171 "client_multihspscan.c" /* Function: hard_link_HSPScanClient(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPScanClient *] * * Return [UNKN ] Undocumented return value [HSPScanClient *] * */ HSPScanClient * hard_link_HSPScanClient(HSPScanClient * obj) { if( obj == NULL ) { warn("Trying to hard link to a HSPScanClient object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HSPScanClient_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPScanClient *] * */ HSPScanClient * HSPScanClient_alloc(void) { HSPScanClient * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HSPScanClient *) ckalloc (sizeof(HSPScanClient))) == NULL) { warn("HSPScanClient_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->host = NULL; out->port = 0; out->hspi = NULL; out->lm = NULL; return out; } /* Function: free_HSPScanClient(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPScanClient *] * * Return [UNKN ] Undocumented return value [HSPScanClient *] * */ HSPScanClient * free_HSPScanClient(HSPScanClient * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HSPScanClient obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->host != NULL) ckfree(obj->host); if( obj->hspi != NULL) free_HSPScanInterface(obj->hspi); if( obj->lm != NULL) free_LinearHSPmanager(obj->lm); /* obj->seq is linked in */ /* obj->p is linked in */ ckfree(obj); return NULL; } /* Function: swap_MultiHSPScanClient(list,i,j) * * Descrip: swap function: an internal for qsort_MultiHSPScanClient * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [HSPScanClient **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_MultiHSPScanClient(HSPScanClient ** list,int i,int j) { HSPScanClient * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_MultiHSPScanClient(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_MultiHSPScanClient which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [HSPScanClient **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_MultiHSPScanClient(HSPScanClient ** list,int left,int right,int (*comp)(HSPScanClient * ,HSPScanClient * )) { int i,last; if( left >= right ) return; swap_MultiHSPScanClient(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_MultiHSPScanClient (list,++last,i); } swap_MultiHSPScanClient (list,left,last); qsort_MultiHSPScanClient(list,left,last-1,comp); qsort_MultiHSPScanClient(list,last+1,right,comp); } /* Function: sort_MultiHSPScanClient(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_MultiHSPScanClient * * * Arg: obj [UNKN ] Object containing list [MultiHSPScanClient *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_MultiHSPScanClient(MultiHSPScanClient * obj,int (*comp)(HSPScanClient *, HSPScanClient *)) { qsort_MultiHSPScanClient(obj->client,0,obj->len-1,comp); return; } /* Function: expand_MultiHSPScanClient(obj,len) * * Descrip: Really an internal function for add_MultiHSPScanClient * * * Arg: obj [UNKN ] Object which contains the list [MultiHSPScanClient *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_MultiHSPScanClient(MultiHSPScanClient * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_MultiHSPScanClient called with no need"); return TRUE; } if( (obj->client = (HSPScanClient ** ) ckrealloc (obj->client,sizeof(HSPScanClient *)*len)) == NULL) { warn("ckrealloc failed for expand_MultiHSPScanClient, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_MultiHSPScanClient(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [MultiHSPScanClient *] * Arg: add [OWNER] Object to add to the list [HSPScanClient *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_MultiHSPScanClient(MultiHSPScanClient * obj,HSPScanClient * add) { if( obj->len >= obj->maxlen) { if( expand_MultiHSPScanClient(obj,obj->len + MultiHSPScanClientLISTLENGTH) == FALSE) return FALSE; } obj->client[obj->len++]=add; return TRUE; } /* Function: flush_MultiHSPScanClient(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [MultiHSPScanClient *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_MultiHSPScanClient(MultiHSPScanClient * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->client[i] != NULL) { free_HSPScanClient(obj->client[i]); obj->client[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: MultiHSPScanClient_alloc_std(void) * * Descrip: Equivalent to MultiHSPScanClient_alloc_len(MultiHSPScanClientLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [MultiHSPScanClient *] * */ MultiHSPScanClient * MultiHSPScanClient_alloc_std(void) { return MultiHSPScanClient_alloc_len(MultiHSPScanClientLISTLENGTH); } /* Function: MultiHSPScanClient_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [MultiHSPScanClient *] * */ MultiHSPScanClient * MultiHSPScanClient_alloc_len(int len) { MultiHSPScanClient * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = MultiHSPScanClient_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->client = (HSPScanClient ** ) ckcalloc (len,sizeof(HSPScanClient *))) == NULL) { warn("Warning, ckcalloc failed in MultiHSPScanClient_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_MultiHSPScanClient(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MultiHSPScanClient *] * * Return [UNKN ] Undocumented return value [MultiHSPScanClient *] * */ MultiHSPScanClient * hard_link_MultiHSPScanClient(MultiHSPScanClient * obj) { if( obj == NULL ) { warn("Trying to hard link to a MultiHSPScanClient object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: MultiHSPScanClient_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MultiHSPScanClient *] * */ MultiHSPScanClient * MultiHSPScanClient_alloc(void) { MultiHSPScanClient * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(MultiHSPScanClient *) ckalloc (sizeof(MultiHSPScanClient))) == NULL) { warn("MultiHSPScanClient_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->client = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_MultiHSPScanClient(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MultiHSPScanClient *] * * Return [UNKN ] Undocumented return value [MultiHSPScanClient *] * */ MultiHSPScanClient * free_MultiHSPScanClient(MultiHSPScanClient * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a MultiHSPScanClient obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->client != NULL) { for(i=0;ilen;i++) { if( obj->client[i] != NULL) free_HSPScanClient(obj->client[i]); } ckfree(obj->client); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/network/client_multihspscan.h0000644000175000001440000001635510670453716020575 0ustar philippusers#ifndef DYNAMITEclient_multihspscanHEADERFILE #define DYNAMITEclient_multihspscanHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "net_hspscan.h" #define MultiHSPScanClientLISTLENGTH 32 #define MAX_CLIENT_HSP_THREADS 128 struct Wise2_HSPScanClient { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * host; int port; HSPScanInterface * hspi; LinearHSPmanager * lm; Sequence * seq; HSPScanInterfacePara * p; } ; /* HSPScanClient defined */ #ifndef DYNAMITE_DEFINED_HSPScanClient typedef struct Wise2_HSPScanClient Wise2_HSPScanClient; #define HSPScanClient Wise2_HSPScanClient #define DYNAMITE_DEFINED_HSPScanClient #endif struct Wise2_MultiHSPScanClient { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif HSPScanClient ** client; int len;/* len for above client */ int maxlen; /* maxlen for above client */ } ; /* MultiHSPScanClient defined */ #ifndef DYNAMITE_DEFINED_MultiHSPScanClient typedef struct Wise2_MultiHSPScanClient Wise2_MultiHSPScanClient; #define MultiHSPScanClient Wise2_MultiHSPScanClient #define DYNAMITE_DEFINED_MultiHSPScanClient #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_HSPScanClient(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPScanClient *] * * Return [UNKN ] Undocumented return value [HSPScanClient *] * */ HSPScanClient * Wise2_hard_link_HSPScanClient(HSPScanClient * obj); #define hard_link_HSPScanClient Wise2_hard_link_HSPScanClient /* Function: HSPScanClient_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPScanClient *] * */ HSPScanClient * Wise2_HSPScanClient_alloc(void); #define HSPScanClient_alloc Wise2_HSPScanClient_alloc /* Function: free_HSPScanClient(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPScanClient *] * * Return [UNKN ] Undocumented return value [HSPScanClient *] * */ HSPScanClient * Wise2_free_HSPScanClient(HSPScanClient * obj); #define free_HSPScanClient Wise2_free_HSPScanClient /* Function: add_MultiHSPScanClient(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [MultiHSPScanClient *] * Arg: add [OWNER] Object to add to the list [HSPScanClient *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_MultiHSPScanClient(MultiHSPScanClient * obj,HSPScanClient * add); #define add_MultiHSPScanClient Wise2_add_MultiHSPScanClient /* Function: flush_MultiHSPScanClient(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [MultiHSPScanClient *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_MultiHSPScanClient(MultiHSPScanClient * obj); #define flush_MultiHSPScanClient Wise2_flush_MultiHSPScanClient /* Function: MultiHSPScanClient_alloc_std(void) * * Descrip: Equivalent to MultiHSPScanClient_alloc_len(MultiHSPScanClientLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [MultiHSPScanClient *] * */ MultiHSPScanClient * Wise2_MultiHSPScanClient_alloc_std(void); #define MultiHSPScanClient_alloc_std Wise2_MultiHSPScanClient_alloc_std /* Function: MultiHSPScanClient_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [MultiHSPScanClient *] * */ MultiHSPScanClient * Wise2_MultiHSPScanClient_alloc_len(int len); #define MultiHSPScanClient_alloc_len Wise2_MultiHSPScanClient_alloc_len /* Function: hard_link_MultiHSPScanClient(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MultiHSPScanClient *] * * Return [UNKN ] Undocumented return value [MultiHSPScanClient *] * */ MultiHSPScanClient * Wise2_hard_link_MultiHSPScanClient(MultiHSPScanClient * obj); #define hard_link_MultiHSPScanClient Wise2_hard_link_MultiHSPScanClient /* Function: MultiHSPScanClient_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MultiHSPScanClient *] * */ MultiHSPScanClient * Wise2_MultiHSPScanClient_alloc(void); #define MultiHSPScanClient_alloc Wise2_MultiHSPScanClient_alloc /* Function: free_MultiHSPScanClient(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MultiHSPScanClient *] * * Return [UNKN ] Undocumented return value [MultiHSPScanClient *] * */ MultiHSPScanClient * Wise2_free_MultiHSPScanClient(MultiHSPScanClient * obj); #define free_MultiHSPScanClient Wise2_free_MultiHSPScanClient /* Unplaced functions */ /* There has been no indication of the use of these functions */ LinearHSPmanager * Wise2_scan_MultiHSPScanClient(void * data,Sequence * seq,HSPScanInterfacePara * para); #define scan_MultiHSPScanClient Wise2_scan_MultiHSPScanClient void * Wise2_client_hsp_thread_worker(void * d); #define client_hsp_thread_worker Wise2_client_hsp_thread_worker HSPScanInterface * Wise2_new_multiclient_HSPScanInterface(char * filename); #define new_multiclient_HSPScanInterface Wise2_new_multiclient_HSPScanInterface void Wise2_free_multihspscanclient(void * data); #define free_multihspscanclient Wise2_free_multihspscanclient MultiHSPScanClient * Wise2_new_MultiHSPScanClient_from_file(FILE * ifp); #define new_MultiHSPScanClient_from_file Wise2_new_MultiHSPScanClient_from_file /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_MultiHSPScanClient(HSPScanClient ** list,int i,int j) ; #define swap_MultiHSPScanClient Wise2_swap_MultiHSPScanClient void Wise2_qsort_MultiHSPScanClient(HSPScanClient ** list,int left,int right,int (*comp)(HSPScanClient * ,HSPScanClient * )); #define qsort_MultiHSPScanClient Wise2_qsort_MultiHSPScanClient void Wise2_sort_MultiHSPScanClient(MultiHSPScanClient * obj,int (*comp)(HSPScanClient *, HSPScanClient *)); #define sort_MultiHSPScanClient Wise2_sort_MultiHSPScanClient boolean Wise2_expand_MultiHSPScanClient(MultiHSPScanClient * obj,int len); #define expand_MultiHSPScanClient Wise2_expand_MultiHSPScanClient #ifdef _cplusplus } #endif #endif wise-2.4.1/src/other_programs/0000755000175000001440000000000010670453616015703 5ustar philippuserswise-2.4.1/src/other_programs/orthoset.dy0000644000175000001440000003614010350327256020107 0ustar philippusers %{ #include "dyna.h" #define OrthoLinkLISTLENGTH 50 #define OrthoNodeLISTLENGTH 50 #define OrthoNode_consLISTLENGTH 50 #define OrthoSpeciesLISTLENGTH 50 #define OrthoGraphLISTLENGTH 50 #define OrthoGraph_speciesLISTLENGTH 20 #define OrthoWrapperListLISTLENGTH 400 #define OrthoNodePathLISTLENGTH 40 %} friend OrthoSeqPos struct OrthoSpecies char * name OrthoSeqPos ** cons !list struct OrthoSeqPos OrthoSpecies * species !link char * seq_name int start int end int strand int score OrthoSeqPos * prev !link OrthoSeqPos * next !link friend OrthoNode struct OrthoLink OrthoSeqPos ** seq !list OrthoNode * left OrthoNode * right int is_consistent !def="0" int is_accounted !def="0" struct OrthoNode OrthoSeqPos ** cons !list !len="cons_" OrthoLink ** link !list int is_dead !def="0" int is_consistent !def="0" int is_break !def="0" struct OrthoNodeWrapper OrthoNode * node !link OrthoSeqPos * seqpos !link struct OrthoWrapperList OrthoNodeWrapper ** w !list struct OrthoGraph OrthoNode ** node !list OrthoSpecies ** species !list !len="species_" struct OrthoGraphLinkPara int max_internode_size !def="200000" struct OrthoNodePath OrthoNodeWrapper ** path !list int is_complex !def="0"; %{ #include "orthoset.h" OrthoNodePath * new_OrthoNodePath_from_break(OrthoNode * start,OrthoLink * first) { int i; int j; OrthoLink * curr; OrthoLink * next; OrthoNode * curr_n; OrthoNodePath * path; OrthoNodeWrapper * w; path = OrthoNodePath_alloc_std(); w = OrthoNodeWrapper_alloc(); w->node = start; add_OrthoNodePath(path,w); curr = first; curr->is_accounted = 1; curr_n = start; while( 1 ) { /* find next node from curr and curr_n */ if( curr->left == curr_n ) { curr_n = curr->right; } else { curr_n = curr->left; } /* add this node into list */ w = OrthoNodeWrapper_alloc(); w->node = curr_n; add_OrthoNodePath(path,w); /* if this is a break node, stop */ if( curr_n->is_break == 1 ) { break; } /* if this node has only one link, stop. End of chromosome! */ if( curr_n->len < 2 ) { break; } /* else, find next link by finding outbound link with highest number of species */ /* if we have more than 2 links, then this path is complex and will need additional processing */ if( curr_n->len > 2 ) { path->is_complex = 1; } next = NULL; for(i=0;ilen;i++) { if( curr_n->link[i] == curr ) { continue; } if( next == NULL ) { next = curr_n->link[i]; } else if ( next->len < curr_n->link[i]->len ) { next = curr_n->link[i]; } } fatal("Actually we have to be careful here to not tread on already accounted for links!"); if( next == NULL ) { warn("This should be impossible! Node with 2 or more links but not a next findable link!"); break; } next->is_accounted = 1; curr = next; } return path; } void classify_definite_break_OrthoNodes(OrthoGraph * g) { int i; int j; int k; int link; /* definite breaks have > 3 links, each link with >1 species */ for(i=0;ilen;i++) { if( g->node[i]->len < 3 ) { continue; } link = 0; for(j=0;jnode[i]->len;j++) { if( g->node[i]->link[j]->len > 1 ) { link++; if( link > 2 ) { break; } } } if( link > 2 ) { g->node[i]->is_break = 1; } } } void classify_consistent_OrthoNodes(OrthoGraph * g) { int i; int j; int k; int spflag; int foundsp; for(i=0;ilen;i++) { if( g->node[i]->len != 2 ) { continue; } spflag = 0; for(j=0;jnode[i]->link[0]->len;j++) { foundsp = 0; for(k=0;knode[i]->link[1]->len;k++) { if( g->node[i]->link[0]->seq[j]->species == g->node[i]->link[1]->seq[k]->species ) { foundsp = 1; break; } } if( foundsp == 0 ) { spflag = 1; break; } } if( spflag == 0 ) { g->node[i]->is_consistent = 1; g->node[i]->link[0]->is_consistent = 1; g->node[i]->link[1]->is_consistent = 1; } } } OrthoLink * find_connecting_OrthoLink(OrthoNode * a,OrthoNode * b) { int i; OrthoNode * t; /* make sure a > b in memory */ if( b > a ) { t = a; a = b; b = t; } for(i=0;ilen;i++) { if( a->link[i]->left == a && a->link[i]->right == b ) { return a->link[i]; } } return NULL; } OrthoNode * next_OrthoNode_considering_species(OrthoNode * curr,OrthoLink * prev) { int found; OrthoLink * l; int i,j; assert(curr != NULL); assert(prev != NULL); if( curr->len != 2 ) { return NULL; } if( curr->link[0] == prev ) { l = curr->link[1]; } else { if( curr->link[1] != prev ) { warn("Suggesting a link which doesn't lead to this node!"); return NULL; } l = curr->link[0]; } for(i=0;ilen;i++) { found = 0; for(j=0;jlen;j++) { if( prev->seq[i]->species == l->seq[i]->species ) { found = 1; break; } } if( found == 0 ) { return NULL; } } if( l->left == curr ) { return l->right; } else { return l->left; } } void add_OrthoLinks_to_OrthoGraph(OrthoGraph * g,OrthoGraphLinkPara * p) { int i,j,k; OrthoWrapperList * owl; OrthoSeqPos * seqpos; OrthoLink * link; int strand; /* * basic algorithm - for each species, pull * out an OrthoNodeWrapper, which has all active nodes * with this species represented. Sort this by * chr and start position. Put in the links along * this set of OrthoNodes. If there is an existing link * between two nodes then just add to this link */ for(i=0;ispecies_len;i++) { owl = new_OrthoWrapperList_from_OrthoGraph(g,g->species[i]); sort_by_chr_start_OrthoWrapperList(owl); for(j=1;jlen;j++) { if( strcmp(owl->w[j]->seqpos->seq_name,owl->w[j-1]->seqpos->seq_name) != 0 ) { continue; /* no link */ } if( owl->w[j-1]->seqpos->end + p->max_internode_size < owl->w[j]->seqpos->start ) { continue; /* no link */ } /* make a link; first off check if we already have a link */ link = NULL; for(k=0;kw[j-1]->node->len;k++) { /* convention is for links always to have the higher node position * on the right link and the lower on the left link */ if( owl->w[j-1]->node > owl->w[j]->node ) { if( owl->w[j-1]->node->link[k]->left == owl->w[j]->node ) { link = owl->w[j-1]->node->link[k]; strand = -1; break; } } else { if( owl->w[j-1]->node->link[k]->right == owl->w[j]->node ) { link = owl->w[j-1]->node->link[k]; strand = 1; break; } } } if( link == NULL ) { /* we did not find this link, make a new one */ /* convention is that the memory-higher node * is to the right */ link = OrthoLink_alloc_std(); if( owl->w[j-1]->node > owl->w[j]->node ) { link->left = owl->w[j]->node; link->right = owl->w[j-1]->node; strand = -1; } else { link->right = owl->w[j]->node; link->left = owl->w[j-1]->node; strand = 1; } add_OrthoNode(owl->w[j-1]->node,link); add_OrthoNode(owl->w[j]->node,link); } /* now put in seqpos at this link */ seqpos = OrthoSeqPos_alloc(); seqpos->species = g->species[i]; seqpos->seq_name = stringalloc(owl->w[j-1]->seqpos->seq_name); seqpos->start = owl->w[j-1]->seqpos->end; seqpos->end = owl->w[j]->seqpos->start; seqpos->strand = strand; add_OrthoLink(link,seqpos); } free_OrthoWrapperList(owl); } } void sort_by_chr_start_OrthoWrapperList(OrthoWrapperList * owl) { sort_OrthoWrapperList(owl,compare_OrthoNodeWrapper); } int compare_OrthoNodeWrapper(OrthoNodeWrapper * one,OrthoNodeWrapper * two) { int t; t = strcmp(one->seqpos->seq_name,two->seqpos->seq_name); if( t != 0 ) { return t; } return (one->seqpos->start - two->seqpos->start); } OrthoWrapperList * new_OrthoWrapperList_from_OrthoGraph(OrthoGraph * g,OrthoSpecies * sp) { int i; int j; OrthoNodeWrapper * w; OrthoWrapperList * out; assert(g != NULL); assert(sp != NULL); out = OrthoWrapperList_alloc_std(); for(i=0;ilen;i++) { if( g->node[i]->is_dead == 1 ) { continue; } for(j=0;jnode[i]->cons_len;j++) { if( g->node[i]->cons[j]->species == sp ) { w = OrthoNodeWrapper_alloc(); w->node = g->node[i]; w->seqpos = g->node[i]->cons[j]; add_OrthoWrapperList(out,w); } } } return out; } OrthoGraph * merged_OrthoGraph_from_pairwise(OrthoGraph * pair) { int i,j,k,l; boolean been_seen; OrthoGraph * g; OrthoNode * current; g = OrthoGraph_alloc_std(); for(i=0;ispecies_len;i++) { add_species_OrthoGraph(g,hard_link_OrthoSpecies(pair->species[i])); } /* for each node in the pairwise set, loop over all existing nodes. If they can merge, add them into. Watch out for a pairwise node bridging between two new nodes - will need merging of nodes followed by deleting one of the new nodes */ for(i=0;ilen;i++) { current = NULL; for(j=0;jlen;j++) { fprintf(stderr,"Considering pair %d with new %d (%d)\n",i,j,g->node[j]->is_dead); if( g->node[j]->is_dead == 0 && overlap_OrthoNode(g->node[j],pair->node[i]) == TRUE ) { current = g->node[j]; for(k=0;knode[i]->cons_len;k++) { /* we need to check that this new SeqPos is not overlapping with one already; * if so, we want to just extend that SeqPos. We can have more than one SeqPos * per node, but _not_ more than one overlapping SeqPos */ been_seen = 0; for(l=0;lcons_len;l++) { if( overlap_OrthoSeqPos(current->cons[l],pair->node[i]->cons[k]) == TRUE ) { been_seen = 1; if( current->cons[l]->start > pair->node[i]->cons[k]->start ) { current->cons[l]->start = pair->node[i]->cons[k]->start; } if( current->cons[l]->end < pair->node[i]->cons[k]->end ) { current->cons[l]->end = pair->node[i]->cons[k]->end; } break; } } if( been_seen == 0 ) { add_cons_OrthoNode(g->node[j],hard_link_OrthoSeqPos(pair->node[i]->cons[k])); } } break; } } /* need to think about meeting new nodes */ /* if we hit another node in the merged set, (g) then * we add this to current, which is the new merged node in * here. When we do this we flag that node as dead in the * merged set */ for(j++;jlen;j++) { if( g->node[j]->is_dead == 0 && overlap_OrthoNode(g->node[j],pair->node[i]) == TRUE ) { for(k=0;knode[j]->cons_len;k++) { add_cons_OrthoNode(current,hard_link_OrthoSeqPos(g->node[j]->cons[k])); } g->node[j]->is_dead = 1; } } /* if current still is NULL here, then this is a currently orphaned node */ if( current == NULL ) { add_OrthoGraph(g,hard_link_OrthoNode(pair->node[i])); } } return g; } boolean overlap_OrthoNode(OrthoNode * rec,OrthoNode * donor) { int i; assert(rec != NULL); assert(donor != NULL); assert(donor->cons_len == 2); for(i=0;icons_len;i++) { fprintf(stderr,"Looking at species %s %s vs %s\n", donor->cons[0]->species->name, donor->cons[1]->species->name, rec->cons[i]->species->name); if( rec->cons[i]->species == donor->cons[0]->species ) if( overlap_OrthoSeqPos(rec->cons[i],donor->cons[0]) == TRUE ) { return TRUE; } if( rec->cons[i]->species == donor->cons[1]->species ) if( overlap_OrthoSeqPos(rec->cons[i],donor->cons[1]) == TRUE ) { return TRUE; } } return FALSE; } boolean overlap_OrthoSeqPos(OrthoSeqPos * one,OrthoSeqPos * two) { assert(one != NULL); assert(two != NULL); if( one->species != two->species ) { return FALSE; } if( strcmp(one->seq_name,two->seq_name) != 0 ) { return FALSE; } if( ! ( ( one->start > two->end) || (one->end < two->start)) ) { return TRUE; } return FALSE; } void read_pairwise_OrthoSeqPos(OrthoGraph * g,FILE * ifp) { char buffer[MAXLINE]; char species1[MAXLINE]; char species2[MAXLINE]; char chr1[MAXLINE]; char chr2[MAXLINE]; int start1,end1,strand1,start2,end2,strand2,score; OrthoSeqPos * one; OrthoSeqPos * two; OrthoSpecies * sp_one = NULL; OrthoSpecies * sp_two = NULL; OrthoNode * n; while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"//") == 0 ) { return; } if( buffer[0] == '#' ) { continue; } /* species chr start end strand species chr start end strand score */ if( sscanf(buffer,"%s %s %d %d %d %s %s %d %d %d %d", species1, chr1, &start1, &end1, &strand1, species2, chr2, &start2, &end2, &strand2, &score ) != 11 ) { warn("Unable to parse %s as species line"); continue; } if( sp_one == NULL || strcmp(sp_one->name,species1) != 0 ) { sp_one = OrthoSpecies_from_name(g,species1); if( sp_one == NULL ) { sp_one = OrthoSpecies_alloc_std(); sp_one->name = stringalloc(species1); add_species_OrthoGraph(g,sp_one); } } if( sp_two == NULL || strcmp(sp_two->name,species2) != 0 ) { sp_two = OrthoSpecies_from_name(g,species2); if( sp_two == NULL ) { sp_two = OrthoSpecies_alloc_std(); sp_two->name = stringalloc(species2); add_species_OrthoGraph(g,sp_two); } } one = OrthoSeqPos_alloc(); two = OrthoSeqPos_alloc(); one->species = sp_one; one->seq_name = stringalloc(chr1); one->start = start1; one->end = end1; one->strand = strand1; two->species = sp_two; two->seq_name = stringalloc(chr2); two->start = start2; two->end = end2; two->strand = strand2; n = OrthoNode_alloc_len(2); add_cons_OrthoNode(n,one); add_cons_OrthoNode(n,two); add_OrthoGraph(g,n); } return; } void * dump_simple_OrthoGraph(OrthoGraph * g,FILE * ofp) { int i,j,k; assert(g != NULL); assert(ofp != NULL); for(i=0;ilen;i++) { fprintf(ofp,"Node %d (id %d) with %d anchors consistent %d\n",i,(int)g->node[i],g->node[i]->cons_len,g->node[i]->is_consistent); for(j=0;jnode[i]->cons_len;j++) { fprintf(ofp," Anchor %s %s %d %d %d %d\n", g->node[i]->cons[j]->species->name, g->node[i]->cons[j]->seq_name, g->node[i]->cons[j]->start, g->node[i]->cons[j]->end, g->node[i]->cons[j]->strand, g->node[i]->cons[j]->score); } for(j=0;jnode[i]->len;j++) { fprintf(ofp," Link to "); if( g->node[i]->link[j]->left == g->node[i] ) { fprintf(ofp," %d\n",g->node[i]->link[j]->right); } else { fprintf(ofp," %d\n",g->node[i]->link[j]->left); } for(k=0;knode[i]->link[j]->len;k++) { fprintf(ofp," span %s %s %d %d %d %d\n", g->node[i]->link[j]->seq[k]->species->name, g->node[i]->link[j]->seq[k]->seq_name, g->node[i]->link[j]->seq[k]->start, g->node[i]->link[j]->seq[k]->end, g->node[i]->link[j]->seq[k]->strand, g->node[i]->link[j]->seq[k]->score); } } } } OrthoSpecies * OrthoSpecies_from_name(OrthoGraph * g,char * name) { int i; assert(g != NULL); for(i=0;ispecies_len;i++) { if( strcmp(g->species[i]->name,name) == 0 ) { return g->species[i]; } } return NULL; } %} wise-2.4.1/src/other_programs/makefile0000644000175000001440000000064510327350142017375 0ustar philippusers .SUFFIXES : .dy CC = cc CFLAGS = -O2 -g3 -c -pthread -DUNIX -I../base/ -I../dynlibsrc `glib-config --cflags` LFLAGS = -g -L../base/ -L../dynlibsrc -lm `glib-config --libs` AR_OPTIONS = ru RANLIB_NEEDED = 0 .c.o : $(CC) $(CFLAGS) $(INCFLAGS) $? DFLAGS = -l -n Wise2_ -a _api.h -b _api.t -latex -perl .dy.c : dyc $(DFLAGS) $< .dy.o : dyc $(DFLAGS) $< $(CC) $(CFLAGS) $*.c init: dyc $(DFLAGS) *.dy wise-2.4.1/src/other_programs/test_ortho.c0000644000175000001440000000073710345025225020236 0ustar philippusers#include "orthoset.h" int main(int argc,char ** argv) { OrthoGraph * g; OrthoGraph * m; OrthoGraphLinkPara * p; g = OrthoGraph_alloc_std(); read_pairwise_OrthoSeqPos(g,stdin); dump_simple_OrthoGraph(g,stdout); m = merged_OrthoGraph_from_pairwise(g); fprintf(stdout,"//\n"); dump_simple_OrthoGraph(m,stdout); fprintf(stdout,"//\n"); p = OrthoGraphLinkPara_alloc(); add_OrthoLinks_to_OrthoGraph(m,p); dump_simple_OrthoGraph(m,stdout); } wise-2.4.1/src/models/0000755000175000001440000000000010670453715014133 5ustar philippuserswise-2.4.1/src/models/pswdb.c0000644000175000001440000003154107705225351015420 0ustar philippusers/* pswdb.c database smith/waterman searching. will also include abc model. pre-alpha Modelled on estwisedb.c Richard Copley. 6/12/1998 */ #include "dyna.h" #include "abc.h" #include "pba.h" #include "sw_wrap.h" #include "seqaligndisplay.h" #include "version.h" #include #include char * program_name = "pswdb"; CompMat * mat = NULL; DBSearchImpl * dbsi = NULL; Hscore * hs = NULL; DPRunImpl * dpri = NULL; ProteinDB * tdb = NULL; ProteinDB * qdb = NULL; int gap = 12; int ext = 2; int a = 120; int b = 10; int c = 3; int report_stagger = 100; int aln_number = 500; int max_desc = 500; char * querydb = NULL; char * targetdb = NULL; char * matrix_file = "BLOSUM62.bla"; char * output_file = "-"; char * cutoff_str = NULL; double search_cutoff = 40; double prob_cutoff = 10; boolean show_histogram = TRUE; boolean show_ids = FALSE; boolean show_pretty = TRUE; boolean use_abc = FALSE; boolean use_pba = FALSE; boolean use_query_db = FALSE; boolean fit_histogram = TRUE; /* makes an alignment anchored to the query sequence */ boolean make_anchored_alignment = FALSE; FILE * ofp = NULL; void show_help(FILE * ofp) { fprintf(ofp,"\npswdb \nSeqs in fasta format\n" "\t-g gap penalty (default 12)\n" "\t-e ext penatly (default 2)\n" "\t-m comp matrix (default BLOSUM62.bla)\n" "\t-abc use the abc model\n" "\t-a a penalty for above (default 120)\n" "\t-b b penalty for above (default 10)\n" "\t-c c penalty for above (default 3)\n" "\t-pba use the pba model\n" "\t-max_desc Number of one line descriptions (default = 500)\n" "\t-max_aln Number of alignments to show (default = 50)\n" "\t-cut Search cutoff (score) (default = 40)\n" "\t-ids Output seq ids with alignments\n" "\t-nohis do not fit histogram\n" ); /* show dbsearch impl help */ show_help_DBSearchImpl(ofp); /* show run time */ show_help_DPRunImpl(ofp); /* standard options */ fprintf(stdout,"Standard options\n"); fprintf(stdout," -help help\n -version show version and compile info\n -silent No messages on stderr\n -quiet No report on stderr\n -erroroffstd No warning messages to stderr\n -errorlog [file] Log warning messages to file\n"); fprintf(stdout,"\nSee WWW help at http://www.somewhere.edu/\n"); } void show_version(void) { fprintf(stdout,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(stdout,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(stdout,"The source code is copyright (c) EMBL 1998 and others\n"); fprintf(stdout,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(stdout,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(stdout,"Credits: Richard Copley (richard.copley@embl-heidelberg.de) wrote the core code.\n"); fprintf(stdout," Portions of this code was written by Ewan Birney\n"); fprintf(stdout," Portions of this code was from HMMer2, written by Sean Eddy\n"); fprintf(stdout,"\nFor more information on the abc algorithm, see: \n"); fprintf(stdout," S. F. Altschul - Proteins 32:88-96 (1998)\n\n"); exit(63); } boolean show_output(void) { double pcid; boolean ret = TRUE; int i; int length,nid; int qmatch; char aa1,aa2; Protein * qseq; Protein * tseq; AlnBlock * alb; AlnColumn * alc; /* sort by bit score */ sort_Hscore_by_score(hs); /* if( make_anchored_alignment == TRUE ) { anc = single_unit_AlnBlock(qseq->len,"SEQUENCE"); set = SequenceSet_alloc_std(); } */ if( fit_histogram == FALSE || hs->his == NULL || hs->his->total < 1000 ) { info("Cannot fit histogram to a db smaller than 1,000"); fprintf(ofp,"[Warning: Can't fit histogram to a db smaller than 1,000]\n\n"); show_histogram = FALSE; } else { if( use_abc ){ fit_Hscore_to_EVD(hs,3000); } else { fit_Hscore_to_EVD(hs,300); } } fprintf(ofp,"\n#High Score list\n"); fprintf(ofp,"-------------------------------------------------------------\n"); for(i=0;ilen;i++) { if( (hs->ds[i]->score < search_cutoff) || (i >= max_desc) || (hs->ds[i]->evalue > prob_cutoff)){ aln_number = i; break; } fprintf(ofp,"Probe %-24s Dbase %-24s %c %4d %.2g\n",hs->ds[i]->query->name,hs->ds[i]->target->name,hs->ds[i]->target->is_reversed == TRUE ? '-' : '+',hs->ds[i]->score,hs->ds[i]->evalue); } fprintf(ofp,"\n\n#Alignments\n"); fprintf(ofp,"-------------------------------------------------------------\n\n"); for(i=0;ilen;i++) { if( hs->ds[i]->score < search_cutoff ) { break; } if( i >= aln_number ) { break; } fprintf(ofp,"\n\n>%s vs %s [%d]\n",hs->ds[i]->query->name,hs->ds[i]->target->name,i+1 ); qseq = get_Protein_from_ProteinDB(qdb,hs->ds[i]->query); tseq = get_Protein_from_ProteinDB(tdb,hs->ds[i]->target); if( use_abc ) { alb = Align_Proteins_ABC(qseq,tseq,mat,-a,-b,-c,NULL,dpri); } else { alb = Align_Proteins_SmithWaterman(qseq,tseq,mat,-gap,-ext,NULL,dpri); } length = 0; nid = 0; qmatch = 0; for( alc = alb->start; alc != NULL; alc = alc->next) { length++; aa1 = Protein_seqchar(qseq,1+alc->alu[0]->start); aa2 = Protein_seqchar(tseq,1+alc->alu[1]->start); if(!strcmp(alc->alu[0]->text_label,"SEQUENCE")){ qmatch++; } if((!strcmp(alc->alu[0]->text_label,"SEQUENCE")) && (!strcmp(alc->alu[1]->text_label,"SEQUENCE")) && (aa1 == aa2)){ nid++; } } length--; pcid = 100.00 * ((double)nid/(double)length); /* if( make_anchored_alignment == TRUE ) { alb->als[1]->data = (void *) tseq; add_SequenceSet(seqset,tseq); add_to_anchored_AlnBlock(anc,alb); } */ if( show_pretty == TRUE ) { fprintf(ofp,"\nP: %.2g Sc: %3d aln_len: %d p_len: %d t_len: %d match: %4.1f%% ID: %4.1f%%\n\n",hs->ds[i]->evalue,hs->ds[i]->score,length,Protein_length(qseq),Protein_length(tseq),100.00*((double)qmatch/(double)(Protein_length(qseq))),pcid); if( show_ids == FALSE ) { ckfree(qseq->baseseq->name); qseq->baseseq->name = stringalloc("probe:"); ckfree(tseq->baseseq->name); tseq->baseseq->name = stringalloc("target:"); /*** icky code. ***/ /* strcpy(qseq->baseseq->name,"probe:"); strcpy(tseq->baseseq->name,"target:"); */ } write_pretty_Protein_align(alb,qseq,tseq,15,50,stdout); } fprintf(ofp,"\n-------------------------------------------------------------\n\n"); free_Protein(qseq); free_Protein(tseq); free_AlnBlock(alb); } if( show_histogram == TRUE ) { PrintASCIIHistogram(hs->his,ofp); } return ret; } boolean free_objects(void) { if( tdb != NULL ) { tdb = free_ProteinDB(tdb); } if( qdb != NULL ) { qdb = free_ProteinDB(qdb); } if( hs != NULL ) { hs = free_Hscore(hs); } return TRUE; } boolean build_objects(void) { boolean ret = TRUE; Sequence * qseq; if( (mat = read_Blast_file_CompMat(matrix_file)) == NULL) { warn("Could not read Comparison matrix file in %s",matrix_file); ret = FALSE; } if((use_abc == TRUE) && (strcmp(matrix_file,"abc.bla"))) { factor_CompMat(mat,10); } if( use_query_db ) { if((qdb = single_fasta_ProteinDB(querydb)) == NULL ) { ret = FALSE; warn("Could not read Protein sequence in %s",querydb); } } else { if((qseq = read_fasta_file_Sequence(querydb)) == NULL ) { ret = FALSE; warn("Could not read single Protein sequence in %s",querydb); } qdb = new_ProteinDB_from_single_seq(qseq); /** free actual sequence now. It is held onto by the database */ free_Sequence(qseq); } if((tdb = single_fasta_ProteinDB(targetdb)) == NULL ) { ret = FALSE; warn("Could not read Protein sequence in %s",targetdb); } if( (ofp = openfile(output_file,"W")) == NULL) { warn("Could not open %s as an output file",output_file); ret = FALSE; } return ret; } boolean search_db(void) { info("Starting search...."); if( use_abc ) { hs = Hscore_from_ProteinABC(qdb,tdb,mat,-a,-b,-c,search_cutoff,report_stagger,FALSE,dbsi); } else if( use_pba){ /* hs = Hscore_from_ProteinBA(qdb,tdb,mat,bentry,bexit,bfor_trans,b_self_trans,b3exit,search_cutoff,report_stgger,dbsi); */ } else { hs = Hscore_from_ProteinSW(qdb,tdb,mat,-gap,-ext,search_cutoff,report_stagger,FALSE,dbsi); } if( hs == NULL ) { return FALSE; } return TRUE; } boolean show_header(FILE * ofp) { fprintf(ofp,"-------------------------------------------------------------\n"); fprintf(ofp,"Wise2 - Protein vs. Protein\n"); fprintf(ofp,"Program: %s version: %s released: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY); fprintf(ofp,"This program is freely distributed under a Gnu Public License.\n"); fprintf(ofp," See -version for more info on copyright\n"); fprintf(ofp,"Bugs and credits to: Richard Copley \n"); fprintf(ofp," Ewan Birney \n"); fprintf(ofp,"-------------------------------------------------------------\n\n"); if( use_abc ){ fprintf(ofp,"Algorithm type: abc model\n"); fprintf(ofp,"a: %d\n",a); fprintf(ofp,"b: %d\n",b); fprintf(ofp,"c: %d\n",c); } else { fprintf(ofp,"Algorithm type: Smith/Waterman\n"); fprintf(ofp,"Gap open: %d\n",gap); fprintf(ofp,"Gap extension: %d\n",ext); } fprintf(ofp,"Query info from: %s\n",querydb); fprintf(ofp,"Database info from: %s\n",targetdb); fprintf(ofp,"Comp Matrix: %s\n",matrix_file); return TRUE; } int main(int argc,char *argv[]) { char * errlog; if( strip_out_boolean_argument(&argc,argv,"h") == TRUE || strip_out_boolean_argument(&argc,argv,"-help") == TRUE) { show_help(stdout); exit(1); } (void) strip_out_integer_argument(&argc,argv,"g",&gap); (void) strip_out_integer_argument(&argc,argv,"e",&ext); (void) strip_out_integer_argument(&argc,argv,"a",&a); (void) strip_out_integer_argument(&argc,argv,"b",&b); (void) strip_out_integer_argument(&argc,argv,"c",&c); (void) strip_out_integer_argument(&argc,argv,"max_desc",&max_desc); (void) strip_out_integer_argument(&argc,argv,"max_aln",&aln_number); (void) strip_out_float_argument(&argc,argv,"cut",&search_cutoff); use_abc = strip_out_boolean_argument(&argc,argv,"abc"); use_pba = strip_out_boolean_argument(&argc,argv,"pba"); show_ids = strip_out_boolean_argument(&argc,argv,"ids"); use_query_db = strip_out_boolean_argument(&argc,argv,"db_vs_db"); if( strip_out_boolean_argument(&argc,argv,"nohis") == TRUE ) { fit_histogram = FALSE; } matrix_file = strip_out_assigned_argument(&argc,argv,"m"); if( matrix_file == NULL) matrix_file = "BLOSUM62.bla"; /* database implementation stuff */ dbsi = new_DBSearchImpl_from_argv(&argc,argv); /* run time */ dpri = new_DPRunImpl_from_argv(&argc,argv); /* standard options */ if( (strip_out_boolean_argument(&argc,argv,"version")) == TRUE ) { show_version(); } if( (strip_out_boolean_argument(&argc,argv,"silent")) == TRUE ) { erroroff(REPORT); erroroff(INFO); erroroff(WARNING); } if( (strip_out_boolean_argument(&argc,argv,"quiet")) == TRUE ) { erroroff(REPORT); erroroff(INFO); } if( (strip_out_boolean_argument(&argc,argv,"erroroffstd")) == TRUE ) { errorstderroff(WARNING); } if( (errlog=strip_out_assigned_argument(&argc,argv,"errlog")) != NULL ) { if( add_log_filename(errlog) == FALSE ) { fatal("Could not use %s as a error log file\n",errlog); } else { warn("Logging errors to %s as well as stderr",errlog); errorlogon(WARNING); } } /*** processed all arguments. Should be left with sequences in argv[1] and argv[2] */ if( argc != 3 ) { warn("Must have two arguments for sequence 1 and sequence 2 %d",argc); show_help(stdout); exit(1); } if(use_abc && use_pba){ warn("Choose only one of pba or abc"); show_help(stdout); exit(1); } if( use_pba ){ warn("PBA algorithm not yet working"); exit(1); } querydb = argv[1]; targetdb = argv[2]; if( build_objects() == FALSE) fatal("Could not build objects!"); show_header(stdout); if( search_db() == FALSE) warn("Could not search database"); show_output(); free_objects(); return 0; } wise-2.4.1/src/models/revcomp.c0000644000175000001440000000045707574066170015764 0ustar philippusers#include "dyna.h" int main(int argc,char ** argv) { Sequence * in; Sequence * rev; while( in = read_fasta_Sequence(stdin) ) { in->type = SEQUENCE_DNA; rev = reverse_complement_Sequence(in); write_fasta_Sequence(rev,stdout); free_Sequence(in); free_Sequence(rev); } } wise-2.4.1/src/models/genome_evidence.c0000644000175000001440000002472010670453714017417 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genome_evidence.h" /* Function: free_GenomeEvidenceUnit(obj) * * Descrip: Specialised deconstructor. Ensures the * data structures are freed * * * Arg: obj [UNKN ] Undocumented argument [GenomeEvidenceUnit *] * * Return [UNKN ] Undocumented return value [GenomeEvidenceUnit *] * */ # line 57 "genome_evidence.dy" GenomeEvidenceUnit * free_GenomeEvidenceUnit(GenomeEvidenceUnit * obj) { (*(obj->geu_free))(obj->data); free(obj); } # line 23 "genome_evidence.c" /* Function: hard_link_GenomeEvidenceUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomeEvidenceUnit *] * * Return [UNKN ] Undocumented return value [GenomeEvidenceUnit *] * */ GenomeEvidenceUnit * hard_link_GenomeEvidenceUnit(GenomeEvidenceUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a GenomeEvidenceUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GenomeEvidenceUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomeEvidenceUnit *] * */ GenomeEvidenceUnit * GenomeEvidenceUnit_alloc(void) { GenomeEvidenceUnit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenomeEvidenceUnit *) ckalloc (sizeof(GenomeEvidenceUnit))) == NULL) { warn("GenomeEvidenceUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = 0; out->data = NULL; out->cds_3SS = NULL; out->cds_5SS = NULL; out->utr_3SS = NULL; out->utr_5SS = NULL; out->cds_pot = NULL; out->utr_pot = NULL; out->cds_intron_pot = NULL; out->utr_intron_pot = NULL; out->frameshift_cds = NULL; out->start_pot = NULL; out->stop_pot = NULL; out->utr3_end = NULL; out->utr5_start = NULL; out->geu_free = NULL; return out; } /* Function: swap_GenomeEvidenceSet(list,i,j) * * Descrip: swap function: an internal for qsort_GenomeEvidenceSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [GenomeEvidenceUnit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_GenomeEvidenceSet(GenomeEvidenceUnit ** list,int i,int j) { GenomeEvidenceUnit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_GenomeEvidenceSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_GenomeEvidenceSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [GenomeEvidenceUnit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_GenomeEvidenceSet(GenomeEvidenceUnit ** list,int left,int right,int (*comp)(GenomeEvidenceUnit * ,GenomeEvidenceUnit * )) { int i,last; if( left >= right ) return; swap_GenomeEvidenceSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_GenomeEvidenceSet (list,++last,i); } swap_GenomeEvidenceSet (list,left,last); qsort_GenomeEvidenceSet(list,left,last-1,comp); qsort_GenomeEvidenceSet(list,last+1,right,comp); } /* Function: sort_GenomeEvidenceSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_GenomeEvidenceSet * * * Arg: obj [UNKN ] Object containing list [GenomeEvidenceSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_GenomeEvidenceSet(GenomeEvidenceSet * obj,int (*comp)(GenomeEvidenceUnit *, GenomeEvidenceUnit *)) { qsort_GenomeEvidenceSet(obj->geu,0,obj->len-1,comp); return; } /* Function: expand_GenomeEvidenceSet(obj,len) * * Descrip: Really an internal function for add_GenomeEvidenceSet * * * Arg: obj [UNKN ] Object which contains the list [GenomeEvidenceSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_GenomeEvidenceSet(GenomeEvidenceSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_GenomeEvidenceSet called with no need"); return TRUE; } if( (obj->geu = (GenomeEvidenceUnit ** ) ckrealloc (obj->geu,sizeof(GenomeEvidenceUnit *)*len)) == NULL) { warn("ckrealloc failed for expand_GenomeEvidenceSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_GenomeEvidenceSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenomeEvidenceSet *] * Arg: add [OWNER] Object to add to the list [GenomeEvidenceUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_GenomeEvidenceSet(GenomeEvidenceSet * obj,GenomeEvidenceUnit * add) { if( obj->len >= obj->maxlen) { if( expand_GenomeEvidenceSet(obj,obj->len + GenomeEvidenceSetLISTLENGTH) == FALSE) return FALSE; } obj->geu[obj->len++]=add; return TRUE; } /* Function: flush_GenomeEvidenceSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenomeEvidenceSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GenomeEvidenceSet(GenomeEvidenceSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->geu[i] != NULL) { free_GenomeEvidenceUnit(obj->geu[i]); obj->geu[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: GenomeEvidenceSet_alloc_std(void) * * Descrip: Equivalent to GenomeEvidenceSet_alloc_len(GenomeEvidenceSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GenomeEvidenceSet *] * */ GenomeEvidenceSet * GenomeEvidenceSet_alloc_std(void) { return GenomeEvidenceSet_alloc_len(GenomeEvidenceSetLISTLENGTH); } /* Function: GenomeEvidenceSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GenomeEvidenceSet *] * */ GenomeEvidenceSet * GenomeEvidenceSet_alloc_len(int len) { GenomeEvidenceSet * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = GenomeEvidenceSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->geu = (GenomeEvidenceUnit ** ) ckcalloc (len,sizeof(GenomeEvidenceUnit *))) == NULL) { warn("Warning, ckcalloc failed in GenomeEvidenceSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_GenomeEvidenceSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomeEvidenceSet *] * * Return [UNKN ] Undocumented return value [GenomeEvidenceSet *] * */ GenomeEvidenceSet * hard_link_GenomeEvidenceSet(GenomeEvidenceSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a GenomeEvidenceSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GenomeEvidenceSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomeEvidenceSet *] * */ GenomeEvidenceSet * GenomeEvidenceSet_alloc(void) { GenomeEvidenceSet * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenomeEvidenceSet *) ckalloc (sizeof(GenomeEvidenceSet))) == NULL) { warn("GenomeEvidenceSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->geu = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_GenomeEvidenceSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomeEvidenceSet *] * * Return [UNKN ] Undocumented return value [GenomeEvidenceSet *] * */ GenomeEvidenceSet * free_GenomeEvidenceSet(GenomeEvidenceSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GenomeEvidenceSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->geu != NULL) { for(i=0;ilen;i++) { if( obj->geu[i] != NULL) free_GenomeEvidenceUnit(obj->geu[i]); } ckfree(obj->geu); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/genome_evidence.h0000644000175000001440000002103010670453714017413 0ustar philippusers#ifndef DYNAMITEgenome_evidenceHEADERFILE #define DYNAMITEgenome_evidenceHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #define GNE_CDS_3SS(evi,i,seq,j,phase) ((*((evi)->geu[i]->cds_3SS))((evi)->geu[i]->data,seq,j,phase)) #define GNE_CDS_5SS(evi,i,seq,j,phase) ((*((evi)->geu[i]->cds_5SS))((evi)->geu[i]->data,seq,j,phase)) #define GNE_CDS(evi,i,seq,j) ((*((evi)->geu[i]->cds_pot))((evi)->geu[i]->data,seq,j)) #define GNE_CDS_INTRON(evi,i,seq,j) ((*((evi)->geu[i]->cds_intron_pot))((evi)->geu[i]->data,seq,j)) #define GNE_UTR_3SS(evi,i,seq,j) ((*((evi)->geu[i]->utr_3SS))((evi)->geu[i]->data,seq,j)) #define GNE_UTR_5SS(evi,i,seq,j) ((*((evi)->geu[i]->utr_5SS))((evi)->geu[i]->data,seq,j)) #define GNE_UTR(evi,i,seq,j) ((*((evi)->geu[i]->utr_pot))((evi)->geu[i]->data,seq,j)) #define GNE_UTR_INTRON(evi,i,seq,j) ((*((evi)->geu[i]->utr_intron_pot))((evi)->geu[i]->data,seq,j)) #define GNE_CDS_FRAMESHIFT(evi,i,seq,j,jump) ((*((evi)->geu[i]->frameshift_cds))((evi)->geu[i]->data,seq,j,jump)) #define GNE_START_CODON(evi,i,seq,j) ((*((evi)->geu[i]->start_pot))((evi)->geu[i]->data,seq,j)) #define GNE_STOP_CODON(evi,i,seq,j) ((*((evi)->geu[i]->stop_pot))((evi)->geu[i]->data,seq,j)) #define GNE_UTR3_END(evi,i,seq,j) ((*((evi)->geu[i]->utr3_end))((evi)->geu[i]->data,seq,j)) #define GNE_UTR5_START(evi,i,seq,j) ((*((evi)->geu[i]->utr5_start))((evi)->geu[i]->data,seq,j)) #define GenomeEvidenceSetLISTLENGTH 512 struct Wise2_GenomeEvidenceUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; void * data; int (*cds_3SS)(void*,Wise2_ComplexSequence*,int,int); int (*cds_5SS)(void*,Wise2_ComplexSequence*,int,int); int (*utr_3SS)(void*,Wise2_ComplexSequence*,int); int (*utr_5SS)(void*,Wise2_ComplexSequence*,int); int (*cds_pot)(void*,Wise2_ComplexSequence*,int); int (*utr_pot)(void*,Wise2_ComplexSequence*,int); int (*cds_intron_pot)(void*,Wise2_ComplexSequence*,int); int (*utr_intron_pot)(void*,Wise2_ComplexSequence*,int); int (*frameshift_cds)(void*,Wise2_ComplexSequence*,int,int); int (*start_pot)(void*,Wise2_ComplexSequence*,int); int (*stop_pot)(void*,Wise2_ComplexSequence*,int); int (*utr3_end)(void*,Wise2_ComplexSequence*,int); int (*utr5_start)(void*,Wise2_ComplexSequence*,int); int (*geu_free)(void *); } ; /* GenomeEvidenceUnit defined */ #ifndef DYNAMITE_DEFINED_GenomeEvidenceUnit typedef struct Wise2_GenomeEvidenceUnit Wise2_GenomeEvidenceUnit; #define GenomeEvidenceUnit Wise2_GenomeEvidenceUnit #define DYNAMITE_DEFINED_GenomeEvidenceUnit #endif struct Wise2_GenomeEvidenceSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GenomeEvidenceUnit ** geu; int len;/* len for above geu */ int maxlen; /* maxlen for above geu */ } ; /* GenomeEvidenceSet defined */ #ifndef DYNAMITE_DEFINED_GenomeEvidenceSet typedef struct Wise2_GenomeEvidenceSet Wise2_GenomeEvidenceSet; #define GenomeEvidenceSet Wise2_GenomeEvidenceSet #define DYNAMITE_DEFINED_GenomeEvidenceSet #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: free_GenomeEvidenceUnit(obj) * * Descrip: Specialised deconstructor. Ensures the * data structures are freed * * * Arg: obj [UNKN ] Undocumented argument [GenomeEvidenceUnit *] * * Return [UNKN ] Undocumented return value [GenomeEvidenceUnit *] * */ GenomeEvidenceUnit * Wise2_free_GenomeEvidenceUnit(GenomeEvidenceUnit * obj); #define free_GenomeEvidenceUnit Wise2_free_GenomeEvidenceUnit /* Function: hard_link_GenomeEvidenceUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomeEvidenceUnit *] * * Return [UNKN ] Undocumented return value [GenomeEvidenceUnit *] * */ GenomeEvidenceUnit * Wise2_hard_link_GenomeEvidenceUnit(GenomeEvidenceUnit * obj); #define hard_link_GenomeEvidenceUnit Wise2_hard_link_GenomeEvidenceUnit /* Function: GenomeEvidenceUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomeEvidenceUnit *] * */ GenomeEvidenceUnit * Wise2_GenomeEvidenceUnit_alloc(void); #define GenomeEvidenceUnit_alloc Wise2_GenomeEvidenceUnit_alloc /* Function: add_GenomeEvidenceSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenomeEvidenceSet *] * Arg: add [OWNER] Object to add to the list [GenomeEvidenceUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_GenomeEvidenceSet(GenomeEvidenceSet * obj,GenomeEvidenceUnit * add); #define add_GenomeEvidenceSet Wise2_add_GenomeEvidenceSet /* Function: flush_GenomeEvidenceSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenomeEvidenceSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_GenomeEvidenceSet(GenomeEvidenceSet * obj); #define flush_GenomeEvidenceSet Wise2_flush_GenomeEvidenceSet /* Function: GenomeEvidenceSet_alloc_std(void) * * Descrip: Equivalent to GenomeEvidenceSet_alloc_len(GenomeEvidenceSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GenomeEvidenceSet *] * */ GenomeEvidenceSet * Wise2_GenomeEvidenceSet_alloc_std(void); #define GenomeEvidenceSet_alloc_std Wise2_GenomeEvidenceSet_alloc_std /* Function: GenomeEvidenceSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GenomeEvidenceSet *] * */ GenomeEvidenceSet * Wise2_GenomeEvidenceSet_alloc_len(int len); #define GenomeEvidenceSet_alloc_len Wise2_GenomeEvidenceSet_alloc_len /* Function: hard_link_GenomeEvidenceSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomeEvidenceSet *] * * Return [UNKN ] Undocumented return value [GenomeEvidenceSet *] * */ GenomeEvidenceSet * Wise2_hard_link_GenomeEvidenceSet(GenomeEvidenceSet * obj); #define hard_link_GenomeEvidenceSet Wise2_hard_link_GenomeEvidenceSet /* Function: GenomeEvidenceSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomeEvidenceSet *] * */ GenomeEvidenceSet * Wise2_GenomeEvidenceSet_alloc(void); #define GenomeEvidenceSet_alloc Wise2_GenomeEvidenceSet_alloc /* Function: free_GenomeEvidenceSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomeEvidenceSet *] * * Return [UNKN ] Undocumented return value [GenomeEvidenceSet *] * */ GenomeEvidenceSet * Wise2_free_GenomeEvidenceSet(GenomeEvidenceSet * obj); #define free_GenomeEvidenceSet Wise2_free_GenomeEvidenceSet /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_GenomeEvidenceSet(GenomeEvidenceUnit ** list,int i,int j) ; #define swap_GenomeEvidenceSet Wise2_swap_GenomeEvidenceSet void Wise2_qsort_GenomeEvidenceSet(GenomeEvidenceUnit ** list,int left,int right,int (*comp)(GenomeEvidenceUnit * ,GenomeEvidenceUnit * )); #define qsort_GenomeEvidenceSet Wise2_qsort_GenomeEvidenceSet void Wise2_sort_GenomeEvidenceSet(GenomeEvidenceSet * obj,int (*comp)(GenomeEvidenceUnit *, GenomeEvidenceUnit *)); #define sort_GenomeEvidenceSet Wise2_sort_GenomeEvidenceSet boolean Wise2_expand_GenomeEvidenceSet(GenomeEvidenceSet * obj,int len); #define expand_GenomeEvidenceSet Wise2_expand_GenomeEvidenceSet #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/standardout.dy0000644000175000001440000000331707445405535017030 0ustar philippusers %{ #include "dyna.h" %} struct StandardOutputOptions boolean show_alb !def="FALSE" boolean show_pal !def="FALSE" boolean show_cumlative_alb !def="FALSE" boolean show_cumlative_pal !def="FALSE" %{ #include "standardout.h" void show_help_StandardOutputOptions(FILE * ofp) { fprintf(ofp,"Standard alignment outputs\n"); fprintf(ofp," -alb show align block format\n"); fprintf(ofp," -pal show raw alignment\n"); fprintf(ofp," -calb show cumlative align block\n"); fprintf(ofp," -cpal show cumlative raw alignemnt\n"); } StandardOutputOptions * new_StandardOutputOptions_from_argv(int * argc,char ** argv) { StandardOutputOptions * out; out = StandardOutputOptions_alloc(); out->show_alb = strip_out_boolean_argument(argc,argv,"alb"); out->show_pal = strip_out_boolean_argument(argc,argv,"pal"); out->show_cumlative_alb = strip_out_boolean_argument(argc,argv,"calb"); out->show_cumlative_pal = strip_out_boolean_argument(argc,argv,"cpal"); return out; } void show_StandardOutputOptions(StandardOutputOptions * out,AlnBlock * alb,PackAln * pal,char * divide_str,FILE * ofp) { assert(out); assert(alb); assert(pal); assert(ofp); assert(divide_str); if( out->show_alb == TRUE ) { mapped_ascii_AlnBlock(alb,Score2Bits,0,ofp); fprintf(ofp,"%s\n",divide_str); } if( out->show_cumlative_alb == TRUE ) { mapped_ascii_AlnBlock(alb,Score2Bits,1,ofp); fprintf(ofp,"%s\n",divide_str); } if( out->show_cumlative_pal == TRUE ) { show_bits_and_cumlative_PackAln(pal,ofp); fprintf(ofp,"%s\n",divide_str); } if( out->show_pal == TRUE ) { show_simple_PackAln(pal,ofp); fprintf(ofp,"%s\n",divide_str); } return; } wise-2.4.1/src/models/gwlite.c0000644000175000001440000100473010670453714015576 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "gwlite.h" # line 5 "gwlite.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define INTRON_0 3 #define INTRON_1 4 #define INTRON_2 5 #define START 0 #define END 1 #define GeneLiteModel_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+3)*6)+STATE][i+1] #define GeneLiteModel_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+3] #define GeneLiteModel_READ_OFF_ERROR -5 #define GeneLiteModel_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+4)%4][((i+1)*6)+STATE] #define GeneLiteModel_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+4)%4][STATE] #define GeneLiteModel_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define GeneLiteModel_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_GeneLiteModel(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_GeneLiteModel(GeneLiteModel * mat) { GeneLiteModel_access_func_holder holder; holder.access_main = GeneLiteModel_shatter_access_main; holder.access_special = GeneLiteModel_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_GeneLiteModel(mat,holder); } /* Function: GeneLiteModel_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneLiteModel_shatter_access_main(GeneLiteModel * mat,int i,int j,int state) { return GeneLiteModel_SHATTER_MATRIX(mat,i,j,state); } /* Function: GeneLiteModel_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneLiteModel_shatter_access_special(GeneLiteModel * mat,int i,int j,int state) { return GeneLiteModel_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_GeneLiteModel(mat,dpenv) * * Descrip: This function calculates the GeneLiteModel matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneLiteModel *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_GeneLiteModel(GeneLiteModel * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_2; int * SIG_1_1; int * SIG_0_3; int * SIG_0_2; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,6,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("GeneLiteModel Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneLiteModel_SHATTER_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = SIG_1_3[INTRON_0] + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = SIG_1_2[INTRON_1] + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = SIG_1_1[INTRON_2] + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_1[MATCH] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLiteModel_SHATTER_SPECIAL(mat,i,j,END) ) { GeneLiteModel_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneLiteModel_SHATTER_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = SIG_0_3[INTRON_0] + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = SIG_0_2[INTRON_1] + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = SIG_0_1[INTRON_2] + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_2[INSERT] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ SIG_0_0[INSERT] = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLiteModel_SHATTER_SPECIAL(mat,i,j,END) ) { GeneLiteModel_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneLiteModel_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLiteModel_SHATTER_SPECIAL(mat,i,j,END) ) { GeneLiteModel_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = SIG_0_1[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_0 */ temp = SIG_0_1[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = SIG_0_1[INTRON_0] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_0] = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SIG_0_2[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_1 */ temp = SIG_0_2[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = SIG_0_1[INTRON_1] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_1] = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_2 */ temp = SIG_0_3[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = SIG_0_1[INTRON_2] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_2] = score; /* Finished calculating state INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_GeneLiteModel(dbsi,out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneLiteModel * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_GeneLiteModel(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_GeneLiteModel * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_GeneLiteModel. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_GeneLiteModel. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for GeneLiteModel, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_GeneLiteModel(out,querydb, targetdb ,gp); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_GeneLiteModel *) ckalloc(sizeof(struct thread_pool_holder_GeneLiteModel)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->gp = gp; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_GeneLiteModel,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for GeneLiteModel"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from GeneLiteModel",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_GeneLiteModel(ptr) * * Descrip: Infinite loop code foreach thread for GeneLiteModel * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_GeneLiteModel(void * ptr) { struct thread_pool_holder_GeneLiteModel * holder; int db_status; int score; DataScore * ds; GwLiteScore* query; ComplexSequence* target; holder = (struct thread_pool_holder_GeneLiteModel *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneLiteModel"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneLiteModel"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_GwLite_GeneWiseDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in GeneLiteModel search"); } query = hard_link_GwLiteScore(holder->query); /* get query information into datascore */ dataentry_add_GwLite_GeneWiseDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_GenomicDB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_GenomicDB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching GeneLiteModel, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_GenomicDB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_GwLiteScore(holder->query); /* get the next query object for the next thread */ holder->query = reload_GwLite_GeneWiseDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching GeneLiteModel, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_GwLite_GeneWiseDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneLiteModel"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneLiteModel"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_GenomicDB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_GeneLiteModel(query, target ,holder->gp); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for GeneLiteModel"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for GeneLiteModel"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneLiteModel"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_GwLiteScore(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneLiteModel"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_GeneLiteModel(out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneLiteModel * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_GeneLiteModel(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp) { GwLiteScore* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GwLite_GeneWiseDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneLiteModel, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_GenomicDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneLiteModel, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_GeneLiteModel(query, target , gp); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("GeneLiteModel search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GwLite_GeneWiseDB(ds->query,query,querydb); dataentry_add_GenomicDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_GenomicDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneLiteModel, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_GenomicDB(target,targetdb); query = reload_GwLite_GeneWiseDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching GeneLiteModel, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GwLite_GeneWiseDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_GeneLiteModel(query,target,gp) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_GeneLiteModel_only * * * Arg: query [UNKN ] query data structure [GwLiteScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_GeneLiteModel(GwLiteScore* query,ComplexSequence* target ,GeneParser4Score * gp) { int bestscore = NEGI; int i; int j; int k; GeneLiteModel * mat; mat = allocate_GeneLiteModel_only(query, target , gp); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(4,(mat->leni + 1) * 6,4,2)) == NULL) { warn("Score only matrix for GeneLiteModel cannot be allocated, (asking for 3 by %d cells)",mat->leni*6); mat = free_GeneLiteModel(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<5;j++) { for(i=(-1);ileni;i++) { for(k=0;k<6;k++) GeneLiteModel_VSMALL_MATRIX(mat,i,j,k) = NEGI; } GeneLiteModel_VSMALL_SPECIAL(mat,i,j,START) = 0; GeneLiteModel_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = GeneLiteModel_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneLiteModel_VSMALL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-1,j-3,INTRON_0) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-1,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-1,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ GeneLiteModel_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLiteModel_VSMALL_SPECIAL(mat,i,j,END) ) { GeneLiteModel_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneLiteModel_VSMALL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-3,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ GeneLiteModel_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLiteModel_VSMALL_SPECIAL(mat,i,j,END) ) { GeneLiteModel_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLiteModel_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state DELETE to state DELETE */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneLiteModel_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLiteModel_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLiteModel_VSMALL_SPECIAL(mat,i,j,END) ) { GeneLiteModel_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_0 */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneLiteModel_VSMALL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-2,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_1 */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneLiteModel_VSMALL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_2 */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLiteModel_VSMALL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneLiteModel_VSMALL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < GeneLiteModel_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = GeneLiteModel_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_GeneLiteModel(mat); return bestscore; } /* Function: PackAln_bestmemory_GeneLiteModel(query,target,gp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneLiteModel * * * Arg: query [UNKN ] query data structure [GwLiteScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_GeneLiteModel(GwLiteScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; GeneLiteModel * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 6 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_GeneLiteModel(query, target , gp,dpri)) == NULL ) { warn("Unable to allocate large GeneLiteModel version"); return NULL; } calculate_dpenv_GeneLiteModel(mat,dpenv); out = PackAln_read_Expl_GeneLiteModel(mat); } else { mat = allocate_GeneLiteModel_only(query, target , gp); calculate_shatter_GeneLiteModel(mat,dpenv); out = PackAln_read_Shatter_GeneLiteModel(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_GeneLiteModel(query, target , gp)) == NULL ) { warn("Unable to allocate small GeneLiteModel version"); return NULL; } out = PackAln_calculate_Small_GeneLiteModel(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_GeneLiteModel(query, target , gp,dpri)) == NULL ) { warn("Unable to allocate large GeneLiteModel version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_GeneLiteModel(mat); out = PackAln_read_Expl_GeneLiteModel(mat); } } } mat = free_GeneLiteModel(mat); return out; } /* Function: allocate_GeneLiteModel_only(query,target,gp) * * Descrip: This function only allocates the GeneLiteModel structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GwLiteScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneLiteModel *] * */ GeneLiteModel * allocate_GeneLiteModel_only(GwLiteScore* query,ComplexSequence* target ,GeneParser4Score * gp) { GeneLiteModel * out; if((out= GeneLiteModel_alloc()) == NULL) { warn("Allocation of basic GeneLiteModel structure failed..."); return NULL; } out->query = query; out->target = target; out->gp = gp; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_GeneLiteModel(query,target,gp,dpri) * * Descrip: This function allocates the GeneLiteModel structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneLiteModel_only * * * Arg: query [UNKN ] query data structure [GwLiteScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneLiteModel *] * */ GeneLiteModel * allocate_Expl_GeneLiteModel(GwLiteScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPRunImpl * dpri) { GeneLiteModel * out; out = allocate_GeneLiteModel_only(query, target , gp); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+3)*6 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+3)*6,(out->leni+1),2,out->lenj+3)) == NULL) { warn("Explicit matrix GeneLiteModel cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_GeneLiteModel(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_GeneLiteModel(out); return out; } /* Function: init_GeneLiteModel(mat) * * Descrip: This function initates GeneLiteModel matrix when in explicit mode * Called in /allocate_Expl_GeneLiteModel * * * Arg: mat [UNKN ] GeneLiteModel which contains explicit basematrix memory [GeneLiteModel *] * */ void init_GeneLiteModel(GeneLiteModel * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-3);j<4;j++) { GeneLiteModel_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } } for(j= (-3);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { GeneLiteModel_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } GeneLiteModel_EXPL_SPECIAL(mat,i,j,START) = 0; GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_GeneLiteModel(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneLiteModel * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * */ void recalculate_PackAln_GeneLiteModel(PackAln * pal,GeneLiteModel * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (START+6) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == INTRON_0 ) { pau->score = ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0); continue; } if( offi == 1 && offj == 2 && prev->state == INTRON_1 ) { pau->score = ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0); continue; } if( offi == 1 && offj == 1 && prev->state == INTRON_2 ) { pau->score = ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (0); continue; } if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (0); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (START+6) ) { pau->score = (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == INTRON_0 ) { pau->score = (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0); continue; } if( offi == 0 && offj == 2 && prev->state == INTRON_1 ) { pau->score = ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_2 ) { pau->score = ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (0); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (START+6) ) { pau->score = mat->query->seg[i]->transition[GW_START2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_0 : if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_0 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_1 : if( offi == 0 && offj == 2 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) + (0); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_1 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_2 : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_2 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+6) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+6) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define GeneLiteModel_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+3)][(i+1)*6+state]) #define GeneLiteModel_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+4)*8) % 32][(i+1)*6+state]) #define GeneLiteModel_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+3)]) #define GeneLiteModel_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+3)]) #define GeneLiteModel_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+4)*8)+(shadow+1)) % 32)][(i+1)*6 + state]) #define GeneLiteModel_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+3)]) #define GeneLiteModel_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+3)% 3) * (leni+1) * 6) + ((i+1) * 6) + (state)]) #define GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+3)% 3) * (leni+1) * 48) + ((i+1) * 48) + (state * 8) + shadow+1]) #define GeneLiteModel_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+3)]) /* Function: allocate_Small_GeneLiteModel(query,target,gp) * * Descrip: This function allocates the GeneLiteModel structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneLiteModel_only * * * Arg: query [UNKN ] query data structure [GwLiteScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneLiteModel *] * */ #define GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+3)]) GeneLiteModel * allocate_Small_GeneLiteModel(GwLiteScore* query,ComplexSequence* target ,GeneParser4Score * gp) { GeneLiteModel * out; out = allocate_GeneLiteModel_only(query, target , gp); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(32,(out->leni + 1) * 6,16,out->lenj+3); if(out == NULL) { warn("Small shadow matrix GeneLiteModel cannot be allocated, (asking for 4 by %d main cells)",out->leni+2); free_GeneLiteModel(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_GeneLiteModel(mat,dpenv) * * Descrip: This function calculates an alignment for GeneLiteModel structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneLiteModel * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneLiteModel * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_GeneLiteModel(GeneLiteModel * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for GeneLiteModel due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneLiteModel(mat,dpenv); score = start_end_find_end_GeneLiteModel(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_GeneLiteModel(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_GeneLiteModel(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == GeneLiteModel_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_GeneLiteModel(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 6; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_GeneLiteModel(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_GeneLiteModel(mat) * * Descrip: This function calculates an alignment for GeneLiteModel structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneLiteModel * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneLiteModel * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneLiteModel * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_GeneLiteModel(GeneLiteModel * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneLiteModel(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_GeneLiteModel(mat); return out; } /* Function: AlnRangeSet_from_GeneLiteModel(mat) * * Descrip: This function reads off a start/end structure * for GeneLiteModel structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneLiteModel * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneLiteModel * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_GeneLiteModel(GeneLiteModel * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneLiteModel"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_GeneLiteModel(mat,&jpos); state = END; while( (temp = AlnRange_build_GeneLiteModel(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_GeneLiteModel(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_GeneLiteModel * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_GeneLiteModel(GeneLiteModel * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneLiteModel"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_GeneLiteModel(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_GeneLiteModel alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = GeneLiteModel_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_GeneLiteModel(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == GeneLiteModel_READ_OFF_ERROR) { warn("In AlnRange_build_GeneLiteModel alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = GeneLiteModel_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_GeneLiteModel(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_GeneLiteModel(GeneLiteModel * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_GeneLiteModel(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneLiteModel_READ_OFF_ERROR) { warn("In GeneLiteModel hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In GeneLiteModel hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In GeneLiteModel hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_GeneLiteModel(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_GeneLiteModel(GeneLiteModel * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneLiteModel_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneLiteModel matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = GeneLiteModel_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 1,INTRON_2) ) { *reti = i - 1; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-1,INTRON_2); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 1,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 2,INTRON_1) ) { *reti = i - 1; *retj = j - 2; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-2,INTRON_1); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 2,INTRON_1); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 3,INTRON_0) ) { *reti = i - 1; *retj = j - 3; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-3,INTRON_0); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 3,INTRON_0); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 2,INTRON_1) ) { *reti = i - 0; *retj = j - 2; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-2,INTRON_1); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 2,INTRON_1); } temp = cscore - ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 3,INTRON_0) ) { *reti = i - 0; *retj = j - 3; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-3,INTRON_0); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 3,INTRON_0); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 2,MATCH) ) { *reti = i - 0; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-2,MATCH); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 2,MATCH); } warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return GeneLiteModel_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_GeneLiteModel(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_GeneLiteModel(GeneLiteModel * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } max_special_strip_GeneLiteModel(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneLiteModel_READ_OFF_ERROR) { warn("In special strip read GeneLiteModel, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read GeneLiteModel, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_GeneLiteModel(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_GeneLiteModel(GeneLiteModel * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = GeneLiteModel_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for GeneLiteModel, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In GeneLiteModel matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = GeneLiteModel_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ default: warn("Major problem (!) - in GeneLiteModel special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_GeneLiteModel(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_GeneLiteModel(GeneLiteModel * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = GeneLiteModel_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In GeneLiteModel matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == GeneLiteModel_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_DC_SHADOW_SPECIAL(mat,i-1,j-3,START); } return GeneLiteModel_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLiteModel matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == GeneLiteModel_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_DC_SHADOW_SPECIAL(mat,i-0,j-3,START); } return GeneLiteModel_DC_SHADOW_MATRIX(mat,i - 0,j - 3,START) ; } /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLiteModel matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == GeneLiteModel_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLiteModel_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return GeneLiteModel_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLiteModel matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : /* Source INTRON_0 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLiteModel matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : /* Source INTRON_1 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLiteModel matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : /* Source INTRON_2 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLiteModel matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_GeneLiteModel(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_GeneLiteModel(GeneLiteModel * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_GeneLiteModel(mat,starti,startj,stopi,stopj); GeneLiteModel_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneLiteModel_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneLiteModel_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneLiteModel_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneLiteModel_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLiteModel_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLiteModel_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-3,INTRON_0) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ GeneLiteModel_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-3,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ GeneLiteModel_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state DELETE to state DELETE */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLiteModel_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_0 */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneLiteModel_HIDDEN_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-2,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_1 */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneLiteModel_HIDDEN_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_2 */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLiteModel_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneLiteModel_HIDDEN_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } } return; } /* Function: init_hidden_GeneLiteModel(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_GeneLiteModel(GeneLiteModel * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-3);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { GeneLiteModel_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneLiteModel_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneLiteModel_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneLiteModel_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLiteModel_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLiteModel_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; } } return; } /* Function: full_dc_GeneLiteModel(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_GeneLiteModel * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_GeneLiteModel to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [GeneLiteModel *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_GeneLiteModel(GeneLiteModel * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_GeneLiteModel"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 15) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_GeneLiteModel(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_GeneLiteModel(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_GeneLiteModel(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for GeneLiteModel, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_GeneLiteModel(mat,GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_GeneLiteModel(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_GeneLiteModel(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_GeneLiteModel(GeneLiteModel * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_GeneLiteModel(mat); GeneLiteModel_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_GeneLiteModel(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_GeneLiteModel(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_GeneLiteModel(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_GeneLiteModel(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_GeneLiteModel(GeneLiteModel * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<3;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-100); GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = (-100); GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-100); GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = (-100); GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-100); GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-3,INTRON_0) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INTRON_0,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INTRON_1,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_2; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INTRON_2,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } } /* Add any movement independant score */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INTRON_0,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INTRON_1,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_2; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } /* Add any movement independant score */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ /* For state INTRON_0, pushing when j - offj <= mergej */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( j - 1 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = MATCH; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INSERT; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INTRON_0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } } /* Add any movement independant score */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished with state INTRON_0 */ /* For state INTRON_1, pushing when j - offj <= mergej */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( j - 2 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-2; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = MATCH; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,k); } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-2; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INSERT; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INTRON_1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } } /* Add any movement independant score */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished with state INTRON_1 */ /* For state INTRON_2, pushing when j - offj <= mergej */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( j - 3 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-3; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = MATCH; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-3; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INSERT; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-1; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INTRON_2; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } } /* Add any movement independant score */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished with state INTRON_2 */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_GeneLiteModel(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_GeneLiteModel(GeneLiteModel * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state INTRON_0 to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-3,INTRON_0) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INTRON_0,k); } /* From state INTRON_1 to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INTRON_1,k); } /* From state INTRON_2 to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INTRON_2,k); } /* From state MATCH to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state INTRON_0 to state INSERT */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INTRON_0,k); } /* From state INTRON_1 to state INSERT */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INTRON_1,k); } /* From state INTRON_2 to state INSERT */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } /* From state INSERT to state INSERT */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state DELETE to state DELETE */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); /* From state INSERT to state INTRON_0 */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,k); /* From state INSERT to state INTRON_1 */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INTRON_2 */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_GeneLiteModel(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_GeneLiteModel(GeneLiteModel * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-3,INTRON_0) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state DELETE to state DELETE */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_0 */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_1 */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_2 */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLiteModel_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_GeneLiteModel(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * */ } void init_dc_GeneLiteModel(GeneLiteModel * mat) { register int i; register int j; register int k; for(j=0;j<5;j++) { for(i=(-1);iquery->len;i++) { GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; for(k=0;k<7;k++) { GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = (-1); GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = (-1); GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = (-1); } } } return; } /* Function: start_end_find_end_GeneLiteModel(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [GeneLiteModel *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_GeneLiteModel(GeneLiteModel * mat,int * endj) { register int j; register int max; register int maxj; max = GeneLiteModel_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( GeneLiteModel_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = GeneLiteModel_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_GeneLiteModel(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [GeneLiteModel] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_GeneLiteModel(GeneLiteModel *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (3 * (leni + 1) * 6,sizeof(int)); shadow_pointers = (int *) calloc (3 * (leni + 1) * 6 * 8,sizeof(int)); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state START to state MATCH */ temp = GeneLiteModel_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_0 to state MATCH */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INTRON_0) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INTRON_0,0)); } /* From state INTRON_1 to state MATCH */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INTRON_1,0)); } /* From state INTRON_2 to state MATCH */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INTRON_2,0)); } /* From state MATCH to state MATCH */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLiteModel_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { GeneLiteModel_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state START to state INSERT */ temp = GeneLiteModel_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_0 to state INSERT */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INTRON_0,0)); } /* From state INTRON_1 to state INSERT */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INTRON_1,0)); } /* From state INTRON_2 to state INSERT */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,0)); } /* From state INSERT to state INSERT */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLiteModel_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { GeneLiteModel_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state DELETE to state DELETE */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state START to state DELETE */ temp = GeneLiteModel_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLiteModel_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { GeneLiteModel_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; GeneLiteModel_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = DELETE; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) + (0); /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); /* From state INSERT to state INTRON_0 */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,0)); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) + (0); /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,0)); /* From state INSERT to state INTRON_1 */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,0)); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) + (0); /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INTRON_2 */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,0)); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLiteModel_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) GeneLiteModel_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_GeneLiteModel(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * */ void init_start_end_linear_GeneLiteModel(GeneLiteModel * mat) { register int i; register int j; for(j=0;j<5;j++) { for(i=(-1);iquery->len;i++) { GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-1); GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-1); GeneLiteModel_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; GeneLiteModel_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-1); } } for(j=(-3);jtarget->seq->len;j++) { GeneLiteModel_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; GeneLiteModel_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; GeneLiteModel_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_GeneLiteModel(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_GeneLiteModel(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_GeneLiteModel(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","INTRON_STATE","END" }; /* Function: AlnConvertSet_GeneLiteModel(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","SEQUENCE_DELETION","INSERT","5SS_PHASE_0","CENTRAL_INTRON","5SS_PHASE_1","5SS_PHASE_2","END" }; AlnConvertSet * AlnConvertSet_GeneLiteModel(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[10]; add_collapse_label_AlnConvertSet(out,"INTRON_STATE","CENTRAL_INTRON"); return out; } /* Function: PackAln_read_Expl_GeneLiteModel(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_GeneLiteModel(GeneLiteModel * mat) { GeneLiteModel_access_func_holder holder; holder.access_main = GeneLiteModel_explicit_access_main; holder.access_special = GeneLiteModel_explicit_access_special; return PackAln_read_generic_GeneLiteModel(mat,holder); } /* Function: GeneLiteModel_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneLiteModel_explicit_access_main(GeneLiteModel * mat,int i,int j,int state) { return GeneLiteModel_EXPL_MATRIX(mat,i,j,state); } /* Function: GeneLiteModel_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneLiteModel_explicit_access_special(GeneLiteModel * mat,int i,int j,int state) { return GeneLiteModel_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_GeneLiteModel(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: h [UNKN ] Undocumented argument [GeneLiteModel_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_GeneLiteModel(GeneLiteModel * mat,GeneLiteModel_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_GeneLiteModel(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in GeneLiteModel_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_GeneLiteModel(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_GeneLiteModel(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == GeneLiteModel_READ_OFF_ERROR || j == GeneLiteModel_READ_OFF_ERROR || state == GeneLiteModel_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in GeneLiteModel_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_GeneLiteModel(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [GeneLiteModel_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_GeneLiteModel(GeneLiteModel * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneLiteModel_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: GeneLiteModel_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void GeneLiteModel_debug_show_matrix(GeneLiteModel * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",GeneLiteModel_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",GeneLiteModel_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",GeneLiteModel_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"State INTRON_0 %d\n",GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_0)); fprintf(ofp,"State INTRON_1 %d\n",GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_1)); fprintf(ofp,"State INTRON_2 %d\n",GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_2)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_GeneLiteModel(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneLiteModel_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_GeneLiteModel(GeneLiteModel * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneLiteModel_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneLiteModel_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneLiteModel matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,INTRON_2) ) { *reti = i - 1; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INTRON_2); } return (*h.access_main)(mat,i - 1,j - 1,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,INTRON_1) ) { *reti = i - 1; *retj = j - 2; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,INTRON_1); } return (*h.access_main)(mat,i - 1,j - 2,INTRON_1); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,INTRON_0) ) { *reti = i - 1; *retj = j - 3; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INTRON_0); } return (*h.access_main)(mat,i - 1,j - 3,INTRON_0); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START); } return (*h.access_main)(mat,i - 1,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,INTRON_1) ) { *reti = i - 0; *retj = j - 2; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 2,INTRON_1); } temp = cscore - ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,INTRON_0) ) { *reti = i - 0; *retj = j - 3; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 3,INTRON_0); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,START); } return (*h.access_main)(mat,i - 0,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,MATCH) ) { *reti = i - 0; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,MATCH); } return (*h.access_main)(mat,i - 0,j - 2,MATCH); } warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_GeneLiteModel(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneLiteModel_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_GeneLiteModel(GeneLiteModel * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneLiteModel_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneLiteModel_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In GeneLiteModel matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in GeneLiteModel read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_GeneLiteModel(mat) * * Descrip: This function calculates the GeneLiteModel matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneLiteModel * * * Arg: mat [UNKN ] GeneLiteModel which contains explicit basematrix memory [GeneLiteModel *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_GeneLiteModel(GeneLiteModel * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneLiteModel, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("GeneLiteModel Matrix calculation: "); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneLiteModel_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-3,INTRON_0) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ GeneLiteModel_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) ) { GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneLiteModel_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-3,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ GeneLiteModel_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) ) { GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state DELETE to state DELETE */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneLiteModel_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLiteModel_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) ) { GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_0 */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-2,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_1 */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-2,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_2 */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_GeneLiteModel(mat,dpenv) * * Descrip: This function calculates the GeneLiteModel matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneLiteModel which contains explicit basematrix memory [GeneLiteModel *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_GeneLiteModel(GeneLiteModel * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneLiteModel, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-3;jleni;i++) { GeneLiteModel_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } } for(j=-3;jlenj;j++) { GeneLiteModel_EXPL_SPECIAL(mat,i,j,START) = 0; GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("GeneLiteModel Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { GeneLiteModel_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneLiteModel_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-3,INTRON_0) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ GeneLiteModel_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) ) { GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneLiteModel_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-3,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-2,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ GeneLiteModel_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) ) { GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state DELETE to state DELETE */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneLiteModel_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLiteModel_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) ) { GeneLiteModel_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_0 */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-2,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_1 */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-2,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); /* From state INSERT to state INTRON_2 */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLiteModel_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneLiteModel_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: GeneLiteModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneLiteModel *] * */ GeneLiteModel * GeneLiteModel_alloc(void) { GeneLiteModel * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneLiteModel *) ckalloc (sizeof(GeneLiteModel))) == NULL) { warn("GeneLiteModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_GeneLiteModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneLiteModel *] * * Return [UNKN ] Undocumented return value [GeneLiteModel *] * */ GeneLiteModel * free_GeneLiteModel(GeneLiteModel * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneLiteModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->gp is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/gwlite.h0000644000175000001440000004664610670453714015616 0ustar philippusers#ifndef DYNAMITEgwliteHEADERFILE #define DYNAMITEgwliteHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "gwlitemodel.h" #include "geneparser4.h" #include "genewisemodeldb.h" struct Wise2_GeneLiteModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GwLiteScore* query; ComplexSequence* target; GeneParser4Score * gp; } ; /* GeneLiteModel defined */ #ifndef DYNAMITE_DEFINED_GeneLiteModel typedef struct Wise2_GeneLiteModel Wise2_GeneLiteModel; #define GeneLiteModel Wise2_GeneLiteModel #define DYNAMITE_DEFINED_GeneLiteModel #endif #ifdef PTHREAD struct thread_pool_holder_GeneLiteModel { GwLiteScore* query; /* Query object placeholder */ GeneWiseDB* querydb;/* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ GenomicDB* targetdb;/* Target database object */ boolean target_init; GeneParser4Score * gp; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_GeneLiteModel_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(GeneLiteModel*,int,int,int); int (*access_special)(GeneLiteModel*,int,int,int); } ; /* GeneLiteModel_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_GeneLiteModel_access_func_holder typedef struct Wise2_GeneLiteModel_access_func_holder Wise2_GeneLiteModel_access_func_holder; #define GeneLiteModel_access_func_holder Wise2_GeneLiteModel_access_func_holder #define DYNAMITE_DEFINED_GeneLiteModel_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_GeneLiteModel(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_GeneLiteModel(GeneLiteModel * mat); #define PackAln_read_Shatter_GeneLiteModel Wise2_PackAln_read_Shatter_GeneLiteModel /* Function: calculate_shatter_GeneLiteModel(mat,dpenv) * * Descrip: This function calculates the GeneLiteModel matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneLiteModel *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_GeneLiteModel(GeneLiteModel * mat,DPEnvelope * dpenv); #define calculate_shatter_GeneLiteModel Wise2_calculate_shatter_GeneLiteModel /* Function: search_GeneLiteModel(dbsi,out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneLiteModel * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_GeneLiteModel(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp); #define search_GeneLiteModel Wise2_search_GeneLiteModel /* Function: serial_search_GeneLiteModel(out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneLiteModel * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_GeneLiteModel(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp); #define serial_search_GeneLiteModel Wise2_serial_search_GeneLiteModel /* Function: PackAln_bestmemory_GeneLiteModel(query,target,gp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneLiteModel * * * Arg: query [UNKN ] query data structure [GwLiteScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_GeneLiteModel(GwLiteScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_GeneLiteModel Wise2_PackAln_bestmemory_GeneLiteModel /* Function: allocate_Expl_GeneLiteModel(query,target,gp,dpri) * * Descrip: This function allocates the GeneLiteModel structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneLiteModel_only * * * Arg: query [UNKN ] query data structure [GwLiteScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneLiteModel *] * */ GeneLiteModel * Wise2_allocate_Expl_GeneLiteModel(GwLiteScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPRunImpl * dpri); #define allocate_Expl_GeneLiteModel Wise2_allocate_Expl_GeneLiteModel /* Function: recalculate_PackAln_GeneLiteModel(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneLiteModel * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * */ void Wise2_recalculate_PackAln_GeneLiteModel(PackAln * pal,GeneLiteModel * mat); #define recalculate_PackAln_GeneLiteModel Wise2_recalculate_PackAln_GeneLiteModel /* Function: allocate_Small_GeneLiteModel(query,target,gp) * * Descrip: This function allocates the GeneLiteModel structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneLiteModel_only * * * Arg: query [UNKN ] query data structure [GwLiteScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneLiteModel *] * */ GeneLiteModel * Wise2_allocate_Small_GeneLiteModel(GwLiteScore* query,ComplexSequence* target ,GeneParser4Score * gp); #define allocate_Small_GeneLiteModel Wise2_allocate_Small_GeneLiteModel /* Function: PackAln_calculate_Small_GeneLiteModel(mat,dpenv) * * Descrip: This function calculates an alignment for GeneLiteModel structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneLiteModel * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneLiteModel * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_GeneLiteModel(GeneLiteModel * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_GeneLiteModel Wise2_PackAln_calculate_Small_GeneLiteModel /* Function: AlnRangeSet_calculate_Small_GeneLiteModel(mat) * * Descrip: This function calculates an alignment for GeneLiteModel structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneLiteModel * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneLiteModel * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneLiteModel * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_GeneLiteModel(GeneLiteModel * mat); #define AlnRangeSet_calculate_Small_GeneLiteModel Wise2_AlnRangeSet_calculate_Small_GeneLiteModel /* Function: AlnRangeSet_from_GeneLiteModel(mat) * * Descrip: This function reads off a start/end structure * for GeneLiteModel structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneLiteModel * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneLiteModel * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_GeneLiteModel(GeneLiteModel * mat); #define AlnRangeSet_from_GeneLiteModel Wise2_AlnRangeSet_from_GeneLiteModel /* Function: convert_PackAln_to_AlnBlock_GeneLiteModel(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_GeneLiteModel(PackAln * pal); #define convert_PackAln_to_AlnBlock_GeneLiteModel Wise2_convert_PackAln_to_AlnBlock_GeneLiteModel /* Function: PackAln_read_Expl_GeneLiteModel(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_GeneLiteModel(GeneLiteModel * mat); #define PackAln_read_Expl_GeneLiteModel Wise2_PackAln_read_Expl_GeneLiteModel /* Function: PackAln_read_generic_GeneLiteModel(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLiteModel *] * Arg: h [UNKN ] Undocumented argument [GeneLiteModel_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_GeneLiteModel(GeneLiteModel * mat,GeneLiteModel_access_func_holder h); #define PackAln_read_generic_GeneLiteModel Wise2_PackAln_read_generic_GeneLiteModel /* Function: calculate_GeneLiteModel(mat) * * Descrip: This function calculates the GeneLiteModel matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneLiteModel * * * Arg: mat [UNKN ] GeneLiteModel which contains explicit basematrix memory [GeneLiteModel *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_GeneLiteModel(GeneLiteModel * mat); #define calculate_GeneLiteModel Wise2_calculate_GeneLiteModel /* Function: calculate_dpenv_GeneLiteModel(mat,dpenv) * * Descrip: This function calculates the GeneLiteModel matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneLiteModel which contains explicit basematrix memory [GeneLiteModel *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_GeneLiteModel(GeneLiteModel * mat,DPEnvelope * dpenv); #define calculate_dpenv_GeneLiteModel Wise2_calculate_dpenv_GeneLiteModel /* Function: GeneLiteModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneLiteModel *] * */ GeneLiteModel * Wise2_GeneLiteModel_alloc(void); #define GeneLiteModel_alloc Wise2_GeneLiteModel_alloc /* Function: free_GeneLiteModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneLiteModel *] * * Return [UNKN ] Undocumented return value [GeneLiteModel *] * */ GeneLiteModel * Wise2_free_GeneLiteModel(GeneLiteModel * obj); #define free_GeneLiteModel Wise2_free_GeneLiteModel /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_GeneLiteModel_shatter_access_main(GeneLiteModel * mat,int i,int j,int state); #define GeneLiteModel_shatter_access_main Wise2_GeneLiteModel_shatter_access_main int Wise2_GeneLiteModel_shatter_access_special(GeneLiteModel * mat,int i,int j,int state); #define GeneLiteModel_shatter_access_special Wise2_GeneLiteModel_shatter_access_special void * Wise2_thread_loop_GeneLiteModel(void * ptr); #define thread_loop_GeneLiteModel Wise2_thread_loop_GeneLiteModel int Wise2_score_only_GeneLiteModel(GwLiteScore* query,ComplexSequence* target ,GeneParser4Score * gp); #define score_only_GeneLiteModel Wise2_score_only_GeneLiteModel GeneLiteModel * Wise2_allocate_GeneLiteModel_only(GwLiteScore* query,ComplexSequence* target ,GeneParser4Score * gp); #define allocate_GeneLiteModel_only Wise2_allocate_GeneLiteModel_only void Wise2_init_GeneLiteModel(GeneLiteModel * mat); #define init_GeneLiteModel Wise2_init_GeneLiteModel AlnRange * Wise2_AlnRange_build_GeneLiteModel(GeneLiteModel * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_GeneLiteModel Wise2_AlnRange_build_GeneLiteModel boolean Wise2_read_hidden_GeneLiteModel(GeneLiteModel * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_GeneLiteModel Wise2_read_hidden_GeneLiteModel int Wise2_max_hidden_GeneLiteModel(GeneLiteModel * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_GeneLiteModel Wise2_max_hidden_GeneLiteModel boolean Wise2_read_special_strip_GeneLiteModel(GeneLiteModel * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_GeneLiteModel Wise2_read_special_strip_GeneLiteModel int Wise2_max_special_strip_GeneLiteModel(GeneLiteModel * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_GeneLiteModel Wise2_max_special_strip_GeneLiteModel int Wise2_max_matrix_to_special_GeneLiteModel(GeneLiteModel * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_GeneLiteModel Wise2_max_matrix_to_special_GeneLiteModel void Wise2_calculate_hidden_GeneLiteModel(GeneLiteModel * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_GeneLiteModel Wise2_calculate_hidden_GeneLiteModel void Wise2_init_hidden_GeneLiteModel(GeneLiteModel * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_GeneLiteModel Wise2_init_hidden_GeneLiteModel boolean Wise2_full_dc_GeneLiteModel(GeneLiteModel * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_GeneLiteModel Wise2_full_dc_GeneLiteModel boolean Wise2_do_dc_single_pass_GeneLiteModel(GeneLiteModel * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_GeneLiteModel Wise2_do_dc_single_pass_GeneLiteModel void Wise2_push_dc_at_merge_GeneLiteModel(GeneLiteModel * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_GeneLiteModel Wise2_push_dc_at_merge_GeneLiteModel void Wise2_follow_on_dc_GeneLiteModel(GeneLiteModel * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_GeneLiteModel Wise2_follow_on_dc_GeneLiteModel void Wise2_run_up_dc_GeneLiteModel(GeneLiteModel * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_GeneLiteModel Wise2_run_up_dc_GeneLiteModel void Wise2_init_dc_GeneLiteModel(GeneLiteModel * mat); #define init_dc_GeneLiteModel Wise2_init_dc_GeneLiteModel int Wise2_start_end_find_end_GeneLiteModel(GeneLiteModel * mat,int * endj); #define start_end_find_end_GeneLiteModel Wise2_start_end_find_end_GeneLiteModel boolean Wise2_dc_optimised_start_end_calc_GeneLiteModel(GeneLiteModel *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_GeneLiteModel Wise2_dc_optimised_start_end_calc_GeneLiteModel void Wise2_init_start_end_linear_GeneLiteModel(GeneLiteModel * mat); #define init_start_end_linear_GeneLiteModel Wise2_init_start_end_linear_GeneLiteModel AlnConvertSet * Wise2_AlnConvertSet_GeneLiteModel(void); #define AlnConvertSet_GeneLiteModel Wise2_AlnConvertSet_GeneLiteModel int Wise2_GeneLiteModel_explicit_access_main(GeneLiteModel * mat,int i,int j,int state); #define GeneLiteModel_explicit_access_main Wise2_GeneLiteModel_explicit_access_main int Wise2_GeneLiteModel_explicit_access_special(GeneLiteModel * mat,int i,int j,int state); #define GeneLiteModel_explicit_access_special Wise2_GeneLiteModel_explicit_access_special int Wise2_find_end_GeneLiteModel(GeneLiteModel * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneLiteModel_access_func_holder h); #define find_end_GeneLiteModel Wise2_find_end_GeneLiteModel void Wise2_GeneLiteModel_debug_show_matrix(GeneLiteModel * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define GeneLiteModel_debug_show_matrix Wise2_GeneLiteModel_debug_show_matrix int Wise2_max_calc_GeneLiteModel(GeneLiteModel * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneLiteModel_access_func_holder h); #define max_calc_GeneLiteModel Wise2_max_calc_GeneLiteModel int Wise2_max_calc_special_GeneLiteModel(GeneLiteModel * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneLiteModel_access_func_holder h); #define max_calc_special_GeneLiteModel Wise2_max_calc_special_GeneLiteModel #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/bigdba.dy0000644000175000001440000000726107470224666015714 0ustar philippusers %{ #include "dyna.h" %} matrix BigDnaMatchBlock query type="DNA" name="query" target type="DNA" name="target" resource type="DnaMatrix*" name="comp55" resource type="DnaMatrix*" name="comp65" resource type="DnaMatrix*" name="comp75" resource type="DnaMatrix*" name="comp85" resource type="DnaMatrix*" name="comp95" resource type="Score" name="g" resource type="Score" name="g65" resource type="Score" name="g55" resource type="Score" name="u" resource type="Score" name="v" resource type="Score" name="s" resource type="Score" name="b" state MATCH55 source MATCH55 offi="1" offj="1" calc="comp55->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + s" endsource source MATCH55 offi="0" offj="1" calc="g55" target_label MI55 endsource source MATCH55 offi="1" offj="0" calc="g55" query_label MI55 endsource source UNMATCHED_TARGET offi="1" offj="1" calc="comp55->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + v" endsource query_label MM55 target_label MM55 endstate state MATCH65 source MATCH65 offi="1" offj="1" calc="comp65->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + s" endsource source MATCH65 offi="0" offj="1" calc="g65" target_label MI65 endsource source MATCH65 offi="1" offj="0" calc="g65" query_label MI65 endsource source UNMATCHED_TARGET offi="1" offj="1" calc="comp65->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + v" endsource query_label MM65 target_label MM65 endstate state MATCH75 source MATCH75 offi="1" offj="1" calc="comp75->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + s" endsource source MATCH75 offi="0" offj="1" calc="g" target_label MI75 endsource source MATCH75 offi="1" offj="0" calc="g" query_label MI75 endsource source UNMATCHED_TARGET offi="1" offj="1" calc="comp75->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + v" endsource query_label MM75 target_label MM75 endstate state MATCH85 source MATCH85 offi="1" offj="1" calc="comp85->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + s" endsource source MATCH85 offi="0" offj="1" calc="g" target_label MI85 endsource source MATCH85 offi="1" offj="0" calc="g" query_label MI85 endsource source UNMATCHED_TARGET offi="1" offj="1" calc="comp85->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + v" endsource query_label MM85 target_label MM85 endstate state MATCH95 source MATCH95 offi="1" offj="1" calc="comp95->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + s" endsource source MATCH95 offi="0" offj="1" calc="g" target_label MI95 endsource source MATCH95 offi="1" offj="0" calc="g" query_label MI95 endsource source UNMATCHED_TARGET offi="1" offj="1" calc="comp95->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + v" endsource query_label MM95 target_label MM95 endstate state UNMATCHED_QUERY offi="1" offj="0" source MATCH55 calc="b" endsource source MATCH65 calc="b" endsource source MATCH75 calc="b" endsource source MATCH85 calc="b" endsource source MATCH95 calc="b" endsource source UNMATCHED_QUERY calc="u" endsource source START !top !left calc="0" endsource query_label UM target_label UI endstate state UNMATCHED_TARGET offi="0" offj="1" source UNMATCHED_QUERY calc="v" endsource source UNMATCHED_TARGET calc="u" endsource target_label UM query_label UI endstate state START !special !start query_label START target_label START endstate state END !special !end source UNMATCHED_TARGET !right !bottom calc="0" endsource query_label END target_label END endstate endmatrix wise-2.4.1/src/models/pfamhmmer1db.typemap0000644000175000001440000000102610670453714020075 0ustar philippusers TYPEMAP Wise2_PfamHmmer1DB * T_Wise2_PfamHmmer1DB INPUT T_Wise2_PfamHmmer1DB $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_PfamHmmer1DB *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_PfamHmmer1DB sv_setref_pv($arg, "Wise2::PfamHmmer1DB", (void*) $var); TYPEMAP Wise2_PfamHmmer1Entry * T_Wise2_PfamHmmer1Entry INPUT T_Wise2_PfamHmmer1Entry $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_PfamHmmer1Entry *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_PfamHmmer1Entry sv_setref_pv($arg, "Wise2::PfamHmmer1Entry", (void*) $var); wise-2.4.1/src/models/motifcluster.c0000644000175000001440000001066510067536713017027 0ustar philippusers#include "transfactor.h" #include "transregion.h" #include "version.h" #include "commandline.h" char * program_name = "motifcluster"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s motif-library sequence\n",program_name); fprintf(ofp," -lr motif library is in laurence's format\n"); fprintf(ofp," -ben motif library is in ben's IUPAC format\n"); fprintf(ofp," -[no]show_match - show all matches that pass criteria, default no\n"); fprintf(ofp," -[no]show_region - show only dense cluster regions, default no\n"); fprintf(ofp," -[no]show_compara - show only comparative matches, default yes\n"); fprintf(ofp," -circular [no] - for randomisation, number of positions to permute\n"); show_help_TransFactorBuildPara(ofp); show_help_TransFactorMatchPara(ofp); show_help_TransFactorRegionPara(ofp); show_help_TransFactorComparaPara(ofp); show_help_DPRunImpl(ofp); show_standard_options(ofp); } int main(int argc,char ** argv) { TransFactorSet * tfs; TransFactorSet * newtfs; /* only used as a temp when permuting */ TransFactorBuildPara * tfb; TransFactorMatchSetCompara * comp; TransFactorMatchPara * matchp; TransFactorComparaPara * comparap; boolean use_laurence = FALSE; boolean use_ben = FALSE; boolean show_matchset = FALSE; boolean show_region = FALSE; boolean show_compara = TRUE; int end_on_seq = 0; int seq_count = 0; int rotate_number = 0; TransFactorRegionSet * tfrs; TransFactorRegionPara * tfrp; DPRunImpl * dpri; FILE * ifp; SeqAlign * sa; int i; tfb = new_TransFactorBuildPara_from_argv(&argc,argv); matchp = new_TransFactorMatchPara_from_argv(&argc,argv); tfrp = new_TransFactorRegionPara_from_argv(&argc,argv); comparap = new_TransFactorComparaPara_from_argv(&argc,argv); dpri = new_DPRunImpl_from_argv(&argc,argv); strip_out_boolean_def_argument(&argc,argv,"show_match",&show_matchset); strip_out_boolean_def_argument(&argc,argv,"show_region",&show_region); strip_out_integer_argument(&argc,argv,"circular",&rotate_number); if( strip_out_boolean_argument(&argc,argv,"lr") == TRUE ) { use_laurence = TRUE; } if( strip_out_boolean_argument(&argc,argv,"ben") == TRUE ) { use_ben = TRUE; } strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 3 ) { show_help(stdout); exit(12); } if( use_laurence == TRUE ) { tfs = read_laurence_TransFactorSet_file(argv[1]); } else if( use_ben == TRUE ) { tfs = read_ben_IUPAC_TransFactorSet_file(argv[1]); } else { tfs = read_TransFactorSet_file(argv[1]); } if( tfs->len == 0 ) { fatal("No transcription factors in set!"); } build_TransFactorSet(tfs,tfb); if( rotate_number > 0 ) { fprintf(stdout,"PERMUTED RESULTS - %d rotation\n",rotate_number); newtfs = circular_permuted_TransFactorSet(tfs,rotate_number); free_TransFactorSet(tfs); tfs = newtfs; } ifp = openfile(argv[2],"r"); if( ifp == NULL ) { fatal("Cannot open %s as input file",argv[2]); } while( (sa = read_fasta_SeqAlign(ifp)) ) { for(i=0;ilen;i++) { sa->seq[i]->type = SEQUENCE_DNA; } comp = calculate_TransFactorMatchSetCompara(sa,tfs,matchp,comparap); sort_by_start_TransFactorMatchSet(comp->overall); fprintf(stdout,"%s %d raw hits %d conserved\n",comp->overall->target->name,comp->tfms[0]->len,comp->overall->len); fflush(stdout); if( show_compara == TRUE ) { show_context_match_TransFactorMatchSetCompara(comp,15,stdout); } if( show_matchset == TRUE ) { show_TransFactorMatchSet(comp->overall,stdout); } if( show_region == TRUE ) { tfrs = new_TransFactorRegionSet(comp->overall,tfrp,dpri); show_TransFactorRegionSet(tfrs,stdout); free_TransFactorRegionSet(tfrs); } free_TransFactorMatchSetCompara(comp); free_SeqAlign(sa); fprintf(stdout,"//\n"); } } wise-2.4.1/src/models/estslim3.dy0000644000175000001440000000602207313404544016230 0ustar philippusers/* Last edited: Apr 24 15:04 1997 (birney) */ %{ #include "dyna.h" #include "cdparser.h" #include "genewisemodel.h" #include "genewisemodeldb.h" %} matrix EstSlim3 query type="CDNA_HMM" name="query" field:len="len" target type="CDNA" name="target" resource type="cDNAParserScore *" name="cp" extern name="GW_*" type="int" extern name="PCD_*" type="int" state MATCH offi="1" offj="3" source MATCH calc="query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource # # Sequencing error transitions, at offsets 2,4 for speed up # source MATCH offi="1" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource query_label MATCH_STATE target_label CODON endstate # # Insert state: does not move along model, produces DNA sequence... # state INSERT offi="0" offj="3" source MATCH calc="query->seg[i]->transition[GW_MATCH2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource # # Sequencing error transitions at only 2,4 for speed up # source INSERT offi="0" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="query->seg[i]->transition[GW_MATCH2DELETE]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2DELETE]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2DELETE]" endsource source START calc="query->seg[i]->transition[GW_START2DELETE]" endsource query_label DELETE_STATE target_label INSERT endstate state START !start !special endstate state END !end !special source MATCH calc="query->seg[i]->transition[GW_MATCH2END]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2END]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2END]" endsource target_label END query_label END endstate endmatrix wise-2.4.1/src/models/gwlitemodel.c0000644000175000001440000006260610670453714016624 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "gwlitemodel.h" /* Function: GwLite_AlnBlock_surgery(alb) * * Descrip: A pretty weird function. Takes an AlnBlock made by GwLite and * performs the necessary surgery at the 3SS to make it look like * the AlnBlocks produced by the other genewise models. This means * it has to eat into the intron by 3 residues * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * */ # line 82 "gwlitemodel.dy" void GwLite_AlnBlock_surgery(AlnBlock * alb) { AlnColumn * alc; for(alc = alb->start;alc != NULL;alc = alc->next ) { if( strstartcmp(alc->alu[1]->text_label,"3SS") == 0 ) { alc->alu[1]->start -= 3; } } } /* Function: GwLite_from_GeneWise(gwm) * * Descrip: Builds a GwLite model from the GeneWise model * * * Arg: gwm [UNKN ] Undocumented argument [GeneWise *] * * Return [UNKN ] Undocumented return value [GwLite *] * */ # line 97 "gwlitemodel.dy" GwLite * GwLite_from_GeneWise(GeneWise * gwm) { GwLite * out; GwLiteSegment * seg; int i,c,codon125; out = GwLite_alloc_len(gwm->len); for(i=0;ilen;i++) { seg = GwLiteSegment_alloc(); for(c=0;c<64;c++) { codon125 = codon_from_base4_codon(c); seg->match[c]= gwm->seg[i]->match[codon125]; seg->insert[c]= gwm->seg[i]->insert[codon125]; } seg->transition[GWL_MATCH2MATCH] = gwm->seg[i]->transition[GW_MATCH2MATCH]; seg->transition[GWL_MATCH2INSERT] = gwm->seg[i]->transition[GW_MATCH2INSERT]; seg->transition[GWL_MATCH2DELETE] = gwm->seg[i]->transition[GW_MATCH2DELETE]; seg->transition[GWL_MATCH2END] = gwm->seg[i]->transition[GW_MATCH2END]; seg->transition[GWL_INSERT2MATCH] = gwm->seg[i]->transition[GW_INSERT2MATCH]; seg->transition[GWL_INSERT2INSERT] = gwm->seg[i]->transition[GW_INSERT2INSERT]; seg->transition[GWL_INSERT2DELETE] = gwm->seg[i]->transition[GW_INSERT2DELETE]; seg->transition[GWL_INSERT2END] = gwm->seg[i]->transition[GW_INSERT2END]; seg->transition[GWL_DELETE2MATCH] = gwm->seg[i]->transition[GW_DELETE2MATCH]; seg->transition[GWL_DELETE2INSERT] = gwm->seg[i]->transition[GW_DELETE2INSERT]; seg->transition[GWL_DELETE2DELETE] = gwm->seg[i]->transition[GW_DELETE2DELETE]; seg->transition[GWL_DELETE2END] = gwm->seg[i]->transition[GW_DELETE2END]; seg->transition[GWL_START2MATCH] = gwm->seg[i]->transition[GW_START2MATCH]; seg->transition[GWL_START2INSERT] = gwm->seg[i]->transition[GW_START2INSERT]; seg->transition[GWL_START2DELETE] = gwm->seg[i]->transition[GW_START2DELETE]; add_GwLite(out,seg); } out->name = stringalloc(gwm->name); return out; } /* Function: GwLiteScore_from_GwLite(gwl) * * Descrip: Makes a lite score from a lite probability basis * * * Arg: gwl [UNKN ] Undocumented argument [GwLite *] * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ # line 143 "gwlitemodel.dy" GwLiteScore * GwLiteScore_from_GwLite(GwLite * gwl) { GwLiteScore * out; GwLiteSegment * prev; int i; out = GwLiteScore_alloc_len(gwl->len); for(i=0,prev=NULL;ilen;i++) { add_GwLiteScore(out,GwLiteSegmentScore_from_GwLiteSegment(prev,gwl->seg[i])); prev = gwl->seg[i]; } out->name = stringalloc(gwl->name); return out; } # line 160 "gwlitemodel.dy" GwLiteSegmentScore * GwLiteSegmentScore_from_GwLiteSegment(GwLiteSegment *prev,GwLiteSegment * seg) { GwLiteSegmentScore * out; out = GwLiteSegmentScore_alloc(); Probability2Score_move(seg->match,out->match,GWL_EMISSION_LEN); Probability2Score_move(seg->insert,out->insert,GWL_EMISSION_LEN); if( prev != NULL ) { out->transition[GWL_MATCH2MATCH] = Probability2Score(prev->transition[GWL_MATCH2MATCH]); out->transition[GWL_INSERT2MATCH] = Probability2Score(prev->transition[GWL_INSERT2MATCH]); out->transition[GWL_DELETE2MATCH] = Probability2Score(prev->transition[GWL_DELETE2MATCH]); out->transition[GWL_MATCH2DELETE] = Probability2Score(prev->transition[GWL_MATCH2DELETE]); out->transition[GWL_INSERT2DELETE] = Probability2Score(prev->transition[GWL_INSERT2DELETE]); out->transition[GWL_DELETE2DELETE] = Probability2Score(prev->transition[GWL_DELETE2DELETE]); } else { out->transition[GWL_MATCH2MATCH] = NEGI; out->transition[GWL_INSERT2MATCH] = NEGI; out->transition[GWL_DELETE2MATCH] = NEGI; out->transition[GWL_MATCH2DELETE] = NEGI; out->transition[GWL_INSERT2DELETE] = NEGI; out->transition[GWL_DELETE2DELETE] = NEGI; } out->transition[GWL_MATCH2INSERT] = Probability2Score(seg->transition[GWL_MATCH2INSERT]); out->transition[GWL_INSERT2INSERT] = Probability2Score(seg->transition[GWL_INSERT2INSERT]); out->transition[GWL_DELETE2INSERT] = Probability2Score(seg->transition[GWL_DELETE2INSERT]); out->transition[GWL_START2MATCH] = Probability2Score(seg->transition[GWL_START2MATCH]); out->transition[GWL_START2INSERT] = Probability2Score(seg->transition[GWL_START2INSERT]); out->transition[GWL_START2DELETE] = Probability2Score(seg->transition[GWL_START2DELETE]); out->transition[GWL_MATCH2END] = Probability2Score(seg->transition[GWL_MATCH2END]); out->transition[GWL_INSERT2END] = Probability2Score(seg->transition[GWL_INSERT2END]); out->transition[GWL_DELETE2END] = Probability2Score(seg->transition[GWL_DELETE2END]); return out; } # line 151 "gwlitemodel.c" /* Function: hard_link_GwLiteSegment(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GwLiteSegment *] * * Return [UNKN ] Undocumented return value [GwLiteSegment *] * */ GwLiteSegment * hard_link_GwLiteSegment(GwLiteSegment * obj) { if( obj == NULL ) { warn("Trying to hard link to a GwLiteSegment object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GwLiteSegment_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GwLiteSegment *] * */ GwLiteSegment * GwLiteSegment_alloc(void) { GwLiteSegment * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GwLiteSegment *) ckalloc (sizeof(GwLiteSegment))) == NULL) { warn("GwLiteSegment_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* match[GWL_EMISSION_LEN] is an array: no default possible */ /* insert[GWL_EMISSION_LEN] is an array: no default possible */ /* transition[GWL_TRANSITION_LEN] is an array: no default possible */ return out; } /* Function: free_GwLiteSegment(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GwLiteSegment *] * * Return [UNKN ] Undocumented return value [GwLiteSegment *] * */ GwLiteSegment * free_GwLiteSegment(GwLiteSegment * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GwLiteSegment obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_GwLite(list,i,j) * * Descrip: swap function: an internal for qsort_GwLite * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [GwLiteSegment **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_GwLite(GwLiteSegment ** list,int i,int j) { GwLiteSegment * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_GwLite(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_GwLite which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [GwLiteSegment **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_GwLite(GwLiteSegment ** list,int left,int right,int (*comp)(GwLiteSegment * ,GwLiteSegment * )) { int i,last; if( left >= right ) return; swap_GwLite(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_GwLite (list,++last,i); } swap_GwLite (list,left,last); qsort_GwLite(list,left,last-1,comp); qsort_GwLite(list,last+1,right,comp); } /* Function: sort_GwLite(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_GwLite * * * Arg: obj [UNKN ] Object containing list [GwLite *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_GwLite(GwLite * obj,int (*comp)(GwLiteSegment *, GwLiteSegment *)) { qsort_GwLite(obj->seg,0,obj->len-1,comp); return; } /* Function: expand_GwLite(obj,len) * * Descrip: Really an internal function for add_GwLite * * * Arg: obj [UNKN ] Object which contains the list [GwLite *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_GwLite(GwLite * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_GwLite called with no need"); return TRUE; } if( (obj->seg = (GwLiteSegment ** ) ckrealloc (obj->seg,sizeof(GwLiteSegment *)*len)) == NULL) { warn("ckrealloc failed for expand_GwLite, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_GwLite(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GwLite *] * Arg: add [OWNER] Object to add to the list [GwLiteSegment *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_GwLite(GwLite * obj,GwLiteSegment * add) { if( obj->len >= obj->maxlen) { if( expand_GwLite(obj,obj->len + GwLiteLISTLENGTH) == FALSE) return FALSE; } obj->seg[obj->len++]=add; return TRUE; } /* Function: flush_GwLite(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GwLite *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GwLite(GwLite * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->seg[i] != NULL) { free_GwLiteSegment(obj->seg[i]); obj->seg[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: GwLite_alloc_std(void) * * Descrip: Equivalent to GwLite_alloc_len(GwLiteLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GwLite *] * */ GwLite * GwLite_alloc_std(void) { return GwLite_alloc_len(GwLiteLISTLENGTH); } /* Function: GwLite_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GwLite *] * */ GwLite * GwLite_alloc_len(int len) { GwLite * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = GwLite_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->seg = (GwLiteSegment ** ) ckcalloc (len,sizeof(GwLiteSegment *))) == NULL) { warn("Warning, ckcalloc failed in GwLite_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_GwLite(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GwLite *] * * Return [UNKN ] Undocumented return value [GwLite *] * */ GwLite * hard_link_GwLite(GwLite * obj) { if( obj == NULL ) { warn("Trying to hard link to a GwLite object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GwLite_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GwLite *] * */ GwLite * GwLite_alloc(void) { GwLite * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GwLite *) ckalloc (sizeof(GwLite))) == NULL) { warn("GwLite_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->seg = NULL; out->len = out->maxlen = 0; out->name = NULL; return out; } /* Function: free_GwLite(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GwLite *] * * Return [UNKN ] Undocumented return value [GwLite *] * */ GwLite * free_GwLite(GwLite * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GwLite obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->seg != NULL) { for(i=0;ilen;i++) { if( obj->seg[i] != NULL) free_GwLiteSegment(obj->seg[i]); } ckfree(obj->seg); } if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: hard_link_GwLiteSegmentScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GwLiteSegmentScore *] * * Return [UNKN ] Undocumented return value [GwLiteSegmentScore *] * */ GwLiteSegmentScore * hard_link_GwLiteSegmentScore(GwLiteSegmentScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a GwLiteSegmentScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GwLiteSegmentScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GwLiteSegmentScore *] * */ GwLiteSegmentScore * GwLiteSegmentScore_alloc(void) { GwLiteSegmentScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GwLiteSegmentScore *) ckalloc (sizeof(GwLiteSegmentScore))) == NULL) { warn("GwLiteSegmentScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* match[GWL_EMISSION_LEN] is an array: no default possible */ /* insert[GWL_EMISSION_LEN] is an array: no default possible */ /* transition[GWL_TRANSITION_LEN] is an array: no default possible */ return out; } /* Function: free_GwLiteSegmentScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GwLiteSegmentScore *] * * Return [UNKN ] Undocumented return value [GwLiteSegmentScore *] * */ GwLiteSegmentScore * free_GwLiteSegmentScore(GwLiteSegmentScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GwLiteSegmentScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_GwLiteScore(list,i,j) * * Descrip: swap function: an internal for qsort_GwLiteScore * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [GwLiteSegmentScore **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_GwLiteScore(GwLiteSegmentScore ** list,int i,int j) { GwLiteSegmentScore * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_GwLiteScore(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_GwLiteScore which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [GwLiteSegmentScore **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_GwLiteScore(GwLiteSegmentScore ** list,int left,int right,int (*comp)(GwLiteSegmentScore * ,GwLiteSegmentScore * )) { int i,last; if( left >= right ) return; swap_GwLiteScore(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_GwLiteScore (list,++last,i); } swap_GwLiteScore (list,left,last); qsort_GwLiteScore(list,left,last-1,comp); qsort_GwLiteScore(list,last+1,right,comp); } /* Function: sort_GwLiteScore(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_GwLiteScore * * * Arg: obj [UNKN ] Object containing list [GwLiteScore *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_GwLiteScore(GwLiteScore * obj,int (*comp)(GwLiteSegmentScore *, GwLiteSegmentScore *)) { qsort_GwLiteScore(obj->seg,0,obj->len-1,comp); return; } /* Function: expand_GwLiteScore(obj,len) * * Descrip: Really an internal function for add_GwLiteScore * * * Arg: obj [UNKN ] Object which contains the list [GwLiteScore *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_GwLiteScore(GwLiteScore * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_GwLiteScore called with no need"); return TRUE; } if( (obj->seg = (GwLiteSegmentScore ** ) ckrealloc (obj->seg,sizeof(GwLiteSegmentScore *)*len)) == NULL) { warn("ckrealloc failed for expand_GwLiteScore, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_GwLiteScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GwLiteScore *] * Arg: add [OWNER] Object to add to the list [GwLiteSegmentScore *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_GwLiteScore(GwLiteScore * obj,GwLiteSegmentScore * add) { if( obj->len >= obj->maxlen) { if( expand_GwLiteScore(obj,obj->len + GwLiteScoreLISTLENGTH) == FALSE) return FALSE; } obj->seg[obj->len++]=add; return TRUE; } /* Function: flush_GwLiteScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GwLiteScore *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GwLiteScore(GwLiteScore * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->seg[i] != NULL) { free_GwLiteSegmentScore(obj->seg[i]); obj->seg[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: GwLiteScore_alloc_std(void) * * Descrip: Equivalent to GwLiteScore_alloc_len(GwLiteScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ GwLiteScore * GwLiteScore_alloc_std(void) { return GwLiteScore_alloc_len(GwLiteScoreLISTLENGTH); } /* Function: GwLiteScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ GwLiteScore * GwLiteScore_alloc_len(int len) { GwLiteScore * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = GwLiteScore_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->seg = (GwLiteSegmentScore ** ) ckcalloc (len,sizeof(GwLiteSegmentScore *))) == NULL) { warn("Warning, ckcalloc failed in GwLiteScore_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_GwLiteScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GwLiteScore *] * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ GwLiteScore * hard_link_GwLiteScore(GwLiteScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a GwLiteScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GwLiteScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ GwLiteScore * GwLiteScore_alloc(void) { GwLiteScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GwLiteScore *) ckalloc (sizeof(GwLiteScore))) == NULL) { warn("GwLiteScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->seg = NULL; out->len = out->maxlen = 0; out->name = NULL; return out; } /* Function: free_GwLiteScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GwLiteScore *] * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ GwLiteScore * free_GwLiteScore(GwLiteScore * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GwLiteScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->seg != NULL) { for(i=0;ilen;i++) { if( obj->seg[i] != NULL) free_GwLiteSegmentScore(obj->seg[i]); } ckfree(obj->seg); } if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/gwlitemodel.h0000644000175000001440000003312610670453714016624 0ustar philippusers#ifndef DYNAMITEgwlitemodelHEADERFILE #define DYNAMITEgwlitemodelHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "genewisemodel.h" #define GwLiteScoreLISTLENGTH 128 #define GwLiteLISTLENGTH 128 enum GwLiteTransition { GWL_MATCH2MATCH, GWL_MATCH2INSERT, GWL_MATCH2DELETE, GWL_MATCH2END, GWL_INSERT2MATCH, GWL_INSERT2INSERT, GWL_INSERT2DELETE, GWL_INSERT2END, GWL_DELETE2MATCH, GWL_DELETE2INSERT, GWL_DELETE2DELETE, GWL_DELETE2END, GWL_START2MATCH, GWL_START2INSERT, GWL_START2DELETE, GWL_TRANSITION_LEN }; #define GWL_EMISSION_LEN 65 /* Object GwLiteSegment * * Descrip: This is a particular HMM node, with * match and insert emissions in the codon space * and the transitions for the genewise light model * * */ struct Wise2_GwLiteSegment { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability match[GWL_EMISSION_LEN]; Probability insert[GWL_EMISSION_LEN]; Probability transition[GWL_TRANSITION_LEN]; } ; /* GwLiteSegment defined */ #ifndef DYNAMITE_DEFINED_GwLiteSegment typedef struct Wise2_GwLiteSegment Wise2_GwLiteSegment; #define GwLiteSegment Wise2_GwLiteSegment #define DYNAMITE_DEFINED_GwLiteSegment #endif /* Object GwLite * * Descrip: This is the lightweight version * of GeneWise designed for faster executation * and better portability to hardware environments * * */ struct Wise2_GwLite { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GwLiteSegment ** seg; int len;/* len for above seg */ int maxlen; /* maxlen for above seg */ char * name; } ; /* GwLite defined */ #ifndef DYNAMITE_DEFINED_GwLite typedef struct Wise2_GwLite Wise2_GwLite; #define GwLite Wise2_GwLite #define DYNAMITE_DEFINED_GwLite #endif /* Object GwLiteSegmentScore * * Descrip: This is the genewise lite scoring * data structure * * */ struct Wise2_GwLiteSegmentScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score match[GWL_EMISSION_LEN]; Score insert[GWL_EMISSION_LEN]; Score transition[GWL_TRANSITION_LEN]; } ; /* GwLiteSegmentScore defined */ #ifndef DYNAMITE_DEFINED_GwLiteSegmentScore typedef struct Wise2_GwLiteSegmentScore Wise2_GwLiteSegmentScore; #define GwLiteSegmentScore Wise2_GwLiteSegmentScore #define DYNAMITE_DEFINED_GwLiteSegmentScore #endif /* Object GwLiteScore * * Descrip: This is the lightweight version * of GeneWise designed for faster executation * and better portability to hardware environments * * */ struct Wise2_GwLiteScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GwLiteSegmentScore ** seg; int len;/* len for above seg */ int maxlen; /* maxlen for above seg */ char * name; } ; /* GwLiteScore defined */ #ifndef DYNAMITE_DEFINED_GwLiteScore typedef struct Wise2_GwLiteScore Wise2_GwLiteScore; #define GwLiteScore Wise2_GwLiteScore #define DYNAMITE_DEFINED_GwLiteScore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: GwLite_AlnBlock_surgery(alb) * * Descrip: A pretty weird function. Takes an AlnBlock made by GwLite and * performs the necessary surgery at the 3SS to make it look like * the AlnBlocks produced by the other genewise models. This means * it has to eat into the intron by 3 residues * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * */ void Wise2_GwLite_AlnBlock_surgery(AlnBlock * alb); #define GwLite_AlnBlock_surgery Wise2_GwLite_AlnBlock_surgery /* Function: GwLite_from_GeneWise(gwm) * * Descrip: Builds a GwLite model from the GeneWise model * * * Arg: gwm [UNKN ] Undocumented argument [GeneWise *] * * Return [UNKN ] Undocumented return value [GwLite *] * */ GwLite * Wise2_GwLite_from_GeneWise(GeneWise * gwm); #define GwLite_from_GeneWise Wise2_GwLite_from_GeneWise /* Function: GwLiteScore_from_GwLite(gwl) * * Descrip: Makes a lite score from a lite probability basis * * * Arg: gwl [UNKN ] Undocumented argument [GwLite *] * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ GwLiteScore * Wise2_GwLiteScore_from_GwLite(GwLite * gwl); #define GwLiteScore_from_GwLite Wise2_GwLiteScore_from_GwLite /* Function: hard_link_GwLiteSegment(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GwLiteSegment *] * * Return [UNKN ] Undocumented return value [GwLiteSegment *] * */ GwLiteSegment * Wise2_hard_link_GwLiteSegment(GwLiteSegment * obj); #define hard_link_GwLiteSegment Wise2_hard_link_GwLiteSegment /* Function: GwLiteSegment_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GwLiteSegment *] * */ GwLiteSegment * Wise2_GwLiteSegment_alloc(void); #define GwLiteSegment_alloc Wise2_GwLiteSegment_alloc /* Function: free_GwLiteSegment(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GwLiteSegment *] * * Return [UNKN ] Undocumented return value [GwLiteSegment *] * */ GwLiteSegment * Wise2_free_GwLiteSegment(GwLiteSegment * obj); #define free_GwLiteSegment Wise2_free_GwLiteSegment /* Function: add_GwLite(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GwLite *] * Arg: add [OWNER] Object to add to the list [GwLiteSegment *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_GwLite(GwLite * obj,GwLiteSegment * add); #define add_GwLite Wise2_add_GwLite /* Function: flush_GwLite(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GwLite *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_GwLite(GwLite * obj); #define flush_GwLite Wise2_flush_GwLite /* Function: GwLite_alloc_std(void) * * Descrip: Equivalent to GwLite_alloc_len(GwLiteLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GwLite *] * */ GwLite * Wise2_GwLite_alloc_std(void); #define GwLite_alloc_std Wise2_GwLite_alloc_std /* Function: GwLite_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GwLite *] * */ GwLite * Wise2_GwLite_alloc_len(int len); #define GwLite_alloc_len Wise2_GwLite_alloc_len /* Function: hard_link_GwLite(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GwLite *] * * Return [UNKN ] Undocumented return value [GwLite *] * */ GwLite * Wise2_hard_link_GwLite(GwLite * obj); #define hard_link_GwLite Wise2_hard_link_GwLite /* Function: GwLite_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GwLite *] * */ GwLite * Wise2_GwLite_alloc(void); #define GwLite_alloc Wise2_GwLite_alloc /* Function: free_GwLite(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GwLite *] * * Return [UNKN ] Undocumented return value [GwLite *] * */ GwLite * Wise2_free_GwLite(GwLite * obj); #define free_GwLite Wise2_free_GwLite /* Function: hard_link_GwLiteSegmentScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GwLiteSegmentScore *] * * Return [UNKN ] Undocumented return value [GwLiteSegmentScore *] * */ GwLiteSegmentScore * Wise2_hard_link_GwLiteSegmentScore(GwLiteSegmentScore * obj); #define hard_link_GwLiteSegmentScore Wise2_hard_link_GwLiteSegmentScore /* Function: GwLiteSegmentScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GwLiteSegmentScore *] * */ GwLiteSegmentScore * Wise2_GwLiteSegmentScore_alloc(void); #define GwLiteSegmentScore_alloc Wise2_GwLiteSegmentScore_alloc /* Function: free_GwLiteSegmentScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GwLiteSegmentScore *] * * Return [UNKN ] Undocumented return value [GwLiteSegmentScore *] * */ GwLiteSegmentScore * Wise2_free_GwLiteSegmentScore(GwLiteSegmentScore * obj); #define free_GwLiteSegmentScore Wise2_free_GwLiteSegmentScore /* Function: add_GwLiteScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GwLiteScore *] * Arg: add [OWNER] Object to add to the list [GwLiteSegmentScore *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_GwLiteScore(GwLiteScore * obj,GwLiteSegmentScore * add); #define add_GwLiteScore Wise2_add_GwLiteScore /* Function: flush_GwLiteScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GwLiteScore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_GwLiteScore(GwLiteScore * obj); #define flush_GwLiteScore Wise2_flush_GwLiteScore /* Function: GwLiteScore_alloc_std(void) * * Descrip: Equivalent to GwLiteScore_alloc_len(GwLiteScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ GwLiteScore * Wise2_GwLiteScore_alloc_std(void); #define GwLiteScore_alloc_std Wise2_GwLiteScore_alloc_std /* Function: GwLiteScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ GwLiteScore * Wise2_GwLiteScore_alloc_len(int len); #define GwLiteScore_alloc_len Wise2_GwLiteScore_alloc_len /* Function: hard_link_GwLiteScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GwLiteScore *] * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ GwLiteScore * Wise2_hard_link_GwLiteScore(GwLiteScore * obj); #define hard_link_GwLiteScore Wise2_hard_link_GwLiteScore /* Function: GwLiteScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ GwLiteScore * Wise2_GwLiteScore_alloc(void); #define GwLiteScore_alloc Wise2_GwLiteScore_alloc /* Function: free_GwLiteScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GwLiteScore *] * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ GwLiteScore * Wise2_free_GwLiteScore(GwLiteScore * obj); #define free_GwLiteScore Wise2_free_GwLiteScore /* Unplaced functions */ /* There has been no indication of the use of these functions */ GwLiteSegmentScore * Wise2_GwLiteSegmentScore_from_GwLiteSegment(GwLiteSegment *prev,GwLiteSegment * seg); #define GwLiteSegmentScore_from_GwLiteSegment Wise2_GwLiteSegmentScore_from_GwLiteSegment /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_GwLite(GwLiteSegment ** list,int i,int j) ; #define swap_GwLite Wise2_swap_GwLite void Wise2_qsort_GwLite(GwLiteSegment ** list,int left,int right,int (*comp)(GwLiteSegment * ,GwLiteSegment * )); #define qsort_GwLite Wise2_qsort_GwLite void Wise2_sort_GwLite(GwLite * obj,int (*comp)(GwLiteSegment *, GwLiteSegment *)); #define sort_GwLite Wise2_sort_GwLite boolean Wise2_expand_GwLite(GwLite * obj,int len); #define expand_GwLite Wise2_expand_GwLite void Wise2_swap_GwLiteScore(GwLiteSegmentScore ** list,int i,int j) ; #define swap_GwLiteScore Wise2_swap_GwLiteScore void Wise2_qsort_GwLiteScore(GwLiteSegmentScore ** list,int left,int right,int (*comp)(GwLiteSegmentScore * ,GwLiteSegmentScore * )); #define qsort_GwLiteScore Wise2_qsort_GwLiteScore void Wise2_sort_GwLiteScore(GwLiteScore * obj,int (*comp)(GwLiteSegmentScore *, GwLiteSegmentScore *)); #define sort_GwLiteScore Wise2_sort_GwLiteScore boolean Wise2_expand_GwLiteScore(GwLiteScore * obj,int len); #define expand_GwLiteScore Wise2_expand_GwLiteScore #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/pfamhmmer1db_api.h0000644000175000001440000002521110670453714017500 0ustar philippusers /* Functions that create, manipulate or act on PfamHmmer1DB * * Wise2_hard_link_PfamHmmer1DB * Wise2_PfamHmmer1DB_alloc_std * Wise2_access_en_PfamHmmer1DB * Wise2_length_en_PfamHmmer1DB * Wise2_flush_PfamHmmer1DB * Wise2_add_PfamHmmer1DB * Wise2_replace_dirname_PfamHmmer1DB * Wise2_access_dirname_PfamHmmer1DB * Wise2_replace_cur_PfamHmmer1DB * Wise2_access_cur_PfamHmmer1DB * Wise2_replace_def_PfamHmmer1DB * Wise2_access_def_PfamHmmer1DB * Wise2_free_PfamHmmer1DB [destructor] * */ /* Functions that create, manipulate or act on PfamHmmer1Entry * * Wise2_hard_link_PfamHmmer1Entry * Wise2_PfamHmmer1Entry_alloc * Wise2_replace_entryname_PfamHmmer1Entry * Wise2_access_entryname_PfamHmmer1Entry * Wise2_replace_is_random_PfamHmmer1Entry * Wise2_access_is_random_PfamHmmer1Entry * Wise2_replace_is_hmmls_PfamHmmer1Entry * Wise2_access_is_hmmls_PfamHmmer1Entry * Wise2_replace_bits_cutoff_PfamHmmer1Entry * Wise2_access_bits_cutoff_PfamHmmer1Entry * Wise2_free_PfamHmmer1Entry [destructor] * */ /* API for object PfamHmmer1DB */ /* Function: Wise2_hard_link_PfamHmmer1DB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_PfamHmmer1DB *] * * Returns Undocumented return value [Wise2_PfamHmmer1DB *] * */ Wise2_PfamHmmer1DB * Wise2_hard_link_PfamHmmer1DB( Wise2_PfamHmmer1DB * obj); /* Function: Wise2_PfamHmmer1DB_alloc_std(void) * * Descrip: Equivalent to PfamHmmer1DB_alloc_len(PfamHmmer1DBLISTLENGTH) * * * * Returns Undocumented return value [Wise2_PfamHmmer1DB *] * */ Wise2_PfamHmmer1DB * Wise2_PfamHmmer1DB_alloc_std(); /* Function: Wise2_access_en_PfamHmmer1DB(obj,i) * * Descrip: Access members stored in the en list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_PfamHmmer1DB *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_PfamHmmer1Entry *] * */ Wise2_PfamHmmer1Entry * Wise2_access_en_PfamHmmer1DB( Wise2_PfamHmmer1DB * obj,int i); /* Function: Wise2_length_en_PfamHmmer1DB(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_PfamHmmer1DB *] * * Returns length of the list [int] * */ int Wise2_length_en_PfamHmmer1DB( Wise2_PfamHmmer1DB * obj); /* Function: Wise2_flush_PfamHmmer1DB(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_PfamHmmer1DB *] * * Returns Undocumented return value [int] * */ int Wise2_flush_PfamHmmer1DB( Wise2_PfamHmmer1DB * obj); /* Function: Wise2_add_PfamHmmer1DB(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_PfamHmmer1DB *] * Arg: add Object to add to the list [Wise2_PfamHmmer1Entry *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_PfamHmmer1DB( Wise2_PfamHmmer1DB * obj,Wise2_PfamHmmer1Entry * add); /* Function: Wise2_replace_dirname_PfamHmmer1DB(obj,dirname) * * Descrip: Replace member variable dirname * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1DB *] * Arg: dirname New value of the variable [char *] * * Returns member variable dirname [boolean] * */ boolean Wise2_replace_dirname_PfamHmmer1DB( Wise2_PfamHmmer1DB * obj,char * dirname); /* Function: Wise2_access_dirname_PfamHmmer1DB(obj) * * Descrip: Access member variable dirname * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1DB *] * * Returns member variable dirname [char *] * */ char * Wise2_access_dirname_PfamHmmer1DB( Wise2_PfamHmmer1DB * obj); /* Function: Wise2_replace_cur_PfamHmmer1DB(obj,cur) * * Descrip: Replace member variable cur * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1DB *] * Arg: cur New value of the variable [int] * * Returns member variable cur [boolean] * */ boolean Wise2_replace_cur_PfamHmmer1DB( Wise2_PfamHmmer1DB * obj,int cur); /* Function: Wise2_access_cur_PfamHmmer1DB(obj) * * Descrip: Access member variable cur * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1DB *] * * Returns member variable cur [int] * */ int Wise2_access_cur_PfamHmmer1DB( Wise2_PfamHmmer1DB * obj); /* Function: Wise2_replace_def_PfamHmmer1DB(obj,def) * * Descrip: Replace member variable def * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1DB *] * Arg: def New value of the variable [Wise2_RandomModel *] * * Returns member variable def [boolean] * */ boolean Wise2_replace_def_PfamHmmer1DB( Wise2_PfamHmmer1DB * obj,Wise2_RandomModel * def); /* Function: Wise2_access_def_PfamHmmer1DB(obj) * * Descrip: Access member variable def * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1DB *] * * Returns member variable def [Wise2_RandomModel *] * */ Wise2_RandomModel * Wise2_access_def_PfamHmmer1DB( Wise2_PfamHmmer1DB * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_PfamHmmer1DB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_PfamHmmer1DB *] * * Returns Undocumented return value [Wise2_PfamHmmer1DB *] * */ Wise2_PfamHmmer1DB * Wise2_free_PfamHmmer1DB( Wise2_PfamHmmer1DB * obj); /* API for object PfamHmmer1Entry */ /* Function: Wise2_hard_link_PfamHmmer1Entry(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_PfamHmmer1Entry *] * * Returns Undocumented return value [Wise2_PfamHmmer1Entry *] * */ Wise2_PfamHmmer1Entry * Wise2_hard_link_PfamHmmer1Entry( Wise2_PfamHmmer1Entry * obj); /* Function: Wise2_PfamHmmer1Entry_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_PfamHmmer1Entry *] * */ Wise2_PfamHmmer1Entry * Wise2_PfamHmmer1Entry_alloc(); /* Function: Wise2_replace_entryname_PfamHmmer1Entry(obj,entryname) * * Descrip: Replace member variable entryname * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1Entry *] * Arg: entryname New value of the variable [char *] * * Returns member variable entryname [boolean] * */ boolean Wise2_replace_entryname_PfamHmmer1Entry( Wise2_PfamHmmer1Entry * obj,char * entryname); /* Function: Wise2_access_entryname_PfamHmmer1Entry(obj) * * Descrip: Access member variable entryname * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1Entry *] * * Returns member variable entryname [char *] * */ char * Wise2_access_entryname_PfamHmmer1Entry( Wise2_PfamHmmer1Entry * obj); /* Function: Wise2_replace_is_random_PfamHmmer1Entry(obj,is_random) * * Descrip: Replace member variable is_random * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1Entry *] * Arg: is_random New value of the variable [boolean] * * Returns member variable is_random [boolean] * */ boolean Wise2_replace_is_random_PfamHmmer1Entry( Wise2_PfamHmmer1Entry * obj,boolean is_random); /* Function: Wise2_access_is_random_PfamHmmer1Entry(obj) * * Descrip: Access member variable is_random * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1Entry *] * * Returns member variable is_random [boolean] * */ boolean Wise2_access_is_random_PfamHmmer1Entry( Wise2_PfamHmmer1Entry * obj); /* Function: Wise2_replace_is_hmmls_PfamHmmer1Entry(obj,is_hmmls) * * Descrip: Replace member variable is_hmmls * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1Entry *] * Arg: is_hmmls New value of the variable [boolean] * * Returns member variable is_hmmls [boolean] * */ boolean Wise2_replace_is_hmmls_PfamHmmer1Entry( Wise2_PfamHmmer1Entry * obj,boolean is_hmmls); /* Function: Wise2_access_is_hmmls_PfamHmmer1Entry(obj) * * Descrip: Access member variable is_hmmls * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1Entry *] * * Returns member variable is_hmmls [boolean] * */ boolean Wise2_access_is_hmmls_PfamHmmer1Entry( Wise2_PfamHmmer1Entry * obj); /* Function: Wise2_replace_bits_cutoff_PfamHmmer1Entry(obj,bits_cutoff) * * Descrip: Replace member variable bits_cutoff * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1Entry *] * Arg: bits_cutoff New value of the variable [double] * * Returns member variable bits_cutoff [boolean] * */ boolean Wise2_replace_bits_cutoff_PfamHmmer1Entry( Wise2_PfamHmmer1Entry * obj,double bits_cutoff); /* Function: Wise2_access_bits_cutoff_PfamHmmer1Entry(obj) * * Descrip: Access member variable bits_cutoff * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PfamHmmer1Entry *] * * Returns member variable bits_cutoff [double] * */ double Wise2_access_bits_cutoff_PfamHmmer1Entry( Wise2_PfamHmmer1Entry * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_PfamHmmer1Entry(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_PfamHmmer1Entry *] * * Returns Undocumented return value [Wise2_PfamHmmer1Entry *] * */ Wise2_PfamHmmer1Entry * Wise2_free_PfamHmmer1Entry( Wise2_PfamHmmer1Entry * obj); wise-2.4.1/src/models/pfamhmmer1db_api.t0000644000175000001440000000016410670453714017514 0ustar philippuserstypedef struct Wise2_PfamHmmer1DB Wise2_PfamHmmer1DB; typedef struct Wise2_PfamHmmer1Entry Wise2_PfamHmmer1Entry; wise-2.4.1/src/models/fivestate.c0000644000175000001440000066307310670453713016306 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "fivestate.h" # line 5 "fivestate.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define OUTBOUND 3 #define INBOUND 4 #define START 0 #define END 1 #define FiveStateProtein_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*5)+STATE][i+1] #define FiveStateProtein_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define FiveStateProtein_READ_OFF_ERROR -3 #define FiveStateProtein_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*5)+STATE] #define FiveStateProtein_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define FiveStateProtein_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define FiveStateProtein_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_FiveStateProtein(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_FiveStateProtein(FiveStateProtein * mat) { FiveStateProtein_access_func_holder holder; holder.access_main = FiveStateProtein_shatter_access_main; holder.access_special = FiveStateProtein_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_FiveStateProtein(mat,holder); } /* Function: FiveStateProtein_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int FiveStateProtein_shatter_access_main(FiveStateProtein * mat,int i,int j,int state) { return FiveStateProtein_SHATTER_MATRIX(mat,i,j,state); } /* Function: FiveStateProtein_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int FiveStateProtein_shatter_access_special(FiveStateProtein * mat,int i,int j,int state) { return FiveStateProtein_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_FiveStateProtein(mat,dpenv) * * Descrip: This function calculates the FiveStateProtein matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [FiveStateProtein *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_FiveStateProtein(FiveStateProtein * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,5,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("FiveStateProtein Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_1[MATCH] + mat->query->unit[i]->transition[FSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = SIG_1_1[INSERT] + mat->query->unit[i]->transition[FSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_1[DELETE] + mat->query->unit[i]->transition[FSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = FiveStateProtein_SHATTER_SPECIAL(mat,i-1,j-1,START) + mat->query->unit[i]->transition[FSM_START2MATCH]; if( temp > score ) { score = temp; } /* From state INBOUND to state MATCH */ temp = SIG_1_1[INBOUND] + mat->query->unit[i]->transition[FSM_INBOUND2MATCH]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state MATCH */ temp = SIG_1_1[OUTBOUND] + mat->query->unit[i]->transition[FSM_OUTBOUND2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_MATCH2END]) + (0) ; if( temp > FiveStateProtein_SHATTER_SPECIAL(mat,i,j,END) ) { FiveStateProtein_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_1[MATCH] + mat->query->unit[i]->transition[FSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->query->unit[i]->transition[FSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_1[DELETE] + mat->query->unit[i]->transition[FSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = FiveStateProtein_SHATTER_SPECIAL(mat,i-0,j-1,START) + mat->query->unit[i]->transition[FSM_START2INSERT]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state INSERT */ temp = SIG_0_1[OUTBOUND] + mat->query->unit[i]->transition[FSM_OUTBOUND2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; SIG_0_0[INSERT] = score; /* state INSERT is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_INSERT2END]) + (0) ; if( temp > FiveStateProtein_SHATTER_SPECIAL(mat,i,j,END) ) { FiveStateProtein_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->unit[i]->transition[FSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->unit[i]->transition[FSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->unit[i]->transition[FSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = FiveStateProtein_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->transition[FSM_START2DELETE]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state DELETE */ temp = SIG_1_0[OUTBOUND] + mat->query->unit[i]->transition[FSM_OUTBOUND2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_DELETE2END]) + (0) ; if( temp > FiveStateProtein_SHATTER_SPECIAL(mat,i,j,END) ) { FiveStateProtein_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state OUTBOUND */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->unit[i]->transition[FSM_MATCH2OUTBOUND]; /* From state INSERT to state OUTBOUND */ temp = SIG_1_0[INSERT] + mat->query->unit[i]->transition[FSM_INSERT2OUTBOUND]; if( temp > score ) { score = temp; } /* From state DELETE to state OUTBOUND */ temp = SIG_1_0[DELETE] + mat->query->unit[i]->transition[FSM_DELETE2OUTBOUND]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state OUTBOUND */ temp = SIG_1_0[OUTBOUND] + mat->query->unit[i]->transition[FSM_OUTBOUND2OUTBOUND]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for OUTBOUND */ /* Add any movement independant score and put away */ SIG_0_0[OUTBOUND] = score; /* state OUTBOUND is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_OUTBOUND2END]) + (0) ; if( temp > FiveStateProtein_SHATTER_SPECIAL(mat,i,j,END) ) { FiveStateProtein_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state OUTBOUND */ /* For state INBOUND */ /* setting first movement to score */ score = SIG_1_0[INBOUND] + mat->query->unit[i]->transition[FSM_INBOUND2INBOUND]; /* From state OUTBOUND to state INBOUND */ temp = SIG_1_0[OUTBOUND] + mat->query->unit[i]->transition[FSM_OUTBOUND2INBOUND]; if( temp > score ) { score = temp; } /* From state START to state INBOUND */ temp = FiveStateProtein_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->transition[FSM_START2INBOUND]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INBOUND */ /* Add any movement independant score and put away */ SIG_0_0[INBOUND] = score; /* state INBOUND is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_INBOUND2END]) + (0) ; if( temp > FiveStateProtein_SHATTER_SPECIAL(mat,i,j,END) ) { FiveStateProtein_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INBOUND */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_FiveStateProtein(dbsi,out,query,targetdb) * * Descrip: This function makes a database search of FiveStateProtein * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [FiveStateScore*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_FiveStateProtein(DBSearchImpl * dbsi,Hscore * out,FiveStateScore* query,ProteinDB* targetdb ) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_FiveStateProtein * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_FiveStateProtein. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_FiveStateProtein. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for FiveStateProtein, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_FiveStateProtein(out,query, targetdb ); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_FiveStateProtein *) ckalloc(sizeof(struct thread_pool_holder_FiveStateProtein)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->query = query; holder->targetdb = targetdb; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_FiveStateProtein,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for FiveStateProtein"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from FiveStateProtein",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_FiveStateProtein(ptr) * * Descrip: dummy loop code foreach thread for FiveStateProtein * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * thread_loop_FiveStateProtein(void * ptr) { fatal("dummy thread loop function"); } /* Function: serial_search_FiveStateProtein(out,query,targetdb) * * Descrip: This function makes a database search of FiveStateProtein * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [FiveStateScore*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_FiveStateProtein(Hscore * out,FiveStateScore* query,ProteinDB* targetdb ) { ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; target = init_ProteinDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching FiveStateProtein, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_FiveStateProtein(query, target ); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("FiveStateProtein search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_ProteinDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_ProteinDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching FiveStateProtein, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break; /* Out of target loop */ target_pos++; } /* end of For all target entries */ close_ProteinDB(target,targetdb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_FiveStateProtein(query,target) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_FiveStateProtein_only * * * Arg: query [UNKN ] query data structure [FiveStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_FiveStateProtein(FiveStateScore* query,ComplexSequence* target ) { int bestscore = NEGI; int i; int j; int k; FiveStateProtein * mat; mat = allocate_FiveStateProtein_only(query, target ); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 5,2,2)) == NULL) { warn("Score only matrix for FiveStateProtein cannot be allocated, (asking for 1 by %d cells)",mat->leni*5); mat = free_FiveStateProtein(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<5;k++) FiveStateProtein_VSMALL_MATRIX(mat,i,j,k) = NEGI; } FiveStateProtein_VSMALL_SPECIAL(mat,i,j,START) = 0; FiveStateProtein_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = FiveStateProtein_VSMALL_SPECIAL(mat,i-1,j-1,START) + mat->query->unit[i]->transition[FSM_START2MATCH]; if( temp > score ) { score = temp; } /* From state INBOUND to state MATCH */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-1,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2MATCH]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state MATCH */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_MATCH2END]) + (0) ; if( temp > FiveStateProtein_VSMALL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = FiveStateProtein_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = FiveStateProtein_VSMALL_SPECIAL(mat,i-0,j-1,START) + mat->query->unit[i]->transition[FSM_START2INSERT]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state INSERT */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-0,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_INSERT2END]) + (0) ; if( temp > FiveStateProtein_VSMALL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = FiveStateProtein_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->transition[FSM_START2DELETE]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state DELETE */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ FiveStateProtein_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_DELETE2END]) + (0) ; if( temp > FiveStateProtein_VSMALL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state OUTBOUND */ /* setting first movement to score */ score = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2OUTBOUND]; /* From state INSERT to state OUTBOUND */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2OUTBOUND]; if( temp > score ) { score = temp; } /* From state DELETE to state OUTBOUND */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2OUTBOUND]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state OUTBOUND */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2OUTBOUND]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for OUTBOUND */ /* Add any movement independant score and put away */ FiveStateProtein_VSMALL_MATRIX(mat,i,j,OUTBOUND) = score; /* state OUTBOUND is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_OUTBOUND2END]) + (0) ; if( temp > FiveStateProtein_VSMALL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state OUTBOUND */ /* For state INBOUND */ /* setting first movement to score */ score = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-0,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2INBOUND]; /* From state OUTBOUND to state INBOUND */ temp = FiveStateProtein_VSMALL_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INBOUND]; if( temp > score ) { score = temp; } /* From state START to state INBOUND */ temp = FiveStateProtein_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->transition[FSM_START2INBOUND]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INBOUND */ /* Add any movement independant score and put away */ FiveStateProtein_VSMALL_MATRIX(mat,i,j,INBOUND) = score; /* state INBOUND is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_INBOUND2END]) + (0) ; if( temp > FiveStateProtein_VSMALL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INBOUND */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < FiveStateProtein_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = FiveStateProtein_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_FiveStateProtein(mat); return bestscore; } /* Function: PackAln_bestmemory_FiveStateProtein(query,target,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_FiveStateProtein * * * Arg: query [UNKN ] query data structure [FiveStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_FiveStateProtein(FiveStateScore* query,ComplexSequence* target ,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; FiveStateProtein * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 5 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_FiveStateProtein(query, target ,dpri)) == NULL ) { warn("Unable to allocate large FiveStateProtein version"); return NULL; } calculate_dpenv_FiveStateProtein(mat,dpenv); out = PackAln_read_Expl_FiveStateProtein(mat); } else { mat = allocate_FiveStateProtein_only(query, target ); calculate_shatter_FiveStateProtein(mat,dpenv); out = PackAln_read_Shatter_FiveStateProtein(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_FiveStateProtein(query, target )) == NULL ) { warn("Unable to allocate small FiveStateProtein version"); return NULL; } out = PackAln_calculate_Small_FiveStateProtein(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_FiveStateProtein(query, target ,dpri)) == NULL ) { warn("Unable to allocate large FiveStateProtein version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_FiveStateProtein(mat); out = PackAln_read_Expl_FiveStateProtein(mat); } } } mat = free_FiveStateProtein(mat); return out; } /* Function: allocate_FiveStateProtein_only(query,target) * * Descrip: This function only allocates the FiveStateProtein structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [FiveStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * * Return [UNKN ] Undocumented return value [FiveStateProtein *] * */ FiveStateProtein * allocate_FiveStateProtein_only(FiveStateScore* query,ComplexSequence* target ) { FiveStateProtein * out; if((out= FiveStateProtein_alloc()) == NULL) { warn("Allocation of basic FiveStateProtein structure failed..."); return NULL; } out->query = query; out->target = target; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_FiveStateProtein(query,target,dpri) * * Descrip: This function allocates the FiveStateProtein structure * and the basematrix area for explicit memory implementations * It calls /allocate_FiveStateProtein_only * * * Arg: query [UNKN ] query data structure [FiveStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [FiveStateProtein *] * */ FiveStateProtein * allocate_Expl_FiveStateProtein(FiveStateScore* query,ComplexSequence* target ,DPRunImpl * dpri) { FiveStateProtein * out; out = allocate_FiveStateProtein_only(query, target ); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*5 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*5,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix FiveStateProtein cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_FiveStateProtein(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_FiveStateProtein(out); return out; } /* Function: init_FiveStateProtein(mat) * * Descrip: This function initates FiveStateProtein matrix when in explicit mode * Called in /allocate_Expl_FiveStateProtein * * * Arg: mat [UNKN ] FiveStateProtein which contains explicit basematrix memory [FiveStateProtein *] * */ void init_FiveStateProtein(FiveStateProtein * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-1);j<2;j++) { FiveStateProtein_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,OUTBOUND) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,INBOUND) = NEGI; } } for(j= (-1);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { FiveStateProtein_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,OUTBOUND) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,INBOUND) = NEGI; } FiveStateProtein_EXPL_SPECIAL(mat,i,j,START) = 0; FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_FiveStateProtein(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by FiveStateProtein * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * */ void recalculate_PackAln_FiveStateProtein(PackAln * pal,FiveStateProtein * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->query->unit[i]->transition[FSM_MATCH2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = mat->query->unit[i]->transition[FSM_INSERT2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 1 && offj == 1 && prev->state == DELETE ) { pau->score = mat->query->unit[i]->transition[FSM_DELETE2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offj == 1 && prev->state == (START+5) ) { pau->score = mat->query->unit[i]->transition[FSM_START2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 1 && offj == 1 && prev->state == INBOUND ) { pau->score = mat->query->unit[i]->transition[FSM_INBOUND2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 1 && offj == 1 && prev->state == OUTBOUND ) { pau->score = mat->query->unit[i]->transition[FSM_OUTBOUND2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = mat->query->unit[i]->transition[FSM_MATCH2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->query->unit[i]->transition[FSM_INSERT2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == DELETE ) { pau->score = mat->query->unit[i]->transition[FSM_DELETE2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offj == 1 && prev->state == (START+5) ) { pau->score = mat->query->unit[i]->transition[FSM_START2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == OUTBOUND ) { pau->score = mat->query->unit[i]->transition[FSM_OUTBOUND2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->unit[i]->transition[FSM_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->unit[i]->transition[FSM_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->unit[i]->transition[FSM_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (START+5) ) { pau->score = mat->query->unit[i]->transition[FSM_START2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == OUTBOUND ) { pau->score = mat->query->unit[i]->transition[FSM_OUTBOUND2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case OUTBOUND : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->unit[i]->transition[FSM_MATCH2OUTBOUND] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->unit[i]->transition[FSM_INSERT2OUTBOUND] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->unit[i]->transition[FSM_DELETE2OUTBOUND] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == OUTBOUND ) { pau->score = mat->query->unit[i]->transition[FSM_OUTBOUND2OUTBOUND] + (0); continue; } warn("In recaluclating PackAln with state OUTBOUND, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INBOUND : if( offi == 1 && offj == 0 && prev->state == INBOUND ) { pau->score = mat->query->unit[i]->transition[FSM_INBOUND2INBOUND] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == OUTBOUND ) { pau->score = mat->query->unit[i]->transition[FSM_OUTBOUND2INBOUND] + (0); continue; } if( offj == 0 && prev->state == (START+5) ) { pau->score = mat->query->unit[i]->transition[FSM_START2INBOUND] + (0); continue; } warn("In recaluclating PackAln with state INBOUND, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+5) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+5) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->unit[i]->transition[FSM_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->unit[i]->transition[FSM_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->unit[i]->transition[FSM_DELETE2END] + (0); continue; } if( offj == 0 && prev->state == INBOUND ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->unit[i]->transition[FSM_INBOUND2END] + (0); continue; } if( offj == 0 && prev->state == OUTBOUND ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->unit[i]->transition[FSM_OUTBOUND2END] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define FiveStateProtein_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*5+state]) #define FiveStateProtein_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*5+state]) #define FiveStateProtein_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define FiveStateProtein_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define FiveStateProtein_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*5 + state]) #define FiveStateProtein_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define FiveStateProtein_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 5) + ((i+1) * 5) + (state)]) #define FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 40) + ((i+1) * 40) + (state * 8) + shadow+1]) #define FiveStateProtein_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_FiveStateProtein(query,target) * * Descrip: This function allocates the FiveStateProtein structure * and the basematrix area for a small memory implementations * It calls /allocate_FiveStateProtein_only * * * Arg: query [UNKN ] query data structure [FiveStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * * Return [UNKN ] Undocumented return value [FiveStateProtein *] * */ #define FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) FiveStateProtein * allocate_Small_FiveStateProtein(FiveStateScore* query,ComplexSequence* target ) { FiveStateProtein * out; out = allocate_FiveStateProtein_only(query, target ); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 5,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix FiveStateProtein cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_FiveStateProtein(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_FiveStateProtein(mat,dpenv) * * Descrip: This function calculates an alignment for FiveStateProtein structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_FiveStateProtein * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_FiveStateProtein * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_FiveStateProtein(FiveStateProtein * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for FiveStateProtein due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_FiveStateProtein(mat,dpenv); score = start_end_find_end_FiveStateProtein(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_FiveStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_FiveStateProtein(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == FiveStateProtein_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_FiveStateProtein(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 5; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_FiveStateProtein(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_FiveStateProtein(mat) * * Descrip: This function calculates an alignment for FiveStateProtein structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_FiveStateProtein * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_FiveStateProtein * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_FiveStateProtein * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_FiveStateProtein(FiveStateProtein * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_FiveStateProtein(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_FiveStateProtein(mat); return out; } /* Function: AlnRangeSet_from_FiveStateProtein(mat) * * Descrip: This function reads off a start/end structure * for FiveStateProtein structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_FiveStateProtein * If you have not calculated the matrix use * /AlnRange_calculate_Small_FiveStateProtein * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_FiveStateProtein(FiveStateProtein * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_FiveStateProtein"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_FiveStateProtein(mat,&jpos); state = END; while( (temp = AlnRange_build_FiveStateProtein(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_FiveStateProtein(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_FiveStateProtein * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_FiveStateProtein(FiveStateProtein * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_FiveStateProtein"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_FiveStateProtein(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_FiveStateProtein alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = FiveStateProtein_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_FiveStateProtein(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == FiveStateProtein_READ_OFF_ERROR) { warn("In AlnRange_build_FiveStateProtein alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = FiveStateProtein_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_FiveStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_FiveStateProtein(FiveStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_FiveStateProtein(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == FiveStateProtein_READ_OFF_ERROR) { warn("In FiveStateProtein hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In FiveStateProtein hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In FiveStateProtein hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_FiveStateProtein(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_FiveStateProtein(FiveStateProtein * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = FiveStateProtein_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In FiveStateProtein matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = FiveStateProtein_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->query->unit[i]->transition[FSM_OUTBOUND2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,OUTBOUND) ) { *reti = i - 1; *retj = j - 1; *retstate = OUTBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,OUTBOUND); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,OUTBOUND); } temp = cscore - (mat->query->unit[i]->transition[FSM_INBOUND2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,INBOUND) ) { *reti = i - 1; *retj = j - 1; *retstate = INBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,INBOUND); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,INBOUND); } /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->unit[i]->transition[FSM_DELETE2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,DELETE); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE); } temp = cscore - (mat->query->unit[i]->transition[FSM_INSERT2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->query->unit[i]->transition[FSM_MATCH2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->query->unit[i]->transition[FSM_OUTBOUND2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,OUTBOUND) ) { *reti = i - 0; *retj = j - 1; *retstate = OUTBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,OUTBOUND); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,OUTBOUND); } /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->unit[i]->transition[FSM_DELETE2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,DELETE) ) { *reti = i - 0; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,DELETE); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,DELETE); } temp = cscore - (mat->query->unit[i]->transition[FSM_INSERT2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->query->unit[i]->transition[FSM_MATCH2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->unit[i]->transition[FSM_OUTBOUND2DELETE]) - (0); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,OUTBOUND) ) { *reti = i - 1; *retj = j - 0; *retstate = OUTBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,OUTBOUND); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,OUTBOUND); } /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->unit[i]->transition[FSM_DELETE2DELETE]) - (0); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->unit[i]->transition[FSM_INSERT2DELETE]) - (0); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->unit[i]->transition[FSM_MATCH2DELETE]) - (0); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); case OUTBOUND : temp = cscore - (mat->query->unit[i]->transition[FSM_OUTBOUND2OUTBOUND]) - (0); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,OUTBOUND) ) { *reti = i - 1; *retj = j - 0; *retstate = OUTBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,OUTBOUND); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,OUTBOUND); } temp = cscore - (mat->query->unit[i]->transition[FSM_DELETE2OUTBOUND]) - (0); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->unit[i]->transition[FSM_INSERT2OUTBOUND]) - (0); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->unit[i]->transition[FSM_MATCH2OUTBOUND]) - (0); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INBOUND : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->unit[i]->transition[FSM_OUTBOUND2INBOUND]) - (0); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,OUTBOUND) ) { *reti = i - 1; *retj = j - 0; *retstate = OUTBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,OUTBOUND); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,OUTBOUND); } temp = cscore - (mat->query->unit[i]->transition[FSM_INBOUND2INBOUND]) - (0); if( temp == FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,INBOUND) ) { *reti = i - 1; *retj = j - 0; *retstate = INBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,INBOUND); } return FiveStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,INBOUND); } warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_FiveStateProtein(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_FiveStateProtein(FiveStateProtein * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 5; add_PackAln(out,pau); } max_special_strip_FiveStateProtein(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == FiveStateProtein_READ_OFF_ERROR) { warn("In special strip read FiveStateProtein, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read FiveStateProtein, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 5; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_FiveStateProtein(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_FiveStateProtein(FiveStateProtein * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = FiveStateProtein_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for FiveStateProtein, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In FiveStateProtein matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = FiveStateProtein_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source OUTBOUND is not a special */ /* Source INBOUND is not a special */ /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ default: warn("Major problem (!) - in FiveStateProtein special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_FiveStateProtein(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_FiveStateProtein(FiveStateProtein * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = FiveStateProtein_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In FiveStateProtein matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source OUTBOUND is not a special, should not get here! */ /* Source INBOUND is not a special, should not get here! */ temp = cscore - (mat->query->unit[i]->transition[FSM_START2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == FiveStateProtein_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return FiveStateProtein_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in FiveStateProtein matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source OUTBOUND is not a special, should not get here! */ temp = cscore - (mat->query->unit[i]->transition[FSM_START2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == FiveStateProtein_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return FiveStateProtein_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in FiveStateProtein matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Source OUTBOUND is not a special, should not get here! */ temp = cscore - (mat->query->unit[i]->transition[FSM_START2DELETE]) - (0); if( temp == FiveStateProtein_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return FiveStateProtein_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in FiveStateProtein matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case OUTBOUND : /* Source OUTBOUND is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in FiveStateProtein matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INBOUND : temp = cscore - (mat->query->unit[i]->transition[FSM_START2INBOUND]) - (0); if( temp == FiveStateProtein_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - FiveStateProtein_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return FiveStateProtein_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source OUTBOUND is not a special, should not get here! */ /* Source INBOUND is not a special, should not get here! */ warn("Major problem (!) - in FiveStateProtein matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_FiveStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_FiveStateProtein(FiveStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_FiveStateProtein(mat,starti,startj,stopi,stopj); FiveStateProtein_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ FiveStateProtein_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; FiveStateProtein_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; FiveStateProtein_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; FiveStateProtein_HIDDEN_MATRIX(mat,i,j,OUTBOUND) = NEGI; FiveStateProtein_HIDDEN_MATRIX(mat,i,j,INBOUND) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state INBOUND to state MATCH */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2MATCH]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state MATCH */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = FiveStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state INSERT */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state DELETE */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ FiveStateProtein_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state OUTBOUND */ /* setting first movement to score */ score = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2OUTBOUND]; /* From state INSERT to state OUTBOUND */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2OUTBOUND]; if( temp > score ) { score = temp; } /* From state DELETE to state OUTBOUND */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2OUTBOUND]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state OUTBOUND */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2OUTBOUND]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for OUTBOUND */ /* Add any movement independant score and put away */ FiveStateProtein_HIDDEN_MATRIX(mat,i,j,OUTBOUND) = score; /* Finished calculating state OUTBOUND */ /* For state INBOUND */ /* setting first movement to score */ score = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2INBOUND]; /* From state OUTBOUND to state INBOUND */ temp = FiveStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INBOUND]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INBOUND */ /* Add any movement independant score and put away */ FiveStateProtein_HIDDEN_MATRIX(mat,i,j,INBOUND) = score; /* Finished calculating state INBOUND */ } } return; } /* Function: init_hidden_FiveStateProtein(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_FiveStateProtein(FiveStateProtein * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { FiveStateProtein_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; FiveStateProtein_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; FiveStateProtein_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; FiveStateProtein_HIDDEN_MATRIX(mat,i,j,OUTBOUND) = NEGI; FiveStateProtein_HIDDEN_MATRIX(mat,i,j,INBOUND) = NEGI; } } return; } /* Function: full_dc_FiveStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_FiveStateProtein * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_FiveStateProtein to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [FiveStateProtein *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_FiveStateProtein(FiveStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_FiveStateProtein"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_FiveStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_FiveStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_FiveStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for FiveStateProtein, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_FiveStateProtein(mat,FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_FiveStateProtein(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_FiveStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_FiveStateProtein(FiveStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_FiveStateProtein(mat); FiveStateProtein_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_FiveStateProtein(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_FiveStateProtein(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_FiveStateProtein(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_FiveStateProtein(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_FiveStateProtein(FiveStateProtein * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,OUTBOUND) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,0) = (-100); FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,1) = (-100); FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INBOUND) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,0) = (-100); FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2MATCH]; if( j - 1 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2MATCH]; if( temp > score) { score = temp; if( j - 1 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2MATCH]; if( temp > score) { score = temp; if( j - 1 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2MATCH]; if( temp > score) { score = temp; if( j - 1 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INBOUND; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INBOUND,k); } } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2MATCH]; if( temp > score) { score = temp; if( j - 1 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = OUTBOUND; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,OUTBOUND,k); } } /* Add any movement independant score */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2INSERT]; if( j - 1 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2INSERT]; if( temp > score) { score = temp; if( j - 1 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2INSERT]; if( temp > score) { score = temp; if( j - 1 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,k); } } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INSERT]; if( temp > score) { score = temp; if( j - 1 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = OUTBOUND; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,OUTBOUND,k); } } /* Add any movement independant score */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2DELETE]; if( j - 0 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = OUTBOUND; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,OUTBOUND,k); } } /* Add any movement independant score */ FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ /* For state OUTBOUND, pushing when j - offj <= mergej */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2OUTBOUND]; if( j - 0 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,1) = j-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,2) = MATCH; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,5) = OUTBOUND; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2OUTBOUND]; if( temp > score) { score = temp; if( j - 0 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,1) = j-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,2) = INSERT; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,5) = OUTBOUND; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2OUTBOUND]; if( temp > score) { score = temp; if( j - 0 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,1) = j-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,2) = DELETE; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,5) = OUTBOUND; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2OUTBOUND]; if( temp > score) { score = temp; if( j - 0 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,1) = j-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,2) = OUTBOUND; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,5) = OUTBOUND; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,OUTBOUND,k); } } /* Add any movement independant score */ FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,OUTBOUND) = score; /* Finished with state OUTBOUND */ /* For state INBOUND, pushing when j - offj <= mergej */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2INBOUND]; if( j - 0 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,1) = j-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,2) = INBOUND; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,5) = INBOUND; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INBOUND,k); } temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INBOUND]; if( temp > score) { score = temp; if( j - 0 <= mergej) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,0) = i-1; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,1) = j-0; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,2) = OUTBOUND; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,3) = i; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,4) = j; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,5) = INBOUND; } else { for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,k) = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,OUTBOUND,k); } } /* Add any movement independant score */ FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INBOUND) = score; /* Finished with state INBOUND */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_FiveStateProtein(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_FiveStateProtein(FiveStateProtein * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,OUTBOUND) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INBOUND) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2MATCH]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); /* From state INSERT to state MATCH */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2MATCH]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* From state DELETE to state MATCH */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2MATCH]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } /* From state INBOUND to state MATCH */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2MATCH]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INBOUND,k); } /* From state OUTBOUND to state MATCH */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2MATCH]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,OUTBOUND,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2INSERT]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); /* From state INSERT to state INSERT */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2INSERT]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* From state DELETE to state INSERT */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2INSERT]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,k); } /* From state OUTBOUND to state INSERT */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INSERT]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,OUTBOUND,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* From state OUTBOUND to state DELETE */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,OUTBOUND,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state OUTBOUND */ /* setting first movement to score */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2OUTBOUND]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state OUTBOUND */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2OUTBOUND]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state OUTBOUND */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2OUTBOUND]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* From state OUTBOUND to state OUTBOUND */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2OUTBOUND]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,OUTBOUND,k); } /* Ok - finished max calculation for OUTBOUND */ /* Add any movement independant score and put away */ FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,OUTBOUND) = score; for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state OUTBOUND */ /* For state INBOUND */ /* setting first movement to score */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2INBOUND]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INBOUND,k); /* From state OUTBOUND to state INBOUND */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INBOUND]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,OUTBOUND,k); } /* Ok - finished max calculation for INBOUND */ /* Add any movement independant score and put away */ FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INBOUND) = score; for(k=0;k<7;k++) FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INBOUND */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_FiveStateProtein(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_FiveStateProtein(FiveStateProtein * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,OUTBOUND) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INBOUND) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state INBOUND to state MATCH */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2MATCH]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state MATCH */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state INSERT */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state DELETE */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state OUTBOUND */ /* setting first movement to score */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2OUTBOUND]; /* From state INSERT to state OUTBOUND */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2OUTBOUND]; if( temp > score ) { score = temp; } /* From state DELETE to state OUTBOUND */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2OUTBOUND]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state OUTBOUND */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2OUTBOUND]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for OUTBOUND */ /* Add any movement independant score and put away */ FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,OUTBOUND) = score; /* Finished calculating state OUTBOUND */ /* For state INBOUND */ /* setting first movement to score */ score = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2INBOUND]; /* From state OUTBOUND to state INBOUND */ temp = FiveStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INBOUND]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INBOUND */ /* Add any movement independant score and put away */ FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INBOUND) = score; /* Finished calculating state INBOUND */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_FiveStateProtein(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * */ } void init_dc_FiveStateProtein(FiveStateProtein * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iquery->len;i++) { FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,OUTBOUND) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INBOUND) = NEGI; for(k=0;k<7;k++) { FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,k) = (-1); FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,k) = (-1); } } } return; } /* Function: start_end_find_end_FiveStateProtein(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [FiveStateProtein *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_FiveStateProtein(FiveStateProtein * mat,int * endj) { register int j; register int max; register int maxj; max = FiveStateProtein_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( FiveStateProtein_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = FiveStateProtein_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_FiveStateProtein(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [FiveStateProtein] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_FiveStateProtein(FiveStateProtein *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 5,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 5 * 8,sizeof(int)); for(j=0;jquery->unit[i]->transition[FSM_MATCH2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); /* From state INSERT to state MATCH */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2MATCH] +(mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* From state DELETE to state MATCH */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2MATCH] +(mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,0)); } /* From state START to state MATCH */ temp = FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + mat->query->unit[i]->transition[FSM_START2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INBOUND to state MATCH */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2MATCH] +(mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INBOUND,0)); } /* From state OUTBOUND to state MATCH */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2MATCH] +(mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,OUTBOUND,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_MATCH2END]) + (0) ; if( temp > FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); /* From state INSERT to state INSERT */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2INSERT] +(mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* From state DELETE to state INSERT */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2INSERT] +(mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,0)); } /* From state START to state INSERT */ temp = FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,START) + mat->query->unit[i]->transition[FSM_START2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* This state [START] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state OUTBOUND to state INSERT */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INSERT] +(mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,OUTBOUND,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_INSERT2END]) + (0) ; if( temp > FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state START to state DELETE */ temp = FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->transition[FSM_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state OUTBOUND to state DELETE */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,OUTBOUND,0)); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_DELETE2END]) + (0) ; if( temp > FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = DELETE; } /* Finished calculating state DELETE */ /* For state OUTBOUND */ /* setting first movement to score */ score = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2OUTBOUND] + (0); /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state OUTBOUND */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2OUTBOUND] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state OUTBOUND */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2OUTBOUND] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state OUTBOUND to state OUTBOUND */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2OUTBOUND] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,OUTBOUND,0)); } /* Ok - finished max calculation for OUTBOUND */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i,j,OUTBOUND) = score; for(k=0;k<7;k++) FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state OUTBOUND is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_OUTBOUND2END]) + (0) ; if( temp > FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,k); FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,6); FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = OUTBOUND; } /* Finished calculating state OUTBOUND */ /* For state INBOUND */ /* setting first movement to score */ score = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2INBOUND] + (0); /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INBOUND,0)); /* From state OUTBOUND to state INBOUND */ temp = FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INBOUND] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,OUTBOUND,0)); } /* From state START to state INBOUND */ temp = FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->transition[FSM_START2INBOUND] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for INBOUND... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INBOUND; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for INBOUND */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ FiveStateProtein_DC_OPT_SHADOW_MATRIX(mat,i,j,INBOUND) = score; for(k=0;k<7;k++) FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INBOUND,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INBOUND is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_INBOUND2END]) + (0) ; if( temp > FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { FiveStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INBOUND,k); FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = FiveStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INBOUND,6); FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; FiveStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = INBOUND; } /* Finished calculating state INBOUND */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_FiveStateProtein(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * */ void init_start_end_linear_FiveStateProtein(FiveStateProtein * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iquery->len;i++) { FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,OUTBOUND) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,OUTBOUND,0) = (-1); FiveStateProtein_DC_SHADOW_MATRIX(mat,i,j,INBOUND) = NEGI; FiveStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INBOUND,0) = (-1); } } for(j=(-1);jtarget->seq->len;j++) { FiveStateProtein_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; FiveStateProtein_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; FiveStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_FiveStateProtein(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_FiveStateProtein(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_FiveStateProtein(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "SEQUENCE","INSERT","OUTBOUND_STATE","INBOUND_STATE","END" }; /* Function: AlnConvertSet_FiveStateProtein(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "SEQUENCE","INSERT","END" }; AlnConvertSet * AlnConvertSet_FiveStateProtein(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 5; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INBOUND; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = OUTBOUND; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 5; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = OUTBOUND; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 5; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = OUTBOUND; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = OUTBOUND; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = OUTBOUND; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = OUTBOUND; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = OUTBOUND; acu->state2 = OUTBOUND; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INBOUND; acu->state2 = INBOUND; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = OUTBOUND; acu->state2 = INBOUND; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 5; acu->is_from_special = TRUE; acu->state2 = INBOUND; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 5; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = END + 5; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = END + 5; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INBOUND; acu->state2 = END + 5; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = OUTBOUND; acu->state2 = END + 5; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[2]; return out; } /* Function: PackAln_read_Expl_FiveStateProtein(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_FiveStateProtein(FiveStateProtein * mat) { FiveStateProtein_access_func_holder holder; holder.access_main = FiveStateProtein_explicit_access_main; holder.access_special = FiveStateProtein_explicit_access_special; return PackAln_read_generic_FiveStateProtein(mat,holder); } /* Function: FiveStateProtein_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int FiveStateProtein_explicit_access_main(FiveStateProtein * mat,int i,int j,int state) { return FiveStateProtein_EXPL_MATRIX(mat,i,j,state); } /* Function: FiveStateProtein_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int FiveStateProtein_explicit_access_special(FiveStateProtein * mat,int i,int j,int state) { return FiveStateProtein_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_FiveStateProtein(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: h [UNKN ] Undocumented argument [FiveStateProtein_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_FiveStateProtein(FiveStateProtein * mat,FiveStateProtein_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_FiveStateProtein(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in FiveStateProtein_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 5; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_FiveStateProtein(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_FiveStateProtein(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == FiveStateProtein_READ_OFF_ERROR || j == FiveStateProtein_READ_OFF_ERROR || state == FiveStateProtein_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in FiveStateProtein_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 5; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_FiveStateProtein(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [FiveStateProtein_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_FiveStateProtein(FiveStateProtein * mat,int * ri,int * rj,int * state,boolean * isspecial,FiveStateProtein_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: FiveStateProtein_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void FiveStateProtein_debug_show_matrix(FiveStateProtein * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",FiveStateProtein_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",FiveStateProtein_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",FiveStateProtein_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"State OUTBOUND %d\n",FiveStateProtein_EXPL_MATRIX(mat,i,j,OUTBOUND)); fprintf(ofp,"State INBOUND %d\n",FiveStateProtein_EXPL_MATRIX(mat,i,j,INBOUND)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_FiveStateProtein(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [FiveStateProtein_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_FiveStateProtein(FiveStateProtein * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,FiveStateProtein_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = FiveStateProtein_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In FiveStateProtein matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->query->unit[i]->transition[FSM_OUTBOUND2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 1,j - 1,OUTBOUND) ) { *reti = i - 1; *retj = j - 1; *retstate = OUTBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,OUTBOUND); } return (*h.access_main)(mat,i - 1,j - 1,OUTBOUND); } temp = cscore - (mat->query->unit[i]->transition[FSM_INBOUND2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 1,j - 1,INBOUND) ) { *reti = i - 1; *retj = j - 1; *retstate = INBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INBOUND); } return (*h.access_main)(mat,i - 1,j - 1,INBOUND); } temp = cscore - (mat->query->unit[i]->transition[FSM_START2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (mat->query->unit[i]->transition[FSM_DELETE2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,DELETE); } return (*h.access_main)(mat,i - 1,j - 1,DELETE); } temp = cscore - (mat->query->unit[i]->transition[FSM_INSERT2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->query->unit[i]->transition[FSM_MATCH2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->query->unit[i]->transition[FSM_OUTBOUND2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,OUTBOUND) ) { *reti = i - 0; *retj = j - 1; *retstate = OUTBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,OUTBOUND); } return (*h.access_main)(mat,i - 0,j - 1,OUTBOUND); } temp = cscore - (mat->query->unit[i]->transition[FSM_START2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_main)(mat,i - 0,j - 1,START); } temp = cscore - (mat->query->unit[i]->transition[FSM_DELETE2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,DELETE) ) { *reti = i - 0; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,DELETE); } return (*h.access_main)(mat,i - 0,j - 1,DELETE); } temp = cscore - (mat->query->unit[i]->transition[FSM_INSERT2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->query->unit[i]->transition[FSM_MATCH2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->unit[i]->transition[FSM_OUTBOUND2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,OUTBOUND) ) { *reti = i - 1; *retj = j - 0; *retstate = OUTBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,OUTBOUND); } return (*h.access_main)(mat,i - 1,j - 0,OUTBOUND); } temp = cscore - (mat->query->unit[i]->transition[FSM_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } temp = cscore - (mat->query->unit[i]->transition[FSM_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->unit[i]->transition[FSM_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->unit[i]->transition[FSM_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); case OUTBOUND : temp = cscore - (mat->query->unit[i]->transition[FSM_OUTBOUND2OUTBOUND]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,OUTBOUND) ) { *reti = i - 1; *retj = j - 0; *retstate = OUTBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,OUTBOUND); } return (*h.access_main)(mat,i - 1,j - 0,OUTBOUND); } temp = cscore - (mat->query->unit[i]->transition[FSM_DELETE2OUTBOUND]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->unit[i]->transition[FSM_INSERT2OUTBOUND]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->unit[i]->transition[FSM_MATCH2OUTBOUND]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INBOUND : temp = cscore - (mat->query->unit[i]->transition[FSM_START2INBOUND]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } temp = cscore - (mat->query->unit[i]->transition[FSM_OUTBOUND2INBOUND]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,OUTBOUND) ) { *reti = i - 1; *retj = j - 0; *retstate = OUTBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,OUTBOUND); } return (*h.access_main)(mat,i - 1,j - 0,OUTBOUND); } temp = cscore - (mat->query->unit[i]->transition[FSM_INBOUND2INBOUND]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INBOUND) ) { *reti = i - 1; *retj = j - 0; *retstate = INBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INBOUND); } return (*h.access_main)(mat,i - 1,j - 0,INBOUND); } warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_FiveStateProtein(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [FiveStateProtein_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_FiveStateProtein(FiveStateProtein * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,FiveStateProtein_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = FiveStateProtein_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In FiveStateProtein matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source OUTBOUND is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->unit[i]->transition[FSM_OUTBOUND2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,OUTBOUND) ) { *reti = i - 0; *retj = j - 0; *retstate = OUTBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,OUTBOUND); } return (*h.access_main)(mat,i - 0,j - 0,OUTBOUND) ; } } /* end of for i >= 0 */ /* source INBOUND is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->unit[i]->transition[FSM_INBOUND2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INBOUND) ) { *reti = i - 0; *retj = j - 0; *retstate = INBOUND; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INBOUND); } return (*h.access_main)(mat,i - 0,j - 0,INBOUND) ; } } /* end of for i >= 0 */ /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->unit[i]->transition[FSM_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->unit[i]->transition[FSM_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->unit[i]->transition[FSM_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in FiveStateProtein read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_FiveStateProtein(mat) * * Descrip: This function calculates the FiveStateProtein matrix when in explicit mode * To allocate the matrix use /allocate_Expl_FiveStateProtein * * * Arg: mat [UNKN ] FiveStateProtein which contains explicit basematrix memory [FiveStateProtein *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_FiveStateProtein(FiveStateProtein * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_FiveStateProtein, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("FiveStateProtein Matrix calculation: "); for(j=0;jquery->unit[i]->transition[FSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = FiveStateProtein_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->query->unit[i]->transition[FSM_START2MATCH]; if( temp > score ) { score = temp; } /* From state INBOUND to state MATCH */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-1,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2MATCH]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state MATCH */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_MATCH2END]) + (0) ; if( temp > FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = FiveStateProtein_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = FiveStateProtein_EXPL_SPECIAL(mat,i-0,j-1,START) + mat->query->unit[i]->transition[FSM_START2INSERT]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state INSERT */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-0,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_INSERT2END]) + (0) ; if( temp > FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = FiveStateProtein_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->transition[FSM_START2DELETE]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state DELETE */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ FiveStateProtein_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_DELETE2END]) + (0) ; if( temp > FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state OUTBOUND */ /* setting first movement to score */ score = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2OUTBOUND]; /* From state INSERT to state OUTBOUND */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2OUTBOUND]; if( temp > score ) { score = temp; } /* From state DELETE to state OUTBOUND */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2OUTBOUND]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state OUTBOUND */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2OUTBOUND]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for OUTBOUND */ /* Add any movement independant score and put away */ FiveStateProtein_EXPL_MATRIX(mat,i,j,OUTBOUND) = score; /* state OUTBOUND is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_OUTBOUND2END]) + (0) ; if( temp > FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state OUTBOUND */ /* For state INBOUND */ /* setting first movement to score */ score = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2INBOUND]; /* From state OUTBOUND to state INBOUND */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INBOUND]; if( temp > score ) { score = temp; } /* From state START to state INBOUND */ temp = FiveStateProtein_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->transition[FSM_START2INBOUND]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INBOUND */ /* Add any movement independant score and put away */ FiveStateProtein_EXPL_MATRIX(mat,i,j,INBOUND) = score; /* state INBOUND is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_INBOUND2END]) + (0) ; if( temp > FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INBOUND */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_FiveStateProtein(mat,dpenv) * * Descrip: This function calculates the FiveStateProtein matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] FiveStateProtein which contains explicit basematrix memory [FiveStateProtein *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_FiveStateProtein(FiveStateProtein * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_FiveStateProtein, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { FiveStateProtein_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,OUTBOUND) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,INBOUND) = NEGI; } } for(j=-1;jlenj;j++) { FiveStateProtein_EXPL_SPECIAL(mat,i,j,START) = 0; FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("FiveStateProtein Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { FiveStateProtein_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,OUTBOUND) = NEGI; FiveStateProtein_EXPL_MATRIX(mat,i,j,INBOUND) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = FiveStateProtein_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->query->unit[i]->transition[FSM_START2MATCH]; if( temp > score ) { score = temp; } /* From state INBOUND to state MATCH */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-1,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2MATCH]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state MATCH */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_MATCH2END]) + (0) ; if( temp > FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = FiveStateProtein_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = FiveStateProtein_EXPL_SPECIAL(mat,i-0,j-1,START) + mat->query->unit[i]->transition[FSM_START2INSERT]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state INSERT */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-0,j-1,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; FiveStateProtein_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_INSERT2END]) + (0) ; if( temp > FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = FiveStateProtein_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->transition[FSM_START2DELETE]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state DELETE */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ FiveStateProtein_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_DELETE2END]) + (0) ; if( temp > FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state OUTBOUND */ /* setting first movement to score */ score = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->transition[FSM_MATCH2OUTBOUND]; /* From state INSERT to state OUTBOUND */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->transition[FSM_INSERT2OUTBOUND]; if( temp > score ) { score = temp; } /* From state DELETE to state OUTBOUND */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->transition[FSM_DELETE2OUTBOUND]; if( temp > score ) { score = temp; } /* From state OUTBOUND to state OUTBOUND */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2OUTBOUND]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for OUTBOUND */ /* Add any movement independant score and put away */ FiveStateProtein_EXPL_MATRIX(mat,i,j,OUTBOUND) = score; /* state OUTBOUND is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_OUTBOUND2END]) + (0) ; if( temp > FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state OUTBOUND */ /* For state INBOUND */ /* setting first movement to score */ score = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,INBOUND) + mat->query->unit[i]->transition[FSM_INBOUND2INBOUND]; /* From state OUTBOUND to state INBOUND */ temp = FiveStateProtein_EXPL_MATRIX(mat,i-1,j-0,OUTBOUND) + mat->query->unit[i]->transition[FSM_OUTBOUND2INBOUND]; if( temp > score ) { score = temp; } /* From state START to state INBOUND */ temp = FiveStateProtein_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->transition[FSM_START2INBOUND]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INBOUND */ /* Add any movement independant score and put away */ FiveStateProtein_EXPL_MATRIX(mat,i,j,INBOUND) = score; /* state INBOUND is a source for special END */ temp = score + (mat->query->unit[i]->transition[FSM_INBOUND2END]) + (0) ; if( temp > FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { FiveStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INBOUND */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: FiveStateProtein_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateProtein *] * */ FiveStateProtein * FiveStateProtein_alloc(void) { FiveStateProtein * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FiveStateProtein *) ckalloc (sizeof(FiveStateProtein))) == NULL) { warn("FiveStateProtein_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_FiveStateProtein(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateProtein *] * * Return [UNKN ] Undocumented return value [FiveStateProtein *] * */ FiveStateProtein * free_FiveStateProtein(FiveStateProtein * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FiveStateProtein obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/fivestate.h0000644000175000001440000004711610670453713016305 0ustar philippusers#ifndef DYNAMITEfivestateHEADERFILE #define DYNAMITEfivestateHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "fivestatemodel.h" struct Wise2_FiveStateProtein { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; FiveStateScore* query; ComplexSequence* target; } ; /* FiveStateProtein defined */ #ifndef DYNAMITE_DEFINED_FiveStateProtein typedef struct Wise2_FiveStateProtein Wise2_FiveStateProtein; #define FiveStateProtein Wise2_FiveStateProtein #define DYNAMITE_DEFINED_FiveStateProtein #endif #ifdef PTHREAD struct thread_pool_holder_FiveStateProtein { FiveStateScore* query; /* Static query data: never free'd */ ComplexSequence* target;/* Target object placeholder */ ProteinDB* targetdb;/* Target database object */ boolean target_init; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_FiveStateProtein_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(FiveStateProtein*,int,int,int); int (*access_special)(FiveStateProtein*,int,int,int); } ; /* FiveStateProtein_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_FiveStateProtein_access_func_holder typedef struct Wise2_FiveStateProtein_access_func_holder Wise2_FiveStateProtein_access_func_holder; #define FiveStateProtein_access_func_holder Wise2_FiveStateProtein_access_func_holder #define DYNAMITE_DEFINED_FiveStateProtein_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_FiveStateProtein(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_FiveStateProtein(FiveStateProtein * mat); #define PackAln_read_Shatter_FiveStateProtein Wise2_PackAln_read_Shatter_FiveStateProtein /* Function: calculate_shatter_FiveStateProtein(mat,dpenv) * * Descrip: This function calculates the FiveStateProtein matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [FiveStateProtein *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_FiveStateProtein(FiveStateProtein * mat,DPEnvelope * dpenv); #define calculate_shatter_FiveStateProtein Wise2_calculate_shatter_FiveStateProtein /* Function: search_FiveStateProtein(dbsi,out,query,targetdb) * * Descrip: This function makes a database search of FiveStateProtein * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [FiveStateScore*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_FiveStateProtein(DBSearchImpl * dbsi,Hscore * out,FiveStateScore* query,ProteinDB* targetdb ); #define search_FiveStateProtein Wise2_search_FiveStateProtein /* Function: serial_search_FiveStateProtein(out,query,targetdb) * * Descrip: This function makes a database search of FiveStateProtein * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [FiveStateScore*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_FiveStateProtein(Hscore * out,FiveStateScore* query,ProteinDB* targetdb ); #define serial_search_FiveStateProtein Wise2_serial_search_FiveStateProtein /* Function: PackAln_bestmemory_FiveStateProtein(query,target,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_FiveStateProtein * * * Arg: query [UNKN ] query data structure [FiveStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_FiveStateProtein(FiveStateScore* query,ComplexSequence* target ,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_FiveStateProtein Wise2_PackAln_bestmemory_FiveStateProtein /* Function: allocate_Expl_FiveStateProtein(query,target,dpri) * * Descrip: This function allocates the FiveStateProtein structure * and the basematrix area for explicit memory implementations * It calls /allocate_FiveStateProtein_only * * * Arg: query [UNKN ] query data structure [FiveStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [FiveStateProtein *] * */ FiveStateProtein * Wise2_allocate_Expl_FiveStateProtein(FiveStateScore* query,ComplexSequence* target ,DPRunImpl * dpri); #define allocate_Expl_FiveStateProtein Wise2_allocate_Expl_FiveStateProtein /* Function: recalculate_PackAln_FiveStateProtein(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by FiveStateProtein * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * */ void Wise2_recalculate_PackAln_FiveStateProtein(PackAln * pal,FiveStateProtein * mat); #define recalculate_PackAln_FiveStateProtein Wise2_recalculate_PackAln_FiveStateProtein /* Function: allocate_Small_FiveStateProtein(query,target) * * Descrip: This function allocates the FiveStateProtein structure * and the basematrix area for a small memory implementations * It calls /allocate_FiveStateProtein_only * * * Arg: query [UNKN ] query data structure [FiveStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * * Return [UNKN ] Undocumented return value [FiveStateProtein *] * */ FiveStateProtein * Wise2_allocate_Small_FiveStateProtein(FiveStateScore* query,ComplexSequence* target ); #define allocate_Small_FiveStateProtein Wise2_allocate_Small_FiveStateProtein /* Function: PackAln_calculate_Small_FiveStateProtein(mat,dpenv) * * Descrip: This function calculates an alignment for FiveStateProtein structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_FiveStateProtein * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_FiveStateProtein * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_FiveStateProtein(FiveStateProtein * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_FiveStateProtein Wise2_PackAln_calculate_Small_FiveStateProtein /* Function: AlnRangeSet_calculate_Small_FiveStateProtein(mat) * * Descrip: This function calculates an alignment for FiveStateProtein structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_FiveStateProtein * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_FiveStateProtein * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_FiveStateProtein * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_FiveStateProtein(FiveStateProtein * mat); #define AlnRangeSet_calculate_Small_FiveStateProtein Wise2_AlnRangeSet_calculate_Small_FiveStateProtein /* Function: AlnRangeSet_from_FiveStateProtein(mat) * * Descrip: This function reads off a start/end structure * for FiveStateProtein structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_FiveStateProtein * If you have not calculated the matrix use * /AlnRange_calculate_Small_FiveStateProtein * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_FiveStateProtein(FiveStateProtein * mat); #define AlnRangeSet_from_FiveStateProtein Wise2_AlnRangeSet_from_FiveStateProtein /* Function: convert_PackAln_to_AlnBlock_FiveStateProtein(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_FiveStateProtein(PackAln * pal); #define convert_PackAln_to_AlnBlock_FiveStateProtein Wise2_convert_PackAln_to_AlnBlock_FiveStateProtein /* Function: PackAln_read_Expl_FiveStateProtein(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_FiveStateProtein(FiveStateProtein * mat); #define PackAln_read_Expl_FiveStateProtein Wise2_PackAln_read_Expl_FiveStateProtein /* Function: PackAln_read_generic_FiveStateProtein(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [FiveStateProtein *] * Arg: h [UNKN ] Undocumented argument [FiveStateProtein_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_FiveStateProtein(FiveStateProtein * mat,FiveStateProtein_access_func_holder h); #define PackAln_read_generic_FiveStateProtein Wise2_PackAln_read_generic_FiveStateProtein /* Function: calculate_FiveStateProtein(mat) * * Descrip: This function calculates the FiveStateProtein matrix when in explicit mode * To allocate the matrix use /allocate_Expl_FiveStateProtein * * * Arg: mat [UNKN ] FiveStateProtein which contains explicit basematrix memory [FiveStateProtein *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_FiveStateProtein(FiveStateProtein * mat); #define calculate_FiveStateProtein Wise2_calculate_FiveStateProtein /* Function: calculate_dpenv_FiveStateProtein(mat,dpenv) * * Descrip: This function calculates the FiveStateProtein matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] FiveStateProtein which contains explicit basematrix memory [FiveStateProtein *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_FiveStateProtein(FiveStateProtein * mat,DPEnvelope * dpenv); #define calculate_dpenv_FiveStateProtein Wise2_calculate_dpenv_FiveStateProtein /* Function: FiveStateProtein_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateProtein *] * */ FiveStateProtein * Wise2_FiveStateProtein_alloc(void); #define FiveStateProtein_alloc Wise2_FiveStateProtein_alloc /* Function: free_FiveStateProtein(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateProtein *] * * Return [UNKN ] Undocumented return value [FiveStateProtein *] * */ FiveStateProtein * Wise2_free_FiveStateProtein(FiveStateProtein * obj); #define free_FiveStateProtein Wise2_free_FiveStateProtein /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_FiveStateProtein_shatter_access_main(FiveStateProtein * mat,int i,int j,int state); #define FiveStateProtein_shatter_access_main Wise2_FiveStateProtein_shatter_access_main int Wise2_FiveStateProtein_shatter_access_special(FiveStateProtein * mat,int i,int j,int state); #define FiveStateProtein_shatter_access_special Wise2_FiveStateProtein_shatter_access_special void * Wise2_thread_loop_FiveStateProtein(void * ptr); #define thread_loop_FiveStateProtein Wise2_thread_loop_FiveStateProtein int Wise2_score_only_FiveStateProtein(FiveStateScore* query,ComplexSequence* target ); #define score_only_FiveStateProtein Wise2_score_only_FiveStateProtein FiveStateProtein * Wise2_allocate_FiveStateProtein_only(FiveStateScore* query,ComplexSequence* target ); #define allocate_FiveStateProtein_only Wise2_allocate_FiveStateProtein_only void Wise2_init_FiveStateProtein(FiveStateProtein * mat); #define init_FiveStateProtein Wise2_init_FiveStateProtein AlnRange * Wise2_AlnRange_build_FiveStateProtein(FiveStateProtein * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_FiveStateProtein Wise2_AlnRange_build_FiveStateProtein boolean Wise2_read_hidden_FiveStateProtein(FiveStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_FiveStateProtein Wise2_read_hidden_FiveStateProtein int Wise2_max_hidden_FiveStateProtein(FiveStateProtein * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_FiveStateProtein Wise2_max_hidden_FiveStateProtein boolean Wise2_read_special_strip_FiveStateProtein(FiveStateProtein * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_FiveStateProtein Wise2_read_special_strip_FiveStateProtein int Wise2_max_special_strip_FiveStateProtein(FiveStateProtein * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_FiveStateProtein Wise2_max_special_strip_FiveStateProtein int Wise2_max_matrix_to_special_FiveStateProtein(FiveStateProtein * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_FiveStateProtein Wise2_max_matrix_to_special_FiveStateProtein void Wise2_calculate_hidden_FiveStateProtein(FiveStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_FiveStateProtein Wise2_calculate_hidden_FiveStateProtein void Wise2_init_hidden_FiveStateProtein(FiveStateProtein * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_FiveStateProtein Wise2_init_hidden_FiveStateProtein boolean Wise2_full_dc_FiveStateProtein(FiveStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_FiveStateProtein Wise2_full_dc_FiveStateProtein boolean Wise2_do_dc_single_pass_FiveStateProtein(FiveStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_FiveStateProtein Wise2_do_dc_single_pass_FiveStateProtein void Wise2_push_dc_at_merge_FiveStateProtein(FiveStateProtein * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_FiveStateProtein Wise2_push_dc_at_merge_FiveStateProtein void Wise2_follow_on_dc_FiveStateProtein(FiveStateProtein * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_FiveStateProtein Wise2_follow_on_dc_FiveStateProtein void Wise2_run_up_dc_FiveStateProtein(FiveStateProtein * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_FiveStateProtein Wise2_run_up_dc_FiveStateProtein void Wise2_init_dc_FiveStateProtein(FiveStateProtein * mat); #define init_dc_FiveStateProtein Wise2_init_dc_FiveStateProtein int Wise2_start_end_find_end_FiveStateProtein(FiveStateProtein * mat,int * endj); #define start_end_find_end_FiveStateProtein Wise2_start_end_find_end_FiveStateProtein boolean Wise2_dc_optimised_start_end_calc_FiveStateProtein(FiveStateProtein *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_FiveStateProtein Wise2_dc_optimised_start_end_calc_FiveStateProtein void Wise2_init_start_end_linear_FiveStateProtein(FiveStateProtein * mat); #define init_start_end_linear_FiveStateProtein Wise2_init_start_end_linear_FiveStateProtein AlnConvertSet * Wise2_AlnConvertSet_FiveStateProtein(void); #define AlnConvertSet_FiveStateProtein Wise2_AlnConvertSet_FiveStateProtein int Wise2_FiveStateProtein_explicit_access_main(FiveStateProtein * mat,int i,int j,int state); #define FiveStateProtein_explicit_access_main Wise2_FiveStateProtein_explicit_access_main int Wise2_FiveStateProtein_explicit_access_special(FiveStateProtein * mat,int i,int j,int state); #define FiveStateProtein_explicit_access_special Wise2_FiveStateProtein_explicit_access_special int Wise2_find_end_FiveStateProtein(FiveStateProtein * mat,int * ri,int * rj,int * state,boolean * isspecial,FiveStateProtein_access_func_holder h); #define find_end_FiveStateProtein Wise2_find_end_FiveStateProtein void Wise2_FiveStateProtein_debug_show_matrix(FiveStateProtein * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define FiveStateProtein_debug_show_matrix Wise2_FiveStateProtein_debug_show_matrix int Wise2_max_calc_FiveStateProtein(FiveStateProtein * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,FiveStateProtein_access_func_holder h); #define max_calc_FiveStateProtein Wise2_max_calc_FiveStateProtein int Wise2_max_calc_special_FiveStateProtein(FiveStateProtein * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,FiveStateProtein_access_func_holder h); #define max_calc_special_FiveStateProtein Wise2_max_calc_special_FiveStateProtein #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/promoterwise.c0000644000175000001440000001373610034317426017040 0ustar philippusers#include "localdba.h" #include "version.h" #include "hsp.h" #include "subseqhash.h" #include "localcishit.h" #include "hitlist.h" #include "pairwiseshortdna.h" char * program_name = "promoterwise"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s query_sequence target_sequence\n",program_name); fprintf(ofp,"Seed restriction\n"); fprintf(ofp," -align [normal/motif] use normal DBA or motif alignment [normal]\n"); fprintf(ofp," -s query start position restriction\n"); fprintf(ofp," -t query end position restriction\n"); fprintf(ofp," -u target start position restriction\n"); fprintf(ofp," -v target end position restriction\n"); show_help_LocalCisHitSetPara(ofp); fprintf(ofp,"Motif Matching and TransFactor matches only for motif alignment\n"); fprintf(ofp," ie, when the -align motif option is used\n"); fprintf(ofp," -lr motif library is in Laurence's format (default is Ewan's)\n"); fprintf(ofp," -ben motif library is in Ben's IUPAC format (default is Ewan's)\n"); fprintf(ofp," -motiflib [filename] motif library file name\n"); show_help_MotifMatrixPara(ofp); show_help_TransFactorBuildPara(ofp); show_help_TransFactorMatchPara(ofp); show_help_HitListOutputImpl(ofp); show_help_DPRunImpl(ofp); show_standard_options(ofp); } #define ALIGN_NORMAL 78 #define ALIGN_MOTIF 79 int main(int argc,char ** argv) { int type = ALIGN_NORMAL; DPRunImpl * dpri = NULL; HitList * hl; HitListOutputImpl * hloi; Sequence * query; Sequence * target; Sequence * target_rev; PairwiseShortDna * two; LocalCisHitSet * set; LocalCisHitSet * greedy_set; LocalCisHitScore * lchs; LocalCisHitSetPara * setpara; MotifMatrixPara * mmp; MotifMatrixScore * mms; TransFactorMatchSet * tfms_query = NULL; TransFactorMatchSet * tfms_target = NULL; TransFactorMatchSet * tfms_target_rev = NULL; int qstart = -1; int qend = -1; int tstart = -1; int tend = -1; int i; char * temp; DnaMatrix * dm; DnaProbMatrix * dmp; TransFactorBuildPara * tfbp; TransFactorMatchPara * tfmp; TransFactorSet * tfs; char * motif_library = NULL; int use_laurence = FALSE; int use_ben = FALSE; dmp = DnaProbMatrix_from_match(0.75,NMaskType_BANNED); assert(dmp); flat_null_DnaProbMatrix(dmp); dm = DnaMatrix_from_DnaProbMatrix(dmp); dpri = new_DPRunImpl_from_argv(&argc,argv); hloi = new_HitListOutputImpl_from_argv(&argc,argv); setpara = new_LocalCisHitSetPara_from_argv(&argc,argv); mmp = new_MotifMatrixPara_from_argv(&argc,argv); tfbp = new_TransFactorBuildPara_from_argv(&argc,argv); tfmp = new_TransFactorMatchPara_from_argv(&argc,argv); strip_out_integer_argument(&argc,argv,"s",&qstart); strip_out_integer_argument(&argc,argv,"t",&qend); strip_out_integer_argument(&argc,argv,"u",&tstart); strip_out_integer_argument(&argc,argv,"v",&tend); temp = strip_out_assigned_argument(&argc,argv,"motiflib"); if( temp != NULL ) { motif_library = stringalloc(temp); } use_laurence = strip_out_boolean_argument(&argc,argv,"lr"); use_ben = strip_out_boolean_argument(&argc,argv,"ben"); temp = strip_out_assigned_argument(&argc,argv,"align"); if( temp != NULL ) { if( strcmp(temp,"motif") == 0 ) { type = ALIGN_MOTIF; } else if ( strcmp(temp,"normal") == 0 ) { type = ALIGN_NORMAL; } else { fatal("cannot recognise string %s as align type",temp); } } strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 3 ) { show_help(stdout); exit(12); } lchs = standard_LocalCisHitScore(NMaskType_VARIABLE); query = read_fasta_file_Sequence(argv[1]); target = read_fasta_file_Sequence(argv[2]); for(i=0;ilen;i++) { query->seq[i] = toupper(query->seq[i]); } assert(query != NULL); assert(target != NULL); target_rev = reverse_complement_Sequence(target); mms = MotifMatrixScore_from_MotifMatrixPara(mmp); if( type == ALIGN_MOTIF ) { if( motif_library == NULL ) { fatal("Wanted to align with motif but not motif library. Must use -motiflib"); } if( use_laurence == TRUE ) { tfs = read_laurence_TransFactorSet_file(motif_library); } else if( use_ben == TRUE ) { tfs = read_ben_IUPAC_TransFactorSet_file(motif_library); } else { tfs = read_TransFactorSet_file(motif_library); } build_TransFactorSet(tfs,tfbp); tfms_query = calculate_TransFactorMatchSet(query,tfs,tfmp); sort_by_start_TransFactorMatchSet(tfms_query); tfms_target = calculate_TransFactorMatchSet(target,tfs,tfmp); sort_by_start_TransFactorMatchSet(tfms_target); tfms_target_rev = calculate_TransFactorMatchSet(target_rev,tfs,tfmp); sort_by_start_TransFactorMatchSet(tfms_target); fprintf(stdout,"Motif Set: %d in query and %d in target\n",tfms_query->len,tfms_target->len); } if( qstart == -1 ) { qstart = 0; } if( qend == -1 ) { qend = query->len; } if( tstart == -1 ) { tstart = 0; } if( tend == -1 ) { tend = target->len; } two = query_to_reverse_target(query,target,dm,qstart,qend,tstart,tend); set = make_LocalCisHitSet(query,target,target_rev,two->forward,two->reverse,setpara,lchs,tfms_query,tfms_target,tfms_target_rev,mms,type == ALIGN_MOTIF ? 1 : 0,dpri); greedy_set = greedy_weed_LocalCisHitSet(set,setpara); hl = HitList_from_LocalCisHitSet(greedy_set); show_HitList_HitListOutputImpl(hloi,hl,stdout); return 0; } wise-2.4.1/src/models/threestatedb.typemap0000644000175000001440000000040210670453715020206 0ustar philippusers TYPEMAP Wise2_ThreeStateDB * T_Wise2_ThreeStateDB INPUT T_Wise2_ThreeStateDB $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_ThreeStateDB *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_ThreeStateDB sv_setref_pv($arg, "Wise2::ThreeStateDB", (void*) $var); wise-2.4.1/src/models/cdnawise10.c0000644000175000001440000111704210670453713016241 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "cdnawise10.h" # line 7 "cdnawise10.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define UTR5 0 #define UTR5_INTRON 1 #define MATCH 2 #define INSERT 3 #define DELETE 4 #define INTRON_0 5 #define INTRON_1 6 #define INTRON_2 7 #define UTR3 8 #define UTR3_INTRON 9 #define START 0 #define END 1 #define CdnaWise10_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+10)*10)+STATE][i+3] #define CdnaWise10_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+10] #define CdnaWise10_READ_OFF_ERROR -14 #define CdnaWise10_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+11)%11][((i+3)*10)+STATE] #define CdnaWise10_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+11)%11][STATE] #define CdnaWise10_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define CdnaWise10_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_CdnaWise10(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_CdnaWise10(CdnaWise10 * mat) { CdnaWise10_access_func_holder holder; holder.access_main = CdnaWise10_shatter_access_main; holder.access_special = CdnaWise10_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_CdnaWise10(mat,holder); } /* Function: CdnaWise10_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int CdnaWise10_shatter_access_main(CdnaWise10 * mat,int i,int j,int state) { return CdnaWise10_SHATTER_MATRIX(mat,i,j,state); } /* Function: CdnaWise10_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int CdnaWise10_shatter_access_special(CdnaWise10 * mat,int i,int j,int state) { return CdnaWise10_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_CdnaWise10(mat,dpenv) * * Descrip: This function calculates the CdnaWise10 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [CdnaWise10 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_CdnaWise10(CdnaWise10 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; int * SIG_3_3; int * SIG_0_6; int * SIG_0_5; int * SIG_0_4; int * SIG_0_3; int * SIG_3_8; int * SIG_0_8; int * SIG_3_9; int * SIG_0_9; int * SIG_3_10; int * SIG_0_10; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,10,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("CdnaWise10 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); SIG_3_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-3,j-3); SIG_0_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-6); SIG_0_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-5); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_3_8 = fetch_cell_from_ShatterMatrix(mat->shatter,i-3,j-8); SIG_0_8 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-8); SIG_3_9 = fetch_cell_from_ShatterMatrix(mat->shatter,i-3,j-9); SIG_0_9 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-9); SIG_3_10 = fetch_cell_from_ShatterMatrix(mat->shatter,i-3,j-10); SIG_0_10 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-10); /* For state UTR5 */ /* setting first movement to score */ score = SIG_1_1[UTR5] + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* From state START to state UTR5 */ temp = CdnaWise10_SHATTER_SPECIAL(mat,i-1,j-1,START) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR5_INTRON to state UTR5 */ temp = SIG_1_1[UTR5_INTRON] + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR5 to state UTR5 */ temp = SIG_0_1[UTR5] + mat->utr_gap; if( temp > score ) { score = temp; } /* From state UTR5 to state UTR5 */ temp = SIG_1_0[UTR5] + mat->utr_gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ SIG_0_0[UTR5] = score; /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = SIG_0_1[UTR5_INTRON] + 0; /* From state UTR5 to state UTR5_INTRON */ temp = SIG_0_1[UTR5] + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ SIG_0_0[UTR5_INTRON] = score; /* Finished calculating state UTR5_INTRON */ /* For state MATCH */ /* setting first movement to score */ score = SIG_3_3[MATCH] + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; /* From state INSERT to state MATCH */ temp = SIG_3_3[INSERT] + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_3_3[DELETE] + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = CdnaWise10_SHATTER_SPECIAL(mat,i-3,j-3,START) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state UTR5 to state MATCH */ temp = SIG_3_3[UTR5] + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = SIG_0_6[INTRON_0] + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = SIG_0_5[INTRON_1] + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = SIG_0_4[INTRON_2] + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > CdnaWise10_SHATTER_SPECIAL(mat,i,j,END) ) { CdnaWise10_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_open); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_ext); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = SIG_0_6[INTRON_0] + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = SIG_0_5[INTRON_1] + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = SIG_0_4[INTRON_2] + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ SIG_0_0[INSERT] = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_open); /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_ext); if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = SIG_3_8[MATCH] + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_0 */ temp = SIG_0_8[INSERT] + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = SIG_0_1[INTRON_0] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_0] = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SIG_3_9[MATCH] + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_1 */ temp = SIG_0_9[INSERT] + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = SIG_0_1[INTRON_1] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_1] = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SIG_3_10[MATCH] + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_2 */ temp = SIG_0_10[INSERT] + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = SIG_0_1[INTRON_2] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_2] = score; /* Finished calculating state INTRON_2 */ /* For state UTR3 */ /* setting first movement to score */ score = SIG_1_1[UTR3] + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* From state UTR3_INTRON to state UTR3 */ temp = SIG_1_1[UTR3_INTRON] + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR3 to state UTR3 */ temp = SIG_0_1[UTR3] + mat->utr_gap; if( temp > score ) { score = temp; } /* From state UTR3 to state UTR3 */ temp = SIG_1_0[UTR3] + mat->utr_gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ SIG_0_0[UTR3] = score; /* state UTR3 is a source for special END */ temp = score + (0) + (0) ; if( temp > CdnaWise10_SHATTER_SPECIAL(mat,i,j,END) ) { CdnaWise10_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = SIG_0_1[UTR3_INTRON] + 0; /* From state UTR3 to state UTR3_INTRON */ temp = SIG_0_1[UTR3] + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ SIG_0_0[UTR3_INTRON] = score; /* Finished calculating state UTR3_INTRON */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_CdnaWise10(dbsi,out,querydb,targetdb,gp,sc,rndcodon,utr,gap_open,gap_ext,utr_gap,intron_gap) * * Descrip: This function makes a database search of CdnaWise10 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [cDNADB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: sc [UNKN ] Undocumented argument [CodonMatrixScore *] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: utr [UNKN ] Undocumented argument [DnaMatrix*] * Arg: gap_open [UNKN ] Undocumented argument [Score] * Arg: gap_ext [UNKN ] Undocumented argument [Score] * Arg: utr_gap [UNKN ] Undocumented argument [Score] * Arg: intron_gap [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_CdnaWise10(DBSearchImpl * dbsi,Hscore * out,cDNADB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_CdnaWise10 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_CdnaWise10. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_CdnaWise10. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for CdnaWise10, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_CdnaWise10(out,querydb, targetdb ,gp,sc,rndcodon,utr,gap_open,gap_ext,utr_gap,intron_gap); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_CdnaWise10 *) ckalloc(sizeof(struct thread_pool_holder_CdnaWise10)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->gp = gp; holder->sc = sc; holder->rndcodon = rndcodon; holder->utr = utr; holder->gap_open = gap_open; holder->gap_ext = gap_ext; holder->utr_gap = utr_gap; holder->intron_gap = intron_gap; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_CdnaWise10,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for CdnaWise10"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from CdnaWise10",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_CdnaWise10(ptr) * * Descrip: Infinite loop code foreach thread for CdnaWise10 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_CdnaWise10(void * ptr) { struct thread_pool_holder_CdnaWise10 * holder; int db_status; int score; DataScore * ds; ComplexSequence* query; ComplexSequence* target; holder = (struct thread_pool_holder_CdnaWise10 *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for CdnaWise10"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for CdnaWise10"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_cDNADB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in CdnaWise10 search"); } query = hard_link_ComplexSequence(holder->query); /* get query information into datascore */ dataentry_add_cDNADB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_GenomicDB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_GenomicDB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching CdnaWise10, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_GenomicDB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_ComplexSequence(holder->query); /* get the next query object for the next thread */ holder->query = reload_cDNADB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching CdnaWise10, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_cDNADB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for CdnaWise10"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for CdnaWise10"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_GenomicDB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_CdnaWise10(query, target ,holder->gp,holder->sc,holder->rndcodon,holder->utr,holder->gap_open,holder->gap_ext,holder->utr_gap,holder->intron_gap); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for CdnaWise10"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for CdnaWise10"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for CdnaWise10"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_ComplexSequence(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for CdnaWise10"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_CdnaWise10(out,querydb,targetdb,gp,sc,rndcodon,utr,gap_open,gap_ext,utr_gap,intron_gap) * * Descrip: This function makes a database search of CdnaWise10 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [cDNADB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: sc [UNKN ] Undocumented argument [CodonMatrixScore *] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: utr [UNKN ] Undocumented argument [DnaMatrix*] * Arg: gap_open [UNKN ] Undocumented argument [Score] * Arg: gap_ext [UNKN ] Undocumented argument [Score] * Arg: utr_gap [UNKN ] Undocumented argument [Score] * Arg: intron_gap [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_CdnaWise10(Hscore * out,cDNADB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap) { ComplexSequence* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_cDNADB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching CdnaWise10, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_GenomicDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching CdnaWise10, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_CdnaWise10(query, target , gp, sc, rndcodon, utr, gap_open, gap_ext, utr_gap, intron_gap); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("CdnaWise10 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_cDNADB(ds->query,query,querydb); dataentry_add_GenomicDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_GenomicDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching CdnaWise10, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_GenomicDB(target,targetdb); query = reload_cDNADB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching CdnaWise10, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_cDNADB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_CdnaWise10(query,target,gp,sc,rndcodon,utr,gap_open,gap_ext,utr_gap,intron_gap) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_CdnaWise10_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: sc [UNKN ] Resource [CodonMatrixScore *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: utr [UNKN ] Resource [DnaMatrix*] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * Arg: utr_gap [UNKN ] Resource [Score] * Arg: intron_gap [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_CdnaWise10(ComplexSequence* query,ComplexSequence* target ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap) { int bestscore = NEGI; int i; int j; int k; CdnaWise10 * mat; mat = allocate_CdnaWise10_only(query, target , gp, sc, rndcodon, utr, gap_open, gap_ext, utr_gap, intron_gap); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(11,(mat->leni + 3) * 10,11,2)) == NULL) { warn("Score only matrix for CdnaWise10 cannot be allocated, (asking for 10 by %d cells)",mat->leni*10); mat = free_CdnaWise10(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<12;j++) { for(i=(-3);ileni;i++) { for(k=0;k<10;k++) CdnaWise10_VSMALL_MATRIX(mat,i,j,k) = NEGI; } CdnaWise10_VSMALL_SPECIAL(mat,i,j,START) = 0; CdnaWise10_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state UTR5 */ /* setting first movement to score */ score = CdnaWise10_VSMALL_MATRIX(mat,i-1,j-1,UTR5) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* From state START to state UTR5 */ temp = CdnaWise10_VSMALL_SPECIAL(mat,i-1,j-1,START) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR5_INTRON to state UTR5 */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-1,j-1,UTR5_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-1,UTR5) + mat->utr_gap; if( temp > score ) { score = temp; } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-1,j-0,UTR5) + mat->utr_gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ CdnaWise10_VSMALL_MATRIX(mat,i,j,UTR5) = score; /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-1,UTR5_INTRON) + 0; /* From state UTR5 to state UTR5_INTRON */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-1,UTR5) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ CdnaWise10_VSMALL_MATRIX(mat,i,j,UTR5_INTRON) = score; /* Finished calculating state UTR5_INTRON */ /* For state MATCH */ /* setting first movement to score */ score = CdnaWise10_VSMALL_MATRIX(mat,i-3,j-3,MATCH) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; /* From state INSERT to state MATCH */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-3,j-3,INSERT) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-3,j-3,DELETE) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = CdnaWise10_VSMALL_SPECIAL(mat,i-3,j-3,START) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state UTR5 to state MATCH */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-3,j-3,UTR5) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ CdnaWise10_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > CdnaWise10_VSMALL_SPECIAL(mat,i,j,END) ) { CdnaWise10_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_open); /* From state INSERT to state INSERT */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_ext); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ CdnaWise10_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = CdnaWise10_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_open); /* From state INSERT to state DELETE */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_ext); if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ CdnaWise10_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = CdnaWise10_VSMALL_MATRIX(mat,i-3,j-8,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_0 */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-8,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ CdnaWise10_VSMALL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = CdnaWise10_VSMALL_MATRIX(mat,i-3,j-9,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_1 */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-9,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ CdnaWise10_VSMALL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = CdnaWise10_VSMALL_MATRIX(mat,i-3,j-10,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_2 */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ CdnaWise10_VSMALL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state UTR3 */ /* setting first movement to score */ score = CdnaWise10_VSMALL_MATRIX(mat,i-1,j-1,UTR3) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* From state UTR3_INTRON to state UTR3 */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-1,j-1,UTR3_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-1,UTR3) + mat->utr_gap; if( temp > score ) { score = temp; } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-1,j-0,UTR3) + mat->utr_gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ CdnaWise10_VSMALL_MATRIX(mat,i,j,UTR3) = score; /* state UTR3 is a source for special END */ temp = score + (0) + (0) ; if( temp > CdnaWise10_VSMALL_SPECIAL(mat,i,j,END) ) { CdnaWise10_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-1,UTR3_INTRON) + 0; /* From state UTR3 to state UTR3_INTRON */ temp = CdnaWise10_VSMALL_MATRIX(mat,i-0,j-1,UTR3) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ CdnaWise10_VSMALL_MATRIX(mat,i,j,UTR3_INTRON) = score; /* Finished calculating state UTR3_INTRON */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < CdnaWise10_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = CdnaWise10_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_CdnaWise10(mat); return bestscore; } /* Function: PackAln_bestmemory_CdnaWise10(query,target,gp,sc,rndcodon,utr,gap_open,gap_ext,utr_gap,intron_gap,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_CdnaWise10 * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: sc [UNKN ] Resource [CodonMatrixScore *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: utr [UNKN ] Resource [DnaMatrix*] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * Arg: utr_gap [UNKN ] Resource [Score] * Arg: intron_gap [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_CdnaWise10(ComplexSequence* query,ComplexSequence* target ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; CdnaWise10 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->seq->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 10 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_CdnaWise10(query, target , gp, sc, rndcodon, utr, gap_open, gap_ext, utr_gap, intron_gap,dpri)) == NULL ) { warn("Unable to allocate large CdnaWise10 version"); return NULL; } calculate_dpenv_CdnaWise10(mat,dpenv); out = PackAln_read_Expl_CdnaWise10(mat); } else { mat = allocate_CdnaWise10_only(query, target , gp, sc, rndcodon, utr, gap_open, gap_ext, utr_gap, intron_gap); calculate_shatter_CdnaWise10(mat,dpenv); out = PackAln_read_Shatter_CdnaWise10(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_CdnaWise10(query, target , gp, sc, rndcodon, utr, gap_open, gap_ext, utr_gap, intron_gap)) == NULL ) { warn("Unable to allocate small CdnaWise10 version"); return NULL; } out = PackAln_calculate_Small_CdnaWise10(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_CdnaWise10(query, target , gp, sc, rndcodon, utr, gap_open, gap_ext, utr_gap, intron_gap,dpri)) == NULL ) { warn("Unable to allocate large CdnaWise10 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_CdnaWise10(mat); out = PackAln_read_Expl_CdnaWise10(mat); } } } mat = free_CdnaWise10(mat); return out; } /* Function: allocate_CdnaWise10_only(query,target,gp,sc,rndcodon,utr,gap_open,gap_ext,utr_gap,intron_gap) * * Descrip: This function only allocates the CdnaWise10 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: sc [UNKN ] Resource [CodonMatrixScore *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: utr [UNKN ] Resource [DnaMatrix*] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * Arg: utr_gap [UNKN ] Resource [Score] * Arg: intron_gap [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [CdnaWise10 *] * */ CdnaWise10 * allocate_CdnaWise10_only(ComplexSequence* query,ComplexSequence* target ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap) { CdnaWise10 * out; if((out= CdnaWise10_alloc()) == NULL) { warn("Allocation of basic CdnaWise10 structure failed..."); return NULL; } out->query = query; out->target = target; out->gp = gp; out->sc = sc; out->rndcodon = rndcodon; out->utr = utr; out->gap_open = gap_open; out->gap_ext = gap_ext; out->utr_gap = utr_gap; out->intron_gap = intron_gap; out->leni = query->seq->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_CdnaWise10(query,target,gp,sc,rndcodon,utr,gap_open,gap_ext,utr_gap,intron_gap,dpri) * * Descrip: This function allocates the CdnaWise10 structure * and the basematrix area for explicit memory implementations * It calls /allocate_CdnaWise10_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: sc [UNKN ] Resource [CodonMatrixScore *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: utr [UNKN ] Resource [DnaMatrix*] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * Arg: utr_gap [UNKN ] Resource [Score] * Arg: intron_gap [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [CdnaWise10 *] * */ CdnaWise10 * allocate_Expl_CdnaWise10(ComplexSequence* query,ComplexSequence* target ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap,DPRunImpl * dpri) { CdnaWise10 * out; out = allocate_CdnaWise10_only(query, target , gp, sc, rndcodon, utr, gap_open, gap_ext, utr_gap, intron_gap); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+10)*10 && dpri->cache->maxlenj >= (out->leni+3)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+10)*10,(out->leni+3),2,out->lenj+10)) == NULL) { warn("Explicit matrix CdnaWise10 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_CdnaWise10(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_CdnaWise10(out); return out; } /* Function: init_CdnaWise10(mat) * * Descrip: This function initates CdnaWise10 matrix when in explicit mode * Called in /allocate_Expl_CdnaWise10 * * * Arg: mat [UNKN ] CdnaWise10 which contains explicit basematrix memory [CdnaWise10 *] * */ void init_CdnaWise10(CdnaWise10 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-3);iquery->seq->len;i++) { for(j= (-10);j<11;j++) { CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; } } for(j= (-10);jtarget->seq->len;j++) { for(i= (-3);i<4;i++) { CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; } CdnaWise10_EXPL_SPECIAL(mat,i,j,START) = 0; CdnaWise10_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_CdnaWise10(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by CdnaWise10 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * */ void recalculate_PackAln_CdnaWise10(PackAln * pal,CdnaWise10 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case UTR5 : if( offi == 1 && offj == 1 && prev->state == UTR5 ) { pau->score = DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)) + (0); continue; } if( offj == 1 && prev->state == (START+10) ) { pau->score = DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)) + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UTR5_INTRON ) { pau->score = DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UTR5 ) { pau->score = mat->utr_gap + (0); continue; } if( offi == 1 && offj == 0 && prev->state == UTR5 ) { pau->score = mat->utr_gap + (0); continue; } warn("In recaluclating PackAln with state UTR5, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UTR5_INTRON : if( offi == 0 && offj == 1 && prev->state == UTR5_INTRON ) { pau->score = 0 + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UTR5 ) { pau->score = (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap) + (0); continue; } warn("In recaluclating PackAln with state UTR5_INTRON, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case MATCH : if( offi == 3 && offj == 3 && prev->state == MATCH ) { pau->score = mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)] + (0); continue; } if( offi == 3 && offj == 3 && prev->state == INSERT ) { pau->score = mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)] + (0); continue; } if( offi == 3 && offj == 3 && prev->state == DELETE ) { pau->score = mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)] + (0); continue; } if( offj == 3 && prev->state == (START+10) ) { pau->score = mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)] + (0); continue; } if( offi == 3 && offj == 3 && prev->state == UTR5 ) { pau->score = mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)] + (0); continue; } if( offi == 0 && offj == 6 && prev->state == INTRON_0 ) { pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-3)) + (0); continue; } if( offi == 0 && offj == 5 && prev->state == INTRON_1 ) { pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-2)) + (0); continue; } if( offi == 0 && offj == 4 && prev->state == INTRON_2 ) { pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-1)) + (0); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_open) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_ext) + (0); continue; } if( offi == 0 && offj == 6 && prev->state == INTRON_0 ) { pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-3)) + (0); continue; } if( offi == 0 && offj == 5 && prev->state == INTRON_1 ) { pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-2)) + (0); continue; } if( offi == 0 && offj == 4 && prev->state == INTRON_2 ) { pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-1)) + (0); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_open) + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_ext) + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_0 : if( offi == 3 && offj == 8 && prev->state == MATCH ) { pau->score = (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == INSERT ) { pau->score = (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_0 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_1 : if( offi == 3 && offj == 9 && prev->state == MATCH ) { pau->score = (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == INSERT ) { pau->score = (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_1 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_2 : if( offi == 3 && offj == 10 && prev->state == MATCH ) { pau->score = (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == INSERT ) { pau->score = (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_2 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UTR3 : if( offi == 1 && offj == 1 && prev->state == UTR3 ) { pau->score = DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)) + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UTR3_INTRON ) { pau->score = DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UTR3 ) { pau->score = mat->utr_gap + (0); continue; } if( offi == 1 && offj == 0 && prev->state == UTR3 ) { pau->score = mat->utr_gap + (0); continue; } warn("In recaluclating PackAln with state UTR3, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UTR3_INTRON : if( offi == 0 && offj == 1 && prev->state == UTR3_INTRON ) { pau->score = 0 + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UTR3 ) { pau->score = (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap) + (0); continue; } warn("In recaluclating PackAln with state UTR3_INTRON, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+10) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+10) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == UTR3 ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define CdnaWise10_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+10)][(i+3)*10+state]) #define CdnaWise10_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+11)*8) % 88][(i+3)*10+state]) #define CdnaWise10_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+10)]) #define CdnaWise10_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) #define CdnaWise10_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+11)*8)+(shadow+1)) % 88)][(i+3)*10 + state]) #define CdnaWise10_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) #define CdnaWise10_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+10)% 10) * (leni+1) * 10) + ((i+3) * 10) + (state)]) #define CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+10)% 10) * (leni+1) * 80) + ((i+3) * 80) + (state * 8) + shadow+1]) #define CdnaWise10_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) /* Function: allocate_Small_CdnaWise10(query,target,gp,sc,rndcodon,utr,gap_open,gap_ext,utr_gap,intron_gap) * * Descrip: This function allocates the CdnaWise10 structure * and the basematrix area for a small memory implementations * It calls /allocate_CdnaWise10_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: sc [UNKN ] Resource [CodonMatrixScore *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: utr [UNKN ] Resource [DnaMatrix*] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * Arg: utr_gap [UNKN ] Resource [Score] * Arg: intron_gap [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [CdnaWise10 *] * */ #define CdnaWise10_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) CdnaWise10 * allocate_Small_CdnaWise10(ComplexSequence* query,ComplexSequence* target ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap) { CdnaWise10 * out; out = allocate_CdnaWise10_only(query, target , gp, sc, rndcodon, utr, gap_open, gap_ext, utr_gap, intron_gap); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(88,(out->leni + 3) * 10,16,out->lenj+10); if(out == NULL) { warn("Small shadow matrix CdnaWise10 cannot be allocated, (asking for 11 by %d main cells)",out->leni+4); free_CdnaWise10(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_CdnaWise10(mat,dpenv) * * Descrip: This function calculates an alignment for CdnaWise10 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_CdnaWise10 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_CdnaWise10 * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_CdnaWise10(CdnaWise10 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for CdnaWise10 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_CdnaWise10(mat,dpenv); score = start_end_find_end_CdnaWise10(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_CdnaWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_CdnaWise10(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == CdnaWise10_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_CdnaWise10(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 10; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_CdnaWise10(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_CdnaWise10(mat) * * Descrip: This function calculates an alignment for CdnaWise10 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_CdnaWise10 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_CdnaWise10 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_CdnaWise10 * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_CdnaWise10(CdnaWise10 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_CdnaWise10(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_CdnaWise10(mat); return out; } /* Function: AlnRangeSet_from_CdnaWise10(mat) * * Descrip: This function reads off a start/end structure * for CdnaWise10 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_CdnaWise10 * If you have not calculated the matrix use * /AlnRange_calculate_Small_CdnaWise10 * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_CdnaWise10(CdnaWise10 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_CdnaWise10"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_CdnaWise10(mat,&jpos); state = END; while( (temp = AlnRange_build_CdnaWise10(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_CdnaWise10(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_CdnaWise10 * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_CdnaWise10(CdnaWise10 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_CdnaWise10"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_CdnaWise10(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_CdnaWise10 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = CdnaWise10_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_CdnaWise10(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == CdnaWise10_READ_OFF_ERROR) { warn("In AlnRange_build_CdnaWise10 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = CdnaWise10_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_CdnaWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_CdnaWise10(CdnaWise10 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_CdnaWise10(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == CdnaWise10_READ_OFF_ERROR) { warn("In CdnaWise10 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In CdnaWise10 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In CdnaWise10 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_CdnaWise10(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_CdnaWise10(CdnaWise10 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = CdnaWise10_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In CdnaWise10 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = CdnaWise10_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case UTR5 : temp = cscore - (mat->utr_gap) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 0,UTR5) ) { *reti = i - 1; *retj = j - 0; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-0,UTR5); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 0,UTR5); } temp = cscore - (mat->utr_gap) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,UTR5); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5); } temp = cscore - (DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j))) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 1,UTR5_INTRON) ) { *reti = i - 1; *retj = j - 1; *retstate = UTR5_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-1,UTR5_INTRON); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 1,UTR5_INTRON); } /* Not allowing special sources.. skipping START */ temp = cscore - (DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j))) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 1,UTR5) ) { *reti = i - 1; *retj = j - 1; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-1,UTR5); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 1,UTR5); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR5_INTRON : temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap)) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,UTR5); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5); } temp = cscore - (0) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5_INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,UTR5_INTRON); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5_INTRON); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH : temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-3))) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0); } temp = cscore - (mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 3,UTR5) ) { *reti = i - 3; *retj = j - 3; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-3,UTR5); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 3,UTR5); } /* Not allowing special sources.. skipping START */ temp = cscore - (mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 3,DELETE) ) { *reti = i - 3; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-3,DELETE); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 3,DELETE); } temp = cscore - (mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 3,INSERT) ) { *reti = i - 3; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-3,INSERT); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 3,INSERT); } temp = cscore - (mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 3,MATCH) ) { *reti = i - 3; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-3,MATCH); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 3,MATCH); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-3))) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0); } temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_ext)) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_open)) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - ((mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_ext)) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - ((mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_open)) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - (0) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap)) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-8,INSERT); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap)) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 8,MATCH) ) { *reti = i - 3; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-8,MATCH); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 8,MATCH); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - (0) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap)) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-9,INSERT); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap)) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 9,MATCH) ) { *reti = i - 3; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-9,MATCH); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 9,MATCH); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - (0) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap)) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-10,INSERT); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap)) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 10,MATCH) ) { *reti = i - 3; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-10,MATCH); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 3,j - 10,MATCH); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR3 : temp = cscore - (mat->utr_gap) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 0,UTR3) ) { *reti = i - 1; *retj = j - 0; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-0,UTR3); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 0,UTR3); } temp = cscore - (mat->utr_gap) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,UTR3); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3); } temp = cscore - (DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j))) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 1,UTR3_INTRON) ) { *reti = i - 1; *retj = j - 1; *retstate = UTR3_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-1,UTR3_INTRON); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 1,UTR3_INTRON); } temp = cscore - (DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j))) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 1,UTR3) ) { *reti = i - 1; *retj = j - 1; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-1,UTR3); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 1,j - 1,UTR3); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR3_INTRON : temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap)) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,UTR3); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3); } temp = cscore - (0) - (0); if( temp == CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3_INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,UTR3_INTRON); } return CdnaWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3_INTRON); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_CdnaWise10(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_CdnaWise10(CdnaWise10 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 10; add_PackAln(out,pau); } max_special_strip_CdnaWise10(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == CdnaWise10_READ_OFF_ERROR) { warn("In special strip read CdnaWise10, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read CdnaWise10, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 10; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_CdnaWise10(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_CdnaWise10(CdnaWise10 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = CdnaWise10_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for CdnaWise10, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In CdnaWise10 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = CdnaWise10_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source UTR3 is not a special */ /* Source MATCH is not a special */ default: warn("Major problem (!) - in CdnaWise10 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_CdnaWise10(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_CdnaWise10(CdnaWise10 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = CdnaWise10_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In CdnaWise10 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case UTR5 : /* Source UTR5 is not a special, should not get here! */ /* Source UTR5 is not a special, should not get here! */ /* Source UTR5_INTRON is not a special, should not get here! */ temp = cscore - (DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j))) - (0); if( temp == CdnaWise10_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return CdnaWise10_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source UTR5 is not a special, should not get here! */ warn("Major problem (!) - in CdnaWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR5_INTRON : /* Source UTR5 is not a special, should not get here! */ /* Source UTR5_INTRON is not a special, should not get here! */ warn("Major problem (!) - in CdnaWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH : /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ /* Source UTR5 is not a special, should not get here! */ temp = cscore - (mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == CdnaWise10_DC_SHADOW_SPECIAL(mat,i - 3,j - 3,START) ) { *reti = i - 3; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - CdnaWise10_DC_SHADOW_SPECIAL(mat,i-3,j-3,START); } return CdnaWise10_DC_SHADOW_MATRIX(mat,i - 3,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in CdnaWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in CdnaWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in CdnaWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : /* Source INTRON_0 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in CdnaWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : /* Source INTRON_1 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in CdnaWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : /* Source INTRON_2 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in CdnaWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR3 : /* Source UTR3 is not a special, should not get here! */ /* Source UTR3 is not a special, should not get here! */ /* Source UTR3_INTRON is not a special, should not get here! */ /* Source UTR3 is not a special, should not get here! */ warn("Major problem (!) - in CdnaWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR3_INTRON : /* Source UTR3 is not a special, should not get here! */ /* Source UTR3_INTRON is not a special, should not get here! */ warn("Major problem (!) - in CdnaWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_CdnaWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_CdnaWise10(CdnaWise10 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_CdnaWise10(mat,starti,startj,stopi,stopj); CdnaWise10_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ CdnaWise10_HIDDEN_MATRIX(mat,i,j,UTR5) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,UTR3) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; continue; } /* end of Is not in envelope */ /* For state UTR5 */ /* setting first movement to score */ score = CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-1,UTR5) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* From state UTR5_INTRON to state UTR5 */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-1,UTR5_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,UTR5) + mat->utr_gap; if( temp > score ) { score = temp; } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-0,UTR5) + mat->utr_gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ CdnaWise10_HIDDEN_MATRIX(mat,i,j,UTR5) = score; /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,UTR5_INTRON) + 0; /* From state UTR5 to state UTR5_INTRON */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,UTR5) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ CdnaWise10_HIDDEN_MATRIX(mat,i,j,UTR5_INTRON) = score; /* Finished calculating state UTR5_INTRON */ /* For state MATCH */ /* setting first movement to score */ score = CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-3,MATCH) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; /* From state INSERT to state MATCH */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-3,INSERT) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-3,DELETE) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state UTR5 to state MATCH */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-3,UTR5) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ CdnaWise10_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_open); /* From state INSERT to state INSERT */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_ext); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ CdnaWise10_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_open); /* From state INSERT to state DELETE */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_ext); if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ CdnaWise10_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-8,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_0 */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-8,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ CdnaWise10_HIDDEN_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-9,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_1 */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-9,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ CdnaWise10_HIDDEN_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = CdnaWise10_HIDDEN_MATRIX(mat,i-3,j-10,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_2 */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ CdnaWise10_HIDDEN_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state UTR3 */ /* setting first movement to score */ score = CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-1,UTR3) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* From state UTR3_INTRON to state UTR3 */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-1,UTR3_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,UTR3) + mat->utr_gap; if( temp > score ) { score = temp; } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-1,j-0,UTR3) + mat->utr_gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ CdnaWise10_HIDDEN_MATRIX(mat,i,j,UTR3) = score; /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,UTR3_INTRON) + 0; /* From state UTR3 to state UTR3_INTRON */ temp = CdnaWise10_HIDDEN_MATRIX(mat,i-0,j-1,UTR3) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ CdnaWise10_HIDDEN_MATRIX(mat,i,j,UTR3_INTRON) = score; /* Finished calculating state UTR3_INTRON */ } } return; } /* Function: init_hidden_CdnaWise10(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_CdnaWise10(CdnaWise10 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-10);j<=stopj;j++) { for(i=(starti-3);i<=stopi;i++) { CdnaWise10_HIDDEN_MATRIX(mat,i,j,UTR5) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,UTR3) = NEGI; CdnaWise10_HIDDEN_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; } } return; } /* Function: full_dc_CdnaWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_CdnaWise10 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_CdnaWise10 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [CdnaWise10 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_CdnaWise10(CdnaWise10 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_CdnaWise10"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 50) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_CdnaWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_CdnaWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_CdnaWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for CdnaWise10, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= CdnaWise10_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= CdnaWise10_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_CdnaWise10(mat,CdnaWise10_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),CdnaWise10_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),CdnaWise10_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_CdnaWise10(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_CdnaWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_CdnaWise10(CdnaWise10 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_CdnaWise10(mat); CdnaWise10_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_CdnaWise10(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_CdnaWise10(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_CdnaWise10(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_CdnaWise10(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_CdnaWise10(CdnaWise10 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<10;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,0) = (-100); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,1) = (-100); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,0) = (-100); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,1) = (-100); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-100); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = (-100); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-100); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = (-100); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-100); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = (-100); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,0) = (-100); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,1) = (-100); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,0) = (-100); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,1) = (-100); continue; } /* end of Is not in envelope */ /* For state UTR5, pushing when j - offj <= mergej */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,UTR5) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( j - 1 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,0) = i-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,1) = j-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,2) = UTR5; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,5) = UTR5; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UTR5,k); } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,UTR5_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score) { score = temp; if( j - 1 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,0) = i-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,1) = j-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,2) = UTR5_INTRON; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,5) = UTR5; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UTR5_INTRON,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + mat->utr_gap; if( temp > score) { score = temp; if( j - 1 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,1) = j-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,2) = UTR5; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,5) = UTR5; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-0,UTR5) + mat->utr_gap; if( temp > score) { score = temp; if( j - 0 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,0) = i-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,1) = j-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,2) = UTR5; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,5) = UTR5; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UTR5,k); } } /* Add any movement independant score */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5) = score; /* Finished with state UTR5 */ /* For state UTR5_INTRON, pushing when j - offj <= mergej */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5_INTRON) + 0; if( j - 1 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,1) = j-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,2) = UTR5_INTRON; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,5) = UTR5_INTRON; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5_INTRON,k); } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score) { score = temp; if( j - 1 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,1) = j-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,2) = UTR5; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,5) = UTR5_INTRON; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5,k); } } /* Add any movement independant score */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = score; /* Finished with state UTR5_INTRON */ /* For state MATCH, pushing when j - offj <= mergej */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-3,MATCH) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( j - 3 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 3,MATCH,k); } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-3,INSERT) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score) { score = temp; if( j - 3 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 3,INSERT,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-3,DELETE) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score) { score = temp; if( j - 3 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 3,DELETE,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-3,UTR5) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score) { score = temp; if( j - 3 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = UTR5; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 3,UTR5,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score) { score = temp; if( j - 6 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-6; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score) { score = temp; if( j - 5 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score) { score = temp; if( j - 4 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_2; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } } /* Add any movement independant score */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_open); if( j - 3 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_ext); if( temp > score) { score = temp; if( j - 3 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score) { score = temp; if( j - 6 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-6; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score) { score = temp; if( j - 5 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score) { score = temp; if( j - 4 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_2; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } } /* Add any movement independant score */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_open); if( j - 0 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_ext); if( temp > score) { score = temp; if( j - 0 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } /* Add any movement independant score */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ /* For state INTRON_0, pushing when j - offj <= mergej */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-8,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( j - 8 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = MATCH; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 8,MATCH,k); } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score) { score = temp; if( j - 8 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INSERT; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INTRON_0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } } /* Add any movement independant score */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished with state INTRON_0 */ /* For state INTRON_1, pushing when j - offj <= mergej */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-9,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( j - 9 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = MATCH; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 9,MATCH,k); } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score) { score = temp; if( j - 9 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INSERT; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INTRON_1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } } /* Add any movement independant score */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished with state INTRON_1 */ /* For state INTRON_2, pushing when j - offj <= mergej */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-10,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( j - 10 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = MATCH; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 10,MATCH,k); } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score) { score = temp; if( j - 10 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INSERT; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INTRON_2; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } } /* Add any movement independant score */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished with state INTRON_2 */ /* For state UTR3, pushing when j - offj <= mergej */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,UTR3) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( j - 1 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,0) = i-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,1) = j-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,2) = UTR3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,5) = UTR3; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UTR3,k); } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,UTR3_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score) { score = temp; if( j - 1 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,0) = i-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,1) = j-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,2) = UTR3_INTRON; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,5) = UTR3; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UTR3_INTRON,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + mat->utr_gap; if( temp > score) { score = temp; if( j - 1 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,1) = j-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,2) = UTR3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,5) = UTR3; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3,k); } } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-0,UTR3) + mat->utr_gap; if( temp > score) { score = temp; if( j - 0 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,0) = i-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,1) = j-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,2) = UTR3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,5) = UTR3; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UTR3,k); } } /* Add any movement independant score */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3) = score; /* Finished with state UTR3 */ /* For state UTR3_INTRON, pushing when j - offj <= mergej */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3_INTRON) + 0; if( j - 1 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,1) = j-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,2) = UTR3_INTRON; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,5) = UTR3_INTRON; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3_INTRON,k); } temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score) { score = temp; if( j - 1 <= mergej) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,0) = i-0; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,1) = j-1; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,2) = UTR3; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,3) = i; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,4) = j; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,5) = UTR3_INTRON; } else { for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,k) = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3,k); } } /* Add any movement independant score */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = score; /* Finished with state UTR3_INTRON */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_CdnaWise10(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_CdnaWise10(CdnaWise10 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state UTR5 */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,UTR5) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UTR5,k); /* From state UTR5_INTRON to state UTR5 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,UTR5_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UTR5_INTRON,k); } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + mat->utr_gap; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5,k); } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-0,UTR5) + mat->utr_gap; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UTR5,k); } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5) = score; for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5_INTRON) + 0; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5_INTRON,k); /* From state UTR5 to state UTR5_INTRON */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5,k); } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = score; for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UTR5_INTRON */ /* For state MATCH */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-3,MATCH) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-3,INSERT) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-3,DELETE) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 3,DELETE,k); } /* From state UTR5 to state MATCH */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-3,UTR5) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 3,UTR5,k); } /* From state INTRON_0 to state MATCH */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } /* From state INTRON_1 to state MATCH */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } /* From state INTRON_2 to state MATCH */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_open); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_ext); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state INTRON_0 to state INSERT */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } /* From state INTRON_1 to state INSERT */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } /* From state INTRON_2 to state INSERT */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_open); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_ext); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-8,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 8,MATCH,k); /* From state INSERT to state INTRON_0 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } /* From state INTRON_0 to state INTRON_0 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-9,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 9,MATCH,k); /* From state INSERT to state INTRON_1 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } /* From state INTRON_1 to state INTRON_1 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-10,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 3,j - 10,MATCH,k); /* From state INSERT to state INTRON_2 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } /* From state INTRON_2 to state INTRON_2 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ /* For state UTR3 */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,UTR3) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UTR3,k); /* From state UTR3_INTRON to state UTR3 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,UTR3_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UTR3_INTRON,k); } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + mat->utr_gap; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3,k); } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-0,UTR3) + mat->utr_gap; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UTR3,k); } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3) = score; for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3_INTRON) + 0; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3_INTRON,k); /* From state UTR3 to state UTR3_INTRON */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3,k); } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = score; for(k=0;k<7;k++) CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UTR3_INTRON */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_CdnaWise10(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_CdnaWise10(CdnaWise10 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state UTR5 */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,UTR5) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* From state UTR5_INTRON to state UTR5 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,UTR5_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + mat->utr_gap; if( temp > score ) { score = temp; } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-0,UTR5) + mat->utr_gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5) = score; /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5_INTRON) + 0; /* From state UTR5 to state UTR5_INTRON */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = score; /* Finished calculating state UTR5_INTRON */ /* For state MATCH */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-3,MATCH) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; /* From state INSERT to state MATCH */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-3,INSERT) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-3,DELETE) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state UTR5 to state MATCH */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-3,UTR5) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_open); /* From state INSERT to state INSERT */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_ext); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_open); /* From state INSERT to state DELETE */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_ext); if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-8,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_0 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-9,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_1 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-3,j-10,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_2 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state UTR3 */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,UTR3) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* From state UTR3_INTRON to state UTR3 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,UTR3_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + mat->utr_gap; if( temp > score ) { score = temp; } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-1,j-0,UTR3) + mat->utr_gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3) = score; /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3_INTRON) + 0; /* From state UTR3 to state UTR3_INTRON */ temp = CdnaWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = score; /* Finished calculating state UTR3_INTRON */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_CdnaWise10(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * */ } void init_dc_CdnaWise10(CdnaWise10 * mat) { register int i; register int j; register int k; for(j=0;j<12;j++) { for(i=(-3);iquery->seq->len;i++) { CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3) = NEGI; CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; for(k=0;k<7;k++) { CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,k) = (-1); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,k) = (-1); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = (-1); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = (-1); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = (-1); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = (-1); CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,k) = (-1); } } } return; } /* Function: start_end_find_end_CdnaWise10(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [CdnaWise10 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_CdnaWise10(CdnaWise10 * mat,int * endj) { register int j; register int max; register int maxj; max = CdnaWise10_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( CdnaWise10_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = CdnaWise10_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_CdnaWise10(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [CdnaWise10] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_CdnaWise10(CdnaWise10 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->seq->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (10 * (leni + 3) * 10,sizeof(int)); shadow_pointers = (int *) calloc (10 * (leni + 3) * 10 * 8,sizeof(int)); for(j=0;jutr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)) + (0); /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UTR5,0)); /* From state START to state UTR5 */ temp = CdnaWise10_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for UTR5... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= UTR5; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state UTR5_INTRON to state UTR5 */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UTR5_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UTR5_INTRON,0)); } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + mat->utr_gap +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5,0)); } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,UTR5) + mat->utr_gap +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UTR5,0)); } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i,j,UTR5) = score; for(k=0;k<7;k++) CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR5,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UTR5_INTRON) + 0 + (0); /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5_INTRON,0)); /* From state UTR5 to state UTR5_INTRON */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5,0)); } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = score; for(k=0;k<7;k++) CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UTR5_INTRON */ /* For state MATCH */ /* setting first movement to score */ score = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-3,j-3,MATCH) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)] + (0); /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 3,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-3,j-3,INSERT) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 3,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-3,j-3,DELETE) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 3,j - 3,DELETE,0)); } /* From state START to state MATCH */ temp = CdnaWise10_DC_OPT_SHADOW_SPECIAL(mat,i-3,j-3,START) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state UTR5 to state MATCH */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-3,j-3,UTR5) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 3,j - 3,UTR5,0)); } /* From state INTRON_0 to state MATCH */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,0)); } /* From state INTRON_1 to state MATCH */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,0)); } /* From state INTRON_2 to state MATCH */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > CdnaWise10_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { CdnaWise10_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) CdnaWise10_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); CdnaWise10_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); CdnaWise10_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; CdnaWise10_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; CdnaWise10_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_open) + (0); /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_ext) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state INTRON_0 to state INSERT */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,0)); } /* From state INTRON_1 to state INSERT */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,0)); } /* From state INTRON_2 to state INSERT */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_open) + (0); /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_ext) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-3,j-8,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap) + (0); /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 3,j - 8,MATCH,0)); /* From state INSERT to state INTRON_0 */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,0)); } /* From state INTRON_0 to state INTRON_0 */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,0)); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-3,j-9,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap) + (0); /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 3,j - 9,MATCH,0)); /* From state INSERT to state INTRON_1 */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,0)); } /* From state INTRON_1 to state INTRON_1 */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,0)); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-3,j-10,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap) + (0); /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 3,j - 10,MATCH,0)); /* From state INSERT to state INTRON_2 */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0)); } /* From state INTRON_2 to state INTRON_2 */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,0)); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ /* For state UTR3 */ /* setting first movement to score */ score = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UTR3) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)) + (0); /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UTR3,0)); /* From state UTR3_INTRON to state UTR3 */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UTR3_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UTR3_INTRON,0)); } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + mat->utr_gap +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3,0)); } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,UTR3) + mat->utr_gap +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UTR3,0)); } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i,j,UTR3) = score; for(k=0;k<7;k++) CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state UTR3 is a source for special END */ temp = score + (0) + (0) ; if( temp > CdnaWise10_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { CdnaWise10_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) CdnaWise10_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR3,k); CdnaWise10_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR3,6); CdnaWise10_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; CdnaWise10_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; CdnaWise10_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = UTR3; } /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UTR3_INTRON) + 0 + (0); /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3_INTRON,0)); /* From state UTR3 to state UTR3_INTRON */ temp = CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3,0)); } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ CdnaWise10_DC_OPT_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = score; for(k=0;k<7;k++) CdnaWise10_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UTR3_INTRON */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_CdnaWise10(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * */ void init_start_end_linear_CdnaWise10(CdnaWise10 * mat) { register int i; register int j; for(j=0;j<12;j++) { for(i=(-3);iquery->seq->len;i++) { CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,0) = (-1); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,0) = (-1); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-1); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-1); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-1); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,0) = (-1); CdnaWise10_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; CdnaWise10_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,0) = (-1); } } for(j=(-10);jtarget->seq->len;j++) { CdnaWise10_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; CdnaWise10_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; CdnaWise10_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_CdnaWise10(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_CdnaWise10(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_CdnaWise10(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "UTR5","UTR5_GAP","MATCH_STATE","INSERT_STATE","DELETE_STATE","INTRON_STATE","UTR3","UTR3_GAP","END" }; /* Function: AlnConvertSet_CdnaWise10(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "UTR5","UTR5_GAP","UTR5_INTRON","CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","INSERT","5SS_PHASE_0","CENTRAL_INTRON","5SS_PHASE_1","5SS_PHASE_2","UTR3","UTR3_GAP","UTR3_INTRON","END" }; AlnConvertSet * AlnConvertSet_CdnaWise10(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5; acu->state2 = UTR5; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 10; acu->is_from_special = TRUE; acu->state2 = UTR5; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5_INTRON; acu->state2 = UTR5; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5; acu->state2 = UTR5; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5; acu->state2 = UTR5; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5_INTRON; acu->state2 = UTR5_INTRON; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5; acu->state2 = UTR5_INTRON; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 3; acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 3; acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 3; acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 10; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5; acu->state2 = MATCH; acu->offi = 3; acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = MATCH; acu->offi = 0; acu->offj = 6; acu->label1 = query_label[2]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = MATCH; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[2]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = MATCH; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INSERT; acu->offi = 0; acu->offj = 6; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[3]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_0; acu->offi = 3; acu->offj = 8; acu->label1 = query_label[5]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[5]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_1; acu->offi = 3; acu->offj = 9; acu->label1 = query_label[5]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[5]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_2; acu->offi = 3; acu->offj = 10; acu->label1 = query_label[5]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[5]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3; acu->state2 = UTR3; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3_INTRON; acu->state2 = UTR3; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3; acu->state2 = UTR3; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3; acu->state2 = UTR3; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[6]; acu->label2 = target_label[13]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3_INTRON; acu->state2 = UTR3_INTRON; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3; acu->state2 = UTR3_INTRON; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 10; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[15]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3; acu->state2 = END + 10; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[15]; add_collapse_label_AlnConvertSet(out,"UTR5","UTR5"); add_collapse_label_AlnConvertSet(out,"UTR3","UTR3"); add_collapse_label_AlnConvertSet(out,"UTR5","UTR5_INTRON"); add_collapse_label_AlnConvertSet(out,"UTR3","UTR3_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_STATE","CENTRAL_INTRON"); return out; } /* Function: PackAln_read_Expl_CdnaWise10(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_CdnaWise10(CdnaWise10 * mat) { CdnaWise10_access_func_holder holder; holder.access_main = CdnaWise10_explicit_access_main; holder.access_special = CdnaWise10_explicit_access_special; return PackAln_read_generic_CdnaWise10(mat,holder); } /* Function: CdnaWise10_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int CdnaWise10_explicit_access_main(CdnaWise10 * mat,int i,int j,int state) { return CdnaWise10_EXPL_MATRIX(mat,i,j,state); } /* Function: CdnaWise10_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int CdnaWise10_explicit_access_special(CdnaWise10 * mat,int i,int j,int state) { return CdnaWise10_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_CdnaWise10(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: h [UNKN ] Undocumented argument [CdnaWise10_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_CdnaWise10(CdnaWise10 * mat,CdnaWise10_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_CdnaWise10(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in CdnaWise10_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 10; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_CdnaWise10(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_CdnaWise10(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == CdnaWise10_READ_OFF_ERROR || j == CdnaWise10_READ_OFF_ERROR || state == CdnaWise10_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in CdnaWise10_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 10; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_CdnaWise10(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [CdnaWise10_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_CdnaWise10(CdnaWise10 * mat,int * ri,int * rj,int * state,boolean * isspecial,CdnaWise10_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: CdnaWise10_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void CdnaWise10_debug_show_matrix(CdnaWise10 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->seq->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State UTR5 %d\n",CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5)); fprintf(ofp,"State UTR5_INTRON %d\n",CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5_INTRON)); fprintf(ofp,"State MATCH %d\n",CdnaWise10_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",CdnaWise10_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",CdnaWise10_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"State INTRON_0 %d\n",CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_0)); fprintf(ofp,"State INTRON_1 %d\n",CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_1)); fprintf(ofp,"State INTRON_2 %d\n",CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_2)); fprintf(ofp,"State UTR3 %d\n",CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3)); fprintf(ofp,"State UTR3_INTRON %d\n",CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3_INTRON)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_CdnaWise10(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [CdnaWise10_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_CdnaWise10(CdnaWise10 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,CdnaWise10_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = CdnaWise10_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In CdnaWise10 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case UTR5 : temp = cscore - (mat->utr_gap) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,UTR5) ) { *reti = i - 1; *retj = j - 0; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,UTR5); } return (*h.access_main)(mat,i - 1,j - 0,UTR5); } temp = cscore - (mat->utr_gap) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR5) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR5); } return (*h.access_main)(mat,i - 0,j - 1,UTR5); } temp = cscore - (DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j))) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UTR5_INTRON) ) { *reti = i - 1; *retj = j - 1; *retstate = UTR5_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UTR5_INTRON); } return (*h.access_main)(mat,i - 1,j - 1,UTR5_INTRON); } temp = cscore - (DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j))) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j))) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UTR5) ) { *reti = i - 1; *retj = j - 1; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UTR5); } return (*h.access_main)(mat,i - 1,j - 1,UTR5); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR5_INTRON : temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR5) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR5); } return (*h.access_main)(mat,i - 0,j - 1,UTR5); } temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR5_INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR5_INTRON); } return (*h.access_main)(mat,i - 0,j - 1,UTR5_INTRON); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH : temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 5,INTRON_1); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-3))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-6,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 6,INTRON_0); } temp = cscore - (mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == (*h.access_main)(mat,i - 3,j - 3,UTR5) ) { *reti = i - 3; *retj = j - 3; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-3,j-3,UTR5); } return (*h.access_main)(mat,i - 3,j - 3,UTR5); } temp = cscore - (mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == (*h.access_special)(mat,i - 3,j - 3,START) ) { *reti = i - 3; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-3,j-3,START); } return (*h.access_main)(mat,i - 3,j - 3,START); } temp = cscore - (mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == (*h.access_main)(mat,i - 3,j - 3,DELETE) ) { *reti = i - 3; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-3,j-3,DELETE); } return (*h.access_main)(mat,i - 3,j - 3,DELETE); } temp = cscore - (mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == (*h.access_main)(mat,i - 3,j - 3,INSERT) ) { *reti = i - 3; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-3,j-3,INSERT); } return (*h.access_main)(mat,i - 3,j - 3,INSERT); } temp = cscore - (mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == (*h.access_main)(mat,i - 3,j - 3,MATCH) ) { *reti = i - 3; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-3,j-3,MATCH); } return (*h.access_main)(mat,i - 3,j - 3,MATCH); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 5,INTRON_1); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-3))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-6,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 6,INTRON_0); } temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_ext)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_open)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - ((mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_ext)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - ((mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_open)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,INSERT); } return (*h.access_main)(mat,i - 0,j - 8,INSERT); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap)) - (0); if( temp == (*h.access_main)(mat,i - 3,j - 8,MATCH) ) { *reti = i - 3; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-3,j-8,MATCH); } return (*h.access_main)(mat,i - 3,j - 8,MATCH); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,INSERT); } return (*h.access_main)(mat,i - 0,j - 9,INSERT); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap)) - (0); if( temp == (*h.access_main)(mat,i - 3,j - 9,MATCH) ) { *reti = i - 3; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-3,j-9,MATCH); } return (*h.access_main)(mat,i - 3,j - 9,MATCH); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT); } return (*h.access_main)(mat,i - 0,j - 10,INSERT); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap)) - (0); if( temp == (*h.access_main)(mat,i - 3,j - 10,MATCH) ) { *reti = i - 3; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-3,j-10,MATCH); } return (*h.access_main)(mat,i - 3,j - 10,MATCH); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR3 : temp = cscore - (mat->utr_gap) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,UTR3) ) { *reti = i - 1; *retj = j - 0; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,UTR3); } return (*h.access_main)(mat,i - 1,j - 0,UTR3); } temp = cscore - (mat->utr_gap) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR3) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR3); } return (*h.access_main)(mat,i - 0,j - 1,UTR3); } temp = cscore - (DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j))) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UTR3_INTRON) ) { *reti = i - 1; *retj = j - 1; *retstate = UTR3_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UTR3_INTRON); } return (*h.access_main)(mat,i - 1,j - 1,UTR3_INTRON); } temp = cscore - (DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j))) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UTR3) ) { *reti = i - 1; *retj = j - 1; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UTR3); } return (*h.access_main)(mat,i - 1,j - 1,UTR3); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR3_INTRON : temp = cscore - ((CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR3) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR3); } return (*h.access_main)(mat,i - 0,j - 1,UTR3); } temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR3_INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR3_INTRON); } return (*h.access_main)(mat,i - 0,j - 1,UTR3_INTRON); } warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_CdnaWise10(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [CdnaWise10_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_CdnaWise10(CdnaWise10 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,CdnaWise10_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = CdnaWise10_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In CdnaWise10 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source UTR3 is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,UTR3) ) { *reti = i - 0; *retj = j - 0; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,UTR3); } return (*h.access_main)(mat,i - 0,j - 0,UTR3) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in CdnaWise10 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_CdnaWise10(mat) * * Descrip: This function calculates the CdnaWise10 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_CdnaWise10 * * * Arg: mat [UNKN ] CdnaWise10 which contains explicit basematrix memory [CdnaWise10 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_CdnaWise10(CdnaWise10 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_CdnaWise10, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("CdnaWise10 Matrix calculation: "); for(j=0;jutr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* From state START to state UTR5 */ temp = CdnaWise10_EXPL_SPECIAL(mat,i-1,j-1,START) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR5_INTRON to state UTR5 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-1,j-1,UTR5_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,UTR5) + mat->utr_gap; if( temp > score ) { score = temp; } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-1,j-0,UTR5) + mat->utr_gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5) = score; /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,UTR5_INTRON) + 0; /* From state UTR5 to state UTR5_INTRON */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,UTR5) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5_INTRON) = score; /* Finished calculating state UTR5_INTRON */ /* For state MATCH */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-3,j-3,MATCH) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; /* From state INSERT to state MATCH */ temp = CdnaWise10_EXPL_MATRIX(mat,i-3,j-3,INSERT) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = CdnaWise10_EXPL_MATRIX(mat,i-3,j-3,DELETE) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = CdnaWise10_EXPL_SPECIAL(mat,i-3,j-3,START) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state UTR5 to state MATCH */ temp = CdnaWise10_EXPL_MATRIX(mat,i-3,j-3,UTR5) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > CdnaWise10_EXPL_SPECIAL(mat,i,j,END) ) { CdnaWise10_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_open); /* From state INSERT to state INSERT */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_ext); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-1,j-0,MATCH) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_open); /* From state INSERT to state DELETE */ temp = CdnaWise10_EXPL_MATRIX(mat,i-1,j-0,INSERT) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_ext); if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-3,j-8,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_0 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-3,j-9,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_1 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-3,j-10,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_2 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state UTR3 */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-1,j-1,UTR3) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* From state UTR3_INTRON to state UTR3 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-1,j-1,UTR3_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,UTR3) + mat->utr_gap; if( temp > score ) { score = temp; } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-1,j-0,UTR3) + mat->utr_gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3) = score; /* state UTR3 is a source for special END */ temp = score + (0) + (0) ; if( temp > CdnaWise10_EXPL_SPECIAL(mat,i,j,END) ) { CdnaWise10_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,UTR3_INTRON) + 0; /* From state UTR3 to state UTR3_INTRON */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,UTR3) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3_INTRON) = score; /* Finished calculating state UTR3_INTRON */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_CdnaWise10(mat,dpenv) * * Descrip: This function calculates the CdnaWise10 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] CdnaWise10 which contains explicit basematrix memory [CdnaWise10 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_CdnaWise10(CdnaWise10 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_CdnaWise10, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-10;jleni;i++) { CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; } } for(j=-10;jlenj;j++) { CdnaWise10_EXPL_SPECIAL(mat,i,j,START) = 0; CdnaWise10_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("CdnaWise10 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3) = NEGI; CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state UTR5 */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-1,j-1,UTR5) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* From state START to state UTR5 */ temp = CdnaWise10_EXPL_SPECIAL(mat,i-1,j-1,START) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR5_INTRON to state UTR5 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-1,j-1,UTR5_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,UTR5) + mat->utr_gap; if( temp > score ) { score = temp; } /* From state UTR5 to state UTR5 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-1,j-0,UTR5) + mat->utr_gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5) = score; /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,UTR5_INTRON) + 0; /* From state UTR5 to state UTR5_INTRON */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,UTR5) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,UTR5_INTRON) = score; /* Finished calculating state UTR5_INTRON */ /* For state MATCH */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-3,j-3,MATCH) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; /* From state INSERT to state MATCH */ temp = CdnaWise10_EXPL_MATRIX(mat,i-3,j-3,INSERT) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = CdnaWise10_EXPL_MATRIX(mat,i-3,j-3,DELETE) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = CdnaWise10_EXPL_SPECIAL(mat,i-3,j-3,START) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state UTR5 to state MATCH */ temp = CdnaWise10_EXPL_MATRIX(mat,i-3,j-3,UTR5) + mat->sc->score[CSEQ_CDNA_CODON(mat->query,i)][CSEQ_GENOMIC_CODON(mat->target,j)]; if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > CdnaWise10_EXPL_SPECIAL(mat,i,j,END) ) { CdnaWise10_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_open); /* From state INSERT to state INSERT */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gap_ext); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + CSEQ_GENOMIC_3SS(mat->target,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-1,j-0,MATCH) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_open); /* From state INSERT to state DELETE */ temp = CdnaWise10_EXPL_MATRIX(mat,i-1,j-0,INSERT) + (mat->rndcodon->codon[CSEQ_CDNA_CODON(mat->query,i)]+mat->gap_ext); if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-3,j-8,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_0 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-3,j-9,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_1 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-3,j-10,MATCH) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); /* From state INSERT to state INTRON_2 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (CSEQ_GENOMIC_5SS(mat->target,(j-7))+mat->intron_gap); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state UTR3 */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-1,j-1,UTR3) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); /* From state UTR3_INTRON to state UTR3 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-1,j-1,UTR3_INTRON) + DnaMatrix_MATCH(mat->utr,CSEQ_CDNA_BASE(mat->query,i),CSEQ_GENOMIC_BASE(mat->target,j)); if( temp > score ) { score = temp; } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,UTR3) + mat->utr_gap; if( temp > score ) { score = temp; } /* From state UTR3 to state UTR3 */ temp = CdnaWise10_EXPL_MATRIX(mat,i-1,j-0,UTR3) + mat->utr_gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3) = score; /* state UTR3 is a source for special END */ temp = score + (0) + (0) ; if( temp > CdnaWise10_EXPL_SPECIAL(mat,i,j,END) ) { CdnaWise10_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,UTR3_INTRON) + 0; /* From state UTR3 to state UTR3_INTRON */ temp = CdnaWise10_EXPL_MATRIX(mat,i-0,j-1,UTR3) + (CSEQ_GENOMIC_5SS(mat->target,j)+mat->intron_gap); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ CdnaWise10_EXPL_MATRIX(mat,i,j,UTR3_INTRON) = score; /* Finished calculating state UTR3_INTRON */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: CdnaWise10_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CdnaWise10 *] * */ CdnaWise10 * CdnaWise10_alloc(void) { CdnaWise10 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CdnaWise10 *) ckalloc (sizeof(CdnaWise10))) == NULL) { warn("CdnaWise10_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_CdnaWise10(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CdnaWise10 *] * * Return [UNKN ] Undocumented return value [CdnaWise10 *] * */ CdnaWise10 * free_CdnaWise10(CdnaWise10 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CdnaWise10 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->gp is linked in */ /* obj->sc is linked in */ /* obj->rndcodon is linked in */ /* obj->utr is linked in */ /* obj->gap_open is linked in */ /* obj->gap_ext is linked in */ /* obj->utr_gap is linked in */ /* obj->intron_gap is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/cdnawise10.h0000644000175000001440000005434310670453713016251 0ustar philippusers#ifndef DYNAMITEcdnawise10HEADERFILE #define DYNAMITEcdnawise10HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "geneparser4.h" struct Wise2_CdnaWise10 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; ComplexSequence* query; ComplexSequence* target; GeneParser4Score * gp; CodonMatrixScore * sc; RandomCodonScore * rndcodon; DnaMatrix* utr; Score gap_open; Score gap_ext; Score utr_gap; Score intron_gap; } ; /* CdnaWise10 defined */ #ifndef DYNAMITE_DEFINED_CdnaWise10 typedef struct Wise2_CdnaWise10 Wise2_CdnaWise10; #define CdnaWise10 Wise2_CdnaWise10 #define DYNAMITE_DEFINED_CdnaWise10 #endif #ifdef PTHREAD struct thread_pool_holder_CdnaWise10 { ComplexSequence* query; /* Query object placeholder */ cDNADB* querydb;/* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ GenomicDB* targetdb;/* Target database object */ boolean target_init; GeneParser4Score * gp; CodonMatrixScore * sc; RandomCodonScore * rndcodon; DnaMatrix* utr; Score gap_open; Score gap_ext; Score utr_gap; Score intron_gap; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_CdnaWise10_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(CdnaWise10*,int,int,int); int (*access_special)(CdnaWise10*,int,int,int); } ; /* CdnaWise10_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_CdnaWise10_access_func_holder typedef struct Wise2_CdnaWise10_access_func_holder Wise2_CdnaWise10_access_func_holder; #define CdnaWise10_access_func_holder Wise2_CdnaWise10_access_func_holder #define DYNAMITE_DEFINED_CdnaWise10_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_CdnaWise10(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_CdnaWise10(CdnaWise10 * mat); #define PackAln_read_Shatter_CdnaWise10 Wise2_PackAln_read_Shatter_CdnaWise10 /* Function: calculate_shatter_CdnaWise10(mat,dpenv) * * Descrip: This function calculates the CdnaWise10 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [CdnaWise10 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_CdnaWise10(CdnaWise10 * mat,DPEnvelope * dpenv); #define calculate_shatter_CdnaWise10 Wise2_calculate_shatter_CdnaWise10 /* Function: search_CdnaWise10(dbsi,out,querydb,targetdb,gp,sc,rndcodon,utr,gap_open,gap_ext,utr_gap,intron_gap) * * Descrip: This function makes a database search of CdnaWise10 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [cDNADB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: sc [UNKN ] Undocumented argument [CodonMatrixScore *] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: utr [UNKN ] Undocumented argument [DnaMatrix*] * Arg: gap_open [UNKN ] Undocumented argument [Score] * Arg: gap_ext [UNKN ] Undocumented argument [Score] * Arg: utr_gap [UNKN ] Undocumented argument [Score] * Arg: intron_gap [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_CdnaWise10(DBSearchImpl * dbsi,Hscore * out,cDNADB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap); #define search_CdnaWise10 Wise2_search_CdnaWise10 /* Function: serial_search_CdnaWise10(out,querydb,targetdb,gp,sc,rndcodon,utr,gap_open,gap_ext,utr_gap,intron_gap) * * Descrip: This function makes a database search of CdnaWise10 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [cDNADB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: sc [UNKN ] Undocumented argument [CodonMatrixScore *] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: utr [UNKN ] Undocumented argument [DnaMatrix*] * Arg: gap_open [UNKN ] Undocumented argument [Score] * Arg: gap_ext [UNKN ] Undocumented argument [Score] * Arg: utr_gap [UNKN ] Undocumented argument [Score] * Arg: intron_gap [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_CdnaWise10(Hscore * out,cDNADB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap); #define serial_search_CdnaWise10 Wise2_serial_search_CdnaWise10 /* Function: PackAln_bestmemory_CdnaWise10(query,target,gp,sc,rndcodon,utr,gap_open,gap_ext,utr_gap,intron_gap,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_CdnaWise10 * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: sc [UNKN ] Resource [CodonMatrixScore *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: utr [UNKN ] Resource [DnaMatrix*] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * Arg: utr_gap [UNKN ] Resource [Score] * Arg: intron_gap [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_CdnaWise10(ComplexSequence* query,ComplexSequence* target ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_CdnaWise10 Wise2_PackAln_bestmemory_CdnaWise10 /* Function: allocate_Expl_CdnaWise10(query,target,gp,sc,rndcodon,utr,gap_open,gap_ext,utr_gap,intron_gap,dpri) * * Descrip: This function allocates the CdnaWise10 structure * and the basematrix area for explicit memory implementations * It calls /allocate_CdnaWise10_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: sc [UNKN ] Resource [CodonMatrixScore *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: utr [UNKN ] Resource [DnaMatrix*] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * Arg: utr_gap [UNKN ] Resource [Score] * Arg: intron_gap [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [CdnaWise10 *] * */ CdnaWise10 * Wise2_allocate_Expl_CdnaWise10(ComplexSequence* query,ComplexSequence* target ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap,DPRunImpl * dpri); #define allocate_Expl_CdnaWise10 Wise2_allocate_Expl_CdnaWise10 /* Function: recalculate_PackAln_CdnaWise10(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by CdnaWise10 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * */ void Wise2_recalculate_PackAln_CdnaWise10(PackAln * pal,CdnaWise10 * mat); #define recalculate_PackAln_CdnaWise10 Wise2_recalculate_PackAln_CdnaWise10 /* Function: allocate_Small_CdnaWise10(query,target,gp,sc,rndcodon,utr,gap_open,gap_ext,utr_gap,intron_gap) * * Descrip: This function allocates the CdnaWise10 structure * and the basematrix area for a small memory implementations * It calls /allocate_CdnaWise10_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: sc [UNKN ] Resource [CodonMatrixScore *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: utr [UNKN ] Resource [DnaMatrix*] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * Arg: utr_gap [UNKN ] Resource [Score] * Arg: intron_gap [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [CdnaWise10 *] * */ CdnaWise10 * Wise2_allocate_Small_CdnaWise10(ComplexSequence* query,ComplexSequence* target ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap); #define allocate_Small_CdnaWise10 Wise2_allocate_Small_CdnaWise10 /* Function: PackAln_calculate_Small_CdnaWise10(mat,dpenv) * * Descrip: This function calculates an alignment for CdnaWise10 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_CdnaWise10 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_CdnaWise10 * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_CdnaWise10(CdnaWise10 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_CdnaWise10 Wise2_PackAln_calculate_Small_CdnaWise10 /* Function: AlnRangeSet_calculate_Small_CdnaWise10(mat) * * Descrip: This function calculates an alignment for CdnaWise10 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_CdnaWise10 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_CdnaWise10 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_CdnaWise10 * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_CdnaWise10(CdnaWise10 * mat); #define AlnRangeSet_calculate_Small_CdnaWise10 Wise2_AlnRangeSet_calculate_Small_CdnaWise10 /* Function: AlnRangeSet_from_CdnaWise10(mat) * * Descrip: This function reads off a start/end structure * for CdnaWise10 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_CdnaWise10 * If you have not calculated the matrix use * /AlnRange_calculate_Small_CdnaWise10 * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_CdnaWise10(CdnaWise10 * mat); #define AlnRangeSet_from_CdnaWise10 Wise2_AlnRangeSet_from_CdnaWise10 /* Function: convert_PackAln_to_AlnBlock_CdnaWise10(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_CdnaWise10(PackAln * pal); #define convert_PackAln_to_AlnBlock_CdnaWise10 Wise2_convert_PackAln_to_AlnBlock_CdnaWise10 /* Function: PackAln_read_Expl_CdnaWise10(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_CdnaWise10(CdnaWise10 * mat); #define PackAln_read_Expl_CdnaWise10 Wise2_PackAln_read_Expl_CdnaWise10 /* Function: PackAln_read_generic_CdnaWise10(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [CdnaWise10 *] * Arg: h [UNKN ] Undocumented argument [CdnaWise10_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_CdnaWise10(CdnaWise10 * mat,CdnaWise10_access_func_holder h); #define PackAln_read_generic_CdnaWise10 Wise2_PackAln_read_generic_CdnaWise10 /* Function: calculate_CdnaWise10(mat) * * Descrip: This function calculates the CdnaWise10 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_CdnaWise10 * * * Arg: mat [UNKN ] CdnaWise10 which contains explicit basematrix memory [CdnaWise10 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_CdnaWise10(CdnaWise10 * mat); #define calculate_CdnaWise10 Wise2_calculate_CdnaWise10 /* Function: calculate_dpenv_CdnaWise10(mat,dpenv) * * Descrip: This function calculates the CdnaWise10 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] CdnaWise10 which contains explicit basematrix memory [CdnaWise10 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_CdnaWise10(CdnaWise10 * mat,DPEnvelope * dpenv); #define calculate_dpenv_CdnaWise10 Wise2_calculate_dpenv_CdnaWise10 /* Function: CdnaWise10_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CdnaWise10 *] * */ CdnaWise10 * Wise2_CdnaWise10_alloc(void); #define CdnaWise10_alloc Wise2_CdnaWise10_alloc /* Function: free_CdnaWise10(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CdnaWise10 *] * * Return [UNKN ] Undocumented return value [CdnaWise10 *] * */ CdnaWise10 * Wise2_free_CdnaWise10(CdnaWise10 * obj); #define free_CdnaWise10 Wise2_free_CdnaWise10 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_CdnaWise10_shatter_access_main(CdnaWise10 * mat,int i,int j,int state); #define CdnaWise10_shatter_access_main Wise2_CdnaWise10_shatter_access_main int Wise2_CdnaWise10_shatter_access_special(CdnaWise10 * mat,int i,int j,int state); #define CdnaWise10_shatter_access_special Wise2_CdnaWise10_shatter_access_special void * Wise2_thread_loop_CdnaWise10(void * ptr); #define thread_loop_CdnaWise10 Wise2_thread_loop_CdnaWise10 int Wise2_score_only_CdnaWise10(ComplexSequence* query,ComplexSequence* target ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap); #define score_only_CdnaWise10 Wise2_score_only_CdnaWise10 CdnaWise10 * Wise2_allocate_CdnaWise10_only(ComplexSequence* query,ComplexSequence* target ,GeneParser4Score * gp,CodonMatrixScore * sc,RandomCodonScore * rndcodon,DnaMatrix* utr,Score gap_open,Score gap_ext,Score utr_gap,Score intron_gap); #define allocate_CdnaWise10_only Wise2_allocate_CdnaWise10_only void Wise2_init_CdnaWise10(CdnaWise10 * mat); #define init_CdnaWise10 Wise2_init_CdnaWise10 AlnRange * Wise2_AlnRange_build_CdnaWise10(CdnaWise10 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_CdnaWise10 Wise2_AlnRange_build_CdnaWise10 boolean Wise2_read_hidden_CdnaWise10(CdnaWise10 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_CdnaWise10 Wise2_read_hidden_CdnaWise10 int Wise2_max_hidden_CdnaWise10(CdnaWise10 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_CdnaWise10 Wise2_max_hidden_CdnaWise10 boolean Wise2_read_special_strip_CdnaWise10(CdnaWise10 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_CdnaWise10 Wise2_read_special_strip_CdnaWise10 int Wise2_max_special_strip_CdnaWise10(CdnaWise10 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_CdnaWise10 Wise2_max_special_strip_CdnaWise10 int Wise2_max_matrix_to_special_CdnaWise10(CdnaWise10 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_CdnaWise10 Wise2_max_matrix_to_special_CdnaWise10 void Wise2_calculate_hidden_CdnaWise10(CdnaWise10 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_CdnaWise10 Wise2_calculate_hidden_CdnaWise10 void Wise2_init_hidden_CdnaWise10(CdnaWise10 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_CdnaWise10 Wise2_init_hidden_CdnaWise10 boolean Wise2_full_dc_CdnaWise10(CdnaWise10 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_CdnaWise10 Wise2_full_dc_CdnaWise10 boolean Wise2_do_dc_single_pass_CdnaWise10(CdnaWise10 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_CdnaWise10 Wise2_do_dc_single_pass_CdnaWise10 void Wise2_push_dc_at_merge_CdnaWise10(CdnaWise10 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_CdnaWise10 Wise2_push_dc_at_merge_CdnaWise10 void Wise2_follow_on_dc_CdnaWise10(CdnaWise10 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_CdnaWise10 Wise2_follow_on_dc_CdnaWise10 void Wise2_run_up_dc_CdnaWise10(CdnaWise10 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_CdnaWise10 Wise2_run_up_dc_CdnaWise10 void Wise2_init_dc_CdnaWise10(CdnaWise10 * mat); #define init_dc_CdnaWise10 Wise2_init_dc_CdnaWise10 int Wise2_start_end_find_end_CdnaWise10(CdnaWise10 * mat,int * endj); #define start_end_find_end_CdnaWise10 Wise2_start_end_find_end_CdnaWise10 boolean Wise2_dc_optimised_start_end_calc_CdnaWise10(CdnaWise10 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_CdnaWise10 Wise2_dc_optimised_start_end_calc_CdnaWise10 void Wise2_init_start_end_linear_CdnaWise10(CdnaWise10 * mat); #define init_start_end_linear_CdnaWise10 Wise2_init_start_end_linear_CdnaWise10 AlnConvertSet * Wise2_AlnConvertSet_CdnaWise10(void); #define AlnConvertSet_CdnaWise10 Wise2_AlnConvertSet_CdnaWise10 int Wise2_CdnaWise10_explicit_access_main(CdnaWise10 * mat,int i,int j,int state); #define CdnaWise10_explicit_access_main Wise2_CdnaWise10_explicit_access_main int Wise2_CdnaWise10_explicit_access_special(CdnaWise10 * mat,int i,int j,int state); #define CdnaWise10_explicit_access_special Wise2_CdnaWise10_explicit_access_special int Wise2_find_end_CdnaWise10(CdnaWise10 * mat,int * ri,int * rj,int * state,boolean * isspecial,CdnaWise10_access_func_holder h); #define find_end_CdnaWise10 Wise2_find_end_CdnaWise10 void Wise2_CdnaWise10_debug_show_matrix(CdnaWise10 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define CdnaWise10_debug_show_matrix Wise2_CdnaWise10_debug_show_matrix int Wise2_max_calc_CdnaWise10(CdnaWise10 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,CdnaWise10_access_func_holder h); #define max_calc_CdnaWise10 Wise2_max_calc_CdnaWise10 int Wise2_max_calc_special_CdnaWise10(CdnaWise10 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,CdnaWise10_access_func_holder h); #define max_calc_special_CdnaWise10 Wise2_max_calc_special_CdnaWise10 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/geneloop6.c0000644000175000001440000107272310670453714016210 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "geneloop6.h" # line 6 "geneloop6.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define INTRON_0 3 #define INTRON_1 4 #define INTRON_2 5 #define LOOP 0 #define START 1 #define END 2 #define GeneLoop6_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+10)*6)+STATE][i+1] #define GeneLoop6_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+10] #define GeneLoop6_READ_OFF_ERROR -12 #define GeneLoop6_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+11)%11][((i+1)*6)+STATE] #define GeneLoop6_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+11)%11][STATE] #define GeneLoop6_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define GeneLoop6_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_GeneLoop6(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_GeneLoop6(GeneLoop6 * mat) { GeneLoop6_access_func_holder holder; holder.access_main = GeneLoop6_shatter_access_main; holder.access_special = GeneLoop6_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_GeneLoop6(mat,holder); } /* Function: GeneLoop6_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneLoop6_shatter_access_main(GeneLoop6 * mat,int i,int j,int state) { return GeneLoop6_SHATTER_MATRIX(mat,i,j,state); } /* Function: GeneLoop6_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneLoop6_shatter_access_special(GeneLoop6 * mat,int i,int j,int state) { return GeneLoop6_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_GeneLoop6(mat,dpenv) * * Descrip: This function calculates the GeneLoop6 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneLoop6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_GeneLoop6(GeneLoop6 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_6; int * SIG_1_5; int * SIG_1_4; int * SIG_1_2; int * SIG_1_1; int * SIG_0_3; int * SIG_0_6; int * SIG_0_5; int * SIG_0_4; int * SIG_0_2; int * SIG_0_1; int * SIG_1_0; int * SIG_0_8; int * SIG_0_9; int * SIG_0_10; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,6,lenj,3); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("GeneLoop6 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-6); SIG_1_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-5); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-6); SIG_0_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-5); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); SIG_0_8 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-8); SIG_0_9 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-9); SIG_0_10 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-10); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = GeneLoop6_SHATTER_SPECIAL(mat,i-1,j-3,LOOP) + ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = SIG_1_6[INTRON_0] + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = SIG_1_5[INTRON_1] + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = SIG_1_4[INTRON_2] + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_1[MATCH] + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_4[MATCH] + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_5[MATCH] + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[MATCH] = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLoop6_SHATTER_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = GeneLoop6_SHATTER_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = SIG_0_6[INTRON_0] + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = SIG_0_5[INTRON_1] + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = SIG_0_4[INTRON_2] + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_2[INSERT] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[INSERT] = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLoop6_SHATTER_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLoop6_SHATTER_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = SIG_0_8[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = SIG_0_8[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = SIG_0_1[INTRON_0] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_0] = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SIG_0_9[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = SIG_0_9[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = SIG_0_1[INTRON_1] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_1] = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SIG_0_10[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = SIG_0_10[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = SIG_0_1[INTRON_2] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_2] = score; /* Finished calculating state INTRON_2 */ } /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop6_SHATTER_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = GeneLoop6_SHATTER_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = GeneLoop6_SHATTER_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop6_SHATTER_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop6_SHATTER_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GeneLoop6_SHATTER_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GeneLoop6_SHATTER_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: search_GeneLoop6(dbsi,out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneLoop6 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_GeneLoop6(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_GeneLoop6 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_GeneLoop6. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_GeneLoop6. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for GeneLoop6, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_GeneLoop6(out,querydb, targetdb ,gp); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_GeneLoop6 *) ckalloc(sizeof(struct thread_pool_holder_GeneLoop6)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->gp = gp; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_GeneLoop6,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for GeneLoop6"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from GeneLoop6",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_GeneLoop6(ptr) * * Descrip: Infinite loop code foreach thread for GeneLoop6 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_GeneLoop6(void * ptr) { struct thread_pool_holder_GeneLoop6 * holder; int db_status; int score; DataScore * ds; GeneWiseScore* query; ComplexSequence* target; holder = (struct thread_pool_holder_GeneLoop6 *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneLoop6"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneLoop6"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_GeneWiseDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in GeneLoop6 search"); } query = hard_link_GeneWiseScore(holder->query); /* get query information into datascore */ dataentry_add_GeneWiseDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_GenomicDB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_GenomicDB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching GeneLoop6, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_GenomicDB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_GeneWiseScore(holder->query); /* get the next query object for the next thread */ holder->query = reload_GeneWiseDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching GeneLoop6, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_GeneWiseDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneLoop6"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneLoop6"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_GenomicDB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_GeneLoop6(query, target ,holder->gp); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for GeneLoop6"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for GeneLoop6"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneLoop6"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_GeneWiseScore(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneLoop6"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_GeneLoop6(out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneLoop6 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_GeneLoop6(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp) { GeneWiseScore* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GeneWiseDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneLoop6, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_GenomicDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneLoop6, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_GeneLoop6(query, target , gp); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("GeneLoop6 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GeneWiseDB(ds->query,query,querydb); dataentry_add_GenomicDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_GenomicDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneLoop6, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_GenomicDB(target,targetdb); query = reload_GeneWiseDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching GeneLoop6, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GeneWiseDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_GeneLoop6(query,target,gp) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_GeneLoop6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_GeneLoop6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp) { int bestscore = NEGI; int i; int j; int k; GeneLoop6 * mat; mat = allocate_GeneLoop6_only(query, target , gp); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(11,(mat->leni + 1) * 6,11,3)) == NULL) { warn("Score only matrix for GeneLoop6 cannot be allocated, (asking for 10 by %d cells)",mat->leni*6); mat = free_GeneLoop6(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<12;j++) { for(i=(-1);ileni;i++) { for(k=0;k<6;k++) GeneLoop6_VSMALL_MATRIX(mat,i,j,k) = NEGI; } GeneLoop6_VSMALL_SPECIAL(mat,i,j,LOOP) = NEGI; GeneLoop6_VSMALL_SPECIAL(mat,i,j,START) = 0; GeneLoop6_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = GeneLoop6_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = GeneLoop6_VSMALL_SPECIAL(mat,i-1,j-3,LOOP) + ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-1,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-1,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-1,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLoop6_VSMALL_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = GeneLoop6_VSMALL_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLoop6_VSMALL_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop6_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLoop6_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLoop6_VSMALL_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneLoop6_VSMALL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneLoop6_VSMALL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLoop6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneLoop6_VSMALL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of for all query positions */ /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop6_VSMALL_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = GeneLoop6_VSMALL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = GeneLoop6_VSMALL_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop6_VSMALL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop6_VSMALL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GeneLoop6_VSMALL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GeneLoop6_VSMALL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ if( bestscore < GeneLoop6_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = GeneLoop6_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_GeneLoop6(mat); return bestscore; } /* Function: PackAln_bestmemory_GeneLoop6(query,target,gp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneLoop6 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_GeneLoop6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; GeneLoop6 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 6 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_GeneLoop6(query, target , gp,dpri)) == NULL ) { warn("Unable to allocate large GeneLoop6 version"); return NULL; } calculate_dpenv_GeneLoop6(mat,dpenv); out = PackAln_read_Expl_GeneLoop6(mat); } else { mat = allocate_GeneLoop6_only(query, target , gp); calculate_shatter_GeneLoop6(mat,dpenv); out = PackAln_read_Shatter_GeneLoop6(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_GeneLoop6(query, target , gp)) == NULL ) { warn("Unable to allocate small GeneLoop6 version"); return NULL; } out = PackAln_calculate_Small_GeneLoop6(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_GeneLoop6(query, target , gp,dpri)) == NULL ) { warn("Unable to allocate large GeneLoop6 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_GeneLoop6(mat); out = PackAln_read_Expl_GeneLoop6(mat); } } } mat = free_GeneLoop6(mat); return out; } /* Function: allocate_GeneLoop6_only(query,target,gp) * * Descrip: This function only allocates the GeneLoop6 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneLoop6 *] * */ GeneLoop6 * allocate_GeneLoop6_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp) { GeneLoop6 * out; if((out= GeneLoop6_alloc()) == NULL) { warn("Allocation of basic GeneLoop6 structure failed..."); return NULL; } out->query = query; out->target = target; out->gp = gp; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_GeneLoop6(query,target,gp,dpri) * * Descrip: This function allocates the GeneLoop6 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneLoop6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneLoop6 *] * */ GeneLoop6 * allocate_Expl_GeneLoop6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPRunImpl * dpri) { GeneLoop6 * out; out = allocate_GeneLoop6_only(query, target , gp); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+10)*6 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+10)*6,(out->leni+1),3,out->lenj+10)) == NULL) { warn("Explicit matrix GeneLoop6 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_GeneLoop6(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_GeneLoop6(out); return out; } /* Function: init_GeneLoop6(mat) * * Descrip: This function initates GeneLoop6 matrix when in explicit mode * Called in /allocate_Expl_GeneLoop6 * * * Arg: mat [UNKN ] GeneLoop6 which contains explicit basematrix memory [GeneLoop6 *] * */ void init_GeneLoop6(GeneLoop6 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-10);j<11;j++) { GeneLoop6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } } for(j= (-10);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { GeneLoop6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) = NEGI; GeneLoop6_EXPL_SPECIAL(mat,i,j,START) = 0; GeneLoop6_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_GeneLoop6(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneLoop6 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * */ void recalculate_PackAln_GeneLoop6(PackAln * pal,GeneLoop6 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (LOOP+6) ) { pau->score = ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == INTRON_0 ) { pau->score = ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == INTRON_1 ) { pau->score = (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == INTRON_2 ) { pau->score = (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_INSERT_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_INSERT_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (LOOP+6) ) { pau->score = ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 6 && prev->state == INTRON_0 ) { pau->score = ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 5 && prev->state == INTRON_1 ) { pau->score = (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 4 && prev->state == INTRON_2 ) { pau->score = (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->seg[i]->transition[GW_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_0 : if( offi == 0 && offj == 8 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_0 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_1 : if( offi == 0 && offj == 9 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_1 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_2 : if( offi == 0 && offj == 10 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_2 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (LOOP+6) : if( offj == 1 && prev->state == (START+6) ) { pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } if( offj == 1 && prev->state == (LOOP+6) ) { pau->score = mat->gp->transition[GP4_LOOP2LOOP] + (0); continue; } warn("In recaluclating PackAln with state LOOP, got a bad source state. Error!"); break; case (START+6) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+6) : if( offj == 1 && prev->state == (LOOP+6) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define GeneLoop6_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+10)][(i+1)*6+state]) #define GeneLoop6_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+11)*8) % 88][(i+1)*6+state]) #define GeneLoop6_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+10)]) #define GeneLoop6_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) #define GeneLoop6_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+11)*8)+(shadow+1)) % 88)][(i+1)*6 + state]) #define GeneLoop6_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) #define GeneLoop6_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+10)% 10) * (leni+1) * 6) + ((i+1) * 6) + (state)]) #define GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+10)% 10) * (leni+1) * 48) + ((i+1) * 48) + (state * 8) + shadow+1]) #define GeneLoop6_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) /* Function: allocate_Small_GeneLoop6(query,target,gp) * * Descrip: This function allocates the GeneLoop6 structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneLoop6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneLoop6 *] * */ #define GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) GeneLoop6 * allocate_Small_GeneLoop6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp) { GeneLoop6 * out; out = allocate_GeneLoop6_only(query, target , gp); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(88,(out->leni + 1) * 6,24,out->lenj+10); if(out == NULL) { warn("Small shadow matrix GeneLoop6 cannot be allocated, (asking for 11 by %d main cells)",out->leni+2); free_GeneLoop6(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_GeneLoop6(mat,dpenv) * * Descrip: This function calculates an alignment for GeneLoop6 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneLoop6 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneLoop6 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_GeneLoop6(GeneLoop6 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for GeneLoop6 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneLoop6(mat,dpenv); score = start_end_find_end_GeneLoop6(mat,&endj); out->score = score; stopstate = END; /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */ log_full_error(REPORT,0,"End at %d Score %d",endj,score); stop_reporting(); for(;;) { /*while there are more special bits to recover*/ start_reporting("Special cell aln end %d:",endj); if( read_special_strip_GeneLoop6(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) { warn("Problem in reading off special state system... going to return partial alignment"); break; } if( startstate == START || endj <= 0) { log_full_error(REPORT,0,"Recovered complete alignment"); stop_reporting(); break; } log_full_error(REPORT,0,"Finished to %d",endj); stop_reporting(); /* Ok... have to eat up another piece of matrix */ temp = startstate; starti = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0); startj = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1); startstate = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2); stopi = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3); stopj = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4); stopstate = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5); /* Get out the score of this block. V. important! */ temp = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6); totalj = stopj - startj; donej = 0; start_reporting("Main matrix aln [%d,%d]:",startj,stopj); if(full_dc_GeneLoop6(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) { warn("In the alignment GeneLoop6 [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj); return out; } /* now have to figure out which special we came from... yikes */ max_matrix_to_special_GeneLoop6(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == GeneLoop6_READ_OFF_ERROR) { warn("In GeneLoop6 read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj); invert_PackAln(out); recalculate_PackAln_GeneLoop6(out,mat); return out; } /* if at start, break, otherwise, back to eat another strip */ if( stopstate == START) { log_full_error(REPORT,0,"Recovered complete alignment "); stop_reporting(); break; } log_full_error(REPORT,0,"Finished alignment to %d ",startj); stop_reporting(); endj = stopj; /* stopstate is correct as it is */ } /* end of while there are more special bits to recover */ invert_PackAln(out); recalculate_PackAln_GeneLoop6(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_GeneLoop6(mat) * * Descrip: This function calculates an alignment for GeneLoop6 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneLoop6 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneLoop6 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneLoop6 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_GeneLoop6(GeneLoop6 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneLoop6(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_GeneLoop6(mat); return out; } /* Function: AlnRangeSet_from_GeneLoop6(mat) * * Descrip: This function reads off a start/end structure * for GeneLoop6 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneLoop6 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneLoop6 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_GeneLoop6(GeneLoop6 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneLoop6"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_GeneLoop6(mat,&jpos); state = END; while( (temp = AlnRange_build_GeneLoop6(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_GeneLoop6(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_GeneLoop6 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_GeneLoop6(GeneLoop6 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneLoop6"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_GeneLoop6(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_GeneLoop6 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = GeneLoop6_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_GeneLoop6(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == GeneLoop6_READ_OFF_ERROR) { warn("In AlnRange_build_GeneLoop6 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = GeneLoop6_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_GeneLoop6(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_GeneLoop6(GeneLoop6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_GeneLoop6(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneLoop6_READ_OFF_ERROR) { warn("In GeneLoop6 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In GeneLoop6 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In GeneLoop6 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_GeneLoop6(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_GeneLoop6(GeneLoop6 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneLoop6_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneLoop6 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = GeneLoop6_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp->transition[GP4_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-5,MATCH); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->gp->transition[GP4_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-4,MATCH); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } temp = cscore - ((mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON_2) ) { *reti = i - 1; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-4,INTRON_2); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON_2); } temp = cscore - ((mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON_1) ) { *reti = i - 1; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-5,INTRON_1); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON_1); } temp = cscore - (((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON_0) ) { *reti = i - 1; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-6,INTRON_0); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON_0); } /* Not allowing special sources.. skipping LOOP */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } temp = cscore - ((mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2); } temp = cscore - ((mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1); } temp = cscore - (((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0); } /* Not allowing special sources.. skipping LOOP */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-3,DELETE); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-8,INSERT); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-8,MATCH); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-9,INSERT); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-9,MATCH); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-10,INSERT); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-10,MATCH); } return GeneLoop6_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_GeneLoop6(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_GeneLoop6(GeneLoop6 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } max_special_strip_GeneLoop6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneLoop6_READ_OFF_ERROR) { warn("In special strip read GeneLoop6, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read GeneLoop6, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_GeneLoop6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_GeneLoop6(GeneLoop6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = GeneLoop6_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for GeneLoop6, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In GeneLoop6 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = GeneLoop6_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case LOOP : /* source LOOP is a special */ temp = cscore - (mat->gp->transition[GP4_LOOP2LOOP]) - (0); if( temp == GeneLoop6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_DC_SHADOW_SPECIAL(mat,i-0,j-1,LOOP); } return GeneLoop6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,LOOP) ; } /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ /* source START is a special */ temp = cscore - (0) - (0); if( temp == GeneLoop6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return GeneLoop6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } case START : case END : /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == GeneLoop6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_DC_SHADOW_SPECIAL(mat,i-0,j-1,LOOP); } return GeneLoop6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,LOOP) ; } default: warn("Major problem (!) - in GeneLoop6 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_GeneLoop6(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_GeneLoop6(GeneLoop6 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = GeneLoop6_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In GeneLoop6 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ temp = cscore - (((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,LOOP) ) { *reti = i - 1; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_DC_SHADOW_SPECIAL(mat,i-1,j-3,LOOP); } return GeneLoop6_DC_SHADOW_MATRIX(mat,i - 1,j - 3,LOOP) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ temp = cscore - (((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,LOOP) ) { *reti = i - 0; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop6_DC_SHADOW_SPECIAL(mat,i-0,j-3,LOOP); } return GeneLoop6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,LOOP) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : /* Source INTRON_0 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : /* Source INTRON_1 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : /* Source INTRON_2 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_GeneLoop6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_GeneLoop6(GeneLoop6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_GeneLoop6(mat,starti,startj,stopi,stopj); GeneLoop6_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneLoop6_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop6_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop6_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLoop6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLoop6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLoop6_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneLoop6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneLoop6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLoop6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneLoop6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } } return; } /* Function: init_hidden_GeneLoop6(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_GeneLoop6(GeneLoop6 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-10);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { GeneLoop6_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop6_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop6_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLoop6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLoop6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; } } return; } /* Function: full_dc_GeneLoop6(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_GeneLoop6 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_GeneLoop6 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [GeneLoop6 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_GeneLoop6(GeneLoop6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_GeneLoop6"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 50) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_GeneLoop6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_GeneLoop6(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_GeneLoop6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for GeneLoop6, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= GeneLoop6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= GeneLoop6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_GeneLoop6(mat,GeneLoop6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),GeneLoop6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),GeneLoop6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_GeneLoop6(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_GeneLoop6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_GeneLoop6(GeneLoop6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_GeneLoop6(mat); GeneLoop6_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_GeneLoop6(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_GeneLoop6(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_GeneLoop6(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_GeneLoop6(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_GeneLoop6(GeneLoop6 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<10;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-100); GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = (-100); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-100); GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = (-100); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-100); GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-6; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_2; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-6; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_2; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ /* For state INTRON_0, pushing when j - offj <= mergej */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( j - 8 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = MATCH; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 8 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INSERT; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INTRON_0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } } /* Add any movement independant score */ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished with state INTRON_0 */ /* For state INTRON_1, pushing when j - offj <= mergej */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( j - 9 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = MATCH; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 9 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INSERT; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INTRON_1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } } /* Add any movement independant score */ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished with state INTRON_1 */ /* For state INTRON_2, pushing when j - offj <= mergej */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( j - 10 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = MATCH; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 10 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INSERT; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } } temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-1; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INTRON_2; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } } /* Add any movement independant score */ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished with state INTRON_2 */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_GeneLoop6(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_GeneLoop6(GeneLoop6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state INTRON_0 to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,k); } /* From state INTRON_1 to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,k); } /* From state INTRON_2 to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,k); } /* From state MATCH to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state DELETE to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } /* From state INTRON_0 to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } /* From state INTRON_1 to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } /* From state INTRON_2 to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } /* From state INSERT to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); /* From state INSERT to state INTRON_0 */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); /* From state INSERT to state INTRON_1 */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); /* From state INSERT to state INTRON_2 */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_GeneLoop6(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_GeneLoop6(GeneLoop6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLoop6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_GeneLoop6(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * */ } void init_dc_GeneLoop6(GeneLoop6 * mat) { register int i; register int j; register int k; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; for(k=0;k<7;k++) { GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = (-1); GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = (-1); GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = (-1); } } } return; } /* Function: start_end_find_end_GeneLoop6(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [GeneLoop6 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_GeneLoop6(GeneLoop6 * mat,int * endj) { register int j; register int max; register int maxj; max = GeneLoop6_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( GeneLoop6_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = GeneLoop6_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_GeneLoop6(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [GeneLoop6] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_GeneLoop6(GeneLoop6 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (10 * (leni + 1) * 6,sizeof(int)); shadow_pointers = (int *) calloc (10 * (leni + 1) * 6 * 8,sizeof(int)); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state LOOP to state MATCH */ temp = GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,LOOP) + ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [LOOP] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_0 to state MATCH */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,0)); } /* From state INTRON_1 to state MATCH */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,0)); } /* From state INTRON_2 to state MATCH */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,0)); } /* From state MATCH to state MATCH */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state DELETE to state INSERT */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0)); } /* From state LOOP to state INSERT */ temp = GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [LOOP] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_0 to state INSERT */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,0)); } /* From state INTRON_1 to state INSERT */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,0)); } /* From state INTRON_2 to state INSERT */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,0)); } /* From state INSERT to state INSERT */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = DELETE; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,0)); /* From state INSERT to state INTRON_0 */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,0)); } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,0)); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,0)); /* From state INSERT to state INTRON_1 */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,0)); } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,0)); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,0)); /* From state INSERT to state INTRON_2 */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0)); } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,0)); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) GeneLoop6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of for each i position in strip */ /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ temp = GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,START,k); } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,LOOP,k); } /* Put back score... (now updated!) */ GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ temp = GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneLoop6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,LOOP,k); } /* Put back score... (now updated!) */ GeneLoop6_DC_OPT_SHADOW_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_GeneLoop6(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * */ void init_start_end_linear_GeneLoop6(GeneLoop6 * mat) { register int i; register int j; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-1); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-1); GeneLoop6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; GeneLoop6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-1); } } for(j=(-10);jtarget->seq->len;j++) { GeneLoop6_DC_SHADOW_SPECIAL(mat,0,j,LOOP) = NEGI; GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,j,LOOP,0) = (-1); GeneLoop6_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; GeneLoop6_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; GeneLoop6_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_GeneLoop6(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_GeneLoop6(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_GeneLoop6(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","INTRON_STATE","LOOP_STATE","END" }; /* Function: AlnConvertSet_GeneLoop6(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","5SS_PHASE_0","CENTRAL_INTRON","5SS_PHASE_1","5SS_PHASE_2","RANDOM_SEQUENCE","END" }; AlnConvertSet * AlnConvertSet_GeneLoop6(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 6; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = MATCH; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 6; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INSERT; acu->offi = 0; acu->offj = 6; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->state2 = LOOP + 6; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = LOOP + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = LOOP + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = LOOP + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 6; acu->state2 = LOOP + 6; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 6; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[12]; add_collapse_label_AlnConvertSet(out,"INTRON_STATE","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"LOOP_STATE","RANDOM_SEQUENCE"); return out; } /* Function: PackAln_read_Expl_GeneLoop6(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_GeneLoop6(GeneLoop6 * mat) { GeneLoop6_access_func_holder holder; holder.access_main = GeneLoop6_explicit_access_main; holder.access_special = GeneLoop6_explicit_access_special; return PackAln_read_generic_GeneLoop6(mat,holder); } /* Function: GeneLoop6_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneLoop6_explicit_access_main(GeneLoop6 * mat,int i,int j,int state) { return GeneLoop6_EXPL_MATRIX(mat,i,j,state); } /* Function: GeneLoop6_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneLoop6_explicit_access_special(GeneLoop6 * mat,int i,int j,int state) { return GeneLoop6_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_GeneLoop6(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: h [UNKN ] Undocumented argument [GeneLoop6_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_GeneLoop6(GeneLoop6 * mat,GeneLoop6_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_GeneLoop6(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in GeneLoop6_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_GeneLoop6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_GeneLoop6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == GeneLoop6_READ_OFF_ERROR || j == GeneLoop6_READ_OFF_ERROR || state == GeneLoop6_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in GeneLoop6_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_GeneLoop6(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [GeneLoop6_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_GeneLoop6(GeneLoop6 * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneLoop6_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: GeneLoop6_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void GeneLoop6_debug_show_matrix(GeneLoop6 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",GeneLoop6_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",GeneLoop6_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",GeneLoop6_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"State INTRON_0 %d\n",GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_0)); fprintf(ofp,"State INTRON_1 %d\n",GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_1)); fprintf(ofp,"State INTRON_2 %d\n",GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_2)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_GeneLoop6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneLoop6_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_GeneLoop6(GeneLoop6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneLoop6_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneLoop6_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneLoop6 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp->transition[GP4_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,MATCH); } return (*h.access_main)(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->gp->transition[GP4_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH); } return (*h.access_main)(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } temp = cscore - ((mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,INTRON_2) ) { *reti = i - 1; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,INTRON_2); } return (*h.access_main)(mat,i - 1,j - 4,INTRON_2); } temp = cscore - ((mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,INTRON_1) ) { *reti = i - 1; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,INTRON_1); } return (*h.access_main)(mat,i - 1,j - 5,INTRON_1); } temp = cscore - (((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,INTRON_0) ) { *reti = i - 1; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,INTRON_0); } return (*h.access_main)(mat,i - 1,j - 6,INTRON_0); } temp = cscore - (((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 1,j - 3,LOOP) ) { *reti = i - 1; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,LOOP); } return (*h.access_main)(mat,i - 1,j - 3,LOOP); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - ((mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 4,INTRON_2); } temp = cscore - ((mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 5,INTRON_1); } temp = cscore - (((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-6,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 6,INTRON_0); } temp = cscore - (((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 0,j - 3,LOOP) ) { *reti = i - 0; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,LOOP); } return (*h.access_main)(mat,i - 0,j - 3,LOOP); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE); } return (*h.access_main)(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,INSERT); } return (*h.access_main)(mat,i - 0,j - 8,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,MATCH); } return (*h.access_main)(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,INSERT); } return (*h.access_main)(mat,i - 0,j - 9,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,MATCH); } return (*h.access_main)(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT); } return (*h.access_main)(mat,i - 0,j - 10,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,MATCH); } return (*h.access_main)(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_GeneLoop6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneLoop6_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_GeneLoop6(GeneLoop6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneLoop6_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneLoop6_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In GeneLoop6 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case LOOP : /* source LOOP is a special */ temp = cscore - (mat->gp->transition[GP4_LOOP2LOOP]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,LOOP); } return (*h.access_special)(mat,i - 0,j - 1,LOOP) ; } /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ /* source START is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_special)(mat,i - 0,j - 1,START) ; } case START : case END : /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,LOOP); } return (*h.access_special)(mat,i - 0,j - 1,LOOP) ; } default: warn("Major problem (!) - in GeneLoop6 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_GeneLoop6(mat) * * Descrip: This function calculates the GeneLoop6 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneLoop6 * * * Arg: mat [UNKN ] GeneLoop6 which contains explicit basematrix memory [GeneLoop6 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_GeneLoop6(GeneLoop6 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneLoop6, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("GeneLoop6 Matrix calculation: "); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = GeneLoop6_EXPL_SPECIAL(mat,i-1,j-3,LOOP) + ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop6_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = GeneLoop6_EXPL_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop6_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLoop6_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLoop6_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLoop6_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLoop6_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop6_EXPL_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = GeneLoop6_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = GeneLoop6_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop6_EXPL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop6_EXPL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GeneLoop6_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GeneLoop6_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_GeneLoop6(mat,dpenv) * * Descrip: This function calculates the GeneLoop6 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneLoop6 which contains explicit basematrix memory [GeneLoop6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_GeneLoop6(GeneLoop6 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneLoop6, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-10;jleni;i++) { GeneLoop6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } } for(j=-10;jlenj;j++) { GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) = NEGI; GeneLoop6_EXPL_SPECIAL(mat,i,j,START) = 0; GeneLoop6_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("GeneLoop6 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { GeneLoop6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = GeneLoop6_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = GeneLoop6_EXPL_SPECIAL(mat,i-1,j-3,LOOP) + ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop6_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = GeneLoop6_EXPL_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + ((mat->gp->transition[GP4_INTRON2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + (mat->gp->transition[GP4_INTRON2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop6_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop6_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneLoop6_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLoop6_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) ) { GeneLoop6_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneLoop6_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneLoop6_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneLoop6_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneLoop6_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneLoop6_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop6_EXPL_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = GeneLoop6_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = GeneLoop6_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop6_EXPL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop6_EXPL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GeneLoop6_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GeneLoop6_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: GeneLoop6_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneLoop6 *] * */ GeneLoop6 * GeneLoop6_alloc(void) { GeneLoop6 * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneLoop6 *) ckalloc (sizeof(GeneLoop6))) == NULL) { warn("GeneLoop6_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_GeneLoop6(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneLoop6 *] * * Return [UNKN ] Undocumented return value [GeneLoop6 *] * */ GeneLoop6 * free_GeneLoop6(GeneLoop6 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneLoop6 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->gp is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/geneloop6.h0000644000175000001440000004465510670453714016217 0ustar philippusers#ifndef DYNAMITEgeneloop6HEADERFILE #define DYNAMITEgeneloop6HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "geneparser4.h" #include "genewisemodel.h" #include "genewisemodeldb.h" struct Wise2_GeneLoop6 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GeneWiseScore* query; ComplexSequence* target; GeneParser4Score * gp; } ; /* GeneLoop6 defined */ #ifndef DYNAMITE_DEFINED_GeneLoop6 typedef struct Wise2_GeneLoop6 Wise2_GeneLoop6; #define GeneLoop6 Wise2_GeneLoop6 #define DYNAMITE_DEFINED_GeneLoop6 #endif #ifdef PTHREAD struct thread_pool_holder_GeneLoop6 { GeneWiseScore* query; /* Query object placeholder */ GeneWiseDB* querydb;/* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ GenomicDB* targetdb;/* Target database object */ boolean target_init; GeneParser4Score * gp; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_GeneLoop6_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(GeneLoop6*,int,int,int); int (*access_special)(GeneLoop6*,int,int,int); } ; /* GeneLoop6_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_GeneLoop6_access_func_holder typedef struct Wise2_GeneLoop6_access_func_holder Wise2_GeneLoop6_access_func_holder; #define GeneLoop6_access_func_holder Wise2_GeneLoop6_access_func_holder #define DYNAMITE_DEFINED_GeneLoop6_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_GeneLoop6(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_GeneLoop6(GeneLoop6 * mat); #define PackAln_read_Shatter_GeneLoop6 Wise2_PackAln_read_Shatter_GeneLoop6 /* Function: calculate_shatter_GeneLoop6(mat,dpenv) * * Descrip: This function calculates the GeneLoop6 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneLoop6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_GeneLoop6(GeneLoop6 * mat,DPEnvelope * dpenv); #define calculate_shatter_GeneLoop6 Wise2_calculate_shatter_GeneLoop6 /* Function: search_GeneLoop6(dbsi,out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneLoop6 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_GeneLoop6(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp); #define search_GeneLoop6 Wise2_search_GeneLoop6 /* Function: serial_search_GeneLoop6(out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneLoop6 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_GeneLoop6(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp); #define serial_search_GeneLoop6 Wise2_serial_search_GeneLoop6 /* Function: PackAln_bestmemory_GeneLoop6(query,target,gp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneLoop6 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_GeneLoop6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_GeneLoop6 Wise2_PackAln_bestmemory_GeneLoop6 /* Function: allocate_Expl_GeneLoop6(query,target,gp,dpri) * * Descrip: This function allocates the GeneLoop6 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneLoop6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneLoop6 *] * */ GeneLoop6 * Wise2_allocate_Expl_GeneLoop6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPRunImpl * dpri); #define allocate_Expl_GeneLoop6 Wise2_allocate_Expl_GeneLoop6 /* Function: recalculate_PackAln_GeneLoop6(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneLoop6 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * */ void Wise2_recalculate_PackAln_GeneLoop6(PackAln * pal,GeneLoop6 * mat); #define recalculate_PackAln_GeneLoop6 Wise2_recalculate_PackAln_GeneLoop6 /* Function: allocate_Small_GeneLoop6(query,target,gp) * * Descrip: This function allocates the GeneLoop6 structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneLoop6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneLoop6 *] * */ GeneLoop6 * Wise2_allocate_Small_GeneLoop6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp); #define allocate_Small_GeneLoop6 Wise2_allocate_Small_GeneLoop6 /* Function: PackAln_calculate_Small_GeneLoop6(mat,dpenv) * * Descrip: This function calculates an alignment for GeneLoop6 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneLoop6 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneLoop6 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_GeneLoop6(GeneLoop6 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_GeneLoop6 Wise2_PackAln_calculate_Small_GeneLoop6 /* Function: AlnRangeSet_calculate_Small_GeneLoop6(mat) * * Descrip: This function calculates an alignment for GeneLoop6 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneLoop6 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneLoop6 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneLoop6 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_GeneLoop6(GeneLoop6 * mat); #define AlnRangeSet_calculate_Small_GeneLoop6 Wise2_AlnRangeSet_calculate_Small_GeneLoop6 /* Function: AlnRangeSet_from_GeneLoop6(mat) * * Descrip: This function reads off a start/end structure * for GeneLoop6 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneLoop6 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneLoop6 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_GeneLoop6(GeneLoop6 * mat); #define AlnRangeSet_from_GeneLoop6 Wise2_AlnRangeSet_from_GeneLoop6 /* Function: convert_PackAln_to_AlnBlock_GeneLoop6(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_GeneLoop6(PackAln * pal); #define convert_PackAln_to_AlnBlock_GeneLoop6 Wise2_convert_PackAln_to_AlnBlock_GeneLoop6 /* Function: PackAln_read_Expl_GeneLoop6(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_GeneLoop6(GeneLoop6 * mat); #define PackAln_read_Expl_GeneLoop6 Wise2_PackAln_read_Expl_GeneLoop6 /* Function: PackAln_read_generic_GeneLoop6(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop6 *] * Arg: h [UNKN ] Undocumented argument [GeneLoop6_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_GeneLoop6(GeneLoop6 * mat,GeneLoop6_access_func_holder h); #define PackAln_read_generic_GeneLoop6 Wise2_PackAln_read_generic_GeneLoop6 /* Function: calculate_GeneLoop6(mat) * * Descrip: This function calculates the GeneLoop6 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneLoop6 * * * Arg: mat [UNKN ] GeneLoop6 which contains explicit basematrix memory [GeneLoop6 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_GeneLoop6(GeneLoop6 * mat); #define calculate_GeneLoop6 Wise2_calculate_GeneLoop6 /* Function: calculate_dpenv_GeneLoop6(mat,dpenv) * * Descrip: This function calculates the GeneLoop6 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneLoop6 which contains explicit basematrix memory [GeneLoop6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_GeneLoop6(GeneLoop6 * mat,DPEnvelope * dpenv); #define calculate_dpenv_GeneLoop6 Wise2_calculate_dpenv_GeneLoop6 /* Function: GeneLoop6_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneLoop6 *] * */ GeneLoop6 * Wise2_GeneLoop6_alloc(void); #define GeneLoop6_alloc Wise2_GeneLoop6_alloc /* Function: free_GeneLoop6(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneLoop6 *] * * Return [UNKN ] Undocumented return value [GeneLoop6 *] * */ GeneLoop6 * Wise2_free_GeneLoop6(GeneLoop6 * obj); #define free_GeneLoop6 Wise2_free_GeneLoop6 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_GeneLoop6_shatter_access_main(GeneLoop6 * mat,int i,int j,int state); #define GeneLoop6_shatter_access_main Wise2_GeneLoop6_shatter_access_main int Wise2_GeneLoop6_shatter_access_special(GeneLoop6 * mat,int i,int j,int state); #define GeneLoop6_shatter_access_special Wise2_GeneLoop6_shatter_access_special void * Wise2_thread_loop_GeneLoop6(void * ptr); #define thread_loop_GeneLoop6 Wise2_thread_loop_GeneLoop6 int Wise2_score_only_GeneLoop6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp); #define score_only_GeneLoop6 Wise2_score_only_GeneLoop6 GeneLoop6 * Wise2_allocate_GeneLoop6_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp); #define allocate_GeneLoop6_only Wise2_allocate_GeneLoop6_only void Wise2_init_GeneLoop6(GeneLoop6 * mat); #define init_GeneLoop6 Wise2_init_GeneLoop6 AlnRange * Wise2_AlnRange_build_GeneLoop6(GeneLoop6 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_GeneLoop6 Wise2_AlnRange_build_GeneLoop6 boolean Wise2_read_hidden_GeneLoop6(GeneLoop6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_GeneLoop6 Wise2_read_hidden_GeneLoop6 int Wise2_max_hidden_GeneLoop6(GeneLoop6 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_GeneLoop6 Wise2_max_hidden_GeneLoop6 boolean Wise2_read_special_strip_GeneLoop6(GeneLoop6 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_GeneLoop6 Wise2_read_special_strip_GeneLoop6 int Wise2_max_special_strip_GeneLoop6(GeneLoop6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_GeneLoop6 Wise2_max_special_strip_GeneLoop6 int Wise2_max_matrix_to_special_GeneLoop6(GeneLoop6 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_GeneLoop6 Wise2_max_matrix_to_special_GeneLoop6 void Wise2_calculate_hidden_GeneLoop6(GeneLoop6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_GeneLoop6 Wise2_calculate_hidden_GeneLoop6 void Wise2_init_hidden_GeneLoop6(GeneLoop6 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_GeneLoop6 Wise2_init_hidden_GeneLoop6 boolean Wise2_full_dc_GeneLoop6(GeneLoop6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_GeneLoop6 Wise2_full_dc_GeneLoop6 boolean Wise2_do_dc_single_pass_GeneLoop6(GeneLoop6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_GeneLoop6 Wise2_do_dc_single_pass_GeneLoop6 void Wise2_push_dc_at_merge_GeneLoop6(GeneLoop6 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_GeneLoop6 Wise2_push_dc_at_merge_GeneLoop6 void Wise2_follow_on_dc_GeneLoop6(GeneLoop6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_GeneLoop6 Wise2_follow_on_dc_GeneLoop6 void Wise2_run_up_dc_GeneLoop6(GeneLoop6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_GeneLoop6 Wise2_run_up_dc_GeneLoop6 void Wise2_init_dc_GeneLoop6(GeneLoop6 * mat); #define init_dc_GeneLoop6 Wise2_init_dc_GeneLoop6 int Wise2_start_end_find_end_GeneLoop6(GeneLoop6 * mat,int * endj); #define start_end_find_end_GeneLoop6 Wise2_start_end_find_end_GeneLoop6 boolean Wise2_dc_optimised_start_end_calc_GeneLoop6(GeneLoop6 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_GeneLoop6 Wise2_dc_optimised_start_end_calc_GeneLoop6 void Wise2_init_start_end_linear_GeneLoop6(GeneLoop6 * mat); #define init_start_end_linear_GeneLoop6 Wise2_init_start_end_linear_GeneLoop6 AlnConvertSet * Wise2_AlnConvertSet_GeneLoop6(void); #define AlnConvertSet_GeneLoop6 Wise2_AlnConvertSet_GeneLoop6 int Wise2_GeneLoop6_explicit_access_main(GeneLoop6 * mat,int i,int j,int state); #define GeneLoop6_explicit_access_main Wise2_GeneLoop6_explicit_access_main int Wise2_GeneLoop6_explicit_access_special(GeneLoop6 * mat,int i,int j,int state); #define GeneLoop6_explicit_access_special Wise2_GeneLoop6_explicit_access_special int Wise2_find_end_GeneLoop6(GeneLoop6 * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneLoop6_access_func_holder h); #define find_end_GeneLoop6 Wise2_find_end_GeneLoop6 void Wise2_GeneLoop6_debug_show_matrix(GeneLoop6 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define GeneLoop6_debug_show_matrix Wise2_GeneLoop6_debug_show_matrix int Wise2_max_calc_GeneLoop6(GeneLoop6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneLoop6_access_func_holder h); #define max_calc_GeneLoop6 Wise2_max_calc_GeneLoop6 int Wise2_max_calc_special_GeneLoop6(GeneLoop6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneLoop6_access_func_holder h); #define max_calc_special_GeneLoop6 Wise2_max_calc_special_GeneLoop6 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/GNULICENSE0000644000175000001440000004307607313404542015516 0ustar philippusers GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. wise-2.4.1/src/models/gwrap.dy0000644000175000001440000004555510413710424015613 0ustar philippusers/* Last edited: Apr 24 10:20 1997 (birney) */ %{ #include "dyna.h" #include "genewise6.h" #include "geneloop6.h" #include "genestretch6.h" #include "genewise4.h" #include "gwlite.h" #include "geneutil.h" #include "genewise21.h" #include "geneloop21.h" /** #include "genelink21.h" **/ #include "geneparameter.h" #include "genefrequency.h" #include "genestats.h" #include "seqhit.h" #include "estwise3.h" #include "estloop3.h" #include "genewisehsp.h" enum GWWRAP_ALG_TYPE { GWWRAP_2193 = 12, GWWRAP_2193L, GWWRAP_2193I, GWWRAP_623, GWWRAP_623L, GWWRAP_421, GWWRAP_6LITE, GWWRAP_333, GWWRAP_333L, GWWRAP_623S, GWWRAP_623P }; %} %{ #include "gwrap.h" %func A general wrap over the production of parameters for the GeneWise programs. The geneparameter21 holds all the parameters, and can be approximated for the 6:23 and 4:21 algorithms This function is the best way to make a GeneParameter21 object as all the different options for how to make it or modify its contents are laid out as arguments to this function %arg gf r Gene Frequency data structure, holding counts for splice sites etc subs_error substitution error on the dna sequence indel_error rough estimate of the insertion/deletion per base error rate rmd the random model of the DNA that is used use_modelled_codon if TRUE, model codon frequency use_modelled_splice if TRUE, make splice models from gf parameters ct codon table which is used for codon->aa mapping return A newly allocated structure %% GeneParameter21 * GeneParameter21_wrap(GeneFrequency21 * gf,double subs_error,double indel_error,RandomModelDNA * rmd,boolean use_modelled_codon,boolean use_modelled_splice,boolean tie_intron_prob,CodonTable * ct,Probability rnd_loop,Probability cds_loop,Probability rnd_to_model,Probability link_loop,Probability link_to_model) { GeneParameter21 * out; int i; out = GeneParameter21_from_GeneFrequency21(gf,ct,rmd,rnd_loop,cds_loop,rnd_to_model,link_loop,link_to_model); if( use_modelled_codon == FALSE ) { out->cm = free_CodonMapper(out->cm); out->cm = flat_CodonMapper(ct); } if( use_modelled_splice == FALSE ) { out->cses = free_ComplexSequenceEvalSet(out->cses); out->cses = default_genomic_ComplexSequenceEvalSet(); out->modelled_splice = FALSE; } if( tie_intron_prob == TRUE ) { for(i=0;i<5;i++) out->gp->central[i] = rmd->base[i]; } /*** errors ***/ sprinkle_errors_over_CodonMapper(out->cm,subs_error); add_flat_error_probabilities_GeneParser21(out->gp,indel_error); GeneParser21_fold_in_RandomModelDNA(out->gp,rmd); fold_in_RandomModelDNA_into_RandomCodon(out->rc,rmd); return out; } %func A function which aligns a Protein sequecne to a Genomic sequence under the Comparison matrix comp and the gene paras in gpara. This is the best function for accessing GeneWise functionality for a protein to dna comparison, allowing for introns. To make the protein object, you will first read in a generic sequence object using something like read_fasta_Sequence and then convert it to a protein object using new_Protein_from_Sequence To make the genomic object, you will first read in a generic sequence object using something like read_fasta_Sequence and then convert it to a genomic object using new_Genomic_from_Sequence To make a CompMat object you will use read_Blast_file_CompMat from the compmat module. It is likely, if the Wise2 enviroment has been set up correctly that read_Blast_file_CompMat("blosum62.bla") will be fine. You should at the moment only use halfbit matrices (blosum62 is one such matrix) To make the necessary random modules use the default construtors in the randommodel module To make the gene parameter object use the GeneParameter21_wrap function found in this module. It will need GeneFrequencies read in using the read_GeneFrequency21_file function in the genefrequency module. Again if Wise2 has been set up correctly, read_GeneFrequency21_file("human.gf") should work To again a valid algorithm type use gwrap_alg_type_from_string found in this module. gwrap_alg_type_from_string("623") would be a good choice This function basically makes a threestatemodel (standard HMM) from the protein and the comparison matrix with the *scary* assumption that the comparison matrix is in half bit form. It then calls /AlnBlock_from_TSM_genewise_wrap to do the nasty stuff. %arg protein protein sequence used in the comparison dna genomic DNA sequence used comp protein comparison matrix *in half bits* gap gap penalty (negative) ext extension penalty (negative) gpara Gene parameters. rmd models to be compared to intergenic model of random dna between genes alg algorithm type is_global has now become flag for local/global/end-biased switch pg r Potential gene - could be NULL - if rough exon positions are known pal wN Raw alginment to be saved if non-NULL %% AlnBlock * AlnBlock_from_protein_genewise_wrap(Protein * protein,Genomic * dna,CompMat * comp,int gap,int ext,GeneParameter21 * gpara,RandomModelDNA * rmd,RandomModelDNA * intergenic,int alg,boolean use_syn,RandomModel * rm,Probability allN,TSM_StartEndMode startendmode,DPRunImpl * dpri,PackAln ** pal,GeneWiseRunPara * gwp) { ThreeStateModel * tsm; RandomModel * rm2; AlnBlock * out; DPEnvelope * dpenv = NULL; if( protein == NULL || dna == NULL || comp == NULL || gpara == NULL || rmd == NULL ){ warn("trappable error in PackAln from protein sequence, passed some NULL objects, Complain!"); return NULL; } assert(dpri); rm2 = default_RandomModel(); if( gwp->use_hsp == TRUE ) { dpenv = DPEnvelope_from_protein_gen(protein->baseseq,dna->baseseq,comp,gpara->ct,gwp); } if( startendmode == TSM_default ) { startendmode = TSM_endbiased; } tsm = ThreeStateModel_from_half_bit_Sequence(protein,comp,rm2,gap,ext); set_startend_policy_ThreeStateModel(tsm,startendmode,30,halfbit2Probability(-15)); out = AlnBlock_from_TSM_genewise_wrap(tsm,dna,gpara,rmd,intergenic,use_syn,alg,allN,1,dpri,pal,dpenv); free_ThreeStateModel(tsm); free_RandomModel(rm2); return out; } %func A function which aligns a protein HMM (as found in my threestatemodel structure) to a genomic DNA sequence. At the moment you are unlikely to be reading in the HMM structure yourself, so this is not something you will be doing. The core algorithms for each method are found in genewise21/geneloop21 etc files. %arg tsm protein TSM to be used in the comparison gen genomic DNA sequence used gpara Gene parameters. rmd models to be compared to intergenic model of random dna between genes alg algorithm type use_syn use a synchronous null model palpoi wN Raw alginment to be saved if non-NULL %% AlnBlock * AlnBlock_from_TSM_genewise_wrap(ThreeStateModel * tsm,Genomic * gen,GeneParameter21 * gpara,RandomModelDNA * rmd,RandomModelDNA * intergenic,boolean use_syn,int alg,Probability allN,boolean flat_insert,DPRunImpl * dpri,PackAln ** palpoi,DPEnvelope * dpenv) { AlnBlock * out = NULL; PackAln * pal = NULL; ComplexSequence * cs = NULL; GeneWise * gw = NULL; GeneWiseScore * gws = NULL; RandomCodonScore * rcs = NULL ; GeneParser21Score * gps = NULL; GeneParser4Score * gp4s = NULL; RandomModelDNAScore * ids = NULL; GeneralGeneModelScore * ggms = NULL; /* for stretch models */ Sequence * dna; cDNAParserScore * cps = NULL; /* for estwise type algorithms */ GwLite * gwl = NULL; GwLiteScore * gwls = NULL; ComplexSequenceEval * tempcse; ComplexSequenceEvalSet * cses; dna = gen->baseseq; assert(tsm); assert(gen); assert(gpara); assert(rmd); assert(gpara->rc); assert(dpri); /*show_Genomic(gen,stderr);*/ /*show_GeneParser21(gpara->gp,stderr); */ if( tsm == NULL || dna == NULL || gpara == NULL || rmd == NULL){ warn("trappable error in PackAln from TSM sequence, passed some NULL objects, Complain!"); return NULL; } /*** prepare cses ***/ if( prepare_ComplexSequenceEvalSet(gpara->cses) == FALSE ) { warn("Unable to prepare complexsequenceevalset in TMS2DNA wrap"); goto exit; } if( alg == GWWRAP_333 || alg == GWWRAP_333L ) { cses = default_cDNA_ComplexSequenceEvalSet(); cs = new_ComplexSequence(gen->baseseq,cses); free_ComplexSequenceEvalSet(cses); } else if ( alg == GWWRAP_6LITE ) { /* yup. This is scary. */ tempcse = gpara->cses->cse[1]; gpara->cses->cse[1] = codon64_number_ComplexSequenceEval(); cs = new_ComplexSequence(gen->baseseq,gpara->cses); free_ComplexSequenceEval(gpara->cses->cse[1]); gpara->cses->cse[1] = tempcse; } else { if( (cs=evaluate_ComplexSequence_Genomic(gen,gpara->cses,0,Probability2Score(0.01))) == FALSE ) { warn("Unable to make ComplexSequence in TMS2DNA wrap"); goto exit; } } /*show_ComplexSequence(cs,stderr);*/ if( (gw=GeneWise_from_ThreeStateModel(tsm,gpara->gp,gpara->cm,allN,gpara->gwcm)) == NULL) { warn("Unable to make GeneWise model"); goto exit; } flatten_balance_scores_GeneWise(gw); /* show_GeneWiseSegment(gw->seg[0],stderr); */ if( use_syn == TRUE ) { if( tsm->rm == NULL ) { warn("Ugh - a threestatemodel without a random model. Not in this code matey"); goto exit; } GeneWise_fold_in_synchronised_RandomModel(gw,tsm->rm,gpara->cm,gpara->ct,0.5); flatten_RandomCodon(gpara->rc); } else { GeneWise_fold_in_RandomModelDNA(gw,rmd); } if( alg == GWWRAP_6LITE ) { gwl = GwLite_from_GeneWise(gw); gwls = GwLiteScore_from_GwLite(gwl); } if( flat_insert == TRUE ) { check_flat_insert(gw,1,0,gpara->cm->ct); } if( (gws = GeneWiseScore_from_GeneWise(gw)) == NULL) { warn("Unable to make GeneWiseScore model"); goto exit; } if( (gps = GeneParser21Score_from_GeneParser21(gpara->gp)) == NULL) { warn("Unable to make GeneParserScore model"); goto exit; } if( (rcs = RandomCodonScore_from_RandomCodon(gpara->rc)) == NULL) { warn("Unable to make RandomCodonScore model"); goto exit; } ids = folded_RandomModelDNAScore_from_2RMD(intergenic,rmd); gp4s = GeneParser4Score_from_GeneParser21Score(gps); gp4s->transition[GP4_INTRON2CDS] = Probability2Score(halfbit2Probability((-12+(5*-2)))); if( alg == GWWRAP_333 || alg == GWWRAP_333L ) { cps = cDNAParserScore_from_GeneParser21Score(gps); } if( alg == GWWRAP_623S ) { ggms = vanilla_GeneralGeneModelScore(gpara->ct,Bits2Probability(10),1.0,Bits2Probability(10)); } switch(alg) { case GWWRAP_2193 : pal = PackAln_bestmemory_GeneWise21(gws,cs,gps,rcs,ids,dpenv,dpri); out = convert_PackAln_to_AlnBlock_GeneWise21(pal); break; case GWWRAP_2193I : warn("Algorithm currently disabled! Sorry!"); break; /** pal = PackAln_dc_build_GeneLinker21(gws,cs,gps,rcs,ids); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneLinker21(pal,NULL); break; **/ case GWWRAP_2193L : pal = PackAln_bestmemory_GeneLoop21(gws,cs,gps,rcs,ids,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneLoop21(pal); break; case GWWRAP_623L : pal = PackAln_bestmemory_GeneLoop6(gws,cs,gp4s,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneLoop6(pal); break; case GWWRAP_623 : /* if( *palpoi != NULL ) { warn("For genewise623, Using given packaln, not calculating!"); pal = *palpoi; } else { pal = PackAln_bestmemory_GeneWise6(gws,cs,gp4s,dpenv,dpri); } */ gp4s->transition[GP4_INTRON2INTRON] = 0; /*fprintf(stderr,"Got intron2intron score of %d\n",gp4s->transition[GP4_INTRON2INTRON]);*/ pal = PackAln_bestmemory_GeneWise6(gws,cs,gp4s,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneWise6(pal); break; case GWWRAP_623S : pal = PackAln_bestmemory_GeneStretch6(gws,cs,gp4s,ggms,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneStretch6(pal); break; case GWWRAP_333 : cps = cDNAParserScore_from_GeneParser21Score(gps); pal = PackAln_bestmemory_EstWise3(gws,cs,cps,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_EstWise3(pal); break; case GWWRAP_333L : cps = cDNAParserScore_from_GeneParser21Score(gps); pal = PackAln_bestmemory_EstLoop3(gws,cs,cps,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_EstLoop3(pal); break; case GWWRAP_421 : pal = PackAln_bestmemory_GeneWise4(gws,cs,gp4s,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneWise4(pal); break; case GWWRAP_6LITE : pal = PackAln_bestmemory_GeneLiteModel(gwls,cs,gp4s,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneLiteModel(pal); GwLite_AlnBlock_surgery(out); break; default : warn("A major problem. No valid algorithm type passed in"); goto exit; } map_phase0_codons_AlnBlock_GeneWise(out,gws,cs); if( palpoi != NULL ) { *palpoi = pal; pal = NULL; } goto exit; exit : if(pal != NULL) pal = free_PackAln(pal); if( cps != NULL ) cps = free_cDNAParserScore(cps); if( ids != NULL ) ids = free_RandomModelDNAScore(ids); if(cs != NULL ) cs = free_ComplexSequence(cs); if(gw != NULL ) gw = free_GeneWise(gw); if(gws != NULL ) gws = free_GeneWiseScore(gws); if(gps != NULL ) free_GeneParser21Score(gps); if(rcs != NULL ) rcs = free_RandomCodonScore(rcs); if(gp4s != NULL) gp4s = free_GeneParser4Score(gp4s); if( ggms != NULL ) ggms = free_GeneralGeneModelScore(ggms); return out; } %func Runs a database search of the genewise algorithm. This makes a high score object which you can then use to retrieve enteries as well as print out the top score (!) %arg tdb r a database of profileHMMs gdb r a database of genomic sequence gpara r geneparameters rmd r random model to be compared with in non syn mode intergenic r random model of intergenic DNA (usually the same as rmd) use_syn use synchronous random model alg algorithm type bits_cutoff cutoff in bits of the scores to store report_level stagger rate of reporting progress on stderr -1 means never die_on_error if true, exits on error (not used at the moment) return a new Hscore object of the entire db search %% Hscore * Hscore_from_TSM_genewise(ThreeStateDB * tdb,GenomicDB * gdb,GeneParameter21 * gpara,RandomModelDNA * rmd,RandomModelDNA * intergenic,boolean use_syn,int alg,double bits_cutoff,Probability allN,int report_level,boolean die_on_error,boolean flat_insert,DBSearchImpl * dbsi) { Hscore * out = NULL; GeneWiseDB * gwdb = NULL; cDNADB * cdb = NULL; cDNAParserScore * cps= NULL; GeneParser21Score * gps = NULL; GeneParser4Score * gp4s = NULL; RandomCodonScore * rcs = NULL; RandomModelDNAScore * ids = NULL; cDNA * temp; Search_Return_Type ret; ComplexSequenceEval * tempcse; ret = SEARCH_ERROR; gwdb = new_GeneWiseDB(tdb,gpara,rmd,use_syn,allN); gwdb->flat_insert = flat_insert; if( gwdb == NULL ) { warn("Could not build a new GeneWiseDB from the objects provided. Exiting without completing the search"); goto exit; } if( (gps = GeneParser21Score_from_GeneParser21(gpara->gp)) == NULL) { warn("Unable to make GeneParserScore model"); goto exit; } if( (rcs = RandomCodonScore_from_RandomCodon(gpara->rc)) == NULL) { warn("Unable to make RandomCodonScore model"); goto exit; } ids = folded_RandomModelDNAScore_from_2RMD(intergenic,rmd); gp4s = GeneParser4Score_from_GeneParser21Score(gps); if( alg == GWWRAP_333 || alg == GWWRAP_333L ) { /* could be a single dna sequence */ if( gdb->is_single_seq == TRUE ) { temp = cDNA_from_Sequence(hard_link_Sequence(gdb->forw->seq)); cdb = new_cDNADB_from_single_seq(temp); free_cDNA(temp); /* hard linked by database */ } else { cdb = new_cDNADB(gdb->sdb); } } /*** allocate Hscore structure ***/ out = std_bits_Hscore(bits_cutoff,report_level); switch(alg) { case GWWRAP_2193 : ret = Wise2_search_GeneWise21(dbsi,out,gwdb,gdb,gps,rcs,ids); break; case GWWRAP_2193I : warn("Algorithm currently disabled! Sorry!"); break; case GWWRAP_2193L : warn("Unable to do db looping searches (sort of - pointless - )!"); break; case GWWRAP_623L : warn("Unable to do db looping searches (sort of - pointless - )!"); break; case GWWRAP_623 : ret = Wise2_search_GeneWise6(dbsi,out,gwdb,gdb,gp4s); break; case GWWRAP_6LITE : ret = Wise2_search_GeneLiteModel(dbsi,out,gwdb,gdb,gp4s); break; case GWWRAP_333 : cps = cDNAParserScore_from_GeneParser21Score(gps); ret = search_EstWise3(dbsi,out,gwdb,cdb,cps); break; case GWWRAP_333L : warn("Unable to do db looping searches (sort of - pointless - )!"); break; case GWWRAP_421 : ret = Wise2_search_GeneWise4(dbsi,out,gwdb,gdb,gp4s); break; default : warn("A major problem. No valid algorithm type passed in"); goto exit; } goto exit; exit : /* for 6LITE leaking a tiny amount of memory. Oh well... */ if( ids != NULL ) ids = free_RandomModelDNAScore(ids); if( cps != NULL ) free_cDNAParserScore(cps); if( cdb != NULL ) free_cDNADB(cdb); if(gps != NULL ) free_GeneParser21Score(gps); if(rcs != NULL ) rcs = free_RandomCodonScore(rcs); if(gp4s != NULL) gp4s = free_GeneParser4Score(gp4s); if( gwdb != NULL ) { free_GeneWiseDB(gwdb); } if( die_on_error == TRUE && ret == SEARCH_ERROR) { if( out != NULL ) { free_Hscore(out); } return NULL; } return out; } %func Makes a cdna parser from a genewise parser. Basically copies the indel penalties across. %type internal %% cDNAParserScore * cDNAParserScore_from_GeneParser21Score(GeneParser21Score * gps) { cDNAParserScore * out; out = cDNAParserScore_alloc(); out->trans[PCD_INSERT_2_BASE] = gps->transition[GP21_INSERT_2_BASE]; out->trans[PCD_INSERT_1_BASE] = gps->transition[GP21_INSERT_1_BASE]; out->trans[PCD_DELETE_2_BASE] = gps->transition[GP21_DELETE_2_BASE]; out->trans[PCD_DELETE_1_BASE] = gps->transition[GP21_DELETE_1_BASE]; return out; } %func Gives you the integer interpretation from the string, which is one of 2193 2193L, 623, 623L, 421, 2193LINK This integer can then be passed into routines like AlnBlock_from_protein_genewise_wrap %% int gwrap_alg_type_from_string(char * str) { int t; t = get_number_from_slashed_string(str,"2193/2193L/623/623L/421/2193LINK/333/333L/6LITE/623S/623P"); switch (t) { case 0 : return GWWRAP_2193; case 1 : return GWWRAP_2193L; case 2 : return GWWRAP_623; case 3 : return GWWRAP_623L; case 4 : return GWWRAP_421; case 5 : return GWWRAP_2193I; case 6 : return GWWRAP_333; case 7 : return GWWRAP_333L; case 8 : return GWWRAP_6LITE; case 9 : return GWWRAP_623S; case 10 : return GWWRAP_623P; default : warn("Cannot convert string %s into a valid genewise algorithm type\n",str); return -1; } } %} wise-2.4.1/src/models/estfrag3.c0000644000175000001440000100105510670453713016015 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "estfrag3.h" # line 5 "estfrag3.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define START 0 #define END 1 #define EstFrag3_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+5)*3)+STATE][i+1] #define EstFrag3_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+5] #define EstFrag3_READ_OFF_ERROR -7 #define EstFrag3_VSMALL_MATRIX(mat,i,j,STATE) internal_matrix[(j+6)%6][((i+1)*3)+STATE] #define EstFrag3_VSMALL_SPECIAL(mat,i,j,STATE) internal_specials[(j+6)%6][STATE] #define EstFrag3_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define EstFrag3_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_EstFrag3(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_EstFrag3(EstFrag3 * mat) { EstFrag3_access_func_holder holder; holder.access_main = EstFrag3_shatter_access_main; holder.access_special = EstFrag3_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_EstFrag3(mat,holder); } /* Function: EstFrag3_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstFrag3_shatter_access_main(EstFrag3 * mat,int i,int j,int state) { return EstFrag3_SHATTER_MATRIX(mat,i,j,state); } /* Function: EstFrag3_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstFrag3_shatter_access_special(EstFrag3 * mat,int i,int j,int state) { return EstFrag3_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_EstFrag3(mat,dpenv) * * Descrip: This function calculates the EstFrag3 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EstFrag3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_EstFrag3(EstFrag3 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_2; int * SIG_1_1; int * SIG_1_4; int * SIG_1_5; int * SIG_0_3; int * SIG_0_2; int * SIG_0_1; int * SIG_0_4; int * SIG_0_5; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("EstFrag3 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_1_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-5); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_0_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-5); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstFrag3_SHATTER_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* Has restricted position */ if( (j-3) == 0 ) { /* From state START to state MATCH */ temp = EstFrag3_SHATTER_SPECIAL(mat,i-1,j-3,START) + (mat->start_frag+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_1[MATCH] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_4[MATCH] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_5[MATCH] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_2[INSERT] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_1[INSERT] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_4[INSERT] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_5[INSERT] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_2[DELETE] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_1[DELETE] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_4[DELETE] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_5[DELETE] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstFrag3_SHATTER_SPECIAL(mat,i,j,END) ) { EstFrag3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* state MATCH is a source for special END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = score + (mat->end_frag) + (0) ; if( temp > EstFrag3_SHATTER_SPECIAL(mat,i,j,END) ) { EstFrag3_SHATTER_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstFrag3_SHATTER_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_2[INSERT] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_4[INSERT] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_5[INSERT] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = SIG_0_2[MATCH] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = SIG_0_1[MATCH] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = SIG_0_4[MATCH] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = SIG_0_5[MATCH] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_2[DELETE] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_1[DELETE] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_4[DELETE] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_5[DELETE] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ SIG_0_0[INSERT] = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstFrag3_SHATTER_SPECIAL(mat,i,j,END) ) { EstFrag3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstFrag3_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstFrag3_SHATTER_SPECIAL(mat,i,j,END) ) { EstFrag3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_EstFrag3(dbsi,out,querydb,targetdb,cp,start_frag,end_frag) * * Descrip: This function makes a database search of EstFrag3 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * Arg: start_frag [UNKN ] Undocumented argument [Score] * Arg: end_frag [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_EstFrag3(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp,Score start_frag,Score end_frag) { if( out == NULL ) { warn("Passed in a null Hscore object into search_EstFrag3. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_EstFrag3. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for EstFrag3, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_EstFrag3(out,querydb, targetdb ,cp,start_frag,end_frag); case DBSearchImpl_Pthreads : warn("This matrix EstFrag3 was not dyc compiled with thread support"); return SEARCH_ERROR; default : warn("database search implementation %s was not provided in the compiled dynamite file from EstFrag3",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: serial_search_EstFrag3(out,querydb,targetdb,cp,start_frag,end_frag) * * Descrip: This function makes a database search of EstFrag3 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * Arg: start_frag [UNKN ] Undocumented argument [Score] * Arg: end_frag [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_EstFrag3(Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp,Score start_frag,Score end_frag) { GeneWiseScore* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GeneWiseDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstFrag3, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_cDNADB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstFrag3, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* Maximum length to search - should check */ if( query->len > 1500 ) { /*if over length*/ warn("A query over the length when maxlen provided. Problem!"); score = -10000; } /* end of if over length */ else score = score_only_EstFrag3(query, target , cp, start_frag, end_frag); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("EstFrag3 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GeneWiseDB(ds->query,query,querydb); dataentry_add_cDNADB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_cDNADB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstFrag3, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_cDNADB(target,targetdb); query = reload_GeneWiseDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching EstFrag3, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GeneWiseDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_EstFrag3(query,target,cp,start_frag,end_frag) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_EstFrag3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: start_frag [UNKN ] Resource [Score] * Arg: end_frag [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_EstFrag3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,Score start_frag,Score end_frag) { int bestscore = NEGI; int i; int j; int k; EstFrag3 * mat; int internal_matrix[6][(1500+1) * 3]; int internal_specials[6][2]; mat = allocate_EstFrag3_only(query, target , cp, start_frag, end_frag); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } /* Ok,don't need to allocate matrix as it is internal, because we have a max length */ /* Now, initiate matrix */ for(j=0;j<7;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) EstFrag3_VSMALL_MATRIX(mat,i,j,k) = NEGI; } EstFrag3_VSMALL_SPECIAL(mat,i,j,START) = 0; EstFrag3_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = EstFrag3_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstFrag3_VSMALL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* Has restricted position */ if( (j-3) == 0 ) { /* From state START to state MATCH */ temp = EstFrag3_VSMALL_SPECIAL(mat,i-1,j-3,START) + (mat->start_frag+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } } /* From state MATCH to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstFrag3_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstFrag3_VSMALL_SPECIAL(mat,i,j,END) ) { EstFrag3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* state MATCH is a source for special END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = score + (mat->end_frag) + (0) ; if( temp > EstFrag3_VSMALL_SPECIAL(mat,i,j,END) ) { EstFrag3_VSMALL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstFrag3_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstFrag3_VSMALL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_VSMALL_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstFrag3_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstFrag3_VSMALL_SPECIAL(mat,i,j,END) ) { EstFrag3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstFrag3_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstFrag3_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstFrag3_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstFrag3_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstFrag3_VSMALL_SPECIAL(mat,i,j,END) ) { EstFrag3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < EstFrag3_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = EstFrag3_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_EstFrag3(mat); return bestscore; } /* Function: PackAln_bestmemory_EstFrag3(query,target,cp,start_frag,end_frag,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EstFrag3 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: start_frag [UNKN ] Resource [Score] * Arg: end_frag [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_EstFrag3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,Score start_frag,Score end_frag,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; EstFrag3 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_EstFrag3(query, target , cp, start_frag, end_frag,dpri)) == NULL ) { warn("Unable to allocate large EstFrag3 version"); return NULL; } calculate_dpenv_EstFrag3(mat,dpenv); out = PackAln_read_Expl_EstFrag3(mat); } else { mat = allocate_EstFrag3_only(query, target , cp, start_frag, end_frag); calculate_shatter_EstFrag3(mat,dpenv); out = PackAln_read_Shatter_EstFrag3(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_EstFrag3(query, target , cp, start_frag, end_frag)) == NULL ) { warn("Unable to allocate small EstFrag3 version"); return NULL; } out = PackAln_calculate_Small_EstFrag3(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_EstFrag3(query, target , cp, start_frag, end_frag,dpri)) == NULL ) { warn("Unable to allocate large EstFrag3 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_EstFrag3(mat); out = PackAln_read_Expl_EstFrag3(mat); } } } mat = free_EstFrag3(mat); return out; } /* Function: allocate_EstFrag3_only(query,target,cp,start_frag,end_frag) * * Descrip: This function only allocates the EstFrag3 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: start_frag [UNKN ] Resource [Score] * Arg: end_frag [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [EstFrag3 *] * */ EstFrag3 * allocate_EstFrag3_only(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,Score start_frag,Score end_frag) { EstFrag3 * out; if((out= EstFrag3_alloc()) == NULL) { warn("Allocation of basic EstFrag3 structure failed..."); return NULL; } out->query = query; out->target = target; out->cp = cp; out->start_frag = start_frag; out->end_frag = end_frag; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_EstFrag3(query,target,cp,start_frag,end_frag,dpri) * * Descrip: This function allocates the EstFrag3 structure * and the basematrix area for explicit memory implementations * It calls /allocate_EstFrag3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: start_frag [UNKN ] Resource [Score] * Arg: end_frag [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EstFrag3 *] * */ EstFrag3 * allocate_Expl_EstFrag3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,Score start_frag,Score end_frag,DPRunImpl * dpri) { EstFrag3 * out; out = allocate_EstFrag3_only(query, target , cp, start_frag, end_frag); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+5)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+5)*3,(out->leni+1),2,out->lenj+5)) == NULL) { warn("Explicit matrix EstFrag3 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_EstFrag3(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_EstFrag3(out); return out; } /* Function: init_EstFrag3(mat) * * Descrip: This function initates EstFrag3 matrix when in explicit mode * Called in /allocate_Expl_EstFrag3 * * * Arg: mat [UNKN ] EstFrag3 which contains explicit basematrix memory [EstFrag3 *] * */ void init_EstFrag3(EstFrag3 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-5);j<6;j++) { EstFrag3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstFrag3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstFrag3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j= (-5);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { EstFrag3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstFrag3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstFrag3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } EstFrag3_EXPL_SPECIAL(mat,i,j,START) = 0; EstFrag3_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_EstFrag3(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EstFrag3 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * */ void recalculate_PackAln_EstFrag3(PackAln * pal,EstFrag3 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (START+3) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (START+3) ) { pau->score = (mat->start_frag+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 1 && offj == 4 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 1 && offj == 5 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } if( offi == 1 && offj == 2 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 1 && offj == 4 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 1 && offj == 5 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } if( offi == 1 && offj == 2 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 1 && offj == 1 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 1 && offj == 4 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 1 && offj == 5 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (START+3) ) { pau->score = (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 0 && offj == 5 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } if( offi == 0 && offj == 2 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 0 && offj == 5 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } if( offi == 0 && offj == 2 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 1 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 0 && offj == 5 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->seg[i]->transition[GW_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (START+3) ) { pau->score = mat->query->seg[i]->transition[GW_START2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+3) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->end_frag + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define EstFrag3_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+5)][(i+1)*3+state]) #define EstFrag3_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+6)*8) % 48][(i+1)*3+state]) #define EstFrag3_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+5)]) #define EstFrag3_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+5)]) #define EstFrag3_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+6)*8)+(shadow+1)) % 48)][(i+1)*3 + state]) #define EstFrag3_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+5)]) #define EstFrag3_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+5)% 5) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define EstFrag3_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+5)% 5) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define EstFrag3_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+5)]) /* Function: allocate_Small_EstFrag3(query,target,cp,start_frag,end_frag) * * Descrip: This function allocates the EstFrag3 structure * and the basematrix area for a small memory implementations * It calls /allocate_EstFrag3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: start_frag [UNKN ] Resource [Score] * Arg: end_frag [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [EstFrag3 *] * */ #define EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+5)]) EstFrag3 * allocate_Small_EstFrag3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,Score start_frag,Score end_frag) { EstFrag3 * out; out = allocate_EstFrag3_only(query, target , cp, start_frag, end_frag); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(48,(out->leni + 1) * 3,16,out->lenj+5); if(out == NULL) { warn("Small shadow matrix EstFrag3 cannot be allocated, (asking for 6 by %d main cells)",out->leni+2); free_EstFrag3(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_EstFrag3(mat,dpenv) * * Descrip: This function calculates an alignment for EstFrag3 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EstFrag3 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EstFrag3 * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_EstFrag3(EstFrag3 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for EstFrag3 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_EstFrag3(mat,dpenv); score = start_end_find_end_EstFrag3(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_EstFrag3(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_EstFrag3(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == EstFrag3_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_EstFrag3(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 3; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_EstFrag3(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_EstFrag3(mat) * * Descrip: This function calculates an alignment for EstFrag3 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EstFrag3 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EstFrag3 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EstFrag3 * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_EstFrag3(EstFrag3 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_EstFrag3(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_EstFrag3(mat); return out; } /* Function: AlnRangeSet_from_EstFrag3(mat) * * Descrip: This function reads off a start/end structure * for EstFrag3 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EstFrag3 * If you have not calculated the matrix use * /AlnRange_calculate_Small_EstFrag3 * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_EstFrag3(EstFrag3 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EstFrag3"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_EstFrag3(mat,&jpos); state = END; while( (temp = AlnRange_build_EstFrag3(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_EstFrag3(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_EstFrag3 * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_EstFrag3(EstFrag3 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EstFrag3"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_EstFrag3(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_EstFrag3 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = EstFrag3_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_EstFrag3(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == EstFrag3_READ_OFF_ERROR) { warn("In AlnRange_build_EstFrag3 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = EstFrag3_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_EstFrag3(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_EstFrag3(EstFrag3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_EstFrag3(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EstFrag3_READ_OFF_ERROR) { warn("In EstFrag3 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In EstFrag3 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In EstFrag3 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_EstFrag3(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_EstFrag3(EstFrag3 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstFrag3_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In EstFrag3 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = EstFrag3_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 5,DELETE) ) { *reti = i - 1; *retj = j - 5; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-5,DELETE); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 5,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 4,DELETE) ) { *reti = i - 1; *retj = j - 4; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-4,DELETE); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 4,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-1,DELETE); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 2,DELETE) ) { *reti = i - 1; *retj = j - 2; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-2,DELETE); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 2,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 5,INSERT) ) { *reti = i - 1; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-5,INSERT); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 5,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 4,INSERT) ) { *reti = i - 1; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-4,INSERT); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 2,INSERT) ) { *reti = i - 1; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-2,INSERT); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 2,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-5,MATCH); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-4,MATCH); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } /* Not allowing special sources.. skipping START */ /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in EstFrag3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 5,DELETE) ) { *reti = i - 0; *retj = j - 5; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-5,DELETE); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 5,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 4,DELETE) ) { *reti = i - 0; *retj = j - 4; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-4,DELETE); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 4,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 1,DELETE) ) { *reti = i - 0; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-1,DELETE); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 1,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 2,DELETE) ) { *reti = i - 0; *retj = j - 2; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-2,DELETE); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 2,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 5,MATCH) ) { *reti = i - 0; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-5,MATCH); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 5,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 4,MATCH) ) { *reti = i - 0; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-4,MATCH); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 2,MATCH) ) { *reti = i - 0; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-2,MATCH); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 2,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 5,INSERT) ) { *reti = i - 0; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-5,INSERT); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 5,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 4,INSERT) ) { *reti = i - 0; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-4,INSERT); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-3,DELETE); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return EstFrag3_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in EstFrag3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return EstFrag3_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in EstFrag3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstFrag3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_EstFrag3(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_EstFrag3(EstFrag3 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > EstFrag3_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_EstFrag3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EstFrag3_READ_OFF_ERROR) { warn("In special strip read EstFrag3, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < EstFrag3_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read EstFrag3, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_EstFrag3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_EstFrag3(EstFrag3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = EstFrag3_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for EstFrag3, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In EstFrag3 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = EstFrag3_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ /* Source MATCH is not a special */ default: warn("Major problem (!) - in EstFrag3 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_EstFrag3(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_EstFrag3(EstFrag3 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = EstFrag3_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In EstFrag3 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ temp = cscore - ((mat->start_frag+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstFrag3_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_DC_SHADOW_SPECIAL(mat,i-1,j-3,START); } return EstFrag3_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ; } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstFrag3_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_DC_SHADOW_SPECIAL(mat,i-1,j-3,START); } return EstFrag3_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstFrag3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstFrag3_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_DC_SHADOW_SPECIAL(mat,i-0,j-3,START); } return EstFrag3_DC_SHADOW_MATRIX(mat,i - 0,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstFrag3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == EstFrag3_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstFrag3_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return EstFrag3_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstFrag3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstFrag3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_EstFrag3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_EstFrag3(EstFrag3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_EstFrag3(mat,starti,startj,stopi,stopj); EstFrag3_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstFrag3_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; EstFrag3_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; EstFrag3_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstFrag3_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstFrag3_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstFrag3_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstFrag3_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } } return; } /* Function: init_hidden_EstFrag3(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_EstFrag3(EstFrag3 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-5);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { EstFrag3_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; EstFrag3_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; EstFrag3_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; } } return; } /* Function: full_dc_EstFrag3(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_EstFrag3 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_EstFrag3 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [EstFrag3 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_EstFrag3(EstFrag3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_EstFrag3"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 25) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_EstFrag3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_EstFrag3(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_EstFrag3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for EstFrag3, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= EstFrag3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= EstFrag3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = EstFrag3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_EstFrag3(mat,EstFrag3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),EstFrag3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),EstFrag3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_EstFrag3(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_EstFrag3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_EstFrag3(EstFrag3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_EstFrag3(mat); EstFrag3_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_EstFrag3(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_EstFrag3(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_EstFrag3(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_EstFrag3(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_EstFrag3(EstFrag3 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<5;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstFrag3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); EstFrag3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); EstFrag3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( j - 3 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,DELETE,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,DELETE,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,DELETE,k); } } /* Add any movement independant score */ EstFrag3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( j - 3 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INSERT,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,MATCH,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,MATCH,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,DELETE,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,DELETE,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,DELETE,k); } } /* Add any movement independant score */ EstFrag3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ EstFrag3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_EstFrag3(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_EstFrag3(EstFrag3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstFrag3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstFrag3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstFrag3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state MATCH to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } /* From state MATCH to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } /* From state MATCH to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } /* From state INSERT to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,k); } /* From state INSERT to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* From state INSERT to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,k); } /* From state INSERT to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,k); } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,DELETE,k); } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,DELETE,k); } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,DELETE,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstFrag3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } /* From state INSERT to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* From state INSERT to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,k); } /* From state INSERT to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INSERT,k); } /* From state MATCH to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,k); } /* From state MATCH to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } /* From state MATCH to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,MATCH,k); } /* From state MATCH to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,MATCH,k); } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,DELETE,k); } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,k); } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,DELETE,k); } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,DELETE,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstFrag3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstFrag3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstFrag3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_EstFrag3(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_EstFrag3(EstFrag3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstFrag3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstFrag3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstFrag3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstFrag3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstFrag3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstFrag3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstFrag3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_EstFrag3(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * */ } void init_dc_EstFrag3(EstFrag3 * mat) { register int i; register int j; register int k; for(j=0;j<7;j++) { for(i=(-1);iquery->len;i++) { EstFrag3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstFrag3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstFrag3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; for(k=0;k<7;k++) { EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); } } } return; } /* Function: start_end_find_end_EstFrag3(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [EstFrag3 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_EstFrag3(EstFrag3 * mat,int * endj) { register int j; register int max; register int maxj; max = EstFrag3_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( EstFrag3_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = EstFrag3_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_EstFrag3(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [EstFrag3] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_EstFrag3(EstFrag3 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (5 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (5 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state START to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state START to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + (mat->start_frag+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state MATCH to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); } /* From state MATCH to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0)); } /* From state MATCH to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,0)); } /* From state INSERT to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,0)); } /* From state INSERT to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* From state INSERT to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,0)); } /* From state INSERT to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,0)); } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,DELETE,0)); } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,0)); } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,DELETE,0)); } /* From state DELETE to state MATCH */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,DELETE,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstFrag3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstFrag3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* state MATCH is a source for special END */ temp = score + (mat->end_frag) + (0) ; if( temp > EstFrag3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstFrag3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0)); } /* From state START to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INSERT to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* From state INSERT to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,0)); } /* From state INSERT to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INSERT,0)); } /* From state MATCH to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,0)); } /* From state MATCH to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); } /* From state MATCH to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,MATCH,0)); } /* From state MATCH to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,MATCH,0)); } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,DELETE,0)); } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,0)); } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,DELETE,0)); } /* From state DELETE to state INSERT */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,DELETE,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstFrag3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstFrag3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state START to state DELETE */ temp = EstFrag3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstFrag3_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstFrag3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstFrag3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstFrag3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstFrag3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = DELETE; } /* Finished calculating state DELETE */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_EstFrag3(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * */ void init_start_end_linear_EstFrag3(EstFrag3 * mat) { register int i; register int j; for(j=0;j<7;j++) { for(i=(-1);iquery->len;i++) { EstFrag3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); EstFrag3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); EstFrag3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; EstFrag3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); } } for(j=(-5);jtarget->seq->len;j++) { EstFrag3_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; EstFrag3_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; EstFrag3_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_EstFrag3(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_EstFrag3(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_EstFrag3(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","END" }; /* Function: AlnConvertSet_EstFrag3(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","END" }; AlnConvertSet * AlnConvertSet_EstFrag3(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; return out; } /* Function: PackAln_read_Expl_EstFrag3(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_EstFrag3(EstFrag3 * mat) { EstFrag3_access_func_holder holder; holder.access_main = EstFrag3_explicit_access_main; holder.access_special = EstFrag3_explicit_access_special; return PackAln_read_generic_EstFrag3(mat,holder); } /* Function: EstFrag3_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstFrag3_explicit_access_main(EstFrag3 * mat,int i,int j,int state) { return EstFrag3_EXPL_MATRIX(mat,i,j,state); } /* Function: EstFrag3_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstFrag3_explicit_access_special(EstFrag3 * mat,int i,int j,int state) { return EstFrag3_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_EstFrag3(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: h [UNKN ] Undocumented argument [EstFrag3_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_EstFrag3(EstFrag3 * mat,EstFrag3_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_EstFrag3(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in EstFrag3_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_EstFrag3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_EstFrag3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == EstFrag3_READ_OFF_ERROR || j == EstFrag3_READ_OFF_ERROR || state == EstFrag3_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in EstFrag3_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_EstFrag3(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [EstFrag3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_EstFrag3(EstFrag3 * mat,int * ri,int * rj,int * state,boolean * isspecial,EstFrag3_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: EstFrag3_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void EstFrag3_debug_show_matrix(EstFrag3 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",EstFrag3_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",EstFrag3_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",EstFrag3_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_EstFrag3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EstFrag3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_EstFrag3(EstFrag3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstFrag3_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstFrag3_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In EstFrag3 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 5,DELETE) ) { *reti = i - 1; *retj = j - 5; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,DELETE); } return (*h.access_main)(mat,i - 1,j - 5,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 4,DELETE) ) { *reti = i - 1; *retj = j - 4; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,DELETE); } return (*h.access_main)(mat,i - 1,j - 4,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,DELETE); } return (*h.access_main)(mat,i - 1,j - 1,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,DELETE) ) { *reti = i - 1; *retj = j - 2; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,DELETE); } return (*h.access_main)(mat,i - 1,j - 2,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 5,INSERT) ) { *reti = i - 1; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,INSERT); } return (*h.access_main)(mat,i - 1,j - 5,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 4,INSERT) ) { *reti = i - 1; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,INSERT); } return (*h.access_main)(mat,i - 1,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,INSERT) ) { *reti = i - 1; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,INSERT); } return (*h.access_main)(mat,i - 1,j - 2,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,MATCH); } return (*h.access_main)(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH); } return (*h.access_main)(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } /* Has restricted position */ if( (j-3) == 0 ) { temp = cscore - ((mat->start_frag+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START); } return (*h.access_main)(mat,i - 1,j - 3,START); } } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START); } return (*h.access_main)(mat,i - 1,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in EstFrag3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,DELETE) ) { *reti = i - 0; *retj = j - 5; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,DELETE); } return (*h.access_main)(mat,i - 0,j - 5,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,DELETE) ) { *reti = i - 0; *retj = j - 4; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,DELETE); } return (*h.access_main)(mat,i - 0,j - 4,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,DELETE) ) { *reti = i - 0; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,DELETE); } return (*h.access_main)(mat,i - 0,j - 1,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,DELETE) ) { *reti = i - 0; *retj = j - 2; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,DELETE); } return (*h.access_main)(mat,i - 0,j - 2,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,MATCH) ) { *reti = i - 0; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,MATCH); } return (*h.access_main)(mat,i - 0,j - 5,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,MATCH) ) { *reti = i - 0; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,MATCH); } return (*h.access_main)(mat,i - 0,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,MATCH) ) { *reti = i - 0; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,MATCH); } return (*h.access_main)(mat,i - 0,j - 2,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,INSERT) ) { *reti = i - 0; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,INSERT); } return (*h.access_main)(mat,i - 0,j - 5,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,INSERT) ) { *reti = i - 0; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INSERT); } return (*h.access_main)(mat,i - 0,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,START); } return (*h.access_main)(mat,i - 0,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE); } return (*h.access_main)(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in EstFrag3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in EstFrag3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstFrag3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_EstFrag3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EstFrag3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_EstFrag3(EstFrag3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstFrag3_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstFrag3_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In EstFrag3 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->end_frag) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in EstFrag3 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_EstFrag3(mat) * * Descrip: This function calculates the EstFrag3 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EstFrag3 * * * Arg: mat [UNKN ] EstFrag3 which contains explicit basematrix memory [EstFrag3 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_EstFrag3(EstFrag3 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EstFrag3, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("EstFrag3 Matrix calculation: "); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstFrag3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* Has restricted position */ if( (j-3) == 0 ) { /* From state START to state MATCH */ temp = EstFrag3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->start_frag+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } } /* From state MATCH to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstFrag3_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstFrag3_EXPL_SPECIAL(mat,i,j,END) ) { EstFrag3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* state MATCH is a source for special END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = score + (mat->end_frag) + (0) ; if( temp > EstFrag3_EXPL_SPECIAL(mat,i,j,END) ) { EstFrag3_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstFrag3_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstFrag3_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstFrag3_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstFrag3_EXPL_SPECIAL(mat,i,j,END) ) { EstFrag3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstFrag3_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstFrag3_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstFrag3_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstFrag3_EXPL_SPECIAL(mat,i,j,END) ) { EstFrag3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_EstFrag3(mat,dpenv) * * Descrip: This function calculates the EstFrag3 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EstFrag3 which contains explicit basematrix memory [EstFrag3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_EstFrag3(EstFrag3 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EstFrag3, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-5;jleni;i++) { EstFrag3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstFrag3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstFrag3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j=-5;jlenj;j++) { EstFrag3_EXPL_SPECIAL(mat,i,j,START) = 0; EstFrag3_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("EstFrag3 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { EstFrag3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstFrag3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstFrag3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = EstFrag3_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstFrag3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* Has restricted position */ if( (j-3) == 0 ) { /* From state START to state MATCH */ temp = EstFrag3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->start_frag+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } } /* From state MATCH to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstFrag3_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstFrag3_EXPL_SPECIAL(mat,i,j,END) ) { EstFrag3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* state MATCH is a source for special END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = score + (mat->end_frag) + (0) ; if( temp > EstFrag3_EXPL_SPECIAL(mat,i,j,END) ) { EstFrag3_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstFrag3_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstFrag3_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstFrag3_EXPL_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstFrag3_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstFrag3_EXPL_SPECIAL(mat,i,j,END) ) { EstFrag3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstFrag3_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstFrag3_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstFrag3_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstFrag3_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstFrag3_EXPL_SPECIAL(mat,i,j,END) ) { EstFrag3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: EstFrag3_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstFrag3 *] * */ EstFrag3 * EstFrag3_alloc(void) { EstFrag3 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EstFrag3 *) ckalloc (sizeof(EstFrag3))) == NULL) { warn("EstFrag3_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_EstFrag3(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstFrag3 *] * * Return [UNKN ] Undocumented return value [EstFrag3 *] * */ EstFrag3 * free_EstFrag3(EstFrag3 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EstFrag3 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->cp is linked in */ /* obj->start_frag is linked in */ /* obj->end_frag is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/estfrag3.h0000644000175000001440000004465110670453713016032 0ustar philippusers#ifndef DYNAMITEestfrag3HEADERFILE #define DYNAMITEestfrag3HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "cdparser.h" #include "genewisemodel.h" #include "genewisemodeldb.h" struct Wise2_EstFrag3 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GeneWiseScore* query; ComplexSequence* target; cDNAParserScore * cp; Score start_frag; Score end_frag; } ; /* EstFrag3 defined */ #ifndef DYNAMITE_DEFINED_EstFrag3 typedef struct Wise2_EstFrag3 Wise2_EstFrag3; #define EstFrag3 Wise2_EstFrag3 #define DYNAMITE_DEFINED_EstFrag3 #endif struct Wise2_EstFrag3_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(EstFrag3*,int,int,int); int (*access_special)(EstFrag3*,int,int,int); } ; /* EstFrag3_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_EstFrag3_access_func_holder typedef struct Wise2_EstFrag3_access_func_holder Wise2_EstFrag3_access_func_holder; #define EstFrag3_access_func_holder Wise2_EstFrag3_access_func_holder #define DYNAMITE_DEFINED_EstFrag3_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_EstFrag3(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_EstFrag3(EstFrag3 * mat); #define PackAln_read_Shatter_EstFrag3 Wise2_PackAln_read_Shatter_EstFrag3 /* Function: calculate_shatter_EstFrag3(mat,dpenv) * * Descrip: This function calculates the EstFrag3 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EstFrag3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_EstFrag3(EstFrag3 * mat,DPEnvelope * dpenv); #define calculate_shatter_EstFrag3 Wise2_calculate_shatter_EstFrag3 /* Function: search_EstFrag3(dbsi,out,querydb,targetdb,cp,start_frag,end_frag) * * Descrip: This function makes a database search of EstFrag3 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * Arg: start_frag [UNKN ] Undocumented argument [Score] * Arg: end_frag [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_EstFrag3(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp,Score start_frag,Score end_frag); #define search_EstFrag3 Wise2_search_EstFrag3 /* Function: serial_search_EstFrag3(out,querydb,targetdb,cp,start_frag,end_frag) * * Descrip: This function makes a database search of EstFrag3 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * Arg: start_frag [UNKN ] Undocumented argument [Score] * Arg: end_frag [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_EstFrag3(Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp,Score start_frag,Score end_frag); #define serial_search_EstFrag3 Wise2_serial_search_EstFrag3 /* Function: PackAln_bestmemory_EstFrag3(query,target,cp,start_frag,end_frag,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EstFrag3 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: start_frag [UNKN ] Resource [Score] * Arg: end_frag [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_EstFrag3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,Score start_frag,Score end_frag,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_EstFrag3 Wise2_PackAln_bestmemory_EstFrag3 /* Function: allocate_Expl_EstFrag3(query,target,cp,start_frag,end_frag,dpri) * * Descrip: This function allocates the EstFrag3 structure * and the basematrix area for explicit memory implementations * It calls /allocate_EstFrag3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: start_frag [UNKN ] Resource [Score] * Arg: end_frag [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EstFrag3 *] * */ EstFrag3 * Wise2_allocate_Expl_EstFrag3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,Score start_frag,Score end_frag,DPRunImpl * dpri); #define allocate_Expl_EstFrag3 Wise2_allocate_Expl_EstFrag3 /* Function: recalculate_PackAln_EstFrag3(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EstFrag3 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * */ void Wise2_recalculate_PackAln_EstFrag3(PackAln * pal,EstFrag3 * mat); #define recalculate_PackAln_EstFrag3 Wise2_recalculate_PackAln_EstFrag3 /* Function: allocate_Small_EstFrag3(query,target,cp,start_frag,end_frag) * * Descrip: This function allocates the EstFrag3 structure * and the basematrix area for a small memory implementations * It calls /allocate_EstFrag3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: start_frag [UNKN ] Resource [Score] * Arg: end_frag [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [EstFrag3 *] * */ EstFrag3 * Wise2_allocate_Small_EstFrag3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,Score start_frag,Score end_frag); #define allocate_Small_EstFrag3 Wise2_allocate_Small_EstFrag3 /* Function: PackAln_calculate_Small_EstFrag3(mat,dpenv) * * Descrip: This function calculates an alignment for EstFrag3 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EstFrag3 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EstFrag3 * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_EstFrag3(EstFrag3 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_EstFrag3 Wise2_PackAln_calculate_Small_EstFrag3 /* Function: AlnRangeSet_calculate_Small_EstFrag3(mat) * * Descrip: This function calculates an alignment for EstFrag3 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EstFrag3 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EstFrag3 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EstFrag3 * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_EstFrag3(EstFrag3 * mat); #define AlnRangeSet_calculate_Small_EstFrag3 Wise2_AlnRangeSet_calculate_Small_EstFrag3 /* Function: AlnRangeSet_from_EstFrag3(mat) * * Descrip: This function reads off a start/end structure * for EstFrag3 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EstFrag3 * If you have not calculated the matrix use * /AlnRange_calculate_Small_EstFrag3 * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_EstFrag3(EstFrag3 * mat); #define AlnRangeSet_from_EstFrag3 Wise2_AlnRangeSet_from_EstFrag3 /* Function: convert_PackAln_to_AlnBlock_EstFrag3(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_EstFrag3(PackAln * pal); #define convert_PackAln_to_AlnBlock_EstFrag3 Wise2_convert_PackAln_to_AlnBlock_EstFrag3 /* Function: PackAln_read_Expl_EstFrag3(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_EstFrag3(EstFrag3 * mat); #define PackAln_read_Expl_EstFrag3 Wise2_PackAln_read_Expl_EstFrag3 /* Function: PackAln_read_generic_EstFrag3(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstFrag3 *] * Arg: h [UNKN ] Undocumented argument [EstFrag3_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_EstFrag3(EstFrag3 * mat,EstFrag3_access_func_holder h); #define PackAln_read_generic_EstFrag3 Wise2_PackAln_read_generic_EstFrag3 /* Function: calculate_EstFrag3(mat) * * Descrip: This function calculates the EstFrag3 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EstFrag3 * * * Arg: mat [UNKN ] EstFrag3 which contains explicit basematrix memory [EstFrag3 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_EstFrag3(EstFrag3 * mat); #define calculate_EstFrag3 Wise2_calculate_EstFrag3 /* Function: calculate_dpenv_EstFrag3(mat,dpenv) * * Descrip: This function calculates the EstFrag3 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EstFrag3 which contains explicit basematrix memory [EstFrag3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_EstFrag3(EstFrag3 * mat,DPEnvelope * dpenv); #define calculate_dpenv_EstFrag3 Wise2_calculate_dpenv_EstFrag3 /* Function: EstFrag3_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstFrag3 *] * */ EstFrag3 * Wise2_EstFrag3_alloc(void); #define EstFrag3_alloc Wise2_EstFrag3_alloc /* Function: free_EstFrag3(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstFrag3 *] * * Return [UNKN ] Undocumented return value [EstFrag3 *] * */ EstFrag3 * Wise2_free_EstFrag3(EstFrag3 * obj); #define free_EstFrag3 Wise2_free_EstFrag3 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_EstFrag3_shatter_access_main(EstFrag3 * mat,int i,int j,int state); #define EstFrag3_shatter_access_main Wise2_EstFrag3_shatter_access_main int Wise2_EstFrag3_shatter_access_special(EstFrag3 * mat,int i,int j,int state); #define EstFrag3_shatter_access_special Wise2_EstFrag3_shatter_access_special int Wise2_score_only_EstFrag3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,Score start_frag,Score end_frag); #define score_only_EstFrag3 Wise2_score_only_EstFrag3 EstFrag3 * Wise2_allocate_EstFrag3_only(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,Score start_frag,Score end_frag); #define allocate_EstFrag3_only Wise2_allocate_EstFrag3_only void Wise2_init_EstFrag3(EstFrag3 * mat); #define init_EstFrag3 Wise2_init_EstFrag3 AlnRange * Wise2_AlnRange_build_EstFrag3(EstFrag3 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_EstFrag3 Wise2_AlnRange_build_EstFrag3 boolean Wise2_read_hidden_EstFrag3(EstFrag3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_EstFrag3 Wise2_read_hidden_EstFrag3 int Wise2_max_hidden_EstFrag3(EstFrag3 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_EstFrag3 Wise2_max_hidden_EstFrag3 boolean Wise2_read_special_strip_EstFrag3(EstFrag3 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_EstFrag3 Wise2_read_special_strip_EstFrag3 int Wise2_max_special_strip_EstFrag3(EstFrag3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_EstFrag3 Wise2_max_special_strip_EstFrag3 int Wise2_max_matrix_to_special_EstFrag3(EstFrag3 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_EstFrag3 Wise2_max_matrix_to_special_EstFrag3 void Wise2_calculate_hidden_EstFrag3(EstFrag3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_EstFrag3 Wise2_calculate_hidden_EstFrag3 void Wise2_init_hidden_EstFrag3(EstFrag3 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_EstFrag3 Wise2_init_hidden_EstFrag3 boolean Wise2_full_dc_EstFrag3(EstFrag3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_EstFrag3 Wise2_full_dc_EstFrag3 boolean Wise2_do_dc_single_pass_EstFrag3(EstFrag3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_EstFrag3 Wise2_do_dc_single_pass_EstFrag3 void Wise2_push_dc_at_merge_EstFrag3(EstFrag3 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_EstFrag3 Wise2_push_dc_at_merge_EstFrag3 void Wise2_follow_on_dc_EstFrag3(EstFrag3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_EstFrag3 Wise2_follow_on_dc_EstFrag3 void Wise2_run_up_dc_EstFrag3(EstFrag3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_EstFrag3 Wise2_run_up_dc_EstFrag3 void Wise2_init_dc_EstFrag3(EstFrag3 * mat); #define init_dc_EstFrag3 Wise2_init_dc_EstFrag3 int Wise2_start_end_find_end_EstFrag3(EstFrag3 * mat,int * endj); #define start_end_find_end_EstFrag3 Wise2_start_end_find_end_EstFrag3 boolean Wise2_dc_optimised_start_end_calc_EstFrag3(EstFrag3 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_EstFrag3 Wise2_dc_optimised_start_end_calc_EstFrag3 void Wise2_init_start_end_linear_EstFrag3(EstFrag3 * mat); #define init_start_end_linear_EstFrag3 Wise2_init_start_end_linear_EstFrag3 AlnConvertSet * Wise2_AlnConvertSet_EstFrag3(void); #define AlnConvertSet_EstFrag3 Wise2_AlnConvertSet_EstFrag3 int Wise2_EstFrag3_explicit_access_main(EstFrag3 * mat,int i,int j,int state); #define EstFrag3_explicit_access_main Wise2_EstFrag3_explicit_access_main int Wise2_EstFrag3_explicit_access_special(EstFrag3 * mat,int i,int j,int state); #define EstFrag3_explicit_access_special Wise2_EstFrag3_explicit_access_special int Wise2_find_end_EstFrag3(EstFrag3 * mat,int * ri,int * rj,int * state,boolean * isspecial,EstFrag3_access_func_holder h); #define find_end_EstFrag3 Wise2_find_end_EstFrag3 void Wise2_EstFrag3_debug_show_matrix(EstFrag3 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define EstFrag3_debug_show_matrix Wise2_EstFrag3_debug_show_matrix int Wise2_max_calc_EstFrag3(EstFrag3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstFrag3_access_func_holder h); #define max_calc_EstFrag3 Wise2_max_calc_EstFrag3 int Wise2_max_calc_special_EstFrag3(EstFrag3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstFrag3_access_func_holder h); #define max_calc_special_EstFrag3 Wise2_max_calc_special_EstFrag3 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/geneparameter_api.h0000644000175000001440000000257010670453714017757 0ustar philippusers /* Functions that create, manipulate or act on GeneParameter21 * * Wise2_hard_link_GeneParameter21 * Wise2_GeneParameter21_alloc_std * Wise2_free_GeneParameter21 [destructor] * */ /* API for object GeneParameter21 */ /* Function: Wise2_hard_link_GeneParameter21(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_GeneParameter21 *] * * Returns Undocumented return value [Wise2_GeneParameter21 *] * */ Wise2_GeneParameter21 * Wise2_hard_link_GeneParameter21( Wise2_GeneParameter21 * obj); /* Function: Wise2_GeneParameter21_alloc_std(void) * * Descrip: Equivalent to GeneParameter21_alloc_len(GeneParameter21LISTLENGTH) * * * * Returns Undocumented return value [Wise2_GeneParameter21 *] * */ Wise2_GeneParameter21 * Wise2_GeneParameter21_alloc_std(); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_GeneParameter21(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_GeneParameter21 *] * * Returns Undocumented return value [Wise2_GeneParameter21 *] * */ Wise2_GeneParameter21 * Wise2_free_GeneParameter21( Wise2_GeneParameter21 * obj); wise-2.4.1/src/models/geneparameter_api.t0000644000175000001440000000007510670453714017771 0ustar philippuserstypedef struct Wise2_GeneParameter21 Wise2_GeneParameter21; wise-2.4.1/src/models/genome_evidence.dy0000644000175000001440000000475007360366655017623 0ustar philippusers %{ #include "dyna.h" #define GNE_CDS_3SS(evi,i,seq,j,phase) ((*((evi)->geu[i]->cds_3SS))((evi)->geu[i]->data,seq,j,phase)) #define GNE_CDS_5SS(evi,i,seq,j,phase) ((*((evi)->geu[i]->cds_5SS))((evi)->geu[i]->data,seq,j,phase)) #define GNE_CDS(evi,i,seq,j) ((*((evi)->geu[i]->cds_pot))((evi)->geu[i]->data,seq,j)) #define GNE_CDS_INTRON(evi,i,seq,j) ((*((evi)->geu[i]->cds_intron_pot))((evi)->geu[i]->data,seq,j)) #define GNE_UTR_3SS(evi,i,seq,j) ((*((evi)->geu[i]->utr_3SS))((evi)->geu[i]->data,seq,j)) #define GNE_UTR_5SS(evi,i,seq,j) ((*((evi)->geu[i]->utr_5SS))((evi)->geu[i]->data,seq,j)) #define GNE_UTR(evi,i,seq,j) ((*((evi)->geu[i]->utr_pot))((evi)->geu[i]->data,seq,j)) #define GNE_UTR_INTRON(evi,i,seq,j) ((*((evi)->geu[i]->utr_intron_pot))((evi)->geu[i]->data,seq,j)) #define GNE_CDS_FRAMESHIFT(evi,i,seq,j,jump) ((*((evi)->geu[i]->frameshift_cds))((evi)->geu[i]->data,seq,j,jump)) #define GNE_START_CODON(evi,i,seq,j) ((*((evi)->geu[i]->start_pot))((evi)->geu[i]->data,seq,j)) #define GNE_STOP_CODON(evi,i,seq,j) ((*((evi)->geu[i]->stop_pot))((evi)->geu[i]->data,seq,j)) #define GNE_UTR3_END(evi,i,seq,j) ((*((evi)->geu[i]->utr3_end))((evi)->geu[i]->data,seq,j)) #define GNE_UTR5_START(evi,i,seq,j) ((*((evi)->geu[i]->utr5_start))((evi)->geu[i]->data,seq,j)) #define GenomeEvidenceSetLISTLENGTH 512 %} struct GenomeEvidenceUnit int type void * data int (*cds_3SS)(void*,Wise2_ComplexSequence*,int,int) !func int (*cds_5SS)(void*,Wise2_ComplexSequence*,int,int) !func int (*utr_3SS)(void*,Wise2_ComplexSequence*,int) !func int (*utr_5SS)(void*,Wise2_ComplexSequence*,int) !func int (*cds_pot)(void*,Wise2_ComplexSequence*,int) !func int (*utr_pot)(void*,Wise2_ComplexSequence*,int) !func int (*cds_intron_pot)(void*,Wise2_ComplexSequence*,int) !func int (*utr_intron_pot)(void*,Wise2_ComplexSequence*,int) !func int (*frameshift_cds)(void*,Wise2_ComplexSequence*,int,int) !func int (*start_pot)(void*,Wise2_ComplexSequence*,int) !func int (*stop_pot)(void*,Wise2_ComplexSequence*,int) !func int (*utr3_end)(void*,Wise2_ComplexSequence*,int) !func int (*utr5_start)(void*,Wise2_ComplexSequence*,int) !func int (*geu_free)(void *) !func struct GenomeEvidenceSet GenomeEvidenceUnit ** geu !list %{ #include "genome_evidence.h" %func Specialised deconstructor. Ensures the data structures are freed %% !deconstructor GenomeEvidenceUnit * free_GenomeEvidenceUnit(GenomeEvidenceUnit * obj) { (*(obj->geu_free))(obj->data); free(obj); } %} wise-2.4.1/src/models/dnaalign.typemap0000644000175000001440000000037410670453713017313 0ustar philippusers TYPEMAP Wise2_DnaStartEnd * T_Wise2_DnaStartEnd INPUT T_Wise2_DnaStartEnd $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_DnaStartEnd *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_DnaStartEnd sv_setref_pv($arg, "Wise2::DnaStartEnd", (void*) $var); wise-2.4.1/src/models/motifwise.c0000644000175000001440000001014710034317426016300 0ustar philippusers#include "transfactor.h" #include "transregion.h" #include "version.h" #include "commandline.h" char * program_name = "motifwise"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s motif-library sequence\n",program_name); fprintf(ofp," -lr motif library is in laurence's format\n"); fprintf(ofp," -ben motif library is in ben's IUPAC format\n"); fprintf(ofp," -[no]show_match - show raw matches, default no\n"); fprintf(ofp," -[no]show_region - show only dense cluster regions, default yes\n"); fprintf(ofp," -end_on_seq [no] - for debugging, end on processing sequence X\n"); fprintf(ofp," -circular [no] - for randomisation, number of positions to permute\n"); show_help_TransFactorBuildPara(ofp); show_help_TransFactorMatchPara(ofp); show_help_TransFactorRegionPara(ofp); show_help_DPRunImpl(ofp); show_standard_options(ofp); } int main(int argc,char ** argv) { TransFactorSet * tfs; TransFactorSet * newtfs; /* only used as a temp when permuting */ TransFactorBuildPara * tfb; TransFactorMatchSet * tfms; TransFactorMatchPara * matchp; boolean use_laurence = FALSE; boolean use_ben = FALSE; boolean show_matchset = FALSE; boolean show_region = TRUE; int end_on_seq = 0; int seq_count = 0; int rotate_number = 0; TransFactorRegionSet * tfrs; TransFactorRegionPara * tfrp; DPRunImpl * dpri; FILE * ifp; Sequence * seq; int i; tfb = new_TransFactorBuildPara_from_argv(&argc,argv); matchp = new_TransFactorMatchPara_from_argv(&argc,argv); tfrp = new_TransFactorRegionPara_from_argv(&argc,argv); dpri = new_DPRunImpl_from_argv(&argc,argv); strip_out_boolean_def_argument(&argc,argv,"show_match",&show_matchset); strip_out_boolean_def_argument(&argc,argv,"show_region",&show_region); strip_out_integer_argument(&argc,argv,"end_on_seq",&end_on_seq); strip_out_integer_argument(&argc,argv,"circular",&rotate_number); if( strip_out_boolean_argument(&argc,argv,"lr") == TRUE ) { use_laurence = TRUE; } if( strip_out_boolean_argument(&argc,argv,"ben") == TRUE ) { use_ben = TRUE; } strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 3 ) { show_help(stdout); exit(12); } if( use_laurence == TRUE ) { tfs = read_laurence_TransFactorSet_file(argv[1]); } else if( use_ben == TRUE ) { tfs = read_ben_IUPAC_TransFactorSet_file(argv[1]); } else { tfs = read_TransFactorSet_file(argv[1]); } ifp = openfile(argv[2],"r"); if( ifp == NULL ) { fatal("Could not open %s",argv[2]); } build_TransFactorSet(tfs,tfb); if( rotate_number > 0 ) { fprintf(stdout,"PERMUTED RESULTS - %d rotation\n",rotate_number); newtfs = circular_permuted_TransFactorSet(tfs,rotate_number); free_TransFactorSet(tfs); tfs = newtfs; } while((seq = read_fasta_Sequence(ifp)) != NULL ) { seq_count++; fprintf(stderr,"Looking at sequence %s with %d motifs\n",seq->name,tfs->len); fprintf(stdout,"Sequence %s %d\n",seq->name,seq->len); tfms = calculate_TransFactorMatchSet(seq,tfs,matchp); sort_by_start_TransFactorMatchSet(tfms); fprintf(stdout,"RawMotif %d\n",tfms->len); fflush(stdout); if( show_matchset == TRUE ) { show_TransFactorMatchSet(tfms,stdout); } if( show_region == TRUE ) { tfrs = new_TransFactorRegionSet(tfms,tfrp,dpri); show_TransFactorRegionSet(tfrs,stdout); free_TransFactorRegionSet(tfrs); } free_TransFactorMatchSet(tfms); free_Sequence(seq); if( end_on_seq != 0 && seq_count > end_on_seq ) { break; } fflush(stdout); } } wise-2.4.1/src/models/estwrap_api.h0000644000175000001440000001314310670453713016622 0ustar philippusers /* Helper functions in the module * * Wise2_Hscore_from_TSM_estwise * Wise2_AlnBlock_from_Protein_estwise_wrap * Wise2_AlnBlock_from_TSM_estwise_wrap * Wise2_alg_estwrap_from_string * /* These functions are not associated with an object */ /* Function: Wise2_Hscore_from_TSM_estwise(tdb,cdb,cp,cm,rmd,use_syn,alg,bits_cutoff,allN,flat_insert,report_level,die_on_error,dbsi) * * Descrip: Runs a database search for the estwise set * of algorithms * * * Arg: tdb a three state model database [Wise2_ThreeStateDB *] * Arg: cdb a dna sequence database [Wise2_cDNADB *] * Arg: cp the codon parser for this comparison [Wise2_cDNAParser *] * Arg: cm the codon mapper for this comparison [Wise2_CodonMapper *] * Arg: rmd random model used for the dna sequence comparison [Wise2_RandomModelDNA *] * Arg: use_syn whether a synchronous coding model should be used or not [boolean] * Arg: alg algorithm to use [int] * Arg: bits_cutoff Undocumented argument [double] * Arg: allN Undocumented argument [Probability] * Arg: flat_insert Undocumented argument [boolean] * Arg: report_level Undocumented argument [int] * Arg: die_on_error if true, dies if there is an error [boolean] * Arg: dbsi Undocumented argument [Wise2_DBSearchImpl *] * * Returns a newly allocated Hscore structure of the search [Wise2_Hscore *] * */ Wise2_Hscore * Wise2_Hscore_from_TSM_estwise( Wise2_ThreeStateDB * tdb,Wise2_cDNADB * cdb,Wise2_cDNAParser * cp,Wise2_CodonMapper * cm,Wise2_RandomModelDNA * rmd,boolean use_syn,int alg,double bits_cutoff,Probability allN,boolean flat_insert,int report_level,boolean die_on_error,Wise2_DBSearchImpl * dbsi); /* Function: Wise2_AlnBlock_from_Protein_estwise_wrap(pro,cdna,cp,cm,ct,comp,gap,ext,is_global,rmd,alg,rm,use_syn,allN,dpri,palpoi) * * Descrip: This function is the guts for the est single alignment * mode. * * It uses /AlnBlock_from_TSM_estwise_wrap for the * heavy part of the call * * * Arg: pro protein to be used in the comparison [Wise2_Protein *] * Arg: cdna cdna to be compared to [Wise2_cDNA *] * Arg: cp cdna parser indicating insertion deletion probabilities [Wise2_cDNAParser *] * Arg: cm codon mapper indicating substitution errors etc [Wise2_CodonMapper *] * Arg: ct codon table for the codon->amino acid mappings [Wise2_CodonTable *] * Arg: comp comparison matrix to use [Wise2_CompMat *] * Arg: gap gap penalty [int] * Arg: ext extension penalty [int] * Arg: is_global if true, global start-end in protein is used [boolean] * Arg: rmd random model of dna to use [Wise2_RandomModelDNA *] * Arg: alg est algorithm type to use [int] * Arg: rm random protein model for use with compmat [Wise2_RandomModel *] * Arg: use_syn if true, uses a synchronous coding model [boolean] * Arg: allN Undocumented argument [Probability] * Arg: dpri Undocumented argument [Wise2_DPRunImpl *] * Arg: palpoi the raw packed alignment output if wanted [Wise2_PackAln **] * * Returns Undocumented return value [Wise2_AlnBlock *] * */ Wise2_AlnBlock * Wise2_AlnBlock_from_Protein_estwise_wrap( Wise2_Protein * pro,Wise2_cDNA * cdna,Wise2_cDNAParser * cp,Wise2_CodonMapper * cm,Wise2_CodonTable * ct,Wise2_CompMat * comp,int gap,int ext,boolean is_global,Wise2_RandomModelDNA * rmd,int alg,Wise2_RandomModel * rm,boolean use_syn,Probability allN,Wise2_DPRunImpl * dpri,Wise2_PackAln ** palpoi); /* Function: Wise2_AlnBlock_from_TSM_estwise_wrap(tsm,cdna,cp,cm,ct,rmd,alg,use_syn,force_flat_insert,allN,dpri,palpoi) * * Descrip: This function is the basic wrap for Protein models * vs cDNA sequences. * * * Arg: tsm threestatemodel to be compared to the dna [Wise2_ThreeStateModel *] * Arg: cdna cdna to be compared to [Wise2_cDNA *] * Arg: cp cdna parser indicating insertion deletion probabilities [Wise2_cDNAParser *] * Arg: cm codon mapper indicating substitution errors etc [Wise2_CodonMapper *] * Arg: ct codon table for the codon->amino acid mappings [Wise2_CodonTable *] * Arg: rmd random model of dna to use [Wise2_RandomModelDNA *] * Arg: alg est algorithm type to use [int] * Arg: use_syn if true, uses a synchronous coding model [boolean] * Arg: force_flat_insert Undocumented argument [boolean] * Arg: allN Undocumented argument [Probability] * Arg: dpri Undocumented argument [Wise2_DPRunImpl *] * Arg: palpoi the raw packed alignment output if wanted [Wise2_PackAln **] * * Returns Undocumented return value [Wise2_AlnBlock *] * */ Wise2_AlnBlock * Wise2_AlnBlock_from_TSM_estwise_wrap( Wise2_ThreeStateModel * tsm,Wise2_cDNA * cdna,Wise2_cDNAParser * cp,Wise2_CodonMapper * cm,Wise2_CodonTable * ct,Wise2_RandomModelDNA * rmd,int alg,boolean use_syn,boolean force_flat_insert,Probability allN,Wise2_DPRunImpl * dpri,Wise2_PackAln ** palpoi); /* Function: Wise2_alg_estwrap_from_string(str) * * Descrip: This function returns the algorithm type * for an est search from the string * * * Arg: str Undocumented argument [char *] * * Returns Undocumented return value [int] * */ int Wise2_alg_estwrap_from_string( char * str); wise-2.4.1/src/models/estwrap_api.t0000644000175000001440000000000010670453713016622 0ustar philippuserswise-2.4.1/src/models/makepwm.c0000644000175000001440000000046007343207564015742 0ustar philippusers#include "pwmdna.h" int main (int argc,char ** argv) { SeqAlign * sa; pwmDNA * dna; sa = read_selex_SeqAlign(stdin); if( sa == NULL ) { fprintf(stderr,"Unable to read alignment on stdin"); exit(1); } dna = pwmDNA_from_SeqAlign(sa,1.0); show_pwmDNA_col(dna,stdout); } wise-2.4.1/src/models/estwise3.dy0000644000175000001440000001272307313404544016240 0ustar philippusers/* Last edited: Apr 24 15:04 1997 (birney) */ %{ #include "dyna.h" #include "cdparser.h" #include "genewisemodel.h" #include "genewisemodeldb.h" %} matrix EstWise3 query type="CDNA_HMM" name="query" field:len="len" target type="CDNA" name="target" resource type="cDNAParserScore *" name="cp" extern name="GW_*" type="int" extern name="PCD_*" type="int" globaldefaultscore NEGI state MATCH offi="1" offj="3" source MATCH calc="query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource # # Sequencing error transitions, at offsets 1,2,4,5 for delete 1,2 or insert 1,2 # source MATCH offi="1" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source MATCH offi="1" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource source INSERT offi="1" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="1" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="1" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source INSERT offi="1" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource source DELETE offi="1" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source DELETE offi="1" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source DELETE offi="1" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source DELETE offi="1" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource query_label MATCH_STATE target_label CODON endstate # # Insert state: does not move along model, produces DNA sequence... # state INSERT offi="0" offj="3" source MATCH calc="query->seg[i]->transition[GW_MATCH2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource # # Sequencing error transitions # source INSERT offi="0" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source INSERT offi="0" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource source MATCH offi="0" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="0" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="0" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source MATCH offi="0" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource source DELETE offi="0" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source DELETE offi="0" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source DELETE offi="0" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source DELETE offi="0" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="query->seg[i]->transition[GW_MATCH2DELETE]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2DELETE]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2DELETE]" endsource source START calc="query->seg[i]->transition[GW_START2DELETE]" endsource query_label DELETE_STATE target_label INSERT endstate state START !start !special defscore="0" endstate state END !end !special source MATCH calc="query->seg[i]->transition[GW_MATCH2END]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2END]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2END]" endsource target_label END query_label END endstate endmatrix wise-2.4.1/src/models/pairwiseshortdna.c0000644000175000001440000001273110670453714017670 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "pairwiseshortdna.h" # line 18 "pairwiseshortdna.dy" boolean process_HSP(HSPset * set,Sequence * query,int query_pos,Sequence * tseq,SeqLookupResultStruct * res_struct,CompMat * mat) { HSP * h; int k; for(k=0;klen;k++) { if( on_HSP(set->hsp[k],query_pos,res_struct->pos) == TRUE ) { return FALSE; } } /* new HSP - extend and add */ h = new_HSP(NULL,query,tseq,query_pos,res_struct->pos,mat,10*Probability2Score(0.8/0.25)); /* fprintf(stderr,"Processing HSP with %d %d\n",h->length,h->score); */ add_HSPset(set,h); return TRUE; } # line 41 "pairwiseshortdna.dy" PairwiseShortDna * query_to_reverse_target(Sequence * query,Sequence * target,DnaMatrix * dm,int qstart,int qend,int tstart,int tend) { PairwiseShortDna * out; HSPset * forward; HSPset * reverse; CompMat * cm; SeqLookupInterface * sli; SeqLookupClientInterface * slci; SeqLookupResultInterface * res; SeqLookupResultStruct * res_struct = NULL; Sequence * revseq; int i; int no; GTree * forward_tree; GTree * reverse_tree; out = PairwiseShortDna_alloc(); cm = new_CompMat_from_DnaMatrix_flat(dm); /* reverse sequence */ revseq = reverse_complement_Sequence(target); forward_tree = g_tree_new(g_int_equal); reverse_tree = g_tree_new(g_int_equal); /* build a hash based lookup table */ sli = new_ghash_SeqLookupInterface(); assert(cm); assert(target); assert(revseq); assert(sli); for(i=tstart;iname); } no = seq_number_dna_7mer_noN(target->seq+i); if( no != -1 ) { (*sli->add_direct_number)(sli->data,no,target,i); } } for(i=target->len-tend;ilen-tstart-7;i++) { if( i%1000 == 0 ) { info("Loaded %d positions in %s",i,target->name); } no = seq_number_dna_7mer_noN(revseq->seq+i); if( no != -1 ) { (*sli->add_direct_number)(sli->data,no,revseq,i); } } forward = HSPset_alloc_std(); reverse = HSPset_alloc_std(); /* scan the table with the query, testing whether new hits fit into HSP */ slci = (*sli->get_client)(sli->data); for(i=qstart;iname,forward->len,reverse->len); } no = seq_number_dna_7mer_noN(query->seq+i); if( no == -1 ) { continue; } if( (*slci->is_populated)(sli->data,no) == FALSE) { continue; } res = (*slci->lookup)(sli->data,no); while( (*res->is_more)(res->data) ) { res_struct = (*res->next)(res->data,res_struct); if( res_struct->seq == target ) { process_HSP(forward,query,i,target,res_struct,cm); } else { process_HSP(reverse,query,i,revseq,res_struct,cm); } } free_SeqLookupResultInterface(res); } free_SeqLookupClientInterface(slci); out->forward = forward; out->reverse = reverse; return out; } # line 138 "pairwiseshortdna.c" /* Function: hard_link_PairwiseShortDna(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PairwiseShortDna *] * * Return [UNKN ] Undocumented return value [PairwiseShortDna *] * */ PairwiseShortDna * hard_link_PairwiseShortDna(PairwiseShortDna * obj) { if( obj == NULL ) { warn("Trying to hard link to a PairwiseShortDna object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PairwiseShortDna_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PairwiseShortDna *] * */ PairwiseShortDna * PairwiseShortDna_alloc(void) { PairwiseShortDna * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PairwiseShortDna *) ckalloc (sizeof(PairwiseShortDna))) == NULL) { warn("PairwiseShortDna_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->forward = NULL; out->reverse = NULL; return out; } /* Function: free_PairwiseShortDna(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PairwiseShortDna *] * * Return [UNKN ] Undocumented return value [PairwiseShortDna *] * */ PairwiseShortDna * free_PairwiseShortDna(PairwiseShortDna * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PairwiseShortDna obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->forward != NULL) free_HSPset(obj->forward); if( obj->reverse != NULL) free_HSPset(obj->reverse); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/pairwiseshortdna.h0000644000175000001440000000540610670453714017676 0ustar philippusers#ifndef DYNAMITEpairwiseshortdnaHEADERFILE #define DYNAMITEpairwiseshortdnaHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "hsp.h" #include "subseqhash.h" struct Wise2_PairwiseShortDna { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif HSPset * forward; HSPset * reverse; } ; /* PairwiseShortDna defined */ #ifndef DYNAMITE_DEFINED_PairwiseShortDna typedef struct Wise2_PairwiseShortDna Wise2_PairwiseShortDna; #define PairwiseShortDna Wise2_PairwiseShortDna #define DYNAMITE_DEFINED_PairwiseShortDna #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_PairwiseShortDna(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PairwiseShortDna *] * * Return [UNKN ] Undocumented return value [PairwiseShortDna *] * */ PairwiseShortDna * Wise2_hard_link_PairwiseShortDna(PairwiseShortDna * obj); #define hard_link_PairwiseShortDna Wise2_hard_link_PairwiseShortDna /* Function: PairwiseShortDna_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PairwiseShortDna *] * */ PairwiseShortDna * Wise2_PairwiseShortDna_alloc(void); #define PairwiseShortDna_alloc Wise2_PairwiseShortDna_alloc /* Function: free_PairwiseShortDna(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PairwiseShortDna *] * * Return [UNKN ] Undocumented return value [PairwiseShortDna *] * */ PairwiseShortDna * Wise2_free_PairwiseShortDna(PairwiseShortDna * obj); #define free_PairwiseShortDna Wise2_free_PairwiseShortDna /* Unplaced functions */ /* There has been no indication of the use of these functions */ boolean Wise2_process_HSP(HSPset * set,Sequence * query,int query_pos,Sequence * tseq,SeqLookupResultStruct * res_struct,CompMat * mat); #define process_HSP Wise2_process_HSP PairwiseShortDna * Wise2_query_to_reverse_target(Sequence * query,Sequence * target,DnaMatrix * dm,int qstart,int qend,int tstart,int tend); #define query_to_reverse_target Wise2_query_to_reverse_target /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/estwisedb.c0000644000175000001440000007570407705225351016303 0ustar philippusers /* has to be before the others due to nasty namespace clashes */ #define WISE2_CROSS_HMMER2 #include "wise2xhmmer2.h" #include "dyna.h" #include "version.h" char * program_name = "estwisedb"; /* * program specific includes */ #include "estwrap.h" #include "genedisplay.h" #include "matchsum.h" #define WISE2_DEFINED /*#define WISE2_CROSS_HMMER1 #include "hmmio.h" */ /* cross-file Wise2<->HMMER1 */ /* * program specific variables */ enum PC_SEARCH_MODE { PC_SEARCH_S2DB, PC_SEARCH_DB2S, PC_SEARCH_DB2DB }; int search_mode; GeneWiseDB * gwdb = NULL; char * dna_seq_file = NULL; cDNADB * cdb = NULL; SequenceDB * sdb = NULL; cDNA * cdna = NULL; boolean use_single_dna = FALSE; boolean do_forward_only = FALSE; char * protein_file = NULL; Protein * pro = NULL; char * hmm_file = NULL; ThreeStateModel * tsm = NULL; char * hmm_name = NULL; ThreeStateDB * tsmdb = NULL; GeneWiseScore * gws = NULL; Hscore * hs = NULL; CodonMapper * cm; cDNAParser * cps; /** different protein possibilities **/ boolean use_single_pro = FALSE; boolean use_db_pro = FALSE; boolean use_tsm = FALSE; boolean use_pfam1 = FALSE; boolean use_pfam2 = FALSE; char * qstart_str = NULL; int qstart = -1; char * qend_str = NULL; int qend = -1; char * matrix_file = "BLOSUM62.bla"; CompMat * mat = NULL; char * gap_str = "12"; int gap = 12; char * ext_str = "2"; int ext = 2; char * codon_file = NULL; CodonTable * ct = NULL; char * output_file = "-"; FILE * ofp = NULL; char * report_str = NULL; int report_stagger = -1; RandomModelDNA * rmd = NULL; char * subs_string = "0.01"; double subs_error = 0.01; char * indel_string = "0.01"; double indel_error = 0.01; char * allN_string = "1.0"; Probability allN = 1.0; boolean flat_insert = FALSE; char * startend_string = "default"; int startend = TSM_default; char * null_string = "syn"; boolean use_syn = TRUE; DBSearchImpl * dbsi = NULL; int alg = ESTSLIM_3; char * alg_str = NULL; DPRunImpl * dpri = NULL; int aln_alg = ESTWISE_3; char * aln_alg_str = NULL; int aln_number = 50; char * aln_number_str = "50"; double search_cutoff = 20.00; char * search_cutoff_str = "20.00"; double evalue_search_cutoff = -1.0; char * evalue_search_str = NULL; char * kbyte_str = NULL; int kbyte = 10000; /* will be reset in build_defaults */ boolean show_histogram = TRUE; boolean show_PackAln = FALSE; boolean show_AlnBlock = FALSE; boolean show_pretty = FALSE; boolean show_pep = FALSE; boolean show_match_sum = FALSE; boolean show_para = FALSE; boolean do_complete_analysis = FALSE; boolean make_anchored_aln = FALSE; char * main_block_str = "50"; int main_block = 50; char * divide_str = "//"; Probability rnd_loop = 0.99; Probability cds_loop = 0.97; Probability rnd_to_model = (1 - 0.99) / 3; Probability link_loop = 0.98; Probability link_to_model = (1- 0.98) / 3; AlnBlock * alb; PackAln * pal; MatchSummarySet * mss; RandomModel * rm; boolean show_output(void) { int i,k; ThreeStateModel * temptsm; AlnBlock * alb; PackAln * pal; MatchSummarySet * mss; Protein * ps; cDNA * cdna; double bits; boolean fitted_res = FALSE; AlnBlockList * alist; AlnBlock * anchored; SequenceSet * set; AlnColumn * alt; Protein * trans; /* sort by bit score first */ sort_Hscore_by_score(hs); if( search_mode == PC_SEARCH_S2DB ) { if( hs->his == NULL || hs->his->total < 1000 ) { info("Cannot fit histogram to a db smaller than 1,000"); fprintf(ofp,"[Warning: Can't fit histogram to a db smaller than 1,000]\n\n"); show_histogram = FALSE; } else { fitted_res = TRUE; fit_Hscore_to_EVD(hs,20); } } /* deal with initialising anchored alignment. * Could be done for either single HMMs or single proteins, * but we will only do it for HMMs at the moment */ if( make_anchored_aln == TRUE ) { if( tsm == NULL ) { warn("Attempting to make an achored alignment without a HMM. impossible!"); make_anchored_aln = FALSE; } else { anchored = single_unit_AlnBlock(tsm->len,"MATCH_STATE"); set = SequenceSet_alloc_std(); } } /* dofus catcher */ if( aln_alg != alg ) { fprintf(ofp,"\n#\n#WARNING!\n#\n# Your alignment algorithm is different from your search algorithm.\n# This is probably quite sensible but will lead to differing scores.\n# Use the search score as an indicator of the significance of the match\n# Read the docs for more information\n#\n"); } fprintf(ofp,"\n\n#High Score list\n"); fprintf(ofp,"#Protein ID DNA Str ID Bits Evalue\n"); fprintf(ofp,"--------------------------------------------------------------------------\n"); for(i=0;ilen;i++) { bits = Score2Bits(hs->ds[i]->score); if( bits < search_cutoff ) { break; } if( fitted_res == TRUE && evalue_search_str != NULL ) { if( hs->ds[i]->evalue > evalue_search_cutoff ) break; } if( fitted_res == TRUE) fprintf(ofp,"Protein %-20sDNA [%c] %-24s %.2f %.2g\n",hs->ds[i]->query->name,hs->ds[i]->target->is_reversed == TRUE ? '-' : '+',hs->ds[i]->target->name,bits,hs->ds[i]->evalue); else fprintf(ofp,"Protein %-20sDNA [%c] %-24s %.2f\n",hs->ds[i]->query->name,hs->ds[i]->target->is_reversed == TRUE ? '-' : '+',hs->ds[i]->target->name,bits); } if( search_mode == PC_SEARCH_S2DB && show_histogram == TRUE ) { fprintf(ofp,"\n\n#Histogram\n"); fprintf(ofp,"-----------------------------------------------------------------------\n"); PrintASCIIHistogram(hs->his,ofp); } fprintf(ofp,"\n\n#Alignments\n"); fprintf(ofp,"-----------------------------------------------------------------------\n"); for(i=0;ilen;i++) { bits = Score2Bits(hs->ds[i]->score); if( bits < search_cutoff ) { break; } if( i >= aln_number ) { break; } if( fitted_res == TRUE && evalue_search_str != NULL ) { if( hs->ds[i]->evalue > evalue_search_cutoff ) break; } fprintf(ofp,"\n\n>Results for %s vs %s (%s) [%d]\n",hs->ds[i]->query->name,hs->ds[i]->target->name,hs->ds[i]->target->is_reversed == TRUE ? "reverse" : "forward",i+1 ); cdna = get_cDNA_from_cDNADB(cdb,hs->ds[i]->target); temptsm = indexed_ThreeStateModel_ThreeStateDB(tsmdb,hs->ds[i]->query); alb = AlnBlock_from_TSM_estwise_wrap(temptsm,cdna,cps,cm,ct,rmd,aln_alg,use_syn,allN,flat_insert,dpri,&pal); if( alb == NULL ) { warn("Got a NULL alignment. Exiting now due to presumed problems"); fprintf(ofp,"\n\n*Got a NULL alignment. Exiting now due to presumed problems*\n\n"); return FALSE; } if( use_single_pro == FALSE) mss = MatchSummarySet_from_AlnBlock_genewise(alb,temptsm->name,1,cdna->baseseq); else mss = MatchSummarySet_from_AlnBlock_genewise(alb,pro->baseseq->name,pro->baseseq->offset,cdna->baseseq); if( show_pretty == TRUE ) { fprintf(ofp,"\n%s output\nScore %4.2f bits over entire alignment.\nThis will be different from per-alignment scores. See manual for details\nFor computer parsable output, try %s -help or read the manual\n",program_name,Score2Bits(pal->score),program_name); if( use_syn == FALSE ) { fprintf(ofp,"Scores as bits over a flat simple random model\n\n"); } else { fprintf(ofp,"Scores as bits over a synchronous coding model\n\n"); } ps = pseudo_Protein_from_ThreeStateModel(temptsm); protcdna_ascii_display(alb,ps->baseseq->seq,ps->baseseq->name,ps->baseseq->offset,cdna,ct,15,main_block,TRUE,ofp); free_Protein(ps); fprintf(ofp,"%s\n",divide_str); } if( show_match_sum == TRUE ) { show_MatchSummary_genewise_header(ofp); show_MatchSummarySet_genewise(mss,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_pep == TRUE ) { alt = alb->start; for(;alt != NULL;) { trans = Protein_from_GeneWise_AlnColumn(cdna->baseseq,alt,1,&alt,ct,is_random_AlnColumn_genewise); if ( trans == NULL ) break; write_fasta_Sequence(trans->baseseq,ofp); free_Protein(trans); } fprintf(ofp,"%s\n",divide_str); } if( show_AlnBlock == TRUE ) { mapped_ascii_AlnBlock(alb,Score2Bits,0,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_PackAln == TRUE ) { show_simple_PackAln(pal,ofp); fprintf(ofp,"%s\n",divide_str); } /* * This goes at the end because it destroys the alb structure */ if( make_anchored_aln == TRUE ) { /* attach sequence to als in alb, so we have it for later use */ alb->seq[1]->data = (void *) cdna->baseseq; /* add to SequenceSet so we can destroy the memory */ add_SequenceSet(set,hard_link_Sequence(cdna->baseseq)); alist = split_AlnBlock(alb,is_random_AlnColumn_genewise); for(k=0;klen;k++) { /* actually produce the anchored alignment */ /*mapped_ascii_AlnBlock(alist->alb[k],Score2Bits,stderr);*/ add_to_anchored_AlnBlock(anchored,alist->alb[k]); /* dump_ascii_AlnBlock(anchored,stderr);*/ } } alb = free_AlnBlock(alb); pal = free_PackAln(pal); mss = free_MatchSummarySet(mss); cdna = free_cDNA(cdna); temptsm = free_ThreeStateModel(temptsm); } if( do_complete_analysis == TRUE ) { fprintf(ofp,"\n\n#Complete Analysis\n"); fprintf(ofp,"-------------------------------------------------------------\n\n"); /* ok - end of loop over relevant hits. If we have an * anchored alignment, print it out! */ if( make_anchored_aln == TRUE ) { /*dump_ascii_AlnBlock(anchored,stderr);*/ write_mul_estwise_AlnBlock(anchored,ct,ofp); fprintf(ofp,"%s\n",divide_str); } } return TRUE; } boolean search_db(void) { info("Starting search..."); hs = Hscore_from_TSM_estwise(tsmdb,cdb,cps,cm,rmd,use_syn,alg,search_cutoff,allN,flat_insert,report_stagger,FALSE,dbsi); if( hs == NULL ) { return FALSE; } return TRUE; } boolean build_db_objects(void) { if( use_single_dna == TRUE ) { cdb = new_cDNADB_from_single_seq(cdna); } else { cdb = new_cDNADB(sdb); } if( do_forward_only == TRUE ) { cdb->forward_only = TRUE; } return TRUE; } boolean build_objects(void) { boolean ret = TRUE; Protein * pro_temp; SequenceDB * psdb; startend = threestatemodel_mode_from_string(startend_string); if( startend == TSM_unknown ) { warn("String %s was unable to converted into a start/end policy\n",startend_string); ret = FALSE; } if( use_single_dna == TRUE ) { cdna = read_fasta_file_cDNA(dna_seq_file); if( cdna == NULL ) { warn("Could not open single dna sequence in %s",dna_seq_file); ret = FALSE; } } else { sdb = single_fasta_SequenceDB(dna_seq_file); if( sdb == NULL ) { warn("Could not build a sequence database on %s",dna_seq_file); ret = FALSE; } } rm = default_RandomModel(); if( (mat = read_Blast_file_CompMat(matrix_file)) == NULL) { if( use_tsm == TRUE ) { info("I could not read the Comparison matrix file in %s; however, you are using a HMM so it is not needed. Please set the WISECONFIGDIR or WISEPERSONALDIR variable correctly to prevent this message.",matrix_file); } else { warn("Could not read Comparison matrix file in %s",matrix_file); ret = FALSE; } } if( is_integer_string(gap_str,&gap) == FALSE ) { warn("Could not get gap string number %s",gap_str); ret = FALSE; } if( is_integer_string(ext_str,&ext) == FALSE ) { warn("Could not get ext string number %s",ext_str); ret = FALSE; } if( qstart_str != NULL ) { if( is_integer_string(qstart_str,&qstart) == FALSE || qstart < 0) { warn("Could not make %s out as query start",qstart); ret = FALSE; } } if( qend_str != NULL ) { if( is_integer_string(qend_str,&qend) == FALSE || qend < 0) { warn("Could not make %s out as query end",qend); ret = FALSE; } } if( aln_number_str != NULL ) { if( is_integer_string(aln_number_str,&aln_number) == FALSE || aln_number < 0) { warn("Weird aln number string %s...\n",aln_number_str); ret = FALSE; } } if( report_str != NULL ) { if( is_integer_string(report_str,&report_stagger) == FALSE ) { warn("Weird report stagger asked for %s",report_str); ret = FALSE; } } if( use_pfam1 == TRUE ) { tsmdb = new_PfamHmmer1DB_ThreeStateDB(protein_file); if( set_search_type_ThreeStateDB(tsmdb,startend_string) == FALSE) { warn("Unable to set global/local switch on threestatedb"); ret = FALSE; } } else if ( use_pfam2 == TRUE ) { tsmdb = HMMer2_ThreeStateDB(protein_file); if( set_search_type_ThreeStateDB(tsmdb,startend_string) == FALSE) { warn("Unable to set global/local switch on threestatedb"); ret = FALSE; } } else if ( use_tsm == TRUE) { /** using a HMM **/ tsm = HMMer2_read_ThreeStateModel(protein_file); if( tsm == NULL ) { warn("Could not read hmm from %s\n",protein_file); ret = FALSE; } else { display_char_in_ThreeStateModel(tsm); if( hmm_name != NULL ) { if( tsm->name != NULL ) ckfree(tsm->name); tsm->name = stringalloc(hmm_name); } else { if( tsm->name == NULL ) { tsm->name = stringalloc(protein_file); } } /** have to set start/end **/ set_startend_policy_ThreeStateModel(tsm,startend,15,0.2); tsmdb = new_single_ThreeStateDB(tsm,rm); if( tsmdb == NULL ) { warn("Could not build a threestatemodel database from a single tsm. Weird!"); ret = FALSE; } } /* end of else tsm != NULL */ } /* end of else is tsm */ else if( use_single_pro ) { if( startend != TSM_default && startend != TSM_global && startend != TSM_local ) { warn("Proteins can only have local/global startend policies set, not %s",startend_string); ret = FALSE; } if( (pro = read_fasta_file_Protein(protein_file)) == NULL ) { ret = FALSE; warn("Could not read Protein sequence in %s",protein_file); } else { if( qstart != -1 || qend != -1 ) { if( qstart == -1 ) qstart = 0; if( qend == -1 ) qend = pro->baseseq->len; pro_temp = truncate_Protein(pro,qstart-1,qend); if( pro_temp == NULL ){ ret = FALSE; } else { free_Protein(pro); pro = pro_temp; } } if( startend == TSM_global) tsm = global_ThreeStateModel_from_half_bit_Sequence(pro,mat,rm,-gap,-ext); else tsm = ThreeStateModel_from_half_bit_Sequence(pro,mat,rm,-gap,-ext); if( tsm == NULL ) { warn("Could not build ThreeStateModel from a single protein sequence..."); ret = FALSE; } else { tsmdb = new_single_ThreeStateDB(tsm,rm); if( tsmdb == NULL ) { warn("Could not build a threestatemodel database from a single tsm. Weird!"); ret = FALSE; } } /* end of could build a TSM */ } /* else is a real protein */ } /* end of else is single protein */ else if (use_db_pro == TRUE ) { psdb = single_fasta_SequenceDB(protein_file); tsmdb = new_proteindb_ThreeStateDB(psdb,mat,-gap,-ext); free_SequenceDB(psdb); } else { warn("No protein input file! Yikes!"); } /*** if( use_tsm == FALSE ) { } else { ****/ if( main_block_str != NULL ) { if( is_integer_string(main_block_str,&main_block) == FALSE ) { warn("Could not get maximum main_block number %s",main_block_str); ret = FALSE; } } if( evalue_search_str != NULL && is_double_string(evalue_search_str,&evalue_search_cutoff) == FALSE ) { warn("Could not convert %s to a double",evalue_search_str); ret = FALSE; } if( is_double_string(search_cutoff_str,&search_cutoff) == FALSE ) { warn("Could not convert %s to a double",search_cutoff_str); ret = FALSE; } if( is_double_string(subs_string,&subs_error) == FALSE ) { warn("Could not convert %s to a double",subs_error); ret = FALSE; } if( is_double_string(indel_string,&indel_error) == FALSE ) { warn("Could not convert %s to a double",indel_error); ret = FALSE; } if( is_double_string(allN_string,&allN) == FALSE ) { warn("Could not convert %s to a double",allN_string); ret = FALSE; } if( strcmp(null_string,"syn") == 0 ) { use_syn = TRUE; } else if ( strcmp(null_string,"flat") == 0 ) { use_syn = FALSE; } else { warn("Cannot interpret [%s] as a null model string\n",null_string); ret = FALSE; } if( alg_str != NULL ) { alg = alg_estwrap_from_string(alg_str); } else { alg_str = "312"; alg = alg_estwrap_from_string(alg_str); } if( aln_alg_str != NULL ) { aln_alg = alg_estwrap_from_string(aln_alg_str); } else { /* if it is a protein, don't loop */ if( use_single_pro == TRUE || use_db_pro == TRUE ) aln_alg_str = "333"; else aln_alg_str = "333L"; aln_alg = alg_estwrap_from_string(aln_alg_str); } if( (rm = default_RandomModel()) == NULL) { warn("Could not make default random model\n"); ret = FALSE; } if( (ct = read_CodonTable_file(codon_file)) == NULL) { ret = FALSE; warn("Could not read codon table file in %s",codon_file); } if( (ofp = openfile(output_file,"W")) == NULL) { warn("Could not open %s as an output file",output_file); ret = FALSE; } rmd = RandomModelDNA_std(); cps = flat_cDNAParser(indel_error); cm = flat_CodonMapper(ct); sprinkle_errors_over_CodonMapper(cm,subs_error); return ret; } void free_objects(void) { if( gwdb != NULL ) gwdb = free_GeneWiseDB(gwdb); if( cdb != NULL ) cdb = free_cDNADB(cdb); if( sdb != NULL ) sdb = free_SequenceDB(sdb); if( cdna != NULL ) cdna = free_cDNA(cdna); if( pro != NULL ) pro = free_Protein(pro); if( tsm != NULL ) tsm = free_ThreeStateModel(tsm); if( tsmdb != NULL ) tsmdb = free_ThreeStateDB(tsmdb); if( gws != NULL ) gws = free_GeneWiseScore(gws); if( hs != NULL ) hs = free_Hscore(hs); if( cm != NULL ) cm = free_CodonMapper(cm); if( cps != NULL ) cps = free_cDNAParser(cps); } void show_short_help(void) { fprintf(stdout,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(stdout,"This program is freely distributed under a GPL. See -version for more info\n"); fprintf(stdout,"Copyright (c) GRL limited: portions of the code are from separate copyrights\n\n"); fprintf(stdout,"spcwise in fasta format\n"); fprintf(stdout," Options. In any order, '-' as filename (for any input) means stdin\nDon't use stdin for databases, as on-the-fly indexing is used\n"); fprintf(stdout," Protein type [-protein,-prodb,-hmmer,-pfam] [default - protein]\n"); fprintf(stdout," Dna type [-dnas,-dnadb] [default - dnadb]\n"); fprintf(stdout," Dna [-tfor]\n"); fprintf(stdout," Protein [-s,-t,-g,-e,-m]\n HMM [-hmmer,-hname]\n"); fprintf(stdout," Model [-codon,-subs,-indel,-null]\n Alg [-kbyte,-alg,-aalg,-aln,-noh]\n"); fprintf(stdout," Output [-pretty,-alb,-pal,-block,-divide]\n"); fprintf(stdout," Standard [-help,-version,-silent,-quiet,-errorlog]\n"); fprintf(stdout,"\nFor more help go %s -help.\n",program_name); fprintf(stdout,"\nSee WWW help at http://www.sanger.ac.uk/Software/Wise2/\n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(ofp,"%s \n",program_name); /* program specific help */ fprintf(ofp,"Protein input type\n"); fprintf(ofp," -protein [default] single protein\n"); fprintf(ofp," -prodb protein fasta format db\n"); fprintf(ofp," -pfam pfam hmm library \n"); fprintf(ofp," -pfam2 pfam style model directory (2.1) \n"); fprintf(ofp," -hmmer single hmmer 1.x HMM\n"); fprintf(ofp,"DNA input type\n"); fprintf(ofp," -dnadb [default] dna fasta database\n"); fprintf(ofp," -dnas a single dna fasta sequence\n"); fprintf(ofp,"DNA sequence options\n"); fprintf(ofp," -tfor search forward strands only\n"); fprintf(ofp,"Protein comparison options\n"); fprintf(ofp," -gap [%3d] gap penalty\n",gap); fprintf(ofp," -ext [%3d] extension penalty\n",ext); fprintf(ofp," -matrix [%s] Comparison matrix\n",matrix_file); fprintf(ofp,"HMM options\n"); fprintf(ofp," -hname For single hmms, use this as the name, not filename\n"); fprintf(ofp,"Model options\n"); fprintf(ofp," -init [%s] [default/global/local/wing] start-end policy\n",startend_string); fprintf(ofp," -codon [%s] Codon file\n",codon_file); fprintf(ofp," -subs [%2.2g] Substitution error rate\n",subs_error); fprintf(ofp," -indel [%2.2g] Insertion/deletion error rate\n",indel_error); fprintf(ofp," -null [syn/flat] Random Model as synchronous or flat [default syn]\n"); fprintf(ofp," -alln [%s] Probability of matching a NNN codon\n",allN_string); fprintf(ofp," -flati Flat insert probabilities\n"); fprintf(ofp,"Algorithm options\n"); fprintf(ofp," -alg [333/312] Algorithm used for searching [default %s]\n",string_from_alg_estwrap(alg)); fprintf(ofp," -aalg [312/333/333L] Algorithm used for alignment [default %s]\n",string_from_alg_estwrap(aln_alg)); fprintf(ofp," -cut [%.2f] Bits cutoff for reporting in search algorithm\n",search_cutoff); fprintf(ofp," -ecut [n/a] Evalue cutoff for single protein vs DNA searches.\n"); fprintf(ofp," -aln [%d] Max number of alignments (even if above cut)\n",aln_number); fprintf(ofp," -nohis Don't show histogram on single protein/hmm vs DNA search\n"); fprintf(ofp," -report [0] Issue a report every x comparisons (default 0 comparisons)\n"); fprintf(ofp,"Output options for each alignment [default -pretty -para]\n"); fprintf(ofp," -pretty show pretty ascii output\n"); fprintf(ofp," -para show parameters\n"); fprintf(ofp," -pep show protein translation, splicing frameshifts\n"); fprintf(ofp," -mul protein mul format alignments [only for one HMM vs DNA db]\n"); fprintf(ofp," -sum show summary output\n"); fprintf(ofp," -alb show logical AlnBlock alignment\n"); fprintf(ofp," -pal show raw matrix alignment\n"); fprintf(ofp," -block [%s] Length of main block in pretty output\n",main_block_str); fprintf(ofp," -divide [%s] divide string for multiple outputs\n",divide_str); show_help_DBSearchImpl(ofp); show_help_DPRunImpl(ofp); show_standard_options(ofp); fprintf(ofp,"\nSee WWW help at http://www.sanger.ac.uk/Software/Wise2/\n"); exit(63); } boolean show_header(FILE * ofp) { fprintf(ofp,"-------------------------------------------------------------\n"); fprintf(ofp,"Wise2 - database searching mode\n"); fprintf(ofp,"Program: %s version: %s released: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY); fprintf(ofp,"This program is freely distributed under a Gnu Public License.\n"); fprintf(ofp," See -version for more info on copyright\n"); fprintf(ofp,"Bugs and credits to Ewan Birney \n"); fprintf(ofp,"-------------------------------------------------------------\n\n"); fprintf(ofp,"Algorithm type: EstWise\n"); fprintf(ofp,"Search algorithm: %s\n",alg_str); fprintf(ofp,"Implementation: %s\n",impl_string_DBSearchImpl(dbsi)); fprintf(ofp,"Search mode: %s\n",search_mode == PC_SEARCH_S2DB ? "Single protein vs cdna db" : search_mode == PC_SEARCH_DB2S ? "Single cdna vs protein db" : "Protein db vs cdna db"); fprintf(ofp,"Protein info from: %s\n",protein_file); fprintf(ofp,"Dna info from: %s\n",dna_seq_file); if( use_single_pro == TRUE || use_db_pro == TRUE ) { fprintf(ofp,"Comp Matrix: %s\n",matrix_file); fprintf(ofp,"Gap open: %d\n",gap); fprintf(ofp,"Gap extension: %d\n",ext); } fprintf(ofp,"Start/End %s\n",startend_string); fprintf(ofp,"Codon Table: %s\n",codon_file); fprintf(ofp,"Subs error: %2.2g\n",subs_error); fprintf(ofp,"Indel error: %2.2g\n",indel_error); fprintf(ofp,"Null model: %s\n",use_syn == FALSE ? "flat" : "synchronous"); fprintf(ofp,"Protein Insertion: %s\n",flat_insert == TRUE ? "flat" : "modelled"); fprintf(ofp,"Alignment Alg %s\n",aln_alg_str); return TRUE; } void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) GRL 1998 and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney wrote the core code.\n"); fprintf(ofp," Portions of this code was from HMMer1, written by Sean Eddy\n"); fprintf(ofp," Portions of this code was from HMMer2, written by Sean Eddy\n"); exit(63); } void build_defaults(void) { codon_file = "codon.table"; matrix_file = "BLOSUM62.bla"; } int main(int argc,char ** argv) { int i; char * temp; build_defaults(); bootstrap_HMMer2(); strip_out_standard_options(&argc,argv,show_help,show_version); if( (temp = strip_out_assigned_argument(&argc,argv,"gap")) != NULL ) gap_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"g")) != NULL ) gap_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"ext")) != NULL ) ext_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"e")) != NULL ) ext_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"matrix")) != NULL ) matrix_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"m")) != NULL ) matrix_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"s")) != NULL ) qstart_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"t")) != NULL ) qend_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"aln")) != NULL ) aln_number_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"codon")) != NULL ) codon_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"alg")) != NULL ) alg_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"aalg")) != NULL ) aln_alg_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"cut")) != NULL ) search_cutoff_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"ecut")) != NULL ) evalue_search_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"subs")) != NULL ) subs_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"indel")) != NULL ) indel_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"init")) != NULL ) startend_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"alln")) != NULL ) allN_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"null")) != NULL ) null_string = temp; if( (strip_out_boolean_argument(&argc,argv,"dnas")) == TRUE ) use_single_dna = TRUE; if( (strip_out_boolean_argument(&argc,argv,"dnadb")) == TRUE ) use_single_dna = FALSE; if( (strip_out_boolean_argument(&argc,argv,"tfor")) == TRUE ) do_forward_only = TRUE; if( (strip_out_boolean_argument(&argc,argv,"flati")) == TRUE ) flat_insert = TRUE; if( (strip_out_boolean_argument(&argc,argv,"hmmer")) == TRUE ) use_tsm = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pfam2")) == TRUE ) use_pfam1 = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pfam")) == TRUE ) use_pfam2 = TRUE; if( (strip_out_boolean_argument(&argc,argv,"protein")) == TRUE ) use_single_pro = TRUE; if( (strip_out_boolean_argument(&argc,argv,"prodb")) == TRUE ) use_db_pro = TRUE; if( (temp = strip_out_assigned_argument(&argc,argv,"hname")) != NULL ) hmm_name = temp; if( (strip_out_boolean_argument(&argc,argv,"nohis")) != FALSE ) show_histogram = FALSE; if( (strip_out_boolean_argument(&argc,argv,"pretty")) != FALSE ) show_pretty = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pep")) != FALSE ) show_pep = TRUE; if( (strip_out_boolean_argument(&argc,argv,"mul")) != FALSE ) make_anchored_aln = TRUE; if( (strip_out_boolean_argument(&argc,argv,"para")) != FALSE ) show_para = TRUE; if( (strip_out_boolean_argument(&argc,argv,"sum")) != FALSE ) show_match_sum = TRUE; if( (strip_out_boolean_argument(&argc,argv,"alb")) != FALSE ) show_AlnBlock = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pal")) != FALSE ) show_PackAln = TRUE; if( (temp = strip_out_assigned_argument(&argc,argv,"divide")) != NULL ) divide_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"block")) != NULL ) main_block_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"report")) != NULL ) report_str = temp; dbsi = new_DBSearchImpl_from_argv(&argc,argv); dpri = new_DPRunImpl_from_argv(&argc,argv); strip_out_remaining_options_with_warning(&argc,argv); if( argc != 3 ) { warn("Wrong number of arguments (expect 2)!\n"); if( argc > 1 ){ warn("Arg line looked like (after option processing)"); for(i=1;ibasematrix->matrix[((j+4)*3)+STATE][i+1] #define EstSlimLoop3_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+4] #define EstSlimLoop3_READ_OFF_ERROR -6 #define EstSlimLoop3_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+5)%5][((i+1)*3)+STATE] #define EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+5)%5][STATE] #define EstSlimLoop3_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define EstSlimLoop3_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_EstSlimLoop3(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_EstSlimLoop3(EstSlimLoop3 * mat) { EstSlimLoop3_access_func_holder holder; holder.access_main = EstSlimLoop3_shatter_access_main; holder.access_special = EstSlimLoop3_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_EstSlimLoop3(mat,holder); } /* Function: EstSlimLoop3_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstSlimLoop3_shatter_access_main(EstSlimLoop3 * mat,int i,int j,int state) { return EstSlimLoop3_SHATTER_MATRIX(mat,i,j,state); } /* Function: EstSlimLoop3_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstSlimLoop3_shatter_access_special(EstSlimLoop3 * mat,int i,int j,int state) { return EstSlimLoop3_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_EstSlimLoop3(mat,dpenv) * * Descrip: This function calculates the EstSlimLoop3 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EstSlimLoop3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_EstSlimLoop3(EstSlimLoop3 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_2; int * SIG_1_4; int * SIG_0_3; int * SIG_0_2; int * SIG_0_4; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,3); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("EstSlimLoop3 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstSlimLoop3_SHATTER_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = EstSlimLoop3_SHATTER_SPECIAL(mat,i-1,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_4[MATCH] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ SIG_0_0[MATCH] = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlimLoop3_SHATTER_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlimLoop3_SHATTER_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstSlimLoop3_SHATTER_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = EstSlimLoop3_SHATTER_SPECIAL(mat,i-0,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_2[INSERT] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_4[INSERT] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ SIG_0_0[INSERT] = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlimLoop3_SHATTER_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlimLoop3_SHATTER_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstSlimLoop3_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlimLoop3_SHATTER_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlimLoop3_SHATTER_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstSlimLoop3_SHATTER_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = EstSlimLoop3_SHATTER_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = EstSlimLoop3_SHATTER_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ EstSlimLoop3_SHATTER_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstSlimLoop3_SHATTER_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = EstSlimLoop3_SHATTER_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Put back score... (now updated!) */ EstSlimLoop3_SHATTER_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: search_EstSlimLoop3(dbsi,out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstSlimLoop3 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_EstSlimLoop3(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_EstSlimLoop3 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_EstSlimLoop3. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_EstSlimLoop3. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for EstSlimLoop3, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_EstSlimLoop3(out,querydb, targetdb ,cp); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_EstSlimLoop3 *) ckalloc(sizeof(struct thread_pool_holder_EstSlimLoop3)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->cp = cp; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_EstSlimLoop3,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for EstSlimLoop3"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from EstSlimLoop3",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_EstSlimLoop3(ptr) * * Descrip: Infinite loop code foreach thread for EstSlimLoop3 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_EstSlimLoop3(void * ptr) { struct thread_pool_holder_EstSlimLoop3 * holder; int db_status; int score; DataScore * ds; GeneWiseScore* query; ComplexSequence* target; holder = (struct thread_pool_holder_EstSlimLoop3 *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for EstSlimLoop3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstSlimLoop3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_GeneWiseDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in EstSlimLoop3 search"); } query = hard_link_GeneWiseScore(holder->query); /* get query information into datascore */ dataentry_add_GeneWiseDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_cDNADB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_cDNADB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching EstSlimLoop3, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_cDNADB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_GeneWiseScore(holder->query); /* get the next query object for the next thread */ holder->query = reload_GeneWiseDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching EstSlimLoop3, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_GeneWiseDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstSlimLoop3"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstSlimLoop3"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_cDNADB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_EstSlimLoop3(query, target ,holder->cp); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for EstSlimLoop3"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for EstSlimLoop3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for EstSlimLoop3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_GeneWiseScore(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstSlimLoop3"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_EstSlimLoop3(out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstSlimLoop3 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_EstSlimLoop3(Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp) { GeneWiseScore* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GeneWiseDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstSlimLoop3, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_cDNADB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstSlimLoop3, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_EstSlimLoop3(query, target , cp); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("EstSlimLoop3 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GeneWiseDB(ds->query,query,querydb); dataentry_add_cDNADB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_cDNADB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstSlimLoop3, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_cDNADB(target,targetdb); query = reload_GeneWiseDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching EstSlimLoop3, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GeneWiseDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_EstSlimLoop3(query,target,cp) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_EstSlimLoop3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_EstSlimLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp) { int bestscore = NEGI; int i; int j; int k; EstSlimLoop3 * mat; mat = allocate_EstSlimLoop3_only(query, target , cp); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(5,(mat->leni + 1) * 3,5,3)) == NULL) { warn("Score only matrix for EstSlimLoop3 cannot be allocated, (asking for 4 by %d cells)",mat->leni*3); mat = free_EstSlimLoop3(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<6;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) EstSlimLoop3_VSMALL_MATRIX(mat,i,j,k) = NEGI; } EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) = NEGI; EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,START) = 0; EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = EstSlimLoop3_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstSlimLoop3_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstSlimLoop3_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstSlimLoop3_VSMALL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = EstSlimLoop3_VSMALL_SPECIAL(mat,i-1,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstSlimLoop3_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlimLoop3_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstSlimLoop3_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstSlimLoop3_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstSlimLoop3_VSMALL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = EstSlimLoop3_VSMALL_SPECIAL(mat,i-0,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_VSMALL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstSlimLoop3_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlimLoop3_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstSlimLoop3_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstSlimLoop3_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstSlimLoop3_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstSlimLoop3_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* end of for all query positions */ /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstSlimLoop3_VSMALL_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = EstSlimLoop3_VSMALL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = EstSlimLoop3_VSMALL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ EstSlimLoop3_VSMALL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstSlimLoop3_VSMALL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = EstSlimLoop3_VSMALL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Put back score... (now updated!) */ EstSlimLoop3_VSMALL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ if( bestscore < EstSlimLoop3_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = EstSlimLoop3_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_EstSlimLoop3(mat); return bestscore; } /* Function: PackAln_bestmemory_EstSlimLoop3(query,target,cp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EstSlimLoop3 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_EstSlimLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; EstSlimLoop3 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_EstSlimLoop3(query, target , cp,dpri)) == NULL ) { warn("Unable to allocate large EstSlimLoop3 version"); return NULL; } calculate_dpenv_EstSlimLoop3(mat,dpenv); out = PackAln_read_Expl_EstSlimLoop3(mat); } else { mat = allocate_EstSlimLoop3_only(query, target , cp); calculate_shatter_EstSlimLoop3(mat,dpenv); out = PackAln_read_Shatter_EstSlimLoop3(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_EstSlimLoop3(query, target , cp)) == NULL ) { warn("Unable to allocate small EstSlimLoop3 version"); return NULL; } out = PackAln_calculate_Small_EstSlimLoop3(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_EstSlimLoop3(query, target , cp,dpri)) == NULL ) { warn("Unable to allocate large EstSlimLoop3 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_EstSlimLoop3(mat); out = PackAln_read_Expl_EstSlimLoop3(mat); } } } mat = free_EstSlimLoop3(mat); return out; } /* Function: allocate_EstSlimLoop3_only(query,target,cp) * * Descrip: This function only allocates the EstSlimLoop3 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstSlimLoop3 *] * */ EstSlimLoop3 * allocate_EstSlimLoop3_only(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp) { EstSlimLoop3 * out; if((out= EstSlimLoop3_alloc()) == NULL) { warn("Allocation of basic EstSlimLoop3 structure failed..."); return NULL; } out->query = query; out->target = target; out->cp = cp; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_EstSlimLoop3(query,target,cp,dpri) * * Descrip: This function allocates the EstSlimLoop3 structure * and the basematrix area for explicit memory implementations * It calls /allocate_EstSlimLoop3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EstSlimLoop3 *] * */ EstSlimLoop3 * allocate_Expl_EstSlimLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPRunImpl * dpri) { EstSlimLoop3 * out; out = allocate_EstSlimLoop3_only(query, target , cp); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+4)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+4)*3,(out->leni+1),3,out->lenj+4)) == NULL) { warn("Explicit matrix EstSlimLoop3 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_EstSlimLoop3(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_EstSlimLoop3(out); return out; } /* Function: init_EstSlimLoop3(mat) * * Descrip: This function initates EstSlimLoop3 matrix when in explicit mode * Called in /allocate_Expl_EstSlimLoop3 * * * Arg: mat [UNKN ] EstSlimLoop3 which contains explicit basematrix memory [EstSlimLoop3 *] * */ void init_EstSlimLoop3(EstSlimLoop3 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-4);j<5;j++) { EstSlimLoop3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstSlimLoop3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstSlimLoop3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j= (-4);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { EstSlimLoop3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstSlimLoop3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstSlimLoop3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = NEGI; EstSlimLoop3_EXPL_SPECIAL(mat,i,j,START) = 0; EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_EstSlimLoop3(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EstSlimLoop3 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * */ void recalculate_PackAln_EstSlimLoop3(PackAln * pal,EstSlimLoop3 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (START+3) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (LOOP+3) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 1 && offj == 4 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (START+3) ) { pau->score = (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (LOOP+3) ) { pau->score = (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->seg[i]->transition[GW_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (START+3) ) { pau->score = mat->query->seg[i]->transition[GW_START2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (LOOP+3) : if( offj == 1 && prev->state == (START+3) ) { pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } if( offj == 1 && prev->state == (LOOP+3) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state LOOP, got a bad source state. Error!"); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+3) : if( offj == 1 && prev->state == (LOOP+3) ) { pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define EstSlimLoop3_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+4)][(i+1)*3+state]) #define EstSlimLoop3_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+5)*8) % 40][(i+1)*3+state]) #define EstSlimLoop3_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+4)]) #define EstSlimLoop3_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+4)]) #define EstSlimLoop3_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+5)*8)+(shadow+1)) % 40)][(i+1)*3 + state]) #define EstSlimLoop3_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+4)]) #define EstSlimLoop3_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+4)% 4) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+4)% 4) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+4)]) /* Function: allocate_Small_EstSlimLoop3(query,target,cp) * * Descrip: This function allocates the EstSlimLoop3 structure * and the basematrix area for a small memory implementations * It calls /allocate_EstSlimLoop3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstSlimLoop3 *] * */ #define EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+4)]) EstSlimLoop3 * allocate_Small_EstSlimLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp) { EstSlimLoop3 * out; out = allocate_EstSlimLoop3_only(query, target , cp); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(40,(out->leni + 1) * 3,24,out->lenj+4); if(out == NULL) { warn("Small shadow matrix EstSlimLoop3 cannot be allocated, (asking for 5 by %d main cells)",out->leni+2); free_EstSlimLoop3(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_EstSlimLoop3(mat,dpenv) * * Descrip: This function calculates an alignment for EstSlimLoop3 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EstSlimLoop3 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EstSlimLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_EstSlimLoop3(EstSlimLoop3 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for EstSlimLoop3 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_EstSlimLoop3(mat,dpenv); score = start_end_find_end_EstSlimLoop3(mat,&endj); out->score = score; stopstate = END; /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */ log_full_error(REPORT,0,"End at %d Score %d",endj,score); stop_reporting(); for(;;) { /*while there are more special bits to recover*/ start_reporting("Special cell aln end %d:",endj); if( read_special_strip_EstSlimLoop3(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) { warn("Problem in reading off special state system... going to return partial alignment"); break; } if( startstate == START || endj <= 0) { log_full_error(REPORT,0,"Recovered complete alignment"); stop_reporting(); break; } log_full_error(REPORT,0,"Finished to %d",endj); stop_reporting(); /* Ok... have to eat up another piece of matrix */ temp = startstate; starti = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0); startj = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1); startstate = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2); stopi = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3); stopj = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4); stopstate = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5); /* Get out the score of this block. V. important! */ temp = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6); totalj = stopj - startj; donej = 0; start_reporting("Main matrix aln [%d,%d]:",startj,stopj); if(full_dc_EstSlimLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) { warn("In the alignment EstSlimLoop3 [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj); return out; } /* now have to figure out which special we came from... yikes */ max_matrix_to_special_EstSlimLoop3(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == EstSlimLoop3_READ_OFF_ERROR) { warn("In EstSlimLoop3 read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj); invert_PackAln(out); recalculate_PackAln_EstSlimLoop3(out,mat); return out; } /* if at start, break, otherwise, back to eat another strip */ if( stopstate == START) { log_full_error(REPORT,0,"Recovered complete alignment "); stop_reporting(); break; } log_full_error(REPORT,0,"Finished alignment to %d ",startj); stop_reporting(); endj = stopj; /* stopstate is correct as it is */ } /* end of while there are more special bits to recover */ invert_PackAln(out); recalculate_PackAln_EstSlimLoop3(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_EstSlimLoop3(mat) * * Descrip: This function calculates an alignment for EstSlimLoop3 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EstSlimLoop3 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EstSlimLoop3 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EstSlimLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_EstSlimLoop3(EstSlimLoop3 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_EstSlimLoop3(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_EstSlimLoop3(mat); return out; } /* Function: AlnRangeSet_from_EstSlimLoop3(mat) * * Descrip: This function reads off a start/end structure * for EstSlimLoop3 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EstSlimLoop3 * If you have not calculated the matrix use * /AlnRange_calculate_Small_EstSlimLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_EstSlimLoop3(EstSlimLoop3 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EstSlimLoop3"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_EstSlimLoop3(mat,&jpos); state = END; while( (temp = AlnRange_build_EstSlimLoop3(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_EstSlimLoop3(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_EstSlimLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_EstSlimLoop3(EstSlimLoop3 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EstSlimLoop3"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_EstSlimLoop3(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_EstSlimLoop3 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = EstSlimLoop3_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_EstSlimLoop3(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == EstSlimLoop3_READ_OFF_ERROR) { warn("In AlnRange_build_EstSlimLoop3 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = EstSlimLoop3_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_EstSlimLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_EstSlimLoop3(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EstSlimLoop3_READ_OFF_ERROR) { warn("In EstSlimLoop3 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In EstSlimLoop3 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In EstSlimLoop3 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_EstSlimLoop3(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_EstSlimLoop3(EstSlimLoop3 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstSlimLoop3_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In EstSlimLoop3 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = EstSlimLoop3_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-4,MATCH); } return EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } /* Not allowing special sources.. skipping LOOP */ /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in EstSlimLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstSlimLoop3_HIDDEN_MATRIX(mat,i - 0,j - 4,INSERT) ) { *reti = i - 0; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_HIDDEN_MATRIX(mat,i-0,j-4,INSERT); } return EstSlimLoop3_HIDDEN_MATRIX(mat,i - 0,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstSlimLoop3_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return EstSlimLoop3_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } /* Not allowing special sources.. skipping LOOP */ /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlimLoop3_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_HIDDEN_MATRIX(mat,i-0,j-3,DELETE); } return EstSlimLoop3_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlimLoop3_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return EstSlimLoop3_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlimLoop3_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return EstSlimLoop3_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in EstSlimLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return EstSlimLoop3_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in EstSlimLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstSlimLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_EstSlimLoop3(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_EstSlimLoop3(EstSlimLoop3 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_EstSlimLoop3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EstSlimLoop3_READ_OFF_ERROR) { warn("In special strip read EstSlimLoop3, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read EstSlimLoop3, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_EstSlimLoop3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_EstSlimLoop3(EstSlimLoop3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = EstSlimLoop3_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for EstSlimLoop3, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In EstSlimLoop3 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case LOOP : /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i-0,j-1,LOOP); } return EstSlimLoop3_DC_SHADOW_MATRIX(mat,i - 0,j - 1,LOOP) ; } /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ /* source START is a special */ temp = cscore - (0) - (0); if( temp == EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return EstSlimLoop3_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } case START : case END : /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i-0,j-1,LOOP); } return EstSlimLoop3_DC_SHADOW_MATRIX(mat,i - 0,j - 1,LOOP) ; } default: warn("Major problem (!) - in EstSlimLoop3 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_EstSlimLoop3(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_EstSlimLoop3(EstSlimLoop3 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = EstSlimLoop3_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In EstSlimLoop3 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,LOOP) ) { *reti = i - 1; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i-1,j-3,LOOP); } return EstSlimLoop3_DC_SHADOW_MATRIX(mat,i - 1,j - 3,LOOP) ; } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i-1,j-3,START); } return EstSlimLoop3_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstSlimLoop3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,LOOP) ) { *reti = i - 0; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i-0,j-3,LOOP); } return EstSlimLoop3_DC_SHADOW_MATRIX(mat,i - 0,j - 3,LOOP) ; } temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i-0,j-3,START); } return EstSlimLoop3_DC_SHADOW_MATRIX(mat,i - 0,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstSlimLoop3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstSlimLoop3_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return EstSlimLoop3_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstSlimLoop3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstSlimLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_EstSlimLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_EstSlimLoop3(mat,starti,startj,stopi,stopj); EstSlimLoop3_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstSlimLoop3_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; EstSlimLoop3_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; EstSlimLoop3_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstSlimLoop3_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlimLoop3_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstSlimLoop3_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstSlimLoop3_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_HIDDEN_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstSlimLoop3_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstSlimLoop3_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstSlimLoop3_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } } return; } /* Function: init_hidden_EstSlimLoop3(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-4);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { EstSlimLoop3_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; EstSlimLoop3_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; EstSlimLoop3_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; } } return; } /* Function: full_dc_EstSlimLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_EstSlimLoop3 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_EstSlimLoop3 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [EstSlimLoop3 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_EstSlimLoop3"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 20) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_EstSlimLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_EstSlimLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_EstSlimLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for EstSlimLoop3, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_EstSlimLoop3(mat,EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_EstSlimLoop3(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_EstSlimLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_EstSlimLoop3(mat); EstSlimLoop3_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_EstSlimLoop3(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_EstSlimLoop3(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_EstSlimLoop3(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_EstSlimLoop3(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<4;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( j - 3 <= mergej) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } } /* Add any movement independant score */ EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( j - 3 <= mergej) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } } temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,k); } } /* Add any movement independant score */ EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_EstSlimLoop3(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state DELETE to state INSERT */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_EstSlimLoop3(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstSlimLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_EstSlimLoop3(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * */ } void init_dc_EstSlimLoop3(EstSlimLoop3 * mat) { register int i; register int j; register int k; for(j=0;j<6;j++) { for(i=(-1);iquery->len;i++) { EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; for(k=0;k<7;k++) { EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); } } } return; } /* Function: start_end_find_end_EstSlimLoop3(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [EstSlimLoop3 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_EstSlimLoop3(EstSlimLoop3 * mat,int * endj) { register int j; register int max; register int maxj; max = EstSlimLoop3_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( EstSlimLoop3_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = EstSlimLoop3_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_EstSlimLoop3(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [EstSlimLoop3] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_EstSlimLoop3(EstSlimLoop3 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (4 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (4 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state START to state MATCH */ temp = EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state LOOP to state MATCH */ temp = EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [LOOP] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = MATCH; } /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state DELETE to state INSERT */ temp = EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0)); } /* From state START to state INSERT */ temp = EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state LOOP to state INSERT */ temp = EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [LOOP] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = INSERT; } /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state START to state DELETE */ temp = EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstSlimLoop3_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = DELETE; } /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstSlimLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = DELETE; } /* Finished calculating state DELETE */ } /* end of for each i position in strip */ /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ temp = EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,START,k); } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,LOOP,k); } /* Put back score... (now updated!) */ EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ temp = EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstSlimLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,LOOP,k); } /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Put back score... (now updated!) */ EstSlimLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_EstSlimLoop3(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * */ void init_start_end_linear_EstSlimLoop3(EstSlimLoop3 * mat) { register int i; register int j; for(j=0;j<6;j++) { for(i=(-1);iquery->len;i++) { EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); EstSlimLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; EstSlimLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); } } for(j=(-4);jtarget->seq->len;j++) { EstSlimLoop3_DC_SHADOW_SPECIAL(mat,0,j,LOOP) = NEGI; EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,j,LOOP,0) = (-1); EstSlimLoop3_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; EstSlimLoop3_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; EstSlimLoop3_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_EstSlimLoop3(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_EstSlimLoop3(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_EstSlimLoop3(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","LOOP","END" }; /* Function: AlnConvertSet_EstSlimLoop3(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","RANDOM_SEQUENCE","END" }; AlnConvertSet * AlnConvertSet_EstSlimLoop3(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 3; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 3; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 3; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[5]; add_collapse_label_AlnConvertSet(out,"LOOP","RANDOM_SEQUENCE"); return out; } /* Function: PackAln_read_Expl_EstSlimLoop3(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_EstSlimLoop3(EstSlimLoop3 * mat) { EstSlimLoop3_access_func_holder holder; holder.access_main = EstSlimLoop3_explicit_access_main; holder.access_special = EstSlimLoop3_explicit_access_special; return PackAln_read_generic_EstSlimLoop3(mat,holder); } /* Function: EstSlimLoop3_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstSlimLoop3_explicit_access_main(EstSlimLoop3 * mat,int i,int j,int state) { return EstSlimLoop3_EXPL_MATRIX(mat,i,j,state); } /* Function: EstSlimLoop3_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstSlimLoop3_explicit_access_special(EstSlimLoop3 * mat,int i,int j,int state) { return EstSlimLoop3_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_EstSlimLoop3(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: h [UNKN ] Undocumented argument [EstSlimLoop3_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_EstSlimLoop3(EstSlimLoop3 * mat,EstSlimLoop3_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_EstSlimLoop3(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in EstSlimLoop3_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_EstSlimLoop3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_EstSlimLoop3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == EstSlimLoop3_READ_OFF_ERROR || j == EstSlimLoop3_READ_OFF_ERROR || state == EstSlimLoop3_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in EstSlimLoop3_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_EstSlimLoop3(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [EstSlimLoop3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_EstSlimLoop3(EstSlimLoop3 * mat,int * ri,int * rj,int * state,boolean * isspecial,EstSlimLoop3_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: EstSlimLoop3_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void EstSlimLoop3_debug_show_matrix(EstSlimLoop3 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",EstSlimLoop3_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",EstSlimLoop3_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",EstSlimLoop3_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_EstSlimLoop3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EstSlimLoop3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_EstSlimLoop3(EstSlimLoop3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstSlimLoop3_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstSlimLoop3_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In EstSlimLoop3 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH); } return (*h.access_main)(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 3,LOOP) ) { *reti = i - 1; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,LOOP); } return (*h.access_main)(mat,i - 1,j - 3,LOOP); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START); } return (*h.access_main)(mat,i - 1,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in EstSlimLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,INSERT) ) { *reti = i - 0; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INSERT); } return (*h.access_main)(mat,i - 0,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,LOOP) ) { *reti = i - 0; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,LOOP); } return (*h.access_main)(mat,i - 0,j - 3,LOOP); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,START); } return (*h.access_main)(mat,i - 0,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE); } return (*h.access_main)(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in EstSlimLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in EstSlimLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstSlimLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_EstSlimLoop3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EstSlimLoop3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_EstSlimLoop3(EstSlimLoop3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstSlimLoop3_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstSlimLoop3_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In EstSlimLoop3 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case LOOP : /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,LOOP); } return (*h.access_special)(mat,i - 0,j - 1,LOOP) ; } /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ /* source START is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_special)(mat,i - 0,j - 1,START) ; } case START : case END : /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,LOOP); } return (*h.access_special)(mat,i - 0,j - 1,LOOP) ; } default: warn("Major problem (!) - in EstSlimLoop3 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_EstSlimLoop3(mat) * * Descrip: This function calculates the EstSlimLoop3 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EstSlimLoop3 * * * Arg: mat [UNKN ] EstSlimLoop3 which contains explicit basematrix memory [EstSlimLoop3 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_EstSlimLoop3(EstSlimLoop3 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EstSlimLoop3, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("EstSlimLoop3 Matrix calculation: "); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstSlimLoop3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = EstSlimLoop3_EXPL_SPECIAL(mat,i-1,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstSlimLoop3_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlimLoop3_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstSlimLoop3_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = EstSlimLoop3_EXPL_SPECIAL(mat,i-0,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstSlimLoop3_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstSlimLoop3_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstSlimLoop3_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstSlimLoop3_EXPL_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = EstSlimLoop3_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = EstSlimLoop3_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ EstSlimLoop3_EXPL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstSlimLoop3_EXPL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = EstSlimLoop3_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Put back score... (now updated!) */ EstSlimLoop3_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_EstSlimLoop3(mat,dpenv) * * Descrip: This function calculates the EstSlimLoop3 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EstSlimLoop3 which contains explicit basematrix memory [EstSlimLoop3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_EstSlimLoop3(EstSlimLoop3 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EstSlimLoop3, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-4;jleni;i++) { EstSlimLoop3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstSlimLoop3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstSlimLoop3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j=-4;jlenj;j++) { EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = NEGI; EstSlimLoop3_EXPL_SPECIAL(mat,i,j,START) = 0; EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("EstSlimLoop3 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { EstSlimLoop3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstSlimLoop3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstSlimLoop3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstSlimLoop3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = EstSlimLoop3_EXPL_SPECIAL(mat,i-1,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstSlimLoop3_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlimLoop3_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstSlimLoop3_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = EstSlimLoop3_EXPL_SPECIAL(mat,i-0,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstSlimLoop3_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstSlimLoop3_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstSlimLoop3_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstSlimLoop3_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) ) { EstSlimLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) ) { EstSlimLoop3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstSlimLoop3_EXPL_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = EstSlimLoop3_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = EstSlimLoop3_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ EstSlimLoop3_EXPL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstSlimLoop3_EXPL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = EstSlimLoop3_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Put back score... (now updated!) */ EstSlimLoop3_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: EstSlimLoop3_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstSlimLoop3 *] * */ EstSlimLoop3 * EstSlimLoop3_alloc(void) { EstSlimLoop3 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EstSlimLoop3 *) ckalloc (sizeof(EstSlimLoop3))) == NULL) { warn("EstSlimLoop3_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_EstSlimLoop3(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstSlimLoop3 *] * * Return [UNKN ] Undocumented return value [EstSlimLoop3 *] * */ EstSlimLoop3 * free_EstSlimLoop3(EstSlimLoop3 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EstSlimLoop3 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->cp is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/estslimloop.h0000644000175000001440000004627210670453713016667 0ustar philippusers#ifndef DYNAMITEestslimloopHEADERFILE #define DYNAMITEestslimloopHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "cdparser.h" #include "genewisemodel.h" #include "genewisemodeldb.h" struct Wise2_EstSlimLoop3 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GeneWiseScore* query; ComplexSequence* target; cDNAParserScore * cp; } ; /* EstSlimLoop3 defined */ #ifndef DYNAMITE_DEFINED_EstSlimLoop3 typedef struct Wise2_EstSlimLoop3 Wise2_EstSlimLoop3; #define EstSlimLoop3 Wise2_EstSlimLoop3 #define DYNAMITE_DEFINED_EstSlimLoop3 #endif #ifdef PTHREAD struct thread_pool_holder_EstSlimLoop3 { GeneWiseScore* query; /* Query object placeholder */ GeneWiseDB* querydb;/* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ cDNADB* targetdb; /* Target database object */ boolean target_init; cDNAParserScore * cp; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_EstSlimLoop3_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(EstSlimLoop3*,int,int,int); int (*access_special)(EstSlimLoop3*,int,int,int); } ; /* EstSlimLoop3_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_EstSlimLoop3_access_func_holder typedef struct Wise2_EstSlimLoop3_access_func_holder Wise2_EstSlimLoop3_access_func_holder; #define EstSlimLoop3_access_func_holder Wise2_EstSlimLoop3_access_func_holder #define DYNAMITE_DEFINED_EstSlimLoop3_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_EstSlimLoop3(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_EstSlimLoop3(EstSlimLoop3 * mat); #define PackAln_read_Shatter_EstSlimLoop3 Wise2_PackAln_read_Shatter_EstSlimLoop3 /* Function: calculate_shatter_EstSlimLoop3(mat,dpenv) * * Descrip: This function calculates the EstSlimLoop3 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EstSlimLoop3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_EstSlimLoop3(EstSlimLoop3 * mat,DPEnvelope * dpenv); #define calculate_shatter_EstSlimLoop3 Wise2_calculate_shatter_EstSlimLoop3 /* Function: search_EstSlimLoop3(dbsi,out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstSlimLoop3 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_EstSlimLoop3(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp); #define search_EstSlimLoop3 Wise2_search_EstSlimLoop3 /* Function: serial_search_EstSlimLoop3(out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstSlimLoop3 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_EstSlimLoop3(Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp); #define serial_search_EstSlimLoop3 Wise2_serial_search_EstSlimLoop3 /* Function: PackAln_bestmemory_EstSlimLoop3(query,target,cp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EstSlimLoop3 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_EstSlimLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_EstSlimLoop3 Wise2_PackAln_bestmemory_EstSlimLoop3 /* Function: allocate_Expl_EstSlimLoop3(query,target,cp,dpri) * * Descrip: This function allocates the EstSlimLoop3 structure * and the basematrix area for explicit memory implementations * It calls /allocate_EstSlimLoop3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EstSlimLoop3 *] * */ EstSlimLoop3 * Wise2_allocate_Expl_EstSlimLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPRunImpl * dpri); #define allocate_Expl_EstSlimLoop3 Wise2_allocate_Expl_EstSlimLoop3 /* Function: recalculate_PackAln_EstSlimLoop3(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EstSlimLoop3 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * */ void Wise2_recalculate_PackAln_EstSlimLoop3(PackAln * pal,EstSlimLoop3 * mat); #define recalculate_PackAln_EstSlimLoop3 Wise2_recalculate_PackAln_EstSlimLoop3 /* Function: allocate_Small_EstSlimLoop3(query,target,cp) * * Descrip: This function allocates the EstSlimLoop3 structure * and the basematrix area for a small memory implementations * It calls /allocate_EstSlimLoop3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstSlimLoop3 *] * */ EstSlimLoop3 * Wise2_allocate_Small_EstSlimLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp); #define allocate_Small_EstSlimLoop3 Wise2_allocate_Small_EstSlimLoop3 /* Function: PackAln_calculate_Small_EstSlimLoop3(mat,dpenv) * * Descrip: This function calculates an alignment for EstSlimLoop3 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EstSlimLoop3 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EstSlimLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_EstSlimLoop3(EstSlimLoop3 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_EstSlimLoop3 Wise2_PackAln_calculate_Small_EstSlimLoop3 /* Function: AlnRangeSet_calculate_Small_EstSlimLoop3(mat) * * Descrip: This function calculates an alignment for EstSlimLoop3 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EstSlimLoop3 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EstSlimLoop3 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EstSlimLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_EstSlimLoop3(EstSlimLoop3 * mat); #define AlnRangeSet_calculate_Small_EstSlimLoop3 Wise2_AlnRangeSet_calculate_Small_EstSlimLoop3 /* Function: AlnRangeSet_from_EstSlimLoop3(mat) * * Descrip: This function reads off a start/end structure * for EstSlimLoop3 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EstSlimLoop3 * If you have not calculated the matrix use * /AlnRange_calculate_Small_EstSlimLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_EstSlimLoop3(EstSlimLoop3 * mat); #define AlnRangeSet_from_EstSlimLoop3 Wise2_AlnRangeSet_from_EstSlimLoop3 /* Function: convert_PackAln_to_AlnBlock_EstSlimLoop3(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_EstSlimLoop3(PackAln * pal); #define convert_PackAln_to_AlnBlock_EstSlimLoop3 Wise2_convert_PackAln_to_AlnBlock_EstSlimLoop3 /* Function: PackAln_read_Expl_EstSlimLoop3(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_EstSlimLoop3(EstSlimLoop3 * mat); #define PackAln_read_Expl_EstSlimLoop3 Wise2_PackAln_read_Expl_EstSlimLoop3 /* Function: PackAln_read_generic_EstSlimLoop3(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstSlimLoop3 *] * Arg: h [UNKN ] Undocumented argument [EstSlimLoop3_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_EstSlimLoop3(EstSlimLoop3 * mat,EstSlimLoop3_access_func_holder h); #define PackAln_read_generic_EstSlimLoop3 Wise2_PackAln_read_generic_EstSlimLoop3 /* Function: calculate_EstSlimLoop3(mat) * * Descrip: This function calculates the EstSlimLoop3 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EstSlimLoop3 * * * Arg: mat [UNKN ] EstSlimLoop3 which contains explicit basematrix memory [EstSlimLoop3 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_EstSlimLoop3(EstSlimLoop3 * mat); #define calculate_EstSlimLoop3 Wise2_calculate_EstSlimLoop3 /* Function: calculate_dpenv_EstSlimLoop3(mat,dpenv) * * Descrip: This function calculates the EstSlimLoop3 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EstSlimLoop3 which contains explicit basematrix memory [EstSlimLoop3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_EstSlimLoop3(EstSlimLoop3 * mat,DPEnvelope * dpenv); #define calculate_dpenv_EstSlimLoop3 Wise2_calculate_dpenv_EstSlimLoop3 /* Function: EstSlimLoop3_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstSlimLoop3 *] * */ EstSlimLoop3 * Wise2_EstSlimLoop3_alloc(void); #define EstSlimLoop3_alloc Wise2_EstSlimLoop3_alloc /* Function: free_EstSlimLoop3(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstSlimLoop3 *] * * Return [UNKN ] Undocumented return value [EstSlimLoop3 *] * */ EstSlimLoop3 * Wise2_free_EstSlimLoop3(EstSlimLoop3 * obj); #define free_EstSlimLoop3 Wise2_free_EstSlimLoop3 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_EstSlimLoop3_shatter_access_main(EstSlimLoop3 * mat,int i,int j,int state); #define EstSlimLoop3_shatter_access_main Wise2_EstSlimLoop3_shatter_access_main int Wise2_EstSlimLoop3_shatter_access_special(EstSlimLoop3 * mat,int i,int j,int state); #define EstSlimLoop3_shatter_access_special Wise2_EstSlimLoop3_shatter_access_special void * Wise2_thread_loop_EstSlimLoop3(void * ptr); #define thread_loop_EstSlimLoop3 Wise2_thread_loop_EstSlimLoop3 int Wise2_score_only_EstSlimLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp); #define score_only_EstSlimLoop3 Wise2_score_only_EstSlimLoop3 EstSlimLoop3 * Wise2_allocate_EstSlimLoop3_only(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp); #define allocate_EstSlimLoop3_only Wise2_allocate_EstSlimLoop3_only void Wise2_init_EstSlimLoop3(EstSlimLoop3 * mat); #define init_EstSlimLoop3 Wise2_init_EstSlimLoop3 AlnRange * Wise2_AlnRange_build_EstSlimLoop3(EstSlimLoop3 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_EstSlimLoop3 Wise2_AlnRange_build_EstSlimLoop3 boolean Wise2_read_hidden_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_EstSlimLoop3 Wise2_read_hidden_EstSlimLoop3 int Wise2_max_hidden_EstSlimLoop3(EstSlimLoop3 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_EstSlimLoop3 Wise2_max_hidden_EstSlimLoop3 boolean Wise2_read_special_strip_EstSlimLoop3(EstSlimLoop3 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_EstSlimLoop3 Wise2_read_special_strip_EstSlimLoop3 int Wise2_max_special_strip_EstSlimLoop3(EstSlimLoop3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_EstSlimLoop3 Wise2_max_special_strip_EstSlimLoop3 int Wise2_max_matrix_to_special_EstSlimLoop3(EstSlimLoop3 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_EstSlimLoop3 Wise2_max_matrix_to_special_EstSlimLoop3 void Wise2_calculate_hidden_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_EstSlimLoop3 Wise2_calculate_hidden_EstSlimLoop3 void Wise2_init_hidden_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_EstSlimLoop3 Wise2_init_hidden_EstSlimLoop3 boolean Wise2_full_dc_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_EstSlimLoop3 Wise2_full_dc_EstSlimLoop3 boolean Wise2_do_dc_single_pass_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_EstSlimLoop3 Wise2_do_dc_single_pass_EstSlimLoop3 void Wise2_push_dc_at_merge_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_EstSlimLoop3 Wise2_push_dc_at_merge_EstSlimLoop3 void Wise2_follow_on_dc_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_EstSlimLoop3 Wise2_follow_on_dc_EstSlimLoop3 void Wise2_run_up_dc_EstSlimLoop3(EstSlimLoop3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_EstSlimLoop3 Wise2_run_up_dc_EstSlimLoop3 void Wise2_init_dc_EstSlimLoop3(EstSlimLoop3 * mat); #define init_dc_EstSlimLoop3 Wise2_init_dc_EstSlimLoop3 int Wise2_start_end_find_end_EstSlimLoop3(EstSlimLoop3 * mat,int * endj); #define start_end_find_end_EstSlimLoop3 Wise2_start_end_find_end_EstSlimLoop3 boolean Wise2_dc_optimised_start_end_calc_EstSlimLoop3(EstSlimLoop3 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_EstSlimLoop3 Wise2_dc_optimised_start_end_calc_EstSlimLoop3 void Wise2_init_start_end_linear_EstSlimLoop3(EstSlimLoop3 * mat); #define init_start_end_linear_EstSlimLoop3 Wise2_init_start_end_linear_EstSlimLoop3 AlnConvertSet * Wise2_AlnConvertSet_EstSlimLoop3(void); #define AlnConvertSet_EstSlimLoop3 Wise2_AlnConvertSet_EstSlimLoop3 int Wise2_EstSlimLoop3_explicit_access_main(EstSlimLoop3 * mat,int i,int j,int state); #define EstSlimLoop3_explicit_access_main Wise2_EstSlimLoop3_explicit_access_main int Wise2_EstSlimLoop3_explicit_access_special(EstSlimLoop3 * mat,int i,int j,int state); #define EstSlimLoop3_explicit_access_special Wise2_EstSlimLoop3_explicit_access_special int Wise2_find_end_EstSlimLoop3(EstSlimLoop3 * mat,int * ri,int * rj,int * state,boolean * isspecial,EstSlimLoop3_access_func_holder h); #define find_end_EstSlimLoop3 Wise2_find_end_EstSlimLoop3 void Wise2_EstSlimLoop3_debug_show_matrix(EstSlimLoop3 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define EstSlimLoop3_debug_show_matrix Wise2_EstSlimLoop3_debug_show_matrix int Wise2_max_calc_EstSlimLoop3(EstSlimLoop3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstSlimLoop3_access_func_holder h); #define max_calc_EstSlimLoop3 Wise2_max_calc_EstSlimLoop3 int Wise2_max_calc_special_EstSlimLoop3(EstSlimLoop3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstSlimLoop3_access_func_holder h); #define max_calc_special_EstSlimLoop3 Wise2_max_calc_special_EstSlimLoop3 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/splicesitemodeler.c0000644000175000001440000001467710670453715020032 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "splicesitemodeler.h" # line 33 "splicesitemodeler.dy" int SpliceSiteModeler_ComplexSequence_eval_func(int type,void * data,char * seq) { if( type != SPLICESITEMODELER_TYPE ) { warn("In evaluating a ComplexSequence Eval function using a SpliceSite modeler, the type was wrong. This is a bad bug, indicating a bad data problem which will probably repeat"); } return SpliceSiteModel_score((SpliceSiteModel *) data,seq); } # line 43 "splicesitemodeler.dy" ComplexSequenceEval * ComplexSequenceEval_from_SpliceSiteModel(SpliceSiteModel * ssm) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); /* shouldn't really add ones, but this is ok anyway. Yukky hack due to not understanding a bug in the window determination */ /* out->left_window = ssm->offset + ssm->pre_splice_site +1; */ out->left_window = 11; /* out->right_window = ssm->offset + ssm->post_splice_site +1; */ out->right_window = 8; out->outside_score= NEGI; out->data_type = SPLICESITEMODELER_TYPE; out->data = ssm; out->type = SEQUENCE_GENOMIC; out->eval_func = SpliceSiteModeler_ComplexSequence_eval_func; return out; } /*** This *must* have been passed a *seq with appropiate lengths on the left and right otherwise there is going to be tears! Really this function is only to be called from trusted function, for example, SpliceSite_ComplexSequence_eval ***/ # line 79 "splicesitemodeler.dy" Score SpliceSiteModel_score(SpliceSiteModel * ssm,char * seq) { int len; int i; int score; char * be = seq; base b; /* check I have enough sequence */ /* fprintf(stderr,"Being passed sequence %c%c%c\n",seq[0],seq[1],seq[2]); */ /* first calculate the CC score */ score = score_from_ComplexConsensi(seq- ssm->offset - ssm->pre_splice_site,ssm->cc); /* now move over the random score */ /* random score is subtracted - ie divided */ /* out from the model */ len = ssm->start_random - ssm->stop_random +1; for(i=0,seq = seq - ssm->start_random+1;irmds->base[b]; } /* this is for the possibility of errors/non splice consensus etc */ if( score < ssm->error_pos ) score = ssm->error_pos; return score; } # line 120 "splicesitemodeler.dy" SpliceSiteModel * std_5SS_SpliceSiteModel(int offset,ComplexConsensi * cc,RandomModelDNAScore * rmds) { return new_SpliceSiteModel(offset,3,7,7,0,cc,rmds,0.0000001); } # line 125 "splicesitemodeler.dy" SpliceSiteModel * std_3SS_SpliceSiteModel(int offset,ComplexConsensi * cc,RandomModelDNAScore * rmds) { /** mystical -1 everywhere because naturally we call caGcag - G as being the 3' SS however, if you think about it, it is the cacCag which is really the 3'SS (the residue after the splice site). Rather than enforcing these rules in the calling function, we subtract one from the offset here **/ return new_SpliceSiteModel(offset-1,3,3,offset+2,offset-1,cc,rmds,0.0000001); } # line 142 "splicesitemodeler.dy" SpliceSiteModel * new_SpliceSiteModel(int offset,int pre_length,int post_length,int start,int stop,ComplexConsensi * cc,RandomModelDNAScore * rmds,Probability error) { SpliceSiteModel * out; out = SpliceSiteModel_alloc(); if( out == NULL ) return NULL; out->offset = offset; out->pre_splice_site = pre_length; out->post_splice_site = post_length; out->start_random = start; out->stop_random = stop; out->cc = hard_link_ComplexConsensi(cc); out->rmds = hard_link_RandomModelDNAScore(rmds); out->error_pos = Probability2Score(error); return out; } # line 143 "splicesitemodeler.c" /* Function: hard_link_SpliceSiteModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SpliceSiteModel *] * * Return [UNKN ] Undocumented return value [SpliceSiteModel *] * */ SpliceSiteModel * hard_link_SpliceSiteModel(SpliceSiteModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a SpliceSiteModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SpliceSiteModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SpliceSiteModel *] * */ SpliceSiteModel * SpliceSiteModel_alloc(void) { SpliceSiteModel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SpliceSiteModel *) ckalloc (sizeof(SpliceSiteModel))) == NULL) { warn("SpliceSiteModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->offset = 0; out->pre_splice_site = 0; out->post_splice_site = 0; out->start_random = 0; out->stop_random = 0; out->cc = NULL; out->rmds = NULL; out->error_pos = 0; return out; } /* Function: free_SpliceSiteModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SpliceSiteModel *] * * Return [UNKN ] Undocumented return value [SpliceSiteModel *] * */ SpliceSiteModel * free_SpliceSiteModel(SpliceSiteModel * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SpliceSiteModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->cc != NULL) free_ComplexConsensi(obj->cc); if( obj->rmds != NULL) free_RandomModelDNAScore(obj->rmds); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/splicesitemodeler.h0000644000175000001440000000714410670453715020026 0ustar philippusers#ifndef DYNAMITEsplicesitemodelerHEADERFILE #define DYNAMITEsplicesitemodelerHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "randommodel.h" #define SPLICESITEMODELER_TYPE 474 struct Wise2_SpliceSiteModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int offset; int pre_splice_site; int post_splice_site; int start_random; int stop_random; ComplexConsensi * cc; RandomModelDNAScore * rmds; Score error_pos; } ; /* SpliceSiteModel defined */ #ifndef DYNAMITE_DEFINED_SpliceSiteModel typedef struct Wise2_SpliceSiteModel Wise2_SpliceSiteModel; #define SpliceSiteModel Wise2_SpliceSiteModel #define DYNAMITE_DEFINED_SpliceSiteModel #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_SpliceSiteModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SpliceSiteModel *] * * Return [UNKN ] Undocumented return value [SpliceSiteModel *] * */ SpliceSiteModel * Wise2_hard_link_SpliceSiteModel(SpliceSiteModel * obj); #define hard_link_SpliceSiteModel Wise2_hard_link_SpliceSiteModel /* Function: SpliceSiteModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SpliceSiteModel *] * */ SpliceSiteModel * Wise2_SpliceSiteModel_alloc(void); #define SpliceSiteModel_alloc Wise2_SpliceSiteModel_alloc /* Function: free_SpliceSiteModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SpliceSiteModel *] * * Return [UNKN ] Undocumented return value [SpliceSiteModel *] * */ SpliceSiteModel * Wise2_free_SpliceSiteModel(SpliceSiteModel * obj); #define free_SpliceSiteModel Wise2_free_SpliceSiteModel /* Unplaced functions */ /* There has been no indication of the use of these functions */ int Wise2_SpliceSiteModeler_ComplexSequence_eval_func(int type,void * data,char * seq); #define SpliceSiteModeler_ComplexSequence_eval_func Wise2_SpliceSiteModeler_ComplexSequence_eval_func ComplexSequenceEval * Wise2_ComplexSequenceEval_from_SpliceSiteModel(SpliceSiteModel * ssm); #define ComplexSequenceEval_from_SpliceSiteModel Wise2_ComplexSequenceEval_from_SpliceSiteModel Score Wise2_SpliceSiteModel_score(SpliceSiteModel * ssm,char * seq); #define SpliceSiteModel_score Wise2_SpliceSiteModel_score SpliceSiteModel * Wise2_std_5SS_SpliceSiteModel(int offset,ComplexConsensi * cc,RandomModelDNAScore * rmds); #define std_5SS_SpliceSiteModel Wise2_std_5SS_SpliceSiteModel SpliceSiteModel * Wise2_std_3SS_SpliceSiteModel(int offset,ComplexConsensi * cc,RandomModelDNAScore * rmds); #define std_3SS_SpliceSiteModel Wise2_std_3SS_SpliceSiteModel SpliceSiteModel * Wise2_new_SpliceSiteModel(int offset,int pre_length,int post_length,int start,int stop,ComplexConsensi * cc,RandomModelDNAScore * rmds,Probability error); #define new_SpliceSiteModel Wise2_new_SpliceSiteModel /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/genedisplay.c0000644000175000001440000004510210670453714016604 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genedisplay.h" /** #define DEBUG **/ /* Function: protein2genomic_ascii_display(alb,p,gen,ct,name,main,ofp) * * Descrip: shows the alignment in alb between protsequence and protname * with genomic into ofp with pretty formatting * * * Arg: alb [UNKN ] logical alignment [AlnBlock *] * Arg: p [UNKN ] protein sequence [Protein *] * Arg: gen [UNKN ] genomic dna to do the comparison [Genomic *] * Arg: ct [UNKN ] codon table for translation [CodonTable *] * Arg: name [UNKN ] length of name block [int] * Arg: main [UNKN ] length of main block [int] * Arg: ofp [UNKN ] output file [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 34 "genedisplay.dy" boolean protein2genomic_ascii_display(AlnBlock * alb,Protein * p,Genomic * gen,CodonTable * ct,int name,int main,FILE * ofp) { return protgene_ascii_display(alb,p->baseseq->seq,p->baseseq->name,p->baseseq->offset,gen,ct,name,main,FALSE,ofp); } /* Function: protgene_ascii_display(alb,protsequence,protname,protoff,gen,ct,name,main,mult,ofp) * * Descrip: shows the alignment in alb between protsequence and protname * with genomic into ofp with pretty formatting * * * Arg: alb [UNKN ] logical alignment [AlnBlock *] * Arg: protsequence [UNKN ] protein sequence - either real or an artifical consensus [char *] * Arg: protname [UNKN ] name of the protein [char *] * Arg: protoff [UNKN ] offset of the alb from the protein [int] * Arg: gen [UNKN ] genomic dna to do the comparison [Genomic *] * Arg: ct [UNKN ] codon table for translation [CodonTable *] * Arg: name [UNKN ] length of name block [int] * Arg: main [UNKN ] length of main block [int] * Arg: mult [UNKN ] is multi-match [boolean] * Arg: ofp [UNKN ] output file [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 54 "genedisplay.dy" boolean protgene_ascii_display(AlnBlock * alb,char * protsequence,char * protname,int protoff,Genomic * gen,CodonTable * ct,int name,int main,boolean mult,FILE * ofp) { boolean ret; btCanvas * btc; btc = new_Ascii_btCanvas(ofp,name+6,main,0,6); ret = protdna_btc_display(alb,protsequence,protname,protoff,gen->baseseq,ct,name,main,btc,match_central_line_std,mult); free_btCanvas(btc); return ret; } /* Function: protcdna_ascii_display(alb,protsequence,protname,protoff,cdna,ct,name,main,mult,ofp) * * Descrip: shows the alignment in alb between protsequence and protname * with cdna into ofp with pretty formatting * * * Arg: alb [UNKN ] logical alignment [AlnBlock *] * Arg: protsequence [UNKN ] protein sequence - either real or an artifical consensus [char *] * Arg: protname [UNKN ] name of the protein [char *] * Arg: protoff [UNKN ] offset of the alb from the protein [int] * Arg: cdna [UNKN ] cdna of the match [cDNA *] * Arg: ct [UNKN ] codon table for translation [CodonTable *] * Arg: name [UNKN ] length of name block [int] * Arg: main [UNKN ] length of main block [int] * Arg: mult [UNKN ] is multi-match [boolean] * Arg: ofp [UNKN ] output file [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 81 "genedisplay.dy" boolean protcdna_ascii_display(AlnBlock * alb,char * protsequence,char * protname,int protoff,cDNA * cdna,CodonTable * ct,int name,int main,boolean mult,FILE * ofp) { boolean ret; btCanvas * btc; btc = new_Ascii_btCanvas(ofp,name+6,main,0,6); ret = protdna_btc_display(alb,protsequence,protname,protoff,cdna->baseseq,ct,name,main,btc,match_central_line_std,mult); free_btCanvas(btc); return ret; } # line 92 "genedisplay.dy" char match_central_line_std(char hmm,int score,char seq) { if( hmm == seq ) { return hmm; } if( score <= 0 ) { return ' '; } return '+'; } # line 105 "genedisplay.dy" boolean protdna_btc_display(AlnBlock * alb,char * protsequence,char * protname_in,int protoff,Sequence * dna,CodonTable * ct,int name,int main,btCanvas * btc,char (*match_central_line)(char,int,char),boolean multalign) { AlnColumn * alc; AlnColumn * alc_temp,*alc_endscore; int a_phase, d_phase; int intron_number = 1; int aln_score; int aln_num = 1; btPasteArea * btp; char tempbuf[2]; char protname[60]; char dnaname[60]; char dnatemp[4]; char protc; char transc; boolean is_reversed = FALSE; boolean issplit; if( strlen(protname_in) > name ) { info("Name %s is longer than allowed name block (%d). Truncating\n",protname_in,name); strncpy(protname,protname_in,name); protname[name] = '\0'; } else { strcpy(protname,protname_in); } if( strlen(dna->name) > name ) { info("Name %s is longer than allowed name block (%d). Truncating\n",dna->name,name); strncpy(dnaname,dna->name,name); dnaname[name] = '\0'; } else { strcpy(dnaname,dna->name); } if( dna->offset > dna->end ) { is_reversed = TRUE; } for(alc=alb->start;alc != NULL;) { if ( strcmp(alc->alu[1]->text_label,"END") == 0 ) break; /* end of alignment */ for(;alc != NULL && is_random_AlnColumn_genewise(alc) == TRUE;alc = alc->next) ; if( alc == NULL) break; /* end of alignment */ if( multalign == TRUE ) { /* get the end score */ for(aln_score = 0,alc_endscore=alc;alc_endscore->next != NULL;alc_endscore = alc_endscore->next) { if( is_random_AlnColumn_genewise(alc_endscore) == TRUE) break; aln_score += alc_endscore->alu[0]->score[0]; } /*aln_score += alc_endscore->alu[0]->score[0];*/ write_alignment_separator(btc,aln_num++,aln_score); } while( alc != NULL ) { write_name_start_stuff(btc,protname,protoff,dnaname,dna,name,alc); for(; alc != NULL;alc=alc->next ) { if( is_random_AlnColumn_genewise(alc) == TRUE ) break; if( strcmp(alc->alu[1]->text_label,"INSERT") == 0 ) { if( can_get_paste_area_btCanvas(btc,1) == FALSE) break; /* back to upper for, to place names and starts */ btp = get_paste_area_btCanvas(btc,1); paste_char_btPasteArea(btp,0,0,protsequence[alc->alu[0]->start+1],0); paste_char_btPasteArea(btp,0,2,'-',0); free_btPasteArea(btp); } else if ( strcmp(alc->alu[1]->text_label,"SEQUENCE_INSERTION") == 0 || strcmp(alc->alu[1]->text_label,"SEQUENCE_DELETION") == 0 ) { if( can_get_paste_area_btCanvas(btc,1) == FALSE) break; /* back to upper for, to place names and starts */ btp = get_paste_area_btCanvas(btc,1); if( strcmp(alc->alu[0]->text_label,"INSERT_STATE")== 0 ) { paste_char_btPasteArea(btp,0,0,'-',0); } else { paste_char_btPasteArea(btp,0,0,protsequence[alc->alu[0]->end],0); } sprintf(tempbuf,"%d",alc->alu[1]->end - alc->alu[1]->start); paste_char_btPasteArea(btp,0,3,tempbuf[0],0); paste_char_btPasteArea(btp,0,2,'!',0); free_btPasteArea(btp); } else if (strcmp(alc->alu[1]->text_label,"END") == 0 && strcmp(alc->alu[0]->text_label,"END") == 0) { break; /* end of alignment */ } else if ( strcmp(alc->alu[1]->text_label,"RANDOM_SEQUENCE") == 0 ) { break; } else if( strcmp(alc->alu[1]->text_label,"CODON") == 0 ) { if( can_get_paste_area_btCanvas(btc,1) == FALSE) break; /* back to upper for, to place names and starts */ btp = get_paste_area_btCanvas(btc,1); if( strcmp(alc->alu[0]->text_label,"INSERT_STATE")== 0 ) { write_codon_match(btp,'-',' ',alc->alu[1]->start+1,aminoacid_from_seq(ct,dna->seq+alc->alu[1]->start+1),dna->seq+alc->alu[1]->start+1); } else if( strcmp(alc->alu[0]->text_label,"BEFORE_MATCH") == 0 || strcmp(alc->alu[0]->text_label,"AFTER_MATCH") == 0 ) { write_codon_match(btp,'~',' ',alc->alu[1]->start+1,aminoacid_from_seq(ct,dna->seq+alc->alu[1]->start+1),dna->seq+alc->alu[1]->start+1); } else { write_codon_match(btp,protsequence[alc->alu[0]->end],(*match_central_line)(protsequence[alc->alu[0]->end],alc->alu[0]->score[0],aminoacid_from_seq(ct,dna->seq+alc->alu[1]->start+1)),alc->alu[1]->start+1,aminoacid_from_seq(ct,dna->seq+alc->alu[1]->start+1),dna->seq+alc->alu[1]->start+1); } free_btPasteArea(btp); continue; } else if ( strstartcmp(alc->alu[1]->text_label,"5SS") == 0 ) { /* * intron stuff. Figure out the start and end, * then place the 5'SS Central and End. * * If we can't fit in the intron, loop over * in this region before returning to higher loop. * */ if( strcmp(alc->alu[1]->text_label,"5SS_PHASE_0") == 0 ) { d_phase = 0; } else if ( strcmp(alc->alu[1]->text_label,"5SS_PHASE_1") == 0 ) { d_phase = 1; } else if ( strcmp(alc->alu[1]->text_label,"5SS_PHASE_2") == 0 ) { d_phase = 2; } else { warn("No no no. You have a non 0,1,2 phase intron (god knows how!). Not displaying it %s",alc->alu[1]->text_label); advance_line_btCanvas(btc); return FALSE; } alc_temp = alc->next; if( strcmp(alc_temp->alu[1]->text_label,"CENTRAL_INTRON") != 0 ) { warn("Bad news. I have found a 5SS in your alignment, but it is not followed by a central intron node. Don't like it!"); advance_line_btCanvas(btc); return FALSE; } for(alc_temp = alc_temp->next ;alc_temp != NULL && strstartcmp(alc_temp->alu[1]->text_label,"3SS") != 0;alc_temp = alc_temp->next) ; if( alc_temp == NULL ) { warn("Got to the end of the alignment in the middle of an intron from %s. Weird!",alc->alu[1]->text_label); advance_line_btCanvas(btc); return FALSE; } if( strcmp(alc_temp->alu[1]->text_label,"3SS_PHASE_0") == 0 ) { a_phase = 0; } else if ( strcmp(alc_temp->alu[1]->text_label,"3SS_PHASE_1") == 0 ) { a_phase = 1; } else if ( strcmp(alc_temp->alu[1]->text_label,"3SS_PHASE_2") == 0 ) { a_phase = 2; } else { warn("No no no. You have a non 0,1,2 phase intron (god knows how!). Not displaying it %s",alc_temp->alu[1]->text_label); advance_line_btCanvas(btc); return FALSE; } /* * At this point we have alc on 5SS alc_temp on 3SS. * * Check to see if we can place 5SS and Central intron piece * on the line, if not advance. * */ if( can_get_paste_area_btCanvas(btc,d_phase+7+17) == FALSE) { advance_line_btCanvas(btc); write_name_start_stuff(btc,protname,protoff,dnaname,dna,name,alc); } /*** ok, if we can't get it now then we are fucked ***/ if( can_get_paste_area_btCanvas(btc,d_phase+7+17) == FALSE) { warn("You have specified a length of your main canvas too small. I need at least 23 characters long."); advance_line_btCanvas(btc); return FALSE; } btp = get_paste_area_btCanvas(btc,d_phase+7); /* ? split phase */ if( a_phase == 0 || (a_phase != d_phase ) ) { protc = ' '; transc = ' '; dnatemp[0]= '\0'; issplit = FALSE; } else { if( strcmp(alc_temp->alu[0]->text_label,"INSERT_STATE")== 0 ) { protc = '-'; } else { protc = protsequence[alc->alu[0]->start+1]; } dnatemp[0] = tolower((int)dna->seq[alc->alu[1]->start+1]); if( d_phase == 2) { dnatemp[1] = tolower((int)dna->seq[alc->alu[1]->start+2]); } else { dnatemp[1] = tolower((int)dna->seq[alc_temp->alu[1]->end-1]); } dnatemp[2] = tolower((int)dna->seq[alc_temp->alu[1]->end]); dnatemp[3] = '\0'; transc = aminoacid_from_seq(ct,dnatemp); issplit = TRUE; } write_5intron_match(btp,d_phase,7,dna->seq+alc->alu[1]->start+1); free_btPasteArea(btp); btp = get_paste_area_btCanvas(btc,17); if( is_reversed == FALSE ) write_intron_desc(btp,alc->alu[1]->start+1+d_phase+dna->offset,alc_temp->alu[1]->start+3+dna->offset,intron_number++,issplit,protc,transc,dnatemp); else write_intron_desc(btp,dna->offset - (alc->alu[1]->start+d_phase+1),dna->offset - (alc_temp->alu[1]->start+3),intron_number++,issplit,protc,transc,dnatemp); free_btPasteArea(btp); /* * written the start of the intron, now to deal with the * acceptor. We need to loop here, because we might go over the * line length. */ alc = alc->next->next; /*** move alc forward two columns ***/ while( alc != alc_temp ) { for(; alc != alc_temp;alc = alc->next) { /** alc_temp is 3SS **/ if( strcmp(alc->alu[1]->text_label,"PYRIMIDINE_TRACT") == 0 ) { if( can_get_paste_area_btCanvas(btc,1) == FALSE ) break; btp = get_paste_area_btCanvas(btc,1); paste_char_btPasteArea(btp,0,3,dna->seq[alc->alu[1]->start+1],0); paste_char_btPasteArea(btp,0,4,'+',0); free_btPasteArea(btp); } else if( strcmp(alc->alu[1]->text_label,"SPACER") == 0 ) { if( can_get_paste_area_btCanvas(btc,1) == FALSE ) break; btp = get_paste_area_btCanvas(btc,1); paste_char_btPasteArea(btp,0,3,dna->seq[alc->alu[1]->start+1],0); free_btPasteArea(btp); } else { warn("Sorry, don't know how to print %s. Skipping...",alc->alu[1]->text_label); } } /** end for for loop **/ if ( alc == alc_temp ) { break; } /*** run out of space ***/ advance_line_btCanvas(btc); write_name_start_stuff(btc,protname,protoff,dnaname,dna,name,alc); } /** end of while still in central->3SS **/ /* * Now do 3SS * */ if( can_get_paste_area_btCanvas(btc,a_phase == 0 ? 3 : 3- a_phase + 3) == FALSE ) { advance_line_btCanvas(btc); write_name_start_stuff(btc,protname,protoff,dnaname,dna,name,alc); } if( a_phase != 0 ) { btp = get_paste_area_btCanvas(btc,3 - a_phase + 3); write_3intron_match(btp,a_phase,3,dna->seq + alc->alu[1]->start+1); free_btPasteArea(btp); } else { btp = get_paste_area_btCanvas(btc,3); write_3intron_match(btp,a_phase,3,dna->seq + alc->alu[1]->start+1); free_btPasteArea(btp); } /* * Finished with intron !!! */ } else { warn("Sorry, could not print the alignment %s:%s column",alc->alu[0]->text_label,alc->alu[1]->text_label); } } /*** in this loop ***/ advance_line_btCanvas(btc); if( alc == NULL) break; if ( is_random_AlnColumn_genewise(alc) == TRUE) break; } /* end of while over alignments */ } /* end of foreach alignment */ /*** end of print ! **/ return TRUE; } # line 437 "genedisplay.dy" boolean write_alignment_separator(btCanvas * btc,int aln,int score) { char buffer[64]; btPasteArea * btp; sprintf(buffer,"Alignment %d Score %4.2f (Bits)",aln,Score2Bits(score)); btp = get_paste_area_btCanvas(btc,strlen(buffer)); paste_string_btPasteArea(btp,0,5,buffer,BC_RIGHT,0); free_btPasteArea(btp); advance_line_btCanvas(btc); return TRUE; } # line 455 "genedisplay.dy" boolean write_name_start_stuff(btCanvas * btc,char * protname,int protoff,char * dnaname,Sequence * dna,int name_len,AlnColumn * alc) { char buffer[64]; btPasteArea * btp; btp = get_reserved_left_btCanvas(btc); paste_string_btPasteArea(btp,0,0,protname,BC_RIGHT,0); paste_string_btPasteArea(btp,0,3,dnaname,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[0]->start+1+protoff); paste_string_btPasteArea(btp,name_len+5-strlen(buffer),0,buffer,BC_RIGHT,0); if( dna->offset < dna->end ) sprintf(buffer,"%d",alc->alu[1]->start+1+dna->offset); else sprintf(buffer,"-%d",dna->offset - (alc->alu[1]->start+1)); paste_string_btPasteArea(btp,name_len+5-strlen(buffer),3,buffer,BC_RIGHT,0); free_btPasteArea(btp); return TRUE; } # line 481 "genedisplay.dy" boolean write_intron_desc(btPasteArea * btp,int start,int stop,int in_number,boolean is_split,char prot,char trans,char * dna) { char buffer[32]; if( is_split ) { sprintf(buffer," %c:%c[%s] ",prot,trans,dna); paste_string_btPasteArea(btp,0,2,buffer,BC_RIGHT,0); } if( in_number < 1000 ) { sprintf(buffer," Intron %-3d ",in_number); } else { sprintf(buffer," Intron ??? ",in_number); } paste_string_btPasteArea(btp,0,3,buffer,BC_RIGHT,0); if( start < 10000000 && stop < 10000000 ) sprintf(buffer,"[%-7d:%7d]",start,stop); else sprintf(buffer,"[???????:???????]"); paste_string_btPasteArea(btp,0,4,buffer,BC_RIGHT,0); return TRUE; } # line 509 "genedisplay.dy" boolean write_3intron_match(btPasteArea * btp,int phase,int length,char * seq) { char buf[2]; int i; int prl; prl = 3 - phase + length; if( phase == 0 ) { prl = 3; } sprintf(buf,"%d",phase); for(i=0;i',0); return TRUE; } # line 541 "genedisplay.dy" boolean write_5intron_match(btPasteArea * btp,int phase,int length,char * seq) { char buf[2]; int i; sprintf(buf,"%d",phase); for(i=0;istart;alc != NULL;alc = alc->next ) { if( strstr(alc->alu[1]->text_label,"REV") != NULL ) { is_reversed = 1; } else { is_reversed = 0; } if( strstr(alc->alu[1]->text_label,"CODON") != NULL ) { if( is_reversed == 0 ) { fprintf(ofp,"%-2.2f %-12s %c%c%c %c [%d]\n",Score2Bits(alc->alu[0]->score[0]), alc->alu[1]->text_label, gen->seq[alc->alu[1]->start+1], gen->seq[alc->alu[1]->start+2], gen->seq[alc->alu[1]->start+3], aminoacid_from_seq(ct,gen->seq+alc->alu[1]->start+1),alc->alu[1]->start+1 ); } else { seq[0] = char_complement_base(gen->seq[alc->alu[1]->start+3]); seq[1] = char_complement_base(gen->seq[alc->alu[1]->start+2]); seq[2] = char_complement_base(gen->seq[alc->alu[1]->start+1]); seq[3] = '\0'; fprintf(ofp,"%-2.2f %-12s %c%c%c %c [%c%c%c] [%d]\n",Score2Bits(alc->alu[0]->score[0]), alc->alu[1]->text_label, gen->seq[alc->alu[1]->start+1], gen->seq[alc->alu[1]->start+2], gen->seq[alc->alu[1]->start+3], aminoacid_from_seq(ct,seq), seq[0], seq[1], seq[2], alc->alu[1]->start+1 ); } } else { fprintf(ofp,"%-2.2f %-12s %d-%d\n",Score2Bits(alc->alu[0]->score[0]), alc->alu[1]->text_label,alc->alu[1]->start,alc->alu[1]->end); } } } void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s multiple-alignment-as-fasta\n",program_name); show_help_AlignGeneModelParam(ofp); show_help_ShowGenomicRegionOptions(ofp); fprintf(ofp,"Debugging parameter space\n"); fprintf(ofp," -show_aligngene - show odd-ratios for likelihoods\n"); fprintf(ofp," -show_alignmodel [file] file of gene structure to show\n"); fprintf(ofp," -singleexon [180] - minimum coding length to show single exon\n"); fprintf(ofp," -multiexon [90] - minimum coding length to show multi exon\n"); show_help_DPRunImpl(ofp); show_help_StandardOutputOptions(ofp); show_standard_options(ofp); } int main(int argc,char ** argv) { int i; DPRunImpl * dpri = NULL; FILE * ifp; SeqAlign * al; AlignGeneModelParam * agmp; AlignGeneModel * agm; AlignGeneModelScore * alignscore; AlignGeneModelFrame * frame; PackAln * pal; AlnBlock * alb; AlnBlock * collapsed; Genomic * genomic = NULL; GenomicRegion * gr = NULL; GenomicRegion * temp_gr = NULL; StandardOutputOptions * std_opt; ShowGenomicRegionOptions * sgro; char * dump_packaln = NULL; char * read_packaln = NULL; FILE * packifp = NULL; boolean show_trans = 1; boolean show_collapsed = 0; boolean show_gene_raw = 0; boolean show_gene_model = FALSE; int genedebug = 0; GenomicRegion * inputgr = NULL; char * input_gr_file = NULL; Score intronscore; Probability intronopen = 0.0001; Score genescore; Probability geneopen_factor = 0.00000005; int multiexon = 90; int singleexon = 180; dpri = new_DPRunImpl_from_argv(&argc,argv); if( dpri == NULL ) { fatal("Unable to build DPRun implementation. Bad arguments"); } agmp = new_AlignGeneModelParam_from_argv(&argc,argv); std_opt = new_StandardOutputOptions_from_argv(&argc,argv); sgro = new_ShowGenomicRegionOptions_from_argv(&argc,argv); strip_out_float_argument(&argc,argv,"intron",&intronopen); strip_out_float_argument(&argc,argv,"genefactor",&geneopen_factor); strip_out_integer_argument(&argc,argv,"singleexon",&singleexon); strip_out_integer_argument(&argc,argv,"multiexon",&multiexon); strip_out_boolean_def_argument(&argc,argv,"show_aligngene",&show_gene_model); input_gr_file = strip_out_assigned_argument(&argc,argv,"show_alignmodel"); strip_out_boolean_def_argument(&argc,argv,"genedebug",&genedebug); strip_out_boolean_def_argument(&argc,argv,"albcoll",&show_collapsed); dump_packaln = strip_out_assigned_argument(&argc,argv,"dump"); read_packaln = strip_out_assigned_argument(&argc,argv,"recover"); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 2 ) { show_help(stdout); exit(12); } intronscore = Probability2Score(intronopen); genescore = Probability2Score(intronopen*geneopen_factor); info("Genescore is %2.4f and intron score is %2.4f\n",Score2Bits(genescore),Score2Bits(intronscore)); if((ifp = openfile(argv[1],"r")) == NULL ) { fatal("Could not open file %s",argv[1]); } al = read_fasta_SeqAlign(ifp); info("Read in alignment, anchor %s, length %d species %d\n",al->seq[0]->name,al->seq[0]->len,al->len); assert(al); assert(al->len > 1); agm = create_AlignGeneModel(al,agmp); if( input_gr_file != NULL ) { if((ifp = openfile(input_gr_file,"r")) == NULL ) { fatal("Could not open file %s",input_gr_file); } inputgr = read_genes_GenomicRegion(ifp); if( inputgr->len <= 0 ) { warn("Alignment input model has no genes!"); } } if( show_gene_model == TRUE ) { show_AlignGeneModel(agm,al,agmp->ct,inputgr,stdout,agmp); exit(0); } alignscore = AlignGeneModelScore_from_AlignGeneModel(agm); frame = AlignGeneModelFrame_alloc(); frame->len = 1; if( read_packaln != NULL ) { packifp = openfile(read_packaln,"r"); if( packifp == NULL ) { fatal("File %s is unopenable - ignoring dump command",dump_packaln); } else { pal = read_simple_PackAln(packifp); } } else { pal = PackAln_bestmemory_AlignWise(frame,alignscore,intronscore,genescore,NULL,dpri); } if( dump_packaln != NULL ) { packifp = openfile(dump_packaln,"w"); if( packifp == NULL ) { warn("File %s is unopenable - ignoring dump command",dump_packaln); } else { show_simple_PackAln(pal,packifp); } } alb = convert_PackAln_to_AlnBlock_AlignWise(pal); genomic = Genomic_from_Sequence(al->seq[0]); gr = new_GenomicRegion(genomic); add_Genes_to_GenomicRegion_new(gr,alb); temp_gr = new_GenomicRegion_discard_short(gr,multiexon,singleexon); /* free_GenomicRegion(gr);*/ gr = temp_gr; show_StandardOutputOptions(std_opt,alb,pal,"//",stdout); if( genedebug ) { show_Gene_debug(alb,al->seq[0],agmp->ct,stdout); } if( show_collapsed ) { collapsed = collapsed_AlnBlock(alb,1); mapped_ascii_AlnBlock(collapsed,Score2Bits,0,stdout); fprintf(stdout,"//\n"); } show_GenomicRegionOptions(sgro,gr,agmp->ct,"//",stdout); return 0; } wise-2.4.1/src/models/abc.c0000644000175000001440000037633010670453713015036 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "abc.h" # line 5 "abc.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define START 0 #define END 1 #define abc_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*2)+STATE][i+1] #define abc_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define abc_READ_OFF_ERROR -3 #define abc_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*2)+STATE] #define abc_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define abc_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define abc_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_abc(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [abc *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_abc(abc * mat) { abc_access_func_holder holder; holder.access_main = abc_shatter_access_main; holder.access_special = abc_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_abc(mat,holder); } /* Function: abc_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int abc_shatter_access_main(abc * mat,int i,int j,int state) { return abc_SHATTER_MATRIX(mat,i,j,state); } /* Function: abc_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int abc_shatter_access_special(abc * mat,int i,int j,int state) { return abc_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_abc(mat,dpenv) * * Descrip: This function calculates the abc matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [abc *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_abc(abc * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_1_0; int * SIG_0_1; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,2,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("abc Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_1[MATCH] + 0; /* From state INSERT to state MATCH */ temp = SIG_1_1[INSERT] + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = abc_SHATTER_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > abc_SHATTER_SPECIAL(mat,i,j,END) ) { abc_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_1_0[MATCH] + (mat->a+mat->b); /* From state MATCH to state INSERT */ temp = SIG_0_1[MATCH] + (mat->a+mat->b); if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = SIG_1_1[MATCH] + (mat->a+mat->c); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_1_0[INSERT] + mat->b; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->b; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_1_1[INSERT] + mat->c; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ SIG_0_0[INSERT] = score; /* Finished calculating state INSERT */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_abc(dbsi,out,querydb,targetdb,comp,a,b,c) * * Descrip: This function makes a database search of abc * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [ProteinDB*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * Arg: comp [UNKN ] Undocumented argument [CompMat*] * Arg: a [UNKN ] Undocumented argument [int] * Arg: b [UNKN ] Undocumented argument [int] * Arg: c [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_abc(DBSearchImpl * dbsi,Hscore * out,ProteinDB* querydb,ProteinDB* targetdb ,CompMat* comp,int a,int b,int c) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_abc * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_abc. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_abc. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for abc, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_abc(out,querydb, targetdb ,comp,a,b,c); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_abc *) ckalloc(sizeof(struct thread_pool_holder_abc)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->comp = comp; holder->a = a; holder->b = b; holder->c = c; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_abc,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for abc"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from abc",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_abc(ptr) * * Descrip: Infinite loop code foreach thread for abc * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_abc(void * ptr) { struct thread_pool_holder_abc * holder; int db_status; int score; DataScore * ds; ComplexSequence* query; ComplexSequence* target; holder = (struct thread_pool_holder_abc *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for abc"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for abc"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_ProteinDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in abc search"); } query = hard_link_ComplexSequence(holder->query); /* get query information into datascore */ dataentry_add_ProteinDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_ProteinDB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_ProteinDB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching abc, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_ProteinDB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_ComplexSequence(holder->query); /* get the next query object for the next thread */ holder->query = reload_ProteinDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching abc, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_ProteinDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for abc"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for abc"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_ProteinDB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_abc(query, target ,holder->comp,holder->a,holder->b,holder->c); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for abc"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for abc"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for abc"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_ComplexSequence(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for abc"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_abc(out,querydb,targetdb,comp,a,b,c) * * Descrip: This function makes a database search of abc * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [ProteinDB*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * Arg: comp [UNKN ] Undocumented argument [CompMat*] * Arg: a [UNKN ] Undocumented argument [int] * Arg: b [UNKN ] Undocumented argument [int] * Arg: c [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_abc(Hscore * out,ProteinDB* querydb,ProteinDB* targetdb ,CompMat* comp,int a,int b,int c) { ComplexSequence* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_ProteinDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching abc, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_ProteinDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching abc, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_abc(query, target , comp, a, b, c); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("abc search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_ProteinDB(ds->query,query,querydb); dataentry_add_ProteinDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_ProteinDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching abc, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_ProteinDB(target,targetdb); query = reload_ProteinDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching abc, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_ProteinDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_abc(query,target,comp,a,b,c) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_abc_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: a [UNKN ] Resource [int] * Arg: b [UNKN ] Resource [int] * Arg: c [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_abc(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int a,int b,int c) { int bestscore = NEGI; int i; int j; int k; abc * mat; mat = allocate_abc_only(query, target , comp, a, b, c); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 2,2,2)) == NULL) { warn("Score only matrix for abc cannot be allocated, (asking for 1 by %d cells)",mat->leni*2); mat = free_abc(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<2;k++) abc_VSMALL_MATRIX(mat,i,j,k) = NEGI; } abc_VSMALL_SPECIAL(mat,i,j,START) = 0; abc_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = abc_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = abc_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = abc_VSMALL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); abc_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > abc_VSMALL_SPECIAL(mat,i,j,END) ) { abc_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = abc_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + (mat->a+mat->b); /* From state MATCH to state INSERT */ temp = abc_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + (mat->a+mat->b); if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = abc_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + (mat->a+mat->c); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->b; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->b; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + mat->c; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ abc_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < abc_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = abc_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_abc(mat); return bestscore; } /* Function: PackAln_bestmemory_abc(query,target,comp,a,b,c,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_abc * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: a [UNKN ] Resource [int] * Arg: b [UNKN ] Resource [int] * Arg: c [UNKN ] Resource [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_abc(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int a,int b,int c,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; abc * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->seq->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 2 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_abc(query, target , comp, a, b, c,dpri)) == NULL ) { warn("Unable to allocate large abc version"); return NULL; } calculate_dpenv_abc(mat,dpenv); out = PackAln_read_Expl_abc(mat); } else { mat = allocate_abc_only(query, target , comp, a, b, c); calculate_shatter_abc(mat,dpenv); out = PackAln_read_Shatter_abc(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_abc(query, target , comp, a, b, c)) == NULL ) { warn("Unable to allocate small abc version"); return NULL; } out = PackAln_calculate_Small_abc(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_abc(query, target , comp, a, b, c,dpri)) == NULL ) { warn("Unable to allocate large abc version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_abc(mat); out = PackAln_read_Expl_abc(mat); } } } mat = free_abc(mat); return out; } /* Function: allocate_abc_only(query,target,comp,a,b,c) * * Descrip: This function only allocates the abc structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: a [UNKN ] Resource [int] * Arg: b [UNKN ] Resource [int] * Arg: c [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [abc *] * */ abc * allocate_abc_only(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int a,int b,int c) { abc * out; if((out= abc_alloc()) == NULL) { warn("Allocation of basic abc structure failed..."); return NULL; } out->query = query; out->target = target; out->comp = comp; out->a = a; out->b = b; out->c = c; out->leni = query->seq->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_abc(query,target,comp,a,b,c,dpri) * * Descrip: This function allocates the abc structure * and the basematrix area for explicit memory implementations * It calls /allocate_abc_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: a [UNKN ] Resource [int] * Arg: b [UNKN ] Resource [int] * Arg: c [UNKN ] Resource [int] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [abc *] * */ abc * allocate_Expl_abc(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int a,int b,int c,DPRunImpl * dpri) { abc * out; out = allocate_abc_only(query, target , comp, a, b, c); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*2 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*2,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix abc cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_abc(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_abc(out); return out; } /* Function: init_abc(mat) * * Descrip: This function initates abc matrix when in explicit mode * Called in /allocate_Expl_abc * * * Arg: mat [UNKN ] abc which contains explicit basematrix memory [abc *] * */ void init_abc(abc * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->seq->len;i++) { for(j= (-1);j<2;j++) { abc_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; abc_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; } } for(j= (-1);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { abc_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; abc_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; } abc_EXPL_SPECIAL(mat,i,j,START) = 0; abc_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_abc(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by abc * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [abc *] * */ void recalculate_PackAln_abc(PackAln * pal,abc * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = 0 + (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = 0 + (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); continue; } if( offj == 1 && prev->state == (START+2) ) { pau->score = 0 + (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = (mat->a+mat->b) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = (mat->a+mat->b) + (0); continue; } if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = (mat->a+mat->c) + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->b + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->b + (0); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = mat->c + (0); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+2) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+2) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define abc_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*2+state]) #define abc_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*2+state]) #define abc_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define abc_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define abc_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*2 + state]) #define abc_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define abc_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 2) + ((i+1) * 2) + (state)]) #define abc_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 16) + ((i+1) * 16) + (state * 8) + shadow+1]) #define abc_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_abc(query,target,comp,a,b,c) * * Descrip: This function allocates the abc structure * and the basematrix area for a small memory implementations * It calls /allocate_abc_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: a [UNKN ] Resource [int] * Arg: b [UNKN ] Resource [int] * Arg: c [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [abc *] * */ #define abc_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) abc * allocate_Small_abc(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int a,int b,int c) { abc * out; out = allocate_abc_only(query, target , comp, a, b, c); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 2,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix abc cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_abc(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_abc(mat,dpenv) * * Descrip: This function calculates an alignment for abc structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_abc * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_abc * * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_abc(abc * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for abc due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_abc(mat,dpenv); score = start_end_find_end_abc(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = abc_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = abc_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = abc_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = abc_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = abc_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = abc_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = abc_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_abc(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_abc(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == abc_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_abc(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 2; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_abc(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_abc(mat) * * Descrip: This function calculates an alignment for abc structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_abc * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_abc * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_abc * * * Arg: mat [UNKN ] Undocumented argument [abc *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_abc(abc * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_abc(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_abc(mat); return out; } /* Function: AlnRangeSet_from_abc(mat) * * Descrip: This function reads off a start/end structure * for abc structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_abc * If you have not calculated the matrix use * /AlnRange_calculate_Small_abc * * * Arg: mat [UNKN ] Undocumented argument [abc *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_abc(abc * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_abc"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_abc(mat,&jpos); state = END; while( (temp = AlnRange_build_abc(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_abc(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_abc * * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_abc(abc * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_abc"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_abc(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_abc alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = abc_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = abc_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = abc_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = abc_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = abc_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = abc_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = abc_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = abc_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_abc(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == abc_READ_OFF_ERROR) { warn("In AlnRange_build_abc alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = abc_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_abc(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_abc(abc * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_abc(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == abc_READ_OFF_ERROR) { warn("In abc hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In abc hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In abc hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_abc(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_abc(abc * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = abc_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In abc matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = abc_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Not allowing special sources.. skipping START */ temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == abc_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - abc_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return abc_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == abc_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - abc_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return abc_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in abc read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->c) - (0); if( temp == abc_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - abc_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return abc_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->b) - (0); if( temp == abc_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - abc_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return abc_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->b) - (0); if( temp == abc_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - abc_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return abc_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - ((mat->a+mat->c)) - (0); if( temp == abc_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - abc_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return abc_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } temp = cscore - ((mat->a+mat->b)) - (0); if( temp == abc_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - abc_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return abc_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } temp = cscore - ((mat->a+mat->b)) - (0); if( temp == abc_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - abc_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return abc_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in abc read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in abc read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_abc(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_abc(abc * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > abc_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 2; add_PackAln(out,pau); } max_special_strip_abc(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == abc_READ_OFF_ERROR) { warn("In special strip read abc, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < abc_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read abc, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 2; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_abc(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_abc(abc * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = abc_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for abc, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In abc matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = abc_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source MATCH is not a special */ default: warn("Major problem (!) - in abc special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_abc(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_abc(abc * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = abc_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In abc matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == abc_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - abc_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return abc_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in abc matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in abc matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in abc read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_abc(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_abc(abc * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_abc(mat,starti,startj,stopi,stopj); abc_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ abc_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; abc_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = abc_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = abc_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); abc_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = abc_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + (mat->a+mat->b); /* From state MATCH to state INSERT */ temp = abc_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + (mat->a+mat->b); if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = abc_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + (mat->a+mat->c); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->b; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->b; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + mat->c; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ abc_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ } } return; } /* Function: init_hidden_abc(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_abc(abc * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { abc_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; abc_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; } } return; } /* Function: full_dc_abc(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_abc * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_abc to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [abc *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_abc(abc * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_abc"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_abc(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_abc(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_abc(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for abc, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= abc_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= abc_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = abc_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_abc(mat,abc_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),abc_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),abc_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_abc(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_abc(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_abc(abc * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_abc(mat); abc_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_abc(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_abc(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_abc(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_abc(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_abc(abc * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ abc_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); abc_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = abc_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; if( j - 1 <= mergej) { abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = abc_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } temp = abc_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = abc_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } /* Add any movement independant score */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); abc_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = abc_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (mat->a+mat->b); if( j - 0 <= mergej) { abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-0; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = abc_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = abc_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->a+mat->b); if( temp > score) { score = temp; if( j - 1 <= mergej) { abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = abc_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } } temp = abc_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + (mat->a+mat->c); if( temp > score) { score = temp; if( j - 1 <= mergej) { abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = abc_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } } temp = abc_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->b; if( temp > score) { score = temp; if( j - 0 <= mergej) { abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-0; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = abc_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = abc_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->b; if( temp > score) { score = temp; if( j - 1 <= mergej) { abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = abc_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } temp = abc_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->c; if( temp > score) { score = temp; if( j - 1 <= mergej) { abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = abc_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } /* Add any movement independant score */ abc_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_abc(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_abc(abc * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ abc_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; abc_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = abc_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = abc_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); /* From state INSERT to state MATCH */ temp = abc_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = abc_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); abc_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = abc_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (mat->a+mat->b); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = abc_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state MATCH to state INSERT */ temp = abc_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->a+mat->b); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = abc_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } /* From state MATCH to state INSERT */ temp = abc_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + (mat->a+mat->c); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = abc_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } /* From state INSERT to state INSERT */ temp = abc_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->b; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = abc_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state INSERT to state INSERT */ temp = abc_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->b; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = abc_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* From state INSERT to state INSERT */ temp = abc_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->c; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = abc_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ abc_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_abc(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_abc(abc * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ abc_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; abc_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = abc_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = abc_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); abc_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = abc_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (mat->a+mat->b); /* From state MATCH to state INSERT */ temp = abc_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->a+mat->b); if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = abc_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + (mat->a+mat->c); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->b; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->b; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->c; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ abc_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_abc(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * */ } void init_dc_abc(abc * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { abc_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; abc_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; for(k=0;k<7;k++) { abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); } } } return; } /* Function: start_end_find_end_abc(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [abc *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_abc(abc * mat,int * endj) { register int j; register int max; register int maxj; max = abc_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( abc_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = abc_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_abc(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [abc] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_abc(abc *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->seq->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 2,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 2 * 8,sizeof(int)); for(j=0;jcomp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); /* assign local shadown pointer */ localsp = &(abc_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); /* From state INSERT to state MATCH */ temp = abc_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0 +(CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(abc_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* From state START to state MATCH */ temp = abc_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + 0 + (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ abc_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) abc_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > abc_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { abc_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) abc_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = abc_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); abc_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = abc_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); abc_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; abc_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; abc_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = abc_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (mat->a+mat->b) + (0); /* assign local shadown pointer */ localsp = &(abc_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state MATCH to state INSERT */ temp = abc_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->a+mat->b) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(abc_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); } /* From state MATCH to state INSERT */ temp = abc_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + (mat->a+mat->c) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(abc_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); } /* From state INSERT to state INSERT */ temp = abc_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->b +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(abc_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state INSERT to state INSERT */ temp = abc_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->b +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(abc_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* From state INSERT to state INSERT */ temp = abc_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->c +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(abc_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ abc_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) abc_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_abc(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * */ void init_start_end_linear_abc(abc * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { abc_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; abc_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); abc_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; abc_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); } } for(j=(-1);jtarget->seq->len;j++) { abc_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; abc_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; abc_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; abc_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_abc(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_abc(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_abc(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "SEQUENCE","UNMATCHED_SEQUENCE","INSERT","END" }; /* Function: AlnConvertSet_abc(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "SEQUENCE","INSERT","UNMATCHED_SEQUENCE","END" }; AlnConvertSet * AlnConvertSet_abc(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 2; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 2; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[3]; return out; } /* Function: PackAln_read_Expl_abc(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [abc *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_abc(abc * mat) { abc_access_func_holder holder; holder.access_main = abc_explicit_access_main; holder.access_special = abc_explicit_access_special; return PackAln_read_generic_abc(mat,holder); } /* Function: abc_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int abc_explicit_access_main(abc * mat,int i,int j,int state) { return abc_EXPL_MATRIX(mat,i,j,state); } /* Function: abc_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int abc_explicit_access_special(abc * mat,int i,int j,int state) { return abc_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_abc(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: h [UNKN ] Undocumented argument [abc_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_abc(abc * mat,abc_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_abc(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in abc_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 2; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_abc(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_abc(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == abc_READ_OFF_ERROR || j == abc_READ_OFF_ERROR || state == abc_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in abc_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 2; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_abc(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [abc_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_abc(abc * mat,int * ri,int * rj,int * state,boolean * isspecial,abc_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: abc_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void abc_debug_show_matrix(abc * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->seq->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",abc_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",abc_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_abc(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [abc_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_abc(abc * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,abc_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = abc_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In abc matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in abc read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->c) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->b) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - ((mat->a+mat->c)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } temp = cscore - ((mat->a+mat->b)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } temp = cscore - ((mat->a+mat->b)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in abc read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in abc read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_abc(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [abc_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_abc(abc * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,abc_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = abc_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In abc matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source MATCH is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in abc read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_abc(mat) * * Descrip: This function calculates the abc matrix when in explicit mode * To allocate the matrix use /allocate_Expl_abc * * * Arg: mat [UNKN ] abc which contains explicit basematrix memory [abc *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_abc(abc * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_abc, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("abc Matrix calculation: "); for(j=0;j score ) { score = temp; } /* From state START to state MATCH */ temp = abc_EXPL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); abc_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > abc_EXPL_SPECIAL(mat,i,j,END) ) { abc_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = abc_EXPL_MATRIX(mat,i-1,j-0,MATCH) + (mat->a+mat->b); /* From state MATCH to state INSERT */ temp = abc_EXPL_MATRIX(mat,i-0,j-1,MATCH) + (mat->a+mat->b); if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = abc_EXPL_MATRIX(mat,i-1,j-1,MATCH) + (mat->a+mat->c); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->b; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->b; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->c; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ abc_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_abc(mat,dpenv) * * Descrip: This function calculates the abc matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] abc which contains explicit basematrix memory [abc *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_abc(abc * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_abc, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { abc_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; abc_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; } } for(j=-1;jlenj;j++) { abc_EXPL_SPECIAL(mat,i,j,START) = 0; abc_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("abc Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { abc_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; abc_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = abc_EXPL_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = abc_EXPL_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = abc_EXPL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); abc_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > abc_EXPL_SPECIAL(mat,i,j,END) ) { abc_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = abc_EXPL_MATRIX(mat,i-1,j-0,MATCH) + (mat->a+mat->b); /* From state MATCH to state INSERT */ temp = abc_EXPL_MATRIX(mat,i-0,j-1,MATCH) + (mat->a+mat->b); if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = abc_EXPL_MATRIX(mat,i-1,j-1,MATCH) + (mat->a+mat->c); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->b; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->b; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = abc_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->c; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ abc_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: abc_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [abc *] * */ abc * abc_alloc(void) { abc * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(abc *) ckalloc (sizeof(abc))) == NULL) { warn("abc_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_abc(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [abc *] * * Return [UNKN ] Undocumented return value [abc *] * */ abc * free_abc(abc * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a abc obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->comp is linked in */ /* obj->a is linked in */ /* obj->b is linked in */ /* obj->c is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/abc.h0000644000175000001440000004323010670453713015031 0ustar philippusers#ifndef DYNAMITEabcHEADERFILE #define DYNAMITEabcHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" struct Wise2_abc { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; ComplexSequence* query; ComplexSequence* target; CompMat* comp; int a; int b; int c; } ; /* abc defined */ #ifndef DYNAMITE_DEFINED_abc typedef struct Wise2_abc Wise2_abc; #define abc Wise2_abc #define DYNAMITE_DEFINED_abc #endif #ifdef PTHREAD struct thread_pool_holder_abc { ComplexSequence* query; /* Query object placeholder */ ProteinDB* querydb; /* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ ProteinDB* targetdb;/* Target database object */ boolean target_init; CompMat* comp; int a; int b; int c; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_abc_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(abc*,int,int,int); int (*access_special)(abc*,int,int,int); } ; /* abc_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_abc_access_func_holder typedef struct Wise2_abc_access_func_holder Wise2_abc_access_func_holder; #define abc_access_func_holder Wise2_abc_access_func_holder #define DYNAMITE_DEFINED_abc_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_abc(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [abc *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_abc(abc * mat); #define PackAln_read_Shatter_abc Wise2_PackAln_read_Shatter_abc /* Function: calculate_shatter_abc(mat,dpenv) * * Descrip: This function calculates the abc matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [abc *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_abc(abc * mat,DPEnvelope * dpenv); #define calculate_shatter_abc Wise2_calculate_shatter_abc /* Function: search_abc(dbsi,out,querydb,targetdb,comp,a,b,c) * * Descrip: This function makes a database search of abc * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [ProteinDB*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * Arg: comp [UNKN ] Undocumented argument [CompMat*] * Arg: a [UNKN ] Undocumented argument [int] * Arg: b [UNKN ] Undocumented argument [int] * Arg: c [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_abc(DBSearchImpl * dbsi,Hscore * out,ProteinDB* querydb,ProteinDB* targetdb ,CompMat* comp,int a,int b,int c); #define search_abc Wise2_search_abc /* Function: serial_search_abc(out,querydb,targetdb,comp,a,b,c) * * Descrip: This function makes a database search of abc * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [ProteinDB*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * Arg: comp [UNKN ] Undocumented argument [CompMat*] * Arg: a [UNKN ] Undocumented argument [int] * Arg: b [UNKN ] Undocumented argument [int] * Arg: c [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_abc(Hscore * out,ProteinDB* querydb,ProteinDB* targetdb ,CompMat* comp,int a,int b,int c); #define serial_search_abc Wise2_serial_search_abc /* Function: PackAln_bestmemory_abc(query,target,comp,a,b,c,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_abc * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: a [UNKN ] Resource [int] * Arg: b [UNKN ] Resource [int] * Arg: c [UNKN ] Resource [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_abc(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int a,int b,int c,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_abc Wise2_PackAln_bestmemory_abc /* Function: allocate_Expl_abc(query,target,comp,a,b,c,dpri) * * Descrip: This function allocates the abc structure * and the basematrix area for explicit memory implementations * It calls /allocate_abc_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: a [UNKN ] Resource [int] * Arg: b [UNKN ] Resource [int] * Arg: c [UNKN ] Resource [int] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [abc *] * */ abc * Wise2_allocate_Expl_abc(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int a,int b,int c,DPRunImpl * dpri); #define allocate_Expl_abc Wise2_allocate_Expl_abc /* Function: recalculate_PackAln_abc(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by abc * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [abc *] * */ void Wise2_recalculate_PackAln_abc(PackAln * pal,abc * mat); #define recalculate_PackAln_abc Wise2_recalculate_PackAln_abc /* Function: allocate_Small_abc(query,target,comp,a,b,c) * * Descrip: This function allocates the abc structure * and the basematrix area for a small memory implementations * It calls /allocate_abc_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: a [UNKN ] Resource [int] * Arg: b [UNKN ] Resource [int] * Arg: c [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [abc *] * */ abc * Wise2_allocate_Small_abc(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int a,int b,int c); #define allocate_Small_abc Wise2_allocate_Small_abc /* Function: PackAln_calculate_Small_abc(mat,dpenv) * * Descrip: This function calculates an alignment for abc structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_abc * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_abc * * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_abc(abc * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_abc Wise2_PackAln_calculate_Small_abc /* Function: AlnRangeSet_calculate_Small_abc(mat) * * Descrip: This function calculates an alignment for abc structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_abc * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_abc * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_abc * * * Arg: mat [UNKN ] Undocumented argument [abc *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_abc(abc * mat); #define AlnRangeSet_calculate_Small_abc Wise2_AlnRangeSet_calculate_Small_abc /* Function: AlnRangeSet_from_abc(mat) * * Descrip: This function reads off a start/end structure * for abc structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_abc * If you have not calculated the matrix use * /AlnRange_calculate_Small_abc * * * Arg: mat [UNKN ] Undocumented argument [abc *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_abc(abc * mat); #define AlnRangeSet_from_abc Wise2_AlnRangeSet_from_abc /* Function: convert_PackAln_to_AlnBlock_abc(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_abc(PackAln * pal); #define convert_PackAln_to_AlnBlock_abc Wise2_convert_PackAln_to_AlnBlock_abc /* Function: PackAln_read_Expl_abc(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [abc *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_abc(abc * mat); #define PackAln_read_Expl_abc Wise2_PackAln_read_Expl_abc /* Function: PackAln_read_generic_abc(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [abc *] * Arg: h [UNKN ] Undocumented argument [abc_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_abc(abc * mat,abc_access_func_holder h); #define PackAln_read_generic_abc Wise2_PackAln_read_generic_abc /* Function: calculate_abc(mat) * * Descrip: This function calculates the abc matrix when in explicit mode * To allocate the matrix use /allocate_Expl_abc * * * Arg: mat [UNKN ] abc which contains explicit basematrix memory [abc *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_abc(abc * mat); #define calculate_abc Wise2_calculate_abc /* Function: calculate_dpenv_abc(mat,dpenv) * * Descrip: This function calculates the abc matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] abc which contains explicit basematrix memory [abc *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_abc(abc * mat,DPEnvelope * dpenv); #define calculate_dpenv_abc Wise2_calculate_dpenv_abc /* Function: abc_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [abc *] * */ abc * Wise2_abc_alloc(void); #define abc_alloc Wise2_abc_alloc /* Function: free_abc(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [abc *] * * Return [UNKN ] Undocumented return value [abc *] * */ abc * Wise2_free_abc(abc * obj); #define free_abc Wise2_free_abc /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_abc_shatter_access_main(abc * mat,int i,int j,int state); #define abc_shatter_access_main Wise2_abc_shatter_access_main int Wise2_abc_shatter_access_special(abc * mat,int i,int j,int state); #define abc_shatter_access_special Wise2_abc_shatter_access_special void * Wise2_thread_loop_abc(void * ptr); #define thread_loop_abc Wise2_thread_loop_abc int Wise2_score_only_abc(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int a,int b,int c); #define score_only_abc Wise2_score_only_abc abc * Wise2_allocate_abc_only(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int a,int b,int c); #define allocate_abc_only Wise2_allocate_abc_only void Wise2_init_abc(abc * mat); #define init_abc Wise2_init_abc AlnRange * Wise2_AlnRange_build_abc(abc * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_abc Wise2_AlnRange_build_abc boolean Wise2_read_hidden_abc(abc * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_abc Wise2_read_hidden_abc int Wise2_max_hidden_abc(abc * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_abc Wise2_max_hidden_abc boolean Wise2_read_special_strip_abc(abc * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_abc Wise2_read_special_strip_abc int Wise2_max_special_strip_abc(abc * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_abc Wise2_max_special_strip_abc int Wise2_max_matrix_to_special_abc(abc * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_abc Wise2_max_matrix_to_special_abc void Wise2_calculate_hidden_abc(abc * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_abc Wise2_calculate_hidden_abc void Wise2_init_hidden_abc(abc * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_abc Wise2_init_hidden_abc boolean Wise2_full_dc_abc(abc * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_abc Wise2_full_dc_abc boolean Wise2_do_dc_single_pass_abc(abc * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_abc Wise2_do_dc_single_pass_abc void Wise2_push_dc_at_merge_abc(abc * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_abc Wise2_push_dc_at_merge_abc void Wise2_follow_on_dc_abc(abc * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_abc Wise2_follow_on_dc_abc void Wise2_run_up_dc_abc(abc * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_abc Wise2_run_up_dc_abc void Wise2_init_dc_abc(abc * mat); #define init_dc_abc Wise2_init_dc_abc int Wise2_start_end_find_end_abc(abc * mat,int * endj); #define start_end_find_end_abc Wise2_start_end_find_end_abc boolean Wise2_dc_optimised_start_end_calc_abc(abc *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_abc Wise2_dc_optimised_start_end_calc_abc void Wise2_init_start_end_linear_abc(abc * mat); #define init_start_end_linear_abc Wise2_init_start_end_linear_abc AlnConvertSet * Wise2_AlnConvertSet_abc(void); #define AlnConvertSet_abc Wise2_AlnConvertSet_abc int Wise2_abc_explicit_access_main(abc * mat,int i,int j,int state); #define abc_explicit_access_main Wise2_abc_explicit_access_main int Wise2_abc_explicit_access_special(abc * mat,int i,int j,int state); #define abc_explicit_access_special Wise2_abc_explicit_access_special int Wise2_find_end_abc(abc * mat,int * ri,int * rj,int * state,boolean * isspecial,abc_access_func_holder h); #define find_end_abc Wise2_find_end_abc void Wise2_abc_debug_show_matrix(abc * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define abc_debug_show_matrix Wise2_abc_debug_show_matrix int Wise2_max_calc_abc(abc * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,abc_access_func_holder h); #define max_calc_abc Wise2_max_calc_abc int Wise2_max_calc_special_abc(abc * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,abc_access_func_holder h); #define max_calc_special_abc Wise2_max_calc_special_abc #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/est_evidence.dy0000644000175000001440000002010707557172746017142 0ustar philippusers %{ #include "genome_evidence.h" #include "aln.h" #define EstEvidenceLISTLENGTH 24 %} struct EstExon int start int end boolean is_coding !def="FALSE" int phase int used !def="0" int intron_3_score !def="0" struct EstIndel int start int end struct EstEvidence EstExon ** exon !list EstIndel ** indel !list !len="indel_" CodonTable * ct int in_smell !default="8" %{ #include "est_evidence.h" int indicate_intron_used(GenomeEvidenceSet * set,AlnBlock * alb) { AlnColumn * alc; int i; int j; int has_used = 0; for(alc=alb->start;alc!=NULL;alc=alc->next ) { if( strstartcmp(alc->alu[1]->text_label,"5SS") == 0 ) { for(i=0;ilen;i++) { auto EstEvidence * evi; evi = (EstEvidence*) set->geu[i]->data; for(j=0;jlen;j++) { if( abs(evi->exon[i]->end - alc->alu[1]->start) < 4 ) { /* this is used */ if( evi->exon[i]->used != 1 ) { evi->exon[i]->used = 1; has_used = 1; } } } } } } return has_used; } GenomeEvidenceSet * read_est_evidence(FILE * ifp,CodonTable * ct) { char buffer[MAXLINE]; GenomeEvidenceUnit * geu; EstEvidence * evi; EstExon * exon; GenomeEvidenceSet * ges; EstIndel * indel; assert(ct); assert(ifp); ges = GenomeEvidenceSet_alloc_std(); evi = EstEvidence_alloc_std(); evi->ct = hard_link_CodonTable(ct); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"//") == 0 ) { geu = new_est_GenomeEvidenceUnit(evi); add_GenomeEvidenceSet(ges,geu); evi = EstEvidence_alloc_std(); evi->ct = hard_link_CodonTable(ct); continue; } if( strstartcmp(buffer,"exon") == 0 ) { exon = EstExon_alloc(); exon->intron_3_score = 0; if( sscanf(buffer,"exon %d %d %d",&exon->start,&exon->end,&exon->intron_3_score) < 2 ) { fatal("Unable to read exon line as evidence [%s]"); } exon->start--; exon->end--; add_EstEvidence(evi,exon); } else if( strstartcmp(buffer,"cds") == 0 ) { exon = EstExon_alloc(); sscanf(buffer,"cds %d %d %d",&exon->start,&exon->end,&exon->phase); exon->start--; exon->end--; if( exon->phase > 2 || exon->phase < 0 ) { fprintf(stderr,"Exon has a non clear phase - %d\n",exon->phase); return NULL; } exon->is_coding = TRUE; add_EstEvidence(evi,exon); } else if ( strstartcmp(buffer,"indel") == 0 ) { indel = EstIndel_alloc(); sscanf(buffer,"indel %d %d",&indel->start,&indel->end); indel->start--; indel->end--; add_indel_EstEvidence(evi,indel); } else { fprintf(stderr,"Unable to read as est evidence - %s",buffer); } } if( evi->len > 0 ) { geu = new_est_GenomeEvidenceUnit(evi); add_GenomeEvidenceSet(ges,geu); } return ges; } GenomeEvidenceUnit * new_est_GenomeEvidenceUnit(EstEvidence * evi) { GenomeEvidenceUnit * in; in = GenomeEvidenceUnit_alloc(); in->cds_3SS = est_cds_3SS; in->cds_5SS = est_cds_5SS; in->utr_3SS = est_3ss; in->utr_5SS = est_5ss; in->cds_pot = est_cds_pot; in->utr_pot = est_utr_pot; in->cds_intron_pot = est_intron_pot; in->utr_intron_pot = est_intron_pot; in->geu_free = free_EstEvidence; in->frameshift_cds = est_cds_frameshift; in->stop_pot = est_stop_pot; in->start_pot = est_start_pot; in->utr3_end = est_utr3_end; in->utr5_start = est_utr5_start; in->data = (void*) evi; return in; } int est_utr5_start(void * data,ComplexSequence *seq,int jposition) { EstEvidence * est; est = (EstEvidence *)data; if( est->exon[0]->start == jposition ) { return 0; } else { return -80000; } } int est_utr3_end(void * data,ComplexSequence *seq,int jposition) { EstEvidence * est; est = (EstEvidence *)data; if( est->exon[est->len-1]->end == jposition ) { return 0; } else { return -80000; } } int est_start_pot(void * data,ComplexSequence *seq,int jposition) { EstEvidence * est; int i; int codon; int atg = (BASE_A*25+BASE_T*5+BASE_G); est = (EstEvidence *)data; codon = CSEQ_GENOMIC_CODON(seq,jposition); if( is_stop_codon(codon,est->ct) ) { return -10000; } else if( codon == atg ) { return 1200; } else { return 0; } } int est_stop_pot(void * data,ComplexSequence *seq,int jposition) { EstEvidence * est; int i; est = (EstEvidence *)data; if( is_stop_codon(CSEQ_GENOMIC_CODON(seq,jposition),est->ct) ) { return 100; } else { return -1000; } } int est_cds_frameshift(void * data,ComplexSequence * seq,int jposition,int jump) { EstEvidence * est; int i; est = (EstEvidence *)data; for(i=1;iindel_len;i++) { if( jposition >= est->indel[i]->start && jposition <= est->indel[i]->end ) { return 0; } } return -10000; } int est_cds_3SS(void * data,ComplexSequence *seq,int jposition,int phase) { switch(phase) { case 0 : return est_3ss(data,seq,jposition); case 1 : return est_3ss(data,seq,jposition); case 2 : return est_3ss(data,seq,jposition); default : return -100000; } } int est_cds_5SS(void * data,ComplexSequence *seq,int jposition,int phase) { switch(phase) { case 0 : return est_5ss(data,seq,jposition); case 1 : return est_5ss(data,seq,jposition); case 2 : return est_5ss(data,seq,jposition); default : return -100000; } } int est_intron_pot(void * data,ComplexSequence *seq,int jposition) { EstEvidence * est; int i; est = (EstEvidence *)data; for(i=1;ilen;i++) { if( (est->exon[i-1]->end <= jposition) && (jposition <= est->exon[i]->start) ) { return 0; } if( (est->exon[i]->start < jposition) && (jposition < est->exon[i]->end) ) { return -1000; } } return -10; } int est_cds_pot(void * data,ComplexSequence *seq,int jposition) { int i; EstEvidence * est; int relative_frame; est = (EstEvidence *)data; for(i=0;ilen;i++) { if( est->exon[i]->start <= jposition && jposition <= est->exon[i]->end ) { if( is_stop_codon(CSEQ_GENOMIC_CODON(seq,jposition),est->ct) ) { return -1000000; } else { if( est->exon[i]->is_coding == TRUE ) { /* phase calculation. difference between start and position */ /* more complex than it looks due to convention of where a codon lies and the phase convention */ relative_frame = (jposition-est->exon[i]->start)%3; if( relative_frame == 2 && est->exon[i]->phase == 0 ) { return 125; } else if ( relative_frame == 1 && est->exon[i]->phase == 1 ) { return 125; } else if ( relative_frame == 0 && est->exon[i]->phase == 2) { return 125; } } else { /* not coding exon - return 45 */ return 80; } } } } /* we have to return same as stop codon penalty, otherwise we can just dodge stop codons using evidence lines */ return -1000000; } int est_3ss(void * data,ComplexSequence *seq,int jposition) { int i; EstEvidence * est; est = (EstEvidence *)data; if( jposition == 0 ) { return -10000; } for(i=0;ilen;i++) { if( jposition+1 == est->exon[i]->start ) { return 50; } if( abs(jposition+1 - est->exon[i]->start) < est->in_smell && seq->seq->seq[jposition] == 'G' && seq->seq->seq[jposition-1] == 'A' ) { return -400; } } return -10000; } int est_5ss(void * data,ComplexSequence * seq,int jposition) { int i; EstEvidence * est; est = (EstEvidence *)data; if( jposition == 0 || jposition >= seq->seq->len+2 ) { return -10000; } for(i=0;ilen;i++) { if( jposition-1 == est->exon[i]->end ) { if( est->exon[i]->used == 0 ) { return 500+est->exon[i]->intron_3_score; } else { return 10+est->exon[i]->intron_3_score; } } if( abs(jposition-1 - est->exon[i]->end) < est->in_smell && seq->seq->seq[jposition] == 'G' && seq->seq->seq[jposition+1] == 'T' ) { return -400; } } return -10000; } int est_utr_pot(void * data,ComplexSequence *seq,int jposition) { int i; EstEvidence * est; est = (EstEvidence *)data; for(i=0;ilen;i++) { if( est->exon[i]->start <= jposition && jposition <= est->exon[i]->end ) { return +10; } } return -10; } wise-2.4.1/src/models/gwlite.dy0000644000175000001440000001410607313404546015764 0ustar philippusers %{ #include "gwlitemodel.h" #include "geneparser4.h" #include "genewisemodeldb.h" %} type GWLITE real GwLiteScore* dbtype GeneWiseDB* init init_GwLite_GeneWiseDB reload reload_GwLite_GeneWiseDB close close_GwLite_GeneWiseDB addentry dataentry_add_GwLite_GeneWiseDB hardlink hard_link_GwLiteScore free free_GwLiteScore threadsafe endtype matrix GeneLiteModel query type="GWLITE" name="query" field:len="len" target type="GENOMIC" name="target" resource type="GeneParser4Score *" name="gp" extern name="GW_*" type="int" extern name="GP4_*" type="int" state MATCH offi="1" offj="3" source MATCH calc="query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource # # phase 0,1,2 introns can calculate whole amino acid for 0. # source INTRON_0 offi="1" offj="3" calc="query->seg[i]->transition[GW_MATCH2MATCH] + gp->transition[GP4_INTRON2CDS] +GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source INTRON_1 offi="1" offj="2" calc="query->seg[i]->transition[GW_MATCH2MATCH] + gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source INTRON_2 offi="1" offj="1" calc="query->seg[i]->transition[GW_MATCH2MATCH] + gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource # # Sequencing error transitions, at offsets 1,2,4,5 for delete 1,2 or insert 1,2 # source MATCH offi="1" offj="2" calc="gp->transition[GP4_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="1" calc="gp->transition[GP4_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource query_label MATCH_STATE target_label CODON endstate # # Insert state: does not move along model, produces DNA sequence... # state INSERT offi="0" offj="3" source MATCH calc="query->seg[i]->transition[GW_MATCH2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource # # phase 0,1,2 introns can calculate whole amino acid for 0. # source INTRON_0 offi="0" offj="3" calc="query->seg[i]->transition[GW_INSERT2INSERT] + gp->transition[GP4_INTRON2CDS] + query->seg[i]->match[GENOMIC_CODON(target,j)]+GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source INTRON_1 offi="0" offj="2" calc="query->seg[i]->transition[GW_INSERT2INSERT] + gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source INTRON_2 offi="0" offj="1" calc="query->seg[i]->transition[GW_INSERT2INSERT] + gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource # # Sequencing error transitions: because insertions are "for free" usually, we will # only model sequence deletion here. Could produce odd results though! # source INSERT offi="0" offj="2" calc="gp->transition[GP4_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="1" calc="gp->transition[GP4_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="query->seg[i]->transition[GW_MATCH2DELETE]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2DELETE]" endsource source START calc="query->seg[i]->transition[GW_START2DELETE]" endsource query_label DELETE_STATE target_label INSERT endstate # # Intron state: 3 separate phases, and merge INSERT/MATCH information # state INTRON_0 offi="0" offj="1" source MATCH offj="1" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j)" target_label 5SS_PHASE_0 endsource source INSERT offj="1" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j)" target_label 5SS_PHASE_0 endsource source INTRON_0 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state INTRON_1 offi="0" offj="1" source MATCH offj="2" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j)" target_label 5SS_PHASE_1 endsource source INSERT offj="2" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j)" target_label 5SS_PHASE_1 endsource source INTRON_1 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state INTRON_2 offi="0" offj="1" source MATCH offj="3" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j)" target_label 5SS_PHASE_2 endsource source INSERT offj="3" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j)" target_label 5SS_PHASE_2 endsource source INTRON_2 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state START !start !special endstate state END !end !special source MATCH calc="query->seg[i]->transition[GW_MATCH2END]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2END]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2END]" endsource target_label END query_label END endstate # # collapse Intron labels! # collapse INTRON_STATE CENTRAL_INTRON endmatrix wise-2.4.1/src/models/dba.c0000644000175000001440000065100310670453713015030 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dba.h" # line 5 "dba.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH65 0 #define MATCH75 1 #define MATCH85 2 #define MATCH95 3 #define UNMATCHED_QUERY 4 #define UNMATCHED_TARGET 5 #define START 0 #define END 1 #define DnaMatchBlock_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*6)+STATE][i+1] #define DnaMatchBlock_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define DnaMatchBlock_READ_OFF_ERROR -3 #define DnaMatchBlock_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*6)+STATE] #define DnaMatchBlock_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define DnaMatchBlock_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define DnaMatchBlock_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_DnaMatchBlock(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_DnaMatchBlock(DnaMatchBlock * mat) { DnaMatchBlock_access_func_holder holder; holder.access_main = DnaMatchBlock_shatter_access_main; holder.access_special = DnaMatchBlock_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_DnaMatchBlock(mat,holder); } /* Function: DnaMatchBlock_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int DnaMatchBlock_shatter_access_main(DnaMatchBlock * mat,int i,int j,int state) { return DnaMatchBlock_SHATTER_MATRIX(mat,i,j,state); } /* Function: DnaMatchBlock_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int DnaMatchBlock_shatter_access_special(DnaMatchBlock * mat,int i,int j,int state) { return DnaMatchBlock_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_DnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the DnaMatchBlock matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [DnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_DnaMatchBlock(DnaMatchBlock * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,6,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("DnaMatchBlock Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH65 */ /* setting first movement to score */ score = SIG_1_1[MATCH65] + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = SIG_0_1[MATCH65] + mat->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = SIG_1_0[MATCH65] + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH65] = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = SIG_1_1[MATCH75] + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH75 to state MATCH75 */ temp = SIG_0_1[MATCH75] + mat->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = SIG_1_0[MATCH75] + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH75] = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = SIG_1_1[MATCH85] + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH85 to state MATCH85 */ temp = SIG_0_1[MATCH85] + mat->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = SIG_1_0[MATCH85] + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH85] = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = SIG_1_1[MATCH95] + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH95 to state MATCH95 */ temp = SIG_0_1[MATCH95] + mat->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = SIG_1_0[MATCH95] + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH95] = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = SIG_1_0[MATCH65] + mat->b; /* From state MATCH75 to state UNMATCHED_QUERY */ temp = SIG_1_0[MATCH75] + mat->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = SIG_1_0[MATCH85] + mat->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = SIG_1_0[MATCH95] + mat->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = SIG_1_0[UNMATCHED_QUERY] + mat->u; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state UNMATCHED_QUERY */ temp = DnaMatchBlock_SHATTER_SPECIAL(mat,i-1,j-0,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ SIG_0_0[UNMATCHED_QUERY] = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = SIG_0_1[UNMATCHED_QUERY] + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = SIG_0_1[UNMATCHED_TARGET] + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ SIG_0_0[UNMATCHED_TARGET] = score; /* state UNMATCHED_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > DnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) ) { DnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state UNMATCHED_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_DnaMatchBlock(dbsi,out,query,target,comp65,comp75,comp85,comp95,g,u,v,s,b) * * Descrip: This function makes a database search of DnaMatchBlock * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp65 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp75 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp85 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp95 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: g [UNKN ] Undocumented argument [Score] * Arg: u [UNKN ] Undocumented argument [Score] * Arg: v [UNKN ] Undocumented argument [Score] * Arg: s [UNKN ] Undocumented argument [Score] * Arg: b [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_DnaMatchBlock(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b) { if( out == NULL ) { warn("Passed in a null Hscore object into search_DnaMatchBlock. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_DnaMatchBlock. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for DnaMatchBlock, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_DnaMatchBlock(out,query,target ,comp65,comp75,comp85,comp95,g,u,v,s,b); case DBSearchImpl_Pthreads : warn("This matrix DnaMatchBlock was not dyc compiled with thread support"); return SEARCH_ERROR; default : warn("database search implementation %s was not provided in the compiled dynamite file from DnaMatchBlock",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: serial_search_DnaMatchBlock(out,query,target,comp65,comp75,comp85,comp95,g,u,v,s,b) * * Descrip: This function makes a database search of DnaMatchBlock * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp65 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp75 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp85 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp95 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: g [UNKN ] Undocumented argument [Score] * Arg: u [UNKN ] Undocumented argument [Score] * Arg: v [UNKN ] Undocumented argument [Score] * Arg: s [UNKN ] Undocumented argument [Score] * Arg: b [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_DnaMatchBlock(Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_DnaMatchBlock(query, target , comp65, comp75, comp85, comp95, g, u, v, s, b); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("DnaMatchBlock search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_DnaMatchBlock(query,target,comp65,comp75,comp85,comp95,g,u,v,s,b) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_DnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_DnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b) { int bestscore = NEGI; int i; int j; int k; DnaMatchBlock * mat; mat = allocate_DnaMatchBlock_only(query, target , comp65, comp75, comp85, comp95, g, u, v, s, b); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 6,2,2)) == NULL) { warn("Score only matrix for DnaMatchBlock cannot be allocated, (asking for 1 by %d cells)",mat->leni*6); mat = free_DnaMatchBlock(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<6;k++) DnaMatchBlock_VSMALL_MATRIX(mat,i,j,k) = NEGI; } DnaMatchBlock_VSMALL_SPECIAL(mat,i,j,START) = 0; DnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH65 */ /* setting first movement to score */ score = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ DnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ DnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH75) = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ DnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH85) = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ DnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH95) = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; /* From state MATCH75 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state UNMATCHED_QUERY */ temp = DnaMatchBlock_VSMALL_SPECIAL(mat,i-1,j-0,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ DnaMatchBlock_VSMALL_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = DnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = DnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ DnaMatchBlock_VSMALL_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* state UNMATCHED_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > DnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) ) { DnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state UNMATCHED_TARGET */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < DnaMatchBlock_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = DnaMatchBlock_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_DnaMatchBlock(mat); return bestscore; } /* Function: PackAln_bestmemory_DnaMatchBlock(query,target,comp65,comp75,comp85,comp95,g,u,v,s,b,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_DnaMatchBlock * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_DnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; DnaMatchBlock * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->seq->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 6 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_DnaMatchBlock(query, target , comp65, comp75, comp85, comp95, g, u, v, s, b,dpri)) == NULL ) { warn("Unable to allocate large DnaMatchBlock version"); return NULL; } calculate_dpenv_DnaMatchBlock(mat,dpenv); out = PackAln_read_Expl_DnaMatchBlock(mat); } else { mat = allocate_DnaMatchBlock_only(query, target , comp65, comp75, comp85, comp95, g, u, v, s, b); calculate_shatter_DnaMatchBlock(mat,dpenv); out = PackAln_read_Shatter_DnaMatchBlock(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_DnaMatchBlock(query, target , comp65, comp75, comp85, comp95, g, u, v, s, b)) == NULL ) { warn("Unable to allocate small DnaMatchBlock version"); return NULL; } out = PackAln_calculate_Small_DnaMatchBlock(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_DnaMatchBlock(query, target , comp65, comp75, comp85, comp95, g, u, v, s, b,dpri)) == NULL ) { warn("Unable to allocate large DnaMatchBlock version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_DnaMatchBlock(mat); out = PackAln_read_Expl_DnaMatchBlock(mat); } } } mat = free_DnaMatchBlock(mat); return out; } /* Function: allocate_DnaMatchBlock_only(query,target,comp65,comp75,comp85,comp95,g,u,v,s,b) * * Descrip: This function only allocates the DnaMatchBlock structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [DnaMatchBlock *] * */ DnaMatchBlock * allocate_DnaMatchBlock_only(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b) { DnaMatchBlock * out; if((out= DnaMatchBlock_alloc()) == NULL) { warn("Allocation of basic DnaMatchBlock structure failed..."); return NULL; } out->query = query; out->target = target; out->comp65 = comp65; out->comp75 = comp75; out->comp85 = comp85; out->comp95 = comp95; out->g = g; out->u = u; out->v = v; out->s = s; out->b = b; out->leni = query->seq->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_DnaMatchBlock(query,target,comp65,comp75,comp85,comp95,g,u,v,s,b,dpri) * * Descrip: This function allocates the DnaMatchBlock structure * and the basematrix area for explicit memory implementations * It calls /allocate_DnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [DnaMatchBlock *] * */ DnaMatchBlock * allocate_Expl_DnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b,DPRunImpl * dpri) { DnaMatchBlock * out; out = allocate_DnaMatchBlock_only(query, target , comp65, comp75, comp85, comp95, g, u, v, s, b); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*6 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*6,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix DnaMatchBlock cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_DnaMatchBlock(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_DnaMatchBlock(out); return out; } /* Function: init_DnaMatchBlock(mat) * * Descrip: This function initates DnaMatchBlock matrix when in explicit mode * Called in /allocate_Expl_DnaMatchBlock * * * Arg: mat [UNKN ] DnaMatchBlock which contains explicit basematrix memory [DnaMatchBlock *] * */ void init_DnaMatchBlock(DnaMatchBlock * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->seq->len;i++) { for(j= (-1);j<2;j++) { DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } } for(j= (-1);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } DnaMatchBlock_EXPL_SPECIAL(mat,i,j,START) = 0; DnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_DnaMatchBlock(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by DnaMatchBlock * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * */ void recalculate_PackAln_DnaMatchBlock(PackAln * pal,DnaMatchBlock * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH65 : if( offi == 1 && offj == 1 && prev->state == MATCH65 ) { pau->score = (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH65 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH65 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH65, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case MATCH75 : if( offi == 1 && offj == 1 && prev->state == MATCH75 ) { pau->score = (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH75 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH75 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH75, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case MATCH85 : if( offi == 1 && offj == 1 && prev->state == MATCH85 ) { pau->score = (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH85 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH85 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH85, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case MATCH95 : if( offi == 1 && offj == 1 && prev->state == MATCH95 ) { pau->score = (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH95 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH95 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH95, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UNMATCHED_QUERY : if( offi == 1 && offj == 0 && prev->state == MATCH65 ) { pau->score = mat->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH75 ) { pau->score = mat->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH85 ) { pau->score = mat->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH95 ) { pau->score = mat->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == UNMATCHED_QUERY ) { pau->score = mat->u + (0); continue; } if( offj == 0 && prev->state == (START+6) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state UNMATCHED_QUERY, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UNMATCHED_TARGET : if( offi == 0 && offj == 1 && prev->state == UNMATCHED_QUERY ) { pau->score = mat->v + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = mat->u + (0); continue; } warn("In recaluclating PackAln with state UNMATCHED_TARGET, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+6) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+6) : if( offj == 0 && prev->state == UNMATCHED_TARGET ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define DnaMatchBlock_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*6+state]) #define DnaMatchBlock_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*6+state]) #define DnaMatchBlock_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define DnaMatchBlock_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define DnaMatchBlock_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*6 + state]) #define DnaMatchBlock_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define DnaMatchBlock_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 6) + ((i+1) * 6) + (state)]) #define DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 48) + ((i+1) * 48) + (state * 8) + shadow+1]) #define DnaMatchBlock_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_DnaMatchBlock(query,target,comp65,comp75,comp85,comp95,g,u,v,s,b) * * Descrip: This function allocates the DnaMatchBlock structure * and the basematrix area for a small memory implementations * It calls /allocate_DnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [DnaMatchBlock *] * */ #define DnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) DnaMatchBlock * allocate_Small_DnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b) { DnaMatchBlock * out; out = allocate_DnaMatchBlock_only(query, target , comp65, comp75, comp85, comp95, g, u, v, s, b); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 6,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix DnaMatchBlock cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_DnaMatchBlock(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_DnaMatchBlock(mat,dpenv) * * Descrip: This function calculates an alignment for DnaMatchBlock structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_DnaMatchBlock * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_DnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_DnaMatchBlock(DnaMatchBlock * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for DnaMatchBlock due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_DnaMatchBlock(mat,dpenv); score = start_end_find_end_DnaMatchBlock(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_DnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_DnaMatchBlock(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == DnaMatchBlock_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_DnaMatchBlock(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 6; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_DnaMatchBlock(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_DnaMatchBlock(mat) * * Descrip: This function calculates an alignment for DnaMatchBlock structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_DnaMatchBlock * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_DnaMatchBlock * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_DnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_DnaMatchBlock(DnaMatchBlock * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_DnaMatchBlock(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_DnaMatchBlock(mat); return out; } /* Function: AlnRangeSet_from_DnaMatchBlock(mat) * * Descrip: This function reads off a start/end structure * for DnaMatchBlock structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_DnaMatchBlock * If you have not calculated the matrix use * /AlnRange_calculate_Small_DnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_DnaMatchBlock(DnaMatchBlock * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_DnaMatchBlock"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_DnaMatchBlock(mat,&jpos); state = END; while( (temp = AlnRange_build_DnaMatchBlock(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_DnaMatchBlock(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_DnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_DnaMatchBlock(DnaMatchBlock * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_DnaMatchBlock"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_DnaMatchBlock(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_DnaMatchBlock alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = DnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_DnaMatchBlock(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == DnaMatchBlock_READ_OFF_ERROR) { warn("In AlnRange_build_DnaMatchBlock alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = DnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_DnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_DnaMatchBlock(DnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_DnaMatchBlock(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == DnaMatchBlock_READ_OFF_ERROR) { warn("In DnaMatchBlock hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In DnaMatchBlock hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In DnaMatchBlock hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_DnaMatchBlock(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_DnaMatchBlock(DnaMatchBlock * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = DnaMatchBlock_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In DnaMatchBlock matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH65 : temp = cscore - ((mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65); } temp = cscore - (mat->g) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH65) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH65); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH65); } temp = cscore - ((mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH65) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH65); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH65); } warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH75 : temp = cscore - ((mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH75) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH75); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH75); } temp = cscore - (mat->g) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH75) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH75); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH75); } temp = cscore - ((mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH75) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH75); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH75); } warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH85 : temp = cscore - ((mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH85) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH85); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH85); } temp = cscore - (mat->g) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH85) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH85); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH85); } temp = cscore - ((mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH85) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH85); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH85); } warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH95 : temp = cscore - ((mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH95) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH95); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH95); } temp = cscore - (mat->g) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH95) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH95); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH95); } temp = cscore - ((mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH95) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH95); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH95); } warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_QUERY : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->u) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,UNMATCHED_QUERY) ) { *reti = i - 1; *retj = j - 0; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,UNMATCHED_QUERY); } temp = cscore - (mat->b) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH95) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH95); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH95); } temp = cscore - (mat->b) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH85) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH85); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH85); } temp = cscore - (mat->b) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH75) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH75); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH75); } temp = cscore - (mat->b) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65); } warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_TARGET : temp = cscore - (mat->u) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_TARGET) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->v) - (0); if( temp == DnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_QUERY) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY); } return DnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_QUERY); } warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_DnaMatchBlock(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_DnaMatchBlock(DnaMatchBlock * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } max_special_strip_DnaMatchBlock(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == DnaMatchBlock_READ_OFF_ERROR) { warn("In special strip read DnaMatchBlock, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read DnaMatchBlock, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_DnaMatchBlock(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_DnaMatchBlock(DnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = DnaMatchBlock_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for DnaMatchBlock, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In DnaMatchBlock matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = DnaMatchBlock_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source UNMATCHED_TARGET is not a special */ default: warn("Major problem (!) - in DnaMatchBlock special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_DnaMatchBlock(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_DnaMatchBlock(DnaMatchBlock * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = DnaMatchBlock_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In DnaMatchBlock matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH65 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ warn("Major problem (!) - in DnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH75 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source MATCH75 is not a special, should not get here! */ /* Source MATCH75 is not a special, should not get here! */ /* Source MATCH75 is not a special, should not get here! */ warn("Major problem (!) - in DnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH85 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source MATCH85 is not a special, should not get here! */ /* Source MATCH85 is not a special, should not get here! */ /* Source MATCH85 is not a special, should not get here! */ warn("Major problem (!) - in DnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH95 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source MATCH95 is not a special, should not get here! */ /* Source MATCH95 is not a special, should not get here! */ /* Source MATCH95 is not a special, should not get here! */ warn("Major problem (!) - in DnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_QUERY : temp = cscore - (0) - (0); if( temp == DnaMatchBlock_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - DnaMatchBlock_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return DnaMatchBlock_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source UNMATCHED_QUERY is not a special, should not get here! */ /* Source MATCH95 is not a special, should not get here! */ /* Source MATCH85 is not a special, should not get here! */ /* Source MATCH75 is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ warn("Major problem (!) - in DnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_TARGET : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source UNMATCHED_QUERY is not a special, should not get here! */ warn("Major problem (!) - in DnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_DnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_DnaMatchBlock(DnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_DnaMatchBlock(mat,starti,startj,stopi,stopj); DnaMatchBlock_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH65) = NEGI; DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH75) = NEGI; DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH85) = NEGI; DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH95) = NEGI; DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH65 */ /* setting first movement to score */ score = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH75) = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH85) = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH95) = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; /* From state MATCH75 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = DnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = DnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished calculating state UNMATCHED_TARGET */ } } return; } /* Function: init_hidden_DnaMatchBlock(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_DnaMatchBlock(DnaMatchBlock * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH65) = NEGI; DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH75) = NEGI; DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH85) = NEGI; DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH95) = NEGI; DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; DnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } } return; } /* Function: full_dc_DnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_DnaMatchBlock * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_DnaMatchBlock to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [DnaMatchBlock *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_DnaMatchBlock(DnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_DnaMatchBlock"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_DnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_DnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_DnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for DnaMatchBlock, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_DnaMatchBlock(mat,DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_DnaMatchBlock(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_DnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_DnaMatchBlock(DnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_DnaMatchBlock(mat); DnaMatchBlock_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_DnaMatchBlock(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_DnaMatchBlock(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_DnaMatchBlock(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_DnaMatchBlock(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_DnaMatchBlock(DnaMatchBlock * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = (-100); DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = (-100); DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = (-100); DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = (-100); DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = (-100); DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = (-100); DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = (-100); DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = (-100); DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = (-100); DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = (-100); DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = (-100); DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH65, pushing when j - offj <= mergej */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = MATCH65; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH65,k); } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = MATCH65; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH65,k); } } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score) { score = temp; if( j - 0 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = MATCH65; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); } } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = UNMATCHED_TARGET; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = score; /* Finished with state MATCH65 */ /* For state MATCH75, pushing when j - offj <= mergej */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,2) = MATCH75; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,5) = MATCH75; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH75,k); } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = i-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,2) = MATCH75; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,5) = MATCH75; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH75,k); } } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score) { score = temp; if( j - 0 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = j-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,2) = MATCH75; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,5) = MATCH75; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,k); } } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,2) = UNMATCHED_TARGET; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,5) = MATCH75; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = score; /* Finished with state MATCH75 */ /* For state MATCH85, pushing when j - offj <= mergej */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,2) = MATCH85; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,5) = MATCH85; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH85,k); } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = i-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,2) = MATCH85; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,5) = MATCH85; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH85,k); } } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score) { score = temp; if( j - 0 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = j-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,2) = MATCH85; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,5) = MATCH85; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,k); } } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,2) = UNMATCHED_TARGET; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,5) = MATCH85; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = score; /* Finished with state MATCH85 */ /* For state MATCH95, pushing when j - offj <= mergej */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,2) = MATCH95; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,5) = MATCH95; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH95,k); } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = i-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,2) = MATCH95; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,5) = MATCH95; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH95,k); } } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score) { score = temp; if( j - 0 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = j-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,2) = MATCH95; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,5) = MATCH95; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,k); } } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,2) = UNMATCHED_TARGET; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,5) = MATCH95; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = score; /* Finished with state MATCH95 */ /* For state UNMATCHED_QUERY, pushing when j - offj <= mergej */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; if( j - 0 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH65; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score) { score = temp; if( j - 0 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH75; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,k); } } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score) { score = temp; if( j - 0 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH85; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,k); } } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score) { score = temp; if( j - 0 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH95; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,k); } } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score) { score = temp; if( j - 0 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = UNMATCHED_QUERY; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED_QUERY,k); } } /* Add any movement independant score */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished with state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET, pushing when j - offj <= mergej */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = i-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,2) = UNMATCHED_QUERY; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,5) = UNMATCHED_TARGET; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_QUERY,k); } temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = i-0; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,1) = j-1; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,2) = UNMATCHED_TARGET; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,3) = i; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,4) = j; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,5) = UNMATCHED_TARGET; } else { for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished with state UNMATCHED_TARGET */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_DnaMatchBlock(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_DnaMatchBlock(DnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH65 */ /* setting first movement to score */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH65,k); /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH65,k); } /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = score; for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH75,k); /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH75,k); } /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,k); } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = score; for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH85,k); /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH85,k); } /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,k); } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = score; for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH95,k); /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH95,k); } /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,k); } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = score; for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); /* From state MATCH75 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,k); } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,k); } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,k); } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED_QUERY,k); } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_QUERY,k); /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; for(k=0;k<7;k++) DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED_TARGET */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_DnaMatchBlock(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_DnaMatchBlock(DnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH65 */ /* setting first movement to score */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; /* From state MATCH75 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = DnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished calculating state UNMATCHED_TARGET */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_DnaMatchBlock(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * */ } void init_dc_DnaMatchBlock(DnaMatchBlock * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; for(k=0;k<7;k++) { DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = (-1); DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = (-1); DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = (-1); DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = (-1); DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = (-1); DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = (-1); } } } return; } /* Function: start_end_find_end_DnaMatchBlock(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [DnaMatchBlock *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_DnaMatchBlock(DnaMatchBlock * mat,int * endj) { register int j; register int max; register int maxj; max = DnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( DnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = DnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_DnaMatchBlock(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [DnaMatchBlock] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_DnaMatchBlock(DnaMatchBlock *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->seq->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 6,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 6 * 8,sizeof(int)); for(j=0;jcomp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH65,0)); /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH65,0)); } /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,0)); } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH65) = score; for(k=0;k<7;k++) DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH75,0)); /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH75) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH75,0)); } /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,0)); } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH75) = score; for(k=0;k<7;k++) DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH85,0)); /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH85) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH85,0)); } /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,0)); } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH85) = score; for(k=0;k<7;k++) DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH95,0)); /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH95) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH95,0)); } /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,0)); } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH95) = score; for(k=0;k<7;k++) DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->b + (0); /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,0)); /* From state MATCH75 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->b +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,0)); } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->b +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,0)); } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->b +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,0)); } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED_QUERY,0)); } /* From state START to state UNMATCHED_QUERY */ temp = DnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + 0 + (0); if( temp > score ) { score = temp; /* This state [START] is a special for UNMATCHED_QUERY... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= UNMATCHED_QUERY; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; for(k=0;k<7;k++) DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v + (0); /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_QUERY,0)); /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ DnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; for(k=0;k<7;k++) DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state UNMATCHED_TARGET is a source for special END */ temp = score + (0) + (0) ; if( temp > DnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { DnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) DnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k); DnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = DnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,6); DnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; DnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; DnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = UNMATCHED_TARGET; } /* Finished calculating state UNMATCHED_TARGET */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_DnaMatchBlock(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * */ void init_start_end_linear_DnaMatchBlock(DnaMatchBlock * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = (-1); DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = (-1); DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = (-1); DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = (-1); DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = (-1); DnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; DnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = (-1); } } for(j=(-1);jtarget->seq->len;j++) { DnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; DnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; DnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_DnaMatchBlock(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_DnaMatchBlock(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_DnaMatchBlock(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MM65","MI65","MM75","MI75","MM85","MI85","MM95","MI95","UM","UI","END" }; /* Function: AlnConvertSet_DnaMatchBlock(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "MM65","MI65","MM75","MI75","MM85","MI85","MM95","MI95","UI","UM","END" }; AlnConvertSet * AlnConvertSet_DnaMatchBlock(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = MATCH65; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = MATCH65; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = MATCH65; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH65; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH75; acu->state2 = MATCH75; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH75; acu->state2 = MATCH75; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH75; acu->state2 = MATCH75; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH75; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH85; acu->state2 = MATCH85; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH85; acu->state2 = MATCH85; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH85; acu->state2 = MATCH85; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[5]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH85; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH95; acu->state2 = MATCH95; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH95; acu->state2 = MATCH95; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH95; acu->state2 = MATCH95; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[7]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH95; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH75; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH85; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH95; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_QUERY; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = UNMATCHED_QUERY; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_QUERY; acu->state2 = UNMATCHED_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[9]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = UNMATCHED_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[9]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[10]; return out; } /* Function: PackAln_read_Expl_DnaMatchBlock(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_DnaMatchBlock(DnaMatchBlock * mat) { DnaMatchBlock_access_func_holder holder; holder.access_main = DnaMatchBlock_explicit_access_main; holder.access_special = DnaMatchBlock_explicit_access_special; return PackAln_read_generic_DnaMatchBlock(mat,holder); } /* Function: DnaMatchBlock_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int DnaMatchBlock_explicit_access_main(DnaMatchBlock * mat,int i,int j,int state) { return DnaMatchBlock_EXPL_MATRIX(mat,i,j,state); } /* Function: DnaMatchBlock_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int DnaMatchBlock_explicit_access_special(DnaMatchBlock * mat,int i,int j,int state) { return DnaMatchBlock_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_DnaMatchBlock(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: h [UNKN ] Undocumented argument [DnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_DnaMatchBlock(DnaMatchBlock * mat,DnaMatchBlock_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_DnaMatchBlock(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in DnaMatchBlock_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_DnaMatchBlock(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_DnaMatchBlock(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == DnaMatchBlock_READ_OFF_ERROR || j == DnaMatchBlock_READ_OFF_ERROR || state == DnaMatchBlock_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in DnaMatchBlock_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_DnaMatchBlock(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [DnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_DnaMatchBlock(DnaMatchBlock * mat,int * ri,int * rj,int * state,boolean * isspecial,DnaMatchBlock_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: DnaMatchBlock_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void DnaMatchBlock_debug_show_matrix(DnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->seq->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH65 %d\n",DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65)); fprintf(ofp,"State MATCH75 %d\n",DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75)); fprintf(ofp,"State MATCH85 %d\n",DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85)); fprintf(ofp,"State MATCH95 %d\n",DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95)); fprintf(ofp,"State UNMATCHED_QUERY %d\n",DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY)); fprintf(ofp,"State UNMATCHED_TARGET %d\n",DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_DnaMatchBlock(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [DnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_DnaMatchBlock(DnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,DnaMatchBlock_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = DnaMatchBlock_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In DnaMatchBlock matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH65 : temp = cscore - ((mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH65); } return (*h.access_main)(mat,i - 1,j - 0,MATCH65); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH65) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH65); } return (*h.access_main)(mat,i - 0,j - 1,MATCH65); } temp = cscore - ((mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH65) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH65); } return (*h.access_main)(mat,i - 1,j - 1,MATCH65); } warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH75 : temp = cscore - ((mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH75) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH75); } return (*h.access_main)(mat,i - 1,j - 0,MATCH75); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH75) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH75); } return (*h.access_main)(mat,i - 0,j - 1,MATCH75); } temp = cscore - ((mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH75) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH75); } return (*h.access_main)(mat,i - 1,j - 1,MATCH75); } warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH85 : temp = cscore - ((mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH85) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH85); } return (*h.access_main)(mat,i - 1,j - 0,MATCH85); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH85) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH85); } return (*h.access_main)(mat,i - 0,j - 1,MATCH85); } temp = cscore - ((mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH85) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH85); } return (*h.access_main)(mat,i - 1,j - 1,MATCH85); } warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH95 : temp = cscore - ((mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH95) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH95); } return (*h.access_main)(mat,i - 1,j - 0,MATCH95); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH95) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH95); } return (*h.access_main)(mat,i - 0,j - 1,MATCH95); } temp = cscore - ((mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH95) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH95); } return (*h.access_main)(mat,i - 1,j - 1,MATCH95); } warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_QUERY : /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } } temp = cscore - (mat->u) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,UNMATCHED_QUERY) ) { *reti = i - 1; *retj = j - 0; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,UNMATCHED_QUERY); } return (*h.access_main)(mat,i - 1,j - 0,UNMATCHED_QUERY); } temp = cscore - (mat->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH95) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH95); } return (*h.access_main)(mat,i - 1,j - 0,MATCH95); } temp = cscore - (mat->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH85) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH85); } return (*h.access_main)(mat,i - 1,j - 0,MATCH85); } temp = cscore - (mat->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH75) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH75); } return (*h.access_main)(mat,i - 1,j - 0,MATCH75); } temp = cscore - (mat->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH65); } return (*h.access_main)(mat,i - 1,j - 0,MATCH65); } warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_TARGET : temp = cscore - (mat->u) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_TARGET) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->v) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_QUERY) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UNMATCHED_QUERY); } return (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_QUERY); } warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_DnaMatchBlock(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [DnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_DnaMatchBlock(DnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,DnaMatchBlock_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = DnaMatchBlock_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In DnaMatchBlock matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source UNMATCHED_TARGET is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,UNMATCHED_TARGET) ) { *reti = i - 0; *retj = j - 0; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 0,j - 0,UNMATCHED_TARGET) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in DnaMatchBlock read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_DnaMatchBlock(mat) * * Descrip: This function calculates the DnaMatchBlock matrix when in explicit mode * To allocate the matrix use /allocate_Expl_DnaMatchBlock * * * Arg: mat [UNKN ] DnaMatchBlock which contains explicit basematrix memory [DnaMatchBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_DnaMatchBlock(DnaMatchBlock * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_DnaMatchBlock, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("DnaMatchBlock Matrix calculation: "); for(j=0;jcomp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; /* From state MATCH75 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state UNMATCHED_QUERY */ temp = DnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-0,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = DnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* state UNMATCHED_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > DnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { DnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state UNMATCHED_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_DnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the DnaMatchBlock matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] DnaMatchBlock which contains explicit basematrix memory [DnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_DnaMatchBlock(DnaMatchBlock * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_DnaMatchBlock, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } } for(j=-1;jlenj;j++) { DnaMatchBlock_EXPL_SPECIAL(mat,i,j,START) = 0; DnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("DnaMatchBlock Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH65 */ /* setting first movement to score */ score = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ DnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; /* From state MATCH75 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state UNMATCHED_QUERY */ temp = DnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-0,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = DnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = DnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ DnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* state UNMATCHED_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > DnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { DnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state UNMATCHED_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: DnaMatchBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaMatchBlock *] * */ DnaMatchBlock * DnaMatchBlock_alloc(void) { DnaMatchBlock * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaMatchBlock *) ckalloc (sizeof(DnaMatchBlock))) == NULL) { warn("DnaMatchBlock_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_DnaMatchBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaMatchBlock *] * * Return [UNKN ] Undocumented return value [DnaMatchBlock *] * */ DnaMatchBlock * free_DnaMatchBlock(DnaMatchBlock * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaMatchBlock obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->comp65 is linked in */ /* obj->comp75 is linked in */ /* obj->comp85 is linked in */ /* obj->comp95 is linked in */ /* obj->g is linked in */ /* obj->u is linked in */ /* obj->v is linked in */ /* obj->s is linked in */ /* obj->b is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/dba.h0000644000175000001440000005331510670453713015037 0ustar philippusers#ifndef DYNAMITEdbaHEADERFILE #define DYNAMITEdbaHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" struct Wise2_DnaMatchBlock { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; ComplexSequence* query; ComplexSequence* target; DnaMatrix* comp65; DnaMatrix* comp75; DnaMatrix* comp85; DnaMatrix* comp95; Score g; Score u; Score v; Score s; Score b; } ; /* DnaMatchBlock defined */ #ifndef DYNAMITE_DEFINED_DnaMatchBlock typedef struct Wise2_DnaMatchBlock Wise2_DnaMatchBlock; #define DnaMatchBlock Wise2_DnaMatchBlock #define DYNAMITE_DEFINED_DnaMatchBlock #endif struct Wise2_DnaMatchBlock_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(DnaMatchBlock*,int,int,int); int (*access_special)(DnaMatchBlock*,int,int,int); } ; /* DnaMatchBlock_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_DnaMatchBlock_access_func_holder typedef struct Wise2_DnaMatchBlock_access_func_holder Wise2_DnaMatchBlock_access_func_holder; #define DnaMatchBlock_access_func_holder Wise2_DnaMatchBlock_access_func_holder #define DYNAMITE_DEFINED_DnaMatchBlock_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_DnaMatchBlock(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_DnaMatchBlock(DnaMatchBlock * mat); #define PackAln_read_Shatter_DnaMatchBlock Wise2_PackAln_read_Shatter_DnaMatchBlock /* Function: calculate_shatter_DnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the DnaMatchBlock matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [DnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_DnaMatchBlock(DnaMatchBlock * mat,DPEnvelope * dpenv); #define calculate_shatter_DnaMatchBlock Wise2_calculate_shatter_DnaMatchBlock /* Function: search_DnaMatchBlock(dbsi,out,query,target,comp65,comp75,comp85,comp95,g,u,v,s,b) * * Descrip: This function makes a database search of DnaMatchBlock * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp65 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp75 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp85 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp95 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: g [UNKN ] Undocumented argument [Score] * Arg: u [UNKN ] Undocumented argument [Score] * Arg: v [UNKN ] Undocumented argument [Score] * Arg: s [UNKN ] Undocumented argument [Score] * Arg: b [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_DnaMatchBlock(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b); #define search_DnaMatchBlock Wise2_search_DnaMatchBlock /* Function: serial_search_DnaMatchBlock(out,query,target,comp65,comp75,comp85,comp95,g,u,v,s,b) * * Descrip: This function makes a database search of DnaMatchBlock * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp65 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp75 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp85 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp95 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: g [UNKN ] Undocumented argument [Score] * Arg: u [UNKN ] Undocumented argument [Score] * Arg: v [UNKN ] Undocumented argument [Score] * Arg: s [UNKN ] Undocumented argument [Score] * Arg: b [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_DnaMatchBlock(Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b); #define serial_search_DnaMatchBlock Wise2_serial_search_DnaMatchBlock /* Function: PackAln_bestmemory_DnaMatchBlock(query,target,comp65,comp75,comp85,comp95,g,u,v,s,b,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_DnaMatchBlock * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_DnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_DnaMatchBlock Wise2_PackAln_bestmemory_DnaMatchBlock /* Function: allocate_Expl_DnaMatchBlock(query,target,comp65,comp75,comp85,comp95,g,u,v,s,b,dpri) * * Descrip: This function allocates the DnaMatchBlock structure * and the basematrix area for explicit memory implementations * It calls /allocate_DnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [DnaMatchBlock *] * */ DnaMatchBlock * Wise2_allocate_Expl_DnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b,DPRunImpl * dpri); #define allocate_Expl_DnaMatchBlock Wise2_allocate_Expl_DnaMatchBlock /* Function: recalculate_PackAln_DnaMatchBlock(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by DnaMatchBlock * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * */ void Wise2_recalculate_PackAln_DnaMatchBlock(PackAln * pal,DnaMatchBlock * mat); #define recalculate_PackAln_DnaMatchBlock Wise2_recalculate_PackAln_DnaMatchBlock /* Function: allocate_Small_DnaMatchBlock(query,target,comp65,comp75,comp85,comp95,g,u,v,s,b) * * Descrip: This function allocates the DnaMatchBlock structure * and the basematrix area for a small memory implementations * It calls /allocate_DnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [DnaMatchBlock *] * */ DnaMatchBlock * Wise2_allocate_Small_DnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b); #define allocate_Small_DnaMatchBlock Wise2_allocate_Small_DnaMatchBlock /* Function: PackAln_calculate_Small_DnaMatchBlock(mat,dpenv) * * Descrip: This function calculates an alignment for DnaMatchBlock structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_DnaMatchBlock * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_DnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_DnaMatchBlock(DnaMatchBlock * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_DnaMatchBlock Wise2_PackAln_calculate_Small_DnaMatchBlock /* Function: AlnRangeSet_calculate_Small_DnaMatchBlock(mat) * * Descrip: This function calculates an alignment for DnaMatchBlock structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_DnaMatchBlock * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_DnaMatchBlock * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_DnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_DnaMatchBlock(DnaMatchBlock * mat); #define AlnRangeSet_calculate_Small_DnaMatchBlock Wise2_AlnRangeSet_calculate_Small_DnaMatchBlock /* Function: AlnRangeSet_from_DnaMatchBlock(mat) * * Descrip: This function reads off a start/end structure * for DnaMatchBlock structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_DnaMatchBlock * If you have not calculated the matrix use * /AlnRange_calculate_Small_DnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_DnaMatchBlock(DnaMatchBlock * mat); #define AlnRangeSet_from_DnaMatchBlock Wise2_AlnRangeSet_from_DnaMatchBlock /* Function: convert_PackAln_to_AlnBlock_DnaMatchBlock(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_DnaMatchBlock(PackAln * pal); #define convert_PackAln_to_AlnBlock_DnaMatchBlock Wise2_convert_PackAln_to_AlnBlock_DnaMatchBlock /* Function: PackAln_read_Expl_DnaMatchBlock(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_DnaMatchBlock(DnaMatchBlock * mat); #define PackAln_read_Expl_DnaMatchBlock Wise2_PackAln_read_Expl_DnaMatchBlock /* Function: PackAln_read_generic_DnaMatchBlock(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaMatchBlock *] * Arg: h [UNKN ] Undocumented argument [DnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_DnaMatchBlock(DnaMatchBlock * mat,DnaMatchBlock_access_func_holder h); #define PackAln_read_generic_DnaMatchBlock Wise2_PackAln_read_generic_DnaMatchBlock /* Function: calculate_DnaMatchBlock(mat) * * Descrip: This function calculates the DnaMatchBlock matrix when in explicit mode * To allocate the matrix use /allocate_Expl_DnaMatchBlock * * * Arg: mat [UNKN ] DnaMatchBlock which contains explicit basematrix memory [DnaMatchBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_DnaMatchBlock(DnaMatchBlock * mat); #define calculate_DnaMatchBlock Wise2_calculate_DnaMatchBlock /* Function: calculate_dpenv_DnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the DnaMatchBlock matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] DnaMatchBlock which contains explicit basematrix memory [DnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_DnaMatchBlock(DnaMatchBlock * mat,DPEnvelope * dpenv); #define calculate_dpenv_DnaMatchBlock Wise2_calculate_dpenv_DnaMatchBlock /* Function: DnaMatchBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaMatchBlock *] * */ DnaMatchBlock * Wise2_DnaMatchBlock_alloc(void); #define DnaMatchBlock_alloc Wise2_DnaMatchBlock_alloc /* Function: free_DnaMatchBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaMatchBlock *] * * Return [UNKN ] Undocumented return value [DnaMatchBlock *] * */ DnaMatchBlock * Wise2_free_DnaMatchBlock(DnaMatchBlock * obj); #define free_DnaMatchBlock Wise2_free_DnaMatchBlock /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_DnaMatchBlock_shatter_access_main(DnaMatchBlock * mat,int i,int j,int state); #define DnaMatchBlock_shatter_access_main Wise2_DnaMatchBlock_shatter_access_main int Wise2_DnaMatchBlock_shatter_access_special(DnaMatchBlock * mat,int i,int j,int state); #define DnaMatchBlock_shatter_access_special Wise2_DnaMatchBlock_shatter_access_special int Wise2_score_only_DnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b); #define score_only_DnaMatchBlock Wise2_score_only_DnaMatchBlock DnaMatchBlock * Wise2_allocate_DnaMatchBlock_only(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score u,Score v,Score s,Score b); #define allocate_DnaMatchBlock_only Wise2_allocate_DnaMatchBlock_only void Wise2_init_DnaMatchBlock(DnaMatchBlock * mat); #define init_DnaMatchBlock Wise2_init_DnaMatchBlock AlnRange * Wise2_AlnRange_build_DnaMatchBlock(DnaMatchBlock * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_DnaMatchBlock Wise2_AlnRange_build_DnaMatchBlock boolean Wise2_read_hidden_DnaMatchBlock(DnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_DnaMatchBlock Wise2_read_hidden_DnaMatchBlock int Wise2_max_hidden_DnaMatchBlock(DnaMatchBlock * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_DnaMatchBlock Wise2_max_hidden_DnaMatchBlock boolean Wise2_read_special_strip_DnaMatchBlock(DnaMatchBlock * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_DnaMatchBlock Wise2_read_special_strip_DnaMatchBlock int Wise2_max_special_strip_DnaMatchBlock(DnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_DnaMatchBlock Wise2_max_special_strip_DnaMatchBlock int Wise2_max_matrix_to_special_DnaMatchBlock(DnaMatchBlock * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_DnaMatchBlock Wise2_max_matrix_to_special_DnaMatchBlock void Wise2_calculate_hidden_DnaMatchBlock(DnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_DnaMatchBlock Wise2_calculate_hidden_DnaMatchBlock void Wise2_init_hidden_DnaMatchBlock(DnaMatchBlock * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_DnaMatchBlock Wise2_init_hidden_DnaMatchBlock boolean Wise2_full_dc_DnaMatchBlock(DnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_DnaMatchBlock Wise2_full_dc_DnaMatchBlock boolean Wise2_do_dc_single_pass_DnaMatchBlock(DnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_DnaMatchBlock Wise2_do_dc_single_pass_DnaMatchBlock void Wise2_push_dc_at_merge_DnaMatchBlock(DnaMatchBlock * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_DnaMatchBlock Wise2_push_dc_at_merge_DnaMatchBlock void Wise2_follow_on_dc_DnaMatchBlock(DnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_DnaMatchBlock Wise2_follow_on_dc_DnaMatchBlock void Wise2_run_up_dc_DnaMatchBlock(DnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_DnaMatchBlock Wise2_run_up_dc_DnaMatchBlock void Wise2_init_dc_DnaMatchBlock(DnaMatchBlock * mat); #define init_dc_DnaMatchBlock Wise2_init_dc_DnaMatchBlock int Wise2_start_end_find_end_DnaMatchBlock(DnaMatchBlock * mat,int * endj); #define start_end_find_end_DnaMatchBlock Wise2_start_end_find_end_DnaMatchBlock boolean Wise2_dc_optimised_start_end_calc_DnaMatchBlock(DnaMatchBlock *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_DnaMatchBlock Wise2_dc_optimised_start_end_calc_DnaMatchBlock void Wise2_init_start_end_linear_DnaMatchBlock(DnaMatchBlock * mat); #define init_start_end_linear_DnaMatchBlock Wise2_init_start_end_linear_DnaMatchBlock AlnConvertSet * Wise2_AlnConvertSet_DnaMatchBlock(void); #define AlnConvertSet_DnaMatchBlock Wise2_AlnConvertSet_DnaMatchBlock int Wise2_DnaMatchBlock_explicit_access_main(DnaMatchBlock * mat,int i,int j,int state); #define DnaMatchBlock_explicit_access_main Wise2_DnaMatchBlock_explicit_access_main int Wise2_DnaMatchBlock_explicit_access_special(DnaMatchBlock * mat,int i,int j,int state); #define DnaMatchBlock_explicit_access_special Wise2_DnaMatchBlock_explicit_access_special int Wise2_find_end_DnaMatchBlock(DnaMatchBlock * mat,int * ri,int * rj,int * state,boolean * isspecial,DnaMatchBlock_access_func_holder h); #define find_end_DnaMatchBlock Wise2_find_end_DnaMatchBlock void Wise2_DnaMatchBlock_debug_show_matrix(DnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define DnaMatchBlock_debug_show_matrix Wise2_DnaMatchBlock_debug_show_matrix int Wise2_max_calc_DnaMatchBlock(DnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,DnaMatchBlock_access_func_holder h); #define max_calc_DnaMatchBlock Wise2_max_calc_DnaMatchBlock int Wise2_max_calc_special_DnaMatchBlock(DnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,DnaMatchBlock_access_func_holder h); #define max_calc_special_DnaMatchBlock Wise2_max_calc_special_DnaMatchBlock #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/matchsum.pod0000644000175000001440000002605410670453714016466 0ustar philippusers=head1 NAME matchsum module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item MatchSummarySet =item MatchSummary =back =head1 DESCRIPTION =head2 Object MatchSummarySet =over =item ms Type [MatchSummary **] List No documentation =back This holds a set of MatchSummaries, =head2 Member functions of MatchSummarySet =over =item MatchSummarySet_from_AlnBlock_estwise &Wise2::MatchSummarySet::MatchSummarySet_from_AlnBlock_estwise(alb,qname,offset,target) Builds a MatchSummarySet from a EstWise alignment. this makes alot of assumptions about the labels setc in alb, so make sure it was a estwise alignment - however as you can notice this is exactly the same labels as found in genewise set Argument alb [UNKN ] Undocumented argument [AlnBlock *] Argument qname [UNKN ] Undocumented argument [char *] Argument offset [UNKN ] Undocumented argument [int] Argument target [UNKN ] Undocumented argument [Sequence *] Return [UNKN ] Undocumented return value [MatchSummarySet *] =item MatchSummarySet_from_AlnBlock_genewise &Wise2::MatchSummarySet::MatchSummarySet_from_AlnBlock_genewise(alb,qname,protoff,target) Builds a MatchSummarySet from a GeneWise alignment. this makes alot of assumptions about the labels setc in alb, so make sure it was a genewise alignment Argument alb [UNKN ] Undocumented argument [AlnBlock *] Argument qname [UNKN ] Undocumented argument [char *] Argument protoff [UNKN ] Undocumented argument [int] Argument target [UNKN ] Undocumented argument [Sequence *] Return [UNKN ] Undocumented return value [MatchSummarySet *] =item hard_link_MatchSummarySet &Wise2::MatchSummarySet::hard_link_MatchSummarySet(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [MatchSummarySet *] Return [UNKN ] Undocumented return value [MatchSummarySet *] =item MatchSummarySet_alloc_std &Wise2::MatchSummarySet::MatchSummarySet_alloc_std(void) Equivalent to MatchSummarySet_alloc_len(MatchSummarySetLISTLENGTH) Return [UNKN ] Undocumented return value [MatchSummarySet *] =item ms &Wise2::MatchSummarySet::ms(obj,i) Access members stored in the ms list For use principly by API functions Argument obj [UNKN ] Object holding the list [MatchSummarySet *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [MatchSummary *] =item length_ms &Wise2::MatchSummarySet::length_ms(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [MatchSummarySet *] Return [UNKN ] length of the list [int] =item flush_ms &Wise2::MatchSummarySet::flush_ms(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [MatchSummarySet *] Return [UNKN ] Undocumented return value [int] =item add_ms &Wise2::MatchSummarySet::add_ms(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [MatchSummarySet *] Argument add [OWNER] Object to add to the list [MatchSummary *] Return [UNKN ] Undocumented return value [boolean] =back =head2 Object MatchSummary =over =item bits Type [double] Scalar No documentation =item qname Type [char *] Scalar No documentation =item tname Type [char *] Scalar No documentation =item qstart Type [int] Scalar No documentation =item qend Type [int] Scalar No documentation =item tstart Type [int] Scalar No documentation =item tend Type [int] Scalar No documentation =item qintron Type [int] Scalar No documentation =item qframeshift Type [int] Scalar No documentation =item tintron Type [int] Scalar No documentation =item tframeshift Type [int] Scalar No documentation =back A Match Summary has summary statistics for a single alignment, with the two start/end ranges and the number of introns and frameshifts for each sequence (obviously, if one is a protein then neither are valid!) =head2 Member functions of MatchSummary =over =item hard_link_MatchSummary &Wise2::MatchSummary::hard_link_MatchSummary(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [MatchSummary *] Return [UNKN ] Undocumented return value [MatchSummary *] =item alloc &Wise2::MatchSummary::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [MatchSummary *] =item set_bits &Wise2::MatchSummary::set_bits(obj,bits) Replace member variable bits For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Argument bits [OWNER] New value of the variable [double] Return [SOFT ] member variable bits [boolean] =item bits &Wise2::MatchSummary::bits(obj) Access member variable bits For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Return [SOFT ] member variable bits [double] =item set_qname &Wise2::MatchSummary::set_qname(obj,qname) Replace member variable qname For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Argument qname [OWNER] New value of the variable [char *] Return [SOFT ] member variable qname [boolean] =item qname &Wise2::MatchSummary::qname(obj) Access member variable qname For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Return [SOFT ] member variable qname [char *] =item set_tname &Wise2::MatchSummary::set_tname(obj,tname) Replace member variable tname For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Argument tname [OWNER] New value of the variable [char *] Return [SOFT ] member variable tname [boolean] =item tname &Wise2::MatchSummary::tname(obj) Access member variable tname For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Return [SOFT ] member variable tname [char *] =item set_qstart &Wise2::MatchSummary::set_qstart(obj,qstart) Replace member variable qstart For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Argument qstart [OWNER] New value of the variable [int] Return [SOFT ] member variable qstart [boolean] =item qstart &Wise2::MatchSummary::qstart(obj) Access member variable qstart For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Return [SOFT ] member variable qstart [int] =item set_qend &Wise2::MatchSummary::set_qend(obj,qend) Replace member variable qend For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Argument qend [OWNER] New value of the variable [int] Return [SOFT ] member variable qend [boolean] =item qend &Wise2::MatchSummary::qend(obj) Access member variable qend For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Return [SOFT ] member variable qend [int] =item set_tstart &Wise2::MatchSummary::set_tstart(obj,tstart) Replace member variable tstart For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Argument tstart [OWNER] New value of the variable [int] Return [SOFT ] member variable tstart [boolean] =item tstart &Wise2::MatchSummary::tstart(obj) Access member variable tstart For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Return [SOFT ] member variable tstart [int] =item set_tend &Wise2::MatchSummary::set_tend(obj,tend) Replace member variable tend For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Argument tend [OWNER] New value of the variable [int] Return [SOFT ] member variable tend [boolean] =item tend &Wise2::MatchSummary::tend(obj) Access member variable tend For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Return [SOFT ] member variable tend [int] =item set_qintron &Wise2::MatchSummary::set_qintron(obj,qintron) Replace member variable qintron For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Argument qintron [OWNER] New value of the variable [int] Return [SOFT ] member variable qintron [boolean] =item qintron &Wise2::MatchSummary::qintron(obj) Access member variable qintron For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Return [SOFT ] member variable qintron [int] =item set_qframeshift &Wise2::MatchSummary::set_qframeshift(obj,qframeshift) Replace member variable qframeshift For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Argument qframeshift [OWNER] New value of the variable [int] Return [SOFT ] member variable qframeshift [boolean] =item qframeshift &Wise2::MatchSummary::qframeshift(obj) Access member variable qframeshift For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Return [SOFT ] member variable qframeshift [int] =item set_tintron &Wise2::MatchSummary::set_tintron(obj,tintron) Replace member variable tintron For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Argument tintron [OWNER] New value of the variable [int] Return [SOFT ] member variable tintron [boolean] =item tintron &Wise2::MatchSummary::tintron(obj) Access member variable tintron For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Return [SOFT ] member variable tintron [int] =item set_tframeshift &Wise2::MatchSummary::set_tframeshift(obj,tframeshift) Replace member variable tframeshift For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Argument tframeshift [OWNER] New value of the variable [int] Return [SOFT ] member variable tframeshift [boolean] =item tframeshift &Wise2::MatchSummary::tframeshift(obj) Access member variable tframeshift For use principly by API functions Argument obj [UNKN ] Object holding the variable [MatchSummary *] Return [SOFT ] member variable tframeshift [int] =back wise-2.4.1/src/models/matchsum.tex0000644000175000001440000000657610670453714016513 0ustar philippusers\section{matchsum} \label{module_matchsum} This module contains the following objects \begin{itemize} \item \ref{object_MatchSummarySet} MatchSummarySet \item \ref{object_MatchSummary} MatchSummary \end{itemize} \subsection{Object MatchSummarySet} \label{object_MatchSummarySet} The MatchSummarySet object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{ms} Type [MatchSummary ** : List] No documentation \end{description} This holds a set of MatchSummaries, Member functions of MatchSummarySet \subsubsection{MatchSummarySet_from_AlnBlock_estwise} \begin{description} \item[External C] {\tt Wise2_MatchSummarySet_from_AlnBlock_estwise (alb,qname,offset,target)} \item[Perl] {\tt &Wise2::MatchSummarySet::MatchSummarySet_from_AlnBlock_estwise (alb,qname,offset,target)} \item[Perl-OOP call] {\tt $obj->MatchSummarySet_from_AlnBlock_estwise(qname,offset,target)} \end{description} Arguments \begin{description} \item[alb] [UNKN ] Undocumented argument [AlnBlock *] \item[qname] [UNKN ] Undocumented argument [char *] \item[offset] [UNKN ] Undocumented argument [int] \item[target] [UNKN ] Undocumented argument [Sequence *] \item[returns] [UNKN ] Undocumented return value [MatchSummarySet *] \end{description} Builds a MatchSummarySet from a EstWise alignment. this makes alot of assumptions about the labels setc in alb, so make sure it was a estwise alignment - however as you can notice this is exactly the same labels as found in genewise set \subsubsection{MatchSummarySet_from_AlnBlock_genewise} \begin{description} \item[External C] {\tt Wise2_MatchSummarySet_from_AlnBlock_genewise (alb,qname,protoff,target)} \item[Perl] {\tt &Wise2::MatchSummarySet::MatchSummarySet_from_AlnBlock_genewise (alb,qname,protoff,target)} \item[Perl-OOP call] {\tt $obj->MatchSummarySet_from_AlnBlock_genewise(qname,protoff,target)} \end{description} Arguments \begin{description} \item[alb] [UNKN ] Undocumented argument [AlnBlock *] \item[qname] [UNKN ] Undocumented argument [char *] \item[protoff] [UNKN ] Undocumented argument [int] \item[target] [UNKN ] Undocumented argument [Sequence *] \item[returns] [UNKN ] Undocumented return value [MatchSummarySet *] \end{description} Builds a MatchSummarySet from a GeneWise alignment. this makes alot of assumptions about the labels setc in alb, so make sure it was a genewise alignment \subsection{Object MatchSummary} \label{object_MatchSummary} The MatchSummary object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{bits} Type [double : Scalar] No documentation \item{qname} Type [char * : Scalar] No documentation \item{tname} Type [char * : Scalar] No documentation \item{qstart} Type [int : Scalar] No documentation \item{qend} Type [int : Scalar] No documentation \item{tstart} Type [int : Scalar] No documentation \item{tend} Type [int : Scalar] No documentation \item{qintron} Type [int : Scalar] No documentation \item{qframeshift} Type [int : Scalar] No documentation \item{tintron} Type [int : Scalar] No documentation \item{tframeshift} Type [int : Scalar] No documentation \end{description} A Match Summary has summary statistics for a single alignment, with the two start/end ranges and the number of introns and frameshifts for each sequence (obviously, if one is a protein then neither are valid!) Member functions of MatchSummary wise-2.4.1/src/models/genestats.c0000644000175000001440000011355310670453714016303 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genestats.h" /* Function: show_help_GeneModelParam(ofp) * * Descrip: Shows help * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 97 "genestats.dy" void show_help_GeneModelParam(FILE * ofp) { fprintf(ofp,"New gene model statistics\n"); fprintf(ofp," -splice_max_collar [5.0] maximum Bits value for a splice site \n"); fprintf(ofp," -splice_min_collar [-5.0] minimum Bits value for a splice site \n"); fprintf(ofp," -splice_score_offset [%.1f] score offset for splice sites\n",DEFAULT_SPLICE_OFFSET_SCORE); fprintf(ofp," -[no]splice_gtag make just gtag splice sites (default is gtag, ie no model)\n"); fprintf(ofp," -splice_gtag_prob [0.001] probability for gt/ag \n"); fprintf(ofp," -genestats [gene.stat]\n"); } /* Function: show_info_GeneModelParam(p,ofp) * * Descrip: Shows genemodel param for info * * * Arg: p [UNKN ] Undocumented argument [GeneModelParam *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 113 "genestats.dy" void show_info_GeneModelParam(GeneModelParam * p,FILE * ofp) { fprintf(ofp,"Gene Parameter file: %s\n",p->gene_stats_file); fprintf(ofp,"Splice site model: %s\n",p->use_gtag_splice == TRUE ? "GT/AG only" : "Position Weight Matrix"); if( p->use_gtag_splice == FALSE ) { fprintf(ofp,"Pseudo counts 5'SS %1.2f\n",p->splice5_pseudo); fprintf(ofp,"Pseudo counts 3'SS %1.2f\n",p->splice3_pseudo); fprintf(ofp,"Minimum SS collar %2.2f\n",p->min_collar); fprintf(ofp,"Maximum SS collar %2.2f\n",p->max_collar); fprintf(ofp,"Splice site offset %2.2f\n",p->score_offset); } else { fprintf(ofp,"GT/AG bits penalty %2.2f\n",Probability2Bits(p->prob_for_gtag)); } } /* Function: new_GeneModelParam_from_argv(argc,argv) * * Descrip: Makes a GeneModelParam from argv * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [GeneModelParam *] * */ # line 133 "genestats.dy" GeneModelParam * new_GeneModelParam_from_argv(int * argc,char ** argv) { GeneModelParam * out; char * temp; out = std_GeneModelParam(); if( (temp=strip_out_assigned_argument(argc,argv,"splice_min_collar")) != NULL ) { if( is_double_string(temp,&out->min_collar) == FALSE ) { warn("%s is not a floating point number. Can't be a splice_min_collar",temp); free_GeneModelParam(out); return NULL; } } strip_out_boolean_def_argument(argc,argv,"splice_gtag",&out->use_gtag_splice); if( (temp=strip_out_assigned_argument(argc,argv,"splice_max_collar")) != NULL ) { if( is_double_string(temp,&out->max_collar) == FALSE ) { warn("%s is not a floating point number. Can't be a splice_max_collar",temp); free_GeneModelParam(out); return NULL; } } if( (temp=strip_out_assigned_argument(argc,argv,"splice_score_offset")) != NULL ) { if( is_double_string(temp,&out->score_offset) == FALSE ) { warn("%s is not a floating point number. Can't be a splice_score_offset",temp); free_GeneModelParam(out); return NULL; } } if( (temp=strip_out_assigned_argument(argc,argv,"genestats")) != NULL ) { if( out->gene_stats_file != NULL ) { ckfree(out->gene_stats_file); } out->gene_stats_file = stringalloc(temp); } if( (temp=strip_out_assigned_argument(argc,argv,"splice_gtag_prob")) != NULL ) { if( is_double_string(temp,&out->prob_for_gtag) == FALSE ) { warn("%s is not a floating pointer number. Can't be a probability for gtag",temp); free_GeneModelParam(out); return NULL; } } return out; } /* Function: vanilla_GeneralGeneModelScore(ct,start_odds,general_odds,stop_odds) * * Descrip: Makes a vanilla general gene model score * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: start_odds [UNKN ] Undocumented argument [Probability] * Arg: general_odds [UNKN ] Undocumented argument [Probability] * Arg: stop_odds [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [GeneralGeneModelScore *] * */ # line 190 "genestats.dy" GeneralGeneModelScore * vanilla_GeneralGeneModelScore(CodonTable * ct,Probability start_odds,Probability general_odds,Probability stop_odds) { GeneralGeneModelScore * out; RandomCodon * temp; out = GeneralGeneModelScore_alloc(); temp = vanilla_start_RandomCodon(ct,start_odds); out->start = RandomCodonScore_from_RandomCodon(temp); free_RandomCodon(temp); temp = vanilla_stop_RandomCodon(ct,stop_odds); out->stop = RandomCodonScore_from_RandomCodon(temp); free_RandomCodon(temp); temp = vanilla_general_RandomCodon(ct,general_odds); out->general = RandomCodonScore_from_RandomCodon(temp); free_RandomCodon(temp); return out; } /* Function: vanilla_start_RandomCodon(ct,start_codon_odd_prob) * * Descrip: Makes a vanilla (ie, all things equal) Met based * start codon rndscore * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: start_codon_odd_prob [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ # line 215 "genestats.dy" RandomCodon * vanilla_start_RandomCodon(CodonTable * ct,Probability start_codon_odd_prob) { int i; RandomCodon * out; out = RandomCodon_alloc(); for(i=0;i<125;i++) { if( aminoacid_from_codon(ct,i) == 'M' ) { out->codon[i] = start_codon_odd_prob; } else { out->codon[i] = 0.0; } } return out; } /* Function: vanilla_stop_RandomCodon(ct,stop_codon_odd_prob) * * Descrip: Makes a vanilla (ie, all things equal) * based * stop codon rndscore * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: stop_codon_odd_prob [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ # line 237 "genestats.dy" RandomCodon * vanilla_stop_RandomCodon(CodonTable * ct,Probability stop_codon_odd_prob) { int i; RandomCodon * out; out = RandomCodon_alloc(); for(i=0;i<125;i++) { if( aminoacid_from_codon(ct,i) == 'X' ) { out->codon[i] = stop_codon_odd_prob; } else { out->codon[i] = 0.0; } } return out; } /* Function: vanilla_general_RandomCodon(ct,coding_odd_prob) * * Descrip: Makes a vanilla (ie, all things equal) general non-stop * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: coding_odd_prob [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ # line 257 "genestats.dy" RandomCodon * vanilla_general_RandomCodon(CodonTable * ct,Probability coding_odd_prob) { int i; RandomCodon * out; out = RandomCodon_alloc(); for(i=0;i<125;i++) { if( aminoacid_from_codon(ct,i) == 'X' ) { out->codon[i] = 0.0; } else { out->codon[i] = coding_odd_prob; } } return out; } /* Function: std_GeneModelParam(void) * * Descrip: Makes a standard GeneModelParam * * * * Return [UNKN ] Undocumented return value [GeneModelParam *] * */ # line 279 "genestats.dy" GeneModelParam * std_GeneModelParam(void) { GeneModelParam * out; out = GeneModelParam_alloc(); out->splice5_pseudo = 1.0; out->splice3_pseudo = 1.0; out->intron_emission_pseudo = 1.0; out->polyp_emission_pseudo = 1.0; out->min_collar = -5.0; out->max_collar = +5.0; out->score_offset = DEFAULT_SPLICE_OFFSET_SCORE; out->gene_stats_file = stringalloc("gene.stat"); out->use_gtag_splice = TRUE; out->prob_for_gtag = 0.001; return out; } /* Function: GeneModel_from_GeneModelParam(p) * * Descrip: Combines GeneStats_from_GeneModelParam and GeneModel_from_GeneStats * * * Arg: p [UNKN ] Undocumented argument [GeneModelParam *] * * Return [UNKN ] Undocumented return value [GeneModel *] * */ # line 304 "genestats.dy" GeneModel * GeneModel_from_GeneModelParam(GeneModelParam * p) { GeneStats * st; GeneModel * out; assert(p); st = GeneStats_from_GeneModelParam(p); assert(st); out = GeneModel_from_GeneStats(st,p); assert(out); free_GeneStats(st); return out; } /* Function: GeneStats_from_GeneModelParam(p) * * Descrip: Makes a GeneStats from GeneModelParam - basically just opening the file * * * Arg: p [UNKN ] Undocumented argument [GeneModelParam *] * * Return [UNKN ] Undocumented return value [GeneStats *] * */ # line 328 "genestats.dy" GeneStats * GeneStats_from_GeneModelParam(GeneModelParam * p) { GeneStats * gs; FILE * ifp; assert(p); assert(p->gene_stats_file); ifp = openfile(p->gene_stats_file,"r"); if( ifp == NULL ) { warn("Unable to open %s as gene stats file",p->gene_stats_file); return NULL; } gs = read_GeneStats(ifp); return gs; } /* Function: GeneModel_from_GeneStats(gs,p) * * Descrip: Makes a model from the stats file * * * Arg: gs [UNKN ] Undocumented argument [GeneStats *] * Arg: p [UNKN ] Undocumented argument [GeneModelParam *] * * Return [UNKN ] Undocumented return value [GeneModel *] * */ # line 351 "genestats.dy" GeneModel * GeneModel_from_GeneStats(GeneStats * gs,GeneModelParam * p) { GeneModel * out; int i; double total; out = GeneModel_alloc(); assert(gs); assert(gs->splice5); assert(gs->splice3); assert(gs->intron); assert(gs->rnd); for(i=0;i<64;i++) { out->codon[i] = gs->codon[i]; } out->splice5 = pwmDNA_from_SeqAlign(gs->splice5,p->splice5_pseudo); /* fprintf(stdout,"GS splice5 %d splice3 %d\n",gs->splice5,gs->splice3);*/ fold_randommodel_pwmDNA(out->splice5,gs->rnd); out->splice5score = SpliceSiteScore_alloc(); out->splice5score->score = pwmDNAScore_from_pwmDNA(out->splice5); out->splice5score->offset = gs->splice5_offset; out->splice5score->min_collar = Probability2Score(Bits2Probability(p->min_collar)); out->splice5score->max_collar = Probability2Score(Bits2Probability(p->max_collar)); out->splice5score->score_offset = Probability2Score(Bits2Probability(p->score_offset)); out->splice3 = pwmDNA_from_SeqAlign(gs->splice3,p->splice3_pseudo); fold_randommodel_pwmDNA(out->splice3,gs->rnd); out->splice3score = SpliceSiteScore_alloc(); out->splice3score->score = pwmDNAScore_from_pwmDNA(out->splice3); out->splice3score->offset = gs->splice3_offset; out->splice3score->min_collar = Probability2Score(Bits2Probability(p->min_collar)); out->splice3score->max_collar = Probability2Score(Bits2Probability(p->max_collar)); out->splice3score->score_offset = Probability2Score(Bits2Probability(p->score_offset)); out->use_gtag_splice = p->use_gtag_splice; out->score_for_gtag = Probability2Score(p->prob_for_gtag); out->intron = RandomModelDNA_alloc(); for(total = 0.0,i=0;i<4;i++) total += gs->intron->base[i] + p->intron_emission_pseudo; for(i=0;i<4;i++) out->intron->base[i] = (gs->intron->base[i] + p->intron_emission_pseudo)/total; out->intron->base[4] = 1.0; if( gs->polyp != NULL ) { out->polyp = RandomModelDNA_alloc(); for(total = 0.0,i=0;i<4;i++) total += gs->polyp->base[i] + p->polyp_emission_pseudo; for(i=0;i<4;i++) out->polyp->base[i] = (gs->polyp->base[i] + p->polyp_emission_pseudo)/total; } out->rnd = hard_link_RandomModelDNA(gs->rnd); return out; } /* Function: show_GeneModel(gm,ofp) * * Descrip: shows a genemodel * * * Arg: gm [UNKN ] Undocumented argument [GeneModel *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 423 "genestats.dy" void show_GeneModel(GeneModel * gm,FILE * ofp) { fprintf(ofp,"Splice5\n"); show_pwmDNA_col(gm->splice5,ofp); fprintf(ofp,"Splice3\n"); show_pwmDNA_col(gm->splice3,ofp); } /* Function: new_ComplexSequenceEvalSet_from_GeneModel(gm) * * Descrip: Makes an entire ComplexSequenceEvalSet for genomic work * * * Arg: gm [UNKN ] Undocumented argument [GeneModel *] * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ # line 434 "genestats.dy" ComplexSequenceEvalSet * new_ComplexSequenceEvalSet_from_GeneModel(GeneModel * gm) { ComplexSequenceEvalSet * out; assert(gm); assert(gm->splice5score); assert(gm->splice3score); out = ComplexSequenceEvalSet_alloc_len(11); add_ComplexSequenceEvalSet(out,base_number_ComplexSequenceEval()); add_ComplexSequenceEvalSet(out,codon_number_ComplexSequenceEval()); if( gm->use_gtag_splice == FALSE ) { add_ComplexSequenceEvalSet(out,ComplexSequenceEval_from_pwmDNAScore_splice(gm->splice5score)); add_ComplexSequenceEvalSet(out,ComplexSequenceEval_from_pwmDNAScore_splice(gm->splice3score)); } else { add_ComplexSequenceEvalSet(out,ComplexSequenceEval_for_scored_gt(&gm->score_for_gtag)); add_ComplexSequenceEvalSet(out,ComplexSequenceEval_for_scored_ag(&gm->score_for_gtag)); } add_ComplexSequenceEvalSet(out,flat_zero()); add_ComplexSequenceEvalSet(out,flat_zero()); out->type = SEQUENCE_GENOMIC; prepare_ComplexSequenceEvalSet(out); return out; } /* Function: ComplexSequenceEval_for_scored_ag(score_for_ag) * * Descrip: Makes a ComplexSequenceEval for a GT rule * * * Arg: score_for_ag [UNKN ] Undocumented argument [Score *] * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ # line 470 "genestats.dy" ComplexSequenceEval * ComplexSequenceEval_for_scored_ag(Score * score_for_ag) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); out->left_window = 3; out->right_window = 3; out->left_lookback = 5; out->outside_score = NEGI; out->data = (void*) score_for_ag; out->type = SEQUENCE_GENOMIC; out->eval_func = scored_ag_eval_func; out->score_type = CseScoreType_Bits; return out; } /* Function: scored_ag_eval_func(type,*data,seq) * * Descrip: Function which actually does the evaluation for scored doners * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: *data [UNKN ] Undocumented argument [void] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 494 "genestats.dy" int scored_ag_eval_func(int type,void *data,char * seq) { if( *(seq-1) == 'A' && *(seq) == 'G' ) return *(Score *)data; else return NEGI; } /* Function: ComplexSequenceEval_for_scored_gt(score_for_gt) * * Descrip: Makes a ComplexSequenceEval for a GT rule * * * Arg: score_for_gt [UNKN ] Undocumented argument [Score *] * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ # line 505 "genestats.dy" ComplexSequenceEval * ComplexSequenceEval_for_scored_gt(Score * score_for_gt) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); out->left_window = 3; out->right_window = 7; out->left_lookback = 8; out->outside_score = NEGI; out->data = (void*) score_for_gt; out->type = SEQUENCE_GENOMIC; out->eval_func = scored_gt_eval_func; out->score_type = CseScoreType_Bits; return out; } /* Function: scored_gt_eval_func(type,*data,seq) * * Descrip: Function which actually does the evaluation for scored doners * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: *data [UNKN ] Undocumented argument [void] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 529 "genestats.dy" int scored_gt_eval_func(int type,void *data,char * seq) { if( *(seq) == 'G' && *(seq+1) == 'T' ) return *(Score *)data; else return NEGI; } /* Function: ComplexSequenceEval_from_pwmDNAScore_splice(score) * * Descrip: Makes a ComplexSequenceEval for a splice site * pwmdna * * * Arg: score [UNKN ] Undocumented argument [SpliceSiteScore *] * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ # line 542 "genestats.dy" ComplexSequenceEval * ComplexSequenceEval_from_pwmDNAScore_splice(SpliceSiteScore * score) { ComplexSequenceEval * out; /* printf("Making CSE from %d\n",score);*/ out = ComplexSequenceEval_alloc(); /* shouldn't really add ones, but this is ok anyway. Yukky hack due to not understanding a bug in the window determination */ /** *STILL don't know precisely what is going on down here! ***/ /* out->left_window = ssm->offset + ssm->pre_splice_site +1; */ out->left_window =10; /* out->right_window = ssm->offset + ssm->post_splice_site +1; */ out->right_window =10; out->left_lookback =10; out->outside_score= NEGI; out->data_type = 245; /* any old key */ out->data = (void *) score; out->type = SEQUENCE_GENOMIC; out->eval_func = pwmDNA_splice_ComplexSequence_eval_func; out->score_type = CseScoreType_Bits; return out; } /* Function: pwmDNA_splice_ComplexSequence_eval_func(type,data,seq) * * Descrip: This function is used as a pointer to function in the eval func * * You should never be using this function yourself! * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 581 "genestats.dy" int pwmDNA_splice_ComplexSequence_eval_func(int type,void * data,char * seq) { SpliceSiteScore * sc; pwmDNAScore * pds; int score; sc = (SpliceSiteScore* ) data; pds = sc->score; /* offset is written in biological coordinates. Need to get c style coordiates */ /* no idea what is happening here, but it works ;) */ if( seq[0] == 'N' && seq[1] == 'N' && seq[2] == 'N' ) { return NEGI; } score = score_pwmDNAScore_string(pds,seq-sc->offset+1); /* printf("Offset is %d %c%c%c\n",sc->offset,seq[0],seq[1],seq[2]);*/ /* fprintf(stdout,"Before collaring, %d\n",score);*/ if( score < sc->min_collar ) { score = sc->min_collar; } if( score > sc->max_collar ) { score = sc->max_collar; } /* fprintf(stdout,"Score %d before offset\n",score);*/ score -= sc->score_offset; /* fprintf(stdout,"Score %d after offset\n",score);*/ /* fprintf(stderr,"Scoring %d at some position\n",score);*/ return score; } /* Function: read_GeneStats(ifp) * * Descrip: Reads a GeneStats file * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [GeneStats *] * */ # line 626 "genestats.dy" GeneStats * read_GeneStats(FILE * ifp) { char buffer[MAXLINE]; GeneStats * out; SeqAlign * temp; char **base; char **brk; out = GeneStats_alloc(); out->rnd = NULL; while( fgets(buffer,MAXLINE,ifp) != NULL ) { /* fprintf(stderr,"Reading (main loop) %s",buffer); */ if( buffer[0] == '#' ) continue; if( buffer[0] == '%' && buffer[1] == '%' ) break; if( strstartcmp(buffer,"splice5") == 0 ) { base = brk = breakstring(buffer,spacestr); if( *brk == NULL || *(brk+1) == NULL || is_integer_string(*(brk+1),&out->splice5_offset) == 0) { warn("Cannot read splice5 offset - must be splice5 "); return NULL; } ckfree(base); temp = read_selex_SeqAlign(ifp); if( temp == NULL ) { warn("Could not read in selex alignment for splice5"); continue; } out->splice5 = temp; continue; } if( strstartcmp(buffer,"splice3") == 0 ) { base = brk = breakstring(buffer,spacestr); if( *brk == NULL || *(brk+1) == NULL || is_integer_string(*(brk+1),&out->splice3_offset) == 0) { warn("Cannot read splice3 offset - must be splice3 "); return NULL; } ckfree(base); temp = read_selex_SeqAlign(ifp); if( temp == NULL ) { warn("Could not read in selex alignment for splice5"); continue; } out->splice3 = temp; continue; } if( strstartcmp(buffer,"intron_emission") == 0 ) { if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Could not read in intron emission line"); break; } out->intron = get_genestat_emission(buffer); if( fgets(buffer,MAXLINE,ifp) != NULL ) { continue; } else { break; } } if( strstartcmp(buffer,"polyp_emission") == 0 ) { if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Could not read in polyp emission line"); break; } out->polyp = get_genestat_emission(buffer); if( fgets(buffer,MAXLINE,ifp) != NULL ) { continue; } else { break; } } if( strstartcmp(buffer,"rnd_emission") == 0 ) { if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Could not read in rnd emission line"); break; } out->rnd = get_genestat_emission(buffer); if( fgets(buffer,MAXLINE,ifp) != NULL ) { continue; } else { break; } } if( strstartcmp(buffer,"rndcodon") == 0 ) { if( read_codon_GeneStats(out->codon,buffer,ifp) == FALSE ) { warn("Problem in reading codon line!"); } continue; } if( isalpha(buffer[0]) ) { warn("Could not read line %s in genestats reading\n",buffer); } } assert(out); assert(out->splice5); assert(out->splice3); return out; } /* Function: get_genestat_emission(buffer) * * Descrip: reads in the emission stuff in a genestats line * * * Arg: buffer [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [RandomModelDNA *] * */ # line 747 "genestats.dy" RandomModelDNA * get_genestat_emission(char * buffer) { RandomModelDNA * out; int i; char ** base; char ** brk; double d; out = RandomModelDNA_alloc(); base = brk = breakstring(buffer,spacestr); for(i=0;*brk != NULL && i < 5;i++, brk++){ if( is_double_string(*brk,out->base+i) == FALSE) { warn("For genestat word %s, not a double in emission!",*brk); return FALSE; } } ckfree(base); if( i < 4 ) { warn("Did not read in 5 numbers for emission scores in genestats"); } return out; } /* Function: dump_GeneStats(st,ofp) * * Descrip: testing function * * * Arg: st [UNKN ] Undocumented argument [GeneStats *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 778 "genestats.dy" void dump_GeneStats(GeneStats * st,FILE * ofp) { int i; assert(st); assert(ofp); fprintf(ofp,"#\n# Dumping gene stats, wise2.2 style\n#\n"); fprintf(ofp,"splice5\n"); write_selex_SeqAlign(st->splice5,10,70,ofp); fprintf(ofp,"//\nsplice3\n"); write_selex_SeqAlign(st->splice3,10,70,ofp); fprintf(ofp,"//\n"); fprintf(ofp,"intron_emission\n"); for(i=0;i<4;i++) { fprintf(ofp,"%f ",st->intron->base[i]); } fprintf(ofp,"\n"); fprintf(ofp,"//\n"); if( st->polyp != NULL ) { fprintf(ofp,"polyp_emission\n"); for(i=0;i<4;i++) { fprintf(ofp,"%f ",st->polyp->base[i]); } } fprintf(ofp,"\n"); fprintf(ofp,"//\n"); } /* Function: read_codon_GeneStats(codon_array,line,ifp) * * Descrip: assummes codon_array is 64 positions long * * line should have begin consensus on it and be of MAXLINE length as it will be used as the buffer. * * This does **not** check that you have filled up all 64 positions. * * * Arg: codon_array [UNKN ] Undocumented argument [double *] * Arg: line [UNKN ] Undocumented argument [char*] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 819 "genestats.dy" boolean read_codon_GeneStats(double * codon_array,char* line,FILE * ifp) { boolean ret = TRUE; char * codon; char * number; if( strwhitestartcmp(line,"rndcodon",spacestr) != 0 ) { warn("In reading codon line, got no 'rndcoodon' tag [%s]",line); return FALSE; } while( fgets(line,MAXLINE,ifp) != NULL ) { if( line[0] == '#' ) continue; if( strwhitestartcmp(line,"//",spacestr) == 0 ) break; codon = strtok(line,spacestr); number = strtok(NULL,spacestr); if( codon == NULL ) { warn("Found an uncommented line in codon consensus with no leading codon word"); continue; } if( number == NULL ) { warn("For codon %s, no number found",codon); ret = FALSE; continue; } if( strchr(codon,'N') != NULL ) continue; if( is_non_ambiguous_codon_seq(codon) == FALSE ) { warn("Codon %s is not really a codon... problem!"); ret = FALSE; continue; } codon_array[base4_codon_from_seq(codon)]= atof(number); } return ret; } # line 923 "genestats.c" /* Function: hard_link_SpliceSiteScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SpliceSiteScore *] * * Return [UNKN ] Undocumented return value [SpliceSiteScore *] * */ SpliceSiteScore * hard_link_SpliceSiteScore(SpliceSiteScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a SpliceSiteScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SpliceSiteScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SpliceSiteScore *] * */ SpliceSiteScore * SpliceSiteScore_alloc(void) { SpliceSiteScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SpliceSiteScore *) ckalloc (sizeof(SpliceSiteScore))) == NULL) { warn("SpliceSiteScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->score = NULL; out->offset = 0; out->min_collar = 0; out->max_collar = 0; out->score_offset = 0; return out; } /* Function: free_SpliceSiteScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SpliceSiteScore *] * * Return [UNKN ] Undocumented return value [SpliceSiteScore *] * */ SpliceSiteScore * free_SpliceSiteScore(SpliceSiteScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SpliceSiteScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->score != NULL) free_pwmDNAScore(obj->score); ckfree(obj); return NULL; } /* Function: hard_link_GeneStats(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneStats *] * * Return [UNKN ] Undocumented return value [GeneStats *] * */ GeneStats * hard_link_GeneStats(GeneStats * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneStats object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneStats_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneStats *] * */ GeneStats * GeneStats_alloc(void) { GeneStats * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneStats *) ckalloc (sizeof(GeneStats))) == NULL) { warn("GeneStats_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->splice5 = NULL; out->splice5_offset = 0; out->splice3 = NULL; out->splice3_offset = 0; out->intron = NULL; out->average_intron = 0; out->polyp = NULL; out->average_polyp = 0; out->rnd = NULL; /* codon[64] is an array: no default possible */ return out; } /* Function: free_GeneStats(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneStats *] * * Return [UNKN ] Undocumented return value [GeneStats *] * */ GeneStats * free_GeneStats(GeneStats * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneStats obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->splice5 != NULL) free_SeqAlign(obj->splice5); if( obj->splice3 != NULL) free_SeqAlign(obj->splice3); if( obj->intron != NULL) free_RandomModelDNA(obj->intron); if( obj->polyp != NULL) free_RandomModelDNA(obj->polyp); if( obj->rnd != NULL) free_RandomModelDNA(obj->rnd); ckfree(obj); return NULL; } /* Function: hard_link_GeneModelParam(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneModelParam *] * * Return [UNKN ] Undocumented return value [GeneModelParam *] * */ GeneModelParam * hard_link_GeneModelParam(GeneModelParam * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneModelParam object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneModelParam_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneModelParam *] * */ GeneModelParam * GeneModelParam_alloc(void) { GeneModelParam * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneModelParam *) ckalloc (sizeof(GeneModelParam))) == NULL) { warn("GeneModelParam_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->splice5_pseudo = 0; out->splice3_pseudo = 0; out->intron_emission_pseudo = 0; out->polyp_emission_pseudo = 0; out->min_collar = 0; out->max_collar = 0; out->score_offset = 0; out->gene_stats_file = NULL; out->use_gtag_splice = FALSE; out->prob_for_gtag = 0; return out; } /* Function: free_GeneModelParam(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneModelParam *] * * Return [UNKN ] Undocumented return value [GeneModelParam *] * */ GeneModelParam * free_GeneModelParam(GeneModelParam * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneModelParam obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->gene_stats_file != NULL) ckfree(obj->gene_stats_file); ckfree(obj); return NULL; } /* Function: hard_link_GeneModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneModel *] * * Return [UNKN ] Undocumented return value [GeneModel *] * */ GeneModel * hard_link_GeneModel(GeneModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneModel *] * */ GeneModel * GeneModel_alloc(void) { GeneModel * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneModel *) ckalloc (sizeof(GeneModel))) == NULL) { warn("GeneModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->splice5 = NULL; out->splice5_offset = 0; out->splice3 = NULL; out->splice3_offset = 0; out->intron = NULL; out->intron_stay_prob = 0; out->polyp = NULL; out->polyp_stay_prob = 0; out->rnd = NULL; out->splice5score = NULL; out->splice3score = NULL; /* codon[64] is an array: no default possible */ out->use_gtag_splice = FALSE; out->score_for_gtag = 0; return out; } /* Function: free_GeneModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneModel *] * * Return [UNKN ] Undocumented return value [GeneModel *] * */ GeneModel * free_GeneModel(GeneModel * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->splice5 != NULL) free_pwmDNA(obj->splice5); if( obj->splice3 != NULL) free_pwmDNA(obj->splice3); if( obj->intron != NULL) free_RandomModelDNA(obj->intron); if( obj->polyp != NULL) free_RandomModelDNA(obj->polyp); if( obj->rnd != NULL) free_RandomModelDNA(obj->rnd); if( obj->splice5score != NULL) free_SpliceSiteScore(obj->splice5score); if( obj->splice3score != NULL) free_SpliceSiteScore(obj->splice3score); ckfree(obj); return NULL; } /* Function: hard_link_GeneralGeneModelScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [GeneralGeneModelScore *] * */ GeneralGeneModelScore * hard_link_GeneralGeneModelScore(GeneralGeneModelScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneralGeneModelScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneralGeneModelScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneralGeneModelScore *] * */ GeneralGeneModelScore * GeneralGeneModelScore_alloc(void) { GeneralGeneModelScore * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneralGeneModelScore *) ckalloc (sizeof(GeneralGeneModelScore))) == NULL) { warn("GeneralGeneModelScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = NULL; out->stop = NULL; out->general = NULL; return out; } /* Function: free_GeneralGeneModelScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [GeneralGeneModelScore *] * */ GeneralGeneModelScore * free_GeneralGeneModelScore(GeneralGeneModelScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneralGeneModelScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->start != NULL) free_RandomCodonScore(obj->start); if( obj->stop != NULL) free_RandomCodonScore(obj->stop); if( obj->general != NULL) free_RandomCodonScore(obj->general); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/genestats.h0000644000175000001440000004447110670453714016312 0ustar philippusers#ifndef DYNAMITEgenestatsHEADERFILE #define DYNAMITEgenestatsHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "seqalign.h" #include "pwmdna.h" #include "randommodel.h" #include "complexsequence.h" #include "complexevalset.h" /* for the standard evals */ #define DEFAULT_SPLICE_OFFSET_SCORE 1.5 struct Wise2_SpliceSiteScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif pwmDNAScore * score; int offset; Score min_collar; Score max_collar; Score score_offset; } ; /* SpliceSiteScore defined */ #ifndef DYNAMITE_DEFINED_SpliceSiteScore typedef struct Wise2_SpliceSiteScore Wise2_SpliceSiteScore; #define SpliceSiteScore Wise2_SpliceSiteScore #define DYNAMITE_DEFINED_SpliceSiteScore #endif /* Object GeneStats * * Descrip: This structure is to hold the * new generation of gene statistics * for the genewise algorithms * * */ struct Wise2_GeneStats { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeqAlign * splice5; int splice5_offset; SeqAlign * splice3; int splice3_offset; RandomModelDNA * intron; /* actually counts */ double average_intron; RandomModelDNA * polyp; /* actually counts */ double average_polyp; RandomModelDNA * rnd; double codon[64]; } ; /* GeneStats defined */ #ifndef DYNAMITE_DEFINED_GeneStats typedef struct Wise2_GeneStats Wise2_GeneStats; #define GeneStats Wise2_GeneStats #define DYNAMITE_DEFINED_GeneStats #endif /* Object GeneModelParam * * Descrip: A small helper object containing * the ways of converting the actual * counts/alignments to the model * * Here really for convience so we can * keep all the code associated with the * creation of the GeneModel together * * */ struct Wise2_GeneModelParam { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif double splice5_pseudo; double splice3_pseudo; double intron_emission_pseudo; double polyp_emission_pseudo; Bits min_collar; Bits max_collar; Bits score_offset; char * gene_stats_file; boolean use_gtag_splice; double prob_for_gtag; } ; /* GeneModelParam defined */ #ifndef DYNAMITE_DEFINED_GeneModelParam typedef struct Wise2_GeneModelParam Wise2_GeneModelParam; #define GeneModelParam Wise2_GeneModelParam #define DYNAMITE_DEFINED_GeneModelParam #endif /* Object GeneModel * * Descrip: This structure is to hold the * new generation of models for the * genewise algorithm * * * */ struct Wise2_GeneModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif pwmDNA * splice5; int splice5_offset; pwmDNA * splice3; int splice3_offset; RandomModelDNA * intron; double intron_stay_prob; RandomModelDNA * polyp; double polyp_stay_prob; RandomModelDNA * rnd; SpliceSiteScore * splice5score; SpliceSiteScore * splice3score; double codon[64]; boolean use_gtag_splice; Score score_for_gtag; } ; /* GeneModel defined */ #ifndef DYNAMITE_DEFINED_GeneModel typedef struct Wise2_GeneModel Wise2_GeneModel; #define GeneModel Wise2_GeneModel #define DYNAMITE_DEFINED_GeneModel #endif struct Wise2_GeneralGeneModelScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif RandomCodonScore * start; RandomCodonScore * stop; RandomCodonScore * general; } ; /* GeneralGeneModelScore defined */ #ifndef DYNAMITE_DEFINED_GeneralGeneModelScore typedef struct Wise2_GeneralGeneModelScore Wise2_GeneralGeneModelScore; #define GeneralGeneModelScore Wise2_GeneralGeneModelScore #define DYNAMITE_DEFINED_GeneralGeneModelScore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: show_help_GeneModelParam(ofp) * * Descrip: Shows help * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_help_GeneModelParam(FILE * ofp); #define show_help_GeneModelParam Wise2_show_help_GeneModelParam /* Function: show_info_GeneModelParam(p,ofp) * * Descrip: Shows genemodel param for info * * * Arg: p [UNKN ] Undocumented argument [GeneModelParam *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_info_GeneModelParam(GeneModelParam * p,FILE * ofp); #define show_info_GeneModelParam Wise2_show_info_GeneModelParam /* Function: new_GeneModelParam_from_argv(argc,argv) * * Descrip: Makes a GeneModelParam from argv * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [GeneModelParam *] * */ GeneModelParam * Wise2_new_GeneModelParam_from_argv(int * argc,char ** argv); #define new_GeneModelParam_from_argv Wise2_new_GeneModelParam_from_argv /* Function: vanilla_GeneralGeneModelScore(ct,start_odds,general_odds,stop_odds) * * Descrip: Makes a vanilla general gene model score * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: start_odds [UNKN ] Undocumented argument [Probability] * Arg: general_odds [UNKN ] Undocumented argument [Probability] * Arg: stop_odds [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [GeneralGeneModelScore *] * */ GeneralGeneModelScore * Wise2_vanilla_GeneralGeneModelScore(CodonTable * ct,Probability start_odds,Probability general_odds,Probability stop_odds); #define vanilla_GeneralGeneModelScore Wise2_vanilla_GeneralGeneModelScore /* Function: vanilla_start_RandomCodon(ct,start_codon_odd_prob) * * Descrip: Makes a vanilla (ie, all things equal) Met based * start codon rndscore * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: start_codon_odd_prob [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ RandomCodon * Wise2_vanilla_start_RandomCodon(CodonTable * ct,Probability start_codon_odd_prob); #define vanilla_start_RandomCodon Wise2_vanilla_start_RandomCodon /* Function: vanilla_stop_RandomCodon(ct,stop_codon_odd_prob) * * Descrip: Makes a vanilla (ie, all things equal) * based * stop codon rndscore * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: stop_codon_odd_prob [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ RandomCodon * Wise2_vanilla_stop_RandomCodon(CodonTable * ct,Probability stop_codon_odd_prob); #define vanilla_stop_RandomCodon Wise2_vanilla_stop_RandomCodon /* Function: vanilla_general_RandomCodon(ct,coding_odd_prob) * * Descrip: Makes a vanilla (ie, all things equal) general non-stop * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: coding_odd_prob [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ RandomCodon * Wise2_vanilla_general_RandomCodon(CodonTable * ct,Probability coding_odd_prob); #define vanilla_general_RandomCodon Wise2_vanilla_general_RandomCodon /* Function: std_GeneModelParam(void) * * Descrip: Makes a standard GeneModelParam * * * * Return [UNKN ] Undocumented return value [GeneModelParam *] * */ GeneModelParam * Wise2_std_GeneModelParam(void); #define std_GeneModelParam Wise2_std_GeneModelParam /* Function: GeneModel_from_GeneModelParam(p) * * Descrip: Combines GeneStats_from_GeneModelParam and GeneModel_from_GeneStats * * * Arg: p [UNKN ] Undocumented argument [GeneModelParam *] * * Return [UNKN ] Undocumented return value [GeneModel *] * */ GeneModel * Wise2_GeneModel_from_GeneModelParam(GeneModelParam * p); #define GeneModel_from_GeneModelParam Wise2_GeneModel_from_GeneModelParam /* Function: GeneStats_from_GeneModelParam(p) * * Descrip: Makes a GeneStats from GeneModelParam - basically just opening the file * * * Arg: p [UNKN ] Undocumented argument [GeneModelParam *] * * Return [UNKN ] Undocumented return value [GeneStats *] * */ GeneStats * Wise2_GeneStats_from_GeneModelParam(GeneModelParam * p); #define GeneStats_from_GeneModelParam Wise2_GeneStats_from_GeneModelParam /* Function: GeneModel_from_GeneStats(gs,p) * * Descrip: Makes a model from the stats file * * * Arg: gs [UNKN ] Undocumented argument [GeneStats *] * Arg: p [UNKN ] Undocumented argument [GeneModelParam *] * * Return [UNKN ] Undocumented return value [GeneModel *] * */ GeneModel * Wise2_GeneModel_from_GeneStats(GeneStats * gs,GeneModelParam * p); #define GeneModel_from_GeneStats Wise2_GeneModel_from_GeneStats /* Function: show_GeneModel(gm,ofp) * * Descrip: shows a genemodel * * * Arg: gm [UNKN ] Undocumented argument [GeneModel *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_GeneModel(GeneModel * gm,FILE * ofp); #define show_GeneModel Wise2_show_GeneModel /* Function: new_ComplexSequenceEvalSet_from_GeneModel(gm) * * Descrip: Makes an entire ComplexSequenceEvalSet for genomic work * * * Arg: gm [UNKN ] Undocumented argument [GeneModel *] * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * Wise2_new_ComplexSequenceEvalSet_from_GeneModel(GeneModel * gm); #define new_ComplexSequenceEvalSet_from_GeneModel Wise2_new_ComplexSequenceEvalSet_from_GeneModel /* Function: read_GeneStats(ifp) * * Descrip: Reads a GeneStats file * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [GeneStats *] * */ GeneStats * Wise2_read_GeneStats(FILE * ifp); #define read_GeneStats Wise2_read_GeneStats /* Function: dump_GeneStats(st,ofp) * * Descrip: testing function * * * Arg: st [UNKN ] Undocumented argument [GeneStats *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_dump_GeneStats(GeneStats * st,FILE * ofp); #define dump_GeneStats Wise2_dump_GeneStats /* Function: read_codon_GeneStats(codon_array,line,ifp) * * Descrip: assummes codon_array is 64 positions long * * line should have begin consensus on it and be of MAXLINE length as it will be used as the buffer. * * This does **not** check that you have filled up all 64 positions. * * * Arg: codon_array [UNKN ] Undocumented argument [double *] * Arg: line [UNKN ] Undocumented argument [char*] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_read_codon_GeneStats(double * codon_array,char* line,FILE * ifp); #define read_codon_GeneStats Wise2_read_codon_GeneStats /* Function: hard_link_SpliceSiteScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SpliceSiteScore *] * * Return [UNKN ] Undocumented return value [SpliceSiteScore *] * */ SpliceSiteScore * Wise2_hard_link_SpliceSiteScore(SpliceSiteScore * obj); #define hard_link_SpliceSiteScore Wise2_hard_link_SpliceSiteScore /* Function: SpliceSiteScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SpliceSiteScore *] * */ SpliceSiteScore * Wise2_SpliceSiteScore_alloc(void); #define SpliceSiteScore_alloc Wise2_SpliceSiteScore_alloc /* Function: free_SpliceSiteScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SpliceSiteScore *] * * Return [UNKN ] Undocumented return value [SpliceSiteScore *] * */ SpliceSiteScore * Wise2_free_SpliceSiteScore(SpliceSiteScore * obj); #define free_SpliceSiteScore Wise2_free_SpliceSiteScore /* Function: hard_link_GeneStats(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneStats *] * * Return [UNKN ] Undocumented return value [GeneStats *] * */ GeneStats * Wise2_hard_link_GeneStats(GeneStats * obj); #define hard_link_GeneStats Wise2_hard_link_GeneStats /* Function: GeneStats_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneStats *] * */ GeneStats * Wise2_GeneStats_alloc(void); #define GeneStats_alloc Wise2_GeneStats_alloc /* Function: free_GeneStats(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneStats *] * * Return [UNKN ] Undocumented return value [GeneStats *] * */ GeneStats * Wise2_free_GeneStats(GeneStats * obj); #define free_GeneStats Wise2_free_GeneStats /* Function: hard_link_GeneModelParam(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneModelParam *] * * Return [UNKN ] Undocumented return value [GeneModelParam *] * */ GeneModelParam * Wise2_hard_link_GeneModelParam(GeneModelParam * obj); #define hard_link_GeneModelParam Wise2_hard_link_GeneModelParam /* Function: GeneModelParam_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneModelParam *] * */ GeneModelParam * Wise2_GeneModelParam_alloc(void); #define GeneModelParam_alloc Wise2_GeneModelParam_alloc /* Function: free_GeneModelParam(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneModelParam *] * * Return [UNKN ] Undocumented return value [GeneModelParam *] * */ GeneModelParam * Wise2_free_GeneModelParam(GeneModelParam * obj); #define free_GeneModelParam Wise2_free_GeneModelParam /* Function: hard_link_GeneModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneModel *] * * Return [UNKN ] Undocumented return value [GeneModel *] * */ GeneModel * Wise2_hard_link_GeneModel(GeneModel * obj); #define hard_link_GeneModel Wise2_hard_link_GeneModel /* Function: GeneModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneModel *] * */ GeneModel * Wise2_GeneModel_alloc(void); #define GeneModel_alloc Wise2_GeneModel_alloc /* Function: free_GeneModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneModel *] * * Return [UNKN ] Undocumented return value [GeneModel *] * */ GeneModel * Wise2_free_GeneModel(GeneModel * obj); #define free_GeneModel Wise2_free_GeneModel /* Function: hard_link_GeneralGeneModelScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [GeneralGeneModelScore *] * */ GeneralGeneModelScore * Wise2_hard_link_GeneralGeneModelScore(GeneralGeneModelScore * obj); #define hard_link_GeneralGeneModelScore Wise2_hard_link_GeneralGeneModelScore /* Function: GeneralGeneModelScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneralGeneModelScore *] * */ GeneralGeneModelScore * Wise2_GeneralGeneModelScore_alloc(void); #define GeneralGeneModelScore_alloc Wise2_GeneralGeneModelScore_alloc /* Function: free_GeneralGeneModelScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [GeneralGeneModelScore *] * */ GeneralGeneModelScore * Wise2_free_GeneralGeneModelScore(GeneralGeneModelScore * obj); #define free_GeneralGeneModelScore Wise2_free_GeneralGeneModelScore /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ ComplexSequenceEval * Wise2_ComplexSequenceEval_for_scored_ag(Score * score_for_ag); #define ComplexSequenceEval_for_scored_ag Wise2_ComplexSequenceEval_for_scored_ag int Wise2_scored_ag_eval_func(int type,void *data,char * seq); #define scored_ag_eval_func Wise2_scored_ag_eval_func ComplexSequenceEval * Wise2_ComplexSequenceEval_for_scored_gt(Score * score_for_gt); #define ComplexSequenceEval_for_scored_gt Wise2_ComplexSequenceEval_for_scored_gt int Wise2_scored_gt_eval_func(int type,void *data,char * seq); #define scored_gt_eval_func Wise2_scored_gt_eval_func ComplexSequenceEval * Wise2_ComplexSequenceEval_from_pwmDNAScore_splice(SpliceSiteScore * score); #define ComplexSequenceEval_from_pwmDNAScore_splice Wise2_ComplexSequenceEval_from_pwmDNAScore_splice int Wise2_pwmDNA_splice_ComplexSequence_eval_func(int type,void * data,char * seq); #define pwmDNA_splice_ComplexSequence_eval_func Wise2_pwmDNA_splice_ComplexSequence_eval_func RandomModelDNA * Wise2_get_genestat_emission(char * buffer); #define get_genestat_emission Wise2_get_genestat_emission #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/lba.c0000644000175000001440000000712510052364120015023 0ustar philippusers#include "version.h" #include "largeblockdp.h" #include "seqaligndisplay.h" char * program_name = "lba"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s query-seq target-seq\n",program_name); fprintf(ofp,"Parameters (all as probabilities)\n"); fprintf(ofp," -matchp [0.75] probability of match in block\n"); fprintf(ofp," -gap [0.1] probability of opening a gap in a block\n"); fprintf(ofp," -block_open [0.0005] probability of a block occuring\n"); fprintf(ofp," -block_ext [0.8] probability ratio of block extension vs null\n"); fprintf(ofp," -undual [1.0] probability ratio of un-matched extension vs null, both seqs\n"); fprintf(ofp," -unsingle [1.0] probability ratio of un-matched extension vs null, one seq\n"); fprintf(ofp,"Output format\n"); fprintf(ofp," -[no]alb show alb format (default no)\n"); fprintf(ofp," -[no]pretty show pretty format (default no)\n"); show_help_DPRunImpl(ofp); show_standard_options(ofp); } int main(int argc,char ** argv) { Sequence * one; Sequence * two; PackAln * pal; AlnBlock * alb; DnaProbMatrix * dmp; DnaMatrix * mat; Probability match = 0.75; Probability gap_open = 0.1; Probability gap_ext = 0.3; Probability block_open = 0.0005; Probability un_dual = 1.0; Probability un_single = 1.0; Probability real_ext = 0.6; boolean show_pretty = TRUE; boolean show_alb = FALSE; ComplexSequence *cone, *ctwo; ComplexSequenceEvalSet *cses; DPRunImpl * dpri; dpri = new_DPRunImpl_from_argv(&argc,argv); strip_out_float_argument(&argc,argv,"matchp",&match); strip_out_float_argument(&argc,argv,"gap",&gap_open); strip_out_float_argument(&argc,argv,"ext",&gap_ext); strip_out_float_argument(&argc,argv,"block_open",&block_open); strip_out_float_argument(&argc,argv,"block_ext",&real_ext); strip_out_float_argument(&argc,argv,"undual",&un_dual); strip_out_float_argument(&argc,argv,"unsingle",&un_single); strip_out_boolean_def_argument(&argc,argv,"pretty",&show_pretty); strip_out_boolean_def_argument(&argc,argv,"alb",&show_alb); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 3 ) { show_help(stdout); exit(12); } one = read_fasta_file_Sequence(argv[1]); two = read_fasta_file_Sequence(argv[2]); dmp = DnaProbMatrix_from_match(match,NMaskType_BANNED); flat_null_DnaProbMatrix(dmp); mat = DnaMatrix_from_DnaProbMatrix(dmp); cses = default_DNA_ComplexSequenceEvalSet(); cone = new_ComplexSequence(one,cses); ctwo = new_ComplexSequence(two,cses); pal = PackAln_bestmemory_LargeBlockAligner(cone,ctwo,mat, Probability2Score(real_ext), Probability2Score(block_open), Probability2Score(un_dual), Probability2Score(un_single), Probability2Score(gap_open), Probability2Score(gap_ext),NULL,dpri); alb = convert_PackAln_to_AlnBlock_LargeBlockAligner(pal); if( show_pretty == TRUE ) write_pretty_seq_align(alb,one,two,12,60,stdout); if( show_alb == TRUE ) dump_ascii_AlnBlock(alb,stdout); } wise-2.4.1/src/models/estquick3.c0000644000175000001440000046065110670453713016224 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "estquick3.h" # line 5 "estquick3.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define START 0 #define END 1 #define EstQuick3_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+4)*3)+STATE][i+1] #define EstQuick3_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+4] #define EstQuick3_READ_OFF_ERROR -6 #define EstQuick3_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+5)%5][((i+1)*3)+STATE] #define EstQuick3_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+5)%5][STATE] #define EstQuick3_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define EstQuick3_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_EstQuick3(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_EstQuick3(EstQuick3 * mat) { EstQuick3_access_func_holder holder; holder.access_main = EstQuick3_shatter_access_main; holder.access_special = EstQuick3_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_EstQuick3(mat,holder); } /* Function: EstQuick3_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstQuick3_shatter_access_main(EstQuick3 * mat,int i,int j,int state) { return EstQuick3_SHATTER_MATRIX(mat,i,j,state); } /* Function: EstQuick3_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstQuick3_shatter_access_special(EstQuick3 * mat,int i,int j,int state) { return EstQuick3_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_EstQuick3(mat,dpenv) * * Descrip: This function calculates the EstQuick3 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EstQuick3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_EstQuick3(EstQuick3 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_2; int * SIG_1_4; int * SIG_0_3; int * SIG_0_2; int * SIG_0_4; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("EstQuick3 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i].transition[GW_MATCH2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i].transition[GW_INSERT2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i].transition[GW_DELETE2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstQuick3_SHATTER_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i].transition[GW_START2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_4[MATCH] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i].transition[GW_MATCH2END]) + (0) ; if( temp > EstQuick3_SHATTER_SPECIAL(mat,i,j,END) ) { EstQuick3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i].transition[GW_MATCH2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i].transition[GW_INSERT2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_2[INSERT] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_4[INSERT] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ SIG_0_0[INSERT] = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i].transition[GW_MATCH2DELETE]; /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i].transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_EstQuick3(dbsi,out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstQuick3 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseQuickDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_EstQuick3(DBSearchImpl * dbsi,Hscore * out,GeneWiseQuickDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_EstQuick3 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_EstQuick3. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_EstQuick3. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for EstQuick3, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_EstQuick3(out,querydb, targetdb ,cp); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_EstQuick3 *) ckalloc(sizeof(struct thread_pool_holder_EstQuick3)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->cp = cp; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_EstQuick3,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for EstQuick3"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from EstQuick3",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_EstQuick3(ptr) * * Descrip: Infinite loop code foreach thread for EstQuick3 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_EstQuick3(void * ptr) { struct thread_pool_holder_EstQuick3 * holder; int db_status; int score; DataScore * ds; GeneWiseScoreFlat* query; ComplexSequence* target; holder = (struct thread_pool_holder_EstQuick3 *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for EstQuick3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstQuick3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_GeneWiseQuickDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in EstQuick3 search"); } query = hard_link_GeneWiseScoreFlat(holder->query); /* get query information into datascore */ dataentry_add_GeneWiseQuickDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_cDNADB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_cDNADB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching EstQuick3, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_cDNADB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_GeneWiseScoreFlat(holder->query); /* get the next query object for the next thread */ holder->query = reload_GeneWiseQuickDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching EstQuick3, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_GeneWiseQuickDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstQuick3"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstQuick3"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_cDNADB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_EstQuick3(query, target ,holder->cp); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for EstQuick3"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for EstQuick3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for EstQuick3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_GeneWiseScoreFlat(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstQuick3"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_EstQuick3(out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstQuick3 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseQuickDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_EstQuick3(Hscore * out,GeneWiseQuickDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp) { GeneWiseScoreFlat* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GeneWiseQuickDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstQuick3, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_cDNADB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstQuick3, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_EstQuick3(query, target , cp); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("EstQuick3 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GeneWiseQuickDB(ds->query,query,querydb); dataentry_add_cDNADB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_cDNADB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstQuick3, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_cDNADB(target,targetdb); query = reload_GeneWiseQuickDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching EstQuick3, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GeneWiseQuickDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_EstQuick3(query,target,cp) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_EstQuick3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScoreFlat*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_EstQuick3(GeneWiseScoreFlat* query,ComplexSequence* target ,cDNAParserScore * cp) { int bestscore = NEGI; int i; int j; int k; EstQuick3 * mat; mat = allocate_EstQuick3_only(query, target , cp); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(5,(mat->leni + 1) * 3,5,2)) == NULL) { warn("Score only matrix for EstQuick3 cannot be allocated, (asking for 4 by %d cells)",mat->leni*3); mat = free_EstQuick3(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<6;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) EstQuick3_VSMALL_MATRIX(mat,i,j,k) = NEGI; } EstQuick3_VSMALL_SPECIAL(mat,i,j,START) = 0; EstQuick3_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = EstQuick3_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstQuick3_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstQuick3_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i].transition[GW_DELETE2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstQuick3_VSMALL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i].transition[GW_START2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstQuick3_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstQuick3_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstQuick3_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i].transition[GW_MATCH2END]) + (0) ; if( temp > EstQuick3_VSMALL_SPECIAL(mat,i,j,END) ) { EstQuick3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstQuick3_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstQuick3_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstQuick3_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstQuick3_VSMALL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstQuick3_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstQuick3_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i].transition[GW_MATCH2DELETE]; /* From state DELETE to state DELETE */ temp = EstQuick3_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i].transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstQuick3_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < EstQuick3_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = EstQuick3_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_EstQuick3(mat); return bestscore; } /* Function: PackAln_bestmemory_EstQuick3(query,target,cp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EstQuick3 * * * Arg: query [UNKN ] query data structure [GeneWiseScoreFlat*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_EstQuick3(GeneWiseScoreFlat* query,ComplexSequence* target ,cDNAParserScore * cp,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; EstQuick3 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_EstQuick3(query, target , cp,dpri)) == NULL ) { warn("Unable to allocate large EstQuick3 version"); return NULL; } calculate_dpenv_EstQuick3(mat,dpenv); out = PackAln_read_Expl_EstQuick3(mat); } else { mat = allocate_EstQuick3_only(query, target , cp); calculate_shatter_EstQuick3(mat,dpenv); out = PackAln_read_Shatter_EstQuick3(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_EstQuick3(query, target , cp)) == NULL ) { warn("Unable to allocate small EstQuick3 version"); return NULL; } out = PackAln_calculate_Small_EstQuick3(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_EstQuick3(query, target , cp,dpri)) == NULL ) { warn("Unable to allocate large EstQuick3 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_EstQuick3(mat); out = PackAln_read_Expl_EstQuick3(mat); } } } mat = free_EstQuick3(mat); return out; } /* Function: allocate_EstQuick3_only(query,target,cp) * * Descrip: This function only allocates the EstQuick3 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GeneWiseScoreFlat*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstQuick3 *] * */ EstQuick3 * allocate_EstQuick3_only(GeneWiseScoreFlat* query,ComplexSequence* target ,cDNAParserScore * cp) { EstQuick3 * out; if((out= EstQuick3_alloc()) == NULL) { warn("Allocation of basic EstQuick3 structure failed..."); return NULL; } out->query = query; out->target = target; out->cp = cp; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_EstQuick3(query,target,cp,dpri) * * Descrip: This function allocates the EstQuick3 structure * and the basematrix area for explicit memory implementations * It calls /allocate_EstQuick3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScoreFlat*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EstQuick3 *] * */ EstQuick3 * allocate_Expl_EstQuick3(GeneWiseScoreFlat* query,ComplexSequence* target ,cDNAParserScore * cp,DPRunImpl * dpri) { EstQuick3 * out; out = allocate_EstQuick3_only(query, target , cp); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+4)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+4)*3,(out->leni+1),2,out->lenj+4)) == NULL) { warn("Explicit matrix EstQuick3 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_EstQuick3(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_EstQuick3(out); return out; } /* Function: init_EstQuick3(mat) * * Descrip: This function initates EstQuick3 matrix when in explicit mode * Called in /allocate_Expl_EstQuick3 * * * Arg: mat [UNKN ] EstQuick3 which contains explicit basematrix memory [EstQuick3 *] * */ void init_EstQuick3(EstQuick3 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-4);j<5;j++) { EstQuick3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstQuick3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstQuick3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j= (-4);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { EstQuick3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstQuick3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstQuick3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } EstQuick3_EXPL_SPECIAL(mat,i,j,START) = 0; EstQuick3_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_EstQuick3(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EstQuick3 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * */ void recalculate_PackAln_EstQuick3(PackAln * pal,EstQuick3 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i].transition[GW_MATCH2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i].transition[GW_INSERT2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i].transition[GW_DELETE2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (START+3) ) { pau->score = (mat->query->seg[i].transition[GW_START2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 1 && offj == 4 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i].transition[GW_MATCH2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i].transition[GW_INSERT2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i].transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i].transition[GW_DELETE2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+3) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i].transition[GW_MATCH2END] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define EstQuick3_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+4)][(i+1)*3+state]) #define EstQuick3_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+5)*8) % 40][(i+1)*3+state]) #define EstQuick3_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+4)]) #define EstQuick3_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+4)]) #define EstQuick3_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+5)*8)+(shadow+1)) % 40)][(i+1)*3 + state]) #define EstQuick3_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+4)]) #define EstQuick3_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+4)% 4) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define EstQuick3_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+4)% 4) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define EstQuick3_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+4)]) /* Function: allocate_Small_EstQuick3(query,target,cp) * * Descrip: This function allocates the EstQuick3 structure * and the basematrix area for a small memory implementations * It calls /allocate_EstQuick3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScoreFlat*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstQuick3 *] * */ #define EstQuick3_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+4)]) EstQuick3 * allocate_Small_EstQuick3(GeneWiseScoreFlat* query,ComplexSequence* target ,cDNAParserScore * cp) { EstQuick3 * out; out = allocate_EstQuick3_only(query, target , cp); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(40,(out->leni + 1) * 3,16,out->lenj+4); if(out == NULL) { warn("Small shadow matrix EstQuick3 cannot be allocated, (asking for 5 by %d main cells)",out->leni+2); free_EstQuick3(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_EstQuick3(mat,dpenv) * * Descrip: This function calculates an alignment for EstQuick3 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EstQuick3 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EstQuick3 * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_EstQuick3(EstQuick3 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for EstQuick3 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_EstQuick3(mat,dpenv); score = start_end_find_end_EstQuick3(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_EstQuick3(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_EstQuick3(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == EstQuick3_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_EstQuick3(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 3; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_EstQuick3(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_EstQuick3(mat) * * Descrip: This function calculates an alignment for EstQuick3 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EstQuick3 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EstQuick3 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EstQuick3 * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_EstQuick3(EstQuick3 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_EstQuick3(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_EstQuick3(mat); return out; } /* Function: AlnRangeSet_from_EstQuick3(mat) * * Descrip: This function reads off a start/end structure * for EstQuick3 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EstQuick3 * If you have not calculated the matrix use * /AlnRange_calculate_Small_EstQuick3 * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_EstQuick3(EstQuick3 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EstQuick3"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_EstQuick3(mat,&jpos); state = END; while( (temp = AlnRange_build_EstQuick3(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_EstQuick3(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_EstQuick3 * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_EstQuick3(EstQuick3 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EstQuick3"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_EstQuick3(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_EstQuick3 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = EstQuick3_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_EstQuick3(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == EstQuick3_READ_OFF_ERROR) { warn("In AlnRange_build_EstQuick3 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = EstQuick3_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_EstQuick3(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_EstQuick3(EstQuick3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_EstQuick3(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EstQuick3_READ_OFF_ERROR) { warn("In EstQuick3 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In EstQuick3 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In EstQuick3 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_EstQuick3(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_EstQuick3(EstQuick3 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstQuick3_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In EstQuick3 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = EstQuick3_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstQuick3_HIDDEN_MATRIX(mat,i-1,j-4,MATCH); } return EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstQuick3_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i].transition[GW_DELETE2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstQuick3_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i].transition[GW_INSERT2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstQuick3_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i].transition[GW_MATCH2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstQuick3_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in EstQuick3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstQuick3_HIDDEN_MATRIX(mat,i - 0,j - 4,INSERT) ) { *reti = i - 0; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstQuick3_HIDDEN_MATRIX(mat,i-0,j-4,INSERT); } return EstQuick3_HIDDEN_MATRIX(mat,i - 0,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstQuick3_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstQuick3_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return EstQuick3_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } temp = cscore - ((mat->query->seg[i].transition[GW_INSERT2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstQuick3_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstQuick3_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return EstQuick3_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i].transition[GW_MATCH2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstQuick3_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstQuick3_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return EstQuick3_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in EstQuick3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i].transition[GW_DELETE2DELETE]) - (0); if( temp == EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstQuick3_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i].transition[GW_MATCH2DELETE]) - (0); if( temp == EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstQuick3_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return EstQuick3_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in EstQuick3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstQuick3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_EstQuick3(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_EstQuick3(EstQuick3 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > EstQuick3_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_EstQuick3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EstQuick3_READ_OFF_ERROR) { warn("In special strip read EstQuick3, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < EstQuick3_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read EstQuick3, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_EstQuick3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_EstQuick3(EstQuick3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = EstQuick3_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for EstQuick3, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In EstQuick3 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = EstQuick3_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source MATCH is not a special */ default: warn("Major problem (!) - in EstQuick3 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_EstQuick3(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_EstQuick3(EstQuick3 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = EstQuick3_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In EstQuick3 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i].transition[GW_START2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstQuick3_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstQuick3_DC_SHADOW_SPECIAL(mat,i-1,j-3,START); } return EstQuick3_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstQuick3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstQuick3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Source DELETE is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstQuick3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstQuick3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_EstQuick3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_EstQuick3(EstQuick3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_EstQuick3(mat,starti,startj,stopi,stopj); EstQuick3_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstQuick3_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; EstQuick3_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; EstQuick3_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = EstQuick3_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstQuick3_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstQuick3_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i].transition[GW_DELETE2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstQuick3_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstQuick3_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstQuick3_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstQuick3_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstQuick3_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstQuick3_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstQuick3_HIDDEN_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstQuick3_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstQuick3_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i].transition[GW_MATCH2DELETE]; /* From state DELETE to state DELETE */ temp = EstQuick3_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i].transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstQuick3_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } } return; } /* Function: init_hidden_EstQuick3(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_EstQuick3(EstQuick3 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-4);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { EstQuick3_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; EstQuick3_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; EstQuick3_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; } } return; } /* Function: full_dc_EstQuick3(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_EstQuick3 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_EstQuick3 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [EstQuick3 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_EstQuick3(EstQuick3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_EstQuick3"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 20) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_EstQuick3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_EstQuick3(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_EstQuick3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for EstQuick3, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= EstQuick3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= EstQuick3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = EstQuick3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_EstQuick3(mat,EstQuick3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),EstQuick3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),EstQuick3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_EstQuick3(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_EstQuick3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_EstQuick3(EstQuick3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_EstQuick3(mat); EstQuick3_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_EstQuick3(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_EstQuick3(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_EstQuick3(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_EstQuick3(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_EstQuick3(EstQuick3 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<4;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstQuick3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); EstQuick3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); EstQuick3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( j - 3 <= mergej) { EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i].transition[GW_DELETE2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } } /* Add any movement independant score */ EstQuick3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = EstQuick3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); if( j - 3 <= mergej) { EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,k); } } /* Add any movement independant score */ EstQuick3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i].transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i].transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ EstQuick3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_EstQuick3(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_EstQuick3(EstQuick3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstQuick3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstQuick3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstQuick3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i].transition[GW_DELETE2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state MATCH to state MATCH */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstQuick3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstQuick3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state INSERT to state INSERT */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstQuick3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i].transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state DELETE to state DELETE */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i].transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstQuick3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstQuick3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_EstQuick3(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_EstQuick3(EstQuick3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstQuick3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstQuick3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstQuick3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i].transition[GW_DELETE2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstQuick3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstQuick3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstQuick3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i].transition[GW_MATCH2DELETE]; /* From state DELETE to state DELETE */ temp = EstQuick3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i].transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstQuick3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_EstQuick3(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * */ } void init_dc_EstQuick3(EstQuick3 * mat) { register int i; register int j; register int k; for(j=0;j<6;j++) { for(i=(-1);iquery->len;i++) { EstQuick3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstQuick3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstQuick3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; for(k=0;k<7;k++) { EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); } } } return; } /* Function: start_end_find_end_EstQuick3(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [EstQuick3 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_EstQuick3(EstQuick3 * mat,int * endj) { register int j; register int max; register int maxj; max = EstQuick3_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( EstQuick3_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = EstQuick3_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_EstQuick3(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [EstQuick3] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_EstQuick3(EstQuick3 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (4 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (4 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jquery->seg[i].transition[GW_MATCH2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = EstQuick3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = EstQuick3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i].transition[GW_DELETE2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state START to state MATCH */ temp = EstQuick3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i].transition[GW_START2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state MATCH to state MATCH */ temp = EstQuick3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = EstQuick3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstQuick3_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i].transition[GW_MATCH2END]) + (0) ; if( temp > EstQuick3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstQuick3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstQuick3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); EstQuick3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); EstQuick3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstQuick3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstQuick3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstQuick3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = EstQuick3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state INSERT to state INSERT */ temp = EstQuick3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = EstQuick3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstQuick3_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstQuick3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i].transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state DELETE to state DELETE */ temp = EstQuick3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i].transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstQuick3_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) EstQuick3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_EstQuick3(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * */ void init_start_end_linear_EstQuick3(EstQuick3 * mat) { register int i; register int j; for(j=0;j<6;j++) { for(i=(-1);iquery->len;i++) { EstQuick3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); EstQuick3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); EstQuick3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; EstQuick3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); } } for(j=(-4);jtarget->seq->len;j++) { EstQuick3_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; EstQuick3_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; EstQuick3_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_EstQuick3(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_EstQuick3(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_EstQuick3(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","END" }; /* Function: AlnConvertSet_EstQuick3(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","END" }; AlnConvertSet * AlnConvertSet_EstQuick3(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; return out; } /* Function: PackAln_read_Expl_EstQuick3(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_EstQuick3(EstQuick3 * mat) { EstQuick3_access_func_holder holder; holder.access_main = EstQuick3_explicit_access_main; holder.access_special = EstQuick3_explicit_access_special; return PackAln_read_generic_EstQuick3(mat,holder); } /* Function: EstQuick3_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstQuick3_explicit_access_main(EstQuick3 * mat,int i,int j,int state) { return EstQuick3_EXPL_MATRIX(mat,i,j,state); } /* Function: EstQuick3_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstQuick3_explicit_access_special(EstQuick3 * mat,int i,int j,int state) { return EstQuick3_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_EstQuick3(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: h [UNKN ] Undocumented argument [EstQuick3_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_EstQuick3(EstQuick3 * mat,EstQuick3_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_EstQuick3(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in EstQuick3_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_EstQuick3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_EstQuick3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == EstQuick3_READ_OFF_ERROR || j == EstQuick3_READ_OFF_ERROR || state == EstQuick3_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in EstQuick3_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_EstQuick3(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [EstQuick3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_EstQuick3(EstQuick3 * mat,int * ri,int * rj,int * state,boolean * isspecial,EstQuick3_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: EstQuick3_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void EstQuick3_debug_show_matrix(EstQuick3 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",EstQuick3_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",EstQuick3_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",EstQuick3_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_EstQuick3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EstQuick3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_EstQuick3(EstQuick3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstQuick3_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstQuick3_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In EstQuick3 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH); } return (*h.access_main)(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } temp = cscore - ((mat->query->seg[i].transition[GW_START2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START); } return (*h.access_main)(mat,i - 1,j - 3,START); } temp = cscore - ((mat->query->seg[i].transition[GW_DELETE2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i].transition[GW_INSERT2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i].transition[GW_MATCH2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in EstQuick3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,INSERT) ) { *reti = i - 0; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INSERT); } return (*h.access_main)(mat,i - 0,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - ((mat->query->seg[i].transition[GW_INSERT2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i].transition[GW_MATCH2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in EstQuick3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i].transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i].transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in EstQuick3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstQuick3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_EstQuick3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EstQuick3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_EstQuick3(EstQuick3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstQuick3_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstQuick3_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In EstQuick3 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i].transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in EstQuick3 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_EstQuick3(mat) * * Descrip: This function calculates the EstQuick3 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EstQuick3 * * * Arg: mat [UNKN ] EstQuick3 which contains explicit basematrix memory [EstQuick3 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_EstQuick3(EstQuick3 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EstQuick3, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("EstQuick3 Matrix calculation: "); for(j=0;jquery->seg[i].transition[GW_MATCH2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstQuick3_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstQuick3_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i].transition[GW_DELETE2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstQuick3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i].transition[GW_START2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstQuick3_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstQuick3_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstQuick3_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i].transition[GW_MATCH2END]) + (0) ; if( temp > EstQuick3_EXPL_SPECIAL(mat,i,j,END) ) { EstQuick3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstQuick3_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstQuick3_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstQuick3_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstQuick3_EXPL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstQuick3_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstQuick3_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i].transition[GW_MATCH2DELETE]; /* From state DELETE to state DELETE */ temp = EstQuick3_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i].transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstQuick3_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_EstQuick3(mat,dpenv) * * Descrip: This function calculates the EstQuick3 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EstQuick3 which contains explicit basematrix memory [EstQuick3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_EstQuick3(EstQuick3 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EstQuick3, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-4;jleni;i++) { EstQuick3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstQuick3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstQuick3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j=-4;jlenj;j++) { EstQuick3_EXPL_SPECIAL(mat,i,j,START) = 0; EstQuick3_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("EstQuick3 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { EstQuick3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstQuick3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstQuick3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = EstQuick3_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstQuick3_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstQuick3_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i].transition[GW_DELETE2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstQuick3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i].transition[GW_START2MATCH]+mat->query->seg[i].match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstQuick3_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstQuick3_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstQuick3_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i].transition[GW_MATCH2END]) + (0) ; if( temp > EstQuick3_EXPL_SPECIAL(mat,i,j,END) ) { EstQuick3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstQuick3_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i].transition[GW_MATCH2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstQuick3_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i].transition[GW_INSERT2INSERT]+mat->query->seg[i].insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstQuick3_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstQuick3_EXPL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstQuick3_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstQuick3_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i].transition[GW_MATCH2DELETE]; /* From state DELETE to state DELETE */ temp = EstQuick3_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i].transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstQuick3_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: EstQuick3_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstQuick3 *] * */ EstQuick3 * EstQuick3_alloc(void) { EstQuick3 * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EstQuick3 *) ckalloc (sizeof(EstQuick3))) == NULL) { warn("EstQuick3_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_EstQuick3(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstQuick3 *] * * Return [UNKN ] Undocumented return value [EstQuick3 *] * */ EstQuick3 * free_EstQuick3(EstQuick3 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EstQuick3 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->cp is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/estquick3.h0000644000175000001440000004472110670453713016225 0ustar philippusers#ifndef DYNAMITEestquick3HEADERFILE #define DYNAMITEestquick3HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "cdparser.h" #include "genewisemodel.h" #include "gwquickdb.h" struct Wise2_EstQuick3 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GeneWiseScoreFlat* query; ComplexSequence* target; cDNAParserScore * cp; } ; /* EstQuick3 defined */ #ifndef DYNAMITE_DEFINED_EstQuick3 typedef struct Wise2_EstQuick3 Wise2_EstQuick3; #define EstQuick3 Wise2_EstQuick3 #define DYNAMITE_DEFINED_EstQuick3 #endif #ifdef PTHREAD struct thread_pool_holder_EstQuick3 { GeneWiseScoreFlat* query; /* Query object placeholder */ GeneWiseQuickDB* querydb; /* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ cDNADB* targetdb; /* Target database object */ boolean target_init; cDNAParserScore * cp; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_EstQuick3_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(EstQuick3*,int,int,int); int (*access_special)(EstQuick3*,int,int,int); } ; /* EstQuick3_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_EstQuick3_access_func_holder typedef struct Wise2_EstQuick3_access_func_holder Wise2_EstQuick3_access_func_holder; #define EstQuick3_access_func_holder Wise2_EstQuick3_access_func_holder #define DYNAMITE_DEFINED_EstQuick3_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_EstQuick3(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_EstQuick3(EstQuick3 * mat); #define PackAln_read_Shatter_EstQuick3 Wise2_PackAln_read_Shatter_EstQuick3 /* Function: calculate_shatter_EstQuick3(mat,dpenv) * * Descrip: This function calculates the EstQuick3 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EstQuick3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_EstQuick3(EstQuick3 * mat,DPEnvelope * dpenv); #define calculate_shatter_EstQuick3 Wise2_calculate_shatter_EstQuick3 /* Function: search_EstQuick3(dbsi,out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstQuick3 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseQuickDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_EstQuick3(DBSearchImpl * dbsi,Hscore * out,GeneWiseQuickDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp); #define search_EstQuick3 Wise2_search_EstQuick3 /* Function: serial_search_EstQuick3(out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstQuick3 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseQuickDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_EstQuick3(Hscore * out,GeneWiseQuickDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp); #define serial_search_EstQuick3 Wise2_serial_search_EstQuick3 /* Function: PackAln_bestmemory_EstQuick3(query,target,cp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EstQuick3 * * * Arg: query [UNKN ] query data structure [GeneWiseScoreFlat*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_EstQuick3(GeneWiseScoreFlat* query,ComplexSequence* target ,cDNAParserScore * cp,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_EstQuick3 Wise2_PackAln_bestmemory_EstQuick3 /* Function: allocate_Expl_EstQuick3(query,target,cp,dpri) * * Descrip: This function allocates the EstQuick3 structure * and the basematrix area for explicit memory implementations * It calls /allocate_EstQuick3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScoreFlat*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EstQuick3 *] * */ EstQuick3 * Wise2_allocate_Expl_EstQuick3(GeneWiseScoreFlat* query,ComplexSequence* target ,cDNAParserScore * cp,DPRunImpl * dpri); #define allocate_Expl_EstQuick3 Wise2_allocate_Expl_EstQuick3 /* Function: recalculate_PackAln_EstQuick3(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EstQuick3 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * */ void Wise2_recalculate_PackAln_EstQuick3(PackAln * pal,EstQuick3 * mat); #define recalculate_PackAln_EstQuick3 Wise2_recalculate_PackAln_EstQuick3 /* Function: allocate_Small_EstQuick3(query,target,cp) * * Descrip: This function allocates the EstQuick3 structure * and the basematrix area for a small memory implementations * It calls /allocate_EstQuick3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScoreFlat*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstQuick3 *] * */ EstQuick3 * Wise2_allocate_Small_EstQuick3(GeneWiseScoreFlat* query,ComplexSequence* target ,cDNAParserScore * cp); #define allocate_Small_EstQuick3 Wise2_allocate_Small_EstQuick3 /* Function: PackAln_calculate_Small_EstQuick3(mat,dpenv) * * Descrip: This function calculates an alignment for EstQuick3 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EstQuick3 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EstQuick3 * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_EstQuick3(EstQuick3 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_EstQuick3 Wise2_PackAln_calculate_Small_EstQuick3 /* Function: AlnRangeSet_calculate_Small_EstQuick3(mat) * * Descrip: This function calculates an alignment for EstQuick3 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EstQuick3 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EstQuick3 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EstQuick3 * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_EstQuick3(EstQuick3 * mat); #define AlnRangeSet_calculate_Small_EstQuick3 Wise2_AlnRangeSet_calculate_Small_EstQuick3 /* Function: AlnRangeSet_from_EstQuick3(mat) * * Descrip: This function reads off a start/end structure * for EstQuick3 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EstQuick3 * If you have not calculated the matrix use * /AlnRange_calculate_Small_EstQuick3 * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_EstQuick3(EstQuick3 * mat); #define AlnRangeSet_from_EstQuick3 Wise2_AlnRangeSet_from_EstQuick3 /* Function: convert_PackAln_to_AlnBlock_EstQuick3(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_EstQuick3(PackAln * pal); #define convert_PackAln_to_AlnBlock_EstQuick3 Wise2_convert_PackAln_to_AlnBlock_EstQuick3 /* Function: PackAln_read_Expl_EstQuick3(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_EstQuick3(EstQuick3 * mat); #define PackAln_read_Expl_EstQuick3 Wise2_PackAln_read_Expl_EstQuick3 /* Function: PackAln_read_generic_EstQuick3(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstQuick3 *] * Arg: h [UNKN ] Undocumented argument [EstQuick3_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_EstQuick3(EstQuick3 * mat,EstQuick3_access_func_holder h); #define PackAln_read_generic_EstQuick3 Wise2_PackAln_read_generic_EstQuick3 /* Function: calculate_EstQuick3(mat) * * Descrip: This function calculates the EstQuick3 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EstQuick3 * * * Arg: mat [UNKN ] EstQuick3 which contains explicit basematrix memory [EstQuick3 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_EstQuick3(EstQuick3 * mat); #define calculate_EstQuick3 Wise2_calculate_EstQuick3 /* Function: calculate_dpenv_EstQuick3(mat,dpenv) * * Descrip: This function calculates the EstQuick3 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EstQuick3 which contains explicit basematrix memory [EstQuick3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_EstQuick3(EstQuick3 * mat,DPEnvelope * dpenv); #define calculate_dpenv_EstQuick3 Wise2_calculate_dpenv_EstQuick3 /* Function: EstQuick3_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstQuick3 *] * */ EstQuick3 * Wise2_EstQuick3_alloc(void); #define EstQuick3_alloc Wise2_EstQuick3_alloc /* Function: free_EstQuick3(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstQuick3 *] * * Return [UNKN ] Undocumented return value [EstQuick3 *] * */ EstQuick3 * Wise2_free_EstQuick3(EstQuick3 * obj); #define free_EstQuick3 Wise2_free_EstQuick3 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_EstQuick3_shatter_access_main(EstQuick3 * mat,int i,int j,int state); #define EstQuick3_shatter_access_main Wise2_EstQuick3_shatter_access_main int Wise2_EstQuick3_shatter_access_special(EstQuick3 * mat,int i,int j,int state); #define EstQuick3_shatter_access_special Wise2_EstQuick3_shatter_access_special void * Wise2_thread_loop_EstQuick3(void * ptr); #define thread_loop_EstQuick3 Wise2_thread_loop_EstQuick3 int Wise2_score_only_EstQuick3(GeneWiseScoreFlat* query,ComplexSequence* target ,cDNAParserScore * cp); #define score_only_EstQuick3 Wise2_score_only_EstQuick3 EstQuick3 * Wise2_allocate_EstQuick3_only(GeneWiseScoreFlat* query,ComplexSequence* target ,cDNAParserScore * cp); #define allocate_EstQuick3_only Wise2_allocate_EstQuick3_only void Wise2_init_EstQuick3(EstQuick3 * mat); #define init_EstQuick3 Wise2_init_EstQuick3 AlnRange * Wise2_AlnRange_build_EstQuick3(EstQuick3 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_EstQuick3 Wise2_AlnRange_build_EstQuick3 boolean Wise2_read_hidden_EstQuick3(EstQuick3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_EstQuick3 Wise2_read_hidden_EstQuick3 int Wise2_max_hidden_EstQuick3(EstQuick3 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_EstQuick3 Wise2_max_hidden_EstQuick3 boolean Wise2_read_special_strip_EstQuick3(EstQuick3 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_EstQuick3 Wise2_read_special_strip_EstQuick3 int Wise2_max_special_strip_EstQuick3(EstQuick3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_EstQuick3 Wise2_max_special_strip_EstQuick3 int Wise2_max_matrix_to_special_EstQuick3(EstQuick3 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_EstQuick3 Wise2_max_matrix_to_special_EstQuick3 void Wise2_calculate_hidden_EstQuick3(EstQuick3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_EstQuick3 Wise2_calculate_hidden_EstQuick3 void Wise2_init_hidden_EstQuick3(EstQuick3 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_EstQuick3 Wise2_init_hidden_EstQuick3 boolean Wise2_full_dc_EstQuick3(EstQuick3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_EstQuick3 Wise2_full_dc_EstQuick3 boolean Wise2_do_dc_single_pass_EstQuick3(EstQuick3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_EstQuick3 Wise2_do_dc_single_pass_EstQuick3 void Wise2_push_dc_at_merge_EstQuick3(EstQuick3 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_EstQuick3 Wise2_push_dc_at_merge_EstQuick3 void Wise2_follow_on_dc_EstQuick3(EstQuick3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_EstQuick3 Wise2_follow_on_dc_EstQuick3 void Wise2_run_up_dc_EstQuick3(EstQuick3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_EstQuick3 Wise2_run_up_dc_EstQuick3 void Wise2_init_dc_EstQuick3(EstQuick3 * mat); #define init_dc_EstQuick3 Wise2_init_dc_EstQuick3 int Wise2_start_end_find_end_EstQuick3(EstQuick3 * mat,int * endj); #define start_end_find_end_EstQuick3 Wise2_start_end_find_end_EstQuick3 boolean Wise2_dc_optimised_start_end_calc_EstQuick3(EstQuick3 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_EstQuick3 Wise2_dc_optimised_start_end_calc_EstQuick3 void Wise2_init_start_end_linear_EstQuick3(EstQuick3 * mat); #define init_start_end_linear_EstQuick3 Wise2_init_start_end_linear_EstQuick3 AlnConvertSet * Wise2_AlnConvertSet_EstQuick3(void); #define AlnConvertSet_EstQuick3 Wise2_AlnConvertSet_EstQuick3 int Wise2_EstQuick3_explicit_access_main(EstQuick3 * mat,int i,int j,int state); #define EstQuick3_explicit_access_main Wise2_EstQuick3_explicit_access_main int Wise2_EstQuick3_explicit_access_special(EstQuick3 * mat,int i,int j,int state); #define EstQuick3_explicit_access_special Wise2_EstQuick3_explicit_access_special int Wise2_find_end_EstQuick3(EstQuick3 * mat,int * ri,int * rj,int * state,boolean * isspecial,EstQuick3_access_func_holder h); #define find_end_EstQuick3 Wise2_find_end_EstQuick3 void Wise2_EstQuick3_debug_show_matrix(EstQuick3 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define EstQuick3_debug_show_matrix Wise2_EstQuick3_debug_show_matrix int Wise2_max_calc_EstQuick3(EstQuick3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstQuick3_access_func_holder h); #define max_calc_EstQuick3 Wise2_max_calc_EstQuick3 int Wise2_max_calc_special_EstQuick3(EstQuick3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstQuick3_access_func_holder h); #define max_calc_special_EstQuick3 Wise2_max_calc_special_EstQuick3 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/dbadisplay.c0000644000175000001440000002414010670453713016412 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dbadisplay.h" /* Function: show_pretty_dba_align(alb,one,two,ofp) * * Descrip: Shows an alignment of from the dba algorithm in * pretty formatted ascii text * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: one [UNKN ] Undocumented argument [Sequence *] * Arg: two [UNKN ] Undocumented argument [Sequence *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 15 "dbadisplay.dy" boolean show_pretty_dba_align(AlnBlock * alb,Sequence * one,Sequence * two,FILE * ofp) { boolean ret; btCanvas * btc; btc = new_Ascii_btCanvas(ofp,20,50,5,3); /*+6 in case we want to put in numbers */ ret = show_pretty_dba_align_btcanvas(btc,alb,one,two,0); free_btCanvas(btc); return ret; } /* Function: is_unmatched_block(alc) * * Descrip: tests whether this is a dba unmatched block * * * Arg: alc [UNKN ] Undocumented argument [AlnColumn *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 33 "dbadisplay.dy" boolean is_unmatched_block(AlnColumn * alc) { if( strcmp(alc->alu[0]->text_label,"UM") == 0 ) return TRUE; if( strcmp(alc->alu[0]->text_label,"UI") == 0 ) return TRUE; if( strcmp(alc->alu[1]->text_label,"UM") == 0 ) return TRUE; if( strcmp(alc->alu[1]->text_label,"UI") == 0 ) return TRUE; return FALSE; } /* Function: show_pretty_Seq_dba_align_btcanvas(alb,one,two,btc) * * Descrip: Different func signature for show_pretty * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: one [UNKN ] Undocumented argument [Sequence *] * Arg: two [UNKN ] Undocumented argument [Sequence *] * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 51 "dbadisplay.dy" boolean show_pretty_Seq_dba_align_btcanvas(AlnBlock * alb,Sequence * one,Sequence * two,btCanvas * btc) { return show_pretty_dba_align_btcanvas(btc,alb,one,two,1); } /* Function: show_pretty_dba_align_btcanvas(btc,alb,one,two,blast_compatible) * * Descrip: Shows the dba alignment on the block text * canvas * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: one [UNKN ] Undocumented argument [Sequence *] * Arg: two [UNKN ] Undocumented argument [Sequence *] * Arg: blast_compatible [UNKN ] Undocumented argument [boolean] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 61 "dbadisplay.dy" boolean show_pretty_dba_align_btcanvas(btCanvas * btc,AlnBlock * alb,Sequence * one,Sequence * two,boolean blast_compatible) { AlnColumn * alc; AlnColumn * end_alc; AlnUnit * q; AlnUnit * t; char buffer[14]; boolean at_start = TRUE; boolean new_block; boolean added_hyphen; /* Added NJ020724 */ boolean is_reversed; btPasteArea * btp; if( two->offset > two->end ) { is_reversed = TRUE; } for(alc=alb->start;alc != NULL;) { /** loop over unmatched portions **/ new_block = FALSE; for(; alc != NULL && is_unmatched_block(alc) == TRUE;alc = alc->next) new_block = TRUE; if( alc == NULL ) break; if( strcmp(alc->alu[0]->text_label,"END") == 0 ) { end_alc = alc; alc = NULL; break; } if( new_block == TRUE && at_start == FALSE ) { /* add in block separator */ btp = get_reserved_left_btCanvas(btc); paste_string_btPasteArea(btp,0,1,">-----------<",BC_RIGHT,0); free_btPasteArea(btp); advance_line_btCanvas(btc); } at_start = FALSE; /** put names in **/ btp = get_reserved_left_btCanvas(btc); if( blast_compatible ) { paste_string_btPasteArea(btp,0,0,"Query:",BC_RIGHT,0); paste_string_btPasteArea(btp,0,2,"Sbjct:",BC_RIGHT,0); } else { paste_string_btPasteArea(btp,0,0,one->name,BC_RIGHT,0); paste_string_btPasteArea(btp,0,2,two->name,BC_RIGHT,0); } sprintf(buffer,"%d",alc->alu[0]->start+1+1); paste_string_btPasteArea(btp,12,0,buffer,BC_RIGHT,0); if( two->offset < two->end ) { sprintf(buffer,"%d",alc->alu[1]->start+1+1); } else { sprintf(buffer,"-%d",two->offset - (alc->alu[1]->start+1)); } paste_string_btPasteArea(btp,12,2,buffer,BC_RIGHT,0); if( strcmp(alc->alu[0]->text_label,"MM65") == 0 ) { paste_string_btPasteArea(btp,17,1,"A",BC_RIGHT,0); } else if ( strcmp(alc->alu[0]->text_label,"MM75") == 0 ) { paste_string_btPasteArea(btp,17,1,"B",BC_RIGHT,0); } else if ( strcmp(alc->alu[0]->text_label,"MM85") == 0 ) { paste_string_btPasteArea(btp,17,1,"C",BC_RIGHT,0); } else if ( strcmp(alc->alu[0]->text_label,"MM95") == 0 ) { paste_string_btPasteArea(btp,17,1,"D",BC_RIGHT,0); } else if ( strcmp(alc->alu[0]->text_label,"MM55") == 0 ) { paste_string_btPasteArea(btp,17,1,"a",BC_RIGHT,0); } else if ( strstr(alc->alu[0]->text_label,"MATCH") != NULL ) { paste_string_btPasteArea(btp,17,1,"M",BC_RIGHT,0); } else { warn("Weird label in dba match block at start of block %s",alc->alu[0]->text_label); paste_string_btPasteArea(btp,17,1,"??",BC_RIGHT,0); } free_btPasteArea(btp); /** now loop over this block **/ for(;alc != NULL && can_get_paste_area_btCanvas(btc,1) == TRUE;alc=alc->next) { q = alc->alu[0]; t = alc->alu[1]; /* * at the end, break */ if( strcmp(q->text_label,"END") == 0 ) { end_alc = alc; alc = NULL; break; } /* Unmatched and break */ if( q->text_label[0] == 'U' ) { break; } /* * Get the paste area, length 1, depth will be 3 */ btp = get_paste_area_btCanvas(btc,1); /* * Change NJ020724 * Hack to fix indel bug. * PROBLEM: Inserts were added to the wrong strand, and nucleotides doubled on the other strand. * SOLUTION: When an MI label is found, a hyphen is added to the OTHER strand. A boolean (hyphen_added) * was introduced to avoid overwriting hyphens added to the target strand. * This is probably not the most elegant solution, but what's a poor sod like me to do? */ added_hyphen = FALSE; if( strstartcmp(q->text_label,"MM") == 0 || strstr(q->text_label,"MATCH") != NULL ) { if( strstr(q->text_label,"SPACER") != NULL ) paste_char_btPasteArea(btp,0,0,tolower((int)one->seq[q->start+1]),0); else paste_char_btPasteArea(btp,0,0,toupper((int)one->seq[q->start+1]),0); } else { /** is insert- we could check **/ if( strstartcmp(q->text_label,"MI") != 0 && strstr(q->text_label,"INSERT") == NULL ) { warn("Got an uninterpretable label, %s",q->text_label); paste_char_btPasteArea(btp,0,0,'?',0); } else { if( strstr(q->text_label,"SPACER") != NULL ) paste_char_btPasteArea(btp,0,0,tolower((int)one->seq[q->start+1]),0); /* Still got to add the nucleotide to this sequence */ else paste_char_btPasteArea(btp,0,0,toupper((int)one->seq[q->start+1]),0); paste_char_btPasteArea(btp,0,2,'-',0); /* Add a - to the OTHER sequence. */ added_hyphen = TRUE; /* Set flag to avoid overwriting the hyphen when checking the target sequence below */ } } /* * Write in the target sequence * */ if( strstartcmp(t->text_label,"MM") == 0 || strstr(t->text_label,"MATCH") != NULL ) { /* Check if a hyphen has already been added */ if (added_hyphen == FALSE) { if( strstr(t->text_label,"SPACER") != NULL ) paste_char_btPasteArea(btp,0,2,tolower((int)two->seq[t->start+1]),0); else paste_char_btPasteArea(btp,0,2,toupper((int)two->seq[t->start+1]),0); } } else { /** is insert- we could check **/ if( strstartcmp(t->text_label,"MI") != 0 && strstr(t->text_label,"INSERT") == NULL) { warn("Got an uninterpretable label, %s",t->text_label); paste_char_btPasteArea(btp,0,2,'?',0); } else { if( strstr(t->text_label,"SPACER") != NULL ) paste_char_btPasteArea(btp,0,2,tolower((int)two->seq[t->start+1]),0); /* Still got to add the nucleotide to this sequence */ else paste_char_btPasteArea(btp,0,2,toupper((int)two->seq[t->start+1]),0); paste_char_btPasteArea(btp,0,0,'-',0); /* Add a - to the OTHER sequence. This overwrites what was pasted above */ } } /* * END change NJ020724 */ /* * Match line */ if( (strstartcmp(q->text_label,"MM") == 0 && strstartcmp(t->text_label,"MM") == 0) || (strstr(q->text_label,"MATCH") != NULL && strstr(t->text_label,"MATCH") != NULL && strstr(q->text_label,"SPACER") == NULL) ) { if( strstr(q->text_label,"MOTIF") != NULL ) { paste_char_btPasteArea(btp,0,1,'*',0); } else if( one->seq[q->start+1] == two->seq[t->start+1] ) { paste_char_btPasteArea(btp,0,1,two->seq[t->start+1],0); } else { paste_char_btPasteArea(btp,0,1,' ',0); } } else paste_char_btPasteArea(btp,0,1,' ',0); free_btPasteArea(btp); } /* end of for this block */ /* * BEGIN added by Chuah Aaron to make it comply with SearchIO parsing */ if( blast_compatible ) { btp = get_reserved_right_btCanvas(btc); if( alc != NULL ) { end_alc = alc; } assert(end_alc); // buffer[0]='0'; buffer[1]=0; //hack to get it to work within 70 columns //Remove the line above and uncomment the 2slash-commented lines below to print meaningful numbers sprintf(buffer,"%d",end_alc->alu[0]->start+1); paste_string_btPasteArea(btp,0,0,buffer,BC_RIGHT,0); if( two->offset < two->end ) { sprintf(buffer,"%d",end_alc->alu[1]->start+1); } else { sprintf(buffer,"-%d",two->offset - (end_alc->alu[1]->start+1)); } paste_string_btPasteArea(btp,0,2,buffer,BC_RIGHT,0); free_btPasteArea(btp); /* * END added by Chuah Aaron */ } advance_line_btCanvas(btc); } /* end of for the alignment */ return TRUE; /* we never returned false. Ooops! */ } # line 328 "dbadisplay.c" #ifdef _cplusplus } #endif wise-2.4.1/src/models/dbadisplay.h0000644000175000001440000000441310670453713016420 0ustar philippusers#ifndef DYNAMITEdbadisplayHEADERFILE #define DYNAMITEdbadisplayHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: show_pretty_dba_align(alb,one,two,ofp) * * Descrip: Shows an alignment of from the dba algorithm in * pretty formatted ascii text * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: one [UNKN ] Undocumented argument [Sequence *] * Arg: two [UNKN ] Undocumented argument [Sequence *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_show_pretty_dba_align(AlnBlock * alb,Sequence * one,Sequence * two,FILE * ofp); #define show_pretty_dba_align Wise2_show_pretty_dba_align /* Function: show_pretty_Seq_dba_align_btcanvas(alb,one,two,btc) * * Descrip: Different func signature for show_pretty * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: one [UNKN ] Undocumented argument [Sequence *] * Arg: two [UNKN ] Undocumented argument [Sequence *] * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_show_pretty_Seq_dba_align_btcanvas(AlnBlock * alb,Sequence * one,Sequence * two,btCanvas * btc); #define show_pretty_Seq_dba_align_btcanvas Wise2_show_pretty_Seq_dba_align_btcanvas /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_is_unmatched_block(AlnColumn * alc); #define is_unmatched_block Wise2_is_unmatched_block boolean Wise2_show_pretty_dba_align_btcanvas(btCanvas * btc,AlnBlock * alb,Sequence * one,Sequence * two,boolean blast_compatible); #define show_pretty_dba_align_btcanvas Wise2_show_pretty_dba_align_btcanvas #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/pba.c0000644000175000001440000053030710670453714015050 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "pba.h" # line 6 "pba.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define BLOCK_1 0 #define BLOCK_2 1 #define BLOCK_3 2 #define UNALIGNED 3 #define START 0 #define END 1 #define ProteinBlockAligner_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*4)+STATE][i+1] #define ProteinBlockAligner_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define ProteinBlockAligner_READ_OFF_ERROR -3 #define ProteinBlockAligner_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*4)+STATE] #define ProteinBlockAligner_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define ProteinBlockAligner_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define ProteinBlockAligner_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_ProteinBlockAligner(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_ProteinBlockAligner(ProteinBlockAligner * mat) { ProteinBlockAligner_access_func_holder holder; holder.access_main = ProteinBlockAligner_shatter_access_main; holder.access_special = ProteinBlockAligner_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_ProteinBlockAligner(mat,holder); } /* Function: ProteinBlockAligner_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ProteinBlockAligner_shatter_access_main(ProteinBlockAligner * mat,int i,int j,int state) { return ProteinBlockAligner_SHATTER_MATRIX(mat,i,j,state); } /* Function: ProteinBlockAligner_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ProteinBlockAligner_shatter_access_special(ProteinBlockAligner * mat,int i,int j,int state) { return ProteinBlockAligner_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_ProteinBlockAligner(mat,dpenv) * * Descrip: This function calculates the ProteinBlockAligner matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [ProteinBlockAligner *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_ProteinBlockAligner(ProteinBlockAligner * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,4,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("ProteinBlockAligner Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state BLOCK_1 */ /* setting first movement to score */ score = SIG_1_1[BLOCK_1] + mat->b_self_trans; /* From state START to state BLOCK_1 */ temp = ProteinBlockAligner_SHATTER_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* From state UNALIGNED to state BLOCK_1 */ temp = SIG_1_1[UNALIGNED] + mat->bentry; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_1 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); SIG_0_0[BLOCK_1] = score; /* state BLOCK_1 is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinBlockAligner_SHATTER_SPECIAL(mat,i,j,END) ) { ProteinBlockAligner_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state BLOCK_1 */ /* For state BLOCK_2 */ /* setting first movement to score */ score = SIG_1_1[BLOCK_2] + mat->b_self_trans; /* From state BLOCK_1 to state BLOCK_2 */ temp = SIG_1_1[BLOCK_1] + mat->bfor_trans; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_2 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); SIG_0_0[BLOCK_2] = score; /* Finished calculating state BLOCK_2 */ /* For state BLOCK_3 */ /* setting first movement to score */ score = SIG_1_1[BLOCK_3] + mat->b_self_trans; /* From state BLOCK_2 to state BLOCK_3 */ temp = SIG_1_1[BLOCK_2] + mat->bfor_trans; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_3 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); SIG_0_0[BLOCK_3] = score; /* Finished calculating state BLOCK_3 */ /* For state UNALIGNED */ /* setting first movement to score */ score = SIG_0_1[BLOCK_1] + mat->bexit; /* From state BLOCK_1 to state UNALIGNED */ temp = SIG_1_0[BLOCK_1] + mat->bexit; if( temp > score ) { score = temp; } /* From state BLOCK_2 to state UNALIGNED */ temp = SIG_0_1[BLOCK_2] + mat->b3exit; if( temp > score ) { score = temp; } /* From state BLOCK_2 to state UNALIGNED */ temp = SIG_1_0[BLOCK_2] + mat->b3exit; if( temp > score ) { score = temp; } /* From state UNALIGNED to state UNALIGNED */ temp = SIG_0_1[UNALIGNED] + 0; if( temp > score ) { score = temp; } /* From state UNALIGNED to state UNALIGNED */ temp = SIG_1_0[UNALIGNED] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNALIGNED */ /* Add any movement independant score and put away */ SIG_0_0[UNALIGNED] = score; /* state UNALIGNED is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinBlockAligner_SHATTER_SPECIAL(mat,i,j,END) ) { ProteinBlockAligner_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state UNALIGNED */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_ProteinBlockAligner(dbsi,out,querydb,targetdb,m,bentry,bexit,bfor_trans,b_self_trans,b3exit) * * Descrip: This function makes a database search of ProteinBlockAligner * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [ProteinDB*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * Arg: m [UNKN ] Undocumented argument [CompMat*] * Arg: bentry [UNKN ] Undocumented argument [Score] * Arg: bexit [UNKN ] Undocumented argument [Score] * Arg: bfor_trans [UNKN ] Undocumented argument [Score] * Arg: b_self_trans [UNKN ] Undocumented argument [Score] * Arg: b3exit [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_ProteinBlockAligner(DBSearchImpl * dbsi,Hscore * out,ProteinDB* querydb,ProteinDB* targetdb ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_ProteinBlockAligner * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_ProteinBlockAligner. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_ProteinBlockAligner. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for ProteinBlockAligner, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_ProteinBlockAligner(out,querydb, targetdb ,m,bentry,bexit,bfor_trans,b_self_trans,b3exit); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_ProteinBlockAligner *) ckalloc(sizeof(struct thread_pool_holder_ProteinBlockAligner)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->m = m; holder->bentry = bentry; holder->bexit = bexit; holder->bfor_trans = bfor_trans; holder->b_self_trans = b_self_trans; holder->b3exit = b3exit; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_ProteinBlockAligner,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for ProteinBlockAligner"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from ProteinBlockAligner",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_ProteinBlockAligner(ptr) * * Descrip: Infinite loop code foreach thread for ProteinBlockAligner * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_ProteinBlockAligner(void * ptr) { struct thread_pool_holder_ProteinBlockAligner * holder; int db_status; int score; DataScore * ds; ComplexSequence* q; ComplexSequence* t; holder = (struct thread_pool_holder_ProteinBlockAligner *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for ProteinBlockAligner"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for ProteinBlockAligner"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->q = init_ProteinDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in ProteinBlockAligner search"); } q = hard_link_ComplexSequence(holder->q); /* get query information into datascore */ dataentry_add_ProteinDB(ds->query,q,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); t = init_ProteinDB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ t = reload_ProteinDB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching ProteinBlockAligner, Reload error on database t, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_ProteinDB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_ComplexSequence(holder->q); /* get the next query object for the next thread */ holder->q = reload_ProteinDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching ProteinBlockAligner, reload error on database q, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_ProteinDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for ProteinBlockAligner"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for ProteinBlockAligner"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_ProteinDB(ds->target,t,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_ProteinBlockAligner(q, t ,holder->m,holder->bentry,holder->bexit,holder->bfor_trans,holder->b_self_trans,holder->b3exit); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for ProteinBlockAligner"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for ProteinBlockAligner"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for ProteinBlockAligner"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_ComplexSequence(q); free_ComplexSequence(t); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for ProteinBlockAligner"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_ProteinBlockAligner(out,querydb,targetdb,m,bentry,bexit,bfor_trans,b_self_trans,b3exit) * * Descrip: This function makes a database search of ProteinBlockAligner * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [ProteinDB*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * Arg: m [UNKN ] Undocumented argument [CompMat*] * Arg: bentry [UNKN ] Undocumented argument [Score] * Arg: bexit [UNKN ] Undocumented argument [Score] * Arg: bfor_trans [UNKN ] Undocumented argument [Score] * Arg: b_self_trans [UNKN ] Undocumented argument [Score] * Arg: b3exit [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_ProteinBlockAligner(Hscore * out,ProteinDB* querydb,ProteinDB* targetdb ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit) { ComplexSequence* q; ComplexSequence* t; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); q = init_ProteinDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching ProteinBlockAligner, got a database reload error on the query [q] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; t = init_ProteinDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching ProteinBlockAligner, got a database init error on the target [t] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_ProteinBlockAligner(q, t , m, bentry, bexit, bfor_trans, b_self_trans, b3exit); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("ProteinBlockAligner search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_ProteinDB(ds->query,q,querydb); dataentry_add_ProteinDB(ds->target,t,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); t = reload_ProteinDB(t,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching ProteinBlockAligner, Reload error on database t, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_ProteinDB(t,targetdb); q = reload_ProteinDB(q,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching ProteinBlockAligner, Reload error on database q, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_ProteinDB(q,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_ProteinBlockAligner(q,t,m,bentry,bexit,bfor_trans,b_self_trans,b3exit) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_ProteinBlockAligner_only * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: m [UNKN ] Resource [CompMat*] * Arg: bentry [UNKN ] Resource [Score] * Arg: bexit [UNKN ] Resource [Score] * Arg: bfor_trans [UNKN ] Resource [Score] * Arg: b_self_trans [UNKN ] Resource [Score] * Arg: b3exit [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_ProteinBlockAligner(ComplexSequence* q,ComplexSequence* t ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit) { int bestscore = NEGI; int i; int j; int k; ProteinBlockAligner * mat; mat = allocate_ProteinBlockAligner_only(q, t , m, bentry, bexit, bfor_trans, b_self_trans, b3exit); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 4,2,2)) == NULL) { warn("Score only matrix for ProteinBlockAligner cannot be allocated, (asking for 1 by %d cells)",mat->leni*4); mat = free_ProteinBlockAligner(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<4;k++) ProteinBlockAligner_VSMALL_MATRIX(mat,i,j,k) = NEGI; } ProteinBlockAligner_VSMALL_SPECIAL(mat,i,j,START) = 0; ProteinBlockAligner_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state BLOCK_1 */ /* setting first movement to score */ score = ProteinBlockAligner_VSMALL_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->b_self_trans; /* From state START to state BLOCK_1 */ temp = ProteinBlockAligner_VSMALL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* From state UNALIGNED to state BLOCK_1 */ temp = ProteinBlockAligner_VSMALL_MATRIX(mat,i-1,j-1,UNALIGNED) + mat->bentry; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_1 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_VSMALL_MATRIX(mat,i,j,BLOCK_1) = score; /* state BLOCK_1 is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinBlockAligner_VSMALL_SPECIAL(mat,i,j,END) ) { ProteinBlockAligner_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state BLOCK_1 */ /* For state BLOCK_2 */ /* setting first movement to score */ score = ProteinBlockAligner_VSMALL_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->b_self_trans; /* From state BLOCK_1 to state BLOCK_2 */ temp = ProteinBlockAligner_VSMALL_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->bfor_trans; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_2 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_VSMALL_MATRIX(mat,i,j,BLOCK_2) = score; /* Finished calculating state BLOCK_2 */ /* For state BLOCK_3 */ /* setting first movement to score */ score = ProteinBlockAligner_VSMALL_MATRIX(mat,i-1,j-1,BLOCK_3) + mat->b_self_trans; /* From state BLOCK_2 to state BLOCK_3 */ temp = ProteinBlockAligner_VSMALL_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->bfor_trans; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_3 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_VSMALL_MATRIX(mat,i,j,BLOCK_3) = score; /* Finished calculating state BLOCK_3 */ /* For state UNALIGNED */ /* setting first movement to score */ score = ProteinBlockAligner_VSMALL_MATRIX(mat,i-0,j-1,BLOCK_1) + mat->bexit; /* From state BLOCK_1 to state UNALIGNED */ temp = ProteinBlockAligner_VSMALL_MATRIX(mat,i-1,j-0,BLOCK_1) + mat->bexit; if( temp > score ) { score = temp; } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_VSMALL_MATRIX(mat,i-0,j-1,BLOCK_2) + mat->b3exit; if( temp > score ) { score = temp; } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_VSMALL_MATRIX(mat,i-1,j-0,BLOCK_2) + mat->b3exit; if( temp > score ) { score = temp; } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_VSMALL_MATRIX(mat,i-0,j-1,UNALIGNED) + 0; if( temp > score ) { score = temp; } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_VSMALL_MATRIX(mat,i-1,j-0,UNALIGNED) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNALIGNED */ /* Add any movement independant score and put away */ ProteinBlockAligner_VSMALL_MATRIX(mat,i,j,UNALIGNED) = score; /* state UNALIGNED is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinBlockAligner_VSMALL_SPECIAL(mat,i,j,END) ) { ProteinBlockAligner_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state UNALIGNED */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < ProteinBlockAligner_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = ProteinBlockAligner_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_ProteinBlockAligner(mat); return bestscore; } /* Function: PackAln_bestmemory_ProteinBlockAligner(q,t,m,bentry,bexit,bfor_trans,b_self_trans,b3exit,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_ProteinBlockAligner * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: m [UNKN ] Resource [CompMat*] * Arg: bentry [UNKN ] Resource [Score] * Arg: bexit [UNKN ] Resource [Score] * Arg: bfor_trans [UNKN ] Resource [Score] * Arg: b_self_trans [UNKN ] Resource [Score] * Arg: b3exit [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_ProteinBlockAligner(ComplexSequence* q,ComplexSequence* t ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; ProteinBlockAligner * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = q->seq->len * t->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 4 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_ProteinBlockAligner(q, t , m, bentry, bexit, bfor_trans, b_self_trans, b3exit,dpri)) == NULL ) { warn("Unable to allocate large ProteinBlockAligner version"); return NULL; } calculate_dpenv_ProteinBlockAligner(mat,dpenv); out = PackAln_read_Expl_ProteinBlockAligner(mat); } else { mat = allocate_ProteinBlockAligner_only(q, t , m, bentry, bexit, bfor_trans, b_self_trans, b3exit); calculate_shatter_ProteinBlockAligner(mat,dpenv); out = PackAln_read_Shatter_ProteinBlockAligner(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_ProteinBlockAligner(q, t , m, bentry, bexit, bfor_trans, b_self_trans, b3exit)) == NULL ) { warn("Unable to allocate small ProteinBlockAligner version"); return NULL; } out = PackAln_calculate_Small_ProteinBlockAligner(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_ProteinBlockAligner(q, t , m, bentry, bexit, bfor_trans, b_self_trans, b3exit,dpri)) == NULL ) { warn("Unable to allocate large ProteinBlockAligner version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_ProteinBlockAligner(mat); out = PackAln_read_Expl_ProteinBlockAligner(mat); } } } mat = free_ProteinBlockAligner(mat); return out; } /* Function: allocate_ProteinBlockAligner_only(q,t,m,bentry,bexit,bfor_trans,b_self_trans,b3exit) * * Descrip: This function only allocates the ProteinBlockAligner structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: m [UNKN ] Resource [CompMat*] * Arg: bentry [UNKN ] Resource [Score] * Arg: bexit [UNKN ] Resource [Score] * Arg: bfor_trans [UNKN ] Resource [Score] * Arg: b_self_trans [UNKN ] Resource [Score] * Arg: b3exit [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [ProteinBlockAligner *] * */ ProteinBlockAligner * allocate_ProteinBlockAligner_only(ComplexSequence* q,ComplexSequence* t ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit) { ProteinBlockAligner * out; if((out= ProteinBlockAligner_alloc()) == NULL) { warn("Allocation of basic ProteinBlockAligner structure failed..."); return NULL; } out->q = q; out->t = t; out->m = m; out->bentry = bentry; out->bexit = bexit; out->bfor_trans = bfor_trans; out->b_self_trans = b_self_trans; out->b3exit = b3exit; out->leni = q->seq->len; out->lenj = t->seq->len; return out; } /* Function: allocate_Expl_ProteinBlockAligner(q,t,m,bentry,bexit,bfor_trans,b_self_trans,b3exit,dpri) * * Descrip: This function allocates the ProteinBlockAligner structure * and the basematrix area for explicit memory implementations * It calls /allocate_ProteinBlockAligner_only * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: m [UNKN ] Resource [CompMat*] * Arg: bentry [UNKN ] Resource [Score] * Arg: bexit [UNKN ] Resource [Score] * Arg: bfor_trans [UNKN ] Resource [Score] * Arg: b_self_trans [UNKN ] Resource [Score] * Arg: b3exit [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [ProteinBlockAligner *] * */ ProteinBlockAligner * allocate_Expl_ProteinBlockAligner(ComplexSequence* q,ComplexSequence* t ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit,DPRunImpl * dpri) { ProteinBlockAligner * out; out = allocate_ProteinBlockAligner_only(q, t , m, bentry, bexit, bfor_trans, b_self_trans, b3exit); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*4 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*4,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix ProteinBlockAligner cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_ProteinBlockAligner(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_ProteinBlockAligner(out); return out; } /* Function: init_ProteinBlockAligner(mat) * * Descrip: This function initates ProteinBlockAligner matrix when in explicit mode * Called in /allocate_Expl_ProteinBlockAligner * * * Arg: mat [UNKN ] ProteinBlockAligner which contains explicit basematrix memory [ProteinBlockAligner *] * */ void init_ProteinBlockAligner(ProteinBlockAligner * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iq->seq->len;i++) { for(j= (-1);j<2;j++) { ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_1) = NEGI; ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_2) = NEGI; ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_3) = NEGI; ProteinBlockAligner_EXPL_MATRIX(mat,i,j,UNALIGNED) = NEGI; } } for(j= (-1);jt->seq->len;j++) { for(i= (-1);i<2;i++) { ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_1) = NEGI; ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_2) = NEGI; ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_3) = NEGI; ProteinBlockAligner_EXPL_MATRIX(mat,i,j,UNALIGNED) = NEGI; } ProteinBlockAligner_EXPL_SPECIAL(mat,i,j,START) = 0; ProteinBlockAligner_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_ProteinBlockAligner(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by ProteinBlockAligner * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * */ void recalculate_PackAln_ProteinBlockAligner(PackAln * pal,ProteinBlockAligner * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case BLOCK_1 : if( offi == 1 && offj == 1 && prev->state == BLOCK_1 ) { pau->score = mat->b_self_trans + (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); continue; } if( offj == 1 && prev->state == (START+4) ) { pau->score = 0 + (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); continue; } if( offi == 1 && offj == 1 && prev->state == UNALIGNED ) { pau->score = mat->bentry + (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); continue; } warn("In recaluclating PackAln with state BLOCK_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case BLOCK_2 : if( offi == 1 && offj == 1 && prev->state == BLOCK_2 ) { pau->score = mat->b_self_trans + (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); continue; } if( offi == 1 && offj == 1 && prev->state == BLOCK_1 ) { pau->score = mat->bfor_trans + (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); continue; } warn("In recaluclating PackAln with state BLOCK_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case BLOCK_3 : if( offi == 1 && offj == 1 && prev->state == BLOCK_3 ) { pau->score = mat->b_self_trans + (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); continue; } if( offi == 1 && offj == 1 && prev->state == BLOCK_2 ) { pau->score = mat->bfor_trans + (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); continue; } warn("In recaluclating PackAln with state BLOCK_3, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UNALIGNED : if( offi == 0 && offj == 1 && prev->state == BLOCK_1 ) { pau->score = mat->bexit + (0); continue; } if( offi == 1 && offj == 0 && prev->state == BLOCK_1 ) { pau->score = mat->bexit + (0); continue; } if( offi == 0 && offj == 1 && prev->state == BLOCK_2 ) { pau->score = mat->b3exit + (0); continue; } if( offi == 1 && offj == 0 && prev->state == BLOCK_2 ) { pau->score = mat->b3exit + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UNALIGNED ) { pau->score = 0 + (0); continue; } if( offi == 1 && offj == 0 && prev->state == UNALIGNED ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state UNALIGNED, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+4) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+4) : if( offj == 0 && prev->state == UNALIGNED ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == BLOCK_1 ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define ProteinBlockAligner_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*4+state]) #define ProteinBlockAligner_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*4+state]) #define ProteinBlockAligner_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define ProteinBlockAligner_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define ProteinBlockAligner_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*4 + state]) #define ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 4) + ((i+1) * 4) + (state)]) #define ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 32) + ((i+1) * 32) + (state * 8) + shadow+1]) #define ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_ProteinBlockAligner(q,t,m,bentry,bexit,bfor_trans,b_self_trans,b3exit) * * Descrip: This function allocates the ProteinBlockAligner structure * and the basematrix area for a small memory implementations * It calls /allocate_ProteinBlockAligner_only * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: m [UNKN ] Resource [CompMat*] * Arg: bentry [UNKN ] Resource [Score] * Arg: bexit [UNKN ] Resource [Score] * Arg: bfor_trans [UNKN ] Resource [Score] * Arg: b_self_trans [UNKN ] Resource [Score] * Arg: b3exit [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [ProteinBlockAligner *] * */ #define ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) ProteinBlockAligner * allocate_Small_ProteinBlockAligner(ComplexSequence* q,ComplexSequence* t ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit) { ProteinBlockAligner * out; out = allocate_ProteinBlockAligner_only(q, t , m, bentry, bexit, bfor_trans, b_self_trans, b3exit); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 4,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix ProteinBlockAligner cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_ProteinBlockAligner(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_ProteinBlockAligner(mat,dpenv) * * Descrip: This function calculates an alignment for ProteinBlockAligner structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_ProteinBlockAligner * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_ProteinBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_ProteinBlockAligner(ProteinBlockAligner * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for ProteinBlockAligner due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_ProteinBlockAligner(mat,dpenv); score = start_end_find_end_ProteinBlockAligner(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_ProteinBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_ProteinBlockAligner(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == ProteinBlockAligner_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_ProteinBlockAligner(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 4; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_ProteinBlockAligner(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_ProteinBlockAligner(mat) * * Descrip: This function calculates an alignment for ProteinBlockAligner structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_ProteinBlockAligner * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_ProteinBlockAligner * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_ProteinBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_ProteinBlockAligner(ProteinBlockAligner * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_ProteinBlockAligner(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_ProteinBlockAligner(mat); return out; } /* Function: AlnRangeSet_from_ProteinBlockAligner(mat) * * Descrip: This function reads off a start/end structure * for ProteinBlockAligner structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_ProteinBlockAligner * If you have not calculated the matrix use * /AlnRange_calculate_Small_ProteinBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_ProteinBlockAligner(ProteinBlockAligner * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_ProteinBlockAligner"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_ProteinBlockAligner(mat,&jpos); state = END; while( (temp = AlnRange_build_ProteinBlockAligner(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_ProteinBlockAligner(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_ProteinBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_ProteinBlockAligner(ProteinBlockAligner * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_ProteinBlockAligner"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_ProteinBlockAligner(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_ProteinBlockAligner alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = ProteinBlockAligner_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_ProteinBlockAligner(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == ProteinBlockAligner_READ_OFF_ERROR) { warn("In AlnRange_build_ProteinBlockAligner alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = ProteinBlockAligner_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_ProteinBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_ProteinBlockAligner(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == ProteinBlockAligner_READ_OFF_ERROR) { warn("In ProteinBlockAligner hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In ProteinBlockAligner hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In ProteinBlockAligner hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_ProteinBlockAligner(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_ProteinBlockAligner(ProteinBlockAligner * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = ProteinBlockAligner_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->q->seq->len || j > mat->t->seq->len) { warn("In ProteinBlockAligner matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = ProteinBlockAligner_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case BLOCK_1 : temp = cscore - (mat->bentry) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,UNALIGNED) ) { *reti = i - 1; *retj = j - 1; *retstate = UNALIGNED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,UNALIGNED); } return ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,UNALIGNED); } /* Not allowing special sources.. skipping START */ temp = cscore - (mat->b_self_trans) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,BLOCK_1) ) { *reti = i - 1; *retj = j - 1; *retstate = BLOCK_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,BLOCK_1); } return ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,BLOCK_1); } warn("Major problem (!) - in ProteinBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); case BLOCK_2 : temp = cscore - (mat->bfor_trans) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,BLOCK_1) ) { *reti = i - 1; *retj = j - 1; *retstate = BLOCK_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,BLOCK_1); } return ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,BLOCK_1); } temp = cscore - (mat->b_self_trans) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,BLOCK_2) ) { *reti = i - 1; *retj = j - 1; *retstate = BLOCK_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,BLOCK_2); } return ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,BLOCK_2); } warn("Major problem (!) - in ProteinBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); case BLOCK_3 : temp = cscore - (mat->bfor_trans) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,BLOCK_2) ) { *reti = i - 1; *retj = j - 1; *retstate = BLOCK_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,BLOCK_2); } return ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,BLOCK_2); } temp = cscore - (mat->b_self_trans) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,BLOCK_3) ) { *reti = i - 1; *retj = j - 1; *retstate = BLOCK_3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,BLOCK_3); } return ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,BLOCK_3); } warn("Major problem (!) - in ProteinBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNALIGNED : temp = cscore - (0) - (0); if( temp == ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 0,UNALIGNED) ) { *reti = i - 1; *retj = j - 0; *retstate = UNALIGNED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-0,UNALIGNED); } return ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 0,UNALIGNED); } temp = cscore - (0) - (0); if( temp == ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 0,j - 1,UNALIGNED) ) { *reti = i - 0; *retj = j - 1; *retstate = UNALIGNED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinBlockAligner_HIDDEN_MATRIX(mat,i-0,j-1,UNALIGNED); } return ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 0,j - 1,UNALIGNED); } temp = cscore - (mat->b3exit) - (0); if( temp == ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 0,BLOCK_2) ) { *reti = i - 1; *retj = j - 0; *retstate = BLOCK_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-0,BLOCK_2); } return ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 0,BLOCK_2); } temp = cscore - (mat->b3exit) - (0); if( temp == ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 0,j - 1,BLOCK_2) ) { *reti = i - 0; *retj = j - 1; *retstate = BLOCK_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinBlockAligner_HIDDEN_MATRIX(mat,i-0,j-1,BLOCK_2); } return ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 0,j - 1,BLOCK_2); } temp = cscore - (mat->bexit) - (0); if( temp == ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 0,BLOCK_1) ) { *reti = i - 1; *retj = j - 0; *retstate = BLOCK_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-0,BLOCK_1); } return ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 0,BLOCK_1); } temp = cscore - (mat->bexit) - (0); if( temp == ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 0,j - 1,BLOCK_1) ) { *reti = i - 0; *retj = j - 1; *retstate = BLOCK_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinBlockAligner_HIDDEN_MATRIX(mat,i-0,j-1,BLOCK_1); } return ProteinBlockAligner_HIDDEN_MATRIX(mat,i - 0,j - 1,BLOCK_1); } warn("Major problem (!) - in ProteinBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in ProteinBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_ProteinBlockAligner(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_ProteinBlockAligner(ProteinBlockAligner * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 4; add_PackAln(out,pau); } max_special_strip_ProteinBlockAligner(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == ProteinBlockAligner_READ_OFF_ERROR) { warn("In special strip read ProteinBlockAligner, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read ProteinBlockAligner, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 4; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_ProteinBlockAligner(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_ProteinBlockAligner(ProteinBlockAligner * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = ProteinBlockAligner_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for ProteinBlockAligner, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->t->seq->len) { warn("In ProteinBlockAligner matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = ProteinBlockAligner_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source BLOCK_1 is not a special */ /* Source UNALIGNED is not a special */ default: warn("Major problem (!) - in ProteinBlockAligner special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_ProteinBlockAligner(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_ProteinBlockAligner(ProteinBlockAligner * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = ProteinBlockAligner_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In ProteinBlockAligner matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case BLOCK_1 : /* Source UNALIGNED is not a special, should not get here! */ temp = cscore - (0) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == ProteinBlockAligner_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - ProteinBlockAligner_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source BLOCK_1 is not a special, should not get here! */ warn("Major problem (!) - in ProteinBlockAligner matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case BLOCK_2 : /* Source BLOCK_1 is not a special, should not get here! */ /* Source BLOCK_2 is not a special, should not get here! */ warn("Major problem (!) - in ProteinBlockAligner matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case BLOCK_3 : /* Source BLOCK_2 is not a special, should not get here! */ /* Source BLOCK_3 is not a special, should not get here! */ warn("Major problem (!) - in ProteinBlockAligner matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNALIGNED : /* Source UNALIGNED is not a special, should not get here! */ /* Source UNALIGNED is not a special, should not get here! */ /* Source BLOCK_2 is not a special, should not get here! */ /* Source BLOCK_2 is not a special, should not get here! */ /* Source BLOCK_1 is not a special, should not get here! */ /* Source BLOCK_1 is not a special, should not get here! */ warn("Major problem (!) - in ProteinBlockAligner matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in ProteinBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_ProteinBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_ProteinBlockAligner(mat,starti,startj,stopi,stopj); ProteinBlockAligner_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ProteinBlockAligner_HIDDEN_MATRIX(mat,i,j,BLOCK_1) = NEGI; ProteinBlockAligner_HIDDEN_MATRIX(mat,i,j,BLOCK_2) = NEGI; ProteinBlockAligner_HIDDEN_MATRIX(mat,i,j,BLOCK_3) = NEGI; ProteinBlockAligner_HIDDEN_MATRIX(mat,i,j,UNALIGNED) = NEGI; continue; } /* end of Is not in envelope */ /* For state BLOCK_1 */ /* setting first movement to score */ score = ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->b_self_trans; /* From state UNALIGNED to state BLOCK_1 */ temp = ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,UNALIGNED) + mat->bentry; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_1 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_HIDDEN_MATRIX(mat,i,j,BLOCK_1) = score; /* Finished calculating state BLOCK_1 */ /* For state BLOCK_2 */ /* setting first movement to score */ score = ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->b_self_trans; /* From state BLOCK_1 to state BLOCK_2 */ temp = ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->bfor_trans; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_2 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_HIDDEN_MATRIX(mat,i,j,BLOCK_2) = score; /* Finished calculating state BLOCK_2 */ /* For state BLOCK_3 */ /* setting first movement to score */ score = ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,BLOCK_3) + mat->b_self_trans; /* From state BLOCK_2 to state BLOCK_3 */ temp = ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->bfor_trans; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_3 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_HIDDEN_MATRIX(mat,i,j,BLOCK_3) = score; /* Finished calculating state BLOCK_3 */ /* For state UNALIGNED */ /* setting first movement to score */ score = ProteinBlockAligner_HIDDEN_MATRIX(mat,i-0,j-1,BLOCK_1) + mat->bexit; /* From state BLOCK_1 to state UNALIGNED */ temp = ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-0,BLOCK_1) + mat->bexit; if( temp > score ) { score = temp; } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_HIDDEN_MATRIX(mat,i-0,j-1,BLOCK_2) + mat->b3exit; if( temp > score ) { score = temp; } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-0,BLOCK_2) + mat->b3exit; if( temp > score ) { score = temp; } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_HIDDEN_MATRIX(mat,i-0,j-1,UNALIGNED) + 0; if( temp > score ) { score = temp; } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_HIDDEN_MATRIX(mat,i-1,j-0,UNALIGNED) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNALIGNED */ /* Add any movement independant score and put away */ ProteinBlockAligner_HIDDEN_MATRIX(mat,i,j,UNALIGNED) = score; /* Finished calculating state UNALIGNED */ } } return; } /* Function: init_hidden_ProteinBlockAligner(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { ProteinBlockAligner_HIDDEN_MATRIX(mat,i,j,BLOCK_1) = NEGI; ProteinBlockAligner_HIDDEN_MATRIX(mat,i,j,BLOCK_2) = NEGI; ProteinBlockAligner_HIDDEN_MATRIX(mat,i,j,BLOCK_3) = NEGI; ProteinBlockAligner_HIDDEN_MATRIX(mat,i,j,UNALIGNED) = NEGI; } } return; } /* Function: full_dc_ProteinBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_ProteinBlockAligner * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_ProteinBlockAligner to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [ProteinBlockAligner *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_ProteinBlockAligner"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_ProteinBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_ProteinBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_ProteinBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for ProteinBlockAligner, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_ProteinBlockAligner(mat,ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_ProteinBlockAligner(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_ProteinBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_ProteinBlockAligner(mat); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_ProteinBlockAligner(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_ProteinBlockAligner(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_ProteinBlockAligner(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_ProteinBlockAligner(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_1) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,0) = (-100); ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,1) = (-100); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_2) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,0) = (-100); ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,1) = (-100); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_3) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,0) = (-100); ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,1) = (-100); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNALIGNED) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,0) = (-100); ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,1) = (-100); continue; } /* end of Is not in envelope */ /* For state BLOCK_1, pushing when j - offj <= mergej */ score = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->b_self_trans; if( j - 1 <= mergej) { ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,0) = i-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,1) = j-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,2) = BLOCK_1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,3) = i; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,4) = j; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,5) = BLOCK_1; } else { for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,k) = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_1,k); } temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,UNALIGNED) + mat->bentry; if( temp > score) { score = temp; if( j - 1 <= mergej) { ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,0) = i-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,1) = j-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,2) = UNALIGNED; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,3) = i; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,4) = j; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,5) = BLOCK_1; } else { for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,k) = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNALIGNED,k); } } /* Add any movement independant score */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_1) = score; /* Finished with state BLOCK_1 */ /* For state BLOCK_2, pushing when j - offj <= mergej */ score = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->b_self_trans; if( j - 1 <= mergej) { ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,0) = i-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,1) = j-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,2) = BLOCK_2; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,3) = i; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,4) = j; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,5) = BLOCK_2; } else { for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,k) = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_2,k); } temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->bfor_trans; if( temp > score) { score = temp; if( j - 1 <= mergej) { ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,0) = i-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,1) = j-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,2) = BLOCK_1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,3) = i; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,4) = j; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,5) = BLOCK_2; } else { for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,k) = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_1,k); } } /* Add any movement independant score */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_2) = score; /* Finished with state BLOCK_2 */ /* For state BLOCK_3, pushing when j - offj <= mergej */ score = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_3) + mat->b_self_trans; if( j - 1 <= mergej) { ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,0) = i-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,1) = j-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,2) = BLOCK_3; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,3) = i; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,4) = j; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,5) = BLOCK_3; } else { for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,k) = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_3,k); } temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->bfor_trans; if( temp > score) { score = temp; if( j - 1 <= mergej) { ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,0) = i-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,1) = j-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,2) = BLOCK_2; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,3) = i; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,4) = j; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,5) = BLOCK_3; } else { for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,k) = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_2,k); } } /* Add any movement independant score */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_3) = score; /* Finished with state BLOCK_3 */ /* For state UNALIGNED, pushing when j - offj <= mergej */ score = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,BLOCK_1) + mat->bexit; if( j - 1 <= mergej) { ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,0) = i-0; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,1) = j-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,2) = BLOCK_1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,3) = i; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,4) = j; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,5) = UNALIGNED; } else { for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,k) = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,BLOCK_1,k); } temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,BLOCK_1) + mat->bexit; if( temp > score) { score = temp; if( j - 0 <= mergej) { ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,0) = i-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,1) = j-0; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,2) = BLOCK_1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,3) = i; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,4) = j; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,5) = UNALIGNED; } else { for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,k) = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,BLOCK_1,k); } } temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,BLOCK_2) + mat->b3exit; if( temp > score) { score = temp; if( j - 1 <= mergej) { ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,0) = i-0; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,1) = j-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,2) = BLOCK_2; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,3) = i; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,4) = j; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,5) = UNALIGNED; } else { for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,k) = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,BLOCK_2,k); } } temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,BLOCK_2) + mat->b3exit; if( temp > score) { score = temp; if( j - 0 <= mergej) { ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,0) = i-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,1) = j-0; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,2) = BLOCK_2; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,3) = i; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,4) = j; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,5) = UNALIGNED; } else { for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,k) = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,BLOCK_2,k); } } temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,UNALIGNED) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,0) = i-0; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,1) = j-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,2) = UNALIGNED; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,3) = i; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,4) = j; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,5) = UNALIGNED; } else { for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,k) = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNALIGNED,k); } } temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,UNALIGNED) + 0; if( temp > score) { score = temp; if( j - 0 <= mergej) { ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,0) = i-1; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,1) = j-0; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,2) = UNALIGNED; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,3) = i; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,4) = j; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,5) = UNALIGNED; } else { for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,k) = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNALIGNED,k); } } /* Add any movement independant score */ ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNALIGNED) = score; /* Finished with state UNALIGNED */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_ProteinBlockAligner(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_1) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_2) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_3) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNALIGNED) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state BLOCK_1 */ /* setting first movement to score */ score = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->b_self_trans; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_1,k); /* From state UNALIGNED to state BLOCK_1 */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,UNALIGNED) + mat->bentry; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNALIGNED,k); } /* Ok - finished max calculation for BLOCK_1 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_1) = score; for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state BLOCK_1 */ /* For state BLOCK_2 */ /* setting first movement to score */ score = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->b_self_trans; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_2,k); /* From state BLOCK_1 to state BLOCK_2 */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->bfor_trans; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_1,k); } /* Ok - finished max calculation for BLOCK_2 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_2) = score; for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state BLOCK_2 */ /* For state BLOCK_3 */ /* setting first movement to score */ score = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_3) + mat->b_self_trans; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_3,k); /* From state BLOCK_2 to state BLOCK_3 */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->bfor_trans; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_2,k); } /* Ok - finished max calculation for BLOCK_3 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_3) = score; for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state BLOCK_3 */ /* For state UNALIGNED */ /* setting first movement to score */ score = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,BLOCK_1) + mat->bexit; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,BLOCK_1,k); /* From state BLOCK_1 to state UNALIGNED */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,BLOCK_1) + mat->bexit; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,BLOCK_1,k); } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,BLOCK_2) + mat->b3exit; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,BLOCK_2,k); } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,BLOCK_2) + mat->b3exit; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,BLOCK_2,k); } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,UNALIGNED) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNALIGNED,k); } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,UNALIGNED) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNALIGNED,k); } /* Ok - finished max calculation for UNALIGNED */ /* Add any movement independant score and put away */ ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNALIGNED) = score; for(k=0;k<7;k++) ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNALIGNED */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_ProteinBlockAligner(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_1) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_2) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_3) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNALIGNED) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state BLOCK_1 */ /* setting first movement to score */ score = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->b_self_trans; /* From state UNALIGNED to state BLOCK_1 */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,UNALIGNED) + mat->bentry; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_1 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_1) = score; /* Finished calculating state BLOCK_1 */ /* For state BLOCK_2 */ /* setting first movement to score */ score = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->b_self_trans; /* From state BLOCK_1 to state BLOCK_2 */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->bfor_trans; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_2 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_2) = score; /* Finished calculating state BLOCK_2 */ /* For state BLOCK_3 */ /* setting first movement to score */ score = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_3) + mat->b_self_trans; /* From state BLOCK_2 to state BLOCK_3 */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->bfor_trans; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_3 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_3) = score; /* Finished calculating state BLOCK_3 */ /* For state UNALIGNED */ /* setting first movement to score */ score = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,BLOCK_1) + mat->bexit; /* From state BLOCK_1 to state UNALIGNED */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,BLOCK_1) + mat->bexit; if( temp > score ) { score = temp; } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,BLOCK_2) + mat->b3exit; if( temp > score ) { score = temp; } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,BLOCK_2) + mat->b3exit; if( temp > score ) { score = temp; } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,UNALIGNED) + 0; if( temp > score ) { score = temp; } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,UNALIGNED) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNALIGNED */ /* Add any movement independant score and put away */ ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNALIGNED) = score; /* Finished calculating state UNALIGNED */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_ProteinBlockAligner(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * */ } void init_dc_ProteinBlockAligner(ProteinBlockAligner * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iq->seq->len;i++) { ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_1) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_2) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_3) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNALIGNED) = NEGI; for(k=0;k<7;k++) { ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,k) = (-1); ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,k) = (-1); ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,k) = (-1); ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,k) = (-1); } } } return; } /* Function: start_end_find_end_ProteinBlockAligner(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [ProteinBlockAligner *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_ProteinBlockAligner(ProteinBlockAligner * mat,int * endj) { register int j; register int max; register int maxj; max = ProteinBlockAligner_DC_SHADOW_SPECIAL(mat,0,mat->t->seq->len-1,END); maxj = mat->t->seq->len-1; for(j= mat->t->seq->len-2 ;j >= 0 ;j--) { if( ProteinBlockAligner_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = ProteinBlockAligner_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_ProteinBlockAligner(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [ProteinBlockAligner] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_ProteinBlockAligner(ProteinBlockAligner *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->q->seq->len; lenj = mat->t->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 4,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 4 * 8,sizeof(int)); for(j=0;jb_self_trans + (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); /* assign local shadown pointer */ localsp = &(ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_1,0)); /* From state START to state BLOCK_1 */ temp = ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + 0 + (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp > score ) { score = temp; /* This state [START] is a special for BLOCK_1... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= BLOCK_1; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state UNALIGNED to state BLOCK_1 */ temp = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNALIGNED) + mat->bentry +(CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNALIGNED,0)); } /* Ok - finished max calculation for BLOCK_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i,j,BLOCK_1) = score; for(k=0;k<7;k++) ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state BLOCK_1 is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,k); ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,6); ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = BLOCK_1; } /* Finished calculating state BLOCK_1 */ /* For state BLOCK_2 */ /* setting first movement to score */ score = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->b_self_trans + (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); /* assign local shadown pointer */ localsp = &(ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_2,0)); /* From state BLOCK_1 to state BLOCK_2 */ temp = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->bfor_trans +(CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_1,0)); } /* Ok - finished max calculation for BLOCK_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i,j,BLOCK_2) = score; for(k=0;k<7;k++) ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state BLOCK_2 */ /* For state BLOCK_3 */ /* setting first movement to score */ score = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_3) + mat->b_self_trans + (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); /* assign local shadown pointer */ localsp = &(ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_3,0)); /* From state BLOCK_2 to state BLOCK_3 */ temp = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->bfor_trans +(CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,BLOCK_2,0)); } /* Ok - finished max calculation for BLOCK_3 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i,j,BLOCK_3) = score; for(k=0;k<7;k++) ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state BLOCK_3 */ /* For state UNALIGNED */ /* setting first movement to score */ score = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,BLOCK_1) + mat->bexit + (0); /* assign local shadown pointer */ localsp = &(ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,BLOCK_1,0)); /* From state BLOCK_1 to state UNALIGNED */ temp = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,BLOCK_1) + mat->bexit +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,BLOCK_1,0)); } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,BLOCK_2) + mat->b3exit +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,BLOCK_2,0)); } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,BLOCK_2) + mat->b3exit +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,BLOCK_2,0)); } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UNALIGNED) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNALIGNED,0)); } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,UNALIGNED) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNALIGNED,0)); } /* Ok - finished max calculation for UNALIGNED */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ ProteinBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i,j,UNALIGNED) = score; for(k=0;k<7;k++) ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state UNALIGNED is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,k); ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = ProteinBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,6); ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; ProteinBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = UNALIGNED; } /* Finished calculating state UNALIGNED */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_ProteinBlockAligner(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * */ void init_start_end_linear_ProteinBlockAligner(ProteinBlockAligner * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iq->seq->len;i++) { ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_1) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_1,0) = (-1); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_2) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_2,0) = (-1); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,BLOCK_3) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,BLOCK_3,0) = (-1); ProteinBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNALIGNED) = NEGI; ProteinBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNALIGNED,0) = (-1); } } for(j=(-1);jt->seq->len;j++) { ProteinBlockAligner_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; ProteinBlockAligner_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; ProteinBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_ProteinBlockAligner(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_ProteinBlockAligner(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_ProteinBlockAligner(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "SEQUENCE_BLOCK_1","SEQUENCE_BLOCK_2","UNALIGNED","END" }; /* Function: AlnConvertSet_ProteinBlockAligner(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "SEQUENCE_BLOCK_1","SEQUENCE_BLOCK_2","UNALIGNED","END" }; AlnConvertSet * AlnConvertSet_ProteinBlockAligner(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BLOCK_1; acu->state2 = BLOCK_1; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 4; acu->is_from_special = TRUE; acu->state2 = BLOCK_1; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNALIGNED; acu->state2 = BLOCK_1; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BLOCK_2; acu->state2 = BLOCK_2; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BLOCK_1; acu->state2 = BLOCK_2; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BLOCK_3; acu->state2 = BLOCK_3; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BLOCK_2; acu->state2 = BLOCK_3; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BLOCK_1; acu->state2 = UNALIGNED; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BLOCK_1; acu->state2 = UNALIGNED; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BLOCK_2; acu->state2 = UNALIGNED; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BLOCK_2; acu->state2 = UNALIGNED; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNALIGNED; acu->state2 = UNALIGNED; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNALIGNED; acu->state2 = UNALIGNED; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNALIGNED; acu->state2 = END + 4; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BLOCK_1; acu->state2 = END + 4; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[3]; return out; } /* Function: PackAln_read_Expl_ProteinBlockAligner(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_ProteinBlockAligner(ProteinBlockAligner * mat) { ProteinBlockAligner_access_func_holder holder; holder.access_main = ProteinBlockAligner_explicit_access_main; holder.access_special = ProteinBlockAligner_explicit_access_special; return PackAln_read_generic_ProteinBlockAligner(mat,holder); } /* Function: ProteinBlockAligner_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ProteinBlockAligner_explicit_access_main(ProteinBlockAligner * mat,int i,int j,int state) { return ProteinBlockAligner_EXPL_MATRIX(mat,i,j,state); } /* Function: ProteinBlockAligner_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ProteinBlockAligner_explicit_access_special(ProteinBlockAligner * mat,int i,int j,int state) { return ProteinBlockAligner_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_ProteinBlockAligner(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: h [UNKN ] Undocumented argument [ProteinBlockAligner_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_ProteinBlockAligner(ProteinBlockAligner * mat,ProteinBlockAligner_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_ProteinBlockAligner(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in ProteinBlockAligner_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 4; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_ProteinBlockAligner(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_ProteinBlockAligner(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == ProteinBlockAligner_READ_OFF_ERROR || j == ProteinBlockAligner_READ_OFF_ERROR || state == ProteinBlockAligner_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in ProteinBlockAligner_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 4; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_ProteinBlockAligner(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [ProteinBlockAligner_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_ProteinBlockAligner(ProteinBlockAligner * mat,int * ri,int * rj,int * state,boolean * isspecial,ProteinBlockAligner_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->t->seq->len-1,END); maxj = mat->t->seq->len-1; for(j= mat->t->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: ProteinBlockAligner_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void ProteinBlockAligner_debug_show_matrix(ProteinBlockAligner * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iq->seq->len;i++) { for(j=startj;jt->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State BLOCK_1 %d\n",ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_1)); fprintf(ofp,"State BLOCK_2 %d\n",ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_2)); fprintf(ofp,"State BLOCK_3 %d\n",ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_3)); fprintf(ofp,"State UNALIGNED %d\n",ProteinBlockAligner_EXPL_MATRIX(mat,i,j,UNALIGNED)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_ProteinBlockAligner(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [ProteinBlockAligner_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_ProteinBlockAligner(ProteinBlockAligner * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ProteinBlockAligner_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = ProteinBlockAligner_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->q->seq->len || j > mat->t->seq->len) { warn("In ProteinBlockAligner matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case BLOCK_1 : temp = cscore - (mat->bentry) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNALIGNED) ) { *reti = i - 1; *retj = j - 1; *retstate = UNALIGNED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNALIGNED); } return (*h.access_main)(mat,i - 1,j - 1,UNALIGNED); } temp = cscore - (0) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (mat->b_self_trans) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,BLOCK_1) ) { *reti = i - 1; *retj = j - 1; *retstate = BLOCK_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,BLOCK_1); } return (*h.access_main)(mat,i - 1,j - 1,BLOCK_1); } warn("Major problem (!) - in ProteinBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); case BLOCK_2 : temp = cscore - (mat->bfor_trans) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,BLOCK_1) ) { *reti = i - 1; *retj = j - 1; *retstate = BLOCK_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,BLOCK_1); } return (*h.access_main)(mat,i - 1,j - 1,BLOCK_1); } temp = cscore - (mat->b_self_trans) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,BLOCK_2) ) { *reti = i - 1; *retj = j - 1; *retstate = BLOCK_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,BLOCK_2); } return (*h.access_main)(mat,i - 1,j - 1,BLOCK_2); } warn("Major problem (!) - in ProteinBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); case BLOCK_3 : temp = cscore - (mat->bfor_trans) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,BLOCK_2) ) { *reti = i - 1; *retj = j - 1; *retstate = BLOCK_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,BLOCK_2); } return (*h.access_main)(mat,i - 1,j - 1,BLOCK_2); } temp = cscore - (mat->b_self_trans) - (CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,BLOCK_3) ) { *reti = i - 1; *retj = j - 1; *retstate = BLOCK_3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,BLOCK_3); } return (*h.access_main)(mat,i - 1,j - 1,BLOCK_3); } warn("Major problem (!) - in ProteinBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNALIGNED : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,UNALIGNED) ) { *reti = i - 1; *retj = j - 0; *retstate = UNALIGNED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,UNALIGNED); } return (*h.access_main)(mat,i - 1,j - 0,UNALIGNED); } temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UNALIGNED) ) { *reti = i - 0; *retj = j - 1; *retstate = UNALIGNED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UNALIGNED); } return (*h.access_main)(mat,i - 0,j - 1,UNALIGNED); } temp = cscore - (mat->b3exit) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,BLOCK_2) ) { *reti = i - 1; *retj = j - 0; *retstate = BLOCK_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,BLOCK_2); } return (*h.access_main)(mat,i - 1,j - 0,BLOCK_2); } temp = cscore - (mat->b3exit) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,BLOCK_2) ) { *reti = i - 0; *retj = j - 1; *retstate = BLOCK_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,BLOCK_2); } return (*h.access_main)(mat,i - 0,j - 1,BLOCK_2); } temp = cscore - (mat->bexit) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,BLOCK_1) ) { *reti = i - 1; *retj = j - 0; *retstate = BLOCK_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,BLOCK_1); } return (*h.access_main)(mat,i - 1,j - 0,BLOCK_1); } temp = cscore - (mat->bexit) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,BLOCK_1) ) { *reti = i - 0; *retj = j - 1; *retstate = BLOCK_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,BLOCK_1); } return (*h.access_main)(mat,i - 0,j - 1,BLOCK_1); } warn("Major problem (!) - in ProteinBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in ProteinBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_ProteinBlockAligner(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [ProteinBlockAligner_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_ProteinBlockAligner(ProteinBlockAligner * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ProteinBlockAligner_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = ProteinBlockAligner_READ_OFF_ERROR; if( j < 0 || j > mat->t->seq->len) { warn("In ProteinBlockAligner matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source BLOCK_1 is from main matrix */ for(i= mat->q->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,BLOCK_1) ) { *reti = i - 0; *retj = j - 0; *retstate = BLOCK_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,BLOCK_1); } return (*h.access_main)(mat,i - 0,j - 0,BLOCK_1) ; } } /* end of for i >= 0 */ /* source UNALIGNED is from main matrix */ for(i= mat->q->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,UNALIGNED) ) { *reti = i - 0; *retj = j - 0; *retstate = UNALIGNED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,UNALIGNED); } return (*h.access_main)(mat,i - 0,j - 0,UNALIGNED) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in ProteinBlockAligner read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_ProteinBlockAligner(mat) * * Descrip: This function calculates the ProteinBlockAligner matrix when in explicit mode * To allocate the matrix use /allocate_Expl_ProteinBlockAligner * * * Arg: mat [UNKN ] ProteinBlockAligner which contains explicit basematrix memory [ProteinBlockAligner *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_ProteinBlockAligner(ProteinBlockAligner * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_ProteinBlockAligner, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("ProteinBlockAligner Matrix calculation: "); for(j=0;jb_self_trans; /* From state START to state BLOCK_1 */ temp = ProteinBlockAligner_EXPL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* From state UNALIGNED to state BLOCK_1 */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-1,UNALIGNED) + mat->bentry; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_1 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_1) = score; /* state BLOCK_1 is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinBlockAligner_EXPL_SPECIAL(mat,i,j,END) ) { ProteinBlockAligner_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state BLOCK_1 */ /* For state BLOCK_2 */ /* setting first movement to score */ score = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->b_self_trans; /* From state BLOCK_1 to state BLOCK_2 */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->bfor_trans; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_2 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_2) = score; /* Finished calculating state BLOCK_2 */ /* For state BLOCK_3 */ /* setting first movement to score */ score = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-1,BLOCK_3) + mat->b_self_trans; /* From state BLOCK_2 to state BLOCK_3 */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->bfor_trans; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_3 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_3) = score; /* Finished calculating state BLOCK_3 */ /* For state UNALIGNED */ /* setting first movement to score */ score = ProteinBlockAligner_EXPL_MATRIX(mat,i-0,j-1,BLOCK_1) + mat->bexit; /* From state BLOCK_1 to state UNALIGNED */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-0,BLOCK_1) + mat->bexit; if( temp > score ) { score = temp; } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-0,j-1,BLOCK_2) + mat->b3exit; if( temp > score ) { score = temp; } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-0,BLOCK_2) + mat->b3exit; if( temp > score ) { score = temp; } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-0,j-1,UNALIGNED) + 0; if( temp > score ) { score = temp; } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-0,UNALIGNED) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNALIGNED */ /* Add any movement independant score and put away */ ProteinBlockAligner_EXPL_MATRIX(mat,i,j,UNALIGNED) = score; /* state UNALIGNED is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinBlockAligner_EXPL_SPECIAL(mat,i,j,END) ) { ProteinBlockAligner_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state UNALIGNED */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_ProteinBlockAligner(mat,dpenv) * * Descrip: This function calculates the ProteinBlockAligner matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] ProteinBlockAligner which contains explicit basematrix memory [ProteinBlockAligner *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_ProteinBlockAligner(ProteinBlockAligner * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_ProteinBlockAligner, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_1) = NEGI; ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_2) = NEGI; ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_3) = NEGI; ProteinBlockAligner_EXPL_MATRIX(mat,i,j,UNALIGNED) = NEGI; } } for(j=-1;jlenj;j++) { ProteinBlockAligner_EXPL_SPECIAL(mat,i,j,START) = 0; ProteinBlockAligner_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("ProteinBlockAligner Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_1) = NEGI; ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_2) = NEGI; ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_3) = NEGI; ProteinBlockAligner_EXPL_MATRIX(mat,i,j,UNALIGNED) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state BLOCK_1 */ /* setting first movement to score */ score = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->b_self_trans; /* From state START to state BLOCK_1 */ temp = ProteinBlockAligner_EXPL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* From state UNALIGNED to state BLOCK_1 */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-1,UNALIGNED) + mat->bentry; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_1 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_1) = score; /* state BLOCK_1 is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinBlockAligner_EXPL_SPECIAL(mat,i,j,END) ) { ProteinBlockAligner_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state BLOCK_1 */ /* For state BLOCK_2 */ /* setting first movement to score */ score = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->b_self_trans; /* From state BLOCK_1 to state BLOCK_2 */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-1,BLOCK_1) + mat->bfor_trans; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_2 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_2) = score; /* Finished calculating state BLOCK_2 */ /* For state BLOCK_3 */ /* setting first movement to score */ score = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-1,BLOCK_3) + mat->b_self_trans; /* From state BLOCK_2 to state BLOCK_3 */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-1,BLOCK_2) + mat->bfor_trans; if( temp > score ) { score = temp; } /* Ok - finished max calculation for BLOCK_3 */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->m,CSEQ_PROTEIN_AMINOACID(mat->q,i),CSEQ_PROTEIN_AMINOACID(mat->t,j)); ProteinBlockAligner_EXPL_MATRIX(mat,i,j,BLOCK_3) = score; /* Finished calculating state BLOCK_3 */ /* For state UNALIGNED */ /* setting first movement to score */ score = ProteinBlockAligner_EXPL_MATRIX(mat,i-0,j-1,BLOCK_1) + mat->bexit; /* From state BLOCK_1 to state UNALIGNED */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-0,BLOCK_1) + mat->bexit; if( temp > score ) { score = temp; } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-0,j-1,BLOCK_2) + mat->b3exit; if( temp > score ) { score = temp; } /* From state BLOCK_2 to state UNALIGNED */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-0,BLOCK_2) + mat->b3exit; if( temp > score ) { score = temp; } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-0,j-1,UNALIGNED) + 0; if( temp > score ) { score = temp; } /* From state UNALIGNED to state UNALIGNED */ temp = ProteinBlockAligner_EXPL_MATRIX(mat,i-1,j-0,UNALIGNED) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNALIGNED */ /* Add any movement independant score and put away */ ProteinBlockAligner_EXPL_MATRIX(mat,i,j,UNALIGNED) = score; /* state UNALIGNED is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinBlockAligner_EXPL_SPECIAL(mat,i,j,END) ) { ProteinBlockAligner_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state UNALIGNED */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: ProteinBlockAligner_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ProteinBlockAligner *] * */ ProteinBlockAligner * ProteinBlockAligner_alloc(void) { ProteinBlockAligner * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ProteinBlockAligner *) ckalloc (sizeof(ProteinBlockAligner))) == NULL) { warn("ProteinBlockAligner_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_ProteinBlockAligner(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ProteinBlockAligner *] * * Return [UNKN ] Undocumented return value [ProteinBlockAligner *] * */ ProteinBlockAligner * free_ProteinBlockAligner(ProteinBlockAligner * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ProteinBlockAligner obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->q is linked in */ /* obj->t is linked in */ /* obj->m is linked in */ /* obj->bentry is linked in */ /* obj->bexit is linked in */ /* obj->bfor_trans is linked in */ /* obj->b_self_trans is linked in */ /* obj->b3exit is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/pba.h0000644000175000001440000005627210670453714015061 0ustar philippusers#ifndef DYNAMITEpbaHEADERFILE #define DYNAMITEpbaHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" struct Wise2_ProteinBlockAligner { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; ComplexSequence* q; ComplexSequence* t; CompMat* m; Score bentry; Score bexit; Score bfor_trans; Score b_self_trans; Score b3exit; } ; /* ProteinBlockAligner defined */ #ifndef DYNAMITE_DEFINED_ProteinBlockAligner typedef struct Wise2_ProteinBlockAligner Wise2_ProteinBlockAligner; #define ProteinBlockAligner Wise2_ProteinBlockAligner #define DYNAMITE_DEFINED_ProteinBlockAligner #endif #ifdef PTHREAD struct thread_pool_holder_ProteinBlockAligner { ComplexSequence* q; /* Query object placeholder */ ProteinDB* querydb; /* Query database object */ boolean query_init; ComplexSequence* t; /* Target object placeholder */ ProteinDB* targetdb;/* Target database object */ boolean target_init; CompMat* m; Score bentry; Score bexit; Score bfor_trans; Score b_self_trans; Score b3exit; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_ProteinBlockAligner_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(ProteinBlockAligner*,int,int,int); int (*access_special)(ProteinBlockAligner*,int,int,int); } ; /* ProteinBlockAligner_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_ProteinBlockAligner_access_func_holder typedef struct Wise2_ProteinBlockAligner_access_func_holder Wise2_ProteinBlockAligner_access_func_holder; #define ProteinBlockAligner_access_func_holder Wise2_ProteinBlockAligner_access_func_holder #define DYNAMITE_DEFINED_ProteinBlockAligner_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_ProteinBlockAligner(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_ProteinBlockAligner(ProteinBlockAligner * mat); #define PackAln_read_Shatter_ProteinBlockAligner Wise2_PackAln_read_Shatter_ProteinBlockAligner /* Function: calculate_shatter_ProteinBlockAligner(mat,dpenv) * * Descrip: This function calculates the ProteinBlockAligner matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [ProteinBlockAligner *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_ProteinBlockAligner(ProteinBlockAligner * mat,DPEnvelope * dpenv); #define calculate_shatter_ProteinBlockAligner Wise2_calculate_shatter_ProteinBlockAligner /* Function: search_ProteinBlockAligner(dbsi,out,querydb,targetdb,m,bentry,bexit,bfor_trans,b_self_trans,b3exit) * * Descrip: This function makes a database search of ProteinBlockAligner * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [ProteinDB*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * Arg: m [UNKN ] Undocumented argument [CompMat*] * Arg: bentry [UNKN ] Undocumented argument [Score] * Arg: bexit [UNKN ] Undocumented argument [Score] * Arg: bfor_trans [UNKN ] Undocumented argument [Score] * Arg: b_self_trans [UNKN ] Undocumented argument [Score] * Arg: b3exit [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_ProteinBlockAligner(DBSearchImpl * dbsi,Hscore * out,ProteinDB* querydb,ProteinDB* targetdb ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit); #define search_ProteinBlockAligner Wise2_search_ProteinBlockAligner /* Function: serial_search_ProteinBlockAligner(out,querydb,targetdb,m,bentry,bexit,bfor_trans,b_self_trans,b3exit) * * Descrip: This function makes a database search of ProteinBlockAligner * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [ProteinDB*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * Arg: m [UNKN ] Undocumented argument [CompMat*] * Arg: bentry [UNKN ] Undocumented argument [Score] * Arg: bexit [UNKN ] Undocumented argument [Score] * Arg: bfor_trans [UNKN ] Undocumented argument [Score] * Arg: b_self_trans [UNKN ] Undocumented argument [Score] * Arg: b3exit [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_ProteinBlockAligner(Hscore * out,ProteinDB* querydb,ProteinDB* targetdb ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit); #define serial_search_ProteinBlockAligner Wise2_serial_search_ProteinBlockAligner /* Function: PackAln_bestmemory_ProteinBlockAligner(q,t,m,bentry,bexit,bfor_trans,b_self_trans,b3exit,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_ProteinBlockAligner * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: m [UNKN ] Resource [CompMat*] * Arg: bentry [UNKN ] Resource [Score] * Arg: bexit [UNKN ] Resource [Score] * Arg: bfor_trans [UNKN ] Resource [Score] * Arg: b_self_trans [UNKN ] Resource [Score] * Arg: b3exit [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_ProteinBlockAligner(ComplexSequence* q,ComplexSequence* t ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_ProteinBlockAligner Wise2_PackAln_bestmemory_ProteinBlockAligner /* Function: allocate_Expl_ProteinBlockAligner(q,t,m,bentry,bexit,bfor_trans,b_self_trans,b3exit,dpri) * * Descrip: This function allocates the ProteinBlockAligner structure * and the basematrix area for explicit memory implementations * It calls /allocate_ProteinBlockAligner_only * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: m [UNKN ] Resource [CompMat*] * Arg: bentry [UNKN ] Resource [Score] * Arg: bexit [UNKN ] Resource [Score] * Arg: bfor_trans [UNKN ] Resource [Score] * Arg: b_self_trans [UNKN ] Resource [Score] * Arg: b3exit [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [ProteinBlockAligner *] * */ ProteinBlockAligner * Wise2_allocate_Expl_ProteinBlockAligner(ComplexSequence* q,ComplexSequence* t ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit,DPRunImpl * dpri); #define allocate_Expl_ProteinBlockAligner Wise2_allocate_Expl_ProteinBlockAligner /* Function: recalculate_PackAln_ProteinBlockAligner(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by ProteinBlockAligner * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * */ void Wise2_recalculate_PackAln_ProteinBlockAligner(PackAln * pal,ProteinBlockAligner * mat); #define recalculate_PackAln_ProteinBlockAligner Wise2_recalculate_PackAln_ProteinBlockAligner /* Function: allocate_Small_ProteinBlockAligner(q,t,m,bentry,bexit,bfor_trans,b_self_trans,b3exit) * * Descrip: This function allocates the ProteinBlockAligner structure * and the basematrix area for a small memory implementations * It calls /allocate_ProteinBlockAligner_only * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: m [UNKN ] Resource [CompMat*] * Arg: bentry [UNKN ] Resource [Score] * Arg: bexit [UNKN ] Resource [Score] * Arg: bfor_trans [UNKN ] Resource [Score] * Arg: b_self_trans [UNKN ] Resource [Score] * Arg: b3exit [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [ProteinBlockAligner *] * */ ProteinBlockAligner * Wise2_allocate_Small_ProteinBlockAligner(ComplexSequence* q,ComplexSequence* t ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit); #define allocate_Small_ProteinBlockAligner Wise2_allocate_Small_ProteinBlockAligner /* Function: PackAln_calculate_Small_ProteinBlockAligner(mat,dpenv) * * Descrip: This function calculates an alignment for ProteinBlockAligner structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_ProteinBlockAligner * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_ProteinBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_ProteinBlockAligner(ProteinBlockAligner * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_ProteinBlockAligner Wise2_PackAln_calculate_Small_ProteinBlockAligner /* Function: AlnRangeSet_calculate_Small_ProteinBlockAligner(mat) * * Descrip: This function calculates an alignment for ProteinBlockAligner structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_ProteinBlockAligner * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_ProteinBlockAligner * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_ProteinBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_ProteinBlockAligner(ProteinBlockAligner * mat); #define AlnRangeSet_calculate_Small_ProteinBlockAligner Wise2_AlnRangeSet_calculate_Small_ProteinBlockAligner /* Function: AlnRangeSet_from_ProteinBlockAligner(mat) * * Descrip: This function reads off a start/end structure * for ProteinBlockAligner structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_ProteinBlockAligner * If you have not calculated the matrix use * /AlnRange_calculate_Small_ProteinBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_ProteinBlockAligner(ProteinBlockAligner * mat); #define AlnRangeSet_from_ProteinBlockAligner Wise2_AlnRangeSet_from_ProteinBlockAligner /* Function: convert_PackAln_to_AlnBlock_ProteinBlockAligner(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_ProteinBlockAligner(PackAln * pal); #define convert_PackAln_to_AlnBlock_ProteinBlockAligner Wise2_convert_PackAln_to_AlnBlock_ProteinBlockAligner /* Function: PackAln_read_Expl_ProteinBlockAligner(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_ProteinBlockAligner(ProteinBlockAligner * mat); #define PackAln_read_Expl_ProteinBlockAligner Wise2_PackAln_read_Expl_ProteinBlockAligner /* Function: PackAln_read_generic_ProteinBlockAligner(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ProteinBlockAligner *] * Arg: h [UNKN ] Undocumented argument [ProteinBlockAligner_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_ProteinBlockAligner(ProteinBlockAligner * mat,ProteinBlockAligner_access_func_holder h); #define PackAln_read_generic_ProteinBlockAligner Wise2_PackAln_read_generic_ProteinBlockAligner /* Function: calculate_ProteinBlockAligner(mat) * * Descrip: This function calculates the ProteinBlockAligner matrix when in explicit mode * To allocate the matrix use /allocate_Expl_ProteinBlockAligner * * * Arg: mat [UNKN ] ProteinBlockAligner which contains explicit basematrix memory [ProteinBlockAligner *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_ProteinBlockAligner(ProteinBlockAligner * mat); #define calculate_ProteinBlockAligner Wise2_calculate_ProteinBlockAligner /* Function: calculate_dpenv_ProteinBlockAligner(mat,dpenv) * * Descrip: This function calculates the ProteinBlockAligner matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] ProteinBlockAligner which contains explicit basematrix memory [ProteinBlockAligner *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_ProteinBlockAligner(ProteinBlockAligner * mat,DPEnvelope * dpenv); #define calculate_dpenv_ProteinBlockAligner Wise2_calculate_dpenv_ProteinBlockAligner /* Function: ProteinBlockAligner_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ProteinBlockAligner *] * */ ProteinBlockAligner * Wise2_ProteinBlockAligner_alloc(void); #define ProteinBlockAligner_alloc Wise2_ProteinBlockAligner_alloc /* Function: free_ProteinBlockAligner(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ProteinBlockAligner *] * * Return [UNKN ] Undocumented return value [ProteinBlockAligner *] * */ ProteinBlockAligner * Wise2_free_ProteinBlockAligner(ProteinBlockAligner * obj); #define free_ProteinBlockAligner Wise2_free_ProteinBlockAligner /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_ProteinBlockAligner_shatter_access_main(ProteinBlockAligner * mat,int i,int j,int state); #define ProteinBlockAligner_shatter_access_main Wise2_ProteinBlockAligner_shatter_access_main int Wise2_ProteinBlockAligner_shatter_access_special(ProteinBlockAligner * mat,int i,int j,int state); #define ProteinBlockAligner_shatter_access_special Wise2_ProteinBlockAligner_shatter_access_special void * Wise2_thread_loop_ProteinBlockAligner(void * ptr); #define thread_loop_ProteinBlockAligner Wise2_thread_loop_ProteinBlockAligner int Wise2_score_only_ProteinBlockAligner(ComplexSequence* q,ComplexSequence* t ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit); #define score_only_ProteinBlockAligner Wise2_score_only_ProteinBlockAligner ProteinBlockAligner * Wise2_allocate_ProteinBlockAligner_only(ComplexSequence* q,ComplexSequence* t ,CompMat* m,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit); #define allocate_ProteinBlockAligner_only Wise2_allocate_ProteinBlockAligner_only void Wise2_init_ProteinBlockAligner(ProteinBlockAligner * mat); #define init_ProteinBlockAligner Wise2_init_ProteinBlockAligner AlnRange * Wise2_AlnRange_build_ProteinBlockAligner(ProteinBlockAligner * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_ProteinBlockAligner Wise2_AlnRange_build_ProteinBlockAligner boolean Wise2_read_hidden_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_ProteinBlockAligner Wise2_read_hidden_ProteinBlockAligner int Wise2_max_hidden_ProteinBlockAligner(ProteinBlockAligner * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_ProteinBlockAligner Wise2_max_hidden_ProteinBlockAligner boolean Wise2_read_special_strip_ProteinBlockAligner(ProteinBlockAligner * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_ProteinBlockAligner Wise2_read_special_strip_ProteinBlockAligner int Wise2_max_special_strip_ProteinBlockAligner(ProteinBlockAligner * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_ProteinBlockAligner Wise2_max_special_strip_ProteinBlockAligner int Wise2_max_matrix_to_special_ProteinBlockAligner(ProteinBlockAligner * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_ProteinBlockAligner Wise2_max_matrix_to_special_ProteinBlockAligner void Wise2_calculate_hidden_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_ProteinBlockAligner Wise2_calculate_hidden_ProteinBlockAligner void Wise2_init_hidden_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_ProteinBlockAligner Wise2_init_hidden_ProteinBlockAligner boolean Wise2_full_dc_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_ProteinBlockAligner Wise2_full_dc_ProteinBlockAligner boolean Wise2_do_dc_single_pass_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_ProteinBlockAligner Wise2_do_dc_single_pass_ProteinBlockAligner void Wise2_push_dc_at_merge_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_ProteinBlockAligner Wise2_push_dc_at_merge_ProteinBlockAligner void Wise2_follow_on_dc_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_ProteinBlockAligner Wise2_follow_on_dc_ProteinBlockAligner void Wise2_run_up_dc_ProteinBlockAligner(ProteinBlockAligner * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_ProteinBlockAligner Wise2_run_up_dc_ProteinBlockAligner void Wise2_init_dc_ProteinBlockAligner(ProteinBlockAligner * mat); #define init_dc_ProteinBlockAligner Wise2_init_dc_ProteinBlockAligner int Wise2_start_end_find_end_ProteinBlockAligner(ProteinBlockAligner * mat,int * endj); #define start_end_find_end_ProteinBlockAligner Wise2_start_end_find_end_ProteinBlockAligner boolean Wise2_dc_optimised_start_end_calc_ProteinBlockAligner(ProteinBlockAligner *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_ProteinBlockAligner Wise2_dc_optimised_start_end_calc_ProteinBlockAligner void Wise2_init_start_end_linear_ProteinBlockAligner(ProteinBlockAligner * mat); #define init_start_end_linear_ProteinBlockAligner Wise2_init_start_end_linear_ProteinBlockAligner AlnConvertSet * Wise2_AlnConvertSet_ProteinBlockAligner(void); #define AlnConvertSet_ProteinBlockAligner Wise2_AlnConvertSet_ProteinBlockAligner int Wise2_ProteinBlockAligner_explicit_access_main(ProteinBlockAligner * mat,int i,int j,int state); #define ProteinBlockAligner_explicit_access_main Wise2_ProteinBlockAligner_explicit_access_main int Wise2_ProteinBlockAligner_explicit_access_special(ProteinBlockAligner * mat,int i,int j,int state); #define ProteinBlockAligner_explicit_access_special Wise2_ProteinBlockAligner_explicit_access_special int Wise2_find_end_ProteinBlockAligner(ProteinBlockAligner * mat,int * ri,int * rj,int * state,boolean * isspecial,ProteinBlockAligner_access_func_holder h); #define find_end_ProteinBlockAligner Wise2_find_end_ProteinBlockAligner void Wise2_ProteinBlockAligner_debug_show_matrix(ProteinBlockAligner * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define ProteinBlockAligner_debug_show_matrix Wise2_ProteinBlockAligner_debug_show_matrix int Wise2_max_calc_ProteinBlockAligner(ProteinBlockAligner * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ProteinBlockAligner_access_func_holder h); #define max_calc_ProteinBlockAligner Wise2_max_calc_ProteinBlockAligner int Wise2_max_calc_special_ProteinBlockAligner(ProteinBlockAligner * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ProteinBlockAligner_access_func_holder h); #define max_calc_special_ProteinBlockAligner Wise2_max_calc_special_ProteinBlockAligner #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/geneparser4.c0000644000175000001440000001531510670453714016522 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "geneparser4.h" # line 34 "geneparser4.dy" GeneParser4 * std_GeneParser4(double indel,double intron2cds) { int i; GeneParser4 * out; out = GeneParser4_alloc(); out->transition[GP4_INTRON2CDS] = intron2cds; out->transition[GP4_INTRON2INTRON] = 1.0; out->transition[GP4_DELETE_1_BASE] = indel; out->transition[GP4_DELETE_2_BASE] = indel; out->transition[GP4_INSERT_1_BASE] = indel; out->transition[GP4_INSERT_2_BASE] = indel; out->transition[GP4_LOOP2MODEL] = 1.0; out->transition[GP4_LOOP2LOOP] = 0; for(i=0;i<5;i++) out->intron[i] = 1.0; return out; } # line 60 "geneparser4.dy" GeneParser4Score * GeneParser4Score_from_GeneParser21Score(GeneParser21Score * gp21s) { int i; GeneParser4Score * out; out = GeneParser4Score_alloc(); out->transition[GP4_INTRON2CDS] = gp21s->transition[GP21_CENTRAL2PY] + gp21s->transition[GP21_PY2SPACER] + gp21s->transition[GP21_SPACER2CDS]; out->transition[GP4_INTRON2INTRON] = gp21s->transition[GP21_CENTRAL2CENTRAL]; out->transition[GP4_DELETE_1_BASE] = gp21s->transition[GP21_DELETE_1_BASE]; out->transition[GP4_DELETE_2_BASE] = gp21s->transition[GP21_DELETE_2_BASE]; out->transition[GP4_INSERT_1_BASE] = gp21s->transition[GP21_INSERT_1_BASE]; out->transition[GP4_INSERT_2_BASE] = gp21s->transition[GP21_INSERT_2_BASE]; out->transition[GP4_LOOP2MODEL] = gp21s->transition[GP21_RND2MODEL]; /* out->transition[GP4_LOOP2LOOP] = gp21s->transition[GP21_RND2RND]; */ out->transition[GP4_LOOP2LOOP] = 0; /* fprintf(stderr,"Loop score is %d\n",out->transition[GP4_LOOP2LOOP]); */ for(i=0;i<5;i++) out->intron[i] = gp21s->central[i]; return out; } # line 88 "geneparser4.dy" GeneParser4Score * GeneParser4Score_from_GeneParser4(GeneParser4 * gp4) { GeneParser4Score * out; out = GeneParser4Score_alloc(); Probability2Score_move(gp4->transition,out->transition,GP4_TRANSITION_LEN); Probability2Score_move(gp4->intron,out->intron,5); return out; } # line 76 "geneparser4.c" /* Function: hard_link_GeneParser4(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneParser4 *] * * Return [UNKN ] Undocumented return value [GeneParser4 *] * */ GeneParser4 * hard_link_GeneParser4(GeneParser4 * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneParser4 object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneParser4_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneParser4 *] * */ GeneParser4 * GeneParser4_alloc(void) { GeneParser4 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneParser4 *) ckalloc (sizeof(GeneParser4))) == NULL) { warn("GeneParser4_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* transition[GP4_TRANSITION_LEN] is an array: no default possible */ /* intron[5] is an array: no default possible */ return out; } /* Function: free_GeneParser4(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneParser4 *] * * Return [UNKN ] Undocumented return value [GeneParser4 *] * */ GeneParser4 * free_GeneParser4(GeneParser4 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneParser4 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_GeneParser4Score(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneParser4Score *] * */ GeneParser4Score * hard_link_GeneParser4Score(GeneParser4Score * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneParser4Score object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneParser4Score_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneParser4Score *] * */ GeneParser4Score * GeneParser4Score_alloc(void) { GeneParser4Score * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneParser4Score *) ckalloc (sizeof(GeneParser4Score))) == NULL) { warn("GeneParser4Score_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* transition[GP4_TRANSITION_LEN] is an array: no default possible */ /* intron[5] is an array: no default possible */ return out; } /* Function: free_GeneParser4Score(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneParser4Score *] * */ GeneParser4Score * free_GeneParser4Score(GeneParser4Score * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneParser4Score obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/geneparser4.h0000644000175000001440000001110410670453714016517 0ustar philippusers#ifndef DYNAMITEgeneparser4HEADERFILE #define DYNAMITEgeneparser4HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "probability.h" #include "geneparser21.h" enum GeneParser4Type { GP4_INTRON2CDS = 0, GP4_INTRON2INTRON, GP4_DELETE_1_BASE, GP4_DELETE_2_BASE, GP4_INSERT_1_BASE, GP4_INSERT_2_BASE, GP4_LOOP2LOOP, GP4_LOOP2MODEL, GP4_TRANSITION_LEN }; struct Wise2_GeneParser4 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability transition[GP4_TRANSITION_LEN]; Probability intron[5]; } ; /* GeneParser4 defined */ #ifndef DYNAMITE_DEFINED_GeneParser4 typedef struct Wise2_GeneParser4 Wise2_GeneParser4; #define GeneParser4 Wise2_GeneParser4 #define DYNAMITE_DEFINED_GeneParser4 #endif struct Wise2_GeneParser4Score { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score transition[GP4_TRANSITION_LEN]; Score intron[5]; } ; /* GeneParser4Score defined */ #ifndef DYNAMITE_DEFINED_GeneParser4Score typedef struct Wise2_GeneParser4Score Wise2_GeneParser4Score; #define GeneParser4Score Wise2_GeneParser4Score #define DYNAMITE_DEFINED_GeneParser4Score #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_GeneParser4(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneParser4 *] * * Return [UNKN ] Undocumented return value [GeneParser4 *] * */ GeneParser4 * Wise2_hard_link_GeneParser4(GeneParser4 * obj); #define hard_link_GeneParser4 Wise2_hard_link_GeneParser4 /* Function: GeneParser4_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneParser4 *] * */ GeneParser4 * Wise2_GeneParser4_alloc(void); #define GeneParser4_alloc Wise2_GeneParser4_alloc /* Function: free_GeneParser4(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneParser4 *] * * Return [UNKN ] Undocumented return value [GeneParser4 *] * */ GeneParser4 * Wise2_free_GeneParser4(GeneParser4 * obj); #define free_GeneParser4 Wise2_free_GeneParser4 /* Function: hard_link_GeneParser4Score(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneParser4Score *] * */ GeneParser4Score * Wise2_hard_link_GeneParser4Score(GeneParser4Score * obj); #define hard_link_GeneParser4Score Wise2_hard_link_GeneParser4Score /* Function: GeneParser4Score_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneParser4Score *] * */ GeneParser4Score * Wise2_GeneParser4Score_alloc(void); #define GeneParser4Score_alloc Wise2_GeneParser4Score_alloc /* Function: free_GeneParser4Score(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneParser4Score *] * */ GeneParser4Score * Wise2_free_GeneParser4Score(GeneParser4Score * obj); #define free_GeneParser4Score Wise2_free_GeneParser4Score /* Unplaced functions */ /* There has been no indication of the use of these functions */ GeneParser4 * Wise2_std_GeneParser4(double indel,double intron2cds); #define std_GeneParser4 Wise2_std_GeneParser4 GeneParser4Score * Wise2_GeneParser4Score_from_GeneParser21Score(GeneParser21Score * gp21s); #define GeneParser4Score_from_GeneParser21Score Wise2_GeneParser4Score_from_GeneParser21Score GeneParser4Score * Wise2_GeneParser4Score_from_GeneParser4(GeneParser4 * gp4); #define GeneParser4Score_from_GeneParser4 Wise2_GeneParser4Score_from_GeneParser4 /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/psw.c0000644000175000001440000001516410151133271015101 0ustar philippusers /* * include proteinsw.h - will include the dynamite * produced declarations provided */ #include "sw_wrap.h" #include "commandline.h" #include "version.h" #include "abc.h" /* * seqaligndisplay - fancy display * */ #include "seqaligndisplay.h" char * program_name = "psw"; void show_help(FILE * ofp) { fprintf(ofp,"\npsw seq1 seq2\nBoth sequences in fasta format\n" "\tOPTIONS\n" "\t-g gap penalty (default 12)\n" "\t-e ext penatly (default 2)\n" "\t-m comp matrix (default BLOSUM62.bla)\n" "\t-abc use the abc model\n" "\t-a a penalty for above (default 120)\n" "\t-b b penalty for above (default 10)\n" "\t-c c penalty for above (default 3)\n" "\t-r show raw output\n" "\t-l show label output\n" "\t-f show fancy output\n" "\t-F force psw to use sequences that seem to be DNA\n" "\t-dpenv DP envelope file...\n" "\t (default, -f, all outputs can be shown together)\n" ); show_help_DPRunImpl(ofp); show_standard_options(ofp); exit(63); } void show_version(FILE * ofp); int main(int argc,char ** argv) { Sequence * query; Sequence * target; CompMat * comp; char * comp_file; int gap = (12); int ext = (2); int a = 120; int b = 10; int c = 3; int ident; int qstart; int qend; int tstart; int tend; AlnColumn * alc; ComplexSequence * query_cs; ComplexSequence * target_cs; ComplexSequenceEvalSet * evalfunc; boolean show_label_output = FALSE; boolean show_fancy_output = FALSE; boolean use_abc = FALSE; boolean show_perc = FALSE; boolean force_protein = FALSE; PackAln * pal; AlnBlock * alb; DPRunImpl * dpri = NULL; DPEnvelope * dpenv = NULL; char * temp; /* * Process command line options * -h or -help gives us help * -g for gap value (an int) - rely on commandline error processing * -e for ext value (an int) - rely on commandline error processing * -m for matrix (a char) * -l - label output * -f - fancy output * * * Use calls to commandline.h functions * */ strip_out_standard_options(&argc,argv,show_help,show_version); if( strip_out_boolean_argument(&argc,argv,"h") == TRUE || strip_out_boolean_argument(&argc,argv,"-help") == TRUE) { show_help(stdout); exit(1); } dpri = new_DPRunImpl_from_argv(&argc,argv); if( dpri == NULL ) { fatal("Unable to build DPRun implementation. Bad arguments"); } show_label_output = strip_out_boolean_argument(&argc,argv,"l"); show_fancy_output = strip_out_boolean_argument(&argc,argv,"f"); show_perc = strip_out_boolean_argument(&argc,argv,"p"); force_protein = strip_out_boolean_argument(&argc,argv,"F"); /** if all FALSE, set fancy to TRUE **/ if( show_label_output == FALSE && show_perc == FALSE) show_fancy_output = TRUE; (void) strip_out_integer_argument(&argc,argv,"g",&gap); (void) strip_out_integer_argument(&argc,argv,"e",&ext); (void) strip_out_integer_argument(&argc,argv,"a",&a); (void) strip_out_integer_argument(&argc,argv,"b",&b); (void) strip_out_integer_argument(&argc,argv,"c",&c); use_abc = strip_out_boolean_argument(&argc,argv,"abc"); comp_file = strip_out_assigned_argument(&argc,argv,"m"); if( comp_file == NULL) comp_file = "BLOSUM62.bla"; if( (temp = strip_out_assigned_argument(&argc,argv,"dpenv")) != NULL ) { dpenv = read_DPEnvelope_file(temp); } if( argc != 3 ) { warn("Must have two arguments for sequence 1 and sequence 2 %d",argc); show_help(stdout); exit(1); } /* * Read in two sequences */ if( (query=read_fasta_file_Sequence(argv[1])) == NULL ) { fatal("Unable to read the sequence in file %s",argv[1]); } if( (target=read_fasta_file_Sequence(argv[2])) == NULL ) { fatal("Unable to read the sequence in file %s",argv[2]); } if ( force_protein ) { query->type = SEQUENCE_PROTEIN; target->type = SEQUENCE_PROTEIN; } /* * Open a blosum matrix. This will be opened from WISECONFIGDIR * or WISEPERSONALDIR if it is not present in the current directory. */ comp = read_Blast_file_CompMat(comp_file); if( comp == NULL ) { fatal("unable to read file %s",comp_file); } /* if abc - factor up matrix! */ if( use_abc == TRUE ) { factor_CompMat(comp,10); } /* * Make an alignment. I don't care about the implementation: * hand it over to sw_wrap function to do it * */ /* show_DPEnvelope(dpenv,stderr); */ if( use_abc ) { evalfunc = default_aminoacid_ComplexSequenceEvalSet(); query_cs = new_ComplexSequence(query,evalfunc); if( query_cs == NULL ) fatal("Cannot build cs objects!"); target_cs = new_ComplexSequence(target,evalfunc); if( target_cs == NULL ) fatal("Cannot build cs objects!"); pal = PackAln_bestmemory_abc(query_cs,target_cs,comp,-a,-b,-c,dpenv,dpri); alb = convert_PackAln_to_AlnBlock_abc(pal); free_ComplexSequence(query_cs); free_ComplexSequence(target_cs); } else { alb = Align_Sequences_ProteinSmithWaterman(query,target,comp,-gap,-ext,dpenv,dpri); } /* * show output. If multiple outputs, divide using // */ if( show_label_output == TRUE ) { show_flat_AlnBlock(alb,stdout); puts("//\n"); } if( show_fancy_output == TRUE ) { write_pretty_seq_align(alb,query,target,15,50,stdout); puts("//\n"); } if( show_perc == TRUE ) { qstart = alb->start->alu[0]->end; tstart = alb->start->alu[1]->end; ident =0; for(alc = alb->start;alc != NULL;alc = alc->next) { if( strcmp(alc->alu[0]->text_label,"SEQUENCE") == 0 && strcmp(alc->alu[1]->text_label,"SEQUENCE") == 0 ) { qend = alc->alu[0]->end; tend = alc->alu[1]->end; if( query->seq[alc->alu[0]->end] == target->seq[alc->alu[1]->end] ) { ident++; } } } fprintf(stdout,"%d %s %d:%d (%.2f) %s %d:%d (%.2f)\n",ident, query->name,qstart+1,qend,(ident*100.0)/(qend-qstart), target->name,tstart+1,tend,(ident*100.0)/(qend-qstart)); } /* * Destroy the memory. */ free_Sequence(query); free_Sequence(target); free_CompMat(comp); free_AlnBlock(alb); return 0; } void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) GRL 1998 and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney wrote the core code.\n"); exit(63); } wise-2.4.1/src/models/genomewise9.dy0000644000175000001440000001313007360366655016732 0ustar philippusers %{ #include "dyna.h" #include "genome_evidence.h" %} matrix GenomeWise9 query name="evi" type="GenomeEvidenceSet*" target name="gen" type="GENOMIC" resource name="switchcost" type="int" resource name="newgenecost" type="int" resource name="non_start_codon" type="int" resource name="non_stop_codon" type="int" resource type="RandomCodonScore *" name="rndcodon" state UTR5 offi="0" offj="1" source UTR5 calc="GNE_UTR(evi,i,gen,j)" endsource source UTR5_INTRON calc="GNE_UTR_3SS(evi,i,gen,j)" endsource source SPECIAL_UTR5 calc="GNE_UTR(evi,i,gen,j)" endsource source START calc="GNE_UTR5_START(evi,i,gen,j)" endsource source INTERGENIC calc="GNE_UTR(evi,i,gen,j) + GNE_UTR5_START(evi,i,gen,j)" endsource source PREGENE_INTERGENIC calc="GNE_UTR(evi,i,gen,j)" endsource query_label UTR5 target_label UTR5 endstate state UTR5_INTRON offj="1" source UTR5_INTRON calc="GNE_UTR_INTRON(evi,i,gen,j)" endsource source UTR5 calc="GNE_UTR_5SS(evi,i,gen,j)" endsource query_label UTR5 target_label UTR5_INTRON endstate state START_CODON offi="0" offj="3" source UTR5_INTRON calc="GNE_START_CODON(evi,i,gen,j)" query_label START_CODON target_label CODON endsource source UTR5 calc="GNE_START_CODON(evi,i,gen,j)" query_label START_CODON target_label CODON endsource endstate state CDS offi="0" offj="3" source CDS calc="GNE_CDS(evi,i,gen,j)" endsource source CDS_INTRON_0 offj="6" calc="GNE_CDS_3SS(evi,i,gen,j-3,0)" target_label 3SS_PHASE_0 endsource source CDS_INTRON_1 offj="5" calc="GNE_CDS_3SS(evi,i,gen,j-2,1)" target_label 3SS_PHASE_1 endsource source CDS_INTRON_2 offj="4" calc="GNE_CDS_3SS(evi,i,gen,j-1,2)" target_label 3SS_PHASE_2 endsource source CDS offj="2" calc="GNE_CDS_FRAMESHIFT(evi,i,gen,j,2)" target_label SEQUENCE_DELETION endsource source CDS offj="4" calc="GNE_CDS_FRAMESHIFT(evi,i,gen,j,4)" target_label SEQUENCE_DELETION endsource source UTR5 calc="GNE_CDS(evi,i,gen,j)+non_start_codon" endsource source START_CODON calc="GNE_CDS(evi,i,gen,j)" endsource source SPECIAL_CDS calc="GNE_CDS(evi,i,gen,j)" endsource source INTERGENIC calc="GNE_CDS(evi,i,gen,j) + GNE_UTR5_START(evi,i,gen,j)" endsource query_label CDS target_label CODON endstate state CDS_INTRON_0 offj="1" source CDS_INTRON_0 offj="1" calc="GNE_CDS_INTRON(evi,i,gen,j)" endsource source CDS offj="8" calc="GNE_CDS_5SS(evi,i,gen,j-7,0)" target_label 5SS_PHASE_0 endsource query_label CDS_INTRON target_label CDS_INTRON endstate state CDS_INTRON_1 offj="1" source CDS_INTRON_1 calc="GNE_CDS_INTRON(evi,i,gen,j)" endsource source CDS offj="9" calc="GNE_CDS_5SS(evi,i,gen,j-7,1)" target_label 5SS_PHASE_1 endsource query_label CDS_INTRON target_label CDS_INTRON endstate state CDS_INTRON_2 offj="1" source CDS_INTRON_2 calc="GNE_CDS_INTRON(evi,i,gen,j)" endsource source CDS offj="10" calc="GNE_CDS_5SS(evi,i,gen,j-7,2)" target_label 5SS_PHASE_2 endsource query_label CDS_INTRON target_label CDS_INTRON endstate state STOP_CODON offi="0" offj="3" source CDS calc="GNE_STOP_CODON(evi,i,gen,j)" query_label STOP_CODON target_label STOP_CODON endsource endstate state UTR3 offi="0" offj="1" source UTR3 calc="GNE_UTR(evi,i,gen,j)" endsource source CDS calc="GNE_UTR(evi,i,gen,j) + non_stop_codon" endsource source STOP_CODON calc="GNE_UTR(evi,i,gen,j)" endsource source UTR3_INTRON calc="GNE_UTR_3SS(evi,i,gen,j)" endsource source INTERGENIC !left calc="GNE_UTR(evi,i,gen,j)" endsource query_label UTR3 target_label UTR3 endstate state UTR3_INTRON offj="1" source UTR3_INTRON calc="GNE_UTR_INTRON(evi,i,gen,j)" endsource source UTR3 calc="GNE_UTR_5SS(evi,i,gen,j)" endsource source SPECIAL_UTR3 calc="GNE_UTR(evi,i,gen,j)" endsource query_label UTR3 target_label UTR3_INTRON endstate state PREGENE_INTERGENIC !special source START offi="0" offj="1" calc="0" endsource query_label INTERGENIC target_label RANDOM_DNA endstate state POSTGENE_INTERGENIC !special source UTR3 offj="0" calc="newgenecost + GNE_UTR3_END(evi,i,gen,j)" endsource query_label INTERGENIC target_label RANDOM_DNA endstate state INTERGENIC !special offj="1" source INTERGENIC offi="0" offj="1" calc="0" endsource source CDS offj="0" calc="newgenecost + GNE_UTR3_END(evi,i,gen,j)" endsource source UTR3 offj="0" calc="newgenecost + GNE_UTR3_END(evi,i,gen,j)" endsource query_label INTERGENIC target_label RANDOM_DNA endstate state SPECIAL_UTR5 !special source UTR5 calc="switchcost" endsource query_label SPECIAL target_label UTR5 endstate state SPECIAL_UTR3 !special source UTR3 calc="switchcost" endsource query_label SPECIAL target_label UTR3 endstate state SPECIAL_CDS !special source CDS calc="switchcost + rndcodon->codon[GENOMIC_CODON(gen,j)]" endsource source SPECIAL_CDS offj="3" calc="rndcodon->codon[GENOMIC_CODON(gen,j)]" endsource query_label SPECIAL target_label CODON endstate state START !start !special endstate state END !end !special source INTERGENIC offj="1" !right calc="0" endsource target_label END query_label END endstate collapse UTR5 UTR5 collapse UTR3 UTR3 collapse UTR5 UTR5_INTRON collapse UTR3 UTR3_INTRON collapse INTERGENIC RANDOM_DNA collapse CDS_INTRON CDS_INTRON endmatrix wise-2.4.1/src/models/pfamhmmer1db.pod0000644000175000001440000001715410670453714017211 0ustar philippusers=head1 NAME pfamhmmer1db module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item PfamHmmer1DB =item PfamHmmer1Entry =back =head1 DESCRIPTION =head2 Object PfamHmmer1DB =over =item en Type [PfamHmmer1Entry **] List No documentation =item dirname Type [char *] Scalar directory name with the models =item cur Type [int] Scalar No documentation =item def Type [RandomModel *] Scalar default random model =back Pfam Hmmer1db is a wrapper around a Pfam Hmmer database. This is file called HMM.s in a directory which has appropiate .HMM and .random files Although this DB will be phased out, it is still around for a while. This wont be used directly, but rather in a threestatedb model. It does not implement a full dynamite style db stream. rather it expects threestatedb to prod it in the correct manner. =head2 Member functions of PfamHmmer1DB =over =item hard_link_PfamHmmer1DB &Wise2::PfamHmmer1DB::hard_link_PfamHmmer1DB(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [PfamHmmer1DB *] Return [UNKN ] Undocumented return value [PfamHmmer1DB *] =item PfamHmmer1DB_alloc_std &Wise2::PfamHmmer1DB::PfamHmmer1DB_alloc_std(void) Equivalent to PfamHmmer1DB_alloc_len(PfamHmmer1DBLISTLENGTH) Return [UNKN ] Undocumented return value [PfamHmmer1DB *] =item en &Wise2::PfamHmmer1DB::en(obj,i) Access members stored in the en list For use principly by API functions Argument obj [UNKN ] Object holding the list [PfamHmmer1DB *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [PfamHmmer1Entry *] =item length_en &Wise2::PfamHmmer1DB::length_en(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [PfamHmmer1DB *] Return [UNKN ] length of the list [int] =item flush_en &Wise2::PfamHmmer1DB::flush_en(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [PfamHmmer1DB *] Return [UNKN ] Undocumented return value [int] =item add_en &Wise2::PfamHmmer1DB::add_en(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [PfamHmmer1DB *] Argument add [OWNER] Object to add to the list [PfamHmmer1Entry *] Return [UNKN ] Undocumented return value [boolean] =item set_dirname &Wise2::PfamHmmer1DB::set_dirname(obj,dirname) Replace member variable dirname For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1DB *] Argument dirname [OWNER] New value of the variable [char *] Return [SOFT ] member variable dirname [boolean] =item dirname &Wise2::PfamHmmer1DB::dirname(obj) Access member variable dirname For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1DB *] Return [SOFT ] member variable dirname [char *] =item set_cur &Wise2::PfamHmmer1DB::set_cur(obj,cur) Replace member variable cur For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1DB *] Argument cur [OWNER] New value of the variable [int] Return [SOFT ] member variable cur [boolean] =item cur &Wise2::PfamHmmer1DB::cur(obj) Access member variable cur For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1DB *] Return [SOFT ] member variable cur [int] =item set_def &Wise2::PfamHmmer1DB::set_def(obj,def) Replace member variable def For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1DB *] Argument def [OWNER] New value of the variable [RandomModel *] Return [SOFT ] member variable def [boolean] =item def &Wise2::PfamHmmer1DB::def(obj) Access member variable def For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1DB *] Return [SOFT ] member variable def [RandomModel *] =back =head2 Object PfamHmmer1Entry =over =item entryname Type [char *] Scalar No documentation =item is_random Type [boolean] Scalar No documentation =item is_hmmls Type [boolean] Scalar No documentation =item bits_cutoff Type [double] Scalar No documentation =back No documentation for PfamHmmer1Entry =head2 Member functions of PfamHmmer1Entry =over =item hard_link_PfamHmmer1Entry &Wise2::PfamHmmer1Entry::hard_link_PfamHmmer1Entry(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [PfamHmmer1Entry *] Return [UNKN ] Undocumented return value [PfamHmmer1Entry *] =item alloc &Wise2::PfamHmmer1Entry::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [PfamHmmer1Entry *] =item set_entryname &Wise2::PfamHmmer1Entry::set_entryname(obj,entryname) Replace member variable entryname For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] Argument entryname [OWNER] New value of the variable [char *] Return [SOFT ] member variable entryname [boolean] =item entryname &Wise2::PfamHmmer1Entry::entryname(obj) Access member variable entryname For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] Return [SOFT ] member variable entryname [char *] =item set_is_random &Wise2::PfamHmmer1Entry::set_is_random(obj,is_random) Replace member variable is_random For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] Argument is_random [OWNER] New value of the variable [boolean] Return [SOFT ] member variable is_random [boolean] =item is_random &Wise2::PfamHmmer1Entry::is_random(obj) Access member variable is_random For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] Return [SOFT ] member variable is_random [boolean] =item set_is_hmmls &Wise2::PfamHmmer1Entry::set_is_hmmls(obj,is_hmmls) Replace member variable is_hmmls For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] Argument is_hmmls [OWNER] New value of the variable [boolean] Return [SOFT ] member variable is_hmmls [boolean] =item is_hmmls &Wise2::PfamHmmer1Entry::is_hmmls(obj) Access member variable is_hmmls For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] Return [SOFT ] member variable is_hmmls [boolean] =item set_bits_cutoff &Wise2::PfamHmmer1Entry::set_bits_cutoff(obj,bits_cutoff) Replace member variable bits_cutoff For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] Argument bits_cutoff [OWNER] New value of the variable [double] Return [SOFT ] member variable bits_cutoff [boolean] =item bits_cutoff &Wise2::PfamHmmer1Entry::bits_cutoff(obj) Access member variable bits_cutoff For use principly by API functions Argument obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] Return [SOFT ] member variable bits_cutoff [double] =back wise-2.4.1/src/models/pfamhmmer1db.tex0000644000175000001440000000316010670453714017217 0ustar philippusers\section{pfamhmmer1db} \label{module_pfamhmmer1db} This module contains the following objects \begin{itemize} \item \ref{object_PfamHmmer1DB} PfamHmmer1DB \item \ref{object_PfamHmmer1Entry} PfamHmmer1Entry \end{itemize} \subsection{Object PfamHmmer1DB} \label{object_PfamHmmer1DB} The PfamHmmer1DB object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{en} Type [PfamHmmer1Entry ** : List] No documentation \item{dirname} Type [char * : Scalar] directory name with the models \item{cur} Type [int : Scalar] No documentation \item{def} Type [RandomModel * : Scalar] default random model \end{description} Pfam Hmmer1db is a wrapper around a Pfam Hmmer database. This is file called HMM.s in a directory which has appropiate .HMM and .random files Although this DB will be phased out, it is still around for a while. This wont be used directly, but rather in a threestatedb model. It does not implement a full dynamite style db stream. rather it expects threestatedb to prod it in the correct manner. Member functions of PfamHmmer1DB \subsection{Object PfamHmmer1Entry} \label{object_PfamHmmer1Entry} The PfamHmmer1Entry object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{entryname} Type [char * : Scalar] No documentation \item{is_random} Type [boolean : Scalar] No documentation \item{is_hmmls} Type [boolean : Scalar] No documentation \item{bits_cutoff} Type [double : Scalar] No documentation \end{description} No documentation for PfamHmmer1Entry Member functions of PfamHmmer1Entry wise-2.4.1/src/models/pairwiseshortdna.dy0000644000175000001440000000601210345263436020054 0ustar philippusers %{ #include "dyna.h" #include "hsp.h" #include "subseqhash.h" %} struct PairwiseShortDna HSPset * forward HSPset * reverse %{ #include "pairwiseshortdna.h" boolean process_HSP(HSPset * set,Sequence * query,int query_pos,Sequence * tseq,SeqLookupResultStruct * res_struct,CompMat * mat) { HSP * h; int k; for(k=0;klen;k++) { if( on_HSP(set->hsp[k],query_pos,res_struct->pos) == TRUE ) { return FALSE; } } /* new HSP - extend and add */ h = new_HSP(NULL,query,tseq,query_pos,res_struct->pos,mat,10*Probability2Score(0.8/0.25)); /* fprintf(stderr,"Processing HSP with %d %d\n",h->length,h->score); */ add_HSPset(set,h); return TRUE; } PairwiseShortDna * query_to_reverse_target(Sequence * query,Sequence * target,DnaMatrix * dm,int qstart,int qend,int tstart,int tend) { PairwiseShortDna * out; HSPset * forward; HSPset * reverse; CompMat * cm; SeqLookupInterface * sli; SeqLookupClientInterface * slci; SeqLookupResultInterface * res; SeqLookupResultStruct * res_struct = NULL; Sequence * revseq; int i; int no; GTree * forward_tree; GTree * reverse_tree; out = PairwiseShortDna_alloc(); cm = new_CompMat_from_DnaMatrix_flat(dm); /* reverse sequence */ revseq = reverse_complement_Sequence(target); forward_tree = g_tree_new(g_int_equal); reverse_tree = g_tree_new(g_int_equal); /* build a hash based lookup table */ sli = new_ghash_SeqLookupInterface(); assert(cm); assert(target); assert(revseq); assert(sli); for(i=tstart;iname); } no = seq_number_dna_7mer_noN(target->seq+i); if( no != -1 ) { (*sli->add_direct_number)(sli->data,no,target,i); } } for(i=target->len-tend;ilen-tstart-7;i++) { if( i%1000 == 0 ) { info("Loaded %d positions in %s",i,target->name); } no = seq_number_dna_7mer_noN(revseq->seq+i); if( no != -1 ) { (*sli->add_direct_number)(sli->data,no,revseq,i); } } forward = HSPset_alloc_std(); reverse = HSPset_alloc_std(); /* scan the table with the query, testing whether new hits fit into HSP */ slci = (*sli->get_client)(sli->data); for(i=qstart;iname,forward->len,reverse->len); } no = seq_number_dna_7mer_noN(query->seq+i); if( no == -1 ) { continue; } if( (*slci->is_populated)(sli->data,no) == FALSE) { continue; } res = (*slci->lookup)(sli->data,no); while( (*res->is_more)(res->data) ) { res_struct = (*res->next)(res->data,res_struct); if( res_struct->seq == target ) { process_HSP(forward,query,i,target,res_struct,cm); } else { process_HSP(reverse,query,i,revseq,res_struct,cm); } } free_SeqLookupResultInterface(res); } free_SeqLookupClientInterface(slci); out->forward = forward; out->reverse = reverse; return out; } %} wise-2.4.1/src/models/geneparameter.c0000644000175000001440000004456110670453714017127 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "geneparameter.h" # line 58 "geneparameter.dy" GeneWiseCodonModel * GeneWiseCodonModel_from_GeneFrequencies(double * cds,GeneConsensus * donor,GeneConsensus * acceptor) { int i; int j,k,l; int codon,perm; int one,two,three; GeneWiseCodonModel * out; out = GeneWiseCodonModel_alloc(); for(i=0;i<64;i++) { out->in_donor[i] = out->in_acceptor[i] = out->in_cds[i] = 0.0000001; if( cds[i] < 0.00000001 ) { out->in_cds[i] = 0.0000001; } else { out->in_cds[i] = cds[i]; } } /** done cds **/ /** for splice site, need to figure out if any entry matches, and add it to the total **/ for(l=0;llen;l++) { one = base_from_char(donor->gsc[l]->string[0] == '-' ? 'N' : donor->gsc[l]->string[0]); two = base_from_char(donor->gsc[l]->string[1] == '-' ? 'N' : donor->gsc[l]->string[1]); three = base_from_char(donor->gsc[l]->string[2] == '-' ? 'N' : donor->gsc[l]->string[2]); codon = one*25 + two *5 + three; for(i=0;i<4;i++) for(j=0;j<4;j++) for(k=0;k<4;k++) { perm = permute_possible_random_bases(codon,i,j,k); /** now add this number /64 to its list **/ out->in_donor[perm] += donor->gsc[l]->number / 64.0; } } for(l=0;llen;l++) { one = base_from_char(acceptor->gsc[l]->string[3] == '-' ? 'N' : acceptor->gsc[l]->string[3]); two = base_from_char(acceptor->gsc[l]->string[4] == '-' ? 'N' : acceptor->gsc[l]->string[4]); three = base_from_char(acceptor->gsc[l]->string[5] == '-' ? 'N' : acceptor->gsc[l]->string[5]); codon = one*25 + two *5 + three; for(i=0;i<4;i++) for(j=0;j<4;j++) for(k=0;k<4;k++) { perm = permute_possible_random_bases(codon,i,j,k); /** now add this number /64 to its list **/ out->in_acceptor[perm] = acceptor->gsc[l]->number / 64.0; } } return out; } /* Function: GeneParameter21_from_GeneModel(gm,ct,rnd_loop,cds_loop,rnd_to_model,link_loop,link_to_model,subs_error,indel_error) * * Descrip: This actually makes the GeneParameter21 stuff from the * new statistics * * * Arg: gm [UNKN ] Undocumented argument [GeneModel *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: rnd_loop [UNKN ] Undocumented argument [Probability] * Arg: cds_loop [UNKN ] Undocumented argument [Probability] * Arg: rnd_to_model [UNKN ] Undocumented argument [Probability] * Arg: link_loop [UNKN ] Undocumented argument [Probability] * Arg: link_to_model [UNKN ] Undocumented argument [Probability] * Arg: subs_error [UNKN ] Undocumented argument [Probability] * Arg: indel_error [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [GeneParameter21 *] * */ # line 127 "geneparameter.dy" GeneParameter21 * GeneParameter21_from_GeneModel(GeneModel * gm,CodonTable * ct,Probability rnd_loop,Probability cds_loop,Probability rnd_to_model,Probability link_loop,Probability link_to_model,Probability subs_error,Probability indel_error) { GeneParameter21 * out; CodonFrequency * cf; RandomModelDNAScore * rmds; ComplexSequenceEval * cse; int i; out = GeneParameter21_alloc_len(4); cf = CodonFrequence_from_raw_counts(gm->codon,ct); out->cm = new_CodonMapper(ct,cf); free_CodonFrequency(cf); out->ct = hard_link_CodonTable(ct); out->gp = std_GeneParser21(); for(i=0;i<5;i++) out->gp->central[i] = gm->rnd->base[i]; GeneParser21_fold_in_RandomModelDNA(out->gp,gm->rnd); out->gp->transition[GP21_CDS2CDS] = cds_loop; out->gp->transition[GP21_CDS2RND] = (1-cds_loop); out->gp->transition[GP21_RND2RND] = rnd_loop; /* fprintf(stderr,"Score is %f\n",out->transition[GP21_RND2RND]); */ out->gp->transition[GP21_RND2CDS] = (1-rnd_loop-rnd_to_model); out->gp->transition[GP21_RND2MODEL] = rnd_to_model; out->gp->transition[GP21_LINK2MODEL] = link_to_model; out->gp->transition[GP21_LINK2LINK] = link_loop; out->gp->transition[GP21_LINK2RND] = (1- link_loop - link_to_model) ; /** build random codon stuff, for soaking up "unused" cds **/ out->rc = RandomCodon_from_raw_CodonFrequency(gm->codon,ct); out->cses = new_ComplexSequenceEvalSet_from_GeneModel(gm); /*** errors ***/ sprinkle_errors_over_CodonMapper(out->cm,subs_error); add_flat_error_probabilities_GeneParser21(out->gp,indel_error); fold_in_RandomModelDNA_into_RandomCodon(out->rc,gm->rnd); return out; } # line 183 "geneparameter.dy" GeneParameter21 * GeneParameter21_from_GeneFrequency21(GeneFrequency21 * gf,CodonTable * ct,RandomModelDNA * rmd,Probability rnd_loop,Probability cds_loop,Probability rnd_to_model,Probability link_loop,Probability link_to_model) { GeneParameter21 * out; CodonFrequency * cf; SpliceSiteModel * ssm; ComplexConsensi * cc; RandomModelDNAScore * rmds; ComplexSequenceEval * cse; out = GeneParameter21_alloc_len(4); out->gp = GeneParser21_from_GeneFrequency21_cds(gf,rnd_loop,cds_loop,rnd_to_model,link_loop,link_to_model); /** build a codon frequency, and then from that a codon mapper **/ cf = CodonFrequency_from_GeneFrequency21(gf,ct); out->cm = new_CodonMapper(ct,cf); out->ct = hard_link_CodonTable(ct); free_CodonFrequency(cf); out->gwcm = GeneWiseCodonModel_from_GeneFrequencies(gf->codon,gf->ss5,gf->ss3); /** build random codon stuff, for soaking up "unused" cds **/ out->rc = RandomCodon_from_raw_CodonFrequency(gf->codon,ct); /** make a new ComplexSequenceEvalSet **/ out->cses = ComplexSequenceEvalSet_alloc_len(6); out->cses->type = SEQUENCE_GENOMIC; /** put in the base/codon eval functions **/ add_ComplexSequenceEvalSet(out->cses,base_number_ComplexSequenceEval()); add_ComplexSequenceEvalSet(out->cses,codon_number_ComplexSequenceEval()); /** make a RandomModelDNAScore **/ rmds = RandomModelDNAScore_from_RandomModelDNA(rmd); /** for each splice site, build a complex consensi **/ /** model, then a splice site model for each offset **/ /** then both add it to the SpliceSite model list, **/ /** and attach a ComplexSequenceEval to the set **/ /** 5'SS **/ cc = ComplexConsensi_5SS_from_GeneFrequency(gf); /** only one offset, at 7 **/ ssm = std_5SS_SpliceSiteModel(0,cc,rmds); cse = ComplexSequenceEval_from_SpliceSiteModel(ssm); cse->left_lookback = 10; /** add to Set **/ add_GeneParameter21(out,ssm); /** add complexeval to cses **/ add_ComplexSequenceEvalSet(out->cses,cse); /** ok, free ComplexConsensi. Remember has been hard linked in std_5SS_Splice etc **/ free_ComplexConsensi(cc); /** 3'SS **/ cc = ComplexConsensi_3SS_from_GeneFrequency(gf); ssm = std_3SS_SpliceSiteModel(0,cc,rmds); cse = ComplexSequenceEval_from_SpliceSiteModel(ssm); cse->left_lookback = 6; add_GeneParameter21(out,ssm); add_ComplexSequenceEvalSet(out->cses,cse); /** ok, we can free the complex consensi for 3'SS **/ free_ComplexConsensi(cc); /** and free the randommodel DNA score, as that gets hard-linked as well **/ free_RandomModelDNAScore(rmds); /* * ok, here we would add the necessary repeat and coding info, * but for now... add flat zeros */ add_ComplexSequenceEvalSet(out->cses,flat_zero()); add_ComplexSequenceEvalSet(out->cses,flat_zero()); /** c'est tout **/ return out; } # line 257 "geneparameter.c" /* Function: hard_link_GeneWiseCodonModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseCodonModel *] * * Return [UNKN ] Undocumented return value [GeneWiseCodonModel *] * */ GeneWiseCodonModel * hard_link_GeneWiseCodonModel(GeneWiseCodonModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneWiseCodonModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneWiseCodonModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseCodonModel *] * */ GeneWiseCodonModel * GeneWiseCodonModel_alloc(void) { GeneWiseCodonModel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWiseCodonModel *) ckalloc (sizeof(GeneWiseCodonModel))) == NULL) { warn("GeneWiseCodonModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* in_donor[64] is an array: no default possible */ /* in_acceptor[64] is an array: no default possible */ /* in_cds[64] is an array: no default possible */ return out; } /* Function: free_GeneWiseCodonModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseCodonModel *] * * Return [UNKN ] Undocumented return value [GeneWiseCodonModel *] * */ GeneWiseCodonModel * free_GeneWiseCodonModel(GeneWiseCodonModel * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneWiseCodonModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_GeneParameter21(list,i,j) * * Descrip: swap function: an internal for qsort_GeneParameter21 * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [SpliceSiteModel **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_GeneParameter21(SpliceSiteModel ** list,int i,int j) { SpliceSiteModel * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_GeneParameter21(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_GeneParameter21 which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [SpliceSiteModel **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_GeneParameter21(SpliceSiteModel ** list,int left,int right,int (*comp)(SpliceSiteModel * ,SpliceSiteModel * )) { int i,last; if( left >= right ) return; swap_GeneParameter21(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_GeneParameter21 (list,++last,i); } swap_GeneParameter21 (list,left,last); qsort_GeneParameter21(list,left,last-1,comp); qsort_GeneParameter21(list,last+1,right,comp); } /* Function: sort_GeneParameter21(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_GeneParameter21 * * * Arg: obj [UNKN ] Object containing list [GeneParameter21 *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_GeneParameter21(GeneParameter21 * obj,int (*comp)(SpliceSiteModel *, SpliceSiteModel *)) { qsort_GeneParameter21(obj->ss,0,obj->len-1,comp); return; } /* Function: expand_GeneParameter21(obj,len) * * Descrip: Really an internal function for add_GeneParameter21 * * * Arg: obj [UNKN ] Object which contains the list [GeneParameter21 *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_GeneParameter21(GeneParameter21 * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_GeneParameter21 called with no need"); return TRUE; } if( (obj->ss = (SpliceSiteModel ** ) ckrealloc (obj->ss,sizeof(SpliceSiteModel *)*len)) == NULL) { warn("ckrealloc failed for expand_GeneParameter21, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_GeneParameter21(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GeneParameter21 *] * Arg: add [OWNER] Object to add to the list [SpliceSiteModel *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_GeneParameter21(GeneParameter21 * obj,SpliceSiteModel * add) { if( obj->len >= obj->maxlen) { if( expand_GeneParameter21(obj,obj->len + GeneParameter21LISTLENGTH) == FALSE) return FALSE; } obj->ss[obj->len++]=add; return TRUE; } /* Function: flush_GeneParameter21(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GeneParameter21 *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GeneParameter21(GeneParameter21 * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->ss[i] != NULL) { free_SpliceSiteModel(obj->ss[i]); obj->ss[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: GeneParameter21_alloc_std(void) * * Descrip: Equivalent to GeneParameter21_alloc_len(GeneParameter21LISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GeneParameter21 *] * */ GeneParameter21 * GeneParameter21_alloc_std(void) { return GeneParameter21_alloc_len(GeneParameter21LISTLENGTH); } /* Function: GeneParameter21_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GeneParameter21 *] * */ GeneParameter21 * GeneParameter21_alloc_len(int len) { GeneParameter21 * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = GeneParameter21_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->ss = (SpliceSiteModel ** ) ckcalloc (len,sizeof(SpliceSiteModel *))) == NULL) { warn("Warning, ckcalloc failed in GeneParameter21_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_GeneParameter21(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneParameter21 *] * * Return [UNKN ] Undocumented return value [GeneParameter21 *] * */ GeneParameter21 * hard_link_GeneParameter21(GeneParameter21 * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneParameter21 object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneParameter21_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneParameter21 *] * */ GeneParameter21 * GeneParameter21_alloc(void) { GeneParameter21 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneParameter21 *) ckalloc (sizeof(GeneParameter21))) == NULL) { warn("GeneParameter21_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->gp = NULL; out->cm = NULL; out->cses = NULL; out->ss = NULL; out->len = out->maxlen = 0; out->rc = NULL; out->gwcm = NULL; out->ct = NULL; out->modelled_splice = TRUE; out->gms = NULL; return out; } /* Function: free_GeneParameter21(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneParameter21 *] * * Return [UNKN ] Undocumented return value [GeneParameter21 *] * */ GeneParameter21 * free_GeneParameter21(GeneParameter21 * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneParameter21 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->gp != NULL) free_GeneParser21(obj->gp); if( obj->cm != NULL) free_CodonMapper(obj->cm); if( obj->cses != NULL) free_ComplexSequenceEvalSet(obj->cses); if( obj->ss != NULL) { for(i=0;ilen;i++) { if( obj->ss[i] != NULL) free_SpliceSiteModel(obj->ss[i]); } ckfree(obj->ss); } if( obj->rc != NULL) free_RandomCodon(obj->rc); if( obj->gwcm != NULL) free_GeneWiseCodonModel(obj->gwcm); if( obj->ct != NULL) free_CodonTable(obj->ct); if( obj->gms != NULL) free_GeneModel(obj->gms); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/geneparameter.h0000644000175000001440000002137210670453714017127 0ustar philippusers#ifndef DYNAMITEgeneparameterHEADERFILE #define DYNAMITEgeneparameterHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "geneparser21.h" #include "genefrequency.h" #include "splicesitemodeler.h" #include "complexevalset.h" #include "probability.h" #include "genestats.h" #define GeneParameter21LISTLENGTH 32 struct Wise2_GeneWiseCodonModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif double in_donor[64]; double in_acceptor[64]; double in_cds[64]; } ; /* GeneWiseCodonModel defined */ #ifndef DYNAMITE_DEFINED_GeneWiseCodonModel typedef struct Wise2_GeneWiseCodonModel Wise2_GeneWiseCodonModel; #define GeneWiseCodonModel Wise2_GeneWiseCodonModel #define DYNAMITE_DEFINED_GeneWiseCodonModel #endif /* Object GeneParameter21 * * Descrip: No Description * */ struct Wise2_GeneParameter21 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GeneParser21 * gp; CodonMapper * cm; ComplexSequenceEvalSet * cses; SpliceSiteModel ** ss; /* held only to be free'd when GeneParser21Set is free'd */ int len;/* len for above ss */ int maxlen; /* maxlen for above ss */ RandomCodon * rc; /* needed to soak up the odd-and-sods of genes */ GeneWiseCodonModel * gwcm; CodonTable * ct; boolean modelled_splice; /* so we can alter balance scores. */ GeneModel * gms; } ; /* GeneParameter21 defined */ #ifndef DYNAMITE_DEFINED_GeneParameter21 typedef struct Wise2_GeneParameter21 Wise2_GeneParameter21; #define GeneParameter21 Wise2_GeneParameter21 #define DYNAMITE_DEFINED_GeneParameter21 #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: GeneParameter21_from_GeneModel(gm,ct,rnd_loop,cds_loop,rnd_to_model,link_loop,link_to_model,subs_error,indel_error) * * Descrip: This actually makes the GeneParameter21 stuff from the * new statistics * * * Arg: gm [UNKN ] Undocumented argument [GeneModel *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: rnd_loop [UNKN ] Undocumented argument [Probability] * Arg: cds_loop [UNKN ] Undocumented argument [Probability] * Arg: rnd_to_model [UNKN ] Undocumented argument [Probability] * Arg: link_loop [UNKN ] Undocumented argument [Probability] * Arg: link_to_model [UNKN ] Undocumented argument [Probability] * Arg: subs_error [UNKN ] Undocumented argument [Probability] * Arg: indel_error [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [GeneParameter21 *] * */ GeneParameter21 * Wise2_GeneParameter21_from_GeneModel(GeneModel * gm,CodonTable * ct,Probability rnd_loop,Probability cds_loop,Probability rnd_to_model,Probability link_loop,Probability link_to_model,Probability subs_error,Probability indel_error); #define GeneParameter21_from_GeneModel Wise2_GeneParameter21_from_GeneModel /* Function: hard_link_GeneWiseCodonModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseCodonModel *] * * Return [UNKN ] Undocumented return value [GeneWiseCodonModel *] * */ GeneWiseCodonModel * Wise2_hard_link_GeneWiseCodonModel(GeneWiseCodonModel * obj); #define hard_link_GeneWiseCodonModel Wise2_hard_link_GeneWiseCodonModel /* Function: GeneWiseCodonModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseCodonModel *] * */ GeneWiseCodonModel * Wise2_GeneWiseCodonModel_alloc(void); #define GeneWiseCodonModel_alloc Wise2_GeneWiseCodonModel_alloc /* Function: free_GeneWiseCodonModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseCodonModel *] * * Return [UNKN ] Undocumented return value [GeneWiseCodonModel *] * */ GeneWiseCodonModel * Wise2_free_GeneWiseCodonModel(GeneWiseCodonModel * obj); #define free_GeneWiseCodonModel Wise2_free_GeneWiseCodonModel /* Function: add_GeneParameter21(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GeneParameter21 *] * Arg: add [OWNER] Object to add to the list [SpliceSiteModel *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_GeneParameter21(GeneParameter21 * obj,SpliceSiteModel * add); #define add_GeneParameter21 Wise2_add_GeneParameter21 /* Function: flush_GeneParameter21(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GeneParameter21 *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_GeneParameter21(GeneParameter21 * obj); #define flush_GeneParameter21 Wise2_flush_GeneParameter21 /* Function: GeneParameter21_alloc_std(void) * * Descrip: Equivalent to GeneParameter21_alloc_len(GeneParameter21LISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GeneParameter21 *] * */ GeneParameter21 * Wise2_GeneParameter21_alloc_std(void); #define GeneParameter21_alloc_std Wise2_GeneParameter21_alloc_std /* Function: GeneParameter21_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GeneParameter21 *] * */ GeneParameter21 * Wise2_GeneParameter21_alloc_len(int len); #define GeneParameter21_alloc_len Wise2_GeneParameter21_alloc_len /* Function: hard_link_GeneParameter21(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneParameter21 *] * * Return [UNKN ] Undocumented return value [GeneParameter21 *] * */ GeneParameter21 * Wise2_hard_link_GeneParameter21(GeneParameter21 * obj); #define hard_link_GeneParameter21 Wise2_hard_link_GeneParameter21 /* Function: GeneParameter21_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneParameter21 *] * */ GeneParameter21 * Wise2_GeneParameter21_alloc(void); #define GeneParameter21_alloc Wise2_GeneParameter21_alloc /* Function: free_GeneParameter21(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneParameter21 *] * * Return [UNKN ] Undocumented return value [GeneParameter21 *] * */ GeneParameter21 * Wise2_free_GeneParameter21(GeneParameter21 * obj); #define free_GeneParameter21 Wise2_free_GeneParameter21 /* Unplaced functions */ /* There has been no indication of the use of these functions */ GeneWiseCodonModel * Wise2_GeneWiseCodonModel_from_GeneFrequencies(double * cds,GeneConsensus * donor,GeneConsensus * acceptor); #define GeneWiseCodonModel_from_GeneFrequencies Wise2_GeneWiseCodonModel_from_GeneFrequencies GeneParameter21 * Wise2_GeneParameter21_from_GeneFrequency21(GeneFrequency21 * gf,CodonTable * ct,RandomModelDNA * rmd,Probability rnd_loop,Probability cds_loop,Probability rnd_to_model,Probability link_loop,Probability link_to_model); #define GeneParameter21_from_GeneFrequency21 Wise2_GeneParameter21_from_GeneFrequency21 /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_GeneParameter21(SpliceSiteModel ** list,int i,int j) ; #define swap_GeneParameter21 Wise2_swap_GeneParameter21 void Wise2_qsort_GeneParameter21(SpliceSiteModel ** list,int left,int right,int (*comp)(SpliceSiteModel * ,SpliceSiteModel * )); #define qsort_GeneParameter21 Wise2_qsort_GeneParameter21 void Wise2_sort_GeneParameter21(GeneParameter21 * obj,int (*comp)(SpliceSiteModel *, SpliceSiteModel *)); #define sort_GeneParameter21 Wise2_sort_GeneParameter21 boolean Wise2_expand_GeneParameter21(GeneParameter21 * obj,int len); #define expand_GeneParameter21 Wise2_expand_GeneParameter21 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/largeblockdp.c0000644000175000001440000047671010670453714016746 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "largeblockdp.h" # line 6 "largeblockdp.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define UNMATCHED 3 #define START 0 #define END 1 #define LargeBlockAligner_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*4)+STATE][i+1] #define LargeBlockAligner_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define LargeBlockAligner_READ_OFF_ERROR -3 #define LargeBlockAligner_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*4)+STATE] #define LargeBlockAligner_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define LargeBlockAligner_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define LargeBlockAligner_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_LargeBlockAligner(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_LargeBlockAligner(LargeBlockAligner * mat) { LargeBlockAligner_access_func_holder holder; holder.access_main = LargeBlockAligner_shatter_access_main; holder.access_special = LargeBlockAligner_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_LargeBlockAligner(mat,holder); } /* Function: LargeBlockAligner_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LargeBlockAligner_shatter_access_main(LargeBlockAligner * mat,int i,int j,int state) { return LargeBlockAligner_SHATTER_MATRIX(mat,i,j,state); } /* Function: LargeBlockAligner_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LargeBlockAligner_shatter_access_special(LargeBlockAligner * mat,int i,int j,int state) { return LargeBlockAligner_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_LargeBlockAligner(mat,dpenv) * * Descrip: This function calculates the LargeBlockAligner matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [LargeBlockAligner *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_LargeBlockAligner(LargeBlockAligner * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,4,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("LargeBlockAligner Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_1[MATCH] + 0; /* From state INSERT to state MATCH */ temp = SIG_1_1[INSERT] + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_1[DELETE] + 0; if( temp > score ) { score = temp; } /* From state UNMATCHED to state MATCH */ temp = SIG_1_1[UNMATCHED] + mat->block_open; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = LargeBlockAligner_SHATTER_SPECIAL(mat,i-1,j-1,START) + mat->block_open; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += (DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext); SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > LargeBlockAligner_SHATTER_SPECIAL(mat,i,j,END) ) { LargeBlockAligner_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_1[MATCH] + mat->gap_open; /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->gap_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ SIG_0_0[INSERT] = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->gap_open; /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->gap_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* Finished calculating state DELETE */ /* For state UNMATCHED */ /* setting first movement to score */ score = SIG_1_1[MATCH] + mat->un_dual; /* From state START to state UNMATCHED */ temp = LargeBlockAligner_SHATTER_SPECIAL(mat,i-1,j-1,START) + mat->un_dual; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = SIG_1_1[UNMATCHED] + mat->un_dual; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = SIG_0_1[UNMATCHED] + mat->un_single; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = SIG_1_0[UNMATCHED] + mat->un_single; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ SIG_0_0[UNMATCHED] = score; /* state UNMATCHED is a source for special END */ temp = score + (0) + (0) ; if( temp > LargeBlockAligner_SHATTER_SPECIAL(mat,i,j,END) ) { LargeBlockAligner_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state UNMATCHED */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_LargeBlockAligner(dbsi,out,q,t,dm,real_ext,block_open,un_dual,un_single,gap_open,gap_ext) * * Descrip: This function makes a database search of LargeBlockAligner * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [ComplexSequence*] * Arg: t [UNKN ] Undocumented argument [ComplexSequence*] * Arg: dm [UNKN ] Undocumented argument [DnaMatrix*] * Arg: real_ext [UNKN ] Undocumented argument [Score] * Arg: block_open [UNKN ] Undocumented argument [Score] * Arg: un_dual [UNKN ] Undocumented argument [Score] * Arg: un_single [UNKN ] Undocumented argument [Score] * Arg: gap_open [UNKN ] Undocumented argument [Score] * Arg: gap_ext [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_LargeBlockAligner(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext) { if( out == NULL ) { warn("Passed in a null Hscore object into search_LargeBlockAligner. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_LargeBlockAligner. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for LargeBlockAligner, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_LargeBlockAligner(out,q,t ,dm,real_ext,block_open,un_dual,un_single,gap_open,gap_ext); case DBSearchImpl_Pthreads : warn("This matrix LargeBlockAligner was not dyc compiled with thread support"); return SEARCH_ERROR; default : warn("database search implementation %s was not provided in the compiled dynamite file from LargeBlockAligner",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: serial_search_LargeBlockAligner(out,q,t,dm,real_ext,block_open,un_dual,un_single,gap_open,gap_ext) * * Descrip: This function makes a database search of LargeBlockAligner * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [ComplexSequence*] * Arg: t [UNKN ] Undocumented argument [ComplexSequence*] * Arg: dm [UNKN ] Undocumented argument [DnaMatrix*] * Arg: real_ext [UNKN ] Undocumented argument [Score] * Arg: block_open [UNKN ] Undocumented argument [Score] * Arg: un_dual [UNKN ] Undocumented argument [Score] * Arg: un_single [UNKN ] Undocumented argument [Score] * Arg: gap_open [UNKN ] Undocumented argument [Score] * Arg: gap_ext [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_LargeBlockAligner(Hscore * out,ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_LargeBlockAligner(q, t , dm, real_ext, block_open, un_dual, un_single, gap_open, gap_ext); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("LargeBlockAligner search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_LargeBlockAligner(q,t,dm,real_ext,block_open,un_dual,un_single,gap_open,gap_ext) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_LargeBlockAligner_only * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: dm [UNKN ] Resource [DnaMatrix*] * Arg: real_ext [UNKN ] Resource [Score] * Arg: block_open [UNKN ] Resource [Score] * Arg: un_dual [UNKN ] Resource [Score] * Arg: un_single [UNKN ] Resource [Score] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_LargeBlockAligner(ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext) { int bestscore = NEGI; int i; int j; int k; LargeBlockAligner * mat; mat = allocate_LargeBlockAligner_only(q, t , dm, real_ext, block_open, un_dual, un_single, gap_open, gap_ext); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 4,2,2)) == NULL) { warn("Score only matrix for LargeBlockAligner cannot be allocated, (asking for 1 by %d cells)",mat->leni*4); mat = free_LargeBlockAligner(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<4;k++) LargeBlockAligner_VSMALL_MATRIX(mat,i,j,k) = NEGI; } LargeBlockAligner_VSMALL_SPECIAL(mat,i,j,START) = 0; LargeBlockAligner_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = LargeBlockAligner_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = LargeBlockAligner_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = LargeBlockAligner_VSMALL_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state UNMATCHED to state MATCH */ temp = LargeBlockAligner_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->block_open; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = LargeBlockAligner_VSMALL_SPECIAL(mat,i-1,j-1,START) + mat->block_open; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += (DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext); LargeBlockAligner_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > LargeBlockAligner_VSMALL_SPECIAL(mat,i,j,END) ) { LargeBlockAligner_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = LargeBlockAligner_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + mat->gap_open; /* From state INSERT to state INSERT */ temp = LargeBlockAligner_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->gap_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ LargeBlockAligner_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = LargeBlockAligner_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->gap_open; /* From state DELETE to state DELETE */ temp = LargeBlockAligner_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->gap_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ LargeBlockAligner_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state UNMATCHED */ /* setting first movement to score */ score = LargeBlockAligner_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->un_dual; /* From state START to state UNMATCHED */ temp = LargeBlockAligner_VSMALL_SPECIAL(mat,i-1,j-1,START) + mat->un_dual; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->un_dual; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_VSMALL_MATRIX(mat,i-0,j-1,UNMATCHED) + mat->un_single; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_VSMALL_MATRIX(mat,i-1,j-0,UNMATCHED) + mat->un_single; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ LargeBlockAligner_VSMALL_MATRIX(mat,i,j,UNMATCHED) = score; /* state UNMATCHED is a source for special END */ temp = score + (0) + (0) ; if( temp > LargeBlockAligner_VSMALL_SPECIAL(mat,i,j,END) ) { LargeBlockAligner_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state UNMATCHED */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < LargeBlockAligner_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = LargeBlockAligner_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_LargeBlockAligner(mat); return bestscore; } /* Function: PackAln_bestmemory_LargeBlockAligner(q,t,dm,real_ext,block_open,un_dual,un_single,gap_open,gap_ext,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_LargeBlockAligner * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: dm [UNKN ] Resource [DnaMatrix*] * Arg: real_ext [UNKN ] Resource [Score] * Arg: block_open [UNKN ] Resource [Score] * Arg: un_dual [UNKN ] Resource [Score] * Arg: un_single [UNKN ] Resource [Score] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_LargeBlockAligner(ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; LargeBlockAligner * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = q->seq->len * t->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 4 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_LargeBlockAligner(q, t , dm, real_ext, block_open, un_dual, un_single, gap_open, gap_ext,dpri)) == NULL ) { warn("Unable to allocate large LargeBlockAligner version"); return NULL; } calculate_dpenv_LargeBlockAligner(mat,dpenv); out = PackAln_read_Expl_LargeBlockAligner(mat); } else { mat = allocate_LargeBlockAligner_only(q, t , dm, real_ext, block_open, un_dual, un_single, gap_open, gap_ext); calculate_shatter_LargeBlockAligner(mat,dpenv); out = PackAln_read_Shatter_LargeBlockAligner(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_LargeBlockAligner(q, t , dm, real_ext, block_open, un_dual, un_single, gap_open, gap_ext)) == NULL ) { warn("Unable to allocate small LargeBlockAligner version"); return NULL; } out = PackAln_calculate_Small_LargeBlockAligner(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_LargeBlockAligner(q, t , dm, real_ext, block_open, un_dual, un_single, gap_open, gap_ext,dpri)) == NULL ) { warn("Unable to allocate large LargeBlockAligner version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_LargeBlockAligner(mat); out = PackAln_read_Expl_LargeBlockAligner(mat); } } } mat = free_LargeBlockAligner(mat); return out; } /* Function: allocate_LargeBlockAligner_only(q,t,dm,real_ext,block_open,un_dual,un_single,gap_open,gap_ext) * * Descrip: This function only allocates the LargeBlockAligner structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: dm [UNKN ] Resource [DnaMatrix*] * Arg: real_ext [UNKN ] Resource [Score] * Arg: block_open [UNKN ] Resource [Score] * Arg: un_dual [UNKN ] Resource [Score] * Arg: un_single [UNKN ] Resource [Score] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [LargeBlockAligner *] * */ LargeBlockAligner * allocate_LargeBlockAligner_only(ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext) { LargeBlockAligner * out; if((out= LargeBlockAligner_alloc()) == NULL) { warn("Allocation of basic LargeBlockAligner structure failed..."); return NULL; } out->q = q; out->t = t; out->dm = dm; out->real_ext = real_ext; out->block_open = block_open; out->un_dual = un_dual; out->un_single = un_single; out->gap_open = gap_open; out->gap_ext = gap_ext; out->leni = q->seq->len; out->lenj = t->seq->len; return out; } /* Function: allocate_Expl_LargeBlockAligner(q,t,dm,real_ext,block_open,un_dual,un_single,gap_open,gap_ext,dpri) * * Descrip: This function allocates the LargeBlockAligner structure * and the basematrix area for explicit memory implementations * It calls /allocate_LargeBlockAligner_only * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: dm [UNKN ] Resource [DnaMatrix*] * Arg: real_ext [UNKN ] Resource [Score] * Arg: block_open [UNKN ] Resource [Score] * Arg: un_dual [UNKN ] Resource [Score] * Arg: un_single [UNKN ] Resource [Score] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [LargeBlockAligner *] * */ LargeBlockAligner * allocate_Expl_LargeBlockAligner(ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext,DPRunImpl * dpri) { LargeBlockAligner * out; out = allocate_LargeBlockAligner_only(q, t , dm, real_ext, block_open, un_dual, un_single, gap_open, gap_ext); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*4 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*4,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix LargeBlockAligner cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_LargeBlockAligner(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_LargeBlockAligner(out); return out; } /* Function: init_LargeBlockAligner(mat) * * Descrip: This function initates LargeBlockAligner matrix when in explicit mode * Called in /allocate_Expl_LargeBlockAligner * * * Arg: mat [UNKN ] LargeBlockAligner which contains explicit basematrix memory [LargeBlockAligner *] * */ void init_LargeBlockAligner(LargeBlockAligner * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iq->seq->len;i++) { for(j= (-1);j<2;j++) { LargeBlockAligner_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; LargeBlockAligner_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; LargeBlockAligner_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; LargeBlockAligner_EXPL_MATRIX(mat,i,j,UNMATCHED) = NEGI; } } for(j= (-1);jt->seq->len;j++) { for(i= (-1);i<2;i++) { LargeBlockAligner_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; LargeBlockAligner_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; LargeBlockAligner_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; LargeBlockAligner_EXPL_MATRIX(mat,i,j,UNMATCHED) = NEGI; } LargeBlockAligner_EXPL_SPECIAL(mat,i,j,START) = 0; LargeBlockAligner_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_LargeBlockAligner(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by LargeBlockAligner * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * */ void recalculate_PackAln_LargeBlockAligner(PackAln * pal,LargeBlockAligner * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = 0 + ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = 0 + ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); continue; } if( offi == 1 && offj == 1 && prev->state == DELETE ) { pau->score = 0 + ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED ) { pau->score = mat->block_open + ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); continue; } if( offj == 1 && prev->state == (START+4) ) { pau->score = mat->block_open + ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = mat->gap_open + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->gap_ext + (0); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->gap_open + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->gap_ext + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UNMATCHED : if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->un_dual + (0); continue; } if( offj == 1 && prev->state == (START+4) ) { pau->score = mat->un_dual + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED ) { pau->score = mat->un_dual + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UNMATCHED ) { pau->score = mat->un_single + (0); continue; } if( offi == 1 && offj == 0 && prev->state == UNMATCHED ) { pau->score = mat->un_single + (0); continue; } warn("In recaluclating PackAln with state UNMATCHED, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+4) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+4) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == UNMATCHED ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define LargeBlockAligner_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*4+state]) #define LargeBlockAligner_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*4+state]) #define LargeBlockAligner_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define LargeBlockAligner_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define LargeBlockAligner_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*4 + state]) #define LargeBlockAligner_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define LargeBlockAligner_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 4) + ((i+1) * 4) + (state)]) #define LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 32) + ((i+1) * 32) + (state * 8) + shadow+1]) #define LargeBlockAligner_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_LargeBlockAligner(q,t,dm,real_ext,block_open,un_dual,un_single,gap_open,gap_ext) * * Descrip: This function allocates the LargeBlockAligner structure * and the basematrix area for a small memory implementations * It calls /allocate_LargeBlockAligner_only * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: dm [UNKN ] Resource [DnaMatrix*] * Arg: real_ext [UNKN ] Resource [Score] * Arg: block_open [UNKN ] Resource [Score] * Arg: un_dual [UNKN ] Resource [Score] * Arg: un_single [UNKN ] Resource [Score] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [LargeBlockAligner *] * */ #define LargeBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) LargeBlockAligner * allocate_Small_LargeBlockAligner(ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext) { LargeBlockAligner * out; out = allocate_LargeBlockAligner_only(q, t , dm, real_ext, block_open, un_dual, un_single, gap_open, gap_ext); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 4,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix LargeBlockAligner cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_LargeBlockAligner(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_LargeBlockAligner(mat,dpenv) * * Descrip: This function calculates an alignment for LargeBlockAligner structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_LargeBlockAligner * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_LargeBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_LargeBlockAligner(LargeBlockAligner * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for LargeBlockAligner due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_LargeBlockAligner(mat,dpenv); score = start_end_find_end_LargeBlockAligner(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_LargeBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_LargeBlockAligner(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == LargeBlockAligner_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_LargeBlockAligner(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 4; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_LargeBlockAligner(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_LargeBlockAligner(mat) * * Descrip: This function calculates an alignment for LargeBlockAligner structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_LargeBlockAligner * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_LargeBlockAligner * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_LargeBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_LargeBlockAligner(LargeBlockAligner * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_LargeBlockAligner(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_LargeBlockAligner(mat); return out; } /* Function: AlnRangeSet_from_LargeBlockAligner(mat) * * Descrip: This function reads off a start/end structure * for LargeBlockAligner structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_LargeBlockAligner * If you have not calculated the matrix use * /AlnRange_calculate_Small_LargeBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_LargeBlockAligner(LargeBlockAligner * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_LargeBlockAligner"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_LargeBlockAligner(mat,&jpos); state = END; while( (temp = AlnRange_build_LargeBlockAligner(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_LargeBlockAligner(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_LargeBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_LargeBlockAligner(LargeBlockAligner * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_LargeBlockAligner"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_LargeBlockAligner(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_LargeBlockAligner alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = LargeBlockAligner_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_LargeBlockAligner(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == LargeBlockAligner_READ_OFF_ERROR) { warn("In AlnRange_build_LargeBlockAligner alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = LargeBlockAligner_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_LargeBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_LargeBlockAligner(LargeBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_LargeBlockAligner(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == LargeBlockAligner_READ_OFF_ERROR) { warn("In LargeBlockAligner hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In LargeBlockAligner hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In LargeBlockAligner hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_LargeBlockAligner(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_LargeBlockAligner(LargeBlockAligner * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = LargeBlockAligner_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->q->seq->len || j > mat->t->seq->len) { warn("In LargeBlockAligner matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = LargeBlockAligner_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->block_open) - ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp == LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED); } return LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED); } temp = cscore - (0) - ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp == LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,DELETE); } return LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE); } temp = cscore - (0) - ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp == LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (0) - ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp == LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in LargeBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gap_ext) - (0); if( temp == LargeBlockAligner_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return LargeBlockAligner_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gap_open) - (0); if( temp == LargeBlockAligner_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return LargeBlockAligner_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in LargeBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->gap_ext) - (0); if( temp == LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->gap_open) - (0); if( temp == LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in LargeBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED : temp = cscore - (mat->un_single) - (0); if( temp == LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 0,UNMATCHED) ) { *reti = i - 1; *retj = j - 0; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-0,UNMATCHED); } return LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 0,UNMATCHED); } temp = cscore - (mat->un_single) - (0); if( temp == LargeBlockAligner_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED); } return LargeBlockAligner_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED); } temp = cscore - (mat->un_dual) - (0); if( temp == LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED); } return LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED); } /* Not allowing special sources.. skipping START */ temp = cscore - (mat->un_dual) - (0); if( temp == LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return LargeBlockAligner_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in LargeBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in LargeBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_LargeBlockAligner(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_LargeBlockAligner(LargeBlockAligner * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 4; add_PackAln(out,pau); } max_special_strip_LargeBlockAligner(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == LargeBlockAligner_READ_OFF_ERROR) { warn("In special strip read LargeBlockAligner, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read LargeBlockAligner, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 4; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_LargeBlockAligner(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_LargeBlockAligner(LargeBlockAligner * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = LargeBlockAligner_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for LargeBlockAligner, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->t->seq->len) { warn("In LargeBlockAligner matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = LargeBlockAligner_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source UNMATCHED is not a special */ /* Source MATCH is not a special */ default: warn("Major problem (!) - in LargeBlockAligner special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_LargeBlockAligner(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_LargeBlockAligner(LargeBlockAligner * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = LargeBlockAligner_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In LargeBlockAligner matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->block_open) - ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp == LargeBlockAligner_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return LargeBlockAligner_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source UNMATCHED is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in LargeBlockAligner matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in LargeBlockAligner matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Source DELETE is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in LargeBlockAligner matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED : /* Source UNMATCHED is not a special, should not get here! */ /* Source UNMATCHED is not a special, should not get here! */ /* Source UNMATCHED is not a special, should not get here! */ temp = cscore - (mat->un_dual) - (0); if( temp == LargeBlockAligner_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - LargeBlockAligner_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return LargeBlockAligner_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in LargeBlockAligner matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in LargeBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_LargeBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_LargeBlockAligner(LargeBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_LargeBlockAligner(mat,starti,startj,stopi,stopj); LargeBlockAligner_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LargeBlockAligner_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; LargeBlockAligner_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; LargeBlockAligner_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; LargeBlockAligner_HIDDEN_MATRIX(mat,i,j,UNMATCHED) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state UNMATCHED to state MATCH */ temp = LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->block_open; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += (DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext); LargeBlockAligner_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = LargeBlockAligner_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + mat->gap_open; /* From state INSERT to state INSERT */ temp = LargeBlockAligner_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->gap_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ LargeBlockAligner_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->gap_open; /* From state DELETE to state DELETE */ temp = LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->gap_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ LargeBlockAligner_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state UNMATCHED */ /* setting first movement to score */ score = LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->un_dual; /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->un_dual; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED) + mat->un_single; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_HIDDEN_MATRIX(mat,i-1,j-0,UNMATCHED) + mat->un_single; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ LargeBlockAligner_HIDDEN_MATRIX(mat,i,j,UNMATCHED) = score; /* Finished calculating state UNMATCHED */ } } return; } /* Function: init_hidden_LargeBlockAligner(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_LargeBlockAligner(LargeBlockAligner * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { LargeBlockAligner_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; LargeBlockAligner_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; LargeBlockAligner_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; LargeBlockAligner_HIDDEN_MATRIX(mat,i,j,UNMATCHED) = NEGI; } } return; } /* Function: full_dc_LargeBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_LargeBlockAligner * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_LargeBlockAligner to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [LargeBlockAligner *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_LargeBlockAligner(LargeBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_LargeBlockAligner"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_LargeBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_LargeBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_LargeBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for LargeBlockAligner, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_LargeBlockAligner(mat,LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_LargeBlockAligner(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_LargeBlockAligner(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_LargeBlockAligner(LargeBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_LargeBlockAligner(mat); LargeBlockAligner_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_LargeBlockAligner(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_LargeBlockAligner(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_LargeBlockAligner(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_LargeBlockAligner(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_LargeBlockAligner(LargeBlockAligner * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,0) = (-100); LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; if( j - 1 <= mergej) { LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } } temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->block_open; if( temp > score) { score = temp; if( j - 1 <= mergej) { LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = UNMATCHED; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED,k); } } /* Add any movement independant score */ score += (DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext); LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gap_open; if( j - 1 <= mergej) { LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gap_ext; if( temp > score) { score = temp; if( j - 1 <= mergej) { LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } /* Add any movement independant score */ LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->gap_open; if( j - 0 <= mergej) { LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->gap_ext; if( temp > score) { score = temp; if( j - 0 <= mergej) { LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ /* For state UNMATCHED, pushing when j - offj <= mergej */ score = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->un_dual; if( j - 1 <= mergej) { LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,0) = i-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,1) = j-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,2) = MATCH; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,3) = i; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,4) = j; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,5) = UNMATCHED; } else { for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->un_dual; if( temp > score) { score = temp; if( j - 1 <= mergej) { LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,0) = i-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,1) = j-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,2) = UNMATCHED; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,3) = i; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,4) = j; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,5) = UNMATCHED; } else { for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED,k); } } temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED) + mat->un_single; if( temp > score) { score = temp; if( j - 1 <= mergej) { LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,0) = i-0; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,1) = j-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,2) = UNMATCHED; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,3) = i; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,4) = j; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,5) = UNMATCHED; } else { for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED,k); } } temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED) + mat->un_single; if( temp > score) { score = temp; if( j - 0 <= mergej) { LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,0) = i-1; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,1) = j-0; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,2) = UNMATCHED; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,3) = i; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,4) = j; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,5) = UNMATCHED; } else { for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED,k); } } /* Add any movement independant score */ LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = score; /* Finished with state UNMATCHED */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_LargeBlockAligner(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_LargeBlockAligner(LargeBlockAligner * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); /* From state INSERT to state MATCH */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* From state DELETE to state MATCH */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } /* From state UNMATCHED to state MATCH */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->block_open; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += (DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext); LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gap_open; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); /* From state INSERT to state INSERT */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gap_ext; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->gap_open; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state DELETE to state DELETE */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->gap_ext; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state UNMATCHED */ /* setting first movement to score */ score = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->un_dual; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->un_dual; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED,k); } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED) + mat->un_single; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED,k); } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED) + mat->un_single; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED,k); } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = score; for(k=0;k<7;k++) LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_LargeBlockAligner(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_LargeBlockAligner(LargeBlockAligner * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state UNMATCHED to state MATCH */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->block_open; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += (DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext); LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gap_open; /* From state INSERT to state INSERT */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gap_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->gap_open; /* From state DELETE to state DELETE */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->gap_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state UNMATCHED */ /* setting first movement to score */ score = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->un_dual; /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->un_dual; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED) + mat->un_single; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED) + mat->un_single; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = score; /* Finished calculating state UNMATCHED */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_LargeBlockAligner(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * */ } void init_dc_LargeBlockAligner(LargeBlockAligner * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iq->seq->len;i++) { LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = NEGI; for(k=0;k<7;k++) { LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = (-1); } } } return; } /* Function: start_end_find_end_LargeBlockAligner(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [LargeBlockAligner *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_LargeBlockAligner(LargeBlockAligner * mat,int * endj) { register int j; register int max; register int maxj; max = LargeBlockAligner_DC_SHADOW_SPECIAL(mat,0,mat->t->seq->len-1,END); maxj = mat->t->seq->len-1; for(j= mat->t->seq->len-2 ;j >= 0 ;j--) { if( LargeBlockAligner_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = LargeBlockAligner_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_LargeBlockAligner(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [LargeBlockAligner] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_LargeBlockAligner(LargeBlockAligner *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->q->seq->len; lenj = mat->t->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 4,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 4 * 8,sizeof(int)); for(j=0;jdm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); /* assign local shadown pointer */ localsp = &(LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); /* From state INSERT to state MATCH */ temp = LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0 +((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* From state DELETE to state MATCH */ temp = LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0 +((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,0)); } /* From state UNMATCHED to state MATCH */ temp = LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->block_open +((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED,0)); } /* From state START to state MATCH */ temp = LargeBlockAligner_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + mat->block_open + ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > LargeBlockAligner_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { LargeBlockAligner_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) LargeBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); LargeBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); LargeBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; LargeBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; LargeBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gap_open + (0); /* assign local shadown pointer */ localsp = &(LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); /* From state INSERT to state INSERT */ temp = LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gap_ext +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->gap_open + (0); /* assign local shadown pointer */ localsp = &(LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state DELETE to state DELETE */ temp = LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->gap_ext +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state UNMATCHED */ /* setting first movement to score */ score = LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->un_dual + (0); /* assign local shadown pointer */ localsp = &(LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); /* From state START to state UNMATCHED */ temp = LargeBlockAligner_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + mat->un_dual + (0); if( temp > score ) { score = temp; /* This state [START] is a special for UNMATCHED... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= UNMATCHED; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->un_dual +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED,0)); } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED) + mat->un_single +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED,0)); } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED) + mat->un_single +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED,0)); } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LargeBlockAligner_DC_OPT_SHADOW_MATRIX(mat,i,j,UNMATCHED) = score; for(k=0;k<7;k++) LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state UNMATCHED is a source for special END */ temp = score + (0) + (0) ; if( temp > LargeBlockAligner_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { LargeBlockAligner_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) LargeBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k); LargeBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = LargeBlockAligner_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,6); LargeBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; LargeBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; LargeBlockAligner_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = UNMATCHED; } /* Finished calculating state UNMATCHED */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_LargeBlockAligner(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * */ void init_start_end_linear_LargeBlockAligner(LargeBlockAligner * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iq->seq->len;i++) { LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); LargeBlockAligner_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = NEGI; LargeBlockAligner_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,0) = (-1); } } for(j=(-1);jt->seq->len;j++) { LargeBlockAligner_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; LargeBlockAligner_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; LargeBlockAligner_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_LargeBlockAligner(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_LargeBlockAligner(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_LargeBlockAligner(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "SEQUENCE","INSERT","UNMATCHED_SEQUENCE","END" }; /* Function: AlnConvertSet_LargeBlockAligner(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "SEQUENCE","INSERT","UNMATCHED_SEQUENCE","END" }; AlnConvertSet * AlnConvertSet_LargeBlockAligner(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 4; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = UNMATCHED; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 4; acu->is_from_special = TRUE; acu->state2 = UNMATCHED; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED; acu->state2 = UNMATCHED; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED; acu->state2 = UNMATCHED; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED; acu->state2 = UNMATCHED; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 4; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED; acu->state2 = END + 4; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[3]; return out; } /* Function: PackAln_read_Expl_LargeBlockAligner(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_LargeBlockAligner(LargeBlockAligner * mat) { LargeBlockAligner_access_func_holder holder; holder.access_main = LargeBlockAligner_explicit_access_main; holder.access_special = LargeBlockAligner_explicit_access_special; return PackAln_read_generic_LargeBlockAligner(mat,holder); } /* Function: LargeBlockAligner_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LargeBlockAligner_explicit_access_main(LargeBlockAligner * mat,int i,int j,int state) { return LargeBlockAligner_EXPL_MATRIX(mat,i,j,state); } /* Function: LargeBlockAligner_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LargeBlockAligner_explicit_access_special(LargeBlockAligner * mat,int i,int j,int state) { return LargeBlockAligner_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_LargeBlockAligner(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: h [UNKN ] Undocumented argument [LargeBlockAligner_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_LargeBlockAligner(LargeBlockAligner * mat,LargeBlockAligner_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_LargeBlockAligner(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in LargeBlockAligner_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 4; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_LargeBlockAligner(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_LargeBlockAligner(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == LargeBlockAligner_READ_OFF_ERROR || j == LargeBlockAligner_READ_OFF_ERROR || state == LargeBlockAligner_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in LargeBlockAligner_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 4; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_LargeBlockAligner(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [LargeBlockAligner_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_LargeBlockAligner(LargeBlockAligner * mat,int * ri,int * rj,int * state,boolean * isspecial,LargeBlockAligner_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->t->seq->len-1,END); maxj = mat->t->seq->len-1; for(j= mat->t->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: LargeBlockAligner_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void LargeBlockAligner_debug_show_matrix(LargeBlockAligner * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iq->seq->len;i++) { for(j=startj;jt->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",LargeBlockAligner_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",LargeBlockAligner_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",LargeBlockAligner_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"State UNMATCHED %d\n",LargeBlockAligner_EXPL_MATRIX(mat,i,j,UNMATCHED)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_LargeBlockAligner(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [LargeBlockAligner_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_LargeBlockAligner(LargeBlockAligner * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LargeBlockAligner_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = LargeBlockAligner_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->q->seq->len || j > mat->t->seq->len) { warn("In LargeBlockAligner matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->block_open) - ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (mat->block_open) - ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED); } temp = cscore - (0) - ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp == (*h.access_main)(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,DELETE); } return (*h.access_main)(mat,i - 1,j - 1,DELETE); } temp = cscore - (0) - ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (0) - ((DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext)); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in LargeBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gap_ext) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gap_open) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in LargeBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->gap_ext) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->gap_open) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in LargeBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED : temp = cscore - (mat->un_single) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,UNMATCHED) ) { *reti = i - 1; *retj = j - 0; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,UNMATCHED); } return (*h.access_main)(mat,i - 1,j - 0,UNMATCHED); } temp = cscore - (mat->un_single) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UNMATCHED) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UNMATCHED); } return (*h.access_main)(mat,i - 0,j - 1,UNMATCHED); } temp = cscore - (mat->un_dual) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED); } temp = cscore - (mat->un_dual) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (mat->un_dual) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in LargeBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in LargeBlockAligner read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_LargeBlockAligner(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [LargeBlockAligner_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_LargeBlockAligner(LargeBlockAligner * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LargeBlockAligner_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = LargeBlockAligner_READ_OFF_ERROR; if( j < 0 || j > mat->t->seq->len) { warn("In LargeBlockAligner matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source UNMATCHED is from main matrix */ for(i= mat->q->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,UNMATCHED) ) { *reti = i - 0; *retj = j - 0; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,UNMATCHED); } return (*h.access_main)(mat,i - 0,j - 0,UNMATCHED) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->q->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in LargeBlockAligner read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_LargeBlockAligner(mat) * * Descrip: This function calculates the LargeBlockAligner matrix when in explicit mode * To allocate the matrix use /allocate_Expl_LargeBlockAligner * * * Arg: mat [UNKN ] LargeBlockAligner which contains explicit basematrix memory [LargeBlockAligner *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_LargeBlockAligner(LargeBlockAligner * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_LargeBlockAligner, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("LargeBlockAligner Matrix calculation: "); for(j=0;j score ) { score = temp; } /* From state DELETE to state MATCH */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state UNMATCHED to state MATCH */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->block_open; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = LargeBlockAligner_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->block_open; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += (DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext); LargeBlockAligner_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > LargeBlockAligner_EXPL_SPECIAL(mat,i,j,END) ) { LargeBlockAligner_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = LargeBlockAligner_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->gap_open; /* From state INSERT to state INSERT */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gap_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ LargeBlockAligner_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->gap_open; /* From state DELETE to state DELETE */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->gap_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ LargeBlockAligner_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state UNMATCHED */ /* setting first movement to score */ score = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->un_dual; /* From state START to state UNMATCHED */ temp = LargeBlockAligner_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->un_dual; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->un_dual; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED) + mat->un_single; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-0,UNMATCHED) + mat->un_single; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ LargeBlockAligner_EXPL_MATRIX(mat,i,j,UNMATCHED) = score; /* state UNMATCHED is a source for special END */ temp = score + (0) + (0) ; if( temp > LargeBlockAligner_EXPL_SPECIAL(mat,i,j,END) ) { LargeBlockAligner_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state UNMATCHED */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_LargeBlockAligner(mat,dpenv) * * Descrip: This function calculates the LargeBlockAligner matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] LargeBlockAligner which contains explicit basematrix memory [LargeBlockAligner *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_LargeBlockAligner(LargeBlockAligner * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_LargeBlockAligner, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { LargeBlockAligner_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; LargeBlockAligner_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; LargeBlockAligner_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; LargeBlockAligner_EXPL_MATRIX(mat,i,j,UNMATCHED) = NEGI; } } for(j=-1;jlenj;j++) { LargeBlockAligner_EXPL_SPECIAL(mat,i,j,START) = 0; LargeBlockAligner_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("LargeBlockAligner Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { LargeBlockAligner_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; LargeBlockAligner_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; LargeBlockAligner_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; LargeBlockAligner_EXPL_MATRIX(mat,i,j,UNMATCHED) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state UNMATCHED to state MATCH */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->block_open; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = LargeBlockAligner_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->block_open; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += (DnaMatrix_MATCH(mat->dm,CSEQ_DNA_BASE(mat->q,i),CSEQ_DNA_BASE(mat->t,j))+mat->real_ext); LargeBlockAligner_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > LargeBlockAligner_EXPL_SPECIAL(mat,i,j,END) ) { LargeBlockAligner_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = LargeBlockAligner_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->gap_open; /* From state INSERT to state INSERT */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gap_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ LargeBlockAligner_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->gap_open; /* From state DELETE to state DELETE */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->gap_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ LargeBlockAligner_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state UNMATCHED */ /* setting first movement to score */ score = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->un_dual; /* From state START to state UNMATCHED */ temp = LargeBlockAligner_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->un_dual; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->un_dual; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED) + mat->un_single; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = LargeBlockAligner_EXPL_MATRIX(mat,i-1,j-0,UNMATCHED) + mat->un_single; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ LargeBlockAligner_EXPL_MATRIX(mat,i,j,UNMATCHED) = score; /* state UNMATCHED is a source for special END */ temp = score + (0) + (0) ; if( temp > LargeBlockAligner_EXPL_SPECIAL(mat,i,j,END) ) { LargeBlockAligner_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state UNMATCHED */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: LargeBlockAligner_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LargeBlockAligner *] * */ LargeBlockAligner * LargeBlockAligner_alloc(void) { LargeBlockAligner * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LargeBlockAligner *) ckalloc (sizeof(LargeBlockAligner))) == NULL) { warn("LargeBlockAligner_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_LargeBlockAligner(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LargeBlockAligner *] * * Return [UNKN ] Undocumented return value [LargeBlockAligner *] * */ LargeBlockAligner * free_LargeBlockAligner(LargeBlockAligner * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LargeBlockAligner obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->q is linked in */ /* obj->t is linked in */ /* obj->dm is linked in */ /* obj->real_ext is linked in */ /* obj->block_open is linked in */ /* obj->un_dual is linked in */ /* obj->un_single is linked in */ /* obj->gap_open is linked in */ /* obj->gap_ext is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/largeblockdp.h0000644000175000001440000005441610670453714016746 0ustar philippusers#ifndef DYNAMITElargeblockdpHEADERFILE #define DYNAMITElargeblockdpHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" struct Wise2_LargeBlockAligner { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; ComplexSequence* q; ComplexSequence* t; DnaMatrix* dm; Score real_ext; Score block_open; Score un_dual; Score un_single; Score gap_open; Score gap_ext; } ; /* LargeBlockAligner defined */ #ifndef DYNAMITE_DEFINED_LargeBlockAligner typedef struct Wise2_LargeBlockAligner Wise2_LargeBlockAligner; #define LargeBlockAligner Wise2_LargeBlockAligner #define DYNAMITE_DEFINED_LargeBlockAligner #endif struct Wise2_LargeBlockAligner_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(LargeBlockAligner*,int,int,int); int (*access_special)(LargeBlockAligner*,int,int,int); } ; /* LargeBlockAligner_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_LargeBlockAligner_access_func_holder typedef struct Wise2_LargeBlockAligner_access_func_holder Wise2_LargeBlockAligner_access_func_holder; #define LargeBlockAligner_access_func_holder Wise2_LargeBlockAligner_access_func_holder #define DYNAMITE_DEFINED_LargeBlockAligner_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_LargeBlockAligner(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_LargeBlockAligner(LargeBlockAligner * mat); #define PackAln_read_Shatter_LargeBlockAligner Wise2_PackAln_read_Shatter_LargeBlockAligner /* Function: calculate_shatter_LargeBlockAligner(mat,dpenv) * * Descrip: This function calculates the LargeBlockAligner matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [LargeBlockAligner *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_LargeBlockAligner(LargeBlockAligner * mat,DPEnvelope * dpenv); #define calculate_shatter_LargeBlockAligner Wise2_calculate_shatter_LargeBlockAligner /* Function: search_LargeBlockAligner(dbsi,out,q,t,dm,real_ext,block_open,un_dual,un_single,gap_open,gap_ext) * * Descrip: This function makes a database search of LargeBlockAligner * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [ComplexSequence*] * Arg: t [UNKN ] Undocumented argument [ComplexSequence*] * Arg: dm [UNKN ] Undocumented argument [DnaMatrix*] * Arg: real_ext [UNKN ] Undocumented argument [Score] * Arg: block_open [UNKN ] Undocumented argument [Score] * Arg: un_dual [UNKN ] Undocumented argument [Score] * Arg: un_single [UNKN ] Undocumented argument [Score] * Arg: gap_open [UNKN ] Undocumented argument [Score] * Arg: gap_ext [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_LargeBlockAligner(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext); #define search_LargeBlockAligner Wise2_search_LargeBlockAligner /* Function: serial_search_LargeBlockAligner(out,q,t,dm,real_ext,block_open,un_dual,un_single,gap_open,gap_ext) * * Descrip: This function makes a database search of LargeBlockAligner * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [ComplexSequence*] * Arg: t [UNKN ] Undocumented argument [ComplexSequence*] * Arg: dm [UNKN ] Undocumented argument [DnaMatrix*] * Arg: real_ext [UNKN ] Undocumented argument [Score] * Arg: block_open [UNKN ] Undocumented argument [Score] * Arg: un_dual [UNKN ] Undocumented argument [Score] * Arg: un_single [UNKN ] Undocumented argument [Score] * Arg: gap_open [UNKN ] Undocumented argument [Score] * Arg: gap_ext [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_LargeBlockAligner(Hscore * out,ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext); #define serial_search_LargeBlockAligner Wise2_serial_search_LargeBlockAligner /* Function: PackAln_bestmemory_LargeBlockAligner(q,t,dm,real_ext,block_open,un_dual,un_single,gap_open,gap_ext,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_LargeBlockAligner * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: dm [UNKN ] Resource [DnaMatrix*] * Arg: real_ext [UNKN ] Resource [Score] * Arg: block_open [UNKN ] Resource [Score] * Arg: un_dual [UNKN ] Resource [Score] * Arg: un_single [UNKN ] Resource [Score] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_LargeBlockAligner(ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_LargeBlockAligner Wise2_PackAln_bestmemory_LargeBlockAligner /* Function: allocate_Expl_LargeBlockAligner(q,t,dm,real_ext,block_open,un_dual,un_single,gap_open,gap_ext,dpri) * * Descrip: This function allocates the LargeBlockAligner structure * and the basematrix area for explicit memory implementations * It calls /allocate_LargeBlockAligner_only * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: dm [UNKN ] Resource [DnaMatrix*] * Arg: real_ext [UNKN ] Resource [Score] * Arg: block_open [UNKN ] Resource [Score] * Arg: un_dual [UNKN ] Resource [Score] * Arg: un_single [UNKN ] Resource [Score] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [LargeBlockAligner *] * */ LargeBlockAligner * Wise2_allocate_Expl_LargeBlockAligner(ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext,DPRunImpl * dpri); #define allocate_Expl_LargeBlockAligner Wise2_allocate_Expl_LargeBlockAligner /* Function: recalculate_PackAln_LargeBlockAligner(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by LargeBlockAligner * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * */ void Wise2_recalculate_PackAln_LargeBlockAligner(PackAln * pal,LargeBlockAligner * mat); #define recalculate_PackAln_LargeBlockAligner Wise2_recalculate_PackAln_LargeBlockAligner /* Function: allocate_Small_LargeBlockAligner(q,t,dm,real_ext,block_open,un_dual,un_single,gap_open,gap_ext) * * Descrip: This function allocates the LargeBlockAligner structure * and the basematrix area for a small memory implementations * It calls /allocate_LargeBlockAligner_only * * * Arg: q [UNKN ] query data structure [ComplexSequence*] * Arg: t [UNKN ] target data structure [ComplexSequence*] * Arg: dm [UNKN ] Resource [DnaMatrix*] * Arg: real_ext [UNKN ] Resource [Score] * Arg: block_open [UNKN ] Resource [Score] * Arg: un_dual [UNKN ] Resource [Score] * Arg: un_single [UNKN ] Resource [Score] * Arg: gap_open [UNKN ] Resource [Score] * Arg: gap_ext [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [LargeBlockAligner *] * */ LargeBlockAligner * Wise2_allocate_Small_LargeBlockAligner(ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext); #define allocate_Small_LargeBlockAligner Wise2_allocate_Small_LargeBlockAligner /* Function: PackAln_calculate_Small_LargeBlockAligner(mat,dpenv) * * Descrip: This function calculates an alignment for LargeBlockAligner structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_LargeBlockAligner * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_LargeBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_LargeBlockAligner(LargeBlockAligner * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_LargeBlockAligner Wise2_PackAln_calculate_Small_LargeBlockAligner /* Function: AlnRangeSet_calculate_Small_LargeBlockAligner(mat) * * Descrip: This function calculates an alignment for LargeBlockAligner structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_LargeBlockAligner * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_LargeBlockAligner * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_LargeBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_LargeBlockAligner(LargeBlockAligner * mat); #define AlnRangeSet_calculate_Small_LargeBlockAligner Wise2_AlnRangeSet_calculate_Small_LargeBlockAligner /* Function: AlnRangeSet_from_LargeBlockAligner(mat) * * Descrip: This function reads off a start/end structure * for LargeBlockAligner structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_LargeBlockAligner * If you have not calculated the matrix use * /AlnRange_calculate_Small_LargeBlockAligner * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_LargeBlockAligner(LargeBlockAligner * mat); #define AlnRangeSet_from_LargeBlockAligner Wise2_AlnRangeSet_from_LargeBlockAligner /* Function: convert_PackAln_to_AlnBlock_LargeBlockAligner(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_LargeBlockAligner(PackAln * pal); #define convert_PackAln_to_AlnBlock_LargeBlockAligner Wise2_convert_PackAln_to_AlnBlock_LargeBlockAligner /* Function: PackAln_read_Expl_LargeBlockAligner(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_LargeBlockAligner(LargeBlockAligner * mat); #define PackAln_read_Expl_LargeBlockAligner Wise2_PackAln_read_Expl_LargeBlockAligner /* Function: PackAln_read_generic_LargeBlockAligner(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LargeBlockAligner *] * Arg: h [UNKN ] Undocumented argument [LargeBlockAligner_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_LargeBlockAligner(LargeBlockAligner * mat,LargeBlockAligner_access_func_holder h); #define PackAln_read_generic_LargeBlockAligner Wise2_PackAln_read_generic_LargeBlockAligner /* Function: calculate_LargeBlockAligner(mat) * * Descrip: This function calculates the LargeBlockAligner matrix when in explicit mode * To allocate the matrix use /allocate_Expl_LargeBlockAligner * * * Arg: mat [UNKN ] LargeBlockAligner which contains explicit basematrix memory [LargeBlockAligner *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_LargeBlockAligner(LargeBlockAligner * mat); #define calculate_LargeBlockAligner Wise2_calculate_LargeBlockAligner /* Function: calculate_dpenv_LargeBlockAligner(mat,dpenv) * * Descrip: This function calculates the LargeBlockAligner matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] LargeBlockAligner which contains explicit basematrix memory [LargeBlockAligner *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_LargeBlockAligner(LargeBlockAligner * mat,DPEnvelope * dpenv); #define calculate_dpenv_LargeBlockAligner Wise2_calculate_dpenv_LargeBlockAligner /* Function: LargeBlockAligner_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LargeBlockAligner *] * */ LargeBlockAligner * Wise2_LargeBlockAligner_alloc(void); #define LargeBlockAligner_alloc Wise2_LargeBlockAligner_alloc /* Function: free_LargeBlockAligner(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LargeBlockAligner *] * * Return [UNKN ] Undocumented return value [LargeBlockAligner *] * */ LargeBlockAligner * Wise2_free_LargeBlockAligner(LargeBlockAligner * obj); #define free_LargeBlockAligner Wise2_free_LargeBlockAligner /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_LargeBlockAligner_shatter_access_main(LargeBlockAligner * mat,int i,int j,int state); #define LargeBlockAligner_shatter_access_main Wise2_LargeBlockAligner_shatter_access_main int Wise2_LargeBlockAligner_shatter_access_special(LargeBlockAligner * mat,int i,int j,int state); #define LargeBlockAligner_shatter_access_special Wise2_LargeBlockAligner_shatter_access_special int Wise2_score_only_LargeBlockAligner(ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext); #define score_only_LargeBlockAligner Wise2_score_only_LargeBlockAligner LargeBlockAligner * Wise2_allocate_LargeBlockAligner_only(ComplexSequence* q,ComplexSequence* t ,DnaMatrix* dm,Score real_ext,Score block_open,Score un_dual,Score un_single,Score gap_open,Score gap_ext); #define allocate_LargeBlockAligner_only Wise2_allocate_LargeBlockAligner_only void Wise2_init_LargeBlockAligner(LargeBlockAligner * mat); #define init_LargeBlockAligner Wise2_init_LargeBlockAligner AlnRange * Wise2_AlnRange_build_LargeBlockAligner(LargeBlockAligner * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_LargeBlockAligner Wise2_AlnRange_build_LargeBlockAligner boolean Wise2_read_hidden_LargeBlockAligner(LargeBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_LargeBlockAligner Wise2_read_hidden_LargeBlockAligner int Wise2_max_hidden_LargeBlockAligner(LargeBlockAligner * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_LargeBlockAligner Wise2_max_hidden_LargeBlockAligner boolean Wise2_read_special_strip_LargeBlockAligner(LargeBlockAligner * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_LargeBlockAligner Wise2_read_special_strip_LargeBlockAligner int Wise2_max_special_strip_LargeBlockAligner(LargeBlockAligner * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_LargeBlockAligner Wise2_max_special_strip_LargeBlockAligner int Wise2_max_matrix_to_special_LargeBlockAligner(LargeBlockAligner * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_LargeBlockAligner Wise2_max_matrix_to_special_LargeBlockAligner void Wise2_calculate_hidden_LargeBlockAligner(LargeBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_LargeBlockAligner Wise2_calculate_hidden_LargeBlockAligner void Wise2_init_hidden_LargeBlockAligner(LargeBlockAligner * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_LargeBlockAligner Wise2_init_hidden_LargeBlockAligner boolean Wise2_full_dc_LargeBlockAligner(LargeBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_LargeBlockAligner Wise2_full_dc_LargeBlockAligner boolean Wise2_do_dc_single_pass_LargeBlockAligner(LargeBlockAligner * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_LargeBlockAligner Wise2_do_dc_single_pass_LargeBlockAligner void Wise2_push_dc_at_merge_LargeBlockAligner(LargeBlockAligner * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_LargeBlockAligner Wise2_push_dc_at_merge_LargeBlockAligner void Wise2_follow_on_dc_LargeBlockAligner(LargeBlockAligner * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_LargeBlockAligner Wise2_follow_on_dc_LargeBlockAligner void Wise2_run_up_dc_LargeBlockAligner(LargeBlockAligner * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_LargeBlockAligner Wise2_run_up_dc_LargeBlockAligner void Wise2_init_dc_LargeBlockAligner(LargeBlockAligner * mat); #define init_dc_LargeBlockAligner Wise2_init_dc_LargeBlockAligner int Wise2_start_end_find_end_LargeBlockAligner(LargeBlockAligner * mat,int * endj); #define start_end_find_end_LargeBlockAligner Wise2_start_end_find_end_LargeBlockAligner boolean Wise2_dc_optimised_start_end_calc_LargeBlockAligner(LargeBlockAligner *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_LargeBlockAligner Wise2_dc_optimised_start_end_calc_LargeBlockAligner void Wise2_init_start_end_linear_LargeBlockAligner(LargeBlockAligner * mat); #define init_start_end_linear_LargeBlockAligner Wise2_init_start_end_linear_LargeBlockAligner AlnConvertSet * Wise2_AlnConvertSet_LargeBlockAligner(void); #define AlnConvertSet_LargeBlockAligner Wise2_AlnConvertSet_LargeBlockAligner int Wise2_LargeBlockAligner_explicit_access_main(LargeBlockAligner * mat,int i,int j,int state); #define LargeBlockAligner_explicit_access_main Wise2_LargeBlockAligner_explicit_access_main int Wise2_LargeBlockAligner_explicit_access_special(LargeBlockAligner * mat,int i,int j,int state); #define LargeBlockAligner_explicit_access_special Wise2_LargeBlockAligner_explicit_access_special int Wise2_find_end_LargeBlockAligner(LargeBlockAligner * mat,int * ri,int * rj,int * state,boolean * isspecial,LargeBlockAligner_access_func_holder h); #define find_end_LargeBlockAligner Wise2_find_end_LargeBlockAligner void Wise2_LargeBlockAligner_debug_show_matrix(LargeBlockAligner * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define LargeBlockAligner_debug_show_matrix Wise2_LargeBlockAligner_debug_show_matrix int Wise2_max_calc_LargeBlockAligner(LargeBlockAligner * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LargeBlockAligner_access_func_holder h); #define max_calc_LargeBlockAligner Wise2_max_calc_LargeBlockAligner int Wise2_max_calc_special_LargeBlockAligner(LargeBlockAligner * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LargeBlockAligner_access_func_holder h); #define max_calc_special_LargeBlockAligner Wise2_max_calc_special_LargeBlockAligner #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/threestatedb.pod0000644000175000001440000001441010670453715017315 0ustar philippusers=head1 NAME threestatedb module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item ThreeStateDB =back =head1 DESCRIPTION =head2 Object ThreeStateDB =over =item dbtype Type [int] Scalar No documentation =item filename Type [char *] Scalar No documentation =item type Type [int] Scalar No documentation =item current_file Type [FILE *] Scalar No documentation =item rm Type [RandomModel *] Scalar NB, this is hard-linked... =item byte_position Type [long] Scalar this is the file position for the current model =item single Type [ThreeStateModel *] Scalar for single db cases =item phdb Type [PfamHmmer1DB *] Scalar for Pfam Hmmer1 style databases. =item sdb Type [SequenceDB *] Scalar for protein databases =item comp Type [CompMat *] Scalar for protein databases =item gap Type [int] Scalar for protein databases =item ext Type [int] Scalar for protein databases =item seq_cache Type [Sequence * ] Scalar needed for a bit of inter-function communication =item reload_generic Type [ThreeStateModel * (*reload_generic)(ThreeStateDB * tdb,int * return_status)] Scalar for generic parsing applications... =item open_generic Type [boolean (*open_generic)(ThreeStateDB * tdb)] Scalar No documentation =item close_generic Type [boolean (*close_generic)(ThreeStateDB * tdb)] Scalar No documentation =item dataentry_add Type [boolean (*dataentry_add)(ThreeStateDB * tdb,DataEntry * en)] Scalar No documentation =item open_index_generic Type [boolean (*open_index_generic)(ThreeStateDB *tdb)] Scalar No documentation =item index_generic Type [ThreeStateModel * (*index_generic)(ThreeStateDB *tdb,DataEntry *de)] Scalar No documentation =item close_index_generic Type [boolean (*close_index_generic)(ThreeStateDB *tdb)] Scalar No documentation =item data Type [void *] Scalar whatever else the damn system wants to carry around with it! =item hmm_model_start Type [int ] Scalar No documentation =item hmm_model_end Type [int ] Scalar No documentation =item current_no Type [int ] Scalar No documentation =back ThreeStateDB is the object that represents a database of profile-HMMs. The object hold a variety of fields on some of which are occupied depending on the type. Realistically we need a more abstract class idea, which is implemented here anyway via the generic stuff, in hacky C-style pointers to function plus a void pointer. This object therefore houses a switch system around the different types including the generic system... but as the generic function stuff was bolted on later, some things are handled with explicit datastructures. It is quite messy ;). Apologies. To be cleaned up. The generic stuff was principly added in to allow a decoupling of this module from the HMMer2.o interface code which is held in wise2xhmmer.dy The old static datastructure code can be made via protein sequences which are then converted or a Pfam 2.0 style directory + HMMs file. =head2 Member functions of ThreeStateDB =over =item indexed_model &Wise2::ThreeStateDB::indexed_model(mdb,en) Retrieves a model from a database which has been opened for indexing by /open_for_indexing_ThreeStateDB The index information comes from the dataentry which should have been from a search of the ThreeStateDB. Argument mdb [UNKN ] database where this is indexed [ThreeStateDB *] Argument en [UNKN ] dataentry to pull the model from [DataEntry *] Return [UNKN ] Undocumented return value [ThreeStateModel *] =item new_proteindb_ThreeStateDB &Wise2::ThreeStateDB::new_proteindb_ThreeStateDB(sdb,comp,gap,ext) makes a new ThreeStateDB from a sequencedb (better be protein!) Argument sdb [READ ] sequence database to use [SequenceDB *] Argument comp [READ ] comparison matrix to use [CompMat *] Argument gap [READ ] gap open penalty [int] Argument ext [READ ] gap extensions penalty [int] Return [UNKN ] Undocumented return value [ThreeStateDB *] =item new_PfamHmmer1DB_ThreeStateDB &Wise2::ThreeStateDB::new_PfamHmmer1DB_ThreeStateDB(dirname) Makes a new PfamHmmer1DB from a filename indicating the directory Argument dirname [UNKN ] Undocumented argument [char *] Return [UNKN ] Undocumented return value [ThreeStateDB *] =item new_single_ThreeStateDB &Wise2::ThreeStateDB::new_single_ThreeStateDB(tsm,rm) Making a new ThreeStateDB from a single model Argument tsm [READ ] a single ThreeStateModel [ThreeStateModel *] Argument rm [READ ] random model to be used in comparisons.. [RandomModel *] Return [UNKN ] Undocumented return value [ThreeStateDB *] =item hard_link_ThreeStateDB &Wise2::ThreeStateDB::hard_link_ThreeStateDB(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [ThreeStateDB *] Return [UNKN ] Undocumented return value [ThreeStateDB *] =item alloc &Wise2::ThreeStateDB::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [ThreeStateDB *] =item set_dbtype &Wise2::ThreeStateDB::set_dbtype(obj,dbtype) Replace member variable dbtype For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateDB *] Argument dbtype [OWNER] New value of the variable [int] Return [SOFT ] member variable dbtype [boolean] =item dbtype &Wise2::ThreeStateDB::dbtype(obj) Access member variable dbtype For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateDB *] Return [SOFT ] member variable dbtype [int] =item set_filename &Wise2::ThreeStateDB::set_filename(obj,filename) Replace member variable filename For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateDB *] Argument filename [OWNER] New value of the variable [char *] Return [SOFT ] member variable filename [boolean] =item filename &Wise2::ThreeStateDB::filename(obj) Access member variable filename For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateDB *] Return [SOFT ] member variable filename [char *] =back wise-2.4.1/src/models/threestatedb.tex0000644000175000001440000001330410670453715017334 0ustar philippusers\section{threestatedb} \label{module_threestatedb} This module contains the following objects \begin{itemize} \item \ref{object_ThreeStateDB} ThreeStateDB \end{itemize} \subsection{Object ThreeStateDB} \label{object_ThreeStateDB} The ThreeStateDB object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{dbtype} Type [int : Scalar] No documentation \item{filename} Type [char * : Scalar] No documentation \item{type} Type [int : Scalar] No documentation \item{current_file} Type [FILE * : Scalar] No documentation \item{rm} Type [RandomModel * : Scalar] NB, this is hard-linked... \item{byte_position} Type [long : Scalar] this is the file position for the current model \item{single} Type [ThreeStateModel * : Scalar] for single db cases \item{phdb} Type [PfamHmmer1DB * : Scalar] for Pfam Hmmer1 style databases. \item{sdb} Type [SequenceDB * : Scalar] for protein databases \item{comp} Type [CompMat * : Scalar] for protein databases \item{gap} Type [int : Scalar] for protein databases \item{ext} Type [int : Scalar] for protein databases \item{seq_cache} Type [Sequence * : Scalar] needed for a bit of inter-function communication \item{reload_generic} Type [ThreeStateModel * (*reload_generic)(ThreeStateDB * tdb,int * return_status) : Scalar] for generic parsing applications... \item{open_generic} Type [boolean (*open_generic)(ThreeStateDB * tdb) : Scalar] No documentation \item{close_generic} Type [boolean (*close_generic)(ThreeStateDB * tdb) : Scalar] No documentation \item{dataentry_add} Type [boolean (*dataentry_add)(ThreeStateDB * tdb,DataEntry * en) : Scalar] No documentation \item{open_index_generic} Type [boolean (*open_index_generic)(ThreeStateDB *tdb) : Scalar] No documentation \item{index_generic} Type [ThreeStateModel * (*index_generic)(ThreeStateDB *tdb,DataEntry *de) : Scalar] No documentation \item{close_index_generic} Type [boolean (*close_index_generic)(ThreeStateDB *tdb) : Scalar] No documentation \item{data} Type [void * : Scalar] whatever else the damn system wants to carry around with it! \item{hmm_model_start} Type [int : Scalar] No documentation \item{hmm_model_end} Type [int : Scalar] No documentation \item{current_no} Type [int : Scalar] No documentation \end{description} ThreeStateDB is the object that represents a database of profile-HMMs. The object hold a variety of fields on some of which are occupied depending on the type. Realistically we need a more abstract class idea, which is implemented here anyway via the generic stuff, in hacky C-style pointers to function plus a void pointer. This object therefore houses a switch system around the different types including the generic system... but as the generic function stuff was bolted on later, some things are handled with explicit datastructures. It is quite messy ;). Apologies. To be cleaned up. The generic stuff was principly added in to allow a decoupling of this module from the HMMer2.o interface code which is held in wise2xhmmer.dy The old static datastructure code can be made via protein sequences which are then converted or a Pfam 2.0 style directory + HMMs file. Member functions of ThreeStateDB \subsubsection{indexed_ThreeStateModel_ThreeStateDB} \begin{description} \item[External C] {\tt Wise2_indexed_ThreeStateModel_ThreeStateDB (mdb,en)} \item[Perl] {\tt &Wise2::ThreeStateDB::indexed_model (mdb,en)} \item[Perl-OOP call] {\tt $obj->indexed_model(en)} \end{description} Arguments \begin{description} \item[mdb] [UNKN ] database where this is indexed [ThreeStateDB *] \item[en] [UNKN ] dataentry to pull the model from [DataEntry *] \item[returns] [UNKN ] Undocumented return value [ThreeStateModel *] \end{description} Retrieves a model from a database which has been opened for indexing by /open_for_indexing_ThreeStateDB The index information comes from the dataentry which should have been from a search of the ThreeStateDB. \subsubsection{new_proteindb_ThreeStateDB} \begin{description} \item[External C] {\tt Wise2_new_proteindb_ThreeStateDB (sdb,comp,gap,ext)} \item[Perl] {\tt &Wise2::ThreeStateDB::new_proteindb_ThreeStateDB (sdb,comp,gap,ext)} \item[Perl-OOP call] {\tt $obj->new_proteindb_ThreeStateDB(comp,gap,ext)} \end{description} Arguments \begin{description} \item[sdb] [READ ] sequence database to use [SequenceDB *] \item[comp] [READ ] comparison matrix to use [CompMat *] \item[gap] [READ ] gap open penalty [int] \item[ext] [READ ] gap extensions penalty [int] \item[returns] [UNKN ] Undocumented return value [ThreeStateDB *] \end{description} makes a new ThreeStateDB from a sequencedb (better be protein!) \subsubsection{new_PfamHmmer1DB_ThreeStateDB} \begin{description} \item[External C] {\tt Wise2_new_PfamHmmer1DB_ThreeStateDB (dirname)} \item[Perl] {\tt &Wise2::ThreeStateDB::new_PfamHmmer1DB_ThreeStateDB (dirname)} \item[Perl-OOP call] {\tt $obj->new_PfamHmmer1DB_ThreeStateDB()} \end{description} Arguments \begin{description} \item[dirname] [UNKN ] Undocumented argument [char *] \item[returns] [UNKN ] Undocumented return value [ThreeStateDB *] \end{description} Makes a new PfamHmmer1DB from a filename indicating the directory \subsubsection{new_single_ThreeStateDB} \begin{description} \item[External C] {\tt Wise2_new_single_ThreeStateDB (tsm,rm)} \item[Perl] {\tt &Wise2::ThreeStateDB::new_single_ThreeStateDB (tsm,rm)} \item[Perl-OOP call] {\tt $obj->new_single_ThreeStateDB(rm)} \end{description} Arguments \begin{description} \item[tsm] [READ ] a single ThreeStateModel [ThreeStateModel *] \item[rm] [READ ] random model to be used in comparisons.. [RandomModel *] \item[returns] [UNKN ] Undocumented return value [ThreeStateDB *] \end{description} Making a new ThreeStateDB from a single model wise-2.4.1/src/models/transregiondp.dy0000644000175000001440000000644110011413470017334 0ustar philippusers %{ #include "transfactor.h" #include "dyna.h" #define TRANS_REGION_MODEL_SCORE(seq,j,model) (seq->coverage[j] == 0 ? model->region_notpresent : model->region_present) #define TRANS_NON_REGION_MODEL_SCORE(seq,j,model) (seq->coverage[j] == 0 ? model->nonregion_notpresent : model->nonregion_present) #define TRANS_REGION_GC_SCORE(seq,j,model) (seq->gc_points[j] == 1 ? model->gc_point : model->gc_non_point) %} struct SequenceBaseCoverage char * coverage char * gc_points int len Sequence * seq struct TransRegionModel int len Score region_present Score region_notpresent Score nonregion_present Score nonregion_notpresent Score region_start Score gc_point Score gc_non_point matrix TransRegionMatrix query name="model" type="TransRegionModel*" target name="seq" type="SequenceBaseCoverage*" state REGION source REGION offi="0" offj="1" calc="TRANS_REGION_MODEL_SCORE(seq,j,model) + TRANS_REGION_GC_SCORE(seq,j,model)" endsource source START offi="0" offj="1" calc="TRANS_REGION_MODEL_SCORE(seq,j,model) + TRANS_REGION_GC_SCORE(seq,j,model)" endsource source NON_REGION offi="0" offj="1" calc="model->region_start" endsource query_label REGION_STATE target_label REGION endstate state NON_REGION source NON_REGION offi="0" offj="1" calc="TRANS_NON_REGION_MODEL_SCORE(seq,j,model)" endsource source START offi="0" offj="1" calc="TRANS_NON_REGION_MODEL_SCORE(seq,j,model)" endsource source REGION offi="0" offj="1" calc="0" endsource query_label NON_REGION_STATE target_label RANDOM endstate state START !special !start endstate state END !special !end source NON_REGION calc="0" endsource source REGION calc="0" endsource query_label END target_label END endstate collapse NON_REGION_STATE RANDOM collapse REGION_STATE REGION endmatrix %{ #include "transregiondp.h" SequenceBaseCoverage * new_SequenceBaseCoverage(TransFactorMatchSet * tfms) { int i; int j; int seqpos; SequenceBaseCoverage * out; out = SequenceBaseCoverage_alloc(); out->coverage = calloc(tfms->target->len,sizeof(char)); out->len = tfms->target->len; out->gc_points = calloc(tfms->target->len,sizeof(char)); for(j=1;jlen;j++) { if( toupper(tfms->target->seq[j-1]) == 'G' && toupper(tfms->target->seq[j]) == 'C') { out->gc_points[j] = 1; } } for(i=0;ilen;i++) { for(j=tfms->match[i]->start;jmatch[i]->end;j++) { if(out->coverage[j] < 100 ) { out->coverage[j]++; } } } return out; } TransRegionModel * new_logodds_TransRegionModel(double in_region_prob,double out_region_prob,double in_cost,double gc_region_ratio) { TransRegionModel * out; out = TransRegionModel_alloc(); out->region_present = Probability2Score(in_region_prob/out_region_prob); out->region_notpresent = Probability2Score((1.0-in_region_prob)/(1.0 - out_region_prob)); out->nonregion_present = Probability2Score(1.0); out->nonregion_notpresent = Probability2Score(1.0); out->region_start = Probability2Score(in_cost); out->gc_point = Probability2Score(gc_region_ratio); out->gc_non_point = 0; out->len = 1; fprintf(stderr,"... %d (%.2f) covered, %d (%.2f) not covered\n",out->region_present,Score2Bits(out->region_present),out->region_notpresent,Score2Bits(out->region_notpresent)); return out; } %} wise-2.4.1/src/models/estwrap.pod0000644000175000001440000001071710670453713016330 0ustar philippusers=head1 NAME estwrap module - part of the Wise2 package =head1 SYNOPSIS This module contains helper functions for the Wise2 package =head1 DESCRIPTION =over =item Hscore_from_TSM_estwise &Wise2::Hscore_from_TSM_estwise(tdb,cdb,cp,cm,rmd,use_syn,alg,bits_cutoff,allN,flat_insert,report_level,die_on_error,dbsi) Runs a database search for the estwise set of algorithms Argument tdb [READ ] a three state model database [ThreeStateDB *] Argument cdb [READ ] a dna sequence database [cDNADB *] Argument cp [READ ] the codon parser for this comparison [cDNAParser *] Argument cm [READ ] the codon mapper for this comparison [CodonMapper *] Argument rmd [READ ] random model used for the dna sequence comparison [RandomModelDNA *] Argument use_syn [UNKN ] whether a synchronous coding model should be used or not [boolean] Argument alg [UNKN ] algorithm to use [int] Argument bits_cutoff [UNKN ] Undocumented argument [double] Argument allN [UNKN ] Undocumented argument [Probability] Argument flat_insert [UNKN ] Undocumented argument [boolean] Argument report_level [UNKN ] Undocumented argument [int] Argument die_on_error [UNKN ] if true, dies if there is an error [boolean] Argument dbsi [UNKN ] Undocumented argument [DBSearchImpl *] Return [OWNER] a newly allocated Hscore structure of the search [Hscore *] =item AlnBlock_from_Protein_estwise_wrap &Wise2::AlnBlock_from_Protein_estwise_wrap(pro,cdna,cp,cm,ct,comp,gap,ext,is_global,rmd,alg,rm,use_syn,allN,dpri,palpoi) This function is the guts for the est single alignment mode. It uses /AlnBlock_from_TSM_estwise_wrap for the heavy part of the call Argument pro [READ ] protein to be used in the comparison [Protein *] Argument cdna [READ ] cdna to be compared to [cDNA *] Argument cp [READ ] cdna parser indicating insertion deletion probabilities [cDNAParser *] Argument cm [READ ] codon mapper indicating substitution errors etc [CodonMapper *] Argument ct [READ ] codon table for the codon->amino acid mappings [CodonTable *] Argument comp [READ ] comparison matrix to use [CompMat *] Argument gap [UNKN ] gap penalty [int] Argument ext [UNKN ] extension penalty [int] Argument is_global [UNKN ] if true, global start-end in protein is used [boolean] Argument rmd [UNKN ] random model of dna to use [RandomModelDNA *] Argument alg [UNKN ] est algorithm type to use [int] Argument rm [UNKN ] random protein model for use with compmat [RandomModel *] Argument use_syn [UNKN ] if true, uses a synchronous coding model [boolean] Argument allN [UNKN ] Undocumented argument [Probability] Argument dpri [UNKN ] Undocumented argument [DPRunImpl *] Argument palpoi [WRITE] the raw packed alignment output if wanted [PackAln **] Return [UNKN ] Undocumented return value [AlnBlock *] =item AlnBlock_from_TSM_estwise_wrap &Wise2::AlnBlock_from_TSM_estwise_wrap(tsm,cdna,cp,cm,ct,rmd,alg,use_syn,force_flat_insert,allN,dpri,palpoi) This function is the basic wrap for Protein models vs cDNA sequences. Argument tsm [READ ] threestatemodel to be compared to the dna [ThreeStateModel *] Argument cdna [READ ] cdna to be compared to [cDNA *] Argument cp [READ ] cdna parser indicating insertion deletion probabilities [cDNAParser *] Argument cm [READ ] codon mapper indicating substitution errors etc [CodonMapper *] Argument ct [READ ] codon table for the codon->amino acid mappings [CodonTable *] Argument rmd [UNKN ] random model of dna to use [RandomModelDNA *] Argument alg [UNKN ] est algorithm type to use [int] Argument use_syn [UNKN ] if true, uses a synchronous coding model [boolean] Argument force_flat_insert [UNKN ] Undocumented argument [boolean] Argument allN [UNKN ] Undocumented argument [Probability] Argument dpri [UNKN ] Undocumented argument [DPRunImpl *] Argument palpoi [WRITE] the raw packed alignment output if wanted [PackAln **] Return [UNKN ] Undocumented return value [AlnBlock *] =item alg_estwrap_from_string &Wise2::alg_estwrap_from_string(str) This function returns the algorithm type for an est search from the string Argument str [UNKN ] Undocumented argument [char *] Return [UNKN ] Undocumented return value [int] =back wise-2.4.1/src/models/estwrap.tex0000644000175000001440000001157710670453713016353 0ustar philippusers\section{estwrap} \label{module_estwrap} This module only contains factory methods \subsection{estwrap factory methods} \subsubsection{Hscore_from_TSM_estwise} \begin{description} \item[External C] {\tt Wise2_Hscore_from_TSM_estwise (tdb,cdb,cp,cm,rmd,use_syn,alg,bits_cutoff,allN,flat_insert,report_level,die_on_error,dbsi)} \item[Perl] {\tt &Wise2::Hscore_from_TSM_estwise (tdb,cdb,cp,cm,rmd,use_syn,alg,bits_cutoff,allN,flat_insert,report_level,die_on_error,dbsi)} \end{description} Arguments \begin{description} \item[tdb] [READ ] a three state model database [ThreeStateDB *] \item[cdb] [READ ] a dna sequence database [cDNADB *] \item[cp] [READ ] the codon parser for this comparison [cDNAParser *] \item[cm] [READ ] the codon mapper for this comparison [CodonMapper *] \item[rmd] [READ ] random model used for the dna sequence comparison [RandomModelDNA *] \item[use_syn] [UNKN ] whether a synchronous coding model should be used or not [boolean] \item[alg] [UNKN ] algorithm to use [int] \item[bits_cutoff] [UNKN ] Undocumented argument [double] \item[allN] [UNKN ] Undocumented argument [Probability] \item[flat_insert] [UNKN ] Undocumented argument [boolean] \item[report_level] [UNKN ] Undocumented argument [int] \item[die_on_error] [UNKN ] if true, dies if there is an error [boolean] \item[dbsi] [UNKN ] Undocumented argument [DBSearchImpl *] \item[returns] [OWNER] a newly allocated Hscore structure of the search [Hscore *] \end{description} Runs a database search for the estwise set of algorithms \subsubsection{AlnBlock_from_Protein_estwise_wrap} \begin{description} \item[External C] {\tt Wise2_AlnBlock_from_Protein_estwise_wrap (pro,cdna,cp,cm,ct,comp,gap,ext,is_global,rmd,alg,rm,use_syn,allN,dpri,palpoi)} \item[Perl] {\tt &Wise2::AlnBlock_from_Protein_estwise_wrap (pro,cdna,cp,cm,ct,comp,gap,ext,is_global,rmd,alg,rm,use_syn,allN,dpri)} \end{description} Arguments \begin{description} \item[pro] [READ ] protein to be used in the comparison [Protein *] \item[cdna] [READ ] cdna to be compared to [cDNA *] \item[cp] [READ ] cdna parser indicating insertion deletion probabilities [cDNAParser *] \item[cm] [READ ] codon mapper indicating substitution errors etc [CodonMapper *] \item[ct] [READ ] codon table for the codon->amino acid mappings [CodonTable *] \item[comp] [READ ] comparison matrix to use [CompMat *] \item[gap] [UNKN ] gap penalty [int] \item[ext] [UNKN ] extension penalty [int] \item[is_global] [UNKN ] if true, global start-end in protein is used [boolean] \item[rmd] [UNKN ] random model of dna to use [RandomModelDNA *] \item[alg] [UNKN ] est algorithm type to use [int] \item[rm] [UNKN ] random protein model for use with compmat [RandomModel *] \item[use_syn] [UNKN ] if true, uses a synchronous coding model [boolean] \item[allN] [UNKN ] Undocumented argument [Probability] \item[dpri] [UNKN ] Undocumented argument [DPRunImpl *] \item[palpoi] \em{only for C api} [WRITE] the raw packed alignment output if wanted [PackAln **] \item[returns] [UNKN ] Undocumented return value [AlnBlock *] \end{description} This function is the guts for the est single alignment mode. It uses /AlnBlock_from_TSM_estwise_wrap for the heavy part of the call \subsubsection{AlnBlock_from_TSM_estwise_wrap} \begin{description} \item[External C] {\tt Wise2_AlnBlock_from_TSM_estwise_wrap (tsm,cdna,cp,cm,ct,rmd,alg,use_syn,force_flat_insert,allN,dpri,palpoi)} \item[Perl] {\tt &Wise2::AlnBlock_from_TSM_estwise_wrap (tsm,cdna,cp,cm,ct,rmd,alg,use_syn,force_flat_insert,allN,dpri)} \end{description} Arguments \begin{description} \item[tsm] [READ ] threestatemodel to be compared to the dna [ThreeStateModel *] \item[cdna] [READ ] cdna to be compared to [cDNA *] \item[cp] [READ ] cdna parser indicating insertion deletion probabilities [cDNAParser *] \item[cm] [READ ] codon mapper indicating substitution errors etc [CodonMapper *] \item[ct] [READ ] codon table for the codon->amino acid mappings [CodonTable *] \item[rmd] [UNKN ] random model of dna to use [RandomModelDNA *] \item[alg] [UNKN ] est algorithm type to use [int] \item[use_syn] [UNKN ] if true, uses a synchronous coding model [boolean] \item[force_flat_insert] [UNKN ] Undocumented argument [boolean] \item[allN] [UNKN ] Undocumented argument [Probability] \item[dpri] [UNKN ] Undocumented argument [DPRunImpl *] \item[palpoi] \em{only for C api} [WRITE] the raw packed alignment output if wanted [PackAln **] \item[returns] [UNKN ] Undocumented return value [AlnBlock *] \end{description} This function is the basic wrap for Protein models vs cDNA sequences. \subsubsection{alg_estwrap_from_string} \begin{description} \item[External C] {\tt Wise2_alg_estwrap_from_string (str)} \item[Perl] {\tt &Wise2::alg_estwrap_from_string (str)} \end{description} Arguments \begin{description} \item[str] [UNKN ] Undocumented argument [char *] \item[returns] [UNKN ] Undocumented return value [int] \end{description} This function returns the algorithm type for an est search from the string wise-2.4.1/src/models/dnaalign_api.h0000644000175000001440000000570410670453713016716 0ustar philippusers /* Functions that create, manipulate or act on DnaStartEnd * * Wise2_hard_link_DnaStartEnd * Wise2_DnaStartEnd_alloc * Wise2_free_DnaStartEnd [destructor] * */ /* Helper functions in the module * * Wise2_make_align_dnaalign * Wise2_DnaStartEnd_from_policy * /* API for object DnaStartEnd */ /* Function: Wise2_hard_link_DnaStartEnd(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_DnaStartEnd *] * * Returns Undocumented return value [Wise2_DnaStartEnd *] * */ Wise2_DnaStartEnd * Wise2_hard_link_DnaStartEnd( Wise2_DnaStartEnd * obj); /* Function: Wise2_DnaStartEnd_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_DnaStartEnd *] * */ Wise2_DnaStartEnd * Wise2_DnaStartEnd_alloc(); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_DnaStartEnd(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_DnaStartEnd *] * * Returns Undocumented return value [Wise2_DnaStartEnd *] * */ Wise2_DnaStartEnd * Wise2_free_DnaStartEnd( Wise2_DnaStartEnd * obj); /* These functions are not associated with an object */ /* Function: Wise2_make_align_dnaalign(one,two,mat,se,qgap,qext,tgap,text,dpri) * * Descrip: Makes an alignment out of two DNA sequences * * * Arg: one first sequence to align [Wise2_Sequence *] * Arg: two second sequence to align [Wise2_Sequence *] * Arg: mat DnaMatrix for the matching [Wise2_DnaMatrix *] * Arg: se DnaStartEnd policy [Wise2_DnaStartEnd *] * Arg: qgap gap open penalty in query (one) coordinate [int] * Arg: qext gap extension penalty in query (one) coordinate [int] * Arg: tgap gap open penalty in target (two) coordinate [int] * Arg: text gap extension penalty in target (two) coordinate [int] * Arg: dpri DPRunImpl structure [Wise2_DPRunImpl *] * * Returns an alb structure of the alignment [Wise2_AlnBlock *] * */ Wise2_AlnBlock * Wise2_make_align_dnaalign( Wise2_Sequence * one,Wise2_Sequence * two,Wise2_DnaMatrix * mat,Wise2_DnaStartEnd * se,int qgap,int qext,int tgap,int text,Wise2_DPRunImpl * dpri); /* Function: Wise2_DnaStartEnd_from_policy(policy) * * Descrip: Makes a DnaStartEnd from a particular string. * Possible strings are: * * local - fully local * global - fully global * edge - aligns only to edges * * * Arg: policy Undocumented argument [char *] * * Returns Undocumented return value [Wise2_DnaStartEnd *] * */ Wise2_DnaStartEnd * Wise2_DnaStartEnd_from_policy( char * policy); wise-2.4.1/src/models/dnaalign_api.t0000644000175000001440000000006510670453713016725 0ustar philippuserstypedef struct Wise2_DnaStartEnd Wise2_DnaStartEnd; wise-2.4.1/src/models/genewisemodel.dy0000644000175000001440000005523410242206155017316 0ustar philippusers/* Last edited: Apr 24 14:53 1997 (birney) */ %{ #include "geneparser21.h" #include "geneparameter.h" #include "threestatemodel.h" #include "codonmapper.h" #include "cdparser.h" #include "genefrequency.h" #include "geneutil.h" #define GeneWiseScoreLISTLENGTH 128 #define GeneWiseLISTLENGTH 128 #define MAX_PROTEIN_GENEWISE 4096 enum GeneWiseTransition { GW_MATCH2MATCH, GW_MATCH2INSERT, GW_MATCH2DELETE, GW_MATCH2END, GW_INSERT2MATCH, GW_INSERT2INSERT, GW_INSERT2DELETE, GW_INSERT2END, GW_DELETE2MATCH, GW_DELETE2INSERT, GW_DELETE2DELETE, GW_DELETE2END, GW_START2MATCH, GW_START2INSERT, GW_START2DELETE, GW_MATCH_BALANCE_5SS, GW_INSERT_BALANCE_5SS, GW_MATCH_BALANCE_3SS, GW_INSERT_BALANCE_3SS, GW_TRANSITION_LEN }; #define GW_EMISSION_LEN 126 %} struct GeneWiseSegment Probability match[GW_EMISSION_LEN] Probability insert[GW_EMISSION_LEN] Probability transition[GW_TRANSITION_LEN] %info This is a particular HMM node, with match and insert emissions in the codon space and the transitions intron/frameshifting transitions are stored in a different datastructure, as they are not position dependent %% struct GeneWise GeneWiseSegment ** seg !list char * name %info This is an expand HMM for codon matching, suitable for genewise and estwise type algorithms. It is simple a list of nodes %% struct GeneWiseScoreSegment Score match[GW_EMISSION_LEN] Score insert[GW_EMISSION_LEN] Score transition[GW_TRANSITION_LEN] %info This is the log space equivalent of GeneWiseSegment %% struct GeneWiseScore GeneWiseScoreSegment ** seg !list char * name %info This is the log space equivalent of the GeneWise %% struct GeneWiseScoreFlat GeneWiseScoreSegment * seg int len %info This is a specialised datastructure which is equivalent to the GeneWiseScore object, but layed out more efficiently for memory lookup. The actual code is usually 10% faster. If you have a really large model however it might barf! %% %{ #include "genewisemodel.h" %func Packing up the GeneWise model into a byte structure %% char * pack_GeneWiseScore(GeneWiseScore * gws) { char * out; return out; } %func This produces a flattened GeneWiseSegment structure for use in quick implementations (memory lookup is much better due to everything being a single piece of memory). %% GeneWiseScoreFlat * GeneWiseScoreFlat_from_GeneWiseScore(GeneWiseScore * gws) { int i; int j; GeneWiseScoreFlat * gwsf; gwsf = GeneWiseScoreFlat_alloc(); gwsf->seg = (GeneWiseScoreSegment *) malloc (sizeof(GeneWiseScoreSegment) * gws->len); for(i=0;ilen;i++) { for(j=0;j<126;j++) { gwsf->seg[i].match[j] = gws->seg[i]->match[j]; gwsf->seg[i].insert[j] = gws->seg[i]->insert[j]; } for(j=0;jseg[i].transition[j] = gws->seg[i]->transition[j]; } gwsf->len = gws->len; return gwsf; } %func Frees the GeneWiseScoreFlat datastructure overrides the usual deconstructor %% !deconstructor GeneWiseScoreFlat * free_GeneWiseScoreFlat(GeneWiseScoreFlat * obj) { if( obj == NULL ) { warn("Attempting to free a NULL GeneWiseScoreFlat object"); return NULL; } if( obj->seg != NULL ) ckfree(obj->seg); ckfree(obj); return NULL; } %func This function does something very sinister. It maps the phase 0 introns which have three base pairs added on the end. It actually changes the AlnBlock structure %% void map_phase0_codons_AlnBlock_GeneWise(AlnBlock * alb,GeneWiseScore * gws,ComplexSequence * cseq) { AlnColumn * alc; AlnColumn * new; for(alc=alb->start;alc != NULL;alc=alc->next) { /* don't map random columns */ if( is_random_AlnColumn_genewise(alc) == TRUE ) continue; if( strcmp(alc->alu[1]->text_label,"3SS_PHASE_0") == 0 ) { new = new_pairwise_AlnColumn(); new->alu[0]->start = alc->alu[0]->start; new->alu[0]->end = alc->alu[0]->end; /* set old alc end to == start */ alc->alu[0]->end = new->alu[0]->start; /* link label in as the same */ new->alu[0]->text_label = alc->alu[0]->text_label; new->alu[1]->end = alc->alu[1]->end; /* new starts at -3 on the codon, which is where old ends */ new->alu[1]->start = alc->alu[1]->end = alc->alu[1]->end -3; new->alu[1]->text_label = "CODON"; new->alu[0]->score[0] = new->alu[1]->score[0] = gws->seg[new->alu[0]->end]->transition[GW_MATCH2MATCH] + gws->seg[new->alu[0]->end]->match[CSEQ_GENOMIC_CODON(cseq,new->alu[1]->end)]; alc->alu[0]->score[0] -= new->alu[0]->score[0]; alc->alu[1]->score[0] -= new->alu[0]->score[0]; /*** add new into the AlnBlock ***/ new->next = alc->next; alc->next = new; } } } %func This function is make all the balance scores 0 (hence prob-ratio to 1). Used when you are using naive models %arg gw genewise model to flatten %% void flatten_balance_scores_GeneWise(GeneWise * gw) { int i; for(i=0;ilen;i++) { gw->seg[i]->transition[GW_MATCH_BALANCE_5SS] = 1; gw->seg[i]->transition[GW_INSERT_BALANCE_5SS] = 1; gw->seg[i]->transition[GW_MATCH_BALANCE_3SS] = 1; gw->seg[i]->transition[GW_INSERT_BALANCE_3SS] = 1; } } %func This function makes a GeneWise model for the estwise type algorithms %% GeneWise * GeneWise_from_ThreeStateModel_cdna(ThreeStateModel * tsm,cDNAParser * cp,CodonMapper * cm,Probability allN) { register int i; GeneWise * out; Probability factor; assert(tsm); assert(cp); assert(cm); if( (out = GeneWise_alloc_len(tsm->len)) == NULL ) return NULL; factor = (1.0 - removed_probability_from_cds_cdna(cp)); for(i=0;ilen;i++) add_GeneWise(out,GeneWiseSegment_from_ThreeStateUnit(tsm->unit[i],factor,cm,NULL,allN)); return out; } %func This function makes a GeneWise model for the estwise type algorithms %% GeneWise * GeneWise_from_ThreeStateModel_setfactor(ThreeStateModel * tsm,Probability factor,CodonMapper * cm,Probability allN) { register int i; GeneWise * out; assert(tsm != NULL); assert(cm != NULL); if( (out = GeneWise_alloc_len(tsm->len)) == NULL ) return NULL; for(i=0;ilen;i++) add_GeneWise(out,GeneWiseSegment_from_ThreeStateUnit(tsm->unit[i],factor,cm,NULL,allN)); return out; } %func This makes a genewise model from a threestatemodel for the genewise type algorithms. Notice you have to provide the gene parameters being used Stop is now not used %% GeneWise * GeneWise_from_ThreeStateModel(ThreeStateModel * tsm,GeneParser21 * gp,CodonMapper * cm,Probability allN,GeneWiseCodonModel * gwcm) { register int i; GeneWise * out; Probability factor; assert(tsm); /* assert(gp); */ assert(cm); /* assert(gwcm); */ /* can cope with null gwcm's */ if( (out = GeneWise_alloc_len(tsm->len)) == NULL ) return NULL; if( tsm->name != NULL ) out->name = stringalloc(tsm->name); if( gp == NULL ) { factor = 1.0; } else { factor = (1.0 - removed_probability_from_cds(gp)); } for(i=0;ilen;i++) { add_GeneWise(out,GeneWiseSegment_from_ThreeStateUnit(tsm->unit[i],factor,cm,gwcm,allN)); } return out; } %func This function places 'log-odd' scores of the genewise model assumming that the random model is a protein model with the codon mapper system added in, *and* that the path of the random model is synchronous with the query model. It fudges stop codons with the stop score given as a probability. In other words, this should give bits scores as if it was a protein, even though it is DNA %% void GeneWise_fold_in_synchronised_RandomModel(GeneWise * gw,RandomModel * rm,CodonMapper * cm,CodonTable *ct,Probability stop_codon_background) { int i; int j; double p; if( gw == NULL || rm == NULL || cm == NULL || ct == NULL ) { fatal("Null objects passed to GeneWise_fold_in_synchronised_RandomModel. Ugh!"); } for(i=0;i<125;i++) { p = map_codon_CodonMapper(i,rm->aminoacid,cm); if( is_stop_codon(i,ct) == FALSE && p < 0.0000001 ) { warn("Got a close to zero probability for %d\n",i); p = 0.0000001; } for(j=0;jlen;j++) { if( is_stop_codon(i,ct) == TRUE ){ gw->seg[j]->match[i] /= stop_codon_background; gw->seg[j]->insert[i] /= stop_codon_background; } else { gw->seg[j]->match[i] = gw->seg[j]->match[i] / p; gw->seg[j]->insert[i] = gw->seg[j]->insert[i] / p; } } } return; } %func This function checks that the insert model is bang on zero, forcing it to zero Potentially it warns for non zeros as well %% boolean check_flat_insert(GeneWise * gw,boolean should_force,boolean should_warn,CodonTable * ct) { boolean ret = TRUE; int i,j; for(i=0;ilen;i++) { for(j=0;j<125;j++) { if ( is_stop_codon(j,ct) ) { continue; } if( gw->seg[i]->insert[j] > 1.02 || gw->seg[i]->insert[j] < 0.99 ) { ret = FALSE; if( should_warn ) { warn("In checking that we have a flat zero over the insert states, at %d, codon %d got %.2f",i,j,gw->seg[i]->insert[j]); } if( should_force ) { gw->seg[i]->insert[j] = 1.0; } } } } return ret; } %func This function folds in a simple random model (single base position) into a genewise model %% void GeneWise_fold_in_RandomModelDNA(GeneWise * gw,RandomModelDNA * rmd) { register int i; register int j; Probability p; for(i=0;i<125;i++) { p = probability_of_this_codon(i,rmd); for(j=0;jlen;j++) { gw->seg[j]->match[i] = gw->seg[j]->match[i] / p; gw->seg[j]->insert[i] = gw->seg[j]->insert[i] / p; } } return; } %func Produces a protein object from a genewise/estwise style label set, setting the last retrieved column %% Protein * Protein_from_GeneWise_AlnColumn(Sequence * dna,AlnColumn * col,int position_in_aln,AlnColumn ** last_column,CodonTable * ct,boolean (*is_random_AlnColumn)(const AlnColumn *)) { Sequence * out; char buffer[MAX_PROTEIN_GENEWISE]; /* max protein length? */ char tempseq[4]; int i =0; tempseq[3] = '\0'; for(;col != NULL && (*is_random_AlnColumn)(col) == TRUE;col = col->next) ; if( col == NULL ) return NULL; sprintf(buffer,"%s.pep",dna->name); out = empty_Sequence_from_dynamic_memory(stringalloc(buffer)); for(;col != NULL && (*is_random_AlnColumn)(col) == FALSE;col = col->next) { if( i+1 >= MAX_PROTEIN_GENEWISE ) { buffer[i] = '\0'; add_string_to_Sequence(out,buffer); i = 0; } if( strstr(col->alu[position_in_aln]->text_label,"CODON") != NULL ) { buffer[i++] = aminoacid_from_seq(ct,dna->seq+col->alu[position_in_aln]->start+1); } else if ( strstr(col->alu[position_in_aln]->text_label,"5SS_PHASE_1") != NULL ) { tempseq[0] = dna->seq[col->alu[position_in_aln]->start+1]; for(col=col->next;col != NULL && strstr(col->alu[position_in_aln]->text_label,"3SS") == NULL;col=col->next) ; if( col == NULL ) { warn("In middle of intron - got no 3'SS in making peptide translation"); return NULL; } tempseq[1] = dna->seq[col->alu[position_in_aln]->start+4]; tempseq[2] = dna->seq[col->alu[position_in_aln]->start+5]; /*fprintf(stderr,"In phase 1 intron, calling %c%c%c as split codon and %c%c%c as last codon\n",tempseq[0],tempseq[1],tempseq[2], dna->seq[col->alu[position_in_aln]->start+6], dna->seq[col->alu[position_in_aln]->start+7], dna->seq[col->alu[position_in_aln]->start+8] ); */ buffer[i++] = aminoacid_from_seq(ct,tempseq); /* buffer[i++] = aminoacid_from_seq(ct,dna->seq+col->alu[position_in_aln]->start+6);*/ printf("Making a %c in phase 1 intron\n",buffer[i-1]); } else if ( strstr(col->alu[position_in_aln]->text_label,"5SS_PHASE_2") != NULL ) { tempseq[0] = dna->seq[col->alu[position_in_aln]->start+1]; tempseq[1] = dna->seq[col->alu[position_in_aln]->start+2]; for(col=col->next;col != NULL && strstr(col->alu[position_in_aln]->text_label,"3SS") == NULL;col=col->next) ; if( col == NULL ) { warn("In middle of intron - got no 3'SS in making peptide translation"); return NULL; } tempseq[2] = dna->seq[col->alu[position_in_aln]->start+4]; buffer[i++] = aminoacid_from_seq(ct,tempseq); /*buffer[i++] = aminoacid_from_seq(ct,dna->seq+col->alu[position_in_aln]->start+5);*/ printf("Making a %c in phase 2 intron\n",buffer[i-1]); } else if ( strstr(col->alu[position_in_aln]->text_label,"5SS_PHASE_0") != NULL ) { /* codon already delt with! */ for(col=col->next;col != NULL && strstr(col->alu[position_in_aln]->text_label,"3SS") == NULL;col=col->next) ; if( col == NULL ) { warn("In middle of intron - got no 3'SS in making peptide translation"); return NULL; } /* buffer already sorted out. No need to provide compute */ continue; buffer[i++] = aminoacid_from_seq(ct,dna->seq+col->alu[position_in_aln]->start+3); printf("Making a %c in phase 0 intron\n",buffer[i-1]); col = col->next; } else if ( strstr(col->alu[position_in_aln]->text_label,"SEQUENCE_DELETION") != NULL ) { buffer[i++] = 'X'; } else if ( strstr(col->alu[position_in_aln]->text_label,"SEQUENCE_INSERTION") != NULL ) { buffer[i++] = 'X'; } else if ( strstr(col->alu[position_in_aln]->text_label,"INSERT") != NULL ) { continue; } else { warn("In processing alignment to peptide, got label %s which cannot handle. Assumming X in protein translation",col->alu[position_in_aln]->text_label); buffer[i++] = 'X'; } } if( last_column != NULL ) *last_column = col; buffer[i] = '\0'; add_string_to_Sequence(out,buffer); out->type = SEQUENCE_PROTEIN; /* force to protein */ return Protein_from_Sequence(out); } %func Helper function for getting probability of codon for a random model %type internal %% Probability probability_of_this_codon(int codon,RandomModelDNA * rmd) { base one; base two; base three; all_bases_from_codon(codon,&one,&two,&three); return rmd->base[one] * rmd->base[two] * rmd->base[three]; } %func debugging function %type internal %% void show_GeneWise(GeneWise * gw,FILE * ofp) { register int i; fprintf(stderr,"Got here at least [%d]\n",gw->len); for(i=0;ilen;i++) show_GeneWiseSegment(gw->seg[i],ofp); } %func debugging %type internal %% void show_GeneWiseSegment(GeneWiseSegment * seg,FILE * ofp) { fprintf(ofp,"match=\" "); show_Probability_array(seg->match,125,ofp); fprintf(ofp,"\n"); show_Probability_array(seg->insert,125,ofp); fprintf(ofp,"\n"); } %func Function which actually does the mapping from threestate model unit to genewise %type internal %% GeneWiseSegment * GeneWiseSegment_from_ThreeStateUnit(ThreeStateUnit * tsu,Probability factor,CodonMapper * cm,GeneWiseCodonModel * gwcm,Probability allN) { register int i; GeneWiseSegment * out; double total; int codon; out = GeneWiseSegment_alloc(); if( out == NULL ) return NULL; (void)set_Probability_array(out->match , 0.0, GW_EMISSION_LEN); (void)set_Probability_array(out->insert , 0.0, GW_EMISSION_LEN); (void)set_Probability_array(out->transition, 0.0, GW_TRANSITION_LEN); true_map_codon_array_CodonMapper(out->match,tsu->match_emission,cm); true_map_codon_array_CodonMapper(out->insert,tsu->insert_emission,cm); codon = codon_from_seq("NNN"); out->match[codon] = allN; out->insert[codon] = allN; out->transition[GW_MATCH2MATCH] = tsu->transition[TSM_MATCH2MATCH] * factor; out->transition[GW_MATCH2INSERT] = tsu->transition[TSM_MATCH2INSERT] * factor; out->transition[GW_MATCH2DELETE] = tsu->transition[TSM_MATCH2DELETE] * factor; out->transition[GW_MATCH2END] = tsu->transition[TSM_MATCH2END] * factor; out->transition[GW_INSERT2MATCH] = tsu->transition[TSM_INSERT2MATCH] * factor; out->transition[GW_INSERT2INSERT] = tsu->transition[TSM_INSERT2INSERT] * factor; out->transition[GW_INSERT2DELETE] = tsu->transition[TSM_INSERT2DELETE] * factor; out->transition[GW_INSERT2END] = tsu->transition[TSM_INSERT2END] * factor; out->transition[GW_DELETE2MATCH] = tsu->transition[TSM_DELETE2MATCH]; out->transition[GW_DELETE2INSERT] = tsu->transition[TSM_DELETE2INSERT]; out->transition[GW_DELETE2DELETE] = tsu->transition[TSM_DELETE2DELETE]; out->transition[GW_DELETE2END] = tsu->transition[TSM_DELETE2END]; out->transition[GW_START2MATCH] = tsu->transition[TSM_START2MATCH]; out->transition[GW_START2INSERT] = tsu->transition[TSM_START2INSERT]; out->transition[GW_START2DELETE] = tsu->transition[TSM_START2DELETE]; /** we need 1/(sum_over_codons (match(codon)) * no(codon in 5'SS)/no(codon in cds) ) **/ if( gwcm != NULL ) { total = 0.0; for(i=0;i<64;i++) { codon = codon_from_base4_codon(i); total += out->match[codon] * gwcm->in_donor[i]/gwcm->in_cds[i]; } out->transition[GW_MATCH_BALANCE_5SS] = 1.0 / total; total = 0.0; for(i=0;i<64;i++) { codon = codon_from_base4_codon(i); total += out->insert[codon] * gwcm->in_donor[i]/gwcm->in_cds[i]; } out->transition[GW_INSERT_BALANCE_5SS] = 1.0 / total; total = 0.0; for(i=0;i<64;i++) { codon = codon_from_base4_codon(i); total += out->match[codon] * gwcm->in_acceptor[i]/gwcm->in_cds[i]; } out->transition[GW_MATCH_BALANCE_3SS] = 1.0 / total; total = 0.0; for(i=0;i<64;i++) { codon = codon_from_base4_codon(i); total += out->insert[codon] * gwcm->in_acceptor[i]/gwcm->in_cds[i]; } out->transition[GW_INSERT_BALANCE_3SS] = 1.0 / total; } else { out->transition[GW_MATCH_BALANCE_5SS] = 1.0; out->transition[GW_MATCH_BALANCE_3SS] = 1.0; out->transition[GW_INSERT_BALANCE_5SS] = 1.0; out->transition[GW_INSERT_BALANCE_3SS] = 1.0; } return out; } %func Helper function %type internal %% Probability Probability_of_codon(int codon,CodonTable * ct,Probability * aminoacid_26_array,Probability stop) { register int i,j,k; base base1,base2,base3; Probability ret = 0.0; if( has_random_bases(codon) == FALSE) { if( is_stop_codon(codon,ct) == TRUE ) { return stop; } else { fprintf(stderr,"Setting a number to %f\n",aminoacid_26_array[aminoacid_no_from_codon(ct,codon)]); return aminoacid_26_array[aminoacid_no_from_codon(ct,codon)]; } } all_bases_from_codon(codon,&base1,&base2,&base3); /*** the first base is N ***/ if( base1 == BASE_N && base2 != BASE_N && base3 != BASE_N) { for(i=0;i<4;i++ ) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(i*25 + base2*5 + base3))]; return ret; } if( base1 == BASE_N && base2 == BASE_N && base3 != BASE_N) { for(i=0;i<4;i++) for(j=0;j<4;j++) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(i*25 + j*5 + base3))]; return ret; } if( base1 == BASE_N && base2 != BASE_N && base3 == BASE_N) { for(i=0;i<4;i++) for(k=0;k<4;k++) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(i*25 + base2*5 + k))]; return ret; } if( base1 == BASE_N && base2 == BASE_N && base3 == BASE_N) { for(i=0;i<4;i++) for(j=0;j<4;j++) for(k=0;k<4;k++) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(i*25 + j*5 + k))]; return ret; } /*** the second base is N ***/ if( base1 != BASE_N && base2 == BASE_N && base3 != BASE_N) { for(j=0;j<4;j++) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(base1*25 + j*5 + base3))]; return ret; } if( base1 != BASE_N && base2 == BASE_N && base3 == BASE_N) { for(j=0;j<4;j++) for(k=0;k<4;k++) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(base1*25 + j*5 + k))]; return ret; } /*** the third base is N ***/ if( base1 != BASE_N && base2 != BASE_N && base3 == BASE_N) { for(k=0;k<4;k++) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(base1*25 + base2*5 + k))]; return ret; } /*** should never reach here ***/ warn("Got to the end of Probability_of_codon without a BASE_N combination being triggered. This looks like a major problem. Codon inputted was %d",codon); return 0.0; } %func Makes a Score (log based) object from a probability based object %% GeneWiseScore * GeneWiseScore_from_GeneWise(GeneWise * gw) { GeneWiseScore * out; register int i; out = GeneWiseScore_alloc_len(gw->len); if(gw->name != NULL ) out->name = stringalloc(gw->name); add_GeneWiseScore(out,GeneWiseScoreSegment_from_GeneWiseSegment(NULL,gw->seg[0])); for(i=1;ilen;i++) add_GeneWiseScore(out,GeneWiseScoreSegment_from_GeneWiseSegment(gw->seg[i-1],gw->seg[i])); return out; } %func helper function for prob to score mapping %type internal %% GeneWiseScoreSegment * GeneWiseScoreSegment_from_GeneWiseSegment(GeneWiseSegment * prev,GeneWiseSegment * seg) { GeneWiseScoreSegment * out; out = GeneWiseScoreSegment_alloc(); Probability2Score_move(seg->match,out->match,GW_EMISSION_LEN); Probability2Score_move(seg->insert,out->insert,GW_EMISSION_LEN); if( prev != NULL ) { out->transition[GW_MATCH2MATCH] = Probability2Score(prev->transition[GW_MATCH2MATCH]); out->transition[GW_INSERT2MATCH] = Probability2Score(prev->transition[GW_INSERT2MATCH]); out->transition[GW_DELETE2MATCH] = Probability2Score(prev->transition[GW_DELETE2MATCH]); out->transition[GW_MATCH2DELETE] = Probability2Score(prev->transition[GW_MATCH2DELETE]); out->transition[GW_INSERT2DELETE] = Probability2Score(prev->transition[GW_INSERT2DELETE]); out->transition[GW_DELETE2DELETE] = Probability2Score(prev->transition[GW_DELETE2DELETE]); } else { out->transition[GW_MATCH2MATCH] = NEGI; out->transition[GW_INSERT2MATCH] = NEGI; out->transition[GW_DELETE2MATCH] = NEGI; out->transition[GW_MATCH2DELETE] = NEGI; out->transition[GW_INSERT2DELETE] = NEGI; out->transition[GW_DELETE2DELETE] = NEGI; } out->transition[GW_MATCH2INSERT] = Probability2Score(seg->transition[GW_MATCH2INSERT]); out->transition[GW_INSERT2INSERT] = Probability2Score(seg->transition[GW_INSERT2INSERT]); out->transition[GW_DELETE2INSERT] = Probability2Score(seg->transition[GW_DELETE2INSERT]); out->transition[GW_START2MATCH] = Probability2Score(seg->transition[GW_START2MATCH]); out->transition[GW_START2INSERT] = Probability2Score(seg->transition[GW_START2INSERT]); out->transition[GW_START2DELETE] = Probability2Score(seg->transition[GW_START2DELETE]); out->transition[GW_MATCH2END] = Probability2Score(seg->transition[GW_MATCH2END]); out->transition[GW_INSERT2END] = Probability2Score(seg->transition[GW_INSERT2END]); out->transition[GW_DELETE2END] = Probability2Score(seg->transition[GW_DELETE2END]); out->transition[GW_MATCH_BALANCE_5SS] = Probability2Score(seg->transition[GW_MATCH_BALANCE_5SS]); out->transition[GW_INSERT_BALANCE_5SS] = Probability2Score(seg->transition[GW_INSERT_BALANCE_5SS]); out->transition[GW_MATCH_BALANCE_3SS] = Probability2Score(seg->transition[GW_MATCH_BALANCE_3SS]); out->transition[GW_INSERT_BALANCE_3SS] = Probability2Score(seg->transition[GW_INSERT_BALANCE_3SS]); return out; } %} wise-2.4.1/src/models/matchsum.c0000644000175000001440000007665310670453714016140 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "matchsum.h" /* Function: MatchSummarySet_from_AlnBlock_estwise(alb,qname,offset,target) * * Descrip: Builds a MatchSummarySet from a * EstWise alignment. this makes * alot of assumptions about the labels * setc in alb, so make sure it was a * estwise alignment - however as you * can notice this is exactly the same * labels as found in genewise set * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: qname [UNKN ] Undocumented argument [char *] * Arg: offset [UNKN ] Undocumented argument [int] * Arg: target [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ # line 60 "matchsum.dy" MatchSummarySet * MatchSummarySet_from_AlnBlock_estwise(AlnBlock * alb,char * qname,int offset,Sequence * target) { return MatchSummarySet_from_AlnBlock_genewise(alb,qname,offset,target); } /* Function: MatchSummarySet_from_AlnBlock_genewise(alb,qname,protoff,target) * * Descrip: Builds a MatchSummarySet from a * GeneWise alignment. this makes * alot of assumptions about the labels * setc in alb, so make sure it was a * genewise alignment * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: qname [UNKN ] Undocumented argument [char *] * Arg: protoff [UNKN ] Undocumented argument [int] * Arg: target [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ # line 72 "matchsum.dy" MatchSummarySet * MatchSummarySet_from_AlnBlock_genewise(AlnBlock * alb,char * qname,int protoff,Sequence * target) { MatchSummarySet * out; MatchSummary * ms; AlnColumn * alc; int len; out = MatchSummarySet_alloc_std(); alc = alb->start; while( (ms = MatchSummary_from_AlnColumn_genewise(alc,&alc)) != NULL ) { ms->qstart+= protoff-1; /*** offset in old-style offset mode ***/ ms->qend += protoff-1; if( target->offset > target->end ) { len = ms->tend - ms->tstart; /* fprintf(stderr,"Look - length %d\n",len); */ ms->tstart = target->offset-1 - ms->tstart; ms->tend = ms->tstart - len; } else { ms->tstart += target->offset-1; ms->tend += target->offset-1; } ms->qname = stringalloc(qname); ms->tname = stringalloc(target->name); add_MatchSummarySet(out,ms); } return out; } /* Function: MatchSummary_from_AlnColumn_genewise(alc,end) * * Descrip: For making each alignment * * * Arg: alc [UNKN ] Undocumented argument [AlnColumn *] * Arg: end [UNKN ] Undocumented argument [AlnColumn **] * * Return [UNKN ] Undocumented return value [MatchSummary *] * */ # line 108 "matchsum.dy" MatchSummary * MatchSummary_from_AlnColumn_genewise(AlnColumn * alc,AlnColumn ** end) { MatchSummary * out; int score; for(;alc != NULL && is_random_AlnColumn_genewise(alc) == TRUE;alc = alc->next) ; if( alc == NULL ) { *end = NULL; return NULL; } out = MatchSummary_alloc(); /* NB alignment start is one before the C ordinate start system */ out->qstart = alc->alu[0]->start+1; /* in C coords */ out->tstart = alc->alu[1]->start+1; /* in C coords */ score = alc->alu[0]->score[0]; for(;alc->next != NULL && is_random_AlnColumn_genewise(alc->next) == FALSE;alc = alc->next) { score += alc->next->alu[0]->score[0]; if( strcmp(alc->alu[1]->text_label,"SEQUENCE_DELETION") == 0 || strcmp(alc->alu[1]->text_label,"SEQUENCE_INSERTION") == 0) out->tframeshift++; else if ( strcmp(alc->alu[1]->text_label,"CENTRAL_INTRON") == 0 ) out->tintron++; /* NB, assuming we have collapsed central intron labels! */ } out->qend = alc->alu[0]->end+1; /* in C coords */ out->tend = alc->alu[1]->end+1; /*score += alc->alu[0]->score[0];*/ out->bits = Score2Bits(score); /*** hmm... this could be bad news ***/ *end = alc->next; return out; } /* Function: show_MatchSummary_genewise_header(ofp) * * Descrip: Shows a header (bits Query start etc) which matches * the order of the show_MatchSummarySet_genewise * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 152 "matchsum.dy" void show_MatchSummary_genewise_header(FILE * ofp) { fprintf(ofp,"Bits Query start end Target start end idels introns\n"); } /* Function: show_MatchSummarySet_genewise(mss,ofp) * * Descrip: shows Matchsummary for genewise * results, ie with target indels and introns * * * Arg: mss [UNKN ] Undocumented argument [MatchSummarySet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 161 "matchsum.dy" void show_MatchSummarySet_genewise(MatchSummarySet * mss,FILE * ofp) { int i; for(i=0;ilen;i++) show_MatchSummary_genewise(mss->ms[i],ofp); } /* Function: show_MatchSummary_genewise(ms,ofp) * * Descrip: shows a single match summary * * * Arg: ms [UNKN ] Undocumented argument [MatchSummary *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 173 "matchsum.dy" void show_MatchSummary_genewise(MatchSummary * ms,FILE * ofp) { if( ms->tstart < ms->tend ) fprintf(ofp,"%4.2f %-12s %4d %4d %-12s %4d %4d %4d %4d\n", ms->bits, ms->qname, ms->qstart+1, /* map to bio coords */ ms->qend, ms->tname, ms->tstart+1, /* map to 'bio coords */ ms->tend, ms->tframeshift, ms->tintron); else fprintf(ofp,"%4.2f %-12s %4d %4d %-12s %4d %4d %4d %4d\n", ms->bits, ms->qname, ms->qstart+1, /* map to bio coords */ ms->qend, ms->tname, ms->tstart+1, /* map to 'bio coords */ ms->tend+2, /* map to bio coords */ ms->tframeshift, ms->tintron); } /* Function: show_MatchSummary_estwise_header(ofp) * * Descrip: Shows a header (bits Query start etc) which matches * the order of the show_MatchSummarySet_estwise * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 204 "matchsum.dy" void show_MatchSummary_estwise_header(FILE * ofp) { fprintf(ofp,"Bits Query start end Target start end idels\n"); } /* Function: show_MatchSummarySet_estwise(mss,ofp) * * Descrip: Shows an estwise match, ie with only the target with indels * * * Arg: mss [UNKN ] Undocumented argument [MatchSummarySet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 212 "matchsum.dy" void show_MatchSummarySet_estwise(MatchSummarySet * mss,FILE * ofp) { int i; for(i=0;ilen;i++) show_MatchSummary_estwise(mss->ms[i],ofp); } /* Function: show_MatchSummary_estwise(ms,ofp) * * Descrip: shows a single estwise match * * * Arg: ms [UNKN ] Undocumented argument [MatchSummary *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 225 "matchsum.dy" void show_MatchSummary_estwise(MatchSummary * ms,FILE * ofp) { fprintf(ofp,"%4.2f %-12s %4d %4d %-12s %4d %4d %4d\n", ms->bits, ms->qname, ms->qstart+1, /* map to bio coords */ ms->qend, ms->tname, ms->tstart+1, /* map to 'bio coords */ ms->tend, ms->tframeshift); } # line 243 "matchsum.c" /* Function: hard_link_MatchSummary(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MatchSummary *] * * Return [UNKN ] Undocumented return value [MatchSummary *] * */ MatchSummary * hard_link_MatchSummary(MatchSummary * obj) { if( obj == NULL ) { warn("Trying to hard link to a MatchSummary object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: MatchSummary_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MatchSummary *] * */ MatchSummary * MatchSummary_alloc(void) { MatchSummary * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(MatchSummary *) ckalloc (sizeof(MatchSummary))) == NULL) { warn("MatchSummary_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->bits = 0; out->qname = NULL; out->tname = NULL; out->qstart = 0; out->qend = 0; out->tstart = 0; out->tend = 0; out->qintron = 0; out->qframeshift = 0; out->tintron = 0; out->tframeshift = 0; return out; } /* Function: free_MatchSummary(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MatchSummary *] * * Return [UNKN ] Undocumented return value [MatchSummary *] * */ MatchSummary * free_MatchSummary(MatchSummary * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a MatchSummary obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->qname != NULL) ckfree(obj->qname); if( obj->tname != NULL) ckfree(obj->tname); ckfree(obj); return NULL; } /* Function: swap_MatchSummarySet(list,i,j) * * Descrip: swap function: an internal for qsort_MatchSummarySet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [MatchSummary **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_MatchSummarySet(MatchSummary ** list,int i,int j) { MatchSummary * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_MatchSummarySet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_MatchSummarySet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [MatchSummary **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_MatchSummarySet(MatchSummary ** list,int left,int right,int (*comp)(MatchSummary * ,MatchSummary * )) { int i,last; if( left >= right ) return; swap_MatchSummarySet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_MatchSummarySet (list,++last,i); } swap_MatchSummarySet (list,left,last); qsort_MatchSummarySet(list,left,last-1,comp); qsort_MatchSummarySet(list,last+1,right,comp); } /* Function: sort_MatchSummarySet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_MatchSummarySet * * * Arg: obj [UNKN ] Object containing list [MatchSummarySet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_MatchSummarySet(MatchSummarySet * obj,int (*comp)(MatchSummary *, MatchSummary *)) { qsort_MatchSummarySet(obj->ms,0,obj->len-1,comp); return; } /* Function: expand_MatchSummarySet(obj,len) * * Descrip: Really an internal function for add_MatchSummarySet * * * Arg: obj [UNKN ] Object which contains the list [MatchSummarySet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_MatchSummarySet(MatchSummarySet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_MatchSummarySet called with no need"); return TRUE; } if( (obj->ms = (MatchSummary ** ) ckrealloc (obj->ms,sizeof(MatchSummary *)*len)) == NULL) { warn("ckrealloc failed for expand_MatchSummarySet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_MatchSummarySet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [MatchSummarySet *] * Arg: add [OWNER] Object to add to the list [MatchSummary *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_MatchSummarySet(MatchSummarySet * obj,MatchSummary * add) { if( obj->len >= obj->maxlen) { if( expand_MatchSummarySet(obj,obj->len + MatchSummarySetLISTLENGTH) == FALSE) return FALSE; } obj->ms[obj->len++]=add; return TRUE; } /* Function: flush_MatchSummarySet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [MatchSummarySet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_MatchSummarySet(MatchSummarySet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->ms[i] != NULL) { free_MatchSummary(obj->ms[i]); obj->ms[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: MatchSummarySet_alloc_std(void) * * Descrip: Equivalent to MatchSummarySet_alloc_len(MatchSummarySetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ MatchSummarySet * MatchSummarySet_alloc_std(void) { return MatchSummarySet_alloc_len(MatchSummarySetLISTLENGTH); } /* Function: MatchSummarySet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ MatchSummarySet * MatchSummarySet_alloc_len(int len) { MatchSummarySet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = MatchSummarySet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->ms = (MatchSummary ** ) ckcalloc (len,sizeof(MatchSummary *))) == NULL) { warn("Warning, ckcalloc failed in MatchSummarySet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_MatchSummarySet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MatchSummarySet *] * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ MatchSummarySet * hard_link_MatchSummarySet(MatchSummarySet * obj) { if( obj == NULL ) { warn("Trying to hard link to a MatchSummarySet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: MatchSummarySet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ MatchSummarySet * MatchSummarySet_alloc(void) { MatchSummarySet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(MatchSummarySet *) ckalloc (sizeof(MatchSummarySet))) == NULL) { warn("MatchSummarySet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->ms = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_MatchSummarySet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MatchSummarySet *] * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ MatchSummarySet * free_MatchSummarySet(MatchSummarySet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a MatchSummarySet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->ms != NULL) { for(i=0;ilen;i++) { if( obj->ms[i] != NULL) free_MatchSummary(obj->ms[i]); } ckfree(obj->ms); } ckfree(obj); return NULL; } /* Function: access_ms_MatchSummarySet(obj,i) * * Descrip: Access members stored in the ms list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [MatchSummarySet *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [MatchSummary *] * */ MatchSummary * access_ms_MatchSummarySet(MatchSummarySet * obj,int i) { if( obj == NULL) { warn("In accessor function ms for object MatchSummarySet, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function ms for object MatchSummarySet, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->ms[i]; } /* Function: length_ms_MatchSummarySet(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [MatchSummarySet *] * * Return [UNKN ] length of the list [int] * */ int length_ms_MatchSummarySet(MatchSummarySet * obj) { if( obj == NULL) { warn("In length function ms for object MatchSummarySet, got a NULL object"); return -1; } return obj->len; } /* Function: replace_bits_MatchSummary(obj,bits) * * Descrip: Replace member variable bits * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * Arg: bits [OWNER] New value of the variable [double] * * Return [SOFT ] member variable bits [boolean] * */ boolean replace_bits_MatchSummary(MatchSummary * obj,double bits) { if( obj == NULL) { warn("In replacement function bits for object MatchSummary, got a NULL object"); return FALSE; } obj->bits = bits; return TRUE; } /* Function: access_bits_MatchSummary(obj) * * Descrip: Access member variable bits * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * * Return [SOFT ] member variable bits [double] * */ double access_bits_MatchSummary(MatchSummary * obj) { if( obj == NULL) { warn("In accessor function bits for object MatchSummary, got a NULL object"); return 0; } return obj->bits; } /* Function: replace_qname_MatchSummary(obj,qname) * * Descrip: Replace member variable qname * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * Arg: qname [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable qname [boolean] * */ boolean replace_qname_MatchSummary(MatchSummary * obj,char * qname) { if( obj == NULL) { warn("In replacement function qname for object MatchSummary, got a NULL object"); return FALSE; } obj->qname = qname; return TRUE; } /* Function: access_qname_MatchSummary(obj) * * Descrip: Access member variable qname * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * * Return [SOFT ] member variable qname [char *] * */ char * access_qname_MatchSummary(MatchSummary * obj) { if( obj == NULL) { warn("In accessor function qname for object MatchSummary, got a NULL object"); return NULL; } return obj->qname; } /* Function: replace_tname_MatchSummary(obj,tname) * * Descrip: Replace member variable tname * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * Arg: tname [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable tname [boolean] * */ boolean replace_tname_MatchSummary(MatchSummary * obj,char * tname) { if( obj == NULL) { warn("In replacement function tname for object MatchSummary, got a NULL object"); return FALSE; } obj->tname = tname; return TRUE; } /* Function: access_tname_MatchSummary(obj) * * Descrip: Access member variable tname * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * * Return [SOFT ] member variable tname [char *] * */ char * access_tname_MatchSummary(MatchSummary * obj) { if( obj == NULL) { warn("In accessor function tname for object MatchSummary, got a NULL object"); return NULL; } return obj->tname; } /* Function: replace_qstart_MatchSummary(obj,qstart) * * Descrip: Replace member variable qstart * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * Arg: qstart [OWNER] New value of the variable [int] * * Return [SOFT ] member variable qstart [boolean] * */ boolean replace_qstart_MatchSummary(MatchSummary * obj,int qstart) { if( obj == NULL) { warn("In replacement function qstart for object MatchSummary, got a NULL object"); return FALSE; } obj->qstart = qstart; return TRUE; } /* Function: access_qstart_MatchSummary(obj) * * Descrip: Access member variable qstart * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * * Return [SOFT ] member variable qstart [int] * */ int access_qstart_MatchSummary(MatchSummary * obj) { if( obj == NULL) { warn("In accessor function qstart for object MatchSummary, got a NULL object"); return 0; } return obj->qstart; } /* Function: replace_qend_MatchSummary(obj,qend) * * Descrip: Replace member variable qend * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * Arg: qend [OWNER] New value of the variable [int] * * Return [SOFT ] member variable qend [boolean] * */ boolean replace_qend_MatchSummary(MatchSummary * obj,int qend) { if( obj == NULL) { warn("In replacement function qend for object MatchSummary, got a NULL object"); return FALSE; } obj->qend = qend; return TRUE; } /* Function: access_qend_MatchSummary(obj) * * Descrip: Access member variable qend * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * * Return [SOFT ] member variable qend [int] * */ int access_qend_MatchSummary(MatchSummary * obj) { if( obj == NULL) { warn("In accessor function qend for object MatchSummary, got a NULL object"); return 0; } return obj->qend; } /* Function: replace_tstart_MatchSummary(obj,tstart) * * Descrip: Replace member variable tstart * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * Arg: tstart [OWNER] New value of the variable [int] * * Return [SOFT ] member variable tstart [boolean] * */ boolean replace_tstart_MatchSummary(MatchSummary * obj,int tstart) { if( obj == NULL) { warn("In replacement function tstart for object MatchSummary, got a NULL object"); return FALSE; } obj->tstart = tstart; return TRUE; } /* Function: access_tstart_MatchSummary(obj) * * Descrip: Access member variable tstart * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * * Return [SOFT ] member variable tstart [int] * */ int access_tstart_MatchSummary(MatchSummary * obj) { if( obj == NULL) { warn("In accessor function tstart for object MatchSummary, got a NULL object"); return 0; } return obj->tstart; } /* Function: replace_tend_MatchSummary(obj,tend) * * Descrip: Replace member variable tend * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * Arg: tend [OWNER] New value of the variable [int] * * Return [SOFT ] member variable tend [boolean] * */ boolean replace_tend_MatchSummary(MatchSummary * obj,int tend) { if( obj == NULL) { warn("In replacement function tend for object MatchSummary, got a NULL object"); return FALSE; } obj->tend = tend; return TRUE; } /* Function: access_tend_MatchSummary(obj) * * Descrip: Access member variable tend * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * * Return [SOFT ] member variable tend [int] * */ int access_tend_MatchSummary(MatchSummary * obj) { if( obj == NULL) { warn("In accessor function tend for object MatchSummary, got a NULL object"); return 0; } return obj->tend; } /* Function: replace_qintron_MatchSummary(obj,qintron) * * Descrip: Replace member variable qintron * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * Arg: qintron [OWNER] New value of the variable [int] * * Return [SOFT ] member variable qintron [boolean] * */ boolean replace_qintron_MatchSummary(MatchSummary * obj,int qintron) { if( obj == NULL) { warn("In replacement function qintron for object MatchSummary, got a NULL object"); return FALSE; } obj->qintron = qintron; return TRUE; } /* Function: access_qintron_MatchSummary(obj) * * Descrip: Access member variable qintron * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * * Return [SOFT ] member variable qintron [int] * */ int access_qintron_MatchSummary(MatchSummary * obj) { if( obj == NULL) { warn("In accessor function qintron for object MatchSummary, got a NULL object"); return 0; } return obj->qintron; } /* Function: replace_qframeshift_MatchSummary(obj,qframeshift) * * Descrip: Replace member variable qframeshift * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * Arg: qframeshift [OWNER] New value of the variable [int] * * Return [SOFT ] member variable qframeshift [boolean] * */ boolean replace_qframeshift_MatchSummary(MatchSummary * obj,int qframeshift) { if( obj == NULL) { warn("In replacement function qframeshift for object MatchSummary, got a NULL object"); return FALSE; } obj->qframeshift = qframeshift; return TRUE; } /* Function: access_qframeshift_MatchSummary(obj) * * Descrip: Access member variable qframeshift * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * * Return [SOFT ] member variable qframeshift [int] * */ int access_qframeshift_MatchSummary(MatchSummary * obj) { if( obj == NULL) { warn("In accessor function qframeshift for object MatchSummary, got a NULL object"); return 0; } return obj->qframeshift; } /* Function: replace_tintron_MatchSummary(obj,tintron) * * Descrip: Replace member variable tintron * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * Arg: tintron [OWNER] New value of the variable [int] * * Return [SOFT ] member variable tintron [boolean] * */ boolean replace_tintron_MatchSummary(MatchSummary * obj,int tintron) { if( obj == NULL) { warn("In replacement function tintron for object MatchSummary, got a NULL object"); return FALSE; } obj->tintron = tintron; return TRUE; } /* Function: access_tintron_MatchSummary(obj) * * Descrip: Access member variable tintron * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * * Return [SOFT ] member variable tintron [int] * */ int access_tintron_MatchSummary(MatchSummary * obj) { if( obj == NULL) { warn("In accessor function tintron for object MatchSummary, got a NULL object"); return 0; } return obj->tintron; } /* Function: replace_tframeshift_MatchSummary(obj,tframeshift) * * Descrip: Replace member variable tframeshift * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * Arg: tframeshift [OWNER] New value of the variable [int] * * Return [SOFT ] member variable tframeshift [boolean] * */ boolean replace_tframeshift_MatchSummary(MatchSummary * obj,int tframeshift) { if( obj == NULL) { warn("In replacement function tframeshift for object MatchSummary, got a NULL object"); return FALSE; } obj->tframeshift = tframeshift; return TRUE; } /* Function: access_tframeshift_MatchSummary(obj) * * Descrip: Access member variable tframeshift * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [MatchSummary *] * * Return [SOFT ] member variable tframeshift [int] * */ int access_tframeshift_MatchSummary(MatchSummary * obj) { if( obj == NULL) { warn("In accessor function tframeshift for object MatchSummary, got a NULL object"); return 0; } return obj->tframeshift; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/matchsum.h0000644000175000001440000003337310670453714016135 0ustar philippusers#ifndef DYNAMITEmatchsumHEADERFILE #define DYNAMITEmatchsumHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "gwrap.h" #define MatchSummarySetLISTLENGTH 128 /* Object MatchSummary * * Descrip: A Match Summary has summary statistics * for a single alignment, with the * two start/end ranges and the number of * introns and frameshifts for each * sequence (obviously, if one is a protein * then neither are valid!) * * */ struct Wise2_MatchSummary { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif double bits; char * qname; char * tname; int qstart; int qend; int tstart; int tend; int qintron; int qframeshift; int tintron; int tframeshift; } ; /* MatchSummary defined */ #ifndef DYNAMITE_DEFINED_MatchSummary typedef struct Wise2_MatchSummary Wise2_MatchSummary; #define MatchSummary Wise2_MatchSummary #define DYNAMITE_DEFINED_MatchSummary #endif /* Object MatchSummarySet * * Descrip: This holds a set of MatchSummaries, * * */ struct Wise2_MatchSummarySet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif MatchSummary ** ms; int len;/* len for above ms */ int maxlen; /* maxlen for above ms */ } ; /* MatchSummarySet defined */ #ifndef DYNAMITE_DEFINED_MatchSummarySet typedef struct Wise2_MatchSummarySet Wise2_MatchSummarySet; #define MatchSummarySet Wise2_MatchSummarySet #define DYNAMITE_DEFINED_MatchSummarySet #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: MatchSummarySet_from_AlnBlock_estwise(alb,qname,offset,target) * * Descrip: Builds a MatchSummarySet from a * EstWise alignment. this makes * alot of assumptions about the labels * setc in alb, so make sure it was a * estwise alignment - however as you * can notice this is exactly the same * labels as found in genewise set * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: qname [UNKN ] Undocumented argument [char *] * Arg: offset [UNKN ] Undocumented argument [int] * Arg: target [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ MatchSummarySet * Wise2_MatchSummarySet_from_AlnBlock_estwise(AlnBlock * alb,char * qname,int offset,Sequence * target); #define MatchSummarySet_from_AlnBlock_estwise Wise2_MatchSummarySet_from_AlnBlock_estwise /* Function: MatchSummarySet_from_AlnBlock_genewise(alb,qname,protoff,target) * * Descrip: Builds a MatchSummarySet from a * GeneWise alignment. this makes * alot of assumptions about the labels * setc in alb, so make sure it was a * genewise alignment * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: qname [UNKN ] Undocumented argument [char *] * Arg: protoff [UNKN ] Undocumented argument [int] * Arg: target [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ MatchSummarySet * Wise2_MatchSummarySet_from_AlnBlock_genewise(AlnBlock * alb,char * qname,int protoff,Sequence * target); #define MatchSummarySet_from_AlnBlock_genewise Wise2_MatchSummarySet_from_AlnBlock_genewise /* Function: show_MatchSummary_genewise_header(ofp) * * Descrip: Shows a header (bits Query start etc) which matches * the order of the show_MatchSummarySet_genewise * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_MatchSummary_genewise_header(FILE * ofp); #define show_MatchSummary_genewise_header Wise2_show_MatchSummary_genewise_header /* Function: show_MatchSummarySet_genewise(mss,ofp) * * Descrip: shows Matchsummary for genewise * results, ie with target indels and introns * * * Arg: mss [UNKN ] Undocumented argument [MatchSummarySet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_MatchSummarySet_genewise(MatchSummarySet * mss,FILE * ofp); #define show_MatchSummarySet_genewise Wise2_show_MatchSummarySet_genewise /* Function: show_MatchSummary_estwise_header(ofp) * * Descrip: Shows a header (bits Query start etc) which matches * the order of the show_MatchSummarySet_estwise * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_MatchSummary_estwise_header(FILE * ofp); #define show_MatchSummary_estwise_header Wise2_show_MatchSummary_estwise_header /* Function: show_MatchSummarySet_estwise(mss,ofp) * * Descrip: Shows an estwise match, ie with only the target with indels * * * Arg: mss [UNKN ] Undocumented argument [MatchSummarySet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_MatchSummarySet_estwise(MatchSummarySet * mss,FILE * ofp); #define show_MatchSummarySet_estwise Wise2_show_MatchSummarySet_estwise /* Function: hard_link_MatchSummary(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MatchSummary *] * * Return [UNKN ] Undocumented return value [MatchSummary *] * */ MatchSummary * Wise2_hard_link_MatchSummary(MatchSummary * obj); #define hard_link_MatchSummary Wise2_hard_link_MatchSummary /* Function: MatchSummary_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MatchSummary *] * */ MatchSummary * Wise2_MatchSummary_alloc(void); #define MatchSummary_alloc Wise2_MatchSummary_alloc /* Function: free_MatchSummary(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MatchSummary *] * * Return [UNKN ] Undocumented return value [MatchSummary *] * */ MatchSummary * Wise2_free_MatchSummary(MatchSummary * obj); #define free_MatchSummary Wise2_free_MatchSummary /* Function: add_MatchSummarySet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [MatchSummarySet *] * Arg: add [OWNER] Object to add to the list [MatchSummary *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_MatchSummarySet(MatchSummarySet * obj,MatchSummary * add); #define add_MatchSummarySet Wise2_add_MatchSummarySet /* Function: flush_MatchSummarySet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [MatchSummarySet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_MatchSummarySet(MatchSummarySet * obj); #define flush_MatchSummarySet Wise2_flush_MatchSummarySet /* Function: MatchSummarySet_alloc_std(void) * * Descrip: Equivalent to MatchSummarySet_alloc_len(MatchSummarySetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ MatchSummarySet * Wise2_MatchSummarySet_alloc_std(void); #define MatchSummarySet_alloc_std Wise2_MatchSummarySet_alloc_std /* Function: MatchSummarySet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ MatchSummarySet * Wise2_MatchSummarySet_alloc_len(int len); #define MatchSummarySet_alloc_len Wise2_MatchSummarySet_alloc_len /* Function: hard_link_MatchSummarySet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MatchSummarySet *] * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ MatchSummarySet * Wise2_hard_link_MatchSummarySet(MatchSummarySet * obj); #define hard_link_MatchSummarySet Wise2_hard_link_MatchSummarySet /* Function: MatchSummarySet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ MatchSummarySet * Wise2_MatchSummarySet_alloc(void); #define MatchSummarySet_alloc Wise2_MatchSummarySet_alloc /* Function: free_MatchSummarySet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MatchSummarySet *] * * Return [UNKN ] Undocumented return value [MatchSummarySet *] * */ MatchSummarySet * Wise2_free_MatchSummarySet(MatchSummarySet * obj); #define free_MatchSummarySet Wise2_free_MatchSummarySet /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ MatchSummary * Wise2_access_ms_MatchSummarySet(MatchSummarySet * obj,int i); #define access_ms_MatchSummarySet Wise2_access_ms_MatchSummarySet boolean Wise2_replace_qstart_MatchSummary(MatchSummary * obj,int qstart); #define replace_qstart_MatchSummary Wise2_replace_qstart_MatchSummary int Wise2_access_qstart_MatchSummary(MatchSummary * obj); #define access_qstart_MatchSummary Wise2_access_qstart_MatchSummary int Wise2_access_qend_MatchSummary(MatchSummary * obj); #define access_qend_MatchSummary Wise2_access_qend_MatchSummary int Wise2_access_tframeshift_MatchSummary(MatchSummary * obj); #define access_tframeshift_MatchSummary Wise2_access_tframeshift_MatchSummary boolean Wise2_replace_tstart_MatchSummary(MatchSummary * obj,int tstart); #define replace_tstart_MatchSummary Wise2_replace_tstart_MatchSummary int Wise2_length_ms_MatchSummarySet(MatchSummarySet * obj); #define length_ms_MatchSummarySet Wise2_length_ms_MatchSummarySet int Wise2_access_tstart_MatchSummary(MatchSummary * obj); #define access_tstart_MatchSummary Wise2_access_tstart_MatchSummary double Wise2_access_bits_MatchSummary(MatchSummary * obj); #define access_bits_MatchSummary Wise2_access_bits_MatchSummary boolean Wise2_replace_tend_MatchSummary(MatchSummary * obj,int tend); #define replace_tend_MatchSummary Wise2_replace_tend_MatchSummary char * Wise2_access_qname_MatchSummary(MatchSummary * obj); #define access_qname_MatchSummary Wise2_access_qname_MatchSummary int Wise2_access_tend_MatchSummary(MatchSummary * obj); #define access_tend_MatchSummary Wise2_access_tend_MatchSummary char * Wise2_access_tname_MatchSummary(MatchSummary * obj); #define access_tname_MatchSummary Wise2_access_tname_MatchSummary boolean Wise2_replace_qintron_MatchSummary(MatchSummary * obj,int qintron); #define replace_qintron_MatchSummary Wise2_replace_qintron_MatchSummary boolean Wise2_replace_qend_MatchSummary(MatchSummary * obj,int qend); #define replace_qend_MatchSummary Wise2_replace_qend_MatchSummary int Wise2_access_qintron_MatchSummary(MatchSummary * obj); #define access_qintron_MatchSummary Wise2_access_qintron_MatchSummary boolean Wise2_replace_bits_MatchSummary(MatchSummary * obj,double bits); #define replace_bits_MatchSummary Wise2_replace_bits_MatchSummary boolean Wise2_replace_qframeshift_MatchSummary(MatchSummary * obj,int qframeshift); #define replace_qframeshift_MatchSummary Wise2_replace_qframeshift_MatchSummary boolean Wise2_replace_tname_MatchSummary(MatchSummary * obj,char * tname); #define replace_tname_MatchSummary Wise2_replace_tname_MatchSummary int Wise2_access_qframeshift_MatchSummary(MatchSummary * obj); #define access_qframeshift_MatchSummary Wise2_access_qframeshift_MatchSummary boolean Wise2_replace_qname_MatchSummary(MatchSummary * obj,char * qname); #define replace_qname_MatchSummary Wise2_replace_qname_MatchSummary boolean Wise2_replace_tintron_MatchSummary(MatchSummary * obj,int tintron); #define replace_tintron_MatchSummary Wise2_replace_tintron_MatchSummary boolean Wise2_replace_tframeshift_MatchSummary(MatchSummary * obj,int tframeshift); #define replace_tframeshift_MatchSummary Wise2_replace_tframeshift_MatchSummary int Wise2_access_tintron_MatchSummary(MatchSummary * obj); #define access_tintron_MatchSummary Wise2_access_tintron_MatchSummary MatchSummary * Wise2_MatchSummary_from_AlnColumn_genewise(AlnColumn * alc,AlnColumn ** end); #define MatchSummary_from_AlnColumn_genewise Wise2_MatchSummary_from_AlnColumn_genewise void Wise2_show_MatchSummary_genewise(MatchSummary * ms,FILE * ofp); #define show_MatchSummary_genewise Wise2_show_MatchSummary_genewise void Wise2_show_MatchSummary_estwise(MatchSummary * ms,FILE * ofp); #define show_MatchSummary_estwise Wise2_show_MatchSummary_estwise void Wise2_swap_MatchSummarySet(MatchSummary ** list,int i,int j) ; #define swap_MatchSummarySet Wise2_swap_MatchSummarySet void Wise2_qsort_MatchSummarySet(MatchSummary ** list,int left,int right,int (*comp)(MatchSummary * ,MatchSummary * )); #define qsort_MatchSummarySet Wise2_qsort_MatchSummarySet void Wise2_sort_MatchSummarySet(MatchSummarySet * obj,int (*comp)(MatchSummary *, MatchSummary *)); #define sort_MatchSummarySet Wise2_sort_MatchSummarySet boolean Wise2_expand_MatchSummarySet(MatchSummarySet * obj,int len); #define expand_MatchSummarySet Wise2_expand_MatchSummarySet #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/seqaligndisplay.dy0000644000175000001440000001415307547571136017675 0ustar philippusers %{ #include "dyna.h" %} api func write_pretty_str_align func write_pretty_seq_align func write_pretty_Protein_align endapi %{ #include "seqaligndisplay.h" %func This gives an interface into the alignment display using Protein objects %arg alb alignment structure q first sequence t second sequence name length of the name block main length of the main block ofp output file %% boolean write_pretty_Protein_align(AlnBlock * alb,Protein * q,Protein * t,int name,int main,FILE * ofp) { if( alb == NULL || q == NULL || t == NULL ) { warn("NULL objects being passed into write_pretty_Protein_align"); return FALSE; } return write_pretty_seq_align(alb,q->baseseq,t->baseseq,name,main,ofp); } %func This gives an interface into the alignment display using sequences and files. A more generic function is write_pretty_str_align %arg alb alignment structure q first sequence t second sequence name length of the name block main length of the main block ofp output file %% boolean write_pretty_seq_align(AlnBlock * alb,Sequence * q,Sequence * t,int name,int main,FILE * ofp) { char qname[64]; char tname[64]; btCanvas * btc; if( alb == NULL || q == NULL || t == NULL ) { warn("NULL objects being passed into write_pretty_seq_align"); return FALSE; } if( name > 64 ) { warn("Sorry - hard coded limited, can't have names longer than 64"); return FALSE; } if( strlen(q->name) > name ) { warn("Name %s is longer than allowed name block (%d). Truncating\n",q->name,name); strncpy(qname,q->name,name); qname[name] = '\0'; } else { strcpy(qname,q->name); } if( strlen(t->name) > name ) { warn("Name %s is longer than allowed name block (%d). Truncating\n",t->name,name); strncpy(tname,t->name,name); tname[name] = '\0'; } else { strcpy(tname,t->name); } btc = new_Ascii_btCanvas(ofp,name+6,main,0,3); /*+6 in case we want to put in numbers */ write_pretty_str_align_btc(alb,qname,q->seq,tname,t->seq,btc); /** destroy btc canvas **/ free_btCanvas(btc); return TRUE; } %func This gives an interface into the alignment display using strings and files. %arg alb alignment structure qname name of first sequence tname name of second sequence query first sequence target second sequence name length of the name block main length of the main block ofp output file %% boolean write_pretty_str_align(AlnBlock * alb,char * qname,char * query,char * tname,char * target,int name,int main,FILE * ofp) { boolean out; btCanvas * btc; btc = new_Ascii_btCanvas(ofp,name+6,main,0,3); /*+6 in case we want to put in numbers */ out = write_pretty_str_align_btc(alb,qname,query,tname,target,btc); /** destroy btc canvas **/ free_btCanvas(btc); return out; } %func This function writes precisely what you expect for a a simple alignment. We can reuse this routine all over the place because we dont use any hard coded structure for the query or the target sequence letters. ... but crap type checking it has to be said! Also we use a generic btCanvas that could have any implementation underneath (eg, ASCII, postscript etc). %% boolean write_pretty_str_align_btc(AlnBlock * alb,char * qname,char * query,char * tname,char * target,btCanvas * btc) { AlnColumn * alc; AlnUnit * q; AlnUnit * t; char buffer[14]; btPasteArea * btp; for(alc=alb->start;alc != NULL;) { /** put names in **/ btp = get_reserved_left_btCanvas(btc); paste_string_btPasteArea(btp,0,0,qname,BC_RIGHT,0); paste_string_btPasteArea(btp,0,2,tname,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[0]->start+1+1); paste_string_btPasteArea(btp,12,0,buffer,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[1]->start+1+1); paste_string_btPasteArea(btp,12,2,buffer,BC_RIGHT,0); free_btPasteArea(btp); /** now loop over this block **/ for(;alc != NULL && can_get_paste_area_btCanvas(btc,1) == TRUE;alc=alc->next) { q = alc->alu[0]; t = alc->alu[1]; /* * at the end, break */ if( strcmp(q->text_label,"END") == 0 ) { alc = NULL; break; } if( strcmp(t->text_label,"LOOP") == 0 ) { advance_line_btCanvas(btc); for(;alc != NULL && strcmp(alc->alu[1]->text_label,"LOOP") == 0;alc = alc->next) { ; } break; } /* * Get the paste area, length 1, depth will be 3 */ btp = get_paste_area_btCanvas(btc,1); /* * Write in the query sequence * */ if( strcmp(q->text_label,"SEQUENCE") == 0 || strstr(q->text_label,"BOUND") != NULL ) { paste_char_btPasteArea(btp,0,0,((int)query[q->start+1]),0); } else if( strcmp(q->text_label,"UNMATCHED_SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,0,tolower((int)query[q->start+1]),0); } else { /** is insert- we could check **/ if( strcmp(q->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",q->text_label); paste_char_btPasteArea(btp,0,0,'?',0); } else { paste_char_btPasteArea(btp,0,0,'-',0); } } /* * Write in the target sequence * */ if( strcmp(t->text_label,"SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,2,toupper((int)target[t->start+1]),0); } else if( strcmp(t->text_label,"UNMATCHED_SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,2,tolower((int)target[t->start+1]),0); } else { /** is insert- we could check **/ if( strcmp(t->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",t->text_label); paste_char_btPasteArea(btp,0,2,'?',0); } else { paste_char_btPasteArea(btp,0,2,'-',0); } } /* * Match line */ if( strcmp(q->text_label,"SEQUENCE") == 0 && strcmp(t->text_label,"SEQUENCE") == 0 ) { if( q->score[0] > 0 ) { if( query[q->start+1] == target[t->start+1] ) { paste_char_btPasteArea(btp,0,1,target[t->start+1],0); } else { paste_char_btPasteArea(btp,0,1,'+',0); } } } else paste_char_btPasteArea(btp,0,1,' ',0); free_btPasteArea(btp); } /* end of for this block */ advance_line_btCanvas(btc); } /* end of for the alignment */ return TRUE; /* we never returned false. Ooops! */ } %} wise-2.4.1/src/models/seqaligndisplay.xs0000644000175000001440000000145510670453715017705 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2 boolean write_pretty_str_align(alb,qname,query,tname,target,name,main,ofp) Wise2_AlnBlock * alb char * qname char * query char * tname char * target int name int main FILE * ofp CODE: RETVAL = Wise2_write_pretty_str_align(alb,qname,query,tname,target,name,main,ofp); OUTPUT: RETVAL boolean write_pretty_seq_align(alb,q,t,name,main,ofp) Wise2_AlnBlock * alb Wise2_Sequence * q Wise2_Sequence * t int name int main FILE * ofp CODE: RETVAL = Wise2_write_pretty_seq_align(alb,q,t,name,main,ofp); OUTPUT: RETVAL boolean write_pretty_Protein_align(alb,q,t,name,main,ofp) Wise2_AlnBlock * alb Wise2_Protein * q Wise2_Protein * t int name int main FILE * ofp CODE: RETVAL = Wise2_write_pretty_Protein_align(alb,q,t,name,main,ofp); OUTPUT: RETVAL wise-2.4.1/src/models/syexonmodel.c0000644000175000001440000005262510670453715016657 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "syexonmodel.h" # line 31 "syexonmodel.dy" SyExonScore * SyExonScore_flat_model(int start,int end,Probability exit,Probability final_stay) { SyExonScore * out; SyExonModel * m; m = SyExonModel_flat_model(start,end,exit,final_stay); out = SyExonScore_from_SyExonModel(m); free_SyExonModel(m); return out; } # line 46 "syexonmodel.dy" SyExonModel * SyExonModel_flat_model(int start,int end,Probability exit,Probability final_stay) { int i; SyExon * e; SyExonModel * out; Probability prev; out = SyExonModel_alloc_len(end); prev = 0.0; for(i=0;iexit_prob = 0.0; e->stay_prob = 0.0; e->prev_prob = prev; prev = 1.0; } else { e->exit_prob = exit; e->stay_prob = 0.0; e->prev_prob = prev; prev = 1.0-exit; } if( i+3 > end ) { e->stay_prob = final_stay; } } return out; } # line 80 "syexonmodel.dy" SyExonScore * SyExonScore_from_SyExonModel(SyExonModel * sym) { int i; SyExonScore * out; out = SyExonScore_alloc_len(sym->len); for(i=0;ilen;i++) { add_SyExonScore(out,SyExonScoreUnit_from_SyExon(sym->exon[i])); } return out; } # line 96 "syexonmodel.dy" SyExonScoreUnit * SyExonScoreUnit_from_SyExon(SyExon * sye) { SyExonScoreUnit * out; out = SyExonScoreUnit_alloc(); out->exit_score = Probability2Score(sye->exit_prob); out->stay_score = Probability2Score(sye->stay_prob); return out; } # line 109 "syexonmodel.dy" void dump_SyExonScore(SyExonScore * sc,FILE *ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,"%d exit %d stay %d\n",i,sc->exon[i]->exit_score,sc->exon[i]->stay_score); } } # line 101 "syexonmodel.c" /* Function: hard_link_SyExon(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SyExon *] * * Return [UNKN ] Undocumented return value [SyExon *] * */ SyExon * hard_link_SyExon(SyExon * obj) { if( obj == NULL ) { warn("Trying to hard link to a SyExon object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SyExon_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SyExon *] * */ SyExon * SyExon_alloc(void) { SyExon * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SyExon *) ckalloc (sizeof(SyExon))) == NULL) { warn("SyExon_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->exit_prob = 0.0; out->stay_prob = 0.0; out->prev_prob = 0.0; return out; } /* Function: free_SyExon(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SyExon *] * * Return [UNKN ] Undocumented return value [SyExon *] * */ SyExon * free_SyExon(SyExon * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SyExon obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_SyExonScoreUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SyExonScoreUnit *] * * Return [UNKN ] Undocumented return value [SyExonScoreUnit *] * */ SyExonScoreUnit * hard_link_SyExonScoreUnit(SyExonScoreUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a SyExonScoreUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SyExonScoreUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SyExonScoreUnit *] * */ SyExonScoreUnit * SyExonScoreUnit_alloc(void) { SyExonScoreUnit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SyExonScoreUnit *) ckalloc (sizeof(SyExonScoreUnit))) == NULL) { warn("SyExonScoreUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->exit_score = 0; out->stay_score = 0; return out; } /* Function: free_SyExonScoreUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SyExonScoreUnit *] * * Return [UNKN ] Undocumented return value [SyExonScoreUnit *] * */ SyExonScoreUnit * free_SyExonScoreUnit(SyExonScoreUnit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SyExonScoreUnit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_SyExonModel(list,i,j) * * Descrip: swap function: an internal for qsort_SyExonModel * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [SyExon **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SyExonModel(SyExon ** list,int i,int j) { SyExon * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SyExonModel(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SyExonModel which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [SyExon **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SyExonModel(SyExon ** list,int left,int right,int (*comp)(SyExon * ,SyExon * )) { int i,last; if( left >= right ) return; swap_SyExonModel(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SyExonModel (list,++last,i); } swap_SyExonModel (list,left,last); qsort_SyExonModel(list,left,last-1,comp); qsort_SyExonModel(list,last+1,right,comp); } /* Function: sort_SyExonModel(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SyExonModel * * * Arg: obj [UNKN ] Object containing list [SyExonModel *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SyExonModel(SyExonModel * obj,int (*comp)(SyExon *, SyExon *)) { qsort_SyExonModel(obj->exon,0,obj->len-1,comp); return; } /* Function: expand_SyExonModel(obj,len) * * Descrip: Really an internal function for add_SyExonModel * * * Arg: obj [UNKN ] Object which contains the list [SyExonModel *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SyExonModel(SyExonModel * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SyExonModel called with no need"); return TRUE; } if( (obj->exon = (SyExon ** ) ckrealloc (obj->exon,sizeof(SyExon *)*len)) == NULL) { warn("ckrealloc failed for expand_SyExonModel, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SyExonModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SyExonModel *] * Arg: add [OWNER] Object to add to the list [SyExon *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SyExonModel(SyExonModel * obj,SyExon * add) { if( obj->len >= obj->maxlen) { if( expand_SyExonModel(obj,obj->len + SyExonModelLISTLENGTH) == FALSE) return FALSE; } obj->exon[obj->len++]=add; return TRUE; } /* Function: flush_SyExonModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SyExonModel *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SyExonModel(SyExonModel * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->exon[i] != NULL) { free_SyExon(obj->exon[i]); obj->exon[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SyExonModel_alloc_std(void) * * Descrip: Equivalent to SyExonModel_alloc_len(SyExonModelLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SyExonModel *] * */ SyExonModel * SyExonModel_alloc_std(void) { return SyExonModel_alloc_len(SyExonModelLISTLENGTH); } /* Function: SyExonModel_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SyExonModel *] * */ SyExonModel * SyExonModel_alloc_len(int len) { SyExonModel * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SyExonModel_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->exon = (SyExon ** ) ckcalloc (len,sizeof(SyExon *))) == NULL) { warn("Warning, ckcalloc failed in SyExonModel_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SyExonModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SyExonModel *] * * Return [UNKN ] Undocumented return value [SyExonModel *] * */ SyExonModel * hard_link_SyExonModel(SyExonModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a SyExonModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SyExonModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SyExonModel *] * */ SyExonModel * SyExonModel_alloc(void) { SyExonModel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SyExonModel *) ckalloc (sizeof(SyExonModel))) == NULL) { warn("SyExonModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->exon = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_SyExonModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SyExonModel *] * * Return [UNKN ] Undocumented return value [SyExonModel *] * */ SyExonModel * free_SyExonModel(SyExonModel * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SyExonModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->exon != NULL) { for(i=0;ilen;i++) { if( obj->exon[i] != NULL) free_SyExon(obj->exon[i]); } ckfree(obj->exon); } ckfree(obj); return NULL; } /* Function: swap_SyExonScore(list,i,j) * * Descrip: swap function: an internal for qsort_SyExonScore * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [SyExonScoreUnit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SyExonScore(SyExonScoreUnit ** list,int i,int j) { SyExonScoreUnit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SyExonScore(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SyExonScore which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [SyExonScoreUnit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SyExonScore(SyExonScoreUnit ** list,int left,int right,int (*comp)(SyExonScoreUnit * ,SyExonScoreUnit * )) { int i,last; if( left >= right ) return; swap_SyExonScore(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SyExonScore (list,++last,i); } swap_SyExonScore (list,left,last); qsort_SyExonScore(list,left,last-1,comp); qsort_SyExonScore(list,last+1,right,comp); } /* Function: sort_SyExonScore(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SyExonScore * * * Arg: obj [UNKN ] Object containing list [SyExonScore *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SyExonScore(SyExonScore * obj,int (*comp)(SyExonScoreUnit *, SyExonScoreUnit *)) { qsort_SyExonScore(obj->exon,0,obj->len-1,comp); return; } /* Function: expand_SyExonScore(obj,len) * * Descrip: Really an internal function for add_SyExonScore * * * Arg: obj [UNKN ] Object which contains the list [SyExonScore *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SyExonScore(SyExonScore * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SyExonScore called with no need"); return TRUE; } if( (obj->exon = (SyExonScoreUnit ** ) ckrealloc (obj->exon,sizeof(SyExonScoreUnit *)*len)) == NULL) { warn("ckrealloc failed for expand_SyExonScore, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SyExonScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SyExonScore *] * Arg: add [OWNER] Object to add to the list [SyExonScoreUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SyExonScore(SyExonScore * obj,SyExonScoreUnit * add) { if( obj->len >= obj->maxlen) { if( expand_SyExonScore(obj,obj->len + SyExonScoreLISTLENGTH) == FALSE) return FALSE; } obj->exon[obj->len++]=add; return TRUE; } /* Function: flush_SyExonScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SyExonScore *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SyExonScore(SyExonScore * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->exon[i] != NULL) { free_SyExonScoreUnit(obj->exon[i]); obj->exon[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SyExonScore_alloc_std(void) * * Descrip: Equivalent to SyExonScore_alloc_len(SyExonScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SyExonScore *] * */ SyExonScore * SyExonScore_alloc_std(void) { return SyExonScore_alloc_len(SyExonScoreLISTLENGTH); } /* Function: SyExonScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SyExonScore *] * */ SyExonScore * SyExonScore_alloc_len(int len) { SyExonScore * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SyExonScore_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->exon = (SyExonScoreUnit ** ) ckcalloc (len,sizeof(SyExonScoreUnit *))) == NULL) { warn("Warning, ckcalloc failed in SyExonScore_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SyExonScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SyExonScore *] * * Return [UNKN ] Undocumented return value [SyExonScore *] * */ SyExonScore * hard_link_SyExonScore(SyExonScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a SyExonScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SyExonScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SyExonScore *] * */ SyExonScore * SyExonScore_alloc(void) { SyExonScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SyExonScore *) ckalloc (sizeof(SyExonScore))) == NULL) { warn("SyExonScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->exon = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_SyExonScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SyExonScore *] * * Return [UNKN ] Undocumented return value [SyExonScore *] * */ SyExonScore * free_SyExonScore(SyExonScore * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SyExonScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->exon != NULL) { for(i=0;ilen;i++) { if( obj->exon[i] != NULL) free_SyExonScoreUnit(obj->exon[i]); } ckfree(obj->exon); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/syexonmodel.h0000644000175000001440000002715410670453715016663 0ustar philippusers#ifndef DYNAMITEsyexonmodelHEADERFILE #define DYNAMITEsyexonmodelHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #define SyExonModelLISTLENGTH 128 #define SyExonScoreLISTLENGTH 128 struct Wise2_SyExon { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability exit_prob; Probability stay_prob; Probability prev_prob; } ; /* SyExon defined */ #ifndef DYNAMITE_DEFINED_SyExon typedef struct Wise2_SyExon Wise2_SyExon; #define SyExon Wise2_SyExon #define DYNAMITE_DEFINED_SyExon #endif struct Wise2_SyExonScoreUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score exit_score; Score stay_score; } ; /* SyExonScoreUnit defined */ #ifndef DYNAMITE_DEFINED_SyExonScoreUnit typedef struct Wise2_SyExonScoreUnit Wise2_SyExonScoreUnit; #define SyExonScoreUnit Wise2_SyExonScoreUnit #define DYNAMITE_DEFINED_SyExonScoreUnit #endif struct Wise2_SyExonModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SyExon ** exon; int len;/* len for above exon */ int maxlen; /* maxlen for above exon */ } ; /* SyExonModel defined */ #ifndef DYNAMITE_DEFINED_SyExonModel typedef struct Wise2_SyExonModel Wise2_SyExonModel; #define SyExonModel Wise2_SyExonModel #define DYNAMITE_DEFINED_SyExonModel #endif struct Wise2_SyExonScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SyExonScoreUnit ** exon; int len;/* len for above exon */ int maxlen; /* maxlen for above exon */ } ; /* SyExonScore defined */ #ifndef DYNAMITE_DEFINED_SyExonScore typedef struct Wise2_SyExonScore Wise2_SyExonScore; #define SyExonScore Wise2_SyExonScore #define DYNAMITE_DEFINED_SyExonScore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_SyExon(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SyExon *] * * Return [UNKN ] Undocumented return value [SyExon *] * */ SyExon * Wise2_hard_link_SyExon(SyExon * obj); #define hard_link_SyExon Wise2_hard_link_SyExon /* Function: SyExon_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SyExon *] * */ SyExon * Wise2_SyExon_alloc(void); #define SyExon_alloc Wise2_SyExon_alloc /* Function: free_SyExon(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SyExon *] * * Return [UNKN ] Undocumented return value [SyExon *] * */ SyExon * Wise2_free_SyExon(SyExon * obj); #define free_SyExon Wise2_free_SyExon /* Function: hard_link_SyExonScoreUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SyExonScoreUnit *] * * Return [UNKN ] Undocumented return value [SyExonScoreUnit *] * */ SyExonScoreUnit * Wise2_hard_link_SyExonScoreUnit(SyExonScoreUnit * obj); #define hard_link_SyExonScoreUnit Wise2_hard_link_SyExonScoreUnit /* Function: SyExonScoreUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SyExonScoreUnit *] * */ SyExonScoreUnit * Wise2_SyExonScoreUnit_alloc(void); #define SyExonScoreUnit_alloc Wise2_SyExonScoreUnit_alloc /* Function: free_SyExonScoreUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SyExonScoreUnit *] * * Return [UNKN ] Undocumented return value [SyExonScoreUnit *] * */ SyExonScoreUnit * Wise2_free_SyExonScoreUnit(SyExonScoreUnit * obj); #define free_SyExonScoreUnit Wise2_free_SyExonScoreUnit /* Function: add_SyExonModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SyExonModel *] * Arg: add [OWNER] Object to add to the list [SyExon *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SyExonModel(SyExonModel * obj,SyExon * add); #define add_SyExonModel Wise2_add_SyExonModel /* Function: flush_SyExonModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SyExonModel *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SyExonModel(SyExonModel * obj); #define flush_SyExonModel Wise2_flush_SyExonModel /* Function: SyExonModel_alloc_std(void) * * Descrip: Equivalent to SyExonModel_alloc_len(SyExonModelLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SyExonModel *] * */ SyExonModel * Wise2_SyExonModel_alloc_std(void); #define SyExonModel_alloc_std Wise2_SyExonModel_alloc_std /* Function: SyExonModel_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SyExonModel *] * */ SyExonModel * Wise2_SyExonModel_alloc_len(int len); #define SyExonModel_alloc_len Wise2_SyExonModel_alloc_len /* Function: hard_link_SyExonModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SyExonModel *] * * Return [UNKN ] Undocumented return value [SyExonModel *] * */ SyExonModel * Wise2_hard_link_SyExonModel(SyExonModel * obj); #define hard_link_SyExonModel Wise2_hard_link_SyExonModel /* Function: SyExonModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SyExonModel *] * */ SyExonModel * Wise2_SyExonModel_alloc(void); #define SyExonModel_alloc Wise2_SyExonModel_alloc /* Function: free_SyExonModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SyExonModel *] * * Return [UNKN ] Undocumented return value [SyExonModel *] * */ SyExonModel * Wise2_free_SyExonModel(SyExonModel * obj); #define free_SyExonModel Wise2_free_SyExonModel /* Function: add_SyExonScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SyExonScore *] * Arg: add [OWNER] Object to add to the list [SyExonScoreUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SyExonScore(SyExonScore * obj,SyExonScoreUnit * add); #define add_SyExonScore Wise2_add_SyExonScore /* Function: flush_SyExonScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SyExonScore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SyExonScore(SyExonScore * obj); #define flush_SyExonScore Wise2_flush_SyExonScore /* Function: SyExonScore_alloc_std(void) * * Descrip: Equivalent to SyExonScore_alloc_len(SyExonScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SyExonScore *] * */ SyExonScore * Wise2_SyExonScore_alloc_std(void); #define SyExonScore_alloc_std Wise2_SyExonScore_alloc_std /* Function: SyExonScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SyExonScore *] * */ SyExonScore * Wise2_SyExonScore_alloc_len(int len); #define SyExonScore_alloc_len Wise2_SyExonScore_alloc_len /* Function: hard_link_SyExonScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SyExonScore *] * * Return [UNKN ] Undocumented return value [SyExonScore *] * */ SyExonScore * Wise2_hard_link_SyExonScore(SyExonScore * obj); #define hard_link_SyExonScore Wise2_hard_link_SyExonScore /* Function: SyExonScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SyExonScore *] * */ SyExonScore * Wise2_SyExonScore_alloc(void); #define SyExonScore_alloc Wise2_SyExonScore_alloc /* Function: free_SyExonScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SyExonScore *] * * Return [UNKN ] Undocumented return value [SyExonScore *] * */ SyExonScore * Wise2_free_SyExonScore(SyExonScore * obj); #define free_SyExonScore Wise2_free_SyExonScore /* Unplaced functions */ /* There has been no indication of the use of these functions */ SyExonScore * Wise2_SyExonScore_flat_model(int start,int end,Probability exit,Probability final_stay); #define SyExonScore_flat_model Wise2_SyExonScore_flat_model SyExonModel * Wise2_SyExonModel_flat_model(int start,int end,Probability exit,Probability final_stay); #define SyExonModel_flat_model Wise2_SyExonModel_flat_model SyExonScore * Wise2_SyExonScore_from_SyExonModel(SyExonModel * sym); #define SyExonScore_from_SyExonModel Wise2_SyExonScore_from_SyExonModel SyExonScoreUnit * Wise2_SyExonScoreUnit_from_SyExon(SyExon * sye); #define SyExonScoreUnit_from_SyExon Wise2_SyExonScoreUnit_from_SyExon void Wise2_dump_SyExonScore(SyExonScore * sc,FILE *ofp); #define dump_SyExonScore Wise2_dump_SyExonScore /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_SyExonModel(SyExon ** list,int i,int j) ; #define swap_SyExonModel Wise2_swap_SyExonModel void Wise2_qsort_SyExonModel(SyExon ** list,int left,int right,int (*comp)(SyExon * ,SyExon * )); #define qsort_SyExonModel Wise2_qsort_SyExonModel void Wise2_sort_SyExonModel(SyExonModel * obj,int (*comp)(SyExon *, SyExon *)); #define sort_SyExonModel Wise2_sort_SyExonModel boolean Wise2_expand_SyExonModel(SyExonModel * obj,int len); #define expand_SyExonModel Wise2_expand_SyExonModel void Wise2_swap_SyExonScore(SyExonScoreUnit ** list,int i,int j) ; #define swap_SyExonScore Wise2_swap_SyExonScore void Wise2_qsort_SyExonScore(SyExonScoreUnit ** list,int left,int right,int (*comp)(SyExonScoreUnit * ,SyExonScoreUnit * )); #define qsort_SyExonScore Wise2_qsort_SyExonScore void Wise2_sort_SyExonScore(SyExonScore * obj,int (*comp)(SyExonScoreUnit *, SyExonScoreUnit *)); #define sort_SyExonScore Wise2_sort_SyExonScore boolean Wise2_expand_SyExonScore(SyExonScore * obj,int len); #define expand_SyExonScore Wise2_expand_SyExonScore #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/fivestatemodel.dy0000644000175000001440000004023207621664040017502 0ustar philippusers %{ #include "threestatemodel.h" enum fsm_trans_type { FSM_MATCH2MATCH = 0, FSM_MATCH2INSERT, FSM_MATCH2DELETE, FSM_MATCH2INBOUND, FSM_MATCH2OUTBOUND, FSM_INSERT2MATCH, FSM_INSERT2INSERT, FSM_INSERT2DELETE, FSM_INSERT2INBOUND, FSM_INSERT2OUTBOUND, FSM_DELETE2MATCH, FSM_DELETE2INSERT, FSM_DELETE2DELETE, FSM_DELETE2INBOUND, FSM_DELETE2OUTBOUND, FSM_START2MATCH, FSM_START2INSERT, FSM_START2DELETE, FSM_START2INBOUND, FSM_MATCH2END, FSM_INSERT2END, FSM_DELETE2END, FSM_INBOUND2MATCH, FSM_INBOUND2INSERT, FSM_INBOUND2DELETE, FSM_INBOUND2END, FSM_INBOUND2INBOUND, FSM_OUTBOUND2MATCH, FSM_OUTBOUND2INSERT, FSM_OUTBOUND2DELETE, FSM_OUTBOUND2OUTBOUND, FSM_OUTBOUND2INBOUND, FSM_OUTBOUND2END, FSM_TRANSITION_LENGTH }; #define FiveStateModelLISTLENGTH 128 #define FiveStateScoreLISTLENGTH 128 #define FiveStateFrameLISTLENGTH 32 #define FiveStateFrameSetLISTLENGTH 32 /* * Cheeky declaration to get around #include mess. */ ThreeStateModel * Wise2_HMMer2_read_ThreeStateModel(char * filename); %} struct FiveStateFrame ThreeStateModel ** stack !list struct FiveStateFrameSet FiveStateFrame ** set !list struct FiveStateUnit Probability match[ALPHABET_SIZE]; Probability insert[ALPHABET_SIZE]; Probability transition[FSM_TRANSITION_LENGTH]; char display_char; !def="'u'" struct FiveStateFrameIndicator ThreeStateModel * tsm int start int end struct FiveStateModel char * name // name of the model FiveStateUnit ** unit !list FiveStateFrameIndicator ** frame !list !len="tsm_" struct FiveStateScoreUnit Score match[ALPHABET_SIZE]; Score insert[ALPHABET_SIZE]; Score transition[FSM_TRANSITION_LENGTH]; char display_char; !def="'u'" struct FiveStateScore char * name // name of the model FiveStateScoreUnit ** unit !list %{ #include "fivestatemodel.h" void dump_FiveStateModel(FiveStateModel * five,FILE * ofp) { int i; assert(five); assert(ofp); for(i=0;ilen;i++) { fprintf(ofp,"Position %d %f %f\n",i,five->unit[i]->transition[FSM_OUTBOUND2INBOUND], five->unit[i]->transition[FSM_OUTBOUND2END]); } } void dump_FiveStateScore(FiveStateScore * five,FILE * ofp) { int i; assert(five); assert(ofp); for(i=0;ilen;i++) { fprintf(ofp,"Position %d %c %d %d %d %d\n",i,five->unit[i]->display_char,five->unit[i]->transition[FSM_OUTBOUND2INBOUND], five->unit[i]->transition[FSM_OUTBOUND2END],five->unit[i]->transition[FSM_INBOUND2MATCH],five->unit[i]->transition[FSM_MATCH2OUTBOUND]); } } FiveStateFrameSet * read_FiveStateFrameSet_file(char * context,char * block_str) { FiveStateFrameSet * out; char filename[MAXLINE]; FILE * ifp; assert(context); assert(block_str); sprintf(filename,"%s/%s",context,block_str); ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s as filename for block structure file",filename); return NULL; } out = read_FiveStateFrameSet(context,ifp); fclose(ifp); return out; } FiveStateFrameSet * read_FiveStateFrameSet(char * context,FILE * ifp) { char buffer[MAXLINE]; FiveStateFrameSet * out; FiveStateFrame * temp; ThreeStateModel * tsm; char * file; char filename[MAXLINE]; out = FiveStateFrameSet_alloc_std(); temp = FiveStateFrame_alloc_std(); add_FiveStateFrameSet(out,temp); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"//") == 0 ) { temp = FiveStateFrame_alloc_std(); add_FiveStateFrameSet(out,temp); } else { file = strtok(buffer,spacestr); sprintf(filename,"%s/%s",context,file); tsm = Wise2_HMMer2_read_ThreeStateModel(filename); if( tsm == NULL ) fatal("Could not read %s as a HMMer2 file - die horribly!",tsm); add_FiveStateFrame(temp,tsm); } } return out; } void blank_FiveStateUnit(FiveStateUnit * u) { int i; for(i=0;imatch[i] = 1.0; u->insert[i] = 1.0; } for(i=0;itransition[i] = 0.0; } } FiveStateModel * FiveStateModel_from_FiveStateFrameSet(FiveStateFrameSet * frame) { FiveStateModel * out; FiveStateUnit * u; int len; int max; int i,j,k,l; int f; FiveStateFrameIndicator * fsfi; ThreeStateModel * tsm; ThreeStateUnit * donor; len = 0; for(i=0;ilen;i++) { for(j=0;jset[i]->len;j++) { len += frame->set[i]->stack[j]->len; } } assert(len > 0); out = FiveStateModel_alloc_len(len); /* the first state is a dummy state to get probability to get to INBOUND */ u = FiveStateUnit_alloc(); blank_FiveStateUnit(u); u->display_char = '*'; u->transition[FSM_START2INBOUND] = 1.0; u->transition[FSM_INBOUND2MATCH] = 1.0/frame->set[0]->len; u->transition[FSM_INBOUND2INBOUND] = 1.0 - u->transition[FSM_INBOUND2MATCH]; fsfi = FiveStateFrameIndicator_alloc(); fsfi->start = 1; fsfi->tsm = hard_link_ThreeStateModel(frame->set[0]->stack[0]); add_tsm_FiveStateModel(out,fsfi); add_FiveStateModel(out,u); f = 0; for(i=0;ilen;i++) { for(j=0;jset[i]->len;j++) { for(k=0;kset[i]->stack[j]->len;k++){ u = FiveStateUnit_alloc(); blank_FiveStateUnit(u); if( fsfi->tsm == NULL ) { fsfi->tsm = hard_link_ThreeStateModel(frame->set[i]->stack[j]); } donor = frame->set[i]->stack[j]->unit[k]; for(l=0;lmatch[l] = donor->match_emission[l]; u->insert[l] = donor->insert_emission[l]; } u->display_char = donor->display_char; add_FiveStateModel(out,u); u->transition[FSM_START2MATCH] = 0.0; u->transition[FSM_START2INSERT] = 0.0; u->transition[FSM_START2DELETE] = 0.0; u->transition[FSM_MATCH2MATCH] = donor->transition[TSM_MATCH2MATCH]; u->transition[FSM_MATCH2INSERT] = donor->transition[TSM_MATCH2INSERT]; u->transition[FSM_MATCH2DELETE] = donor->transition[TSM_MATCH2DELETE]; u->transition[FSM_MATCH2END] = 0.0; u->transition[FSM_DELETE2MATCH] = donor->transition[TSM_DELETE2MATCH]; u->transition[FSM_DELETE2INSERT] = donor->transition[TSM_DELETE2INSERT]; u->transition[FSM_DELETE2DELETE] = donor->transition[TSM_DELETE2DELETE]; u->transition[FSM_DELETE2END] = 0.0; u->transition[FSM_INSERT2MATCH] = donor->transition[TSM_INSERT2MATCH]; u->transition[FSM_INSERT2INSERT] = donor->transition[TSM_INSERT2INSERT]; u->transition[FSM_INSERT2DELETE] = donor->transition[TSM_INSERT2DELETE]; u->transition[FSM_INSERT2END] = 0.0; /* by default, set inbound and outbound to transition on at 1.0 */ u->transition[FSM_OUTBOUND2OUTBOUND] = 1.0; u->transition[FSM_INBOUND2INBOUND] = 1.0; /* all the interesting stuff happens at the end of HMM */ if( k == frame->set[i]->stack[j]->len-1 ) { /* end of this stack. transition out to outbound */ u->transition[FSM_MATCH2OUTBOUND] = 1.0; /* set fsfi end point here */ fsfi->end = out->len; /* if this is also end of the stack, handle the switch from out to in */ if( j == frame->set[i]->len-1 ) { u->transition[FSM_INBOUND2INBOUND] = 0.0; if( i == frame->len-1 ) { u->transition[FSM_MATCH2END] = 1.0; } /* because Dynamite has to have an offset in the model, need one extra units to flip to inbound */ u = FiveStateUnit_alloc(); blank_FiveStateUnit(u); u->display_char = '*'; u->transition[FSM_OUTBOUND2INBOUND] = 1.0; add_FiveStateModel(out,u); u = FiveStateUnit_alloc(); blank_FiveStateUnit(u); u->display_char = '*'; /* if the end of the model */ if( i == frame->len-1 ) { u->transition[FSM_OUTBOUND2END] = 1.0; u->transition[FSM_INBOUND2END] = 1.0; } else { u->transition[FSM_INBOUND2MATCH] = 1.0/frame->set[i+1]->len; u->transition[FSM_INBOUND2INBOUND] = 1.0 - u->transition[FSM_INBOUND2MATCH]; } add_FiveStateModel(out,u); } else { /* the stack continues - adjust inbound to next point */ u->transition[FSM_INBOUND2MATCH] = 1.0 / frame->set[i]->len; u->transition[FSM_INBOUND2INBOUND] = 1.0 - u->transition[FSM_INBOUND2MATCH]; } /* allocate and add next fsfi */ fsfi = FiveStateFrameIndicator_alloc(); fsfi->start = out->len; add_tsm_FiveStateModel(out,fsfi); } } /* end of the component hmm */ } /* end of the stack */ } /* end of the frame */ return out; } void fold_RandomModel_into_FiveStateModel(FiveStateModel * fsm,RandomModel * rm) { register int i; register int j; assert(fsm); assert(rm); for(i=0;ilen;i++) { auto FiveStateUnit * tsu; tsu = fsm->unit[i]; for(j=0;j<26;j++) { if( rm->aminoacid[j] < 0.00000001 ) { warn("While trying to fold in random model, amino acid %d [%c] was below zero, ignoring",j,'A'+j); continue; } tsu->match[j] = tsu->match[j] / rm->aminoacid[j]; tsu->insert[j] = tsu->insert[j] / rm->aminoacid[j]; } } } FiveStateModel * FiveStateModel_from_flat_ThreeStateModel(ThreeStateModel * tsm) { FiveStateModel * out; FiveStateUnit * u; ThreeStateUnit * donor; int i,j; out = FiveStateModel_alloc_len(tsm->len); for(i=0;ilen;i++) { donor = tsm->unit[i]; u = FiveStateUnit_alloc(); for(j=0;jmatch[j] = donor->match_emission[j]; u->insert[j] = donor->insert_emission[j]; } u->transition[FSM_START2MATCH] = donor->transition[TSM_START2MATCH]; u->transition[FSM_START2INSERT] = donor->transition[TSM_START2INSERT]; u->transition[FSM_START2DELETE] = donor->transition[TSM_START2DELETE]; u->transition[FSM_MATCH2MATCH] = donor->transition[TSM_MATCH2MATCH]; u->transition[FSM_MATCH2INSERT] = donor->transition[TSM_MATCH2INSERT]; u->transition[FSM_MATCH2DELETE] = donor->transition[TSM_MATCH2DELETE]; u->transition[FSM_MATCH2END] = donor->transition[TSM_MATCH2END]; u->transition[FSM_DELETE2MATCH] = donor->transition[TSM_DELETE2MATCH]; u->transition[FSM_DELETE2INSERT] = donor->transition[TSM_DELETE2INSERT]; u->transition[FSM_DELETE2DELETE] = donor->transition[TSM_DELETE2DELETE]; u->transition[FSM_DELETE2END] = donor->transition[TSM_DELETE2END]; u->transition[FSM_INSERT2MATCH] = donor->transition[TSM_INSERT2MATCH]; u->transition[FSM_INSERT2INSERT] = donor->transition[TSM_INSERT2INSERT]; u->transition[FSM_INSERT2DELETE] = donor->transition[TSM_INSERT2DELETE]; u->transition[FSM_INSERT2END] = donor->transition[TSM_INSERT2END]; u->transition[FSM_MATCH2INBOUND] = 0.0; u->transition[FSM_DELETE2INBOUND] = 0.0; u->transition[FSM_INSERT2INBOUND] = 0.0; u->transition[FSM_MATCH2INBOUND] = 0.0; u->transition[FSM_DELETE2INBOUND] = 0.0; u->transition[FSM_INSERT2INBOUND] = 0.0; u->display_char = donor->display_char; add_FiveStateModel(out,u); } return out; } %func Makes a protein sequence out of the display characters. Not very useful! %% Protein * pseudo_Protein_from_FiveStateModel(FiveStateModel * tsm) { int i; Sequence * seq; seq = Sequence_alloc(); seq->name = stringalloc(tsm->name); seq->seq = ckcalloc(tsm->len+1,sizeof(char)); for(i=0;ilen;i++) { seq->seq[i] = tsm->unit[i]->display_char; } seq->seq[i]='\0'; make_len_type_Sequence(seq); seq->type = SEQUENCE_PROTEIN; return Protein_from_Sequence(seq); } FiveStateScore * FiveStateScore_from_FiveStateModel(FiveStateModel * fsm) { FiveStateScore * out; int i; out = FiveStateScore_alloc_len(fsm->len); add_FiveStateScore(out,FiveStateScoreUnit_from_FiveStateUnit(NULL,fsm->unit[0])); for(i=1;ilen;i++) { add_FiveStateScore(out,FiveStateScoreUnit_from_FiveStateUnit(fsm->unit[i-1],fsm->unit[i])); } return out; } FiveStateScoreUnit * FiveStateScoreUnit_from_FiveStateUnit(FiveStateUnit * prev,FiveStateUnit * u) { FiveStateScoreUnit * out; out = FiveStateScoreUnit_alloc(); Probability2Score_move(u->match,out->match,ALPHABET_SIZE); Probability2Score_move(u->insert,out->insert,ALPHABET_SIZE); out->display_char = u->display_char; if( prev != NULL ) { out->transition[FSM_MATCH2MATCH] = Probability2Score(prev->transition[FSM_MATCH2MATCH]); out->transition[FSM_INSERT2MATCH] = Probability2Score(prev->transition[FSM_INSERT2MATCH]); out->transition[FSM_DELETE2MATCH] = Probability2Score(prev->transition[FSM_DELETE2MATCH]); out->transition[FSM_INBOUND2MATCH] = Probability2Score(prev->transition[FSM_INBOUND2MATCH]); out->transition[FSM_OUTBOUND2MATCH] = Probability2Score(prev->transition[FSM_OUTBOUND2MATCH]); out->transition[FSM_MATCH2DELETE] = Probability2Score(prev->transition[FSM_MATCH2DELETE]); out->transition[FSM_INSERT2DELETE] = Probability2Score(prev->transition[FSM_INSERT2DELETE]); out->transition[FSM_DELETE2DELETE] = Probability2Score(prev->transition[FSM_DELETE2DELETE]); out->transition[FSM_INBOUND2DELETE] = Probability2Score(prev->transition[FSM_INBOUND2DELETE]); out->transition[FSM_OUTBOUND2DELETE] = Probability2Score(prev->transition[FSM_OUTBOUND2DELETE]); out->transition[FSM_MATCH2INBOUND] = Probability2Score(prev->transition[FSM_MATCH2INBOUND]); out->transition[FSM_INSERT2INBOUND] = Probability2Score(prev->transition[FSM_INSERT2INBOUND]); out->transition[FSM_DELETE2INBOUND] = Probability2Score(prev->transition[FSM_DELETE2INBOUND]); out->transition[FSM_INBOUND2INBOUND] = Probability2Score(prev->transition[FSM_INBOUND2INBOUND]); out->transition[FSM_OUTBOUND2INBOUND] = Probability2Score(prev->transition[FSM_OUTBOUND2INBOUND]); out->transition[FSM_MATCH2OUTBOUND] = Probability2Score(prev->transition[FSM_MATCH2OUTBOUND]); out->transition[FSM_INSERT2OUTBOUND] = Probability2Score(prev->transition[FSM_INSERT2OUTBOUND]); out->transition[FSM_DELETE2OUTBOUND] = Probability2Score(prev->transition[FSM_DELETE2OUTBOUND]); out->transition[FSM_OUTBOUND2OUTBOUND] = Probability2Score(prev->transition[FSM_OUTBOUND2OUTBOUND]); out->transition[FSM_INBOUND2END] = Probability2Score(prev->transition[FSM_INBOUND2END]); out->transition[FSM_OUTBOUND2END] = Probability2Score(prev->transition[FSM_OUTBOUND2END]); out->transition[FSM_OUTBOUND2INBOUND] = Probability2Score(prev->transition[FSM_OUTBOUND2INBOUND]); } else { out->transition[FSM_MATCH2MATCH] = NEGI; out->transition[FSM_INSERT2MATCH] = NEGI; out->transition[FSM_DELETE2MATCH] = NEGI; out->transition[FSM_INBOUND2MATCH] = NEGI; out->transition[FSM_OUTBOUND2MATCH] = NEGI; out->transition[FSM_MATCH2DELETE] = NEGI; out->transition[FSM_INSERT2DELETE] = NEGI; out->transition[FSM_DELETE2DELETE] = NEGI; out->transition[FSM_INBOUND2DELETE] = NEGI; out->transition[FSM_OUTBOUND2DELETE] = NEGI; out->transition[FSM_MATCH2INBOUND] = NEGI; out->transition[FSM_INSERT2INBOUND] = NEGI; out->transition[FSM_DELETE2INBOUND] = NEGI; out->transition[FSM_INBOUND2INBOUND] = NEGI; out->transition[FSM_MATCH2OUTBOUND] = NEGI; out->transition[FSM_INSERT2OUTBOUND] = NEGI; out->transition[FSM_DELETE2OUTBOUND] = NEGI; out->transition[FSM_OUTBOUND2OUTBOUND] = NEGI; out->transition[FSM_INBOUND2END] = NEGI; out->transition[FSM_OUTBOUND2END] = NEGI; out->transition[FSM_OUTBOUND2INBOUND] = NEGI; } out->transition[FSM_MATCH2INSERT] = Probability2Score(u->transition[FSM_MATCH2INSERT]); out->transition[FSM_INSERT2INSERT] = Probability2Score(u->transition[FSM_INSERT2INSERT]); out->transition[FSM_DELETE2INSERT] = Probability2Score(u->transition[FSM_DELETE2INSERT]); out->transition[FSM_INBOUND2INSERT] = Probability2Score(u->transition[FSM_INBOUND2INSERT]); out->transition[FSM_OUTBOUND2INSERT] = Probability2Score(u->transition[FSM_OUTBOUND2INSERT]); out->transition[FSM_START2MATCH] = Probability2Score(u->transition[FSM_START2MATCH]); out->transition[FSM_START2INSERT] = Probability2Score(u->transition[FSM_START2INSERT]); out->transition[FSM_START2DELETE] = Probability2Score(u->transition[FSM_START2DELETE]); out->transition[FSM_START2INBOUND] = Probability2Score(u->transition[FSM_START2INBOUND]); out->transition[FSM_MATCH2END] = Probability2Score(u->transition[FSM_MATCH2END]); out->transition[FSM_INSERT2END] = Probability2Score(u->transition[FSM_INSERT2END]); out->transition[FSM_DELETE2END] = Probability2Score(u->transition[FSM_DELETE2END]); return out; } %} wise-2.4.1/src/models/dnaalign.dy0000644000175000001440000001136607646753111016257 0ustar philippusers %{ #include "dyna.h" enum DnaStartEndEnum { DSE_GLOBAL_START = 0, DSE_GLOBAL_END, DSE_EDGE_START, DSE_EDGE_END, DSE_LOCAL_START, DSE_LOCAL_END, DSE_NUMBER }; %} struct DnaStartEnd int trans[DSE_NUMBER] // start/end points possibilities matrix DnaAlign query name="query" type="DNA" target name="target" type="DNA" resource name="comp" type="DNACOMPMAT" resource name="qgap" type="Score" resource name="qext" type="Score" resource name="tgap" type="Score" resource name="text" type="Score" resource name="startend" type="DnaStartEnd *" extern name="DSE_*" type="TRANS_TYPE" state MATCH offi="1" offj="1" calc="DNABASEMATCH(comp,DNA_BASE(query,i),DNA_BASE(target,j))" source MATCH calc="0" endsource source INSERT calc="0" endsource source DELETE calc="0" endsource source START calc="startend->trans[DSE_LOCAL_START]" endsource source START !left calc="startend->trans[DSE_EDGE_START]" endsource source START !top calc="startend->trans[DSE_EDGE_START]" endsource source START !top !left calc="startend->trans[DSE_GLOBAL_START]" endsource query_label SEQUENCE target_label SEQUENCE endstate state INSERT offi="0" offj="1" source MATCH calc="qgap" endsource source INSERT calc="qext" endsource query_label INSERT target_label SEQUENCE endstate state DELETE offi="1" offj="0" source MATCH calc="tgap" endsource source DELETE calc="text" endsource query_label SEQUENCE target_label INSERT endstate state START !special !start endstate state END !special !end source MATCH calc="startend->trans[DSE_LOCAL_END]" endsource source MATCH !bottom calc="startend->trans[DSE_EDGE_END]" endsource source MATCH !right calc="startend->trans[DSE_EDGE_END]" endsource source MATCH !right !bottom calc="startend->trans[DSE_GLOBAL_END]" endsource query_label END target_label END endstate endmatrix api object DnaStartEnd des free_DnaStartEnd endobject func make_align_dnaalign func DnaStartEnd_from_policy endapi %{ #include "dnaalign.h" %func Makes an alignment out of two DNA sequences %arg one r first sequence to align two r second sequence to align mat r DnaMatrix for the matching se r DnaStartEnd policy qgap r gap open penalty in query (one) coordinate qext r gap extension penalty in query (one) coordinate tgap r gap open penalty in target (two) coordinate text r gap extension penalty in target (two) coordinate dpri r DPRunImpl structure return an alb structure of the alignment %% AlnBlock * make_align_dnaalign(Sequence * one,Sequence * two,DnaMatrix * mat,DnaStartEnd * se,int qgap,int qext,int tgap,int text,DPRunImpl * dpri) { AlnBlock * alb; PackAln * pal; ComplexSequence * cone; ComplexSequence * ctwo; ComplexSequenceEvalSet * cses; if( one == NULL || two == NULL || mat == NULL || se == NULL ) { warn("Passed null objects into make_align_dnaalign... no!"); return NULL; } cses = default_dna_ComplexSequenceEvalSet(); assert(cses); cone = new_ComplexSequence(one,cses); ctwo = new_ComplexSequence(two,cses); assert(cone); assert(ctwo); assert(qgap <= 0 ); assert(qext <= 0 ); assert(tgap <= 0 ); assert(text <= 0 ); pal = PackAln_bestmemory_DnaAlign(cone,ctwo,mat,qgap,qext,tgap,text,se,NULL,dpri); alb = convert_PackAln_to_AlnBlock_DnaAlign(pal); free_ComplexSequence(cone); free_ComplexSequence(ctwo); free_ComplexSequenceEvalSet(cses); return alb; } %func Makes a DnaStartEnd from a particular string. Possible strings are: local - fully local global - fully global edge - aligns only to edges %% DnaStartEnd * DnaStartEnd_from_policy(char * policy) { int t; DnaStartEnd * out; t = get_number_from_slashed_string(policy,"local/global/edge"); if( t == -1 ) { warn("Policy %s is not a valid policy!",policy); return NULL; } out = DnaStartEnd_alloc(); switch (t) { case 0 : out->trans[DSE_GLOBAL_START] = NEGI; out->trans[DSE_GLOBAL_END] = NEGI; out->trans[DSE_LOCAL_START] = 0; out->trans[DSE_LOCAL_END] = 0; out->trans[DSE_EDGE_START] = NEGI; out->trans[DSE_EDGE_END] = NEGI; break; case 1: out->trans[DSE_GLOBAL_START] = 0; out->trans[DSE_GLOBAL_END] = 0; out->trans[DSE_LOCAL_START] = NEGI; out->trans[DSE_LOCAL_END] = NEGI; out->trans[DSE_EDGE_START] = NEGI; out->trans[DSE_EDGE_END] = NEGI; break; case 2: out->trans[DSE_GLOBAL_START] = NEGI; out->trans[DSE_GLOBAL_END] = NEGI; out->trans[DSE_LOCAL_START] = NEGI; out->trans[DSE_LOCAL_END] = NEGI; out->trans[DSE_EDGE_START] = 0; out->trans[DSE_EDGE_END] = 0; break; } return out; } wise-2.4.1/src/models/dnaalign.xs0000644000175000001440000000206010670453713016260 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::DnaStartEnd Wise2_DnaStartEnd * hard_link_DnaStartEnd(obj) Wise2_DnaStartEnd * obj CODE: RETVAL = Wise2_hard_link_DnaStartEnd(obj); OUTPUT: RETVAL Wise2_DnaStartEnd * alloc() CODE: RETVAL = Wise2_DnaStartEnd_alloc(); OUTPUT: RETVAL Wise2_DnaStartEnd * new(class) char * class PPCODE: Wise2_DnaStartEnd * out; out = Wise2_DnaStartEnd_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_DnaStartEnd * obj CODE: Wise2_free_DnaStartEnd(obj); MODULE = Wise2 PACKAGE = Wise2 Wise2_AlnBlock * make_align_dnaalign(one,two,mat,se,qgap,qext,tgap,text,dpri) Wise2_Sequence * one Wise2_Sequence * two Wise2_DnaMatrix * mat Wise2_DnaStartEnd * se int qgap int qext int tgap int text Wise2_DPRunImpl * dpri CODE: RETVAL = Wise2_make_align_dnaalign(one,two,mat,se,qgap,qext,tgap,text,dpri); OUTPUT: RETVAL Wise2_DnaStartEnd * DnaStartEnd_from_policy(policy) char * policy CODE: RETVAL = Wise2_DnaStartEnd_from_policy(policy); OUTPUT: RETVAL wise-2.4.1/src/models/genefrequency.dy0000644000175000001440000005144107344153573017341 0ustar philippusers/* Last edited: Apr 22 17:49 1997 (birney) */ %{ #include "probability.h" #include "codon.h" #include "wisebase.h" #include "dyna.h" #include "randommodel.h" enum { GF21_CENTRAL_STAY, GF21_PY_STAY, GF21_SPACER_STAY, GF21_NO_SPACER, GF21_INTRON_CORR_TERM, GENEFREQUENCY21_TRANSITION_LEN }; #define GeneConsensusLISTLENGTH 128 enum { GeneConsensusType_5SS = 131, GeneConsensusType_3SS, GeneConsensusType_CDS, GeneConsensusType_Intron_Corr_Term, GeneConsensusType_Intron_emission, GeneConsensusType_Pyrimidine_emission, GeneConsensusType_Spacer_emission, GeneConsensusType_Central_stay, GeneConsensusType_Pyrimidine_stay, GeneConsensusType_Spacer_stay, GeneConsensusType_No_spacer, GeneConsensusType_Error }; %} struct GeneSingleCons char * string double number struct GeneConsensus int center GeneSingleCons ** gsc !list struct GeneFrequency21 GeneConsensus * ss5 GeneConsensus * ss3 double codon[64] double central[4] double py[4] double spacer[4] double transition[GENEFREQUENCY21_TRANSITION_LEN] double cds_triplet[64] // phase 0 api object GeneFrequency21 des free_GeneFrequency21 endobject object GeneConsensus des free_GeneConsensus endobject object GeneSingleCons des free_GeneSingleCons endobject func read_GeneFrequency21_file func read_GeneFrequency21 endapi %{ #include "genefrequency.h" %func makes a randomcodon probability emission from the counts in genefrequency %% RandomCodon * RandomCodon_from_cds_triplet(GeneFrequency21 * gf) { int i; int a,b,c; double total; double lit; RandomCodon * out; out = RandomCodon_alloc(); for(i=0,total=0;i<64;i++) total += gf->cds_triplet[i]; for(i=0;i<125;i++) { if( has_random_bases(i) ) { lit = 0.0; for(a=0;a<4;a++) for(b=0;b<4;b++) for(c=0;c<4;c++) lit += gf->cds_triplet[base4_codon_from_codon(permute_possible_random_bases(i,a,b,c))]; out->codon[i] = lit/(64*total); } else { out->codon[i] = gf->cds_triplet[base4_codon_from_codon(i)]/(total); } } return out; } %func Makes a random model from the central gene model of an intron. Ideal for tieing intron state distribution to the randommodel %% RandomModelDNA * RandomModelDNA_from_central_GeneFrequency21(GeneFrequency21 * gf) { RandomModelDNA * out; double total; total = sum_Probability_array(gf->central,4); out = RandomModelDNA_alloc(); out->base[BASE_A] = gf->central[BASE_A]/total; out->base[BASE_T] = gf->central[BASE_T]/total; out->base[BASE_G] = gf->central[BASE_G]/total; out->base[BASE_C] = gf->central[BASE_C]/total; out->base[BASE_N] = 1.0; return out; } %func makes 5'SS ComplexConsensi from GeneFrequency21 structure using CCC|XXXXXXX score = no(5'SS with CCC|XXXXXXX) / no(CCC in cds). %% ComplexConsensi * ComplexConsensi_5SS_from_GeneFrequency(GeneFrequency21 * gf) { register int i; double nocds; ComplexConsensi * out; out = ComplexConsensi_alloc_len(gf->ss5->len); for(i=0;iss5->len;i++) { nocds = nocds_from_ambiguous_codon(gf->ss5->gsc[i]->string,gf->cds_triplet); if( nocds < 20 ) { warn("In making 5'SS consensi, got %g cds for codon %s ... not happy about this",nocds,gf->ss5->gsc[i]->string); } add_ComplexConsensi(out,ComplexConsensusWord_from_string_and_prob(gf->ss5->gsc[i]->string,gf->ss5->gsc[i]->number / nocds)); } return out; } %func makes 3'SS ComplexConsensi from GeneFrequency21 structure using ZZZ|CCC score = no(3'SS with ZZZ|CCC) / no(CCC in cds). %% ComplexConsensi * ComplexConsensi_3SS_from_GeneFrequency(GeneFrequency21 * gf) { register int i; double nocds; ComplexConsensi * out; out = ComplexConsensi_alloc_len(gf->ss3->len); for(i=0;iss3->len;i++) { nocds = nocds_from_ambiguous_codon(gf->ss3->gsc[i]->string+3,gf->cds_triplet); if( nocds < 20 ) { warn("In making 3'SS consensi, got %g cds for codon %s ... not happy about this!",nocds,gf->ss3->gsc[i]->string); } add_ComplexConsensi(out,ComplexConsensusWord_from_string_and_prob(gf->ss3->gsc[i]->string,gf->ss3->gsc[i]->number / nocds)); } return out; } %func helper function for above guys %type internal %% double nocds_from_ambiguous_codon(char * codon,double * codon_freq_array) { int factor = 1; int one; int two; int three; int i,j,k; double ret = 0.0; one = base_from_char(*codon == '-' ? 'N' : *codon); two = base_from_char(*(codon+1) == '-' ? 'N' : *(codon+1)); three = base_from_char(*(codon+2) == '-' ? 'N' : *(codon+2)); if(one == BASE_N) factor *= 4; if(two == BASE_N) factor *= 4; if(three == BASE_N) factor *= 4; for(i=0;i<4;i++) for(j=0;j<4;j++) for(k=0;k<4;k++) if( (one == i || one == BASE_N) && (two == j || two == BASE_N) && (three == k || three == BASE_N)) { ret += codon_freq_array[i*16+j*4+k]; } ret = ret / factor; if( ret < 0.0000000000000001 ) { warn("For codon %c%c%c we have a frequency of %g",*codon,*(codon+1),*(codon+2),ret); ret = 0.0000000000000001; } return ret; } %func convienent constructor %type internal %% ComplexConsensusWord * ComplexConsensusWord_from_string_and_prob(char * string,Probability p) { ComplexConsensusWord * out; out = ComplexConsensusWord_alloc(); out->pattern = stringalloc(string); out->p = p; out->score = Probability2Score(p); return out; } %func Builds a codon frequency table from raw counts in the counts file %% CodonFrequency * CodonFrequency_from_GeneFrequency21(GeneFrequency21 * gf,CodonTable * ct) { return CodonFrequence_from_raw_counts(gf->codon,ct); } %func For debugging %type internal %% void show_flat_GeneFrequency21(GeneFrequency21 * gf21,FILE * ofp) { if( gf21->ss5 != NULL ) { fprintf(ofp,"5'SS\n"); show_GeneConsensus(gf21->ss5,ofp); } if( gf21->ss3 != NULL ) { fprintf(ofp,"3'SS\n"); show_GeneConsensus(gf21->ss3,ofp); } fprintf(ofp,"Codon frequency\n"); show_codon_emission(gf21->codon,ofp); fprintf(ofp,"Central emission\n"); show_base_emission(gf21->central,ofp); fprintf(ofp,"Pyrimidine emission\n"); show_base_emission(gf21->py,ofp); fprintf(ofp,"Spacer emission\n"); show_base_emission(gf21->spacer,ofp); fprintf(ofp,"Transitions\n"); show_Probability_array(gf21->transition,GENEFREQUENCY21_TRANSITION_LEN,ofp); fprintf(ofp,"\n\n"); } %func For debugging %type internal %% void show_codon_emission(double * codon,FILE * ofp) { register int i; fprintf(ofp,"begin consensus\n"); for(i=0;i<64;i++) show_single_codon_emission(codon[i],i,ofp); fprintf(ofp,"end consensus\n"); } %func For debugging %type internal %% void show_single_codon_emission(double no,int base4codon,FILE * ofp) { codon c; base one; base two; base three; c = codon_from_base4_codon(base4codon); all_bases_from_codon(c,&one,&two,&three); fprintf(ofp,"%c%c%c %.2f\n",char_from_base(one),char_from_base(two),char_from_base(three),no); } %func For debugging %type internal %% void show_base_emission(double * base,FILE * ofp) { register int i; fprintf(ofp,"begin consensus\n"); for(i=0;i<4;i++) fprintf(ofp,"%c %.2f\n",char_from_base(i),base[i]); fprintf(ofp,"end consensus\n"); } %func For debugging %type internal %% void show_GeneConsensus(GeneConsensus * gc,FILE * ofp) { register int i; fprintf(ofp,"begin consensus\n"); for(i=0;ilen;i++) show_GeneSingleCons(gc->gsc[i],ofp); fprintf(ofp,"end consensus\n"); } %func For debugging %type internal %% void show_GeneSingleCons(GeneSingleCons * gsc,FILE * ofp) { fprintf(ofp,"%s %f\n",gsc->string,gsc->number); } /*** reading in ***/ %func Opens the file with /openfile Reads in a GeneFrequency (Mor-Ewan style) %arg filename will open from WISECONFIGDIR etc via openfile return a newly allocated structure %% GeneFrequency21 * read_GeneFrequency21_file(char * filename) { GeneFrequency21 * out; FILE * ifp; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s as a genefrequency file",filename); return NULL; } out = read_GeneFrequency21(ifp); fclose(ifp); return out; } %func Reads in a GeneFrequency (Mor-Ewan style) file from ifp %arg ifp file pointer return a newly allocated structure %% GeneFrequency21 * read_GeneFrequency21(FILE * ifp) { GeneFrequency21 * out; GeneConsensus * temp; char buffer[MAXLINE]; int phase; int center; int type; boolean err = FALSE; out = GeneFrequency21_alloc(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '#' ) continue; if( strwhitestartcmp(buffer,"type",spacestr) == 0 ) { phase = 3; /** if no phase, assumme it is for all phases **/ type = check_type_GeneFrequency(buffer,ifp,¢er,&phase); switch(type) { case GeneConsensusType_5SS : if( phase == 3) { temp = read_line_GeneConsensus(buffer,ifp); temp->center = center; out->ss5 = temp; } else { if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd 5'SS information ... problem!"); break; } } break; case GeneConsensusType_3SS : if( phase == 3) { temp = read_line_GeneConsensus(buffer,ifp); temp->center = center; out->ss3 = temp; } else { if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd 5'SS information ... problem!"); err = TRUE; } } break; case GeneConsensusType_CDS : if( phase == 0) { if( read_codon_GeneConsensus(out->codon,buffer,ifp) == FALSE ) { warn("Unable to read codon information in GeneFrequency21... problem!"); break; } } else if( phase == 3 ) { /*** we need this! ***/ if( read_codon_GeneConsensus(out->cds_triplet,buffer,ifp) == FALSE ) { warn("Unable to read codon information in GeneFrequency21... problem!"); break; } } else { /** in a different phase **/ if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd CDS information ... problem!"); err = TRUE; } } break; case GeneConsensusType_Intron_emission : if( phase == 3 ) { if( read_base_GeneConsensus(out->central,buffer,ifp) == FALSE ) { warn("Unable to read Intron emissions in genefrequency21 ... problem!"); err = TRUE; } } else { if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd CDS information ... problem!"); err = TRUE; } } break; case GeneConsensusType_Pyrimidine_emission : if( phase == 3 ) { if( read_base_GeneConsensus(out->py,buffer,ifp) == FALSE ) { warn("Unable to read pyrimidine emissions in genefrequency21 ... problem!"); err = TRUE; } } else { if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd pyrimidine information ... problem!"); err = TRUE; } } break; case GeneConsensusType_Spacer_emission : if( phase == 3 ) { if( read_base_GeneConsensus(out->spacer,buffer,ifp) == FALSE ) { warn("Unable to read spacer emissions in genefrequency21 ... problem!"); err = TRUE; } } else { if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd spacer information ... problem!"); err = TRUE; } } break; case GeneConsensusType_Central_stay : out->transition[GF21_CENTRAL_STAY] = double_from_line(buffer); break; case GeneConsensusType_Pyrimidine_stay : out->transition[GF21_PY_STAY] = double_from_line(buffer); break; case GeneConsensusType_Spacer_stay : out->transition[GF21_SPACER_STAY] = double_from_line(buffer); break; case GeneConsensusType_No_spacer : out->transition[GF21_NO_SPACER] = double_from_line(buffer); break; case GeneConsensusType_Intron_Corr_Term : switch(phase) { case 0 : /* out->transition[GF21_INTRON_CORR_TERM_0] = double_from_line(buffer); */ break; case 1 : /* out->transition[GF21_INTRON_CORR_TERM_1] = double_from_line(buffer); */ break; case 2 : /* out->transition[GF21_INTRON_CORR_TERM_2] = double_from_line(buffer); */ break; case 3 : out->transition[GF21_INTRON_CORR_TERM] = double_from_line(buffer); break; default : warn("Well... I have got some bad news for you. We found a phase of %d in Intron correction term. ",phase); break; } break; default : warn("Got an unidenitifable type in GeneFrequency21 parse. Skippping"); if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd 5'SS information ... problem!"); err = TRUE; } } if( err == TRUE ) { warn("You have had an unrecoverable error in GeneFrequency21 parsing"); break; } } else { striptoprint(buffer); warn("Could not understand line [%s] in GeneFrequency21 parse",buffer); } } return out; } %func helper string function %% double double_from_line(char * buffer) { char * runner; char * end; double ret; runner = strtok(buffer,spacestr); if( runner == NULL ) { warn("Unable to read a number in double_from_line"); return -1.0; } ret = strtod(runner,&end); if( end == runner || isalnum((int)*end) ) { warn("Bad conversion of string [%s] to double [%f] occured",runner,ret); } return ret; } %func helper function for teh file parsing %type internal %% boolean skip_consensus(FILE * ifp) { char buffer[MAXLINE]; while(fgets(buffer,MAXLINE,ifp) != NULL ) if( strwhitestartcmp(buffer,"end",spacestr) == 0) break; if( feof(ifp) || ferror(ifp) ) return FALSE; return TRUE; } %func Pretty sneaky function give line starting with "type xxx" ifp file pointer centre a &int for returning the centre value of the consensus if any. phase a &int for returning the phase value of the consensus if any. you get *back* the line with the line "begin consensus" or "number" in it. It returns a GeneConsensusType with GeneConsensusType_Error on error %% int check_type_GeneFrequency(char *line,FILE * ifp,int * center,int * phase) { int ret = GeneConsensusType_Error; char * runner; if( strwhitestartcmp(line,"type",spacestr) != 0 ) { warn("Attempting to check phase of consensus with no type line..."); return GeneConsensusType_Error; } runner = strtok(line,spacestr); runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("GeneFrequency type with no type. Can't read type, must set to error, but problem in later parsing"); ret = GeneConsensusType_Error; } else { ret = string_to_GeneConsensusType(runner); } while( fgets(line,MAXLINE,ifp) != NULL ) { if( line[0] == '#' ) continue; else if( strwhitestartcmp(line,"phase",spacestr) == 0 ) { runner = strtok(line,spacestr); runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("Got phase line with no phase. Sad...."); continue; } if( phase != NULL ) { if( strcmp(runner,"all") ==0 || strcmp(runner,"All") == 0) *phase = 3; else *phase = atoi(runner); } } else if( strwhitestartcmp(line,"center",spacestr) == 0 || strwhitestartcmp(line,"centre",spacestr) == 0) { runner = strtok(line,spacestr); runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("Got center line with no phase. Sad...."); continue; } if( center != NULL ) { *center = atoi(runner); } } else { break; } } return ret; } %func flips string 5SS to enum type %type internal %% int string_to_GeneConsensusType(char * string) { if( strcmp(string,"5SS") == 0 ) return GeneConsensusType_5SS; else if( strcmp(string,"3SS") == 0 ) return GeneConsensusType_3SS; else if( strcmp(string,"CDS") == 0 ) return GeneConsensusType_CDS; else if( strcmp(string,"Intron_Corr_Term") == 0 ) return GeneConsensusType_Intron_Corr_Term; else if( strcmp(string,"Intron_emission") == 0 ) return GeneConsensusType_Intron_emission; else if( strcmp(string,"Pyrimidine_emission") == 0 ) return GeneConsensusType_Pyrimidine_emission; else if( strcmp(string,"Spacer_emission") == 0 ) return GeneConsensusType_Spacer_emission; else if( strcmp(string,"Central_Intron_Stay_Prob") == 0 ) return GeneConsensusType_Central_stay; else if( strcmp(string,"Pyrimidine_Stay_Prob") == 0 ) return GeneConsensusType_Pyrimidine_stay; else if( strcmp(string,"Spacer_Stay_Prob") == 0 ) return GeneConsensusType_Spacer_stay; else if( strcmp(string,"No_Spacer_Prob") == 0 ) return GeneConsensusType_No_spacer; else { warn("Could convert string [%s] into a gene frequency type",string); return GeneConsensusType_Error; } } %func assummes base_array is 4 positions long line should have begin consensus on it and be of MAXLINE length as it will be used as the buffer. This does **not** check that you have filled up all 4 positions. %% boolean read_base_GeneConsensus(double * base_array,char* line,FILE * ifp) { boolean ret = TRUE; int b; char * base; char * number; if( strwhitestartcmp(line,"begin",spacestr) != 0 || strstr(line,"consensus") == NULL ) { warn("In reading base GeneConsensus line, got no 'begin consensus' tag [%s]",line); return FALSE; } while( fgets(line,MAXLINE,ifp) != NULL ) { if( line[0] == '#' ) continue; if( strwhitestartcmp(line,"end",spacestr) == 0 ) break; base = strtok(line,spacestr); number = strtok(NULL,spacestr); if( base == NULL ) { warn("Found an uncommented line in base consensus with no leading base word"); continue; } if( number == NULL ) { warn("For base %s, no number found",base); ret = FALSE; continue; } if( strlen(base) > 1 || (b=base_from_char(*base)) == BASE_N ) { warn("Could not interpret %s as an actual DNA base in read_base_GeneConsensus"); ret = FALSE; continue; } base_array[b]= atof(number); } return ret; } %func assummes codon_array is 64 positions long line should have begin consensus on it and be of MAXLINE length as it will be used as the buffer. This does **not** check that you have filled up all 64 positions. %% boolean read_codon_GeneConsensus(double * codon_array,char* line,FILE * ifp) { boolean ret = TRUE; char * codon; char * number; if( strwhitestartcmp(line,"begin",spacestr) != 0 || strstr(line,"consensus") == NULL ) { warn("In reading codon GeneConsensus line, got no 'begin consensus' tag [%s]",line); return FALSE; } while( fgets(line,MAXLINE,ifp) != NULL ) { if( line[0] == '#' ) continue; if( strwhitestartcmp(line,"end",spacestr) == 0 ) break; codon = strtok(line,spacestr); number = strtok(NULL,spacestr); if( codon == NULL ) { warn("Found an uncommented line in codon consensus with no leading codon word"); continue; } if( number == NULL ) { warn("For codon %s, no number found",codon); ret = FALSE; continue; } if( strchr(codon,'N') != NULL ) continue; if( is_non_ambiguous_codon_seq(codon) == FALSE ) { warn("Codon %s is not really a codon... problem!"); ret = FALSE; continue; } codon_array[base4_codon_from_seq(codon)]= atof(number); } return ret; } %func Reads a single GeneConsensus from a file %% GeneConsensus * read_line_GeneConsensus(char * line,FILE * ifp) { GeneConsensus * out; GeneSingleCons * temp; char buffer[MAXLINE]; char * runner; if( strwhitestartcmp(line,"begin",spacestr) != 0 ) { warn("Attempting to read a GeneConsensus structure with a line not starting with 'begin' [%s]",line); return NULL; } runner = strtok(line,spacestr); runner = strtok(NULL,spacestr); if( runner == NULL || strcmp(runner,"consensus") != 0 ) { warn("Attempting to read a GeneConsensus structure without a 'begin consensus' tag [%s]",line); return NULL; } out = GeneConsensus_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '#' ) continue; if( strwhitestartcmp(buffer,"end",spacestr) == 0 ) break; temp = read_line_GeneSingleCons(buffer); if( temp == NULL ) { warn("Unable to process GeneSingleCons line... dropping out..."); break; } add_GeneConsensus(out,temp); } return out; } GeneSingleCons * read_line_GeneSingleCons(char * line) { GeneSingleCons * out; char * runner; char * run2; runner = strtok(line,spacestr); run2 = strtok(NULL,spacestr); if( runner == NULL || run2 == NULL ) { warn("In read_line_GeneSingleCons was not give two different words in line [%s]",line); return NULL; } out = GeneSingleCons_alloc(); out->string = stringalloc(runner); out->number = strtod(run2,&runner); if( runner == run2 || *runner != '\0' ) { warn("In read_line_GeneSingleCons, for string [%s], unable to convert the number [%s]",out->string,run2); } return out; } GeneFrequency21 * untouched_GeneFrequency21(void) { register int i; GeneFrequency21 * out; out = GeneFrequency21_alloc(); for(i=0;i<64;i++) out->codon[i] = (-1); for(i=0;i<4;i++) out->central[i] = out->py[i] = out->spacer[i] = (-1); for(i=0;itransition[i] = (-1.0); return out; } %} wise-2.4.1/src/models/genefrequency.xs0000644000175000001440000001136610670453714017355 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::GeneFrequency21 Wise2_GeneFrequency21 * hard_link_GeneFrequency21(obj) Wise2_GeneFrequency21 * obj CODE: RETVAL = Wise2_hard_link_GeneFrequency21(obj); OUTPUT: RETVAL Wise2_GeneFrequency21 * alloc() CODE: RETVAL = Wise2_GeneFrequency21_alloc(); OUTPUT: RETVAL boolean set_ss5(obj,ss5) Wise2_GeneFrequency21 * obj Wise2_GeneConsensus * ss5 CODE: RETVAL = Wise2_replace_ss5_GeneFrequency21(obj,Wise2_hard_link_GeneConsensus(ss5)); OUTPUT: RETVAL Wise2_GeneConsensus * ss5(obj) Wise2_GeneFrequency21 * obj INIT: Wise2_GeneConsensus * temp; CODE: temp = Wise2_hard_link_GeneConsensus(Wise2_access_ss5_GeneFrequency21(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_ss3(obj,ss3) Wise2_GeneFrequency21 * obj Wise2_GeneConsensus * ss3 CODE: RETVAL = Wise2_replace_ss3_GeneFrequency21(obj,Wise2_hard_link_GeneConsensus(ss3)); OUTPUT: RETVAL Wise2_GeneConsensus * ss3(obj) Wise2_GeneFrequency21 * obj INIT: Wise2_GeneConsensus * temp; CODE: temp = Wise2_hard_link_GeneConsensus(Wise2_access_ss3_GeneFrequency21(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_GeneFrequency21 * new(class) char * class PPCODE: Wise2_GeneFrequency21 * out; out = Wise2_GeneFrequency21_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_GeneFrequency21 * obj CODE: Wise2_free_GeneFrequency21(obj); MODULE = Wise2 PACKAGE = Wise2::GeneConsensus Wise2_GeneConsensus * hard_link_GeneConsensus(obj) Wise2_GeneConsensus * obj CODE: RETVAL = Wise2_hard_link_GeneConsensus(obj); OUTPUT: RETVAL Wise2_GeneConsensus * GeneConsensus_alloc_std() CODE: RETVAL = Wise2_GeneConsensus_alloc_std(); OUTPUT: RETVAL boolean set_center(obj,center) Wise2_GeneConsensus * obj int center CODE: RETVAL = Wise2_replace_center_GeneConsensus(obj,center); OUTPUT: RETVAL int center(obj) Wise2_GeneConsensus * obj CODE: RETVAL = Wise2_access_center_GeneConsensus(obj); OUTPUT: RETVAL Wise2_GeneSingleCons * gsc(obj,i) Wise2_GeneConsensus * obj int i INIT: Wise2_GeneSingleCons * temp; CODE: temp = Wise2_hard_link_GeneSingleCons(Wise2_access_gsc_GeneConsensus(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_gsc(obj) Wise2_GeneConsensus * obj CODE: RETVAL = Wise2_length_gsc_GeneConsensus(obj); OUTPUT: RETVAL int flush_gsc(obj) Wise2_GeneConsensus * obj CODE: RETVAL = Wise2_flush_GeneConsensus(obj); OUTPUT: RETVAL boolean add_gsc(obj,add) Wise2_GeneConsensus * obj Wise2_GeneSingleCons * add CODE: RETVAL = Wise2_add_GeneConsensus(obj,Wise2_hard_link_GeneSingleCons(add)); OUTPUT: RETVAL Wise2_GeneConsensus * new(class) char * class PPCODE: Wise2_GeneConsensus * out; out = Wise2_GeneConsensus_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_GeneConsensus * obj CODE: Wise2_free_GeneConsensus(obj); void each_gsc(obj) Wise2_GeneConsensus * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_gsc_GeneConsensus(obj); for(i=0;igwdb,return_status); if( gws != NULL ) { return GeneWiseScoreFlat_from_GeneWiseScore(gws); } } %func Reloads a genewisequick database %% GeneWiseScoreFlat * reload_GeneWiseQuickDB(GeneWiseScoreFlat * prev,GeneWiseQuickDB * gdb,int * return_status) { GeneWiseScore * gws; if( prev != NULL ) free_GeneWiseScoreFlat(prev); gws = reload_GeneWiseDB(NULL,gdb->gwdb,return_status); if( gws != NULL ) { return GeneWiseScoreFlat_from_GeneWiseScore(gws); } } %func closes a GeneWiseDB %% boolean close_GeneWiseQuickDB(GeneWiseScoreFlat * gws,GeneWiseQuickDB * gdb) { if( gws != NULL ) free_GeneWiseScoreFlat(gws); return close_GeneWiseDB(NULL,gdb->gwdb); } %func adds dataentry stuff to a query. %% boolean dataentry_add_GeneWiseQuickDB(DataEntry * de,GeneWiseScoreFlat * gws,GeneWiseQuickDB * gdb) { return dataentry_add_GeneWiseDB(de,NULL,gdb->gwdb); } %func Makes a new genewisequickdb from a genewisemodeldb %arg gwdb r genewisedb - hard links as it enters %% GeneWiseQuickDB * GeneWiseQuickDB_from_GeneWiseDB(GeneWiseDB * gwdb) { GeneWiseQuickDB * out; out = GeneWiseQuickDB_alloc(); out->gwdb = hard_link_GeneWiseDB(gwdb); return out; } wise-2.4.1/src/models/geneparameter.pod0000644000175000001440000000343510670453714017462 0ustar philippusers=head1 NAME geneparameter module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item GeneParameter21 =back =head1 DESCRIPTION =head2 Object GeneParameter21 =over =item gp Type [GeneParser21 *] Scalar No documentation =item cm Type [CodonMapper *] Scalar No documentation =item cses Type [ComplexSequenceEvalSet *] Scalar No documentation =item ss Type [SpliceSiteModel **] List held only to be free'd when GeneParser21Set is free'd =item rc Type [RandomCodon *] Scalar needed to soak up the odd-and-sods of genes =item gwcm Type [GeneWiseCodonModel *] Scalar No documentation =item ct Type [CodonTable *] Scalar No documentation =item modelled_splice Type [boolean] Scalar so we can alter balance scores. =item gms Type [GeneModel *] Scalar No documentation =back GeneParameter21 keeps all the parameters for genewise algorithms in one tidy unit. This is also the switch between the old (compugen handled) and new statistics. This object can be made from either the old or the new statistics I have made the object complete opaque to scripting apis because the contents have to be coordinated quite well =head2 Member functions of GeneParameter21 =over =item hard_link_GeneParameter21 &Wise2::GeneParameter21::hard_link_GeneParameter21(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [GeneParameter21 *] Return [UNKN ] Undocumented return value [GeneParameter21 *] =item GeneParameter21_alloc_std &Wise2::GeneParameter21::GeneParameter21_alloc_std(void) Equivalent to GeneParameter21_alloc_len(GeneParameter21LISTLENGTH) Return [UNKN ] Undocumented return value [GeneParameter21 *] =back wise-2.4.1/src/models/geneparameter.tex0000644000175000001440000000262310670453714017476 0ustar philippusers\section{geneparameter} \label{module_geneparameter} This module contains the following objects \begin{itemize} \item \ref{object_GeneParameter21} GeneParameter21 \end{itemize} \subsection{Object GeneParameter21} \label{object_GeneParameter21} The GeneParameter21 object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{gp} Type [GeneParser21 * : Scalar] No documentation \item{cm} Type [CodonMapper * : Scalar] No documentation \item{cses} Type [ComplexSequenceEvalSet * : Scalar] No documentation \item{ss} Type [SpliceSiteModel ** : List] held only to be free'd when GeneParser21Set is free'd \item{rc} Type [RandomCodon * : Scalar] needed to soak up the odd-and-sods of genes \item{gwcm} Type [GeneWiseCodonModel * : Scalar] No documentation \item{ct} Type [CodonTable * : Scalar] No documentation \item{modelled_splice} Type [boolean : Scalar] so we can alter balance scores. \item{gms} Type [GeneModel * : Scalar] No documentation \end{description} GeneParameter21 keeps all the parameters for genewise algorithms in one tidy unit. This is also the switch between the old (compugen handled) and new statistics. This object can be made from either the old or the new statistics I have made the object complete opaque to scripting apis because the contents have to be coordinated quite well Member functions of GeneParameter21 wise-2.4.1/src/models/sw_wrap.pod0000644000175000001440000001515510670453715016330 0ustar philippusers=head1 NAME sw_wrap module - part of the Wise2 package =head1 SYNOPSIS This module contains helper functions for the Wise2 package =head1 DESCRIPTION =over =item Align_strings_ProteinSmithWaterman &Wise2::Align_strings_ProteinSmithWaterman(one,two,comp,gap,ext,dpenv,dpri) This is the most *stupidly* abstracted view of two sequences getting aligned, being two strings. It would be much better if you used Sequence objects or Protein objects to carry the proteins. Argument one [UNKN ] string of the first sequence [char *] Argument two [UNKN ] string of the second sequence [char *] Argument comp [UNKN ] Comparison Matrix [CompMat *] Argument gap [UNKN ] gap penalty [int] Argument ext [UNKN ] extension penalty [int] Argument dpenv [UNKN ] Undocumented argument [DPEnvelope *] Argument dpri [UNKN ] Undocumented argument [DPRunImpl *] Return [UNKN ] Undocumented return value [AlnBlock *] =item Align_Sequences_ProteinSmithWaterman &Wise2::Align_Sequences_ProteinSmithWaterman(one,two,comp,gap,ext,dpenv,dpri) This function is a mid-level abstraction of comparing two sequences, which could be generic types (eg DNA!). This is tested for and warnings are given but the alignment is still calculated. To prevent this test warning either make sure the Sequence types are set to PROTEIN or, better still, use the high level abstraction Align_Proteins_SmithWaterman Otherwise this performs a standard smith waterman protein alignment... To display the alignment use write_pretty_seq_align Argument one [READ ] First sequence to compare [Sequence *] Argument two [READ ] Second sequecne to compare [Sequence *] Argument comp [READ ] Comparison matrix to use [CompMat *] Argument gap [UNKN ] gap penalty. Must be negative or 0 [int] Argument ext [UNKN ] ext penalty. Must be negative or 0 [int] Argument dpenv [UNKN ] Undocumented argument [DPEnvelope *] Argument dpri [UNKN ] Undocumented argument [DPRunImpl *] Return [OWNER] new AlnBlock structure representing the alignment [AlnBlock *] =item Align_Proteins_SmithWaterman &Wise2::Align_Proteins_SmithWaterman(one,two,comp,gap,ext,dpenv,dpri) This is the most correct way of aligning two Proteins, using Protein objects, which can be assummed to be proteins with no objections To display the alignment use write_pretty_Protein_align Argument one [UNKN ] Protein to align [Protein *] Argument two [UNKN ] Protein to align [Protein *] Argument comp [UNKN ] Comparison Matrix [CompMat *] Argument gap [UNKN ] gap penalty [int] Argument ext [UNKN ] extension penalty [int] Argument dpenv [UNKN ] Undocumented argument [DPEnvelope *] Argument dpri [UNKN ] Undocumented argument [DPRunImpl *] Return [UNKN ] Undocumented return value [AlnBlock *] =item Align_Proteins_ABC &Wise2::Align_Proteins_ABC(one,two,comp,a,b,c,dpenv,dpri) Analogous to Align_Proteins_SmithWaterman for ABC model Argument one [UNKN ] protein to align [Protein *] Argument two [UNKN ] protein to align [Protein *] Argument comp [UNKN ] comparison matrix [CompMat *] Argument a [UNKN ] generalized affine gap cost a [int] Argument b [UNKN ] generalized affine gap cost b [int] Argument c [UNKN ] generalized affine gap cost c [int] Argument dpenv [UNKN ] Undocumented argument [DPEnvelope *] Argument dpri [UNKN ] Undocumented argument [DPRunImpl *] Return [UNKN ] Undocumented return value [AlnBlock *] =item Align_Sequences_ProteinABC &Wise2::Align_Sequences_ProteinABC(one,two,comp,a,b,c,dpenv,dpri) Align_Sequences_ProteinABC this function is analogous to Align_Sequences_ProteinSmithWaterman but using the abc model Argument one [UNKN ] Sequence to align [Sequence *] Argument two [UNKN ] Sequence to align [Sequence *] Argument comp [UNKN ] Comparison Matrix [CompMat *] Argument a [UNKN ] genearlized affine gap cost [int] Argument b [UNKN ] genearlized affine gap cost [int] Argument c [UNKN ] genearlized affine gap cost [int] Argument dpenv [UNKN ] Undocumented argument [DPEnvelope *] Argument dpri [UNKN ] Undocumented argument [DPRunImpl *] Return [UNKN ] Undocumented return value [AlnBlock *] =item Hscore_from_ProteinSW &Wise2::Hscore_from_ProteinSW(querydb,targetdb,comp,gap,ext,bits_cutoff,report_level,die_on_error,dbsi) Runs a database psw search Argument querydb [UNKN ] query database [ProteinDB*] Argument targetdb [UNKN ] target database [ProteinDB*] Argument comp [UNKN ] comparison matrix [CompMat*] Argument gap [UNKN ] gap penalty [int] Argument ext [UNKN ] extension penalty [int] Argument bits_cutoff [UNKN ] [double] Argument report_level [UNKN ] [int] Argument die_on_error [UNKN ] [boolean] Argument dbsi [UNKN ] [DBSearchImpl*] Return [UNKN ] Undocumented return value [Hscore *] =item Hscore_from_ProteinABC &Wise2::Hscore_from_ProteinABC(querydb,targetdb,comp,a,b,c,bits_cutoff,report_level,die_on_error,dbsi) Runs a database abc search Argument querydb [UNKN ] query database [ProteinDB*] Argument targetdb [UNKN ] target database [ProteinDB*] Argument comp [UNKN ] comparison matrix [CompMat*] Argument a [UNKN ] generalized affine gap cost a [int] Argument b [UNKN ] generalized affine gap cost b [int] Argument c [UNKN ] generalized affine gap cost c [int] Argument bits_cutoff [UNKN ] [double] Argument report_level [UNKN ] [int] Argument die_on_error [UNKN ] [boolean] Argument dbsi [UNKN ] [DBSearchImpl*] Return [UNKN ] Undocumented return value [Hscore *] =item Hscore_from_ProteinBA &Wise2::Hscore_from_ProteinBA(querydb,targetdb,comp,bentry,bexit,bfor_trans,b_self_trans,b3exit,bits_cutoff,report_level,dbsi) Runs a database pba search Argument querydb [UNKN ] query database [ProteinDB*] Argument targetdb [UNKN ] target database [ProteinDB*] Argument comp [UNKN ] comparison matrix [CompMat*] Argument bentry [UNKN ] [Score] Argument bexit [UNKN ] [Score] Argument bfor_trans [UNKN ] [Score] Argument b_self_trans [UNKN ] [Score] Argument b3exit [UNKN ] [Score] Argument bits_cutoff [UNKN ] [double] Argument report_level [UNKN ] [int] Argument dbsi [UNKN ] [DBSearchImpl*] Return [UNKN ] Undocumented return value [Hscore *] =back wise-2.4.1/src/models/sw_wrap.tex0000644000175000001440000001706310670453715016346 0ustar philippusers\section{sw_wrap} \label{module_sw_wrap} This module only contains factory methods \subsection{sw_wrap factory methods} \subsubsection{Align_strings_ProteinSmithWaterman} \begin{description} \item[External C] {\tt Wise2_Align_strings_ProteinSmithWaterman (one,two,comp,gap,ext,dpenv,dpri)} \item[Perl] {\tt &Wise2::Align_strings_ProteinSmithWaterman (one,two,comp,gap,ext,dpenv,dpri)} \end{description} Arguments \begin{description} \item[one] [UNKN ] string of the first sequence [char *] \item[two] [UNKN ] string of the second sequence [char *] \item[comp] [UNKN ] Comparison Matrix [CompMat *] \item[gap] [UNKN ] gap penalty [int] \item[ext] [UNKN ] extension penalty [int] \item[dpenv] [UNKN ] Undocumented argument [DPEnvelope *] \item[dpri] [UNKN ] Undocumented argument [DPRunImpl *] \item[returns] [UNKN ] Undocumented return value [AlnBlock *] \end{description} This is the most *stupidly* abstracted view of two sequences getting aligned, being two strings. It would be much better if you used Sequence objects or Protein objects to carry the proteins. \subsubsection{Align_Sequences_ProteinSmithWaterman} \begin{description} \item[External C] {\tt Wise2_Align_Sequences_ProteinSmithWaterman (one,two,comp,gap,ext,dpenv,dpri)} \item[Perl] {\tt &Wise2::Align_Sequences_ProteinSmithWaterman (one,two,comp,gap,ext,dpenv,dpri)} \end{description} Arguments \begin{description} \item[one] [READ ] First sequence to compare [Sequence *] \item[two] [READ ] Second sequecne to compare [Sequence *] \item[comp] [READ ] Comparison matrix to use [CompMat *] \item[gap] [UNKN ] gap penalty. Must be negative or 0 [int] \item[ext] [UNKN ] ext penalty. Must be negative or 0 [int] \item[dpenv] [UNKN ] Undocumented argument [DPEnvelope *] \item[dpri] [UNKN ] Undocumented argument [DPRunImpl *] \item[returns] [OWNER] new AlnBlock structure representing the alignment [AlnBlock *] \end{description} This function is a mid-level abstraction of comparing two sequences, which could be generic types (eg DNA!). This is tested for and warnings are given but the alignment is still calculated. To prevent this test warning either make sure the Sequence types are set to PROTEIN or, better still, use the high level abstraction Align_Proteins_SmithWaterman Otherwise this performs a standard smith waterman protein alignment... To display the alignment use write_pretty_seq_align \subsubsection{Align_Proteins_SmithWaterman} \begin{description} \item[External C] {\tt Wise2_Align_Proteins_SmithWaterman (one,two,comp,gap,ext,dpenv,dpri)} \item[Perl] {\tt &Wise2::Align_Proteins_SmithWaterman (one,two,comp,gap,ext,dpenv,dpri)} \end{description} Arguments \begin{description} \item[one] [UNKN ] Protein to align [Protein *] \item[two] [UNKN ] Protein to align [Protein *] \item[comp] [UNKN ] Comparison Matrix [CompMat *] \item[gap] [UNKN ] gap penalty [int] \item[ext] [UNKN ] extension penalty [int] \item[dpenv] [UNKN ] Undocumented argument [DPEnvelope *] \item[dpri] [UNKN ] Undocumented argument [DPRunImpl *] \item[returns] [UNKN ] Undocumented return value [AlnBlock *] \end{description} This is the most correct way of aligning two Proteins, using Protein objects, which can be assummed to be proteins with no objections To display the alignment use write_pretty_Protein_align \subsubsection{Align_Proteins_ABC} \begin{description} \item[External C] {\tt Wise2_Align_Proteins_ABC (one,two,comp,a,b,c,dpenv,dpri)} \item[Perl] {\tt &Wise2::Align_Proteins_ABC (one,two,comp,a,b,c,dpenv,dpri)} \end{description} Arguments \begin{description} \item[one] [UNKN ] protein to align [Protein *] \item[two] [UNKN ] protein to align [Protein *] \item[comp] [UNKN ] comparison matrix [CompMat *] \item[a] [UNKN ] generalized affine gap cost a [int] \item[b] [UNKN ] generalized affine gap cost b [int] \item[c] [UNKN ] generalized affine gap cost c [int] \item[dpenv] [UNKN ] Undocumented argument [DPEnvelope *] \item[dpri] [UNKN ] Undocumented argument [DPRunImpl *] \item[returns] [UNKN ] Undocumented return value [AlnBlock *] \end{description} Analogous to Align_Proteins_SmithWaterman for ABC model \subsubsection{Align_Sequences_ProteinABC} \begin{description} \item[External C] {\tt Wise2_Align_Sequences_ProteinABC (one,two,comp,a,b,c,dpenv,dpri)} \item[Perl] {\tt &Wise2::Align_Sequences_ProteinABC (one,two,comp,a,b,c,dpenv,dpri)} \end{description} Arguments \begin{description} \item[one] [UNKN ] Sequence to align [Sequence *] \item[two] [UNKN ] Sequence to align [Sequence *] \item[comp] [UNKN ] Comparison Matrix [CompMat *] \item[a] [UNKN ] genearlized affine gap cost [int] \item[b] [UNKN ] genearlized affine gap cost [int] \item[c] [UNKN ] genearlized affine gap cost [int] \item[dpenv] [UNKN ] Undocumented argument [DPEnvelope *] \item[dpri] [UNKN ] Undocumented argument [DPRunImpl *] \item[returns] [UNKN ] Undocumented return value [AlnBlock *] \end{description} Align_Sequences_ProteinABC this function is analogous to Align_Sequences_ProteinSmithWaterman but using the abc model \subsubsection{Hscore_from_ProteinSW} \begin{description} \item[External C] {\tt Wise2_Hscore_from_ProteinSW (querydb,targetdb,comp,gap,ext,bits_cutoff,report_level,die_on_error,dbsi)} \item[Perl] {\tt &Wise2::Hscore_from_ProteinSW (querydb,targetdb,comp,gap,ext,bits_cutoff,report_level,die_on_error,dbsi)} \end{description} Arguments \begin{description} \item[querydb] [UNKN ] query database [ProteinDB*] \item[targetdb] [UNKN ] target database [ProteinDB*] \item[comp] [UNKN ] comparison matrix [CompMat*] \item[gap] [UNKN ] gap penalty [int] \item[ext] [UNKN ] extension penalty [int] \item[bits_cutoff] [UNKN ] [double] \item[report_level] [UNKN ] [int] \item[die_on_error] [UNKN ] [boolean] \item[dbsi] [UNKN ] [DBSearchImpl*] \item[returns] [UNKN ] Undocumented return value [Hscore *] \end{description} Runs a database psw search \subsubsection{Hscore_from_ProteinABC} \begin{description} \item[External C] {\tt Wise2_Hscore_from_ProteinABC (querydb,targetdb,comp,a,b,c,bits_cutoff,report_level,die_on_error,dbsi)} \item[Perl] {\tt &Wise2::Hscore_from_ProteinABC (querydb,targetdb,comp,a,b,c,bits_cutoff,report_level,die_on_error,dbsi)} \end{description} Arguments \begin{description} \item[querydb] [UNKN ] query database [ProteinDB*] \item[targetdb] [UNKN ] target database [ProteinDB*] \item[comp] [UNKN ] comparison matrix [CompMat*] \item[a] [UNKN ] generalized affine gap cost a [int] \item[b] [UNKN ] generalized affine gap cost b [int] \item[c] [UNKN ] generalized affine gap cost c [int] \item[bits_cutoff] [UNKN ] [double] \item[report_level] [UNKN ] [int] \item[die_on_error] [UNKN ] [boolean] \item[dbsi] [UNKN ] [DBSearchImpl*] \item[returns] [UNKN ] Undocumented return value [Hscore *] \end{description} Runs a database abc search \subsubsection{Hscore_from_ProteinBA} \begin{description} \item[External C] {\tt Wise2_Hscore_from_ProteinBA (querydb,targetdb,comp,bentry,bexit,bfor_trans,b_self_trans,b3exit,bits_cutoff,report_level,dbsi)} \item[Perl] {\tt &Wise2::Hscore_from_ProteinBA (querydb,targetdb,comp,bentry,bexit,bfor_trans,b_self_trans,b3exit,bits_cutoff,report_level,dbsi)} \end{description} Arguments \begin{description} \item[querydb] [UNKN ] query database [ProteinDB*] \item[targetdb] [UNKN ] target database [ProteinDB*] \item[comp] [UNKN ] comparison matrix [CompMat*] \item[bentry] [UNKN ] [Score] \item[bexit] [UNKN ] [Score] \item[bfor_trans] [UNKN ] [Score] \item[b_self_trans] [UNKN ] [Score] \item[b3exit] [UNKN ] [Score] \item[bits_cutoff] [UNKN ] [double] \item[report_level] [UNKN ] [int] \item[dbsi] [UNKN ] [DBSearchImpl*] \item[returns] [UNKN ] Undocumented return value [Hscore *] \end{description} Runs a database pba search wise-2.4.1/src/models/test_splice.c0000644000175000001440000000157707571661351016632 0ustar philippusers#include "aligngenemodel.h" int main(int argc,char **argv) { int i; AlignGeneModelParam * agmp; GeneStats * gs; GeneModelParam * gmp = NULL; CompProb * comp_prob; DnaProbMatrix * dm; CodonTable * ct; RandomModel * rm; Sequence * test; ct = read_CodonTable_file("codon.table"); rm = default_RandomModel(); comp_prob = read_Blast_file_CompProb("wag85"); gmp = new_GeneModelParam_from_argv(&argc,argv); dm = DnaProbMatrix_from_match(0.8,NMaskType_VARIABLE); if((gs=GeneStats_from_GeneModelParam(gmp)) == NULL ) { fatal("Could not build gene stats"); } agmp = std_AlignGeneModelParam(comp_prob,dm,ct,gs); test = read_fasta_file_Sequence(argv[1]); assert(test); for(i=0;ilen;i++) { fprintf(stdout,"%c ss5 %.6f ss3 %.6f\n",test->seq[i],prob_SpliceSiteProb(agmp->ss5,test,i),prob_SpliceSiteProb(agmp->ss3,test,i)); } } wise-2.4.1/src/models/localcishit.dy0000644000175000001440000003677610414205303016772 0ustar philippusers %{ #include "dyna.h" #include "hsp.h" #include "localdba.h" #include "dbadisplay.h" #include "hitlist.h" #include "motifmatrix.h" #include "motifmatrixdp.h" #define LocalCisHitSetLISTLENGTH 128 typedef enum LocalCisGreedyType { LocalCisGreedy_None = 55, LocalCisGreedy_Query, LocalCisGreedy_Both } LocalCisGreedyType; %} struct LocalCisHit int start_q; int end_q; int start_t; int end_t; int target_rev; AlnBlock * alb; // relative to absolute coords int score Sequence * query Sequence * target struct LocalCisHitSet LocalCisHit ** lch !list struct LocalCisHitSetPara double seed_bit_trigger !def=15.0 int expansion_size !def=200 double aln_cutoff boolean sort_by_score !def=0 int max !def=20000 LocalCisGreedyType type !def="LocalCisGreedy_Query" %{ #include "localcishit.h" HitList * HitList_from_LocalCisHitSet(LocalCisHitSet * in) { HitList * out; HitPair * p; HitAln * a; int i; out = HitList_alloc_std(); for(i=0;ilen;i++) { p = HitPair_alloc_std(); add_HitList(out,p); p->query = hard_link_Sequence(in->lch[i]->query); p->target = hard_link_Sequence(in->lch[i]->target); p->raw_score = in->lch[i]->score; p->bit_score = Score2Bits(p->raw_score); p->target_reversed = in->lch[i]->target_rev; a = HitAln_alloc(); add_HitPair(p,a); a->alb = hard_link_AlnBlock(in->lch[i]->alb); a->raw_score = p->raw_score; a->bit_score = p->bit_score; } out->write_btc_func = show_pretty_Seq_dba_align_btcanvas; return out; } LocalCisHitSet * expand_to_subhits_LocalCisHitSet(LocalCisHitSet * in) { int i; AlnBlock * new; AlnColumn * alc; LocalCisHitSet * out; int qstart; int tstart; int qend; int tend; int score_start; int score; out = LocalCisHitSet_alloc_std(); for(i=0;in->len;i++) { for(alc=in->lch[i]->alb->start;alc != NULL;alc = alc->next ) { if( strcmp(alc->alu[0]->text_label,"UNMATCHED_QUERY") == 0 ) { break; } } if( alc == NULL ) { /* just one hit */ add_LocalCisHitSet(out,hard_link_LocalCisHit(in->lch[i])); } else { for(alc=in->lch[i]->alb->start;alc != NULL;alc = alc->next) { if( strstr(alc->alu[0]->text_label,"MM") != NULL ) { /* start here */ qstart = alc->alu[0]->start; tstart = alc->alu[1]->start; score = 0; new = AlnBlock_alloc(); new->start = alc; for(;alc != NULL && strstr(alc->alu[0]->text_label,"UNMATCHED") == NULL; alc = alc->next) { } } } fatal("Ewan has not implemented subhit expansion!"); } } return out; } void show_help_LocalCisHitSetPara(FILE * ofp) { fprintf(ofp,"Local Hit expansion parameters\n"); fprintf(ofp," -lhwindow - sequence window given to alignment [50]\n"); fprintf(ofp," -lhseed - seed score cutoff [10.0 bits]\n"); fprintf(ofp," -lhaln - aln score cutoff [8.0 bits]\n"); fprintf(ofp," -lhscore - sort final list by score (default by position)\n"); fprintf(ofp," -lhreject [none/query/both] - overlap rejection criteria in greedy assembly [query]\n"); fprintf(ofp," -lhmax [20000] - maximum number of processed hits\n"); } LocalCisHitSetPara * new_LocalCisHitSetPara_from_argv(int * argc,char ** argv) { LocalCisHitSetPara * setpara; char * temp; setpara = LocalCisHitSetPara_alloc(); setpara->expansion_size = 50; setpara->seed_bit_trigger = 10.0; setpara->aln_cutoff = 8.0; setpara->sort_by_score = 0; setpara->max = 20000; setpara->type = LocalCisGreedy_Query; strip_out_integer_argument(argc,argv,"lhwindow",&setpara->expansion_size); strip_out_integer_argument(argc,argv,"lhmax",&setpara->max); strip_out_float_argument(argc,argv,"lhseed",&setpara->seed_bit_trigger); strip_out_float_argument(argc,argv,"lhaln",&setpara->aln_cutoff); strip_out_boolean_def_argument(argc,argv,"lhscore",&setpara->sort_by_score); temp = strip_out_assigned_argument(argc,argv,"lhreject"); if( temp != NULL ) { if( strcmp(temp,"none") == 0) { setpara->type = LocalCisGreedy_None; } else if ( strcmp(temp,"query") == 0 ) { setpara->type = LocalCisGreedy_Query; } else if ( strcmp(temp,"both") == 0){ setpara->type = LocalCisGreedy_Both; } else { fatal("Bad parameter for lhreject %s",temp); } } return setpara; } void show_pretty_LocalCisHitSet(LocalCisHitSet * lchs,FILE * ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,">%s %5d,%5d %s %5d,%5d [%c] Bits %.2f\n", lchs->lch[i]->query->name, lchs->lch[i]->start_q+1, lchs->lch[i]->end_q, lchs->lch[i]->target->name, lchs->lch[i]->start_t+1, lchs->lch[i]->end_t, lchs->lch[i]->target_rev == 1 ? '-' : '+', Score2Bits(lchs->lch[i]->score) ); fprintf(ofp,"\n"); show_pretty_dba_align(lchs->lch[i]->alb,lchs->lch[i]->query,lchs->lch[i]->target,ofp); } } void show_summary_LocalCisHitSet(LocalCisHitSet * lchs,FILE * ofp) { int i; assert(lchs); assert(ofp); for(i=0;ilen;i++) { fprintf(ofp,"Query %5d,%5d Target %5d,%5d [%c] Bits %.2f\n", lchs->lch[i]->start_q+1, lchs->lch[i]->end_q, lchs->lch[i]->start_t+1, lchs->lch[i]->end_t, lchs->lch[i]->target_rev == 1 ? '-' : '+', Score2Bits(lchs->lch[i]->score) ); } } LocalCisHitSet * greedy_weed_LocalCisHitSet(LocalCisHitSet * set,LocalCisHitSetPara *p) { LocalCisHitSet * out; int i; int j; int is_valid; sort_LocalCisHitSet_by_score(set); out = LocalCisHitSet_alloc_std(); for(i=0;ilen;i++) { if( Score2Bits(set->lch[i]->score) < p->aln_cutoff) { break; } is_valid = 1; if( p->type != LocalCisGreedy_None ) { for(j=0;jlen;j++) { if( is_query_overlap_LocalCisHit(set->lch[i],out->lch[j]) == 1 ) { is_valid = 0; break; } } if( is_valid == 1 && p->type == LocalCisGreedy_Both ) { for(j=0;jlen;j++) { if( is_target_overlap_LocalCisHit(set->lch[i],out->lch[j]) == 1 ) { is_valid = 0; break; } } } } if( is_valid == 1 ) { add_LocalCisHitSet(out,hard_link_LocalCisHit(set->lch[i])); } } if( p->sort_by_score == 0 ) { sort_LocalCisHitSet_by_start(out); } return out; } void sort_LocalCisHitSet_by_score(LocalCisHitSet * set) { sort_LocalCisHitSet(set,compare_LocalCisHit_score); } void sort_LocalCisHitSet_by_start(LocalCisHitSet * set) { sort_LocalCisHitSet(set,compare_LocalCisHit_start); } int compare_LocalCisHit_score(LocalCisHit * a,LocalCisHit * b) { return b->score - a->score; } int compare_LocalCisHit_start(LocalCisHit * a,LocalCisHit * b) { return a->start_q - b->start_q; } int is_query_overlap_LocalCisHit(LocalCisHit * a,LocalCisHit * b) { if( a->start_q > b->end_q || a->end_q < b->start_q ) { return 0; } else { return 1; } } int is_target_overlap_LocalCisHit(LocalCisHit * a,LocalCisHit * b) { if( a->start_t > b->end_t || a->end_t < b->start_t ) { return 0; } else { return 1; } } int is_consumed_HSP(HSP * a,int q_start,int q_end,int t_start,int t_end) { int qcentre; int tcentre; /* find centre of hit, and see if it is in the system */ qcentre = a->query_start + (a->length/2); tcentre = a->target_start + (a->length/2); if( qcentre >= q_start && qcentre <= q_end && tcentre >= t_start && tcentre <= t_end ) { return 1; } else { return 0; } } LocalCisHitSet * make_LocalCisHitSet(Sequence * query,Sequence * target,Sequence * target_rev,HSPset * forward,HSPset * reverse,LocalCisHitSetPara * p,LocalCisHitScore * scorepara,TransFactorMatchSet * tfms_query,TransFactorMatchSet * tfms_target,TransFactorMatchSet * tfms_target_rev,MotifMatrixScore * mms,boolean use_motif,DPRunImpl * dpri) { LocalCisHitSet * set; LocalCisHit * lch; int i,j; int * forward_used; int * reverse_used; int q_start; int q_end; int t_start; int t_end; int temp_q_start; int temp_q_end; int temp_t_start; int temp_t_end; assert(query); assert(target); assert(target_rev); assert(forward); assert(reverse); sort_HSPset_by_score(forward); sort_HSPset_by_score(reverse); set = LocalCisHitSet_alloc_std(); forward_used = calloc(forward->len,sizeof(int)); for(i=0;ilen;i++) { forward_used[i] = 0; } for(i=0;ilen && i < p->max;i++) { /* fprintf(stderr,"Looking at hsp set %d %d %f score vs trigger %f\n",i,forward->hsp[i]->score,Score2Bits(forward->hsp[i]->score),p->seed_bit_trigger); */ if( forward_used[i] == 0 && Score2Bits(forward->hsp[i]->score) > p->seed_bit_trigger ) { forward_used[i] = 1; q_start = forward->hsp[i]->query_start-p->expansion_size; q_end = forward->hsp[i]->query_start+forward->hsp[i]->length+p->expansion_size; t_start = forward->hsp[i]->target_start-p->expansion_size; t_end = forward->hsp[i]->target_start+forward->hsp[i]->length+p->expansion_size; for(j=i;jlen && j < p->max;j++) { if( forward_used[j] == 1 ) { continue; } if( is_consumed_HSP(forward->hsp[j],q_start,q_end,t_start,t_end) ) { forward_used[j] = 1; /*info("consuming forward %d by %d\n",j,i);*/ temp_q_start = forward->hsp[j]->query_start-p->expansion_size; temp_q_end = forward->hsp[j]->query_start+forward->hsp[i]->length+p->expansion_size; temp_t_start = forward->hsp[j]->target_start-p->expansion_size; temp_t_end = forward->hsp[j]->target_start+forward->hsp[i]->length+p->expansion_size; q_start = temp_q_start < q_start ? temp_q_start : q_start; t_start = temp_t_start < t_start ? temp_t_start : t_start; t_end = temp_t_end > t_end ? temp_t_end : t_end; q_end = temp_q_end > q_end ? temp_q_end : q_end; } } /* now build local cis hit */ if( use_motif == 0 ) { lch = make_LocalCisHit(query,target,0, q_start, q_end, t_start, t_end, scorepara,dpri ); } else { lch = make_motif_LocalCisHit(query,target,0, q_start, q_end, t_start, t_end, tfms_query, tfms_target, mms,dpri ); } add_LocalCisHitSet(set,lch); } else { break; } } reverse_used = calloc(reverse->len,sizeof(int)); for(i=0;ilen;i++) { reverse_used[i] = 0; } for(i=0;ilen && i < p->max ;i++) { if( reverse_used[i] == 0 && Score2Bits(reverse->hsp[i]->score) > p->seed_bit_trigger ) { reverse_used[i] = 1; q_start = reverse->hsp[i]->query_start-p->expansion_size; q_end = reverse->hsp[i]->query_start+reverse->hsp[i]->length+p->expansion_size; t_start = reverse->hsp[i]->target_start-p->expansion_size; t_end = reverse->hsp[i]->target_start+reverse->hsp[i]->length+p->expansion_size; for(j=i;jlen && j < p->max ;j++) { if( reverse_used[j] == 1 ) { continue; } if( is_consumed_HSP(reverse->hsp[j],q_start,q_end,t_start,t_end) ) { reverse_used[j] = 1; /*info("consuming reverse %d by %d\n",j,i);*/ temp_q_start = reverse->hsp[j]->query_start-p->expansion_size; temp_q_end = reverse->hsp[j]->query_start+reverse->hsp[i]->length+p->expansion_size; temp_t_start = reverse->hsp[j]->target_start-p->expansion_size; temp_t_end = reverse->hsp[j]->target_start+reverse->hsp[i]->length+p->expansion_size; q_start = temp_q_start < q_start ? temp_q_start : q_start; t_start = temp_t_start < t_start ? temp_t_start : t_start; t_end = temp_t_end > t_end ? temp_t_end : t_end; q_end = temp_q_end > q_end ? temp_q_end : q_end; } } if( use_motif == 0 ) { lch = make_LocalCisHit(query,target_rev,1, q_start, q_end, t_start, t_end, scorepara,dpri ); } else { lch = make_motif_LocalCisHit(query,target_rev,1, q_start, q_end, t_start, t_end, tfms_query, tfms_target_rev, mms,dpri ); } add_LocalCisHitSet(set,lch); } else { break; } } return set; } LocalCisHit * make_LocalCisHit(Sequence * query,Sequence * target,int is_reversed,int guess_q_start,int guess_q_end,int guess_t_start,int guess_t_end,LocalCisHitScore * score,DPRunImpl * dpri) { LocalCisHit * out; Sequence * temp_q; Sequence * temp_t; ComplexSequence * q_cseq; ComplexSequence * t_cseq; ComplexSequenceEvalSet * cses; PackAln * pal; AlnBlock * alb; int i; assert(query); assert(target); assert(score); if( guess_q_start < 0 ) { guess_q_start = 0; } if( guess_q_end >= query->len ) { guess_q_end = query->len-1; } if( guess_t_start < 0 ) { guess_t_start = 0; } if( guess_t_end >= target->len ) { guess_t_end = target->len-1; } temp_q = trunc_Sequence(query,guess_q_start,guess_q_end); temp_t = trunc_Sequence(target,guess_t_start,guess_t_end); cses = default_DNA_ComplexSequenceEvalSet(); q_cseq = new_ComplexSequence(temp_q,cses); t_cseq = new_ComplexSequence(temp_t,cses); assert(q_cseq); assert(t_cseq); pal = PackAln_bestmemory_LocalDnaMatchBlock(q_cseq,t_cseq,score,NULL,dpri); assert(pal); for(i=0;ilen;i++) { pal->pau[i]->i = pal->pau[i]->i + guess_q_start; pal->pau[i]->j = pal->pau[i]->j + guess_t_start; } alb = convert_PackAln_to_AlnBlock_LocalDnaMatchBlock(pal); out = LocalCisHit_alloc(); out->start_q = pal->pau[0]->i; out->end_q = pal->pau[pal->len-2]->i; out->start_t = pal->pau[0]->j; out->end_t = pal->pau[pal->len-1]->j; out->score = pal->score; out->target_rev = is_reversed; out->alb = alb; out->query = hard_link_Sequence(query); out->target = hard_link_Sequence(target); free_PackAln(pal); return out; } LocalCisHit * make_motif_LocalCisHit(Sequence * query,Sequence * target,int is_reversed,int guess_q_start,int guess_q_end,int guess_t_start,int guess_t_end,TransFactorMatchSet * tfms_query,TransFactorMatchSet * tfms_target,MotifMatrixScore * mms,DPRunImpl * dpri) { LocalCisHit * out; Sequence * temp_q; Sequence * temp_t; ComplexSequence * q_cseq; ComplexSequence * t_cseq; ComplexSequenceEvalSet * cses; MotifConsMatrix * mcm; PackAln * pal; AlnBlock * alb; int i; assert(query != NULL); assert(target != NULL); assert(mms != NULL); assert(tfms_query != NULL); assert(tfms_target != NULL); if( guess_q_start < 0 ) { guess_q_start = 0; } if( guess_q_end >= query->len ) { guess_q_end = query->len-1; } if( guess_t_start < 0 ) { guess_t_start = 0; } if( guess_t_end >= target->len ) { guess_t_end = target->len-1; } temp_q = trunc_Sequence(query,guess_q_start,guess_q_end); temp_t = trunc_Sequence(target,guess_t_start,guess_t_end); cses = default_DNA_ComplexSequenceEvalSet(); q_cseq = new_ComplexSequence(temp_q,cses); t_cseq = new_ComplexSequence(temp_t,cses); assert(q_cseq); assert(t_cseq); mcm = new_MotifConsMatrix(tfms_query,guess_q_start,guess_q_end,tfms_target,guess_t_start,guess_t_end); pal = PackAln_bestmemory_LocalMotifMatrix(q_cseq,t_cseq,mcm,mms,NULL,dpri); assert(pal); for(i=0;ilen;i++) { pal->pau[i]->i = pal->pau[i]->i + guess_q_start; pal->pau[i]->j = pal->pau[i]->j + guess_t_start; } alb = convert_PackAln_to_AlnBlock_LocalMotifMatrix(pal); out = LocalCisHit_alloc(); out->start_q = pal->pau[0]->i; out->end_q = pal->pau[pal->len-2]->i; out->start_t = pal->pau[0]->j; out->end_t = pal->pau[pal->len-1]->j; out->score = pal->score; out->target_rev = is_reversed; out->alb = alb; out->query = hard_link_Sequence(query); out->target = hard_link_Sequence(target); free_PackAln(pal); return out; } %} wise-2.4.1/src/models/threestateloop.dy0000644000175000001440000000401107654461305017531 0ustar philippusers %{ #include "threestatemodel.h" %} matrix ThreeStateLoop query type="ThreeStateScore*" name="query" target type="PROTEIN" name="target" state MATCH offi="1" offj="1" calc="query->unit[i]->match[AMINOACID(target,j)]" source MATCH calc="query->unit[i]->trans[TSM_MATCH2MATCH]" endsource source INSERT calc="query->unit[i]->trans[TSM_INSERT2MATCH]" endsource source DELETE calc="query->unit[i]->trans[TSM_DELETE2MATCH]" endsource source LOOP calc="query->unit[i]->trans[TSM_START2MATCH]" endsource query_label SEQUENCE target_label SEQUENCE endstate state INSERT offi="0" offj="1" calc="query->unit[i]->insert[AMINOACID(target,j)]" source MATCH calc="query->unit[i]->trans[TSM_MATCH2INSERT]" endsource source INSERT calc="query->unit[i]->trans[TSM_INSERT2INSERT]" endsource source DELETE calc="query->unit[i]->trans[TSM_DELETE2INSERT]" endsource source LOOP calc="query->unit[i]->trans[TSM_START2INSERT]" endsource query_label INSERT target_label SEQUENCE endstate state DELETE offi="1" offj="0" source MATCH calc="query->unit[i]->trans[TSM_MATCH2DELETE]" endsource source INSERT calc="query->unit[i]->trans[TSM_INSERT2DELETE]" endsource source DELETE calc="query->unit[i]->trans[TSM_DELETE2DELETE]" endsource source START calc="query->unit[i]->trans[TSM_START2DELETE]" endsource query_label SEQUENCE target_label INSERT endstate state START !special !start endstate state LOOP !special source MATCH calc="query->unit[i]->trans[TSM_MATCH2END]" endsource source INSERT calc="query->unit[i]->trans[TSM_INSERT2END]" endsource source DELETE calc="query->unit[i]->trans[TSM_DELETE2END]" endsource source LOOP offj="1" calc="0" endsource source START offj="1" calc="0" endsource query_label LOOP target_label LOOP endstate state END !end !special source LOOP offj="1" calc="0" endsource query_label END target_label END endstate endmatrix wise-2.4.1/src/models/genedisplay.typemap0000644000175000001440000000000010670453714020025 0ustar philippuserswise-2.4.1/src/models/aligngenemodel.c0000644000175000001440000012177410670453713017263 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "aligngenemodel.h" # line 77 "aligngenemodel.dy" Probability weighted_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp) { int aa; int seq_no; Probability out; Probability aa_prob; int codon; out = 0.0; for(aa=0;aa<26;aa++) { if( agmp->rm->aminoacid[aa] < 0.0000000001 ) { continue; } aa_prob = agmp->rm->aminoacid[aa]; for(seq_no=0;seq_nolen;seq_no++) { if( !isalpha(store->codon[seq_no].seq[0]) || !isalpha(store->codon[seq_no].seq[1]) || !isalpha(store->codon[seq_no].seq[2]) ) { return 0.5; } codon = codon_from_seq(store->codon[seq_no].seq); if( is_stop_codon(codon,agmp->ct) ) { if( seq_no > 0 && agmp->tolerate_nonanchor_stops ) { return agmp->nonanchor_stop; } else { return 0.0; } } aa_prob *= agmp->protein->comp[aa][aminoacid_from_codon(agmp->ct,codon)-'A'] * store->codon[seq_no].weight; } out += aa_prob; } return out; } # line 122 "aligngenemodel.dy" void window_AlignGeneModel(SeqAlign * sal,AlignGeneModel * agm,AlignGeneModelParam * agmp) { int i; int j; int k; int count; int win_count; double average_change; int change; double * change_array; change_array = calloc(agm->len,sizeof(double)); fprintf(stderr,"Got Window at %f and non window at %f\n",agmp->coding_window_bonus,agmp->noncoding_window_pen); for(i=1;ilen;i++) { average_change = 0.0; count = 0; for(j=0;jseq[0]->len-32;j++) { change = 0; win_count = 0; for(k = 0;k<31;k++) { if( sal->seq[0]->seq[j+k] != sal->seq[i]->seq[j+k] && sal->seq[i]->seq[j+k] != '~') { change++; } if( sal->seq[i]->seq[j+k] != '~' ) { win_count++; } } if( win_count == 0 ) { change_array[j+15] = 0.9; continue; } change_array[j+15] = ((double) change) / win_count; average_change += change_array[j+15]; count++; /* fprintf(stdout,"Got %f, running average %f\n",change_array[j+15],average_change/(double)count);*/ } average_change = average_change / (double) count; fprintf(stdout,"For %s, Average change is %f\n",sal->seq[i]->name,average_change); for(j=15;jseq[0]->len-16;j++) { if( change_array[j] < (average_change/agmp->coding_window_thres) ) { /* fprintf(stdout,"At position %d in %s giving coding bonus\n",j,sal->seq[i]->name);*/ agm->forward_coding[j] *= agmp->coding_window_bonus; agm->reverse_coding[j] *= agmp->coding_window_bonus; } if( change_array[j] > (average_change * agmp->noncoding_window_thres) ) { /* fprintf(stdout,"At position %d in %s giving penalty\n",j,sal->seq[i]->name);*/ agm->forward_coding[j] *= agmp->noncoding_window_pen; agm->reverse_coding[j] *= agmp->noncoding_window_pen; } } } free(change_array); return; } # line 192 "aligngenemodel.dy" NonCodingSimpleModel * create_NonCodingSimpleModel(Probability change) { NonCodingSimpleModel * out; out = NonCodingSimpleModel_alloc(); out->one_off = change * (1.0-change) * (1.0-change) * 3; out->two_off = change * change * (1.0-change) * 3; out->identical = 1.0 - (out->one_off + out->two_off); return out; } # line 205 "aligngenemodel.dy" Probability simple_non_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp) { int i; int j; int k; Probability out = 1.0; Probability col = 0.0; Probability c = 0.0; for(k=0;k<3;k++) { col = 0.0; for(j=0;j<4;j++) { c= 0.25; for(i=0;ilen;i++) { if( store->codon[i].seq[2-k] == '-' || store->codon[i].seq[2-k] == '~') { return 0.5; } c *= agmp->dm->prob[j][base_from_char(store->codon[i].seq[2-k])]; } col += c; } out *= col; } return out; } # line 234 "aligngenemodel.dy" Probability weighted_non_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp) { int i; int j; int k; Probability out = 1.0; Probability col = 0.0; Probability c = 0.0; for(k=0;k<3;k++) { col = 0.0; for(j=0;j<4;j++) { c= 0.25; for(i=0;ilen;i++) { if( store->codon[i].seq[2-k] == '-' || store->codon[i].seq[2-k] == '~') { return 0.5; } c *= agmp->dm->prob[j][base_from_char(store->codon[i].seq[2-k])]; } col += c; } out *= col; } return out; } # line 268 "aligngenemodel.dy" Probability weighted_simple_non_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp) { int i; int j; int k; Probability out = 1.0; Probability col = 0.0; Probability c = 0.0; for(k=0;k<3;k++) { col = 0.0; for(j=0;j<4;j++) { c= 0.25; for(i=0;ilen;i++) { if( store->codon[i].seq[2-k] == '-' ) { return 0.5; } c *= agmp->dm->prob[j][base_from_char(store->codon[i].seq[2-k])]; } col += c; } out *= col; } return out; } # line 301 "aligngenemodel.dy" Probability simple_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp) { int i; int j; int codon; Probability out = 0.0; Probability c = 0.0; Probability f; assert(store); assert(agmp); for(j=0;j<26;j++) { if( agmp->rm->aminoacid[j] < 0.0000000001 ) { continue; } c = agmp->rm->aminoacid[j]; for(i=0;ilen;i++) { if( !isalpha(store->codon[i].seq[0]) || !isalpha(store->codon[i].seq[1]) || !isalpha(store->codon[i].seq[2]) ) { return 0.0; } codon = codon_from_seq(store->codon[i].seq); if( is_stop_codon(codon,agmp->ct) ) { return 0.0; } f = agmp->protein->comp[j][aminoacid_from_codon(agmp->ct,codon)-'A']; /* fprintf(stdout,"For amino acid %c, match %.4f cum %.4f\n",j+'A', agmp->protein->comp[j][aminoacid_from_codon(agmp->ct,codon)-'A'], c); */ /* c = c*f;*/ c = c*f; /* fprintf(stdout,"Refactoring by %f\n",store->codon[i].weight); */ /* c = c*100; */ } out += c; } /* fprintf(stdout,"final %.4f\n",out);*/ return out; } # line 350 "aligngenemodel.dy" boolean fill_reverse_AlignGeneColumn(AlignGeneColumnStore * store,SeqAlign * sa,int forward_codon_end) { int i; assert(store); assert(sa); assert(store->len == sa->len); assert(forward_codon_end >= 0 && forward_codon_end < sa->seq[0]->len); for(i=0;ilen;i++) { store->codon[i].seq[0] = char_complement_base(sa->seq[i]->seq[forward_codon_end]); store->codon[i].seq[1] = char_complement_base(sa->seq[i]->seq[forward_codon_end-1]); store->codon[i].seq[2] = char_complement_base(sa->seq[i]->seq[forward_codon_end-2]); store->codon[i].weight = sa->seq[i]->weight; } return TRUE; } # line 370 "aligngenemodel.dy" boolean fill_forward_AlignGeneColumn(AlignGeneColumnStore * store,SeqAlign * sa,int codon_end) { int i; assert(store); assert(sa); assert(store->len == sa->len); assert(codon_end >= 0 && codon_end < sa->seq[0]->len); for(i=0;ilen;i++) { store->codon[i].seq[0] = sa->seq[i]->seq[codon_end-2]; store->codon[i].seq[1] = sa->seq[i]->seq[codon_end-1]; store->codon[i].seq[2] = sa->seq[i]->seq[codon_end]; store->codon[i].weight = sa->seq[i]->weight; } return TRUE; } # line 389 "aligngenemodel.dy" AlignGeneColumnStore * new_empty_AlignGeneColumnStore(int len) { AlignGeneColumnStore * out; out = AlignGeneColumnStore_alloc(); out->codon = calloc(len,sizeof(AlignGeneCodon)); out->len = len; return out; } # line 401 "aligngenemodel.dy" AlignGeneCodon * free_AlignGeneCodon(AlignGeneCodon * c) { ckfree(c); return NULL; } # line 408 "aligngenemodel.dy" AlignGeneModel * new_AlignGeneModel(int len) { AlignGeneModel * out; out = AlignGeneModel_alloc(); out->len = len; out->forward_coding = calloc(len,sizeof(Probability)); out->reverse_coding = calloc(len,sizeof(Probability)); out->splice5_forward = calloc(len,sizeof(Probability)); out->splice3_forward = calloc(len,sizeof(Probability)); out->splice5_reverse = calloc(len,sizeof(Probability)); out->splice3_reverse = calloc(len,sizeof(Probability)); out->change_rate = calloc(len,sizeof(double)); out->align = NULL; out->anchor = NULL; return out; } # line 430 "aligngenemodel.dy" void show_AlignGeneModel(AlignGeneModel * agm,SeqAlign * sal,CodonTable * ct,GenomicRegion * gr,FILE * ofp,AlignGeneModelParam * agmp) { int i; int j; int * should_show; int ex_len; int k; AlignGeneColumnStore * store; int tr_len; int phase_score[3]; int total_phase_0 = 0; int phase; int * phase_array; int pos; int count = 0; fprintf(stderr,"Gene model at %d with %d\n",gr,gr->len); should_show = calloc(agm->len,sizeof(int)); phase_array = calloc(agm->len,sizeof(int)); fprintf(stderr,"Gene model at %d with %d\n",gr,gr->len); if( gr != NULL ) { if( gr->len == 0 ) { warn("genomic region given, but no genes on region!"); } for(i=0;ilen;i++) should_show[i] = 0; } else { for(i=0;ilen;i++) should_show[i] = 1; } if( gr != NULL ) { for( i=0;ilen;i++) { tr_len = 3; for( j=0;jgene[i]->transcript[0]->ex_len; j++) { ex_len = gr->gene[i]->transcript[0]->exon[j]->end - gr->gene[i]->transcript[0]->exon[j]->start; phase_score[0] = 0; phase_score[1] = 0; phase_score[2] = 0; /* deal with splice sites etc */ pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start-4; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start-3; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start-2; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start-1; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start+ex_len+1; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start+ex_len; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start+ex_len+2; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start+ex_len+3; should_show[pos] = 1; for(k=0;kgene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start+k; phase_score[phase] += Probability2Score(agm->forward_coding[pos]); phase_array[pos] = phase_score[phase]; /* printf("%d Adding %d in to %d with %f\n",phase,Probability2Score(agm->forward_coding[pos]),phase_score[phase],Score2Bits(phase_score[phase])); */ if( phase == 0 ) { total_phase_0 += Probability2Score(agm->forward_coding[i]); should_show[pos] = 2; } else { should_show[pos] = 1; } tr_len++; } } } } store = new_empty_AlignGeneColumnStore(sal->len); for(i=0;ilen;i++) { if( should_show[i] == 0 ) { continue; } if( i > 0 && should_show[i-1] == 0 ) { /* just had a discontinuity */ fprintf(ofp,"\n ---\n"); } fill_forward_AlignGeneColumn(store,sal,i); fprintf(ofp,"%c %4d %2.4f Bits: %2.4f [%1.6f vs %1.6f cum % 8.1f] %2.4f %2.4f | %2.4f %2.4f %2.4f ", should_show[i] == 2 ? '*' : '-', i, agm->forward_coding[i], Score2Bits(Probability2Score(agm->forward_coding[i])), weighted_coding_AlignGeneColumn(store,agmp), weighted_non_coding_AlignGeneColumn(store,agmp), gr == NULL ? 0.0 : Score2Bits(phase_array[i]), agm->splice5_forward[i], agm->splice3_forward[i], agm->reverse_coding[i],agm->splice5_reverse[i], agm->splice3_reverse[i] ); for(j=0;jlen;j++) { fprintf(ofp,"%c",sal->seq[j]->seq[i]); } fprintf(ofp,"|"); for(j=0;jlen;j++) { fprintf(ofp,"%c",char_complement_base(sal->seq[j]->seq[i])); } fprintf(ofp," "); if( i > 3 ) { for(j=0;jlen;j++) { if( sal->seq[j]->seq[i-2] == '~' || sal->seq[j]->seq[i-2] == '-' || sal->seq[j]->seq[i-1] == '~' || sal->seq[j]->seq[i-1] == '-' || sal->seq[j]->seq[i] == '~' || sal->seq[j]->seq[i] == '-' ) { fprintf(ofp,"?"); } else { if( sal->seq[0]->seq[i-2] != sal->seq[1]->seq[i-2] || sal->seq[0]->seq[i-1] != sal->seq[1]->seq[i-1] || sal->seq[0]->seq[i] != sal->seq[1]->seq[i]) { fprintf(ofp,"%c",aminoacid_from_seq(ct,sal->seq[j]->seq+i-2)); } else { fprintf(ofp,"%c",tolower(aminoacid_from_seq(ct,sal->seq[j]->seq+i-2))); } } } if( agm->forward_coding[i] > 15.0 ) { fprintf(ofp,"*"); } } fprintf(ofp,"\n"); } } # line 582 "aligngenemodel.dy" AlignGeneModel * create_AlignGeneModel(SeqAlign * sal,AlignGeneModelParam * agmp) { AlignGeneModel * out; int i; int j; Probability ss5p; Probability ss3p; AlignGeneColumnStore * store; Sequence * rev; assert(agmp); assert(agmp->ct); assert(agmp->protein); assert(agmp->dm); out = new_AlignGeneModel(sal->seq[0]->len); reweight_SeqAlign(sal); for(i=0;ilen;i++) { fprintf(stdout,"%s weight %f\n",sal->seq[i]->name,sal->seq[i]->weight); } store = new_empty_AlignGeneColumnStore(sal->len); for(i=0;iseq[0]->len;i++) { if( i > 2 ) { fill_forward_AlignGeneColumn(store,sal,i); /* fprintf(stdout,"%d %f vs %f [%f] | %f vs %f %c%c%c %c%c%c\n",i, simple_coding_AlignGeneColumn(store,agmp), weighted_coding_AlignGeneColumn(store,agmp), simple_coding_AlignGeneColumn(store,agmp)/weighted_coding_AlignGeneColumn(store,agmp), simple_non_coding_AlignGeneColumn(store,agmp), non_coding_probability_AlignGeneModel(sal,i,agmp), store->codon[0].seq[0], store->codon[0].seq[1], store->codon[0].seq[2], store->codon[1].seq[0], store->codon[1].seq[1], store->codon[1].seq[2]); */ out->forward_coding[i] = weighted_coding_AlignGeneColumn(store,agmp)*agmp->total_weight/ (weighted_non_coding_AlignGeneColumn(store,agmp)); } ss5p = 1.0; ss3p = 1.0; for(j=0;j<1;j++) { if( sal->seq[j]->seq[i] == 'G' && sal->seq[j]->seq[i+1] == 'T' && i < sal->seq[j]->len-2) ss5p *= prob_SpliceSiteProb(agmp->ss5,sal->seq[j],i); else ss5p = 0.00000001; if( sal->seq[j]->seq[i] == 'G' && sal->seq[j]->seq[i-1] == 'A' && i > 2 ) ss3p *= prob_SpliceSiteProb(agmp->ss3,sal->seq[j],i); else ss3p = 0.000000001; } if( ss5p > 4 ) { ss5p = 4.0; } if( ss3p > 4 ) { ss3p = 4.0; } out->splice5_forward[i] = ss5p; out->splice3_forward[i] = ss3p; } rev = reverse_complement_Sequence(sal->seq[0]); for(i=0;iseq[0]->len;i++) { if( i > 2 ) { fill_reverse_AlignGeneColumn(store,sal,i); out->reverse_coding[i] = weighted_coding_AlignGeneColumn(store,agmp)*agmp->total_weight/ (weighted_non_coding_AlignGeneColumn(store,agmp)); } if( rev->seq[rev->len-i] == 'G' && rev->seq[rev->len-i-1] == 'T' && i > 2) out->splice5_reverse[i] = prob_SpliceSiteProb(agmp->ss5,rev,rev->len-i); else out->splice5_reverse[i] = 0.00000001; if( rev->seq[rev->len-i] == 'G' && rev->seq[rev->len-i+1] == 'A' && i < rev->len -2) out->splice3_reverse[i] = prob_SpliceSiteProb(agmp->ss3,rev,rev->len-i); else out->splice3_reverse[i] = 0.00000001; if( out->splice5_reverse[i] > 4 ) { out->splice5_reverse[i] = 4.0; } if( out->splice3_reverse[i] > 4 ) { out->splice3_reverse[i] = 4.0; } /* out->splice5_reverse[i] = 1.0; out->splice3_reverse[i] = 1.0; */ } free_AlignGeneColumnStore(store); free_Sequence(rev); window_AlignGeneModel(sal,out,agmp); out->align = hard_link_SeqAlign(sal); out->anchor = hard_link_Sequence(sal->seq[0]); return out; } # line 709 "aligngenemodel.dy" Probability prob_SpliceSiteProb(SpliceSiteProb * ssp,Sequence * seq,int pos) { assert(ssp); assert(seq); if( pos<= ssp->offset ) { return 0.0; } return prob_pwmDNA_string(ssp->pwm,seq->seq-ssp->offset+1+pos); } # line 724 "aligngenemodel.dy" Probability non_coding_probability_AlignGeneModel(SeqAlign * sal,int codon_end_pos,AlignGeneModelParam * agmp) { int i; int j; int k; Probability out = 1.0; Probability col = 0.0; Probability c = 0.0; for(k=0;k<3;k++) { for(j=0;j<4;j++) { c= 0.25; for(i=0;ilen;i++) { if( sal->seq[i]->seq[codon_end_pos-k] == '-' ) { return 0.5; } c *= agmp->dm->prob[j][base_from_char(sal->seq[i]->seq[codon_end_pos-k])]; } col += c; } out *= col; } return out; } # line 753 "aligngenemodel.dy" Probability coding_probability_AlignGeneModel(SeqAlign * sal,int codon_end_pos,AlignGeneModelParam * agmp) { int i; int j; int codon; Probability out = 0.0; Probability c = 0.0; Probability f; assert(sal); assert(agmp); assert(agmp->rm); assert(agmp->protein); /* fprintf(stdout,"Testing %c%c%c [%c] vs %c%c%c [%c]\n", sal->seq[0]->seq[codon_end_pos-2], sal->seq[0]->seq[codon_end_pos-1], sal->seq[0]->seq[codon_end_pos], aminoacid_from_codon(agmp->ct,codon_from_seq(sal->seq[0]->seq+codon_end_pos-2)), sal->seq[1]->seq[codon_end_pos-2], sal->seq[1]->seq[codon_end_pos-1], sal->seq[1]->seq[codon_end_pos], aminoacid_from_codon(agmp->ct,codon_from_seq(sal->seq[1]->seq+codon_end_pos-2)) ); */ for(j=0;j<26;j++) { if( agmp->rm->aminoacid[j] < 0.0000000001 ) { continue; } c = agmp->rm->aminoacid[j]; for(i=0;ilen;i++) { if( !isalpha(sal->seq[i]->seq[codon_end_pos-2]) || !isalpha(sal->seq[i]->seq[codon_end_pos-1]) || !isalpha(sal->seq[i]->seq[codon_end_pos]) ) { return 0.0; } codon = codon_from_seq(sal->seq[i]->seq+codon_end_pos-2); if( is_stop_codon(codon,agmp->ct) ) { return 0.0; } f = agmp->protein->comp[j][aminoacid_from_codon(agmp->ct,codon)-'A']; /* fprintf(stdout,"For amino acid %c, match %.4f cum %.4f\n",j+'A', agmp->protein->comp[j][aminoacid_from_codon(agmp->ct,codon)-'A'], c); */ c = c*f; } out += c; } /* fprintf(stdout,"final %.4f\n",out);*/ return out; } # line 814 "aligngenemodel.dy" AlignGeneModelParam * new_AlignGeneModelParam_from_argv(int * argc,char ** argv) { AlignGeneModelParam * out; CompProb * cp; DnaProbMatrix * dm; GeneModelParam * gmp; GeneStats * gs; char * temp; double temp_prob; out = AlignGeneModelParam_alloc(); if( (temp = strip_out_assigned_argument(argc,argv,"am_codon")) == NULL ) { temp = "codon.table"; } out->ct = read_CodonTable_file(temp); assert(out->ct); if( (temp = strip_out_assigned_argument(argc,argv,"am_protein")) == NULL ) { temp = "wag85"; } out->protein = read_Blast_file_CompProb(temp); assert(out->protein); temp_prob = 0.85; strip_out_float_argument(argc,argv,"am_dna",&temp_prob); out->dm = DnaProbMatrix_from_match(0.85,NMaskType_VARIABLE); gmp = new_GeneModelParam_from_argv(argc,argv); if((gs=GeneStats_from_GeneModelParam(gmp)) == NULL ) { fatal("Could not build gene stats"); } out->gs = gs; out->rm = default_RandomModel(); out->ss5 = SpliceSiteProb_alloc(); out->ss5->pwm = pwmDNA_from_SeqAlign(gs->splice5,1); out->ss5->offset = gs->splice5_offset; fold_randommodel_pwmDNA(out->ss5->pwm,gs->rnd); out->ss3 = SpliceSiteProb_alloc(); out->ss3->pwm = pwmDNA_from_SeqAlign(gs->splice3,1); out->ss3->offset = gs->splice3_offset; fold_randommodel_pwmDNA(out->ss3->pwm,gs->rnd); out->nonanchor_stop = 0.001; strip_out_float_argument(argc,argv,"am_nonanchor_stop_pen",&out->nonanchor_stop); out->tolerate_nonanchor_stops = 1; strip_out_boolean_def_argument(argc,argv,"am_nonanchor_stop",&out->tolerate_nonanchor_stops); out->coding_window_thres = 3.0; strip_out_float_argument(argc,argv,"am_coding_bonus_thres",&out->coding_window_thres); out->noncoding_window_thres = 2.0; strip_out_float_argument(argc,argv,"am_noncoding_bonus_thres",&out->noncoding_window_thres); out->coding_window_bonus = 4.0; strip_out_float_argument(argc,argv,"am_coding_bonus_factor",&out->coding_window_bonus); out->noncoding_window_pen = 0.25; strip_out_float_argument(argc,argv,"am_noncoding_bonus_factor",&out->noncoding_window_pen); out->total_weight = 0.5; strip_out_float_argument(argc,argv,"am_overall_coding",&out->total_weight); return out; } # line 896 "aligngenemodel.dy" void show_help_AlignGeneModelParam(FILE * ofp) { fprintf(ofp,"Align Gene Model Parameters\n"); fprintf(ofp," -am_codon [codon.table] codon table\n"); fprintf(ofp," -am_protein [wag85] protein comparison probabilities\n"); fprintf(ofp," -am_dna [0.85] DNA non coding model match probability\n"); fprintf(ofp," -[no]am_nonanchor_stop allow stops in non anchor sequences [true]\n"); fprintf(ofp," -am_nonanchor_stop_pen penalty for non anchor stops when allowed [0.001]\n"); fprintf(ofp," -am_coding_bonus_thres coding threshold to use conservation window [3.0]\n"); fprintf(ofp," -am_noncoding_bonus_thres nonc threshold to use conservation window [2.0]\n"); fprintf(ofp," -am_coding_bonus_factor coding bonus factor when windowed [4.0]\n"); fprintf(ofp," -am_noncoding_bonus_factor nonc bonus factor when windowed [0.25]\n"); fprintf(ofp," -am_overall_coding overall per column \"odds-prior\" for coding [0.5]\n"); fprintf(ofp,"Gene Model statistics used by AlignModel\n"); show_help_GeneModelParam(ofp); return; } # line 918 "aligngenemodel.dy" AlignGeneModelParam * std_AlignGeneModelParam(CompProb * cp,DnaProbMatrix * dm,CodonTable * ct,GeneStats * gs,Probability change) { AlignGeneModelParam * out; out = AlignGeneModelParam_alloc(); assert(cp); assert(dm); assert(ct); assert(gs); assert(gs->splice5); assert(gs->splice5->len > 1); assert(gs->splice5->seq[0]->len > 0); assert(gs->splice3); assert(gs->splice3->len > 1); assert(gs->splice3->seq[0]->len > 0); out->ncsm = create_NonCodingSimpleModel(change); out->protein = hard_link_CompProb(cp); out->rm = default_RandomModel(); out->ct = hard_link_CodonTable(ct); out->dm = hard_link_DnaProbMatrix(dm); out->ss5 = SpliceSiteProb_alloc(); out->ss5->pwm = pwmDNA_from_SeqAlign(gs->splice5,1); out->ss5->offset = gs->splice5_offset; fold_randommodel_pwmDNA(out->ss5->pwm,gs->rnd); /* show_pwmDNA_col(out->ss5->pwm,stdout); fprintf(stdout,"\n"); */ out->ss3 = SpliceSiteProb_alloc(); out->ss3->pwm = pwmDNA_from_SeqAlign(gs->splice3,1); out->ss3->offset = gs->splice3_offset; fold_randommodel_pwmDNA(out->ss3->pwm,gs->rnd); /* show_pwmDNA_col(out->ss3->pwm,stdout); fprintf(stdout,"\n"); */ out->nonanchor_stop = 0.001; out->coding_window_thres = 3.0; out->noncoding_window_thres = 2.0; out->coding_window_bonus = 4.0; out->noncoding_window_pen = 0.25; out->tolerate_nonanchor_stops = 1; out->total_weight = 0.5; return out; } # line 975 "aligngenemodel.dy" AlignGeneModelScore * AlignGeneModelScore_from_AlignGeneModel(AlignGeneModel * agm) { AlignGeneModelScore * out; out = AlignGeneModelScore_alloc(); out->len = agm->len; out->forward_coding = calloc(agm->len,sizeof(Score)); out->reverse_coding = calloc(agm->len,sizeof(Score)); out->splice5_forward = calloc(agm->len,sizeof(Score)); out->splice3_forward = calloc(agm->len,sizeof(Score)); out->splice5_reverse = calloc(agm->len,sizeof(Score)); out->splice3_reverse = calloc(agm->len,sizeof(Score)); Probability2Score_move(agm->forward_coding,out->forward_coding,agm->len); Probability2Score_move(agm->reverse_coding,out->reverse_coding,agm->len); Probability2Score_move(agm->splice5_forward,out->splice5_forward,agm->len); Probability2Score_move(agm->splice3_forward,out->splice3_forward,agm->len); Probability2Score_move(agm->splice5_reverse,out->splice5_reverse,agm->len); Probability2Score_move(agm->splice3_reverse,out->splice3_reverse,agm->len); out->align = hard_link_SeqAlign(agm->align); out->anchor = hard_link_Sequence(agm->anchor); return out; } # line 1004 "aligngenemodel.dy" Probability * free_Probability(Probability * p) { ckfree(p); return NULL; } # line 1010 "aligngenemodel.dy" Score * free_Score(Score * p) { ckfree(p); return NULL; } # line 969 "aligngenemodel.c" /* Function: hard_link_NonCodingSimpleModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [NonCodingSimpleModel *] * * Return [UNKN ] Undocumented return value [NonCodingSimpleModel *] * */ NonCodingSimpleModel * hard_link_NonCodingSimpleModel(NonCodingSimpleModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a NonCodingSimpleModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: NonCodingSimpleModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [NonCodingSimpleModel *] * */ NonCodingSimpleModel * NonCodingSimpleModel_alloc(void) { NonCodingSimpleModel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(NonCodingSimpleModel *) ckalloc (sizeof(NonCodingSimpleModel))) == NULL) { warn("NonCodingSimpleModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->identical = 0.0; out->one_off = 0.0; out->two_off = 0.0; return out; } /* Function: free_NonCodingSimpleModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [NonCodingSimpleModel *] * * Return [UNKN ] Undocumented return value [NonCodingSimpleModel *] * */ NonCodingSimpleModel * free_NonCodingSimpleModel(NonCodingSimpleModel * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a NonCodingSimpleModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_SpliceSiteProb(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SpliceSiteProb *] * * Return [UNKN ] Undocumented return value [SpliceSiteProb *] * */ SpliceSiteProb * hard_link_SpliceSiteProb(SpliceSiteProb * obj) { if( obj == NULL ) { warn("Trying to hard link to a SpliceSiteProb object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SpliceSiteProb_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SpliceSiteProb *] * */ SpliceSiteProb * SpliceSiteProb_alloc(void) { SpliceSiteProb * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SpliceSiteProb *) ckalloc (sizeof(SpliceSiteProb))) == NULL) { warn("SpliceSiteProb_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->pwm = NULL; out->offset = 0; return out; } /* Function: free_SpliceSiteProb(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SpliceSiteProb *] * * Return [UNKN ] Undocumented return value [SpliceSiteProb *] * */ SpliceSiteProb * free_SpliceSiteProb(SpliceSiteProb * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SpliceSiteProb obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->pwm != NULL) free_pwmDNA(obj->pwm); ckfree(obj); return NULL; } /* Function: hard_link_AlignGeneColumnStore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlignGeneColumnStore *] * * Return [UNKN ] Undocumented return value [AlignGeneColumnStore *] * */ AlignGeneColumnStore * hard_link_AlignGeneColumnStore(AlignGeneColumnStore * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlignGeneColumnStore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlignGeneColumnStore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlignGeneColumnStore *] * */ AlignGeneColumnStore * AlignGeneColumnStore_alloc(void) { AlignGeneColumnStore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlignGeneColumnStore *) ckalloc (sizeof(AlignGeneColumnStore))) == NULL) { warn("AlignGeneColumnStore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->codon = NULL; out->len = 0; return out; } /* Function: free_AlignGeneColumnStore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlignGeneColumnStore *] * * Return [UNKN ] Undocumented return value [AlignGeneColumnStore *] * */ AlignGeneColumnStore * free_AlignGeneColumnStore(AlignGeneColumnStore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AlignGeneColumnStore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->codon != NULL) free_AlignGeneCodon(obj->codon); ckfree(obj); return NULL; } /* Function: hard_link_AlignGeneModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlignGeneModel *] * * Return [UNKN ] Undocumented return value [AlignGeneModel *] * */ AlignGeneModel * hard_link_AlignGeneModel(AlignGeneModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlignGeneModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlignGeneModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlignGeneModel *] * */ AlignGeneModel * AlignGeneModel_alloc(void) { AlignGeneModel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlignGeneModel *) ckalloc (sizeof(AlignGeneModel))) == NULL) { warn("AlignGeneModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->len = 0; out->forward_coding = NULL; out->reverse_coding = NULL; out->splice5_forward = NULL; out->splice3_forward = NULL; out->splice5_reverse = NULL; out->splice3_reverse = NULL; out->align = NULL; out->anchor = NULL; out->change_rate = NULL; return out; } /* Function: free_AlignGeneModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlignGeneModel *] * * Return [UNKN ] Undocumented return value [AlignGeneModel *] * */ AlignGeneModel * free_AlignGeneModel(AlignGeneModel * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AlignGeneModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->forward_coding != NULL) free_Probability(obj->forward_coding); if( obj->reverse_coding != NULL) free_Probability(obj->reverse_coding); if( obj->splice5_forward != NULL) free_Probability(obj->splice5_forward); if( obj->splice3_forward != NULL) free_Probability(obj->splice3_forward); if( obj->splice5_reverse != NULL) free_Probability(obj->splice5_reverse); if( obj->splice3_reverse != NULL) free_Probability(obj->splice3_reverse); if( obj->align != NULL) free_SeqAlign(obj->align); if( obj->anchor != NULL) free_Sequence(obj->anchor); if( obj->change_rate != NULL) ckfree(obj->change_rate); ckfree(obj); return NULL; } /* Function: hard_link_AlignGeneModelScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlignGeneModelScore *] * * Return [UNKN ] Undocumented return value [AlignGeneModelScore *] * */ AlignGeneModelScore * hard_link_AlignGeneModelScore(AlignGeneModelScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlignGeneModelScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlignGeneModelScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlignGeneModelScore *] * */ AlignGeneModelScore * AlignGeneModelScore_alloc(void) { AlignGeneModelScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlignGeneModelScore *) ckalloc (sizeof(AlignGeneModelScore))) == NULL) { warn("AlignGeneModelScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->len = 0; out->forward_coding = NULL; out->reverse_coding = NULL; out->splice5_forward = NULL; out->splice3_forward = NULL; out->splice5_reverse = NULL; out->splice3_reverse = NULL; out->align = NULL; out->anchor = NULL; return out; } /* Function: free_AlignGeneModelScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlignGeneModelScore *] * * Return [UNKN ] Undocumented return value [AlignGeneModelScore *] * */ AlignGeneModelScore * free_AlignGeneModelScore(AlignGeneModelScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AlignGeneModelScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->forward_coding != NULL) free_Score(obj->forward_coding); if( obj->reverse_coding != NULL) free_Score(obj->reverse_coding); if( obj->splice5_forward != NULL) free_Score(obj->splice5_forward); if( obj->splice3_forward != NULL) free_Score(obj->splice3_forward); if( obj->splice5_reverse != NULL) free_Score(obj->splice5_reverse); if( obj->splice3_reverse != NULL) free_Score(obj->splice3_reverse); if( obj->align != NULL) free_SeqAlign(obj->align); if( obj->anchor != NULL) free_Sequence(obj->anchor); ckfree(obj); return NULL; } /* Function: hard_link_AlignGeneModelParam(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlignGeneModelParam *] * * Return [UNKN ] Undocumented return value [AlignGeneModelParam *] * */ AlignGeneModelParam * hard_link_AlignGeneModelParam(AlignGeneModelParam * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlignGeneModelParam object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlignGeneModelParam_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlignGeneModelParam *] * */ AlignGeneModelParam * AlignGeneModelParam_alloc(void) { AlignGeneModelParam * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlignGeneModelParam *) ckalloc (sizeof(AlignGeneModelParam))) == NULL) { warn("AlignGeneModelParam_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->protein = NULL; out->rm = NULL; out->cm = NULL; out->ct = NULL; out->dm = NULL; out->ss5 = NULL; out->ss3 = NULL; out->gs = NULL; out->total_weight = 2; out->tolerate_nonanchor_stops = TRUE; out->nonanchor_stop = 0.0; out->ncsm = NULL; out->coding_window_thres = 0; out->noncoding_window_thres = 0; out->coding_window_bonus = 0; out->noncoding_window_pen = 0; return out; } /* Function: free_AlignGeneModelParam(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlignGeneModelParam *] * * Return [UNKN ] Undocumented return value [AlignGeneModelParam *] * */ AlignGeneModelParam * free_AlignGeneModelParam(AlignGeneModelParam * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AlignGeneModelParam obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->protein != NULL) free_CompProb(obj->protein); if( obj->rm != NULL) free_RandomModel(obj->rm); if( obj->cm != NULL) free_CodonMapper(obj->cm); if( obj->ct != NULL) free_CodonTable(obj->ct); if( obj->dm != NULL) free_DnaProbMatrix(obj->dm); if( obj->ss5 != NULL) free_SpliceSiteProb(obj->ss5); if( obj->ss3 != NULL) free_SpliceSiteProb(obj->ss3); if( obj->gs != NULL) free_GeneStats(obj->gs); if( obj->ncsm != NULL) free_NonCodingSimpleModel(obj->ncsm); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/aligngenemodel.h0000644000175000001440000003673510670453713017272 0ustar philippusers#ifndef DYNAMITEaligngenemodelHEADERFILE #define DYNAMITEaligngenemodelHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "pwmdna.h" #include "genestats.h" typedef struct align_gene_codon { char seq[3]; double weight; } AlignGeneCodon; struct Wise2_NonCodingSimpleModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability identical; Probability one_off; Probability two_off; } ; /* NonCodingSimpleModel defined */ #ifndef DYNAMITE_DEFINED_NonCodingSimpleModel typedef struct Wise2_NonCodingSimpleModel Wise2_NonCodingSimpleModel; #define NonCodingSimpleModel Wise2_NonCodingSimpleModel #define DYNAMITE_DEFINED_NonCodingSimpleModel #endif struct Wise2_SpliceSiteProb { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif pwmDNA * pwm; int offset; } ; /* SpliceSiteProb defined */ #ifndef DYNAMITE_DEFINED_SpliceSiteProb typedef struct Wise2_SpliceSiteProb Wise2_SpliceSiteProb; #define SpliceSiteProb Wise2_SpliceSiteProb #define DYNAMITE_DEFINED_SpliceSiteProb #endif struct Wise2_AlignGeneColumnStore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif AlignGeneCodon * codon; int len; } ; /* AlignGeneColumnStore defined */ #ifndef DYNAMITE_DEFINED_AlignGeneColumnStore typedef struct Wise2_AlignGeneColumnStore Wise2_AlignGeneColumnStore; #define AlignGeneColumnStore Wise2_AlignGeneColumnStore #define DYNAMITE_DEFINED_AlignGeneColumnStore #endif struct Wise2_AlignGeneModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int len; Probability * forward_coding; Probability * reverse_coding; Probability * splice5_forward; Probability * splice3_forward; Probability * splice5_reverse; Probability * splice3_reverse; SeqAlign * align; Sequence * anchor; double * change_rate; } ; /* AlignGeneModel defined */ #ifndef DYNAMITE_DEFINED_AlignGeneModel typedef struct Wise2_AlignGeneModel Wise2_AlignGeneModel; #define AlignGeneModel Wise2_AlignGeneModel #define DYNAMITE_DEFINED_AlignGeneModel #endif struct Wise2_AlignGeneModelScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int len; Score * forward_coding; Score * reverse_coding; Score * splice5_forward; Score * splice3_forward; Score * splice5_reverse; Score * splice3_reverse; SeqAlign * align; Sequence * anchor; } ; /* AlignGeneModelScore defined */ #ifndef DYNAMITE_DEFINED_AlignGeneModelScore typedef struct Wise2_AlignGeneModelScore Wise2_AlignGeneModelScore; #define AlignGeneModelScore Wise2_AlignGeneModelScore #define DYNAMITE_DEFINED_AlignGeneModelScore #endif struct Wise2_AlignGeneModelParam { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif CompProb * protein; RandomModel * rm; CodonMapper * cm; CodonTable * ct; DnaProbMatrix * dm; SpliceSiteProb * ss5; SpliceSiteProb * ss3; GeneStats * gs; Probability total_weight; boolean tolerate_nonanchor_stops; Probability nonanchor_stop; NonCodingSimpleModel * ncsm; double coding_window_thres; double noncoding_window_thres; double coding_window_bonus; double noncoding_window_pen; } ; /* AlignGeneModelParam defined */ #ifndef DYNAMITE_DEFINED_AlignGeneModelParam typedef struct Wise2_AlignGeneModelParam Wise2_AlignGeneModelParam; #define AlignGeneModelParam Wise2_AlignGeneModelParam #define DYNAMITE_DEFINED_AlignGeneModelParam #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_NonCodingSimpleModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [NonCodingSimpleModel *] * * Return [UNKN ] Undocumented return value [NonCodingSimpleModel *] * */ NonCodingSimpleModel * Wise2_hard_link_NonCodingSimpleModel(NonCodingSimpleModel * obj); #define hard_link_NonCodingSimpleModel Wise2_hard_link_NonCodingSimpleModel /* Function: NonCodingSimpleModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [NonCodingSimpleModel *] * */ NonCodingSimpleModel * Wise2_NonCodingSimpleModel_alloc(void); #define NonCodingSimpleModel_alloc Wise2_NonCodingSimpleModel_alloc /* Function: free_NonCodingSimpleModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [NonCodingSimpleModel *] * * Return [UNKN ] Undocumented return value [NonCodingSimpleModel *] * */ NonCodingSimpleModel * Wise2_free_NonCodingSimpleModel(NonCodingSimpleModel * obj); #define free_NonCodingSimpleModel Wise2_free_NonCodingSimpleModel /* Function: hard_link_SpliceSiteProb(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SpliceSiteProb *] * * Return [UNKN ] Undocumented return value [SpliceSiteProb *] * */ SpliceSiteProb * Wise2_hard_link_SpliceSiteProb(SpliceSiteProb * obj); #define hard_link_SpliceSiteProb Wise2_hard_link_SpliceSiteProb /* Function: SpliceSiteProb_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SpliceSiteProb *] * */ SpliceSiteProb * Wise2_SpliceSiteProb_alloc(void); #define SpliceSiteProb_alloc Wise2_SpliceSiteProb_alloc /* Function: free_SpliceSiteProb(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SpliceSiteProb *] * * Return [UNKN ] Undocumented return value [SpliceSiteProb *] * */ SpliceSiteProb * Wise2_free_SpliceSiteProb(SpliceSiteProb * obj); #define free_SpliceSiteProb Wise2_free_SpliceSiteProb /* Function: hard_link_AlignGeneColumnStore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlignGeneColumnStore *] * * Return [UNKN ] Undocumented return value [AlignGeneColumnStore *] * */ AlignGeneColumnStore * Wise2_hard_link_AlignGeneColumnStore(AlignGeneColumnStore * obj); #define hard_link_AlignGeneColumnStore Wise2_hard_link_AlignGeneColumnStore /* Function: AlignGeneColumnStore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlignGeneColumnStore *] * */ AlignGeneColumnStore * Wise2_AlignGeneColumnStore_alloc(void); #define AlignGeneColumnStore_alloc Wise2_AlignGeneColumnStore_alloc /* Function: free_AlignGeneColumnStore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlignGeneColumnStore *] * * Return [UNKN ] Undocumented return value [AlignGeneColumnStore *] * */ AlignGeneColumnStore * Wise2_free_AlignGeneColumnStore(AlignGeneColumnStore * obj); #define free_AlignGeneColumnStore Wise2_free_AlignGeneColumnStore /* Function: hard_link_AlignGeneModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlignGeneModel *] * * Return [UNKN ] Undocumented return value [AlignGeneModel *] * */ AlignGeneModel * Wise2_hard_link_AlignGeneModel(AlignGeneModel * obj); #define hard_link_AlignGeneModel Wise2_hard_link_AlignGeneModel /* Function: AlignGeneModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlignGeneModel *] * */ AlignGeneModel * Wise2_AlignGeneModel_alloc(void); #define AlignGeneModel_alloc Wise2_AlignGeneModel_alloc /* Function: free_AlignGeneModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlignGeneModel *] * * Return [UNKN ] Undocumented return value [AlignGeneModel *] * */ AlignGeneModel * Wise2_free_AlignGeneModel(AlignGeneModel * obj); #define free_AlignGeneModel Wise2_free_AlignGeneModel /* Function: hard_link_AlignGeneModelScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlignGeneModelScore *] * * Return [UNKN ] Undocumented return value [AlignGeneModelScore *] * */ AlignGeneModelScore * Wise2_hard_link_AlignGeneModelScore(AlignGeneModelScore * obj); #define hard_link_AlignGeneModelScore Wise2_hard_link_AlignGeneModelScore /* Function: AlignGeneModelScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlignGeneModelScore *] * */ AlignGeneModelScore * Wise2_AlignGeneModelScore_alloc(void); #define AlignGeneModelScore_alloc Wise2_AlignGeneModelScore_alloc /* Function: free_AlignGeneModelScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlignGeneModelScore *] * * Return [UNKN ] Undocumented return value [AlignGeneModelScore *] * */ AlignGeneModelScore * Wise2_free_AlignGeneModelScore(AlignGeneModelScore * obj); #define free_AlignGeneModelScore Wise2_free_AlignGeneModelScore /* Function: hard_link_AlignGeneModelParam(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlignGeneModelParam *] * * Return [UNKN ] Undocumented return value [AlignGeneModelParam *] * */ AlignGeneModelParam * Wise2_hard_link_AlignGeneModelParam(AlignGeneModelParam * obj); #define hard_link_AlignGeneModelParam Wise2_hard_link_AlignGeneModelParam /* Function: AlignGeneModelParam_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlignGeneModelParam *] * */ AlignGeneModelParam * Wise2_AlignGeneModelParam_alloc(void); #define AlignGeneModelParam_alloc Wise2_AlignGeneModelParam_alloc /* Function: free_AlignGeneModelParam(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlignGeneModelParam *] * * Return [UNKN ] Undocumented return value [AlignGeneModelParam *] * */ AlignGeneModelParam * Wise2_free_AlignGeneModelParam(AlignGeneModelParam * obj); #define free_AlignGeneModelParam Wise2_free_AlignGeneModelParam /* Unplaced functions */ /* There has been no indication of the use of these functions */ Probability Wise2_weighted_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp); #define weighted_coding_AlignGeneColumn Wise2_weighted_coding_AlignGeneColumn void Wise2_window_AlignGeneModel(SeqAlign * sal,AlignGeneModel * agm,AlignGeneModelParam * agmp); #define window_AlignGeneModel Wise2_window_AlignGeneModel NonCodingSimpleModel * Wise2_create_NonCodingSimpleModel(Probability change); #define create_NonCodingSimpleModel Wise2_create_NonCodingSimpleModel Probability Wise2_simple_non_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp); #define simple_non_coding_AlignGeneColumn Wise2_simple_non_coding_AlignGeneColumn Probability Wise2_weighted_non_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp); #define weighted_non_coding_AlignGeneColumn Wise2_weighted_non_coding_AlignGeneColumn Probability Wise2_weighted_simple_non_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp); #define weighted_simple_non_coding_AlignGeneColumn Wise2_weighted_simple_non_coding_AlignGeneColumn Probability Wise2_simple_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp); #define simple_coding_AlignGeneColumn Wise2_simple_coding_AlignGeneColumn boolean Wise2_fill_reverse_AlignGeneColumn(AlignGeneColumnStore * store,SeqAlign * sa,int forward_codon_end); #define fill_reverse_AlignGeneColumn Wise2_fill_reverse_AlignGeneColumn boolean Wise2_fill_forward_AlignGeneColumn(AlignGeneColumnStore * store,SeqAlign * sa,int codon_end); #define fill_forward_AlignGeneColumn Wise2_fill_forward_AlignGeneColumn AlignGeneColumnStore * Wise2_new_empty_AlignGeneColumnStore(int len); #define new_empty_AlignGeneColumnStore Wise2_new_empty_AlignGeneColumnStore AlignGeneCodon * Wise2_free_AlignGeneCodon(AlignGeneCodon * c); #define free_AlignGeneCodon Wise2_free_AlignGeneCodon AlignGeneModel * Wise2_new_AlignGeneModel(int len); #define new_AlignGeneModel Wise2_new_AlignGeneModel void Wise2_show_AlignGeneModel(AlignGeneModel * agm,SeqAlign * sal,CodonTable * ct,GenomicRegion * gr,FILE * ofp,AlignGeneModelParam * agmp); #define show_AlignGeneModel Wise2_show_AlignGeneModel AlignGeneModel * Wise2_create_AlignGeneModel(SeqAlign * sal,AlignGeneModelParam * agmp); #define create_AlignGeneModel Wise2_create_AlignGeneModel Probability Wise2_prob_SpliceSiteProb(SpliceSiteProb * ssp,Sequence * seq,int pos); #define prob_SpliceSiteProb Wise2_prob_SpliceSiteProb Probability Wise2_non_coding_probability_AlignGeneModel(SeqAlign * sal,int codon_end_pos,AlignGeneModelParam * agmp); #define non_coding_probability_AlignGeneModel Wise2_non_coding_probability_AlignGeneModel Probability Wise2_coding_probability_AlignGeneModel(SeqAlign * sal,int codon_end_pos,AlignGeneModelParam * agmp); #define coding_probability_AlignGeneModel Wise2_coding_probability_AlignGeneModel AlignGeneModelParam * Wise2_new_AlignGeneModelParam_from_argv(int * argc,char ** argv); #define new_AlignGeneModelParam_from_argv Wise2_new_AlignGeneModelParam_from_argv void Wise2_show_help_AlignGeneModelParam(FILE * ofp); #define show_help_AlignGeneModelParam Wise2_show_help_AlignGeneModelParam AlignGeneModelParam * Wise2_std_AlignGeneModelParam(CompProb * cp,DnaProbMatrix * dm,CodonTable * ct,GeneStats * gs,Probability change); #define std_AlignGeneModelParam Wise2_std_AlignGeneModelParam AlignGeneModelScore * Wise2_AlignGeneModelScore_from_AlignGeneModel(AlignGeneModel * agm); #define AlignGeneModelScore_from_AlignGeneModel Wise2_AlignGeneModelScore_from_AlignGeneModel Probability * Wise2_free_Probability(Probability * p); #define free_Probability Wise2_free_Probability Score * Wise2_free_Score(Score * p); #define free_Score Wise2_free_Score /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/threestatemodel_api.h0000644000175000001440000003300110670453715020323 0ustar philippusers /* Functions that create, manipulate or act on ThreeStateModel * * Wise2_force_global_model * Wise2_force_weighted_local_model * Wise2_ThreeStateModel_from_half_bit_Sequence * Wise2_write_HMMer_1_7_ascii_ThreeStateModel * Wise2_hard_link_ThreeStateModel * Wise2_ThreeStateModel_alloc_std * Wise2_replace_name_ThreeStateModel * Wise2_access_name_ThreeStateModel * Wise2_access_unit_ThreeStateModel * Wise2_length_unit_ThreeStateModel * Wise2_flush_ThreeStateModel * Wise2_add_ThreeStateModel * Wise2_replace_alphabet_ThreeStateModel * Wise2_access_alphabet_ThreeStateModel * Wise2_replace_accession_ThreeStateModel * Wise2_access_accession_ThreeStateModel * Wise2_replace_threshold_ThreeStateModel * Wise2_access_threshold_ThreeStateModel * Wise2_replace_rm_ThreeStateModel * Wise2_access_rm_ThreeStateModel * Wise2_free_ThreeStateModel [destructor] * */ /* Functions that create, manipulate or act on ThreeStateUnit * * Wise2_hard_link_ThreeStateUnit * Wise2_ThreeStateUnit_alloc * Wise2_replace_display_char_ThreeStateUnit * Wise2_access_display_char_ThreeStateUnit * Wise2_free_ThreeStateUnit [destructor] * */ /* Helper functions in the module * * Wise2_read_HMMer_1_7_ascii_file * Wise2_read_HMMer_1_7_ascii * /* API for object ThreeStateModel */ /* Function: Wise2_force_global_model(tsm,prob_into_model) * * Descrip: Makes start at position 0 and end at position end, * no other positions being valid * * * * Arg: tsm ThreeStateModel to be 'forced' [Wise2_ThreeStateModel *] * Arg: prob_into_model Probability to start the model: for true global will be 1.0 [double] * * Returns Undocumented return value [void] * */ void Wise2_force_global_model( Wise2_ThreeStateModel * tsm,double prob_into_model); /* Function: Wise2_force_weighted_local_model(tsm,prob_into_model,ratio_start,ratio_end) * * Descrip: places the ratio of probability to start/end, * and then distributes the rest over the start/end * * * * Arg: tsm ThreeStateModel to be 'forced' [Wise2_ThreeStateModel *] * Arg: prob_into_model Probability to start the model: for true global will be 1.0 [double] * Arg: ratio_start ratio of prob to unit 0 to the rest (1.0 means all goes to start) [double] * Arg: ratio_end ratio of prob to unit (last) to the rest (1.0 means all goes to the end) [double] * * Returns Undocumented return value [void] * */ void Wise2_force_weighted_local_model( Wise2_ThreeStateModel * tsm,double prob_into_model,double ratio_start,double ratio_end); /* Function: Wise2_ThreeStateModel_from_half_bit_Sequence(pro,mat,rm,gap,ext) * * Descrip: Makes a local three-state-model from a sequence. this is scary * hackery, assumming that the matrix is half-bits and normalising in a * *very* wrong way to get "probabilities" out. * * Works though * * * Arg: pro protein sequence [Wise2_Protein *] * Arg: mat comparison matrix to use [Wise2_CompMat *] * Arg: rm random model which you assumme the matrix was built with [Wise2_RandomModel *] * Arg: gap gap open penalty [int] * Arg: ext gap ext penalty [int] * * Returns Undocumented return value [Wise2_ThreeStateModel *] * */ Wise2_ThreeStateModel * Wise2_ThreeStateModel_from_half_bit_Sequence( Wise2_Protein * pro,Wise2_CompMat * mat,Wise2_RandomModel * rm,int gap,int ext); /* Function: Wise2_write_HMMer_1_7_ascii_ThreeStateModel(tsm,ofp) * * Descrip: writes a HMMer version 1.7 (also ok with 1.8) file * * * Arg: tsm Undocumented argument [Wise2_ThreeStateModel *] * Arg: ofp Undocumented argument [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_write_HMMer_1_7_ascii_ThreeStateModel( Wise2_ThreeStateModel * tsm,FILE * ofp); /* Function: Wise2_hard_link_ThreeStateModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_ThreeStateModel *] * * Returns Undocumented return value [Wise2_ThreeStateModel *] * */ Wise2_ThreeStateModel * Wise2_hard_link_ThreeStateModel( Wise2_ThreeStateModel * obj); /* Function: Wise2_ThreeStateModel_alloc_std(void) * * Descrip: Equivalent to ThreeStateModel_alloc_len(ThreeStateModelLISTLENGTH) * * * * Returns Undocumented return value [Wise2_ThreeStateModel *] * */ Wise2_ThreeStateModel * Wise2_ThreeStateModel_alloc_std(); /* Function: Wise2_replace_name_ThreeStateModel(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateModel *] * Arg: name New value of the variable [char *] * * Returns member variable name [boolean] * */ boolean Wise2_replace_name_ThreeStateModel( Wise2_ThreeStateModel * obj,char * name); /* Function: Wise2_access_name_ThreeStateModel(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateModel *] * * Returns member variable name [char *] * */ char * Wise2_access_name_ThreeStateModel( Wise2_ThreeStateModel * obj); /* Function: Wise2_access_unit_ThreeStateModel(obj,i) * * Descrip: Access members stored in the unit list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_ThreeStateModel *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_ThreeStateUnit *] * */ Wise2_ThreeStateUnit * Wise2_access_unit_ThreeStateModel( Wise2_ThreeStateModel * obj,int i); /* Function: Wise2_length_unit_ThreeStateModel(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_ThreeStateModel *] * * Returns length of the list [int] * */ int Wise2_length_unit_ThreeStateModel( Wise2_ThreeStateModel * obj); /* Function: Wise2_flush_ThreeStateModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_ThreeStateModel *] * * Returns Undocumented return value [int] * */ int Wise2_flush_ThreeStateModel( Wise2_ThreeStateModel * obj); /* Function: Wise2_add_ThreeStateModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_ThreeStateModel *] * Arg: add Object to add to the list [Wise2_ThreeStateUnit *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_ThreeStateModel( Wise2_ThreeStateModel * obj,Wise2_ThreeStateUnit * add); /* Function: Wise2_replace_alphabet_ThreeStateModel(obj,alphabet) * * Descrip: Replace member variable alphabet * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateModel *] * Arg: alphabet New value of the variable [char *] * * Returns member variable alphabet [boolean] * */ boolean Wise2_replace_alphabet_ThreeStateModel( Wise2_ThreeStateModel * obj,char * alphabet); /* Function: Wise2_access_alphabet_ThreeStateModel(obj) * * Descrip: Access member variable alphabet * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateModel *] * * Returns member variable alphabet [char *] * */ char * Wise2_access_alphabet_ThreeStateModel( Wise2_ThreeStateModel * obj); /* Function: Wise2_replace_accession_ThreeStateModel(obj,accession) * * Descrip: Replace member variable accession * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateModel *] * Arg: accession New value of the variable [char *] * * Returns member variable accession [boolean] * */ boolean Wise2_replace_accession_ThreeStateModel( Wise2_ThreeStateModel * obj,char * accession); /* Function: Wise2_access_accession_ThreeStateModel(obj) * * Descrip: Access member variable accession * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateModel *] * * Returns member variable accession [char *] * */ char * Wise2_access_accession_ThreeStateModel( Wise2_ThreeStateModel * obj); /* Function: Wise2_replace_threshold_ThreeStateModel(obj,threshold) * * Descrip: Replace member variable threshold * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateModel *] * Arg: threshold New value of the variable [double] * * Returns member variable threshold [boolean] * */ boolean Wise2_replace_threshold_ThreeStateModel( Wise2_ThreeStateModel * obj,double threshold); /* Function: Wise2_access_threshold_ThreeStateModel(obj) * * Descrip: Access member variable threshold * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateModel *] * * Returns member variable threshold [double] * */ double Wise2_access_threshold_ThreeStateModel( Wise2_ThreeStateModel * obj); /* Function: Wise2_replace_rm_ThreeStateModel(obj,rm) * * Descrip: Replace member variable rm * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateModel *] * Arg: rm New value of the variable [Wise2_RandomModel *] * * Returns member variable rm [boolean] * */ boolean Wise2_replace_rm_ThreeStateModel( Wise2_ThreeStateModel * obj,Wise2_RandomModel * rm); /* Function: Wise2_access_rm_ThreeStateModel(obj) * * Descrip: Access member variable rm * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateModel *] * * Returns member variable rm [Wise2_RandomModel *] * */ Wise2_RandomModel * Wise2_access_rm_ThreeStateModel( Wise2_ThreeStateModel * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_ThreeStateModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_ThreeStateModel *] * * Returns Undocumented return value [Wise2_ThreeStateModel *] * */ Wise2_ThreeStateModel * Wise2_free_ThreeStateModel( Wise2_ThreeStateModel * obj); /* API for object ThreeStateUnit */ /* Function: Wise2_hard_link_ThreeStateUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_ThreeStateUnit *] * * Returns Undocumented return value [Wise2_ThreeStateUnit *] * */ Wise2_ThreeStateUnit * Wise2_hard_link_ThreeStateUnit( Wise2_ThreeStateUnit * obj); /* Function: Wise2_ThreeStateUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_ThreeStateUnit *] * */ Wise2_ThreeStateUnit * Wise2_ThreeStateUnit_alloc(); /* Function: Wise2_replace_display_char_ThreeStateUnit(obj,display_char) * * Descrip: Replace member variable display_char * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateUnit *] * Arg: display_char New value of the variable [char] * * Returns member variable display_char [boolean] * */ boolean Wise2_replace_display_char_ThreeStateUnit( Wise2_ThreeStateUnit * obj,char display_char); /* Function: Wise2_access_display_char_ThreeStateUnit(obj) * * Descrip: Access member variable display_char * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateUnit *] * * Returns member variable display_char [char] * */ char Wise2_access_display_char_ThreeStateUnit( Wise2_ThreeStateUnit * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_ThreeStateUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_ThreeStateUnit *] * * Returns Undocumented return value [Wise2_ThreeStateUnit *] * */ Wise2_ThreeStateUnit * Wise2_free_ThreeStateUnit( Wise2_ThreeStateUnit * obj); /* These functions are not associated with an object */ /* Function: Wise2_read_HMMer_1_7_ascii_file(filename) * * Descrip: reads a HMMer ascii version 1.7 (1.8) file from filename. * * * * Arg: filename the name fo the hmmer file [char *] * * Returns Undocumented return value [Wise2_ThreeStateModel *] * */ Wise2_ThreeStateModel * Wise2_read_HMMer_1_7_ascii_file( char * filename); /* Function: Wise2_read_HMMer_1_7_ascii(ifp) * * Descrip: Basic function to read HMMer version 1.7(1.8) files. * * * Arg: ifp Undocumented argument [FILE *] * * Returns Undocumented return value [Wise2_ThreeStateModel *] * */ Wise2_ThreeStateModel * Wise2_read_HMMer_1_7_ascii( FILE * ifp); wise-2.4.1/src/models/threestatemodel_api.t0000644000175000001440000000017010670453715020340 0ustar philippuserstypedef struct Wise2_ThreeStateModel Wise2_ThreeStateModel; typedef struct Wise2_ThreeStateUnit Wise2_ThreeStateUnit; wise-2.4.1/src/models/estloop3.dy0000644000175000001440000001412607530250520016233 0ustar philippusers/* Last edited: Apr 24 15:04 1997 (birney) */ %{ #include "dyna.h" #include "cdparser.h" #include "genewisemodel.h" #include "genewisemodeldb.h" %} matrix EstLoop3 query type="GENEWISEMODEL" name="query" field:len="len" target type="CDNA" name="target" resource type="cDNAParserScore *" name="cp" extern name="GW_*" type="int" extern name="PCD_*" type="int" state MATCH offi="1" offj="3" source MATCH calc="query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source LOOP calc="query->seg[i]->transition[GW_START2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource # # Sequencing error transitions, at offsets 1,2,4,5 for delete 1,2 or insert 1,2 # source MATCH offi="1" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source MATCH offi="1" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource source INSERT offi="1" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="1" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="1" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source INSERT offi="1" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource source DELETE offi="1" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source DELETE offi="1" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source DELETE offi="1" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source DELETE offi="1" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource query_label MATCH_STATE target_label CODON endstate # # Insert state: does not move along model, produces DNA sequence... # state INSERT offi="0" offj="3" source MATCH calc="query->seg[i]->transition[GW_MATCH2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source LOOP calc="query->seg[i]->transition[GW_START2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource # # Sequencing error transitions # source INSERT offi="0" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source INSERT offi="0" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource source MATCH offi="0" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="0" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="0" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source MATCH offi="0" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource source DELETE offi="0" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source DELETE offi="0" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source DELETE offi="0" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source DELETE offi="0" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="query->seg[i]->transition[GW_MATCH2DELETE]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2DELETE]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2DELETE]" endsource source LOOP calc="query->seg[i]->transition[GW_START2DELETE]" endsource query_label DELETE_STATE target_label INSERT endstate state LOOP !special source START offj="1" !left calc="0" endsource source MATCH calc="query->seg[i]->transition[GW_MATCH2END]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2END]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2END]" endsource source LOOP offj="1" calc="0" endsource target_label RANDOM_SEQUENCE query_label LOOP endstate state START !start !special endstate state END !end !special source LOOP !right offj="1" calc="0" endsource source MATCH calc="query->seg[i]->transition[GW_MATCH2END]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2END]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2END]" endsource target_label END query_label END endstate # collapse labels collapse LOOP RANDOM_SEQUENCE endmatrix wise-2.4.1/src/models/genewisemodeldb.c0000644000175000001440000003727710670453714017453 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genewisemodeldb.h" /* Function: init_GeneWiseDB(gdb,return_status) * * Descrip: inits a genewise database. Remember this is used * for both genomic and cdna searches * * * * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ # line 47 "genewisemodeldb.dy" GeneWiseScore * init_GeneWiseDB(GeneWiseDB * gdb,int * return_status) { ThreeStateModel * tsm; GeneWise * gw; GeneWiseScore * gws; *return_status = DB_RETURN_ERROR; if( gdb->is_single == TRUE ) { *return_status = DB_RETURN_OK; return gdb->gws; } if( open_ThreeStateDB(gdb->tdb) == FALSE ) { warn("Could not open three state db, so no genewisemodel possible!"); return NULL; } tsm = read_TSM_ThreeStateDB(gdb->tdb,return_status); if( *return_status == DB_RETURN_ERROR) { warn("Cannot read a ThreeStateModelDB for the GeneWiseDB. Problem!"); return NULL; } gw = GeneWise_from_ThreeStateModel_GDB(tsm,gdb); gws = GeneWiseScore_from_GeneWise(gw); free_ThreeStateModel(tsm); free_GeneWise(gw); return gws; } /* Function: reload_GeneWiseDB(prev,gdb,return_status) * * Descrip: Reloads a genewise database * * * * Arg: prev [UNKN ] Undocumented argument [GeneWiseScore *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ # line 87 "genewisemodeldb.dy" GeneWiseScore * reload_GeneWiseDB(GeneWiseScore * prev,GeneWiseDB * gdb,int * return_status) { ThreeStateModel * tsm; GeneWise * gw; GeneWiseScore * gws; if( gdb->is_single == TRUE ) { *return_status = DB_RETURN_END; return NULL; } if( prev != NULL) free_GeneWiseScore(prev); *return_status = DB_RETURN_ERROR; tsm = read_TSM_ThreeStateDB(gdb->tdb,return_status); if( *return_status != DB_RETURN_OK) { if( *return_status == DB_RETURN_END) { return NULL; } warn("Cannot read a ThreeStateModelDB for the GeneWiseDB. Problem!"); return NULL; } gw = GeneWise_from_ThreeStateModel_GDB(tsm,gdb); gws = GeneWiseScore_from_GeneWise(gw); free_ThreeStateModel(tsm); free_GeneWise(gw); *return_status = DB_RETURN_OK; return gws; } /* Function: close_GeneWiseDB(gws,gdb) * * Descrip: closes a GeneWiseDB * * * Arg: gws [UNKN ] Undocumented argument [GeneWiseScore *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 133 "genewisemodeldb.dy" boolean close_GeneWiseDB(GeneWiseScore * gws,GeneWiseDB * gdb) { if( gdb->is_single == TRUE ) { return TRUE; } if( gws != NULL) free_GeneWiseScore(gws); return close_ThreeStateDB(NULL,gdb->tdb); } /* Function: dataentry_add_GeneWiseDB(de,gws,gdb) * * Descrip: adds dataentry stuff to a query. Relies completely * on threestatedb * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: gws [UNKN ] Undocumented argument [GeneWiseScore *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 149 "genewisemodeldb.dy" boolean dataentry_add_GeneWiseDB(DataEntry * de,GeneWiseScore * gws,GeneWiseDB * gdb) { if( gdb->is_single == TRUE) { if ( gdb->gws->name == NULL ) { warn("No name for a single GeneWiseDB unit."); de->name = stringalloc("NoName"); } else { de->name = stringalloc(gdb->gws->name); } return TRUE; } /*de->name = stringalloc(gws->name);*/ /* otherwise, pass it on to tdb */ dataentry_add_ThreeStateDB(de,NULL,gdb->tdb); if( de->name == NULL ) { if( gws->name != NULL ) { de->name = stringalloc(gws->name); } } return TRUE; } /* Function: GeneWise_from_ThreeStateModel_GDB(tsm,gdb) * * Descrip: Makes a genewise models from the threestatemodel * and parameters held in the GeneWiseDB * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [GeneWise *] * */ # line 180 "genewisemodeldb.dy" GeneWise * GeneWise_from_ThreeStateModel_GDB(ThreeStateModel * tsm,GeneWiseDB * gdb) { int i; GeneWise * out; if( gdb->gpara != NULL ) { out=GeneWise_from_ThreeStateModel(tsm,gdb->gpara->gp,gdb->gpara->cm,gdb->allN,gdb->gpara->gwcm); if( out == NULL ) { return NULL; } if( gdb->gpara->modelled_splice == FALSE) flatten_balance_scores_GeneWise(out); } else { out = GeneWise_alloc_len(tsm->len); out->name = stringalloc(tsm->name); for(i=0;ilen;i++) { add_GeneWise(out,GeneWiseSegment_from_ThreeStateUnit(tsm->unit[i],gdb->cds_factor,gdb->cm,NULL,gdb->allN)); } } if( gdb->is_syn == TRUE ) { if( tsm->rm == NULL ) { warn("Bad error. ThreeStateModel does not have a random model!"); return free_GeneWise(out); } GeneWise_fold_in_synchronised_RandomModel(out,tsm->rm,gdb->cm,gdb->cm->ct,0.5); } else { GeneWise_fold_in_RandomModelDNA(out,gdb->rmd); } if( gdb->flat_insert == TRUE ) { check_flat_insert(out,1,0,gdb->cm->ct); } return out; } /* Function: new_GeneWiseDB_cdna(syn,tdb,cp,cm,rmd,use_syn,flat_insert,allN) * * Descrip: makes a new GeneWiseDB from its component parts, * assumming a cDNA db. * * All the objects are hard-linked internally, so you can, if you * wish, free them once passing them into this function * * * Arg: syn [UNKN ] if ture, use a synchronous coding model vs internally stored tdb rm's [NullString] * Arg: tdb [UNKN ] three state model db to use [ThreeStateDB *] * Arg: cp [UNKN ] codon parser function to remove from match state [cDNAParser *] * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * Arg: rmd [UNKN ] random model (dna) [RandomModelDNA *] * Arg: use_syn [UNKN ] Undocumented argument [boolean] * Arg: flat_insert [UNKN ] Undocumented argument [boolean] * Arg: allN [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [GeneWiseDB *] * */ # line 233 "genewisemodeldb.dy" GeneWiseDB * new_GeneWiseDB_cdna(ThreeStateDB * tdb,cDNAParser * cp,CodonMapper * cm,RandomModelDNA * rmd,boolean use_syn,boolean flat_insert,Probability allN) { GeneWiseDB * out; out = GeneWiseDB_alloc(); out->tdb = hard_link_ThreeStateDB(tdb); out->is_single = FALSE; out->rmd = hard_link_RandomModelDNA(rmd); out->cm = hard_link_CodonMapper(cm); out->cds_factor = (1.0 - removed_probability_from_cds_cdna(cp)); out->is_syn = use_syn; out->allN = allN; out->flat_insert = flat_insert; return out; } /* Function: new_GeneWiseDB(tdb,gp,rmd,use_syn,allN) * * Descrip: makes a new GeneWiseDB from its component parts. * All the objects are hard-linked internally, so you can, if you * wish, free them once passing them into this function * * * Arg: tdb [UNKN ] Undocumented argument [ThreeStateDB *] * Arg: gp [UNKN ] Undocumented argument [GeneParameter21 *] * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * Arg: use_syn [UNKN ] Undocumented argument [boolean] * Arg: allN [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [GeneWiseDB *] * */ # line 256 "genewisemodeldb.dy" GeneWiseDB * new_GeneWiseDB(ThreeStateDB * tdb,GeneParameter21 * gp,RandomModelDNA * rmd,boolean use_syn,Probability allN) { GeneWiseDB * out; out = GeneWiseDB_alloc(); out->tdb = hard_link_ThreeStateDB(tdb); out->is_single = FALSE; out->rmd = hard_link_RandomModelDNA(rmd); out->gpara = hard_link_GeneParameter21(gp); out->cm = hard_link_CodonMapper(gp->cm); out->is_syn = use_syn; out->allN = allN; return out; } /* Function: new_single_GeneWiseDB(gws) * * Descrip: makes a new GeneWiseDB from a single GeneWiseScore. * It hard links it, so you should free it afterwards * in its own scope. * * * Arg: gws [UNKN ] Undocumented argument [GeneWiseScore *] * * Return [UNKN ] Undocumented return value [GeneWiseDB *] * */ # line 278 "genewisemodeldb.dy" GeneWiseDB * new_single_GeneWiseDB(GeneWiseScore * gws) { GeneWiseDB * out; out = GeneWiseDB_alloc(); out->gws = hard_link_GeneWiseScore(gws); out->is_single = TRUE; return out; } /* Function: init_GwLite_GeneWiseDB(gdb,return_status) * * Descrip: inits a genewise database for gwlite models * * * * * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ # line 295 "genewisemodeldb.dy" GwLiteScore * init_GwLite_GeneWiseDB(GeneWiseDB * gdb,int * return_status) { ThreeStateModel * tsm; GeneWise * gw; GwLite * gl; GwLiteScore * gws; *return_status = DB_RETURN_ERROR; if( gdb->is_single == TRUE ) { *return_status = DB_RETURN_OK; /* at the moment, die horribly */ fatal("Apologies. We don't handle single genewise model databases for gwlite yet"); return gdb->gwls; } if( open_ThreeStateDB(gdb->tdb) == FALSE ) { warn("Could not open three state db, so no genewisemodel possible!"); return NULL; } tsm = read_TSM_ThreeStateDB(gdb->tdb,return_status); if( *return_status == DB_RETURN_ERROR) { warn("Cannot read a ThreeStateModelDB for the GeneWiseDB. Problem!"); return NULL; } gw = GeneWise_from_ThreeStateModel_GDB(tsm,gdb); gl = GwLite_from_GeneWise(gw); gws = GwLiteScore_from_GwLite(gl); free_ThreeStateModel(tsm); free_GeneWise(gw); free_GwLite(gl); return gws; } /* Function: reload_GwLite_GeneWiseDB(prev,gdb,return_status) * * Descrip: Reloads a genewise database for a GwLite database * * * * Arg: prev [UNKN ] Undocumented argument [GwLiteScore *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ # line 339 "genewisemodeldb.dy" GwLiteScore * reload_GwLite_GeneWiseDB(GwLiteScore * prev,GeneWiseDB * gdb,int * return_status) { ThreeStateModel * tsm; GeneWise * gw; GwLite * gl; GwLiteScore * gws; if( gdb->is_single == TRUE ) { *return_status = DB_RETURN_END; return NULL; } if( prev != NULL) free_GwLiteScore(prev); *return_status = DB_RETURN_ERROR; tsm = read_TSM_ThreeStateDB(gdb->tdb,return_status); if( *return_status != DB_RETURN_OK) { if( *return_status == DB_RETURN_END) { return NULL; } warn("Cannot read a ThreeStateModelDB for the GeneWiseDB. Problem!"); return NULL; } gw = GeneWise_from_ThreeStateModel_GDB(tsm,gdb); gl = GwLite_from_GeneWise(gw); gws = GwLiteScore_from_GwLite(gl); free_ThreeStateModel(tsm); free_GeneWise(gw); free_GwLite(gl); *return_status = DB_RETURN_OK; return gws; } /* Function: close_GwLite_GeneWiseDB(gws,gdb) * * Descrip: closes a GeneWiseDB * * * Arg: gws [UNKN ] Undocumented argument [GwLiteScore *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 386 "genewisemodeldb.dy" boolean close_GwLite_GeneWiseDB(GwLiteScore * gws,GeneWiseDB * gdb) { if( gdb->is_single == TRUE ) { return TRUE; } if( gws != NULL) free_GwLiteScore(gws); return close_ThreeStateDB(NULL,gdb->tdb); } /* Function: dataentry_add_GwLite_GeneWiseDB(de,gws,gdb) * * Descrip: adds dataentry stuff to a query. Relies completely * on threestatedb * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: gws [UNKN ] Undocumented argument [GwLiteScore *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 402 "genewisemodeldb.dy" boolean dataentry_add_GwLite_GeneWiseDB(DataEntry * de,GwLiteScore * gws,GeneWiseDB * gdb) { if( gdb->is_single == TRUE) { if ( gdb->gws->name == NULL ) { warn("No name for a single GeneWiseDB unit."); de->name = stringalloc("NoName"); } else { de->name = stringalloc(gdb->gws->name); } return TRUE; } /*de->name = stringalloc(gws->name);*/ /* otherwise, pass it on to tdb */ dataentry_add_ThreeStateDB(de,NULL,gdb->tdb); if( de->name == NULL ) { if( gws->name != NULL ) { de->name = stringalloc(gws->name); } } return TRUE; } # line 483 "genewisemodeldb.c" /* Function: hard_link_GeneWiseDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [GeneWiseDB *] * */ GeneWiseDB * hard_link_GeneWiseDB(GeneWiseDB * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneWiseDB object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneWiseDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseDB *] * */ GeneWiseDB * GeneWiseDB_alloc(void) { GeneWiseDB * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWiseDB *) ckalloc (sizeof(GeneWiseDB))) == NULL) { warn("GeneWiseDB_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->tdb = NULL; out->cds_factor = 0; out->cm = NULL; out->rmd = NULL; out->gws = NULL; out->gpara = NULL; out->is_single = FALSE; out->is_syn = TRUE; out->allN = 1.0; out->flat_insert = FALSE; out->gwls = NULL; return out; } /* Function: free_GeneWiseDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [GeneWiseDB *] * */ GeneWiseDB * free_GeneWiseDB(GeneWiseDB * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneWiseDB obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->tdb != NULL) free_ThreeStateDB(obj->tdb); if( obj->cm != NULL) free_CodonMapper(obj->cm); if( obj->rmd != NULL) free_RandomModelDNA(obj->rmd); if( obj->gws != NULL) free_GeneWiseScore(obj->gws); if( obj->gpara != NULL) free_GeneParameter21(obj->gpara); if( obj->gwls != NULL) free_GwLiteScore(obj->gwls); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/genewisemodeldb.h0000644000175000001440000002350210670453714017442 0ustar philippusers#ifndef DYNAMITEgenewisemodeldbHEADERFILE #define DYNAMITEgenewisemodeldbHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "genewisemodel.h" #include "threestatedb.h" #include "gwlitemodel.h" /* Object GeneWiseDB * * Descrip: This is a database of genewisemodels * for database searching versions of * genewise and estwise type algorithms. * * The actual HMM database streaming * happens via the ThreeStateDB (tdb). * This object holds the necessary conversion * system for the HMM database as it * is mapped into the genewisemodel * * */ struct Wise2_GeneWiseDB { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ThreeStateDB * tdb; double cds_factor; CodonMapper * cm; /* NB, hard linked. */ RandomModelDNA * rmd; /* NB hard linked */ GeneWiseScore * gws; /* hardlinked, only if single. */ GeneParameter21 * gpara; /* if a genomic model - est models wont use this! */ boolean is_single; boolean is_syn; Probability allN; boolean flat_insert; GwLiteScore * gwls; /* only if single */ } ; /* GeneWiseDB defined */ #ifndef DYNAMITE_DEFINED_GeneWiseDB typedef struct Wise2_GeneWiseDB Wise2_GeneWiseDB; #define GeneWiseDB Wise2_GeneWiseDB #define DYNAMITE_DEFINED_GeneWiseDB #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: init_GeneWiseDB(gdb,return_status) * * Descrip: inits a genewise database. Remember this is used * for both genomic and cdna searches * * * * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ GeneWiseScore * Wise2_init_GeneWiseDB(GeneWiseDB * gdb,int * return_status); #define init_GeneWiseDB Wise2_init_GeneWiseDB /* Function: reload_GeneWiseDB(prev,gdb,return_status) * * Descrip: Reloads a genewise database * * * * Arg: prev [UNKN ] Undocumented argument [GeneWiseScore *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ GeneWiseScore * Wise2_reload_GeneWiseDB(GeneWiseScore * prev,GeneWiseDB * gdb,int * return_status); #define reload_GeneWiseDB Wise2_reload_GeneWiseDB /* Function: close_GeneWiseDB(gws,gdb) * * Descrip: closes a GeneWiseDB * * * Arg: gws [UNKN ] Undocumented argument [GeneWiseScore *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_close_GeneWiseDB(GeneWiseScore * gws,GeneWiseDB * gdb); #define close_GeneWiseDB Wise2_close_GeneWiseDB /* Function: dataentry_add_GeneWiseDB(de,gws,gdb) * * Descrip: adds dataentry stuff to a query. Relies completely * on threestatedb * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: gws [UNKN ] Undocumented argument [GeneWiseScore *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_dataentry_add_GeneWiseDB(DataEntry * de,GeneWiseScore * gws,GeneWiseDB * gdb); #define dataentry_add_GeneWiseDB Wise2_dataentry_add_GeneWiseDB /* Function: new_GeneWiseDB_cdna(syn,tdb,cp,cm,rmd,use_syn,flat_insert,allN) * * Descrip: makes a new GeneWiseDB from its component parts, * assumming a cDNA db. * * All the objects are hard-linked internally, so you can, if you * wish, free them once passing them into this function * * * Arg: syn [UNKN ] if ture, use a synchronous coding model vs internally stored tdb rm's [NullString] * Arg: tdb [UNKN ] three state model db to use [ThreeStateDB *] * Arg: cp [UNKN ] codon parser function to remove from match state [cDNAParser *] * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * Arg: rmd [UNKN ] random model (dna) [RandomModelDNA *] * Arg: use_syn [UNKN ] Undocumented argument [boolean] * Arg: flat_insert [UNKN ] Undocumented argument [boolean] * Arg: allN [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [GeneWiseDB *] * */ GeneWiseDB * Wise2_new_GeneWiseDB_cdna(ThreeStateDB * tdb,cDNAParser * cp,CodonMapper * cm,RandomModelDNA * rmd,boolean use_syn,boolean flat_insert,Probability allN) ; #define new_GeneWiseDB_cdna Wise2_new_GeneWiseDB_cdna /* Function: new_GeneWiseDB(tdb,gp,rmd,use_syn,allN) * * Descrip: makes a new GeneWiseDB from its component parts. * All the objects are hard-linked internally, so you can, if you * wish, free them once passing them into this function * * * Arg: tdb [UNKN ] Undocumented argument [ThreeStateDB *] * Arg: gp [UNKN ] Undocumented argument [GeneParameter21 *] * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * Arg: use_syn [UNKN ] Undocumented argument [boolean] * Arg: allN [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [GeneWiseDB *] * */ GeneWiseDB * Wise2_new_GeneWiseDB(ThreeStateDB * tdb,GeneParameter21 * gp,RandomModelDNA * rmd,boolean use_syn,Probability allN); #define new_GeneWiseDB Wise2_new_GeneWiseDB /* Function: new_single_GeneWiseDB(gws) * * Descrip: makes a new GeneWiseDB from a single GeneWiseScore. * It hard links it, so you should free it afterwards * in its own scope. * * * Arg: gws [UNKN ] Undocumented argument [GeneWiseScore *] * * Return [UNKN ] Undocumented return value [GeneWiseDB *] * */ GeneWiseDB * Wise2_new_single_GeneWiseDB(GeneWiseScore * gws); #define new_single_GeneWiseDB Wise2_new_single_GeneWiseDB /* Function: init_GwLite_GeneWiseDB(gdb,return_status) * * Descrip: inits a genewise database for gwlite models * * * * * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ GwLiteScore * Wise2_init_GwLite_GeneWiseDB(GeneWiseDB * gdb,int * return_status); #define init_GwLite_GeneWiseDB Wise2_init_GwLite_GeneWiseDB /* Function: reload_GwLite_GeneWiseDB(prev,gdb,return_status) * * Descrip: Reloads a genewise database for a GwLite database * * * * Arg: prev [UNKN ] Undocumented argument [GwLiteScore *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [GwLiteScore *] * */ GwLiteScore * Wise2_reload_GwLite_GeneWiseDB(GwLiteScore * prev,GeneWiseDB * gdb,int * return_status); #define reload_GwLite_GeneWiseDB Wise2_reload_GwLite_GeneWiseDB /* Function: close_GwLite_GeneWiseDB(gws,gdb) * * Descrip: closes a GeneWiseDB * * * Arg: gws [UNKN ] Undocumented argument [GwLiteScore *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_close_GwLite_GeneWiseDB(GwLiteScore * gws,GeneWiseDB * gdb); #define close_GwLite_GeneWiseDB Wise2_close_GwLite_GeneWiseDB /* Function: dataentry_add_GwLite_GeneWiseDB(de,gws,gdb) * * Descrip: adds dataentry stuff to a query. Relies completely * on threestatedb * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: gws [UNKN ] Undocumented argument [GwLiteScore *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_dataentry_add_GwLite_GeneWiseDB(DataEntry * de,GwLiteScore * gws,GeneWiseDB * gdb); #define dataentry_add_GwLite_GeneWiseDB Wise2_dataentry_add_GwLite_GeneWiseDB /* Function: hard_link_GeneWiseDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [GeneWiseDB *] * */ GeneWiseDB * Wise2_hard_link_GeneWiseDB(GeneWiseDB * obj); #define hard_link_GeneWiseDB Wise2_hard_link_GeneWiseDB /* Function: GeneWiseDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseDB *] * */ GeneWiseDB * Wise2_GeneWiseDB_alloc(void); #define GeneWiseDB_alloc Wise2_GeneWiseDB_alloc /* Function: free_GeneWiseDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [GeneWiseDB *] * */ GeneWiseDB * Wise2_free_GeneWiseDB(GeneWiseDB * obj); #define free_GeneWiseDB Wise2_free_GeneWiseDB /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ GeneWise * Wise2_GeneWise_from_ThreeStateModel_GDB(ThreeStateModel * tsm,GeneWiseDB * gdb); #define GeneWise_from_ThreeStateModel_GDB Wise2_GeneWise_from_ThreeStateModel_GDB #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/dnaprofile.dy0000644000175000001440000001464510052363765016625 0ustar philippusers %{ #include "dyna.h" #include "transfactor.h" typedef enum DnaProfileTransition { DnaProfile_M2M = 0, DnaProfile_M2I, DnaProfile_I2I, DnaProfile_I2M, DnaProfile_M2D, DnaProfile_D2D, DnaProfile_D2M, DnaProfile_TRANS_LENGTH } DnaProfileTransition; #define DnaProfileScoreLISTLENGTH 128 #define DnaProfileLISTLENGTH 128 %} struct DnaProfileCol Probability emit[5] Probability trans[DnaProfile_TRANS_LENGTH] int seqalign_col struct DnaProfileColScore Score emit[5] Score trans[DnaProfile_TRANS_LENGTH] struct DnaProfileScore DnaProfileColScore ** col !list struct DnaProfile DnaProfileCol ** col !list SeqAlign * sa boolean folded_random !def="FALSE" %{ #include "dnaprofile.h" TransFactor * new_TransFactor_from_DnaProfile(DnaProfile * dp,char * name) { TransFactor * out; assert(dp != NULL); out = TransFactor_alloc(); out->name = stringalloc(name); out->seed = hard_link_SeqAlign(dp->sa); return out; } double bits_entropy_DnaProfile(DnaProfile * dnap,RandomModelDNA * background) { double entropy = 0.0; double prob = 0; int i; int j; for(i=0;ilen;i++) { for(j=0;j<4;j++) { prob = dnap->col[i]->emit[j] * background->base[j]; entropy += prob * (-(log(prob)/log(2.0))); } } return entropy; } SeqAlign * merged_SeqAlign(DnaProfile * one,DnaProfile * two,AlnBlock * alb) { SeqAlign * out; Sequence * temp; int i; int j; int len = 0; AlnColumn * alc; char * temp_seq; out = SeqAlign_alloc_std(); for(alc=alb->start,len = 0;alc != NULL;alc = alc->next ) { len++; } temp_seq = calloc(len+1,sizeof(char)); /* loop along the top sequence */ for(i=0;isa->len;i++) { j = 0; for(alc=alb->start;alc!=NULL;alc=alc->next) { if( strcmp(alc->alu[1]->text_label,"END") == 0 ) { break; } if( strcmp(alc->alu[0]->text_label,"MATCH") == 0 || strcmp(alc->alu[0]->text_label,"INSERT") == 0 ) { temp_seq[j++] = one->sa->seq[i]->seq[alc->alu[0]->end]; } else if( strcmp(alc->alu[0]->text_label,"SEQ_UNMATCHED") == 0) { temp_seq[j++] = tolower(one->sa->seq[i]->seq[alc->alu[0]->end]); } else { temp_seq[j++] = '-'; } } temp_seq[j] = '\0'; temp = Sequence_from_static_memory(one->sa->seq[i]->name,temp_seq); add_SeqAlign(out,temp); } for(i=0;isa->len;i++) { j = 0; for(alc=alb->start;alc!=NULL;alc=alc->next) { if( strcmp(alc->alu[1]->text_label,"END") == 0 ) { break; } if( strcmp(alc->alu[1]->text_label,"MATCH") == 0 || strcmp(alc->alu[1]->text_label,"INSERT") == 0 ) { temp_seq[j++] = two->sa->seq[i]->seq[alc->alu[1]->end]; } else if( strcmp(alc->alu[1]->text_label,"SEQ_UNMATCHED") == 0) { temp_seq[j++] = tolower(two->sa->seq[i]->seq[alc->alu[1]->end]); } else { temp_seq[j++] = '-'; } } temp_seq[j] = '\0'; temp = Sequence_from_static_memory(two->sa->seq[i]->name,temp_seq); add_SeqAlign(out,temp); } return out; } DnaProfileScore * DnaProfileScore_from_DnaProfile(DnaProfile * dp) { int i,k; DnaProfileColScore * col; DnaProfileScore * out; out = DnaProfileScore_alloc_len(dp->len); for(i=0;ilen;i++) { col = DnaProfileColScore_alloc(); Probability2Score_move(dp->col[i]->emit,col->emit,4); Probability2Score_move(dp->col[i]->trans,col->trans,DnaProfile_TRANS_LENGTH); add_DnaProfileScore(out,col); } return out; } void fold_RandomModel_DnaProfile(DnaProfile * dp,RandomModelDNA * rm) { int i,k; for(i=0;ilen;i++) { for(k=0;k<4;k++) { dp->col[i]->emit[k] /= rm->base[k]; } } dp->folded_random = TRUE; } DnaProfile * naive_DnaProfile_from_Sequence(Sequence * seq,double id,double m2i,double m2d,double i2i,double d2d) { DnaProfile * out; DnaProfileCol * col; int i,k; SeqAlign * sa; sa = SeqAlign_alloc_len(1); add_SeqAlign(sa,hard_link_Sequence(seq)); out= DnaProfile_alloc_len(seq->len); out->sa = sa; for(i=0;ilen;i++) { col = DnaProfileCol_alloc(); for(k=0;k<4;k++) { col->emit[k]= (1.0-id)/3.0; } if( base_from_char(seq->seq[i]) != BASE_N ) { col->emit[base_from_char(seq->seq[i])] = id; } col->trans[DnaProfile_M2I] = m2i; col->trans[DnaProfile_M2D] = m2d; col->trans[DnaProfile_I2I] = i2i; col->trans[DnaProfile_D2D] = d2d; col->trans[DnaProfile_M2M] = (1.0 - m2i - m2d); col->trans[DnaProfile_D2M] = (1.0 - d2d); col->trans[DnaProfile_I2M] = (1.0 - i2i); add_DnaProfile(out,col); } return out; } DnaProfile * naive_DnaProfile_from_SeqAlign(SeqAlign * sa,double simple_pseudo,double m2i,double m2d,double i2i,double d2d) { int i; int j; int k; DnaProfile * out; DnaProfileCol * col; int base_n; double count[4]; double total; assert(sa != NULL); assert(sa->len > 1); assert(sa->seq[0]->len > 1); out = DnaProfile_alloc_len(sa->seq[0]->len); out->sa = hard_link_SeqAlign(sa); total = (4*simple_pseudo)+sa->len; for(i=0;iseq[0]->len;i++) { for(k=0;k<4;k++) { count[k] = simple_pseudo; } for(j=0;jlen;j++) { assert(sa->seq[j]->len > i); base_n = base_from_char(sa->seq[j]->seq[i]); if( base_n < 4 ) { count[base_n]++; } else { for(k=0;k<4;k++) { count[base_n] += 0.25; } } } col = DnaProfileCol_alloc(); col->seqalign_col = i; for(k=0;k<4;k++) { col->emit[k] = count[k] / total; } col->trans[DnaProfile_M2I] = m2i; col->trans[DnaProfile_M2D] = m2d; col->trans[DnaProfile_I2I] = i2i; col->trans[DnaProfile_D2D] = d2d; col->trans[DnaProfile_M2M] = (1.0 - m2i - m2d); col->trans[DnaProfile_D2M] = (1.0 - d2d); col->trans[DnaProfile_I2M] = (1.0 - i2i); add_DnaProfile(out,col); } return out; } void show_DnaProfile(DnaProfile * dnap,RandomModelDNA * rm,FILE * ofp) { int i; int k; double max; double max_base; double ent; ent = bits_entropy_DnaProfile(dnap,rm); fprintf(ofp,"Entropy %.4f (%.4f per column)\n",ent,ent/dnap->len); for(i=0;ilen;i++) { max = dnap->col[i]->emit[0]; max_base =0; for(k=1;k<4;k++) { if( dnap->col[i]->emit[k] > max ) { max = dnap->col[i]->emit[k]; max_base =k; } } fprintf(ofp,"%5d %c ",i,char_from_base(max_base)); for(k=0;k<4;k++) { fprintf(ofp," %c:%.3f ",char_from_base(k),dnap->col[i]->emit[k]); } fprintf(ofp,"\n"); } write_selex_SeqAlign(dnap->sa,15,50,ofp); fprintf(ofp,"//\n"); } %} wise-2.4.1/src/models/hsp2aln_sw.c0000644000175000001440000005001410670453714016356 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "hsp2aln_sw.h" #ifdef PTHREAD # line 56 "hsp2aln_sw.dy" HitList * HitList_from_LinearHSPmanager_heuristic_threaded(LinearHSPmanager * lm,DPRunImpl * dpri,int thr_no,HSPset2HitPairPara * para) { struct hsp2aln_thread_manager tm; pthread_attr_t pat; int i; pthread_attr_init(&pat); #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ tm.input = lm; tm.current_pos = 0; tm.output = HitList_alloc_std(); tm.dpri = dpri; tm.para = para; tm.topscore = lm->set[0]->score; if( pthread_mutex_init(&(tm.input_lock),NULL) != 0 ) { fatal("Unable to make input mutex"); } if( pthread_mutex_init(&(tm.output_lock),NULL) != 0 ) { fatal("Unable to make output mutex"); } tm.pool = ckcalloc(thr_no,sizeof(pthread_t)); for(i=0;idpri); while(1) { /* get input lock, die if at end */ if( pthread_mutex_lock(&(tm->input_lock)) != 0 ) fatal("bad error getting input lock"); if( tm->current_pos >= tm->input->len || tm->para->no_hitalns > 0 && tm->current_pos > tm->para->no_hitalns || (tm->para->best_hit == TRUE && (((double)(tm->topscore - tm->input->set[tm->current_pos]->score))*100.0/tm->topscore) > tm->para->perc_hit_dropoff) ) { /* end of this thread */ if( pthread_mutex_unlock(&(tm->input_lock))!= 0 ) fatal("Error in releasing input lock for ProteinSW"); break; } else { /* get a HSPset */ set= tm->input->set[tm->current_pos++]; /* release the lock */ if( pthread_mutex_unlock(&(tm->input_lock))!= 0 ) fatal("Error in releasing input lock for ProteinSW"); } /* now got a set in HSPset */ pair = HitPair_from_HSPset_heuristic(set,thread_dpri,tm->input->mat,tm->para); if( pthread_mutex_lock(&(tm->output_lock))!= 0 ) fatal("Error on getting output lock"); add_HitList(tm->output,pair); if( pthread_mutex_unlock(&(tm->output_lock))!= 0 ) fatal("Error on getting output lock"); } free_DPRunImpl(thread_dpri); return NULL; } #else # line 155 "hsp2aln_sw.dy" HitList * HitList_from_LinearHSPmanager_heuristic_threaded(LinearHSPmanager * lm,DPRunImpl * dpri,int thr_no,HSPset2HitPairPara * para) { fatal("Not compiled with pthreads"); return NULL; } #endif # line 163 "hsp2aln_sw.dy" HitList * HitList_from_LinearHSPmanager_heuristic(LinearHSPmanager * lm,DPRunImpl * dpri,HSPset2HitPairPara * para) { HitList * out; int i; int topscore; out = HitList_alloc_std(); out->mat = hard_link_CompMat(lm->mat); if( lm->len <= 0 ) { return out; } topscore = lm->set[0]->score; for(i=0;ilen;i++) { if( para->no_hitalns > 0 && i > para->no_hitalns ) { break; } if( para->best_hit == TRUE && (((double)(topscore - lm->set[i]->score))*100.0/topscore) > para->perc_hit_dropoff ) { break; } add_HitList(out,HitPair_from_HSPset_heuristic(lm->set[i],dpri,lm->mat,para)); } return out; } # line 194 "hsp2aln_sw.dy" HitPair * HitPair_from_HSPset_heuristic(HSPset * set,DPRunImpl * dpri,CompMat * mat,HSPset2HitPairPara *p) { HitPair * out; HitAln * aln; int i; int total_score = 0; Hsp2AlnHelper * helper; out = HitPair_alloc_std(); out->query = hard_link_Sequence(set->hsp[0]->query); out->target = hard_link_Sequence(set->hsp[0]->target); out->query->type = SEQUENCE_PROTEIN; out->target->type = SEQUENCE_PROTEIN; helper = build_HSP2AlnHelper(set,p->hsp_width,p->hsp_length,p->poor_score,p->poor_score_factor); for(i=0;ilen;i++) { if( p->no_subalns != 0 && i > p->no_subalns ) { break; } aln = HitAln_alloc(); if( p->debug == TRUE ) { fprintf(stdout,"For %s to %s, DPENV is\n",out->query->name,out->target->name); show_DPEnvelope(helper->dpenv[i],stdout); fprintf(stdout,"\n-----------\n"); } aln->alb = Align_Sequences_ProteinSmithWaterman(out->query,out->target,mat,-12,-2,helper->dpenv[i],dpri); aln->raw_score = aln->alb->score; total_score += aln->raw_score; add_HitPair(out,aln); break; } free_Hsp2AlnHelper(helper); out->raw_score = total_score; return out; } # line 239 "hsp2aln_sw.dy" Hsp2AlnHelper * build_HSP2AlnHelper(HSPset * set,int width,int tail,int min_score,int small_factor) { Hsp2AlnHelper * out; DPEnvelope * dpenv; DPUnit * dpunit; int i; int j; int k; int eaten; int factor = 1; out = Hsp2AlnHelper_alloc_std(); sort_HSPset_by_score(set); for(i=0;ilen;i++) { dpunit = DPUnit_alloc(); dpunit->starti = set->hsp[i]->query_start - (tail*factor); dpunit->startj = set->hsp[i]->target_start - (tail*factor); dpunit->type = DPENV_DIAG; dpunit->height = (width*factor); dpunit->length = set->hsp[i]->length + 2*(tail*factor); eaten = 0; for(j=0;jlen;j++) { for(k=0;kdpenv[j]->len;k++) { if( overlap_DPUnit(out->dpenv[j]->dpu[k],dpunit) == TRUE ) { add_DPEnvelope(out->dpenv[j],dpunit); eaten = 1; break; } } if( eaten == 1 ) { break; } } if( eaten == 0 ) { dpenv = DPEnvelope_alloc_std(); add_DPEnvelope(dpenv,dpunit); add_Hsp2AlnHelper(out,dpenv); } } return out; } # line 295 "hsp2aln_sw.dy" void show_help_HSPset2HitPairPara(FILE * ofp) { fprintf(ofp,"Converting HSP sets to HitPair heuristic parameters\n"); fprintf(ofp," -hsp2hit_width [no] width around each HSP to consider\n"); fprintf(ofp," -hsp2hit_length [no] length around each HSP to consider\n"); fprintf(ofp," -hsp2hit_subaln [no] number of HSP subalignments to consider (disabled)\n"); fprintf(ofp," -hsp2hit_hitaln [no] number of hitpairs to assess\n"); fprintf(ofp," -[no]hsp2hit_best use best-in-search truncation (default no)\n"); fprintf(ofp," -hsp2hit_best_perc [10] percentage off best score taken in best-in-search truncation\n"); fprintf(ofp," -[no]hsp2hit_debug print debugging features on stdout (default no)\n"); } # line 307 "hsp2aln_sw.dy" HSPset2HitPairPara * new_HSPset2HitPairPara_from_argv(int * argc,char ** argv) { HSPset2HitPairPara * out; out = HSPset2HitPairPara_alloc(); strip_out_integer_argument(argc,argv,"hsp2hit_width",&out->hsp_width); strip_out_integer_argument(argc,argv,"hsp2hit_length",&out->hsp_length); strip_out_integer_argument(argc,argv,"hsp2hit_subaln",&out->no_subalns); strip_out_integer_argument(argc,argv,"hsp2hit_hitaln",&out->no_hitalns); strip_out_boolean_def_argument(argc,argv,"hsp2hit_best",&out->best_hit); strip_out_boolean_def_argument(argc,argv,"hsp2hit_debug",&out->debug); strip_out_float_argument(argc,argv,"hsp2hit_best_perc",&out->perc_hit_dropoff); return out; } # line 287 "hsp2aln_sw.c" /* Function: hard_link_HSPset2HitPairPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPset2HitPairPara *] * * Return [UNKN ] Undocumented return value [HSPset2HitPairPara *] * */ HSPset2HitPairPara * hard_link_HSPset2HitPairPara(HSPset2HitPairPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a HSPset2HitPairPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HSPset2HitPairPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPset2HitPairPara *] * */ HSPset2HitPairPara * HSPset2HitPairPara_alloc(void) { HSPset2HitPairPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HSPset2HitPairPara *) ckalloc (sizeof(HSPset2HitPairPara))) == NULL) { warn("HSPset2HitPairPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->hsp_width = 40; out->hsp_length = 90; out->no_subalns = 0; out->no_hitalns = 0; out->best_hit = FALSE; out->perc_hit_dropoff = 10.0; out->debug = FALSE; out->poor_score_factor = 2; out->poor_score = 100; return out; } /* Function: free_HSPset2HitPairPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPset2HitPairPara *] * * Return [UNKN ] Undocumented return value [HSPset2HitPairPara *] * */ HSPset2HitPairPara * free_HSPset2HitPairPara(HSPset2HitPairPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HSPset2HitPairPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_Hsp2AlnHelper(list,i,j) * * Descrip: swap function: an internal for qsort_Hsp2AlnHelper * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [DPEnvelope **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Hsp2AlnHelper(DPEnvelope ** list,int i,int j) { DPEnvelope * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Hsp2AlnHelper(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Hsp2AlnHelper which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [DPEnvelope **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Hsp2AlnHelper(DPEnvelope ** list,int left,int right,int (*comp)(DPEnvelope * ,DPEnvelope * )) { int i,last; if( left >= right ) return; swap_Hsp2AlnHelper(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Hsp2AlnHelper (list,++last,i); } swap_Hsp2AlnHelper (list,left,last); qsort_Hsp2AlnHelper(list,left,last-1,comp); qsort_Hsp2AlnHelper(list,last+1,right,comp); } /* Function: sort_Hsp2AlnHelper(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Hsp2AlnHelper * * * Arg: obj [UNKN ] Object containing list [Hsp2AlnHelper *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Hsp2AlnHelper(Hsp2AlnHelper * obj,int (*comp)(DPEnvelope *, DPEnvelope *)) { qsort_Hsp2AlnHelper(obj->dpenv,0,obj->len-1,comp); return; } /* Function: expand_Hsp2AlnHelper(obj,len) * * Descrip: Really an internal function for add_Hsp2AlnHelper * * * Arg: obj [UNKN ] Object which contains the list [Hsp2AlnHelper *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Hsp2AlnHelper(Hsp2AlnHelper * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Hsp2AlnHelper called with no need"); return TRUE; } if( (obj->dpenv = (DPEnvelope ** ) ckrealloc (obj->dpenv,sizeof(DPEnvelope *)*len)) == NULL) { warn("ckrealloc failed for expand_Hsp2AlnHelper, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Hsp2AlnHelper(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Hsp2AlnHelper *] * Arg: add [OWNER] Object to add to the list [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Hsp2AlnHelper(Hsp2AlnHelper * obj,DPEnvelope * add) { if( obj->len >= obj->maxlen) { if( expand_Hsp2AlnHelper(obj,obj->len + Hsp2AlnHelperLISTLENGTH) == FALSE) return FALSE; } obj->dpenv[obj->len++]=add; return TRUE; } /* Function: flush_Hsp2AlnHelper(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Hsp2AlnHelper *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Hsp2AlnHelper(Hsp2AlnHelper * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->dpenv[i] != NULL) { free_DPEnvelope(obj->dpenv[i]); obj->dpenv[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: Hsp2AlnHelper_alloc_std(void) * * Descrip: Equivalent to Hsp2AlnHelper_alloc_len(Hsp2AlnHelperLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Hsp2AlnHelper *] * */ Hsp2AlnHelper * Hsp2AlnHelper_alloc_std(void) { return Hsp2AlnHelper_alloc_len(Hsp2AlnHelperLISTLENGTH); } /* Function: Hsp2AlnHelper_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Hsp2AlnHelper *] * */ Hsp2AlnHelper * Hsp2AlnHelper_alloc_len(int len) { Hsp2AlnHelper * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Hsp2AlnHelper_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->dpenv = (DPEnvelope ** ) ckcalloc (len,sizeof(DPEnvelope *))) == NULL) { warn("Warning, ckcalloc failed in Hsp2AlnHelper_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_Hsp2AlnHelper(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Hsp2AlnHelper *] * * Return [UNKN ] Undocumented return value [Hsp2AlnHelper *] * */ Hsp2AlnHelper * hard_link_Hsp2AlnHelper(Hsp2AlnHelper * obj) { if( obj == NULL ) { warn("Trying to hard link to a Hsp2AlnHelper object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Hsp2AlnHelper_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Hsp2AlnHelper *] * */ Hsp2AlnHelper * Hsp2AlnHelper_alloc(void) { Hsp2AlnHelper * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Hsp2AlnHelper *) ckalloc (sizeof(Hsp2AlnHelper))) == NULL) { warn("Hsp2AlnHelper_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->dpenv = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_Hsp2AlnHelper(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Hsp2AlnHelper *] * * Return [UNKN ] Undocumented return value [Hsp2AlnHelper *] * */ Hsp2AlnHelper * free_Hsp2AlnHelper(Hsp2AlnHelper * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Hsp2AlnHelper obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->dpenv != NULL) { for(i=0;ilen;i++) { if( obj->dpenv[i] != NULL) free_DPEnvelope(obj->dpenv[i]); } ckfree(obj->dpenv); } ckfree(obj); return NULL; } /* Function: hard_link_Hsp2AlnPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Hsp2AlnPara *] * * Return [UNKN ] Undocumented return value [Hsp2AlnPara *] * */ Hsp2AlnPara * hard_link_Hsp2AlnPara(Hsp2AlnPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a Hsp2AlnPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Hsp2AlnPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Hsp2AlnPara *] * */ Hsp2AlnPara * Hsp2AlnPara_alloc(void) { Hsp2AlnPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Hsp2AlnPara *) ckalloc (sizeof(Hsp2AlnPara))) == NULL) { warn("Hsp2AlnPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->align_size = 0; return out; } /* Function: free_Hsp2AlnPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Hsp2AlnPara *] * * Return [UNKN ] Undocumented return value [Hsp2AlnPara *] * */ Hsp2AlnPara * free_Hsp2AlnPara(Hsp2AlnPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Hsp2AlnPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/hsp2aln_sw.h0000644000175000001440000002310610670453714016365 0ustar philippusers#ifndef DYNAMITEhsp2aln_swHEADERFILE #define DYNAMITEhsp2aln_swHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sw_wrap.h" #include "hitlist.h" #include "hsp.h" #define Hsp2AlnHelperLISTLENGTH 20 #ifdef PTHREAD #include "pthread.h" struct hsp2aln_thread_manager { pthread_mutex_t input_lock; pthread_mutex_t output_lock; pthread_t * pool; int thread_size; int current_pos; LinearHSPmanager * input; HitList * output; DPRunImpl * dpri; struct Wise2_HSPset2HitPairPara * para; int topscore; }; #endif struct Wise2_HSPset2HitPairPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int hsp_width; int hsp_length; int no_subalns; int no_hitalns; boolean best_hit; double perc_hit_dropoff; boolean debug; int poor_score_factor; int poor_score; } ; /* HSPset2HitPairPara defined */ #ifndef DYNAMITE_DEFINED_HSPset2HitPairPara typedef struct Wise2_HSPset2HitPairPara Wise2_HSPset2HitPairPara; #define HSPset2HitPairPara Wise2_HSPset2HitPairPara #define DYNAMITE_DEFINED_HSPset2HitPairPara #endif struct Wise2_Hsp2AlnHelper { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DPEnvelope ** dpenv; int len;/* len for above dpenv */ int maxlen; /* maxlen for above dpenv */ } ; /* Hsp2AlnHelper defined */ #ifndef DYNAMITE_DEFINED_Hsp2AlnHelper typedef struct Wise2_Hsp2AlnHelper Wise2_Hsp2AlnHelper; #define Hsp2AlnHelper Wise2_Hsp2AlnHelper #define DYNAMITE_DEFINED_Hsp2AlnHelper #endif struct Wise2_Hsp2AlnPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int align_size; } ; /* Hsp2AlnPara defined */ #ifndef DYNAMITE_DEFINED_Hsp2AlnPara typedef struct Wise2_Hsp2AlnPara Wise2_Hsp2AlnPara; #define Hsp2AlnPara Wise2_Hsp2AlnPara #define DYNAMITE_DEFINED_Hsp2AlnPara #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_HSPset2HitPairPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPset2HitPairPara *] * * Return [UNKN ] Undocumented return value [HSPset2HitPairPara *] * */ HSPset2HitPairPara * Wise2_hard_link_HSPset2HitPairPara(HSPset2HitPairPara * obj); #define hard_link_HSPset2HitPairPara Wise2_hard_link_HSPset2HitPairPara /* Function: HSPset2HitPairPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPset2HitPairPara *] * */ HSPset2HitPairPara * Wise2_HSPset2HitPairPara_alloc(void); #define HSPset2HitPairPara_alloc Wise2_HSPset2HitPairPara_alloc /* Function: free_HSPset2HitPairPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPset2HitPairPara *] * * Return [UNKN ] Undocumented return value [HSPset2HitPairPara *] * */ HSPset2HitPairPara * Wise2_free_HSPset2HitPairPara(HSPset2HitPairPara * obj); #define free_HSPset2HitPairPara Wise2_free_HSPset2HitPairPara /* Function: add_Hsp2AlnHelper(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Hsp2AlnHelper *] * Arg: add [OWNER] Object to add to the list [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_Hsp2AlnHelper(Hsp2AlnHelper * obj,DPEnvelope * add); #define add_Hsp2AlnHelper Wise2_add_Hsp2AlnHelper /* Function: flush_Hsp2AlnHelper(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Hsp2AlnHelper *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_Hsp2AlnHelper(Hsp2AlnHelper * obj); #define flush_Hsp2AlnHelper Wise2_flush_Hsp2AlnHelper /* Function: Hsp2AlnHelper_alloc_std(void) * * Descrip: Equivalent to Hsp2AlnHelper_alloc_len(Hsp2AlnHelperLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Hsp2AlnHelper *] * */ Hsp2AlnHelper * Wise2_Hsp2AlnHelper_alloc_std(void); #define Hsp2AlnHelper_alloc_std Wise2_Hsp2AlnHelper_alloc_std /* Function: Hsp2AlnHelper_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Hsp2AlnHelper *] * */ Hsp2AlnHelper * Wise2_Hsp2AlnHelper_alloc_len(int len); #define Hsp2AlnHelper_alloc_len Wise2_Hsp2AlnHelper_alloc_len /* Function: hard_link_Hsp2AlnHelper(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Hsp2AlnHelper *] * * Return [UNKN ] Undocumented return value [Hsp2AlnHelper *] * */ Hsp2AlnHelper * Wise2_hard_link_Hsp2AlnHelper(Hsp2AlnHelper * obj); #define hard_link_Hsp2AlnHelper Wise2_hard_link_Hsp2AlnHelper /* Function: Hsp2AlnHelper_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Hsp2AlnHelper *] * */ Hsp2AlnHelper * Wise2_Hsp2AlnHelper_alloc(void); #define Hsp2AlnHelper_alloc Wise2_Hsp2AlnHelper_alloc /* Function: free_Hsp2AlnHelper(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Hsp2AlnHelper *] * * Return [UNKN ] Undocumented return value [Hsp2AlnHelper *] * */ Hsp2AlnHelper * Wise2_free_Hsp2AlnHelper(Hsp2AlnHelper * obj); #define free_Hsp2AlnHelper Wise2_free_Hsp2AlnHelper /* Function: hard_link_Hsp2AlnPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Hsp2AlnPara *] * * Return [UNKN ] Undocumented return value [Hsp2AlnPara *] * */ Hsp2AlnPara * Wise2_hard_link_Hsp2AlnPara(Hsp2AlnPara * obj); #define hard_link_Hsp2AlnPara Wise2_hard_link_Hsp2AlnPara /* Function: Hsp2AlnPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Hsp2AlnPara *] * */ Hsp2AlnPara * Wise2_Hsp2AlnPara_alloc(void); #define Hsp2AlnPara_alloc Wise2_Hsp2AlnPara_alloc /* Function: free_Hsp2AlnPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Hsp2AlnPara *] * * Return [UNKN ] Undocumented return value [Hsp2AlnPara *] * */ Hsp2AlnPara * Wise2_free_Hsp2AlnPara(Hsp2AlnPara * obj); #define free_Hsp2AlnPara Wise2_free_Hsp2AlnPara /* Unplaced functions */ /* There has been no indication of the use of these functions */ HitList * Wise2_HitList_from_LinearHSPmanager_heuristic_threaded(LinearHSPmanager * lm,DPRunImpl * dpri,int thr_no,HSPset2HitPairPara * para); #define HitList_from_LinearHSPmanager_heuristic_threaded Wise2_HitList_from_LinearHSPmanager_heuristic_threaded void * Wise2_worker_thread_LM2HitList(void * p); #define worker_thread_LM2HitList Wise2_worker_thread_LM2HitList HitList * Wise2_HitList_from_LinearHSPmanager_heuristic_threaded(LinearHSPmanager * lm,DPRunImpl * dpri,int thr_no,HSPset2HitPairPara * para); #define HitList_from_LinearHSPmanager_heuristic_threaded Wise2_HitList_from_LinearHSPmanager_heuristic_threaded HitList * Wise2_HitList_from_LinearHSPmanager_heuristic(LinearHSPmanager * lm,DPRunImpl * dpri,HSPset2HitPairPara * para); #define HitList_from_LinearHSPmanager_heuristic Wise2_HitList_from_LinearHSPmanager_heuristic HitPair * Wise2_HitPair_from_HSPset_heuristic(HSPset * set,DPRunImpl * dpri,CompMat * mat,HSPset2HitPairPara *p); #define HitPair_from_HSPset_heuristic Wise2_HitPair_from_HSPset_heuristic Hsp2AlnHelper * Wise2_build_HSP2AlnHelper(HSPset * set,int width,int tail,int min_score,int small_factor); #define build_HSP2AlnHelper Wise2_build_HSP2AlnHelper void Wise2_show_help_HSPset2HitPairPara(FILE * ofp); #define show_help_HSPset2HitPairPara Wise2_show_help_HSPset2HitPairPara HSPset2HitPairPara * Wise2_new_HSPset2HitPairPara_from_argv(int * argc,char ** argv); #define new_HSPset2HitPairPara_from_argv Wise2_new_HSPset2HitPairPara_from_argv /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_Hsp2AlnHelper(DPEnvelope ** list,int i,int j) ; #define swap_Hsp2AlnHelper Wise2_swap_Hsp2AlnHelper void Wise2_qsort_Hsp2AlnHelper(DPEnvelope ** list,int left,int right,int (*comp)(DPEnvelope * ,DPEnvelope * )); #define qsort_Hsp2AlnHelper Wise2_qsort_Hsp2AlnHelper void Wise2_sort_Hsp2AlnHelper(Hsp2AlnHelper * obj,int (*comp)(DPEnvelope *, DPEnvelope *)); #define sort_Hsp2AlnHelper Wise2_sort_Hsp2AlnHelper boolean Wise2_expand_Hsp2AlnHelper(Hsp2AlnHelper * obj,int len); #define expand_Hsp2AlnHelper Wise2_expand_Hsp2AlnHelper #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/dnaprofileengine.dy0000644000175000001440000004122210052363765020002 0ustar philippusers %{ #include "dnaprofile.h" #include "dnaprofiledp.h" #include "localcishit.h" #include "pairwiseshortdna.h" #define DnaProfileNode_LEAF 67 #define DnaProfileNode_SET 68 #define DnaProfileNode_UNCALC 69 #define DnaProfileSetLISTLENGTH 128 #define DnaProfileMatchPairSetLISTLENGTH 128 %} struct DnaProfileEnginePara DPRunImpl * dpri; RandomModelDNA * rm; LocalCisHitSetPara * setpara; LocalCisHitScore * lchs; Probability pseudo; Probability open_unmatched Probability ext_unmatched Probability gap_unmatched Probability seq_id Probability m2i Probability m2d Probability i2i Probability d2d Score min_seq_prof struct DnaProfileSet DnaProfile ** dnap !list friend DnaProfileNode struct DnaProfileNode int type Sequence * leaf DnaProfileSet * set DnaProfileNode * left DnaProfileNode * right DnaProfileNode * parent !link struct DnaProfileMatchPair DnaProfile * query DnaProfile * target AlnBlock * alb int score int accepted struct DnaProfileMatchPairSet DnaProfileMatchPair ** pair !list %{ #include "dnaprofileengine.h" TransFactorSet * TransFactorSet_from_DnaProfileSet(DnaProfileSet * in) { int i; char name_buf[512]; TransFactorSet * out; out = TransFactorSet_alloc_len(in->len); } DnaProfileNode * balanced_4_Sequence_fasta_stream(FILE * ifp) { Sequence * one; Sequence * two; Sequence * three; Sequence * four; DnaProfileNode * leafone; DnaProfileNode * leaftwo; DnaProfileNode * leafthree; DnaProfileNode * leaffour; DnaProfileNode * midonetwo; DnaProfileNode * midthreefour; DnaProfileNode * root; one = read_fasta_Sequence(ifp); fprintf(stderr,"Got 1 %s\n",one->name); two = read_fasta_Sequence(ifp); fprintf(stderr,"Got 2 %s\n",two->name); three = read_fasta_Sequence(ifp); fprintf(stderr,"Got 3 %s\n",three->name); four = read_fasta_Sequence(ifp); fprintf(stderr,"Got 4 %s\n",four->name); assert(four != NULL); leafone = new_leaf_DnaProfileNode(one); leaftwo = new_leaf_DnaProfileNode(two); leafthree = new_leaf_DnaProfileNode(three); leaffour = new_leaf_DnaProfileNode(four); midonetwo = DnaProfileNode_alloc(); midonetwo->type = DnaProfileNode_SET; midonetwo->left = leafone; midonetwo->right = leaftwo; midthreefour = DnaProfileNode_alloc(); midthreefour->type = DnaProfileNode_SET; midthreefour->left = leafthree; midthreefour->right = leaffour; root = DnaProfileNode_alloc(); root->type = DnaProfileNode_SET; root->left = midonetwo; root->right = midthreefour; return root; } DnaProfileNode * simple_cascade_Sequence_fasta_stream(FILE * ifp) { DnaProfileNode * head; DnaProfileNode * leaf; DnaProfileNode * first; DnaProfileNode * temp; Sequence * read; read = read_fasta_Sequence(ifp); uppercase_Sequence(read); if( read == NULL ) { fatal("Attempting to build a cascade with only no sequences! impossible!"); } first = new_leaf_DnaProfileNode(read); read = read_fasta_Sequence(ifp); uppercase_Sequence(read); if( read == NULL ) { fatal("Attempting to build a cascade with only one sequence! impossible!"); } leaf = new_leaf_DnaProfileNode(read); head = DnaProfileNode_alloc(); head->type = DnaProfileNode_SET; head->left = first; head->right = leaf; /* now loop over all remaining sequences */ while( (read = read_fasta_Sequence(ifp)) != NULL ) { uppercase_Sequence(read); leaf = new_leaf_DnaProfileNode(read); temp = DnaProfileNode_alloc(); temp->type = DnaProfileNode_SET; temp->left = head; temp->right = leaf; head = temp; } return head; } DnaProfileNode * new_leaf_DnaProfileNode(Sequence * seq) { DnaProfileNode * out; assert(seq != NULL); out = DnaProfileNode_alloc(); out->type = DnaProfileNode_LEAF; out->leaf = seq; return out; } void populate_DnaProfileNode_from_root(DnaProfileNode * root,DnaProfileEnginePara * dpep) { assert(root != NULL); if( root->left->type == DnaProfileNode_SET ) { populate_DnaProfileNode_from_root(root->left,dpep); } if( root->right->type == DnaProfileNode_SET ) { populate_DnaProfileNode_from_root(root->right,dpep); } /* left and right now populated */ root->set = join_two_DnaProfileNode(root->left,root->right,dpep); } DnaProfileSet * join_two_DnaProfileNode(DnaProfileNode * left,DnaProfileNode * right,DnaProfileEnginePara * dpep) { /* big switch around the types of left and right */ fprintf(stderr,"Entering join with %d vs %d\n",left->type,right->type); if( left->type == DnaProfileNode_LEAF && right->type == DnaProfileNode_LEAF ) { assert(left->leaf); assert(right->leaf); return DnaProfileSet_from_leaf_leaf(left->leaf,right->leaf,dpep); } if( left->type == DnaProfileNode_SET && right->type == DnaProfileNode_LEAF ) { assert(left->set); assert(right->leaf); return DnaProfileSet_from_leaf_node(right->leaf,left->set,dpep); } if( left->type == DnaProfileNode_LEAF && right->type == DnaProfileNode_SET ) { assert(left->leaf); assert(right->set); return DnaProfileSet_from_leaf_node(left->leaf,right->set,dpep); } if( left->type == DnaProfileNode_SET && right->type == DnaProfileNode_SET ) { assert(left->set); assert(right->set); return DnaProfileSet_from_node_node(left->set,right->set,dpep); } fatal("Should not get here. Weird no leaf/node case"); return NULL; } DnaProfileEnginePara * new_DnaProfileEnginePara_from_argv(int * argc,char ** argv) { DnaProfileEnginePara * out; out = DnaProfileEnginePara_alloc(); out->dpri = new_DPRunImpl_from_argv(argc,argv); out->setpara = new_LocalCisHitSetPara_from_argv(argc,argv); out->lchs = standard_LocalCisHitScore(NMaskType_VARIABLE); out->rm = RandomModelDNA_std(); out->pseudo = 0.5; out->open_unmatched = 0.001; out->ext_unmatched = 0.8; out->gap_unmatched = 0.5; out->seq_id = 0.8; out->m2i = 0.1; out->m2d = 0.1; out->i2i = 0.8; out->d2d = 0.8; out->min_seq_prof = 400; strip_out_float_argument(argc,argv,"dnap_pseudo",&out->pseudo); strip_out_float_argument(argc,argv,"dnap_open_un",&out->open_unmatched); strip_out_float_argument(argc,argv,"dnap_ext_un",&out->ext_unmatched); strip_out_float_argument(argc,argv,"dnap_gap_un",&out->ext_unmatched); strip_out_float_argument(argc,argv,"dnap_seq_self",&out->seq_id); strip_out_float_argument(argc,argv,"dnap_m2i",&out->m2i); strip_out_float_argument(argc,argv,"dnap_m2d",&out->m2d); strip_out_float_argument(argc,argv,"dnap_i2i",&out->i2i); strip_out_float_argument(argc,argv,"dnap_d2d",&out->d2d); strip_out_integer_argument(argc,argv,"dnap_min_seq_prof",&out->min_seq_prof); return out; } void show_help_DnaProfileEnginePara(FILE * ofp) { fprintf(ofp,"DnaProfile build/matching parameters\n"); fprintf(ofp," -dnap_pseudo [0.1] pseudo count used in profile construction\n"); fprintf(ofp," -dnap_open_un [0.4] unmatched probability open\n"); fprintf(ofp," -dnap_ext_un [0.95] unmatched extend probability\n"); fprintf(ofp," -dnap_ext_un [0.5] unmatched gap probability\n"); fprintf(ofp," -dnap_seq_self [0.8] %% identity for pure sequence matching\n"); fprintf(ofp," -dnap_m2i [0.1] Match 2 insert transition in dnaprofiles\n"); fprintf(ofp," -dnap_m2d [0.1] Match 2 delete transitions in dnaprofiles\n"); fprintf(ofp," -dnap_i2i [0.8] Insert 2 Insert transition in dnaprofiles\n"); fprintf(ofp," -dnap_d2d [0.8] Delete 2 Delete transition in dnaprofiles\n"); fprintf(ofp," -dnap_min_seq_prof [400] minimum score for sequence profile matching\n"); fprintf(ofp,"Local CisHit para for sequence to sequnence matching\n"); show_help_LocalCisHitSetPara(ofp); show_help_DPRunImpl(ofp); } DnaProfileSet * filter_DnaProfileSet(DnaProfileSet * in,int min_length,int min_score) { int i; DnaProfileSet * out; out = DnaProfileSet_alloc_std(); for(i=0;ilen;i++) { if( in->dnap[i]->sa->seq[0]->len <= min_length ) { continue; } add_DnaProfileSet(out,hard_link_DnaProfile(in->dnap[i])); } return out; } DnaProfileSet * DnaProfileSet_from_leaf_leaf(Sequence * one,Sequence * two,DnaProfileEnginePara * dpep) { DnaProfileSet * out; DnaMatrix * dm; DnaProbMatrix * dmp; PairwiseShortDna * psd; LocalCisHitSet * set; Sequence * two_rev; DnaProfile * dp; SeqAlign * sa; Sequence * temp1; Sequence * temp2; char * temp_seq1; char * temp_seq2; int unmatched; int seq1_i,seq2_i; AlnColumn * alc; int i; two_rev = reverse_complement_Sequence(two); dmp = DnaProbMatrix_from_match(0.65,NMaskType_BANNED); assert(dmp); flat_null_DnaProbMatrix(dmp); dm = DnaMatrix_from_DnaProbMatrix(dmp); show_DnaMatrix(dm,stderr); psd = query_to_reverse_target(one,two,dm,0,one->len,0,two->len); set = make_LocalCisHitSet(one,two,two_rev,psd->forward,psd->reverse,dpep->setpara,dpep->lchs,NULL,NULL,NULL,NULL,0,dpep->dpri); temp_seq1 = calloc(one->len > two->len ? one->len : two->len,sizeof(char)); temp_seq2 = calloc(one->len > two->len ? one->len : two->len,sizeof(char)); out = DnaProfileSet_alloc_std(); for(i=0;ilen;i++) { unmatched = 1; sa = NULL; /* * Main loop over DBA style alignment. We need to make one * DnaProfile per matching block, which are separated by unmatched * blocks. Could potentially be no blocks. * * Extra annoyance provided by the "wrong" convention being used in * DBA alignments, meaning that "inserts" label the "sequence" containing * strand, not the non-sequence containing strand. Stupid, but dbadisplay * uses this convention, so if we changed, would have to fix lots of exisiting * code. Not ideal. * */ for(alc=set->lch[i]->alb->start;alc != NULL;alc=alc->next) { /* hitting an unmatched block */ if( unmatched == 0 && (strcmp(alc->alu[0]->text_label,"UM") == 0 || strcmp(alc->alu[0]->text_label,"UI") == 0 || strcmp(alc->alu[0]->text_label,"END") == 0) ) { /* if we have an alignment, put it away now */ if( sa != NULL ) { temp_seq1[seq1_i] = '\0'; temp_seq2[seq2_i] = '\0'; temp1 = Sequence_from_static_memory(one->name,temp_seq1); temp2 = Sequence_from_static_memory(two->name,temp_seq2); add_SeqAlign(sa,temp1); add_SeqAlign(sa,temp2); dp = naive_DnaProfile_from_SeqAlign(sa,0.15,0.1,0.1,0.8,0.8); fold_RandomModel_DnaProfile(dp,dpep->rm); add_DnaProfileSet(out,dp); free_SeqAlign(sa); /* hard linked inside DP */ sa = NULL; } continue; } else if( unmatched == 1 && (strstartcmp(alc->alu[0]->text_label,"MM") == 0 || strstartcmp(alc->alu[0]->text_label,"MI") == 0 ) ) { unmatched = 0; sa = SeqAlign_alloc_len(2); seq1_i = 0; seq2_i = 0; } /* only if we are in a matched block */ if( unmatched == 0 ) { /* Bloody twisted DBA convention - Niclas has alot to answer for. Evil stuff -- MI is on the wrong strand! */ if( strstartcmp(alc->alu[0]->text_label,"MI") == 0 ) { /* means 0 has sequence, other has gap */ temp_seq1[seq1_i++] = one->seq[alc->alu[0]->end]; temp_seq2[seq2_i++] = '-'; } else if ( strstartcmp(alc->alu[1]->text_label,"MI") == 0 ) { temp_seq1[seq1_i++] = '-'; temp_seq2[seq2_i++] = two->seq[alc->alu[1]->end]; } else if ( strstartcmp(alc->alu[0]->text_label,"MM") == 0 && strstartcmp(alc->alu[1]->text_label,"MM") == 0 ) { temp_seq1[seq1_i++] = one->seq[alc->alu[0]->end]; temp_seq2[seq2_i++] = two->seq[alc->alu[1]->end]; } else { warn("Impossible label pair reached in matched block local cis hit stuff, %s,%s",alc->alu[0]->text_label,alc->alu[1]->text_label); } } } } free(temp_seq1); free(temp_seq2); free_PairwiseShortDna(psd); free_LocalCisHitSet(set); free_DnaMatrix(dm); free_DnaProbMatrix(dmp); return out; } DnaProfileSet * DnaProfileSet_from_node_node(DnaProfileSet * one,DnaProfileSet * two,DnaProfileEnginePara * dpep) { DnaProfile * new_dnap; DnaProfileSet * out; DnaProfileMatchPairSet * dpmps; SeqAlign * sa; int i; int j; dpmps = DnaProfileMatchPairSet_alloc_std(); for(i=0;ilen;i++) { for(j=0;jlen;j++) { add_DnaProfileMatchPairSet(dpmps,DnaProfileMatchPair_from_DnaProfile(one->dnap[i],two->dnap[j],dpep)); } } sort_DnaProfileMatchPairSet_by_score(dpmps); out = DnaProfileSet_alloc_std(); for(i=0;ilen;i++) { /* check this profile has not already been used */ /* not done yet */ if( dpmps->pair[i]->score < dpep->min_seq_prof ) { fprintf(stderr,"Warning... rejecting match due to score %d vs %d\n",dpmps->pair[i]->score,dpep->min_seq_prof); break; } sa = merged_SeqAlign(dpmps->pair[i]->query,dpmps->pair[i]->target,dpmps->pair[i]->alb); fprintf(stderr,"Node/Node Accepting score at %d length %d\n",dpmps->pair[i]->score,sa->seq[0]->len); new_dnap = naive_DnaProfile_from_SeqAlign(sa,dpep->pseudo,dpep->m2i,dpep->m2d,dpep->i2i,dpep->d2d); assert(new_dnap != NULL); /* need to log-odds dnap here */ fold_RandomModel_DnaProfile(new_dnap,dpep->rm); add_DnaProfileSet(out,new_dnap); } fprintf(stderr,"Returing %d profiles\n",out->len); return out; } DnaProfileSet * DnaProfileSet_from_leaf_node(Sequence * one,DnaProfileSet * two,DnaProfileEnginePara * dpep) { DnaProfileSet * out; DnaProfile * dnap; DnaProfile * dnapr; DnaProfileMatchPairSet * dpmps; Sequence * rev; SeqAlign * sa; DnaProfile * new_dnap; int i; int j; dpmps = DnaProfileMatchPairSet_alloc_std(); out = DnaProfileSet_alloc_std(); rev = reverse_complement_Sequence(one); dnap = naive_DnaProfile_from_Sequence(one,dpep->seq_id,dpep->m2i,dpep->m2d,dpep->i2i,dpep->d2d); dnapr = naive_DnaProfile_from_Sequence(rev,dpep->seq_id,dpep->m2i,dpep->m2d,dpep->i2i,dpep->d2d); fold_RandomModel_DnaProfile(dnap,dpep->rm); fold_RandomModel_DnaProfile(dnapr,dpep->rm); for(i=0;ilen;i++) { fprintf(stderr,"Processing %d\n",i); add_DnaProfileMatchPairSet(dpmps,DnaProfileMatchPair_from_DnaProfile(dnap,two->dnap[i],dpep)); add_DnaProfileMatchPairSet(dpmps,DnaProfileMatchPair_from_DnaProfile(dnapr,two->dnap[i],dpep)); } fprintf(stderr,"Sorting....\n"); sort_DnaProfileMatchPairSet_by_score(dpmps); for(i=0;ilen;i++) { /* check this profile has not already been used */ /* not done yet */ if( dpmps->pair[i]->score < dpep->min_seq_prof ) { fprintf(stderr,"Warning... rejecting match due to score %d vs %d\n",dpmps->pair[i]->score,dpep->min_seq_prof); break; } sa = merged_SeqAlign(dpmps->pair[i]->query,dpmps->pair[i]->target,dpmps->pair[i]->alb); new_dnap = naive_DnaProfile_from_SeqAlign(sa,dpep->pseudo,dpep->m2i,dpep->m2d,dpep->i2i,dpep->d2d); /* need to log-odds dnap here */ fold_RandomModel_DnaProfile(new_dnap,dpep->rm); add_DnaProfileSet(out,new_dnap); } fprintf(stderr,"Freeing DNA profiles...\n"); free_DnaProfile(dnap); free_DnaProfile(dnapr); fprintf(stderr,"Freeing sequences\n"); free_Sequence(rev); return out; } DnaProfileMatchPair * DnaProfileMatchPair_from_DnaProfile(DnaProfile * query,DnaProfile * target,DnaProfileEnginePara * dpep) { DnaProfileMatchPair * out; DnaProfileScore * query_s; DnaProfileScore * target_s; DnaProfileMatchScore * match; PackAln * pal; assert(query != NULL); assert(target != NULL); /* assert(query->len > 4 ); assert(target->len > 4); */ out = DnaProfileMatchPair_alloc(); out->query = hard_link_DnaProfile(query); out->target = hard_link_DnaProfile(target); query_s = DnaProfileScore_from_DnaProfile(query); target_s = DnaProfileScore_from_DnaProfile(target); fprintf(stderr,"Matching %d to %d\n",query->len,target->len); match= new_ALLR_DnaProfileMatchScore(query,target); pal = PackAln_bestmemory_DnaProfileMat(query_s,target_s,match,Probability2Score(dpep->open_unmatched),Probability2Score(dpep->ext_unmatched),Probability2Score(dpep->gap_unmatched),NULL,dpep->dpri); fprintf(stderr,"...Made pal %d\n",pal); out->alb = convert_PackAln_to_AlnBlock_DnaProfileMat(pal); out->score = pal->score; fprintf(stderr,"...freeing pal\n"); free_PackAln(pal); fprintf(stderr,"...freeing match\n"); free_DnaProfileMatchScore(match); fprintf(stderr,"...freeing query\n"); free_DnaProfileScore(query_s); fprintf(stderr,"...freeing target\n"); free_DnaProfileScore(target_s); return out; } void sort_DnaProfileMatchPairSet_by_score(DnaProfileMatchPairSet * set) { sort_DnaProfileMatchPairSet(set,compare_DnaProfileMatchPair); } int compare_DnaProfileMatchPair(DnaProfileMatchPair * one,DnaProfileMatchPair * two) { return two->score - one->score; } void show_DnaProfileSet(DnaProfileSet * dnaps,RandomModelDNA * rm,FILE * ofp) { int i; for(i=0;ilen;i++) { show_DnaProfile(dnaps->dnap[i],rm,ofp); } } %} wise-2.4.1/src/models/matchsum.dy0000644000175000001440000001273607313404547016322 0ustar philippusers %{ #include "gwrap.h" #define MatchSummarySetLISTLENGTH 128 %} struct MatchSummary double bits char * qname char * tname int qstart int qend int tstart int tend int qintron !def="0" int qframeshift !def="0" int tintron !def="0" int tframeshift !def="0" %info A Match Summary has summary statistics for a single alignment, with the two start/end ranges and the number of introns and frameshifts for each sequence (obviously, if one is a protein then neither are valid!) %% struct MatchSummarySet MatchSummary ** ms !list %info This holds a set of MatchSummaries, %% api object MatchSummarySet des free_MatchSummarySet func MatchSummarySet_from_AlnBlock_estwise func MatchSummarySet_from_AlnBlock_genewise endobject object MatchSummary des free_MatchSummary endobject endapi %{ #include "matchsum.h" %func Builds a MatchSummarySet from a EstWise alignment. this makes alot of assumptions about the labels setc in alb, so make sure it was a estwise alignment - however as you can notice this is exactly the same labels as found in genewise set %% MatchSummarySet * MatchSummarySet_from_AlnBlock_estwise(AlnBlock * alb,char * qname,int offset,Sequence * target) { return MatchSummarySet_from_AlnBlock_genewise(alb,qname,offset,target); } %func Builds a MatchSummarySet from a GeneWise alignment. this makes alot of assumptions about the labels setc in alb, so make sure it was a genewise alignment %% MatchSummarySet * MatchSummarySet_from_AlnBlock_genewise(AlnBlock * alb,char * qname,int protoff,Sequence * target) { MatchSummarySet * out; MatchSummary * ms; AlnColumn * alc; int len; out = MatchSummarySet_alloc_std(); alc = alb->start; while( (ms = MatchSummary_from_AlnColumn_genewise(alc,&alc)) != NULL ) { ms->qstart+= protoff-1; /*** offset in old-style offset mode ***/ ms->qend += protoff-1; if( target->offset > target->end ) { len = ms->tend - ms->tstart; /* fprintf(stderr,"Look - length %d\n",len); */ ms->tstart = target->offset-1 - ms->tstart; ms->tend = ms->tstart - len; } else { ms->tstart += target->offset-1; ms->tend += target->offset-1; } ms->qname = stringalloc(qname); ms->tname = stringalloc(target->name); add_MatchSummarySet(out,ms); } return out; } %func For making each alignment %type internal %% MatchSummary * MatchSummary_from_AlnColumn_genewise(AlnColumn * alc,AlnColumn ** end) { MatchSummary * out; int score; for(;alc != NULL && is_random_AlnColumn_genewise(alc) == TRUE;alc = alc->next) ; if( alc == NULL ) { *end = NULL; return NULL; } out = MatchSummary_alloc(); /* NB alignment start is one before the C ordinate start system */ out->qstart = alc->alu[0]->start+1; /* in C coords */ out->tstart = alc->alu[1]->start+1; /* in C coords */ score = alc->alu[0]->score[0]; for(;alc->next != NULL && is_random_AlnColumn_genewise(alc->next) == FALSE;alc = alc->next) { score += alc->next->alu[0]->score[0]; if( strcmp(alc->alu[1]->text_label,"SEQUENCE_DELETION") == 0 || strcmp(alc->alu[1]->text_label,"SEQUENCE_INSERTION") == 0) out->tframeshift++; else if ( strcmp(alc->alu[1]->text_label,"CENTRAL_INTRON") == 0 ) out->tintron++; /* NB, assuming we have collapsed central intron labels! */ } out->qend = alc->alu[0]->end+1; /* in C coords */ out->tend = alc->alu[1]->end+1; /*score += alc->alu[0]->score[0];*/ out->bits = Score2Bits(score); /*** hmm... this could be bad news ***/ *end = alc->next; return out; } %func Shows a header (bits Query start etc) which matches the order of the show_MatchSummarySet_genewise %% void show_MatchSummary_genewise_header(FILE * ofp) { fprintf(ofp,"Bits Query start end Target start end idels introns\n"); } %func shows Matchsummary for genewise results, ie with target indels and introns %% void show_MatchSummarySet_genewise(MatchSummarySet * mss,FILE * ofp) { int i; for(i=0;ilen;i++) show_MatchSummary_genewise(mss->ms[i],ofp); } %func shows a single match summary %type internal %% void show_MatchSummary_genewise(MatchSummary * ms,FILE * ofp) { if( ms->tstart < ms->tend ) fprintf(ofp,"%4.2f %-12s %4d %4d %-12s %4d %4d %4d %4d\n", ms->bits, ms->qname, ms->qstart+1, /* map to bio coords */ ms->qend, ms->tname, ms->tstart+1, /* map to 'bio coords */ ms->tend, ms->tframeshift, ms->tintron); else fprintf(ofp,"%4.2f %-12s %4d %4d %-12s %4d %4d %4d %4d\n", ms->bits, ms->qname, ms->qstart+1, /* map to bio coords */ ms->qend, ms->tname, ms->tstart+1, /* map to 'bio coords */ ms->tend+2, /* map to bio coords */ ms->tframeshift, ms->tintron); } %func Shows a header (bits Query start etc) which matches the order of the show_MatchSummarySet_estwise %% void show_MatchSummary_estwise_header(FILE * ofp) { fprintf(ofp,"Bits Query start end Target start end idels\n"); } %func Shows an estwise match, ie with only the target with indels %% void show_MatchSummarySet_estwise(MatchSummarySet * mss,FILE * ofp) { int i; for(i=0;ilen;i++) show_MatchSummary_estwise(mss->ms[i],ofp); } %func shows a single estwise match %type internal %% void show_MatchSummary_estwise(MatchSummary * ms,FILE * ofp) { fprintf(ofp,"%4.2f %-12s %4d %4d %-12s %4d %4d %4d\n", ms->bits, ms->qname, ms->qstart+1, /* map to bio coords */ ms->qend, ms->tname, ms->tstart+1, /* map to 'bio coords */ ms->tend, ms->tframeshift); } wise-2.4.1/src/models/matchsum.xs0000644000175000001440000001346110670453714016334 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::MatchSummarySet Wise2_MatchSummarySet * MatchSummarySet_from_AlnBlock_estwise(alb,qname,offset,target) Wise2_AlnBlock * alb char * qname int offset Wise2_Sequence * target CODE: RETVAL = Wise2_MatchSummarySet_from_AlnBlock_estwise(alb,qname,offset,target); OUTPUT: RETVAL Wise2_MatchSummarySet * MatchSummarySet_from_AlnBlock_genewise(alb,qname,protoff,target) Wise2_AlnBlock * alb char * qname int protoff Wise2_Sequence * target CODE: RETVAL = Wise2_MatchSummarySet_from_AlnBlock_genewise(alb,qname,protoff,target); OUTPUT: RETVAL Wise2_MatchSummarySet * hard_link_MatchSummarySet(obj) Wise2_MatchSummarySet * obj CODE: RETVAL = Wise2_hard_link_MatchSummarySet(obj); OUTPUT: RETVAL Wise2_MatchSummarySet * MatchSummarySet_alloc_std() CODE: RETVAL = Wise2_MatchSummarySet_alloc_std(); OUTPUT: RETVAL Wise2_MatchSummary * ms(obj,i) Wise2_MatchSummarySet * obj int i INIT: Wise2_MatchSummary * temp; CODE: temp = Wise2_hard_link_MatchSummary(Wise2_access_ms_MatchSummarySet(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_ms(obj) Wise2_MatchSummarySet * obj CODE: RETVAL = Wise2_length_ms_MatchSummarySet(obj); OUTPUT: RETVAL int flush_ms(obj) Wise2_MatchSummarySet * obj CODE: RETVAL = Wise2_flush_MatchSummarySet(obj); OUTPUT: RETVAL boolean add_ms(obj,add) Wise2_MatchSummarySet * obj Wise2_MatchSummary * add CODE: RETVAL = Wise2_add_MatchSummarySet(obj,Wise2_hard_link_MatchSummary(add)); OUTPUT: RETVAL Wise2_MatchSummarySet * new(class) char * class PPCODE: Wise2_MatchSummarySet * out; out = Wise2_MatchSummarySet_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_MatchSummarySet * obj CODE: Wise2_free_MatchSummarySet(obj); void each_ms(obj) Wise2_MatchSummarySet * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_ms_MatchSummarySet(obj); for(i=0;ibasematrix->matrix[((j+3)*14)+STATE][i+1] #define SyWise20_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+3] #define SyWise20_READ_OFF_ERROR -5 #define SyWise20_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+4)%4][((i+1)*14)+STATE] #define SyWise20_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+4)%4][STATE] #define SyWise20_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define SyWise20_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_SyWise20(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_SyWise20(SyWise20 * mat) { SyWise20_access_func_holder holder; holder.access_main = SyWise20_shatter_access_main; holder.access_special = SyWise20_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_SyWise20(mat,holder); } /* Function: SyWise20_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int SyWise20_shatter_access_main(SyWise20 * mat,int i,int j,int state) { return SyWise20_SHATTER_MATRIX(mat,i,j,state); } /* Function: SyWise20_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int SyWise20_shatter_access_special(SyWise20 * mat,int i,int j,int state) { return SyWise20_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_SyWise20(mat,dpenv) * * Descrip: This function calculates the SyWise20 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [SyWise20 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_SyWise20(SyWise20 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_0_3; int * SIG_1_2; int * SIG_1_1; int * SIG_0_1; int * SIG_0_2; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,14,lenj,4); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("SyWise20 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); /* For state CODON */ /* setting first movement to score */ score = SIG_1_3[CODON] + mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]; /* From state CODON to state CODON */ temp = SIG_0_3[CODON] + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state NON_CDS_CONSERVED to state CODON */ temp = SyWise20_SHATTER_SPECIAL(mat,i-1,j-3,NON_CDS_CONSERVED) + mat->start->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]; if( temp > score ) { score = temp; } } /* From state INTRON_MATCH_0 to state CODON */ temp = SIG_1_3[INTRON_MATCH_0] + CSEQ_PAIR_3SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_1 to state CODON */ temp = SIG_1_2[INTRON_MATCH_1] + CSEQ_PAIR_3SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_2 to state CODON */ temp = SIG_1_1[INTRON_MATCH_2] + CSEQ_PAIR_3SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ SIG_0_0[CODON] = score; /* state CODON is a source for special NON_CDS_CONSERVED */ temp = score + (((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)])) + (0) ; if( temp > SyWise20_SHATTER_SPECIAL(mat,i,j,NON_CDS_CONSERVED) ) { SyWise20_SHATTER_SPECIAL(mat,i,j,NON_CDS_CONSERVED) = temp; } /* Finished calculating state CODON */ /* For state INTRON_MATCH_0 */ /* setting first movement to score */ score = SIG_0_1[CODON] + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_0 to state INTRON_MATCH_0 */ temp = SIG_0_1[INTRON_0] + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_0 to state INTRON_MATCH_0 */ temp = SIG_0_1[INTRON_MATCH_0] + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_MATCH_0] = score; /* Finished calculating state INTRON_MATCH_0 */ /* For state INTRON_0 */ /* setting first movement to score */ score = SIG_0_1[INTRON_MATCH_0] + 0; /* From state INTRON_0 to state INTRON_0 */ temp = SIG_0_1[INTRON_0] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_0] = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_MATCH_1 */ /* setting first movement to score */ score = SIG_0_2[CODON] + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_1 to state INTRON_MATCH_1 */ temp = SIG_0_1[INTRON_1] + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_1 to state INTRON_MATCH_1 */ temp = SIG_0_1[INTRON_MATCH_1] + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_MATCH_1] = score; /* Finished calculating state INTRON_MATCH_1 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SIG_0_1[INTRON_MATCH_1] + 0; /* From state INTRON_1 to state INTRON_1 */ temp = SIG_0_1[INTRON_1] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_1] = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_MATCH_2 */ /* setting first movement to score */ score = SIG_0_3[CODON] + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_2 to state INTRON_MATCH_2 */ temp = SIG_0_1[INTRON_2] + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_2 to state INTRON_MATCH_2 */ temp = SIG_0_1[INTRON_MATCH_2] + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_MATCH_2] = score; /* Finished calculating state INTRON_MATCH_2 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SIG_0_1[INTRON_MATCH_2] + 0; /* From state INTRON_2 to state INTRON_2 */ temp = SIG_0_1[INTRON_2] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_2] = score; /* Finished calculating state INTRON_2 */ /* For state REV_CODON */ /* setting first movement to score */ score = SIG_1_3[REV_CODON] + mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]; /* From state REV_CODON to state REV_CODON */ temp = SIG_0_3[REV_CODON] + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_0 to state REV_CODON */ temp = SIG_1_3[REV_INTRON_MATCH_0] + CSEQ_REV_PAIR_5SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_1 to state REV_CODON */ temp = SIG_1_1[REV_INTRON_MATCH_1] + CSEQ_REV_PAIR_5SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_2 to state REV_CODON */ temp = SIG_1_2[REV_INTRON_MATCH_2] + CSEQ_PAIR_5SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state NON_CDS_CONSERVED to state REV_CODON */ temp = SyWise20_SHATTER_SPECIAL(mat,i-1,j-3,NON_CDS_CONSERVED) + mat->start->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for REV_CODON */ /* Add any movement independant score and put away */ SIG_0_0[REV_CODON] = score; /* state REV_CODON is a source for special NON_CDS_CONSERVED */ temp = score + (((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)])) + (0) ; if( temp > SyWise20_SHATTER_SPECIAL(mat,i,j,NON_CDS_CONSERVED) ) { SyWise20_SHATTER_SPECIAL(mat,i,j,NON_CDS_CONSERVED) = temp; } /* Finished calculating state REV_CODON */ /* For state REV_INTRON_MATCH_0 */ /* setting first movement to score */ score = SIG_0_1[REV_CODON] + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_REV_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_0 to state REV_INTRON_MATCH_0 */ temp = SIG_0_1[REV_INTRON_0] + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_0 to state REV_INTRON_MATCH_0 */ temp = SIG_0_1[REV_INTRON_MATCH_0] + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SIG_0_0[REV_INTRON_MATCH_0] = score; /* Finished calculating state REV_INTRON_MATCH_0 */ /* For state REV_INTRON_0 */ /* setting first movement to score */ score = SIG_0_1[REV_INTRON_0] + 0; /* From state REV_INTRON_MATCH_0 to state REV_INTRON_0 */ temp = SIG_0_1[REV_INTRON_MATCH_0] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_0 */ /* Add any movement independant score and put away */ SIG_0_0[REV_INTRON_0] = score; /* Finished calculating state REV_INTRON_0 */ /* For state REV_INTRON_MATCH_1 */ /* setting first movement to score */ score = SIG_0_3[REV_CODON] + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_1 to state REV_INTRON_MATCH_1 */ temp = SIG_0_1[REV_INTRON_1] + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_1 to state REV_INTRON_MATCH_1 */ temp = SIG_0_1[REV_INTRON_MATCH_1] + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SIG_0_0[REV_INTRON_MATCH_1] = score; /* Finished calculating state REV_INTRON_MATCH_1 */ /* For state REV_INTRON_1 */ /* setting first movement to score */ score = SIG_0_1[REV_INTRON_1] + 0; /* From state REV_INTRON_MATCH_1 to state REV_INTRON_1 */ temp = SIG_0_1[REV_INTRON_MATCH_1] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_1 */ /* Add any movement independant score and put away */ SIG_0_0[REV_INTRON_1] = score; /* Finished calculating state REV_INTRON_1 */ /* For state REV_INTRON_MATCH_2 */ /* setting first movement to score */ score = SIG_0_2[REV_CODON] + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_2 to state REV_INTRON_MATCH_2 */ temp = SIG_0_1[REV_INTRON_2] + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_2 to state REV_INTRON_MATCH_2 */ temp = SIG_0_1[REV_INTRON_MATCH_2] + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SIG_0_0[REV_INTRON_MATCH_2] = score; /* Finished calculating state REV_INTRON_MATCH_2 */ /* For state REV_INTRON_2 */ /* setting first movement to score */ score = SIG_0_1[REV_INTRON_2] + 0; /* From state REV_INTRON_MATCH_2 to state REV_INTRON_2 */ temp = SIG_0_1[REV_INTRON_MATCH_2] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_2 */ /* Add any movement independant score and put away */ SIG_0_0[REV_INTRON_2] = score; /* Finished calculating state REV_INTRON_2 */ } /* Special state NON_CDS_CONSERVED has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_SHATTER_SPECIAL(mat,0,j,NON_CDS_CONSERVED); /* Source CODON for state NON_CDS_CONSERVED is not special... already calculated */ /* Source REV_CODON for state NON_CDS_CONSERVED is not special... already calculated */ /* Source NON_CDS_CONSERVED is a special source for NON_CDS_CONSERVED */ temp = SyWise20_SHATTER_SPECIAL(mat,0,j - 1,NON_CDS_CONSERVED) + (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) + (0); if( temp > score ) score = temp; /* Source RND_SEQ is a special source for NON_CDS_CONSERVED */ temp = SyWise20_SHATTER_SPECIAL(mat,0,j - 1,RND_SEQ) + ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ SyWise20_SHATTER_SPECIAL(mat,0,j,NON_CDS_CONSERVED) = score; /* Finished updating state NON_CDS_CONSERVED */ /* Special state RND_SEQ has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_SHATTER_SPECIAL(mat,0,j,RND_SEQ); /* Source NON_CDS_CONSERVED is a special source for RND_SEQ */ temp = SyWise20_SHATTER_SPECIAL(mat,0,j - 1,NON_CDS_CONSERVED) + (0) + (0); if( temp > score ) score = temp; /* Source RND_SEQ is a special source for RND_SEQ */ temp = SyWise20_SHATTER_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) score = temp; /* Source START is a special source for RND_SEQ */ temp = SyWise20_SHATTER_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ SyWise20_SHATTER_SPECIAL(mat,0,j,RND_SEQ) = score; /* Finished updating state RND_SEQ */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_SHATTER_SPECIAL(mat,0,j,END); /* Source RND_SEQ is a special source for END */ temp = SyWise20_SHATTER_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ SyWise20_SHATTER_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: search_SyWise20(dbsi,out,exonmodel,seq,codon,nonc,start,stop,intron_open,gene_open,nonc_cost) * * Descrip: This function makes a database search of SyWise20 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: exonmodel [UNKN ] Undocumented argument [SyExonScore*] * Arg: seq [UNKN ] Undocumented argument [ComplexSequence*] * Arg: codon [UNKN ] Undocumented argument [PairBaseCodonModelScore*] * Arg: nonc [UNKN ] Undocumented argument [PairBaseModelScore*] * Arg: start [UNKN ] Undocumented argument [PairBaseCodonModelScore*] * Arg: stop [UNKN ] Undocumented argument [PairBaseCodonModelScore*] * Arg: intron_open [UNKN ] Undocumented argument [Score] * Arg: gene_open [UNKN ] Undocumented argument [Score] * Arg: nonc_cost [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_SyWise20(DBSearchImpl * dbsi,Hscore * out,SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_SyWise20 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_SyWise20. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_SyWise20. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for SyWise20, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_SyWise20(out,exonmodel,seq ,codon,nonc,start,stop,intron_open,gene_open,nonc_cost); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_SyWise20 *) ckalloc(sizeof(struct thread_pool_holder_SyWise20)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->exonmodel = exonmodel; holder->seq = seq; holder->codon = codon; holder->nonc = nonc; holder->start = start; holder->stop = stop; holder->intron_open = intron_open; holder->gene_open = gene_open; holder->nonc_cost = nonc_cost; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_SyWise20,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for SyWise20"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from SyWise20",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_SyWise20(ptr) * * Descrip: dummy loop code foreach thread for SyWise20 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * thread_loop_SyWise20(void * ptr) { fatal("dummy thread loop function"); } /* Function: serial_search_SyWise20(out,exonmodel,seq,codon,nonc,start,stop,intron_open,gene_open,nonc_cost) * * Descrip: This function makes a database search of SyWise20 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: exonmodel [UNKN ] Undocumented argument [SyExonScore*] * Arg: seq [UNKN ] Undocumented argument [ComplexSequence*] * Arg: codon [UNKN ] Undocumented argument [PairBaseCodonModelScore*] * Arg: nonc [UNKN ] Undocumented argument [PairBaseModelScore*] * Arg: start [UNKN ] Undocumented argument [PairBaseCodonModelScore*] * Arg: stop [UNKN ] Undocumented argument [PairBaseCodonModelScore*] * Arg: intron_open [UNKN ] Undocumented argument [Score] * Arg: gene_open [UNKN ] Undocumented argument [Score] * Arg: nonc_cost [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_SyWise20(Hscore * out,SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_SyWise20(exonmodel, seq , codon, nonc, start, stop, intron_open, gene_open, nonc_cost); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("SyWise20 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_SyWise20(exonmodel,seq,codon,nonc,start,stop,intron_open,gene_open,nonc_cost) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_SyWise20_only * * * Arg: exonmodel [UNKN ] query data structure [SyExonScore*] * Arg: seq [UNKN ] target data structure [ComplexSequence*] * Arg: codon [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: nonc [UNKN ] Resource [PairBaseModelScore*] * Arg: start [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: stop [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: intron_open [UNKN ] Resource [Score] * Arg: gene_open [UNKN ] Resource [Score] * Arg: nonc_cost [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_SyWise20(SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost) { int bestscore = NEGI; int i; int j; int k; SyWise20 * mat; mat = allocate_SyWise20_only(exonmodel, seq , codon, nonc, start, stop, intron_open, gene_open, nonc_cost); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(4,(mat->leni + 1) * 14,4,4)) == NULL) { warn("Score only matrix for SyWise20 cannot be allocated, (asking for 3 by %d cells)",mat->leni*14); mat = free_SyWise20(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<5;j++) { for(i=(-1);ileni;i++) { for(k=0;k<14;k++) SyWise20_VSMALL_MATRIX(mat,i,j,k) = NEGI; } SyWise20_VSMALL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) = NEGI; SyWise20_VSMALL_SPECIAL(mat,i,j,RND_SEQ) = NEGI; SyWise20_VSMALL_SPECIAL(mat,i,j,START) = 0; SyWise20_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state CODON */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-1,j-3,CODON) + mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]; /* From state CODON to state CODON */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-3,CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state NON_CDS_CONSERVED to state CODON */ temp = SyWise20_VSMALL_SPECIAL(mat,i-1,j-3,NON_CDS_CONSERVED) + mat->start->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]; if( temp > score ) { score = temp; } } /* From state INTRON_MATCH_0 to state CODON */ temp = SyWise20_VSMALL_MATRIX(mat,i-1,j-3,INTRON_MATCH_0) + CSEQ_PAIR_3SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_1 to state CODON */ temp = SyWise20_VSMALL_MATRIX(mat,i-1,j-2,INTRON_MATCH_1) + CSEQ_PAIR_3SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_2 to state CODON */ temp = SyWise20_VSMALL_MATRIX(mat,i-1,j-1,INTRON_MATCH_2) + CSEQ_PAIR_3SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,CODON) = score; /* state CODON is a source for special NON_CDS_CONSERVED */ temp = score + (((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)])) + (0) ; if( temp > SyWise20_VSMALL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) ) { SyWise20_VSMALL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) = temp; } /* Finished calculating state CODON */ /* For state INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_0 to state INTRON_MATCH_0 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_0 to state INTRON_MATCH_0 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,INTRON_MATCH_0) = score; /* Finished calculating state INTRON_MATCH_0 */ /* For state INTRON_0 */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + 0; /* From state INTRON_0 to state INTRON_0 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-0,j-2,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_1 to state INTRON_MATCH_1 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_1 to state INTRON_MATCH_1 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,INTRON_MATCH_1) = score; /* Finished calculating state INTRON_MATCH_1 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + 0; /* From state INTRON_1 to state INTRON_1 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-0,j-3,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_2 to state INTRON_MATCH_2 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_2 to state INTRON_MATCH_2 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,INTRON_MATCH_2) = score; /* Finished calculating state INTRON_MATCH_2 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + 0; /* From state INTRON_2 to state INTRON_2 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state REV_CODON */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-1,j-3,REV_CODON) + mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]; /* From state REV_CODON to state REV_CODON */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-3,REV_CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_0 to state REV_CODON */ temp = SyWise20_VSMALL_MATRIX(mat,i-1,j-3,REV_INTRON_MATCH_0) + CSEQ_REV_PAIR_5SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_1 to state REV_CODON */ temp = SyWise20_VSMALL_MATRIX(mat,i-1,j-1,REV_INTRON_MATCH_1) + CSEQ_REV_PAIR_5SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_2 to state REV_CODON */ temp = SyWise20_VSMALL_MATRIX(mat,i-1,j-2,REV_INTRON_MATCH_2) + CSEQ_PAIR_5SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state NON_CDS_CONSERVED to state REV_CODON */ temp = SyWise20_VSMALL_SPECIAL(mat,i-1,j-3,NON_CDS_CONSERVED) + mat->start->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for REV_CODON */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,REV_CODON) = score; /* state REV_CODON is a source for special NON_CDS_CONSERVED */ temp = score + (((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)])) + (0) ; if( temp > SyWise20_VSMALL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) ) { SyWise20_VSMALL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) = temp; } /* Finished calculating state REV_CODON */ /* For state REV_INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_REV_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,REV_INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = score; /* Finished calculating state REV_INTRON_MATCH_0 */ /* For state REV_INTRON_0 */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,REV_INTRON_0) + 0; /* From state REV_INTRON_MATCH_0 to state REV_INTRON_0 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_0 */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,REV_INTRON_0) = score; /* Finished calculating state REV_INTRON_0 */ /* For state REV_INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-0,j-3,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,REV_INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = score; /* Finished calculating state REV_INTRON_MATCH_1 */ /* For state REV_INTRON_1 */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,REV_INTRON_1) + 0; /* From state REV_INTRON_MATCH_1 to state REV_INTRON_1 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_1 */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,REV_INTRON_1) = score; /* Finished calculating state REV_INTRON_1 */ /* For state REV_INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-0,j-2,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,REV_INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = score; /* Finished calculating state REV_INTRON_MATCH_2 */ /* For state REV_INTRON_2 */ /* setting first movement to score */ score = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,REV_INTRON_2) + 0; /* From state REV_INTRON_MATCH_2 to state REV_INTRON_2 */ temp = SyWise20_VSMALL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_2 */ /* Add any movement independant score and put away */ SyWise20_VSMALL_MATRIX(mat,i,j,REV_INTRON_2) = score; /* Finished calculating state REV_INTRON_2 */ } /* end of for all query positions */ /* Special state NON_CDS_CONSERVED has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_VSMALL_SPECIAL(mat,0,j,NON_CDS_CONSERVED); /* Source CODON for state NON_CDS_CONSERVED is not special... already calculated */ /* Source REV_CODON for state NON_CDS_CONSERVED is not special... already calculated */ /* Source NON_CDS_CONSERVED is a special source for NON_CDS_CONSERVED */ temp = SyWise20_VSMALL_SPECIAL(mat,0,j - 1,NON_CDS_CONSERVED) + (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) + (0); if( temp > score ) score = temp; /* Source RND_SEQ is a special source for NON_CDS_CONSERVED */ temp = SyWise20_VSMALL_SPECIAL(mat,0,j - 1,RND_SEQ) + ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ SyWise20_VSMALL_SPECIAL(mat,0,j,NON_CDS_CONSERVED) = score; /* Finished updating state NON_CDS_CONSERVED */ /* Special state RND_SEQ has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_VSMALL_SPECIAL(mat,0,j,RND_SEQ); /* Source NON_CDS_CONSERVED is a special source for RND_SEQ */ temp = SyWise20_VSMALL_SPECIAL(mat,0,j - 1,NON_CDS_CONSERVED) + (0) + (0); if( temp > score ) score = temp; /* Source RND_SEQ is a special source for RND_SEQ */ temp = SyWise20_VSMALL_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) score = temp; /* Source START is a special source for RND_SEQ */ temp = SyWise20_VSMALL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ SyWise20_VSMALL_SPECIAL(mat,0,j,RND_SEQ) = score; /* Finished updating state RND_SEQ */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_VSMALL_SPECIAL(mat,0,j,END); /* Source RND_SEQ is a special source for END */ temp = SyWise20_VSMALL_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ SyWise20_VSMALL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ if( bestscore < SyWise20_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = SyWise20_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_SyWise20(mat); return bestscore; } /* Function: PackAln_bestmemory_SyWise20(exonmodel,seq,codon,nonc,start,stop,intron_open,gene_open,nonc_cost,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_SyWise20 * * * Arg: exonmodel [UNKN ] query data structure [SyExonScore*] * Arg: seq [UNKN ] target data structure [ComplexSequence*] * Arg: codon [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: nonc [UNKN ] Resource [PairBaseModelScore*] * Arg: start [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: stop [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: intron_open [UNKN ] Resource [Score] * Arg: gene_open [UNKN ] Resource [Score] * Arg: nonc_cost [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_SyWise20(SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; SyWise20 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = exonmodel->len * seq->length; if( dpri->memory == DPIM_Default ) { if( (total * 14 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_SyWise20(exonmodel, seq , codon, nonc, start, stop, intron_open, gene_open, nonc_cost,dpri)) == NULL ) { warn("Unable to allocate large SyWise20 version"); return NULL; } calculate_dpenv_SyWise20(mat,dpenv); out = PackAln_read_Expl_SyWise20(mat); } else { mat = allocate_SyWise20_only(exonmodel, seq , codon, nonc, start, stop, intron_open, gene_open, nonc_cost); calculate_shatter_SyWise20(mat,dpenv); out = PackAln_read_Shatter_SyWise20(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_SyWise20(exonmodel, seq , codon, nonc, start, stop, intron_open, gene_open, nonc_cost)) == NULL ) { warn("Unable to allocate small SyWise20 version"); return NULL; } out = PackAln_calculate_Small_SyWise20(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_SyWise20(exonmodel, seq , codon, nonc, start, stop, intron_open, gene_open, nonc_cost,dpri)) == NULL ) { warn("Unable to allocate large SyWise20 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_SyWise20(mat); out = PackAln_read_Expl_SyWise20(mat); } } } mat = free_SyWise20(mat); return out; } /* Function: allocate_SyWise20_only(exonmodel,seq,codon,nonc,start,stop,intron_open,gene_open,nonc_cost) * * Descrip: This function only allocates the SyWise20 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: exonmodel [UNKN ] query data structure [SyExonScore*] * Arg: seq [UNKN ] target data structure [ComplexSequence*] * Arg: codon [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: nonc [UNKN ] Resource [PairBaseModelScore*] * Arg: start [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: stop [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: intron_open [UNKN ] Resource [Score] * Arg: gene_open [UNKN ] Resource [Score] * Arg: nonc_cost [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [SyWise20 *] * */ SyWise20 * allocate_SyWise20_only(SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost) { SyWise20 * out; if((out= SyWise20_alloc()) == NULL) { warn("Allocation of basic SyWise20 structure failed..."); return NULL; } out->exonmodel = exonmodel; out->seq = seq; out->codon = codon; out->nonc = nonc; out->start = start; out->stop = stop; out->intron_open = intron_open; out->gene_open = gene_open; out->nonc_cost = nonc_cost; out->leni = exonmodel->len; out->lenj = seq->length; return out; } /* Function: allocate_Expl_SyWise20(exonmodel,seq,codon,nonc,start,stop,intron_open,gene_open,nonc_cost,dpri) * * Descrip: This function allocates the SyWise20 structure * and the basematrix area for explicit memory implementations * It calls /allocate_SyWise20_only * * * Arg: exonmodel [UNKN ] query data structure [SyExonScore*] * Arg: seq [UNKN ] target data structure [ComplexSequence*] * Arg: codon [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: nonc [UNKN ] Resource [PairBaseModelScore*] * Arg: start [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: stop [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: intron_open [UNKN ] Resource [Score] * Arg: gene_open [UNKN ] Resource [Score] * Arg: nonc_cost [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [SyWise20 *] * */ SyWise20 * allocate_Expl_SyWise20(SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost,DPRunImpl * dpri) { SyWise20 * out; out = allocate_SyWise20_only(exonmodel, seq , codon, nonc, start, stop, intron_open, gene_open, nonc_cost); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+3)*14 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+3)*14,(out->leni+1),4,out->lenj+3)) == NULL) { warn("Explicit matrix SyWise20 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_SyWise20(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_SyWise20(out); return out; } /* Function: init_SyWise20(mat) * * Descrip: This function initates SyWise20 matrix when in explicit mode * Called in /allocate_Expl_SyWise20 * * * Arg: mat [UNKN ] SyWise20 which contains explicit basematrix memory [SyWise20 *] * */ void init_SyWise20(SyWise20 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iexonmodel->len;i++) { for(j= (-3);j<4;j++) { SyWise20_EXPL_MATRIX(mat,i,j,CODON) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_2) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_CODON) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_2) = NEGI; } } for(j= (-3);jseq->length;j++) { for(i= (-1);i<2;i++) { SyWise20_EXPL_MATRIX(mat,i,j,CODON) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_2) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_CODON) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_2) = NEGI; } SyWise20_EXPL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) = NEGI; SyWise20_EXPL_SPECIAL(mat,i,j,RND_SEQ) = NEGI; SyWise20_EXPL_SPECIAL(mat,i,j,START) = 0; SyWise20_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_SyWise20(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by SyWise20 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * */ void recalculate_PackAln_SyWise20(PackAln * pal,SyWise20 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case CODON : if( offi == 1 && offj == 3 && prev->state == CODON ) { pau->score = mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)] + (0); continue; } if( offi == 0 && offj == 3 && prev->state == CODON ) { pau->score = (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]) + (0); continue; } if( offj == 3 && prev->state == (NON_CDS_CONSERVED+14) ) { pau->score = mat->start->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)] + (0); continue; } if( offi == 1 && offj == 3 && prev->state == INTRON_MATCH_0 ) { pau->score = CSEQ_PAIR_3SS(mat->seq,(j-3)) + (0); continue; } if( offi == 1 && offj == 2 && prev->state == INTRON_MATCH_1 ) { pau->score = CSEQ_PAIR_3SS(mat->seq,(j-2)) + (0); continue; } if( offi == 1 && offj == 1 && prev->state == INTRON_MATCH_2 ) { pau->score = CSEQ_PAIR_3SS(mat->seq,(j-1)) + (0); continue; } warn("In recaluclating PackAln with state CODON, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_MATCH_0 : if( offi == 0 && offj == 1 && prev->state == CODON ) { pau->score = ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_0 ) { pau->score = (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_MATCH_0 ) { pau->score = mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)] + (0); continue; } warn("In recaluclating PackAln with state INTRON_MATCH_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_0 : if( offi == 0 && offj == 1 && prev->state == INTRON_MATCH_0 ) { pau->score = 0 + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_0 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_MATCH_1 : if( offi == 0 && offj == 2 && prev->state == CODON ) { pau->score = ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_1 ) { pau->score = (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_MATCH_1 ) { pau->score = mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)] + (0); continue; } warn("In recaluclating PackAln with state INTRON_MATCH_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_1 : if( offi == 0 && offj == 1 && prev->state == INTRON_MATCH_1 ) { pau->score = 0 + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_1 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_MATCH_2 : if( offi == 0 && offj == 3 && prev->state == CODON ) { pau->score = ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_2 ) { pau->score = (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_MATCH_2 ) { pau->score = mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)] + (0); continue; } warn("In recaluclating PackAln with state INTRON_MATCH_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_2 : if( offi == 0 && offj == 1 && prev->state == INTRON_MATCH_2 ) { pau->score = 0 + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_2 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case REV_CODON : if( offi == 1 && offj == 3 && prev->state == REV_CODON ) { pau->score = mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)] + (0); continue; } if( offi == 0 && offj == 3 && prev->state == REV_CODON ) { pau->score = (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == REV_INTRON_MATCH_0 ) { pau->score = CSEQ_REV_PAIR_5SS(mat->seq,(j-3)) + (0); continue; } if( offi == 1 && offj == 1 && prev->state == REV_INTRON_MATCH_1 ) { pau->score = CSEQ_REV_PAIR_5SS(mat->seq,(j-1)) + (0); continue; } if( offi == 1 && offj == 2 && prev->state == REV_INTRON_MATCH_2 ) { pau->score = CSEQ_PAIR_5SS(mat->seq,(j-2)) + (0); continue; } if( offj == 3 && prev->state == (NON_CDS_CONSERVED+14) ) { pau->score = mat->start->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)] + (0); continue; } warn("In recaluclating PackAln with state REV_CODON, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case REV_INTRON_MATCH_0 : if( offi == 0 && offj == 1 && prev->state == REV_CODON ) { pau->score = ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_REV_PAIR_3SS(mat->seq,j))+mat->intron_open) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == REV_INTRON_0 ) { pau->score = (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == REV_INTRON_MATCH_0 ) { pau->score = mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)] + (0); continue; } warn("In recaluclating PackAln with state REV_INTRON_MATCH_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case REV_INTRON_0 : if( offi == 0 && offj == 1 && prev->state == REV_INTRON_0 ) { pau->score = 0 + (0); continue; } if( offi == 0 && offj == 1 && prev->state == REV_INTRON_MATCH_0 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state REV_INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case REV_INTRON_MATCH_1 : if( offi == 0 && offj == 3 && prev->state == REV_CODON ) { pau->score = ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == REV_INTRON_1 ) { pau->score = (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == REV_INTRON_MATCH_1 ) { pau->score = mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)] + (0); continue; } warn("In recaluclating PackAln with state REV_INTRON_MATCH_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case REV_INTRON_1 : if( offi == 0 && offj == 1 && prev->state == REV_INTRON_1 ) { pau->score = 0 + (0); continue; } if( offi == 0 && offj == 1 && prev->state == REV_INTRON_MATCH_1 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state REV_INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case REV_INTRON_MATCH_2 : if( offi == 0 && offj == 2 && prev->state == REV_CODON ) { pau->score = ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == REV_INTRON_2 ) { pau->score = (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == REV_INTRON_MATCH_2 ) { pau->score = mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)] + (0); continue; } warn("In recaluclating PackAln with state REV_INTRON_MATCH_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case REV_INTRON_2 : if( offi == 0 && offj == 1 && prev->state == REV_INTRON_2 ) { pau->score = 0 + (0); continue; } if( offi == 0 && offj == 1 && prev->state == REV_INTRON_MATCH_2 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state REV_INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (NON_CDS_CONSERVED+14) : if( offj == 0 && prev->state == CODON ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = ((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]) + (0); continue; } if( offj == 0 && prev->state == REV_CODON ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = ((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]) + (0); continue; } if( offj == 1 && prev->state == (NON_CDS_CONSERVED+14) ) { pau->score = mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)] + (0); continue; } if( offj == 1 && prev->state == (RND_SEQ+14) ) { pau->score = (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) + (0); continue; } warn("In recaluclating PackAln with state NON_CDS_CONSERVED, got a bad source state. Error!"); break; case (RND_SEQ+14) : if( offj == 1 && prev->state == (NON_CDS_CONSERVED+14) ) { pau->score = 0 + (0); continue; } if( offj == 1 && prev->state == (RND_SEQ+14) ) { pau->score = 0 + (0); continue; } if( offj == 1 && prev->state == (START+14) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state RND_SEQ, got a bad source state. Error!"); break; case (START+14) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+14) : if( offj == 1 && prev->state == (RND_SEQ+14) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define SyWise20_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+3)][(i+1)*14+state]) #define SyWise20_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+4)*8) % 32][(i+1)*14+state]) #define SyWise20_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+3)]) #define SyWise20_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+3)]) #define SyWise20_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+4)*8)+(shadow+1)) % 32)][(i+1)*14 + state]) #define SyWise20_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+3)]) #define SyWise20_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+3)% 3) * (leni+1) * 14) + ((i+1) * 14) + (state)]) #define SyWise20_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+3)% 3) * (leni+1) * 112) + ((i+1) * 112) + (state * 8) + shadow+1]) #define SyWise20_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+3)]) /* Function: allocate_Small_SyWise20(exonmodel,seq,codon,nonc,start,stop,intron_open,gene_open,nonc_cost) * * Descrip: This function allocates the SyWise20 structure * and the basematrix area for a small memory implementations * It calls /allocate_SyWise20_only * * * Arg: exonmodel [UNKN ] query data structure [SyExonScore*] * Arg: seq [UNKN ] target data structure [ComplexSequence*] * Arg: codon [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: nonc [UNKN ] Resource [PairBaseModelScore*] * Arg: start [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: stop [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: intron_open [UNKN ] Resource [Score] * Arg: gene_open [UNKN ] Resource [Score] * Arg: nonc_cost [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [SyWise20 *] * */ #define SyWise20_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+3)]) SyWise20 * allocate_Small_SyWise20(SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost) { SyWise20 * out; out = allocate_SyWise20_only(exonmodel, seq , codon, nonc, start, stop, intron_open, gene_open, nonc_cost); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(32,(out->leni + 1) * 14,32,out->lenj+3); if(out == NULL) { warn("Small shadow matrix SyWise20 cannot be allocated, (asking for 4 by %d main cells)",out->leni+2); free_SyWise20(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_SyWise20(mat,dpenv) * * Descrip: This function calculates an alignment for SyWise20 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_SyWise20 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_SyWise20 * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_SyWise20(SyWise20 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for SyWise20 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_SyWise20(mat,dpenv); score = start_end_find_end_SyWise20(mat,&endj); out->score = score; stopstate = END; /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */ log_full_error(REPORT,0,"End at %d Score %d",endj,score); stop_reporting(); for(;;) { /*while there are more special bits to recover*/ start_reporting("Special cell aln end %d:",endj); if( read_special_strip_SyWise20(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) { warn("Problem in reading off special state system... going to return partial alignment"); break; } if( startstate == START || endj <= 0) { log_full_error(REPORT,0,"Recovered complete alignment"); stop_reporting(); break; } log_full_error(REPORT,0,"Finished to %d",endj); stop_reporting(); /* Ok... have to eat up another piece of matrix */ temp = startstate; starti = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0); startj = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1); startstate = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2); stopi = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3); stopj = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4); stopstate = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5); /* Get out the score of this block. V. important! */ temp = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6); totalj = stopj - startj; donej = 0; start_reporting("Main matrix aln [%d,%d]:",startj,stopj); if(full_dc_SyWise20(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) { warn("In the alignment SyWise20 [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj); return out; } /* now have to figure out which special we came from... yikes */ max_matrix_to_special_SyWise20(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == SyWise20_READ_OFF_ERROR) { warn("In SyWise20 read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj); invert_PackAln(out); recalculate_PackAln_SyWise20(out,mat); return out; } /* if at start, break, otherwise, back to eat another strip */ if( stopstate == START) { log_full_error(REPORT,0,"Recovered complete alignment "); stop_reporting(); break; } log_full_error(REPORT,0,"Finished alignment to %d ",startj); stop_reporting(); endj = stopj; /* stopstate is correct as it is */ } /* end of while there are more special bits to recover */ invert_PackAln(out); recalculate_PackAln_SyWise20(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_SyWise20(mat) * * Descrip: This function calculates an alignment for SyWise20 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_SyWise20 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_SyWise20 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_SyWise20 * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_SyWise20(SyWise20 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_SyWise20(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_SyWise20(mat); return out; } /* Function: AlnRangeSet_from_SyWise20(mat) * * Descrip: This function reads off a start/end structure * for SyWise20 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_SyWise20 * If you have not calculated the matrix use * /AlnRange_calculate_Small_SyWise20 * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_SyWise20(SyWise20 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_SyWise20"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_SyWise20(mat,&jpos); state = END; while( (temp = AlnRange_build_SyWise20(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_SyWise20(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_SyWise20 * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_SyWise20(SyWise20 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_SyWise20"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_SyWise20(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_SyWise20 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = SyWise20_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_SyWise20(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == SyWise20_READ_OFF_ERROR) { warn("In AlnRange_build_SyWise20 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = SyWise20_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_SyWise20(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_SyWise20(SyWise20 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_SyWise20(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == SyWise20_READ_OFF_ERROR) { warn("In SyWise20 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In SyWise20 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In SyWise20 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_SyWise20(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_SyWise20(SyWise20 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = SyWise20_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->exonmodel->len || j > mat->seq->length) { warn("In SyWise20 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = SyWise20_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case CODON : temp = cscore - (CSEQ_PAIR_3SS(mat->seq,(j-1))) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 1,INTRON_MATCH_2) ) { *reti = i - 1; *retj = j - 1; *retstate = INTRON_MATCH_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-1,j-1,INTRON_MATCH_2); } return SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 1,INTRON_MATCH_2); } temp = cscore - (CSEQ_PAIR_3SS(mat->seq,(j-2))) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 2,INTRON_MATCH_1) ) { *reti = i - 1; *retj = j - 2; *retstate = INTRON_MATCH_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-1,j-2,INTRON_MATCH_1); } return SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 2,INTRON_MATCH_1); } temp = cscore - (CSEQ_PAIR_3SS(mat->seq,(j-3))) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 3,INTRON_MATCH_0) ) { *reti = i - 1; *retj = j - 3; *retstate = INTRON_MATCH_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-1,j-3,INTRON_MATCH_0); } return SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 3,INTRON_MATCH_0); } /* Not allowing special sources.. skipping NON_CDS_CONSERVED */ temp = cscore - ((mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)])) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 3,CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-3,CODON); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 3,CODON); } temp = cscore - (mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 3,CODON) ) { *reti = i - 1; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-1,j-3,CODON); } return SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 3,CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_MATCH_0 : temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_MATCH_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_MATCH_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_MATCH_0); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_MATCH_0); } temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0); } temp = cscore - (((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open)) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,CODON); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - (0) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0); } temp = cscore - (0) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_MATCH_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_MATCH_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_MATCH_0); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_MATCH_0); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_MATCH_1 : temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_MATCH_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_MATCH_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_MATCH_1); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_MATCH_1); } temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1); } temp = cscore - (((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open)) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 2,CODON) ) { *reti = i - 0; *retj = j - 2; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-2,CODON); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 2,CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - (0) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1); } temp = cscore - (0) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_MATCH_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_MATCH_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_MATCH_1); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_MATCH_1); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_MATCH_2 : temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_MATCH_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_MATCH_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_MATCH_2); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_MATCH_2); } temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2); } temp = cscore - (((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open)) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 3,CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-3,CODON); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 3,CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - (0) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2); } temp = cscore - (0) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_MATCH_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_MATCH_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_MATCH_2); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_MATCH_2); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_CODON : /* Not allowing special sources.. skipping NON_CDS_CONSERVED */ temp = cscore - (CSEQ_PAIR_5SS(mat->seq,(j-2))) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 2,REV_INTRON_MATCH_2) ) { *reti = i - 1; *retj = j - 2; *retstate = REV_INTRON_MATCH_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-1,j-2,REV_INTRON_MATCH_2); } return SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 2,REV_INTRON_MATCH_2); } temp = cscore - (CSEQ_REV_PAIR_5SS(mat->seq,(j-1))) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 1,REV_INTRON_MATCH_1) ) { *reti = i - 1; *retj = j - 1; *retstate = REV_INTRON_MATCH_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-1,j-1,REV_INTRON_MATCH_1); } return SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 1,REV_INTRON_MATCH_1); } temp = cscore - (CSEQ_REV_PAIR_5SS(mat->seq,(j-3))) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 3,REV_INTRON_MATCH_0) ) { *reti = i - 1; *retj = j - 3; *retstate = REV_INTRON_MATCH_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-1,j-3,REV_INTRON_MATCH_0); } return SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 3,REV_INTRON_MATCH_0); } temp = cscore - ((mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)])) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 3,REV_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = REV_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-3,REV_CODON); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 3,REV_CODON); } temp = cscore - (mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 3,REV_CODON) ) { *reti = i - 1; *retj = j - 3; *retstate = REV_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-1,j-3,REV_CODON); } return SyWise20_HIDDEN_MATRIX(mat,i - 1,j - 3,REV_CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_MATCH_0 : temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_MATCH_0) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_MATCH_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_MATCH_0); } temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_0); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_0); } temp = cscore - (((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_REV_PAIR_3SS(mat->seq,j))+mat->intron_open)) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_CODON); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_0 : temp = cscore - (0) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_MATCH_0) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_MATCH_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_MATCH_0); } temp = cscore - (0) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_0); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_0); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_MATCH_1 : temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_MATCH_1) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_MATCH_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_MATCH_1); } temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_1); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_1); } temp = cscore - (((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open)) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 3,REV_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = REV_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-3,REV_CODON); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 3,REV_CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_1 : temp = cscore - (0) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_MATCH_1) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_MATCH_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_MATCH_1); } temp = cscore - (0) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_1); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_1); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_MATCH_2 : temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_MATCH_2) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_MATCH_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_MATCH_2); } temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_2); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_2); } temp = cscore - (((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open)) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 2,REV_CODON) ) { *reti = i - 0; *retj = j - 2; *retstate = REV_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-2,REV_CODON); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 2,REV_CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_2 : temp = cscore - (0) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_MATCH_2) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_MATCH_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_MATCH_2); } temp = cscore - (0) - (0); if( temp == SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_2); } return SyWise20_HIDDEN_MATRIX(mat,i - 0,j - 1,REV_INTRON_2); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_SyWise20(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_SyWise20(SyWise20 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > SyWise20_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 14; add_PackAln(out,pau); } max_special_strip_SyWise20(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == SyWise20_READ_OFF_ERROR) { warn("In special strip read SyWise20, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < SyWise20_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read SyWise20, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 14; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_SyWise20(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_SyWise20(SyWise20 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = SyWise20_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for SyWise20, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->seq->length) { warn("In SyWise20 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = SyWise20_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case NON_CDS_CONSERVED : /* source RND_SEQ is a special */ temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == SyWise20_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,RND_SEQ) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_SEQ; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_DC_SHADOW_SPECIAL(mat,i-0,j-1,RND_SEQ); } return SyWise20_DC_SHADOW_MATRIX(mat,i - 0,j - 1,RND_SEQ) ; } /* source NON_CDS_CONSERVED is a special */ temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == SyWise20_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,NON_CDS_CONSERVED) ) { *reti = i - 0; *retj = j - 1; *retstate = NON_CDS_CONSERVED; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_DC_SHADOW_SPECIAL(mat,i-0,j-1,NON_CDS_CONSERVED); } return SyWise20_DC_SHADOW_MATRIX(mat,i - 0,j - 1,NON_CDS_CONSERVED) ; } /* Source REV_CODON is not a special */ /* Source CODON is not a special */ case RND_SEQ : /* source START is a special */ temp = cscore - (0) - (0); if( temp == SyWise20_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return SyWise20_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } /* source RND_SEQ is a special */ temp = cscore - (0) - (0); if( temp == SyWise20_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,RND_SEQ) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_SEQ; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_DC_SHADOW_SPECIAL(mat,i-0,j-1,RND_SEQ); } return SyWise20_DC_SHADOW_MATRIX(mat,i - 0,j - 1,RND_SEQ) ; } /* source NON_CDS_CONSERVED is a special */ temp = cscore - (0) - (0); if( temp == SyWise20_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,NON_CDS_CONSERVED) ) { *reti = i - 0; *retj = j - 1; *retstate = NON_CDS_CONSERVED; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_DC_SHADOW_SPECIAL(mat,i-0,j-1,NON_CDS_CONSERVED); } return SyWise20_DC_SHADOW_MATRIX(mat,i - 0,j - 1,NON_CDS_CONSERVED) ; } case START : case END : /* source RND_SEQ is a special */ temp = cscore - (0) - (0); if( temp == SyWise20_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,RND_SEQ) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_SEQ; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_DC_SHADOW_SPECIAL(mat,i-0,j-1,RND_SEQ); } return SyWise20_DC_SHADOW_MATRIX(mat,i - 0,j - 1,RND_SEQ) ; } default: warn("Major problem (!) - in SyWise20 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_SyWise20(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_SyWise20(SyWise20 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = SyWise20_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In SyWise20 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case CODON : /* Source INTRON_MATCH_2 is not a special, should not get here! */ /* Source INTRON_MATCH_1 is not a special, should not get here! */ /* Source INTRON_MATCH_0 is not a special, should not get here! */ temp = cscore - (mat->start->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]) - (0); if( temp == SyWise20_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,NON_CDS_CONSERVED) ) { *reti = i - 1; *retj = j - 3; *retstate = NON_CDS_CONSERVED; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_DC_SHADOW_SPECIAL(mat,i-1,j-3,NON_CDS_CONSERVED); } return SyWise20_DC_SHADOW_MATRIX(mat,i - 1,j - 3,NON_CDS_CONSERVED) ; } /* Source CODON is not a special, should not get here! */ /* Source CODON is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_MATCH_0 : /* Source INTRON_MATCH_0 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ /* Source CODON is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : /* Source INTRON_0 is not a special, should not get here! */ /* Source INTRON_MATCH_0 is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_MATCH_1 : /* Source INTRON_MATCH_1 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source CODON is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_MATCH_1 is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_MATCH_2 : /* Source INTRON_MATCH_2 is not a special, should not get here! */ /* Source INTRON_2 is not a special, should not get here! */ /* Source CODON is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_MATCH_2 is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_CODON : temp = cscore - (mat->start->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]) - (0); if( temp == SyWise20_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,NON_CDS_CONSERVED) ) { *reti = i - 1; *retj = j - 3; *retstate = NON_CDS_CONSERVED; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - SyWise20_DC_SHADOW_SPECIAL(mat,i-1,j-3,NON_CDS_CONSERVED); } return SyWise20_DC_SHADOW_MATRIX(mat,i - 1,j - 3,NON_CDS_CONSERVED) ; } /* Source REV_INTRON_MATCH_2 is not a special, should not get here! */ /* Source REV_INTRON_MATCH_1 is not a special, should not get here! */ /* Source REV_INTRON_MATCH_0 is not a special, should not get here! */ /* Source REV_CODON is not a special, should not get here! */ /* Source REV_CODON is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_MATCH_0 : /* Source REV_INTRON_MATCH_0 is not a special, should not get here! */ /* Source REV_INTRON_0 is not a special, should not get here! */ /* Source REV_CODON is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_0 : /* Source REV_INTRON_MATCH_0 is not a special, should not get here! */ /* Source REV_INTRON_0 is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_MATCH_1 : /* Source REV_INTRON_MATCH_1 is not a special, should not get here! */ /* Source REV_INTRON_1 is not a special, should not get here! */ /* Source REV_CODON is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_1 : /* Source REV_INTRON_MATCH_1 is not a special, should not get here! */ /* Source REV_INTRON_1 is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_MATCH_2 : /* Source REV_INTRON_MATCH_2 is not a special, should not get here! */ /* Source REV_INTRON_2 is not a special, should not get here! */ /* Source REV_CODON is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_2 : /* Source REV_INTRON_MATCH_2 is not a special, should not get here! */ /* Source REV_INTRON_2 is not a special, should not get here! */ warn("Major problem (!) - in SyWise20 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_SyWise20(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_SyWise20(SyWise20 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_SyWise20(mat,starti,startj,stopi,stopj); SyWise20_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ SyWise20_HIDDEN_MATRIX(mat,i,j,CODON) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_MATCH_0) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_MATCH_1) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_MATCH_2) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_CODON) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_0) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_1) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ /* For state CODON */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-1,j-3,CODON) + mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]; /* From state CODON to state CODON */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-3,CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_0 to state CODON */ temp = SyWise20_HIDDEN_MATRIX(mat,i-1,j-3,INTRON_MATCH_0) + CSEQ_PAIR_3SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_1 to state CODON */ temp = SyWise20_HIDDEN_MATRIX(mat,i-1,j-2,INTRON_MATCH_1) + CSEQ_PAIR_3SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_2 to state CODON */ temp = SyWise20_HIDDEN_MATRIX(mat,i-1,j-1,INTRON_MATCH_2) + CSEQ_PAIR_3SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,CODON) = score; /* Finished calculating state CODON */ /* For state INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_0 to state INTRON_MATCH_0 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_0 to state INTRON_MATCH_0 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_MATCH_0) = score; /* Finished calculating state INTRON_MATCH_0 */ /* For state INTRON_0 */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + 0; /* From state INTRON_0 to state INTRON_0 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-0,j-2,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_1 to state INTRON_MATCH_1 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_1 to state INTRON_MATCH_1 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_MATCH_1) = score; /* Finished calculating state INTRON_MATCH_1 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + 0; /* From state INTRON_1 to state INTRON_1 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-0,j-3,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_2 to state INTRON_MATCH_2 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_2 to state INTRON_MATCH_2 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_MATCH_2) = score; /* Finished calculating state INTRON_MATCH_2 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + 0; /* From state INTRON_2 to state INTRON_2 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state REV_CODON */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-1,j-3,REV_CODON) + mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]; /* From state REV_CODON to state REV_CODON */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-3,REV_CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_0 to state REV_CODON */ temp = SyWise20_HIDDEN_MATRIX(mat,i-1,j-3,REV_INTRON_MATCH_0) + CSEQ_REV_PAIR_5SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_1 to state REV_CODON */ temp = SyWise20_HIDDEN_MATRIX(mat,i-1,j-1,REV_INTRON_MATCH_1) + CSEQ_REV_PAIR_5SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_2 to state REV_CODON */ temp = SyWise20_HIDDEN_MATRIX(mat,i-1,j-2,REV_INTRON_MATCH_2) + CSEQ_PAIR_5SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_CODON */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,REV_CODON) = score; /* Finished calculating state REV_CODON */ /* For state REV_INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_REV_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = score; /* Finished calculating state REV_INTRON_MATCH_0 */ /* For state REV_INTRON_0 */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_0) + 0; /* From state REV_INTRON_MATCH_0 to state REV_INTRON_0 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_0 */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_0) = score; /* Finished calculating state REV_INTRON_0 */ /* For state REV_INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-0,j-3,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = score; /* Finished calculating state REV_INTRON_MATCH_1 */ /* For state REV_INTRON_1 */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_1) + 0; /* From state REV_INTRON_MATCH_1 to state REV_INTRON_1 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_1 */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_1) = score; /* Finished calculating state REV_INTRON_1 */ /* For state REV_INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-0,j-2,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = score; /* Finished calculating state REV_INTRON_MATCH_2 */ /* For state REV_INTRON_2 */ /* setting first movement to score */ score = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_2) + 0; /* From state REV_INTRON_MATCH_2 to state REV_INTRON_2 */ temp = SyWise20_HIDDEN_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_2 */ /* Add any movement independant score and put away */ SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_2) = score; /* Finished calculating state REV_INTRON_2 */ } } return; } /* Function: init_hidden_SyWise20(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_SyWise20(SyWise20 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-3);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { SyWise20_HIDDEN_MATRIX(mat,i,j,CODON) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_MATCH_0) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_MATCH_1) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_MATCH_2) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_CODON) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_0) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_1) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = NEGI; SyWise20_HIDDEN_MATRIX(mat,i,j,REV_INTRON_2) = NEGI; } } return; } /* Function: full_dc_SyWise20(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_SyWise20 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_SyWise20 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [SyWise20 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_SyWise20(SyWise20 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_SyWise20"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 15) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_SyWise20(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_SyWise20(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_SyWise20(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for SyWise20, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= SyWise20_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= SyWise20_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = SyWise20_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_SyWise20(mat,SyWise20_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),SyWise20_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),SyWise20_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_SyWise20(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_SyWise20(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_SyWise20(SyWise20 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_SyWise20(mat); SyWise20_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_SyWise20(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_SyWise20(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_SyWise20(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_SyWise20(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_SyWise20(SyWise20 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<3;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ SyWise20_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = (-100); SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_0) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,1) = (-100); SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = (-100); SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_1) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,1) = (-100); SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = (-100); SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_2) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,1) = (-100); SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = (-100); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_CODON) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,1) = (-100); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,1) = (-100); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_0) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,1) = (-100); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,1) = (-100); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_1) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,1) = (-100); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,1) = (-100); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_2) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,0) = (-100); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,1) = (-100); continue; } /* end of Is not in envelope */ /* For state CODON, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-3,CODON) + mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]; if( j - 3 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-3; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = CODON; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,CODON,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-3; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = CODON; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,k); } } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-3,INTRON_MATCH_0) + CSEQ_PAIR_3SS(mat->seq,(j-3)); if( temp > score) { score = temp; if( j - 3 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-3; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = INTRON_MATCH_0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INTRON_MATCH_0,k); } } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-2,INTRON_MATCH_1) + CSEQ_PAIR_3SS(mat->seq,(j-2)); if( temp > score) { score = temp; if( j - 2 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = INTRON_MATCH_1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INTRON_MATCH_1,k); } } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-1,INTRON_MATCH_2) + CSEQ_PAIR_3SS(mat->seq,(j-1)); if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = INTRON_MATCH_2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INTRON_MATCH_2,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,CODON) = score; /* Finished with state CODON */ /* For state INTRON_MATCH_0, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,2) = CODON; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,5) = INTRON_MATCH_0; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CODON,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,2) = INTRON_0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,5) = INTRON_MATCH_0; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,2) = INTRON_MATCH_0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,5) = INTRON_MATCH_0; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_0,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_0) = score; /* Finished with state INTRON_MATCH_0 */ /* For state INTRON_0, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + 0; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INTRON_MATCH_0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_0,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INTRON_0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished with state INTRON_0 */ /* For state INTRON_MATCH_1, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-2,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); if( j - 2 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,1) = j-2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,2) = CODON; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,5) = INTRON_MATCH_1; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,CODON,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,2) = INTRON_1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,5) = INTRON_MATCH_1; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,2) = INTRON_MATCH_1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,5) = INTRON_MATCH_1; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_1,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_1) = score; /* Finished with state INTRON_MATCH_1 */ /* For state INTRON_1, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + 0; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INTRON_MATCH_1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_1,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INTRON_1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished with state INTRON_1 */ /* For state INTRON_MATCH_2, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); if( j - 3 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,1) = j-3; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,2) = CODON; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,5) = INTRON_MATCH_2; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,2) = INTRON_2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,5) = INTRON_MATCH_2; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,2) = INTRON_MATCH_2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,5) = INTRON_MATCH_2; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_2,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_2) = score; /* Finished with state INTRON_MATCH_2 */ /* For state INTRON_2, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + 0; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INTRON_MATCH_2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_2,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INTRON_2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished with state INTRON_2 */ /* For state REV_CODON, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-3,REV_CODON) + mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]; if( j - 3 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,0) = i-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,1) = j-3; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,2) = REV_CODON; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,5) = REV_CODON; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,REV_CODON,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-3,REV_CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,1) = j-3; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,2) = REV_CODON; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,5) = REV_CODON; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,REV_CODON,k); } } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-3,REV_INTRON_MATCH_0) + CSEQ_REV_PAIR_5SS(mat->seq,(j-3)); if( temp > score) { score = temp; if( j - 3 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,0) = i-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,1) = j-3; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,2) = REV_INTRON_MATCH_0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,5) = REV_CODON; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,REV_INTRON_MATCH_0,k); } } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-1,REV_INTRON_MATCH_1) + CSEQ_REV_PAIR_5SS(mat->seq,(j-1)); if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,0) = i-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,2) = REV_INTRON_MATCH_1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,5) = REV_CODON; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,REV_INTRON_MATCH_1,k); } } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-2,REV_INTRON_MATCH_2) + CSEQ_PAIR_5SS(mat->seq,(j-2)); if( temp > score) { score = temp; if( j - 2 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,0) = i-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,1) = j-2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,2) = REV_INTRON_MATCH_2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,5) = REV_CODON; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,REV_INTRON_MATCH_2,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_CODON) = score; /* Finished with state REV_CODON */ /* For state REV_INTRON_MATCH_0, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_REV_PAIR_3SS(mat->seq,j))+mat->intron_open); if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,2) = REV_CODON; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,5) = REV_INTRON_MATCH_0; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_CODON,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,2) = REV_INTRON_0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,5) = REV_INTRON_MATCH_0; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_0,k); } } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,2) = REV_INTRON_MATCH_0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,5) = REV_INTRON_MATCH_0; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_0,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = score; /* Finished with state REV_INTRON_MATCH_0 */ /* For state REV_INTRON_0, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_0) + 0; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,2) = REV_INTRON_0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,5) = REV_INTRON_0; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_0,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,2) = REV_INTRON_MATCH_0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,5) = REV_INTRON_0; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_0,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_0) = score; /* Finished with state REV_INTRON_0 */ /* For state REV_INTRON_MATCH_1, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-3,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); if( j - 3 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,1) = j-3; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,2) = REV_CODON; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,5) = REV_INTRON_MATCH_1; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,REV_CODON,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,2) = REV_INTRON_1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,5) = REV_INTRON_MATCH_1; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_1,k); } } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,2) = REV_INTRON_MATCH_1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,5) = REV_INTRON_MATCH_1; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_1,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = score; /* Finished with state REV_INTRON_MATCH_1 */ /* For state REV_INTRON_1, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_1) + 0; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,2) = REV_INTRON_1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,5) = REV_INTRON_1; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_1,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,2) = REV_INTRON_MATCH_1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,5) = REV_INTRON_1; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_1,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_1) = score; /* Finished with state REV_INTRON_1 */ /* For state REV_INTRON_MATCH_2, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-2,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); if( j - 2 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,1) = j-2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,2) = REV_CODON; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,5) = REV_INTRON_MATCH_2; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,REV_CODON,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,2) = REV_INTRON_2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,5) = REV_INTRON_MATCH_2; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_2,k); } } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,2) = REV_INTRON_MATCH_2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,5) = REV_INTRON_MATCH_2; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_2,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = score; /* Finished with state REV_INTRON_MATCH_2 */ /* For state REV_INTRON_2, pushing when j - offj <= mergej */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_2) + 0; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,2) = REV_INTRON_2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,5) = REV_INTRON_2; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_2,k); } temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,0) = i-0; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,1) = j-1; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,2) = REV_INTRON_MATCH_2; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,3) = i; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,4) = j; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,5) = REV_INTRON_2; } else { for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,k) = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_2,k); } } /* Add any movement independant score */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_2) = score; /* Finished with state REV_INTRON_2 */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_SyWise20(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_SyWise20(SyWise20 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ SyWise20_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_0) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_1) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_2) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_CODON) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_0) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_1) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state CODON */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-3,CODON) + mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,CODON,k); /* From state CODON to state CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,k); } /* From state INTRON_MATCH_0 to state CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-3,INTRON_MATCH_0) + CSEQ_PAIR_3SS(mat->seq,(j-3)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INTRON_MATCH_0,k); } /* From state INTRON_MATCH_1 to state CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-2,INTRON_MATCH_1) + CSEQ_PAIR_3SS(mat->seq,(j-2)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INTRON_MATCH_1,k); } /* From state INTRON_MATCH_2 to state CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-1,INTRON_MATCH_2) + CSEQ_PAIR_3SS(mat->seq,(j-1)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INTRON_MATCH_2,k); } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,CODON) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CODON */ /* For state INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CODON,k); /* From state INTRON_0 to state INTRON_MATCH_0 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } /* From state INTRON_MATCH_0 to state INTRON_MATCH_0 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_0,k); } /* Ok - finished max calculation for INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_0) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_MATCH_0 */ /* For state INTRON_0 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + 0; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_0,k); /* From state INTRON_0 to state INTRON_0 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-2,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,CODON,k); /* From state INTRON_1 to state INTRON_MATCH_1 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } /* From state INTRON_MATCH_1 to state INTRON_MATCH_1 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_1,k); } /* Ok - finished max calculation for INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_1) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_MATCH_1 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + 0; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_1,k); /* From state INTRON_1 to state INTRON_1 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,k); /* From state INTRON_2 to state INTRON_MATCH_2 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } /* From state INTRON_MATCH_2 to state INTRON_MATCH_2 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_2,k); } /* Ok - finished max calculation for INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_2) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_MATCH_2 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + 0; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_2,k); /* From state INTRON_2 to state INTRON_2 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ /* For state REV_CODON */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-3,REV_CODON) + mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,REV_CODON,k); /* From state REV_CODON to state REV_CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-3,REV_CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,REV_CODON,k); } /* From state REV_INTRON_MATCH_0 to state REV_CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-3,REV_INTRON_MATCH_0) + CSEQ_REV_PAIR_5SS(mat->seq,(j-3)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,REV_INTRON_MATCH_0,k); } /* From state REV_INTRON_MATCH_1 to state REV_CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-1,REV_INTRON_MATCH_1) + CSEQ_REV_PAIR_5SS(mat->seq,(j-1)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,REV_INTRON_MATCH_1,k); } /* From state REV_INTRON_MATCH_2 to state REV_CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-2,REV_INTRON_MATCH_2) + CSEQ_PAIR_5SS(mat->seq,(j-2)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,REV_INTRON_MATCH_2,k); } /* Ok - finished max calculation for REV_CODON */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_CODON) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REV_CODON */ /* For state REV_INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_REV_PAIR_3SS(mat->seq,j))+mat->intron_open); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_CODON,k); /* From state REV_INTRON_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_0,k); } /* From state REV_INTRON_MATCH_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_0,k); } /* Ok - finished max calculation for REV_INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REV_INTRON_MATCH_0 */ /* For state REV_INTRON_0 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_0) + 0; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_0,k); /* From state REV_INTRON_MATCH_0 to state REV_INTRON_0 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_0,k); } /* Ok - finished max calculation for REV_INTRON_0 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_0) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REV_INTRON_0 */ /* For state REV_INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-3,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,REV_CODON,k); /* From state REV_INTRON_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_1,k); } /* From state REV_INTRON_MATCH_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_1,k); } /* Ok - finished max calculation for REV_INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REV_INTRON_MATCH_1 */ /* For state REV_INTRON_1 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_1) + 0; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_1,k); /* From state REV_INTRON_MATCH_1 to state REV_INTRON_1 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_1,k); } /* Ok - finished max calculation for REV_INTRON_1 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_1) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REV_INTRON_1 */ /* For state REV_INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-2,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,REV_CODON,k); /* From state REV_INTRON_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_2,k); } /* From state REV_INTRON_MATCH_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_2,k); } /* Ok - finished max calculation for REV_INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REV_INTRON_MATCH_2 */ /* For state REV_INTRON_2 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_2) + 0; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_2,k); /* From state REV_INTRON_MATCH_2 to state REV_INTRON_2 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SyWise20_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_2,k); } /* Ok - finished max calculation for REV_INTRON_2 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_2) = score; for(k=0;k<7;k++) SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REV_INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_SyWise20(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_SyWise20(SyWise20 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ SyWise20_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_0) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_1) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_2) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_CODON) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_0) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_1) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state CODON */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-3,CODON) + mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]; /* From state CODON to state CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_0 to state CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-3,INTRON_MATCH_0) + CSEQ_PAIR_3SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_1 to state CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-2,INTRON_MATCH_1) + CSEQ_PAIR_3SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_2 to state CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-1,INTRON_MATCH_2) + CSEQ_PAIR_3SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,CODON) = score; /* Finished calculating state CODON */ /* For state INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_0 to state INTRON_MATCH_0 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_0 to state INTRON_MATCH_0 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_0) = score; /* Finished calculating state INTRON_MATCH_0 */ /* For state INTRON_0 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + 0; /* From state INTRON_0 to state INTRON_0 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-2,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_1 to state INTRON_MATCH_1 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_1 to state INTRON_MATCH_1 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_1) = score; /* Finished calculating state INTRON_MATCH_1 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + 0; /* From state INTRON_1 to state INTRON_1 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_2 to state INTRON_MATCH_2 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_2 to state INTRON_MATCH_2 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_2) = score; /* Finished calculating state INTRON_MATCH_2 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + 0; /* From state INTRON_2 to state INTRON_2 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state REV_CODON */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-3,REV_CODON) + mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]; /* From state REV_CODON to state REV_CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-3,REV_CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_0 to state REV_CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-3,REV_INTRON_MATCH_0) + CSEQ_REV_PAIR_5SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_1 to state REV_CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-1,REV_INTRON_MATCH_1) + CSEQ_REV_PAIR_5SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_2 to state REV_CODON */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-1,j-2,REV_INTRON_MATCH_2) + CSEQ_PAIR_5SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_CODON */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_CODON) = score; /* Finished calculating state REV_CODON */ /* For state REV_INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_REV_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = score; /* Finished calculating state REV_INTRON_MATCH_0 */ /* For state REV_INTRON_0 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_0) + 0; /* From state REV_INTRON_MATCH_0 to state REV_INTRON_0 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_0 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_0) = score; /* Finished calculating state REV_INTRON_0 */ /* For state REV_INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-3,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = score; /* Finished calculating state REV_INTRON_MATCH_1 */ /* For state REV_INTRON_1 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_1) + 0; /* From state REV_INTRON_MATCH_1 to state REV_INTRON_1 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_1 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_1) = score; /* Finished calculating state REV_INTRON_1 */ /* For state REV_INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-2,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = score; /* Finished calculating state REV_INTRON_MATCH_2 */ /* For state REV_INTRON_2 */ /* setting first movement to score */ score = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_2) + 0; /* From state REV_INTRON_MATCH_2 to state REV_INTRON_2 */ temp = SyWise20_DC_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_2 */ /* Add any movement independant score and put away */ SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_2) = score; /* Finished calculating state REV_INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_SyWise20(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * */ } void init_dc_SyWise20(SyWise20 * mat) { register int i; register int j; register int k; for(j=0;j<5;j++) { for(i=(-1);iexonmodel->len;i++) { SyWise20_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_0) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_1) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_2) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_CODON) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_0) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_1) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = NEGI; SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_2) = NEGI; for(k=0;k<7;k++) { SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = (-1); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,k) = (-1); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = (-1); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,k) = (-1); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = (-1); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,k) = (-1); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = (-1); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,k) = (-1); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,k) = (-1); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,k) = (-1); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,k) = (-1); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,k) = (-1); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,k) = (-1); SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,k) = (-1); } } } return; } /* Function: start_end_find_end_SyWise20(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [SyWise20 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_SyWise20(SyWise20 * mat,int * endj) { register int j; register int max; register int maxj; max = SyWise20_DC_SHADOW_SPECIAL(mat,0,mat->seq->length-1,END); maxj = mat->seq->length-1; for(j= mat->seq->length-2 ;j >= 0 ;j--) { if( SyWise20_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = SyWise20_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_SyWise20(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [SyWise20] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_SyWise20(SyWise20 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->exonmodel->len; lenj = mat->seq->length; total = leni * lenj; score_pointers = (int *) calloc (3 * (leni + 1) * 14,sizeof(int)); shadow_pointers = (int *) calloc (3 * (leni + 1) * 14 * 8,sizeof(int)); for(j=0;jcodon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)] + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,CODON,0)); /* From state CODON to state CODON */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,0)); } /* From state NON_CDS_CONSERVED to state CODON */ temp = SyWise20_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,NON_CDS_CONSERVED) + mat->start->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)] + (0); if( temp > score ) { score = temp; /* This state [NON_CDS_CONSERVED] is a special for CODON... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= CODON; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_MATCH_0 to state CODON */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INTRON_MATCH_0) + CSEQ_PAIR_3SS(mat->seq,(j-3)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INTRON_MATCH_0,0)); } /* From state INTRON_MATCH_1 to state CODON */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,INTRON_MATCH_1) + CSEQ_PAIR_3SS(mat->seq,(j-2)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INTRON_MATCH_1,0)); } /* From state INTRON_MATCH_2 to state CODON */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INTRON_MATCH_2) + CSEQ_PAIR_3SS(mat->seq,(j-1)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INTRON_MATCH_2,0)); } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,CODON) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state CODON is a source for special NON_CDS_CONSERVED */ temp = score + (((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)])) + (0) ; if( temp > SyWise20_DC_OPT_SHADOW_SPECIAL(mat,i,j,NON_CDS_CONSERVED) ) { SyWise20_DC_OPT_SHADOW_SPECIAL(mat,i,j,NON_CDS_CONSERVED) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,NON_CDS_CONSERVED,k) = SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CODON,k); SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,NON_CDS_CONSERVED,6) = SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CODON,6); SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,NON_CDS_CONSERVED,3) = i; SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,NON_CDS_CONSERVED,4) = j; SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,NON_CDS_CONSERVED,5) = CODON; } /* Finished calculating state CODON */ /* For state INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open) + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CODON,0)); /* From state INTRON_0 to state INTRON_MATCH_0 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,0)); } /* From state INTRON_MATCH_0 to state INTRON_MATCH_0 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_0,0)); } /* Ok - finished max calculation for INTRON_MATCH_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_0) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_MATCH_0 */ /* For state INTRON_0 */ /* setting first movement to score */ score = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + 0 + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_0,0)); /* From state INTRON_0 to state INTRON_0 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,0)); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open) + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,CODON,0)); /* From state INTRON_1 to state INTRON_MATCH_1 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,0)); } /* From state INTRON_MATCH_1 to state INTRON_MATCH_1 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_1,0)); } /* Ok - finished max calculation for INTRON_MATCH_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_1) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_MATCH_1 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + 0 + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_1,0)); /* From state INTRON_1 to state INTRON_1 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,0)); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open) + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,0)); /* From state INTRON_2 to state INTRON_MATCH_2 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,0)); } /* From state INTRON_MATCH_2 to state INTRON_MATCH_2 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_2,0)); } /* Ok - finished max calculation for INTRON_MATCH_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_2) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_MATCH_2 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + 0 + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_MATCH_2,0)); /* From state INTRON_2 to state INTRON_2 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,0)); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ /* For state REV_CODON */ /* setting first movement to score */ score = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,REV_CODON) + mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)] + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,REV_CODON,0)); /* From state REV_CODON to state REV_CODON */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,REV_CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,REV_CODON,0)); } /* From state REV_INTRON_MATCH_0 to state REV_CODON */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,REV_INTRON_MATCH_0) + CSEQ_REV_PAIR_5SS(mat->seq,(j-3)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,REV_INTRON_MATCH_0,0)); } /* From state REV_INTRON_MATCH_1 to state REV_CODON */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,REV_INTRON_MATCH_1) + CSEQ_REV_PAIR_5SS(mat->seq,(j-1)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,REV_INTRON_MATCH_1,0)); } /* From state REV_INTRON_MATCH_2 to state REV_CODON */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,REV_INTRON_MATCH_2) + CSEQ_PAIR_5SS(mat->seq,(j-2)) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,REV_INTRON_MATCH_2,0)); } /* From state NON_CDS_CONSERVED to state REV_CODON */ temp = SyWise20_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,NON_CDS_CONSERVED) + mat->start->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)] + (0); if( temp > score ) { score = temp; /* This state [NON_CDS_CONSERVED] is a special for REV_CODON... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= REV_CODON; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for REV_CODON */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,REV_CODON) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state REV_CODON is a source for special NON_CDS_CONSERVED */ temp = score + (((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)])) + (0) ; if( temp > SyWise20_DC_OPT_SHADOW_SPECIAL(mat,i,j,NON_CDS_CONSERVED) ) { SyWise20_DC_OPT_SHADOW_SPECIAL(mat,i,j,NON_CDS_CONSERVED) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,NON_CDS_CONSERVED,k) = SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,k); SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,NON_CDS_CONSERVED,6) = SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,6); SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,NON_CDS_CONSERVED,3) = i; SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,NON_CDS_CONSERVED,4) = j; SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,NON_CDS_CONSERVED,5) = REV_CODON; } /* Finished calculating state REV_CODON */ /* For state REV_INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_REV_PAIR_3SS(mat->seq,j))+mat->intron_open) + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_CODON,0)); /* From state REV_INTRON_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_0,0)); } /* From state REV_INTRON_MATCH_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_0,0)); } /* Ok - finished max calculation for REV_INTRON_MATCH_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REV_INTRON_MATCH_0 */ /* For state REV_INTRON_0 */ /* setting first movement to score */ score = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_0) + 0 + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_0,0)); /* From state REV_INTRON_MATCH_0 to state REV_INTRON_0 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_0,0)); } /* Ok - finished max calculation for REV_INTRON_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,REV_INTRON_0) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REV_INTRON_0 */ /* For state REV_INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open) + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,REV_CODON,0)); /* From state REV_INTRON_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_1,0)); } /* From state REV_INTRON_MATCH_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_1,0)); } /* Ok - finished max calculation for REV_INTRON_MATCH_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REV_INTRON_MATCH_1 */ /* For state REV_INTRON_1 */ /* setting first movement to score */ score = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_1) + 0 + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_1,0)); /* From state REV_INTRON_MATCH_1 to state REV_INTRON_1 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_1,0)); } /* Ok - finished max calculation for REV_INTRON_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,REV_INTRON_1) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REV_INTRON_1 */ /* For state REV_INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open) + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,REV_CODON,0)); /* From state REV_INTRON_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_2,0)); } /* From state REV_INTRON_MATCH_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_2,0)); } /* Ok - finished max calculation for REV_INTRON_MATCH_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REV_INTRON_MATCH_2 */ /* For state REV_INTRON_2 */ /* setting first movement to score */ score = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_2) + 0 + (0); /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_2,0)); /* From state REV_INTRON_MATCH_2 to state REV_INTRON_2 */ temp = SyWise20_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REV_INTRON_MATCH_2,0)); } /* Ok - finished max calculation for REV_INTRON_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SyWise20_DC_OPT_SHADOW_MATRIX(mat,i,j,REV_INTRON_2) = score; for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REV_INTRON_2 */ } /* end of for each i position in strip */ /* Special state NON_CDS_CONSERVED has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_DC_OPT_SHADOW_SPECIAL(mat,0,j,NON_CDS_CONSERVED); /* Source CODON for state NON_CDS_CONSERVED is not special... already calculated */ /* Source REV_CODON for state NON_CDS_CONSERVED is not special... already calculated */ /* Source NON_CDS_CONSERVED is a special source for NON_CDS_CONSERVED */ temp = SyWise20_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,NON_CDS_CONSERVED) + (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,NON_CDS_CONSERVED,k) = SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,NON_CDS_CONSERVED,k); } /* Source RND_SEQ is a special source for NON_CDS_CONSERVED */ temp = SyWise20_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,RND_SEQ) + ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,NON_CDS_CONSERVED,k) = SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,RND_SEQ,k); } /* Put back score... (now updated!) */ SyWise20_DC_OPT_SHADOW_SPECIAL(mat,0,j,NON_CDS_CONSERVED) = score; /* Finished updating state NON_CDS_CONSERVED */ /* Special state RND_SEQ has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_DC_OPT_SHADOW_SPECIAL(mat,0,j,RND_SEQ); /* Source NON_CDS_CONSERVED is a special source for RND_SEQ */ temp = SyWise20_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,NON_CDS_CONSERVED) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_SEQ,k) = SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,NON_CDS_CONSERVED,k); } /* Source RND_SEQ is a special source for RND_SEQ */ temp = SyWise20_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_SEQ,k) = SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,RND_SEQ,k); } /* Source START is a special source for RND_SEQ */ temp = SyWise20_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_SEQ,k) = SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,START,k); } /* Put back score... (now updated!) */ SyWise20_DC_OPT_SHADOW_SPECIAL(mat,0,j,RND_SEQ) = score; /* Finished updating state RND_SEQ */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_DC_OPT_SHADOW_SPECIAL(mat,0,j,END); /* Source RND_SEQ is a special source for END */ temp = SyWise20_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = SyWise20_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,RND_SEQ,k); } /* Put back score... (now updated!) */ SyWise20_DC_OPT_SHADOW_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_SyWise20(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * */ void init_start_end_linear_SyWise20(SyWise20 * mat) { register int i; register int j; for(j=0;j<5;j++) { for(i=(-1);iexonmodel->len;i++) { SyWise20_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = (-1); SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_0) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_0,0) = (-1); SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-1); SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_1) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_1,0) = (-1); SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-1); SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_MATCH_2) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_MATCH_2,0) = (-1); SyWise20_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-1); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_CODON) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_CODON,0) = (-1); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_0,0) = (-1); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_0) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_0,0) = (-1); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_1,0) = (-1); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_1) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_1,0) = (-1); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_MATCH_2,0) = (-1); SyWise20_DC_SHADOW_MATRIX(mat,i,j,REV_INTRON_2) = NEGI; SyWise20_DC_SHADOW_MATRIX_SP(mat,i,j,REV_INTRON_2,0) = (-1); } } for(j=(-3);jseq->length;j++) { SyWise20_DC_SHADOW_SPECIAL(mat,0,j,NON_CDS_CONSERVED) = NEGI; SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,j,NON_CDS_CONSERVED,0) = (-1); SyWise20_DC_SHADOW_SPECIAL(mat,0,j,RND_SEQ) = NEGI; SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,j,RND_SEQ,0) = (-1); SyWise20_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; SyWise20_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; SyWise20_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_SyWise20(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_SyWise20(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_SyWise20(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "EXON_STATE","INTRON_STATE","REV_EXON_STATE","REV_INTRON_STATE","NON_CDS_CONSERVED","LOOP_STATE","END" }; /* Function: AlnConvertSet_SyWise20(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","5SS_PHASE_0","NON_CDS_CONSERVED","CENTRAL_INTRON","5SS_PHASE_1","5SS_PHASE_2","REV_CODON","REV_5SS_PHASE_0","REV_5SS_PHASE_1","REV_5SS_PHASE_2","REV_3SS_PHASE_0","REV_3SS_PHASE_1","GENE_EXIT","RANDOM_SEQUENCE","END" }; AlnConvertSet * AlnConvertSet_SyWise20(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = CODON; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = CODON; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = NON_CDS_CONSERVED + 14; acu->is_from_special = TRUE; acu->state2 = CODON; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_MATCH_0; acu->state2 = CODON; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_MATCH_1; acu->state2 = CODON; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_MATCH_2; acu->state2 = CODON; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = INTRON_MATCH_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INTRON_MATCH_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_MATCH_0; acu->state2 = INTRON_MATCH_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_MATCH_0; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = INTRON_MATCH_1; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INTRON_MATCH_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_MATCH_1; acu->state2 = INTRON_MATCH_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_MATCH_1; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = INTRON_MATCH_2; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INTRON_MATCH_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_MATCH_2; acu->state2 = INTRON_MATCH_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_MATCH_2; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_CODON; acu->state2 = REV_CODON; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_CODON; acu->state2 = REV_CODON; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_MATCH_0; acu->state2 = REV_CODON; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_MATCH_1; acu->state2 = REV_CODON; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_MATCH_2; acu->state2 = REV_CODON; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[2]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = NON_CDS_CONSERVED + 14; acu->is_from_special = TRUE; acu->state2 = REV_CODON; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_CODON; acu->state2 = REV_INTRON_MATCH_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[13]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_0; acu->state2 = REV_INTRON_MATCH_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_MATCH_0; acu->state2 = REV_INTRON_MATCH_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_0; acu->state2 = REV_INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_MATCH_0; acu->state2 = REV_INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_CODON; acu->state2 = REV_INTRON_MATCH_1; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[3]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_1; acu->state2 = REV_INTRON_MATCH_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_MATCH_1; acu->state2 = REV_INTRON_MATCH_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_1; acu->state2 = REV_INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_MATCH_1; acu->state2 = REV_INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_CODON; acu->state2 = REV_INTRON_MATCH_2; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[3]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_2; acu->state2 = REV_INTRON_MATCH_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_MATCH_2; acu->state2 = REV_INTRON_MATCH_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_2; acu->state2 = REV_INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_INTRON_MATCH_2; acu->state2 = REV_INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = NON_CDS_CONSERVED + 14; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[15]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REV_CODON; acu->state2 = NON_CDS_CONSERVED + 14; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[15]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = NON_CDS_CONSERVED + 14; acu->state2 = NON_CDS_CONSERVED + 14; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[16]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_SEQ + 14; acu->state2 = NON_CDS_CONSERVED + 14; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[16]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = NON_CDS_CONSERVED + 14; acu->state2 = RND_SEQ + 14; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[16]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_SEQ + 14; acu->state2 = RND_SEQ + 14; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[16]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 14; acu->state2 = RND_SEQ + 14; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[16]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_SEQ + 14; acu->state2 = END + 14; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[17]; add_collapse_label_AlnConvertSet(out,"LOOP_STATE","RANDOM_SEQUENCE"); add_collapse_label_AlnConvertSet(out,"NON_CDS_CONSERVED","RANDOM_SEQUENCE"); add_collapse_label_AlnConvertSet(out,"INTRON_STATE","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_STATE","NON_CDS_CONSERVED"); add_collapse_label_AlnConvertSet(out,"REV_INTRON_STATE","NON_CDS_CONSERVED"); return out; } /* Function: PackAln_read_Expl_SyWise20(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_SyWise20(SyWise20 * mat) { SyWise20_access_func_holder holder; holder.access_main = SyWise20_explicit_access_main; holder.access_special = SyWise20_explicit_access_special; return PackAln_read_generic_SyWise20(mat,holder); } /* Function: SyWise20_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int SyWise20_explicit_access_main(SyWise20 * mat,int i,int j,int state) { return SyWise20_EXPL_MATRIX(mat,i,j,state); } /* Function: SyWise20_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int SyWise20_explicit_access_special(SyWise20 * mat,int i,int j,int state) { return SyWise20_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_SyWise20(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: h [UNKN ] Undocumented argument [SyWise20_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_SyWise20(SyWise20 * mat,SyWise20_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_SyWise20(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in SyWise20_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 14; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_SyWise20(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_SyWise20(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == SyWise20_READ_OFF_ERROR || j == SyWise20_READ_OFF_ERROR || state == SyWise20_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in SyWise20_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 14; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_SyWise20(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [SyWise20_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_SyWise20(SyWise20 * mat,int * ri,int * rj,int * state,boolean * isspecial,SyWise20_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->seq->length-1,END); maxj = mat->seq->length-1; for(j= mat->seq->length-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: SyWise20_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void SyWise20_debug_show_matrix(SyWise20 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iexonmodel->len;i++) { for(j=startj;jseq->length;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State CODON %d\n",SyWise20_EXPL_MATRIX(mat,i,j,CODON)); fprintf(ofp,"State INTRON_MATCH_0 %d\n",SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_0)); fprintf(ofp,"State INTRON_0 %d\n",SyWise20_EXPL_MATRIX(mat,i,j,INTRON_0)); fprintf(ofp,"State INTRON_MATCH_1 %d\n",SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_1)); fprintf(ofp,"State INTRON_1 %d\n",SyWise20_EXPL_MATRIX(mat,i,j,INTRON_1)); fprintf(ofp,"State INTRON_MATCH_2 %d\n",SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_2)); fprintf(ofp,"State INTRON_2 %d\n",SyWise20_EXPL_MATRIX(mat,i,j,INTRON_2)); fprintf(ofp,"State REV_CODON %d\n",SyWise20_EXPL_MATRIX(mat,i,j,REV_CODON)); fprintf(ofp,"State REV_INTRON_MATCH_0 %d\n",SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_0)); fprintf(ofp,"State REV_INTRON_0 %d\n",SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_0)); fprintf(ofp,"State REV_INTRON_MATCH_1 %d\n",SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_1)); fprintf(ofp,"State REV_INTRON_1 %d\n",SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_1)); fprintf(ofp,"State REV_INTRON_MATCH_2 %d\n",SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_2)); fprintf(ofp,"State REV_INTRON_2 %d\n",SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_2)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_SyWise20(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [SyWise20_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_SyWise20(SyWise20 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,SyWise20_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = SyWise20_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->exonmodel->len || j > mat->seq->length) { warn("In SyWise20 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case CODON : temp = cscore - (CSEQ_PAIR_3SS(mat->seq,(j-1))) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,INTRON_MATCH_2) ) { *reti = i - 1; *retj = j - 1; *retstate = INTRON_MATCH_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INTRON_MATCH_2); } return (*h.access_main)(mat,i - 1,j - 1,INTRON_MATCH_2); } temp = cscore - (CSEQ_PAIR_3SS(mat->seq,(j-2))) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,INTRON_MATCH_1) ) { *reti = i - 1; *retj = j - 2; *retstate = INTRON_MATCH_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,INTRON_MATCH_1); } return (*h.access_main)(mat,i - 1,j - 2,INTRON_MATCH_1); } temp = cscore - (CSEQ_PAIR_3SS(mat->seq,(j-3))) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,INTRON_MATCH_0) ) { *reti = i - 1; *retj = j - 3; *retstate = INTRON_MATCH_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INTRON_MATCH_0); } return (*h.access_main)(mat,i - 1,j - 3,INTRON_MATCH_0); } /* Has restricted position */ if( (i-1) == 0 ) { temp = cscore - (mat->start->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 3,NON_CDS_CONSERVED) ) { *reti = i - 1; *retj = j - 3; *retstate = NON_CDS_CONSERVED; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,NON_CDS_CONSERVED); } return (*h.access_main)(mat,i - 1,j - 3,NON_CDS_CONSERVED); } } temp = cscore - ((mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,CODON); } return (*h.access_main)(mat,i - 0,j - 3,CODON); } temp = cscore - (mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,CODON) ) { *reti = i - 1; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,CODON); } return (*h.access_main)(mat,i - 1,j - 3,CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_MATCH_0 : temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_MATCH_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_MATCH_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_MATCH_0); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_MATCH_0); } temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_0); } temp = cscore - (((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CODON); } return (*h.access_main)(mat,i - 0,j - 1,CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_0); } temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_MATCH_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_MATCH_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_MATCH_0); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_MATCH_0); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_MATCH_1 : temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_MATCH_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_MATCH_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_MATCH_1); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_MATCH_1); } temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_1); } temp = cscore - (((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,CODON) ) { *reti = i - 0; *retj = j - 2; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,CODON); } return (*h.access_main)(mat,i - 0,j - 2,CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_1); } temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_MATCH_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_MATCH_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_MATCH_1); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_MATCH_1); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_MATCH_2 : temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_MATCH_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_MATCH_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_MATCH_2); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_MATCH_2); } temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_2); } temp = cscore - (((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,CODON); } return (*h.access_main)(mat,i - 0,j - 3,CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_2); } temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_MATCH_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_MATCH_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_MATCH_2); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_MATCH_2); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_CODON : /* Has restricted position */ if( (i-1) == 0 ) { temp = cscore - (mat->start->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 3,NON_CDS_CONSERVED) ) { *reti = i - 1; *retj = j - 3; *retstate = NON_CDS_CONSERVED; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,NON_CDS_CONSERVED); } return (*h.access_main)(mat,i - 1,j - 3,NON_CDS_CONSERVED); } } temp = cscore - (CSEQ_PAIR_5SS(mat->seq,(j-2))) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,REV_INTRON_MATCH_2) ) { *reti = i - 1; *retj = j - 2; *retstate = REV_INTRON_MATCH_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,REV_INTRON_MATCH_2); } return (*h.access_main)(mat,i - 1,j - 2,REV_INTRON_MATCH_2); } temp = cscore - (CSEQ_REV_PAIR_5SS(mat->seq,(j-1))) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,REV_INTRON_MATCH_1) ) { *reti = i - 1; *retj = j - 1; *retstate = REV_INTRON_MATCH_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,REV_INTRON_MATCH_1); } return (*h.access_main)(mat,i - 1,j - 1,REV_INTRON_MATCH_1); } temp = cscore - (CSEQ_REV_PAIR_5SS(mat->seq,(j-3))) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,REV_INTRON_MATCH_0) ) { *reti = i - 1; *retj = j - 3; *retstate = REV_INTRON_MATCH_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,REV_INTRON_MATCH_0); } return (*h.access_main)(mat,i - 1,j - 3,REV_INTRON_MATCH_0); } temp = cscore - ((mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,REV_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = REV_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,REV_CODON); } return (*h.access_main)(mat,i - 0,j - 3,REV_CODON); } temp = cscore - (mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,REV_CODON) ) { *reti = i - 1; *retj = j - 3; *retstate = REV_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,REV_CODON); } return (*h.access_main)(mat,i - 1,j - 3,REV_CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_MATCH_0 : temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_MATCH_0) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_MATCH_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REV_INTRON_MATCH_0); } return (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_MATCH_0); } temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REV_INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_0); } temp = cscore - (((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_REV_PAIR_3SS(mat->seq,j))+mat->intron_open)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REV_CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REV_CODON); } return (*h.access_main)(mat,i - 0,j - 1,REV_CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_0 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_MATCH_0) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_MATCH_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REV_INTRON_MATCH_0); } return (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_MATCH_0); } temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REV_INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_0); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_MATCH_1 : temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_MATCH_1) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_MATCH_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REV_INTRON_MATCH_1); } return (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_MATCH_1); } temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REV_INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_1); } temp = cscore - (((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,REV_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = REV_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,REV_CODON); } return (*h.access_main)(mat,i - 0,j - 3,REV_CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_1 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_MATCH_1) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_MATCH_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REV_INTRON_MATCH_1); } return (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_MATCH_1); } temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REV_INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_1); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_MATCH_2 : temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_MATCH_2) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_MATCH_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REV_INTRON_MATCH_2); } return (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_MATCH_2); } temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REV_INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_2); } temp = cscore - (((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,REV_CODON) ) { *reti = i - 0; *retj = j - 2; *retstate = REV_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,REV_CODON); } return (*h.access_main)(mat,i - 0,j - 2,REV_CODON); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REV_INTRON_2 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_MATCH_2) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_MATCH_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REV_INTRON_MATCH_2); } return (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_MATCH_2); } temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = REV_INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REV_INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,REV_INTRON_2); } warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_SyWise20(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [SyWise20_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_SyWise20(SyWise20 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,SyWise20_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = SyWise20_READ_OFF_ERROR; if( j < 0 || j > mat->seq->length) { warn("In SyWise20 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case NON_CDS_CONSERVED : /* source RND_SEQ is a special */ temp = cscore - ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,RND_SEQ) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_SEQ; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,RND_SEQ); } return (*h.access_special)(mat,i - 0,j - 1,RND_SEQ) ; } /* source NON_CDS_CONSERVED is a special */ temp = cscore - (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,NON_CDS_CONSERVED) ) { *reti = i - 0; *retj = j - 1; *retstate = NON_CDS_CONSERVED; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,NON_CDS_CONSERVED); } return (*h.access_special)(mat,i - 0,j - 1,NON_CDS_CONSERVED) ; } /* source REV_CODON is from main matrix */ for(i= mat->exonmodel->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,REV_CODON) ) { *reti = i - 0; *retj = j - 0; *retstate = REV_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,REV_CODON); } return (*h.access_main)(mat,i - 0,j - 0,REV_CODON) ; } } /* end of for i >= 0 */ /* source CODON is from main matrix */ for(i= mat->exonmodel->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,CODON) ) { *reti = i - 0; *retj = j - 0; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,CODON); } return (*h.access_main)(mat,i - 0,j - 0,CODON) ; } } /* end of for i >= 0 */ case RND_SEQ : /* source START is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_special)(mat,i - 0,j - 1,START) ; } /* source RND_SEQ is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,RND_SEQ) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_SEQ; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,RND_SEQ); } return (*h.access_special)(mat,i - 0,j - 1,RND_SEQ) ; } /* source NON_CDS_CONSERVED is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,NON_CDS_CONSERVED) ) { *reti = i - 0; *retj = j - 1; *retstate = NON_CDS_CONSERVED; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,NON_CDS_CONSERVED); } return (*h.access_special)(mat,i - 0,j - 1,NON_CDS_CONSERVED) ; } case START : case END : /* source RND_SEQ is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,RND_SEQ) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_SEQ; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,RND_SEQ); } return (*h.access_special)(mat,i - 0,j - 1,RND_SEQ) ; } default: warn("Major problem (!) - in SyWise20 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_SyWise20(mat) * * Descrip: This function calculates the SyWise20 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_SyWise20 * * * Arg: mat [UNKN ] SyWise20 which contains explicit basematrix memory [SyWise20 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_SyWise20(SyWise20 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_SyWise20, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("SyWise20 Matrix calculation: "); for(j=0;jcodon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]; /* From state CODON to state CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-3,CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state NON_CDS_CONSERVED to state CODON */ temp = SyWise20_EXPL_SPECIAL(mat,i-1,j-3,NON_CDS_CONSERVED) + mat->start->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]; if( temp > score ) { score = temp; } } /* From state INTRON_MATCH_0 to state CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-1,j-3,INTRON_MATCH_0) + CSEQ_PAIR_3SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_1 to state CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-1,j-2,INTRON_MATCH_1) + CSEQ_PAIR_3SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_2 to state CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-1,j-1,INTRON_MATCH_2) + CSEQ_PAIR_3SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,CODON) = score; /* state CODON is a source for special NON_CDS_CONSERVED */ temp = score + (((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)])) + (0) ; if( temp > SyWise20_EXPL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) ) { SyWise20_EXPL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) = temp; } /* Finished calculating state CODON */ /* For state INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_0 to state INTRON_MATCH_0 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_0 to state INTRON_MATCH_0 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_0) = score; /* Finished calculating state INTRON_MATCH_0 */ /* For state INTRON_0 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + 0; /* From state INTRON_0 to state INTRON_0 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-2,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_1 to state INTRON_MATCH_1 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_1 to state INTRON_MATCH_1 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_1) = score; /* Finished calculating state INTRON_MATCH_1 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + 0; /* From state INTRON_1 to state INTRON_1 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-3,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_2 to state INTRON_MATCH_2 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_2 to state INTRON_MATCH_2 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_2) = score; /* Finished calculating state INTRON_MATCH_2 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + 0; /* From state INTRON_2 to state INTRON_2 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state REV_CODON */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-1,j-3,REV_CODON) + mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]; /* From state REV_CODON to state REV_CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-3,REV_CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_0 to state REV_CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-1,j-3,REV_INTRON_MATCH_0) + CSEQ_REV_PAIR_5SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_1 to state REV_CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-1,j-1,REV_INTRON_MATCH_1) + CSEQ_REV_PAIR_5SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_2 to state REV_CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-1,j-2,REV_INTRON_MATCH_2) + CSEQ_PAIR_5SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state NON_CDS_CONSERVED to state REV_CODON */ temp = SyWise20_EXPL_SPECIAL(mat,i-1,j-3,NON_CDS_CONSERVED) + mat->start->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for REV_CODON */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_CODON) = score; /* state REV_CODON is a source for special NON_CDS_CONSERVED */ temp = score + (((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)])) + (0) ; if( temp > SyWise20_EXPL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) ) { SyWise20_EXPL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) = temp; } /* Finished calculating state REV_CODON */ /* For state REV_INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_REV_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = score; /* Finished calculating state REV_INTRON_MATCH_0 */ /* For state REV_INTRON_0 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_0) + 0; /* From state REV_INTRON_MATCH_0 to state REV_INTRON_0 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_0 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_0) = score; /* Finished calculating state REV_INTRON_0 */ /* For state REV_INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-3,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = score; /* Finished calculating state REV_INTRON_MATCH_1 */ /* For state REV_INTRON_1 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_1) + 0; /* From state REV_INTRON_MATCH_1 to state REV_INTRON_1 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_1 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_1) = score; /* Finished calculating state REV_INTRON_1 */ /* For state REV_INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-2,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = score; /* Finished calculating state REV_INTRON_MATCH_2 */ /* For state REV_INTRON_2 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_2) + 0; /* From state REV_INTRON_MATCH_2 to state REV_INTRON_2 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_2 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_2) = score; /* Finished calculating state REV_INTRON_2 */ } /* Special state NON_CDS_CONSERVED has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_EXPL_SPECIAL(mat,0,j,NON_CDS_CONSERVED); /* Source CODON for state NON_CDS_CONSERVED is not special... already calculated */ /* Source REV_CODON for state NON_CDS_CONSERVED is not special... already calculated */ /* Source NON_CDS_CONSERVED is a special source for NON_CDS_CONSERVED */ temp = SyWise20_EXPL_SPECIAL(mat,0,j - 1,NON_CDS_CONSERVED) + (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) + (0); if( temp > score ) score = temp; /* Source RND_SEQ is a special source for NON_CDS_CONSERVED */ temp = SyWise20_EXPL_SPECIAL(mat,0,j - 1,RND_SEQ) + ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ SyWise20_EXPL_SPECIAL(mat,0,j,NON_CDS_CONSERVED) = score; /* Finished updating state NON_CDS_CONSERVED */ /* Special state RND_SEQ has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_EXPL_SPECIAL(mat,0,j,RND_SEQ); /* Source NON_CDS_CONSERVED is a special source for RND_SEQ */ temp = SyWise20_EXPL_SPECIAL(mat,0,j - 1,NON_CDS_CONSERVED) + (0) + (0); if( temp > score ) score = temp; /* Source RND_SEQ is a special source for RND_SEQ */ temp = SyWise20_EXPL_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) score = temp; /* Source START is a special source for RND_SEQ */ temp = SyWise20_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ SyWise20_EXPL_SPECIAL(mat,0,j,RND_SEQ) = score; /* Finished updating state RND_SEQ */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_EXPL_SPECIAL(mat,0,j,END); /* Source RND_SEQ is a special source for END */ temp = SyWise20_EXPL_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ SyWise20_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_SyWise20(mat,dpenv) * * Descrip: This function calculates the SyWise20 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] SyWise20 which contains explicit basematrix memory [SyWise20 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_SyWise20(SyWise20 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_SyWise20, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-3;jleni;i++) { SyWise20_EXPL_MATRIX(mat,i,j,CODON) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_2) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_CODON) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_2) = NEGI; } } for(j=-3;jlenj;j++) { SyWise20_EXPL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) = NEGI; SyWise20_EXPL_SPECIAL(mat,i,j,RND_SEQ) = NEGI; SyWise20_EXPL_SPECIAL(mat,i,j,START) = 0; SyWise20_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("SyWise20 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { SyWise20_EXPL_MATRIX(mat,i,j,CODON) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_2) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_CODON) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_0) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_1) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = NEGI; SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_2) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state CODON */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-1,j-3,CODON) + mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]; /* From state CODON to state CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-3,CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state NON_CDS_CONSERVED to state CODON */ temp = SyWise20_EXPL_SPECIAL(mat,i-1,j-3,NON_CDS_CONSERVED) + mat->start->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)]; if( temp > score ) { score = temp; } } /* From state INTRON_MATCH_0 to state CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-1,j-3,INTRON_MATCH_0) + CSEQ_PAIR_3SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_1 to state CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-1,j-2,INTRON_MATCH_1) + CSEQ_PAIR_3SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_2 to state CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-1,j-1,INTRON_MATCH_2) + CSEQ_PAIR_3SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,CODON) = score; /* state CODON is a source for special NON_CDS_CONSERVED */ temp = score + (((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_PAIR_PAIRCODON(mat->seq,j)])) + (0) ; if( temp > SyWise20_EXPL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) ) { SyWise20_EXPL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) = temp; } /* Finished calculating state CODON */ /* For state INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_0 to state INTRON_MATCH_0 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_0 to state INTRON_MATCH_0 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_0) = score; /* Finished calculating state INTRON_MATCH_0 */ /* For state INTRON_0 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_MATCH_0) + 0; /* From state INTRON_0 to state INTRON_0 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-2,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_1 to state INTRON_MATCH_1 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_1 to state INTRON_MATCH_1 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_1) = score; /* Finished calculating state INTRON_MATCH_1 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_MATCH_1) + 0; /* From state INTRON_1 to state INTRON_1 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-3,CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_5SS(mat->seq,j))+mat->intron_open); /* From state INTRON_2 to state INTRON_MATCH_2 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state INTRON_MATCH_2 to state INTRON_MATCH_2 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,INTRON_MATCH_2) = score; /* Finished calculating state INTRON_MATCH_2 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_MATCH_2) + 0; /* From state INTRON_2 to state INTRON_2 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state REV_CODON */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-1,j-3,REV_CODON) + mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]; /* From state REV_CODON to state REV_CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-3,REV_CODON) + (mat->exonmodel->exon[i]->stay_score+mat->codon->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_0 to state REV_CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-1,j-3,REV_INTRON_MATCH_0) + CSEQ_REV_PAIR_5SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_1 to state REV_CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-1,j-1,REV_INTRON_MATCH_1) + CSEQ_REV_PAIR_5SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_2 to state REV_CODON */ temp = SyWise20_EXPL_MATRIX(mat,i-1,j-2,REV_INTRON_MATCH_2) + CSEQ_PAIR_5SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state NON_CDS_CONSERVED to state REV_CODON */ temp = SyWise20_EXPL_SPECIAL(mat,i-1,j-3,NON_CDS_CONSERVED) + mat->start->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)]; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for REV_CODON */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_CODON) = score; /* state REV_CODON is a source for special NON_CDS_CONSERVED */ temp = score + (((mat->exonmodel->exon[i]->exit_score+mat->gene_open)+mat->stop->codon[CSEQ_REV_PAIR_PAIRCODON(mat->seq,j)])) + (0) ; if( temp > SyWise20_EXPL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) ) { SyWise20_EXPL_SPECIAL(mat,i,j,NON_CDS_CONSERVED) = temp; } /* Finished calculating state REV_CODON */ /* For state REV_INTRON_MATCH_0 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_REV_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_0) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_0 to state REV_INTRON_MATCH_0 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_0 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_0) = score; /* Finished calculating state REV_INTRON_MATCH_0 */ /* For state REV_INTRON_0 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_0) + 0; /* From state REV_INTRON_MATCH_0 to state REV_INTRON_0 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_0 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_0) = score; /* Finished calculating state REV_INTRON_0 */ /* For state REV_INTRON_MATCH_1 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-3,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_1) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_1 to state REV_INTRON_MATCH_1 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_1 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_1) = score; /* Finished calculating state REV_INTRON_MATCH_1 */ /* For state REV_INTRON_1 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_1) + 0; /* From state REV_INTRON_MATCH_1 to state REV_INTRON_1 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_1 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_1) = score; /* Finished calculating state REV_INTRON_1 */ /* For state REV_INTRON_MATCH_2 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-2,REV_CODON) + ((mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]+CSEQ_PAIR_3SS(mat->seq,j))+mat->intron_open); /* From state REV_INTRON_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_2) + (mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]); if( temp > score ) { score = temp; } /* From state REV_INTRON_MATCH_2 to state REV_INTRON_MATCH_2 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_MATCH_2 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_MATCH_2) = score; /* Finished calculating state REV_INTRON_MATCH_2 */ /* For state REV_INTRON_2 */ /* setting first movement to score */ score = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_2) + 0; /* From state REV_INTRON_MATCH_2 to state REV_INTRON_2 */ temp = SyWise20_EXPL_MATRIX(mat,i-0,j-1,REV_INTRON_MATCH_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REV_INTRON_2 */ /* Add any movement independant score and put away */ SyWise20_EXPL_MATRIX(mat,i,j,REV_INTRON_2) = score; /* Finished calculating state REV_INTRON_2 */ } /* Special state NON_CDS_CONSERVED has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_EXPL_SPECIAL(mat,0,j,NON_CDS_CONSERVED); /* Source CODON for state NON_CDS_CONSERVED is not special... already calculated */ /* Source REV_CODON for state NON_CDS_CONSERVED is not special... already calculated */ /* Source NON_CDS_CONSERVED is a special source for NON_CDS_CONSERVED */ temp = SyWise20_EXPL_SPECIAL(mat,0,j - 1,NON_CDS_CONSERVED) + (mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)]) + (0); if( temp > score ) score = temp; /* Source RND_SEQ is a special source for NON_CDS_CONSERVED */ temp = SyWise20_EXPL_SPECIAL(mat,0,j - 1,RND_SEQ) + ((mat->nonc_cost+mat->nonc->base[CSEQ_PAIR_PAIRBASE(mat->seq,j)])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ SyWise20_EXPL_SPECIAL(mat,0,j,NON_CDS_CONSERVED) = score; /* Finished updating state NON_CDS_CONSERVED */ /* Special state RND_SEQ has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_EXPL_SPECIAL(mat,0,j,RND_SEQ); /* Source NON_CDS_CONSERVED is a special source for RND_SEQ */ temp = SyWise20_EXPL_SPECIAL(mat,0,j - 1,NON_CDS_CONSERVED) + (0) + (0); if( temp > score ) score = temp; /* Source RND_SEQ is a special source for RND_SEQ */ temp = SyWise20_EXPL_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) score = temp; /* Source START is a special source for RND_SEQ */ temp = SyWise20_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ SyWise20_EXPL_SPECIAL(mat,0,j,RND_SEQ) = score; /* Finished updating state RND_SEQ */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = SyWise20_EXPL_SPECIAL(mat,0,j,END); /* Source RND_SEQ is a special source for END */ temp = SyWise20_EXPL_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ SyWise20_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: SyWise20_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SyWise20 *] * */ SyWise20 * SyWise20_alloc(void) { SyWise20 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SyWise20 *) ckalloc (sizeof(SyWise20))) == NULL) { warn("SyWise20_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_SyWise20(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SyWise20 *] * * Return [UNKN ] Undocumented return value [SyWise20 *] * */ SyWise20 * free_SyWise20(SyWise20 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SyWise20 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->exonmodel is linked in */ /* obj->seq is linked in */ /* obj->codon is linked in */ /* obj->nonc is linked in */ /* obj->start is linked in */ /* obj->stop is linked in */ /* obj->intron_open is linked in */ /* obj->gene_open is linked in */ /* obj->nonc_cost is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/sywise20.h0000644000175000001440000005326710670453715016006 0ustar philippusers#ifndef DYNAMITEsywise20HEADERFILE #define DYNAMITEsywise20HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "pairbaseseq.h" #include "pairbase.h" #include "syexonmodel.h" struct Wise2_SyWise20 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; SyExonScore* exonmodel; ComplexSequence* seq; PairBaseCodonModelScore* codon; PairBaseModelScore* nonc; PairBaseCodonModelScore* start; PairBaseCodonModelScore* stop; Score intron_open; Score gene_open; Score nonc_cost; } ; /* SyWise20 defined */ #ifndef DYNAMITE_DEFINED_SyWise20 typedef struct Wise2_SyWise20 Wise2_SyWise20; #define SyWise20 Wise2_SyWise20 #define DYNAMITE_DEFINED_SyWise20 #endif #ifdef PTHREAD struct thread_pool_holder_SyWise20 { SyExonScore* exonmodel; /* Static query data: never free'd */ ComplexSequence* seq; /* Static target data: never free'd */ PairBaseCodonModelScore* codon; PairBaseModelScore* nonc; PairBaseCodonModelScore* start; PairBaseCodonModelScore* stop; Score intron_open; Score gene_open; Score nonc_cost; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_SyWise20_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(SyWise20*,int,int,int); int (*access_special)(SyWise20*,int,int,int); } ; /* SyWise20_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_SyWise20_access_func_holder typedef struct Wise2_SyWise20_access_func_holder Wise2_SyWise20_access_func_holder; #define SyWise20_access_func_holder Wise2_SyWise20_access_func_holder #define DYNAMITE_DEFINED_SyWise20_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_SyWise20(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_SyWise20(SyWise20 * mat); #define PackAln_read_Shatter_SyWise20 Wise2_PackAln_read_Shatter_SyWise20 /* Function: calculate_shatter_SyWise20(mat,dpenv) * * Descrip: This function calculates the SyWise20 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [SyWise20 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_SyWise20(SyWise20 * mat,DPEnvelope * dpenv); #define calculate_shatter_SyWise20 Wise2_calculate_shatter_SyWise20 /* Function: search_SyWise20(dbsi,out,exonmodel,seq,codon,nonc,start,stop,intron_open,gene_open,nonc_cost) * * Descrip: This function makes a database search of SyWise20 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: exonmodel [UNKN ] Undocumented argument [SyExonScore*] * Arg: seq [UNKN ] Undocumented argument [ComplexSequence*] * Arg: codon [UNKN ] Undocumented argument [PairBaseCodonModelScore*] * Arg: nonc [UNKN ] Undocumented argument [PairBaseModelScore*] * Arg: start [UNKN ] Undocumented argument [PairBaseCodonModelScore*] * Arg: stop [UNKN ] Undocumented argument [PairBaseCodonModelScore*] * Arg: intron_open [UNKN ] Undocumented argument [Score] * Arg: gene_open [UNKN ] Undocumented argument [Score] * Arg: nonc_cost [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_SyWise20(DBSearchImpl * dbsi,Hscore * out,SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost); #define search_SyWise20 Wise2_search_SyWise20 /* Function: serial_search_SyWise20(out,exonmodel,seq,codon,nonc,start,stop,intron_open,gene_open,nonc_cost) * * Descrip: This function makes a database search of SyWise20 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: exonmodel [UNKN ] Undocumented argument [SyExonScore*] * Arg: seq [UNKN ] Undocumented argument [ComplexSequence*] * Arg: codon [UNKN ] Undocumented argument [PairBaseCodonModelScore*] * Arg: nonc [UNKN ] Undocumented argument [PairBaseModelScore*] * Arg: start [UNKN ] Undocumented argument [PairBaseCodonModelScore*] * Arg: stop [UNKN ] Undocumented argument [PairBaseCodonModelScore*] * Arg: intron_open [UNKN ] Undocumented argument [Score] * Arg: gene_open [UNKN ] Undocumented argument [Score] * Arg: nonc_cost [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_SyWise20(Hscore * out,SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost); #define serial_search_SyWise20 Wise2_serial_search_SyWise20 /* Function: PackAln_bestmemory_SyWise20(exonmodel,seq,codon,nonc,start,stop,intron_open,gene_open,nonc_cost,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_SyWise20 * * * Arg: exonmodel [UNKN ] query data structure [SyExonScore*] * Arg: seq [UNKN ] target data structure [ComplexSequence*] * Arg: codon [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: nonc [UNKN ] Resource [PairBaseModelScore*] * Arg: start [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: stop [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: intron_open [UNKN ] Resource [Score] * Arg: gene_open [UNKN ] Resource [Score] * Arg: nonc_cost [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_SyWise20(SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_SyWise20 Wise2_PackAln_bestmemory_SyWise20 /* Function: allocate_Expl_SyWise20(exonmodel,seq,codon,nonc,start,stop,intron_open,gene_open,nonc_cost,dpri) * * Descrip: This function allocates the SyWise20 structure * and the basematrix area for explicit memory implementations * It calls /allocate_SyWise20_only * * * Arg: exonmodel [UNKN ] query data structure [SyExonScore*] * Arg: seq [UNKN ] target data structure [ComplexSequence*] * Arg: codon [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: nonc [UNKN ] Resource [PairBaseModelScore*] * Arg: start [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: stop [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: intron_open [UNKN ] Resource [Score] * Arg: gene_open [UNKN ] Resource [Score] * Arg: nonc_cost [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [SyWise20 *] * */ SyWise20 * Wise2_allocate_Expl_SyWise20(SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost,DPRunImpl * dpri); #define allocate_Expl_SyWise20 Wise2_allocate_Expl_SyWise20 /* Function: recalculate_PackAln_SyWise20(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by SyWise20 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * */ void Wise2_recalculate_PackAln_SyWise20(PackAln * pal,SyWise20 * mat); #define recalculate_PackAln_SyWise20 Wise2_recalculate_PackAln_SyWise20 /* Function: allocate_Small_SyWise20(exonmodel,seq,codon,nonc,start,stop,intron_open,gene_open,nonc_cost) * * Descrip: This function allocates the SyWise20 structure * and the basematrix area for a small memory implementations * It calls /allocate_SyWise20_only * * * Arg: exonmodel [UNKN ] query data structure [SyExonScore*] * Arg: seq [UNKN ] target data structure [ComplexSequence*] * Arg: codon [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: nonc [UNKN ] Resource [PairBaseModelScore*] * Arg: start [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: stop [UNKN ] Resource [PairBaseCodonModelScore*] * Arg: intron_open [UNKN ] Resource [Score] * Arg: gene_open [UNKN ] Resource [Score] * Arg: nonc_cost [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [SyWise20 *] * */ SyWise20 * Wise2_allocate_Small_SyWise20(SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost); #define allocate_Small_SyWise20 Wise2_allocate_Small_SyWise20 /* Function: PackAln_calculate_Small_SyWise20(mat,dpenv) * * Descrip: This function calculates an alignment for SyWise20 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_SyWise20 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_SyWise20 * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_SyWise20(SyWise20 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_SyWise20 Wise2_PackAln_calculate_Small_SyWise20 /* Function: AlnRangeSet_calculate_Small_SyWise20(mat) * * Descrip: This function calculates an alignment for SyWise20 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_SyWise20 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_SyWise20 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_SyWise20 * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_SyWise20(SyWise20 * mat); #define AlnRangeSet_calculate_Small_SyWise20 Wise2_AlnRangeSet_calculate_Small_SyWise20 /* Function: AlnRangeSet_from_SyWise20(mat) * * Descrip: This function reads off a start/end structure * for SyWise20 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_SyWise20 * If you have not calculated the matrix use * /AlnRange_calculate_Small_SyWise20 * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_SyWise20(SyWise20 * mat); #define AlnRangeSet_from_SyWise20 Wise2_AlnRangeSet_from_SyWise20 /* Function: convert_PackAln_to_AlnBlock_SyWise20(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_SyWise20(PackAln * pal); #define convert_PackAln_to_AlnBlock_SyWise20 Wise2_convert_PackAln_to_AlnBlock_SyWise20 /* Function: PackAln_read_Expl_SyWise20(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_SyWise20(SyWise20 * mat); #define PackAln_read_Expl_SyWise20 Wise2_PackAln_read_Expl_SyWise20 /* Function: PackAln_read_generic_SyWise20(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [SyWise20 *] * Arg: h [UNKN ] Undocumented argument [SyWise20_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_SyWise20(SyWise20 * mat,SyWise20_access_func_holder h); #define PackAln_read_generic_SyWise20 Wise2_PackAln_read_generic_SyWise20 /* Function: calculate_SyWise20(mat) * * Descrip: This function calculates the SyWise20 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_SyWise20 * * * Arg: mat [UNKN ] SyWise20 which contains explicit basematrix memory [SyWise20 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_SyWise20(SyWise20 * mat); #define calculate_SyWise20 Wise2_calculate_SyWise20 /* Function: calculate_dpenv_SyWise20(mat,dpenv) * * Descrip: This function calculates the SyWise20 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] SyWise20 which contains explicit basematrix memory [SyWise20 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_SyWise20(SyWise20 * mat,DPEnvelope * dpenv); #define calculate_dpenv_SyWise20 Wise2_calculate_dpenv_SyWise20 /* Function: SyWise20_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SyWise20 *] * */ SyWise20 * Wise2_SyWise20_alloc(void); #define SyWise20_alloc Wise2_SyWise20_alloc /* Function: free_SyWise20(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SyWise20 *] * * Return [UNKN ] Undocumented return value [SyWise20 *] * */ SyWise20 * Wise2_free_SyWise20(SyWise20 * obj); #define free_SyWise20 Wise2_free_SyWise20 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_SyWise20_shatter_access_main(SyWise20 * mat,int i,int j,int state); #define SyWise20_shatter_access_main Wise2_SyWise20_shatter_access_main int Wise2_SyWise20_shatter_access_special(SyWise20 * mat,int i,int j,int state); #define SyWise20_shatter_access_special Wise2_SyWise20_shatter_access_special void * Wise2_thread_loop_SyWise20(void * ptr); #define thread_loop_SyWise20 Wise2_thread_loop_SyWise20 int Wise2_score_only_SyWise20(SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost); #define score_only_SyWise20 Wise2_score_only_SyWise20 SyWise20 * Wise2_allocate_SyWise20_only(SyExonScore* exonmodel,ComplexSequence* seq ,PairBaseCodonModelScore* codon,PairBaseModelScore* nonc,PairBaseCodonModelScore* start,PairBaseCodonModelScore* stop,Score intron_open,Score gene_open,Score nonc_cost); #define allocate_SyWise20_only Wise2_allocate_SyWise20_only void Wise2_init_SyWise20(SyWise20 * mat); #define init_SyWise20 Wise2_init_SyWise20 AlnRange * Wise2_AlnRange_build_SyWise20(SyWise20 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_SyWise20 Wise2_AlnRange_build_SyWise20 boolean Wise2_read_hidden_SyWise20(SyWise20 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_SyWise20 Wise2_read_hidden_SyWise20 int Wise2_max_hidden_SyWise20(SyWise20 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_SyWise20 Wise2_max_hidden_SyWise20 boolean Wise2_read_special_strip_SyWise20(SyWise20 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_SyWise20 Wise2_read_special_strip_SyWise20 int Wise2_max_special_strip_SyWise20(SyWise20 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_SyWise20 Wise2_max_special_strip_SyWise20 int Wise2_max_matrix_to_special_SyWise20(SyWise20 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_SyWise20 Wise2_max_matrix_to_special_SyWise20 void Wise2_calculate_hidden_SyWise20(SyWise20 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_SyWise20 Wise2_calculate_hidden_SyWise20 void Wise2_init_hidden_SyWise20(SyWise20 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_SyWise20 Wise2_init_hidden_SyWise20 boolean Wise2_full_dc_SyWise20(SyWise20 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_SyWise20 Wise2_full_dc_SyWise20 boolean Wise2_do_dc_single_pass_SyWise20(SyWise20 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_SyWise20 Wise2_do_dc_single_pass_SyWise20 void Wise2_push_dc_at_merge_SyWise20(SyWise20 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_SyWise20 Wise2_push_dc_at_merge_SyWise20 void Wise2_follow_on_dc_SyWise20(SyWise20 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_SyWise20 Wise2_follow_on_dc_SyWise20 void Wise2_run_up_dc_SyWise20(SyWise20 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_SyWise20 Wise2_run_up_dc_SyWise20 void Wise2_init_dc_SyWise20(SyWise20 * mat); #define init_dc_SyWise20 Wise2_init_dc_SyWise20 int Wise2_start_end_find_end_SyWise20(SyWise20 * mat,int * endj); #define start_end_find_end_SyWise20 Wise2_start_end_find_end_SyWise20 boolean Wise2_dc_optimised_start_end_calc_SyWise20(SyWise20 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_SyWise20 Wise2_dc_optimised_start_end_calc_SyWise20 void Wise2_init_start_end_linear_SyWise20(SyWise20 * mat); #define init_start_end_linear_SyWise20 Wise2_init_start_end_linear_SyWise20 AlnConvertSet * Wise2_AlnConvertSet_SyWise20(void); #define AlnConvertSet_SyWise20 Wise2_AlnConvertSet_SyWise20 int Wise2_SyWise20_explicit_access_main(SyWise20 * mat,int i,int j,int state); #define SyWise20_explicit_access_main Wise2_SyWise20_explicit_access_main int Wise2_SyWise20_explicit_access_special(SyWise20 * mat,int i,int j,int state); #define SyWise20_explicit_access_special Wise2_SyWise20_explicit_access_special int Wise2_find_end_SyWise20(SyWise20 * mat,int * ri,int * rj,int * state,boolean * isspecial,SyWise20_access_func_holder h); #define find_end_SyWise20 Wise2_find_end_SyWise20 void Wise2_SyWise20_debug_show_matrix(SyWise20 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define SyWise20_debug_show_matrix Wise2_SyWise20_debug_show_matrix int Wise2_max_calc_SyWise20(SyWise20 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,SyWise20_access_func_holder h); #define max_calc_SyWise20 Wise2_max_calc_SyWise20 int Wise2_max_calc_special_SyWise20(SyWise20 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,SyWise20_access_func_holder h); #define max_calc_special_SyWise20 Wise2_max_calc_special_SyWise20 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/threestateloop.c0000644000175000001440000051062310670453715017350 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "threestateloop.h" # line 5 "threestateloop.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:33 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define START 0 #define LOOP 1 #define END 2 #define ThreeStateLoop_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*3)+STATE][i+1] #define ThreeStateLoop_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define ThreeStateLoop_READ_OFF_ERROR -3 #define ThreeStateLoop_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*3)+STATE] #define ThreeStateLoop_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define ThreeStateLoop_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define ThreeStateLoop_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_ThreeStateLoop(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_ThreeStateLoop(ThreeStateLoop * mat) { ThreeStateLoop_access_func_holder holder; holder.access_main = ThreeStateLoop_shatter_access_main; holder.access_special = ThreeStateLoop_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_ThreeStateLoop(mat,holder); } /* Function: ThreeStateLoop_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ThreeStateLoop_shatter_access_main(ThreeStateLoop * mat,int i,int j,int state) { return ThreeStateLoop_SHATTER_MATRIX(mat,i,j,state); } /* Function: ThreeStateLoop_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ThreeStateLoop_shatter_access_special(ThreeStateLoop * mat,int i,int j,int state) { return ThreeStateLoop_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_ThreeStateLoop(mat,dpenv) * * Descrip: This function calculates the ThreeStateLoop matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [ThreeStateLoop *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_ThreeStateLoop(ThreeStateLoop * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,3); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("ThreeStateLoop Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_1[MATCH] + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = SIG_1_1[INSERT] + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_1[DELETE] + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = ThreeStateLoop_SHATTER_SPECIAL(mat,i-1,j-1,LOOP) + mat->query->unit[i]->trans[TSM_START2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; SIG_0_0[MATCH] = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_MATCH2END]) + (0) ; if( temp > ThreeStateLoop_SHATTER_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_1[MATCH] + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_1[DELETE] + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = ThreeStateLoop_SHATTER_SPECIAL(mat,i-0,j-1,LOOP) + mat->query->unit[i]->trans[TSM_START2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; SIG_0_0[INSERT] = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_INSERT2END]) + (0) ; if( temp > ThreeStateLoop_SHATTER_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = ThreeStateLoop_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->trans[TSM_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_DELETE2END]) + (0) ; if( temp > ThreeStateLoop_SHATTER_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = ThreeStateLoop_SHATTER_SPECIAL(mat,0,j,LOOP); /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = ThreeStateLoop_SHATTER_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Source START is a special source for LOOP */ temp = ThreeStateLoop_SHATTER_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ ThreeStateLoop_SHATTER_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = ThreeStateLoop_SHATTER_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ temp = ThreeStateLoop_SHATTER_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ ThreeStateLoop_SHATTER_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: search_ThreeStateLoop(dbsi,out,query,targetdb) * * Descrip: This function makes a database search of ThreeStateLoop * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ThreeStateScore*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_ThreeStateLoop(DBSearchImpl * dbsi,Hscore * out,ThreeStateScore* query,ProteinDB* targetdb ) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_ThreeStateLoop * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_ThreeStateLoop. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_ThreeStateLoop. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for ThreeStateLoop, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_ThreeStateLoop(out,query, targetdb ); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_ThreeStateLoop *) ckalloc(sizeof(struct thread_pool_holder_ThreeStateLoop)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->query = query; holder->targetdb = targetdb; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_ThreeStateLoop,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for ThreeStateLoop"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from ThreeStateLoop",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_ThreeStateLoop(ptr) * * Descrip: dummy loop code foreach thread for ThreeStateLoop * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * thread_loop_ThreeStateLoop(void * ptr) { fatal("dummy thread loop function"); } /* Function: serial_search_ThreeStateLoop(out,query,targetdb) * * Descrip: This function makes a database search of ThreeStateLoop * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ThreeStateScore*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_ThreeStateLoop(Hscore * out,ThreeStateScore* query,ProteinDB* targetdb ) { ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; target = init_ProteinDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching ThreeStateLoop, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_ThreeStateLoop(query, target ); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("ThreeStateLoop search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_ProteinDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_ProteinDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching ThreeStateLoop, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break; /* Out of target loop */ target_pos++; } /* end of For all target entries */ close_ProteinDB(target,targetdb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_ThreeStateLoop(query,target) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_ThreeStateLoop_only * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_ThreeStateLoop(ThreeStateScore* query,ComplexSequence* target ) { int bestscore = NEGI; int i; int j; int k; ThreeStateLoop * mat; mat = allocate_ThreeStateLoop_only(query, target ); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 3,2,3)) == NULL) { warn("Score only matrix for ThreeStateLoop cannot be allocated, (asking for 1 by %d cells)",mat->leni*3); mat = free_ThreeStateLoop(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) ThreeStateLoop_VSMALL_MATRIX(mat,i,j,k) = NEGI; } ThreeStateLoop_VSMALL_SPECIAL(mat,i,j,START) = 0; ThreeStateLoop_VSMALL_SPECIAL(mat,i,j,LOOP) = NEGI; ThreeStateLoop_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = ThreeStateLoop_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = ThreeStateLoop_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ThreeStateLoop_VSMALL_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = ThreeStateLoop_VSMALL_SPECIAL(mat,i-1,j-1,LOOP) + mat->query->unit[i]->trans[TSM_START2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_MATCH2END]) + (0) ; if( temp > ThreeStateLoop_VSMALL_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateLoop_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = ThreeStateLoop_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = ThreeStateLoop_VSMALL_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = ThreeStateLoop_VSMALL_SPECIAL(mat,i-0,j-1,LOOP) + mat->query->unit[i]->trans[TSM_START2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_INSERT2END]) + (0) ; if( temp > ThreeStateLoop_VSMALL_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateLoop_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = ThreeStateLoop_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = ThreeStateLoop_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = ThreeStateLoop_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->trans[TSM_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ThreeStateLoop_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_DELETE2END]) + (0) ; if( temp > ThreeStateLoop_VSMALL_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state DELETE */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = ThreeStateLoop_VSMALL_SPECIAL(mat,0,j,LOOP); /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = ThreeStateLoop_VSMALL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Source START is a special source for LOOP */ temp = ThreeStateLoop_VSMALL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ ThreeStateLoop_VSMALL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = ThreeStateLoop_VSMALL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ temp = ThreeStateLoop_VSMALL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ ThreeStateLoop_VSMALL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ if( bestscore < ThreeStateLoop_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = ThreeStateLoop_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_ThreeStateLoop(mat); return bestscore; } /* Function: PackAln_bestmemory_ThreeStateLoop(query,target,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_ThreeStateLoop * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_ThreeStateLoop(ThreeStateScore* query,ComplexSequence* target ,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; ThreeStateLoop * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_ThreeStateLoop(query, target ,dpri)) == NULL ) { warn("Unable to allocate large ThreeStateLoop version"); return NULL; } calculate_dpenv_ThreeStateLoop(mat,dpenv); out = PackAln_read_Expl_ThreeStateLoop(mat); } else { mat = allocate_ThreeStateLoop_only(query, target ); calculate_shatter_ThreeStateLoop(mat,dpenv); out = PackAln_read_Shatter_ThreeStateLoop(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_ThreeStateLoop(query, target )) == NULL ) { warn("Unable to allocate small ThreeStateLoop version"); return NULL; } out = PackAln_calculate_Small_ThreeStateLoop(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_ThreeStateLoop(query, target ,dpri)) == NULL ) { warn("Unable to allocate large ThreeStateLoop version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_ThreeStateLoop(mat); out = PackAln_read_Expl_ThreeStateLoop(mat); } } } mat = free_ThreeStateLoop(mat); return out; } /* Function: allocate_ThreeStateLoop_only(query,target) * * Descrip: This function only allocates the ThreeStateLoop structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * * Return [UNKN ] Undocumented return value [ThreeStateLoop *] * */ ThreeStateLoop * allocate_ThreeStateLoop_only(ThreeStateScore* query,ComplexSequence* target ) { ThreeStateLoop * out; if((out= ThreeStateLoop_alloc()) == NULL) { warn("Allocation of basic ThreeStateLoop structure failed..."); return NULL; } out->query = query; out->target = target; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_ThreeStateLoop(query,target,dpri) * * Descrip: This function allocates the ThreeStateLoop structure * and the basematrix area for explicit memory implementations * It calls /allocate_ThreeStateLoop_only * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [ThreeStateLoop *] * */ ThreeStateLoop * allocate_Expl_ThreeStateLoop(ThreeStateScore* query,ComplexSequence* target ,DPRunImpl * dpri) { ThreeStateLoop * out; out = allocate_ThreeStateLoop_only(query, target ); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*3,(out->leni+1),3,out->lenj+1)) == NULL) { warn("Explicit matrix ThreeStateLoop cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_ThreeStateLoop(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_ThreeStateLoop(out); return out; } /* Function: init_ThreeStateLoop(mat) * * Descrip: This function initates ThreeStateLoop matrix when in explicit mode * Called in /allocate_Expl_ThreeStateLoop * * * Arg: mat [UNKN ] ThreeStateLoop which contains explicit basematrix memory [ThreeStateLoop *] * */ void init_ThreeStateLoop(ThreeStateLoop * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-1);j<2;j++) { ThreeStateLoop_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateLoop_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateLoop_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j= (-1);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { ThreeStateLoop_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateLoop_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateLoop_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } ThreeStateLoop_EXPL_SPECIAL(mat,i,j,START) = 0; ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) = NEGI; ThreeStateLoop_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_ThreeStateLoop(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by ThreeStateLoop * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * */ void recalculate_PackAln_ThreeStateLoop(PackAln * pal,ThreeStateLoop * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->query->unit[i]->trans[TSM_MATCH2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = mat->query->unit[i]->trans[TSM_INSERT2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 1 && offj == 1 && prev->state == DELETE ) { pau->score = mat->query->unit[i]->trans[TSM_DELETE2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offj == 1 && prev->state == (LOOP+3) ) { pau->score = mat->query->unit[i]->trans[TSM_START2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = mat->query->unit[i]->trans[TSM_MATCH2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->query->unit[i]->trans[TSM_INSERT2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == DELETE ) { pau->score = mat->query->unit[i]->trans[TSM_DELETE2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offj == 1 && prev->state == (LOOP+3) ) { pau->score = mat->query->unit[i]->trans[TSM_START2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->unit[i]->trans[TSM_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->unit[i]->trans[TSM_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->unit[i]->trans[TSM_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (START+3) ) { pau->score = mat->query->unit[i]->trans[TSM_START2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (LOOP+3) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->unit[i]->trans[TSM_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->unit[i]->trans[TSM_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->unit[i]->trans[TSM_DELETE2END] + (0); continue; } if( offj == 1 && prev->state == (LOOP+3) ) { pau->score = 0 + (0); continue; } if( offj == 1 && prev->state == (START+3) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state LOOP, got a bad source state. Error!"); break; case (END+3) : if( offj == 1 && prev->state == (LOOP+3) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define ThreeStateLoop_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*3+state]) #define ThreeStateLoop_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*3+state]) #define ThreeStateLoop_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define ThreeStateLoop_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define ThreeStateLoop_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*3 + state]) #define ThreeStateLoop_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define ThreeStateLoop_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_ThreeStateLoop(query,target) * * Descrip: This function allocates the ThreeStateLoop structure * and the basematrix area for a small memory implementations * It calls /allocate_ThreeStateLoop_only * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * * Return [UNKN ] Undocumented return value [ThreeStateLoop *] * */ #define ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) ThreeStateLoop * allocate_Small_ThreeStateLoop(ThreeStateScore* query,ComplexSequence* target ) { ThreeStateLoop * out; out = allocate_ThreeStateLoop_only(query, target ); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 3,24,out->lenj+1); if(out == NULL) { warn("Small shadow matrix ThreeStateLoop cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_ThreeStateLoop(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_ThreeStateLoop(mat,dpenv) * * Descrip: This function calculates an alignment for ThreeStateLoop structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_ThreeStateLoop * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_ThreeStateLoop * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_ThreeStateLoop(ThreeStateLoop * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for ThreeStateLoop due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_ThreeStateLoop(mat,dpenv); score = start_end_find_end_ThreeStateLoop(mat,&endj); out->score = score; stopstate = END; /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */ log_full_error(REPORT,0,"End at %d Score %d",endj,score); stop_reporting(); for(;;) { /*while there are more special bits to recover*/ start_reporting("Special cell aln end %d:",endj); if( read_special_strip_ThreeStateLoop(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) { warn("Problem in reading off special state system... going to return partial alignment"); break; } if( startstate == START || endj <= 0) { log_full_error(REPORT,0,"Recovered complete alignment"); stop_reporting(); break; } log_full_error(REPORT,0,"Finished to %d",endj); stop_reporting(); /* Ok... have to eat up another piece of matrix */ temp = startstate; starti = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0); startj = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1); startstate = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2); stopi = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3); stopj = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4); stopstate = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5); /* Get out the score of this block. V. important! */ temp = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6); totalj = stopj - startj; donej = 0; start_reporting("Main matrix aln [%d,%d]:",startj,stopj); if(full_dc_ThreeStateLoop(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) { warn("In the alignment ThreeStateLoop [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj); return out; } /* now have to figure out which special we came from... yikes */ max_matrix_to_special_ThreeStateLoop(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == ThreeStateLoop_READ_OFF_ERROR) { warn("In ThreeStateLoop read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj); invert_PackAln(out); recalculate_PackAln_ThreeStateLoop(out,mat); return out; } /* if at start, break, otherwise, back to eat another strip */ if( stopstate == START) { log_full_error(REPORT,0,"Recovered complete alignment "); stop_reporting(); break; } log_full_error(REPORT,0,"Finished alignment to %d ",startj); stop_reporting(); endj = stopj; /* stopstate is correct as it is */ } /* end of while there are more special bits to recover */ invert_PackAln(out); recalculate_PackAln_ThreeStateLoop(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_ThreeStateLoop(mat) * * Descrip: This function calculates an alignment for ThreeStateLoop structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_ThreeStateLoop * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_ThreeStateLoop * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_ThreeStateLoop * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_ThreeStateLoop(ThreeStateLoop * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_ThreeStateLoop(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_ThreeStateLoop(mat); return out; } /* Function: AlnRangeSet_from_ThreeStateLoop(mat) * * Descrip: This function reads off a start/end structure * for ThreeStateLoop structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_ThreeStateLoop * If you have not calculated the matrix use * /AlnRange_calculate_Small_ThreeStateLoop * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_ThreeStateLoop(ThreeStateLoop * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_ThreeStateLoop"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_ThreeStateLoop(mat,&jpos); state = END; while( (temp = AlnRange_build_ThreeStateLoop(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_ThreeStateLoop(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_ThreeStateLoop * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_ThreeStateLoop(ThreeStateLoop * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_ThreeStateLoop"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_ThreeStateLoop(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_ThreeStateLoop alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = ThreeStateLoop_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_ThreeStateLoop(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == ThreeStateLoop_READ_OFF_ERROR) { warn("In AlnRange_build_ThreeStateLoop alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = ThreeStateLoop_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_ThreeStateLoop(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_ThreeStateLoop(ThreeStateLoop * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_ThreeStateLoop(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == ThreeStateLoop_READ_OFF_ERROR) { warn("In ThreeStateLoop hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In ThreeStateLoop hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In ThreeStateLoop hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_ThreeStateLoop(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_ThreeStateLoop(ThreeStateLoop * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = ThreeStateLoop_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In ThreeStateLoop matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = ThreeStateLoop_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Not allowing special sources.. skipping LOOP */ temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateLoop_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_HIDDEN_MATRIX(mat,i-1,j-1,DELETE); } return ThreeStateLoop_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE); } temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateLoop_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return ThreeStateLoop_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateLoop_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return ThreeStateLoop_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in ThreeStateLoop read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Not allowing special sources.. skipping LOOP */ temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateLoop_HIDDEN_MATRIX(mat,i - 0,j - 1,DELETE) ) { *reti = i - 0; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_HIDDEN_MATRIX(mat,i-0,j-1,DELETE); } return ThreeStateLoop_HIDDEN_MATRIX(mat,i - 0,j - 1,DELETE); } temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateLoop_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return ThreeStateLoop_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateLoop_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return ThreeStateLoop_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in ThreeStateLoop read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2DELETE]) - (0); if( temp == ThreeStateLoop_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return ThreeStateLoop_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2DELETE]) - (0); if( temp == ThreeStateLoop_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return ThreeStateLoop_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2DELETE]) - (0); if( temp == ThreeStateLoop_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return ThreeStateLoop_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in ThreeStateLoop read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in ThreeStateLoop read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_ThreeStateLoop(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_ThreeStateLoop(ThreeStateLoop * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_ThreeStateLoop(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == ThreeStateLoop_READ_OFF_ERROR) { warn("In special strip read ThreeStateLoop, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read ThreeStateLoop, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_ThreeStateLoop(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_ThreeStateLoop(ThreeStateLoop * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = ThreeStateLoop_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for ThreeStateLoop, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In ThreeStateLoop matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = ThreeStateLoop_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case LOOP : /* source START is a special */ temp = cscore - (0) - (0); if( temp == ThreeStateLoop_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return ThreeStateLoop_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == ThreeStateLoop_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_DC_SHADOW_SPECIAL(mat,i-0,j-1,LOOP); } return ThreeStateLoop_DC_SHADOW_MATRIX(mat,i - 0,j - 1,LOOP) ; } /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ case END : /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == ThreeStateLoop_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_DC_SHADOW_SPECIAL(mat,i-0,j-1,LOOP); } return ThreeStateLoop_DC_SHADOW_MATRIX(mat,i - 0,j - 1,LOOP) ; } default: warn("Major problem (!) - in ThreeStateLoop special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_ThreeStateLoop(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_ThreeStateLoop(ThreeStateLoop * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = ThreeStateLoop_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In ThreeStateLoop matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->query->unit[i]->trans[TSM_START2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateLoop_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,LOOP) ) { *reti = i - 1; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_DC_SHADOW_SPECIAL(mat,i-1,j-1,LOOP); } return ThreeStateLoop_DC_SHADOW_MATRIX(mat,i - 1,j - 1,LOOP) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in ThreeStateLoop matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->query->unit[i]->trans[TSM_START2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateLoop_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_DC_SHADOW_SPECIAL(mat,i-0,j-1,LOOP); } return ThreeStateLoop_DC_SHADOW_MATRIX(mat,i - 0,j - 1,LOOP) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in ThreeStateLoop matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->unit[i]->trans[TSM_START2DELETE]) - (0); if( temp == ThreeStateLoop_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateLoop_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return ThreeStateLoop_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in ThreeStateLoop matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in ThreeStateLoop read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_ThreeStateLoop(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_ThreeStateLoop(ThreeStateLoop * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_ThreeStateLoop(mat,starti,startj,stopi,stopj); ThreeStateLoop_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ThreeStateLoop_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateLoop_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateLoop_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = ThreeStateLoop_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = ThreeStateLoop_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ThreeStateLoop_HIDDEN_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateLoop_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = ThreeStateLoop_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = ThreeStateLoop_HIDDEN_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateLoop_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = ThreeStateLoop_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = ThreeStateLoop_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ThreeStateLoop_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } } return; } /* Function: init_hidden_ThreeStateLoop(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_ThreeStateLoop(ThreeStateLoop * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { ThreeStateLoop_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateLoop_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateLoop_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; } } return; } /* Function: full_dc_ThreeStateLoop(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_ThreeStateLoop * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_ThreeStateLoop to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [ThreeStateLoop *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_ThreeStateLoop(ThreeStateLoop * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_ThreeStateLoop"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_ThreeStateLoop(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_ThreeStateLoop(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_ThreeStateLoop(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for ThreeStateLoop, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_ThreeStateLoop(mat,ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_ThreeStateLoop(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_ThreeStateLoop(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_ThreeStateLoop(ThreeStateLoop * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_ThreeStateLoop(mat); ThreeStateLoop_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_ThreeStateLoop(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_ThreeStateLoop(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_ThreeStateLoop(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_ThreeStateLoop(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_ThreeStateLoop(ThreeStateLoop * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; if( j - 1 <= mergej) { ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score) { score = temp; if( j - 1 <= mergej) { ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score) { score = temp; if( j - 1 <= mergej) { ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } } /* Add any movement independant score */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; if( j - 1 <= mergej) { ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score) { score = temp; if( j - 1 <= mergej) { ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score) { score = temp; if( j - 1 <= mergej) { ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,k); } } /* Add any movement independant score */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; if( j - 0 <= mergej) { ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_ThreeStateLoop(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_ThreeStateLoop(ThreeStateLoop * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); /* From state INSERT to state MATCH */ temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* From state DELETE to state MATCH */ temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); /* From state INSERT to state INSERT */ temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* From state DELETE to state INSERT */ temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_ThreeStateLoop(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_ThreeStateLoop(ThreeStateLoop * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = ThreeStateLoop_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_ThreeStateLoop(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * */ } void init_dc_ThreeStateLoop(ThreeStateLoop * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iquery->len;i++) { ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; for(k=0;k<7;k++) { ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); } } } return; } /* Function: start_end_find_end_ThreeStateLoop(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [ThreeStateLoop *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_ThreeStateLoop(ThreeStateLoop * mat,int * endj) { register int j; register int max; register int maxj; max = ThreeStateLoop_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( ThreeStateLoop_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = ThreeStateLoop_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_ThreeStateLoop(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [ThreeStateLoop] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_ThreeStateLoop(ThreeStateLoop *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jquery->unit[i]->trans[TSM_MATCH2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); /* assign local shadown pointer */ localsp = &(ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); /* From state INSERT to state MATCH */ temp = ThreeStateLoop_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH] +(mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* From state DELETE to state MATCH */ temp = ThreeStateLoop_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH] +(mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,0)); } /* From state LOOP to state MATCH */ temp = ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,LOOP) + mat->query->unit[i]->trans[TSM_START2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* This state [LOOP] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ ThreeStateLoop_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_MATCH2END]) + (0) ; if( temp > ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateLoop_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); /* assign local shadown pointer */ localsp = &(ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); /* From state INSERT to state INSERT */ temp = ThreeStateLoop_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT] +(mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* From state DELETE to state INSERT */ temp = ThreeStateLoop_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT] +(mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,0)); } /* From state LOOP to state INSERT */ temp = ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,LOOP) + mat->query->unit[i]->trans[TSM_START2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* This state [LOOP] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ ThreeStateLoop_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_INSERT2END]) + (0) ; if( temp > ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateLoop_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = ThreeStateLoop_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = ThreeStateLoop_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state START to state DELETE */ temp = ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->trans[TSM_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ ThreeStateLoop_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_DELETE2END]) + (0) ; if( temp > ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = ThreeStateLoop_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = DELETE; } /* Finished calculating state DELETE */ } /* end of for each i position in strip */ /* Special state START has no special to special movements */ /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,0,j,LOOP); /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,LOOP,k); } /* Source START is a special source for LOOP */ temp = ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,START,k); } /* Put back score... (now updated!) */ ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ temp = ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = ThreeStateLoop_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,LOOP,k); } /* Put back score... (now updated!) */ ThreeStateLoop_DC_OPT_SHADOW_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_ThreeStateLoop(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * */ void init_start_end_linear_ThreeStateLoop(ThreeStateLoop * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iquery->len;i++) { ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); ThreeStateLoop_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; ThreeStateLoop_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); } } for(j=(-1);jtarget->seq->len;j++) { ThreeStateLoop_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; ThreeStateLoop_DC_SHADOW_SPECIAL(mat,0,j,LOOP) = NEGI; ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,j,LOOP,0) = (-1); ThreeStateLoop_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; ThreeStateLoop_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_ThreeStateLoop(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_ThreeStateLoop(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_ThreeStateLoop(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "SEQUENCE","INSERT","LOOP","END" }; /* Function: AlnConvertSet_ThreeStateLoop(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "SEQUENCE","INSERT","LOOP","END" }; AlnConvertSet * AlnConvertSet_ThreeStateLoop(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 3; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 3; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 3; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[3]; return out; } /* Function: PackAln_read_Expl_ThreeStateLoop(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_ThreeStateLoop(ThreeStateLoop * mat) { ThreeStateLoop_access_func_holder holder; holder.access_main = ThreeStateLoop_explicit_access_main; holder.access_special = ThreeStateLoop_explicit_access_special; return PackAln_read_generic_ThreeStateLoop(mat,holder); } /* Function: ThreeStateLoop_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ThreeStateLoop_explicit_access_main(ThreeStateLoop * mat,int i,int j,int state) { return ThreeStateLoop_EXPL_MATRIX(mat,i,j,state); } /* Function: ThreeStateLoop_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ThreeStateLoop_explicit_access_special(ThreeStateLoop * mat,int i,int j,int state) { return ThreeStateLoop_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_ThreeStateLoop(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: h [UNKN ] Undocumented argument [ThreeStateLoop_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_ThreeStateLoop(ThreeStateLoop * mat,ThreeStateLoop_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_ThreeStateLoop(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in ThreeStateLoop_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_ThreeStateLoop(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_ThreeStateLoop(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == ThreeStateLoop_READ_OFF_ERROR || j == ThreeStateLoop_READ_OFF_ERROR || state == ThreeStateLoop_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in ThreeStateLoop_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_ThreeStateLoop(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [ThreeStateLoop_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_ThreeStateLoop(ThreeStateLoop * mat,int * ri,int * rj,int * state,boolean * isspecial,ThreeStateLoop_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: ThreeStateLoop_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void ThreeStateLoop_debug_show_matrix(ThreeStateLoop * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",ThreeStateLoop_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",ThreeStateLoop_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",ThreeStateLoop_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_ThreeStateLoop(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [ThreeStateLoop_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_ThreeStateLoop(ThreeStateLoop * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ThreeStateLoop_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = ThreeStateLoop_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In ThreeStateLoop matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->query->unit[i]->trans[TSM_START2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 1,j - 1,LOOP) ) { *reti = i - 1; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,LOOP); } return (*h.access_main)(mat,i - 1,j - 1,LOOP); } temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,DELETE); } return (*h.access_main)(mat,i - 1,j - 1,DELETE); } temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in ThreeStateLoop read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->query->unit[i]->trans[TSM_START2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,LOOP); } return (*h.access_main)(mat,i - 0,j - 1,LOOP); } temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,DELETE) ) { *reti = i - 0; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,DELETE); } return (*h.access_main)(mat,i - 0,j - 1,DELETE); } temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in ThreeStateLoop read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->unit[i]->trans[TSM_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in ThreeStateLoop read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in ThreeStateLoop read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_ThreeStateLoop(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [ThreeStateLoop_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_ThreeStateLoop(ThreeStateLoop * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ThreeStateLoop_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = ThreeStateLoop_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In ThreeStateLoop matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case LOOP : /* source START is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_special)(mat,i - 0,j - 1,START) ; } /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,LOOP); } return (*h.access_special)(mat,i - 0,j - 1,LOOP) ; } /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ case END : /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,LOOP); } return (*h.access_special)(mat,i - 0,j - 1,LOOP) ; } default: warn("Major problem (!) - in ThreeStateLoop read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_ThreeStateLoop(mat) * * Descrip: This function calculates the ThreeStateLoop matrix when in explicit mode * To allocate the matrix use /allocate_Expl_ThreeStateLoop * * * Arg: mat [UNKN ] ThreeStateLoop which contains explicit basematrix memory [ThreeStateLoop *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_ThreeStateLoop(ThreeStateLoop * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_ThreeStateLoop, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("ThreeStateLoop Matrix calculation: "); for(j=0;jquery->unit[i]->trans[TSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = ThreeStateLoop_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ThreeStateLoop_EXPL_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = ThreeStateLoop_EXPL_SPECIAL(mat,i-1,j-1,LOOP) + mat->query->unit[i]->trans[TSM_START2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_MATCH2END]) + (0) ; if( temp > ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateLoop_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = ThreeStateLoop_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = ThreeStateLoop_EXPL_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = ThreeStateLoop_EXPL_SPECIAL(mat,i-0,j-1,LOOP) + mat->query->unit[i]->trans[TSM_START2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_INSERT2END]) + (0) ; if( temp > ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateLoop_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = ThreeStateLoop_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = ThreeStateLoop_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = ThreeStateLoop_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->trans[TSM_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ThreeStateLoop_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_DELETE2END]) + (0) ; if( temp > ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = ThreeStateLoop_EXPL_SPECIAL(mat,0,j,LOOP); /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = ThreeStateLoop_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Source START is a special source for LOOP */ temp = ThreeStateLoop_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ ThreeStateLoop_EXPL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = ThreeStateLoop_EXPL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ temp = ThreeStateLoop_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ ThreeStateLoop_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_ThreeStateLoop(mat,dpenv) * * Descrip: This function calculates the ThreeStateLoop matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] ThreeStateLoop which contains explicit basematrix memory [ThreeStateLoop *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_ThreeStateLoop(ThreeStateLoop * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_ThreeStateLoop, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { ThreeStateLoop_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateLoop_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateLoop_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j=-1;jlenj;j++) { ThreeStateLoop_EXPL_SPECIAL(mat,i,j,START) = 0; ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) = NEGI; ThreeStateLoop_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("ThreeStateLoop Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { ThreeStateLoop_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateLoop_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateLoop_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = ThreeStateLoop_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = ThreeStateLoop_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ThreeStateLoop_EXPL_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = ThreeStateLoop_EXPL_SPECIAL(mat,i-1,j-1,LOOP) + mat->query->unit[i]->trans[TSM_START2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_MATCH2END]) + (0) ; if( temp > ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateLoop_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = ThreeStateLoop_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = ThreeStateLoop_EXPL_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = ThreeStateLoop_EXPL_SPECIAL(mat,i-0,j-1,LOOP) + mat->query->unit[i]->trans[TSM_START2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateLoop_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_INSERT2END]) + (0) ; if( temp > ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateLoop_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = ThreeStateLoop_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = ThreeStateLoop_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = ThreeStateLoop_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->trans[TSM_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ThreeStateLoop_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->unit[i]->trans[TSM_DELETE2END]) + (0) ; if( temp > ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) ) { ThreeStateLoop_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = ThreeStateLoop_EXPL_SPECIAL(mat,0,j,LOOP); /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = ThreeStateLoop_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Source START is a special source for LOOP */ temp = ThreeStateLoop_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ ThreeStateLoop_EXPL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = ThreeStateLoop_EXPL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ temp = ThreeStateLoop_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ ThreeStateLoop_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: ThreeStateLoop_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateLoop *] * */ ThreeStateLoop * ThreeStateLoop_alloc(void) { ThreeStateLoop * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ThreeStateLoop *) ckalloc (sizeof(ThreeStateLoop))) == NULL) { warn("ThreeStateLoop_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_ThreeStateLoop(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateLoop *] * * Return [UNKN ] Undocumented return value [ThreeStateLoop *] * */ ThreeStateLoop * free_ThreeStateLoop(ThreeStateLoop * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ThreeStateLoop obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/threestateloop.h0000644000175000001440000004611310670453715017353 0ustar philippusers#ifndef DYNAMITEthreestateloopHEADERFILE #define DYNAMITEthreestateloopHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "threestatemodel.h" struct Wise2_ThreeStateLoop { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; ThreeStateScore* query; ComplexSequence* target; } ; /* ThreeStateLoop defined */ #ifndef DYNAMITE_DEFINED_ThreeStateLoop typedef struct Wise2_ThreeStateLoop Wise2_ThreeStateLoop; #define ThreeStateLoop Wise2_ThreeStateLoop #define DYNAMITE_DEFINED_ThreeStateLoop #endif #ifdef PTHREAD struct thread_pool_holder_ThreeStateLoop { ThreeStateScore* query; /* Static query data: never free'd */ ComplexSequence* target;/* Target object placeholder */ ProteinDB* targetdb;/* Target database object */ boolean target_init; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_ThreeStateLoop_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(ThreeStateLoop*,int,int,int); int (*access_special)(ThreeStateLoop*,int,int,int); } ; /* ThreeStateLoop_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_ThreeStateLoop_access_func_holder typedef struct Wise2_ThreeStateLoop_access_func_holder Wise2_ThreeStateLoop_access_func_holder; #define ThreeStateLoop_access_func_holder Wise2_ThreeStateLoop_access_func_holder #define DYNAMITE_DEFINED_ThreeStateLoop_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_ThreeStateLoop(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_ThreeStateLoop(ThreeStateLoop * mat); #define PackAln_read_Shatter_ThreeStateLoop Wise2_PackAln_read_Shatter_ThreeStateLoop /* Function: calculate_shatter_ThreeStateLoop(mat,dpenv) * * Descrip: This function calculates the ThreeStateLoop matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [ThreeStateLoop *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_ThreeStateLoop(ThreeStateLoop * mat,DPEnvelope * dpenv); #define calculate_shatter_ThreeStateLoop Wise2_calculate_shatter_ThreeStateLoop /* Function: search_ThreeStateLoop(dbsi,out,query,targetdb) * * Descrip: This function makes a database search of ThreeStateLoop * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ThreeStateScore*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_ThreeStateLoop(DBSearchImpl * dbsi,Hscore * out,ThreeStateScore* query,ProteinDB* targetdb ); #define search_ThreeStateLoop Wise2_search_ThreeStateLoop /* Function: serial_search_ThreeStateLoop(out,query,targetdb) * * Descrip: This function makes a database search of ThreeStateLoop * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ThreeStateScore*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_ThreeStateLoop(Hscore * out,ThreeStateScore* query,ProteinDB* targetdb ); #define serial_search_ThreeStateLoop Wise2_serial_search_ThreeStateLoop /* Function: PackAln_bestmemory_ThreeStateLoop(query,target,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_ThreeStateLoop * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_ThreeStateLoop(ThreeStateScore* query,ComplexSequence* target ,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_ThreeStateLoop Wise2_PackAln_bestmemory_ThreeStateLoop /* Function: allocate_Expl_ThreeStateLoop(query,target,dpri) * * Descrip: This function allocates the ThreeStateLoop structure * and the basematrix area for explicit memory implementations * It calls /allocate_ThreeStateLoop_only * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [ThreeStateLoop *] * */ ThreeStateLoop * Wise2_allocate_Expl_ThreeStateLoop(ThreeStateScore* query,ComplexSequence* target ,DPRunImpl * dpri); #define allocate_Expl_ThreeStateLoop Wise2_allocate_Expl_ThreeStateLoop /* Function: recalculate_PackAln_ThreeStateLoop(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by ThreeStateLoop * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * */ void Wise2_recalculate_PackAln_ThreeStateLoop(PackAln * pal,ThreeStateLoop * mat); #define recalculate_PackAln_ThreeStateLoop Wise2_recalculate_PackAln_ThreeStateLoop /* Function: allocate_Small_ThreeStateLoop(query,target) * * Descrip: This function allocates the ThreeStateLoop structure * and the basematrix area for a small memory implementations * It calls /allocate_ThreeStateLoop_only * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * * Return [UNKN ] Undocumented return value [ThreeStateLoop *] * */ ThreeStateLoop * Wise2_allocate_Small_ThreeStateLoop(ThreeStateScore* query,ComplexSequence* target ); #define allocate_Small_ThreeStateLoop Wise2_allocate_Small_ThreeStateLoop /* Function: PackAln_calculate_Small_ThreeStateLoop(mat,dpenv) * * Descrip: This function calculates an alignment for ThreeStateLoop structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_ThreeStateLoop * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_ThreeStateLoop * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_ThreeStateLoop(ThreeStateLoop * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_ThreeStateLoop Wise2_PackAln_calculate_Small_ThreeStateLoop /* Function: AlnRangeSet_calculate_Small_ThreeStateLoop(mat) * * Descrip: This function calculates an alignment for ThreeStateLoop structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_ThreeStateLoop * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_ThreeStateLoop * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_ThreeStateLoop * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_ThreeStateLoop(ThreeStateLoop * mat); #define AlnRangeSet_calculate_Small_ThreeStateLoop Wise2_AlnRangeSet_calculate_Small_ThreeStateLoop /* Function: AlnRangeSet_from_ThreeStateLoop(mat) * * Descrip: This function reads off a start/end structure * for ThreeStateLoop structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_ThreeStateLoop * If you have not calculated the matrix use * /AlnRange_calculate_Small_ThreeStateLoop * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_ThreeStateLoop(ThreeStateLoop * mat); #define AlnRangeSet_from_ThreeStateLoop Wise2_AlnRangeSet_from_ThreeStateLoop /* Function: convert_PackAln_to_AlnBlock_ThreeStateLoop(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_ThreeStateLoop(PackAln * pal); #define convert_PackAln_to_AlnBlock_ThreeStateLoop Wise2_convert_PackAln_to_AlnBlock_ThreeStateLoop /* Function: PackAln_read_Expl_ThreeStateLoop(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_ThreeStateLoop(ThreeStateLoop * mat); #define PackAln_read_Expl_ThreeStateLoop Wise2_PackAln_read_Expl_ThreeStateLoop /* Function: PackAln_read_generic_ThreeStateLoop(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateLoop *] * Arg: h [UNKN ] Undocumented argument [ThreeStateLoop_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_ThreeStateLoop(ThreeStateLoop * mat,ThreeStateLoop_access_func_holder h); #define PackAln_read_generic_ThreeStateLoop Wise2_PackAln_read_generic_ThreeStateLoop /* Function: calculate_ThreeStateLoop(mat) * * Descrip: This function calculates the ThreeStateLoop matrix when in explicit mode * To allocate the matrix use /allocate_Expl_ThreeStateLoop * * * Arg: mat [UNKN ] ThreeStateLoop which contains explicit basematrix memory [ThreeStateLoop *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_ThreeStateLoop(ThreeStateLoop * mat); #define calculate_ThreeStateLoop Wise2_calculate_ThreeStateLoop /* Function: calculate_dpenv_ThreeStateLoop(mat,dpenv) * * Descrip: This function calculates the ThreeStateLoop matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] ThreeStateLoop which contains explicit basematrix memory [ThreeStateLoop *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_ThreeStateLoop(ThreeStateLoop * mat,DPEnvelope * dpenv); #define calculate_dpenv_ThreeStateLoop Wise2_calculate_dpenv_ThreeStateLoop /* Function: ThreeStateLoop_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateLoop *] * */ ThreeStateLoop * Wise2_ThreeStateLoop_alloc(void); #define ThreeStateLoop_alloc Wise2_ThreeStateLoop_alloc /* Function: free_ThreeStateLoop(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateLoop *] * * Return [UNKN ] Undocumented return value [ThreeStateLoop *] * */ ThreeStateLoop * Wise2_free_ThreeStateLoop(ThreeStateLoop * obj); #define free_ThreeStateLoop Wise2_free_ThreeStateLoop /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_ThreeStateLoop_shatter_access_main(ThreeStateLoop * mat,int i,int j,int state); #define ThreeStateLoop_shatter_access_main Wise2_ThreeStateLoop_shatter_access_main int Wise2_ThreeStateLoop_shatter_access_special(ThreeStateLoop * mat,int i,int j,int state); #define ThreeStateLoop_shatter_access_special Wise2_ThreeStateLoop_shatter_access_special void * Wise2_thread_loop_ThreeStateLoop(void * ptr); #define thread_loop_ThreeStateLoop Wise2_thread_loop_ThreeStateLoop int Wise2_score_only_ThreeStateLoop(ThreeStateScore* query,ComplexSequence* target ); #define score_only_ThreeStateLoop Wise2_score_only_ThreeStateLoop ThreeStateLoop * Wise2_allocate_ThreeStateLoop_only(ThreeStateScore* query,ComplexSequence* target ); #define allocate_ThreeStateLoop_only Wise2_allocate_ThreeStateLoop_only void Wise2_init_ThreeStateLoop(ThreeStateLoop * mat); #define init_ThreeStateLoop Wise2_init_ThreeStateLoop AlnRange * Wise2_AlnRange_build_ThreeStateLoop(ThreeStateLoop * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_ThreeStateLoop Wise2_AlnRange_build_ThreeStateLoop boolean Wise2_read_hidden_ThreeStateLoop(ThreeStateLoop * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_ThreeStateLoop Wise2_read_hidden_ThreeStateLoop int Wise2_max_hidden_ThreeStateLoop(ThreeStateLoop * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_ThreeStateLoop Wise2_max_hidden_ThreeStateLoop boolean Wise2_read_special_strip_ThreeStateLoop(ThreeStateLoop * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_ThreeStateLoop Wise2_read_special_strip_ThreeStateLoop int Wise2_max_special_strip_ThreeStateLoop(ThreeStateLoop * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_ThreeStateLoop Wise2_max_special_strip_ThreeStateLoop int Wise2_max_matrix_to_special_ThreeStateLoop(ThreeStateLoop * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_ThreeStateLoop Wise2_max_matrix_to_special_ThreeStateLoop void Wise2_calculate_hidden_ThreeStateLoop(ThreeStateLoop * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_ThreeStateLoop Wise2_calculate_hidden_ThreeStateLoop void Wise2_init_hidden_ThreeStateLoop(ThreeStateLoop * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_ThreeStateLoop Wise2_init_hidden_ThreeStateLoop boolean Wise2_full_dc_ThreeStateLoop(ThreeStateLoop * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_ThreeStateLoop Wise2_full_dc_ThreeStateLoop boolean Wise2_do_dc_single_pass_ThreeStateLoop(ThreeStateLoop * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_ThreeStateLoop Wise2_do_dc_single_pass_ThreeStateLoop void Wise2_push_dc_at_merge_ThreeStateLoop(ThreeStateLoop * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_ThreeStateLoop Wise2_push_dc_at_merge_ThreeStateLoop void Wise2_follow_on_dc_ThreeStateLoop(ThreeStateLoop * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_ThreeStateLoop Wise2_follow_on_dc_ThreeStateLoop void Wise2_run_up_dc_ThreeStateLoop(ThreeStateLoop * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_ThreeStateLoop Wise2_run_up_dc_ThreeStateLoop void Wise2_init_dc_ThreeStateLoop(ThreeStateLoop * mat); #define init_dc_ThreeStateLoop Wise2_init_dc_ThreeStateLoop int Wise2_start_end_find_end_ThreeStateLoop(ThreeStateLoop * mat,int * endj); #define start_end_find_end_ThreeStateLoop Wise2_start_end_find_end_ThreeStateLoop boolean Wise2_dc_optimised_start_end_calc_ThreeStateLoop(ThreeStateLoop *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_ThreeStateLoop Wise2_dc_optimised_start_end_calc_ThreeStateLoop void Wise2_init_start_end_linear_ThreeStateLoop(ThreeStateLoop * mat); #define init_start_end_linear_ThreeStateLoop Wise2_init_start_end_linear_ThreeStateLoop AlnConvertSet * Wise2_AlnConvertSet_ThreeStateLoop(void); #define AlnConvertSet_ThreeStateLoop Wise2_AlnConvertSet_ThreeStateLoop int Wise2_ThreeStateLoop_explicit_access_main(ThreeStateLoop * mat,int i,int j,int state); #define ThreeStateLoop_explicit_access_main Wise2_ThreeStateLoop_explicit_access_main int Wise2_ThreeStateLoop_explicit_access_special(ThreeStateLoop * mat,int i,int j,int state); #define ThreeStateLoop_explicit_access_special Wise2_ThreeStateLoop_explicit_access_special int Wise2_find_end_ThreeStateLoop(ThreeStateLoop * mat,int * ri,int * rj,int * state,boolean * isspecial,ThreeStateLoop_access_func_holder h); #define find_end_ThreeStateLoop Wise2_find_end_ThreeStateLoop void Wise2_ThreeStateLoop_debug_show_matrix(ThreeStateLoop * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define ThreeStateLoop_debug_show_matrix Wise2_ThreeStateLoop_debug_show_matrix int Wise2_max_calc_ThreeStateLoop(ThreeStateLoop * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ThreeStateLoop_access_func_holder h); #define max_calc_ThreeStateLoop Wise2_max_calc_ThreeStateLoop int Wise2_max_calc_special_ThreeStateLoop(ThreeStateLoop * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ThreeStateLoop_access_func_holder h); #define max_calc_special_ThreeStateLoop Wise2_max_calc_special_ThreeStateLoop #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/gwlitemodel.dy0000644000175000001440000001366307313404546017014 0ustar philippusers %{ #include "dyna.h" #include "genewisemodel.h" #define GwLiteScoreLISTLENGTH 128 #define GwLiteLISTLENGTH 128 enum GwLiteTransition { GWL_MATCH2MATCH, GWL_MATCH2INSERT, GWL_MATCH2DELETE, GWL_MATCH2END, GWL_INSERT2MATCH, GWL_INSERT2INSERT, GWL_INSERT2DELETE, GWL_INSERT2END, GWL_DELETE2MATCH, GWL_DELETE2INSERT, GWL_DELETE2DELETE, GWL_DELETE2END, GWL_START2MATCH, GWL_START2INSERT, GWL_START2DELETE, GWL_TRANSITION_LEN }; #define GWL_EMISSION_LEN 65 %} struct GwLiteSegment Probability match[GWL_EMISSION_LEN] Probability insert[GWL_EMISSION_LEN] Probability transition[GWL_TRANSITION_LEN] %info This is a particular HMM node, with match and insert emissions in the codon space and the transitions for the genewise light model %% struct GwLite GwLiteSegment ** seg !list char * name %info This is the lightweight version of GeneWise designed for faster executation and better portability to hardware environments %% struct GwLiteSegmentScore Score match[GWL_EMISSION_LEN] Score insert[GWL_EMISSION_LEN] Score transition[GWL_TRANSITION_LEN] %info This is the genewise lite scoring data structure %% struct GwLiteScore GwLiteSegmentScore ** seg !list char * name %info This is the lightweight version of GeneWise designed for faster executation and better portability to hardware environments %% %{ #include "gwlitemodel.h" %func A pretty weird function. Takes an AlnBlock made by GwLite and performs the necessary surgery at the 3SS to make it look like the AlnBlocks produced by the other genewise models. This means it has to eat into the intron by 3 residues %% void GwLite_AlnBlock_surgery(AlnBlock * alb) { AlnColumn * alc; for(alc = alb->start;alc != NULL;alc = alc->next ) { if( strstartcmp(alc->alu[1]->text_label,"3SS") == 0 ) { alc->alu[1]->start -= 3; } } } %func Builds a GwLite model from the GeneWise model %% GwLite * GwLite_from_GeneWise(GeneWise * gwm) { GwLite * out; GwLiteSegment * seg; int i,c,codon125; out = GwLite_alloc_len(gwm->len); for(i=0;ilen;i++) { seg = GwLiteSegment_alloc(); for(c=0;c<64;c++) { codon125 = codon_from_base4_codon(c); seg->match[c]= gwm->seg[i]->match[codon125]; seg->insert[c]= gwm->seg[i]->insert[codon125]; } seg->transition[GWL_MATCH2MATCH] = gwm->seg[i]->transition[GW_MATCH2MATCH]; seg->transition[GWL_MATCH2INSERT] = gwm->seg[i]->transition[GW_MATCH2INSERT]; seg->transition[GWL_MATCH2DELETE] = gwm->seg[i]->transition[GW_MATCH2DELETE]; seg->transition[GWL_MATCH2END] = gwm->seg[i]->transition[GW_MATCH2END]; seg->transition[GWL_INSERT2MATCH] = gwm->seg[i]->transition[GW_INSERT2MATCH]; seg->transition[GWL_INSERT2INSERT] = gwm->seg[i]->transition[GW_INSERT2INSERT]; seg->transition[GWL_INSERT2DELETE] = gwm->seg[i]->transition[GW_INSERT2DELETE]; seg->transition[GWL_INSERT2END] = gwm->seg[i]->transition[GW_INSERT2END]; seg->transition[GWL_DELETE2MATCH] = gwm->seg[i]->transition[GW_DELETE2MATCH]; seg->transition[GWL_DELETE2INSERT] = gwm->seg[i]->transition[GW_DELETE2INSERT]; seg->transition[GWL_DELETE2DELETE] = gwm->seg[i]->transition[GW_DELETE2DELETE]; seg->transition[GWL_DELETE2END] = gwm->seg[i]->transition[GW_DELETE2END]; seg->transition[GWL_START2MATCH] = gwm->seg[i]->transition[GW_START2MATCH]; seg->transition[GWL_START2INSERT] = gwm->seg[i]->transition[GW_START2INSERT]; seg->transition[GWL_START2DELETE] = gwm->seg[i]->transition[GW_START2DELETE]; add_GwLite(out,seg); } out->name = stringalloc(gwm->name); return out; } %func Makes a lite score from a lite probability basis %% GwLiteScore * GwLiteScore_from_GwLite(GwLite * gwl) { GwLiteScore * out; GwLiteSegment * prev; int i; out = GwLiteScore_alloc_len(gwl->len); for(i=0,prev=NULL;ilen;i++) { add_GwLiteScore(out,GwLiteSegmentScore_from_GwLiteSegment(prev,gwl->seg[i])); prev = gwl->seg[i]; } out->name = stringalloc(gwl->name); return out; } GwLiteSegmentScore * GwLiteSegmentScore_from_GwLiteSegment(GwLiteSegment *prev,GwLiteSegment * seg) { GwLiteSegmentScore * out; out = GwLiteSegmentScore_alloc(); Probability2Score_move(seg->match,out->match,GWL_EMISSION_LEN); Probability2Score_move(seg->insert,out->insert,GWL_EMISSION_LEN); if( prev != NULL ) { out->transition[GWL_MATCH2MATCH] = Probability2Score(prev->transition[GWL_MATCH2MATCH]); out->transition[GWL_INSERT2MATCH] = Probability2Score(prev->transition[GWL_INSERT2MATCH]); out->transition[GWL_DELETE2MATCH] = Probability2Score(prev->transition[GWL_DELETE2MATCH]); out->transition[GWL_MATCH2DELETE] = Probability2Score(prev->transition[GWL_MATCH2DELETE]); out->transition[GWL_INSERT2DELETE] = Probability2Score(prev->transition[GWL_INSERT2DELETE]); out->transition[GWL_DELETE2DELETE] = Probability2Score(prev->transition[GWL_DELETE2DELETE]); } else { out->transition[GWL_MATCH2MATCH] = NEGI; out->transition[GWL_INSERT2MATCH] = NEGI; out->transition[GWL_DELETE2MATCH] = NEGI; out->transition[GWL_MATCH2DELETE] = NEGI; out->transition[GWL_INSERT2DELETE] = NEGI; out->transition[GWL_DELETE2DELETE] = NEGI; } out->transition[GWL_MATCH2INSERT] = Probability2Score(seg->transition[GWL_MATCH2INSERT]); out->transition[GWL_INSERT2INSERT] = Probability2Score(seg->transition[GWL_INSERT2INSERT]); out->transition[GWL_DELETE2INSERT] = Probability2Score(seg->transition[GWL_DELETE2INSERT]); out->transition[GWL_START2MATCH] = Probability2Score(seg->transition[GWL_START2MATCH]); out->transition[GWL_START2INSERT] = Probability2Score(seg->transition[GWL_START2INSERT]); out->transition[GWL_START2DELETE] = Probability2Score(seg->transition[GWL_START2DELETE]); out->transition[GWL_MATCH2END] = Probability2Score(seg->transition[GWL_MATCH2END]); out->transition[GWL_INSERT2END] = Probability2Score(seg->transition[GWL_INSERT2END]); out->transition[GWL_DELETE2END] = Probability2Score(seg->transition[GWL_DELETE2END]); return out; } %} wise-2.4.1/src/models/dnamatcher.c0000644000175000001440000001164510670453713016412 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dnamatcher.h" # line 20 "dnamatcher.dy" void show_help_DnaMatchPara(FILE * ofp) { fprintf(ofp,"Dna Matching Parameters\n"); fprintf(ofp," -dm_match [5] match score\n"); fprintf(ofp," -dm_mismatch [-4] mismatch score\n"); fprintf(ofp," -dm_gappen [5] gap open penalty\n"); fprintf(ofp," -dm_extpen [1] gap extension penalty\n"); show_help_DPRunImpl(ofp); } # line 31 "dnamatcher.dy" DnaMatchPara * new_DnaMatchPara_from_argv(int * argc,char ** argv) { DnaMatchPara * out; int match = 5; int mismatch = -10; out = DnaMatchPara_alloc(); strip_out_integer_argument(argc,argv,"dm_match",&match); strip_out_integer_argument(argc,argv,"dm_mismatch",&mismatch); assert(mismatch < 0 ); out->dpri = new_DPRunImpl_from_argv(argc,argv); out->mat = identity_DnaMatrix(match,mismatch); out->dse = DnaStartEnd_from_policy("local"); out->gap = 30; out->ext = 20; strip_out_integer_argument(argc,argv,"dm_gappen",&out->gap); strip_out_integer_argument(argc,argv,"dm_extpen",&out->ext); return out; } # line 59 "dnamatcher.dy" HitList * HitList_from_Sequence_SequenceSet_DNA(Sequence * query,SequenceSet * set,DnaMatchPara * p) { int i; HitList * out; HitPair * pair; HitAln * aln; AlnBlock * forward; AlnBlock * reverse; Sequence * rev; char buffer[512]; out = HitList_alloc_std(); for(i=0;ilen;i++) { rev = reverse_complement_Sequence(set->set[i]); ckfree(rev->name); sprintf(buffer,"%s.reverse",set->set[i]->name); rev->name = stringalloc(buffer); pair = HitPair_alloc_std(); aln = HitAln_alloc(); forward = make_align_dnaalign(query,set->set[i],p->mat,p->dse,-p->gap,-p->ext,-p->gap,-p->ext,p->dpri); reverse = make_align_dnaalign(query,rev,p->mat,p->dse,-p->gap,-p->ext,-p->gap,-p->ext,p->dpri); if( forward->score > reverse->score ) { pair->query = hard_link_Sequence(query); pair->target = hard_link_Sequence(set->set[i]); aln->alb = hard_link_AlnBlock(forward); } else { pair->query = hard_link_Sequence(query); pair->target = hard_link_Sequence(rev); aln->alb = hard_link_AlnBlock(reverse); } add_HitPair(pair,aln); aln->raw_score = pair->raw_score = aln->alb->score; add_HitList(out,pair); free_AlnBlock(forward); free_AlnBlock(reverse); free_Sequence(rev); } return out; } # line 106 "dnamatcher.c" /* Function: hard_link_DnaMatchPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaMatchPara *] * * Return [UNKN ] Undocumented return value [DnaMatchPara *] * */ DnaMatchPara * hard_link_DnaMatchPara(DnaMatchPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaMatchPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaMatchPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaMatchPara *] * */ DnaMatchPara * DnaMatchPara_alloc(void) { DnaMatchPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaMatchPara *) ckalloc (sizeof(DnaMatchPara))) == NULL) { warn("DnaMatchPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->dpri = NULL; out->mat = NULL; out->dse = NULL; out->gap = 0; out->ext = 0; return out; } /* Function: free_DnaMatchPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaMatchPara *] * * Return [UNKN ] Undocumented return value [DnaMatchPara *] * */ DnaMatchPara * free_DnaMatchPara(DnaMatchPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaMatchPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->dpri != NULL) free_DPRunImpl(obj->dpri); if( obj->mat != NULL) free_DnaMatrix(obj->mat); if( obj->dse != NULL) free_DnaStartEnd(obj->dse); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/dnamatcher.h0000644000175000001440000000536410670453713016420 0ustar philippusers#ifndef DYNAMITEdnamatcherHEADERFILE #define DYNAMITEdnamatcherHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dnaalign.h" #include "hitlist.h" struct Wise2_DnaMatchPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DPRunImpl * dpri; DnaMatrix * mat; DnaStartEnd * dse; int gap; int ext; } ; /* DnaMatchPara defined */ #ifndef DYNAMITE_DEFINED_DnaMatchPara typedef struct Wise2_DnaMatchPara Wise2_DnaMatchPara; #define DnaMatchPara Wise2_DnaMatchPara #define DYNAMITE_DEFINED_DnaMatchPara #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_DnaMatchPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaMatchPara *] * * Return [UNKN ] Undocumented return value [DnaMatchPara *] * */ DnaMatchPara * Wise2_hard_link_DnaMatchPara(DnaMatchPara * obj); #define hard_link_DnaMatchPara Wise2_hard_link_DnaMatchPara /* Function: DnaMatchPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaMatchPara *] * */ DnaMatchPara * Wise2_DnaMatchPara_alloc(void); #define DnaMatchPara_alloc Wise2_DnaMatchPara_alloc /* Function: free_DnaMatchPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaMatchPara *] * * Return [UNKN ] Undocumented return value [DnaMatchPara *] * */ DnaMatchPara * Wise2_free_DnaMatchPara(DnaMatchPara * obj); #define free_DnaMatchPara Wise2_free_DnaMatchPara /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_show_help_DnaMatchPara(FILE * ofp); #define show_help_DnaMatchPara Wise2_show_help_DnaMatchPara DnaMatchPara * Wise2_new_DnaMatchPara_from_argv(int * argc,char ** argv); #define new_DnaMatchPara_from_argv Wise2_new_DnaMatchPara_from_argv HitList * Wise2_HitList_from_Sequence_SequenceSet_DNA(Sequence * query,SequenceSet * set,DnaMatchPara * p); #define HitList_from_Sequence_SequenceSet_DNA Wise2_HitList_from_Sequence_SequenceSet_DNA /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/makeseqerror.c0000644000175000001440000000141307313404547016775 0ustar philippusers#include "seqerror.h" int main(int argc,char ** argv) { Sequence * seq; ErrorSequence * eseq; int i; boolean just_fasta = FALSE; int number = 10; Probability error = 0.01; if( strip_out_boolean_argument(&argc,argv,"fasta") ) { just_fasta = TRUE; } strip_out_integer_argument(&argc,argv,"no",&number); strip_out_float_argument(&argc,argv,"error",&error); seq = read_fasta_file_Sequence(argv[1]); for(i=0;iseq,stdout); } else { show_SequenceErrorSet(eseq->ses,stdout); printf("#\n"); write_fasta_Sequence(eseq->seq,stdout); printf("//\n"); } free_ErrorSequence(eseq); } return 0; } wise-2.4.1/src/models/transregion.dy0000644000175000001440000002134310011413470017006 0ustar philippusers %{ #include "transfactor.h" #include "transregiondp.h" #define TransFactorRegionLISTLENGTH 128 #define TransFactorRegionSetLISTLENGTH 128 #define TRANSREGION_PARA_DP 93 #define TRANSREGION_PARA_WINDOW 94 %} struct TransFactorRegion int start int end TransFactorMatch ** match !list double density double bits_score struct TransFactorRegionSet TransFactorRegion ** region !list Sequence * target struct TransFactorRegionPara int type !def="TRANSREGION_PARA_DP" double min_density !def="0.3" int min_window !def="60" double in_region_prob !def="0.35" double out_region_prob !def="0.2" double in_cost !def="0.000001" int hmm_min_window !def="60" double gc_region_ratio !def="1.5" %{ #include "transregion.h" void show_help_TransFactorRegionPara(FILE * ofp) { fprintf(ofp,"TransFactor Region parameters\n"); fprintf(ofp," -tf_convert [hmm/window] use HMM or window for conversion, default HMM\n"); fprintf(ofp," -tf_density [0.2] minimum density of bases in a cluster for window\n"); fprintf(ofp," -tf_window [60] minimum window size of region\n"); fprintf(ofp," -tf_inprob [0.35] probability of a covered base in a region for HMM\n"); fprintf(ofp," -tf_outprob [0.2] probability of a covered base outside a region for HMM\n"); fprintf(ofp," -tf_entry [0.000001] probablity of entering a region\n"); fprintf(ofp," -tf_hmm_window [60] minimum window for HMM\n"); fprintf(ofp," -tf_gc_region [1.5] Expected ration of GC dinucleotides in regions vs out\n"); return; } TransFactorRegionPara * new_TransFactorRegionPara_from_argv(int * argc,char ** argv) { TransFactorRegionPara * out; char * temp; out = TransFactorRegionPara_alloc(); temp = strip_out_assigned_argument(argc,argv,"tf_convert"); if( temp != NULL ) { if( strcmp(temp,"window") == 0 ) { out->type = TRANSREGION_PARA_WINDOW; } else if ( strcmp(temp,"hmm") == 0 ) { out->type = TRANSREGION_PARA_DP; } else { fatal("Could not interpret %s for tf_convert string",temp); } } strip_out_float_argument(argc,argv,"tf_density",&out->min_density); strip_out_integer_argument(argc,argv,"tf_window",&out->min_window); strip_out_integer_argument(argc,argv,"tf_hmm_window",&out->hmm_min_window); strip_out_float_argument(argc,argv,"tf_inprob",&out->in_region_prob); strip_out_float_argument(argc,argv,"tf_outprob",&out->out_region_prob); strip_out_float_argument(argc,argv,"tf_entry",&out->in_cost); strip_out_float_argument(argc,argv,"tf_gc_region",&out->gc_region_ratio); return out; } void show_TransFactorRegionSet(TransFactorRegionSet * tfrs,FILE * ofp) { int i; int j; Sequence * temp; for(i=0;ilen;i++) { fprintf(ofp,"Region\t%s\t%d\t%d\t%.2f\t%.2f\n",tfrs->target->name,tfrs->region[i]->start+1,tfrs->region[i]->end,tfrs->region[i]->density,tfrs->region[i]->bits_score); fprintf(ofp,"motif\n"); for(j=0;jregion[i]->len;j++) { auto TransFactorMatch * tfm = tfrs->region[i]->match[j]; fprintf(ofp,"Motif\t%s\t%d\t%d\t%d\t%s\t%.2f\t%.*s\n",tfrs->target->name,tfm->start+1,tfm->end,tfm->strand,tfm->factor->name,tfm->bit_score,tfm->end-tfm->start,tfrs->target->seq+tfm->start); } fprintf(ofp,"end motif\n"); temp = trunc_Sequence(tfrs->target,tfrs->region[i]->start,tfrs->region[i]->end); write_fasta_Sequence(temp,ofp); free_Sequence(temp); fprintf(ofp,"end region\n"); } } TransFactorRegionSet * new_TransFactorRegionSet(TransFactorMatchSet * tfms,TransFactorRegionPara * tfrp,DPRunImpl * dpri) { switch(tfrp->type) { case TRANSREGION_PARA_DP : return new_dp_TransFactorRegionSet(tfms,tfrp,dpri); break; case TRANSREGION_PARA_WINDOW : return new_window_TransFactorRegionSet(tfms,tfrp); break; default : fatal("Very weird. Bad type for TransFactorRegionPara"); } /* can't get here... but ... */ return NULL; } TransFactorRegionSet * new_dp_TransFactorRegionSet(TransFactorMatchSet * tfms,TransFactorRegionPara * tfrp,DPRunImpl * dpri) { AlnBlock * alb; PackAln * pal; AlnColumn * alc; SequenceBaseCoverage * sbc; TransRegionModel * model; TransFactorRegionSet * out; TransFactorRegion * region; int i; int covered; int uncovered; assert(tfms); assert(tfrp); assert(dpri); sbc = new_SequenceBaseCoverage(tfms); fprintf(stderr,"Making model with %.2f vs %.2f\n",tfrp->in_region_prob,tfrp->out_region_prob); model = new_logodds_TransRegionModel(tfrp->in_region_prob,tfrp->out_region_prob,tfrp->in_cost,tfrp->gc_region_ratio); fprintf(stderr,"GC score is %d (%.2f)\n",model->gc_point,Score2Bits(model->gc_point)); pal = PackAln_bestmemory_TransRegionMatrix(model,sbc,NULL,dpri); alb = convert_PackAln_to_AlnBlock_TransRegionMatrix(pal); free_PackAln(pal); out = TransFactorRegionSet_alloc_std(); out->target = hard_link_Sequence(tfms->target); for(alc = alb->start;alc != NULL;alc = alc->next ) { if( strstr(alc->alu[1]->text_label,"REGION") != NULL ) { if( alc->alu[1]->end - alc->alu[1]->start < tfrp->hmm_min_window ) { continue; } region = TransFactorRegion_alloc_std(); add_TransFactorRegionSet(out,region); region->start = alc->alu[1]->start+1; region->end = alc->alu[1]->end; region->bits_score = Score2Bits(alc->alu[0]->score[0]); covered = 0; uncovered = 0; for(i=alc->alu[1]->start+1;ialu[1]->end;i++) { if(sbc->coverage[i] == 0 ) { uncovered++; } else { covered++; } } region->density = (double) covered / (double)(covered+uncovered); for(i=0;ilen;i++) { if( tfms->match[i]->end < region->start ) { continue; } if( tfms->match[i]->start > region->end ) { break; } add_TransFactorRegion(region,hard_link_TransFactorMatch(tfms->match[i])); } } } free_SequenceBaseCoverage(sbc); free_TransRegionModel(model); free_AlnBlock(alb); return out; } TransFactorRegionSet * new_window_TransFactorRegionSet(TransFactorMatchSet * tfms,TransFactorRegionPara * tfrp) { int seqpos; int motifpos; int seq_trial; int motif_trial; int end; int covered_bases; int i; int temp_start; int last_covered_base; TransFactorRegionSet * out; TransFactorRegion * region; assert(tfms); assert(tfrp); out = TransFactorRegionSet_alloc_std(); out->target = hard_link_Sequence(tfms->target); if( tfms->len == 0 ) { /* not motifs... no regions! */ return out; } sort_by_start_TransFactorMatchSet(tfms); end = tfms->match[tfms->len-1]->start; for(seqpos = tfms->match[0]->start,motifpos = 0;seqpos < end && motifpos < tfms->len;) { /* see whether there is a potential region here */ covered_bases =0; last_covered_base = seqpos; for(seq_trial = seqpos, motif_trial = motifpos; seq_trial < end && seq_trial - seqpos < tfrp->min_window;seq_trial++) { for(;motif_trial < tfms->len;motif_trial++ ) { if( seq_trial >= tfms->match[motif_trial]->start && seq_trial < tfms->match[motif_trial]->end) { covered_bases++; last_covered_base = seq_trial; break; } if( seq_trial < tfms->match[motif_trial]->start ) { break; } } } if( seq_trial - seqpos < tfrp->min_window ) { break; } /* seq_trial is beyond window size... */ if( (double) covered_bases / (double) (seq_trial - seqpos) < tfrp->min_density ) { motifpos++; if( motifpos >= tfms->len ) { break; } else { seqpos = tfms->match[motifpos]->start; continue; /* next motif start point */ } } seq_trial = last_covered_base; /* has ok density now. Extend until we have bad density */ /* this is not a great extension - each new motif must be providing at least min_density bases */ for(motif_trial;motif_trial < tfms->len;motif_trial++) { if( seq_trial >= tfms->match[motif_trial]->end ) { continue; } if( (tfms->match[motif_trial]->end - tfms->match[motif_trial]->start) / (double) (tfms->match[motif_trial]->end - seq_trial) < tfrp->min_density ) { break; } else { temp_start = seq_trial > tfms->match[motif_trial]->start ? seq_trial : tfms->match[motif_trial]->start; seq_trial = tfms->match[motif_trial]->end; covered_bases += (tfms->match[motif_trial]->end - temp_start); } } /* we have a match! from seqpos to seq_trial and from motifpos to motiftrial */ region = TransFactorRegion_alloc_std(); region->start = seqpos; region->end = seq_trial; region->density = (double) covered_bases / (double) (seq_trial - seqpos); for(i=0;motifpos+i < motif_trial;i++) { add_TransFactorRegion(region,hard_link_TransFactorMatch(tfms->match[motifpos+i])); } add_TransFactorRegionSet(out,region); motifpos = motif_trial++; if( motifpos >= tfms->len ) { break; } seqpos = tfms->match[motifpos]->start; } return out; } wise-2.4.1/src/models/threestatemodel.dy0000644000175000001440000011305210577565051017667 0ustar philippusers/* Last edited: Apr 1 10:19 1997 (birney) */ %{ #include "dyna.h" #include "randommodel.h" #define ThreeStateModelLISTLENGTH 128 #define ThreeStateScoreLISTLENGTH 128 enum tsm_trans_type { TSM_MATCH2MATCH = 0, TSM_MATCH2INSERT, TSM_MATCH2DELETE, TSM_INSERT2MATCH, TSM_INSERT2INSERT, TSM_INSERT2DELETE, TSM_DELETE2MATCH, TSM_DELETE2INSERT, TSM_DELETE2DELETE, TSM_START2MATCH, TSM_START2INSERT, TSM_START2DELETE, TSM_MATCH2END, TSM_INSERT2END, TSM_DELETE2END }; #define TRANSITION_LEN 15 #define BLANK_SCORE (-10000000) extern char * std_alphabet; #define ALPHABET_SIZE 26 typedef enum TSM_StartEndMode { TSM_unknown = 26, TSM_default, TSM_local, TSM_global, TSM_wing, TSM_endbiased } TSM_StartEndMode; %} struct ThreeStateUnit Probability match_emission[ALPHABET_SIZE]; Probability insert_emission[ALPHABET_SIZE]; Probability transition[TRANSITION_LEN]; char display_char; !def="'u'" %info This object is the probability version of hte common unit to profile HMMs, ie the match,insert,delete triple %% struct ThreeStateModel char * name // name of the model ThreeStateUnit ** unit !list // the actuall three state probs and emissions char * alphabet // alphabet used char * accession // accession number double threshold // bits threshold (if sensible) RandomModel * rm // Random model for the model: maybe NULL! %info This is profile-HMM object, similar to the SAM and HMMer plan9 architecture. %% struct ThreeStateScoreUnit Score match[ALPHABET_SIZE] Score insert[ALPHABET_SIZE] Score trans[TRANSITION_LEN] %info This is the Score (ie , log-odded) version of the ThreeStateUnit %% struct ThreeStateScore ThreeStateScoreUnit ** unit !list char * name char * accession %info This is hte score version of the ThreeStateModel, ie this has its emissions and transitions log-odded %% api object ThreeStateModel des free_ThreeStateModel func force_global_model func force_weighted_local_model func ThreeStateModel_from_half_bit_Sequence func write_HMMer_1_7_ascii_ThreeStateModel endobject object ThreeStateUnit des free_ThreeStateUnit endobject func read_HMMer_1_7_ascii_file func read_HMMer_1_7_ascii endapi %{ #include "threestatemodel.h" char * std_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; %func Gets the information content (K-L divergence) vs a background for a position %% double information_from_ThreeStateUnit(ThreeStateUnit * tsu,RandomModel * rm) { int i; double info = 0.0; double p; for(i=0;iaminoacid[i] < 1.0 ) { p = rm->aminoacid[i]*Probability2Bits(rm->aminoacid[i]/tsu->match_emission[i]); info += p; /* fprintf(stderr,"For amino acid %d, adding %f %f\n",i,p,rm->aminoacid[i]); */ } } return info; } %func gets out the mode from a string %% int threestatemodel_mode_from_string(char * mode) { int t; t = get_number_from_slashed_string(mode,"default/global/local/wing/endbias"); switch (t) { case 0 : return TSM_default; case 1 : return TSM_global; case 2 : return TSM_local; case 3 : return TSM_wing; case 4 : return TSM_endbiased; default : warn("%s is not a valid TSM mode!",mode); return TSM_unknown; } return TSM_unknown; } %func Sets the start/end policy on the basis of the mode %% void set_startend_policy_ThreeStateModel(ThreeStateModel * tsm,TSM_StartEndMode mode,int wing_length,Probability internal_bias) { switch(mode) { case TSM_default : return; case TSM_global : force_weighted_local_model(tsm,1.0,1.0,1.0); return; case TSM_local : force_hmmfs_ThreeStateModel(tsm); return; case TSM_wing : force_wing_local_model(tsm,0.75,wing_length); return; case TSM_endbiased : force_endbias_model(tsm,1.0,internal_bias); return; case TSM_unknown : default : warn("No valid mode passed into set_startend_policy"); } } %func Makes start/end on probability and internal another not probabilistically correct %% void force_endbias_model(ThreeStateModel * tsm,double startend,double internal) { int i; if( tsm == NULL ) { warn("In force_endbias_model, got a NULL threestate model! Problem!"); return; } for(i=0;ilen;i++) { tsm->unit[i]->transition[TSM_START2MATCH] = internal; tsm->unit[i]->transition[TSM_START2DELETE] = internal; tsm->unit[i]->transition[TSM_START2INSERT] = internal; tsm->unit[i]->transition[TSM_MATCH2END] = internal; tsm->unit[i]->transition[TSM_INSERT2END] = internal; tsm->unit[i]->transition[TSM_DELETE2END] = internal; } tsm->unit[0]->transition[TSM_START2MATCH] = startend; tsm->unit[0]->transition[TSM_START2DELETE] = startend; tsm->unit[tsm->len-1]->transition[TSM_MATCH2END] = startend; tsm->unit[tsm->len-1]->transition[TSM_DELETE2END] = startend; } %func Makes start at position 0 and end at position end, no other positions being valid %arg tsm ThreeStateModel to be 'forced' prob_into_model Probability to start the model: for true global will be 1.0 %% void force_global_model(ThreeStateModel * tsm,double prob_into_model) { force_weighted_local_model(tsm,prob_into_model,1.0,1.0); } %func Places the balanace of the start probability at the start and then the rest spread evenly descending over the wing stretch of sequences Same with the end probability %arg terminus_prob the amount of probability to put on the real start and end wing_length the rest of the probability spread over this distance into the wing %% void force_wing_local_model(ThreeStateModel * tsm,double terminus_prob,int wing_length) { int i; double k; /* * k is the amount to take off for each step along the wing * * it comes from solving sum_(terminus_prob - nk) = 1.0 * with n going from 0 to wing_length * * I make this k = 2(terminus_prob)/wing_length - 2/(wing_length+1)wing_length * */ k = (2.0 * terminus_prob / wing_length) - 2.0 / ((wing_length + 1)*wing_length); if( k < 0.0 ) { warn("Weird - got k less than zero in force wing model"); return; } if( tsm == NULL ) { warn("In force_wing_local_model, got a NULL threestate model! Problem!"); return; } for(i=0;ilen && i < wing_length ;i++) { tsm->unit[i]->transition[TSM_START2MATCH] = (terminus_prob) - (i * k) ; tsm->unit[i]->transition[TSM_START2DELETE] = (terminus_prob) - (i * k) ; tsm->unit[i]->transition[TSM_START2INSERT] = (terminus_prob) - ( i * k) ; tsm->unit[tsm->len-1-i]->transition[TSM_MATCH2END] = (terminus_prob) - (i * k) ; tsm->unit[tsm->len-1-i]->transition[TSM_INSERT2END] = (terminus_prob) - ( i * k) ; tsm->unit[tsm->len-1-i]->transition[TSM_DELETE2END] = (terminus_prob) - (i * k) ; } } %func places the ratio of probability to start/end, and then distributes the rest over the start/end %arg tsm ThreeStateModel to be 'forced' prob_into_model Probability to start the model: for true global will be 1.0 ratio_start ratio of prob to unit 0 to the rest (1.0 means all goes to start) ratio_end ratio of prob to unit (last) to the rest (1.0 means all goes to the end) %% void force_weighted_local_model(ThreeStateModel * tsm,double prob_into_model,double ratio_start,double ratio_end) { int i; if( tsm == NULL ) { warn("In force_weighted_local_model, got a NULL threestate model! Problem!"); return; } for(i=0;ilen;i++) { tsm->unit[i]->transition[TSM_START2MATCH] = prob_into_model * (1.0 - ratio_start) / (tsm->len-1) ; tsm->unit[i]->transition[TSM_START2DELETE] = prob_into_model * (1.0 - ratio_start) / (tsm->len-1); tsm->unit[i]->transition[TSM_START2INSERT] = prob_into_model * (1.0 - ratio_start)/ (tsm->len-1) ; tsm->unit[i]->transition[TSM_MATCH2END] = (1.0 - ratio_end) / (tsm->len-1); tsm->unit[i]->transition[TSM_INSERT2END] = (1.0 - ratio_end) / (tsm->len-1); tsm->unit[i]->transition[TSM_DELETE2END] = (1.0 - ratio_end)/ (tsm->len-1); } tsm->unit[0]->transition[TSM_START2MATCH] = prob_into_model * (ratio_start); tsm->unit[0]->transition[TSM_START2DELETE] = prob_into_model * (ratio_start); /* tsm->unit[0]->transition[TSM_START2INSERT] = prob_into_model * (ratio_start); */ tsm->unit[tsm->len-1]->transition[TSM_MATCH2END] = (ratio_end); tsm->unit[tsm->len-1]->transition[TSM_DELETE2END] = (ratio_end); } %func places the probability at start end to precisely match hmmfs code. %arg tsm ThreeStateModel to be 'forced' %% void force_hmmfs_ThreeStateModel(ThreeStateModel * tsm) { int i; double prob; prob = 1.0 - (1000. / 1001. ); for(i=0;ilen;i++) { tsm->unit[i]->transition[TSM_START2MATCH] = prob*0.5/(2.0 * (tsm->len-1)) ; tsm->unit[i]->transition[TSM_START2DELETE] = 0.0; tsm->unit[i]->transition[TSM_START2INSERT] = 0.0; tsm->unit[i]->transition[TSM_MATCH2END] = 1.0 / (tsm->len-1); tsm->unit[i]->transition[TSM_INSERT2END] = 0.0; tsm->unit[i]->transition[TSM_DELETE2END] = 0.0; } tsm->unit[0]->transition[TSM_START2MATCH] = prob*0.5/2.0; tsm->unit[tsm->len-1]->transition[TSM_MATCH2END] = 1.0; } %func Converts the three probability form to the score form. There is real complications to this due to the fact that the prob model is a "push" model, that is MATCH2MATCH[i] means the match from i to i+1, whereas the DP routines rely on a "pull" model, ie MATCH2MATCH[i] is i-1 to i. This routines does the conversion from push to pull, essentially offsetting the Match2 and Delete2 movements. %arg tsm r ThreeStateModel probability form %% ThreeStateScore * ThreeStateScore_from_ThreeStateModel(ThreeStateModel * tsm) { register int i; ThreeStateScore * tss; tss = ThreeStateScore_alloc_len(tsm->len); add_ThreeStateScore(tss,ThreeStateScoreUnit_from_ThreeStateUnit(NULL,tsm->unit[0])); for(i=1;ilen;i++) add_ThreeStateScore(tss,ThreeStateScoreUnit_from_ThreeStateUnit(tsm->unit[i-1],tsm->unit[i])); tss->name = stringalloc(tsm->name); if( tsm->accession != NULL ) tss->accession = stringalloc(tsm->accession); return tss; } %func Converts a three state model unit to a score unit becuase of the push to pull conversion needed, it needs the previous unit. for the first unit this is NULL and 0s are placed in the correct places in the transitions %type internal %% ThreeStateScoreUnit * ThreeStateScoreUnit_from_ThreeStateUnit(ThreeStateUnit * prev,ThreeStateUnit * tsu) { ThreeStateScoreUnit * out; out = ThreeStateScoreUnit_alloc(); if( out == NULL ) return NULL; Probability2Score_move(tsu->match_emission,out->match,ALPHABET_SIZE); Probability2Score_move(tsu->insert_emission,out->insert,ALPHABET_SIZE); if( prev != NULL ) { out->trans[TSM_MATCH2MATCH] = Probability2Score(prev->transition[TSM_MATCH2MATCH]); out->trans[TSM_INSERT2MATCH] = Probability2Score(prev->transition[TSM_INSERT2MATCH]); out->trans[TSM_DELETE2MATCH] = Probability2Score(prev->transition[TSM_DELETE2MATCH]); out->trans[TSM_MATCH2DELETE] = Probability2Score(prev->transition[TSM_MATCH2DELETE]); out->trans[TSM_INSERT2DELETE] = Probability2Score(prev->transition[TSM_INSERT2DELETE]); out->trans[TSM_DELETE2DELETE] = Probability2Score(prev->transition[TSM_DELETE2DELETE]); } else { out->trans[TSM_MATCH2MATCH] = NEGI; out->trans[TSM_INSERT2MATCH] = NEGI; out->trans[TSM_DELETE2MATCH] = NEGI; out->trans[TSM_MATCH2DELETE] = NEGI; out->trans[TSM_INSERT2DELETE] = NEGI; out->trans[TSM_DELETE2DELETE] = NEGI; } out->trans[TSM_MATCH2INSERT] = Probability2Score(tsu->transition[TSM_MATCH2INSERT]); out->trans[TSM_INSERT2INSERT] = Probability2Score(tsu->transition[TSM_INSERT2INSERT]); out->trans[TSM_DELETE2INSERT] = Probability2Score(tsu->transition[TSM_DELETE2INSERT]); out->trans[TSM_START2MATCH] = Probability2Score(tsu->transition[TSM_START2MATCH]); out->trans[TSM_START2INSERT] = Probability2Score(tsu->transition[TSM_START2INSERT]); out->trans[TSM_START2DELETE] = Probability2Score(tsu->transition[TSM_START2DELETE]); out->trans[TSM_MATCH2END] = Probability2Score(tsu->transition[TSM_MATCH2END]); out->trans[TSM_INSERT2END] = Probability2Score(tsu->transition[TSM_INSERT2END]); out->trans[TSM_DELETE2END] = Probability2Score(tsu->transition[TSM_DELETE2END]); return out; } %func shows pretty ugly debugging type format. Pretty useless %% void show_ThreeStateModel(ThreeStateModel * tsm,FILE * ofp) { register int i; for(i=0;ilen;i++) { fprintf(ofp,"Position %d %c\n",i,tsm->unit[i]->display_char); show_ThreeStateUnit(tsm->unit[i],ofp); } } %func for debugging problems %type internal %% void show_ThreeStateUnit(ThreeStateUnit * tsu,FILE * ofp) { fprintf(ofp,"Match "); show_Probability_array(tsu->match_emission,26,ofp); fprintf(ofp,"\nInsert "); show_Probability_array(tsu->insert_emission,26,ofp); fprintf(ofp,"\nTransition "); show_Probability_array(tsu->transition,TRANSITION_LEN,ofp); fprintf(ofp,"\n"); } %func Makes a protein sequence out of the display characters. Not very useful! %% Protein * pseudo_Protein_from_ThreeStateModel(ThreeStateModel * tsm) { int i; Sequence * seq; seq = Sequence_alloc(); seq->name = stringalloc(tsm->name); seq->seq = ckcalloc(tsm->len+1,sizeof(char)); for(i=0;ilen;i++) { seq->seq[i] = tsm->unit[i]->display_char; } seq->seq[i]='\0'; make_len_type_Sequence(seq); seq->type = SEQUENCE_PROTEIN; return Protein_from_Sequence(seq); } %func Makes a local three-state-model from a sequence. this is scary hackery, assumming that the matrix is half-bits and normalising in a *very* wrong way to get "probabilities" out. Works though %arg pro r protein sequence mat r comparison matrix to use rm r random model which you assumme the matrix was built with gap r gap open penalty ext r gap ext penalty %% ThreeStateModel * ThreeStateModel_from_half_bit_Sequence(Protein * pro,CompMat * mat,RandomModel * rm,int gap,int ext) { Sequence * seq; register int i; ThreeStateModel * out; if( pro == NULL || mat == NULL || rm == NULL ) { warn("you have passed through NULL objects in trying to make TSM from sequence"); return NULL; } if( gap > 0 || ext > 0 ) { warn("You have passed in gap and extension penalties of > 0 Gap %d Ext %d. Expecting them to be negated. Giving you back an error!",gap,ext); return NULL; } seq = pro->baseseq; out = ThreeStateModel_alloc_len(seq->len); if( seq->name != NULL ) out->name = stringalloc(seq->name); else out->name = stringalloc("NoName"); out->rm = hard_link_RandomModel(rm); for(i=0;ilen;i++) { add_ThreeStateModel(out,ThreeStateUnit_from_half_bit_aminoacid(seq->seq[i],mat,rm,gap,ext)); } return out; } %func The internal protein->hmm conversion routine. %type internal %% ThreeStateUnit * ThreeStateUnit_from_half_bit_aminoacid(char aa,CompMat * mat,RandomModel * rm,int gap,int ext) { ThreeStateUnit * tsu; register int i; Probability go; Probability ge; Probability rnd_error; tsu = ThreeStateUnit_alloc(); aa = toupper((int)aa); /* maybe do more checking on aa? */ for(i=0;i<26;i++) { tsu->match_emission[i] = halfbit2Probability(fail_safe_CompMat_access(mat,aa-'A',i)) * rm->aminoacid[i]; tsu->insert_emission[i] = rm->aminoacid[i]; } rnd_error = renormalise_Probability_array(tsu->match_emission,26); if( fabs(rnd_error) > 0.5 ) { warn("Very bad problem - got a stupid error %.2f after renormalisation from the null model with the match state on aa %c\n",rnd_error,aa); } rnd_error = renormalise_Probability_array(tsu->insert_emission,26); if( fabs(rnd_error) > 0.5 ) { warn("Very bad problem - got a stupid error %.2f after renormalisation from the null model\n",rnd_error); } ge = halfbit2Probability(ext); go = halfbit2Probability(gap); /** 1-ge is the gap closing penalty. So we have to remove that from the go **/ go = go / (1-ge); tsu->transition[TSM_MATCH2INSERT] = tsu->transition[TSM_MATCH2DELETE] = go; tsu->transition[TSM_INSERT2MATCH] = tsu->transition[TSM_DELETE2MATCH] = 1-ge; tsu->transition[TSM_INSERT2INSERT] = tsu->transition[TSM_DELETE2DELETE] = ge; tsu->transition[TSM_INSERT2DELETE] = tsu->transition[TSM_DELETE2INSERT] = 0.0; tsu->transition[TSM_MATCH2MATCH] = 1-(2*go); tsu->transition[TSM_START2MATCH] = 1.0; tsu->transition[TSM_MATCH2END] = 1.0; tsu->display_char = aa; return tsu; } %func Makes a global three-state-model from a sequence. Like the local version, this is scary hackery, assumming that the matrix is half-bits and normalising in a *very* wrong way to get "probabilities" out. Works though %arg pro r protein sequence mat r comparison matrix to use rm r random model which you assumme the matrix was built with gap r gap open penalty ext r gap ext penalty %% ThreeStateModel * global_ThreeStateModel_from_half_bit_Sequence(Protein * pro,CompMat * mat,RandomModel * rm,int gap,int ext) { register int i; ThreeStateModel * out; ThreeStateUnit * temp; Sequence * seq; if( pro == NULL || mat == NULL || rm == NULL ) { warn("you have passed through NULL objects in trying to make TSM from sequence"); return NULL; } seq = pro->baseseq; out = ThreeStateModel_alloc_len(seq->len); if( seq->name != NULL ) out->name = stringalloc(seq->name); else out->name = stringalloc("NoName"); for(i=0;ilen;i++) { temp = ThreeStateUnit_from_half_bit_aminoacid(seq->seq[i],mat,rm,gap,ext); temp->transition[TSM_START2MATCH] = 0.0; temp->transition[TSM_MATCH2END] = 0.0; add_ThreeStateModel(out,temp); } out->unit[0]->transition[TSM_START2MATCH] = 1.0; out->unit[out->len-1]->transition[TSM_MATCH2END] = 1.0; out->rm = hard_link_RandomModel(rm); return out; } %func Makes a display character for this threestateunit by finding the most probable match emission %type internal %% char display_char_for_ThreeStateUnit(ThreeStateUnit * tsu) { register int i; Probability p; int c; p = tsu->match_emission[0]; c = 0; for(i=1;imatch_emission[i] > p ) { p = tsu->match_emission[i]; c = i; } return c + 'A'; } %func Makes the display chars in the tsm come from the most likely amino acid in the match position %% void display_char_in_ThreeStateModel(ThreeStateModel * tsm) { register int i; for(i=0;ilen;i++) tsm->unit[i]->display_char = display_char_for_ThreeStateUnit(tsm->unit[i]); } %func divides the emission and insertion scores by the random model for use in log-odd implementations %% void fold_RandomModel_into_ThreeStateModel(ThreeStateModel * tsm,RandomModel * rm) { register int i; register int j; assert(tsm); assert(rm); for(i=0;ilen;i++) { auto ThreeStateUnit * tsu; tsu = tsm->unit[i]; for(j=0;j<26;j++) { if( rm->aminoacid[j] < 0.00000001 ) { warn("While trying to fold in random model, amino acid %d [%c] was below zero, ignoring",j,'A'+j); continue; } tsu->match_emission[j] = tsu->match_emission[j] / rm->aminoacid[j]; tsu->insert_emission[j] = tsu->insert_emission[j] / rm->aminoacid[j]; } } } %func added start 0.5, 0.25,0.25 for hmmls type Deprecated %% void add_sensible_start_end_global_for_HMMer(ThreeStateModel * tsm) { ThreeStateUnit * end; tsm->unit[0]->transition[TSM_START2MATCH] = 0.5; tsm->unit[0]->transition[TSM_START2INSERT] = 0.25; tsm->unit[0]->transition[TSM_START2DELETE] = 0.25; /*** these should not add to one due to sum in states ***/ end = tsm->unit[tsm->len-1]; end->transition[TSM_MATCH2END] = (1 - end->transition[TSM_MATCH2INSERT]) ; end->transition[TSM_DELETE2END] = (1 - end->transition[TSM_DELETE2INSERT]) ; end->transition[TSM_INSERT2END] = (1 - end->transition[TSM_INSERT2INSERT]); } %func adds start/end for loop probabilities coming in Deprecated %% void add_sensible_start_end_looping_for_HMMer(ThreeStateModel * tsm,Probability loop) { tsm->unit[0]->transition[TSM_START2MATCH] = loop * 0.5; tsm->unit[0]->transition[TSM_START2INSERT] = loop * 0.25; tsm->unit[0]->transition[TSM_START2DELETE] = loop * 0.25; /*** these should not add to one due to sum in states ***/ tsm->unit[tsm->len-1]->transition[TSM_MATCH2END] = 0.5; tsm->unit[tsm->len-1]->transition[TSM_DELETE2END] = 0.25; tsm->unit[tsm->len-1]->transition[TSM_INSERT2END] = 0.25; } /**** I/O *****/ %func writes the HMF format %% void write_HMF_ThreeStateModel(ThreeStateModel * tsm,FILE * ofp) { int i; fprintf(ofp,"ID %s\n",tsm->name != NULL ? tsm->name : "NoName"); fprintf(ofp,"TR %4.2f\n",tsm->threshold); fprintf(ofp,"CC HMF format for HMM, each three state block starts UN after MO line\n"); fprintf(ofp,"CC Alphabet A-Z\n"); fprintf(ofp,"MO\n"); for(i=0;ilen;i++) write_HMF_ThreeStateUnit(tsm->unit[i],ofp); fprintf(ofp,"//\n"); } %func writes each Unit line %type internal %% void write_HMF_ThreeStateUnit(ThreeStateUnit * tsu,FILE * ofp) { fprintf(ofp,"UN %c\n",tsu->display_char); fprintf(ofp,"MA "); show_Probability_array_exp(tsu->match_emission,ALPHABET_SIZE,ofp); fprintf(ofp,"\nIN "); show_Probability_array_exp(tsu->insert_emission,ALPHABET_SIZE,ofp); fprintf(ofp,"\nTR "); show_Probability_array_exp(tsu->transition,TRANSITION_LEN,ofp); fprintf(ofp,"\n"); } %func reads the HMF format. Leaves the file ready to read the next format %% ThreeStateModel * read_HMF_ThreeStateModel(FILE * ifp) { ThreeStateUnit * temp; ThreeStateModel * out; char buffer[MAXLINE]; char * name = NULL; char * runner; if( feof(ifp) || ferror(ifp) ) return NULL; while( fgets(buffer,MAXLINE,ifp) != NULL ) { chop_newline(buffer); if( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"ID") == 0 ) { name = stringalloc(strtok(buffer+3,spacestr)); break; } warn("In reading HMF format, before ID line, ignoring [%s]",buffer); } if( feof(ifp) || ferror(ifp) || name == NULL) return NULL; out = ThreeStateModel_alloc_std(); out->name = name; while( fgets(buffer,MAXLINE,ifp) != NULL ) { chop_newline(buffer); if( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"MO") == 0 ) break; else if( strstartcmp(buffer,"CC") == 0 ) continue; else if( strstartcmp(buffer,"TR") == 0 ) { runner = strtok(buffer+2,spacestr); if( is_double_string(runner,&out->threshold) == FALSE) { warn("Could not interpret [%s] as a threshold",runner); } } else if( strstartcmp(buffer,"ID") == 0 ) { warn("Already got a name for [%s], ignoring [%s]",out->name,buffer); } else { warn("Did not understand %s",buffer); } } while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"UN") == 0 ) break; chop_newline(buffer); warn("You have a problem here: [%s] between MO and UN lines",buffer); } while( (temp = read_HMF_ThreeStateUnit(buffer,ifp)) != NULL ) { add_ThreeStateModel(out,temp); if( strstartcmp(buffer,"//") == 0 ) break; } display_char_in_ThreeStateModel(out); return out; } %func reads a unit set of lines: Line is used as the buffer, so should be MAXLINE length. At the end, it will have a different characters (probably the next unit line) in the line buffer, so you should test that %type internal %arg line w pointer to a MAXLINE length buffer. ifp input file %% ThreeStateUnit * read_HMF_ThreeStateUnit(char * line,FILE * ifp) { ThreeStateUnit * out; char * runner; if( strstartcmp(line,"UN") != 0 ) { warn("Attempting to read a ThreeStateUnit with a non UN line: [%s]",line); return NULL; } out = blank_ThreeStateUnit(); /* display char */ runner = strtok(line+2,spacestr); if( runner != NULL ) { out->display_char = *runner; } while ( fgets(line,MAXLINE,ifp) != NULL ) { if( strstartcmp(line,"//") == 0 ) break; if( strstartcmp(line,"UN") == 0 ) break; if( strstartcmp(line,"MA") == 0 ) { if( read_Probability_array(out->match_emission,ALPHABET_SIZE,line+3) == FALSE ) { warn("Unable to read Match emission line"); } } else if ( strstartcmp(line,"IN") == 0) { if( read_Probability_array(out->insert_emission,ALPHABET_SIZE,line+3) == FALSE ) { warn("Unable to read Insert emission line"); } } else if ( strstartcmp(line,"TR") == 0 ) { if( read_Probability_array(out->transition,TRANSITION_LEN,line+3) == FALSE ) { warn("Unable to read Insert emission line"); } } else { chop_newline(line); warn("Could not understand line [%s] in reading threestateunit",line); } } return out; } %func writes a HMMer version 1.7 (also ok with 1.8) file %% void write_HMMer_1_7_ascii_ThreeStateModel(ThreeStateModel * tsm,FILE * ofp) { register int i; fprintf(ofp,"# HMM v1.7\n"); fprintf(ofp,"%d # Length of model\n",tsm->len); fprintf(ofp,"%d # length of alphabet\n",26); fprintf(ofp,"3 # alphabet type\n"); fprintf(ofp,"%s # alphabet\n",std_alphabet); fprintf(ofp,"no # optional\nno # optional \n"); for(i=0;ilen;i++) write_HMMer_1_7_ascii_ThreeStateUnit(tsm->unit[i],i,ofp); } %func the internal for the ThreeStateModel write %type internal %% void write_HMMer_1_7_ascii_ThreeStateUnit(ThreeStateUnit * tsu,int no,FILE * ofp) { register int i; fprintf(ofp,"###MATCH_STATE %d ( ) ( )\n",no); fprintf(ofp,"%f\t# t_m%d\n",tsu->transition[TSM_MATCH2MATCH],no+1); fprintf(ofp,"%f\t# t_d%d\n",tsu->transition[TSM_MATCH2DELETE],no+1); fprintf(ofp,"%f\t# t_i%d\n",tsu->transition[TSM_MATCH2INSERT],no); for(i=0;i<26;i++) { fprintf(ofp,"%f\t# Symbol %c probability\n",tsu->match_emission[i],'A'+i); } fprintf(ofp,"###DELETE_STATE %d\n",no); fprintf(ofp,"%f\t# t_m%d\n",tsu->transition[TSM_DELETE2MATCH],no+1); fprintf(ofp,"%f\t# t_d%d\n",tsu->transition[TSM_DELETE2DELETE],no+1); fprintf(ofp,"%f\t# t_i%d\n",tsu->transition[TSM_DELETE2INSERT],no); fprintf(ofp,"###INSERT_STATE %d\n",no); fprintf(ofp,"%f\t# t_m%d\n",tsu->transition[TSM_INSERT2MATCH],no+1); fprintf(ofp,"%f\t# t_d%d\n",tsu->transition[TSM_INSERT2DELETE],no+1); fprintf(ofp,"%f\t# t_i%d\n",tsu->transition[TSM_INSERT2INSERT],no); for(i=0;i<26;i++) { fprintf(ofp,"%f\t# Symbol %c probability\n",tsu->insert_emission[i],'A'+i); } } %func reads a HMMer ascii version 1.7 (1.8) file from filename. %arg filename the name fo the hmmer file %% ThreeStateModel * read_HMMer_1_7_ascii_file(char * filename) { FILE * ifp; ThreeStateModel * out; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open file %s for read HMMer 17 ",filename); return NULL; } out = read_HMMer_1_7_ascii(ifp); ckfree(out->name); if( strcmp(filename,"-") == 0 ) { /* comes from stdin, we're fucked to find the name */ out->name = stringalloc("HMMerModel"); } else { if( strchr(filename,'/') != NULL) { filename = filename + strlen(filename) -1; for(;*filename != '/';filename--) ; filename++; } out->name = stringalloc(filename); } fclose(ifp); return out; } %func Not sure if this is needed now, as score model will be pull, and probability model will be push. %type internal %% ThreeStateModel * convert_push_model_to_pull_model(ThreeStateModel * tsm) { register int i; ThreeStateModel * out; out = ThreeStateModel_alloc_len(tsm->len-1); for(i=1;ilen;i++) add_ThreeStateModel(out,convert_push_unit_to_pull_unit(tsm->unit[i-1],tsm->unit[i])); if( tsm->name != NULL) out->name = stringalloc(tsm->name); return out; } %func Not sure if this is needed now, as score model will be pull, and probability model will be push. %type internal %% ThreeStateUnit * convert_push_unit_to_pull_unit(ThreeStateUnit * prev,ThreeStateUnit * this) { ThreeStateUnit * out; out = ThreeStateUnit_alloc(); Probability_move(this->match_emission ,out->match_emission ,ALPHABET_SIZE); Probability_move(this->insert_emission,out->insert_emission,ALPHABET_SIZE); set_Probability_array(out->transition,0.0,TRANSITION_LEN); out->transition[TSM_MATCH2MATCH] = prev->transition[TSM_MATCH2MATCH]; out->transition[TSM_DELETE2MATCH] = prev->transition[TSM_DELETE2MATCH]; out->transition[TSM_INSERT2MATCH] = prev->transition[TSM_INSERT2MATCH]; out->transition[TSM_MATCH2INSERT] = this->transition[TSM_MATCH2INSERT]; out->transition[TSM_INSERT2INSERT] = this->transition[TSM_INSERT2INSERT]; out->transition[TSM_DELETE2INSERT] = this->transition[TSM_DELETE2INSERT]; out->transition[TSM_MATCH2DELETE] = prev->transition[TSM_MATCH2DELETE]; out->transition[TSM_INSERT2DELETE] = prev->transition[TSM_INSERT2DELETE]; out->transition[TSM_DELETE2DELETE] = prev->transition[TSM_DELETE2DELETE]; /*** not dealing with start/end things here ***/ return out; } %func Basic function to read HMMer version 1.7(1.8) files. %% ThreeStateModel * read_HMMer_1_7_ascii(FILE * ifp) { char buffer[MAXLINE]; char * runner; char * alphabet; int length; int count; ThreeStateModel * out; ThreeStateUnit * temp; /*** read top of model ***/ /*** then we will loop ***/ /*** over all the states ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, but no first line!"); return NULL; } if( strstartcmp(buffer,"# HMM") != 0 ) { warn("In reading HMMer ascii file, expecting first line to start [# HMM], starts as [%s]... can't handle",buffer); return NULL; } if( strstartcmp(buffer,"# HMM v1.7") != 0) { warn("In reading HMMer ascii file, expecting a version 1.7 file, got a version [%s] file... trying to read",buffer); } /*** length next ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, length line (2nd line) not there"); return NULL; } if( (runner=strtok(buffer,spacestr)) == NULL ) { warn("Trying to read HMMer ascii file, length line (2nd line) has no length!"); return NULL; } length = atoi(runner); if( length <= 0 || length > 4000 ) { warn("Picked up length [%s] which was interpreted as the number [%d], which seems unfeasible. S'ok... can work without the length",runner,length); length = 100; } /*** get the alphabet length... no point in checking ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, length of alphabet (3rd line) not there"); return NULL; } if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, type of alphabet (4th line) not there"); return NULL; } if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, alphabet (5th line) not there"); return NULL; } if( (runner=strtok(buffer,spacestr)) == NULL ) { warn("HMMer ascii read, alphabet line (5th line) has no alphabet!"); return NULL; } alphabet = stringalloc(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, reference (6th line) not there"); return NULL; } if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, reference (7th line) not there"); return NULL; } /*** ok, ready to rock, we have the length and alphabet, ***/ /*** now loop over the states ... ***/ out = ThreeStateModel_alloc_len(length); for(count=0;count < length+1 && !feof(ifp) && !(ferror(ifp));count++ ) { temp = read_HMMer_1_7_ThreeStateUnit(alphabet,ifp); if( temp == NULL ) { warn("In HMMer read, On unit number [%d], unable to get unit...",count); break; } if( count == 0 ) continue; /** skip first "dummy" state **/ else add_ThreeStateModel(out,temp); } out->name = stringalloc("HMMer Model"); out->alphabet = alphabet; /*** by default, make it a global model ***/ force_global_model(out,1.0); return out; } %func Function to read a single unit from a 1.7(1.8) file %type internal %% ThreeStateUnit * read_HMMer_1_7_ThreeStateUnit(char * alphabet,FILE * ifp) { char buffer[MAXLINE]; char * runner; char * al; ThreeStateUnit * out; if( fgets(buffer,MAXLINE,ifp) == NULL ) { /*** could be the end of the model. Return silently for the next stage ***/ return NULL; } if( strstartcmp(buffer,"###MATCH_STATE") != 0 ) { warn("Start of ThreeStateUnit HMMr read... does not match [###MATCH_STATE], instead... [%s]",buffer); return NULL; } out = blank_ThreeStateUnit(); if( out == NULL ) return NULL; /** warning already issued **/ /*** ok read in the first three transitions ***/ /*** transitions for MATCH ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no m2m line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got m2m line, but no transition worked out"); return NULL; } out->transition[TSM_MATCH2MATCH] = atof(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no m2d line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got m2d line, but no transition worked out"); return NULL; } out->transition[TSM_MATCH2DELETE] = atof(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no m2i line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got m2i line, but no transition worked out"); return NULL; } out->transition[TSM_MATCH2INSERT] = atof(runner); /*** match emission probs ***/ for(al=alphabet;*al;al++) { if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr threestateunit, the file ended on the match emission of %c",*al); free_ThreeStateUnit(out); return NULL; } runner = strtok(buffer,spacestr); /**** ASSUMMING a 26 alphabet now... Aaaaah ****/ out->match_emission[ toupper((int)*al)-'A'] = atof(runner); } /*** now to delete probabilities ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no start line!"); return NULL; } if( strstartcmp(buffer,"###DELETE_STATE") != 0 ) { warn("Start of delete ThreeStateUnit HMMr read... does not match [###DELETE_STATE], instead... [%s]",buffer); return NULL; } /*** ok read in the first three transitions ***/ /*** transitions for DELETE ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no d2m line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got d2m line, but no transition worked out"); return NULL; } out->transition[TSM_DELETE2MATCH] = atof(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no d2d line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got d2d line, but no transition worked out"); return NULL; } out->transition[TSM_DELETE2DELETE] = atof(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no d2i line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got d2i line, but no transition worked out"); return NULL; } out->transition[TSM_DELETE2INSERT] = atof(runner); /***** now insert probs *****/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no start line!"); return NULL; } if( strstartcmp(buffer,"###INSERT_STATE") != 0 ) { warn("Start of ThreeStateUnit HMMr read... does not match [###INSERT_STATE], instead... [%s]",buffer); return NULL; } /*** ok read in the first three transitions ***/ /*** transitions for INSERT ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no i2m line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got i2m line, but no transition worked out"); return NULL; } out->transition[TSM_INSERT2MATCH] = atof(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no i2d line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got i2d line, but no transition worked out"); return NULL; } out->transition[TSM_INSERT2DELETE] = atof(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no i2i line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got i2i line, but no transition worked out"); return NULL; } out->transition[TSM_INSERT2INSERT] = atof(runner); /*** insert emission probs ***/ for(al=alphabet;*al;al++) { if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr threestateunit, the file ended on the insert emission of %c",*al); free_ThreeStateUnit(out); return NULL; } runner = strtok(buffer,spacestr); /**** ASSUMMING a 26 alphabet now... Aaaaah ****/ out->insert_emission[ toupper((int)*al)-'A'] = atof(runner); } return out; } %func Makes a set to 0.0 unit %type internal %% ThreeStateUnit * blank_ThreeStateUnit(void) { ThreeStateUnit * out; register int i; out = ThreeStateUnit_alloc(); if(out == NULL ) return NULL; for(i=0;i<26;i++) out->match_emission[i] = out->insert_emission[i] = 0.0; for(i=0;itransition[i] = 0.0; return out; } %} wise-2.4.1/src/models/threestatemodel.xs0000644000175000001440000001264410670453715017707 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::ThreeStateModel void force_global_model(tsm,prob_into_model) Wise2_ThreeStateModel * tsm double prob_into_model CODE: Wise2_force_global_model(tsm,prob_into_model); void force_weighted_local_model(tsm,prob_into_model,ratio_start,ratio_end) Wise2_ThreeStateModel * tsm double prob_into_model double ratio_start double ratio_end CODE: Wise2_force_weighted_local_model(tsm,prob_into_model,ratio_start,ratio_end); Wise2_ThreeStateModel * ThreeStateModel_from_half_bit_Sequence(pro,mat,rm,gap,ext) Wise2_Protein * pro Wise2_CompMat * mat Wise2_RandomModel * rm int gap int ext CODE: RETVAL = Wise2_ThreeStateModel_from_half_bit_Sequence(pro,mat,rm,gap,ext); OUTPUT: RETVAL void write_HMMer_1_7_ascii_ThreeStateModel(tsm,ofp) Wise2_ThreeStateModel * tsm FILE * ofp CODE: Wise2_write_HMMer_1_7_ascii_ThreeStateModel(tsm,ofp); Wise2_ThreeStateModel * hard_link_ThreeStateModel(obj) Wise2_ThreeStateModel * obj CODE: RETVAL = Wise2_hard_link_ThreeStateModel(obj); OUTPUT: RETVAL Wise2_ThreeStateModel * ThreeStateModel_alloc_std() CODE: RETVAL = Wise2_ThreeStateModel_alloc_std(); OUTPUT: RETVAL boolean set_name(obj,name) Wise2_ThreeStateModel * obj char * name CODE: RETVAL = Wise2_replace_name_ThreeStateModel(obj,Wise2_stringalloc(name)); OUTPUT: RETVAL char * name(obj) Wise2_ThreeStateModel * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_name_ThreeStateModel(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_ThreeStateUnit * unit(obj,i) Wise2_ThreeStateModel * obj int i INIT: Wise2_ThreeStateUnit * temp; CODE: temp = Wise2_hard_link_ThreeStateUnit(Wise2_access_unit_ThreeStateModel(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_unit(obj) Wise2_ThreeStateModel * obj CODE: RETVAL = Wise2_length_unit_ThreeStateModel(obj); OUTPUT: RETVAL int flush_unit(obj) Wise2_ThreeStateModel * obj CODE: RETVAL = Wise2_flush_ThreeStateModel(obj); OUTPUT: RETVAL boolean add_unit(obj,add) Wise2_ThreeStateModel * obj Wise2_ThreeStateUnit * add CODE: RETVAL = Wise2_add_ThreeStateModel(obj,Wise2_hard_link_ThreeStateUnit(add)); OUTPUT: RETVAL boolean set_alphabet(obj,alphabet) Wise2_ThreeStateModel * obj char * alphabet CODE: RETVAL = Wise2_replace_alphabet_ThreeStateModel(obj,Wise2_stringalloc(alphabet)); OUTPUT: RETVAL char * alphabet(obj) Wise2_ThreeStateModel * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_alphabet_ThreeStateModel(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_accession(obj,accession) Wise2_ThreeStateModel * obj char * accession CODE: RETVAL = Wise2_replace_accession_ThreeStateModel(obj,Wise2_stringalloc(accession)); OUTPUT: RETVAL char * accession(obj) Wise2_ThreeStateModel * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_accession_ThreeStateModel(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_threshold(obj,threshold) Wise2_ThreeStateModel * obj double threshold CODE: RETVAL = Wise2_replace_threshold_ThreeStateModel(obj,threshold); OUTPUT: RETVAL double threshold(obj) Wise2_ThreeStateModel * obj CODE: RETVAL = Wise2_access_threshold_ThreeStateModel(obj); OUTPUT: RETVAL boolean set_rm(obj,rm) Wise2_ThreeStateModel * obj Wise2_RandomModel * rm CODE: RETVAL = Wise2_replace_rm_ThreeStateModel(obj,Wise2_hard_link_RandomModel(rm)); OUTPUT: RETVAL Wise2_RandomModel * rm(obj) Wise2_ThreeStateModel * obj INIT: Wise2_RandomModel * temp; CODE: temp = Wise2_hard_link_RandomModel(Wise2_access_rm_ThreeStateModel(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_ThreeStateModel * new(class) char * class PPCODE: Wise2_ThreeStateModel * out; out = Wise2_ThreeStateModel_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_ThreeStateModel * obj CODE: Wise2_free_ThreeStateModel(obj); void each_unit(obj) Wise2_ThreeStateModel * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_unit_ThreeStateModel(obj); for(i=0;idpri = new_DPRunImpl_from_argv(argc,argv); out->mat = identity_DnaMatrix(match,mismatch); out->dse = DnaStartEnd_from_policy("local"); out->gap = 30; out->ext = 20; strip_out_integer_argument(argc,argv,"dm_gappen",&out->gap); strip_out_integer_argument(argc,argv,"dm_extpen",&out->ext); return out; } HitList * HitList_from_Sequence_SequenceSet_DNA(Sequence * query,SequenceSet * set,DnaMatchPara * p) { int i; HitList * out; HitPair * pair; HitAln * aln; AlnBlock * forward; AlnBlock * reverse; Sequence * rev; char buffer[512]; out = HitList_alloc_std(); for(i=0;ilen;i++) { rev = reverse_complement_Sequence(set->set[i]); ckfree(rev->name); sprintf(buffer,"%s.reverse",set->set[i]->name); rev->name = stringalloc(buffer); pair = HitPair_alloc_std(); aln = HitAln_alloc(); forward = make_align_dnaalign(query,set->set[i],p->mat,p->dse,-p->gap,-p->ext,-p->gap,-p->ext,p->dpri); reverse = make_align_dnaalign(query,rev,p->mat,p->dse,-p->gap,-p->ext,-p->gap,-p->ext,p->dpri); if( forward->score > reverse->score ) { pair->query = hard_link_Sequence(query); pair->target = hard_link_Sequence(set->set[i]); aln->alb = hard_link_AlnBlock(forward); } else { pair->query = hard_link_Sequence(query); pair->target = hard_link_Sequence(rev); aln->alb = hard_link_AlnBlock(reverse); } add_HitPair(pair,aln); aln->raw_score = pair->raw_score = aln->alb->score; add_HitList(out,pair); free_AlnBlock(forward); free_AlnBlock(reverse); free_Sequence(rev); } return out; } wise-2.4.1/src/models/sw_wrap.c0000644000175000001440000004032210670453715015762 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "sw_wrap.h" /* Function: Align_strings_ProteinSmithWaterman(one,two,comp,gap,ext,dpenv,dpri) * * Descrip: This is the most *stupidly* abstracted view of two sequences * getting aligned, being two strings. * * It would be much better if you used Sequence objects or Protein * objects to carry the proteins. * * * Arg: one [UNKN ] string of the first sequence [char *] * Arg: two [UNKN ] string of the second sequence [char *] * Arg: comp [UNKN ] Comparison Matrix [CompMat *] * Arg: gap [UNKN ] gap penalty [int] * Arg: ext [UNKN ] extension penalty [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 37 "sw_wrap.dy" AlnBlock * Align_strings_ProteinSmithWaterman(char * one,char * two,CompMat * comp,int gap,int ext,DPEnvelope * dpenv,DPRunImpl * dpri) { Sequence * one_s; Sequence * two_s; AlnBlock * out; /* error check the strings? */ one_s = new_Sequence_from_strings(NULL,one); if( one_s == NULL ) { warn("Cannot make new sequence...\n"); return NULL; } two_s = new_Sequence_from_strings(NULL,two); if( two_s == NULL ) { warn("Cannot make new sequence...\n"); return NULL; } out = Align_Sequences_ProteinSmithWaterman(one_s,two_s,comp,gap,ext,dpenv,dpri); free_Sequence(one_s); free_Sequence(two_s); return out; } /* Function: Align_Sequences_ProteinSmithWaterman(one,two,comp,gap,ext,dpenv,dpri) * * Descrip: This function is a mid-level abstraction of * comparing two sequences, which could be * generic types (eg DNA!). This is tested * for and warnings are given but the alignment * is still calculated. To prevent this test * warning either make sure the Sequence types * are set to PROTEIN or, better still, use the * high level abstraction Align_Proteins_SmithWaterman * * Otherwise this performs a standard smith waterman * protein alignment... * * To display the alignment use write_pretty_seq_align * * * Arg: one [READ ] First sequence to compare [Sequence *] * Arg: two [READ ] Second sequecne to compare [Sequence *] * Arg: comp [READ ] Comparison matrix to use [CompMat *] * Arg: gap [UNKN ] gap penalty. Must be negative or 0 [int] * Arg: ext [UNKN ] ext penalty. Must be negative or 0 [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [OWNER] new AlnBlock structure representing the alignment [AlnBlock *] * */ # line 88 "sw_wrap.dy" AlnBlock * Align_Sequences_ProteinSmithWaterman(Sequence * one,Sequence * two,CompMat * comp,int gap,int ext,DPEnvelope * dpenv,DPRunImpl * dpri) { AlnBlock * out = NULL; ComplexSequenceEvalSet * evalfunc = NULL; ComplexSequence * query_cs = NULL; ComplexSequence * target_cs = NULL; PackAln * pal = NULL; if( one == NULL || two == NULL || comp == NULL ) { warn("Passed in NULL objects into Align_Sequences_ProteinSmithWaterman!"); return NULL; } if( one->type != SEQUENCE_PROTEIN ) { warn("Sequence %s is not typed as protein... ignoring!\n",one->name); } if( two->type != SEQUENCE_PROTEIN ) { warn("Sequence %s is not typed as protein... ignoring!\n",two->name); } if( gap > 0 || ext > 0 ) { warn("Gap penalties %d,%d only make sense if they are negative",gap,ext); return NULL; } evalfunc = default_aminoacid_ComplexSequenceEvalSet(); query_cs = new_ComplexSequence(one,evalfunc); if( query_cs == NULL ) goto cleanup; target_cs = new_ComplexSequence(two,evalfunc); if( target_cs == NULL ) goto cleanup; pal = PackAln_bestmemory_ProteinSW(query_cs,target_cs,comp,gap,ext,dpenv,dpri); if( pal == NULL ) goto cleanup; out = convert_PackAln_to_AlnBlock_ProteinSW(pal); goto cleanup; cleanup : if( query_cs != NULL ) free_ComplexSequence(query_cs); if( target_cs != NULL ) free_ComplexSequence(target_cs); if( pal != NULL ) free_PackAln(pal); if( evalfunc != NULL ) free_ComplexSequenceEvalSet(evalfunc); return out; } /* Function: Align_Sequences_ProteinBlockAligner(one,two,comp,bentry,bexit,b1exit,b_self,b_on,dpenv,dpri) * * Descrip: This is a way of aligning two sequences using * the ProteinBlockAligner algorithm * * * * Arg: one [UNKN ] Sequence to align [Sequence *] * Arg: two [UNKN ] Sequence to align [Sequence *] * Arg: comp [UNKN ] Comparison Matrix [CompMat *] * Arg: bentry [UNKN ] entry into a block [int] * Arg: bexit [UNKN ] exit for a block [int] * Arg: b1exit [UNKN ] exit for a block of length one [int] * Arg: b_self [UNKN ] self transition [int] * Arg: b_on [UNKN ] onwards transition [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 164 "sw_wrap.dy" AlnBlock * Align_Sequences_ProteinBlockAligner(Sequence * one,Sequence * two,CompMat * comp,int bentry,int bexit,int b1exit,int b_self,int b_on,DPEnvelope * dpenv,DPRunImpl * dpri) { ComplexSequence * cone=NULL; ComplexSequence * ctwo=NULL; AlnBlock * alb= NULL; PackAln * pal=NULL; ComplexSequenceEvalSet * evalfunc = NULL; if( one == NULL || two == NULL || comp == NULL ) { warn("Passed in NULL objects into Align_Sequences_ProteinSmithWaterman!"); return NULL; } if( one->type != SEQUENCE_PROTEIN ) { warn("Sequence %s is not typed as protein... ignoring!\n",one->name); } if( two->type != SEQUENCE_PROTEIN ) { warn("Sequence %s is not typed as protein... ignoring!\n",two->name); } evalfunc = default_aminoacid_ComplexSequenceEvalSet(); cone = new_ComplexSequence(one,evalfunc); if( cone == NULL ) goto cleanup; ctwo = new_ComplexSequence(two,evalfunc); if( ctwo == NULL ) goto cleanup; pal = PackAln_bestmemory_ProteinBlockAligner(cone,ctwo,comp,bentry,b1exit,b_on,b_self,bexit,dpenv,dpri); if( pal == NULL ) goto cleanup; alb = convert_PackAln_to_AlnBlock_ProteinSW(pal); goto cleanup; cleanup : if( cone != NULL ) free_ComplexSequence(cone); if( ctwo != NULL ) free_ComplexSequence(ctwo); if( pal != NULL ) free_PackAln(pal); if( evalfunc != NULL ) free_ComplexSequenceEvalSet(evalfunc); return alb; } /* Function: Align_Sequences_ProteinABC(one,two,comp,a,b,c,dpenv,dpri) * * Descrip: Align_Sequences_ProteinABC * this function is analogous to Align_Sequences_ProteinSmithWaterman * but using the abc model * * * Arg: one [UNKN ] Sequence to align [Sequence *] * Arg: two [UNKN ] Sequence to align [Sequence *] * Arg: comp [UNKN ] Comparison Matrix [CompMat *] * Arg: a [UNKN ] genearlized affine gap cost [int] * Arg: b [UNKN ] genearlized affine gap cost [int] * Arg: c [UNKN ] genearlized affine gap cost [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 234 "sw_wrap.dy" AlnBlock * Align_Sequences_ProteinABC(Sequence * one,Sequence * two,CompMat * comp,int a, int b, int c,DPEnvelope * dpenv,DPRunImpl * dpri) { ComplexSequence * cone=NULL; ComplexSequence * ctwo=NULL; AlnBlock * alb= NULL; PackAln * pal=NULL; ComplexSequenceEvalSet * evalfunc = NULL; if( one == NULL || two == NULL || comp == NULL ) { warn("Passed in NULL objects into Align_Sequences_ProteinSmithWaterman!"); return NULL; } if( one->type != SEQUENCE_PROTEIN ) { warn("Sequence %s is not typed as protein... ignoring!\n",one->name); } if( two->type != SEQUENCE_PROTEIN ) { warn("Sequence %s is not typed as protein... ignoring!\n",two->name); } evalfunc = default_aminoacid_ComplexSequenceEvalSet(); cone = new_ComplexSequence(one,evalfunc); if( cone == NULL ) goto cleanup; ctwo = new_ComplexSequence(two,evalfunc); if( ctwo == NULL ) goto cleanup; pal = PackAln_bestmemory_abc(cone,ctwo,comp,a,b,c,NULL,dpri); if( pal == NULL ) goto cleanup; alb = convert_PackAln_to_AlnBlock_abc(pal); goto cleanup; cleanup : if( cone != NULL ) free_ComplexSequence(cone); if( ctwo != NULL ) free_ComplexSequence(ctwo); if( pal != NULL ) free_PackAln(pal); if( evalfunc != NULL ) free_ComplexSequenceEvalSet(evalfunc); return alb; } /* Function: Align_Proteins_ABC(one,two,comp,a,b,c,dpenv,dpri) * * Descrip: Analogous to Align_Proteins_SmithWaterman for ABC model * * * Arg: one [UNKN ] protein to align [Protein *] * Arg: two [UNKN ] protein to align [Protein *] * Arg: comp [UNKN ] comparison matrix [CompMat *] * Arg: a [UNKN ] generalized affine gap cost a [int] * Arg: b [UNKN ] generalized affine gap cost b [int] * Arg: c [UNKN ] generalized affine gap cost c [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 301 "sw_wrap.dy" AlnBlock * Align_Proteins_ABC(Protein * one,Protein * two,CompMat * comp,int a,int b,int c,DPEnvelope * dpenv,DPRunImpl * dpri) { if( one == NULL || two == NULL || comp == NULL ) { warn("Passed in NULL objects into Align_Proteins_ABC!"); return NULL; } return Align_Sequences_ProteinABC(one->baseseq,two->baseseq,comp,a,b,c,dpenv,dpri); } /* Function: Align_Proteins_SmithWaterman(one,two,comp,gap,ext,dpenv,dpri) * * Descrip: This is the most correct way of aligning two Proteins, * using Protein objects, which can be assummed to be * proteins with no objections * * To display the alignment use write_pretty_Protein_align * * * * Arg: one [UNKN ] Protein to align [Protein *] * Arg: two [UNKN ] Protein to align [Protein *] * Arg: comp [UNKN ] Comparison Matrix [CompMat *] * Arg: gap [UNKN ] gap penalty [int] * Arg: ext [UNKN ] extension penalty [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 326 "sw_wrap.dy" AlnBlock * Align_Proteins_SmithWaterman(Protein * one,Protein * two,CompMat * comp,int gap,int ext,DPEnvelope * dpenv,DPRunImpl * dpri) { if( one == NULL || two == NULL || comp == NULL ) { warn("Passed in NULL objects into Align_Proteins_SmithWaterman!"); return NULL; } return Align_Sequences_ProteinSmithWaterman(one->baseseq,two->baseseq,comp,gap,ext,dpenv,dpri); } /* Function: Hscore_from_ProteinSW(querydb,targetdb,comp,gap,ext,bits_cutoff,report_level,die_on_error,dbsi) * * Descrip: Runs a database psw search * * * Arg: querydb [UNKN ] query database [ProteinDB*] * Arg: targetdb [UNKN ] target database [ProteinDB*] * Arg: comp [UNKN ] comparison matrix [CompMat*] * Arg: gap [UNKN ] gap penalty [int] * Arg: ext [UNKN ] extension penalty [int] * Arg: bits_cutoff [UNKN ] [double] * Arg: report_level [UNKN ] [int] * Arg: die_on_error [UNKN ] [boolean] * Arg: dbsi [UNKN ] [DBSearchImpl*] * * Return [UNKN ] Undocumented return value [Hscore *] * */ # line 350 "sw_wrap.dy" Hscore * Hscore_from_ProteinSW(ProteinDB* querydb,ProteinDB* targetdb,CompMat* comp,int gap,int ext,double bits_cutoff,int report_level,boolean die_on_error,DBSearchImpl* dbsi) { Hscore * out = NULL; Search_Return_Type ret; ret = SEARCH_ERROR; out = std_score_Hscore(bits_cutoff,report_level); if( dbsi == NULL ) { warn("Passed a NULL dbsi search implementaion object. Exiting without searching"); goto exit; } if( querydb == NULL ) { warn("Passed a NULL querydb. Exiting without searching"); goto exit; } if( targetdb == NULL ) { warn("Passed a NULL targetdb. Exiting without searching"); goto exit; } if( comp == NULL ) { warn("Passed a NULL comparison matrix. Exiting without searching"); goto exit; } ret = search_ProteinSW(dbsi,out,querydb,targetdb,comp,gap,ext); exit: return out; } /* Function: Hscore_from_ProteinABC(querydb,targetdb,comp,a,b,c,bits_cutoff,report_level,die_on_error,dbsi) * * Descrip: Runs a database abc search * * * Arg: querydb [UNKN ] query database [ProteinDB*] * Arg: targetdb [UNKN ] target database [ProteinDB*] * Arg: comp [UNKN ] comparison matrix [CompMat*] * Arg: a [UNKN ] generalized affine gap cost a [int] * Arg: b [UNKN ] generalized affine gap cost b [int] * Arg: c [UNKN ] generalized affine gap cost c [int] * Arg: bits_cutoff [UNKN ] [double] * Arg: report_level [UNKN ] [int] * Arg: die_on_error [UNKN ] [boolean] * Arg: dbsi [UNKN ] [DBSearchImpl*] * * Return [UNKN ] Undocumented return value [Hscore *] * */ # line 402 "sw_wrap.dy" Hscore * Hscore_from_ProteinABC(ProteinDB* querydb,ProteinDB* targetdb,CompMat* comp,int a,int b,int c,double bits_cutoff,int report_level,boolean die_on_error,DBSearchImpl* dbsi) { Hscore * out = NULL; Search_Return_Type ret; ret = SEARCH_ERROR; out = std_score_Hscore(bits_cutoff,report_level); if( dbsi == NULL ) { warn("Passed a NULL dbsi search implementaion object. Exiting without searching"); goto exit; } if( querydb == NULL ) { warn("Passed a NULL querydb. Exiting without searching"); goto exit; } if( targetdb == NULL ) { warn("Passed a NULL targetdb. Exiting without searching"); goto exit; } if( comp == NULL ) { warn("Passed a NULL comparison matrix. Exiting without searching"); goto exit; } ret = search_abc(dbsi,out,querydb,targetdb,comp,a,b,c); exit: return out; } /* Function: Hscore_from_ProteinBA(querydb,targetdb,comp,bentry,bexit,bfor_trans,b_self_trans,b3exit,bits_cutoff,report_level,dbsi) * * Descrip: Runs a database pba search * * * Arg: querydb [UNKN ] query database [ProteinDB*] * Arg: targetdb [UNKN ] target database [ProteinDB*] * Arg: comp [UNKN ] comparison matrix [CompMat*] * Arg: bentry [UNKN ] [Score] * Arg: bexit [UNKN ] [Score] * Arg: bfor_trans [UNKN ] [Score] * Arg: b_self_trans [UNKN ] [Score] * Arg: b3exit [UNKN ] [Score] * Arg: bits_cutoff [UNKN ] [double] * Arg: report_level [UNKN ] [int] * Arg: dbsi [UNKN ] [DBSearchImpl*] * * Return [UNKN ] Undocumented return value [Hscore *] * */ # line 455 "sw_wrap.dy" Hscore * Hscore_from_ProteinBA(ProteinDB* querydb,ProteinDB* targetdb,CompMat* comp,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit,double bits_cutoff,int report_level,DBSearchImpl* dbsi) { Hscore * out = NULL; Search_Return_Type ret; ret = SEARCH_ERROR; out = std_score_Hscore(bits_cutoff,report_level); if( dbsi == NULL ) { warn("Passed a NULL dbsi search implementaion object. Exiting without searching"); goto exit; } if( querydb == NULL ) { warn("Passed a NULL querydb. Exiting without searching"); goto exit; } if( targetdb == NULL ) { warn("Passed a NULL targetdb. Exiting without searching"); goto exit; } if( comp == NULL ) { warn("Passed a NULL comparison matrix. Exiting without searching"); goto exit; } ret = search_ProteinBlockAligner(dbsi,out,querydb,targetdb,comp,bentry,bexit,bfor_trans,b_self_trans,b3exit); exit: return out; } # line 521 "sw_wrap.c" #ifdef _cplusplus } #endif wise-2.4.1/src/models/sw_wrap.h0000644000175000001440000002464010670453715015774 0ustar philippusers#ifndef DYNAMITEsw_wrapHEADERFILE #define DYNAMITEsw_wrapHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "proteinsw.h" #include "abc.h" #include "pba.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: Align_strings_ProteinSmithWaterman(one,two,comp,gap,ext,dpenv,dpri) * * Descrip: This is the most *stupidly* abstracted view of two sequences * getting aligned, being two strings. * * It would be much better if you used Sequence objects or Protein * objects to carry the proteins. * * * Arg: one [UNKN ] string of the first sequence [char *] * Arg: two [UNKN ] string of the second sequence [char *] * Arg: comp [UNKN ] Comparison Matrix [CompMat *] * Arg: gap [UNKN ] gap penalty [int] * Arg: ext [UNKN ] extension penalty [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_Align_strings_ProteinSmithWaterman(char * one,char * two,CompMat * comp,int gap,int ext,DPEnvelope * dpenv,DPRunImpl * dpri); #define Align_strings_ProteinSmithWaterman Wise2_Align_strings_ProteinSmithWaterman /* Function: Align_Sequences_ProteinSmithWaterman(one,two,comp,gap,ext,dpenv,dpri) * * Descrip: This function is a mid-level abstraction of * comparing two sequences, which could be * generic types (eg DNA!). This is tested * for and warnings are given but the alignment * is still calculated. To prevent this test * warning either make sure the Sequence types * are set to PROTEIN or, better still, use the * high level abstraction Align_Proteins_SmithWaterman * * Otherwise this performs a standard smith waterman * protein alignment... * * To display the alignment use write_pretty_seq_align * * * Arg: one [READ ] First sequence to compare [Sequence *] * Arg: two [READ ] Second sequecne to compare [Sequence *] * Arg: comp [READ ] Comparison matrix to use [CompMat *] * Arg: gap [UNKN ] gap penalty. Must be negative or 0 [int] * Arg: ext [UNKN ] ext penalty. Must be negative or 0 [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [OWNER] new AlnBlock structure representing the alignment [AlnBlock *] * */ AlnBlock * Wise2_Align_Sequences_ProteinSmithWaterman(Sequence * one,Sequence * two,CompMat * comp,int gap,int ext,DPEnvelope * dpenv,DPRunImpl * dpri); #define Align_Sequences_ProteinSmithWaterman Wise2_Align_Sequences_ProteinSmithWaterman /* Function: Align_Sequences_ProteinBlockAligner(one,two,comp,bentry,bexit,b1exit,b_self,b_on,dpenv,dpri) * * Descrip: This is a way of aligning two sequences using * the ProteinBlockAligner algorithm * * * * Arg: one [UNKN ] Sequence to align [Sequence *] * Arg: two [UNKN ] Sequence to align [Sequence *] * Arg: comp [UNKN ] Comparison Matrix [CompMat *] * Arg: bentry [UNKN ] entry into a block [int] * Arg: bexit [UNKN ] exit for a block [int] * Arg: b1exit [UNKN ] exit for a block of length one [int] * Arg: b_self [UNKN ] self transition [int] * Arg: b_on [UNKN ] onwards transition [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_Align_Sequences_ProteinBlockAligner(Sequence * one,Sequence * two,CompMat * comp,int bentry,int bexit,int b1exit,int b_self,int b_on,DPEnvelope * dpenv,DPRunImpl * dpri); #define Align_Sequences_ProteinBlockAligner Wise2_Align_Sequences_ProteinBlockAligner /* Function: Align_Sequences_ProteinABC(one,two,comp,a,b,c,dpenv,dpri) * * Descrip: Align_Sequences_ProteinABC * this function is analogous to Align_Sequences_ProteinSmithWaterman * but using the abc model * * * Arg: one [UNKN ] Sequence to align [Sequence *] * Arg: two [UNKN ] Sequence to align [Sequence *] * Arg: comp [UNKN ] Comparison Matrix [CompMat *] * Arg: a [UNKN ] genearlized affine gap cost [int] * Arg: b [UNKN ] genearlized affine gap cost [int] * Arg: c [UNKN ] genearlized affine gap cost [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_Align_Sequences_ProteinABC(Sequence * one,Sequence * two,CompMat * comp,int a, int b, int c,DPEnvelope * dpenv,DPRunImpl * dpri); #define Align_Sequences_ProteinABC Wise2_Align_Sequences_ProteinABC /* Function: Align_Proteins_ABC(one,two,comp,a,b,c,dpenv,dpri) * * Descrip: Analogous to Align_Proteins_SmithWaterman for ABC model * * * Arg: one [UNKN ] protein to align [Protein *] * Arg: two [UNKN ] protein to align [Protein *] * Arg: comp [UNKN ] comparison matrix [CompMat *] * Arg: a [UNKN ] generalized affine gap cost a [int] * Arg: b [UNKN ] generalized affine gap cost b [int] * Arg: c [UNKN ] generalized affine gap cost c [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_Align_Proteins_ABC(Protein * one,Protein * two,CompMat * comp,int a,int b,int c,DPEnvelope * dpenv,DPRunImpl * dpri) ; #define Align_Proteins_ABC Wise2_Align_Proteins_ABC /* Function: Align_Proteins_SmithWaterman(one,two,comp,gap,ext,dpenv,dpri) * * Descrip: This is the most correct way of aligning two Proteins, * using Protein objects, which can be assummed to be * proteins with no objections * * To display the alignment use write_pretty_Protein_align * * * * Arg: one [UNKN ] Protein to align [Protein *] * Arg: two [UNKN ] Protein to align [Protein *] * Arg: comp [UNKN ] Comparison Matrix [CompMat *] * Arg: gap [UNKN ] gap penalty [int] * Arg: ext [UNKN ] extension penalty [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_Align_Proteins_SmithWaterman(Protein * one,Protein * two,CompMat * comp,int gap,int ext,DPEnvelope * dpenv,DPRunImpl * dpri); #define Align_Proteins_SmithWaterman Wise2_Align_Proteins_SmithWaterman /* Function: Hscore_from_ProteinSW(querydb,targetdb,comp,gap,ext,bits_cutoff,report_level,die_on_error,dbsi) * * Descrip: Runs a database psw search * * * Arg: querydb [UNKN ] query database [ProteinDB*] * Arg: targetdb [UNKN ] target database [ProteinDB*] * Arg: comp [UNKN ] comparison matrix [CompMat*] * Arg: gap [UNKN ] gap penalty [int] * Arg: ext [UNKN ] extension penalty [int] * Arg: bits_cutoff [UNKN ] [double] * Arg: report_level [UNKN ] [int] * Arg: die_on_error [UNKN ] [boolean] * Arg: dbsi [UNKN ] [DBSearchImpl*] * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * Wise2_Hscore_from_ProteinSW(ProteinDB* querydb,ProteinDB* targetdb,CompMat* comp,int gap,int ext,double bits_cutoff,int report_level,boolean die_on_error,DBSearchImpl* dbsi); #define Hscore_from_ProteinSW Wise2_Hscore_from_ProteinSW /* Function: Hscore_from_ProteinABC(querydb,targetdb,comp,a,b,c,bits_cutoff,report_level,die_on_error,dbsi) * * Descrip: Runs a database abc search * * * Arg: querydb [UNKN ] query database [ProteinDB*] * Arg: targetdb [UNKN ] target database [ProteinDB*] * Arg: comp [UNKN ] comparison matrix [CompMat*] * Arg: a [UNKN ] generalized affine gap cost a [int] * Arg: b [UNKN ] generalized affine gap cost b [int] * Arg: c [UNKN ] generalized affine gap cost c [int] * Arg: bits_cutoff [UNKN ] [double] * Arg: report_level [UNKN ] [int] * Arg: die_on_error [UNKN ] [boolean] * Arg: dbsi [UNKN ] [DBSearchImpl*] * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * Wise2_Hscore_from_ProteinABC(ProteinDB* querydb,ProteinDB* targetdb,CompMat* comp,int a,int b,int c,double bits_cutoff,int report_level,boolean die_on_error,DBSearchImpl* dbsi); #define Hscore_from_ProteinABC Wise2_Hscore_from_ProteinABC /* Function: Hscore_from_ProteinBA(querydb,targetdb,comp,bentry,bexit,bfor_trans,b_self_trans,b3exit,bits_cutoff,report_level,dbsi) * * Descrip: Runs a database pba search * * * Arg: querydb [UNKN ] query database [ProteinDB*] * Arg: targetdb [UNKN ] target database [ProteinDB*] * Arg: comp [UNKN ] comparison matrix [CompMat*] * Arg: bentry [UNKN ] [Score] * Arg: bexit [UNKN ] [Score] * Arg: bfor_trans [UNKN ] [Score] * Arg: b_self_trans [UNKN ] [Score] * Arg: b3exit [UNKN ] [Score] * Arg: bits_cutoff [UNKN ] [double] * Arg: report_level [UNKN ] [int] * Arg: dbsi [UNKN ] [DBSearchImpl*] * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * Wise2_Hscore_from_ProteinBA(ProteinDB* querydb,ProteinDB* targetdb,CompMat* comp,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit,double bits_cutoff,int report_level,DBSearchImpl* dbsi); #define Hscore_from_ProteinBA Wise2_Hscore_from_ProteinBA /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/estslimloop.dy0000644000175000001440000000746707313404544017055 0ustar philippusers/* Last edited: Apr 24 15:04 1997 (birney) */ %{ #include "dyna.h" #include "cdparser.h" #include "genewisemodel.h" #include "genewisemodeldb.h" %} matrix EstSlimLoop3 query type="CDNA_HMM" name="query" field:len="len" target type="CDNA" name="target" resource type="cDNAParserScore *" name="cp" extern name="GW_*" type="int" extern name="PCD_*" type="int" state MATCH offi="1" offj="3" source MATCH calc="query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source LOOP calc="query->seg[i]->transition[GW_START2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource # # Sequencing error transitions, at offsets 2,4 for speed up # source MATCH offi="1" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource query_label MATCH_STATE target_label CODON endstate # # Insert state: does not move along model, produces DNA sequence... # state INSERT offi="0" offj="3" source MATCH calc="query->seg[i]->transition[GW_MATCH2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source LOOP calc="query->seg[i]->transition[GW_START2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource # # Sequencing error transitions at only 2,4 for speed up # source INSERT offi="0" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="query->seg[i]->transition[GW_MATCH2DELETE]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2DELETE]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2DELETE]" endsource source START calc="query->seg[i]->transition[GW_START2DELETE]" endsource query_label DELETE_STATE target_label INSERT endstate state LOOP !special source START offj="1" !left calc="0" endsource source MATCH calc="query->seg[i]->transition[GW_MATCH2END]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2END]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2END]" endsource source LOOP offj="1" calc="0" endsource target_label RANDOM_SEQUENCE query_label LOOP endstate state START !start !special endstate state END !end !special source LOOP !right offj="1" calc="0" endsource source MATCH calc="query->seg[i]->transition[GW_MATCH2END]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2END]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2END]" endsource target_label END query_label END endstate # collapse labels collapse LOOP RANDOM_SEQUENCE endmatrix wise-2.4.1/src/models/dnahmm.dy0000644000175000001440000000763507547571136015757 0ustar philippusers %{ #include "dyna.h" enum dhmm_trans_type { DHMM_MATCH2MATCH = 0, DHMM_MATCH2INSERT, DHMM_MATCH2DELETE, DHMM_INSERT2MATCH, DHMM_INSERT2INSERT, DHMM_INSERT2DELETE, DHMM_DELETE2MATCH, DHMM_DELETE2INSERT, DHMM_DELETE2DELETE, DHMM_START2MATCH, DHMM_START2INSERT, DHMM_START2DELETE, DHMM_MATCH2END, DHMM_INSERT2END, DHMM_DELETE2END, DHMM_TRANSITION_LEN }; #define DNA_HMM_ALPHABET 5 #define DnaHmmProbLISTLENGTH 64 #define DnaHmmScoreLISTLENGTH 64 %} struct DnaHmmProbUnit Probability match[DNA_HMM_ALPHABET] Probability insert[DNA_HMM_ALPHABET] Probability transition[DHMM_TRANSITION_LEN] struct DnaHmmProb DnaHmmProbUnit ** unit !list SeqAlign * ref_align char * consensus; struct DnaHmmScoreUnit Score match[DNA_HMM_ALPHABET] Score insert[DNA_HMM_ALPHABET] Score transition[DHMM_TRANSITION_LEN] struct DnaHmmScore DnaHmmScoreUnit ** unit !list SeqAlign * ref_align %{ #include "dnahmm.h" DnaHmmScore * DnaHmmScore_from_DnaHmmProb(DnaHmmProb * dhp) { int i; DnaHmmScore * out; out = DnaHmmScore_alloc_len(dhp->len); for(i=0;ilen;i++) { add_DnaHmmScore(out,DnaHmmScoreUnit_from_DnaHmmProbUnit(dhp->unit[i])); } return out; } void make_consensus_DnaHmmProb(DnaHmmProb * dhp) { int i; int j; double prob_max; int base; dhp->consensus = calloc(dhp->len+1,sizeof(char)); for(i=0;ilen;i++) { prob_max = -1.0; for(j=0;j<4;j++) { if( dhp->unit[i]->match[j] > prob_max ) { prob_max = dhp->unit[i]->match[j]; base = j; } } if( prob_max > 0.5 ) { dhp->consensus[i] = char_from_base(base); } else if ( prob_max > 0.3 ) { dhp->consensus[i] = tolower(char_from_base(base)); } else { dhp->consensus[i] = '.'; } } dhp->consensus[i] = '\0'; } DnaHmmScoreUnit * DnaHmmScoreUnit_from_DnaHmmProbUnit(DnaHmmProbUnit * dpu) { DnaHmmScoreUnit * out; out = DnaHmmScoreUnit_alloc(); Probability2Score_move(dpu->match,out->match,DNA_HMM_ALPHABET); Probability2Score_move(dpu->insert,out->insert,DNA_HMM_ALPHABET); Probability2Score_move(dpu->transition,out->transition,DHMM_TRANSITION_LEN); return out; } DnaHmmProb * new_DnaHmmProb_from_SeqAlign_ungapped(SeqAlign * sa,double simple_pseudocount) { DnaHmmProb * out; ColumnCount * cc; int i; assert(sa); out = DnaHmmProb_alloc_std(); out->ref_align = hard_link_SeqAlign(sa); for(i=0;iseq[0]->len;i++) { cc = ColumnCount_from_SeqAlign(sa,i); add_DnaHmmProb(out,new_DnaHmmProbUnit_from_ColumnCount_ungapped(cc,simple_pseudocount)); free_ColumnCount(cc); } out->unit[0]->transition[DHMM_START2MATCH] = 1.0; out->unit[out->len-1]->transition[DHMM_MATCH2END] = 1.0; return out; } DnaHmmProbUnit * new_DnaHmmProbUnit_from_ColumnCount_ungapped(ColumnCount * cc,double simple_pseudocount) { DnaHmmProbUnit * out; double total; char base[] = "ATGC"; int i; out = DnaHmmProbUnit_alloc(); for(i=0,total = 0.0;i<4;i++) total += (cc->count[base[i]-'A'] + simple_pseudocount); for(i=0;i<4;i++) out->match[base_from_char(base[i])] = (cc->count[base[i]-'A'] + simple_pseudocount) / total; out->match[4] = 1.0; for(i=0;itransition[i] = 0.0; } out->transition[DHMM_MATCH2MATCH] = 1.0; return out; } void set_N_DnaHmmProb(DnaHmmProb * dhp,Probability basen) { int i; for(i=0;ilen;i++) { dhp->unit[i]->match[BASE_N] = basen; dhp->unit[i]->insert[BASE_N] = basen; } } void fold_RandomModelDNA_DnaHmmProb(DnaHmmProb * dhp,RandomModelDNA * d,Probability rnd_advance) { int i; int j; for(i=0;ilen;i++) { for(j=0;junit[i]->match[j] = dhp->unit[i]->match[j] / d->base[j]; dhp->unit[i]->insert[j] = dhp->unit[i]->insert[j] / d->base[j]; } for(j=0;junit[i]->transition[j] = dhp->unit[i]->transition[j] / rnd_advance; } } } %} wise-2.4.1/src/models/seqaligndisplay.pod0000644000175000001440000000414010670453715020027 0ustar philippusers=head1 NAME seqaligndisplay module - part of the Wise2 package =head1 SYNOPSIS This module contains helper functions for the Wise2 package =head1 DESCRIPTION =over =item write_pretty_str_align &Wise2::write_pretty_str_align(alb,qname,query,tname,target,name,main,ofp) This gives an interface into the alignment display using strings and files. Argument alb [UNKN ] alignment structure [AlnBlock *] Argument qname [UNKN ] name of first sequence [char *] Argument query [UNKN ] first sequence [char *] Argument tname [UNKN ] name of second sequence [char *] Argument target [UNKN ] second sequence [char *] Argument name [UNKN ] length of the name block [int] Argument main [UNKN ] length of the main block [int] Argument ofp [UNKN ] output file [FILE *] Return [UNKN ] Undocumented return value [boolean] =item write_pretty_seq_align &Wise2::write_pretty_seq_align(alb,q,t,name,main,ofp) This gives an interface into the alignment display using sequences and files. A more generic function is write_pretty_str_align Argument alb [UNKN ] alignment structure [AlnBlock *] Argument q [UNKN ] first sequence [Sequence *] Argument t [UNKN ] second sequence [Sequence *] Argument name [UNKN ] length of the name block [int] Argument main [UNKN ] length of the main block [int] Argument ofp [UNKN ] output file [FILE *] Return [UNKN ] Undocumented return value [boolean] =item write_pretty_Protein_align &Wise2::write_pretty_Protein_align(alb,q,t,name,main,ofp) This gives an interface into the alignment display using Protein objects Argument alb [UNKN ] alignment structure [AlnBlock *] Argument q [UNKN ] first sequence [Protein *] Argument t [UNKN ] second sequence [Protein *] Argument name [UNKN ] length of the name block [int] Argument main [UNKN ] length of the main block [int] Argument ofp [UNKN ] output file [FILE *] Return [UNKN ] Undocumented return value [boolean] =back wise-2.4.1/src/models/seqaligndisplay.tex0000644000175000001440000000462410670453715020054 0ustar philippusers\section{seqaligndisplay} \label{module_seqaligndisplay} This module only contains factory methods \subsection{seqaligndisplay factory methods} \subsubsection{write_pretty_str_align} \begin{description} \item[External C] {\tt Wise2_write_pretty_str_align (alb,qname,query,tname,target,name,main,ofp)} \item[Perl] {\tt &Wise2::write_pretty_str_align (alb,qname,query,tname,target,name,main,ofp)} \end{description} Arguments \begin{description} \item[alb] [UNKN ] alignment structure [AlnBlock *] \item[qname] [UNKN ] name of first sequence [char *] \item[query] [UNKN ] first sequence [char *] \item[tname] [UNKN ] name of second sequence [char *] \item[target] [UNKN ] second sequence [char *] \item[name] [UNKN ] length of the name block [int] \item[main] [UNKN ] length of the main block [int] \item[ofp] [UNKN ] output file [FILE *] \item[returns] [UNKN ] Undocumented return value [boolean] \end{description} This gives an interface into the alignment display using strings and files. \subsubsection{write_pretty_seq_align} \begin{description} \item[External C] {\tt Wise2_write_pretty_seq_align (alb,q,t,name,main,ofp)} \item[Perl] {\tt &Wise2::write_pretty_seq_align (alb,q,t,name,main,ofp)} \end{description} Arguments \begin{description} \item[alb] [UNKN ] alignment structure [AlnBlock *] \item[q] [UNKN ] first sequence [Sequence *] \item[t] [UNKN ] second sequence [Sequence *] \item[name] [UNKN ] length of the name block [int] \item[main] [UNKN ] length of the main block [int] \item[ofp] [UNKN ] output file [FILE *] \item[returns] [UNKN ] Undocumented return value [boolean] \end{description} This gives an interface into the alignment display using sequences and files. A more generic function is write_pretty_str_align \subsubsection{write_pretty_Protein_align} \begin{description} \item[External C] {\tt Wise2_write_pretty_Protein_align (alb,q,t,name,main,ofp)} \item[Perl] {\tt &Wise2::write_pretty_Protein_align (alb,q,t,name,main,ofp)} \end{description} Arguments \begin{description} \item[alb] [UNKN ] alignment structure [AlnBlock *] \item[q] [UNKN ] first sequence [Protein *] \item[t] [UNKN ] second sequence [Protein *] \item[name] [UNKN ] length of the name block [int] \item[main] [UNKN ] length of the main block [int] \item[ofp] [UNKN ] output file [FILE *] \item[returns] [UNKN ] Undocumented return value [boolean] \end{description} This gives an interface into the alignment display using Protein objects wise-2.4.1/src/models/genefrequency_api.h0000644000175000001440000002606610670453714020006 0ustar philippusers /* Functions that create, manipulate or act on GeneFrequency21 * * Wise2_hard_link_GeneFrequency21 * Wise2_GeneFrequency21_alloc * Wise2_replace_ss5_GeneFrequency21 * Wise2_access_ss5_GeneFrequency21 * Wise2_replace_ss3_GeneFrequency21 * Wise2_access_ss3_GeneFrequency21 * Wise2_free_GeneFrequency21 [destructor] * */ /* Functions that create, manipulate or act on GeneConsensus * * Wise2_hard_link_GeneConsensus * Wise2_GeneConsensus_alloc_std * Wise2_replace_center_GeneConsensus * Wise2_access_center_GeneConsensus * Wise2_access_gsc_GeneConsensus * Wise2_length_gsc_GeneConsensus * Wise2_flush_GeneConsensus * Wise2_add_GeneConsensus * Wise2_free_GeneConsensus [destructor] * */ /* Functions that create, manipulate or act on GeneSingleCons * * Wise2_hard_link_GeneSingleCons * Wise2_GeneSingleCons_alloc * Wise2_replace_string_GeneSingleCons * Wise2_access_string_GeneSingleCons * Wise2_replace_number_GeneSingleCons * Wise2_access_number_GeneSingleCons * Wise2_free_GeneSingleCons [destructor] * */ /* Helper functions in the module * * Wise2_read_GeneFrequency21_file * Wise2_read_GeneFrequency21 * /* API for object GeneFrequency21 */ /* Function: Wise2_hard_link_GeneFrequency21(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_GeneFrequency21 *] * * Returns Undocumented return value [Wise2_GeneFrequency21 *] * */ Wise2_GeneFrequency21 * Wise2_hard_link_GeneFrequency21( Wise2_GeneFrequency21 * obj); /* Function: Wise2_GeneFrequency21_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_GeneFrequency21 *] * */ Wise2_GeneFrequency21 * Wise2_GeneFrequency21_alloc(); /* Function: Wise2_replace_ss5_GeneFrequency21(obj,ss5) * * Descrip: Replace member variable ss5 * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GeneFrequency21 *] * Arg: ss5 New value of the variable [Wise2_GeneConsensus *] * * Returns member variable ss5 [boolean] * */ boolean Wise2_replace_ss5_GeneFrequency21( Wise2_GeneFrequency21 * obj,Wise2_GeneConsensus * ss5); /* Function: Wise2_access_ss5_GeneFrequency21(obj) * * Descrip: Access member variable ss5 * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GeneFrequency21 *] * * Returns member variable ss5 [Wise2_GeneConsensus *] * */ Wise2_GeneConsensus * Wise2_access_ss5_GeneFrequency21( Wise2_GeneFrequency21 * obj); /* Function: Wise2_replace_ss3_GeneFrequency21(obj,ss3) * * Descrip: Replace member variable ss3 * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GeneFrequency21 *] * Arg: ss3 New value of the variable [Wise2_GeneConsensus *] * * Returns member variable ss3 [boolean] * */ boolean Wise2_replace_ss3_GeneFrequency21( Wise2_GeneFrequency21 * obj,Wise2_GeneConsensus * ss3); /* Function: Wise2_access_ss3_GeneFrequency21(obj) * * Descrip: Access member variable ss3 * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GeneFrequency21 *] * * Returns member variable ss3 [Wise2_GeneConsensus *] * */ Wise2_GeneConsensus * Wise2_access_ss3_GeneFrequency21( Wise2_GeneFrequency21 * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_GeneFrequency21(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_GeneFrequency21 *] * * Returns Undocumented return value [Wise2_GeneFrequency21 *] * */ Wise2_GeneFrequency21 * Wise2_free_GeneFrequency21( Wise2_GeneFrequency21 * obj); /* API for object GeneConsensus */ /* Function: Wise2_hard_link_GeneConsensus(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_GeneConsensus *] * * Returns Undocumented return value [Wise2_GeneConsensus *] * */ Wise2_GeneConsensus * Wise2_hard_link_GeneConsensus( Wise2_GeneConsensus * obj); /* Function: Wise2_GeneConsensus_alloc_std(void) * * Descrip: Equivalent to GeneConsensus_alloc_len(GeneConsensusLISTLENGTH) * * * * Returns Undocumented return value [Wise2_GeneConsensus *] * */ Wise2_GeneConsensus * Wise2_GeneConsensus_alloc_std(); /* Function: Wise2_replace_center_GeneConsensus(obj,center) * * Descrip: Replace member variable center * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GeneConsensus *] * Arg: center New value of the variable [int] * * Returns member variable center [boolean] * */ boolean Wise2_replace_center_GeneConsensus( Wise2_GeneConsensus * obj,int center); /* Function: Wise2_access_center_GeneConsensus(obj) * * Descrip: Access member variable center * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GeneConsensus *] * * Returns member variable center [int] * */ int Wise2_access_center_GeneConsensus( Wise2_GeneConsensus * obj); /* Function: Wise2_access_gsc_GeneConsensus(obj,i) * * Descrip: Access members stored in the gsc list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_GeneConsensus *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_GeneSingleCons *] * */ Wise2_GeneSingleCons * Wise2_access_gsc_GeneConsensus( Wise2_GeneConsensus * obj,int i); /* Function: Wise2_length_gsc_GeneConsensus(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_GeneConsensus *] * * Returns length of the list [int] * */ int Wise2_length_gsc_GeneConsensus( Wise2_GeneConsensus * obj); /* Function: Wise2_flush_GeneConsensus(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_GeneConsensus *] * * Returns Undocumented return value [int] * */ int Wise2_flush_GeneConsensus( Wise2_GeneConsensus * obj); /* Function: Wise2_add_GeneConsensus(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_GeneConsensus *] * Arg: add Object to add to the list [Wise2_GeneSingleCons *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_GeneConsensus( Wise2_GeneConsensus * obj,Wise2_GeneSingleCons * add); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_GeneConsensus(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_GeneConsensus *] * * Returns Undocumented return value [Wise2_GeneConsensus *] * */ Wise2_GeneConsensus * Wise2_free_GeneConsensus( Wise2_GeneConsensus * obj); /* API for object GeneSingleCons */ /* Function: Wise2_hard_link_GeneSingleCons(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_GeneSingleCons *] * * Returns Undocumented return value [Wise2_GeneSingleCons *] * */ Wise2_GeneSingleCons * Wise2_hard_link_GeneSingleCons( Wise2_GeneSingleCons * obj); /* Function: Wise2_GeneSingleCons_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_GeneSingleCons *] * */ Wise2_GeneSingleCons * Wise2_GeneSingleCons_alloc(); /* Function: Wise2_replace_string_GeneSingleCons(obj,string) * * Descrip: Replace member variable string * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GeneSingleCons *] * Arg: string New value of the variable [char *] * * Returns member variable string [boolean] * */ boolean Wise2_replace_string_GeneSingleCons( Wise2_GeneSingleCons * obj,char * string); /* Function: Wise2_access_string_GeneSingleCons(obj) * * Descrip: Access member variable string * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GeneSingleCons *] * * Returns member variable string [char *] * */ char * Wise2_access_string_GeneSingleCons( Wise2_GeneSingleCons * obj); /* Function: Wise2_replace_number_GeneSingleCons(obj,number) * * Descrip: Replace member variable number * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GeneSingleCons *] * Arg: number New value of the variable [double] * * Returns member variable number [boolean] * */ boolean Wise2_replace_number_GeneSingleCons( Wise2_GeneSingleCons * obj,double number); /* Function: Wise2_access_number_GeneSingleCons(obj) * * Descrip: Access member variable number * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GeneSingleCons *] * * Returns member variable number [double] * */ double Wise2_access_number_GeneSingleCons( Wise2_GeneSingleCons * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_GeneSingleCons(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_GeneSingleCons *] * * Returns Undocumented return value [Wise2_GeneSingleCons *] * */ Wise2_GeneSingleCons * Wise2_free_GeneSingleCons( Wise2_GeneSingleCons * obj); /* These functions are not associated with an object */ /* Function: Wise2_read_GeneFrequency21_file(filename) * * Descrip: Opens the file with /openfile * * Reads in a GeneFrequency (Mor-Ewan style) * * * * Arg: filename will open from WISECONFIGDIR etc via openfile [char *] * * Returns a newly allocated structure [Wise2_GeneFrequency21 *] * */ Wise2_GeneFrequency21 * Wise2_read_GeneFrequency21_file( char * filename); /* Function: Wise2_read_GeneFrequency21(ifp) * * Descrip: Reads in a GeneFrequency (Mor-Ewan style) * file from ifp * * * Arg: ifp file pointer [FILE *] * * Returns a newly allocated structure [Wise2_GeneFrequency21 *] * */ Wise2_GeneFrequency21 * Wise2_read_GeneFrequency21( FILE * ifp); wise-2.4.1/src/models/genefrequency_api.t0000644000175000001440000000026110670453714020007 0ustar philippuserstypedef struct Wise2_GeneFrequency21 Wise2_GeneFrequency21; typedef struct Wise2_GeneConsensus Wise2_GeneConsensus; typedef struct Wise2_GeneSingleCons Wise2_GeneSingleCons; wise-2.4.1/src/models/splicesitemodeler.dy0000644000175000001440000000763607313404547020220 0ustar philippusers/* Last edited: Jan 12 14:16 1997 (birney) */ %{ #include "dyna.h" #include "randommodel.h" #define SPLICESITEMODELER_TYPE 474 %} struct SpliceSiteModel int offset int pre_splice_site int post_splice_site int start_random; int stop_random; ComplexConsensi * cc; RandomModelDNAScore * rmds; Score error_pos; %{ #include "splicesitemodeler.h" int SpliceSiteModeler_ComplexSequence_eval_func(int type,void * data,char * seq) { if( type != SPLICESITEMODELER_TYPE ) { warn("In evaluating a ComplexSequence Eval function using a SpliceSite modeler, the type was wrong. This is a bad bug, indicating a bad data problem which will probably repeat"); } return SpliceSiteModel_score((SpliceSiteModel *) data,seq); } ComplexSequenceEval * ComplexSequenceEval_from_SpliceSiteModel(SpliceSiteModel * ssm) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); /* shouldn't really add ones, but this is ok anyway. Yukky hack due to not understanding a bug in the window determination */ /* out->left_window = ssm->offset + ssm->pre_splice_site +1; */ out->left_window = 11; /* out->right_window = ssm->offset + ssm->post_splice_site +1; */ out->right_window = 8; out->outside_score= NEGI; out->data_type = SPLICESITEMODELER_TYPE; out->data = ssm; out->type = SEQUENCE_GENOMIC; out->eval_func = SpliceSiteModeler_ComplexSequence_eval_func; return out; } /*** This *must* have been passed a *seq with appropiate lengths on the left and right otherwise there is going to be tears! Really this function is only to be called from trusted function, for example, SpliceSite_ComplexSequence_eval ***/ Score SpliceSiteModel_score(SpliceSiteModel * ssm,char * seq) { int len; int i; int score; char * be = seq; base b; /* check I have enough sequence */ /* fprintf(stderr,"Being passed sequence %c%c%c\n",seq[0],seq[1],seq[2]); */ /* first calculate the CC score */ score = score_from_ComplexConsensi(seq- ssm->offset - ssm->pre_splice_site,ssm->cc); /* now move over the random score */ /* random score is subtracted - ie divided */ /* out from the model */ len = ssm->start_random - ssm->stop_random +1; for(i=0,seq = seq - ssm->start_random+1;irmds->base[b]; } /* this is for the possibility of errors/non splice consensus etc */ if( score < ssm->error_pos ) score = ssm->error_pos; return score; } SpliceSiteModel * std_5SS_SpliceSiteModel(int offset,ComplexConsensi * cc,RandomModelDNAScore * rmds) { return new_SpliceSiteModel(offset,3,7,7,0,cc,rmds,0.0000001); } SpliceSiteModel * std_3SS_SpliceSiteModel(int offset,ComplexConsensi * cc,RandomModelDNAScore * rmds) { /** mystical -1 everywhere because naturally we call caGcag - G as being the 3' SS however, if you think about it, it is the cacCag which is really the 3'SS (the residue after the splice site). Rather than enforcing these rules in the calling function, we subtract one from the offset here **/ return new_SpliceSiteModel(offset-1,3,3,offset+2,offset-1,cc,rmds,0.0000001); } SpliceSiteModel * new_SpliceSiteModel(int offset,int pre_length,int post_length,int start,int stop,ComplexConsensi * cc,RandomModelDNAScore * rmds,Probability error) { SpliceSiteModel * out; out = SpliceSiteModel_alloc(); if( out == NULL ) return NULL; out->offset = offset; out->pre_splice_site = pre_length; out->post_splice_site = post_length; out->start_random = start; out->stop_random = stop; out->cc = hard_link_ComplexConsensi(cc); out->rmds = hard_link_RandomModelDNAScore(rmds); out->error_pos = Probability2Score(error); return out; } %} wise-2.4.1/src/models/genedisplay.dy0000644000175000001440000004144710577565051017012 0ustar philippusers %{ #include "dyna.h" #include "geneutil.h" %} api func protein2genomic_ascii_display func protcdna_ascii_display endapi %{ #include "genedisplay.h" /** #define DEBUG **/ %func shows the alignment in alb between protsequence and protname with genomic into ofp with pretty formatting %arg alb logical alignment p protein sequence gen genomic dna to do the comparison ct codon table for translation name length of name block main length of main block ofp output file %% boolean protein2genomic_ascii_display(AlnBlock * alb,Protein * p,Genomic * gen,CodonTable * ct,int name,int main,FILE * ofp) { return protgene_ascii_display(alb,p->baseseq->seq,p->baseseq->name,p->baseseq->offset,gen,ct,name,main,FALSE,ofp); } %func shows the alignment in alb between protsequence and protname with genomic into ofp with pretty formatting %arg alb logical alignment protsequence protein sequence - either real or an artifical consensus protname name of the protein protoff offset of the alb from the protein gen genomic dna to do the comparison ct codon table for translation name length of name block main length of main block mult ? is multi-match ofp output file %% boolean protgene_ascii_display(AlnBlock * alb,char * protsequence,char * protname,int protoff,Genomic * gen,CodonTable * ct,int name,int main,boolean mult,FILE * ofp) { boolean ret; btCanvas * btc; btc = new_Ascii_btCanvas(ofp,name+6,main,0,6); ret = protdna_btc_display(alb,protsequence,protname,protoff,gen->baseseq,ct,name,main,btc,match_central_line_std,mult); free_btCanvas(btc); return ret; } %func shows the alignment in alb between protsequence and protname with cdna into ofp with pretty formatting %arg alb logical alignment protsequence protein sequence - either real or an artifical consensus protname name of the protein protoff offset of the alb from the protein cdna cdna of the match ct codon table for translation name length of name block main length of main block mult ? is multi-match ofp output file %% boolean protcdna_ascii_display(AlnBlock * alb,char * protsequence,char * protname,int protoff,cDNA * cdna,CodonTable * ct,int name,int main,boolean mult,FILE * ofp) { boolean ret; btCanvas * btc; btc = new_Ascii_btCanvas(ofp,name+6,main,0,6); ret = protdna_btc_display(alb,protsequence,protname,protoff,cdna->baseseq,ct,name,main,btc,match_central_line_std,mult); free_btCanvas(btc); return ret; } char match_central_line_std(char hmm,int score,char seq) { if( hmm == seq ) { return hmm; } if( score <= 0 ) { return ' '; } return '+'; } boolean protdna_btc_display(AlnBlock * alb,char * protsequence,char * protname_in,int protoff,Sequence * dna,CodonTable * ct,int name,int main,btCanvas * btc,char (*match_central_line)(char,int,char),boolean multalign) { AlnColumn * alc; AlnColumn * alc_temp,*alc_endscore; int a_phase, d_phase; int intron_number = 1; int aln_score; int aln_num = 1; btPasteArea * btp; char tempbuf[2]; char protname[60]; char dnaname[60]; char dnatemp[4]; char protc; char transc; boolean is_reversed = FALSE; boolean issplit; if( strlen(protname_in) > name ) { info("Name %s is longer than allowed name block (%d). Truncating\n",protname_in,name); strncpy(protname,protname_in,name); protname[name] = '\0'; } else { strcpy(protname,protname_in); } if( strlen(dna->name) > name ) { info("Name %s is longer than allowed name block (%d). Truncating\n",dna->name,name); strncpy(dnaname,dna->name,name); dnaname[name] = '\0'; } else { strcpy(dnaname,dna->name); } if( dna->offset > dna->end ) { is_reversed = TRUE; } for(alc=alb->start;alc != NULL;) { if ( strcmp(alc->alu[1]->text_label,"END") == 0 ) break; /* end of alignment */ for(;alc != NULL && is_random_AlnColumn_genewise(alc) == TRUE;alc = alc->next) ; if( alc == NULL) break; /* end of alignment */ if( multalign == TRUE ) { /* get the end score */ for(aln_score = 0,alc_endscore=alc;alc_endscore->next != NULL;alc_endscore = alc_endscore->next) { if( is_random_AlnColumn_genewise(alc_endscore) == TRUE) break; aln_score += alc_endscore->alu[0]->score[0]; } /*aln_score += alc_endscore->alu[0]->score[0];*/ write_alignment_separator(btc,aln_num++,aln_score); } while( alc != NULL ) { write_name_start_stuff(btc,protname,protoff,dnaname,dna,name,alc); for(; alc != NULL;alc=alc->next ) { if( is_random_AlnColumn_genewise(alc) == TRUE ) break; if( strcmp(alc->alu[1]->text_label,"INSERT") == 0 ) { if( can_get_paste_area_btCanvas(btc,1) == FALSE) break; /* back to upper for, to place names and starts */ btp = get_paste_area_btCanvas(btc,1); paste_char_btPasteArea(btp,0,0,protsequence[alc->alu[0]->start+1],0); paste_char_btPasteArea(btp,0,2,'-',0); free_btPasteArea(btp); } else if ( strcmp(alc->alu[1]->text_label,"SEQUENCE_INSERTION") == 0 || strcmp(alc->alu[1]->text_label,"SEQUENCE_DELETION") == 0 ) { if( can_get_paste_area_btCanvas(btc,1) == FALSE) break; /* back to upper for, to place names and starts */ btp = get_paste_area_btCanvas(btc,1); if( strcmp(alc->alu[0]->text_label,"INSERT_STATE")== 0 ) { paste_char_btPasteArea(btp,0,0,'-',0); } else { paste_char_btPasteArea(btp,0,0,protsequence[alc->alu[0]->end],0); } sprintf(tempbuf,"%d",alc->alu[1]->end - alc->alu[1]->start); paste_char_btPasteArea(btp,0,3,tempbuf[0],0); paste_char_btPasteArea(btp,0,2,'!',0); free_btPasteArea(btp); } else if (strcmp(alc->alu[1]->text_label,"END") == 0 && strcmp(alc->alu[0]->text_label,"END") == 0) { break; /* end of alignment */ } else if ( strcmp(alc->alu[1]->text_label,"RANDOM_SEQUENCE") == 0 ) { break; } else if( strcmp(alc->alu[1]->text_label,"CODON") == 0 ) { if( can_get_paste_area_btCanvas(btc,1) == FALSE) break; /* back to upper for, to place names and starts */ btp = get_paste_area_btCanvas(btc,1); if( strcmp(alc->alu[0]->text_label,"INSERT_STATE")== 0 ) { write_codon_match(btp,'-',' ',alc->alu[1]->start+1,aminoacid_from_seq(ct,dna->seq+alc->alu[1]->start+1),dna->seq+alc->alu[1]->start+1); } else if( strcmp(alc->alu[0]->text_label,"BEFORE_MATCH") == 0 || strcmp(alc->alu[0]->text_label,"AFTER_MATCH") == 0 ) { write_codon_match(btp,'~',' ',alc->alu[1]->start+1,aminoacid_from_seq(ct,dna->seq+alc->alu[1]->start+1),dna->seq+alc->alu[1]->start+1); } else { write_codon_match(btp,protsequence[alc->alu[0]->end],(*match_central_line)(protsequence[alc->alu[0]->end],alc->alu[0]->score[0],aminoacid_from_seq(ct,dna->seq+alc->alu[1]->start+1)),alc->alu[1]->start+1,aminoacid_from_seq(ct,dna->seq+alc->alu[1]->start+1),dna->seq+alc->alu[1]->start+1); } free_btPasteArea(btp); continue; } else if ( strstartcmp(alc->alu[1]->text_label,"5SS") == 0 ) { /* * intron stuff. Figure out the start and end, * then place the 5'SS Central and End. * * If we can't fit in the intron, loop over * in this region before returning to higher loop. * */ if( strcmp(alc->alu[1]->text_label,"5SS_PHASE_0") == 0 ) { d_phase = 0; } else if ( strcmp(alc->alu[1]->text_label,"5SS_PHASE_1") == 0 ) { d_phase = 1; } else if ( strcmp(alc->alu[1]->text_label,"5SS_PHASE_2") == 0 ) { d_phase = 2; } else { warn("No no no. You have a non 0,1,2 phase intron (god knows how!). Not displaying it %s",alc->alu[1]->text_label); advance_line_btCanvas(btc); return FALSE; } alc_temp = alc->next; if( strcmp(alc_temp->alu[1]->text_label,"CENTRAL_INTRON") != 0 ) { warn("Bad news. I have found a 5SS in your alignment, but it is not followed by a central intron node. Don't like it!"); advance_line_btCanvas(btc); return FALSE; } for(alc_temp = alc_temp->next ;alc_temp != NULL && strstartcmp(alc_temp->alu[1]->text_label,"3SS") != 0;alc_temp = alc_temp->next) ; if( alc_temp == NULL ) { warn("Got to the end of the alignment in the middle of an intron from %s. Weird!",alc->alu[1]->text_label); advance_line_btCanvas(btc); return FALSE; } if( strcmp(alc_temp->alu[1]->text_label,"3SS_PHASE_0") == 0 ) { a_phase = 0; } else if ( strcmp(alc_temp->alu[1]->text_label,"3SS_PHASE_1") == 0 ) { a_phase = 1; } else if ( strcmp(alc_temp->alu[1]->text_label,"3SS_PHASE_2") == 0 ) { a_phase = 2; } else { warn("No no no. You have a non 0,1,2 phase intron (god knows how!). Not displaying it %s",alc_temp->alu[1]->text_label); advance_line_btCanvas(btc); return FALSE; } /* * At this point we have alc on 5SS alc_temp on 3SS. * * Check to see if we can place 5SS and Central intron piece * on the line, if not advance. * */ if( can_get_paste_area_btCanvas(btc,d_phase+7+17) == FALSE) { advance_line_btCanvas(btc); write_name_start_stuff(btc,protname,protoff,dnaname,dna,name,alc); } /*** ok, if we can't get it now then we are fucked ***/ if( can_get_paste_area_btCanvas(btc,d_phase+7+17) == FALSE) { warn("You have specified a length of your main canvas too small. I need at least 23 characters long."); advance_line_btCanvas(btc); return FALSE; } btp = get_paste_area_btCanvas(btc,d_phase+7); /* ? split phase */ if( a_phase == 0 || (a_phase != d_phase ) ) { protc = ' '; transc = ' '; dnatemp[0]= '\0'; issplit = FALSE; } else { if( strcmp(alc_temp->alu[0]->text_label,"INSERT_STATE")== 0 ) { protc = '-'; } else { protc = protsequence[alc->alu[0]->start+1]; } dnatemp[0] = tolower((int)dna->seq[alc->alu[1]->start+1]); if( d_phase == 2) { dnatemp[1] = tolower((int)dna->seq[alc->alu[1]->start+2]); } else { dnatemp[1] = tolower((int)dna->seq[alc_temp->alu[1]->end-1]); } dnatemp[2] = tolower((int)dna->seq[alc_temp->alu[1]->end]); dnatemp[3] = '\0'; transc = aminoacid_from_seq(ct,dnatemp); issplit = TRUE; } write_5intron_match(btp,d_phase,7,dna->seq+alc->alu[1]->start+1); free_btPasteArea(btp); btp = get_paste_area_btCanvas(btc,17); if( is_reversed == FALSE ) write_intron_desc(btp,alc->alu[1]->start+1+d_phase+dna->offset,alc_temp->alu[1]->start+3+dna->offset,intron_number++,issplit,protc,transc,dnatemp); else write_intron_desc(btp,dna->offset - (alc->alu[1]->start+d_phase+1),dna->offset - (alc_temp->alu[1]->start+3),intron_number++,issplit,protc,transc,dnatemp); free_btPasteArea(btp); /* * written the start of the intron, now to deal with the * acceptor. We need to loop here, because we might go over the * line length. */ alc = alc->next->next; /*** move alc forward two columns ***/ while( alc != alc_temp ) { for(; alc != alc_temp;alc = alc->next) { /** alc_temp is 3SS **/ if( strcmp(alc->alu[1]->text_label,"PYRIMIDINE_TRACT") == 0 ) { if( can_get_paste_area_btCanvas(btc,1) == FALSE ) break; btp = get_paste_area_btCanvas(btc,1); paste_char_btPasteArea(btp,0,3,dna->seq[alc->alu[1]->start+1],0); paste_char_btPasteArea(btp,0,4,'+',0); free_btPasteArea(btp); } else if( strcmp(alc->alu[1]->text_label,"SPACER") == 0 ) { if( can_get_paste_area_btCanvas(btc,1) == FALSE ) break; btp = get_paste_area_btCanvas(btc,1); paste_char_btPasteArea(btp,0,3,dna->seq[alc->alu[1]->start+1],0); free_btPasteArea(btp); } else { warn("Sorry, don't know how to print %s. Skipping...",alc->alu[1]->text_label); } } /** end for for loop **/ if ( alc == alc_temp ) { break; } /*** run out of space ***/ advance_line_btCanvas(btc); write_name_start_stuff(btc,protname,protoff,dnaname,dna,name,alc); } /** end of while still in central->3SS **/ /* * Now do 3SS * */ if( can_get_paste_area_btCanvas(btc,a_phase == 0 ? 3 : 3- a_phase + 3) == FALSE ) { advance_line_btCanvas(btc); write_name_start_stuff(btc,protname,protoff,dnaname,dna,name,alc); } if( a_phase != 0 ) { btp = get_paste_area_btCanvas(btc,3 - a_phase + 3); write_3intron_match(btp,a_phase,3,dna->seq + alc->alu[1]->start+1); free_btPasteArea(btp); } else { btp = get_paste_area_btCanvas(btc,3); write_3intron_match(btp,a_phase,3,dna->seq + alc->alu[1]->start+1); free_btPasteArea(btp); } /* * Finished with intron !!! */ } else { warn("Sorry, could not print the alignment %s:%s column",alc->alu[0]->text_label,alc->alu[1]->text_label); } } /*** in this loop ***/ advance_line_btCanvas(btc); if( alc == NULL) break; if ( is_random_AlnColumn_genewise(alc) == TRUE) break; } /* end of while over alignments */ } /* end of foreach alignment */ /*** end of print ! **/ return TRUE; } boolean write_alignment_separator(btCanvas * btc,int aln,int score) { char buffer[64]; btPasteArea * btp; sprintf(buffer,"Alignment %d Score %4.2f (Bits)",aln,Score2Bits(score)); btp = get_paste_area_btCanvas(btc,strlen(buffer)); paste_string_btPasteArea(btp,0,5,buffer,BC_RIGHT,0); free_btPasteArea(btp); advance_line_btCanvas(btc); return TRUE; } boolean write_name_start_stuff(btCanvas * btc,char * protname,int protoff,char * dnaname,Sequence * dna,int name_len,AlnColumn * alc) { char buffer[64]; btPasteArea * btp; btp = get_reserved_left_btCanvas(btc); paste_string_btPasteArea(btp,0,0,protname,BC_RIGHT,0); paste_string_btPasteArea(btp,0,3,dnaname,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[0]->start+1+protoff); paste_string_btPasteArea(btp,name_len+5-strlen(buffer),0,buffer,BC_RIGHT,0); if( dna->offset < dna->end ) sprintf(buffer,"%d",alc->alu[1]->start+1+dna->offset); else sprintf(buffer,"-%d",dna->offset - (alc->alu[1]->start+1)); paste_string_btPasteArea(btp,name_len+5-strlen(buffer),3,buffer,BC_RIGHT,0); free_btPasteArea(btp); return TRUE; } boolean write_intron_desc(btPasteArea * btp,int start,int stop,int in_number,boolean is_split,char prot,char trans,char * dna) { char buffer[32]; if( is_split ) { sprintf(buffer," %c:%c[%s] ",prot,trans,dna); paste_string_btPasteArea(btp,0,2,buffer,BC_RIGHT,0); } if( in_number < 1000 ) { sprintf(buffer," Intron %-3d ",in_number); } else { sprintf(buffer," Intron ??? ",in_number); } paste_string_btPasteArea(btp,0,3,buffer,BC_RIGHT,0); if( start < 10000000 && stop < 10000000 ) sprintf(buffer,"[%-7d:%7d]",start,stop); else sprintf(buffer,"[???????:???????]"); paste_string_btPasteArea(btp,0,4,buffer,BC_RIGHT,0); return TRUE; } boolean write_3intron_match(btPasteArea * btp,int phase,int length,char * seq) { char buf[2]; int i; int prl; prl = 3 - phase + length; if( phase == 0 ) { prl = 3; } sprintf(buf,"%d",phase); for(i=0;i',0); return TRUE; } boolean write_5intron_match(btPasteArea * btp,int phase,int length,char * seq) { char buf[2]; int i; sprintf(buf,"%d",phase); for(i=0;icomp65 = DnaProbMatrix_from_match(0.65,nmask); flat_null_DnaProbMatrix(out->comp65); out->comp75 = DnaProbMatrix_from_match(0.75,nmask); flat_null_DnaProbMatrix(out->comp75); out->comp85 = DnaProbMatrix_from_match(0.85,nmask); flat_null_DnaProbMatrix(out->comp85); out->comp95 = DnaProbMatrix_from_match(0.95,nmask); flat_null_DnaProbMatrix(out->comp95); out->g = LCH_GAP / LCH_UNMATCHED_PEN; out->u = 1.0; out->v = (1.0- LCH_UNMATCHED_PEN)/(LCH_UNMATCHED_PEN); out->s = (1.0 - (LCH_GAP + LCH_GAP + LCH_BLOCKOPEN))/(LCH_UNMATCHED_PEN * LCH_UNMATCHED_PEN); out->b = (LCH_BLOCKOPEN/LCH_UNMATCHED_PEN); return out; } # line 82 "localcispara.dy" LocalCisHitScore * LocalCisHitScore_from_LocalCisHitProb(LocalCisHitProb * lchp) { LocalCisHitScore * lchs; lchs = LocalCisHitScore_alloc(); lchs->comp65 = DnaMatrix_from_DnaProbMatrix(lchp->comp65); lchs->comp75 = DnaMatrix_from_DnaProbMatrix(lchp->comp75); lchs->comp85 = DnaMatrix_from_DnaProbMatrix(lchp->comp85); lchs->comp95 = DnaMatrix_from_DnaProbMatrix(lchp->comp95); lchs->g = Probability2Score(lchp->g); lchs->u = Probability2Score(lchp->u); lchs->v = Probability2Score(lchp->v); lchs->s = Probability2Score(lchp->s); lchs->b = Probability2Score(lchp->b); return lchs; } # line 69 "localcispara.c" /* Function: hard_link_LocalCisHitProb(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LocalCisHitProb *] * * Return [UNKN ] Undocumented return value [LocalCisHitProb *] * */ LocalCisHitProb * hard_link_LocalCisHitProb(LocalCisHitProb * obj) { if( obj == NULL ) { warn("Trying to hard link to a LocalCisHitProb object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LocalCisHitProb_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalCisHitProb *] * */ LocalCisHitProb * LocalCisHitProb_alloc(void) { LocalCisHitProb * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LocalCisHitProb *) ckalloc (sizeof(LocalCisHitProb))) == NULL) { warn("LocalCisHitProb_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->comp65 = NULL; out->comp75 = NULL; out->comp85 = NULL; out->comp95 = NULL; out->g = 0.0; out->u = 0.0; out->v = 0.0; out->s = 0.0; out->b = 0.0; return out; } /* Function: free_LocalCisHitProb(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalCisHitProb *] * * Return [UNKN ] Undocumented return value [LocalCisHitProb *] * */ LocalCisHitProb * free_LocalCisHitProb(LocalCisHitProb * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LocalCisHitProb obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->comp65 != NULL) free_DnaProbMatrix(obj->comp65); if( obj->comp75 != NULL) free_DnaProbMatrix(obj->comp75); if( obj->comp85 != NULL) free_DnaProbMatrix(obj->comp85); if( obj->comp95 != NULL) free_DnaProbMatrix(obj->comp95); ckfree(obj); return NULL; } /* Function: hard_link_LocalCisHitScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LocalCisHitScore *] * * Return [UNKN ] Undocumented return value [LocalCisHitScore *] * */ LocalCisHitScore * hard_link_LocalCisHitScore(LocalCisHitScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a LocalCisHitScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LocalCisHitScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalCisHitScore *] * */ LocalCisHitScore * LocalCisHitScore_alloc(void) { LocalCisHitScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LocalCisHitScore *) ckalloc (sizeof(LocalCisHitScore))) == NULL) { warn("LocalCisHitScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->comp65 = NULL; out->comp75 = NULL; out->comp85 = NULL; out->comp95 = NULL; out->g = 0; out->u = 0; out->v = 0; out->s = 0; out->b = 0; return out; } /* Function: free_LocalCisHitScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalCisHitScore *] * * Return [UNKN ] Undocumented return value [LocalCisHitScore *] * */ LocalCisHitScore * free_LocalCisHitScore(LocalCisHitScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LocalCisHitScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->comp65 != NULL) free_DnaMatrix(obj->comp65); if( obj->comp75 != NULL) free_DnaMatrix(obj->comp75); if( obj->comp85 != NULL) free_DnaMatrix(obj->comp85); if( obj->comp95 != NULL) free_DnaMatrix(obj->comp95); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/localcispara.h0000644000175000001440000001141510670453714016742 0ustar philippusers#ifndef DYNAMITElocalcisparaHEADERFILE #define DYNAMITElocalcisparaHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #define LCH_GAP 0.05 #define LCH_BLOCKOPEN 0.01 #define LCH_UNMATCHED_PEN 0.99 struct Wise2_LocalCisHitProb { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DnaProbMatrix* comp65; DnaProbMatrix* comp75; DnaProbMatrix* comp85; DnaProbMatrix* comp95; Probability g; Probability u; Probability v; Probability s; Probability b; } ; /* LocalCisHitProb defined */ #ifndef DYNAMITE_DEFINED_LocalCisHitProb typedef struct Wise2_LocalCisHitProb Wise2_LocalCisHitProb; #define LocalCisHitProb Wise2_LocalCisHitProb #define DYNAMITE_DEFINED_LocalCisHitProb #endif struct Wise2_LocalCisHitScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DnaMatrix* comp65; DnaMatrix* comp75; DnaMatrix* comp85; DnaMatrix* comp95; Score g; Score u; Score v; Score s; Score b; } ; /* LocalCisHitScore defined */ #ifndef DYNAMITE_DEFINED_LocalCisHitScore typedef struct Wise2_LocalCisHitScore Wise2_LocalCisHitScore; #define LocalCisHitScore Wise2_LocalCisHitScore #define DYNAMITE_DEFINED_LocalCisHitScore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_LocalCisHitProb(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LocalCisHitProb *] * * Return [UNKN ] Undocumented return value [LocalCisHitProb *] * */ LocalCisHitProb * Wise2_hard_link_LocalCisHitProb(LocalCisHitProb * obj); #define hard_link_LocalCisHitProb Wise2_hard_link_LocalCisHitProb /* Function: LocalCisHitProb_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalCisHitProb *] * */ LocalCisHitProb * Wise2_LocalCisHitProb_alloc(void); #define LocalCisHitProb_alloc Wise2_LocalCisHitProb_alloc /* Function: free_LocalCisHitProb(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalCisHitProb *] * * Return [UNKN ] Undocumented return value [LocalCisHitProb *] * */ LocalCisHitProb * Wise2_free_LocalCisHitProb(LocalCisHitProb * obj); #define free_LocalCisHitProb Wise2_free_LocalCisHitProb /* Function: hard_link_LocalCisHitScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LocalCisHitScore *] * * Return [UNKN ] Undocumented return value [LocalCisHitScore *] * */ LocalCisHitScore * Wise2_hard_link_LocalCisHitScore(LocalCisHitScore * obj); #define hard_link_LocalCisHitScore Wise2_hard_link_LocalCisHitScore /* Function: LocalCisHitScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalCisHitScore *] * */ LocalCisHitScore * Wise2_LocalCisHitScore_alloc(void); #define LocalCisHitScore_alloc Wise2_LocalCisHitScore_alloc /* Function: free_LocalCisHitScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalCisHitScore *] * * Return [UNKN ] Undocumented return value [LocalCisHitScore *] * */ LocalCisHitScore * Wise2_free_LocalCisHitScore(LocalCisHitScore * obj); #define free_LocalCisHitScore Wise2_free_LocalCisHitScore /* Unplaced functions */ /* There has been no indication of the use of these functions */ LocalCisHitScore * Wise2_standard_LocalCisHitScore(NMaskType nmask); #define standard_LocalCisHitScore Wise2_standard_LocalCisHitScore LocalCisHitProb * Wise2_standard_LocalCisHitProb(NMaskType nmask); #define standard_LocalCisHitProb Wise2_standard_LocalCisHitProb LocalCisHitScore * Wise2_LocalCisHitScore_from_LocalCisHitProb(LocalCisHitProb * lchp); #define LocalCisHitScore_from_LocalCisHitProb Wise2_LocalCisHitScore_from_LocalCisHitProb /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/alignwisedp.dy0000644000175000001440000000740707657732677017031 0ustar philippusers %{ #include "aligngenemodel.h" %} struct AlignGeneModelFrame int len matrix AlignWise query type="AlignGeneModelFrame*" name="model" field:len="len" target type="AlignGeneModelScore*" name="align" field:len="len" resource type="Score" name="intronopen" resource type="Score" name="geneopen" state CODON offi="0" source CODON offj="3" calc="align->forward_coding[j]" endsource source INTERGENIC offj="3" calc="align->forward_coding[j]" endsource source INTRON_0 offj="6" calc="align->splice3_forward[j-3] + align->forward_coding[j]" target_label 3SS_PHASE_0 endsource source INTRON_1 offj="5" calc="align->splice3_forward[j-2]" target_label 3SS_PHASE_1 endsource source INTRON_2 offj="4" calc="align->splice3_forward[j-1]" target_label 3SS_PHASE_2 endsource query_label EXON_STATE target_label CODON endstate state INTRON_0 offi="0" offj="1" source CODON offj="8" calc="align->splice5_forward[j-7]+intronopen" target_label 5SS_PHASE_0 endsource source INTRON_0 offj="1" calc="0" endsource query_label INTRON_STATE target_label INTRON endstate state INTRON_1 offi="0" offj="1" source CODON offj="9" calc="align->splice5_forward[j-7]+intronopen" target_label 5SS_PHASE_1 endsource source INTRON_1 offj="1" calc="0" endsource query_label INTRON_STATE target_label INTRON endstate state INTRON_2 offi="0" offj="1" source CODON offj="10" calc="align->splice5_forward[j-7]+intronopen" target_label 5SS_PHASE_2 endsource source INTRON_2 offj="1" calc="0" endsource query_label INTRON_STATE target_label INTRON endstate state REVERSE_CODON offi="0" source REVERSE_CODON offj="3" calc="align->reverse_coding[j]" endsource source INTERGENIC offj="3" calc="align->reverse_coding[j]" endsource source REVERSE_INTRON_0 offj="6" calc="align->splice5_reverse[j-3]" target_label REV_5SS_PHASE_0 endsource source REVERSE_INTRON_1 offj="5" calc="align->splice5_reverse[j-2]" target_label REV_5SS_PHASE_1 endsource source REVERSE_INTRON_2 offj="4" calc="align->splice5_reverse[j-1]" target_label REV_5SS_PHASE_2 endsource query_label REV_EXON_STATE target_label REV_CODON endstate state REVERSE_INTRON_0 offi="0" offj="1" source REVERSE_CODON offj="8" calc="align->splice3_reverse[j-7]+intronopen" target_label REV_3SS_PHASE_0 endsource source REVERSE_INTRON_0 offj="1" calc="0" endsource query_label REV_INTRON_STATE target_label REV_INTRON endstate state REVERSE_INTRON_1 offi="0" offj="1" source REVERSE_CODON offj="9" calc="align->splice3_reverse[j-7]+intronopen" target_label REV_3SS_PHASE_1 endsource source REVERSE_INTRON_1 offj="1" calc="0" endsource query_label REV_INTRON_STATE target_label REV_INTRON endstate state REVERSE_INTRON_2 offi="0" offj="1" source REVERSE_CODON offj="10" calc="align->splice3_reverse[j-7]+intronopen" target_label REV_3SS_PHASE_2 endsource source REVERSE_INTRON_2 offj="1" calc="0" endsource query_label REV_INTRON_STATE target_label REV_INTRON endstate state START !special !start endstate state INTERGENIC !special source START offj="1" calc="0" endsource source INTERGENIC offj="1" calc="0" endsource source CODON calc="geneopen" target_label STOP endsource source REVERSE_CODON calc="geneopen" target_label REV_CODON endsource target_label SEQUENCE query_label INTERGENIC endstate state END !special !end source INTERGENIC offj="1" calc="0" endsource query_label END target_label END endstate collapse INTRON_STATE INTRON collapse REV_INTRON_STATE REV_INTRON collapse INTERGENIC SEQUENCE endmatrix %{ #include "alignwisedp.h" %} wise-2.4.1/src/models/makefile0000644000175000001440000004360510420650634015633 0ustar philippusers .SUFFIXES : .dy NEWG = geneparser21.o \ geneparameter.o \ genestats.o \ genewisehsp.o \ geneutil.o \ geneoutput.o \ threestatemodel.o \ genefrequency.o \ splicesitemodeler.o \ genewise4.o \ genewise6.o \ genestretch6.o \ genewise21.o \ geneloop21.o \ geneloop6.o \ genephase6.o \ gwlite.o \ gwlitemodel.o \ gwrap.o \ matchsum.o \ estwrap.o \ genewisemodel.o \ phasemodel.o \ cdparser.o \ genedisplay.o \ estwise3.o \ estslim3.o \ estloop3.o \ estfrag3.o \ estslimloop.o \ gwquickdb.o \ threestatedb.o \ pfamhmmer1db.o \ pwmdna.o \ wise2xhmmer2.o \ genewisemodeldb.o \ seqhit.o \ standardout.o \ geneparser4.o \ sw_wrap.o \ abc.o \ pba.o \ seqaligndisplay.o \ dbadisplay.o \ proteinsw.o \ estquick3.o all : dnal psw pswdb dba estwise genewise genewisedb estwisedb genomewise sywise pseudowise promoterwise scanwise libmodel.a libmodel.a : $(NEWG) ar $(AR_OPTIONS) libmodel.a $(NEWG) wise2xhmmer2.o : wise2xhmmer2.c $(CC) $(CFLAGS) -I$(HMMER_INCLUDE) -D$(HMMER_DEFINE) $(INCFLAGS) wise2xhmmer2.c # $(CC) $(CFLAGS) -I../HMMer2/ $(INCFLAGS) wise2xhmmer2.c testgenestat : testgenestat.o genestats.o pwmdna.o $(CC) -o testgenestat testgenestat.o genestats.o pwmdna.o -ldyna -lwisebase $(LFLAGS) test_aligng : test_aligng.o aligngenemodel.o pwmdna.o $(CC) -o test_aligng test_aligng.o aligngenemodel.o pwmdna.o -ldyna -lwisebase $(LFLAGS) makepwm : makepwm.o pwmdna.o $(CC) -o makepwm makepwm.o pwmdna.o -ldyna -lwisebase $(LFLAGS) testwise2xhmmer2.o : testwise2xhmmer2.c $(CC) $(CFLAGS) -I../HMMer2/ $(INCFLAGS) testwise2xhmmer2.c testwise2xhmmer2 : testwise2xhmmer2.o threestatemodel.o threestatedb.o pfamhmmer1db.o $(CC) -o testwise2xhmmer2 wise2xhmmer2.o testwise2xhmmer2.o threestatemodel.o threestatedb.o pfamhmmer1db.o -ldyna -lwisebase -lhmmer $(LFLAGS) plan7test.o : plan7test.c $(CC) $(CFLAGS) -I../HMMer2/ plan7test.c plan7test : plan7test.o plan7.o wise2xhmmer2.o threestatemodel.o threestatedb.o pfamhmmer1db.o $(CC) -o plan7test plan7test.o plan7.o threestatemodel.o threestatedb.o pfamhmmer1db.o wise2xhmmer2.o -ldyna -lwisebase -lhmmer $(LFLAGS) seqstat : seqstat.o $(CC) -o seqstat seqstat.o -ldyna -lwisebase $(LFLAGS) mutatedna : mutatedna.o $(CC) -o mutatedna mutatedna.o -ldyna -lwisebase $(LFLAGS) revcomp : revcomp.o $(CC) -o revcomp revcomp.o -ldyna -lwisebase $(LFLAGS) stupid_motif_scan : stupid_motif_scan.o $(CC) -o stupid_motif_scan stupid_motif_scan.o -ldyna -lwisebase $(LFLAGS) seqtrunc : seqtrunc.o $(CC) -o seqtrunc seqtrunc.o -ldyna -lwisebase $(LFLAGS) seqlist : seqlist.o $(CC) -o seqlist seqlist.o -ldyna -lwisebase $(LFLAGS) testpwm : testpwm.o pwmdna.o $(CC) -o testpwm testpwm.o pwmdna.o -ldyna -lwisebase $(LFLAGS) -lefence threestate : $(MODELOBJ) gw21 : $(MODELOBJ) $(GENEWISEMODEL) genewisemodel.o pwise : $(MODELOBJ) threestatemat.o threestatedisplay.o test : test.o proteinsw.o protprotdis.o $(CC) -o test test.o proteinsw.o protprotdis.o -ldyna_glib -ldyna -lwisebase ../dynlibsrc/matrix.o $(LFLAGS) testanc : testanc.o proteinsw.o abc.o pba.o sw_wrap.o $(CC) -o testanc testanc.o proteinsw.o abc.o pba.o sw_wrap.o $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) test_tf : test_transfactor.o transfactor.o pwmdna.o $(CC) -o test_tf test_transfactor.o transfactor.o pwmdna.o $(LFLAGS) -ldyna -lwisebase motifwise : motifwise.o transfactor.o transregion.o pwmdna.o transregiondp.o $(CC) -o motifwise motifwise.o transfactor.o transregion.o pwmdna.o transregiondp.o $(LFLAGS) -ldyna -lwisebase motifcluster : motifcluster.o transfactor.o transregion.o pwmdna.o transregiondp.o $(CC) -o motifcluster motifcluster.o transfactor.o transregion.o pwmdna.o transregiondp.o $(LFLAGS) -ldyna -lwisebase motifdiff : motifdiff.o transfactor.o transregion.o pwmdna.o transregiondp.o $(CC) -o motifdiff motifdiff.o transfactor.o transregion.o pwmdna.o transregiondp.o $(LFLAGS) -ldyna -lwisebase cdtest : cdtest.o cdna2genomic.o d2d_display.o $(CC) -o cdtest cdtest.o cdna2genomic.o d2d_display.o -ldyna_glib -ldyna -lwisebase $(LFLAGS) prob2bits : prob2bits.o $(CC) -o prob2bits $(LFLAGS) -ldyna_glib -ldyna -lwisebase quick : cc -O -c -I../dynlibsrc/ -I../base/ genewise6.c cc -O -c -I../dynlibsrc/ -I../base/ geneloop6.c cc -O -c -I../dynlibsrc/ -I../base/ genewise21.c cc -O -c -I../dynlibsrc/ -I../base/ geneloop21.c cc -O -c -I../dynlibsrc/ -I../base/ estwise3.c cc -O -c -I../dynlibsrc/ -I../base/ estloop3.c quicke : cc -O -c -I../dynlibsrc/ -I../base/ estwise3.c cc -O -c -I../dynlibsrc/ -I../base/ estloop3.c cc -O -c -I../dynlibsrc/ -I../base/ estslim3.c quicksw : cc -O -c -I../dynlibsrc/ -I../base/ proteinsw.c cc -O -c -I../dynlibsrc/ -I../base/ abc.c genewisedb.o : genewisedb.c $(CC) $(CFLAGS) genewisedb.c -I../base/ -I../dynlibsrc/ -I../HMMer2/ estwisedb.o : estwisedb.c $(CC) $(CFLAGS) estwisedb.c -I../base/ -I../dynlibsrc/ -I../HMMer2/ estwise.o : estwise.c $(CC) $(CFLAGS) estwise.c -I../base/ -I../dynlibsrc/ -I../HMMer2/ -I. genewise.o : genewise.c $(CC) $(CFLAGS) genewise.c -I../base/ -I../dynlibsrc/ -I../HMMer2/ -I. evopairwise.o : evopairwise.c $(CC) $(CFLAGS) evopairwise.c -I../base/ -I../dynlibsrc/ -I../HMMer2/ -I. test_threestatehsp.o : test_threestatehsp.c $(CC) $(CFLAGS) test_threestatehsp.c -I../base/ -I../dynlibsrc/ -I../HMMer2/ -I. fivestar.o : fivestar.c $(CC) $(CFLAGS) fivestar.c -I../base/ -I../dynlibsrc/ -I../HMMer2/ -I. fivestarsearch.o : fivestarsearch.c $(CC) $(CFLAGS) fivestarsearch.c -I../base/ -I../dynlibsrc/ -I../HMMer2/ -I. fivestarscan.o : fivestarscan.c $(CC) $(CFLAGS) fivestarscan.c -I../base/ -I../dynlibsrc/ -I../HMMer2/ -I. oldpostwise : oldpostwise.o $(NEWG) $(CC) -g -o oldpostwise oldpostwise.o $(NEWG) $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase testdna : testdna.o dnaalign.o seqaligndisplay.o $(CC) -o testdna testdna.o dnaalign.o seqaligndisplay.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) dnal : dnal.o dnaalign.o seqaligndisplay.o $(CC) -o dnal dnal.o dnaalign.o seqaligndisplay.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) psw : psw.o seqaligndisplay.o proteinsw.o sw_wrap.o abc.o pba.o $(CC) -o psw psw.o sw_wrap.o seqaligndisplay.o proteinsw.o abc.o pba.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) scanwisep.o : scanwisep.c $(CC) $(CFLAGS) $(INCFLAGS) -I../external/mott `glib-config --cflags` $? hsp2aln_sw.o : hsp2aln_sw.c $(CC) $(CFLAGS) $(INCFLAGS) `glib-config --cflags` $? scanwisep_mysql.o : scanwisep.c $(CC) $(CFLAGS) -DSCAN_MYSQL -I../corba -I../external/mott -I../mysql/protein_index/ -I/usr/local/mysql/include scanwisep.c scanwisep_mysql : scanwisep_mysql.o seqaligndisplay.o proteinsw.o sw_wrap.o abc.o pba.o hsp2aln_sw.o $(CC) -o scanwisep scanwisep.o sw_wrap.o seqaligndisplay.o proteinsw.o abc.o pba.o hsp2aln_sw.o ../mysql/protein_index/mysql_protein_index.o $(LFLAGS) -L../external/mott -L/usr/local/mysql/lib -ldyna_glib -ldyna ott -lwisebase -lmysqlclient -lm $(EXTRALIBS) -lpthread -lZ scanwisep_corba.o : scanwisep.c $(CC) $(CFLAGS) -DSCAN_CORBA -I../corba -I../external/mott `orbit-config --cflags server` scanwisep.c scanwisep_corba : scanwisep_corba.o seqaligndisplay.o proteinsw.o sw_wrap.o abc.o pba.o hsp2aln_sw.o $(CC) -o scanwisep scanwisep.o sw_wrap.o seqaligndisplay.o proteinsw.o abc.o pba.o hsp2aln_sw.o ../corba/hspscan_corba-common.o ../corba/hspscan_corba-stubs.o ../corba/corba_singleton.o ../corba/hspscan_corba_wrapper.o $(LFLAGS) -L../external/mott -ldyna_glib -ldyna -lmott -lwisebase $(EXTRALIBS) `orbit-config --libs server` -lpthread scanwisep_wiseserver.o : scanwisep.c $(CC) $(CFLAGS) $(INCFLAGS) -o scanwisep_wiseserver.o -DSCAN_WISESERVER -I../network -I../socket -I../external/mott scanwisep.c scanwise : scanwisep_wiseserver.o seqaligndisplay.o proteinsw.o sw_wrap.o abc.o pba.o hsp2aln_sw.o $(CC) -o scanwise scanwisep_wiseserver.o sw_wrap.o seqaligndisplay.o proteinsw.o abc.o pba.o hsp2aln_sw.o ../network/net_hspscan.o ../network/client_multihspscan.o $(LFLAGS) -L../external/mott -L../socket -lmott -ldyna_glib -ldyna -lwisesocket -lwisebase $(EXTRALIBS) -lpthread scanwisep_compress.o : scanwisep.c $(CC) $(CFLAGS) -DSCAN_COMPRESS -I../dnaindex -I../network -I../socket -I../external/mott scanwisep.c scanwisep_compress : scanwisep_compress.o seqaligndisplay.o proteinsw.o sw_wrap.o abc.o pba.o hsp2aln_sw.o $(CC) -o scanwisep scanwisep.o sw_wrap.o seqaligndisplay.o proteinsw.o abc.o pba.o hsp2aln_sw.o ../dnaindex/compressed_protein_index.o ../dnaindex/singleseqspace.o ../dnaindex/kmer_direct.o ../dnaindex/kmer_index_interface.o $(LFLAGS) -L../external/mott -L../socket -lmott -ldyna_glib -ldyna -lwisesocket -lwisebase $(EXTRALIBS) -lpthread scanwisep : scanwisep.o seqaligndisplay.o proteinsw.o sw_wrap.o abc.o pba.o hsp2aln_sw.o $(CC) -o scanwisep scanwisep.o sw_wrap.o seqaligndisplay.o proteinsw.o abc.o pba.o hsp2aln_sw.o $(LFLAGS) -L../external/mott -lmott -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) `glib-config --libs` -lpthread test_gwhsp : test_gwhsp.o genewisehsp.o $(CC) -o test_gwhsp test_gwhsp.o genewisehsp.o $(LFLAGS) -ldyna_glib -ldyna_glib -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) `glib-config --libs` -lpthread localcishit.o : localcishit.c $(CC) $(CFLAGS) $(INCFLAGS) `glib-config --cflags` $? promoterwise.o : promoterwise.c $(CC) $(CFLAGS) $(INCFLAGS) `glib-config --cflags` $? promoterwise : promoterwise.o localdba.o localcishit.o localcispara.o dbadisplay.o motifmatrix.o motifmatrixdp.o transfactor.o pwmdna.o pairwiseshortdna.o $(CC) -g -o promoterwise promoterwise.o localdba.o localcishit.o localcispara.o dbadisplay.o motifmatrix.o motifmatrixdp.o transfactor.o pwmdna.o pairwiseshortdna.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) `glib-config --libs` -lpthread test_deng : test_deng.o localdba.o localcishit.o localcispara.o dbadisplay.o motifmatrix.o motifmatrixdp.o transfactor.o pwmdna.o pairwiseshortdna.o dnaprofile.o dnaprofiledp.o dnaprofileengine.o $(CC) -o test_deng test_deng.o localdba.o localcishit.o localcispara.o dbadisplay.o motifmatrix.o motifmatrixdp.o transfactor.o pwmdna.o pairwiseshortdna.o dnaprofile.o dnaprofiledp.o dnaprofileengine.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) `glib-config --libs` -lpthread promotercluster : promotercluster.o localdba.o localcishit.o localcispara.o dbadisplay.o motifmatrix.o motifmatrixdp.o transfactor.o pwmdna.o pairwiseshortdna.o dnaprofile.o dnaprofiledp.o dnaprofileengine.o $(CC) -o promotercluster promotercluster.o localdba.o localcishit.o localcispara.o dbadisplay.o motifmatrix.o motifmatrixdp.o transfactor.o pwmdna.o pairwiseshortdna.o dnaprofile.o dnaprofiledp.o dnaprofileengine.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) `glib-config --libs` -lpthread dnawise : dnawise.o dnahmm.o dnahmmdp.o seqaligndisplay.o $(CC) -o dnawise dnawise.o dnahmm.o dnahmmdp.o seqaligndisplay.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase -lpthread pswdb : pswdb.o seqaligndisplay.o proteinsw.o sw_wrap.o abc.o pba.o $(CC) -o pswdb pswdb.o sw_wrap.o seqaligndisplay.o proteinsw.o abc.o pba.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) efpswdb : pswdb.o seqaligndisplay.o proteinsw.o sw_wrap.o abc.o pba.o $(CC) -o pswdb pswdb.o sw_wrap.o seqaligndisplay.o proteinsw.o abc.o pba.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase -lefence $(EXTRALIBS) dba : dbac.o dba.o slimdba.o bigdba.o dbadisplay.o $(CC) -o dba dbac.o dba.o slimdba.o bigdba.o dbadisplay.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) lba : lba.o largeblockdp.o seqaligndisplay.o $(CC) -o lba lba.o largeblockdp.o seqaligndisplay.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) fastdba : fastdba.o dba.o slimdba.o bigdba.o dbadisplay.o $(CC) -o fastdba fastdba.o dba.o slimdba.o bigdba.o dbadisplay.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) evopairwise : evopairwise.o threestatemodel.o threestateloop.o threestatedb.o pfamhmmer1db.o wise2xhmmer2.o seqaligndisplay.o $(CC) -o evopairwise evopairwise.o threestatemodel.o threestateloop.o threestatedb.o pfamhmmer1db.o wise2xhmmer2.o seqaligndisplay.o $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) test_threestatehsp : test_threestatehsp.o threestatemodel.o threestateloop.o threestatedb.o pfamhmmer1db.o wise2xhmmer2.o seqaligndisplay.o threestatehsp.o $(CC) -o test_threestatehsp test_threestatehsp.o threestatemodel.o threestateloop.o threestatedb.o pfamhmmer1db.o seqaligndisplay.o threestatehsp.o wise2xhmmer2.o $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) makerandomdb : makerandomdb.o $(CC) -o makerandomdb makerandomdb.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) genewise : genewise.o $(NEWG) $(CC) -o genewise genewise.o $(NEWG) $(LFLAGS) -lhmmer -ldyna_glib -ldyna_glib -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) cdnawise : cdnawise.o $(NEWG) cdnawise10.o $(CC) -g -o cdnawise cdnawise.o cdnawise10.o $(NEWG) $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) fivestar : fivestar.o fivestatemodel.o fivestate.o threestatemodel.o threestatedb.o pfamhmmer1db.o wise2xhmmer2.o seqaligndisplay.o standardout.o threestatedp.o $(CC) -g -o fivestar fivestar.o fivestatemodel.o fivestate.o threestatedb.o threestatemodel.o pfamhmmer1db.o wise2xhmmer2.o seqaligndisplay.o standardout.o threestatedp.o $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) fivestarsearch : fivestarsearch.o fivestatemodel.o fivestate.o threestatemodel.o threestatedb.o pfamhmmer1db.o wise2xhmmer2.o seqaligndisplay.o standardout.o threestatedp.o $(CC) -g -o fivestarsearch fivestarsearch.o fivestatemodel.o fivestate.o threestatedb.o threestatemodel.o pfamhmmer1db.o wise2xhmmer2.o seqaligndisplay.o standardout.o threestatedp.o $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) fivestarscan : fivestarscan.o fivestatemodel.o fivestate.o threestatemodel.o threestatedb.o pfamhmmer1db.o wise2xhmmer2.o seqaligndisplay.o standardout.o threestatedp.o $(CC) -g -o fivestarscan fivestarscan.o fivestatemodel.o fivestate.o threestatedb.o threestatemodel.o pfamhmmer1db.o wise2xhmmer2.o seqaligndisplay.o standardout.o threestatedp.o $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) editdist : editdist.o editdistdp.o standardout.o seqaligndisplay.o $(CC) -g -o editdist editdist.o editdistdp.o standardout.o seqaligndisplay.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase efgw : genewise.o $(NEWG) $(CC) -g -o genewise genewise.o $(NEWG) $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) -lefence genewisedb : genewisedb.o $(NEWG) $(CC) -g -o genewisedb genewisedb.o $(NEWG) $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) estwisedb : estwisedb.o $(NEWG) $(CC) -g -o estwisedb estwisedb.o $(NEWG) $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) edb : estwisedb.o $(NEWG) $(CC) -g -o estwisedb estwisedb.o $(NEWG) $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) -lefence estwise : estwise.o $(NEWG) $(CC) -g -o estwise estwise.o $(NEWG) $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) amplimer_resolver : amplimer_resolver.o dnaalign.o dnamatcher.o $(CC) -g -o amplimer_resolver amplimer_resolver.o dnamatcher.o dnaalign.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) genomewise : genomewise.o genomewise9.o genome_evidence.o est_evidence.o geneutil.o geneoutput.o $(CC) -g -o genomewise genomewise.o genomewise9.o genome_evidence.o est_evidence.o geneoutput.o geneutil.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) sywise : sywise.o sywise20.o syexonmodel.o genestats.o pwmdna.o geneutil.o standardout.o $(CC) -g -o sywise sywise.o sywise20.o syexonmodel.o genestats.o pwmdna.o standardout.o geneutil.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) alignwise : alignwise.o alignwisedp.o aligngenemodel.o genestats.o pwmdna.o geneutil.o standardout.o geneoutput.o $(CC) -g -o alignwise alignwise.o alignwisedp.o aligngenemodel.o genestats.o pwmdna.o geneutil.o standardout.o geneoutput.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) test_splice : test_splice.o aligngenemodel.o genestats.o pwmdna.o geneutil.o standardout.o $(CC) -g -o test_splice test_splice.o aligngenemodel.o genestats.o pwmdna.o geneutil.o standardout.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) statwise : statwise.o statwise10.o syexonmodel.o genestats.o pwmdna.o geneutil.o $(CC) -g -o statwise statwise.o statwise10.o syexonmodel.o genestats.o pwmdna.o geneutil.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) pseudowise : pseudowise.o pseudowise7.o $(NEWG) $(CC) -g -o pseudowise pseudowise.o pseudowise7.o $(NEWG) $(LFLAGS) -lhmmer -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) clonewise : clonewise.o clonewisedp.o localclonewisedp.o mapstruct.o $(CC) -g -o clonewise clonewise.o clonewisedp.o localclonewisedp.o mapstruct.o $(LFLAGS) -ldyna_glib -ldyna -lwisebase $(EXTRALIBS) HMMER_LIBS = ../HMMer2/ HMMER_INCLUDE = ../HMMer2/ HMMER_DEFINE = CC = cc #CFLAGS = -c -O2 -pg -I../base/ -I../dynlibsrc/ #CFLAGS = -c -O2 -DPTHREAD -DHAS_PTHREAD_SETSCOPE -DUNIX -I../base/ -I../dynlibsrc/ -I. CFLAGS = -c -g3 -O2 -DUNIX -I../base/ -I../dynlibsrc/ -I. -pthread `glib-config --cflags` #CFLAGS = -c -g -DHAS_PTHREAD_SETSCOPE -DUNIX -I../base/ -I../dynlibsrc/ `glib-config --cflags` #LFLAGS = -L../base/ -L../dynlibsrc/ -L../HMMer2/ LFLAGS = -L../base/ -L../dynlibsrc/ -L$(HMMER_LIBS) -lpthread `glib-config --libs` AR_OPTIONS = ru RANLIB_NEEDED = 0 # # Base library build - call wisebase # #test : test.o libwisedb.a # $(CC) -o test test.o libwisedb.a -lprob -ldyn -lwisebase $(LFLAGS) # # # .c.o : $(CC) $(CFLAGS) $(INCFLAGS) $? INCFLAGS = -I../base/ -I../dynlibsrc/ DFLAGS = -l -D -n Wise2_ -a _api.h -b _api.t -latex -perl -pthreads -dbtrace 5 -nocwarn #DFLAGS = -l -O -D -n Wise2_ -a _api.h -b _api.t -latex -perl -pthreads -dbtrace 5 #DFLAGS = -l -n Wise2_ .dy.c : dyc $(DFLAGS) $< .dy.o : dyc $(DFLAGS) $< $(CC) $(CFLAGS) $*.c init : dyc $(DFLAGS) *.dy # # pro2DNAmatrix.c pro2DNAmatrix.h : pro2DNAmatrix.dy # dy pro2DNAmatrix.dy wise-2.4.1/src/models/transregiondp.c0000644000175000001440000036627710670453715017203 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "transregiondp.h" # line 81 "transregiondp.dy" SequenceBaseCoverage * new_SequenceBaseCoverage(TransFactorMatchSet * tfms) { int i; int j; int seqpos; SequenceBaseCoverage * out; out = SequenceBaseCoverage_alloc(); out->coverage = calloc(tfms->target->len,sizeof(char)); out->len = tfms->target->len; out->gc_points = calloc(tfms->target->len,sizeof(char)); for(j=1;jlen;j++) { if( toupper(tfms->target->seq[j-1]) == 'G' && toupper(tfms->target->seq[j]) == 'C') { out->gc_points[j] = 1; } } for(i=0;ilen;i++) { for(j=tfms->match[i]->start;jmatch[i]->end;j++) { if(out->coverage[j] < 100 ) { out->coverage[j]++; } } } return out; } # line 116 "transregiondp.dy" TransRegionModel * new_logodds_TransRegionModel(double in_region_prob,double out_region_prob,double in_cost,double gc_region_ratio) { TransRegionModel * out; out = TransRegionModel_alloc(); out->region_present = Probability2Score(in_region_prob/out_region_prob); out->region_notpresent = Probability2Score((1.0-in_region_prob)/(1.0 - out_region_prob)); out->nonregion_present = Probability2Score(1.0); out->nonregion_notpresent = Probability2Score(1.0); out->region_start = Probability2Score(in_cost); out->gc_point = Probability2Score(gc_region_ratio); out->gc_non_point = 0; out->len = 1; fprintf(stderr,"... %d (%.2f) covered, %d (%.2f) not covered\n",out->region_present,Score2Bits(out->region_present),out->region_notpresent,Score2Bits(out->region_notpresent)); return out; } # line 68 "transregiondp.c" /* Function: hard_link_SequenceBaseCoverage(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SequenceBaseCoverage *] * * Return [UNKN ] Undocumented return value [SequenceBaseCoverage *] * */ SequenceBaseCoverage * hard_link_SequenceBaseCoverage(SequenceBaseCoverage * obj) { if( obj == NULL ) { warn("Trying to hard link to a SequenceBaseCoverage object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SequenceBaseCoverage_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SequenceBaseCoverage *] * */ SequenceBaseCoverage * SequenceBaseCoverage_alloc(void) { SequenceBaseCoverage * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SequenceBaseCoverage *) ckalloc (sizeof(SequenceBaseCoverage))) == NULL) { warn("SequenceBaseCoverage_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->coverage = NULL; out->gc_points = NULL; out->len = 0; out->seq = NULL; return out; } /* Function: free_SequenceBaseCoverage(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SequenceBaseCoverage *] * * Return [UNKN ] Undocumented return value [SequenceBaseCoverage *] * */ SequenceBaseCoverage * free_SequenceBaseCoverage(SequenceBaseCoverage * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SequenceBaseCoverage obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->coverage != NULL) ckfree(obj->coverage); if( obj->gc_points != NULL) ckfree(obj->gc_points); if( obj->seq != NULL) free_Sequence(obj->seq); ckfree(obj); return NULL; } /* Function: hard_link_TransRegionModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransRegionModel *] * * Return [UNKN ] Undocumented return value [TransRegionModel *] * */ TransRegionModel * hard_link_TransRegionModel(TransRegionModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransRegionModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransRegionModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransRegionModel *] * */ TransRegionModel * TransRegionModel_alloc(void) { TransRegionModel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransRegionModel *) ckalloc (sizeof(TransRegionModel))) == NULL) { warn("TransRegionModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->len = 0; out->region_present = 0; out->region_notpresent = 0; out->nonregion_present = 0; out->nonregion_notpresent = 0; out->region_start = 0; out->gc_point = 0; out->gc_non_point = 0; return out; } /* Function: free_TransRegionModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransRegionModel *] * * Return [UNKN ] Undocumented return value [TransRegionModel *] * */ TransRegionModel * free_TransRegionModel(TransRegionModel * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransRegionModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:33 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define REGION 0 #define NON_REGION 1 #define START 0 #define END 1 #define TransRegionMatrix_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*2)+STATE][i+0] #define TransRegionMatrix_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define TransRegionMatrix_READ_OFF_ERROR -2 #define TransRegionMatrix_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+0)*2)+STATE] #define TransRegionMatrix_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define TransRegionMatrix_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define TransRegionMatrix_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_TransRegionMatrix(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_TransRegionMatrix(TransRegionMatrix * mat) { TransRegionMatrix_access_func_holder holder; holder.access_main = TransRegionMatrix_shatter_access_main; holder.access_special = TransRegionMatrix_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_TransRegionMatrix(mat,holder); } /* Function: TransRegionMatrix_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int TransRegionMatrix_shatter_access_main(TransRegionMatrix * mat,int i,int j,int state) { return TransRegionMatrix_SHATTER_MATRIX(mat,i,j,state); } /* Function: TransRegionMatrix_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int TransRegionMatrix_shatter_access_special(TransRegionMatrix * mat,int i,int j,int state) { return TransRegionMatrix_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_TransRegionMatrix(mat,dpenv) * * Descrip: This function calculates the TransRegionMatrix matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [TransRegionMatrix *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_TransRegionMatrix(TransRegionMatrix * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_0_1; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,2,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("TransRegionMatrix Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); /* For state REGION */ /* setting first movement to score */ score = SIG_0_1[REGION] + (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)); /* From state START to state REGION */ temp = TransRegionMatrix_SHATTER_SPECIAL(mat,i-0,j-1,START) + (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)); if( temp > score ) { score = temp; } /* From state NON_REGION to state REGION */ temp = SIG_0_1[NON_REGION] + mat->model->region_start; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REGION */ /* Add any movement independant score and put away */ SIG_0_0[REGION] = score; /* state REGION is a source for special END */ temp = score + (0) + (0) ; if( temp > TransRegionMatrix_SHATTER_SPECIAL(mat,i,j,END) ) { TransRegionMatrix_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state REGION */ /* For state NON_REGION */ /* setting first movement to score */ score = SIG_0_1[NON_REGION] + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model); /* From state START to state NON_REGION */ temp = TransRegionMatrix_SHATTER_SPECIAL(mat,i-0,j-1,START) + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model); if( temp > score ) { score = temp; } /* From state REGION to state NON_REGION */ temp = SIG_0_1[REGION] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for NON_REGION */ /* Add any movement independant score and put away */ SIG_0_0[NON_REGION] = score; /* state NON_REGION is a source for special END */ temp = score + (0) + (0) ; if( temp > TransRegionMatrix_SHATTER_SPECIAL(mat,i,j,END) ) { TransRegionMatrix_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state NON_REGION */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_TransRegionMatrix(dbsi,out,model,seq) * * Descrip: This function makes a database search of TransRegionMatrix * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: model [UNKN ] Undocumented argument [TransRegionModel*] * Arg: seq [UNKN ] Undocumented argument [SequenceBaseCoverage*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_TransRegionMatrix(DBSearchImpl * dbsi,Hscore * out,TransRegionModel* model,SequenceBaseCoverage* seq ) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_TransRegionMatrix * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_TransRegionMatrix. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_TransRegionMatrix. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for TransRegionMatrix, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_TransRegionMatrix(out,model,seq ); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_TransRegionMatrix *) ckalloc(sizeof(struct thread_pool_holder_TransRegionMatrix)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->model = model; holder->seq = seq; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_TransRegionMatrix,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for TransRegionMatrix"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from TransRegionMatrix",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_TransRegionMatrix(ptr) * * Descrip: dummy loop code foreach thread for TransRegionMatrix * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * thread_loop_TransRegionMatrix(void * ptr) { fatal("dummy thread loop function"); } /* Function: serial_search_TransRegionMatrix(out,model,seq) * * Descrip: This function makes a database search of TransRegionMatrix * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: model [UNKN ] Undocumented argument [TransRegionModel*] * Arg: seq [UNKN ] Undocumented argument [SequenceBaseCoverage*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_TransRegionMatrix(Hscore * out,TransRegionModel* model,SequenceBaseCoverage* seq ) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_TransRegionMatrix(model, seq ); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("TransRegionMatrix search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_TransRegionMatrix(model,seq) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_TransRegionMatrix_only * * * Arg: model [UNKN ] query data structure [TransRegionModel*] * Arg: seq [UNKN ] target data structure [SequenceBaseCoverage*] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_TransRegionMatrix(TransRegionModel* model,SequenceBaseCoverage* seq ) { int bestscore = NEGI; int i; int j; int k; TransRegionMatrix * mat; mat = allocate_TransRegionMatrix_only(model, seq ); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 0) * 2,2,2)) == NULL) { warn("Score only matrix for TransRegionMatrix cannot be allocated, (asking for 1 by %d cells)",mat->leni*2); mat = free_TransRegionMatrix(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-0);ileni;i++) { for(k=0;k<2;k++) TransRegionMatrix_VSMALL_MATRIX(mat,i,j,k) = NEGI; } TransRegionMatrix_VSMALL_SPECIAL(mat,i,j,START) = 0; TransRegionMatrix_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state REGION */ /* setting first movement to score */ score = TransRegionMatrix_VSMALL_MATRIX(mat,i-0,j-1,REGION) + (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)); /* From state START to state REGION */ temp = TransRegionMatrix_VSMALL_SPECIAL(mat,i-0,j-1,START) + (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)); if( temp > score ) { score = temp; } /* From state NON_REGION to state REGION */ temp = TransRegionMatrix_VSMALL_MATRIX(mat,i-0,j-1,NON_REGION) + mat->model->region_start; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REGION */ /* Add any movement independant score and put away */ TransRegionMatrix_VSMALL_MATRIX(mat,i,j,REGION) = score; /* state REGION is a source for special END */ temp = score + (0) + (0) ; if( temp > TransRegionMatrix_VSMALL_SPECIAL(mat,i,j,END) ) { TransRegionMatrix_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state REGION */ /* For state NON_REGION */ /* setting first movement to score */ score = TransRegionMatrix_VSMALL_MATRIX(mat,i-0,j-1,NON_REGION) + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model); /* From state START to state NON_REGION */ temp = TransRegionMatrix_VSMALL_SPECIAL(mat,i-0,j-1,START) + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model); if( temp > score ) { score = temp; } /* From state REGION to state NON_REGION */ temp = TransRegionMatrix_VSMALL_MATRIX(mat,i-0,j-1,REGION) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for NON_REGION */ /* Add any movement independant score and put away */ TransRegionMatrix_VSMALL_MATRIX(mat,i,j,NON_REGION) = score; /* state NON_REGION is a source for special END */ temp = score + (0) + (0) ; if( temp > TransRegionMatrix_VSMALL_SPECIAL(mat,i,j,END) ) { TransRegionMatrix_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state NON_REGION */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < TransRegionMatrix_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = TransRegionMatrix_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_TransRegionMatrix(mat); return bestscore; } /* Function: PackAln_bestmemory_TransRegionMatrix(model,seq,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_TransRegionMatrix * * * Arg: model [UNKN ] query data structure [TransRegionModel*] * Arg: seq [UNKN ] target data structure [SequenceBaseCoverage*] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_TransRegionMatrix(TransRegionModel* model,SequenceBaseCoverage* seq ,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; TransRegionMatrix * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = model->len * seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 2 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_TransRegionMatrix(model, seq ,dpri)) == NULL ) { warn("Unable to allocate large TransRegionMatrix version"); return NULL; } calculate_dpenv_TransRegionMatrix(mat,dpenv); out = PackAln_read_Expl_TransRegionMatrix(mat); } else { mat = allocate_TransRegionMatrix_only(model, seq ); calculate_shatter_TransRegionMatrix(mat,dpenv); out = PackAln_read_Shatter_TransRegionMatrix(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_TransRegionMatrix(model, seq )) == NULL ) { warn("Unable to allocate small TransRegionMatrix version"); return NULL; } out = PackAln_calculate_Small_TransRegionMatrix(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_TransRegionMatrix(model, seq ,dpri)) == NULL ) { warn("Unable to allocate large TransRegionMatrix version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_TransRegionMatrix(mat); out = PackAln_read_Expl_TransRegionMatrix(mat); } } } mat = free_TransRegionMatrix(mat); return out; } /* Function: allocate_TransRegionMatrix_only(model,seq) * * Descrip: This function only allocates the TransRegionMatrix structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: model [UNKN ] query data structure [TransRegionModel*] * Arg: seq [UNKN ] target data structure [SequenceBaseCoverage*] * * Return [UNKN ] Undocumented return value [TransRegionMatrix *] * */ TransRegionMatrix * allocate_TransRegionMatrix_only(TransRegionModel* model,SequenceBaseCoverage* seq ) { TransRegionMatrix * out; if((out= TransRegionMatrix_alloc()) == NULL) { warn("Allocation of basic TransRegionMatrix structure failed..."); return NULL; } out->model = model; out->seq = seq; out->leni = model->len; out->lenj = seq->len; return out; } /* Function: allocate_Expl_TransRegionMatrix(model,seq,dpri) * * Descrip: This function allocates the TransRegionMatrix structure * and the basematrix area for explicit memory implementations * It calls /allocate_TransRegionMatrix_only * * * Arg: model [UNKN ] query data structure [TransRegionModel*] * Arg: seq [UNKN ] target data structure [SequenceBaseCoverage*] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [TransRegionMatrix *] * */ TransRegionMatrix * allocate_Expl_TransRegionMatrix(TransRegionModel* model,SequenceBaseCoverage* seq ,DPRunImpl * dpri) { TransRegionMatrix * out; out = allocate_TransRegionMatrix_only(model, seq ); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*2 && dpri->cache->maxlenj >= (out->leni+0)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*2,(out->leni+0),2,out->lenj+1)) == NULL) { warn("Explicit matrix TransRegionMatrix cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_TransRegionMatrix(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_TransRegionMatrix(out); return out; } /* Function: init_TransRegionMatrix(mat) * * Descrip: This function initates TransRegionMatrix matrix when in explicit mode * Called in /allocate_Expl_TransRegionMatrix * * * Arg: mat [UNKN ] TransRegionMatrix which contains explicit basematrix memory [TransRegionMatrix *] * */ void init_TransRegionMatrix(TransRegionMatrix * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-0);imodel->len;i++) { for(j= (-1);j<2;j++) { TransRegionMatrix_EXPL_MATRIX(mat,i,j,REGION) = NEGI; TransRegionMatrix_EXPL_MATRIX(mat,i,j,NON_REGION) = NEGI; } } for(j= (-1);jseq->len;j++) { for(i= (-0);i<1;i++) { TransRegionMatrix_EXPL_MATRIX(mat,i,j,REGION) = NEGI; TransRegionMatrix_EXPL_MATRIX(mat,i,j,NON_REGION) = NEGI; } TransRegionMatrix_EXPL_SPECIAL(mat,i,j,START) = 0; TransRegionMatrix_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_TransRegionMatrix(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by TransRegionMatrix * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * */ void recalculate_PackAln_TransRegionMatrix(PackAln * pal,TransRegionMatrix * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case REGION : if( offi == 0 && offj == 1 && prev->state == REGION ) { pau->score = (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)) + (0); continue; } if( offj == 1 && prev->state == (START+2) ) { pau->score = (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == NON_REGION ) { pau->score = mat->model->region_start + (0); continue; } warn("In recaluclating PackAln with state REGION, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case NON_REGION : if( offi == 0 && offj == 1 && prev->state == NON_REGION ) { pau->score = TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model) + (0); continue; } if( offj == 1 && prev->state == (START+2) ) { pau->score = TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == REGION ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state NON_REGION, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+2) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+2) : if( offj == 0 && prev->state == NON_REGION ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == REGION ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define TransRegionMatrix_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+0)*2+state]) #define TransRegionMatrix_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+0)*2+state]) #define TransRegionMatrix_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define TransRegionMatrix_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define TransRegionMatrix_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+0)*2 + state]) #define TransRegionMatrix_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define TransRegionMatrix_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 2) + ((i+0) * 2) + (state)]) #define TransRegionMatrix_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 16) + ((i+0) * 16) + (state * 8) + shadow+1]) #define TransRegionMatrix_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_TransRegionMatrix(model,seq) * * Descrip: This function allocates the TransRegionMatrix structure * and the basematrix area for a small memory implementations * It calls /allocate_TransRegionMatrix_only * * * Arg: model [UNKN ] query data structure [TransRegionModel*] * Arg: seq [UNKN ] target data structure [SequenceBaseCoverage*] * * Return [UNKN ] Undocumented return value [TransRegionMatrix *] * */ #define TransRegionMatrix_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) TransRegionMatrix * allocate_Small_TransRegionMatrix(TransRegionModel* model,SequenceBaseCoverage* seq ) { TransRegionMatrix * out; out = allocate_TransRegionMatrix_only(model, seq ); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 0) * 2,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix TransRegionMatrix cannot be allocated, (asking for 2 by %d main cells)",out->leni+1); free_TransRegionMatrix(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_TransRegionMatrix(mat,dpenv) * * Descrip: This function calculates an alignment for TransRegionMatrix structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_TransRegionMatrix * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_TransRegionMatrix * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_TransRegionMatrix(TransRegionMatrix * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for TransRegionMatrix due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_TransRegionMatrix(mat,dpenv); score = start_end_find_end_TransRegionMatrix(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_TransRegionMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_TransRegionMatrix(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == TransRegionMatrix_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_TransRegionMatrix(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 2; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_TransRegionMatrix(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_TransRegionMatrix(mat) * * Descrip: This function calculates an alignment for TransRegionMatrix structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_TransRegionMatrix * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_TransRegionMatrix * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_TransRegionMatrix * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_TransRegionMatrix(TransRegionMatrix * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_TransRegionMatrix(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_TransRegionMatrix(mat); return out; } /* Function: AlnRangeSet_from_TransRegionMatrix(mat) * * Descrip: This function reads off a start/end structure * for TransRegionMatrix structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_TransRegionMatrix * If you have not calculated the matrix use * /AlnRange_calculate_Small_TransRegionMatrix * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_TransRegionMatrix(TransRegionMatrix * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_TransRegionMatrix"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_TransRegionMatrix(mat,&jpos); state = END; while( (temp = AlnRange_build_TransRegionMatrix(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_TransRegionMatrix(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_TransRegionMatrix * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_TransRegionMatrix(TransRegionMatrix * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_TransRegionMatrix"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_TransRegionMatrix(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_TransRegionMatrix alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = TransRegionMatrix_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_TransRegionMatrix(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == TransRegionMatrix_READ_OFF_ERROR) { warn("In AlnRange_build_TransRegionMatrix alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = TransRegionMatrix_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_TransRegionMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_TransRegionMatrix(TransRegionMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_TransRegionMatrix(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == TransRegionMatrix_READ_OFF_ERROR) { warn("In TransRegionMatrix hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In TransRegionMatrix hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In TransRegionMatrix hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_TransRegionMatrix(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_TransRegionMatrix(TransRegionMatrix * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = TransRegionMatrix_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->model->len || j > mat->seq->len) { warn("In TransRegionMatrix matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = TransRegionMatrix_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case REGION : temp = cscore - (mat->model->region_start) - (0); if( temp == TransRegionMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,NON_REGION) ) { *reti = i - 0; *retj = j - 1; *retstate = NON_REGION; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - TransRegionMatrix_HIDDEN_MATRIX(mat,i-0,j-1,NON_REGION); } return TransRegionMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,NON_REGION); } /* Not allowing special sources.. skipping START */ temp = cscore - ((TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model))) - (0); if( temp == TransRegionMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,REGION) ) { *reti = i - 0; *retj = j - 1; *retstate = REGION; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - TransRegionMatrix_HIDDEN_MATRIX(mat,i-0,j-1,REGION); } return TransRegionMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,REGION); } warn("Major problem (!) - in TransRegionMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); case NON_REGION : temp = cscore - (0) - (0); if( temp == TransRegionMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,REGION) ) { *reti = i - 0; *retj = j - 1; *retstate = REGION; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - TransRegionMatrix_HIDDEN_MATRIX(mat,i-0,j-1,REGION); } return TransRegionMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,REGION); } /* Not allowing special sources.. skipping START */ temp = cscore - (TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model)) - (0); if( temp == TransRegionMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,NON_REGION) ) { *reti = i - 0; *retj = j - 1; *retstate = NON_REGION; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - TransRegionMatrix_HIDDEN_MATRIX(mat,i-0,j-1,NON_REGION); } return TransRegionMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,NON_REGION); } warn("Major problem (!) - in TransRegionMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in TransRegionMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_TransRegionMatrix(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_TransRegionMatrix(TransRegionMatrix * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 2; add_PackAln(out,pau); } max_special_strip_TransRegionMatrix(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == TransRegionMatrix_READ_OFF_ERROR) { warn("In special strip read TransRegionMatrix, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read TransRegionMatrix, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 2; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_TransRegionMatrix(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_TransRegionMatrix(TransRegionMatrix * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = TransRegionMatrix_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for TransRegionMatrix, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->seq->len) { warn("In TransRegionMatrix matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = TransRegionMatrix_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source REGION is not a special */ /* Source NON_REGION is not a special */ default: warn("Major problem (!) - in TransRegionMatrix special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_TransRegionMatrix(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_TransRegionMatrix(TransRegionMatrix * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = TransRegionMatrix_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In TransRegionMatrix matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case REGION : /* Source NON_REGION is not a special, should not get here! */ temp = cscore - ((TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model))) - (0); if( temp == TransRegionMatrix_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - TransRegionMatrix_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return TransRegionMatrix_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } /* Source REGION is not a special, should not get here! */ warn("Major problem (!) - in TransRegionMatrix matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case NON_REGION : /* Source REGION is not a special, should not get here! */ temp = cscore - (TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model)) - (0); if( temp == TransRegionMatrix_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - TransRegionMatrix_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return TransRegionMatrix_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } /* Source NON_REGION is not a special, should not get here! */ warn("Major problem (!) - in TransRegionMatrix matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in TransRegionMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_TransRegionMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_TransRegionMatrix(TransRegionMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_TransRegionMatrix(mat,starti,startj,stopi,stopj); TransRegionMatrix_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ TransRegionMatrix_HIDDEN_MATRIX(mat,i,j,REGION) = NEGI; TransRegionMatrix_HIDDEN_MATRIX(mat,i,j,NON_REGION) = NEGI; continue; } /* end of Is not in envelope */ /* For state REGION */ /* setting first movement to score */ score = TransRegionMatrix_HIDDEN_MATRIX(mat,i-0,j-1,REGION) + (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)); /* From state NON_REGION to state REGION */ temp = TransRegionMatrix_HIDDEN_MATRIX(mat,i-0,j-1,NON_REGION) + mat->model->region_start; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REGION */ /* Add any movement independant score and put away */ TransRegionMatrix_HIDDEN_MATRIX(mat,i,j,REGION) = score; /* Finished calculating state REGION */ /* For state NON_REGION */ /* setting first movement to score */ score = TransRegionMatrix_HIDDEN_MATRIX(mat,i-0,j-1,NON_REGION) + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model); /* From state REGION to state NON_REGION */ temp = TransRegionMatrix_HIDDEN_MATRIX(mat,i-0,j-1,REGION) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for NON_REGION */ /* Add any movement independant score and put away */ TransRegionMatrix_HIDDEN_MATRIX(mat,i,j,NON_REGION) = score; /* Finished calculating state NON_REGION */ } } return; } /* Function: init_hidden_TransRegionMatrix(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_TransRegionMatrix(TransRegionMatrix * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-0);i<=stopi;i++) { TransRegionMatrix_HIDDEN_MATRIX(mat,i,j,REGION) = NEGI; TransRegionMatrix_HIDDEN_MATRIX(mat,i,j,NON_REGION) = NEGI; } } return; } /* Function: full_dc_TransRegionMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_TransRegionMatrix * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_TransRegionMatrix to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [TransRegionMatrix *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_TransRegionMatrix(TransRegionMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_TransRegionMatrix"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_TransRegionMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_TransRegionMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_TransRegionMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for TransRegionMatrix, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_TransRegionMatrix(mat,TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_TransRegionMatrix(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_TransRegionMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_TransRegionMatrix(TransRegionMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_TransRegionMatrix(mat); TransRegionMatrix_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_TransRegionMatrix(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_TransRegionMatrix(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_TransRegionMatrix(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_TransRegionMatrix(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_TransRegionMatrix(TransRegionMatrix * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,REGION) = NEGI; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,0) = (-100); TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,1) = (-100); TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,NON_REGION) = NEGI; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,0) = (-100); TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,1) = (-100); continue; } /* end of Is not in envelope */ /* For state REGION, pushing when j - offj <= mergej */ score = TransRegionMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,REGION) + (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)); if( j - 1 <= mergej) { TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,0) = i-0; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,1) = j-1; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,2) = REGION; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,3) = i; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,4) = j; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,5) = REGION; } else { for(k=0;k<7;k++) TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,k) = TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REGION,k); } temp = TransRegionMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,NON_REGION) + mat->model->region_start; if( temp > score) { score = temp; if( j - 1 <= mergej) { TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,0) = i-0; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,1) = j-1; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,2) = NON_REGION; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,3) = i; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,4) = j; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,5) = REGION; } else { for(k=0;k<7;k++) TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,k) = TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,NON_REGION,k); } } /* Add any movement independant score */ TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,REGION) = score; /* Finished with state REGION */ /* For state NON_REGION, pushing when j - offj <= mergej */ score = TransRegionMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,NON_REGION) + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model); if( j - 1 <= mergej) { TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,0) = i-0; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,1) = j-1; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,2) = NON_REGION; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,3) = i; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,4) = j; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,5) = NON_REGION; } else { for(k=0;k<7;k++) TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,k) = TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,NON_REGION,k); } temp = TransRegionMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,REGION) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,0) = i-0; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,1) = j-1; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,2) = REGION; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,3) = i; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,4) = j; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,5) = NON_REGION; } else { for(k=0;k<7;k++) TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,k) = TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REGION,k); } } /* Add any movement independant score */ TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,NON_REGION) = score; /* Finished with state NON_REGION */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_TransRegionMatrix(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_TransRegionMatrix(TransRegionMatrix * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,REGION) = NEGI; TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,NON_REGION) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state REGION */ /* setting first movement to score */ score = TransRegionMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,REGION) + (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REGION,k); /* From state NON_REGION to state REGION */ temp = TransRegionMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,NON_REGION) + mat->model->region_start; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,NON_REGION,k); } /* Ok - finished max calculation for REGION */ /* Add any movement independant score and put away */ TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,REGION) = score; for(k=0;k<7;k++) TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REGION */ /* For state NON_REGION */ /* setting first movement to score */ score = TransRegionMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,NON_REGION) + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,NON_REGION,k); /* From state REGION to state NON_REGION */ temp = TransRegionMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,REGION) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REGION,k); } /* Ok - finished max calculation for NON_REGION */ /* Add any movement independant score and put away */ TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,NON_REGION) = score; for(k=0;k<7;k++) TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state NON_REGION */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_TransRegionMatrix(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_TransRegionMatrix(TransRegionMatrix * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,REGION) = NEGI; TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,NON_REGION) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state REGION */ /* setting first movement to score */ score = TransRegionMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,REGION) + (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)); /* From state NON_REGION to state REGION */ temp = TransRegionMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,NON_REGION) + mat->model->region_start; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REGION */ /* Add any movement independant score and put away */ TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,REGION) = score; /* Finished calculating state REGION */ /* For state NON_REGION */ /* setting first movement to score */ score = TransRegionMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,NON_REGION) + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model); /* From state REGION to state NON_REGION */ temp = TransRegionMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,REGION) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for NON_REGION */ /* Add any movement independant score and put away */ TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,NON_REGION) = score; /* Finished calculating state NON_REGION */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_TransRegionMatrix(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * */ } void init_dc_TransRegionMatrix(TransRegionMatrix * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-0);imodel->len;i++) { TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,REGION) = NEGI; TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,NON_REGION) = NEGI; for(k=0;k<7;k++) { TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,k) = (-1); TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,k) = (-1); } } } return; } /* Function: start_end_find_end_TransRegionMatrix(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [TransRegionMatrix *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_TransRegionMatrix(TransRegionMatrix * mat,int * endj) { register int j; register int max; register int maxj; max = TransRegionMatrix_DC_SHADOW_SPECIAL(mat,0,mat->seq->len-1,END); maxj = mat->seq->len-1; for(j= mat->seq->len-2 ;j >= 0 ;j--) { if( TransRegionMatrix_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = TransRegionMatrix_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_TransRegionMatrix(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [TransRegionMatrix] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_TransRegionMatrix(TransRegionMatrix *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->model->len; lenj = mat->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 0) * 2,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 0) * 2 * 8,sizeof(int)); for(j=0;jseq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)) + (0); /* assign local shadown pointer */ localsp = &(TransRegionMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REGION,0)); /* From state START to state REGION */ temp = TransRegionMatrix_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,START) + (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for REGION... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= REGION; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state NON_REGION to state REGION */ temp = TransRegionMatrix_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,NON_REGION) + mat->model->region_start +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(TransRegionMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,NON_REGION,0)); } /* Ok - finished max calculation for REGION */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ TransRegionMatrix_DC_OPT_SHADOW_MATRIX(mat,i,j,REGION) = score; for(k=0;k<7;k++) TransRegionMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REGION,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state REGION is a source for special END */ temp = score + (0) + (0) ; if( temp > TransRegionMatrix_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { TransRegionMatrix_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) TransRegionMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = TransRegionMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REGION,k); TransRegionMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = TransRegionMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REGION,6); TransRegionMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; TransRegionMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; TransRegionMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = REGION; } /* Finished calculating state REGION */ /* For state NON_REGION */ /* setting first movement to score */ score = TransRegionMatrix_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,NON_REGION) + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model) + (0); /* assign local shadown pointer */ localsp = &(TransRegionMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,NON_REGION,0)); /* From state START to state NON_REGION */ temp = TransRegionMatrix_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,START) + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for NON_REGION... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= NON_REGION; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state REGION to state NON_REGION */ temp = TransRegionMatrix_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REGION) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(TransRegionMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REGION,0)); } /* Ok - finished max calculation for NON_REGION */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ TransRegionMatrix_DC_OPT_SHADOW_MATRIX(mat,i,j,NON_REGION) = score; for(k=0;k<7;k++) TransRegionMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state NON_REGION is a source for special END */ temp = score + (0) + (0) ; if( temp > TransRegionMatrix_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { TransRegionMatrix_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) TransRegionMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = TransRegionMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,k); TransRegionMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = TransRegionMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,6); TransRegionMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; TransRegionMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; TransRegionMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = NON_REGION; } /* Finished calculating state NON_REGION */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_TransRegionMatrix(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * */ void init_start_end_linear_TransRegionMatrix(TransRegionMatrix * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-0);imodel->len;i++) { TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,REGION) = NEGI; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,REGION,0) = (-1); TransRegionMatrix_DC_SHADOW_MATRIX(mat,i,j,NON_REGION) = NEGI; TransRegionMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,NON_REGION,0) = (-1); } } for(j=(-1);jseq->len;j++) { TransRegionMatrix_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; TransRegionMatrix_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; TransRegionMatrix_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_TransRegionMatrix(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_TransRegionMatrix(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_TransRegionMatrix(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "REGION_STATE","NON_REGION_STATE","END" }; /* Function: AlnConvertSet_TransRegionMatrix(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "REGION","RANDOM","END" }; AlnConvertSet * AlnConvertSet_TransRegionMatrix(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REGION; acu->state2 = REGION; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 2; acu->is_from_special = TRUE; acu->state2 = REGION; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = NON_REGION; acu->state2 = REGION; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = NON_REGION; acu->state2 = NON_REGION; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 2; acu->is_from_special = TRUE; acu->state2 = NON_REGION; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REGION; acu->state2 = NON_REGION; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = NON_REGION; acu->state2 = END + 2; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REGION; acu->state2 = END + 2; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; add_collapse_label_AlnConvertSet(out,"NON_REGION_STATE","RANDOM"); add_collapse_label_AlnConvertSet(out,"REGION_STATE","REGION"); return out; } /* Function: PackAln_read_Expl_TransRegionMatrix(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_TransRegionMatrix(TransRegionMatrix * mat) { TransRegionMatrix_access_func_holder holder; holder.access_main = TransRegionMatrix_explicit_access_main; holder.access_special = TransRegionMatrix_explicit_access_special; return PackAln_read_generic_TransRegionMatrix(mat,holder); } /* Function: TransRegionMatrix_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int TransRegionMatrix_explicit_access_main(TransRegionMatrix * mat,int i,int j,int state) { return TransRegionMatrix_EXPL_MATRIX(mat,i,j,state); } /* Function: TransRegionMatrix_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int TransRegionMatrix_explicit_access_special(TransRegionMatrix * mat,int i,int j,int state) { return TransRegionMatrix_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_TransRegionMatrix(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: h [UNKN ] Undocumented argument [TransRegionMatrix_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_TransRegionMatrix(TransRegionMatrix * mat,TransRegionMatrix_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_TransRegionMatrix(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in TransRegionMatrix_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 2; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_TransRegionMatrix(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_TransRegionMatrix(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == TransRegionMatrix_READ_OFF_ERROR || j == TransRegionMatrix_READ_OFF_ERROR || state == TransRegionMatrix_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in TransRegionMatrix_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 2; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_TransRegionMatrix(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [TransRegionMatrix_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_TransRegionMatrix(TransRegionMatrix * mat,int * ri,int * rj,int * state,boolean * isspecial,TransRegionMatrix_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->seq->len-1,END); maxj = mat->seq->len-1; for(j= mat->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: TransRegionMatrix_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void TransRegionMatrix_debug_show_matrix(TransRegionMatrix * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;imodel->len;i++) { for(j=startj;jseq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State REGION %d\n",TransRegionMatrix_EXPL_MATRIX(mat,i,j,REGION)); fprintf(ofp,"State NON_REGION %d\n",TransRegionMatrix_EXPL_MATRIX(mat,i,j,NON_REGION)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_TransRegionMatrix(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [TransRegionMatrix_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_TransRegionMatrix(TransRegionMatrix * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,TransRegionMatrix_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = TransRegionMatrix_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->model->len || j > mat->seq->len) { warn("In TransRegionMatrix matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case REGION : temp = cscore - (mat->model->region_start) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,NON_REGION) ) { *reti = i - 0; *retj = j - 1; *retstate = NON_REGION; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,NON_REGION); } return (*h.access_main)(mat,i - 0,j - 1,NON_REGION); } temp = cscore - ((TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_main)(mat,i - 0,j - 1,START); } temp = cscore - ((TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REGION) ) { *reti = i - 0; *retj = j - 1; *retstate = REGION; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REGION); } return (*h.access_main)(mat,i - 0,j - 1,REGION); } warn("Major problem (!) - in TransRegionMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); case NON_REGION : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REGION) ) { *reti = i - 0; *retj = j - 1; *retstate = REGION; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REGION); } return (*h.access_main)(mat,i - 0,j - 1,REGION); } temp = cscore - (TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model)) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_main)(mat,i - 0,j - 1,START); } temp = cscore - (TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,NON_REGION) ) { *reti = i - 0; *retj = j - 1; *retstate = NON_REGION; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,NON_REGION); } return (*h.access_main)(mat,i - 0,j - 1,NON_REGION); } warn("Major problem (!) - in TransRegionMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in TransRegionMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_TransRegionMatrix(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [TransRegionMatrix_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_TransRegionMatrix(TransRegionMatrix * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,TransRegionMatrix_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = TransRegionMatrix_READ_OFF_ERROR; if( j < 0 || j > mat->seq->len) { warn("In TransRegionMatrix matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source REGION is from main matrix */ for(i= mat->model->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,REGION) ) { *reti = i - 0; *retj = j - 0; *retstate = REGION; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,REGION); } return (*h.access_main)(mat,i - 0,j - 0,REGION) ; } } /* end of for i >= 0 */ /* source NON_REGION is from main matrix */ for(i= mat->model->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,NON_REGION) ) { *reti = i - 0; *retj = j - 0; *retstate = NON_REGION; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,NON_REGION); } return (*h.access_main)(mat,i - 0,j - 0,NON_REGION) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in TransRegionMatrix read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_TransRegionMatrix(mat) * * Descrip: This function calculates the TransRegionMatrix matrix when in explicit mode * To allocate the matrix use /allocate_Expl_TransRegionMatrix * * * Arg: mat [UNKN ] TransRegionMatrix which contains explicit basematrix memory [TransRegionMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_TransRegionMatrix(TransRegionMatrix * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_TransRegionMatrix, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("TransRegionMatrix Matrix calculation: "); for(j=0;jseq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)); /* From state START to state REGION */ temp = TransRegionMatrix_EXPL_SPECIAL(mat,i-0,j-1,START) + (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)); if( temp > score ) { score = temp; } /* From state NON_REGION to state REGION */ temp = TransRegionMatrix_EXPL_MATRIX(mat,i-0,j-1,NON_REGION) + mat->model->region_start; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REGION */ /* Add any movement independant score and put away */ TransRegionMatrix_EXPL_MATRIX(mat,i,j,REGION) = score; /* state REGION is a source for special END */ temp = score + (0) + (0) ; if( temp > TransRegionMatrix_EXPL_SPECIAL(mat,i,j,END) ) { TransRegionMatrix_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state REGION */ /* For state NON_REGION */ /* setting first movement to score */ score = TransRegionMatrix_EXPL_MATRIX(mat,i-0,j-1,NON_REGION) + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model); /* From state START to state NON_REGION */ temp = TransRegionMatrix_EXPL_SPECIAL(mat,i-0,j-1,START) + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model); if( temp > score ) { score = temp; } /* From state REGION to state NON_REGION */ temp = TransRegionMatrix_EXPL_MATRIX(mat,i-0,j-1,REGION) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for NON_REGION */ /* Add any movement independant score and put away */ TransRegionMatrix_EXPL_MATRIX(mat,i,j,NON_REGION) = score; /* state NON_REGION is a source for special END */ temp = score + (0) + (0) ; if( temp > TransRegionMatrix_EXPL_SPECIAL(mat,i,j,END) ) { TransRegionMatrix_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state NON_REGION */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_TransRegionMatrix(mat,dpenv) * * Descrip: This function calculates the TransRegionMatrix matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] TransRegionMatrix which contains explicit basematrix memory [TransRegionMatrix *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_TransRegionMatrix(TransRegionMatrix * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_TransRegionMatrix, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { TransRegionMatrix_EXPL_MATRIX(mat,i,j,REGION) = NEGI; TransRegionMatrix_EXPL_MATRIX(mat,i,j,NON_REGION) = NEGI; } } for(j=-1;jlenj;j++) { TransRegionMatrix_EXPL_SPECIAL(mat,i,j,START) = 0; TransRegionMatrix_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("TransRegionMatrix Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { TransRegionMatrix_EXPL_MATRIX(mat,i,j,REGION) = NEGI; TransRegionMatrix_EXPL_MATRIX(mat,i,j,NON_REGION) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state REGION */ /* setting first movement to score */ score = TransRegionMatrix_EXPL_MATRIX(mat,i-0,j-1,REGION) + (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)); /* From state START to state REGION */ temp = TransRegionMatrix_EXPL_SPECIAL(mat,i-0,j-1,START) + (TRANS_REGION_MODEL_SCORE(mat->seq,j,mat->model)+TRANS_REGION_GC_SCORE(mat->seq,j,mat->model)); if( temp > score ) { score = temp; } /* From state NON_REGION to state REGION */ temp = TransRegionMatrix_EXPL_MATRIX(mat,i-0,j-1,NON_REGION) + mat->model->region_start; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REGION */ /* Add any movement independant score and put away */ TransRegionMatrix_EXPL_MATRIX(mat,i,j,REGION) = score; /* state REGION is a source for special END */ temp = score + (0) + (0) ; if( temp > TransRegionMatrix_EXPL_SPECIAL(mat,i,j,END) ) { TransRegionMatrix_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state REGION */ /* For state NON_REGION */ /* setting first movement to score */ score = TransRegionMatrix_EXPL_MATRIX(mat,i-0,j-1,NON_REGION) + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model); /* From state START to state NON_REGION */ temp = TransRegionMatrix_EXPL_SPECIAL(mat,i-0,j-1,START) + TRANS_NON_REGION_MODEL_SCORE(mat->seq,j,mat->model); if( temp > score ) { score = temp; } /* From state REGION to state NON_REGION */ temp = TransRegionMatrix_EXPL_MATRIX(mat,i-0,j-1,REGION) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for NON_REGION */ /* Add any movement independant score and put away */ TransRegionMatrix_EXPL_MATRIX(mat,i,j,NON_REGION) = score; /* state NON_REGION is a source for special END */ temp = score + (0) + (0) ; if( temp > TransRegionMatrix_EXPL_SPECIAL(mat,i,j,END) ) { TransRegionMatrix_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state NON_REGION */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: TransRegionMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransRegionMatrix *] * */ TransRegionMatrix * TransRegionMatrix_alloc(void) { TransRegionMatrix * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransRegionMatrix *) ckalloc (sizeof(TransRegionMatrix))) == NULL) { warn("TransRegionMatrix_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_TransRegionMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransRegionMatrix *] * * Return [UNKN ] Undocumented return value [TransRegionMatrix *] * */ TransRegionMatrix * free_TransRegionMatrix(TransRegionMatrix * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransRegionMatrix obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->model is linked in */ /* obj->seq is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/transregiondp.h0000644000175000001440000006013510670453715017170 0ustar philippusers#ifndef DYNAMITEtransregiondpHEADERFILE #define DYNAMITEtransregiondpHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "transfactor.h" #include "dyna.h" #define TRANS_REGION_MODEL_SCORE(seq,j,model) (seq->coverage[j] == 0 ? model->region_notpresent : model->region_present) #define TRANS_NON_REGION_MODEL_SCORE(seq,j,model) (seq->coverage[j] == 0 ? model->nonregion_notpresent : model->nonregion_present) #define TRANS_REGION_GC_SCORE(seq,j,model) (seq->gc_points[j] == 1 ? model->gc_point : model->gc_non_point) struct Wise2_SequenceBaseCoverage { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * coverage; char * gc_points; int len; Sequence * seq; } ; /* SequenceBaseCoverage defined */ #ifndef DYNAMITE_DEFINED_SequenceBaseCoverage typedef struct Wise2_SequenceBaseCoverage Wise2_SequenceBaseCoverage; #define SequenceBaseCoverage Wise2_SequenceBaseCoverage #define DYNAMITE_DEFINED_SequenceBaseCoverage #endif struct Wise2_TransRegionModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int len; Score region_present; Score region_notpresent; Score nonregion_present; Score nonregion_notpresent; Score region_start; Score gc_point; Score gc_non_point; } ; /* TransRegionModel defined */ #ifndef DYNAMITE_DEFINED_TransRegionModel typedef struct Wise2_TransRegionModel Wise2_TransRegionModel; #define TransRegionModel Wise2_TransRegionModel #define DYNAMITE_DEFINED_TransRegionModel #endif struct Wise2_TransRegionMatrix { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; TransRegionModel* model; SequenceBaseCoverage* seq; } ; /* TransRegionMatrix defined */ #ifndef DYNAMITE_DEFINED_TransRegionMatrix typedef struct Wise2_TransRegionMatrix Wise2_TransRegionMatrix; #define TransRegionMatrix Wise2_TransRegionMatrix #define DYNAMITE_DEFINED_TransRegionMatrix #endif #ifdef PTHREAD struct thread_pool_holder_TransRegionMatrix { TransRegionModel* model;/* Static query data: never free'd */ SequenceBaseCoverage* seq; /* Static target data: never free'd */ pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_TransRegionMatrix_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(TransRegionMatrix*,int,int,int); int (*access_special)(TransRegionMatrix*,int,int,int); } ; /* TransRegionMatrix_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_TransRegionMatrix_access_func_holder typedef struct Wise2_TransRegionMatrix_access_func_holder Wise2_TransRegionMatrix_access_func_holder; #define TransRegionMatrix_access_func_holder Wise2_TransRegionMatrix_access_func_holder #define DYNAMITE_DEFINED_TransRegionMatrix_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_SequenceBaseCoverage(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SequenceBaseCoverage *] * * Return [UNKN ] Undocumented return value [SequenceBaseCoverage *] * */ SequenceBaseCoverage * Wise2_hard_link_SequenceBaseCoverage(SequenceBaseCoverage * obj); #define hard_link_SequenceBaseCoverage Wise2_hard_link_SequenceBaseCoverage /* Function: SequenceBaseCoverage_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SequenceBaseCoverage *] * */ SequenceBaseCoverage * Wise2_SequenceBaseCoverage_alloc(void); #define SequenceBaseCoverage_alloc Wise2_SequenceBaseCoverage_alloc /* Function: free_SequenceBaseCoverage(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SequenceBaseCoverage *] * * Return [UNKN ] Undocumented return value [SequenceBaseCoverage *] * */ SequenceBaseCoverage * Wise2_free_SequenceBaseCoverage(SequenceBaseCoverage * obj); #define free_SequenceBaseCoverage Wise2_free_SequenceBaseCoverage /* Function: hard_link_TransRegionModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransRegionModel *] * * Return [UNKN ] Undocumented return value [TransRegionModel *] * */ TransRegionModel * Wise2_hard_link_TransRegionModel(TransRegionModel * obj); #define hard_link_TransRegionModel Wise2_hard_link_TransRegionModel /* Function: TransRegionModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransRegionModel *] * */ TransRegionModel * Wise2_TransRegionModel_alloc(void); #define TransRegionModel_alloc Wise2_TransRegionModel_alloc /* Function: free_TransRegionModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransRegionModel *] * * Return [UNKN ] Undocumented return value [TransRegionModel *] * */ TransRegionModel * Wise2_free_TransRegionModel(TransRegionModel * obj); #define free_TransRegionModel Wise2_free_TransRegionModel /* Function: PackAln_read_Shatter_TransRegionMatrix(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_TransRegionMatrix(TransRegionMatrix * mat); #define PackAln_read_Shatter_TransRegionMatrix Wise2_PackAln_read_Shatter_TransRegionMatrix /* Function: calculate_shatter_TransRegionMatrix(mat,dpenv) * * Descrip: This function calculates the TransRegionMatrix matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [TransRegionMatrix *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_TransRegionMatrix(TransRegionMatrix * mat,DPEnvelope * dpenv); #define calculate_shatter_TransRegionMatrix Wise2_calculate_shatter_TransRegionMatrix /* Function: search_TransRegionMatrix(dbsi,out,model,seq) * * Descrip: This function makes a database search of TransRegionMatrix * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: model [UNKN ] Undocumented argument [TransRegionModel*] * Arg: seq [UNKN ] Undocumented argument [SequenceBaseCoverage*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_TransRegionMatrix(DBSearchImpl * dbsi,Hscore * out,TransRegionModel* model,SequenceBaseCoverage* seq ); #define search_TransRegionMatrix Wise2_search_TransRegionMatrix /* Function: serial_search_TransRegionMatrix(out,model,seq) * * Descrip: This function makes a database search of TransRegionMatrix * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: model [UNKN ] Undocumented argument [TransRegionModel*] * Arg: seq [UNKN ] Undocumented argument [SequenceBaseCoverage*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_TransRegionMatrix(Hscore * out,TransRegionModel* model,SequenceBaseCoverage* seq ); #define serial_search_TransRegionMatrix Wise2_serial_search_TransRegionMatrix /* Function: PackAln_bestmemory_TransRegionMatrix(model,seq,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_TransRegionMatrix * * * Arg: model [UNKN ] query data structure [TransRegionModel*] * Arg: seq [UNKN ] target data structure [SequenceBaseCoverage*] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_TransRegionMatrix(TransRegionModel* model,SequenceBaseCoverage* seq ,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_TransRegionMatrix Wise2_PackAln_bestmemory_TransRegionMatrix /* Function: allocate_Expl_TransRegionMatrix(model,seq,dpri) * * Descrip: This function allocates the TransRegionMatrix structure * and the basematrix area for explicit memory implementations * It calls /allocate_TransRegionMatrix_only * * * Arg: model [UNKN ] query data structure [TransRegionModel*] * Arg: seq [UNKN ] target data structure [SequenceBaseCoverage*] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [TransRegionMatrix *] * */ TransRegionMatrix * Wise2_allocate_Expl_TransRegionMatrix(TransRegionModel* model,SequenceBaseCoverage* seq ,DPRunImpl * dpri); #define allocate_Expl_TransRegionMatrix Wise2_allocate_Expl_TransRegionMatrix /* Function: recalculate_PackAln_TransRegionMatrix(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by TransRegionMatrix * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * */ void Wise2_recalculate_PackAln_TransRegionMatrix(PackAln * pal,TransRegionMatrix * mat); #define recalculate_PackAln_TransRegionMatrix Wise2_recalculate_PackAln_TransRegionMatrix /* Function: allocate_Small_TransRegionMatrix(model,seq) * * Descrip: This function allocates the TransRegionMatrix structure * and the basematrix area for a small memory implementations * It calls /allocate_TransRegionMatrix_only * * * Arg: model [UNKN ] query data structure [TransRegionModel*] * Arg: seq [UNKN ] target data structure [SequenceBaseCoverage*] * * Return [UNKN ] Undocumented return value [TransRegionMatrix *] * */ TransRegionMatrix * Wise2_allocate_Small_TransRegionMatrix(TransRegionModel* model,SequenceBaseCoverage* seq ); #define allocate_Small_TransRegionMatrix Wise2_allocate_Small_TransRegionMatrix /* Function: PackAln_calculate_Small_TransRegionMatrix(mat,dpenv) * * Descrip: This function calculates an alignment for TransRegionMatrix structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_TransRegionMatrix * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_TransRegionMatrix * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_TransRegionMatrix(TransRegionMatrix * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_TransRegionMatrix Wise2_PackAln_calculate_Small_TransRegionMatrix /* Function: AlnRangeSet_calculate_Small_TransRegionMatrix(mat) * * Descrip: This function calculates an alignment for TransRegionMatrix structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_TransRegionMatrix * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_TransRegionMatrix * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_TransRegionMatrix * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_TransRegionMatrix(TransRegionMatrix * mat); #define AlnRangeSet_calculate_Small_TransRegionMatrix Wise2_AlnRangeSet_calculate_Small_TransRegionMatrix /* Function: AlnRangeSet_from_TransRegionMatrix(mat) * * Descrip: This function reads off a start/end structure * for TransRegionMatrix structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_TransRegionMatrix * If you have not calculated the matrix use * /AlnRange_calculate_Small_TransRegionMatrix * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_TransRegionMatrix(TransRegionMatrix * mat); #define AlnRangeSet_from_TransRegionMatrix Wise2_AlnRangeSet_from_TransRegionMatrix /* Function: convert_PackAln_to_AlnBlock_TransRegionMatrix(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_TransRegionMatrix(PackAln * pal); #define convert_PackAln_to_AlnBlock_TransRegionMatrix Wise2_convert_PackAln_to_AlnBlock_TransRegionMatrix /* Function: PackAln_read_Expl_TransRegionMatrix(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_TransRegionMatrix(TransRegionMatrix * mat); #define PackAln_read_Expl_TransRegionMatrix Wise2_PackAln_read_Expl_TransRegionMatrix /* Function: PackAln_read_generic_TransRegionMatrix(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [TransRegionMatrix *] * Arg: h [UNKN ] Undocumented argument [TransRegionMatrix_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_TransRegionMatrix(TransRegionMatrix * mat,TransRegionMatrix_access_func_holder h); #define PackAln_read_generic_TransRegionMatrix Wise2_PackAln_read_generic_TransRegionMatrix /* Function: calculate_TransRegionMatrix(mat) * * Descrip: This function calculates the TransRegionMatrix matrix when in explicit mode * To allocate the matrix use /allocate_Expl_TransRegionMatrix * * * Arg: mat [UNKN ] TransRegionMatrix which contains explicit basematrix memory [TransRegionMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_TransRegionMatrix(TransRegionMatrix * mat); #define calculate_TransRegionMatrix Wise2_calculate_TransRegionMatrix /* Function: calculate_dpenv_TransRegionMatrix(mat,dpenv) * * Descrip: This function calculates the TransRegionMatrix matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] TransRegionMatrix which contains explicit basematrix memory [TransRegionMatrix *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_TransRegionMatrix(TransRegionMatrix * mat,DPEnvelope * dpenv); #define calculate_dpenv_TransRegionMatrix Wise2_calculate_dpenv_TransRegionMatrix /* Function: TransRegionMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransRegionMatrix *] * */ TransRegionMatrix * Wise2_TransRegionMatrix_alloc(void); #define TransRegionMatrix_alloc Wise2_TransRegionMatrix_alloc /* Function: free_TransRegionMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransRegionMatrix *] * * Return [UNKN ] Undocumented return value [TransRegionMatrix *] * */ TransRegionMatrix * Wise2_free_TransRegionMatrix(TransRegionMatrix * obj); #define free_TransRegionMatrix Wise2_free_TransRegionMatrix /* Unplaced functions */ /* There has been no indication of the use of these functions */ SequenceBaseCoverage * Wise2_new_SequenceBaseCoverage(TransFactorMatchSet * tfms); #define new_SequenceBaseCoverage Wise2_new_SequenceBaseCoverage TransRegionModel * Wise2_new_logodds_TransRegionModel(double in_region_prob,double out_region_prob,double in_cost,double gc_region_ratio); #define new_logodds_TransRegionModel Wise2_new_logodds_TransRegionModel /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_TransRegionMatrix_shatter_access_main(TransRegionMatrix * mat,int i,int j,int state); #define TransRegionMatrix_shatter_access_main Wise2_TransRegionMatrix_shatter_access_main int Wise2_TransRegionMatrix_shatter_access_special(TransRegionMatrix * mat,int i,int j,int state); #define TransRegionMatrix_shatter_access_special Wise2_TransRegionMatrix_shatter_access_special void * Wise2_thread_loop_TransRegionMatrix(void * ptr); #define thread_loop_TransRegionMatrix Wise2_thread_loop_TransRegionMatrix int Wise2_score_only_TransRegionMatrix(TransRegionModel* model,SequenceBaseCoverage* seq ); #define score_only_TransRegionMatrix Wise2_score_only_TransRegionMatrix TransRegionMatrix * Wise2_allocate_TransRegionMatrix_only(TransRegionModel* model,SequenceBaseCoverage* seq ); #define allocate_TransRegionMatrix_only Wise2_allocate_TransRegionMatrix_only void Wise2_init_TransRegionMatrix(TransRegionMatrix * mat); #define init_TransRegionMatrix Wise2_init_TransRegionMatrix AlnRange * Wise2_AlnRange_build_TransRegionMatrix(TransRegionMatrix * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_TransRegionMatrix Wise2_AlnRange_build_TransRegionMatrix boolean Wise2_read_hidden_TransRegionMatrix(TransRegionMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_TransRegionMatrix Wise2_read_hidden_TransRegionMatrix int Wise2_max_hidden_TransRegionMatrix(TransRegionMatrix * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_TransRegionMatrix Wise2_max_hidden_TransRegionMatrix boolean Wise2_read_special_strip_TransRegionMatrix(TransRegionMatrix * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_TransRegionMatrix Wise2_read_special_strip_TransRegionMatrix int Wise2_max_special_strip_TransRegionMatrix(TransRegionMatrix * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_TransRegionMatrix Wise2_max_special_strip_TransRegionMatrix int Wise2_max_matrix_to_special_TransRegionMatrix(TransRegionMatrix * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_TransRegionMatrix Wise2_max_matrix_to_special_TransRegionMatrix void Wise2_calculate_hidden_TransRegionMatrix(TransRegionMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_TransRegionMatrix Wise2_calculate_hidden_TransRegionMatrix void Wise2_init_hidden_TransRegionMatrix(TransRegionMatrix * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_TransRegionMatrix Wise2_init_hidden_TransRegionMatrix boolean Wise2_full_dc_TransRegionMatrix(TransRegionMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_TransRegionMatrix Wise2_full_dc_TransRegionMatrix boolean Wise2_do_dc_single_pass_TransRegionMatrix(TransRegionMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_TransRegionMatrix Wise2_do_dc_single_pass_TransRegionMatrix void Wise2_push_dc_at_merge_TransRegionMatrix(TransRegionMatrix * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_TransRegionMatrix Wise2_push_dc_at_merge_TransRegionMatrix void Wise2_follow_on_dc_TransRegionMatrix(TransRegionMatrix * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_TransRegionMatrix Wise2_follow_on_dc_TransRegionMatrix void Wise2_run_up_dc_TransRegionMatrix(TransRegionMatrix * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_TransRegionMatrix Wise2_run_up_dc_TransRegionMatrix void Wise2_init_dc_TransRegionMatrix(TransRegionMatrix * mat); #define init_dc_TransRegionMatrix Wise2_init_dc_TransRegionMatrix int Wise2_start_end_find_end_TransRegionMatrix(TransRegionMatrix * mat,int * endj); #define start_end_find_end_TransRegionMatrix Wise2_start_end_find_end_TransRegionMatrix boolean Wise2_dc_optimised_start_end_calc_TransRegionMatrix(TransRegionMatrix *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_TransRegionMatrix Wise2_dc_optimised_start_end_calc_TransRegionMatrix void Wise2_init_start_end_linear_TransRegionMatrix(TransRegionMatrix * mat); #define init_start_end_linear_TransRegionMatrix Wise2_init_start_end_linear_TransRegionMatrix AlnConvertSet * Wise2_AlnConvertSet_TransRegionMatrix(void); #define AlnConvertSet_TransRegionMatrix Wise2_AlnConvertSet_TransRegionMatrix int Wise2_TransRegionMatrix_explicit_access_main(TransRegionMatrix * mat,int i,int j,int state); #define TransRegionMatrix_explicit_access_main Wise2_TransRegionMatrix_explicit_access_main int Wise2_TransRegionMatrix_explicit_access_special(TransRegionMatrix * mat,int i,int j,int state); #define TransRegionMatrix_explicit_access_special Wise2_TransRegionMatrix_explicit_access_special int Wise2_find_end_TransRegionMatrix(TransRegionMatrix * mat,int * ri,int * rj,int * state,boolean * isspecial,TransRegionMatrix_access_func_holder h); #define find_end_TransRegionMatrix Wise2_find_end_TransRegionMatrix void Wise2_TransRegionMatrix_debug_show_matrix(TransRegionMatrix * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define TransRegionMatrix_debug_show_matrix Wise2_TransRegionMatrix_debug_show_matrix int Wise2_max_calc_TransRegionMatrix(TransRegionMatrix * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,TransRegionMatrix_access_func_holder h); #define max_calc_TransRegionMatrix Wise2_max_calc_TransRegionMatrix int Wise2_max_calc_special_TransRegionMatrix(TransRegionMatrix * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,TransRegionMatrix_access_func_holder h); #define max_calc_special_TransRegionMatrix Wise2_max_calc_special_TransRegionMatrix #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/genewisemodel.c0000644000175000001440000014325110670453714017133 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genewisemodel.h" /* Function: pack_GeneWiseScore(gws) * * Descrip: Packing up the GeneWise model into a byte structure * * * Arg: gws [UNKN ] Undocumented argument [GeneWiseScore *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 110 "genewisemodel.dy" char * pack_GeneWiseScore(GeneWiseScore * gws) { char * out; return out; } /* Function: GeneWiseScoreFlat_from_GeneWiseScore(gws) * * Descrip: This produces a flattened GeneWiseSegment structure * for use in quick implementations (memory lookup * is much better due to everything being a single * piece of memory). * * * Arg: gws [UNKN ] Undocumented argument [GeneWiseScore *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *] * */ # line 125 "genewisemodel.dy" GeneWiseScoreFlat * GeneWiseScoreFlat_from_GeneWiseScore(GeneWiseScore * gws) { int i; int j; GeneWiseScoreFlat * gwsf; gwsf = GeneWiseScoreFlat_alloc(); gwsf->seg = (GeneWiseScoreSegment *) malloc (sizeof(GeneWiseScoreSegment) * gws->len); for(i=0;ilen;i++) { for(j=0;j<126;j++) { gwsf->seg[i].match[j] = gws->seg[i]->match[j]; gwsf->seg[i].insert[j] = gws->seg[i]->insert[j]; } for(j=0;jseg[i].transition[j] = gws->seg[i]->transition[j]; } gwsf->len = gws->len; return gwsf; } /* Function: free_GeneWiseScoreFlat(obj) * * Descrip: Frees the GeneWiseScoreFlat datastructure * * overrides the usual deconstructor * * * Arg: obj [UNKN ] Undocumented argument [GeneWiseScoreFlat *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *] * */ # line 153 "genewisemodel.dy" GeneWiseScoreFlat * free_GeneWiseScoreFlat(GeneWiseScoreFlat * obj) { if( obj == NULL ) { warn("Attempting to free a NULL GeneWiseScoreFlat object"); return NULL; } if( obj->seg != NULL ) ckfree(obj->seg); ckfree(obj); return NULL; } /* Function: map_phase0_codons_AlnBlock_GeneWise(alb,gws,cseq) * * Descrip: This function does something very * sinister. * * It maps the phase 0 introns which * have three base pairs added on the * end. * * It actually changes the AlnBlock structure * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: gws [UNKN ] Undocumented argument [GeneWiseScore *] * Arg: cseq [UNKN ] Undocumented argument [ComplexSequence *] * */ # line 178 "genewisemodel.dy" void map_phase0_codons_AlnBlock_GeneWise(AlnBlock * alb,GeneWiseScore * gws,ComplexSequence * cseq) { AlnColumn * alc; AlnColumn * new; for(alc=alb->start;alc != NULL;alc=alc->next) { /* don't map random columns */ if( is_random_AlnColumn_genewise(alc) == TRUE ) continue; if( strcmp(alc->alu[1]->text_label,"3SS_PHASE_0") == 0 ) { new = new_pairwise_AlnColumn(); new->alu[0]->start = alc->alu[0]->start; new->alu[0]->end = alc->alu[0]->end; /* set old alc end to == start */ alc->alu[0]->end = new->alu[0]->start; /* link label in as the same */ new->alu[0]->text_label = alc->alu[0]->text_label; new->alu[1]->end = alc->alu[1]->end; /* new starts at -3 on the codon, which is where old ends */ new->alu[1]->start = alc->alu[1]->end = alc->alu[1]->end -3; new->alu[1]->text_label = "CODON"; new->alu[0]->score[0] = new->alu[1]->score[0] = gws->seg[new->alu[0]->end]->transition[GW_MATCH2MATCH] + gws->seg[new->alu[0]->end]->match[CSEQ_GENOMIC_CODON(cseq,new->alu[1]->end)]; alc->alu[0]->score[0] -= new->alu[0]->score[0]; alc->alu[1]->score[0] -= new->alu[0]->score[0]; /*** add new into the AlnBlock ***/ new->next = alc->next; alc->next = new; } } } /* Function: flatten_balance_scores_GeneWise(gw) * * Descrip: This function is make all the balance scores 0 (hence prob-ratio to 1). * * Used when you are using naive models * * * Arg: gw [UNKN ] genewise model to flatten [GeneWise *] * */ # line 231 "genewisemodel.dy" void flatten_balance_scores_GeneWise(GeneWise * gw) { int i; for(i=0;ilen;i++) { gw->seg[i]->transition[GW_MATCH_BALANCE_5SS] = 1; gw->seg[i]->transition[GW_INSERT_BALANCE_5SS] = 1; gw->seg[i]->transition[GW_MATCH_BALANCE_3SS] = 1; gw->seg[i]->transition[GW_INSERT_BALANCE_3SS] = 1; } } /* Function: GeneWise_from_ThreeStateModel_cdna(tsm,cp,cm,allN) * * Descrip: This function makes a * GeneWise model for the estwise * type algorithms * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: cp [UNKN ] Undocumented argument [cDNAParser *] * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * Arg: allN [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [GeneWise *] * */ # line 249 "genewisemodel.dy" GeneWise * GeneWise_from_ThreeStateModel_cdna(ThreeStateModel * tsm,cDNAParser * cp,CodonMapper * cm,Probability allN) { register int i; GeneWise * out; Probability factor; assert(tsm); assert(cp); assert(cm); if( (out = GeneWise_alloc_len(tsm->len)) == NULL ) return NULL; factor = (1.0 - removed_probability_from_cds_cdna(cp)); for(i=0;ilen;i++) add_GeneWise(out,GeneWiseSegment_from_ThreeStateUnit(tsm->unit[i],factor,cm,NULL,allN)); return out; } /* Function: GeneWise_from_ThreeStateModel_setfactor(tsm,factor,cm,allN) * * Descrip: This function makes a * GeneWise model for the estwise * type algorithms * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: factor [UNKN ] Undocumented argument [Probability] * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * Arg: allN [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [GeneWise *] * */ # line 277 "genewisemodel.dy" GeneWise * GeneWise_from_ThreeStateModel_setfactor(ThreeStateModel * tsm,Probability factor,CodonMapper * cm,Probability allN) { register int i; GeneWise * out; assert(tsm != NULL); assert(cm != NULL); if( (out = GeneWise_alloc_len(tsm->len)) == NULL ) return NULL; for(i=0;ilen;i++) add_GeneWise(out,GeneWiseSegment_from_ThreeStateUnit(tsm->unit[i],factor,cm,NULL,allN)); return out; } /* Function: GeneWise_from_ThreeStateModel(tsm,gp,cm,allN,gwcm) * * Descrip: This makes a genewise model from a * threestatemodel for the genewise type * algorithms. * * Notice you have to provide the gene parameters * being used * * Stop is now not used * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: gp [UNKN ] Undocumented argument [GeneParser21 *] * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: gwcm [UNKN ] Undocumented argument [GeneWiseCodonModel *] * * Return [UNKN ] Undocumented return value [GeneWise *] * */ # line 306 "genewisemodel.dy" GeneWise * GeneWise_from_ThreeStateModel(ThreeStateModel * tsm,GeneParser21 * gp,CodonMapper * cm,Probability allN,GeneWiseCodonModel * gwcm) { register int i; GeneWise * out; Probability factor; assert(tsm); /* assert(gp); */ assert(cm); /* assert(gwcm); */ /* can cope with null gwcm's */ if( (out = GeneWise_alloc_len(tsm->len)) == NULL ) return NULL; if( tsm->name != NULL ) out->name = stringalloc(tsm->name); if( gp == NULL ) { factor = 1.0; } else { factor = (1.0 - removed_probability_from_cds(gp)); } for(i=0;ilen;i++) { add_GeneWise(out,GeneWiseSegment_from_ThreeStateUnit(tsm->unit[i],factor,cm,gwcm,allN)); } return out; } /* Function: GeneWise_fold_in_synchronised_RandomModel(gw,rm,cm,*ct,stop_codon_background) * * Descrip: This function places 'log-odd' scores of the * genewise model assumming that the random model * is a protein model with the codon mapper system * added in, *and* that the path of the random model * is synchronous with the query model. * * It fudges stop codons with the stop score given * as a probability. * * In other words, this should give bits scores as * if it was a protein, even though it is DNA * * * Arg: gw [UNKN ] Undocumented argument [GeneWise *] * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * Arg: *ct [UNKN ] Undocumented argument [CodonTable] * Arg: stop_codon_background [UNKN ] Undocumented argument [Probability] * */ # line 349 "genewisemodel.dy" void GeneWise_fold_in_synchronised_RandomModel(GeneWise * gw,RandomModel * rm,CodonMapper * cm,CodonTable *ct,Probability stop_codon_background) { int i; int j; double p; if( gw == NULL || rm == NULL || cm == NULL || ct == NULL ) { fatal("Null objects passed to GeneWise_fold_in_synchronised_RandomModel. Ugh!"); } for(i=0;i<125;i++) { p = map_codon_CodonMapper(i,rm->aminoacid,cm); if( is_stop_codon(i,ct) == FALSE && p < 0.0000001 ) { warn("Got a close to zero probability for %d\n",i); p = 0.0000001; } for(j=0;jlen;j++) { if( is_stop_codon(i,ct) == TRUE ){ gw->seg[j]->match[i] /= stop_codon_background; gw->seg[j]->insert[i] /= stop_codon_background; } else { gw->seg[j]->match[i] = gw->seg[j]->match[i] / p; gw->seg[j]->insert[i] = gw->seg[j]->insert[i] / p; } } } return; } /* Function: check_flat_insert(gw,should_force,should_warn,ct) * * Descrip: This function checks that the insert model is bang on * zero, forcing it to zero * * Potentially it warns for non zeros as well * * * Arg: gw [UNKN ] Undocumented argument [GeneWise *] * Arg: should_force [UNKN ] Undocumented argument [boolean] * Arg: should_warn [UNKN ] Undocumented argument [boolean] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 390 "genewisemodel.dy" boolean check_flat_insert(GeneWise * gw,boolean should_force,boolean should_warn,CodonTable * ct) { boolean ret = TRUE; int i,j; for(i=0;ilen;i++) { for(j=0;j<125;j++) { if ( is_stop_codon(j,ct) ) { continue; } if( gw->seg[i]->insert[j] > 1.02 || gw->seg[i]->insert[j] < 0.99 ) { ret = FALSE; if( should_warn ) { warn("In checking that we have a flat zero over the insert states, at %d, codon %d got %.2f",i,j,gw->seg[i]->insert[j]); } if( should_force ) { gw->seg[i]->insert[j] = 1.0; } } } } return ret; } /* Function: GeneWise_fold_in_RandomModelDNA(gw,rmd) * * Descrip: This function folds in a simple random model * (single base position) into a genewise model * * * Arg: gw [UNKN ] Undocumented argument [GeneWise *] * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * */ # line 419 "genewisemodel.dy" void GeneWise_fold_in_RandomModelDNA(GeneWise * gw,RandomModelDNA * rmd) { register int i; register int j; Probability p; for(i=0;i<125;i++) { p = probability_of_this_codon(i,rmd); for(j=0;jlen;j++) { gw->seg[j]->match[i] = gw->seg[j]->match[i] / p; gw->seg[j]->insert[i] = gw->seg[j]->insert[i] / p; } } return; } /* Function: Protein_from_GeneWise_AlnColumn(dna,is_random_AlnColumn,col,position_in_aln,last_column,ct) * * Descrip: Produces a protein object from a genewise/estwise * style label set, setting the last retrieved column * * * Arg: dna [UNKN ] Undocumented argument [Sequence *] * Arg: is_random_AlnColumn [UNKN ] Undocumented argument [NullString] * Arg: col [UNKN ] Undocumented argument [AlnColumn *] * Arg: position_in_aln [UNKN ] Undocumented argument [int] * Arg: last_column [UNKN ] Undocumented argument [AlnColumn **] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [Protein *] * */ # line 444 "genewisemodel.dy" Protein * Protein_from_GeneWise_AlnColumn(Sequence * dna,AlnColumn * col,int position_in_aln,AlnColumn ** last_column,CodonTable * ct,boolean (*is_random_AlnColumn)(const AlnColumn *)) { Sequence * out; char buffer[MAX_PROTEIN_GENEWISE]; /* max protein length? */ char tempseq[4]; int i =0; tempseq[3] = '\0'; for(;col != NULL && (*is_random_AlnColumn)(col) == TRUE;col = col->next) ; if( col == NULL ) return NULL; sprintf(buffer,"%s.pep",dna->name); out = empty_Sequence_from_dynamic_memory(stringalloc(buffer)); for(;col != NULL && (*is_random_AlnColumn)(col) == FALSE;col = col->next) { if( i+1 >= MAX_PROTEIN_GENEWISE ) { buffer[i] = '\0'; add_string_to_Sequence(out,buffer); i = 0; } if( strstr(col->alu[position_in_aln]->text_label,"CODON") != NULL ) { buffer[i++] = aminoacid_from_seq(ct,dna->seq+col->alu[position_in_aln]->start+1); } else if ( strstr(col->alu[position_in_aln]->text_label,"5SS_PHASE_1") != NULL ) { tempseq[0] = dna->seq[col->alu[position_in_aln]->start+1]; for(col=col->next;col != NULL && strstr(col->alu[position_in_aln]->text_label,"3SS") == NULL;col=col->next) ; if( col == NULL ) { warn("In middle of intron - got no 3'SS in making peptide translation"); return NULL; } tempseq[1] = dna->seq[col->alu[position_in_aln]->start+4]; tempseq[2] = dna->seq[col->alu[position_in_aln]->start+5]; /*fprintf(stderr,"In phase 1 intron, calling %c%c%c as split codon and %c%c%c as last codon\n",tempseq[0],tempseq[1],tempseq[2], dna->seq[col->alu[position_in_aln]->start+6], dna->seq[col->alu[position_in_aln]->start+7], dna->seq[col->alu[position_in_aln]->start+8] ); */ buffer[i++] = aminoacid_from_seq(ct,tempseq); /* buffer[i++] = aminoacid_from_seq(ct,dna->seq+col->alu[position_in_aln]->start+6);*/ printf("Making a %c in phase 1 intron\n",buffer[i-1]); } else if ( strstr(col->alu[position_in_aln]->text_label,"5SS_PHASE_2") != NULL ) { tempseq[0] = dna->seq[col->alu[position_in_aln]->start+1]; tempseq[1] = dna->seq[col->alu[position_in_aln]->start+2]; for(col=col->next;col != NULL && strstr(col->alu[position_in_aln]->text_label,"3SS") == NULL;col=col->next) ; if( col == NULL ) { warn("In middle of intron - got no 3'SS in making peptide translation"); return NULL; } tempseq[2] = dna->seq[col->alu[position_in_aln]->start+4]; buffer[i++] = aminoacid_from_seq(ct,tempseq); /*buffer[i++] = aminoacid_from_seq(ct,dna->seq+col->alu[position_in_aln]->start+5);*/ printf("Making a %c in phase 2 intron\n",buffer[i-1]); } else if ( strstr(col->alu[position_in_aln]->text_label,"5SS_PHASE_0") != NULL ) { /* codon already delt with! */ for(col=col->next;col != NULL && strstr(col->alu[position_in_aln]->text_label,"3SS") == NULL;col=col->next) ; if( col == NULL ) { warn("In middle of intron - got no 3'SS in making peptide translation"); return NULL; } /* buffer already sorted out. No need to provide compute */ continue; buffer[i++] = aminoacid_from_seq(ct,dna->seq+col->alu[position_in_aln]->start+3); printf("Making a %c in phase 0 intron\n",buffer[i-1]); col = col->next; } else if ( strstr(col->alu[position_in_aln]->text_label,"SEQUENCE_DELETION") != NULL ) { buffer[i++] = 'X'; } else if ( strstr(col->alu[position_in_aln]->text_label,"SEQUENCE_INSERTION") != NULL ) { buffer[i++] = 'X'; } else if ( strstr(col->alu[position_in_aln]->text_label,"INSERT") != NULL ) { continue; } else { warn("In processing alignment to peptide, got label %s which cannot handle. Assumming X in protein translation",col->alu[position_in_aln]->text_label); buffer[i++] = 'X'; } } if( last_column != NULL ) *last_column = col; buffer[i] = '\0'; add_string_to_Sequence(out,buffer); out->type = SEQUENCE_PROTEIN; /* force to protein */ return Protein_from_Sequence(out); } /* Function: probability_of_this_codon(codon,rmd) * * Descrip: Helper function for getting probability of * codon for a random model * * * Arg: codon [UNKN ] Undocumented argument [int] * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [Probability] * */ # line 539 "genewisemodel.dy" Probability probability_of_this_codon(int codon,RandomModelDNA * rmd) { base one; base two; base three; all_bases_from_codon(codon,&one,&two,&three); return rmd->base[one] * rmd->base[two] * rmd->base[three]; } /* Function: show_GeneWise(gw,ofp) * * Descrip: debugging function * * * Arg: gw [UNKN ] Undocumented argument [GeneWise *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 554 "genewisemodel.dy" void show_GeneWise(GeneWise * gw,FILE * ofp) { register int i; fprintf(stderr,"Got here at least [%d]\n",gw->len); for(i=0;ilen;i++) show_GeneWiseSegment(gw->seg[i],ofp); } /* Function: show_GeneWiseSegment(seg,ofp) * * Descrip: debugging * * * Arg: seg [UNKN ] Undocumented argument [GeneWiseSegment *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 570 "genewisemodel.dy" void show_GeneWiseSegment(GeneWiseSegment * seg,FILE * ofp) { fprintf(ofp,"match=\" "); show_Probability_array(seg->match,125,ofp); fprintf(ofp,"\n"); show_Probability_array(seg->insert,125,ofp); fprintf(ofp,"\n"); } /* Function: GeneWiseSegment_from_ThreeStateUnit(tsu,factor,cm,gwcm,allN) * * Descrip: Function which actually does the mapping from * threestate model unit to genewise * * * Arg: tsu [UNKN ] Undocumented argument [ThreeStateUnit *] * Arg: factor [UNKN ] Undocumented argument [Probability] * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * Arg: gwcm [UNKN ] Undocumented argument [GeneWiseCodonModel *] * Arg: allN [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [GeneWiseSegment *] * */ # line 585 "genewisemodel.dy" GeneWiseSegment * GeneWiseSegment_from_ThreeStateUnit(ThreeStateUnit * tsu,Probability factor,CodonMapper * cm,GeneWiseCodonModel * gwcm,Probability allN) { register int i; GeneWiseSegment * out; double total; int codon; out = GeneWiseSegment_alloc(); if( out == NULL ) return NULL; (void)set_Probability_array(out->match , 0.0, GW_EMISSION_LEN); (void)set_Probability_array(out->insert , 0.0, GW_EMISSION_LEN); (void)set_Probability_array(out->transition, 0.0, GW_TRANSITION_LEN); true_map_codon_array_CodonMapper(out->match,tsu->match_emission,cm); true_map_codon_array_CodonMapper(out->insert,tsu->insert_emission,cm); codon = codon_from_seq("NNN"); out->match[codon] = allN; out->insert[codon] = allN; out->transition[GW_MATCH2MATCH] = tsu->transition[TSM_MATCH2MATCH] * factor; out->transition[GW_MATCH2INSERT] = tsu->transition[TSM_MATCH2INSERT] * factor; out->transition[GW_MATCH2DELETE] = tsu->transition[TSM_MATCH2DELETE] * factor; out->transition[GW_MATCH2END] = tsu->transition[TSM_MATCH2END] * factor; out->transition[GW_INSERT2MATCH] = tsu->transition[TSM_INSERT2MATCH] * factor; out->transition[GW_INSERT2INSERT] = tsu->transition[TSM_INSERT2INSERT] * factor; out->transition[GW_INSERT2DELETE] = tsu->transition[TSM_INSERT2DELETE] * factor; out->transition[GW_INSERT2END] = tsu->transition[TSM_INSERT2END] * factor; out->transition[GW_DELETE2MATCH] = tsu->transition[TSM_DELETE2MATCH]; out->transition[GW_DELETE2INSERT] = tsu->transition[TSM_DELETE2INSERT]; out->transition[GW_DELETE2DELETE] = tsu->transition[TSM_DELETE2DELETE]; out->transition[GW_DELETE2END] = tsu->transition[TSM_DELETE2END]; out->transition[GW_START2MATCH] = tsu->transition[TSM_START2MATCH]; out->transition[GW_START2INSERT] = tsu->transition[TSM_START2INSERT]; out->transition[GW_START2DELETE] = tsu->transition[TSM_START2DELETE]; /** we need 1/(sum_over_codons (match(codon)) * no(codon in 5'SS)/no(codon in cds) ) **/ if( gwcm != NULL ) { total = 0.0; for(i=0;i<64;i++) { codon = codon_from_base4_codon(i); total += out->match[codon] * gwcm->in_donor[i]/gwcm->in_cds[i]; } out->transition[GW_MATCH_BALANCE_5SS] = 1.0 / total; total = 0.0; for(i=0;i<64;i++) { codon = codon_from_base4_codon(i); total += out->insert[codon] * gwcm->in_donor[i]/gwcm->in_cds[i]; } out->transition[GW_INSERT_BALANCE_5SS] = 1.0 / total; total = 0.0; for(i=0;i<64;i++) { codon = codon_from_base4_codon(i); total += out->match[codon] * gwcm->in_acceptor[i]/gwcm->in_cds[i]; } out->transition[GW_MATCH_BALANCE_3SS] = 1.0 / total; total = 0.0; for(i=0;i<64;i++) { codon = codon_from_base4_codon(i); total += out->insert[codon] * gwcm->in_acceptor[i]/gwcm->in_cds[i]; } out->transition[GW_INSERT_BALANCE_3SS] = 1.0 / total; } else { out->transition[GW_MATCH_BALANCE_5SS] = 1.0; out->transition[GW_MATCH_BALANCE_3SS] = 1.0; out->transition[GW_INSERT_BALANCE_5SS] = 1.0; out->transition[GW_INSERT_BALANCE_3SS] = 1.0; } return out; } /* Function: Probability_of_codon(codon,ct,aminoacid_26_array,stop) * * Descrip: Helper function * * * Arg: codon [UNKN ] Undocumented argument [int] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: aminoacid_26_array [UNKN ] Undocumented argument [Probability *] * Arg: stop [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [Probability] * */ # line 675 "genewisemodel.dy" Probability Probability_of_codon(int codon,CodonTable * ct,Probability * aminoacid_26_array,Probability stop) { register int i,j,k; base base1,base2,base3; Probability ret = 0.0; if( has_random_bases(codon) == FALSE) { if( is_stop_codon(codon,ct) == TRUE ) { return stop; } else { fprintf(stderr,"Setting a number to %f\n",aminoacid_26_array[aminoacid_no_from_codon(ct,codon)]); return aminoacid_26_array[aminoacid_no_from_codon(ct,codon)]; } } all_bases_from_codon(codon,&base1,&base2,&base3); /*** the first base is N ***/ if( base1 == BASE_N && base2 != BASE_N && base3 != BASE_N) { for(i=0;i<4;i++ ) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(i*25 + base2*5 + base3))]; return ret; } if( base1 == BASE_N && base2 == BASE_N && base3 != BASE_N) { for(i=0;i<4;i++) for(j=0;j<4;j++) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(i*25 + j*5 + base3))]; return ret; } if( base1 == BASE_N && base2 != BASE_N && base3 == BASE_N) { for(i=0;i<4;i++) for(k=0;k<4;k++) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(i*25 + base2*5 + k))]; return ret; } if( base1 == BASE_N && base2 == BASE_N && base3 == BASE_N) { for(i=0;i<4;i++) for(j=0;j<4;j++) for(k=0;k<4;k++) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(i*25 + j*5 + k))]; return ret; } /*** the second base is N ***/ if( base1 != BASE_N && base2 == BASE_N && base3 != BASE_N) { for(j=0;j<4;j++) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(base1*25 + j*5 + base3))]; return ret; } if( base1 != BASE_N && base2 == BASE_N && base3 == BASE_N) { for(j=0;j<4;j++) for(k=0;k<4;k++) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(base1*25 + j*5 + k))]; return ret; } /*** the third base is N ***/ if( base1 != BASE_N && base2 != BASE_N && base3 == BASE_N) { for(k=0;k<4;k++) ret += aminoacid_26_array[aminoacid_no_from_codon(ct,(base1*25 + base2*5 + k))]; return ret; } /*** should never reach here ***/ warn("Got to the end of Probability_of_codon without a BASE_N combination being triggered. This looks like a major problem. Codon inputted was %d",codon); return 0.0; } /* Function: GeneWiseScore_from_GeneWise(gw) * * Descrip: Makes a Score (log based) object from * a probability based object * * * Arg: gw [UNKN ] Undocumented argument [GeneWise *] * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ # line 763 "genewisemodel.dy" GeneWiseScore * GeneWiseScore_from_GeneWise(GeneWise * gw) { GeneWiseScore * out; register int i; out = GeneWiseScore_alloc_len(gw->len); if(gw->name != NULL ) out->name = stringalloc(gw->name); add_GeneWiseScore(out,GeneWiseScoreSegment_from_GeneWiseSegment(NULL,gw->seg[0])); for(i=1;ilen;i++) add_GeneWiseScore(out,GeneWiseScoreSegment_from_GeneWiseSegment(gw->seg[i-1],gw->seg[i])); return out; } /* Function: GeneWiseScoreSegment_from_GeneWiseSegment(prev,seg) * * Descrip: helper function for prob to score mapping * * * Arg: prev [UNKN ] Undocumented argument [GeneWiseSegment *] * Arg: seg [UNKN ] Undocumented argument [GeneWiseSegment *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreSegment *] * */ # line 786 "genewisemodel.dy" GeneWiseScoreSegment * GeneWiseScoreSegment_from_GeneWiseSegment(GeneWiseSegment * prev,GeneWiseSegment * seg) { GeneWiseScoreSegment * out; out = GeneWiseScoreSegment_alloc(); Probability2Score_move(seg->match,out->match,GW_EMISSION_LEN); Probability2Score_move(seg->insert,out->insert,GW_EMISSION_LEN); if( prev != NULL ) { out->transition[GW_MATCH2MATCH] = Probability2Score(prev->transition[GW_MATCH2MATCH]); out->transition[GW_INSERT2MATCH] = Probability2Score(prev->transition[GW_INSERT2MATCH]); out->transition[GW_DELETE2MATCH] = Probability2Score(prev->transition[GW_DELETE2MATCH]); out->transition[GW_MATCH2DELETE] = Probability2Score(prev->transition[GW_MATCH2DELETE]); out->transition[GW_INSERT2DELETE] = Probability2Score(prev->transition[GW_INSERT2DELETE]); out->transition[GW_DELETE2DELETE] = Probability2Score(prev->transition[GW_DELETE2DELETE]); } else { out->transition[GW_MATCH2MATCH] = NEGI; out->transition[GW_INSERT2MATCH] = NEGI; out->transition[GW_DELETE2MATCH] = NEGI; out->transition[GW_MATCH2DELETE] = NEGI; out->transition[GW_INSERT2DELETE] = NEGI; out->transition[GW_DELETE2DELETE] = NEGI; } out->transition[GW_MATCH2INSERT] = Probability2Score(seg->transition[GW_MATCH2INSERT]); out->transition[GW_INSERT2INSERT] = Probability2Score(seg->transition[GW_INSERT2INSERT]); out->transition[GW_DELETE2INSERT] = Probability2Score(seg->transition[GW_DELETE2INSERT]); out->transition[GW_START2MATCH] = Probability2Score(seg->transition[GW_START2MATCH]); out->transition[GW_START2INSERT] = Probability2Score(seg->transition[GW_START2INSERT]); out->transition[GW_START2DELETE] = Probability2Score(seg->transition[GW_START2DELETE]); out->transition[GW_MATCH2END] = Probability2Score(seg->transition[GW_MATCH2END]); out->transition[GW_INSERT2END] = Probability2Score(seg->transition[GW_INSERT2END]); out->transition[GW_DELETE2END] = Probability2Score(seg->transition[GW_DELETE2END]); out->transition[GW_MATCH_BALANCE_5SS] = Probability2Score(seg->transition[GW_MATCH_BALANCE_5SS]); out->transition[GW_INSERT_BALANCE_5SS] = Probability2Score(seg->transition[GW_INSERT_BALANCE_5SS]); out->transition[GW_MATCH_BALANCE_3SS] = Probability2Score(seg->transition[GW_MATCH_BALANCE_3SS]); out->transition[GW_INSERT_BALANCE_3SS] = Probability2Score(seg->transition[GW_INSERT_BALANCE_3SS]); return out; } # line 867 "genewisemodel.c" /* Function: hard_link_GeneWiseSegment(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseSegment *] * * Return [UNKN ] Undocumented return value [GeneWiseSegment *] * */ GeneWiseSegment * hard_link_GeneWiseSegment(GeneWiseSegment * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneWiseSegment object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneWiseSegment_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseSegment *] * */ GeneWiseSegment * GeneWiseSegment_alloc(void) { GeneWiseSegment * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWiseSegment *) ckalloc (sizeof(GeneWiseSegment))) == NULL) { warn("GeneWiseSegment_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* match[GW_EMISSION_LEN] is an array: no default possible */ /* insert[GW_EMISSION_LEN] is an array: no default possible */ /* transition[GW_TRANSITION_LEN] is an array: no default possible */ return out; } /* Function: free_GeneWiseSegment(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseSegment *] * * Return [UNKN ] Undocumented return value [GeneWiseSegment *] * */ GeneWiseSegment * free_GeneWiseSegment(GeneWiseSegment * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneWiseSegment obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_GeneWise(list,i,j) * * Descrip: swap function: an internal for qsort_GeneWise * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [GeneWiseSegment **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_GeneWise(GeneWiseSegment ** list,int i,int j) { GeneWiseSegment * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_GeneWise(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_GeneWise which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [GeneWiseSegment **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_GeneWise(GeneWiseSegment ** list,int left,int right,int (*comp)(GeneWiseSegment * ,GeneWiseSegment * )) { int i,last; if( left >= right ) return; swap_GeneWise(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_GeneWise (list,++last,i); } swap_GeneWise (list,left,last); qsort_GeneWise(list,left,last-1,comp); qsort_GeneWise(list,last+1,right,comp); } /* Function: sort_GeneWise(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_GeneWise * * * Arg: obj [UNKN ] Object containing list [GeneWise *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_GeneWise(GeneWise * obj,int (*comp)(GeneWiseSegment *, GeneWiseSegment *)) { qsort_GeneWise(obj->seg,0,obj->len-1,comp); return; } /* Function: expand_GeneWise(obj,len) * * Descrip: Really an internal function for add_GeneWise * * * Arg: obj [UNKN ] Object which contains the list [GeneWise *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_GeneWise(GeneWise * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_GeneWise called with no need"); return TRUE; } if( (obj->seg = (GeneWiseSegment ** ) ckrealloc (obj->seg,sizeof(GeneWiseSegment *)*len)) == NULL) { warn("ckrealloc failed for expand_GeneWise, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_GeneWise(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GeneWise *] * Arg: add [OWNER] Object to add to the list [GeneWiseSegment *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_GeneWise(GeneWise * obj,GeneWiseSegment * add) { if( obj->len >= obj->maxlen) { if( expand_GeneWise(obj,obj->len + GeneWiseLISTLENGTH) == FALSE) return FALSE; } obj->seg[obj->len++]=add; return TRUE; } /* Function: flush_GeneWise(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GeneWise *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GeneWise(GeneWise * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->seg[i] != NULL) { free_GeneWiseSegment(obj->seg[i]); obj->seg[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: GeneWise_alloc_std(void) * * Descrip: Equivalent to GeneWise_alloc_len(GeneWiseLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GeneWise *] * */ GeneWise * GeneWise_alloc_std(void) { return GeneWise_alloc_len(GeneWiseLISTLENGTH); } /* Function: GeneWise_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GeneWise *] * */ GeneWise * GeneWise_alloc_len(int len) { GeneWise * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = GeneWise_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->seg = (GeneWiseSegment ** ) ckcalloc (len,sizeof(GeneWiseSegment *))) == NULL) { warn("Warning, ckcalloc failed in GeneWise_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_GeneWise(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWise *] * * Return [UNKN ] Undocumented return value [GeneWise *] * */ GeneWise * hard_link_GeneWise(GeneWise * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneWise object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneWise_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWise *] * */ GeneWise * GeneWise_alloc(void) { GeneWise * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWise *) ckalloc (sizeof(GeneWise))) == NULL) { warn("GeneWise_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->seg = NULL; out->len = out->maxlen = 0; out->name = NULL; return out; } /* Function: free_GeneWise(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWise *] * * Return [UNKN ] Undocumented return value [GeneWise *] * */ GeneWise * free_GeneWise(GeneWise * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneWise obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->seg != NULL) { for(i=0;ilen;i++) { if( obj->seg[i] != NULL) free_GeneWiseSegment(obj->seg[i]); } ckfree(obj->seg); } if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: hard_link_GeneWiseScoreSegment(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseScoreSegment *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreSegment *] * */ GeneWiseScoreSegment * hard_link_GeneWiseScoreSegment(GeneWiseScoreSegment * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneWiseScoreSegment object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneWiseScoreSegment_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseScoreSegment *] * */ GeneWiseScoreSegment * GeneWiseScoreSegment_alloc(void) { GeneWiseScoreSegment * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWiseScoreSegment *) ckalloc (sizeof(GeneWiseScoreSegment))) == NULL) { warn("GeneWiseScoreSegment_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* match[GW_EMISSION_LEN] is an array: no default possible */ /* insert[GW_EMISSION_LEN] is an array: no default possible */ /* transition[GW_TRANSITION_LEN] is an array: no default possible */ return out; } /* Function: free_GeneWiseScoreSegment(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseScoreSegment *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreSegment *] * */ GeneWiseScoreSegment * free_GeneWiseScoreSegment(GeneWiseScoreSegment * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneWiseScoreSegment obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_GeneWiseScore(list,i,j) * * Descrip: swap function: an internal for qsort_GeneWiseScore * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [GeneWiseScoreSegment **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_GeneWiseScore(GeneWiseScoreSegment ** list,int i,int j) { GeneWiseScoreSegment * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_GeneWiseScore(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_GeneWiseScore which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [GeneWiseScoreSegment **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_GeneWiseScore(GeneWiseScoreSegment ** list,int left,int right,int (*comp)(GeneWiseScoreSegment * ,GeneWiseScoreSegment * )) { int i,last; if( left >= right ) return; swap_GeneWiseScore(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_GeneWiseScore (list,++last,i); } swap_GeneWiseScore (list,left,last); qsort_GeneWiseScore(list,left,last-1,comp); qsort_GeneWiseScore(list,last+1,right,comp); } /* Function: sort_GeneWiseScore(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_GeneWiseScore * * * Arg: obj [UNKN ] Object containing list [GeneWiseScore *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_GeneWiseScore(GeneWiseScore * obj,int (*comp)(GeneWiseScoreSegment *, GeneWiseScoreSegment *)) { qsort_GeneWiseScore(obj->seg,0,obj->len-1,comp); return; } /* Function: expand_GeneWiseScore(obj,len) * * Descrip: Really an internal function for add_GeneWiseScore * * * Arg: obj [UNKN ] Object which contains the list [GeneWiseScore *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_GeneWiseScore(GeneWiseScore * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_GeneWiseScore called with no need"); return TRUE; } if( (obj->seg = (GeneWiseScoreSegment ** ) ckrealloc (obj->seg,sizeof(GeneWiseScoreSegment *)*len)) == NULL) { warn("ckrealloc failed for expand_GeneWiseScore, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_GeneWiseScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GeneWiseScore *] * Arg: add [OWNER] Object to add to the list [GeneWiseScoreSegment *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_GeneWiseScore(GeneWiseScore * obj,GeneWiseScoreSegment * add) { if( obj->len >= obj->maxlen) { if( expand_GeneWiseScore(obj,obj->len + GeneWiseScoreLISTLENGTH) == FALSE) return FALSE; } obj->seg[obj->len++]=add; return TRUE; } /* Function: flush_GeneWiseScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GeneWiseScore *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GeneWiseScore(GeneWiseScore * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->seg[i] != NULL) { free_GeneWiseScoreSegment(obj->seg[i]); obj->seg[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: GeneWiseScore_alloc_std(void) * * Descrip: Equivalent to GeneWiseScore_alloc_len(GeneWiseScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ GeneWiseScore * GeneWiseScore_alloc_std(void) { return GeneWiseScore_alloc_len(GeneWiseScoreLISTLENGTH); } /* Function: GeneWiseScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ GeneWiseScore * GeneWiseScore_alloc_len(int len) { GeneWiseScore * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = GeneWiseScore_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->seg = (GeneWiseScoreSegment ** ) ckcalloc (len,sizeof(GeneWiseScoreSegment *))) == NULL) { warn("Warning, ckcalloc failed in GeneWiseScore_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_GeneWiseScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseScore *] * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ GeneWiseScore * hard_link_GeneWiseScore(GeneWiseScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneWiseScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneWiseScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ GeneWiseScore * GeneWiseScore_alloc(void) { GeneWiseScore * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWiseScore *) ckalloc (sizeof(GeneWiseScore))) == NULL) { warn("GeneWiseScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->seg = NULL; out->len = out->maxlen = 0; out->name = NULL; return out; } /* Function: free_GeneWiseScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseScore *] * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ GeneWiseScore * free_GeneWiseScore(GeneWiseScore * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneWiseScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->seg != NULL) { for(i=0;ilen;i++) { if( obj->seg[i] != NULL) free_GeneWiseScoreSegment(obj->seg[i]); } ckfree(obj->seg); } if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: hard_link_GeneWiseScoreFlat(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseScoreFlat *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *] * */ GeneWiseScoreFlat * hard_link_GeneWiseScoreFlat(GeneWiseScoreFlat * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneWiseScoreFlat object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneWiseScoreFlat_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *] * */ GeneWiseScoreFlat * GeneWiseScoreFlat_alloc(void) { GeneWiseScoreFlat * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWiseScoreFlat *) ckalloc (sizeof(GeneWiseScoreFlat))) == NULL) { warn("GeneWiseScoreFlat_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->seg = NULL; out->len = 0; return out; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/genewisemodel.h0000644000175000001440000006030410670453714017135 0ustar philippusers#ifndef DYNAMITEgenewisemodelHEADERFILE #define DYNAMITEgenewisemodelHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "geneparser21.h" #include "geneparameter.h" #include "threestatemodel.h" #include "codonmapper.h" #include "cdparser.h" #include "genefrequency.h" #include "geneutil.h" #define GeneWiseScoreLISTLENGTH 128 #define GeneWiseLISTLENGTH 128 #define MAX_PROTEIN_GENEWISE 4096 enum GeneWiseTransition { GW_MATCH2MATCH, GW_MATCH2INSERT, GW_MATCH2DELETE, GW_MATCH2END, GW_INSERT2MATCH, GW_INSERT2INSERT, GW_INSERT2DELETE, GW_INSERT2END, GW_DELETE2MATCH, GW_DELETE2INSERT, GW_DELETE2DELETE, GW_DELETE2END, GW_START2MATCH, GW_START2INSERT, GW_START2DELETE, GW_MATCH_BALANCE_5SS, GW_INSERT_BALANCE_5SS, GW_MATCH_BALANCE_3SS, GW_INSERT_BALANCE_3SS, GW_TRANSITION_LEN }; #define GW_EMISSION_LEN 126 /* Object GeneWiseSegment * * Descrip: This is a particular HMM node, with * match and insert emissions in the codon space * and the transitions * * intron/frameshifting transitions are stored * in a different datastructure, as they are * not position dependent * * */ struct Wise2_GeneWiseSegment { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability match[GW_EMISSION_LEN]; Probability insert[GW_EMISSION_LEN]; Probability transition[GW_TRANSITION_LEN]; } ; /* GeneWiseSegment defined */ #ifndef DYNAMITE_DEFINED_GeneWiseSegment typedef struct Wise2_GeneWiseSegment Wise2_GeneWiseSegment; #define GeneWiseSegment Wise2_GeneWiseSegment #define DYNAMITE_DEFINED_GeneWiseSegment #endif /* Object GeneWise * * Descrip: This is an expand HMM for codon * matching, suitable for genewise and * estwise type algorithms. It is simple * a list of nodes * * */ struct Wise2_GeneWise { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GeneWiseSegment ** seg; int len;/* len for above seg */ int maxlen; /* maxlen for above seg */ char * name; } ; /* GeneWise defined */ #ifndef DYNAMITE_DEFINED_GeneWise typedef struct Wise2_GeneWise Wise2_GeneWise; #define GeneWise Wise2_GeneWise #define DYNAMITE_DEFINED_GeneWise #endif /* Object GeneWiseScoreSegment * * Descrip: This is the log space equivalent * of GeneWiseSegment * * */ struct Wise2_GeneWiseScoreSegment { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score match[GW_EMISSION_LEN]; Score insert[GW_EMISSION_LEN]; Score transition[GW_TRANSITION_LEN]; } ; /* GeneWiseScoreSegment defined */ #ifndef DYNAMITE_DEFINED_GeneWiseScoreSegment typedef struct Wise2_GeneWiseScoreSegment Wise2_GeneWiseScoreSegment; #define GeneWiseScoreSegment Wise2_GeneWiseScoreSegment #define DYNAMITE_DEFINED_GeneWiseScoreSegment #endif /* Object GeneWiseScore * * Descrip: This is the log space equivalent * of the GeneWise * * */ struct Wise2_GeneWiseScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GeneWiseScoreSegment ** seg; int len;/* len for above seg */ int maxlen; /* maxlen for above seg */ char * name; } ; /* GeneWiseScore defined */ #ifndef DYNAMITE_DEFINED_GeneWiseScore typedef struct Wise2_GeneWiseScore Wise2_GeneWiseScore; #define GeneWiseScore Wise2_GeneWiseScore #define DYNAMITE_DEFINED_GeneWiseScore #endif /* Object GeneWiseScoreFlat * * Descrip: This is a specialised datastructure * which is equivalent to the GeneWiseScore * object, but layed out more efficiently * for memory lookup. The actual code is * usually 10% faster. If you have a really * large model however it might barf! * * */ struct Wise2_GeneWiseScoreFlat { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GeneWiseScoreSegment * seg; int len; } ; /* GeneWiseScoreFlat defined */ #ifndef DYNAMITE_DEFINED_GeneWiseScoreFlat typedef struct Wise2_GeneWiseScoreFlat Wise2_GeneWiseScoreFlat; #define GeneWiseScoreFlat Wise2_GeneWiseScoreFlat #define DYNAMITE_DEFINED_GeneWiseScoreFlat #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: pack_GeneWiseScore(gws) * * Descrip: Packing up the GeneWise model into a byte structure * * * Arg: gws [UNKN ] Undocumented argument [GeneWiseScore *] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_pack_GeneWiseScore(GeneWiseScore * gws); #define pack_GeneWiseScore Wise2_pack_GeneWiseScore /* Function: GeneWiseScoreFlat_from_GeneWiseScore(gws) * * Descrip: This produces a flattened GeneWiseSegment structure * for use in quick implementations (memory lookup * is much better due to everything being a single * piece of memory). * * * Arg: gws [UNKN ] Undocumented argument [GeneWiseScore *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *] * */ GeneWiseScoreFlat * Wise2_GeneWiseScoreFlat_from_GeneWiseScore(GeneWiseScore * gws); #define GeneWiseScoreFlat_from_GeneWiseScore Wise2_GeneWiseScoreFlat_from_GeneWiseScore /* Function: free_GeneWiseScoreFlat(obj) * * Descrip: Frees the GeneWiseScoreFlat datastructure * * overrides the usual deconstructor * * * Arg: obj [UNKN ] Undocumented argument [GeneWiseScoreFlat *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *] * */ GeneWiseScoreFlat * Wise2_free_GeneWiseScoreFlat(GeneWiseScoreFlat * obj); #define free_GeneWiseScoreFlat Wise2_free_GeneWiseScoreFlat /* Function: map_phase0_codons_AlnBlock_GeneWise(alb,gws,cseq) * * Descrip: This function does something very * sinister. * * It maps the phase 0 introns which * have three base pairs added on the * end. * * It actually changes the AlnBlock structure * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: gws [UNKN ] Undocumented argument [GeneWiseScore *] * Arg: cseq [UNKN ] Undocumented argument [ComplexSequence *] * */ void Wise2_map_phase0_codons_AlnBlock_GeneWise(AlnBlock * alb,GeneWiseScore * gws,ComplexSequence * cseq); #define map_phase0_codons_AlnBlock_GeneWise Wise2_map_phase0_codons_AlnBlock_GeneWise /* Function: flatten_balance_scores_GeneWise(gw) * * Descrip: This function is make all the balance scores 0 (hence prob-ratio to 1). * * Used when you are using naive models * * * Arg: gw [UNKN ] genewise model to flatten [GeneWise *] * */ void Wise2_flatten_balance_scores_GeneWise(GeneWise * gw); #define flatten_balance_scores_GeneWise Wise2_flatten_balance_scores_GeneWise /* Function: GeneWise_from_ThreeStateModel_cdna(tsm,cp,cm,allN) * * Descrip: This function makes a * GeneWise model for the estwise * type algorithms * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: cp [UNKN ] Undocumented argument [cDNAParser *] * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * Arg: allN [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [GeneWise *] * */ GeneWise * Wise2_GeneWise_from_ThreeStateModel_cdna(ThreeStateModel * tsm,cDNAParser * cp,CodonMapper * cm,Probability allN); #define GeneWise_from_ThreeStateModel_cdna Wise2_GeneWise_from_ThreeStateModel_cdna /* Function: GeneWise_from_ThreeStateModel_setfactor(tsm,factor,cm,allN) * * Descrip: This function makes a * GeneWise model for the estwise * type algorithms * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: factor [UNKN ] Undocumented argument [Probability] * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * Arg: allN [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [GeneWise *] * */ GeneWise * Wise2_GeneWise_from_ThreeStateModel_setfactor(ThreeStateModel * tsm,Probability factor,CodonMapper * cm,Probability allN); #define GeneWise_from_ThreeStateModel_setfactor Wise2_GeneWise_from_ThreeStateModel_setfactor /* Function: GeneWise_from_ThreeStateModel(tsm,gp,cm,allN,gwcm) * * Descrip: This makes a genewise model from a * threestatemodel for the genewise type * algorithms. * * Notice you have to provide the gene parameters * being used * * Stop is now not used * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: gp [UNKN ] Undocumented argument [GeneParser21 *] * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: gwcm [UNKN ] Undocumented argument [GeneWiseCodonModel *] * * Return [UNKN ] Undocumented return value [GeneWise *] * */ GeneWise * Wise2_GeneWise_from_ThreeStateModel(ThreeStateModel * tsm,GeneParser21 * gp,CodonMapper * cm,Probability allN,GeneWiseCodonModel * gwcm); #define GeneWise_from_ThreeStateModel Wise2_GeneWise_from_ThreeStateModel /* Function: GeneWise_fold_in_synchronised_RandomModel(gw,rm,cm,*ct,stop_codon_background) * * Descrip: This function places 'log-odd' scores of the * genewise model assumming that the random model * is a protein model with the codon mapper system * added in, *and* that the path of the random model * is synchronous with the query model. * * It fudges stop codons with the stop score given * as a probability. * * In other words, this should give bits scores as * if it was a protein, even though it is DNA * * * Arg: gw [UNKN ] Undocumented argument [GeneWise *] * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * Arg: *ct [UNKN ] Undocumented argument [CodonTable] * Arg: stop_codon_background [UNKN ] Undocumented argument [Probability] * */ void Wise2_GeneWise_fold_in_synchronised_RandomModel(GeneWise * gw,RandomModel * rm,CodonMapper * cm,CodonTable *ct,Probability stop_codon_background); #define GeneWise_fold_in_synchronised_RandomModel Wise2_GeneWise_fold_in_synchronised_RandomModel /* Function: check_flat_insert(gw,should_force,should_warn,ct) * * Descrip: This function checks that the insert model is bang on * zero, forcing it to zero * * Potentially it warns for non zeros as well * * * Arg: gw [UNKN ] Undocumented argument [GeneWise *] * Arg: should_force [UNKN ] Undocumented argument [boolean] * Arg: should_warn [UNKN ] Undocumented argument [boolean] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_check_flat_insert(GeneWise * gw,boolean should_force,boolean should_warn,CodonTable * ct); #define check_flat_insert Wise2_check_flat_insert /* Function: GeneWise_fold_in_RandomModelDNA(gw,rmd) * * Descrip: This function folds in a simple random model * (single base position) into a genewise model * * * Arg: gw [UNKN ] Undocumented argument [GeneWise *] * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * */ void Wise2_GeneWise_fold_in_RandomModelDNA(GeneWise * gw,RandomModelDNA * rmd); #define GeneWise_fold_in_RandomModelDNA Wise2_GeneWise_fold_in_RandomModelDNA /* Function: Protein_from_GeneWise_AlnColumn(dna,is_random_AlnColumn,col,position_in_aln,last_column,ct) * * Descrip: Produces a protein object from a genewise/estwise * style label set, setting the last retrieved column * * * Arg: dna [UNKN ] Undocumented argument [Sequence *] * Arg: is_random_AlnColumn [UNKN ] Undocumented argument [NullString] * Arg: col [UNKN ] Undocumented argument [AlnColumn *] * Arg: position_in_aln [UNKN ] Undocumented argument [int] * Arg: last_column [UNKN ] Undocumented argument [AlnColumn **] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Wise2_Protein_from_GeneWise_AlnColumn(Sequence * dna,AlnColumn * col,int position_in_aln,AlnColumn ** last_column,CodonTable * ct,boolean (*is_random_AlnColumn)(const AlnColumn *)); #define Protein_from_GeneWise_AlnColumn Wise2_Protein_from_GeneWise_AlnColumn /* Function: GeneWiseScore_from_GeneWise(gw) * * Descrip: Makes a Score (log based) object from * a probability based object * * * Arg: gw [UNKN ] Undocumented argument [GeneWise *] * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ GeneWiseScore * Wise2_GeneWiseScore_from_GeneWise(GeneWise * gw); #define GeneWiseScore_from_GeneWise Wise2_GeneWiseScore_from_GeneWise /* Function: hard_link_GeneWiseSegment(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseSegment *] * * Return [UNKN ] Undocumented return value [GeneWiseSegment *] * */ GeneWiseSegment * Wise2_hard_link_GeneWiseSegment(GeneWiseSegment * obj); #define hard_link_GeneWiseSegment Wise2_hard_link_GeneWiseSegment /* Function: GeneWiseSegment_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseSegment *] * */ GeneWiseSegment * Wise2_GeneWiseSegment_alloc(void); #define GeneWiseSegment_alloc Wise2_GeneWiseSegment_alloc /* Function: free_GeneWiseSegment(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseSegment *] * * Return [UNKN ] Undocumented return value [GeneWiseSegment *] * */ GeneWiseSegment * Wise2_free_GeneWiseSegment(GeneWiseSegment * obj); #define free_GeneWiseSegment Wise2_free_GeneWiseSegment /* Function: add_GeneWise(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GeneWise *] * Arg: add [OWNER] Object to add to the list [GeneWiseSegment *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_GeneWise(GeneWise * obj,GeneWiseSegment * add); #define add_GeneWise Wise2_add_GeneWise /* Function: flush_GeneWise(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GeneWise *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_GeneWise(GeneWise * obj); #define flush_GeneWise Wise2_flush_GeneWise /* Function: GeneWise_alloc_std(void) * * Descrip: Equivalent to GeneWise_alloc_len(GeneWiseLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GeneWise *] * */ GeneWise * Wise2_GeneWise_alloc_std(void); #define GeneWise_alloc_std Wise2_GeneWise_alloc_std /* Function: GeneWise_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GeneWise *] * */ GeneWise * Wise2_GeneWise_alloc_len(int len); #define GeneWise_alloc_len Wise2_GeneWise_alloc_len /* Function: hard_link_GeneWise(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWise *] * * Return [UNKN ] Undocumented return value [GeneWise *] * */ GeneWise * Wise2_hard_link_GeneWise(GeneWise * obj); #define hard_link_GeneWise Wise2_hard_link_GeneWise /* Function: GeneWise_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWise *] * */ GeneWise * Wise2_GeneWise_alloc(void); #define GeneWise_alloc Wise2_GeneWise_alloc /* Function: free_GeneWise(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWise *] * * Return [UNKN ] Undocumented return value [GeneWise *] * */ GeneWise * Wise2_free_GeneWise(GeneWise * obj); #define free_GeneWise Wise2_free_GeneWise /* Function: hard_link_GeneWiseScoreSegment(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseScoreSegment *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreSegment *] * */ GeneWiseScoreSegment * Wise2_hard_link_GeneWiseScoreSegment(GeneWiseScoreSegment * obj); #define hard_link_GeneWiseScoreSegment Wise2_hard_link_GeneWiseScoreSegment /* Function: GeneWiseScoreSegment_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseScoreSegment *] * */ GeneWiseScoreSegment * Wise2_GeneWiseScoreSegment_alloc(void); #define GeneWiseScoreSegment_alloc Wise2_GeneWiseScoreSegment_alloc /* Function: free_GeneWiseScoreSegment(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseScoreSegment *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreSegment *] * */ GeneWiseScoreSegment * Wise2_free_GeneWiseScoreSegment(GeneWiseScoreSegment * obj); #define free_GeneWiseScoreSegment Wise2_free_GeneWiseScoreSegment /* Function: add_GeneWiseScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GeneWiseScore *] * Arg: add [OWNER] Object to add to the list [GeneWiseScoreSegment *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_GeneWiseScore(GeneWiseScore * obj,GeneWiseScoreSegment * add); #define add_GeneWiseScore Wise2_add_GeneWiseScore /* Function: flush_GeneWiseScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GeneWiseScore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_GeneWiseScore(GeneWiseScore * obj); #define flush_GeneWiseScore Wise2_flush_GeneWiseScore /* Function: GeneWiseScore_alloc_std(void) * * Descrip: Equivalent to GeneWiseScore_alloc_len(GeneWiseScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ GeneWiseScore * Wise2_GeneWiseScore_alloc_std(void); #define GeneWiseScore_alloc_std Wise2_GeneWiseScore_alloc_std /* Function: GeneWiseScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ GeneWiseScore * Wise2_GeneWiseScore_alloc_len(int len); #define GeneWiseScore_alloc_len Wise2_GeneWiseScore_alloc_len /* Function: hard_link_GeneWiseScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseScore *] * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ GeneWiseScore * Wise2_hard_link_GeneWiseScore(GeneWiseScore * obj); #define hard_link_GeneWiseScore Wise2_hard_link_GeneWiseScore /* Function: GeneWiseScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ GeneWiseScore * Wise2_GeneWiseScore_alloc(void); #define GeneWiseScore_alloc Wise2_GeneWiseScore_alloc /* Function: free_GeneWiseScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseScore *] * * Return [UNKN ] Undocumented return value [GeneWiseScore *] * */ GeneWiseScore * Wise2_free_GeneWiseScore(GeneWiseScore * obj); #define free_GeneWiseScore Wise2_free_GeneWiseScore /* Function: hard_link_GeneWiseScoreFlat(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseScoreFlat *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *] * */ GeneWiseScoreFlat * Wise2_hard_link_GeneWiseScoreFlat(GeneWiseScoreFlat * obj); #define hard_link_GeneWiseScoreFlat Wise2_hard_link_GeneWiseScoreFlat /* Function: GeneWiseScoreFlat_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *] * */ GeneWiseScoreFlat * Wise2_GeneWiseScoreFlat_alloc(void); #define GeneWiseScoreFlat_alloc Wise2_GeneWiseScoreFlat_alloc /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ Probability Wise2_probability_of_this_codon(int codon,RandomModelDNA * rmd); #define probability_of_this_codon Wise2_probability_of_this_codon void Wise2_show_GeneWise(GeneWise * gw,FILE * ofp); #define show_GeneWise Wise2_show_GeneWise void Wise2_show_GeneWiseSegment(GeneWiseSegment * seg,FILE * ofp); #define show_GeneWiseSegment Wise2_show_GeneWiseSegment GeneWiseSegment * Wise2_GeneWiseSegment_from_ThreeStateUnit(ThreeStateUnit * tsu,Probability factor,CodonMapper * cm,GeneWiseCodonModel * gwcm,Probability allN); #define GeneWiseSegment_from_ThreeStateUnit Wise2_GeneWiseSegment_from_ThreeStateUnit Probability Wise2_Probability_of_codon(int codon,CodonTable * ct,Probability * aminoacid_26_array,Probability stop); #define Probability_of_codon Wise2_Probability_of_codon GeneWiseScoreSegment * Wise2_GeneWiseScoreSegment_from_GeneWiseSegment(GeneWiseSegment * prev,GeneWiseSegment * seg); #define GeneWiseScoreSegment_from_GeneWiseSegment Wise2_GeneWiseScoreSegment_from_GeneWiseSegment void Wise2_swap_GeneWise(GeneWiseSegment ** list,int i,int j) ; #define swap_GeneWise Wise2_swap_GeneWise void Wise2_qsort_GeneWise(GeneWiseSegment ** list,int left,int right,int (*comp)(GeneWiseSegment * ,GeneWiseSegment * )); #define qsort_GeneWise Wise2_qsort_GeneWise void Wise2_sort_GeneWise(GeneWise * obj,int (*comp)(GeneWiseSegment *, GeneWiseSegment *)); #define sort_GeneWise Wise2_sort_GeneWise boolean Wise2_expand_GeneWise(GeneWise * obj,int len); #define expand_GeneWise Wise2_expand_GeneWise void Wise2_swap_GeneWiseScore(GeneWiseScoreSegment ** list,int i,int j) ; #define swap_GeneWiseScore Wise2_swap_GeneWiseScore void Wise2_qsort_GeneWiseScore(GeneWiseScoreSegment ** list,int left,int right,int (*comp)(GeneWiseScoreSegment * ,GeneWiseScoreSegment * )); #define qsort_GeneWiseScore Wise2_qsort_GeneWiseScore void Wise2_sort_GeneWiseScore(GeneWiseScore * obj,int (*comp)(GeneWiseScoreSegment *, GeneWiseScoreSegment *)); #define sort_GeneWiseScore Wise2_sort_GeneWiseScore boolean Wise2_expand_GeneWiseScore(GeneWiseScore * obj,int len); #define expand_GeneWiseScore Wise2_expand_GeneWiseScore #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/amplimer_resolver.c0000644000175000001440000000756007651240360020031 0ustar philippusers #include "dnaalign.h" #include "dnamatcher.h" #include "version.h" char * program_name = "amplimer_resolver"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s target-fasta-file amplimer-fasta-file\n",program_name); show_help_DnaMatchPara(ofp); show_help_HitListOutputImpl(ofp); show_standard_options(ofp); } Sequence * swapped_Sequence(Sequence * reference,HitList * hl) { Sequence * out; int i; AlnColumn * alc; char buffer[512]; char * swapped; int coord; int swap; sprintf(buffer,"swapped_%s",reference->name); out = new_Sequence_from_strings(buffer,reference->seq); for(i=0;ilen;i++) { out->seq[i] = tolower(reference->seq[i]); } /* calloc sets things to 0 be defn */ swapped = calloc(reference->len,sizeof(char)); for(i=0;ilen;i++) { fprintf(stderr,"Using... %s\n",hl->pair[i]->target->name); for(alc =hl->pair[i]->aln[0]->alb->start ;alc != NULL;alc = alc->next) { /* fprintf(stderr," Looking at %d,%d\n",alc->alu[0]->end,alc->alu[1]->end);*/ if( strcmp(alc->alu[0]->text_label,"SEQUENCE") == 0 && strcmp(alc->alu[1]->text_label,"SEQUENCE") == 0 ) { /* fprintf(stderr,"MATCH Looking at %d,%d\n",alc->alu[0]->end,alc->alu[1]->end); */ coord = alc->alu[0]->end; swap = hl->pair[i]->target->seq[alc->alu[1]->end]; if( swapped[coord] == 1 ) { warn("Reswapping position %d to %c from %c",coord,swap,out->seq[coord]); } else if( toupper(swap) != toupper(out->seq[coord]) ) { info("Swapping position %d from %c to %c",coord,out->seq[coord],swap); } out->seq[coord] = toupper(swap); swapped[coord] = 1; } } } ckfree(swapped); return out; } Sequence * translate_swapped(Sequence * swapped) { CodonTable * ct; int i,j; Sequence * out; out = Sequence_alloc(); out->name = stringalloc(swapped->name); out->seq = calloc(1+swapped->len/3,sizeof(char)); ct = read_CodonTable_file("codon.table"); for(i=0,j=0;ilen;i+=3,j++) { out->seq[j] = aminoacid_from_seq(ct,swapped->seq+i); if( isupper(swapped->seq[i]) && isupper(swapped->seq[i+1]) && isupper(swapped->seq[i+2]) ) { out->seq[j] = toupper(out->seq[j]); } else{ out->seq[j] = tolower(out->seq[j]); } } out->seq[j] = '\0'; return out; } int main(int argc,char ** argv) { DnaMatchPara * para; HitListOutputImpl * hitoutput; HitList * hitlist; Sequence * reference; Sequence * swap; Sequence * trans; SequenceSet * amplimers; int show_hitlist = 0; int show_swapped = 1; hitoutput = new_HitListOutputImpl_from_argv(&argc,argv); para = new_DnaMatchPara_from_argv(&argc,argv); strip_out_boolean_def_argument(&argc,argv,"hitlist",&show_hitlist); strip_out_boolean_def_argument(&argc,argv,"swapped",&show_hitlist); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 3 ) { show_help(stdout); exit(12); } reference = read_fasta_file_Sequence(argv[1]); amplimers = read_fasta_SequenceSet_file(argv[2]); hitlist = HitList_from_Sequence_SequenceSet_DNA(reference,amplimers,para); if( show_hitlist ) { show_HitList_HitListOutputImpl(hitoutput,hitlist,stdout); } swap = swapped_Sequence(reference,hitlist); trans = translate_swapped(swap); if( show_swapped ) { write_fasta_Sequence(swap,stdout); write_fasta_Sequence(trans,stdout); } } wise-2.4.1/src/models/threestatemodel.c0000644000175000001440000022426510670453715017503 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "threestatemodel.h" char * std_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; /* Function: information_from_ThreeStateUnit(tsu,rm) * * Descrip: Gets the information content (K-L divergence) vs a background for a position * * * Arg: tsu [UNKN ] Undocumented argument [ThreeStateUnit *] * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * * Return [UNKN ] Undocumented return value [double] * */ # line 117 "threestatemodel.dy" double information_from_ThreeStateUnit(ThreeStateUnit * tsu,RandomModel * rm) { int i; double info = 0.0; double p; for(i=0;iaminoacid[i] < 1.0 ) { p = rm->aminoacid[i]*Probability2Bits(rm->aminoacid[i]/tsu->match_emission[i]); info += p; /* fprintf(stderr,"For amino acid %d, adding %f %f\n",i,p,rm->aminoacid[i]); */ } } return info; } /* Function: threestatemodel_mode_from_string(mode) * * Descrip: gets out the mode from a string * * * Arg: mode [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 137 "threestatemodel.dy" int threestatemodel_mode_from_string(char * mode) { int t; t = get_number_from_slashed_string(mode,"default/global/local/wing/endbias"); switch (t) { case 0 : return TSM_default; case 1 : return TSM_global; case 2 : return TSM_local; case 3 : return TSM_wing; case 4 : return TSM_endbiased; default : warn("%s is not a valid TSM mode!",mode); return TSM_unknown; } return TSM_unknown; } /* Function: set_startend_policy_ThreeStateModel(tsm,mode,wing_length,internal_bias) * * Descrip: Sets the start/end policy on the basis of the mode * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: mode [UNKN ] Undocumented argument [TSM_StartEndMode] * Arg: wing_length [UNKN ] Undocumented argument [int] * Arg: internal_bias [UNKN ] Undocumented argument [Probability] * */ # line 158 "threestatemodel.dy" void set_startend_policy_ThreeStateModel(ThreeStateModel * tsm,TSM_StartEndMode mode,int wing_length,Probability internal_bias) { switch(mode) { case TSM_default : return; case TSM_global : force_weighted_local_model(tsm,1.0,1.0,1.0); return; case TSM_local : force_hmmfs_ThreeStateModel(tsm); return; case TSM_wing : force_wing_local_model(tsm,0.75,wing_length); return; case TSM_endbiased : force_endbias_model(tsm,1.0,internal_bias); return; case TSM_unknown : default : warn("No valid mode passed into set_startend_policy"); } } /* Function: force_endbias_model(tsm,startend,internal) * * Descrip: Makes start/end on probability and * internal another * * not probabilistically correct * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: startend [UNKN ] Undocumented argument [double] * Arg: internal [UNKN ] Undocumented argument [double] * */ # line 180 "threestatemodel.dy" void force_endbias_model(ThreeStateModel * tsm,double startend,double internal) { int i; if( tsm == NULL ) { warn("In force_endbias_model, got a NULL threestate model! Problem!"); return; } for(i=0;ilen;i++) { tsm->unit[i]->transition[TSM_START2MATCH] = internal; tsm->unit[i]->transition[TSM_START2DELETE] = internal; tsm->unit[i]->transition[TSM_START2INSERT] = internal; tsm->unit[i]->transition[TSM_MATCH2END] = internal; tsm->unit[i]->transition[TSM_INSERT2END] = internal; tsm->unit[i]->transition[TSM_DELETE2END] = internal; } tsm->unit[0]->transition[TSM_START2MATCH] = startend; tsm->unit[0]->transition[TSM_START2DELETE] = startend; tsm->unit[tsm->len-1]->transition[TSM_MATCH2END] = startend; tsm->unit[tsm->len-1]->transition[TSM_DELETE2END] = startend; } /* Function: force_global_model(tsm,prob_into_model) * * Descrip: Makes start at position 0 and end at position end, * no other positions being valid * * * * Arg: tsm [UNKN ] ThreeStateModel to be 'forced' [ThreeStateModel *] * Arg: prob_into_model [UNKN ] Probability to start the model: for true global will be 1.0 [double] * */ # line 214 "threestatemodel.dy" void force_global_model(ThreeStateModel * tsm,double prob_into_model) { force_weighted_local_model(tsm,prob_into_model,1.0,1.0); } /* Function: force_wing_local_model(tsm,terminus_prob,wing_length) * * Descrip: Places the balanace of the start probability * at the start and then the rest spread evenly * descending over the wing stretch of sequences * * Same with the end probability * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: terminus_prob [UNKN ] the amount of probability to put on the real start and end [double] * Arg: wing_length [UNKN ] the rest of the probability spread over this distance into the wing [int] * */ # line 229 "threestatemodel.dy" void force_wing_local_model(ThreeStateModel * tsm,double terminus_prob,int wing_length) { int i; double k; /* * k is the amount to take off for each step along the wing * * it comes from solving sum_(terminus_prob - nk) = 1.0 * with n going from 0 to wing_length * * I make this k = 2(terminus_prob)/wing_length - 2/(wing_length+1)wing_length * */ k = (2.0 * terminus_prob / wing_length) - 2.0 / ((wing_length + 1)*wing_length); if( k < 0.0 ) { warn("Weird - got k less than zero in force wing model"); return; } if( tsm == NULL ) { warn("In force_wing_local_model, got a NULL threestate model! Problem!"); return; } for(i=0;ilen && i < wing_length ;i++) { tsm->unit[i]->transition[TSM_START2MATCH] = (terminus_prob) - (i * k) ; tsm->unit[i]->transition[TSM_START2DELETE] = (terminus_prob) - (i * k) ; tsm->unit[i]->transition[TSM_START2INSERT] = (terminus_prob) - ( i * k) ; tsm->unit[tsm->len-1-i]->transition[TSM_MATCH2END] = (terminus_prob) - (i * k) ; tsm->unit[tsm->len-1-i]->transition[TSM_INSERT2END] = (terminus_prob) - ( i * k) ; tsm->unit[tsm->len-1-i]->transition[TSM_DELETE2END] = (terminus_prob) - (i * k) ; } } /* Function: force_weighted_local_model(tsm,prob_into_model,ratio_start,ratio_end) * * Descrip: places the ratio of probability to start/end, * and then distributes the rest over the start/end * * * * Arg: tsm [UNKN ] ThreeStateModel to be 'forced' [ThreeStateModel *] * Arg: prob_into_model [UNKN ] Probability to start the model: for true global will be 1.0 [double] * Arg: ratio_start [UNKN ] ratio of prob to unit 0 to the rest (1.0 means all goes to start) [double] * Arg: ratio_end [UNKN ] ratio of prob to unit (last) to the rest (1.0 means all goes to the end) [double] * */ # line 284 "threestatemodel.dy" void force_weighted_local_model(ThreeStateModel * tsm,double prob_into_model,double ratio_start,double ratio_end) { int i; if( tsm == NULL ) { warn("In force_weighted_local_model, got a NULL threestate model! Problem!"); return; } for(i=0;ilen;i++) { tsm->unit[i]->transition[TSM_START2MATCH] = prob_into_model * (1.0 - ratio_start) / (tsm->len-1) ; tsm->unit[i]->transition[TSM_START2DELETE] = prob_into_model * (1.0 - ratio_start) / (tsm->len-1); tsm->unit[i]->transition[TSM_START2INSERT] = prob_into_model * (1.0 - ratio_start)/ (tsm->len-1) ; tsm->unit[i]->transition[TSM_MATCH2END] = (1.0 - ratio_end) / (tsm->len-1); tsm->unit[i]->transition[TSM_INSERT2END] = (1.0 - ratio_end) / (tsm->len-1); tsm->unit[i]->transition[TSM_DELETE2END] = (1.0 - ratio_end)/ (tsm->len-1); } tsm->unit[0]->transition[TSM_START2MATCH] = prob_into_model * (ratio_start); tsm->unit[0]->transition[TSM_START2DELETE] = prob_into_model * (ratio_start); /* tsm->unit[0]->transition[TSM_START2INSERT] = prob_into_model * (ratio_start); */ tsm->unit[tsm->len-1]->transition[TSM_MATCH2END] = (ratio_end); tsm->unit[tsm->len-1]->transition[TSM_DELETE2END] = (ratio_end); } /* Function: force_hmmfs_ThreeStateModel(tsm) * * Descrip: places the probability at start end to precisely match * hmmfs code. * * * * Arg: tsm [UNKN ] ThreeStateModel to be 'forced' [ThreeStateModel *] * */ # line 316 "threestatemodel.dy" void force_hmmfs_ThreeStateModel(ThreeStateModel * tsm) { int i; double prob; prob = 1.0 - (1000. / 1001. ); for(i=0;ilen;i++) { tsm->unit[i]->transition[TSM_START2MATCH] = prob*0.5/(2.0 * (tsm->len-1)) ; tsm->unit[i]->transition[TSM_START2DELETE] = 0.0; tsm->unit[i]->transition[TSM_START2INSERT] = 0.0; tsm->unit[i]->transition[TSM_MATCH2END] = 1.0 / (tsm->len-1); tsm->unit[i]->transition[TSM_INSERT2END] = 0.0; tsm->unit[i]->transition[TSM_DELETE2END] = 0.0; } tsm->unit[0]->transition[TSM_START2MATCH] = prob*0.5/2.0; tsm->unit[tsm->len-1]->transition[TSM_MATCH2END] = 1.0; } /* Function: ThreeStateScore_from_ThreeStateModel(tsm) * * Descrip: Converts the three probability form to the score form. * * There is real complications to this due to the fact that the prob * model is a "push" model, that is MATCH2MATCH[i] means the match from i * to i+1, whereas the DP routines rely on a "pull" model, ie * MATCH2MATCH[i] is i-1 to i. * * This routines does the conversion from push to pull, essentially offsetting * the Match2 and Delete2 movements. * * * Arg: tsm [READ ] ThreeStateModel probability form [ThreeStateModel *] * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ # line 350 "threestatemodel.dy" ThreeStateScore * ThreeStateScore_from_ThreeStateModel(ThreeStateModel * tsm) { register int i; ThreeStateScore * tss; tss = ThreeStateScore_alloc_len(tsm->len); add_ThreeStateScore(tss,ThreeStateScoreUnit_from_ThreeStateUnit(NULL,tsm->unit[0])); for(i=1;ilen;i++) add_ThreeStateScore(tss,ThreeStateScoreUnit_from_ThreeStateUnit(tsm->unit[i-1],tsm->unit[i])); tss->name = stringalloc(tsm->name); if( tsm->accession != NULL ) tss->accession = stringalloc(tsm->accession); return tss; } /* Function: ThreeStateScoreUnit_from_ThreeStateUnit(prev,tsu) * * Descrip: Converts a three state model unit to a score unit * * becuase of the push to pull conversion needed, it needs the previous * unit. for the first unit this is NULL and 0s are placed in the correct * places in the transitions * * * Arg: prev [UNKN ] Undocumented argument [ThreeStateUnit *] * Arg: tsu [UNKN ] Undocumented argument [ThreeStateUnit *] * * Return [UNKN ] Undocumented return value [ThreeStateScoreUnit *] * */ # line 376 "threestatemodel.dy" ThreeStateScoreUnit * ThreeStateScoreUnit_from_ThreeStateUnit(ThreeStateUnit * prev,ThreeStateUnit * tsu) { ThreeStateScoreUnit * out; out = ThreeStateScoreUnit_alloc(); if( out == NULL ) return NULL; Probability2Score_move(tsu->match_emission,out->match,ALPHABET_SIZE); Probability2Score_move(tsu->insert_emission,out->insert,ALPHABET_SIZE); if( prev != NULL ) { out->trans[TSM_MATCH2MATCH] = Probability2Score(prev->transition[TSM_MATCH2MATCH]); out->trans[TSM_INSERT2MATCH] = Probability2Score(prev->transition[TSM_INSERT2MATCH]); out->trans[TSM_DELETE2MATCH] = Probability2Score(prev->transition[TSM_DELETE2MATCH]); out->trans[TSM_MATCH2DELETE] = Probability2Score(prev->transition[TSM_MATCH2DELETE]); out->trans[TSM_INSERT2DELETE] = Probability2Score(prev->transition[TSM_INSERT2DELETE]); out->trans[TSM_DELETE2DELETE] = Probability2Score(prev->transition[TSM_DELETE2DELETE]); } else { out->trans[TSM_MATCH2MATCH] = NEGI; out->trans[TSM_INSERT2MATCH] = NEGI; out->trans[TSM_DELETE2MATCH] = NEGI; out->trans[TSM_MATCH2DELETE] = NEGI; out->trans[TSM_INSERT2DELETE] = NEGI; out->trans[TSM_DELETE2DELETE] = NEGI; } out->trans[TSM_MATCH2INSERT] = Probability2Score(tsu->transition[TSM_MATCH2INSERT]); out->trans[TSM_INSERT2INSERT] = Probability2Score(tsu->transition[TSM_INSERT2INSERT]); out->trans[TSM_DELETE2INSERT] = Probability2Score(tsu->transition[TSM_DELETE2INSERT]); out->trans[TSM_START2MATCH] = Probability2Score(tsu->transition[TSM_START2MATCH]); out->trans[TSM_START2INSERT] = Probability2Score(tsu->transition[TSM_START2INSERT]); out->trans[TSM_START2DELETE] = Probability2Score(tsu->transition[TSM_START2DELETE]); out->trans[TSM_MATCH2END] = Probability2Score(tsu->transition[TSM_MATCH2END]); out->trans[TSM_INSERT2END] = Probability2Score(tsu->transition[TSM_INSERT2END]); out->trans[TSM_DELETE2END] = Probability2Score(tsu->transition[TSM_DELETE2END]); return out; } /* Function: show_ThreeStateModel(tsm,ofp) * * Descrip: shows pretty ugly debugging type format. * * Pretty useless * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 428 "threestatemodel.dy" void show_ThreeStateModel(ThreeStateModel * tsm,FILE * ofp) { register int i; for(i=0;ilen;i++) { fprintf(ofp,"Position %d %c\n",i,tsm->unit[i]->display_char); show_ThreeStateUnit(tsm->unit[i],ofp); } } /* Function: show_ThreeStateUnit(tsu,ofp) * * Descrip: for debugging problems * * * Arg: tsu [UNKN ] Undocumented argument [ThreeStateUnit *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 442 "threestatemodel.dy" void show_ThreeStateUnit(ThreeStateUnit * tsu,FILE * ofp) { fprintf(ofp,"Match "); show_Probability_array(tsu->match_emission,26,ofp); fprintf(ofp,"\nInsert "); show_Probability_array(tsu->insert_emission,26,ofp); fprintf(ofp,"\nTransition "); show_Probability_array(tsu->transition,TRANSITION_LEN,ofp); fprintf(ofp,"\n"); } /* Function: pseudo_Protein_from_ThreeStateModel(tsm) * * Descrip: Makes a protein sequence out of the display characters. * Not very useful! * * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * * Return [UNKN ] Undocumented return value [Protein *] * */ # line 459 "threestatemodel.dy" Protein * pseudo_Protein_from_ThreeStateModel(ThreeStateModel * tsm) { int i; Sequence * seq; seq = Sequence_alloc(); seq->name = stringalloc(tsm->name); seq->seq = ckcalloc(tsm->len+1,sizeof(char)); for(i=0;ilen;i++) { seq->seq[i] = tsm->unit[i]->display_char; } seq->seq[i]='\0'; make_len_type_Sequence(seq); seq->type = SEQUENCE_PROTEIN; return Protein_from_Sequence(seq); } /* Function: ThreeStateModel_from_half_bit_Sequence(pro,mat,rm,gap,ext) * * Descrip: Makes a local three-state-model from a sequence. this is scary * hackery, assumming that the matrix is half-bits and normalising in a * *very* wrong way to get "probabilities" out. * * Works though * * * Arg: pro [READ ] protein sequence [Protein *] * Arg: mat [READ ] comparison matrix to use [CompMat *] * Arg: rm [READ ] random model which you assumme the matrix was built with [RandomModel *] * Arg: gap [READ ] gap open penalty [int] * Arg: ext [READ ] gap ext penalty [int] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 494 "threestatemodel.dy" ThreeStateModel * ThreeStateModel_from_half_bit_Sequence(Protein * pro,CompMat * mat,RandomModel * rm,int gap,int ext) { Sequence * seq; register int i; ThreeStateModel * out; if( pro == NULL || mat == NULL || rm == NULL ) { warn("you have passed through NULL objects in trying to make TSM from sequence"); return NULL; } if( gap > 0 || ext > 0 ) { warn("You have passed in gap and extension penalties of > 0 Gap %d Ext %d. Expecting them to be negated. Giving you back an error!",gap,ext); return NULL; } seq = pro->baseseq; out = ThreeStateModel_alloc_len(seq->len); if( seq->name != NULL ) out->name = stringalloc(seq->name); else out->name = stringalloc("NoName"); out->rm = hard_link_RandomModel(rm); for(i=0;ilen;i++) { add_ThreeStateModel(out,ThreeStateUnit_from_half_bit_aminoacid(seq->seq[i],mat,rm,gap,ext)); } return out; } /* Function: ThreeStateUnit_from_half_bit_aminoacid(aa,mat,rm,gap,ext) * * Descrip: The internal protein->hmm conversion routine. * * * Arg: aa [UNKN ] Undocumented argument [char] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * Arg: gap [UNKN ] Undocumented argument [int] * Arg: ext [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ThreeStateUnit *] * */ # line 536 "threestatemodel.dy" ThreeStateUnit * ThreeStateUnit_from_half_bit_aminoacid(char aa,CompMat * mat,RandomModel * rm,int gap,int ext) { ThreeStateUnit * tsu; register int i; Probability go; Probability ge; Probability rnd_error; tsu = ThreeStateUnit_alloc(); aa = toupper((int)aa); /* maybe do more checking on aa? */ for(i=0;i<26;i++) { tsu->match_emission[i] = halfbit2Probability(fail_safe_CompMat_access(mat,aa-'A',i)) * rm->aminoacid[i]; tsu->insert_emission[i] = rm->aminoacid[i]; } rnd_error = renormalise_Probability_array(tsu->match_emission,26); if( fabs(rnd_error) > 0.5 ) { warn("Very bad problem - got a stupid error %.2f after renormalisation from the null model with the match state on aa %c\n",rnd_error,aa); } rnd_error = renormalise_Probability_array(tsu->insert_emission,26); if( fabs(rnd_error) > 0.5 ) { warn("Very bad problem - got a stupid error %.2f after renormalisation from the null model\n",rnd_error); } ge = halfbit2Probability(ext); go = halfbit2Probability(gap); /** 1-ge is the gap closing penalty. So we have to remove that from the go **/ go = go / (1-ge); tsu->transition[TSM_MATCH2INSERT] = tsu->transition[TSM_MATCH2DELETE] = go; tsu->transition[TSM_INSERT2MATCH] = tsu->transition[TSM_DELETE2MATCH] = 1-ge; tsu->transition[TSM_INSERT2INSERT] = tsu->transition[TSM_DELETE2DELETE] = ge; tsu->transition[TSM_INSERT2DELETE] = tsu->transition[TSM_DELETE2INSERT] = 0.0; tsu->transition[TSM_MATCH2MATCH] = 1-(2*go); tsu->transition[TSM_START2MATCH] = 1.0; tsu->transition[TSM_MATCH2END] = 1.0; tsu->display_char = aa; return tsu; } /* Function: global_ThreeStateModel_from_half_bit_Sequence(pro,mat,rm,gap,ext) * * Descrip: Makes a global three-state-model from a sequence. * Like the local version, this is scary hackery, assumming * that the matrix is half-bits and normalising in a *very* * wrong way to get "probabilities" out. * * Works though * * * Arg: pro [READ ] protein sequence [Protein *] * Arg: mat [READ ] comparison matrix to use [CompMat *] * Arg: rm [READ ] random model which you assumme the matrix was built with [RandomModel *] * Arg: gap [READ ] gap open penalty [int] * Arg: ext [READ ] gap ext penalty [int] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 602 "threestatemodel.dy" ThreeStateModel * global_ThreeStateModel_from_half_bit_Sequence(Protein * pro,CompMat * mat,RandomModel * rm,int gap,int ext) { register int i; ThreeStateModel * out; ThreeStateUnit * temp; Sequence * seq; if( pro == NULL || mat == NULL || rm == NULL ) { warn("you have passed through NULL objects in trying to make TSM from sequence"); return NULL; } seq = pro->baseseq; out = ThreeStateModel_alloc_len(seq->len); if( seq->name != NULL ) out->name = stringalloc(seq->name); else out->name = stringalloc("NoName"); for(i=0;ilen;i++) { temp = ThreeStateUnit_from_half_bit_aminoacid(seq->seq[i],mat,rm,gap,ext); temp->transition[TSM_START2MATCH] = 0.0; temp->transition[TSM_MATCH2END] = 0.0; add_ThreeStateModel(out,temp); } out->unit[0]->transition[TSM_START2MATCH] = 1.0; out->unit[out->len-1]->transition[TSM_MATCH2END] = 1.0; out->rm = hard_link_RandomModel(rm); return out; } /* Function: display_char_for_ThreeStateUnit(tsu) * * Descrip: Makes a display character for * this threestateunit by finding the * most probable match emission * * * Arg: tsu [UNKN ] Undocumented argument [ThreeStateUnit *] * * Return [UNKN ] Undocumented return value [char] * */ # line 646 "threestatemodel.dy" char display_char_for_ThreeStateUnit(ThreeStateUnit * tsu) { register int i; Probability p; int c; p = tsu->match_emission[0]; c = 0; for(i=1;imatch_emission[i] > p ) { p = tsu->match_emission[i]; c = i; } return c + 'A'; } /* Function: display_char_in_ThreeStateModel(tsm) * * Descrip: Makes the display chars in the tsm come from * the most likely amino acid in the match position * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * */ # line 668 "threestatemodel.dy" void display_char_in_ThreeStateModel(ThreeStateModel * tsm) { register int i; for(i=0;ilen;i++) tsm->unit[i]->display_char = display_char_for_ThreeStateUnit(tsm->unit[i]); } /* Function: fold_RandomModel_into_ThreeStateModel(tsm,rm) * * Descrip: divides the emission and insertion scores * by the random model for use in log-odd * implementations * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * */ # line 681 "threestatemodel.dy" void fold_RandomModel_into_ThreeStateModel(ThreeStateModel * tsm,RandomModel * rm) { register int i; register int j; assert(tsm); assert(rm); for(i=0;ilen;i++) { auto ThreeStateUnit * tsu; tsu = tsm->unit[i]; for(j=0;j<26;j++) { if( rm->aminoacid[j] < 0.00000001 ) { warn("While trying to fold in random model, amino acid %d [%c] was below zero, ignoring",j,'A'+j); continue; } tsu->match_emission[j] = tsu->match_emission[j] / rm->aminoacid[j]; tsu->insert_emission[j] = tsu->insert_emission[j] / rm->aminoacid[j]; } } } /* Function: add_sensible_start_end_global_for_HMMer(tsm) * * Descrip: added start 0.5, 0.25,0.25 for hmmls type * * Deprecated * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * */ # line 709 "threestatemodel.dy" void add_sensible_start_end_global_for_HMMer(ThreeStateModel * tsm) { ThreeStateUnit * end; tsm->unit[0]->transition[TSM_START2MATCH] = 0.5; tsm->unit[0]->transition[TSM_START2INSERT] = 0.25; tsm->unit[0]->transition[TSM_START2DELETE] = 0.25; /*** these should not add to one due to sum in states ***/ end = tsm->unit[tsm->len-1]; end->transition[TSM_MATCH2END] = (1 - end->transition[TSM_MATCH2INSERT]) ; end->transition[TSM_DELETE2END] = (1 - end->transition[TSM_DELETE2INSERT]) ; end->transition[TSM_INSERT2END] = (1 - end->transition[TSM_INSERT2INSERT]); } /* Function: add_sensible_start_end_looping_for_HMMer(tsm,loop) * * Descrip: adds start/end for loop probabilities coming * in * * Deprecated * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: loop [UNKN ] Undocumented argument [Probability] * */ # line 734 "threestatemodel.dy" void add_sensible_start_end_looping_for_HMMer(ThreeStateModel * tsm,Probability loop) { tsm->unit[0]->transition[TSM_START2MATCH] = loop * 0.5; tsm->unit[0]->transition[TSM_START2INSERT] = loop * 0.25; tsm->unit[0]->transition[TSM_START2DELETE] = loop * 0.25; /*** these should not add to one due to sum in states ***/ tsm->unit[tsm->len-1]->transition[TSM_MATCH2END] = 0.5; tsm->unit[tsm->len-1]->transition[TSM_DELETE2END] = 0.25; tsm->unit[tsm->len-1]->transition[TSM_INSERT2END] = 0.25; } /**** I/O *****/ /* Function: write_HMF_ThreeStateModel(tsm,ofp) * * Descrip: writes the HMF format * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 757 "threestatemodel.dy" void write_HMF_ThreeStateModel(ThreeStateModel * tsm,FILE * ofp) { int i; fprintf(ofp,"ID %s\n",tsm->name != NULL ? tsm->name : "NoName"); fprintf(ofp,"TR %4.2f\n",tsm->threshold); fprintf(ofp,"CC HMF format for HMM, each three state block starts UN after MO line\n"); fprintf(ofp,"CC Alphabet A-Z\n"); fprintf(ofp,"MO\n"); for(i=0;ilen;i++) write_HMF_ThreeStateUnit(tsm->unit[i],ofp); fprintf(ofp,"//\n"); } /* Function: write_HMF_ThreeStateUnit(tsu,ofp) * * Descrip: writes each Unit line * * * Arg: tsu [UNKN ] Undocumented argument [ThreeStateUnit *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 778 "threestatemodel.dy" void write_HMF_ThreeStateUnit(ThreeStateUnit * tsu,FILE * ofp) { fprintf(ofp,"UN %c\n",tsu->display_char); fprintf(ofp,"MA "); show_Probability_array_exp(tsu->match_emission,ALPHABET_SIZE,ofp); fprintf(ofp,"\nIN "); show_Probability_array_exp(tsu->insert_emission,ALPHABET_SIZE,ofp); fprintf(ofp,"\nTR "); show_Probability_array_exp(tsu->transition,TRANSITION_LEN,ofp); fprintf(ofp,"\n"); } /* Function: read_HMF_ThreeStateModel(ifp) * * Descrip: reads the HMF format. Leaves the file ready * to read the next format * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 794 "threestatemodel.dy" ThreeStateModel * read_HMF_ThreeStateModel(FILE * ifp) { ThreeStateUnit * temp; ThreeStateModel * out; char buffer[MAXLINE]; char * name = NULL; char * runner; if( feof(ifp) || ferror(ifp) ) return NULL; while( fgets(buffer,MAXLINE,ifp) != NULL ) { chop_newline(buffer); if( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"ID") == 0 ) { name = stringalloc(strtok(buffer+3,spacestr)); break; } warn("In reading HMF format, before ID line, ignoring [%s]",buffer); } if( feof(ifp) || ferror(ifp) || name == NULL) return NULL; out = ThreeStateModel_alloc_std(); out->name = name; while( fgets(buffer,MAXLINE,ifp) != NULL ) { chop_newline(buffer); if( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"MO") == 0 ) break; else if( strstartcmp(buffer,"CC") == 0 ) continue; else if( strstartcmp(buffer,"TR") == 0 ) { runner = strtok(buffer+2,spacestr); if( is_double_string(runner,&out->threshold) == FALSE) { warn("Could not interpret [%s] as a threshold",runner); } } else if( strstartcmp(buffer,"ID") == 0 ) { warn("Already got a name for [%s], ignoring [%s]",out->name,buffer); } else { warn("Did not understand %s",buffer); } } while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"UN") == 0 ) break; chop_newline(buffer); warn("You have a problem here: [%s] between MO and UN lines",buffer); } while( (temp = read_HMF_ThreeStateUnit(buffer,ifp)) != NULL ) { add_ThreeStateModel(out,temp); if( strstartcmp(buffer,"//") == 0 ) break; } display_char_in_ThreeStateModel(out); return out; } /* Function: read_HMF_ThreeStateUnit(line,ifp) * * Descrip: reads a unit set of lines: * * Line is used as the buffer, so should be MAXLINE length. At the * end, it will have a different characters (probably the next unit * line) in the line buffer, so you should test that * * * Arg: line [WRITE] pointer to a MAXLINE length buffer. [char *] * Arg: ifp [UNKN ] input file [FILE *] * * Return [UNKN ] Undocumented return value [ThreeStateUnit *] * */ # line 877 "threestatemodel.dy" ThreeStateUnit * read_HMF_ThreeStateUnit(char * line,FILE * ifp) { ThreeStateUnit * out; char * runner; if( strstartcmp(line,"UN") != 0 ) { warn("Attempting to read a ThreeStateUnit with a non UN line: [%s]",line); return NULL; } out = blank_ThreeStateUnit(); /* display char */ runner = strtok(line+2,spacestr); if( runner != NULL ) { out->display_char = *runner; } while ( fgets(line,MAXLINE,ifp) != NULL ) { if( strstartcmp(line,"//") == 0 ) break; if( strstartcmp(line,"UN") == 0 ) break; if( strstartcmp(line,"MA") == 0 ) { if( read_Probability_array(out->match_emission,ALPHABET_SIZE,line+3) == FALSE ) { warn("Unable to read Match emission line"); } } else if ( strstartcmp(line,"IN") == 0) { if( read_Probability_array(out->insert_emission,ALPHABET_SIZE,line+3) == FALSE ) { warn("Unable to read Insert emission line"); } } else if ( strstartcmp(line,"TR") == 0 ) { if( read_Probability_array(out->transition,TRANSITION_LEN,line+3) == FALSE ) { warn("Unable to read Insert emission line"); } } else { chop_newline(line); warn("Could not understand line [%s] in reading threestateunit",line); } } return out; } /* Function: write_HMMer_1_7_ascii_ThreeStateModel(tsm,ofp) * * Descrip: writes a HMMer version 1.7 (also ok with 1.8) file * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 925 "threestatemodel.dy" void write_HMMer_1_7_ascii_ThreeStateModel(ThreeStateModel * tsm,FILE * ofp) { register int i; fprintf(ofp,"# HMM v1.7\n"); fprintf(ofp,"%d # Length of model\n",tsm->len); fprintf(ofp,"%d # length of alphabet\n",26); fprintf(ofp,"3 # alphabet type\n"); fprintf(ofp,"%s # alphabet\n",std_alphabet); fprintf(ofp,"no # optional\nno # optional \n"); for(i=0;ilen;i++) write_HMMer_1_7_ascii_ThreeStateUnit(tsm->unit[i],i,ofp); } /* Function: write_HMMer_1_7_ascii_ThreeStateUnit(tsu,no,ofp) * * Descrip: the internal for the ThreeStateModel write * * * Arg: tsu [UNKN ] Undocumented argument [ThreeStateUnit *] * Arg: no [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 944 "threestatemodel.dy" void write_HMMer_1_7_ascii_ThreeStateUnit(ThreeStateUnit * tsu,int no,FILE * ofp) { register int i; fprintf(ofp,"###MATCH_STATE %d ( ) ( )\n",no); fprintf(ofp,"%f\t# t_m%d\n",tsu->transition[TSM_MATCH2MATCH],no+1); fprintf(ofp,"%f\t# t_d%d\n",tsu->transition[TSM_MATCH2DELETE],no+1); fprintf(ofp,"%f\t# t_i%d\n",tsu->transition[TSM_MATCH2INSERT],no); for(i=0;i<26;i++) { fprintf(ofp,"%f\t# Symbol %c probability\n",tsu->match_emission[i],'A'+i); } fprintf(ofp,"###DELETE_STATE %d\n",no); fprintf(ofp,"%f\t# t_m%d\n",tsu->transition[TSM_DELETE2MATCH],no+1); fprintf(ofp,"%f\t# t_d%d\n",tsu->transition[TSM_DELETE2DELETE],no+1); fprintf(ofp,"%f\t# t_i%d\n",tsu->transition[TSM_DELETE2INSERT],no); fprintf(ofp,"###INSERT_STATE %d\n",no); fprintf(ofp,"%f\t# t_m%d\n",tsu->transition[TSM_INSERT2MATCH],no+1); fprintf(ofp,"%f\t# t_d%d\n",tsu->transition[TSM_INSERT2DELETE],no+1); fprintf(ofp,"%f\t# t_i%d\n",tsu->transition[TSM_INSERT2INSERT],no); for(i=0;i<26;i++) { fprintf(ofp,"%f\t# Symbol %c probability\n",tsu->insert_emission[i],'A'+i); } } /* Function: read_HMMer_1_7_ascii_file(filename) * * Descrip: reads a HMMer ascii version 1.7 (1.8) file from filename. * * * * Arg: filename [UNKN ] the name fo the hmmer file [char *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 977 "threestatemodel.dy" ThreeStateModel * read_HMMer_1_7_ascii_file(char * filename) { FILE * ifp; ThreeStateModel * out; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open file %s for read HMMer 17 ",filename); return NULL; } out = read_HMMer_1_7_ascii(ifp); ckfree(out->name); if( strcmp(filename,"-") == 0 ) { /* comes from stdin, we're fucked to find the name */ out->name = stringalloc("HMMerModel"); } else { if( strchr(filename,'/') != NULL) { filename = filename + strlen(filename) -1; for(;*filename != '/';filename--) ; filename++; } out->name = stringalloc(filename); } fclose(ifp); return out; } /* Function: convert_push_model_to_pull_model(tsm) * * Descrip: Not sure if this is needed now, as score model will be pull, and * probability model will be push. * * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 1016 "threestatemodel.dy" ThreeStateModel * convert_push_model_to_pull_model(ThreeStateModel * tsm) { register int i; ThreeStateModel * out; out = ThreeStateModel_alloc_len(tsm->len-1); for(i=1;ilen;i++) add_ThreeStateModel(out,convert_push_unit_to_pull_unit(tsm->unit[i-1],tsm->unit[i])); if( tsm->name != NULL) out->name = stringalloc(tsm->name); return out; } /* Function: convert_push_unit_to_pull_unit(prev,this) * * Descrip: Not sure if this is needed now, as score model will be pull, and * probability model will be push. * * * * Arg: prev [UNKN ] Undocumented argument [ThreeStateUnit *] * Arg: this [UNKN ] Undocumented argument [ThreeStateUnit *] * * Return [UNKN ] Undocumented return value [ThreeStateUnit *] * */ # line 1039 "threestatemodel.dy" ThreeStateUnit * convert_push_unit_to_pull_unit(ThreeStateUnit * prev,ThreeStateUnit * this) { ThreeStateUnit * out; out = ThreeStateUnit_alloc(); Probability_move(this->match_emission ,out->match_emission ,ALPHABET_SIZE); Probability_move(this->insert_emission,out->insert_emission,ALPHABET_SIZE); set_Probability_array(out->transition,0.0,TRANSITION_LEN); out->transition[TSM_MATCH2MATCH] = prev->transition[TSM_MATCH2MATCH]; out->transition[TSM_DELETE2MATCH] = prev->transition[TSM_DELETE2MATCH]; out->transition[TSM_INSERT2MATCH] = prev->transition[TSM_INSERT2MATCH]; out->transition[TSM_MATCH2INSERT] = this->transition[TSM_MATCH2INSERT]; out->transition[TSM_INSERT2INSERT] = this->transition[TSM_INSERT2INSERT]; out->transition[TSM_DELETE2INSERT] = this->transition[TSM_DELETE2INSERT]; out->transition[TSM_MATCH2DELETE] = prev->transition[TSM_MATCH2DELETE]; out->transition[TSM_INSERT2DELETE] = prev->transition[TSM_INSERT2DELETE]; out->transition[TSM_DELETE2DELETE] = prev->transition[TSM_DELETE2DELETE]; /*** not dealing with start/end things here ***/ return out; } /* Function: read_HMMer_1_7_ascii(ifp) * * Descrip: Basic function to read HMMer version 1.7(1.8) files. * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 1071 "threestatemodel.dy" ThreeStateModel * read_HMMer_1_7_ascii(FILE * ifp) { char buffer[MAXLINE]; char * runner; char * alphabet; int length; int count; ThreeStateModel * out; ThreeStateUnit * temp; /*** read top of model ***/ /*** then we will loop ***/ /*** over all the states ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, but no first line!"); return NULL; } if( strstartcmp(buffer,"# HMM") != 0 ) { warn("In reading HMMer ascii file, expecting first line to start [# HMM], starts as [%s]... can't handle",buffer); return NULL; } if( strstartcmp(buffer,"# HMM v1.7") != 0) { warn("In reading HMMer ascii file, expecting a version 1.7 file, got a version [%s] file... trying to read",buffer); } /*** length next ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, length line (2nd line) not there"); return NULL; } if( (runner=strtok(buffer,spacestr)) == NULL ) { warn("Trying to read HMMer ascii file, length line (2nd line) has no length!"); return NULL; } length = atoi(runner); if( length <= 0 || length > 4000 ) { warn("Picked up length [%s] which was interpreted as the number [%d], which seems unfeasible. S'ok... can work without the length",runner,length); length = 100; } /*** get the alphabet length... no point in checking ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, length of alphabet (3rd line) not there"); return NULL; } if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, type of alphabet (4th line) not there"); return NULL; } if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, alphabet (5th line) not there"); return NULL; } if( (runner=strtok(buffer,spacestr)) == NULL ) { warn("HMMer ascii read, alphabet line (5th line) has no alphabet!"); return NULL; } alphabet = stringalloc(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, reference (6th line) not there"); return NULL; } if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Trying to read HMMer ascii file, reference (7th line) not there"); return NULL; } /*** ok, ready to rock, we have the length and alphabet, ***/ /*** now loop over the states ... ***/ out = ThreeStateModel_alloc_len(length); for(count=0;count < length+1 && !feof(ifp) && !(ferror(ifp));count++ ) { temp = read_HMMer_1_7_ThreeStateUnit(alphabet,ifp); if( temp == NULL ) { warn("In HMMer read, On unit number [%d], unable to get unit...",count); break; } if( count == 0 ) continue; /** skip first "dummy" state **/ else add_ThreeStateModel(out,temp); } out->name = stringalloc("HMMer Model"); out->alphabet = alphabet; /*** by default, make it a global model ***/ force_global_model(out,1.0); return out; } /* Function: read_HMMer_1_7_ThreeStateUnit(alphabet,ifp) * * Descrip: Function to read a single unit from a 1.7(1.8) file * * * * Arg: alphabet [UNKN ] Undocumented argument [char *] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [ThreeStateUnit *] * */ # line 1190 "threestatemodel.dy" ThreeStateUnit * read_HMMer_1_7_ThreeStateUnit(char * alphabet,FILE * ifp) { char buffer[MAXLINE]; char * runner; char * al; ThreeStateUnit * out; if( fgets(buffer,MAXLINE,ifp) == NULL ) { /*** could be the end of the model. Return silently for the next stage ***/ return NULL; } if( strstartcmp(buffer,"###MATCH_STATE") != 0 ) { warn("Start of ThreeStateUnit HMMr read... does not match [###MATCH_STATE], instead... [%s]",buffer); return NULL; } out = blank_ThreeStateUnit(); if( out == NULL ) return NULL; /** warning already issued **/ /*** ok read in the first three transitions ***/ /*** transitions for MATCH ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no m2m line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got m2m line, but no transition worked out"); return NULL; } out->transition[TSM_MATCH2MATCH] = atof(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no m2d line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got m2d line, but no transition worked out"); return NULL; } out->transition[TSM_MATCH2DELETE] = atof(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no m2i line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got m2i line, but no transition worked out"); return NULL; } out->transition[TSM_MATCH2INSERT] = atof(runner); /*** match emission probs ***/ for(al=alphabet;*al;al++) { if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr threestateunit, the file ended on the match emission of %c",*al); free_ThreeStateUnit(out); return NULL; } runner = strtok(buffer,spacestr); /**** ASSUMMING a 26 alphabet now... Aaaaah ****/ out->match_emission[ toupper((int)*al)-'A'] = atof(runner); } /*** now to delete probabilities ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no start line!"); return NULL; } if( strstartcmp(buffer,"###DELETE_STATE") != 0 ) { warn("Start of delete ThreeStateUnit HMMr read... does not match [###DELETE_STATE], instead... [%s]",buffer); return NULL; } /*** ok read in the first three transitions ***/ /*** transitions for DELETE ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no d2m line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got d2m line, but no transition worked out"); return NULL; } out->transition[TSM_DELETE2MATCH] = atof(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no d2d line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got d2d line, but no transition worked out"); return NULL; } out->transition[TSM_DELETE2DELETE] = atof(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no d2i line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got d2i line, but no transition worked out"); return NULL; } out->transition[TSM_DELETE2INSERT] = atof(runner); /***** now insert probs *****/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no start line!"); return NULL; } if( strstartcmp(buffer,"###INSERT_STATE") != 0 ) { warn("Start of ThreeStateUnit HMMr read... does not match [###INSERT_STATE], instead... [%s]",buffer); return NULL; } /*** ok read in the first three transitions ***/ /*** transitions for INSERT ***/ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no i2m line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got i2m line, but no transition worked out"); return NULL; } out->transition[TSM_INSERT2MATCH] = atof(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no i2d line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got i2d line, but no transition worked out"); return NULL; } out->transition[TSM_INSERT2DELETE] = atof(runner); if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr ThreeStateUnit, got no i2i line"); free_ThreeStateUnit(out); return NULL; } if( (runner = strtok(buffer,spacestr)) == NULL ) { warn("In reading HMMr ThreeStateUnit, got i2i line, but no transition worked out"); return NULL; } out->transition[TSM_INSERT2INSERT] = atof(runner); /*** insert emission probs ***/ for(al=alphabet;*al;al++) { if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("In reading HMMr threestateunit, the file ended on the insert emission of %c",*al); free_ThreeStateUnit(out); return NULL; } runner = strtok(buffer,spacestr); /**** ASSUMMING a 26 alphabet now... Aaaaah ****/ out->insert_emission[ toupper((int)*al)-'A'] = atof(runner); } return out; } /* Function: blank_ThreeStateUnit(void) * * Descrip: Makes a set to 0.0 unit * * * * Return [UNKN ] Undocumented return value [ThreeStateUnit *] * */ # line 1404 "threestatemodel.dy" ThreeStateUnit * blank_ThreeStateUnit(void) { ThreeStateUnit * out; register int i; out = ThreeStateUnit_alloc(); if(out == NULL ) return NULL; for(i=0;i<26;i++) out->match_emission[i] = out->insert_emission[i] = 0.0; for(i=0;itransition[i] = 0.0; return out; } # line 1476 "threestatemodel.c" /* Function: hard_link_ThreeStateUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ThreeStateUnit *] * * Return [UNKN ] Undocumented return value [ThreeStateUnit *] * */ ThreeStateUnit * hard_link_ThreeStateUnit(ThreeStateUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a ThreeStateUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ThreeStateUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateUnit *] * */ ThreeStateUnit * ThreeStateUnit_alloc(void) { ThreeStateUnit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ThreeStateUnit *) ckalloc (sizeof(ThreeStateUnit))) == NULL) { warn("ThreeStateUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* match_emission[ALPHABET_SIZE] is an array: no default possible */ /* insert_emission[ALPHABET_SIZE] is an array: no default possible */ /* transition[TRANSITION_LEN] is an array: no default possible */ out->display_char = 'u'; return out; } /* Function: free_ThreeStateUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateUnit *] * * Return [UNKN ] Undocumented return value [ThreeStateUnit *] * */ ThreeStateUnit * free_ThreeStateUnit(ThreeStateUnit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ThreeStateUnit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_ThreeStateModel(list,i,j) * * Descrip: swap function: an internal for qsort_ThreeStateModel * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ThreeStateUnit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ThreeStateModel(ThreeStateUnit ** list,int i,int j) { ThreeStateUnit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ThreeStateModel(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ThreeStateModel which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ThreeStateUnit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ThreeStateModel(ThreeStateUnit ** list,int left,int right,int (*comp)(ThreeStateUnit * ,ThreeStateUnit * )) { int i,last; if( left >= right ) return; swap_ThreeStateModel(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ThreeStateModel (list,++last,i); } swap_ThreeStateModel (list,left,last); qsort_ThreeStateModel(list,left,last-1,comp); qsort_ThreeStateModel(list,last+1,right,comp); } /* Function: sort_ThreeStateModel(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ThreeStateModel * * * Arg: obj [UNKN ] Object containing list [ThreeStateModel *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ThreeStateModel(ThreeStateModel * obj,int (*comp)(ThreeStateUnit *, ThreeStateUnit *)) { qsort_ThreeStateModel(obj->unit,0,obj->len-1,comp); return; } /* Function: expand_ThreeStateModel(obj,len) * * Descrip: Really an internal function for add_ThreeStateModel * * * Arg: obj [UNKN ] Object which contains the list [ThreeStateModel *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ThreeStateModel(ThreeStateModel * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_ThreeStateModel called with no need"); return TRUE; } if( (obj->unit = (ThreeStateUnit ** ) ckrealloc (obj->unit,sizeof(ThreeStateUnit *)*len)) == NULL) { warn("ckrealloc failed for expand_ThreeStateModel, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_ThreeStateModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ThreeStateModel *] * Arg: add [OWNER] Object to add to the list [ThreeStateUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ThreeStateModel(ThreeStateModel * obj,ThreeStateUnit * add) { if( obj->len >= obj->maxlen) { if( expand_ThreeStateModel(obj,obj->len + ThreeStateModelLISTLENGTH) == FALSE) return FALSE; } obj->unit[obj->len++]=add; return TRUE; } /* Function: flush_ThreeStateModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ThreeStateModel *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ThreeStateModel(ThreeStateModel * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->unit[i] != NULL) { free_ThreeStateUnit(obj->unit[i]); obj->unit[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: ThreeStateModel_alloc_std(void) * * Descrip: Equivalent to ThreeStateModel_alloc_len(ThreeStateModelLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * ThreeStateModel_alloc_std(void) { return ThreeStateModel_alloc_len(ThreeStateModelLISTLENGTH); } /* Function: ThreeStateModel_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * ThreeStateModel_alloc_len(int len) { ThreeStateModel * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = ThreeStateModel_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->unit = (ThreeStateUnit ** ) ckcalloc (len,sizeof(ThreeStateUnit *))) == NULL) { warn("Warning, ckcalloc failed in ThreeStateModel_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_ThreeStateModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ThreeStateModel *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * hard_link_ThreeStateModel(ThreeStateModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a ThreeStateModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ThreeStateModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * ThreeStateModel_alloc(void) { ThreeStateModel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ThreeStateModel *) ckalloc (sizeof(ThreeStateModel))) == NULL) { warn("ThreeStateModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->unit = NULL; out->len = out->maxlen = 0; out->alphabet = NULL; out->accession = NULL; out->threshold = 0; out->rm = NULL; return out; } /* Function: free_ThreeStateModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateModel *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * free_ThreeStateModel(ThreeStateModel * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ThreeStateModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->unit != NULL) { for(i=0;ilen;i++) { if( obj->unit[i] != NULL) free_ThreeStateUnit(obj->unit[i]); } ckfree(obj->unit); } if( obj->alphabet != NULL) ckfree(obj->alphabet); if( obj->accession != NULL) ckfree(obj->accession); if( obj->rm != NULL) free_RandomModel(obj->rm); ckfree(obj); return NULL; } /* Function: hard_link_ThreeStateScoreUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ThreeStateScoreUnit *] * * Return [UNKN ] Undocumented return value [ThreeStateScoreUnit *] * */ ThreeStateScoreUnit * hard_link_ThreeStateScoreUnit(ThreeStateScoreUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a ThreeStateScoreUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ThreeStateScoreUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateScoreUnit *] * */ ThreeStateScoreUnit * ThreeStateScoreUnit_alloc(void) { ThreeStateScoreUnit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ThreeStateScoreUnit *) ckalloc (sizeof(ThreeStateScoreUnit))) == NULL) { warn("ThreeStateScoreUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* match[ALPHABET_SIZE] is an array: no default possible */ /* insert[ALPHABET_SIZE] is an array: no default possible */ /* trans[TRANSITION_LEN] is an array: no default possible */ return out; } /* Function: free_ThreeStateScoreUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateScoreUnit *] * * Return [UNKN ] Undocumented return value [ThreeStateScoreUnit *] * */ ThreeStateScoreUnit * free_ThreeStateScoreUnit(ThreeStateScoreUnit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ThreeStateScoreUnit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_ThreeStateScore(list,i,j) * * Descrip: swap function: an internal for qsort_ThreeStateScore * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ThreeStateScoreUnit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ThreeStateScore(ThreeStateScoreUnit ** list,int i,int j) { ThreeStateScoreUnit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ThreeStateScore(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ThreeStateScore which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ThreeStateScoreUnit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ThreeStateScore(ThreeStateScoreUnit ** list,int left,int right,int (*comp)(ThreeStateScoreUnit * ,ThreeStateScoreUnit * )) { int i,last; if( left >= right ) return; swap_ThreeStateScore(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ThreeStateScore (list,++last,i); } swap_ThreeStateScore (list,left,last); qsort_ThreeStateScore(list,left,last-1,comp); qsort_ThreeStateScore(list,last+1,right,comp); } /* Function: sort_ThreeStateScore(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ThreeStateScore * * * Arg: obj [UNKN ] Object containing list [ThreeStateScore *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ThreeStateScore(ThreeStateScore * obj,int (*comp)(ThreeStateScoreUnit *, ThreeStateScoreUnit *)) { qsort_ThreeStateScore(obj->unit,0,obj->len-1,comp); return; } /* Function: expand_ThreeStateScore(obj,len) * * Descrip: Really an internal function for add_ThreeStateScore * * * Arg: obj [UNKN ] Object which contains the list [ThreeStateScore *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ThreeStateScore(ThreeStateScore * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_ThreeStateScore called with no need"); return TRUE; } if( (obj->unit = (ThreeStateScoreUnit ** ) ckrealloc (obj->unit,sizeof(ThreeStateScoreUnit *)*len)) == NULL) { warn("ckrealloc failed for expand_ThreeStateScore, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_ThreeStateScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ThreeStateScore *] * Arg: add [OWNER] Object to add to the list [ThreeStateScoreUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ThreeStateScore(ThreeStateScore * obj,ThreeStateScoreUnit * add) { if( obj->len >= obj->maxlen) { if( expand_ThreeStateScore(obj,obj->len + ThreeStateScoreLISTLENGTH) == FALSE) return FALSE; } obj->unit[obj->len++]=add; return TRUE; } /* Function: flush_ThreeStateScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ThreeStateScore *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ThreeStateScore(ThreeStateScore * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->unit[i] != NULL) { free_ThreeStateScoreUnit(obj->unit[i]); obj->unit[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: ThreeStateScore_alloc_std(void) * * Descrip: Equivalent to ThreeStateScore_alloc_len(ThreeStateScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ ThreeStateScore * ThreeStateScore_alloc_std(void) { return ThreeStateScore_alloc_len(ThreeStateScoreLISTLENGTH); } /* Function: ThreeStateScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ ThreeStateScore * ThreeStateScore_alloc_len(int len) { ThreeStateScore * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = ThreeStateScore_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->unit = (ThreeStateScoreUnit ** ) ckcalloc (len,sizeof(ThreeStateScoreUnit *))) == NULL) { warn("Warning, ckcalloc failed in ThreeStateScore_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_ThreeStateScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ThreeStateScore *] * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ ThreeStateScore * hard_link_ThreeStateScore(ThreeStateScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a ThreeStateScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ThreeStateScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ ThreeStateScore * ThreeStateScore_alloc(void) { ThreeStateScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ThreeStateScore *) ckalloc (sizeof(ThreeStateScore))) == NULL) { warn("ThreeStateScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->unit = NULL; out->len = out->maxlen = 0; out->name = NULL; out->accession = NULL; return out; } /* Function: free_ThreeStateScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateScore *] * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ ThreeStateScore * free_ThreeStateScore(ThreeStateScore * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ThreeStateScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->unit != NULL) { for(i=0;ilen;i++) { if( obj->unit[i] != NULL) free_ThreeStateScoreUnit(obj->unit[i]); } ckfree(obj->unit); } if( obj->name != NULL) ckfree(obj->name); if( obj->accession != NULL) ckfree(obj->accession); ckfree(obj); return NULL; } /* Function: replace_name_ThreeStateModel(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateModel *] * Arg: name [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable name [boolean] * */ boolean replace_name_ThreeStateModel(ThreeStateModel * obj,char * name) { if( obj == NULL) { warn("In replacement function name for object ThreeStateModel, got a NULL object"); return FALSE; } obj->name = name; return TRUE; } /* Function: access_name_ThreeStateModel(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateModel *] * * Return [SOFT ] member variable name [char *] * */ char * access_name_ThreeStateModel(ThreeStateModel * obj) { if( obj == NULL) { warn("In accessor function name for object ThreeStateModel, got a NULL object"); return NULL; } return obj->name; } /* Function: access_unit_ThreeStateModel(obj,i) * * Descrip: Access members stored in the unit list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [ThreeStateModel *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [ThreeStateUnit *] * */ ThreeStateUnit * access_unit_ThreeStateModel(ThreeStateModel * obj,int i) { if( obj == NULL) { warn("In accessor function unit for object ThreeStateModel, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function unit for object ThreeStateModel, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->unit[i]; } /* Function: length_unit_ThreeStateModel(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [ThreeStateModel *] * * Return [UNKN ] length of the list [int] * */ int length_unit_ThreeStateModel(ThreeStateModel * obj) { if( obj == NULL) { warn("In length function unit for object ThreeStateModel, got a NULL object"); return -1; } return obj->len; } /* Function: replace_alphabet_ThreeStateModel(obj,alphabet) * * Descrip: Replace member variable alphabet * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateModel *] * Arg: alphabet [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable alphabet [boolean] * */ boolean replace_alphabet_ThreeStateModel(ThreeStateModel * obj,char * alphabet) { if( obj == NULL) { warn("In replacement function alphabet for object ThreeStateModel, got a NULL object"); return FALSE; } obj->alphabet = alphabet; return TRUE; } /* Function: access_alphabet_ThreeStateModel(obj) * * Descrip: Access member variable alphabet * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateModel *] * * Return [SOFT ] member variable alphabet [char *] * */ char * access_alphabet_ThreeStateModel(ThreeStateModel * obj) { if( obj == NULL) { warn("In accessor function alphabet for object ThreeStateModel, got a NULL object"); return NULL; } return obj->alphabet; } /* Function: replace_accession_ThreeStateModel(obj,accession) * * Descrip: Replace member variable accession * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateModel *] * Arg: accession [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable accession [boolean] * */ boolean replace_accession_ThreeStateModel(ThreeStateModel * obj,char * accession) { if( obj == NULL) { warn("In replacement function accession for object ThreeStateModel, got a NULL object"); return FALSE; } obj->accession = accession; return TRUE; } /* Function: access_accession_ThreeStateModel(obj) * * Descrip: Access member variable accession * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateModel *] * * Return [SOFT ] member variable accession [char *] * */ char * access_accession_ThreeStateModel(ThreeStateModel * obj) { if( obj == NULL) { warn("In accessor function accession for object ThreeStateModel, got a NULL object"); return NULL; } return obj->accession; } /* Function: replace_threshold_ThreeStateModel(obj,threshold) * * Descrip: Replace member variable threshold * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateModel *] * Arg: threshold [OWNER] New value of the variable [double] * * Return [SOFT ] member variable threshold [boolean] * */ boolean replace_threshold_ThreeStateModel(ThreeStateModel * obj,double threshold) { if( obj == NULL) { warn("In replacement function threshold for object ThreeStateModel, got a NULL object"); return FALSE; } obj->threshold = threshold; return TRUE; } /* Function: access_threshold_ThreeStateModel(obj) * * Descrip: Access member variable threshold * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateModel *] * * Return [SOFT ] member variable threshold [double] * */ double access_threshold_ThreeStateModel(ThreeStateModel * obj) { if( obj == NULL) { warn("In accessor function threshold for object ThreeStateModel, got a NULL object"); return 0; } return obj->threshold; } /* Function: replace_rm_ThreeStateModel(obj,rm) * * Descrip: Replace member variable rm * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateModel *] * Arg: rm [OWNER] New value of the variable [RandomModel *] * * Return [SOFT ] member variable rm [boolean] * */ boolean replace_rm_ThreeStateModel(ThreeStateModel * obj,RandomModel * rm) { if( obj == NULL) { warn("In replacement function rm for object ThreeStateModel, got a NULL object"); return FALSE; } obj->rm = rm; return TRUE; } /* Function: access_rm_ThreeStateModel(obj) * * Descrip: Access member variable rm * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateModel *] * * Return [SOFT ] member variable rm [RandomModel *] * */ RandomModel * access_rm_ThreeStateModel(ThreeStateModel * obj) { if( obj == NULL) { warn("In accessor function rm for object ThreeStateModel, got a NULL object"); return NULL; } return obj->rm; } /* Function: replace_display_char_ThreeStateUnit(obj,display_char) * * Descrip: Replace member variable display_char * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateUnit *] * Arg: display_char [OWNER] New value of the variable [char] * * Return [SOFT ] member variable display_char [boolean] * */ boolean replace_display_char_ThreeStateUnit(ThreeStateUnit * obj,char display_char) { if( obj == NULL) { warn("In replacement function display_char for object ThreeStateUnit, got a NULL object"); return FALSE; } obj->display_char = display_char; return TRUE; } /* Function: access_display_char_ThreeStateUnit(obj) * * Descrip: Access member variable display_char * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateUnit *] * * Return [SOFT ] member variable display_char [char] * */ char access_display_char_ThreeStateUnit(ThreeStateUnit * obj) { if( obj == NULL) { warn("In accessor function display_char for object ThreeStateUnit, got a NULL object"); return 'u'; } return obj->display_char; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/threestatemodel.h0000644000175000001440000007261510670453715017510 0ustar philippusers#ifndef DYNAMITEthreestatemodelHEADERFILE #define DYNAMITEthreestatemodelHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "randommodel.h" #define ThreeStateModelLISTLENGTH 128 #define ThreeStateScoreLISTLENGTH 128 enum tsm_trans_type { TSM_MATCH2MATCH = 0, TSM_MATCH2INSERT, TSM_MATCH2DELETE, TSM_INSERT2MATCH, TSM_INSERT2INSERT, TSM_INSERT2DELETE, TSM_DELETE2MATCH, TSM_DELETE2INSERT, TSM_DELETE2DELETE, TSM_START2MATCH, TSM_START2INSERT, TSM_START2DELETE, TSM_MATCH2END, TSM_INSERT2END, TSM_DELETE2END }; #define TRANSITION_LEN 15 #define BLANK_SCORE (-10000000) extern char * std_alphabet; #define ALPHABET_SIZE 26 typedef enum TSM_StartEndMode { TSM_unknown = 26, TSM_default, TSM_local, TSM_global, TSM_wing, TSM_endbiased } TSM_StartEndMode; /* Object ThreeStateUnit * * Descrip: This object is the probability version * of hte common unit to profile HMMs, ie * the match,insert,delete triple * * */ struct Wise2_ThreeStateUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability match_emission[ALPHABET_SIZE]; Probability insert_emission[ALPHABET_SIZE]; Probability transition[TRANSITION_LEN]; char display_char; } ; /* ThreeStateUnit defined */ #ifndef DYNAMITE_DEFINED_ThreeStateUnit typedef struct Wise2_ThreeStateUnit Wise2_ThreeStateUnit; #define ThreeStateUnit Wise2_ThreeStateUnit #define DYNAMITE_DEFINED_ThreeStateUnit #endif /* Object ThreeStateModel * * Descrip: This is profile-HMM object, similar to the * SAM and HMMer plan9 architecture. * * */ struct Wise2_ThreeStateModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; /* name of the model */ ThreeStateUnit ** unit; /* the actuall three state probs and emissions */ int len;/* len for above unit */ int maxlen; /* maxlen for above unit */ char * alphabet; /* alphabet used */ char * accession; /* accession number */ double threshold; /* bits threshold (if sensible) */ RandomModel * rm; /* Random model for the model: maybe NULL! */ } ; /* ThreeStateModel defined */ #ifndef DYNAMITE_DEFINED_ThreeStateModel typedef struct Wise2_ThreeStateModel Wise2_ThreeStateModel; #define ThreeStateModel Wise2_ThreeStateModel #define DYNAMITE_DEFINED_ThreeStateModel #endif /* Object ThreeStateScoreUnit * * Descrip: This is the Score (ie , log-odded) * version of the ThreeStateUnit * * */ struct Wise2_ThreeStateScoreUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score match[ALPHABET_SIZE]; Score insert[ALPHABET_SIZE]; Score trans[TRANSITION_LEN]; } ; /* ThreeStateScoreUnit defined */ #ifndef DYNAMITE_DEFINED_ThreeStateScoreUnit typedef struct Wise2_ThreeStateScoreUnit Wise2_ThreeStateScoreUnit; #define ThreeStateScoreUnit Wise2_ThreeStateScoreUnit #define DYNAMITE_DEFINED_ThreeStateScoreUnit #endif /* Object ThreeStateScore * * Descrip: This is hte score version of the * ThreeStateModel, ie this has its * emissions and transitions log-odded * * */ struct Wise2_ThreeStateScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ThreeStateScoreUnit ** unit; int len;/* len for above unit */ int maxlen; /* maxlen for above unit */ char * name; char * accession; } ; /* ThreeStateScore defined */ #ifndef DYNAMITE_DEFINED_ThreeStateScore typedef struct Wise2_ThreeStateScore Wise2_ThreeStateScore; #define ThreeStateScore Wise2_ThreeStateScore #define DYNAMITE_DEFINED_ThreeStateScore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: information_from_ThreeStateUnit(tsu,rm) * * Descrip: Gets the information content (K-L divergence) vs a background for a position * * * Arg: tsu [UNKN ] Undocumented argument [ThreeStateUnit *] * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_information_from_ThreeStateUnit(ThreeStateUnit * tsu,RandomModel * rm); #define information_from_ThreeStateUnit Wise2_information_from_ThreeStateUnit /* Function: threestatemodel_mode_from_string(mode) * * Descrip: gets out the mode from a string * * * Arg: mode [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_threestatemodel_mode_from_string(char * mode); #define threestatemodel_mode_from_string Wise2_threestatemodel_mode_from_string /* Function: set_startend_policy_ThreeStateModel(tsm,mode,wing_length,internal_bias) * * Descrip: Sets the start/end policy on the basis of the mode * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: mode [UNKN ] Undocumented argument [TSM_StartEndMode] * Arg: wing_length [UNKN ] Undocumented argument [int] * Arg: internal_bias [UNKN ] Undocumented argument [Probability] * */ void Wise2_set_startend_policy_ThreeStateModel(ThreeStateModel * tsm,TSM_StartEndMode mode,int wing_length,Probability internal_bias); #define set_startend_policy_ThreeStateModel Wise2_set_startend_policy_ThreeStateModel /* Function: force_endbias_model(tsm,startend,internal) * * Descrip: Makes start/end on probability and * internal another * * not probabilistically correct * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: startend [UNKN ] Undocumented argument [double] * Arg: internal [UNKN ] Undocumented argument [double] * */ void Wise2_force_endbias_model(ThreeStateModel * tsm,double startend,double internal); #define force_endbias_model Wise2_force_endbias_model /* Function: force_global_model(tsm,prob_into_model) * * Descrip: Makes start at position 0 and end at position end, * no other positions being valid * * * * Arg: tsm [UNKN ] ThreeStateModel to be 'forced' [ThreeStateModel *] * Arg: prob_into_model [UNKN ] Probability to start the model: for true global will be 1.0 [double] * */ void Wise2_force_global_model(ThreeStateModel * tsm,double prob_into_model) ; #define force_global_model Wise2_force_global_model /* Function: force_wing_local_model(tsm,terminus_prob,wing_length) * * Descrip: Places the balanace of the start probability * at the start and then the rest spread evenly * descending over the wing stretch of sequences * * Same with the end probability * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: terminus_prob [UNKN ] the amount of probability to put on the real start and end [double] * Arg: wing_length [UNKN ] the rest of the probability spread over this distance into the wing [int] * */ void Wise2_force_wing_local_model(ThreeStateModel * tsm,double terminus_prob,int wing_length); #define force_wing_local_model Wise2_force_wing_local_model /* Function: force_weighted_local_model(tsm,prob_into_model,ratio_start,ratio_end) * * Descrip: places the ratio of probability to start/end, * and then distributes the rest over the start/end * * * * Arg: tsm [UNKN ] ThreeStateModel to be 'forced' [ThreeStateModel *] * Arg: prob_into_model [UNKN ] Probability to start the model: for true global will be 1.0 [double] * Arg: ratio_start [UNKN ] ratio of prob to unit 0 to the rest (1.0 means all goes to start) [double] * Arg: ratio_end [UNKN ] ratio of prob to unit (last) to the rest (1.0 means all goes to the end) [double] * */ void Wise2_force_weighted_local_model(ThreeStateModel * tsm,double prob_into_model,double ratio_start,double ratio_end) ; #define force_weighted_local_model Wise2_force_weighted_local_model /* Function: force_hmmfs_ThreeStateModel(tsm) * * Descrip: places the probability at start end to precisely match * hmmfs code. * * * * Arg: tsm [UNKN ] ThreeStateModel to be 'forced' [ThreeStateModel *] * */ void Wise2_force_hmmfs_ThreeStateModel(ThreeStateModel * tsm); #define force_hmmfs_ThreeStateModel Wise2_force_hmmfs_ThreeStateModel /* Function: ThreeStateScore_from_ThreeStateModel(tsm) * * Descrip: Converts the three probability form to the score form. * * There is real complications to this due to the fact that the prob * model is a "push" model, that is MATCH2MATCH[i] means the match from i * to i+1, whereas the DP routines rely on a "pull" model, ie * MATCH2MATCH[i] is i-1 to i. * * This routines does the conversion from push to pull, essentially offsetting * the Match2 and Delete2 movements. * * * Arg: tsm [READ ] ThreeStateModel probability form [ThreeStateModel *] * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ ThreeStateScore * Wise2_ThreeStateScore_from_ThreeStateModel(ThreeStateModel * tsm); #define ThreeStateScore_from_ThreeStateModel Wise2_ThreeStateScore_from_ThreeStateModel /* Function: show_ThreeStateModel(tsm,ofp) * * Descrip: shows pretty ugly debugging type format. * * Pretty useless * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_ThreeStateModel(ThreeStateModel * tsm,FILE * ofp); #define show_ThreeStateModel Wise2_show_ThreeStateModel /* Function: pseudo_Protein_from_ThreeStateModel(tsm) * * Descrip: Makes a protein sequence out of the display characters. * Not very useful! * * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Wise2_pseudo_Protein_from_ThreeStateModel(ThreeStateModel * tsm); #define pseudo_Protein_from_ThreeStateModel Wise2_pseudo_Protein_from_ThreeStateModel /* Function: ThreeStateModel_from_half_bit_Sequence(pro,mat,rm,gap,ext) * * Descrip: Makes a local three-state-model from a sequence. this is scary * hackery, assumming that the matrix is half-bits and normalising in a * *very* wrong way to get "probabilities" out. * * Works though * * * Arg: pro [READ ] protein sequence [Protein *] * Arg: mat [READ ] comparison matrix to use [CompMat *] * Arg: rm [READ ] random model which you assumme the matrix was built with [RandomModel *] * Arg: gap [READ ] gap open penalty [int] * Arg: ext [READ ] gap ext penalty [int] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_ThreeStateModel_from_half_bit_Sequence(Protein * pro,CompMat * mat,RandomModel * rm,int gap,int ext); #define ThreeStateModel_from_half_bit_Sequence Wise2_ThreeStateModel_from_half_bit_Sequence /* Function: global_ThreeStateModel_from_half_bit_Sequence(pro,mat,rm,gap,ext) * * Descrip: Makes a global three-state-model from a sequence. * Like the local version, this is scary hackery, assumming * that the matrix is half-bits and normalising in a *very* * wrong way to get "probabilities" out. * * Works though * * * Arg: pro [READ ] protein sequence [Protein *] * Arg: mat [READ ] comparison matrix to use [CompMat *] * Arg: rm [READ ] random model which you assumme the matrix was built with [RandomModel *] * Arg: gap [READ ] gap open penalty [int] * Arg: ext [READ ] gap ext penalty [int] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_global_ThreeStateModel_from_half_bit_Sequence(Protein * pro,CompMat * mat,RandomModel * rm,int gap,int ext); #define global_ThreeStateModel_from_half_bit_Sequence Wise2_global_ThreeStateModel_from_half_bit_Sequence /* Function: display_char_in_ThreeStateModel(tsm) * * Descrip: Makes the display chars in the tsm come from * the most likely amino acid in the match position * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * */ void Wise2_display_char_in_ThreeStateModel(ThreeStateModel * tsm); #define display_char_in_ThreeStateModel Wise2_display_char_in_ThreeStateModel /* Function: fold_RandomModel_into_ThreeStateModel(tsm,rm) * * Descrip: divides the emission and insertion scores * by the random model for use in log-odd * implementations * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * */ void Wise2_fold_RandomModel_into_ThreeStateModel(ThreeStateModel * tsm,RandomModel * rm); #define fold_RandomModel_into_ThreeStateModel Wise2_fold_RandomModel_into_ThreeStateModel /* Function: add_sensible_start_end_global_for_HMMer(tsm) * * Descrip: added start 0.5, 0.25,0.25 for hmmls type * * Deprecated * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * */ void Wise2_add_sensible_start_end_global_for_HMMer(ThreeStateModel * tsm); #define add_sensible_start_end_global_for_HMMer Wise2_add_sensible_start_end_global_for_HMMer /* Function: add_sensible_start_end_looping_for_HMMer(tsm,loop) * * Descrip: adds start/end for loop probabilities coming * in * * Deprecated * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: loop [UNKN ] Undocumented argument [Probability] * */ void Wise2_add_sensible_start_end_looping_for_HMMer(ThreeStateModel * tsm,Probability loop); #define add_sensible_start_end_looping_for_HMMer Wise2_add_sensible_start_end_looping_for_HMMer /* Function: write_HMF_ThreeStateModel(tsm,ofp) * * Descrip: writes the HMF format * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_write_HMF_ThreeStateModel(ThreeStateModel * tsm,FILE * ofp); #define write_HMF_ThreeStateModel Wise2_write_HMF_ThreeStateModel /* Function: read_HMF_ThreeStateModel(ifp) * * Descrip: reads the HMF format. Leaves the file ready * to read the next format * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_read_HMF_ThreeStateModel(FILE * ifp); #define read_HMF_ThreeStateModel Wise2_read_HMF_ThreeStateModel /* Function: write_HMMer_1_7_ascii_ThreeStateModel(tsm,ofp) * * Descrip: writes a HMMer version 1.7 (also ok with 1.8) file * * * Arg: tsm [UNKN ] Undocumented argument [ThreeStateModel *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_write_HMMer_1_7_ascii_ThreeStateModel(ThreeStateModel * tsm,FILE * ofp); #define write_HMMer_1_7_ascii_ThreeStateModel Wise2_write_HMMer_1_7_ascii_ThreeStateModel /* Function: read_HMMer_1_7_ascii_file(filename) * * Descrip: reads a HMMer ascii version 1.7 (1.8) file from filename. * * * * Arg: filename [UNKN ] the name fo the hmmer file [char *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_read_HMMer_1_7_ascii_file(char * filename); #define read_HMMer_1_7_ascii_file Wise2_read_HMMer_1_7_ascii_file /* Function: read_HMMer_1_7_ascii(ifp) * * Descrip: Basic function to read HMMer version 1.7(1.8) files. * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_read_HMMer_1_7_ascii(FILE * ifp) ; #define read_HMMer_1_7_ascii Wise2_read_HMMer_1_7_ascii /* Function: hard_link_ThreeStateUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ThreeStateUnit *] * * Return [UNKN ] Undocumented return value [ThreeStateUnit *] * */ ThreeStateUnit * Wise2_hard_link_ThreeStateUnit(ThreeStateUnit * obj); #define hard_link_ThreeStateUnit Wise2_hard_link_ThreeStateUnit /* Function: ThreeStateUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateUnit *] * */ ThreeStateUnit * Wise2_ThreeStateUnit_alloc(void); #define ThreeStateUnit_alloc Wise2_ThreeStateUnit_alloc /* Function: free_ThreeStateUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateUnit *] * * Return [UNKN ] Undocumented return value [ThreeStateUnit *] * */ ThreeStateUnit * Wise2_free_ThreeStateUnit(ThreeStateUnit * obj); #define free_ThreeStateUnit Wise2_free_ThreeStateUnit /* Function: add_ThreeStateModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ThreeStateModel *] * Arg: add [OWNER] Object to add to the list [ThreeStateUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_ThreeStateModel(ThreeStateModel * obj,ThreeStateUnit * add); #define add_ThreeStateModel Wise2_add_ThreeStateModel /* Function: flush_ThreeStateModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ThreeStateModel *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_ThreeStateModel(ThreeStateModel * obj); #define flush_ThreeStateModel Wise2_flush_ThreeStateModel /* Function: ThreeStateModel_alloc_std(void) * * Descrip: Equivalent to ThreeStateModel_alloc_len(ThreeStateModelLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_ThreeStateModel_alloc_std(void); #define ThreeStateModel_alloc_std Wise2_ThreeStateModel_alloc_std /* Function: ThreeStateModel_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_ThreeStateModel_alloc_len(int len); #define ThreeStateModel_alloc_len Wise2_ThreeStateModel_alloc_len /* Function: hard_link_ThreeStateModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ThreeStateModel *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_hard_link_ThreeStateModel(ThreeStateModel * obj); #define hard_link_ThreeStateModel Wise2_hard_link_ThreeStateModel /* Function: ThreeStateModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_ThreeStateModel_alloc(void); #define ThreeStateModel_alloc Wise2_ThreeStateModel_alloc /* Function: free_ThreeStateModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateModel *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_free_ThreeStateModel(ThreeStateModel * obj); #define free_ThreeStateModel Wise2_free_ThreeStateModel /* Function: hard_link_ThreeStateScoreUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ThreeStateScoreUnit *] * * Return [UNKN ] Undocumented return value [ThreeStateScoreUnit *] * */ ThreeStateScoreUnit * Wise2_hard_link_ThreeStateScoreUnit(ThreeStateScoreUnit * obj); #define hard_link_ThreeStateScoreUnit Wise2_hard_link_ThreeStateScoreUnit /* Function: ThreeStateScoreUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateScoreUnit *] * */ ThreeStateScoreUnit * Wise2_ThreeStateScoreUnit_alloc(void); #define ThreeStateScoreUnit_alloc Wise2_ThreeStateScoreUnit_alloc /* Function: free_ThreeStateScoreUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateScoreUnit *] * * Return [UNKN ] Undocumented return value [ThreeStateScoreUnit *] * */ ThreeStateScoreUnit * Wise2_free_ThreeStateScoreUnit(ThreeStateScoreUnit * obj); #define free_ThreeStateScoreUnit Wise2_free_ThreeStateScoreUnit /* Function: add_ThreeStateScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ThreeStateScore *] * Arg: add [OWNER] Object to add to the list [ThreeStateScoreUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_ThreeStateScore(ThreeStateScore * obj,ThreeStateScoreUnit * add); #define add_ThreeStateScore Wise2_add_ThreeStateScore /* Function: flush_ThreeStateScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ThreeStateScore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_ThreeStateScore(ThreeStateScore * obj); #define flush_ThreeStateScore Wise2_flush_ThreeStateScore /* Function: ThreeStateScore_alloc_std(void) * * Descrip: Equivalent to ThreeStateScore_alloc_len(ThreeStateScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ ThreeStateScore * Wise2_ThreeStateScore_alloc_std(void); #define ThreeStateScore_alloc_std Wise2_ThreeStateScore_alloc_std /* Function: ThreeStateScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ ThreeStateScore * Wise2_ThreeStateScore_alloc_len(int len); #define ThreeStateScore_alloc_len Wise2_ThreeStateScore_alloc_len /* Function: hard_link_ThreeStateScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ThreeStateScore *] * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ ThreeStateScore * Wise2_hard_link_ThreeStateScore(ThreeStateScore * obj); #define hard_link_ThreeStateScore Wise2_hard_link_ThreeStateScore /* Function: ThreeStateScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ ThreeStateScore * Wise2_ThreeStateScore_alloc(void); #define ThreeStateScore_alloc Wise2_ThreeStateScore_alloc /* Function: free_ThreeStateScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateScore *] * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ ThreeStateScore * Wise2_free_ThreeStateScore(ThreeStateScore * obj); #define free_ThreeStateScore Wise2_free_ThreeStateScore /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_name_ThreeStateModel(ThreeStateModel * obj,char * name); #define replace_name_ThreeStateModel Wise2_replace_name_ThreeStateModel char * Wise2_access_name_ThreeStateModel(ThreeStateModel * obj); #define access_name_ThreeStateModel Wise2_access_name_ThreeStateModel int Wise2_length_unit_ThreeStateModel(ThreeStateModel * obj); #define length_unit_ThreeStateModel Wise2_length_unit_ThreeStateModel boolean Wise2_replace_alphabet_ThreeStateModel(ThreeStateModel * obj,char * alphabet); #define replace_alphabet_ThreeStateModel Wise2_replace_alphabet_ThreeStateModel char Wise2_access_display_char_ThreeStateUnit(ThreeStateUnit * obj); #define access_display_char_ThreeStateUnit Wise2_access_display_char_ThreeStateUnit char * Wise2_access_alphabet_ThreeStateModel(ThreeStateModel * obj); #define access_alphabet_ThreeStateModel Wise2_access_alphabet_ThreeStateModel boolean Wise2_replace_display_char_ThreeStateUnit(ThreeStateUnit * obj,char display_char); #define replace_display_char_ThreeStateUnit Wise2_replace_display_char_ThreeStateUnit boolean Wise2_replace_accession_ThreeStateModel(ThreeStateModel * obj,char * accession); #define replace_accession_ThreeStateModel Wise2_replace_accession_ThreeStateModel RandomModel * Wise2_access_rm_ThreeStateModel(ThreeStateModel * obj); #define access_rm_ThreeStateModel Wise2_access_rm_ThreeStateModel char * Wise2_access_accession_ThreeStateModel(ThreeStateModel * obj); #define access_accession_ThreeStateModel Wise2_access_accession_ThreeStateModel ThreeStateUnit * Wise2_access_unit_ThreeStateModel(ThreeStateModel * obj,int i); #define access_unit_ThreeStateModel Wise2_access_unit_ThreeStateModel boolean Wise2_replace_threshold_ThreeStateModel(ThreeStateModel * obj,double threshold); #define replace_threshold_ThreeStateModel Wise2_replace_threshold_ThreeStateModel boolean Wise2_replace_rm_ThreeStateModel(ThreeStateModel * obj,RandomModel * rm); #define replace_rm_ThreeStateModel Wise2_replace_rm_ThreeStateModel double Wise2_access_threshold_ThreeStateModel(ThreeStateModel * obj); #define access_threshold_ThreeStateModel Wise2_access_threshold_ThreeStateModel ThreeStateScoreUnit * Wise2_ThreeStateScoreUnit_from_ThreeStateUnit(ThreeStateUnit * prev,ThreeStateUnit * tsu); #define ThreeStateScoreUnit_from_ThreeStateUnit Wise2_ThreeStateScoreUnit_from_ThreeStateUnit void Wise2_show_ThreeStateUnit(ThreeStateUnit * tsu,FILE * ofp); #define show_ThreeStateUnit Wise2_show_ThreeStateUnit ThreeStateUnit * Wise2_ThreeStateUnit_from_half_bit_aminoacid(char aa,CompMat * mat,RandomModel * rm,int gap,int ext); #define ThreeStateUnit_from_half_bit_aminoacid Wise2_ThreeStateUnit_from_half_bit_aminoacid char Wise2_display_char_for_ThreeStateUnit(ThreeStateUnit * tsu) ; #define display_char_for_ThreeStateUnit Wise2_display_char_for_ThreeStateUnit void Wise2_write_HMF_ThreeStateUnit(ThreeStateUnit * tsu,FILE * ofp); #define write_HMF_ThreeStateUnit Wise2_write_HMF_ThreeStateUnit ThreeStateUnit * Wise2_read_HMF_ThreeStateUnit(char * line,FILE * ifp); #define read_HMF_ThreeStateUnit Wise2_read_HMF_ThreeStateUnit void Wise2_write_HMMer_1_7_ascii_ThreeStateUnit(ThreeStateUnit * tsu,int no,FILE * ofp); #define write_HMMer_1_7_ascii_ThreeStateUnit Wise2_write_HMMer_1_7_ascii_ThreeStateUnit ThreeStateModel * Wise2_convert_push_model_to_pull_model(ThreeStateModel * tsm); #define convert_push_model_to_pull_model Wise2_convert_push_model_to_pull_model ThreeStateUnit * Wise2_convert_push_unit_to_pull_unit(ThreeStateUnit * prev,ThreeStateUnit * this); #define convert_push_unit_to_pull_unit Wise2_convert_push_unit_to_pull_unit ThreeStateUnit * Wise2_read_HMMer_1_7_ThreeStateUnit(char * alphabet,FILE * ifp) ; #define read_HMMer_1_7_ThreeStateUnit Wise2_read_HMMer_1_7_ThreeStateUnit ThreeStateUnit * Wise2_blank_ThreeStateUnit(void); #define blank_ThreeStateUnit Wise2_blank_ThreeStateUnit void Wise2_swap_ThreeStateModel(ThreeStateUnit ** list,int i,int j) ; #define swap_ThreeStateModel Wise2_swap_ThreeStateModel void Wise2_qsort_ThreeStateModel(ThreeStateUnit ** list,int left,int right,int (*comp)(ThreeStateUnit * ,ThreeStateUnit * )); #define qsort_ThreeStateModel Wise2_qsort_ThreeStateModel void Wise2_sort_ThreeStateModel(ThreeStateModel * obj,int (*comp)(ThreeStateUnit *, ThreeStateUnit *)); #define sort_ThreeStateModel Wise2_sort_ThreeStateModel boolean Wise2_expand_ThreeStateModel(ThreeStateModel * obj,int len); #define expand_ThreeStateModel Wise2_expand_ThreeStateModel void Wise2_swap_ThreeStateScore(ThreeStateScoreUnit ** list,int i,int j) ; #define swap_ThreeStateScore Wise2_swap_ThreeStateScore void Wise2_qsort_ThreeStateScore(ThreeStateScoreUnit ** list,int left,int right,int (*comp)(ThreeStateScoreUnit * ,ThreeStateScoreUnit * )); #define qsort_ThreeStateScore Wise2_qsort_ThreeStateScore void Wise2_sort_ThreeStateScore(ThreeStateScore * obj,int (*comp)(ThreeStateScoreUnit *, ThreeStateScoreUnit *)); #define sort_ThreeStateScore Wise2_sort_ThreeStateScore boolean Wise2_expand_ThreeStateScore(ThreeStateScore * obj,int len); #define expand_ThreeStateScore Wise2_expand_ThreeStateScore #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/proteinsw.c0000644000175000001440000040563710670453715016350 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "proteinsw.h" # line 5 "proteinsw.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define START 0 #define END 1 #define ProteinSW_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*3)+STATE][i+1] #define ProteinSW_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define ProteinSW_READ_OFF_ERROR -3 #define ProteinSW_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*3)+STATE] #define ProteinSW_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define ProteinSW_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define ProteinSW_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_ProteinSW(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_ProteinSW(ProteinSW * mat) { ProteinSW_access_func_holder holder; holder.access_main = ProteinSW_shatter_access_main; holder.access_special = ProteinSW_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_ProteinSW(mat,holder); } /* Function: ProteinSW_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ProteinSW_shatter_access_main(ProteinSW * mat,int i,int j,int state) { return ProteinSW_SHATTER_MATRIX(mat,i,j,state); } /* Function: ProteinSW_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ProteinSW_shatter_access_special(ProteinSW * mat,int i,int j,int state) { return ProteinSW_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_ProteinSW(mat,dpenv) * * Descrip: This function calculates the ProteinSW matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [ProteinSW *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_ProteinSW(ProteinSW * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("ProteinSW Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_1[MATCH] + 0; /* From state INSERT to state MATCH */ temp = SIG_1_1[INSERT] + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_1[DELETE] + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = ProteinSW_SHATTER_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinSW_SHATTER_SPECIAL(mat,i,j,END) ) { ProteinSW_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_1[MATCH] + mat->gap; /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ SIG_0_0[INSERT] = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->gap; /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_ProteinSW(dbsi,out,querydb,targetdb,comp,gap,ext) * * Descrip: This function makes a database search of ProteinSW * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [ProteinDB*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * Arg: comp [UNKN ] Undocumented argument [CompMat*] * Arg: gap [UNKN ] Undocumented argument [int] * Arg: ext [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_ProteinSW(DBSearchImpl * dbsi,Hscore * out,ProteinDB* querydb,ProteinDB* targetdb ,CompMat* comp,int gap,int ext) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_ProteinSW * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_ProteinSW. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_ProteinSW. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for ProteinSW, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_ProteinSW(out,querydb, targetdb ,comp,gap,ext); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_ProteinSW *) ckalloc(sizeof(struct thread_pool_holder_ProteinSW)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->comp = comp; holder->gap = gap; holder->ext = ext; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_ProteinSW,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for ProteinSW"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from ProteinSW",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_ProteinSW(ptr) * * Descrip: Infinite loop code foreach thread for ProteinSW * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_ProteinSW(void * ptr) { struct thread_pool_holder_ProteinSW * holder; int db_status; int score; DataScore * ds; ComplexSequence* query; ComplexSequence* target; holder = (struct thread_pool_holder_ProteinSW *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for ProteinSW"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for ProteinSW"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_ProteinDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in ProteinSW search"); } query = hard_link_ComplexSequence(holder->query); /* get query information into datascore */ dataentry_add_ProteinDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_ProteinDB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_ProteinDB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching ProteinSW, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_ProteinDB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_ComplexSequence(holder->query); /* get the next query object for the next thread */ holder->query = reload_ProteinDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching ProteinSW, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_ProteinDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for ProteinSW"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for ProteinSW"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_ProteinDB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_ProteinSW(query, target ,holder->comp,holder->gap,holder->ext); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for ProteinSW"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for ProteinSW"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for ProteinSW"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_ComplexSequence(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for ProteinSW"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_ProteinSW(out,querydb,targetdb,comp,gap,ext) * * Descrip: This function makes a database search of ProteinSW * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [ProteinDB*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * Arg: comp [UNKN ] Undocumented argument [CompMat*] * Arg: gap [UNKN ] Undocumented argument [int] * Arg: ext [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_ProteinSW(Hscore * out,ProteinDB* querydb,ProteinDB* targetdb ,CompMat* comp,int gap,int ext) { ComplexSequence* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_ProteinDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching ProteinSW, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_ProteinDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching ProteinSW, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_ProteinSW(query, target , comp, gap, ext); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("ProteinSW search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_ProteinDB(ds->query,query,querydb); dataentry_add_ProteinDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_ProteinDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching ProteinSW, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_ProteinDB(target,targetdb); query = reload_ProteinDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching ProteinSW, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_ProteinDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_ProteinSW(query,target,comp,gap,ext) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_ProteinSW_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: gap [UNKN ] Resource [int] * Arg: ext [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_ProteinSW(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int gap,int ext) { int bestscore = NEGI; int i; int j; int k; ProteinSW * mat; mat = allocate_ProteinSW_only(query, target , comp, gap, ext); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 3,2,2)) == NULL) { warn("Score only matrix for ProteinSW cannot be allocated, (asking for 1 by %d cells)",mat->leni*3); mat = free_ProteinSW(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) ProteinSW_VSMALL_MATRIX(mat,i,j,k) = NEGI; } ProteinSW_VSMALL_SPECIAL(mat,i,j,START) = 0; ProteinSW_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = ProteinSW_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = ProteinSW_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ProteinSW_VSMALL_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = ProteinSW_VSMALL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); ProteinSW_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinSW_VSMALL_SPECIAL(mat,i,j,END) ) { ProteinSW_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ProteinSW_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; /* From state INSERT to state INSERT */ temp = ProteinSW_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ ProteinSW_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ProteinSW_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; /* From state DELETE to state DELETE */ temp = ProteinSW_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ProteinSW_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < ProteinSW_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = ProteinSW_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_ProteinSW(mat); return bestscore; } /* Function: PackAln_bestmemory_ProteinSW(query,target,comp,gap,ext,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_ProteinSW * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: gap [UNKN ] Resource [int] * Arg: ext [UNKN ] Resource [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_ProteinSW(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int gap,int ext,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; ProteinSW * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->seq->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_ProteinSW(query, target , comp, gap, ext,dpri)) == NULL ) { warn("Unable to allocate large ProteinSW version"); return NULL; } calculate_dpenv_ProteinSW(mat,dpenv); out = PackAln_read_Expl_ProteinSW(mat); } else { mat = allocate_ProteinSW_only(query, target , comp, gap, ext); calculate_shatter_ProteinSW(mat,dpenv); out = PackAln_read_Shatter_ProteinSW(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_ProteinSW(query, target , comp, gap, ext)) == NULL ) { warn("Unable to allocate small ProteinSW version"); return NULL; } out = PackAln_calculate_Small_ProteinSW(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_ProteinSW(query, target , comp, gap, ext,dpri)) == NULL ) { warn("Unable to allocate large ProteinSW version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_ProteinSW(mat); out = PackAln_read_Expl_ProteinSW(mat); } } } mat = free_ProteinSW(mat); return out; } /* Function: allocate_ProteinSW_only(query,target,comp,gap,ext) * * Descrip: This function only allocates the ProteinSW structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: gap [UNKN ] Resource [int] * Arg: ext [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [ProteinSW *] * */ ProteinSW * allocate_ProteinSW_only(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int gap,int ext) { ProteinSW * out; if((out= ProteinSW_alloc()) == NULL) { warn("Allocation of basic ProteinSW structure failed..."); return NULL; } out->query = query; out->target = target; out->comp = comp; out->gap = gap; out->ext = ext; out->leni = query->seq->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_ProteinSW(query,target,comp,gap,ext,dpri) * * Descrip: This function allocates the ProteinSW structure * and the basematrix area for explicit memory implementations * It calls /allocate_ProteinSW_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: gap [UNKN ] Resource [int] * Arg: ext [UNKN ] Resource [int] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [ProteinSW *] * */ ProteinSW * allocate_Expl_ProteinSW(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int gap,int ext,DPRunImpl * dpri) { ProteinSW * out; out = allocate_ProteinSW_only(query, target , comp, gap, ext); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*3,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix ProteinSW cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_ProteinSW(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_ProteinSW(out); return out; } /* Function: init_ProteinSW(mat) * * Descrip: This function initates ProteinSW matrix when in explicit mode * Called in /allocate_Expl_ProteinSW * * * Arg: mat [UNKN ] ProteinSW which contains explicit basematrix memory [ProteinSW *] * */ void init_ProteinSW(ProteinSW * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->seq->len;i++) { for(j= (-1);j<2;j++) { ProteinSW_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; ProteinSW_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; ProteinSW_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j= (-1);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { ProteinSW_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; ProteinSW_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; ProteinSW_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } ProteinSW_EXPL_SPECIAL(mat,i,j,START) = 0; ProteinSW_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_ProteinSW(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by ProteinSW * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * */ void recalculate_PackAln_ProteinSW(PackAln * pal,ProteinSW * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = 0 + (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = 0 + (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); continue; } if( offi == 1 && offj == 1 && prev->state == DELETE ) { pau->score = 0 + (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); continue; } if( offj == 1 && prev->state == (START+3) ) { pau->score = 0 + (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = mat->gap + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->ext + (0); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->gap + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->ext + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+3) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define ProteinSW_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*3+state]) #define ProteinSW_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*3+state]) #define ProteinSW_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define ProteinSW_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define ProteinSW_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*3 + state]) #define ProteinSW_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define ProteinSW_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define ProteinSW_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define ProteinSW_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_ProteinSW(query,target,comp,gap,ext) * * Descrip: This function allocates the ProteinSW structure * and the basematrix area for a small memory implementations * It calls /allocate_ProteinSW_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: gap [UNKN ] Resource [int] * Arg: ext [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [ProteinSW *] * */ #define ProteinSW_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) ProteinSW * allocate_Small_ProteinSW(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int gap,int ext) { ProteinSW * out; out = allocate_ProteinSW_only(query, target , comp, gap, ext); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 3,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix ProteinSW cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_ProteinSW(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_ProteinSW(mat,dpenv) * * Descrip: This function calculates an alignment for ProteinSW structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_ProteinSW * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_ProteinSW * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_ProteinSW(ProteinSW * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for ProteinSW due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_ProteinSW(mat,dpenv); score = start_end_find_end_ProteinSW(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_ProteinSW(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_ProteinSW(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == ProteinSW_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_ProteinSW(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 3; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_ProteinSW(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_ProteinSW(mat) * * Descrip: This function calculates an alignment for ProteinSW structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_ProteinSW * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_ProteinSW * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_ProteinSW * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_ProteinSW(ProteinSW * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_ProteinSW(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_ProteinSW(mat); return out; } /* Function: AlnRangeSet_from_ProteinSW(mat) * * Descrip: This function reads off a start/end structure * for ProteinSW structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_ProteinSW * If you have not calculated the matrix use * /AlnRange_calculate_Small_ProteinSW * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_ProteinSW(ProteinSW * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_ProteinSW"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_ProteinSW(mat,&jpos); state = END; while( (temp = AlnRange_build_ProteinSW(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_ProteinSW(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_ProteinSW * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_ProteinSW(ProteinSW * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_ProteinSW"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_ProteinSW(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_ProteinSW alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = ProteinSW_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_ProteinSW(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == ProteinSW_READ_OFF_ERROR) { warn("In AlnRange_build_ProteinSW alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = ProteinSW_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_ProteinSW(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_ProteinSW(ProteinSW * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_ProteinSW(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == ProteinSW_READ_OFF_ERROR) { warn("In ProteinSW hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In ProteinSW hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In ProteinSW hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_ProteinSW(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_ProteinSW(ProteinSW * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = ProteinSW_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In ProteinSW matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = ProteinSW_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Not allowing special sources.. skipping START */ temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == ProteinSW_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinSW_HIDDEN_MATRIX(mat,i-1,j-1,DELETE); } return ProteinSW_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE); } temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == ProteinSW_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinSW_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return ProteinSW_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == ProteinSW_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinSW_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return ProteinSW_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in ProteinSW read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->ext) - (0); if( temp == ProteinSW_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinSW_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return ProteinSW_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gap) - (0); if( temp == ProteinSW_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinSW_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return ProteinSW_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in ProteinSW read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->ext) - (0); if( temp == ProteinSW_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinSW_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return ProteinSW_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->gap) - (0); if( temp == ProteinSW_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ProteinSW_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return ProteinSW_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in ProteinSW read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in ProteinSW read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_ProteinSW(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_ProteinSW(ProteinSW * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > ProteinSW_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_ProteinSW(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == ProteinSW_READ_OFF_ERROR) { warn("In special strip read ProteinSW, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < ProteinSW_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read ProteinSW, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_ProteinSW(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_ProteinSW(ProteinSW * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = ProteinSW_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for ProteinSW, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In ProteinSW matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = ProteinSW_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source MATCH is not a special */ default: warn("Major problem (!) - in ProteinSW special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_ProteinSW(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_ProteinSW(ProteinSW * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = ProteinSW_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In ProteinSW matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == ProteinSW_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - ProteinSW_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return ProteinSW_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in ProteinSW matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in ProteinSW matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Source DELETE is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in ProteinSW matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in ProteinSW read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_ProteinSW(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_ProteinSW(ProteinSW * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_ProteinSW(mat,starti,startj,stopi,stopj); ProteinSW_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ProteinSW_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; ProteinSW_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; ProteinSW_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = ProteinSW_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = ProteinSW_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ProteinSW_HIDDEN_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); ProteinSW_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ProteinSW_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; /* From state INSERT to state INSERT */ temp = ProteinSW_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ ProteinSW_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ProteinSW_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; /* From state DELETE to state DELETE */ temp = ProteinSW_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ProteinSW_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } } return; } /* Function: init_hidden_ProteinSW(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_ProteinSW(ProteinSW * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { ProteinSW_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; ProteinSW_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; ProteinSW_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; } } return; } /* Function: full_dc_ProteinSW(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_ProteinSW * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_ProteinSW to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [ProteinSW *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_ProteinSW(ProteinSW * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_ProteinSW"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_ProteinSW(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_ProteinSW(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_ProteinSW(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for ProteinSW, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= ProteinSW_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= ProteinSW_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = ProteinSW_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_ProteinSW(mat,ProteinSW_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),ProteinSW_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),ProteinSW_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_ProteinSW(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_ProteinSW(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_ProteinSW(ProteinSW * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_ProteinSW(mat); ProteinSW_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_ProteinSW(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_ProteinSW(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_ProteinSW(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_ProteinSW(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_ProteinSW(ProteinSW * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ProteinSW_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); ProteinSW_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); ProteinSW_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; if( j - 1 <= mergej) { ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } temp = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } temp = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } } /* Add any movement independant score */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); ProteinSW_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = ProteinSW_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; if( j - 1 <= mergej) { ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } temp = ProteinSW_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->ext; if( temp > score) { score = temp; if( j - 1 <= mergej) { ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } /* Add any movement independant score */ ProteinSW_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; if( j - 0 <= mergej) { ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->ext; if( temp > score) { score = temp; if( j - 0 <= mergej) { ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ ProteinSW_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_ProteinSW(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_ProteinSW(ProteinSW * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ProteinSW_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ProteinSW_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ProteinSW_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); /* From state INSERT to state MATCH */ temp = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* From state DELETE to state MATCH */ temp = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); ProteinSW_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ProteinSW_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); /* From state INSERT to state INSERT */ temp = ProteinSW_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->ext; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ ProteinSW_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state DELETE to state DELETE */ temp = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->ext; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ProteinSW_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ProteinSW_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_ProteinSW(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_ProteinSW(ProteinSW * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ProteinSW_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ProteinSW_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ProteinSW_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); ProteinSW_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ProteinSW_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; /* From state INSERT to state INSERT */ temp = ProteinSW_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ ProteinSW_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; /* From state DELETE to state DELETE */ temp = ProteinSW_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ProteinSW_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_ProteinSW(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * */ } void init_dc_ProteinSW(ProteinSW * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { ProteinSW_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ProteinSW_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ProteinSW_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; for(k=0;k<7;k++) { ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); } } } return; } /* Function: start_end_find_end_ProteinSW(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [ProteinSW *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_ProteinSW(ProteinSW * mat,int * endj) { register int j; register int max; register int maxj; max = ProteinSW_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( ProteinSW_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = ProteinSW_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_ProteinSW(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [ProteinSW] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_ProteinSW(ProteinSW *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->seq->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jcomp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); /* assign local shadown pointer */ localsp = &(ProteinSW_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); /* From state INSERT to state MATCH */ temp = ProteinSW_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0 +(CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ProteinSW_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* From state DELETE to state MATCH */ temp = ProteinSW_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0 +(CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ProteinSW_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,0)); } /* From state START to state MATCH */ temp = ProteinSW_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + 0 + (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ ProteinSW_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) ProteinSW_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinSW_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { ProteinSW_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) ProteinSW_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = ProteinSW_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); ProteinSW_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = ProteinSW_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); ProteinSW_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; ProteinSW_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; ProteinSW_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ProteinSW_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gap + (0); /* assign local shadown pointer */ localsp = &(ProteinSW_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); /* From state INSERT to state INSERT */ temp = ProteinSW_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->ext +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ProteinSW_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ ProteinSW_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) ProteinSW_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ProteinSW_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->gap + (0); /* assign local shadown pointer */ localsp = &(ProteinSW_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state DELETE to state DELETE */ temp = ProteinSW_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->ext +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ProteinSW_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ ProteinSW_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) ProteinSW_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_ProteinSW(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * */ void init_start_end_linear_ProteinSW(ProteinSW * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { ProteinSW_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); ProteinSW_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); ProteinSW_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; ProteinSW_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); } } for(j=(-1);jtarget->seq->len;j++) { ProteinSW_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; ProteinSW_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; ProteinSW_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_ProteinSW(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_ProteinSW(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_ProteinSW(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "SEQUENCE","INSERT","END" }; /* Function: AlnConvertSet_ProteinSW(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "SEQUENCE","INSERT","END" }; AlnConvertSet * AlnConvertSet_ProteinSW(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; return out; } /* Function: PackAln_read_Expl_ProteinSW(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_ProteinSW(ProteinSW * mat) { ProteinSW_access_func_holder holder; holder.access_main = ProteinSW_explicit_access_main; holder.access_special = ProteinSW_explicit_access_special; return PackAln_read_generic_ProteinSW(mat,holder); } /* Function: ProteinSW_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ProteinSW_explicit_access_main(ProteinSW * mat,int i,int j,int state) { return ProteinSW_EXPL_MATRIX(mat,i,j,state); } /* Function: ProteinSW_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ProteinSW_explicit_access_special(ProteinSW * mat,int i,int j,int state) { return ProteinSW_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_ProteinSW(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: h [UNKN ] Undocumented argument [ProteinSW_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_ProteinSW(ProteinSW * mat,ProteinSW_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_ProteinSW(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in ProteinSW_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_ProteinSW(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_ProteinSW(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == ProteinSW_READ_OFF_ERROR || j == ProteinSW_READ_OFF_ERROR || state == ProteinSW_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in ProteinSW_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_ProteinSW(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [ProteinSW_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_ProteinSW(ProteinSW * mat,int * ri,int * rj,int * state,boolean * isspecial,ProteinSW_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: ProteinSW_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void ProteinSW_debug_show_matrix(ProteinSW * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->seq->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",ProteinSW_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",ProteinSW_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",ProteinSW_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_ProteinSW(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [ProteinSW_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_ProteinSW(ProteinSW * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ProteinSW_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = ProteinSW_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In ProteinSW matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,DELETE); } return (*h.access_main)(mat,i - 1,j - 1,DELETE); } temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (0) - (CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in ProteinSW read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->ext) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gap) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in ProteinSW read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->ext) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->gap) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in ProteinSW read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in ProteinSW read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_ProteinSW(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [ProteinSW_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_ProteinSW(ProteinSW * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ProteinSW_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = ProteinSW_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In ProteinSW matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source MATCH is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in ProteinSW read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_ProteinSW(mat) * * Descrip: This function calculates the ProteinSW matrix when in explicit mode * To allocate the matrix use /allocate_Expl_ProteinSW * * * Arg: mat [UNKN ] ProteinSW which contains explicit basematrix memory [ProteinSW *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_ProteinSW(ProteinSW * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_ProteinSW, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("ProteinSW Matrix calculation: "); for(j=0;j score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ProteinSW_EXPL_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = ProteinSW_EXPL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); ProteinSW_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinSW_EXPL_SPECIAL(mat,i,j,END) ) { ProteinSW_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ProteinSW_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; /* From state INSERT to state INSERT */ temp = ProteinSW_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ ProteinSW_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ProteinSW_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; /* From state DELETE to state DELETE */ temp = ProteinSW_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ProteinSW_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_ProteinSW(mat,dpenv) * * Descrip: This function calculates the ProteinSW matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] ProteinSW which contains explicit basematrix memory [ProteinSW *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_ProteinSW(ProteinSW * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_ProteinSW, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { ProteinSW_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; ProteinSW_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; ProteinSW_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j=-1;jlenj;j++) { ProteinSW_EXPL_SPECIAL(mat,i,j,START) = 0; ProteinSW_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("ProteinSW Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { ProteinSW_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; ProteinSW_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; ProteinSW_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = ProteinSW_EXPL_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = ProteinSW_EXPL_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ProteinSW_EXPL_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = ProteinSW_EXPL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CompMat_AAMATCH(mat->comp,CSEQ_PROTEIN_AMINOACID(mat->query,i),CSEQ_PROTEIN_AMINOACID(mat->target,j)); ProteinSW_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > ProteinSW_EXPL_SPECIAL(mat,i,j,END) ) { ProteinSW_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ProteinSW_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; /* From state INSERT to state INSERT */ temp = ProteinSW_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ ProteinSW_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ProteinSW_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; /* From state DELETE to state DELETE */ temp = ProteinSW_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ProteinSW_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: ProteinSW_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ProteinSW *] * */ ProteinSW * ProteinSW_alloc(void) { ProteinSW * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ProteinSW *) ckalloc (sizeof(ProteinSW))) == NULL) { warn("ProteinSW_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_ProteinSW(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ProteinSW *] * * Return [UNKN ] Undocumented return value [ProteinSW *] * */ ProteinSW * free_ProteinSW(ProteinSW * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ProteinSW obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->comp is linked in */ /* obj->gap is linked in */ /* obj->ext is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/proteinsw.h0000644000175000001440000004572510670453715016353 0ustar philippusers#ifndef DYNAMITEproteinswHEADERFILE #define DYNAMITEproteinswHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" struct Wise2_ProteinSW { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; ComplexSequence* query; ComplexSequence* target; CompMat* comp; int gap; int ext; } ; /* ProteinSW defined */ #ifndef DYNAMITE_DEFINED_ProteinSW typedef struct Wise2_ProteinSW Wise2_ProteinSW; #define ProteinSW Wise2_ProteinSW #define DYNAMITE_DEFINED_ProteinSW #endif #ifdef PTHREAD struct thread_pool_holder_ProteinSW { ComplexSequence* query; /* Query object placeholder */ ProteinDB* querydb; /* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ ProteinDB* targetdb;/* Target database object */ boolean target_init; CompMat* comp; int gap; int ext; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_ProteinSW_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(ProteinSW*,int,int,int); int (*access_special)(ProteinSW*,int,int,int); } ; /* ProteinSW_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_ProteinSW_access_func_holder typedef struct Wise2_ProteinSW_access_func_holder Wise2_ProteinSW_access_func_holder; #define ProteinSW_access_func_holder Wise2_ProteinSW_access_func_holder #define DYNAMITE_DEFINED_ProteinSW_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_ProteinSW(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_ProteinSW(ProteinSW * mat); #define PackAln_read_Shatter_ProteinSW Wise2_PackAln_read_Shatter_ProteinSW /* Function: calculate_shatter_ProteinSW(mat,dpenv) * * Descrip: This function calculates the ProteinSW matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [ProteinSW *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_ProteinSW(ProteinSW * mat,DPEnvelope * dpenv); #define calculate_shatter_ProteinSW Wise2_calculate_shatter_ProteinSW /* Function: search_ProteinSW(dbsi,out,querydb,targetdb,comp,gap,ext) * * Descrip: This function makes a database search of ProteinSW * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [ProteinDB*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * Arg: comp [UNKN ] Undocumented argument [CompMat*] * Arg: gap [UNKN ] Undocumented argument [int] * Arg: ext [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_ProteinSW(DBSearchImpl * dbsi,Hscore * out,ProteinDB* querydb,ProteinDB* targetdb ,CompMat* comp,int gap,int ext); #define search_ProteinSW Wise2_search_ProteinSW /* Function: serial_search_ProteinSW(out,querydb,targetdb,comp,gap,ext) * * Descrip: This function makes a database search of ProteinSW * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [ProteinDB*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * Arg: comp [UNKN ] Undocumented argument [CompMat*] * Arg: gap [UNKN ] Undocumented argument [int] * Arg: ext [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_ProteinSW(Hscore * out,ProteinDB* querydb,ProteinDB* targetdb ,CompMat* comp,int gap,int ext); #define serial_search_ProteinSW Wise2_serial_search_ProteinSW /* Function: PackAln_bestmemory_ProteinSW(query,target,comp,gap,ext,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_ProteinSW * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: gap [UNKN ] Resource [int] * Arg: ext [UNKN ] Resource [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_ProteinSW(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int gap,int ext,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_ProteinSW Wise2_PackAln_bestmemory_ProteinSW /* Function: allocate_Expl_ProteinSW(query,target,comp,gap,ext,dpri) * * Descrip: This function allocates the ProteinSW structure * and the basematrix area for explicit memory implementations * It calls /allocate_ProteinSW_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: gap [UNKN ] Resource [int] * Arg: ext [UNKN ] Resource [int] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [ProteinSW *] * */ ProteinSW * Wise2_allocate_Expl_ProteinSW(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int gap,int ext,DPRunImpl * dpri); #define allocate_Expl_ProteinSW Wise2_allocate_Expl_ProteinSW /* Function: recalculate_PackAln_ProteinSW(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by ProteinSW * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * */ void Wise2_recalculate_PackAln_ProteinSW(PackAln * pal,ProteinSW * mat); #define recalculate_PackAln_ProteinSW Wise2_recalculate_PackAln_ProteinSW /* Function: allocate_Small_ProteinSW(query,target,comp,gap,ext) * * Descrip: This function allocates the ProteinSW structure * and the basematrix area for a small memory implementations * It calls /allocate_ProteinSW_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [CompMat*] * Arg: gap [UNKN ] Resource [int] * Arg: ext [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [ProteinSW *] * */ ProteinSW * Wise2_allocate_Small_ProteinSW(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int gap,int ext); #define allocate_Small_ProteinSW Wise2_allocate_Small_ProteinSW /* Function: PackAln_calculate_Small_ProteinSW(mat,dpenv) * * Descrip: This function calculates an alignment for ProteinSW structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_ProteinSW * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_ProteinSW * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_ProteinSW(ProteinSW * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_ProteinSW Wise2_PackAln_calculate_Small_ProteinSW /* Function: AlnRangeSet_calculate_Small_ProteinSW(mat) * * Descrip: This function calculates an alignment for ProteinSW structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_ProteinSW * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_ProteinSW * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_ProteinSW * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_ProteinSW(ProteinSW * mat); #define AlnRangeSet_calculate_Small_ProteinSW Wise2_AlnRangeSet_calculate_Small_ProteinSW /* Function: AlnRangeSet_from_ProteinSW(mat) * * Descrip: This function reads off a start/end structure * for ProteinSW structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_ProteinSW * If you have not calculated the matrix use * /AlnRange_calculate_Small_ProteinSW * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_ProteinSW(ProteinSW * mat); #define AlnRangeSet_from_ProteinSW Wise2_AlnRangeSet_from_ProteinSW /* Function: convert_PackAln_to_AlnBlock_ProteinSW(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_ProteinSW(PackAln * pal); #define convert_PackAln_to_AlnBlock_ProteinSW Wise2_convert_PackAln_to_AlnBlock_ProteinSW /* Function: PackAln_read_Expl_ProteinSW(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_ProteinSW(ProteinSW * mat); #define PackAln_read_Expl_ProteinSW Wise2_PackAln_read_Expl_ProteinSW /* Function: PackAln_read_generic_ProteinSW(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ProteinSW *] * Arg: h [UNKN ] Undocumented argument [ProteinSW_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_ProteinSW(ProteinSW * mat,ProteinSW_access_func_holder h); #define PackAln_read_generic_ProteinSW Wise2_PackAln_read_generic_ProteinSW /* Function: calculate_ProteinSW(mat) * * Descrip: This function calculates the ProteinSW matrix when in explicit mode * To allocate the matrix use /allocate_Expl_ProteinSW * * * Arg: mat [UNKN ] ProteinSW which contains explicit basematrix memory [ProteinSW *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_ProteinSW(ProteinSW * mat); #define calculate_ProteinSW Wise2_calculate_ProteinSW /* Function: calculate_dpenv_ProteinSW(mat,dpenv) * * Descrip: This function calculates the ProteinSW matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] ProteinSW which contains explicit basematrix memory [ProteinSW *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_ProteinSW(ProteinSW * mat,DPEnvelope * dpenv); #define calculate_dpenv_ProteinSW Wise2_calculate_dpenv_ProteinSW /* Function: ProteinSW_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ProteinSW *] * */ ProteinSW * Wise2_ProteinSW_alloc(void); #define ProteinSW_alloc Wise2_ProteinSW_alloc /* Function: free_ProteinSW(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ProteinSW *] * * Return [UNKN ] Undocumented return value [ProteinSW *] * */ ProteinSW * Wise2_free_ProteinSW(ProteinSW * obj); #define free_ProteinSW Wise2_free_ProteinSW /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_ProteinSW_shatter_access_main(ProteinSW * mat,int i,int j,int state); #define ProteinSW_shatter_access_main Wise2_ProteinSW_shatter_access_main int Wise2_ProteinSW_shatter_access_special(ProteinSW * mat,int i,int j,int state); #define ProteinSW_shatter_access_special Wise2_ProteinSW_shatter_access_special void * Wise2_thread_loop_ProteinSW(void * ptr); #define thread_loop_ProteinSW Wise2_thread_loop_ProteinSW int Wise2_score_only_ProteinSW(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int gap,int ext); #define score_only_ProteinSW Wise2_score_only_ProteinSW ProteinSW * Wise2_allocate_ProteinSW_only(ComplexSequence* query,ComplexSequence* target ,CompMat* comp,int gap,int ext); #define allocate_ProteinSW_only Wise2_allocate_ProteinSW_only void Wise2_init_ProteinSW(ProteinSW * mat); #define init_ProteinSW Wise2_init_ProteinSW AlnRange * Wise2_AlnRange_build_ProteinSW(ProteinSW * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_ProteinSW Wise2_AlnRange_build_ProteinSW boolean Wise2_read_hidden_ProteinSW(ProteinSW * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_ProteinSW Wise2_read_hidden_ProteinSW int Wise2_max_hidden_ProteinSW(ProteinSW * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_ProteinSW Wise2_max_hidden_ProteinSW boolean Wise2_read_special_strip_ProteinSW(ProteinSW * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_ProteinSW Wise2_read_special_strip_ProteinSW int Wise2_max_special_strip_ProteinSW(ProteinSW * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_ProteinSW Wise2_max_special_strip_ProteinSW int Wise2_max_matrix_to_special_ProteinSW(ProteinSW * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_ProteinSW Wise2_max_matrix_to_special_ProteinSW void Wise2_calculate_hidden_ProteinSW(ProteinSW * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_ProteinSW Wise2_calculate_hidden_ProteinSW void Wise2_init_hidden_ProteinSW(ProteinSW * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_ProteinSW Wise2_init_hidden_ProteinSW boolean Wise2_full_dc_ProteinSW(ProteinSW * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_ProteinSW Wise2_full_dc_ProteinSW boolean Wise2_do_dc_single_pass_ProteinSW(ProteinSW * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_ProteinSW Wise2_do_dc_single_pass_ProteinSW void Wise2_push_dc_at_merge_ProteinSW(ProteinSW * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_ProteinSW Wise2_push_dc_at_merge_ProteinSW void Wise2_follow_on_dc_ProteinSW(ProteinSW * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_ProteinSW Wise2_follow_on_dc_ProteinSW void Wise2_run_up_dc_ProteinSW(ProteinSW * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_ProteinSW Wise2_run_up_dc_ProteinSW void Wise2_init_dc_ProteinSW(ProteinSW * mat); #define init_dc_ProteinSW Wise2_init_dc_ProteinSW int Wise2_start_end_find_end_ProteinSW(ProteinSW * mat,int * endj); #define start_end_find_end_ProteinSW Wise2_start_end_find_end_ProteinSW boolean Wise2_dc_optimised_start_end_calc_ProteinSW(ProteinSW *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_ProteinSW Wise2_dc_optimised_start_end_calc_ProteinSW void Wise2_init_start_end_linear_ProteinSW(ProteinSW * mat); #define init_start_end_linear_ProteinSW Wise2_init_start_end_linear_ProteinSW AlnConvertSet * Wise2_AlnConvertSet_ProteinSW(void); #define AlnConvertSet_ProteinSW Wise2_AlnConvertSet_ProteinSW int Wise2_ProteinSW_explicit_access_main(ProteinSW * mat,int i,int j,int state); #define ProteinSW_explicit_access_main Wise2_ProteinSW_explicit_access_main int Wise2_ProteinSW_explicit_access_special(ProteinSW * mat,int i,int j,int state); #define ProteinSW_explicit_access_special Wise2_ProteinSW_explicit_access_special int Wise2_find_end_ProteinSW(ProteinSW * mat,int * ri,int * rj,int * state,boolean * isspecial,ProteinSW_access_func_holder h); #define find_end_ProteinSW Wise2_find_end_ProteinSW void Wise2_ProteinSW_debug_show_matrix(ProteinSW * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define ProteinSW_debug_show_matrix Wise2_ProteinSW_debug_show_matrix int Wise2_max_calc_ProteinSW(ProteinSW * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ProteinSW_access_func_holder h); #define max_calc_ProteinSW Wise2_max_calc_ProteinSW int Wise2_max_calc_special_ProteinSW(ProteinSW * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ProteinSW_access_func_holder h); #define max_calc_special_ProteinSW Wise2_max_calc_special_ProteinSW #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/localclonewisedp.dy0000644000175000001440000000377007313404546020025 0ustar philippusers %{ #include "mapstruct.h" %} matrix LocalCloneWise query name="q" type="MappedCloneSet *" field:len="length" target name="t" type="MappedCloneSet *" field:len="length" resource name="match" type="MappedCloneMatch*" resource name="target_skip_start" type="Score" resource name="target_skip" type="Score" resource name="query_skip_start" type="Score" resource name="query_skip" type="Score" resource name="spread" type="int" resource name="target_special_s" type="int" state MATCH offi="1" offj="1" source MATCH calc="match->matrix[i][j]" endsource source MATCH offi="0" offj="1" calc="0-1" query_label QUERY_MATCH_PAUSE endsource source MATCH offi="1" offj="0" calc="0-1" target_label TARGET_MATCH_PAUSE endsource source SKIP_QUERY calc="0" endsource source SKIP_TARGET calc="0" endsource source START !top calc="0" endsource query_label QUERY_MATCH target_label TARGET_MATCH calc="match->matrix[i][j]" endstate state SKIP_QUERY offi="1" offj="0" source MATCH calc="query_skip_start" endsource source SKIP_TARGET calc="query_skip_start" endsource source SKIP_QUERY calc="0" endsource source START !top calc="query_skip_start" endsource calc="match->skip_iset[i]" query_label QUERY_SKIP target_label TARGET_PAUSE endstate state SKIP_TARGET offi="0" offj="1" source MATCH calc="target_skip_start - 10" endsource source SKIP_QUERY calc="target_skip_start - 10" endsource source SKIP_TARGET calc="0 -10" endsource source START !top calc="target_skip_start" endsource calc="match->skip_jset[j]" query_label QUERY_PAUSE target_label TARGET_SKIP endstate state START !special !start endstate state END !special !end source MATCH !bottom calc="0" endsource source SKIP_TARGET !bottom calc="0" endsource source SKIP_QUERY !bottom calc="0" endsource query_label END target_label END endstate endmatrix wise-2.4.1/src/models/localdba.c0000644000175000001440000072455310670453714016057 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "localdba.h" # line 5 "localdba.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH65 0 #define MATCH75 1 #define MATCH85 2 #define MATCH95 3 #define UNMATCHED_QUERY 4 #define UNMATCHED_TARGET 5 #define START 0 #define END 1 #define LocalDnaMatchBlock_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*6)+STATE][i+1] #define LocalDnaMatchBlock_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define LocalDnaMatchBlock_READ_OFF_ERROR -3 #define LocalDnaMatchBlock_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*6)+STATE] #define LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define LocalDnaMatchBlock_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define LocalDnaMatchBlock_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_LocalDnaMatchBlock(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_LocalDnaMatchBlock(LocalDnaMatchBlock * mat) { LocalDnaMatchBlock_access_func_holder holder; holder.access_main = LocalDnaMatchBlock_shatter_access_main; holder.access_special = LocalDnaMatchBlock_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_LocalDnaMatchBlock(mat,holder); } /* Function: LocalDnaMatchBlock_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LocalDnaMatchBlock_shatter_access_main(LocalDnaMatchBlock * mat,int i,int j,int state) { return LocalDnaMatchBlock_SHATTER_MATRIX(mat,i,j,state); } /* Function: LocalDnaMatchBlock_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LocalDnaMatchBlock_shatter_access_special(LocalDnaMatchBlock * mat,int i,int j,int state) { return LocalDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_LocalDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the LocalDnaMatchBlock matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [LocalDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,6,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("LocalDnaMatchBlock Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH65 */ /* setting first movement to score */ score = SIG_1_1[MATCH65] + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH65 to state MATCH65 */ temp = SIG_0_1[MATCH65] + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = SIG_1_0[MATCH65] + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH65 */ temp = LocalDnaMatchBlock_SHATTER_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH65] = score; /* state MATCH65 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = SIG_1_1[MATCH75] + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH75 to state MATCH75 */ temp = SIG_0_1[MATCH75] + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = SIG_1_0[MATCH75] + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH75 */ temp = LocalDnaMatchBlock_SHATTER_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH75] = score; /* state MATCH75 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = SIG_1_1[MATCH85] + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH85 to state MATCH85 */ temp = SIG_0_1[MATCH85] + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = SIG_1_0[MATCH85] + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH85 */ temp = LocalDnaMatchBlock_SHATTER_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH85] = score; /* state MATCH85 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = SIG_1_1[MATCH95] + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH95 to state MATCH95 */ temp = SIG_0_1[MATCH95] + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = SIG_1_0[MATCH95] + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH95 */ temp = LocalDnaMatchBlock_SHATTER_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH95] = score; /* state MATCH95 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = SIG_1_0[MATCH65] + mat->lchs->b; /* From state MATCH75 to state UNMATCHED_QUERY */ temp = SIG_1_0[MATCH75] + mat->lchs->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = SIG_1_0[MATCH85] + mat->lchs->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = SIG_1_0[MATCH95] + mat->lchs->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = SIG_1_0[UNMATCHED_QUERY] + mat->lchs->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ SIG_0_0[UNMATCHED_QUERY] = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = SIG_0_1[UNMATCHED_QUERY] + mat->lchs->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = SIG_0_1[UNMATCHED_TARGET] + mat->lchs->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ SIG_0_0[UNMATCHED_TARGET] = score; /* Finished calculating state UNMATCHED_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_LocalDnaMatchBlock(dbsi,out,query,target,lchs) * * Descrip: This function makes a database search of LocalDnaMatchBlock * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: lchs [UNKN ] Undocumented argument [LocalCisHitScore*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_LocalDnaMatchBlock(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs) { if( out == NULL ) { warn("Passed in a null Hscore object into search_LocalDnaMatchBlock. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_LocalDnaMatchBlock. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for LocalDnaMatchBlock, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_LocalDnaMatchBlock(out,query,target ,lchs); case DBSearchImpl_Pthreads : warn("This matrix LocalDnaMatchBlock was not dyc compiled with thread support"); return SEARCH_ERROR; default : warn("database search implementation %s was not provided in the compiled dynamite file from LocalDnaMatchBlock",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: serial_search_LocalDnaMatchBlock(out,query,target,lchs) * * Descrip: This function makes a database search of LocalDnaMatchBlock * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: lchs [UNKN ] Undocumented argument [LocalCisHitScore*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_LocalDnaMatchBlock(Hscore * out,ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_LocalDnaMatchBlock(query, target , lchs); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("LocalDnaMatchBlock search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_LocalDnaMatchBlock(query,target,lchs) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_LocalDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: lchs [UNKN ] Resource [LocalCisHitScore*] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_LocalDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs) { int bestscore = NEGI; int i; int j; int k; LocalDnaMatchBlock * mat; mat = allocate_LocalDnaMatchBlock_only(query, target , lchs); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 6,2,2)) == NULL) { warn("Score only matrix for LocalDnaMatchBlock cannot be allocated, (asking for 1 by %d cells)",mat->leni*6); mat = free_LocalDnaMatchBlock(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<6;k++) LocalDnaMatchBlock_VSMALL_MATRIX(mat,i,j,k) = NEGI; } LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,START) = 0; LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH65 */ /* setting first movement to score */ score = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH65) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH65) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH65 */ temp = LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH65) = score; /* state MATCH65 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH75) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH75) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH75 */ temp = LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH75) = score; /* state MATCH75 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH85) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH85) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH85 */ temp = LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH85) = score; /* state MATCH85 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH95) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH95) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH95 */ temp = LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH95) = score; /* state MATCH95 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->b; /* From state MATCH75 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->lchs->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_VSMALL_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->lchs->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = LocalDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->lchs->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_VSMALL_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished calculating state UNMATCHED_TARGET */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < LocalDnaMatchBlock_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = LocalDnaMatchBlock_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_LocalDnaMatchBlock(mat); return bestscore; } /* Function: PackAln_bestmemory_LocalDnaMatchBlock(query,target,lchs,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_LocalDnaMatchBlock * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: lchs [UNKN ] Resource [LocalCisHitScore*] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_LocalDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; LocalDnaMatchBlock * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->seq->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 6 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_LocalDnaMatchBlock(query, target , lchs,dpri)) == NULL ) { warn("Unable to allocate large LocalDnaMatchBlock version"); return NULL; } calculate_dpenv_LocalDnaMatchBlock(mat,dpenv); out = PackAln_read_Expl_LocalDnaMatchBlock(mat); } else { mat = allocate_LocalDnaMatchBlock_only(query, target , lchs); calculate_shatter_LocalDnaMatchBlock(mat,dpenv); out = PackAln_read_Shatter_LocalDnaMatchBlock(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_LocalDnaMatchBlock(query, target , lchs)) == NULL ) { warn("Unable to allocate small LocalDnaMatchBlock version"); return NULL; } out = PackAln_calculate_Small_LocalDnaMatchBlock(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_LocalDnaMatchBlock(query, target , lchs,dpri)) == NULL ) { warn("Unable to allocate large LocalDnaMatchBlock version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_LocalDnaMatchBlock(mat); out = PackAln_read_Expl_LocalDnaMatchBlock(mat); } } } mat = free_LocalDnaMatchBlock(mat); return out; } /* Function: allocate_LocalDnaMatchBlock_only(query,target,lchs) * * Descrip: This function only allocates the LocalDnaMatchBlock structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: lchs [UNKN ] Resource [LocalCisHitScore*] * * Return [UNKN ] Undocumented return value [LocalDnaMatchBlock *] * */ LocalDnaMatchBlock * allocate_LocalDnaMatchBlock_only(ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs) { LocalDnaMatchBlock * out; if((out= LocalDnaMatchBlock_alloc()) == NULL) { warn("Allocation of basic LocalDnaMatchBlock structure failed..."); return NULL; } out->query = query; out->target = target; out->lchs = lchs; out->leni = query->seq->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_LocalDnaMatchBlock(query,target,lchs,dpri) * * Descrip: This function allocates the LocalDnaMatchBlock structure * and the basematrix area for explicit memory implementations * It calls /allocate_LocalDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: lchs [UNKN ] Resource [LocalCisHitScore*] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [LocalDnaMatchBlock *] * */ LocalDnaMatchBlock * allocate_Expl_LocalDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs,DPRunImpl * dpri) { LocalDnaMatchBlock * out; out = allocate_LocalDnaMatchBlock_only(query, target , lchs); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*6 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*6,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix LocalDnaMatchBlock cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_LocalDnaMatchBlock(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_LocalDnaMatchBlock(out); return out; } /* Function: init_LocalDnaMatchBlock(mat) * * Descrip: This function initates LocalDnaMatchBlock matrix when in explicit mode * Called in /allocate_Expl_LocalDnaMatchBlock * * * Arg: mat [UNKN ] LocalDnaMatchBlock which contains explicit basematrix memory [LocalDnaMatchBlock *] * */ void init_LocalDnaMatchBlock(LocalDnaMatchBlock * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->seq->len;i++) { for(j= (-1);j<2;j++) { LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } } for(j= (-1);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,START) = 0; LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_LocalDnaMatchBlock(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by LocalDnaMatchBlock * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * */ void recalculate_PackAln_LocalDnaMatchBlock(PackAln * pal,LocalDnaMatchBlock * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH65 : if( offi == 1 && offj == 1 && prev->state == MATCH65 ) { pau->score = (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH65 ) { pau->score = mat->lchs->g + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH65 ) { pau->score = mat->lchs->g + (0); continue; } if( offj == 1 && prev->state == (START+6) ) { pau->score = (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH65, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case MATCH75 : if( offi == 1 && offj == 1 && prev->state == MATCH75 ) { pau->score = (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH75 ) { pau->score = mat->lchs->g + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH75 ) { pau->score = mat->lchs->g + (0); continue; } if( offj == 1 && prev->state == (START+6) ) { pau->score = (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH75, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case MATCH85 : if( offi == 1 && offj == 1 && prev->state == MATCH85 ) { pau->score = (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH85 ) { pau->score = mat->lchs->g + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH85 ) { pau->score = mat->lchs->g + (0); continue; } if( offj == 1 && prev->state == (START+6) ) { pau->score = (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH85, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case MATCH95 : if( offi == 1 && offj == 1 && prev->state == MATCH95 ) { pau->score = (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH95 ) { pau->score = mat->lchs->g + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH95 ) { pau->score = mat->lchs->g + (0); continue; } if( offj == 1 && prev->state == (START+6) ) { pau->score = (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH95, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UNMATCHED_QUERY : if( offi == 1 && offj == 0 && prev->state == MATCH65 ) { pau->score = mat->lchs->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH75 ) { pau->score = mat->lchs->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH85 ) { pau->score = mat->lchs->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH95 ) { pau->score = mat->lchs->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == UNMATCHED_QUERY ) { pau->score = mat->lchs->u + (0); continue; } warn("In recaluclating PackAln with state UNMATCHED_QUERY, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UNMATCHED_TARGET : if( offi == 0 && offj == 1 && prev->state == UNMATCHED_QUERY ) { pau->score = mat->lchs->v + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = mat->lchs->u + (0); continue; } warn("In recaluclating PackAln with state UNMATCHED_TARGET, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+6) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+6) : if( offj == 0 && prev->state == MATCH65 ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == MATCH75 ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == MATCH85 ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == MATCH95 ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define LocalDnaMatchBlock_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*6+state]) #define LocalDnaMatchBlock_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*6+state]) #define LocalDnaMatchBlock_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define LocalDnaMatchBlock_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*6 + state]) #define LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 6) + ((i+1) * 6) + (state)]) #define LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 48) + ((i+1) * 48) + (state * 8) + shadow+1]) #define LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_LocalDnaMatchBlock(query,target,lchs) * * Descrip: This function allocates the LocalDnaMatchBlock structure * and the basematrix area for a small memory implementations * It calls /allocate_LocalDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: lchs [UNKN ] Resource [LocalCisHitScore*] * * Return [UNKN ] Undocumented return value [LocalDnaMatchBlock *] * */ #define LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) LocalDnaMatchBlock * allocate_Small_LocalDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs) { LocalDnaMatchBlock * out; out = allocate_LocalDnaMatchBlock_only(query, target , lchs); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 6,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix LocalDnaMatchBlock cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_LocalDnaMatchBlock(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_LocalDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates an alignment for LocalDnaMatchBlock structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_LocalDnaMatchBlock * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_LocalDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for LocalDnaMatchBlock due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_LocalDnaMatchBlock(mat,dpenv); score = start_end_find_end_LocalDnaMatchBlock(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_LocalDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_LocalDnaMatchBlock(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == LocalDnaMatchBlock_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_LocalDnaMatchBlock(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 6; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_LocalDnaMatchBlock(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_LocalDnaMatchBlock(mat) * * Descrip: This function calculates an alignment for LocalDnaMatchBlock structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_LocalDnaMatchBlock * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_LocalDnaMatchBlock * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_LocalDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_LocalDnaMatchBlock(LocalDnaMatchBlock * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_LocalDnaMatchBlock(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_LocalDnaMatchBlock(mat); return out; } /* Function: AlnRangeSet_from_LocalDnaMatchBlock(mat) * * Descrip: This function reads off a start/end structure * for LocalDnaMatchBlock structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_LocalDnaMatchBlock * If you have not calculated the matrix use * /AlnRange_calculate_Small_LocalDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_LocalDnaMatchBlock(LocalDnaMatchBlock * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_LocalDnaMatchBlock"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_LocalDnaMatchBlock(mat,&jpos); state = END; while( (temp = AlnRange_build_LocalDnaMatchBlock(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_LocalDnaMatchBlock(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_LocalDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_LocalDnaMatchBlock"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_LocalDnaMatchBlock(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_LocalDnaMatchBlock alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_LocalDnaMatchBlock(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == LocalDnaMatchBlock_READ_OFF_ERROR) { warn("In AlnRange_build_LocalDnaMatchBlock alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_LocalDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_LocalDnaMatchBlock(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == LocalDnaMatchBlock_READ_OFF_ERROR) { warn("In LocalDnaMatchBlock hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In LocalDnaMatchBlock hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In LocalDnaMatchBlock hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_LocalDnaMatchBlock(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = LocalDnaMatchBlock_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In LocalDnaMatchBlock matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH65 : temp = cscore - ((mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } /* Not allowing special sources.. skipping START */ temp = cscore - (mat->lchs->g) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65); } temp = cscore - (mat->lchs->g) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH65) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH65); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH65); } temp = cscore - ((mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s)) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH65) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH65); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH65); } warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH75 : temp = cscore - ((mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } /* Not allowing special sources.. skipping START */ temp = cscore - (mat->lchs->g) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH75) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH75); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH75); } temp = cscore - (mat->lchs->g) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH75) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH75); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH75); } temp = cscore - ((mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s)) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH75) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH75); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH75); } warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH85 : temp = cscore - ((mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } /* Not allowing special sources.. skipping START */ temp = cscore - (mat->lchs->g) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH85) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH85); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH85); } temp = cscore - (mat->lchs->g) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH85) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH85); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH85); } temp = cscore - ((mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s)) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH85) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH85); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH85); } warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH95 : temp = cscore - ((mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } /* Not allowing special sources.. skipping START */ temp = cscore - (mat->lchs->g) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH95) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH95); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH95); } temp = cscore - (mat->lchs->g) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH95) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH95); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH95); } temp = cscore - ((mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s)) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH95) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH95); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH95); } warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_QUERY : temp = cscore - (mat->lchs->u) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,UNMATCHED_QUERY) ) { *reti = i - 1; *retj = j - 0; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,UNMATCHED_QUERY); } temp = cscore - (mat->lchs->b) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH95) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH95); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH95); } temp = cscore - (mat->lchs->b) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH85) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH85); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH85); } temp = cscore - (mat->lchs->b) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH75) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH75); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH75); } temp = cscore - (mat->lchs->b) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65); } warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_TARGET : temp = cscore - (mat->lchs->u) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_TARGET) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->lchs->v) - (0); if( temp == LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_QUERY) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY); } return LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_QUERY); } warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_LocalDnaMatchBlock(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } max_special_strip_LocalDnaMatchBlock(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == LocalDnaMatchBlock_READ_OFF_ERROR) { warn("In special strip read LocalDnaMatchBlock, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read LocalDnaMatchBlock, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_LocalDnaMatchBlock(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = LocalDnaMatchBlock_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for LocalDnaMatchBlock, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In LocalDnaMatchBlock matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source MATCH95 is not a special */ /* Source MATCH85 is not a special */ /* Source MATCH75 is not a special */ /* Source MATCH65 is not a special */ default: warn("Major problem (!) - in LocalDnaMatchBlock special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_LocalDnaMatchBlock(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = LocalDnaMatchBlock_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In LocalDnaMatchBlock matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH65 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ temp = cscore - ((mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source MATCH65 is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ warn("Major problem (!) - in LocalDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH75 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ temp = cscore - ((mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source MATCH75 is not a special, should not get here! */ /* Source MATCH75 is not a special, should not get here! */ /* Source MATCH75 is not a special, should not get here! */ warn("Major problem (!) - in LocalDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH85 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ temp = cscore - ((mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source MATCH85 is not a special, should not get here! */ /* Source MATCH85 is not a special, should not get here! */ /* Source MATCH85 is not a special, should not get here! */ warn("Major problem (!) - in LocalDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH95 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ temp = cscore - ((mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source MATCH95 is not a special, should not get here! */ /* Source MATCH95 is not a special, should not get here! */ /* Source MATCH95 is not a special, should not get here! */ warn("Major problem (!) - in LocalDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_QUERY : /* Source UNMATCHED_QUERY is not a special, should not get here! */ /* Source MATCH95 is not a special, should not get here! */ /* Source MATCH85 is not a special, should not get here! */ /* Source MATCH75 is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ warn("Major problem (!) - in LocalDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_TARGET : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source UNMATCHED_QUERY is not a special, should not get here! */ warn("Major problem (!) - in LocalDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_LocalDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_LocalDnaMatchBlock(mat,starti,startj,stopi,stopj); LocalDnaMatchBlock_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH65) = NEGI; LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH75) = NEGI; LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH85) = NEGI; LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH95) = NEGI; LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH65 */ /* setting first movement to score */ score = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH65) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH65) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH75) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH75) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH75) = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH85) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH85) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH85) = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH95) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH95) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH95) = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->b; /* From state MATCH75 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->lchs->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->lchs->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->lchs->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished calculating state UNMATCHED_TARGET */ } } return; } /* Function: init_hidden_LocalDnaMatchBlock(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH65) = NEGI; LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH75) = NEGI; LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH85) = NEGI; LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH95) = NEGI; LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; LocalDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } } return; } /* Function: full_dc_LocalDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_LocalDnaMatchBlock * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_LocalDnaMatchBlock to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [LocalDnaMatchBlock *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_LocalDnaMatchBlock"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_LocalDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_LocalDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_LocalDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for LocalDnaMatchBlock, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_LocalDnaMatchBlock(mat,LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_LocalDnaMatchBlock(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_LocalDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_LocalDnaMatchBlock(mat); LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_LocalDnaMatchBlock(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_LocalDnaMatchBlock(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_LocalDnaMatchBlock(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_LocalDnaMatchBlock(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = (-100); LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = (-100); LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = (-100); LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = (-100); LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = (-100); LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = (-100); LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = (-100); LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = (-100); LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = (-100); LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = (-100); LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = (-100); LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH65, pushing when j - offj <= mergej */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH65) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = MATCH65; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH65,k); } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->lchs->g; if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = MATCH65; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH65,k); } } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->g; if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = MATCH65; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); } } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = UNMATCHED_TARGET; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = score; /* Finished with state MATCH65 */ /* For state MATCH75, pushing when j - offj <= mergej */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH75) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,2) = MATCH75; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,5) = MATCH75; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH75,k); } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH75) + mat->lchs->g; if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = i-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,2) = MATCH75; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,5) = MATCH75; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH75,k); } } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->g; if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = j-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,2) = MATCH75; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,5) = MATCH75; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,k); } } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,2) = UNMATCHED_TARGET; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,5) = MATCH75; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = score; /* Finished with state MATCH75 */ /* For state MATCH85, pushing when j - offj <= mergej */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH85) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,2) = MATCH85; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,5) = MATCH85; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH85,k); } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH85) + mat->lchs->g; if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = i-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,2) = MATCH85; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,5) = MATCH85; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH85,k); } } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->g; if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = j-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,2) = MATCH85; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,5) = MATCH85; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,k); } } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,2) = UNMATCHED_TARGET; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,5) = MATCH85; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = score; /* Finished with state MATCH85 */ /* For state MATCH95, pushing when j - offj <= mergej */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH95) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,2) = MATCH95; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,5) = MATCH95; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH95,k); } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH95) + mat->lchs->g; if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = i-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,2) = MATCH95; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,5) = MATCH95; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH95,k); } } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->g; if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = j-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,2) = MATCH95; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,5) = MATCH95; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,k); } } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,2) = UNMATCHED_TARGET; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,5) = MATCH95; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = score; /* Finished with state MATCH95 */ /* For state UNMATCHED_QUERY, pushing when j - offj <= mergej */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->b; if( j - 0 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH65; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->b; if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH75; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,k); } } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->b; if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH85; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,k); } } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->b; if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH95; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,k); } } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->lchs->u; if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = UNMATCHED_QUERY; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED_QUERY,k); } } /* Add any movement independant score */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished with state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET, pushing when j - offj <= mergej */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->lchs->v; if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = i-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,2) = UNMATCHED_QUERY; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,5) = UNMATCHED_TARGET; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_QUERY,k); } temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->lchs->u; if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = i-0; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,1) = j-1; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,2) = UNMATCHED_TARGET; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,3) = i; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,4) = j; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,5) = UNMATCHED_TARGET; } else { for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished with state UNMATCHED_TARGET */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_LocalDnaMatchBlock(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH65 */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH65) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH65,k); /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->lchs->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH65,k); } /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = score; for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH75) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH75,k); /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH75) + mat->lchs->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH75,k); } /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,k); } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = score; for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH85) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH85,k); /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH85) + mat->lchs->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH85,k); } /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,k); } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = score; for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH95) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH95,k); /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH95) + mat->lchs->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH95,k); } /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,k); } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = score; for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->b; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); /* From state MATCH75 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->b; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,k); } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->b; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,k); } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->b; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,k); } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->lchs->u; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED_QUERY,k); } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->lchs->v; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_QUERY,k); /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->lchs->u; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; for(k=0;k<7;k++) LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED_TARGET */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_LocalDnaMatchBlock(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH65 */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH65) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH75) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH75) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH85) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH85) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH95) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH95) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->b; /* From state MATCH75 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->lchs->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->lchs->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->lchs->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished calculating state UNMATCHED_TARGET */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_LocalDnaMatchBlock(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * */ } void init_dc_LocalDnaMatchBlock(LocalDnaMatchBlock * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; for(k=0;k<7;k++) { LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = (-1); LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = (-1); LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = (-1); LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = (-1); LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = (-1); LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = (-1); } } } return; } /* Function: start_end_find_end_LocalDnaMatchBlock(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [LocalDnaMatchBlock *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int * endj) { register int j; register int max; register int maxj; max = LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_LocalDnaMatchBlock(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [LocalDnaMatchBlock] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_LocalDnaMatchBlock(LocalDnaMatchBlock *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->seq->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 6,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 6 * 8,sizeof(int)); for(j=0;jlchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s) + (0); /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH65,0)); /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->lchs->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH65,0)); } /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,0)); } /* From state START to state MATCH65 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH65... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH65; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH65) = score; for(k=0;k<7;k++) LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH65 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k); LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH65,6); LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH65; } /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH75) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s) + (0); /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH75,0)); /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH75) + mat->lchs->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH75,0)); } /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,0)); } /* From state START to state MATCH75 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH75... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH75; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH75) = score; for(k=0;k<7;k++) LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH75 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k); LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH75,6); LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH75; } /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH85) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s) + (0); /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH85,0)); /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH85) + mat->lchs->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH85,0)); } /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,0)); } /* From state START to state MATCH85 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH85... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH85; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH85) = score; for(k=0;k<7;k++) LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH85 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k); LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH85,6); LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH85; } /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH95) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s) + (0); /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH95,0)); /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH95) + mat->lchs->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH95,0)); } /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,0)); } /* From state START to state MATCH95 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH95... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH95; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH95) = score; for(k=0;k<7;k++) LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH95 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k); LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH95,6); LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; LocalDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH95; } /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->b + (0); /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,0)); /* From state MATCH75 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->b +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,0)); } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->b +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,0)); } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->b +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,0)); } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->lchs->u +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED_QUERY,0)); } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; for(k=0;k<7;k++) LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->lchs->v + (0); /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_QUERY,0)); /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->lchs->u +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; for(k=0;k<7;k++) LocalDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED_TARGET */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_LocalDnaMatchBlock(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * */ void init_start_end_linear_LocalDnaMatchBlock(LocalDnaMatchBlock * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = (-1); LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = (-1); LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = (-1); LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = (-1); LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = (-1); LocalDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; LocalDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = (-1); } } for(j=(-1);jtarget->seq->len;j++) { LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; LocalDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; LocalDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_LocalDnaMatchBlock(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_LocalDnaMatchBlock(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_LocalDnaMatchBlock(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MM65","MI65","MM75","MI75","MM85","MI85","MM95","MI95","UM","UI","END" }; /* Function: AlnConvertSet_LocalDnaMatchBlock(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "MM65","MI65","MM75","MI75","MM85","MI85","MM95","MI95","UI","UM","END" }; AlnConvertSet * AlnConvertSet_LocalDnaMatchBlock(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = MATCH65; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = MATCH65; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = MATCH65; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = MATCH65; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH65; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH75; acu->state2 = MATCH75; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH75; acu->state2 = MATCH75; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH75; acu->state2 = MATCH75; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = MATCH75; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH75; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH85; acu->state2 = MATCH85; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH85; acu->state2 = MATCH85; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH85; acu->state2 = MATCH85; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[5]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = MATCH85; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH85; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH95; acu->state2 = MATCH95; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH95; acu->state2 = MATCH95; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH95; acu->state2 = MATCH95; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[7]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = MATCH95; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH95; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH75; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH85; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH95; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_QUERY; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_QUERY; acu->state2 = UNMATCHED_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[9]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = UNMATCHED_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[9]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH75; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH85; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH95; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[10]; return out; } /* Function: PackAln_read_Expl_LocalDnaMatchBlock(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_LocalDnaMatchBlock(LocalDnaMatchBlock * mat) { LocalDnaMatchBlock_access_func_holder holder; holder.access_main = LocalDnaMatchBlock_explicit_access_main; holder.access_special = LocalDnaMatchBlock_explicit_access_special; return PackAln_read_generic_LocalDnaMatchBlock(mat,holder); } /* Function: LocalDnaMatchBlock_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LocalDnaMatchBlock_explicit_access_main(LocalDnaMatchBlock * mat,int i,int j,int state) { return LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,state); } /* Function: LocalDnaMatchBlock_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LocalDnaMatchBlock_explicit_access_special(LocalDnaMatchBlock * mat,int i,int j,int state) { return LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_LocalDnaMatchBlock(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: h [UNKN ] Undocumented argument [LocalDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,LocalDnaMatchBlock_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_LocalDnaMatchBlock(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in LocalDnaMatchBlock_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_LocalDnaMatchBlock(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_LocalDnaMatchBlock(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == LocalDnaMatchBlock_READ_OFF_ERROR || j == LocalDnaMatchBlock_READ_OFF_ERROR || state == LocalDnaMatchBlock_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in LocalDnaMatchBlock_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_LocalDnaMatchBlock(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [LocalDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int * ri,int * rj,int * state,boolean * isspecial,LocalDnaMatchBlock_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: LocalDnaMatchBlock_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void LocalDnaMatchBlock_debug_show_matrix(LocalDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->seq->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH65 %d\n",LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65)); fprintf(ofp,"State MATCH75 %d\n",LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75)); fprintf(ofp,"State MATCH85 %d\n",LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85)); fprintf(ofp,"State MATCH95 %d\n",LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95)); fprintf(ofp,"State UNMATCHED_QUERY %d\n",LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY)); fprintf(ofp,"State UNMATCHED_TARGET %d\n",LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_LocalDnaMatchBlock(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [LocalDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LocalDnaMatchBlock_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = LocalDnaMatchBlock_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In LocalDnaMatchBlock matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH65 : temp = cscore - ((mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - ((mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (mat->lchs->g) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH65); } return (*h.access_main)(mat,i - 1,j - 0,MATCH65); } temp = cscore - (mat->lchs->g) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH65) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH65); } return (*h.access_main)(mat,i - 0,j - 1,MATCH65); } temp = cscore - ((mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH65) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH65); } return (*h.access_main)(mat,i - 1,j - 1,MATCH65); } warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH75 : temp = cscore - ((mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - ((mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (mat->lchs->g) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH75) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH75); } return (*h.access_main)(mat,i - 1,j - 0,MATCH75); } temp = cscore - (mat->lchs->g) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH75) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH75); } return (*h.access_main)(mat,i - 0,j - 1,MATCH75); } temp = cscore - ((mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH75) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH75); } return (*h.access_main)(mat,i - 1,j - 1,MATCH75); } warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH85 : temp = cscore - ((mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - ((mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (mat->lchs->g) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH85) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH85); } return (*h.access_main)(mat,i - 1,j - 0,MATCH85); } temp = cscore - (mat->lchs->g) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH85) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH85); } return (*h.access_main)(mat,i - 0,j - 1,MATCH85); } temp = cscore - ((mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH85) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH85); } return (*h.access_main)(mat,i - 1,j - 1,MATCH85); } warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH95 : temp = cscore - ((mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - ((mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v)) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (mat->lchs->g) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH95) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH95); } return (*h.access_main)(mat,i - 1,j - 0,MATCH95); } temp = cscore - (mat->lchs->g) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH95) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH95); } return (*h.access_main)(mat,i - 0,j - 1,MATCH95); } temp = cscore - ((mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH95) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH95); } return (*h.access_main)(mat,i - 1,j - 1,MATCH95); } warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_QUERY : temp = cscore - (mat->lchs->u) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,UNMATCHED_QUERY) ) { *reti = i - 1; *retj = j - 0; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,UNMATCHED_QUERY); } return (*h.access_main)(mat,i - 1,j - 0,UNMATCHED_QUERY); } temp = cscore - (mat->lchs->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH95) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH95); } return (*h.access_main)(mat,i - 1,j - 0,MATCH95); } temp = cscore - (mat->lchs->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH85) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH85); } return (*h.access_main)(mat,i - 1,j - 0,MATCH85); } temp = cscore - (mat->lchs->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH75) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH75); } return (*h.access_main)(mat,i - 1,j - 0,MATCH75); } temp = cscore - (mat->lchs->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH65); } return (*h.access_main)(mat,i - 1,j - 0,MATCH65); } warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_TARGET : temp = cscore - (mat->lchs->u) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_TARGET) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->lchs->v) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_QUERY) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UNMATCHED_QUERY); } return (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_QUERY); } warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_LocalDnaMatchBlock(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [LocalDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LocalDnaMatchBlock_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = LocalDnaMatchBlock_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In LocalDnaMatchBlock matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source MATCH95 is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH95) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH95); } return (*h.access_main)(mat,i - 0,j - 0,MATCH95) ; } } /* end of for i >= 0 */ /* source MATCH85 is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH85) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH85); } return (*h.access_main)(mat,i - 0,j - 0,MATCH85) ; } } /* end of for i >= 0 */ /* source MATCH75 is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH75) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH75); } return (*h.access_main)(mat,i - 0,j - 0,MATCH75) ; } } /* end of for i >= 0 */ /* source MATCH65 is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH65) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH65); } return (*h.access_main)(mat,i - 0,j - 0,MATCH65) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in LocalDnaMatchBlock read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_LocalDnaMatchBlock(mat) * * Descrip: This function calculates the LocalDnaMatchBlock matrix when in explicit mode * To allocate the matrix use /allocate_Expl_LocalDnaMatchBlock * * * Arg: mat [UNKN ] LocalDnaMatchBlock which contains explicit basematrix memory [LocalDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_LocalDnaMatchBlock(LocalDnaMatchBlock * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_LocalDnaMatchBlock, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("LocalDnaMatchBlock Matrix calculation: "); for(j=0;jlchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH65) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH65 */ temp = LocalDnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = score; /* state MATCH65 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH75) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH75) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH75 */ temp = LocalDnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = score; /* state MATCH75 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH85) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH85) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH85 */ temp = LocalDnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = score; /* state MATCH85 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH95) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH95) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH95 */ temp = LocalDnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = score; /* state MATCH95 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->b; /* From state MATCH75 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->lchs->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->lchs->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->lchs->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished calculating state UNMATCHED_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_LocalDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the LocalDnaMatchBlock matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] LocalDnaMatchBlock which contains explicit basematrix memory [LocalDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_LocalDnaMatchBlock, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } } for(j=-1;jlenj;j++) { LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,START) = 0; LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("LocalDnaMatchBlock Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH65 */ /* setting first movement to score */ score = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH65) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH65) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH65 */ temp = LocalDnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = score; /* state MATCH65 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH75) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH75) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH75 */ temp = LocalDnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = score; /* state MATCH75 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH85) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH85) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH85 */ temp = LocalDnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = score; /* state MATCH85 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH95) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->s); /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH95) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->g; if( temp > score ) { score = temp; } /* From state START to state MATCH95 */ temp = LocalDnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-1,START) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->lchs->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->lchs->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = score; /* state MATCH95 is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { LocalDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->lchs->b; /* From state MATCH75 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH75) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH85) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH95) + mat->lchs->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->lchs->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->lchs->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = LocalDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->lchs->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ LocalDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished calculating state UNMATCHED_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: LocalDnaMatchBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalDnaMatchBlock *] * */ LocalDnaMatchBlock * LocalDnaMatchBlock_alloc(void) { LocalDnaMatchBlock * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LocalDnaMatchBlock *) ckalloc (sizeof(LocalDnaMatchBlock))) == NULL) { warn("LocalDnaMatchBlock_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_LocalDnaMatchBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [LocalDnaMatchBlock *] * */ LocalDnaMatchBlock * free_LocalDnaMatchBlock(LocalDnaMatchBlock * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LocalDnaMatchBlock obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->lchs is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/localdba.h0000644000175000001440000005001210670453714016042 0ustar philippusers#ifndef DYNAMITElocaldbaHEADERFILE #define DYNAMITElocaldbaHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "localcispara.h" struct Wise2_LocalDnaMatchBlock { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; ComplexSequence* query; ComplexSequence* target; LocalCisHitScore* lchs; } ; /* LocalDnaMatchBlock defined */ #ifndef DYNAMITE_DEFINED_LocalDnaMatchBlock typedef struct Wise2_LocalDnaMatchBlock Wise2_LocalDnaMatchBlock; #define LocalDnaMatchBlock Wise2_LocalDnaMatchBlock #define DYNAMITE_DEFINED_LocalDnaMatchBlock #endif struct Wise2_LocalDnaMatchBlock_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(LocalDnaMatchBlock*,int,int,int); int (*access_special)(LocalDnaMatchBlock*,int,int,int); } ; /* LocalDnaMatchBlock_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_LocalDnaMatchBlock_access_func_holder typedef struct Wise2_LocalDnaMatchBlock_access_func_holder Wise2_LocalDnaMatchBlock_access_func_holder; #define LocalDnaMatchBlock_access_func_holder Wise2_LocalDnaMatchBlock_access_func_holder #define DYNAMITE_DEFINED_LocalDnaMatchBlock_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_LocalDnaMatchBlock(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_LocalDnaMatchBlock(LocalDnaMatchBlock * mat); #define PackAln_read_Shatter_LocalDnaMatchBlock Wise2_PackAln_read_Shatter_LocalDnaMatchBlock /* Function: calculate_shatter_LocalDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the LocalDnaMatchBlock matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [LocalDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,DPEnvelope * dpenv); #define calculate_shatter_LocalDnaMatchBlock Wise2_calculate_shatter_LocalDnaMatchBlock /* Function: search_LocalDnaMatchBlock(dbsi,out,query,target,lchs) * * Descrip: This function makes a database search of LocalDnaMatchBlock * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: lchs [UNKN ] Undocumented argument [LocalCisHitScore*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_LocalDnaMatchBlock(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs); #define search_LocalDnaMatchBlock Wise2_search_LocalDnaMatchBlock /* Function: serial_search_LocalDnaMatchBlock(out,query,target,lchs) * * Descrip: This function makes a database search of LocalDnaMatchBlock * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: lchs [UNKN ] Undocumented argument [LocalCisHitScore*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_LocalDnaMatchBlock(Hscore * out,ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs); #define serial_search_LocalDnaMatchBlock Wise2_serial_search_LocalDnaMatchBlock /* Function: PackAln_bestmemory_LocalDnaMatchBlock(query,target,lchs,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_LocalDnaMatchBlock * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: lchs [UNKN ] Resource [LocalCisHitScore*] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_LocalDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_LocalDnaMatchBlock Wise2_PackAln_bestmemory_LocalDnaMatchBlock /* Function: allocate_Expl_LocalDnaMatchBlock(query,target,lchs,dpri) * * Descrip: This function allocates the LocalDnaMatchBlock structure * and the basematrix area for explicit memory implementations * It calls /allocate_LocalDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: lchs [UNKN ] Resource [LocalCisHitScore*] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [LocalDnaMatchBlock *] * */ LocalDnaMatchBlock * Wise2_allocate_Expl_LocalDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs,DPRunImpl * dpri); #define allocate_Expl_LocalDnaMatchBlock Wise2_allocate_Expl_LocalDnaMatchBlock /* Function: recalculate_PackAln_LocalDnaMatchBlock(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by LocalDnaMatchBlock * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * */ void Wise2_recalculate_PackAln_LocalDnaMatchBlock(PackAln * pal,LocalDnaMatchBlock * mat); #define recalculate_PackAln_LocalDnaMatchBlock Wise2_recalculate_PackAln_LocalDnaMatchBlock /* Function: allocate_Small_LocalDnaMatchBlock(query,target,lchs) * * Descrip: This function allocates the LocalDnaMatchBlock structure * and the basematrix area for a small memory implementations * It calls /allocate_LocalDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: lchs [UNKN ] Resource [LocalCisHitScore*] * * Return [UNKN ] Undocumented return value [LocalDnaMatchBlock *] * */ LocalDnaMatchBlock * Wise2_allocate_Small_LocalDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs); #define allocate_Small_LocalDnaMatchBlock Wise2_allocate_Small_LocalDnaMatchBlock /* Function: PackAln_calculate_Small_LocalDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates an alignment for LocalDnaMatchBlock structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_LocalDnaMatchBlock * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_LocalDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_LocalDnaMatchBlock Wise2_PackAln_calculate_Small_LocalDnaMatchBlock /* Function: AlnRangeSet_calculate_Small_LocalDnaMatchBlock(mat) * * Descrip: This function calculates an alignment for LocalDnaMatchBlock structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_LocalDnaMatchBlock * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_LocalDnaMatchBlock * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_LocalDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_LocalDnaMatchBlock(LocalDnaMatchBlock * mat); #define AlnRangeSet_calculate_Small_LocalDnaMatchBlock Wise2_AlnRangeSet_calculate_Small_LocalDnaMatchBlock /* Function: AlnRangeSet_from_LocalDnaMatchBlock(mat) * * Descrip: This function reads off a start/end structure * for LocalDnaMatchBlock structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_LocalDnaMatchBlock * If you have not calculated the matrix use * /AlnRange_calculate_Small_LocalDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_LocalDnaMatchBlock(LocalDnaMatchBlock * mat); #define AlnRangeSet_from_LocalDnaMatchBlock Wise2_AlnRangeSet_from_LocalDnaMatchBlock /* Function: convert_PackAln_to_AlnBlock_LocalDnaMatchBlock(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_LocalDnaMatchBlock(PackAln * pal); #define convert_PackAln_to_AlnBlock_LocalDnaMatchBlock Wise2_convert_PackAln_to_AlnBlock_LocalDnaMatchBlock /* Function: PackAln_read_Expl_LocalDnaMatchBlock(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_LocalDnaMatchBlock(LocalDnaMatchBlock * mat); #define PackAln_read_Expl_LocalDnaMatchBlock Wise2_PackAln_read_Expl_LocalDnaMatchBlock /* Function: PackAln_read_generic_LocalDnaMatchBlock(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalDnaMatchBlock *] * Arg: h [UNKN ] Undocumented argument [LocalDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,LocalDnaMatchBlock_access_func_holder h); #define PackAln_read_generic_LocalDnaMatchBlock Wise2_PackAln_read_generic_LocalDnaMatchBlock /* Function: calculate_LocalDnaMatchBlock(mat) * * Descrip: This function calculates the LocalDnaMatchBlock matrix when in explicit mode * To allocate the matrix use /allocate_Expl_LocalDnaMatchBlock * * * Arg: mat [UNKN ] LocalDnaMatchBlock which contains explicit basematrix memory [LocalDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_LocalDnaMatchBlock(LocalDnaMatchBlock * mat); #define calculate_LocalDnaMatchBlock Wise2_calculate_LocalDnaMatchBlock /* Function: calculate_dpenv_LocalDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the LocalDnaMatchBlock matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] LocalDnaMatchBlock which contains explicit basematrix memory [LocalDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,DPEnvelope * dpenv); #define calculate_dpenv_LocalDnaMatchBlock Wise2_calculate_dpenv_LocalDnaMatchBlock /* Function: LocalDnaMatchBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalDnaMatchBlock *] * */ LocalDnaMatchBlock * Wise2_LocalDnaMatchBlock_alloc(void); #define LocalDnaMatchBlock_alloc Wise2_LocalDnaMatchBlock_alloc /* Function: free_LocalDnaMatchBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [LocalDnaMatchBlock *] * */ LocalDnaMatchBlock * Wise2_free_LocalDnaMatchBlock(LocalDnaMatchBlock * obj); #define free_LocalDnaMatchBlock Wise2_free_LocalDnaMatchBlock /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_LocalDnaMatchBlock_shatter_access_main(LocalDnaMatchBlock * mat,int i,int j,int state); #define LocalDnaMatchBlock_shatter_access_main Wise2_LocalDnaMatchBlock_shatter_access_main int Wise2_LocalDnaMatchBlock_shatter_access_special(LocalDnaMatchBlock * mat,int i,int j,int state); #define LocalDnaMatchBlock_shatter_access_special Wise2_LocalDnaMatchBlock_shatter_access_special int Wise2_score_only_LocalDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs); #define score_only_LocalDnaMatchBlock Wise2_score_only_LocalDnaMatchBlock LocalDnaMatchBlock * Wise2_allocate_LocalDnaMatchBlock_only(ComplexSequence* query,ComplexSequence* target ,LocalCisHitScore* lchs); #define allocate_LocalDnaMatchBlock_only Wise2_allocate_LocalDnaMatchBlock_only void Wise2_init_LocalDnaMatchBlock(LocalDnaMatchBlock * mat); #define init_LocalDnaMatchBlock Wise2_init_LocalDnaMatchBlock AlnRange * Wise2_AlnRange_build_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_LocalDnaMatchBlock Wise2_AlnRange_build_LocalDnaMatchBlock boolean Wise2_read_hidden_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_LocalDnaMatchBlock Wise2_read_hidden_LocalDnaMatchBlock int Wise2_max_hidden_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_LocalDnaMatchBlock Wise2_max_hidden_LocalDnaMatchBlock boolean Wise2_read_special_strip_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_LocalDnaMatchBlock Wise2_read_special_strip_LocalDnaMatchBlock int Wise2_max_special_strip_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_LocalDnaMatchBlock Wise2_max_special_strip_LocalDnaMatchBlock int Wise2_max_matrix_to_special_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_LocalDnaMatchBlock Wise2_max_matrix_to_special_LocalDnaMatchBlock void Wise2_calculate_hidden_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_LocalDnaMatchBlock Wise2_calculate_hidden_LocalDnaMatchBlock void Wise2_init_hidden_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_LocalDnaMatchBlock Wise2_init_hidden_LocalDnaMatchBlock boolean Wise2_full_dc_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_LocalDnaMatchBlock Wise2_full_dc_LocalDnaMatchBlock boolean Wise2_do_dc_single_pass_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_LocalDnaMatchBlock Wise2_do_dc_single_pass_LocalDnaMatchBlock void Wise2_push_dc_at_merge_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_LocalDnaMatchBlock Wise2_push_dc_at_merge_LocalDnaMatchBlock void Wise2_follow_on_dc_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_LocalDnaMatchBlock Wise2_follow_on_dc_LocalDnaMatchBlock void Wise2_run_up_dc_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_LocalDnaMatchBlock Wise2_run_up_dc_LocalDnaMatchBlock void Wise2_init_dc_LocalDnaMatchBlock(LocalDnaMatchBlock * mat); #define init_dc_LocalDnaMatchBlock Wise2_init_dc_LocalDnaMatchBlock int Wise2_start_end_find_end_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int * endj); #define start_end_find_end_LocalDnaMatchBlock Wise2_start_end_find_end_LocalDnaMatchBlock boolean Wise2_dc_optimised_start_end_calc_LocalDnaMatchBlock(LocalDnaMatchBlock *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_LocalDnaMatchBlock Wise2_dc_optimised_start_end_calc_LocalDnaMatchBlock void Wise2_init_start_end_linear_LocalDnaMatchBlock(LocalDnaMatchBlock * mat); #define init_start_end_linear_LocalDnaMatchBlock Wise2_init_start_end_linear_LocalDnaMatchBlock AlnConvertSet * Wise2_AlnConvertSet_LocalDnaMatchBlock(void); #define AlnConvertSet_LocalDnaMatchBlock Wise2_AlnConvertSet_LocalDnaMatchBlock int Wise2_LocalDnaMatchBlock_explicit_access_main(LocalDnaMatchBlock * mat,int i,int j,int state); #define LocalDnaMatchBlock_explicit_access_main Wise2_LocalDnaMatchBlock_explicit_access_main int Wise2_LocalDnaMatchBlock_explicit_access_special(LocalDnaMatchBlock * mat,int i,int j,int state); #define LocalDnaMatchBlock_explicit_access_special Wise2_LocalDnaMatchBlock_explicit_access_special int Wise2_find_end_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int * ri,int * rj,int * state,boolean * isspecial,LocalDnaMatchBlock_access_func_holder h); #define find_end_LocalDnaMatchBlock Wise2_find_end_LocalDnaMatchBlock void Wise2_LocalDnaMatchBlock_debug_show_matrix(LocalDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define LocalDnaMatchBlock_debug_show_matrix Wise2_LocalDnaMatchBlock_debug_show_matrix int Wise2_max_calc_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LocalDnaMatchBlock_access_func_holder h); #define max_calc_LocalDnaMatchBlock Wise2_max_calc_LocalDnaMatchBlock int Wise2_max_calc_special_LocalDnaMatchBlock(LocalDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LocalDnaMatchBlock_access_func_holder h); #define max_calc_special_LocalDnaMatchBlock Wise2_max_calc_special_LocalDnaMatchBlock #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/mapstruct.c0000644000175000001440000006147410670453714016334 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "mapstruct.h" # line 33 "mapstruct.dy" MappedCloneMatch * new_MappedCloneMatch(MappedCloneSet * iset,MappedCloneSet * jset,int match,int mismatch) { int i; int j; int ii; int jj; int k; MappedCloneMatch * out; int * buffer; assert(match >= 0 ); assert(mismatch <= 0); assert(iset); assert(jset); out = MappedCloneMatch_alloc_matrix(iset->length,jset->length); buffer = calloc(jset->length,sizeof(int)); for(i=0;ilen;i++) { /* no point even noticing not seen clones */ if( iset->clone[i]->seen == 0 ) { continue; } for(k=0;klength;k++) buffer[k] = 0; for(j=0;jlen;j++) { /* positive scores are easy, as we only have to loop over names */ if( strcmp(iset->clone[i]->clone_name,jset->clone[j]->clone_name) == 0 ) { for(ii=iset->clone[i]->start;iiclone[i]->end;ii++) { for(jj=jset->clone[j]->start;jjclone[j]->end;jj++) { out->matrix[ii][jj] += match; buffer[jj] = 1; } } } } /* now handle negative scores. in the j dimension, where buffer == 0, these regions do not have this particular i clone. As long as this i clone is actually seen (true due to first continue if) then we can substract the mismatch across the i */ for(k=0;klength;k++) { if( buffer[k] == 0 ) { for(ii=iset->clone[i]->start;iiclone[i]->end;ii++) { out->matrix[ii][k] += mismatch; } } } } out->skip_iset = (int*) calloc(iset->length,sizeof(int)); out->skip_jset = (int*) calloc(jset->length,sizeof(int)); for(i=0;ilen;i++) { for(ii=iset->clone[i]->start;iiclone[i]->end;ii++) { if( iset->clone[i]->seen == 1 ) { out->skip_iset += mismatch; } } } for(j=0;jlen;j++) { for(jj=jset->clone[j]->start;jjclone[j]->end;jj++) { if( jset->clone[j]->seen == 1 ) { out->skip_jset += mismatch; } } } return out; } # line 117 "mapstruct.dy" int MappedCloneSet_skip(MappedCloneSet * s,int pos,int skip_cost) { int i; int score = 0; MappedCloneSet * mcs; mcs = subsection_MappedCloneSet(s,pos,pos,1); free_MappedCloneSet(mcs); return skip_cost*mcs->len; } # line 131 "mapstruct.dy" int MappedCloneSet_match(MappedCloneSet * weak_query,MappedCloneSet * trusted_target,int qpos,int tpos,int spread,int match,int mismatch) { MappedCloneSet * weak_slice; MappedCloneSet * trusted_slice; int i; int j; int score =0; weak_slice = subsection_MappedCloneSet(weak_query,qpos-spread,qpos+spread,1); trusted_slice = subsection_MappedCloneSet(trusted_target,tpos-spread,tpos+spread,1); if( weak_slice->len == 0 || trusted_slice->len == 0 ) { score = mismatch; } else { for(i=0;ilen;i++) { for(j=0;jlen;j++) { if( strcmp(weak_slice->clone[i]->clone_name,trusted_slice->clone[j]->clone_name) == 0 ) { score += match; } } } } free_MappedCloneSet(weak_slice); free_MappedCloneSet(trusted_slice); return score; } # line 162 "mapstruct.dy" int old_MappedCloneSet_match(MappedCloneSet * one,MappedCloneSet * two,int qpos,int tpos,int spread,int match,int mismatch) { int i; int startj; int j; int score = 0; int has_matched; /* sorted by start. If positions are before start - return 0 */ if( one->clone[0]->start-spread > qpos ) { return mismatch; } if( two->clone[0]->start-spread > tpos ) { return mismatch; } for(i=0;ilen;i++) { if( one->clone[i]->end+spread >= qpos ) { break; } } for(startj=0;startjlen;startj++) { if( two->clone[startj]->end+spread >= tpos ) { break; } } if( i >= one->len ) { return mismatch; } if( startj >= two->len ) { return mismatch; } for(;ilen && one->clone[i]->start-spread <= qpos;i++) { if( one->clone[i]->seen == 0 ) { continue; } has_matched = 0; for(j=startj;jlen && j < two->clone[j]->start-spread < tpos;j++) { if( two->clone[j]->seen == 0 ) { continue; } if( strcmp(two->clone[j]->clone_name,one->clone[i]->clone_name) == 0 ) { has_matched = 1; break; } } if( has_matched == 1 ) { score += match; } else { score -= mismatch; } } return score; } /* Function: synchronise_MappedCloneSets(one,two) * * Descrip: updates the internal seen flags for the clone sets in * preparation for the dp * * * Arg: one [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: two [UNKN ] Undocumented argument [MappedCloneSet *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 231 "mapstruct.dy" boolean synchronise_MappedCloneSets(MappedCloneSet * one,MappedCloneSet * two) { int i; MappedClone * mc; assert(one); assert(two); for(i=0;ilen;i++) { mc = find_named_MappedClone(two,one->clone[i]->clone_name); if( mc != NULL ) { mc->seen = 1; one->clone[i]->seen = 1; } } return TRUE; } /* Function: subsection_MappedCloneSet(mcs,coord_start,coord_end,only_seen) * * Descrip: Returns a sub-section of the MappedClone * * * Arg: mcs [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: coord_start [UNKN ] Undocumented argument [int] * Arg: coord_end [UNKN ] Undocumented argument [int] * Arg: only_seen [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ # line 255 "mapstruct.dy" MappedCloneSet * subsection_MappedCloneSet(MappedCloneSet * mcs,int coord_start,int coord_end,int only_seen) { MappedCloneSet * out; int i; out = MappedCloneSet_alloc_std(); for(i=0;ilen;i++) { if( mcs->clone[i]->end >= coord_start ) { break; } } if( i >= mcs->len ) { return out; } for(i=0;ilen;i++) { if( only_seen == 1 && mcs->clone[i]->seen == 0 ) { continue; } if( !(mcs->clone[i]->end < coord_start || mcs->clone[i]->start > coord_end) ) { add_MappedCloneSet(out,hard_link_MappedClone(mcs->clone[i])); } if( mcs->clone[i]->start > coord_end ) { break; } } return out; } /* Function: find_named_MappedClone(mcs,clone_name) * * Descrip: Finds a mapped clone set with this name * * * Arg: mcs [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: clone_name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [MappedClone *] * */ # line 294 "mapstruct.dy" MappedClone * find_named_MappedClone(MappedCloneSet * mcs,char * clone_name) { int i; /*we should have hashed. Oooops */ for(i=0;ilen;i++) { if( strcmp(mcs->clone[i]->clone_name,clone_name) == 0 ) { return mcs->clone[i]; } } return NULL; } /* Function: start_comp_MappedClone(a,b) * * Descrip: sorting for MappedClones * * * Arg: a [UNKN ] Undocumented argument [MappedClone *] * Arg: b [UNKN ] Undocumented argument [MappedClone *] * * Return [UNKN ] Undocumented return value [int] * */ # line 312 "mapstruct.dy" int start_comp_MappedClone(MappedClone * a,MappedClone * b) { if( a->start >= b->start ) { return 1; } else { return -1; } } /* Function: read_MappedCloneSet(ifp) * * Descrip: Reads in a MappedCloneSet file * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ # line 325 "mapstruct.dy" MappedCloneSet * read_MappedCloneSet(FILE * ifp) { MappedCloneSet * out; MappedClone * temp; char buffer[512]; out = MappedCloneSet_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"#") == 0 ) { continue; } temp = read_MappedClone_line(buffer); if( temp == NULL ) { continue; } add_MappedCloneSet(out,temp); } sort_MappedCloneSet(out,start_comp_MappedClone); out->length = out->clone[out->len-1]->end; return out; } /* Function: read_MappedClone_line(line) * * Descrip: Provides a mapped clone from a name\tstart\tend format * * * Arg: line [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [MappedClone *] * */ # line 357 "mapstruct.dy" MappedClone * read_MappedClone_line(char * line) { MappedClone * out; char * a; char * b; char * c; char * d; char * e; char * copy; copy = stringalloc(line); out = MappedClone_alloc(); a = strtok(line,spacestr); b = strtok(NULL,spacestr); c = strtok(NULL,spacestr); d = strtok(NULL,spacestr); e = strtok(NULL,spacestr); if( a == NULL || b == NULL || c == NULL || d == NULL || e == NULL ) { warn("Bad clone line %s",copy); ckfree(copy); return NULL; } out->start = atol(a); out->end = atol(b); out->clone_name = stringalloc(c); out->accession = stringalloc(d); out->contig = stringalloc(e); ckfree(copy); return out; } # line 417 "mapstruct.c" /* Function: hard_link_MappedClone(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MappedClone *] * * Return [UNKN ] Undocumented return value [MappedClone *] * */ MappedClone * hard_link_MappedClone(MappedClone * obj) { if( obj == NULL ) { warn("Trying to hard link to a MappedClone object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: MappedClone_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MappedClone *] * */ MappedClone * MappedClone_alloc(void) { MappedClone * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(MappedClone *) ckalloc (sizeof(MappedClone))) == NULL) { warn("MappedClone_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->clone_name = NULL; out->accession = NULL; out->contig = NULL; out->start = 0; out->end = 0; out->seen = 0; return out; } /* Function: free_MappedClone(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MappedClone *] * * Return [UNKN ] Undocumented return value [MappedClone *] * */ MappedClone * free_MappedClone(MappedClone * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a MappedClone obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->clone_name != NULL) ckfree(obj->clone_name); if( obj->accession != NULL) ckfree(obj->accession); if( obj->contig != NULL) ckfree(obj->contig); ckfree(obj); return NULL; } /* Function: swap_MappedCloneSet(list,i,j) * * Descrip: swap function: an internal for qsort_MappedCloneSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [MappedClone **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_MappedCloneSet(MappedClone ** list,int i,int j) { MappedClone * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_MappedCloneSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_MappedCloneSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [MappedClone **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_MappedCloneSet(MappedClone ** list,int left,int right,int (*comp)(MappedClone * ,MappedClone * )) { int i,last; if( left >= right ) return; swap_MappedCloneSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_MappedCloneSet (list,++last,i); } swap_MappedCloneSet (list,left,last); qsort_MappedCloneSet(list,left,last-1,comp); qsort_MappedCloneSet(list,last+1,right,comp); } /* Function: sort_MappedCloneSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_MappedCloneSet * * * Arg: obj [UNKN ] Object containing list [MappedCloneSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_MappedCloneSet(MappedCloneSet * obj,int (*comp)(MappedClone *, MappedClone *)) { qsort_MappedCloneSet(obj->clone,0,obj->len-1,comp); return; } /* Function: expand_MappedCloneSet(obj,len) * * Descrip: Really an internal function for add_MappedCloneSet * * * Arg: obj [UNKN ] Object which contains the list [MappedCloneSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_MappedCloneSet(MappedCloneSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_MappedCloneSet called with no need"); return TRUE; } if( (obj->clone = (MappedClone ** ) ckrealloc (obj->clone,sizeof(MappedClone *)*len)) == NULL) { warn("ckrealloc failed for expand_MappedCloneSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_MappedCloneSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [MappedCloneSet *] * Arg: add [OWNER] Object to add to the list [MappedClone *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_MappedCloneSet(MappedCloneSet * obj,MappedClone * add) { if( obj->len >= obj->maxlen) { if( expand_MappedCloneSet(obj,obj->len + MappedCloneSetLISTLENGTH) == FALSE) return FALSE; } obj->clone[obj->len++]=add; return TRUE; } /* Function: flush_MappedCloneSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [MappedCloneSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_MappedCloneSet(MappedCloneSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->clone[i] != NULL) { free_MappedClone(obj->clone[i]); obj->clone[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: MappedCloneSet_alloc_std(void) * * Descrip: Equivalent to MappedCloneSet_alloc_len(MappedCloneSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ MappedCloneSet * MappedCloneSet_alloc_std(void) { return MappedCloneSet_alloc_len(MappedCloneSetLISTLENGTH); } /* Function: MappedCloneSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ MappedCloneSet * MappedCloneSet_alloc_len(int len) { MappedCloneSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = MappedCloneSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->clone = (MappedClone ** ) ckcalloc (len,sizeof(MappedClone *))) == NULL) { warn("Warning, ckcalloc failed in MappedCloneSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_MappedCloneSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MappedCloneSet *] * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ MappedCloneSet * hard_link_MappedCloneSet(MappedCloneSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a MappedCloneSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: MappedCloneSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ MappedCloneSet * MappedCloneSet_alloc(void) { MappedCloneSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(MappedCloneSet *) ckalloc (sizeof(MappedCloneSet))) == NULL) { warn("MappedCloneSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->clone = NULL; out->len = out->maxlen = 0; out->length = 0; out->cursor = 0; return out; } /* Function: free_MappedCloneSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MappedCloneSet *] * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ MappedCloneSet * free_MappedCloneSet(MappedCloneSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a MappedCloneSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->clone != NULL) { for(i=0;ilen;i++) { if( obj->clone[i] != NULL) free_MappedClone(obj->clone[i]); } ckfree(obj->clone); } ckfree(obj); return NULL; } /* Function: MappedCloneMatch_alloc_matrix(leni,lenj) * * Descrip: Allocates structure and matrix * * * Arg: leni [UNKN ] Length of first dimension of matrix [int] * Arg: lenj [UNKN ] Length of second dimension of matrix [int] * * Return [UNKN ] Undocumented return value [MappedCloneMatch *] * */ MappedCloneMatch * MappedCloneMatch_alloc_matrix(int leni,int lenj) { MappedCloneMatch * out; /* out is exported */ register int i; /* for stepping down matrix */ register int j; /* for stepping across matrix */ /* Call alloc function, return NULL if NULL */ if((out = MappedCloneMatch_alloc()) == NULL) return NULL; /* Allocate memory for matrix */ if((out->matrix = (int **) ckcalloc (leni,sizeof(int *))) == NULL) { warn("Memory allocation problem in matrix for MappedCloneMatch matrix, first pointer set"); ckfree(out); return NULL; } /* Add NULL to all matrix pointers so free can be called */ for(i=0;imatrix[i] = NULL; /* Allocate each matrix row */ for(i=0;imatrix[i] = (int *) ckcalloc (lenj,sizeof(int )); if( out->matrix[i] == NULL) { warn("Failed alloc on %d, calling free and returning NULL",i); free_MappedCloneMatch(out); return NULL; } } for(i=0;imatrix[i][j] = 0; } out->leni=out->maxleni=leni; out->lenj=out->maxlenj=lenj; return out; } /* Function: expand_MappedCloneMatch(obj,leni,lenj) * * Descrip: Expands matrix. Rarely used * * * Arg: obj [UNKN ] Undocumented argument [MappedCloneMatch *] * Arg: leni [UNKN ] Undocumented argument [int] * Arg: lenj [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_MappedCloneMatch(MappedCloneMatch * obj,int leni,int lenj) { int i; int actualj; if( obj == NULL) { warn("Trying to expand a MappedCloneMatch but is NULL!"); return FALSE; } if( leni <= obj->maxleni && lenj <= obj->maxlenj) return TRUE; if( obj->maxleni < leni ) { if( (obj->matrix=(int **) ckrealloc (obj->matrix,sizeof(int *)*leni)) == NULL) return FALSE; obj->maxleni=obj->leni=leni; } if( lenj > obj->maxlenj ) actualj = lenj; else actualj = obj->maxlenj; for(i=0;ileni;i++) { if((obj->matrix[i] = (int *) realloc (obj->matrix[i],sizeof(int ) * actualj)) == NULL) return FALSE; } return TRUE; } /* Function: hard_link_MappedCloneMatch(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MappedCloneMatch *] * * Return [UNKN ] Undocumented return value [MappedCloneMatch *] * */ MappedCloneMatch * hard_link_MappedCloneMatch(MappedCloneMatch * obj) { if( obj == NULL ) { warn("Trying to hard link to a MappedCloneMatch object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: MappedCloneMatch_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MappedCloneMatch *] * */ MappedCloneMatch * MappedCloneMatch_alloc(void) { MappedCloneMatch * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(MappedCloneMatch *) ckalloc (sizeof(MappedCloneMatch))) == NULL) { warn("MappedCloneMatch_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->matrix = NULL; out->leni=out->maxleni=0; out->lenj=out->maxlenj=0; out->skip_iset = NULL; out->skip_jset = NULL; return out; } /* Function: free_MappedCloneMatch(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MappedCloneMatch *] * * Return [UNKN ] Undocumented return value [MappedCloneMatch *] * */ MappedCloneMatch * free_MappedCloneMatch(MappedCloneMatch * obj) { int return_early = 0; int i; int j; if( obj == NULL) { warn("Attempting to free a NULL pointer to a MappedCloneMatch obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->matrix != NULL) { for(i=0;ileni;i++) { if( obj->matrix[i] != NULL) ckfree(obj->matrix[i]); } ckfree(obj->matrix); } if( obj->skip_iset != NULL) ckfree(obj->skip_iset); if( obj->skip_jset != NULL) ckfree(obj->skip_jset); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/mapstruct.h0000644000175000001440000002776710670453714016350 0ustar philippusers#ifndef DYNAMITEmapstructHEADERFILE #define DYNAMITEmapstructHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #define MappedCloneSetLISTLENGTH 1024 struct Wise2_MappedClone { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * clone_name; char * accession; char * contig; int start; int end; int seen; } ; /* MappedClone defined */ #ifndef DYNAMITE_DEFINED_MappedClone typedef struct Wise2_MappedClone Wise2_MappedClone; #define MappedClone Wise2_MappedClone #define DYNAMITE_DEFINED_MappedClone #endif struct Wise2_MappedCloneSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif MappedClone ** clone; int len;/* len for above clone */ int maxlen; /* maxlen for above clone */ int length; int cursor; } ; /* MappedCloneSet defined */ #ifndef DYNAMITE_DEFINED_MappedCloneSet typedef struct Wise2_MappedCloneSet Wise2_MappedCloneSet; #define MappedCloneSet Wise2_MappedCloneSet #define DYNAMITE_DEFINED_MappedCloneSet #endif struct Wise2_MappedCloneMatch { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int ** matrix; /* NB i,j proper */ int leni; /* leni for above matrix */ int maxleni;/* max length for above pointer set */ int lenj; /* lenj for above matrix */ int maxlenj;/* max length for above pointer set */ int * skip_iset; int * skip_jset; } ; /* MappedCloneMatch defined */ #ifndef DYNAMITE_DEFINED_MappedCloneMatch typedef struct Wise2_MappedCloneMatch Wise2_MappedCloneMatch; #define MappedCloneMatch Wise2_MappedCloneMatch #define DYNAMITE_DEFINED_MappedCloneMatch #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: synchronise_MappedCloneSets(one,two) * * Descrip: updates the internal seen flags for the clone sets in * preparation for the dp * * * Arg: one [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: two [UNKN ] Undocumented argument [MappedCloneSet *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_synchronise_MappedCloneSets(MappedCloneSet * one,MappedCloneSet * two); #define synchronise_MappedCloneSets Wise2_synchronise_MappedCloneSets /* Function: subsection_MappedCloneSet(mcs,coord_start,coord_end,only_seen) * * Descrip: Returns a sub-section of the MappedClone * * * Arg: mcs [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: coord_start [UNKN ] Undocumented argument [int] * Arg: coord_end [UNKN ] Undocumented argument [int] * Arg: only_seen [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ MappedCloneSet * Wise2_subsection_MappedCloneSet(MappedCloneSet * mcs,int coord_start,int coord_end,int only_seen); #define subsection_MappedCloneSet Wise2_subsection_MappedCloneSet /* Function: find_named_MappedClone(mcs,clone_name) * * Descrip: Finds a mapped clone set with this name * * * Arg: mcs [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: clone_name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [MappedClone *] * */ MappedClone * Wise2_find_named_MappedClone(MappedCloneSet * mcs,char * clone_name); #define find_named_MappedClone Wise2_find_named_MappedClone /* Function: start_comp_MappedClone(a,b) * * Descrip: sorting for MappedClones * * * Arg: a [UNKN ] Undocumented argument [MappedClone *] * Arg: b [UNKN ] Undocumented argument [MappedClone *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_start_comp_MappedClone(MappedClone * a,MappedClone * b); #define start_comp_MappedClone Wise2_start_comp_MappedClone /* Function: read_MappedCloneSet(ifp) * * Descrip: Reads in a MappedCloneSet file * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ MappedCloneSet * Wise2_read_MappedCloneSet(FILE * ifp) ; #define read_MappedCloneSet Wise2_read_MappedCloneSet /* Function: read_MappedClone_line(line) * * Descrip: Provides a mapped clone from a name\tstart\tend format * * * Arg: line [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [MappedClone *] * */ MappedClone * Wise2_read_MappedClone_line(char * line); #define read_MappedClone_line Wise2_read_MappedClone_line /* Function: hard_link_MappedClone(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MappedClone *] * * Return [UNKN ] Undocumented return value [MappedClone *] * */ MappedClone * Wise2_hard_link_MappedClone(MappedClone * obj); #define hard_link_MappedClone Wise2_hard_link_MappedClone /* Function: MappedClone_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MappedClone *] * */ MappedClone * Wise2_MappedClone_alloc(void); #define MappedClone_alloc Wise2_MappedClone_alloc /* Function: free_MappedClone(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MappedClone *] * * Return [UNKN ] Undocumented return value [MappedClone *] * */ MappedClone * Wise2_free_MappedClone(MappedClone * obj); #define free_MappedClone Wise2_free_MappedClone /* Function: add_MappedCloneSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [MappedCloneSet *] * Arg: add [OWNER] Object to add to the list [MappedClone *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_MappedCloneSet(MappedCloneSet * obj,MappedClone * add); #define add_MappedCloneSet Wise2_add_MappedCloneSet /* Function: flush_MappedCloneSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [MappedCloneSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_MappedCloneSet(MappedCloneSet * obj); #define flush_MappedCloneSet Wise2_flush_MappedCloneSet /* Function: MappedCloneSet_alloc_std(void) * * Descrip: Equivalent to MappedCloneSet_alloc_len(MappedCloneSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ MappedCloneSet * Wise2_MappedCloneSet_alloc_std(void); #define MappedCloneSet_alloc_std Wise2_MappedCloneSet_alloc_std /* Function: MappedCloneSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ MappedCloneSet * Wise2_MappedCloneSet_alloc_len(int len); #define MappedCloneSet_alloc_len Wise2_MappedCloneSet_alloc_len /* Function: hard_link_MappedCloneSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MappedCloneSet *] * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ MappedCloneSet * Wise2_hard_link_MappedCloneSet(MappedCloneSet * obj); #define hard_link_MappedCloneSet Wise2_hard_link_MappedCloneSet /* Function: MappedCloneSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ MappedCloneSet * Wise2_MappedCloneSet_alloc(void); #define MappedCloneSet_alloc Wise2_MappedCloneSet_alloc /* Function: free_MappedCloneSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MappedCloneSet *] * * Return [UNKN ] Undocumented return value [MappedCloneSet *] * */ MappedCloneSet * Wise2_free_MappedCloneSet(MappedCloneSet * obj); #define free_MappedCloneSet Wise2_free_MappedCloneSet /* Function: MappedCloneMatch_alloc_matrix(leni,lenj) * * Descrip: Allocates structure and matrix * * * Arg: leni [UNKN ] Length of first dimension of matrix [int] * Arg: lenj [UNKN ] Length of second dimension of matrix [int] * * Return [UNKN ] Undocumented return value [MappedCloneMatch *] * */ MappedCloneMatch * Wise2_MappedCloneMatch_alloc_matrix(int leni,int lenj); #define MappedCloneMatch_alloc_matrix Wise2_MappedCloneMatch_alloc_matrix /* Function: hard_link_MappedCloneMatch(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MappedCloneMatch *] * * Return [UNKN ] Undocumented return value [MappedCloneMatch *] * */ MappedCloneMatch * Wise2_hard_link_MappedCloneMatch(MappedCloneMatch * obj); #define hard_link_MappedCloneMatch Wise2_hard_link_MappedCloneMatch /* Function: MappedCloneMatch_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MappedCloneMatch *] * */ MappedCloneMatch * Wise2_MappedCloneMatch_alloc(void); #define MappedCloneMatch_alloc Wise2_MappedCloneMatch_alloc /* Function: free_MappedCloneMatch(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MappedCloneMatch *] * * Return [UNKN ] Undocumented return value [MappedCloneMatch *] * */ MappedCloneMatch * Wise2_free_MappedCloneMatch(MappedCloneMatch * obj); #define free_MappedCloneMatch Wise2_free_MappedCloneMatch /* Unplaced functions */ /* There has been no indication of the use of these functions */ MappedCloneMatch * Wise2_new_MappedCloneMatch(MappedCloneSet * iset,MappedCloneSet * jset,int match,int mismatch); #define new_MappedCloneMatch Wise2_new_MappedCloneMatch int Wise2_MappedCloneSet_skip(MappedCloneSet * s,int pos,int skip_cost); #define MappedCloneSet_skip Wise2_MappedCloneSet_skip int Wise2_MappedCloneSet_match(MappedCloneSet * weak_query,MappedCloneSet * trusted_target,int qpos,int tpos,int spread,int match,int mismatch); #define MappedCloneSet_match Wise2_MappedCloneSet_match int Wise2_old_MappedCloneSet_match(MappedCloneSet * one,MappedCloneSet * two,int qpos,int tpos,int spread,int match,int mismatch); #define old_MappedCloneSet_match Wise2_old_MappedCloneSet_match /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_MappedCloneSet(MappedClone ** list,int i,int j) ; #define swap_MappedCloneSet Wise2_swap_MappedCloneSet void Wise2_qsort_MappedCloneSet(MappedClone ** list,int left,int right,int (*comp)(MappedClone * ,MappedClone * )); #define qsort_MappedCloneSet Wise2_qsort_MappedCloneSet void Wise2_sort_MappedCloneSet(MappedCloneSet * obj,int (*comp)(MappedClone *, MappedClone *)); #define sort_MappedCloneSet Wise2_sort_MappedCloneSet boolean Wise2_expand_MappedCloneSet(MappedCloneSet * obj,int len); #define expand_MappedCloneSet Wise2_expand_MappedCloneSet boolean Wise2_expand_MappedCloneMatch(MappedCloneMatch * obj,int leni,int lenj); #define expand_MappedCloneMatch Wise2_expand_MappedCloneMatch #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/pwmdna.dy0000644000175000001440000001537610027305411015754 0ustar philippusers %{ #include "wisebase.h" #include "seqalign.h" #include "randommodel.h" #include "probability.h" #define pwmDNALISTLENGTH 64 #define pwmDNAScoreLISTLENGTH 64 %} struct pwmColScore Score emit[5] %info Actual Scores for a position in a Score representation of a PWM %% struct pwmColProb Probability emit[5] %info Actual probabilities for a position in a PWM %% struct pwmDNA pwmColProb ** pos !list SeqAlign * ref_align; %info This structure holds a position weight matrix as probabilities. Generally you want to use the Score based system for the actual scoring, but this for manipulation of the probabilities You can build this data structure from a simple sequence alignment plus a pseudocount %% struct pwmDNAScore pwmColScore ** pos !list SeqAlign * ref_align; %info This structure holds a position weight matrix as Scores, generally log-odded to a random model This is the structure used for scoring. You make it from a pwmDNA %% %{ #include "pwmdna.h" %func maximum prob of pwmDNA %% double max_prob_pwmDNA(pwmDNA * in) { int i,k; double temp_max; double score = 0.0; for(i=0;ilen;i++) { temp_max = in->pos[i]->emit[0]; for(k=1;k<4;k++) { if( temp_max < in->pos[i]->emit[k] ) { temp_max = in->pos[i]->emit[k]; } } score *= temp_max; } return score; } %func minimum prob of pwmDNA %% double min_prob_pwmDNA(pwmDNA * in) { int i,k; double temp_min; double score = 0.0; for(i=0;ilen;i++) { temp_min = in->pos[i]->emit[0]; for(k=1;k<4;k++) { if( temp_min > in->pos[i]->emit[k] ) { temp_min = in->pos[i]->emit[k]; } } score *= temp_min; } return score; } %func Provides a rotated pwm for randomisation %% pwmDNA * circular_permuted_pwmDNA(pwmDNA * in,int rotate_number) { int i; pwmDNA * out; pwmColProb * col; int j; int pos; assert(in != NULL); out = pwmDNA_alloc_len(in->len); for(i=0;ilen;i++) { pos = (i+rotate_number) % in->len; col = pwmColProb_alloc(); add_pwmDNA(out,col); for(j=0;j<5;j++) { col->emit[j] = in->pos[pos]->emit[j]; } } return out; } %func This gives back a Score from a particular sequence and position %% Score score_pwmDNAScore_Sequence(pwmDNAScore * pds,Sequence * s,int pos) { int score; if( pds->len + pos > s->len ) { warn("For sequence %s, position %d is unable to be matched to pwmDNA of length %d",s->name,pos,pds->len); } score = score_pwmDNAScore_string(pds,s->seq+pos); fprintf(stderr,"Making score %d for %d\n",score,pos); return score; } %func This gives back a Score from a particular string %% Score score_pwmDNAScore_string(pwmDNAScore * pds,char * str) { int i; Score total = 0.0; /* if( strlen(str) < pds->len ) { warn("String [%s] is shorter than the length of the pds. Should not be using it!",str); return NEGI; } */ for(i=0;ilen;i++) total += pds->pos[i]->emit[base_from_char(str[i])]; /* printf("Score %c%c%c to score with %s [%d]\n",str[0],str[1],str[2],pds->ref_align->seq[0]->seq,total);*/ return total; } %func This gives back a Probability from a particular string %% Probability prob_pwmDNA_string(pwmDNA * pds,char * str) { int i; Probability total = 1.0; for(i=0;ilen;i++) { if( str[i] == '\0' ) { return 0.0; } else { total *= pds->pos[i]->emit[base_from_char(str[i])]; /* fprintf(stdout,"As %d, total %.6f with %c\n",i,total,str[i]);*/ } } return total; } %func This folds in a randommodel into pwmDNA %% void fold_randommodel_pwmDNA(pwmDNA * pd,RandomModelDNA * rmd) { int i; int j; assert(pd); assert(rmd); for(i=0;ilen;i++) for(j=0;j<5;j++) if( rmd->base[j] < 0.00000000000000001 ) { warn("Zero base %d, skipping",j); } else { pd->pos[i]->emit[j] /= rmd->base[j]; } } %func This function makes a single pwmDNA from a SeqAlign FIXME: This DOES NOT handle ambiguity codes well %% pwmDNA * pwmDNA_from_SeqAlign(SeqAlign * sa,double simple_pseudocount) { pwmDNA * out; pwmColProb * col; ColumnCount * cc; int i; assert(sa); out = pwmDNA_alloc_std(); out->ref_align = hard_link_SeqAlign(sa); for(i=0;iseq[0]->len;i++) { cc = ColumnCount_from_SeqAlign(sa,i); col = pwmColProb_from_ColumnCount(cc,simple_pseudocount); add_pwmDNA(out,col); free_ColumnCount(cc); } return out; } %func Shows a columns along the page %% void show_pwmDNA_col(pwmDNA * pd,FILE * ofp) { char base[] = "ATGC"; int i; int j; for(j=0;j<4;j++) { fprintf(ofp," %c ",base[j]); for(i=0;ilen;i++) { fprintf(ofp," %.4f ",pd->pos[i]->emit[base_from_char(base[j])]); } fprintf(ofp,"\n"); } } %func This function makes a single pwmColProb from a ColumnCount, applying a simple pseudocount method FIXME: This DOES NOT handle ambiguity codes well %type internal %% pwmColProb * pwmColProb_from_ColumnCount(ColumnCount * cc,double simple_pseudocount) { pwmColProb * out; double total; char base[] = "ATGC"; int i; out = pwmColProb_alloc(); for(i=0,total = 0.0;i<4;i++) total += (cc->count[base[i]-'A'] + simple_pseudocount); for(i=0;i<4;i++) out->emit[base_from_char(base[i])] = (cc->count[base[i]-'A'] + simple_pseudocount) / total; out->emit[4] = 1.0; return out; } %func This function makes score represention of a position weight matrix from a probability, with a random model folded in on-the-fly %% pwmDNAScore * pwmDNAScore_from_pwmDNA_RandomModelDNA(pwmDNA * pwm,RandomModelDNA * rmd) { int i; pwmDNAScore * out; out = pwmDNAScore_alloc_std(); out->ref_align = hard_link_SeqAlign(pwm->ref_align); for(i=0;ilen;i++) { add_pwmDNAScore(out,pwmColScore_from_pwmColProb_rmd(pwm->pos[i],rmd)); } return out; } %func This function makes score represention of a position weight matrix from a probability %% pwmDNAScore * pwmDNAScore_from_pwmDNA(pwmDNA * pwm) { int i; pwmDNAScore * out; out = pwmDNAScore_alloc_std(); out->ref_align = hard_link_SeqAlign(pwm->ref_align); for(i=0;ilen;i++) { add_pwmDNAScore(out,pwmColScore_from_pwmColProb(pwm->pos[i])); } return out; } %func This function makes a score representation of a position weight matrix from a column representation %type internal %% pwmColScore * pwmColScore_from_pwmColProb(pwmColProb * p) { pwmColScore * out; out = pwmColScore_alloc(); Probability2Score_move(p->emit,out->emit,5); return out; } %func This function makes a score representation of a position weight matrix from a column representation, with a RandomModel factored in %type internal %% pwmColScore * pwmColScore_from_pwmColProb_rmd(pwmColProb * p,RandomModelDNA * rmd) { pwmColScore * out; int i; out = pwmColScore_alloc(); for(i=0;i<5;i++) out->emit[i] = Probability2Score(p->emit[i] / rmd->base[i]); return out; } %} wise-2.4.1/src/models/genestretch6.c0000644000175000001440000116051610670453714016711 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genestretch6.h" # line 6 "genestretch6.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define INTRON_0 3 #define INTRON_1 4 #define INTRON_2 5 #define START 0 #define END 1 #define BEFORE_MATCH_CODING 2 #define AFTER_MATCH_CODING 3 #define GeneStretch6_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+10)*6)+STATE][i+1] #define GeneStretch6_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+10] #define GeneStretch6_READ_OFF_ERROR -12 #define GeneStretch6_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+11)%11][((i+1)*6)+STATE] #define GeneStretch6_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+11)%11][STATE] #define GeneStretch6_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define GeneStretch6_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_GeneStretch6(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_GeneStretch6(GeneStretch6 * mat) { GeneStretch6_access_func_holder holder; holder.access_main = GeneStretch6_shatter_access_main; holder.access_special = GeneStretch6_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_GeneStretch6(mat,holder); } /* Function: GeneStretch6_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneStretch6_shatter_access_main(GeneStretch6 * mat,int i,int j,int state) { return GeneStretch6_SHATTER_MATRIX(mat,i,j,state); } /* Function: GeneStretch6_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneStretch6_shatter_access_special(GeneStretch6 * mat,int i,int j,int state) { return GeneStretch6_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_GeneStretch6(mat,dpenv) * * Descrip: This function calculates the GeneStretch6 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneStretch6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_GeneStretch6(GeneStretch6 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_6; int * SIG_1_5; int * SIG_1_4; int * SIG_1_2; int * SIG_1_1; int * SIG_0_3; int * SIG_0_6; int * SIG_0_5; int * SIG_0_4; int * SIG_0_2; int * SIG_0_1; int * SIG_1_0; int * SIG_0_8; int * SIG_0_9; int * SIG_0_10; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,6,lenj,4); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("GeneStretch6 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-6); SIG_1_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-5); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-6); SIG_0_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-5); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); SIG_0_8 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-8); SIG_0_9 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-9); SIG_0_10 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-10); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneStretch6_SHATTER_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_MATCH_CODING to state MATCH */ temp = GeneStretch6_SHATTER_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = SIG_1_6[INTRON_0] + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = SIG_1_5[INTRON_1] + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = SIG_1_4[INTRON_2] + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_1[MATCH] + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_4[MATCH] + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_5[MATCH] + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneStretch6_SHATTER_SPECIAL(mat,i,j,END) ) { GeneStretch6_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* state MATCH is a source for special AFTER_MATCH_CODING */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneStretch6_SHATTER_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) { GeneStretch6_SHATTER_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneStretch6_SHATTER_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = SIG_0_6[INTRON_0] + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = SIG_0_5[INTRON_1] + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = SIG_0_4[INTRON_2] + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_2[INSERT] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[INSERT] = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneStretch6_SHATTER_SPECIAL(mat,i,j,END) ) { GeneStretch6_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneStretch6_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneStretch6_SHATTER_SPECIAL(mat,i,j,END) ) { GeneStretch6_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = SIG_0_8[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = SIG_0_8[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = SIG_0_1[INTRON_0] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_0] = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SIG_0_9[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = SIG_0_9[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = SIG_0_1[INTRON_1] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_1] = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SIG_0_10[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = SIG_0_10[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = SIG_0_1[INTRON_2] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_2] = score; /* Finished calculating state INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_SHATTER_SPECIAL(mat,0,j,END); /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for END */ temp = GeneStretch6_SHATTER_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneStretch6_SHATTER_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_CODING); /* Source START is a special source for BEFORE_MATCH_CODING */ temp = GeneStretch6_SHATTER_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */ temp = GeneStretch6_SHATTER_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneStretch6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score; /* Finished updating state BEFORE_MATCH_CODING */ /* Special state AFTER_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_SHATTER_SPECIAL(mat,0,j,AFTER_MATCH_CODING); /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */ temp = GeneStretch6_SHATTER_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneStretch6_SHATTER_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score; /* Finished updating state AFTER_MATCH_CODING */ } stop_reporting(); return TRUE; } /* Function: search_GeneStretch6(dbsi,out,querydb,targetdb,gp,general_model) * * Descrip: This function makes a database search of GeneStretch6 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: general_model [UNKN ] Undocumented argument [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_GeneStretch6(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp,GeneralGeneModelScore * general_model) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_GeneStretch6 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_GeneStretch6. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_GeneStretch6. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for GeneStretch6, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_GeneStretch6(out,querydb, targetdb ,gp,general_model); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_GeneStretch6 *) ckalloc(sizeof(struct thread_pool_holder_GeneStretch6)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->gp = gp; holder->general_model = general_model; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_GeneStretch6,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for GeneStretch6"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from GeneStretch6",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_GeneStretch6(ptr) * * Descrip: Infinite loop code foreach thread for GeneStretch6 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_GeneStretch6(void * ptr) { struct thread_pool_holder_GeneStretch6 * holder; int db_status; int score; DataScore * ds; GeneWiseScore* query; ComplexSequence* target; holder = (struct thread_pool_holder_GeneStretch6 *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneStretch6"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneStretch6"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_GeneWiseDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in GeneStretch6 search"); } query = hard_link_GeneWiseScore(holder->query); /* get query information into datascore */ dataentry_add_GeneWiseDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_GenomicDB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_GenomicDB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching GeneStretch6, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_GenomicDB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_GeneWiseScore(holder->query); /* get the next query object for the next thread */ holder->query = reload_GeneWiseDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching GeneStretch6, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_GeneWiseDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneStretch6"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneStretch6"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_GenomicDB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_GeneStretch6(query, target ,holder->gp,holder->general_model); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for GeneStretch6"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for GeneStretch6"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneStretch6"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_GeneWiseScore(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneStretch6"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_GeneStretch6(out,querydb,targetdb,gp,general_model) * * Descrip: This function makes a database search of GeneStretch6 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: general_model [UNKN ] Undocumented argument [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_GeneStretch6(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp,GeneralGeneModelScore * general_model) { GeneWiseScore* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GeneWiseDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneStretch6, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_GenomicDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneStretch6, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_GeneStretch6(query, target , gp, general_model); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("GeneStretch6 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GeneWiseDB(ds->query,query,querydb); dataentry_add_GenomicDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_GenomicDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneStretch6, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_GenomicDB(target,targetdb); query = reload_GeneWiseDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching GeneStretch6, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GeneWiseDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_GeneStretch6(query,target,gp,general_model) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_GeneStretch6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_GeneStretch6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model) { int bestscore = NEGI; int i; int j; int k; GeneStretch6 * mat; mat = allocate_GeneStretch6_only(query, target , gp, general_model); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(11,(mat->leni + 1) * 6,11,4)) == NULL) { warn("Score only matrix for GeneStretch6 cannot be allocated, (asking for 10 by %d cells)",mat->leni*6); mat = free_GeneStretch6(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<12;j++) { for(i=(-1);ileni;i++) { for(k=0;k<6;k++) GeneStretch6_VSMALL_MATRIX(mat,i,j,k) = NEGI; } GeneStretch6_VSMALL_SPECIAL(mat,i,j,START) = 0; GeneStretch6_VSMALL_SPECIAL(mat,i,j,END) = NEGI; GeneStretch6_VSMALL_SPECIAL(mat,i,j,BEFORE_MATCH_CODING) = NEGI; GeneStretch6_VSMALL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = GeneStretch6_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneStretch6_VSMALL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_MATCH_CODING to state MATCH */ temp = GeneStretch6_VSMALL_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneStretch6_VSMALL_SPECIAL(mat,i,j,END) ) { GeneStretch6_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* state MATCH is a source for special AFTER_MATCH_CODING */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneStretch6_VSMALL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) { GeneStretch6_VSMALL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneStretch6_VSMALL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneStretch6_VSMALL_SPECIAL(mat,i,j,END) ) { GeneStretch6_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneStretch6_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneStretch6_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneStretch6_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneStretch6_VSMALL_SPECIAL(mat,i,j,END) ) { GeneStretch6_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneStretch6_VSMALL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneStretch6_VSMALL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneStretch6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneStretch6_VSMALL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_VSMALL_SPECIAL(mat,0,j,END); /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for END */ temp = GeneStretch6_VSMALL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneStretch6_VSMALL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING); /* Source START is a special source for BEFORE_MATCH_CODING */ temp = GeneStretch6_VSMALL_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */ temp = GeneStretch6_VSMALL_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneStretch6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score; /* Finished updating state BEFORE_MATCH_CODING */ /* Special state AFTER_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_VSMALL_SPECIAL(mat,0,j,AFTER_MATCH_CODING); /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */ temp = GeneStretch6_VSMALL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneStretch6_VSMALL_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score; /* Finished updating state AFTER_MATCH_CODING */ if( bestscore < GeneStretch6_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = GeneStretch6_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_GeneStretch6(mat); return bestscore; } /* Function: PackAln_bestmemory_GeneStretch6(query,target,gp,general_model,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneStretch6 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_GeneStretch6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; GeneStretch6 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 6 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_GeneStretch6(query, target , gp, general_model,dpri)) == NULL ) { warn("Unable to allocate large GeneStretch6 version"); return NULL; } calculate_dpenv_GeneStretch6(mat,dpenv); out = PackAln_read_Expl_GeneStretch6(mat); } else { mat = allocate_GeneStretch6_only(query, target , gp, general_model); calculate_shatter_GeneStretch6(mat,dpenv); out = PackAln_read_Shatter_GeneStretch6(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_GeneStretch6(query, target , gp, general_model)) == NULL ) { warn("Unable to allocate small GeneStretch6 version"); return NULL; } out = PackAln_calculate_Small_GeneStretch6(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_GeneStretch6(query, target , gp, general_model,dpri)) == NULL ) { warn("Unable to allocate large GeneStretch6 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_GeneStretch6(mat); out = PackAln_read_Expl_GeneStretch6(mat); } } } mat = free_GeneStretch6(mat); return out; } /* Function: allocate_GeneStretch6_only(query,target,gp,general_model) * * Descrip: This function only allocates the GeneStretch6 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [GeneStretch6 *] * */ GeneStretch6 * allocate_GeneStretch6_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model) { GeneStretch6 * out; if((out= GeneStretch6_alloc()) == NULL) { warn("Allocation of basic GeneStretch6 structure failed..."); return NULL; } out->query = query; out->target = target; out->gp = gp; out->general_model = general_model; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_GeneStretch6(query,target,gp,general_model,dpri) * * Descrip: This function allocates the GeneStretch6 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneStretch6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneStretch6 *] * */ GeneStretch6 * allocate_Expl_GeneStretch6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model,DPRunImpl * dpri) { GeneStretch6 * out; out = allocate_GeneStretch6_only(query, target , gp, general_model); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+10)*6 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+10)*6,(out->leni+1),4,out->lenj+10)) == NULL) { warn("Explicit matrix GeneStretch6 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_GeneStretch6(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_GeneStretch6(out); return out; } /* Function: init_GeneStretch6(mat) * * Descrip: This function initates GeneStretch6 matrix when in explicit mode * Called in /allocate_Expl_GeneStretch6 * * * Arg: mat [UNKN ] GeneStretch6 which contains explicit basematrix memory [GeneStretch6 *] * */ void init_GeneStretch6(GeneStretch6 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-10);j<11;j++) { GeneStretch6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } } for(j= (-10);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { GeneStretch6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } GeneStretch6_EXPL_SPECIAL(mat,i,j,START) = 0; GeneStretch6_EXPL_SPECIAL(mat,i,j,END) = NEGI; GeneStretch6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_CODING) = NEGI; GeneStretch6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = NEGI; } return; } /* Function: recalculate_PackAln_GeneStretch6(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneStretch6 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * */ void recalculate_PackAln_GeneStretch6(PackAln * pal,GeneStretch6 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (START+6) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (BEFORE_MATCH_CODING+6) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == INTRON_0 ) { pau->score = (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == INTRON_1 ) { pau->score = ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == INTRON_2 ) { pau->score = ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_INSERT_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_INSERT_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (START+6) ) { pau->score = (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 6 && prev->state == INTRON_0 ) { pau->score = (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 5 && prev->state == INTRON_1 ) { pau->score = ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 4 && prev->state == INTRON_2 ) { pau->score = ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->seg[i]->transition[GW_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (START+6) ) { pau->score = mat->query->seg[i]->transition[GW_START2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_0 : if( offi == 0 && offj == 8 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_0 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_1 : if( offi == 0 && offj == 9 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_1 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_2 : if( offi == 0 && offj == 10 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_2 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+6) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+6) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } if( offj == 3 && prev->state == (AFTER_MATCH_CODING+6) ) { pau->score = mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; case (BEFORE_MATCH_CODING+6) : if( offj == 3 && prev->state == (START+6) ) { pau->score = mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)] + (0); continue; } if( offj == 3 && prev->state == (BEFORE_MATCH_CODING+6) ) { pau->score = mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)] + (0); continue; } warn("In recaluclating PackAln with state BEFORE_MATCH_CODING, got a bad source state. Error!"); break; case (AFTER_MATCH_CODING+6) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 3 && prev->state == (AFTER_MATCH_CODING+6) ) { pau->score = mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)] + (0); continue; } warn("In recaluclating PackAln with state AFTER_MATCH_CODING, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define GeneStretch6_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+10)][(i+1)*6+state]) #define GeneStretch6_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+11)*8) % 88][(i+1)*6+state]) #define GeneStretch6_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+10)]) #define GeneStretch6_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) #define GeneStretch6_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+11)*8)+(shadow+1)) % 88)][(i+1)*6 + state]) #define GeneStretch6_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) #define GeneStretch6_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+10)% 10) * (leni+1) * 6) + ((i+1) * 6) + (state)]) #define GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+10)% 10) * (leni+1) * 48) + ((i+1) * 48) + (state * 8) + shadow+1]) #define GeneStretch6_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) /* Function: allocate_Small_GeneStretch6(query,target,gp,general_model) * * Descrip: This function allocates the GeneStretch6 structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneStretch6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [GeneStretch6 *] * */ #define GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) GeneStretch6 * allocate_Small_GeneStretch6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model) { GeneStretch6 * out; out = allocate_GeneStretch6_only(query, target , gp, general_model); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(88,(out->leni + 1) * 6,32,out->lenj+10); if(out == NULL) { warn("Small shadow matrix GeneStretch6 cannot be allocated, (asking for 11 by %d main cells)",out->leni+2); free_GeneStretch6(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_GeneStretch6(mat,dpenv) * * Descrip: This function calculates an alignment for GeneStretch6 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneStretch6 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneStretch6 * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_GeneStretch6(GeneStretch6 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for GeneStretch6 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneStretch6(mat,dpenv); score = start_end_find_end_GeneStretch6(mat,&endj); out->score = score; stopstate = END; /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */ log_full_error(REPORT,0,"End at %d Score %d",endj,score); stop_reporting(); for(;;) { /*while there are more special bits to recover*/ start_reporting("Special cell aln end %d:",endj); if( read_special_strip_GeneStretch6(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) { warn("Problem in reading off special state system... going to return partial alignment"); break; } if( startstate == START || endj <= 0) { log_full_error(REPORT,0,"Recovered complete alignment"); stop_reporting(); break; } log_full_error(REPORT,0,"Finished to %d",endj); stop_reporting(); /* Ok... have to eat up another piece of matrix */ temp = startstate; starti = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0); startj = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1); startstate = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2); stopi = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3); stopj = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4); stopstate = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5); /* Get out the score of this block. V. important! */ temp = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6); totalj = stopj - startj; donej = 0; start_reporting("Main matrix aln [%d,%d]:",startj,stopj); if(full_dc_GeneStretch6(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) { warn("In the alignment GeneStretch6 [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj); return out; } /* now have to figure out which special we came from... yikes */ max_matrix_to_special_GeneStretch6(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == GeneStretch6_READ_OFF_ERROR) { warn("In GeneStretch6 read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj); invert_PackAln(out); recalculate_PackAln_GeneStretch6(out,mat); return out; } /* if at start, break, otherwise, back to eat another strip */ if( stopstate == START) { log_full_error(REPORT,0,"Recovered complete alignment "); stop_reporting(); break; } log_full_error(REPORT,0,"Finished alignment to %d ",startj); stop_reporting(); endj = stopj; /* stopstate is correct as it is */ } /* end of while there are more special bits to recover */ invert_PackAln(out); recalculate_PackAln_GeneStretch6(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_GeneStretch6(mat) * * Descrip: This function calculates an alignment for GeneStretch6 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneStretch6 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneStretch6 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneStretch6 * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_GeneStretch6(GeneStretch6 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneStretch6(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_GeneStretch6(mat); return out; } /* Function: AlnRangeSet_from_GeneStretch6(mat) * * Descrip: This function reads off a start/end structure * for GeneStretch6 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneStretch6 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneStretch6 * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_GeneStretch6(GeneStretch6 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneStretch6"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_GeneStretch6(mat,&jpos); state = END; while( (temp = AlnRange_build_GeneStretch6(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_GeneStretch6(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_GeneStretch6 * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_GeneStretch6(GeneStretch6 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneStretch6"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_GeneStretch6(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_GeneStretch6 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = GeneStretch6_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_GeneStretch6(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == GeneStretch6_READ_OFF_ERROR) { warn("In AlnRange_build_GeneStretch6 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = GeneStretch6_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_GeneStretch6(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_GeneStretch6(GeneStretch6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_GeneStretch6(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneStretch6_READ_OFF_ERROR) { warn("In GeneStretch6 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In GeneStretch6 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In GeneStretch6 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_GeneStretch6(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_GeneStretch6(GeneStretch6 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneStretch6_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneStretch6 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = GeneStretch6_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp->transition[GP4_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-5,MATCH); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->gp->transition[GP4_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-4,MATCH); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON_2) ) { *reti = i - 1; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-4,INTRON_2); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON_1) ) { *reti = i - 1; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-5,INTRON_1); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON_1); } temp = cscore - ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON_0) ) { *reti = i - 1; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-6,INTRON_0); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON_0); } /* Not allowing special sources.. skipping BEFORE_MATCH_CODING */ /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1); } temp = cscore - ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-3,DELETE); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-8,INSERT); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-8,MATCH); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-9,INSERT); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-9,MATCH); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-10,INSERT); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-10,MATCH); } return GeneStretch6_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_GeneStretch6(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_GeneStretch6(GeneStretch6 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } max_special_strip_GeneStretch6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneStretch6_READ_OFF_ERROR) { warn("In special strip read GeneStretch6, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read GeneStretch6, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_GeneStretch6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_GeneStretch6(GeneStretch6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = GeneStretch6_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for GeneStretch6, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In GeneStretch6 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = GeneStretch6_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source AFTER_MATCH_CODING is a special */ temp = cscore - (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == GeneStretch6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,AFTER_MATCH_CODING) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_DC_SHADOW_SPECIAL(mat,i-0,j-3,AFTER_MATCH_CODING); } return GeneStretch6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,AFTER_MATCH_CODING) ; } /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ case BEFORE_MATCH_CODING : /* source BEFORE_MATCH_CODING is a special */ temp = cscore - (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == GeneStretch6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,BEFORE_MATCH_CODING) ) { *reti = i - 0; *retj = j - 3; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_DC_SHADOW_SPECIAL(mat,i-0,j-3,BEFORE_MATCH_CODING); } return GeneStretch6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,BEFORE_MATCH_CODING) ; } /* source START is a special */ temp = cscore - (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == GeneStretch6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_DC_SHADOW_SPECIAL(mat,i-0,j-3,START); } return GeneStretch6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,START) ; } case AFTER_MATCH_CODING : /* source AFTER_MATCH_CODING is a special */ temp = cscore - (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == GeneStretch6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,AFTER_MATCH_CODING) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_DC_SHADOW_SPECIAL(mat,i-0,j-3,AFTER_MATCH_CODING); } return GeneStretch6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,AFTER_MATCH_CODING) ; } /* Source MATCH is not a special */ default: warn("Major problem (!) - in GeneStretch6 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_GeneStretch6(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_GeneStretch6(GeneStretch6 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = GeneStretch6_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In GeneStretch6 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,BEFORE_MATCH_CODING) ) { *reti = i - 1; *retj = j - 3; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_DC_SHADOW_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING); } return GeneStretch6_DC_SHADOW_MATRIX(mat,i - 1,j - 3,BEFORE_MATCH_CODING) ; } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_DC_SHADOW_SPECIAL(mat,i-1,j-3,START); } return GeneStretch6_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneStretch6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneStretch6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_DC_SHADOW_SPECIAL(mat,i-0,j-3,START); } return GeneStretch6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneStretch6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == GeneStretch6_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneStretch6_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return GeneStretch6_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneStretch6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : /* Source INTRON_0 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneStretch6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : /* Source INTRON_1 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneStretch6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : /* Source INTRON_2 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneStretch6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_GeneStretch6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_GeneStretch6(GeneStretch6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_GeneStretch6(mat,starti,startj,stopi,stopj); GeneStretch6_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneStretch6_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneStretch6_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneStretch6_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneStretch6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneStretch6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneStretch6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneStretch6_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneStretch6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneStretch6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneStretch6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneStretch6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } } return; } /* Function: init_hidden_GeneStretch6(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_GeneStretch6(GeneStretch6 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-10);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { GeneStretch6_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneStretch6_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneStretch6_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneStretch6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneStretch6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneStretch6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; } } return; } /* Function: full_dc_GeneStretch6(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_GeneStretch6 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_GeneStretch6 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [GeneStretch6 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_GeneStretch6(GeneStretch6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_GeneStretch6"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 50) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_GeneStretch6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_GeneStretch6(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_GeneStretch6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for GeneStretch6, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= GeneStretch6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= GeneStretch6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_GeneStretch6(mat,GeneStretch6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),GeneStretch6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),GeneStretch6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_GeneStretch6(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_GeneStretch6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_GeneStretch6(GeneStretch6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_GeneStretch6(mat); GeneStretch6_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_GeneStretch6(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_GeneStretch6(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_GeneStretch6(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_GeneStretch6(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_GeneStretch6(GeneStretch6 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<10;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-100); GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = (-100); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-100); GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = (-100); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-100); GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-6; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_2; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-6; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_2; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ /* For state INTRON_0, pushing when j - offj <= mergej */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( j - 8 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = MATCH; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 8 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INSERT; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INTRON_0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } } /* Add any movement independant score */ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished with state INTRON_0 */ /* For state INTRON_1, pushing when j - offj <= mergej */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( j - 9 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = MATCH; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 9 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INSERT; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INTRON_1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } } /* Add any movement independant score */ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished with state INTRON_1 */ /* For state INTRON_2, pushing when j - offj <= mergej */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( j - 10 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = MATCH; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 10 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INSERT; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } } temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-1; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INTRON_2; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } } /* Add any movement independant score */ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished with state INTRON_2 */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_GeneStretch6(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_GeneStretch6(GeneStretch6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state INTRON_0 to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,k); } /* From state INTRON_1 to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,k); } /* From state INTRON_2 to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,k); } /* From state MATCH to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state DELETE to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } /* From state INTRON_0 to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } /* From state INTRON_1 to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } /* From state INTRON_2 to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } /* From state INSERT to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); /* From state INSERT to state INTRON_0 */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } /* From state INTRON_0 to state INTRON_0 */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); /* From state INSERT to state INTRON_1 */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } /* From state INTRON_1 to state INTRON_1 */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); /* From state INSERT to state INTRON_2 */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } /* From state INTRON_2 to state INTRON_2 */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_GeneStretch6(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_GeneStretch6(GeneStretch6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneStretch6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_GeneStretch6(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * */ } void init_dc_GeneStretch6(GeneStretch6 * mat) { register int i; register int j; register int k; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; for(k=0;k<7;k++) { GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = (-1); GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = (-1); GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = (-1); } } } return; } /* Function: start_end_find_end_GeneStretch6(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [GeneStretch6 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_GeneStretch6(GeneStretch6 * mat,int * endj) { register int j; register int max; register int maxj; max = GeneStretch6_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( GeneStretch6_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = GeneStretch6_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_GeneStretch6(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [GeneStretch6] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_GeneStretch6(GeneStretch6 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (10 * (leni + 1) * 6,sizeof(int)); shadow_pointers = (int *) calloc (10 * (leni + 1) * 6 * 8,sizeof(int)); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state START to state MATCH */ temp = GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state BEFORE_MATCH_CODING to state MATCH */ temp = GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [BEFORE_MATCH_CODING] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_0 to state MATCH */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,0)); } /* From state INTRON_1 to state MATCH */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,0)); } /* From state INTRON_2 to state MATCH */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,0)); } /* From state MATCH to state MATCH */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* state MATCH is a source for special AFTER_MATCH_CODING */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) { GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,k) = GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,6) = GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,3) = i; GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,4) = j; GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state DELETE to state INSERT */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0)); } /* From state START to state INSERT */ temp = GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [START] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_0 to state INSERT */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,0)); } /* From state INTRON_1 to state INSERT */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,0)); } /* From state INTRON_2 to state INSERT */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,0)); } /* From state INSERT to state INSERT */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state START to state DELETE */ temp = GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = DELETE; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,0)); /* From state INSERT to state INTRON_0 */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,0)); } /* From state INTRON_0 to state INTRON_0 */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,0)); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,0)); /* From state INSERT to state INTRON_1 */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,0)); } /* From state INTRON_1 to state INTRON_1 */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,0)); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,0)); /* From state INSERT to state INTRON_2 */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0)); } /* From state INTRON_2 to state INTRON_2 */ temp = GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,0)); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneStretch6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) GeneStretch6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of for each i position in strip */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,0,j,END); /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for END */ temp = GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,AFTER_MATCH_CODING,k); } /* Put back score... (now updated!) */ GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_CODING); /* Source START is a special source for BEFORE_MATCH_CODING */ temp = GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_CODING,k) = GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,START,k); } /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */ temp = GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_CODING,k) = GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,BEFORE_MATCH_CODING,k); } /* Put back score... (now updated!) */ GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score; /* Finished updating state BEFORE_MATCH_CODING */ /* Special state AFTER_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_MATCH_CODING); /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */ temp = GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,k) = GeneStretch6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,AFTER_MATCH_CODING,k); } /* Put back score... (now updated!) */ GeneStretch6_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score; /* Finished updating state AFTER_MATCH_CODING */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_GeneStretch6(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * */ void init_start_end_linear_GeneStretch6(GeneStretch6 * mat) { register int i; register int j; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-1); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-1); GeneStretch6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; GeneStretch6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-1); } } for(j=(-10);jtarget->seq->len;j++) { GeneStretch6_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; GeneStretch6_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); GeneStretch6_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = NEGI; GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_MATCH_CODING,0) = (-1); GeneStretch6_DC_SHADOW_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = NEGI; GeneStretch6_DC_SHADOW_SPECIAL_SP(mat,0,j,AFTER_MATCH_CODING,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_GeneStretch6(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_GeneStretch6(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_GeneStretch6(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","INTRON_STATE","END","BEFORE_MATCH" }; /* Function: AlnConvertSet_GeneStretch6(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","5SS_PHASE_0","CENTRAL_INTRON","5SS_PHASE_1","5SS_PHASE_2","END" }; AlnConvertSet * AlnConvertSet_GeneStretch6(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_MATCH_CODING + 6; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = MATCH; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INSERT; acu->offi = 0; acu->offj = 6; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_MATCH_CODING + 6; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->state2 = BEFORE_MATCH_CODING + 6; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[5]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_MATCH_CODING + 6; acu->state2 = BEFORE_MATCH_CODING + 6; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[5]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = AFTER_MATCH_CODING + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[5]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_MATCH_CODING + 6; acu->state2 = AFTER_MATCH_CODING + 6; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[5]; acu->label2 = target_label[0]; add_collapse_label_AlnConvertSet(out,"INTRON_STATE","CENTRAL_INTRON"); return out; } /* Function: PackAln_read_Expl_GeneStretch6(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_GeneStretch6(GeneStretch6 * mat) { GeneStretch6_access_func_holder holder; holder.access_main = GeneStretch6_explicit_access_main; holder.access_special = GeneStretch6_explicit_access_special; return PackAln_read_generic_GeneStretch6(mat,holder); } /* Function: GeneStretch6_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneStretch6_explicit_access_main(GeneStretch6 * mat,int i,int j,int state) { return GeneStretch6_EXPL_MATRIX(mat,i,j,state); } /* Function: GeneStretch6_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneStretch6_explicit_access_special(GeneStretch6 * mat,int i,int j,int state) { return GeneStretch6_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_GeneStretch6(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: h [UNKN ] Undocumented argument [GeneStretch6_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_GeneStretch6(GeneStretch6 * mat,GeneStretch6_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_GeneStretch6(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in GeneStretch6_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_GeneStretch6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_GeneStretch6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == GeneStretch6_READ_OFF_ERROR || j == GeneStretch6_READ_OFF_ERROR || state == GeneStretch6_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in GeneStretch6_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_GeneStretch6(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [GeneStretch6_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_GeneStretch6(GeneStretch6 * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneStretch6_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: GeneStretch6_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void GeneStretch6_debug_show_matrix(GeneStretch6 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",GeneStretch6_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",GeneStretch6_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",GeneStretch6_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"State INTRON_0 %d\n",GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_0)); fprintf(ofp,"State INTRON_1 %d\n",GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_1)); fprintf(ofp,"State INTRON_2 %d\n",GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_2)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_GeneStretch6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneStretch6_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_GeneStretch6(GeneStretch6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneStretch6_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneStretch6_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneStretch6 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp->transition[GP4_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,MATCH); } return (*h.access_main)(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->gp->transition[GP4_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH); } return (*h.access_main)(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,INTRON_2) ) { *reti = i - 1; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,INTRON_2); } return (*h.access_main)(mat,i - 1,j - 4,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,INTRON_1) ) { *reti = i - 1; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,INTRON_1); } return (*h.access_main)(mat,i - 1,j - 5,INTRON_1); } temp = cscore - ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,INTRON_0) ) { *reti = i - 1; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,INTRON_0); } return (*h.access_main)(mat,i - 1,j - 6,INTRON_0); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 1,j - 3,BEFORE_MATCH_CODING) ) { *reti = i - 1; *retj = j - 3; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,BEFORE_MATCH_CODING); } return (*h.access_main)(mat,i - 1,j - 3,BEFORE_MATCH_CODING); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START); } return (*h.access_main)(mat,i - 1,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 5,INTRON_1); } temp = cscore - ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-6,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 6,INTRON_0); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,START); } return (*h.access_main)(mat,i - 0,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE); } return (*h.access_main)(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,INSERT); } return (*h.access_main)(mat,i - 0,j - 8,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,MATCH); } return (*h.access_main)(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,INSERT); } return (*h.access_main)(mat,i - 0,j - 9,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,MATCH); } return (*h.access_main)(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT); } return (*h.access_main)(mat,i - 0,j - 10,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,MATCH); } return (*h.access_main)(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_GeneStretch6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneStretch6_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_GeneStretch6(GeneStretch6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneStretch6_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneStretch6_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In GeneStretch6 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source AFTER_MATCH_CODING is a special */ temp = cscore - (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,AFTER_MATCH_CODING) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,AFTER_MATCH_CODING); } return (*h.access_special)(mat,i - 0,j - 3,AFTER_MATCH_CODING) ; } /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ case BEFORE_MATCH_CODING : /* source BEFORE_MATCH_CODING is a special */ temp = cscore - (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,BEFORE_MATCH_CODING) ) { *reti = i - 0; *retj = j - 3; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,BEFORE_MATCH_CODING); } return (*h.access_special)(mat,i - 0,j - 3,BEFORE_MATCH_CODING) ; } /* source START is a special */ temp = cscore - (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,START); } return (*h.access_special)(mat,i - 0,j - 3,START) ; } case AFTER_MATCH_CODING : /* source AFTER_MATCH_CODING is a special */ temp = cscore - (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,AFTER_MATCH_CODING) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,AFTER_MATCH_CODING); } return (*h.access_special)(mat,i - 0,j - 3,AFTER_MATCH_CODING) ; } /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in GeneStretch6 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_GeneStretch6(mat) * * Descrip: This function calculates the GeneStretch6 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneStretch6 * * * Arg: mat [UNKN ] GeneStretch6 which contains explicit basematrix memory [GeneStretch6 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_GeneStretch6(GeneStretch6 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneStretch6, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("GeneStretch6 Matrix calculation: "); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneStretch6_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_MATCH_CODING to state MATCH */ temp = GeneStretch6_EXPL_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneStretch6_EXPL_SPECIAL(mat,i,j,END) ) { GeneStretch6_EXPL_SPECIAL(mat,i,j,END) = temp; } /* state MATCH is a source for special AFTER_MATCH_CODING */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneStretch6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) { GeneStretch6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneStretch6_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneStretch6_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneStretch6_EXPL_SPECIAL(mat,i,j,END) ) { GeneStretch6_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneStretch6_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneStretch6_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneStretch6_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneStretch6_EXPL_SPECIAL(mat,i,j,END) ) { GeneStretch6_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneStretch6_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneStretch6_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneStretch6_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_EXPL_SPECIAL(mat,0,j,END); /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for END */ temp = GeneStretch6_EXPL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneStretch6_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING); /* Source START is a special source for BEFORE_MATCH_CODING */ temp = GeneStretch6_EXPL_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */ temp = GeneStretch6_EXPL_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneStretch6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score; /* Finished updating state BEFORE_MATCH_CODING */ /* Special state AFTER_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_EXPL_SPECIAL(mat,0,j,AFTER_MATCH_CODING); /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */ temp = GeneStretch6_EXPL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneStretch6_EXPL_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score; /* Finished updating state AFTER_MATCH_CODING */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_GeneStretch6(mat,dpenv) * * Descrip: This function calculates the GeneStretch6 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneStretch6 which contains explicit basematrix memory [GeneStretch6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_GeneStretch6(GeneStretch6 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneStretch6, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-10;jleni;i++) { GeneStretch6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } } for(j=-10;jlenj;j++) { GeneStretch6_EXPL_SPECIAL(mat,i,j,START) = 0; GeneStretch6_EXPL_SPECIAL(mat,i,j,END) = NEGI; GeneStretch6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_CODING) = NEGI; GeneStretch6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = NEGI; } start_reporting("GeneStretch6 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { GeneStretch6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = GeneStretch6_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneStretch6_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_MATCH_CODING to state MATCH */ temp = GeneStretch6_EXPL_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneStretch6_EXPL_SPECIAL(mat,i,j,END) ) { GeneStretch6_EXPL_SPECIAL(mat,i,j,END) = temp; } /* state MATCH is a source for special AFTER_MATCH_CODING */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneStretch6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) { GeneStretch6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneStretch6_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneStretch6_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneStretch6_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneStretch6_EXPL_SPECIAL(mat,i,j,END) ) { GeneStretch6_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneStretch6_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneStretch6_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneStretch6_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneStretch6_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneStretch6_EXPL_SPECIAL(mat,i,j,END) ) { GeneStretch6_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneStretch6_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneStretch6_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneStretch6_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneStretch6_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneStretch6_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_EXPL_SPECIAL(mat,0,j,END); /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for END */ temp = GeneStretch6_EXPL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneStretch6_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING); /* Source START is a special source for BEFORE_MATCH_CODING */ temp = GeneStretch6_EXPL_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */ temp = GeneStretch6_EXPL_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneStretch6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score; /* Finished updating state BEFORE_MATCH_CODING */ /* Special state AFTER_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneStretch6_EXPL_SPECIAL(mat,0,j,AFTER_MATCH_CODING); /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */ temp = GeneStretch6_EXPL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneStretch6_EXPL_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score; /* Finished updating state AFTER_MATCH_CODING */ } stop_reporting(); return TRUE; } /* Function: GeneStretch6_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneStretch6 *] * */ GeneStretch6 * GeneStretch6_alloc(void) { GeneStretch6 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneStretch6 *) ckalloc (sizeof(GeneStretch6))) == NULL) { warn("GeneStretch6_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_GeneStretch6(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneStretch6 *] * * Return [UNKN ] Undocumented return value [GeneStretch6 *] * */ GeneStretch6 * free_GeneStretch6(GeneStretch6 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneStretch6 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->gp is linked in */ /* obj->general_model is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/genestretch6.h0000644000175000001440000005023310670453714016707 0ustar philippusers#ifndef DYNAMITEgenestretch6HEADERFILE #define DYNAMITEgenestretch6HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "geneparser4.h" #include "genewisemodel.h" #include "genewisemodeldb.h" #include "genestats.h" struct Wise2_GeneStretch6 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GeneWiseScore* query; ComplexSequence* target; GeneParser4Score * gp; GeneralGeneModelScore * general_model; } ; /* GeneStretch6 defined */ #ifndef DYNAMITE_DEFINED_GeneStretch6 typedef struct Wise2_GeneStretch6 Wise2_GeneStretch6; #define GeneStretch6 Wise2_GeneStretch6 #define DYNAMITE_DEFINED_GeneStretch6 #endif #ifdef PTHREAD struct thread_pool_holder_GeneStretch6 { GeneWiseScore* query; /* Query object placeholder */ GeneWiseDB* querydb;/* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ GenomicDB* targetdb;/* Target database object */ boolean target_init; GeneParser4Score * gp; GeneralGeneModelScore * general_model; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_GeneStretch6_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(GeneStretch6*,int,int,int); int (*access_special)(GeneStretch6*,int,int,int); } ; /* GeneStretch6_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_GeneStretch6_access_func_holder typedef struct Wise2_GeneStretch6_access_func_holder Wise2_GeneStretch6_access_func_holder; #define GeneStretch6_access_func_holder Wise2_GeneStretch6_access_func_holder #define DYNAMITE_DEFINED_GeneStretch6_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_GeneStretch6(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_GeneStretch6(GeneStretch6 * mat); #define PackAln_read_Shatter_GeneStretch6 Wise2_PackAln_read_Shatter_GeneStretch6 /* Function: calculate_shatter_GeneStretch6(mat,dpenv) * * Descrip: This function calculates the GeneStretch6 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneStretch6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_GeneStretch6(GeneStretch6 * mat,DPEnvelope * dpenv); #define calculate_shatter_GeneStretch6 Wise2_calculate_shatter_GeneStretch6 /* Function: search_GeneStretch6(dbsi,out,querydb,targetdb,gp,general_model) * * Descrip: This function makes a database search of GeneStretch6 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: general_model [UNKN ] Undocumented argument [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_GeneStretch6(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp,GeneralGeneModelScore * general_model); #define search_GeneStretch6 Wise2_search_GeneStretch6 /* Function: serial_search_GeneStretch6(out,querydb,targetdb,gp,general_model) * * Descrip: This function makes a database search of GeneStretch6 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: general_model [UNKN ] Undocumented argument [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_GeneStretch6(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp,GeneralGeneModelScore * general_model); #define serial_search_GeneStretch6 Wise2_serial_search_GeneStretch6 /* Function: PackAln_bestmemory_GeneStretch6(query,target,gp,general_model,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneStretch6 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_GeneStretch6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_GeneStretch6 Wise2_PackAln_bestmemory_GeneStretch6 /* Function: allocate_Expl_GeneStretch6(query,target,gp,general_model,dpri) * * Descrip: This function allocates the GeneStretch6 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneStretch6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneStretch6 *] * */ GeneStretch6 * Wise2_allocate_Expl_GeneStretch6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model,DPRunImpl * dpri); #define allocate_Expl_GeneStretch6 Wise2_allocate_Expl_GeneStretch6 /* Function: recalculate_PackAln_GeneStretch6(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneStretch6 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * */ void Wise2_recalculate_PackAln_GeneStretch6(PackAln * pal,GeneStretch6 * mat); #define recalculate_PackAln_GeneStretch6 Wise2_recalculate_PackAln_GeneStretch6 /* Function: allocate_Small_GeneStretch6(query,target,gp,general_model) * * Descrip: This function allocates the GeneStretch6 structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneStretch6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [GeneStretch6 *] * */ GeneStretch6 * Wise2_allocate_Small_GeneStretch6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model); #define allocate_Small_GeneStretch6 Wise2_allocate_Small_GeneStretch6 /* Function: PackAln_calculate_Small_GeneStretch6(mat,dpenv) * * Descrip: This function calculates an alignment for GeneStretch6 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneStretch6 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneStretch6 * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_GeneStretch6(GeneStretch6 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_GeneStretch6 Wise2_PackAln_calculate_Small_GeneStretch6 /* Function: AlnRangeSet_calculate_Small_GeneStretch6(mat) * * Descrip: This function calculates an alignment for GeneStretch6 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneStretch6 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneStretch6 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneStretch6 * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_GeneStretch6(GeneStretch6 * mat); #define AlnRangeSet_calculate_Small_GeneStretch6 Wise2_AlnRangeSet_calculate_Small_GeneStretch6 /* Function: AlnRangeSet_from_GeneStretch6(mat) * * Descrip: This function reads off a start/end structure * for GeneStretch6 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneStretch6 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneStretch6 * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_GeneStretch6(GeneStretch6 * mat); #define AlnRangeSet_from_GeneStretch6 Wise2_AlnRangeSet_from_GeneStretch6 /* Function: convert_PackAln_to_AlnBlock_GeneStretch6(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_GeneStretch6(PackAln * pal); #define convert_PackAln_to_AlnBlock_GeneStretch6 Wise2_convert_PackAln_to_AlnBlock_GeneStretch6 /* Function: PackAln_read_Expl_GeneStretch6(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_GeneStretch6(GeneStretch6 * mat); #define PackAln_read_Expl_GeneStretch6 Wise2_PackAln_read_Expl_GeneStretch6 /* Function: PackAln_read_generic_GeneStretch6(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneStretch6 *] * Arg: h [UNKN ] Undocumented argument [GeneStretch6_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_GeneStretch6(GeneStretch6 * mat,GeneStretch6_access_func_holder h); #define PackAln_read_generic_GeneStretch6 Wise2_PackAln_read_generic_GeneStretch6 /* Function: calculate_GeneStretch6(mat) * * Descrip: This function calculates the GeneStretch6 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneStretch6 * * * Arg: mat [UNKN ] GeneStretch6 which contains explicit basematrix memory [GeneStretch6 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_GeneStretch6(GeneStretch6 * mat); #define calculate_GeneStretch6 Wise2_calculate_GeneStretch6 /* Function: calculate_dpenv_GeneStretch6(mat,dpenv) * * Descrip: This function calculates the GeneStretch6 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneStretch6 which contains explicit basematrix memory [GeneStretch6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_GeneStretch6(GeneStretch6 * mat,DPEnvelope * dpenv); #define calculate_dpenv_GeneStretch6 Wise2_calculate_dpenv_GeneStretch6 /* Function: GeneStretch6_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneStretch6 *] * */ GeneStretch6 * Wise2_GeneStretch6_alloc(void); #define GeneStretch6_alloc Wise2_GeneStretch6_alloc /* Function: free_GeneStretch6(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneStretch6 *] * * Return [UNKN ] Undocumented return value [GeneStretch6 *] * */ GeneStretch6 * Wise2_free_GeneStretch6(GeneStretch6 * obj); #define free_GeneStretch6 Wise2_free_GeneStretch6 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_GeneStretch6_shatter_access_main(GeneStretch6 * mat,int i,int j,int state); #define GeneStretch6_shatter_access_main Wise2_GeneStretch6_shatter_access_main int Wise2_GeneStretch6_shatter_access_special(GeneStretch6 * mat,int i,int j,int state); #define GeneStretch6_shatter_access_special Wise2_GeneStretch6_shatter_access_special void * Wise2_thread_loop_GeneStretch6(void * ptr); #define thread_loop_GeneStretch6 Wise2_thread_loop_GeneStretch6 int Wise2_score_only_GeneStretch6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model); #define score_only_GeneStretch6 Wise2_score_only_GeneStretch6 GeneStretch6 * Wise2_allocate_GeneStretch6_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model); #define allocate_GeneStretch6_only Wise2_allocate_GeneStretch6_only void Wise2_init_GeneStretch6(GeneStretch6 * mat); #define init_GeneStretch6 Wise2_init_GeneStretch6 AlnRange * Wise2_AlnRange_build_GeneStretch6(GeneStretch6 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_GeneStretch6 Wise2_AlnRange_build_GeneStretch6 boolean Wise2_read_hidden_GeneStretch6(GeneStretch6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_GeneStretch6 Wise2_read_hidden_GeneStretch6 int Wise2_max_hidden_GeneStretch6(GeneStretch6 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_GeneStretch6 Wise2_max_hidden_GeneStretch6 boolean Wise2_read_special_strip_GeneStretch6(GeneStretch6 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_GeneStretch6 Wise2_read_special_strip_GeneStretch6 int Wise2_max_special_strip_GeneStretch6(GeneStretch6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_GeneStretch6 Wise2_max_special_strip_GeneStretch6 int Wise2_max_matrix_to_special_GeneStretch6(GeneStretch6 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_GeneStretch6 Wise2_max_matrix_to_special_GeneStretch6 void Wise2_calculate_hidden_GeneStretch6(GeneStretch6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_GeneStretch6 Wise2_calculate_hidden_GeneStretch6 void Wise2_init_hidden_GeneStretch6(GeneStretch6 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_GeneStretch6 Wise2_init_hidden_GeneStretch6 boolean Wise2_full_dc_GeneStretch6(GeneStretch6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_GeneStretch6 Wise2_full_dc_GeneStretch6 boolean Wise2_do_dc_single_pass_GeneStretch6(GeneStretch6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_GeneStretch6 Wise2_do_dc_single_pass_GeneStretch6 void Wise2_push_dc_at_merge_GeneStretch6(GeneStretch6 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_GeneStretch6 Wise2_push_dc_at_merge_GeneStretch6 void Wise2_follow_on_dc_GeneStretch6(GeneStretch6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_GeneStretch6 Wise2_follow_on_dc_GeneStretch6 void Wise2_run_up_dc_GeneStretch6(GeneStretch6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_GeneStretch6 Wise2_run_up_dc_GeneStretch6 void Wise2_init_dc_GeneStretch6(GeneStretch6 * mat); #define init_dc_GeneStretch6 Wise2_init_dc_GeneStretch6 int Wise2_start_end_find_end_GeneStretch6(GeneStretch6 * mat,int * endj); #define start_end_find_end_GeneStretch6 Wise2_start_end_find_end_GeneStretch6 boolean Wise2_dc_optimised_start_end_calc_GeneStretch6(GeneStretch6 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_GeneStretch6 Wise2_dc_optimised_start_end_calc_GeneStretch6 void Wise2_init_start_end_linear_GeneStretch6(GeneStretch6 * mat); #define init_start_end_linear_GeneStretch6 Wise2_init_start_end_linear_GeneStretch6 AlnConvertSet * Wise2_AlnConvertSet_GeneStretch6(void); #define AlnConvertSet_GeneStretch6 Wise2_AlnConvertSet_GeneStretch6 int Wise2_GeneStretch6_explicit_access_main(GeneStretch6 * mat,int i,int j,int state); #define GeneStretch6_explicit_access_main Wise2_GeneStretch6_explicit_access_main int Wise2_GeneStretch6_explicit_access_special(GeneStretch6 * mat,int i,int j,int state); #define GeneStretch6_explicit_access_special Wise2_GeneStretch6_explicit_access_special int Wise2_find_end_GeneStretch6(GeneStretch6 * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneStretch6_access_func_holder h); #define find_end_GeneStretch6 Wise2_find_end_GeneStretch6 void Wise2_GeneStretch6_debug_show_matrix(GeneStretch6 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define GeneStretch6_debug_show_matrix Wise2_GeneStretch6_debug_show_matrix int Wise2_max_calc_GeneStretch6(GeneStretch6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneStretch6_access_func_holder h); #define max_calc_GeneStretch6 Wise2_max_calc_GeneStretch6 int Wise2_max_calc_special_GeneStretch6(GeneStretch6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneStretch6_access_func_holder h); #define max_calc_special_GeneStretch6 Wise2_max_calc_special_GeneStretch6 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/abc.dy0000644000175000001440000000234407313404542015213 0ustar philippusers %{ #include "dyna.h" %} matrix abc query type="PROTEIN" name="query" target type="PROTEIN" name="target" resource type="COMPMAT" name="comp" resource type="int" name="a" resource type="int" name="b" resource type="int" name="c" state MATCH offi="1" offj="1" calc="AAMATCH(comp,AMINOACID(query,i),AMINOACID(target,j))" source MATCH calc="0" endsource source INSERT calc="0" endsource source START calc="0" endsource query_label SEQUENCE target_label SEQUENCE endstate state INSERT source MATCH offi="1" offj="0" calc="a + b" target_label INSERT endsource source MATCH offi="0" offj="1" calc="a + b" query_label INSERT endsource source MATCH offi="1" offj="1" calc="a + c" endsource source INSERT offi="1" offj="0" calc="b" target_label INSERT endsource source INSERT offi="0" offj="1" calc="b" query_label INSERT endsource source INSERT offi="1" offj="1" calc="c" endsource query_label UNMATCHED_SEQUENCE target_label UNMATCHED_SEQUENCE endstate state START !special !start query_label START target_label START endstate state END !special !end source MATCH calc="0" endsource query_label END target_label END endstate endmatrix %{ #include "abc.h" %} wise-2.4.1/src/models/syexonmodel.dy0000644000175000001440000000365007502704706017042 0ustar philippusers %{ #include "dyna.h" #define SyExonModelLISTLENGTH 128 #define SyExonScoreLISTLENGTH 128 %} struct SyExon Probability exit_prob Probability stay_prob Probability prev_prob struct SyExonScoreUnit Score exit_score Score stay_score struct SyExonModel SyExon ** exon !list struct SyExonScore SyExonScoreUnit ** exon !list %{ #include "syexonmodel.h" SyExonScore * SyExonScore_flat_model(int start,int end,Probability exit,Probability final_stay) { SyExonScore * out; SyExonModel * m; m = SyExonModel_flat_model(start,end,exit,final_stay); out = SyExonScore_from_SyExonModel(m); free_SyExonModel(m); return out; } SyExonModel * SyExonModel_flat_model(int start,int end,Probability exit,Probability final_stay) { int i; SyExon * e; SyExonModel * out; Probability prev; out = SyExonModel_alloc_len(end); prev = 0.0; for(i=0;iexit_prob = 0.0; e->stay_prob = 0.0; e->prev_prob = prev; prev = 1.0; } else { e->exit_prob = exit; e->stay_prob = 0.0; e->prev_prob = prev; prev = 1.0-exit; } if( i+3 > end ) { e->stay_prob = final_stay; } } return out; } SyExonScore * SyExonScore_from_SyExonModel(SyExonModel * sym) { int i; SyExonScore * out; out = SyExonScore_alloc_len(sym->len); for(i=0;ilen;i++) { add_SyExonScore(out,SyExonScoreUnit_from_SyExon(sym->exon[i])); } return out; } SyExonScoreUnit * SyExonScoreUnit_from_SyExon(SyExon * sye) { SyExonScoreUnit * out; out = SyExonScoreUnit_alloc(); out->exit_score = Probability2Score(sye->exit_prob); out->stay_score = Probability2Score(sye->stay_prob); return out; } void dump_SyExonScore(SyExonScore * sc,FILE *ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,"%d exit %d stay %d\n",i,sc->exon[i]->exit_score,sc->exon[i]->stay_score); } } wise-2.4.1/src/models/proteinsw.dy0000644000175000001440000000202407313404547016520 0ustar philippusers %{ #include "dyna.h" %} matrix ProteinSW query type="PROTEIN" name="query" target type="PROTEIN" name="target" resource type="COMPMAT" name="comp" resource type="int" name="gap" resource type="int" name="ext" state MATCH offi="1" offj="1" calc="AAMATCH(comp,AMINOACID(query,i),AMINOACID(target,j))" source MATCH calc="0" endsource source INSERT calc="0" endsource source DELETE calc="0" endsource source START calc="0" endsource query_label SEQUENCE target_label SEQUENCE endstate state INSERT offi="0" offj="1" source MATCH calc="gap" endsource source INSERT calc="ext" endsource query_label INSERT target_label SEQUENCE endstate state DELETE offi="1" offj="0" source MATCH calc="gap" endsource source DELETE calc="ext" endsource query_label SEQUENCE target_label INSERT endstate state START !special !start query_label START target_label START endstate state END !special !end source MATCH calc="0" endsource query_label END target_label END endstate endmatrix wise-2.4.1/src/models/promotercluster.c0000644000175000001440000000314610052363765017553 0ustar philippusers#include "dnaprofileengine.h" #include "version.h" char * program_name = "promotercluster"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s fasta-file-for-promoter-set\n",program_name); show_help_DnaProfileEnginePara(ofp); show_standard_options(ofp); } int main(int argc,char ** argv) { DnaProfileEnginePara * dpep; DnaProfileNode * root; DnaProfileSet * set; FILE * ifp; boolean is_four = FALSE; dpep = new_DnaProfileEnginePara_from_argv(&argc,argv); is_four = strip_out_boolean_argument(&argc,argv,"bfour"); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 2 ) { show_help(stdout); exit(12); } ifp = openfile(argv[1],"r"); if( ifp == NULL ) { fatal("could not open file %s",argv[1]); } if( is_four ) { root = balanced_4_Sequence_fasta_stream(ifp); } else { root = simple_cascade_Sequence_fasta_stream(ifp); } populate_DnaProfileNode_from_root(root,dpep); /*set = filter_DnaProfileSet(root->set,0,0);*/ show_DnaProfileSet(root->set,dpep->rm,stdout); return 0; } wise-2.4.1/src/models/fivestate.dy0000644000175000001440000000613507457773426016505 0ustar philippusers %{ #include "fivestatemodel.h" %} matrix FiveStateProtein query type="FiveStateScore*" name="query" target type="PROTEIN" name="target" state MATCH offi="1" offj="1" calc="query->unit[i]->match[AMINOACID(target,j)]" source MATCH calc="query->unit[i]->transition[FSM_MATCH2MATCH]" endsource source INSERT calc="query->unit[i]->transition[FSM_INSERT2MATCH]" endsource source DELETE calc="query->unit[i]->transition[FSM_DELETE2MATCH]" endsource source START calc="query->unit[i]->transition[FSM_START2MATCH]" endsource source INBOUND calc="query->unit[i]->transition[FSM_INBOUND2MATCH]" endsource source OUTBOUND calc="query->unit[i]->transition[FSM_OUTBOUND2MATCH]" endsource query_label SEQUENCE target_label SEQUENCE endstate state INSERT offi="0" offj="1" calc="query->unit[i]->insert[AMINOACID(target,j)]" source MATCH calc="query->unit[i]->transition[FSM_MATCH2INSERT]" endsource source INSERT calc="query->unit[i]->transition[FSM_INSERT2INSERT]" endsource source DELETE calc="query->unit[i]->transition[FSM_DELETE2INSERT]" endsource source START calc="query->unit[i]->transition[FSM_START2INSERT]" endsource source OUTBOUND calc="query->unit[i]->transition[FSM_OUTBOUND2INSERT]" endsource query_label INSERT target_label SEQUENCE endstate state DELETE offi="1" offj="0" source MATCH calc="query->unit[i]->transition[FSM_MATCH2DELETE]" endsource source INSERT calc="query->unit[i]->transition[FSM_INSERT2DELETE]" endsource source DELETE calc="query->unit[i]->transition[FSM_DELETE2DELETE]" endsource source START calc="query->unit[i]->transition[FSM_START2DELETE]" endsource source OUTBOUND calc="query->unit[i]->transition[FSM_OUTBOUND2DELETE]" endsource query_label SEQUENCE target_label INSERT endstate state OUTBOUND offi="1" offj="0" source MATCH calc="query->unit[i]->transition[FSM_MATCH2OUTBOUND]" endsource source INSERT calc="query->unit[i]->transition[FSM_INSERT2OUTBOUND]" endsource source DELETE calc="query->unit[i]->transition[FSM_DELETE2OUTBOUND]" endsource source OUTBOUND calc="query->unit[i]->transition[FSM_OUTBOUND2OUTBOUND]" endsource query_label OUTBOUND_STATE target_label INSERT endstate state INBOUND offi="1" offj="0" source INBOUND calc="query->unit[i]->transition[FSM_INBOUND2INBOUND]" endsource source OUTBOUND calc="query->unit[i]->transition[FSM_OUTBOUND2INBOUND]" endsource source START calc="query->unit[i]->transition[FSM_START2INBOUND]" endsource query_label INBOUND_STATE target_label INSERT endstate state START !special !start endstate state END !special !end source MATCH calc="query->unit[i]->transition[FSM_MATCH2END]" endsource source INSERT calc="query->unit[i]->transition[FSM_INSERT2END]" endsource source DELETE calc="query->unit[i]->transition[FSM_DELETE2END]" endsource source INBOUND calc="query->unit[i]->transition[FSM_INBOUND2END]" endsource source OUTBOUND calc="query->unit[i]->transition[FSM_OUTBOUND2END]" endsource query_label END target_label END endstate endmatrix wise-2.4.1/src/models/geneoutput.c0000644000175000001440000001731510670453714016504 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "geneoutput.h" # line 35 "geneoutput.dy" void show_GeneOutput(GeneOutputData * data,GeneOutputPara * para,FILE * ofp) { Protein * trans; cDNA * cdna; int i; assert(data); assert(data->ct); assert(data->gr); assert(data->gen); if( para->show_genes ) { show_pretty_GenomicRegion(data->gr,0,ofp); fprintf(stdout,"%s\n",para->divide_string); } if( para->show_gff ) { show_GFF_GenomicRegion(data->gr,data->gen->baseseq->name,"genomwise",stdout); fprintf(stdout,"%s\n",para->divide_string); } if( para->show_trans ) { for(i=0;igr->len;i++) { if( data->gr->gene[i]->ispseudo == TRUE ) { fprintf(stdout,"#Gene %d is a pseudo gene - no translation possible\n",i); } else { trans = get_Protein_from_Translation(data->gr->gene[i]->transcript[0]->translation[0],data->ct); write_fasta_Sequence(trans->baseseq,ofp); } } fprintf(stdout,"%s\n",para->divide_string); } if( para->show_cdna ) { for(i=0;igr->len;i++) { cdna = get_cDNA_from_Transcript(data->gr->gene[i]->transcript[0]); write_fasta_Sequence(cdna->baseseq,ofp); } fprintf(stdout,"%s\n",para->divide_string); } if( para->show_geneutr ) { show_utr_exon_genomewise(data->alb,ofp); fprintf(stdout,"%s\n",para->divide_string); } } # line 86 "geneoutput.dy" double id_map_func(int i) { return (double)i; } # line 91 "geneoutput.dy" GeneOutputPara * new_GeneOutputPara_from_argv(int * argc,char ** argv) { GeneOutputPara * out; out = GeneOutputPara_alloc(); out->show_genes = 1; out->show_trans = 1; out->divide_string = stringalloc("//"); strip_out_boolean_def_argument(argc,argv,"geneutr",&out->show_geneutr); strip_out_boolean_def_argument(argc,argv,"genes",&out->show_genes); strip_out_boolean_def_argument(argc,argv,"trans",&out->show_trans); strip_out_boolean_def_argument(argc,argv,"gff",&out->show_gff); strip_out_boolean_def_argument(argc,argv,"cdna",&out->show_cdna); strip_out_boolean_def_argument(argc,argv,"genedebug",&out->show_debug); return out; } # line 111 "geneoutput.dy" void show_help_GeneOutputPara(FILE * ofp) { fprintf(ofp,"Gene Output\n"); fprintf(ofp," -[no]genes show gene structure (default yes)\n"); fprintf(ofp," -[no]geneutr show gene structure with utrs (default no)\n"); fprintf(ofp," -[no]trans show protein translation (default yes)\n"); fprintf(ofp," -[no]gff show gff (default no)\n"); fprintf(ofp," -[no]genedebug show gene debug\n"); } # line 102 "geneoutput.c" /* Function: hard_link_GeneOutputData(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneOutputData *] * * Return [UNKN ] Undocumented return value [GeneOutputData *] * */ GeneOutputData * hard_link_GeneOutputData(GeneOutputData * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneOutputData object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneOutputData_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneOutputData *] * */ GeneOutputData * GeneOutputData_alloc(void) { GeneOutputData * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneOutputData *) ckalloc (sizeof(GeneOutputData))) == NULL) { warn("GeneOutputData_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->alb = NULL; out->pal = NULL; out->gr = NULL; out->gen = NULL; out->ct = NULL; return out; } /* Function: free_GeneOutputData(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneOutputData *] * * Return [UNKN ] Undocumented return value [GeneOutputData *] * */ GeneOutputData * free_GeneOutputData(GeneOutputData * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneOutputData obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->alb != NULL) free_AlnBlock(obj->alb); if( obj->pal != NULL) free_PackAln(obj->pal); if( obj->gr != NULL) free_GenomicRegion(obj->gr); if( obj->gen != NULL) free_Genomic(obj->gen); if( obj->ct != NULL) free_CodonTable(obj->ct); ckfree(obj); return NULL; } /* Function: hard_link_GeneOutputPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneOutputPara *] * * Return [UNKN ] Undocumented return value [GeneOutputPara *] * */ GeneOutputPara * hard_link_GeneOutputPara(GeneOutputPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneOutputPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneOutputPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneOutputPara *] * */ GeneOutputPara * GeneOutputPara_alloc(void) { GeneOutputPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneOutputPara *) ckalloc (sizeof(GeneOutputPara))) == NULL) { warn("GeneOutputPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->show_genes = 0; out->show_gff = 0; out->show_trans = 0; out->show_cdna = 0; out->show_geneutr = 0; out->show_alb = 0; out->show_pal = 0; out->show_debug = 0; out->divide_string = NULL; return out; } /* Function: free_GeneOutputPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneOutputPara *] * * Return [UNKN ] Undocumented return value [GeneOutputPara *] * */ GeneOutputPara * free_GeneOutputPara(GeneOutputPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneOutputPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->divide_string != NULL) ckfree(obj->divide_string); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/geneoutput.h0000644000175000001440000001110010670453714016473 0ustar philippusers#ifndef DYNAMITEgeneoutputHEADERFILE #define DYNAMITEgeneoutputHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "geneutil.h" struct Wise2_GeneOutputData { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif AlnBlock * alb; PackAln * pal; GenomicRegion * gr; Genomic * gen; CodonTable * ct; } ; /* GeneOutputData defined */ #ifndef DYNAMITE_DEFINED_GeneOutputData typedef struct Wise2_GeneOutputData Wise2_GeneOutputData; #define GeneOutputData Wise2_GeneOutputData #define DYNAMITE_DEFINED_GeneOutputData #endif struct Wise2_GeneOutputPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif boolean show_genes; boolean show_gff; boolean show_trans; boolean show_cdna; boolean show_geneutr; boolean show_alb; boolean show_pal; boolean show_debug; char * divide_string; } ; /* GeneOutputPara defined */ #ifndef DYNAMITE_DEFINED_GeneOutputPara typedef struct Wise2_GeneOutputPara Wise2_GeneOutputPara; #define GeneOutputPara Wise2_GeneOutputPara #define DYNAMITE_DEFINED_GeneOutputPara #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_GeneOutputData(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneOutputData *] * * Return [UNKN ] Undocumented return value [GeneOutputData *] * */ GeneOutputData * Wise2_hard_link_GeneOutputData(GeneOutputData * obj); #define hard_link_GeneOutputData Wise2_hard_link_GeneOutputData /* Function: GeneOutputData_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneOutputData *] * */ GeneOutputData * Wise2_GeneOutputData_alloc(void); #define GeneOutputData_alloc Wise2_GeneOutputData_alloc /* Function: free_GeneOutputData(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneOutputData *] * * Return [UNKN ] Undocumented return value [GeneOutputData *] * */ GeneOutputData * Wise2_free_GeneOutputData(GeneOutputData * obj); #define free_GeneOutputData Wise2_free_GeneOutputData /* Function: hard_link_GeneOutputPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneOutputPara *] * * Return [UNKN ] Undocumented return value [GeneOutputPara *] * */ GeneOutputPara * Wise2_hard_link_GeneOutputPara(GeneOutputPara * obj); #define hard_link_GeneOutputPara Wise2_hard_link_GeneOutputPara /* Function: GeneOutputPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneOutputPara *] * */ GeneOutputPara * Wise2_GeneOutputPara_alloc(void); #define GeneOutputPara_alloc Wise2_GeneOutputPara_alloc /* Function: free_GeneOutputPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneOutputPara *] * * Return [UNKN ] Undocumented return value [GeneOutputPara *] * */ GeneOutputPara * Wise2_free_GeneOutputPara(GeneOutputPara * obj); #define free_GeneOutputPara Wise2_free_GeneOutputPara /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_show_GeneOutput(GeneOutputData * data,GeneOutputPara * para,FILE * ofp); #define show_GeneOutput Wise2_show_GeneOutput double Wise2_id_map_func(int i); #define id_map_func Wise2_id_map_func GeneOutputPara * Wise2_new_GeneOutputPara_from_argv(int * argc,char ** argv); #define new_GeneOutputPara_from_argv Wise2_new_GeneOutputPara_from_argv void Wise2_show_help_GeneOutputPara(FILE * ofp); #define show_help_GeneOutputPara Wise2_show_help_GeneOutputPara /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/geneutil.dy0000644000175000001440000006654110413710424016305 0ustar philippusers %{ #include "dyna.h" %} %{ #include "geneutil.h" %func Makes a new GenomicRegion with the genes predicted from this AlnBlock Really a wrapper around the add_Genes_to_GenomicRegion_GeneWise and other functionality %arg gen genomic sequence to use pseudo If true, predicts frameshifted genes as pseudogenes alb genewise alignment to predict genes from return a newly allocated structure %% GenomicRegion * new_GenomicRegion_from_GeneWise(Genomic * gen,boolean pseudo,AlnBlock * alb) { GenomicRegion * out; out = new_GenomicRegion(gen); add_Genes_to_GenomicRegion_new(out,alb); return out; } %func Potential an Alnblock may have more than one gene due to looping models This adds all the genes to gr %arg gr genomic region to add genes to org_start start point of the dna to which the alb was made from org_end end point of the dna to which the alb was made from alb logical label alignment pseudo If true, frameshifted genes are predicted as pseudo genes root the second argument to make_name make_name fN a pointer to a function to actually make the name of the gene %% int add_Genes_to_GenomicRegion_GeneWise(GenomicRegion * gr,int org_start,int org_end,AlnBlock * alb,char * root,boolean pseudo,char * (*make_name)(Wise2_Genomic *,char *,int ,Wise2_Gene * )) { int count = 0; Gene * gene; AlnColumn * alc; alc = alb->start; while( (gene = Gene_from_AlnColumn_GeneWise(alc,org_start,org_end,pseudo,&alc)) != NULL ) { if( make_name != NULL ) { gene->name = (*make_name)(gr->genomic,root,gr->len,gene); } if( root != NULL ) { gene->seqname = stringalloc(root); } add_Gene_to_GenomicRegion(gr,gene); count++; if( alc == NULL ) break; } return count; } %func Adds genes using the new gene function %% int add_Genes_to_GenomicRegion_new(GenomicRegion * gr,AlnBlock * alb) { int count = 0; Gene * out; Transcript * tr; Transcript * new_tr; Translation * ts; Exon * exon; AlnBlock * coll; AlnColumn * alc; AlnColumn * exon_start; AlnColumn * intron_start; int trace = 1; int exon_start_coord; int is_reversed = 0; int temp; int i; coll = collapsed_AlnBlock(alb,1); /* find start */ for(alc = coll->start;alc != NULL;alc = alc->next ) { if( strstr(alc->alu[1]->text_label,"CODON") != NULL ) { if( trace ) fprintf(stderr,"Got %s as first codon\n",alc->alu[1]->text_label); /* got a gene */ out = Gene_alloc_len(1); add_Gene_to_GenomicRegion(gr,out); tr = Transcript_alloc_std(); /* don't add transcript yet, because reversing it requires arsing around with exons */ if( strstr(alc->alu[1]->text_label,"REV") != NULL ) { is_reversed = 1; } else { is_reversed = 0; } exon_start_coord = alc->alu[1]->start+1; out->start = exon_start_coord; /* first exon is different as there is no 3' splice site */ exon_start = alc; alc = alc->next; if( alc == NULL ) { warn("weird death in gene parsing"); return 1; } /* handle single exon genes */ if( strstr(alc->alu[1]->text_label,"SS") == NULL ) { /* single exon gene */ exon = Exon_alloc_std(); exon->start = 0; exon->end = alc->alu[1]->start+3 - exon_start->alu[1]->start; if( trace ) fprintf(stderr,"Single exon gene %s from %d to %d\n",alc->alu[1]->text_label,exon->start,exon->end); if( is_reversed == 0 ) { out->start = exon_start->alu[1]->start+1; out->end = alc->alu[1]->start+4; } else { out->end = exon_start->alu[1]->start; out->start = alc->alu[1]->start+3; } add_ex_Transcript(tr,exon); ts = Translation_alloc(); ts->start = 0; ts->end = length_Transcript(tr); ts->parent = tr; add_Transcript(tr,ts); tr->parent = out; add_Gene(out,tr); continue; } /* handle first exon */ exon = Exon_alloc_std(); add_ex_Transcript(tr,exon); exon->start = exon_start->alu[1]->start+1 - exon_start_coord; if( strstr(alc->alu[1]->text_label,"PHASE_0") != NULL) { exon->end = alc->alu[1]->start +1 - out->start; } else if ( strstr(alc->alu[1]->text_label,"PHASE_1") != NULL) { exon->end = alc->alu[1]->start +2 - out->start; } else if ( strstr(alc->alu[1]->text_label,"PHASE_2") != NULL) { exon->end = alc->alu[1]->start +3 - out->start; } /* loop over internal exons. Alc is current on leftmost splice site */ for( ;; ) { if( trace ) fprintf(stderr,"internal exon - this should be leftmost splice %s\n",alc->alu[1]->text_label); if( strstr(alc->next->alu[1]->text_label,"SS") != NULL ) { warn("Have a no-base intron. Conceptually possible, but highly unlikely. Probably misparamterisation somewhere..."); } else { alc = alc->next; if( trace ) fprintf(stderr,"internal exon - this should be INTRON %s\n",alc->alu[1]->text_label); } if( alc == NULL ) { warn("Weird death inside Intron of gene parsing"); return 1; } alc = alc->next; if( trace ) fprintf(stderr,"internal exon - this should be rightmost splice %s\n",alc->alu[1]->text_label); if( alc == NULL ) { warn("Weird death inside Intron of gene parsing"); return 1; } if( strstr(alc->alu[1]->text_label,"SS") == NULL ) { warn("At end of intron , non splice label %s",alc->alu[1]->text_label); return 1; } exon_start = alc; alc = alc->next; if( trace ) fprintf(stderr,"internal exon - this should be CODON %s\n",alc->alu[1]->text_label); if( alc == NULL ) { warn("Weird death inside Intron of gene parsing"); return 1; } alc = alc->next; if( alc == NULL ) { warn("Weird death inside Intron of gene parsing"); return 1; } if( trace ) fprintf(stderr,"internal exon - this should be 5SS %s\n",alc->alu[1]->text_label); /* should have a 3'SS whatever */ exon = Exon_alloc_std(); add_ex_Transcript(tr,exon); if( strstr(exon_start->alu[1]->text_label,"PHASE_0") != NULL) { exon->start = exon_start->alu[1]->start +4 - out->start; } else if ( strstr(exon_start->alu[1]->text_label,"PHASE_1") == NULL) { exon->start = exon_start->alu[1]->start +4 - out->start; } else if ( strstr(exon_start->alu[1]->text_label,"PHASE_2") == NULL) { exon->start = exon_start->alu[1]->start +4 - out->start; } if( strstr(alc->alu[1]->text_label,"SS") == NULL ) { fprintf(stderr,"Breaking with no 5'SS on %s with %d\n",alc->alu[1]->text_label,alc->alu[1]->start); exon->end = alc->alu[1]->start +1 - out->start; break; } else { if( strstr(alc->alu[1]->text_label,"PHASE_0") != NULL) { exon->end = alc->alu[1]->start +1 - out->start; } else if ( strstr(alc->alu[1]->text_label,"PHASE_1") != NULL) { exon->end = alc->alu[1]->start +2 - out->start; } else if ( strstr(alc->alu[1]->text_label,"PHASE_2") != NULL) { exon->end = alc->alu[1]->start +3 - out->start; } } /* alc is left on the 5'SS for the next exon */ } /* end of for (;;) over internal exons*/ /* end of a gene. exon is the last exon */ out->end = exon->end + out->start; ts = Translation_alloc(); ts->start = 0; ts->end = length_Transcript(tr); if( ts->end % 3 != 0 ) { warn("Transcript is not mod 3 size. It is %d doh!",ts->end); } if( is_reversed == 1 ) { if( trace ) fprintf(stderr,"Reversing gene %d to %d\n",out->start,out->end); temp = out->end; temp = temp; out->end = out->start; out->start = temp; /* reversed genes have an off by one convention */ out->end -= 1; out->start -= 1; /* now have to reverse transcript. doh! */ new_tr = Transcript_alloc_std(); temp = out->start - out->end; for(i=tr->ex_len-1;i >= 0;i-- ) { exon = Exon_alloc_std(); exon->start = temp - tr->exon[i]->end; exon->end = temp - tr->exon[i]->start; fprintf(stderr,"Adding exon %d %d which used to be %d %d\n",exon->start,exon->end,tr->exon[i]->start,tr->exon[i]->end); add_ex_Transcript(new_tr,exon); } free_Transcript(tr); tr = new_tr; } add_Gene(out,tr); ts->parent = tr; add_Transcript(tr,ts); tr->parent = out; } else { if( trace ) fprintf(stderr,"Skipping %s before codon\n",alc->alu[1]->text_label); /* do nothing if not a codon - march on */ } } /* free_AlnBlock(coll);*/ return 1; } %func helper function for new system %% boolean is_exon_AlnColumn_new(AlnColumn * alc) { if( strstr(alc->alu[1]->text_label,"CODON") != NULL ) { return TRUE; } else { return FALSE; } } %func helper function for the new system %% boolean is_splice_site_AlnColumn(AlnColumn * alc,int * type,int * phase) { if( strstr(alc->alu[1]->text_label,"SS") != NULL ) { if( strstr(alc->alu[1]->text_label,"5SS") != NULL ) { *type = 5; } else { *type = 3; } if( strstr(alc->alu[1]->text_label,"0") != NULL ) { *phase = 0; } else if ( strstr(alc->alu[1]->text_label,"1") != NULL ) { *phase = 1; } else if ( strstr(alc->alu[1]->text_label,"2") != NULL ) { *phase = 2; } return TRUE; } else { return FALSE; } } %func A new hope for building genes %% Gene * Gene_from_AlnColumn_new(AlnColumn * alc,AlnColumn ** end) { Gene * out; Transcript * tr; Translation * ts; Exon * ex; int exon_start; int exon_end; int phase_start; int phase_end; int is_reversed; int is_3ss; int phase; int type; int tmp; AlnColumn * prev; boolean end_gene = 0; while(alc != NULL && is_exon_AlnColumn_new(alc) == FALSE ) alc = alc->next; if( alc == NULL ) { *end = NULL; return NULL; } if( strstr(alc->alu[1]->text_label,"CODON") == NULL ) { warn("Bad news... exited from random columns, but not in a codon column, in a %s",alc->alu[1]->text_label); * end = NULL; return NULL; } /* we should have either a forward or reversed gene */ if( strstr(alc->alu[1]->text_label,"REV") != NULL ) { is_reversed = 1; } else { is_reversed = 0; } out = Gene_alloc_len(1); tr = Transcript_alloc_std(); add_Gene(out,tr); out->start = alc->alu[1]->start +1; phase_start = 0; exon_start = 0; /* by definition, the first exon is at the start*/ is_3ss = 0; for(;;) { if( strstr(alc->alu[1]->text_label,"GENE_EXIT") != NULL ) { break; } exon_start = alc->alu[1]->start+1 - out->start; if( is_3ss ) { if( phase_start == 0 ) { exon_start -= 3; } else if ( phase_start == 1 ) { exon_start -= 2; } else if ( phase_start == 2 ) { exon_start -= 1; } } /* this is at the start of exon */ /* go to the end of the exon */ for(; alc != NULL && is_exon_AlnColumn_new(alc);alc=alc->next) { fprintf(stdout,"Exonifying past %d %s\n",alc->alu[1]->start,alc->alu[1]->text_label); prev = alc; } /* irregardless of the fate of this exon, we now can put it * in, as if it was phase0-phase0 */ exon_end = prev->alu[1]->end +1 - out->start; ex = Exon_alloc_std(); fprintf(stdout,"Adding exon with %d-%d\n",ex->start,ex->end); add_ex_Transcript(tr,ex); ex->start = exon_start; ex->end = exon_end; if( alc != NULL && is_splice_site_AlnColumn(alc,&type,&phase) ) { phase_end = phase; } else { is_3ss = 0; phase_end = 0; end_gene = 1; } /* jigging the splice sites for the phases */ if( phase_end == 0 ) { ex->end = ex->end; } else if( phase_end == 1 ) { ex->end = ex->end +1; } else if( phase_end == 2 ) { ex->end = ex->end +2; } ex->phase = phase_start; if( end_gene == 1 ) { break; } for(; alc != NULL && !is_exon_AlnColumn_new(alc);alc=alc->next) { /* fprintf(stdout,"Moving past %d %s\n",alc->alu[1]->start,alc->alu[1]->text_label);*/ if( is_splice_site_AlnColumn(alc,&type,&phase) ) { is_3ss = 1; phase_start = phase; } if( strstr(alc->alu[1]->text_label,"GENE_EXIT") != NULL ) { /* fprintf(stdout,"Exiting %d %s\n",alc->alu[1]->start,alc->alu[1]->text_label); */ end_gene = 1; break; } } if( end_gene == 1 ) { break; } if( alc == NULL ) { break; } } *end = alc; out->end = ex->end + out->start; if( is_reversed == 1 ) { tmp = out->start; out->start = out->end; out->end = tmp; } ts = Translation_alloc(); ts->start = 0; ts->end = length_Transcript(tr); ts->parent = tr; add_Transcript(tr,ts); tr->parent = out; fprintf(stdout,"returning gene %d %d\n",out->start,out->end); return out; } %func A wrap for making a gene structure from an AlnBlock derived from one of the genewise methods %arg alc Alignment column in an AlnBlock produced by genewise org_start offset that the genewise alignment was to the coordinate system org_end emd that the genewise alignment was to the coordinate system end w pointer to a AlnColumn * to say when it has finished with this gene %% Gene * Gene_from_AlnColumn_GeneWise(AlnColumn * alc,int org_start,int org_end,boolean predict_pseudo_for_frameshift,AlnColumn ** end) { Gene * out; Transcript * tr; Translation * ts; Exon * ex; AlnColumn * prev; SupportingFeature * sf; int score = 0; int dosf = 0; int phase = 0; int frame_break = 0; while(alc != NULL && is_random_AlnColumn_genewise(alc) == TRUE ) alc = alc->next; while (alc != NULL && strcmp(alc->alu[1]->text_label,"CODON") != 0 ) alc = alc->next; if( alc == NULL) return NULL; out = Gene_alloc_len(1); tr = Transcript_alloc_std(); add_Gene(out,tr); out->start = alc->alu[1]->start +1; score += alc->alu[0]->score[0]; for(;;) { /* fprintf(stderr,"Top loop - alc at %s %s\n",alc->alu[1]->text_label,alc->alu[0]->text_label); */ /* fprintf(stderr,"2 Score is %.2f %s %d %.2f\n",Score2Bits(score),alc->alu[1]->text_label,alc->alu[0]->score[0],Score2Bits(alc->alu[0]->score[0]));*/ ex = Exon_alloc_std(); add_ex_Transcript(tr,ex); /* * this is always the start of an exon */ dosf = 0; if( strcmp(alc->alu[1]->text_label,"CODON") == 0 ) { ex->start = alc->alu[1]->start+1 - out->start; /* coordinated in alignment coords */ dosf = 1; phase = 0; } else if ( strcmp(alc->alu[1]->text_label,"3SS_PHASE_0") == 0 ) { ex->start = alc->alu[1]->start +4 - out->start; dosf = 1; phase = 0; } else if ( strcmp(alc->alu[1]->text_label,"3SS_PHASE_1") == 0 ) { ex->start = alc->alu[1]->start +4 - out->start; phase = 1; } else if ( strcmp(alc->alu[1]->text_label,"3SS_PHASE_2") == 0 ) { ex->start = alc->alu[1]->start +4 - out->start; phase = 2; } else { ex->start = alc->alu[1]->start +1 - out->start; /* coordinated in alignment coords */ phase = -1; } ex->phase = phase; /* * Exons can start in INSERTs (yuk). In which case we don't * make a supporting feature */ if( dosf == 1 && strstartcmp(alc->alu[0]->text_label,"INSERT") != 0 ) { sf = SupportingFeature_alloc(); /* we fill in start and end from the exon at the moment. Not pretty */ sf->hstart = alc->alu[0]->start+1; sf->hstrand = 1; /* currently only got proteins. Thank the lord! */ sf->start = ex->start; } else { sf = NULL; /* make sure we don't generate a sf here */ } for(prev=alc,alc=alc->next;alc != NULL; ) { /* fprintf(stderr,"Exon loop - alc at %s %s %d\n",alc->alu[1]->text_label,alc->alu[0]->text_label,sf); */ score += alc->alu[0]->score[0]; /* fprintf(stderr,"1 Score is %.2f %s\n",Score2Bits(score),alc->alu[1]->text_label); */ if( is_frameshift_AlnColumn_genewise(alc) == TRUE && predict_pseudo_for_frameshift == TRUE ) { score += alc->alu[0]->score[0]; fprintf(stderr,"Score is %.2f\n",Score2Bits(score)); out->ispseudo = TRUE; alc = alc->next; continue; } if( is_random_AlnColumn_genewise(alc) == TRUE) break; if( strcmp(alc->alu[1]->text_label,"CODON") != 0 ) { if( strstartcmp(alc->alu[0]->text_label,"DELETE") == 0 ) { /* must add sf and start a new one */ /*fprintf(stderr,"Looking at alc at %s %s %d %d %d\n",alc->alu[1]->text_label,alc->alu[0]->text_label,prev,out,sf);*/ if( sf != NULL ) { sf->end = prev->alu[1]->end+1 - out->start; sf->hend = prev->alu[0]->end+1; add_Exon(ex,sf); sf = NULL; } /* * go the end of this delete run, which are residues in the query with no * target info */ while( alc->next != NULL && strstartcmp(alc->next->alu[0]->text_label,"DELETE") == 0 ) { alc = alc->next; } if( alc->next != NULL && strcmp(alc->next->alu[1]->text_label,"CODON") == 0 ) { /* the next position is the start of the new alignment */ sf = SupportingFeature_alloc(); sf->hstart = alc->next->alu[0]->start+1; sf->start = alc->next->alu[1]->start+1 - out->start; } else { sf = NULL; } } else { break; } } else { /* it is a codon match, but it could be an insert */ if( strstartcmp(alc->alu[0]->text_label,"INSERT") == 0) { /* break at this point, add this supporting feature */ if( sf != NULL ) { sf->end = prev->alu[1]->end+1 - out->start; sf->hend = prev->alu[0]->end+1; add_Exon(ex,sf); sf = NULL; } frame_break = 0; /* go to the end of this insert run, watching for frameshifts */ while( alc->next != NULL && strstartcmp(alc->next->alu[0]->text_label,"INSERT") == 0 ) { if( is_frameshift_AlnColumn_genewise(alc->next) == TRUE || is_random_AlnColumn_genewise(alc->next) == TRUE) { if( is_frameshift_AlnColumn_genewise(alc->next) == TRUE && predict_pseudo_for_frameshift == TRUE ) { out->ispseudo = TRUE; alc = alc->next; continue; } else { alc = alc->next; frame_break = 1; break; } } alc = alc->next; } if( frame_break == 1 ) { break; /* out of this gene */ } if( alc->next != NULL && strcmp(alc->next->alu[1]->text_label,"CODON") == 0 ) { /* the next position is the start of the new alignment */ sf = SupportingFeature_alloc(); /* do not understand why not having a +1 here is correct. Hmph */ sf->hstart = alc->next->alu[0]->start+1; sf->start = alc->next->alu[1]->start+1 - out->start; } else { sf = NULL; } } else { /* could be the start of a run from INSERT into match */ if( sf == NULL ) { sf = SupportingFeature_alloc(); /* we fill in start and end from the exon at the moment. Not pretty */ sf->hstart = alc->alu[0]->start+1; sf->hstrand = 1; /* currently only got proteins. Thank the lord! */ sf->start = alc->alu[1]->start+1 - out->start; } } } /* end of else it is a codon match */ prev = alc; alc = alc->next; } /* * The exon has ended. But why? */ if( sf != NULL ) { sf->hend = prev->alu[0]->end+1; add_Exon(ex,sf); } if( alc == NULL ) { out->end = prev->alu[1]->end +1; ex->end = out->end - out->start; if( sf != NULL ) { sf->end = ex->end; } break; } if( is_random_AlnColumn_genewise(alc) == TRUE) { out->end = prev->alu[1]->end +1; ex->end = out->end - out->start; if( sf != NULL ) { sf->end = ex->end; } break; } /* fprintf(stderr,"Exiting out of exon loop...\n");*/ if( strcmp(alc->alu[1]->text_label,"5SS_PHASE_0") == 0 ) { out->end = alc->alu[1]->start+1; phase = 0; } else if ( strcmp(alc->alu[1]->text_label,"5SS_PHASE_1") == 0 ) { out->end = alc->alu[1]->start+2; phase = 1; } else if ( strcmp(alc->alu[1]->text_label,"5SS_PHASE_2") == 0 ) { out->end = alc->alu[1]->start+3; phase = 2; } else { phase = 0; /* fixes from Steve, via an issue with Steve */ if ( strncmp(prev->alu[1]->text_label,"3SS_PHASE_0",11) == 0 ) { out->end = prev->alu[1]->end + 4; } else if ( strncmp(prev->alu[1]->text_label,"3SS_PHASE_1",11) == 0 ) { out->end = prev->alu[1]->end + 4; } else if ( strncmp(prev->alu[1]->text_label,"3SS_PHASE_1",11) == 0 ) { out->end = prev->alu[1]->end + 4; } else { out->end = prev->alu[1]->end +1; } ex->end = out->end - out->start; if( sf != NULL ) { sf->end = ex->end; } break; } /** set end of exon to the correct size from here **/ ex->end = out->end - out->start; /** sf is to the codon, not to the exon */ if( sf != NULL ) { if( phase == 0 ) { sf->end = ex->end; } else if ( phase == 1 ) { sf->end = ex->end-1; } else { sf->end = ex->end-2; } } while( alc != NULL && strstartcmp(alc->alu[1]->text_label,"3SS") != 0 ) { /* fprintf(stderr,"Intron loop - alc at %s %s %d\n",alc->alu[1]->text_label,alc->alu[0]->text_label,sf); */ alc = alc->next; score += alc->alu[0]->score[0]; } if( alc == NULL ) { warn("Got to the end of an alignment inside an intron. Oooops!"); break; } }/* back to for(;;) */ if( end != NULL ) *end = alc; if( org_start < org_end) { out->start += org_start-1; out->end += org_start-1; } else { /* fprintf(stderr,"was %d to %d\n",out->start,out->end); */ out->start = org_start-1 - out->start; out->end = org_start-1 - out->end; /* fprintf(stderr,"now %d to %d (%d)\n",out->start,out->end,org_start); */ } if( out->ispseudo == FALSE ) { ts = Translation_alloc(); ts->start = 0; ts->end = length_Transcript(tr); ts->parent = tr; add_Transcript(tr,ts); } tr->parent = out; out->bits = Score2Bits(score); return out; } %func This function is to say what is a frameshift label %type internal %% boolean is_frameshift_AlnColumn_genewise(const AlnColumn * alc) { if( strcmp(alc->alu[1]->text_label,"SEQUENCE_INSERTION") == 0 ) { return TRUE; } if( strcmp(alc->alu[1]->text_label,"SEQUENCE_DELETION") == 0 ) { return TRUE; } return FALSE; } %func This function is to say where this should be skipped in alignment/gene prediction problems %type internal %% boolean is_random_AlnColumn_genewise(const AlnColumn * alc) { char * la; la = alc->alu[1]->text_label; if( strcmp(la,"RANDOM_SEQUENCE") == 0 ) return TRUE; if( strcmp(la,"END") == 0 ) return TRUE; la = alc->alu[0]->text_label; if( strstr(la,"_RND_") != NULL ) return TRUE; return FALSE; } %func This function is to say where things are introns %type internal %% boolean is_intron_AlnColumn_genewise(const AlnColumn * alc) { char * la; la = alc->alu[1]->text_label; if( strcmp(la,"CENTRAL_INTRON") == 0 ) return TRUE; if( strcmp(la,"PYRIMIDINE_TRACT") == 0 ) return TRUE; if( strcmp(la,"SPACER") == 0 ) return TRUE; return FALSE; } #define GW_EXON_TYPE_UTR5 45 #define GW_EXON_TYPE_CDS 46 #define GW_EXON_TYPE_UTR3 47 #define GW_EXON_TYPE_NONE 48 int exon_type_AlnColumn_genomewise(AlnColumn * alc) { if( strcmp(alc->alu[1]->text_label,"CODON") == 0 ) { return GW_EXON_TYPE_CDS; } if( strcmp(alc->alu[1]->text_label,"UTR5") == 0 ) { return GW_EXON_TYPE_UTR5; } if( strcmp(alc->alu[1]->text_label,"UTR3") == 0 || strcmp(alc->alu[1]->text_label,"STOP_CODON") == 0) { return GW_EXON_TYPE_UTR3; } return GW_EXON_TYPE_NONE; } void show_utr_exon_genomewise(AlnBlock * alb,FILE * ofp) { AlnColumn * alc; int exon_start; int exon_end; int is_start; int phase; int endphase; int is_3ss; for(alc=alb->start;alc != NULL;) { /* find the first exon */ for(;alc != NULL && exon_type_AlnColumn_genomewise(alc) != GW_EXON_TYPE_UTR5;alc = alc->next) ; if( alc == NULL ) { break; } fprintf(ofp,"Gene\n"); if( alc != NULL && exon_type_AlnColumn_genomewise(alc) == GW_EXON_TYPE_UTR5 ) { is_start = 1; while( alc != NULL ) { /* while loop goes over all 5UTRs */ exon_start = alc->alu[1]->start+ (is_start ? 2 : 3); is_start = 0; for(;alc != NULL && exon_type_AlnColumn_genomewise(alc) == GW_EXON_TYPE_UTR5;alc = alc->next ) { ; } /* fprintf(stderr,"Broken out with %s\n",alc->alu[1]->text_label); */ if( strcmp(alc->alu[1]->text_label,"UTR5_INTRON") ==0 ) { /* ntron. should be +2-1 at the end of this, goes to 1*/ fprintf(ofp," utr5 %d %d\n",exon_start,alc->alu[1]->start+1); /* now loop through the intron */ for(;alc != NULL && strcmp(alc->alu[1]->text_label,"UTR5_INTRON") == 0;alc = alc->next ) { ; } if( alc == NULL || exon_type_AlnColumn_genomewise(alc) != GW_EXON_TYPE_UTR5 ) { break; /* while loop */ } else{ continue; /* another utr5 exon */ } } else { /* print this guy and break */ fprintf(ofp," utr5 %d %d\n",exon_start,alc->alu[1]->start+1); break; } } } /* we now should be at a CDS column */ if( alc != NULL && exon_type_AlnColumn_genomewise(alc) == GW_EXON_TYPE_CDS ) { is_start = 1; while( alc != NULL ) { /* while loop goes over all coding Exons */ /* fprintf(stderr,"Entering codoing loop with %s\n",alc->alu[1]->text_label); */ exon_start = alc->alu[1]->start+2; if( strstr(alc->alu[1]->text_label,"3SS") != NULL ) { is_3ss = 1; if( strstr(alc->alu[1]->text_label,"1") != NULL ) { phase = 1; } else if ( strstr(alc->alu[1]->text_label,"2") != NULL ) { phase = 2; } else { phase = 0; } alc = alc->next; } else { is_3ss = 0; phase = 0; } if( phase == 1 ) { exon_start += 3; } else if ( phase == 2) { exon_start += 3; } else if ( is_3ss ) { /* phase 0 and spliced needs adjusting */ exon_start += 3; } for(;alc != NULL && exon_type_AlnColumn_genomewise(alc) == GW_EXON_TYPE_CDS ;alc = alc->next ) { ; } if( strstr(alc->alu[1]->text_label,"5SS") != NULL ) { exon_end = alc->alu[1]->start+1; if( strstr(alc->alu[1]->text_label,"1") != NULL ) { endphase = 1; } else if ( strstr(alc->alu[1]->text_label,"2") != NULL ) { endphase = 2; } else { endphase = 0; } if( endphase == 1 ) { exon_end += 1; } else if( endphase == 2 ) { exon_end += 2; } /* no change for phase 0 */ /* intron. should be +1-1 at the end of this, goes to 0*/ fprintf(ofp," cds %d %d phase %d\n",exon_start,exon_end,phase); /* now loop through the intron */ for(alc= alc->next;alc != NULL && strstr(alc->alu[1]->text_label,"3SS") == NULL;alc = alc->next ) { ; } if( alc == NULL || strstr(alc->alu[1]->text_label,"3SS") == NULL ) { break; /* while loop */ } else{ continue; /* another cds exon */ } } else { fprintf(ofp," cds %d %d phase %d\n",exon_start,alc->alu[1]->start+1,phase); break; } } } if( alc != NULL && exon_type_AlnColumn_genomewise(alc) == GW_EXON_TYPE_UTR3 ) { is_start = 1; while( alc != NULL ) { /* while loop goes over all 3UTRs */ exon_start = alc->alu[1]->start+ (is_start ? 2 : 3); is_start = 0; for(;alc != NULL && exon_type_AlnColumn_genomewise(alc) == GW_EXON_TYPE_UTR3 ;alc = alc->next ) { ; } if( strstr(alc->alu[1]->text_label,"INTRON") != NULL ) { /* intron. should be +2-1 at the end of this, goes to 1*/ fprintf(ofp," utr3 %d %d\n",exon_start,alc->alu[1]->start+1); /* now loop through the intron */ for(;alc != NULL && strstr(alc->alu[1]->text_label,"INTRON") != NULL;alc = alc->next ) { ; } if( alc == NULL || exon_type_AlnColumn_genomewise(alc) != GW_EXON_TYPE_UTR3 ) { break; /* while loop */ } else{ continue; /* another utr3 exon */ } } else { fprintf(ofp," utr3 %d %d\n",exon_start,alc->alu[1]->start+1); break; } } } fprintf(ofp,"End\n"); /* back to next gene */ } } %} wise-2.4.1/src/models/localdba.dy0000644000175000001440000000704107547276646016253 0ustar philippusers %{ #include "dyna.h" #include "localcispara.h" %} matrix LocalDnaMatchBlock query type="DNA" name="query" target type="DNA" name="target" resource type="LocalCisHitScore*" name="lchs" state MATCH65 source MATCH65 offi="1" offj="1" calc="lchs->comp65->score[DNA_BASE(query,i)][DNA_BASE(target,j)] +lchs->s" endsource source MATCH65 offi="0" offj="1" calc="lchs->g" target_label MI65 endsource source MATCH65 offi="1" offj="0" calc="lchs->g" query_label MI65 endsource source START offi="1" offj="1" calc="lchs->comp65->score[DNA_BASE(query,i)][DNA_BASE(target,j)] +lchs->v" endsource source UNMATCHED_TARGET offi="1" offj="1" calc="lchs->comp65->score[DNA_BASE(query,i)][DNA_BASE(target,j)] +lchs->v" endsource query_label MM65 target_label MM65 endstate state MATCH75 source MATCH75 offi="1" offj="1" calc="lchs->comp75->score[DNA_BASE(query,i)][DNA_BASE(target,j)] +lchs->s" endsource source MATCH75 offi="0" offj="1" calc="lchs->g" target_label MI75 endsource source MATCH75 offi="1" offj="0" calc="lchs->g" query_label MI75 endsource source START offi="1" offj="1" calc="lchs->comp75->score[DNA_BASE(query,i)][DNA_BASE(target,j)] +lchs->v" endsource source UNMATCHED_TARGET offi="1" offj="1" calc="lchs->comp75->score[DNA_BASE(query,i)][DNA_BASE(target,j)] +lchs->v" endsource query_label MM75 target_label MM75 endstate state MATCH85 source MATCH85 offi="1" offj="1" calc="lchs->comp85->score[DNA_BASE(query,i)][DNA_BASE(target,j)] +lchs->s" endsource source MATCH85 offi="0" offj="1" calc="lchs->g" target_label MI85 endsource source MATCH85 offi="1" offj="0" calc="lchs->g" query_label MI85 endsource source START offi="1" offj="1" calc="lchs->comp85->score[DNA_BASE(query,i)][DNA_BASE(target,j)] +lchs->v" endsource source UNMATCHED_TARGET offi="1" offj="1" calc="lchs->comp85->score[DNA_BASE(query,i)][DNA_BASE(target,j)] +lchs->v" endsource query_label MM85 target_label MM85 endstate state MATCH95 source MATCH95 offi="1" offj="1" calc="lchs->comp95->score[DNA_BASE(query,i)][DNA_BASE(target,j)] +lchs->s" endsource source MATCH95 offi="0" offj="1" calc="lchs->g" target_label MI95 endsource source MATCH95 offi="1" offj="0" calc="lchs->g" query_label MI95 endsource source START offi="1" offj="1" calc="lchs->comp95->score[DNA_BASE(query,i)][DNA_BASE(target,j)] +lchs->v" endsource source UNMATCHED_TARGET offi="1" offj="1" calc="lchs->comp95->score[DNA_BASE(query,i)][DNA_BASE(target,j)] +lchs->v" endsource query_label MM95 target_label MM95 endstate state UNMATCHED_QUERY offi="1" offj="0" source MATCH65 calc="lchs->b" endsource source MATCH75 calc="lchs->b" endsource source MATCH85 calc="lchs->b" endsource source MATCH95 calc="lchs->b" endsource source UNMATCHED_QUERY calc="lchs->u" endsource query_label UM target_label UI endstate state UNMATCHED_TARGET offi="0" offj="1" source UNMATCHED_QUERY calc="lchs->v" endsource source UNMATCHED_TARGET calc="lchs->u" endsource target_label UM query_label UI endstate state START !special !start query_label START target_label START endstate state END !special !end source MATCH65 calc="0" endsource source MATCH75 calc="0" endsource source MATCH85 calc="0" endsource source MATCH95 calc="0" endsource query_label END target_label END endstate endmatrix wise-2.4.1/src/models/mapstruct.dy0000644000175000001440000001666707313404547016532 0ustar philippusers %{ #include "dyna.h" #define MappedCloneSetLISTLENGTH 1024 %} struct MappedClone char * clone_name char * accession char * contig int start int end int seen !def="0" struct MappedCloneSet MappedClone ** clone !list int length int cursor !def="0" struct MappedCloneMatch int ** matrix !matrix !def="0" // NB i,j proper int * skip_iset int * skip_jset %{ #include "mapstruct.h" MappedCloneMatch * new_MappedCloneMatch(MappedCloneSet * iset,MappedCloneSet * jset,int match,int mismatch) { int i; int j; int ii; int jj; int k; MappedCloneMatch * out; int * buffer; assert(match >= 0 ); assert(mismatch <= 0); assert(iset); assert(jset); out = MappedCloneMatch_alloc_matrix(iset->length,jset->length); buffer = calloc(jset->length,sizeof(int)); for(i=0;ilen;i++) { /* no point even noticing not seen clones */ if( iset->clone[i]->seen == 0 ) { continue; } for(k=0;klength;k++) buffer[k] = 0; for(j=0;jlen;j++) { /* positive scores are easy, as we only have to loop over names */ if( strcmp(iset->clone[i]->clone_name,jset->clone[j]->clone_name) == 0 ) { for(ii=iset->clone[i]->start;iiclone[i]->end;ii++) { for(jj=jset->clone[j]->start;jjclone[j]->end;jj++) { out->matrix[ii][jj] += match; buffer[jj] = 1; } } } } /* now handle negative scores. in the j dimension, where buffer == 0, these regions do not have this particular i clone. As long as this i clone is actually seen (true due to first continue if) then we can substract the mismatch across the i */ for(k=0;klength;k++) { if( buffer[k] == 0 ) { for(ii=iset->clone[i]->start;iiclone[i]->end;ii++) { out->matrix[ii][k] += mismatch; } } } } out->skip_iset = (int*) calloc(iset->length,sizeof(int)); out->skip_jset = (int*) calloc(jset->length,sizeof(int)); for(i=0;ilen;i++) { for(ii=iset->clone[i]->start;iiclone[i]->end;ii++) { if( iset->clone[i]->seen == 1 ) { out->skip_iset += mismatch; } } } for(j=0;jlen;j++) { for(jj=jset->clone[j]->start;jjclone[j]->end;jj++) { if( jset->clone[j]->seen == 1 ) { out->skip_jset += mismatch; } } } return out; } int MappedCloneSet_skip(MappedCloneSet * s,int pos,int skip_cost) { int i; int score = 0; MappedCloneSet * mcs; mcs = subsection_MappedCloneSet(s,pos,pos,1); free_MappedCloneSet(mcs); return skip_cost*mcs->len; } int MappedCloneSet_match(MappedCloneSet * weak_query,MappedCloneSet * trusted_target,int qpos,int tpos,int spread,int match,int mismatch) { MappedCloneSet * weak_slice; MappedCloneSet * trusted_slice; int i; int j; int score =0; weak_slice = subsection_MappedCloneSet(weak_query,qpos-spread,qpos+spread,1); trusted_slice = subsection_MappedCloneSet(trusted_target,tpos-spread,tpos+spread,1); if( weak_slice->len == 0 || trusted_slice->len == 0 ) { score = mismatch; } else { for(i=0;ilen;i++) { for(j=0;jlen;j++) { if( strcmp(weak_slice->clone[i]->clone_name,trusted_slice->clone[j]->clone_name) == 0 ) { score += match; } } } } free_MappedCloneSet(weak_slice); free_MappedCloneSet(trusted_slice); return score; } int old_MappedCloneSet_match(MappedCloneSet * one,MappedCloneSet * two,int qpos,int tpos,int spread,int match,int mismatch) { int i; int startj; int j; int score = 0; int has_matched; /* sorted by start. If positions are before start - return 0 */ if( one->clone[0]->start-spread > qpos ) { return mismatch; } if( two->clone[0]->start-spread > tpos ) { return mismatch; } for(i=0;ilen;i++) { if( one->clone[i]->end+spread >= qpos ) { break; } } for(startj=0;startjlen;startj++) { if( two->clone[startj]->end+spread >= tpos ) { break; } } if( i >= one->len ) { return mismatch; } if( startj >= two->len ) { return mismatch; } for(;ilen && one->clone[i]->start-spread <= qpos;i++) { if( one->clone[i]->seen == 0 ) { continue; } has_matched = 0; for(j=startj;jlen && j < two->clone[j]->start-spread < tpos;j++) { if( two->clone[j]->seen == 0 ) { continue; } if( strcmp(two->clone[j]->clone_name,one->clone[i]->clone_name) == 0 ) { has_matched = 1; break; } } if( has_matched == 1 ) { score += match; } else { score -= mismatch; } } return score; } %func updates the internal seen flags for the clone sets in preparation for the dp %% boolean synchronise_MappedCloneSets(MappedCloneSet * one,MappedCloneSet * two) { int i; MappedClone * mc; assert(one); assert(two); for(i=0;ilen;i++) { mc = find_named_MappedClone(two,one->clone[i]->clone_name); if( mc != NULL ) { mc->seen = 1; one->clone[i]->seen = 1; } } return TRUE; } %func Returns a sub-section of the MappedClone %% MappedCloneSet * subsection_MappedCloneSet(MappedCloneSet * mcs,int coord_start,int coord_end,int only_seen) { MappedCloneSet * out; int i; out = MappedCloneSet_alloc_std(); for(i=0;ilen;i++) { if( mcs->clone[i]->end >= coord_start ) { break; } } if( i >= mcs->len ) { return out; } for(i=0;ilen;i++) { if( only_seen == 1 && mcs->clone[i]->seen == 0 ) { continue; } if( !(mcs->clone[i]->end < coord_start || mcs->clone[i]->start > coord_end) ) { add_MappedCloneSet(out,hard_link_MappedClone(mcs->clone[i])); } if( mcs->clone[i]->start > coord_end ) { break; } } return out; } %func Finds a mapped clone set with this name %% MappedClone * find_named_MappedClone(MappedCloneSet * mcs,char * clone_name) { int i; /*we should have hashed. Oooops */ for(i=0;ilen;i++) { if( strcmp(mcs->clone[i]->clone_name,clone_name) == 0 ) { return mcs->clone[i]; } } return NULL; } %func sorting for MappedClones %% int start_comp_MappedClone(MappedClone * a,MappedClone * b) { if( a->start >= b->start ) { return 1; } else { return -1; } } %func Reads in a MappedCloneSet file %% MappedCloneSet * read_MappedCloneSet(FILE * ifp) { MappedCloneSet * out; MappedClone * temp; char buffer[512]; out = MappedCloneSet_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"#") == 0 ) { continue; } temp = read_MappedClone_line(buffer); if( temp == NULL ) { continue; } add_MappedCloneSet(out,temp); } sort_MappedCloneSet(out,start_comp_MappedClone); out->length = out->clone[out->len-1]->end; return out; } %func Provides a mapped clone from a name\tstart\tend format %% MappedClone * read_MappedClone_line(char * line) { MappedClone * out; char * a; char * b; char * c; char * d; char * e; char * copy; copy = stringalloc(line); out = MappedClone_alloc(); a = strtok(line,spacestr); b = strtok(NULL,spacestr); c = strtok(NULL,spacestr); d = strtok(NULL,spacestr); e = strtok(NULL,spacestr); if( a == NULL || b == NULL || c == NULL || d == NULL || e == NULL ) { warn("Bad clone line %s",copy); ckfree(copy); return NULL; } out->start = atol(a); out->end = atol(b); out->clone_name = stringalloc(c); out->accession = stringalloc(d); out->contig = stringalloc(e); ckfree(copy); return out; } wise-2.4.1/src/models/threestatemodel.pod0000644000175000001440000002347510670453715020043 0ustar philippusers=head1 NAME threestatemodel module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item ThreeStateModel =item ThreeStateUnit =back =head1 DESCRIPTION =head2 Object ThreeStateModel =over =item name Type [char *] Scalar name of the model =item unit Type [ThreeStateUnit **] List the actuall three state probs and emissions =item alphabet Type [char *] Scalar alphabet used =item accession Type [char *] Scalar accession number =item threshold Type [double] Scalar bits threshold (if sensible) =item rm Type [RandomModel *] Scalar Random model for the model: maybe NULL! =back This is profile-HMM object, similar to the SAM and HMMer plan9 architecture. =head2 Member functions of ThreeStateModel =over =item force_global_model &Wise2::ThreeStateModel::force_global_model(tsm,prob_into_model) Makes start at position 0 and end at position end, no other positions being valid Argument tsm [UNKN ] ThreeStateModel to be 'forced' [ThreeStateModel *] Argument prob_into_model [UNKN ] Probability to start the model: for true global will be 1.0 [double] Return [UNKN ] Undocumented return value [void] =item force_weighted_local_model &Wise2::ThreeStateModel::force_weighted_local_model(tsm,prob_into_model,ratio_start,ratio_end) places the ratio of probability to start/end, and then distributes the rest over the start/end Argument tsm [UNKN ] ThreeStateModel to be 'forced' [ThreeStateModel *] Argument prob_into_model [UNKN ] Probability to start the model: for true global will be 1.0 [double] Argument ratio_start [UNKN ] ratio of prob to unit 0 to the rest (1.0 means all goes to start) [double] Argument ratio_end [UNKN ] ratio of prob to unit (last) to the rest (1.0 means all goes to the end) [double] Return [UNKN ] Undocumented return value [void] =item ThreeStateModel_from_half_bit_Sequence &Wise2::ThreeStateModel::ThreeStateModel_from_half_bit_Sequence(pro,mat,rm,gap,ext) Makes a local three-state-model from a sequence. this is scary hackery, assumming that the matrix is half-bits and normalising in a *very* wrong way to get "probabilities" out. Works though Argument pro [READ ] protein sequence [Protein *] Argument mat [READ ] comparison matrix to use [CompMat *] Argument rm [READ ] random model which you assumme the matrix was built with [RandomModel *] Argument gap [READ ] gap open penalty [int] Argument ext [READ ] gap ext penalty [int] Return [UNKN ] Undocumented return value [ThreeStateModel *] =item write_HMMer_1_7_ascii_ThreeStateModel &Wise2::ThreeStateModel::write_HMMer_1_7_ascii_ThreeStateModel(tsm,ofp) writes a HMMer version 1.7 (also ok with 1.8) file Argument tsm [UNKN ] Undocumented argument [ThreeStateModel *] Argument ofp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [void] =item hard_link_ThreeStateModel &Wise2::ThreeStateModel::hard_link_ThreeStateModel(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [ThreeStateModel *] Return [UNKN ] Undocumented return value [ThreeStateModel *] =item ThreeStateModel_alloc_std &Wise2::ThreeStateModel::ThreeStateModel_alloc_std(void) Equivalent to ThreeStateModel_alloc_len(ThreeStateModelLISTLENGTH) Return [UNKN ] Undocumented return value [ThreeStateModel *] =item set_name &Wise2::ThreeStateModel::set_name(obj,name) Replace member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateModel *] Argument name [OWNER] New value of the variable [char *] Return [SOFT ] member variable name [boolean] =item name &Wise2::ThreeStateModel::name(obj) Access member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateModel *] Return [SOFT ] member variable name [char *] =item unit &Wise2::ThreeStateModel::unit(obj,i) Access members stored in the unit list For use principly by API functions Argument obj [UNKN ] Object holding the list [ThreeStateModel *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [ThreeStateUnit *] =item length_unit &Wise2::ThreeStateModel::length_unit(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [ThreeStateModel *] Return [UNKN ] length of the list [int] =item flush_unit &Wise2::ThreeStateModel::flush_unit(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [ThreeStateModel *] Return [UNKN ] Undocumented return value [int] =item add_unit &Wise2::ThreeStateModel::add_unit(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [ThreeStateModel *] Argument add [OWNER] Object to add to the list [ThreeStateUnit *] Return [UNKN ] Undocumented return value [boolean] =item set_alphabet &Wise2::ThreeStateModel::set_alphabet(obj,alphabet) Replace member variable alphabet For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateModel *] Argument alphabet [OWNER] New value of the variable [char *] Return [SOFT ] member variable alphabet [boolean] =item alphabet &Wise2::ThreeStateModel::alphabet(obj) Access member variable alphabet For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateModel *] Return [SOFT ] member variable alphabet [char *] =item set_accession &Wise2::ThreeStateModel::set_accession(obj,accession) Replace member variable accession For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateModel *] Argument accession [OWNER] New value of the variable [char *] Return [SOFT ] member variable accession [boolean] =item accession &Wise2::ThreeStateModel::accession(obj) Access member variable accession For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateModel *] Return [SOFT ] member variable accession [char *] =item set_threshold &Wise2::ThreeStateModel::set_threshold(obj,threshold) Replace member variable threshold For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateModel *] Argument threshold [OWNER] New value of the variable [double] Return [SOFT ] member variable threshold [boolean] =item threshold &Wise2::ThreeStateModel::threshold(obj) Access member variable threshold For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateModel *] Return [SOFT ] member variable threshold [double] =item set_rm &Wise2::ThreeStateModel::set_rm(obj,rm) Replace member variable rm For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateModel *] Argument rm [OWNER] New value of the variable [RandomModel *] Return [SOFT ] member variable rm [boolean] =item rm &Wise2::ThreeStateModel::rm(obj) Access member variable rm For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateModel *] Return [SOFT ] member variable rm [RandomModel *] =back =head2 Object ThreeStateUnit =over =item match_emission[ALPHABET_SIZE] Type [Probability] Scalar No documentation =item insert_emission[ALPHABET_SIZE] Type [Probability] Scalar No documentation =item transition[TRANSITION_LEN] Type [Probability] Scalar No documentation =item display_char Type [char] Scalar No documentation =back This object is the probability version of hte common unit to profile HMMs, ie the match,insert,delete triple =head2 Member functions of ThreeStateUnit =over =item hard_link_ThreeStateUnit &Wise2::ThreeStateUnit::hard_link_ThreeStateUnit(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [ThreeStateUnit *] Return [UNKN ] Undocumented return value [ThreeStateUnit *] =item alloc &Wise2::ThreeStateUnit::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [ThreeStateUnit *] =item set_display_char &Wise2::ThreeStateUnit::set_display_char(obj,display_char) Replace member variable display_char For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateUnit *] Argument display_char [OWNER] New value of the variable [char] Return [SOFT ] member variable display_char [boolean] =item display_char &Wise2::ThreeStateUnit::display_char(obj) Access member variable display_char For use principly by API functions Argument obj [UNKN ] Object holding the variable [ThreeStateUnit *] Return [SOFT ] member variable display_char [char] =back =over =item read_HMMer_1_7_ascii_file &Wise2::read_HMMer_1_7_ascii_file(filename) reads a HMMer ascii version 1.7 (1.8) file from filename. Argument filename [UNKN ] the name fo the hmmer file [char *] Return [UNKN ] Undocumented return value [ThreeStateModel *] =item read_HMMer_1_7_ascii &Wise2::read_HMMer_1_7_ascii(ifp) Basic function to read HMMer version 1.7(1.8) files. Argument ifp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [ThreeStateModel *] =back wise-2.4.1/src/models/threestatemodel.tex0000644000175000001440000001322510670453715020051 0ustar philippusers\section{threestatemodel} \label{module_threestatemodel} This module contains the following objects \begin{itemize} \item \ref{object_ThreeStateModel} ThreeStateModel \item \ref{object_ThreeStateUnit} ThreeStateUnit \item This module also contains some factory methods \end{itemize} \subsection{threestatemodel factory methods} \subsubsection{read_HMMer_1_7_ascii_file} \begin{description} \item[External C] {\tt Wise2_read_HMMer_1_7_ascii_file (filename)} \item[Perl] {\tt &Wise2::read_HMMer_1_7_ascii_file (filename)} \end{description} Arguments \begin{description} \item[filename] [UNKN ] the name fo the hmmer file [char *] \item[returns] [UNKN ] Undocumented return value [ThreeStateModel *] \end{description} reads a HMMer ascii version 1.7 (1.8) file from filename. \subsubsection{read_HMMer_1_7_ascii} \begin{description} \item[External C] {\tt Wise2_read_HMMer_1_7_ascii (ifp)} \item[Perl] {\tt &Wise2::read_HMMer_1_7_ascii (ifp)} \end{description} Arguments \begin{description} \item[ifp] [UNKN ] Undocumented argument [FILE *] \item[returns] [UNKN ] Undocumented return value [ThreeStateModel *] \end{description} Basic function to read HMMer version 1.7(1.8) files. \subsection{Object ThreeStateModel} \label{object_ThreeStateModel} The ThreeStateModel object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{name} Type [char * : Scalar] name of the model \item{unit} Type [ThreeStateUnit ** : List] the actuall three state probs and emissions \item{alphabet} Type [char * : Scalar] alphabet used \item{accession} Type [char * : Scalar] accession number \item{threshold} Type [double : Scalar] bits threshold (if sensible) \item{rm} Type [RandomModel * : Scalar] Random model for the model: maybe NULL! \end{description} This is profile-HMM object, similar to the SAM and HMMer plan9 architecture. Member functions of ThreeStateModel \subsubsection{force_global_model} \begin{description} \item[External C] {\tt Wise2_force_global_model (tsm,prob_into_model)} \item[Perl] {\tt &Wise2::ThreeStateModel::force_global_model (tsm,prob_into_model)} \item[Perl-OOP call] {\tt $obj->force_global_model(prob_into_model)} \end{description} Arguments \begin{description} \item[tsm] [UNKN ] ThreeStateModel to be 'forced' [ThreeStateModel *] \item[prob_into_model] [UNKN ] Probability to start the model: for true global will be 1.0 [double] \item[returns] Nothing - no return value \end{description} Makes start at position 0 and end at position end, no other positions being valid \subsubsection{force_weighted_local_model} \begin{description} \item[External C] {\tt Wise2_force_weighted_local_model (tsm,prob_into_model,ratio_start,ratio_end)} \item[Perl] {\tt &Wise2::ThreeStateModel::force_weighted_local_model (tsm,prob_into_model,ratio_start,ratio_end)} \item[Perl-OOP call] {\tt $obj->force_weighted_local_model(prob_into_model,ratio_start,ratio_end)} \end{description} Arguments \begin{description} \item[tsm] [UNKN ] ThreeStateModel to be 'forced' [ThreeStateModel *] \item[prob_into_model] [UNKN ] Probability to start the model: for true global will be 1.0 [double] \item[ratio_start] [UNKN ] ratio of prob to unit 0 to the rest (1.0 means all goes to start) [double] \item[ratio_end] [UNKN ] ratio of prob to unit (last) to the rest (1.0 means all goes to the end) [double] \item[returns] Nothing - no return value \end{description} places the ratio of probability to start/end, and then distributes the rest over the start/end \subsubsection{ThreeStateModel_from_half_bit_Sequence} \begin{description} \item[External C] {\tt Wise2_ThreeStateModel_from_half_bit_Sequence (pro,mat,rm,gap,ext)} \item[Perl] {\tt &Wise2::ThreeStateModel::ThreeStateModel_from_half_bit_Sequence (pro,mat,rm,gap,ext)} \item[Perl-OOP call] {\tt $obj->ThreeStateModel_from_half_bit_Sequence(mat,rm,gap,ext)} \end{description} Arguments \begin{description} \item[pro] [READ ] protein sequence [Protein *] \item[mat] [READ ] comparison matrix to use [CompMat *] \item[rm] [READ ] random model which you assumme the matrix was built with [RandomModel *] \item[gap] [READ ] gap open penalty [int] \item[ext] [READ ] gap ext penalty [int] \item[returns] [UNKN ] Undocumented return value [ThreeStateModel *] \end{description} Makes a local three-state-model from a sequence. this is scary hackery, assumming that the matrix is half-bits and normalising in a *very* wrong way to get "probabilities" out. Works though \subsubsection{write_HMMer_1_7_ascii_ThreeStateModel} \begin{description} \item[External C] {\tt Wise2_write_HMMer_1_7_ascii_ThreeStateModel (tsm,ofp)} \item[Perl] {\tt &Wise2::ThreeStateModel::write_HMMer_1_7_ascii_ThreeStateModel (tsm,ofp)} \item[Perl-OOP call] {\tt $obj->write_HMMer_1_7_ascii_ThreeStateModel(ofp)} \end{description} Arguments \begin{description} \item[tsm] [UNKN ] Undocumented argument [ThreeStateModel *] \item[ofp] [UNKN ] Undocumented argument [FILE *] \item[returns] Nothing - no return value \end{description} writes a HMMer version 1.7 (also ok with 1.8) file \subsection{Object ThreeStateUnit} \label{object_ThreeStateUnit} The ThreeStateUnit object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{match_emission[ALPHABET_SIZE]} Type [Probability : Scalar] No documentation \item{insert_emission[ALPHABET_SIZE]} Type [Probability : Scalar] No documentation \item{transition[TRANSITION_LEN]} Type [Probability : Scalar] No documentation \item{display_char} Type [char : Scalar] No documentation \end{description} This object is the probability version of hte common unit to profile HMMs, ie the match,insert,delete triple Member functions of ThreeStateUnit wise-2.4.1/src/models/dba.dy0000644000175000001440000000606007313404543015214 0ustar philippusers %{ #include "dyna.h" %} matrix DnaMatchBlock query type="DNA" name="query" target type="DNA" name="target" resource type="DnaMatrix*" name="comp65" resource type="DnaMatrix*" name="comp75" resource type="DnaMatrix*" name="comp85" resource type="DnaMatrix*" name="comp95" resource type="Score" name="g" resource type="Score" name="u" resource type="Score" name="v" resource type="Score" name="s" resource type="Score" name="b" state MATCH65 source MATCH65 offi="1" offj="1" calc="comp65->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + s" endsource source MATCH65 offi="0" offj="1" calc="g" target_label MI65 endsource source MATCH65 offi="1" offj="0" calc="g" query_label MI65 endsource source UNMATCHED_TARGET offi="1" offj="1" calc="comp65->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + v" endsource query_label MM65 target_label MM65 endstate state MATCH75 source MATCH75 offi="1" offj="1" calc="comp75->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + s" endsource source MATCH75 offi="0" offj="1" calc="g" target_label MI75 endsource source MATCH75 offi="1" offj="0" calc="g" query_label MI75 endsource source UNMATCHED_TARGET offi="1" offj="1" calc="comp75->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + v" endsource query_label MM75 target_label MM75 endstate state MATCH85 source MATCH85 offi="1" offj="1" calc="comp85->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + s" endsource source MATCH85 offi="0" offj="1" calc="g" target_label MI85 endsource source MATCH85 offi="1" offj="0" calc="g" query_label MI85 endsource source UNMATCHED_TARGET offi="1" offj="1" calc="comp85->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + v" endsource query_label MM85 target_label MM85 endstate state MATCH95 source MATCH95 offi="1" offj="1" calc="comp95->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + s" endsource source MATCH95 offi="0" offj="1" calc="g" target_label MI95 endsource source MATCH95 offi="1" offj="0" calc="g" query_label MI95 endsource source UNMATCHED_TARGET offi="1" offj="1" calc="comp95->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + v" endsource query_label MM95 target_label MM95 endstate state UNMATCHED_QUERY offi="1" offj="0" source MATCH65 calc="b" endsource source MATCH75 calc="b" endsource source MATCH85 calc="b" endsource source MATCH95 calc="b" endsource source UNMATCHED_QUERY calc="u" endsource source START !top !left calc="0" endsource query_label UM target_label UI endstate state UNMATCHED_TARGET offi="0" offj="1" source UNMATCHED_QUERY calc="v" endsource source UNMATCHED_TARGET calc="u" endsource target_label UM query_label UI endstate state START !special !start query_label START target_label START endstate state END !special !end source UNMATCHED_TARGET !right !bottom calc="0" endsource query_label END target_label END endstate endmatrix wise-2.4.1/src/models/dbac.c0000644000175000001440000005642607644752045015212 0ustar philippusers /* * this main is a real mess and needs to be completely * reworked. ugh! ugh! * * Will do this in 2.2.4 onwards * */ /* * $Revision: 1.11 $ * $Id: dbac.c,v 1.11 2003/04/09 08:04:53 birney Exp $ */ typedef int BOOL ; #define TRUE 1 #define FALSE 0 /*WK #define MAXD 1.0E300 */ /*#define DOPROB*/ #include "dba.h" #include "slimdba.h" #include "bigdba.h" #include "dbadisplay.h" #include "version.h" #include "seqalign.h" /* * Dbb alignment. Idea by R. Durbin */ static Probability MATCH55 = 0.55 ; static Probability MATCH65 = 0.65 ; static Probability MATCH75 = 0.75 ; static Probability MATCH85 = 0.85 ; static Probability MATCH95 = 0.95 ; static Probability MATCHS = 0.8 ; static Probability GAP = 0.05 ; static Probability BLOCKOPEN = 0.01 ; static Probability UNMATCHED_PEN = 0.99; static Probability GAP55 = 0.10; static Probability GAP65 = 0.10; int kbyte = 25000; void prettyAlnBlock (AlnBlock *alb, Sequence *one, Sequence *two) { AlnColumn *alc ; AlnUnit *alu ; for (alc = alb->start ; alc ; alc = alc->next) { alu = alc->alu[0] ; if (!alu->text_label) alu->text_label = "empty_label" ; printf ("%2s ", alu->text_label) ; if (alu->end > alu->start) printf ("%5d %c", alu->end, one->seq[alu->end]) ; else printf (" ") ; alu = alc->alu[1] ; if (alu->end > alu->start) printf (" %c %5d", two->seq[alu->end], alu->end) ; else printf (" ") ; if (!alu->text_label) alu->text_label = "empty_label" ; printf (" %2s", alu->text_label) ; printf ("\n") ; } } void alnBlockSummary (AlnBlock *alb, Sequence *x, Sequence *y) { AlnColumn *alc ; AlnUnit *xa, *ya ; BOOL inBlock = FALSE ; /* int type = 0; */ /* char * type; */ /* type = malloc(8); */ char t[8]; char * type = &t[0]; int nMatch, nMismatch, nGap, x1, y1 ; for (alc = alb->start ; alc ; alc = alc->next) { xa = alc->alu[0] ; ya = alc->alu[1] ; if (*xa->text_label == 'M') { if (!inBlock) { inBlock = TRUE ; if (xa->text_label[2] == '6') { /* type = 65; */ /* type = MATCH65 * 100; */ type = "MATCH_A"; } else if (xa->text_label[2] == '7') { /* type = 75; */ /* type = MATCH75 * 100; */ type = "MATCH_B"; } else if (xa->text_label[2] == '8') { /* type = 85; */ /* type = MATCH85 * 100; */ type = "MATCH_C"; } else if (xa->text_label[2] == '9') { /* type = 95; */ /* type = MATCH95 * 100; */ type = "MATCH_D"; } nMatch = nMismatch = nGap = 0 ; x1 = xa->end ; y1 = ya->end ; } if (xa->text_label[1] == 'I' || ya->text_label[1] == 'I') ++nGap ; else if (x->seq[xa->end] == y->seq[ya->end]) ++nMatch ; else ++nMismatch ; } else if (inBlock) { /* printf ("%6d %6d %6d %6d %2d%% %d gaps, %d\n", x1, xa->start, y1, ya->start, (int)((100.0*nMatch)/(nMatch + nMismatch) + 0.5), nGap, nMatch*MATCH + nMismatch*MISMATCH + nGap*GAP +BLOCKOPEN) ; */ /* printf ("%6d %6d %6d %6d %2d%% %d gaps, %s\n", x1, xa->start, y1, ya->start, (int)((100.0*nMatch)/(nMatch + nMismatch) + 0.5), nGap, type) ; */ printf ("%6d %6d %6d %6d %2d%% %d gaps, %s\n", x1 + 1, xa->start + 1, y1 +1 , ya->start + 1, (int)((100.0*nMatch)/(nMatch + nMismatch) + 0.5), nGap, type) ; inBlock = FALSE ; } } /* free(type); */ } /* * Produces phylogenetic footprinting format (gapped fasta) output, with a gff line as the comment line like this: * > DBA Block + . block ;id ;gaps ;type */ void showPFF (AlnBlock *alb, Sequence *x, Sequence *y) { AlnColumn *alc ; AlnUnit *xa, *ya ; BOOL inBlock = FALSE ; /* int type = 0; */ /* char * type; type = malloc(8); */ char t[8]; char * type = &t[0]; int nMatch, nMismatch, nGap, x1, y1, xcount, ycount ; int blockCount = 0; /* used for the block numbering in the comment gff line */ /*WK double score; */ double tmpbitscore; double currMatch; double s = 1-2*GAP-BLOCKOPEN; /* used for calculating score */ char xtmp[2] = " "; /* The Jareborg way of C programming: */ char ytmp[2] = " "; /* these are used for converting the */ char * xstr = &xtmp[0]; /* nucleotide chars to strings when */ char * ystr = &ytmp[0]; /* building the gapped sequence */ char * xSeq; /* holder for the gapped x sequence */ char * ySeq; /* holder for the gapped y sequence */ xSeq = malloc(2 * x->len); /* allocate enough memory to hold the gapped x sequence */ ySeq = malloc(2 * y->len); /* allocate enough memory to hold the gapped y sequence */ if (xSeq == NULL) { fprintf(stderr, "Can't allocate memory for sequence x\n"); exit(1); } if (ySeq == NULL) { fprintf(stderr, "Can't allocate memory for sequence y\n"); exit(1); } /* make sure the sequence strings are empty before we start */ strcpy (xSeq, ""); strcpy (ySeq, ""); for (alc = alb->start ; alc ; alc = alc->next) { xa = alc->alu[0] ; ya = alc->alu[1] ; if (*xa->text_label == 'M') { if (!inBlock) { inBlock = TRUE ; blockCount++; tmpbitscore = (log((((1-UNMATCHED_PEN)/(UNMATCHED_PEN*UNMATCHED_PEN)) * (BLOCKOPEN/UNMATCHED_PEN)) / 4))/log(2); if (xa->text_label[2] == '6') { /* type = 65; */ /* type = MATCH65 * 100; */ type = "MATCH_A"; currMatch = MATCH65; } else if (xa->text_label[2] == '7') { /* type = 75; */ /* type = MATCH75 * 100; */ type = "MATCH_B"; currMatch = MATCH75; } else if (xa->text_label[2] == '8') { /* type = 85; */ /* type = MATCH85 * 100; */ type = "MATCH_C"; currMatch = MATCH85; } else if (xa->text_label[2] == '9') { /* type = 95; */ /* type = MATCH95 * 100; */ type = "MATCH_D"; currMatch = MATCH95; } nMatch = nMismatch = nGap = 0 ; x1 = xa->end ; y1 = ya->end ; } if (xa->text_label[1] == 'I') { ++nGap ; xtmp[0] = x->seq[xa->end]; strcat(xSeq, xstr); strcat(ySeq, "."); tmpbitscore += (log(GAP/UNMATCHED_PEN))/log(2); } else if (ya->text_label[1] == 'I') { ++nGap; strcat(xSeq, "."); ytmp[0] = y->seq[ya->end]; strcat(ySeq, ystr); tmpbitscore += (log(GAP/UNMATCHED_PEN))/log(2); } else if (x->seq[xa->end] == y->seq[ya->end]) { ++nMatch ; /* printf("nucl %c\n", x->seq[xa->end]); */ xtmp[0] = x->seq[xa->end]; strcat(xSeq, xstr); ytmp[0] = y->seq[ya->end]; strcat(ySeq, ystr); tmpbitscore += (log( (s/(UNMATCHED_PEN*UNMATCHED_PEN)) *(currMatch/0.25)))/log(2); } else { ++nMismatch ; xtmp[0] = x->seq[xa->end]; strcat(xSeq, xstr); ytmp[0] = y->seq[ya->end]; strcat(ySeq, ystr); tmpbitscore += (log( (s/(UNMATCHED_PEN*UNMATCHED_PEN)) *( ((1-currMatch)/3)/0.25 )))/log(2); } } else if (inBlock) { double bitscore = tmpbitscore; /* print comment gff line for x */ /* printf (">%s\tDBA\tBlock\t%d\t%d\t%.2f\t+\t.\tblock %2d; id %d; gaps %d; type %s\n", x->name, x1, xa->start, bitscore, blockCount, (int)((100.0*nMatch)/(nMatch + nMismatch) + 0.5), nGap, type) ; */ printf (">%s\tDBA\tBlock\t%d\t%d\t%.2f\t+\t.\tblock %2d; id %d; gaps %d; type %s\n", x->name, x1 + 1, xa->start + 1, bitscore, blockCount, (int)((100.0*nMatch)/(nMatch + nMismatch) + 0.5), nGap, type) ; /*print sequence for x */ xcount = 0; while(*xSeq != '\0') { putchar(*xSeq); ++xSeq; if (++xcount%60 == 0) putchar ('\n'); } putchar ('\n'); /* print comment gff line for y */ /* printf (">%s\tDBA\tBlock\t%d\t%d\t%.2f\t+\t.\tblock %2d; id %d; gaps %d; type %s\n", y->name, y1, ya->start, bitscore, blockCount, (int)((100.0*nMatch)/(nMatch + nMismatch) + 0.5), nGap, type) ; */ printf (">%s\tDBA\tBlock\t%d\t%d\t%.2f\t+\t.\tblock %2d; id %d; gaps %d; type %s\n", y->name, y1 +1 , ya->start + 1, bitscore, blockCount, (int)((100.0*nMatch)/(nMatch + nMismatch) + 0.5), nGap, type) ; /*print sequence for x */ ycount = 0; while(*ySeq != '\0') { putchar(*ySeq); ++ySeq; if (++ycount%60 == 0) putchar ('\n'); } putchar ('\n'); /* reset sequence holders */ strcpy (xSeq, ""); strcpy (ySeq, ""); inBlock = FALSE ; } } } void usage (FILE * ofp) { fprintf (ofp, "dba version: %s\n",VERSION_NUMBER) ; fprintf (ofp, "Usage: dba [options] seq1 seq2\n") ; fprintf (ofp, " -matchA [%g] match level A\n",MATCH65) ; fprintf (ofp, " -matchB [%g] match level B\n",MATCH75) ; fprintf (ofp, " -matchC [%g] match level C\n",MATCH85) ; fprintf (ofp, " -matchD [%g] match level D\n",MATCH95) ; fprintf (ofp, " -gapA [%g] (big only) Gap probability for A\n",GAP65) ; fprintf (ofp, " -gapAA [%g] (big only) Gap probability for AA\n",GAP55) ; fprintf (ofp, " -gap [%g] gap probability\n",GAP) ; fprintf (ofp, " -blockopen [%g] block open probability\n",BLOCKOPEN) ; fprintf (ofp, " -umatch [%g] unmatched gap probability\n",UNMATCHED_PEN) ; fprintf (ofp, " -single use only one match level, set with -matchA [%g]\n", MATCHS) ; fprintf (ofp, " -nomatchn do not match N to any base\n") ; fprintf (ofp, " -align show alignment for computer parsing\n") ; fprintf (ofp, " -anchor show anchored alignment to first sequence\n") ; fprintf (ofp, " -pretty show alignment for ASCII viewing\n") ; fprintf (ofp, " -pff show phylogenetic footprinting format output\n") ; fprintf (ofp, " (gapped fasta)\n") ; fprintf (ofp, " -label show label alignment\n") ; fprintf (ofp, " -slim use slim DBA alignment\n") ; fprintf (ofp, " -big use big DBA alignment with AA block\n") ; fprintf (ofp, " -params print parameters\n") ; show_help_DPRunImpl(ofp); show_standard_options(ofp); exit (-1) ; } void show_version(FILE * ofp) { fprintf(ofp,"dba version %s\n",VERSION_NUMBER); fprintf(ofp," Released %s\n",RELEASE_DAY); fprintf(ofp," Compiled %s\n",COMPILE_DATE); fprintf(ofp,"dba was written by Niclas Jareborg, Ewan Birney and Richard Durbin\n"); fprintf(ofp,"Copyright (c) 1998,1999,2000,2001 GRL ltd. It is distributed under a Gnu Public License\n"); fprintf(ofp,"See GNULICENSE in source directory for more information\n"); } SeqAlign * make_SeqAlign_from_align(AlnBlock * alb,Sequence * one,Sequence * two) { Sequence * one_align; Sequence * two_align; SeqAlign * out; AlnColumn * alc; int i; char * seq; /* one is anchor - easy! */ one_align = new_Sequence_from_strings(one->name,one->seq); /* next one is harder! */ seq = calloc(one->len,sizeof(char)); for(i=0,alc=alb->start;ilen;i++) { seq[i] = '~'; if( alc == NULL ) { continue; } if( alc->alu[0]->start+1 < i ) { for(;alc->alu[0]->start+1 != i;alc = alc->next) ; } if( alc != NULL && alc->alu[0]->start+1 == i ) { if( strstr(alc->alu[0]->text_label,"MM") != NULL ) { seq[i] = two->seq[alc->alu[1]->start+1]; } else if ( strstr(alc->alu[0]->text_label,"MI") != NULL ) { seq[i] = '-'; } else{ ; } alc = alc->next; } } seq[one->len] = '\0'; fprintf(stderr,"Got %d with %d vs %d\n",i,strlen(seq),one->len); two_align = new_Sequence_from_strings(two->name,seq); out = SeqAlign_alloc_len(2); add_SeqAlign(out,one_align); add_SeqAlign(out,two_align); return out; } int main (int argc, char **argv) { Sequence *one, *two ; ComplexSequence *cone, *ctwo ; ComplexSequenceEvalSet *cses ; DnaMatrix *dcm55 ; DnaMatrix *dcm65 ; DnaMatrix *dcm75 ; DnaMatrix *dcm85 ; DnaMatrix *dcm95 ; DnaProbMatrix * dpm55; DnaProbMatrix * dpm65; DnaProbMatrix * dpm75; DnaProbMatrix * dpm85; DnaProbMatrix * dpm95; int temp; PackAln *pal ; AlnBlock *alb ; int isShowAlign = 0 ; int isShowParams = 0 ; int show_label_align = 0; int show_pretty_align = 0; int isNoMatchN = 0; /* changed Jan 28 (nic) */ int isSingle = 0; int aSet = 0; int show_pff = 0; int show_anchor = 0; int use_slim = 0; int use_big = 0; SeqAlign * seqalign; DnaMatchBlock * dmat; DPRunImpl * dpri; int score; strip_out_standard_options(&argc,argv,usage,show_version); /* run time */ dpri = new_DPRunImpl_from_argv(&argc,argv); for (++argv, --argc ; argc > 2 ; ++argv, --argc) if (!strcmp (*argv, "-align")) isShowAlign = 1 ; else if (!strcmp (*argv, "-params")) isShowParams = 1 ; else if (!strcmp (*argv, "-label")) show_label_align = 1; else if (!strcmp (*argv, "-pretty")) show_pretty_align = 1; else if (!strcmp (*argv, "-matchA")) { MATCH65 = atof (*++argv) ; --argc ; aSet = 1; } else if (!strcmp (*argv, "-matchB")) { MATCH75 = atof (*++argv) ; --argc ; } else if (!strcmp (*argv, "-matchC")) { MATCH85 = atof (*++argv) ; --argc ; } else if (!strcmp (*argv, "-matchD")) { MATCH95 = atof (*++argv) ; --argc ; } else if (!strcmp (*argv, "-gapA")) { GAP65 = atof (*++argv) ; --argc ; } else if (!strcmp (*argv, "-gapAA")) { GAP55 = atof (*++argv) ; --argc ; } else if (!strcmp (*argv, "-umatch")) { UNMATCHED_PEN = atof (*++argv) ; --argc ; } else if (!strcmp (*argv, "-gap")) { GAP = atof (*++argv) ; --argc ; } else if (!strcmp (*argv, "-kbyte")) { kbyte = atoi (*++argv) ; --argc ; } else if (!strcmp (*argv, "-blockopen")) { BLOCKOPEN = atof (*++argv) ; --argc ; } else if (!strcmp (*argv, "-single")) { isSingle = 1 ; } else if (!strcmp (*argv, "-nomatchn")) /* changed Jan 28 (nic) */ isNoMatchN = 1 ; else if (!strcmp (*argv, "-pff")) show_pff = 1 ; else if (!strcmp (*argv, "-anchor")) show_anchor = 1 ; else if (!strcmp (*argv, "-slim")) use_slim = 1 ; else if (!strcmp (*argv, "-big")) use_big = 1 ; else { fprintf (stderr, "option %s not recognized\n", *argv) ; usage(stdout) ; } if (argc < 2) usage(stdout) ; if(isSingle) { MATCH75 = 0; MATCH85 = 0; MATCH95 = 0; if (!aSet) { MATCH65 = MATCHS; } } if (isShowParams) printf ("MATCH_A = %g, MATCH_B = %g, MATCH_C = %g, MATCH_D = %g, UMATCH = %g, GAP = %g, BLOCKOPEN = %g\n", MATCH65, MATCH75, MATCH85, MATCH95, UNMATCHED_PEN, GAP, BLOCKOPEN) ; /* * we should use type-safe DNA * * here, but what the hell... * */ one = read_fasta_file_Sequence(*argv++); two = read_fasta_file_Sequence(*argv++); uppercase_Sequence(one); uppercase_Sequence(two); /* * make sure sequences are DNA. Complain if they over 50% no ATGCN */ force_to_dna_Sequence(one,0.0,&temp); if( temp > (one->len/2) ) { warn("Sequence %s has more than 50% of its residues no ATGCN. Are you sure its DNA?",one->name); } force_to_dna_Sequence(two,0.0,&temp); if( temp > (two->len/2) ) { warn("Sequence %s has more than 50% of its residues no ATGCN. Are you sure its DNA?",two->name); } one->type = SEQUENCE_DNA; two->type = SEQUENCE_DNA; /** make them into DNA complex sequences **/ cses = default_DNA_ComplexSequenceEvalSet(); cone = new_ComplexSequence(one,cses); ctwo = new_ComplexSequence(two,cses); if( cone == NULL || ctwo == NULL ) { fatal("For some reason, unable to make complexsequences"); } /** make DnaProbMat's **/ dpm55 = DnaProbMatrix_from_match(MATCH55,isNoMatchN == 1 ? NMaskType_BANNED : NMaskType_VARIABLE); if( dpm55 == NULL ) { fatal("Could not build DnaProbMatrix for MATCH65"); } flat_null_DnaProbMatrix(dpm55); dpm65 = DnaProbMatrix_from_match(MATCH65,isNoMatchN == 1 ? NMaskType_BANNED : NMaskType_VARIABLE); if( dpm65 == NULL ) { fatal("Could not build DnaProbMatrix for MATCH65"); } flat_null_DnaProbMatrix(dpm65); dpm75 = DnaProbMatrix_from_match(MATCH75,isNoMatchN == 1 ? NMaskType_BANNED : NMaskType_VARIABLE); if( dpm75 == NULL ) { fatal("Could not build DnaProbMatrix for MATCH75"); } flat_null_DnaProbMatrix(dpm75); dpm85 = DnaProbMatrix_from_match(MATCH85,isNoMatchN == 1 ? NMaskType_BANNED : NMaskType_VARIABLE); if( dpm85 == NULL ) { fatal("Could not build DnaProbMatrix for MATCH85"); } flat_null_DnaProbMatrix(dpm85); dpm95 = DnaProbMatrix_from_match(MATCH95,isNoMatchN == 1 ? NMaskType_BANNED : NMaskType_VARIABLE); if( dpm95 == NULL ) { fatal("Could not build DnaProbMatrix for MATCH95"); } flat_null_DnaProbMatrix(dpm95); dcm55 = DnaMatrix_from_DnaProbMatrix(dpm55); if( dcm55 == NULL ) { fatal("Could not build DnaCompMat 55"); } dcm65 = DnaMatrix_from_DnaProbMatrix(dpm65); if( dcm65 == NULL ) { fatal("Could not build DnaCompMat 65"); } dcm75 = DnaMatrix_from_DnaProbMatrix(dpm75); if( dcm75 == NULL ) { fatal("Could not build DnaCompMat 75"); } dcm85 = DnaMatrix_from_DnaProbMatrix(dpm85); if( dcm85 == NULL ) { fatal("Could not build DnaCompMat 85"); } dcm95 = DnaMatrix_from_DnaProbMatrix(dpm95); if( dcm95 == NULL ) { fatal("Could not build DnaCompMat 95"); } /** make the alignment **/ change_max_BaseMatrix_kbytes (kbyte) ; /* 25Mb */ if( use_big == 1 ) { pal = PackAln_bestmemory_BigDnaMatchBlock (cone, ctwo, dcm55, dcm65, dcm75, dcm85, dcm95, Probability2Score(GAP/UNMATCHED_PEN), Probability2Score(GAP65/UNMATCHED_PEN), Probability2Score(GAP55/UNMATCHED_PEN), Probability2Score(1), /* horrible hack here so that single searches are not / 4 */ Probability2Score(((1-UNMATCHED_PEN)/(UNMATCHED_PEN))/ (isSingle == TRUE ? 1 : 4)), Probability2Score((1.0 - (GAP + GAP + BLOCKOPEN))/(UNMATCHED_PEN*UNMATCHED_PEN)), Probability2Score(BLOCKOPEN/UNMATCHED_PEN), NULL,dpri ); alb = convert_PackAln_to_AlnBlock_BigDnaMatchBlock(pal); } else if( use_slim == 1 ) { pal = PackAln_bestmemory_SlimDnaMatchBlock (cone, ctwo, dcm65, Probability2Score(GAP/UNMATCHED_PEN), Probability2Score(1), /* horrible hack here so that single searches are not / 4 */ Probability2Score(((1-UNMATCHED_PEN)/(UNMATCHED_PEN))/ (isSingle == TRUE ? 1 : 4)), Probability2Score((1.0 - (GAP + GAP + BLOCKOPEN))/(UNMATCHED_PEN*UNMATCHED_PEN)), Probability2Score(BLOCKOPEN/UNMATCHED_PEN), NULL,dpri ); alb = convert_PackAln_to_AlnBlock_DnaMatchBlock(pal); } else { pal = PackAln_bestmemory_DnaMatchBlock (cone, ctwo, dcm65, dcm75, dcm85, dcm95, Probability2Score(GAP/UNMATCHED_PEN), Probability2Score(1), /* horrible hack here so that single searches are not / 4 */ Probability2Score(((1-UNMATCHED_PEN)/(UNMATCHED_PEN))/ (isSingle == TRUE ? 1 : 4)), Probability2Score((1.0 - (GAP + GAP + BLOCKOPEN))/(UNMATCHED_PEN*UNMATCHED_PEN)), Probability2Score(BLOCKOPEN/UNMATCHED_PEN), NULL,dpri ); #ifdef DOPROB dmat = matrix_logsum_DnaMatchBlock(cone, ctwo, dcm65, dcm75, dcm85, dcm95, Probability2Score(GAP/UNMATCHED_PEN), Probability2Score(1), /* horrible hack here so that single searches are not / 4 */ Probability2Score(((1-UNMATCHED_PEN)/(UNMATCHED_PEN))/ (isSingle == TRUE ? 1 : 4)), Probability2Score((1.0 - (GAP + GAP + BLOCKOPEN))/(UNMATCHED_PEN*UNMATCHED_PEN)), Probability2Score(BLOCKOPEN/UNMATCHED_PEN) ); fprintf(stdout,"And the score is %d %.2f\n",dmat->basematrix->matrix[dmat->basematrix->leni-1][dmat->basematrix->lenj-1],Score2Bits(dmat->basematrix->matrix[dmat->basematrix->leni-1][dmat->basematrix->lenj-1])); score = score_only_logsum_DnaMatchBlock(cone, ctwo, dcm65, dcm75, dcm85, dcm95, Probability2Score(GAP/UNMATCHED_PEN), Probability2Score(1), /* horrible hack here so that single searches are not / 4 */ Probability2Score(((1-UNMATCHED_PEN)/(UNMATCHED_PEN))/ (isSingle == TRUE ? 1 : 4)), Probability2Score((1.0 - (GAP + GAP + BLOCKOPEN))/(UNMATCHED_PEN*UNMATCHED_PEN)), Probability2Score(BLOCKOPEN/UNMATCHED_PEN) ); fprintf(stdout,"And the score is %d %.2f\n",score,Score2Bits(score)); #endif if( pal == NULL ) fatal("Unable to build alignment!"); alb = convert_PackAln_to_AlnBlock_DnaMatchBlock(pal); } /* alignment done! */ if( show_label_align ) { printf ("score = %.2f\n", Score2Bits(pal->score)) ; mapped_ascii_AlnBlock(alb,Score2Probability,0,stdout); } else if ( show_pretty_align ) { printf ("score = %.2f\n", Score2Bits(pal->score)) ; show_pretty_dba_align(alb,one,two,stdout); } else if (isShowAlign) { printf ("score = %.2f\n", Score2Bits(pal->score)) ; prettyAlnBlock (alb, one, two) ; } else if (show_pff) { showPFF (alb, one, two) ; } else if ( show_anchor ) { seqalign = make_SeqAlign_from_align(alb,one,two); write_fasta_SeqAlign(seqalign,stdout); free_SeqAlign(seqalign); } else { printf ("score = %.2f\n", Score2Bits(pal->score)) ; alnBlockSummary (alb, one, two) ; } return 0; } /******************* end of file ***************/ wise-2.4.1/src/models/clonewisedp.dy0000644000175000001440000000451507313404543017005 0ustar philippusers %{ #include "mapstruct.h" %} matrix CloneWise query name="q" type="MappedCloneSet *" field:len="length" target name="t" type="MappedCloneSet *" field:len="length" resource name="match" type="MappedCloneMatch*" resource name="target_skip_start" type="Score" resource name="target_skip" type="Score" resource name="query_skip_start" type="Score" resource name="query_skip" type="Score" resource name="spread" type="int" resource name="target_special_s" type="int" state MATCH offi="1" offj="1" source MATCH calc="match->matrix[i][j]+1" endsource source MATCH offi="0" offj="1" calc="0" query_label QUERY_MATCH_PAUSE endsource source MATCH offi="1" offj="0" calc="0" target_label TARGET_MATCH_PAUSE endsource source SKIP_QUERY calc="0" endsource source SKIP_TARGET calc="0" endsource source START !top !left calc="0" endsource query_label QUERY_MATCH target_label TARGET_MATCH calc="match->matrix[i][j]" endstate state SKIP_QUERY offi="1" offj="0" source MATCH calc="query_skip_start" endsource source SKIP_TARGET calc="query_skip_start" endsource source SKIP_QUERY calc="0" endsource source START !left !top calc="query_skip_start" endsource calc="match->skip_iset[i]" query_label QUERY_SKIP target_label TARGET_PAUSE endstate state SKIP_TARGET offi="0" offj="1" source MATCH calc="target_skip_start" endsource source SKIP_QUERY calc="target_skip_start" endsource source SKIP_TARGET calc="0" endsource source START !left !top calc="target_skip_start" endsource calc="match->skip_jset[j]" query_label QUERY_PAUSE target_label TARGET_SKIP endstate state START !special !start endstate state TRUSTED_SPECIAL !special offj="1" source START !left calc="0" endsource source TRUSTED_SPECIAL calc="match->skip_jset[j]-1" endsource source MATCH offj="0" calc="target_special_s" endsource source SKIP_QUERY offj="0" calc="target_special_s" endsource source SKIP_TARGET offj="0" calc="target_special_s" endsource query_label NO_QUERY_PAUSE target_label TARGET_SKIP endstate state END !special !end source TRUSTED_SPECIAL !right offj="1" calc="0" endsource query_label END target_label END endstate endmatrix wise-2.4.1/src/models/estwise3.c0000644000175000001440000100242210670453713016044 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "estwise3.h" # line 5 "estwise3.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define START 0 #define END 1 #define EstWise3_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+5)*3)+STATE][i+1] #define EstWise3_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+5] #define EstWise3_READ_OFF_ERROR -7 #define EstWise3_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+6)%6][((i+1)*3)+STATE] #define EstWise3_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+6)%6][STATE] #define EstWise3_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define EstWise3_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_EstWise3(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_EstWise3(EstWise3 * mat) { EstWise3_access_func_holder holder; holder.access_main = EstWise3_shatter_access_main; holder.access_special = EstWise3_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_EstWise3(mat,holder); } /* Function: EstWise3_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstWise3_shatter_access_main(EstWise3 * mat,int i,int j,int state) { return EstWise3_SHATTER_MATRIX(mat,i,j,state); } /* Function: EstWise3_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstWise3_shatter_access_special(EstWise3 * mat,int i,int j,int state) { return EstWise3_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_EstWise3(mat,dpenv) * * Descrip: This function calculates the EstWise3 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EstWise3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_EstWise3(EstWise3 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_2; int * SIG_1_1; int * SIG_1_4; int * SIG_1_5; int * SIG_0_3; int * SIG_0_2; int * SIG_0_1; int * SIG_0_4; int * SIG_0_5; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("EstWise3 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_1_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-5); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_0_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-5); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstWise3_SHATTER_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_1[MATCH] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_4[MATCH] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_5[MATCH] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_2[INSERT] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_1[INSERT] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_4[INSERT] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_5[INSERT] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_2[DELETE] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_1[DELETE] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_4[DELETE] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_5[DELETE] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstWise3_SHATTER_SPECIAL(mat,i,j,END) ) { EstWise3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstWise3_SHATTER_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_2[INSERT] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_4[INSERT] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_5[INSERT] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = SIG_0_2[MATCH] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = SIG_0_1[MATCH] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = SIG_0_4[MATCH] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = SIG_0_5[MATCH] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_2[DELETE] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_1[DELETE] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_4[DELETE] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_5[DELETE] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ SIG_0_0[INSERT] = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstWise3_SHATTER_SPECIAL(mat,i,j,END) ) { EstWise3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstWise3_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstWise3_SHATTER_SPECIAL(mat,i,j,END) ) { EstWise3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_EstWise3(dbsi,out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstWise3 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_EstWise3(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_EstWise3 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_EstWise3. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_EstWise3. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for EstWise3, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_EstWise3(out,querydb, targetdb ,cp); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_EstWise3 *) ckalloc(sizeof(struct thread_pool_holder_EstWise3)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->cp = cp; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_EstWise3,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for EstWise3"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from EstWise3",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_EstWise3(ptr) * * Descrip: Infinite loop code foreach thread for EstWise3 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_EstWise3(void * ptr) { struct thread_pool_holder_EstWise3 * holder; int db_status; int score; DataScore * ds; GeneWiseScore* query; ComplexSequence* target; holder = (struct thread_pool_holder_EstWise3 *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for EstWise3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstWise3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_GeneWiseDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in EstWise3 search"); } query = hard_link_GeneWiseScore(holder->query); /* get query information into datascore */ dataentry_add_GeneWiseDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_cDNADB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_cDNADB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching EstWise3, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_cDNADB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_GeneWiseScore(holder->query); /* get the next query object for the next thread */ holder->query = reload_GeneWiseDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching EstWise3, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_GeneWiseDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstWise3"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstWise3"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_cDNADB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_EstWise3(query, target ,holder->cp); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for EstWise3"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for EstWise3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for EstWise3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_GeneWiseScore(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstWise3"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_EstWise3(out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstWise3 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_EstWise3(Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp) { GeneWiseScore* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GeneWiseDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstWise3, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_cDNADB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstWise3, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_EstWise3(query, target , cp); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("EstWise3 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GeneWiseDB(ds->query,query,querydb); dataentry_add_cDNADB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_cDNADB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstWise3, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_cDNADB(target,targetdb); query = reload_GeneWiseDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching EstWise3, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GeneWiseDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_EstWise3(query,target,cp) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_EstWise3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_EstWise3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp) { int bestscore = NEGI; int i; int j; int k; EstWise3 * mat; mat = allocate_EstWise3_only(query, target , cp); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(6,(mat->leni + 1) * 3,6,2)) == NULL) { warn("Score only matrix for EstWise3 cannot be allocated, (asking for 5 by %d cells)",mat->leni*3); mat = free_EstWise3(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<7;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) EstWise3_VSMALL_MATRIX(mat,i,j,k) = NEGI; } EstWise3_VSMALL_SPECIAL(mat,i,j,START) = 0; EstWise3_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = EstWise3_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstWise3_VSMALL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstWise3_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstWise3_VSMALL_SPECIAL(mat,i,j,END) ) { EstWise3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstWise3_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstWise3_VSMALL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_VSMALL_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstWise3_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstWise3_VSMALL_SPECIAL(mat,i,j,END) ) { EstWise3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstWise3_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstWise3_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstWise3_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstWise3_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstWise3_VSMALL_SPECIAL(mat,i,j,END) ) { EstWise3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < EstWise3_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = EstWise3_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_EstWise3(mat); return bestscore; } /* Function: PackAln_bestmemory_EstWise3(query,target,cp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EstWise3 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_EstWise3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; EstWise3 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_EstWise3(query, target , cp,dpri)) == NULL ) { warn("Unable to allocate large EstWise3 version"); return NULL; } calculate_dpenv_EstWise3(mat,dpenv); out = PackAln_read_Expl_EstWise3(mat); } else { mat = allocate_EstWise3_only(query, target , cp); calculate_shatter_EstWise3(mat,dpenv); out = PackAln_read_Shatter_EstWise3(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_EstWise3(query, target , cp)) == NULL ) { warn("Unable to allocate small EstWise3 version"); return NULL; } out = PackAln_calculate_Small_EstWise3(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_EstWise3(query, target , cp,dpri)) == NULL ) { warn("Unable to allocate large EstWise3 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_EstWise3(mat); out = PackAln_read_Expl_EstWise3(mat); } } } mat = free_EstWise3(mat); return out; } /* Function: allocate_EstWise3_only(query,target,cp) * * Descrip: This function only allocates the EstWise3 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstWise3 *] * */ EstWise3 * allocate_EstWise3_only(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp) { EstWise3 * out; if((out= EstWise3_alloc()) == NULL) { warn("Allocation of basic EstWise3 structure failed..."); return NULL; } out->query = query; out->target = target; out->cp = cp; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_EstWise3(query,target,cp,dpri) * * Descrip: This function allocates the EstWise3 structure * and the basematrix area for explicit memory implementations * It calls /allocate_EstWise3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EstWise3 *] * */ EstWise3 * allocate_Expl_EstWise3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPRunImpl * dpri) { EstWise3 * out; out = allocate_EstWise3_only(query, target , cp); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+5)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+5)*3,(out->leni+1),2,out->lenj+5)) == NULL) { warn("Explicit matrix EstWise3 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_EstWise3(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_EstWise3(out); return out; } /* Function: init_EstWise3(mat) * * Descrip: This function initates EstWise3 matrix when in explicit mode * Called in /allocate_Expl_EstWise3 * * * Arg: mat [UNKN ] EstWise3 which contains explicit basematrix memory [EstWise3 *] * */ void init_EstWise3(EstWise3 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-5);j<6;j++) { EstWise3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstWise3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstWise3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j= (-5);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { EstWise3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstWise3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstWise3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } EstWise3_EXPL_SPECIAL(mat,i,j,START) = 0; EstWise3_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_EstWise3(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EstWise3 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * */ void recalculate_PackAln_EstWise3(PackAln * pal,EstWise3 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (START+3) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 1 && offj == 4 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 1 && offj == 5 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } if( offi == 1 && offj == 2 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 1 && offj == 4 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 1 && offj == 5 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } if( offi == 1 && offj == 2 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 1 && offj == 1 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 1 && offj == 4 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 1 && offj == 5 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (START+3) ) { pau->score = (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 0 && offj == 5 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } if( offi == 0 && offj == 2 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 0 && offj == 5 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } if( offi == 0 && offj == 2 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 1 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 0 && offj == 5 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->seg[i]->transition[GW_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (START+3) ) { pau->score = mat->query->seg[i]->transition[GW_START2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+3) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define EstWise3_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+5)][(i+1)*3+state]) #define EstWise3_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+6)*8) % 48][(i+1)*3+state]) #define EstWise3_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+5)]) #define EstWise3_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+5)]) #define EstWise3_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+6)*8)+(shadow+1)) % 48)][(i+1)*3 + state]) #define EstWise3_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+5)]) #define EstWise3_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+5)% 5) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define EstWise3_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+5)% 5) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define EstWise3_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+5)]) /* Function: allocate_Small_EstWise3(query,target,cp) * * Descrip: This function allocates the EstWise3 structure * and the basematrix area for a small memory implementations * It calls /allocate_EstWise3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstWise3 *] * */ #define EstWise3_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+5)]) EstWise3 * allocate_Small_EstWise3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp) { EstWise3 * out; out = allocate_EstWise3_only(query, target , cp); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(48,(out->leni + 1) * 3,16,out->lenj+5); if(out == NULL) { warn("Small shadow matrix EstWise3 cannot be allocated, (asking for 6 by %d main cells)",out->leni+2); free_EstWise3(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_EstWise3(mat,dpenv) * * Descrip: This function calculates an alignment for EstWise3 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EstWise3 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EstWise3 * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_EstWise3(EstWise3 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for EstWise3 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_EstWise3(mat,dpenv); score = start_end_find_end_EstWise3(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_EstWise3(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_EstWise3(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == EstWise3_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_EstWise3(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 3; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_EstWise3(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_EstWise3(mat) * * Descrip: This function calculates an alignment for EstWise3 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EstWise3 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EstWise3 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EstWise3 * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_EstWise3(EstWise3 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_EstWise3(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_EstWise3(mat); return out; } /* Function: AlnRangeSet_from_EstWise3(mat) * * Descrip: This function reads off a start/end structure * for EstWise3 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EstWise3 * If you have not calculated the matrix use * /AlnRange_calculate_Small_EstWise3 * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_EstWise3(EstWise3 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EstWise3"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_EstWise3(mat,&jpos); state = END; while( (temp = AlnRange_build_EstWise3(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_EstWise3(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_EstWise3 * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_EstWise3(EstWise3 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EstWise3"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_EstWise3(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_EstWise3 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = EstWise3_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_EstWise3(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == EstWise3_READ_OFF_ERROR) { warn("In AlnRange_build_EstWise3 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = EstWise3_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_EstWise3(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_EstWise3(EstWise3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_EstWise3(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EstWise3_READ_OFF_ERROR) { warn("In EstWise3 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In EstWise3 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In EstWise3 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_EstWise3(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_EstWise3(EstWise3 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstWise3_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In EstWise3 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = EstWise3_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 5,DELETE) ) { *reti = i - 1; *retj = j - 5; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-5,DELETE); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 5,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 4,DELETE) ) { *reti = i - 1; *retj = j - 4; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-4,DELETE); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 4,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-1,DELETE); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 2,DELETE) ) { *reti = i - 1; *retj = j - 2; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-2,DELETE); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 2,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 5,INSERT) ) { *reti = i - 1; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-5,INSERT); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 5,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 4,INSERT) ) { *reti = i - 1; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-4,INSERT); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 2,INSERT) ) { *reti = i - 1; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-2,INSERT); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 2,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-5,MATCH); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-4,MATCH); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in EstWise3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 5,DELETE) ) { *reti = i - 0; *retj = j - 5; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-5,DELETE); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 5,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 4,DELETE) ) { *reti = i - 0; *retj = j - 4; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-4,DELETE); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 4,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 1,DELETE) ) { *reti = i - 0; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-1,DELETE); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 1,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 2,DELETE) ) { *reti = i - 0; *retj = j - 2; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-2,DELETE); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 2,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 5,MATCH) ) { *reti = i - 0; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-5,MATCH); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 5,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 4,MATCH) ) { *reti = i - 0; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-4,MATCH); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 2,MATCH) ) { *reti = i - 0; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-2,MATCH); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 2,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 5,INSERT) ) { *reti = i - 0; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-5,INSERT); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 5,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 4,INSERT) ) { *reti = i - 0; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-4,INSERT); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-3,DELETE); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return EstWise3_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in EstWise3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return EstWise3_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in EstWise3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstWise3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_EstWise3(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_EstWise3(EstWise3 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > EstWise3_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_EstWise3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EstWise3_READ_OFF_ERROR) { warn("In special strip read EstWise3, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < EstWise3_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read EstWise3, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_EstWise3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_EstWise3(EstWise3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = EstWise3_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for EstWise3, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In EstWise3 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = EstWise3_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ default: warn("Major problem (!) - in EstWise3 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_EstWise3(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_EstWise3(EstWise3 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = EstWise3_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In EstWise3 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstWise3_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_DC_SHADOW_SPECIAL(mat,i-1,j-3,START); } return EstWise3_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstWise3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstWise3_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_DC_SHADOW_SPECIAL(mat,i-0,j-3,START); } return EstWise3_DC_SHADOW_MATRIX(mat,i - 0,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstWise3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == EstWise3_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstWise3_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return EstWise3_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstWise3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstWise3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_EstWise3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_EstWise3(EstWise3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_EstWise3(mat,starti,startj,stopi,stopj); EstWise3_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstWise3_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; EstWise3_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; EstWise3_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = EstWise3_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstWise3_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstWise3_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_HIDDEN_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstWise3_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstWise3_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstWise3_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstWise3_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } } return; } /* Function: init_hidden_EstWise3(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_EstWise3(EstWise3 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-5);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { EstWise3_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; EstWise3_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; EstWise3_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; } } return; } /* Function: full_dc_EstWise3(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_EstWise3 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_EstWise3 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [EstWise3 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_EstWise3(EstWise3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_EstWise3"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 25) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_EstWise3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_EstWise3(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_EstWise3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for EstWise3, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= EstWise3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= EstWise3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = EstWise3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_EstWise3(mat,EstWise3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),EstWise3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),EstWise3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_EstWise3(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_EstWise3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_EstWise3(EstWise3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_EstWise3(mat); EstWise3_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_EstWise3(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_EstWise3(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_EstWise3(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_EstWise3(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_EstWise3(EstWise3 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<5;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstWise3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); EstWise3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); EstWise3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( j - 3 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,DELETE,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,DELETE,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,DELETE,k); } } /* Add any movement independant score */ EstWise3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( j - 3 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INSERT,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,MATCH,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,MATCH,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,DELETE,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,DELETE,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,DELETE,k); } } /* Add any movement independant score */ EstWise3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ EstWise3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_EstWise3(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_EstWise3(EstWise3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstWise3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstWise3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstWise3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state MATCH to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } /* From state MATCH to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } /* From state MATCH to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } /* From state INSERT to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,k); } /* From state INSERT to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* From state INSERT to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,k); } /* From state INSERT to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,k); } /* From state DELETE to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,DELETE,k); } /* From state DELETE to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } /* From state DELETE to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,DELETE,k); } /* From state DELETE to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,DELETE,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstWise3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state DELETE to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } /* From state INSERT to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* From state INSERT to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,k); } /* From state INSERT to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INSERT,k); } /* From state MATCH to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,k); } /* From state MATCH to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } /* From state MATCH to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,MATCH,k); } /* From state MATCH to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,MATCH,k); } /* From state DELETE to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,DELETE,k); } /* From state DELETE to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,k); } /* From state DELETE to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,DELETE,k); } /* From state DELETE to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,DELETE,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstWise3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstWise3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstWise3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_EstWise3(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_EstWise3(EstWise3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstWise3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstWise3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstWise3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstWise3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstWise3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstWise3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstWise3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_EstWise3(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * */ } void init_dc_EstWise3(EstWise3 * mat) { register int i; register int j; register int k; for(j=0;j<7;j++) { for(i=(-1);iquery->len;i++) { EstWise3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstWise3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstWise3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; for(k=0;k<7;k++) { EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); } } } return; } /* Function: start_end_find_end_EstWise3(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [EstWise3 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_EstWise3(EstWise3 * mat,int * endj) { register int j; register int max; register int maxj; max = EstWise3_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( EstWise3_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = EstWise3_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_EstWise3(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [EstWise3] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_EstWise3(EstWise3 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (5 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (5 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state START to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state MATCH to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); } /* From state MATCH to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0)); } /* From state MATCH to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,0)); } /* From state INSERT to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,0)); } /* From state INSERT to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* From state INSERT to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,0)); } /* From state INSERT to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,0)); } /* From state DELETE to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,DELETE,0)); } /* From state DELETE to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,0)); } /* From state DELETE to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,DELETE,0)); } /* From state DELETE to state MATCH */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,DELETE,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstWise3_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstWise3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstWise3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state DELETE to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0)); } /* From state START to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INSERT to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* From state INSERT to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,0)); } /* From state INSERT to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INSERT,0)); } /* From state MATCH to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,0)); } /* From state MATCH to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); } /* From state MATCH to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,MATCH,0)); } /* From state MATCH to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,MATCH,0)); } /* From state DELETE to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,DELETE,0)); } /* From state DELETE to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,0)); } /* From state DELETE to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,DELETE,0)); } /* From state DELETE to state INSERT */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,DELETE,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstWise3_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstWise3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstWise3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = EstWise3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state START to state DELETE */ temp = EstWise3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstWise3_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstWise3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstWise3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstWise3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstWise3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = DELETE; } /* Finished calculating state DELETE */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_EstWise3(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * */ void init_start_end_linear_EstWise3(EstWise3 * mat) { register int i; register int j; for(j=0;j<7;j++) { for(i=(-1);iquery->len;i++) { EstWise3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); EstWise3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); EstWise3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; EstWise3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); } } for(j=(-5);jtarget->seq->len;j++) { EstWise3_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; EstWise3_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; EstWise3_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_EstWise3(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_EstWise3(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_EstWise3(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","END" }; /* Function: AlnConvertSet_EstWise3(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","END" }; AlnConvertSet * AlnConvertSet_EstWise3(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; return out; } /* Function: PackAln_read_Expl_EstWise3(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_EstWise3(EstWise3 * mat) { EstWise3_access_func_holder holder; holder.access_main = EstWise3_explicit_access_main; holder.access_special = EstWise3_explicit_access_special; return PackAln_read_generic_EstWise3(mat,holder); } /* Function: EstWise3_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstWise3_explicit_access_main(EstWise3 * mat,int i,int j,int state) { return EstWise3_EXPL_MATRIX(mat,i,j,state); } /* Function: EstWise3_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstWise3_explicit_access_special(EstWise3 * mat,int i,int j,int state) { return EstWise3_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_EstWise3(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: h [UNKN ] Undocumented argument [EstWise3_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_EstWise3(EstWise3 * mat,EstWise3_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_EstWise3(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in EstWise3_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_EstWise3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_EstWise3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == EstWise3_READ_OFF_ERROR || j == EstWise3_READ_OFF_ERROR || state == EstWise3_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in EstWise3_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_EstWise3(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [EstWise3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_EstWise3(EstWise3 * mat,int * ri,int * rj,int * state,boolean * isspecial,EstWise3_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: EstWise3_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void EstWise3_debug_show_matrix(EstWise3 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",EstWise3_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",EstWise3_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",EstWise3_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_EstWise3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EstWise3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_EstWise3(EstWise3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstWise3_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstWise3_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In EstWise3 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 5,DELETE) ) { *reti = i - 1; *retj = j - 5; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,DELETE); } return (*h.access_main)(mat,i - 1,j - 5,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 4,DELETE) ) { *reti = i - 1; *retj = j - 4; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,DELETE); } return (*h.access_main)(mat,i - 1,j - 4,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,DELETE); } return (*h.access_main)(mat,i - 1,j - 1,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,DELETE) ) { *reti = i - 1; *retj = j - 2; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,DELETE); } return (*h.access_main)(mat,i - 1,j - 2,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 5,INSERT) ) { *reti = i - 1; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,INSERT); } return (*h.access_main)(mat,i - 1,j - 5,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 4,INSERT) ) { *reti = i - 1; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,INSERT); } return (*h.access_main)(mat,i - 1,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,INSERT) ) { *reti = i - 1; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,INSERT); } return (*h.access_main)(mat,i - 1,j - 2,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,MATCH); } return (*h.access_main)(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH); } return (*h.access_main)(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START); } return (*h.access_main)(mat,i - 1,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in EstWise3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,DELETE) ) { *reti = i - 0; *retj = j - 5; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,DELETE); } return (*h.access_main)(mat,i - 0,j - 5,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,DELETE) ) { *reti = i - 0; *retj = j - 4; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,DELETE); } return (*h.access_main)(mat,i - 0,j - 4,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,DELETE) ) { *reti = i - 0; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,DELETE); } return (*h.access_main)(mat,i - 0,j - 1,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,DELETE) ) { *reti = i - 0; *retj = j - 2; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,DELETE); } return (*h.access_main)(mat,i - 0,j - 2,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,MATCH) ) { *reti = i - 0; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,MATCH); } return (*h.access_main)(mat,i - 0,j - 5,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,MATCH) ) { *reti = i - 0; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,MATCH); } return (*h.access_main)(mat,i - 0,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,MATCH) ) { *reti = i - 0; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,MATCH); } return (*h.access_main)(mat,i - 0,j - 2,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,INSERT) ) { *reti = i - 0; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,INSERT); } return (*h.access_main)(mat,i - 0,j - 5,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,INSERT) ) { *reti = i - 0; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INSERT); } return (*h.access_main)(mat,i - 0,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,START); } return (*h.access_main)(mat,i - 0,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE); } return (*h.access_main)(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in EstWise3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in EstWise3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstWise3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_EstWise3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EstWise3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_EstWise3(EstWise3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstWise3_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstWise3_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In EstWise3 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in EstWise3 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_EstWise3(mat) * * Descrip: This function calculates the EstWise3 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EstWise3 * * * Arg: mat [UNKN ] EstWise3 which contains explicit basematrix memory [EstWise3 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_EstWise3(EstWise3 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EstWise3, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("EstWise3 Matrix calculation: "); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstWise3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstWise3_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstWise3_EXPL_SPECIAL(mat,i,j,END) ) { EstWise3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstWise3_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstWise3_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstWise3_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstWise3_EXPL_SPECIAL(mat,i,j,END) ) { EstWise3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstWise3_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstWise3_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstWise3_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstWise3_EXPL_SPECIAL(mat,i,j,END) ) { EstWise3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_EstWise3(mat,dpenv) * * Descrip: This function calculates the EstWise3 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EstWise3 which contains explicit basematrix memory [EstWise3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_EstWise3(EstWise3 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EstWise3, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-5;jleni;i++) { EstWise3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstWise3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstWise3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j=-5;jlenj;j++) { EstWise3_EXPL_SPECIAL(mat,i,j,START) = 0; EstWise3_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("EstWise3 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { EstWise3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstWise3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstWise3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = EstWise3_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstWise3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstWise3_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstWise3_EXPL_SPECIAL(mat,i,j,END) ) { EstWise3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstWise3_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstWise3_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstWise3_EXPL_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstWise3_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstWise3_EXPL_SPECIAL(mat,i,j,END) ) { EstWise3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstWise3_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstWise3_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstWise3_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstWise3_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstWise3_EXPL_SPECIAL(mat,i,j,END) ) { EstWise3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: EstWise3_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstWise3 *] * */ EstWise3 * EstWise3_alloc(void) { EstWise3 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EstWise3 *) ckalloc (sizeof(EstWise3))) == NULL) { warn("EstWise3_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_EstWise3(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstWise3 *] * * Return [UNKN ] Undocumented return value [EstWise3 *] * */ EstWise3 * free_EstWise3(EstWise3 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EstWise3 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->cp is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/estwise3.h0000644000175000001440000004421010670453713016051 0ustar philippusers#ifndef DYNAMITEestwise3HEADERFILE #define DYNAMITEestwise3HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "cdparser.h" #include "genewisemodel.h" #include "genewisemodeldb.h" struct Wise2_EstWise3 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GeneWiseScore* query; ComplexSequence* target; cDNAParserScore * cp; } ; /* EstWise3 defined */ #ifndef DYNAMITE_DEFINED_EstWise3 typedef struct Wise2_EstWise3 Wise2_EstWise3; #define EstWise3 Wise2_EstWise3 #define DYNAMITE_DEFINED_EstWise3 #endif #ifdef PTHREAD struct thread_pool_holder_EstWise3 { GeneWiseScore* query; /* Query object placeholder */ GeneWiseDB* querydb;/* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ cDNADB* targetdb; /* Target database object */ boolean target_init; cDNAParserScore * cp; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_EstWise3_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(EstWise3*,int,int,int); int (*access_special)(EstWise3*,int,int,int); } ; /* EstWise3_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_EstWise3_access_func_holder typedef struct Wise2_EstWise3_access_func_holder Wise2_EstWise3_access_func_holder; #define EstWise3_access_func_holder Wise2_EstWise3_access_func_holder #define DYNAMITE_DEFINED_EstWise3_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_EstWise3(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_EstWise3(EstWise3 * mat); #define PackAln_read_Shatter_EstWise3 Wise2_PackAln_read_Shatter_EstWise3 /* Function: calculate_shatter_EstWise3(mat,dpenv) * * Descrip: This function calculates the EstWise3 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EstWise3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_EstWise3(EstWise3 * mat,DPEnvelope * dpenv); #define calculate_shatter_EstWise3 Wise2_calculate_shatter_EstWise3 /* Function: search_EstWise3(dbsi,out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstWise3 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_EstWise3(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp); #define search_EstWise3 Wise2_search_EstWise3 /* Function: serial_search_EstWise3(out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstWise3 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_EstWise3(Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp); #define serial_search_EstWise3 Wise2_serial_search_EstWise3 /* Function: PackAln_bestmemory_EstWise3(query,target,cp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EstWise3 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_EstWise3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_EstWise3 Wise2_PackAln_bestmemory_EstWise3 /* Function: allocate_Expl_EstWise3(query,target,cp,dpri) * * Descrip: This function allocates the EstWise3 structure * and the basematrix area for explicit memory implementations * It calls /allocate_EstWise3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EstWise3 *] * */ EstWise3 * Wise2_allocate_Expl_EstWise3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPRunImpl * dpri); #define allocate_Expl_EstWise3 Wise2_allocate_Expl_EstWise3 /* Function: recalculate_PackAln_EstWise3(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EstWise3 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * */ void Wise2_recalculate_PackAln_EstWise3(PackAln * pal,EstWise3 * mat); #define recalculate_PackAln_EstWise3 Wise2_recalculate_PackAln_EstWise3 /* Function: allocate_Small_EstWise3(query,target,cp) * * Descrip: This function allocates the EstWise3 structure * and the basematrix area for a small memory implementations * It calls /allocate_EstWise3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstWise3 *] * */ EstWise3 * Wise2_allocate_Small_EstWise3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp); #define allocate_Small_EstWise3 Wise2_allocate_Small_EstWise3 /* Function: PackAln_calculate_Small_EstWise3(mat,dpenv) * * Descrip: This function calculates an alignment for EstWise3 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EstWise3 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EstWise3 * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_EstWise3(EstWise3 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_EstWise3 Wise2_PackAln_calculate_Small_EstWise3 /* Function: AlnRangeSet_calculate_Small_EstWise3(mat) * * Descrip: This function calculates an alignment for EstWise3 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EstWise3 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EstWise3 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EstWise3 * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_EstWise3(EstWise3 * mat); #define AlnRangeSet_calculate_Small_EstWise3 Wise2_AlnRangeSet_calculate_Small_EstWise3 /* Function: AlnRangeSet_from_EstWise3(mat) * * Descrip: This function reads off a start/end structure * for EstWise3 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EstWise3 * If you have not calculated the matrix use * /AlnRange_calculate_Small_EstWise3 * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_EstWise3(EstWise3 * mat); #define AlnRangeSet_from_EstWise3 Wise2_AlnRangeSet_from_EstWise3 /* Function: convert_PackAln_to_AlnBlock_EstWise3(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_EstWise3(PackAln * pal); #define convert_PackAln_to_AlnBlock_EstWise3 Wise2_convert_PackAln_to_AlnBlock_EstWise3 /* Function: PackAln_read_Expl_EstWise3(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_EstWise3(EstWise3 * mat); #define PackAln_read_Expl_EstWise3 Wise2_PackAln_read_Expl_EstWise3 /* Function: PackAln_read_generic_EstWise3(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstWise3 *] * Arg: h [UNKN ] Undocumented argument [EstWise3_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_EstWise3(EstWise3 * mat,EstWise3_access_func_holder h); #define PackAln_read_generic_EstWise3 Wise2_PackAln_read_generic_EstWise3 /* Function: calculate_EstWise3(mat) * * Descrip: This function calculates the EstWise3 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EstWise3 * * * Arg: mat [UNKN ] EstWise3 which contains explicit basematrix memory [EstWise3 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_EstWise3(EstWise3 * mat); #define calculate_EstWise3 Wise2_calculate_EstWise3 /* Function: calculate_dpenv_EstWise3(mat,dpenv) * * Descrip: This function calculates the EstWise3 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EstWise3 which contains explicit basematrix memory [EstWise3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_EstWise3(EstWise3 * mat,DPEnvelope * dpenv); #define calculate_dpenv_EstWise3 Wise2_calculate_dpenv_EstWise3 /* Function: EstWise3_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstWise3 *] * */ EstWise3 * Wise2_EstWise3_alloc(void); #define EstWise3_alloc Wise2_EstWise3_alloc /* Function: free_EstWise3(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstWise3 *] * * Return [UNKN ] Undocumented return value [EstWise3 *] * */ EstWise3 * Wise2_free_EstWise3(EstWise3 * obj); #define free_EstWise3 Wise2_free_EstWise3 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_EstWise3_shatter_access_main(EstWise3 * mat,int i,int j,int state); #define EstWise3_shatter_access_main Wise2_EstWise3_shatter_access_main int Wise2_EstWise3_shatter_access_special(EstWise3 * mat,int i,int j,int state); #define EstWise3_shatter_access_special Wise2_EstWise3_shatter_access_special void * Wise2_thread_loop_EstWise3(void * ptr); #define thread_loop_EstWise3 Wise2_thread_loop_EstWise3 int Wise2_score_only_EstWise3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp); #define score_only_EstWise3 Wise2_score_only_EstWise3 EstWise3 * Wise2_allocate_EstWise3_only(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp); #define allocate_EstWise3_only Wise2_allocate_EstWise3_only void Wise2_init_EstWise3(EstWise3 * mat); #define init_EstWise3 Wise2_init_EstWise3 AlnRange * Wise2_AlnRange_build_EstWise3(EstWise3 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_EstWise3 Wise2_AlnRange_build_EstWise3 boolean Wise2_read_hidden_EstWise3(EstWise3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_EstWise3 Wise2_read_hidden_EstWise3 int Wise2_max_hidden_EstWise3(EstWise3 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_EstWise3 Wise2_max_hidden_EstWise3 boolean Wise2_read_special_strip_EstWise3(EstWise3 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_EstWise3 Wise2_read_special_strip_EstWise3 int Wise2_max_special_strip_EstWise3(EstWise3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_EstWise3 Wise2_max_special_strip_EstWise3 int Wise2_max_matrix_to_special_EstWise3(EstWise3 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_EstWise3 Wise2_max_matrix_to_special_EstWise3 void Wise2_calculate_hidden_EstWise3(EstWise3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_EstWise3 Wise2_calculate_hidden_EstWise3 void Wise2_init_hidden_EstWise3(EstWise3 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_EstWise3 Wise2_init_hidden_EstWise3 boolean Wise2_full_dc_EstWise3(EstWise3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_EstWise3 Wise2_full_dc_EstWise3 boolean Wise2_do_dc_single_pass_EstWise3(EstWise3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_EstWise3 Wise2_do_dc_single_pass_EstWise3 void Wise2_push_dc_at_merge_EstWise3(EstWise3 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_EstWise3 Wise2_push_dc_at_merge_EstWise3 void Wise2_follow_on_dc_EstWise3(EstWise3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_EstWise3 Wise2_follow_on_dc_EstWise3 void Wise2_run_up_dc_EstWise3(EstWise3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_EstWise3 Wise2_run_up_dc_EstWise3 void Wise2_init_dc_EstWise3(EstWise3 * mat); #define init_dc_EstWise3 Wise2_init_dc_EstWise3 int Wise2_start_end_find_end_EstWise3(EstWise3 * mat,int * endj); #define start_end_find_end_EstWise3 Wise2_start_end_find_end_EstWise3 boolean Wise2_dc_optimised_start_end_calc_EstWise3(EstWise3 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_EstWise3 Wise2_dc_optimised_start_end_calc_EstWise3 void Wise2_init_start_end_linear_EstWise3(EstWise3 * mat); #define init_start_end_linear_EstWise3 Wise2_init_start_end_linear_EstWise3 AlnConvertSet * Wise2_AlnConvertSet_EstWise3(void); #define AlnConvertSet_EstWise3 Wise2_AlnConvertSet_EstWise3 int Wise2_EstWise3_explicit_access_main(EstWise3 * mat,int i,int j,int state); #define EstWise3_explicit_access_main Wise2_EstWise3_explicit_access_main int Wise2_EstWise3_explicit_access_special(EstWise3 * mat,int i,int j,int state); #define EstWise3_explicit_access_special Wise2_EstWise3_explicit_access_special int Wise2_find_end_EstWise3(EstWise3 * mat,int * ri,int * rj,int * state,boolean * isspecial,EstWise3_access_func_holder h); #define find_end_EstWise3 Wise2_find_end_EstWise3 void Wise2_EstWise3_debug_show_matrix(EstWise3 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define EstWise3_debug_show_matrix Wise2_EstWise3_debug_show_matrix int Wise2_max_calc_EstWise3(EstWise3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstWise3_access_func_holder h); #define max_calc_EstWise3 Wise2_max_calc_EstWise3 int Wise2_max_calc_special_EstWise3(EstWise3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstWise3_access_func_holder h); #define max_calc_special_EstWise3 Wise2_max_calc_special_EstWise3 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/dnaprofiledp.dy0000644000175000001440000000706110045364634017141 0ustar philippusers %{ #include "dnaprofile.h" %} struct DnaProfileMatchScore Score ** score !matrix matrix DnaProfileMat query name="q" type="DnaProfileScore *" target name="t" type="DnaProfileScore *" resource name="m" type="DnaProfileMatchScore*" resource name="open_unmatched" type="Score" resource name="ext_unmatched" type="Score" resource name="gap_unmatched" type="Score" state MATCH source MATCH offi="1" offj="1" calc="0" endsource source UNMATCHED offi="1" offj="1" calc="0" endsource source INSERT offi="1" offj="1" calc="0" endsource source DELETE offi="1" offj="1" calc="0" endsource source START offi="1" offj="1" calc="0" endsource calc="m->score[i][j]" query_label MATCH target_label MATCH endstate state UNMATCHED offi="1" offj="1" source MATCH calc="open_unmatched" endsource source UNMATCHED calc="ext_unmatched" endsource source UNMATCHED offi="0" offj="1" calc="ext_unmatched+gap_unmatched" query_label PAUSED_UNMATCHED endsource source UNMATCHED offi="1" offj="0" calc="ext_unmatched+gap_unmatched" target_label PAUSED_UNMATCHED endsource query_label SEQ_UNMATCHED target_label SEQ_UNMATCHED endstate state INSERT offi="0" offj="1" source MATCH calc="q->col[i]->trans[DnaProfile_M2I] + t->col[j]->trans[DnaProfile_M2D]" endsource source INSERT calc="q->col[i]->trans[DnaProfile_I2I] + t->col[j]->trans[DnaProfile_D2D]" endsource query_label PAUSE target_label INSERT endstate state DELETE offi="1" offj="0" source MATCH calc="t->col[j]->trans[DnaProfile_M2I] + q->col[i]->trans[DnaProfile_M2D]" endsource source INSERT calc="t->col[j]->trans[DnaProfile_I2I] + q->col[i]->trans[DnaProfile_D2D]" endsource target_label PAUSE query_label INSERT endstate state START !special !start endstate state END !special !end source MATCH calc="0" endsource query_label END target_label END endstate endmatrix %{ #include "dnaprofiledp.h" DnaProfileMatchScore * new_ALLR_DnaProfileMatchScore(DnaProfile * q,DnaProfile * t) { DnaProfileMatchScore * out; int i; int j; int k; int length_q; int length_t; double score; double total; assert(q != NULL); assert(t != NULL); assert(q->folded_random == TRUE); assert(t->folded_random == TRUE); length_q = q->sa->len; length_t = t->sa->len; out = DnaProfileMatchScore_alloc_matrix(q->len,t->len); assert(out != NULL); for(i=0;ilen;i++) { for(j=0;jlen;j++) { /* Sum_all_bases( count_bt.ln(fr_bq/rnd_b) + count_bq.ln(fr_bt/rnd_b) ) / Sum_all_bases( count_bt + count_bq ) */ score = 0.0; total = 0.0; for(k=0;k<4;k++) { score += (length_t * t->col[j]->emit[k]) * (log(q->col[i]->emit[k])); score += (length_q * q->col[i]->emit[k]) * (log(t->col[j]->emit[k])); total += (length_t * t->col[j]->emit[k]) + (length_q * q->col[i]->emit[k]); } score = score / total; out->score[i][j] = (int)(score * (double)INTEGER_FACTOR); } } return out; } DnaProfileMatchScore * new_DnaProfileMatchScore(DnaProfileScore * q,DnaProfileScore * t) { int i,j; int k; DnaProfileMatchScore * out; int score; assert(q != NULL); assert(t != NULL); out = DnaProfileMatchScore_alloc_matrix(q->len,t->len); for(i=0;ilen;i++) { for(j=0;jlen;j++) { score =0; for(k=0;k<4;k++) { if( q->col[i]->emit[k] > 0 || t->col[j]->emit[k] > 0 ) { score += ((q->col[i]->emit[k] + t->col[j]->emit[k]) / 4); } } out->score[i][j] = score; } } return out; } %} wise-2.4.1/src/models/pfamhmmer1db.dy0000644000175000001440000001123507313404547017035 0ustar philippusers %{ #include "threestatemodel.h" #define NO_HMMER_INCLUDES #include "wise2xhmmer2.h" #define PfamHmmer1DBLISTLENGTH 512 %} struct PfamHmmer1Entry char * entryname boolean is_random boolean is_hmmls double bits_cutoff struct PfamHmmer1DB PfamHmmer1Entry ** en !list char * dirname // directory name with the models int cur !def="0" RandomModel * def; // default random model %info Pfam Hmmer1db is a wrapper around a Pfam Hmmer database. This is file called HMM.s in a directory which has appropiate .HMM and .random files Although this DB will be phased out, it is still around for a while. This wont be used directly, but rather in a threestatedb model. It does not implement a full dynamite style db stream. rather it expects threestatedb to prod it in the correct manner. %% api object PfamHmmer1DB des free_PfamHmmer1DB endobject object PfamHmmer1Entry des free_PfamHmmer1Entry endobject endapi %{ #include "pfamhmmer1db.h" %func reads a named model - akin to indexing %% ThreeStateModel * ThreeStateModel_from_name_PfamHmmer1DB(PfamHmmer1DB * phd,char * name) { char buffer[512]; ThreeStateModel * tsm; sprintf(buffer,"%s/%s.hmm",phd->dirname,name); /* tsm = Wise2_read_ThreeStateModel_from_hmmer1_file(buffer); */ tsm = HMMer2_read_ThreeStateModel(buffer); if( tsm == NULL ) { warn("Could not open Hmmer1 style hmm from Pfam db on file [%s]",buffer); return NULL; } if( tsm->name != NULL ) { ckfree(tsm->name); } tsm->name = stringalloc(name); /* ignore random stuff for the moment */ return tsm; } %func reads the next threestatemodel for PfamHmmer1DB, placing the correct status into return_status( DB_RETURN_OK, etc). %% ThreeStateModel * read_next_TSM_PfamHmmer1DB(PfamHmmer1DB * phd,int * return_status) { ThreeStateModel * out; if( phd->cur >= phd->len ) { *return_status = DB_RETURN_END; return NULL; } out = read_TSM_from_PfamHmmer1Entry(phd->en[phd->cur++],phd->dirname); if( out == NULL ) { *return_status = DB_RETURN_ERROR; return NULL; } else { *return_status = DB_RETURN_OK; out->rm = hard_link_RandomModel(phd->def); return out; } return out; } %func reads an individual HMMer model from the entry specification %% ThreeStateModel * read_TSM_from_PfamHmmer1Entry(PfamHmmer1Entry * en,char * dir) { char buffer[512]; ThreeStateModel * tsm; sprintf(buffer,"%s/%s.hmm",dir,en->entryname); /* tsm = Wise2_read_ThreeStateModel_from_hmmer1_file(buffer); */ tsm = HMMer2_read_ThreeStateModel(buffer); if( tsm == NULL ) { warn("Could not open Hmmer1 style hmm from Pfam db on file [%s]",buffer); return NULL; } if( tsm->name != NULL ) { ckfree(tsm->name); } tsm->name = stringalloc(en->entryname); display_char_in_ThreeStateModel(tsm); /* ignore random stuff for the moment */ if( en->is_hmmls == FALSE ) { force_weighted_local_model(tsm,1.0,1.0,1.0); } else { force_weighted_local_model(tsm,1.0,0.5,0.5); } return tsm; } %func Makes a new PfamHmmer1DB from the dir name. The directory should have a file HMMs which has entries like rrm hmmls 12 with -r indicating a specialised random model. %% PfamHmmer1DB * PfamHmmer1DB_from_dirname(char * dirname) { char buffer[512]; PfamHmmer1DB * out; FILE * ifp; char * runner; PfamHmmer1Entry * en; if( dirname == NULL ) { warn("passed through a NULL dirname into PfamHmmer1DB!"); return NULL; } sprintf(buffer,"%s/HMMs",dirname); if( (ifp= openfile(buffer,"r")) == NULL ) { warn("Could not open %s as PfamHmmer1DB file list",buffer); return NULL; } out = PfamHmmer1DB_alloc_std(); out->def = default_RandomModel(); out->dirname = stringalloc(dirname); while( fgets(buffer,512,ifp) != NULL ) { if( (runner=strtok(buffer,spacestr)) == NULL) { continue; /* silently */ } en = PfamHmmer1Entry_alloc(); en->entryname = stringalloc(runner); if( (runner=strtok(NULL,spacestr)) == NULL) { warn("Got a bad HMM.s line for a Pfam db. Skipping"); free_PfamHmmer1Entry(en); continue; } if( strstr(runner,"hmmls") != NULL ) { en->is_hmmls = TRUE; } else { en->is_hmmls = FALSE; } if( strstr(runner,"-r") != NULL ) { en->is_random = TRUE; } else { en->is_random = FALSE; } if( (runner=strtok(NULL,spacestr)) == NULL) { warn("Got a bad HMM.s line for a Pfam db. Skipping"); free_PfamHmmer1Entry(en); continue; } if( is_double_string(runner,&en->bits_cutoff) == FALSE ) { warn("%s does not look like a bits cutoff to me. Calling it 25",en->entryname,runner); en->bits_cutoff = 25; } add_PfamHmmer1DB(out,en); } fclose(ifp); return out; } %} wise-2.4.1/src/models/pfamhmmer1db.xs0000644000175000001440000001066010670453714017054 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::PfamHmmer1DB Wise2_PfamHmmer1DB * hard_link_PfamHmmer1DB(obj) Wise2_PfamHmmer1DB * obj CODE: RETVAL = Wise2_hard_link_PfamHmmer1DB(obj); OUTPUT: RETVAL Wise2_PfamHmmer1DB * PfamHmmer1DB_alloc_std() CODE: RETVAL = Wise2_PfamHmmer1DB_alloc_std(); OUTPUT: RETVAL Wise2_PfamHmmer1Entry * en(obj,i) Wise2_PfamHmmer1DB * obj int i INIT: Wise2_PfamHmmer1Entry * temp; CODE: temp = Wise2_hard_link_PfamHmmer1Entry(Wise2_access_en_PfamHmmer1DB(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_en(obj) Wise2_PfamHmmer1DB * obj CODE: RETVAL = Wise2_length_en_PfamHmmer1DB(obj); OUTPUT: RETVAL int flush_en(obj) Wise2_PfamHmmer1DB * obj CODE: RETVAL = Wise2_flush_PfamHmmer1DB(obj); OUTPUT: RETVAL boolean add_en(obj,add) Wise2_PfamHmmer1DB * obj Wise2_PfamHmmer1Entry * add CODE: RETVAL = Wise2_add_PfamHmmer1DB(obj,Wise2_hard_link_PfamHmmer1Entry(add)); OUTPUT: RETVAL boolean set_dirname(obj,dirname) Wise2_PfamHmmer1DB * obj char * dirname CODE: RETVAL = Wise2_replace_dirname_PfamHmmer1DB(obj,Wise2_stringalloc(dirname)); OUTPUT: RETVAL char * dirname(obj) Wise2_PfamHmmer1DB * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_dirname_PfamHmmer1DB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_cur(obj,cur) Wise2_PfamHmmer1DB * obj int cur CODE: RETVAL = Wise2_replace_cur_PfamHmmer1DB(obj,cur); OUTPUT: RETVAL int cur(obj) Wise2_PfamHmmer1DB * obj CODE: RETVAL = Wise2_access_cur_PfamHmmer1DB(obj); OUTPUT: RETVAL boolean set_def(obj,def) Wise2_PfamHmmer1DB * obj Wise2_RandomModel * def CODE: RETVAL = Wise2_replace_def_PfamHmmer1DB(obj,Wise2_hard_link_RandomModel(def)); OUTPUT: RETVAL Wise2_RandomModel * def(obj) Wise2_PfamHmmer1DB * obj INIT: Wise2_RandomModel * temp; CODE: temp = Wise2_hard_link_RandomModel(Wise2_access_def_PfamHmmer1DB(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_PfamHmmer1DB * new(class) char * class PPCODE: Wise2_PfamHmmer1DB * out; out = Wise2_PfamHmmer1DB_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_PfamHmmer1DB * obj CODE: Wise2_free_PfamHmmer1DB(obj); void each_en(obj) Wise2_PfamHmmer1DB * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_en_PfamHmmer1DB(obj); for(i=0;i\n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s fivestar-directory protein-file-fasta\n",program_name); fprintf(ofp," -ga gathering cutoff (bits)"); show_help_DBSearchImpl(ofp); show_standard_options(ofp); } int main(int argc,char **argv) { FiveStateFrameSet * frame; FiveStateModel * fsm; FiveStateScore * fss; RandomModel * rm; ProteinDB * proteindb; DBSearchImpl * dbsi; Hscore * hs; double gathering_cutoff = 0.0; double bits; int i; dbsi = new_DBSearchImpl_from_argv(&argc,argv); strip_out_float_argument(&argc,argv,"ga",&gathering_cutoff); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 3 ) { show_help(stdout); exit(12); } rm = default_RandomModel(); frame = read_FiveStateFrameSet_file(argv[1],"block.str"); if( frame == NULL ) fatal("Unable to make FiveStateModel from context %s, block.str file",argv[1]); fsm = FiveStateModel_from_FiveStateFrameSet(frame); /* dump_FiveStateModel(fsm,stdout); */ fsm->name = stringalloc(argv[1]); fold_RandomModel_into_FiveStateModel(fsm,rm); /* converts probabilities to integers for calculation */ fss = FiveStateScore_from_FiveStateModel(fsm); proteindb = single_fasta_ProteinDB(argv[2]); if( proteindb== NULL ) fatal("Unable to make proteindb from %s",argv[2]); hs = std_score_Hscore(Probability2Score(gathering_cutoff)-10,-1); search_FiveStateProtein(dbsi,hs,fss,proteindb); fprintf(stdout,"\n\n#High Score list\n"); fprintf(stdout,"#Protein ID DNA Str ID Bits Evalue\n"); fprintf(stdout,"--------------------------------------------------------------------------\n"); for(i=0;ilen;i++) { bits = Score2Bits(hs->ds[i]->score); if( bits < gathering_cutoff ) { break; } fprintf(stdout,"Protein %-20sDNA [%c] %-24s %.2f\n",hs->ds[i]->query->name,hs->ds[i]->target->is_reversed == TRUE ? '-' : '+',hs->ds[i]->target->name,bits); } } wise-2.4.1/src/models/dnal.c0000644000175000001440000000713210151133043015177 0ustar philippusers /* quick dna alignment program. Short and sweet */ #include "dnaalign.h" #include "seqaligndisplay.h" #include "version.h" char * program_name = "dnal"; void show_short_help(FILE * ofp); void show_version(FILE * ofp); int main(int argc,char ** argv) { Sequence * one; Sequence * two; DnaMatrix * mat; DnaStartEnd * dse; AlnBlock * alb; DPRunImpl * dpri; int kbyte = 100000; int match = 5; int mismatch = -4; int gap = 5; int ext = 1; char * policy = NULL; boolean show_pretty = TRUE; boolean show_alb = FALSE; boolean show_pal = FALSE; strip_out_standard_options(&argc,argv,show_short_help,show_version); dpri = new_DPRunImpl_from_argv(&argc,argv); strip_out_boolean_def_argument(&argc,argv,"pretty",&show_pretty); strip_out_boolean_def_argument(&argc,argv,"alb",&show_alb); strip_out_boolean_def_argument(&argc,argv,"pal",&show_pal); strip_out_integer_argument(&argc,argv,"match",&match); strip_out_integer_argument(&argc,argv,"mis",&mismatch); strip_out_integer_argument(&argc,argv,"gap",&gap); strip_out_integer_argument(&argc,argv,"ext",&ext); strip_out_integer_argument(&argc,argv,"kbyte",&kbyte); if( (policy = strip_out_assigned_argument(&argc,argv,"bound")) == NULL ) policy = "local"; if( argc != 3 ) { show_short_help(stdout); } one = read_fasta_file_Sequence(argv[1]); two = read_fasta_file_Sequence(argv[2]); mat = identity_DnaMatrix(match,mismatch); dse = DnaStartEnd_from_policy(policy); change_max_BaseMatrix_kbytes(kbyte); if( one == NULL || two == NULL || mat == NULL || dse == NULL ) { fatal("Some objects are null - cannot build alignment"); } alb = make_align_dnaalign(one,two,mat,dse,-gap,-ext,-gap,-ext,dpri); printf("Score %d\n",alb->score); if( alb == NULL ) fatal("Could not build alignment!"); if( show_pretty == TRUE ) write_pretty_seq_align(alb,one,two,12,60,stdout); if( show_alb == TRUE ) dump_ascii_AlnBlock(alb,stdout); } void show_short_help(FILE * ofp) { fprintf(ofp,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(ofp,"This program is freely distributed under a GPL. See -version for more info\n"); fprintf(ofp,"Copyright (c) GRL limited: portions of the code are from separate copyright\n\n"); fprintf(ofp,"dnal in fasta format\n"); fprintf(ofp," Options. In any order, '-' as filename (for any input) means stdin\n"); fprintf(ofp," -match [4] Match score\n"); fprintf(ofp," -mis [-1] MisMatch score\n"); fprintf(ofp," -gap [5] Gap penalty\n"); fprintf(ofp," -ext [1] Gap extension penalty\n"); fprintf(ofp," -bound [local/global/edge] Start/End policy\n"); fprintf(ofp," -kbyte [100000] Number of kbytes allowed in main memory\n"); fprintf(ofp," -[no]pretty - show pretty alignment (default - yes)\n"); fprintf(ofp," -[no]alb - show alb alignment (default - no)\n"); show_help_DPRunImpl(ofp); show_standard_options(ofp); fprintf(ofp,"\nSee WWW help at http://www.sanger.ac.uk/Software/Wise2/\n"); exit(63); } void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) GRL 1998 and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney wrote the core code.\n"); exit(63); } wise-2.4.1/src/models/fivestatemodel.c0000644000175000001440000016671110670453714017325 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "fivestatemodel.h" # line 95 "fivestatemodel.dy" void dump_FiveStateModel(FiveStateModel * five,FILE * ofp) { int i; assert(five); assert(ofp); for(i=0;ilen;i++) { fprintf(ofp,"Position %d %f %f\n",i,five->unit[i]->transition[FSM_OUTBOUND2INBOUND], five->unit[i]->transition[FSM_OUTBOUND2END]); } } # line 109 "fivestatemodel.dy" void dump_FiveStateScore(FiveStateScore * five,FILE * ofp) { int i; assert(five); assert(ofp); for(i=0;ilen;i++) { fprintf(ofp,"Position %d %c %d %d %d %d\n",i,five->unit[i]->display_char,five->unit[i]->transition[FSM_OUTBOUND2INBOUND], five->unit[i]->transition[FSM_OUTBOUND2END],five->unit[i]->transition[FSM_INBOUND2MATCH],five->unit[i]->transition[FSM_MATCH2OUTBOUND]); } } # line 123 "fivestatemodel.dy" FiveStateFrameSet * read_FiveStateFrameSet_file(char * context,char * block_str) { FiveStateFrameSet * out; char filename[MAXLINE]; FILE * ifp; assert(context); assert(block_str); sprintf(filename,"%s/%s",context,block_str); ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s as filename for block structure file",filename); return NULL; } out = read_FiveStateFrameSet(context,ifp); fclose(ifp); return out; } # line 147 "fivestatemodel.dy" FiveStateFrameSet * read_FiveStateFrameSet(char * context,FILE * ifp) { char buffer[MAXLINE]; FiveStateFrameSet * out; FiveStateFrame * temp; ThreeStateModel * tsm; char * file; char filename[MAXLINE]; out = FiveStateFrameSet_alloc_std(); temp = FiveStateFrame_alloc_std(); add_FiveStateFrameSet(out,temp); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"//") == 0 ) { temp = FiveStateFrame_alloc_std(); add_FiveStateFrameSet(out,temp); } else { file = strtok(buffer,spacestr); sprintf(filename,"%s/%s",context,file); tsm = Wise2_HMMer2_read_ThreeStateModel(filename); if( tsm == NULL ) fatal("Could not read %s as a HMMer2 file - die horribly!",tsm); add_FiveStateFrame(temp,tsm); } } return out; } # line 180 "fivestatemodel.dy" void blank_FiveStateUnit(FiveStateUnit * u) { int i; for(i=0;imatch[i] = 1.0; u->insert[i] = 1.0; } for(i=0;itransition[i] = 0.0; } } # line 196 "fivestatemodel.dy" FiveStateModel * FiveStateModel_from_FiveStateFrameSet(FiveStateFrameSet * frame) { FiveStateModel * out; FiveStateUnit * u; int len; int max; int i,j,k,l; int f; FiveStateFrameIndicator * fsfi; ThreeStateModel * tsm; ThreeStateUnit * donor; len = 0; for(i=0;ilen;i++) { for(j=0;jset[i]->len;j++) { len += frame->set[i]->stack[j]->len; } } assert(len > 0); out = FiveStateModel_alloc_len(len); /* the first state is a dummy state to get probability to get to INBOUND */ u = FiveStateUnit_alloc(); blank_FiveStateUnit(u); u->display_char = '*'; u->transition[FSM_START2INBOUND] = 1.0; u->transition[FSM_INBOUND2MATCH] = 1.0/frame->set[0]->len; u->transition[FSM_INBOUND2INBOUND] = 1.0 - u->transition[FSM_INBOUND2MATCH]; fsfi = FiveStateFrameIndicator_alloc(); fsfi->start = 1; fsfi->tsm = hard_link_ThreeStateModel(frame->set[0]->stack[0]); add_tsm_FiveStateModel(out,fsfi); add_FiveStateModel(out,u); f = 0; for(i=0;ilen;i++) { for(j=0;jset[i]->len;j++) { for(k=0;kset[i]->stack[j]->len;k++){ u = FiveStateUnit_alloc(); blank_FiveStateUnit(u); if( fsfi->tsm == NULL ) { fsfi->tsm = hard_link_ThreeStateModel(frame->set[i]->stack[j]); } donor = frame->set[i]->stack[j]->unit[k]; for(l=0;lmatch[l] = donor->match_emission[l]; u->insert[l] = donor->insert_emission[l]; } u->display_char = donor->display_char; add_FiveStateModel(out,u); u->transition[FSM_START2MATCH] = 0.0; u->transition[FSM_START2INSERT] = 0.0; u->transition[FSM_START2DELETE] = 0.0; u->transition[FSM_MATCH2MATCH] = donor->transition[TSM_MATCH2MATCH]; u->transition[FSM_MATCH2INSERT] = donor->transition[TSM_MATCH2INSERT]; u->transition[FSM_MATCH2DELETE] = donor->transition[TSM_MATCH2DELETE]; u->transition[FSM_MATCH2END] = 0.0; u->transition[FSM_DELETE2MATCH] = donor->transition[TSM_DELETE2MATCH]; u->transition[FSM_DELETE2INSERT] = donor->transition[TSM_DELETE2INSERT]; u->transition[FSM_DELETE2DELETE] = donor->transition[TSM_DELETE2DELETE]; u->transition[FSM_DELETE2END] = 0.0; u->transition[FSM_INSERT2MATCH] = donor->transition[TSM_INSERT2MATCH]; u->transition[FSM_INSERT2INSERT] = donor->transition[TSM_INSERT2INSERT]; u->transition[FSM_INSERT2DELETE] = donor->transition[TSM_INSERT2DELETE]; u->transition[FSM_INSERT2END] = 0.0; /* by default, set inbound and outbound to transition on at 1.0 */ u->transition[FSM_OUTBOUND2OUTBOUND] = 1.0; u->transition[FSM_INBOUND2INBOUND] = 1.0; /* all the interesting stuff happens at the end of HMM */ if( k == frame->set[i]->stack[j]->len-1 ) { /* end of this stack. transition out to outbound */ u->transition[FSM_MATCH2OUTBOUND] = 1.0; /* set fsfi end point here */ fsfi->end = out->len; /* if this is also end of the stack, handle the switch from out to in */ if( j == frame->set[i]->len-1 ) { u->transition[FSM_INBOUND2INBOUND] = 0.0; if( i == frame->len-1 ) { u->transition[FSM_MATCH2END] = 1.0; } /* because Dynamite has to have an offset in the model, need one extra units to flip to inbound */ u = FiveStateUnit_alloc(); blank_FiveStateUnit(u); u->display_char = '*'; u->transition[FSM_OUTBOUND2INBOUND] = 1.0; add_FiveStateModel(out,u); u = FiveStateUnit_alloc(); blank_FiveStateUnit(u); u->display_char = '*'; /* if the end of the model */ if( i == frame->len-1 ) { u->transition[FSM_OUTBOUND2END] = 1.0; u->transition[FSM_INBOUND2END] = 1.0; } else { u->transition[FSM_INBOUND2MATCH] = 1.0/frame->set[i+1]->len; u->transition[FSM_INBOUND2INBOUND] = 1.0 - u->transition[FSM_INBOUND2MATCH]; } add_FiveStateModel(out,u); } else { /* the stack continues - adjust inbound to next point */ u->transition[FSM_INBOUND2MATCH] = 1.0 / frame->set[i]->len; u->transition[FSM_INBOUND2INBOUND] = 1.0 - u->transition[FSM_INBOUND2MATCH]; } /* allocate and add next fsfi */ fsfi = FiveStateFrameIndicator_alloc(); fsfi->start = out->len; add_tsm_FiveStateModel(out,fsfi); } } /* end of the component hmm */ } /* end of the stack */ } /* end of the frame */ return out; } # line 353 "fivestatemodel.dy" void fold_RandomModel_into_FiveStateModel(FiveStateModel * fsm,RandomModel * rm) { register int i; register int j; assert(fsm); assert(rm); for(i=0;ilen;i++) { auto FiveStateUnit * tsu; tsu = fsm->unit[i]; for(j=0;j<26;j++) { if( rm->aminoacid[j] < 0.00000001 ) { warn("While trying to fold in random model, amino acid %d [%c] was below zero, ignoring",j,'A'+j); continue; } tsu->match[j] = tsu->match[j] / rm->aminoacid[j]; tsu->insert[j] = tsu->insert[j] / rm->aminoacid[j]; } } } # line 378 "fivestatemodel.dy" FiveStateModel * FiveStateModel_from_flat_ThreeStateModel(ThreeStateModel * tsm) { FiveStateModel * out; FiveStateUnit * u; ThreeStateUnit * donor; int i,j; out = FiveStateModel_alloc_len(tsm->len); for(i=0;ilen;i++) { donor = tsm->unit[i]; u = FiveStateUnit_alloc(); for(j=0;jmatch[j] = donor->match_emission[j]; u->insert[j] = donor->insert_emission[j]; } u->transition[FSM_START2MATCH] = donor->transition[TSM_START2MATCH]; u->transition[FSM_START2INSERT] = donor->transition[TSM_START2INSERT]; u->transition[FSM_START2DELETE] = donor->transition[TSM_START2DELETE]; u->transition[FSM_MATCH2MATCH] = donor->transition[TSM_MATCH2MATCH]; u->transition[FSM_MATCH2INSERT] = donor->transition[TSM_MATCH2INSERT]; u->transition[FSM_MATCH2DELETE] = donor->transition[TSM_MATCH2DELETE]; u->transition[FSM_MATCH2END] = donor->transition[TSM_MATCH2END]; u->transition[FSM_DELETE2MATCH] = donor->transition[TSM_DELETE2MATCH]; u->transition[FSM_DELETE2INSERT] = donor->transition[TSM_DELETE2INSERT]; u->transition[FSM_DELETE2DELETE] = donor->transition[TSM_DELETE2DELETE]; u->transition[FSM_DELETE2END] = donor->transition[TSM_DELETE2END]; u->transition[FSM_INSERT2MATCH] = donor->transition[TSM_INSERT2MATCH]; u->transition[FSM_INSERT2INSERT] = donor->transition[TSM_INSERT2INSERT]; u->transition[FSM_INSERT2DELETE] = donor->transition[TSM_INSERT2DELETE]; u->transition[FSM_INSERT2END] = donor->transition[TSM_INSERT2END]; u->transition[FSM_MATCH2INBOUND] = 0.0; u->transition[FSM_DELETE2INBOUND] = 0.0; u->transition[FSM_INSERT2INBOUND] = 0.0; u->transition[FSM_MATCH2INBOUND] = 0.0; u->transition[FSM_DELETE2INBOUND] = 0.0; u->transition[FSM_INSERT2INBOUND] = 0.0; u->display_char = donor->display_char; add_FiveStateModel(out,u); } return out; } /* Function: pseudo_Protein_from_FiveStateModel(tsm) * * Descrip: Makes a protein sequence out of the display characters. * Not very useful! * * * * Arg: tsm [UNKN ] Undocumented argument [FiveStateModel *] * * Return [UNKN ] Undocumented return value [Protein *] * */ # line 434 "fivestatemodel.dy" Protein * pseudo_Protein_from_FiveStateModel(FiveStateModel * tsm) { int i; Sequence * seq; seq = Sequence_alloc(); seq->name = stringalloc(tsm->name); seq->seq = ckcalloc(tsm->len+1,sizeof(char)); for(i=0;ilen;i++) { seq->seq[i] = tsm->unit[i]->display_char; } seq->seq[i]='\0'; make_len_type_Sequence(seq); seq->type = SEQUENCE_PROTEIN; return Protein_from_Sequence(seq); } # line 454 "fivestatemodel.dy" FiveStateScore * FiveStateScore_from_FiveStateModel(FiveStateModel * fsm) { FiveStateScore * out; int i; out = FiveStateScore_alloc_len(fsm->len); add_FiveStateScore(out,FiveStateScoreUnit_from_FiveStateUnit(NULL,fsm->unit[0])); for(i=1;ilen;i++) { add_FiveStateScore(out,FiveStateScoreUnit_from_FiveStateUnit(fsm->unit[i-1],fsm->unit[i])); } return out; } # line 470 "fivestatemodel.dy" FiveStateScoreUnit * FiveStateScoreUnit_from_FiveStateUnit(FiveStateUnit * prev,FiveStateUnit * u) { FiveStateScoreUnit * out; out = FiveStateScoreUnit_alloc(); Probability2Score_move(u->match,out->match,ALPHABET_SIZE); Probability2Score_move(u->insert,out->insert,ALPHABET_SIZE); out->display_char = u->display_char; if( prev != NULL ) { out->transition[FSM_MATCH2MATCH] = Probability2Score(prev->transition[FSM_MATCH2MATCH]); out->transition[FSM_INSERT2MATCH] = Probability2Score(prev->transition[FSM_INSERT2MATCH]); out->transition[FSM_DELETE2MATCH] = Probability2Score(prev->transition[FSM_DELETE2MATCH]); out->transition[FSM_INBOUND2MATCH] = Probability2Score(prev->transition[FSM_INBOUND2MATCH]); out->transition[FSM_OUTBOUND2MATCH] = Probability2Score(prev->transition[FSM_OUTBOUND2MATCH]); out->transition[FSM_MATCH2DELETE] = Probability2Score(prev->transition[FSM_MATCH2DELETE]); out->transition[FSM_INSERT2DELETE] = Probability2Score(prev->transition[FSM_INSERT2DELETE]); out->transition[FSM_DELETE2DELETE] = Probability2Score(prev->transition[FSM_DELETE2DELETE]); out->transition[FSM_INBOUND2DELETE] = Probability2Score(prev->transition[FSM_INBOUND2DELETE]); out->transition[FSM_OUTBOUND2DELETE] = Probability2Score(prev->transition[FSM_OUTBOUND2DELETE]); out->transition[FSM_MATCH2INBOUND] = Probability2Score(prev->transition[FSM_MATCH2INBOUND]); out->transition[FSM_INSERT2INBOUND] = Probability2Score(prev->transition[FSM_INSERT2INBOUND]); out->transition[FSM_DELETE2INBOUND] = Probability2Score(prev->transition[FSM_DELETE2INBOUND]); out->transition[FSM_INBOUND2INBOUND] = Probability2Score(prev->transition[FSM_INBOUND2INBOUND]); out->transition[FSM_OUTBOUND2INBOUND] = Probability2Score(prev->transition[FSM_OUTBOUND2INBOUND]); out->transition[FSM_MATCH2OUTBOUND] = Probability2Score(prev->transition[FSM_MATCH2OUTBOUND]); out->transition[FSM_INSERT2OUTBOUND] = Probability2Score(prev->transition[FSM_INSERT2OUTBOUND]); out->transition[FSM_DELETE2OUTBOUND] = Probability2Score(prev->transition[FSM_DELETE2OUTBOUND]); out->transition[FSM_OUTBOUND2OUTBOUND] = Probability2Score(prev->transition[FSM_OUTBOUND2OUTBOUND]); out->transition[FSM_INBOUND2END] = Probability2Score(prev->transition[FSM_INBOUND2END]); out->transition[FSM_OUTBOUND2END] = Probability2Score(prev->transition[FSM_OUTBOUND2END]); out->transition[FSM_OUTBOUND2INBOUND] = Probability2Score(prev->transition[FSM_OUTBOUND2INBOUND]); } else { out->transition[FSM_MATCH2MATCH] = NEGI; out->transition[FSM_INSERT2MATCH] = NEGI; out->transition[FSM_DELETE2MATCH] = NEGI; out->transition[FSM_INBOUND2MATCH] = NEGI; out->transition[FSM_OUTBOUND2MATCH] = NEGI; out->transition[FSM_MATCH2DELETE] = NEGI; out->transition[FSM_INSERT2DELETE] = NEGI; out->transition[FSM_DELETE2DELETE] = NEGI; out->transition[FSM_INBOUND2DELETE] = NEGI; out->transition[FSM_OUTBOUND2DELETE] = NEGI; out->transition[FSM_MATCH2INBOUND] = NEGI; out->transition[FSM_INSERT2INBOUND] = NEGI; out->transition[FSM_DELETE2INBOUND] = NEGI; out->transition[FSM_INBOUND2INBOUND] = NEGI; out->transition[FSM_MATCH2OUTBOUND] = NEGI; out->transition[FSM_INSERT2OUTBOUND] = NEGI; out->transition[FSM_DELETE2OUTBOUND] = NEGI; out->transition[FSM_OUTBOUND2OUTBOUND] = NEGI; out->transition[FSM_INBOUND2END] = NEGI; out->transition[FSM_OUTBOUND2END] = NEGI; out->transition[FSM_OUTBOUND2INBOUND] = NEGI; } out->transition[FSM_MATCH2INSERT] = Probability2Score(u->transition[FSM_MATCH2INSERT]); out->transition[FSM_INSERT2INSERT] = Probability2Score(u->transition[FSM_INSERT2INSERT]); out->transition[FSM_DELETE2INSERT] = Probability2Score(u->transition[FSM_DELETE2INSERT]); out->transition[FSM_INBOUND2INSERT] = Probability2Score(u->transition[FSM_INBOUND2INSERT]); out->transition[FSM_OUTBOUND2INSERT] = Probability2Score(u->transition[FSM_OUTBOUND2INSERT]); out->transition[FSM_START2MATCH] = Probability2Score(u->transition[FSM_START2MATCH]); out->transition[FSM_START2INSERT] = Probability2Score(u->transition[FSM_START2INSERT]); out->transition[FSM_START2DELETE] = Probability2Score(u->transition[FSM_START2DELETE]); out->transition[FSM_START2INBOUND] = Probability2Score(u->transition[FSM_START2INBOUND]); out->transition[FSM_MATCH2END] = Probability2Score(u->transition[FSM_MATCH2END]); out->transition[FSM_INSERT2END] = Probability2Score(u->transition[FSM_INSERT2END]); out->transition[FSM_DELETE2END] = Probability2Score(u->transition[FSM_DELETE2END]); return out; } # line 491 "fivestatemodel.c" /* Function: swap_FiveStateFrame(list,i,j) * * Descrip: swap function: an internal for qsort_FiveStateFrame * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ThreeStateModel **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_FiveStateFrame(ThreeStateModel ** list,int i,int j) { ThreeStateModel * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_FiveStateFrame(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_FiveStateFrame which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ThreeStateModel **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_FiveStateFrame(ThreeStateModel ** list,int left,int right,int (*comp)(ThreeStateModel * ,ThreeStateModel * )) { int i,last; if( left >= right ) return; swap_FiveStateFrame(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_FiveStateFrame (list,++last,i); } swap_FiveStateFrame (list,left,last); qsort_FiveStateFrame(list,left,last-1,comp); qsort_FiveStateFrame(list,last+1,right,comp); } /* Function: sort_FiveStateFrame(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_FiveStateFrame * * * Arg: obj [UNKN ] Object containing list [FiveStateFrame *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_FiveStateFrame(FiveStateFrame * obj,int (*comp)(ThreeStateModel *, ThreeStateModel *)) { qsort_FiveStateFrame(obj->stack,0,obj->len-1,comp); return; } /* Function: expand_FiveStateFrame(obj,len) * * Descrip: Really an internal function for add_FiveStateFrame * * * Arg: obj [UNKN ] Object which contains the list [FiveStateFrame *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_FiveStateFrame(FiveStateFrame * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_FiveStateFrame called with no need"); return TRUE; } if( (obj->stack = (ThreeStateModel ** ) ckrealloc (obj->stack,sizeof(ThreeStateModel *)*len)) == NULL) { warn("ckrealloc failed for expand_FiveStateFrame, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_FiveStateFrame(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FiveStateFrame *] * Arg: add [OWNER] Object to add to the list [ThreeStateModel *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_FiveStateFrame(FiveStateFrame * obj,ThreeStateModel * add) { if( obj->len >= obj->maxlen) { if( expand_FiveStateFrame(obj,obj->len + FiveStateFrameLISTLENGTH) == FALSE) return FALSE; } obj->stack[obj->len++]=add; return TRUE; } /* Function: flush_FiveStateFrame(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FiveStateFrame *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_FiveStateFrame(FiveStateFrame * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->stack[i] != NULL) { free_ThreeStateModel(obj->stack[i]); obj->stack[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: FiveStateFrame_alloc_std(void) * * Descrip: Equivalent to FiveStateFrame_alloc_len(FiveStateFrameLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FiveStateFrame *] * */ FiveStateFrame * FiveStateFrame_alloc_std(void) { return FiveStateFrame_alloc_len(FiveStateFrameLISTLENGTH); } /* Function: FiveStateFrame_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FiveStateFrame *] * */ FiveStateFrame * FiveStateFrame_alloc_len(int len) { FiveStateFrame * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = FiveStateFrame_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->stack = (ThreeStateModel ** ) ckcalloc (len,sizeof(ThreeStateModel *))) == NULL) { warn("Warning, ckcalloc failed in FiveStateFrame_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_FiveStateFrame(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateFrame *] * * Return [UNKN ] Undocumented return value [FiveStateFrame *] * */ FiveStateFrame * hard_link_FiveStateFrame(FiveStateFrame * obj) { if( obj == NULL ) { warn("Trying to hard link to a FiveStateFrame object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: FiveStateFrame_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateFrame *] * */ FiveStateFrame * FiveStateFrame_alloc(void) { FiveStateFrame * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FiveStateFrame *) ckalloc (sizeof(FiveStateFrame))) == NULL) { warn("FiveStateFrame_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->stack = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_FiveStateFrame(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateFrame *] * * Return [UNKN ] Undocumented return value [FiveStateFrame *] * */ FiveStateFrame * free_FiveStateFrame(FiveStateFrame * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FiveStateFrame obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->stack != NULL) { for(i=0;ilen;i++) { if( obj->stack[i] != NULL) free_ThreeStateModel(obj->stack[i]); } ckfree(obj->stack); } ckfree(obj); return NULL; } /* Function: swap_FiveStateFrameSet(list,i,j) * * Descrip: swap function: an internal for qsort_FiveStateFrameSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [FiveStateFrame **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_FiveStateFrameSet(FiveStateFrame ** list,int i,int j) { FiveStateFrame * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_FiveStateFrameSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_FiveStateFrameSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [FiveStateFrame **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_FiveStateFrameSet(FiveStateFrame ** list,int left,int right,int (*comp)(FiveStateFrame * ,FiveStateFrame * )) { int i,last; if( left >= right ) return; swap_FiveStateFrameSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_FiveStateFrameSet (list,++last,i); } swap_FiveStateFrameSet (list,left,last); qsort_FiveStateFrameSet(list,left,last-1,comp); qsort_FiveStateFrameSet(list,last+1,right,comp); } /* Function: sort_FiveStateFrameSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_FiveStateFrameSet * * * Arg: obj [UNKN ] Object containing list [FiveStateFrameSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_FiveStateFrameSet(FiveStateFrameSet * obj,int (*comp)(FiveStateFrame *, FiveStateFrame *)) { qsort_FiveStateFrameSet(obj->set,0,obj->len-1,comp); return; } /* Function: expand_FiveStateFrameSet(obj,len) * * Descrip: Really an internal function for add_FiveStateFrameSet * * * Arg: obj [UNKN ] Object which contains the list [FiveStateFrameSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_FiveStateFrameSet(FiveStateFrameSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_FiveStateFrameSet called with no need"); return TRUE; } if( (obj->set = (FiveStateFrame ** ) ckrealloc (obj->set,sizeof(FiveStateFrame *)*len)) == NULL) { warn("ckrealloc failed for expand_FiveStateFrameSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_FiveStateFrameSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FiveStateFrameSet *] * Arg: add [OWNER] Object to add to the list [FiveStateFrame *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_FiveStateFrameSet(FiveStateFrameSet * obj,FiveStateFrame * add) { if( obj->len >= obj->maxlen) { if( expand_FiveStateFrameSet(obj,obj->len + FiveStateFrameSetLISTLENGTH) == FALSE) return FALSE; } obj->set[obj->len++]=add; return TRUE; } /* Function: flush_FiveStateFrameSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FiveStateFrameSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_FiveStateFrameSet(FiveStateFrameSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->set[i] != NULL) { free_FiveStateFrame(obj->set[i]); obj->set[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: FiveStateFrameSet_alloc_std(void) * * Descrip: Equivalent to FiveStateFrameSet_alloc_len(FiveStateFrameSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FiveStateFrameSet *] * */ FiveStateFrameSet * FiveStateFrameSet_alloc_std(void) { return FiveStateFrameSet_alloc_len(FiveStateFrameSetLISTLENGTH); } /* Function: FiveStateFrameSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FiveStateFrameSet *] * */ FiveStateFrameSet * FiveStateFrameSet_alloc_len(int len) { FiveStateFrameSet * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = FiveStateFrameSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->set = (FiveStateFrame ** ) ckcalloc (len,sizeof(FiveStateFrame *))) == NULL) { warn("Warning, ckcalloc failed in FiveStateFrameSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_FiveStateFrameSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateFrameSet *] * * Return [UNKN ] Undocumented return value [FiveStateFrameSet *] * */ FiveStateFrameSet * hard_link_FiveStateFrameSet(FiveStateFrameSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a FiveStateFrameSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: FiveStateFrameSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateFrameSet *] * */ FiveStateFrameSet * FiveStateFrameSet_alloc(void) { FiveStateFrameSet * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FiveStateFrameSet *) ckalloc (sizeof(FiveStateFrameSet))) == NULL) { warn("FiveStateFrameSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->set = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_FiveStateFrameSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateFrameSet *] * * Return [UNKN ] Undocumented return value [FiveStateFrameSet *] * */ FiveStateFrameSet * free_FiveStateFrameSet(FiveStateFrameSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FiveStateFrameSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->set != NULL) { for(i=0;ilen;i++) { if( obj->set[i] != NULL) free_FiveStateFrame(obj->set[i]); } ckfree(obj->set); } ckfree(obj); return NULL; } /* Function: hard_link_FiveStateUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateUnit *] * * Return [UNKN ] Undocumented return value [FiveStateUnit *] * */ FiveStateUnit * hard_link_FiveStateUnit(FiveStateUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a FiveStateUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: FiveStateUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateUnit *] * */ FiveStateUnit * FiveStateUnit_alloc(void) { FiveStateUnit * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FiveStateUnit *) ckalloc (sizeof(FiveStateUnit))) == NULL) { warn("FiveStateUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* match[ALPHABET_SIZE] is an array: no default possible */ /* insert[ALPHABET_SIZE] is an array: no default possible */ /* transition[FSM_TRANSITION_LENGTH] is an array: no default possible */ out->display_char = 'u'; return out; } /* Function: free_FiveStateUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateUnit *] * * Return [UNKN ] Undocumented return value [FiveStateUnit *] * */ FiveStateUnit * free_FiveStateUnit(FiveStateUnit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FiveStateUnit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_FiveStateFrameIndicator(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateFrameIndicator *] * * Return [UNKN ] Undocumented return value [FiveStateFrameIndicator *] * */ FiveStateFrameIndicator * hard_link_FiveStateFrameIndicator(FiveStateFrameIndicator * obj) { if( obj == NULL ) { warn("Trying to hard link to a FiveStateFrameIndicator object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: FiveStateFrameIndicator_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateFrameIndicator *] * */ FiveStateFrameIndicator * FiveStateFrameIndicator_alloc(void) { FiveStateFrameIndicator * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FiveStateFrameIndicator *) ckalloc (sizeof(FiveStateFrameIndicator))) == NULL) { warn("FiveStateFrameIndicator_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->tsm = NULL; out->start = 0; out->end = 0; return out; } /* Function: free_FiveStateFrameIndicator(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateFrameIndicator *] * * Return [UNKN ] Undocumented return value [FiveStateFrameIndicator *] * */ FiveStateFrameIndicator * free_FiveStateFrameIndicator(FiveStateFrameIndicator * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FiveStateFrameIndicator obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->tsm != NULL) free_ThreeStateModel(obj->tsm); ckfree(obj); return NULL; } /* Function: swap_FiveStateModel(list,i,j) * * Descrip: swap function: an internal for qsort_FiveStateModel * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [FiveStateUnit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_FiveStateModel(FiveStateUnit ** list,int i,int j) { FiveStateUnit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_FiveStateModel(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_FiveStateModel which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [FiveStateUnit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_FiveStateModel(FiveStateUnit ** list,int left,int right,int (*comp)(FiveStateUnit * ,FiveStateUnit * )) { int i,last; if( left >= right ) return; swap_FiveStateModel(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_FiveStateModel (list,++last,i); } swap_FiveStateModel (list,left,last); qsort_FiveStateModel(list,left,last-1,comp); qsort_FiveStateModel(list,last+1,right,comp); } /* Function: sort_FiveStateModel(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_FiveStateModel * * * Arg: obj [UNKN ] Object containing list [FiveStateModel *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_FiveStateModel(FiveStateModel * obj,int (*comp)(FiveStateUnit *, FiveStateUnit *)) { qsort_FiveStateModel(obj->unit,0,obj->len-1,comp); return; } /* Function: expand_FiveStateModel(obj,len) * * Descrip: Really an internal function for add_FiveStateModel * * * Arg: obj [UNKN ] Object which contains the list [FiveStateModel *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_FiveStateModel(FiveStateModel * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_FiveStateModel called with no need"); return TRUE; } if( (obj->unit = (FiveStateUnit ** ) ckrealloc (obj->unit,sizeof(FiveStateUnit *)*len)) == NULL) { warn("ckrealloc failed for expand_FiveStateModel, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_FiveStateModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FiveStateModel *] * Arg: add [OWNER] Object to add to the list [FiveStateUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_FiveStateModel(FiveStateModel * obj,FiveStateUnit * add) { if( obj->len >= obj->maxlen) { if( expand_FiveStateModel(obj,obj->len + FiveStateModelLISTLENGTH) == FALSE) return FALSE; } obj->unit[obj->len++]=add; return TRUE; } /* Function: flush_FiveStateModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FiveStateModel *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_FiveStateModel(FiveStateModel * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->unit[i] != NULL) { free_FiveStateUnit(obj->unit[i]); obj->unit[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: swap_tsm_FiveStateModel(list,i,j) * * Descrip: swap function: an internal for qsort_tsm_FiveStateModel * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [FiveStateFrameIndicator **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_tsm_FiveStateModel(FiveStateFrameIndicator ** list,int i,int j) { FiveStateFrameIndicator * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_tsm_FiveStateModel(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_tsm_FiveStateModel which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [FiveStateFrameIndicator **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_tsm_FiveStateModel(FiveStateFrameIndicator ** list,int left,int right,int (*comp)(FiveStateFrameIndicator * ,FiveStateFrameIndicator * )) { int i,last; if( left >= right ) return; swap_tsm_FiveStateModel(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_tsm_FiveStateModel (list,++last,i); } swap_tsm_FiveStateModel (list,left,last); qsort_tsm_FiveStateModel(list,left,last-1,comp); qsort_tsm_FiveStateModel(list,last+1,right,comp); } /* Function: sort_tsm_FiveStateModel(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_tsm_FiveStateModel * * * Arg: obj [UNKN ] Object containing list [FiveStateModel *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_tsm_FiveStateModel(FiveStateModel * obj,int (*comp)(FiveStateFrameIndicator *, FiveStateFrameIndicator *)) { qsort_tsm_FiveStateModel(obj->frame,0,obj->tsm_len-1,comp); return; } /* Function: expand_tsm_FiveStateModel(obj,len) * * Descrip: Really an internal function for add_tsm_FiveStateModel * * * Arg: obj [UNKN ] Object which contains the list [FiveStateModel *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_tsm_FiveStateModel(FiveStateModel * obj,int len) { if( obj->tsm_maxlen > obj->tsm_len ) { warn("expand_FiveStateModeltsm_ called with no need"); return TRUE; } if( (obj->frame = (FiveStateFrameIndicator ** ) ckrealloc (obj->frame,sizeof(FiveStateFrameIndicator *)*len)) == NULL) { warn("ckrealloc failed for expand_FiveStateModel, returning FALSE"); return FALSE; } obj->tsm_maxlen = len; return TRUE; } /* Function: add_tsm_FiveStateModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FiveStateModel *] * Arg: add [OWNER] Object to add to the list [FiveStateFrameIndicator *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_tsm_FiveStateModel(FiveStateModel * obj,FiveStateFrameIndicator * add) { if( obj->tsm_len >= obj->tsm_maxlen) { if( expand_tsm_FiveStateModel(obj,obj->tsm_len + FiveStateModelLISTLENGTH) == FALSE) return FALSE; } obj->frame[obj->tsm_len++]=add; return TRUE; } /* Function: flush_tsm_FiveStateModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FiveStateModel *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_tsm_FiveStateModel(FiveStateModel * obj) { int i; for(i=0;itsm_len;i++) { /*for i over list length*/ if( obj->frame[i] != NULL) { free_FiveStateFrameIndicator(obj->frame[i]); obj->frame[i] = NULL; } } /* end of for i over list length */ obj->tsm_len = 0; return i; } /* Function: FiveStateModel_alloc_std(void) * * Descrip: Equivalent to FiveStateModel_alloc_len(FiveStateModelLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FiveStateModel *] * */ FiveStateModel * FiveStateModel_alloc_std(void) { return FiveStateModel_alloc_len(FiveStateModelLISTLENGTH); } /* Function: FiveStateModel_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FiveStateModel *] * */ FiveStateModel * FiveStateModel_alloc_len(int len) { FiveStateModel * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = FiveStateModel_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->unit = (FiveStateUnit ** ) ckcalloc (len,sizeof(FiveStateUnit *))) == NULL) { warn("Warning, ckcalloc failed in FiveStateModel_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; if((out->frame = (FiveStateFrameIndicator ** ) ckcalloc (len,sizeof(FiveStateFrameIndicator *))) == NULL) { warn("Warning, ckcalloc failed in FiveStateModel_alloc_len"); return NULL; } out->tsm_len = 0; out->tsm_maxlen = len; return out; } /* Function: hard_link_FiveStateModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateModel *] * * Return [UNKN ] Undocumented return value [FiveStateModel *] * */ FiveStateModel * hard_link_FiveStateModel(FiveStateModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a FiveStateModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: FiveStateModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateModel *] * */ FiveStateModel * FiveStateModel_alloc(void) { FiveStateModel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FiveStateModel *) ckalloc (sizeof(FiveStateModel))) == NULL) { warn("FiveStateModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->unit = NULL; out->len = out->maxlen = 0; out->frame = NULL; out->tsm_len = out->tsm_maxlen = 0; return out; } /* Function: free_FiveStateModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateModel *] * * Return [UNKN ] Undocumented return value [FiveStateModel *] * */ FiveStateModel * free_FiveStateModel(FiveStateModel * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FiveStateModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->unit != NULL) { for(i=0;ilen;i++) { if( obj->unit[i] != NULL) free_FiveStateUnit(obj->unit[i]); } ckfree(obj->unit); } if( obj->frame != NULL) { for(i=0;itsm_len;i++) { if( obj->frame[i] != NULL) free_FiveStateFrameIndicator(obj->frame[i]); } ckfree(obj->frame); } ckfree(obj); return NULL; } /* Function: hard_link_FiveStateScoreUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateScoreUnit *] * * Return [UNKN ] Undocumented return value [FiveStateScoreUnit *] * */ FiveStateScoreUnit * hard_link_FiveStateScoreUnit(FiveStateScoreUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a FiveStateScoreUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: FiveStateScoreUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateScoreUnit *] * */ FiveStateScoreUnit * FiveStateScoreUnit_alloc(void) { FiveStateScoreUnit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FiveStateScoreUnit *) ckalloc (sizeof(FiveStateScoreUnit))) == NULL) { warn("FiveStateScoreUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* match[ALPHABET_SIZE] is an array: no default possible */ /* insert[ALPHABET_SIZE] is an array: no default possible */ /* transition[FSM_TRANSITION_LENGTH] is an array: no default possible */ out->display_char = 'u'; return out; } /* Function: free_FiveStateScoreUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateScoreUnit *] * * Return [UNKN ] Undocumented return value [FiveStateScoreUnit *] * */ FiveStateScoreUnit * free_FiveStateScoreUnit(FiveStateScoreUnit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FiveStateScoreUnit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_FiveStateScore(list,i,j) * * Descrip: swap function: an internal for qsort_FiveStateScore * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [FiveStateScoreUnit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_FiveStateScore(FiveStateScoreUnit ** list,int i,int j) { FiveStateScoreUnit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_FiveStateScore(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_FiveStateScore which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [FiveStateScoreUnit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_FiveStateScore(FiveStateScoreUnit ** list,int left,int right,int (*comp)(FiveStateScoreUnit * ,FiveStateScoreUnit * )) { int i,last; if( left >= right ) return; swap_FiveStateScore(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_FiveStateScore (list,++last,i); } swap_FiveStateScore (list,left,last); qsort_FiveStateScore(list,left,last-1,comp); qsort_FiveStateScore(list,last+1,right,comp); } /* Function: sort_FiveStateScore(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_FiveStateScore * * * Arg: obj [UNKN ] Object containing list [FiveStateScore *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_FiveStateScore(FiveStateScore * obj,int (*comp)(FiveStateScoreUnit *, FiveStateScoreUnit *)) { qsort_FiveStateScore(obj->unit,0,obj->len-1,comp); return; } /* Function: expand_FiveStateScore(obj,len) * * Descrip: Really an internal function for add_FiveStateScore * * * Arg: obj [UNKN ] Object which contains the list [FiveStateScore *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_FiveStateScore(FiveStateScore * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_FiveStateScore called with no need"); return TRUE; } if( (obj->unit = (FiveStateScoreUnit ** ) ckrealloc (obj->unit,sizeof(FiveStateScoreUnit *)*len)) == NULL) { warn("ckrealloc failed for expand_FiveStateScore, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_FiveStateScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FiveStateScore *] * Arg: add [OWNER] Object to add to the list [FiveStateScoreUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_FiveStateScore(FiveStateScore * obj,FiveStateScoreUnit * add) { if( obj->len >= obj->maxlen) { if( expand_FiveStateScore(obj,obj->len + FiveStateScoreLISTLENGTH) == FALSE) return FALSE; } obj->unit[obj->len++]=add; return TRUE; } /* Function: flush_FiveStateScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FiveStateScore *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_FiveStateScore(FiveStateScore * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->unit[i] != NULL) { free_FiveStateScoreUnit(obj->unit[i]); obj->unit[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: FiveStateScore_alloc_std(void) * * Descrip: Equivalent to FiveStateScore_alloc_len(FiveStateScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FiveStateScore *] * */ FiveStateScore * FiveStateScore_alloc_std(void) { return FiveStateScore_alloc_len(FiveStateScoreLISTLENGTH); } /* Function: FiveStateScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FiveStateScore *] * */ FiveStateScore * FiveStateScore_alloc_len(int len) { FiveStateScore * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = FiveStateScore_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->unit = (FiveStateScoreUnit ** ) ckcalloc (len,sizeof(FiveStateScoreUnit *))) == NULL) { warn("Warning, ckcalloc failed in FiveStateScore_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_FiveStateScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateScore *] * * Return [UNKN ] Undocumented return value [FiveStateScore *] * */ FiveStateScore * hard_link_FiveStateScore(FiveStateScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a FiveStateScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: FiveStateScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateScore *] * */ FiveStateScore * FiveStateScore_alloc(void) { FiveStateScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FiveStateScore *) ckalloc (sizeof(FiveStateScore))) == NULL) { warn("FiveStateScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->unit = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_FiveStateScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateScore *] * * Return [UNKN ] Undocumented return value [FiveStateScore *] * */ FiveStateScore * free_FiveStateScore(FiveStateScore * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FiveStateScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->unit != NULL) { for(i=0;ilen;i++) { if( obj->unit[i] != NULL) free_FiveStateScoreUnit(obj->unit[i]); } ckfree(obj->unit); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/fivestatemodel.h0000644000175000001440000006464010670453714017330 0ustar philippusers#ifndef DYNAMITEfivestatemodelHEADERFILE #define DYNAMITEfivestatemodelHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "threestatemodel.h" enum fsm_trans_type { FSM_MATCH2MATCH = 0, FSM_MATCH2INSERT, FSM_MATCH2DELETE, FSM_MATCH2INBOUND, FSM_MATCH2OUTBOUND, FSM_INSERT2MATCH, FSM_INSERT2INSERT, FSM_INSERT2DELETE, FSM_INSERT2INBOUND, FSM_INSERT2OUTBOUND, FSM_DELETE2MATCH, FSM_DELETE2INSERT, FSM_DELETE2DELETE, FSM_DELETE2INBOUND, FSM_DELETE2OUTBOUND, FSM_START2MATCH, FSM_START2INSERT, FSM_START2DELETE, FSM_START2INBOUND, FSM_MATCH2END, FSM_INSERT2END, FSM_DELETE2END, FSM_INBOUND2MATCH, FSM_INBOUND2INSERT, FSM_INBOUND2DELETE, FSM_INBOUND2END, FSM_INBOUND2INBOUND, FSM_OUTBOUND2MATCH, FSM_OUTBOUND2INSERT, FSM_OUTBOUND2DELETE, FSM_OUTBOUND2OUTBOUND, FSM_OUTBOUND2INBOUND, FSM_OUTBOUND2END, FSM_TRANSITION_LENGTH }; #define FiveStateModelLISTLENGTH 128 #define FiveStateScoreLISTLENGTH 128 #define FiveStateFrameLISTLENGTH 32 #define FiveStateFrameSetLISTLENGTH 32 /* * Cheeky declaration to get around #include mess. */ ThreeStateModel * Wise2_HMMer2_read_ThreeStateModel(char * filename); struct Wise2_FiveStateFrame { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ThreeStateModel ** stack; int len;/* len for above stack */ int maxlen; /* maxlen for above stack */ } ; /* FiveStateFrame defined */ #ifndef DYNAMITE_DEFINED_FiveStateFrame typedef struct Wise2_FiveStateFrame Wise2_FiveStateFrame; #define FiveStateFrame Wise2_FiveStateFrame #define DYNAMITE_DEFINED_FiveStateFrame #endif struct Wise2_FiveStateFrameSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif FiveStateFrame ** set; int len;/* len for above set */ int maxlen; /* maxlen for above set */ } ; /* FiveStateFrameSet defined */ #ifndef DYNAMITE_DEFINED_FiveStateFrameSet typedef struct Wise2_FiveStateFrameSet Wise2_FiveStateFrameSet; #define FiveStateFrameSet Wise2_FiveStateFrameSet #define DYNAMITE_DEFINED_FiveStateFrameSet #endif struct Wise2_FiveStateUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability match[ALPHABET_SIZE]; Probability insert[ALPHABET_SIZE]; Probability transition[FSM_TRANSITION_LENGTH]; char display_char; } ; /* FiveStateUnit defined */ #ifndef DYNAMITE_DEFINED_FiveStateUnit typedef struct Wise2_FiveStateUnit Wise2_FiveStateUnit; #define FiveStateUnit Wise2_FiveStateUnit #define DYNAMITE_DEFINED_FiveStateUnit #endif struct Wise2_FiveStateFrameIndicator { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ThreeStateModel * tsm; int start; int end; } ; /* FiveStateFrameIndicator defined */ #ifndef DYNAMITE_DEFINED_FiveStateFrameIndicator typedef struct Wise2_FiveStateFrameIndicator Wise2_FiveStateFrameIndicator; #define FiveStateFrameIndicator Wise2_FiveStateFrameIndicator #define DYNAMITE_DEFINED_FiveStateFrameIndicator #endif struct Wise2_FiveStateModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; /* name of the model */ FiveStateUnit ** unit; int len;/* len for above unit */ int maxlen; /* maxlen for above unit */ FiveStateFrameIndicator ** frame; int tsm_len;/* len for above frame */ int tsm_maxlen; /* maxlen for above frame */ } ; /* FiveStateModel defined */ #ifndef DYNAMITE_DEFINED_FiveStateModel typedef struct Wise2_FiveStateModel Wise2_FiveStateModel; #define FiveStateModel Wise2_FiveStateModel #define DYNAMITE_DEFINED_FiveStateModel #endif struct Wise2_FiveStateScoreUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score match[ALPHABET_SIZE]; Score insert[ALPHABET_SIZE]; Score transition[FSM_TRANSITION_LENGTH]; char display_char; } ; /* FiveStateScoreUnit defined */ #ifndef DYNAMITE_DEFINED_FiveStateScoreUnit typedef struct Wise2_FiveStateScoreUnit Wise2_FiveStateScoreUnit; #define FiveStateScoreUnit Wise2_FiveStateScoreUnit #define DYNAMITE_DEFINED_FiveStateScoreUnit #endif struct Wise2_FiveStateScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; /* name of the model */ FiveStateScoreUnit ** unit; int len;/* len for above unit */ int maxlen; /* maxlen for above unit */ } ; /* FiveStateScore defined */ #ifndef DYNAMITE_DEFINED_FiveStateScore typedef struct Wise2_FiveStateScore Wise2_FiveStateScore; #define FiveStateScore Wise2_FiveStateScore #define DYNAMITE_DEFINED_FiveStateScore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: pseudo_Protein_from_FiveStateModel(tsm) * * Descrip: Makes a protein sequence out of the display characters. * Not very useful! * * * * Arg: tsm [UNKN ] Undocumented argument [FiveStateModel *] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Wise2_pseudo_Protein_from_FiveStateModel(FiveStateModel * tsm); #define pseudo_Protein_from_FiveStateModel Wise2_pseudo_Protein_from_FiveStateModel /* Function: add_FiveStateFrame(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FiveStateFrame *] * Arg: add [OWNER] Object to add to the list [ThreeStateModel *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_FiveStateFrame(FiveStateFrame * obj,ThreeStateModel * add); #define add_FiveStateFrame Wise2_add_FiveStateFrame /* Function: flush_FiveStateFrame(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FiveStateFrame *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_FiveStateFrame(FiveStateFrame * obj); #define flush_FiveStateFrame Wise2_flush_FiveStateFrame /* Function: FiveStateFrame_alloc_std(void) * * Descrip: Equivalent to FiveStateFrame_alloc_len(FiveStateFrameLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FiveStateFrame *] * */ FiveStateFrame * Wise2_FiveStateFrame_alloc_std(void); #define FiveStateFrame_alloc_std Wise2_FiveStateFrame_alloc_std /* Function: FiveStateFrame_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FiveStateFrame *] * */ FiveStateFrame * Wise2_FiveStateFrame_alloc_len(int len); #define FiveStateFrame_alloc_len Wise2_FiveStateFrame_alloc_len /* Function: hard_link_FiveStateFrame(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateFrame *] * * Return [UNKN ] Undocumented return value [FiveStateFrame *] * */ FiveStateFrame * Wise2_hard_link_FiveStateFrame(FiveStateFrame * obj); #define hard_link_FiveStateFrame Wise2_hard_link_FiveStateFrame /* Function: FiveStateFrame_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateFrame *] * */ FiveStateFrame * Wise2_FiveStateFrame_alloc(void); #define FiveStateFrame_alloc Wise2_FiveStateFrame_alloc /* Function: free_FiveStateFrame(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateFrame *] * * Return [UNKN ] Undocumented return value [FiveStateFrame *] * */ FiveStateFrame * Wise2_free_FiveStateFrame(FiveStateFrame * obj); #define free_FiveStateFrame Wise2_free_FiveStateFrame /* Function: add_FiveStateFrameSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FiveStateFrameSet *] * Arg: add [OWNER] Object to add to the list [FiveStateFrame *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_FiveStateFrameSet(FiveStateFrameSet * obj,FiveStateFrame * add); #define add_FiveStateFrameSet Wise2_add_FiveStateFrameSet /* Function: flush_FiveStateFrameSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FiveStateFrameSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_FiveStateFrameSet(FiveStateFrameSet * obj); #define flush_FiveStateFrameSet Wise2_flush_FiveStateFrameSet /* Function: FiveStateFrameSet_alloc_std(void) * * Descrip: Equivalent to FiveStateFrameSet_alloc_len(FiveStateFrameSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FiveStateFrameSet *] * */ FiveStateFrameSet * Wise2_FiveStateFrameSet_alloc_std(void); #define FiveStateFrameSet_alloc_std Wise2_FiveStateFrameSet_alloc_std /* Function: FiveStateFrameSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FiveStateFrameSet *] * */ FiveStateFrameSet * Wise2_FiveStateFrameSet_alloc_len(int len); #define FiveStateFrameSet_alloc_len Wise2_FiveStateFrameSet_alloc_len /* Function: hard_link_FiveStateFrameSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateFrameSet *] * * Return [UNKN ] Undocumented return value [FiveStateFrameSet *] * */ FiveStateFrameSet * Wise2_hard_link_FiveStateFrameSet(FiveStateFrameSet * obj); #define hard_link_FiveStateFrameSet Wise2_hard_link_FiveStateFrameSet /* Function: FiveStateFrameSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateFrameSet *] * */ FiveStateFrameSet * Wise2_FiveStateFrameSet_alloc(void); #define FiveStateFrameSet_alloc Wise2_FiveStateFrameSet_alloc /* Function: free_FiveStateFrameSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateFrameSet *] * * Return [UNKN ] Undocumented return value [FiveStateFrameSet *] * */ FiveStateFrameSet * Wise2_free_FiveStateFrameSet(FiveStateFrameSet * obj); #define free_FiveStateFrameSet Wise2_free_FiveStateFrameSet /* Function: hard_link_FiveStateUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateUnit *] * * Return [UNKN ] Undocumented return value [FiveStateUnit *] * */ FiveStateUnit * Wise2_hard_link_FiveStateUnit(FiveStateUnit * obj); #define hard_link_FiveStateUnit Wise2_hard_link_FiveStateUnit /* Function: FiveStateUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateUnit *] * */ FiveStateUnit * Wise2_FiveStateUnit_alloc(void); #define FiveStateUnit_alloc Wise2_FiveStateUnit_alloc /* Function: free_FiveStateUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateUnit *] * * Return [UNKN ] Undocumented return value [FiveStateUnit *] * */ FiveStateUnit * Wise2_free_FiveStateUnit(FiveStateUnit * obj); #define free_FiveStateUnit Wise2_free_FiveStateUnit /* Function: hard_link_FiveStateFrameIndicator(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateFrameIndicator *] * * Return [UNKN ] Undocumented return value [FiveStateFrameIndicator *] * */ FiveStateFrameIndicator * Wise2_hard_link_FiveStateFrameIndicator(FiveStateFrameIndicator * obj); #define hard_link_FiveStateFrameIndicator Wise2_hard_link_FiveStateFrameIndicator /* Function: FiveStateFrameIndicator_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateFrameIndicator *] * */ FiveStateFrameIndicator * Wise2_FiveStateFrameIndicator_alloc(void); #define FiveStateFrameIndicator_alloc Wise2_FiveStateFrameIndicator_alloc /* Function: free_FiveStateFrameIndicator(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateFrameIndicator *] * * Return [UNKN ] Undocumented return value [FiveStateFrameIndicator *] * */ FiveStateFrameIndicator * Wise2_free_FiveStateFrameIndicator(FiveStateFrameIndicator * obj); #define free_FiveStateFrameIndicator Wise2_free_FiveStateFrameIndicator /* Function: add_FiveStateModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FiveStateModel *] * Arg: add [OWNER] Object to add to the list [FiveStateUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_FiveStateModel(FiveStateModel * obj,FiveStateUnit * add); #define add_FiveStateModel Wise2_add_FiveStateModel /* Function: flush_FiveStateModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FiveStateModel *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_FiveStateModel(FiveStateModel * obj); #define flush_FiveStateModel Wise2_flush_FiveStateModel /* Function: add_tsm_FiveStateModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FiveStateModel *] * Arg: add [OWNER] Object to add to the list [FiveStateFrameIndicator *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_tsm_FiveStateModel(FiveStateModel * obj,FiveStateFrameIndicator * add); #define add_tsm_FiveStateModel Wise2_add_tsm_FiveStateModel /* Function: flush_tsm_FiveStateModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FiveStateModel *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_tsm_FiveStateModel(FiveStateModel * obj); #define flush_tsm_FiveStateModel Wise2_flush_tsm_FiveStateModel /* Function: FiveStateModel_alloc_std(void) * * Descrip: Equivalent to FiveStateModel_alloc_len(FiveStateModelLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FiveStateModel *] * */ FiveStateModel * Wise2_FiveStateModel_alloc_std(void); #define FiveStateModel_alloc_std Wise2_FiveStateModel_alloc_std /* Function: FiveStateModel_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FiveStateModel *] * */ FiveStateModel * Wise2_FiveStateModel_alloc_len(int len); #define FiveStateModel_alloc_len Wise2_FiveStateModel_alloc_len /* Function: hard_link_FiveStateModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateModel *] * * Return [UNKN ] Undocumented return value [FiveStateModel *] * */ FiveStateModel * Wise2_hard_link_FiveStateModel(FiveStateModel * obj); #define hard_link_FiveStateModel Wise2_hard_link_FiveStateModel /* Function: FiveStateModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateModel *] * */ FiveStateModel * Wise2_FiveStateModel_alloc(void); #define FiveStateModel_alloc Wise2_FiveStateModel_alloc /* Function: free_FiveStateModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateModel *] * * Return [UNKN ] Undocumented return value [FiveStateModel *] * */ FiveStateModel * Wise2_free_FiveStateModel(FiveStateModel * obj); #define free_FiveStateModel Wise2_free_FiveStateModel /* Function: hard_link_FiveStateScoreUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateScoreUnit *] * * Return [UNKN ] Undocumented return value [FiveStateScoreUnit *] * */ FiveStateScoreUnit * Wise2_hard_link_FiveStateScoreUnit(FiveStateScoreUnit * obj); #define hard_link_FiveStateScoreUnit Wise2_hard_link_FiveStateScoreUnit /* Function: FiveStateScoreUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateScoreUnit *] * */ FiveStateScoreUnit * Wise2_FiveStateScoreUnit_alloc(void); #define FiveStateScoreUnit_alloc Wise2_FiveStateScoreUnit_alloc /* Function: free_FiveStateScoreUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateScoreUnit *] * * Return [UNKN ] Undocumented return value [FiveStateScoreUnit *] * */ FiveStateScoreUnit * Wise2_free_FiveStateScoreUnit(FiveStateScoreUnit * obj); #define free_FiveStateScoreUnit Wise2_free_FiveStateScoreUnit /* Function: add_FiveStateScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FiveStateScore *] * Arg: add [OWNER] Object to add to the list [FiveStateScoreUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_FiveStateScore(FiveStateScore * obj,FiveStateScoreUnit * add); #define add_FiveStateScore Wise2_add_FiveStateScore /* Function: flush_FiveStateScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FiveStateScore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_FiveStateScore(FiveStateScore * obj); #define flush_FiveStateScore Wise2_flush_FiveStateScore /* Function: FiveStateScore_alloc_std(void) * * Descrip: Equivalent to FiveStateScore_alloc_len(FiveStateScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FiveStateScore *] * */ FiveStateScore * Wise2_FiveStateScore_alloc_std(void); #define FiveStateScore_alloc_std Wise2_FiveStateScore_alloc_std /* Function: FiveStateScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FiveStateScore *] * */ FiveStateScore * Wise2_FiveStateScore_alloc_len(int len); #define FiveStateScore_alloc_len Wise2_FiveStateScore_alloc_len /* Function: hard_link_FiveStateScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FiveStateScore *] * * Return [UNKN ] Undocumented return value [FiveStateScore *] * */ FiveStateScore * Wise2_hard_link_FiveStateScore(FiveStateScore * obj); #define hard_link_FiveStateScore Wise2_hard_link_FiveStateScore /* Function: FiveStateScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FiveStateScore *] * */ FiveStateScore * Wise2_FiveStateScore_alloc(void); #define FiveStateScore_alloc Wise2_FiveStateScore_alloc /* Function: free_FiveStateScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FiveStateScore *] * * Return [UNKN ] Undocumented return value [FiveStateScore *] * */ FiveStateScore * Wise2_free_FiveStateScore(FiveStateScore * obj); #define free_FiveStateScore Wise2_free_FiveStateScore /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_dump_FiveStateModel(FiveStateModel * five,FILE * ofp); #define dump_FiveStateModel Wise2_dump_FiveStateModel void Wise2_dump_FiveStateScore(FiveStateScore * five,FILE * ofp); #define dump_FiveStateScore Wise2_dump_FiveStateScore FiveStateFrameSet * Wise2_read_FiveStateFrameSet_file(char * context,char * block_str); #define read_FiveStateFrameSet_file Wise2_read_FiveStateFrameSet_file FiveStateFrameSet * Wise2_read_FiveStateFrameSet(char * context,FILE * ifp); #define read_FiveStateFrameSet Wise2_read_FiveStateFrameSet void Wise2_blank_FiveStateUnit(FiveStateUnit * u); #define blank_FiveStateUnit Wise2_blank_FiveStateUnit FiveStateModel * Wise2_FiveStateModel_from_FiveStateFrameSet(FiveStateFrameSet * frame); #define FiveStateModel_from_FiveStateFrameSet Wise2_FiveStateModel_from_FiveStateFrameSet void Wise2_fold_RandomModel_into_FiveStateModel(FiveStateModel * fsm,RandomModel * rm); #define fold_RandomModel_into_FiveStateModel Wise2_fold_RandomModel_into_FiveStateModel FiveStateModel * Wise2_FiveStateModel_from_flat_ThreeStateModel(ThreeStateModel * tsm); #define FiveStateModel_from_flat_ThreeStateModel Wise2_FiveStateModel_from_flat_ThreeStateModel FiveStateScore * Wise2_FiveStateScore_from_FiveStateModel(FiveStateModel * fsm); #define FiveStateScore_from_FiveStateModel Wise2_FiveStateScore_from_FiveStateModel FiveStateScoreUnit * Wise2_FiveStateScoreUnit_from_FiveStateUnit(FiveStateUnit * prev,FiveStateUnit * u); #define FiveStateScoreUnit_from_FiveStateUnit Wise2_FiveStateScoreUnit_from_FiveStateUnit /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_FiveStateFrame(ThreeStateModel ** list,int i,int j) ; #define swap_FiveStateFrame Wise2_swap_FiveStateFrame void Wise2_qsort_FiveStateFrame(ThreeStateModel ** list,int left,int right,int (*comp)(ThreeStateModel * ,ThreeStateModel * )); #define qsort_FiveStateFrame Wise2_qsort_FiveStateFrame void Wise2_sort_FiveStateFrame(FiveStateFrame * obj,int (*comp)(ThreeStateModel *, ThreeStateModel *)); #define sort_FiveStateFrame Wise2_sort_FiveStateFrame boolean Wise2_expand_FiveStateFrame(FiveStateFrame * obj,int len); #define expand_FiveStateFrame Wise2_expand_FiveStateFrame void Wise2_swap_FiveStateFrameSet(FiveStateFrame ** list,int i,int j) ; #define swap_FiveStateFrameSet Wise2_swap_FiveStateFrameSet void Wise2_qsort_FiveStateFrameSet(FiveStateFrame ** list,int left,int right,int (*comp)(FiveStateFrame * ,FiveStateFrame * )); #define qsort_FiveStateFrameSet Wise2_qsort_FiveStateFrameSet void Wise2_sort_FiveStateFrameSet(FiveStateFrameSet * obj,int (*comp)(FiveStateFrame *, FiveStateFrame *)); #define sort_FiveStateFrameSet Wise2_sort_FiveStateFrameSet boolean Wise2_expand_FiveStateFrameSet(FiveStateFrameSet * obj,int len); #define expand_FiveStateFrameSet Wise2_expand_FiveStateFrameSet void Wise2_swap_FiveStateModel(FiveStateUnit ** list,int i,int j) ; #define swap_FiveStateModel Wise2_swap_FiveStateModel void Wise2_qsort_FiveStateModel(FiveStateUnit ** list,int left,int right,int (*comp)(FiveStateUnit * ,FiveStateUnit * )); #define qsort_FiveStateModel Wise2_qsort_FiveStateModel void Wise2_sort_FiveStateModel(FiveStateModel * obj,int (*comp)(FiveStateUnit *, FiveStateUnit *)); #define sort_FiveStateModel Wise2_sort_FiveStateModel boolean Wise2_expand_FiveStateModel(FiveStateModel * obj,int len); #define expand_FiveStateModel Wise2_expand_FiveStateModel void Wise2_swap_tsm_FiveStateModel(FiveStateFrameIndicator ** list,int i,int j) ; #define swap_tsm_FiveStateModel Wise2_swap_tsm_FiveStateModel void Wise2_qsort_tsm_FiveStateModel(FiveStateFrameIndicator ** list,int left,int right,int (*comp)(FiveStateFrameIndicator * ,FiveStateFrameIndicator * )); #define qsort_tsm_FiveStateModel Wise2_qsort_tsm_FiveStateModel void Wise2_sort_tsm_FiveStateModel(FiveStateModel * obj,int (*comp)(FiveStateFrameIndicator *, FiveStateFrameIndicator *)); #define sort_tsm_FiveStateModel Wise2_sort_tsm_FiveStateModel boolean Wise2_expand_tsm_FiveStateModel(FiveStateModel * obj,int len); #define expand_tsm_FiveStateModel Wise2_expand_tsm_FiveStateModel void Wise2_swap_FiveStateScore(FiveStateScoreUnit ** list,int i,int j) ; #define swap_FiveStateScore Wise2_swap_FiveStateScore void Wise2_qsort_FiveStateScore(FiveStateScoreUnit ** list,int left,int right,int (*comp)(FiveStateScoreUnit * ,FiveStateScoreUnit * )); #define qsort_FiveStateScore Wise2_qsort_FiveStateScore void Wise2_sort_FiveStateScore(FiveStateScore * obj,int (*comp)(FiveStateScoreUnit *, FiveStateScoreUnit *)); #define sort_FiveStateScore Wise2_sort_FiveStateScore boolean Wise2_expand_FiveStateScore(FiveStateScore * obj,int len); #define expand_FiveStateScore Wise2_expand_FiveStateScore #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/gwquickdb.c0000644000175000001440000001245610670453714016266 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "gwquickdb.h" /* Function: init_GeneWiseQuickDB(gdb,return_status) * * Descrip: inits a genewisequick database. * * * Arg: gdb [UNKN ] Undocumented argument [GeneWiseQuickDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *] * */ # line 37 "gwquickdb.dy" GeneWiseScoreFlat * init_GeneWiseQuickDB(GeneWiseQuickDB * gdb,int * return_status) { GeneWiseScore * gws; gws = init_GeneWiseDB(gdb->gwdb,return_status); if( gws != NULL ) { return GeneWiseScoreFlat_from_GeneWiseScore(gws); } } /* Function: reload_GeneWiseQuickDB(prev,gdb,return_status) * * Descrip: Reloads a genewisequick database * * * * Arg: prev [UNKN ] Undocumented argument [GeneWiseScoreFlat *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseQuickDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *] * */ # line 53 "gwquickdb.dy" GeneWiseScoreFlat * reload_GeneWiseQuickDB(GeneWiseScoreFlat * prev,GeneWiseQuickDB * gdb,int * return_status) { GeneWiseScore * gws; if( prev != NULL ) free_GeneWiseScoreFlat(prev); gws = reload_GeneWiseDB(NULL,gdb->gwdb,return_status); if( gws != NULL ) { return GeneWiseScoreFlat_from_GeneWiseScore(gws); } } /* Function: close_GeneWiseQuickDB(gws,gdb) * * Descrip: closes a GeneWiseDB * * * Arg: gws [UNKN ] Undocumented argument [GeneWiseScoreFlat *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseQuickDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 71 "gwquickdb.dy" boolean close_GeneWiseQuickDB(GeneWiseScoreFlat * gws,GeneWiseQuickDB * gdb) { if( gws != NULL ) free_GeneWiseScoreFlat(gws); return close_GeneWiseDB(NULL,gdb->gwdb); } /* Function: dataentry_add_GeneWiseQuickDB(de,gws,gdb) * * Descrip: adds dataentry stuff to a query. * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: gws [UNKN ] Undocumented argument [GeneWiseScoreFlat *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseQuickDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 82 "gwquickdb.dy" boolean dataentry_add_GeneWiseQuickDB(DataEntry * de,GeneWiseScoreFlat * gws,GeneWiseQuickDB * gdb) { return dataentry_add_GeneWiseDB(de,NULL,gdb->gwdb); } /* Function: GeneWiseQuickDB_from_GeneWiseDB(gwdb) * * Descrip: Makes a new genewisequickdb from a genewisemodeldb * * * Arg: gwdb [READ ] genewisedb - hard links as it enters [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [GeneWiseQuickDB *] * */ # line 92 "gwquickdb.dy" GeneWiseQuickDB * GeneWiseQuickDB_from_GeneWiseDB(GeneWiseDB * gwdb) { GeneWiseQuickDB * out; out = GeneWiseQuickDB_alloc(); out->gwdb = hard_link_GeneWiseDB(gwdb); return out; } # line 108 "gwquickdb.c" /* Function: hard_link_GeneWiseQuickDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseQuickDB *] * * Return [UNKN ] Undocumented return value [GeneWiseQuickDB *] * */ GeneWiseQuickDB * hard_link_GeneWiseQuickDB(GeneWiseQuickDB * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneWiseQuickDB object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneWiseQuickDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseQuickDB *] * */ GeneWiseQuickDB * GeneWiseQuickDB_alloc(void) { GeneWiseQuickDB * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWiseQuickDB *) ckalloc (sizeof(GeneWiseQuickDB))) == NULL) { warn("GeneWiseQuickDB_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->gwdb = NULL; return out; } /* Function: free_GeneWiseQuickDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseQuickDB *] * * Return [UNKN ] Undocumented return value [GeneWiseQuickDB *] * */ GeneWiseQuickDB * free_GeneWiseQuickDB(GeneWiseQuickDB * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneWiseQuickDB obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->gwdb != NULL) free_GeneWiseDB(obj->gwdb); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/gwquickdb.h0000644000175000001440000001260310670453714016265 0ustar philippusers#ifndef DYNAMITEgwquickdbHEADERFILE #define DYNAMITEgwquickdbHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "genewisemodeldb.h" /* Object GeneWiseQuickDB * * Descrip: This is a database stream of * GeneWiseScoreFlat objects, layered * ontop of a vanilla genewisedb. * * The GeneWiseScoreFlat objects give * around a 10% speed up due to them * being allocated as a single block * of memory that then gets accessed * * This object is a very thin layer over * the genewisedb object, which itself handles * the actual HMM stuff via threestatedb object. * So if you want to discover how HMMs are * actually being streamed into the database, * look in there. * * */ struct Wise2_GeneWiseQuickDB { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GeneWiseDB * gwdb; } ; /* GeneWiseQuickDB defined */ #ifndef DYNAMITE_DEFINED_GeneWiseQuickDB typedef struct Wise2_GeneWiseQuickDB Wise2_GeneWiseQuickDB; #define GeneWiseQuickDB Wise2_GeneWiseQuickDB #define DYNAMITE_DEFINED_GeneWiseQuickDB #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: init_GeneWiseQuickDB(gdb,return_status) * * Descrip: inits a genewisequick database. * * * Arg: gdb [UNKN ] Undocumented argument [GeneWiseQuickDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *] * */ GeneWiseScoreFlat * Wise2_init_GeneWiseQuickDB(GeneWiseQuickDB * gdb,int * return_status); #define init_GeneWiseQuickDB Wise2_init_GeneWiseQuickDB /* Function: reload_GeneWiseQuickDB(prev,gdb,return_status) * * Descrip: Reloads a genewisequick database * * * * Arg: prev [UNKN ] Undocumented argument [GeneWiseScoreFlat *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseQuickDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [GeneWiseScoreFlat *] * */ GeneWiseScoreFlat * Wise2_reload_GeneWiseQuickDB(GeneWiseScoreFlat * prev,GeneWiseQuickDB * gdb,int * return_status); #define reload_GeneWiseQuickDB Wise2_reload_GeneWiseQuickDB /* Function: close_GeneWiseQuickDB(gws,gdb) * * Descrip: closes a GeneWiseDB * * * Arg: gws [UNKN ] Undocumented argument [GeneWiseScoreFlat *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseQuickDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_close_GeneWiseQuickDB(GeneWiseScoreFlat * gws,GeneWiseQuickDB * gdb); #define close_GeneWiseQuickDB Wise2_close_GeneWiseQuickDB /* Function: dataentry_add_GeneWiseQuickDB(de,gws,gdb) * * Descrip: adds dataentry stuff to a query. * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: gws [UNKN ] Undocumented argument [GeneWiseScoreFlat *] * Arg: gdb [UNKN ] Undocumented argument [GeneWiseQuickDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_dataentry_add_GeneWiseQuickDB(DataEntry * de,GeneWiseScoreFlat * gws,GeneWiseQuickDB * gdb); #define dataentry_add_GeneWiseQuickDB Wise2_dataentry_add_GeneWiseQuickDB /* Function: GeneWiseQuickDB_from_GeneWiseDB(gwdb) * * Descrip: Makes a new genewisequickdb from a genewisemodeldb * * * Arg: gwdb [READ ] genewisedb - hard links as it enters [GeneWiseDB *] * * Return [UNKN ] Undocumented return value [GeneWiseQuickDB *] * */ GeneWiseQuickDB * Wise2_GeneWiseQuickDB_from_GeneWiseDB(GeneWiseDB * gwdb); #define GeneWiseQuickDB_from_GeneWiseDB Wise2_GeneWiseQuickDB_from_GeneWiseDB /* Function: hard_link_GeneWiseQuickDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseQuickDB *] * * Return [UNKN ] Undocumented return value [GeneWiseQuickDB *] * */ GeneWiseQuickDB * Wise2_hard_link_GeneWiseQuickDB(GeneWiseQuickDB * obj); #define hard_link_GeneWiseQuickDB Wise2_hard_link_GeneWiseQuickDB /* Function: GeneWiseQuickDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseQuickDB *] * */ GeneWiseQuickDB * Wise2_GeneWiseQuickDB_alloc(void); #define GeneWiseQuickDB_alloc Wise2_GeneWiseQuickDB_alloc /* Function: free_GeneWiseQuickDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseQuickDB *] * * Return [UNKN ] Undocumented return value [GeneWiseQuickDB *] * */ GeneWiseQuickDB * Wise2_free_GeneWiseQuickDB(GeneWiseQuickDB * obj); #define free_GeneWiseQuickDB Wise2_free_GeneWiseQuickDB /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/localclonewisedp.c0000644000175000001440000050560510670453714017640 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "localclonewisedp.h" # line 5 "localclonewisedp.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define SKIP_QUERY 1 #define SKIP_TARGET 2 #define START 0 #define END 1 #define LocalCloneWise_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*3)+STATE][i+1] #define LocalCloneWise_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define LocalCloneWise_READ_OFF_ERROR -3 #define LocalCloneWise_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*3)+STATE] #define LocalCloneWise_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define LocalCloneWise_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define LocalCloneWise_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_LocalCloneWise(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_LocalCloneWise(LocalCloneWise * mat) { LocalCloneWise_access_func_holder holder; holder.access_main = LocalCloneWise_shatter_access_main; holder.access_special = LocalCloneWise_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_LocalCloneWise(mat,holder); } /* Function: LocalCloneWise_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LocalCloneWise_shatter_access_main(LocalCloneWise * mat,int i,int j,int state) { return LocalCloneWise_SHATTER_MATRIX(mat,i,j,state); } /* Function: LocalCloneWise_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LocalCloneWise_shatter_access_special(LocalCloneWise * mat,int i,int j,int state) { return LocalCloneWise_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_LocalCloneWise(mat,dpenv) * * Descrip: This function calculates the LocalCloneWise matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [LocalCloneWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_LocalCloneWise(LocalCloneWise * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("LocalCloneWise Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_1[MATCH] + mat->match->matrix[i][j]; /* From state MATCH to state MATCH */ temp = SIG_0_1[MATCH] + (0-1); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_0[MATCH] + (0-1); if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state MATCH */ temp = SIG_1_1[SKIP_QUERY] + 0; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state MATCH */ temp = SIG_1_1[SKIP_TARGET] + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state START to state MATCH */ temp = LocalCloneWise_SHATTER_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (0) + (0) ; if( temp > LocalCloneWise_SHATTER_SPECIAL(mat,i,j,END) ) { LocalCloneWise_SHATTER_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query_skip_start; /* From state SKIP_TARGET to state SKIP_QUERY */ temp = SIG_1_0[SKIP_TARGET] + mat->query_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = SIG_1_0[SKIP_QUERY] + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state START to state SKIP_QUERY */ temp = LocalCloneWise_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; SIG_0_0[SKIP_QUERY] = score; /* state SKIP_QUERY is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (0) + (0) ; if( temp > LocalCloneWise_SHATTER_SPECIAL(mat,i,j,END) ) { LocalCloneWise_SHATTER_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = SIG_0_1[MATCH] + (mat->target_skip_start-10); /* From state SKIP_QUERY to state SKIP_TARGET */ temp = SIG_0_1[SKIP_QUERY] + (mat->target_skip_start-10); if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = SIG_0_1[SKIP_TARGET] + (0-10); if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-0) == 0 ) { /* From state START to state SKIP_TARGET */ temp = LocalCloneWise_SHATTER_SPECIAL(mat,i-0,j-1,START) + mat->target_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; SIG_0_0[SKIP_TARGET] = score; /* state SKIP_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (0) + (0) ; if( temp > LocalCloneWise_SHATTER_SPECIAL(mat,i,j,END) ) { LocalCloneWise_SHATTER_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state SKIP_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_LocalCloneWise(dbsi,out,q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function makes a database search of LocalCloneWise * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: t [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: match [UNKN ] Undocumented argument [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Undocumented argument [Score] * Arg: target_skip [UNKN ] Undocumented argument [Score] * Arg: query_skip_start [UNKN ] Undocumented argument [Score] * Arg: query_skip [UNKN ] Undocumented argument [Score] * Arg: spread [UNKN ] Undocumented argument [int] * Arg: target_special_s [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_LocalCloneWise(DBSearchImpl * dbsi,Hscore * out,MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_LocalCloneWise * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_LocalCloneWise. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_LocalCloneWise. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for LocalCloneWise, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_LocalCloneWise(out,q,t ,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_LocalCloneWise *) ckalloc(sizeof(struct thread_pool_holder_LocalCloneWise)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->q = q; holder->t = t; holder->match = match; holder->target_skip_start = target_skip_start; holder->target_skip = target_skip; holder->query_skip_start = query_skip_start; holder->query_skip = query_skip; holder->spread = spread; holder->target_special_s = target_special_s; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_LocalCloneWise,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for LocalCloneWise"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from LocalCloneWise",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_LocalCloneWise(ptr) * * Descrip: dummy loop code foreach thread for LocalCloneWise * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * thread_loop_LocalCloneWise(void * ptr) { fatal("dummy thread loop function"); } /* Function: serial_search_LocalCloneWise(out,q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function makes a database search of LocalCloneWise * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: t [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: match [UNKN ] Undocumented argument [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Undocumented argument [Score] * Arg: target_skip [UNKN ] Undocumented argument [Score] * Arg: query_skip_start [UNKN ] Undocumented argument [Score] * Arg: query_skip [UNKN ] Undocumented argument [Score] * Arg: spread [UNKN ] Undocumented argument [int] * Arg: target_special_s [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_LocalCloneWise(Hscore * out,MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_LocalCloneWise(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("LocalCloneWise search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_LocalCloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_LocalCloneWise_only * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_LocalCloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s) { int bestscore = NEGI; int i; int j; int k; LocalCloneWise * mat; mat = allocate_LocalCloneWise_only(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 3,2,2)) == NULL) { warn("Score only matrix for LocalCloneWise cannot be allocated, (asking for 1 by %d cells)",mat->leni*3); mat = free_LocalCloneWise(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) LocalCloneWise_VSMALL_MATRIX(mat,i,j,k) = NEGI; } LocalCloneWise_VSMALL_SPECIAL(mat,i,j,START) = 0; LocalCloneWise_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = LocalCloneWise_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->match->matrix[i][j]; /* From state MATCH to state MATCH */ temp = LocalCloneWise_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + (0-1); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = LocalCloneWise_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + (0-1); if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state MATCH */ temp = LocalCloneWise_VSMALL_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state MATCH */ temp = LocalCloneWise_VSMALL_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state START to state MATCH */ temp = LocalCloneWise_VSMALL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; LocalCloneWise_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (0) + (0) ; if( temp > LocalCloneWise_VSMALL_SPECIAL(mat,i,j,END) ) { LocalCloneWise_VSMALL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = LocalCloneWise_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; /* From state SKIP_TARGET to state SKIP_QUERY */ temp = LocalCloneWise_VSMALL_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = LocalCloneWise_VSMALL_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state START to state SKIP_QUERY */ temp = LocalCloneWise_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; LocalCloneWise_VSMALL_MATRIX(mat,i,j,SKIP_QUERY) = score; /* state SKIP_QUERY is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (0) + (0) ; if( temp > LocalCloneWise_VSMALL_SPECIAL(mat,i,j,END) ) { LocalCloneWise_VSMALL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = LocalCloneWise_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + (mat->target_skip_start-10); /* From state SKIP_QUERY to state SKIP_TARGET */ temp = LocalCloneWise_VSMALL_MATRIX(mat,i-0,j-1,SKIP_QUERY) + (mat->target_skip_start-10); if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = LocalCloneWise_VSMALL_MATRIX(mat,i-0,j-1,SKIP_TARGET) + (0-10); if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-0) == 0 ) { /* From state START to state SKIP_TARGET */ temp = LocalCloneWise_VSMALL_SPECIAL(mat,i-0,j-1,START) + mat->target_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; LocalCloneWise_VSMALL_MATRIX(mat,i,j,SKIP_TARGET) = score; /* state SKIP_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (0) + (0) ; if( temp > LocalCloneWise_VSMALL_SPECIAL(mat,i,j,END) ) { LocalCloneWise_VSMALL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state SKIP_TARGET */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < LocalCloneWise_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = LocalCloneWise_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_LocalCloneWise(mat); return bestscore; } /* Function: PackAln_bestmemory_LocalCloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_LocalCloneWise * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_LocalCloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; LocalCloneWise * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = q->length * t->length; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_LocalCloneWise(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s,dpri)) == NULL ) { warn("Unable to allocate large LocalCloneWise version"); return NULL; } calculate_dpenv_LocalCloneWise(mat,dpenv); out = PackAln_read_Expl_LocalCloneWise(mat); } else { mat = allocate_LocalCloneWise_only(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s); calculate_shatter_LocalCloneWise(mat,dpenv); out = PackAln_read_Shatter_LocalCloneWise(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_LocalCloneWise(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s)) == NULL ) { warn("Unable to allocate small LocalCloneWise version"); return NULL; } out = PackAln_calculate_Small_LocalCloneWise(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_LocalCloneWise(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s,dpri)) == NULL ) { warn("Unable to allocate large LocalCloneWise version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_LocalCloneWise(mat); out = PackAln_read_Expl_LocalCloneWise(mat); } } } mat = free_LocalCloneWise(mat); return out; } /* Function: allocate_LocalCloneWise_only(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function only allocates the LocalCloneWise structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [LocalCloneWise *] * */ LocalCloneWise * allocate_LocalCloneWise_only(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s) { LocalCloneWise * out; if((out= LocalCloneWise_alloc()) == NULL) { warn("Allocation of basic LocalCloneWise structure failed..."); return NULL; } out->q = q; out->t = t; out->match = match; out->target_skip_start = target_skip_start; out->target_skip = target_skip; out->query_skip_start = query_skip_start; out->query_skip = query_skip; out->spread = spread; out->target_special_s = target_special_s; out->leni = q->length; out->lenj = t->length; return out; } /* Function: allocate_Expl_LocalCloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s,dpri) * * Descrip: This function allocates the LocalCloneWise structure * and the basematrix area for explicit memory implementations * It calls /allocate_LocalCloneWise_only * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [LocalCloneWise *] * */ LocalCloneWise * allocate_Expl_LocalCloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s,DPRunImpl * dpri) { LocalCloneWise * out; out = allocate_LocalCloneWise_only(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*3,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix LocalCloneWise cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_LocalCloneWise(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_LocalCloneWise(out); return out; } /* Function: init_LocalCloneWise(mat) * * Descrip: This function initates LocalCloneWise matrix when in explicit mode * Called in /allocate_Expl_LocalCloneWise * * * Arg: mat [UNKN ] LocalCloneWise which contains explicit basematrix memory [LocalCloneWise *] * */ void init_LocalCloneWise(LocalCloneWise * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iq->length;i++) { for(j= (-1);j<2;j++) { LocalCloneWise_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; } } for(j= (-1);jt->length;j++) { for(i= (-1);i<2;i++) { LocalCloneWise_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; } LocalCloneWise_EXPL_SPECIAL(mat,i,j,START) = 0; LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_LocalCloneWise(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by LocalCloneWise * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * */ void recalculate_PackAln_LocalCloneWise(PackAln * pal,LocalCloneWise * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->match->matrix[i][j] + (mat->match->matrix[i][j]); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = (0-1) + (mat->match->matrix[i][j]); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = (0-1) + (mat->match->matrix[i][j]); continue; } if( offi == 1 && offj == 1 && prev->state == SKIP_QUERY ) { pau->score = 0 + (mat->match->matrix[i][j]); continue; } if( offi == 1 && offj == 1 && prev->state == SKIP_TARGET ) { pau->score = 0 + (mat->match->matrix[i][j]); continue; } if( offj == 1 && prev->state == (START+3) ) { pau->score = 0 + (mat->match->matrix[i][j]); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SKIP_QUERY : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query_skip_start + (mat->match->skip_iset[i]); continue; } if( offi == 1 && offj == 0 && prev->state == SKIP_TARGET ) { pau->score = mat->query_skip_start + (mat->match->skip_iset[i]); continue; } if( offi == 1 && offj == 0 && prev->state == SKIP_QUERY ) { pau->score = 0 + (mat->match->skip_iset[i]); continue; } if( offj == 0 && prev->state == (START+3) ) { pau->score = mat->query_skip_start + (mat->match->skip_iset[i]); continue; } warn("In recaluclating PackAln with state SKIP_QUERY, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SKIP_TARGET : if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = (mat->target_skip_start-10) + (mat->match->skip_jset[j]); continue; } if( offi == 0 && offj == 1 && prev->state == SKIP_QUERY ) { pau->score = (mat->target_skip_start-10) + (mat->match->skip_jset[j]); continue; } if( offi == 0 && offj == 1 && prev->state == SKIP_TARGET ) { pau->score = (0-10) + (mat->match->skip_jset[j]); continue; } if( offj == 1 && prev->state == (START+3) ) { pau->score = mat->target_skip_start + (mat->match->skip_jset[j]); continue; } warn("In recaluclating PackAln with state SKIP_TARGET, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+3) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == SKIP_TARGET ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == SKIP_QUERY ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define LocalCloneWise_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*3+state]) #define LocalCloneWise_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*3+state]) #define LocalCloneWise_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define LocalCloneWise_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define LocalCloneWise_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*3 + state]) #define LocalCloneWise_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define LocalCloneWise_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define LocalCloneWise_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_LocalCloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function allocates the LocalCloneWise structure * and the basematrix area for a small memory implementations * It calls /allocate_LocalCloneWise_only * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [LocalCloneWise *] * */ #define LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) LocalCloneWise * allocate_Small_LocalCloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s) { LocalCloneWise * out; out = allocate_LocalCloneWise_only(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 3,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix LocalCloneWise cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_LocalCloneWise(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_LocalCloneWise(mat,dpenv) * * Descrip: This function calculates an alignment for LocalCloneWise structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_LocalCloneWise * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_LocalCloneWise * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_LocalCloneWise(LocalCloneWise * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for LocalCloneWise due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_LocalCloneWise(mat,dpenv); score = start_end_find_end_LocalCloneWise(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_LocalCloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_LocalCloneWise(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == LocalCloneWise_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_LocalCloneWise(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 3; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_LocalCloneWise(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_LocalCloneWise(mat) * * Descrip: This function calculates an alignment for LocalCloneWise structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_LocalCloneWise * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_LocalCloneWise * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_LocalCloneWise * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_LocalCloneWise(LocalCloneWise * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_LocalCloneWise(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_LocalCloneWise(mat); return out; } /* Function: AlnRangeSet_from_LocalCloneWise(mat) * * Descrip: This function reads off a start/end structure * for LocalCloneWise structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_LocalCloneWise * If you have not calculated the matrix use * /AlnRange_calculate_Small_LocalCloneWise * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_LocalCloneWise(LocalCloneWise * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_LocalCloneWise"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_LocalCloneWise(mat,&jpos); state = END; while( (temp = AlnRange_build_LocalCloneWise(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_LocalCloneWise(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_LocalCloneWise * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_LocalCloneWise(LocalCloneWise * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_LocalCloneWise"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_LocalCloneWise(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_LocalCloneWise alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = LocalCloneWise_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_LocalCloneWise(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == LocalCloneWise_READ_OFF_ERROR) { warn("In AlnRange_build_LocalCloneWise alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = LocalCloneWise_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_LocalCloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_LocalCloneWise(LocalCloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_LocalCloneWise(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == LocalCloneWise_READ_OFF_ERROR) { warn("In LocalCloneWise hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In LocalCloneWise hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In LocalCloneWise hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_LocalCloneWise(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_LocalCloneWise(LocalCloneWise * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = LocalCloneWise_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->q->length || j > mat->t->length) { warn("In LocalCloneWise matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = LocalCloneWise_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Not allowing special sources.. skipping START */ temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 1,SKIP_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-1,SKIP_TARGET); } return LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 1,SKIP_TARGET); } temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 1,SKIP_QUERY) ) { *reti = i - 1; *retj = j - 1; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-1,SKIP_QUERY); } return LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 1,SKIP_QUERY); } temp = cscore - ((0-1)) - (mat->match->matrix[i][j]); if( temp == LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } temp = cscore - ((0-1)) - (mat->match->matrix[i][j]); if( temp == LocalCloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return LocalCloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } temp = cscore - (mat->match->matrix[i][j]) - (mat->match->matrix[i][j]); if( temp == LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in LocalCloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SKIP_QUERY : /* Not allowing special sources.. skipping START */ temp = cscore - (0) - (mat->match->skip_iset[i]); if( temp == LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,SKIP_QUERY) ) { *reti = i - 1; *retj = j - 0; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-0,SKIP_QUERY); } return LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,SKIP_QUERY); } temp = cscore - (mat->query_skip_start) - (mat->match->skip_iset[i]); if( temp == LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,SKIP_TARGET) ) { *reti = i - 1; *retj = j - 0; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-0,SKIP_TARGET); } return LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,SKIP_TARGET); } temp = cscore - (mat->query_skip_start) - (mat->match->skip_iset[i]); if( temp == LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return LocalCloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in LocalCloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SKIP_TARGET : /* Not allowing special sources.. skipping START */ temp = cscore - ((0-10)) - (mat->match->skip_jset[j]); if( temp == LocalCloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,SKIP_TARGET) ) { *reti = i - 0; *retj = j - 1; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_HIDDEN_MATRIX(mat,i-0,j-1,SKIP_TARGET); } return LocalCloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,SKIP_TARGET); } temp = cscore - ((mat->target_skip_start-10)) - (mat->match->skip_jset[j]); if( temp == LocalCloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,SKIP_QUERY) ) { *reti = i - 0; *retj = j - 1; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_HIDDEN_MATRIX(mat,i-0,j-1,SKIP_QUERY); } return LocalCloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,SKIP_QUERY); } temp = cscore - ((mat->target_skip_start-10)) - (mat->match->skip_jset[j]); if( temp == LocalCloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return LocalCloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in LocalCloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in LocalCloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_LocalCloneWise(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_LocalCloneWise(LocalCloneWise * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_LocalCloneWise(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == LocalCloneWise_READ_OFF_ERROR) { warn("In special strip read LocalCloneWise, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read LocalCloneWise, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_LocalCloneWise(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_LocalCloneWise(LocalCloneWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = LocalCloneWise_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for LocalCloneWise, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->t->length) { warn("In LocalCloneWise matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = LocalCloneWise_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source SKIP_QUERY is not a special */ /* Source SKIP_TARGET is not a special */ /* Source MATCH is not a special */ default: warn("Major problem (!) - in LocalCloneWise special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_LocalCloneWise(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_LocalCloneWise(LocalCloneWise * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = LocalCloneWise_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In LocalCloneWise matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == LocalCloneWise_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return LocalCloneWise_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source SKIP_TARGET is not a special, should not get here! */ /* Source SKIP_QUERY is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in LocalCloneWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SKIP_QUERY : temp = cscore - (mat->query_skip_start) - (mat->match->skip_iset[i]); if( temp == LocalCloneWise_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return LocalCloneWise_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source SKIP_QUERY is not a special, should not get here! */ /* Source SKIP_TARGET is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in LocalCloneWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SKIP_TARGET : temp = cscore - (mat->target_skip_start) - (mat->match->skip_jset[j]); if( temp == LocalCloneWise_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - LocalCloneWise_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return LocalCloneWise_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } /* Source SKIP_TARGET is not a special, should not get here! */ /* Source SKIP_QUERY is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in LocalCloneWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in LocalCloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_LocalCloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_LocalCloneWise(LocalCloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_LocalCloneWise(mat,starti,startj,stopi,stopj); LocalCloneWise_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LocalCloneWise_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; LocalCloneWise_HIDDEN_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; LocalCloneWise_HIDDEN_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->match->matrix[i][j]; /* From state MATCH to state MATCH */ temp = LocalCloneWise_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + (0-1); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + (0-1); if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state MATCH */ temp = LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state MATCH */ temp = LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; LocalCloneWise_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; /* From state SKIP_TARGET to state SKIP_QUERY */ temp = LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = LocalCloneWise_HIDDEN_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; LocalCloneWise_HIDDEN_MATRIX(mat,i,j,SKIP_QUERY) = score; /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = LocalCloneWise_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + (mat->target_skip_start-10); /* From state SKIP_QUERY to state SKIP_TARGET */ temp = LocalCloneWise_HIDDEN_MATRIX(mat,i-0,j-1,SKIP_QUERY) + (mat->target_skip_start-10); if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = LocalCloneWise_HIDDEN_MATRIX(mat,i-0,j-1,SKIP_TARGET) + (0-10); if( temp > score ) { score = temp; } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; LocalCloneWise_HIDDEN_MATRIX(mat,i,j,SKIP_TARGET) = score; /* Finished calculating state SKIP_TARGET */ } } return; } /* Function: init_hidden_LocalCloneWise(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_LocalCloneWise(LocalCloneWise * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { LocalCloneWise_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; LocalCloneWise_HIDDEN_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; LocalCloneWise_HIDDEN_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; } } return; } /* Function: full_dc_LocalCloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_LocalCloneWise * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_LocalCloneWise to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [LocalCloneWise *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_LocalCloneWise(LocalCloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_LocalCloneWise"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_LocalCloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_LocalCloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_LocalCloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for LocalCloneWise, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_LocalCloneWise(mat,LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_LocalCloneWise(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_LocalCloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_LocalCloneWise(LocalCloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_LocalCloneWise(mat); LocalCloneWise_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_LocalCloneWise(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_LocalCloneWise(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_LocalCloneWise(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_LocalCloneWise(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_LocalCloneWise(LocalCloneWise * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,0) = (-100); LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,1) = (-100); LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,0) = (-100); LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->match->matrix[i][j]; if( j - 1 <= mergej) { LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (0-1); if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-0; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } } temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (0-1); if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-0; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } } temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = SKIP_QUERY; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SKIP_QUERY,k); } } temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = SKIP_TARGET; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SKIP_TARGET,k); } } /* Add any movement independant score */ score += mat->match->matrix[i][j]; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state SKIP_QUERY, pushing when j - offj <= mergej */ score = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; if( j - 0 <= mergej) { LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,0) = i-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,1) = j-0; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,2) = MATCH; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,3) = i; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,4) = j; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,5) = SKIP_QUERY; } else { for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k) = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,0) = i-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,1) = j-0; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,2) = SKIP_TARGET; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,3) = i; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,4) = j; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,5) = SKIP_QUERY; } else { for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k) = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SKIP_TARGET,k); } } temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,0) = i-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,1) = j-0; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,2) = SKIP_QUERY; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,3) = i; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,4) = j; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,5) = SKIP_QUERY; } else { for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k) = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SKIP_QUERY,k); } } /* Add any movement independant score */ score += mat->match->skip_iset[i]; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = score; /* Finished with state SKIP_QUERY */ /* For state SKIP_TARGET, pushing when j - offj <= mergej */ score = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->target_skip_start-10); if( j - 1 <= mergej) { LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,0) = i-0; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,1) = j-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,2) = MATCH; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,3) = i; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,4) = j; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,5) = SKIP_TARGET; } else { for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k) = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,SKIP_QUERY) + (mat->target_skip_start-10); if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,0) = i-0; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,1) = j-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,2) = SKIP_QUERY; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,3) = i; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,4) = j; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,5) = SKIP_TARGET; } else { for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k) = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SKIP_QUERY,k); } } temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,SKIP_TARGET) + (0-10); if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,0) = i-0; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,1) = j-1; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,2) = SKIP_TARGET; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,3) = i; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,4) = j; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,5) = SKIP_TARGET; } else { for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k) = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SKIP_TARGET,k); } } /* Add any movement independant score */ score += mat->match->skip_jset[j]; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = score; /* Finished with state SKIP_TARGET */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_LocalCloneWise(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_LocalCloneWise(LocalCloneWise * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->match->matrix[i][j]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); /* From state MATCH to state MATCH */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (0-1); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } /* From state MATCH to state MATCH */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (0-1); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } /* From state SKIP_QUERY to state MATCH */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SKIP_QUERY,k); } /* From state SKIP_TARGET to state MATCH */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SKIP_TARGET,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state SKIP_TARGET to state SKIP_QUERY */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SKIP_TARGET,k); } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SKIP_QUERY,k); } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = score; for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->target_skip_start-10); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); /* From state SKIP_QUERY to state SKIP_TARGET */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,SKIP_QUERY) + (mat->target_skip_start-10); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SKIP_QUERY,k); } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,SKIP_TARGET) + (0-10); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SKIP_TARGET,k); } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = score; for(k=0;k<7;k++) LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SKIP_TARGET */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_LocalCloneWise(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_LocalCloneWise(LocalCloneWise * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->match->matrix[i][j]; /* From state MATCH to state MATCH */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (0-1); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (0-1); if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state MATCH */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state MATCH */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; /* From state SKIP_TARGET to state SKIP_QUERY */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = score; /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->target_skip_start-10); /* From state SKIP_QUERY to state SKIP_TARGET */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,SKIP_QUERY) + (mat->target_skip_start-10); if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = LocalCloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,SKIP_TARGET) + (0-10); if( temp > score ) { score = temp; } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = score; /* Finished calculating state SKIP_TARGET */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_LocalCloneWise(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * */ } void init_dc_LocalCloneWise(LocalCloneWise * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iq->length;i++) { LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; for(k=0;k<7;k++) { LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k) = (-1); LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k) = (-1); } } } return; } /* Function: start_end_find_end_LocalCloneWise(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [LocalCloneWise *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_LocalCloneWise(LocalCloneWise * mat,int * endj) { register int j; register int max; register int maxj; max = LocalCloneWise_DC_SHADOW_SPECIAL(mat,0,mat->t->length-1,END); maxj = mat->t->length-1; for(j= mat->t->length-2 ;j >= 0 ;j--) { if( LocalCloneWise_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = LocalCloneWise_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_LocalCloneWise(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [LocalCloneWise] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_LocalCloneWise(LocalCloneWise *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->q->length; lenj = mat->t->length; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jmatch->matrix[i][j] + (mat->match->matrix[i][j]); /* assign local shadown pointer */ localsp = &(LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); /* From state MATCH to state MATCH */ temp = LocalCloneWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (0-1) +(mat->match->matrix[i][j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); } /* From state MATCH to state MATCH */ temp = LocalCloneWise_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (0-1) +(mat->match->matrix[i][j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); } /* From state SKIP_QUERY to state MATCH */ temp = LocalCloneWise_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0 +(mat->match->matrix[i][j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SKIP_QUERY,0)); } /* From state SKIP_TARGET to state MATCH */ temp = LocalCloneWise_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0 +(mat->match->matrix[i][j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SKIP_TARGET,0)); } /* From state START to state MATCH */ temp = LocalCloneWise_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + 0 + (mat->match->matrix[i][j]); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LocalCloneWise_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalCloneWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { LocalCloneWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = LocalCloneWise_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start + (mat->match->skip_iset[i]); /* assign local shadown pointer */ localsp = &(LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state SKIP_TARGET to state SKIP_QUERY */ temp = LocalCloneWise_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start +(mat->match->skip_iset[i]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SKIP_TARGET,0)); } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = LocalCloneWise_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0 +(mat->match->skip_iset[i]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SKIP_QUERY,0)); } /* From state START to state SKIP_QUERY */ temp = LocalCloneWise_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query_skip_start + (mat->match->skip_iset[i]); if( temp > score ) { score = temp; /* This state [START] is a special for SKIP_QUERY... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= SKIP_QUERY; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LocalCloneWise_DC_OPT_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = score; for(k=0;k<7;k++) LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state SKIP_QUERY is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalCloneWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { LocalCloneWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k); LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,6); LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = SKIP_QUERY; } /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = LocalCloneWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->target_skip_start-10) + (mat->match->skip_jset[j]); /* assign local shadown pointer */ localsp = &(LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); /* From state SKIP_QUERY to state SKIP_TARGET */ temp = LocalCloneWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SKIP_QUERY) + (mat->target_skip_start-10) +(mat->match->skip_jset[j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SKIP_QUERY,0)); } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = LocalCloneWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SKIP_TARGET) + (0-10) +(mat->match->skip_jset[j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SKIP_TARGET,0)); } /* From state START to state SKIP_TARGET */ temp = LocalCloneWise_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,START) + mat->target_skip_start + (mat->match->skip_jset[j]); if( temp > score ) { score = temp; /* This state [START] is a special for SKIP_TARGET... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= SKIP_TARGET; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LocalCloneWise_DC_OPT_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = score; for(k=0;k<7;k++) LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state SKIP_TARGET is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalCloneWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { LocalCloneWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k); LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = LocalCloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,6); LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; LocalCloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = SKIP_TARGET; } /* Finished calculating state SKIP_TARGET */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_LocalCloneWise(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * */ void init_start_end_linear_LocalCloneWise(LocalCloneWise * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iq->length;i++) { LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,0) = (-1); LocalCloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; LocalCloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,0) = (-1); } } for(j=(-1);jt->length;j++) { LocalCloneWise_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; LocalCloneWise_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; LocalCloneWise_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_LocalCloneWise(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_LocalCloneWise(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_LocalCloneWise(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "QUERY_MATCH","QUERY_MATCH_PAUSE","QUERY_SKIP","QUERY_PAUSE","END" }; /* Function: AlnConvertSet_LocalCloneWise(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "TARGET_MATCH","TARGET_MATCH_PAUSE","TARGET_PAUSE","TARGET_SKIP","END" }; AlnConvertSet * AlnConvertSet_LocalCloneWise(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_QUERY; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_TARGET; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = SKIP_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_TARGET; acu->state2 = SKIP_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_QUERY; acu->state2 = SKIP_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = SKIP_QUERY; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = SKIP_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_QUERY; acu->state2 = SKIP_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_TARGET; acu->state2 = SKIP_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = SKIP_TARGET; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_TARGET; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_QUERY; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[4]; return out; } /* Function: PackAln_read_Expl_LocalCloneWise(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_LocalCloneWise(LocalCloneWise * mat) { LocalCloneWise_access_func_holder holder; holder.access_main = LocalCloneWise_explicit_access_main; holder.access_special = LocalCloneWise_explicit_access_special; return PackAln_read_generic_LocalCloneWise(mat,holder); } /* Function: LocalCloneWise_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LocalCloneWise_explicit_access_main(LocalCloneWise * mat,int i,int j,int state) { return LocalCloneWise_EXPL_MATRIX(mat,i,j,state); } /* Function: LocalCloneWise_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LocalCloneWise_explicit_access_special(LocalCloneWise * mat,int i,int j,int state) { return LocalCloneWise_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_LocalCloneWise(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: h [UNKN ] Undocumented argument [LocalCloneWise_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_LocalCloneWise(LocalCloneWise * mat,LocalCloneWise_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_LocalCloneWise(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in LocalCloneWise_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_LocalCloneWise(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_LocalCloneWise(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == LocalCloneWise_READ_OFF_ERROR || j == LocalCloneWise_READ_OFF_ERROR || state == LocalCloneWise_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in LocalCloneWise_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_LocalCloneWise(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [LocalCloneWise_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_LocalCloneWise(LocalCloneWise * mat,int * ri,int * rj,int * state,boolean * isspecial,LocalCloneWise_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->t->length-1,END); maxj = mat->t->length-1; for(j= mat->t->length-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: LocalCloneWise_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void LocalCloneWise_debug_show_matrix(LocalCloneWise * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iq->length;i++) { for(j=startj;jt->length;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",LocalCloneWise_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State SKIP_QUERY %d\n",LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY)); fprintf(ofp,"State SKIP_TARGET %d\n",LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_LocalCloneWise(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [LocalCloneWise_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_LocalCloneWise(LocalCloneWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LocalCloneWise_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = LocalCloneWise_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->q->length || j > mat->t->length) { warn("In LocalCloneWise matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Has restricted position */ if( (i-1) == 0 ) { temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } } temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == (*h.access_main)(mat,i - 1,j - 1,SKIP_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,SKIP_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,SKIP_TARGET); } temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == (*h.access_main)(mat,i - 1,j - 1,SKIP_QUERY) ) { *reti = i - 1; *retj = j - 1; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,SKIP_QUERY); } return (*h.access_main)(mat,i - 1,j - 1,SKIP_QUERY); } temp = cscore - ((0-1)) - (mat->match->matrix[i][j]); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } temp = cscore - ((0-1)) - (mat->match->matrix[i][j]); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } temp = cscore - (mat->match->matrix[i][j]) - (mat->match->matrix[i][j]); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in LocalCloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SKIP_QUERY : /* Has restricted position */ if( (i-1) == 0 ) { temp = cscore - (mat->query_skip_start) - (mat->match->skip_iset[i]); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } } temp = cscore - (0) - (mat->match->skip_iset[i]); if( temp == (*h.access_main)(mat,i - 1,j - 0,SKIP_QUERY) ) { *reti = i - 1; *retj = j - 0; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,SKIP_QUERY); } return (*h.access_main)(mat,i - 1,j - 0,SKIP_QUERY); } temp = cscore - (mat->query_skip_start) - (mat->match->skip_iset[i]); if( temp == (*h.access_main)(mat,i - 1,j - 0,SKIP_TARGET) ) { *reti = i - 1; *retj = j - 0; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,SKIP_TARGET); } return (*h.access_main)(mat,i - 1,j - 0,SKIP_TARGET); } temp = cscore - (mat->query_skip_start) - (mat->match->skip_iset[i]); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in LocalCloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SKIP_TARGET : /* Has restricted position */ if( (i-0) == 0 ) { temp = cscore - (mat->target_skip_start) - (mat->match->skip_jset[j]); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_main)(mat,i - 0,j - 1,START); } } temp = cscore - ((0-10)) - (mat->match->skip_jset[j]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SKIP_TARGET) ) { *reti = i - 0; *retj = j - 1; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SKIP_TARGET); } return (*h.access_main)(mat,i - 0,j - 1,SKIP_TARGET); } temp = cscore - ((mat->target_skip_start-10)) - (mat->match->skip_jset[j]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SKIP_QUERY) ) { *reti = i - 0; *retj = j - 1; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SKIP_QUERY); } return (*h.access_main)(mat,i - 0,j - 1,SKIP_QUERY); } temp = cscore - ((mat->target_skip_start-10)) - (mat->match->skip_jset[j]); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in LocalCloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in LocalCloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_LocalCloneWise(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [LocalCloneWise_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_LocalCloneWise(LocalCloneWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LocalCloneWise_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = LocalCloneWise_READ_OFF_ERROR; if( j < 0 || j > mat->t->length) { warn("In LocalCloneWise matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source SKIP_QUERY is from main matrix */ for(i= mat->q->length-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,SKIP_QUERY) ) { *reti = i - 0; *retj = j - 0; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,SKIP_QUERY); } return (*h.access_main)(mat,i - 0,j - 0,SKIP_QUERY) ; } } /* end of for i >= 0 */ /* source SKIP_TARGET is from main matrix */ for(i= mat->q->length-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,SKIP_TARGET) ) { *reti = i - 0; *retj = j - 0; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,SKIP_TARGET); } return (*h.access_main)(mat,i - 0,j - 0,SKIP_TARGET) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->q->length-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in LocalCloneWise read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_LocalCloneWise(mat) * * Descrip: This function calculates the LocalCloneWise matrix when in explicit mode * To allocate the matrix use /allocate_Expl_LocalCloneWise * * * Arg: mat [UNKN ] LocalCloneWise which contains explicit basematrix memory [LocalCloneWise *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_LocalCloneWise(LocalCloneWise * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_LocalCloneWise, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("LocalCloneWise Matrix calculation: "); for(j=0;jmatch->matrix[i][j]; /* From state MATCH to state MATCH */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-0,j-1,MATCH) + (0-1); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-1,j-0,MATCH) + (0-1); if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state MATCH */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state MATCH */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state START to state MATCH */ temp = LocalCloneWise_EXPL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; LocalCloneWise_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (0) + (0) ; if( temp > LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) ) { LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = LocalCloneWise_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; /* From state SKIP_TARGET to state SKIP_QUERY */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state START to state SKIP_QUERY */ temp = LocalCloneWise_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY) = score; /* state SKIP_QUERY is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (0) + (0) ; if( temp > LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) ) { LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = LocalCloneWise_EXPL_MATRIX(mat,i-0,j-1,MATCH) + (mat->target_skip_start-10); /* From state SKIP_QUERY to state SKIP_TARGET */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-0,j-1,SKIP_QUERY) + (mat->target_skip_start-10); if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-0,j-1,SKIP_TARGET) + (0-10); if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-0) == 0 ) { /* From state START to state SKIP_TARGET */ temp = LocalCloneWise_EXPL_SPECIAL(mat,i-0,j-1,START) + mat->target_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET) = score; /* state SKIP_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (0) + (0) ; if( temp > LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) ) { LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state SKIP_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_LocalCloneWise(mat,dpenv) * * Descrip: This function calculates the LocalCloneWise matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] LocalCloneWise which contains explicit basematrix memory [LocalCloneWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_LocalCloneWise(LocalCloneWise * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_LocalCloneWise, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { LocalCloneWise_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; } } for(j=-1;jlenj;j++) { LocalCloneWise_EXPL_SPECIAL(mat,i,j,START) = 0; LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("LocalCloneWise Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { LocalCloneWise_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = LocalCloneWise_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->match->matrix[i][j]; /* From state MATCH to state MATCH */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-0,j-1,MATCH) + (0-1); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-1,j-0,MATCH) + (0-1); if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state MATCH */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state MATCH */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state START to state MATCH */ temp = LocalCloneWise_EXPL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; LocalCloneWise_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (0) + (0) ; if( temp > LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) ) { LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = LocalCloneWise_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; /* From state SKIP_TARGET to state SKIP_QUERY */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 ) { /* From state START to state SKIP_QUERY */ temp = LocalCloneWise_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY) = score; /* state SKIP_QUERY is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (0) + (0) ; if( temp > LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) ) { LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = LocalCloneWise_EXPL_MATRIX(mat,i-0,j-1,MATCH) + (mat->target_skip_start-10); /* From state SKIP_QUERY to state SKIP_TARGET */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-0,j-1,SKIP_QUERY) + (mat->target_skip_start-10); if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = LocalCloneWise_EXPL_MATRIX(mat,i-0,j-1,SKIP_TARGET) + (0-10); if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-0) == 0 ) { /* From state START to state SKIP_TARGET */ temp = LocalCloneWise_EXPL_SPECIAL(mat,i-0,j-1,START) + mat->target_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; LocalCloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET) = score; /* state SKIP_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (0) + (0) ; if( temp > LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) ) { LocalCloneWise_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state SKIP_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: LocalCloneWise_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalCloneWise *] * */ LocalCloneWise * LocalCloneWise_alloc(void) { LocalCloneWise * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LocalCloneWise *) ckalloc (sizeof(LocalCloneWise))) == NULL) { warn("LocalCloneWise_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_LocalCloneWise(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalCloneWise *] * * Return [UNKN ] Undocumented return value [LocalCloneWise *] * */ LocalCloneWise * free_LocalCloneWise(LocalCloneWise * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LocalCloneWise obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->q is linked in */ /* obj->t is linked in */ /* obj->match is linked in */ /* obj->target_skip_start is linked in */ /* obj->target_skip is linked in */ /* obj->query_skip_start is linked in */ /* obj->query_skip is linked in */ /* obj->spread is linked in */ /* obj->target_special_s is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/localclonewisedp.h0000644000175000001440000005601010670453714017634 0ustar philippusers#ifndef DYNAMITElocalclonewisedpHEADERFILE #define DYNAMITElocalclonewisedpHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "mapstruct.h" struct Wise2_LocalCloneWise { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; MappedCloneSet * q; MappedCloneSet * t; MappedCloneMatch* match; Score target_skip_start; Score target_skip; Score query_skip_start; Score query_skip; int spread; int target_special_s; } ; /* LocalCloneWise defined */ #ifndef DYNAMITE_DEFINED_LocalCloneWise typedef struct Wise2_LocalCloneWise Wise2_LocalCloneWise; #define LocalCloneWise Wise2_LocalCloneWise #define DYNAMITE_DEFINED_LocalCloneWise #endif #ifdef PTHREAD struct thread_pool_holder_LocalCloneWise { MappedCloneSet * q; /* Static query data: never free'd */ MappedCloneSet * t; /* Static target data: never free'd */ MappedCloneMatch* match; Score target_skip_start; Score target_skip; Score query_skip_start; Score query_skip; int spread; int target_special_s; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_LocalCloneWise_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(LocalCloneWise*,int,int,int); int (*access_special)(LocalCloneWise*,int,int,int); } ; /* LocalCloneWise_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_LocalCloneWise_access_func_holder typedef struct Wise2_LocalCloneWise_access_func_holder Wise2_LocalCloneWise_access_func_holder; #define LocalCloneWise_access_func_holder Wise2_LocalCloneWise_access_func_holder #define DYNAMITE_DEFINED_LocalCloneWise_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_LocalCloneWise(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_LocalCloneWise(LocalCloneWise * mat); #define PackAln_read_Shatter_LocalCloneWise Wise2_PackAln_read_Shatter_LocalCloneWise /* Function: calculate_shatter_LocalCloneWise(mat,dpenv) * * Descrip: This function calculates the LocalCloneWise matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [LocalCloneWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_LocalCloneWise(LocalCloneWise * mat,DPEnvelope * dpenv); #define calculate_shatter_LocalCloneWise Wise2_calculate_shatter_LocalCloneWise /* Function: search_LocalCloneWise(dbsi,out,q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function makes a database search of LocalCloneWise * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: t [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: match [UNKN ] Undocumented argument [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Undocumented argument [Score] * Arg: target_skip [UNKN ] Undocumented argument [Score] * Arg: query_skip_start [UNKN ] Undocumented argument [Score] * Arg: query_skip [UNKN ] Undocumented argument [Score] * Arg: spread [UNKN ] Undocumented argument [int] * Arg: target_special_s [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_LocalCloneWise(DBSearchImpl * dbsi,Hscore * out,MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s); #define search_LocalCloneWise Wise2_search_LocalCloneWise /* Function: serial_search_LocalCloneWise(out,q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function makes a database search of LocalCloneWise * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: t [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: match [UNKN ] Undocumented argument [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Undocumented argument [Score] * Arg: target_skip [UNKN ] Undocumented argument [Score] * Arg: query_skip_start [UNKN ] Undocumented argument [Score] * Arg: query_skip [UNKN ] Undocumented argument [Score] * Arg: spread [UNKN ] Undocumented argument [int] * Arg: target_special_s [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_LocalCloneWise(Hscore * out,MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s); #define serial_search_LocalCloneWise Wise2_serial_search_LocalCloneWise /* Function: PackAln_bestmemory_LocalCloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_LocalCloneWise * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_LocalCloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_LocalCloneWise Wise2_PackAln_bestmemory_LocalCloneWise /* Function: allocate_Expl_LocalCloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s,dpri) * * Descrip: This function allocates the LocalCloneWise structure * and the basematrix area for explicit memory implementations * It calls /allocate_LocalCloneWise_only * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [LocalCloneWise *] * */ LocalCloneWise * Wise2_allocate_Expl_LocalCloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s,DPRunImpl * dpri); #define allocate_Expl_LocalCloneWise Wise2_allocate_Expl_LocalCloneWise /* Function: recalculate_PackAln_LocalCloneWise(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by LocalCloneWise * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * */ void Wise2_recalculate_PackAln_LocalCloneWise(PackAln * pal,LocalCloneWise * mat); #define recalculate_PackAln_LocalCloneWise Wise2_recalculate_PackAln_LocalCloneWise /* Function: allocate_Small_LocalCloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function allocates the LocalCloneWise structure * and the basematrix area for a small memory implementations * It calls /allocate_LocalCloneWise_only * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [LocalCloneWise *] * */ LocalCloneWise * Wise2_allocate_Small_LocalCloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s); #define allocate_Small_LocalCloneWise Wise2_allocate_Small_LocalCloneWise /* Function: PackAln_calculate_Small_LocalCloneWise(mat,dpenv) * * Descrip: This function calculates an alignment for LocalCloneWise structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_LocalCloneWise * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_LocalCloneWise * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_LocalCloneWise(LocalCloneWise * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_LocalCloneWise Wise2_PackAln_calculate_Small_LocalCloneWise /* Function: AlnRangeSet_calculate_Small_LocalCloneWise(mat) * * Descrip: This function calculates an alignment for LocalCloneWise structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_LocalCloneWise * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_LocalCloneWise * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_LocalCloneWise * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_LocalCloneWise(LocalCloneWise * mat); #define AlnRangeSet_calculate_Small_LocalCloneWise Wise2_AlnRangeSet_calculate_Small_LocalCloneWise /* Function: AlnRangeSet_from_LocalCloneWise(mat) * * Descrip: This function reads off a start/end structure * for LocalCloneWise structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_LocalCloneWise * If you have not calculated the matrix use * /AlnRange_calculate_Small_LocalCloneWise * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_LocalCloneWise(LocalCloneWise * mat); #define AlnRangeSet_from_LocalCloneWise Wise2_AlnRangeSet_from_LocalCloneWise /* Function: convert_PackAln_to_AlnBlock_LocalCloneWise(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_LocalCloneWise(PackAln * pal); #define convert_PackAln_to_AlnBlock_LocalCloneWise Wise2_convert_PackAln_to_AlnBlock_LocalCloneWise /* Function: PackAln_read_Expl_LocalCloneWise(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_LocalCloneWise(LocalCloneWise * mat); #define PackAln_read_Expl_LocalCloneWise Wise2_PackAln_read_Expl_LocalCloneWise /* Function: PackAln_read_generic_LocalCloneWise(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalCloneWise *] * Arg: h [UNKN ] Undocumented argument [LocalCloneWise_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_LocalCloneWise(LocalCloneWise * mat,LocalCloneWise_access_func_holder h); #define PackAln_read_generic_LocalCloneWise Wise2_PackAln_read_generic_LocalCloneWise /* Function: calculate_LocalCloneWise(mat) * * Descrip: This function calculates the LocalCloneWise matrix when in explicit mode * To allocate the matrix use /allocate_Expl_LocalCloneWise * * * Arg: mat [UNKN ] LocalCloneWise which contains explicit basematrix memory [LocalCloneWise *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_LocalCloneWise(LocalCloneWise * mat); #define calculate_LocalCloneWise Wise2_calculate_LocalCloneWise /* Function: calculate_dpenv_LocalCloneWise(mat,dpenv) * * Descrip: This function calculates the LocalCloneWise matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] LocalCloneWise which contains explicit basematrix memory [LocalCloneWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_LocalCloneWise(LocalCloneWise * mat,DPEnvelope * dpenv); #define calculate_dpenv_LocalCloneWise Wise2_calculate_dpenv_LocalCloneWise /* Function: LocalCloneWise_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalCloneWise *] * */ LocalCloneWise * Wise2_LocalCloneWise_alloc(void); #define LocalCloneWise_alloc Wise2_LocalCloneWise_alloc /* Function: free_LocalCloneWise(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalCloneWise *] * * Return [UNKN ] Undocumented return value [LocalCloneWise *] * */ LocalCloneWise * Wise2_free_LocalCloneWise(LocalCloneWise * obj); #define free_LocalCloneWise Wise2_free_LocalCloneWise /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_LocalCloneWise_shatter_access_main(LocalCloneWise * mat,int i,int j,int state); #define LocalCloneWise_shatter_access_main Wise2_LocalCloneWise_shatter_access_main int Wise2_LocalCloneWise_shatter_access_special(LocalCloneWise * mat,int i,int j,int state); #define LocalCloneWise_shatter_access_special Wise2_LocalCloneWise_shatter_access_special void * Wise2_thread_loop_LocalCloneWise(void * ptr); #define thread_loop_LocalCloneWise Wise2_thread_loop_LocalCloneWise int Wise2_score_only_LocalCloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s); #define score_only_LocalCloneWise Wise2_score_only_LocalCloneWise LocalCloneWise * Wise2_allocate_LocalCloneWise_only(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s); #define allocate_LocalCloneWise_only Wise2_allocate_LocalCloneWise_only void Wise2_init_LocalCloneWise(LocalCloneWise * mat); #define init_LocalCloneWise Wise2_init_LocalCloneWise AlnRange * Wise2_AlnRange_build_LocalCloneWise(LocalCloneWise * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_LocalCloneWise Wise2_AlnRange_build_LocalCloneWise boolean Wise2_read_hidden_LocalCloneWise(LocalCloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_LocalCloneWise Wise2_read_hidden_LocalCloneWise int Wise2_max_hidden_LocalCloneWise(LocalCloneWise * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_LocalCloneWise Wise2_max_hidden_LocalCloneWise boolean Wise2_read_special_strip_LocalCloneWise(LocalCloneWise * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_LocalCloneWise Wise2_read_special_strip_LocalCloneWise int Wise2_max_special_strip_LocalCloneWise(LocalCloneWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_LocalCloneWise Wise2_max_special_strip_LocalCloneWise int Wise2_max_matrix_to_special_LocalCloneWise(LocalCloneWise * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_LocalCloneWise Wise2_max_matrix_to_special_LocalCloneWise void Wise2_calculate_hidden_LocalCloneWise(LocalCloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_LocalCloneWise Wise2_calculate_hidden_LocalCloneWise void Wise2_init_hidden_LocalCloneWise(LocalCloneWise * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_LocalCloneWise Wise2_init_hidden_LocalCloneWise boolean Wise2_full_dc_LocalCloneWise(LocalCloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_LocalCloneWise Wise2_full_dc_LocalCloneWise boolean Wise2_do_dc_single_pass_LocalCloneWise(LocalCloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_LocalCloneWise Wise2_do_dc_single_pass_LocalCloneWise void Wise2_push_dc_at_merge_LocalCloneWise(LocalCloneWise * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_LocalCloneWise Wise2_push_dc_at_merge_LocalCloneWise void Wise2_follow_on_dc_LocalCloneWise(LocalCloneWise * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_LocalCloneWise Wise2_follow_on_dc_LocalCloneWise void Wise2_run_up_dc_LocalCloneWise(LocalCloneWise * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_LocalCloneWise Wise2_run_up_dc_LocalCloneWise void Wise2_init_dc_LocalCloneWise(LocalCloneWise * mat); #define init_dc_LocalCloneWise Wise2_init_dc_LocalCloneWise int Wise2_start_end_find_end_LocalCloneWise(LocalCloneWise * mat,int * endj); #define start_end_find_end_LocalCloneWise Wise2_start_end_find_end_LocalCloneWise boolean Wise2_dc_optimised_start_end_calc_LocalCloneWise(LocalCloneWise *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_LocalCloneWise Wise2_dc_optimised_start_end_calc_LocalCloneWise void Wise2_init_start_end_linear_LocalCloneWise(LocalCloneWise * mat); #define init_start_end_linear_LocalCloneWise Wise2_init_start_end_linear_LocalCloneWise AlnConvertSet * Wise2_AlnConvertSet_LocalCloneWise(void); #define AlnConvertSet_LocalCloneWise Wise2_AlnConvertSet_LocalCloneWise int Wise2_LocalCloneWise_explicit_access_main(LocalCloneWise * mat,int i,int j,int state); #define LocalCloneWise_explicit_access_main Wise2_LocalCloneWise_explicit_access_main int Wise2_LocalCloneWise_explicit_access_special(LocalCloneWise * mat,int i,int j,int state); #define LocalCloneWise_explicit_access_special Wise2_LocalCloneWise_explicit_access_special int Wise2_find_end_LocalCloneWise(LocalCloneWise * mat,int * ri,int * rj,int * state,boolean * isspecial,LocalCloneWise_access_func_holder h); #define find_end_LocalCloneWise Wise2_find_end_LocalCloneWise void Wise2_LocalCloneWise_debug_show_matrix(LocalCloneWise * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define LocalCloneWise_debug_show_matrix Wise2_LocalCloneWise_debug_show_matrix int Wise2_max_calc_LocalCloneWise(LocalCloneWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LocalCloneWise_access_func_holder h); #define max_calc_LocalCloneWise Wise2_max_calc_LocalCloneWise int Wise2_max_calc_special_LocalCloneWise(LocalCloneWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LocalCloneWise_access_func_holder h); #define max_calc_special_LocalCloneWise Wise2_max_calc_special_LocalCloneWise #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/pwmdna.c0000644000175000001440000007175110670453715015600 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "pwmdna.h" /* Function: max_prob_pwmDNA(in) * * Descrip: maximum prob of pwmDNA * * * Arg: in [UNKN ] Undocumented argument [pwmDNA *] * * Return [UNKN ] Undocumented return value [double] * */ # line 64 "pwmdna.dy" double max_prob_pwmDNA(pwmDNA * in) { int i,k; double temp_max; double score = 0.0; for(i=0;ilen;i++) { temp_max = in->pos[i]->emit[0]; for(k=1;k<4;k++) { if( temp_max < in->pos[i]->emit[k] ) { temp_max = in->pos[i]->emit[k]; } } score *= temp_max; } return score; } /* Function: min_prob_pwmDNA(in) * * Descrip: minimum prob of pwmDNA * * * Arg: in [UNKN ] Undocumented argument [pwmDNA *] * * Return [UNKN ] Undocumented return value [double] * */ # line 87 "pwmdna.dy" double min_prob_pwmDNA(pwmDNA * in) { int i,k; double temp_min; double score = 0.0; for(i=0;ilen;i++) { temp_min = in->pos[i]->emit[0]; for(k=1;k<4;k++) { if( temp_min > in->pos[i]->emit[k] ) { temp_min = in->pos[i]->emit[k]; } } score *= temp_min; } return score; } /* Function: circular_permuted_pwmDNA(in,rotate_number) * * Descrip: Provides a rotated pwm for randomisation * * * Arg: in [UNKN ] Undocumented argument [pwmDNA *] * Arg: rotate_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ # line 109 "pwmdna.dy" pwmDNA * circular_permuted_pwmDNA(pwmDNA * in,int rotate_number) { int i; pwmDNA * out; pwmColProb * col; int j; int pos; assert(in != NULL); out = pwmDNA_alloc_len(in->len); for(i=0;ilen;i++) { pos = (i+rotate_number) % in->len; col = pwmColProb_alloc(); add_pwmDNA(out,col); for(j=0;j<5;j++) { col->emit[j] = in->pos[pos]->emit[j]; } } return out; } /* Function: score_pwmDNAScore_Sequence(pds,s,pos) * * Descrip: This gives back a Score from a particular sequence and * position * * * Arg: pds [UNKN ] Undocumented argument [pwmDNAScore *] * Arg: s [UNKN ] Undocumented argument [Sequence *] * Arg: pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Score] * */ # line 137 "pwmdna.dy" Score score_pwmDNAScore_Sequence(pwmDNAScore * pds,Sequence * s,int pos) { int score; if( pds->len + pos > s->len ) { warn("For sequence %s, position %d is unable to be matched to pwmDNA of length %d",s->name,pos,pds->len); } score = score_pwmDNAScore_string(pds,s->seq+pos); fprintf(stderr,"Making score %d for %d\n",score,pos); return score; } /* Function: score_pwmDNAScore_string(pds,str) * * Descrip: This gives back a Score from a particular string * * * Arg: pds [UNKN ] Undocumented argument [pwmDNAScore *] * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Score] * */ # line 153 "pwmdna.dy" Score score_pwmDNAScore_string(pwmDNAScore * pds,char * str) { int i; Score total = 0.0; /* if( strlen(str) < pds->len ) { warn("String [%s] is shorter than the length of the pds. Should not be using it!",str); return NEGI; } */ for(i=0;ilen;i++) total += pds->pos[i]->emit[base_from_char(str[i])]; /* printf("Score %c%c%c to score with %s [%d]\n",str[0],str[1],str[2],pds->ref_align->seq[0]->seq,total);*/ return total; } /* Function: prob_pwmDNA_string(pds,str) * * Descrip: This gives back a Probability from a particular string * * * Arg: pds [UNKN ] Undocumented argument [pwmDNA *] * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Probability] * */ # line 176 "pwmdna.dy" Probability prob_pwmDNA_string(pwmDNA * pds,char * str) { int i; Probability total = 1.0; for(i=0;ilen;i++) { if( str[i] == '\0' ) { return 0.0; } else { total *= pds->pos[i]->emit[base_from_char(str[i])]; /* fprintf(stdout,"As %d, total %.6f with %c\n",i,total,str[i]);*/ } } return total; } /* Function: fold_randommodel_pwmDNA(pd,rmd) * * Descrip: This folds in a randommodel into pwmDNA * * * Arg: pd [UNKN ] Undocumented argument [pwmDNA *] * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * */ # line 197 "pwmdna.dy" void fold_randommodel_pwmDNA(pwmDNA * pd,RandomModelDNA * rmd) { int i; int j; assert(pd); assert(rmd); for(i=0;ilen;i++) for(j=0;j<5;j++) if( rmd->base[j] < 0.00000000000000001 ) { warn("Zero base %d, skipping",j); } else { pd->pos[i]->emit[j] /= rmd->base[j]; } } /* Function: pwmDNA_from_SeqAlign(sa,simple_pseudocount) * * Descrip: This function makes a single pwmDNA from * a SeqAlign * * FIXME: This DOES NOT handle ambiguity codes well * * * Arg: sa [UNKN ] Undocumented argument [SeqAlign *] * Arg: simple_pseudocount [UNKN ] Undocumented argument [double] * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ # line 220 "pwmdna.dy" pwmDNA * pwmDNA_from_SeqAlign(SeqAlign * sa,double simple_pseudocount) { pwmDNA * out; pwmColProb * col; ColumnCount * cc; int i; assert(sa); out = pwmDNA_alloc_std(); out->ref_align = hard_link_SeqAlign(sa); for(i=0;iseq[0]->len;i++) { cc = ColumnCount_from_SeqAlign(sa,i); col = pwmColProb_from_ColumnCount(cc,simple_pseudocount); add_pwmDNA(out,col); free_ColumnCount(cc); } return out; } /* Function: show_pwmDNA_col(pd,ofp) * * Descrip: Shows a columns along the page * * * Arg: pd [UNKN ] Undocumented argument [pwmDNA *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 246 "pwmdna.dy" void show_pwmDNA_col(pwmDNA * pd,FILE * ofp) { char base[] = "ATGC"; int i; int j; for(j=0;j<4;j++) { fprintf(ofp," %c ",base[j]); for(i=0;ilen;i++) { fprintf(ofp," %.4f ",pd->pos[i]->emit[base_from_char(base[j])]); } fprintf(ofp,"\n"); } } /* Function: pwmColProb_from_ColumnCount(cc,simple_pseudocount) * * Descrip: This function makes a single pwmColProb from * a ColumnCount, applying a simple pseudocount * method * * FIXME: This DOES NOT handle ambiguity codes well * * * Arg: cc [UNKN ] Undocumented argument [ColumnCount *] * Arg: simple_pseudocount [UNKN ] Undocumented argument [double] * * Return [UNKN ] Undocumented return value [pwmColProb *] * */ # line 271 "pwmdna.dy" pwmColProb * pwmColProb_from_ColumnCount(ColumnCount * cc,double simple_pseudocount) { pwmColProb * out; double total; char base[] = "ATGC"; int i; out = pwmColProb_alloc(); for(i=0,total = 0.0;i<4;i++) total += (cc->count[base[i]-'A'] + simple_pseudocount); for(i=0;i<4;i++) out->emit[base_from_char(base[i])] = (cc->count[base[i]-'A'] + simple_pseudocount) / total; out->emit[4] = 1.0; return out; } /* Function: pwmDNAScore_from_pwmDNA_RandomModelDNA(pwm,rmd) * * Descrip: This function makes score represention of a * position weight matrix from a probability, * with a random model folded in on-the-fly * * * Arg: pwm [UNKN ] Undocumented argument [pwmDNA *] * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ # line 294 "pwmdna.dy" pwmDNAScore * pwmDNAScore_from_pwmDNA_RandomModelDNA(pwmDNA * pwm,RandomModelDNA * rmd) { int i; pwmDNAScore * out; out = pwmDNAScore_alloc_std(); out->ref_align = hard_link_SeqAlign(pwm->ref_align); for(i=0;ilen;i++) { add_pwmDNAScore(out,pwmColScore_from_pwmColProb_rmd(pwm->pos[i],rmd)); } return out; } /* Function: pwmDNAScore_from_pwmDNA(pwm) * * Descrip: This function makes score represention of a * position weight matrix from a probability * * * Arg: pwm [UNKN ] Undocumented argument [pwmDNA *] * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ # line 312 "pwmdna.dy" pwmDNAScore * pwmDNAScore_from_pwmDNA(pwmDNA * pwm) { int i; pwmDNAScore * out; out = pwmDNAScore_alloc_std(); out->ref_align = hard_link_SeqAlign(pwm->ref_align); for(i=0;ilen;i++) { add_pwmDNAScore(out,pwmColScore_from_pwmColProb(pwm->pos[i])); } return out; } /* Function: pwmColScore_from_pwmColProb(p) * * Descrip: This function makes a score representation of a * position weight matrix from a column representation * * * Arg: p [UNKN ] Undocumented argument [pwmColProb *] * * Return [UNKN ] Undocumented return value [pwmColScore *] * */ # line 332 "pwmdna.dy" pwmColScore * pwmColScore_from_pwmColProb(pwmColProb * p) { pwmColScore * out; out = pwmColScore_alloc(); Probability2Score_move(p->emit,out->emit,5); return out; } /* Function: pwmColScore_from_pwmColProb_rmd(p,rmd) * * Descrip: This function makes a score representation of a * position weight matrix from a column representation, * with a RandomModel factored in * * * Arg: p [UNKN ] Undocumented argument [pwmColProb *] * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [pwmColScore *] * */ # line 348 "pwmdna.dy" pwmColScore * pwmColScore_from_pwmColProb_rmd(pwmColProb * p,RandomModelDNA * rmd) { pwmColScore * out; int i; out = pwmColScore_alloc(); for(i=0;i<5;i++) out->emit[i] = Probability2Score(p->emit[i] / rmd->base[i]); return out; } # line 393 "pwmdna.c" /* Function: hard_link_pwmColScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [pwmColScore *] * * Return [UNKN ] Undocumented return value [pwmColScore *] * */ pwmColScore * hard_link_pwmColScore(pwmColScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a pwmColScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: pwmColScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [pwmColScore *] * */ pwmColScore * pwmColScore_alloc(void) { pwmColScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(pwmColScore *) ckalloc (sizeof(pwmColScore))) == NULL) { warn("pwmColScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* emit[5] is an array: no default possible */ return out; } /* Function: free_pwmColScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [pwmColScore *] * * Return [UNKN ] Undocumented return value [pwmColScore *] * */ pwmColScore * free_pwmColScore(pwmColScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a pwmColScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_pwmColProb(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [pwmColProb *] * * Return [UNKN ] Undocumented return value [pwmColProb *] * */ pwmColProb * hard_link_pwmColProb(pwmColProb * obj) { if( obj == NULL ) { warn("Trying to hard link to a pwmColProb object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: pwmColProb_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [pwmColProb *] * */ pwmColProb * pwmColProb_alloc(void) { pwmColProb * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(pwmColProb *) ckalloc (sizeof(pwmColProb))) == NULL) { warn("pwmColProb_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* emit[5] is an array: no default possible */ return out; } /* Function: free_pwmColProb(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [pwmColProb *] * * Return [UNKN ] Undocumented return value [pwmColProb *] * */ pwmColProb * free_pwmColProb(pwmColProb * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a pwmColProb obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_pwmDNA(list,i,j) * * Descrip: swap function: an internal for qsort_pwmDNA * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [pwmColProb **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_pwmDNA(pwmColProb ** list,int i,int j) { pwmColProb * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_pwmDNA(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_pwmDNA which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [pwmColProb **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_pwmDNA(pwmColProb ** list,int left,int right,int (*comp)(pwmColProb * ,pwmColProb * )) { int i,last; if( left >= right ) return; swap_pwmDNA(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_pwmDNA (list,++last,i); } swap_pwmDNA (list,left,last); qsort_pwmDNA(list,left,last-1,comp); qsort_pwmDNA(list,last+1,right,comp); } /* Function: sort_pwmDNA(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_pwmDNA * * * Arg: obj [UNKN ] Object containing list [pwmDNA *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_pwmDNA(pwmDNA * obj,int (*comp)(pwmColProb *, pwmColProb *)) { qsort_pwmDNA(obj->pos,0,obj->len-1,comp); return; } /* Function: expand_pwmDNA(obj,len) * * Descrip: Really an internal function for add_pwmDNA * * * Arg: obj [UNKN ] Object which contains the list [pwmDNA *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_pwmDNA(pwmDNA * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_pwmDNA called with no need"); return TRUE; } if( (obj->pos = (pwmColProb ** ) ckrealloc (obj->pos,sizeof(pwmColProb *)*len)) == NULL) { warn("ckrealloc failed for expand_pwmDNA, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_pwmDNA(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [pwmDNA *] * Arg: add [OWNER] Object to add to the list [pwmColProb *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_pwmDNA(pwmDNA * obj,pwmColProb * add) { if( obj->len >= obj->maxlen) { if( expand_pwmDNA(obj,obj->len + pwmDNALISTLENGTH) == FALSE) return FALSE; } obj->pos[obj->len++]=add; return TRUE; } /* Function: flush_pwmDNA(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [pwmDNA *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_pwmDNA(pwmDNA * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->pos[i] != NULL) { free_pwmColProb(obj->pos[i]); obj->pos[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: pwmDNA_alloc_std(void) * * Descrip: Equivalent to pwmDNA_alloc_len(pwmDNALISTLENGTH) * * * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ pwmDNA * pwmDNA_alloc_std(void) { return pwmDNA_alloc_len(pwmDNALISTLENGTH); } /* Function: pwmDNA_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ pwmDNA * pwmDNA_alloc_len(int len) { pwmDNA * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = pwmDNA_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->pos = (pwmColProb ** ) ckcalloc (len,sizeof(pwmColProb *))) == NULL) { warn("Warning, ckcalloc failed in pwmDNA_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_pwmDNA(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [pwmDNA *] * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ pwmDNA * hard_link_pwmDNA(pwmDNA * obj) { if( obj == NULL ) { warn("Trying to hard link to a pwmDNA object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: pwmDNA_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ pwmDNA * pwmDNA_alloc(void) { pwmDNA * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(pwmDNA *) ckalloc (sizeof(pwmDNA))) == NULL) { warn("pwmDNA_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->pos = NULL; out->len = out->maxlen = 0; out->ref_align = NULL; return out; } /* Function: free_pwmDNA(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [pwmDNA *] * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ pwmDNA * free_pwmDNA(pwmDNA * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a pwmDNA obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->pos != NULL) { for(i=0;ilen;i++) { if( obj->pos[i] != NULL) free_pwmColProb(obj->pos[i]); } ckfree(obj->pos); } if( obj->ref_align != NULL) free_SeqAlign(obj->ref_align); ckfree(obj); return NULL; } /* Function: swap_pwmDNAScore(list,i,j) * * Descrip: swap function: an internal for qsort_pwmDNAScore * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [pwmColScore **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_pwmDNAScore(pwmColScore ** list,int i,int j) { pwmColScore * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_pwmDNAScore(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_pwmDNAScore which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [pwmColScore **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_pwmDNAScore(pwmColScore ** list,int left,int right,int (*comp)(pwmColScore * ,pwmColScore * )) { int i,last; if( left >= right ) return; swap_pwmDNAScore(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_pwmDNAScore (list,++last,i); } swap_pwmDNAScore (list,left,last); qsort_pwmDNAScore(list,left,last-1,comp); qsort_pwmDNAScore(list,last+1,right,comp); } /* Function: sort_pwmDNAScore(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_pwmDNAScore * * * Arg: obj [UNKN ] Object containing list [pwmDNAScore *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_pwmDNAScore(pwmDNAScore * obj,int (*comp)(pwmColScore *, pwmColScore *)) { qsort_pwmDNAScore(obj->pos,0,obj->len-1,comp); return; } /* Function: expand_pwmDNAScore(obj,len) * * Descrip: Really an internal function for add_pwmDNAScore * * * Arg: obj [UNKN ] Object which contains the list [pwmDNAScore *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_pwmDNAScore(pwmDNAScore * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_pwmDNAScore called with no need"); return TRUE; } if( (obj->pos = (pwmColScore ** ) ckrealloc (obj->pos,sizeof(pwmColScore *)*len)) == NULL) { warn("ckrealloc failed for expand_pwmDNAScore, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_pwmDNAScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [pwmDNAScore *] * Arg: add [OWNER] Object to add to the list [pwmColScore *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_pwmDNAScore(pwmDNAScore * obj,pwmColScore * add) { if( obj->len >= obj->maxlen) { if( expand_pwmDNAScore(obj,obj->len + pwmDNAScoreLISTLENGTH) == FALSE) return FALSE; } obj->pos[obj->len++]=add; return TRUE; } /* Function: flush_pwmDNAScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [pwmDNAScore *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_pwmDNAScore(pwmDNAScore * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->pos[i] != NULL) { free_pwmColScore(obj->pos[i]); obj->pos[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: pwmDNAScore_alloc_std(void) * * Descrip: Equivalent to pwmDNAScore_alloc_len(pwmDNAScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ pwmDNAScore * pwmDNAScore_alloc_std(void) { return pwmDNAScore_alloc_len(pwmDNAScoreLISTLENGTH); } /* Function: pwmDNAScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ pwmDNAScore * pwmDNAScore_alloc_len(int len) { pwmDNAScore * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = pwmDNAScore_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->pos = (pwmColScore ** ) ckcalloc (len,sizeof(pwmColScore *))) == NULL) { warn("Warning, ckcalloc failed in pwmDNAScore_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_pwmDNAScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [pwmDNAScore *] * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ pwmDNAScore * hard_link_pwmDNAScore(pwmDNAScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a pwmDNAScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: pwmDNAScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ pwmDNAScore * pwmDNAScore_alloc(void) { pwmDNAScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(pwmDNAScore *) ckalloc (sizeof(pwmDNAScore))) == NULL) { warn("pwmDNAScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->pos = NULL; out->len = out->maxlen = 0; out->ref_align = NULL; return out; } /* Function: free_pwmDNAScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [pwmDNAScore *] * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ pwmDNAScore * free_pwmDNAScore(pwmDNAScore * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a pwmDNAScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->pos != NULL) { for(i=0;ilen;i++) { if( obj->pos[i] != NULL) free_pwmColScore(obj->pos[i]); } ckfree(obj->pos); } if( obj->ref_align != NULL) free_SeqAlign(obj->ref_align); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/pwmdna.h0000644000175000001440000004107710670453715015603 0ustar philippusers#ifndef DYNAMITEpwmdnaHEADERFILE #define DYNAMITEpwmdnaHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "seqalign.h" #include "randommodel.h" #include "probability.h" #define pwmDNALISTLENGTH 64 #define pwmDNAScoreLISTLENGTH 64 /* Object pwmColScore * * Descrip: Actual Scores for a * position in a Score * representation of a PWM * * */ struct Wise2_pwmColScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score emit[5]; } ; /* pwmColScore defined */ #ifndef DYNAMITE_DEFINED_pwmColScore typedef struct Wise2_pwmColScore Wise2_pwmColScore; #define pwmColScore Wise2_pwmColScore #define DYNAMITE_DEFINED_pwmColScore #endif /* Object pwmColProb * * Descrip: Actual probabilities for * a position in a PWM * * */ struct Wise2_pwmColProb { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability emit[5]; } ; /* pwmColProb defined */ #ifndef DYNAMITE_DEFINED_pwmColProb typedef struct Wise2_pwmColProb Wise2_pwmColProb; #define pwmColProb Wise2_pwmColProb #define DYNAMITE_DEFINED_pwmColProb #endif /* Object pwmDNA * * Descrip: This structure holds a position * weight matrix as probabilities. * * Generally you want to use the Score * based system for the actual scoring, * but this for manipulation of the probabilities * * You can build this data structure from a * simple sequence alignment plus a pseudocount * * */ struct Wise2_pwmDNA { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif pwmColProb ** pos; int len;/* len for above pos */ int maxlen; /* maxlen for above pos */ SeqAlign * ref_align; } ; /* pwmDNA defined */ #ifndef DYNAMITE_DEFINED_pwmDNA typedef struct Wise2_pwmDNA Wise2_pwmDNA; #define pwmDNA Wise2_pwmDNA #define DYNAMITE_DEFINED_pwmDNA #endif /* Object pwmDNAScore * * Descrip: This structure holds a position * weight matrix as Scores, generally * log-odded to a random model * * This is the structure used for scoring. * You make it from a pwmDNA * * */ struct Wise2_pwmDNAScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif pwmColScore ** pos; int len;/* len for above pos */ int maxlen; /* maxlen for above pos */ SeqAlign * ref_align; } ; /* pwmDNAScore defined */ #ifndef DYNAMITE_DEFINED_pwmDNAScore typedef struct Wise2_pwmDNAScore Wise2_pwmDNAScore; #define pwmDNAScore Wise2_pwmDNAScore #define DYNAMITE_DEFINED_pwmDNAScore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: max_prob_pwmDNA(in) * * Descrip: maximum prob of pwmDNA * * * Arg: in [UNKN ] Undocumented argument [pwmDNA *] * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_max_prob_pwmDNA(pwmDNA * in); #define max_prob_pwmDNA Wise2_max_prob_pwmDNA /* Function: min_prob_pwmDNA(in) * * Descrip: minimum prob of pwmDNA * * * Arg: in [UNKN ] Undocumented argument [pwmDNA *] * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_min_prob_pwmDNA(pwmDNA * in); #define min_prob_pwmDNA Wise2_min_prob_pwmDNA /* Function: circular_permuted_pwmDNA(in,rotate_number) * * Descrip: Provides a rotated pwm for randomisation * * * Arg: in [UNKN ] Undocumented argument [pwmDNA *] * Arg: rotate_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ pwmDNA * Wise2_circular_permuted_pwmDNA(pwmDNA * in,int rotate_number); #define circular_permuted_pwmDNA Wise2_circular_permuted_pwmDNA /* Function: score_pwmDNAScore_Sequence(pds,s,pos) * * Descrip: This gives back a Score from a particular sequence and * position * * * Arg: pds [UNKN ] Undocumented argument [pwmDNAScore *] * Arg: s [UNKN ] Undocumented argument [Sequence *] * Arg: pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Score] * */ Score Wise2_score_pwmDNAScore_Sequence(pwmDNAScore * pds,Sequence * s,int pos); #define score_pwmDNAScore_Sequence Wise2_score_pwmDNAScore_Sequence /* Function: score_pwmDNAScore_string(pds,str) * * Descrip: This gives back a Score from a particular string * * * Arg: pds [UNKN ] Undocumented argument [pwmDNAScore *] * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Score] * */ Score Wise2_score_pwmDNAScore_string(pwmDNAScore * pds,char * str); #define score_pwmDNAScore_string Wise2_score_pwmDNAScore_string /* Function: prob_pwmDNA_string(pds,str) * * Descrip: This gives back a Probability from a particular string * * * Arg: pds [UNKN ] Undocumented argument [pwmDNA *] * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Probability] * */ Probability Wise2_prob_pwmDNA_string(pwmDNA * pds,char * str); #define prob_pwmDNA_string Wise2_prob_pwmDNA_string /* Function: fold_randommodel_pwmDNA(pd,rmd) * * Descrip: This folds in a randommodel into pwmDNA * * * Arg: pd [UNKN ] Undocumented argument [pwmDNA *] * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * */ void Wise2_fold_randommodel_pwmDNA(pwmDNA * pd,RandomModelDNA * rmd); #define fold_randommodel_pwmDNA Wise2_fold_randommodel_pwmDNA /* Function: pwmDNA_from_SeqAlign(sa,simple_pseudocount) * * Descrip: This function makes a single pwmDNA from * a SeqAlign * * FIXME: This DOES NOT handle ambiguity codes well * * * Arg: sa [UNKN ] Undocumented argument [SeqAlign *] * Arg: simple_pseudocount [UNKN ] Undocumented argument [double] * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ pwmDNA * Wise2_pwmDNA_from_SeqAlign(SeqAlign * sa,double simple_pseudocount); #define pwmDNA_from_SeqAlign Wise2_pwmDNA_from_SeqAlign /* Function: show_pwmDNA_col(pd,ofp) * * Descrip: Shows a columns along the page * * * Arg: pd [UNKN ] Undocumented argument [pwmDNA *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_pwmDNA_col(pwmDNA * pd,FILE * ofp); #define show_pwmDNA_col Wise2_show_pwmDNA_col /* Function: pwmDNAScore_from_pwmDNA_RandomModelDNA(pwm,rmd) * * Descrip: This function makes score represention of a * position weight matrix from a probability, * with a random model folded in on-the-fly * * * Arg: pwm [UNKN ] Undocumented argument [pwmDNA *] * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ pwmDNAScore * Wise2_pwmDNAScore_from_pwmDNA_RandomModelDNA(pwmDNA * pwm,RandomModelDNA * rmd); #define pwmDNAScore_from_pwmDNA_RandomModelDNA Wise2_pwmDNAScore_from_pwmDNA_RandomModelDNA /* Function: pwmDNAScore_from_pwmDNA(pwm) * * Descrip: This function makes score represention of a * position weight matrix from a probability * * * Arg: pwm [UNKN ] Undocumented argument [pwmDNA *] * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ pwmDNAScore * Wise2_pwmDNAScore_from_pwmDNA(pwmDNA * pwm); #define pwmDNAScore_from_pwmDNA Wise2_pwmDNAScore_from_pwmDNA /* Function: hard_link_pwmColScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [pwmColScore *] * * Return [UNKN ] Undocumented return value [pwmColScore *] * */ pwmColScore * Wise2_hard_link_pwmColScore(pwmColScore * obj); #define hard_link_pwmColScore Wise2_hard_link_pwmColScore /* Function: pwmColScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [pwmColScore *] * */ pwmColScore * Wise2_pwmColScore_alloc(void); #define pwmColScore_alloc Wise2_pwmColScore_alloc /* Function: free_pwmColScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [pwmColScore *] * * Return [UNKN ] Undocumented return value [pwmColScore *] * */ pwmColScore * Wise2_free_pwmColScore(pwmColScore * obj); #define free_pwmColScore Wise2_free_pwmColScore /* Function: hard_link_pwmColProb(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [pwmColProb *] * * Return [UNKN ] Undocumented return value [pwmColProb *] * */ pwmColProb * Wise2_hard_link_pwmColProb(pwmColProb * obj); #define hard_link_pwmColProb Wise2_hard_link_pwmColProb /* Function: pwmColProb_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [pwmColProb *] * */ pwmColProb * Wise2_pwmColProb_alloc(void); #define pwmColProb_alloc Wise2_pwmColProb_alloc /* Function: free_pwmColProb(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [pwmColProb *] * * Return [UNKN ] Undocumented return value [pwmColProb *] * */ pwmColProb * Wise2_free_pwmColProb(pwmColProb * obj); #define free_pwmColProb Wise2_free_pwmColProb /* Function: add_pwmDNA(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [pwmDNA *] * Arg: add [OWNER] Object to add to the list [pwmColProb *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_pwmDNA(pwmDNA * obj,pwmColProb * add); #define add_pwmDNA Wise2_add_pwmDNA /* Function: flush_pwmDNA(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [pwmDNA *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_pwmDNA(pwmDNA * obj); #define flush_pwmDNA Wise2_flush_pwmDNA /* Function: pwmDNA_alloc_std(void) * * Descrip: Equivalent to pwmDNA_alloc_len(pwmDNALISTLENGTH) * * * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ pwmDNA * Wise2_pwmDNA_alloc_std(void); #define pwmDNA_alloc_std Wise2_pwmDNA_alloc_std /* Function: pwmDNA_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ pwmDNA * Wise2_pwmDNA_alloc_len(int len); #define pwmDNA_alloc_len Wise2_pwmDNA_alloc_len /* Function: hard_link_pwmDNA(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [pwmDNA *] * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ pwmDNA * Wise2_hard_link_pwmDNA(pwmDNA * obj); #define hard_link_pwmDNA Wise2_hard_link_pwmDNA /* Function: pwmDNA_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ pwmDNA * Wise2_pwmDNA_alloc(void); #define pwmDNA_alloc Wise2_pwmDNA_alloc /* Function: free_pwmDNA(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [pwmDNA *] * * Return [UNKN ] Undocumented return value [pwmDNA *] * */ pwmDNA * Wise2_free_pwmDNA(pwmDNA * obj); #define free_pwmDNA Wise2_free_pwmDNA /* Function: add_pwmDNAScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [pwmDNAScore *] * Arg: add [OWNER] Object to add to the list [pwmColScore *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_pwmDNAScore(pwmDNAScore * obj,pwmColScore * add); #define add_pwmDNAScore Wise2_add_pwmDNAScore /* Function: flush_pwmDNAScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [pwmDNAScore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_pwmDNAScore(pwmDNAScore * obj); #define flush_pwmDNAScore Wise2_flush_pwmDNAScore /* Function: pwmDNAScore_alloc_std(void) * * Descrip: Equivalent to pwmDNAScore_alloc_len(pwmDNAScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ pwmDNAScore * Wise2_pwmDNAScore_alloc_std(void); #define pwmDNAScore_alloc_std Wise2_pwmDNAScore_alloc_std /* Function: pwmDNAScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ pwmDNAScore * Wise2_pwmDNAScore_alloc_len(int len); #define pwmDNAScore_alloc_len Wise2_pwmDNAScore_alloc_len /* Function: hard_link_pwmDNAScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [pwmDNAScore *] * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ pwmDNAScore * Wise2_hard_link_pwmDNAScore(pwmDNAScore * obj); #define hard_link_pwmDNAScore Wise2_hard_link_pwmDNAScore /* Function: pwmDNAScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ pwmDNAScore * Wise2_pwmDNAScore_alloc(void); #define pwmDNAScore_alloc Wise2_pwmDNAScore_alloc /* Function: free_pwmDNAScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [pwmDNAScore *] * * Return [UNKN ] Undocumented return value [pwmDNAScore *] * */ pwmDNAScore * Wise2_free_pwmDNAScore(pwmDNAScore * obj); #define free_pwmDNAScore Wise2_free_pwmDNAScore /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ pwmColProb * Wise2_pwmColProb_from_ColumnCount(ColumnCount * cc,double simple_pseudocount); #define pwmColProb_from_ColumnCount Wise2_pwmColProb_from_ColumnCount pwmColScore * Wise2_pwmColScore_from_pwmColProb(pwmColProb * p); #define pwmColScore_from_pwmColProb Wise2_pwmColScore_from_pwmColProb pwmColScore * Wise2_pwmColScore_from_pwmColProb_rmd(pwmColProb * p,RandomModelDNA * rmd); #define pwmColScore_from_pwmColProb_rmd Wise2_pwmColScore_from_pwmColProb_rmd void Wise2_swap_pwmDNA(pwmColProb ** list,int i,int j) ; #define swap_pwmDNA Wise2_swap_pwmDNA void Wise2_qsort_pwmDNA(pwmColProb ** list,int left,int right,int (*comp)(pwmColProb * ,pwmColProb * )); #define qsort_pwmDNA Wise2_qsort_pwmDNA void Wise2_sort_pwmDNA(pwmDNA * obj,int (*comp)(pwmColProb *, pwmColProb *)); #define sort_pwmDNA Wise2_sort_pwmDNA boolean Wise2_expand_pwmDNA(pwmDNA * obj,int len); #define expand_pwmDNA Wise2_expand_pwmDNA void Wise2_swap_pwmDNAScore(pwmColScore ** list,int i,int j) ; #define swap_pwmDNAScore Wise2_swap_pwmDNAScore void Wise2_qsort_pwmDNAScore(pwmColScore ** list,int left,int right,int (*comp)(pwmColScore * ,pwmColScore * )); #define qsort_pwmDNAScore Wise2_qsort_pwmDNAScore void Wise2_sort_pwmDNAScore(pwmDNAScore * obj,int (*comp)(pwmColScore *, pwmColScore *)); #define sort_pwmDNAScore Wise2_sort_pwmDNAScore boolean Wise2_expand_pwmDNAScore(pwmDNAScore * obj,int len); #define expand_pwmDNAScore Wise2_expand_pwmDNAScore #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/genedisplay_api.h0000644000175000001440000000421010670453714017435 0ustar philippusers /* Helper functions in the module * * Wise2_protein2genomic_ascii_display * Wise2_protcdna_ascii_display * /* These functions are not associated with an object */ /* Function: Wise2_protein2genomic_ascii_display(alb,p,gen,ct,name,main,ofp) * * Descrip: shows the alignment in alb between protsequence and protname * with genomic into ofp with pretty formatting * * * Arg: alb logical alignment [Wise2_AlnBlock *] * Arg: p protein sequence [Wise2_Protein *] * Arg: gen genomic dna to do the comparison [Wise2_Genomic *] * Arg: ct codon table for translation [Wise2_CodonTable *] * Arg: name length of name block [int] * Arg: main length of main block [int] * Arg: ofp output file [FILE *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_protein2genomic_ascii_display( Wise2_AlnBlock * alb,Wise2_Protein * p,Wise2_Genomic * gen,Wise2_CodonTable * ct,int name,int main,FILE * ofp); /* Function: Wise2_protcdna_ascii_display(alb,protsequence,protname,protoff,cdna,ct,name,main,mult,ofp) * * Descrip: shows the alignment in alb between protsequence and protname * with cdna into ofp with pretty formatting * * * Arg: alb logical alignment [Wise2_AlnBlock *] * Arg: protsequence protein sequence - either real or an artifical consensus [char *] * Arg: protname name of the protein [char *] * Arg: protoff offset of the alb from the protein [int] * Arg: cdna cdna of the match [Wise2_cDNA *] * Arg: ct codon table for translation [Wise2_CodonTable *] * Arg: name length of name block [int] * Arg: main length of main block [int] * Arg: mult is multi-match [boolean] * Arg: ofp output file [FILE *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_protcdna_ascii_display( Wise2_AlnBlock * alb,char * protsequence,char * protname,int protoff,Wise2_cDNA * cdna,Wise2_CodonTable * ct,int name,int main,boolean mult,FILE * ofp); wise-2.4.1/src/models/genedisplay_api.t0000644000175000001440000000000010670453714017442 0ustar philippuserswise-2.4.1/src/models/seqerror.dy0000644000175000001440000001047307313404547016337 0ustar philippusers %{ #include "wisebase.h" #include "probability.h" #include "aln.h" #include "sequence.h" enum SeqErrorType { SeqErrorInsertion, SeqErrorDeletion, SeqErrorSubstitution }; #define SequenceErrorSetLISTLENGTH 128 %} struct SequenceError int type int start int end char * replaced_bases Probability probability char * inserted_bases char * suspected_deletion %info This holds information about a particular insertion or deletion for one sequence %% struct SequenceErrorSet SequenceError ** error !list %info This holds a set of insertion or deletions for a sequence %% struct ErrorSequence Sequence * seq SequenceErrorSet * ses %info This holds a sequence and what errors have occured in it. %% %{ #include "seqerror.h" %func Makes a sequence error set from standard genewise labels %% SequenceErrorSet * genewise_SequenceErrorSet(AlnSequence * als ) { SequenceErrorSet * out; SequenceError * se; AlnUnit * alu; assert(als); out = SequenceErrorSet_alloc_std(); for(alu=als->start;alu;alu = alu->next ) { if( strcmp(alu->text_label,"SEQUENCE_INSERTION") == 0 ) { se = SequenceError_alloc(); add_SequenceErrorSet(out,se); se->start = alu->start+1; se->end = alu->end; se->type = SeqErrorInsertion; se->inserted_bases = stringalloc("?"); se->replaced_bases = stringalloc("NNN"); } else if ( strcmp(alu->text_label,"SEQUENCE_DELETION") == 0 ) { se = SequenceError_alloc(); se->start = alu->start+1; se->end = alu->end; se->type = SeqErrorDeletion; se->replaced_bases = stringalloc("NNN"); add_SequenceErrorSet(out,se); } } return out; } %func Displays a set of sequence errors in space deliminted format %% void show_SequenceErrorSet(SequenceErrorSet * ses,FILE * ofp) { int i; for(i=0;ilen;i++) { show_SequenceError(ses->error[i],ofp); } } %func Displays sequence error in space deliminted format %% void show_SequenceError(SequenceError * se,FILE * ofp) { fprintf(ofp,"%c %5d %5d %10s (%10s)\n", (se->type == SeqErrorInsertion ? 'I' : (se->type == SeqErrorDeletion ? 'D' : 'S')), se->start,se->end, se->replaced_bases == NULL ? "-none-" : se->replaced_bases, se->type == SeqErrorInsertion ? se->inserted_bases : "-"); } %func Makes an error sequence (DNA) with set substitution and insertion/deletion rates. %% ErrorSequence * make_ErrorSequence(Sequence * seq,Probability subs,Probability insertion,Probability deletion) { ErrorSequence * out; char * seq_buffer; int buf_len; int i,j; double rnd; char c[2]; SequenceError * se; i=j=0; out = ErrorSequence_alloc(); out->ses = SequenceErrorSet_alloc_std(); c[1] = '\0'; buf_len = seq->len *3; seq_buffer = (char*)calloc(buf_len,sizeof(char)); for(i=0;ilen;i++) { if( j >= buf_len ) { warn("run out of temporary buffer in error sequence"); break; } rnd = random_0_to_1(); if( rnd > deletion ) { /* yes this base is here */ rnd = random_0_to_1(); if( rnd < subs ) { rnd = random_0_to_1(); if( rnd < 0.25 ) { c[0] = 'A'; } else if ( rnd < 0.5 ) { c[0] = 'T'; } else if ( rnd < 0.75 ) { c[0] = 'G'; } else { c[0] = 'C'; } se = SequenceError_alloc(); se->type = SeqErrorSubstitution; se->start = j+1; se->end = j+1; se->replaced_bases = stringalloc(c); add_SequenceErrorSet(out->ses,se); seq_buffer[j++] = c[0]; } else { seq_buffer[j++] = seq->seq[i]; } } else { /* there has been a deletion */ se = SequenceError_alloc(); se->type = SeqErrorDeletion; se->start = j+1; se->end = j+1; c[0] = seq_buffer[i]; se->suspected_deletion = stringalloc(c); add_SequenceErrorSet(out->ses,se); } rnd = random_0_to_1(); if( rnd < insertion ) { rnd = random_0_to_1(); if( rnd < 0.25 ) { c[0] = 'A'; } else if ( rnd < 0.5 ) { c[0] = 'T'; } else if ( rnd < 0.75 ) { c[0] = 'G'; } else { c[0] = 'C'; } se = SequenceError_alloc(); se->type = SeqErrorInsertion; se->start = j+1; se->end = j+1; se->inserted_bases = stringalloc(c); add_SequenceErrorSet(out->ses,se); seq_buffer[j++] = c[0]; } } seq_buffer[j] = '\0'; out->seq = new_Sequence_from_strings(seq->name,seq_buffer); return out; } wise-2.4.1/src/models/clonewisedp.c0000644000175000001440000053427510670453713016631 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "clonewisedp.h" # line 5 "clonewisedp.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define SKIP_QUERY 1 #define SKIP_TARGET 2 #define START 0 #define TRUSTED_SPECIAL 1 #define END 2 #define CloneWise_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*3)+STATE][i+1] #define CloneWise_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define CloneWise_READ_OFF_ERROR -3 #define CloneWise_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*3)+STATE] #define CloneWise_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define CloneWise_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define CloneWise_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_CloneWise(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_CloneWise(CloneWise * mat) { CloneWise_access_func_holder holder; holder.access_main = CloneWise_shatter_access_main; holder.access_special = CloneWise_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_CloneWise(mat,holder); } /* Function: CloneWise_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int CloneWise_shatter_access_main(CloneWise * mat,int i,int j,int state) { return CloneWise_SHATTER_MATRIX(mat,i,j,state); } /* Function: CloneWise_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int CloneWise_shatter_access_special(CloneWise * mat,int i,int j,int state) { return CloneWise_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_CloneWise(mat,dpenv) * * Descrip: This function calculates the CloneWise matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [CloneWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_CloneWise(CloneWise * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,3); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("CloneWise Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_1[MATCH] + (mat->match->matrix[i][j]+1); /* From state MATCH to state MATCH */ temp = SIG_0_1[MATCH] + 0; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_0[MATCH] + 0; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state MATCH */ temp = SIG_1_1[SKIP_QUERY] + 0; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state MATCH */ temp = SIG_1_1[SKIP_TARGET] + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = CloneWise_SHATTER_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; SIG_0_0[MATCH] = score; /* state MATCH is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_SHATTER_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_SHATTER_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; } /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query_skip_start; /* From state SKIP_TARGET to state SKIP_QUERY */ temp = SIG_1_0[SKIP_TARGET] + mat->query_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = SIG_1_0[SKIP_QUERY] + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state SKIP_QUERY */ temp = CloneWise_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; SIG_0_0[SKIP_QUERY] = score; /* state SKIP_QUERY is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_SHATTER_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_SHATTER_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; } /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = SIG_0_1[MATCH] + mat->target_skip_start; /* From state SKIP_QUERY to state SKIP_TARGET */ temp = SIG_0_1[SKIP_QUERY] + mat->target_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = SIG_0_1[SKIP_TARGET] + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-0) == 0 && (j-1) == 0 ) { /* From state START to state SKIP_TARGET */ temp = CloneWise_SHATTER_SPECIAL(mat,i-0,j-1,START) + mat->target_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; SIG_0_0[SKIP_TARGET] = score; /* state SKIP_TARGET is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_SHATTER_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_SHATTER_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; } /* Finished calculating state SKIP_TARGET */ } /* Special state START has no special to special movements */ /* Special state TRUSTED_SPECIAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = CloneWise_SHATTER_SPECIAL(mat,0,j,TRUSTED_SPECIAL); /* Source START is a special source for TRUSTED_SPECIAL */ /* Has restricted position */ if( (j-1) == 0 ) { temp = CloneWise_SHATTER_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source TRUSTED_SPECIAL is a special source for TRUSTED_SPECIAL */ temp = CloneWise_SHATTER_SPECIAL(mat,0,j - 1,TRUSTED_SPECIAL) + ((mat->match->skip_jset[j]-1)) + (0); if( temp > score ) score = temp; /* Source MATCH for state TRUSTED_SPECIAL is not special... already calculated */ /* Source SKIP_QUERY for state TRUSTED_SPECIAL is not special... already calculated */ /* Source SKIP_TARGET for state TRUSTED_SPECIAL is not special... already calculated */ /* Put back score... (now updated!) */ CloneWise_SHATTER_SPECIAL(mat,0,j,TRUSTED_SPECIAL) = score; /* Finished updating state TRUSTED_SPECIAL */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = CloneWise_SHATTER_SPECIAL(mat,0,j,END); /* Source TRUSTED_SPECIAL is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = CloneWise_SHATTER_SPECIAL(mat,0,j - 1,TRUSTED_SPECIAL) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ CloneWise_SHATTER_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: search_CloneWise(dbsi,out,q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function makes a database search of CloneWise * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: t [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: match [UNKN ] Undocumented argument [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Undocumented argument [Score] * Arg: target_skip [UNKN ] Undocumented argument [Score] * Arg: query_skip_start [UNKN ] Undocumented argument [Score] * Arg: query_skip [UNKN ] Undocumented argument [Score] * Arg: spread [UNKN ] Undocumented argument [int] * Arg: target_special_s [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_CloneWise(DBSearchImpl * dbsi,Hscore * out,MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_CloneWise * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_CloneWise. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_CloneWise. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for CloneWise, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_CloneWise(out,q,t ,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_CloneWise *) ckalloc(sizeof(struct thread_pool_holder_CloneWise)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->q = q; holder->t = t; holder->match = match; holder->target_skip_start = target_skip_start; holder->target_skip = target_skip; holder->query_skip_start = query_skip_start; holder->query_skip = query_skip; holder->spread = spread; holder->target_special_s = target_special_s; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_CloneWise,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for CloneWise"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from CloneWise",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_CloneWise(ptr) * * Descrip: dummy loop code foreach thread for CloneWise * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * thread_loop_CloneWise(void * ptr) { fatal("dummy thread loop function"); } /* Function: serial_search_CloneWise(out,q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function makes a database search of CloneWise * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: t [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: match [UNKN ] Undocumented argument [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Undocumented argument [Score] * Arg: target_skip [UNKN ] Undocumented argument [Score] * Arg: query_skip_start [UNKN ] Undocumented argument [Score] * Arg: query_skip [UNKN ] Undocumented argument [Score] * Arg: spread [UNKN ] Undocumented argument [int] * Arg: target_special_s [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_CloneWise(Hscore * out,MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_CloneWise(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("CloneWise search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_CloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_CloneWise_only * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_CloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s) { int bestscore = NEGI; int i; int j; int k; CloneWise * mat; mat = allocate_CloneWise_only(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 3,2,3)) == NULL) { warn("Score only matrix for CloneWise cannot be allocated, (asking for 1 by %d cells)",mat->leni*3); mat = free_CloneWise(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) CloneWise_VSMALL_MATRIX(mat,i,j,k) = NEGI; } CloneWise_VSMALL_SPECIAL(mat,i,j,START) = 0; CloneWise_VSMALL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = NEGI; CloneWise_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = CloneWise_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + (mat->match->matrix[i][j]+1); /* From state MATCH to state MATCH */ temp = CloneWise_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + 0; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = CloneWise_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + 0; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state MATCH */ temp = CloneWise_VSMALL_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state MATCH */ temp = CloneWise_VSMALL_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = CloneWise_VSMALL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; CloneWise_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_VSMALL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_VSMALL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; } /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = CloneWise_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; /* From state SKIP_TARGET to state SKIP_QUERY */ temp = CloneWise_VSMALL_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = CloneWise_VSMALL_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state SKIP_QUERY */ temp = CloneWise_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; CloneWise_VSMALL_MATRIX(mat,i,j,SKIP_QUERY) = score; /* state SKIP_QUERY is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_VSMALL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_VSMALL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; } /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = CloneWise_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + mat->target_skip_start; /* From state SKIP_QUERY to state SKIP_TARGET */ temp = CloneWise_VSMALL_MATRIX(mat,i-0,j-1,SKIP_QUERY) + mat->target_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = CloneWise_VSMALL_MATRIX(mat,i-0,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-0) == 0 && (j-1) == 0 ) { /* From state START to state SKIP_TARGET */ temp = CloneWise_VSMALL_SPECIAL(mat,i-0,j-1,START) + mat->target_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; CloneWise_VSMALL_MATRIX(mat,i,j,SKIP_TARGET) = score; /* state SKIP_TARGET is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_VSMALL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_VSMALL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; } /* Finished calculating state SKIP_TARGET */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state TRUSTED_SPECIAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = CloneWise_VSMALL_SPECIAL(mat,0,j,TRUSTED_SPECIAL); /* Source START is a special source for TRUSTED_SPECIAL */ /* Has restricted position */ if( (j-1) == 0 ) { temp = CloneWise_VSMALL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source TRUSTED_SPECIAL is a special source for TRUSTED_SPECIAL */ temp = CloneWise_VSMALL_SPECIAL(mat,0,j - 1,TRUSTED_SPECIAL) + ((mat->match->skip_jset[j]-1)) + (0); if( temp > score ) score = temp; /* Source MATCH for state TRUSTED_SPECIAL is not special... already calculated */ /* Source SKIP_QUERY for state TRUSTED_SPECIAL is not special... already calculated */ /* Source SKIP_TARGET for state TRUSTED_SPECIAL is not special... already calculated */ /* Put back score... (now updated!) */ CloneWise_VSMALL_SPECIAL(mat,0,j,TRUSTED_SPECIAL) = score; /* Finished updating state TRUSTED_SPECIAL */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = CloneWise_VSMALL_SPECIAL(mat,0,j,END); /* Source TRUSTED_SPECIAL is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = CloneWise_VSMALL_SPECIAL(mat,0,j - 1,TRUSTED_SPECIAL) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ CloneWise_VSMALL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ if( bestscore < CloneWise_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = CloneWise_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_CloneWise(mat); return bestscore; } /* Function: PackAln_bestmemory_CloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_CloneWise * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_CloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; CloneWise * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = q->length * t->length; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_CloneWise(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s,dpri)) == NULL ) { warn("Unable to allocate large CloneWise version"); return NULL; } calculate_dpenv_CloneWise(mat,dpenv); out = PackAln_read_Expl_CloneWise(mat); } else { mat = allocate_CloneWise_only(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s); calculate_shatter_CloneWise(mat,dpenv); out = PackAln_read_Shatter_CloneWise(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_CloneWise(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s)) == NULL ) { warn("Unable to allocate small CloneWise version"); return NULL; } out = PackAln_calculate_Small_CloneWise(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_CloneWise(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s,dpri)) == NULL ) { warn("Unable to allocate large CloneWise version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_CloneWise(mat); out = PackAln_read_Expl_CloneWise(mat); } } } mat = free_CloneWise(mat); return out; } /* Function: allocate_CloneWise_only(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function only allocates the CloneWise structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [CloneWise *] * */ CloneWise * allocate_CloneWise_only(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s) { CloneWise * out; if((out= CloneWise_alloc()) == NULL) { warn("Allocation of basic CloneWise structure failed..."); return NULL; } out->q = q; out->t = t; out->match = match; out->target_skip_start = target_skip_start; out->target_skip = target_skip; out->query_skip_start = query_skip_start; out->query_skip = query_skip; out->spread = spread; out->target_special_s = target_special_s; out->leni = q->length; out->lenj = t->length; return out; } /* Function: allocate_Expl_CloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s,dpri) * * Descrip: This function allocates the CloneWise structure * and the basematrix area for explicit memory implementations * It calls /allocate_CloneWise_only * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [CloneWise *] * */ CloneWise * allocate_Expl_CloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s,DPRunImpl * dpri) { CloneWise * out; out = allocate_CloneWise_only(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*3,(out->leni+1),3,out->lenj+1)) == NULL) { warn("Explicit matrix CloneWise cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_CloneWise(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_CloneWise(out); return out; } /* Function: init_CloneWise(mat) * * Descrip: This function initates CloneWise matrix when in explicit mode * Called in /allocate_Expl_CloneWise * * * Arg: mat [UNKN ] CloneWise which contains explicit basematrix memory [CloneWise *] * */ void init_CloneWise(CloneWise * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iq->length;i++) { for(j= (-1);j<2;j++) { CloneWise_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; CloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; CloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; } } for(j= (-1);jt->length;j++) { for(i= (-1);i<2;i++) { CloneWise_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; CloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; CloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; } CloneWise_EXPL_SPECIAL(mat,i,j,START) = 0; CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = NEGI; CloneWise_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_CloneWise(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by CloneWise * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * */ void recalculate_PackAln_CloneWise(PackAln * pal,CloneWise * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = (mat->match->matrix[i][j]+1) + (mat->match->matrix[i][j]); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = 0 + (mat->match->matrix[i][j]); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = 0 + (mat->match->matrix[i][j]); continue; } if( offi == 1 && offj == 1 && prev->state == SKIP_QUERY ) { pau->score = 0 + (mat->match->matrix[i][j]); continue; } if( offi == 1 && offj == 1 && prev->state == SKIP_TARGET ) { pau->score = 0 + (mat->match->matrix[i][j]); continue; } if( offj == 1 && prev->state == (START+3) ) { pau->score = 0 + (mat->match->matrix[i][j]); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SKIP_QUERY : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query_skip_start + (mat->match->skip_iset[i]); continue; } if( offi == 1 && offj == 0 && prev->state == SKIP_TARGET ) { pau->score = mat->query_skip_start + (mat->match->skip_iset[i]); continue; } if( offi == 1 && offj == 0 && prev->state == SKIP_QUERY ) { pau->score = 0 + (mat->match->skip_iset[i]); continue; } if( offj == 0 && prev->state == (START+3) ) { pau->score = mat->query_skip_start + (mat->match->skip_iset[i]); continue; } warn("In recaluclating PackAln with state SKIP_QUERY, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SKIP_TARGET : if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = mat->target_skip_start + (mat->match->skip_jset[j]); continue; } if( offi == 0 && offj == 1 && prev->state == SKIP_QUERY ) { pau->score = mat->target_skip_start + (mat->match->skip_jset[j]); continue; } if( offi == 0 && offj == 1 && prev->state == SKIP_TARGET ) { pau->score = 0 + (mat->match->skip_jset[j]); continue; } if( offj == 1 && prev->state == (START+3) ) { pau->score = mat->target_skip_start + (mat->match->skip_jset[j]); continue; } warn("In recaluclating PackAln with state SKIP_TARGET, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (TRUSTED_SPECIAL+3) : if( offj == 1 && prev->state == (START+3) ) { pau->score = 0 + (0); continue; } if( offj == 1 && prev->state == (TRUSTED_SPECIAL+3) ) { pau->score = (mat->match->skip_jset[j]-1) + (0); continue; } if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->target_special_s + (0); continue; } if( offj == 0 && prev->state == SKIP_QUERY ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->target_special_s + (0); continue; } if( offj == 0 && prev->state == SKIP_TARGET ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->target_special_s + (0); continue; } warn("In recaluclating PackAln with state TRUSTED_SPECIAL, got a bad source state. Error!"); break; case (END+3) : if( offj == 1 && prev->state == (TRUSTED_SPECIAL+3) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define CloneWise_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*3+state]) #define CloneWise_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*3+state]) #define CloneWise_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define CloneWise_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define CloneWise_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*3 + state]) #define CloneWise_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define CloneWise_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define CloneWise_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define CloneWise_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_CloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function allocates the CloneWise structure * and the basematrix area for a small memory implementations * It calls /allocate_CloneWise_only * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [CloneWise *] * */ #define CloneWise_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) CloneWise * allocate_Small_CloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s) { CloneWise * out; out = allocate_CloneWise_only(q, t , match, target_skip_start, target_skip, query_skip_start, query_skip, spread, target_special_s); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 3,24,out->lenj+1); if(out == NULL) { warn("Small shadow matrix CloneWise cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_CloneWise(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_CloneWise(mat,dpenv) * * Descrip: This function calculates an alignment for CloneWise structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_CloneWise * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_CloneWise * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_CloneWise(CloneWise * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for CloneWise due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_CloneWise(mat,dpenv); score = start_end_find_end_CloneWise(mat,&endj); out->score = score; stopstate = END; /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */ log_full_error(REPORT,0,"End at %d Score %d",endj,score); stop_reporting(); for(;;) { /*while there are more special bits to recover*/ start_reporting("Special cell aln end %d:",endj); if( read_special_strip_CloneWise(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) { warn("Problem in reading off special state system... going to return partial alignment"); break; } if( startstate == START || endj <= 0) { log_full_error(REPORT,0,"Recovered complete alignment"); stop_reporting(); break; } log_full_error(REPORT,0,"Finished to %d",endj); stop_reporting(); /* Ok... have to eat up another piece of matrix */ temp = startstate; starti = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0); startj = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1); startstate = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2); stopi = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3); stopj = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4); stopstate = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5); /* Get out the score of this block. V. important! */ temp = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6); totalj = stopj - startj; donej = 0; start_reporting("Main matrix aln [%d,%d]:",startj,stopj); if(full_dc_CloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) { warn("In the alignment CloneWise [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj); return out; } /* now have to figure out which special we came from... yikes */ max_matrix_to_special_CloneWise(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == CloneWise_READ_OFF_ERROR) { warn("In CloneWise read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj); invert_PackAln(out); recalculate_PackAln_CloneWise(out,mat); return out; } /* if at start, break, otherwise, back to eat another strip */ if( stopstate == START) { log_full_error(REPORT,0,"Recovered complete alignment "); stop_reporting(); break; } log_full_error(REPORT,0,"Finished alignment to %d ",startj); stop_reporting(); endj = stopj; /* stopstate is correct as it is */ } /* end of while there are more special bits to recover */ invert_PackAln(out); recalculate_PackAln_CloneWise(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_CloneWise(mat) * * Descrip: This function calculates an alignment for CloneWise structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_CloneWise * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_CloneWise * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_CloneWise * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_CloneWise(CloneWise * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_CloneWise(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_CloneWise(mat); return out; } /* Function: AlnRangeSet_from_CloneWise(mat) * * Descrip: This function reads off a start/end structure * for CloneWise structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_CloneWise * If you have not calculated the matrix use * /AlnRange_calculate_Small_CloneWise * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_CloneWise(CloneWise * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_CloneWise"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_CloneWise(mat,&jpos); state = END; while( (temp = AlnRange_build_CloneWise(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_CloneWise(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_CloneWise * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_CloneWise(CloneWise * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_CloneWise"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_CloneWise(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_CloneWise alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = CloneWise_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_CloneWise(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == CloneWise_READ_OFF_ERROR) { warn("In AlnRange_build_CloneWise alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = CloneWise_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_CloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_CloneWise(CloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_CloneWise(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == CloneWise_READ_OFF_ERROR) { warn("In CloneWise hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In CloneWise hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In CloneWise hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_CloneWise(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_CloneWise(CloneWise * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = CloneWise_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->q->length || j > mat->t->length) { warn("In CloneWise matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = CloneWise_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Not allowing special sources.. skipping START */ temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 1,SKIP_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_HIDDEN_MATRIX(mat,i-1,j-1,SKIP_TARGET); } return CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 1,SKIP_TARGET); } temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 1,SKIP_QUERY) ) { *reti = i - 1; *retj = j - 1; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_HIDDEN_MATRIX(mat,i-1,j-1,SKIP_QUERY); } return CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 1,SKIP_QUERY); } temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == CloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return CloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } temp = cscore - ((mat->match->matrix[i][j]+1)) - (mat->match->matrix[i][j]); if( temp == CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in CloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SKIP_QUERY : /* Not allowing special sources.. skipping START */ temp = cscore - (0) - (mat->match->skip_iset[i]); if( temp == CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,SKIP_QUERY) ) { *reti = i - 1; *retj = j - 0; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_HIDDEN_MATRIX(mat,i-1,j-0,SKIP_QUERY); } return CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,SKIP_QUERY); } temp = cscore - (mat->query_skip_start) - (mat->match->skip_iset[i]); if( temp == CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,SKIP_TARGET) ) { *reti = i - 1; *retj = j - 0; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_HIDDEN_MATRIX(mat,i-1,j-0,SKIP_TARGET); } return CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,SKIP_TARGET); } temp = cscore - (mat->query_skip_start) - (mat->match->skip_iset[i]); if( temp == CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return CloneWise_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in CloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SKIP_TARGET : /* Not allowing special sources.. skipping START */ temp = cscore - (0) - (mat->match->skip_jset[j]); if( temp == CloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,SKIP_TARGET) ) { *reti = i - 0; *retj = j - 1; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_HIDDEN_MATRIX(mat,i-0,j-1,SKIP_TARGET); } return CloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,SKIP_TARGET); } temp = cscore - (mat->target_skip_start) - (mat->match->skip_jset[j]); if( temp == CloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,SKIP_QUERY) ) { *reti = i - 0; *retj = j - 1; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_HIDDEN_MATRIX(mat,i-0,j-1,SKIP_QUERY); } return CloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,SKIP_QUERY); } temp = cscore - (mat->target_skip_start) - (mat->match->skip_jset[j]); if( temp == CloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return CloneWise_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in CloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in CloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_CloneWise(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_CloneWise(CloneWise * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > CloneWise_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_CloneWise(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == CloneWise_READ_OFF_ERROR) { warn("In special strip read CloneWise, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < CloneWise_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read CloneWise, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_CloneWise(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_CloneWise(CloneWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = CloneWise_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for CloneWise, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->t->length) { warn("In CloneWise matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = CloneWise_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case TRUSTED_SPECIAL : /* Source SKIP_TARGET is not a special */ /* Source SKIP_QUERY is not a special */ /* Source MATCH is not a special */ /* source TRUSTED_SPECIAL is a special */ temp = cscore - ((mat->match->skip_jset[j]-1)) - (0); if( temp == CloneWise_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,TRUSTED_SPECIAL) ) { *reti = i - 0; *retj = j - 1; *retstate = TRUSTED_SPECIAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_DC_SHADOW_SPECIAL(mat,i-0,j-1,TRUSTED_SPECIAL); } return CloneWise_DC_SHADOW_MATRIX(mat,i - 0,j - 1,TRUSTED_SPECIAL) ; } /* source START is a special */ temp = cscore - (0) - (0); if( temp == CloneWise_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return CloneWise_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } case END : /* source TRUSTED_SPECIAL is a special */ temp = cscore - (0) - (0); if( temp == CloneWise_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,TRUSTED_SPECIAL) ) { *reti = i - 0; *retj = j - 1; *retstate = TRUSTED_SPECIAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_DC_SHADOW_SPECIAL(mat,i-0,j-1,TRUSTED_SPECIAL); } return CloneWise_DC_SHADOW_MATRIX(mat,i - 0,j - 1,TRUSTED_SPECIAL) ; } default: warn("Major problem (!) - in CloneWise special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_CloneWise(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_CloneWise(CloneWise * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = CloneWise_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In CloneWise matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == CloneWise_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return CloneWise_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source SKIP_TARGET is not a special, should not get here! */ /* Source SKIP_QUERY is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in CloneWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SKIP_QUERY : temp = cscore - (mat->query_skip_start) - (mat->match->skip_iset[i]); if( temp == CloneWise_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return CloneWise_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source SKIP_QUERY is not a special, should not get here! */ /* Source SKIP_TARGET is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in CloneWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SKIP_TARGET : temp = cscore - (mat->target_skip_start) - (mat->match->skip_jset[j]); if( temp == CloneWise_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - CloneWise_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return CloneWise_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } /* Source SKIP_TARGET is not a special, should not get here! */ /* Source SKIP_QUERY is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in CloneWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in CloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_CloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_CloneWise(CloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_CloneWise(mat,starti,startj,stopi,stopj); CloneWise_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ CloneWise_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; CloneWise_HIDDEN_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; CloneWise_HIDDEN_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = CloneWise_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + (mat->match->matrix[i][j]+1); /* From state MATCH to state MATCH */ temp = CloneWise_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + 0; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = CloneWise_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + 0; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state MATCH */ temp = CloneWise_HIDDEN_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state MATCH */ temp = CloneWise_HIDDEN_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; CloneWise_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = CloneWise_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; /* From state SKIP_TARGET to state SKIP_QUERY */ temp = CloneWise_HIDDEN_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = CloneWise_HIDDEN_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; CloneWise_HIDDEN_MATRIX(mat,i,j,SKIP_QUERY) = score; /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = CloneWise_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + mat->target_skip_start; /* From state SKIP_QUERY to state SKIP_TARGET */ temp = CloneWise_HIDDEN_MATRIX(mat,i-0,j-1,SKIP_QUERY) + mat->target_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = CloneWise_HIDDEN_MATRIX(mat,i-0,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; CloneWise_HIDDEN_MATRIX(mat,i,j,SKIP_TARGET) = score; /* Finished calculating state SKIP_TARGET */ } } return; } /* Function: init_hidden_CloneWise(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_CloneWise(CloneWise * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { CloneWise_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; CloneWise_HIDDEN_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; CloneWise_HIDDEN_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; } } return; } /* Function: full_dc_CloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_CloneWise * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_CloneWise to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [CloneWise *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_CloneWise(CloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_CloneWise"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_CloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_CloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_CloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for CloneWise, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= CloneWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= CloneWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = CloneWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_CloneWise(mat,CloneWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),CloneWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),CloneWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_CloneWise(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_CloneWise(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_CloneWise(CloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_CloneWise(mat); CloneWise_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_CloneWise(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_CloneWise(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_CloneWise(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_CloneWise(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_CloneWise(CloneWise * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ CloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,0) = (-100); CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,1) = (-100); CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,0) = (-100); CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + (mat->match->matrix[i][j]+1); if( j - 1 <= mergej) { CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } temp = CloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-0; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } } temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + 0; if( temp > score) { score = temp; if( j - 0 <= mergej) { CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-0; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } } temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = SKIP_QUERY; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SKIP_QUERY,k); } } temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = SKIP_TARGET; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SKIP_TARGET,k); } } /* Add any movement independant score */ score += mat->match->matrix[i][j]; CloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state SKIP_QUERY, pushing when j - offj <= mergej */ score = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; if( j - 0 <= mergej) { CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,0) = i-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,1) = j-0; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,2) = MATCH; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,3) = i; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,4) = j; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,5) = SKIP_QUERY; } else { for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k) = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score) { score = temp; if( j - 0 <= mergej) { CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,0) = i-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,1) = j-0; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,2) = SKIP_TARGET; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,3) = i; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,4) = j; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,5) = SKIP_QUERY; } else { for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k) = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SKIP_TARGET,k); } } temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score) { score = temp; if( j - 0 <= mergej) { CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,0) = i-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,1) = j-0; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,2) = SKIP_QUERY; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,3) = i; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,4) = j; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,5) = SKIP_QUERY; } else { for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k) = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SKIP_QUERY,k); } } /* Add any movement independant score */ score += mat->match->skip_iset[i]; CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = score; /* Finished with state SKIP_QUERY */ /* For state SKIP_TARGET, pushing when j - offj <= mergej */ score = CloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->target_skip_start; if( j - 1 <= mergej) { CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,0) = i-0; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,1) = j-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,2) = MATCH; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,3) = i; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,4) = j; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,5) = SKIP_TARGET; } else { for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k) = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } temp = CloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,SKIP_QUERY) + mat->target_skip_start; if( temp > score) { score = temp; if( j - 1 <= mergej) { CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,0) = i-0; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,1) = j-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,2) = SKIP_QUERY; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,3) = i; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,4) = j; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,5) = SKIP_TARGET; } else { for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k) = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SKIP_QUERY,k); } } temp = CloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,SKIP_TARGET) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,0) = i-0; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,1) = j-1; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,2) = SKIP_TARGET; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,3) = i; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,4) = j; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,5) = SKIP_TARGET; } else { for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k) = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SKIP_TARGET,k); } } /* Add any movement independant score */ score += mat->match->skip_jset[j]; CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = score; /* Finished with state SKIP_TARGET */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_CloneWise(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_CloneWise(CloneWise * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ CloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + (mat->match->matrix[i][j]+1); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); /* From state MATCH to state MATCH */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } /* From state MATCH to state MATCH */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } /* From state SKIP_QUERY to state MATCH */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SKIP_QUERY,k); } /* From state SKIP_TARGET to state MATCH */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SKIP_TARGET,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; CloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state SKIP_TARGET to state SKIP_QUERY */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SKIP_TARGET,k); } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SKIP_QUERY,k); } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = score; for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = CloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->target_skip_start; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); /* From state SKIP_QUERY to state SKIP_TARGET */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,SKIP_QUERY) + mat->target_skip_start; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SKIP_QUERY,k); } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = CloneWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SKIP_TARGET,k); } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = score; for(k=0;k<7;k++) CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SKIP_TARGET */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_CloneWise(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_CloneWise(CloneWise * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ CloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + (mat->match->matrix[i][j]+1); /* From state MATCH to state MATCH */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + 0; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + 0; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state MATCH */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state MATCH */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; CloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; /* From state SKIP_TARGET to state SKIP_QUERY */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = score; /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = CloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->target_skip_start; /* From state SKIP_QUERY to state SKIP_TARGET */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,SKIP_QUERY) + mat->target_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = CloneWise_DC_SHADOW_MATRIX(mat,i-0,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = score; /* Finished calculating state SKIP_TARGET */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_CloneWise(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * */ } void init_dc_CloneWise(CloneWise * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iq->length;i++) { CloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; for(k=0;k<7;k++) { CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k) = (-1); CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k) = (-1); } } } return; } /* Function: start_end_find_end_CloneWise(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [CloneWise *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_CloneWise(CloneWise * mat,int * endj) { register int j; register int max; register int maxj; max = CloneWise_DC_SHADOW_SPECIAL(mat,0,mat->t->length-1,END); maxj = mat->t->length-1; for(j= mat->t->length-2 ;j >= 0 ;j--) { if( CloneWise_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = CloneWise_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_CloneWise(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [CloneWise] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_CloneWise(CloneWise *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->q->length; lenj = mat->t->length; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jmatch->matrix[i][j]+1) + (mat->match->matrix[i][j]); /* assign local shadown pointer */ localsp = &(CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); /* From state MATCH to state MATCH */ temp = CloneWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + 0 +(mat->match->matrix[i][j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); } /* From state MATCH to state MATCH */ temp = CloneWise_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + 0 +(mat->match->matrix[i][j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); } /* From state SKIP_QUERY to state MATCH */ temp = CloneWise_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0 +(mat->match->matrix[i][j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SKIP_QUERY,0)); } /* From state SKIP_TARGET to state MATCH */ temp = CloneWise_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0 +(mat->match->matrix[i][j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SKIP_TARGET,0)); } /* From state START to state MATCH */ temp = CloneWise_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + 0 + (mat->match->matrix[i][j]); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ CloneWise_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,k) = CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,6) = CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,3) = i; CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,4) = j; CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,5) = MATCH; } /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = CloneWise_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start + (mat->match->skip_iset[i]); /* assign local shadown pointer */ localsp = &(CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state SKIP_TARGET to state SKIP_QUERY */ temp = CloneWise_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start +(mat->match->skip_iset[i]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SKIP_TARGET,0)); } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = CloneWise_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0 +(mat->match->skip_iset[i]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SKIP_QUERY,0)); } /* From state START to state SKIP_QUERY */ temp = CloneWise_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query_skip_start + (mat->match->skip_iset[i]); if( temp > score ) { score = temp; /* This state [START] is a special for SKIP_QUERY... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= SKIP_QUERY; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ CloneWise_DC_OPT_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = score; for(k=0;k<7;k++) CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state SKIP_QUERY is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,k) = CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,k); CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,6) = CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,6); CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,3) = i; CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,4) = j; CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,5) = SKIP_QUERY; } /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = CloneWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->target_skip_start + (mat->match->skip_jset[j]); /* assign local shadown pointer */ localsp = &(CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); /* From state SKIP_QUERY to state SKIP_TARGET */ temp = CloneWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SKIP_QUERY) + mat->target_skip_start +(mat->match->skip_jset[j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SKIP_QUERY,0)); } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = CloneWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SKIP_TARGET) + 0 +(mat->match->skip_jset[j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SKIP_TARGET,0)); } /* From state START to state SKIP_TARGET */ temp = CloneWise_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,START) + mat->target_skip_start + (mat->match->skip_jset[j]); if( temp > score ) { score = temp; /* This state [START] is a special for SKIP_TARGET... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= SKIP_TARGET; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ CloneWise_DC_OPT_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = score; for(k=0;k<7;k++) CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state SKIP_TARGET is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,k) = CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,k); CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,6) = CloneWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,6); CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,3) = i; CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,4) = j; CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,5) = SKIP_TARGET; } /* Finished calculating state SKIP_TARGET */ } /* end of for each i position in strip */ /* Special state START has no special to special movements */ /* Special state TRUSTED_SPECIAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = CloneWise_DC_OPT_SHADOW_SPECIAL(mat,0,j,TRUSTED_SPECIAL); /* Source START is a special source for TRUSTED_SPECIAL */ temp = CloneWise_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,k) = CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,START,k); } /* Source TRUSTED_SPECIAL is a special source for TRUSTED_SPECIAL */ temp = CloneWise_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,TRUSTED_SPECIAL) + ((mat->match->skip_jset[j]-1)) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,TRUSTED_SPECIAL,k) = CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,TRUSTED_SPECIAL,k); } /* Source MATCH for state TRUSTED_SPECIAL is not special... already calculated */ /* Source SKIP_QUERY for state TRUSTED_SPECIAL is not special... already calculated */ /* Source SKIP_TARGET for state TRUSTED_SPECIAL is not special... already calculated */ /* Put back score... (now updated!) */ CloneWise_DC_OPT_SHADOW_SPECIAL(mat,0,j,TRUSTED_SPECIAL) = score; /* Finished updating state TRUSTED_SPECIAL */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = CloneWise_DC_OPT_SHADOW_SPECIAL(mat,0,j,END); /* Source TRUSTED_SPECIAL is a special source for END */ temp = CloneWise_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,TRUSTED_SPECIAL) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = CloneWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,TRUSTED_SPECIAL,k); } /* Put back score... (now updated!) */ CloneWise_DC_OPT_SHADOW_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_CloneWise(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * */ void init_start_end_linear_CloneWise(CloneWise * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iq->length;i++) { CloneWise_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_QUERY,0) = (-1); CloneWise_DC_SHADOW_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; CloneWise_DC_SHADOW_MATRIX_SP(mat,i,j,SKIP_TARGET,0) = (-1); } } for(j=(-1);jt->length;j++) { CloneWise_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; CloneWise_DC_SHADOW_SPECIAL(mat,0,j,TRUSTED_SPECIAL) = NEGI; CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,j,TRUSTED_SPECIAL,0) = (-1); CloneWise_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; CloneWise_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_CloneWise(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_CloneWise(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_CloneWise(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "QUERY_MATCH","QUERY_MATCH_PAUSE","QUERY_SKIP","QUERY_PAUSE","NO_QUERY_PAUSE","END" }; /* Function: AlnConvertSet_CloneWise(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "TARGET_MATCH","TARGET_MATCH_PAUSE","TARGET_PAUSE","TARGET_SKIP","END" }; AlnConvertSet * AlnConvertSet_CloneWise(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_QUERY; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_TARGET; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = SKIP_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_TARGET; acu->state2 = SKIP_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_QUERY; acu->state2 = SKIP_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = SKIP_QUERY; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = SKIP_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_QUERY; acu->state2 = SKIP_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_TARGET; acu->state2 = SKIP_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = SKIP_TARGET; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->state2 = TRUSTED_SPECIAL + 3; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = TRUSTED_SPECIAL + 3; acu->state2 = TRUSTED_SPECIAL + 3; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = TRUSTED_SPECIAL + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_QUERY; acu->state2 = TRUSTED_SPECIAL + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SKIP_TARGET; acu->state2 = TRUSTED_SPECIAL + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = TRUSTED_SPECIAL + 3; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[4]; return out; } /* Function: PackAln_read_Expl_CloneWise(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_CloneWise(CloneWise * mat) { CloneWise_access_func_holder holder; holder.access_main = CloneWise_explicit_access_main; holder.access_special = CloneWise_explicit_access_special; return PackAln_read_generic_CloneWise(mat,holder); } /* Function: CloneWise_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int CloneWise_explicit_access_main(CloneWise * mat,int i,int j,int state) { return CloneWise_EXPL_MATRIX(mat,i,j,state); } /* Function: CloneWise_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int CloneWise_explicit_access_special(CloneWise * mat,int i,int j,int state) { return CloneWise_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_CloneWise(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: h [UNKN ] Undocumented argument [CloneWise_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_CloneWise(CloneWise * mat,CloneWise_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_CloneWise(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in CloneWise_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_CloneWise(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_CloneWise(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == CloneWise_READ_OFF_ERROR || j == CloneWise_READ_OFF_ERROR || state == CloneWise_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in CloneWise_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_CloneWise(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [CloneWise_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_CloneWise(CloneWise * mat,int * ri,int * rj,int * state,boolean * isspecial,CloneWise_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->t->length-1,END); maxj = mat->t->length-1; for(j= mat->t->length-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: CloneWise_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void CloneWise_debug_show_matrix(CloneWise * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iq->length;i++) { for(j=startj;jt->length;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",CloneWise_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State SKIP_QUERY %d\n",CloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY)); fprintf(ofp,"State SKIP_TARGET %d\n",CloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_CloneWise(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [CloneWise_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_CloneWise(CloneWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,CloneWise_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = CloneWise_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->q->length || j > mat->t->length) { warn("In CloneWise matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } } temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == (*h.access_main)(mat,i - 1,j - 1,SKIP_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,SKIP_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,SKIP_TARGET); } temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == (*h.access_main)(mat,i - 1,j - 1,SKIP_QUERY) ) { *reti = i - 1; *retj = j - 1; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,SKIP_QUERY); } return (*h.access_main)(mat,i - 1,j - 1,SKIP_QUERY); } temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } temp = cscore - (0) - (mat->match->matrix[i][j]); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } temp = cscore - ((mat->match->matrix[i][j]+1)) - (mat->match->matrix[i][j]); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in CloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SKIP_QUERY : /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { temp = cscore - (mat->query_skip_start) - (mat->match->skip_iset[i]); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } } temp = cscore - (0) - (mat->match->skip_iset[i]); if( temp == (*h.access_main)(mat,i - 1,j - 0,SKIP_QUERY) ) { *reti = i - 1; *retj = j - 0; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,SKIP_QUERY); } return (*h.access_main)(mat,i - 1,j - 0,SKIP_QUERY); } temp = cscore - (mat->query_skip_start) - (mat->match->skip_iset[i]); if( temp == (*h.access_main)(mat,i - 1,j - 0,SKIP_TARGET) ) { *reti = i - 1; *retj = j - 0; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,SKIP_TARGET); } return (*h.access_main)(mat,i - 1,j - 0,SKIP_TARGET); } temp = cscore - (mat->query_skip_start) - (mat->match->skip_iset[i]); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in CloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SKIP_TARGET : /* Has restricted position */ if( (i-0) == 0 && (j-1) == 0 ) { temp = cscore - (mat->target_skip_start) - (mat->match->skip_jset[j]); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_main)(mat,i - 0,j - 1,START); } } temp = cscore - (0) - (mat->match->skip_jset[j]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SKIP_TARGET) ) { *reti = i - 0; *retj = j - 1; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SKIP_TARGET); } return (*h.access_main)(mat,i - 0,j - 1,SKIP_TARGET); } temp = cscore - (mat->target_skip_start) - (mat->match->skip_jset[j]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SKIP_QUERY) ) { *reti = i - 0; *retj = j - 1; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SKIP_QUERY); } return (*h.access_main)(mat,i - 0,j - 1,SKIP_QUERY); } temp = cscore - (mat->target_skip_start) - (mat->match->skip_jset[j]); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in CloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in CloneWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_CloneWise(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [CloneWise_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_CloneWise(CloneWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,CloneWise_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = CloneWise_READ_OFF_ERROR; if( j < 0 || j > mat->t->length) { warn("In CloneWise matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case TRUSTED_SPECIAL : /* source SKIP_TARGET is from main matrix */ for(i= mat->q->length-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->target_special_s) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,SKIP_TARGET) ) { *reti = i - 0; *retj = j - 0; *retstate = SKIP_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,SKIP_TARGET); } return (*h.access_main)(mat,i - 0,j - 0,SKIP_TARGET) ; } } /* end of for i >= 0 */ /* source SKIP_QUERY is from main matrix */ for(i= mat->q->length-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->target_special_s) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,SKIP_QUERY) ) { *reti = i - 0; *retj = j - 0; *retstate = SKIP_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,SKIP_QUERY); } return (*h.access_main)(mat,i - 0,j - 0,SKIP_QUERY) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->q->length-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->target_special_s) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ /* source TRUSTED_SPECIAL is a special */ temp = cscore - ((mat->match->skip_jset[j]-1)) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,TRUSTED_SPECIAL) ) { *reti = i - 0; *retj = j - 1; *retstate = TRUSTED_SPECIAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,TRUSTED_SPECIAL); } return (*h.access_special)(mat,i - 0,j - 1,TRUSTED_SPECIAL) ; } /* source START is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_special)(mat,i - 0,j - 1,START) ; } case END : /* source TRUSTED_SPECIAL is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,TRUSTED_SPECIAL) ) { *reti = i - 0; *retj = j - 1; *retstate = TRUSTED_SPECIAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,TRUSTED_SPECIAL); } return (*h.access_special)(mat,i - 0,j - 1,TRUSTED_SPECIAL) ; } default: warn("Major problem (!) - in CloneWise read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_CloneWise(mat) * * Descrip: This function calculates the CloneWise matrix when in explicit mode * To allocate the matrix use /allocate_Expl_CloneWise * * * Arg: mat [UNKN ] CloneWise which contains explicit basematrix memory [CloneWise *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_CloneWise(CloneWise * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_CloneWise, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("CloneWise Matrix calculation: "); for(j=0;jmatch->matrix[i][j]+1); /* From state MATCH to state MATCH */ temp = CloneWise_EXPL_MATRIX(mat,i-0,j-1,MATCH) + 0; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = CloneWise_EXPL_MATRIX(mat,i-1,j-0,MATCH) + 0; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state MATCH */ temp = CloneWise_EXPL_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state MATCH */ temp = CloneWise_EXPL_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = CloneWise_EXPL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; CloneWise_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; } /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = CloneWise_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; /* From state SKIP_TARGET to state SKIP_QUERY */ temp = CloneWise_EXPL_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = CloneWise_EXPL_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state SKIP_QUERY */ temp = CloneWise_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; CloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY) = score; /* state SKIP_QUERY is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; } /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = CloneWise_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->target_skip_start; /* From state SKIP_QUERY to state SKIP_TARGET */ temp = CloneWise_EXPL_MATRIX(mat,i-0,j-1,SKIP_QUERY) + mat->target_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = CloneWise_EXPL_MATRIX(mat,i-0,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-0) == 0 && (j-1) == 0 ) { /* From state START to state SKIP_TARGET */ temp = CloneWise_EXPL_SPECIAL(mat,i-0,j-1,START) + mat->target_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; CloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET) = score; /* state SKIP_TARGET is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; } /* Finished calculating state SKIP_TARGET */ } /* Special state START has no special to special movements */ /* Special state TRUSTED_SPECIAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = CloneWise_EXPL_SPECIAL(mat,0,j,TRUSTED_SPECIAL); /* Source START is a special source for TRUSTED_SPECIAL */ /* Has restricted position */ if( (j-1) == 0 ) { temp = CloneWise_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source TRUSTED_SPECIAL is a special source for TRUSTED_SPECIAL */ temp = CloneWise_EXPL_SPECIAL(mat,0,j - 1,TRUSTED_SPECIAL) + ((mat->match->skip_jset[j]-1)) + (0); if( temp > score ) score = temp; /* Source MATCH for state TRUSTED_SPECIAL is not special... already calculated */ /* Source SKIP_QUERY for state TRUSTED_SPECIAL is not special... already calculated */ /* Source SKIP_TARGET for state TRUSTED_SPECIAL is not special... already calculated */ /* Put back score... (now updated!) */ CloneWise_EXPL_SPECIAL(mat,0,j,TRUSTED_SPECIAL) = score; /* Finished updating state TRUSTED_SPECIAL */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = CloneWise_EXPL_SPECIAL(mat,0,j,END); /* Source TRUSTED_SPECIAL is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = CloneWise_EXPL_SPECIAL(mat,0,j - 1,TRUSTED_SPECIAL) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ CloneWise_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_CloneWise(mat,dpenv) * * Descrip: This function calculates the CloneWise matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] CloneWise which contains explicit basematrix memory [CloneWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_CloneWise(CloneWise * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_CloneWise, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { CloneWise_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; CloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; CloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; } } for(j=-1;jlenj;j++) { CloneWise_EXPL_SPECIAL(mat,i,j,START) = 0; CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = NEGI; CloneWise_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("CloneWise Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { CloneWise_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; CloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY) = NEGI; CloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = CloneWise_EXPL_MATRIX(mat,i-1,j-1,MATCH) + (mat->match->matrix[i][j]+1); /* From state MATCH to state MATCH */ temp = CloneWise_EXPL_MATRIX(mat,i-0,j-1,MATCH) + 0; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = CloneWise_EXPL_MATRIX(mat,i-1,j-0,MATCH) + 0; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state MATCH */ temp = CloneWise_EXPL_MATRIX(mat,i-1,j-1,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state MATCH */ temp = CloneWise_EXPL_MATRIX(mat,i-1,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = CloneWise_EXPL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->match->matrix[i][j]; CloneWise_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; } /* Finished calculating state MATCH */ /* For state SKIP_QUERY */ /* setting first movement to score */ score = CloneWise_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query_skip_start; /* From state SKIP_TARGET to state SKIP_QUERY */ temp = CloneWise_EXPL_MATRIX(mat,i-1,j-0,SKIP_TARGET) + mat->query_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_QUERY to state SKIP_QUERY */ temp = CloneWise_EXPL_MATRIX(mat,i-1,j-0,SKIP_QUERY) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state SKIP_QUERY */ temp = CloneWise_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_QUERY */ /* Add any movement independant score and put away */ score += mat->match->skip_iset[i]; CloneWise_EXPL_MATRIX(mat,i,j,SKIP_QUERY) = score; /* state SKIP_QUERY is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; } /* Finished calculating state SKIP_QUERY */ /* For state SKIP_TARGET */ /* setting first movement to score */ score = CloneWise_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->target_skip_start; /* From state SKIP_QUERY to state SKIP_TARGET */ temp = CloneWise_EXPL_MATRIX(mat,i-0,j-1,SKIP_QUERY) + mat->target_skip_start; if( temp > score ) { score = temp; } /* From state SKIP_TARGET to state SKIP_TARGET */ temp = CloneWise_EXPL_MATRIX(mat,i-0,j-1,SKIP_TARGET) + 0; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-0) == 0 && (j-1) == 0 ) { /* From state START to state SKIP_TARGET */ temp = CloneWise_EXPL_SPECIAL(mat,i-0,j-1,START) + mat->target_skip_start; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for SKIP_TARGET */ /* Add any movement independant score and put away */ score += mat->match->skip_jset[j]; CloneWise_EXPL_MATRIX(mat,i,j,SKIP_TARGET) = score; /* state SKIP_TARGET is a source for special TRUSTED_SPECIAL */ temp = score + (mat->target_special_s) + (0) ; if( temp > CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) ) { CloneWise_EXPL_SPECIAL(mat,i,j,TRUSTED_SPECIAL) = temp; } /* Finished calculating state SKIP_TARGET */ } /* Special state START has no special to special movements */ /* Special state TRUSTED_SPECIAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = CloneWise_EXPL_SPECIAL(mat,0,j,TRUSTED_SPECIAL); /* Source START is a special source for TRUSTED_SPECIAL */ /* Has restricted position */ if( (j-1) == 0 ) { temp = CloneWise_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source TRUSTED_SPECIAL is a special source for TRUSTED_SPECIAL */ temp = CloneWise_EXPL_SPECIAL(mat,0,j - 1,TRUSTED_SPECIAL) + ((mat->match->skip_jset[j]-1)) + (0); if( temp > score ) score = temp; /* Source MATCH for state TRUSTED_SPECIAL is not special... already calculated */ /* Source SKIP_QUERY for state TRUSTED_SPECIAL is not special... already calculated */ /* Source SKIP_TARGET for state TRUSTED_SPECIAL is not special... already calculated */ /* Put back score... (now updated!) */ CloneWise_EXPL_SPECIAL(mat,0,j,TRUSTED_SPECIAL) = score; /* Finished updating state TRUSTED_SPECIAL */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = CloneWise_EXPL_SPECIAL(mat,0,j,END); /* Source TRUSTED_SPECIAL is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = CloneWise_EXPL_SPECIAL(mat,0,j - 1,TRUSTED_SPECIAL) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ CloneWise_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: CloneWise_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CloneWise *] * */ CloneWise * CloneWise_alloc(void) { CloneWise * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CloneWise *) ckalloc (sizeof(CloneWise))) == NULL) { warn("CloneWise_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_CloneWise(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CloneWise *] * * Return [UNKN ] Undocumented return value [CloneWise *] * */ CloneWise * free_CloneWise(CloneWise * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CloneWise obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->q is linked in */ /* obj->t is linked in */ /* obj->match is linked in */ /* obj->target_skip_start is linked in */ /* obj->target_skip is linked in */ /* obj->query_skip_start is linked in */ /* obj->query_skip is linked in */ /* obj->spread is linked in */ /* obj->target_special_s is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/clonewisedp.h0000644000175000001440000005331110670453713016621 0ustar philippusers#ifndef DYNAMITEclonewisedpHEADERFILE #define DYNAMITEclonewisedpHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "mapstruct.h" struct Wise2_CloneWise { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; MappedCloneSet * q; MappedCloneSet * t; MappedCloneMatch* match; Score target_skip_start; Score target_skip; Score query_skip_start; Score query_skip; int spread; int target_special_s; } ; /* CloneWise defined */ #ifndef DYNAMITE_DEFINED_CloneWise typedef struct Wise2_CloneWise Wise2_CloneWise; #define CloneWise Wise2_CloneWise #define DYNAMITE_DEFINED_CloneWise #endif #ifdef PTHREAD struct thread_pool_holder_CloneWise { MappedCloneSet * q; /* Static query data: never free'd */ MappedCloneSet * t; /* Static target data: never free'd */ MappedCloneMatch* match; Score target_skip_start; Score target_skip; Score query_skip_start; Score query_skip; int spread; int target_special_s; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_CloneWise_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(CloneWise*,int,int,int); int (*access_special)(CloneWise*,int,int,int); } ; /* CloneWise_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_CloneWise_access_func_holder typedef struct Wise2_CloneWise_access_func_holder Wise2_CloneWise_access_func_holder; #define CloneWise_access_func_holder Wise2_CloneWise_access_func_holder #define DYNAMITE_DEFINED_CloneWise_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_CloneWise(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_CloneWise(CloneWise * mat); #define PackAln_read_Shatter_CloneWise Wise2_PackAln_read_Shatter_CloneWise /* Function: calculate_shatter_CloneWise(mat,dpenv) * * Descrip: This function calculates the CloneWise matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [CloneWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_CloneWise(CloneWise * mat,DPEnvelope * dpenv); #define calculate_shatter_CloneWise Wise2_calculate_shatter_CloneWise /* Function: search_CloneWise(dbsi,out,q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function makes a database search of CloneWise * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: t [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: match [UNKN ] Undocumented argument [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Undocumented argument [Score] * Arg: target_skip [UNKN ] Undocumented argument [Score] * Arg: query_skip_start [UNKN ] Undocumented argument [Score] * Arg: query_skip [UNKN ] Undocumented argument [Score] * Arg: spread [UNKN ] Undocumented argument [int] * Arg: target_special_s [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_CloneWise(DBSearchImpl * dbsi,Hscore * out,MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s); #define search_CloneWise Wise2_search_CloneWise /* Function: serial_search_CloneWise(out,q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function makes a database search of CloneWise * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: t [UNKN ] Undocumented argument [MappedCloneSet *] * Arg: match [UNKN ] Undocumented argument [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Undocumented argument [Score] * Arg: target_skip [UNKN ] Undocumented argument [Score] * Arg: query_skip_start [UNKN ] Undocumented argument [Score] * Arg: query_skip [UNKN ] Undocumented argument [Score] * Arg: spread [UNKN ] Undocumented argument [int] * Arg: target_special_s [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_CloneWise(Hscore * out,MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s); #define serial_search_CloneWise Wise2_serial_search_CloneWise /* Function: PackAln_bestmemory_CloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_CloneWise * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_CloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_CloneWise Wise2_PackAln_bestmemory_CloneWise /* Function: allocate_Expl_CloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s,dpri) * * Descrip: This function allocates the CloneWise structure * and the basematrix area for explicit memory implementations * It calls /allocate_CloneWise_only * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [CloneWise *] * */ CloneWise * Wise2_allocate_Expl_CloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s,DPRunImpl * dpri); #define allocate_Expl_CloneWise Wise2_allocate_Expl_CloneWise /* Function: recalculate_PackAln_CloneWise(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by CloneWise * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * */ void Wise2_recalculate_PackAln_CloneWise(PackAln * pal,CloneWise * mat); #define recalculate_PackAln_CloneWise Wise2_recalculate_PackAln_CloneWise /* Function: allocate_Small_CloneWise(q,t,match,target_skip_start,target_skip,query_skip_start,query_skip,spread,target_special_s) * * Descrip: This function allocates the CloneWise structure * and the basematrix area for a small memory implementations * It calls /allocate_CloneWise_only * * * Arg: q [UNKN ] query data structure [MappedCloneSet *] * Arg: t [UNKN ] target data structure [MappedCloneSet *] * Arg: match [UNKN ] Resource [MappedCloneMatch*] * Arg: target_skip_start [UNKN ] Resource [Score] * Arg: target_skip [UNKN ] Resource [Score] * Arg: query_skip_start [UNKN ] Resource [Score] * Arg: query_skip [UNKN ] Resource [Score] * Arg: spread [UNKN ] Resource [int] * Arg: target_special_s [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [CloneWise *] * */ CloneWise * Wise2_allocate_Small_CloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s); #define allocate_Small_CloneWise Wise2_allocate_Small_CloneWise /* Function: PackAln_calculate_Small_CloneWise(mat,dpenv) * * Descrip: This function calculates an alignment for CloneWise structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_CloneWise * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_CloneWise * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_CloneWise(CloneWise * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_CloneWise Wise2_PackAln_calculate_Small_CloneWise /* Function: AlnRangeSet_calculate_Small_CloneWise(mat) * * Descrip: This function calculates an alignment for CloneWise structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_CloneWise * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_CloneWise * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_CloneWise * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_CloneWise(CloneWise * mat); #define AlnRangeSet_calculate_Small_CloneWise Wise2_AlnRangeSet_calculate_Small_CloneWise /* Function: AlnRangeSet_from_CloneWise(mat) * * Descrip: This function reads off a start/end structure * for CloneWise structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_CloneWise * If you have not calculated the matrix use * /AlnRange_calculate_Small_CloneWise * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_CloneWise(CloneWise * mat); #define AlnRangeSet_from_CloneWise Wise2_AlnRangeSet_from_CloneWise /* Function: convert_PackAln_to_AlnBlock_CloneWise(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_CloneWise(PackAln * pal); #define convert_PackAln_to_AlnBlock_CloneWise Wise2_convert_PackAln_to_AlnBlock_CloneWise /* Function: PackAln_read_Expl_CloneWise(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_CloneWise(CloneWise * mat); #define PackAln_read_Expl_CloneWise Wise2_PackAln_read_Expl_CloneWise /* Function: PackAln_read_generic_CloneWise(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [CloneWise *] * Arg: h [UNKN ] Undocumented argument [CloneWise_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_CloneWise(CloneWise * mat,CloneWise_access_func_holder h); #define PackAln_read_generic_CloneWise Wise2_PackAln_read_generic_CloneWise /* Function: calculate_CloneWise(mat) * * Descrip: This function calculates the CloneWise matrix when in explicit mode * To allocate the matrix use /allocate_Expl_CloneWise * * * Arg: mat [UNKN ] CloneWise which contains explicit basematrix memory [CloneWise *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_CloneWise(CloneWise * mat); #define calculate_CloneWise Wise2_calculate_CloneWise /* Function: calculate_dpenv_CloneWise(mat,dpenv) * * Descrip: This function calculates the CloneWise matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] CloneWise which contains explicit basematrix memory [CloneWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_CloneWise(CloneWise * mat,DPEnvelope * dpenv); #define calculate_dpenv_CloneWise Wise2_calculate_dpenv_CloneWise /* Function: CloneWise_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CloneWise *] * */ CloneWise * Wise2_CloneWise_alloc(void); #define CloneWise_alloc Wise2_CloneWise_alloc /* Function: free_CloneWise(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CloneWise *] * * Return [UNKN ] Undocumented return value [CloneWise *] * */ CloneWise * Wise2_free_CloneWise(CloneWise * obj); #define free_CloneWise Wise2_free_CloneWise /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_CloneWise_shatter_access_main(CloneWise * mat,int i,int j,int state); #define CloneWise_shatter_access_main Wise2_CloneWise_shatter_access_main int Wise2_CloneWise_shatter_access_special(CloneWise * mat,int i,int j,int state); #define CloneWise_shatter_access_special Wise2_CloneWise_shatter_access_special void * Wise2_thread_loop_CloneWise(void * ptr); #define thread_loop_CloneWise Wise2_thread_loop_CloneWise int Wise2_score_only_CloneWise(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s); #define score_only_CloneWise Wise2_score_only_CloneWise CloneWise * Wise2_allocate_CloneWise_only(MappedCloneSet * q,MappedCloneSet * t ,MappedCloneMatch* match,Score target_skip_start,Score target_skip,Score query_skip_start,Score query_skip,int spread,int target_special_s); #define allocate_CloneWise_only Wise2_allocate_CloneWise_only void Wise2_init_CloneWise(CloneWise * mat); #define init_CloneWise Wise2_init_CloneWise AlnRange * Wise2_AlnRange_build_CloneWise(CloneWise * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_CloneWise Wise2_AlnRange_build_CloneWise boolean Wise2_read_hidden_CloneWise(CloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_CloneWise Wise2_read_hidden_CloneWise int Wise2_max_hidden_CloneWise(CloneWise * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_CloneWise Wise2_max_hidden_CloneWise boolean Wise2_read_special_strip_CloneWise(CloneWise * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_CloneWise Wise2_read_special_strip_CloneWise int Wise2_max_special_strip_CloneWise(CloneWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_CloneWise Wise2_max_special_strip_CloneWise int Wise2_max_matrix_to_special_CloneWise(CloneWise * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_CloneWise Wise2_max_matrix_to_special_CloneWise void Wise2_calculate_hidden_CloneWise(CloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_CloneWise Wise2_calculate_hidden_CloneWise void Wise2_init_hidden_CloneWise(CloneWise * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_CloneWise Wise2_init_hidden_CloneWise boolean Wise2_full_dc_CloneWise(CloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_CloneWise Wise2_full_dc_CloneWise boolean Wise2_do_dc_single_pass_CloneWise(CloneWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_CloneWise Wise2_do_dc_single_pass_CloneWise void Wise2_push_dc_at_merge_CloneWise(CloneWise * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_CloneWise Wise2_push_dc_at_merge_CloneWise void Wise2_follow_on_dc_CloneWise(CloneWise * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_CloneWise Wise2_follow_on_dc_CloneWise void Wise2_run_up_dc_CloneWise(CloneWise * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_CloneWise Wise2_run_up_dc_CloneWise void Wise2_init_dc_CloneWise(CloneWise * mat); #define init_dc_CloneWise Wise2_init_dc_CloneWise int Wise2_start_end_find_end_CloneWise(CloneWise * mat,int * endj); #define start_end_find_end_CloneWise Wise2_start_end_find_end_CloneWise boolean Wise2_dc_optimised_start_end_calc_CloneWise(CloneWise *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_CloneWise Wise2_dc_optimised_start_end_calc_CloneWise void Wise2_init_start_end_linear_CloneWise(CloneWise * mat); #define init_start_end_linear_CloneWise Wise2_init_start_end_linear_CloneWise AlnConvertSet * Wise2_AlnConvertSet_CloneWise(void); #define AlnConvertSet_CloneWise Wise2_AlnConvertSet_CloneWise int Wise2_CloneWise_explicit_access_main(CloneWise * mat,int i,int j,int state); #define CloneWise_explicit_access_main Wise2_CloneWise_explicit_access_main int Wise2_CloneWise_explicit_access_special(CloneWise * mat,int i,int j,int state); #define CloneWise_explicit_access_special Wise2_CloneWise_explicit_access_special int Wise2_find_end_CloneWise(CloneWise * mat,int * ri,int * rj,int * state,boolean * isspecial,CloneWise_access_func_holder h); #define find_end_CloneWise Wise2_find_end_CloneWise void Wise2_CloneWise_debug_show_matrix(CloneWise * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define CloneWise_debug_show_matrix Wise2_CloneWise_debug_show_matrix int Wise2_max_calc_CloneWise(CloneWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,CloneWise_access_func_holder h); #define max_calc_CloneWise Wise2_max_calc_CloneWise int Wise2_max_calc_special_CloneWise(CloneWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,CloneWise_access_func_holder h); #define max_calc_special_CloneWise Wise2_max_calc_special_CloneWise #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/pfamhmmer1db.c0000644000175000001440000006161710670453714016654 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "pfamhmmer1db.h" /* Function: ThreeStateModel_from_name_PfamHmmer1DB(phd,name) * * Descrip: reads a named model - akin to indexing * * * Arg: phd [UNKN ] Undocumented argument [PfamHmmer1DB *] * Arg: name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 53 "pfamhmmer1db.dy" ThreeStateModel * ThreeStateModel_from_name_PfamHmmer1DB(PfamHmmer1DB * phd,char * name) { char buffer[512]; ThreeStateModel * tsm; sprintf(buffer,"%s/%s.hmm",phd->dirname,name); /* tsm = Wise2_read_ThreeStateModel_from_hmmer1_file(buffer); */ tsm = HMMer2_read_ThreeStateModel(buffer); if( tsm == NULL ) { warn("Could not open Hmmer1 style hmm from Pfam db on file [%s]",buffer); return NULL; } if( tsm->name != NULL ) { ckfree(tsm->name); } tsm->name = stringalloc(name); /* ignore random stuff for the moment */ return tsm; } /* Function: read_next_TSM_PfamHmmer1DB(phd,return_status) * * Descrip: reads the next threestatemodel * for PfamHmmer1DB, placing the correct * status into return_status( DB_RETURN_OK, etc). * * * Arg: phd [UNKN ] Undocumented argument [PfamHmmer1DB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 83 "pfamhmmer1db.dy" ThreeStateModel * read_next_TSM_PfamHmmer1DB(PfamHmmer1DB * phd,int * return_status) { ThreeStateModel * out; if( phd->cur >= phd->len ) { *return_status = DB_RETURN_END; return NULL; } out = read_TSM_from_PfamHmmer1Entry(phd->en[phd->cur++],phd->dirname); if( out == NULL ) { *return_status = DB_RETURN_ERROR; return NULL; } else { *return_status = DB_RETURN_OK; out->rm = hard_link_RandomModel(phd->def); return out; } return out; } /* Function: read_TSM_from_PfamHmmer1Entry(en,dir) * * Descrip: reads an individual HMMer model from the entry * specification * * * Arg: en [UNKN ] Undocumented argument [PfamHmmer1Entry *] * Arg: dir [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 108 "pfamhmmer1db.dy" ThreeStateModel * read_TSM_from_PfamHmmer1Entry(PfamHmmer1Entry * en,char * dir) { char buffer[512]; ThreeStateModel * tsm; sprintf(buffer,"%s/%s.hmm",dir,en->entryname); /* tsm = Wise2_read_ThreeStateModel_from_hmmer1_file(buffer); */ tsm = HMMer2_read_ThreeStateModel(buffer); if( tsm == NULL ) { warn("Could not open Hmmer1 style hmm from Pfam db on file [%s]",buffer); return NULL; } if( tsm->name != NULL ) { ckfree(tsm->name); } tsm->name = stringalloc(en->entryname); display_char_in_ThreeStateModel(tsm); /* ignore random stuff for the moment */ if( en->is_hmmls == FALSE ) { force_weighted_local_model(tsm,1.0,1.0,1.0); } else { force_weighted_local_model(tsm,1.0,0.5,0.5); } return tsm; } /* Function: PfamHmmer1DB_from_dirname(dirname) * * Descrip: Makes a new PfamHmmer1DB from the dir name. * * The directory should have a file HMMs which has * entries like * * rrm hmmls 12 * * with -r indicating a specialised random model. * * * Arg: dirname [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [PfamHmmer1DB *] * */ # line 150 "pfamhmmer1db.dy" PfamHmmer1DB * PfamHmmer1DB_from_dirname(char * dirname) { char buffer[512]; PfamHmmer1DB * out; FILE * ifp; char * runner; PfamHmmer1Entry * en; if( dirname == NULL ) { warn("passed through a NULL dirname into PfamHmmer1DB!"); return NULL; } sprintf(buffer,"%s/HMMs",dirname); if( (ifp= openfile(buffer,"r")) == NULL ) { warn("Could not open %s as PfamHmmer1DB file list",buffer); return NULL; } out = PfamHmmer1DB_alloc_std(); out->def = default_RandomModel(); out->dirname = stringalloc(dirname); while( fgets(buffer,512,ifp) != NULL ) { if( (runner=strtok(buffer,spacestr)) == NULL) { continue; /* silently */ } en = PfamHmmer1Entry_alloc(); en->entryname = stringalloc(runner); if( (runner=strtok(NULL,spacestr)) == NULL) { warn("Got a bad HMM.s line for a Pfam db. Skipping"); free_PfamHmmer1Entry(en); continue; } if( strstr(runner,"hmmls") != NULL ) { en->is_hmmls = TRUE; } else { en->is_hmmls = FALSE; } if( strstr(runner,"-r") != NULL ) { en->is_random = TRUE; } else { en->is_random = FALSE; } if( (runner=strtok(NULL,spacestr)) == NULL) { warn("Got a bad HMM.s line for a Pfam db. Skipping"); free_PfamHmmer1Entry(en); continue; } if( is_double_string(runner,&en->bits_cutoff) == FALSE ) { warn("%s does not look like a bits cutoff to me. Calling it 25",en->entryname,runner); en->bits_cutoff = 25; } add_PfamHmmer1DB(out,en); } fclose(ifp); return out; } # line 198 "pfamhmmer1db.c" /* Function: hard_link_PfamHmmer1Entry(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PfamHmmer1Entry *] * * Return [UNKN ] Undocumented return value [PfamHmmer1Entry *] * */ PfamHmmer1Entry * hard_link_PfamHmmer1Entry(PfamHmmer1Entry * obj) { if( obj == NULL ) { warn("Trying to hard link to a PfamHmmer1Entry object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PfamHmmer1Entry_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PfamHmmer1Entry *] * */ PfamHmmer1Entry * PfamHmmer1Entry_alloc(void) { PfamHmmer1Entry * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PfamHmmer1Entry *) ckalloc (sizeof(PfamHmmer1Entry))) == NULL) { warn("PfamHmmer1Entry_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->entryname = NULL; out->is_random = FALSE; out->is_hmmls = FALSE; out->bits_cutoff = 0; return out; } /* Function: free_PfamHmmer1Entry(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PfamHmmer1Entry *] * * Return [UNKN ] Undocumented return value [PfamHmmer1Entry *] * */ PfamHmmer1Entry * free_PfamHmmer1Entry(PfamHmmer1Entry * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PfamHmmer1Entry obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->entryname != NULL) ckfree(obj->entryname); ckfree(obj); return NULL; } /* Function: swap_PfamHmmer1DB(list,i,j) * * Descrip: swap function: an internal for qsort_PfamHmmer1DB * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [PfamHmmer1Entry **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_PfamHmmer1DB(PfamHmmer1Entry ** list,int i,int j) { PfamHmmer1Entry * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_PfamHmmer1DB(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_PfamHmmer1DB which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [PfamHmmer1Entry **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_PfamHmmer1DB(PfamHmmer1Entry ** list,int left,int right,int (*comp)(PfamHmmer1Entry * ,PfamHmmer1Entry * )) { int i,last; if( left >= right ) return; swap_PfamHmmer1DB(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_PfamHmmer1DB (list,++last,i); } swap_PfamHmmer1DB (list,left,last); qsort_PfamHmmer1DB(list,left,last-1,comp); qsort_PfamHmmer1DB(list,last+1,right,comp); } /* Function: sort_PfamHmmer1DB(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_PfamHmmer1DB * * * Arg: obj [UNKN ] Object containing list [PfamHmmer1DB *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_PfamHmmer1DB(PfamHmmer1DB * obj,int (*comp)(PfamHmmer1Entry *, PfamHmmer1Entry *)) { qsort_PfamHmmer1DB(obj->en,0,obj->len-1,comp); return; } /* Function: expand_PfamHmmer1DB(obj,len) * * Descrip: Really an internal function for add_PfamHmmer1DB * * * Arg: obj [UNKN ] Object which contains the list [PfamHmmer1DB *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_PfamHmmer1DB(PfamHmmer1DB * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_PfamHmmer1DB called with no need"); return TRUE; } if( (obj->en = (PfamHmmer1Entry ** ) ckrealloc (obj->en,sizeof(PfamHmmer1Entry *)*len)) == NULL) { warn("ckrealloc failed for expand_PfamHmmer1DB, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_PfamHmmer1DB(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [PfamHmmer1DB *] * Arg: add [OWNER] Object to add to the list [PfamHmmer1Entry *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_PfamHmmer1DB(PfamHmmer1DB * obj,PfamHmmer1Entry * add) { if( obj->len >= obj->maxlen) { if( expand_PfamHmmer1DB(obj,obj->len + PfamHmmer1DBLISTLENGTH) == FALSE) return FALSE; } obj->en[obj->len++]=add; return TRUE; } /* Function: flush_PfamHmmer1DB(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [PfamHmmer1DB *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_PfamHmmer1DB(PfamHmmer1DB * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->en[i] != NULL) { free_PfamHmmer1Entry(obj->en[i]); obj->en[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: PfamHmmer1DB_alloc_std(void) * * Descrip: Equivalent to PfamHmmer1DB_alloc_len(PfamHmmer1DBLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [PfamHmmer1DB *] * */ PfamHmmer1DB * PfamHmmer1DB_alloc_std(void) { return PfamHmmer1DB_alloc_len(PfamHmmer1DBLISTLENGTH); } /* Function: PfamHmmer1DB_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [PfamHmmer1DB *] * */ PfamHmmer1DB * PfamHmmer1DB_alloc_len(int len) { PfamHmmer1DB * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = PfamHmmer1DB_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->en = (PfamHmmer1Entry ** ) ckcalloc (len,sizeof(PfamHmmer1Entry *))) == NULL) { warn("Warning, ckcalloc failed in PfamHmmer1DB_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_PfamHmmer1DB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PfamHmmer1DB *] * * Return [UNKN ] Undocumented return value [PfamHmmer1DB *] * */ PfamHmmer1DB * hard_link_PfamHmmer1DB(PfamHmmer1DB * obj) { if( obj == NULL ) { warn("Trying to hard link to a PfamHmmer1DB object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PfamHmmer1DB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PfamHmmer1DB *] * */ PfamHmmer1DB * PfamHmmer1DB_alloc(void) { PfamHmmer1DB * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PfamHmmer1DB *) ckalloc (sizeof(PfamHmmer1DB))) == NULL) { warn("PfamHmmer1DB_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->en = NULL; out->len = out->maxlen = 0; out->dirname = NULL; out->cur = 0; out->def = NULL; return out; } /* Function: free_PfamHmmer1DB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PfamHmmer1DB *] * * Return [UNKN ] Undocumented return value [PfamHmmer1DB *] * */ PfamHmmer1DB * free_PfamHmmer1DB(PfamHmmer1DB * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PfamHmmer1DB obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->en != NULL) { for(i=0;ilen;i++) { if( obj->en[i] != NULL) free_PfamHmmer1Entry(obj->en[i]); } ckfree(obj->en); } if( obj->dirname != NULL) ckfree(obj->dirname); if( obj->def != NULL) free_RandomModel(obj->def); ckfree(obj); return NULL; } /* Function: access_en_PfamHmmer1DB(obj,i) * * Descrip: Access members stored in the en list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [PfamHmmer1DB *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [PfamHmmer1Entry *] * */ PfamHmmer1Entry * access_en_PfamHmmer1DB(PfamHmmer1DB * obj,int i) { if( obj == NULL) { warn("In accessor function en for object PfamHmmer1DB, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function en for object PfamHmmer1DB, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->en[i]; } /* Function: length_en_PfamHmmer1DB(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [PfamHmmer1DB *] * * Return [UNKN ] length of the list [int] * */ int length_en_PfamHmmer1DB(PfamHmmer1DB * obj) { if( obj == NULL) { warn("In length function en for object PfamHmmer1DB, got a NULL object"); return -1; } return obj->len; } /* Function: replace_dirname_PfamHmmer1DB(obj,dirname) * * Descrip: Replace member variable dirname * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1DB *] * Arg: dirname [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable dirname [boolean] * */ boolean replace_dirname_PfamHmmer1DB(PfamHmmer1DB * obj,char * dirname) { if( obj == NULL) { warn("In replacement function dirname for object PfamHmmer1DB, got a NULL object"); return FALSE; } obj->dirname = dirname; return TRUE; } /* Function: access_dirname_PfamHmmer1DB(obj) * * Descrip: Access member variable dirname * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1DB *] * * Return [SOFT ] member variable dirname [char *] * */ char * access_dirname_PfamHmmer1DB(PfamHmmer1DB * obj) { if( obj == NULL) { warn("In accessor function dirname for object PfamHmmer1DB, got a NULL object"); return NULL; } return obj->dirname; } /* Function: replace_cur_PfamHmmer1DB(obj,cur) * * Descrip: Replace member variable cur * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1DB *] * Arg: cur [OWNER] New value of the variable [int] * * Return [SOFT ] member variable cur [boolean] * */ boolean replace_cur_PfamHmmer1DB(PfamHmmer1DB * obj,int cur) { if( obj == NULL) { warn("In replacement function cur for object PfamHmmer1DB, got a NULL object"); return FALSE; } obj->cur = cur; return TRUE; } /* Function: access_cur_PfamHmmer1DB(obj) * * Descrip: Access member variable cur * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1DB *] * * Return [SOFT ] member variable cur [int] * */ int access_cur_PfamHmmer1DB(PfamHmmer1DB * obj) { if( obj == NULL) { warn("In accessor function cur for object PfamHmmer1DB, got a NULL object"); return 0; } return obj->cur; } /* Function: replace_def_PfamHmmer1DB(obj,def) * * Descrip: Replace member variable def * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1DB *] * Arg: def [OWNER] New value of the variable [RandomModel *] * * Return [SOFT ] member variable def [boolean] * */ boolean replace_def_PfamHmmer1DB(PfamHmmer1DB * obj,RandomModel * def) { if( obj == NULL) { warn("In replacement function def for object PfamHmmer1DB, got a NULL object"); return FALSE; } obj->def = def; return TRUE; } /* Function: access_def_PfamHmmer1DB(obj) * * Descrip: Access member variable def * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1DB *] * * Return [SOFT ] member variable def [RandomModel *] * */ RandomModel * access_def_PfamHmmer1DB(PfamHmmer1DB * obj) { if( obj == NULL) { warn("In accessor function def for object PfamHmmer1DB, got a NULL object"); return NULL; } return obj->def; } /* Function: replace_entryname_PfamHmmer1Entry(obj,entryname) * * Descrip: Replace member variable entryname * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] * Arg: entryname [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable entryname [boolean] * */ boolean replace_entryname_PfamHmmer1Entry(PfamHmmer1Entry * obj,char * entryname) { if( obj == NULL) { warn("In replacement function entryname for object PfamHmmer1Entry, got a NULL object"); return FALSE; } obj->entryname = entryname; return TRUE; } /* Function: access_entryname_PfamHmmer1Entry(obj) * * Descrip: Access member variable entryname * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] * * Return [SOFT ] member variable entryname [char *] * */ char * access_entryname_PfamHmmer1Entry(PfamHmmer1Entry * obj) { if( obj == NULL) { warn("In accessor function entryname for object PfamHmmer1Entry, got a NULL object"); return NULL; } return obj->entryname; } /* Function: replace_is_random_PfamHmmer1Entry(obj,is_random) * * Descrip: Replace member variable is_random * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] * Arg: is_random [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable is_random [boolean] * */ boolean replace_is_random_PfamHmmer1Entry(PfamHmmer1Entry * obj,boolean is_random) { if( obj == NULL) { warn("In replacement function is_random for object PfamHmmer1Entry, got a NULL object"); return FALSE; } obj->is_random = is_random; return TRUE; } /* Function: access_is_random_PfamHmmer1Entry(obj) * * Descrip: Access member variable is_random * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] * * Return [SOFT ] member variable is_random [boolean] * */ boolean access_is_random_PfamHmmer1Entry(PfamHmmer1Entry * obj) { if( obj == NULL) { warn("In accessor function is_random for object PfamHmmer1Entry, got a NULL object"); return FALSE; } return obj->is_random; } /* Function: replace_is_hmmls_PfamHmmer1Entry(obj,is_hmmls) * * Descrip: Replace member variable is_hmmls * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] * Arg: is_hmmls [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable is_hmmls [boolean] * */ boolean replace_is_hmmls_PfamHmmer1Entry(PfamHmmer1Entry * obj,boolean is_hmmls) { if( obj == NULL) { warn("In replacement function is_hmmls for object PfamHmmer1Entry, got a NULL object"); return FALSE; } obj->is_hmmls = is_hmmls; return TRUE; } /* Function: access_is_hmmls_PfamHmmer1Entry(obj) * * Descrip: Access member variable is_hmmls * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] * * Return [SOFT ] member variable is_hmmls [boolean] * */ boolean access_is_hmmls_PfamHmmer1Entry(PfamHmmer1Entry * obj) { if( obj == NULL) { warn("In accessor function is_hmmls for object PfamHmmer1Entry, got a NULL object"); return FALSE; } return obj->is_hmmls; } /* Function: replace_bits_cutoff_PfamHmmer1Entry(obj,bits_cutoff) * * Descrip: Replace member variable bits_cutoff * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] * Arg: bits_cutoff [OWNER] New value of the variable [double] * * Return [SOFT ] member variable bits_cutoff [boolean] * */ boolean replace_bits_cutoff_PfamHmmer1Entry(PfamHmmer1Entry * obj,double bits_cutoff) { if( obj == NULL) { warn("In replacement function bits_cutoff for object PfamHmmer1Entry, got a NULL object"); return FALSE; } obj->bits_cutoff = bits_cutoff; return TRUE; } /* Function: access_bits_cutoff_PfamHmmer1Entry(obj) * * Descrip: Access member variable bits_cutoff * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PfamHmmer1Entry *] * * Return [SOFT ] member variable bits_cutoff [double] * */ double access_bits_cutoff_PfamHmmer1Entry(PfamHmmer1Entry * obj) { if( obj == NULL) { warn("In accessor function bits_cutoff for object PfamHmmer1Entry, got a NULL object"); return 0; } return obj->bits_cutoff; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/pfamhmmer1db.h0000644000175000001440000002544510670453714016660 0ustar philippusers#ifndef DYNAMITEpfamhmmer1dbHEADERFILE #define DYNAMITEpfamhmmer1dbHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "threestatemodel.h" #define NO_HMMER_INCLUDES #include "wise2xhmmer2.h" #define PfamHmmer1DBLISTLENGTH 512 struct Wise2_PfamHmmer1Entry { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * entryname; boolean is_random; boolean is_hmmls; double bits_cutoff; } ; /* PfamHmmer1Entry defined */ #ifndef DYNAMITE_DEFINED_PfamHmmer1Entry typedef struct Wise2_PfamHmmer1Entry Wise2_PfamHmmer1Entry; #define PfamHmmer1Entry Wise2_PfamHmmer1Entry #define DYNAMITE_DEFINED_PfamHmmer1Entry #endif /* Object PfamHmmer1DB * * Descrip: No Description * */ struct Wise2_PfamHmmer1DB { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif PfamHmmer1Entry ** en; int len;/* len for above en */ int maxlen; /* maxlen for above en */ char * dirname; /* directory name with the models */ int cur; RandomModel * def; /* default random model */ } ; /* PfamHmmer1DB defined */ #ifndef DYNAMITE_DEFINED_PfamHmmer1DB typedef struct Wise2_PfamHmmer1DB Wise2_PfamHmmer1DB; #define PfamHmmer1DB Wise2_PfamHmmer1DB #define DYNAMITE_DEFINED_PfamHmmer1DB #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: ThreeStateModel_from_name_PfamHmmer1DB(phd,name) * * Descrip: reads a named model - akin to indexing * * * Arg: phd [UNKN ] Undocumented argument [PfamHmmer1DB *] * Arg: name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_ThreeStateModel_from_name_PfamHmmer1DB(PfamHmmer1DB * phd,char * name); #define ThreeStateModel_from_name_PfamHmmer1DB Wise2_ThreeStateModel_from_name_PfamHmmer1DB /* Function: read_next_TSM_PfamHmmer1DB(phd,return_status) * * Descrip: reads the next threestatemodel * for PfamHmmer1DB, placing the correct * status into return_status( DB_RETURN_OK, etc). * * * Arg: phd [UNKN ] Undocumented argument [PfamHmmer1DB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_read_next_TSM_PfamHmmer1DB(PfamHmmer1DB * phd,int * return_status); #define read_next_TSM_PfamHmmer1DB Wise2_read_next_TSM_PfamHmmer1DB /* Function: read_TSM_from_PfamHmmer1Entry(en,dir) * * Descrip: reads an individual HMMer model from the entry * specification * * * Arg: en [UNKN ] Undocumented argument [PfamHmmer1Entry *] * Arg: dir [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_read_TSM_from_PfamHmmer1Entry(PfamHmmer1Entry * en,char * dir); #define read_TSM_from_PfamHmmer1Entry Wise2_read_TSM_from_PfamHmmer1Entry /* Function: PfamHmmer1DB_from_dirname(dirname) * * Descrip: Makes a new PfamHmmer1DB from the dir name. * * The directory should have a file HMMs which has * entries like * * rrm hmmls 12 * * with -r indicating a specialised random model. * * * Arg: dirname [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [PfamHmmer1DB *] * */ PfamHmmer1DB * Wise2_PfamHmmer1DB_from_dirname(char * dirname); #define PfamHmmer1DB_from_dirname Wise2_PfamHmmer1DB_from_dirname /* Function: hard_link_PfamHmmer1Entry(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PfamHmmer1Entry *] * * Return [UNKN ] Undocumented return value [PfamHmmer1Entry *] * */ PfamHmmer1Entry * Wise2_hard_link_PfamHmmer1Entry(PfamHmmer1Entry * obj); #define hard_link_PfamHmmer1Entry Wise2_hard_link_PfamHmmer1Entry /* Function: PfamHmmer1Entry_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PfamHmmer1Entry *] * */ PfamHmmer1Entry * Wise2_PfamHmmer1Entry_alloc(void); #define PfamHmmer1Entry_alloc Wise2_PfamHmmer1Entry_alloc /* Function: free_PfamHmmer1Entry(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PfamHmmer1Entry *] * * Return [UNKN ] Undocumented return value [PfamHmmer1Entry *] * */ PfamHmmer1Entry * Wise2_free_PfamHmmer1Entry(PfamHmmer1Entry * obj); #define free_PfamHmmer1Entry Wise2_free_PfamHmmer1Entry /* Function: add_PfamHmmer1DB(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [PfamHmmer1DB *] * Arg: add [OWNER] Object to add to the list [PfamHmmer1Entry *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_PfamHmmer1DB(PfamHmmer1DB * obj,PfamHmmer1Entry * add); #define add_PfamHmmer1DB Wise2_add_PfamHmmer1DB /* Function: flush_PfamHmmer1DB(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [PfamHmmer1DB *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_PfamHmmer1DB(PfamHmmer1DB * obj); #define flush_PfamHmmer1DB Wise2_flush_PfamHmmer1DB /* Function: PfamHmmer1DB_alloc_std(void) * * Descrip: Equivalent to PfamHmmer1DB_alloc_len(PfamHmmer1DBLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [PfamHmmer1DB *] * */ PfamHmmer1DB * Wise2_PfamHmmer1DB_alloc_std(void); #define PfamHmmer1DB_alloc_std Wise2_PfamHmmer1DB_alloc_std /* Function: PfamHmmer1DB_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [PfamHmmer1DB *] * */ PfamHmmer1DB * Wise2_PfamHmmer1DB_alloc_len(int len); #define PfamHmmer1DB_alloc_len Wise2_PfamHmmer1DB_alloc_len /* Function: hard_link_PfamHmmer1DB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PfamHmmer1DB *] * * Return [UNKN ] Undocumented return value [PfamHmmer1DB *] * */ PfamHmmer1DB * Wise2_hard_link_PfamHmmer1DB(PfamHmmer1DB * obj); #define hard_link_PfamHmmer1DB Wise2_hard_link_PfamHmmer1DB /* Function: PfamHmmer1DB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PfamHmmer1DB *] * */ PfamHmmer1DB * Wise2_PfamHmmer1DB_alloc(void); #define PfamHmmer1DB_alloc Wise2_PfamHmmer1DB_alloc /* Function: free_PfamHmmer1DB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PfamHmmer1DB *] * * Return [UNKN ] Undocumented return value [PfamHmmer1DB *] * */ PfamHmmer1DB * Wise2_free_PfamHmmer1DB(PfamHmmer1DB * obj); #define free_PfamHmmer1DB Wise2_free_PfamHmmer1DB /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_access_cur_PfamHmmer1DB(PfamHmmer1DB * obj); #define access_cur_PfamHmmer1DB Wise2_access_cur_PfamHmmer1DB boolean Wise2_replace_def_PfamHmmer1DB(PfamHmmer1DB * obj,RandomModel * def); #define replace_def_PfamHmmer1DB Wise2_replace_def_PfamHmmer1DB RandomModel * Wise2_access_def_PfamHmmer1DB(PfamHmmer1DB * obj); #define access_def_PfamHmmer1DB Wise2_access_def_PfamHmmer1DB boolean Wise2_replace_entryname_PfamHmmer1Entry(PfamHmmer1Entry * obj,char * entryname); #define replace_entryname_PfamHmmer1Entry Wise2_replace_entryname_PfamHmmer1Entry PfamHmmer1Entry * Wise2_access_en_PfamHmmer1DB(PfamHmmer1DB * obj,int i); #define access_en_PfamHmmer1DB Wise2_access_en_PfamHmmer1DB char * Wise2_access_entryname_PfamHmmer1Entry(PfamHmmer1Entry * obj); #define access_entryname_PfamHmmer1Entry Wise2_access_entryname_PfamHmmer1Entry boolean Wise2_replace_dirname_PfamHmmer1DB(PfamHmmer1DB * obj,char * dirname); #define replace_dirname_PfamHmmer1DB Wise2_replace_dirname_PfamHmmer1DB boolean Wise2_replace_is_random_PfamHmmer1Entry(PfamHmmer1Entry * obj,boolean is_random); #define replace_is_random_PfamHmmer1Entry Wise2_replace_is_random_PfamHmmer1Entry boolean Wise2_replace_cur_PfamHmmer1DB(PfamHmmer1DB * obj,int cur); #define replace_cur_PfamHmmer1DB Wise2_replace_cur_PfamHmmer1DB boolean Wise2_access_is_random_PfamHmmer1Entry(PfamHmmer1Entry * obj); #define access_is_random_PfamHmmer1Entry Wise2_access_is_random_PfamHmmer1Entry int Wise2_length_en_PfamHmmer1DB(PfamHmmer1DB * obj); #define length_en_PfamHmmer1DB Wise2_length_en_PfamHmmer1DB boolean Wise2_replace_is_hmmls_PfamHmmer1Entry(PfamHmmer1Entry * obj,boolean is_hmmls); #define replace_is_hmmls_PfamHmmer1Entry Wise2_replace_is_hmmls_PfamHmmer1Entry double Wise2_access_bits_cutoff_PfamHmmer1Entry(PfamHmmer1Entry * obj); #define access_bits_cutoff_PfamHmmer1Entry Wise2_access_bits_cutoff_PfamHmmer1Entry boolean Wise2_access_is_hmmls_PfamHmmer1Entry(PfamHmmer1Entry * obj); #define access_is_hmmls_PfamHmmer1Entry Wise2_access_is_hmmls_PfamHmmer1Entry char * Wise2_access_dirname_PfamHmmer1DB(PfamHmmer1DB * obj); #define access_dirname_PfamHmmer1DB Wise2_access_dirname_PfamHmmer1DB boolean Wise2_replace_bits_cutoff_PfamHmmer1Entry(PfamHmmer1Entry * obj,double bits_cutoff); #define replace_bits_cutoff_PfamHmmer1Entry Wise2_replace_bits_cutoff_PfamHmmer1Entry void Wise2_swap_PfamHmmer1DB(PfamHmmer1Entry ** list,int i,int j) ; #define swap_PfamHmmer1DB Wise2_swap_PfamHmmer1DB void Wise2_qsort_PfamHmmer1DB(PfamHmmer1Entry ** list,int left,int right,int (*comp)(PfamHmmer1Entry * ,PfamHmmer1Entry * )); #define qsort_PfamHmmer1DB Wise2_qsort_PfamHmmer1DB void Wise2_sort_PfamHmmer1DB(PfamHmmer1DB * obj,int (*comp)(PfamHmmer1Entry *, PfamHmmer1Entry *)); #define sort_PfamHmmer1DB Wise2_sort_PfamHmmer1DB boolean Wise2_expand_PfamHmmer1DB(PfamHmmer1DB * obj,int len); #define expand_PfamHmmer1DB Wise2_expand_PfamHmmer1DB #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/dnaalign.pod0000644000175000001440000000406710670453713016421 0ustar philippusers=head1 NAME dnaalign module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item DnaStartEnd =back =head1 DESCRIPTION =head2 Object DnaStartEnd =over =item trans[DSE_NUMBER] Type [int] Scalar start/end points possibilities =back No documentation for DnaStartEnd =head2 Member functions of DnaStartEnd =over =item hard_link_DnaStartEnd &Wise2::DnaStartEnd::hard_link_DnaStartEnd(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [DnaStartEnd *] Return [UNKN ] Undocumented return value [DnaStartEnd *] =item alloc &Wise2::DnaStartEnd::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [DnaStartEnd *] =back =over =item make_align_dnaalign &Wise2::make_align_dnaalign(one,two,mat,se,qgap,qext,tgap,text,dpri) Makes an alignment out of two DNA sequences Argument one [READ ] first sequence to align [Sequence *] Argument two [READ ] second sequence to align [Sequence *] Argument mat [READ ] DnaMatrix for the matching [DnaMatrix *] Argument se [READ ] DnaStartEnd policy [DnaStartEnd *] Argument qgap [READ ] gap open penalty in query (one) coordinate [int] Argument qext [READ ] gap extension penalty in query (one) coordinate [int] Argument tgap [READ ] gap open penalty in target (two) coordinate [int] Argument text [READ ] gap extension penalty in target (two) coordinate [int] Argument dpri [READ ] DPRunImpl structure [DPRunImpl *] Return [UNKN ] an alb structure of the alignment [AlnBlock *] =item DnaStartEnd_from_policy &Wise2::DnaStartEnd_from_policy(policy) Makes a DnaStartEnd from a particular string. Possible strings are: local - fully local global - fully global edge - aligns only to edges Argument policy [UNKN ] Undocumented argument [char *] Return [UNKN ] Undocumented return value [DnaStartEnd *] =back wise-2.4.1/src/models/dnaalign.tex0000644000175000001440000000406510670453713016435 0ustar philippusers\section{dnaalign} \label{module_dnaalign} This module contains the following objects \begin{itemize} \item \ref{object_DnaStartEnd} DnaStartEnd \item This module also contains some factory methods \end{itemize} \subsection{dnaalign factory methods} \subsubsection{make_align_dnaalign} \begin{description} \item[External C] {\tt Wise2_make_align_dnaalign (one,two,mat,se,qgap,qext,tgap,text,dpri)} \item[Perl] {\tt &Wise2::make_align_dnaalign (one,two,mat,se,qgap,qext,tgap,text,dpri)} \end{description} Arguments \begin{description} \item[one] [READ ] first sequence to align [Sequence *] \item[two] [READ ] second sequence to align [Sequence *] \item[mat] [READ ] DnaMatrix for the matching [DnaMatrix *] \item[se] [READ ] DnaStartEnd policy [DnaStartEnd *] \item[qgap] [READ ] gap open penalty in query (one) coordinate [int] \item[qext] [READ ] gap extension penalty in query (one) coordinate [int] \item[tgap] [READ ] gap open penalty in target (two) coordinate [int] \item[text] [READ ] gap extension penalty in target (two) coordinate [int] \item[dpri] [READ ] DPRunImpl structure [DPRunImpl *] \item[returns] [UNKN ] an alb structure of the alignment [AlnBlock *] \end{description} Makes an alignment out of two DNA sequences \subsubsection{DnaStartEnd_from_policy} \begin{description} \item[External C] {\tt Wise2_DnaStartEnd_from_policy (policy)} \item[Perl] {\tt &Wise2::DnaStartEnd_from_policy (policy)} \end{description} Arguments \begin{description} \item[policy] [UNKN ] Undocumented argument [char *] \item[returns] [UNKN ] Undocumented return value [DnaStartEnd *] \end{description} Makes a DnaStartEnd from a particular string. Possible strings are: local - fully local global - fully global edge - aligns only to edges \subsection{Object DnaStartEnd} \label{object_DnaStartEnd} The DnaStartEnd object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{trans[DSE_NUMBER]} Type [int : Scalar] start/end points possibilities \end{description} No documentation for DnaStartEnd Member functions of DnaStartEnd wise-2.4.1/src/models/threestatemodel.typemap0000644000175000001440000000104210670453715020722 0ustar philippusers TYPEMAP Wise2_ThreeStateModel * T_Wise2_ThreeStateModel INPUT T_Wise2_ThreeStateModel $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_ThreeStateModel *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_ThreeStateModel sv_setref_pv($arg, "Wise2::ThreeStateModel", (void*) $var); TYPEMAP Wise2_ThreeStateUnit * T_Wise2_ThreeStateUnit INPUT T_Wise2_ThreeStateUnit $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_ThreeStateUnit *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_ThreeStateUnit sv_setref_pv($arg, "Wise2::ThreeStateUnit", (void*) $var); wise-2.4.1/src/models/editdistdp.c0000644000175000001440000033261110670453713016440 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "editdistdp.h" # line 71 "editdistdp.dy" EditString * new_EditString(char * string) { EditString * out; out = EditString_alloc(); out->string = stringalloc(string); out->len = strlen(string); return out; } # line 18 "editdistdp.c" /* Function: hard_link_EditString(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EditString *] * * Return [UNKN ] Undocumented return value [EditString *] * */ EditString * hard_link_EditString(EditString * obj) { if( obj == NULL ) { warn("Trying to hard link to a EditString object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: EditString_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EditString *] * */ EditString * EditString_alloc(void) { EditString * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EditString *) ckalloc (sizeof(EditString))) == NULL) { warn("EditString_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->string = NULL; out->len = 0; return out; } /* Function: free_EditString(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EditString *] * * Return [UNKN ] Undocumented return value [EditString *] * */ EditString * free_EditString(EditString * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EditString obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->string != NULL) ckfree(obj->string); ckfree(obj); return NULL; } /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define START 0 #define END 1 #define EditDistance_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*1)+STATE][i+1] #define EditDistance_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define EditDistance_READ_OFF_ERROR -3 #define EditDistance_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*1)+STATE] #define EditDistance_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define EditDistance_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define EditDistance_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_EditDistance(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_EditDistance(EditDistance * mat) { EditDistance_access_func_holder holder; holder.access_main = EditDistance_shatter_access_main; holder.access_special = EditDistance_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_EditDistance(mat,holder); } /* Function: EditDistance_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EditDistance_shatter_access_main(EditDistance * mat,int i,int j,int state) { return EditDistance_SHATTER_MATRIX(mat,i,j,state); } /* Function: EditDistance_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EditDistance_shatter_access_special(EditDistance * mat,int i,int j,int state) { return EditDistance_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_EditDistance(mat,dpenv) * * Descrip: This function calculates the EditDistance matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EditDistance *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_EditDistance(EditDistance * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,1,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("EditDistance Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_1[MATCH] + EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch); /* From state MATCH to state MATCH */ temp = SIG_0_1[MATCH] + mat->gap; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_0[MATCH] + mat->gap; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = EditDistance_SHATTER_SPECIAL(mat,i-1,j-1,START) + EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch); if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-0) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = EditDistance_SHATTER_SPECIAL(mat,i-0,j-1,START) + mat->gap; if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state MATCH */ temp = EditDistance_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->gap; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > EditDistance_SHATTER_SPECIAL(mat,i,j,END) ) { EditDistance_SHATTER_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_EditDistance(dbsi,out,q,t,match,mismatch,gap) * * Descrip: This function makes a database search of EditDistance * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [EditString*] * Arg: t [UNKN ] Undocumented argument [EditString*] * Arg: match [UNKN ] Undocumented argument [int] * Arg: mismatch [UNKN ] Undocumented argument [int] * Arg: gap [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_EditDistance(DBSearchImpl * dbsi,Hscore * out,EditString* q,EditString* t ,int match,int mismatch,int gap) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_EditDistance * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_EditDistance. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_EditDistance. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for EditDistance, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_EditDistance(out,q,t ,match,mismatch,gap); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_EditDistance *) ckalloc(sizeof(struct thread_pool_holder_EditDistance)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->q = q; holder->t = t; holder->match = match; holder->mismatch = mismatch; holder->gap = gap; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_EditDistance,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for EditDistance"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from EditDistance",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_EditDistance(ptr) * * Descrip: dummy loop code foreach thread for EditDistance * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * thread_loop_EditDistance(void * ptr) { fatal("dummy thread loop function"); } /* Function: serial_search_EditDistance(out,q,t,match,mismatch,gap) * * Descrip: This function makes a database search of EditDistance * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [EditString*] * Arg: t [UNKN ] Undocumented argument [EditString*] * Arg: match [UNKN ] Undocumented argument [int] * Arg: mismatch [UNKN ] Undocumented argument [int] * Arg: gap [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_EditDistance(Hscore * out,EditString* q,EditString* t ,int match,int mismatch,int gap) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_EditDistance(q, t , match, mismatch, gap); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("EditDistance search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_EditDistance(q,t,match,mismatch,gap) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_EditDistance_only * * * Arg: q [UNKN ] query data structure [EditString*] * Arg: t [UNKN ] target data structure [EditString*] * Arg: match [UNKN ] Resource [int] * Arg: mismatch [UNKN ] Resource [int] * Arg: gap [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_EditDistance(EditString* q,EditString* t ,int match,int mismatch,int gap) { int bestscore = NEGI; int i; int j; int k; EditDistance * mat; mat = allocate_EditDistance_only(q, t , match, mismatch, gap); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 1,2,2)) == NULL) { warn("Score only matrix for EditDistance cannot be allocated, (asking for 1 by %d cells)",mat->leni*1); mat = free_EditDistance(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<1;k++) EditDistance_VSMALL_MATRIX(mat,i,j,k) = NEGI; } EditDistance_VSMALL_SPECIAL(mat,i,j,START) = 0; EditDistance_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = EditDistance_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch); /* From state MATCH to state MATCH */ temp = EditDistance_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EditDistance_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = EditDistance_VSMALL_SPECIAL(mat,i-1,j-1,START) + EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch); if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-0) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = EditDistance_VSMALL_SPECIAL(mat,i-0,j-1,START) + mat->gap; if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state MATCH */ temp = EditDistance_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->gap; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EditDistance_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > EditDistance_VSMALL_SPECIAL(mat,i,j,END) ) { EditDistance_VSMALL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < EditDistance_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = EditDistance_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_EditDistance(mat); return bestscore; } /* Function: PackAln_bestmemory_EditDistance(q,t,match,mismatch,gap,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EditDistance * * * Arg: q [UNKN ] query data structure [EditString*] * Arg: t [UNKN ] target data structure [EditString*] * Arg: match [UNKN ] Resource [int] * Arg: mismatch [UNKN ] Resource [int] * Arg: gap [UNKN ] Resource [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_EditDistance(EditString* q,EditString* t ,int match,int mismatch,int gap,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; EditDistance * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = q->len * t->len; if( dpri->memory == DPIM_Default ) { if( (total * 1 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_EditDistance(q, t , match, mismatch, gap,dpri)) == NULL ) { warn("Unable to allocate large EditDistance version"); return NULL; } calculate_dpenv_EditDistance(mat,dpenv); out = PackAln_read_Expl_EditDistance(mat); } else { mat = allocate_EditDistance_only(q, t , match, mismatch, gap); calculate_shatter_EditDistance(mat,dpenv); out = PackAln_read_Shatter_EditDistance(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_EditDistance(q, t , match, mismatch, gap)) == NULL ) { warn("Unable to allocate small EditDistance version"); return NULL; } out = PackAln_calculate_Small_EditDistance(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_EditDistance(q, t , match, mismatch, gap,dpri)) == NULL ) { warn("Unable to allocate large EditDistance version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_EditDistance(mat); out = PackAln_read_Expl_EditDistance(mat); } } } mat = free_EditDistance(mat); return out; } /* Function: allocate_EditDistance_only(q,t,match,mismatch,gap) * * Descrip: This function only allocates the EditDistance structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: q [UNKN ] query data structure [EditString*] * Arg: t [UNKN ] target data structure [EditString*] * Arg: match [UNKN ] Resource [int] * Arg: mismatch [UNKN ] Resource [int] * Arg: gap [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [EditDistance *] * */ EditDistance * allocate_EditDistance_only(EditString* q,EditString* t ,int match,int mismatch,int gap) { EditDistance * out; if((out= EditDistance_alloc()) == NULL) { warn("Allocation of basic EditDistance structure failed..."); return NULL; } out->q = q; out->t = t; out->match = match; out->mismatch = mismatch; out->gap = gap; out->leni = q->len; out->lenj = t->len; return out; } /* Function: allocate_Expl_EditDistance(q,t,match,mismatch,gap,dpri) * * Descrip: This function allocates the EditDistance structure * and the basematrix area for explicit memory implementations * It calls /allocate_EditDistance_only * * * Arg: q [UNKN ] query data structure [EditString*] * Arg: t [UNKN ] target data structure [EditString*] * Arg: match [UNKN ] Resource [int] * Arg: mismatch [UNKN ] Resource [int] * Arg: gap [UNKN ] Resource [int] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EditDistance *] * */ EditDistance * allocate_Expl_EditDistance(EditString* q,EditString* t ,int match,int mismatch,int gap,DPRunImpl * dpri) { EditDistance * out; out = allocate_EditDistance_only(q, t , match, mismatch, gap); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*1 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*1,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix EditDistance cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_EditDistance(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_EditDistance(out); return out; } /* Function: init_EditDistance(mat) * * Descrip: This function initates EditDistance matrix when in explicit mode * Called in /allocate_Expl_EditDistance * * * Arg: mat [UNKN ] EditDistance which contains explicit basematrix memory [EditDistance *] * */ void init_EditDistance(EditDistance * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iq->len;i++) { for(j= (-1);j<2;j++) { EditDistance_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; } } for(j= (-1);jt->len;j++) { for(i= (-1);i<2;i++) { EditDistance_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; } EditDistance_EXPL_SPECIAL(mat,i,j,START) = 0; EditDistance_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_EditDistance(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EditDistance * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * */ void recalculate_PackAln_EditDistance(PackAln * pal,EditDistance * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = mat->gap + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->gap + (0); continue; } if( offj == 1 && prev->state == (START+1) ) { pau->score = EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch) + (0); continue; } if( offj == 1 && prev->state == (START+1) ) { pau->score = mat->gap + (0); continue; } if( offj == 0 && prev->state == (START+1) ) { pau->score = mat->gap + (0); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+1) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+1) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define EditDistance_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*1+state]) #define EditDistance_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*1+state]) #define EditDistance_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define EditDistance_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define EditDistance_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*1 + state]) #define EditDistance_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define EditDistance_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 1) + ((i+1) * 1) + (state)]) #define EditDistance_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 8) + ((i+1) * 8) + (state * 8) + shadow+1]) #define EditDistance_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_EditDistance(q,t,match,mismatch,gap) * * Descrip: This function allocates the EditDistance structure * and the basematrix area for a small memory implementations * It calls /allocate_EditDistance_only * * * Arg: q [UNKN ] query data structure [EditString*] * Arg: t [UNKN ] target data structure [EditString*] * Arg: match [UNKN ] Resource [int] * Arg: mismatch [UNKN ] Resource [int] * Arg: gap [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [EditDistance *] * */ #define EditDistance_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) EditDistance * allocate_Small_EditDistance(EditString* q,EditString* t ,int match,int mismatch,int gap) { EditDistance * out; out = allocate_EditDistance_only(q, t , match, mismatch, gap); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 1,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix EditDistance cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_EditDistance(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_EditDistance(mat,dpenv) * * Descrip: This function calculates an alignment for EditDistance structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EditDistance * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EditDistance * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_EditDistance(EditDistance * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for EditDistance due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_EditDistance(mat,dpenv); score = start_end_find_end_EditDistance(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_EditDistance(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_EditDistance(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == EditDistance_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_EditDistance(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 1; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_EditDistance(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_EditDistance(mat) * * Descrip: This function calculates an alignment for EditDistance structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EditDistance * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EditDistance * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EditDistance * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_EditDistance(EditDistance * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_EditDistance(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_EditDistance(mat); return out; } /* Function: AlnRangeSet_from_EditDistance(mat) * * Descrip: This function reads off a start/end structure * for EditDistance structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EditDistance * If you have not calculated the matrix use * /AlnRange_calculate_Small_EditDistance * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_EditDistance(EditDistance * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EditDistance"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_EditDistance(mat,&jpos); state = END; while( (temp = AlnRange_build_EditDistance(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_EditDistance(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_EditDistance * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_EditDistance(EditDistance * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EditDistance"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_EditDistance(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_EditDistance alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = EditDistance_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_EditDistance(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == EditDistance_READ_OFF_ERROR) { warn("In AlnRange_build_EditDistance alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = EditDistance_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_EditDistance(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_EditDistance(EditDistance * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_EditDistance(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EditDistance_READ_OFF_ERROR) { warn("In EditDistance hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In EditDistance hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In EditDistance hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_EditDistance(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_EditDistance(EditDistance * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EditDistance_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->q->len || j > mat->t->len) { warn("In EditDistance matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = EditDistance_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Not allowing special sources.. skipping START */ /* Not allowing special sources.. skipping START */ /* Not allowing special sources.. skipping START */ temp = cscore - (mat->gap) - (0); if( temp == EditDistance_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EditDistance_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return EditDistance_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } temp = cscore - (mat->gap) - (0); if( temp == EditDistance_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EditDistance_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return EditDistance_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } temp = cscore - (EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch)) - (0); if( temp == EditDistance_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EditDistance_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return EditDistance_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in EditDistance read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EditDistance read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_EditDistance(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_EditDistance(EditDistance * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > EditDistance_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 1; add_PackAln(out,pau); } max_special_strip_EditDistance(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EditDistance_READ_OFF_ERROR) { warn("In special strip read EditDistance, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < EditDistance_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read EditDistance, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 1; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_EditDistance(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_EditDistance(EditDistance * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = EditDistance_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for EditDistance, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->t->len) { warn("In EditDistance matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = EditDistance_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source MATCH is not a special */ default: warn("Major problem (!) - in EditDistance special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_EditDistance(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_EditDistance(EditDistance * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = EditDistance_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In EditDistance matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gap) - (0); if( temp == EditDistance_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EditDistance_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return EditDistance_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } temp = cscore - (mat->gap) - (0); if( temp == EditDistance_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EditDistance_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return EditDistance_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } temp = cscore - (EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch)) - (0); if( temp == EditDistance_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EditDistance_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return EditDistance_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EditDistance matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EditDistance read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_EditDistance(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_EditDistance(EditDistance * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_EditDistance(mat,starti,startj,stopi,stopj); EditDistance_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EditDistance_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = EditDistance_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch); /* From state MATCH to state MATCH */ temp = EditDistance_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EditDistance_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EditDistance_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ } } return; } /* Function: init_hidden_EditDistance(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_EditDistance(EditDistance * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { EditDistance_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; } } return; } /* Function: full_dc_EditDistance(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_EditDistance * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_EditDistance to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [EditDistance *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_EditDistance(EditDistance * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_EditDistance"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_EditDistance(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_EditDistance(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_EditDistance(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for EditDistance, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= EditDistance_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= EditDistance_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = EditDistance_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_EditDistance(mat,EditDistance_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),EditDistance_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),EditDistance_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_EditDistance(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_EditDistance(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_EditDistance(EditDistance * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_EditDistance(mat); EditDistance_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_EditDistance(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_EditDistance(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_EditDistance(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_EditDistance(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_EditDistance(EditDistance * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EditDistance_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = EditDistance_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch); if( j - 1 <= mergej) { EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EditDistance_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } temp = EditDistance_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; if( temp > score) { score = temp; if( j - 1 <= mergej) { EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-0; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EditDistance_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } } temp = EditDistance_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; if( temp > score) { score = temp; if( j - 0 <= mergej) { EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-0; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EditDistance_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } } /* Add any movement independant score */ EditDistance_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_EditDistance(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_EditDistance(EditDistance * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EditDistance_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EditDistance_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EditDistance_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); /* From state MATCH to state MATCH */ temp = EditDistance_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EditDistance_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } /* From state MATCH to state MATCH */ temp = EditDistance_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EditDistance_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EditDistance_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_EditDistance(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_EditDistance(EditDistance * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EditDistance_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EditDistance_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch); /* From state MATCH to state MATCH */ temp = EditDistance_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EditDistance_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EditDistance_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_EditDistance(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * */ } void init_dc_EditDistance(EditDistance * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iq->len;i++) { EditDistance_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; for(k=0;k<7;k++) { EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); } } } return; } /* Function: start_end_find_end_EditDistance(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [EditDistance *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_EditDistance(EditDistance * mat,int * endj) { register int j; register int max; register int maxj; max = EditDistance_DC_SHADOW_SPECIAL(mat,0,mat->t->len-1,END); maxj = mat->t->len-1; for(j= mat->t->len-2 ;j >= 0 ;j--) { if( EditDistance_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = EditDistance_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_EditDistance(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [EditDistance] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_EditDistance(EditDistance *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->q->len; lenj = mat->t->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 1,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 1 * 8,sizeof(int)); for(j=0;jq->string[i],mat->t->string[j],mat->match,mat->mismatch) + (0); /* assign local shadown pointer */ localsp = &(EditDistance_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); /* From state MATCH to state MATCH */ temp = EditDistance_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gap +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EditDistance_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); } /* From state MATCH to state MATCH */ temp = EditDistance_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->gap +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EditDistance_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); } /* From state START to state MATCH */ temp = EditDistance_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state START to state MATCH */ temp = EditDistance_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,START) + mat->gap + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state START to state MATCH */ temp = EditDistance_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->gap + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EditDistance_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EditDistance_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > EditDistance_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EditDistance_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EditDistance_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EditDistance_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); EditDistance_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EditDistance_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); EditDistance_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EditDistance_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EditDistance_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_EditDistance(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * */ void init_start_end_linear_EditDistance(EditDistance * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iq->len;i++) { EditDistance_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EditDistance_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); } } for(j=(-1);jt->len;j++) { EditDistance_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; EditDistance_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; EditDistance_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_EditDistance(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_EditDistance(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_EditDistance(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "SEQUENCE","INSERT","END" }; /* Function: AlnConvertSet_EditDistance(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "SEQUENCE","INSERT","END" }; AlnConvertSet * AlnConvertSet_EditDistance(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 1; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 1; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 1; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 1; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; return out; } /* Function: PackAln_read_Expl_EditDistance(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_EditDistance(EditDistance * mat) { EditDistance_access_func_holder holder; holder.access_main = EditDistance_explicit_access_main; holder.access_special = EditDistance_explicit_access_special; return PackAln_read_generic_EditDistance(mat,holder); } /* Function: EditDistance_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EditDistance_explicit_access_main(EditDistance * mat,int i,int j,int state) { return EditDistance_EXPL_MATRIX(mat,i,j,state); } /* Function: EditDistance_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EditDistance_explicit_access_special(EditDistance * mat,int i,int j,int state) { return EditDistance_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_EditDistance(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: h [UNKN ] Undocumented argument [EditDistance_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_EditDistance(EditDistance * mat,EditDistance_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_EditDistance(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in EditDistance_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 1; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_EditDistance(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_EditDistance(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == EditDistance_READ_OFF_ERROR || j == EditDistance_READ_OFF_ERROR || state == EditDistance_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in EditDistance_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 1; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_EditDistance(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [EditDistance_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_EditDistance(EditDistance * mat,int * ri,int * rj,int * state,boolean * isspecial,EditDistance_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->t->len-1,END); maxj = mat->t->len-1; for(j= mat->t->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: EditDistance_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void EditDistance_debug_show_matrix(EditDistance * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iq->len;i++) { for(j=startj;jt->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",EditDistance_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_EditDistance(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EditDistance_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_EditDistance(EditDistance * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EditDistance_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EditDistance_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->q->len || j > mat->t->len) { warn("In EditDistance matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { temp = cscore - (mat->gap) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } } /* Has restricted position */ if( (i-0) == 0 && (j-1) == 0 ) { temp = cscore - (mat->gap) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_main)(mat,i - 0,j - 1,START); } } /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { temp = cscore - (EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch)) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } } temp = cscore - (mat->gap) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } temp = cscore - (mat->gap) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } temp = cscore - (EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in EditDistance read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EditDistance read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_EditDistance(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EditDistance_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_EditDistance(EditDistance * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EditDistance_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EditDistance_READ_OFF_ERROR; if( j < 0 || j > mat->t->len) { warn("In EditDistance matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source MATCH is from main matrix */ for(i= mat->q->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in EditDistance read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_EditDistance(mat) * * Descrip: This function calculates the EditDistance matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EditDistance * * * Arg: mat [UNKN ] EditDistance which contains explicit basematrix memory [EditDistance *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_EditDistance(EditDistance * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EditDistance, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("EditDistance Matrix calculation: "); for(j=0;jq->string[i],mat->t->string[j],mat->match,mat->mismatch); /* From state MATCH to state MATCH */ temp = EditDistance_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EditDistance_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = EditDistance_EXPL_SPECIAL(mat,i-1,j-1,START) + EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch); if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-0) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = EditDistance_EXPL_SPECIAL(mat,i-0,j-1,START) + mat->gap; if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state MATCH */ temp = EditDistance_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->gap; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EditDistance_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > EditDistance_EXPL_SPECIAL(mat,i,j,END) ) { EditDistance_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_EditDistance(mat,dpenv) * * Descrip: This function calculates the EditDistance matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EditDistance which contains explicit basematrix memory [EditDistance *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_EditDistance(EditDistance * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EditDistance, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { EditDistance_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; } } for(j=-1;jlenj;j++) { EditDistance_EXPL_SPECIAL(mat,i,j,START) = 0; EditDistance_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("EditDistance Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { EditDistance_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = EditDistance_EXPL_MATRIX(mat,i-1,j-1,MATCH) + EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch); /* From state MATCH to state MATCH */ temp = EditDistance_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->gap; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EditDistance_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->gap; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = EditDistance_EXPL_SPECIAL(mat,i-1,j-1,START) + EDITMATCH(mat->q->string[i],mat->t->string[j],mat->match,mat->mismatch); if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-0) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = EditDistance_EXPL_SPECIAL(mat,i-0,j-1,START) + mat->gap; if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state MATCH */ temp = EditDistance_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->gap; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EditDistance_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > EditDistance_EXPL_SPECIAL(mat,i,j,END) ) { EditDistance_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: EditDistance_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EditDistance *] * */ EditDistance * EditDistance_alloc(void) { EditDistance * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EditDistance *) ckalloc (sizeof(EditDistance))) == NULL) { warn("EditDistance_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_EditDistance(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EditDistance *] * * Return [UNKN ] Undocumented return value [EditDistance *] * */ EditDistance * free_EditDistance(EditDistance * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EditDistance obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->q is linked in */ /* obj->t is linked in */ /* obj->match is linked in */ /* obj->mismatch is linked in */ /* obj->gap is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/editdistdp.h0000644000175000001440000005205210670453713016443 0ustar philippusers#ifndef DYNAMITEeditdistdpHEADERFILE #define DYNAMITEeditdistdpHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #define EDITMATCH(string1c,string2c,match,mismatch) (string1c == string2c ? match : mismatch) struct Wise2_EditString { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * string; int len; } ; /* EditString defined */ #ifndef DYNAMITE_DEFINED_EditString typedef struct Wise2_EditString Wise2_EditString; #define EditString Wise2_EditString #define DYNAMITE_DEFINED_EditString #endif struct Wise2_EditDistance { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; EditString* q; EditString* t; int match; int mismatch; int gap; } ; /* EditDistance defined */ #ifndef DYNAMITE_DEFINED_EditDistance typedef struct Wise2_EditDistance Wise2_EditDistance; #define EditDistance Wise2_EditDistance #define DYNAMITE_DEFINED_EditDistance #endif #ifdef PTHREAD struct thread_pool_holder_EditDistance { EditString* q; /* Static query data: never free'd */ EditString* t; /* Static target data: never free'd */ int match; int mismatch; int gap; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_EditDistance_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(EditDistance*,int,int,int); int (*access_special)(EditDistance*,int,int,int); } ; /* EditDistance_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_EditDistance_access_func_holder typedef struct Wise2_EditDistance_access_func_holder Wise2_EditDistance_access_func_holder; #define EditDistance_access_func_holder Wise2_EditDistance_access_func_holder #define DYNAMITE_DEFINED_EditDistance_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_EditString(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EditString *] * * Return [UNKN ] Undocumented return value [EditString *] * */ EditString * Wise2_hard_link_EditString(EditString * obj); #define hard_link_EditString Wise2_hard_link_EditString /* Function: EditString_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EditString *] * */ EditString * Wise2_EditString_alloc(void); #define EditString_alloc Wise2_EditString_alloc /* Function: free_EditString(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EditString *] * * Return [UNKN ] Undocumented return value [EditString *] * */ EditString * Wise2_free_EditString(EditString * obj); #define free_EditString Wise2_free_EditString /* Function: PackAln_read_Shatter_EditDistance(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_EditDistance(EditDistance * mat); #define PackAln_read_Shatter_EditDistance Wise2_PackAln_read_Shatter_EditDistance /* Function: calculate_shatter_EditDistance(mat,dpenv) * * Descrip: This function calculates the EditDistance matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EditDistance *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_EditDistance(EditDistance * mat,DPEnvelope * dpenv); #define calculate_shatter_EditDistance Wise2_calculate_shatter_EditDistance /* Function: search_EditDistance(dbsi,out,q,t,match,mismatch,gap) * * Descrip: This function makes a database search of EditDistance * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [EditString*] * Arg: t [UNKN ] Undocumented argument [EditString*] * Arg: match [UNKN ] Undocumented argument [int] * Arg: mismatch [UNKN ] Undocumented argument [int] * Arg: gap [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_EditDistance(DBSearchImpl * dbsi,Hscore * out,EditString* q,EditString* t ,int match,int mismatch,int gap); #define search_EditDistance Wise2_search_EditDistance /* Function: serial_search_EditDistance(out,q,t,match,mismatch,gap) * * Descrip: This function makes a database search of EditDistance * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [EditString*] * Arg: t [UNKN ] Undocumented argument [EditString*] * Arg: match [UNKN ] Undocumented argument [int] * Arg: mismatch [UNKN ] Undocumented argument [int] * Arg: gap [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_EditDistance(Hscore * out,EditString* q,EditString* t ,int match,int mismatch,int gap); #define serial_search_EditDistance Wise2_serial_search_EditDistance /* Function: PackAln_bestmemory_EditDistance(q,t,match,mismatch,gap,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EditDistance * * * Arg: q [UNKN ] query data structure [EditString*] * Arg: t [UNKN ] target data structure [EditString*] * Arg: match [UNKN ] Resource [int] * Arg: mismatch [UNKN ] Resource [int] * Arg: gap [UNKN ] Resource [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_EditDistance(EditString* q,EditString* t ,int match,int mismatch,int gap,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_EditDistance Wise2_PackAln_bestmemory_EditDistance /* Function: allocate_Expl_EditDistance(q,t,match,mismatch,gap,dpri) * * Descrip: This function allocates the EditDistance structure * and the basematrix area for explicit memory implementations * It calls /allocate_EditDistance_only * * * Arg: q [UNKN ] query data structure [EditString*] * Arg: t [UNKN ] target data structure [EditString*] * Arg: match [UNKN ] Resource [int] * Arg: mismatch [UNKN ] Resource [int] * Arg: gap [UNKN ] Resource [int] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EditDistance *] * */ EditDistance * Wise2_allocate_Expl_EditDistance(EditString* q,EditString* t ,int match,int mismatch,int gap,DPRunImpl * dpri); #define allocate_Expl_EditDistance Wise2_allocate_Expl_EditDistance /* Function: recalculate_PackAln_EditDistance(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EditDistance * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * */ void Wise2_recalculate_PackAln_EditDistance(PackAln * pal,EditDistance * mat); #define recalculate_PackAln_EditDistance Wise2_recalculate_PackAln_EditDistance /* Function: allocate_Small_EditDistance(q,t,match,mismatch,gap) * * Descrip: This function allocates the EditDistance structure * and the basematrix area for a small memory implementations * It calls /allocate_EditDistance_only * * * Arg: q [UNKN ] query data structure [EditString*] * Arg: t [UNKN ] target data structure [EditString*] * Arg: match [UNKN ] Resource [int] * Arg: mismatch [UNKN ] Resource [int] * Arg: gap [UNKN ] Resource [int] * * Return [UNKN ] Undocumented return value [EditDistance *] * */ EditDistance * Wise2_allocate_Small_EditDistance(EditString* q,EditString* t ,int match,int mismatch,int gap); #define allocate_Small_EditDistance Wise2_allocate_Small_EditDistance /* Function: PackAln_calculate_Small_EditDistance(mat,dpenv) * * Descrip: This function calculates an alignment for EditDistance structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EditDistance * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EditDistance * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_EditDistance(EditDistance * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_EditDistance Wise2_PackAln_calculate_Small_EditDistance /* Function: AlnRangeSet_calculate_Small_EditDistance(mat) * * Descrip: This function calculates an alignment for EditDistance structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EditDistance * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EditDistance * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EditDistance * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_EditDistance(EditDistance * mat); #define AlnRangeSet_calculate_Small_EditDistance Wise2_AlnRangeSet_calculate_Small_EditDistance /* Function: AlnRangeSet_from_EditDistance(mat) * * Descrip: This function reads off a start/end structure * for EditDistance structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EditDistance * If you have not calculated the matrix use * /AlnRange_calculate_Small_EditDistance * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_EditDistance(EditDistance * mat); #define AlnRangeSet_from_EditDistance Wise2_AlnRangeSet_from_EditDistance /* Function: convert_PackAln_to_AlnBlock_EditDistance(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_EditDistance(PackAln * pal); #define convert_PackAln_to_AlnBlock_EditDistance Wise2_convert_PackAln_to_AlnBlock_EditDistance /* Function: PackAln_read_Expl_EditDistance(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_EditDistance(EditDistance * mat); #define PackAln_read_Expl_EditDistance Wise2_PackAln_read_Expl_EditDistance /* Function: PackAln_read_generic_EditDistance(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EditDistance *] * Arg: h [UNKN ] Undocumented argument [EditDistance_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_EditDistance(EditDistance * mat,EditDistance_access_func_holder h); #define PackAln_read_generic_EditDistance Wise2_PackAln_read_generic_EditDistance /* Function: calculate_EditDistance(mat) * * Descrip: This function calculates the EditDistance matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EditDistance * * * Arg: mat [UNKN ] EditDistance which contains explicit basematrix memory [EditDistance *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_EditDistance(EditDistance * mat); #define calculate_EditDistance Wise2_calculate_EditDistance /* Function: calculate_dpenv_EditDistance(mat,dpenv) * * Descrip: This function calculates the EditDistance matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EditDistance which contains explicit basematrix memory [EditDistance *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_EditDistance(EditDistance * mat,DPEnvelope * dpenv); #define calculate_dpenv_EditDistance Wise2_calculate_dpenv_EditDistance /* Function: EditDistance_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EditDistance *] * */ EditDistance * Wise2_EditDistance_alloc(void); #define EditDistance_alloc Wise2_EditDistance_alloc /* Function: free_EditDistance(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EditDistance *] * * Return [UNKN ] Undocumented return value [EditDistance *] * */ EditDistance * Wise2_free_EditDistance(EditDistance * obj); #define free_EditDistance Wise2_free_EditDistance /* Unplaced functions */ /* There has been no indication of the use of these functions */ EditString * Wise2_new_EditString(char * string); #define new_EditString Wise2_new_EditString /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_EditDistance_shatter_access_main(EditDistance * mat,int i,int j,int state); #define EditDistance_shatter_access_main Wise2_EditDistance_shatter_access_main int Wise2_EditDistance_shatter_access_special(EditDistance * mat,int i,int j,int state); #define EditDistance_shatter_access_special Wise2_EditDistance_shatter_access_special void * Wise2_thread_loop_EditDistance(void * ptr); #define thread_loop_EditDistance Wise2_thread_loop_EditDistance int Wise2_score_only_EditDistance(EditString* q,EditString* t ,int match,int mismatch,int gap); #define score_only_EditDistance Wise2_score_only_EditDistance EditDistance * Wise2_allocate_EditDistance_only(EditString* q,EditString* t ,int match,int mismatch,int gap); #define allocate_EditDistance_only Wise2_allocate_EditDistance_only void Wise2_init_EditDistance(EditDistance * mat); #define init_EditDistance Wise2_init_EditDistance AlnRange * Wise2_AlnRange_build_EditDistance(EditDistance * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_EditDistance Wise2_AlnRange_build_EditDistance boolean Wise2_read_hidden_EditDistance(EditDistance * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_EditDistance Wise2_read_hidden_EditDistance int Wise2_max_hidden_EditDistance(EditDistance * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_EditDistance Wise2_max_hidden_EditDistance boolean Wise2_read_special_strip_EditDistance(EditDistance * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_EditDistance Wise2_read_special_strip_EditDistance int Wise2_max_special_strip_EditDistance(EditDistance * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_EditDistance Wise2_max_special_strip_EditDistance int Wise2_max_matrix_to_special_EditDistance(EditDistance * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_EditDistance Wise2_max_matrix_to_special_EditDistance void Wise2_calculate_hidden_EditDistance(EditDistance * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_EditDistance Wise2_calculate_hidden_EditDistance void Wise2_init_hidden_EditDistance(EditDistance * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_EditDistance Wise2_init_hidden_EditDistance boolean Wise2_full_dc_EditDistance(EditDistance * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_EditDistance Wise2_full_dc_EditDistance boolean Wise2_do_dc_single_pass_EditDistance(EditDistance * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_EditDistance Wise2_do_dc_single_pass_EditDistance void Wise2_push_dc_at_merge_EditDistance(EditDistance * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_EditDistance Wise2_push_dc_at_merge_EditDistance void Wise2_follow_on_dc_EditDistance(EditDistance * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_EditDistance Wise2_follow_on_dc_EditDistance void Wise2_run_up_dc_EditDistance(EditDistance * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_EditDistance Wise2_run_up_dc_EditDistance void Wise2_init_dc_EditDistance(EditDistance * mat); #define init_dc_EditDistance Wise2_init_dc_EditDistance int Wise2_start_end_find_end_EditDistance(EditDistance * mat,int * endj); #define start_end_find_end_EditDistance Wise2_start_end_find_end_EditDistance boolean Wise2_dc_optimised_start_end_calc_EditDistance(EditDistance *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_EditDistance Wise2_dc_optimised_start_end_calc_EditDistance void Wise2_init_start_end_linear_EditDistance(EditDistance * mat); #define init_start_end_linear_EditDistance Wise2_init_start_end_linear_EditDistance AlnConvertSet * Wise2_AlnConvertSet_EditDistance(void); #define AlnConvertSet_EditDistance Wise2_AlnConvertSet_EditDistance int Wise2_EditDistance_explicit_access_main(EditDistance * mat,int i,int j,int state); #define EditDistance_explicit_access_main Wise2_EditDistance_explicit_access_main int Wise2_EditDistance_explicit_access_special(EditDistance * mat,int i,int j,int state); #define EditDistance_explicit_access_special Wise2_EditDistance_explicit_access_special int Wise2_find_end_EditDistance(EditDistance * mat,int * ri,int * rj,int * state,boolean * isspecial,EditDistance_access_func_holder h); #define find_end_EditDistance Wise2_find_end_EditDistance void Wise2_EditDistance_debug_show_matrix(EditDistance * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define EditDistance_debug_show_matrix Wise2_EditDistance_debug_show_matrix int Wise2_max_calc_EditDistance(EditDistance * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EditDistance_access_func_holder h); #define max_calc_EditDistance Wise2_max_calc_EditDistance int Wise2_max_calc_special_EditDistance(EditDistance * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EditDistance_access_func_holder h); #define max_calc_special_EditDistance Wise2_max_calc_special_EditDistance #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/genewisehsp.dy0000644000175000001440000002134310364130152017000 0ustar philippusers %{ #include "dyna.h" #include "subseqhash.h" #include "hsplookupscan.h" #define GeneWiseHSPmanagerLISTLENGTH 1024 %} struct GeneWiseRunPara boolean use_hsp !def="TRUE" int edge_query !def="10" int edge_target !def="3000" int splice_spread !def="4" boolean debug !def="FALSE" struct GeneWiseHSP int query_start int query_end int target_start int target_end int score int frame struct GeneWiseHSPmanager GeneWiseHSP ** hsp !list %{ #include "genewisehsp.h" GeneWiseRunPara * new_GeneWiseRunPara_from_argv(int * argc,char ** argv) { GeneWiseRunPara * out; out = GeneWiseRunPara_alloc(); out->use_hsp = FALSE; out->edge_query = 10; out->edge_target = 3000; out->splice_spread = 5; strip_out_boolean_def_argument(argc,argv,"gwhsp",&out->use_hsp); strip_out_boolean_def_argument(argc,argv,"gwdebug",&out->debug); strip_out_integer_argument(argc,argv,"gw_edgequery",&out->edge_query); strip_out_integer_argument(argc,argv,"gw_edgetarget",&out->edge_target); strip_out_integer_argument(argc,argv,"gw_splicespread",&out->splice_spread); return out; } void show_help_GeneWiseRunPara(FILE * ofp) { fprintf(ofp,"Genewise protein running heuristics\n"); fprintf(ofp," -[no]gwhsp use heuristics for proteins [FALSE currently]\n"); fprintf(ofp," -gw_edgequery at start/end, amount of protein area to expand [10]\n"); fprintf(ofp," -gw_edgetarget at start/end, amount of DNA area to expand [3000]\n"); fprintf(ofp," -gw_splicespread spread around splice sites in codons [5]\n"); fprintf(ofp," -gwdebug print out debugging of heuristics on stdout\n"); } DPEnvelope * DPEnvelope_from_protein_gen(Sequence * prot,Sequence * dna,CompMat * mat,CodonTable * ct,GeneWiseRunPara *p) { SeqLookupInterface * sli; HSPScanInterface * hsi; HSPScanInterfacePara para; Sequence * trans; int i; int j; int frame; char * temp_seq; int can_use = 0; LinearHSPmanager * lm; GeneWiseHSPmanager * gwh; GeneWiseHSPmanager * final; DPEnvelope * out; DPUnit * dpunit; int prev_query; int prev_target; SeqLookupLoadPara loadpara; info("Using HSP based heuristic for bounds calculation. Result may not be accurate (in particular for low similarity)"); loadpara.tile_freq = 1; sli = new_ghash_SeqLookupInterface(); (*sli->add_seq)(sli->data,prot,&loadpara); hsi = new_one_off_HSPScanInterface(sli,mat,15,5); para.min_score= 10; para.max_results = 750; para.use_protein_heuristic = FALSE; gwh = GeneWiseHSPmanager_alloc_std(); for(frame=0;frame<3;frame++) { temp_seq = calloc(1+dna->len/3,sizeof(char)); for(j=0,i=frame;i+3 < dna->len;i+=3,j++) { temp_seq[j] = aminoacid_from_seq(ct,dna->seq+i); } temp_seq[j]= '\0'; trans = Sequence_alloc(); trans->name = stringalloc("temp_seq"); trans->seq = temp_seq; trans->len = strlen(temp_seq); if( p->debug ) { info("starting scan in frame %d\n",frame); } lm = (*hsi->scan_query)(hsi->data,trans,¶); if( p->debug ) { info("Retrieved %d hits in frame %d\n",lm->len,frame); } if( lm->len > 0 ) { add_GeneWiseHSPmanager_HSPset(gwh,lm->set[0],frame); } free_LinearHSPmanager(lm); } /* if this is empty, do something! */ if( gwh->len == 0 ) { info("For genewise %s vs %s, no HSPs generated, heuristic failed",prot->name,dna->name); return NULL; } /* sort by score, descend list */ sort_GeneWiseHSPmanager(gwh,compare_GeneWiseHSP_score); if( p->debug == TRUE ) { for(i=0;ilen;i++) { fprintf(stdout,"GWHSP [Before] %d,%d to %d,%d %d\n", gwh->hsp[i]->query_start, gwh->hsp[i]->query_end, gwh->hsp[i]->target_start, gwh->hsp[i]->target_end, gwh->hsp[i]->score); } } final = GeneWiseHSPmanager_alloc_std(); for(i=0;ilen;i++) { can_use = 1; for(j=0;jlen;j++) { if( consistent_GeneWiseHSP(final->hsp[j],gwh->hsp[i]) == 0 ) { can_use = 0; break; } } if( can_use == 1 ) { if( p->debug == TRUE ) { fprintf(stdout,"GWHSP accepting %d,%d to %d,%d\n", gwh->hsp[i]->query_start, gwh->hsp[i]->query_end, gwh->hsp[i]->target_start, gwh->hsp[i]->target_end ); } add_GeneWiseHSPmanager(final,hard_link_GeneWiseHSP(gwh->hsp[i])); } else { if( p->debug == TRUE ) { fprintf(stdout,"GWHSP rejecting %d,%d to %d,%d\n", gwh->hsp[i]->query_start, gwh->hsp[i]->query_end, gwh->hsp[i]->target_start, gwh->hsp[i]->target_end ); } } } out = DPEnvelope_alloc_std(); sort_GeneWiseHSPmanager(final,compare_GeneWiseHSP_start); prev_query = final->hsp[0]->query_start - p->edge_query; prev_target = final->hsp[0]->target_start - p->edge_target; if( prev_query < 0 ) { prev_query = 0; } if( prev_target < 0 ) { prev_target = 0; } for(i=0;ilen;i++) { /* rectangle from previous exon to this one */ dpunit = DPUnit_alloc(); dpunit->type = DPENV_RECT; dpunit->starti = prev_query; dpunit->startj = prev_target; dpunit->height = final->hsp[i]->query_start - dpunit->starti + p->splice_spread; dpunit->length = final->hsp[i]->target_start - dpunit->startj + p->splice_spread*3; if( dpunit->height <= 0 || dpunit->length <= 0 ) { if( p->debug ) { fprintf(stdout,"On position %d , error with the jigging %d plays %d vs %d plays %d",i, final->hsp[i]->query_start,dpunit->starti,final->hsp[i]->target_start,dpunit->startj); } if( dpunit->height <= 0 ) { dpunit->height = 1; } if( dpunit->length <= 0 ) { dpunit->length = 1; } } if( p->debug ) { fprintf(stdout,"GWHSP Bridging to %d,%d to %d,%d from %dth element with %d,%d coordinate\n", dpunit->starti, dpunit->startj, dpunit->height, dpunit->length,i,final->hsp[i]->query_start, final->hsp[i]->target_start ); } add_DPEnvelope(out,dpunit); /* rectange for this exon */ dpunit = DPUnit_alloc(); dpunit->type = DPENV_RECT; dpunit->starti = final->hsp[i]->query_start - p->splice_spread; dpunit->startj = final->hsp[i]->target_start - p->splice_spread*3;; dpunit->height = final->hsp[i]->query_end - dpunit->starti + p->splice_spread; dpunit->length = final->hsp[i]->target_end - dpunit->startj + p->splice_spread*3; if( dpunit->height <= 0 || dpunit->length <= 0 ) { fatal("On exon position %d, error with the jigging of the positions",i); } if( p->debug ) { fprintf(stdout,"GWHSP Exon: %d,%d to %d,%d from %dth element with %d,%d coordinate\n", dpunit->starti, dpunit->startj, dpunit->height, dpunit->length,i,final->hsp[i]->query_start, final->hsp[i]->target_start ); } add_DPEnvelope(out,dpunit); prev_query = final->hsp[i]->query_end - p->splice_spread; prev_target = final->hsp[i]->target_end - p->splice_spread*3; } free_GeneWiseHSPmanager(gwh); free_GeneWiseHSPmanager(final); free_HSPScanInterface(hsi); if( p->debug ) { fprintf(stdout,"GWHSP - exited with %d DP units\n",out->len); fflush(stdout); } return out; } int consistent_GeneWiseHSP(GeneWiseHSP * true,GeneWiseHSP * proposed) { int query_centre; int target_centre; assert(true); assert(proposed); /* is this left or right of the true HSP */ query_centre = (proposed->query_start + proposed->query_end) / 2; target_centre = (proposed->target_start + proposed->target_end) / 2; /* overlap criteria first */ if( query_centre >= true->query_start && query_centre <= true->query_end ) { return 0; } /* left or right */ if( query_centre > true->query_end ) { if( target_centre < true->target_end ) { /* no - inconsistent */ return 0; } } else { if( target_centre > true->target_start ) { return 0; } } /* overlap */ if( target_centre >= true->target_start && target_centre <= true->target_end ) { return 0; } return 1; } int compare_GeneWiseHSP_start(GeneWiseHSP * one,GeneWiseHSP * two) { return one->query_start - two->query_start; } %func internal for sort by score %type internal %% int compare_GeneWiseHSP_score(GeneWiseHSP * one,GeneWiseHSP * two) { return two->score - one->score; } void add_GeneWiseHSPmanager_HSPset(GeneWiseHSPmanager * gwh,HSPset * set,int frame) { int i; GeneWiseHSP * h; for(i=0;ilen;i++) { h = GeneWiseHSP_alloc(); h->query_start = set->hsp[i]->target_start; h->query_end = set->hsp[i]->target_start+set->hsp[i]->length; h->target_start = set->hsp[i]->query_start*3 + frame; h->target_end = (set->hsp[i]->query_start+set->hsp[i]->length)*3 + frame; h->score = set->hsp[i]->score; add_GeneWiseHSPmanager(gwh,h); } } %} wise-2.4.1/src/models/genewise21.c0000644000175000001440000264152110670453714016262 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genewise21.h" # line 7 "genewise21.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define CENTRAL_0M 3 #define PY_0M 4 #define SPACER_0M 5 #define CENTRAL_1M 6 #define PY_1M 7 #define SPACER_1M 8 #define CENTRAL_2M 9 #define PY_2M 10 #define SPACER_2M 11 #define CENTRAL_0I 12 #define PY_0I 13 #define SPACER_0I 14 #define CENTRAL_1I 15 #define PY_1I 16 #define SPACER_1I 17 #define CENTRAL_2I 18 #define PY_2I 19 #define SPACER_2I 20 #define START 0 #define END 1 #define BEFORE_RND 2 #define BEFORE_CODON 3 #define BEFORE_CENTRAL 4 #define BEFORE_PY_TRACT 5 #define BEFORE_SPACER 6 #define AFTER_RND 7 #define AFTER_CODON 8 #define AFTER_CENTRAL 9 #define AFTER_PY_TRACT 10 #define AFTER_SPACER 11 #define GeneWise21_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+10)*21)+STATE][i+1] #define GeneWise21_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+10] #define GeneWise21_READ_OFF_ERROR -12 #define GeneWise21_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+11)%11][((i+1)*21)+STATE] #define GeneWise21_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+11)%11][STATE] #define GeneWise21_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define GeneWise21_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_GeneWise21(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_GeneWise21(GeneWise21 * mat) { GeneWise21_access_func_holder holder; holder.access_main = GeneWise21_shatter_access_main; holder.access_special = GeneWise21_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_GeneWise21(mat,holder); } /* Function: GeneWise21_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneWise21_shatter_access_main(GeneWise21 * mat,int i,int j,int state) { return GeneWise21_SHATTER_MATRIX(mat,i,j,state); } /* Function: GeneWise21_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneWise21_shatter_access_special(GeneWise21 * mat,int i,int j,int state) { return GeneWise21_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_GeneWise21(mat,dpenv) * * Descrip: This function calculates the GeneWise21 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneWise21 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_GeneWise21(GeneWise21 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_6; int * SIG_1_5; int * SIG_1_4; int * SIG_1_2; int * SIG_1_1; int * SIG_0_3; int * SIG_1_0; int * SIG_0_8; int * SIG_0_1; int * SIG_0_9; int * SIG_0_10; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,21,lenj,12); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("GeneWise21 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-6); SIG_1_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-5); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); SIG_0_8 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-8); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_0_9 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-9); SIG_0_10 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-10); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_CODON to state MATCH */ temp = GeneWise21_SHATTER_SPECIAL(mat,i-1,j-3,BEFORE_CODON) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0M to state MATCH */ temp = SIG_1_6[SPACER_0M] + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_0M to state MATCH */ temp = SIG_1_6[PY_0M] + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1M to state MATCH */ temp = SIG_1_5[SPACER_1M] + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_1M to state MATCH */ temp = SIG_1_5[PY_1M] + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2M to state MATCH */ temp = SIG_1_4[SPACER_2M] + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_2M to state MATCH */ temp = SIG_1_4[PY_2M] + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_1[MATCH] + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_4[MATCH] + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_5[MATCH] + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[MATCH] = score; /* state MATCH is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise21_SHATTER_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_SHATTER_SPECIAL(mat,i,j,AFTER_CODON) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_CODON to state INSERT */ temp = GeneWise21_SHATTER_SPECIAL(mat,i-0,j-3,BEFORE_CODON) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0I to state INSERT */ temp = SIG_1_6[SPACER_0I] + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1I to state INSERT */ temp = SIG_1_5[SPACER_1I] + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2I to state INSERT */ temp = SIG_1_4[SPACER_2I] + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_0I to state INSERT */ temp = SIG_1_6[PY_0I] + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_1I to state INSERT */ temp = SIG_1_5[PY_1I] + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_2I to state INSERT */ temp = SIG_1_4[PY_2I] + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_1_2[INSERT] + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_1_1[INSERT] + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_1_4[INSERT] + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_1_5[INSERT] + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[INSERT] = score; /* state INSERT is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneWise21_SHATTER_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_SHATTER_SPECIAL(mat,i,j,AFTER_CODON) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state BEFORE_CODON to state DELETE */ temp = GeneWise21_SHATTER_SPECIAL(mat,i-1,j-0,BEFORE_CODON) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneWise21_SHATTER_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_SHATTER_SPECIAL(mat,i,j,AFTER_CODON) = temp; } /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = SIG_0_8[MATCH] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0M */ temp = SIG_0_8[INSERT] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0M */ temp = SIG_0_8[DELETE] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = SIG_0_1[CENTRAL_0M] + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ SIG_0_0[CENTRAL_0M] = score; /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = SIG_0_1[CENTRAL_0M] + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0M to state PY_0M */ temp = SIG_0_1[PY_0M] + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[PY_0M] = score; /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = SIG_0_1[PY_0M] + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0M to state SPACER_0M */ temp = SIG_0_1[SPACER_0M] + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[SPACER_0M] = score; /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = SIG_0_9[MATCH] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_1M */ temp = SIG_0_9[INSERT] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1M */ temp = SIG_0_9[DELETE] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = SIG_0_1[CENTRAL_1M] + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ SIG_0_0[CENTRAL_1M] = score; /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = SIG_0_1[CENTRAL_1M] + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1M to state PY_1M */ temp = SIG_0_1[PY_1M] + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[PY_1M] = score; /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = SIG_0_1[PY_1M] + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1M to state SPACER_1M */ temp = SIG_0_1[SPACER_1M] + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[SPACER_1M] = score; /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = SIG_0_10[MATCH] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_2M */ temp = SIG_0_10[INSERT] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_2M */ temp = SIG_0_10[DELETE] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = SIG_0_1[CENTRAL_2M] + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ SIG_0_0[CENTRAL_2M] = score; /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = SIG_0_1[CENTRAL_2M] + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2M to state PY_2M */ temp = SIG_0_1[PY_2M] + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[PY_2M] = score; /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = SIG_0_1[PY_2M] + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2M to state SPACER_2M */ temp = SIG_0_1[SPACER_2M] + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[SPACER_2M] = score; /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = SIG_0_8[MATCH] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0I */ temp = SIG_0_8[INSERT] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0I */ temp = SIG_0_8[DELETE] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = SIG_0_1[CENTRAL_0I] + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ SIG_0_0[CENTRAL_0I] = score; /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = SIG_0_1[CENTRAL_0I] + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0I to state PY_0I */ temp = SIG_0_1[PY_0I] + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[PY_0I] = score; /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = SIG_0_1[PY_0I] + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0I to state SPACER_0I */ temp = SIG_0_1[SPACER_0I] + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[SPACER_0I] = score; /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = SIG_0_9[MATCH] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_1I */ temp = SIG_0_9[INSERT] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1I */ temp = SIG_0_9[DELETE] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = SIG_0_1[CENTRAL_1I] + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ SIG_0_0[CENTRAL_1I] = score; /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = SIG_0_1[CENTRAL_1I] + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1I to state PY_1I */ temp = SIG_0_1[PY_1I] + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[PY_1I] = score; /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = SIG_0_1[PY_1I] + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1I to state SPACER_1I */ temp = SIG_0_1[SPACER_1I] + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[SPACER_1I] = score; /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = SIG_0_10[MATCH] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_2I */ temp = SIG_0_10[INSERT] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state INSERT to state CENTRAL_2I */ temp = SIG_0_10[INSERT] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = SIG_0_1[CENTRAL_2I] + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ SIG_0_0[CENTRAL_2I] = score; /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = SIG_0_1[CENTRAL_2I] + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2I to state PY_2I */ temp = SIG_0_1[PY_2I] + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[PY_2I] = score; /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = SIG_0_1[PY_2I] + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2I to state SPACER_2I */ temp = SIG_0_1[SPACER_2I] + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[SPACER_2I] = score; /* Finished calculating state SPACER_2I */ } /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_SHATTER_SPECIAL(mat,0,j,END); /* Source AFTER_RND is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,AFTER_RND) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GeneWise21_SHATTER_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_SHATTER_SPECIAL(mat,0,j,BEFORE_RND); /* Source START is a special source for BEFORE_RND */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,START) + (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_RND is a special source for BEFORE_RND */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_RND */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_SHATTER_SPECIAL(mat,0,j,BEFORE_RND) = score; /* Finished updating state BEFORE_RND */ /* Special state BEFORE_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_SHATTER_SPECIAL(mat,0,j,BEFORE_CODON); /* Source BEFORE_RND is a special source for BEFORE_CODON */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 3,BEFORE_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CODON */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 3,BEFORE_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 5,BEFORE_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 4,BEFORE_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 3,BEFORE_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_SHATTER_SPECIAL(mat,0,j,BEFORE_CODON) = score; /* Finished updating state BEFORE_CODON */ /* Special state BEFORE_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_SHATTER_SPECIAL(mat,0,j,BEFORE_CENTRAL); /* Source BEFORE_CENTRAL is a special source for BEFORE_CENTRAL */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 8,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 9,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 10,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_SHATTER_SPECIAL(mat,0,j,BEFORE_CENTRAL) = score; /* Finished updating state BEFORE_CENTRAL */ /* Special state BEFORE_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_SHATTER_SPECIAL(mat,0,j,BEFORE_PY_TRACT); /* Source BEFORE_CENTRAL is a special source for BEFORE_PY_TRACT */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source BEFORE_PY_TRACT is a special source for BEFORE_PY_TRACT */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_SHATTER_SPECIAL(mat,0,j,BEFORE_PY_TRACT) = score; /* Finished updating state BEFORE_PY_TRACT */ /* Special state BEFORE_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_SHATTER_SPECIAL(mat,0,j,BEFORE_SPACER); /* Source BEFORE_PY_TRACT is a special source for BEFORE_SPACER */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_SPACER */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_SHATTER_SPECIAL(mat,0,j,BEFORE_SPACER) = score; /* Finished updating state BEFORE_SPACER */ /* Special state AFTER_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_SHATTER_SPECIAL(mat,0,j,AFTER_RND); /* Source AFTER_RND is a special source for AFTER_RND */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,AFTER_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_RND */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,AFTER_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_SHATTER_SPECIAL(mat,0,j,AFTER_RND) = score; /* Finished updating state AFTER_RND */ /* Special state AFTER_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_SHATTER_SPECIAL(mat,0,j,AFTER_CODON); /* Source AFTER_RND is a special source for AFTER_CODON */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 3,AFTER_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) score = temp; /* Source MATCH for state AFTER_CODON is not special... already calculated */ /* Source INSERT for state AFTER_CODON is not special... already calculated */ /* Source DELETE for state AFTER_CODON is not special... already calculated */ /* Source AFTER_CODON is a special source for AFTER_CODON */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 3,AFTER_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 5,AFTER_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 4,AFTER_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 3,AFTER_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_SHATTER_SPECIAL(mat,0,j,AFTER_CODON) = score; /* Finished updating state AFTER_CODON */ /* Special state AFTER_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_SHATTER_SPECIAL(mat,0,j,AFTER_CENTRAL); /* Source AFTER_CENTRAL is a special source for AFTER_CENTRAL */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,AFTER_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 8,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 9,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 10,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_SHATTER_SPECIAL(mat,0,j,AFTER_CENTRAL) = score; /* Finished updating state AFTER_CENTRAL */ /* Special state AFTER_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_SHATTER_SPECIAL(mat,0,j,AFTER_PY_TRACT); /* Source AFTER_CENTRAL is a special source for AFTER_PY_TRACT */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,AFTER_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source AFTER_PY_TRACT is a special source for AFTER_PY_TRACT */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,AFTER_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_SHATTER_SPECIAL(mat,0,j,AFTER_PY_TRACT) = score; /* Finished updating state AFTER_PY_TRACT */ /* Special state AFTER_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_SHATTER_SPECIAL(mat,0,j,AFTER_SPACER); /* Source AFTER_PY_TRACT is a special source for AFTER_SPACER */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,AFTER_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_SPACER */ temp = GeneWise21_SHATTER_SPECIAL(mat,0,j - 1,AFTER_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_SHATTER_SPECIAL(mat,0,j,AFTER_SPACER) = score; /* Finished updating state AFTER_SPACER */ } stop_reporting(); return TRUE; } /* Function: search_GeneWise21(dbsi,out,querydb,targetdb,gp21,rndcodon,rndbase) * * Descrip: This function makes a database search of GeneWise21 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp21 [UNKN ] Undocumented argument [GeneParser21Score *] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: rndbase [UNKN ] Undocumented argument [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_GeneWise21(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_GeneWise21 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_GeneWise21. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_GeneWise21. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for GeneWise21, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_GeneWise21(out,querydb, targetdb ,gp21,rndcodon,rndbase); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_GeneWise21 *) ckalloc(sizeof(struct thread_pool_holder_GeneWise21)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->gp21 = gp21; holder->rndcodon = rndcodon; holder->rndbase = rndbase; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_GeneWise21,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for GeneWise21"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from GeneWise21",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_GeneWise21(ptr) * * Descrip: Infinite loop code foreach thread for GeneWise21 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_GeneWise21(void * ptr) { struct thread_pool_holder_GeneWise21 * holder; int db_status; int score; DataScore * ds; GeneWiseScore* query; ComplexSequence* target; holder = (struct thread_pool_holder_GeneWise21 *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneWise21"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneWise21"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_GeneWiseDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in GeneWise21 search"); } query = hard_link_GeneWiseScore(holder->query); /* get query information into datascore */ dataentry_add_GeneWiseDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_GenomicDB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_GenomicDB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching GeneWise21, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_GenomicDB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_GeneWiseScore(holder->query); /* get the next query object for the next thread */ holder->query = reload_GeneWiseDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching GeneWise21, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_GeneWiseDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneWise21"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneWise21"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_GenomicDB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_GeneWise21(query, target ,holder->gp21,holder->rndcodon,holder->rndbase); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for GeneWise21"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for GeneWise21"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneWise21"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_GeneWiseScore(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneWise21"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_GeneWise21(out,querydb,targetdb,gp21,rndcodon,rndbase) * * Descrip: This function makes a database search of GeneWise21 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp21 [UNKN ] Undocumented argument [GeneParser21Score *] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: rndbase [UNKN ] Undocumented argument [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_GeneWise21(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase) { GeneWiseScore* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GeneWiseDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneWise21, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_GenomicDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneWise21, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_GeneWise21(query, target , gp21, rndcodon, rndbase); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("GeneWise21 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GeneWiseDB(ds->query,query,querydb); dataentry_add_GenomicDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_GenomicDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneWise21, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_GenomicDB(target,targetdb); query = reload_GeneWiseDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching GeneWise21, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GeneWiseDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_GeneWise21(query,target,gp21,rndcodon,rndbase) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_GeneWise21_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_GeneWise21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase) { int bestscore = NEGI; int i; int j; int k; GeneWise21 * mat; mat = allocate_GeneWise21_only(query, target , gp21, rndcodon, rndbase); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(11,(mat->leni + 1) * 21,11,12)) == NULL) { warn("Score only matrix for GeneWise21 cannot be allocated, (asking for 10 by %d cells)",mat->leni*21); mat = free_GeneWise21(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<12;j++) { for(i=(-1);ileni;i++) { for(k=0;k<21;k++) GeneWise21_VSMALL_MATRIX(mat,i,j,k) = NEGI; } GeneWise21_VSMALL_SPECIAL(mat,i,j,START) = 0; GeneWise21_VSMALL_SPECIAL(mat,i,j,END) = NEGI; GeneWise21_VSMALL_SPECIAL(mat,i,j,BEFORE_RND) = NEGI; GeneWise21_VSMALL_SPECIAL(mat,i,j,BEFORE_CODON) = NEGI; GeneWise21_VSMALL_SPECIAL(mat,i,j,BEFORE_CENTRAL) = NEGI; GeneWise21_VSMALL_SPECIAL(mat,i,j,BEFORE_PY_TRACT) = NEGI; GeneWise21_VSMALL_SPECIAL(mat,i,j,BEFORE_SPACER) = NEGI; GeneWise21_VSMALL_SPECIAL(mat,i,j,AFTER_RND) = NEGI; GeneWise21_VSMALL_SPECIAL(mat,i,j,AFTER_CODON) = NEGI; GeneWise21_VSMALL_SPECIAL(mat,i,j,AFTER_CENTRAL) = NEGI; GeneWise21_VSMALL_SPECIAL(mat,i,j,AFTER_PY_TRACT) = NEGI; GeneWise21_VSMALL_SPECIAL(mat,i,j,AFTER_SPACER) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_CODON to state MATCH */ temp = GeneWise21_VSMALL_SPECIAL(mat,i-1,j-3,BEFORE_CODON) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0M to state MATCH */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_0M to state MATCH */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1M to state MATCH */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_1M to state MATCH */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2M to state MATCH */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_2M to state MATCH */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise21_VSMALL_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_VSMALL_SPECIAL(mat,i,j,AFTER_CODON) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_CODON to state INSERT */ temp = GeneWise21_VSMALL_SPECIAL(mat,i-0,j-3,BEFORE_CODON) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0I to state INSERT */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1I to state INSERT */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2I to state INSERT */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_0I to state INSERT */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_1I to state INSERT */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_2I to state INSERT */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneWise21_VSMALL_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_VSMALL_SPECIAL(mat,i,j,AFTER_CODON) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise21_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state BEFORE_CODON to state DELETE */ temp = GeneWise21_VSMALL_SPECIAL(mat,i-1,j-0,BEFORE_CODON) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise21_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneWise21_VSMALL_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_VSMALL_SPECIAL(mat,i,j,AFTER_CODON) = temp; } /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ GeneWise21_VSMALL_MATRIX(mat,i,j,CENTRAL_0M) = score; /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0M to state PY_0M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_VSMALL_MATRIX(mat,i,j,PY_0M) = score; /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0M to state SPACER_0M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_VSMALL_MATRIX(mat,i,j,SPACER_0M) = score; /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_1M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ GeneWise21_VSMALL_MATRIX(mat,i,j,CENTRAL_1M) = score; /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1M to state PY_1M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_VSMALL_MATRIX(mat,i,j,PY_1M) = score; /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1M to state SPACER_1M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_VSMALL_MATRIX(mat,i,j,SPACER_1M) = score; /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_2M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_2M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ GeneWise21_VSMALL_MATRIX(mat,i,j,CENTRAL_2M) = score; /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2M to state PY_2M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_VSMALL_MATRIX(mat,i,j,PY_2M) = score; /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2M to state SPACER_2M */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_VSMALL_MATRIX(mat,i,j,SPACER_2M) = score; /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ GeneWise21_VSMALL_MATRIX(mat,i,j,CENTRAL_0I) = score; /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0I to state PY_0I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_VSMALL_MATRIX(mat,i,j,PY_0I) = score; /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0I to state SPACER_0I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_VSMALL_MATRIX(mat,i,j,SPACER_0I) = score; /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_1I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ GeneWise21_VSMALL_MATRIX(mat,i,j,CENTRAL_1I) = score; /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1I to state PY_1I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_VSMALL_MATRIX(mat,i,j,PY_1I) = score; /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1I to state SPACER_1I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_VSMALL_MATRIX(mat,i,j,SPACER_1I) = score; /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ GeneWise21_VSMALL_MATRIX(mat,i,j,CENTRAL_2I) = score; /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2I to state PY_2I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_VSMALL_MATRIX(mat,i,j,PY_2I) = score; /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2I to state SPACER_2I */ temp = GeneWise21_VSMALL_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_VSMALL_MATRIX(mat,i,j,SPACER_2I) = score; /* Finished calculating state SPACER_2I */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_VSMALL_SPECIAL(mat,0,j,END); /* Source AFTER_RND is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,AFTER_RND) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GeneWise21_VSMALL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_VSMALL_SPECIAL(mat,0,j,BEFORE_RND); /* Source START is a special source for BEFORE_RND */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,START) + (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_RND is a special source for BEFORE_RND */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_RND */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_VSMALL_SPECIAL(mat,0,j,BEFORE_RND) = score; /* Finished updating state BEFORE_RND */ /* Special state BEFORE_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_VSMALL_SPECIAL(mat,0,j,BEFORE_CODON); /* Source BEFORE_RND is a special source for BEFORE_CODON */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 3,BEFORE_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CODON */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 3,BEFORE_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 5,BEFORE_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 4,BEFORE_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 3,BEFORE_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_VSMALL_SPECIAL(mat,0,j,BEFORE_CODON) = score; /* Finished updating state BEFORE_CODON */ /* Special state BEFORE_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_VSMALL_SPECIAL(mat,0,j,BEFORE_CENTRAL); /* Source BEFORE_CENTRAL is a special source for BEFORE_CENTRAL */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 8,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 9,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 10,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_VSMALL_SPECIAL(mat,0,j,BEFORE_CENTRAL) = score; /* Finished updating state BEFORE_CENTRAL */ /* Special state BEFORE_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_VSMALL_SPECIAL(mat,0,j,BEFORE_PY_TRACT); /* Source BEFORE_CENTRAL is a special source for BEFORE_PY_TRACT */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source BEFORE_PY_TRACT is a special source for BEFORE_PY_TRACT */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_VSMALL_SPECIAL(mat,0,j,BEFORE_PY_TRACT) = score; /* Finished updating state BEFORE_PY_TRACT */ /* Special state BEFORE_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_VSMALL_SPECIAL(mat,0,j,BEFORE_SPACER); /* Source BEFORE_PY_TRACT is a special source for BEFORE_SPACER */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_SPACER */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_VSMALL_SPECIAL(mat,0,j,BEFORE_SPACER) = score; /* Finished updating state BEFORE_SPACER */ /* Special state AFTER_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_VSMALL_SPECIAL(mat,0,j,AFTER_RND); /* Source AFTER_RND is a special source for AFTER_RND */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,AFTER_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_RND */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,AFTER_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_VSMALL_SPECIAL(mat,0,j,AFTER_RND) = score; /* Finished updating state AFTER_RND */ /* Special state AFTER_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_VSMALL_SPECIAL(mat,0,j,AFTER_CODON); /* Source AFTER_RND is a special source for AFTER_CODON */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 3,AFTER_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) score = temp; /* Source MATCH for state AFTER_CODON is not special... already calculated */ /* Source INSERT for state AFTER_CODON is not special... already calculated */ /* Source DELETE for state AFTER_CODON is not special... already calculated */ /* Source AFTER_CODON is a special source for AFTER_CODON */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 3,AFTER_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 5,AFTER_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 4,AFTER_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 3,AFTER_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_VSMALL_SPECIAL(mat,0,j,AFTER_CODON) = score; /* Finished updating state AFTER_CODON */ /* Special state AFTER_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_VSMALL_SPECIAL(mat,0,j,AFTER_CENTRAL); /* Source AFTER_CENTRAL is a special source for AFTER_CENTRAL */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,AFTER_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 8,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 9,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 10,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_VSMALL_SPECIAL(mat,0,j,AFTER_CENTRAL) = score; /* Finished updating state AFTER_CENTRAL */ /* Special state AFTER_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_VSMALL_SPECIAL(mat,0,j,AFTER_PY_TRACT); /* Source AFTER_CENTRAL is a special source for AFTER_PY_TRACT */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,AFTER_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source AFTER_PY_TRACT is a special source for AFTER_PY_TRACT */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,AFTER_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_VSMALL_SPECIAL(mat,0,j,AFTER_PY_TRACT) = score; /* Finished updating state AFTER_PY_TRACT */ /* Special state AFTER_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_VSMALL_SPECIAL(mat,0,j,AFTER_SPACER); /* Source AFTER_PY_TRACT is a special source for AFTER_SPACER */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,AFTER_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_SPACER */ temp = GeneWise21_VSMALL_SPECIAL(mat,0,j - 1,AFTER_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_VSMALL_SPECIAL(mat,0,j,AFTER_SPACER) = score; /* Finished updating state AFTER_SPACER */ if( bestscore < GeneWise21_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = GeneWise21_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_GeneWise21(mat); return bestscore; } /* Function: PackAln_bestmemory_GeneWise21(query,target,gp21,rndcodon,rndbase,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneWise21 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_GeneWise21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; GeneWise21 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 21 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_GeneWise21(query, target , gp21, rndcodon, rndbase,dpri)) == NULL ) { warn("Unable to allocate large GeneWise21 version"); return NULL; } calculate_dpenv_GeneWise21(mat,dpenv); out = PackAln_read_Expl_GeneWise21(mat); } else { mat = allocate_GeneWise21_only(query, target , gp21, rndcodon, rndbase); calculate_shatter_GeneWise21(mat,dpenv); out = PackAln_read_Shatter_GeneWise21(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_GeneWise21(query, target , gp21, rndcodon, rndbase)) == NULL ) { warn("Unable to allocate small GeneWise21 version"); return NULL; } out = PackAln_calculate_Small_GeneWise21(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_GeneWise21(query, target , gp21, rndcodon, rndbase,dpri)) == NULL ) { warn("Unable to allocate large GeneWise21 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_GeneWise21(mat); out = PackAln_read_Expl_GeneWise21(mat); } } } mat = free_GeneWise21(mat); return out; } /* Function: allocate_GeneWise21_only(query,target,gp21,rndcodon,rndbase) * * Descrip: This function only allocates the GeneWise21 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [GeneWise21 *] * */ GeneWise21 * allocate_GeneWise21_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase) { GeneWise21 * out; if((out= GeneWise21_alloc()) == NULL) { warn("Allocation of basic GeneWise21 structure failed..."); return NULL; } out->query = query; out->target = target; out->gp21 = gp21; out->rndcodon = rndcodon; out->rndbase = rndbase; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_GeneWise21(query,target,gp21,rndcodon,rndbase,dpri) * * Descrip: This function allocates the GeneWise21 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneWise21_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneWise21 *] * */ GeneWise21 * allocate_Expl_GeneWise21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase,DPRunImpl * dpri) { GeneWise21 * out; out = allocate_GeneWise21_only(query, target , gp21, rndcodon, rndbase); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+10)*21 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+10)*21,(out->leni+1),12,out->lenj+10)) == NULL) { warn("Explicit matrix GeneWise21 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_GeneWise21(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_GeneWise21(out); return out; } /* Function: init_GeneWise21(mat) * * Descrip: This function initates GeneWise21 matrix when in explicit mode * Called in /allocate_Expl_GeneWise21 * * * Arg: mat [UNKN ] GeneWise21 which contains explicit basematrix memory [GeneWise21 *] * */ void init_GeneWise21(GeneWise21 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-10);j<11;j++) { GeneWise21_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_0M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_1M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_2M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_0I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_1I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_2I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2I) = NEGI; } } for(j= (-10);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { GeneWise21_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_0M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_1M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_2M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_0I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_1I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_2I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2I) = NEGI; } GeneWise21_EXPL_SPECIAL(mat,i,j,START) = 0; GeneWise21_EXPL_SPECIAL(mat,i,j,END) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,BEFORE_RND) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,BEFORE_CODON) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,BEFORE_CENTRAL) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,BEFORE_PY_TRACT) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,BEFORE_SPACER) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_RND) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CENTRAL) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_PY_TRACT) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_SPACER) = NEGI; } return; } /* Function: recalculate_PackAln_GeneWise21(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneWise21 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * */ void recalculate_PackAln_GeneWise21(PackAln * pal,GeneWise21 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (BEFORE_CODON+21) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == SPACER_0M ) { pau->score = (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == PY_0M ) { pau->score = (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == SPACER_1M ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == PY_1M ) { pau->score = (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == SPACER_2M ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == PY_2M ) { pau->score = (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->gp21->transition[GP21_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->gp21->transition[GP21_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == MATCH ) { pau->score = mat->gp21->transition[GP21_INSERT_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == MATCH ) { pau->score = mat->gp21->transition[GP21_INSERT_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (BEFORE_CODON+21) ) { pau->score = (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == SPACER_0I ) { pau->score = (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == SPACER_1I ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == SPACER_2I ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == PY_0I ) { pau->score = (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == PY_1I ) { pau->score = (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == PY_2I ) { pau->score = (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 2 && prev->state == INSERT ) { pau->score = mat->gp21->transition[GP21_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = mat->gp21->transition[GP21_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == INSERT ) { pau->score = mat->gp21->transition[GP21_INSERT_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == INSERT ) { pau->score = mat->gp21->transition[GP21_INSERT_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->seg[i]->transition[GW_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (BEFORE_CODON+21) ) { pau->score = mat->query->seg[i]->transition[GW_START2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CENTRAL_0M : if( offi == 0 && offj == 8 && prev->state == MATCH ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == INSERT ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == DELETE ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CENTRAL_0M ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } warn("In recaluclating PackAln with state CENTRAL_0M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case PY_0M : if( offi == 0 && offj == 1 && prev->state == CENTRAL_0M ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == PY_0M ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state PY_0M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SPACER_0M : if( offi == 0 && offj == 1 && prev->state == PY_0M ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == SPACER_0M ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state SPACER_0M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CENTRAL_1M : if( offi == 0 && offj == 9 && prev->state == MATCH ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == INSERT ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == DELETE ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CENTRAL_1M ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } warn("In recaluclating PackAln with state CENTRAL_1M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case PY_1M : if( offi == 0 && offj == 1 && prev->state == CENTRAL_1M ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == PY_1M ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state PY_1M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SPACER_1M : if( offi == 0 && offj == 1 && prev->state == PY_1M ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == SPACER_1M ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state SPACER_1M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CENTRAL_2M : if( offi == 0 && offj == 10 && prev->state == MATCH ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == INSERT ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == DELETE ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CENTRAL_2M ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } warn("In recaluclating PackAln with state CENTRAL_2M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case PY_2M : if( offi == 0 && offj == 1 && prev->state == CENTRAL_2M ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == PY_2M ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state PY_2M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SPACER_2M : if( offi == 0 && offj == 1 && prev->state == PY_2M ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == SPACER_2M ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state SPACER_2M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CENTRAL_0I : if( offi == 0 && offj == 8 && prev->state == MATCH ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == INSERT ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == DELETE ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CENTRAL_0I ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } warn("In recaluclating PackAln with state CENTRAL_0I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case PY_0I : if( offi == 0 && offj == 1 && prev->state == CENTRAL_0I ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == PY_0I ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state PY_0I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SPACER_0I : if( offi == 0 && offj == 1 && prev->state == PY_0I ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == SPACER_0I ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state SPACER_0I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CENTRAL_1I : if( offi == 0 && offj == 9 && prev->state == MATCH ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == INSERT ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == DELETE ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CENTRAL_1I ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } warn("In recaluclating PackAln with state CENTRAL_1I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case PY_1I : if( offi == 0 && offj == 1 && prev->state == CENTRAL_1I ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == PY_1I ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state PY_1I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SPACER_1I : if( offi == 0 && offj == 1 && prev->state == PY_1I ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == SPACER_1I ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state SPACER_1I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CENTRAL_2I : if( offi == 0 && offj == 10 && prev->state == MATCH ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == INSERT ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == INSERT ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CENTRAL_2I ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } warn("In recaluclating PackAln with state CENTRAL_2I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case PY_2I : if( offi == 0 && offj == 1 && prev->state == CENTRAL_2I ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == PY_2I ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state PY_2I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SPACER_2I : if( offi == 0 && offj == 1 && prev->state == PY_2I ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == SPACER_2I ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state SPACER_2I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+21) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+21) : if( offj == 1 && prev->state == (AFTER_RND+21) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; case (BEFORE_RND+21) : if( offj == 1 && prev->state == (START+21) ) { pau->score = mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)] + (0); continue; } if( offj == 1 && prev->state == (BEFORE_RND+21) ) { pau->score = (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND]) + (0); continue; } if( offj == 1 && prev->state == (BEFORE_CODON+21) ) { pau->score = (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND]) + (0); continue; } warn("In recaluclating PackAln with state BEFORE_RND, got a bad source state. Error!"); break; case (BEFORE_CODON+21) : if( offj == 3 && prev->state == (BEFORE_RND+21) ) { pau->score = (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS]) + (0); continue; } if( offj == 3 && prev->state == (BEFORE_CODON+21) ) { pau->score = (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS]) + (0); continue; } if( offj == 5 && prev->state == (BEFORE_SPACER+21) ) { pau->score = ((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0); continue; } if( offj == 4 && prev->state == (BEFORE_SPACER+21) ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0); continue; } if( offj == 3 && prev->state == (BEFORE_SPACER+21) ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0); continue; } warn("In recaluclating PackAln with state BEFORE_CODON, got a bad source state. Error!"); break; case (BEFORE_CENTRAL+21) : if( offj == 1 && prev->state == (BEFORE_CENTRAL+21) ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } if( offj == 8 && prev->state == (BEFORE_CODON+21) ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offj == 9 && prev->state == (BEFORE_CODON+21) ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offj == 10 && prev->state == (BEFORE_CODON+21) ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } warn("In recaluclating PackAln with state BEFORE_CENTRAL, got a bad source state. Error!"); break; case (BEFORE_PY_TRACT+21) : if( offj == 1 && prev->state == (BEFORE_CENTRAL+21) ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offj == 1 && prev->state == (BEFORE_PY_TRACT+21) ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state BEFORE_PY_TRACT, got a bad source state. Error!"); break; case (BEFORE_SPACER+21) : if( offj == 1 && prev->state == (BEFORE_PY_TRACT+21) ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offj == 1 && prev->state == (BEFORE_SPACER+21) ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state BEFORE_SPACER, got a bad source state. Error!"); break; case (AFTER_RND+21) : if( offj == 1 && prev->state == (AFTER_RND+21) ) { pau->score = (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND]) + (0); continue; } if( offj == 1 && prev->state == (AFTER_CODON+21) ) { pau->score = (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND]) + (0); continue; } warn("In recaluclating PackAln with state AFTER_RND, got a bad source state. Error!"); break; case (AFTER_CODON+21) : if( offj == 3 && prev->state == (AFTER_RND+21) ) { pau->score = (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS]) + (0); continue; } if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } if( offj == 3 && prev->state == (AFTER_CODON+21) ) { pau->score = (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS]) + (0); continue; } if( offj == 5 && prev->state == (AFTER_SPACER+21) ) { pau->score = ((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0); continue; } if( offj == 4 && prev->state == (AFTER_SPACER+21) ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0); continue; } if( offj == 3 && prev->state == (AFTER_SPACER+21) ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0); continue; } warn("In recaluclating PackAln with state AFTER_CODON, got a bad source state. Error!"); break; case (AFTER_CENTRAL+21) : if( offj == 1 && prev->state == (AFTER_CENTRAL+21) ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } if( offj == 8 && prev->state == (AFTER_CODON+21) ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offj == 9 && prev->state == (AFTER_CODON+21) ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offj == 10 && prev->state == (AFTER_CODON+21) ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } warn("In recaluclating PackAln with state AFTER_CENTRAL, got a bad source state. Error!"); break; case (AFTER_PY_TRACT+21) : if( offj == 1 && prev->state == (AFTER_CENTRAL+21) ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offj == 1 && prev->state == (AFTER_PY_TRACT+21) ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state AFTER_PY_TRACT, got a bad source state. Error!"); break; case (AFTER_SPACER+21) : if( offj == 1 && prev->state == (AFTER_PY_TRACT+21) ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offj == 1 && prev->state == (AFTER_SPACER+21) ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state AFTER_SPACER, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define GeneWise21_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+10)][(i+1)*21+state]) #define GeneWise21_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+11)*8) % 88][(i+1)*21+state]) #define GeneWise21_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+10)]) #define GeneWise21_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) #define GeneWise21_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+11)*8)+(shadow+1)) % 88)][(i+1)*21 + state]) #define GeneWise21_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) #define GeneWise21_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+10)% 10) * (leni+1) * 21) + ((i+1) * 21) + (state)]) #define GeneWise21_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+10)% 10) * (leni+1) * 168) + ((i+1) * 168) + (state * 8) + shadow+1]) #define GeneWise21_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) /* Function: allocate_Small_GeneWise21(query,target,gp21,rndcodon,rndbase) * * Descrip: This function allocates the GeneWise21 structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneWise21_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [GeneWise21 *] * */ #define GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) GeneWise21 * allocate_Small_GeneWise21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase) { GeneWise21 * out; out = allocate_GeneWise21_only(query, target , gp21, rndcodon, rndbase); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(88,(out->leni + 1) * 21,96,out->lenj+10); if(out == NULL) { warn("Small shadow matrix GeneWise21 cannot be allocated, (asking for 11 by %d main cells)",out->leni+2); free_GeneWise21(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_GeneWise21(mat,dpenv) * * Descrip: This function calculates an alignment for GeneWise21 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneWise21 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneWise21 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_GeneWise21(GeneWise21 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for GeneWise21 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneWise21(mat,dpenv); score = start_end_find_end_GeneWise21(mat,&endj); out->score = score; stopstate = END; /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */ log_full_error(REPORT,0,"End at %d Score %d",endj,score); stop_reporting(); for(;;) { /*while there are more special bits to recover*/ start_reporting("Special cell aln end %d:",endj); if( read_special_strip_GeneWise21(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) { warn("Problem in reading off special state system... going to return partial alignment"); break; } if( startstate == START || endj <= 0) { log_full_error(REPORT,0,"Recovered complete alignment"); stop_reporting(); break; } log_full_error(REPORT,0,"Finished to %d",endj); stop_reporting(); /* Ok... have to eat up another piece of matrix */ temp = startstate; starti = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0); startj = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1); startstate = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2); stopi = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3); stopj = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4); stopstate = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5); /* Get out the score of this block. V. important! */ temp = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6); totalj = stopj - startj; donej = 0; start_reporting("Main matrix aln [%d,%d]:",startj,stopj); if(full_dc_GeneWise21(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) { warn("In the alignment GeneWise21 [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj); return out; } /* now have to figure out which special we came from... yikes */ max_matrix_to_special_GeneWise21(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == GeneWise21_READ_OFF_ERROR) { warn("In GeneWise21 read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj); invert_PackAln(out); recalculate_PackAln_GeneWise21(out,mat); return out; } /* if at start, break, otherwise, back to eat another strip */ if( stopstate == START) { log_full_error(REPORT,0,"Recovered complete alignment "); stop_reporting(); break; } log_full_error(REPORT,0,"Finished alignment to %d ",startj); stop_reporting(); endj = stopj; /* stopstate is correct as it is */ } /* end of while there are more special bits to recover */ invert_PackAln(out); recalculate_PackAln_GeneWise21(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_GeneWise21(mat) * * Descrip: This function calculates an alignment for GeneWise21 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneWise21 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneWise21 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneWise21 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_GeneWise21(GeneWise21 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneWise21(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_GeneWise21(mat); return out; } /* Function: AlnRangeSet_from_GeneWise21(mat) * * Descrip: This function reads off a start/end structure * for GeneWise21 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneWise21 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneWise21 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_GeneWise21(GeneWise21 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneWise21"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_GeneWise21(mat,&jpos); state = END; while( (temp = AlnRange_build_GeneWise21(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_GeneWise21(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_GeneWise21 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_GeneWise21(GeneWise21 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneWise21"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_GeneWise21(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_GeneWise21 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = GeneWise21_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_GeneWise21(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == GeneWise21_READ_OFF_ERROR) { warn("In AlnRange_build_GeneWise21 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = GeneWise21_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_GeneWise21(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_GeneWise21(GeneWise21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_GeneWise21(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneWise21_READ_OFF_ERROR) { warn("In GeneWise21 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In GeneWise21 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In GeneWise21 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_GeneWise21(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_GeneWise21(GeneWise21 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneWise21_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneWise21 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = GeneWise21_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp21->transition[GP21_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-5,MATCH); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->gp21->transition[GP21_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-4,MATCH); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp21->transition[GP21_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp21->transition[GP21_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 4,PY_2M) ) { *reti = i - 1; *retj = j - 4; *retstate = PY_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-4,PY_2M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 4,PY_2M); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 4,SPACER_2M) ) { *reti = i - 1; *retj = j - 4; *retstate = SPACER_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-4,SPACER_2M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 4,SPACER_2M); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 5,PY_1M) ) { *reti = i - 1; *retj = j - 5; *retstate = PY_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-5,PY_1M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 5,PY_1M); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 5,SPACER_1M) ) { *reti = i - 1; *retj = j - 5; *retstate = SPACER_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-5,SPACER_1M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 5,SPACER_1M); } temp = cscore - ((((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 6,PY_0M) ) { *reti = i - 1; *retj = j - 6; *retstate = PY_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-6,PY_0M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 6,PY_0M); } temp = cscore - ((((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 6,SPACER_0M) ) { *reti = i - 1; *retj = j - 6; *retstate = SPACER_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-6,SPACER_0M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 6,SPACER_0M); } /* Not allowing special sources.. skipping BEFORE_CODON */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp21->transition[GP21_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 5,INSERT) ) { *reti = i - 1; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-5,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 5,INSERT); } temp = cscore - (mat->gp21->transition[GP21_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 4,INSERT) ) { *reti = i - 1; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-4,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 4,INSERT); } temp = cscore - (mat->gp21->transition[GP21_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->gp21->transition[GP21_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 2,INSERT) ) { *reti = i - 1; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-2,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 2,INSERT); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 4,PY_2I) ) { *reti = i - 1; *retj = j - 4; *retstate = PY_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-4,PY_2I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 4,PY_2I); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 5,PY_1I) ) { *reti = i - 1; *retj = j - 5; *retstate = PY_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-5,PY_1I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 5,PY_1I); } temp = cscore - ((((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 6,PY_0I) ) { *reti = i - 1; *retj = j - 6; *retstate = PY_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-6,PY_0I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 6,PY_0I); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 4,SPACER_2I) ) { *reti = i - 1; *retj = j - 4; *retstate = SPACER_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-4,SPACER_2I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 4,SPACER_2I); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 5,SPACER_1I) ) { *reti = i - 1; *retj = j - 5; *retstate = SPACER_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-5,SPACER_1I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 5,SPACER_1I); } temp = cscore - ((((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 6,SPACER_0I) ) { *reti = i - 1; *retj = j - 6; *retstate = SPACER_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-6,SPACER_0I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 6,SPACER_0I); } /* Not allowing special sources.. skipping BEFORE_CODON */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-3,DELETE); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Not allowing special sources.. skipping BEFORE_CODON */ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return GeneWise21_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_0M : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0M); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 8,DELETE) ) { *reti = i - 0; *retj = j - 8; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-8,DELETE); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 8,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-8,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-8,MATCH); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_0M : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0M); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0M); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_0M : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_0M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_0M); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0M); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_1M : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1M); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 9,DELETE) ) { *reti = i - 0; *retj = j - 9; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-9,DELETE); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 9,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-9,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-9,MATCH); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_1M : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1M); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1M); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_1M : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_1M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_1M); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1M); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_2M : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2M); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 10,DELETE) ) { *reti = i - 0; *retj = j - 10; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-10,DELETE); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 10,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-10,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-10,MATCH); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_2M : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2M); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2M); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_2M : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_2M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_2M); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2M); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2M); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_0I : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0I); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 8,DELETE) ) { *reti = i - 0; *retj = j - 8; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-8,DELETE); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 8,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-8,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-8,MATCH); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_0I : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0I); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0I); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_0I : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_0I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_0I); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0I); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_1I : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1I); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 9,DELETE) ) { *reti = i - 0; *retj = j - 9; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-9,DELETE); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 9,DELETE); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-9,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-9,MATCH); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_1I : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1I); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1I); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_1I : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_1I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_1I); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1I); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_2I : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2I); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-10,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-10,INSERT); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])) - (0); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-10,MATCH); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_2I : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2I); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2I); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_2I : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_2I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_2I); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2I); } return GeneWise21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2I); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_GeneWise21(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_GeneWise21(GeneWise21 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > GeneWise21_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 21; add_PackAln(out,pau); } max_special_strip_GeneWise21(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneWise21_READ_OFF_ERROR) { warn("In special strip read GeneWise21, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < GeneWise21_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read GeneWise21, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 21; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_GeneWise21(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_GeneWise21(GeneWise21 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = GeneWise21_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for GeneWise21, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In GeneWise21 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = GeneWise21_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source AFTER_RND is a special */ temp = cscore - (0) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,AFTER_RND) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,AFTER_RND); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,AFTER_RND) ; } case BEFORE_RND : /* source BEFORE_CODON is a special */ temp = cscore - ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_CODON); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_CODON) ; } /* source BEFORE_RND is a special */ temp = cscore - ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_RND) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_RND); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_RND) ; } /* source START is a special */ temp = cscore - (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } case BEFORE_CODON : /* source BEFORE_SPACER is a special */ temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,BEFORE_SPACER) ) { *reti = i - 0; *retj = j - 3; *retstate = BEFORE_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-3,BEFORE_SPACER); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 3,BEFORE_SPACER) ; } /* source BEFORE_SPACER is a special */ temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 4,BEFORE_SPACER) ) { *reti = i - 0; *retj = j - 4; *retstate = BEFORE_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-4,BEFORE_SPACER); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 4,BEFORE_SPACER) ; } /* source BEFORE_SPACER is a special */ temp = cscore - (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 5,BEFORE_SPACER) ) { *reti = i - 0; *retj = j - 5; *retstate = BEFORE_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-5,BEFORE_SPACER); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 5,BEFORE_SPACER) ; } /* source BEFORE_CODON is a special */ temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,BEFORE_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-3,BEFORE_CODON); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 3,BEFORE_CODON) ; } /* source BEFORE_RND is a special */ temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,BEFORE_RND) ) { *reti = i - 0; *retj = j - 3; *retstate = BEFORE_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-3,BEFORE_RND); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 3,BEFORE_RND) ; } case BEFORE_CENTRAL : /* source BEFORE_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 10,BEFORE_CODON) ) { *reti = i - 0; *retj = j - 10; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-10,BEFORE_CODON); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 10,BEFORE_CODON) ; } /* source BEFORE_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 9,BEFORE_CODON) ) { *reti = i - 0; *retj = j - 9; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-9,BEFORE_CODON); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 9,BEFORE_CODON) ; } /* source BEFORE_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 8,BEFORE_CODON) ) { *reti = i - 0; *retj = j - 8; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-8,BEFORE_CODON); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 8,BEFORE_CODON) ; } /* source BEFORE_CENTRAL is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_CENTRAL) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_CENTRAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_CENTRAL); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_CENTRAL) ; } case BEFORE_PY_TRACT : /* source BEFORE_PY_TRACT is a special */ temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_PY_TRACT) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_PY_TRACT; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_PY_TRACT); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_PY_TRACT) ; } /* source BEFORE_CENTRAL is a special */ temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_CENTRAL) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_CENTRAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_CENTRAL); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_CENTRAL) ; } case BEFORE_SPACER : /* source BEFORE_SPACER is a special */ temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_SPACER) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_SPACER); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_SPACER) ; } /* source BEFORE_PY_TRACT is a special */ temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_PY_TRACT) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_PY_TRACT; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_PY_TRACT); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_PY_TRACT) ; } case AFTER_RND : /* source AFTER_CODON is a special */ temp = cscore - ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,AFTER_CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,AFTER_CODON); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,AFTER_CODON) ; } /* source AFTER_RND is a special */ temp = cscore - ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,AFTER_RND) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,AFTER_RND); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,AFTER_RND) ; } case AFTER_CODON : /* source AFTER_SPACER is a special */ temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,AFTER_SPACER) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-3,AFTER_SPACER); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 3,AFTER_SPACER) ; } /* source AFTER_SPACER is a special */ temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 4,AFTER_SPACER) ) { *reti = i - 0; *retj = j - 4; *retstate = AFTER_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-4,AFTER_SPACER); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 4,AFTER_SPACER) ; } /* source AFTER_SPACER is a special */ temp = cscore - (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 5,AFTER_SPACER) ) { *reti = i - 0; *retj = j - 5; *retstate = AFTER_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-5,AFTER_SPACER); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 5,AFTER_SPACER) ; } /* source AFTER_CODON is a special */ temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,AFTER_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-3,AFTER_CODON); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 3,AFTER_CODON) ; } /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ /* source AFTER_RND is a special */ temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,AFTER_RND) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-3,AFTER_RND); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 3,AFTER_RND) ; } case AFTER_CENTRAL : /* source AFTER_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 10,AFTER_CODON) ) { *reti = i - 0; *retj = j - 10; *retstate = AFTER_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-10,AFTER_CODON); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 10,AFTER_CODON) ; } /* source AFTER_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 9,AFTER_CODON) ) { *reti = i - 0; *retj = j - 9; *retstate = AFTER_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-9,AFTER_CODON); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 9,AFTER_CODON) ; } /* source AFTER_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 8,AFTER_CODON) ) { *reti = i - 0; *retj = j - 8; *retstate = AFTER_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-8,AFTER_CODON); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 8,AFTER_CODON) ; } /* source AFTER_CENTRAL is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,AFTER_CENTRAL) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_CENTRAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,AFTER_CENTRAL); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,AFTER_CENTRAL) ; } case AFTER_PY_TRACT : /* source AFTER_PY_TRACT is a special */ temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,AFTER_PY_TRACT) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_PY_TRACT; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,AFTER_PY_TRACT); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,AFTER_PY_TRACT) ; } /* source AFTER_CENTRAL is a special */ temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,AFTER_CENTRAL) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_CENTRAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,AFTER_CENTRAL); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,AFTER_CENTRAL) ; } case AFTER_SPACER : /* source AFTER_SPACER is a special */ temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,AFTER_SPACER) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,AFTER_SPACER); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,AFTER_SPACER) ; } /* source AFTER_PY_TRACT is a special */ temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,AFTER_PY_TRACT) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_PY_TRACT; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-1,AFTER_PY_TRACT); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,AFTER_PY_TRACT) ; } default: warn("Major problem (!) - in GeneWise21 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_GeneWise21(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_GeneWise21(GeneWise21 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = GeneWise21_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In GeneWise21 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source PY_2M is not a special, should not get here! */ /* Source SPACER_2M is not a special, should not get here! */ /* Source PY_1M is not a special, should not get here! */ /* Source SPACER_1M is not a special, should not get here! */ /* Source PY_0M is not a special, should not get here! */ /* Source SPACER_0M is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,BEFORE_CODON) ) { *reti = i - 1; *retj = j - 3; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-1,j-3,BEFORE_CODON); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 1,j - 3,BEFORE_CODON) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source PY_2I is not a special, should not get here! */ /* Source PY_1I is not a special, should not get here! */ /* Source PY_0I is not a special, should not get here! */ /* Source SPACER_2I is not a special, should not get here! */ /* Source SPACER_1I is not a special, should not get here! */ /* Source SPACER_0I is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,BEFORE_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-0,j-3,BEFORE_CODON); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 0,j - 3,BEFORE_CODON) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == GeneWise21_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,BEFORE_CODON) ) { *reti = i - 1; *retj = j - 0; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise21_DC_SHADOW_SPECIAL(mat,i-1,j-0,BEFORE_CODON); } return GeneWise21_DC_SHADOW_MATRIX(mat,i - 1,j - 0,BEFORE_CODON) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_0M : /* Source CENTRAL_0M is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_0M : /* Source PY_0M is not a special, should not get here! */ /* Source CENTRAL_0M is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_0M : /* Source SPACER_0M is not a special, should not get here! */ /* Source PY_0M is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_1M : /* Source CENTRAL_1M is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_1M : /* Source PY_1M is not a special, should not get here! */ /* Source CENTRAL_1M is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_1M : /* Source SPACER_1M is not a special, should not get here! */ /* Source PY_1M is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_2M : /* Source CENTRAL_2M is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_2M : /* Source PY_2M is not a special, should not get here! */ /* Source CENTRAL_2M is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_2M : /* Source SPACER_2M is not a special, should not get here! */ /* Source PY_2M is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_0I : /* Source CENTRAL_0I is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_0I : /* Source PY_0I is not a special, should not get here! */ /* Source CENTRAL_0I is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_0I : /* Source SPACER_0I is not a special, should not get here! */ /* Source PY_0I is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_1I : /* Source CENTRAL_1I is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_1I : /* Source PY_1I is not a special, should not get here! */ /* Source CENTRAL_1I is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_1I : /* Source SPACER_1I is not a special, should not get here! */ /* Source PY_1I is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_2I : /* Source CENTRAL_2I is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_2I : /* Source PY_2I is not a special, should not get here! */ /* Source CENTRAL_2I is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_2I : /* Source SPACER_2I is not a special, should not get here! */ /* Source PY_2I is not a special, should not get here! */ warn("Major problem (!) - in GeneWise21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_GeneWise21(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_GeneWise21(GeneWise21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_GeneWise21(mat,starti,startj,stopi,stopj); GeneWise21_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneWise21_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_0M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_1M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_2M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_0I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_1I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_2I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_2I) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0M to state MATCH */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_0M to state MATCH */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1M to state MATCH */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_1M to state MATCH */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2M to state MATCH */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_2M to state MATCH */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0I to state INSERT */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1I to state INSERT */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2I to state INSERT */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_0I to state INSERT */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_1I to state INSERT */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_2I to state INSERT */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise21_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_0M) = score; /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0M to state PY_0M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_0M) = score; /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0M to state SPACER_0M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_0M) = score; /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_1M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_1M) = score; /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1M to state PY_1M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_1M) = score; /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1M to state SPACER_1M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_1M) = score; /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_2M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_2M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_2M) = score; /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2M to state PY_2M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_2M) = score; /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2M to state SPACER_2M */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_2M) = score; /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_0I) = score; /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0I to state PY_0I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_0I) = score; /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0I to state SPACER_0I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_0I) = score; /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_1I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_1I) = score; /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1I to state PY_1I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_1I) = score; /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1I to state SPACER_1I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_1I) = score; /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_2I) = score; /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2I to state PY_2I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_2I) = score; /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2I to state SPACER_2I */ temp = GeneWise21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_2I) = score; /* Finished calculating state SPACER_2I */ } } return; } /* Function: init_hidden_GeneWise21(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_GeneWise21(GeneWise21 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-10);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { GeneWise21_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_0M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_1M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_2M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_0I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_1I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,PY_2I) = NEGI; GeneWise21_HIDDEN_MATRIX(mat,i,j,SPACER_2I) = NEGI; } } return; } /* Function: full_dc_GeneWise21(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_GeneWise21 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_GeneWise21 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [GeneWise21 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_GeneWise21(GeneWise21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_GeneWise21"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 50) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_GeneWise21(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_GeneWise21(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_GeneWise21(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for GeneWise21, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= GeneWise21_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= GeneWise21_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = GeneWise21_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_GeneWise21(mat,GeneWise21_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),GeneWise21_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),GeneWise21_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_GeneWise21(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_GeneWise21(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_GeneWise21(GeneWise21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_GeneWise21(mat); GeneWise21_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_GeneWise21(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_GeneWise21(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_GeneWise21(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_GeneWise21(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_GeneWise21(GeneWise21 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<10;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,1) = (-100); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,0) = (-100); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-6; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = SPACER_0M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,SPACER_0M,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-6; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = PY_0M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,PY_0M,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = SPACER_1M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,SPACER_1M,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = PY_1M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,PY_1M,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = SPACER_2M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,SPACER_2M,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = PY_2M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,PY_2M,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-6; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = SPACER_0I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,SPACER_0I,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = SPACER_1I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,SPACER_1I,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = SPACER_2I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,SPACER_2I,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-6; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = PY_0I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,PY_0I,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = PY_1I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,PY_1I,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = PY_2I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,PY_2I,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ /* For state CENTRAL_0M, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( j - 8 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,1) = j-8; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,2) = MATCH; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,5) = CENTRAL_0M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score) { score = temp; if( j - 8 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,1) = j-8; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,5) = CENTRAL_0M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score) { score = temp; if( j - 8 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,1) = j-8; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,2) = DELETE; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,5) = CENTRAL_0M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,DELETE,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,2) = CENTRAL_0M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,5) = CENTRAL_0M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0M,k); } } /* Add any movement independant score */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = score; /* Finished with state CENTRAL_0M */ /* For state PY_0M, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,2) = CENTRAL_0M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,5) = PY_0M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0M,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,2) = PY_0M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,5) = PY_0M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0M,k); } } /* Add any movement independant score */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = score; /* Finished with state PY_0M */ /* For state SPACER_0M, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,2) = PY_0M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,5) = SPACER_0M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0M,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,2) = SPACER_0M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,5) = SPACER_0M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_0M,k); } } /* Add any movement independant score */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = score; /* Finished with state SPACER_0M */ /* For state CENTRAL_1M, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( j - 9 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,1) = j-9; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,2) = MATCH; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,5) = CENTRAL_1M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score) { score = temp; if( j - 9 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,1) = j-9; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,5) = CENTRAL_1M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score) { score = temp; if( j - 9 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,1) = j-9; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,2) = DELETE; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,5) = CENTRAL_1M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,DELETE,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,2) = CENTRAL_1M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,5) = CENTRAL_1M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1M,k); } } /* Add any movement independant score */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = score; /* Finished with state CENTRAL_1M */ /* For state PY_1M, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,2) = CENTRAL_1M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,5) = PY_1M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1M,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,2) = PY_1M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,5) = PY_1M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1M,k); } } /* Add any movement independant score */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = score; /* Finished with state PY_1M */ /* For state SPACER_1M, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,2) = PY_1M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,5) = SPACER_1M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1M,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,2) = SPACER_1M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,5) = SPACER_1M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_1M,k); } } /* Add any movement independant score */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = score; /* Finished with state SPACER_1M */ /* For state CENTRAL_2M, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( j - 10 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,1) = j-10; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,2) = MATCH; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,5) = CENTRAL_2M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score) { score = temp; if( j - 10 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,1) = j-10; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,5) = CENTRAL_2M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score) { score = temp; if( j - 10 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,1) = j-10; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,2) = DELETE; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,5) = CENTRAL_2M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,DELETE,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,2) = CENTRAL_2M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,5) = CENTRAL_2M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2M,k); } } /* Add any movement independant score */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = score; /* Finished with state CENTRAL_2M */ /* For state PY_2M, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,2) = CENTRAL_2M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,5) = PY_2M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2M,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,2) = PY_2M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,5) = PY_2M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2M,k); } } /* Add any movement independant score */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = score; /* Finished with state PY_2M */ /* For state SPACER_2M, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,2) = PY_2M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,5) = SPACER_2M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2M,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,2) = SPACER_2M; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,5) = SPACER_2M; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_2M,k); } } /* Add any movement independant score */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = score; /* Finished with state SPACER_2M */ /* For state CENTRAL_0I, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( j - 8 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,1) = j-8; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,2) = MATCH; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,5) = CENTRAL_0I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score) { score = temp; if( j - 8 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,1) = j-8; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,5) = CENTRAL_0I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score) { score = temp; if( j - 8 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,1) = j-8; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,2) = DELETE; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,5) = CENTRAL_0I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,DELETE,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,2) = CENTRAL_0I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,5) = CENTRAL_0I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0I,k); } } /* Add any movement independant score */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = score; /* Finished with state CENTRAL_0I */ /* For state PY_0I, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,2) = CENTRAL_0I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,5) = PY_0I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0I,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,2) = PY_0I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,5) = PY_0I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0I,k); } } /* Add any movement independant score */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = score; /* Finished with state PY_0I */ /* For state SPACER_0I, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,2) = PY_0I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,5) = SPACER_0I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0I,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,2) = SPACER_0I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,5) = SPACER_0I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_0I,k); } } /* Add any movement independant score */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = score; /* Finished with state SPACER_0I */ /* For state CENTRAL_1I, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); if( j - 9 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,1) = j-9; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,2) = MATCH; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,5) = CENTRAL_1I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score) { score = temp; if( j - 9 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,1) = j-9; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,5) = CENTRAL_1I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score) { score = temp; if( j - 9 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,1) = j-9; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,2) = DELETE; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,5) = CENTRAL_1I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,DELETE,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,2) = CENTRAL_1I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,5) = CENTRAL_1I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1I,k); } } /* Add any movement independant score */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = score; /* Finished with state CENTRAL_1I */ /* For state PY_1I, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,2) = CENTRAL_1I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,5) = PY_1I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1I,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,2) = PY_1I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,5) = PY_1I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1I,k); } } /* Add any movement independant score */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = score; /* Finished with state PY_1I */ /* For state SPACER_1I, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,2) = PY_1I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,5) = SPACER_1I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1I,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,2) = SPACER_1I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,5) = SPACER_1I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_1I,k); } } /* Add any movement independant score */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = score; /* Finished with state SPACER_1I */ /* For state CENTRAL_2I, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); if( j - 10 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,1) = j-10; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,2) = MATCH; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,5) = CENTRAL_2I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score) { score = temp; if( j - 10 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,1) = j-10; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,5) = CENTRAL_2I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score) { score = temp; if( j - 10 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,1) = j-10; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,2) = INSERT; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,5) = CENTRAL_2I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,2) = CENTRAL_2I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,5) = CENTRAL_2I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2I,k); } } /* Add any movement independant score */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = score; /* Finished with state CENTRAL_2I */ /* For state PY_2I, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,2) = CENTRAL_2I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,5) = PY_2I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2I,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,2) = PY_2I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,5) = PY_2I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2I,k); } } /* Add any movement independant score */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = score; /* Finished with state PY_2I */ /* For state SPACER_2I, pushing when j - offj <= mergej */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,2) = PY_2I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,5) = SPACER_2I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2I,k); } temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,0) = i-0; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,1) = j-1; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,2) = SPACER_2I; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,3) = i; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,4) = j; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,5) = SPACER_2I; } else { for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,k) = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_2I,k); } } /* Add any movement independant score */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = score; /* Finished with state SPACER_2I */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_GeneWise21(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_GeneWise21(GeneWise21 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state SPACER_0M to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,SPACER_0M,k); } /* From state PY_0M to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,PY_0M,k); } /* From state SPACER_1M to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,SPACER_1M,k); } /* From state PY_1M to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,PY_1M,k); } /* From state SPACER_2M to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,SPACER_2M,k); } /* From state PY_2M to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,PY_2M,k); } /* From state MATCH to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state DELETE to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } /* From state SPACER_0I to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,SPACER_0I,k); } /* From state SPACER_1I to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,SPACER_1I,k); } /* From state SPACER_2I to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,SPACER_2I,k); } /* From state PY_0I to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,PY_0I,k); } /* From state PY_1I to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,PY_1I,k); } /* From state PY_2I to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,PY_2I,k); } /* From state INSERT to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* From state INSERT to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,k); } /* From state INSERT to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); /* From state INSERT to state CENTRAL_0M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } /* From state DELETE to state CENTRAL_0M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,DELETE,k); } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0M,k); } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0M,k); /* From state PY_0M to state PY_0M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0M,k); } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0M,k); /* From state SPACER_0M to state SPACER_0M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_0M,k); } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); /* From state INSERT to state CENTRAL_1M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } /* From state DELETE to state CENTRAL_1M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,DELETE,k); } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1M,k); } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1M,k); /* From state PY_1M to state PY_1M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1M,k); } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1M,k); /* From state SPACER_1M to state SPACER_1M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_1M,k); } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); /* From state INSERT to state CENTRAL_2M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } /* From state DELETE to state CENTRAL_2M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,DELETE,k); } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2M,k); } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2M,k); /* From state PY_2M to state PY_2M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2M,k); } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2M,k); /* From state SPACER_2M to state SPACER_2M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_2M,k); } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); /* From state INSERT to state CENTRAL_0I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } /* From state DELETE to state CENTRAL_0I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,DELETE,k); } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0I,k); } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0I,k); /* From state PY_0I to state PY_0I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0I,k); } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0I,k); /* From state SPACER_0I to state SPACER_0I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_0I,k); } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); /* From state INSERT to state CENTRAL_1I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } /* From state DELETE to state CENTRAL_1I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,DELETE,k); } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1I,k); } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1I,k); /* From state PY_1I to state PY_1I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1I,k); } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1I,k); /* From state SPACER_1I to state SPACER_1I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_1I,k); } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2I,k); } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2I,k); /* From state PY_2I to state PY_2I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2I,k); } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2I,k); /* From state SPACER_2I to state SPACER_2I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_2I,k); } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = score; for(k=0;k<7;k++) GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_2I */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_GeneWise21(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_GeneWise21(GeneWise21 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0M to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_0M to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1M to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_1M to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2M to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_2M to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0I to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1I to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2I to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_0I to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_1I to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_2I to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = score; /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0M to state PY_0M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = score; /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0M to state SPACER_0M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = score; /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_1M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = score; /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1M to state PY_1M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = score; /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1M to state SPACER_1M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = score; /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_2M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_2M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = score; /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2M to state PY_2M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = score; /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2M to state SPACER_2M */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = score; /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = score; /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0I to state PY_0I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = score; /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0I to state SPACER_0I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = score; /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_1I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = score; /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1I to state PY_1I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = score; /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1I to state SPACER_1I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = score; /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = score; /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2I to state PY_2I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = score; /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2I to state SPACER_2I */ temp = GeneWise21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = score; /* Finished calculating state SPACER_2I */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_GeneWise21(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * */ } void init_dc_GeneWise21(GeneWise21 * mat) { register int i; register int j; register int k; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GeneWise21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = NEGI; GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = NEGI; for(k=0;k<7;k++) { GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,k) = (-1); GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,k) = (-1); } } } return; } /* Function: start_end_find_end_GeneWise21(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [GeneWise21 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_GeneWise21(GeneWise21 * mat,int * endj) { register int j; register int max; register int maxj; max = GeneWise21_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_GeneWise21(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [GeneWise21] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_GeneWise21(GeneWise21 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (10 * (leni + 1) * 21,sizeof(int)); shadow_pointers = (int *) calloc (10 * (leni + 1) * 21 * 8,sizeof(int)); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state BEFORE_CODON to state MATCH */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,BEFORE_CODON) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [BEFORE_CODON] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state SPACER_0M to state MATCH */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,SPACER_0M,0)); } /* From state PY_0M to state MATCH */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,PY_0M,0)); } /* From state SPACER_1M to state MATCH */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,SPACER_1M,0)); } /* From state PY_1M to state MATCH */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,PY_1M,0)); } /* From state SPACER_2M to state MATCH */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,SPACER_2M,0)); } /* From state PY_2M to state MATCH */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,PY_2M,0)); } /* From state MATCH to state MATCH */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,i,j,AFTER_CODON) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,k) = GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,6) = GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,3) = i; GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,4) = j; GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state DELETE to state INSERT */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0)); } /* From state BEFORE_CODON to state INSERT */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,BEFORE_CODON) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [BEFORE_CODON] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state SPACER_0I to state INSERT */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,SPACER_0I,0)); } /* From state SPACER_1I to state INSERT */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,SPACER_1I,0)); } /* From state SPACER_2I to state INSERT */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,SPACER_2I,0)); } /* From state PY_0I to state INSERT */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,PY_0I,0)); } /* From state PY_1I to state INSERT */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,PY_1I,0)); } /* From state PY_2I to state INSERT */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,PY_2I,0)); } /* From state INSERT to state INSERT */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* From state INSERT to state INSERT */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,0)); } /* From state INSERT to state INSERT */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,i,j,AFTER_CODON) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,k) = GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,6) = GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,3) = i; GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,4) = j; GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state BEFORE_CODON to state DELETE */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,BEFORE_CODON) + mat->query->seg[i]->transition[GW_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [BEFORE_CODON] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,i,j,AFTER_CODON) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,k) = GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,6) = GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,3) = i; GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,4) = j; GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,5) = DELETE; } /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,0)); /* From state INSERT to state CENTRAL_0M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,0)); } /* From state DELETE to state CENTRAL_0M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,DELETE,0)); } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0M,0)); } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0M,0)); /* From state PY_0M to state PY_0M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY] +(mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0M,0)); } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,PY_0M) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,PY_0M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0M,0)); /* From state SPACER_0M to state SPACER_0M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER] +(mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_0M,0)); } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,SPACER_0M) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,0)); /* From state INSERT to state CENTRAL_1M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,0)); } /* From state DELETE to state CENTRAL_1M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,DELETE,0)); } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1M,0)); } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1M,0)); /* From state PY_1M to state PY_1M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY] +(mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1M,0)); } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,PY_1M) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,PY_1M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1M,0)); /* From state SPACER_1M to state SPACER_1M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER] +(mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_1M,0)); } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,SPACER_1M) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,0)); /* From state INSERT to state CENTRAL_2M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0)); } /* From state DELETE to state CENTRAL_2M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,DELETE,0)); } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2M,0)); } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2M,0)); /* From state PY_2M to state PY_2M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY] +(mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2M,0)); } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,PY_2M) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,PY_2M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2M,0)); /* From state SPACER_2M to state SPACER_2M */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER] +(mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_2M,0)); } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,SPACER_2M) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,0)); /* From state INSERT to state CENTRAL_0I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,0)); } /* From state DELETE to state CENTRAL_0I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,DELETE,0)); } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0I,0)); } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0I,0)); /* From state PY_0I to state PY_0I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY] +(mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0I,0)); } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,PY_0I) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,PY_0I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0I,0)); /* From state SPACER_0I to state SPACER_0I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER] +(mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_0I,0)); } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,SPACER_0I) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]) + (0); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,0)); /* From state INSERT to state CENTRAL_1I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,0)); } /* From state DELETE to state CENTRAL_1I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,DELETE,0)); } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1I,0)); } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1I,0)); /* From state PY_1I to state PY_1I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY] +(mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1I,0)); } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,PY_1I) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,PY_1I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1I,0)); /* From state SPACER_1I to state SPACER_1I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER] +(mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_1I,0)); } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,SPACER_1I) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]) + (0); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,0)); /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0)); } /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0)); } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2I,0)); } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2I,0)); /* From state PY_2I to state PY_2I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY] +(mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2I,0)); } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,PY_2I) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,PY_2I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2I,0)); /* From state SPACER_2I to state SPACER_2I */ temp = GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER] +(mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_2I,0)); } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise21_DC_OPT_SHADOW_MATRIX(mat,i,j,SPACER_2I) = score; for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_2I */ } /* end of for each i position in strip */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,END); /* Source AFTER_RND is a special source for END */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,AFTER_RND) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,AFTER_RND,k); } /* Put back score... (now updated!) */ GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_RND); /* Source START is a special source for BEFORE_RND */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,START) + (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_RND,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,START,k); } /* Source BEFORE_RND is a special source for BEFORE_RND */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_RND,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_RND,k); } /* Source BEFORE_CODON is a special source for BEFORE_RND */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_RND,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_CODON,k); } /* Put back score... (now updated!) */ GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_RND) = score; /* Finished updating state BEFORE_RND */ /* Special state BEFORE_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_CODON); /* Source BEFORE_RND is a special source for BEFORE_CODON */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,BEFORE_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_CODON,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,BEFORE_RND,k); } /* Source BEFORE_CODON is a special source for BEFORE_CODON */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,BEFORE_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_CODON,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,BEFORE_CODON,k); } /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 5,BEFORE_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_CODON,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 5,BEFORE_SPACER,k); } /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 4,BEFORE_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_CODON,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 4,BEFORE_SPACER,k); } /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,BEFORE_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_CODON,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,BEFORE_SPACER,k); } /* Put back score... (now updated!) */ GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_CODON) = score; /* Finished updating state BEFORE_CODON */ /* Special state BEFORE_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_CENTRAL); /* Source BEFORE_CENTRAL is a special source for BEFORE_CENTRAL */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_CENTRAL,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_CENTRAL,k); } /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 8,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_CENTRAL,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 8,BEFORE_CODON,k); } /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 9,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_CENTRAL,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 9,BEFORE_CODON,k); } /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 10,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_CENTRAL,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 10,BEFORE_CODON,k); } /* Put back score... (now updated!) */ GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_CENTRAL) = score; /* Finished updating state BEFORE_CENTRAL */ /* Special state BEFORE_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_PY_TRACT); /* Source BEFORE_CENTRAL is a special source for BEFORE_PY_TRACT */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_PY_TRACT,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_CENTRAL,k); } /* Source BEFORE_PY_TRACT is a special source for BEFORE_PY_TRACT */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_PY_TRACT,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_PY_TRACT,k); } /* Put back score... (now updated!) */ GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_PY_TRACT) = score; /* Finished updating state BEFORE_PY_TRACT */ /* Special state BEFORE_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_SPACER); /* Source BEFORE_PY_TRACT is a special source for BEFORE_SPACER */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_SPACER,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_PY_TRACT,k); } /* Source BEFORE_SPACER is a special source for BEFORE_SPACER */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_SPACER,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_SPACER,k); } /* Put back score... (now updated!) */ GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_SPACER) = score; /* Finished updating state BEFORE_SPACER */ /* Special state AFTER_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_RND); /* Source AFTER_RND is a special source for AFTER_RND */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,AFTER_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_RND,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,AFTER_RND,k); } /* Source AFTER_CODON is a special source for AFTER_RND */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,AFTER_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_RND,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,AFTER_CODON,k); } /* Put back score... (now updated!) */ GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_RND) = score; /* Finished updating state AFTER_RND */ /* Special state AFTER_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_CODON); /* Source AFTER_RND is a special source for AFTER_CODON */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,AFTER_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,AFTER_RND,k); } /* Source MATCH for state AFTER_CODON is not special... already calculated */ /* Source INSERT for state AFTER_CODON is not special... already calculated */ /* Source DELETE for state AFTER_CODON is not special... already calculated */ /* Source AFTER_CODON is a special source for AFTER_CODON */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,AFTER_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,AFTER_CODON,k); } /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 5,AFTER_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 5,AFTER_SPACER,k); } /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 4,AFTER_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 4,AFTER_SPACER,k); } /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,AFTER_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CODON,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,AFTER_SPACER,k); } /* Put back score... (now updated!) */ GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_CODON) = score; /* Finished updating state AFTER_CODON */ /* Special state AFTER_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_CENTRAL); /* Source AFTER_CENTRAL is a special source for AFTER_CENTRAL */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,AFTER_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CENTRAL,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,AFTER_CENTRAL,k); } /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 8,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CENTRAL,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 8,AFTER_CODON,k); } /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 9,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CENTRAL,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 9,AFTER_CODON,k); } /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 10,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_CENTRAL,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 10,AFTER_CODON,k); } /* Put back score... (now updated!) */ GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_CENTRAL) = score; /* Finished updating state AFTER_CENTRAL */ /* Special state AFTER_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_PY_TRACT); /* Source AFTER_CENTRAL is a special source for AFTER_PY_TRACT */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,AFTER_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_PY_TRACT,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,AFTER_CENTRAL,k); } /* Source AFTER_PY_TRACT is a special source for AFTER_PY_TRACT */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,AFTER_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_PY_TRACT,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,AFTER_PY_TRACT,k); } /* Put back score... (now updated!) */ GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_PY_TRACT) = score; /* Finished updating state AFTER_PY_TRACT */ /* Special state AFTER_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_SPACER); /* Source AFTER_PY_TRACT is a special source for AFTER_SPACER */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,AFTER_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_SPACER,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,AFTER_PY_TRACT,k); } /* Source AFTER_SPACER is a special source for AFTER_SPACER */ temp = GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,AFTER_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_SPACER,k) = GeneWise21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,AFTER_SPACER,k); } /* Put back score... (now updated!) */ GeneWise21_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_SPACER) = score; /* Finished updating state AFTER_SPACER */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_GeneWise21(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * */ void init_start_end_linear_GeneWise21(GeneWise21 * mat) { register int i; register int j; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GeneWise21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,0) = (-1); GeneWise21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = NEGI; GeneWise21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,0) = (-1); } } for(j=(-10);jtarget->seq->len;j++) { GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_RND) = NEGI; GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_RND,0) = (-1); GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_CODON) = NEGI; GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_CODON,0) = (-1); GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_CENTRAL) = NEGI; GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_CENTRAL,0) = (-1); GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_PY_TRACT) = NEGI; GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_PY_TRACT,0) = (-1); GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_SPACER) = NEGI; GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_SPACER,0) = (-1); GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,AFTER_RND) = NEGI; GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,j,AFTER_RND,0) = (-1); GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,AFTER_CODON) = NEGI; GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,j,AFTER_CODON,0) = (-1); GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,AFTER_CENTRAL) = NEGI; GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,j,AFTER_CENTRAL,0) = (-1); GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,AFTER_PY_TRACT) = NEGI; GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,j,AFTER_PY_TRACT,0) = (-1); GeneWise21_DC_SHADOW_SPECIAL(mat,0,j,AFTER_SPACER) = NEGI; GeneWise21_DC_SHADOW_SPECIAL_SP(mat,0,j,AFTER_SPACER,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_GeneWise21(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_GeneWise21(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_GeneWise21(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","INTRON_MATCH_0","INTRON_MATCH_1","INTRON_MATCH_2","INTRON_INSERT_0","INTRON_INSERT_1","INTRON_INSERT_2","END","BEFORE_RND_STATE","AFTER_RND_STATE" }; /* Function: AlnConvertSet_GeneWise21(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","5SS_PHASE_0","CENTRAL_INTRON","PYRIMIDINE_TRACT","SPACER","5SS_PHASE_1","5SS_PHASE_2","END","RANDOM_SEQUENCE" }; AlnConvertSet * AlnConvertSet_GeneWise21(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_CODON + 21; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_0M; acu->state2 = MATCH; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_0M; acu->state2 = MATCH; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_1M; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_1M; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_2M; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_2M; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_CODON + 21; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_0I; acu->state2 = INSERT; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_1I; acu->state2 = INSERT; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_2I; acu->state2 = INSERT; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_0I; acu->state2 = INSERT; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_1I; acu->state2 = INSERT; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_2I; acu->state2 = INSERT; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_CODON + 21; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = CENTRAL_0M; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_0M; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = CENTRAL_0M; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_0M; acu->state2 = CENTRAL_0M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_0M; acu->state2 = PY_0M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_0M; acu->state2 = PY_0M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_0M; acu->state2 = SPACER_0M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_0M; acu->state2 = SPACER_0M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = CENTRAL_1M; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_1M; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = CENTRAL_1M; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_1M; acu->state2 = CENTRAL_1M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_1M; acu->state2 = PY_1M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_1M; acu->state2 = PY_1M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_1M; acu->state2 = SPACER_1M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_1M; acu->state2 = SPACER_1M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = CENTRAL_2M; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[5]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_2M; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[5]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = CENTRAL_2M; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[5]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_2M; acu->state2 = CENTRAL_2M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_2M; acu->state2 = PY_2M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_2M; acu->state2 = PY_2M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_2M; acu->state2 = SPACER_2M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_2M; acu->state2 = SPACER_2M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = CENTRAL_0I; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[6]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_0I; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[6]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = CENTRAL_0I; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[6]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_0I; acu->state2 = CENTRAL_0I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_0I; acu->state2 = PY_0I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_0I; acu->state2 = PY_0I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_0I; acu->state2 = SPACER_0I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_0I; acu->state2 = SPACER_0I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = CENTRAL_1I; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[7]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_1I; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[7]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = CENTRAL_1I; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[7]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_1I; acu->state2 = CENTRAL_1I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_1I; acu->state2 = PY_1I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_1I; acu->state2 = PY_1I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_1I; acu->state2 = SPACER_1I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_1I; acu->state2 = SPACER_1I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = CENTRAL_2I; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[8]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_2I; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[8]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_2I; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[8]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_2I; acu->state2 = CENTRAL_2I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_2I; acu->state2 = PY_2I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_2I; acu->state2 = PY_2I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_2I; acu->state2 = SPACER_2I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_2I; acu->state2 = SPACER_2I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_RND + 21; acu->state2 = END + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[9]; acu->label2 = target_label[13]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 21; acu->state2 = BEFORE_RND + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_RND + 21; acu->state2 = BEFORE_RND + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_CODON + 21; acu->state2 = BEFORE_RND + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_RND + 21; acu->state2 = BEFORE_CODON + 21; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[10]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_CODON + 21; acu->state2 = BEFORE_CODON + 21; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[10]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_SPACER + 21; acu->state2 = BEFORE_CODON + 21; acu->offi = (-1); acu->offj = 5; acu->label1 = query_label[10]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_SPACER + 21; acu->state2 = BEFORE_CODON + 21; acu->offi = (-1); acu->offj = 4; acu->label1 = query_label[10]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_SPACER + 21; acu->state2 = BEFORE_CODON + 21; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[10]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_CENTRAL + 21; acu->state2 = BEFORE_CENTRAL + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_CODON + 21; acu->state2 = BEFORE_CENTRAL + 21; acu->offi = (-1); acu->offj = 8; acu->label1 = query_label[10]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_CODON + 21; acu->state2 = BEFORE_CENTRAL + 21; acu->offi = (-1); acu->offj = 9; acu->label1 = query_label[10]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_CODON + 21; acu->state2 = BEFORE_CENTRAL + 21; acu->offi = (-1); acu->offj = 10; acu->label1 = query_label[10]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_CENTRAL + 21; acu->state2 = BEFORE_PY_TRACT + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_PY_TRACT + 21; acu->state2 = BEFORE_PY_TRACT + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_PY_TRACT + 21; acu->state2 = BEFORE_SPACER + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_SPACER + 21; acu->state2 = BEFORE_SPACER + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_RND + 21; acu->state2 = AFTER_RND + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[11]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_CODON + 21; acu->state2 = AFTER_RND + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[11]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_RND + 21; acu->state2 = AFTER_CODON + 21; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[11]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = AFTER_CODON + 21; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[11]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = AFTER_CODON + 21; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[11]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = AFTER_CODON + 21; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[11]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_CODON + 21; acu->state2 = AFTER_CODON + 21; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[11]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_SPACER + 21; acu->state2 = AFTER_CODON + 21; acu->offi = (-1); acu->offj = 5; acu->label1 = query_label[11]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_SPACER + 21; acu->state2 = AFTER_CODON + 21; acu->offi = (-1); acu->offj = 4; acu->label1 = query_label[11]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_SPACER + 21; acu->state2 = AFTER_CODON + 21; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[11]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_CENTRAL + 21; acu->state2 = AFTER_CENTRAL + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[11]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_CODON + 21; acu->state2 = AFTER_CENTRAL + 21; acu->offi = (-1); acu->offj = 8; acu->label1 = query_label[11]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_CODON + 21; acu->state2 = AFTER_CENTRAL + 21; acu->offi = (-1); acu->offj = 9; acu->label1 = query_label[11]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_CODON + 21; acu->state2 = AFTER_CENTRAL + 21; acu->offi = (-1); acu->offj = 10; acu->label1 = query_label[11]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_CENTRAL + 21; acu->state2 = AFTER_PY_TRACT + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[11]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_PY_TRACT + 21; acu->state2 = AFTER_PY_TRACT + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[11]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_PY_TRACT + 21; acu->state2 = AFTER_SPACER + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[11]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_SPACER + 21; acu->state2 = AFTER_SPACER + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[11]; acu->label2 = target_label[10]; add_collapse_label_AlnConvertSet(out,"BEFORE_RND_STATE","RANDOM_SEQUENCE"); add_collapse_label_AlnConvertSet(out,"AFTER_RND_STATE","RANDOM_SEQUENCE"); add_collapse_label_AlnConvertSet(out,"BEFORE_RND_STATE","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"AFTER_RND_STATE","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_MATCH_0","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_MATCH_1","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_MATCH_2","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_INSERT_0","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_INSERT_1","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_INSERT_2","CENTRAL_INTRON"); return out; } /* Function: PackAln_read_Expl_GeneWise21(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_GeneWise21(GeneWise21 * mat) { GeneWise21_access_func_holder holder; holder.access_main = GeneWise21_explicit_access_main; holder.access_special = GeneWise21_explicit_access_special; return PackAln_read_generic_GeneWise21(mat,holder); } /* Function: GeneWise21_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneWise21_explicit_access_main(GeneWise21 * mat,int i,int j,int state) { return GeneWise21_EXPL_MATRIX(mat,i,j,state); } /* Function: GeneWise21_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneWise21_explicit_access_special(GeneWise21 * mat,int i,int j,int state) { return GeneWise21_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_GeneWise21(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: h [UNKN ] Undocumented argument [GeneWise21_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_GeneWise21(GeneWise21 * mat,GeneWise21_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_GeneWise21(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in GeneWise21_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 21; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_GeneWise21(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_GeneWise21(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == GeneWise21_READ_OFF_ERROR || j == GeneWise21_READ_OFF_ERROR || state == GeneWise21_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in GeneWise21_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 21; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_GeneWise21(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [GeneWise21_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_GeneWise21(GeneWise21 * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneWise21_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: GeneWise21_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void GeneWise21_debug_show_matrix(GeneWise21 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"State CENTRAL_0M %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0M)); fprintf(ofp,"State PY_0M %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,PY_0M)); fprintf(ofp,"State SPACER_0M %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0M)); fprintf(ofp,"State CENTRAL_1M %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1M)); fprintf(ofp,"State PY_1M %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,PY_1M)); fprintf(ofp,"State SPACER_1M %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1M)); fprintf(ofp,"State CENTRAL_2M %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2M)); fprintf(ofp,"State PY_2M %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,PY_2M)); fprintf(ofp,"State SPACER_2M %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2M)); fprintf(ofp,"State CENTRAL_0I %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0I)); fprintf(ofp,"State PY_0I %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,PY_0I)); fprintf(ofp,"State SPACER_0I %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0I)); fprintf(ofp,"State CENTRAL_1I %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1I)); fprintf(ofp,"State PY_1I %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,PY_1I)); fprintf(ofp,"State SPACER_1I %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1I)); fprintf(ofp,"State CENTRAL_2I %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2I)); fprintf(ofp,"State PY_2I %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,PY_2I)); fprintf(ofp,"State SPACER_2I %d\n",GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2I)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_GeneWise21(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneWise21_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_GeneWise21(GeneWise21 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneWise21_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneWise21_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneWise21 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp21->transition[GP21_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,MATCH); } return (*h.access_main)(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->gp21->transition[GP21_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH); } return (*h.access_main)(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp21->transition[GP21_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp21->transition[GP21_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,PY_2M) ) { *reti = i - 1; *retj = j - 4; *retstate = PY_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,PY_2M); } return (*h.access_main)(mat,i - 1,j - 4,PY_2M); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,SPACER_2M) ) { *reti = i - 1; *retj = j - 4; *retstate = SPACER_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,SPACER_2M); } return (*h.access_main)(mat,i - 1,j - 4,SPACER_2M); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,PY_1M) ) { *reti = i - 1; *retj = j - 5; *retstate = PY_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,PY_1M); } return (*h.access_main)(mat,i - 1,j - 5,PY_1M); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,SPACER_1M) ) { *reti = i - 1; *retj = j - 5; *retstate = SPACER_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,SPACER_1M); } return (*h.access_main)(mat,i - 1,j - 5,SPACER_1M); } temp = cscore - ((((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,PY_0M) ) { *reti = i - 1; *retj = j - 6; *retstate = PY_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,PY_0M); } return (*h.access_main)(mat,i - 1,j - 6,PY_0M); } temp = cscore - ((((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,SPACER_0M) ) { *reti = i - 1; *retj = j - 6; *retstate = SPACER_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,SPACER_0M); } return (*h.access_main)(mat,i - 1,j - 6,SPACER_0M); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 1,j - 3,BEFORE_CODON) ) { *reti = i - 1; *retj = j - 3; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,BEFORE_CODON); } return (*h.access_main)(mat,i - 1,j - 3,BEFORE_CODON); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp21->transition[GP21_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,INSERT) ) { *reti = i - 1; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,INSERT); } return (*h.access_main)(mat,i - 1,j - 5,INSERT); } temp = cscore - (mat->gp21->transition[GP21_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,INSERT) ) { *reti = i - 1; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,INSERT); } return (*h.access_main)(mat,i - 1,j - 4,INSERT); } temp = cscore - (mat->gp21->transition[GP21_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->gp21->transition[GP21_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 2,INSERT) ) { *reti = i - 1; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,INSERT); } return (*h.access_main)(mat,i - 1,j - 2,INSERT); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,PY_2I) ) { *reti = i - 1; *retj = j - 4; *retstate = PY_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,PY_2I); } return (*h.access_main)(mat,i - 1,j - 4,PY_2I); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,PY_1I) ) { *reti = i - 1; *retj = j - 5; *retstate = PY_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,PY_1I); } return (*h.access_main)(mat,i - 1,j - 5,PY_1I); } temp = cscore - ((((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,PY_0I) ) { *reti = i - 1; *retj = j - 6; *retstate = PY_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,PY_0I); } return (*h.access_main)(mat,i - 1,j - 6,PY_0I); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,SPACER_2I) ) { *reti = i - 1; *retj = j - 4; *retstate = SPACER_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,SPACER_2I); } return (*h.access_main)(mat,i - 1,j - 4,SPACER_2I); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,SPACER_1I) ) { *reti = i - 1; *retj = j - 5; *retstate = SPACER_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,SPACER_1I); } return (*h.access_main)(mat,i - 1,j - 5,SPACER_1I); } temp = cscore - ((((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,SPACER_0I) ) { *reti = i - 1; *retj = j - 6; *retstate = SPACER_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,SPACER_0I); } return (*h.access_main)(mat,i - 1,j - 6,SPACER_0I); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 0,j - 3,BEFORE_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,BEFORE_CODON); } return (*h.access_main)(mat,i - 0,j - 3,BEFORE_CODON); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE); } return (*h.access_main)(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,BEFORE_CODON) ) { *reti = i - 1; *retj = j - 0; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,BEFORE_CODON); } return (*h.access_main)(mat,i - 1,j - 0,BEFORE_CODON); } temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_0M : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_0M); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0M); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,DELETE) ) { *reti = i - 0; *retj = j - 8; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,DELETE); } return (*h.access_main)(mat,i - 0,j - 8,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,INSERT); } return (*h.access_main)(mat,i - 0,j - 8,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,MATCH); } return (*h.access_main)(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_0M : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_0M); } return (*h.access_main)(mat,i - 0,j - 1,PY_0M); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_0M); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0M); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_0M : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SPACER_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SPACER_0M); } return (*h.access_main)(mat,i - 0,j - 1,SPACER_0M); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_0M); } return (*h.access_main)(mat,i - 0,j - 1,PY_0M); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_1M : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_1M); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1M); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,DELETE) ) { *reti = i - 0; *retj = j - 9; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,DELETE); } return (*h.access_main)(mat,i - 0,j - 9,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,INSERT); } return (*h.access_main)(mat,i - 0,j - 9,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,MATCH); } return (*h.access_main)(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_1M : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_1M); } return (*h.access_main)(mat,i - 0,j - 1,PY_1M); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_1M); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1M); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_1M : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SPACER_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SPACER_1M); } return (*h.access_main)(mat,i - 0,j - 1,SPACER_1M); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_1M); } return (*h.access_main)(mat,i - 0,j - 1,PY_1M); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_2M : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_2M); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2M); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,DELETE) ) { *reti = i - 0; *retj = j - 10; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,DELETE); } return (*h.access_main)(mat,i - 0,j - 10,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT); } return (*h.access_main)(mat,i - 0,j - 10,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,MATCH); } return (*h.access_main)(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_2M : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_2M); } return (*h.access_main)(mat,i - 0,j - 1,PY_2M); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_2M); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2M); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_2M : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SPACER_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SPACER_2M); } return (*h.access_main)(mat,i - 0,j - 1,SPACER_2M); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_2M); } return (*h.access_main)(mat,i - 0,j - 1,PY_2M); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_0I : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_0I); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0I); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,DELETE) ) { *reti = i - 0; *retj = j - 8; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,DELETE); } return (*h.access_main)(mat,i - 0,j - 8,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,INSERT); } return (*h.access_main)(mat,i - 0,j - 8,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,MATCH); } return (*h.access_main)(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_0I : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_0I); } return (*h.access_main)(mat,i - 0,j - 1,PY_0I); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_0I); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0I); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_0I : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SPACER_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SPACER_0I); } return (*h.access_main)(mat,i - 0,j - 1,SPACER_0I); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_0I); } return (*h.access_main)(mat,i - 0,j - 1,PY_0I); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_1I : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_1I); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1I); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,DELETE) ) { *reti = i - 0; *retj = j - 9; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,DELETE); } return (*h.access_main)(mat,i - 0,j - 9,DELETE); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,INSERT); } return (*h.access_main)(mat,i - 0,j - 9,INSERT); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,MATCH); } return (*h.access_main)(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_1I : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_1I); } return (*h.access_main)(mat,i - 0,j - 1,PY_1I); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_1I); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1I); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_1I : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SPACER_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SPACER_1I); } return (*h.access_main)(mat,i - 0,j - 1,SPACER_1I); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_1I); } return (*h.access_main)(mat,i - 0,j - 1,PY_1I); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_2I : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_2I); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2I); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT); } return (*h.access_main)(mat,i - 0,j - 10,INSERT); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT); } return (*h.access_main)(mat,i - 0,j - 10,INSERT); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,MATCH); } return (*h.access_main)(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_2I : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_2I); } return (*h.access_main)(mat,i - 0,j - 1,PY_2I); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_2I); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2I); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_2I : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SPACER_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SPACER_2I); } return (*h.access_main)(mat,i - 0,j - 1,SPACER_2I); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_2I); } return (*h.access_main)(mat,i - 0,j - 1,PY_2I); } warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_GeneWise21(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneWise21_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_GeneWise21(GeneWise21 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneWise21_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneWise21_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In GeneWise21 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source AFTER_RND is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,AFTER_RND) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,AFTER_RND); } return (*h.access_special)(mat,i - 0,j - 1,AFTER_RND) ; } case BEFORE_RND : /* source BEFORE_CODON is a special */ temp = cscore - ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_CODON); } return (*h.access_special)(mat,i - 0,j - 1,BEFORE_CODON) ; } /* source BEFORE_RND is a special */ temp = cscore - ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_RND) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_RND); } return (*h.access_special)(mat,i - 0,j - 1,BEFORE_RND) ; } /* source START is a special */ temp = cscore - (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_special)(mat,i - 0,j - 1,START) ; } case BEFORE_CODON : /* source BEFORE_SPACER is a special */ temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,BEFORE_SPACER) ) { *reti = i - 0; *retj = j - 3; *retstate = BEFORE_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,BEFORE_SPACER); } return (*h.access_special)(mat,i - 0,j - 3,BEFORE_SPACER) ; } /* source BEFORE_SPACER is a special */ temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 4,BEFORE_SPACER) ) { *reti = i - 0; *retj = j - 4; *retstate = BEFORE_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-4,BEFORE_SPACER); } return (*h.access_special)(mat,i - 0,j - 4,BEFORE_SPACER) ; } /* source BEFORE_SPACER is a special */ temp = cscore - (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 5,BEFORE_SPACER) ) { *reti = i - 0; *retj = j - 5; *retstate = BEFORE_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-5,BEFORE_SPACER); } return (*h.access_special)(mat,i - 0,j - 5,BEFORE_SPACER) ; } /* source BEFORE_CODON is a special */ temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,BEFORE_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,BEFORE_CODON); } return (*h.access_special)(mat,i - 0,j - 3,BEFORE_CODON) ; } /* source BEFORE_RND is a special */ temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,BEFORE_RND) ) { *reti = i - 0; *retj = j - 3; *retstate = BEFORE_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,BEFORE_RND); } return (*h.access_special)(mat,i - 0,j - 3,BEFORE_RND) ; } case BEFORE_CENTRAL : /* source BEFORE_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 10,BEFORE_CODON) ) { *reti = i - 0; *retj = j - 10; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-10,BEFORE_CODON); } return (*h.access_special)(mat,i - 0,j - 10,BEFORE_CODON) ; } /* source BEFORE_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 9,BEFORE_CODON) ) { *reti = i - 0; *retj = j - 9; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-9,BEFORE_CODON); } return (*h.access_special)(mat,i - 0,j - 9,BEFORE_CODON) ; } /* source BEFORE_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 8,BEFORE_CODON) ) { *reti = i - 0; *retj = j - 8; *retstate = BEFORE_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-8,BEFORE_CODON); } return (*h.access_special)(mat,i - 0,j - 8,BEFORE_CODON) ; } /* source BEFORE_CENTRAL is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_CENTRAL) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_CENTRAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_CENTRAL); } return (*h.access_special)(mat,i - 0,j - 1,BEFORE_CENTRAL) ; } case BEFORE_PY_TRACT : /* source BEFORE_PY_TRACT is a special */ temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_PY_TRACT) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_PY_TRACT; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_PY_TRACT); } return (*h.access_special)(mat,i - 0,j - 1,BEFORE_PY_TRACT) ; } /* source BEFORE_CENTRAL is a special */ temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_CENTRAL) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_CENTRAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_CENTRAL); } return (*h.access_special)(mat,i - 0,j - 1,BEFORE_CENTRAL) ; } case BEFORE_SPACER : /* source BEFORE_SPACER is a special */ temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_SPACER) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_SPACER); } return (*h.access_special)(mat,i - 0,j - 1,BEFORE_SPACER) ; } /* source BEFORE_PY_TRACT is a special */ temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_PY_TRACT) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_PY_TRACT; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_PY_TRACT); } return (*h.access_special)(mat,i - 0,j - 1,BEFORE_PY_TRACT) ; } case AFTER_RND : /* source AFTER_CODON is a special */ temp = cscore - ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,AFTER_CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,AFTER_CODON); } return (*h.access_special)(mat,i - 0,j - 1,AFTER_CODON) ; } /* source AFTER_RND is a special */ temp = cscore - ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,AFTER_RND) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,AFTER_RND); } return (*h.access_special)(mat,i - 0,j - 1,AFTER_RND) ; } case AFTER_CODON : /* source AFTER_SPACER is a special */ temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,AFTER_SPACER) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,AFTER_SPACER); } return (*h.access_special)(mat,i - 0,j - 3,AFTER_SPACER) ; } /* source AFTER_SPACER is a special */ temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 4,AFTER_SPACER) ) { *reti = i - 0; *retj = j - 4; *retstate = AFTER_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-4,AFTER_SPACER); } return (*h.access_special)(mat,i - 0,j - 4,AFTER_SPACER) ; } /* source AFTER_SPACER is a special */ temp = cscore - (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 5,AFTER_SPACER) ) { *reti = i - 0; *retj = j - 5; *retstate = AFTER_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-5,AFTER_SPACER); } return (*h.access_special)(mat,i - 0,j - 5,AFTER_SPACER) ; } /* source AFTER_CODON is a special */ temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,AFTER_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,AFTER_CODON); } return (*h.access_special)(mat,i - 0,j - 3,AFTER_CODON) ; } /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ /* source AFTER_RND is a special */ temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,AFTER_RND) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,AFTER_RND); } return (*h.access_special)(mat,i - 0,j - 3,AFTER_RND) ; } case AFTER_CENTRAL : /* source AFTER_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 10,AFTER_CODON) ) { *reti = i - 0; *retj = j - 10; *retstate = AFTER_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-10,AFTER_CODON); } return (*h.access_special)(mat,i - 0,j - 10,AFTER_CODON) ; } /* source AFTER_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 9,AFTER_CODON) ) { *reti = i - 0; *retj = j - 9; *retstate = AFTER_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-9,AFTER_CODON); } return (*h.access_special)(mat,i - 0,j - 9,AFTER_CODON) ; } /* source AFTER_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 8,AFTER_CODON) ) { *reti = i - 0; *retj = j - 8; *retstate = AFTER_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-8,AFTER_CODON); } return (*h.access_special)(mat,i - 0,j - 8,AFTER_CODON) ; } /* source AFTER_CENTRAL is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,AFTER_CENTRAL) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_CENTRAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,AFTER_CENTRAL); } return (*h.access_special)(mat,i - 0,j - 1,AFTER_CENTRAL) ; } case AFTER_PY_TRACT : /* source AFTER_PY_TRACT is a special */ temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,AFTER_PY_TRACT) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_PY_TRACT; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,AFTER_PY_TRACT); } return (*h.access_special)(mat,i - 0,j - 1,AFTER_PY_TRACT) ; } /* source AFTER_CENTRAL is a special */ temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,AFTER_CENTRAL) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_CENTRAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,AFTER_CENTRAL); } return (*h.access_special)(mat,i - 0,j - 1,AFTER_CENTRAL) ; } case AFTER_SPACER : /* source AFTER_SPACER is a special */ temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,AFTER_SPACER) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,AFTER_SPACER); } return (*h.access_special)(mat,i - 0,j - 1,AFTER_SPACER) ; } /* source AFTER_PY_TRACT is a special */ temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,AFTER_PY_TRACT) ) { *reti = i - 0; *retj = j - 1; *retstate = AFTER_PY_TRACT; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,AFTER_PY_TRACT); } return (*h.access_special)(mat,i - 0,j - 1,AFTER_PY_TRACT) ; } default: warn("Major problem (!) - in GeneWise21 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_GeneWise21(mat) * * Descrip: This function calculates the GeneWise21 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneWise21 * * * Arg: mat [UNKN ] GeneWise21 which contains explicit basematrix memory [GeneWise21 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_GeneWise21(GeneWise21 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneWise21, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("GeneWise21 Matrix calculation: "); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_CODON to state MATCH */ temp = GeneWise21_EXPL_SPECIAL(mat,i-1,j-3,BEFORE_CODON) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0M to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_0M to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1M to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_1M to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2M to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_2M to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_CODON to state INSERT */ temp = GeneWise21_EXPL_SPECIAL(mat,i-0,j-3,BEFORE_CODON) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0I to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1I to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2I to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_0I to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_1I to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_2I to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state BEFORE_CODON to state DELETE */ temp = GeneWise21_EXPL_SPECIAL(mat,i-1,j-0,BEFORE_CODON) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) = temp; } /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0M) = score; /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0M to state PY_0M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,PY_0M) = score; /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0M to state SPACER_0M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0M) = score; /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_1M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1M) = score; /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1M to state PY_1M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,PY_1M) = score; /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1M to state SPACER_1M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1M) = score; /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_2M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_2M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2M) = score; /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2M to state PY_2M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,PY_2M) = score; /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2M to state SPACER_2M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2M) = score; /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0I) = score; /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0I to state PY_0I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,PY_0I) = score; /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0I to state SPACER_0I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0I) = score; /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_1I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1I) = score; /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1I to state PY_1I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,PY_1I) = score; /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1I to state SPACER_1I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1I) = score; /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2I) = score; /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2I to state PY_2I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,PY_2I) = score; /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2I to state SPACER_2I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2I) = score; /* Finished calculating state SPACER_2I */ } /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,END); /* Source AFTER_RND is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_RND) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_RND); /* Source START is a special source for BEFORE_RND */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,START) + (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_RND is a special source for BEFORE_RND */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_RND */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_RND) = score; /* Finished updating state BEFORE_RND */ /* Special state BEFORE_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_CODON); /* Source BEFORE_RND is a special source for BEFORE_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 3,BEFORE_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 3,BEFORE_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 5,BEFORE_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 4,BEFORE_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 3,BEFORE_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_CODON) = score; /* Finished updating state BEFORE_CODON */ /* Special state BEFORE_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_CENTRAL); /* Source BEFORE_CENTRAL is a special source for BEFORE_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 8,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 9,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 10,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_CENTRAL) = score; /* Finished updating state BEFORE_CENTRAL */ /* Special state BEFORE_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_PY_TRACT); /* Source BEFORE_CENTRAL is a special source for BEFORE_PY_TRACT */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source BEFORE_PY_TRACT is a special source for BEFORE_PY_TRACT */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_PY_TRACT) = score; /* Finished updating state BEFORE_PY_TRACT */ /* Special state BEFORE_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_SPACER); /* Source BEFORE_PY_TRACT is a special source for BEFORE_SPACER */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_SPACER */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_SPACER) = score; /* Finished updating state BEFORE_SPACER */ /* Special state AFTER_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_RND); /* Source AFTER_RND is a special source for AFTER_RND */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_RND */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_RND) = score; /* Finished updating state AFTER_RND */ /* Special state AFTER_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_CODON); /* Source AFTER_RND is a special source for AFTER_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 3,AFTER_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) score = temp; /* Source MATCH for state AFTER_CODON is not special... already calculated */ /* Source INSERT for state AFTER_CODON is not special... already calculated */ /* Source DELETE for state AFTER_CODON is not special... already calculated */ /* Source AFTER_CODON is a special source for AFTER_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 3,AFTER_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 5,AFTER_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 4,AFTER_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 3,AFTER_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_CODON) = score; /* Finished updating state AFTER_CODON */ /* Special state AFTER_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_CENTRAL); /* Source AFTER_CENTRAL is a special source for AFTER_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 8,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 9,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 10,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_CENTRAL) = score; /* Finished updating state AFTER_CENTRAL */ /* Special state AFTER_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_PY_TRACT); /* Source AFTER_CENTRAL is a special source for AFTER_PY_TRACT */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source AFTER_PY_TRACT is a special source for AFTER_PY_TRACT */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_PY_TRACT) = score; /* Finished updating state AFTER_PY_TRACT */ /* Special state AFTER_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_SPACER); /* Source AFTER_PY_TRACT is a special source for AFTER_SPACER */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_SPACER */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_SPACER) = score; /* Finished updating state AFTER_SPACER */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_GeneWise21(mat,dpenv) * * Descrip: This function calculates the GeneWise21 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneWise21 which contains explicit basematrix memory [GeneWise21 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_GeneWise21(GeneWise21 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneWise21, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-10;jleni;i++) { GeneWise21_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_0M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_1M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_2M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_0I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_1I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_2I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2I) = NEGI; } } for(j=-10;jlenj;j++) { GeneWise21_EXPL_SPECIAL(mat,i,j,START) = 0; GeneWise21_EXPL_SPECIAL(mat,i,j,END) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,BEFORE_RND) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,BEFORE_CODON) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,BEFORE_CENTRAL) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,BEFORE_PY_TRACT) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,BEFORE_SPACER) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_RND) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CENTRAL) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_PY_TRACT) = NEGI; GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_SPACER) = NEGI; } start_reporting("GeneWise21 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { GeneWise21_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_0M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_1M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_2M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_0I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_1I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,PY_2I) = NEGI; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2I) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_CODON to state MATCH */ temp = GeneWise21_EXPL_SPECIAL(mat,i-1,j-3,BEFORE_CODON) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0M to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_0M to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1M to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_1M to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2M to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_2M to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_CODON to state INSERT */ temp = GeneWise21_EXPL_SPECIAL(mat,i-0,j-3,BEFORE_CODON) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0I to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1I to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2I to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_0I to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_1I to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_2I to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise21_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise21_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state BEFORE_CODON to state DELETE */ temp = GeneWise21_EXPL_SPECIAL(mat,i-1,j-0,BEFORE_CODON) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special AFTER_CODON */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) ) { GeneWise21_EXPL_SPECIAL(mat,i,j,AFTER_CODON) = temp; } /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0M) = score; /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0M to state PY_0M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,PY_0M) = score; /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0M to state SPACER_0M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0M) = score; /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_1M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1M) = score; /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1M to state PY_1M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,PY_1M) = score; /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1M to state SPACER_1M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1M) = score; /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_2M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_2M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2M) = score; /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2M to state PY_2M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,PY_2M) = score; /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2M to state SPACER_2M */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2M) = score; /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_0I) = score; /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0I to state PY_0I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,PY_0I) = score; /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0I to state SPACER_0I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_0I) = score; /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_1I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_1I) = score; /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1I to state PY_1I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,PY_1I) = score; /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1I to state SPACER_1I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_1I) = score; /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state INSERT to state CENTRAL_2I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ GeneWise21_EXPL_MATRIX(mat,i,j,CENTRAL_2I) = score; /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2I to state PY_2I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,PY_2I) = score; /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2I to state SPACER_2I */ temp = GeneWise21_EXPL_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneWise21_EXPL_MATRIX(mat,i,j,SPACER_2I) = score; /* Finished calculating state SPACER_2I */ } /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,END); /* Source AFTER_RND is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_RND) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_RND); /* Source START is a special source for BEFORE_RND */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,START) + (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_RND is a special source for BEFORE_RND */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_RND */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_RND) = score; /* Finished updating state BEFORE_RND */ /* Special state BEFORE_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_CODON); /* Source BEFORE_RND is a special source for BEFORE_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 3,BEFORE_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 3,BEFORE_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 5,BEFORE_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 4,BEFORE_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 3,BEFORE_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_CODON) = score; /* Finished updating state BEFORE_CODON */ /* Special state BEFORE_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_CENTRAL); /* Source BEFORE_CENTRAL is a special source for BEFORE_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 8,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 9,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_CODON is a special source for BEFORE_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 10,BEFORE_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_CENTRAL) = score; /* Finished updating state BEFORE_CENTRAL */ /* Special state BEFORE_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_PY_TRACT); /* Source BEFORE_CENTRAL is a special source for BEFORE_PY_TRACT */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source BEFORE_PY_TRACT is a special source for BEFORE_PY_TRACT */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_PY_TRACT) = score; /* Finished updating state BEFORE_PY_TRACT */ /* Special state BEFORE_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_SPACER); /* Source BEFORE_PY_TRACT is a special source for BEFORE_SPACER */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source BEFORE_SPACER is a special source for BEFORE_SPACER */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,BEFORE_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,BEFORE_SPACER) = score; /* Finished updating state BEFORE_SPACER */ /* Special state AFTER_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_RND); /* Source AFTER_RND is a special source for AFTER_RND */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_RND */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_RND) = score; /* Finished updating state AFTER_RND */ /* Special state AFTER_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_CODON); /* Source AFTER_RND is a special source for AFTER_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 3,AFTER_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) score = temp; /* Source MATCH for state AFTER_CODON is not special... already calculated */ /* Source INSERT for state AFTER_CODON is not special... already calculated */ /* Source DELETE for state AFTER_CODON is not special... already calculated */ /* Source AFTER_CODON is a special source for AFTER_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 3,AFTER_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 5,AFTER_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 4,AFTER_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_CODON */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 3,AFTER_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_CODON) = score; /* Finished updating state AFTER_CODON */ /* Special state AFTER_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_CENTRAL); /* Source AFTER_CENTRAL is a special source for AFTER_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 8,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 9,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source AFTER_CODON is a special source for AFTER_CENTRAL */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 10,AFTER_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_CENTRAL) = score; /* Finished updating state AFTER_CENTRAL */ /* Special state AFTER_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_PY_TRACT); /* Source AFTER_CENTRAL is a special source for AFTER_PY_TRACT */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source AFTER_PY_TRACT is a special source for AFTER_PY_TRACT */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_PY_TRACT) = score; /* Finished updating state AFTER_PY_TRACT */ /* Special state AFTER_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_SPACER); /* Source AFTER_PY_TRACT is a special source for AFTER_SPACER */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source AFTER_SPACER is a special source for AFTER_SPACER */ temp = GeneWise21_EXPL_SPECIAL(mat,0,j - 1,AFTER_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneWise21_EXPL_SPECIAL(mat,0,j,AFTER_SPACER) = score; /* Finished updating state AFTER_SPACER */ } stop_reporting(); return TRUE; } /* Function: GeneWise21_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWise21 *] * */ GeneWise21 * GeneWise21_alloc(void) { GeneWise21 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWise21 *) ckalloc (sizeof(GeneWise21))) == NULL) { warn("GeneWise21_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_GeneWise21(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWise21 *] * * Return [UNKN ] Undocumented return value [GeneWise21 *] * */ GeneWise21 * free_GeneWise21(GeneWise21 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneWise21 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->gp21 is linked in */ /* obj->rndcodon is linked in */ /* obj->rndbase is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/genewise21.h0000644000175000001440000005002610670453714016257 0ustar philippusers#ifndef DYNAMITEgenewise21HEADERFILE #define DYNAMITEgenewise21HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "genewisemodel.h" #include "genewisemodeldb.h" struct Wise2_GeneWise21 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GeneWiseScore* query; ComplexSequence* target; GeneParser21Score * gp21; RandomCodonScore * rndcodon; RandomModelDNAScore * rndbase; } ; /* GeneWise21 defined */ #ifndef DYNAMITE_DEFINED_GeneWise21 typedef struct Wise2_GeneWise21 Wise2_GeneWise21; #define GeneWise21 Wise2_GeneWise21 #define DYNAMITE_DEFINED_GeneWise21 #endif #ifdef PTHREAD struct thread_pool_holder_GeneWise21 { GeneWiseScore* query; /* Query object placeholder */ GeneWiseDB* querydb;/* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ GenomicDB* targetdb;/* Target database object */ boolean target_init; GeneParser21Score * gp21; RandomCodonScore * rndcodon; RandomModelDNAScore * rndbase; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_GeneWise21_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(GeneWise21*,int,int,int); int (*access_special)(GeneWise21*,int,int,int); } ; /* GeneWise21_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_GeneWise21_access_func_holder typedef struct Wise2_GeneWise21_access_func_holder Wise2_GeneWise21_access_func_holder; #define GeneWise21_access_func_holder Wise2_GeneWise21_access_func_holder #define DYNAMITE_DEFINED_GeneWise21_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_GeneWise21(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_GeneWise21(GeneWise21 * mat); #define PackAln_read_Shatter_GeneWise21 Wise2_PackAln_read_Shatter_GeneWise21 /* Function: calculate_shatter_GeneWise21(mat,dpenv) * * Descrip: This function calculates the GeneWise21 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneWise21 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_GeneWise21(GeneWise21 * mat,DPEnvelope * dpenv); #define calculate_shatter_GeneWise21 Wise2_calculate_shatter_GeneWise21 /* Function: search_GeneWise21(dbsi,out,querydb,targetdb,gp21,rndcodon,rndbase) * * Descrip: This function makes a database search of GeneWise21 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp21 [UNKN ] Undocumented argument [GeneParser21Score *] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: rndbase [UNKN ] Undocumented argument [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_GeneWise21(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase); #define search_GeneWise21 Wise2_search_GeneWise21 /* Function: serial_search_GeneWise21(out,querydb,targetdb,gp21,rndcodon,rndbase) * * Descrip: This function makes a database search of GeneWise21 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp21 [UNKN ] Undocumented argument [GeneParser21Score *] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: rndbase [UNKN ] Undocumented argument [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_GeneWise21(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase); #define serial_search_GeneWise21 Wise2_serial_search_GeneWise21 /* Function: PackAln_bestmemory_GeneWise21(query,target,gp21,rndcodon,rndbase,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneWise21 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_GeneWise21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_GeneWise21 Wise2_PackAln_bestmemory_GeneWise21 /* Function: allocate_Expl_GeneWise21(query,target,gp21,rndcodon,rndbase,dpri) * * Descrip: This function allocates the GeneWise21 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneWise21_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneWise21 *] * */ GeneWise21 * Wise2_allocate_Expl_GeneWise21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase,DPRunImpl * dpri); #define allocate_Expl_GeneWise21 Wise2_allocate_Expl_GeneWise21 /* Function: recalculate_PackAln_GeneWise21(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneWise21 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * */ void Wise2_recalculate_PackAln_GeneWise21(PackAln * pal,GeneWise21 * mat); #define recalculate_PackAln_GeneWise21 Wise2_recalculate_PackAln_GeneWise21 /* Function: allocate_Small_GeneWise21(query,target,gp21,rndcodon,rndbase) * * Descrip: This function allocates the GeneWise21 structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneWise21_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [GeneWise21 *] * */ GeneWise21 * Wise2_allocate_Small_GeneWise21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase); #define allocate_Small_GeneWise21 Wise2_allocate_Small_GeneWise21 /* Function: PackAln_calculate_Small_GeneWise21(mat,dpenv) * * Descrip: This function calculates an alignment for GeneWise21 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneWise21 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneWise21 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_GeneWise21(GeneWise21 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_GeneWise21 Wise2_PackAln_calculate_Small_GeneWise21 /* Function: AlnRangeSet_calculate_Small_GeneWise21(mat) * * Descrip: This function calculates an alignment for GeneWise21 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneWise21 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneWise21 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneWise21 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_GeneWise21(GeneWise21 * mat); #define AlnRangeSet_calculate_Small_GeneWise21 Wise2_AlnRangeSet_calculate_Small_GeneWise21 /* Function: AlnRangeSet_from_GeneWise21(mat) * * Descrip: This function reads off a start/end structure * for GeneWise21 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneWise21 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneWise21 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_GeneWise21(GeneWise21 * mat); #define AlnRangeSet_from_GeneWise21 Wise2_AlnRangeSet_from_GeneWise21 /* Function: convert_PackAln_to_AlnBlock_GeneWise21(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_GeneWise21(PackAln * pal); #define convert_PackAln_to_AlnBlock_GeneWise21 Wise2_convert_PackAln_to_AlnBlock_GeneWise21 /* Function: PackAln_read_Expl_GeneWise21(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_GeneWise21(GeneWise21 * mat); #define PackAln_read_Expl_GeneWise21 Wise2_PackAln_read_Expl_GeneWise21 /* Function: PackAln_read_generic_GeneWise21(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise21 *] * Arg: h [UNKN ] Undocumented argument [GeneWise21_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_GeneWise21(GeneWise21 * mat,GeneWise21_access_func_holder h); #define PackAln_read_generic_GeneWise21 Wise2_PackAln_read_generic_GeneWise21 /* Function: calculate_GeneWise21(mat) * * Descrip: This function calculates the GeneWise21 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneWise21 * * * Arg: mat [UNKN ] GeneWise21 which contains explicit basematrix memory [GeneWise21 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_GeneWise21(GeneWise21 * mat); #define calculate_GeneWise21 Wise2_calculate_GeneWise21 /* Function: calculate_dpenv_GeneWise21(mat,dpenv) * * Descrip: This function calculates the GeneWise21 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneWise21 which contains explicit basematrix memory [GeneWise21 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_GeneWise21(GeneWise21 * mat,DPEnvelope * dpenv); #define calculate_dpenv_GeneWise21 Wise2_calculate_dpenv_GeneWise21 /* Function: GeneWise21_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWise21 *] * */ GeneWise21 * Wise2_GeneWise21_alloc(void); #define GeneWise21_alloc Wise2_GeneWise21_alloc /* Function: free_GeneWise21(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWise21 *] * * Return [UNKN ] Undocumented return value [GeneWise21 *] * */ GeneWise21 * Wise2_free_GeneWise21(GeneWise21 * obj); #define free_GeneWise21 Wise2_free_GeneWise21 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_GeneWise21_shatter_access_main(GeneWise21 * mat,int i,int j,int state); #define GeneWise21_shatter_access_main Wise2_GeneWise21_shatter_access_main int Wise2_GeneWise21_shatter_access_special(GeneWise21 * mat,int i,int j,int state); #define GeneWise21_shatter_access_special Wise2_GeneWise21_shatter_access_special void * Wise2_thread_loop_GeneWise21(void * ptr); #define thread_loop_GeneWise21 Wise2_thread_loop_GeneWise21 int Wise2_score_only_GeneWise21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase); #define score_only_GeneWise21 Wise2_score_only_GeneWise21 GeneWise21 * Wise2_allocate_GeneWise21_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase); #define allocate_GeneWise21_only Wise2_allocate_GeneWise21_only void Wise2_init_GeneWise21(GeneWise21 * mat); #define init_GeneWise21 Wise2_init_GeneWise21 AlnRange * Wise2_AlnRange_build_GeneWise21(GeneWise21 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_GeneWise21 Wise2_AlnRange_build_GeneWise21 boolean Wise2_read_hidden_GeneWise21(GeneWise21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_GeneWise21 Wise2_read_hidden_GeneWise21 int Wise2_max_hidden_GeneWise21(GeneWise21 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_GeneWise21 Wise2_max_hidden_GeneWise21 boolean Wise2_read_special_strip_GeneWise21(GeneWise21 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_GeneWise21 Wise2_read_special_strip_GeneWise21 int Wise2_max_special_strip_GeneWise21(GeneWise21 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_GeneWise21 Wise2_max_special_strip_GeneWise21 int Wise2_max_matrix_to_special_GeneWise21(GeneWise21 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_GeneWise21 Wise2_max_matrix_to_special_GeneWise21 void Wise2_calculate_hidden_GeneWise21(GeneWise21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_GeneWise21 Wise2_calculate_hidden_GeneWise21 void Wise2_init_hidden_GeneWise21(GeneWise21 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_GeneWise21 Wise2_init_hidden_GeneWise21 boolean Wise2_full_dc_GeneWise21(GeneWise21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_GeneWise21 Wise2_full_dc_GeneWise21 boolean Wise2_do_dc_single_pass_GeneWise21(GeneWise21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_GeneWise21 Wise2_do_dc_single_pass_GeneWise21 void Wise2_push_dc_at_merge_GeneWise21(GeneWise21 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_GeneWise21 Wise2_push_dc_at_merge_GeneWise21 void Wise2_follow_on_dc_GeneWise21(GeneWise21 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_GeneWise21 Wise2_follow_on_dc_GeneWise21 void Wise2_run_up_dc_GeneWise21(GeneWise21 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_GeneWise21 Wise2_run_up_dc_GeneWise21 void Wise2_init_dc_GeneWise21(GeneWise21 * mat); #define init_dc_GeneWise21 Wise2_init_dc_GeneWise21 int Wise2_start_end_find_end_GeneWise21(GeneWise21 * mat,int * endj); #define start_end_find_end_GeneWise21 Wise2_start_end_find_end_GeneWise21 boolean Wise2_dc_optimised_start_end_calc_GeneWise21(GeneWise21 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_GeneWise21 Wise2_dc_optimised_start_end_calc_GeneWise21 void Wise2_init_start_end_linear_GeneWise21(GeneWise21 * mat); #define init_start_end_linear_GeneWise21 Wise2_init_start_end_linear_GeneWise21 AlnConvertSet * Wise2_AlnConvertSet_GeneWise21(void); #define AlnConvertSet_GeneWise21 Wise2_AlnConvertSet_GeneWise21 int Wise2_GeneWise21_explicit_access_main(GeneWise21 * mat,int i,int j,int state); #define GeneWise21_explicit_access_main Wise2_GeneWise21_explicit_access_main int Wise2_GeneWise21_explicit_access_special(GeneWise21 * mat,int i,int j,int state); #define GeneWise21_explicit_access_special Wise2_GeneWise21_explicit_access_special int Wise2_find_end_GeneWise21(GeneWise21 * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneWise21_access_func_holder h); #define find_end_GeneWise21 Wise2_find_end_GeneWise21 void Wise2_GeneWise21_debug_show_matrix(GeneWise21 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define GeneWise21_debug_show_matrix Wise2_GeneWise21_debug_show_matrix int Wise2_max_calc_GeneWise21(GeneWise21 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneWise21_access_func_holder h); #define max_calc_GeneWise21 Wise2_max_calc_GeneWise21 int Wise2_max_calc_special_GeneWise21(GeneWise21 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneWise21_access_func_holder h); #define max_calc_special_GeneWise21 Wise2_max_calc_special_GeneWise21 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/genewise4.dy0000644000175000001440000001350607313404545016365 0ustar philippusers/* Last edited: Mar 5 10:27 1997 (birney) */ %{ #include "dyna.h" #include "geneparser4.h" #include "genewisemodel.h" #include "genewisemodeldb.h" %} matrix GeneWise4 query type="GENEWISEMODEL" name="query" field:len="len" target type="GENOMIC" name="target" resource type="GeneParser4Score *" name="gp" extern name="GW_*" type="int" extern name="GP4_*" type="int" state MATCH offi="1" offj="3" calc="GENOMIC_CDS_POT(target,j)" source MATCH calc="query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource # # phase 0,1,2 introns can calculate whole amino acid for 0. # source INTRON offi="1" offj="6" calc="query->seg[i]->transition[GW_MATCH2MATCH] + gp->transition[GP4_INTRON2CDS] + query->seg[i]->match[GENOMIC_CODON(target,j)]+GENOMIC_3SS(target,j-3)+query->seg[i]->transition[GW_MATCH_BALANCE_3SS]" target_label 3SS_PHASE_0 endsource source INTRON offi="1" offj="5" calc="query->seg[i]->transition[GW_MATCH2MATCH] + gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source INTRON offi="1" offj="4" calc="query->seg[i]->transition[GW_MATCH2MATCH] + gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource # # Sequencing error transitions, at offsets 2 and 4 (covers both frames) # source MATCH offi="1" offj="2" calc="gp->transition[GP4_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="4" calc="gp->transition[GP4_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource query_label MATCH_STATE target_label CODON endstate # # Insert state: does not move along model, produces DNA sequence... # state INSERT offi="0" offj="3" calc="GENOMIC_CDS_POT(target,j)" source MATCH calc="query->seg[i]->transition[GW_MATCH2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource # # phase 0,1,2 introns can calculate whole amino acid for 0. # source INTRON offi="0" offj="6" calc="query->seg[i]->transition[GW_INSERT2INSERT] + gp->transition[GP4_INTRON2CDS] + query->seg[i]->match[GENOMIC_CODON(target,j)]+GENOMIC_3SS(target,j-3)+query->seg[i]->transition[GW_INSERT_BALANCE_3SS]" target_label 3SS_PHASE_0 endsource source INTRON offi="0" offj="5" calc="query->seg[i]->transition[GW_INSERT2INSERT] + gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source INTRON offi="0" offj="4" calc="query->seg[i]->transition[GW_INSERT2INSERT] + gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource # # Sequencing error transitions: because insertions are "for free" usually, we will # only model sequence deletion here. Could produce odd results though! # source INSERT offi="0" offj="2" calc="gp->transition[GP4_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="1" calc="gp->transition[GP4_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="query->seg[i]->transition[GW_MATCH2DELETE]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2DELETE]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2DELETE]" endsource source START calc="query->seg[i]->transition[GW_START2DELETE]" endsource query_label DELETE_STATE target_label INSERT endstate # # Intron state: Merge phase and match/insert stuff. # state INTRON offi="0" offj="1" source MATCH offj="8" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)+ query->seg[i]->transition[GW_MATCH_BALANCE_5SS]" target_label 5SS_PHASE_0 endsource source INSERT offj="8" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)+ query->seg[i]->transition[GW_INSERT_BALANCE_5SS]" target_label 5SS_PHASE_0 endsource source MATCH offj="9" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_1 endsource source INSERT offj="9" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_1 endsource source MATCH offj="10" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_2 endsource source INSERT offj="10" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_2 endsource source INTRON offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state START !start !special defscore="0" endstate state END !end !special source MATCH calc="query->seg[i]->transition[GW_MATCH2END]" endsource target_label END query_label END endstate # # collapse Intron labels! # collapse INTRON_STATE CENTRAL_INTRON endmatrix %{ #include "genewise4.h" %} wise-2.4.1/src/models/genewise6.dy0000644000175000001440000001501007640617710016362 0ustar philippusers/* Last edited: Mar 5 10:27 1997 (birney) */ %{ #include "dyna.h" #include "geneparser4.h" #include "genewisemodel.h" #include "genewisemodeldb.h" %} matrix GeneWise6 query type="GENEWISEMODEL" name="query" field:len="len" target type="GENOMIC" name="target" resource type="GeneParser4Score *" name="gp" extern name="GW_*" type="int" extern name="GP4_*" type="int" state MATCH offi="1" offj="3" calc="GENOMIC_CDS_POT(target,j)" source MATCH calc="query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource # # phase 0,1,2 introns can calculate whole amino acid for 0. # source INTRON_0 offi="1" offj="6" calc="query->seg[i]->transition[GW_MATCH2MATCH] + gp->transition[GP4_INTRON2CDS] + query->seg[i]->match[GENOMIC_CODON(target,j)]+GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source INTRON_1 offi="1" offj="5" calc="query->seg[i]->transition[GW_MATCH2MATCH] + gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source INTRON_2 offi="1" offj="4" calc="query->seg[i]->transition[GW_MATCH2MATCH] + gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource # # Sequencing error transitions, at offsets 1,2,4,5 for delete 1,2 or insert 1,2 # source MATCH offi="1" offj="2" calc="gp->transition[GP4_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="1" calc="gp->transition[GP4_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="4" calc="gp->transition[GP4_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source MATCH offi="1" offj="5" calc="gp->transition[GP4_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource query_label MATCH_STATE target_label CODON endstate # # Insert state: does not move along model, produces DNA sequence... # state INSERT offi="0" offj="3" calc="GENOMIC_CDS_POT(target,j)" source MATCH calc="query->seg[i]->transition[GW_MATCH2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource # # phase 0,1,2 introns can calculate whole amino acid for 0. # source INTRON_0 offi="0" offj="6" calc="query->seg[i]->transition[GW_INSERT2INSERT] + gp->transition[GP4_INTRON2CDS] + query->seg[i]->match[GENOMIC_CODON(target,j)]+GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source INTRON_1 offi="0" offj="5" calc="query->seg[i]->transition[GW_INSERT2INSERT] + gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source INTRON_2 offi="0" offj="4" calc="query->seg[i]->transition[GW_INSERT2INSERT] + gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource # # Sequencing error transitions: because insertions are "for free" usually, we will # only model sequence deletion here. Could produce odd results though! # source INSERT offi="0" offj="2" calc="gp->transition[GP4_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="1" calc="gp->transition[GP4_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="query->seg[i]->transition[GW_MATCH2DELETE]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2DELETE]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2DELETE]" endsource source START calc="query->seg[i]->transition[GW_START2DELETE]" endsource query_label DELETE_STATE target_label INSERT endstate # # Intron state: 3 separate phases, and merge INSERT/MATCH information # state INTRON_0 offi="0" offj="1" source MATCH offj="8" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_0 endsource source INSERT offj="8" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_0 endsource source INTRON_0 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state INTRON_1 offi="0" offj="1" source MATCH offj="9" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_1 endsource source INSERT offj="9" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_1 endsource source INTRON_1 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state INTRON_2 offi="0" offj="1" source MATCH offj="10" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_2 endsource source INSERT offj="10" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_2 endsource source INTRON_2 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state START !start !special endstate state END !end !special source MATCH calc="query->seg[i]->transition[GW_MATCH2END]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2END]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2END]" endsource target_label END query_label END endstate # # collapse Intron labels! # collapse INTRON_STATE CENTRAL_INTRON endmatrix %{ #include "genewise6.h" %} wise-2.4.1/src/models/dnawise.c0000644000175000001440000000365007547571136015744 0ustar philippusers#include "dnahmmdp.h" #include "version.h" #include "seqaligndisplay.h" char * program_name = "dnawise"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s query_alignment target_sequence\n",program_name); show_help_DPRunImpl(ofp); show_standard_options(ofp); } int main(int argc,char ** argv) { DPRunImpl * dpri = NULL; SeqAlign * query; Sequence * target; ComplexSequence * cseq; ComplexSequenceEvalSet * cses; DnaHmmProb * dhp; DnaHmmScore * dhs; RandomModelDNA * rmd; PackAln * pal; AlnBlock * alb; dpri = new_DPRunImpl_from_argv(&argc,argv); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 3 ) { show_help(stdout); exit(12); } query = read_selex_SeqAlign_file(argv[1]); target = read_fasta_file_Sequence(argv[2]); assert(query); assert(target); cses = default_DNA_ComplexSequenceEvalSet(); dhp = new_DnaHmmProb_from_SeqAlign_ungapped(query,1.0); rmd = RandomModelDNA_std(); cseq = new_ComplexSequence(target,cses); make_consensus_DnaHmmProb(dhp); fold_RandomModelDNA_DnaHmmProb(dhp,rmd,1.0); dhs = DnaHmmScore_from_DnaHmmProb(dhp); pal = PackAln_bestmemory_DnaHmmMatrix(dhs,cseq,Probability2Score(1.0),NULL,dpri); alb = convert_PackAln_to_AlnBlock_DnaHmmMatrix(pal); write_pretty_str_align(alb,"align",dhp->consensus,target->name,target->seq,12,50,stdout); } wise-2.4.1/src/models/genestats.dy0000644000175000001440000005002010413710424016447 0ustar philippusers %{ #include "wisebase.h" #include "seqalign.h" #include "pwmdna.h" #include "randommodel.h" #include "complexsequence.h" #include "complexevalset.h" /* for the standard evals */ #define DEFAULT_SPLICE_OFFSET_SCORE 1.5 %} struct SpliceSiteScore pwmDNAScore * score int offset Score min_collar Score max_collar Score score_offset struct GeneStats SeqAlign * splice5 int splice5_offset SeqAlign * splice3 int splice3_offset RandomModelDNA * intron; !def="NULL"// actually counts double average_intron RandomModelDNA * polyp; !def="NULL"// actually counts double average_polyp RandomModelDNA * rnd; !def="NULL" double codon[64] %info This structure is to hold the new generation of gene statistics for the genewise algorithms %% struct GeneModelParam double splice5_pseudo double splice3_pseudo double intron_emission_pseudo double polyp_emission_pseudo Bits min_collar Bits max_collar Bits score_offset char * gene_stats_file boolean use_gtag_splice double prob_for_gtag %info A small helper object containing the ways of converting the actual counts/alignments to the model Here really for convience so we can keep all the code associated with the creation of the GeneModel together %% struct GeneModel pwmDNA * splice5 int splice5_offset pwmDNA * splice3 int splice3_offset RandomModelDNA * intron double intron_stay_prob RandomModelDNA * polyp double polyp_stay_prob RandomModelDNA * rnd SpliceSiteScore * splice5score SpliceSiteScore * splice3score double codon[64] boolean use_gtag_splice Score score_for_gtag %info This structure is to hold the new generation of models for the genewise algorithm %% struct GeneralGeneModelScore RandomCodonScore * start RandomCodonScore * stop RandomCodonScore * general %{ #include "genestats.h" %func Shows help %% void show_help_GeneModelParam(FILE * ofp) { fprintf(ofp,"New gene model statistics\n"); fprintf(ofp," -splice_max_collar [5.0] maximum Bits value for a splice site \n"); fprintf(ofp," -splice_min_collar [-5.0] minimum Bits value for a splice site \n"); fprintf(ofp," -splice_score_offset [%.1f] score offset for splice sites\n",DEFAULT_SPLICE_OFFSET_SCORE); fprintf(ofp," -[no]splice_gtag make just gtag splice sites (default is gtag, ie no model)\n"); fprintf(ofp," -splice_gtag_prob [0.001] probability for gt/ag \n"); fprintf(ofp," -genestats [gene.stat]\n"); } %func Shows genemodel param for info %% void show_info_GeneModelParam(GeneModelParam * p,FILE * ofp) { fprintf(ofp,"Gene Parameter file: %s\n",p->gene_stats_file); fprintf(ofp,"Splice site model: %s\n",p->use_gtag_splice == TRUE ? "GT/AG only" : "Position Weight Matrix"); if( p->use_gtag_splice == FALSE ) { fprintf(ofp,"Pseudo counts 5'SS %1.2f\n",p->splice5_pseudo); fprintf(ofp,"Pseudo counts 3'SS %1.2f\n",p->splice3_pseudo); fprintf(ofp,"Minimum SS collar %2.2f\n",p->min_collar); fprintf(ofp,"Maximum SS collar %2.2f\n",p->max_collar); fprintf(ofp,"Splice site offset %2.2f\n",p->score_offset); } else { fprintf(ofp,"GT/AG bits penalty %2.2f\n",Probability2Bits(p->prob_for_gtag)); } } %func Makes a GeneModelParam from argv %% GeneModelParam * new_GeneModelParam_from_argv(int * argc,char ** argv) { GeneModelParam * out; char * temp; out = std_GeneModelParam(); if( (temp=strip_out_assigned_argument(argc,argv,"splice_min_collar")) != NULL ) { if( is_double_string(temp,&out->min_collar) == FALSE ) { warn("%s is not a floating point number. Can't be a splice_min_collar",temp); free_GeneModelParam(out); return NULL; } } strip_out_boolean_def_argument(argc,argv,"splice_gtag",&out->use_gtag_splice); if( (temp=strip_out_assigned_argument(argc,argv,"splice_max_collar")) != NULL ) { if( is_double_string(temp,&out->max_collar) == FALSE ) { warn("%s is not a floating point number. Can't be a splice_max_collar",temp); free_GeneModelParam(out); return NULL; } } if( (temp=strip_out_assigned_argument(argc,argv,"splice_score_offset")) != NULL ) { if( is_double_string(temp,&out->score_offset) == FALSE ) { warn("%s is not a floating point number. Can't be a splice_score_offset",temp); free_GeneModelParam(out); return NULL; } } if( (temp=strip_out_assigned_argument(argc,argv,"genestats")) != NULL ) { if( out->gene_stats_file != NULL ) { ckfree(out->gene_stats_file); } out->gene_stats_file = stringalloc(temp); } if( (temp=strip_out_assigned_argument(argc,argv,"splice_gtag_prob")) != NULL ) { if( is_double_string(temp,&out->prob_for_gtag) == FALSE ) { warn("%s is not a floating pointer number. Can't be a probability for gtag",temp); free_GeneModelParam(out); return NULL; } } return out; } %func Makes a vanilla general gene model score %% GeneralGeneModelScore * vanilla_GeneralGeneModelScore(CodonTable * ct,Probability start_odds,Probability general_odds,Probability stop_odds) { GeneralGeneModelScore * out; RandomCodon * temp; out = GeneralGeneModelScore_alloc(); temp = vanilla_start_RandomCodon(ct,start_odds); out->start = RandomCodonScore_from_RandomCodon(temp); free_RandomCodon(temp); temp = vanilla_stop_RandomCodon(ct,stop_odds); out->stop = RandomCodonScore_from_RandomCodon(temp); free_RandomCodon(temp); temp = vanilla_general_RandomCodon(ct,general_odds); out->general = RandomCodonScore_from_RandomCodon(temp); free_RandomCodon(temp); return out; } %func Makes a vanilla (ie, all things equal) Met based start codon rndscore %% RandomCodon * vanilla_start_RandomCodon(CodonTable * ct,Probability start_codon_odd_prob) { int i; RandomCodon * out; out = RandomCodon_alloc(); for(i=0;i<125;i++) { if( aminoacid_from_codon(ct,i) == 'M' ) { out->codon[i] = start_codon_odd_prob; } else { out->codon[i] = 0.0; } } return out; } %func Makes a vanilla (ie, all things equal) * based stop codon rndscore %% RandomCodon * vanilla_stop_RandomCodon(CodonTable * ct,Probability stop_codon_odd_prob) { int i; RandomCodon * out; out = RandomCodon_alloc(); for(i=0;i<125;i++) { if( aminoacid_from_codon(ct,i) == 'X' ) { out->codon[i] = stop_codon_odd_prob; } else { out->codon[i] = 0.0; } } return out; } %func Makes a vanilla (ie, all things equal) general non-stop %% RandomCodon * vanilla_general_RandomCodon(CodonTable * ct,Probability coding_odd_prob) { int i; RandomCodon * out; out = RandomCodon_alloc(); for(i=0;i<125;i++) { if( aminoacid_from_codon(ct,i) == 'X' ) { out->codon[i] = 0.0; } else { out->codon[i] = coding_odd_prob; } } return out; } %func Makes a standard GeneModelParam %% GeneModelParam * std_GeneModelParam(void) { GeneModelParam * out; out = GeneModelParam_alloc(); out->splice5_pseudo = 1.0; out->splice3_pseudo = 1.0; out->intron_emission_pseudo = 1.0; out->polyp_emission_pseudo = 1.0; out->min_collar = -5.0; out->max_collar = +5.0; out->score_offset = DEFAULT_SPLICE_OFFSET_SCORE; out->gene_stats_file = stringalloc("gene.stat"); out->use_gtag_splice = TRUE; out->prob_for_gtag = 0.001; return out; } %func Combines GeneStats_from_GeneModelParam and GeneModel_from_GeneStats %% GeneModel * GeneModel_from_GeneModelParam(GeneModelParam * p) { GeneStats * st; GeneModel * out; assert(p); st = GeneStats_from_GeneModelParam(p); assert(st); out = GeneModel_from_GeneStats(st,p); assert(out); free_GeneStats(st); return out; } %func Makes a GeneStats from GeneModelParam - basically just opening the file %% GeneStats * GeneStats_from_GeneModelParam(GeneModelParam * p) { GeneStats * gs; FILE * ifp; assert(p); assert(p->gene_stats_file); ifp = openfile(p->gene_stats_file,"r"); if( ifp == NULL ) { warn("Unable to open %s as gene stats file",p->gene_stats_file); return NULL; } gs = read_GeneStats(ifp); return gs; } %func Makes a model from the stats file %% GeneModel * GeneModel_from_GeneStats(GeneStats * gs,GeneModelParam * p) { GeneModel * out; int i; double total; out = GeneModel_alloc(); assert(gs); assert(gs->splice5); assert(gs->splice3); assert(gs->intron); assert(gs->rnd); for(i=0;i<64;i++) { out->codon[i] = gs->codon[i]; } out->splice5 = pwmDNA_from_SeqAlign(gs->splice5,p->splice5_pseudo); /* fprintf(stdout,"GS splice5 %d splice3 %d\n",gs->splice5,gs->splice3);*/ fold_randommodel_pwmDNA(out->splice5,gs->rnd); out->splice5score = SpliceSiteScore_alloc(); out->splice5score->score = pwmDNAScore_from_pwmDNA(out->splice5); out->splice5score->offset = gs->splice5_offset; out->splice5score->min_collar = Probability2Score(Bits2Probability(p->min_collar)); out->splice5score->max_collar = Probability2Score(Bits2Probability(p->max_collar)); out->splice5score->score_offset = Probability2Score(Bits2Probability(p->score_offset)); out->splice3 = pwmDNA_from_SeqAlign(gs->splice3,p->splice3_pseudo); fold_randommodel_pwmDNA(out->splice3,gs->rnd); out->splice3score = SpliceSiteScore_alloc(); out->splice3score->score = pwmDNAScore_from_pwmDNA(out->splice3); out->splice3score->offset = gs->splice3_offset; out->splice3score->min_collar = Probability2Score(Bits2Probability(p->min_collar)); out->splice3score->max_collar = Probability2Score(Bits2Probability(p->max_collar)); out->splice3score->score_offset = Probability2Score(Bits2Probability(p->score_offset)); out->use_gtag_splice = p->use_gtag_splice; out->score_for_gtag = Probability2Score(p->prob_for_gtag); out->intron = RandomModelDNA_alloc(); for(total = 0.0,i=0;i<4;i++) total += gs->intron->base[i] + p->intron_emission_pseudo; for(i=0;i<4;i++) out->intron->base[i] = (gs->intron->base[i] + p->intron_emission_pseudo)/total; out->intron->base[4] = 1.0; if( gs->polyp != NULL ) { out->polyp = RandomModelDNA_alloc(); for(total = 0.0,i=0;i<4;i++) total += gs->polyp->base[i] + p->polyp_emission_pseudo; for(i=0;i<4;i++) out->polyp->base[i] = (gs->polyp->base[i] + p->polyp_emission_pseudo)/total; } out->rnd = hard_link_RandomModelDNA(gs->rnd); return out; } %func shows a genemodel %% void show_GeneModel(GeneModel * gm,FILE * ofp) { fprintf(ofp,"Splice5\n"); show_pwmDNA_col(gm->splice5,ofp); fprintf(ofp,"Splice3\n"); show_pwmDNA_col(gm->splice3,ofp); } %func Makes an entire ComplexSequenceEvalSet for genomic work %% ComplexSequenceEvalSet * new_ComplexSequenceEvalSet_from_GeneModel(GeneModel * gm) { ComplexSequenceEvalSet * out; assert(gm); assert(gm->splice5score); assert(gm->splice3score); out = ComplexSequenceEvalSet_alloc_len(11); add_ComplexSequenceEvalSet(out,base_number_ComplexSequenceEval()); add_ComplexSequenceEvalSet(out,codon_number_ComplexSequenceEval()); if( gm->use_gtag_splice == FALSE ) { add_ComplexSequenceEvalSet(out,ComplexSequenceEval_from_pwmDNAScore_splice(gm->splice5score)); add_ComplexSequenceEvalSet(out,ComplexSequenceEval_from_pwmDNAScore_splice(gm->splice3score)); } else { add_ComplexSequenceEvalSet(out,ComplexSequenceEval_for_scored_gt(&gm->score_for_gtag)); add_ComplexSequenceEvalSet(out,ComplexSequenceEval_for_scored_ag(&gm->score_for_gtag)); } add_ComplexSequenceEvalSet(out,flat_zero()); add_ComplexSequenceEvalSet(out,flat_zero()); out->type = SEQUENCE_GENOMIC; prepare_ComplexSequenceEvalSet(out); return out; } %func Makes a ComplexSequenceEval for a GT rule %type internal %% ComplexSequenceEval * ComplexSequenceEval_for_scored_ag(Score * score_for_ag) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); out->left_window = 3; out->right_window = 3; out->left_lookback = 5; out->outside_score = NEGI; out->data = (void*) score_for_ag; out->type = SEQUENCE_GENOMIC; out->eval_func = scored_ag_eval_func; out->score_type = CseScoreType_Bits; return out; } %func Function which actually does the evaluation for scored doners %type internal %arg %% int scored_ag_eval_func(int type,void *data,char * seq) { if( *(seq-1) == 'A' && *(seq) == 'G' ) return *(Score *)data; else return NEGI; } %func Makes a ComplexSequenceEval for a GT rule %type internal %% ComplexSequenceEval * ComplexSequenceEval_for_scored_gt(Score * score_for_gt) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); out->left_window = 3; out->right_window = 7; out->left_lookback = 8; out->outside_score = NEGI; out->data = (void*) score_for_gt; out->type = SEQUENCE_GENOMIC; out->eval_func = scored_gt_eval_func; out->score_type = CseScoreType_Bits; return out; } %func Function which actually does the evaluation for scored doners %type internal %arg %% int scored_gt_eval_func(int type,void *data,char * seq) { if( *(seq) == 'G' && *(seq+1) == 'T' ) return *(Score *)data; else return NEGI; } %func Makes a ComplexSequenceEval for a splice site pwmdna %type internal %% ComplexSequenceEval * ComplexSequenceEval_from_pwmDNAScore_splice(SpliceSiteScore * score) { ComplexSequenceEval * out; /* printf("Making CSE from %d\n",score);*/ out = ComplexSequenceEval_alloc(); /* shouldn't really add ones, but this is ok anyway. Yukky hack due to not understanding a bug in the window determination */ /** *STILL don't know precisely what is going on down here! ***/ /* out->left_window = ssm->offset + ssm->pre_splice_site +1; */ out->left_window =10; /* out->right_window = ssm->offset + ssm->post_splice_site +1; */ out->right_window =10; out->left_lookback =10; out->outside_score= NEGI; out->data_type = 245; /* any old key */ out->data = (void *) score; out->type = SEQUENCE_GENOMIC; out->eval_func = pwmDNA_splice_ComplexSequence_eval_func; out->score_type = CseScoreType_Bits; return out; } %func This function is used as a pointer to function in the eval func You should never be using this function yourself! %type internal %% int pwmDNA_splice_ComplexSequence_eval_func(int type,void * data,char * seq) { SpliceSiteScore * sc; pwmDNAScore * pds; int score; sc = (SpliceSiteScore* ) data; pds = sc->score; /* offset is written in biological coordinates. Need to get c style coordiates */ /* no idea what is happening here, but it works ;) */ if( seq[0] == 'N' && seq[1] == 'N' && seq[2] == 'N' ) { return NEGI; } score = score_pwmDNAScore_string(pds,seq-sc->offset+1); /* printf("Offset is %d %c%c%c\n",sc->offset,seq[0],seq[1],seq[2]);*/ /* fprintf(stdout,"Before collaring, %d\n",score);*/ if( score < sc->min_collar ) { score = sc->min_collar; } if( score > sc->max_collar ) { score = sc->max_collar; } /* fprintf(stdout,"Score %d before offset\n",score);*/ score -= sc->score_offset; /* fprintf(stdout,"Score %d after offset\n",score);*/ /* fprintf(stderr,"Scoring %d at some position\n",score);*/ return score; } %func Reads a GeneStats file %% GeneStats * read_GeneStats(FILE * ifp) { char buffer[MAXLINE]; GeneStats * out; SeqAlign * temp; char **base; char **brk; out = GeneStats_alloc(); out->rnd = NULL; while( fgets(buffer,MAXLINE,ifp) != NULL ) { /* fprintf(stderr,"Reading (main loop) %s",buffer); */ if( buffer[0] == '#' ) continue; if( buffer[0] == '%' && buffer[1] == '%' ) break; if( strstartcmp(buffer,"splice5") == 0 ) { base = brk = breakstring(buffer,spacestr); if( *brk == NULL || *(brk+1) == NULL || is_integer_string(*(brk+1),&out->splice5_offset) == 0) { warn("Cannot read splice5 offset - must be splice5 "); return NULL; } ckfree(base); temp = read_selex_SeqAlign(ifp); if( temp == NULL ) { warn("Could not read in selex alignment for splice5"); continue; } out->splice5 = temp; continue; } if( strstartcmp(buffer,"splice3") == 0 ) { base = brk = breakstring(buffer,spacestr); if( *brk == NULL || *(brk+1) == NULL || is_integer_string(*(brk+1),&out->splice3_offset) == 0) { warn("Cannot read splice3 offset - must be splice3 "); return NULL; } ckfree(base); temp = read_selex_SeqAlign(ifp); if( temp == NULL ) { warn("Could not read in selex alignment for splice5"); continue; } out->splice3 = temp; continue; } if( strstartcmp(buffer,"intron_emission") == 0 ) { if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Could not read in intron emission line"); break; } out->intron = get_genestat_emission(buffer); if( fgets(buffer,MAXLINE,ifp) != NULL ) { continue; } else { break; } } if( strstartcmp(buffer,"polyp_emission") == 0 ) { if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Could not read in polyp emission line"); break; } out->polyp = get_genestat_emission(buffer); if( fgets(buffer,MAXLINE,ifp) != NULL ) { continue; } else { break; } } if( strstartcmp(buffer,"rnd_emission") == 0 ) { if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Could not read in rnd emission line"); break; } out->rnd = get_genestat_emission(buffer); if( fgets(buffer,MAXLINE,ifp) != NULL ) { continue; } else { break; } } if( strstartcmp(buffer,"rndcodon") == 0 ) { if( read_codon_GeneStats(out->codon,buffer,ifp) == FALSE ) { warn("Problem in reading codon line!"); } continue; } if( isalpha(buffer[0]) ) { warn("Could not read line %s in genestats reading\n",buffer); } } assert(out); assert(out->splice5); assert(out->splice3); return out; } %func reads in the emission stuff in a genestats line %type internal %% RandomModelDNA * get_genestat_emission(char * buffer) { RandomModelDNA * out; int i; char ** base; char ** brk; double d; out = RandomModelDNA_alloc(); base = brk = breakstring(buffer,spacestr); for(i=0;*brk != NULL && i < 5;i++, brk++){ if( is_double_string(*brk,out->base+i) == FALSE) { warn("For genestat word %s, not a double in emission!",*brk); return FALSE; } } ckfree(base); if( i < 4 ) { warn("Did not read in 5 numbers for emission scores in genestats"); } return out; } %func testing function %% void dump_GeneStats(GeneStats * st,FILE * ofp) { int i; assert(st); assert(ofp); fprintf(ofp,"#\n# Dumping gene stats, wise2.2 style\n#\n"); fprintf(ofp,"splice5\n"); write_selex_SeqAlign(st->splice5,10,70,ofp); fprintf(ofp,"//\nsplice3\n"); write_selex_SeqAlign(st->splice3,10,70,ofp); fprintf(ofp,"//\n"); fprintf(ofp,"intron_emission\n"); for(i=0;i<4;i++) { fprintf(ofp,"%f ",st->intron->base[i]); } fprintf(ofp,"\n"); fprintf(ofp,"//\n"); if( st->polyp != NULL ) { fprintf(ofp,"polyp_emission\n"); for(i=0;i<4;i++) { fprintf(ofp,"%f ",st->polyp->base[i]); } } fprintf(ofp,"\n"); fprintf(ofp,"//\n"); } %func assummes codon_array is 64 positions long line should have begin consensus on it and be of MAXLINE length as it will be used as the buffer. This does **not** check that you have filled up all 64 positions. %% boolean read_codon_GeneStats(double * codon_array,char* line,FILE * ifp) { boolean ret = TRUE; char * codon; char * number; if( strwhitestartcmp(line,"rndcodon",spacestr) != 0 ) { warn("In reading codon line, got no 'rndcoodon' tag [%s]",line); return FALSE; } while( fgets(line,MAXLINE,ifp) != NULL ) { if( line[0] == '#' ) continue; if( strwhitestartcmp(line,"//",spacestr) == 0 ) break; codon = strtok(line,spacestr); number = strtok(NULL,spacestr); if( codon == NULL ) { warn("Found an uncommented line in codon consensus with no leading codon word"); continue; } if( number == NULL ) { warn("For codon %s, no number found",codon); ret = FALSE; continue; } if( strchr(codon,'N') != NULL ) continue; if( is_non_ambiguous_codon_seq(codon) == FALSE ) { warn("Codon %s is not really a codon... problem!"); ret = FALSE; continue; } codon_array[base4_codon_from_seq(codon)]= atof(number); } return ret; } %} wise-2.4.1/src/models/genewisedb.c0000644000175000001440000011522507705225351016417 0ustar philippusers /* has to be before the others due to nasty namespace clashes */ #define WISE2_CROSS_HMMER2 #include "wise2xhmmer2.h" #include "dyna.h" #include "version.h" #include "gwrap.h" char * program_name = "genewisedb"; /* * program specific includes */ #include "gwrap.h" #include "genedisplay.h" #include "matchsum.h" /* * program specific variables */ enum PG_SEARCH_MODE { PG_SEARCH_S2DB, PG_SEARCH_DB2S, PG_SEARCH_DB2DB }; int search_mode; GeneWiseDB * gwdb = NULL; char * dna_seq_file = NULL; GenomicDB * gdb = NULL; SequenceDB * sdb = NULL; Genomic * gen = NULL; boolean use_single_dna = FALSE; int dna_seqdb_start = -1; int dna_seqdb_end = -1; char * protein_file = NULL; Protein * pro = NULL; char * hmm_file = NULL; ThreeStateModel * tsm = NULL; char * hmm_name = NULL; ThreeStateDB * tsmdb = NULL; int pro_seqdb_start = -1; int pro_seqdb_end = -1; GeneWiseScore * gws = NULL; Hscore * hs = NULL; /** different protein possibilities **/ boolean use_single_pro = FALSE; boolean use_db_pro = FALSE; boolean use_tsm = FALSE; boolean use_pfam1 = FALSE; boolean use_pfam2 = FALSE; char * qstart_str = NULL; int qstart = -1; char * qend_str = NULL; int qend = -1; char * gene_file = NULL; GeneFrequency21 * gf = NULL; char * matrix_file = "BLOSUM62.bla"; CompMat * mat = NULL; char * gap_str = "12"; int gap = 12; char * ext_str = "2"; int ext = 2; char * length_of_N_str = "10"; int length_of_N = 10; char * prob_in_rep = "0.001"; double rep_prob = 0.001 ; char * codon_file = NULL; CodonTable * ct = NULL; char * output_file = "-"; FILE * ofp = NULL; char * report_str = NULL; int report_stagger = -1; RandomModelDNA * rmd = NULL; char * subs_string = "0.00001"; double subs_error = 0.00001; char * indel_string = "0.00001"; double indel_error = 0.00001; char * cfreq_string = "flat"; boolean model_codon = FALSE; char * splice_string = "model"; boolean model_splice = TRUE; boolean flat_insert = TRUE; char * startend_string = "default"; int startend = TSM_default; char * allN_string = "0.9"; Probability allN = 0.9; char * null_string = "syn"; boolean use_syn = FALSE; char * intron_string = "tied"; boolean use_tied_model = FALSE; DBSearchImpl * dbsi = NULL; int alg = GWWRAP_623; char * alg_str = NULL; DPRunImpl * dpri = NULL; int aln_alg = GWWRAP_623; char * aln_alg_str = NULL; int aln_number = 50; char * aln_number_str = "50"; double search_cutoff = 20.00; char * search_cutoff_str = "20.00"; double evalue_search_cutoff = -1.0; char * evalue_search_str = NULL; boolean show_histogram = TRUE; boolean show_PackAln = FALSE; boolean show_AlnBlock = FALSE; boolean show_ace = FALSE; boolean show_gff = FALSE; boolean show_trans = FALSE; boolean show_pep = FALSE; boolean show_cdna = FALSE; boolean show_pretty = FALSE; boolean show_pretty_gene = FALSE; boolean show_gene_plain = FALSE; boolean show_match_sum = FALSE; boolean show_para = FALSE; boolean show_overlap = FALSE; boolean pseudo = FALSE; char * main_block_str = "50"; int main_block = 50; char * divide_str = "//"; boolean complete = FALSE; /* complete analysis or not */ boolean complete_trans = FALSE; boolean complete_gene = FALSE; boolean complete_cdna = FALSE; boolean complete_ace = FALSE; boolean show_diana = FALSE; boolean show_acehalf = FALSE; boolean show_embl = FALSE; Probability rnd_loop = 0.99; Probability cds_loop = 0.97; Probability rnd_to_model = (1 - 0.99) / 3; Probability link_loop = 0.98; Probability link_to_model = (1- 0.98) / 3; AlnBlock * alb; PackAln * pal; GenomicRegion * gr; GenomicRegion * embl; MatchSummarySet * mss; RandomModel * rm; GeneParameter21 * gpara; GeneParser21Score * gps; GeneParser4Score * gp4s; RandomCodonScore * rcs; RandomModelDNAScore * ids; boolean show_output(void) { int i,j,k; Genomic * gent; ThreeStateModel * temptsm; AlnBlock * alb; PackAln * pal; GenomicRegion * gr; GenomicRegion * cgr; MatchSummarySet * mss; Protein * ps; Protein * trans; cDNA * cdna; double bits; double aln_cutoff; boolean fitted_res = FALSE; AlnColumn * alt; /* sort by bit score first */ sort_Hscore_by_score(hs); aln_cutoff = search_cutoff; /* for the moment */ if( search_mode == PG_SEARCH_S2DB ) { if( hs->his == NULL || hs->his->total < 1000 ) { info("Cannot fit histogram to a db smaller than 1,000"); fprintf(ofp,"[Warning: Can't fit histogram to a db smaller than 1,000]\n\n"); fitted_res = FALSE; show_histogram = FALSE; } else { fit_Hscore_to_EVD(hs,20); fitted_res = TRUE; } } /* if you think this is scary, you are absolutely right! */ if( alg == GWWRAP_6LITE && aln_alg != GWWRAP_6LITE) { /* memory leak here. Apologies */ gpara->cses->cse[1] = codon_number_ComplexSequenceEval(); } /* dofus catcher */ if( aln_alg != alg ) { fprintf(ofp,"\n#\n#WARNING!\n#\n# Your alignment algorithm is different from your search algorithm.\n# This is probably quite sensible but will lead to differing scores.\n# Use the search score as an indicator of the significance of the match\n# Read the docs for more information\n#\n"); } fprintf(ofp,"\n\n#High Score list\n"); fprintf(ofp,"#Protein ID DNA Str ID Bits Evalue\n"); fprintf(ofp,"--------------------------------------------------------------------------\n"); for(i=0;ilen;i++) { bits = Score2Bits(hs->ds[i]->score); if( bits < search_cutoff ) { break; } if( fitted_res == TRUE && evalue_search_str != NULL ) { if( hs->ds[i]->evalue > evalue_search_cutoff ) break; } if( fitted_res == TRUE) fprintf(ofp,"Protein %-20sDNA [%c] %-24s %.2f %.2g\n",hs->ds[i]->query->name,hs->ds[i]->target->is_reversed == TRUE ? '-' : '+',hs->ds[i]->target->name,bits,hs->ds[i]->evalue); else fprintf(ofp,"Protein %-20sDNA [%c] %-24s %.2f\n",hs->ds[i]->query->name,hs->ds[i]->target->is_reversed == TRUE ? '-' : '+',hs->ds[i]->target->name,bits); /* fprintf(ofp,"Sequence %-24s %c %.2f\n",hs->ds[i]->target->name,hs->ds[i]->target->is_reversed == TRUE ? '-' : '+',bits); */ } if( search_mode == PG_SEARCH_S2DB && show_histogram == TRUE ) { fprintf(ofp,"\n\n#Histogram\n"); fprintf(ofp,"-----------------------------------------------------------------------\n"); PrintASCIIHistogram(hs->his,ofp); } fprintf(ofp,"\n\n#Alignments\n"); fprintf(ofp,"-----------------------------------------------------------------------\n"); if( complete == TRUE ) { cgr = new_GenomicRegion(gen); } for(i=0;ilen;i++) { bits = Score2Bits(hs->ds[i]->score); if( bits < search_cutoff ) { break; } if( i >= aln_number ) { break; } if( fitted_res == TRUE && evalue_search_str != NULL ) { if( hs->ds[i]->evalue > evalue_search_cutoff ) break; } fprintf(ofp,"\n>Results for %s vs %s (%s) [%d]\n",hs->ds[i]->query->name,hs->ds[i]->target->name,hs->ds[i]->target->is_reversed == TRUE ? "reverse" : "forward",i ); gent = get_Genomic_from_GenomicDB(gdb,hs->ds[i]->target); if( gent == NULL ) { warn("Unable to retrieve %s for alignment. Skipping...",hs->ds[i]->target->name); continue; } temptsm = indexed_ThreeStateModel_ThreeStateDB(tsmdb,hs->ds[i]->query); alb = AlnBlock_from_TSM_genewise_wrap(temptsm,gent,gpara,rmd,rmd,use_syn,aln_alg,allN,flat_insert,dpri,&pal,NULL); gr = new_GenomicRegion(gent); add_Genes_to_GenomicRegion_GeneWise(gr,gent->baseseq->offset,gent->baseseq->end,alb,NULL,pseudo,NULL); /* put in their seqname */ for(j=0;jlen;j++) { if( temptsm->accession != NULL ) gr->gene[j]->seqname = stringalloc(temptsm->accession); else gr->gene[j]->seqname = stringalloc(temptsm->name); } if( complete == TRUE ) { /* copy genes over into cgr region */ for(j=0;jlen;j++) { if( gr->gene[j]->bits > aln_cutoff ) add_Gene_to_GenomicRegion(cgr,hard_link_Gene(gr->gene[j])); } } if( use_single_pro == FALSE || pro == NULL) mss = MatchSummarySet_from_AlnBlock_genewise(alb,temptsm->name,1,gent->baseseq); else mss = MatchSummarySet_from_AlnBlock_genewise(alb,pro->baseseq->name,pro->baseseq->offset,gent->baseseq); if( show_pretty == TRUE ) { fprintf(ofp,"\n%s output\nScore %4.2f bits over entire alignment.\nThis will be different from per-alignment scores. See manual for details\nFor computer parsable output, try %s -help or read the manual\n",program_name,Score2Bits(pal->score),program_name); if( alg == GWWRAP_2193L || alg == GWWRAP_2193) { fprintf(ofp,"Entrie alignment score contains unseen 'random' score segments\nYou should only use the per-alignments score printed below\nfor the bits score of the alignment\n\n"); } if( use_syn == FALSE ) { fprintf(ofp,"Scores as bits over a flat simple random model\n\n"); } else { fprintf(ofp,"Scores as bits over a synchronous coding model\n\n"); } ps = pseudo_Protein_from_ThreeStateModel(temptsm); protgene_ascii_display(alb,ps->baseseq->seq,ps->baseseq->name,ps->baseseq->offset,gent,ct,15,main_block,TRUE,ofp); free_Protein(ps); fprintf(ofp,"%s\n",divide_str); } if( show_match_sum == TRUE ) { show_MatchSummary_genewise_header(ofp); show_MatchSummarySet_genewise(mss,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_pretty_gene == TRUE ) { show_pretty_GenomicRegion(gr,0,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_trans == TRUE ) { for(k=0;klen;k++) { if( gr->gene[k]->ispseudo == TRUE ) { fprintf(ofp,"#Gene %d is a pseudo gene - no translation possible\n",k); } else { trans = get_Protein_from_Translation(gr->gene[k]->transcript[0]->translation[0],ct); write_fasta_Sequence(trans->baseseq,ofp); } } fprintf(ofp,"%s\n",divide_str); } if( show_pep == TRUE ) { alt = alb->start; for(;alt != NULL;) { trans = Protein_from_GeneWise_AlnColumn(gent->baseseq,alt,1,&alt,ct,is_random_AlnColumn_genewise); if ( trans == NULL ) break; write_fasta_Sequence(trans->baseseq,ofp); free_Protein(trans); } fprintf(ofp,"%s\n",divide_str); } if( show_cdna == TRUE ) { for(k=0;klen;k++) { cdna = get_cDNA_from_Transcript(gr->gene[k]->transcript[0]); write_fasta_Sequence(cdna->baseseq,ofp); } fprintf(ofp,"%s\n",divide_str); } if( show_ace == TRUE ) { show_ace_GenomicRegion(gr,gent->baseseq->name,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_gff == TRUE ) { show_GFF_GenomicRegion(gr,gent->baseseq->name,"GeneWise",ofp); fprintf(ofp,"%s\n",divide_str); } if( show_gene_plain == TRUE ) { show_GenomicRegion(gr,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_AlnBlock == TRUE ) { mapped_ascii_AlnBlock(alb,Score2Bits,0,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_PackAln == TRUE ) { show_simple_PackAln(pal,ofp); fprintf(ofp,"%s\n",divide_str); } alb = free_AlnBlock(alb); pal = free_PackAln(pal); mss = free_MatchSummarySet(mss); gr = free_GenomicRegion(gr); gent = free_Genomic(gent); temptsm = free_ThreeStateModel(temptsm); } if( complete == TRUE ) { fprintf(ofp,"\n\n#Complete Analysis\n"); fprintf(ofp,"-------------------------------------------------------------\n\n"); sort_GenomicRegion_absolute(cgr); if( complete_ace == TRUE ) { show_ace_GenomicRegion(cgr,cgr->genomic->baseseq->name,ofp); fprintf(ofp,"%s\n",divide_str); } if( complete_gene == TRUE ) { show_pretty_GenomicRegion(cgr,0,ofp); fprintf(ofp,"%s\n",divide_str); } if( complete_cdna == TRUE ) { dump_transcripts_GenomicRegion(cgr,ofp); fprintf(ofp,"%s\n",divide_str); } if( complete_trans == TRUE ) { dump_translations_GenomicRegion(cgr,ct,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_diana == TRUE ) { write_Diana_FT_GenomicRegion(cgr,ofp); } if( show_embl == TRUE ) { write_Embl_FT_GenomicRegion(cgr,ofp); } if( show_acehalf == TRUE ) { show_halfwise_GenomicRegion(cgr,cgr->genomic->baseseq->name,"HALFWISE","PFAM",1,"Pfam-Sanger",ofp); } } return TRUE; } boolean show_header(FILE * ofp) { fprintf(ofp,"Wise2 - database searching mode\n"); fprintf(ofp,"Program: %s version: %s released: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY); fprintf(ofp,"This program is freely distributed under a Gnu Public License.\n"); fprintf(ofp," See -version for more info on copyright\n"); fprintf(ofp,"Bugs and credits to Ewan Birney \n"); fprintf(ofp,"-----------------------------------------------------\n\n"); fprintf(ofp,"Algorithm type: GeneWise\n"); fprintf(ofp,"Search algorithm used: %s\n",alg_str); fprintf(ofp,"Implementation: %s\n",impl_string_DBSearchImpl(dbsi)); fprintf(ofp,"Search mode: %s\n",search_mode == PG_SEARCH_S2DB ? "Single protein vs genomic db" : search_mode == PG_SEARCH_DB2S ? "Single genomic vs protein db" : "Protein db vs genomic db"); fprintf(ofp,"Protein info from: %s\n",protein_file); fprintf(ofp,"Dna info from: %s\n",dna_seq_file); if( use_single_pro == TRUE || use_db_pro == TRUE ) { fprintf(ofp,"Comp Matrix: %s\n",matrix_file); fprintf(ofp,"Gap open: %d\n",gap); fprintf(ofp,"Gap extension: %d\n",ext); } fprintf(ofp,"Start/End (protein) %s\n",startend_string); fprintf(ofp,"Gene Paras: %s\n",gene_file); fprintf(ofp,"Codon Table: %s\n",codon_file); fprintf(ofp,"Subs error: %2.2g\n",subs_error); fprintf(ofp,"Indel error: %2.2g\n",indel_error); fprintf(ofp,"Model splice? %s\n",splice_string); fprintf(ofp,"Model codon bias? %s\n",cfreq_string); fprintf(ofp,"Model intron bias? %s\n",intron_string); fprintf(ofp,"Null model %s\n",null_string); fprintf(ofp,"Alignment Alg %s\n",aln_alg_str); return TRUE; } boolean search_db(void) { info("Starting search..."); hs = Hscore_from_TSM_genewise(tsmdb,gdb,gpara,rmd,rmd,use_syn,alg,search_cutoff,allN,report_stagger,FALSE,flat_insert,dbsi); if( hs == NULL ) { return FALSE; } return TRUE; } boolean build_db_objects(void) { gpara = GeneParameter21_wrap(gf,subs_error,indel_error,rmd,model_codon,model_splice,use_tied_model,ct,rnd_loop,cds_loop,rnd_to_model,link_loop,link_to_model); if( gpara == NULL ) { warn("Sorry - could not build gene parameters. Must be a bug of some sort"); return FALSE; } if( prepare_ComplexSequenceEvalSet(gpara->cses) == FALSE ) { warn("Unable to prepare complexsequenceevalset"); return FALSE; } if( alg == GWWRAP_6LITE ) { /* memory leak here. Apologies */ gpara->cses->cse[1] = codon64_number_ComplexSequenceEval(); } if( use_single_dna == TRUE ) { gdb = new_GenomicDB_from_single_seq(gen,gpara->cses,Probability2Score(rep_prob)); } else { gdb = new_GenomicDB(sdb,gpara->cses,length_of_N,Probability2Score(rep_prob)); } if( gdb == NULL ) { return FALSE; } return TRUE; } boolean build_objects(void) { boolean ret = TRUE; Protein * pro_temp; SequenceDB * psdb; startend = threestatemodel_mode_from_string(startend_string); if( startend == TSM_unknown ) { warn("String %s was unable to converted into a start/end policy\n",startend_string); ret = FALSE; } if( use_single_dna == TRUE ) { gen = read_fasta_file_Genomic(dna_seq_file,length_of_N); if( gen == NULL ) { warn("Could not open single dna sequence in %s",dna_seq_file); ret = FALSE; } } else { sdb = single_fasta_SequenceDB(dna_seq_file); if( sdb == NULL ) { warn("Could not build a sequence database on %s",dna_seq_file); ret = FALSE; } if( dna_seqdb_start != -1 && dna_seqdb_end != -1 ) { sdb->seq_start = dna_seqdb_start; sdb->seq_end = dna_seqdb_end; } } rm = default_RandomModel(); if( (mat = read_Blast_file_CompMat(matrix_file)) == NULL) { if( use_tsm == TRUE ) { info("I could not read the Comparison matrix file in %s; however, you are using a HMM so it is not needed. Please set the WISECONFIGDIR or WISEPERSONALDIR variable correctly to prevent this message.",matrix_file); } else { warn("Could not read Comparison matrix file in %s",matrix_file); ret = FALSE; } } if( is_integer_string(gap_str,&gap) == FALSE ) { warn("Could not get gap string number %s",gap_str); ret = FALSE; } if( is_integer_string(ext_str,&ext) == FALSE ) { warn("Could not get ext string number %s",ext_str); ret = FALSE; } if( qstart_str != NULL ) { if( is_integer_string(qstart_str,&qstart) == FALSE || qstart < 0) { warn("Could not make %s out as query start",qstart); ret = FALSE; } } if( qend_str != NULL ) { if( is_integer_string(qend_str,&qend) == FALSE || qend < 0) { warn("Could not make %s out as query end",qend); ret = FALSE; } } if( aln_number_str != NULL ) { if( is_integer_string(aln_number_str,&aln_number) == FALSE || aln_number < 0) { warn("Weird aln number string %s...\n",aln_number_str); ret = FALSE; } } if( report_str != NULL ) { if( is_integer_string(report_str,&report_stagger) == FALSE ) { warn("Weird report stagger asked for %s",report_str); ret = FALSE; } } if( use_pfam1 == TRUE ) { tsmdb = new_PfamHmmer1DB_ThreeStateDB(protein_file); if( set_search_type_ThreeStateDB(tsmdb,startend_string) == FALSE) { warn("Unable to set global/local switch on threestatedb"); ret = FALSE; } } else if ( use_pfam2 == TRUE ) { tsmdb = HMMer2_ThreeStateDB(protein_file); if( set_search_type_ThreeStateDB(tsmdb,startend_string) == FALSE) { warn("Unable to set global/local switch on threestatedb"); ret = FALSE; } } else if ( use_tsm == TRUE) { /** using a HMM **/ /*tsm = read_HMMer_1_7_ascii_file(hmm_file);*/ /* tsm = Wise2_read_ThreeStateModel_from_hmmer1_file(protein_file);*/ tsm = HMMer2_read_ThreeStateModel(protein_file); if( tsm == NULL ) { warn("Could not read hmm from %s\n",protein_file); ret = FALSE; } else { display_char_in_ThreeStateModel(tsm); if( hmm_name != NULL ) { if( tsm->name != NULL ) ckfree(tsm->name); tsm->name = stringalloc(hmm_name); } else { if( tsm->name == NULL ) { tsm->name = stringalloc(protein_file); } } set_startend_policy_ThreeStateModel(tsm,startend,30,0.2); tsmdb = new_single_ThreeStateDB(tsm,rm); if( tsmdb == NULL ) { warn("Could not build a threestatemodel database from a single tsm. Weird!"); ret = FALSE; } } /* end of else tsm != NULL */ } /* end of else is tsm */ else if( use_single_pro ) { if( startend != TSM_default && startend != TSM_global && startend != TSM_local ) { warn("Proteins can only have local/global startend policies set, not %s",startend_string); ret = FALSE; } if( (pro = read_fasta_file_Protein(protein_file)) == NULL ) { ret = FALSE; warn("Could not read Protein sequence in %s",protein_file); } else { if( qstart != -1 || qend != -1 ) { if( qstart == -1 ) qstart = 0; if( qend == -1 ) qend = pro->baseseq->len; pro_temp = truncate_Protein(pro,qstart-1,qend); if( pro_temp == NULL ){ ret = FALSE; } else { free_Protein(pro); pro = pro_temp; } } if( startend == TSM_global) tsm = global_ThreeStateModel_from_half_bit_Sequence(pro,mat,rm,-gap,-ext); else tsm = ThreeStateModel_from_half_bit_Sequence(pro,mat,rm,-gap,-ext); if( tsm == NULL ) { warn("Could not build ThreeStateModel from a single protein sequence..."); ret = FALSE; } else { tsmdb = new_single_ThreeStateDB(tsm,rm); if( tsmdb == NULL ) { warn("Could not build a threestatemodel database from a single tsm. Weird!"); ret = FALSE; } } /* end of could build a TSM */ } /* else is a real protein */ } /* end of else is single protein */ else if (use_db_pro == TRUE ) { psdb = single_fasta_SequenceDB(protein_file); tsmdb = new_proteindb_ThreeStateDB(psdb,mat,-gap,-ext); if( set_search_type_ThreeStateDB(tsmdb,startend_string) == FALSE) { warn("Unable to set global/local switch on threestatedb"); ret = FALSE; } free_SequenceDB(psdb); } else { warn("No protein input file! Yikes!"); } if( pro_seqdb_start != -1 && pro_seqdb_end != -1 ) { tsmdb->hmm_model_start = pro_seqdb_start; tsmdb->hmm_model_end = pro_seqdb_end; } if( main_block_str != NULL ) { if( is_integer_string(main_block_str,&main_block) == FALSE ) { warn("Could not get maximum main_block number %s",main_block_str); ret = FALSE; } } if( alg_str != NULL ) { alg = gwrap_alg_type_from_string(alg_str); } else { alg_str = "623"; alg = gwrap_alg_type_from_string(alg_str); } if( aln_alg_str != NULL ) { aln_alg = gwrap_alg_type_from_string(aln_alg_str); } else { if( use_single_pro == TRUE || use_db_pro == TRUE) { aln_alg_str = "623"; } else { aln_alg_str = "623L"; } aln_alg = gwrap_alg_type_from_string(aln_alg_str); } if( evalue_search_str != NULL && is_double_string(evalue_search_str,&evalue_search_cutoff) == FALSE ) { warn("Could not convert %s to a double",evalue_search_str); ret = FALSE; } if( is_double_string(search_cutoff_str,&search_cutoff) == FALSE ) { warn("Could not convert %s to a double",search_cutoff_str); ret = FALSE; } if( is_double_string(subs_string,&subs_error) == FALSE ) { warn("Could not convert %s to a double",subs_error); ret = FALSE; } if( is_double_string(indel_string,&indel_error) == FALSE ) { warn("Could not convert %s to a double",indel_error); ret = FALSE; } if( is_double_string(allN_string,&allN) == FALSE ) { warn("Could not convert %s to a double",allN_string); ret = FALSE; } if( strcmp(cfreq_string,"model") == 0 ) { model_codon = TRUE; } else if ( strcmp(cfreq_string,"flat") == 0 ) { model_codon = FALSE; } else { warn("Cannot interpret [%s] as a codon modelling parameter\n",cfreq_string); ret = FALSE; } if( strcmp(splice_string,"model") == 0 ) { model_splice = TRUE; } else if ( strcmp(splice_string,"flat") == 0 ) { model_splice = FALSE; } else { warn("Cannot interpret [%s] as a splice modelling parameter\n",splice_string); ret = FALSE; } if( strcmp(null_string,"syn") == 0 ) { use_syn = TRUE; } else if ( strcmp(null_string,"flat") == 0 ) { use_syn = FALSE; } else { warn("Cannot interpret [%s] as a null model string\n",null_string); ret = FALSE; } if( strcmp(intron_string,"model") == 0 ) { use_tied_model = FALSE; } else if ( strcmp(intron_string,"tied") == 0 ) { use_tied_model = TRUE; } else { warn("Cannot interpret [%s] as a intron tieing switch\n",intron_string); ret = FALSE; } if( (rm = default_RandomModel()) == NULL) { warn("Could not make default random model\n"); ret = FALSE; } if( (gf = read_GeneFrequency21_file(gene_file)) == NULL) { ret = FALSE; warn("Could not read a GeneFrequency file in %s",gene_file); } if( (ct = read_CodonTable_file(codon_file)) == NULL) { ret = FALSE; warn("Could not read codon table file in %s",codon_file); } if( (ofp = openfile(output_file,"W")) == NULL) { warn("Could not open %s as an output file",output_file); ret = FALSE; } rmd = RandomModelDNA_std(); return ret; } void show_short_help(void) { fprintf(stdout,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(stdout,"This program is freely distributed under a GPL. See -version for more info\n"); fprintf(stdout,"Copyright (c) GRL limited: portions of the code are from separate copyrights\n\n"); fprintf(stdout,"swisepg in fasta format\n"); fprintf(stdout," Options. In any order, '-' as filename (for any input) means stdin\nDon't use stdin for databases, as on-the-fly indexing is used\n"); fprintf(stdout," Protein type [-protein,-prodb,-hmmer,-pfam] [default - protein]\n"); fprintf(stdout," Dna type [-dnas,-dnadb] [default - dnadb]\n"); fprintf(stdout," Protein [-s,-t,-g,-e,-m]\n HMM [-hmmer,-hname]\n"); fprintf(stdout," Model [-codon,-gene,-cfreq,-splice,-subs,-indel,-intron,-null]\n Alg [-kbyte,-alg,-aalg,-aln,-noh]\n"); fprintf(stdout," Output [-pretty,-genes,-para,-sum,-cdna,-trans,-ace,]\n"); fprintf(stdout," ..cont [-gff,-gener,-alb,-pal,-block,-divide]\n"); fprintf(stdout," Standard [-help,-version,-silent,-quiet,-errorlog]\n"); fprintf(stdout,"\nFor more help go %s -help.\n",program_name); fprintf(stdout,"\nSee WWW help at http://www.sanger.ac.uk/Software/Wise2/\n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(ofp,"%s \n",program_name); /* program specific help */ fprintf(ofp,"Protein input type\n"); fprintf(ofp," -protein [default] single protein\n"); fprintf(ofp," -prodb protein fasta format db\n"); fprintf(ofp," -pfam pfam hmm library\n"); fprintf(ofp," -pfam2 pfam old style model directory (2.1) \n"); fprintf(ofp," -hmmer single hmmer HMM (version 2 compatible)\n"); fprintf(ofp," -pro_db_start start position in protein/hmm database\n"); fprintf(ofp," -pro_db_end end position in protein/hmm database\n"); fprintf(ofp,"DNA input type\n"); fprintf(ofp," -dnadb [default] dna fasta database\n"); fprintf(ofp," -dnas a single dna fasta sequence\n"); fprintf(ofp," -dna_db_start start position in dna database\n"); fprintf(ofp," -dna_db_end end position in dna database\n"); fprintf(ofp,"Protein comparison options\n"); fprintf(ofp," -gap [%3d] gap penalty\n",gap); fprintf(ofp," -ext [%3d] extension penalty\n",ext); fprintf(ofp," -matrix [%s] Comparison matrix\n",matrix_file); fprintf(ofp,"HMM options\n"); fprintf(ofp," -hname For single hmms, use this as the name, not filename\n"); fprintf(ofp,"Gene Model options\n"); fprintf(ofp," -init [%s] [default/global/local/wing/endbias] start-end policy\n",startend_string); fprintf(ofp," -codon [%s] Codon file\n",codon_file); fprintf(ofp," -gene [%s] Gene parameter file\n",gene_file); fprintf(ofp," -subs [%2.2g] Substitution error rate\n",subs_error); fprintf(ofp," -indel [%2.2g] Insertion/deletion error rate\n",indel_error); fprintf(ofp," -cfreq [model/flat] Using codon bias or not? [default flat]\n"); fprintf(ofp," -splice [model/flat] Using splice model or GT/AG? [default model]\n"); fprintf(ofp," -intron [model/tied] Use tied model for introns [default tied]\n"); fprintf(ofp," -null [syn/flat] Random Model as synchronous or flat [default syn]\n"); fprintf(ofp," -insert [model/flat] Use protein insert model [default flat]\n"); fprintf(ofp,"Algorithm options\n"); fprintf(ofp," -alg [623/2193/] Algorithm used for searching [default 623]\n"); fprintf(ofp," -aalg [623/623L/2193/2193L] Algorithm used for alignment [default 623/623L]\n"); fprintf(ofp," -cut [%.2f] Bits cutoff for reporting in search algorithm\n",search_cutoff); fprintf(ofp," -ecut [n/a] Evalue cutoff for single protein vs DNA searches.\n"); fprintf(ofp," -aln [%d] Max number of alignments (even if above cut)\n",aln_number); fprintf(ofp," -alln [%s] Probability of matching a NNN codon (only for single HMM vs DNAdb)\n",allN_string); fprintf(ofp," -nohis Don't show histogram on single protein/hmm vs DNA search\n"); fprintf(ofp," -report [0] Issue a report every x comparisons (default 0 comparisons)\n"); fprintf(ofp,"Output options [default -pretty -para]\n"); fprintf(ofp," -pretty show pretty ascii output\n"); fprintf(ofp," -genes show gene structure\n"); fprintf(ofp," -para show parameters\n"); fprintf(ofp," -sum show summary output\n"); fprintf(ofp," -cdna show cDNA\n"); fprintf(ofp," -trans show protein translation\n"); fprintf(ofp," -ace ace file gene structure\n"); fprintf(ofp," -gff Gene Feature Format file\n"); fprintf(ofp," -gener raw gene structure\n"); fprintf(ofp," -alb show logical AlnBlock alignment\n"); fprintf(ofp," -pal show raw matrix alignment\n"); fprintf(ofp," -block [%s] Length of main block in pretty output\n",main_block_str); fprintf(ofp," -divide [%s] divide string for multiple outputs\n",divide_str); fprintf(ofp,"Output for complete analysis (only available for single dna seq vs proteindb)\n"); fprintf(ofp," -pseudo Mark genes with frameshifts as pseudogenes\n"); fprintf(ofp," -ctrans provide all translations\n"); fprintf(ofp," -ccdna provide all cdna\n"); fprintf(ofp," -cgene provide all gene structures\n"); fprintf(ofp," -cace provide all gene structures in ace format\n"); fprintf(ofp," -cdiana provide all gene structures in diana EMBL FT format\n"); fprintf(ofp," -cembl provide all gene structures in EMBL FT format\n"); fprintf(ofp," -caceh provide all gene structures in halfwise type ace format\n"); show_help_DBSearchImpl(ofp); show_help_DPRunImpl(ofp); show_standard_options(ofp); fprintf(ofp,"\nSee WWW help at http://www.sanger.ac.uk/Software/Wise2/\n"); exit(63); } void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) GRL 1998 and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney wrote the core code.\n"); fprintf(ofp," Portions of this code was from HMMer2, written by Sean Eddy\n"); exit(63); } void build_defaults(void) { gene_file = "human.gf"; codon_file = "codon.table"; matrix_file = "BLOSUM62.bla"; } int main(int argc,char ** argv) { int i; char * temp; build_defaults(); strip_out_standard_options(&argc,argv,show_help,show_version); if( (temp = strip_out_assigned_argument(&argc,argv,"gap")) != NULL ) gap_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"g")) != NULL ) gap_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"ext")) != NULL ) ext_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"e")) != NULL ) ext_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"matrix")) != NULL ) matrix_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"m")) != NULL ) matrix_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"s")) != NULL ) qstart_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"t")) != NULL ) qend_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"aln")) != NULL ) aln_number_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"codon")) != NULL ) codon_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"gene")) != NULL ) gene_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"alg")) != NULL ) alg_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"aalg")) != NULL ) aln_alg_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"cut")) != NULL ) search_cutoff_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"ecut")) != NULL ) evalue_search_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"subs")) != NULL ) subs_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"indel")) != NULL ) indel_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"alln")) != NULL ) allN_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"cfreq")) != NULL ) cfreq_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"splice")) != NULL ) splice_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"init")) != NULL ) startend_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"null")) != NULL ) null_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"intron")) != NULL ) intron_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"insert")) != NULL ) { if( strcmp(temp,"flat") == 0 ) { flat_insert = TRUE; } else { flat_insert = FALSE; } } if( (temp = strip_out_assigned_argument(&argc,argv,"report")) != NULL ) report_str = temp; pseudo = strip_out_boolean_argument(&argc,argv,"pseudo"); if( (strip_out_boolean_argument(&argc,argv,"dnas")) == TRUE ) use_single_dna = TRUE; if( (strip_out_boolean_argument(&argc,argv,"dnadb")) == TRUE ) use_single_dna = FALSE; strip_out_integer_argument(&argc,argv,"dna_db_start",&dna_seqdb_start); strip_out_integer_argument(&argc,argv,"dna_db_end",&dna_seqdb_end); if( (strip_out_boolean_argument(&argc,argv,"hmmer")) == TRUE ) use_tsm = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pfam2")) == TRUE ) use_pfam1 = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pfam")) == TRUE ) use_pfam2 = TRUE; if( (strip_out_boolean_argument(&argc,argv,"protein")) == TRUE ) use_single_pro = TRUE; if( (strip_out_boolean_argument(&argc,argv,"prodb")) == TRUE ) use_db_pro = TRUE; strip_out_integer_argument(&argc,argv,"pro_db_start",&pro_seqdb_start); strip_out_integer_argument(&argc,argv,"pro_db_end",&pro_seqdb_end); if( (strip_out_boolean_argument(&argc,argv,"intie")) == TRUE ) use_tied_model = TRUE; if( (temp = strip_out_assigned_argument(&argc,argv,"hname")) != NULL ) hmm_name = temp; if( (strip_out_boolean_argument(&argc,argv,"nohis")) != FALSE ) show_histogram = FALSE; if( (strip_out_boolean_argument(&argc,argv,"pretty")) != FALSE ) show_pretty = TRUE; if( (strip_out_boolean_argument(&argc,argv,"gff")) != FALSE ) show_gff = TRUE; if( (strip_out_boolean_argument(&argc,argv,"genes")) != FALSE ) show_pretty_gene = TRUE; if( (strip_out_boolean_argument(&argc,argv,"para")) != FALSE ) show_para = TRUE; if( (strip_out_boolean_argument(&argc,argv,"trans")) != FALSE ) show_trans = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pep")) != FALSE ) show_pep = TRUE; if( (strip_out_boolean_argument(&argc,argv,"cdna")) != FALSE ) show_cdna = TRUE; if( (strip_out_boolean_argument(&argc,argv,"sum")) != FALSE ) show_match_sum = TRUE; if( (strip_out_boolean_argument(&argc,argv,"alb")) != FALSE ) show_AlnBlock = TRUE; if( (strip_out_boolean_argument(&argc,argv,"ace")) != FALSE ) show_ace = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pal")) != FALSE ) show_PackAln = TRUE; if( (strip_out_boolean_argument(&argc,argv,"gener")) != FALSE ) show_gene_plain = TRUE; if( (strip_out_boolean_argument(&argc,argv,"over")) != FALSE ) show_overlap = TRUE; if( (temp = strip_out_assigned_argument(&argc,argv,"divide")) != NULL ) divide_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"block")) != NULL ) main_block_str = temp; complete_trans = strip_out_boolean_argument(&argc,argv,"ctrans") ; complete_gene = strip_out_boolean_argument(&argc,argv,"cgene") ; complete_ace = strip_out_boolean_argument(&argc,argv,"cace") ; complete_cdna = strip_out_boolean_argument(&argc,argv,"ccdna"); if( (strip_out_boolean_argument(&argc,argv,"cdiana")) != FALSE ) show_diana = TRUE; if( (strip_out_boolean_argument(&argc,argv,"cembl")) != FALSE ) show_embl = TRUE; if( (strip_out_boolean_argument(&argc,argv,"caceh")) != FALSE ) show_acehalf = TRUE; dbsi = new_DBSearchImpl_from_argv(&argc,argv); dpri = new_DPRunImpl_from_argv(&argc,argv); assert(dpri); assert(dbsi); strip_out_remaining_options_with_warning(&argc,argv); if( argc != 3 ) { warn("Wrong number of arguments (expect 2)!\n"); if( argc > 1 ){ warn("Arg line looked like (after option processing)"); for(i=1;iamino acid mappings comp r comparison matrix to use gap gap penalty ext extension penalty is_global if true, global start-end in protein is used rmd random model of dna to use alg est algorithm type to use rm random protein model for use with compmat use_syn if true, uses a synchronous coding model palpoi wN the raw packed alignment output if wanted %% AlnBlock * AlnBlock_from_Protein_estwise_wrap(Protein * pro,cDNA * cdna,cDNAParser * cp,CodonMapper * cm,CodonTable * ct,CompMat * comp,int gap,int ext,boolean is_global,RandomModelDNA * rmd,int alg,RandomModel * rm,boolean use_syn,Probability allN,DPRunImpl * dpri,PackAln ** palpoi) { ThreeStateModel * tsm; AlnBlock * out; if( pro == NULL || cdna == NULL || comp == NULL || rm == NULL || dpri == NULL){ warn("trappable error in PackAln from protein sequence vs cDNA, passed some NULL objects, Complain!"); return NULL; } rm = default_RandomModel(); if( is_global == TRUE) tsm = global_ThreeStateModel_from_half_bit_Sequence(pro,comp,rm,gap,ext); else tsm = ThreeStateModel_from_half_bit_Sequence(pro,comp,rm,gap,ext); out = AlnBlock_from_TSM_estwise_wrap(tsm,cdna,cp,cm,ct,rmd,alg,use_syn,FALSE,allN,dpri,palpoi); free_ThreeStateModel(tsm); free_RandomModel(rm); return out; } %func This function is the basic wrap for Protein models vs cDNA sequences. %arg tsm r threestatemodel to be compared to the dna cdna r cdna to be compared to cp r cdna parser indicating insertion deletion probabilities cm r codon mapper indicating substitution errors etc ct r codon table for the codon->amino acid mappings rmd random model of dna to use alg est algorithm type to use use_syn if true, uses a synchronous coding model palpoi wN the raw packed alignment output if wanted %% AlnBlock * AlnBlock_from_TSM_estwise_wrap(ThreeStateModel * tsm,cDNA * cdna,cDNAParser * cp,CodonMapper * cm,CodonTable * ct,RandomModelDNA * rmd,int alg,boolean use_syn,boolean force_flat_insert,Probability allN,DPRunImpl * dpri,PackAln ** palpoi) { AlnBlock * out; PackAln * pal; cDNAParserScore * cps = NULL ; GeneWise * gw = NULL ; GeneWiseScore * gws = NULL ; ComplexSequence * cs = NULL ; ComplexSequenceEvalSet * cses = NULL ; if( tsm == NULL || cdna == NULL || cp == NULL || rmd == NULL || dpri == NULL){ warn("trappable error in AlnBlock estwise wrap, passed some NULL objects, Complain!"); return NULL; } if( (gw=GeneWise_from_ThreeStateModel_cdna(tsm,cp,cm,allN)) == NULL) { warn("Unable to make GeneWise model in estwise wrap"); goto exit; } if( use_syn == TRUE ) { if( tsm->rm == NULL ) { warn("A three state model with no random model! Ugh!"); goto exit; } GeneWise_fold_in_synchronised_RandomModel(gw,tsm->rm,cm,ct,0.5); if( force_flat_insert == TRUE ) { check_flat_insert(gw,TRUE,FALSE,ct); } } else { GeneWise_fold_in_RandomModelDNA(gw,rmd); } if( (gws = GeneWiseScore_from_GeneWise(gw)) == NULL) { warn("Unable to make GeneWiseScore model in estwise wrap"); goto exit; } if( (cps = cDNAParserScore_from_cDNAParser(cp)) == NULL ) { warn("Unable to make cDNAParserScore in estwise wrap"); goto exit; } cses = default_cDNA_ComplexSequenceEvalSet(); cs = new_ComplexSequence(cdna->baseseq,cses); cses = free_ComplexSequenceEvalSet(cses); switch(alg) { case ESTWISE_3 : pal = PackAln_bestmemory_EstWise3(gws,cs,cps,NULL,dpri); out = convert_PackAln_to_AlnBlock_EstWise3(pal); break; case ESTLOOP_3 : pal = PackAln_bestmemory_EstLoop3(gws,cs,cps,NULL,dpri); out = convert_PackAln_to_AlnBlock_EstLoop3(pal); break; case ESTSLIM_3 : pal = PackAln_bestmemory_EstSlim3(gws,cs,cps,NULL,dpri); out = convert_PackAln_to_AlnBlock_EstLoop3(pal); break; case ESTSLIM_L : pal = PackAln_bestmemory_EstSlimLoop3(gws,cs,cps,NULL,dpri); out = convert_PackAln_to_AlnBlock_EstSlimLoop3(pal); break; case ESTFRAG_3 : pal = PackAln_bestmemory_EstFrag3(gws,cs,cps,0,0,NULL,dpri); out = convert_PackAln_to_AlnBlock_EstFrag3(pal); break; default : warn("No algorithm type specified. Not good news!"); goto exit; } if( palpoi != NULL) { *palpoi = pal; } else { free_PackAln(pal); } goto exit; exit : if( cps != NULL ) free_cDNAParserScore(cps); if( gw != NULL ) free_GeneWise(gw); if( gws != NULL) free_GeneWiseScore(gws); if( cs != NULL) free_ComplexSequence(cs); if( cses != NULL) free_ComplexSequenceEvalSet(cses); return out; } %func Runs a database search for the estwise set of algorithms %arg tdb r a three state model database cdb r a dna sequence database cp r the codon parser for this comparison cm r the codon mapper for this comparison rmd r random model used for the dna sequence comparison use_syn whether a synchronous coding model should be used or not alg algorithm to use die_on_error if true, dies if there is an error return o a newly allocated Hscore structure of the search %% Hscore * Hscore_from_TSM_estwise(ThreeStateDB * tdb,cDNADB * cdb,cDNAParser * cp,CodonMapper * cm,RandomModelDNA * rmd,boolean use_syn,int alg,double bits_cutoff,Probability allN,boolean flat_insert,int report_level,boolean die_on_error,DBSearchImpl * dbsi) { Hscore * out = NULL; GeneWiseDB * gwdb; cDNAParserScore * cps = NULL ; GeneWiseQuickDB * gwq; Search_Return_Type ret; ret = SEARCH_ERROR; if( alg == ESTQUICK_3 && tdb->type != TSMDB_SINGLE ) { warn("Can only currently use estquick in a single mode search"); return NULL; } gwdb = new_GeneWiseDB_cdna(tdb,cp,cm,rmd,use_syn,allN,flat_insert); if( gwdb == NULL ) { warn("Could not build a new GeneWiseDB from the objects provided. Exiting without completing the search"); goto exit; } if( (cps = cDNAParserScore_from_cDNAParser(cp)) == NULL ) { warn("Unable to make cDNAParserScore in estwise wrap"); goto exit; } /*** allocate Hscore structure ***/ out = std_bits_Hscore(bits_cutoff,report_level); switch(alg) { case ESTWISE_3 : ret = search_EstWise3(dbsi,out,gwdb,cdb,cps); break; case ESTSLIM_3 : ret = search_EstSlim3(dbsi,out,gwdb,cdb,cps); break; case ESTQUICK_3 : gwq = GeneWiseQuickDB_from_GeneWiseDB(gwdb); ret = search_EstQuick3(dbsi,out,gwq,cdb,cps); free_GeneWiseQuickDB(gwq); break; default : warn("A major problem. No valid algorithm type passed in"); goto exit; } goto exit; exit : if( gwdb != NULL ) { free_GeneWiseDB(gwdb); } if( cps != NULL ) free_cDNAParserScore(cps); return out; } %func writes an mul format protein multiple alignment from an AlnBlock with the first sequence an HMM/protein and ignored, and the second and subsequent sequences cdna sequences which are then translated into proteins This relies considerably on the alb being made correctly, and if it is not, then god help you. the estwisedb programs makes the alb correctly %% void write_mul_estwise_AlnBlock(AlnBlock * alb,CodonTable * ct,FILE * ofp) { char namebuffer[128]; AlnSequence * als; AlnUnit *ale; AlnColumn * alc; Sequence * seq; int i; assert(alb); assert(ct); for(i=1;ilen;i++) { als = alb->seq[i]; if( als->data == NULL ) { warn("For sequence %d in the estwise alnblock, no attached sequence, and so cannot write. Skipping",i); continue; } seq = (Sequence *) als->data; /* scared? I am! */ for(alc = alb->start,ale=NULL;alc->next != NULL;alc = alc->next) if( strstr(alc->alu[i]->text_label,"CODON") != NULL ) { ale = alc->alu[i]; } if( ale == NULL ) { warn("Unable to find even a codon matching this. Exiting for sequence %s in mul output",seq->name); continue; } /* fprintf(stdout,"Ale is %d-%d %s\n",ale->start,ale->end,ale->text_label);*/ if( is_reversed_Sequence(seq) ) sprintf(namebuffer,"%s/%d-%d",seq->name,ale->end,als->start->start+1); else sprintf(namebuffer,"%s/%d-%d",seq->name,als->start->start+2,ale->end+1); fprintf(ofp,"%-30s ",namebuffer); for(alc = alb->start;alc != NULL;alc = alc->next ) { if( strstr(alc->alu[i]->text_label,"CODON") != NULL ) { fputc(aminoacid_from_seq(ct,seq->seq+alc->alu[i]->start+1),ofp); } else if( strstr(alc->alu[i]->text_label,"INSERT") != NULL ) { fputc('-',ofp); } else { fputc('X',ofp); } } fputc('\n',ofp); } } %} wise-2.4.1/src/models/estwrap.xs0000644000175000001440000000336010670453713016174 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2 Wise2_Hscore * Hscore_from_TSM_estwise(tdb,cdb,cp,cm,rmd,use_syn,alg,bits_cutoff,allN,flat_insert,report_level,die_on_error,dbsi) Wise2_ThreeStateDB * tdb Wise2_cDNADB * cdb Wise2_cDNAParser * cp Wise2_CodonMapper * cm Wise2_RandomModelDNA * rmd boolean use_syn int alg double bits_cutoff Probability allN boolean flat_insert int report_level boolean die_on_error Wise2_DBSearchImpl * dbsi CODE: RETVAL = Wise2_Hscore_from_TSM_estwise(tdb,cdb,cp,cm,rmd,use_syn,alg,bits_cutoff,allN,flat_insert,report_level,die_on_error,dbsi); OUTPUT: RETVAL Wise2_AlnBlock * AlnBlock_from_Protein_estwise_wrap(pro,cdna,cp,cm,ct,comp,gap,ext,is_global,rmd,alg,rm,use_syn,allN,dpri) Wise2_Protein * pro Wise2_cDNA * cdna Wise2_cDNAParser * cp Wise2_CodonMapper * cm Wise2_CodonTable * ct Wise2_CompMat * comp int gap int ext boolean is_global Wise2_RandomModelDNA * rmd int alg Wise2_RandomModel * rm boolean use_syn Probability allN Wise2_DPRunImpl * dpri CODE: RETVAL = Wise2_AlnBlock_from_Protein_estwise_wrap(pro,cdna,cp,cm,ct,comp,gap,ext,is_global,rmd,alg,rm,use_syn,allN,dpri,NULL); OUTPUT: RETVAL Wise2_AlnBlock * AlnBlock_from_TSM_estwise_wrap(tsm,cdna,cp,cm,ct,rmd,alg,use_syn,force_flat_insert,allN,dpri) Wise2_ThreeStateModel * tsm Wise2_cDNA * cdna Wise2_cDNAParser * cp Wise2_CodonMapper * cm Wise2_CodonTable * ct Wise2_RandomModelDNA * rmd int alg boolean use_syn boolean force_flat_insert Probability allN Wise2_DPRunImpl * dpri CODE: RETVAL = Wise2_AlnBlock_from_TSM_estwise_wrap(tsm,cdna,cp,cm,ct,rmd,alg,use_syn,force_flat_insert,allN,dpri,NULL); OUTPUT: RETVAL int alg_estwrap_from_string(str) char * str CODE: RETVAL = Wise2_alg_estwrap_from_string(str); OUTPUT: RETVAL wise-2.4.1/src/models/genefrequency.c0000644000175000001440000013246010670453714017144 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genefrequency.h" /* Function: RandomCodon_from_cds_triplet(gf) * * Descrip: makes a randomcodon probability emission * from the counts in genefrequency * * * Arg: gf [UNKN ] Undocumented argument [GeneFrequency21 *] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ # line 83 "genefrequency.dy" RandomCodon * RandomCodon_from_cds_triplet(GeneFrequency21 * gf) { int i; int a,b,c; double total; double lit; RandomCodon * out; out = RandomCodon_alloc(); for(i=0,total=0;i<64;i++) total += gf->cds_triplet[i]; for(i=0;i<125;i++) { if( has_random_bases(i) ) { lit = 0.0; for(a=0;a<4;a++) for(b=0;b<4;b++) for(c=0;c<4;c++) lit += gf->cds_triplet[base4_codon_from_codon(permute_possible_random_bases(i,a,b,c))]; out->codon[i] = lit/(64*total); } else { out->codon[i] = gf->cds_triplet[base4_codon_from_codon(i)]/(total); } } return out; } /* Function: RandomModelDNA_from_central_GeneFrequency21(gf) * * Descrip: Makes a random model from the central gene * model of an intron. Ideal for tieing intron * state distribution to the randommodel * * * Arg: gf [UNKN ] Undocumented argument [GeneFrequency21 *] * * Return [UNKN ] Undocumented return value [RandomModelDNA *] * */ # line 119 "genefrequency.dy" RandomModelDNA * RandomModelDNA_from_central_GeneFrequency21(GeneFrequency21 * gf) { RandomModelDNA * out; double total; total = sum_Probability_array(gf->central,4); out = RandomModelDNA_alloc(); out->base[BASE_A] = gf->central[BASE_A]/total; out->base[BASE_T] = gf->central[BASE_T]/total; out->base[BASE_G] = gf->central[BASE_G]/total; out->base[BASE_C] = gf->central[BASE_C]/total; out->base[BASE_N] = 1.0; return out; } /* Function: ComplexConsensi_5SS_from_GeneFrequency(gf) * * Descrip: makes 5'SS ComplexConsensi from GeneFrequency21 structure using * * CCC|XXXXXXX score = no(5'SS with CCC|XXXXXXX) / no(CCC in cds). * * * Arg: gf [UNKN ] Undocumented argument [GeneFrequency21 *] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ # line 143 "genefrequency.dy" ComplexConsensi * ComplexConsensi_5SS_from_GeneFrequency(GeneFrequency21 * gf) { register int i; double nocds; ComplexConsensi * out; out = ComplexConsensi_alloc_len(gf->ss5->len); for(i=0;iss5->len;i++) { nocds = nocds_from_ambiguous_codon(gf->ss5->gsc[i]->string,gf->cds_triplet); if( nocds < 20 ) { warn("In making 5'SS consensi, got %g cds for codon %s ... not happy about this",nocds,gf->ss5->gsc[i]->string); } add_ComplexConsensi(out,ComplexConsensusWord_from_string_and_prob(gf->ss5->gsc[i]->string,gf->ss5->gsc[i]->number / nocds)); } return out; } /* Function: ComplexConsensi_3SS_from_GeneFrequency(gf) * * Descrip: makes 3'SS ComplexConsensi from GeneFrequency21 structure using * * ZZZ|CCC score = no(3'SS with ZZZ|CCC) / no(CCC in cds). * * * Arg: gf [UNKN ] Undocumented argument [GeneFrequency21 *] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ # line 170 "genefrequency.dy" ComplexConsensi * ComplexConsensi_3SS_from_GeneFrequency(GeneFrequency21 * gf) { register int i; double nocds; ComplexConsensi * out; out = ComplexConsensi_alloc_len(gf->ss3->len); for(i=0;iss3->len;i++) { nocds = nocds_from_ambiguous_codon(gf->ss3->gsc[i]->string+3,gf->cds_triplet); if( nocds < 20 ) { warn("In making 3'SS consensi, got %g cds for codon %s ... not happy about this!",nocds,gf->ss3->gsc[i]->string); } add_ComplexConsensi(out,ComplexConsensusWord_from_string_and_prob(gf->ss3->gsc[i]->string,gf->ss3->gsc[i]->number / nocds)); } return out; } /* Function: nocds_from_ambiguous_codon(codon,codon_freq_array) * * Descrip: helper function for above guys * * * Arg: codon [UNKN ] Undocumented argument [char *] * Arg: codon_freq_array [UNKN ] Undocumented argument [double *] * * Return [UNKN ] Undocumented return value [double] * */ # line 194 "genefrequency.dy" double nocds_from_ambiguous_codon(char * codon,double * codon_freq_array) { int factor = 1; int one; int two; int three; int i,j,k; double ret = 0.0; one = base_from_char(*codon == '-' ? 'N' : *codon); two = base_from_char(*(codon+1) == '-' ? 'N' : *(codon+1)); three = base_from_char(*(codon+2) == '-' ? 'N' : *(codon+2)); if(one == BASE_N) factor *= 4; if(two == BASE_N) factor *= 4; if(three == BASE_N) factor *= 4; for(i=0;i<4;i++) for(j=0;j<4;j++) for(k=0;k<4;k++) if( (one == i || one == BASE_N) && (two == j || two == BASE_N) && (three == k || three == BASE_N)) { ret += codon_freq_array[i*16+j*4+k]; } ret = ret / factor; if( ret < 0.0000000000000001 ) { warn("For codon %c%c%c we have a frequency of %g",*codon,*(codon+1),*(codon+2),ret); ret = 0.0000000000000001; } return ret; } /* Function: ComplexConsensusWord_from_string_and_prob(string,p) * * Descrip: convienent constructor * * * Arg: string [UNKN ] Undocumented argument [char *] * Arg: p [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [ComplexConsensusWord *] * */ # line 238 "genefrequency.dy" ComplexConsensusWord * ComplexConsensusWord_from_string_and_prob(char * string,Probability p) { ComplexConsensusWord * out; out = ComplexConsensusWord_alloc(); out->pattern = stringalloc(string); out->p = p; out->score = Probability2Score(p); return out; } /* Function: CodonFrequency_from_GeneFrequency21(gf,ct) * * Descrip: Builds a codon frequency table from raw counts * in the counts file * * * Arg: gf [UNKN ] Undocumented argument [GeneFrequency21 *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [CodonFrequency *] * */ # line 256 "genefrequency.dy" CodonFrequency * CodonFrequency_from_GeneFrequency21(GeneFrequency21 * gf,CodonTable * ct) { return CodonFrequence_from_raw_counts(gf->codon,ct); } /* Function: show_flat_GeneFrequency21(gf21,ofp) * * Descrip: For debugging * * * Arg: gf21 [UNKN ] Undocumented argument [GeneFrequency21 *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 266 "genefrequency.dy" void show_flat_GeneFrequency21(GeneFrequency21 * gf21,FILE * ofp) { if( gf21->ss5 != NULL ) { fprintf(ofp,"5'SS\n"); show_GeneConsensus(gf21->ss5,ofp); } if( gf21->ss3 != NULL ) { fprintf(ofp,"3'SS\n"); show_GeneConsensus(gf21->ss3,ofp); } fprintf(ofp,"Codon frequency\n"); show_codon_emission(gf21->codon,ofp); fprintf(ofp,"Central emission\n"); show_base_emission(gf21->central,ofp); fprintf(ofp,"Pyrimidine emission\n"); show_base_emission(gf21->py,ofp); fprintf(ofp,"Spacer emission\n"); show_base_emission(gf21->spacer,ofp); fprintf(ofp,"Transitions\n"); show_Probability_array(gf21->transition,GENEFREQUENCY21_TRANSITION_LEN,ofp); fprintf(ofp,"\n\n"); } /* Function: show_codon_emission(codon,ofp) * * Descrip: For debugging * * * Arg: codon [UNKN ] Undocumented argument [double *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 299 "genefrequency.dy" void show_codon_emission(double * codon,FILE * ofp) { register int i; fprintf(ofp,"begin consensus\n"); for(i=0;i<64;i++) show_single_codon_emission(codon[i],i,ofp); fprintf(ofp,"end consensus\n"); } /* Function: show_single_codon_emission(no,base4codon,ofp) * * Descrip: For debugging * * * Arg: no [UNKN ] Undocumented argument [double] * Arg: base4codon [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 315 "genefrequency.dy" void show_single_codon_emission(double no,int base4codon,FILE * ofp) { codon c; base one; base two; base three; c = codon_from_base4_codon(base4codon); all_bases_from_codon(c,&one,&two,&three); fprintf(ofp,"%c%c%c %.2f\n",char_from_base(one),char_from_base(two),char_from_base(three),no); } /* Function: show_base_emission(base,ofp) * * Descrip: For debugging * * * Arg: base [UNKN ] Undocumented argument [double *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 333 "genefrequency.dy" void show_base_emission(double * base,FILE * ofp) { register int i; fprintf(ofp,"begin consensus\n"); for(i=0;i<4;i++) fprintf(ofp,"%c %.2f\n",char_from_base(i),base[i]); fprintf(ofp,"end consensus\n"); } /* Function: show_GeneConsensus(gc,ofp) * * Descrip: For debugging * * * Arg: gc [UNKN ] Undocumented argument [GeneConsensus *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 350 "genefrequency.dy" void show_GeneConsensus(GeneConsensus * gc,FILE * ofp) { register int i; fprintf(ofp,"begin consensus\n"); for(i=0;ilen;i++) show_GeneSingleCons(gc->gsc[i],ofp); fprintf(ofp,"end consensus\n"); } /* Function: show_GeneSingleCons(gsc,ofp) * * Descrip: For debugging * * * Arg: gsc [UNKN ] Undocumented argument [GeneSingleCons *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 367 "genefrequency.dy" void show_GeneSingleCons(GeneSingleCons * gsc,FILE * ofp) { fprintf(ofp,"%s %f\n",gsc->string,gsc->number); } /*** reading in ***/ /* Function: read_GeneFrequency21_file(filename) * * Descrip: Opens the file with /openfile * * Reads in a GeneFrequency (Mor-Ewan style) * * * * Arg: filename [UNKN ] will open from WISECONFIGDIR etc via openfile [char *] * * Return [UNKN ] a newly allocated structure [GeneFrequency21 *] * */ # line 386 "genefrequency.dy" GeneFrequency21 * read_GeneFrequency21_file(char * filename) { GeneFrequency21 * out; FILE * ifp; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s as a genefrequency file",filename); return NULL; } out = read_GeneFrequency21(ifp); fclose(ifp); return out; } /* Function: read_GeneFrequency21(ifp) * * Descrip: Reads in a GeneFrequency (Mor-Ewan style) * file from ifp * * * Arg: ifp [UNKN ] file pointer [FILE *] * * Return [UNKN ] a newly allocated structure [GeneFrequency21 *] * */ # line 412 "genefrequency.dy" GeneFrequency21 * read_GeneFrequency21(FILE * ifp) { GeneFrequency21 * out; GeneConsensus * temp; char buffer[MAXLINE]; int phase; int center; int type; boolean err = FALSE; out = GeneFrequency21_alloc(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '#' ) continue; if( strwhitestartcmp(buffer,"type",spacestr) == 0 ) { phase = 3; /** if no phase, assumme it is for all phases **/ type = check_type_GeneFrequency(buffer,ifp,¢er,&phase); switch(type) { case GeneConsensusType_5SS : if( phase == 3) { temp = read_line_GeneConsensus(buffer,ifp); temp->center = center; out->ss5 = temp; } else { if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd 5'SS information ... problem!"); break; } } break; case GeneConsensusType_3SS : if( phase == 3) { temp = read_line_GeneConsensus(buffer,ifp); temp->center = center; out->ss3 = temp; } else { if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd 5'SS information ... problem!"); err = TRUE; } } break; case GeneConsensusType_CDS : if( phase == 0) { if( read_codon_GeneConsensus(out->codon,buffer,ifp) == FALSE ) { warn("Unable to read codon information in GeneFrequency21... problem!"); break; } } else if( phase == 3 ) { /*** we need this! ***/ if( read_codon_GeneConsensus(out->cds_triplet,buffer,ifp) == FALSE ) { warn("Unable to read codon information in GeneFrequency21... problem!"); break; } } else { /** in a different phase **/ if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd CDS information ... problem!"); err = TRUE; } } break; case GeneConsensusType_Intron_emission : if( phase == 3 ) { if( read_base_GeneConsensus(out->central,buffer,ifp) == FALSE ) { warn("Unable to read Intron emissions in genefrequency21 ... problem!"); err = TRUE; } } else { if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd CDS information ... problem!"); err = TRUE; } } break; case GeneConsensusType_Pyrimidine_emission : if( phase == 3 ) { if( read_base_GeneConsensus(out->py,buffer,ifp) == FALSE ) { warn("Unable to read pyrimidine emissions in genefrequency21 ... problem!"); err = TRUE; } } else { if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd pyrimidine information ... problem!"); err = TRUE; } } break; case GeneConsensusType_Spacer_emission : if( phase == 3 ) { if( read_base_GeneConsensus(out->spacer,buffer,ifp) == FALSE ) { warn("Unable to read spacer emissions in genefrequency21 ... problem!"); err = TRUE; } } else { if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd spacer information ... problem!"); err = TRUE; } } break; case GeneConsensusType_Central_stay : out->transition[GF21_CENTRAL_STAY] = double_from_line(buffer); break; case GeneConsensusType_Pyrimidine_stay : out->transition[GF21_PY_STAY] = double_from_line(buffer); break; case GeneConsensusType_Spacer_stay : out->transition[GF21_SPACER_STAY] = double_from_line(buffer); break; case GeneConsensusType_No_spacer : out->transition[GF21_NO_SPACER] = double_from_line(buffer); break; case GeneConsensusType_Intron_Corr_Term : switch(phase) { case 0 : /* out->transition[GF21_INTRON_CORR_TERM_0] = double_from_line(buffer); */ break; case 1 : /* out->transition[GF21_INTRON_CORR_TERM_1] = double_from_line(buffer); */ break; case 2 : /* out->transition[GF21_INTRON_CORR_TERM_2] = double_from_line(buffer); */ break; case 3 : out->transition[GF21_INTRON_CORR_TERM] = double_from_line(buffer); break; default : warn("Well... I have got some bad news for you. We found a phase of %d in Intron correction term. ",phase); break; } break; default : warn("Got an unidenitifable type in GeneFrequency21 parse. Skippping"); if( skip_consensus(ifp) == FALSE ) { warn("Unable to skip phase'd 5'SS information ... problem!"); err = TRUE; } } if( err == TRUE ) { warn("You have had an unrecoverable error in GeneFrequency21 parsing"); break; } } else { striptoprint(buffer); warn("Could not understand line [%s] in GeneFrequency21 parse",buffer); } } return out; } /* Function: double_from_line(buffer) * * Descrip: helper string function * * * Arg: buffer [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [double] * */ # line 584 "genefrequency.dy" double double_from_line(char * buffer) { char * runner; char * end; double ret; runner = strtok(buffer,spacestr); if( runner == NULL ) { warn("Unable to read a number in double_from_line"); return -1.0; } ret = strtod(runner,&end); if( end == runner || isalnum((int)*end) ) { warn("Bad conversion of string [%s] to double [%f] occured",runner,ret); } return ret; } /* Function: skip_consensus(ifp) * * Descrip: helper function for * teh file parsing * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 611 "genefrequency.dy" boolean skip_consensus(FILE * ifp) { char buffer[MAXLINE]; while(fgets(buffer,MAXLINE,ifp) != NULL ) if( strwhitestartcmp(buffer,"end",spacestr) == 0) break; if( feof(ifp) || ferror(ifp) ) return FALSE; return TRUE; } /* Function: check_type_GeneFrequency(*line,ifp,center,phase) * * Descrip: Pretty sneaky function * * give * * line starting with "type xxx" * ifp file pointer * centre a &int for returning the centre value of the consensus if any. * phase a &int for returning the phase value of the consensus if any. * * you get *back* the line with the line "begin consensus" or "number" in it. * * * It returns a GeneConsensusType * * with GeneConsensusType_Error on error * * * * Arg: *line [UNKN ] Undocumented argument [char] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * Arg: center [UNKN ] Undocumented argument [int *] * Arg: phase [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ # line 644 "genefrequency.dy" int check_type_GeneFrequency(char *line,FILE * ifp,int * center,int * phase) { int ret = GeneConsensusType_Error; char * runner; if( strwhitestartcmp(line,"type",spacestr) != 0 ) { warn("Attempting to check phase of consensus with no type line..."); return GeneConsensusType_Error; } runner = strtok(line,spacestr); runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("GeneFrequency type with no type. Can't read type, must set to error, but problem in later parsing"); ret = GeneConsensusType_Error; } else { ret = string_to_GeneConsensusType(runner); } while( fgets(line,MAXLINE,ifp) != NULL ) { if( line[0] == '#' ) continue; else if( strwhitestartcmp(line,"phase",spacestr) == 0 ) { runner = strtok(line,spacestr); runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("Got phase line with no phase. Sad...."); continue; } if( phase != NULL ) { if( strcmp(runner,"all") ==0 || strcmp(runner,"All") == 0) *phase = 3; else *phase = atoi(runner); } } else if( strwhitestartcmp(line,"center",spacestr) == 0 || strwhitestartcmp(line,"centre",spacestr) == 0) { runner = strtok(line,spacestr); runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("Got center line with no phase. Sad...."); continue; } if( center != NULL ) { *center = atoi(runner); } } else { break; } } return ret; } /* Function: string_to_GeneConsensusType(string) * * Descrip: flips string 5SS to enum type * * * Arg: string [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 715 "genefrequency.dy" int string_to_GeneConsensusType(char * string) { if( strcmp(string,"5SS") == 0 ) return GeneConsensusType_5SS; else if( strcmp(string,"3SS") == 0 ) return GeneConsensusType_3SS; else if( strcmp(string,"CDS") == 0 ) return GeneConsensusType_CDS; else if( strcmp(string,"Intron_Corr_Term") == 0 ) return GeneConsensusType_Intron_Corr_Term; else if( strcmp(string,"Intron_emission") == 0 ) return GeneConsensusType_Intron_emission; else if( strcmp(string,"Pyrimidine_emission") == 0 ) return GeneConsensusType_Pyrimidine_emission; else if( strcmp(string,"Spacer_emission") == 0 ) return GeneConsensusType_Spacer_emission; else if( strcmp(string,"Central_Intron_Stay_Prob") == 0 ) return GeneConsensusType_Central_stay; else if( strcmp(string,"Pyrimidine_Stay_Prob") == 0 ) return GeneConsensusType_Pyrimidine_stay; else if( strcmp(string,"Spacer_Stay_Prob") == 0 ) return GeneConsensusType_Spacer_stay; else if( strcmp(string,"No_Spacer_Prob") == 0 ) return GeneConsensusType_No_spacer; else { warn("Could convert string [%s] into a gene frequency type",string); return GeneConsensusType_Error; } } /* Function: read_base_GeneConsensus(base_array,line,ifp) * * Descrip: assummes base_array is 4 positions long * * line should have begin consensus on it and be of MAXLINE length as it will be used as the buffer. * * This does **not** check that you have filled up all 4 positions. * * * Arg: base_array [UNKN ] Undocumented argument [double *] * Arg: line [UNKN ] Undocumented argument [char*] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 754 "genefrequency.dy" boolean read_base_GeneConsensus(double * base_array,char* line,FILE * ifp) { boolean ret = TRUE; int b; char * base; char * number; if( strwhitestartcmp(line,"begin",spacestr) != 0 || strstr(line,"consensus") == NULL ) { warn("In reading base GeneConsensus line, got no 'begin consensus' tag [%s]",line); return FALSE; } while( fgets(line,MAXLINE,ifp) != NULL ) { if( line[0] == '#' ) continue; if( strwhitestartcmp(line,"end",spacestr) == 0 ) break; base = strtok(line,spacestr); number = strtok(NULL,spacestr); if( base == NULL ) { warn("Found an uncommented line in base consensus with no leading base word"); continue; } if( number == NULL ) { warn("For base %s, no number found",base); ret = FALSE; continue; } if( strlen(base) > 1 || (b=base_from_char(*base)) == BASE_N ) { warn("Could not interpret %s as an actual DNA base in read_base_GeneConsensus"); ret = FALSE; continue; } base_array[b]= atof(number); } return ret; } /* Function: read_codon_GeneConsensus(codon_array,line,ifp) * * Descrip: assummes codon_array is 64 positions long * * line should have begin consensus on it and be of MAXLINE length as it will be used as the buffer. * * This does **not** check that you have filled up all 64 positions. * * * Arg: codon_array [UNKN ] Undocumented argument [double *] * Arg: line [UNKN ] Undocumented argument [char*] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 811 "genefrequency.dy" boolean read_codon_GeneConsensus(double * codon_array,char* line,FILE * ifp) { boolean ret = TRUE; char * codon; char * number; if( strwhitestartcmp(line,"begin",spacestr) != 0 || strstr(line,"consensus") == NULL ) { warn("In reading codon GeneConsensus line, got no 'begin consensus' tag [%s]",line); return FALSE; } while( fgets(line,MAXLINE,ifp) != NULL ) { if( line[0] == '#' ) continue; if( strwhitestartcmp(line,"end",spacestr) == 0 ) break; codon = strtok(line,spacestr); number = strtok(NULL,spacestr); if( codon == NULL ) { warn("Found an uncommented line in codon consensus with no leading codon word"); continue; } if( number == NULL ) { warn("For codon %s, no number found",codon); ret = FALSE; continue; } if( strchr(codon,'N') != NULL ) continue; if( is_non_ambiguous_codon_seq(codon) == FALSE ) { warn("Codon %s is not really a codon... problem!"); ret = FALSE; continue; } codon_array[base4_codon_from_seq(codon)]= atof(number); } return ret; } /* Function: read_line_GeneConsensus(line,ifp) * * Descrip: Reads a single GeneConsensus from a file * * * Arg: line [UNKN ] Undocumented argument [char *] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [GeneConsensus *] * */ # line 866 "genefrequency.dy" GeneConsensus * read_line_GeneConsensus(char * line,FILE * ifp) { GeneConsensus * out; GeneSingleCons * temp; char buffer[MAXLINE]; char * runner; if( strwhitestartcmp(line,"begin",spacestr) != 0 ) { warn("Attempting to read a GeneConsensus structure with a line not starting with 'begin' [%s]",line); return NULL; } runner = strtok(line,spacestr); runner = strtok(NULL,spacestr); if( runner == NULL || strcmp(runner,"consensus") != 0 ) { warn("Attempting to read a GeneConsensus structure without a 'begin consensus' tag [%s]",line); return NULL; } out = GeneConsensus_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '#' ) continue; if( strwhitestartcmp(buffer,"end",spacestr) == 0 ) break; temp = read_line_GeneSingleCons(buffer); if( temp == NULL ) { warn("Unable to process GeneSingleCons line... dropping out..."); break; } add_GeneConsensus(out,temp); } return out; } # line 913 "genefrequency.dy" GeneSingleCons * read_line_GeneSingleCons(char * line) { GeneSingleCons * out; char * runner; char * run2; runner = strtok(line,spacestr); run2 = strtok(NULL,spacestr); if( runner == NULL || run2 == NULL ) { warn("In read_line_GeneSingleCons was not give two different words in line [%s]",line); return NULL; } out = GeneSingleCons_alloc(); out->string = stringalloc(runner); out->number = strtod(run2,&runner); if( runner == run2 || *runner != '\0' ) { warn("In read_line_GeneSingleCons, for string [%s], unable to convert the number [%s]",out->string,run2); } return out; } # line 942 "genefrequency.dy" GeneFrequency21 * untouched_GeneFrequency21(void) { register int i; GeneFrequency21 * out; out = GeneFrequency21_alloc(); for(i=0;i<64;i++) out->codon[i] = (-1); for(i=0;i<4;i++) out->central[i] = out->py[i] = out->spacer[i] = (-1); for(i=0;itransition[i] = (-1.0); return out; } # line 1013 "genefrequency.c" /* Function: hard_link_GeneSingleCons(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneSingleCons *] * * Return [UNKN ] Undocumented return value [GeneSingleCons *] * */ GeneSingleCons * hard_link_GeneSingleCons(GeneSingleCons * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneSingleCons object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneSingleCons_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneSingleCons *] * */ GeneSingleCons * GeneSingleCons_alloc(void) { GeneSingleCons * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneSingleCons *) ckalloc (sizeof(GeneSingleCons))) == NULL) { warn("GeneSingleCons_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->string = NULL; out->number = 0; return out; } /* Function: free_GeneSingleCons(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneSingleCons *] * * Return [UNKN ] Undocumented return value [GeneSingleCons *] * */ GeneSingleCons * free_GeneSingleCons(GeneSingleCons * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneSingleCons obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->string != NULL) ckfree(obj->string); ckfree(obj); return NULL; } /* Function: swap_GeneConsensus(list,i,j) * * Descrip: swap function: an internal for qsort_GeneConsensus * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [GeneSingleCons **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_GeneConsensus(GeneSingleCons ** list,int i,int j) { GeneSingleCons * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_GeneConsensus(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_GeneConsensus which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [GeneSingleCons **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_GeneConsensus(GeneSingleCons ** list,int left,int right,int (*comp)(GeneSingleCons * ,GeneSingleCons * )) { int i,last; if( left >= right ) return; swap_GeneConsensus(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_GeneConsensus (list,++last,i); } swap_GeneConsensus (list,left,last); qsort_GeneConsensus(list,left,last-1,comp); qsort_GeneConsensus(list,last+1,right,comp); } /* Function: sort_GeneConsensus(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_GeneConsensus * * * Arg: obj [UNKN ] Object containing list [GeneConsensus *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_GeneConsensus(GeneConsensus * obj,int (*comp)(GeneSingleCons *, GeneSingleCons *)) { qsort_GeneConsensus(obj->gsc,0,obj->len-1,comp); return; } /* Function: expand_GeneConsensus(obj,len) * * Descrip: Really an internal function for add_GeneConsensus * * * Arg: obj [UNKN ] Object which contains the list [GeneConsensus *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_GeneConsensus(GeneConsensus * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_GeneConsensus called with no need"); return TRUE; } if( (obj->gsc = (GeneSingleCons ** ) ckrealloc (obj->gsc,sizeof(GeneSingleCons *)*len)) == NULL) { warn("ckrealloc failed for expand_GeneConsensus, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_GeneConsensus(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GeneConsensus *] * Arg: add [OWNER] Object to add to the list [GeneSingleCons *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_GeneConsensus(GeneConsensus * obj,GeneSingleCons * add) { if( obj->len >= obj->maxlen) { if( expand_GeneConsensus(obj,obj->len + GeneConsensusLISTLENGTH) == FALSE) return FALSE; } obj->gsc[obj->len++]=add; return TRUE; } /* Function: flush_GeneConsensus(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GeneConsensus *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GeneConsensus(GeneConsensus * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->gsc[i] != NULL) { free_GeneSingleCons(obj->gsc[i]); obj->gsc[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: GeneConsensus_alloc_std(void) * * Descrip: Equivalent to GeneConsensus_alloc_len(GeneConsensusLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GeneConsensus *] * */ GeneConsensus * GeneConsensus_alloc_std(void) { return GeneConsensus_alloc_len(GeneConsensusLISTLENGTH); } /* Function: GeneConsensus_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GeneConsensus *] * */ GeneConsensus * GeneConsensus_alloc_len(int len) { GeneConsensus * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = GeneConsensus_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->gsc = (GeneSingleCons ** ) ckcalloc (len,sizeof(GeneSingleCons *))) == NULL) { warn("Warning, ckcalloc failed in GeneConsensus_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_GeneConsensus(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneConsensus *] * * Return [UNKN ] Undocumented return value [GeneConsensus *] * */ GeneConsensus * hard_link_GeneConsensus(GeneConsensus * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneConsensus object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneConsensus_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneConsensus *] * */ GeneConsensus * GeneConsensus_alloc(void) { GeneConsensus * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneConsensus *) ckalloc (sizeof(GeneConsensus))) == NULL) { warn("GeneConsensus_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->center = 0; out->gsc = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_GeneConsensus(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneConsensus *] * * Return [UNKN ] Undocumented return value [GeneConsensus *] * */ GeneConsensus * free_GeneConsensus(GeneConsensus * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneConsensus obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->gsc != NULL) { for(i=0;ilen;i++) { if( obj->gsc[i] != NULL) free_GeneSingleCons(obj->gsc[i]); } ckfree(obj->gsc); } ckfree(obj); return NULL; } /* Function: hard_link_GeneFrequency21(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneFrequency21 *] * * Return [UNKN ] Undocumented return value [GeneFrequency21 *] * */ GeneFrequency21 * hard_link_GeneFrequency21(GeneFrequency21 * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneFrequency21 object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneFrequency21_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneFrequency21 *] * */ GeneFrequency21 * GeneFrequency21_alloc(void) { GeneFrequency21 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneFrequency21 *) ckalloc (sizeof(GeneFrequency21))) == NULL) { warn("GeneFrequency21_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->ss5 = NULL; out->ss3 = NULL; /* codon[64] is an array: no default possible */ /* central[4] is an array: no default possible */ /* py[4] is an array: no default possible */ /* spacer[4] is an array: no default possible */ /* transition[GENEFREQUENCY21_TRANSITION_LEN] is an array: no default possible */ /* cds_triplet[64] is an array: no default possible */ return out; } /* Function: free_GeneFrequency21(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneFrequency21 *] * * Return [UNKN ] Undocumented return value [GeneFrequency21 *] * */ GeneFrequency21 * free_GeneFrequency21(GeneFrequency21 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneFrequency21 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->ss5 != NULL) free_GeneConsensus(obj->ss5); if( obj->ss3 != NULL) free_GeneConsensus(obj->ss3); ckfree(obj); return NULL; } /* Function: replace_ss5_GeneFrequency21(obj,ss5) * * Descrip: Replace member variable ss5 * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GeneFrequency21 *] * Arg: ss5 [OWNER] New value of the variable [GeneConsensus *] * * Return [SOFT ] member variable ss5 [boolean] * */ boolean replace_ss5_GeneFrequency21(GeneFrequency21 * obj,GeneConsensus * ss5) { if( obj == NULL) { warn("In replacement function ss5 for object GeneFrequency21, got a NULL object"); return FALSE; } obj->ss5 = ss5; return TRUE; } /* Function: access_ss5_GeneFrequency21(obj) * * Descrip: Access member variable ss5 * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GeneFrequency21 *] * * Return [SOFT ] member variable ss5 [GeneConsensus *] * */ GeneConsensus * access_ss5_GeneFrequency21(GeneFrequency21 * obj) { if( obj == NULL) { warn("In accessor function ss5 for object GeneFrequency21, got a NULL object"); return NULL; } return obj->ss5; } /* Function: replace_ss3_GeneFrequency21(obj,ss3) * * Descrip: Replace member variable ss3 * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GeneFrequency21 *] * Arg: ss3 [OWNER] New value of the variable [GeneConsensus *] * * Return [SOFT ] member variable ss3 [boolean] * */ boolean replace_ss3_GeneFrequency21(GeneFrequency21 * obj,GeneConsensus * ss3) { if( obj == NULL) { warn("In replacement function ss3 for object GeneFrequency21, got a NULL object"); return FALSE; } obj->ss3 = ss3; return TRUE; } /* Function: access_ss3_GeneFrequency21(obj) * * Descrip: Access member variable ss3 * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GeneFrequency21 *] * * Return [SOFT ] member variable ss3 [GeneConsensus *] * */ GeneConsensus * access_ss3_GeneFrequency21(GeneFrequency21 * obj) { if( obj == NULL) { warn("In accessor function ss3 for object GeneFrequency21, got a NULL object"); return NULL; } return obj->ss3; } /* Function: replace_center_GeneConsensus(obj,center) * * Descrip: Replace member variable center * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GeneConsensus *] * Arg: center [OWNER] New value of the variable [int] * * Return [SOFT ] member variable center [boolean] * */ boolean replace_center_GeneConsensus(GeneConsensus * obj,int center) { if( obj == NULL) { warn("In replacement function center for object GeneConsensus, got a NULL object"); return FALSE; } obj->center = center; return TRUE; } /* Function: access_center_GeneConsensus(obj) * * Descrip: Access member variable center * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GeneConsensus *] * * Return [SOFT ] member variable center [int] * */ int access_center_GeneConsensus(GeneConsensus * obj) { if( obj == NULL) { warn("In accessor function center for object GeneConsensus, got a NULL object"); return 0; } return obj->center; } /* Function: access_gsc_GeneConsensus(obj,i) * * Descrip: Access members stored in the gsc list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [GeneConsensus *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [GeneSingleCons *] * */ GeneSingleCons * access_gsc_GeneConsensus(GeneConsensus * obj,int i) { if( obj == NULL) { warn("In accessor function gsc for object GeneConsensus, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function gsc for object GeneConsensus, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->gsc[i]; } /* Function: length_gsc_GeneConsensus(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [GeneConsensus *] * * Return [UNKN ] length of the list [int] * */ int length_gsc_GeneConsensus(GeneConsensus * obj) { if( obj == NULL) { warn("In length function gsc for object GeneConsensus, got a NULL object"); return -1; } return obj->len; } /* Function: replace_string_GeneSingleCons(obj,string) * * Descrip: Replace member variable string * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GeneSingleCons *] * Arg: string [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable string [boolean] * */ boolean replace_string_GeneSingleCons(GeneSingleCons * obj,char * string) { if( obj == NULL) { warn("In replacement function string for object GeneSingleCons, got a NULL object"); return FALSE; } obj->string = string; return TRUE; } /* Function: access_string_GeneSingleCons(obj) * * Descrip: Access member variable string * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GeneSingleCons *] * * Return [SOFT ] member variable string [char *] * */ char * access_string_GeneSingleCons(GeneSingleCons * obj) { if( obj == NULL) { warn("In accessor function string for object GeneSingleCons, got a NULL object"); return NULL; } return obj->string; } /* Function: replace_number_GeneSingleCons(obj,number) * * Descrip: Replace member variable number * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GeneSingleCons *] * Arg: number [OWNER] New value of the variable [double] * * Return [SOFT ] member variable number [boolean] * */ boolean replace_number_GeneSingleCons(GeneSingleCons * obj,double number) { if( obj == NULL) { warn("In replacement function number for object GeneSingleCons, got a NULL object"); return FALSE; } obj->number = number; return TRUE; } /* Function: access_number_GeneSingleCons(obj) * * Descrip: Access member variable number * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GeneSingleCons *] * * Return [SOFT ] member variable number [double] * */ double access_number_GeneSingleCons(GeneSingleCons * obj) { if( obj == NULL) { warn("In accessor function number for object GeneSingleCons, got a NULL object"); return 0; } return obj->number; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/genefrequency.h0000644000175000001440000004457410670453714017161 0ustar philippusers#ifndef DYNAMITEgenefrequencyHEADERFILE #define DYNAMITEgenefrequencyHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "probability.h" #include "codon.h" #include "wisebase.h" #include "dyna.h" #include "randommodel.h" enum { GF21_CENTRAL_STAY, GF21_PY_STAY, GF21_SPACER_STAY, GF21_NO_SPACER, GF21_INTRON_CORR_TERM, GENEFREQUENCY21_TRANSITION_LEN }; #define GeneConsensusLISTLENGTH 128 enum { GeneConsensusType_5SS = 131, GeneConsensusType_3SS, GeneConsensusType_CDS, GeneConsensusType_Intron_Corr_Term, GeneConsensusType_Intron_emission, GeneConsensusType_Pyrimidine_emission, GeneConsensusType_Spacer_emission, GeneConsensusType_Central_stay, GeneConsensusType_Pyrimidine_stay, GeneConsensusType_Spacer_stay, GeneConsensusType_No_spacer, GeneConsensusType_Error }; struct Wise2_GeneSingleCons { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * string; double number; } ; /* GeneSingleCons defined */ #ifndef DYNAMITE_DEFINED_GeneSingleCons typedef struct Wise2_GeneSingleCons Wise2_GeneSingleCons; #define GeneSingleCons Wise2_GeneSingleCons #define DYNAMITE_DEFINED_GeneSingleCons #endif struct Wise2_GeneConsensus { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int center; GeneSingleCons ** gsc; int len;/* len for above gsc */ int maxlen; /* maxlen for above gsc */ } ; /* GeneConsensus defined */ #ifndef DYNAMITE_DEFINED_GeneConsensus typedef struct Wise2_GeneConsensus Wise2_GeneConsensus; #define GeneConsensus Wise2_GeneConsensus #define DYNAMITE_DEFINED_GeneConsensus #endif struct Wise2_GeneFrequency21 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GeneConsensus * ss5; GeneConsensus * ss3; double codon[64]; double central[4]; double py[4]; double spacer[4]; double transition[GENEFREQUENCY21_TRANSITION_LEN]; double cds_triplet[64]; /* phase 0 */ } ; /* GeneFrequency21 defined */ #ifndef DYNAMITE_DEFINED_GeneFrequency21 typedef struct Wise2_GeneFrequency21 Wise2_GeneFrequency21; #define GeneFrequency21 Wise2_GeneFrequency21 #define DYNAMITE_DEFINED_GeneFrequency21 #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: RandomCodon_from_cds_triplet(gf) * * Descrip: makes a randomcodon probability emission * from the counts in genefrequency * * * Arg: gf [UNKN ] Undocumented argument [GeneFrequency21 *] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ RandomCodon * Wise2_RandomCodon_from_cds_triplet(GeneFrequency21 * gf); #define RandomCodon_from_cds_triplet Wise2_RandomCodon_from_cds_triplet /* Function: RandomModelDNA_from_central_GeneFrequency21(gf) * * Descrip: Makes a random model from the central gene * model of an intron. Ideal for tieing intron * state distribution to the randommodel * * * Arg: gf [UNKN ] Undocumented argument [GeneFrequency21 *] * * Return [UNKN ] Undocumented return value [RandomModelDNA *] * */ RandomModelDNA * Wise2_RandomModelDNA_from_central_GeneFrequency21(GeneFrequency21 * gf); #define RandomModelDNA_from_central_GeneFrequency21 Wise2_RandomModelDNA_from_central_GeneFrequency21 /* Function: ComplexConsensi_5SS_from_GeneFrequency(gf) * * Descrip: makes 5'SS ComplexConsensi from GeneFrequency21 structure using * * CCC|XXXXXXX score = no(5'SS with CCC|XXXXXXX) / no(CCC in cds). * * * Arg: gf [UNKN ] Undocumented argument [GeneFrequency21 *] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * Wise2_ComplexConsensi_5SS_from_GeneFrequency(GeneFrequency21 * gf); #define ComplexConsensi_5SS_from_GeneFrequency Wise2_ComplexConsensi_5SS_from_GeneFrequency /* Function: ComplexConsensi_3SS_from_GeneFrequency(gf) * * Descrip: makes 3'SS ComplexConsensi from GeneFrequency21 structure using * * ZZZ|CCC score = no(3'SS with ZZZ|CCC) / no(CCC in cds). * * * Arg: gf [UNKN ] Undocumented argument [GeneFrequency21 *] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * Wise2_ComplexConsensi_3SS_from_GeneFrequency(GeneFrequency21 * gf); #define ComplexConsensi_3SS_from_GeneFrequency Wise2_ComplexConsensi_3SS_from_GeneFrequency /* Function: CodonFrequency_from_GeneFrequency21(gf,ct) * * Descrip: Builds a codon frequency table from raw counts * in the counts file * * * Arg: gf [UNKN ] Undocumented argument [GeneFrequency21 *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [CodonFrequency *] * */ CodonFrequency * Wise2_CodonFrequency_from_GeneFrequency21(GeneFrequency21 * gf,CodonTable * ct); #define CodonFrequency_from_GeneFrequency21 Wise2_CodonFrequency_from_GeneFrequency21 /* Function: read_GeneFrequency21_file(filename) * * Descrip: Opens the file with /openfile * * Reads in a GeneFrequency (Mor-Ewan style) * * * * Arg: filename [UNKN ] will open from WISECONFIGDIR etc via openfile [char *] * * Return [UNKN ] a newly allocated structure [GeneFrequency21 *] * */ GeneFrequency21 * Wise2_read_GeneFrequency21_file(char * filename); #define read_GeneFrequency21_file Wise2_read_GeneFrequency21_file /* Function: read_GeneFrequency21(ifp) * * Descrip: Reads in a GeneFrequency (Mor-Ewan style) * file from ifp * * * Arg: ifp [UNKN ] file pointer [FILE *] * * Return [UNKN ] a newly allocated structure [GeneFrequency21 *] * */ GeneFrequency21 * Wise2_read_GeneFrequency21(FILE * ifp); #define read_GeneFrequency21 Wise2_read_GeneFrequency21 /* Function: double_from_line(buffer) * * Descrip: helper string function * * * Arg: buffer [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_double_from_line(char * buffer); #define double_from_line Wise2_double_from_line /* Function: check_type_GeneFrequency(*line,ifp,center,phase) * * Descrip: Pretty sneaky function * * give * * line starting with "type xxx" * ifp file pointer * centre a &int for returning the centre value of the consensus if any. * phase a &int for returning the phase value of the consensus if any. * * you get *back* the line with the line "begin consensus" or "number" in it. * * * It returns a GeneConsensusType * * with GeneConsensusType_Error on error * * * * Arg: *line [UNKN ] Undocumented argument [char] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * Arg: center [UNKN ] Undocumented argument [int *] * Arg: phase [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_check_type_GeneFrequency(char *line,FILE * ifp,int * center,int * phase) ; #define check_type_GeneFrequency Wise2_check_type_GeneFrequency /* Function: read_base_GeneConsensus(base_array,line,ifp) * * Descrip: assummes base_array is 4 positions long * * line should have begin consensus on it and be of MAXLINE length as it will be used as the buffer. * * This does **not** check that you have filled up all 4 positions. * * * Arg: base_array [UNKN ] Undocumented argument [double *] * Arg: line [UNKN ] Undocumented argument [char*] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_read_base_GeneConsensus(double * base_array,char* line,FILE * ifp); #define read_base_GeneConsensus Wise2_read_base_GeneConsensus /* Function: read_codon_GeneConsensus(codon_array,line,ifp) * * Descrip: assummes codon_array is 64 positions long * * line should have begin consensus on it and be of MAXLINE length as it will be used as the buffer. * * This does **not** check that you have filled up all 64 positions. * * * Arg: codon_array [UNKN ] Undocumented argument [double *] * Arg: line [UNKN ] Undocumented argument [char*] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_read_codon_GeneConsensus(double * codon_array,char* line,FILE * ifp); #define read_codon_GeneConsensus Wise2_read_codon_GeneConsensus /* Function: read_line_GeneConsensus(line,ifp) * * Descrip: Reads a single GeneConsensus from a file * * * Arg: line [UNKN ] Undocumented argument [char *] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [GeneConsensus *] * */ GeneConsensus * Wise2_read_line_GeneConsensus(char * line,FILE * ifp); #define read_line_GeneConsensus Wise2_read_line_GeneConsensus /* Function: hard_link_GeneSingleCons(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneSingleCons *] * * Return [UNKN ] Undocumented return value [GeneSingleCons *] * */ GeneSingleCons * Wise2_hard_link_GeneSingleCons(GeneSingleCons * obj); #define hard_link_GeneSingleCons Wise2_hard_link_GeneSingleCons /* Function: GeneSingleCons_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneSingleCons *] * */ GeneSingleCons * Wise2_GeneSingleCons_alloc(void); #define GeneSingleCons_alloc Wise2_GeneSingleCons_alloc /* Function: free_GeneSingleCons(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneSingleCons *] * * Return [UNKN ] Undocumented return value [GeneSingleCons *] * */ GeneSingleCons * Wise2_free_GeneSingleCons(GeneSingleCons * obj); #define free_GeneSingleCons Wise2_free_GeneSingleCons /* Function: add_GeneConsensus(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GeneConsensus *] * Arg: add [OWNER] Object to add to the list [GeneSingleCons *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_GeneConsensus(GeneConsensus * obj,GeneSingleCons * add); #define add_GeneConsensus Wise2_add_GeneConsensus /* Function: flush_GeneConsensus(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GeneConsensus *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_GeneConsensus(GeneConsensus * obj); #define flush_GeneConsensus Wise2_flush_GeneConsensus /* Function: GeneConsensus_alloc_std(void) * * Descrip: Equivalent to GeneConsensus_alloc_len(GeneConsensusLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GeneConsensus *] * */ GeneConsensus * Wise2_GeneConsensus_alloc_std(void); #define GeneConsensus_alloc_std Wise2_GeneConsensus_alloc_std /* Function: GeneConsensus_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GeneConsensus *] * */ GeneConsensus * Wise2_GeneConsensus_alloc_len(int len); #define GeneConsensus_alloc_len Wise2_GeneConsensus_alloc_len /* Function: hard_link_GeneConsensus(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneConsensus *] * * Return [UNKN ] Undocumented return value [GeneConsensus *] * */ GeneConsensus * Wise2_hard_link_GeneConsensus(GeneConsensus * obj); #define hard_link_GeneConsensus Wise2_hard_link_GeneConsensus /* Function: GeneConsensus_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneConsensus *] * */ GeneConsensus * Wise2_GeneConsensus_alloc(void); #define GeneConsensus_alloc Wise2_GeneConsensus_alloc /* Function: free_GeneConsensus(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneConsensus *] * * Return [UNKN ] Undocumented return value [GeneConsensus *] * */ GeneConsensus * Wise2_free_GeneConsensus(GeneConsensus * obj); #define free_GeneConsensus Wise2_free_GeneConsensus /* Function: hard_link_GeneFrequency21(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneFrequency21 *] * * Return [UNKN ] Undocumented return value [GeneFrequency21 *] * */ GeneFrequency21 * Wise2_hard_link_GeneFrequency21(GeneFrequency21 * obj); #define hard_link_GeneFrequency21 Wise2_hard_link_GeneFrequency21 /* Function: GeneFrequency21_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneFrequency21 *] * */ GeneFrequency21 * Wise2_GeneFrequency21_alloc(void); #define GeneFrequency21_alloc Wise2_GeneFrequency21_alloc /* Function: free_GeneFrequency21(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneFrequency21 *] * * Return [UNKN ] Undocumented return value [GeneFrequency21 *] * */ GeneFrequency21 * Wise2_free_GeneFrequency21(GeneFrequency21 * obj); #define free_GeneFrequency21 Wise2_free_GeneFrequency21 /* Unplaced functions */ /* There has been no indication of the use of these functions */ GeneSingleCons * Wise2_read_line_GeneSingleCons(char * line); #define read_line_GeneSingleCons Wise2_read_line_GeneSingleCons GeneFrequency21 * Wise2_untouched_GeneFrequency21(void); #define untouched_GeneFrequency21 Wise2_untouched_GeneFrequency21 /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ GeneConsensus * Wise2_access_ss5_GeneFrequency21(GeneFrequency21 * obj); #define access_ss5_GeneFrequency21 Wise2_access_ss5_GeneFrequency21 boolean Wise2_replace_ss3_GeneFrequency21(GeneFrequency21 * obj,GeneConsensus * ss3); #define replace_ss3_GeneFrequency21 Wise2_replace_ss3_GeneFrequency21 GeneConsensus * Wise2_access_ss3_GeneFrequency21(GeneFrequency21 * obj); #define access_ss3_GeneFrequency21 Wise2_access_ss3_GeneFrequency21 boolean Wise2_replace_number_GeneSingleCons(GeneSingleCons * obj,double number); #define replace_number_GeneSingleCons Wise2_replace_number_GeneSingleCons char * Wise2_access_string_GeneSingleCons(GeneSingleCons * obj); #define access_string_GeneSingleCons Wise2_access_string_GeneSingleCons boolean Wise2_replace_center_GeneConsensus(GeneConsensus * obj,int center); #define replace_center_GeneConsensus Wise2_replace_center_GeneConsensus double Wise2_access_number_GeneSingleCons(GeneSingleCons * obj); #define access_number_GeneSingleCons Wise2_access_number_GeneSingleCons int Wise2_access_center_GeneConsensus(GeneConsensus * obj); #define access_center_GeneConsensus Wise2_access_center_GeneConsensus boolean Wise2_replace_ss5_GeneFrequency21(GeneFrequency21 * obj,GeneConsensus * ss5); #define replace_ss5_GeneFrequency21 Wise2_replace_ss5_GeneFrequency21 GeneSingleCons * Wise2_access_gsc_GeneConsensus(GeneConsensus * obj,int i); #define access_gsc_GeneConsensus Wise2_access_gsc_GeneConsensus boolean Wise2_replace_string_GeneSingleCons(GeneSingleCons * obj,char * string); #define replace_string_GeneSingleCons Wise2_replace_string_GeneSingleCons int Wise2_length_gsc_GeneConsensus(GeneConsensus * obj); #define length_gsc_GeneConsensus Wise2_length_gsc_GeneConsensus double Wise2_nocds_from_ambiguous_codon(char * codon,double * codon_freq_array); #define nocds_from_ambiguous_codon Wise2_nocds_from_ambiguous_codon ComplexConsensusWord * Wise2_ComplexConsensusWord_from_string_and_prob(char * string,Probability p); #define ComplexConsensusWord_from_string_and_prob Wise2_ComplexConsensusWord_from_string_and_prob void Wise2_show_flat_GeneFrequency21(GeneFrequency21 * gf21,FILE * ofp); #define show_flat_GeneFrequency21 Wise2_show_flat_GeneFrequency21 void Wise2_show_codon_emission(double * codon,FILE * ofp); #define show_codon_emission Wise2_show_codon_emission void Wise2_show_single_codon_emission(double no,int base4codon,FILE * ofp); #define show_single_codon_emission Wise2_show_single_codon_emission void Wise2_show_base_emission(double * base,FILE * ofp); #define show_base_emission Wise2_show_base_emission void Wise2_show_GeneConsensus(GeneConsensus * gc,FILE * ofp); #define show_GeneConsensus Wise2_show_GeneConsensus void Wise2_show_GeneSingleCons(GeneSingleCons * gsc,FILE * ofp); #define show_GeneSingleCons Wise2_show_GeneSingleCons boolean Wise2_skip_consensus(FILE * ifp); #define skip_consensus Wise2_skip_consensus int Wise2_string_to_GeneConsensusType(char * string); #define string_to_GeneConsensusType Wise2_string_to_GeneConsensusType void Wise2_swap_GeneConsensus(GeneSingleCons ** list,int i,int j) ; #define swap_GeneConsensus Wise2_swap_GeneConsensus void Wise2_qsort_GeneConsensus(GeneSingleCons ** list,int left,int right,int (*comp)(GeneSingleCons * ,GeneSingleCons * )); #define qsort_GeneConsensus Wise2_qsort_GeneConsensus void Wise2_sort_GeneConsensus(GeneConsensus * obj,int (*comp)(GeneSingleCons *, GeneSingleCons *)); #define sort_GeneConsensus Wise2_sort_GeneConsensus boolean Wise2_expand_GeneConsensus(GeneConsensus * obj,int len); #define expand_GeneConsensus Wise2_expand_GeneConsensus #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/transfactor.dy0000644000175000001440000005041010076537057017021 0ustar philippusers %{ #include "pwmdna.h" #include "hitlist.h" #define TransFactorSetLISTLENGTH 64 #define TransFactorMatchSetLISTLENGTH 64 #define TransFactorMatchSetComparaLISTLENGTH 8 #define TFCOMPARA_OVERLAP_PRECISE 37 #define TFCOMPARA_OVERLAP_OVERLAP 38 #define TFCOMPARA_OVERLAP_REGION 39 #define TFM_ABSOLUTE 84 #define TFM_RELATIVE 85 #define TFM_RELATIVE_MIXED 86 %} struct TransFactor char * name SeqAlign * seed pwmDNA * pwm SeqAlign * full double max_prob double min_prob struct TransFactorSet TransFactor ** factor !list struct TransFactorMatch int start int end char strand !def="1" double bit_score TransFactor * factor struct TransFactorMatchSet TransFactorMatch ** match !list Sequence * target struct TransFactorMatchSetCompara SeqAlign * sa; TransFactorMatchSet ** tfms !list TransFactorMatchSet * overall struct TransFactorComparaPara int overlap_type !def="TFCOMPARA_OVERLAP_PRECISE" int overlap_len !def=20 int missing_seq !def=0 struct TransFactorBuildPara RandomModelDNA * rnd_dna double pseudo_count !def="0.3" boolean warn_on_small_seq !def="TRUE" struct TransFactorMatchPara double min_bits !def="11.0" double min_relative !def="11.0" double relative_prob !def=0.95 double relative_prob_bits !def=0.9 char type !def="TFM_RELATIVE_MIXED" int allow_N !def="0" %{ #include "transfactor.h" void show_context_match_TransFactorMatchSetCompara(TransFactorMatchSetCompara * tfmsc,int context,FILE *ofp) { int i; int j; int k; int p; char buffer[MAXLINE]; assert(tfmsc != NULL); assert(tfmsc->overall != NULL); for(i=0;ioverall->len;i++) { fprintf(ofp,"Match %d Factor %s %s %d %d %d %.2f %.2f\n",i,tfmsc->overall->match[i]->factor->name,tfmsc->overall->target->name, tfmsc->overall->match[i]->start, tfmsc->overall->match[i]->end, tfmsc->overall->match[i]->strand, tfmsc->overall->match[i]->bit_score, Probability2Bits(tfmsc->overall->match[i]->factor->max_prob) ); for(j=0;jsa->len;j++) { k = tfmsc->overall->match[i]->start - context; if( k <= 0 ) { k = 0; } for(p=0;koverall->match[i]->start;k++,p++) { buffer[p] = tolower(tfmsc->sa->seq[j]->seq[k]); } for(;koverall->match[i]->end;k++,p++) { buffer[p] = toupper(tfmsc->sa->seq[j]->seq[k]); } for(;koverall->match[i]->end+context;k++,p++) { buffer[p] = tolower(tfmsc->sa->seq[j]->seq[k]); } buffer[p] = '\0'; fprintf(ofp,"%40s %s\n",tfmsc->sa->seq[j]->name,buffer); } fprintf(ofp,"EndMatch\n"); } } TransFactorSet * circular_permuted_TransFactorSet(TransFactorSet * in,int rotate_number) { TransFactorSet * out; int i; TransFactor * f; assert(in != NULL); out = TransFactorSet_alloc_len(in->len); for(i=0;ilen;i++) { f = TransFactor_alloc(); f->name = stringalloc(in->factor[i]->name); f->pwm = circular_permuted_pwmDNA(in->factor[i]->pwm,rotate_number); f->seed = hard_link_SeqAlign(in->factor[i]->seed); add_TransFactorSet(out,f); } return out; } void show_TransFactorMatchSet(TransFactorMatchSet * tfms,FILE * ofp) { int i; assert(tfms != NULL); assert(ofp != NULL); assert(tfms->target != NULL); for(i=0;ilen;i++) { fprintf(ofp,"Motif\t%s\t%d\t%d\t%d\t%s\t%.2f\t%.*s\n",tfms->target->name,tfms->match[i]->start+1,tfms->match[i]->start+tfms->match[i]->factor->seed->seq[0]->len,tfms->match[i]->strand,tfms->match[i]->factor->name,tfms->match[i]->bit_score,tfms->match[i]->factor->seed->seq[0]->len,tfms->target->seq+tfms->match[i]->start); } } void show_help_TransFactorMatchPara(FILE * ofp) { fprintf(ofp,"TransFactor Match Parameters\n"); fprintf(ofp," -tfm_type [abs/rel/relmix] type of cutoff: absolute, relative, relative mixed\n"); fprintf(ofp," -tfm_cutoff (abs) bits cutoff for absolute matches, default 11.0\n"); fprintf(ofp," -tfm_rel [0.95] (rel/relmix) Relative to best possible score, accept if above irregardless of score\nn"); fprintf(ofp," -tfm_relsoft [0.9] (relmix) Relative to best possible score, accept if above this relative and bit score\n"); fprintf(ofp," -tfm_relbits [11.0] (relmix) If above relsoft and above this bits score, accept\n"); } void show_help_TransFactorComparaPara(FILE * ofp) { fprintf(ofp,"TransFactor comparative filter parameters\n"); fprintf(ofp," -tfc_type [precise/overlap/region] overlap criteria\n"); fprintf(ofp," -tfc_region [20] region length\n"); fprintf(ofp," -tfc_missing [0] number of sequences motif can be missing in\n"); } TransFactorComparaPara * new_TransFactorComparaPara_from_argv(int * argc,char ** argv) { char * temp; TransFactorComparaPara * out; out = TransFactorComparaPara_alloc(); temp = strip_out_assigned_argument(argc,argv,"tfc_type"); if( temp != NULL ) { if( strcmp(temp,"precise") == 0 ) { out->overlap_type = TFCOMPARA_OVERLAP_PRECISE; } else if ( strcmp(temp,"overlap") == 0 ) { out->overlap_type = TFCOMPARA_OVERLAP_OVERLAP; } else if( strcmp(temp,"region") == 0 ) { out->overlap_type = TFCOMPARA_OVERLAP_REGION; } else { warn("string %s is not a valid tf_compara overlap type",temp); return NULL; } } strip_out_integer_argument(argc,argv,"tfc_region",&out->overlap_len); strip_out_integer_argument(argc,argv,"tfc_missing",&out->missing_seq); return out; } TransFactorMatchSetCompara * calculate_TransFactorMatchSetCompara(SeqAlign * sa,TransFactorSet * tfs,TransFactorMatchPara * match_para,TransFactorComparaPara * para) { int i; int j; int k; int count; int found; TransFactorMatchSetCompara * out; out = TransFactorMatchSetCompara_alloc_len(sa->len); out->sa = hard_link_SeqAlign(sa); for(i=0;ilen;i++) { add_TransFactorMatchSetCompara(out,calculate_TransFactorMatchSet(sa->seq[i],tfs,match_para)); } out->overall = TransFactorMatchSet_alloc_std(); out->overall->target = hard_link_Sequence(out->tfms[0]->target); for(i=0;itfms[0]->len;i++) { count = 0; for(k=1;klen;k++) { found = 0; for(j=0;jtfms[k]->len;j++) { if( out->tfms[0]->match[i]->factor == out->tfms[k]->match[j]->factor ) { if( para->overlap_type == TFCOMPARA_OVERLAP_PRECISE ) { if( out->tfms[0]->match[i]->start == out->tfms[k]->match[j]->start ) { found = 1; break; } } else if ( para->overlap_type == TFCOMPARA_OVERLAP_OVERLAP ) { if( !(out->tfms[0]->match[i]->end < out->tfms[k]->match[j]->start || out->tfms[0]->match[i]->start > out->tfms[k]->match[j]->end ) ) { found = 1; break; } } else if ( para->overlap_type == TFCOMPARA_OVERLAP_REGION ) { if( !(out->tfms[0]->match[i]->end - para->overlap_len < out->tfms[k]->match[j]->start || out->tfms[0]->match[i]->start + para->overlap_len > out->tfms[k]->match[j]->end ) ) { found = 1; break; } } else { fatal("Bad overlap type in compara tf matching"); } } } if( found == 0 ) { count++; } } if( count <= para->missing_seq ) { add_TransFactorMatchSet(out->overall,hard_link_TransFactorMatch(out->tfms[0]->match[i])); } } return out; } void show_help_TransFactorBuildPara(FILE * ofp) { fprintf(ofp,"TransFactor Build Parameters\n"); fprintf(ofp," -tfb_pseudo simple pseudo count, default 0.3\n"); fprintf(ofp," -[no]tfb_warn warn on small sequence number [default yes]\n"); } TransFactorBuildPara * new_TransFactorBuildPara_from_argv(int * argc,char ** argv) { TransFactorBuildPara * out; out = TransFactorBuildPara_alloc(); out->pseudo_count = 0.3; out->rnd_dna = RandomModelDNA_std(); strip_out_float_argument(argc,argv,"tfb_pseudo",&out->pseudo_count); return out; } TransFactorMatchPara * new_TransFactorMatchPara_from_argv(int * argc,char ** argv) { char * temp; TransFactorMatchPara * out; out = TransFactorMatchPara_alloc(); out->type = TFM_RELATIVE_MIXED; out->relative_prob = 0.95; out->relative_prob_bits = 0.9; out->min_bits = 11.0; out->min_relative = 11.0; out->allow_N = 0; temp = strip_out_assigned_argument(argc,argv,"tfm_type"); if( temp != NULL ) { if( strcmp(temp,"abs") == 0 ) { out->type = TFM_ABSOLUTE; } else if ( strcmp(temp,"rel") == 0 ) { out->type = TFM_RELATIVE; } else if ( strcmp(temp,"relmix") == 0 ) { out->type = TFM_RELATIVE_MIXED; } else { warn("Could not understand %s as a match para type",temp); return NULL; } } strip_out_float_argument(argc,argv,"tfm_cutoff",&out->min_bits); strip_out_float_argument(argc,argv,"tfm_rel",&out->relative_prob); strip_out_float_argument(argc,argv,"tfm_relsoft",&out->relative_prob_bits); strip_out_float_argument(argc,argv,"tfm_relbits",&out->min_relative); assert(out->relative_prob <= 1.0 ); assert(out->relative_prob_bits <= 1.0 ); return out; } boolean build_TransFactorSet(TransFactorSet * tfs,TransFactorBuildPara * p) { int i; assert(tfs); assert(p); for(i=0;ilen;i++) { build_pwm_TransFactor(tfs->factor[i],p); } } boolean build_pwm_TransFactor(TransFactor * tf,TransFactorBuildPara * p) { assert(tf); assert(tf->seed); assert(p); tf->pwm = pwmDNA_from_SeqAlign(tf->seed,p->pseudo_count); fold_randommodel_pwmDNA(tf->pwm,p->rnd_dna); tf->max_prob = max_prob_TransFactor(tf); tf->min_prob = min_prob_TransFactor(tf); return TRUE; } TransFactorMatchSet * calculate_TransFactorMatchSet(Sequence * seq,TransFactorSet * tfs,TransFactorMatchPara * p) { int i; int j; int k; int len; double prob; double rev_prob; double cutoff; double t; TransFactorMatchSet * out; TransFactorMatch * m; Sequence * comp; assert(seq); assert(tfs); assert(p); comp = reverse_complement_Sequence(seq); assert(comp); out = TransFactorMatchSet_alloc_std(); out->target = hard_link_Sequence(seq); for(i=0;ilen;i++) { len = seq->len - tfs->factor[i]->pwm->len; /* adjust cutoff on a per motif basis */ switch(p->type ) { case TFM_ABSOLUTE : cutoff = Bits2Probability(p->min_bits); break; case TFM_RELATIVE : cutoff = Bits2Probability(Probability2Bits(tfs->factor[i]->max_prob)*p->relative_prob); break; case TFM_RELATIVE_MIXED : cutoff = Bits2Probability(Probability2Bits(tfs->factor[i]->max_prob)*p->relative_prob); t = Bits2Probability(Probability2Bits(tfs->factor[i]->max_prob)*p->relative_prob_bits); if( t > p->min_relative && t < cutoff) { cutoff = t; } break; default : fatal("Impossible - bad match parameter passed in"); } /* fprintf(stderr,"Cutoff is %.2f for factor %d (%.2f) vs %.2f (bits) and %.2f cutoff %.2f\n",cutoff,i,tfs->factor[i]->max_prob,Probability2Bits(tfs->factor[i]->max_prob),Probability2Bits(tfs->factor[i]->max_prob)*p->relative_prob,p->relative_prob); */ for(j=0;jfactor[i]->pwm->len;k++) { /* fprintf(stderr,"position is %d, chr %c base %d\n",j+k,seq->seq[j+k],base_from_char(seq->seq[j+k])); */ if( p->allow_N == 0 && base_from_char(seq->seq[j+k]) == BASE_N ) { prob *= 0.0; } if( p->allow_N == 0 && base_from_char(comp->seq[j+k]) == BASE_N ) { rev_prob *= 0.0; } prob *= tfs->factor[i]->pwm->pos[k]->emit[base_from_char(seq->seq[j+k])]; rev_prob *= tfs->factor[i]->pwm->pos[k]->emit[base_from_char(comp->seq[j+k])]; } if( prob > cutoff ) { m = TransFactorMatch_alloc(); m->start = j; m->end = j+tfs->factor[i]->seed->seq[0]->len; m->strand = 1; m->bit_score = Score2Bits(Probability2Score(prob)); m->factor = hard_link_TransFactor(tfs->factor[i]); add_TransFactorMatchSet(out,m); } if( rev_prob > cutoff ) { m = TransFactorMatch_alloc(); m->start = seq->len - j - tfs->factor[i]->seed->seq[0]->len;; m->end = seq->len - j; m->strand = -1; m->bit_score = Score2Bits(Probability2Score(rev_prob)); m->factor = hard_link_TransFactor(tfs->factor[i]); add_TransFactorMatchSet(out,m); } } } free_Sequence(comp); return out; } double min_prob_TransFactor(TransFactor * tf) { double sc; int i,j; double min; assert(tf != NULL); assert(tf->pwm != NULL); sc = 1.0; for(i=0;ipwm->len;i++) { min = tf->pwm->pos[i]->emit[0]; for(j=1;j<4;j++) { if( min > tf->pwm->pos[i]->emit[j] ) { min = tf->pwm->pos[i]->emit[j]; } } sc *= min; } return sc; } double max_prob_TransFactor(TransFactor * tf) { double sc; int i,j; int maxj; double max; assert(tf != NULL); assert(tf->pwm != NULL); sc = 1.0; for(i=0;ipwm->len;i++) { max = tf->pwm->pos[i]->emit[0]; maxj = 0; for(j=1;j<4;j++) { /* fprintf(stderr,"%d, comparing %.2f with %.2f\n",i,max,tf->pwm->pos[i]->emit[j]); */ if( max < tf->pwm->pos[i]->emit[j] ) { max = tf->pwm->pos[i]->emit[j]; maxj = j; } } /*fprintf(stderr,"At position %d, so far %.2f with %.2f (%d)\n",i,sc,max,maxj);*/ sc *= max; } /*fprintf(stderr,"Returning %.2f as max\n",sc);*/ return sc; } void write_TransFactorSet(TransFactorSet * tfs,FILE * ofp) { int i; for(i=0;ilen;i++) { write_TransFactor(tfs->factor[i],ofp); } } void write_TransFactor(TransFactor * tf,FILE * ofp) { double sc = 0.0; int i; int j; assert(tf); assert(tf->seed); if( tf->pwm != NULL ) { for(i=0;iseed->seq[0]->len;i++) { for(j=0;j<4;j++) { sc += 0.25 * tf->pwm->pos[i]->emit[j]; } } } else { sc = 0.0; } fprintf(ofp,"factor %s\n",tf->name); fprintf(ofp,"seed\n"); fprintf(ofp,"expected %.2f\n",sc); write_selex_SeqAlign(tf->seed,15,100,ofp); fprintf(ofp,"//\n"); fprintf(ofp,"end factor\n"); } TransFactorSet * read_TransFactorSet_file(char * filename) { TransFactorSet * tfs; FILE * ifp; assert(filename); ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s for TransFactorSet reading",filename); return NULL; } tfs = read_TransFactorSet(ifp); fclose(ifp); return tfs; } TransFactorSet * read_ben_IUPAC_TransFactorSet_file(char * filename) { TransFactorSet * tfs; FILE * ifp; assert(filename); ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s for TransFactorSet reading",filename); return NULL; } tfs = read_ben_IUPAC_TransFactorSet(ifp); fclose(ifp); return tfs; } static char iupac_map[17][5] = { {'A','A','.','.','.'}, {'C','C','.','.','.'}, {'G','G','.','.','.'}, {'T','T','.','.','.'}, {'M','A','C','.','.'}, {'R','A','G','.','.'}, {'W','A','T','.','.'}, {'S','C','G','.','.'}, {'Y','C','T','.','.'}, {'K','G','T','.','.'}, {'V','A','C','G','.'}, {'H','A','C','T','.'}, {'D','A','G','T','.'}, {'B','C','G','T','.'}, {'X','A','G','T','C'}, {'N','A','G','T','C'}, }; TransFactorSet * read_ben_IUPAC_TransFactorSet(FILE * ifp) { char buffer[MAXLINE]; TransFactorSet * out; TransFactor * temp; SeqAlign * align; Sequence * line; char lines [12][40]; char sbuffer[MAXLINE]; int motif_no = 1; int seq_no = 1; int i; int j; int k; int l; out = TransFactorSet_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == ' ' || buffer[0] == '#' ) { continue; } for(i=0;!isspace(buffer[i]);i++) { for(l=0;l<17;l++) { if( iupac_map[l][0] == buffer[i] ) { break; } } if( l == 17 ) { warn("Weird non IUPAC code [%c] in %s",buffer[i],buffer); break; } /* we make 12 fake sequences, using the IUPAC map, moving the k, the index in the possible nuc in the map when we hit . - this means A becomes 12 A's, Y becomes 6 C's and 6 T's etc */ for(j=0,k=1;j<12;j++,k++) { for(;iupac_map[l][k] == '.' && k < 5;k++) ; if( k == 5 ) { k = 1; } if( buffer[i] == 'N' ) { lines[j][i] = 'N'; } else { lines[j][i] = iupac_map[l][k]; } } } if( !isspace(buffer[i]) ) { continue; /* error scenario */ } else { buffer[i] = '\0'; } for(j=0;j<12;j++) { lines[j][i] = '\0'; } sprintf(sbuffer,"motif_%d_%s",motif_no,buffer); temp = TransFactor_alloc(); temp->name = stringalloc(sbuffer); align = SeqAlign_alloc_std(); for(j=0;j<12;j++) { sprintf(sbuffer,"fake_%d_%d",motif_no,j); line = Sequence_from_static_memory(sbuffer,lines[j]); add_SeqAlign(align,line); } temp->seed = trim_from_N_SeqAlign(align); free_SeqAlign(align); add_TransFactorSet(out,temp); motif_no++; } return out; } TransFactorSet * read_laurence_TransFactorSet_file(char * filename) { TransFactorSet * tfs; FILE * ifp; assert(filename); ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s for TransFactorSet reading",filename); return NULL; } tfs = read_laurence_TransFactorSet(ifp); fclose(ifp); return tfs; } TransFactorSet * read_laurence_TransFactorSet(FILE * ifp) { char buffer[MAXLINE]; TransFactorSet * out; TransFactor * temp; SeqAlign * align; Sequence * line; char sbuffer[MAXLINE]; int motif_no = 1; int seq_no = 1; int i; out = TransFactorSet_alloc_std(); sprintf(sbuffer,"motif_%d",motif_no); temp = TransFactor_alloc(); temp->name = stringalloc(sbuffer); align = SeqAlign_alloc_std(); while( fgets(buffer,MAXLINE,ifp) ) { if( buffer[0] == '#' ) { continue; } if( strstr(buffer,"degenerate") != NULL ) { temp->seed = trim_from_N_SeqAlign(align); free_SeqAlign(align); add_TransFactorSet(out,temp); seq_no = 1; motif_no++; sprintf(sbuffer,"motif_%d",motif_no); temp = TransFactor_alloc(); temp->name = stringalloc(sbuffer); align = SeqAlign_alloc_std(); continue; } if( buffer[0] == '=' ) { continue; } for(i=0;buffer[i] != '\0';i++) { if( buffer[i] != 'A' && buffer[i] != 'T' && buffer[i] != 'G' && buffer[i] != 'C' ) { buffer[i] = 'N'; } } line = Sequence_alloc(); sprintf(sbuffer,"motif_%d_seq_%d",motif_no,seq_no); seq_no++; line->name = stringalloc(sbuffer); line->seq = stringalloc(buffer); line->type = SEQUENCE_DNA; line->len = strlen(buffer); add_SeqAlign(align,line); } return out; } TransFactorSet * read_TransFactorSet(FILE * ifp) { char buffer[MAXLINE]; TransFactorSet * out; TransFactor * temp; out = TransFactorSet_alloc_std(); while( fgets(buffer,MAXLINE,ifp) ) { if( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"factor") == 0 ) { temp = read_TransFactor(buffer,ifp); if( temp == NULL ) { warn("No transfactor; skipping; parsing may have fallen down"); continue; } else { add_TransFactorSet(out,temp); } continue; } if( isalpha(buffer[0]) ) { warn("could not interpret in reading transfactorset %s",buffer); } } return out; } TransFactor * read_TransFactor(char * line,FILE * ifp) { char buffer[MAXLINE]; char * name; char * t; TransFactor * out; SeqAlign * temp; if( strstartcmp(line,"factor") != 0 ) { warn("Passed in a line [%s] which has no factor to the factor reader. Not good!",line); return NULL; } name = line + strlen("factor")+1; for(;isspace(*name);name++) ; if( *name == '\0' ) { warn("No name in factor - which is bad! %s\n",line); return NULL; } for(t=name;*t && !isspace(*t);t++) ; *t = '\0'; while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"seed") == 0 ) { temp = read_selex_SeqAlign(ifp); if( temp == NULL ) { warn("No sequence alignment for this factor. Skipping"); return NULL; } continue; } if( strstartcmp(buffer,"end") == 0 ) { break; } if( isalpha(buffer[0]) ) { warn("Uninterpretable line in transfactor %s",buffer); } } if( temp == NULL ) { warn("No seed alignment read. Impossible for %s",name); return NULL; } out = TransFactor_alloc(); out->seed = temp; out->name = stringalloc(name); return out; } int compare_start_TransFactorMatch(TransFactorMatch * a,TransFactorMatch * b) { return a->start - b->start; } void sort_by_start_TransFactorMatchSet(TransFactorMatchSet * t) { sort_TransFactorMatchSet(t,compare_start_TransFactorMatch); } %} wise-2.4.1/src/models/estquick3.dy0000644000175000001440000000530707313404544016405 0ustar philippusers/* Last edited: Apr 24 15:04 1997 (birney) */ %{ #include "dyna.h" #include "cdparser.h" #include "genewisemodel.h" #include "gwquickdb.h" %} type QUICK_GENEWISE real GeneWiseScoreFlat* dbtype GeneWiseQuickDB* init init_GeneWiseQuickDB reload reload_GeneWiseQuickDB close close_GeneWiseQuickDB addentry dataentry_add_GeneWiseQuickDB hardlink hard_link_GeneWiseScoreFlat free free_GeneWiseScoreFlat threadsafe endtype matrix EstQuick3 query type="QUICK_GENEWISE" name="query" field:len="len" target type="CDNA" name="target" resource type="cDNAParserScore *" name="cp" extern name="GW_*" type="int" extern name="PCD_*" type="int" state MATCH offi="1" offj="3" source MATCH calc="query->seg[i].transition[GW_MATCH2MATCH] + query->seg[i].match[CDNA_CODON(target,j)]" endsource source INSERT calc="query->seg[i].transition[GW_INSERT2MATCH] + query->seg[i].match[CDNA_CODON(target,j)]" endsource source DELETE calc="query->seg[i].transition[GW_DELETE2MATCH] + query->seg[i].match[CDNA_CODON(target,j)]" endsource source START calc="query->seg[i].transition[GW_START2MATCH] + query->seg[i].match[CDNA_CODON(target,j)]" endsource # # Sequencing error transitions, at offsets 2,4 for speed up # source MATCH offi="1" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource query_label MATCH_STATE target_label CODON endstate # # Insert state: does not move along model, produces DNA sequence... # state INSERT offi="0" offj="3" source MATCH calc="query->seg[i].transition[GW_MATCH2INSERT] + query->seg[i].insert[CDNA_CODON(target,j)]" endsource source INSERT calc="query->seg[i].transition[GW_INSERT2INSERT] + query->seg[i].insert[CDNA_CODON(target,j)]" endsource # # Sequencing error transitions at only 2,4 for speed up # source INSERT offi="0" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="query->seg[i].transition[GW_MATCH2DELETE]" endsource source DELETE calc="query->seg[i].transition[GW_DELETE2DELETE]" endsource query_label DELETE_STATE target_label INSERT endstate state START !start !special endstate state END !end !special source MATCH calc="query->seg[i].transition[GW_MATCH2END]" endsource target_label END query_label END endstate endmatrix wise-2.4.1/src/models/seqaligndisplay_api.h0000644000175000001440000000505110670453715020327 0ustar philippusers /* Helper functions in the module * * Wise2_write_pretty_str_align * Wise2_write_pretty_seq_align * Wise2_write_pretty_Protein_align * /* These functions are not associated with an object */ /* Function: Wise2_write_pretty_str_align(alb,qname,query,tname,target,name,main,ofp) * * Descrip: This gives an interface into the alignment * display using strings and files. * * * Arg: alb alignment structure [Wise2_AlnBlock *] * Arg: qname name of first sequence [char *] * Arg: query first sequence [char *] * Arg: tname name of second sequence [char *] * Arg: target second sequence [char *] * Arg: name length of the name block [int] * Arg: main length of the main block [int] * Arg: ofp output file [FILE *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_write_pretty_str_align( Wise2_AlnBlock * alb,char * qname,char * query,char * tname,char * target,int name,int main,FILE * ofp); /* Function: Wise2_write_pretty_seq_align(alb,q,t,name,main,ofp) * * Descrip: This gives an interface into the alignment * display using sequences and files. A more * generic function is write_pretty_str_align * * * Arg: alb alignment structure [Wise2_AlnBlock *] * Arg: q first sequence [Wise2_Sequence *] * Arg: t second sequence [Wise2_Sequence *] * Arg: name length of the name block [int] * Arg: main length of the main block [int] * Arg: ofp output file [FILE *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_write_pretty_seq_align( Wise2_AlnBlock * alb,Wise2_Sequence * q,Wise2_Sequence * t,int name,int main,FILE * ofp); /* Function: Wise2_write_pretty_Protein_align(alb,q,t,name,main,ofp) * * Descrip: This gives an interface into the * alignment display using Protein * objects * * * Arg: alb alignment structure [Wise2_AlnBlock *] * Arg: q first sequence [Wise2_Protein *] * Arg: t second sequence [Wise2_Protein *] * Arg: name length of the name block [int] * Arg: main length of the main block [int] * Arg: ofp output file [FILE *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_write_pretty_Protein_align( Wise2_AlnBlock * alb,Wise2_Protein * q,Wise2_Protein * t,int name,int main,FILE * ofp); wise-2.4.1/src/models/seqaligndisplay_api.t0000644000175000001440000000000010670453715020330 0ustar philippuserswise-2.4.1/src/models/geneloop21.dy0000644000175000001440000004221607530250520016437 0ustar philippusers/* Last edited: Apr 22 11:47 1997 (birney) */ %{ #include "dyna.h" #include "genewisemodel.h" #include "genewisemodeldb.h" %} matrix GeneLoop21 query type="GENEWISEMODEL" name="query" field:len="len" target type="GENOMIC" name="target" resource type="GeneParser21Score *" name="gp21" resource type="RandomCodonScore *" name="rndcodon" resource type="RandomModelDNAScore *" name="rndbase" extern type="int" name="GW_*" extern type="int" name="GP21_*" globaldefaultscore NEGI state MATCH offi="1" offj="3" calc="GENOMIC_CDS_POT(target,j)" source MATCH calc="query->seg[i]->transition[GW_MATCH2MATCH] +query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2MATCH] +query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2MATCH] +query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source RND_CODON offj="3" calc="query->seg[i]->transition[GW_START2MATCH] +query->seg[i]->match[GENOMIC_CODON(target,j)]+ gp21->transition[GP21_RND2MODEL]" endsource source SPACER_0M offi="1" offj="6" target_label 3SS_PHASE_0 calc="gp21->transition[GP21_SPACER2CDS] +query->seg[i]->match[GENOMIC_CODON(target,j)] +GENOMIC_3SS(target,j-3) + query->seg[i]->transition[GW_MATCH_BALANCE_3SS]" endsource source PY_0M offi="1" offj="6" target_label 3SS_PHASE_0 calc="gp21->transition[GP21_PY2CDS] +query->seg[i]->match[GENOMIC_CODON(target,j)] +GENOMIC_3SS(target,j-3) + query->seg[i]->transition[GW_MATCH_BALANCE_3SS]" endsource source SPACER_1M offi="1" offj="5" target_label 3SS_PHASE_1 calc="gp21->transition[GP21_SPACER2CDS] +GENOMIC_3SS(target,j-2)" endsource source PY_1M offi="1" offj="5" target_label 3SS_PHASE_1 calc="gp21->transition[GP21_PY2CDS] +GENOMIC_3SS(target,j-2)" endsource source SPACER_2M offi="1" offj="4" target_label 3SS_PHASE_2 calc="gp21->transition[GP21_SPACER2CDS] +GENOMIC_3SS(target,j-1)" endsource source PY_2M offi="1" offj="4" target_label 3SS_PHASE_2 calc="gp21->transition[GP21_PY2CDS] +GENOMIC_3SS(target,j-1)" endsource source MATCH offi="1" offj="2" target_label SEQUENCE_DELETION calc="gp21->transition[GP21_DELETE_1_BASE]" endsource source MATCH offi="1" offj="1" target_label SEQUENCE_DELETION calc="gp21->transition[GP21_DELETE_2_BASE]" endsource source MATCH offi="1" offj="4" target_label SEQUENCE_INSERTION calc="gp21->transition[GP21_INSERT_1_BASE]" endsource source MATCH offi="1" offj="5" target_label SEQUENCE_INSERTION calc="gp21->transition[GP21_INSERT_2_BASE]" endsource query_label MATCH_STATE target_label CODON endstate state INSERT offi="0" offj="3" calc="GENOMIC_CDS_POT(target,j)" source MATCH calc="query->seg[i]->transition[GW_MATCH2INSERT] +query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2INSERT] +query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2INSERT] +query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source SPACER_0I offi="1" offj="6" target_label 3SS_PHASE_0 calc="gp21->transition[GP21_SPACER2CDS] +query->seg[i]->insert[GENOMIC_CODON(target,j)] +GENOMIC_3SS(target,j-3) + query->seg[i]->transition[GW_MATCH_BALANCE_3SS]" endsource source SPACER_1I offi="1" offj="5" target_label 3SS_PHASE_1 calc="gp21->transition[GP21_SPACER2CDS] +GENOMIC_3SS(target,j-2)" endsource source SPACER_2I offi="1" offj="4" target_label 3SS_PHASE_2 calc="gp21->transition[GP21_SPACER2CDS] +GENOMIC_3SS(target,j-1)" endsource source PY_0I offi="1" offj="6" target_label 3SS_PHASE_0 calc="gp21->transition[GP21_PY2CDS] +query->seg[i]->insert[GENOMIC_CODON(target,j)] +GENOMIC_3SS(target,j-3) + query->seg[i]->transition[GW_MATCH_BALANCE_3SS]" endsource source PY_1I offi="1" offj="5" target_label 3SS_PHASE_1 calc="gp21->transition[GP21_PY2CDS] +GENOMIC_3SS(target,j-2)" endsource source PY_2I offi="1" offj="4" target_label 3SS_PHASE_2 calc="gp21->transition[GP21_PY2CDS] +GENOMIC_3SS(target,j-1)" endsource source INSERT offi="1" offj="2" target_label SEQUENCE_DELETION calc="gp21->transition[GP21_DELETE_1_BASE]" endsource source INSERT offi="1" offj="1" target_label SEQUENCE_DELETION calc="gp21->transition[GP21_DELETE_2_BASE]" endsource source INSERT offi="1" offj="4" target_label SEQUENCE_INSERTION calc="gp21->transition[GP21_INSERT_1_BASE]" endsource source INSERT offi="1" offj="5" target_label SEQUENCE_INSERTION calc="gp21->transition[GP21_INSERT_2_BASE]" endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="query->seg[i]->transition[GW_MATCH2DELETE]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2DELETE]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2DELETE]" endsource query_label DELETE_STATE target_label INSERT endstate # # # state CENTRAL_0M source MATCH offj="8" offi="0" target_label 5SS_PHASE_0 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->transition[GW_MATCH_BALANCE_5SS]" endsource source INSERT offj="8" offi="0" target_label 5SS_PHASE_0 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->transition[GW_INSERT_BALANCE_5SS]" endsource source DELETE offj="8" offi="0" target_label 5SS_PHASE_0 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_DELETE2MATCH]" endsource source CENTRAL_0M offj="1" offi="0" calc="gp21->central[ GENOMIC_BASE(target,j)] +gp21->transition[GP21_CENTRAL2CENTRAL]" endsource query_label INTRON_MATCH_0 target_label CENTRAL_INTRON endstate state PY_0M offj="1" offi="0" calc="gp21->py[GENOMIC_BASE(target,j)]" source CENTRAL_0M calc="gp21->transition[GP21_CENTRAL2PY]" endsource source PY_0M calc="gp21->transition[GP21_PY2PY]" endsource query_label INTRON_MATCH_0 target_label PYRIMIDINE_TRACT endstate state SPACER_0M offj="1" offi="0" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source PY_0M calc="gp21->transition[GP21_PY2SPACER]" endsource source SPACER_0M calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label INTRON_MATCH_0 target_label SPACER endstate state CENTRAL_1M source MATCH offj="9" offi="0" target_label 5SS_PHASE_1 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->transition[GW_MATCH_BALANCE_5SS]" endsource source INSERT offj="9" offi="0" target_label 5SS_PHASE_1 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->transition[GW_MATCH_BALANCE_5SS]" endsource source DELETE offj="9" offi="0" target_label 5SS_PHASE_1 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_DELETE2MATCH]" endsource source CENTRAL_1M offj="1" offi="0" calc="gp21->central[ GENOMIC_BASE(target,j)] +gp21->transition[GP21_CENTRAL2CENTRAL]" endsource query_label INTRON_MATCH_1 target_label CENTRAL_INTRON endstate state PY_1M offj="1" offi="0" calc="gp21->py[GENOMIC_BASE(target,j)]" source CENTRAL_1M calc="gp21->transition[GP21_CENTRAL2PY]" endsource source PY_1M calc="gp21->transition[GP21_PY2PY]" endsource query_label INTRON_MATCH_1 target_label PYRIMIDINE_TRACT endstate state SPACER_1M offj="1" offi="0" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source PY_1M calc="gp21->transition[GP21_PY2SPACER]" endsource source SPACER_1M calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label INTRON_MATCH_1 target_label SPACER endstate state CENTRAL_2M source MATCH offj="10" offi="0" target_label 5SS_PHASE_2 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->transition[GW_MATCH_BALANCE_5SS]" endsource source INSERT offj="10" offi="0" target_label 5SS_PHASE_2 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->transition[GW_MATCH_BALANCE_5SS]" endsource source DELETE offj="10" offi="0" target_label 5SS_PHASE_2 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_DELETE2MATCH]" endsource source CENTRAL_2M offj="1" offi="0" calc="gp21->central[ GENOMIC_BASE(target,j)] +gp21->transition[GP21_CENTRAL2CENTRAL]" endsource query_label INTRON_MATCH_2 target_label CENTRAL_INTRON endstate state PY_2M offj="1" offi="0" calc="gp21->py[GENOMIC_BASE(target,j)]" source CENTRAL_2M calc="gp21->transition[GP21_CENTRAL2PY]" endsource source PY_2M calc="gp21->transition[GP21_PY2PY]" endsource query_label INTRON_MATCH_2 target_label PYRIMIDINE_TRACT endstate state SPACER_2M offj="1" offi="0" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source PY_2M calc="gp21->transition[GP21_PY2SPACER]" endsource source SPACER_2M calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label INTRON_MATCH_2 target_label SPACER endstate # # Insert intron states now # # # state CENTRAL_0I source MATCH offj="8" offi="0" target_label 5SS_PHASE_0 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_MATCH2INSERT] + query->seg[i]->transition[GW_MATCH_BALANCE_5SS]" endsource source INSERT offj="8" offi="0" target_label 5SS_PHASE_0 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_INSERT2INSERT] + query->seg[i]->transition[GW_INSERT_BALANCE_5SS]" endsource source DELETE offj="8" offi="0" target_label 5SS_PHASE_0 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_DELETE2INSERT]" endsource source CENTRAL_0I offj="1" offi="0" calc="gp21->central[ GENOMIC_BASE(target,j)] +gp21->transition[GP21_CENTRAL2CENTRAL]" endsource query_label INTRON_INSERT_0 target_label CENTRAL_INTRON endstate state PY_0I offj="1" offi="0" calc="gp21->py[GENOMIC_BASE(target,j)]" source CENTRAL_0I calc="gp21->transition[GP21_CENTRAL2PY]" endsource source PY_0I calc="gp21->transition[GP21_PY2PY]" endsource query_label INTRON_INSERT_0 target_label PYRIMIDINE_TRACT endstate state SPACER_0I offj="1" offi="0" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source PY_0I calc="gp21->transition[GP21_PY2SPACER]" endsource source SPACER_0I calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label INTRON_INSERT_0 target_label SPACER endstate state CENTRAL_1I source MATCH offj="9" offi="0" target_label 5SS_PHASE_1 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_MATCH2INSERT] " endsource source INSERT offj="9" offi="0" target_label 5SS_PHASE_1 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_INSERT2INSERT] " endsource source DELETE offj="9" offi="0" target_label 5SS_PHASE_1 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_DELETE2INSERT] " endsource source CENTRAL_1I offj="1" offi="0" calc="gp21->central[ GENOMIC_BASE(target,j)] +gp21->transition[GP21_CENTRAL2CENTRAL]" endsource query_label INTRON_INSERT_1 target_label CENTRAL_INTRON endstate state PY_1I offj="1" offi="0" calc="gp21->py[GENOMIC_BASE(target,j)]" source CENTRAL_1I calc="gp21->transition[GP21_CENTRAL2PY]" endsource source PY_1I calc="gp21->transition[GP21_PY2PY]" endsource query_label INTRON_INSERT_1 target_label PYRIMIDINE_TRACT endstate state SPACER_1I offj="1" offi="0" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source PY_1I calc="gp21->transition[GP21_PY2SPACER]" endsource source SPACER_1I calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label INTRON_INSERT_1 target_label SPACER endstate state CENTRAL_2I source MATCH offj="10" offi="0" target_label 5SS_PHASE_2 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_MATCH2INSERT] " endsource source INSERT offj="10" offi="0" target_label 5SS_PHASE_2 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_INSERT2INSERT] " endsource source INSERT offj="10" offi="0" target_label 5SS_PHASE_2 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_DELETE2INSERT] " endsource source CENTRAL_2I offj="1" offi="0" calc="gp21->central[ GENOMIC_BASE(target,j)] +gp21->transition[GP21_CENTRAL2CENTRAL]" endsource query_label INTRON_INSERT_2 target_label CENTRAL_INTRON endstate state PY_2I offj="1" offi="0" calc="gp21->py[GENOMIC_BASE(target,j)]" source CENTRAL_2I calc="gp21->transition[GP21_CENTRAL2PY]" endsource source PY_2I calc="gp21->transition[GP21_PY2PY]" endsource query_label INTRON_INSERT_2 target_label PYRIMIDINE_TRACT endstate state SPACER_2I offj="1" offi="0" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source PY_2I calc="gp21->transition[GP21_PY2SPACER]" endsource source SPACER_2I calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label INTRON_INSERT_2 target_label SPACER endstate state START !special !start defscore="0" endstate state END !special !end source GENOMIC_RND offj="1" !right calc="0" endsource target_label END query_label END endstate state GENOMIC_RND !special source START offj="1" !left calc="rndbase->base[GENOMIC_BASE(target,j)]" endsource source GENOMIC_RND offj="1" calc="rndbase->base[GENOMIC_BASE(target,j)] + gp21->transition[GP21_RND2RND]" endsource source RND_CODON offj="1" calc="rndbase->base[GENOMIC_BASE(target,j)] + gp21->transition[GP21_CDS2RND]" endsource query_label GENOMIC_RND_STATE target_label RANDOM_SEQUENCE endstate state RND_CODON !special offj="3" source GENOMIC_RND calc="rndcodon->codon[GENOMIC_CODON(target,j)] + gp21->transition[GP21_RND2CDS]" endsource source MATCH offj="0" calc="query->seg[i]->transition[GW_MATCH2END]" endsource source INSERT offj="0" calc="query->seg[i]->transition[GW_INSERT2END]" endsource source DELETE offj="0" calc="query->seg[i]->transition[GW_DELETE2END]" endsource source RND_CODON calc="rndcodon->codon[GENOMIC_CODON(target,j)] + gp21->transition[GP21_CDS2CDS]" endsource source RND_SPACER offj="5" calc="gp21->transition[GP21_SPACER2CDS] + rndcodon->codon[GENOMIC_CODON(target,j)] + GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source RND_SPACER offj="4" calc="gp21->transition[GP21_SPACER2CDS] + GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source RND_SPACER offj="3" calc="gp21->transition[GP21_SPACER2CDS] + GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource query_label GENOMIC_RND_STATE target_label CODON endstate state RND_CENTRAL !special source RND_CENTRAL offj="1" calc="gp21->central[GENOMIC_BASE(target,j)] + gp21->transition[GP21_CENTRAL2CENTRAL]" endsource source RND_CODON offj="8" calc="gp21->central[GENOMIC_BASE(target,j)] + GENOMIC_5SS(target,j-7) " target_label 5SS_PHASE_0 endsource source RND_CODON offj="9" calc="gp21->central[GENOMIC_BASE(target,j)] + GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_1 endsource source RND_CODON offj="10" calc="gp21->central[GENOMIC_BASE(target,j)] + GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_2 endsource query_label GENOMIC_RND_STATE target_label CENTRAL_INTRON endstate state RND_PY_TRACT !special offj="1" calc="gp21->py[GENOMIC_BASE(target,j)]" source RND_CENTRAL calc="gp21->transition[GP21_CENTRAL2PY]" endsource source RND_PY_TRACT calc="gp21->transition[GP21_PY2PY]" endsource query_label GENOMIC_RND_STATE target_label PYRIMIDINE_TRACT endstate state RND_SPACER !special offj="1" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source RND_PY_TRACT offj="1" calc="gp21->transition[GP21_PY2SPACER]" endsource source RND_SPACER offj="1" calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label GENOMIC_RND_STATE target_label SPACER endstate # # # collapse GENOMIC_RND_STATE RANDOM_SEQUENCE collapse GENOMIC_RND_STATE CENTRAL_INTRON # # Collapse central states # collapse INTRON_MATCH_0 CENTRAL_INTRON collapse INTRON_MATCH_1 CENTRAL_INTRON collapse INTRON_MATCH_2 CENTRAL_INTRON collapse INTRON_INSERT_0 CENTRAL_INTRON collapse INTRON_INSERT_1 CENTRAL_INTRON collapse INTRON_INSERT_2 CENTRAL_INTRON endmatrix wise-2.4.1/src/models/wise2xhmmer2.dy0000644000175000001440000002264007313404550017022 0ustar philippusers %{ /* include stdio etc */ #include "wisebase.h" /* include hmmer2 files */ /* we have to prevent some namespace clobbering between different versions of histogram */ #ifndef NO_HMMER_INCLUDES #include "structs.h" #include "funcs.h" #endif /* include dynamite files */ /*#include "dyna.h"*/ #include "seqalign.h" #include "threestatemodel.h" #include "threestatedb.h" /* quieten down gcc about struct p7 */ struct plan7_s; %} friend ThreeStateDB friend SeqAlign %{ #include "wise2xhmmer2.h" #ifndef HMMER2_EXTERN_DEFINED #include "globals.h" #endif %func You need to call this function before you call any other to get the HMMer2 system working ;) %% void bootstrap_HMMer2(void) { SetAlphabet(hmmAMINO); } %func This function read a single SeqAlign from the filename using the HMMER libraries %% SeqAlign * read_SeqAlign_HMMER(char * seqfile) { AINFO ainfo; char ** data; int format; SeqAlign * out; int i; Sequence * temp; if (! SeqfileFormat(seqfile, &format, NULL) ) { switch (squid_errno) { case SQERR_NOFILE: warn("Alignment file %s could not be opened for reading", seqfile); return NULL; case SQERR_FORMAT: default: warn("Failed to determine format of alignment file %s", seqfile); } } /* attempt to read it in now */ if (! ReadAlignment(seqfile, format, &data, &ainfo)) { warn("Failed to read aligned sequence file %s", seqfile); return NULL; } /* make SeqAlign */ out = SeqAlign_alloc_len(ainfo.nseq); for (i = 0; i < ainfo.nseq; i++) { temp = new_Sequence_from_strings(ainfo.sqinfo[i].name,data[i]); add_SeqAlign(out,temp); } return out; } %func This function reads a single HMM from filename for a ThreeStateModel %% ThreeStateModel * HMMer2_read_ThreeStateModel(char * filename) { struct plan7_s *hmm; ThreeStateModel * out; HMMFILE * hmmfp; if( filename == NULL ) { warn("You have passed in a NULL filename into HMMer2_read_ThreeStateModel - unlikely to work!"); return NULL; } hmmfp = HMMFileOpen(filename,"HMMERDB"); if( hmmfp == NULL ) { warn("Could not open %s for HMM reading",filename); return NULL; } if( HMMFileRead(hmmfp, &hmm) == 0 ) { return NULL; } if( hmm == NULL ) { warn("Unable to read HMM file... "); return NULL; } out = ThreeStateModel_from_HMMer2(hmm); FreePlan7(hmm); return out; } %func This function makes a new ThreeStateDB from a filename for the HMMer2 system. %arg filename s filename of the HMMer db %% ThreeStateDB * HMMer2_ThreeStateDB(char * filename) { ThreeStateDB * out; out = ThreeStateDB_alloc(); out->dbtype = TSMDB_GENERIC; out->filename = stringalloc(filename); out->reload_generic = reload_ThreeStateDB_HMMer2; out->open_generic = open_ThreeStateDB_HMMer2; out->close_generic = close_ThreeStateDB_HMMer2; out->dataentry_add = dataentry_ThreeStateDB_HMMer2; out->open_index_generic = open_for_indexing_ThreeStateDB_HMMer2; out->close_index_generic = close_for_indexing_ThreeStateDB_HMMer2; out->index_generic = index_ThreeStateDB_HMMer2; return out; } %func This function is the generic wrapper for the threestatedb open for indexing %type internal %% boolean open_for_indexing_ThreeStateDB_HMMer2(ThreeStateDB * tdb) { return TRUE; /* nowt to do ! */ } %func This function is the generic wrapper for the threestatedb open for indexing %type internal %% boolean close_for_indexing_ThreeStateDB_HMMer2(ThreeStateDB * tdb) { return TRUE; /* nowt to do ! */ } #ifdef HMMER_2_1_2 /* new style indexing */ ThreeStateModel * index_ThreeStateDB_HMMer2(ThreeStateDB * tdb,DataEntry *de) { struct plan7_s *hmm; ThreeStateModel * out; HMMFILE * hmmfp; hmmfp = HMMFileOpen(tdb->filename,"HMMERDB"); if( hmmfp == NULL ) { warn("Could not open %s as HMMER file\n",tdb->filename); return NULL; } if( hmmfp->gsi == NULL ) { warn("Could not retrieve sequences from HMMER database as it is not indexed!"); return NULL; } if( ! HMMFilePositionByName(hmmfp,de->name) ) { warn("Unable to find HMM %s in %s",de->name,tdb->filename); return NULL; } if( HMMFileRead(hmmfp, &hmm) == 0 ) { return NULL; } if( hmm == NULL ) { warn("Unable to read HMM file... "); return NULL; } out = ThreeStateModel_from_HMMer2(hmm); FreePlan7(hmm); HMMFileClose(hmmfp); return out; } #else /* use old style indexing */ %func This function is the generic wrapper for the threestatedb get indexed %type internal %% ThreeStateModel* index_ThreeStateDB_HMMer2(ThreeStateDB * tdb,DataEntry *de) { struct plan7_s *hmm; ThreeStateModel * out; HMMFILE * hmmfp; hmmfp = HMMFileOpenFseek(tdb->filename,"HMMERDB",de->byte_position); if( hmmfp == NULL ) { warn("Could not open %s to byte position %d",tdb->filename,de->data[0]); return NULL; } if( HMMFileRead(hmmfp, &hmm) == 0 ) { return NULL; } if( hmm == NULL ) { warn("Unable to read HMM file... "); return NULL; } out = ThreeStateModel_from_HMMer2(hmm); FreePlan7(hmm); HMMFileClose(hmmfp); return out; } #endif /* HMMER_2_1_2 */ %func This function is the generic wrapper for the threestatedb info for hmmer2 %type internal %% boolean dataentry_ThreeStateDB_HMMer2(ThreeStateDB * tdb,DataEntry * en) { HMMFILE * hmmfp; hmmfp = (HMMFILE *) (tdb->data); #ifdef HMMER_2_1_2 en->data[0] = 0; /* we rely on the fact that someone has already set the name */ #else en->data[0] = HMMFtell(hmmfp); en->byte_position = tdb->byte_position; #endif return TRUE; } %func This function is the generic wrapper for the threestatedb close for hmmer2 %type internal %% boolean close_ThreeStateDB_HMMer2(ThreeStateDB * tdb) { HMMFILE * hmmfp; hmmfp = (HMMFILE *) (tdb->data); HMMFileClose(hmmfp); return TRUE; } %func This function is the generic wrapper for the threestatedb relaod function for hmmer2 %type internal %% ThreeStateModel * reload_ThreeStateDB_HMMer2(ThreeStateDB * tdb,int * return_status) { struct plan7_s *hmm; ThreeStateModel * out; HMMFILE * hmmfp; hmmfp = (HMMFILE *) (tdb->data); #ifndef HMMER_2_1_2 tdb->byte_position = HMMFtell(hmmfp); #endif if( HMMFileRead(hmmfp, &hmm) == 0 ) { /* end of file */ *return_status = DB_RETURN_END; return NULL; } if( hmm == NULL ) { warn("Unable to read HMM file... "); *return_status = DB_RETURN_ERROR; } *return_status = DB_RETURN_OK; out = ThreeStateModel_from_HMMer2(hmm); FreePlan7(hmm); return out; } %func This function is the generic wrapper for the threestatedb open function %type internal %% boolean open_ThreeStateDB_HMMer2(ThreeStateDB * tdb) { if( tdb->data != NULL ) { warn("Attempting to open an already open tdb. Ugh!"); return FALSE; } if( (tdb->data = (void *)HMMFileOpen(tdb->filename,"HMMERDB")) == NULL ) { warn("Could not open %s as a filename for hmmer2 directory",tdb->filename); return FALSE; } tdb->byte_position = 0; return TRUE; } %func This function converts a HMMer2 HMM into a Wise2 HMM (threestatemodel). %% ThreeStateModel * ThreeStateModel_from_HMMer2(struct plan7_s * p7) { ThreeStateModel * out; ThreeStateUnit * unit; int i,j; char * runner; if( p7 == NULL ) { warn("Can't make a ThreeStateModel from a NULL pointer... "); return NULL; } out = ThreeStateModel_alloc_len(p7->M); if( out == NULL ) return NULL; /* already complained*/ out->name = stringalloc(p7->name); #ifdef HMMER_2_1_2 if( p7->acc != NULL ) { out->accession = stringalloc(p7->acc); } else { out->accession = stringalloc(p7->name); } #else /* munge around accession number. Ugh! */ if( p7->desc != NULL ) { runner = strtok(p7->desc,spacestr); if( runner != NULL && strstartcmp(runner,"PF") == 0 ) { out->accession = stringalloc(runner); } else { out->accession = stringalloc(p7->name); } } #endif for(i=0;iM;i++) { unit = blank_ThreeStateUnit(); add_ThreeStateModel(out,unit); if( i != p7->M-1) { unit->transition[TSM_MATCH2MATCH]= p7->t[i+1][TMM]; unit->transition[TSM_MATCH2DELETE]= p7->t[i+1][TMD]; unit->transition[TSM_MATCH2INSERT]= p7->t[i+1][TMI]; unit->transition[TSM_INSERT2MATCH]= p7->t[i+1][TIM]; unit->transition[TSM_INSERT2INSERT]= p7->t[i+1][TII]; unit->transition[TSM_DELETE2MATCH]= p7->t[i+1][TDM]; unit->transition[TSM_DELETE2DELETE]= p7->t[i+1][TDD]; unit->transition[TSM_START2MATCH] = p7->begin[i+1]; unit->transition[TSM_MATCH2END] = p7->end[i+1]; } if( i == p7->M-1) { /* all probability onto end */ unit->transition[TSM_MATCH2END] = 1.0; } /* we have to map sean's probabilities over to ours */ for(j=0;jmatch_emission[Alphabet[j]-'A'] = p7->mat[i+1][j]; } if( i != p7->M-1) { for(j=0;jinsert_emission[Alphabet[j]-'A'] = p7->ins[i+1][j]; } } else { /* no insert position! - could leave as 0's? */ /* but this does upset some sensible error tracking code */ /* set it to 1/26 probs ;) */ for(j=0;jinsert_emission[Alphabet[j]-'A'] = p7->ins[1][j]; } } } out->rm = RandomModel_alloc(); for(i=0;i<26;i++) out->rm->aminoacid[i] = 1.0; for(j=0;jrm->aminoacid[Alphabet[j]-'A'] = p7->null[j]; } display_char_in_ThreeStateModel(out); return out; } wise-2.4.1/src/models/genefrequency.pod0000644000175000001440000001672310670453714017507 0ustar philippusers=head1 NAME genefrequency module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item GeneFrequency21 =item GeneConsensus =item GeneSingleCons =back =head1 DESCRIPTION =head2 Object GeneFrequency21 =over =item ss5 Type [GeneConsensus *] Scalar No documentation =item ss3 Type [GeneConsensus *] Scalar No documentation =item codon[64] Type [double] Scalar No documentation =item central[4] Type [double] Scalar No documentation =item py[4] Type [double] Scalar No documentation =item spacer[4] Type [double] Scalar No documentation =item transition[GENEFREQUENCY21_TRANSITION_LEN] Type [double] Scalar No documentation =item cds_triplet[64] Type [double] Scalar phase 0 =back No documentation for GeneFrequency21 =head2 Member functions of GeneFrequency21 =over =item hard_link_GeneFrequency21 &Wise2::GeneFrequency21::hard_link_GeneFrequency21(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [GeneFrequency21 *] Return [UNKN ] Undocumented return value [GeneFrequency21 *] =item alloc &Wise2::GeneFrequency21::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [GeneFrequency21 *] =item set_ss5 &Wise2::GeneFrequency21::set_ss5(obj,ss5) Replace member variable ss5 For use principly by API functions Argument obj [UNKN ] Object holding the variable [GeneFrequency21 *] Argument ss5 [OWNER] New value of the variable [GeneConsensus *] Return [SOFT ] member variable ss5 [boolean] =item ss5 &Wise2::GeneFrequency21::ss5(obj) Access member variable ss5 For use principly by API functions Argument obj [UNKN ] Object holding the variable [GeneFrequency21 *] Return [SOFT ] member variable ss5 [GeneConsensus *] =item set_ss3 &Wise2::GeneFrequency21::set_ss3(obj,ss3) Replace member variable ss3 For use principly by API functions Argument obj [UNKN ] Object holding the variable [GeneFrequency21 *] Argument ss3 [OWNER] New value of the variable [GeneConsensus *] Return [SOFT ] member variable ss3 [boolean] =item ss3 &Wise2::GeneFrequency21::ss3(obj) Access member variable ss3 For use principly by API functions Argument obj [UNKN ] Object holding the variable [GeneFrequency21 *] Return [SOFT ] member variable ss3 [GeneConsensus *] =back =head2 Object GeneConsensus =over =item center Type [int] Scalar No documentation =item gsc Type [GeneSingleCons **] List No documentation =back No documentation for GeneConsensus =head2 Member functions of GeneConsensus =over =item hard_link_GeneConsensus &Wise2::GeneConsensus::hard_link_GeneConsensus(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [GeneConsensus *] Return [UNKN ] Undocumented return value [GeneConsensus *] =item GeneConsensus_alloc_std &Wise2::GeneConsensus::GeneConsensus_alloc_std(void) Equivalent to GeneConsensus_alloc_len(GeneConsensusLISTLENGTH) Return [UNKN ] Undocumented return value [GeneConsensus *] =item set_center &Wise2::GeneConsensus::set_center(obj,center) Replace member variable center For use principly by API functions Argument obj [UNKN ] Object holding the variable [GeneConsensus *] Argument center [OWNER] New value of the variable [int] Return [SOFT ] member variable center [boolean] =item center &Wise2::GeneConsensus::center(obj) Access member variable center For use principly by API functions Argument obj [UNKN ] Object holding the variable [GeneConsensus *] Return [SOFT ] member variable center [int] =item gsc &Wise2::GeneConsensus::gsc(obj,i) Access members stored in the gsc list For use principly by API functions Argument obj [UNKN ] Object holding the list [GeneConsensus *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [GeneSingleCons *] =item length_gsc &Wise2::GeneConsensus::length_gsc(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [GeneConsensus *] Return [UNKN ] length of the list [int] =item flush_gsc &Wise2::GeneConsensus::flush_gsc(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [GeneConsensus *] Return [UNKN ] Undocumented return value [int] =item add_gsc &Wise2::GeneConsensus::add_gsc(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [GeneConsensus *] Argument add [OWNER] Object to add to the list [GeneSingleCons *] Return [UNKN ] Undocumented return value [boolean] =back =head2 Object GeneSingleCons =over =item string Type [char *] Scalar No documentation =item number Type [double] Scalar No documentation =back No documentation for GeneSingleCons =head2 Member functions of GeneSingleCons =over =item hard_link_GeneSingleCons &Wise2::GeneSingleCons::hard_link_GeneSingleCons(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [GeneSingleCons *] Return [UNKN ] Undocumented return value [GeneSingleCons *] =item alloc &Wise2::GeneSingleCons::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [GeneSingleCons *] =item set_string &Wise2::GeneSingleCons::set_string(obj,string) Replace member variable string For use principly by API functions Argument obj [UNKN ] Object holding the variable [GeneSingleCons *] Argument string [OWNER] New value of the variable [char *] Return [SOFT ] member variable string [boolean] =item string &Wise2::GeneSingleCons::string(obj) Access member variable string For use principly by API functions Argument obj [UNKN ] Object holding the variable [GeneSingleCons *] Return [SOFT ] member variable string [char *] =item set_number &Wise2::GeneSingleCons::set_number(obj,number) Replace member variable number For use principly by API functions Argument obj [UNKN ] Object holding the variable [GeneSingleCons *] Argument number [OWNER] New value of the variable [double] Return [SOFT ] member variable number [boolean] =item number &Wise2::GeneSingleCons::number(obj) Access member variable number For use principly by API functions Argument obj [UNKN ] Object holding the variable [GeneSingleCons *] Return [SOFT ] member variable number [double] =back =over =item read_GeneFrequency21_file &Wise2::read_GeneFrequency21_file(filename) Opens the file with /openfile Reads in a GeneFrequency (Mor-Ewan style) Argument filename [UNKN ] will open from WISECONFIGDIR etc via openfile [char *] Return [UNKN ] a newly allocated structure [GeneFrequency21 *] =item read_GeneFrequency21 &Wise2::read_GeneFrequency21(ifp) Reads in a GeneFrequency (Mor-Ewan style) file from ifp Argument ifp [UNKN ] file pointer [FILE *] Return [UNKN ] a newly allocated structure [GeneFrequency21 *] =back wise-2.4.1/src/models/genefrequency.tex0000644000175000001440000000544310670453714017522 0ustar philippusers\section{genefrequency} \label{module_genefrequency} This module contains the following objects \begin{itemize} \item \ref{object_GeneFrequency21} GeneFrequency21 \item \ref{object_GeneConsensus} GeneConsensus \item \ref{object_GeneSingleCons} GeneSingleCons \item This module also contains some factory methods \end{itemize} \subsection{genefrequency factory methods} \subsubsection{read_GeneFrequency21_file} \begin{description} \item[External C] {\tt Wise2_read_GeneFrequency21_file (filename)} \item[Perl] {\tt &Wise2::read_GeneFrequency21_file (filename)} \end{description} Arguments \begin{description} \item[filename] [UNKN ] will open from WISECONFIGDIR etc via openfile [char *] \item[returns] [UNKN ] a newly allocated structure [GeneFrequency21 *] \end{description} Opens the file with /openfile Reads in a GeneFrequency (Mor-Ewan style) \subsubsection{read_GeneFrequency21} \begin{description} \item[External C] {\tt Wise2_read_GeneFrequency21 (ifp)} \item[Perl] {\tt &Wise2::read_GeneFrequency21 (ifp)} \end{description} Arguments \begin{description} \item[ifp] [UNKN ] file pointer [FILE *] \item[returns] [UNKN ] a newly allocated structure [GeneFrequency21 *] \end{description} Reads in a GeneFrequency (Mor-Ewan style) file from ifp \subsection{Object GeneFrequency21} \label{object_GeneFrequency21} The GeneFrequency21 object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{ss5} Type [GeneConsensus * : Scalar] No documentation \item{ss3} Type [GeneConsensus * : Scalar] No documentation \item{codon[64]} Type [double : Scalar] No documentation \item{central[4]} Type [double : Scalar] No documentation \item{py[4]} Type [double : Scalar] No documentation \item{spacer[4]} Type [double : Scalar] No documentation \item{transition[GENEFREQUENCY21_TRANSITION_LEN]} Type [double : Scalar] No documentation \item{cds_triplet[64]} Type [double : Scalar] phase 0 \end{description} No documentation for GeneFrequency21 Member functions of GeneFrequency21 \subsection{Object GeneConsensus} \label{object_GeneConsensus} The GeneConsensus object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{center} Type [int : Scalar] No documentation \item{gsc} Type [GeneSingleCons ** : List] No documentation \end{description} No documentation for GeneConsensus Member functions of GeneConsensus \subsection{Object GeneSingleCons} \label{object_GeneSingleCons} The GeneSingleCons object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{string} Type [char * : Scalar] No documentation \item{number} Type [double : Scalar] No documentation \end{description} No documentation for GeneSingleCons Member functions of GeneSingleCons wise-2.4.1/src/models/genewise4.c0000644000175000001440000075444710670453714016215 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genewise4.h" # line 6 "genewise4.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define INTRON 3 #define START 0 #define END 1 #define GeneWise4_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+10)*4)+STATE][i+1] #define GeneWise4_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+10] #define GeneWise4_READ_OFF_ERROR -12 #define GeneWise4_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+11)%11][((i+1)*4)+STATE] #define GeneWise4_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+11)%11][STATE] #define GeneWise4_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define GeneWise4_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_GeneWise4(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_GeneWise4(GeneWise4 * mat) { GeneWise4_access_func_holder holder; holder.access_main = GeneWise4_shatter_access_main; holder.access_special = GeneWise4_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_GeneWise4(mat,holder); } /* Function: GeneWise4_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneWise4_shatter_access_main(GeneWise4 * mat,int i,int j,int state) { return GeneWise4_SHATTER_MATRIX(mat,i,j,state); } /* Function: GeneWise4_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneWise4_shatter_access_special(GeneWise4 * mat,int i,int j,int state) { return GeneWise4_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_GeneWise4(mat,dpenv) * * Descrip: This function calculates the GeneWise4 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneWise4 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_GeneWise4(GeneWise4 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_6; int * SIG_1_5; int * SIG_1_4; int * SIG_1_2; int * SIG_0_3; int * SIG_0_6; int * SIG_0_5; int * SIG_0_4; int * SIG_0_2; int * SIG_0_1; int * SIG_1_0; int * SIG_0_8; int * SIG_0_9; int * SIG_0_10; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,4,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("GeneWise4 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-6); SIG_1_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-5); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-6); SIG_0_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-5); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); SIG_0_8 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-8); SIG_0_9 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-9); SIG_0_10 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-10); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneWise4_SHATTER_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = SIG_1_6[INTRON] + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = SIG_1_5[INTRON] + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = SIG_1_4[INTRON] + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_4[MATCH] + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise4_SHATTER_SPECIAL(mat,i,j,END) ) { GeneWise4_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneWise4_SHATTER_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = SIG_0_6[INTRON] + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = SIG_0_5[INTRON] + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = SIG_0_4[INTRON] + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_2[INSERT] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[INSERT] = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneWise4_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* Finished calculating state DELETE */ /* For state INTRON */ /* setting first movement to score */ score = SIG_0_8[MATCH] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state INTRON */ temp = SIG_0_8[INSERT] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state MATCH to state INTRON */ temp = SIG_0_9[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INSERT to state INTRON */ temp = SIG_0_9[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state MATCH to state INTRON */ temp = SIG_0_10[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INSERT to state INTRON */ temp = SIG_0_10[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON to state INTRON */ temp = SIG_0_1[INTRON] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON */ /* Add any movement independant score and put away */ SIG_0_0[INTRON] = score; /* Finished calculating state INTRON */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_GeneWise4(dbsi,out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneWise4 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_GeneWise4(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_GeneWise4 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_GeneWise4. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_GeneWise4. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for GeneWise4, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_GeneWise4(out,querydb, targetdb ,gp); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_GeneWise4 *) ckalloc(sizeof(struct thread_pool_holder_GeneWise4)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->gp = gp; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_GeneWise4,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for GeneWise4"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from GeneWise4",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_GeneWise4(ptr) * * Descrip: Infinite loop code foreach thread for GeneWise4 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_GeneWise4(void * ptr) { struct thread_pool_holder_GeneWise4 * holder; int db_status; int score; DataScore * ds; GeneWiseScore* query; ComplexSequence* target; holder = (struct thread_pool_holder_GeneWise4 *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneWise4"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneWise4"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_GeneWiseDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in GeneWise4 search"); } query = hard_link_GeneWiseScore(holder->query); /* get query information into datascore */ dataentry_add_GeneWiseDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_GenomicDB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_GenomicDB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching GeneWise4, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_GenomicDB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_GeneWiseScore(holder->query); /* get the next query object for the next thread */ holder->query = reload_GeneWiseDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching GeneWise4, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_GeneWiseDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneWise4"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneWise4"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_GenomicDB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_GeneWise4(query, target ,holder->gp); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for GeneWise4"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for GeneWise4"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneWise4"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_GeneWiseScore(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneWise4"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_GeneWise4(out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneWise4 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_GeneWise4(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp) { GeneWiseScore* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GeneWiseDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneWise4, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_GenomicDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneWise4, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_GeneWise4(query, target , gp); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("GeneWise4 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GeneWiseDB(ds->query,query,querydb); dataentry_add_GenomicDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_GenomicDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneWise4, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_GenomicDB(target,targetdb); query = reload_GeneWiseDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching GeneWise4, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GeneWiseDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_GeneWise4(query,target,gp) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_GeneWise4_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_GeneWise4(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp) { int bestscore = NEGI; int i; int j; int k; GeneWise4 * mat; mat = allocate_GeneWise4_only(query, target , gp); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(11,(mat->leni + 1) * 4,11,2)) == NULL) { warn("Score only matrix for GeneWise4 cannot be allocated, (asking for 10 by %d cells)",mat->leni*4); mat = free_GeneWise4(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<12;j++) { for(i=(-1);ileni;i++) { for(k=0;k<4;k++) GeneWise4_VSMALL_MATRIX(mat,i,j,k) = NEGI; } GeneWise4_VSMALL_SPECIAL(mat,i,j,START) = 0; GeneWise4_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = GeneWise4_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise4_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise4_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneWise4_VSMALL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_VSMALL_MATRIX(mat,i-1,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_VSMALL_MATRIX(mat,i-1,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_VSMALL_MATRIX(mat,i-1,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise4_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise4_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise4_VSMALL_SPECIAL(mat,i,j,END) ) { GeneWise4_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise4_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise4_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise4_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneWise4_VSMALL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_VSMALL_MATRIX(mat,i-0,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_VSMALL_MATRIX(mat,i-0,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_VSMALL_MATRIX(mat,i-0,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise4_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise4_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise4_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise4_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise4_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneWise4_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise4_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON */ /* setting first movement to score */ score = GeneWise4_VSMALL_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state INTRON */ temp = GeneWise4_VSMALL_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state MATCH to state INTRON */ temp = GeneWise4_VSMALL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INSERT to state INTRON */ temp = GeneWise4_VSMALL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state MATCH to state INTRON */ temp = GeneWise4_VSMALL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INSERT to state INTRON */ temp = GeneWise4_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON to state INTRON */ temp = GeneWise4_VSMALL_MATRIX(mat,i-0,j-1,INTRON) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON */ /* Add any movement independant score and put away */ GeneWise4_VSMALL_MATRIX(mat,i,j,INTRON) = score; /* Finished calculating state INTRON */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < GeneWise4_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = GeneWise4_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_GeneWise4(mat); return bestscore; } /* Function: PackAln_bestmemory_GeneWise4(query,target,gp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneWise4 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_GeneWise4(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; GeneWise4 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 4 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_GeneWise4(query, target , gp,dpri)) == NULL ) { warn("Unable to allocate large GeneWise4 version"); return NULL; } calculate_dpenv_GeneWise4(mat,dpenv); out = PackAln_read_Expl_GeneWise4(mat); } else { mat = allocate_GeneWise4_only(query, target , gp); calculate_shatter_GeneWise4(mat,dpenv); out = PackAln_read_Shatter_GeneWise4(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_GeneWise4(query, target , gp)) == NULL ) { warn("Unable to allocate small GeneWise4 version"); return NULL; } out = PackAln_calculate_Small_GeneWise4(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_GeneWise4(query, target , gp,dpri)) == NULL ) { warn("Unable to allocate large GeneWise4 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_GeneWise4(mat); out = PackAln_read_Expl_GeneWise4(mat); } } } mat = free_GeneWise4(mat); return out; } /* Function: allocate_GeneWise4_only(query,target,gp) * * Descrip: This function only allocates the GeneWise4 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneWise4 *] * */ GeneWise4 * allocate_GeneWise4_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp) { GeneWise4 * out; if((out= GeneWise4_alloc()) == NULL) { warn("Allocation of basic GeneWise4 structure failed..."); return NULL; } out->query = query; out->target = target; out->gp = gp; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_GeneWise4(query,target,gp,dpri) * * Descrip: This function allocates the GeneWise4 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneWise4_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneWise4 *] * */ GeneWise4 * allocate_Expl_GeneWise4(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPRunImpl * dpri) { GeneWise4 * out; out = allocate_GeneWise4_only(query, target , gp); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+10)*4 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+10)*4,(out->leni+1),2,out->lenj+10)) == NULL) { warn("Explicit matrix GeneWise4 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_GeneWise4(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_GeneWise4(out); return out; } /* Function: init_GeneWise4(mat) * * Descrip: This function initates GeneWise4 matrix when in explicit mode * Called in /allocate_Expl_GeneWise4 * * * Arg: mat [UNKN ] GeneWise4 which contains explicit basematrix memory [GeneWise4 *] * */ void init_GeneWise4(GeneWise4 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-10);j<11;j++) { GeneWise4_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise4_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise4_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise4_EXPL_MATRIX(mat,i,j,INTRON) = NEGI; } } for(j= (-10);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { GeneWise4_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise4_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise4_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise4_EXPL_MATRIX(mat,i,j,INTRON) = NEGI; } GeneWise4_EXPL_SPECIAL(mat,i,j,START) = 0; GeneWise4_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_GeneWise4(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneWise4 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * */ void recalculate_PackAln_GeneWise4(PackAln * pal,GeneWise4 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (START+4) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == INTRON ) { pau->score = ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == INTRON ) { pau->score = ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == INTRON ) { pau->score = ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_INSERT_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (START+4) ) { pau->score = (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 6 && prev->state == INTRON ) { pau->score = ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 5 && prev->state == INTRON ) { pau->score = ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 4 && prev->state == INTRON ) { pau->score = ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->seg[i]->transition[GW_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (START+4) ) { pau->score = mat->query->seg[i]->transition[GW_START2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON : if( offi == 0 && offj == 8 && prev->state == MATCH ) { pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == INSERT ) { pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+4) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+4) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define GeneWise4_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+10)][(i+1)*4+state]) #define GeneWise4_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+11)*8) % 88][(i+1)*4+state]) #define GeneWise4_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+10)]) #define GeneWise4_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) #define GeneWise4_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+11)*8)+(shadow+1)) % 88)][(i+1)*4 + state]) #define GeneWise4_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) #define GeneWise4_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+10)% 10) * (leni+1) * 4) + ((i+1) * 4) + (state)]) #define GeneWise4_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+10)% 10) * (leni+1) * 32) + ((i+1) * 32) + (state * 8) + shadow+1]) #define GeneWise4_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) /* Function: allocate_Small_GeneWise4(query,target,gp) * * Descrip: This function allocates the GeneWise4 structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneWise4_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneWise4 *] * */ #define GeneWise4_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) GeneWise4 * allocate_Small_GeneWise4(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp) { GeneWise4 * out; out = allocate_GeneWise4_only(query, target , gp); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(88,(out->leni + 1) * 4,16,out->lenj+10); if(out == NULL) { warn("Small shadow matrix GeneWise4 cannot be allocated, (asking for 11 by %d main cells)",out->leni+2); free_GeneWise4(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_GeneWise4(mat,dpenv) * * Descrip: This function calculates an alignment for GeneWise4 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneWise4 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneWise4 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_GeneWise4(GeneWise4 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for GeneWise4 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneWise4(mat,dpenv); score = start_end_find_end_GeneWise4(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_GeneWise4(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_GeneWise4(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == GeneWise4_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_GeneWise4(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 4; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_GeneWise4(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_GeneWise4(mat) * * Descrip: This function calculates an alignment for GeneWise4 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneWise4 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneWise4 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneWise4 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_GeneWise4(GeneWise4 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneWise4(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_GeneWise4(mat); return out; } /* Function: AlnRangeSet_from_GeneWise4(mat) * * Descrip: This function reads off a start/end structure * for GeneWise4 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneWise4 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneWise4 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_GeneWise4(GeneWise4 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneWise4"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_GeneWise4(mat,&jpos); state = END; while( (temp = AlnRange_build_GeneWise4(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_GeneWise4(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_GeneWise4 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_GeneWise4(GeneWise4 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneWise4"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_GeneWise4(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_GeneWise4 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = GeneWise4_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_GeneWise4(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == GeneWise4_READ_OFF_ERROR) { warn("In AlnRange_build_GeneWise4 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = GeneWise4_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_GeneWise4(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_GeneWise4(GeneWise4 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_GeneWise4(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneWise4_READ_OFF_ERROR) { warn("In GeneWise4 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In GeneWise4 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In GeneWise4 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_GeneWise4(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_GeneWise4(GeneWise4 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneWise4_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneWise4 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = GeneWise4_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp->transition[GP4_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-1,j-4,MATCH); } return GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON) ) { *reti = i - 1; *retj = j - 4; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-1,j-4,INTRON); } return GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON) ) { *reti = i - 1; *retj = j - 5; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-1,j-5,INTRON); } return GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON); } temp = cscore - (((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON) ) { *reti = i - 1; *retj = j - 6; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-1,j-6,INTRON); } return GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneWise4 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-4,INTRON); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-5,INTRON); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON); } temp = cscore - (((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-6,INTRON); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-3,DELETE); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneWise4 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return GeneWise4_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneWise4 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-1,INTRON); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-10,INSERT); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-10,MATCH); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-9,INSERT); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-9,MATCH); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS])) - (0); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-8,INSERT); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_HIDDEN_MATRIX(mat,i-0,j-8,MATCH); } return GeneWise4_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneWise4 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneWise4 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_GeneWise4(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_GeneWise4(GeneWise4 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > GeneWise4_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 4; add_PackAln(out,pau); } max_special_strip_GeneWise4(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneWise4_READ_OFF_ERROR) { warn("In special strip read GeneWise4, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < GeneWise4_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read GeneWise4, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 4; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_GeneWise4(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_GeneWise4(GeneWise4 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = GeneWise4_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for GeneWise4, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In GeneWise4 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = GeneWise4_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source MATCH is not a special */ default: warn("Major problem (!) - in GeneWise4 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_GeneWise4(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_GeneWise4(GeneWise4 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = GeneWise4_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In GeneWise4 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source INTRON is not a special, should not get here! */ /* Source INTRON is not a special, should not get here! */ /* Source INTRON is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_DC_SHADOW_SPECIAL(mat,i-1,j-3,START); } return GeneWise4_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise4 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INTRON is not a special, should not get here! */ /* Source INTRON is not a special, should not get here! */ /* Source INTRON is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise4_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_DC_SHADOW_SPECIAL(mat,i-0,j-3,START); } return GeneWise4_DC_SHADOW_MATRIX(mat,i - 0,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise4 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == GeneWise4_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise4_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return GeneWise4_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise4 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON : /* Source INTRON is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise4 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneWise4 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_GeneWise4(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_GeneWise4(GeneWise4 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_GeneWise4(mat,starti,startj,stopi,stopj); GeneWise4_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneWise4_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise4_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise4_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise4_HIDDEN_MATRIX(mat,i,j,INTRON) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = GeneWise4_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-1,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-1,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-1,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise4_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise4_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON */ /* setting first movement to score */ score = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state INTRON */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state MATCH to state INTRON */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INSERT to state INTRON */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state MATCH to state INTRON */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INSERT to state INTRON */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON to state INTRON */ temp = GeneWise4_HIDDEN_MATRIX(mat,i-0,j-1,INTRON) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON */ /* Add any movement independant score and put away */ GeneWise4_HIDDEN_MATRIX(mat,i,j,INTRON) = score; /* Finished calculating state INTRON */ } } return; } /* Function: init_hidden_GeneWise4(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_GeneWise4(GeneWise4 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-10);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { GeneWise4_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise4_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise4_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise4_HIDDEN_MATRIX(mat,i,j,INTRON) = NEGI; } } return; } /* Function: full_dc_GeneWise4(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_GeneWise4 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_GeneWise4 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [GeneWise4 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_GeneWise4(GeneWise4 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_GeneWise4"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 50) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_GeneWise4(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_GeneWise4(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_GeneWise4(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for GeneWise4, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= GeneWise4_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= GeneWise4_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = GeneWise4_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_GeneWise4(mat,GeneWise4_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),GeneWise4_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),GeneWise4_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_GeneWise4(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_GeneWise4(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_GeneWise4(GeneWise4 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_GeneWise4(mat); GeneWise4_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_GeneWise4(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_GeneWise4(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_GeneWise4(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_GeneWise4(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_GeneWise4(GeneWise4 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<10;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneWise4_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); GeneWise4_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INTRON) = NEGI; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,0) = (-100); GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-6; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-6; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ GeneWise4_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ /* For state INTRON, pushing when j - offj <= mergej */ score = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( j - 8 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,1) = j-8; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,2) = MATCH; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,5) = INTRON; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score) { score = temp; if( j - 8 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,1) = j-8; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,2) = INSERT; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,5) = INTRON; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 9 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,1) = j-9; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,2) = MATCH; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,5) = INTRON; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 9 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,1) = j-9; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,2) = INSERT; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,5) = INTRON; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 10 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,1) = j-10; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,2) = MATCH; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,5) = INTRON; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 10 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,1) = j-10; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,2) = INSERT; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,5) = INTRON; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } } temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,0) = i-0; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,1) = j-1; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,2) = INTRON; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,3) = i; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,4) = j; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,5) = INTRON; } else { for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,k) = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON,k); } } /* Add any movement independant score */ GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INTRON) = score; /* Finished with state INTRON */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_GeneWise4(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_GeneWise4(GeneWise4 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneWise4_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise4_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INTRON) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state INTRON to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON,k); } /* From state INTRON to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON,k); } /* From state INTRON to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON,k); } /* From state MATCH to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state DELETE to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } /* From state INTRON to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON,k); } /* From state INTRON to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON,k); } /* From state INTRON to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON,k); } /* From state INSERT to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise4_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state INTRON */ /* setting first movement to score */ score = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); /* From state INSERT to state INTRON */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } /* From state MATCH to state INTRON */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); } /* From state INSERT to state INTRON */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } /* From state MATCH to state INTRON */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); } /* From state INSERT to state INTRON */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } /* From state INTRON to state INTRON */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise4_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON,k); } /* Ok - finished max calculation for INTRON */ /* Add any movement independant score and put away */ GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INTRON) = score; for(k=0;k<7;k++) GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_GeneWise4(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_GeneWise4(GeneWise4 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneWise4_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise4_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INTRON) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise4_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON */ /* setting first movement to score */ score = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state INTRON */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state MATCH to state INTRON */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INSERT to state INTRON */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state MATCH to state INTRON */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INSERT to state INTRON */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON to state INTRON */ temp = GeneWise4_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON */ /* Add any movement independant score and put away */ GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INTRON) = score; /* Finished calculating state INTRON */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_GeneWise4(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * */ } void init_dc_GeneWise4(GeneWise4 * mat) { register int i; register int j; register int k; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GeneWise4_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise4_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INTRON) = NEGI; for(k=0;k<7;k++) { GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,k) = (-1); } } } return; } /* Function: start_end_find_end_GeneWise4(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [GeneWise4 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_GeneWise4(GeneWise4 * mat,int * endj) { register int j; register int max; register int maxj; max = GeneWise4_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( GeneWise4_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = GeneWise4_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_GeneWise4(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [GeneWise4] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_GeneWise4(GeneWise4 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (10 * (leni + 1) * 4,sizeof(int)); shadow_pointers = (int *) calloc (10 * (leni + 1) * 4 * 8,sizeof(int)); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state START to state MATCH */ temp = GeneWise4_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON to state MATCH */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON,0)); } /* From state INTRON to state MATCH */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON,0)); } /* From state INTRON to state MATCH */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON,0)); } /* From state MATCH to state MATCH */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise4_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { GeneWise4_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneWise4_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); GeneWise4_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); GeneWise4_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; GeneWise4_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; GeneWise4_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state DELETE to state INSERT */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0)); } /* From state START to state INSERT */ temp = GeneWise4_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [START] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON to state INSERT */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON,0)); } /* From state INTRON to state INSERT */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON,0)); } /* From state INTRON to state INSERT */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON,0)); } /* From state INSERT to state INSERT */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state START to state DELETE */ temp = GeneWise4_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state INTRON */ /* setting first movement to score */ score = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,0)); /* From state INSERT to state INTRON */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,0)); } /* From state MATCH to state INTRON */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,0)); } /* From state INSERT to state INTRON */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,0)); } /* From state MATCH to state INTRON */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,0)); } /* From state INSERT to state INTRON */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0)); } /* From state INTRON to state INTRON */ temp = GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON,0)); } /* Ok - finished max calculation for INTRON */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise4_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON) = score; for(k=0;k<7;k++) GeneWise4_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_GeneWise4(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * */ void init_start_end_linear_GeneWise4(GeneWise4 * mat) { register int i; register int j; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GeneWise4_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); GeneWise4_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); GeneWise4_DC_SHADOW_MATRIX(mat,i,j,INTRON) = NEGI; GeneWise4_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON,0) = (-1); } } for(j=(-10);jtarget->seq->len;j++) { GeneWise4_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; GeneWise4_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; GeneWise4_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_GeneWise4(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_GeneWise4(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_GeneWise4(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","INTRON_STATE","END" }; /* Function: AlnConvertSet_GeneWise4(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","5SS_PHASE_0","5SS_PHASE_1","5SS_PHASE_2","CENTRAL_INTRON","END" }; AlnConvertSet * AlnConvertSet_GeneWise4(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 4; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON; acu->state2 = MATCH; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 4; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON; acu->state2 = INSERT; acu->offi = 0; acu->offj = 6; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 4; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON; acu->state2 = INTRON; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 4; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[11]; add_collapse_label_AlnConvertSet(out,"INTRON_STATE","CENTRAL_INTRON"); return out; } /* Function: PackAln_read_Expl_GeneWise4(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_GeneWise4(GeneWise4 * mat) { GeneWise4_access_func_holder holder; holder.access_main = GeneWise4_explicit_access_main; holder.access_special = GeneWise4_explicit_access_special; return PackAln_read_generic_GeneWise4(mat,holder); } /* Function: GeneWise4_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneWise4_explicit_access_main(GeneWise4 * mat,int i,int j,int state) { return GeneWise4_EXPL_MATRIX(mat,i,j,state); } /* Function: GeneWise4_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneWise4_explicit_access_special(GeneWise4 * mat,int i,int j,int state) { return GeneWise4_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_GeneWise4(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: h [UNKN ] Undocumented argument [GeneWise4_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_GeneWise4(GeneWise4 * mat,GeneWise4_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_GeneWise4(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in GeneWise4_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 4; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_GeneWise4(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_GeneWise4(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == GeneWise4_READ_OFF_ERROR || j == GeneWise4_READ_OFF_ERROR || state == GeneWise4_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in GeneWise4_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 4; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_GeneWise4(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [GeneWise4_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_GeneWise4(GeneWise4 * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneWise4_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: GeneWise4_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void GeneWise4_debug_show_matrix(GeneWise4 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",GeneWise4_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",GeneWise4_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",GeneWise4_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"State INTRON %d\n",GeneWise4_EXPL_MATRIX(mat,i,j,INTRON)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_GeneWise4(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneWise4_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_GeneWise4(GeneWise4 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneWise4_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneWise4_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneWise4 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp->transition[GP4_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH); } return (*h.access_main)(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,INTRON) ) { *reti = i - 1; *retj = j - 4; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,INTRON); } return (*h.access_main)(mat,i - 1,j - 4,INTRON); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,INTRON) ) { *reti = i - 1; *retj = j - 5; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,INTRON); } return (*h.access_main)(mat,i - 1,j - 5,INTRON); } temp = cscore - (((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,INTRON) ) { *reti = i - 1; *retj = j - 6; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,INTRON); } return (*h.access_main)(mat,i - 1,j - 6,INTRON); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START); } return (*h.access_main)(mat,i - 1,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneWise4 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 4,INTRON) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INTRON); } return (*h.access_main)(mat,i - 0,j - 4,INTRON); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 5,INTRON) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,INTRON); } return (*h.access_main)(mat,i - 0,j - 5,INTRON); } temp = cscore - (((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 6,INTRON) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-6,INTRON); } return (*h.access_main)(mat,i - 0,j - 6,INTRON); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,START); } return (*h.access_main)(mat,i - 0,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE); } return (*h.access_main)(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneWise4 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneWise4 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON); } return (*h.access_main)(mat,i - 0,j - 1,INTRON); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT); } return (*h.access_main)(mat,i - 0,j - 10,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,MATCH); } return (*h.access_main)(mat,i - 0,j - 10,MATCH); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,INSERT); } return (*h.access_main)(mat,i - 0,j - 9,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,MATCH); } return (*h.access_main)(mat,i - 0,j - 9,MATCH); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,INSERT); } return (*h.access_main)(mat,i - 0,j - 8,INSERT); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,MATCH); } return (*h.access_main)(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneWise4 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneWise4 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_GeneWise4(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneWise4_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_GeneWise4(GeneWise4 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneWise4_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneWise4_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In GeneWise4 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in GeneWise4 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_GeneWise4(mat) * * Descrip: This function calculates the GeneWise4 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneWise4 * * * Arg: mat [UNKN ] GeneWise4 which contains explicit basematrix memory [GeneWise4 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_GeneWise4(GeneWise4 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneWise4, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("GeneWise4 Matrix calculation: "); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneWise4_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise4_EXPL_SPECIAL(mat,i,j,END) ) { GeneWise4_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise4_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneWise4_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise4_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneWise4_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise4_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON */ /* setting first movement to score */ score = GeneWise4_EXPL_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state INTRON */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state MATCH to state INTRON */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INSERT to state INTRON */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state MATCH to state INTRON */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INSERT to state INTRON */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON to state INTRON */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-1,INTRON) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON */ /* Add any movement independant score and put away */ GeneWise4_EXPL_MATRIX(mat,i,j,INTRON) = score; /* Finished calculating state INTRON */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_GeneWise4(mat,dpenv) * * Descrip: This function calculates the GeneWise4 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneWise4 which contains explicit basematrix memory [GeneWise4 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_GeneWise4(GeneWise4 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneWise4, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-10;jleni;i++) { GeneWise4_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise4_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise4_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise4_EXPL_MATRIX(mat,i,j,INTRON) = NEGI; } } for(j=-10;jlenj;j++) { GeneWise4_EXPL_SPECIAL(mat,i,j,START) = 0; GeneWise4_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("GeneWise4 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { GeneWise4_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise4_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise4_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise4_EXPL_MATRIX(mat,i,j,INTRON) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = GeneWise4_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneWise4_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise4_EXPL_SPECIAL(mat,i,j,END) ) { GeneWise4_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise4_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneWise4_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-6,INTRON) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-5,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-4,INTRON) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise4_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise4_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise4_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneWise4_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise4_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON */ /* setting first movement to score */ score = GeneWise4_EXPL_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state INTRON */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state MATCH to state INTRON */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INSERT to state INTRON */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state MATCH to state INTRON */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INSERT to state INTRON */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON to state INTRON */ temp = GeneWise4_EXPL_MATRIX(mat,i-0,j-1,INTRON) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON */ /* Add any movement independant score and put away */ GeneWise4_EXPL_MATRIX(mat,i,j,INTRON) = score; /* Finished calculating state INTRON */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: GeneWise4_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWise4 *] * */ GeneWise4 * GeneWise4_alloc(void) { GeneWise4 * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWise4 *) ckalloc (sizeof(GeneWise4))) == NULL) { warn("GeneWise4_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_GeneWise4(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWise4 *] * * Return [UNKN ] Undocumented return value [GeneWise4 *] * */ GeneWise4 * free_GeneWise4(GeneWise4 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneWise4 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->gp is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/genewise4.h0000644000175000001440000004465410670453714016212 0ustar philippusers#ifndef DYNAMITEgenewise4HEADERFILE #define DYNAMITEgenewise4HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "geneparser4.h" #include "genewisemodel.h" #include "genewisemodeldb.h" struct Wise2_GeneWise4 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GeneWiseScore* query; ComplexSequence* target; GeneParser4Score * gp; } ; /* GeneWise4 defined */ #ifndef DYNAMITE_DEFINED_GeneWise4 typedef struct Wise2_GeneWise4 Wise2_GeneWise4; #define GeneWise4 Wise2_GeneWise4 #define DYNAMITE_DEFINED_GeneWise4 #endif #ifdef PTHREAD struct thread_pool_holder_GeneWise4 { GeneWiseScore* query; /* Query object placeholder */ GeneWiseDB* querydb;/* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ GenomicDB* targetdb;/* Target database object */ boolean target_init; GeneParser4Score * gp; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_GeneWise4_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(GeneWise4*,int,int,int); int (*access_special)(GeneWise4*,int,int,int); } ; /* GeneWise4_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_GeneWise4_access_func_holder typedef struct Wise2_GeneWise4_access_func_holder Wise2_GeneWise4_access_func_holder; #define GeneWise4_access_func_holder Wise2_GeneWise4_access_func_holder #define DYNAMITE_DEFINED_GeneWise4_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_GeneWise4(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_GeneWise4(GeneWise4 * mat); #define PackAln_read_Shatter_GeneWise4 Wise2_PackAln_read_Shatter_GeneWise4 /* Function: calculate_shatter_GeneWise4(mat,dpenv) * * Descrip: This function calculates the GeneWise4 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneWise4 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_GeneWise4(GeneWise4 * mat,DPEnvelope * dpenv); #define calculate_shatter_GeneWise4 Wise2_calculate_shatter_GeneWise4 /* Function: search_GeneWise4(dbsi,out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneWise4 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_GeneWise4(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp); #define search_GeneWise4 Wise2_search_GeneWise4 /* Function: serial_search_GeneWise4(out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneWise4 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_GeneWise4(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp); #define serial_search_GeneWise4 Wise2_serial_search_GeneWise4 /* Function: PackAln_bestmemory_GeneWise4(query,target,gp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneWise4 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_GeneWise4(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_GeneWise4 Wise2_PackAln_bestmemory_GeneWise4 /* Function: allocate_Expl_GeneWise4(query,target,gp,dpri) * * Descrip: This function allocates the GeneWise4 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneWise4_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneWise4 *] * */ GeneWise4 * Wise2_allocate_Expl_GeneWise4(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPRunImpl * dpri); #define allocate_Expl_GeneWise4 Wise2_allocate_Expl_GeneWise4 /* Function: recalculate_PackAln_GeneWise4(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneWise4 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * */ void Wise2_recalculate_PackAln_GeneWise4(PackAln * pal,GeneWise4 * mat); #define recalculate_PackAln_GeneWise4 Wise2_recalculate_PackAln_GeneWise4 /* Function: allocate_Small_GeneWise4(query,target,gp) * * Descrip: This function allocates the GeneWise4 structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneWise4_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneWise4 *] * */ GeneWise4 * Wise2_allocate_Small_GeneWise4(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp); #define allocate_Small_GeneWise4 Wise2_allocate_Small_GeneWise4 /* Function: PackAln_calculate_Small_GeneWise4(mat,dpenv) * * Descrip: This function calculates an alignment for GeneWise4 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneWise4 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneWise4 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_GeneWise4(GeneWise4 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_GeneWise4 Wise2_PackAln_calculate_Small_GeneWise4 /* Function: AlnRangeSet_calculate_Small_GeneWise4(mat) * * Descrip: This function calculates an alignment for GeneWise4 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneWise4 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneWise4 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneWise4 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_GeneWise4(GeneWise4 * mat); #define AlnRangeSet_calculate_Small_GeneWise4 Wise2_AlnRangeSet_calculate_Small_GeneWise4 /* Function: AlnRangeSet_from_GeneWise4(mat) * * Descrip: This function reads off a start/end structure * for GeneWise4 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneWise4 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneWise4 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_GeneWise4(GeneWise4 * mat); #define AlnRangeSet_from_GeneWise4 Wise2_AlnRangeSet_from_GeneWise4 /* Function: convert_PackAln_to_AlnBlock_GeneWise4(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_GeneWise4(PackAln * pal); #define convert_PackAln_to_AlnBlock_GeneWise4 Wise2_convert_PackAln_to_AlnBlock_GeneWise4 /* Function: PackAln_read_Expl_GeneWise4(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_GeneWise4(GeneWise4 * mat); #define PackAln_read_Expl_GeneWise4 Wise2_PackAln_read_Expl_GeneWise4 /* Function: PackAln_read_generic_GeneWise4(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise4 *] * Arg: h [UNKN ] Undocumented argument [GeneWise4_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_GeneWise4(GeneWise4 * mat,GeneWise4_access_func_holder h); #define PackAln_read_generic_GeneWise4 Wise2_PackAln_read_generic_GeneWise4 /* Function: calculate_GeneWise4(mat) * * Descrip: This function calculates the GeneWise4 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneWise4 * * * Arg: mat [UNKN ] GeneWise4 which contains explicit basematrix memory [GeneWise4 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_GeneWise4(GeneWise4 * mat); #define calculate_GeneWise4 Wise2_calculate_GeneWise4 /* Function: calculate_dpenv_GeneWise4(mat,dpenv) * * Descrip: This function calculates the GeneWise4 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneWise4 which contains explicit basematrix memory [GeneWise4 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_GeneWise4(GeneWise4 * mat,DPEnvelope * dpenv); #define calculate_dpenv_GeneWise4 Wise2_calculate_dpenv_GeneWise4 /* Function: GeneWise4_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWise4 *] * */ GeneWise4 * Wise2_GeneWise4_alloc(void); #define GeneWise4_alloc Wise2_GeneWise4_alloc /* Function: free_GeneWise4(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWise4 *] * * Return [UNKN ] Undocumented return value [GeneWise4 *] * */ GeneWise4 * Wise2_free_GeneWise4(GeneWise4 * obj); #define free_GeneWise4 Wise2_free_GeneWise4 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_GeneWise4_shatter_access_main(GeneWise4 * mat,int i,int j,int state); #define GeneWise4_shatter_access_main Wise2_GeneWise4_shatter_access_main int Wise2_GeneWise4_shatter_access_special(GeneWise4 * mat,int i,int j,int state); #define GeneWise4_shatter_access_special Wise2_GeneWise4_shatter_access_special void * Wise2_thread_loop_GeneWise4(void * ptr); #define thread_loop_GeneWise4 Wise2_thread_loop_GeneWise4 int Wise2_score_only_GeneWise4(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp); #define score_only_GeneWise4 Wise2_score_only_GeneWise4 GeneWise4 * Wise2_allocate_GeneWise4_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp); #define allocate_GeneWise4_only Wise2_allocate_GeneWise4_only void Wise2_init_GeneWise4(GeneWise4 * mat); #define init_GeneWise4 Wise2_init_GeneWise4 AlnRange * Wise2_AlnRange_build_GeneWise4(GeneWise4 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_GeneWise4 Wise2_AlnRange_build_GeneWise4 boolean Wise2_read_hidden_GeneWise4(GeneWise4 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_GeneWise4 Wise2_read_hidden_GeneWise4 int Wise2_max_hidden_GeneWise4(GeneWise4 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_GeneWise4 Wise2_max_hidden_GeneWise4 boolean Wise2_read_special_strip_GeneWise4(GeneWise4 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_GeneWise4 Wise2_read_special_strip_GeneWise4 int Wise2_max_special_strip_GeneWise4(GeneWise4 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_GeneWise4 Wise2_max_special_strip_GeneWise4 int Wise2_max_matrix_to_special_GeneWise4(GeneWise4 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_GeneWise4 Wise2_max_matrix_to_special_GeneWise4 void Wise2_calculate_hidden_GeneWise4(GeneWise4 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_GeneWise4 Wise2_calculate_hidden_GeneWise4 void Wise2_init_hidden_GeneWise4(GeneWise4 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_GeneWise4 Wise2_init_hidden_GeneWise4 boolean Wise2_full_dc_GeneWise4(GeneWise4 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_GeneWise4 Wise2_full_dc_GeneWise4 boolean Wise2_do_dc_single_pass_GeneWise4(GeneWise4 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_GeneWise4 Wise2_do_dc_single_pass_GeneWise4 void Wise2_push_dc_at_merge_GeneWise4(GeneWise4 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_GeneWise4 Wise2_push_dc_at_merge_GeneWise4 void Wise2_follow_on_dc_GeneWise4(GeneWise4 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_GeneWise4 Wise2_follow_on_dc_GeneWise4 void Wise2_run_up_dc_GeneWise4(GeneWise4 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_GeneWise4 Wise2_run_up_dc_GeneWise4 void Wise2_init_dc_GeneWise4(GeneWise4 * mat); #define init_dc_GeneWise4 Wise2_init_dc_GeneWise4 int Wise2_start_end_find_end_GeneWise4(GeneWise4 * mat,int * endj); #define start_end_find_end_GeneWise4 Wise2_start_end_find_end_GeneWise4 boolean Wise2_dc_optimised_start_end_calc_GeneWise4(GeneWise4 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_GeneWise4 Wise2_dc_optimised_start_end_calc_GeneWise4 void Wise2_init_start_end_linear_GeneWise4(GeneWise4 * mat); #define init_start_end_linear_GeneWise4 Wise2_init_start_end_linear_GeneWise4 AlnConvertSet * Wise2_AlnConvertSet_GeneWise4(void); #define AlnConvertSet_GeneWise4 Wise2_AlnConvertSet_GeneWise4 int Wise2_GeneWise4_explicit_access_main(GeneWise4 * mat,int i,int j,int state); #define GeneWise4_explicit_access_main Wise2_GeneWise4_explicit_access_main int Wise2_GeneWise4_explicit_access_special(GeneWise4 * mat,int i,int j,int state); #define GeneWise4_explicit_access_special Wise2_GeneWise4_explicit_access_special int Wise2_find_end_GeneWise4(GeneWise4 * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneWise4_access_func_holder h); #define find_end_GeneWise4 Wise2_find_end_GeneWise4 void Wise2_GeneWise4_debug_show_matrix(GeneWise4 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define GeneWise4_debug_show_matrix Wise2_GeneWise4_debug_show_matrix int Wise2_max_calc_GeneWise4(GeneWise4 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneWise4_access_func_holder h); #define max_calc_GeneWise4 Wise2_max_calc_GeneWise4 int Wise2_max_calc_special_GeneWise4(GeneWise4 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneWise4_access_func_holder h); #define max_calc_special_GeneWise4 Wise2_max_calc_special_GeneWise4 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/genewise6.c0000644000175000001440000105205510670453714016202 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genewise6.h" # line 6 "genewise6.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define INTRON_0 3 #define INTRON_1 4 #define INTRON_2 5 #define START 0 #define END 1 #define GeneWise6_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+10)*6)+STATE][i+1] #define GeneWise6_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+10] #define GeneWise6_READ_OFF_ERROR -12 #define GeneWise6_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+11)%11][((i+1)*6)+STATE] #define GeneWise6_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+11)%11][STATE] #define GeneWise6_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define GeneWise6_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_GeneWise6(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_GeneWise6(GeneWise6 * mat) { GeneWise6_access_func_holder holder; holder.access_main = GeneWise6_shatter_access_main; holder.access_special = GeneWise6_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_GeneWise6(mat,holder); } /* Function: GeneWise6_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneWise6_shatter_access_main(GeneWise6 * mat,int i,int j,int state) { return GeneWise6_SHATTER_MATRIX(mat,i,j,state); } /* Function: GeneWise6_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneWise6_shatter_access_special(GeneWise6 * mat,int i,int j,int state) { return GeneWise6_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_GeneWise6(mat,dpenv) * * Descrip: This function calculates the GeneWise6 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneWise6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_GeneWise6(GeneWise6 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_6; int * SIG_1_5; int * SIG_1_4; int * SIG_1_2; int * SIG_1_1; int * SIG_0_3; int * SIG_0_6; int * SIG_0_5; int * SIG_0_4; int * SIG_0_2; int * SIG_0_1; int * SIG_1_0; int * SIG_0_8; int * SIG_0_9; int * SIG_0_10; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,6,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("GeneWise6 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-6); SIG_1_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-5); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-6); SIG_0_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-5); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); SIG_0_8 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-8); SIG_0_9 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-9); SIG_0_10 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-10); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneWise6_SHATTER_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = SIG_1_6[INTRON_0] + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = SIG_1_5[INTRON_1] + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = SIG_1_4[INTRON_2] + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_1[MATCH] + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_4[MATCH] + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_5[MATCH] + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise6_SHATTER_SPECIAL(mat,i,j,END) ) { GeneWise6_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneWise6_SHATTER_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = SIG_0_6[INTRON_0] + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = SIG_0_5[INTRON_1] + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = SIG_0_4[INTRON_2] + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_2[INSERT] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[INSERT] = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneWise6_SHATTER_SPECIAL(mat,i,j,END) ) { GeneWise6_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneWise6_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneWise6_SHATTER_SPECIAL(mat,i,j,END) ) { GeneWise6_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = SIG_0_8[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = SIG_0_8[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = SIG_0_1[INTRON_0] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_0] = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SIG_0_9[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = SIG_0_9[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = SIG_0_1[INTRON_1] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_1] = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SIG_0_10[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = SIG_0_10[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = SIG_0_1[INTRON_2] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_2] = score; /* Finished calculating state INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_GeneWise6(dbsi,out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneWise6 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_GeneWise6(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_GeneWise6 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_GeneWise6. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_GeneWise6. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for GeneWise6, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_GeneWise6(out,querydb, targetdb ,gp); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_GeneWise6 *) ckalloc(sizeof(struct thread_pool_holder_GeneWise6)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->gp = gp; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_GeneWise6,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for GeneWise6"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from GeneWise6",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_GeneWise6(ptr) * * Descrip: Infinite loop code foreach thread for GeneWise6 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_GeneWise6(void * ptr) { struct thread_pool_holder_GeneWise6 * holder; int db_status; int score; DataScore * ds; GeneWiseScore* query; ComplexSequence* target; holder = (struct thread_pool_holder_GeneWise6 *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneWise6"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneWise6"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_GeneWiseDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in GeneWise6 search"); } query = hard_link_GeneWiseScore(holder->query); /* get query information into datascore */ dataentry_add_GeneWiseDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_GenomicDB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_GenomicDB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching GeneWise6, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_GenomicDB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_GeneWiseScore(holder->query); /* get the next query object for the next thread */ holder->query = reload_GeneWiseDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching GeneWise6, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_GeneWiseDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneWise6"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneWise6"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_GenomicDB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_GeneWise6(query, target ,holder->gp); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for GeneWise6"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for GeneWise6"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneWise6"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_GeneWiseScore(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneWise6"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_GeneWise6(out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneWise6 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_GeneWise6(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp) { GeneWiseScore* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GeneWiseDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneWise6, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_GenomicDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneWise6, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_GeneWise6(query, target , gp); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("GeneWise6 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GeneWiseDB(ds->query,query,querydb); dataentry_add_GenomicDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_GenomicDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneWise6, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_GenomicDB(target,targetdb); query = reload_GeneWiseDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching GeneWise6, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GeneWiseDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_GeneWise6(query,target,gp) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_GeneWise6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_GeneWise6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp) { int bestscore = NEGI; int i; int j; int k; GeneWise6 * mat; mat = allocate_GeneWise6_only(query, target , gp); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(11,(mat->leni + 1) * 6,11,2)) == NULL) { warn("Score only matrix for GeneWise6 cannot be allocated, (asking for 10 by %d cells)",mat->leni*6); mat = free_GeneWise6(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<12;j++) { for(i=(-1);ileni;i++) { for(k=0;k<6;k++) GeneWise6_VSMALL_MATRIX(mat,i,j,k) = NEGI; } GeneWise6_VSMALL_SPECIAL(mat,i,j,START) = 0; GeneWise6_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = GeneWise6_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise6_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise6_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneWise6_VSMALL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneWise6_VSMALL_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneWise6_VSMALL_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneWise6_VSMALL_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_VSMALL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise6_VSMALL_SPECIAL(mat,i,j,END) ) { GeneWise6_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise6_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise6_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise6_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneWise6_VSMALL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneWise6_VSMALL_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneWise6_VSMALL_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneWise6_VSMALL_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise6_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise6_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneWise6_VSMALL_SPECIAL(mat,i,j,END) ) { GeneWise6_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise6_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise6_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise6_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneWise6_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise6_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneWise6_VSMALL_SPECIAL(mat,i,j,END) ) { GeneWise6_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneWise6_VSMALL_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneWise6_VSMALL_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneWise6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneWise6_VSMALL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneWise6_VSMALL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneWise6_VSMALL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneWise6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneWise6_VSMALL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneWise6_VSMALL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneWise6_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneWise6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneWise6_VSMALL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < GeneWise6_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = GeneWise6_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_GeneWise6(mat); return bestscore; } /* Function: PackAln_bestmemory_GeneWise6(query,target,gp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneWise6 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_GeneWise6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; GeneWise6 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 6 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_GeneWise6(query, target , gp,dpri)) == NULL ) { warn("Unable to allocate large GeneWise6 version"); return NULL; } calculate_dpenv_GeneWise6(mat,dpenv); out = PackAln_read_Expl_GeneWise6(mat); } else { mat = allocate_GeneWise6_only(query, target , gp); calculate_shatter_GeneWise6(mat,dpenv); out = PackAln_read_Shatter_GeneWise6(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_GeneWise6(query, target , gp)) == NULL ) { warn("Unable to allocate small GeneWise6 version"); return NULL; } out = PackAln_calculate_Small_GeneWise6(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_GeneWise6(query, target , gp,dpri)) == NULL ) { warn("Unable to allocate large GeneWise6 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_GeneWise6(mat); out = PackAln_read_Expl_GeneWise6(mat); } } } mat = free_GeneWise6(mat); return out; } /* Function: allocate_GeneWise6_only(query,target,gp) * * Descrip: This function only allocates the GeneWise6 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneWise6 *] * */ GeneWise6 * allocate_GeneWise6_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp) { GeneWise6 * out; if((out= GeneWise6_alloc()) == NULL) { warn("Allocation of basic GeneWise6 structure failed..."); return NULL; } out->query = query; out->target = target; out->gp = gp; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_GeneWise6(query,target,gp,dpri) * * Descrip: This function allocates the GeneWise6 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneWise6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneWise6 *] * */ GeneWise6 * allocate_Expl_GeneWise6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPRunImpl * dpri) { GeneWise6 * out; out = allocate_GeneWise6_only(query, target , gp); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+10)*6 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+10)*6,(out->leni+1),2,out->lenj+10)) == NULL) { warn("Explicit matrix GeneWise6 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_GeneWise6(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_GeneWise6(out); return out; } /* Function: init_GeneWise6(mat) * * Descrip: This function initates GeneWise6 matrix when in explicit mode * Called in /allocate_Expl_GeneWise6 * * * Arg: mat [UNKN ] GeneWise6 which contains explicit basematrix memory [GeneWise6 *] * */ void init_GeneWise6(GeneWise6 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-10);j<11;j++) { GeneWise6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } } for(j= (-10);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { GeneWise6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } GeneWise6_EXPL_SPECIAL(mat,i,j,START) = 0; GeneWise6_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_GeneWise6(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneWise6 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * */ void recalculate_PackAln_GeneWise6(PackAln * pal,GeneWise6 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (START+6) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == INTRON_0 ) { pau->score = (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == INTRON_1 ) { pau->score = ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == INTRON_2 ) { pau->score = ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_INSERT_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_INSERT_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (START+6) ) { pau->score = (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 6 && prev->state == INTRON_0 ) { pau->score = (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 5 && prev->state == INTRON_1 ) { pau->score = ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 4 && prev->state == INTRON_2 ) { pau->score = ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->seg[i]->transition[GW_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (START+6) ) { pau->score = mat->query->seg[i]->transition[GW_START2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_0 : if( offi == 0 && offj == 8 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_0 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_1 : if( offi == 0 && offj == 9 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_1 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_2 : if( offi == 0 && offj == 10 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_2 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+6) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+6) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define GeneWise6_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+10)][(i+1)*6+state]) #define GeneWise6_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+11)*8) % 88][(i+1)*6+state]) #define GeneWise6_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+10)]) #define GeneWise6_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) #define GeneWise6_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+11)*8)+(shadow+1)) % 88)][(i+1)*6 + state]) #define GeneWise6_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) #define GeneWise6_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+10)% 10) * (leni+1) * 6) + ((i+1) * 6) + (state)]) #define GeneWise6_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+10)% 10) * (leni+1) * 48) + ((i+1) * 48) + (state * 8) + shadow+1]) #define GeneWise6_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) /* Function: allocate_Small_GeneWise6(query,target,gp) * * Descrip: This function allocates the GeneWise6 structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneWise6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneWise6 *] * */ #define GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) GeneWise6 * allocate_Small_GeneWise6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp) { GeneWise6 * out; out = allocate_GeneWise6_only(query, target , gp); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(88,(out->leni + 1) * 6,16,out->lenj+10); if(out == NULL) { warn("Small shadow matrix GeneWise6 cannot be allocated, (asking for 11 by %d main cells)",out->leni+2); free_GeneWise6(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_GeneWise6(mat,dpenv) * * Descrip: This function calculates an alignment for GeneWise6 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneWise6 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneWise6 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_GeneWise6(GeneWise6 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for GeneWise6 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneWise6(mat,dpenv); score = start_end_find_end_GeneWise6(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_GeneWise6(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_GeneWise6(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == GeneWise6_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_GeneWise6(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 6; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_GeneWise6(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_GeneWise6(mat) * * Descrip: This function calculates an alignment for GeneWise6 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneWise6 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneWise6 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneWise6 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_GeneWise6(GeneWise6 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneWise6(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_GeneWise6(mat); return out; } /* Function: AlnRangeSet_from_GeneWise6(mat) * * Descrip: This function reads off a start/end structure * for GeneWise6 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneWise6 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneWise6 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_GeneWise6(GeneWise6 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneWise6"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_GeneWise6(mat,&jpos); state = END; while( (temp = AlnRange_build_GeneWise6(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_GeneWise6(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_GeneWise6 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_GeneWise6(GeneWise6 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneWise6"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_GeneWise6(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_GeneWise6 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = GeneWise6_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_GeneWise6(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == GeneWise6_READ_OFF_ERROR) { warn("In AlnRange_build_GeneWise6 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = GeneWise6_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_GeneWise6(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_GeneWise6(GeneWise6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_GeneWise6(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneWise6_READ_OFF_ERROR) { warn("In GeneWise6 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In GeneWise6 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In GeneWise6 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_GeneWise6(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_GeneWise6(GeneWise6 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneWise6_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneWise6 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = GeneWise6_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp->transition[GP4_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-1,j-5,MATCH); } return GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->gp->transition[GP4_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-1,j-4,MATCH); } return GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON_2) ) { *reti = i - 1; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-1,j-4,INTRON_2); } return GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON_1) ) { *reti = i - 1; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-1,j-5,INTRON_1); } return GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON_1); } temp = cscore - ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON_0) ) { *reti = i - 1; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-1,j-6,INTRON_0); } return GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON_0); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1); } temp = cscore - ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-3,DELETE); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return GeneWise6_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-8,INSERT); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-8,MATCH); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-9,INSERT); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-9,MATCH); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-10,INSERT); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_HIDDEN_MATRIX(mat,i-0,j-10,MATCH); } return GeneWise6_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_GeneWise6(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_GeneWise6(GeneWise6 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > GeneWise6_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } max_special_strip_GeneWise6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneWise6_READ_OFF_ERROR) { warn("In special strip read GeneWise6, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < GeneWise6_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read GeneWise6, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_GeneWise6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_GeneWise6(GeneWise6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = GeneWise6_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for GeneWise6, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In GeneWise6 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = GeneWise6_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ default: warn("Major problem (!) - in GeneWise6 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_GeneWise6(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_GeneWise6(GeneWise6 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = GeneWise6_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In GeneWise6 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_DC_SHADOW_SPECIAL(mat,i-1,j-3,START); } return GeneWise6_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneWise6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_DC_SHADOW_SPECIAL(mat,i-0,j-3,START); } return GeneWise6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == GeneWise6_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneWise6_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return GeneWise6_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : /* Source INTRON_0 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : /* Source INTRON_1 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : /* Source INTRON_2 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneWise6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_GeneWise6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_GeneWise6(GeneWise6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_GeneWise6(mat,starti,startj,stopi,stopj); GeneWise6_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneWise6_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise6_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise6_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneWise6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneWise6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = GeneWise6_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise6_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise6_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneWise6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneWise6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneWise6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneWise6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } } return; } /* Function: init_hidden_GeneWise6(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_GeneWise6(GeneWise6 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-10);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { GeneWise6_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise6_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise6_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneWise6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneWise6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; } } return; } /* Function: full_dc_GeneWise6(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_GeneWise6 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_GeneWise6 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [GeneWise6 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_GeneWise6(GeneWise6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_GeneWise6"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 50) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_GeneWise6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_GeneWise6(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_GeneWise6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for GeneWise6, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= GeneWise6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= GeneWise6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = GeneWise6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_GeneWise6(mat,GeneWise6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),GeneWise6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),GeneWise6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_GeneWise6(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_GeneWise6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_GeneWise6(GeneWise6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_GeneWise6(mat); GeneWise6_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_GeneWise6(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_GeneWise6(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_GeneWise6(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_GeneWise6(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_GeneWise6(GeneWise6 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<10;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-100); GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = (-100); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-100); GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = (-100); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-100); GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-6; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_2; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-6; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_2; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ /* For state INTRON_0, pushing when j - offj <= mergej */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( j - 8 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = MATCH; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 8 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INSERT; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INTRON_0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } } /* Add any movement independant score */ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished with state INTRON_0 */ /* For state INTRON_1, pushing when j - offj <= mergej */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( j - 9 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = MATCH; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 9 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INSERT; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INTRON_1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } } /* Add any movement independant score */ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished with state INTRON_1 */ /* For state INTRON_2, pushing when j - offj <= mergej */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( j - 10 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = MATCH; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 10 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INSERT; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } } temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-1; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INTRON_2; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } } /* Add any movement independant score */ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished with state INTRON_2 */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_GeneWise6(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_GeneWise6(GeneWise6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state INTRON_0 to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,k); } /* From state INTRON_1 to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,k); } /* From state INTRON_2 to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,k); } /* From state MATCH to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state DELETE to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } /* From state INTRON_0 to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } /* From state INTRON_1 to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } /* From state INTRON_2 to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } /* From state INSERT to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); /* From state INSERT to state INTRON_0 */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } /* From state INTRON_0 to state INTRON_0 */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); /* From state INSERT to state INTRON_1 */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } /* From state INTRON_1 to state INTRON_1 */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); /* From state INSERT to state INTRON_2 */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } /* From state INTRON_2 to state INTRON_2 */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneWise6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_GeneWise6(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_GeneWise6(GeneWise6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneWise6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_GeneWise6(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * */ } void init_dc_GeneWise6(GeneWise6 * mat) { register int i; register int j; register int k; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GeneWise6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; for(k=0;k<7;k++) { GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = (-1); GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = (-1); GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = (-1); } } } return; } /* Function: start_end_find_end_GeneWise6(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [GeneWise6 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_GeneWise6(GeneWise6 * mat,int * endj) { register int j; register int max; register int maxj; max = GeneWise6_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( GeneWise6_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = GeneWise6_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_GeneWise6(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [GeneWise6] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_GeneWise6(GeneWise6 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (10 * (leni + 1) * 6,sizeof(int)); shadow_pointers = (int *) calloc (10 * (leni + 1) * 6 * 8,sizeof(int)); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state START to state MATCH */ temp = GeneWise6_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_0 to state MATCH */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,0)); } /* From state INTRON_1 to state MATCH */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,0)); } /* From state INTRON_2 to state MATCH */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,0)); } /* From state MATCH to state MATCH */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise6_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { GeneWise6_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state DELETE to state INSERT */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0)); } /* From state START to state INSERT */ temp = GeneWise6_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [START] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_0 to state INSERT */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,0)); } /* From state INTRON_1 to state INSERT */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,0)); } /* From state INTRON_2 to state INSERT */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,0)); } /* From state INSERT to state INSERT */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneWise6_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { GeneWise6_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state START to state DELETE */ temp = GeneWise6_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneWise6_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { GeneWise6_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; GeneWise6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = DELETE; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,0)); /* From state INSERT to state INTRON_0 */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,0)); } /* From state INTRON_0 to state INTRON_0 */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,0)); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,0)); /* From state INSERT to state INTRON_1 */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,0)); } /* From state INTRON_1 to state INTRON_1 */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,0)); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,0)); /* From state INSERT to state INTRON_2 */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0)); } /* From state INTRON_2 to state INTRON_2 */ temp = GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,0)); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneWise6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) GeneWise6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_GeneWise6(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * */ void init_start_end_linear_GeneWise6(GeneWise6 * mat) { register int i; register int j; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GeneWise6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-1); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-1); GeneWise6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; GeneWise6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-1); } } for(j=(-10);jtarget->seq->len;j++) { GeneWise6_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; GeneWise6_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; GeneWise6_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_GeneWise6(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_GeneWise6(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_GeneWise6(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","INTRON_STATE","END" }; /* Function: AlnConvertSet_GeneWise6(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","5SS_PHASE_0","CENTRAL_INTRON","5SS_PHASE_1","5SS_PHASE_2","END" }; AlnConvertSet * AlnConvertSet_GeneWise6(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = MATCH; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INSERT; acu->offi = 0; acu->offj = 6; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[11]; add_collapse_label_AlnConvertSet(out,"INTRON_STATE","CENTRAL_INTRON"); return out; } /* Function: PackAln_read_Expl_GeneWise6(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_GeneWise6(GeneWise6 * mat) { GeneWise6_access_func_holder holder; holder.access_main = GeneWise6_explicit_access_main; holder.access_special = GeneWise6_explicit_access_special; return PackAln_read_generic_GeneWise6(mat,holder); } /* Function: GeneWise6_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneWise6_explicit_access_main(GeneWise6 * mat,int i,int j,int state) { return GeneWise6_EXPL_MATRIX(mat,i,j,state); } /* Function: GeneWise6_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneWise6_explicit_access_special(GeneWise6 * mat,int i,int j,int state) { return GeneWise6_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_GeneWise6(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: h [UNKN ] Undocumented argument [GeneWise6_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_GeneWise6(GeneWise6 * mat,GeneWise6_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_GeneWise6(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in GeneWise6_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_GeneWise6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_GeneWise6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == GeneWise6_READ_OFF_ERROR || j == GeneWise6_READ_OFF_ERROR || state == GeneWise6_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in GeneWise6_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_GeneWise6(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [GeneWise6_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_GeneWise6(GeneWise6 * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneWise6_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: GeneWise6_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void GeneWise6_debug_show_matrix(GeneWise6 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",GeneWise6_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",GeneWise6_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",GeneWise6_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"State INTRON_0 %d\n",GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_0)); fprintf(ofp,"State INTRON_1 %d\n",GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_1)); fprintf(ofp,"State INTRON_2 %d\n",GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_2)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_GeneWise6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneWise6_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_GeneWise6(GeneWise6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneWise6_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneWise6_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneWise6 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp->transition[GP4_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,MATCH); } return (*h.access_main)(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->gp->transition[GP4_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH); } return (*h.access_main)(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,INTRON_2) ) { *reti = i - 1; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,INTRON_2); } return (*h.access_main)(mat,i - 1,j - 4,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,INTRON_1) ) { *reti = i - 1; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,INTRON_1); } return (*h.access_main)(mat,i - 1,j - 5,INTRON_1); } temp = cscore - ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,INTRON_0) ) { *reti = i - 1; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,INTRON_0); } return (*h.access_main)(mat,i - 1,j - 6,INTRON_0); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START); } return (*h.access_main)(mat,i - 1,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 5,INTRON_1); } temp = cscore - ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-6,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 6,INTRON_0); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,START); } return (*h.access_main)(mat,i - 0,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE); } return (*h.access_main)(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,INSERT); } return (*h.access_main)(mat,i - 0,j - 8,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,MATCH); } return (*h.access_main)(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,INSERT); } return (*h.access_main)(mat,i - 0,j - 9,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,MATCH); } return (*h.access_main)(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT); } return (*h.access_main)(mat,i - 0,j - 10,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,MATCH); } return (*h.access_main)(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_GeneWise6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneWise6_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_GeneWise6(GeneWise6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneWise6_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneWise6_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In GeneWise6 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in GeneWise6 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_GeneWise6(mat) * * Descrip: This function calculates the GeneWise6 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneWise6 * * * Arg: mat [UNKN ] GeneWise6 which contains explicit basematrix memory [GeneWise6 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_GeneWise6(GeneWise6 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneWise6, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("GeneWise6 Matrix calculation: "); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneWise6_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise6_EXPL_SPECIAL(mat,i,j,END) ) { GeneWise6_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise6_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneWise6_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneWise6_EXPL_SPECIAL(mat,i,j,END) ) { GeneWise6_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise6_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneWise6_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise6_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneWise6_EXPL_SPECIAL(mat,i,j,END) ) { GeneWise6_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneWise6_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneWise6_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneWise6_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_GeneWise6(mat,dpenv) * * Descrip: This function calculates the GeneWise6 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneWise6 which contains explicit basematrix memory [GeneWise6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_GeneWise6(GeneWise6 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneWise6, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-10;jleni;i++) { GeneWise6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } } for(j=-10;jlenj;j++) { GeneWise6_EXPL_SPECIAL(mat,i,j,START) = 0; GeneWise6_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("GeneWise6 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { GeneWise6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = GeneWise6_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GeneWise6_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneWise6_EXPL_SPECIAL(mat,i,j,END) ) { GeneWise6_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneWise6_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = GeneWise6_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneWise6_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneWise6_EXPL_SPECIAL(mat,i,j,END) ) { GeneWise6_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneWise6_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneWise6_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = GeneWise6_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneWise6_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneWise6_EXPL_SPECIAL(mat,i,j,END) ) { GeneWise6_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GeneWise6_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_0 */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GeneWise6_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GeneWise6_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GeneWise6_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GeneWise6_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: GeneWise6_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWise6 *] * */ GeneWise6 * GeneWise6_alloc(void) { GeneWise6 * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWise6 *) ckalloc (sizeof(GeneWise6))) == NULL) { warn("GeneWise6_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_GeneWise6(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWise6 *] * * Return [UNKN ] Undocumented return value [GeneWise6 *] * */ GeneWise6 * free_GeneWise6(GeneWise6 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneWise6 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->gp is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/genewise6.h0000644000175000001440000004465410670453714016214 0ustar philippusers#ifndef DYNAMITEgenewise6HEADERFILE #define DYNAMITEgenewise6HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "geneparser4.h" #include "genewisemodel.h" #include "genewisemodeldb.h" struct Wise2_GeneWise6 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GeneWiseScore* query; ComplexSequence* target; GeneParser4Score * gp; } ; /* GeneWise6 defined */ #ifndef DYNAMITE_DEFINED_GeneWise6 typedef struct Wise2_GeneWise6 Wise2_GeneWise6; #define GeneWise6 Wise2_GeneWise6 #define DYNAMITE_DEFINED_GeneWise6 #endif #ifdef PTHREAD struct thread_pool_holder_GeneWise6 { GeneWiseScore* query; /* Query object placeholder */ GeneWiseDB* querydb;/* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ GenomicDB* targetdb;/* Target database object */ boolean target_init; GeneParser4Score * gp; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_GeneWise6_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(GeneWise6*,int,int,int); int (*access_special)(GeneWise6*,int,int,int); } ; /* GeneWise6_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_GeneWise6_access_func_holder typedef struct Wise2_GeneWise6_access_func_holder Wise2_GeneWise6_access_func_holder; #define GeneWise6_access_func_holder Wise2_GeneWise6_access_func_holder #define DYNAMITE_DEFINED_GeneWise6_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_GeneWise6(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_GeneWise6(GeneWise6 * mat); #define PackAln_read_Shatter_GeneWise6 Wise2_PackAln_read_Shatter_GeneWise6 /* Function: calculate_shatter_GeneWise6(mat,dpenv) * * Descrip: This function calculates the GeneWise6 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneWise6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_GeneWise6(GeneWise6 * mat,DPEnvelope * dpenv); #define calculate_shatter_GeneWise6 Wise2_calculate_shatter_GeneWise6 /* Function: search_GeneWise6(dbsi,out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneWise6 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_GeneWise6(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp); #define search_GeneWise6 Wise2_search_GeneWise6 /* Function: serial_search_GeneWise6(out,querydb,targetdb,gp) * * Descrip: This function makes a database search of GeneWise6 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_GeneWise6(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp); #define serial_search_GeneWise6 Wise2_serial_search_GeneWise6 /* Function: PackAln_bestmemory_GeneWise6(query,target,gp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneWise6 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_GeneWise6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_GeneWise6 Wise2_PackAln_bestmemory_GeneWise6 /* Function: allocate_Expl_GeneWise6(query,target,gp,dpri) * * Descrip: This function allocates the GeneWise6 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneWise6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneWise6 *] * */ GeneWise6 * Wise2_allocate_Expl_GeneWise6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,DPRunImpl * dpri); #define allocate_Expl_GeneWise6 Wise2_allocate_Expl_GeneWise6 /* Function: recalculate_PackAln_GeneWise6(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneWise6 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * */ void Wise2_recalculate_PackAln_GeneWise6(PackAln * pal,GeneWise6 * mat); #define recalculate_PackAln_GeneWise6 Wise2_recalculate_PackAln_GeneWise6 /* Function: allocate_Small_GeneWise6(query,target,gp) * * Descrip: This function allocates the GeneWise6 structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneWise6_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * * Return [UNKN ] Undocumented return value [GeneWise6 *] * */ GeneWise6 * Wise2_allocate_Small_GeneWise6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp); #define allocate_Small_GeneWise6 Wise2_allocate_Small_GeneWise6 /* Function: PackAln_calculate_Small_GeneWise6(mat,dpenv) * * Descrip: This function calculates an alignment for GeneWise6 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneWise6 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneWise6 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_GeneWise6(GeneWise6 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_GeneWise6 Wise2_PackAln_calculate_Small_GeneWise6 /* Function: AlnRangeSet_calculate_Small_GeneWise6(mat) * * Descrip: This function calculates an alignment for GeneWise6 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneWise6 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneWise6 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneWise6 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_GeneWise6(GeneWise6 * mat); #define AlnRangeSet_calculate_Small_GeneWise6 Wise2_AlnRangeSet_calculate_Small_GeneWise6 /* Function: AlnRangeSet_from_GeneWise6(mat) * * Descrip: This function reads off a start/end structure * for GeneWise6 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneWise6 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneWise6 * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_GeneWise6(GeneWise6 * mat); #define AlnRangeSet_from_GeneWise6 Wise2_AlnRangeSet_from_GeneWise6 /* Function: convert_PackAln_to_AlnBlock_GeneWise6(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_GeneWise6(PackAln * pal); #define convert_PackAln_to_AlnBlock_GeneWise6 Wise2_convert_PackAln_to_AlnBlock_GeneWise6 /* Function: PackAln_read_Expl_GeneWise6(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_GeneWise6(GeneWise6 * mat); #define PackAln_read_Expl_GeneWise6 Wise2_PackAln_read_Expl_GeneWise6 /* Function: PackAln_read_generic_GeneWise6(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneWise6 *] * Arg: h [UNKN ] Undocumented argument [GeneWise6_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_GeneWise6(GeneWise6 * mat,GeneWise6_access_func_holder h); #define PackAln_read_generic_GeneWise6 Wise2_PackAln_read_generic_GeneWise6 /* Function: calculate_GeneWise6(mat) * * Descrip: This function calculates the GeneWise6 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneWise6 * * * Arg: mat [UNKN ] GeneWise6 which contains explicit basematrix memory [GeneWise6 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_GeneWise6(GeneWise6 * mat); #define calculate_GeneWise6 Wise2_calculate_GeneWise6 /* Function: calculate_dpenv_GeneWise6(mat,dpenv) * * Descrip: This function calculates the GeneWise6 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneWise6 which contains explicit basematrix memory [GeneWise6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_GeneWise6(GeneWise6 * mat,DPEnvelope * dpenv); #define calculate_dpenv_GeneWise6 Wise2_calculate_dpenv_GeneWise6 /* Function: GeneWise6_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWise6 *] * */ GeneWise6 * Wise2_GeneWise6_alloc(void); #define GeneWise6_alloc Wise2_GeneWise6_alloc /* Function: free_GeneWise6(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWise6 *] * * Return [UNKN ] Undocumented return value [GeneWise6 *] * */ GeneWise6 * Wise2_free_GeneWise6(GeneWise6 * obj); #define free_GeneWise6 Wise2_free_GeneWise6 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_GeneWise6_shatter_access_main(GeneWise6 * mat,int i,int j,int state); #define GeneWise6_shatter_access_main Wise2_GeneWise6_shatter_access_main int Wise2_GeneWise6_shatter_access_special(GeneWise6 * mat,int i,int j,int state); #define GeneWise6_shatter_access_special Wise2_GeneWise6_shatter_access_special void * Wise2_thread_loop_GeneWise6(void * ptr); #define thread_loop_GeneWise6 Wise2_thread_loop_GeneWise6 int Wise2_score_only_GeneWise6(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp); #define score_only_GeneWise6 Wise2_score_only_GeneWise6 GeneWise6 * Wise2_allocate_GeneWise6_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp); #define allocate_GeneWise6_only Wise2_allocate_GeneWise6_only void Wise2_init_GeneWise6(GeneWise6 * mat); #define init_GeneWise6 Wise2_init_GeneWise6 AlnRange * Wise2_AlnRange_build_GeneWise6(GeneWise6 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_GeneWise6 Wise2_AlnRange_build_GeneWise6 boolean Wise2_read_hidden_GeneWise6(GeneWise6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_GeneWise6 Wise2_read_hidden_GeneWise6 int Wise2_max_hidden_GeneWise6(GeneWise6 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_GeneWise6 Wise2_max_hidden_GeneWise6 boolean Wise2_read_special_strip_GeneWise6(GeneWise6 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_GeneWise6 Wise2_read_special_strip_GeneWise6 int Wise2_max_special_strip_GeneWise6(GeneWise6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_GeneWise6 Wise2_max_special_strip_GeneWise6 int Wise2_max_matrix_to_special_GeneWise6(GeneWise6 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_GeneWise6 Wise2_max_matrix_to_special_GeneWise6 void Wise2_calculate_hidden_GeneWise6(GeneWise6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_GeneWise6 Wise2_calculate_hidden_GeneWise6 void Wise2_init_hidden_GeneWise6(GeneWise6 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_GeneWise6 Wise2_init_hidden_GeneWise6 boolean Wise2_full_dc_GeneWise6(GeneWise6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_GeneWise6 Wise2_full_dc_GeneWise6 boolean Wise2_do_dc_single_pass_GeneWise6(GeneWise6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_GeneWise6 Wise2_do_dc_single_pass_GeneWise6 void Wise2_push_dc_at_merge_GeneWise6(GeneWise6 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_GeneWise6 Wise2_push_dc_at_merge_GeneWise6 void Wise2_follow_on_dc_GeneWise6(GeneWise6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_GeneWise6 Wise2_follow_on_dc_GeneWise6 void Wise2_run_up_dc_GeneWise6(GeneWise6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_GeneWise6 Wise2_run_up_dc_GeneWise6 void Wise2_init_dc_GeneWise6(GeneWise6 * mat); #define init_dc_GeneWise6 Wise2_init_dc_GeneWise6 int Wise2_start_end_find_end_GeneWise6(GeneWise6 * mat,int * endj); #define start_end_find_end_GeneWise6 Wise2_start_end_find_end_GeneWise6 boolean Wise2_dc_optimised_start_end_calc_GeneWise6(GeneWise6 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_GeneWise6 Wise2_dc_optimised_start_end_calc_GeneWise6 void Wise2_init_start_end_linear_GeneWise6(GeneWise6 * mat); #define init_start_end_linear_GeneWise6 Wise2_init_start_end_linear_GeneWise6 AlnConvertSet * Wise2_AlnConvertSet_GeneWise6(void); #define AlnConvertSet_GeneWise6 Wise2_AlnConvertSet_GeneWise6 int Wise2_GeneWise6_explicit_access_main(GeneWise6 * mat,int i,int j,int state); #define GeneWise6_explicit_access_main Wise2_GeneWise6_explicit_access_main int Wise2_GeneWise6_explicit_access_special(GeneWise6 * mat,int i,int j,int state); #define GeneWise6_explicit_access_special Wise2_GeneWise6_explicit_access_special int Wise2_find_end_GeneWise6(GeneWise6 * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneWise6_access_func_holder h); #define find_end_GeneWise6 Wise2_find_end_GeneWise6 void Wise2_GeneWise6_debug_show_matrix(GeneWise6 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define GeneWise6_debug_show_matrix Wise2_GeneWise6_debug_show_matrix int Wise2_max_calc_GeneWise6(GeneWise6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneWise6_access_func_holder h); #define max_calc_GeneWise6 Wise2_max_calc_GeneWise6 int Wise2_max_calc_special_GeneWise6(GeneWise6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneWise6_access_func_holder h); #define max_calc_special_GeneWise6 Wise2_max_calc_special_GeneWise6 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/dbadisplay.dy0000644000175000001440000002076010011714154016574 0ustar philippusers %{ #include "dyna.h" %} %{ #include "dbadisplay.h" %func Shows an alignment of from the dba algorithm in pretty formatted ascii text %% boolean show_pretty_dba_align(AlnBlock * alb,Sequence * one,Sequence * two,FILE * ofp) { boolean ret; btCanvas * btc; btc = new_Ascii_btCanvas(ofp,20,50,5,3); /*+6 in case we want to put in numbers */ ret = show_pretty_dba_align_btcanvas(btc,alb,one,two,0); free_btCanvas(btc); return ret; } %func tests whether this is a dba unmatched block %type internal %% boolean is_unmatched_block(AlnColumn * alc) { if( strcmp(alc->alu[0]->text_label,"UM") == 0 ) return TRUE; if( strcmp(alc->alu[0]->text_label,"UI") == 0 ) return TRUE; if( strcmp(alc->alu[1]->text_label,"UM") == 0 ) return TRUE; if( strcmp(alc->alu[1]->text_label,"UI") == 0 ) return TRUE; return FALSE; } %func Different func signature for show_pretty %% boolean show_pretty_Seq_dba_align_btcanvas(AlnBlock * alb,Sequence * one,Sequence * two,btCanvas * btc) { return show_pretty_dba_align_btcanvas(btc,alb,one,two,1); } %func Shows the dba alignment on the block text canvas %type internal %% boolean show_pretty_dba_align_btcanvas(btCanvas * btc,AlnBlock * alb,Sequence * one,Sequence * two,boolean blast_compatible) { AlnColumn * alc; AlnColumn * end_alc; AlnUnit * q; AlnUnit * t; char buffer[14]; boolean at_start = TRUE; boolean new_block; boolean added_hyphen; /* Added NJ020724 */ boolean is_reversed; btPasteArea * btp; if( two->offset > two->end ) { is_reversed = TRUE; } for(alc=alb->start;alc != NULL;) { /** loop over unmatched portions **/ new_block = FALSE; for(; alc != NULL && is_unmatched_block(alc) == TRUE;alc = alc->next) new_block = TRUE; if( alc == NULL ) break; if( strcmp(alc->alu[0]->text_label,"END") == 0 ) { end_alc = alc; alc = NULL; break; } if( new_block == TRUE && at_start == FALSE ) { /* add in block separator */ btp = get_reserved_left_btCanvas(btc); paste_string_btPasteArea(btp,0,1,">-----------<",BC_RIGHT,0); free_btPasteArea(btp); advance_line_btCanvas(btc); } at_start = FALSE; /** put names in **/ btp = get_reserved_left_btCanvas(btc); if( blast_compatible ) { paste_string_btPasteArea(btp,0,0,"Query:",BC_RIGHT,0); paste_string_btPasteArea(btp,0,2,"Sbjct:",BC_RIGHT,0); } else { paste_string_btPasteArea(btp,0,0,one->name,BC_RIGHT,0); paste_string_btPasteArea(btp,0,2,two->name,BC_RIGHT,0); } sprintf(buffer,"%d",alc->alu[0]->start+1+1); paste_string_btPasteArea(btp,12,0,buffer,BC_RIGHT,0); if( two->offset < two->end ) { sprintf(buffer,"%d",alc->alu[1]->start+1+1); } else { sprintf(buffer,"-%d",two->offset - (alc->alu[1]->start+1)); } paste_string_btPasteArea(btp,12,2,buffer,BC_RIGHT,0); if( strcmp(alc->alu[0]->text_label,"MM65") == 0 ) { paste_string_btPasteArea(btp,17,1,"A",BC_RIGHT,0); } else if ( strcmp(alc->alu[0]->text_label,"MM75") == 0 ) { paste_string_btPasteArea(btp,17,1,"B",BC_RIGHT,0); } else if ( strcmp(alc->alu[0]->text_label,"MM85") == 0 ) { paste_string_btPasteArea(btp,17,1,"C",BC_RIGHT,0); } else if ( strcmp(alc->alu[0]->text_label,"MM95") == 0 ) { paste_string_btPasteArea(btp,17,1,"D",BC_RIGHT,0); } else if ( strcmp(alc->alu[0]->text_label,"MM55") == 0 ) { paste_string_btPasteArea(btp,17,1,"a",BC_RIGHT,0); } else if ( strstr(alc->alu[0]->text_label,"MATCH") != NULL ) { paste_string_btPasteArea(btp,17,1,"M",BC_RIGHT,0); } else { warn("Weird label in dba match block at start of block %s",alc->alu[0]->text_label); paste_string_btPasteArea(btp,17,1,"??",BC_RIGHT,0); } free_btPasteArea(btp); /** now loop over this block **/ for(;alc != NULL && can_get_paste_area_btCanvas(btc,1) == TRUE;alc=alc->next) { q = alc->alu[0]; t = alc->alu[1]; /* * at the end, break */ if( strcmp(q->text_label,"END") == 0 ) { end_alc = alc; alc = NULL; break; } /* Unmatched and break */ if( q->text_label[0] == 'U' ) { break; } /* * Get the paste area, length 1, depth will be 3 */ btp = get_paste_area_btCanvas(btc,1); /* * Change NJ020724 * Hack to fix indel bug. * PROBLEM: Inserts were added to the wrong strand, and nucleotides doubled on the other strand. * SOLUTION: When an MI label is found, a hyphen is added to the OTHER strand. A boolean (hyphen_added) * was introduced to avoid overwriting hyphens added to the target strand. * This is probably not the most elegant solution, but what's a poor sod like me to do? */ added_hyphen = FALSE; if( strstartcmp(q->text_label,"MM") == 0 || strstr(q->text_label,"MATCH") != NULL ) { if( strstr(q->text_label,"SPACER") != NULL ) paste_char_btPasteArea(btp,0,0,tolower((int)one->seq[q->start+1]),0); else paste_char_btPasteArea(btp,0,0,toupper((int)one->seq[q->start+1]),0); } else { /** is insert- we could check **/ if( strstartcmp(q->text_label,"MI") != 0 && strstr(q->text_label,"INSERT") == NULL ) { warn("Got an uninterpretable label, %s",q->text_label); paste_char_btPasteArea(btp,0,0,'?',0); } else { if( strstr(q->text_label,"SPACER") != NULL ) paste_char_btPasteArea(btp,0,0,tolower((int)one->seq[q->start+1]),0); /* Still got to add the nucleotide to this sequence */ else paste_char_btPasteArea(btp,0,0,toupper((int)one->seq[q->start+1]),0); paste_char_btPasteArea(btp,0,2,'-',0); /* Add a - to the OTHER sequence. */ added_hyphen = TRUE; /* Set flag to avoid overwriting the hyphen when checking the target sequence below */ } } /* * Write in the target sequence * */ if( strstartcmp(t->text_label,"MM") == 0 || strstr(t->text_label,"MATCH") != NULL ) { /* Check if a hyphen has already been added */ if (added_hyphen == FALSE) { if( strstr(t->text_label,"SPACER") != NULL ) paste_char_btPasteArea(btp,0,2,tolower((int)two->seq[t->start+1]),0); else paste_char_btPasteArea(btp,0,2,toupper((int)two->seq[t->start+1]),0); } } else { /** is insert- we could check **/ if( strstartcmp(t->text_label,"MI") != 0 && strstr(t->text_label,"INSERT") == NULL) { warn("Got an uninterpretable label, %s",t->text_label); paste_char_btPasteArea(btp,0,2,'?',0); } else { if( strstr(t->text_label,"SPACER") != NULL ) paste_char_btPasteArea(btp,0,2,tolower((int)two->seq[t->start+1]),0); /* Still got to add the nucleotide to this sequence */ else paste_char_btPasteArea(btp,0,2,toupper((int)two->seq[t->start+1]),0); paste_char_btPasteArea(btp,0,0,'-',0); /* Add a - to the OTHER sequence. This overwrites what was pasted above */ } } /* * END change NJ020724 */ /* * Match line */ if( (strstartcmp(q->text_label,"MM") == 0 && strstartcmp(t->text_label,"MM") == 0) || (strstr(q->text_label,"MATCH") != NULL && strstr(t->text_label,"MATCH") != NULL && strstr(q->text_label,"SPACER") == NULL) ) { if( strstr(q->text_label,"MOTIF") != NULL ) { paste_char_btPasteArea(btp,0,1,'*',0); } else if( one->seq[q->start+1] == two->seq[t->start+1] ) { paste_char_btPasteArea(btp,0,1,two->seq[t->start+1],0); } else { paste_char_btPasteArea(btp,0,1,' ',0); } } else paste_char_btPasteArea(btp,0,1,' ',0); free_btPasteArea(btp); } /* end of for this block */ /* * BEGIN added by Chuah Aaron to make it comply with SearchIO parsing */ if( blast_compatible ) { btp = get_reserved_right_btCanvas(btc); if( alc != NULL ) { end_alc = alc; } assert(end_alc); // buffer[0]='0'; buffer[1]=0; //hack to get it to work within 70 columns //Remove the line above and uncomment the 2slash-commented lines below to print meaningful numbers sprintf(buffer,"%d",end_alc->alu[0]->start+1); paste_string_btPasteArea(btp,0,0,buffer,BC_RIGHT,0); if( two->offset < two->end ) { sprintf(buffer,"%d",end_alc->alu[1]->start+1); } else { sprintf(buffer,"-%d",two->offset - (end_alc->alu[1]->start+1)); } paste_string_btPasteArea(btp,0,2,buffer,BC_RIGHT,0); free_btPasteArea(btp); /* * END added by Chuah Aaron */ } advance_line_btCanvas(btc); } /* end of for the alignment */ return TRUE; /* we never returned false. Ooops! */ } wise-2.4.1/src/models/motifmatrixdp.c0000644000175000001440000050133510670453714017174 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "motifmatrixdp.h" # line 6 "motifmatrixdp.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define SPACER_MATCH 0 #define MOTIF_MATCH 1 #define CONS_MATCH 2 #define START 0 #define END 1 #define LocalMotifMatrix_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*3)+STATE][i+1] #define LocalMotifMatrix_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define LocalMotifMatrix_READ_OFF_ERROR -3 #define LocalMotifMatrix_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*3)+STATE] #define LocalMotifMatrix_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define LocalMotifMatrix_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define LocalMotifMatrix_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_LocalMotifMatrix(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_LocalMotifMatrix(LocalMotifMatrix * mat) { LocalMotifMatrix_access_func_holder holder; holder.access_main = LocalMotifMatrix_shatter_access_main; holder.access_special = LocalMotifMatrix_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_LocalMotifMatrix(mat,holder); } /* Function: LocalMotifMatrix_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LocalMotifMatrix_shatter_access_main(LocalMotifMatrix * mat,int i,int j,int state) { return LocalMotifMatrix_SHATTER_MATRIX(mat,i,j,state); } /* Function: LocalMotifMatrix_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LocalMotifMatrix_shatter_access_special(LocalMotifMatrix * mat,int i,int j,int state) { return LocalMotifMatrix_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_LocalMotifMatrix(mat,dpenv) * * Descrip: This function calculates the LocalMotifMatrix matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [LocalMotifMatrix *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_LocalMotifMatrix(LocalMotifMatrix * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_1_0; int * SIG_0_1; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("LocalMotifMatrix Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); /* For state SPACER_MATCH */ /* setting first movement to score */ score = SIG_1_1[SPACER_MATCH] + (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_duration); /* From state SPACER_MATCH to state SPACER_MATCH */ temp = SIG_1_0[SPACER_MATCH] + mat->ms->spacer_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state SPACER_MATCH */ temp = SIG_0_1[SPACER_MATCH] + mat->ms->spacer_indel; if( temp > score ) { score = temp; } /* From state MOTIF_MATCH to state SPACER_MATCH */ temp = SIG_1_1[MOTIF_MATCH] + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* From state CONS_MATCH to state SPACER_MATCH */ temp = SIG_1_1[CONS_MATCH] + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* From state START to state SPACER_MATCH */ temp = LocalMotifMatrix_SHATTER_SPECIAL(mat,i-1,j-1,START) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_MATCH */ /* Add any movement independant score and put away */ SIG_0_0[SPACER_MATCH] = score; /* state SPACER_MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalMotifMatrix_SHATTER_SPECIAL(mat,i,j,END) ) { LocalMotifMatrix_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state SPACER_MATCH */ /* For state MOTIF_MATCH */ /* setting first movement to score */ score = SIG_1_1[MOTIF_MATCH] + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->motif_duration); /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = SIG_1_0[MOTIF_MATCH] + mat->ms->motif_indel; if( temp > score ) { score = temp; } /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = SIG_0_1[MOTIF_MATCH] + mat->ms->motif_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state MOTIF_MATCH */ temp = SIG_1_1[SPACER_MATCH] + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->spacer_to_motif); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MOTIF_MATCH */ /* Add any movement independant score and put away */ SIG_0_0[MOTIF_MATCH] = score; /* Finished calculating state MOTIF_MATCH */ /* For state CONS_MATCH */ /* setting first movement to score */ score = SIG_1_1[CONS_MATCH] + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->cons_duration); /* From state CONS_MATCH to state CONS_MATCH */ temp = SIG_1_0[CONS_MATCH] + mat->ms->cons_indel; if( temp > score ) { score = temp; } /* From state CONS_MATCH to state CONS_MATCH */ temp = SIG_0_1[CONS_MATCH] + mat->ms->cons_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state CONS_MATCH */ temp = SIG_1_1[SPACER_MATCH] + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_to_cons); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CONS_MATCH */ /* Add any movement independant score and put away */ SIG_0_0[CONS_MATCH] = score; /* Finished calculating state CONS_MATCH */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_LocalMotifMatrix(dbsi,out,query,target,motif,ms) * * Descrip: This function makes a database search of LocalMotifMatrix * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: motif [UNKN ] Undocumented argument [MotifConsMatrix*] * Arg: ms [UNKN ] Undocumented argument [MotifMatrixScore*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_LocalMotifMatrix(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms) { if( out == NULL ) { warn("Passed in a null Hscore object into search_LocalMotifMatrix. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_LocalMotifMatrix. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for LocalMotifMatrix, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_LocalMotifMatrix(out,query,target ,motif,ms); case DBSearchImpl_Pthreads : warn("This matrix LocalMotifMatrix was not dyc compiled with thread support"); return SEARCH_ERROR; default : warn("database search implementation %s was not provided in the compiled dynamite file from LocalMotifMatrix",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: serial_search_LocalMotifMatrix(out,query,target,motif,ms) * * Descrip: This function makes a database search of LocalMotifMatrix * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: motif [UNKN ] Undocumented argument [MotifConsMatrix*] * Arg: ms [UNKN ] Undocumented argument [MotifMatrixScore*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_LocalMotifMatrix(Hscore * out,ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_LocalMotifMatrix(query, target , motif, ms); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("LocalMotifMatrix search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_LocalMotifMatrix(query,target,motif,ms) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_LocalMotifMatrix_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: motif [UNKN ] Resource [MotifConsMatrix*] * Arg: ms [UNKN ] Resource [MotifMatrixScore*] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_LocalMotifMatrix(ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms) { int bestscore = NEGI; int i; int j; int k; LocalMotifMatrix * mat; mat = allocate_LocalMotifMatrix_only(query, target , motif, ms); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 3,2,2)) == NULL) { warn("Score only matrix for LocalMotifMatrix cannot be allocated, (asking for 1 by %d cells)",mat->leni*3); mat = free_LocalMotifMatrix(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) LocalMotifMatrix_VSMALL_MATRIX(mat,i,j,k) = NEGI; } LocalMotifMatrix_VSMALL_SPECIAL(mat,i,j,START) = 0; LocalMotifMatrix_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state SPACER_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_VSMALL_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_duration); /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_VSMALL_MATRIX(mat,i-1,j-0,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_VSMALL_MATRIX(mat,i-0,j-1,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score ) { score = temp; } /* From state MOTIF_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_VSMALL_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* From state CONS_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_VSMALL_MATRIX(mat,i-1,j-1,CONS_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* From state START to state SPACER_MATCH */ temp = LocalMotifMatrix_VSMALL_SPECIAL(mat,i-1,j-1,START) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_VSMALL_MATRIX(mat,i,j,SPACER_MATCH) = score; /* state SPACER_MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalMotifMatrix_VSMALL_SPECIAL(mat,i,j,END) ) { LocalMotifMatrix_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state SPACER_MATCH */ /* For state MOTIF_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_VSMALL_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->motif_duration); /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_VSMALL_MATRIX(mat,i-1,j-0,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score ) { score = temp; } /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_VSMALL_MATRIX(mat,i-0,j-1,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_VSMALL_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->spacer_to_motif); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MOTIF_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_VSMALL_MATRIX(mat,i,j,MOTIF_MATCH) = score; /* Finished calculating state MOTIF_MATCH */ /* For state CONS_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_VSMALL_MATRIX(mat,i-1,j-1,CONS_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->cons_duration); /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_VSMALL_MATRIX(mat,i-1,j-0,CONS_MATCH) + mat->ms->cons_indel; if( temp > score ) { score = temp; } /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_VSMALL_MATRIX(mat,i-0,j-1,CONS_MATCH) + mat->ms->cons_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_VSMALL_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_to_cons); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CONS_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_VSMALL_MATRIX(mat,i,j,CONS_MATCH) = score; /* Finished calculating state CONS_MATCH */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < LocalMotifMatrix_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = LocalMotifMatrix_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_LocalMotifMatrix(mat); return bestscore; } /* Function: PackAln_bestmemory_LocalMotifMatrix(query,target,motif,ms,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_LocalMotifMatrix * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: motif [UNKN ] Resource [MotifConsMatrix*] * Arg: ms [UNKN ] Resource [MotifMatrixScore*] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_LocalMotifMatrix(ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; LocalMotifMatrix * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->seq->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_LocalMotifMatrix(query, target , motif, ms,dpri)) == NULL ) { warn("Unable to allocate large LocalMotifMatrix version"); return NULL; } calculate_dpenv_LocalMotifMatrix(mat,dpenv); out = PackAln_read_Expl_LocalMotifMatrix(mat); } else { mat = allocate_LocalMotifMatrix_only(query, target , motif, ms); calculate_shatter_LocalMotifMatrix(mat,dpenv); out = PackAln_read_Shatter_LocalMotifMatrix(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_LocalMotifMatrix(query, target , motif, ms)) == NULL ) { warn("Unable to allocate small LocalMotifMatrix version"); return NULL; } out = PackAln_calculate_Small_LocalMotifMatrix(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_LocalMotifMatrix(query, target , motif, ms,dpri)) == NULL ) { warn("Unable to allocate large LocalMotifMatrix version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_LocalMotifMatrix(mat); out = PackAln_read_Expl_LocalMotifMatrix(mat); } } } mat = free_LocalMotifMatrix(mat); return out; } /* Function: allocate_LocalMotifMatrix_only(query,target,motif,ms) * * Descrip: This function only allocates the LocalMotifMatrix structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: motif [UNKN ] Resource [MotifConsMatrix*] * Arg: ms [UNKN ] Resource [MotifMatrixScore*] * * Return [UNKN ] Undocumented return value [LocalMotifMatrix *] * */ LocalMotifMatrix * allocate_LocalMotifMatrix_only(ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms) { LocalMotifMatrix * out; if((out= LocalMotifMatrix_alloc()) == NULL) { warn("Allocation of basic LocalMotifMatrix structure failed..."); return NULL; } out->query = query; out->target = target; out->motif = motif; out->ms = ms; out->leni = query->seq->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_LocalMotifMatrix(query,target,motif,ms,dpri) * * Descrip: This function allocates the LocalMotifMatrix structure * and the basematrix area for explicit memory implementations * It calls /allocate_LocalMotifMatrix_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: motif [UNKN ] Resource [MotifConsMatrix*] * Arg: ms [UNKN ] Resource [MotifMatrixScore*] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [LocalMotifMatrix *] * */ LocalMotifMatrix * allocate_Expl_LocalMotifMatrix(ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms,DPRunImpl * dpri) { LocalMotifMatrix * out; out = allocate_LocalMotifMatrix_only(query, target , motif, ms); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*3,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix LocalMotifMatrix cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_LocalMotifMatrix(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_LocalMotifMatrix(out); return out; } /* Function: init_LocalMotifMatrix(mat) * * Descrip: This function initates LocalMotifMatrix matrix when in explicit mode * Called in /allocate_Expl_LocalMotifMatrix * * * Arg: mat [UNKN ] LocalMotifMatrix which contains explicit basematrix memory [LocalMotifMatrix *] * */ void init_LocalMotifMatrix(LocalMotifMatrix * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->seq->len;i++) { for(j= (-1);j<2;j++) { LocalMotifMatrix_EXPL_MATRIX(mat,i,j,SPACER_MATCH) = NEGI; LocalMotifMatrix_EXPL_MATRIX(mat,i,j,MOTIF_MATCH) = NEGI; LocalMotifMatrix_EXPL_MATRIX(mat,i,j,CONS_MATCH) = NEGI; } } for(j= (-1);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { LocalMotifMatrix_EXPL_MATRIX(mat,i,j,SPACER_MATCH) = NEGI; LocalMotifMatrix_EXPL_MATRIX(mat,i,j,MOTIF_MATCH) = NEGI; LocalMotifMatrix_EXPL_MATRIX(mat,i,j,CONS_MATCH) = NEGI; } LocalMotifMatrix_EXPL_SPECIAL(mat,i,j,START) = 0; LocalMotifMatrix_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_LocalMotifMatrix(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by LocalMotifMatrix * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * */ void recalculate_PackAln_LocalMotifMatrix(PackAln * pal,LocalMotifMatrix * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case SPACER_MATCH : if( offi == 1 && offj == 1 && prev->state == SPACER_MATCH ) { pau->score = (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_duration) + (0); continue; } if( offi == 1 && offj == 0 && prev->state == SPACER_MATCH ) { pau->score = mat->ms->spacer_indel + (0); continue; } if( offi == 0 && offj == 1 && prev->state == SPACER_MATCH ) { pau->score = mat->ms->spacer_indel + (0); continue; } if( offi == 1 && offj == 1 && prev->state == MOTIF_MATCH ) { pau->score = mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)] + (0); continue; } if( offi == 1 && offj == 1 && prev->state == CONS_MATCH ) { pau->score = mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)] + (0); continue; } if( offj == 1 && prev->state == (START+3) ) { pau->score = mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)] + (0); continue; } warn("In recaluclating PackAln with state SPACER_MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case MOTIF_MATCH : if( offi == 1 && offj == 1 && prev->state == MOTIF_MATCH ) { pau->score = (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->motif_duration) + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MOTIF_MATCH ) { pau->score = mat->ms->motif_indel + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MOTIF_MATCH ) { pau->score = mat->ms->motif_indel + (0); continue; } if( offi == 1 && offj == 1 && prev->state == SPACER_MATCH ) { pau->score = (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->spacer_to_motif) + (0); continue; } warn("In recaluclating PackAln with state MOTIF_MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CONS_MATCH : if( offi == 1 && offj == 1 && prev->state == CONS_MATCH ) { pau->score = (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->cons_duration) + (0); continue; } if( offi == 1 && offj == 0 && prev->state == CONS_MATCH ) { pau->score = mat->ms->cons_indel + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CONS_MATCH ) { pau->score = mat->ms->cons_indel + (0); continue; } if( offi == 1 && offj == 1 && prev->state == SPACER_MATCH ) { pau->score = (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_to_cons) + (0); continue; } warn("In recaluclating PackAln with state CONS_MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+3) : if( offj == 0 && prev->state == SPACER_MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define LocalMotifMatrix_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*3+state]) #define LocalMotifMatrix_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*3+state]) #define LocalMotifMatrix_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define LocalMotifMatrix_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define LocalMotifMatrix_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*3 + state]) #define LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define LocalMotifMatrix_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_LocalMotifMatrix(query,target,motif,ms) * * Descrip: This function allocates the LocalMotifMatrix structure * and the basematrix area for a small memory implementations * It calls /allocate_LocalMotifMatrix_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: motif [UNKN ] Resource [MotifConsMatrix*] * Arg: ms [UNKN ] Resource [MotifMatrixScore*] * * Return [UNKN ] Undocumented return value [LocalMotifMatrix *] * */ #define LocalMotifMatrix_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) LocalMotifMatrix * allocate_Small_LocalMotifMatrix(ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms) { LocalMotifMatrix * out; out = allocate_LocalMotifMatrix_only(query, target , motif, ms); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 3,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix LocalMotifMatrix cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_LocalMotifMatrix(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_LocalMotifMatrix(mat,dpenv) * * Descrip: This function calculates an alignment for LocalMotifMatrix structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_LocalMotifMatrix * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_LocalMotifMatrix * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_LocalMotifMatrix(LocalMotifMatrix * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for LocalMotifMatrix due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_LocalMotifMatrix(mat,dpenv); score = start_end_find_end_LocalMotifMatrix(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_LocalMotifMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_LocalMotifMatrix(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == LocalMotifMatrix_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_LocalMotifMatrix(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 3; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_LocalMotifMatrix(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_LocalMotifMatrix(mat) * * Descrip: This function calculates an alignment for LocalMotifMatrix structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_LocalMotifMatrix * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_LocalMotifMatrix * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_LocalMotifMatrix * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_LocalMotifMatrix(LocalMotifMatrix * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_LocalMotifMatrix(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_LocalMotifMatrix(mat); return out; } /* Function: AlnRangeSet_from_LocalMotifMatrix(mat) * * Descrip: This function reads off a start/end structure * for LocalMotifMatrix structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_LocalMotifMatrix * If you have not calculated the matrix use * /AlnRange_calculate_Small_LocalMotifMatrix * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_LocalMotifMatrix(LocalMotifMatrix * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_LocalMotifMatrix"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_LocalMotifMatrix(mat,&jpos); state = END; while( (temp = AlnRange_build_LocalMotifMatrix(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_LocalMotifMatrix(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_LocalMotifMatrix * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_LocalMotifMatrix(LocalMotifMatrix * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_LocalMotifMatrix"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_LocalMotifMatrix(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_LocalMotifMatrix alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = LocalMotifMatrix_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_LocalMotifMatrix(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == LocalMotifMatrix_READ_OFF_ERROR) { warn("In AlnRange_build_LocalMotifMatrix alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = LocalMotifMatrix_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_LocalMotifMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_LocalMotifMatrix(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == LocalMotifMatrix_READ_OFF_ERROR) { warn("In LocalMotifMatrix hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In LocalMotifMatrix hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In LocalMotifMatrix hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_LocalMotifMatrix(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_LocalMotifMatrix(LocalMotifMatrix * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = LocalMotifMatrix_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In LocalMotifMatrix matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = LocalMotifMatrix_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case SPACER_MATCH : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]) - (0); if( temp == LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,CONS_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = CONS_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,CONS_MATCH); } return LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,CONS_MATCH); } temp = cscore - (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]) - (0); if( temp == LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,MOTIF_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MOTIF_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,MOTIF_MATCH); } return LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,MOTIF_MATCH); } temp = cscore - (mat->ms->spacer_indel) - (0); if( temp == LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_MATCH); } return LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_MATCH); } temp = cscore - (mat->ms->spacer_indel) - (0); if( temp == LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 0,SPACER_MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = SPACER_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-0,SPACER_MATCH); } return LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 0,SPACER_MATCH); } temp = cscore - ((mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_duration)) - (0); if( temp == LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,SPACER_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = SPACER_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,SPACER_MATCH); } return LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,SPACER_MATCH); } warn("Major problem (!) - in LocalMotifMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MOTIF_MATCH : temp = cscore - ((MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->spacer_to_motif)) - (0); if( temp == LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,SPACER_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = SPACER_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,SPACER_MATCH); } return LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,SPACER_MATCH); } temp = cscore - (mat->ms->motif_indel) - (0); if( temp == LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,MOTIF_MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MOTIF_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_HIDDEN_MATRIX(mat,i-0,j-1,MOTIF_MATCH); } return LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,MOTIF_MATCH); } temp = cscore - (mat->ms->motif_indel) - (0); if( temp == LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 0,MOTIF_MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MOTIF_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-0,MOTIF_MATCH); } return LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 0,MOTIF_MATCH); } temp = cscore - ((MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->motif_duration)) - (0); if( temp == LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,MOTIF_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MOTIF_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,MOTIF_MATCH); } return LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,MOTIF_MATCH); } warn("Major problem (!) - in LocalMotifMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CONS_MATCH : temp = cscore - ((mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_to_cons)) - (0); if( temp == LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,SPACER_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = SPACER_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,SPACER_MATCH); } return LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,SPACER_MATCH); } temp = cscore - (mat->ms->cons_indel) - (0); if( temp == LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,CONS_MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = CONS_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_HIDDEN_MATRIX(mat,i-0,j-1,CONS_MATCH); } return LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 0,j - 1,CONS_MATCH); } temp = cscore - (mat->ms->cons_indel) - (0); if( temp == LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 0,CONS_MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = CONS_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-0,CONS_MATCH); } return LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 0,CONS_MATCH); } temp = cscore - ((mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->cons_duration)) - (0); if( temp == LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,CONS_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = CONS_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,CONS_MATCH); } return LocalMotifMatrix_HIDDEN_MATRIX(mat,i - 1,j - 1,CONS_MATCH); } warn("Major problem (!) - in LocalMotifMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in LocalMotifMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_LocalMotifMatrix(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_LocalMotifMatrix(LocalMotifMatrix * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_LocalMotifMatrix(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == LocalMotifMatrix_READ_OFF_ERROR) { warn("In special strip read LocalMotifMatrix, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read LocalMotifMatrix, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_LocalMotifMatrix(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_LocalMotifMatrix(LocalMotifMatrix * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = LocalMotifMatrix_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for LocalMotifMatrix, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In LocalMotifMatrix matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = LocalMotifMatrix_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source SPACER_MATCH is not a special */ default: warn("Major problem (!) - in LocalMotifMatrix special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_LocalMotifMatrix(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_LocalMotifMatrix(LocalMotifMatrix * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = LocalMotifMatrix_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In LocalMotifMatrix matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case SPACER_MATCH : temp = cscore - (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]) - (0); if( temp == LocalMotifMatrix_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - LocalMotifMatrix_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source CONS_MATCH is not a special, should not get here! */ /* Source MOTIF_MATCH is not a special, should not get here! */ /* Source SPACER_MATCH is not a special, should not get here! */ /* Source SPACER_MATCH is not a special, should not get here! */ /* Source SPACER_MATCH is not a special, should not get here! */ warn("Major problem (!) - in LocalMotifMatrix matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MOTIF_MATCH : /* Source SPACER_MATCH is not a special, should not get here! */ /* Source MOTIF_MATCH is not a special, should not get here! */ /* Source MOTIF_MATCH is not a special, should not get here! */ /* Source MOTIF_MATCH is not a special, should not get here! */ warn("Major problem (!) - in LocalMotifMatrix matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CONS_MATCH : /* Source SPACER_MATCH is not a special, should not get here! */ /* Source CONS_MATCH is not a special, should not get here! */ /* Source CONS_MATCH is not a special, should not get here! */ /* Source CONS_MATCH is not a special, should not get here! */ warn("Major problem (!) - in LocalMotifMatrix matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in LocalMotifMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_LocalMotifMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_LocalMotifMatrix(mat,starti,startj,stopi,stopj); LocalMotifMatrix_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LocalMotifMatrix_HIDDEN_MATRIX(mat,i,j,SPACER_MATCH) = NEGI; LocalMotifMatrix_HIDDEN_MATRIX(mat,i,j,MOTIF_MATCH) = NEGI; LocalMotifMatrix_HIDDEN_MATRIX(mat,i,j,CONS_MATCH) = NEGI; continue; } /* end of Is not in envelope */ /* For state SPACER_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_duration); /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-0,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score ) { score = temp; } /* From state MOTIF_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* From state CONS_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,CONS_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_HIDDEN_MATRIX(mat,i,j,SPACER_MATCH) = score; /* Finished calculating state SPACER_MATCH */ /* For state MOTIF_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->motif_duration); /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-0,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score ) { score = temp; } /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_HIDDEN_MATRIX(mat,i-0,j-1,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->spacer_to_motif); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MOTIF_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_HIDDEN_MATRIX(mat,i,j,MOTIF_MATCH) = score; /* Finished calculating state MOTIF_MATCH */ /* For state CONS_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,CONS_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->cons_duration); /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-0,CONS_MATCH) + mat->ms->cons_indel; if( temp > score ) { score = temp; } /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_HIDDEN_MATRIX(mat,i-0,j-1,CONS_MATCH) + mat->ms->cons_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_HIDDEN_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_to_cons); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CONS_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_HIDDEN_MATRIX(mat,i,j,CONS_MATCH) = score; /* Finished calculating state CONS_MATCH */ } } return; } /* Function: init_hidden_LocalMotifMatrix(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { LocalMotifMatrix_HIDDEN_MATRIX(mat,i,j,SPACER_MATCH) = NEGI; LocalMotifMatrix_HIDDEN_MATRIX(mat,i,j,MOTIF_MATCH) = NEGI; LocalMotifMatrix_HIDDEN_MATRIX(mat,i,j,CONS_MATCH) = NEGI; } } return; } /* Function: full_dc_LocalMotifMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_LocalMotifMatrix * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_LocalMotifMatrix to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [LocalMotifMatrix *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_LocalMotifMatrix"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_LocalMotifMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_LocalMotifMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_LocalMotifMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for LocalMotifMatrix, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_LocalMotifMatrix(mat,LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_LocalMotifMatrix(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_LocalMotifMatrix(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_LocalMotifMatrix(mat); LocalMotifMatrix_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_LocalMotifMatrix(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_LocalMotifMatrix(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_LocalMotifMatrix(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_LocalMotifMatrix(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,SPACER_MATCH) = NEGI; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,0) = (-100); LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,1) = (-100); LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,MOTIF_MATCH) = NEGI; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,0) = (-100); LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,1) = (-100); LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,CONS_MATCH) = NEGI; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,0) = (-100); LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,1) = (-100); continue; } /* end of Is not in envelope */ /* For state SPACER_MATCH, pushing when j - offj <= mergej */ score = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_duration); if( j - 1 <= mergej) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,0) = i-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,1) = j-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,2) = SPACER_MATCH; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,3) = i; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,4) = j; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,5) = SPACER_MATCH; } else { for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,k) = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SPACER_MATCH,k); } temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-0,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,0) = i-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,1) = j-0; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,2) = SPACER_MATCH; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,3) = i; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,4) = j; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,5) = SPACER_MATCH; } else { for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,k) = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SPACER_MATCH,k); } } temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,0) = i-0; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,1) = j-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,2) = SPACER_MATCH; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,3) = i; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,4) = j; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,5) = SPACER_MATCH; } else { for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,k) = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_MATCH,k); } } temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,0) = i-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,1) = j-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,2) = MOTIF_MATCH; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,3) = i; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,4) = j; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,5) = SPACER_MATCH; } else { for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,k) = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MOTIF_MATCH,k); } } temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,CONS_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,0) = i-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,1) = j-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,2) = CONS_MATCH; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,3) = i; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,4) = j; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,5) = SPACER_MATCH; } else { for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,k) = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,CONS_MATCH,k); } } /* Add any movement independant score */ LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,SPACER_MATCH) = score; /* Finished with state SPACER_MATCH */ /* For state MOTIF_MATCH, pushing when j - offj <= mergej */ score = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->motif_duration); if( j - 1 <= mergej) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,0) = i-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,1) = j-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,2) = MOTIF_MATCH; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,3) = i; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,4) = j; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,5) = MOTIF_MATCH; } else { for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,k) = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MOTIF_MATCH,k); } temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-0,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,0) = i-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,1) = j-0; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,2) = MOTIF_MATCH; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,3) = i; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,4) = j; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,5) = MOTIF_MATCH; } else { for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,k) = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MOTIF_MATCH,k); } } temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,0) = i-0; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,1) = j-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,2) = MOTIF_MATCH; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,3) = i; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,4) = j; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,5) = MOTIF_MATCH; } else { for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,k) = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MOTIF_MATCH,k); } } temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->spacer_to_motif); if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,0) = i-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,1) = j-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,2) = SPACER_MATCH; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,3) = i; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,4) = j; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,5) = MOTIF_MATCH; } else { for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,k) = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SPACER_MATCH,k); } } /* Add any movement independant score */ LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,MOTIF_MATCH) = score; /* Finished with state MOTIF_MATCH */ /* For state CONS_MATCH, pushing when j - offj <= mergej */ score = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,CONS_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->cons_duration); if( j - 1 <= mergej) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,0) = i-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,1) = j-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,2) = CONS_MATCH; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,3) = i; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,4) = j; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,5) = CONS_MATCH; } else { for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,k) = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,CONS_MATCH,k); } temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-0,CONS_MATCH) + mat->ms->cons_indel; if( temp > score) { score = temp; if( j - 0 <= mergej) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,0) = i-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,1) = j-0; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,2) = CONS_MATCH; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,3) = i; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,4) = j; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,5) = CONS_MATCH; } else { for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,k) = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,CONS_MATCH,k); } } temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,CONS_MATCH) + mat->ms->cons_indel; if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,0) = i-0; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,1) = j-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,2) = CONS_MATCH; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,3) = i; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,4) = j; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,5) = CONS_MATCH; } else { for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,k) = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CONS_MATCH,k); } } temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_to_cons); if( temp > score) { score = temp; if( j - 1 <= mergej) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,0) = i-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,1) = j-1; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,2) = SPACER_MATCH; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,3) = i; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,4) = j; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,5) = CONS_MATCH; } else { for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,k) = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SPACER_MATCH,k); } } /* Add any movement independant score */ LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,CONS_MATCH) = score; /* Finished with state CONS_MATCH */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_LocalMotifMatrix(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,SPACER_MATCH) = NEGI; LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,MOTIF_MATCH) = NEGI; LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,CONS_MATCH) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state SPACER_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_duration); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SPACER_MATCH,k); /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-0,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SPACER_MATCH,k); } /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_MATCH,k); } /* From state MOTIF_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MOTIF_MATCH,k); } /* From state CONS_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,CONS_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,CONS_MATCH,k); } /* Ok - finished max calculation for SPACER_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,SPACER_MATCH) = score; for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_MATCH */ /* For state MOTIF_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->motif_duration); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MOTIF_MATCH,k); /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-0,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MOTIF_MATCH,k); } /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MOTIF_MATCH,k); } /* From state SPACER_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->spacer_to_motif); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SPACER_MATCH,k); } /* Ok - finished max calculation for MOTIF_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,MOTIF_MATCH) = score; for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MOTIF_MATCH */ /* For state CONS_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,CONS_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->cons_duration); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,CONS_MATCH,k); /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-0,CONS_MATCH) + mat->ms->cons_indel; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,CONS_MATCH,k); } /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,CONS_MATCH) + mat->ms->cons_indel; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CONS_MATCH,k); } /* From state SPACER_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_to_cons); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SPACER_MATCH,k); } /* Ok - finished max calculation for CONS_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,CONS_MATCH) = score; for(k=0;k<7;k++) LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CONS_MATCH */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_LocalMotifMatrix(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,SPACER_MATCH) = NEGI; LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,MOTIF_MATCH) = NEGI; LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,CONS_MATCH) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state SPACER_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_duration); /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-0,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score ) { score = temp; } /* From state MOTIF_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* From state CONS_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,CONS_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,SPACER_MATCH) = score; /* Finished calculating state SPACER_MATCH */ /* For state MOTIF_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->motif_duration); /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-0,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score ) { score = temp; } /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->spacer_to_motif); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MOTIF_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,MOTIF_MATCH) = score; /* Finished calculating state MOTIF_MATCH */ /* For state CONS_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,CONS_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->cons_duration); /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-0,CONS_MATCH) + mat->ms->cons_indel; if( temp > score ) { score = temp; } /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-0,j-1,CONS_MATCH) + mat->ms->cons_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_to_cons); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CONS_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,CONS_MATCH) = score; /* Finished calculating state CONS_MATCH */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_LocalMotifMatrix(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * */ } void init_dc_LocalMotifMatrix(LocalMotifMatrix * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,SPACER_MATCH) = NEGI; LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,MOTIF_MATCH) = NEGI; LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,CONS_MATCH) = NEGI; for(k=0;k<7;k++) { LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,k) = (-1); LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,k) = (-1); LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,k) = (-1); } } } return; } /* Function: start_end_find_end_LocalMotifMatrix(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [LocalMotifMatrix *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_LocalMotifMatrix(LocalMotifMatrix * mat,int * endj) { register int j; register int max; register int maxj; max = LocalMotifMatrix_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( LocalMotifMatrix_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = LocalMotifMatrix_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_LocalMotifMatrix(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [LocalMotifMatrix] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_LocalMotifMatrix(LocalMotifMatrix *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->seq->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_duration) + (0); /* assign local shadown pointer */ localsp = &(LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SPACER_MATCH,0)); /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,SPACER_MATCH) + mat->ms->spacer_indel +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,SPACER_MATCH,0)); } /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SPACER_MATCH) + mat->ms->spacer_indel +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_MATCH,0)); } /* From state MOTIF_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MOTIF_MATCH,0)); } /* From state CONS_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,CONS_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,CONS_MATCH,0)); } /* From state START to state SPACER_MATCH */ temp = LocalMotifMatrix_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for SPACER_MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= SPACER_MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for SPACER_MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i,j,SPACER_MATCH) = score; for(k=0;k<7;k++) LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state SPACER_MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalMotifMatrix_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { LocalMotifMatrix_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) LocalMotifMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,k); LocalMotifMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,6); LocalMotifMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; LocalMotifMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; LocalMotifMatrix_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = SPACER_MATCH; } /* Finished calculating state SPACER_MATCH */ /* For state MOTIF_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->motif_duration) + (0); /* assign local shadown pointer */ localsp = &(LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MOTIF_MATCH,0)); /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MOTIF_MATCH) + mat->ms->motif_indel +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MOTIF_MATCH,0)); } /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MOTIF_MATCH) + mat->ms->motif_indel +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MOTIF_MATCH,0)); } /* From state SPACER_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->spacer_to_motif) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SPACER_MATCH,0)); } /* Ok - finished max calculation for MOTIF_MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i,j,MOTIF_MATCH) = score; for(k=0;k<7;k++) LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MOTIF_MATCH */ /* For state CONS_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,CONS_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->cons_duration) + (0); /* assign local shadown pointer */ localsp = &(LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,CONS_MATCH,0)); /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,CONS_MATCH) + mat->ms->cons_indel +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,CONS_MATCH,0)); } /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CONS_MATCH) + mat->ms->cons_indel +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CONS_MATCH,0)); } /* From state SPACER_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_to_cons) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,SPACER_MATCH,0)); } /* Ok - finished max calculation for CONS_MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ LocalMotifMatrix_DC_OPT_SHADOW_MATRIX(mat,i,j,CONS_MATCH) = score; for(k=0;k<7;k++) LocalMotifMatrix_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CONS_MATCH */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_LocalMotifMatrix(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * */ void init_start_end_linear_LocalMotifMatrix(LocalMotifMatrix * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,SPACER_MATCH) = NEGI; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_MATCH,0) = (-1); LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,MOTIF_MATCH) = NEGI; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,MOTIF_MATCH,0) = (-1); LocalMotifMatrix_DC_SHADOW_MATRIX(mat,i,j,CONS_MATCH) = NEGI; LocalMotifMatrix_DC_SHADOW_MATRIX_SP(mat,i,j,CONS_MATCH,0) = (-1); } } for(j=(-1);jtarget->seq->len;j++) { LocalMotifMatrix_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; LocalMotifMatrix_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; LocalMotifMatrix_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_LocalMotifMatrix(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_LocalMotifMatrix(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_LocalMotifMatrix(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "SPACER_MATCH","SPACER_INSERT","MOTIF_MATCH","MOTIF_INSERT","CONS_MATCH","CONS_INSERT","END" }; /* Function: AlnConvertSet_LocalMotifMatrix(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "SPACER_MATCH","SPACER_INSERT","MOTIF_MATCH","MOTIF_INSERT","CONS_MATCH","CONS_INSERT","END" }; AlnConvertSet * AlnConvertSet_LocalMotifMatrix(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_MATCH; acu->state2 = SPACER_MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_MATCH; acu->state2 = SPACER_MATCH; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_MATCH; acu->state2 = SPACER_MATCH; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MOTIF_MATCH; acu->state2 = SPACER_MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CONS_MATCH; acu->state2 = SPACER_MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = SPACER_MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MOTIF_MATCH; acu->state2 = MOTIF_MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MOTIF_MATCH; acu->state2 = MOTIF_MATCH; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MOTIF_MATCH; acu->state2 = MOTIF_MATCH; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_MATCH; acu->state2 = MOTIF_MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CONS_MATCH; acu->state2 = CONS_MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CONS_MATCH; acu->state2 = CONS_MATCH; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[5]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CONS_MATCH; acu->state2 = CONS_MATCH; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_MATCH; acu->state2 = CONS_MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[6]; acu->label2 = target_label[6]; return out; } /* Function: PackAln_read_Expl_LocalMotifMatrix(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_LocalMotifMatrix(LocalMotifMatrix * mat) { LocalMotifMatrix_access_func_holder holder; holder.access_main = LocalMotifMatrix_explicit_access_main; holder.access_special = LocalMotifMatrix_explicit_access_special; return PackAln_read_generic_LocalMotifMatrix(mat,holder); } /* Function: LocalMotifMatrix_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LocalMotifMatrix_explicit_access_main(LocalMotifMatrix * mat,int i,int j,int state) { return LocalMotifMatrix_EXPL_MATRIX(mat,i,j,state); } /* Function: LocalMotifMatrix_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int LocalMotifMatrix_explicit_access_special(LocalMotifMatrix * mat,int i,int j,int state) { return LocalMotifMatrix_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_LocalMotifMatrix(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: h [UNKN ] Undocumented argument [LocalMotifMatrix_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_LocalMotifMatrix(LocalMotifMatrix * mat,LocalMotifMatrix_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_LocalMotifMatrix(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in LocalMotifMatrix_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_LocalMotifMatrix(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_LocalMotifMatrix(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == LocalMotifMatrix_READ_OFF_ERROR || j == LocalMotifMatrix_READ_OFF_ERROR || state == LocalMotifMatrix_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in LocalMotifMatrix_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_LocalMotifMatrix(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [LocalMotifMatrix_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_LocalMotifMatrix(LocalMotifMatrix * mat,int * ri,int * rj,int * state,boolean * isspecial,LocalMotifMatrix_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: LocalMotifMatrix_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void LocalMotifMatrix_debug_show_matrix(LocalMotifMatrix * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->seq->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State SPACER_MATCH %d\n",LocalMotifMatrix_EXPL_MATRIX(mat,i,j,SPACER_MATCH)); fprintf(ofp,"State MOTIF_MATCH %d\n",LocalMotifMatrix_EXPL_MATRIX(mat,i,j,MOTIF_MATCH)); fprintf(ofp,"State CONS_MATCH %d\n",LocalMotifMatrix_EXPL_MATRIX(mat,i,j,CONS_MATCH)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_LocalMotifMatrix(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [LocalMotifMatrix_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_LocalMotifMatrix(LocalMotifMatrix * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LocalMotifMatrix_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = LocalMotifMatrix_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In LocalMotifMatrix matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case SPACER_MATCH : temp = cscore - (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,CONS_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = CONS_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,CONS_MATCH); } return (*h.access_main)(mat,i - 1,j - 1,CONS_MATCH); } temp = cscore - (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MOTIF_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MOTIF_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MOTIF_MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MOTIF_MATCH); } temp = cscore - (mat->ms->spacer_indel) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,SPACER_MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SPACER_MATCH); } return (*h.access_main)(mat,i - 0,j - 1,SPACER_MATCH); } temp = cscore - (mat->ms->spacer_indel) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,SPACER_MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = SPACER_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,SPACER_MATCH); } return (*h.access_main)(mat,i - 1,j - 0,SPACER_MATCH); } temp = cscore - ((mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_duration)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,SPACER_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = SPACER_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,SPACER_MATCH); } return (*h.access_main)(mat,i - 1,j - 1,SPACER_MATCH); } warn("Major problem (!) - in LocalMotifMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MOTIF_MATCH : temp = cscore - ((MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->spacer_to_motif)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,SPACER_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = SPACER_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,SPACER_MATCH); } return (*h.access_main)(mat,i - 1,j - 1,SPACER_MATCH); } temp = cscore - (mat->ms->motif_indel) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MOTIF_MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MOTIF_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MOTIF_MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MOTIF_MATCH); } temp = cscore - (mat->ms->motif_indel) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MOTIF_MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MOTIF_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MOTIF_MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MOTIF_MATCH); } temp = cscore - ((MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->motif_duration)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MOTIF_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MOTIF_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MOTIF_MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MOTIF_MATCH); } warn("Major problem (!) - in LocalMotifMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CONS_MATCH : temp = cscore - ((mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_to_cons)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,SPACER_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = SPACER_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,SPACER_MATCH); } return (*h.access_main)(mat,i - 1,j - 1,SPACER_MATCH); } temp = cscore - (mat->ms->cons_indel) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CONS_MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = CONS_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CONS_MATCH); } return (*h.access_main)(mat,i - 0,j - 1,CONS_MATCH); } temp = cscore - (mat->ms->cons_indel) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,CONS_MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = CONS_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,CONS_MATCH); } return (*h.access_main)(mat,i - 1,j - 0,CONS_MATCH); } temp = cscore - ((mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->cons_duration)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,CONS_MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = CONS_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,CONS_MATCH); } return (*h.access_main)(mat,i - 1,j - 1,CONS_MATCH); } warn("Major problem (!) - in LocalMotifMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in LocalMotifMatrix read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_LocalMotifMatrix(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [LocalMotifMatrix_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_LocalMotifMatrix(LocalMotifMatrix * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LocalMotifMatrix_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = LocalMotifMatrix_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In LocalMotifMatrix matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source SPACER_MATCH is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,SPACER_MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = SPACER_MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,SPACER_MATCH); } return (*h.access_main)(mat,i - 0,j - 0,SPACER_MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in LocalMotifMatrix read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_LocalMotifMatrix(mat) * * Descrip: This function calculates the LocalMotifMatrix matrix when in explicit mode * To allocate the matrix use /allocate_Expl_LocalMotifMatrix * * * Arg: mat [UNKN ] LocalMotifMatrix which contains explicit basematrix memory [LocalMotifMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_LocalMotifMatrix(LocalMotifMatrix * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_LocalMotifMatrix, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("LocalMotifMatrix Matrix calculation: "); for(j=0;jms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_duration); /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-0,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-0,j-1,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score ) { score = temp; } /* From state MOTIF_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* From state CONS_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-1,CONS_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* From state START to state SPACER_MATCH */ temp = LocalMotifMatrix_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_EXPL_MATRIX(mat,i,j,SPACER_MATCH) = score; /* state SPACER_MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalMotifMatrix_EXPL_SPECIAL(mat,i,j,END) ) { LocalMotifMatrix_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state SPACER_MATCH */ /* For state MOTIF_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->motif_duration); /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-0,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score ) { score = temp; } /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-0,j-1,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->spacer_to_motif); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MOTIF_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_EXPL_MATRIX(mat,i,j,MOTIF_MATCH) = score; /* Finished calculating state MOTIF_MATCH */ /* For state CONS_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-1,CONS_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->cons_duration); /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-0,CONS_MATCH) + mat->ms->cons_indel; if( temp > score ) { score = temp; } /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-0,j-1,CONS_MATCH) + mat->ms->cons_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_to_cons); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CONS_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_EXPL_MATRIX(mat,i,j,CONS_MATCH) = score; /* Finished calculating state CONS_MATCH */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_LocalMotifMatrix(mat,dpenv) * * Descrip: This function calculates the LocalMotifMatrix matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] LocalMotifMatrix which contains explicit basematrix memory [LocalMotifMatrix *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_LocalMotifMatrix(LocalMotifMatrix * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_LocalMotifMatrix, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { LocalMotifMatrix_EXPL_MATRIX(mat,i,j,SPACER_MATCH) = NEGI; LocalMotifMatrix_EXPL_MATRIX(mat,i,j,MOTIF_MATCH) = NEGI; LocalMotifMatrix_EXPL_MATRIX(mat,i,j,CONS_MATCH) = NEGI; } } for(j=-1;jlenj;j++) { LocalMotifMatrix_EXPL_SPECIAL(mat,i,j,START) = 0; LocalMotifMatrix_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("LocalMotifMatrix Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { LocalMotifMatrix_EXPL_MATRIX(mat,i,j,SPACER_MATCH) = NEGI; LocalMotifMatrix_EXPL_MATRIX(mat,i,j,MOTIF_MATCH) = NEGI; LocalMotifMatrix_EXPL_MATRIX(mat,i,j,CONS_MATCH) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state SPACER_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_duration); /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-0,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-0,j-1,SPACER_MATCH) + mat->ms->spacer_indel; if( temp > score ) { score = temp; } /* From state MOTIF_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* From state CONS_MATCH to state SPACER_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-1,CONS_MATCH) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* From state START to state SPACER_MATCH */ temp = LocalMotifMatrix_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->ms->comp_spacer->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_EXPL_MATRIX(mat,i,j,SPACER_MATCH) = score; /* state SPACER_MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > LocalMotifMatrix_EXPL_SPECIAL(mat,i,j,END) ) { LocalMotifMatrix_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state SPACER_MATCH */ /* For state MOTIF_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-1,MOTIF_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->motif_duration); /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-0,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score ) { score = temp; } /* From state MOTIF_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-0,j-1,MOTIF_MATCH) + mat->ms->motif_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state MOTIF_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (MOTIF_MATRIX_IN(mat->motif,i,j,mat->ms->comp_in_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)])+mat->ms->spacer_to_motif); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MOTIF_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_EXPL_MATRIX(mat,i,j,MOTIF_MATCH) = score; /* Finished calculating state MOTIF_MATCH */ /* For state CONS_MATCH */ /* setting first movement to score */ score = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-1,CONS_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->cons_duration); /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-0,CONS_MATCH) + mat->ms->cons_indel; if( temp > score ) { score = temp; } /* From state CONS_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-0,j-1,CONS_MATCH) + mat->ms->cons_indel; if( temp > score ) { score = temp; } /* From state SPACER_MATCH to state CONS_MATCH */ temp = LocalMotifMatrix_EXPL_MATRIX(mat,i-1,j-1,SPACER_MATCH) + (mat->ms->comp_out_motif->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->ms->spacer_to_cons); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CONS_MATCH */ /* Add any movement independant score and put away */ LocalMotifMatrix_EXPL_MATRIX(mat,i,j,CONS_MATCH) = score; /* Finished calculating state CONS_MATCH */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: LocalMotifMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalMotifMatrix *] * */ LocalMotifMatrix * LocalMotifMatrix_alloc(void) { LocalMotifMatrix * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LocalMotifMatrix *) ckalloc (sizeof(LocalMotifMatrix))) == NULL) { warn("LocalMotifMatrix_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_LocalMotifMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalMotifMatrix *] * * Return [UNKN ] Undocumented return value [LocalMotifMatrix *] * */ LocalMotifMatrix * free_LocalMotifMatrix(LocalMotifMatrix * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LocalMotifMatrix obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->motif is linked in */ /* obj->ms is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/motifmatrixdp.h0000644000175000001440000005011010670453714017167 0ustar philippusers#ifndef DYNAMITEmotifmatrixdpHEADERFILE #define DYNAMITEmotifmatrixdpHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "motifmatrix.h" #define MOTIF_MATRIX_IN(motif,i,j,score) (motif->mat[i][j] == 0 ? 0 : (score)) struct Wise2_LocalMotifMatrix { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; ComplexSequence* query; ComplexSequence* target; MotifConsMatrix* motif; MotifMatrixScore* ms; } ; /* LocalMotifMatrix defined */ #ifndef DYNAMITE_DEFINED_LocalMotifMatrix typedef struct Wise2_LocalMotifMatrix Wise2_LocalMotifMatrix; #define LocalMotifMatrix Wise2_LocalMotifMatrix #define DYNAMITE_DEFINED_LocalMotifMatrix #endif struct Wise2_LocalMotifMatrix_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(LocalMotifMatrix*,int,int,int); int (*access_special)(LocalMotifMatrix*,int,int,int); } ; /* LocalMotifMatrix_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_LocalMotifMatrix_access_func_holder typedef struct Wise2_LocalMotifMatrix_access_func_holder Wise2_LocalMotifMatrix_access_func_holder; #define LocalMotifMatrix_access_func_holder Wise2_LocalMotifMatrix_access_func_holder #define DYNAMITE_DEFINED_LocalMotifMatrix_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_LocalMotifMatrix(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_LocalMotifMatrix(LocalMotifMatrix * mat); #define PackAln_read_Shatter_LocalMotifMatrix Wise2_PackAln_read_Shatter_LocalMotifMatrix /* Function: calculate_shatter_LocalMotifMatrix(mat,dpenv) * * Descrip: This function calculates the LocalMotifMatrix matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [LocalMotifMatrix *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_LocalMotifMatrix(LocalMotifMatrix * mat,DPEnvelope * dpenv); #define calculate_shatter_LocalMotifMatrix Wise2_calculate_shatter_LocalMotifMatrix /* Function: search_LocalMotifMatrix(dbsi,out,query,target,motif,ms) * * Descrip: This function makes a database search of LocalMotifMatrix * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: motif [UNKN ] Undocumented argument [MotifConsMatrix*] * Arg: ms [UNKN ] Undocumented argument [MotifMatrixScore*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_LocalMotifMatrix(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms); #define search_LocalMotifMatrix Wise2_search_LocalMotifMatrix /* Function: serial_search_LocalMotifMatrix(out,query,target,motif,ms) * * Descrip: This function makes a database search of LocalMotifMatrix * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: motif [UNKN ] Undocumented argument [MotifConsMatrix*] * Arg: ms [UNKN ] Undocumented argument [MotifMatrixScore*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_LocalMotifMatrix(Hscore * out,ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms); #define serial_search_LocalMotifMatrix Wise2_serial_search_LocalMotifMatrix /* Function: PackAln_bestmemory_LocalMotifMatrix(query,target,motif,ms,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_LocalMotifMatrix * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: motif [UNKN ] Resource [MotifConsMatrix*] * Arg: ms [UNKN ] Resource [MotifMatrixScore*] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_LocalMotifMatrix(ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_LocalMotifMatrix Wise2_PackAln_bestmemory_LocalMotifMatrix /* Function: allocate_Expl_LocalMotifMatrix(query,target,motif,ms,dpri) * * Descrip: This function allocates the LocalMotifMatrix structure * and the basematrix area for explicit memory implementations * It calls /allocate_LocalMotifMatrix_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: motif [UNKN ] Resource [MotifConsMatrix*] * Arg: ms [UNKN ] Resource [MotifMatrixScore*] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [LocalMotifMatrix *] * */ LocalMotifMatrix * Wise2_allocate_Expl_LocalMotifMatrix(ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms,DPRunImpl * dpri); #define allocate_Expl_LocalMotifMatrix Wise2_allocate_Expl_LocalMotifMatrix /* Function: recalculate_PackAln_LocalMotifMatrix(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by LocalMotifMatrix * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * */ void Wise2_recalculate_PackAln_LocalMotifMatrix(PackAln * pal,LocalMotifMatrix * mat); #define recalculate_PackAln_LocalMotifMatrix Wise2_recalculate_PackAln_LocalMotifMatrix /* Function: allocate_Small_LocalMotifMatrix(query,target,motif,ms) * * Descrip: This function allocates the LocalMotifMatrix structure * and the basematrix area for a small memory implementations * It calls /allocate_LocalMotifMatrix_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: motif [UNKN ] Resource [MotifConsMatrix*] * Arg: ms [UNKN ] Resource [MotifMatrixScore*] * * Return [UNKN ] Undocumented return value [LocalMotifMatrix *] * */ LocalMotifMatrix * Wise2_allocate_Small_LocalMotifMatrix(ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms); #define allocate_Small_LocalMotifMatrix Wise2_allocate_Small_LocalMotifMatrix /* Function: PackAln_calculate_Small_LocalMotifMatrix(mat,dpenv) * * Descrip: This function calculates an alignment for LocalMotifMatrix structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_LocalMotifMatrix * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_LocalMotifMatrix * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_LocalMotifMatrix(LocalMotifMatrix * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_LocalMotifMatrix Wise2_PackAln_calculate_Small_LocalMotifMatrix /* Function: AlnRangeSet_calculate_Small_LocalMotifMatrix(mat) * * Descrip: This function calculates an alignment for LocalMotifMatrix structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_LocalMotifMatrix * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_LocalMotifMatrix * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_LocalMotifMatrix * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_LocalMotifMatrix(LocalMotifMatrix * mat); #define AlnRangeSet_calculate_Small_LocalMotifMatrix Wise2_AlnRangeSet_calculate_Small_LocalMotifMatrix /* Function: AlnRangeSet_from_LocalMotifMatrix(mat) * * Descrip: This function reads off a start/end structure * for LocalMotifMatrix structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_LocalMotifMatrix * If you have not calculated the matrix use * /AlnRange_calculate_Small_LocalMotifMatrix * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_LocalMotifMatrix(LocalMotifMatrix * mat); #define AlnRangeSet_from_LocalMotifMatrix Wise2_AlnRangeSet_from_LocalMotifMatrix /* Function: convert_PackAln_to_AlnBlock_LocalMotifMatrix(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_LocalMotifMatrix(PackAln * pal); #define convert_PackAln_to_AlnBlock_LocalMotifMatrix Wise2_convert_PackAln_to_AlnBlock_LocalMotifMatrix /* Function: PackAln_read_Expl_LocalMotifMatrix(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_LocalMotifMatrix(LocalMotifMatrix * mat); #define PackAln_read_Expl_LocalMotifMatrix Wise2_PackAln_read_Expl_LocalMotifMatrix /* Function: PackAln_read_generic_LocalMotifMatrix(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [LocalMotifMatrix *] * Arg: h [UNKN ] Undocumented argument [LocalMotifMatrix_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_LocalMotifMatrix(LocalMotifMatrix * mat,LocalMotifMatrix_access_func_holder h); #define PackAln_read_generic_LocalMotifMatrix Wise2_PackAln_read_generic_LocalMotifMatrix /* Function: calculate_LocalMotifMatrix(mat) * * Descrip: This function calculates the LocalMotifMatrix matrix when in explicit mode * To allocate the matrix use /allocate_Expl_LocalMotifMatrix * * * Arg: mat [UNKN ] LocalMotifMatrix which contains explicit basematrix memory [LocalMotifMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_LocalMotifMatrix(LocalMotifMatrix * mat); #define calculate_LocalMotifMatrix Wise2_calculate_LocalMotifMatrix /* Function: calculate_dpenv_LocalMotifMatrix(mat,dpenv) * * Descrip: This function calculates the LocalMotifMatrix matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] LocalMotifMatrix which contains explicit basematrix memory [LocalMotifMatrix *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_LocalMotifMatrix(LocalMotifMatrix * mat,DPEnvelope * dpenv); #define calculate_dpenv_LocalMotifMatrix Wise2_calculate_dpenv_LocalMotifMatrix /* Function: LocalMotifMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalMotifMatrix *] * */ LocalMotifMatrix * Wise2_LocalMotifMatrix_alloc(void); #define LocalMotifMatrix_alloc Wise2_LocalMotifMatrix_alloc /* Function: free_LocalMotifMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalMotifMatrix *] * * Return [UNKN ] Undocumented return value [LocalMotifMatrix *] * */ LocalMotifMatrix * Wise2_free_LocalMotifMatrix(LocalMotifMatrix * obj); #define free_LocalMotifMatrix Wise2_free_LocalMotifMatrix /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_LocalMotifMatrix_shatter_access_main(LocalMotifMatrix * mat,int i,int j,int state); #define LocalMotifMatrix_shatter_access_main Wise2_LocalMotifMatrix_shatter_access_main int Wise2_LocalMotifMatrix_shatter_access_special(LocalMotifMatrix * mat,int i,int j,int state); #define LocalMotifMatrix_shatter_access_special Wise2_LocalMotifMatrix_shatter_access_special int Wise2_score_only_LocalMotifMatrix(ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms); #define score_only_LocalMotifMatrix Wise2_score_only_LocalMotifMatrix LocalMotifMatrix * Wise2_allocate_LocalMotifMatrix_only(ComplexSequence* query,ComplexSequence* target ,MotifConsMatrix* motif,MotifMatrixScore* ms); #define allocate_LocalMotifMatrix_only Wise2_allocate_LocalMotifMatrix_only void Wise2_init_LocalMotifMatrix(LocalMotifMatrix * mat); #define init_LocalMotifMatrix Wise2_init_LocalMotifMatrix AlnRange * Wise2_AlnRange_build_LocalMotifMatrix(LocalMotifMatrix * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_LocalMotifMatrix Wise2_AlnRange_build_LocalMotifMatrix boolean Wise2_read_hidden_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_LocalMotifMatrix Wise2_read_hidden_LocalMotifMatrix int Wise2_max_hidden_LocalMotifMatrix(LocalMotifMatrix * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_LocalMotifMatrix Wise2_max_hidden_LocalMotifMatrix boolean Wise2_read_special_strip_LocalMotifMatrix(LocalMotifMatrix * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_LocalMotifMatrix Wise2_read_special_strip_LocalMotifMatrix int Wise2_max_special_strip_LocalMotifMatrix(LocalMotifMatrix * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_LocalMotifMatrix Wise2_max_special_strip_LocalMotifMatrix int Wise2_max_matrix_to_special_LocalMotifMatrix(LocalMotifMatrix * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_LocalMotifMatrix Wise2_max_matrix_to_special_LocalMotifMatrix void Wise2_calculate_hidden_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_LocalMotifMatrix Wise2_calculate_hidden_LocalMotifMatrix void Wise2_init_hidden_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_LocalMotifMatrix Wise2_init_hidden_LocalMotifMatrix boolean Wise2_full_dc_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_LocalMotifMatrix Wise2_full_dc_LocalMotifMatrix boolean Wise2_do_dc_single_pass_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_LocalMotifMatrix Wise2_do_dc_single_pass_LocalMotifMatrix void Wise2_push_dc_at_merge_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_LocalMotifMatrix Wise2_push_dc_at_merge_LocalMotifMatrix void Wise2_follow_on_dc_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_LocalMotifMatrix Wise2_follow_on_dc_LocalMotifMatrix void Wise2_run_up_dc_LocalMotifMatrix(LocalMotifMatrix * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_LocalMotifMatrix Wise2_run_up_dc_LocalMotifMatrix void Wise2_init_dc_LocalMotifMatrix(LocalMotifMatrix * mat); #define init_dc_LocalMotifMatrix Wise2_init_dc_LocalMotifMatrix int Wise2_start_end_find_end_LocalMotifMatrix(LocalMotifMatrix * mat,int * endj); #define start_end_find_end_LocalMotifMatrix Wise2_start_end_find_end_LocalMotifMatrix boolean Wise2_dc_optimised_start_end_calc_LocalMotifMatrix(LocalMotifMatrix *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_LocalMotifMatrix Wise2_dc_optimised_start_end_calc_LocalMotifMatrix void Wise2_init_start_end_linear_LocalMotifMatrix(LocalMotifMatrix * mat); #define init_start_end_linear_LocalMotifMatrix Wise2_init_start_end_linear_LocalMotifMatrix AlnConvertSet * Wise2_AlnConvertSet_LocalMotifMatrix(void); #define AlnConvertSet_LocalMotifMatrix Wise2_AlnConvertSet_LocalMotifMatrix int Wise2_LocalMotifMatrix_explicit_access_main(LocalMotifMatrix * mat,int i,int j,int state); #define LocalMotifMatrix_explicit_access_main Wise2_LocalMotifMatrix_explicit_access_main int Wise2_LocalMotifMatrix_explicit_access_special(LocalMotifMatrix * mat,int i,int j,int state); #define LocalMotifMatrix_explicit_access_special Wise2_LocalMotifMatrix_explicit_access_special int Wise2_find_end_LocalMotifMatrix(LocalMotifMatrix * mat,int * ri,int * rj,int * state,boolean * isspecial,LocalMotifMatrix_access_func_holder h); #define find_end_LocalMotifMatrix Wise2_find_end_LocalMotifMatrix void Wise2_LocalMotifMatrix_debug_show_matrix(LocalMotifMatrix * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define LocalMotifMatrix_debug_show_matrix Wise2_LocalMotifMatrix_debug_show_matrix int Wise2_max_calc_LocalMotifMatrix(LocalMotifMatrix * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LocalMotifMatrix_access_func_holder h); #define max_calc_LocalMotifMatrix Wise2_max_calc_LocalMotifMatrix int Wise2_max_calc_special_LocalMotifMatrix(LocalMotifMatrix * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,LocalMotifMatrix_access_func_holder h); #define max_calc_special_LocalMotifMatrix Wise2_max_calc_special_LocalMotifMatrix #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/pba.dy0000644000175000001440000000364007313404547015235 0ustar philippusers %{ #include "dyna.h" %} matrix ProteinBlockAligner query name="q" type="PROTEIN" target name="t" type="PROTEIN" resource name="m" type="COMPMAT" resource name="bentry" type="Score" resource name="bexit" type="Score" resource name="bfor_trans" type="Score" resource name="b_self_trans" type="Score" resource name="b3exit" type="Score" state BLOCK_1 calc="AAMATCH(m,AMINOACID(q,i),AMINOACID(t,j))" source BLOCK_1 offi="1" offj="1" calc="b_self_trans" endsource source START offi="1" offj="1" calc="0" endsource source UNALIGNED offi="1" offj="1" calc="bentry" endsource query_label SEQUENCE_BLOCK_1 target_label SEQUENCE_BLOCK_1 endstate state BLOCK_2 calc="AAMATCH(m,AMINOACID(q,i),AMINOACID(t,j))" source BLOCK_2 offi="1" offj="1" calc="b_self_trans" endsource source BLOCK_1 offi="1" offj="1" calc="bfor_trans" endsource query_label SEQUENCE_BLOCK_2 target_label SEQUENCE_BLOCK_2 endstate state BLOCK_3 calc="AAMATCH(m,AMINOACID(q,i),AMINOACID(t,j))" source BLOCK_3 offi="1" offj="1" calc="b_self_trans" endsource source BLOCK_2 offi="1" offj="1" calc="bfor_trans" endsource query_label SEQUENCE_BLOCK_2 target_label SEQUENCE_BLOCK_2 endstate state UNALIGNED source BLOCK_1 offi="0" offj="1" calc="bexit" endsource source BLOCK_1 offi="1" offj="0" calc="bexit" endsource source BLOCK_2 offi="0" offj="1" calc="b3exit" endsource source BLOCK_2 offi="1" offj="0" calc="b3exit" endsource source UNALIGNED offi="0" offj="1" calc="0" endsource source UNALIGNED offi="1" offj="0" calc="0" endsource query_label UNALIGNED target_label UNALIGNED endstate state START !start !special endstate state END !end !special source UNALIGNED calc="0" endsource source BLOCK_1 calc="0" endsource query_label END target_label END endstate endmatrix %{ #include "pba.h" %} wise-2.4.1/src/models/sw_wrap.typemap0000644000175000001440000000000010670453715017204 0ustar philippuserswise-2.4.1/src/models/pseudowise.c0000644000175000001440000001610507536707717016504 0ustar philippusers#include "version.h" #include "genestats.h" #include "geneutil.h" #include "standardout.h" #include "pseudowise7.h" #include "genedisplay.h" #include "genewise6.h" char * program_name = "pseudowise"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s query-protein-as-fasta query-cdna-as-fasta target-genomic-region\n",program_name); fprintf(ofp," -pretty show pretty output\n"); show_help_GeneModelParam(ofp); show_help_StandardOutputOptions(ofp); show_help_DPRunImpl(ofp); show_standard_options(ofp); } typedef struct { double gene_model; double pseudo_model; int synonymous; int nonsynonymous; int unlikely; int frameshift; int identical; int stop; int codon; int intron; } PseudoGeneAssessment; PseudoGeneAssessment pseudo_gene_assessment(AlnBlock * alb,Sequence * pep,Sequence * cdna,Sequence *gen,CompMat * protein,CodonTable * ct,double subs,double indel) { int aa; int gen_pos; int pep_pos; int i,j; AlnColumn * alc; PseudoGeneAssessment out; out.gene_model = 1.0; out.pseudo_model = 1.0; out.synonymous = 0; out.nonsynonymous = 0; out.identical = 0; out.unlikely = 0; out.frameshift = 0; out.stop = 0; out.codon = 0; out.intron = 0; for(alc=alb->start;alc!=NULL;alc = alc->next ) { gen_pos = alc->alu[1]->start+1; pep_pos = alc->alu[0]->start+1; if( strcmp(alc->alu[1]->text_label,"CODON") == 0 && strcmp(alc->alu[0]->text_label,"MATCH_STATE") == 0 ) { out.codon++; if( is_stop_codon(codon_from_seq(gen->seq+gen_pos),ct) ) { out.stop++; continue; } aa = aminoacid_from_seq(ct,gen->seq+gen_pos); /* see if there has been a synomous codon change here */ if( aa == pep->seq[pep_pos] ) { if( cdna->seq[pep_pos*3] != gen->seq[gen_pos] || cdna->seq[pep_pos*3+1] != gen->seq[gen_pos+1] || cdna->seq[pep_pos*3+2] != gen->seq[gen_pos+2] ) { out.synonymous++; } else { /* identical codon */ out.identical++; } } else { out.nonsynonymous++; if( protein->comp[aa][pep->seq[pep_pos]] < 0 ) { out.unlikely++; } } } else if ( strstr(alc->alu[1]->text_label,"SEQUENCE_DELETION") != NULL ) { out.frameshift++; } else if ( strstr(alc->alu[1]->text_label,"SEQUENCE_INSERTION") != NULL ) { out.frameshift++; } else if( strstr(alc->alu[1]->text_label,"5SS") != NULL ) { out.intron++; } } return out; } int check_pep_cdna_synchrony(Sequence * cdna,Sequence * pep,CodonTable * ct) { int i; assert(cdna); assert(pep); if( ! (is_dna_SequenceType(cdna->type)) ) { fatal("cDNA sequnece is not DNA!"); } for(i=0;ilen;i++) { if( pep->seq[i] != aminoacid_from_seq(ct,cdna->seq+(i*3)) ) { fatal("cDNA sequence does not match up with peptide sequence"); } } return 0; } int main(int argc,char ** argv) { DPRunImpl * dpri = NULL; GeneModelParam * gmp = NULL; GeneModel * gm = NULL; CodonTable * ct = NULL; Sequence * prot = NULL; Protein * protein = NULL; Sequence * cdna = NULL; Sequence * genomic = NULL; Genomic * gen = NULL; ComplexSequenceEvalSet * cses = NULL; ComplexSequence * cseq = NULL; ThreeStateModel * tsm; GeneWise * gw; GeneWiseScore * gws; GeneParser4Score * gps; GeneParser4 * gp; GenomicRegion * gr; CodonMapper * cm = NULL; StandardOutputOptions * std_opt; boolean show_pretty = FALSE; PackAln * pal; AlnBlock * alb; PseudoGeneAssessment pa; boolean use_genewise= TRUE; char * matrix = "blosum62.bla"; CompMat * mat; double indel_rate = 0.01; double subs_rate = 0.01; int offset; RandomModel * rm; RandomModelDNA * rmd; dpri = new_DPRunImpl_from_argv(&argc,argv); if( dpri == NULL ) { fatal("Unable to build DPRun implementation. Bad arguments"); } gmp = new_GeneModelParam_from_argv(&argc,argv); strip_out_boolean_def_argument(&argc,argv,"pretty",&show_pretty); std_opt = new_StandardOutputOptions_from_argv(&argc,argv); strip_out_boolean_def_argument(&argc,argv,"gw",&use_genewise); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 4 ) { show_help(stdout); exit(12); } if((gm=GeneModel_from_GeneModelParam(gmp)) == NULL ) { fatal("Could not build gene model"); } ct= read_CodonTable_file("codon.table"); prot = read_fasta_file_Sequence(argv[1]); cdna = read_fasta_file_Sequence(argv[2]); genomic = read_fasta_file_Sequence(argv[3]); if( prot == NULL || cdna == NULL || genomic == NULL ) { fatal("need to have 3 sequences- protein guide, cdna and genomic"); } offset = check_pep_cdna_synchrony(cdna,prot,ct); rm = default_RandomModel(); rmd = RandomModelDNA_std(); mat = read_Blast_file_CompMat(matrix); cm = flat_CodonMapper(ct); sprinkle_errors_over_CodonMapper(cm,subs_rate); protein = Protein_from_Sequence(prot); tsm = ThreeStateModel_from_half_bit_Sequence(protein,mat,rm,-11,-1); gw = GeneWise_from_ThreeStateModel(tsm,NULL,cm,0.0001,NULL); cses = new_ComplexSequenceEvalSet_from_GeneModel(gm); cseq = new_ComplexSequence(genomic,cses); gp = std_GeneParser4(indel_rate,indel_rate*0.1); gps = GeneParser4Score_from_GeneParser4(gp); GeneWise_fold_in_RandomModelDNA(gw,rmd); gws = GeneWiseScore_from_GeneWise(gw); if( use_genewise ) { pal = PackAln_bestmemory_GeneWise6(gws,cseq,gps,NULL,dpri); alb = convert_PackAln_to_AlnBlock_GeneWise6(pal); } else { pal = PackAln_bestmemory_PseudoWise7(gws,cseq,gps,Probability2Score(indel_rate),NULL,dpri); alb = convert_PackAln_to_AlnBlock_PseudoWise7(pal); } show_StandardOutputOptions(std_opt,alb,pal,"//",stdout); pa = pseudo_gene_assessment(alb, prot, cdna, genomic, mat,ct,subs_rate,indel_rate); printf("Synonymous : %d\n",pa.synonymous); printf("Nonsynonymous : %d\n",pa.nonsynonymous); printf("Ka/Ks : %.2f\n",(double)pa.nonsynonymous/(double)pa.synonymous); printf("Unlikely : %d\n",pa.unlikely); printf("Identical : %d\n",pa.identical); printf("Stop : %d\n",pa.stop); printf("Total codons : %d\n",pa.codon); printf("Frameshift : %d\n",pa.frameshift); printf("Intron : %d\n",pa.intron); printf("//\n"); gen = Genomic_from_Sequence(genomic); gr = new_GenomicRegion_from_GeneWise(gen,FALSE,alb); show_pretty_GenomicRegion(gr,0,stdout); printf("//\n"); if( show_pretty) { protgene_ascii_display(alb,prot->seq,prot->name,prot->offset,gen,ct,15,50,FALSE, stdout); } return 0; } wise-2.4.1/src/models/genomewise.c0000644000175000001440000001335307534626466016460 0ustar philippusers#include "est_evidence.h" #include "genomewise9.h" #include "geneutil.h" #include "geneoutput.h" #include "version.h" char * program_name = "genomewise"; void debug_genomewise(AlnBlock * alb,GenomeEvidenceSet * ges,CodonTable * ct,Sequence * gen,FILE * ofp); void show_utr_exon_genomewise(AlnBlock * alb,FILE * ofp); void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s genomic-fasta-file evidence-file\n",program_name); fprintf(ofp," ** Genomewise is designed to work with the Ensembl EST build system\n"); fprintf(ofp," ** Although you can reuse it directly, alot of the magic occurs in \n"); fprintf(ofp," ** the Ensembl Runnable/RunnableDB system behind this. see www.ensembl.org \n\n"); fprintf(ofp," evidence file should have exon,cds and indel lines separated by //\n"); fprintf(ofp," between predictions (multiple predictions ok)\n"); fprintf(ofp," exon start end -- means exon prediction, no phase restriction\n"); fprintf(ofp," cds start end phase -- means exon prediction, only in that phase\n"); fprintf(ofp," indel start end -- allow frameshifting in this area\n"); fprintf(ofp,"eg - \n"); fprintf(ofp,"exon 120 340\n"); fprintf(ofp,"exon 560 591\n"); fprintf(ofp,"//\n"); fprintf(ofp,"cds 12 56 0\n"); fprintf(ofp,"cds 70 80 1\n"); fprintf(ofp,"\n\nOPTIONS (can occur anywhere on the command line\n"); fprintf(ofp,"Scoring\n"); fprintf(ofp," -start no start codon penalty 30\n"); fprintf(ofp," -stop no stop codon penalty 200\n"); fprintf(ofp," -gene new gene cost 5000\n"); fprintf(ofp," -switch evidence switch cost 100\n"); fprintf(ofp," -smell smell space used for out-phase splice sites 8\n"); show_help_GeneOutputPara(ofp); show_help_DPRunImpl(ofp); show_standard_options(ofp); } int main(int argc,char ** argv) { Sequence * gen; Genomic * genomic; CodonTable * ct = NULL; GenomeEvidenceSet * ges = NULL; RandomCodonScore * rcs; FILE * ifp = NULL; ComplexSequence * cs = NULL; ComplexSequenceEvalSet * cses = NULL; AlnBlock * alb; PackAln * pal; GenomicRegion * gr; int i; int kbyte = 10000; int stop_codon_pen = 200; int start_codon_pen = 30; int new_gene = 5000; int switch_cost = 100; int smell = 8; DPRunImpl * dpri = NULL; GeneOutputPara * geneout = NULL; GeneOutputData data; EstEvidence * est; boolean show_debug = FALSE; char * divide_string = "//"; strip_out_boolean_def_argument(&argc,argv,"debug",&show_debug); strip_out_integer_argument(&argc,argv,"stop",&stop_codon_pen); strip_out_integer_argument(&argc,argv,"start",&start_codon_pen); strip_out_integer_argument(&argc,argv,"gene",&new_gene); strip_out_integer_argument(&argc,argv,"switch",&switch_cost); strip_out_integer_argument(&argc,argv,"smell",&smell); dpri = new_DPRunImpl_from_argv(&argc,argv); if( dpri == NULL ) { fatal("Unable to build DPRun implementation. Bad arguments"); } geneout = new_GeneOutputPara_from_argv(&argc,argv); assert(geneout); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 3 ) { show_help(stdout); exit(12); } ct = read_CodonTable_file("codon.table"); /* fprintf(stderr,"Codon table is %d\n",ct);*/ gen = read_fasta_file_Sequence(argv[1]); ifp = openfile(argv[2],"r"); ges = read_est_evidence(ifp,ct); for(i=0;ilen;i++) { est = (EstEvidence *) (ges->geu[i]->data); est->in_smell = smell; } rcs= RandomCodonScore_alloc(); for(i=0;i<125;i++) { if( is_stop_codon(i,ct) ) { rcs->codon[i] = -1000000; } else { rcs->codon[i] = 0; } /* fprintf(stderr,"Got %d for %d\n",rcs->codon[i],i); */ } cses = default_genomic_ComplexSequenceEvalSet(); cs = new_ComplexSequence(gen,cses); pal = PackAln_bestmemory_GenomeWise9(ges,cs,-switch_cost,-new_gene,-start_codon_pen,-stop_codon_pen,rcs,NULL,dpri); alb = convert_PackAln_to_AlnBlock_GenomeWise9(pal); genomic = Genomic_from_Sequence(gen); gr = new_GenomicRegion(genomic); add_Genes_to_GenomicRegion_GeneWise(gr,1,gen->len,alb,gen->name,0,NULL); data.pal = pal; data.alb = alb; data.gr = gr; data.gen = genomic; data.ct = ct; show_GeneOutput(&data,geneout,stdout); if( show_debug ) { debug_genomewise(alb,ges,ct,gen,stdout); fprintf(stdout,"%s\n",geneout->divide_string); } return 0; } void debug_genomewise(AlnBlock * alb,GenomeEvidenceSet * ges,CodonTable * ct,Sequence * gen,FILE * ofp) { AlnColumn *alc; int cstart; for(alc=alb->start;alc != NULL;alc = alc->next ) { fprintf(ofp,"%4d %12s %12s [%3d][%5d %5d] ",alc->alu[1]->score[0],alc->alu[0]->text_label,alc->alu[1]->text_label,alc->alu[0]->start,alc->alu[1]->start+1,alc->alu[1]->end); if( strstartcmp(alc->alu[1]->text_label,"CODON") == 0 ) { cstart = alc->alu[1]->start+1; fprintf(ofp,"%c%c%c %c\n",gen->seq[cstart],gen->seq[cstart+1],gen->seq[cstart+2],aminoacid_from_seq(ct,gen->seq+cstart)); } else { for (cstart = alc->alu[1]->start+1; cstart <= alc->alu[1]->end; cstart++) { fprintf(ofp,"%c",gen->seq[cstart]); } fprintf(ofp,"\n"); } } } wise-2.4.1/src/models/testgenestat.c0000644000175000001440000000132407346410113017000 0ustar philippusers#include "genestats.h" #include #include #include "sequence.h" int main(int argc,char ** argv) { Sequence * seq; ComplexSequence * cs; ComplexSequenceEvalSet * cset; GeneStats * st; GeneModel * gm; GeneModelParam * gp; FILE * ifp; gp = std_GeneModelParam(); seq = read_fasta_file_Sequence("../../test_data/human.genomic"); ifp = openfile("gene.stat","r"); st = read_GeneStats(ifp); /* dump_GeneStats(st,stdout); */ fflush(stdout); gm = GeneModel_from_GeneStats(st,gp); show_GeneModel(gm,stdout); fflush(stdout); cset = new_ComplexSequenceEvalSet_from_GeneModel(gm); cs = new_ComplexSequence(seq,cset); show_ComplexSequence(cs,stdout); } wise-2.4.1/src/models/geneparser21.c0000644000175000001440000002733310670453714016604 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "geneparser21.h" # line 64 "geneparser21.dy" RandomModelDNA * fudged_mixed_RandomModelDNA_from_GeneParser21(GeneParser21 * gp,RandomModelDNA * rnd) { RandomModelDNA * out; int i; out = RandomModelDNA_alloc(); #define PROBMAX(this,that) (this > that ? this : that) for(i=0;i<5;i++) { out->base[i] = PROBMAX(PROBMAX(gp->central[i],gp->py[i]),PROBMAX(gp->spacer[i],rnd->base[i]))/rnd->base[i]; } #undef PROBMAX return out; } /*** Adds the error probabilities ***/ # line 89 "geneparser21.dy" void add_flat_error_probabilities_GeneParser21(GeneParser21 * gp21,Probability error) { add_error_probabilities_GeneParser21(gp21,error,error,error,error); } # line 94 "geneparser21.dy" void add_error_probabilities_GeneParser21(GeneParser21 * gp21,Probability insert_1,Probability insert_2,Probability delete_1,Probability delete_2) { gp21->transition[GP21_INSERT_1_BASE] = insert_1; gp21->transition[GP21_INSERT_2_BASE] = insert_2; gp21->transition[GP21_DELETE_1_BASE] = delete_1; gp21->transition[GP21_DELETE_2_BASE] = delete_2; } /**** Makes the GeneParser21 structure, which essentially has transition probabilities for geneparsing this sets everything to zero and then only allocates gene parsing probs. Frameshifting error is not delt with here. ****/ # line 116 "geneparser21.dy" GeneParser21 * GeneParser21_from_GeneFrequency21_cds(GeneFrequency21 * gf,Probability rnd_loop,Probability cds_loop,Probability rnd_to_model,Probability link_loop,Probability link_to_model) { GeneParser21 * out; register int i; double total; out = GeneParser21_alloc(); set_Probability_array(out->transition,0.0,GENEPARSER21_TRANSITION_LEN); set_Probability_array(out->central,0.0,GENEPARSER21_EMISSION_LEN); set_Probability_array(out->spacer,0.0,GENEPARSER21_EMISSION_LEN); set_Probability_array(out->py,0.0,GENEPARSER21_EMISSION_LEN); total = sum_Probability_array(gf->central,4); for(i=0;i<4;i++) { out->central[i] = gf->central[i]/total; } out->central[4] = 1.0; total = sum_Probability_array(gf->py,4); for(i=0;i<4;i++) { out->py[i] = gf->py[i]/total; } out->py[4] = 1.0; total = sum_Probability_array(gf->spacer,4); for(i=0;i<4;i++) { out->spacer[i] = gf->spacer[i]/total; } out->spacer[4] = 1.0; out->transition[GP21_CENTRAL2CENTRAL] = gf->transition[GF21_CENTRAL_STAY]; out->transition[GP21_CENTRAL2PY] = 1- gf->transition[GF21_CENTRAL_STAY]; out->transition[GP21_PY2PY] = gf->transition[GF21_PY_STAY]; out->transition[GP21_PY2SPACER] = 1 - gf->transition[GF21_PY_STAY] * (1-gf->transition[GF21_NO_SPACER]); out->transition[GP21_PY2CDS] = 1 - gf->transition[GF21_PY_STAY] * (gf->transition[GF21_NO_SPACER]); out->transition[GP21_SPACER2SPACER] = gf->transition[GF21_SPACER_STAY]; out->transition[GP21_SPACER2CDS] = 1 - gf->transition[GF21_SPACER_STAY]; out->transition[GP21_CDS2CDS] = cds_loop; out->transition[GP21_CDS2RND] = (1-cds_loop); out->transition[GP21_RND2RND] = rnd_loop; /* fprintf(stderr,"Score is %f\n",out->transition[GP21_RND2RND]); */ out->transition[GP21_RND2CDS] = (1-rnd_loop-rnd_to_model); out->transition[GP21_RND2MODEL] = rnd_to_model; out->transition[GP21_LINK2MODEL] = link_to_model; out->transition[GP21_LINK2LINK] = link_loop; out->transition[GP21_LINK2RND] = (1- link_loop - link_to_model) ; return out; } # line 173 "geneparser21.dy" RandomModelDNA * RandomModelDNA_from_central_GeneParser21(GeneParser21 *gp21) { RandomModelDNA * rmd; rmd = RandomModelDNA_alloc(); if( rmd == NULL ) return NULL; rmd->base[BASE_A] = gp21->central[BASE_A]; rmd->base[BASE_T] = gp21->central[BASE_T]; rmd->base[BASE_G] = gp21->central[BASE_G]; rmd->base[BASE_C] = gp21->central[BASE_C]; rmd->base[BASE_N] = gp21->central[BASE_N]; return rmd; } # line 190 "geneparser21.dy" void show_GeneParser21(GeneParser21 * gp21,FILE * ofp) { fprintf(ofp,"Central emissions\n"); show_Probability_array(gp21->central,GENEPARSER21_EMISSION_LEN,ofp); fprintf(ofp,"\nPyrimidine emissions\n"); show_Probability_array(gp21->py,GENEPARSER21_EMISSION_LEN,ofp); fprintf(ofp,"\nSpacer emissions\n"); show_Probability_array(gp21->spacer,GENEPARSER21_EMISSION_LEN,ofp); fprintf(ofp,"\nTransitions\n"); show_Probability_array(gp21->transition,GENEPARSER21_TRANSITION_LEN,ofp); } # line 204 "geneparser21.dy" GeneParser21 * std_GeneParser21(void) { GeneParser21 * out; out = GeneParser21_alloc(); out->central[BASE_T] = 0.25; out->central[BASE_G] = 0.25; out->central[BASE_C] = 0.25; out->central[BASE_A] = 0.25; out->py[BASE_T] = 0.4; out->py[BASE_C] = 0.4; out->py[BASE_G] = 0.1; out->py[BASE_A] = 0.1; out->spacer[BASE_T] = 0.4; out->spacer[BASE_G] = 0.2; out->spacer[BASE_C] = 0.2; out->spacer[BASE_A] = 0.2; out->central[BASE_N] = out->py[BASE_N] = out->spacer[BASE_N] = 1.0; out->transition[GP21_CDS2CENTRAL] = 0.0; out->transition[GP21_CENTRAL2CENTRAL] = 0.998; out->transition[GP21_CENTRAL2PY] = 0.002; out->transition[GP21_PY2PY] = 0.94; out->transition[GP21_PY2CDS] = 0.01; out->transition[GP21_PY2SPACER] = 0.05; out->transition[GP21_SPACER2SPACER] = 0.9; out->transition[GP21_SPACER2CDS] = 0.1; out->transition[GP21_INSERT_1_BASE] = 0.001; out->transition[GP21_INSERT_2_BASE] = 0.001; out->transition[GP21_DELETE_1_BASE] = 0.002; out->transition[GP21_DELETE_2_BASE] = 0.003; return out; } # line 246 "geneparser21.dy" Probability removed_probability_from_cds(GeneParser21 * gp21) { Probability ret; ret = gp21->transition[GP21_INSERT_1_BASE] + gp21->transition[GP21_INSERT_2_BASE] + gp21->transition[GP21_DELETE_2_BASE] + gp21->transition[GP21_DELETE_1_BASE]; return ret; } # line 259 "geneparser21.dy" void GeneParser21_fold_in_RandomModelDNA(GeneParser21 * gp21,RandomModelDNA * rmd) { (void)Probability_array_divide(gp21->central,gp21->central,rmd->base,5); (void)Probability_array_divide(gp21->py,gp21->py,rmd->base,5); (void)Probability_array_divide(gp21->spacer,gp21->spacer,rmd->base,5); } # line 267 "geneparser21.dy" GeneParser21Score * GeneParser21Score_from_GeneParser21(GeneParser21 * gp21) { GeneParser21Score * out; out = GeneParser21Score_alloc(); if( out == NULL ) return NULL; Probability2Score_move(gp21->transition,out->transition,GENEPARSER21_TRANSITION_LEN); Probability2Score_move(gp21->central, out->central, GENEPARSER21_EMISSION_LEN); Probability2Score_move(gp21->py, out->py, GENEPARSER21_EMISSION_LEN); Probability2Score_move(gp21->spacer, out->spacer, GENEPARSER21_EMISSION_LEN); return out; } # line 239 "geneparser21.c" /* Function: hard_link_GeneParser21(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneParser21 *] * * Return [UNKN ] Undocumented return value [GeneParser21 *] * */ GeneParser21 * hard_link_GeneParser21(GeneParser21 * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneParser21 object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneParser21_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneParser21 *] * */ GeneParser21 * GeneParser21_alloc(void) { GeneParser21 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneParser21 *) ckalloc (sizeof(GeneParser21))) == NULL) { warn("GeneParser21_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* transition[GENEPARSER21_TRANSITION_LEN] is an array: no default possible */ /* central[GENEPARSER21_EMISSION_LEN] is an array: no default possible */ /* py[GENEPARSER21_EMISSION_LEN] is an array: no default possible */ /* spacer[GENEPARSER21_EMISSION_LEN] is an array: no default possible */ return out; } /* Function: free_GeneParser21(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneParser21 *] * * Return [UNKN ] Undocumented return value [GeneParser21 *] * */ GeneParser21 * free_GeneParser21(GeneParser21 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneParser21 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_GeneParser21Score(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneParser21Score *] * * Return [UNKN ] Undocumented return value [GeneParser21Score *] * */ GeneParser21Score * hard_link_GeneParser21Score(GeneParser21Score * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneParser21Score object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneParser21Score_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneParser21Score *] * */ GeneParser21Score * GeneParser21Score_alloc(void) { GeneParser21Score * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneParser21Score *) ckalloc (sizeof(GeneParser21Score))) == NULL) { warn("GeneParser21Score_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* transition[GENEPARSER21_TRANSITION_LEN] is an array: no default possible */ /* central[GENEPARSER21_EMISSION_LEN] is an array: no default possible */ /* py[GENEPARSER21_EMISSION_LEN] is an array: no default possible */ /* spacer[GENEPARSER21_EMISSION_LEN] is an array: no default possible */ return out; } /* Function: free_GeneParser21Score(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneParser21Score *] * * Return [UNKN ] Undocumented return value [GeneParser21Score *] * */ GeneParser21Score * free_GeneParser21Score(GeneParser21Score * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneParser21Score obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/geneparser21.h0000644000175000001440000001513310670453714016604 0ustar philippusers#ifndef DYNAMITEgeneparser21HEADERFILE #define DYNAMITEgeneparser21HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "probability.h" #include "dyna.h" #include "randommodel.h" #include "genefrequency.h" enum { GP21_CDS2CENTRAL = 0, GP21_CENTRAL2CENTRAL, GP21_CENTRAL2PY, GP21_PY2PY, GP21_PY2SPACER, GP21_PY2CDS, GP21_SPACER2SPACER, GP21_SPACER2CDS, GP21_INSERT_1_BASE, GP21_INSERT_2_BASE, GP21_DELETE_1_BASE, GP21_DELETE_2_BASE, GP21_CDS2CDS, /* this is for gene parsing outside of the *Wise set */ GP21_RND2CDS, GP21_CDS2RND, GP21_RND2RND, GP21_RND2MODEL, GP21_LINK2MODEL, /* this is for link models */ GP21_LINK2LINK, GP21_LINK2RND, GENEPARSER21_TRANSITION_LEN }; #define GENEPARSER21_EMISSION_LEN 5 #define GeneParser21SetLISTLENGTH 32 struct Wise2_GeneParser21 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability transition[GENEPARSER21_TRANSITION_LEN]; Probability central[GENEPARSER21_EMISSION_LEN]; Probability py[GENEPARSER21_EMISSION_LEN]; Probability spacer[GENEPARSER21_EMISSION_LEN]; } ; /* GeneParser21 defined */ #ifndef DYNAMITE_DEFINED_GeneParser21 typedef struct Wise2_GeneParser21 Wise2_GeneParser21; #define GeneParser21 Wise2_GeneParser21 #define DYNAMITE_DEFINED_GeneParser21 #endif struct Wise2_GeneParser21Score { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score transition[GENEPARSER21_TRANSITION_LEN]; Score central[GENEPARSER21_EMISSION_LEN]; Score py[GENEPARSER21_EMISSION_LEN]; Score spacer[GENEPARSER21_EMISSION_LEN]; } ; /* GeneParser21Score defined */ #ifndef DYNAMITE_DEFINED_GeneParser21Score typedef struct Wise2_GeneParser21Score Wise2_GeneParser21Score; #define GeneParser21Score Wise2_GeneParser21Score #define DYNAMITE_DEFINED_GeneParser21Score #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_GeneParser21(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneParser21 *] * * Return [UNKN ] Undocumented return value [GeneParser21 *] * */ GeneParser21 * Wise2_hard_link_GeneParser21(GeneParser21 * obj); #define hard_link_GeneParser21 Wise2_hard_link_GeneParser21 /* Function: GeneParser21_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneParser21 *] * */ GeneParser21 * Wise2_GeneParser21_alloc(void); #define GeneParser21_alloc Wise2_GeneParser21_alloc /* Function: free_GeneParser21(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneParser21 *] * * Return [UNKN ] Undocumented return value [GeneParser21 *] * */ GeneParser21 * Wise2_free_GeneParser21(GeneParser21 * obj); #define free_GeneParser21 Wise2_free_GeneParser21 /* Function: hard_link_GeneParser21Score(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneParser21Score *] * * Return [UNKN ] Undocumented return value [GeneParser21Score *] * */ GeneParser21Score * Wise2_hard_link_GeneParser21Score(GeneParser21Score * obj); #define hard_link_GeneParser21Score Wise2_hard_link_GeneParser21Score /* Function: GeneParser21Score_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneParser21Score *] * */ GeneParser21Score * Wise2_GeneParser21Score_alloc(void); #define GeneParser21Score_alloc Wise2_GeneParser21Score_alloc /* Function: free_GeneParser21Score(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneParser21Score *] * * Return [UNKN ] Undocumented return value [GeneParser21Score *] * */ GeneParser21Score * Wise2_free_GeneParser21Score(GeneParser21Score * obj); #define free_GeneParser21Score Wise2_free_GeneParser21Score /* Unplaced functions */ /* There has been no indication of the use of these functions */ RandomModelDNA * Wise2_fudged_mixed_RandomModelDNA_from_GeneParser21(GeneParser21 * gp,RandomModelDNA * rnd); #define fudged_mixed_RandomModelDNA_from_GeneParser21 Wise2_fudged_mixed_RandomModelDNA_from_GeneParser21 void Wise2_add_flat_error_probabilities_GeneParser21(GeneParser21 * gp21,Probability error); #define add_flat_error_probabilities_GeneParser21 Wise2_add_flat_error_probabilities_GeneParser21 void Wise2_add_error_probabilities_GeneParser21(GeneParser21 * gp21,Probability insert_1,Probability insert_2,Probability delete_1,Probability delete_2); #define add_error_probabilities_GeneParser21 Wise2_add_error_probabilities_GeneParser21 GeneParser21 * Wise2_GeneParser21_from_GeneFrequency21_cds(GeneFrequency21 * gf,Probability rnd_loop,Probability cds_loop,Probability rnd_to_model,Probability link_loop,Probability link_to_model); #define GeneParser21_from_GeneFrequency21_cds Wise2_GeneParser21_from_GeneFrequency21_cds RandomModelDNA * Wise2_RandomModelDNA_from_central_GeneParser21(GeneParser21 *gp21); #define RandomModelDNA_from_central_GeneParser21 Wise2_RandomModelDNA_from_central_GeneParser21 void Wise2_show_GeneParser21(GeneParser21 * gp21,FILE * ofp); #define show_GeneParser21 Wise2_show_GeneParser21 GeneParser21 * Wise2_std_GeneParser21(void); #define std_GeneParser21 Wise2_std_GeneParser21 Probability Wise2_removed_probability_from_cds(GeneParser21 * gp21); #define removed_probability_from_cds Wise2_removed_probability_from_cds void Wise2_GeneParser21_fold_in_RandomModelDNA(GeneParser21 * gp21,RandomModelDNA * rmd); #define GeneParser21_fold_in_RandomModelDNA Wise2_GeneParser21_fold_in_RandomModelDNA GeneParser21Score * Wise2_GeneParser21Score_from_GeneParser21(GeneParser21 * gp21); #define GeneParser21Score_from_GeneParser21 Wise2_GeneParser21Score_from_GeneParser21 /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/geneparser4.dy0000644000175000001440000000465707460556110016720 0ustar philippusers/* Last edited: Mar 3 13:16 1997 (birney) */ %{ #include "wisebase.h" #include "probability.h" #include "geneparser21.h" enum GeneParser4Type { GP4_INTRON2CDS = 0, GP4_INTRON2INTRON, GP4_DELETE_1_BASE, GP4_DELETE_2_BASE, GP4_INSERT_1_BASE, GP4_INSERT_2_BASE, GP4_LOOP2LOOP, GP4_LOOP2MODEL, GP4_TRANSITION_LEN }; %} struct GeneParser4 Probability transition[GP4_TRANSITION_LEN] Probability intron[5] struct GeneParser4Score Score transition[GP4_TRANSITION_LEN] Score intron[5] %{ #include "geneparser4.h" GeneParser4 * std_GeneParser4(double indel,double intron2cds) { int i; GeneParser4 * out; out = GeneParser4_alloc(); out->transition[GP4_INTRON2CDS] = intron2cds; out->transition[GP4_INTRON2INTRON] = 1.0; out->transition[GP4_DELETE_1_BASE] = indel; out->transition[GP4_DELETE_2_BASE] = indel; out->transition[GP4_INSERT_1_BASE] = indel; out->transition[GP4_INSERT_2_BASE] = indel; out->transition[GP4_LOOP2MODEL] = 1.0; out->transition[GP4_LOOP2LOOP] = 0; for(i=0;i<5;i++) out->intron[i] = 1.0; return out; } GeneParser4Score * GeneParser4Score_from_GeneParser21Score(GeneParser21Score * gp21s) { int i; GeneParser4Score * out; out = GeneParser4Score_alloc(); out->transition[GP4_INTRON2CDS] = gp21s->transition[GP21_CENTRAL2PY] + gp21s->transition[GP21_PY2SPACER] + gp21s->transition[GP21_SPACER2CDS]; out->transition[GP4_INTRON2INTRON] = gp21s->transition[GP21_CENTRAL2CENTRAL]; out->transition[GP4_DELETE_1_BASE] = gp21s->transition[GP21_DELETE_1_BASE]; out->transition[GP4_DELETE_2_BASE] = gp21s->transition[GP21_DELETE_2_BASE]; out->transition[GP4_INSERT_1_BASE] = gp21s->transition[GP21_INSERT_1_BASE]; out->transition[GP4_INSERT_2_BASE] = gp21s->transition[GP21_INSERT_2_BASE]; out->transition[GP4_LOOP2MODEL] = gp21s->transition[GP21_RND2MODEL]; /* out->transition[GP4_LOOP2LOOP] = gp21s->transition[GP21_RND2RND]; */ out->transition[GP4_LOOP2LOOP] = 0; /* fprintf(stderr,"Loop score is %d\n",out->transition[GP4_LOOP2LOOP]); */ for(i=0;i<5;i++) out->intron[i] = gp21s->central[i]; return out; } GeneParser4Score * GeneParser4Score_from_GeneParser4(GeneParser4 * gp4) { GeneParser4Score * out; out = GeneParser4Score_alloc(); Probability2Score_move(gp4->transition,out->transition,GP4_TRANSITION_LEN); Probability2Score_move(gp4->intron,out->intron,5); return out; } %} wise-2.4.1/src/models/cdparser.dy0000644000175000001440000000341407313404543016271 0ustar philippusers/* Last edited: Apr 24 14:51 1997 (birney) */ %{ #include "wisebase.h" #include "probability.h" enum cDNAParserTrans { PCD_INSERT_2_BASE = 0, PCD_INSERT_1_BASE, PCD_DELETE_2_BASE, PCD_DELETE_1_BASE, PCD_PARSER_TRANS_LEN }; %} struct cDNAParser Probability trans[PCD_PARSER_TRANS_LEN] %info This object holds the (very few) extra transition information needed for the estwise algorithm. It is sort of like the 'gene model' part of sequencing error (but very very simple) %% struct cDNAParserScore Score trans[PCD_PARSER_TRANS_LEN] %info This object is the score counter point to cDNAParser (which is in probabilities). %% api object cDNAParser des free_cDNAParser endobject func flat_cDNAParser endapi %{ #include "cdparser.h" %func Makes a convienient sum over all the transition probabilities %% Probability removed_probability_from_cds_cdna(cDNAParser * cdp) { return cdp->trans[PCD_INSERT_2_BASE] + cdp->trans[PCD_INSERT_1_BASE] + cdp->trans[PCD_DELETE_2_BASE] + cdp->trans[PCD_DELETE_1_BASE]; } %func Makes a new Score object from its probability counterpart %% cDNAParserScore * cDNAParserScore_from_cDNAParser(cDNAParser * cdp) { cDNAParserScore * out; out = cDNAParserScore_alloc(); Probability2Score_move(cdp->trans,out->trans,PCD_PARSER_TRANS_LEN); return out; } %func Makes a flat (ie, indels of 1 or 2 == p) cDNA parser. This means that insertions and deletions of both 1 or 2 bases are all parameterised at the same probability %arg p r probability of an indel %% cDNAParser * flat_cDNAParser(Probability p) { cDNAParser * out; out = cDNAParser_alloc(); out->trans[PCD_INSERT_2_BASE] = p; out->trans[PCD_INSERT_1_BASE] = p; out->trans[PCD_DELETE_2_BASE] = p; out->trans[PCD_DELETE_1_BASE] = p; return out; } %} wise-2.4.1/src/models/cdparser.xs0000644000175000001440000000126710670453713016316 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::cDNAParser Wise2_cDNAParser * hard_link_cDNAParser(obj) Wise2_cDNAParser * obj CODE: RETVAL = Wise2_hard_link_cDNAParser(obj); OUTPUT: RETVAL Wise2_cDNAParser * alloc() CODE: RETVAL = Wise2_cDNAParser_alloc(); OUTPUT: RETVAL Wise2_cDNAParser * new(class) char * class PPCODE: Wise2_cDNAParser * out; out = Wise2_cDNAParser_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_cDNAParser * obj CODE: Wise2_free_cDNAParser(obj); MODULE = Wise2 PACKAGE = Wise2 Wise2_cDNAParser * flat_cDNAParser(p) Probability p CODE: RETVAL = Wise2_flat_cDNAParser(p); OUTPUT: RETVAL wise-2.4.1/src/models/test_gwhsp.c0000644000175000001440000000073707555212131016466 0ustar philippusers#include "genewisehsp.h" int main(int argc,char **argv) { Sequence * a; Sequence * b; DPEnvelope * dpenv; GeneWiseRunPara * p; CompMat * mat; CodonTable * ct; a = read_fasta_file_Sequence(argv[1]); b = read_fasta_file_Sequence(argv[2]); p = GeneWiseRunPara_alloc(); mat = read_Blast_file_CompMat("blosum62.bla"); ct = read_CodonTable_file("codon.table"); dpenv = DPEnvelope_from_protein_gen(a,b,mat,ct,p); show_DPEnvelope(dpenv,stdout); } wise-2.4.1/src/models/cdnawise.c0000644000175000001440000001323207434501775016101 0ustar philippusers#include "dyna.h" #include "genestats.h" #include "geneparser4.h" #include "cdnawise10.h" #include "version.h" #include "geneutil.h" #include "geneoutput.h" char * program_name = "cdnawise"; char * codon_file = "codon.table"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL (2001) and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney wrote the core code.\n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(ofp,"cdnawise in fasta format\n"); fprintf(ofp,"cDna sequence options\n"); fprintf(ofp," -s start position in dna\n"); fprintf(ofp," -t end position in dna\n"); fprintf(ofp,"Genomic Dna sequence options\n"); fprintf(ofp," -u start position in dna\n"); fprintf(ofp," -v end position in dna\n"); fprintf(ofp,"Match algorithm options\n"); fprintf(ofp," -g gap open penalty\n"); fprintf(ofp," -e gap ext penalty\n"); show_help_GeneModelParam(ofp); show_help_GeneOutputPara(ofp); show_help_DPRunImpl(ofp); show_standard_options(ofp); } int main(int argc,char ** argv) { Sequence * cdna; Sequence * gen; Sequence * active_gen; Sequence * active_cdna; int i; int dstart = -1; int dend = -1; int cstart = -1; int cend = -1; int gapopen = 12; int gapext = 2; CodonTable * ct = NULL; CodonMatrixScore * cm = NULL; RandomCodon * rndcodon = NULL; RandomCodonScore * rndcodonscore = NULL; DnaMatrix * dm = NULL; DPRunImpl * dpri = NULL; GeneModel * gm; GeneModelParam * gmp; GeneStats * gs; GeneParser21 * gp21; GeneParser21Score * gp21s; GeneParser4Score * gp; GeneOutputData data; GeneOutputPara * geneout; ComplexSequenceEvalSet * cdna_cses; ComplexSequenceEvalSet * gen_cses; ComplexSequence * cs_cdna; ComplexSequence * cs_gen; Genomic * gent; GenomicRegion * gr; CompMat * cmat; CompProb * cprob; char * matfile = "blosum62.bla"; Protein * trans; PackAln * pal; AlnBlock * alb; FILE * ofp = stdout; dpri = new_DPRunImpl_from_argv(&argc,argv); gmp = new_GeneModelParam_from_argv(&argc,argv); geneout = new_GeneOutputPara_from_argv(&argc,argv); strip_out_integer_argument(&argc,argv,"u",&dstart); strip_out_integer_argument(&argc,argv,"v",&dend); strip_out_integer_argument(&argc,argv,"s",&cstart); strip_out_integer_argument(&argc,argv,"t",&cend); strip_out_integer_argument(&argc,argv,"g",&gapopen); strip_out_integer_argument(&argc,argv,"e",&gapext); strip_out_standard_options(&argc,argv,show_help,show_version); ct = read_CodonTable_file(codon_file); cmat = read_Blast_file_CompMat(matfile); cprob = CompProb_from_halfbit(cmat); cm = naive_CodonMatrixScore_from_prob(ct,cprob); gm = GeneModel_from_GeneModelParam(gmp); cdna = read_fasta_file_Sequence(argv[1]); gen = read_fasta_file_Sequence(argv[2]); if( dstart != -1 || dend != -1 ) { if( dstart == -1 ) { dstart = 1; } if( dend == -1 ) { dend = gen->len; } active_gen = magic_trunc_Sequence(gen,dstart,dend); } else { active_gen = hard_link_Sequence(gen); } if( cstart != -1 || cend != -1 ) { if( cstart == -1 ) { cstart = 1; } if( cend == -1 ) { cend = gen->len; } active_cdna = magic_trunc_Sequence(gen,cstart,cend); } else { active_cdna = hard_link_Sequence(gen); } rndcodon = RandomCodon_from_raw_CodonFrequency(gm->codon,ct); fold_in_RandomModelDNA_into_RandomCodon(rndcodon,gm->rnd); rndcodonscore = RandomCodonScore_from_RandomCodon(rndcodon); assert(active_cdna); assert(active_gen); cdna_cses = default_cDNA_ComplexSequenceEvalSet(); gen_cses = new_ComplexSequenceEvalSet_from_GeneModel(gm); cs_cdna = new_ComplexSequence(active_cdna,cdna_cses); cs_gen = new_ComplexSequence(active_gen,gen_cses); gp21 = std_GeneParser21(); GeneParser21_fold_in_RandomModelDNA(gp21,gm->rnd); gp21s = GeneParser21Score_from_GeneParser21(gp21); gp = GeneParser4Score_from_GeneParser21Score(gp21s); dm = identity_DnaMatrix(Probability2Score(halfbit2Probability(1)),Probability2Score(halfbit2Probability(-1))); assert(cs_cdna); assert(cs_gen); assert(gp); assert(rndcodonscore); assert(dm); assert(dpri); /* show_CodonMatrixScore(cm,ct,ofp);*/ /* pal = PackAln_bestmemory_CdnaWise10(cs_cdna,cs_gen,gp,cm,rndcodonscore,dm, Probability2Score(halfbit2Probability(-gapopen)), Probability2Score(halfbit2Probability(-gapext)), Probability2Score(halfbit2Probability(-5)), +50, NULL, dpri); */ pal = PackAln_bestmemory_CdnaWise10(cs_cdna,cs_gen,gp,cm,rndcodonscore,dm, 0, 0, Probability2Score(halfbit2Probability(-5)), +50, NULL, dpri); alb = convert_PackAln_to_AlnBlock_CdnaWise10(pal); gent = Genomic_from_Sequence(gen); assert(gent); gr = new_GenomicRegion(gent); assert(gr); add_Genes_to_GenomicRegion_GeneWise(gr,active_gen->offset,active_gen->end,alb,cdna->name,0,NULL); data.pal = pal; data.alb = alb; data.gr = gr; data.gen = gent; data.ct = ct; show_GeneOutput(&data,geneout,stdout); return 0; } wise-2.4.1/src/models/fivestar.c0000644000175000001440000000712707464445643016141 0ustar philippusers#define WISE2_CROSS_HMMER2 #include "wise2xhmmer2.h" #include "fivestate.h" #include "version.h" #include "seqaligndisplay.h" #include "standardout.h" #include "threestatedp.h" char * program_name = "fivestar"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s hmmer-file protein-file\n",program_name); fprintf(ofp,"[no]five do fivestar method\n"); show_help_StandardOutputOptions(ofp); show_help_DPRunImpl(ofp); show_standard_options(ofp); } int main(int argc,char **argv) { char * hmmer_file; char * sequence_file; ThreeStateModel * tsm; ThreeStateScore * tss; FiveStateFrameSet * frame; FiveStateModel * fsm; FiveStateScore * fss; RandomModel * rm; Sequence * seq; Protein * tseq; ComplexSequence * cseq; ComplexSequenceEvalSet * cses; PackAln * pal; AlnBlock * alb; boolean do_fivestar = FALSE; int i; DPRunImpl * dpri = NULL; StandardOutputOptions * std_opt = NULL; rm = default_RandomModel(); dpri = new_DPRunImpl_from_argv(&argc,argv); std_opt = new_StandardOutputOptions_from_argv(&argc,argv); if( dpri == NULL ) { fatal("Unable to build DPRun implementation. Bad arguments"); } strip_out_boolean_def_argument(&argc,argv,"five",&do_fivestar); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 3 ) { show_help(stdout); exit(12); } if( do_fivestar ) { frame = read_FiveStateFrameSet_file(argv[1],"block.str"); if( frame == NULL ) fatal("Unable to make FiveStateModel from context %s, block.str file",argv[1]); fsm = FiveStateModel_from_FiveStateFrameSet(frame); /* dump_FiveStateModel(fsm,stdout); */ fsm->name = stringalloc(argv[1]); } else { tsm = HMMer2_read_ThreeStateModel(argv[1]); fsm = FiveStateModel_from_flat_ThreeStateModel(tsm); } fold_RandomModel_into_FiveStateModel(fsm,rm); /* converts probabilities to integers for calculation */ fss = FiveStateScore_from_FiveStateModel(fsm); /* dump_FiveStateScore(fss,stdout); */ seq = read_fasta_file_Sequence(argv[2]); assert(seq); cses = default_aminoacid_ComplexSequenceEvalSet(); cseq = new_ComplexSequence(seq,cses); /* * Actually do the alignment. If fivestar is switched on, * use the FiveStateProtein match */ if( do_fivestar ) { /* PackAln_bestmemory is Viterbi algorithm */ pal = PackAln_bestmemory_FiveStateProtein(fss,cseq,NULL,dpri); alb = convert_PackAln_to_AlnBlock_FiveStateProtein(pal); tseq = pseudo_Protein_from_FiveStateModel(fsm); } else { fold_RandomModel_into_ThreeStateModel(tsm,tsm->rm); tss = ThreeStateScore_from_ThreeStateModel(tsm); pal = PackAln_bestmemory_ThreeStateProtein(tss,cseq,NULL,dpri); alb = convert_PackAln_to_AlnBlock_ThreeStateProtein(pal); tseq = pseudo_Protein_from_ThreeStateModel(tsm); } show_StandardOutputOptions(std_opt,alb,pal,"//",stdout); printf("Score %d Bits %.3f\n",pal->score,Score2Bits(pal->score)); write_pretty_str_align(alb,tseq->baseseq->name,tseq->baseseq->seq,seq->name,seq->seq,12,50,stdout); return 0; } wise-2.4.1/src/models/statwise10.c0000644000175000001440000042323507454521132016307 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "statwise10.h" # line 5 "statwise10.c" /***************** C functions ****************/ /* Written using dynamite */ /* Tue Apr 2 10:59:22 2002 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define CODON 0 #define INTRON_0 1 #define INTRON_1 2 #define INTRON_2 3 #define RND_SEQ 0 #define START 1 #define END 2 #define StatWise10_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+3)*4)+STATE][i+1] #define StatWise10_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+3] #define StatWise10_READ_OFF_ERROR -5 #define StatWise10_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+4)%4][((i+1)*4)+STATE] #define StatWise10_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+4)%4][STATE] /* Function: search_StatWise10(dbsi,out,exonmodel,seq,codon,intron_open,gene_open) * * Descrip: This function makes a database search of StatWise10 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: exonmodel [UNKN ] Undocumented argument [SyExonScore*] * Arg: seq [UNKN ] Undocumented argument [ComplexSequence*] * Arg: codon [UNKN ] Undocumented argument [RandomCodonScore*] * Arg: intron_open [UNKN ] Undocumented argument [Score] * Arg: gene_open [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_StatWise10(DBSearchImpl * dbsi,Hscore * out,SyExonScore* exonmodel,ComplexSequence* seq ,RandomCodonScore* codon,Score intron_open,Score gene_open) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_StatWise10 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_StatWise10. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_StatWise10. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for StatWise10, but it was compiled with a trace level of 1702062423. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_StatWise10(out,exonmodel,seq ,codon,intron_open,gene_open); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_StatWise10 *) ckalloc(sizeof(struct thread_pool_holder_StatWise10)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->exonmodel = exonmodel; holder->seq = seq; holder->codon = codon; holder->intron_open = intron_open; holder->gene_open = gene_open; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_StatWise10,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for StatWise10"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from StatWise10",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: serial_search_StatWise10(out,exonmodel,seq,codon,intron_open,gene_open) * * Descrip: This function makes a database search of StatWise10 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: exonmodel [UNKN ] Undocumented argument [SyExonScore*] * Arg: seq [UNKN ] Undocumented argument [ComplexSequence*] * Arg: codon [UNKN ] Undocumented argument [RandomCodonScore*] * Arg: intron_open [UNKN ] Undocumented argument [Score] * Arg: gene_open [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_StatWise10(Hscore * out,SyExonScore* exonmodel,ComplexSequence* seq ,RandomCodonScore* codon,Score intron_open,Score gene_open) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_StatWise10(exonmodel, seq , codon, intron_open, gene_open); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("StatWise10 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_StatWise10(exonmodel,seq,codon,intron_open,gene_open) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_StatWise10_only * * * Arg: exonmodel [UNKN ] query data structure [SyExonScore*] * Arg: seq [UNKN ] target data structure [ComplexSequence*] * Arg: codon [UNKN ] Resource [RandomCodonScore*] * Arg: intron_open [UNKN ] Resource [Score] * Arg: gene_open [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_StatWise10(SyExonScore* exonmodel,ComplexSequence* seq ,RandomCodonScore* codon,Score intron_open,Score gene_open) { int bestscore = NEGI; int i; int j; int k; StatWise10 * mat; mat = allocate_StatWise10_only(exonmodel, seq , codon, intron_open, gene_open); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(4,(mat->leni + 1) * 4,4,3)) == NULL) { warn("Score only matrix for StatWise10 cannot be allocated, (asking for 3 by %d cells)",mat->leni*4); mat = free_StatWise10(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<5;j++) { for(i=(-1);ileni;i++) { for(k=0;k<4;k++) StatWise10_VSMALL_MATRIX(mat,i,j,k) = NEGI; } StatWise10_VSMALL_SPECIAL(mat,i,j,RND_SEQ) = NEGI; StatWise10_VSMALL_SPECIAL(mat,i,j,START) = 0; StatWise10_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state CODON */ /* setting first movement to score */ score = StatWise10_VSMALL_MATRIX(mat,i-1,j-3,CODON) + mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]; /* Has restricted position */ if( (i-1) == 0 ) { /* From state RND_SEQ to state CODON */ temp = StatWise10_VSMALL_SPECIAL(mat,i-1,j-3,RND_SEQ) + (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->gene_open); if( temp > score ) { score = temp; } } /* From state CODON to state CODON */ temp = StatWise10_VSMALL_MATRIX(mat,i-0,j-3,CODON) + (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->exonmodel->exon[i]->stay_score); if( temp > score ) { score = temp; } /* From state INTRON_0 to state CODON */ temp = StatWise10_VSMALL_MATRIX(mat,i-1,j-3,INTRON_0) + CSEQ_GENOMIC_3SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state CODON */ temp = StatWise10_VSMALL_MATRIX(mat,i-1,j-2,INTRON_1) + CSEQ_GENOMIC_3SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state CODON */ temp = StatWise10_VSMALL_MATRIX(mat,i-1,j-1,INTRON_2) + CSEQ_GENOMIC_3SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ StatWise10_VSMALL_MATRIX(mat,i,j,CODON) = score; /* state CODON is a source for special RND_SEQ */ temp = score + (mat->exonmodel->exon[i]->exit_score) + (0) ; if( temp > StatWise10_VSMALL_SPECIAL(mat,i,j,RND_SEQ) ) { StatWise10_VSMALL_SPECIAL(mat,i,j,RND_SEQ) = temp; } /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = StatWise10_VSMALL_MATRIX(mat,i-0,j-1,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* From state INTRON_0 to state INTRON_0 */ temp = StatWise10_VSMALL_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ StatWise10_VSMALL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = StatWise10_VSMALL_MATRIX(mat,i-0,j-2,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* From state INTRON_1 to state INTRON_1 */ temp = StatWise10_VSMALL_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ StatWise10_VSMALL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = StatWise10_VSMALL_MATRIX(mat,i-0,j-3,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* From state INTRON_2 to state INTRON_2 */ temp = StatWise10_VSMALL_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ StatWise10_VSMALL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of for all query positions */ /* Special state RND_SEQ has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = StatWise10_VSMALL_SPECIAL(mat,0,j,RND_SEQ); /* Source CODON for state RND_SEQ is not special... already calculated */ /* Source RND_SEQ is a special source for RND_SEQ */ temp = StatWise10_VSMALL_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) score = temp; /* Source START is a special source for RND_SEQ */ temp = StatWise10_VSMALL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ StatWise10_VSMALL_SPECIAL(mat,0,j,RND_SEQ) = score; /* Finished updating state RND_SEQ */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = StatWise10_VSMALL_SPECIAL(mat,0,j,END); /* Source RND_SEQ is a special source for END */ temp = StatWise10_VSMALL_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ StatWise10_VSMALL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ if( bestscore < StatWise10_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = StatWise10_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_StatWise10(mat); return bestscore; } /* Function: PackAln_bestmemory_StatWise10(exonmodel,seq,codon,intron_open,gene_open,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_StatWise10 * * * Arg: exonmodel [UNKN ] query data structure [SyExonScore*] * Arg: seq [UNKN ] target data structure [ComplexSequence*] * Arg: codon [UNKN ] Resource [RandomCodonScore*] * Arg: intron_open [UNKN ] Resource [Score] * Arg: gene_open [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_StatWise10(SyExonScore* exonmodel,ComplexSequence* seq ,RandomCodonScore* codon,Score intron_open,Score gene_open,DPEnvelope * dpenv,DPRunImpl * dpri) { int total; StatWise10 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = exonmodel->len * seq->length; if( dpri->memory == DPIM_Default ) { if( (total * 4 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_StatWise10(exonmodel, seq , codon, intron_open, gene_open)) == NULL ) { warn("Unable to allocate small StatWise10 version"); return NULL; } out = PackAln_calculate_Small_StatWise10(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_StatWise10(exonmodel, seq , codon, intron_open, gene_open)) == NULL ) { warn("Unable to allocate large StatWise10 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else calculate_StatWise10(mat); out = PackAln_read_Expl_StatWise10(mat); } mat = free_StatWise10(mat); return out; } /* Function: allocate_StatWise10_only(exonmodel,seq,codon,intron_open,gene_open) * * Descrip: This function only allocates the StatWise10 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: exonmodel [UNKN ] query data structure [SyExonScore*] * Arg: seq [UNKN ] target data structure [ComplexSequence*] * Arg: codon [UNKN ] Resource [RandomCodonScore*] * Arg: intron_open [UNKN ] Resource [Score] * Arg: gene_open [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [StatWise10 *] * */ StatWise10 * allocate_StatWise10_only(SyExonScore* exonmodel,ComplexSequence* seq ,RandomCodonScore* codon,Score intron_open,Score gene_open) { StatWise10 * out; if((out= StatWise10_alloc()) == NULL) { warn("Allocation of basic StatWise10 structure failed..."); return NULL; } out->exonmodel = exonmodel; out->seq = seq; out->codon = codon; out->intron_open = intron_open; out->gene_open = gene_open; out->leni = exonmodel->len; out->lenj = seq->length; return out; } /* Function: allocate_Expl_StatWise10(exonmodel,seq,codon,intron_open,gene_open) * * Descrip: This function allocates the StatWise10 structure * and the basematrix area for explicit memory implementations * It calls /allocate_StatWise10_only * * * Arg: exonmodel [UNKN ] query data structure [SyExonScore*] * Arg: seq [UNKN ] target data structure [ComplexSequence*] * Arg: codon [UNKN ] Resource [RandomCodonScore*] * Arg: intron_open [UNKN ] Resource [Score] * Arg: gene_open [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [StatWise10 *] * */ StatWise10 * allocate_Expl_StatWise10(SyExonScore* exonmodel,ComplexSequence* seq ,RandomCodonScore* codon,Score intron_open,Score gene_open) { StatWise10 * out; out = allocate_StatWise10_only(exonmodel, seq , codon, intron_open, gene_open); if( out == NULL ) return NULL; if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+3)*4,(out->leni+1),3,out->lenj+3)) == NULL) { warn("Explicit matrix StatWise10 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_StatWise10(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_StatWise10(out); return out; } /* Function: init_StatWise10(mat) * * Descrip: This function initates StatWise10 matrix when in explicit mode * Called in /allocate_Expl_StatWise10 * * * Arg: mat [UNKN ] StatWise10 which contains explicit basematrix memory [StatWise10 *] * */ void init_StatWise10(StatWise10 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iexonmodel->len;i++) { for(j= (-3);j<4;j++) { StatWise10_EXPL_MATRIX(mat,i,j,CODON) = NEGI; StatWise10_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; StatWise10_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; StatWise10_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } } for(j= (-3);jseq->length;j++) { for(i= (-1);i<2;i++) { StatWise10_EXPL_MATRIX(mat,i,j,CODON) = NEGI; StatWise10_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; StatWise10_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; StatWise10_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } StatWise10_EXPL_SPECIAL(mat,i,j,RND_SEQ) = NEGI; StatWise10_EXPL_SPECIAL(mat,i,j,START) = 0; StatWise10_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_StatWise10(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by StatWise10 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * */ void recalculate_PackAln_StatWise10(PackAln * pal,StatWise10 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case CODON : if( offi == 1 && offj == 3 && prev->state == CODON ) { pau->score = mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)] + (0); continue; } if( offj == 3 && prev->state == (RND_SEQ+4) ) { pau->score = (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->gene_open) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == CODON ) { pau->score = (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->exonmodel->exon[i]->stay_score) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == INTRON_0 ) { pau->score = CSEQ_GENOMIC_3SS(mat->seq,(j-3)) + (0); continue; } if( offi == 1 && offj == 2 && prev->state == INTRON_1 ) { pau->score = CSEQ_GENOMIC_3SS(mat->seq,(j-2)) + (0); continue; } if( offi == 1 && offj == 1 && prev->state == INTRON_2 ) { pau->score = CSEQ_GENOMIC_3SS(mat->seq,(j-1)) + (0); continue; } warn("In recaluclating PackAln with state CODON, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_0 : if( offi == 0 && offj == 1 && prev->state == CODON ) { pau->score = (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_0 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_1 : if( offi == 0 && offj == 2 && prev->state == CODON ) { pau->score = (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_1 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_2 : if( offi == 0 && offj == 3 && prev->state == CODON ) { pau->score = (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_2 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (RND_SEQ+4) : if( offj == 0 && prev->state == CODON ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->exonmodel->exon[i]->exit_score + (0); continue; } if( offj == 1 && prev->state == (RND_SEQ+4) ) { pau->score = 0 + (0); continue; } if( offj == 1 && prev->state == (START+4) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state RND_SEQ, got a bad source state. Error!"); break; case (START+4) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+4) : if( offj == 1 && prev->state == (RND_SEQ+4) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define StatWise10_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+3)][(i+1)*4+state]) #define StatWise10_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+4)*8) % 32][(i+1)*4+state]) #define StatWise10_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+3)]) #define StatWise10_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+3)]) #define StatWise10_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+4)*8)+(shadow+1)) % 32)][(i+1)*4 + state]) /* Function: allocate_Small_StatWise10(exonmodel,seq,codon,intron_open,gene_open) * * Descrip: This function allocates the StatWise10 structure * and the basematrix area for a small memory implementations * It calls /allocate_StatWise10_only * * * Arg: exonmodel [UNKN ] query data structure [SyExonScore*] * Arg: seq [UNKN ] target data structure [ComplexSequence*] * Arg: codon [UNKN ] Resource [RandomCodonScore*] * Arg: intron_open [UNKN ] Resource [Score] * Arg: gene_open [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [StatWise10 *] * */ #define StatWise10_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+3)]) StatWise10 * allocate_Small_StatWise10(SyExonScore* exonmodel,ComplexSequence* seq ,RandomCodonScore* codon,Score intron_open,Score gene_open) { StatWise10 * out; out = allocate_StatWise10_only(exonmodel, seq , codon, intron_open, gene_open); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(32,(out->leni + 1) * 4,24,out->lenj+3); if(out == NULL) { warn("Small shadow matrix StatWise10 cannot be allocated, (asking for 4 by %d main cells)",out->leni+2); free_StatWise10(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_StatWise10(mat,dpenv) * * Descrip: This function calculates an alignment for StatWise10 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_StatWise10 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_StatWise10 * * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_StatWise10(StatWise10 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for StatWise10 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_start_end_calculate_StatWise10(mat,dpenv); score = start_end_find_end_StatWise10(mat,&endj); out->score = score; stopstate = END; /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */ log_full_error(REPORT,0,"End at %d Score %d",endj,score); stop_reporting(); for(;;) { /*while there are more special bits to recover*/ start_reporting("Special cell aln end %d:",endj); if( read_special_strip_StatWise10(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) { warn("Problem in reading off special state system... going to return partial alignment"); break; } if( startstate == START || endj <= 0) { log_full_error(REPORT,0,"Recovered complete alignment"); stop_reporting(); break; } log_full_error(REPORT,0,"Finished to %d",endj); stop_reporting(); /* Ok... have to eat up another piece of matrix */ temp = startstate; starti = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0); startj = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1); startstate = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2); stopi = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3); stopj = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4); stopstate = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5); /* Get out the score of this block. V. important! */ temp = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6); totalj = stopj - startj; donej = 0; start_reporting("Main matrix aln [%d,%d]:",startj,stopj); if(full_dc_StatWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) { warn("In the alignment StatWise10 [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj); return out; } /* now have to figure out which special we came from... yikes */ max_matrix_to_special_StatWise10(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == StatWise10_READ_OFF_ERROR) { warn("In StatWise10 read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj); invert_PackAln(out); recalculate_PackAln_StatWise10(out,mat); return out; } /* if at start, break, otherwise, back to eat another strip */ if( stopstate == START) { log_full_error(REPORT,0,"Recovered complete alignment "); stop_reporting(); break; } log_full_error(REPORT,0,"Finished alignment to %d ",startj); stop_reporting(); endj = stopj; /* stopstate is correct as it is */ } /* end of while there are more special bits to recover */ invert_PackAln(out); recalculate_PackAln_StatWise10(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_StatWise10(mat) * * Descrip: This function calculates an alignment for StatWise10 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_StatWise10 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_StatWise10 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_StatWise10 * * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_StatWise10(StatWise10 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_start_end_calculate_StatWise10(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_StatWise10(mat); return out; } /* Function: AlnRangeSet_from_StatWise10(mat) * * Descrip: This function reads off a start/end structure * for StatWise10 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_StatWise10 * If you have not calculated the matrix use * /AlnRange_calculate_Small_StatWise10 * * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_StatWise10(StatWise10 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_StatWise10"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_StatWise10(mat,&jpos); state = END; while( (temp = AlnRange_build_StatWise10(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_StatWise10(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_StatWise10 * * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_StatWise10(StatWise10 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_StatWise10"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_StatWise10(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_StatWise10 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = StatWise10_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_StatWise10(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == StatWise10_READ_OFF_ERROR) { warn("In AlnRange_build_StatWise10 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = StatWise10_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_StatWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_StatWise10(StatWise10 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_StatWise10(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == StatWise10_READ_OFF_ERROR) { warn("In StatWise10 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In StatWise10 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In StatWise10 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_StatWise10(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_StatWise10(StatWise10 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = StatWise10_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->exonmodel->len || j > mat->seq->length) { warn("In StatWise10 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = StatWise10_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case CODON : temp = cscore - (CSEQ_GENOMIC_3SS(mat->seq,(j-1))) - (0); if( temp == StatWise10_HIDDEN_MATRIX(mat,i - 1,j - 1,INTRON_2) ) { *reti = i - 1; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_HIDDEN_MATRIX(mat,i-1,j-1,INTRON_2); } return StatWise10_HIDDEN_MATRIX(mat,i - 1,j - 1,INTRON_2); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->seq,(j-2))) - (0); if( temp == StatWise10_HIDDEN_MATRIX(mat,i - 1,j - 2,INTRON_1) ) { *reti = i - 1; *retj = j - 2; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_HIDDEN_MATRIX(mat,i-1,j-2,INTRON_1); } return StatWise10_HIDDEN_MATRIX(mat,i - 1,j - 2,INTRON_1); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->seq,(j-3))) - (0); if( temp == StatWise10_HIDDEN_MATRIX(mat,i - 1,j - 3,INTRON_0) ) { *reti = i - 1; *retj = j - 3; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_HIDDEN_MATRIX(mat,i-1,j-3,INTRON_0); } return StatWise10_HIDDEN_MATRIX(mat,i - 1,j - 3,INTRON_0); } temp = cscore - ((mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->exonmodel->exon[i]->stay_score)) - (0); if( temp == StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 3,CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_HIDDEN_MATRIX(mat,i-0,j-3,CODON); } return StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 3,CODON); } /* Not allowing special sources.. skipping RND_SEQ */ temp = cscore - (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]) - (0); if( temp == StatWise10_HIDDEN_MATRIX(mat,i - 1,j - 3,CODON) ) { *reti = i - 1; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_HIDDEN_MATRIX(mat,i-1,j-3,CODON); } return StatWise10_HIDDEN_MATRIX(mat,i - 1,j - 3,CODON); } warn("Major problem (!) - in StatWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - (0) - (0); if( temp == StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0); } return StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open)) - (0); if( temp == StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_HIDDEN_MATRIX(mat,i-0,j-1,CODON); } return StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,CODON); } warn("Major problem (!) - in StatWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - (0) - (0); if( temp == StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1); } return StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open)) - (0); if( temp == StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 2,CODON) ) { *reti = i - 0; *retj = j - 2; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_HIDDEN_MATRIX(mat,i-0,j-2,CODON); } return StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 2,CODON); } warn("Major problem (!) - in StatWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - (0) - (0); if( temp == StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2); } return StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open)) - (0); if( temp == StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 3,CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_HIDDEN_MATRIX(mat,i-0,j-3,CODON); } return StatWise10_HIDDEN_MATRIX(mat,i - 0,j - 3,CODON); } warn("Major problem (!) - in StatWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in StatWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_StatWise10(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_StatWise10(StatWise10 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > StatWise10_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 4; add_PackAln(out,pau); } max_special_strip_StatWise10(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == StatWise10_READ_OFF_ERROR) { warn("In special strip read StatWise10, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < StatWise10_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read StatWise10, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 4; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_StatWise10(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_StatWise10(StatWise10 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = StatWise10_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for StatWise10, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->seq->length) { warn("In StatWise10 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = StatWise10_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case RND_SEQ : /* source START is a special */ temp = cscore - (0) - (0); if( temp == StatWise10_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return StatWise10_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } /* source RND_SEQ is a special */ temp = cscore - (0) - (0); if( temp == StatWise10_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,RND_SEQ) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_SEQ; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_DC_SHADOW_SPECIAL(mat,i-0,j-1,RND_SEQ); } return StatWise10_DC_SHADOW_MATRIX(mat,i - 0,j - 1,RND_SEQ) ; } /* Source CODON is not a special */ case START : case END : /* source RND_SEQ is a special */ temp = cscore - (0) - (0); if( temp == StatWise10_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,RND_SEQ) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_SEQ; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_DC_SHADOW_SPECIAL(mat,i-0,j-1,RND_SEQ); } return StatWise10_DC_SHADOW_MATRIX(mat,i - 0,j - 1,RND_SEQ) ; } default: warn("Major problem (!) - in StatWise10 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_StatWise10(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_StatWise10(StatWise10 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = StatWise10_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In StatWise10 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case CODON : /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ /* Source CODON is not a special, should not get here! */ temp = cscore - ((mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->gene_open)) - (0); if( temp == StatWise10_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,RND_SEQ) ) { *reti = i - 1; *retj = j - 3; *retstate = RND_SEQ; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_DC_SHADOW_SPECIAL(mat,i-1,j-3,RND_SEQ); } return StatWise10_DC_SHADOW_MATRIX(mat,i - 1,j - 3,RND_SEQ) ; } /* Source CODON is not a special, should not get here! */ warn("Major problem (!) - in StatWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : /* Source INTRON_0 is not a special, should not get here! */ /* Source CODON is not a special, should not get here! */ warn("Major problem (!) - in StatWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : /* Source INTRON_1 is not a special, should not get here! */ /* Source CODON is not a special, should not get here! */ warn("Major problem (!) - in StatWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : /* Source INTRON_2 is not a special, should not get here! */ /* Source CODON is not a special, should not get here! */ warn("Major problem (!) - in StatWise10 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in StatWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_StatWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_StatWise10(StatWise10 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_StatWise10(mat,starti,startj,stopi,stopj); StatWise10_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ StatWise10_HIDDEN_MATRIX(mat,i,j,CODON) = NEGI; StatWise10_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; StatWise10_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; StatWise10_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ /* For state CODON */ /* setting first movement to score */ score = StatWise10_HIDDEN_MATRIX(mat,i-1,j-3,CODON) + mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]; /* From state CODON to state CODON */ temp = StatWise10_HIDDEN_MATRIX(mat,i-0,j-3,CODON) + (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->exonmodel->exon[i]->stay_score); if( temp > score ) { score = temp; } /* From state INTRON_0 to state CODON */ temp = StatWise10_HIDDEN_MATRIX(mat,i-1,j-3,INTRON_0) + CSEQ_GENOMIC_3SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state CODON */ temp = StatWise10_HIDDEN_MATRIX(mat,i-1,j-2,INTRON_1) + CSEQ_GENOMIC_3SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state CODON */ temp = StatWise10_HIDDEN_MATRIX(mat,i-1,j-1,INTRON_2) + CSEQ_GENOMIC_3SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ StatWise10_HIDDEN_MATRIX(mat,i,j,CODON) = score; /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = StatWise10_HIDDEN_MATRIX(mat,i-0,j-1,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* From state INTRON_0 to state INTRON_0 */ temp = StatWise10_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ StatWise10_HIDDEN_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = StatWise10_HIDDEN_MATRIX(mat,i-0,j-2,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* From state INTRON_1 to state INTRON_1 */ temp = StatWise10_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ StatWise10_HIDDEN_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = StatWise10_HIDDEN_MATRIX(mat,i-0,j-3,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* From state INTRON_2 to state INTRON_2 */ temp = StatWise10_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ StatWise10_HIDDEN_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } } return; } /* Function: init_hidden_StatWise10(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_StatWise10(StatWise10 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-3);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { StatWise10_HIDDEN_MATRIX(mat,i,j,CODON) = NEGI; StatWise10_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; StatWise10_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; StatWise10_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; } } return; } /* Function: full_dc_StatWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_StatWise10 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_StatWise10 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [StatWise10 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_StatWise10(StatWise10 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_StatWise10"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 15) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_StatWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_StatWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_StatWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for StatWise10, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= StatWise10_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= StatWise10_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = StatWise10_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_StatWise10(mat,StatWise10_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),StatWise10_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),StatWise10_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_StatWise10(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_StatWise10(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_StatWise10(StatWise10 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_StatWise10(mat); StatWise10_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_StatWise10(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_StatWise10(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_StatWise10(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_StatWise10(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_StatWise10(StatWise10 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<3;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ StatWise10_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = (-100); StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = (-100); StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-100); StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = (-100); StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-100); StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = (-100); StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-100); StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = (-100); continue; } /* end of Is not in envelope */ /* For state CODON, pushing when j - offj <= mergej */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-3,CODON) + mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]; if( j - 3 <= mergej) { StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-1; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-3; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = CODON; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,CODON,k); } temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->exonmodel->exon[i]->stay_score); if( temp > score) { score = temp; if( j - 3 <= mergej) { StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-0; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-3; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = CODON; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,k); } } temp = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-3,INTRON_0) + CSEQ_GENOMIC_3SS(mat->seq,(j-3)); if( temp > score) { score = temp; if( j - 3 <= mergej) { StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-1; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-3; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = INTRON_0; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INTRON_0,k); } } temp = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-2,INTRON_1) + CSEQ_GENOMIC_3SS(mat->seq,(j-2)); if( temp > score) { score = temp; if( j - 2 <= mergej) { StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-1; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-2; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = INTRON_1; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INTRON_1,k); } } temp = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,INTRON_2) + CSEQ_GENOMIC_3SS(mat->seq,(j-1)); if( temp > score) { score = temp; if( j - 1 <= mergej) { StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-1; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-1; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = INTRON_2; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INTRON_2,k); } } /* Add any movement independant score */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,CODON) = score; /* Finished with state CODON */ /* For state INTRON_0, pushing when j - offj <= mergej */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); if( j - 1 <= mergej) { StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = CODON; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CODON,k); } temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INTRON_0; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } } /* Add any movement independant score */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished with state INTRON_0 */ /* For state INTRON_1, pushing when j - offj <= mergej */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-2,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); if( j - 2 <= mergej) { StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-2; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = CODON; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,CODON,k); } temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-1; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INTRON_1; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } } /* Add any movement independant score */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished with state INTRON_1 */ /* For state INTRON_2, pushing when j - offj <= mergej */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); if( j - 3 <= mergej) { StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-3; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = CODON; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,k); } temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-1; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INTRON_2; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } } /* Add any movement independant score */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished with state INTRON_2 */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_StatWise10(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_StatWise10(StatWise10 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ StatWise10_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state CODON */ /* setting first movement to score */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-3,CODON) + mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,CODON,k); /* From state CODON to state CODON */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->exonmodel->exon[i]->stay_score); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,k); } /* From state INTRON_0 to state CODON */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-3,INTRON_0) + CSEQ_GENOMIC_3SS(mat->seq,(j-3)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INTRON_0,k); } /* From state INTRON_1 to state CODON */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-2,INTRON_1) + CSEQ_GENOMIC_3SS(mat->seq,(j-2)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INTRON_1,k); } /* From state INTRON_2 to state CODON */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,INTRON_2) + CSEQ_GENOMIC_3SS(mat->seq,(j-1)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INTRON_2,k); } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,CODON) = score; for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CODON,k); /* From state INTRON_0 to state INTRON_0 */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-2,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,CODON,k); /* From state INTRON_1 to state INTRON_1 */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,k); /* From state INTRON_2 to state INTRON_2 */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_StatWise10(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_StatWise10(StatWise10 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ StatWise10_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state CODON */ /* setting first movement to score */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-3,CODON) + mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]; /* From state CODON to state CODON */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->exonmodel->exon[i]->stay_score); if( temp > score ) { score = temp; } /* From state INTRON_0 to state CODON */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-3,INTRON_0) + CSEQ_GENOMIC_3SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state CODON */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-2,INTRON_1) + CSEQ_GENOMIC_3SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state CODON */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,INTRON_2) + CSEQ_GENOMIC_3SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,CODON) = score; /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* From state INTRON_0 to state INTRON_0 */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-2,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* From state INTRON_1 to state INTRON_1 */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* From state INTRON_2 to state INTRON_2 */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_StatWise10(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * */ } void init_dc_StatWise10(StatWise10 * mat) { register int i; register int j; register int k; for(j=0;j<5;j++) { for(i=(-1);iexonmodel->len;i++) { StatWise10_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; for(k=0;k<7;k++) { StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = (-1); StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = (-1); StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = (-1); StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = (-1); } } } return; } /* Function: dc_start_end_calculate_StatWise10(mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in the shadow matrix * One tricky thing is that we need to add score-independent calcs in the states * As we have to evaluate them then. This is not ideally implemented therefore * In fact it is *definitely* not ideal. Will have to do for now * * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_start_end_calculate_StatWise10(StatWise10 * mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; init_start_end_linear_StatWise10(mat); leni = mat->exonmodel->len; lenj = mat->seq->length; total = leni * lenj; for(j=0;jcodon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)] + (0); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,CODON,k); /* From state RND_SEQ to state CODON */ temp = StatWise10_DC_SHADOW_SPECIAL(mat,i-1,j-3,RND_SEQ) + (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->gene_open) + (0); if( temp > score ) { score = temp; /* This state [RND_SEQ] is a special for CODON... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= CODON; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; } /* From state CODON to state CODON */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->exonmodel->exon[i]->stay_score) +(0); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,k); } /* From state INTRON_0 to state CODON */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-3,INTRON_0) + CSEQ_GENOMIC_3SS(mat->seq,(j-3)) +(0); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INTRON_0,k); } /* From state INTRON_1 to state CODON */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-2,INTRON_1) + CSEQ_GENOMIC_3SS(mat->seq,(j-2)) +(0); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INTRON_1,k); } /* From state INTRON_2 to state CODON */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-1,j-1,INTRON_2) + CSEQ_GENOMIC_3SS(mat->seq,(j-1)) +(0); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INTRON_2,k); } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,CODON) = score; for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* state CODON is a source for special RND_SEQ */ temp = score + (mat->exonmodel->exon[i]->exit_score) + (0) ; if( temp > StatWise10_DC_SHADOW_SPECIAL(mat,i,j,RND_SEQ) ) { StatWise10_DC_SHADOW_SPECIAL(mat,i,j,RND_SEQ) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) StatWise10_DC_SHADOW_SPECIAL_SP(mat,i,j,RND_SEQ,k) = StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k); StatWise10_DC_SHADOW_SPECIAL_SP(mat,i,j,RND_SEQ,6) = StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,6); StatWise10_DC_SHADOW_SPECIAL_SP(mat,i,j,RND_SEQ,3) = i; StatWise10_DC_SHADOW_SPECIAL_SP(mat,i,j,RND_SEQ,4) = j; StatWise10_DC_SHADOW_SPECIAL_SP(mat,i,j,RND_SEQ,5) = CODON; } /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open) + (0); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CODON,k); /* From state INTRON_0 to state INTRON_0 */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0 +(0); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-2,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open) + (0); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,CODON,k); /* From state INTRON_1 to state INTRON_1 */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0 +(0); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open) + (0); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,k); /* From state INTRON_2 to state INTRON_2 */ temp = StatWise10_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0 +(0); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = StatWise10_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of for each i position in strip */ /* Special state RND_SEQ has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = StatWise10_DC_SHADOW_SPECIAL(mat,0,j,RND_SEQ); /* Source CODON for state RND_SEQ is not special... already calculated */ /* Source RND_SEQ is a special source for RND_SEQ */ temp = StatWise10_DC_SHADOW_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) StatWise10_DC_SHADOW_SPECIAL_SP(mat,i,j,RND_SEQ,k) = StatWise10_DC_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,RND_SEQ,k); } /* Source START is a special source for RND_SEQ */ temp = StatWise10_DC_SHADOW_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) StatWise10_DC_SHADOW_SPECIAL_SP(mat,i,j,RND_SEQ,k) = StatWise10_DC_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,START,k); } /* Put back score... (now updated!) */ StatWise10_DC_SHADOW_SPECIAL(mat,0,j,RND_SEQ) = score; /* Finished updating state RND_SEQ */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = StatWise10_DC_SHADOW_SPECIAL(mat,0,j,END); /* Source RND_SEQ is a special source for END */ temp = StatWise10_DC_SHADOW_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) StatWise10_DC_SHADOW_SPECIAL_SP(mat,i,j,END,k) = StatWise10_DC_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,RND_SEQ,k); } /* Put back score... (now updated!) */ StatWise10_DC_SHADOW_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } /* end of for each j strip */ return TRUE; } /* Function: start_end_find_end_StatWise10(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [StatWise10 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_StatWise10(StatWise10 * mat,int * endj) { register int j; register int max; register int maxj; max = StatWise10_DC_SHADOW_SPECIAL(mat,0,mat->seq->length-1,END); maxj = mat->seq->length-1; for(j= mat->seq->length-2 ;j >= 0 ;j--) { if( StatWise10_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = StatWise10_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: init_start_end_linear_StatWise10(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * */ void init_start_end_linear_StatWise10(StatWise10 * mat) { register int i; register int j; for(j=0;j<5;j++) { for(i=(-1);iexonmodel->len;i++) { StatWise10_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = (-1); StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-1); StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-1); StatWise10_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; StatWise10_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-1); } } for(j=(-3);jseq->length;j++) { StatWise10_DC_SHADOW_SPECIAL(mat,0,j,RND_SEQ) = NEGI; StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,j,RND_SEQ,0) = (-1); StatWise10_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; StatWise10_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; StatWise10_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_StatWise10(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_StatWise10(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_StatWise10(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "EXON_STATE","INTRON_STATE","LOOP_STATE","END" }; /* Function: AlnConvertSet_StatWise10(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","5SS_PHASE_0","CENTRAL_INTRON","5SS_PHASE_1","5SS_PHASE_2","RANDOM_SEQUENCE","END" }; AlnConvertSet * AlnConvertSet_StatWise10(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = CODON; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_SEQ + 4; acu->is_from_special = TRUE; acu->state2 = CODON; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = CODON; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = CODON; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = CODON; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = CODON; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = RND_SEQ + 4; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_SEQ + 4; acu->state2 = RND_SEQ + 4; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 4; acu->state2 = RND_SEQ + 4; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_SEQ + 4; acu->state2 = END + 4; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[9]; add_collapse_label_AlnConvertSet(out,"LOOP_STATE","RANDOM_SEQUENCE"); add_collapse_label_AlnConvertSet(out,"NON_CDS_CONSERVED","RANDOM_SEQUENCE"); add_collapse_label_AlnConvertSet(out,"INTRON_STATE","CENTRAL_INTRON"); return out; } /* Function: PackAln_read_Expl_StatWise10(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_StatWise10(StatWise10 * mat) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("In StatWise10_basic_read You have asked for an alignment from a non-explicit matrix: c'est impossible [current type is %d - %s]", mat->basematrix->type,basematrix_type_to_string(mat->basematrix->type)); return NULL; } out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_StatWise10(mat,&i,&j,&state,&isspecial); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in StatWise10_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 4; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_StatWise10(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); else max_calc_StatWise10(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if(i == StatWise10_READ_OFF_ERROR || j == StatWise10_READ_OFF_ERROR || state == StatWise10_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in StatWise10_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 4; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_StatWise10(mat,ri,rj,state,isspecial) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_StatWise10(StatWise10 * mat,int * ri,int * rj,int * state,boolean * isspecial) { register int j; register int max; register int maxj; max = StatWise10_EXPL_SPECIAL(mat,0,mat->seq->length-1,END); maxj = mat->seq->length-1; for(j= mat->seq->length-2 ;j >= 0 ;j--) { if( StatWise10_EXPL_SPECIAL(mat,0,j,END) > max ) { max = StatWise10_EXPL_SPECIAL(mat,0,j,END); maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: StatWise10_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void StatWise10_debug_show_matrix(StatWise10 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iexonmodel->len;i++) { for(j=startj;jseq->length;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State CODON %d\n",StatWise10_EXPL_MATRIX(mat,i,j,CODON)); fprintf(ofp,"State INTRON_0 %d\n",StatWise10_EXPL_MATRIX(mat,i,j,INTRON_0)); fprintf(ofp,"State INTRON_1 %d\n",StatWise10_EXPL_MATRIX(mat,i,j,INTRON_1)); fprintf(ofp,"State INTRON_2 %d\n",StatWise10_EXPL_MATRIX(mat,i,j,INTRON_2)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_StatWise10(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_StatWise10(StatWise10 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = StatWise10_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->exonmodel->len || j > mat->seq->length) { warn("In StatWise10 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = StatWise10_EXPL_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case CODON : temp = cscore - (CSEQ_GENOMIC_3SS(mat->seq,(j-1))) - (0); if( temp == StatWise10_EXPL_MATRIX(mat,i - 1,j - 1,INTRON_2) ) { *reti = i - 1; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_MATRIX(mat,i-1,j-1,INTRON_2); } return StatWise10_EXPL_MATRIX(mat,i - 1,j - 1,INTRON_2); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->seq,(j-2))) - (0); if( temp == StatWise10_EXPL_MATRIX(mat,i - 1,j - 2,INTRON_1) ) { *reti = i - 1; *retj = j - 2; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_MATRIX(mat,i-1,j-2,INTRON_1); } return StatWise10_EXPL_MATRIX(mat,i - 1,j - 2,INTRON_1); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->seq,(j-3))) - (0); if( temp == StatWise10_EXPL_MATRIX(mat,i - 1,j - 3,INTRON_0) ) { *reti = i - 1; *retj = j - 3; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_MATRIX(mat,i-1,j-3,INTRON_0); } return StatWise10_EXPL_MATRIX(mat,i - 1,j - 3,INTRON_0); } temp = cscore - ((mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->exonmodel->exon[i]->stay_score)) - (0); if( temp == StatWise10_EXPL_MATRIX(mat,i - 0,j - 3,CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_MATRIX(mat,i-0,j-3,CODON); } return StatWise10_EXPL_MATRIX(mat,i - 0,j - 3,CODON); } /* Has restricted position */ if( (i-1) == 0 ) { temp = cscore - ((mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->gene_open)) - (0); if( temp == StatWise10_EXPL_SPECIAL(mat,i - 1,j - 3,RND_SEQ) ) { *reti = i - 1; *retj = j - 3; *retstate = RND_SEQ; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_SPECIAL(mat,i-1,j-3,RND_SEQ); } return StatWise10_EXPL_MATRIX(mat,i - 1,j - 3,RND_SEQ); } } temp = cscore - (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]) - (0); if( temp == StatWise10_EXPL_MATRIX(mat,i - 1,j - 3,CODON) ) { *reti = i - 1; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_MATRIX(mat,i-1,j-3,CODON); } return StatWise10_EXPL_MATRIX(mat,i - 1,j - 3,CODON); } warn("Major problem (!) - in StatWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - (0) - (0); if( temp == StatWise10_EXPL_MATRIX(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_MATRIX(mat,i-0,j-1,INTRON_0); } return StatWise10_EXPL_MATRIX(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open)) - (0); if( temp == StatWise10_EXPL_MATRIX(mat,i - 0,j - 1,CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_MATRIX(mat,i-0,j-1,CODON); } return StatWise10_EXPL_MATRIX(mat,i - 0,j - 1,CODON); } warn("Major problem (!) - in StatWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - (0) - (0); if( temp == StatWise10_EXPL_MATRIX(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_MATRIX(mat,i-0,j-1,INTRON_1); } return StatWise10_EXPL_MATRIX(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open)) - (0); if( temp == StatWise10_EXPL_MATRIX(mat,i - 0,j - 2,CODON) ) { *reti = i - 0; *retj = j - 2; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_MATRIX(mat,i-0,j-2,CODON); } return StatWise10_EXPL_MATRIX(mat,i - 0,j - 2,CODON); } warn("Major problem (!) - in StatWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - (0) - (0); if( temp == StatWise10_EXPL_MATRIX(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_MATRIX(mat,i-0,j-1,INTRON_2); } return StatWise10_EXPL_MATRIX(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open)) - (0); if( temp == StatWise10_EXPL_MATRIX(mat,i - 0,j - 3,CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_MATRIX(mat,i-0,j-3,CODON); } return StatWise10_EXPL_MATRIX(mat,i - 0,j - 3,CODON); } warn("Major problem (!) - in StatWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in StatWise10 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_StatWise10(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [StatWise10 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_StatWise10(StatWise10 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = StatWise10_READ_OFF_ERROR; if( j < 0 || j > mat->seq->length) { warn("In StatWise10 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = StatWise10_EXPL_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case RND_SEQ : /* source START is a special */ temp = cscore - (0) - (0); if( temp == StatWise10_EXPL_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_SPECIAL(mat,i-0,j-1,START); } return StatWise10_EXPL_MATRIX(mat,i - 0,j - 1,START) ; } /* source RND_SEQ is a special */ temp = cscore - (0) - (0); if( temp == StatWise10_EXPL_SPECIAL(mat,i - 0,j - 1,RND_SEQ) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_SEQ; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_SPECIAL(mat,i-0,j-1,RND_SEQ); } return StatWise10_EXPL_MATRIX(mat,i - 0,j - 1,RND_SEQ) ; } /* source CODON is from main matrix */ for(i= mat->exonmodel->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->exonmodel->exon[i]->exit_score) - (0); if( temp == StatWise10_EXPL_MATRIX(mat,i - 0,j - 0,CODON) ) { *reti = i - 0; *retj = j - 0; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_MATRIX(mat,i-0,j-0,CODON); } return StatWise10_EXPL_MATRIX(mat,i - 0,j - 0,CODON) ; } } /* end of for i >= 0 */ case START : case END : /* source RND_SEQ is a special */ temp = cscore - (0) - (0); if( temp == StatWise10_EXPL_SPECIAL(mat,i - 0,j - 1,RND_SEQ) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_SEQ; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - StatWise10_EXPL_SPECIAL(mat,i-0,j-1,RND_SEQ); } return StatWise10_EXPL_MATRIX(mat,i - 0,j - 1,RND_SEQ) ; } default: warn("Major problem (!) - in StatWise10 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_StatWise10(mat) * * Descrip: This function calculates the StatWise10 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_StatWise10 * * * Arg: mat [UNKN ] StatWise10 which contains explicit basematrix memory [StatWise10 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_StatWise10(StatWise10 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_StatWise10, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("StatWise10 Matrix calculation: "); for(j=0;jcodon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]; /* Has restricted position */ if( (i-1) == 0 ) { /* From state RND_SEQ to state CODON */ temp = StatWise10_EXPL_SPECIAL(mat,i-1,j-3,RND_SEQ) + (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->gene_open); if( temp > score ) { score = temp; } } /* From state CODON to state CODON */ temp = StatWise10_EXPL_MATRIX(mat,i-0,j-3,CODON) + (mat->codon->codon[CSEQ_GENOMIC_CODON(mat->seq,j)]+mat->exonmodel->exon[i]->stay_score); if( temp > score ) { score = temp; } /* From state INTRON_0 to state CODON */ temp = StatWise10_EXPL_MATRIX(mat,i-1,j-3,INTRON_0) + CSEQ_GENOMIC_3SS(mat->seq,(j-3)); if( temp > score ) { score = temp; } /* From state INTRON_1 to state CODON */ temp = StatWise10_EXPL_MATRIX(mat,i-1,j-2,INTRON_1) + CSEQ_GENOMIC_3SS(mat->seq,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state CODON */ temp = StatWise10_EXPL_MATRIX(mat,i-1,j-1,INTRON_2) + CSEQ_GENOMIC_3SS(mat->seq,(j-1)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ StatWise10_EXPL_MATRIX(mat,i,j,CODON) = score; /* state CODON is a source for special RND_SEQ */ temp = score + (mat->exonmodel->exon[i]->exit_score) + (0) ; if( temp > StatWise10_EXPL_SPECIAL(mat,i,j,RND_SEQ) ) { StatWise10_EXPL_SPECIAL(mat,i,j,RND_SEQ) = temp; } /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = StatWise10_EXPL_MATRIX(mat,i-0,j-1,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* From state INTRON_0 to state INTRON_0 */ temp = StatWise10_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ StatWise10_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = StatWise10_EXPL_MATRIX(mat,i-0,j-2,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* From state INTRON_1 to state INTRON_1 */ temp = StatWise10_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ StatWise10_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = StatWise10_EXPL_MATRIX(mat,i-0,j-3,CODON) + (CSEQ_GENOMIC_5SS(mat->seq,j)+mat->intron_open); /* From state INTRON_2 to state INTRON_2 */ temp = StatWise10_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ StatWise10_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* Special state RND_SEQ has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = StatWise10_EXPL_SPECIAL(mat,0,j,RND_SEQ); /* Source CODON for state RND_SEQ is not special... already calculated */ /* Source RND_SEQ is a special source for RND_SEQ */ temp = StatWise10_EXPL_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) score = temp; /* Source START is a special source for RND_SEQ */ temp = StatWise10_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ StatWise10_EXPL_SPECIAL(mat,0,j,RND_SEQ) = score; /* Finished updating state RND_SEQ */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = StatWise10_EXPL_SPECIAL(mat,0,j,END); /* Source RND_SEQ is a special source for END */ temp = StatWise10_EXPL_SPECIAL(mat,0,j - 1,RND_SEQ) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ StatWise10_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: StatWise10_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [StatWise10 *] * */ StatWise10 * StatWise10_alloc(void) { StatWise10 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(StatWise10 *) ckalloc (sizeof(StatWise10))) == NULL) { warn("StatWise10_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; out->basematrix = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_StatWise10(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [StatWise10 *] * * Return [UNKN ] Undocumented return value [StatWise10 *] * */ StatWise10 * free_StatWise10(StatWise10 * obj) { if( obj == NULL) { warn("Attempting to free a NULL pointer to a StatWise10 obj. Should be trappable"); return NULL; } if( obj->dynamite_hard_link > 1) { obj->dynamite_hard_link--; return NULL; } if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); /* obj->exonmodel is linked in */ /* obj->seq is linked in */ /* obj->codon is linked in */ /* obj->intron_open is linked in */ /* obj->gene_open is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/fivestarscan.c0000644000175000001440000000541507617434602016775 0ustar philippusers#define WISE2_CROSS_HMMER2 #include "wise2xhmmer2.h" #include "fivestate.h" #include "version.h" #include "seqaligndisplay.h" #include "hitlist.h" char * program_name = "fivestarscan"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s fivestar-directory protein-file-fasta\n",program_name); fprintf(ofp," -ga gathering cutoff (bits)\n"); show_help_DPRunImpl(ofp); show_help_HitListOutputImpl(ofp); show_standard_options(ofp); } int main(int argc,char **argv) { FiveStateFrameSet * frame; FiveStateModel * fsm; FiveStateScore * fss; RandomModel * rm; double gathering_cutoff = 0.0; double bits; int i; FILE * seqin; Sequence * seq; DPRunImpl * dpri; HitList * hl; HitPair * hp; HitAln * ha; HitListOutputImpl * hloi; PackAln * pal; AlnBlock * alb; ComplexSequence * cseq; ComplexSequenceEvalSet * cses; strip_out_float_argument(&argc,argv,"ga",&gathering_cutoff); hloi = new_HitListOutputImpl_from_argv(&argc,argv); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 3 ) { show_help(stdout); exit(12); } rm = default_RandomModel(); frame = read_FiveStateFrameSet_file(argv[1],"block.str"); if( frame == NULL ) fatal("Unable to make FiveStateModel from context %s, block.str file",argv[1]); fsm = FiveStateModel_from_FiveStateFrameSet(frame); /* dump_FiveStateModel(fsm,stdout); */ fsm->name = stringalloc(argv[1]); fold_RandomModel_into_FiveStateModel(fsm,rm); /* converts probabilities to integers for calculation */ fss = FiveStateScore_from_FiveStateModel(fsm); seqin = fopen(argv[2],"r"); if( seqin == NULL ) { fatal("Unable to open %s",argv[2]); } cses = default_aminoacid_ComplexSequenceEvalSet(); hl = HitList_alloc_std(); while( (seq = read_fasta_Sequence(seqin)) ) { cseq = new_ComplexSequence(seq,cses); pal = PackAln_bestmemory_FiveStateProtein(fss,cseq,NULL,dpri); alb = convert_PackAln_to_AlnBlock_FiveStateProtein(pal); hp = HitPair_alloc_std(); add_HitList(hl,hp); hp->query = seq; hp->bit_score = Score2Bits(pal->score); hp->raw_score = pal->score; } show_HitList_HitListOutputImpl(hloi,hl,stdout); return 0; } wise-2.4.1/src/models/dnaalign.c0000644000175000001440000045067610670453713016074 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dnaalign.h" /* Function: make_align_dnaalign(one,two,mat,se,qgap,qext,tgap,text,dpri) * * Descrip: Makes an alignment out of two DNA sequences * * * Arg: one [READ ] first sequence to align [Sequence *] * Arg: two [READ ] second sequence to align [Sequence *] * Arg: mat [READ ] DnaMatrix for the matching [DnaMatrix *] * Arg: se [READ ] DnaStartEnd policy [DnaStartEnd *] * Arg: qgap [READ ] gap open penalty in query (one) coordinate [int] * Arg: qext [READ ] gap extension penalty in query (one) coordinate [int] * Arg: tgap [READ ] gap open penalty in target (two) coordinate [int] * Arg: text [READ ] gap extension penalty in target (two) coordinate [int] * Arg: dpri [READ ] DPRunImpl structure [DPRunImpl *] * * Return [UNKN ] an alb structure of the alignment [AlnBlock *] * */ # line 123 "dnaalign.dy" AlnBlock * make_align_dnaalign(Sequence * one,Sequence * two,DnaMatrix * mat,DnaStartEnd * se,int qgap,int qext,int tgap,int text,DPRunImpl * dpri) { AlnBlock * alb; PackAln * pal; ComplexSequence * cone; ComplexSequence * ctwo; ComplexSequenceEvalSet * cses; if( one == NULL || two == NULL || mat == NULL || se == NULL ) { warn("Passed null objects into make_align_dnaalign... no!"); return NULL; } cses = default_dna_ComplexSequenceEvalSet(); assert(cses); cone = new_ComplexSequence(one,cses); ctwo = new_ComplexSequence(two,cses); assert(cone); assert(ctwo); assert(qgap <= 0 ); assert(qext <= 0 ); assert(tgap <= 0 ); assert(text <= 0 ); pal = PackAln_bestmemory_DnaAlign(cone,ctwo,mat,qgap,qext,tgap,text,se,NULL,dpri); alb = convert_PackAln_to_AlnBlock_DnaAlign(pal); free_ComplexSequence(cone); free_ComplexSequence(ctwo); free_ComplexSequenceEvalSet(cses); return alb; } /* Function: DnaStartEnd_from_policy(policy) * * Descrip: Makes a DnaStartEnd from a particular string. * Possible strings are: * * local - fully local * global - fully global * edge - aligns only to edges * * * Arg: policy [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [DnaStartEnd *] * */ # line 172 "dnaalign.dy" DnaStartEnd * DnaStartEnd_from_policy(char * policy) { int t; DnaStartEnd * out; t = get_number_from_slashed_string(policy,"local/global/edge"); if( t == -1 ) { warn("Policy %s is not a valid policy!",policy); return NULL; } out = DnaStartEnd_alloc(); switch (t) { case 0 : out->trans[DSE_GLOBAL_START] = NEGI; out->trans[DSE_GLOBAL_END] = NEGI; out->trans[DSE_LOCAL_START] = 0; out->trans[DSE_LOCAL_END] = 0; out->trans[DSE_EDGE_START] = NEGI; out->trans[DSE_EDGE_END] = NEGI; break; case 1: out->trans[DSE_GLOBAL_START] = 0; out->trans[DSE_GLOBAL_END] = 0; out->trans[DSE_LOCAL_START] = NEGI; out->trans[DSE_LOCAL_END] = NEGI; out->trans[DSE_EDGE_START] = NEGI; out->trans[DSE_EDGE_END] = NEGI; break; case 2: out->trans[DSE_GLOBAL_START] = NEGI; out->trans[DSE_GLOBAL_END] = NEGI; out->trans[DSE_LOCAL_START] = NEGI; out->trans[DSE_LOCAL_END] = NEGI; out->trans[DSE_EDGE_START] = 0; out->trans[DSE_EDGE_END] = 0; break; } return out; } # line 124 "dnaalign.c" /* Function: hard_link_DnaStartEnd(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaStartEnd *] * * Return [UNKN ] Undocumented return value [DnaStartEnd *] * */ DnaStartEnd * hard_link_DnaStartEnd(DnaStartEnd * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaStartEnd object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaStartEnd_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaStartEnd *] * */ DnaStartEnd * DnaStartEnd_alloc(void) { DnaStartEnd * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaStartEnd *) ckalloc (sizeof(DnaStartEnd))) == NULL) { warn("DnaStartEnd_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* trans[DSE_NUMBER] is an array: no default possible */ return out; } /* Function: free_DnaStartEnd(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaStartEnd *] * * Return [UNKN ] Undocumented return value [DnaStartEnd *] * */ DnaStartEnd * free_DnaStartEnd(DnaStartEnd * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaStartEnd obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define START 0 #define END 1 #define DnaAlign_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*3)+STATE][i+1] #define DnaAlign_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define DnaAlign_READ_OFF_ERROR -3 #define DnaAlign_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*3)+STATE] #define DnaAlign_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define DnaAlign_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define DnaAlign_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_DnaAlign(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_DnaAlign(DnaAlign * mat) { DnaAlign_access_func_holder holder; holder.access_main = DnaAlign_shatter_access_main; holder.access_special = DnaAlign_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_DnaAlign(mat,holder); } /* Function: DnaAlign_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int DnaAlign_shatter_access_main(DnaAlign * mat,int i,int j,int state) { return DnaAlign_SHATTER_MATRIX(mat,i,j,state); } /* Function: DnaAlign_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int DnaAlign_shatter_access_special(DnaAlign * mat,int i,int j,int state) { return DnaAlign_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_DnaAlign(mat,dpenv) * * Descrip: This function calculates the DnaAlign matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [DnaAlign *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_DnaAlign(DnaAlign * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("DnaAlign Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_1[MATCH] + 0; /* From state INSERT to state MATCH */ temp = SIG_1_1[INSERT] + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_1[DELETE] + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = DnaAlign_SHATTER_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_LOCAL_START]; if( temp > score ) { score = temp; } /* Has restricted position */ if( (j-1) == 0 ) { /* From state START to state MATCH */ temp = DnaAlign_SHATTER_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_EDGE_START]; if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-1) == 0 ) { /* From state START to state MATCH */ temp = DnaAlign_SHATTER_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_EDGE_START]; if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = DnaAlign_SHATTER_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_GLOBAL_START]; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j)); SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (mat->startend->trans[DSE_LOCAL_END]) + (0) ; if( temp > DnaAlign_SHATTER_SPECIAL(mat,i,j,END) ) { DnaAlign_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (mat->startend->trans[DSE_EDGE_END]) + (0) ; if( temp > DnaAlign_SHATTER_SPECIAL(mat,i,j,END) ) { DnaAlign_SHATTER_SPECIAL(mat,i,j,END) = temp; } } /* state MATCH is a source for special END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = score + (mat->startend->trans[DSE_EDGE_END]) + (0) ; if( temp > DnaAlign_SHATTER_SPECIAL(mat,i,j,END) ) { DnaAlign_SHATTER_SPECIAL(mat,i,j,END) = temp; } } /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (mat->startend->trans[DSE_GLOBAL_END]) + (0) ; if( temp > DnaAlign_SHATTER_SPECIAL(mat,i,j,END) ) { DnaAlign_SHATTER_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_1[MATCH] + mat->qgap; /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->qext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ SIG_0_0[INSERT] = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->tgap; /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->text; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_DnaAlign(dbsi,out,query,target,comp,qgap,qext,tgap,text,startend) * * Descrip: This function makes a database search of DnaAlign * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp [UNKN ] Undocumented argument [DnaMatrix*] * Arg: qgap [UNKN ] Undocumented argument [Score] * Arg: qext [UNKN ] Undocumented argument [Score] * Arg: tgap [UNKN ] Undocumented argument [Score] * Arg: text [UNKN ] Undocumented argument [Score] * Arg: startend [UNKN ] Undocumented argument [DnaStartEnd *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_DnaAlign(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend) { if( out == NULL ) { warn("Passed in a null Hscore object into search_DnaAlign. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_DnaAlign. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for DnaAlign, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_DnaAlign(out,query,target ,comp,qgap,qext,tgap,text,startend); case DBSearchImpl_Pthreads : warn("This matrix DnaAlign was not dyc compiled with thread support"); return SEARCH_ERROR; default : warn("database search implementation %s was not provided in the compiled dynamite file from DnaAlign",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: serial_search_DnaAlign(out,query,target,comp,qgap,qext,tgap,text,startend) * * Descrip: This function makes a database search of DnaAlign * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp [UNKN ] Undocumented argument [DnaMatrix*] * Arg: qgap [UNKN ] Undocumented argument [Score] * Arg: qext [UNKN ] Undocumented argument [Score] * Arg: tgap [UNKN ] Undocumented argument [Score] * Arg: text [UNKN ] Undocumented argument [Score] * Arg: startend [UNKN ] Undocumented argument [DnaStartEnd *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_DnaAlign(Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_DnaAlign(query, target , comp, qgap, qext, tgap, text, startend); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("DnaAlign search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_DnaAlign(query,target,comp,qgap,qext,tgap,text,startend) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_DnaAlign_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [DnaMatrix*] * Arg: qgap [UNKN ] Resource [Score] * Arg: qext [UNKN ] Resource [Score] * Arg: tgap [UNKN ] Resource [Score] * Arg: text [UNKN ] Resource [Score] * Arg: startend [UNKN ] Resource [DnaStartEnd *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_DnaAlign(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend) { int bestscore = NEGI; int i; int j; int k; DnaAlign * mat; mat = allocate_DnaAlign_only(query, target , comp, qgap, qext, tgap, text, startend); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 3,2,2)) == NULL) { warn("Score only matrix for DnaAlign cannot be allocated, (asking for 1 by %d cells)",mat->leni*3); mat = free_DnaAlign(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) DnaAlign_VSMALL_MATRIX(mat,i,j,k) = NEGI; } DnaAlign_VSMALL_SPECIAL(mat,i,j,START) = 0; DnaAlign_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = DnaAlign_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = DnaAlign_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = DnaAlign_VSMALL_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = DnaAlign_VSMALL_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_LOCAL_START]; if( temp > score ) { score = temp; } /* Has restricted position */ if( (j-1) == 0 ) { /* From state START to state MATCH */ temp = DnaAlign_VSMALL_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_EDGE_START]; if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-1) == 0 ) { /* From state START to state MATCH */ temp = DnaAlign_VSMALL_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_EDGE_START]; if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = DnaAlign_VSMALL_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_GLOBAL_START]; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j)); DnaAlign_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->startend->trans[DSE_LOCAL_END]) + (0) ; if( temp > DnaAlign_VSMALL_SPECIAL(mat,i,j,END) ) { DnaAlign_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (mat->startend->trans[DSE_EDGE_END]) + (0) ; if( temp > DnaAlign_VSMALL_SPECIAL(mat,i,j,END) ) { DnaAlign_VSMALL_SPECIAL(mat,i,j,END) = temp; } } /* state MATCH is a source for special END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = score + (mat->startend->trans[DSE_EDGE_END]) + (0) ; if( temp > DnaAlign_VSMALL_SPECIAL(mat,i,j,END) ) { DnaAlign_VSMALL_SPECIAL(mat,i,j,END) = temp; } } /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (mat->startend->trans[DSE_GLOBAL_END]) + (0) ; if( temp > DnaAlign_VSMALL_SPECIAL(mat,i,j,END) ) { DnaAlign_VSMALL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = DnaAlign_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + mat->qgap; /* From state INSERT to state INSERT */ temp = DnaAlign_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->qext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ DnaAlign_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaAlign_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->tgap; /* From state DELETE to state DELETE */ temp = DnaAlign_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->text; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ DnaAlign_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < DnaAlign_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = DnaAlign_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_DnaAlign(mat); return bestscore; } /* Function: PackAln_bestmemory_DnaAlign(query,target,comp,qgap,qext,tgap,text,startend,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_DnaAlign * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [DnaMatrix*] * Arg: qgap [UNKN ] Resource [Score] * Arg: qext [UNKN ] Resource [Score] * Arg: tgap [UNKN ] Resource [Score] * Arg: text [UNKN ] Resource [Score] * Arg: startend [UNKN ] Resource [DnaStartEnd *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_DnaAlign(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; DnaAlign * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->seq->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_DnaAlign(query, target , comp, qgap, qext, tgap, text, startend,dpri)) == NULL ) { warn("Unable to allocate large DnaAlign version"); return NULL; } calculate_dpenv_DnaAlign(mat,dpenv); out = PackAln_read_Expl_DnaAlign(mat); } else { mat = allocate_DnaAlign_only(query, target , comp, qgap, qext, tgap, text, startend); calculate_shatter_DnaAlign(mat,dpenv); out = PackAln_read_Shatter_DnaAlign(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_DnaAlign(query, target , comp, qgap, qext, tgap, text, startend)) == NULL ) { warn("Unable to allocate small DnaAlign version"); return NULL; } out = PackAln_calculate_Small_DnaAlign(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_DnaAlign(query, target , comp, qgap, qext, tgap, text, startend,dpri)) == NULL ) { warn("Unable to allocate large DnaAlign version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_DnaAlign(mat); out = PackAln_read_Expl_DnaAlign(mat); } } } mat = free_DnaAlign(mat); return out; } /* Function: allocate_DnaAlign_only(query,target,comp,qgap,qext,tgap,text,startend) * * Descrip: This function only allocates the DnaAlign structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [DnaMatrix*] * Arg: qgap [UNKN ] Resource [Score] * Arg: qext [UNKN ] Resource [Score] * Arg: tgap [UNKN ] Resource [Score] * Arg: text [UNKN ] Resource [Score] * Arg: startend [UNKN ] Resource [DnaStartEnd *] * * Return [UNKN ] Undocumented return value [DnaAlign *] * */ DnaAlign * allocate_DnaAlign_only(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend) { DnaAlign * out; if((out= DnaAlign_alloc()) == NULL) { warn("Allocation of basic DnaAlign structure failed..."); return NULL; } out->query = query; out->target = target; out->comp = comp; out->qgap = qgap; out->qext = qext; out->tgap = tgap; out->text = text; out->startend = startend; out->leni = query->seq->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_DnaAlign(query,target,comp,qgap,qext,tgap,text,startend,dpri) * * Descrip: This function allocates the DnaAlign structure * and the basematrix area for explicit memory implementations * It calls /allocate_DnaAlign_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [DnaMatrix*] * Arg: qgap [UNKN ] Resource [Score] * Arg: qext [UNKN ] Resource [Score] * Arg: tgap [UNKN ] Resource [Score] * Arg: text [UNKN ] Resource [Score] * Arg: startend [UNKN ] Resource [DnaStartEnd *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [DnaAlign *] * */ DnaAlign * allocate_Expl_DnaAlign(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend,DPRunImpl * dpri) { DnaAlign * out; out = allocate_DnaAlign_only(query, target , comp, qgap, qext, tgap, text, startend); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*3,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix DnaAlign cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_DnaAlign(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_DnaAlign(out); return out; } /* Function: init_DnaAlign(mat) * * Descrip: This function initates DnaAlign matrix when in explicit mode * Called in /allocate_Expl_DnaAlign * * * Arg: mat [UNKN ] DnaAlign which contains explicit basematrix memory [DnaAlign *] * */ void init_DnaAlign(DnaAlign * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->seq->len;i++) { for(j= (-1);j<2;j++) { DnaAlign_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; DnaAlign_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; DnaAlign_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j= (-1);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { DnaAlign_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; DnaAlign_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; DnaAlign_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } DnaAlign_EXPL_SPECIAL(mat,i,j,START) = 0; DnaAlign_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_DnaAlign(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by DnaAlign * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * */ void recalculate_PackAln_DnaAlign(PackAln * pal,DnaAlign * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = 0 + (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = 0 + (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); continue; } if( offi == 1 && offj == 1 && prev->state == DELETE ) { pau->score = 0 + (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); continue; } if( offj == 1 && prev->state == (START+3) ) { pau->score = mat->startend->trans[DSE_LOCAL_START] + (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); continue; } if( offj == 1 && prev->state == (START+3) ) { pau->score = mat->startend->trans[DSE_EDGE_START] + (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); continue; } if( offj == 1 && prev->state == (START+3) ) { pau->score = mat->startend->trans[DSE_EDGE_START] + (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); continue; } if( offj == 1 && prev->state == (START+3) ) { pau->score = mat->startend->trans[DSE_GLOBAL_START] + (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = mat->qgap + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->qext + (0); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->tgap + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->text + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+3) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->startend->trans[DSE_LOCAL_END] + (0); continue; } if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->startend->trans[DSE_EDGE_END] + (0); continue; } if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->startend->trans[DSE_EDGE_END] + (0); continue; } if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->startend->trans[DSE_GLOBAL_END] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define DnaAlign_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*3+state]) #define DnaAlign_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*3+state]) #define DnaAlign_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define DnaAlign_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define DnaAlign_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*3 + state]) #define DnaAlign_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define DnaAlign_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define DnaAlign_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define DnaAlign_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_DnaAlign(query,target,comp,qgap,qext,tgap,text,startend) * * Descrip: This function allocates the DnaAlign structure * and the basematrix area for a small memory implementations * It calls /allocate_DnaAlign_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [DnaMatrix*] * Arg: qgap [UNKN ] Resource [Score] * Arg: qext [UNKN ] Resource [Score] * Arg: tgap [UNKN ] Resource [Score] * Arg: text [UNKN ] Resource [Score] * Arg: startend [UNKN ] Resource [DnaStartEnd *] * * Return [UNKN ] Undocumented return value [DnaAlign *] * */ #define DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) DnaAlign * allocate_Small_DnaAlign(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend) { DnaAlign * out; out = allocate_DnaAlign_only(query, target , comp, qgap, qext, tgap, text, startend); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 3,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix DnaAlign cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_DnaAlign(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_DnaAlign(mat,dpenv) * * Descrip: This function calculates an alignment for DnaAlign structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_DnaAlign * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_DnaAlign * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_DnaAlign(DnaAlign * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for DnaAlign due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_DnaAlign(mat,dpenv); score = start_end_find_end_DnaAlign(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_DnaAlign(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_DnaAlign(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == DnaAlign_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_DnaAlign(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 3; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_DnaAlign(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_DnaAlign(mat) * * Descrip: This function calculates an alignment for DnaAlign structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_DnaAlign * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_DnaAlign * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_DnaAlign * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_DnaAlign(DnaAlign * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_DnaAlign(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_DnaAlign(mat); return out; } /* Function: AlnRangeSet_from_DnaAlign(mat) * * Descrip: This function reads off a start/end structure * for DnaAlign structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_DnaAlign * If you have not calculated the matrix use * /AlnRange_calculate_Small_DnaAlign * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_DnaAlign(DnaAlign * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_DnaAlign"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_DnaAlign(mat,&jpos); state = END; while( (temp = AlnRange_build_DnaAlign(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_DnaAlign(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_DnaAlign * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_DnaAlign(DnaAlign * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_DnaAlign"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_DnaAlign(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_DnaAlign alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = DnaAlign_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_DnaAlign(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == DnaAlign_READ_OFF_ERROR) { warn("In AlnRange_build_DnaAlign alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = DnaAlign_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_DnaAlign(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_DnaAlign(DnaAlign * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_DnaAlign(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == DnaAlign_READ_OFF_ERROR) { warn("In DnaAlign hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In DnaAlign hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In DnaAlign hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_DnaAlign(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_DnaAlign(DnaAlign * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = DnaAlign_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In DnaAlign matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = DnaAlign_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Not allowing special sources.. skipping START */ /* Not allowing special sources.. skipping START */ /* Not allowing special sources.. skipping START */ /* Not allowing special sources.. skipping START */ temp = cscore - (0) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == DnaAlign_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaAlign_HIDDEN_MATRIX(mat,i-1,j-1,DELETE); } return DnaAlign_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE); } temp = cscore - (0) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == DnaAlign_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaAlign_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return DnaAlign_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (0) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == DnaAlign_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaAlign_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return DnaAlign_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in DnaAlign read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->qext) - (0); if( temp == DnaAlign_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaAlign_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return DnaAlign_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->qgap) - (0); if( temp == DnaAlign_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaAlign_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return DnaAlign_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in DnaAlign read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->text) - (0); if( temp == DnaAlign_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaAlign_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return DnaAlign_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->tgap) - (0); if( temp == DnaAlign_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaAlign_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return DnaAlign_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in DnaAlign read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in DnaAlign read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_DnaAlign(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_DnaAlign(DnaAlign * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > DnaAlign_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_DnaAlign(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == DnaAlign_READ_OFF_ERROR) { warn("In special strip read DnaAlign, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < DnaAlign_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read DnaAlign, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_DnaAlign(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_DnaAlign(DnaAlign * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = DnaAlign_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for DnaAlign, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In DnaAlign matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = DnaAlign_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source MATCH is not a special */ /* Source MATCH is not a special */ /* Source MATCH is not a special */ /* Source MATCH is not a special */ default: warn("Major problem (!) - in DnaAlign special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_DnaAlign(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_DnaAlign(DnaAlign * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = DnaAlign_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In DnaAlign matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->startend->trans[DSE_GLOBAL_START]) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == DnaAlign_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - DnaAlign_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return DnaAlign_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } temp = cscore - (mat->startend->trans[DSE_EDGE_START]) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == DnaAlign_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - DnaAlign_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return DnaAlign_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } temp = cscore - (mat->startend->trans[DSE_EDGE_START]) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == DnaAlign_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - DnaAlign_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return DnaAlign_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } temp = cscore - (mat->startend->trans[DSE_LOCAL_START]) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == DnaAlign_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - DnaAlign_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return DnaAlign_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in DnaAlign matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in DnaAlign matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Source DELETE is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in DnaAlign matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in DnaAlign read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_DnaAlign(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_DnaAlign(DnaAlign * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_DnaAlign(mat,starti,startj,stopi,stopj); DnaAlign_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ DnaAlign_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; DnaAlign_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; DnaAlign_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = DnaAlign_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = DnaAlign_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = DnaAlign_HIDDEN_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j)); DnaAlign_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = DnaAlign_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + mat->qgap; /* From state INSERT to state INSERT */ temp = DnaAlign_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->qext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ DnaAlign_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaAlign_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->tgap; /* From state DELETE to state DELETE */ temp = DnaAlign_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->text; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ DnaAlign_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } } return; } /* Function: init_hidden_DnaAlign(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_DnaAlign(DnaAlign * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { DnaAlign_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; DnaAlign_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; DnaAlign_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; } } return; } /* Function: full_dc_DnaAlign(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_DnaAlign * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_DnaAlign to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [DnaAlign *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_DnaAlign(DnaAlign * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_DnaAlign"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_DnaAlign(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_DnaAlign(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_DnaAlign(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for DnaAlign, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= DnaAlign_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= DnaAlign_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = DnaAlign_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_DnaAlign(mat,DnaAlign_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),DnaAlign_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),DnaAlign_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_DnaAlign(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_DnaAlign(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_DnaAlign(DnaAlign * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_DnaAlign(mat); DnaAlign_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_DnaAlign(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_DnaAlign(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_DnaAlign(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_DnaAlign(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_DnaAlign(DnaAlign * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ DnaAlign_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); DnaAlign_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); DnaAlign_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; if( j - 1 <= mergej) { DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } temp = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } temp = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } } /* Add any movement independant score */ score += DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j)); DnaAlign_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = DnaAlign_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->qgap; if( j - 1 <= mergej) { DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } temp = DnaAlign_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->qext; if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } /* Add any movement independant score */ DnaAlign_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->tgap; if( j - 0 <= mergej) { DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->text; if( temp > score) { score = temp; if( j - 0 <= mergej) { DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ DnaAlign_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_DnaAlign(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_DnaAlign(DnaAlign * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ DnaAlign_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; DnaAlign_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; DnaAlign_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); /* From state INSERT to state MATCH */ temp = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* From state DELETE to state MATCH */ temp = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j)); DnaAlign_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = DnaAlign_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->qgap; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); /* From state INSERT to state INSERT */ temp = DnaAlign_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->qext; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ DnaAlign_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->tgap; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state DELETE to state DELETE */ temp = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->text; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaAlign_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ DnaAlign_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_DnaAlign(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_DnaAlign(DnaAlign * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ DnaAlign_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; DnaAlign_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; DnaAlign_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j)); DnaAlign_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = DnaAlign_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->qgap; /* From state INSERT to state INSERT */ temp = DnaAlign_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->qext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ DnaAlign_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->tgap; /* From state DELETE to state DELETE */ temp = DnaAlign_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->text; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ DnaAlign_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_DnaAlign(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * */ } void init_dc_DnaAlign(DnaAlign * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { DnaAlign_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; DnaAlign_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; DnaAlign_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; for(k=0;k<7;k++) { DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); } } } return; } /* Function: start_end_find_end_DnaAlign(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [DnaAlign *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_DnaAlign(DnaAlign * mat,int * endj) { register int j; register int max; register int maxj; max = DnaAlign_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( DnaAlign_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = DnaAlign_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_DnaAlign(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [DnaAlign] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_DnaAlign(DnaAlign *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->seq->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jcomp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); /* assign local shadown pointer */ localsp = &(DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); /* From state INSERT to state MATCH */ temp = DnaAlign_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0 +(DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* From state DELETE to state MATCH */ temp = DnaAlign_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0 +(DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,0)); } /* From state START to state MATCH */ temp = DnaAlign_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_LOCAL_START] + (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state START to state MATCH */ temp = DnaAlign_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_EDGE_START] + (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state START to state MATCH */ temp = DnaAlign_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_EDGE_START] + (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state START to state MATCH */ temp = DnaAlign_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_GLOBAL_START] + (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ DnaAlign_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (mat->startend->trans[DSE_LOCAL_END]) + (0) ; if( temp > DnaAlign_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { DnaAlign_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* state MATCH is a source for special END */ temp = score + (mat->startend->trans[DSE_EDGE_END]) + (0) ; if( temp > DnaAlign_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { DnaAlign_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* state MATCH is a source for special END */ temp = score + (mat->startend->trans[DSE_EDGE_END]) + (0) ; if( temp > DnaAlign_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { DnaAlign_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* state MATCH is a source for special END */ temp = score + (mat->startend->trans[DSE_GLOBAL_END]) + (0) ; if( temp > DnaAlign_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { DnaAlign_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; DnaAlign_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = DnaAlign_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->qgap + (0); /* assign local shadown pointer */ localsp = &(DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); /* From state INSERT to state INSERT */ temp = DnaAlign_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->qext +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ DnaAlign_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaAlign_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->tgap + (0); /* assign local shadown pointer */ localsp = &(DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state DELETE to state DELETE */ temp = DnaAlign_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->text +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ DnaAlign_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) DnaAlign_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_DnaAlign(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * */ void init_start_end_linear_DnaAlign(DnaAlign * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { DnaAlign_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); DnaAlign_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); DnaAlign_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; DnaAlign_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); } } for(j=(-1);jtarget->seq->len;j++) { DnaAlign_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; DnaAlign_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; DnaAlign_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_DnaAlign(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_DnaAlign(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_DnaAlign(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "SEQUENCE","INSERT","END" }; /* Function: AlnConvertSet_DnaAlign(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "SEQUENCE","INSERT","END" }; AlnConvertSet * AlnConvertSet_DnaAlign(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; return out; } /* Function: PackAln_read_Expl_DnaAlign(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_DnaAlign(DnaAlign * mat) { DnaAlign_access_func_holder holder; holder.access_main = DnaAlign_explicit_access_main; holder.access_special = DnaAlign_explicit_access_special; return PackAln_read_generic_DnaAlign(mat,holder); } /* Function: DnaAlign_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int DnaAlign_explicit_access_main(DnaAlign * mat,int i,int j,int state) { return DnaAlign_EXPL_MATRIX(mat,i,j,state); } /* Function: DnaAlign_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int DnaAlign_explicit_access_special(DnaAlign * mat,int i,int j,int state) { return DnaAlign_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_DnaAlign(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: h [UNKN ] Undocumented argument [DnaAlign_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_DnaAlign(DnaAlign * mat,DnaAlign_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_DnaAlign(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in DnaAlign_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_DnaAlign(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_DnaAlign(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == DnaAlign_READ_OFF_ERROR || j == DnaAlign_READ_OFF_ERROR || state == DnaAlign_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in DnaAlign_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_DnaAlign(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [DnaAlign_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_DnaAlign(DnaAlign * mat,int * ri,int * rj,int * state,boolean * isspecial,DnaAlign_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: DnaAlign_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void DnaAlign_debug_show_matrix(DnaAlign * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->seq->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",DnaAlign_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",DnaAlign_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",DnaAlign_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_DnaAlign(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [DnaAlign_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_DnaAlign(DnaAlign * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,DnaAlign_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = DnaAlign_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In DnaAlign matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { temp = cscore - (mat->startend->trans[DSE_GLOBAL_START]) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } } /* Has restricted position */ if( (i-1) == 0 ) { temp = cscore - (mat->startend->trans[DSE_EDGE_START]) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } } /* Has restricted position */ if( (j-1) == 0 ) { temp = cscore - (mat->startend->trans[DSE_EDGE_START]) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } } temp = cscore - (mat->startend->trans[DSE_LOCAL_START]) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (0) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,DELETE); } return (*h.access_main)(mat,i - 1,j - 1,DELETE); } temp = cscore - (0) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (0) - (DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j))); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in DnaAlign read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->qext) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->qgap) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in DnaAlign read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->text) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->tgap) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in DnaAlign read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in DnaAlign read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_DnaAlign(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [DnaAlign_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_DnaAlign(DnaAlign * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,DnaAlign_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = DnaAlign_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In DnaAlign matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source MATCH is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->startend->trans[DSE_GLOBAL_END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->startend->trans[DSE_EDGE_END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->startend->trans[DSE_EDGE_END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->startend->trans[DSE_LOCAL_END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in DnaAlign read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_DnaAlign(mat) * * Descrip: This function calculates the DnaAlign matrix when in explicit mode * To allocate the matrix use /allocate_Expl_DnaAlign * * * Arg: mat [UNKN ] DnaAlign which contains explicit basematrix memory [DnaAlign *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_DnaAlign(DnaAlign * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_DnaAlign, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("DnaAlign Matrix calculation: "); for(j=0;j score ) { score = temp; } /* From state DELETE to state MATCH */ temp = DnaAlign_EXPL_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = DnaAlign_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_LOCAL_START]; if( temp > score ) { score = temp; } /* Has restricted position */ if( (j-1) == 0 ) { /* From state START to state MATCH */ temp = DnaAlign_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_EDGE_START]; if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-1) == 0 ) { /* From state START to state MATCH */ temp = DnaAlign_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_EDGE_START]; if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = DnaAlign_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_GLOBAL_START]; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j)); DnaAlign_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->startend->trans[DSE_LOCAL_END]) + (0) ; if( temp > DnaAlign_EXPL_SPECIAL(mat,i,j,END) ) { DnaAlign_EXPL_SPECIAL(mat,i,j,END) = temp; } /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (mat->startend->trans[DSE_EDGE_END]) + (0) ; if( temp > DnaAlign_EXPL_SPECIAL(mat,i,j,END) ) { DnaAlign_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* state MATCH is a source for special END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = score + (mat->startend->trans[DSE_EDGE_END]) + (0) ; if( temp > DnaAlign_EXPL_SPECIAL(mat,i,j,END) ) { DnaAlign_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (mat->startend->trans[DSE_GLOBAL_END]) + (0) ; if( temp > DnaAlign_EXPL_SPECIAL(mat,i,j,END) ) { DnaAlign_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = DnaAlign_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->qgap; /* From state INSERT to state INSERT */ temp = DnaAlign_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->qext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ DnaAlign_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaAlign_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->tgap; /* From state DELETE to state DELETE */ temp = DnaAlign_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->text; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ DnaAlign_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_DnaAlign(mat,dpenv) * * Descrip: This function calculates the DnaAlign matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] DnaAlign which contains explicit basematrix memory [DnaAlign *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_DnaAlign(DnaAlign * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_DnaAlign, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { DnaAlign_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; DnaAlign_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; DnaAlign_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j=-1;jlenj;j++) { DnaAlign_EXPL_SPECIAL(mat,i,j,START) = 0; DnaAlign_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("DnaAlign Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { DnaAlign_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; DnaAlign_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; DnaAlign_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = DnaAlign_EXPL_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state INSERT to state MATCH */ temp = DnaAlign_EXPL_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = DnaAlign_EXPL_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = DnaAlign_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_LOCAL_START]; if( temp > score ) { score = temp; } /* Has restricted position */ if( (j-1) == 0 ) { /* From state START to state MATCH */ temp = DnaAlign_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_EDGE_START]; if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-1) == 0 ) { /* From state START to state MATCH */ temp = DnaAlign_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_EDGE_START]; if( temp > score ) { score = temp; } } /* Has restricted position */ if( (i-1) == 0 && (j-1) == 0 ) { /* From state START to state MATCH */ temp = DnaAlign_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->startend->trans[DSE_GLOBAL_START]; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += DnaMatrix_MATCH(mat->comp,CSEQ_DNA_BASE(mat->query,i),CSEQ_DNA_BASE(mat->target,j)); DnaAlign_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->startend->trans[DSE_LOCAL_END]) + (0) ; if( temp > DnaAlign_EXPL_SPECIAL(mat,i,j,END) ) { DnaAlign_EXPL_SPECIAL(mat,i,j,END) = temp; } /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 ) { temp = score + (mat->startend->trans[DSE_EDGE_END]) + (0) ; if( temp > DnaAlign_EXPL_SPECIAL(mat,i,j,END) ) { DnaAlign_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* state MATCH is a source for special END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = score + (mat->startend->trans[DSE_EDGE_END]) + (0) ; if( temp > DnaAlign_EXPL_SPECIAL(mat,i,j,END) ) { DnaAlign_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* state MATCH is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (mat->startend->trans[DSE_GLOBAL_END]) + (0) ; if( temp > DnaAlign_EXPL_SPECIAL(mat,i,j,END) ) { DnaAlign_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = DnaAlign_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->qgap; /* From state INSERT to state INSERT */ temp = DnaAlign_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->qext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ DnaAlign_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaAlign_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->tgap; /* From state DELETE to state DELETE */ temp = DnaAlign_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->text; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ DnaAlign_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: DnaAlign_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaAlign *] * */ DnaAlign * DnaAlign_alloc(void) { DnaAlign * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaAlign *) ckalloc (sizeof(DnaAlign))) == NULL) { warn("DnaAlign_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_DnaAlign(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaAlign *] * * Return [UNKN ] Undocumented return value [DnaAlign *] * */ DnaAlign * free_DnaAlign(DnaAlign * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaAlign obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->comp is linked in */ /* obj->qgap is linked in */ /* obj->qext is linked in */ /* obj->tgap is linked in */ /* obj->text is linked in */ /* obj->startend is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/dnaalign.h0000644000175000001440000005521410670453713016066 0ustar philippusers#ifndef DYNAMITEdnaalignHEADERFILE #define DYNAMITEdnaalignHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" enum DnaStartEndEnum { DSE_GLOBAL_START = 0, DSE_GLOBAL_END, DSE_EDGE_START, DSE_EDGE_END, DSE_LOCAL_START, DSE_LOCAL_END, DSE_NUMBER }; struct Wise2_DnaStartEnd { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int trans[DSE_NUMBER]; /* start/end points possibilities */ } ; /* DnaStartEnd defined */ #ifndef DYNAMITE_DEFINED_DnaStartEnd typedef struct Wise2_DnaStartEnd Wise2_DnaStartEnd; #define DnaStartEnd Wise2_DnaStartEnd #define DYNAMITE_DEFINED_DnaStartEnd #endif struct Wise2_DnaAlign { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; ComplexSequence* query; ComplexSequence* target; DnaMatrix* comp; Score qgap; Score qext; Score tgap; Score text; DnaStartEnd * startend; } ; /* DnaAlign defined */ #ifndef DYNAMITE_DEFINED_DnaAlign typedef struct Wise2_DnaAlign Wise2_DnaAlign; #define DnaAlign Wise2_DnaAlign #define DYNAMITE_DEFINED_DnaAlign #endif struct Wise2_DnaAlign_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(DnaAlign*,int,int,int); int (*access_special)(DnaAlign*,int,int,int); } ; /* DnaAlign_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_DnaAlign_access_func_holder typedef struct Wise2_DnaAlign_access_func_holder Wise2_DnaAlign_access_func_holder; #define DnaAlign_access_func_holder Wise2_DnaAlign_access_func_holder #define DYNAMITE_DEFINED_DnaAlign_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: make_align_dnaalign(one,two,mat,se,qgap,qext,tgap,text,dpri) * * Descrip: Makes an alignment out of two DNA sequences * * * Arg: one [READ ] first sequence to align [Sequence *] * Arg: two [READ ] second sequence to align [Sequence *] * Arg: mat [READ ] DnaMatrix for the matching [DnaMatrix *] * Arg: se [READ ] DnaStartEnd policy [DnaStartEnd *] * Arg: qgap [READ ] gap open penalty in query (one) coordinate [int] * Arg: qext [READ ] gap extension penalty in query (one) coordinate [int] * Arg: tgap [READ ] gap open penalty in target (two) coordinate [int] * Arg: text [READ ] gap extension penalty in target (two) coordinate [int] * Arg: dpri [READ ] DPRunImpl structure [DPRunImpl *] * * Return [UNKN ] an alb structure of the alignment [AlnBlock *] * */ AlnBlock * Wise2_make_align_dnaalign(Sequence * one,Sequence * two,DnaMatrix * mat,DnaStartEnd * se,int qgap,int qext,int tgap,int text,DPRunImpl * dpri); #define make_align_dnaalign Wise2_make_align_dnaalign /* Function: DnaStartEnd_from_policy(policy) * * Descrip: Makes a DnaStartEnd from a particular string. * Possible strings are: * * local - fully local * global - fully global * edge - aligns only to edges * * * Arg: policy [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [DnaStartEnd *] * */ DnaStartEnd * Wise2_DnaStartEnd_from_policy(char * policy); #define DnaStartEnd_from_policy Wise2_DnaStartEnd_from_policy /* Function: hard_link_DnaStartEnd(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaStartEnd *] * * Return [UNKN ] Undocumented return value [DnaStartEnd *] * */ DnaStartEnd * Wise2_hard_link_DnaStartEnd(DnaStartEnd * obj); #define hard_link_DnaStartEnd Wise2_hard_link_DnaStartEnd /* Function: DnaStartEnd_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaStartEnd *] * */ DnaStartEnd * Wise2_DnaStartEnd_alloc(void); #define DnaStartEnd_alloc Wise2_DnaStartEnd_alloc /* Function: free_DnaStartEnd(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaStartEnd *] * * Return [UNKN ] Undocumented return value [DnaStartEnd *] * */ DnaStartEnd * Wise2_free_DnaStartEnd(DnaStartEnd * obj); #define free_DnaStartEnd Wise2_free_DnaStartEnd /* Function: PackAln_read_Shatter_DnaAlign(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_DnaAlign(DnaAlign * mat); #define PackAln_read_Shatter_DnaAlign Wise2_PackAln_read_Shatter_DnaAlign /* Function: calculate_shatter_DnaAlign(mat,dpenv) * * Descrip: This function calculates the DnaAlign matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [DnaAlign *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_DnaAlign(DnaAlign * mat,DPEnvelope * dpenv); #define calculate_shatter_DnaAlign Wise2_calculate_shatter_DnaAlign /* Function: search_DnaAlign(dbsi,out,query,target,comp,qgap,qext,tgap,text,startend) * * Descrip: This function makes a database search of DnaAlign * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp [UNKN ] Undocumented argument [DnaMatrix*] * Arg: qgap [UNKN ] Undocumented argument [Score] * Arg: qext [UNKN ] Undocumented argument [Score] * Arg: tgap [UNKN ] Undocumented argument [Score] * Arg: text [UNKN ] Undocumented argument [Score] * Arg: startend [UNKN ] Undocumented argument [DnaStartEnd *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_DnaAlign(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend); #define search_DnaAlign Wise2_search_DnaAlign /* Function: serial_search_DnaAlign(out,query,target,comp,qgap,qext,tgap,text,startend) * * Descrip: This function makes a database search of DnaAlign * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp [UNKN ] Undocumented argument [DnaMatrix*] * Arg: qgap [UNKN ] Undocumented argument [Score] * Arg: qext [UNKN ] Undocumented argument [Score] * Arg: tgap [UNKN ] Undocumented argument [Score] * Arg: text [UNKN ] Undocumented argument [Score] * Arg: startend [UNKN ] Undocumented argument [DnaStartEnd *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_DnaAlign(Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend); #define serial_search_DnaAlign Wise2_serial_search_DnaAlign /* Function: PackAln_bestmemory_DnaAlign(query,target,comp,qgap,qext,tgap,text,startend,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_DnaAlign * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [DnaMatrix*] * Arg: qgap [UNKN ] Resource [Score] * Arg: qext [UNKN ] Resource [Score] * Arg: tgap [UNKN ] Resource [Score] * Arg: text [UNKN ] Resource [Score] * Arg: startend [UNKN ] Resource [DnaStartEnd *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_DnaAlign(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_DnaAlign Wise2_PackAln_bestmemory_DnaAlign /* Function: allocate_Expl_DnaAlign(query,target,comp,qgap,qext,tgap,text,startend,dpri) * * Descrip: This function allocates the DnaAlign structure * and the basematrix area for explicit memory implementations * It calls /allocate_DnaAlign_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [DnaMatrix*] * Arg: qgap [UNKN ] Resource [Score] * Arg: qext [UNKN ] Resource [Score] * Arg: tgap [UNKN ] Resource [Score] * Arg: text [UNKN ] Resource [Score] * Arg: startend [UNKN ] Resource [DnaStartEnd *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [DnaAlign *] * */ DnaAlign * Wise2_allocate_Expl_DnaAlign(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend,DPRunImpl * dpri); #define allocate_Expl_DnaAlign Wise2_allocate_Expl_DnaAlign /* Function: recalculate_PackAln_DnaAlign(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by DnaAlign * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * */ void Wise2_recalculate_PackAln_DnaAlign(PackAln * pal,DnaAlign * mat); #define recalculate_PackAln_DnaAlign Wise2_recalculate_PackAln_DnaAlign /* Function: allocate_Small_DnaAlign(query,target,comp,qgap,qext,tgap,text,startend) * * Descrip: This function allocates the DnaAlign structure * and the basematrix area for a small memory implementations * It calls /allocate_DnaAlign_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp [UNKN ] Resource [DnaMatrix*] * Arg: qgap [UNKN ] Resource [Score] * Arg: qext [UNKN ] Resource [Score] * Arg: tgap [UNKN ] Resource [Score] * Arg: text [UNKN ] Resource [Score] * Arg: startend [UNKN ] Resource [DnaStartEnd *] * * Return [UNKN ] Undocumented return value [DnaAlign *] * */ DnaAlign * Wise2_allocate_Small_DnaAlign(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend); #define allocate_Small_DnaAlign Wise2_allocate_Small_DnaAlign /* Function: PackAln_calculate_Small_DnaAlign(mat,dpenv) * * Descrip: This function calculates an alignment for DnaAlign structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_DnaAlign * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_DnaAlign * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_DnaAlign(DnaAlign * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_DnaAlign Wise2_PackAln_calculate_Small_DnaAlign /* Function: AlnRangeSet_calculate_Small_DnaAlign(mat) * * Descrip: This function calculates an alignment for DnaAlign structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_DnaAlign * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_DnaAlign * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_DnaAlign * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_DnaAlign(DnaAlign * mat); #define AlnRangeSet_calculate_Small_DnaAlign Wise2_AlnRangeSet_calculate_Small_DnaAlign /* Function: AlnRangeSet_from_DnaAlign(mat) * * Descrip: This function reads off a start/end structure * for DnaAlign structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_DnaAlign * If you have not calculated the matrix use * /AlnRange_calculate_Small_DnaAlign * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_DnaAlign(DnaAlign * mat); #define AlnRangeSet_from_DnaAlign Wise2_AlnRangeSet_from_DnaAlign /* Function: convert_PackAln_to_AlnBlock_DnaAlign(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_DnaAlign(PackAln * pal); #define convert_PackAln_to_AlnBlock_DnaAlign Wise2_convert_PackAln_to_AlnBlock_DnaAlign /* Function: PackAln_read_Expl_DnaAlign(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_DnaAlign(DnaAlign * mat); #define PackAln_read_Expl_DnaAlign Wise2_PackAln_read_Expl_DnaAlign /* Function: PackAln_read_generic_DnaAlign(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaAlign *] * Arg: h [UNKN ] Undocumented argument [DnaAlign_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_DnaAlign(DnaAlign * mat,DnaAlign_access_func_holder h); #define PackAln_read_generic_DnaAlign Wise2_PackAln_read_generic_DnaAlign /* Function: calculate_DnaAlign(mat) * * Descrip: This function calculates the DnaAlign matrix when in explicit mode * To allocate the matrix use /allocate_Expl_DnaAlign * * * Arg: mat [UNKN ] DnaAlign which contains explicit basematrix memory [DnaAlign *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_DnaAlign(DnaAlign * mat); #define calculate_DnaAlign Wise2_calculate_DnaAlign /* Function: calculate_dpenv_DnaAlign(mat,dpenv) * * Descrip: This function calculates the DnaAlign matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] DnaAlign which contains explicit basematrix memory [DnaAlign *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_DnaAlign(DnaAlign * mat,DPEnvelope * dpenv); #define calculate_dpenv_DnaAlign Wise2_calculate_dpenv_DnaAlign /* Function: DnaAlign_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaAlign *] * */ DnaAlign * Wise2_DnaAlign_alloc(void); #define DnaAlign_alloc Wise2_DnaAlign_alloc /* Function: free_DnaAlign(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaAlign *] * * Return [UNKN ] Undocumented return value [DnaAlign *] * */ DnaAlign * Wise2_free_DnaAlign(DnaAlign * obj); #define free_DnaAlign Wise2_free_DnaAlign /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_DnaAlign_shatter_access_main(DnaAlign * mat,int i,int j,int state); #define DnaAlign_shatter_access_main Wise2_DnaAlign_shatter_access_main int Wise2_DnaAlign_shatter_access_special(DnaAlign * mat,int i,int j,int state); #define DnaAlign_shatter_access_special Wise2_DnaAlign_shatter_access_special int Wise2_score_only_DnaAlign(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend); #define score_only_DnaAlign Wise2_score_only_DnaAlign DnaAlign * Wise2_allocate_DnaAlign_only(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp,Score qgap,Score qext,Score tgap,Score text,DnaStartEnd * startend); #define allocate_DnaAlign_only Wise2_allocate_DnaAlign_only void Wise2_init_DnaAlign(DnaAlign * mat); #define init_DnaAlign Wise2_init_DnaAlign AlnRange * Wise2_AlnRange_build_DnaAlign(DnaAlign * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_DnaAlign Wise2_AlnRange_build_DnaAlign boolean Wise2_read_hidden_DnaAlign(DnaAlign * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_DnaAlign Wise2_read_hidden_DnaAlign int Wise2_max_hidden_DnaAlign(DnaAlign * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_DnaAlign Wise2_max_hidden_DnaAlign boolean Wise2_read_special_strip_DnaAlign(DnaAlign * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_DnaAlign Wise2_read_special_strip_DnaAlign int Wise2_max_special_strip_DnaAlign(DnaAlign * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_DnaAlign Wise2_max_special_strip_DnaAlign int Wise2_max_matrix_to_special_DnaAlign(DnaAlign * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_DnaAlign Wise2_max_matrix_to_special_DnaAlign void Wise2_calculate_hidden_DnaAlign(DnaAlign * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_DnaAlign Wise2_calculate_hidden_DnaAlign void Wise2_init_hidden_DnaAlign(DnaAlign * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_DnaAlign Wise2_init_hidden_DnaAlign boolean Wise2_full_dc_DnaAlign(DnaAlign * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_DnaAlign Wise2_full_dc_DnaAlign boolean Wise2_do_dc_single_pass_DnaAlign(DnaAlign * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_DnaAlign Wise2_do_dc_single_pass_DnaAlign void Wise2_push_dc_at_merge_DnaAlign(DnaAlign * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_DnaAlign Wise2_push_dc_at_merge_DnaAlign void Wise2_follow_on_dc_DnaAlign(DnaAlign * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_DnaAlign Wise2_follow_on_dc_DnaAlign void Wise2_run_up_dc_DnaAlign(DnaAlign * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_DnaAlign Wise2_run_up_dc_DnaAlign void Wise2_init_dc_DnaAlign(DnaAlign * mat); #define init_dc_DnaAlign Wise2_init_dc_DnaAlign int Wise2_start_end_find_end_DnaAlign(DnaAlign * mat,int * endj); #define start_end_find_end_DnaAlign Wise2_start_end_find_end_DnaAlign boolean Wise2_dc_optimised_start_end_calc_DnaAlign(DnaAlign *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_DnaAlign Wise2_dc_optimised_start_end_calc_DnaAlign void Wise2_init_start_end_linear_DnaAlign(DnaAlign * mat); #define init_start_end_linear_DnaAlign Wise2_init_start_end_linear_DnaAlign AlnConvertSet * Wise2_AlnConvertSet_DnaAlign(void); #define AlnConvertSet_DnaAlign Wise2_AlnConvertSet_DnaAlign int Wise2_DnaAlign_explicit_access_main(DnaAlign * mat,int i,int j,int state); #define DnaAlign_explicit_access_main Wise2_DnaAlign_explicit_access_main int Wise2_DnaAlign_explicit_access_special(DnaAlign * mat,int i,int j,int state); #define DnaAlign_explicit_access_special Wise2_DnaAlign_explicit_access_special int Wise2_find_end_DnaAlign(DnaAlign * mat,int * ri,int * rj,int * state,boolean * isspecial,DnaAlign_access_func_holder h); #define find_end_DnaAlign Wise2_find_end_DnaAlign void Wise2_DnaAlign_debug_show_matrix(DnaAlign * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define DnaAlign_debug_show_matrix Wise2_DnaAlign_debug_show_matrix int Wise2_max_calc_DnaAlign(DnaAlign * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,DnaAlign_access_func_holder h); #define max_calc_DnaAlign Wise2_max_calc_DnaAlign int Wise2_max_calc_special_DnaAlign(DnaAlign * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,DnaAlign_access_func_holder h); #define max_calc_special_DnaAlign Wise2_max_calc_special_DnaAlign #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/sw_wrap.dy0000644000175000001440000002670607523254007016162 0ustar philippusers %{ #include "proteinsw.h" #include "abc.h" #include "pba.h" %} api func Align_strings_ProteinSmithWaterman func Align_Sequences_ProteinSmithWaterman func Align_Proteins_SmithWaterman func Align_Proteins_ABC func Align_Sequences_ProteinABC func Hscore_from_ProteinSW func Hscore_from_ProteinABC func Hscore_from_ProteinBA endapi %{ #include "sw_wrap.h" %func This is the most *stupidly* abstracted view of two sequences getting aligned, being two strings. It would be much better if you used Sequence objects or Protein objects to carry the proteins. %arg one string of the first sequence two string of the second sequence comp Comparison Matrix gap gap penalty ext extension penalty %% AlnBlock * Align_strings_ProteinSmithWaterman(char * one,char * two,CompMat * comp,int gap,int ext,DPEnvelope * dpenv,DPRunImpl * dpri) { Sequence * one_s; Sequence * two_s; AlnBlock * out; /* error check the strings? */ one_s = new_Sequence_from_strings(NULL,one); if( one_s == NULL ) { warn("Cannot make new sequence...\n"); return NULL; } two_s = new_Sequence_from_strings(NULL,two); if( two_s == NULL ) { warn("Cannot make new sequence...\n"); return NULL; } out = Align_Sequences_ProteinSmithWaterman(one_s,two_s,comp,gap,ext,dpenv,dpri); free_Sequence(one_s); free_Sequence(two_s); return out; } %func This function is a mid-level abstraction of comparing two sequences, which could be generic types (eg DNA!). This is tested for and warnings are given but the alignment is still calculated. To prevent this test warning either make sure the Sequence types are set to PROTEIN or, better still, use the high level abstraction Align_Proteins_SmithWaterman Otherwise this performs a standard smith waterman protein alignment... To display the alignment use write_pretty_seq_align %arg one r First sequence to compare two r Second sequecne to compare comp r Comparison matrix to use gap gap penalty. Must be negative or 0 ext ext penalty. Must be negative or 0 return o new AlnBlock structure representing the alignment %% AlnBlock * Align_Sequences_ProteinSmithWaterman(Sequence * one,Sequence * two,CompMat * comp,int gap,int ext,DPEnvelope * dpenv,DPRunImpl * dpri) { AlnBlock * out = NULL; ComplexSequenceEvalSet * evalfunc = NULL; ComplexSequence * query_cs = NULL; ComplexSequence * target_cs = NULL; PackAln * pal = NULL; if( one == NULL || two == NULL || comp == NULL ) { warn("Passed in NULL objects into Align_Sequences_ProteinSmithWaterman!"); return NULL; } if( one->type != SEQUENCE_PROTEIN ) { warn("Sequence %s is not typed as protein... ignoring!\n",one->name); } if( two->type != SEQUENCE_PROTEIN ) { warn("Sequence %s is not typed as protein... ignoring!\n",two->name); } if( gap > 0 || ext > 0 ) { warn("Gap penalties %d,%d only make sense if they are negative",gap,ext); return NULL; } evalfunc = default_aminoacid_ComplexSequenceEvalSet(); query_cs = new_ComplexSequence(one,evalfunc); if( query_cs == NULL ) goto cleanup; target_cs = new_ComplexSequence(two,evalfunc); if( target_cs == NULL ) goto cleanup; pal = PackAln_bestmemory_ProteinSW(query_cs,target_cs,comp,gap,ext,dpenv,dpri); if( pal == NULL ) goto cleanup; out = convert_PackAln_to_AlnBlock_ProteinSW(pal); goto cleanup; cleanup : if( query_cs != NULL ) free_ComplexSequence(query_cs); if( target_cs != NULL ) free_ComplexSequence(target_cs); if( pal != NULL ) free_PackAln(pal); if( evalfunc != NULL ) free_ComplexSequenceEvalSet(evalfunc); return out; } %func This is a way of aligning two sequences using the ProteinBlockAligner algorithm %arg one Sequence to align two Sequence to align comp Comparison Matrix bentry entry into a block bexit exit for a block b1exit exit for a block of length one b_self self transition b_on onwards transition %% AlnBlock * Align_Sequences_ProteinBlockAligner(Sequence * one,Sequence * two,CompMat * comp,int bentry,int bexit,int b1exit,int b_self,int b_on,DPEnvelope * dpenv,DPRunImpl * dpri) { ComplexSequence * cone=NULL; ComplexSequence * ctwo=NULL; AlnBlock * alb= NULL; PackAln * pal=NULL; ComplexSequenceEvalSet * evalfunc = NULL; if( one == NULL || two == NULL || comp == NULL ) { warn("Passed in NULL objects into Align_Sequences_ProteinSmithWaterman!"); return NULL; } if( one->type != SEQUENCE_PROTEIN ) { warn("Sequence %s is not typed as protein... ignoring!\n",one->name); } if( two->type != SEQUENCE_PROTEIN ) { warn("Sequence %s is not typed as protein... ignoring!\n",two->name); } evalfunc = default_aminoacid_ComplexSequenceEvalSet(); cone = new_ComplexSequence(one,evalfunc); if( cone == NULL ) goto cleanup; ctwo = new_ComplexSequence(two,evalfunc); if( ctwo == NULL ) goto cleanup; pal = PackAln_bestmemory_ProteinBlockAligner(cone,ctwo,comp,bentry,b1exit,b_on,b_self,bexit,dpenv,dpri); if( pal == NULL ) goto cleanup; alb = convert_PackAln_to_AlnBlock_ProteinSW(pal); goto cleanup; cleanup : if( cone != NULL ) free_ComplexSequence(cone); if( ctwo != NULL ) free_ComplexSequence(ctwo); if( pal != NULL ) free_PackAln(pal); if( evalfunc != NULL ) free_ComplexSequenceEvalSet(evalfunc); return alb; } %func Align_Sequences_ProteinABC this function is analogous to Align_Sequences_ProteinSmithWaterman but using the abc model %arg one Sequence to align two Sequence to align comp Comparison Matrix a genearlized affine gap cost b genearlized affine gap cost c genearlized affine gap cost %% AlnBlock * Align_Sequences_ProteinABC(Sequence * one,Sequence * two,CompMat * comp,int a, int b, int c,DPEnvelope * dpenv,DPRunImpl * dpri) { ComplexSequence * cone=NULL; ComplexSequence * ctwo=NULL; AlnBlock * alb= NULL; PackAln * pal=NULL; ComplexSequenceEvalSet * evalfunc = NULL; if( one == NULL || two == NULL || comp == NULL ) { warn("Passed in NULL objects into Align_Sequences_ProteinSmithWaterman!"); return NULL; } if( one->type != SEQUENCE_PROTEIN ) { warn("Sequence %s is not typed as protein... ignoring!\n",one->name); } if( two->type != SEQUENCE_PROTEIN ) { warn("Sequence %s is not typed as protein... ignoring!\n",two->name); } evalfunc = default_aminoacid_ComplexSequenceEvalSet(); cone = new_ComplexSequence(one,evalfunc); if( cone == NULL ) goto cleanup; ctwo = new_ComplexSequence(two,evalfunc); if( ctwo == NULL ) goto cleanup; pal = PackAln_bestmemory_abc(cone,ctwo,comp,a,b,c,NULL,dpri); if( pal == NULL ) goto cleanup; alb = convert_PackAln_to_AlnBlock_abc(pal); goto cleanup; cleanup : if( cone != NULL ) free_ComplexSequence(cone); if( ctwo != NULL ) free_ComplexSequence(ctwo); if( pal != NULL ) free_PackAln(pal); if( evalfunc != NULL ) free_ComplexSequenceEvalSet(evalfunc); return alb; } %func Analogous to Align_Proteins_SmithWaterman for ABC model %arg one protein to align two protein to align comp comparison matrix a generalized affine gap cost a b generalized affine gap cost b c generalized affine gap cost c %% AlnBlock * Align_Proteins_ABC(Protein * one,Protein * two,CompMat * comp,int a,int b,int c,DPEnvelope * dpenv,DPRunImpl * dpri) { if( one == NULL || two == NULL || comp == NULL ) { warn("Passed in NULL objects into Align_Proteins_ABC!"); return NULL; } return Align_Sequences_ProteinABC(one->baseseq,two->baseseq,comp,a,b,c,dpenv,dpri); } %func This is the most correct way of aligning two Proteins, using Protein objects, which can be assummed to be proteins with no objections To display the alignment use write_pretty_Protein_align %arg one Protein to align two Protein to align comp Comparison Matrix gap gap penalty ext extension penalty %% AlnBlock * Align_Proteins_SmithWaterman(Protein * one,Protein * two,CompMat * comp,int gap,int ext,DPEnvelope * dpenv,DPRunImpl * dpri) { if( one == NULL || two == NULL || comp == NULL ) { warn("Passed in NULL objects into Align_Proteins_SmithWaterman!"); return NULL; } return Align_Sequences_ProteinSmithWaterman(one->baseseq,two->baseseq,comp,gap,ext,dpenv,dpri); } %func Runs a database psw search %arg querydb query database targetdb target database comp comparison matrix gap gap penalty ext extension penalty bits_cutoff report_level die_on_error dbsi %% Hscore * Hscore_from_ProteinSW(ProteinDB* querydb,ProteinDB* targetdb,CompMat* comp,int gap,int ext,double bits_cutoff,int report_level,boolean die_on_error,DBSearchImpl* dbsi) { Hscore * out = NULL; Search_Return_Type ret; ret = SEARCH_ERROR; out = std_score_Hscore(bits_cutoff,report_level); if( dbsi == NULL ) { warn("Passed a NULL dbsi search implementaion object. Exiting without searching"); goto exit; } if( querydb == NULL ) { warn("Passed a NULL querydb. Exiting without searching"); goto exit; } if( targetdb == NULL ) { warn("Passed a NULL targetdb. Exiting without searching"); goto exit; } if( comp == NULL ) { warn("Passed a NULL comparison matrix. Exiting without searching"); goto exit; } ret = search_ProteinSW(dbsi,out,querydb,targetdb,comp,gap,ext); exit: return out; } %func Runs a database abc search %arg querydb query database targetdb target database comp comparison matrix a generalized affine gap cost a b generalized affine gap cost b c generalized affine gap cost c bits_cutoff report_level die_on_error dbsi %% Hscore * Hscore_from_ProteinABC(ProteinDB* querydb,ProteinDB* targetdb,CompMat* comp,int a,int b,int c,double bits_cutoff,int report_level,boolean die_on_error,DBSearchImpl* dbsi) { Hscore * out = NULL; Search_Return_Type ret; ret = SEARCH_ERROR; out = std_score_Hscore(bits_cutoff,report_level); if( dbsi == NULL ) { warn("Passed a NULL dbsi search implementaion object. Exiting without searching"); goto exit; } if( querydb == NULL ) { warn("Passed a NULL querydb. Exiting without searching"); goto exit; } if( targetdb == NULL ) { warn("Passed a NULL targetdb. Exiting without searching"); goto exit; } if( comp == NULL ) { warn("Passed a NULL comparison matrix. Exiting without searching"); goto exit; } ret = search_abc(dbsi,out,querydb,targetdb,comp,a,b,c); exit: return out; } %func Runs a database pba search %arg querydb query database targetdb target database comp comparison matrix bentry bexit bfor_trans b_self_trans b3exit bits_cutoff report_level dbsi %% Hscore * Hscore_from_ProteinBA(ProteinDB* querydb,ProteinDB* targetdb,CompMat* comp,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit,double bits_cutoff,int report_level,DBSearchImpl* dbsi) { Hscore * out = NULL; Search_Return_Type ret; ret = SEARCH_ERROR; out = std_score_Hscore(bits_cutoff,report_level); if( dbsi == NULL ) { warn("Passed a NULL dbsi search implementaion object. Exiting without searching"); goto exit; } if( querydb == NULL ) { warn("Passed a NULL querydb. Exiting without searching"); goto exit; } if( targetdb == NULL ) { warn("Passed a NULL targetdb. Exiting without searching"); goto exit; } if( comp == NULL ) { warn("Passed a NULL comparison matrix. Exiting without searching"); goto exit; } ret = search_ProteinBlockAligner(dbsi,out,querydb,targetdb,comp,bentry,bexit,bfor_trans,b_self_trans,b3exit); exit: return out; } %} wise-2.4.1/src/models/sw_wrap.xs0000644000175000001440000000564410670453715016202 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2 Wise2_AlnBlock * Align_strings_ProteinSmithWaterman(one,two,comp,gap,ext,dpenv,dpri) char * one char * two Wise2_CompMat * comp int gap int ext Wise2_DPEnvelope * dpenv Wise2_DPRunImpl * dpri CODE: RETVAL = Wise2_Align_strings_ProteinSmithWaterman(one,two,comp,gap,ext,dpenv,dpri); OUTPUT: RETVAL Wise2_AlnBlock * Align_Sequences_ProteinSmithWaterman(one,two,comp,gap,ext,dpenv,dpri) Wise2_Sequence * one Wise2_Sequence * two Wise2_CompMat * comp int gap int ext Wise2_DPEnvelope * dpenv Wise2_DPRunImpl * dpri CODE: RETVAL = Wise2_Align_Sequences_ProteinSmithWaterman(one,two,comp,gap,ext,dpenv,dpri); OUTPUT: RETVAL Wise2_AlnBlock * Align_Proteins_SmithWaterman(one,two,comp,gap,ext,dpenv,dpri) Wise2_Protein * one Wise2_Protein * two Wise2_CompMat * comp int gap int ext Wise2_DPEnvelope * dpenv Wise2_DPRunImpl * dpri CODE: RETVAL = Wise2_Align_Proteins_SmithWaterman(one,two,comp,gap,ext,dpenv,dpri); OUTPUT: RETVAL Wise2_AlnBlock * Align_Proteins_ABC(one,two,comp,a,b,c,dpenv,dpri) Wise2_Protein * one Wise2_Protein * two Wise2_CompMat * comp int a int b int c Wise2_DPEnvelope * dpenv Wise2_DPRunImpl * dpri CODE: RETVAL = Wise2_Align_Proteins_ABC(one,two,comp,a,b,c,dpenv,dpri); OUTPUT: RETVAL Wise2_AlnBlock * Align_Sequences_ProteinABC(one,two,comp,a,b,c,dpenv,dpri) Wise2_Sequence * one Wise2_Sequence * two Wise2_CompMat * comp int a int b int c Wise2_DPEnvelope * dpenv Wise2_DPRunImpl * dpri CODE: RETVAL = Wise2_Align_Sequences_ProteinABC(one,two,comp,a,b,c,dpenv,dpri); OUTPUT: RETVAL Wise2_Hscore * Hscore_from_ProteinSW(querydb,targetdb,comp,gap,ext,bits_cutoff,report_level,die_on_error,dbsi) Wise2_ProteinDB* querydb Wise2_ProteinDB* targetdb Wise2_CompMat* comp int gap int ext double bits_cutoff int report_level boolean die_on_error Wise2_DBSearchImpl* dbsi CODE: RETVAL = Wise2_Hscore_from_ProteinSW(querydb,targetdb,comp,gap,ext,bits_cutoff,report_level,die_on_error,dbsi); OUTPUT: RETVAL Wise2_Hscore * Hscore_from_ProteinABC(querydb,targetdb,comp,a,b,c,bits_cutoff,report_level,die_on_error,dbsi) Wise2_ProteinDB* querydb Wise2_ProteinDB* targetdb Wise2_CompMat* comp int a int b int c double bits_cutoff int report_level boolean die_on_error Wise2_DBSearchImpl* dbsi CODE: RETVAL = Wise2_Hscore_from_ProteinABC(querydb,targetdb,comp,a,b,c,bits_cutoff,report_level,die_on_error,dbsi); OUTPUT: RETVAL Wise2_Hscore * Hscore_from_ProteinBA(querydb,targetdb,comp,bentry,bexit,bfor_trans,b_self_trans,b3exit,bits_cutoff,report_level,dbsi) Wise2_ProteinDB* querydb Wise2_ProteinDB* targetdb Wise2_CompMat* comp Score bentry Score bexit Score bfor_trans Score b_self_trans Score b3exit double bits_cutoff int report_level Wise2_DBSearchImpl* dbsi CODE: RETVAL = Wise2_Hscore_from_ProteinBA(querydb,targetdb,comp,bentry,bexit,bfor_trans,b_self_trans,b3exit,bits_cutoff,report_level,dbsi); OUTPUT: RETVAL wise-2.4.1/src/models/dnaprofile.c0000644000175000001440000006472110670453713016432 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dnaprofile.h" # line 46 "dnaprofile.dy" TransFactor * new_TransFactor_from_DnaProfile(DnaProfile * dp,char * name) { TransFactor * out; assert(dp != NULL); out = TransFactor_alloc(); out->name = stringalloc(name); out->seed = hard_link_SeqAlign(dp->sa); return out; } # line 58 "dnaprofile.dy" double bits_entropy_DnaProfile(DnaProfile * dnap,RandomModelDNA * background) { double entropy = 0.0; double prob = 0; int i; int j; for(i=0;ilen;i++) { for(j=0;j<4;j++) { prob = dnap->col[i]->emit[j] * background->base[j]; entropy += prob * (-(log(prob)/log(2.0))); } } return entropy; } # line 76 "dnaprofile.dy" SeqAlign * merged_SeqAlign(DnaProfile * one,DnaProfile * two,AlnBlock * alb) { SeqAlign * out; Sequence * temp; int i; int j; int len = 0; AlnColumn * alc; char * temp_seq; out = SeqAlign_alloc_std(); for(alc=alb->start,len = 0;alc != NULL;alc = alc->next ) { len++; } temp_seq = calloc(len+1,sizeof(char)); /* loop along the top sequence */ for(i=0;isa->len;i++) { j = 0; for(alc=alb->start;alc!=NULL;alc=alc->next) { if( strcmp(alc->alu[1]->text_label,"END") == 0 ) { break; } if( strcmp(alc->alu[0]->text_label,"MATCH") == 0 || strcmp(alc->alu[0]->text_label,"INSERT") == 0 ) { temp_seq[j++] = one->sa->seq[i]->seq[alc->alu[0]->end]; } else if( strcmp(alc->alu[0]->text_label,"SEQ_UNMATCHED") == 0) { temp_seq[j++] = tolower(one->sa->seq[i]->seq[alc->alu[0]->end]); } else { temp_seq[j++] = '-'; } } temp_seq[j] = '\0'; temp = Sequence_from_static_memory(one->sa->seq[i]->name,temp_seq); add_SeqAlign(out,temp); } for(i=0;isa->len;i++) { j = 0; for(alc=alb->start;alc!=NULL;alc=alc->next) { if( strcmp(alc->alu[1]->text_label,"END") == 0 ) { break; } if( strcmp(alc->alu[1]->text_label,"MATCH") == 0 || strcmp(alc->alu[1]->text_label,"INSERT") == 0 ) { temp_seq[j++] = two->sa->seq[i]->seq[alc->alu[1]->end]; } else if( strcmp(alc->alu[1]->text_label,"SEQ_UNMATCHED") == 0) { temp_seq[j++] = tolower(two->sa->seq[i]->seq[alc->alu[1]->end]); } else { temp_seq[j++] = '-'; } } temp_seq[j] = '\0'; temp = Sequence_from_static_memory(two->sa->seq[i]->name,temp_seq); add_SeqAlign(out,temp); } return out; } # line 138 "dnaprofile.dy" DnaProfileScore * DnaProfileScore_from_DnaProfile(DnaProfile * dp) { int i,k; DnaProfileColScore * col; DnaProfileScore * out; out = DnaProfileScore_alloc_len(dp->len); for(i=0;ilen;i++) { col = DnaProfileColScore_alloc(); Probability2Score_move(dp->col[i]->emit,col->emit,4); Probability2Score_move(dp->col[i]->trans,col->trans,DnaProfile_TRANS_LENGTH); add_DnaProfileScore(out,col); } return out; } # line 159 "dnaprofile.dy" void fold_RandomModel_DnaProfile(DnaProfile * dp,RandomModelDNA * rm) { int i,k; for(i=0;ilen;i++) { for(k=0;k<4;k++) { dp->col[i]->emit[k] /= rm->base[k]; } } dp->folded_random = TRUE; } # line 171 "dnaprofile.dy" DnaProfile * naive_DnaProfile_from_Sequence(Sequence * seq,double id,double m2i,double m2d,double i2i,double d2d) { DnaProfile * out; DnaProfileCol * col; int i,k; SeqAlign * sa; sa = SeqAlign_alloc_len(1); add_SeqAlign(sa,hard_link_Sequence(seq)); out= DnaProfile_alloc_len(seq->len); out->sa = sa; for(i=0;ilen;i++) { col = DnaProfileCol_alloc(); for(k=0;k<4;k++) { col->emit[k]= (1.0-id)/3.0; } if( base_from_char(seq->seq[i]) != BASE_N ) { col->emit[base_from_char(seq->seq[i])] = id; } col->trans[DnaProfile_M2I] = m2i; col->trans[DnaProfile_M2D] = m2d; col->trans[DnaProfile_I2I] = i2i; col->trans[DnaProfile_D2D] = d2d; col->trans[DnaProfile_M2M] = (1.0 - m2i - m2d); col->trans[DnaProfile_D2M] = (1.0 - d2d); col->trans[DnaProfile_I2M] = (1.0 - i2i); add_DnaProfile(out,col); } return out; } # line 213 "dnaprofile.dy" DnaProfile * naive_DnaProfile_from_SeqAlign(SeqAlign * sa,double simple_pseudo,double m2i,double m2d,double i2i,double d2d) { int i; int j; int k; DnaProfile * out; DnaProfileCol * col; int base_n; double count[4]; double total; assert(sa != NULL); assert(sa->len > 1); assert(sa->seq[0]->len > 1); out = DnaProfile_alloc_len(sa->seq[0]->len); out->sa = hard_link_SeqAlign(sa); total = (4*simple_pseudo)+sa->len; for(i=0;iseq[0]->len;i++) { for(k=0;k<4;k++) { count[k] = simple_pseudo; } for(j=0;jlen;j++) { assert(sa->seq[j]->len > i); base_n = base_from_char(sa->seq[j]->seq[i]); if( base_n < 4 ) { count[base_n]++; } else { for(k=0;k<4;k++) { count[base_n] += 0.25; } } } col = DnaProfileCol_alloc(); col->seqalign_col = i; for(k=0;k<4;k++) { col->emit[k] = count[k] / total; } col->trans[DnaProfile_M2I] = m2i; col->trans[DnaProfile_M2D] = m2d; col->trans[DnaProfile_I2I] = i2i; col->trans[DnaProfile_D2D] = d2d; col->trans[DnaProfile_M2M] = (1.0 - m2i - m2d); col->trans[DnaProfile_D2M] = (1.0 - d2d); col->trans[DnaProfile_I2M] = (1.0 - i2i); add_DnaProfile(out,col); } return out; } # line 277 "dnaprofile.dy" void show_DnaProfile(DnaProfile * dnap,RandomModelDNA * rm,FILE * ofp) { int i; int k; double max; double max_base; double ent; ent = bits_entropy_DnaProfile(dnap,rm); fprintf(ofp,"Entropy %.4f (%.4f per column)\n",ent,ent/dnap->len); for(i=0;ilen;i++) { max = dnap->col[i]->emit[0]; max_base =0; for(k=1;k<4;k++) { if( dnap->col[i]->emit[k] > max ) { max = dnap->col[i]->emit[k]; max_base =k; } } fprintf(ofp,"%5d %c ",i,char_from_base(max_base)); for(k=0;k<4;k++) { fprintf(ofp," %c:%.3f ",char_from_base(k),dnap->col[i]->emit[k]); } fprintf(ofp,"\n"); } write_selex_SeqAlign(dnap->sa,15,50,ofp); fprintf(ofp,"//\n"); } # line 283 "dnaprofile.c" /* Function: hard_link_DnaProfileCol(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileCol *] * * Return [UNKN ] Undocumented return value [DnaProfileCol *] * */ DnaProfileCol * hard_link_DnaProfileCol(DnaProfileCol * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaProfileCol object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaProfileCol_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileCol *] * */ DnaProfileCol * DnaProfileCol_alloc(void) { DnaProfileCol * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaProfileCol *) ckalloc (sizeof(DnaProfileCol))) == NULL) { warn("DnaProfileCol_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* emit[5] is an array: no default possible */ /* trans[DnaProfile_TRANS_LENGTH] is an array: no default possible */ out->seqalign_col = 0; return out; } /* Function: free_DnaProfileCol(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileCol *] * * Return [UNKN ] Undocumented return value [DnaProfileCol *] * */ DnaProfileCol * free_DnaProfileCol(DnaProfileCol * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaProfileCol obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_DnaProfileColScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileColScore *] * * Return [UNKN ] Undocumented return value [DnaProfileColScore *] * */ DnaProfileColScore * hard_link_DnaProfileColScore(DnaProfileColScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaProfileColScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaProfileColScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileColScore *] * */ DnaProfileColScore * DnaProfileColScore_alloc(void) { DnaProfileColScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaProfileColScore *) ckalloc (sizeof(DnaProfileColScore))) == NULL) { warn("DnaProfileColScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* emit[5] is an array: no default possible */ /* trans[DnaProfile_TRANS_LENGTH] is an array: no default possible */ return out; } /* Function: free_DnaProfileColScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileColScore *] * * Return [UNKN ] Undocumented return value [DnaProfileColScore *] * */ DnaProfileColScore * free_DnaProfileColScore(DnaProfileColScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaProfileColScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_DnaProfileScore(list,i,j) * * Descrip: swap function: an internal for qsort_DnaProfileScore * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [DnaProfileColScore **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_DnaProfileScore(DnaProfileColScore ** list,int i,int j) { DnaProfileColScore * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_DnaProfileScore(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_DnaProfileScore which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [DnaProfileColScore **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_DnaProfileScore(DnaProfileColScore ** list,int left,int right,int (*comp)(DnaProfileColScore * ,DnaProfileColScore * )) { int i,last; if( left >= right ) return; swap_DnaProfileScore(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_DnaProfileScore (list,++last,i); } swap_DnaProfileScore (list,left,last); qsort_DnaProfileScore(list,left,last-1,comp); qsort_DnaProfileScore(list,last+1,right,comp); } /* Function: sort_DnaProfileScore(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_DnaProfileScore * * * Arg: obj [UNKN ] Object containing list [DnaProfileScore *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_DnaProfileScore(DnaProfileScore * obj,int (*comp)(DnaProfileColScore *, DnaProfileColScore *)) { qsort_DnaProfileScore(obj->col,0,obj->len-1,comp); return; } /* Function: expand_DnaProfileScore(obj,len) * * Descrip: Really an internal function for add_DnaProfileScore * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileScore *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_DnaProfileScore(DnaProfileScore * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_DnaProfileScore called with no need"); return TRUE; } if( (obj->col = (DnaProfileColScore ** ) ckrealloc (obj->col,sizeof(DnaProfileColScore *)*len)) == NULL) { warn("ckrealloc failed for expand_DnaProfileScore, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_DnaProfileScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileScore *] * Arg: add [OWNER] Object to add to the list [DnaProfileColScore *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_DnaProfileScore(DnaProfileScore * obj,DnaProfileColScore * add) { if( obj->len >= obj->maxlen) { if( expand_DnaProfileScore(obj,obj->len + DnaProfileScoreLISTLENGTH) == FALSE) return FALSE; } obj->col[obj->len++]=add; return TRUE; } /* Function: flush_DnaProfileScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileScore *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_DnaProfileScore(DnaProfileScore * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->col[i] != NULL) { free_DnaProfileColScore(obj->col[i]); obj->col[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: DnaProfileScore_alloc_std(void) * * Descrip: Equivalent to DnaProfileScore_alloc_len(DnaProfileScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DnaProfileScore *] * */ DnaProfileScore * DnaProfileScore_alloc_std(void) { return DnaProfileScore_alloc_len(DnaProfileScoreLISTLENGTH); } /* Function: DnaProfileScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DnaProfileScore *] * */ DnaProfileScore * DnaProfileScore_alloc_len(int len) { DnaProfileScore * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = DnaProfileScore_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->col = (DnaProfileColScore ** ) ckcalloc (len,sizeof(DnaProfileColScore *))) == NULL) { warn("Warning, ckcalloc failed in DnaProfileScore_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_DnaProfileScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileScore *] * * Return [UNKN ] Undocumented return value [DnaProfileScore *] * */ DnaProfileScore * hard_link_DnaProfileScore(DnaProfileScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaProfileScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaProfileScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileScore *] * */ DnaProfileScore * DnaProfileScore_alloc(void) { DnaProfileScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaProfileScore *) ckalloc (sizeof(DnaProfileScore))) == NULL) { warn("DnaProfileScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->col = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_DnaProfileScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileScore *] * * Return [UNKN ] Undocumented return value [DnaProfileScore *] * */ DnaProfileScore * free_DnaProfileScore(DnaProfileScore * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaProfileScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->col != NULL) { for(i=0;ilen;i++) { if( obj->col[i] != NULL) free_DnaProfileColScore(obj->col[i]); } ckfree(obj->col); } ckfree(obj); return NULL; } /* Function: swap_DnaProfile(list,i,j) * * Descrip: swap function: an internal for qsort_DnaProfile * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [DnaProfileCol **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_DnaProfile(DnaProfileCol ** list,int i,int j) { DnaProfileCol * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_DnaProfile(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_DnaProfile which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [DnaProfileCol **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_DnaProfile(DnaProfileCol ** list,int left,int right,int (*comp)(DnaProfileCol * ,DnaProfileCol * )) { int i,last; if( left >= right ) return; swap_DnaProfile(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_DnaProfile (list,++last,i); } swap_DnaProfile (list,left,last); qsort_DnaProfile(list,left,last-1,comp); qsort_DnaProfile(list,last+1,right,comp); } /* Function: sort_DnaProfile(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_DnaProfile * * * Arg: obj [UNKN ] Object containing list [DnaProfile *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_DnaProfile(DnaProfile * obj,int (*comp)(DnaProfileCol *, DnaProfileCol *)) { qsort_DnaProfile(obj->col,0,obj->len-1,comp); return; } /* Function: expand_DnaProfile(obj,len) * * Descrip: Really an internal function for add_DnaProfile * * * Arg: obj [UNKN ] Object which contains the list [DnaProfile *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_DnaProfile(DnaProfile * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_DnaProfile called with no need"); return TRUE; } if( (obj->col = (DnaProfileCol ** ) ckrealloc (obj->col,sizeof(DnaProfileCol *)*len)) == NULL) { warn("ckrealloc failed for expand_DnaProfile, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_DnaProfile(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DnaProfile *] * Arg: add [OWNER] Object to add to the list [DnaProfileCol *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_DnaProfile(DnaProfile * obj,DnaProfileCol * add) { if( obj->len >= obj->maxlen) { if( expand_DnaProfile(obj,obj->len + DnaProfileLISTLENGTH) == FALSE) return FALSE; } obj->col[obj->len++]=add; return TRUE; } /* Function: flush_DnaProfile(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DnaProfile *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_DnaProfile(DnaProfile * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->col[i] != NULL) { free_DnaProfileCol(obj->col[i]); obj->col[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: DnaProfile_alloc_std(void) * * Descrip: Equivalent to DnaProfile_alloc_len(DnaProfileLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DnaProfile *] * */ DnaProfile * DnaProfile_alloc_std(void) { return DnaProfile_alloc_len(DnaProfileLISTLENGTH); } /* Function: DnaProfile_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DnaProfile *] * */ DnaProfile * DnaProfile_alloc_len(int len) { DnaProfile * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = DnaProfile_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->col = (DnaProfileCol ** ) ckcalloc (len,sizeof(DnaProfileCol *))) == NULL) { warn("Warning, ckcalloc failed in DnaProfile_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_DnaProfile(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfile *] * * Return [UNKN ] Undocumented return value [DnaProfile *] * */ DnaProfile * hard_link_DnaProfile(DnaProfile * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaProfile object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaProfile_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfile *] * */ DnaProfile * DnaProfile_alloc(void) { DnaProfile * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaProfile *) ckalloc (sizeof(DnaProfile))) == NULL) { warn("DnaProfile_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->col = NULL; out->len = out->maxlen = 0; out->sa = NULL; out->folded_random = FALSE; return out; } /* Function: free_DnaProfile(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfile *] * * Return [UNKN ] Undocumented return value [DnaProfile *] * */ DnaProfile * free_DnaProfile(DnaProfile * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaProfile obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->col != NULL) { for(i=0;ilen;i++) { if( obj->col[i] != NULL) free_DnaProfileCol(obj->col[i]); } ckfree(obj->col); } if( obj->sa != NULL) free_SeqAlign(obj->sa); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/dnaprofile.h0000644000175000001440000003206010670453713016426 0ustar philippusers#ifndef DYNAMITEdnaprofileHEADERFILE #define DYNAMITEdnaprofileHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "transfactor.h" typedef enum DnaProfileTransition { DnaProfile_M2M = 0, DnaProfile_M2I, DnaProfile_I2I, DnaProfile_I2M, DnaProfile_M2D, DnaProfile_D2D, DnaProfile_D2M, DnaProfile_TRANS_LENGTH } DnaProfileTransition; #define DnaProfileScoreLISTLENGTH 128 #define DnaProfileLISTLENGTH 128 struct Wise2_DnaProfileCol { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability emit[5]; Probability trans[DnaProfile_TRANS_LENGTH]; int seqalign_col; } ; /* DnaProfileCol defined */ #ifndef DYNAMITE_DEFINED_DnaProfileCol typedef struct Wise2_DnaProfileCol Wise2_DnaProfileCol; #define DnaProfileCol Wise2_DnaProfileCol #define DYNAMITE_DEFINED_DnaProfileCol #endif struct Wise2_DnaProfileColScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score emit[5]; Score trans[DnaProfile_TRANS_LENGTH]; } ; /* DnaProfileColScore defined */ #ifndef DYNAMITE_DEFINED_DnaProfileColScore typedef struct Wise2_DnaProfileColScore Wise2_DnaProfileColScore; #define DnaProfileColScore Wise2_DnaProfileColScore #define DYNAMITE_DEFINED_DnaProfileColScore #endif struct Wise2_DnaProfileScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DnaProfileColScore ** col; int len;/* len for above col */ int maxlen; /* maxlen for above col */ } ; /* DnaProfileScore defined */ #ifndef DYNAMITE_DEFINED_DnaProfileScore typedef struct Wise2_DnaProfileScore Wise2_DnaProfileScore; #define DnaProfileScore Wise2_DnaProfileScore #define DYNAMITE_DEFINED_DnaProfileScore #endif struct Wise2_DnaProfile { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DnaProfileCol ** col; int len;/* len for above col */ int maxlen; /* maxlen for above col */ SeqAlign * sa; boolean folded_random; } ; /* DnaProfile defined */ #ifndef DYNAMITE_DEFINED_DnaProfile typedef struct Wise2_DnaProfile Wise2_DnaProfile; #define DnaProfile Wise2_DnaProfile #define DYNAMITE_DEFINED_DnaProfile #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_DnaProfileCol(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileCol *] * * Return [UNKN ] Undocumented return value [DnaProfileCol *] * */ DnaProfileCol * Wise2_hard_link_DnaProfileCol(DnaProfileCol * obj); #define hard_link_DnaProfileCol Wise2_hard_link_DnaProfileCol /* Function: DnaProfileCol_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileCol *] * */ DnaProfileCol * Wise2_DnaProfileCol_alloc(void); #define DnaProfileCol_alloc Wise2_DnaProfileCol_alloc /* Function: free_DnaProfileCol(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileCol *] * * Return [UNKN ] Undocumented return value [DnaProfileCol *] * */ DnaProfileCol * Wise2_free_DnaProfileCol(DnaProfileCol * obj); #define free_DnaProfileCol Wise2_free_DnaProfileCol /* Function: hard_link_DnaProfileColScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileColScore *] * * Return [UNKN ] Undocumented return value [DnaProfileColScore *] * */ DnaProfileColScore * Wise2_hard_link_DnaProfileColScore(DnaProfileColScore * obj); #define hard_link_DnaProfileColScore Wise2_hard_link_DnaProfileColScore /* Function: DnaProfileColScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileColScore *] * */ DnaProfileColScore * Wise2_DnaProfileColScore_alloc(void); #define DnaProfileColScore_alloc Wise2_DnaProfileColScore_alloc /* Function: free_DnaProfileColScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileColScore *] * * Return [UNKN ] Undocumented return value [DnaProfileColScore *] * */ DnaProfileColScore * Wise2_free_DnaProfileColScore(DnaProfileColScore * obj); #define free_DnaProfileColScore Wise2_free_DnaProfileColScore /* Function: add_DnaProfileScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileScore *] * Arg: add [OWNER] Object to add to the list [DnaProfileColScore *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_DnaProfileScore(DnaProfileScore * obj,DnaProfileColScore * add); #define add_DnaProfileScore Wise2_add_DnaProfileScore /* Function: flush_DnaProfileScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileScore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_DnaProfileScore(DnaProfileScore * obj); #define flush_DnaProfileScore Wise2_flush_DnaProfileScore /* Function: DnaProfileScore_alloc_std(void) * * Descrip: Equivalent to DnaProfileScore_alloc_len(DnaProfileScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DnaProfileScore *] * */ DnaProfileScore * Wise2_DnaProfileScore_alloc_std(void); #define DnaProfileScore_alloc_std Wise2_DnaProfileScore_alloc_std /* Function: DnaProfileScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DnaProfileScore *] * */ DnaProfileScore * Wise2_DnaProfileScore_alloc_len(int len); #define DnaProfileScore_alloc_len Wise2_DnaProfileScore_alloc_len /* Function: hard_link_DnaProfileScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileScore *] * * Return [UNKN ] Undocumented return value [DnaProfileScore *] * */ DnaProfileScore * Wise2_hard_link_DnaProfileScore(DnaProfileScore * obj); #define hard_link_DnaProfileScore Wise2_hard_link_DnaProfileScore /* Function: DnaProfileScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileScore *] * */ DnaProfileScore * Wise2_DnaProfileScore_alloc(void); #define DnaProfileScore_alloc Wise2_DnaProfileScore_alloc /* Function: free_DnaProfileScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileScore *] * * Return [UNKN ] Undocumented return value [DnaProfileScore *] * */ DnaProfileScore * Wise2_free_DnaProfileScore(DnaProfileScore * obj); #define free_DnaProfileScore Wise2_free_DnaProfileScore /* Function: add_DnaProfile(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DnaProfile *] * Arg: add [OWNER] Object to add to the list [DnaProfileCol *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_DnaProfile(DnaProfile * obj,DnaProfileCol * add); #define add_DnaProfile Wise2_add_DnaProfile /* Function: flush_DnaProfile(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DnaProfile *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_DnaProfile(DnaProfile * obj); #define flush_DnaProfile Wise2_flush_DnaProfile /* Function: DnaProfile_alloc_std(void) * * Descrip: Equivalent to DnaProfile_alloc_len(DnaProfileLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DnaProfile *] * */ DnaProfile * Wise2_DnaProfile_alloc_std(void); #define DnaProfile_alloc_std Wise2_DnaProfile_alloc_std /* Function: DnaProfile_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DnaProfile *] * */ DnaProfile * Wise2_DnaProfile_alloc_len(int len); #define DnaProfile_alloc_len Wise2_DnaProfile_alloc_len /* Function: hard_link_DnaProfile(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfile *] * * Return [UNKN ] Undocumented return value [DnaProfile *] * */ DnaProfile * Wise2_hard_link_DnaProfile(DnaProfile * obj); #define hard_link_DnaProfile Wise2_hard_link_DnaProfile /* Function: DnaProfile_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfile *] * */ DnaProfile * Wise2_DnaProfile_alloc(void); #define DnaProfile_alloc Wise2_DnaProfile_alloc /* Function: free_DnaProfile(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfile *] * * Return [UNKN ] Undocumented return value [DnaProfile *] * */ DnaProfile * Wise2_free_DnaProfile(DnaProfile * obj); #define free_DnaProfile Wise2_free_DnaProfile /* Unplaced functions */ /* There has been no indication of the use of these functions */ TransFactor * Wise2_new_TransFactor_from_DnaProfile(DnaProfile * dp,char * name); #define new_TransFactor_from_DnaProfile Wise2_new_TransFactor_from_DnaProfile double Wise2_bits_entropy_DnaProfile(DnaProfile * dnap,RandomModelDNA * background); #define bits_entropy_DnaProfile Wise2_bits_entropy_DnaProfile SeqAlign * Wise2_merged_SeqAlign(DnaProfile * one,DnaProfile * two,AlnBlock * alb); #define merged_SeqAlign Wise2_merged_SeqAlign DnaProfileScore * Wise2_DnaProfileScore_from_DnaProfile(DnaProfile * dp); #define DnaProfileScore_from_DnaProfile Wise2_DnaProfileScore_from_DnaProfile void Wise2_fold_RandomModel_DnaProfile(DnaProfile * dp,RandomModelDNA * rm); #define fold_RandomModel_DnaProfile Wise2_fold_RandomModel_DnaProfile DnaProfile * Wise2_naive_DnaProfile_from_Sequence(Sequence * seq,double id,double m2i,double m2d,double i2i,double d2d); #define naive_DnaProfile_from_Sequence Wise2_naive_DnaProfile_from_Sequence DnaProfile * Wise2_naive_DnaProfile_from_SeqAlign(SeqAlign * sa,double simple_pseudo,double m2i,double m2d,double i2i,double d2d); #define naive_DnaProfile_from_SeqAlign Wise2_naive_DnaProfile_from_SeqAlign void Wise2_show_DnaProfile(DnaProfile * dnap,RandomModelDNA * rm,FILE * ofp); #define show_DnaProfile Wise2_show_DnaProfile /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_DnaProfileScore(DnaProfileColScore ** list,int i,int j) ; #define swap_DnaProfileScore Wise2_swap_DnaProfileScore void Wise2_qsort_DnaProfileScore(DnaProfileColScore ** list,int left,int right,int (*comp)(DnaProfileColScore * ,DnaProfileColScore * )); #define qsort_DnaProfileScore Wise2_qsort_DnaProfileScore void Wise2_sort_DnaProfileScore(DnaProfileScore * obj,int (*comp)(DnaProfileColScore *, DnaProfileColScore *)); #define sort_DnaProfileScore Wise2_sort_DnaProfileScore boolean Wise2_expand_DnaProfileScore(DnaProfileScore * obj,int len); #define expand_DnaProfileScore Wise2_expand_DnaProfileScore void Wise2_swap_DnaProfile(DnaProfileCol ** list,int i,int j) ; #define swap_DnaProfile Wise2_swap_DnaProfile void Wise2_qsort_DnaProfile(DnaProfileCol ** list,int left,int right,int (*comp)(DnaProfileCol * ,DnaProfileCol * )); #define qsort_DnaProfile Wise2_qsort_DnaProfile void Wise2_sort_DnaProfile(DnaProfile * obj,int (*comp)(DnaProfileCol *, DnaProfileCol *)); #define sort_DnaProfile Wise2_sort_DnaProfile boolean Wise2_expand_DnaProfile(DnaProfile * obj,int len); #define expand_DnaProfile Wise2_expand_DnaProfile #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/editdist.c0000644000175000001440000000367007457233532016120 0ustar philippusers#include "editdistdp.h" #include "version.h" #include "standardout.h" #include "seqaligndisplay.h" char * program_name = "editdist"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s string1 string2\n",program_name); fprintf(ofp,"-pretty show pretty alignment\n"); show_help_StandardOutputOptions(ofp); show_help_DPRunImpl(ofp); show_standard_options(ofp); } int main (int argc,char ** argv) { EditString * q; EditString * t; PackAln * pal; AlnBlock * alb; int match = 1; int mismatch = -1; int gap = -1; boolean show_pretty = FALSE; DPRunImpl * dpri = NULL; StandardOutputOptions * std_opt = NULL; strip_out_boolean_def_argument(&argc,argv,"pretty",&show_pretty); dpri = new_DPRunImpl_from_argv(&argc,argv); std_opt = new_StandardOutputOptions_from_argv(&argc,argv); if( dpri == NULL ) { fatal("Unable to build DPRun implementation. Bad arguments"); } if( argc != 3 ) { show_help(stdout); exit(12); } q = new_EditString(argv[1]); t = new_EditString(argv[2]); pal = PackAln_bestmemory_EditDistance(q,t,match,mismatch,gap,NULL,dpri); alb = convert_PackAln_to_AlnBlock_EditDistance(pal); fprintf(stdout,"Score %d\n",pal->score); if( show_pretty == TRUE ) { write_pretty_str_align(alb,"string1",q->string,"string2",t->string,12,60,stdout); } show_StandardOutputOptions(std_opt,alb,pal,"//",stdout); return 0; } wise-2.4.1/src/models/estwrap.typemap0000644000175000001440000000000010670453713017205 0ustar philippuserswise-2.4.1/src/models/editdistdp.dy0000644000175000001440000000313507463470413016630 0ustar philippusers %{ #include "dyna.h" #define EDITMATCH(string1c,string2c,match,mismatch) (string1c == string2c ? match : mismatch) %} struct EditString char * string int len matrix EditDistance query name="q" type="EditString*" target name="t" type="EditString*" resource name="match" type="int" resource name="mismatch" type="int" resource name="gap" type="int" state MATCH source MATCH offi="1" offj="1" calc="EDITMATCH(q->string[i],t->string[j],match,mismatch)" query_label SEQUENCE target_label SEQUENCE endsource source MATCH offi="0" offj="1" calc="gap" query_label INSERT target_label SEQUENCE endsource source MATCH offi="1" offj="0" calc="gap" query_label SEQUENCE target_label INSERT endsource source START offi="1" offj="1" !top !left calc="EDITMATCH(q->string[i],t->string[j],match,mismatch)" query_label SEQUENCE target_label SEQUENCE endsource source START offi="0" offj="1" !top !left calc="gap" query_label INSERT target_label SEQUENCE endsource source START offi="1" offj="0" !top !left calc="gap" query_label SEQUENCE target_label INSERT endsource endstate state START !special !start endstate state END !special !end source MATCH offj="0" !bottom !right calc="0" endsource query_label END target_label END endstate endmatrix %{ #include "editdistdp.h" EditString * new_EditString(char * string) { EditString * out; out = EditString_alloc(); out->string = stringalloc(string); out->len = strlen(string); return out; } wise-2.4.1/src/models/seqerror.c0000644000175000001440000004337710670453715016157 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "seqerror.h" /* Function: genewise_SequenceErrorSet(als) * * Descrip: Makes a sequence error set from standard genewise labels * * * Arg: als [UNKN ] Undocumented argument [AlnSequence *] * * Return [UNKN ] Undocumented return value [SequenceErrorSet *] * */ # line 56 "seqerror.dy" SequenceErrorSet * genewise_SequenceErrorSet(AlnSequence * als ) { SequenceErrorSet * out; SequenceError * se; AlnUnit * alu; assert(als); out = SequenceErrorSet_alloc_std(); for(alu=als->start;alu;alu = alu->next ) { if( strcmp(alu->text_label,"SEQUENCE_INSERTION") == 0 ) { se = SequenceError_alloc(); add_SequenceErrorSet(out,se); se->start = alu->start+1; se->end = alu->end; se->type = SeqErrorInsertion; se->inserted_bases = stringalloc("?"); se->replaced_bases = stringalloc("NNN"); } else if ( strcmp(alu->text_label,"SEQUENCE_DELETION") == 0 ) { se = SequenceError_alloc(); se->start = alu->start+1; se->end = alu->end; se->type = SeqErrorDeletion; se->replaced_bases = stringalloc("NNN"); add_SequenceErrorSet(out,se); } } return out; } /* Function: show_SequenceErrorSet(ses,ofp) * * Descrip: Displays a set of sequence errors in space deliminted format * * * Arg: ses [UNKN ] Undocumented argument [SequenceErrorSet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 93 "seqerror.dy" void show_SequenceErrorSet(SequenceErrorSet * ses,FILE * ofp) { int i; for(i=0;ilen;i++) { show_SequenceError(ses->error[i],ofp); } } /* Function: show_SequenceError(se,ofp) * * Descrip: Displays sequence error in space deliminted format * * * Arg: se [UNKN ] Undocumented argument [SequenceError *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 107 "seqerror.dy" void show_SequenceError(SequenceError * se,FILE * ofp) { fprintf(ofp,"%c %5d %5d %10s (%10s)\n", (se->type == SeqErrorInsertion ? 'I' : (se->type == SeqErrorDeletion ? 'D' : 'S')), se->start,se->end, se->replaced_bases == NULL ? "-none-" : se->replaced_bases, se->type == SeqErrorInsertion ? se->inserted_bases : "-"); } /* Function: make_ErrorSequence(seq,subs,insertion,deletion) * * Descrip: Makes an error sequence (DNA) with set substitution * and insertion/deletion rates. * * * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: subs [UNKN ] Undocumented argument [Probability] * Arg: insertion [UNKN ] Undocumented argument [Probability] * Arg: deletion [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [ErrorSequence *] * */ # line 121 "seqerror.dy" ErrorSequence * make_ErrorSequence(Sequence * seq,Probability subs,Probability insertion,Probability deletion) { ErrorSequence * out; char * seq_buffer; int buf_len; int i,j; double rnd; char c[2]; SequenceError * se; i=j=0; out = ErrorSequence_alloc(); out->ses = SequenceErrorSet_alloc_std(); c[1] = '\0'; buf_len = seq->len *3; seq_buffer = (char*)calloc(buf_len,sizeof(char)); for(i=0;ilen;i++) { if( j >= buf_len ) { warn("run out of temporary buffer in error sequence"); break; } rnd = random_0_to_1(); if( rnd > deletion ) { /* yes this base is here */ rnd = random_0_to_1(); if( rnd < subs ) { rnd = random_0_to_1(); if( rnd < 0.25 ) { c[0] = 'A'; } else if ( rnd < 0.5 ) { c[0] = 'T'; } else if ( rnd < 0.75 ) { c[0] = 'G'; } else { c[0] = 'C'; } se = SequenceError_alloc(); se->type = SeqErrorSubstitution; se->start = j+1; se->end = j+1; se->replaced_bases = stringalloc(c); add_SequenceErrorSet(out->ses,se); seq_buffer[j++] = c[0]; } else { seq_buffer[j++] = seq->seq[i]; } } else { /* there has been a deletion */ se = SequenceError_alloc(); se->type = SeqErrorDeletion; se->start = j+1; se->end = j+1; c[0] = seq_buffer[i]; se->suspected_deletion = stringalloc(c); add_SequenceErrorSet(out->ses,se); } rnd = random_0_to_1(); if( rnd < insertion ) { rnd = random_0_to_1(); if( rnd < 0.25 ) { c[0] = 'A'; } else if ( rnd < 0.5 ) { c[0] = 'T'; } else if ( rnd < 0.75 ) { c[0] = 'G'; } else { c[0] = 'C'; } se = SequenceError_alloc(); se->type = SeqErrorInsertion; se->start = j+1; se->end = j+1; se->inserted_bases = stringalloc(c); add_SequenceErrorSet(out->ses,se); seq_buffer[j++] = c[0]; } } seq_buffer[j] = '\0'; out->seq = new_Sequence_from_strings(seq->name,seq_buffer); return out; } # line 202 "seqerror.c" /* Function: hard_link_SequenceError(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SequenceError *] * * Return [UNKN ] Undocumented return value [SequenceError *] * */ SequenceError * hard_link_SequenceError(SequenceError * obj) { if( obj == NULL ) { warn("Trying to hard link to a SequenceError object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SequenceError_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SequenceError *] * */ SequenceError * SequenceError_alloc(void) { SequenceError * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SequenceError *) ckalloc (sizeof(SequenceError))) == NULL) { warn("SequenceError_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = 0; out->start = 0; out->end = 0; out->replaced_bases = NULL; out->probability = 0.0; out->inserted_bases = NULL; out->suspected_deletion = NULL; return out; } /* Function: free_SequenceError(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SequenceError *] * * Return [UNKN ] Undocumented return value [SequenceError *] * */ SequenceError * free_SequenceError(SequenceError * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SequenceError obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->replaced_bases != NULL) ckfree(obj->replaced_bases); if( obj->inserted_bases != NULL) ckfree(obj->inserted_bases); if( obj->suspected_deletion != NULL) ckfree(obj->suspected_deletion); ckfree(obj); return NULL; } /* Function: swap_SequenceErrorSet(list,i,j) * * Descrip: swap function: an internal for qsort_SequenceErrorSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [SequenceError **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SequenceErrorSet(SequenceError ** list,int i,int j) { SequenceError * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SequenceErrorSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SequenceErrorSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [SequenceError **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SequenceErrorSet(SequenceError ** list,int left,int right,int (*comp)(SequenceError * ,SequenceError * )) { int i,last; if( left >= right ) return; swap_SequenceErrorSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SequenceErrorSet (list,++last,i); } swap_SequenceErrorSet (list,left,last); qsort_SequenceErrorSet(list,left,last-1,comp); qsort_SequenceErrorSet(list,last+1,right,comp); } /* Function: sort_SequenceErrorSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SequenceErrorSet * * * Arg: obj [UNKN ] Object containing list [SequenceErrorSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SequenceErrorSet(SequenceErrorSet * obj,int (*comp)(SequenceError *, SequenceError *)) { qsort_SequenceErrorSet(obj->error,0,obj->len-1,comp); return; } /* Function: expand_SequenceErrorSet(obj,len) * * Descrip: Really an internal function for add_SequenceErrorSet * * * Arg: obj [UNKN ] Object which contains the list [SequenceErrorSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SequenceErrorSet(SequenceErrorSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SequenceErrorSet called with no need"); return TRUE; } if( (obj->error = (SequenceError ** ) ckrealloc (obj->error,sizeof(SequenceError *)*len)) == NULL) { warn("ckrealloc failed for expand_SequenceErrorSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SequenceErrorSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SequenceErrorSet *] * Arg: add [OWNER] Object to add to the list [SequenceError *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SequenceErrorSet(SequenceErrorSet * obj,SequenceError * add) { if( obj->len >= obj->maxlen) { if( expand_SequenceErrorSet(obj,obj->len + SequenceErrorSetLISTLENGTH) == FALSE) return FALSE; } obj->error[obj->len++]=add; return TRUE; } /* Function: flush_SequenceErrorSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SequenceErrorSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SequenceErrorSet(SequenceErrorSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->error[i] != NULL) { free_SequenceError(obj->error[i]); obj->error[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SequenceErrorSet_alloc_std(void) * * Descrip: Equivalent to SequenceErrorSet_alloc_len(SequenceErrorSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SequenceErrorSet *] * */ SequenceErrorSet * SequenceErrorSet_alloc_std(void) { return SequenceErrorSet_alloc_len(SequenceErrorSetLISTLENGTH); } /* Function: SequenceErrorSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SequenceErrorSet *] * */ SequenceErrorSet * SequenceErrorSet_alloc_len(int len) { SequenceErrorSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SequenceErrorSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->error = (SequenceError ** ) ckcalloc (len,sizeof(SequenceError *))) == NULL) { warn("Warning, ckcalloc failed in SequenceErrorSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SequenceErrorSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SequenceErrorSet *] * * Return [UNKN ] Undocumented return value [SequenceErrorSet *] * */ SequenceErrorSet * hard_link_SequenceErrorSet(SequenceErrorSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a SequenceErrorSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SequenceErrorSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SequenceErrorSet *] * */ SequenceErrorSet * SequenceErrorSet_alloc(void) { SequenceErrorSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SequenceErrorSet *) ckalloc (sizeof(SequenceErrorSet))) == NULL) { warn("SequenceErrorSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->error = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_SequenceErrorSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SequenceErrorSet *] * * Return [UNKN ] Undocumented return value [SequenceErrorSet *] * */ SequenceErrorSet * free_SequenceErrorSet(SequenceErrorSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SequenceErrorSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->error != NULL) { for(i=0;ilen;i++) { if( obj->error[i] != NULL) free_SequenceError(obj->error[i]); } ckfree(obj->error); } ckfree(obj); return NULL; } /* Function: hard_link_ErrorSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ErrorSequence *] * * Return [UNKN ] Undocumented return value [ErrorSequence *] * */ ErrorSequence * hard_link_ErrorSequence(ErrorSequence * obj) { if( obj == NULL ) { warn("Trying to hard link to a ErrorSequence object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ErrorSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ErrorSequence *] * */ ErrorSequence * ErrorSequence_alloc(void) { ErrorSequence * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ErrorSequence *) ckalloc (sizeof(ErrorSequence))) == NULL) { warn("ErrorSequence_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->seq = NULL; out->ses = NULL; return out; } /* Function: free_ErrorSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ErrorSequence *] * * Return [UNKN ] Undocumented return value [ErrorSequence *] * */ ErrorSequence * free_ErrorSequence(ErrorSequence * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ErrorSequence obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->seq != NULL) free_Sequence(obj->seq); if( obj->ses != NULL) free_SequenceErrorSet(obj->ses); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/seqerror.h0000644000175000001440000002437510670453715016161 0ustar philippusers#ifndef DYNAMITEseqerrorHEADERFILE #define DYNAMITEseqerrorHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "probability.h" #include "aln.h" #include "sequence.h" enum SeqErrorType { SeqErrorInsertion, SeqErrorDeletion, SeqErrorSubstitution }; #define SequenceErrorSetLISTLENGTH 128 /* Object SequenceError * * Descrip: This holds information about * a particular insertion or * deletion for one sequence * * */ struct Wise2_SequenceError { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; int start; int end; char * replaced_bases; Probability probability; char * inserted_bases; char * suspected_deletion; } ; /* SequenceError defined */ #ifndef DYNAMITE_DEFINED_SequenceError typedef struct Wise2_SequenceError Wise2_SequenceError; #define SequenceError Wise2_SequenceError #define DYNAMITE_DEFINED_SequenceError #endif /* Object SequenceErrorSet * * Descrip: This holds a set of insertion * or deletions for a sequence * * */ struct Wise2_SequenceErrorSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SequenceError ** error; int len;/* len for above error */ int maxlen; /* maxlen for above error */ } ; /* SequenceErrorSet defined */ #ifndef DYNAMITE_DEFINED_SequenceErrorSet typedef struct Wise2_SequenceErrorSet Wise2_SequenceErrorSet; #define SequenceErrorSet Wise2_SequenceErrorSet #define DYNAMITE_DEFINED_SequenceErrorSet #endif /* Object ErrorSequence * * Descrip: This holds a sequence and what * errors have occured in it. * * */ struct Wise2_ErrorSequence { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence * seq; SequenceErrorSet * ses; } ; /* ErrorSequence defined */ #ifndef DYNAMITE_DEFINED_ErrorSequence typedef struct Wise2_ErrorSequence Wise2_ErrorSequence; #define ErrorSequence Wise2_ErrorSequence #define DYNAMITE_DEFINED_ErrorSequence #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: genewise_SequenceErrorSet(als) * * Descrip: Makes a sequence error set from standard genewise labels * * * Arg: als [UNKN ] Undocumented argument [AlnSequence *] * * Return [UNKN ] Undocumented return value [SequenceErrorSet *] * */ SequenceErrorSet * Wise2_genewise_SequenceErrorSet(AlnSequence * als ); #define genewise_SequenceErrorSet Wise2_genewise_SequenceErrorSet /* Function: show_SequenceErrorSet(ses,ofp) * * Descrip: Displays a set of sequence errors in space deliminted format * * * Arg: ses [UNKN ] Undocumented argument [SequenceErrorSet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_SequenceErrorSet(SequenceErrorSet * ses,FILE * ofp); #define show_SequenceErrorSet Wise2_show_SequenceErrorSet /* Function: show_SequenceError(se,ofp) * * Descrip: Displays sequence error in space deliminted format * * * Arg: se [UNKN ] Undocumented argument [SequenceError *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_SequenceError(SequenceError * se,FILE * ofp); #define show_SequenceError Wise2_show_SequenceError /* Function: make_ErrorSequence(seq,subs,insertion,deletion) * * Descrip: Makes an error sequence (DNA) with set substitution * and insertion/deletion rates. * * * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: subs [UNKN ] Undocumented argument [Probability] * Arg: insertion [UNKN ] Undocumented argument [Probability] * Arg: deletion [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [ErrorSequence *] * */ ErrorSequence * Wise2_make_ErrorSequence(Sequence * seq,Probability subs,Probability insertion,Probability deletion); #define make_ErrorSequence Wise2_make_ErrorSequence /* Function: hard_link_SequenceError(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SequenceError *] * * Return [UNKN ] Undocumented return value [SequenceError *] * */ SequenceError * Wise2_hard_link_SequenceError(SequenceError * obj); #define hard_link_SequenceError Wise2_hard_link_SequenceError /* Function: SequenceError_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SequenceError *] * */ SequenceError * Wise2_SequenceError_alloc(void); #define SequenceError_alloc Wise2_SequenceError_alloc /* Function: free_SequenceError(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SequenceError *] * * Return [UNKN ] Undocumented return value [SequenceError *] * */ SequenceError * Wise2_free_SequenceError(SequenceError * obj); #define free_SequenceError Wise2_free_SequenceError /* Function: add_SequenceErrorSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SequenceErrorSet *] * Arg: add [OWNER] Object to add to the list [SequenceError *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SequenceErrorSet(SequenceErrorSet * obj,SequenceError * add); #define add_SequenceErrorSet Wise2_add_SequenceErrorSet /* Function: flush_SequenceErrorSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SequenceErrorSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SequenceErrorSet(SequenceErrorSet * obj); #define flush_SequenceErrorSet Wise2_flush_SequenceErrorSet /* Function: SequenceErrorSet_alloc_std(void) * * Descrip: Equivalent to SequenceErrorSet_alloc_len(SequenceErrorSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SequenceErrorSet *] * */ SequenceErrorSet * Wise2_SequenceErrorSet_alloc_std(void); #define SequenceErrorSet_alloc_std Wise2_SequenceErrorSet_alloc_std /* Function: SequenceErrorSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SequenceErrorSet *] * */ SequenceErrorSet * Wise2_SequenceErrorSet_alloc_len(int len); #define SequenceErrorSet_alloc_len Wise2_SequenceErrorSet_alloc_len /* Function: hard_link_SequenceErrorSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SequenceErrorSet *] * * Return [UNKN ] Undocumented return value [SequenceErrorSet *] * */ SequenceErrorSet * Wise2_hard_link_SequenceErrorSet(SequenceErrorSet * obj); #define hard_link_SequenceErrorSet Wise2_hard_link_SequenceErrorSet /* Function: SequenceErrorSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SequenceErrorSet *] * */ SequenceErrorSet * Wise2_SequenceErrorSet_alloc(void); #define SequenceErrorSet_alloc Wise2_SequenceErrorSet_alloc /* Function: free_SequenceErrorSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SequenceErrorSet *] * * Return [UNKN ] Undocumented return value [SequenceErrorSet *] * */ SequenceErrorSet * Wise2_free_SequenceErrorSet(SequenceErrorSet * obj); #define free_SequenceErrorSet Wise2_free_SequenceErrorSet /* Function: hard_link_ErrorSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ErrorSequence *] * * Return [UNKN ] Undocumented return value [ErrorSequence *] * */ ErrorSequence * Wise2_hard_link_ErrorSequence(ErrorSequence * obj); #define hard_link_ErrorSequence Wise2_hard_link_ErrorSequence /* Function: ErrorSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ErrorSequence *] * */ ErrorSequence * Wise2_ErrorSequence_alloc(void); #define ErrorSequence_alloc Wise2_ErrorSequence_alloc /* Function: free_ErrorSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ErrorSequence *] * * Return [UNKN ] Undocumented return value [ErrorSequence *] * */ ErrorSequence * Wise2_free_ErrorSequence(ErrorSequence * obj); #define free_ErrorSequence Wise2_free_ErrorSequence /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_SequenceErrorSet(SequenceError ** list,int i,int j) ; #define swap_SequenceErrorSet Wise2_swap_SequenceErrorSet void Wise2_qsort_SequenceErrorSet(SequenceError ** list,int left,int right,int (*comp)(SequenceError * ,SequenceError * )); #define qsort_SequenceErrorSet Wise2_qsort_SequenceErrorSet void Wise2_sort_SequenceErrorSet(SequenceErrorSet * obj,int (*comp)(SequenceError *, SequenceError *)); #define sort_SequenceErrorSet Wise2_sort_SequenceErrorSet boolean Wise2_expand_SequenceErrorSet(SequenceErrorSet * obj,int len); #define expand_SequenceErrorSet Wise2_expand_SequenceErrorSet #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/cdnawise10.dy0000644000175000001440000001265407346742774016453 0ustar philippusers %{ #include "dyna.h" #include "geneparser4.h" %} matrix CdnaWise10 query type="CDNA" name="query" target type="GENOMIC" name="target" resource type="GeneParser4Score *" name="gp" resource type="CodonMatrixScore *" name="sc" resource type="RandomCodonScore *" name="rndcodon" resource name="utr" type="DNACOMPMAT" resource type="Score" name="gap_open" resource type="Score" name="gap_ext" resource type="Score" name="utr_gap" resource type="Score" name="intron_gap" extern name="GP4_*" type="int" state UTR5 offi="1" offj="1" source UTR5 calc="DNABASEMATCH(utr,CDNA_BASE(query,i),GENOMIC_BASE(target,j))" endsource source START calc="DNABASEMATCH(utr,CDNA_BASE(query,i),GENOMIC_BASE(target,j))" endsource source UTR5_INTRON calc="DNABASEMATCH(utr,CDNA_BASE(query,i),GENOMIC_BASE(target,j))" endsource source UTR5 offi="0" calc="utr_gap" query_label UTR5_GAP endsource source UTR5 offj="0" calc="utr_gap" target_label UTR5_GAP endsource query_label UTR5 target_label UTR5 endstate state UTR5_INTRON offj="1" source UTR5_INTRON calc="0" endsource source UTR5 calc="GENOMIC_5SS(target,j) + intron_gap" endsource query_label UTR5 target_label UTR5_INTRON endstate state MATCH offi="3" offj="3" source MATCH calc="sc->score[CDNA_CODON(query,i)][GENOMIC_CODON(target,j)]" endsource source INSERT calc="sc->score[CDNA_CODON(query,i)][GENOMIC_CODON(target,j)]" endsource source DELETE calc="sc->score[CDNA_CODON(query,i)][GENOMIC_CODON(target,j)]" endsource source START calc="sc->score[CDNA_CODON(query,i)][GENOMIC_CODON(target,j)]" endsource source UTR5 calc="sc->score[CDNA_CODON(query,i)][GENOMIC_CODON(target,j)]" endsource source INTRON_0 offi="0" offj="6" calc="GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source INTRON_1 offi="0" offj="5" calc="GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source INTRON_2 offi="0" offj="4" calc="GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource query_label MATCH_STATE target_label CODON endstate # # Insert state: does not move along model, produces DNA sequence... # state INSERT offi="0" offj="3" source MATCH calc="rndcodon->codon[GENOMIC_CODON(target,j)] + gap_open" endsource source INSERT calc="rndcodon->codon[GENOMIC_CODON(target,j)] + gap_ext" endsource # # phase 0,1,2 introns can calculate whole amino acid for 0. # source INTRON_0 offi="0" offj="6" calc="GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source INTRON_1 offi="0" offj="5" calc="GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source INTRON_2 offi="0" offj="4" calc="GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="rndcodon->codon[CDNA_CODON(query,i)] + gap_open" endsource source INSERT calc="rndcodon->codon[CDNA_CODON(query,i)] + gap_ext" endsource query_label DELETE_STATE target_label INSERT endstate # # Intron state: 3 separate phases, and merge INSERT/MATCH information # state INTRON_0 offi="0" offj="1" source MATCH offj="8" offi="3" calc="GENOMIC_5SS(target,j-7) + intron_gap" target_label 5SS_PHASE_0 endsource source INSERT offj="8" offi="0" calc="GENOMIC_5SS(target,j-7) + intron_gap" target_label 5SS_PHASE_0 endsource source INTRON_0 offj="1" calc="0" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state INTRON_1 offi="0" offj="1" source MATCH offj="9" offi="3" calc="GENOMIC_5SS(target,j-7) + intron_gap" target_label 5SS_PHASE_1 endsource source INSERT offj="9" offi="0" calc="GENOMIC_5SS(target,j-7) + intron_gap" target_label 5SS_PHASE_1 endsource source INTRON_1 offj="1" calc="0" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state INTRON_2 offi="0" offj="1" source MATCH offj="10" offi="3" calc="GENOMIC_5SS(target,j-7) + intron_gap" target_label 5SS_PHASE_2 endsource source INSERT offj="10" offi="0" calc="GENOMIC_5SS(target,j-7) + intron_gap" target_label 5SS_PHASE_2 endsource source INTRON_2 offj="1" calc="0" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state UTR3 offi="1" offj="1" source UTR3 calc="DNABASEMATCH(utr,CDNA_BASE(query,i),GENOMIC_BASE(target,j))" endsource source UTR3_INTRON calc="DNABASEMATCH(utr,CDNA_BASE(query,i),GENOMIC_BASE(target,j))" endsource source UTR3 offi="0" calc="utr_gap" query_label UTR3_GAP endsource source UTR3 offj="0" calc="utr_gap" target_label UTR3_GAP endsource query_label UTR3 target_label UTR3 endstate state UTR3_INTRON offj="1" source UTR3_INTRON calc="0" endsource source UTR3 calc="GENOMIC_5SS(target,j) + intron_gap" endsource query_label UTR3 target_label UTR3_INTRON endstate state START !start !special endstate state END !end !special source MATCH calc="0" endsource source UTR3 calc="0" endsource target_label END query_label END endstate # # collapse Intron labels! # collapse UTR5 UTR5 collapse UTR3 UTR3 collapse UTR5 UTR5_INTRON collapse UTR3 UTR3_INTRON collapse INTRON_STATE CENTRAL_INTRON endmatrix %{ #include "cdnawise10.h" %}wise-2.4.1/src/models/geneloop21.c0000644000175000001440000242405310670453714016263 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "geneloop21.h" # line 5 "geneloop21.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define CENTRAL_0M 3 #define PY_0M 4 #define SPACER_0M 5 #define CENTRAL_1M 6 #define PY_1M 7 #define SPACER_1M 8 #define CENTRAL_2M 9 #define PY_2M 10 #define SPACER_2M 11 #define CENTRAL_0I 12 #define PY_0I 13 #define SPACER_0I 14 #define CENTRAL_1I 15 #define PY_1I 16 #define SPACER_1I 17 #define CENTRAL_2I 18 #define PY_2I 19 #define SPACER_2I 20 #define START 0 #define END 1 #define GENOMIC_RND 2 #define RND_CODON 3 #define RND_CENTRAL 4 #define RND_PY_TRACT 5 #define RND_SPACER 6 #define GeneLoop21_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+10)*21)+STATE][i+1] #define GeneLoop21_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+10] #define GeneLoop21_READ_OFF_ERROR -12 #define GeneLoop21_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+11)%11][((i+1)*21)+STATE] #define GeneLoop21_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+11)%11][STATE] #define GeneLoop21_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define GeneLoop21_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_GeneLoop21(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_GeneLoop21(GeneLoop21 * mat) { GeneLoop21_access_func_holder holder; holder.access_main = GeneLoop21_shatter_access_main; holder.access_special = GeneLoop21_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_GeneLoop21(mat,holder); } /* Function: GeneLoop21_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneLoop21_shatter_access_main(GeneLoop21 * mat,int i,int j,int state) { return GeneLoop21_SHATTER_MATRIX(mat,i,j,state); } /* Function: GeneLoop21_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneLoop21_shatter_access_special(GeneLoop21 * mat,int i,int j,int state) { return GeneLoop21_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_GeneLoop21(mat,dpenv) * * Descrip: This function calculates the GeneLoop21 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneLoop21 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_GeneLoop21(GeneLoop21 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_6; int * SIG_1_5; int * SIG_1_4; int * SIG_1_2; int * SIG_1_1; int * SIG_0_3; int * SIG_1_0; int * SIG_0_8; int * SIG_0_1; int * SIG_0_9; int * SIG_0_10; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,21,lenj,7); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("GeneLoop21 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-6); SIG_1_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-5); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); SIG_0_8 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-8); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_0_9 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-9); SIG_0_10 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-10); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state RND_CODON to state MATCH */ temp = GeneLoop21_SHATTER_SPECIAL(mat,i-1,j-3,RND_CODON) + ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp21->transition[GP21_RND2MODEL]); if( temp > score ) { score = temp; } /* From state SPACER_0M to state MATCH */ temp = SIG_1_6[SPACER_0M] + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_0M to state MATCH */ temp = SIG_1_6[PY_0M] + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1M to state MATCH */ temp = SIG_1_5[SPACER_1M] + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_1M to state MATCH */ temp = SIG_1_5[PY_1M] + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2M to state MATCH */ temp = SIG_1_4[SPACER_2M] + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_2M to state MATCH */ temp = SIG_1_4[PY_2M] + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_1[MATCH] + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_4[MATCH] + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_5[MATCH] + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[MATCH] = score; /* state MATCH is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLoop21_SHATTER_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_SHATTER_SPECIAL(mat,i,j,RND_CODON) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0I to state INSERT */ temp = SIG_1_6[SPACER_0I] + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1I to state INSERT */ temp = SIG_1_5[SPACER_1I] + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2I to state INSERT */ temp = SIG_1_4[SPACER_2I] + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_0I to state INSERT */ temp = SIG_1_6[PY_0I] + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_1I to state INSERT */ temp = SIG_1_5[PY_1I] + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_2I to state INSERT */ temp = SIG_1_4[PY_2I] + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_1_2[INSERT] + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_1_1[INSERT] + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_1_4[INSERT] + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_1_5[INSERT] + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[INSERT] = score; /* state INSERT is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLoop21_SHATTER_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_SHATTER_SPECIAL(mat,i,j,RND_CODON) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLoop21_SHATTER_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_SHATTER_SPECIAL(mat,i,j,RND_CODON) = temp; } /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = SIG_0_8[MATCH] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0M */ temp = SIG_0_8[INSERT] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0M */ temp = SIG_0_8[DELETE] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = SIG_0_1[CENTRAL_0M] + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ SIG_0_0[CENTRAL_0M] = score; /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = SIG_0_1[CENTRAL_0M] + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0M to state PY_0M */ temp = SIG_0_1[PY_0M] + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[PY_0M] = score; /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = SIG_0_1[PY_0M] + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0M to state SPACER_0M */ temp = SIG_0_1[SPACER_0M] + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[SPACER_0M] = score; /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = SIG_0_9[MATCH] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_1M */ temp = SIG_0_9[INSERT] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1M */ temp = SIG_0_9[DELETE] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = SIG_0_1[CENTRAL_1M] + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ SIG_0_0[CENTRAL_1M] = score; /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = SIG_0_1[CENTRAL_1M] + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1M to state PY_1M */ temp = SIG_0_1[PY_1M] + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[PY_1M] = score; /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = SIG_0_1[PY_1M] + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1M to state SPACER_1M */ temp = SIG_0_1[SPACER_1M] + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[SPACER_1M] = score; /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = SIG_0_10[MATCH] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_2M */ temp = SIG_0_10[INSERT] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_2M */ temp = SIG_0_10[DELETE] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = SIG_0_1[CENTRAL_2M] + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ SIG_0_0[CENTRAL_2M] = score; /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = SIG_0_1[CENTRAL_2M] + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2M to state PY_2M */ temp = SIG_0_1[PY_2M] + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[PY_2M] = score; /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = SIG_0_1[PY_2M] + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2M to state SPACER_2M */ temp = SIG_0_1[SPACER_2M] + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[SPACER_2M] = score; /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = SIG_0_8[MATCH] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0I */ temp = SIG_0_8[INSERT] + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0I */ temp = SIG_0_8[DELETE] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = SIG_0_1[CENTRAL_0I] + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ SIG_0_0[CENTRAL_0I] = score; /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = SIG_0_1[CENTRAL_0I] + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0I to state PY_0I */ temp = SIG_0_1[PY_0I] + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[PY_0I] = score; /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = SIG_0_1[PY_0I] + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0I to state SPACER_0I */ temp = SIG_0_1[SPACER_0I] + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[SPACER_0I] = score; /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = SIG_0_9[MATCH] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_1I */ temp = SIG_0_9[INSERT] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1I */ temp = SIG_0_9[DELETE] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = SIG_0_1[CENTRAL_1I] + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ SIG_0_0[CENTRAL_1I] = score; /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = SIG_0_1[CENTRAL_1I] + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1I to state PY_1I */ temp = SIG_0_1[PY_1I] + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[PY_1I] = score; /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = SIG_0_1[PY_1I] + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1I to state SPACER_1I */ temp = SIG_0_1[SPACER_1I] + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[SPACER_1I] = score; /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = SIG_0_10[MATCH] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_2I */ temp = SIG_0_10[INSERT] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state INSERT to state CENTRAL_2I */ temp = SIG_0_10[INSERT] + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = SIG_0_1[CENTRAL_2I] + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ SIG_0_0[CENTRAL_2I] = score; /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = SIG_0_1[CENTRAL_2I] + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2I to state PY_2I */ temp = SIG_0_1[PY_2I] + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[PY_2I] = score; /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = SIG_0_1[PY_2I] + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2I to state SPACER_2I */ temp = SIG_0_1[SPACER_2I] + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; SIG_0_0[SPACER_2I] = score; /* Finished calculating state SPACER_2I */ } /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_SHATTER_SPECIAL(mat,0,j,END); /* Source GENOMIC_RND is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 1,GENOMIC_RND) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GeneLoop21_SHATTER_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state GENOMIC_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_SHATTER_SPECIAL(mat,0,j,GENOMIC_RND); /* Source START is a special source for GENOMIC_RND */ /* Has restricted position */ if( (j-1) == 0 ) { temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 1,START) + (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) + (0); if( temp > score ) score = temp; } /* Source GENOMIC_RND is a special source for GENOMIC_RND */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 1,GENOMIC_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for GENOMIC_RND */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 1,RND_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_SHATTER_SPECIAL(mat,0,j,GENOMIC_RND) = score; /* Finished updating state GENOMIC_RND */ /* Special state RND_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_SHATTER_SPECIAL(mat,0,j,RND_CODON); /* Source GENOMIC_RND is a special source for RND_CODON */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 3,GENOMIC_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) score = temp; /* Source MATCH for state RND_CODON is not special... already calculated */ /* Source INSERT for state RND_CODON is not special... already calculated */ /* Source DELETE for state RND_CODON is not special... already calculated */ /* Source RND_CODON is a special source for RND_CODON */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 3,RND_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 5,RND_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 4,RND_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 3,RND_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_SHATTER_SPECIAL(mat,0,j,RND_CODON) = score; /* Finished updating state RND_CODON */ /* Special state RND_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_SHATTER_SPECIAL(mat,0,j,RND_CENTRAL); /* Source RND_CENTRAL is a special source for RND_CENTRAL */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 1,RND_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 8,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 9,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 10,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_SHATTER_SPECIAL(mat,0,j,RND_CENTRAL) = score; /* Finished updating state RND_CENTRAL */ /* Special state RND_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_SHATTER_SPECIAL(mat,0,j,RND_PY_TRACT); /* Source RND_CENTRAL is a special source for RND_PY_TRACT */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 1,RND_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source RND_PY_TRACT is a special source for RND_PY_TRACT */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 1,RND_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_SHATTER_SPECIAL(mat,0,j,RND_PY_TRACT) = score; /* Finished updating state RND_PY_TRACT */ /* Special state RND_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_SHATTER_SPECIAL(mat,0,j,RND_SPACER); /* Source RND_PY_TRACT is a special source for RND_SPACER */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 1,RND_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_SPACER */ temp = GeneLoop21_SHATTER_SPECIAL(mat,0,j - 1,RND_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_SHATTER_SPECIAL(mat,0,j,RND_SPACER) = score; /* Finished updating state RND_SPACER */ } stop_reporting(); return TRUE; } /* Function: search_GeneLoop21(dbsi,out,querydb,targetdb,gp21,rndcodon,rndbase) * * Descrip: This function makes a database search of GeneLoop21 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp21 [UNKN ] Undocumented argument [GeneParser21Score *] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: rndbase [UNKN ] Undocumented argument [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_GeneLoop21(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_GeneLoop21 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_GeneLoop21. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_GeneLoop21. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for GeneLoop21, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_GeneLoop21(out,querydb, targetdb ,gp21,rndcodon,rndbase); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_GeneLoop21 *) ckalloc(sizeof(struct thread_pool_holder_GeneLoop21)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->gp21 = gp21; holder->rndcodon = rndcodon; holder->rndbase = rndbase; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_GeneLoop21,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for GeneLoop21"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from GeneLoop21",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_GeneLoop21(ptr) * * Descrip: Infinite loop code foreach thread for GeneLoop21 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_GeneLoop21(void * ptr) { struct thread_pool_holder_GeneLoop21 * holder; int db_status; int score; DataScore * ds; GeneWiseScore* query; ComplexSequence* target; holder = (struct thread_pool_holder_GeneLoop21 *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneLoop21"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneLoop21"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_GeneWiseDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in GeneLoop21 search"); } query = hard_link_GeneWiseScore(holder->query); /* get query information into datascore */ dataentry_add_GeneWiseDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_GenomicDB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_GenomicDB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching GeneLoop21, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_GenomicDB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_GeneWiseScore(holder->query); /* get the next query object for the next thread */ holder->query = reload_GeneWiseDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching GeneLoop21, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_GeneWiseDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneLoop21"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneLoop21"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_GenomicDB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_GeneLoop21(query, target ,holder->gp21,holder->rndcodon,holder->rndbase); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for GeneLoop21"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for GeneLoop21"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for GeneLoop21"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_GeneWiseScore(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for GeneLoop21"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_GeneLoop21(out,querydb,targetdb,gp21,rndcodon,rndbase) * * Descrip: This function makes a database search of GeneLoop21 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp21 [UNKN ] Undocumented argument [GeneParser21Score *] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: rndbase [UNKN ] Undocumented argument [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_GeneLoop21(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase) { GeneWiseScore* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GeneWiseDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneLoop21, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_GenomicDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneLoop21, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_GeneLoop21(query, target , gp21, rndcodon, rndbase); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("GeneLoop21 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GeneWiseDB(ds->query,query,querydb); dataentry_add_GenomicDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_GenomicDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GeneLoop21, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_GenomicDB(target,targetdb); query = reload_GeneWiseDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching GeneLoop21, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GeneWiseDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_GeneLoop21(query,target,gp21,rndcodon,rndbase) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_GeneLoop21_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_GeneLoop21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase) { int bestscore = NEGI; int i; int j; int k; GeneLoop21 * mat; mat = allocate_GeneLoop21_only(query, target , gp21, rndcodon, rndbase); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(11,(mat->leni + 1) * 21,11,7)) == NULL) { warn("Score only matrix for GeneLoop21 cannot be allocated, (asking for 10 by %d cells)",mat->leni*21); mat = free_GeneLoop21(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<12;j++) { for(i=(-1);ileni;i++) { for(k=0;k<21;k++) GeneLoop21_VSMALL_MATRIX(mat,i,j,k) = NEGI; } GeneLoop21_VSMALL_SPECIAL(mat,i,j,START) = 0; GeneLoop21_VSMALL_SPECIAL(mat,i,j,END) = NEGI; GeneLoop21_VSMALL_SPECIAL(mat,i,j,GENOMIC_RND) = NEGI; GeneLoop21_VSMALL_SPECIAL(mat,i,j,RND_CODON) = NEGI; GeneLoop21_VSMALL_SPECIAL(mat,i,j,RND_CENTRAL) = NEGI; GeneLoop21_VSMALL_SPECIAL(mat,i,j,RND_PY_TRACT) = NEGI; GeneLoop21_VSMALL_SPECIAL(mat,i,j,RND_SPACER) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state RND_CODON to state MATCH */ temp = GeneLoop21_VSMALL_SPECIAL(mat,i-1,j-3,RND_CODON) + ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp21->transition[GP21_RND2MODEL]); if( temp > score ) { score = temp; } /* From state SPACER_0M to state MATCH */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_0M to state MATCH */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1M to state MATCH */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_1M to state MATCH */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2M to state MATCH */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_2M to state MATCH */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLoop21_VSMALL_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_VSMALL_SPECIAL(mat,i,j,RND_CODON) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0I to state INSERT */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1I to state INSERT */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2I to state INSERT */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_0I to state INSERT */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_1I to state INSERT */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_2I to state INSERT */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLoop21_VSMALL_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_VSMALL_SPECIAL(mat,i,j,RND_CODON) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLoop21_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLoop21_VSMALL_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_VSMALL_SPECIAL(mat,i,j,RND_CODON) = temp; } /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ GeneLoop21_VSMALL_MATRIX(mat,i,j,CENTRAL_0M) = score; /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0M to state PY_0M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_VSMALL_MATRIX(mat,i,j,PY_0M) = score; /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0M to state SPACER_0M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_VSMALL_MATRIX(mat,i,j,SPACER_0M) = score; /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_1M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ GeneLoop21_VSMALL_MATRIX(mat,i,j,CENTRAL_1M) = score; /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1M to state PY_1M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_VSMALL_MATRIX(mat,i,j,PY_1M) = score; /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1M to state SPACER_1M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_VSMALL_MATRIX(mat,i,j,SPACER_1M) = score; /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_2M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_2M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ GeneLoop21_VSMALL_MATRIX(mat,i,j,CENTRAL_2M) = score; /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2M to state PY_2M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_VSMALL_MATRIX(mat,i,j,PY_2M) = score; /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2M to state SPACER_2M */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_VSMALL_MATRIX(mat,i,j,SPACER_2M) = score; /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ GeneLoop21_VSMALL_MATRIX(mat,i,j,CENTRAL_0I) = score; /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0I to state PY_0I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_VSMALL_MATRIX(mat,i,j,PY_0I) = score; /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0I to state SPACER_0I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_VSMALL_MATRIX(mat,i,j,SPACER_0I) = score; /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_1I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ GeneLoop21_VSMALL_MATRIX(mat,i,j,CENTRAL_1I) = score; /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1I to state PY_1I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_VSMALL_MATRIX(mat,i,j,PY_1I) = score; /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1I to state SPACER_1I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_VSMALL_MATRIX(mat,i,j,SPACER_1I) = score; /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ GeneLoop21_VSMALL_MATRIX(mat,i,j,CENTRAL_2I) = score; /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2I to state PY_2I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_VSMALL_MATRIX(mat,i,j,PY_2I) = score; /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2I to state SPACER_2I */ temp = GeneLoop21_VSMALL_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_VSMALL_MATRIX(mat,i,j,SPACER_2I) = score; /* Finished calculating state SPACER_2I */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_VSMALL_SPECIAL(mat,0,j,END); /* Source GENOMIC_RND is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 1,GENOMIC_RND) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GeneLoop21_VSMALL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state GENOMIC_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_VSMALL_SPECIAL(mat,0,j,GENOMIC_RND); /* Source START is a special source for GENOMIC_RND */ /* Has restricted position */ if( (j-1) == 0 ) { temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 1,START) + (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) + (0); if( temp > score ) score = temp; } /* Source GENOMIC_RND is a special source for GENOMIC_RND */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 1,GENOMIC_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for GENOMIC_RND */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 1,RND_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_VSMALL_SPECIAL(mat,0,j,GENOMIC_RND) = score; /* Finished updating state GENOMIC_RND */ /* Special state RND_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_VSMALL_SPECIAL(mat,0,j,RND_CODON); /* Source GENOMIC_RND is a special source for RND_CODON */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 3,GENOMIC_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) score = temp; /* Source MATCH for state RND_CODON is not special... already calculated */ /* Source INSERT for state RND_CODON is not special... already calculated */ /* Source DELETE for state RND_CODON is not special... already calculated */ /* Source RND_CODON is a special source for RND_CODON */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 3,RND_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 5,RND_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 4,RND_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 3,RND_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_VSMALL_SPECIAL(mat,0,j,RND_CODON) = score; /* Finished updating state RND_CODON */ /* Special state RND_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_VSMALL_SPECIAL(mat,0,j,RND_CENTRAL); /* Source RND_CENTRAL is a special source for RND_CENTRAL */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 1,RND_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 8,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 9,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 10,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_VSMALL_SPECIAL(mat,0,j,RND_CENTRAL) = score; /* Finished updating state RND_CENTRAL */ /* Special state RND_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_VSMALL_SPECIAL(mat,0,j,RND_PY_TRACT); /* Source RND_CENTRAL is a special source for RND_PY_TRACT */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 1,RND_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source RND_PY_TRACT is a special source for RND_PY_TRACT */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 1,RND_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_VSMALL_SPECIAL(mat,0,j,RND_PY_TRACT) = score; /* Finished updating state RND_PY_TRACT */ /* Special state RND_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_VSMALL_SPECIAL(mat,0,j,RND_SPACER); /* Source RND_PY_TRACT is a special source for RND_SPACER */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 1,RND_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_SPACER */ temp = GeneLoop21_VSMALL_SPECIAL(mat,0,j - 1,RND_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_VSMALL_SPECIAL(mat,0,j,RND_SPACER) = score; /* Finished updating state RND_SPACER */ if( bestscore < GeneLoop21_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = GeneLoop21_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_GeneLoop21(mat); return bestscore; } /* Function: PackAln_bestmemory_GeneLoop21(query,target,gp21,rndcodon,rndbase,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneLoop21 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_GeneLoop21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; GeneLoop21 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 21 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_GeneLoop21(query, target , gp21, rndcodon, rndbase,dpri)) == NULL ) { warn("Unable to allocate large GeneLoop21 version"); return NULL; } calculate_dpenv_GeneLoop21(mat,dpenv); out = PackAln_read_Expl_GeneLoop21(mat); } else { mat = allocate_GeneLoop21_only(query, target , gp21, rndcodon, rndbase); calculate_shatter_GeneLoop21(mat,dpenv); out = PackAln_read_Shatter_GeneLoop21(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_GeneLoop21(query, target , gp21, rndcodon, rndbase)) == NULL ) { warn("Unable to allocate small GeneLoop21 version"); return NULL; } out = PackAln_calculate_Small_GeneLoop21(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_GeneLoop21(query, target , gp21, rndcodon, rndbase,dpri)) == NULL ) { warn("Unable to allocate large GeneLoop21 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_GeneLoop21(mat); out = PackAln_read_Expl_GeneLoop21(mat); } } } mat = free_GeneLoop21(mat); return out; } /* Function: allocate_GeneLoop21_only(query,target,gp21,rndcodon,rndbase) * * Descrip: This function only allocates the GeneLoop21 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [GeneLoop21 *] * */ GeneLoop21 * allocate_GeneLoop21_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase) { GeneLoop21 * out; if((out= GeneLoop21_alloc()) == NULL) { warn("Allocation of basic GeneLoop21 structure failed..."); return NULL; } out->query = query; out->target = target; out->gp21 = gp21; out->rndcodon = rndcodon; out->rndbase = rndbase; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_GeneLoop21(query,target,gp21,rndcodon,rndbase,dpri) * * Descrip: This function allocates the GeneLoop21 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneLoop21_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneLoop21 *] * */ GeneLoop21 * allocate_Expl_GeneLoop21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase,DPRunImpl * dpri) { GeneLoop21 * out; out = allocate_GeneLoop21_only(query, target , gp21, rndcodon, rndbase); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+10)*21 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+10)*21,(out->leni+1),7,out->lenj+10)) == NULL) { warn("Explicit matrix GeneLoop21 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_GeneLoop21(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_GeneLoop21(out); return out; } /* Function: init_GeneLoop21(mat) * * Descrip: This function initates GeneLoop21 matrix when in explicit mode * Called in /allocate_Expl_GeneLoop21 * * * Arg: mat [UNKN ] GeneLoop21 which contains explicit basematrix memory [GeneLoop21 *] * */ void init_GeneLoop21(GeneLoop21 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-10);j<11;j++) { GeneLoop21_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2I) = NEGI; } } for(j= (-10);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { GeneLoop21_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2I) = NEGI; } GeneLoop21_EXPL_SPECIAL(mat,i,j,START) = 0; GeneLoop21_EXPL_SPECIAL(mat,i,j,END) = NEGI; GeneLoop21_EXPL_SPECIAL(mat,i,j,GENOMIC_RND) = NEGI; GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) = NEGI; GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CENTRAL) = NEGI; GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_PY_TRACT) = NEGI; GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_SPACER) = NEGI; } return; } /* Function: recalculate_PackAln_GeneLoop21(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneLoop21 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * */ void recalculate_PackAln_GeneLoop21(PackAln * pal,GeneLoop21 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (RND_CODON+21) ) { pau->score = ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp21->transition[GP21_RND2MODEL]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == SPACER_0M ) { pau->score = (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == PY_0M ) { pau->score = (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == SPACER_1M ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == PY_1M ) { pau->score = (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == SPACER_2M ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == PY_2M ) { pau->score = (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->gp21->transition[GP21_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->gp21->transition[GP21_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == MATCH ) { pau->score = mat->gp21->transition[GP21_INSERT_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == MATCH ) { pau->score = mat->gp21->transition[GP21_INSERT_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == SPACER_0I ) { pau->score = (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == SPACER_1I ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == SPACER_2I ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == PY_0I ) { pau->score = (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == PY_1I ) { pau->score = (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == PY_2I ) { pau->score = (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 2 && prev->state == INSERT ) { pau->score = mat->gp21->transition[GP21_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = mat->gp21->transition[GP21_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == INSERT ) { pau->score = mat->gp21->transition[GP21_INSERT_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == INSERT ) { pau->score = mat->gp21->transition[GP21_INSERT_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->seg[i]->transition[GW_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CENTRAL_0M : if( offi == 0 && offj == 8 && prev->state == MATCH ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == INSERT ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == DELETE ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CENTRAL_0M ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } warn("In recaluclating PackAln with state CENTRAL_0M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case PY_0M : if( offi == 0 && offj == 1 && prev->state == CENTRAL_0M ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == PY_0M ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state PY_0M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SPACER_0M : if( offi == 0 && offj == 1 && prev->state == PY_0M ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == SPACER_0M ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state SPACER_0M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CENTRAL_1M : if( offi == 0 && offj == 9 && prev->state == MATCH ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == INSERT ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == DELETE ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CENTRAL_1M ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } warn("In recaluclating PackAln with state CENTRAL_1M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case PY_1M : if( offi == 0 && offj == 1 && prev->state == CENTRAL_1M ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == PY_1M ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state PY_1M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SPACER_1M : if( offi == 0 && offj == 1 && prev->state == PY_1M ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == SPACER_1M ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state SPACER_1M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CENTRAL_2M : if( offi == 0 && offj == 10 && prev->state == MATCH ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == INSERT ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == DELETE ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CENTRAL_2M ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } warn("In recaluclating PackAln with state CENTRAL_2M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case PY_2M : if( offi == 0 && offj == 1 && prev->state == CENTRAL_2M ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == PY_2M ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state PY_2M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SPACER_2M : if( offi == 0 && offj == 1 && prev->state == PY_2M ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == SPACER_2M ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state SPACER_2M, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CENTRAL_0I : if( offi == 0 && offj == 8 && prev->state == MATCH ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == INSERT ) { pau->score = (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == DELETE ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CENTRAL_0I ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } warn("In recaluclating PackAln with state CENTRAL_0I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case PY_0I : if( offi == 0 && offj == 1 && prev->state == CENTRAL_0I ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == PY_0I ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state PY_0I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SPACER_0I : if( offi == 0 && offj == 1 && prev->state == PY_0I ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == SPACER_0I ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state SPACER_0I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CENTRAL_1I : if( offi == 0 && offj == 9 && prev->state == MATCH ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == INSERT ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == DELETE ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CENTRAL_1I ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } warn("In recaluclating PackAln with state CENTRAL_1I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case PY_1I : if( offi == 0 && offj == 1 && prev->state == CENTRAL_1I ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == PY_1I ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state PY_1I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SPACER_1I : if( offi == 0 && offj == 1 && prev->state == PY_1I ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == SPACER_1I ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state SPACER_1I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CENTRAL_2I : if( offi == 0 && offj == 10 && prev->state == MATCH ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == INSERT ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == INSERT ) { pau->score = ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CENTRAL_2I ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } warn("In recaluclating PackAln with state CENTRAL_2I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case PY_2I : if( offi == 0 && offj == 1 && prev->state == CENTRAL_2I ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == PY_2I ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state PY_2I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SPACER_2I : if( offi == 0 && offj == 1 && prev->state == PY_2I ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == SPACER_2I ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state SPACER_2I, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+21) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+21) : if( offj == 1 && prev->state == (GENOMIC_RND+21) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; case (GENOMIC_RND+21) : if( offj == 1 && prev->state == (START+21) ) { pau->score = mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)] + (0); continue; } if( offj == 1 && prev->state == (GENOMIC_RND+21) ) { pau->score = (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND]) + (0); continue; } if( offj == 1 && prev->state == (RND_CODON+21) ) { pau->score = (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND]) + (0); continue; } warn("In recaluclating PackAln with state GENOMIC_RND, got a bad source state. Error!"); break; case (RND_CODON+21) : if( offj == 3 && prev->state == (GENOMIC_RND+21) ) { pau->score = (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS]) + (0); continue; } if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } if( offj == 3 && prev->state == (RND_CODON+21) ) { pau->score = (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS]) + (0); continue; } if( offj == 5 && prev->state == (RND_SPACER+21) ) { pau->score = ((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0); continue; } if( offj == 4 && prev->state == (RND_SPACER+21) ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0); continue; } if( offj == 3 && prev->state == (RND_SPACER+21) ) { pau->score = (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0); continue; } warn("In recaluclating PackAln with state RND_CODON, got a bad source state. Error!"); break; case (RND_CENTRAL+21) : if( offj == 1 && prev->state == (RND_CENTRAL+21) ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) + (0); continue; } if( offj == 8 && prev->state == (RND_CODON+21) ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offj == 9 && prev->state == (RND_CODON+21) ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offj == 10 && prev->state == (RND_CODON+21) ) { pau->score = (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } warn("In recaluclating PackAln with state RND_CENTRAL, got a bad source state. Error!"); break; case (RND_PY_TRACT+21) : if( offj == 1 && prev->state == (RND_CENTRAL+21) ) { pau->score = mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offj == 1 && prev->state == (RND_PY_TRACT+21) ) { pau->score = mat->gp21->transition[GP21_PY2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state RND_PY_TRACT, got a bad source state. Error!"); break; case (RND_SPACER+21) : if( offj == 1 && prev->state == (RND_PY_TRACT+21) ) { pau->score = mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } if( offj == 1 && prev->state == (RND_SPACER+21) ) { pau->score = mat->gp21->transition[GP21_SPACER2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); continue; } warn("In recaluclating PackAln with state RND_SPACER, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define GeneLoop21_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+10)][(i+1)*21+state]) #define GeneLoop21_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+11)*8) % 88][(i+1)*21+state]) #define GeneLoop21_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+10)]) #define GeneLoop21_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) #define GeneLoop21_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+11)*8)+(shadow+1)) % 88)][(i+1)*21 + state]) #define GeneLoop21_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) #define GeneLoop21_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+10)% 10) * (leni+1) * 21) + ((i+1) * 21) + (state)]) #define GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+10)% 10) * (leni+1) * 168) + ((i+1) * 168) + (state * 8) + shadow+1]) #define GeneLoop21_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) /* Function: allocate_Small_GeneLoop21(query,target,gp21,rndcodon,rndbase) * * Descrip: This function allocates the GeneLoop21 structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneLoop21_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [GeneLoop21 *] * */ #define GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) GeneLoop21 * allocate_Small_GeneLoop21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase) { GeneLoop21 * out; out = allocate_GeneLoop21_only(query, target , gp21, rndcodon, rndbase); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(88,(out->leni + 1) * 21,56,out->lenj+10); if(out == NULL) { warn("Small shadow matrix GeneLoop21 cannot be allocated, (asking for 11 by %d main cells)",out->leni+2); free_GeneLoop21(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_GeneLoop21(mat,dpenv) * * Descrip: This function calculates an alignment for GeneLoop21 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneLoop21 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneLoop21 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_GeneLoop21(GeneLoop21 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for GeneLoop21 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneLoop21(mat,dpenv); score = start_end_find_end_GeneLoop21(mat,&endj); out->score = score; stopstate = END; /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */ log_full_error(REPORT,0,"End at %d Score %d",endj,score); stop_reporting(); for(;;) { /*while there are more special bits to recover*/ start_reporting("Special cell aln end %d:",endj); if( read_special_strip_GeneLoop21(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) { warn("Problem in reading off special state system... going to return partial alignment"); break; } if( startstate == START || endj <= 0) { log_full_error(REPORT,0,"Recovered complete alignment"); stop_reporting(); break; } log_full_error(REPORT,0,"Finished to %d",endj); stop_reporting(); /* Ok... have to eat up another piece of matrix */ temp = startstate; starti = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0); startj = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1); startstate = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2); stopi = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3); stopj = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4); stopstate = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5); /* Get out the score of this block. V. important! */ temp = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6); totalj = stopj - startj; donej = 0; start_reporting("Main matrix aln [%d,%d]:",startj,stopj); if(full_dc_GeneLoop21(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) { warn("In the alignment GeneLoop21 [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj); return out; } /* now have to figure out which special we came from... yikes */ max_matrix_to_special_GeneLoop21(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == GeneLoop21_READ_OFF_ERROR) { warn("In GeneLoop21 read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj); invert_PackAln(out); recalculate_PackAln_GeneLoop21(out,mat); return out; } /* if at start, break, otherwise, back to eat another strip */ if( stopstate == START) { log_full_error(REPORT,0,"Recovered complete alignment "); stop_reporting(); break; } log_full_error(REPORT,0,"Finished alignment to %d ",startj); stop_reporting(); endj = stopj; /* stopstate is correct as it is */ } /* end of while there are more special bits to recover */ invert_PackAln(out); recalculate_PackAln_GeneLoop21(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_GeneLoop21(mat) * * Descrip: This function calculates an alignment for GeneLoop21 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneLoop21 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneLoop21 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneLoop21 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_GeneLoop21(GeneLoop21 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_GeneLoop21(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_GeneLoop21(mat); return out; } /* Function: AlnRangeSet_from_GeneLoop21(mat) * * Descrip: This function reads off a start/end structure * for GeneLoop21 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneLoop21 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneLoop21 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_GeneLoop21(GeneLoop21 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneLoop21"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_GeneLoop21(mat,&jpos); state = END; while( (temp = AlnRange_build_GeneLoop21(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_GeneLoop21(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_GeneLoop21 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_GeneLoop21(GeneLoop21 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GeneLoop21"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_GeneLoop21(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_GeneLoop21 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = GeneLoop21_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_GeneLoop21(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == GeneLoop21_READ_OFF_ERROR) { warn("In AlnRange_build_GeneLoop21 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = GeneLoop21_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_GeneLoop21(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_GeneLoop21(GeneLoop21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_GeneLoop21(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneLoop21_READ_OFF_ERROR) { warn("In GeneLoop21 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In GeneLoop21 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In GeneLoop21 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_GeneLoop21(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_GeneLoop21(GeneLoop21 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneLoop21_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneLoop21 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = GeneLoop21_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp21->transition[GP21_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-5,MATCH); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->gp21->transition[GP21_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-4,MATCH); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp21->transition[GP21_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp21->transition[GP21_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 4,PY_2M) ) { *reti = i - 1; *retj = j - 4; *retstate = PY_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-4,PY_2M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 4,PY_2M); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 4,SPACER_2M) ) { *reti = i - 1; *retj = j - 4; *retstate = SPACER_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-4,SPACER_2M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 4,SPACER_2M); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 5,PY_1M) ) { *reti = i - 1; *retj = j - 5; *retstate = PY_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-5,PY_1M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 5,PY_1M); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 5,SPACER_1M) ) { *reti = i - 1; *retj = j - 5; *retstate = SPACER_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-5,SPACER_1M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 5,SPACER_1M); } temp = cscore - ((((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 6,PY_0M) ) { *reti = i - 1; *retj = j - 6; *retstate = PY_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-6,PY_0M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 6,PY_0M); } temp = cscore - ((((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 6,SPACER_0M) ) { *reti = i - 1; *retj = j - 6; *retstate = SPACER_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-6,SPACER_0M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 6,SPACER_0M); } /* Not allowing special sources.. skipping RND_CODON */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp21->transition[GP21_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 5,INSERT) ) { *reti = i - 1; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-5,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 5,INSERT); } temp = cscore - (mat->gp21->transition[GP21_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 4,INSERT) ) { *reti = i - 1; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-4,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 4,INSERT); } temp = cscore - (mat->gp21->transition[GP21_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->gp21->transition[GP21_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 2,INSERT) ) { *reti = i - 1; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-2,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 2,INSERT); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 4,PY_2I) ) { *reti = i - 1; *retj = j - 4; *retstate = PY_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-4,PY_2I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 4,PY_2I); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 5,PY_1I) ) { *reti = i - 1; *retj = j - 5; *retstate = PY_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-5,PY_1I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 5,PY_1I); } temp = cscore - ((((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 6,PY_0I) ) { *reti = i - 1; *retj = j - 6; *retstate = PY_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-6,PY_0I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 6,PY_0I); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 4,SPACER_2I) ) { *reti = i - 1; *retj = j - 4; *retstate = SPACER_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-4,SPACER_2I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 4,SPACER_2I); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 5,SPACER_1I) ) { *reti = i - 1; *retj = j - 5; *retstate = SPACER_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-5,SPACER_1I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 5,SPACER_1I); } temp = cscore - ((((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 6,SPACER_0I) ) { *reti = i - 1; *retj = j - 6; *retstate = SPACER_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-6,SPACER_0I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 6,SPACER_0I); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-3,DELETE); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_0M : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0M); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 8,DELETE) ) { *reti = i - 0; *retj = j - 8; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-8,DELETE); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 8,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-8,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-8,MATCH); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_0M : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0M); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0M); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_0M : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_0M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_0M); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0M); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_1M : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1M); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 9,DELETE) ) { *reti = i - 0; *retj = j - 9; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-9,DELETE); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 9,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-9,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-9,MATCH); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_1M : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1M); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1M); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_1M : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_1M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_1M); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1M); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_2M : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2M); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 10,DELETE) ) { *reti = i - 0; *retj = j - 10; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-10,DELETE); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 10,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-10,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-10,MATCH); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_2M : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2M); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2M); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_2M : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_2M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_2M); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2M); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2M); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_0I : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0I); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 8,DELETE) ) { *reti = i - 0; *retj = j - 8; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-8,DELETE); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 8,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-8,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-8,MATCH); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_0I : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0I); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_0I); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_0I : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_0I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_0I); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_0I); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_1I : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1I); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 9,DELETE) ) { *reti = i - 0; *retj = j - 9; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-9,DELETE); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 9,DELETE); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-9,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-9,MATCH); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_1I : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1I); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_1I); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_1I : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_1I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_1I); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_1I); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_2I : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2I); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-10,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-10,INSERT); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])) - (0); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-10,MATCH); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_2I : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2I); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,CENTRAL_2I); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_2I : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_2I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,SPACER_2I); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2I); } return GeneLoop21_HIDDEN_MATRIX(mat,i - 0,j - 1,PY_2I); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_GeneLoop21(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_GeneLoop21(GeneLoop21 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 21; add_PackAln(out,pau); } max_special_strip_GeneLoop21(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GeneLoop21_READ_OFF_ERROR) { warn("In special strip read GeneLoop21, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read GeneLoop21, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 21; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_GeneLoop21(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_GeneLoop21(GeneLoop21 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = GeneLoop21_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for GeneLoop21, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In GeneLoop21 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = GeneLoop21_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source GENOMIC_RND is a special */ temp = cscore - (0) - (0); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,GENOMIC_RND) ) { *reti = i - 0; *retj = j - 1; *retstate = GENOMIC_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-1,GENOMIC_RND); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,GENOMIC_RND) ; } case GENOMIC_RND : /* source RND_CODON is a special */ temp = cscore - ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) - (0); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,RND_CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-1,RND_CODON); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,RND_CODON) ; } /* source GENOMIC_RND is a special */ temp = cscore - ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) - (0); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,GENOMIC_RND) ) { *reti = i - 0; *retj = j - 1; *retstate = GENOMIC_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-1,GENOMIC_RND); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,GENOMIC_RND) ; } /* source START is a special */ temp = cscore - (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) - (0); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } case RND_CODON : /* source RND_SPACER is a special */ temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (0); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,RND_SPACER) ) { *reti = i - 0; *retj = j - 3; *retstate = RND_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-3,RND_SPACER); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 3,RND_SPACER) ; } /* source RND_SPACER is a special */ temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (0); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 4,RND_SPACER) ) { *reti = i - 0; *retj = j - 4; *retstate = RND_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-4,RND_SPACER); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 4,RND_SPACER) ; } /* source RND_SPACER is a special */ temp = cscore - (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (0); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 5,RND_SPACER) ) { *reti = i - 0; *retj = j - 5; *retstate = RND_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-5,RND_SPACER); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 5,RND_SPACER) ; } /* source RND_CODON is a special */ temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) - (0); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,RND_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = RND_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-3,RND_CODON); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 3,RND_CODON) ; } /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ /* source GENOMIC_RND is a special */ temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) - (0); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,GENOMIC_RND) ) { *reti = i - 0; *retj = j - 3; *retstate = GENOMIC_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-3,GENOMIC_RND); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 3,GENOMIC_RND) ; } case RND_CENTRAL : /* source RND_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 10,RND_CODON) ) { *reti = i - 0; *retj = j - 10; *retstate = RND_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-10,RND_CODON); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 10,RND_CODON) ; } /* source RND_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 9,RND_CODON) ) { *reti = i - 0; *retj = j - 9; *retstate = RND_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-9,RND_CODON); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 9,RND_CODON) ; } /* source RND_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 8,RND_CODON) ) { *reti = i - 0; *retj = j - 8; *retstate = RND_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-8,RND_CODON); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 8,RND_CODON) ; } /* source RND_CENTRAL is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,RND_CENTRAL) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_CENTRAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-1,RND_CENTRAL); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,RND_CENTRAL) ; } case RND_PY_TRACT : /* source RND_PY_TRACT is a special */ temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,RND_PY_TRACT) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_PY_TRACT; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-1,RND_PY_TRACT); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,RND_PY_TRACT) ; } /* source RND_CENTRAL is a special */ temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,RND_CENTRAL) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_CENTRAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-1,RND_CENTRAL); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,RND_CENTRAL) ; } case RND_SPACER : /* source RND_SPACER is a special */ temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,RND_SPACER) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-1,RND_SPACER); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,RND_SPACER) ; } /* source RND_PY_TRACT is a special */ temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,RND_PY_TRACT) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_PY_TRACT; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-0,j-1,RND_PY_TRACT); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 0,j - 1,RND_PY_TRACT) ; } default: warn("Major problem (!) - in GeneLoop21 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_GeneLoop21(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_GeneLoop21(GeneLoop21 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = GeneLoop21_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In GeneLoop21 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source PY_2M is not a special, should not get here! */ /* Source SPACER_2M is not a special, should not get here! */ /* Source PY_1M is not a special, should not get here! */ /* Source SPACER_1M is not a special, should not get here! */ /* Source PY_0M is not a special, should not get here! */ /* Source SPACER_0M is not a special, should not get here! */ temp = cscore - (((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp21->transition[GP21_RND2MODEL])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GeneLoop21_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,RND_CODON) ) { *reti = i - 1; *retj = j - 3; *retstate = RND_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GeneLoop21_DC_SHADOW_SPECIAL(mat,i-1,j-3,RND_CODON); } return GeneLoop21_DC_SHADOW_MATRIX(mat,i - 1,j - 3,RND_CODON) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source PY_2I is not a special, should not get here! */ /* Source PY_1I is not a special, should not get here! */ /* Source PY_0I is not a special, should not get here! */ /* Source SPACER_2I is not a special, should not get here! */ /* Source SPACER_1I is not a special, should not get here! */ /* Source SPACER_0I is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_0M : /* Source CENTRAL_0M is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_0M : /* Source PY_0M is not a special, should not get here! */ /* Source CENTRAL_0M is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_0M : /* Source SPACER_0M is not a special, should not get here! */ /* Source PY_0M is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_1M : /* Source CENTRAL_1M is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_1M : /* Source PY_1M is not a special, should not get here! */ /* Source CENTRAL_1M is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_1M : /* Source SPACER_1M is not a special, should not get here! */ /* Source PY_1M is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_2M : /* Source CENTRAL_2M is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_2M : /* Source PY_2M is not a special, should not get here! */ /* Source CENTRAL_2M is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_2M : /* Source SPACER_2M is not a special, should not get here! */ /* Source PY_2M is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_0I : /* Source CENTRAL_0I is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_0I : /* Source PY_0I is not a special, should not get here! */ /* Source CENTRAL_0I is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_0I : /* Source SPACER_0I is not a special, should not get here! */ /* Source PY_0I is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_1I : /* Source CENTRAL_1I is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_1I : /* Source PY_1I is not a special, should not get here! */ /* Source CENTRAL_1I is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_1I : /* Source SPACER_1I is not a special, should not get here! */ /* Source PY_1I is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_2I : /* Source CENTRAL_2I is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_2I : /* Source PY_2I is not a special, should not get here! */ /* Source CENTRAL_2I is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_2I : /* Source SPACER_2I is not a special, should not get here! */ /* Source PY_2I is not a special, should not get here! */ warn("Major problem (!) - in GeneLoop21 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_GeneLoop21(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_GeneLoop21(GeneLoop21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_GeneLoop21(mat,starti,startj,stopi,stopj); GeneLoop21_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneLoop21_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_0M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_1M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_2M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_0I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_1I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_2I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_2I) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0M to state MATCH */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_0M to state MATCH */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1M to state MATCH */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_1M to state MATCH */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2M to state MATCH */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_2M to state MATCH */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0I to state INSERT */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1I to state INSERT */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2I to state INSERT */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_0I to state INSERT */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_1I to state INSERT */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_2I to state INSERT */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLoop21_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_0M) = score; /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0M to state PY_0M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_0M) = score; /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0M to state SPACER_0M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_0M) = score; /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_1M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_1M) = score; /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1M to state PY_1M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_1M) = score; /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1M to state SPACER_1M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_1M) = score; /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_2M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_2M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_2M) = score; /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2M to state PY_2M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_2M) = score; /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2M to state SPACER_2M */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_2M) = score; /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_0I) = score; /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0I to state PY_0I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_0I) = score; /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0I to state SPACER_0I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_0I) = score; /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_1I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_1I) = score; /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1I to state PY_1I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_1I) = score; /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1I to state SPACER_1I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_1I) = score; /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_2I) = score; /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2I to state PY_2I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_2I) = score; /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2I to state SPACER_2I */ temp = GeneLoop21_HIDDEN_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_2I) = score; /* Finished calculating state SPACER_2I */ } } return; } /* Function: init_hidden_GeneLoop21(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_GeneLoop21(GeneLoop21 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-10);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { GeneLoop21_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_0M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_1M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_2M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_0I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_1I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,PY_2I) = NEGI; GeneLoop21_HIDDEN_MATRIX(mat,i,j,SPACER_2I) = NEGI; } } return; } /* Function: full_dc_GeneLoop21(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_GeneLoop21 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_GeneLoop21 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [GeneLoop21 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_GeneLoop21(GeneLoop21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_GeneLoop21"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 50) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_GeneLoop21(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_GeneLoop21(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_GeneLoop21(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for GeneLoop21, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= GeneLoop21_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= GeneLoop21_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_GeneLoop21(mat,GeneLoop21_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),GeneLoop21_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),GeneLoop21_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_GeneLoop21(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_GeneLoop21(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_GeneLoop21(GeneLoop21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_GeneLoop21(mat); GeneLoop21_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_GeneLoop21(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_GeneLoop21(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_GeneLoop21(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_GeneLoop21(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_GeneLoop21(GeneLoop21 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<10;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,1) = (-100); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,0) = (-100); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-6; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = SPACER_0M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,SPACER_0M,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-6; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = PY_0M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,PY_0M,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = SPACER_1M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,SPACER_1M,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = PY_1M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,PY_1M,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = SPACER_2M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,SPACER_2M,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = PY_2M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,PY_2M,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-6; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = SPACER_0I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,SPACER_0I,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = SPACER_1I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,SPACER_1I,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = SPACER_2I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,SPACER_2I,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score) { score = temp; if( j - 6 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-6; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = PY_0I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,PY_0I,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = PY_1I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,PY_1I,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = PY_2I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,PY_2I,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ /* For state CENTRAL_0M, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( j - 8 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,1) = j-8; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,2) = MATCH; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,5) = CENTRAL_0M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score) { score = temp; if( j - 8 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,1) = j-8; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,5) = CENTRAL_0M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score) { score = temp; if( j - 8 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,1) = j-8; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,2) = DELETE; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,5) = CENTRAL_0M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,DELETE,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,2) = CENTRAL_0M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,5) = CENTRAL_0M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0M,k); } } /* Add any movement independant score */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = score; /* Finished with state CENTRAL_0M */ /* For state PY_0M, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,2) = CENTRAL_0M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,5) = PY_0M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0M,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,2) = PY_0M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,5) = PY_0M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0M,k); } } /* Add any movement independant score */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = score; /* Finished with state PY_0M */ /* For state SPACER_0M, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,2) = PY_0M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,5) = SPACER_0M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0M,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,2) = SPACER_0M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,5) = SPACER_0M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_0M,k); } } /* Add any movement independant score */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = score; /* Finished with state SPACER_0M */ /* For state CENTRAL_1M, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( j - 9 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,1) = j-9; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,2) = MATCH; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,5) = CENTRAL_1M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score) { score = temp; if( j - 9 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,1) = j-9; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,5) = CENTRAL_1M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score) { score = temp; if( j - 9 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,1) = j-9; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,2) = DELETE; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,5) = CENTRAL_1M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,DELETE,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,2) = CENTRAL_1M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,5) = CENTRAL_1M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1M,k); } } /* Add any movement independant score */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = score; /* Finished with state CENTRAL_1M */ /* For state PY_1M, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,2) = CENTRAL_1M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,5) = PY_1M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1M,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,2) = PY_1M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,5) = PY_1M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1M,k); } } /* Add any movement independant score */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = score; /* Finished with state PY_1M */ /* For state SPACER_1M, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,2) = PY_1M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,5) = SPACER_1M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1M,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,2) = SPACER_1M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,5) = SPACER_1M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_1M,k); } } /* Add any movement independant score */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = score; /* Finished with state SPACER_1M */ /* For state CENTRAL_2M, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( j - 10 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,1) = j-10; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,2) = MATCH; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,5) = CENTRAL_2M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score) { score = temp; if( j - 10 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,1) = j-10; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,5) = CENTRAL_2M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score) { score = temp; if( j - 10 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,1) = j-10; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,2) = DELETE; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,5) = CENTRAL_2M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,DELETE,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,2) = CENTRAL_2M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,5) = CENTRAL_2M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2M,k); } } /* Add any movement independant score */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = score; /* Finished with state CENTRAL_2M */ /* For state PY_2M, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,2) = CENTRAL_2M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,5) = PY_2M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2M,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,2) = PY_2M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,5) = PY_2M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2M,k); } } /* Add any movement independant score */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = score; /* Finished with state PY_2M */ /* For state SPACER_2M, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,2) = PY_2M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,5) = SPACER_2M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2M,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,2) = SPACER_2M; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,5) = SPACER_2M; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_2M,k); } } /* Add any movement independant score */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = score; /* Finished with state SPACER_2M */ /* For state CENTRAL_0I, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( j - 8 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,1) = j-8; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,2) = MATCH; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,5) = CENTRAL_0I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score) { score = temp; if( j - 8 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,1) = j-8; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,5) = CENTRAL_0I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score) { score = temp; if( j - 8 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,1) = j-8; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,2) = DELETE; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,5) = CENTRAL_0I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,DELETE,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,2) = CENTRAL_0I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,5) = CENTRAL_0I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0I,k); } } /* Add any movement independant score */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = score; /* Finished with state CENTRAL_0I */ /* For state PY_0I, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,2) = CENTRAL_0I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,5) = PY_0I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0I,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,2) = PY_0I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,5) = PY_0I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0I,k); } } /* Add any movement independant score */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = score; /* Finished with state PY_0I */ /* For state SPACER_0I, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,2) = PY_0I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,5) = SPACER_0I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0I,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,2) = SPACER_0I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,5) = SPACER_0I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_0I,k); } } /* Add any movement independant score */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = score; /* Finished with state SPACER_0I */ /* For state CENTRAL_1I, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); if( j - 9 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,1) = j-9; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,2) = MATCH; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,5) = CENTRAL_1I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score) { score = temp; if( j - 9 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,1) = j-9; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,5) = CENTRAL_1I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score) { score = temp; if( j - 9 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,1) = j-9; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,2) = DELETE; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,5) = CENTRAL_1I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,DELETE,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,2) = CENTRAL_1I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,5) = CENTRAL_1I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1I,k); } } /* Add any movement independant score */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = score; /* Finished with state CENTRAL_1I */ /* For state PY_1I, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,2) = CENTRAL_1I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,5) = PY_1I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1I,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,2) = PY_1I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,5) = PY_1I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1I,k); } } /* Add any movement independant score */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = score; /* Finished with state PY_1I */ /* For state SPACER_1I, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,2) = PY_1I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,5) = SPACER_1I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1I,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,2) = SPACER_1I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,5) = SPACER_1I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_1I,k); } } /* Add any movement independant score */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = score; /* Finished with state SPACER_1I */ /* For state CENTRAL_2I, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); if( j - 10 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,1) = j-10; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,2) = MATCH; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,5) = CENTRAL_2I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score) { score = temp; if( j - 10 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,1) = j-10; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,5) = CENTRAL_2I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score) { score = temp; if( j - 10 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,1) = j-10; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,2) = INSERT; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,5) = CENTRAL_2I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,2) = CENTRAL_2I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,5) = CENTRAL_2I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2I,k); } } /* Add any movement independant score */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = score; /* Finished with state CENTRAL_2I */ /* For state PY_2I, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,2) = CENTRAL_2I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,5) = PY_2I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2I,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,2) = PY_2I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,5) = PY_2I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2I,k); } } /* Add any movement independant score */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = score; /* Finished with state PY_2I */ /* For state SPACER_2I, pushing when j - offj <= mergej */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,2) = PY_2I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,5) = SPACER_2I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2I,k); } temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,0) = i-0; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,1) = j-1; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,2) = SPACER_2I; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,3) = i; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,4) = j; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,5) = SPACER_2I; } else { for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,k) = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_2I,k); } } /* Add any movement independant score */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = score; /* Finished with state SPACER_2I */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_GeneLoop21(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_GeneLoop21(GeneLoop21 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state SPACER_0M to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,SPACER_0M,k); } /* From state PY_0M to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,PY_0M,k); } /* From state SPACER_1M to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,SPACER_1M,k); } /* From state PY_1M to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,PY_1M,k); } /* From state SPACER_2M to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,SPACER_2M,k); } /* From state PY_2M to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,PY_2M,k); } /* From state MATCH to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } /* From state MATCH to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state DELETE to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } /* From state SPACER_0I to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,SPACER_0I,k); } /* From state SPACER_1I to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,SPACER_1I,k); } /* From state SPACER_2I to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,SPACER_2I,k); } /* From state PY_0I to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,PY_0I,k); } /* From state PY_1I to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,PY_1I,k); } /* From state PY_2I to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,PY_2I,k); } /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,k); } /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); /* From state INSERT to state CENTRAL_0M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } /* From state DELETE to state CENTRAL_0M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,DELETE,k); } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0M,k); } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0M,k); /* From state PY_0M to state PY_0M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0M,k); } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0M,k); /* From state SPACER_0M to state SPACER_0M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_0M,k); } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); /* From state INSERT to state CENTRAL_1M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } /* From state DELETE to state CENTRAL_1M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,DELETE,k); } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1M,k); } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1M,k); /* From state PY_1M to state PY_1M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1M,k); } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1M,k); /* From state SPACER_1M to state SPACER_1M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_1M,k); } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); /* From state INSERT to state CENTRAL_2M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } /* From state DELETE to state CENTRAL_2M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,DELETE,k); } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2M,k); } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2M,k); /* From state PY_2M to state PY_2M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2M,k); } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2M,k); /* From state SPACER_2M to state SPACER_2M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_2M,k); } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); /* From state INSERT to state CENTRAL_0I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } /* From state DELETE to state CENTRAL_0I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,DELETE,k); } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0I,k); } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0I,k); /* From state PY_0I to state PY_0I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0I,k); } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0I,k); /* From state SPACER_0I to state SPACER_0I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_0I,k); } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); /* From state INSERT to state CENTRAL_1I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } /* From state DELETE to state CENTRAL_1I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,DELETE,k); } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1I,k); } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1I,k); /* From state PY_1I to state PY_1I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1I,k); } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1I,k); /* From state SPACER_1I to state SPACER_1I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_1I,k); } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2I,k); } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2I,k); /* From state PY_2I to state PY_2I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2I,k); } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2I,k); /* From state SPACER_2I to state SPACER_2I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_2I,k); } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = score; for(k=0;k<7;k++) GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_2I */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_GeneLoop21(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_GeneLoop21(GeneLoop21 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0M to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_0M to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1M to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_1M to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2M to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_2M to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0I to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1I to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2I to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_0I to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_1I to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_2I to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = score; /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0M to state PY_0M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = score; /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0M to state SPACER_0M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = score; /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_1M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = score; /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1M to state PY_1M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = score; /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1M to state SPACER_1M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = score; /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_2M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_2M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = score; /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2M to state PY_2M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = score; /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2M to state SPACER_2M */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = score; /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = score; /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0I to state PY_0I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = score; /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0I to state SPACER_0I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = score; /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_1I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = score; /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1I to state PY_1I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = score; /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1I to state SPACER_1I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = score; /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = score; /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2I to state PY_2I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = score; /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2I to state SPACER_2I */ temp = GeneLoop21_DC_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = score; /* Finished calculating state SPACER_2I */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_GeneLoop21(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * */ } void init_dc_GeneLoop21(GeneLoop21 * mat) { register int i; register int j; register int k; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = NEGI; for(k=0;k<7;k++) { GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,k) = (-1); GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,k) = (-1); } } } return; } /* Function: start_end_find_end_GeneLoop21(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [GeneLoop21 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_GeneLoop21(GeneLoop21 * mat,int * endj) { register int j; register int max; register int maxj; max = GeneLoop21_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( GeneLoop21_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = GeneLoop21_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_GeneLoop21(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [GeneLoop21] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_GeneLoop21(GeneLoop21 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (10 * (leni + 1) * 21,sizeof(int)); shadow_pointers = (int *) calloc (10 * (leni + 1) * 21 * 8,sizeof(int)); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state RND_CODON to state MATCH */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,RND_CODON) + ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp21->transition[GP21_RND2MODEL]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [RND_CODON] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state SPACER_0M to state MATCH */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,SPACER_0M,0)); } /* From state PY_0M to state MATCH */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,PY_0M,0)); } /* From state SPACER_1M to state MATCH */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,SPACER_1M,0)); } /* From state PY_1M to state MATCH */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,PY_1M,0)); } /* From state SPACER_2M to state MATCH */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,SPACER_2M,0)); } /* From state PY_2M to state MATCH */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,PY_2M,0)); } /* From state MATCH to state MATCH */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,i,j,RND_CODON) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,k) = GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,6) = GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,3) = i; GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,4) = j; GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state DELETE to state INSERT */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0)); } /* From state SPACER_0I to state INSERT */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,SPACER_0I,0)); } /* From state SPACER_1I to state INSERT */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,SPACER_1I,0)); } /* From state SPACER_2I to state INSERT */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,SPACER_2I,0)); } /* From state PY_0I to state INSERT */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,PY_0I,0)); } /* From state PY_1I to state INSERT */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,PY_1I,0)); } /* From state PY_2I to state INSERT */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,PY_2I,0)); } /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,0)); } /* From state INSERT to state INSERT */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,i,j,RND_CODON) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,k) = GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,6) = GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,3) = i; GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,4) = j; GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,i,j,RND_CODON) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,k) = GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,6) = GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,3) = i; GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,4) = j; GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,5) = DELETE; } /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,0)); /* From state INSERT to state CENTRAL_0M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,0)); } /* From state DELETE to state CENTRAL_0M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,DELETE,0)); } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0M,0)); } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0M,0)); /* From state PY_0M to state PY_0M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY] +(mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0M,0)); } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,PY_0M) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,PY_0M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0M,0)); /* From state SPACER_0M to state SPACER_0M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER] +(mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_0M,0)); } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,SPACER_0M) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,0)); /* From state INSERT to state CENTRAL_1M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,0)); } /* From state DELETE to state CENTRAL_1M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,DELETE,0)); } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1M,0)); } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1M,0)); /* From state PY_1M to state PY_1M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY] +(mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1M,0)); } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,PY_1M) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,PY_1M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1M,0)); /* From state SPACER_1M to state SPACER_1M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER] +(mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_1M,0)); } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,SPACER_1M) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,0)); /* From state INSERT to state CENTRAL_2M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0)); } /* From state DELETE to state CENTRAL_2M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,DELETE,0)); } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2M,0)); } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2M,0)); /* From state PY_2M to state PY_2M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY] +(mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2M,0)); } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,PY_2M) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,PY_2M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2M,0)); /* From state SPACER_2M to state SPACER_2M */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER] +(mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_2M,0)); } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,SPACER_2M) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,0)); /* From state INSERT to state CENTRAL_0I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,0)); } /* From state DELETE to state CENTRAL_0I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,DELETE,0)); } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0I,0)); } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_0I,0)); /* From state PY_0I to state PY_0I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY] +(mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0I,0)); } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,PY_0I) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,PY_0I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_0I,0)); /* From state SPACER_0I to state SPACER_0I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER] +(mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_0I,0)); } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,SPACER_0I) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]) + (0); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,0)); /* From state INSERT to state CENTRAL_1I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,0)); } /* From state DELETE to state CENTRAL_1I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,DELETE,0)); } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1I,0)); } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_1I,0)); /* From state PY_1I to state PY_1I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY] +(mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1I,0)); } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,PY_1I) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,PY_1I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_1I,0)); /* From state SPACER_1I to state SPACER_1I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER] +(mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_1I,0)); } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,SPACER_1I) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]) + (0); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,0)); /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0)); } /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0)); } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2I,0)); } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY] + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CENTRAL_2I,0)); /* From state PY_2I to state PY_2I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY] +(mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2I,0)); } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,PY_2I) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,PY_2I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER] + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,PY_2I,0)); /* From state SPACER_2I to state SPACER_2I */ temp = GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER] +(mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SPACER_2I,0)); } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GeneLoop21_DC_OPT_SHADOW_MATRIX(mat,i,j,SPACER_2I) = score; for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SPACER_2I */ } /* end of for each i position in strip */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j,END); /* Source GENOMIC_RND is a special source for END */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,GENOMIC_RND) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,GENOMIC_RND,k); } /* Put back score... (now updated!) */ GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state GENOMIC_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j,GENOMIC_RND); /* Source START is a special source for GENOMIC_RND */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,START) + (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,GENOMIC_RND,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,START,k); } /* Source GENOMIC_RND is a special source for GENOMIC_RND */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,GENOMIC_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,GENOMIC_RND,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,GENOMIC_RND,k); } /* Source RND_CODON is a special source for GENOMIC_RND */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,RND_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,GENOMIC_RND,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,RND_CODON,k); } /* Put back score... (now updated!) */ GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j,GENOMIC_RND) = score; /* Finished updating state GENOMIC_RND */ /* Special state RND_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j,RND_CODON); /* Source GENOMIC_RND is a special source for RND_CODON */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,GENOMIC_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,GENOMIC_RND,k); } /* Source MATCH for state RND_CODON is not special... already calculated */ /* Source INSERT for state RND_CODON is not special... already calculated */ /* Source DELETE for state RND_CODON is not special... already calculated */ /* Source RND_CODON is a special source for RND_CODON */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,RND_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,RND_CODON,k); } /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 5,RND_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 5,RND_SPACER,k); } /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 4,RND_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 4,RND_SPACER,k); } /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,RND_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CODON,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,RND_SPACER,k); } /* Put back score... (now updated!) */ GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j,RND_CODON) = score; /* Finished updating state RND_CODON */ /* Special state RND_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j,RND_CENTRAL); /* Source RND_CENTRAL is a special source for RND_CENTRAL */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,RND_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CENTRAL,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,RND_CENTRAL,k); } /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 8,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CENTRAL,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 8,RND_CODON,k); } /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 9,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CENTRAL,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 9,RND_CODON,k); } /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 10,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_CENTRAL,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 10,RND_CODON,k); } /* Put back score... (now updated!) */ GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j,RND_CENTRAL) = score; /* Finished updating state RND_CENTRAL */ /* Special state RND_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j,RND_PY_TRACT); /* Source RND_CENTRAL is a special source for RND_PY_TRACT */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,RND_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_PY_TRACT,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,RND_CENTRAL,k); } /* Source RND_PY_TRACT is a special source for RND_PY_TRACT */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,RND_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_PY_TRACT,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,RND_PY_TRACT,k); } /* Put back score... (now updated!) */ GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j,RND_PY_TRACT) = score; /* Finished updating state RND_PY_TRACT */ /* Special state RND_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j,RND_SPACER); /* Source RND_PY_TRACT is a special source for RND_SPACER */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,RND_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_SPACER,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,RND_PY_TRACT,k); } /* Source RND_SPACER is a special source for RND_SPACER */ temp = GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,RND_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,RND_SPACER,k) = GeneLoop21_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,RND_SPACER,k); } /* Put back score... (now updated!) */ GeneLoop21_DC_OPT_SHADOW_SPECIAL(mat,0,j,RND_SPACER) = score; /* Finished updating state RND_SPACER */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_GeneLoop21(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * */ void init_start_end_linear_GeneLoop21(GeneLoop21 * mat) { register int i; register int j; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0M,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0M,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0M,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1M,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1M,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1M,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2M,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2M,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2M,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_0I,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_0I,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_0I,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_1I,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_1I,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_1I,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,CENTRAL_2I,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,PY_2I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,PY_2I,0) = (-1); GeneLoop21_DC_SHADOW_MATRIX(mat,i,j,SPACER_2I) = NEGI; GeneLoop21_DC_SHADOW_MATRIX_SP(mat,i,j,SPACER_2I,0) = (-1); } } for(j=(-10);jtarget->seq->len;j++) { GeneLoop21_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; GeneLoop21_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); GeneLoop21_DC_SHADOW_SPECIAL(mat,0,j,GENOMIC_RND) = NEGI; GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,j,GENOMIC_RND,0) = (-1); GeneLoop21_DC_SHADOW_SPECIAL(mat,0,j,RND_CODON) = NEGI; GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,j,RND_CODON,0) = (-1); GeneLoop21_DC_SHADOW_SPECIAL(mat,0,j,RND_CENTRAL) = NEGI; GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,j,RND_CENTRAL,0) = (-1); GeneLoop21_DC_SHADOW_SPECIAL(mat,0,j,RND_PY_TRACT) = NEGI; GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,j,RND_PY_TRACT,0) = (-1); GeneLoop21_DC_SHADOW_SPECIAL(mat,0,j,RND_SPACER) = NEGI; GeneLoop21_DC_SHADOW_SPECIAL_SP(mat,0,j,RND_SPACER,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_GeneLoop21(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_GeneLoop21(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_GeneLoop21(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","INTRON_MATCH_0","INTRON_MATCH_1","INTRON_MATCH_2","INTRON_INSERT_0","INTRON_INSERT_1","INTRON_INSERT_2","END","GENOMIC_RND_STATE" }; /* Function: AlnConvertSet_GeneLoop21(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","5SS_PHASE_0","CENTRAL_INTRON","PYRIMIDINE_TRACT","SPACER","5SS_PHASE_1","5SS_PHASE_2","END","RANDOM_SEQUENCE" }; AlnConvertSet * AlnConvertSet_GeneLoop21(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_CODON + 21; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_0M; acu->state2 = MATCH; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_0M; acu->state2 = MATCH; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_1M; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_1M; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_2M; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_2M; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_0I; acu->state2 = INSERT; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_1I; acu->state2 = INSERT; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_2I; acu->state2 = INSERT; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_0I; acu->state2 = INSERT; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_1I; acu->state2 = INSERT; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_2I; acu->state2 = INSERT; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = CENTRAL_0M; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_0M; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = CENTRAL_0M; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_0M; acu->state2 = CENTRAL_0M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_0M; acu->state2 = PY_0M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_0M; acu->state2 = PY_0M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_0M; acu->state2 = SPACER_0M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_0M; acu->state2 = SPACER_0M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = CENTRAL_1M; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_1M; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = CENTRAL_1M; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_1M; acu->state2 = CENTRAL_1M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_1M; acu->state2 = PY_1M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_1M; acu->state2 = PY_1M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_1M; acu->state2 = SPACER_1M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_1M; acu->state2 = SPACER_1M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = CENTRAL_2M; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[5]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_2M; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[5]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = CENTRAL_2M; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[5]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_2M; acu->state2 = CENTRAL_2M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_2M; acu->state2 = PY_2M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_2M; acu->state2 = PY_2M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_2M; acu->state2 = SPACER_2M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_2M; acu->state2 = SPACER_2M; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = CENTRAL_0I; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[6]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_0I; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[6]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = CENTRAL_0I; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[6]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_0I; acu->state2 = CENTRAL_0I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_0I; acu->state2 = PY_0I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_0I; acu->state2 = PY_0I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_0I; acu->state2 = SPACER_0I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_0I; acu->state2 = SPACER_0I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = CENTRAL_1I; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[7]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_1I; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[7]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = CENTRAL_1I; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[7]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_1I; acu->state2 = CENTRAL_1I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_1I; acu->state2 = PY_1I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_1I; acu->state2 = PY_1I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_1I; acu->state2 = SPACER_1I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_1I; acu->state2 = SPACER_1I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = CENTRAL_2I; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[8]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_2I; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[8]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = CENTRAL_2I; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[8]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_2I; acu->state2 = CENTRAL_2I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CENTRAL_2I; acu->state2 = PY_2I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_2I; acu->state2 = PY_2I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PY_2I; acu->state2 = SPACER_2I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPACER_2I; acu->state2 = SPACER_2I; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = GENOMIC_RND + 21; acu->state2 = END + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[9]; acu->label2 = target_label[13]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 21; acu->state2 = GENOMIC_RND + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = GENOMIC_RND + 21; acu->state2 = GENOMIC_RND + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_CODON + 21; acu->state2 = GENOMIC_RND + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = GENOMIC_RND + 21; acu->state2 = RND_CODON + 21; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[10]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = RND_CODON + 21; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = RND_CODON + 21; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = RND_CODON + 21; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_CODON + 21; acu->state2 = RND_CODON + 21; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[10]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_SPACER + 21; acu->state2 = RND_CODON + 21; acu->offi = (-1); acu->offj = 5; acu->label1 = query_label[10]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_SPACER + 21; acu->state2 = RND_CODON + 21; acu->offi = (-1); acu->offj = 4; acu->label1 = query_label[10]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_SPACER + 21; acu->state2 = RND_CODON + 21; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[10]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_CENTRAL + 21; acu->state2 = RND_CENTRAL + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_CODON + 21; acu->state2 = RND_CENTRAL + 21; acu->offi = (-1); acu->offj = 8; acu->label1 = query_label[10]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_CODON + 21; acu->state2 = RND_CENTRAL + 21; acu->offi = (-1); acu->offj = 9; acu->label1 = query_label[10]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_CODON + 21; acu->state2 = RND_CENTRAL + 21; acu->offi = (-1); acu->offj = 10; acu->label1 = query_label[10]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_CENTRAL + 21; acu->state2 = RND_PY_TRACT + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_PY_TRACT + 21; acu->state2 = RND_PY_TRACT + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_PY_TRACT + 21; acu->state2 = RND_SPACER + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = RND_SPACER + 21; acu->state2 = RND_SPACER + 21; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[10]; acu->label2 = target_label[10]; add_collapse_label_AlnConvertSet(out,"GENOMIC_RND_STATE","RANDOM_SEQUENCE"); add_collapse_label_AlnConvertSet(out,"GENOMIC_RND_STATE","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_MATCH_0","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_MATCH_1","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_MATCH_2","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_INSERT_0","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_INSERT_1","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"INTRON_INSERT_2","CENTRAL_INTRON"); return out; } /* Function: PackAln_read_Expl_GeneLoop21(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_GeneLoop21(GeneLoop21 * mat) { GeneLoop21_access_func_holder holder; holder.access_main = GeneLoop21_explicit_access_main; holder.access_special = GeneLoop21_explicit_access_special; return PackAln_read_generic_GeneLoop21(mat,holder); } /* Function: GeneLoop21_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneLoop21_explicit_access_main(GeneLoop21 * mat,int i,int j,int state) { return GeneLoop21_EXPL_MATRIX(mat,i,j,state); } /* Function: GeneLoop21_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GeneLoop21_explicit_access_special(GeneLoop21 * mat,int i,int j,int state) { return GeneLoop21_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_GeneLoop21(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: h [UNKN ] Undocumented argument [GeneLoop21_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_GeneLoop21(GeneLoop21 * mat,GeneLoop21_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_GeneLoop21(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in GeneLoop21_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 21; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_GeneLoop21(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_GeneLoop21(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == GeneLoop21_READ_OFF_ERROR || j == GeneLoop21_READ_OFF_ERROR || state == GeneLoop21_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in GeneLoop21_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 21; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_GeneLoop21(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [GeneLoop21_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_GeneLoop21(GeneLoop21 * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneLoop21_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: GeneLoop21_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void GeneLoop21_debug_show_matrix(GeneLoop21 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"State CENTRAL_0M %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0M)); fprintf(ofp,"State PY_0M %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0M)); fprintf(ofp,"State SPACER_0M %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0M)); fprintf(ofp,"State CENTRAL_1M %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1M)); fprintf(ofp,"State PY_1M %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1M)); fprintf(ofp,"State SPACER_1M %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1M)); fprintf(ofp,"State CENTRAL_2M %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2M)); fprintf(ofp,"State PY_2M %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2M)); fprintf(ofp,"State SPACER_2M %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2M)); fprintf(ofp,"State CENTRAL_0I %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0I)); fprintf(ofp,"State PY_0I %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0I)); fprintf(ofp,"State SPACER_0I %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0I)); fprintf(ofp,"State CENTRAL_1I %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1I)); fprintf(ofp,"State PY_1I %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1I)); fprintf(ofp,"State SPACER_1I %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1I)); fprintf(ofp,"State CENTRAL_2I %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2I)); fprintf(ofp,"State PY_2I %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2I)); fprintf(ofp,"State SPACER_2I %d\n",GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2I)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_GeneLoop21(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneLoop21_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_GeneLoop21(GeneLoop21 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneLoop21_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneLoop21_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GeneLoop21 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp21->transition[GP21_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,MATCH); } return (*h.access_main)(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->gp21->transition[GP21_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH); } return (*h.access_main)(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp21->transition[GP21_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp21->transition[GP21_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,PY_2M) ) { *reti = i - 1; *retj = j - 4; *retstate = PY_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,PY_2M); } return (*h.access_main)(mat,i - 1,j - 4,PY_2M); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,SPACER_2M) ) { *reti = i - 1; *retj = j - 4; *retstate = SPACER_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,SPACER_2M); } return (*h.access_main)(mat,i - 1,j - 4,SPACER_2M); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,PY_1M) ) { *reti = i - 1; *retj = j - 5; *retstate = PY_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,PY_1M); } return (*h.access_main)(mat,i - 1,j - 5,PY_1M); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,SPACER_1M) ) { *reti = i - 1; *retj = j - 5; *retstate = SPACER_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,SPACER_1M); } return (*h.access_main)(mat,i - 1,j - 5,SPACER_1M); } temp = cscore - ((((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,PY_0M) ) { *reti = i - 1; *retj = j - 6; *retstate = PY_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,PY_0M); } return (*h.access_main)(mat,i - 1,j - 6,PY_0M); } temp = cscore - ((((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,SPACER_0M) ) { *reti = i - 1; *retj = j - 6; *retstate = SPACER_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,SPACER_0M); } return (*h.access_main)(mat,i - 1,j - 6,SPACER_0M); } temp = cscore - (((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp21->transition[GP21_RND2MODEL])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 1,j - 3,RND_CODON) ) { *reti = i - 1; *retj = j - 3; *retstate = RND_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,RND_CODON); } return (*h.access_main)(mat,i - 1,j - 3,RND_CODON); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp21->transition[GP21_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,INSERT) ) { *reti = i - 1; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,INSERT); } return (*h.access_main)(mat,i - 1,j - 5,INSERT); } temp = cscore - (mat->gp21->transition[GP21_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,INSERT) ) { *reti = i - 1; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,INSERT); } return (*h.access_main)(mat,i - 1,j - 4,INSERT); } temp = cscore - (mat->gp21->transition[GP21_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->gp21->transition[GP21_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 2,INSERT) ) { *reti = i - 1; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,INSERT); } return (*h.access_main)(mat,i - 1,j - 2,INSERT); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,PY_2I) ) { *reti = i - 1; *retj = j - 4; *retstate = PY_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,PY_2I); } return (*h.access_main)(mat,i - 1,j - 4,PY_2I); } temp = cscore - ((mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,PY_1I) ) { *reti = i - 1; *retj = j - 5; *retstate = PY_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,PY_1I); } return (*h.access_main)(mat,i - 1,j - 5,PY_1I); } temp = cscore - ((((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,PY_0I) ) { *reti = i - 1; *retj = j - 6; *retstate = PY_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,PY_0I); } return (*h.access_main)(mat,i - 1,j - 6,PY_0I); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,SPACER_2I) ) { *reti = i - 1; *retj = j - 4; *retstate = SPACER_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,SPACER_2I); } return (*h.access_main)(mat,i - 1,j - 4,SPACER_2I); } temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,SPACER_1I) ) { *reti = i - 1; *retj = j - 5; *retstate = SPACER_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,SPACER_1I); } return (*h.access_main)(mat,i - 1,j - 5,SPACER_1I); } temp = cscore - ((((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,SPACER_0I) ) { *reti = i - 1; *retj = j - 6; *retstate = SPACER_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,SPACER_0I); } return (*h.access_main)(mat,i - 1,j - 6,SPACER_0I); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE); } return (*h.access_main)(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_0M : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_0M); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0M); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,DELETE) ) { *reti = i - 0; *retj = j - 8; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,DELETE); } return (*h.access_main)(mat,i - 0,j - 8,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,INSERT); } return (*h.access_main)(mat,i - 0,j - 8,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,MATCH); } return (*h.access_main)(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_0M : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_0M); } return (*h.access_main)(mat,i - 0,j - 1,PY_0M); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_0M); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0M); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_0M : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SPACER_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SPACER_0M); } return (*h.access_main)(mat,i - 0,j - 1,SPACER_0M); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_0M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_0M); } return (*h.access_main)(mat,i - 0,j - 1,PY_0M); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_1M : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_1M); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1M); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,DELETE) ) { *reti = i - 0; *retj = j - 9; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,DELETE); } return (*h.access_main)(mat,i - 0,j - 9,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,INSERT); } return (*h.access_main)(mat,i - 0,j - 9,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,MATCH); } return (*h.access_main)(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_1M : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_1M); } return (*h.access_main)(mat,i - 0,j - 1,PY_1M); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_1M); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1M); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_1M : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SPACER_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SPACER_1M); } return (*h.access_main)(mat,i - 0,j - 1,SPACER_1M); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_1M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_1M); } return (*h.access_main)(mat,i - 0,j - 1,PY_1M); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_2M : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_2M); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2M); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,DELETE) ) { *reti = i - 0; *retj = j - 10; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,DELETE); } return (*h.access_main)(mat,i - 0,j - 10,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT); } return (*h.access_main)(mat,i - 0,j - 10,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,MATCH); } return (*h.access_main)(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_2M : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_2M); } return (*h.access_main)(mat,i - 0,j - 1,PY_2M); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_2M); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2M); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_2M : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SPACER_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SPACER_2M); } return (*h.access_main)(mat,i - 0,j - 1,SPACER_2M); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_2M) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2M; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_2M); } return (*h.access_main)(mat,i - 0,j - 1,PY_2M); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_0I : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_0I); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0I); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,DELETE) ) { *reti = i - 0; *retj = j - 8; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,DELETE); } return (*h.access_main)(mat,i - 0,j - 8,DELETE); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,INSERT); } return (*h.access_main)(mat,i - 0,j - 8,INSERT); } temp = cscore - ((((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,MATCH); } return (*h.access_main)(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_0I : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_0I); } return (*h.access_main)(mat,i - 0,j - 1,PY_0I); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_0I); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_0I); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_0I : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SPACER_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SPACER_0I); } return (*h.access_main)(mat,i - 0,j - 1,SPACER_0I); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_0I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_0I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_0I); } return (*h.access_main)(mat,i - 0,j - 1,PY_0I); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_1I : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_1I); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1I); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,DELETE) ) { *reti = i - 0; *retj = j - 9; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,DELETE); } return (*h.access_main)(mat,i - 0,j - 9,DELETE); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,INSERT); } return (*h.access_main)(mat,i - 0,j - 9,INSERT); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,MATCH); } return (*h.access_main)(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_1I : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_1I); } return (*h.access_main)(mat,i - 0,j - 1,PY_1I); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_1I); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_1I); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_1I : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SPACER_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SPACER_1I); } return (*h.access_main)(mat,i - 0,j - 1,SPACER_1I); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_1I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_1I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_1I); } return (*h.access_main)(mat,i - 0,j - 1,PY_1I); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CENTRAL_2I : temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_2I); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2I); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT); } return (*h.access_main)(mat,i - 0,j - 10,INSERT); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT); } return (*h.access_main)(mat,i - 0,j - 10,INSERT); } temp = cscore - (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,MATCH); } return (*h.access_main)(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case PY_2I : temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_2I); } return (*h.access_main)(mat,i - 0,j - 1,PY_2I); } temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = CENTRAL_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CENTRAL_2I); } return (*h.access_main)(mat,i - 0,j - 1,CENTRAL_2I); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SPACER_2I : temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,SPACER_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = SPACER_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SPACER_2I); } return (*h.access_main)(mat,i - 0,j - 1,SPACER_2I); } temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,PY_2I) ) { *reti = i - 0; *retj = j - 1; *retstate = PY_2I; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,PY_2I); } return (*h.access_main)(mat,i - 0,j - 1,PY_2I); } warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_GeneLoop21(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GeneLoop21_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_GeneLoop21(GeneLoop21 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneLoop21_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GeneLoop21_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In GeneLoop21 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source GENOMIC_RND is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,GENOMIC_RND) ) { *reti = i - 0; *retj = j - 1; *retstate = GENOMIC_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,GENOMIC_RND); } return (*h.access_special)(mat,i - 0,j - 1,GENOMIC_RND) ; } case GENOMIC_RND : /* source RND_CODON is a special */ temp = cscore - ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,RND_CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,RND_CODON); } return (*h.access_special)(mat,i - 0,j - 1,RND_CODON) ; } /* source GENOMIC_RND is a special */ temp = cscore - ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,GENOMIC_RND) ) { *reti = i - 0; *retj = j - 1; *retstate = GENOMIC_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,GENOMIC_RND); } return (*h.access_special)(mat,i - 0,j - 1,GENOMIC_RND) ; } /* source START is a special */ temp = cscore - (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_special)(mat,i - 0,j - 1,START) ; } case RND_CODON : /* source RND_SPACER is a special */ temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,RND_SPACER) ) { *reti = i - 0; *retj = j - 3; *retstate = RND_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,RND_SPACER); } return (*h.access_special)(mat,i - 0,j - 3,RND_SPACER) ; } /* source RND_SPACER is a special */ temp = cscore - ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 4,RND_SPACER) ) { *reti = i - 0; *retj = j - 4; *retstate = RND_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-4,RND_SPACER); } return (*h.access_special)(mat,i - 0,j - 4,RND_SPACER) ; } /* source RND_SPACER is a special */ temp = cscore - (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 5,RND_SPACER) ) { *reti = i - 0; *retj = j - 5; *retstate = RND_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-5,RND_SPACER); } return (*h.access_special)(mat,i - 0,j - 5,RND_SPACER) ; } /* source RND_CODON is a special */ temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,RND_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = RND_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,RND_CODON); } return (*h.access_special)(mat,i - 0,j - 3,RND_CODON) ; } /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ /* source GENOMIC_RND is a special */ temp = cscore - ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,GENOMIC_RND) ) { *reti = i - 0; *retj = j - 3; *retstate = GENOMIC_RND; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,GENOMIC_RND); } return (*h.access_special)(mat,i - 0,j - 3,GENOMIC_RND) ; } case RND_CENTRAL : /* source RND_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 10,RND_CODON) ) { *reti = i - 0; *retj = j - 10; *retstate = RND_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-10,RND_CODON); } return (*h.access_special)(mat,i - 0,j - 10,RND_CODON) ; } /* source RND_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 9,RND_CODON) ) { *reti = i - 0; *retj = j - 9; *retstate = RND_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-9,RND_CODON); } return (*h.access_special)(mat,i - 0,j - 9,RND_CODON) ; } /* source RND_CODON is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 8,RND_CODON) ) { *reti = i - 0; *retj = j - 8; *retstate = RND_CODON; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-8,RND_CODON); } return (*h.access_special)(mat,i - 0,j - 8,RND_CODON) ; } /* source RND_CENTRAL is a special */ temp = cscore - ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,RND_CENTRAL) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_CENTRAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,RND_CENTRAL); } return (*h.access_special)(mat,i - 0,j - 1,RND_CENTRAL) ; } case RND_PY_TRACT : /* source RND_PY_TRACT is a special */ temp = cscore - (mat->gp21->transition[GP21_PY2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,RND_PY_TRACT) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_PY_TRACT; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,RND_PY_TRACT); } return (*h.access_special)(mat,i - 0,j - 1,RND_PY_TRACT) ; } /* source RND_CENTRAL is a special */ temp = cscore - (mat->gp21->transition[GP21_CENTRAL2PY]) - (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,RND_CENTRAL) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_CENTRAL; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,RND_CENTRAL); } return (*h.access_special)(mat,i - 0,j - 1,RND_CENTRAL) ; } case RND_SPACER : /* source RND_SPACER is a special */ temp = cscore - (mat->gp21->transition[GP21_SPACER2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,RND_SPACER) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_SPACER; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,RND_SPACER); } return (*h.access_special)(mat,i - 0,j - 1,RND_SPACER) ; } /* source RND_PY_TRACT is a special */ temp = cscore - (mat->gp21->transition[GP21_PY2SPACER]) - (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,RND_PY_TRACT) ) { *reti = i - 0; *retj = j - 1; *retstate = RND_PY_TRACT; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,RND_PY_TRACT); } return (*h.access_special)(mat,i - 0,j - 1,RND_PY_TRACT) ; } default: warn("Major problem (!) - in GeneLoop21 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_GeneLoop21(mat) * * Descrip: This function calculates the GeneLoop21 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneLoop21 * * * Arg: mat [UNKN ] GeneLoop21 which contains explicit basematrix memory [GeneLoop21 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_GeneLoop21(GeneLoop21 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneLoop21, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("GeneLoop21 Matrix calculation: "); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state RND_CODON to state MATCH */ temp = GeneLoop21_EXPL_SPECIAL(mat,i-1,j-3,RND_CODON) + ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp21->transition[GP21_RND2MODEL]); if( temp > score ) { score = temp; } /* From state SPACER_0M to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_0M to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1M to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_1M to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2M to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_2M to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0I to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1I to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2I to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_0I to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_1I to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_2I to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) = temp; } /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0M) = score; /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0M to state PY_0M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0M) = score; /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0M to state SPACER_0M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0M) = score; /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_1M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1M) = score; /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1M to state PY_1M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1M) = score; /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1M to state SPACER_1M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1M) = score; /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_2M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_2M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2M) = score; /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2M to state PY_2M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2M) = score; /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2M to state SPACER_2M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2M) = score; /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0I) = score; /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0I to state PY_0I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0I) = score; /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0I to state SPACER_0I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0I) = score; /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_1I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1I) = score; /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1I to state PY_1I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1I) = score; /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1I to state SPACER_1I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1I) = score; /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2I) = score; /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2I to state PY_2I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2I) = score; /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2I to state SPACER_2I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2I) = score; /* Finished calculating state SPACER_2I */ } /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_EXPL_SPECIAL(mat,0,j,END); /* Source GENOMIC_RND is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,GENOMIC_RND) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GeneLoop21_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state GENOMIC_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_EXPL_SPECIAL(mat,0,j,GENOMIC_RND); /* Source START is a special source for GENOMIC_RND */ /* Has restricted position */ if( (j-1) == 0 ) { temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,START) + (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) + (0); if( temp > score ) score = temp; } /* Source GENOMIC_RND is a special source for GENOMIC_RND */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,GENOMIC_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for GENOMIC_RND */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,RND_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_EXPL_SPECIAL(mat,0,j,GENOMIC_RND) = score; /* Finished updating state GENOMIC_RND */ /* Special state RND_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_CODON); /* Source GENOMIC_RND is a special source for RND_CODON */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 3,GENOMIC_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) score = temp; /* Source MATCH for state RND_CODON is not special... already calculated */ /* Source INSERT for state RND_CODON is not special... already calculated */ /* Source DELETE for state RND_CODON is not special... already calculated */ /* Source RND_CODON is a special source for RND_CODON */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 3,RND_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 5,RND_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 4,RND_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 3,RND_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_CODON) = score; /* Finished updating state RND_CODON */ /* Special state RND_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_CENTRAL); /* Source RND_CENTRAL is a special source for RND_CENTRAL */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,RND_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 8,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 9,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 10,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_CENTRAL) = score; /* Finished updating state RND_CENTRAL */ /* Special state RND_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_PY_TRACT); /* Source RND_CENTRAL is a special source for RND_PY_TRACT */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,RND_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source RND_PY_TRACT is a special source for RND_PY_TRACT */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,RND_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_PY_TRACT) = score; /* Finished updating state RND_PY_TRACT */ /* Special state RND_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_SPACER); /* Source RND_PY_TRACT is a special source for RND_SPACER */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,RND_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_SPACER */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,RND_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_SPACER) = score; /* Finished updating state RND_SPACER */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_GeneLoop21(mat,dpenv) * * Descrip: This function calculates the GeneLoop21 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneLoop21 which contains explicit basematrix memory [GeneLoop21 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_GeneLoop21(GeneLoop21 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GeneLoop21, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-10;jleni;i++) { GeneLoop21_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2I) = NEGI; } } for(j=-10;jlenj;j++) { GeneLoop21_EXPL_SPECIAL(mat,i,j,START) = 0; GeneLoop21_EXPL_SPECIAL(mat,i,j,END) = NEGI; GeneLoop21_EXPL_SPECIAL(mat,i,j,GENOMIC_RND) = NEGI; GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) = NEGI; GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CENTRAL) = NEGI; GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_PY_TRACT) = NEGI; GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_SPACER) = NEGI; } start_reporting("GeneLoop21 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { GeneLoop21_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2M) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2I) = NEGI; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2I) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state RND_CODON to state MATCH */ temp = GeneLoop21_EXPL_SPECIAL(mat,i-1,j-3,RND_CODON) + ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp21->transition[GP21_RND2MODEL]); if( temp > score ) { score = temp; } /* From state SPACER_0M to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-6,SPACER_0M) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_0M to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-6,PY_0M) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1M to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-5,SPACER_1M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_1M to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-5,PY_1M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2M to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-4,SPACER_2M) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_2M to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-4,PY_2M) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state SPACER_0I to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-6,SPACER_0I) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state SPACER_1I to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-5,SPACER_1I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state SPACER_2I to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-4,SPACER_2I) + (mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state PY_0I to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-6,PY_0I) + (((mat->gp21->transition[GP21_PY2CDS]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state PY_1I to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-5,PY_1I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state PY_2I to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-4,PY_2I) + (mat->gp21->transition[GP21_PY2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-2,INSERT) + mat->gp21->transition[GP21_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->gp21->transition[GP21_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-4,INSERT) + mat->gp21->transition[GP21_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-5,INSERT) + mat->gp21->transition[GP21_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GeneLoop21_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GeneLoop21_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special RND_CODON */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) ) { GeneLoop21_EXPL_SPECIAL(mat,i,j,RND_CODON) = temp; } /* Finished calculating state DELETE */ /* For state CENTRAL_0M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_0M to state CENTRAL_0M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0M */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0M) = score; /* Finished calculating state CENTRAL_0M */ /* For state PY_0M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0M to state PY_0M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0M) = score; /* Finished calculating state PY_0M */ /* For state SPACER_0M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_0M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0M to state SPACER_0M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,SPACER_0M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0M) = score; /* Finished calculating state SPACER_0M */ /* For state CENTRAL_1M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_1M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_1M to state CENTRAL_1M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1M */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1M) = score; /* Finished calculating state CENTRAL_1M */ /* For state PY_1M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1M to state PY_1M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1M) = score; /* Finished calculating state PY_1M */ /* For state SPACER_1M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_1M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1M to state SPACER_1M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,SPACER_1M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1M) = score; /* Finished calculating state SPACER_1M */ /* For state CENTRAL_2M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_2M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2MATCH])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_2M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-10,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2MATCH]); if( temp > score ) { score = temp; } /* From state CENTRAL_2M to state CENTRAL_2M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2M) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2M */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2M) = score; /* Finished calculating state CENTRAL_2M */ /* For state PY_2M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2M) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2M to state PY_2M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2M */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2M) = score; /* Finished calculating state PY_2M */ /* For state SPACER_2M */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_2M) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2M to state SPACER_2M */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,SPACER_2M) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2M */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2M) = score; /* Finished calculating state SPACER_2M */ /* For state CENTRAL_0I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-8,MATCH) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT])+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state CENTRAL_0I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-8,INSERT) + (((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT])+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_0I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-8,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_0I to state CENTRAL_0I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_0I */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_0I) = score; /* Finished calculating state CENTRAL_0I */ /* For state PY_0I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_0I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_0I to state PY_0I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_0I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_0I) = score; /* Finished calculating state PY_0I */ /* For state SPACER_0I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_0I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_0I to state SPACER_0I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,SPACER_0I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_0I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_0I) = score; /* Finished calculating state SPACER_0I */ /* For state CENTRAL_1I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_1I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state DELETE to state CENTRAL_1I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-9,DELETE) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_1I to state CENTRAL_1I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_1I */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_1I) = score; /* Finished calculating state CENTRAL_1I */ /* For state PY_1I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_1I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_1I to state PY_1I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_1I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_1I) = score; /* Finished calculating state PY_1I */ /* For state SPACER_1I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_1I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_1I to state SPACER_1I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,SPACER_1I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_1I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_1I) = score; /* Finished calculating state SPACER_1I */ /* For state CENTRAL_2I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH2INSERT]); /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT2INSERT]); if( temp > score ) { score = temp; } /* From state INSERT to state CENTRAL_2I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_DELETE2INSERT]); if( temp > score ) { score = temp; } /* From state CENTRAL_2I to state CENTRAL_2I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2I) + (mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CENTRAL_2I */ /* Add any movement independant score and put away */ GeneLoop21_EXPL_MATRIX(mat,i,j,CENTRAL_2I) = score; /* Finished calculating state CENTRAL_2I */ /* For state PY_2I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,CENTRAL_2I) + mat->gp21->transition[GP21_CENTRAL2PY]; /* From state PY_2I to state PY_2I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2PY]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for PY_2I */ /* Add any movement independant score and put away */ score += mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,PY_2I) = score; /* Finished calculating state PY_2I */ /* For state SPACER_2I */ /* setting first movement to score */ score = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,PY_2I) + mat->gp21->transition[GP21_PY2SPACER]; /* From state SPACER_2I to state SPACER_2I */ temp = GeneLoop21_EXPL_MATRIX(mat,i-0,j-1,SPACER_2I) + mat->gp21->transition[GP21_SPACER2SPACER]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SPACER_2I */ /* Add any movement independant score and put away */ score += mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]; GeneLoop21_EXPL_MATRIX(mat,i,j,SPACER_2I) = score; /* Finished calculating state SPACER_2I */ } /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_EXPL_SPECIAL(mat,0,j,END); /* Source GENOMIC_RND is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,GENOMIC_RND) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GeneLoop21_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state GENOMIC_RND has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_EXPL_SPECIAL(mat,0,j,GENOMIC_RND); /* Source START is a special source for GENOMIC_RND */ /* Has restricted position */ if( (j-1) == 0 ) { temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,START) + (mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]) + (0); if( temp > score ) score = temp; } /* Source GENOMIC_RND is a special source for GENOMIC_RND */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,GENOMIC_RND) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_RND2RND])) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for GENOMIC_RND */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,RND_CODON) + ((mat->rndbase->base[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CDS2RND])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_EXPL_SPECIAL(mat,0,j,GENOMIC_RND) = score; /* Finished updating state GENOMIC_RND */ /* Special state RND_CODON has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_CODON); /* Source GENOMIC_RND is a special source for RND_CODON */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 3,GENOMIC_RND) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_RND2CDS])) + (0); if( temp > score ) score = temp; /* Source MATCH for state RND_CODON is not special... already calculated */ /* Source INSERT for state RND_CODON is not special... already calculated */ /* Source DELETE for state RND_CODON is not special... already calculated */ /* Source RND_CODON is a special source for RND_CODON */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 3,RND_CODON) + ((mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)]+mat->gp21->transition[GP21_CDS2CDS])) + (0); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 5,RND_SPACER) + (((mat->gp21->transition[GP21_SPACER2CDS]+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) + (0); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 4,RND_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) + (0); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_CODON */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 3,RND_SPACER) + ((mat->gp21->transition[GP21_SPACER2CDS]+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_CODON) = score; /* Finished updating state RND_CODON */ /* Special state RND_CENTRAL has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_CENTRAL); /* Source RND_CENTRAL is a special source for RND_CENTRAL */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,RND_CENTRAL) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp21->transition[GP21_CENTRAL2CENTRAL])) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 8,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 9,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source RND_CODON is a special source for RND_CENTRAL */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 10,RND_CODON) + ((mat->gp21->central[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_CENTRAL) = score; /* Finished updating state RND_CENTRAL */ /* Special state RND_PY_TRACT has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_PY_TRACT); /* Source RND_CENTRAL is a special source for RND_PY_TRACT */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,RND_CENTRAL) + (mat->gp21->transition[GP21_CENTRAL2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source RND_PY_TRACT is a special source for RND_PY_TRACT */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,RND_PY_TRACT) + (mat->gp21->transition[GP21_PY2PY]) + (mat->gp21->py[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_PY_TRACT) = score; /* Finished updating state RND_PY_TRACT */ /* Special state RND_SPACER has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_SPACER); /* Source RND_PY_TRACT is a special source for RND_SPACER */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,RND_PY_TRACT) + (mat->gp21->transition[GP21_PY2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Source RND_SPACER is a special source for RND_SPACER */ temp = GeneLoop21_EXPL_SPECIAL(mat,0,j - 1,RND_SPACER) + (mat->gp21->transition[GP21_SPACER2SPACER]) + (mat->gp21->spacer[CSEQ_GENOMIC_BASE(mat->target,j)]); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GeneLoop21_EXPL_SPECIAL(mat,0,j,RND_SPACER) = score; /* Finished updating state RND_SPACER */ } stop_reporting(); return TRUE; } /* Function: GeneLoop21_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneLoop21 *] * */ GeneLoop21 * GeneLoop21_alloc(void) { GeneLoop21 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneLoop21 *) ckalloc (sizeof(GeneLoop21))) == NULL) { warn("GeneLoop21_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_GeneLoop21(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneLoop21 *] * * Return [UNKN ] Undocumented return value [GeneLoop21 *] * */ GeneLoop21 * free_GeneLoop21(GeneLoop21 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneLoop21 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->gp21 is linked in */ /* obj->rndcodon is linked in */ /* obj->rndbase is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/geneloop21.h0000644000175000001440000005002610670453714016261 0ustar philippusers#ifndef DYNAMITEgeneloop21HEADERFILE #define DYNAMITEgeneloop21HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "genewisemodel.h" #include "genewisemodeldb.h" struct Wise2_GeneLoop21 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GeneWiseScore* query; ComplexSequence* target; GeneParser21Score * gp21; RandomCodonScore * rndcodon; RandomModelDNAScore * rndbase; } ; /* GeneLoop21 defined */ #ifndef DYNAMITE_DEFINED_GeneLoop21 typedef struct Wise2_GeneLoop21 Wise2_GeneLoop21; #define GeneLoop21 Wise2_GeneLoop21 #define DYNAMITE_DEFINED_GeneLoop21 #endif #ifdef PTHREAD struct thread_pool_holder_GeneLoop21 { GeneWiseScore* query; /* Query object placeholder */ GeneWiseDB* querydb;/* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ GenomicDB* targetdb;/* Target database object */ boolean target_init; GeneParser21Score * gp21; RandomCodonScore * rndcodon; RandomModelDNAScore * rndbase; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_GeneLoop21_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(GeneLoop21*,int,int,int); int (*access_special)(GeneLoop21*,int,int,int); } ; /* GeneLoop21_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_GeneLoop21_access_func_holder typedef struct Wise2_GeneLoop21_access_func_holder Wise2_GeneLoop21_access_func_holder; #define GeneLoop21_access_func_holder Wise2_GeneLoop21_access_func_holder #define DYNAMITE_DEFINED_GeneLoop21_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_GeneLoop21(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_GeneLoop21(GeneLoop21 * mat); #define PackAln_read_Shatter_GeneLoop21 Wise2_PackAln_read_Shatter_GeneLoop21 /* Function: calculate_shatter_GeneLoop21(mat,dpenv) * * Descrip: This function calculates the GeneLoop21 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GeneLoop21 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_GeneLoop21(GeneLoop21 * mat,DPEnvelope * dpenv); #define calculate_shatter_GeneLoop21 Wise2_calculate_shatter_GeneLoop21 /* Function: search_GeneLoop21(dbsi,out,querydb,targetdb,gp21,rndcodon,rndbase) * * Descrip: This function makes a database search of GeneLoop21 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp21 [UNKN ] Undocumented argument [GeneParser21Score *] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: rndbase [UNKN ] Undocumented argument [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_GeneLoop21(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase); #define search_GeneLoop21 Wise2_search_GeneLoop21 /* Function: serial_search_GeneLoop21(out,querydb,targetdb,gp21,rndcodon,rndbase) * * Descrip: This function makes a database search of GeneLoop21 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp21 [UNKN ] Undocumented argument [GeneParser21Score *] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: rndbase [UNKN ] Undocumented argument [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_GeneLoop21(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase); #define serial_search_GeneLoop21 Wise2_serial_search_GeneLoop21 /* Function: PackAln_bestmemory_GeneLoop21(query,target,gp21,rndcodon,rndbase,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GeneLoop21 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_GeneLoop21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_GeneLoop21 Wise2_PackAln_bestmemory_GeneLoop21 /* Function: allocate_Expl_GeneLoop21(query,target,gp21,rndcodon,rndbase,dpri) * * Descrip: This function allocates the GeneLoop21 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GeneLoop21_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GeneLoop21 *] * */ GeneLoop21 * Wise2_allocate_Expl_GeneLoop21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase,DPRunImpl * dpri); #define allocate_Expl_GeneLoop21 Wise2_allocate_Expl_GeneLoop21 /* Function: recalculate_PackAln_GeneLoop21(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GeneLoop21 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * */ void Wise2_recalculate_PackAln_GeneLoop21(PackAln * pal,GeneLoop21 * mat); #define recalculate_PackAln_GeneLoop21 Wise2_recalculate_PackAln_GeneLoop21 /* Function: allocate_Small_GeneLoop21(query,target,gp21,rndcodon,rndbase) * * Descrip: This function allocates the GeneLoop21 structure * and the basematrix area for a small memory implementations * It calls /allocate_GeneLoop21_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp21 [UNKN ] Resource [GeneParser21Score *] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: rndbase [UNKN ] Resource [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [GeneLoop21 *] * */ GeneLoop21 * Wise2_allocate_Small_GeneLoop21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase); #define allocate_Small_GeneLoop21 Wise2_allocate_Small_GeneLoop21 /* Function: PackAln_calculate_Small_GeneLoop21(mat,dpenv) * * Descrip: This function calculates an alignment for GeneLoop21 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GeneLoop21 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GeneLoop21 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_GeneLoop21(GeneLoop21 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_GeneLoop21 Wise2_PackAln_calculate_Small_GeneLoop21 /* Function: AlnRangeSet_calculate_Small_GeneLoop21(mat) * * Descrip: This function calculates an alignment for GeneLoop21 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GeneLoop21 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GeneLoop21 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GeneLoop21 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_GeneLoop21(GeneLoop21 * mat); #define AlnRangeSet_calculate_Small_GeneLoop21 Wise2_AlnRangeSet_calculate_Small_GeneLoop21 /* Function: AlnRangeSet_from_GeneLoop21(mat) * * Descrip: This function reads off a start/end structure * for GeneLoop21 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GeneLoop21 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GeneLoop21 * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_GeneLoop21(GeneLoop21 * mat); #define AlnRangeSet_from_GeneLoop21 Wise2_AlnRangeSet_from_GeneLoop21 /* Function: convert_PackAln_to_AlnBlock_GeneLoop21(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_GeneLoop21(PackAln * pal); #define convert_PackAln_to_AlnBlock_GeneLoop21 Wise2_convert_PackAln_to_AlnBlock_GeneLoop21 /* Function: PackAln_read_Expl_GeneLoop21(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_GeneLoop21(GeneLoop21 * mat); #define PackAln_read_Expl_GeneLoop21 Wise2_PackAln_read_Expl_GeneLoop21 /* Function: PackAln_read_generic_GeneLoop21(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GeneLoop21 *] * Arg: h [UNKN ] Undocumented argument [GeneLoop21_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_GeneLoop21(GeneLoop21 * mat,GeneLoop21_access_func_holder h); #define PackAln_read_generic_GeneLoop21 Wise2_PackAln_read_generic_GeneLoop21 /* Function: calculate_GeneLoop21(mat) * * Descrip: This function calculates the GeneLoop21 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GeneLoop21 * * * Arg: mat [UNKN ] GeneLoop21 which contains explicit basematrix memory [GeneLoop21 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_GeneLoop21(GeneLoop21 * mat); #define calculate_GeneLoop21 Wise2_calculate_GeneLoop21 /* Function: calculate_dpenv_GeneLoop21(mat,dpenv) * * Descrip: This function calculates the GeneLoop21 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GeneLoop21 which contains explicit basematrix memory [GeneLoop21 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_GeneLoop21(GeneLoop21 * mat,DPEnvelope * dpenv); #define calculate_dpenv_GeneLoop21 Wise2_calculate_dpenv_GeneLoop21 /* Function: GeneLoop21_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneLoop21 *] * */ GeneLoop21 * Wise2_GeneLoop21_alloc(void); #define GeneLoop21_alloc Wise2_GeneLoop21_alloc /* Function: free_GeneLoop21(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneLoop21 *] * * Return [UNKN ] Undocumented return value [GeneLoop21 *] * */ GeneLoop21 * Wise2_free_GeneLoop21(GeneLoop21 * obj); #define free_GeneLoop21 Wise2_free_GeneLoop21 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_GeneLoop21_shatter_access_main(GeneLoop21 * mat,int i,int j,int state); #define GeneLoop21_shatter_access_main Wise2_GeneLoop21_shatter_access_main int Wise2_GeneLoop21_shatter_access_special(GeneLoop21 * mat,int i,int j,int state); #define GeneLoop21_shatter_access_special Wise2_GeneLoop21_shatter_access_special void * Wise2_thread_loop_GeneLoop21(void * ptr); #define thread_loop_GeneLoop21 Wise2_thread_loop_GeneLoop21 int Wise2_score_only_GeneLoop21(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase); #define score_only_GeneLoop21 Wise2_score_only_GeneLoop21 GeneLoop21 * Wise2_allocate_GeneLoop21_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser21Score * gp21,RandomCodonScore * rndcodon,RandomModelDNAScore * rndbase); #define allocate_GeneLoop21_only Wise2_allocate_GeneLoop21_only void Wise2_init_GeneLoop21(GeneLoop21 * mat); #define init_GeneLoop21 Wise2_init_GeneLoop21 AlnRange * Wise2_AlnRange_build_GeneLoop21(GeneLoop21 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_GeneLoop21 Wise2_AlnRange_build_GeneLoop21 boolean Wise2_read_hidden_GeneLoop21(GeneLoop21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_GeneLoop21 Wise2_read_hidden_GeneLoop21 int Wise2_max_hidden_GeneLoop21(GeneLoop21 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_GeneLoop21 Wise2_max_hidden_GeneLoop21 boolean Wise2_read_special_strip_GeneLoop21(GeneLoop21 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_GeneLoop21 Wise2_read_special_strip_GeneLoop21 int Wise2_max_special_strip_GeneLoop21(GeneLoop21 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_GeneLoop21 Wise2_max_special_strip_GeneLoop21 int Wise2_max_matrix_to_special_GeneLoop21(GeneLoop21 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_GeneLoop21 Wise2_max_matrix_to_special_GeneLoop21 void Wise2_calculate_hidden_GeneLoop21(GeneLoop21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_GeneLoop21 Wise2_calculate_hidden_GeneLoop21 void Wise2_init_hidden_GeneLoop21(GeneLoop21 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_GeneLoop21 Wise2_init_hidden_GeneLoop21 boolean Wise2_full_dc_GeneLoop21(GeneLoop21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_GeneLoop21 Wise2_full_dc_GeneLoop21 boolean Wise2_do_dc_single_pass_GeneLoop21(GeneLoop21 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_GeneLoop21 Wise2_do_dc_single_pass_GeneLoop21 void Wise2_push_dc_at_merge_GeneLoop21(GeneLoop21 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_GeneLoop21 Wise2_push_dc_at_merge_GeneLoop21 void Wise2_follow_on_dc_GeneLoop21(GeneLoop21 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_GeneLoop21 Wise2_follow_on_dc_GeneLoop21 void Wise2_run_up_dc_GeneLoop21(GeneLoop21 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_GeneLoop21 Wise2_run_up_dc_GeneLoop21 void Wise2_init_dc_GeneLoop21(GeneLoop21 * mat); #define init_dc_GeneLoop21 Wise2_init_dc_GeneLoop21 int Wise2_start_end_find_end_GeneLoop21(GeneLoop21 * mat,int * endj); #define start_end_find_end_GeneLoop21 Wise2_start_end_find_end_GeneLoop21 boolean Wise2_dc_optimised_start_end_calc_GeneLoop21(GeneLoop21 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_GeneLoop21 Wise2_dc_optimised_start_end_calc_GeneLoop21 void Wise2_init_start_end_linear_GeneLoop21(GeneLoop21 * mat); #define init_start_end_linear_GeneLoop21 Wise2_init_start_end_linear_GeneLoop21 AlnConvertSet * Wise2_AlnConvertSet_GeneLoop21(void); #define AlnConvertSet_GeneLoop21 Wise2_AlnConvertSet_GeneLoop21 int Wise2_GeneLoop21_explicit_access_main(GeneLoop21 * mat,int i,int j,int state); #define GeneLoop21_explicit_access_main Wise2_GeneLoop21_explicit_access_main int Wise2_GeneLoop21_explicit_access_special(GeneLoop21 * mat,int i,int j,int state); #define GeneLoop21_explicit_access_special Wise2_GeneLoop21_explicit_access_special int Wise2_find_end_GeneLoop21(GeneLoop21 * mat,int * ri,int * rj,int * state,boolean * isspecial,GeneLoop21_access_func_holder h); #define find_end_GeneLoop21 Wise2_find_end_GeneLoop21 void Wise2_GeneLoop21_debug_show_matrix(GeneLoop21 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define GeneLoop21_debug_show_matrix Wise2_GeneLoop21_debug_show_matrix int Wise2_max_calc_GeneLoop21(GeneLoop21 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneLoop21_access_func_holder h); #define max_calc_GeneLoop21 Wise2_max_calc_GeneLoop21 int Wise2_max_calc_special_GeneLoop21(GeneLoop21 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GeneLoop21_access_func_holder h); #define max_calc_special_GeneLoop21 Wise2_max_calc_special_GeneLoop21 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/geneloop6.dy0000644000175000001440000001512207644256136016375 0ustar philippusers/* Last edited: Mar 11 16:47 1997 (birney) */ %{ #include "dyna.h" #include "geneparser4.h" #include "genewisemodel.h" #include "genewisemodeldb.h" %} matrix GeneLoop6 query type="GENEWISEMODEL" name="query" field:len="len" target type="GENOMIC" name="target" resource type="GeneParser4Score *" name="gp" extern name="GW_*" type="int" extern name="GP4_*" type="int" globaldefaultscore NEGI state MATCH offi="1" offj="3" calc="GENOMIC_CDS_POT(target,j)" source MATCH calc="query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source LOOP calc="query->seg[i]->transition[GW_START2MATCH] + query->seg[i]->match[GENOMIC_CODON(target,j)] + gp->transition[GP4_LOOP2MODEL]" endsource # # phase 0,1,2 introns can calculate whole amino acid for 0. # source INTRON_0 offi="1" offj="6" calc="gp->transition[GP4_INTRON2CDS] + query->seg[i]->match[GENOMIC_CODON(target,j)]+GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source INTRON_1 offi="1" offj="5" calc="gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source INTRON_2 offi="1" offj="4" calc="gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource # # Sequencing error transitions, at offsets 1,2,4,5 for delete 1,2 or insert 1,2 # source MATCH offi="1" offj="2" calc="gp->transition[GP4_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="1" calc="gp->transition[GP4_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="4" calc="gp->transition[GP4_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source MATCH offi="1" offj="5" calc="gp->transition[GP4_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource query_label MATCH_STATE target_label CODON endstate # # Insert state: does not move along model, produces DNA sequence... # state INSERT offi="0" offj="3" calc="GENOMIC_CDS_POT(target,j)" source MATCH calc="query->seg[i]->transition[GW_MATCH2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source LOOP calc="query->seg[i]->transition[GW_START2INSERT] + query->seg[i]->insert[GENOMIC_CODON(target,j)] + gp->transition[GP4_LOOP2MODEL]" endsource # # phase 0,1,2 introns can calculate whole amino acid for 0. # source INTRON_0 offi="0" offj="6" calc="gp->transition[GP4_INTRON2CDS] + query->seg[i]->match[GENOMIC_CODON(target,j)]+GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source INTRON_1 offi="0" offj="5" calc="gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source INTRON_2 offi="0" offj="4" calc="gp->transition[GP4_INTRON2CDS] + GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource # # Sequencing error transitions: because insertions are "for free" usually, we will # only model sequence deletion here. Could produce odd results though! # source INSERT offi="0" offj="2" calc="gp->transition[GP4_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="1" calc="gp->transition[GP4_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="query->seg[i]->transition[GW_MATCH2DELETE]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2DELETE]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2DELETE]" endsource query_label DELETE_STATE target_label INSERT endstate # # Intron state: 3 separate phases, and merge INSERT/MATCH information # state INTRON_0 offi="0" offj="1" source MATCH offj="8" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_0 endsource source INSERT offj="8" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_0 endsource source INTRON_0 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state INTRON_1 offi="0" offj="1" source MATCH offj="9" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_1 endsource source INSERT offj="9" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_1 endsource source INTRON_1 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state INTRON_2 offi="0" offj="1" source MATCH offj="10" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_2 endsource source INSERT offj="10" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_2 endsource source INTRON_2 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state LOOP !special source START offj="1" !left calc="0" endsource source MATCH calc="query->seg[i]->transition[GW_MATCH2END]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2END]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2END]" endsource source LOOP offj="1" calc="gp->transition[GP4_LOOP2LOOP]" endsource query_label LOOP_STATE target_label RANDOM_SEQUENCE endstate state START !start !special defscore="0" endstate state END !end !special source LOOP offj="1" !right calc="0" endsource target_label END query_label END endstate # # collapse Intron labels! # collapse INTRON_STATE CENTRAL_INTRON collapse LOOP_STATE RANDOM_SEQUENCE endmatrix %{ #include "geneloop6.h" %} wise-2.4.1/src/models/mutatedna.c0000644000175000001440000000167407460747406016277 0ustar philippusers#include "dyna.h" int main(int argc,char ** argv) { Sequence * dna = NULL; RandomModelDNA * rmd; char * seq; Sequence * out; double subs = 0.01; double indel = 0.002; int i,j; strip_out_float_argument(&argc,argv,"subs",&subs); strip_out_float_argument(&argc,argv,"indel",&indel); dna = read_fasta_file_Sequence(argv[1]); if( dna == NULL ) { fatal("Must have DNA sequnece as first argument"); } seq = calloc(sizeof(char),dna->len*2); rmd = RandomModelDNA_std(); for(i=0,j=0;ilen;i++) { if( random_0_to_1() < subs ) { info("Randomising %d\n",i); seq[j++] = draw_random_base_RandomModelDNA(rmd); } else { seq[j++] = dna->seq[i]; } if( random_0_to_1() < indel ) { info("inserting at %d\n",i); seq[j++] = draw_random_base_RandomModelDNA(rmd); } } seq[j]='\0'; out = new_Sequence_from_strings(dna->name,seq); write_fasta_Sequence(out,stdout); } wise-2.4.1/src/models/motifmatrixdp.dy0000644000175000001440000000477410011714154017356 0ustar philippusers %{ #include "motifmatrix.h" #define MOTIF_MATRIX_IN(motif,i,j,score) (motif->mat[i][j] == 0 ? 0 : (score)) %} matrix LocalMotifMatrix query type="DNA" name="query" target type="DNA" name="target" resource type="MotifConsMatrix*" name="motif" resource type="MotifMatrixScore*" name="ms" state SPACER_MATCH source SPACER_MATCH offi="1" offj="1" calc="ms->comp_spacer->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + ms->spacer_duration" endsource source SPACER_MATCH offi="1" offj="0" calc="ms->spacer_indel" query_label SPACER_INSERT endsource source SPACER_MATCH offi="0" offj="1" calc="ms->spacer_indel" target_label SPACER_INSERT endsource source MOTIF_MATCH offi="1" offj="1" calc="ms->comp_spacer->score[DNA_BASE(query,i)][DNA_BASE(target,j)]" endsource source CONS_MATCH offi="1" offj="1" calc="ms->comp_spacer->score[DNA_BASE(query,i)][DNA_BASE(target,j)]" endsource source START offi="1" offj="1" calc="ms->comp_spacer->score[DNA_BASE(query,i)][DNA_BASE(target,j)]" endsource query_label SPACER_MATCH target_label SPACER_MATCH endstate state MOTIF_MATCH source MOTIF_MATCH offi="1" offj="1" calc="MOTIF_MATRIX_IN(motif,i,j,ms->comp_in_motif->score[DNA_BASE(query,i)][DNA_BASE(target,j)]) + ms->motif_duration" endsource source MOTIF_MATCH offi="1" offj="0" calc="ms->motif_indel" query_label MOTIF_INSERT endsource source MOTIF_MATCH offi="0" offj="1" calc="ms->motif_indel" target_label MOTIF_INSERT endsource source SPACER_MATCH offi="1" offj="1" calc="MOTIF_MATRIX_IN(motif,i,j,ms->comp_in_motif->score[DNA_BASE(query,i)][DNA_BASE(target,j)]) + ms->spacer_to_motif" endsource query_label MOTIF_MATCH target_label MOTIF_MATCH endstate state CONS_MATCH source CONS_MATCH offi="1" offj="1" calc="ms->comp_out_motif->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + ms->cons_duration" endsource source CONS_MATCH offi="1" offj="0" calc="ms->cons_indel" query_label CONS_INSERT endsource source CONS_MATCH offi="0" offj="1" calc="ms->cons_indel" target_label CONS_INSERT endsource source SPACER_MATCH offi="1" offj="1" calc="ms->comp_out_motif->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + ms->spacer_to_cons" endsource query_label CONS_MATCH target_label CONS_MATCH endstate state START !special !start endstate state END !special !end source SPACER_MATCH calc="0" endsource query_label END target_label END endstate endmatrix %{ #include "motifmatrixdp.h" %}wise-2.4.1/src/models/makerandomdb.c0000644000175000001440000000066107434501776016733 0ustar philippusers#include "randomdb.h" #include "wisebase.h" int main(int argc,char ** argv) { int i; RandomDNADB * db; RandomModelDNA * rndmodel; int len = 1000; Sequence * seq; int num = 2000; strip_out_integer_argument(&argc,argv,"l",&len); rndmodel = RandomModelDNA_std(); db = new_flat_RandomDNADB(rndmodel,len); for(i=0;i 2 || phase < 0 ) { warn("Got phase of %d, when must be between 0 and 2",phase); continue; } in = ProteinIntron_alloc(); pos--; in->position = pos; in->phase = phase; add_ProteinIntronList(out,in); } return out; } # line 98 "phasemodel.dy" ProteinIntronList * read_ProteinIntronList_from_filename(char * f) { ProteinIntronList * pl; FILE * ifp; ifp = openfile(f,"r"); if( ifp == NULL ) { warn("Cannot open file %s",f); return NULL; } pl = read_ProteinIntronList(ifp); fclose(ifp); return pl; } # line 117 "phasemodel.dy" PhasedProteinPara * new_PhasedProteinPara_from_argv(int * argc,char ** argv) { PhasedProteinPara * out; char * temp; out = PhasedProteinPara_alloc(); out->marked_intron = 0.95; out->unmarked_intron = 0.00001; out->use_phase = 0; strip_out_float_argument(argc,argv,"phase_marked",&out->marked_intron); strip_out_float_argument(argc,argv,"phase_unmarked",&out->unmarked_intron); /* strip_out_boolean_def_argument(argc,argv,"phase_model",&out->use_phase); */ if( (temp = strip_out_assigned_argument(argc,argv,"phase_file")) != NULL ) { out->intron_file = stringalloc(temp); } if( strip_out_boolean_argument(argc,argv,"phase_help") == TRUE ) { fprintf(stdout,"Phased marks provide the ability to restrict the position of introns\n"); fprintf(stdout,"relative to the protein sequence; ie, assuming conserved introns. This\n"); fprintf(stdout,"is most useful for fast evolving genes inside of relatively consistent\n"); fprintf(stdout,"clades, eg for fast evolving genes, such as cytokines, in vertebrates\n"); fprintf(stdout,"As moving between clades - say between Human and Drosophila - the intron\n"); fprintf(stdout,"positions change, using these options would actively hinder good gene prediction\n"); fprintf(stdout,"\n"); fprintf(stdout,"This option can be used for either HMMs or proteins, although it is harder\n"); fprintf(stdout,"to coordinate the HMM intron position than the protein positions.\n"); fprintf(stdout,"Two things need to occur to use the phase information\n"); fprintf(stdout," provide a phase mark file as -phase_file \n"); fprintf(stdout," use the algorithm type 623P (6 states, 23 transitions, phased introns)\n"); fprintf(stdout,"\n"); fprintf(stdout,"The phase model attempts to make a ATG to STOP gene, even if the protein match\n"); fprintf(stdout,"is not present across the entire gene. One major headache in this are introns in first\n"); fprintf(stdout,"ATG, which is not handled at the moment\n\n"); fprintf(stdout,"Genewise uses the protein position, in 1 coordinates, (first amino acid is 1)\n"); fprintf(stdout,"for the definition of the intron. For phase 0 introns, it should be labeled as\n"); fprintf(stdout,"the amino acid before the intron. For phase 1 and 2 introns, this is on the intron\n\n"); fprintf(stdout,"We suggest using a small spread of positions to cope with intron positioning errors\n"); fprintf(stdout," eg, defining an intron at position 4, phase 0, make postions 3,4 and 5 with position 0\n\n"); fprintf(stdout,"The phase file format is\n"); fprintf(stdout,"# lines starting with hash are comments\n"); fprintf(stdout,"# three tab delimited columns\n"); fprintf(stdout,"# \n"); fprintf(stdout,"# eg\n"); fprintf(stdout,"4 0\n"); exit(0); } return out; } # line 170 "phasemodel.dy" void show_help_PhasedProteinPara(FILE * ofp) { fprintf(ofp,"Phased Protein/HMM parameters (separate from other options)\n"); fprintf(ofp," -phase_marked [0.95] Probability of marked introns\n"); fprintf(ofp," -phase_unmarked [0.00001] Probability of unmarked introns\n"); fprintf(ofp," -phase_file [filename] Intron positions and phases\n"); fprintf(ofp," -phase_help prints longer help on phase file and exits\n"); } # line 180 "phasemodel.dy" void write_fasta_PhasedProtein(PhasedProtein * pp,FILE * ofp) { int i; int j; int line; assert(pp != NULL); write_fasta_Sequence(pp->protein,ofp); fprintf(ofp,">%s\n",pp->protein->name); for(i=0,j=0,line = 0;iprotein->len;i++) { if( line != 0 && line % 50 == 0 ) { fputc('\n',ofp); } fputc(pp->protein->seq[i],ofp); line++; if( j < pp->list->len && pp->list->intron[j]->position == i ) { fputc('0'+pp->list->intron[j]->phase,ofp); line++; j++; } } } # line 212 "phasemodel.dy" PhasedProtein * read_fasta_PhasedProtein_file(char * file) { PhasedProtein * pp; FILE * ifp; ifp = openfile(file,"r"); pp = read_fasta_PhasedProtein(ifp); fclose(ifp); return pp; } # line 227 "phasemodel.dy" PhasedProtein * read_fasta_PhasedProtein(FILE * ifp) { PhasedProtein * pp; ProteinIntron * intron; Sequence * input; int i; int j; char seqbuffer[10000]; char name[2000]; char c; pp = PhasedProtein_alloc(); pp->list = ProteinIntronList_alloc_std(); fgets(name,10000,ifp); assert(name[0] == '>'); for(i=1; !isspace(name[i]);i++) { ; } name[i] = '\0'; i = 0; while( (c = fgetc(ifp)) != EOF ) { if( c == '>' ) { ungetc('>',ifp); break; } if( isalpha(c) ) { seqbuffer[i++] = c; } else if( c == '0' || c == '1' || c == '2' ) { intron = ProteinIntron_alloc(); intron->position = i-1; intron->phase = c - '0'; add_ProteinIntronList(pp->list,intron); } } seqbuffer[i] = '\0'; pp->protein = Sequence_from_static_memory(name+1,seqbuffer); return pp; } # line 275 "phasemodel.dy" GenePhaseModel * GenePhaseModel_from_ThreeStateModel(ThreeStateModel * tsm,CodonMapper * cm,RandomModel * rm,CompMat * mat,PhasedProteinPara * ppp) { GenePhaseModel * out; ProteinIntronList * pl; int i; int j; assert(ppp != NULL); assert(tsm != NULL); assert(rm != NULL); assert(mat != NULL); pl = read_ProteinIntronList_from_filename(ppp->intron_file); assert(pl != NULL); out = GenePhaseModel_alloc_std(); /* current set this at global */ for(i=0;ilen;i++) { tsm->unit[i]->transition[TSM_START2MATCH] = 0.0; tsm->unit[i]->transition[TSM_MATCH2END] = 0.0; } tsm->unit[0]->transition[TSM_START2MATCH] = 1.0; tsm->unit[tsm->len-1]->transition[TSM_MATCH2END] = 1.0; out->gw = GeneWise_from_ThreeStateModel_setfactor(tsm,0.95,cm,0.1); for(i=0,j=0;ilen;i++) { /* set to default first */ add_GenePhaseModel(out,GenePhaseSeg_alloc()); out->phase[i]->intron_0 = ppp->unmarked_intron; out->phase[i]->intron_1 = ppp->unmarked_intron; out->phase[i]->intron_2 = ppp->unmarked_intron; out->phase[i]->insert_intron = ppp->unmarked_intron; if( j < pl->len && i == pl->intron[j]->position ) { if( pl->intron[j]->phase == 0 ) { out->phase[i]->intron_0 = ppp->marked_intron; } if( pl->intron[j]->phase == 1 ) { out->phase[i]->intron_1 = ppp->marked_intron; } if( pl->intron[j]->phase == 2 ) { out->phase[i]->intron_2 = ppp->marked_intron; } out->gw->seg[i]->transition[GW_MATCH2MATCH] = (1.0 - ppp->marked_intron)*out->gw->seg[i]->transition[GW_MATCH2MATCH]; out->gw->seg[i]->transition[GW_MATCH2INSERT] = (1.0 - ppp->marked_intron)*out->gw->seg[i]->transition[GW_MATCH2INSERT]; out->gw->seg[i]->transition[GW_MATCH2DELETE] = (1.0 - ppp->marked_intron)*out->gw->seg[i]->transition[GW_MATCH2DELETE]; out->gw->seg[i]->transition[GW_DELETE2DELETE] = (1.0 - ppp->marked_intron)*out->gw->seg[i]->transition[GW_DELETE2DELETE]; out->gw->seg[i]->transition[GW_DELETE2MATCH] = (1.0 - ppp->marked_intron)*out->gw->seg[i]->transition[GW_DELETE2MATCH]; j++; } } return out; } # line 345 "phasemodel.dy" GenePhaseScore * GenePhaseScore_from_GenePhaseModel(GenePhaseModel * gpm) { int i; GenePhaseScore * out; assert(gpm != NULL); assert(gpm->gw != NULL); assert(gpm->gw->len == gpm->len); out = GenePhaseScore_alloc_len(gpm->len); out->gws = GeneWiseScore_from_GeneWise(gpm->gw); for(i=0;ilen;i++) { add_GenePhaseScore(out,GenePhaseSegScore_alloc()); out->phase[i]->intron_0 = Probability2Score(gpm->phase[i]->intron_0); out->phase[i]->intron_1 = Probability2Score(gpm->phase[i]->intron_1); out->phase[i]->intron_2 = Probability2Score(gpm->phase[i]->intron_2); } return out; } # line 325 "phasemodel.c" /* Function: hard_link_ProteinIntron(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ProteinIntron *] * * Return [UNKN ] Undocumented return value [ProteinIntron *] * */ ProteinIntron * hard_link_ProteinIntron(ProteinIntron * obj) { if( obj == NULL ) { warn("Trying to hard link to a ProteinIntron object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ProteinIntron_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ProteinIntron *] * */ ProteinIntron * ProteinIntron_alloc(void) { ProteinIntron * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ProteinIntron *) ckalloc (sizeof(ProteinIntron))) == NULL) { warn("ProteinIntron_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->position = 0; out->phase = 0; return out; } /* Function: free_ProteinIntron(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ProteinIntron *] * * Return [UNKN ] Undocumented return value [ProteinIntron *] * */ ProteinIntron * free_ProteinIntron(ProteinIntron * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ProteinIntron obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_ProteinIntronList(list,i,j) * * Descrip: swap function: an internal for qsort_ProteinIntronList * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ProteinIntron **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ProteinIntronList(ProteinIntron ** list,int i,int j) { ProteinIntron * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ProteinIntronList(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ProteinIntronList which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ProteinIntron **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ProteinIntronList(ProteinIntron ** list,int left,int right,int (*comp)(ProteinIntron * ,ProteinIntron * )) { int i,last; if( left >= right ) return; swap_ProteinIntronList(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ProteinIntronList (list,++last,i); } swap_ProteinIntronList (list,left,last); qsort_ProteinIntronList(list,left,last-1,comp); qsort_ProteinIntronList(list,last+1,right,comp); } /* Function: sort_ProteinIntronList(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ProteinIntronList * * * Arg: obj [UNKN ] Object containing list [ProteinIntronList *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ProteinIntronList(ProteinIntronList * obj,int (*comp)(ProteinIntron *, ProteinIntron *)) { qsort_ProteinIntronList(obj->intron,0,obj->len-1,comp); return; } /* Function: expand_ProteinIntronList(obj,len) * * Descrip: Really an internal function for add_ProteinIntronList * * * Arg: obj [UNKN ] Object which contains the list [ProteinIntronList *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ProteinIntronList(ProteinIntronList * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_ProteinIntronList called with no need"); return TRUE; } if( (obj->intron = (ProteinIntron ** ) ckrealloc (obj->intron,sizeof(ProteinIntron *)*len)) == NULL) { warn("ckrealloc failed for expand_ProteinIntronList, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_ProteinIntronList(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ProteinIntronList *] * Arg: add [OWNER] Object to add to the list [ProteinIntron *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ProteinIntronList(ProteinIntronList * obj,ProteinIntron * add) { if( obj->len >= obj->maxlen) { if( expand_ProteinIntronList(obj,obj->len + ProteinIntronListLISTLENGTH) == FALSE) return FALSE; } obj->intron[obj->len++]=add; return TRUE; } /* Function: flush_ProteinIntronList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ProteinIntronList *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ProteinIntronList(ProteinIntronList * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->intron[i] != NULL) { free_ProteinIntron(obj->intron[i]); obj->intron[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: ProteinIntronList_alloc_std(void) * * Descrip: Equivalent to ProteinIntronList_alloc_len(ProteinIntronListLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ProteinIntronList *] * */ ProteinIntronList * ProteinIntronList_alloc_std(void) { return ProteinIntronList_alloc_len(ProteinIntronListLISTLENGTH); } /* Function: ProteinIntronList_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ProteinIntronList *] * */ ProteinIntronList * ProteinIntronList_alloc_len(int len) { ProteinIntronList * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = ProteinIntronList_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->intron = (ProteinIntron ** ) ckcalloc (len,sizeof(ProteinIntron *))) == NULL) { warn("Warning, ckcalloc failed in ProteinIntronList_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_ProteinIntronList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ProteinIntronList *] * * Return [UNKN ] Undocumented return value [ProteinIntronList *] * */ ProteinIntronList * hard_link_ProteinIntronList(ProteinIntronList * obj) { if( obj == NULL ) { warn("Trying to hard link to a ProteinIntronList object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ProteinIntronList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ProteinIntronList *] * */ ProteinIntronList * ProteinIntronList_alloc(void) { ProteinIntronList * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ProteinIntronList *) ckalloc (sizeof(ProteinIntronList))) == NULL) { warn("ProteinIntronList_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->intron = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_ProteinIntronList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ProteinIntronList *] * * Return [UNKN ] Undocumented return value [ProteinIntronList *] * */ ProteinIntronList * free_ProteinIntronList(ProteinIntronList * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ProteinIntronList obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->intron != NULL) { for(i=0;ilen;i++) { if( obj->intron[i] != NULL) free_ProteinIntron(obj->intron[i]); } ckfree(obj->intron); } ckfree(obj); return NULL; } /* Function: hard_link_PhasedProtein(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PhasedProtein *] * * Return [UNKN ] Undocumented return value [PhasedProtein *] * */ PhasedProtein * hard_link_PhasedProtein(PhasedProtein * obj) { if( obj == NULL ) { warn("Trying to hard link to a PhasedProtein object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PhasedProtein_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PhasedProtein *] * */ PhasedProtein * PhasedProtein_alloc(void) { PhasedProtein * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PhasedProtein *) ckalloc (sizeof(PhasedProtein))) == NULL) { warn("PhasedProtein_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->protein = NULL; out->list = NULL; return out; } /* Function: free_PhasedProtein(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PhasedProtein *] * * Return [UNKN ] Undocumented return value [PhasedProtein *] * */ PhasedProtein * free_PhasedProtein(PhasedProtein * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PhasedProtein obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->protein != NULL) free_Sequence(obj->protein); if( obj->list != NULL) free_ProteinIntronList(obj->list); ckfree(obj); return NULL; } /* Function: hard_link_PhasedProteinPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PhasedProteinPara *] * * Return [UNKN ] Undocumented return value [PhasedProteinPara *] * */ PhasedProteinPara * hard_link_PhasedProteinPara(PhasedProteinPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a PhasedProteinPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PhasedProteinPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PhasedProteinPara *] * */ PhasedProteinPara * PhasedProteinPara_alloc(void) { PhasedProteinPara * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PhasedProteinPara *) ckalloc (sizeof(PhasedProteinPara))) == NULL) { warn("PhasedProteinPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->marked_intron = 0.95; out->unmarked_intron = 0.000001; out->gap = -12; out->ext = -2; out->use_phase = FALSE; out->intron_file = NULL; return out; } /* Function: free_PhasedProteinPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PhasedProteinPara *] * * Return [UNKN ] Undocumented return value [PhasedProteinPara *] * */ PhasedProteinPara * free_PhasedProteinPara(PhasedProteinPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PhasedProteinPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->intron_file != NULL) ckfree(obj->intron_file); ckfree(obj); return NULL; } /* Function: hard_link_PhasedHMM(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PhasedHMM *] * * Return [UNKN ] Undocumented return value [PhasedHMM *] * */ PhasedHMM * hard_link_PhasedHMM(PhasedHMM * obj) { if( obj == NULL ) { warn("Trying to hard link to a PhasedHMM object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PhasedHMM_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PhasedHMM *] * */ PhasedHMM * PhasedHMM_alloc(void) { PhasedHMM * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PhasedHMM *) ckalloc (sizeof(PhasedHMM))) == NULL) { warn("PhasedHMM_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->tsm = NULL; out->list = NULL; return out; } /* Function: free_PhasedHMM(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PhasedHMM *] * * Return [UNKN ] Undocumented return value [PhasedHMM *] * */ PhasedHMM * free_PhasedHMM(PhasedHMM * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PhasedHMM obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->tsm != NULL) free_ThreeStateModel(obj->tsm); if( obj->list != NULL) free_ProteinIntronList(obj->list); ckfree(obj); return NULL; } /* Function: hard_link_GenePhaseSeg(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenePhaseSeg *] * * Return [UNKN ] Undocumented return value [GenePhaseSeg *] * */ GenePhaseSeg * hard_link_GenePhaseSeg(GenePhaseSeg * obj) { if( obj == NULL ) { warn("Trying to hard link to a GenePhaseSeg object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GenePhaseSeg_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenePhaseSeg *] * */ GenePhaseSeg * GenePhaseSeg_alloc(void) { GenePhaseSeg * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenePhaseSeg *) ckalloc (sizeof(GenePhaseSeg))) == NULL) { warn("GenePhaseSeg_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->intron_0 = 0.0; out->intron_1 = 0.0; out->intron_2 = 0.0; out->insert_intron = 0.0; return out; } /* Function: free_GenePhaseSeg(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenePhaseSeg *] * * Return [UNKN ] Undocumented return value [GenePhaseSeg *] * */ GenePhaseSeg * free_GenePhaseSeg(GenePhaseSeg * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GenePhaseSeg obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_GenePhaseModel(list,i,j) * * Descrip: swap function: an internal for qsort_GenePhaseModel * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [GenePhaseSeg **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_GenePhaseModel(GenePhaseSeg ** list,int i,int j) { GenePhaseSeg * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_GenePhaseModel(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_GenePhaseModel which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [GenePhaseSeg **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_GenePhaseModel(GenePhaseSeg ** list,int left,int right,int (*comp)(GenePhaseSeg * ,GenePhaseSeg * )) { int i,last; if( left >= right ) return; swap_GenePhaseModel(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_GenePhaseModel (list,++last,i); } swap_GenePhaseModel (list,left,last); qsort_GenePhaseModel(list,left,last-1,comp); qsort_GenePhaseModel(list,last+1,right,comp); } /* Function: sort_GenePhaseModel(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_GenePhaseModel * * * Arg: obj [UNKN ] Object containing list [GenePhaseModel *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_GenePhaseModel(GenePhaseModel * obj,int (*comp)(GenePhaseSeg *, GenePhaseSeg *)) { qsort_GenePhaseModel(obj->phase,0,obj->len-1,comp); return; } /* Function: expand_GenePhaseModel(obj,len) * * Descrip: Really an internal function for add_GenePhaseModel * * * Arg: obj [UNKN ] Object which contains the list [GenePhaseModel *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_GenePhaseModel(GenePhaseModel * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_GenePhaseModel called with no need"); return TRUE; } if( (obj->phase = (GenePhaseSeg ** ) ckrealloc (obj->phase,sizeof(GenePhaseSeg *)*len)) == NULL) { warn("ckrealloc failed for expand_GenePhaseModel, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_GenePhaseModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenePhaseModel *] * Arg: add [OWNER] Object to add to the list [GenePhaseSeg *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_GenePhaseModel(GenePhaseModel * obj,GenePhaseSeg * add) { if( obj->len >= obj->maxlen) { if( expand_GenePhaseModel(obj,obj->len + GenePhaseModelLISTLENGTH) == FALSE) return FALSE; } obj->phase[obj->len++]=add; return TRUE; } /* Function: flush_GenePhaseModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenePhaseModel *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GenePhaseModel(GenePhaseModel * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->phase[i] != NULL) { free_GenePhaseSeg(obj->phase[i]); obj->phase[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: GenePhaseModel_alloc_std(void) * * Descrip: Equivalent to GenePhaseModel_alloc_len(GenePhaseModelLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GenePhaseModel *] * */ GenePhaseModel * GenePhaseModel_alloc_std(void) { return GenePhaseModel_alloc_len(GenePhaseModelLISTLENGTH); } /* Function: GenePhaseModel_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GenePhaseModel *] * */ GenePhaseModel * GenePhaseModel_alloc_len(int len) { GenePhaseModel * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = GenePhaseModel_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->phase = (GenePhaseSeg ** ) ckcalloc (len,sizeof(GenePhaseSeg *))) == NULL) { warn("Warning, ckcalloc failed in GenePhaseModel_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_GenePhaseModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenePhaseModel *] * * Return [UNKN ] Undocumented return value [GenePhaseModel *] * */ GenePhaseModel * hard_link_GenePhaseModel(GenePhaseModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a GenePhaseModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GenePhaseModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenePhaseModel *] * */ GenePhaseModel * GenePhaseModel_alloc(void) { GenePhaseModel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenePhaseModel *) ckalloc (sizeof(GenePhaseModel))) == NULL) { warn("GenePhaseModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->phase = NULL; out->len = out->maxlen = 0; out->gw = NULL; return out; } /* Function: free_GenePhaseModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenePhaseModel *] * * Return [UNKN ] Undocumented return value [GenePhaseModel *] * */ GenePhaseModel * free_GenePhaseModel(GenePhaseModel * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GenePhaseModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->phase != NULL) { for(i=0;ilen;i++) { if( obj->phase[i] != NULL) free_GenePhaseSeg(obj->phase[i]); } ckfree(obj->phase); } if( obj->gw != NULL) free_GeneWise(obj->gw); ckfree(obj); return NULL; } /* Function: hard_link_GenePhaseSegScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenePhaseSegScore *] * * Return [UNKN ] Undocumented return value [GenePhaseSegScore *] * */ GenePhaseSegScore * hard_link_GenePhaseSegScore(GenePhaseSegScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a GenePhaseSegScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GenePhaseSegScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenePhaseSegScore *] * */ GenePhaseSegScore * GenePhaseSegScore_alloc(void) { GenePhaseSegScore * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenePhaseSegScore *) ckalloc (sizeof(GenePhaseSegScore))) == NULL) { warn("GenePhaseSegScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->intron_0 = 0; out->intron_1 = 0; out->intron_2 = 0; out->insert_intron = 0; return out; } /* Function: free_GenePhaseSegScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenePhaseSegScore *] * * Return [UNKN ] Undocumented return value [GenePhaseSegScore *] * */ GenePhaseSegScore * free_GenePhaseSegScore(GenePhaseSegScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GenePhaseSegScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_GenePhaseScore(list,i,j) * * Descrip: swap function: an internal for qsort_GenePhaseScore * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [GenePhaseSegScore **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_GenePhaseScore(GenePhaseSegScore ** list,int i,int j) { GenePhaseSegScore * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_GenePhaseScore(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_GenePhaseScore which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [GenePhaseSegScore **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_GenePhaseScore(GenePhaseSegScore ** list,int left,int right,int (*comp)(GenePhaseSegScore * ,GenePhaseSegScore * )) { int i,last; if( left >= right ) return; swap_GenePhaseScore(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_GenePhaseScore (list,++last,i); } swap_GenePhaseScore (list,left,last); qsort_GenePhaseScore(list,left,last-1,comp); qsort_GenePhaseScore(list,last+1,right,comp); } /* Function: sort_GenePhaseScore(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_GenePhaseScore * * * Arg: obj [UNKN ] Object containing list [GenePhaseScore *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_GenePhaseScore(GenePhaseScore * obj,int (*comp)(GenePhaseSegScore *, GenePhaseSegScore *)) { qsort_GenePhaseScore(obj->phase,0,obj->len-1,comp); return; } /* Function: expand_GenePhaseScore(obj,len) * * Descrip: Really an internal function for add_GenePhaseScore * * * Arg: obj [UNKN ] Object which contains the list [GenePhaseScore *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_GenePhaseScore(GenePhaseScore * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_GenePhaseScore called with no need"); return TRUE; } if( (obj->phase = (GenePhaseSegScore ** ) ckrealloc (obj->phase,sizeof(GenePhaseSegScore *)*len)) == NULL) { warn("ckrealloc failed for expand_GenePhaseScore, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_GenePhaseScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenePhaseScore *] * Arg: add [OWNER] Object to add to the list [GenePhaseSegScore *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_GenePhaseScore(GenePhaseScore * obj,GenePhaseSegScore * add) { if( obj->len >= obj->maxlen) { if( expand_GenePhaseScore(obj,obj->len + GenePhaseScoreLISTLENGTH) == FALSE) return FALSE; } obj->phase[obj->len++]=add; return TRUE; } /* Function: flush_GenePhaseScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenePhaseScore *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GenePhaseScore(GenePhaseScore * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->phase[i] != NULL) { free_GenePhaseSegScore(obj->phase[i]); obj->phase[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: GenePhaseScore_alloc_std(void) * * Descrip: Equivalent to GenePhaseScore_alloc_len(GenePhaseScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GenePhaseScore *] * */ GenePhaseScore * GenePhaseScore_alloc_std(void) { return GenePhaseScore_alloc_len(GenePhaseScoreLISTLENGTH); } /* Function: GenePhaseScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GenePhaseScore *] * */ GenePhaseScore * GenePhaseScore_alloc_len(int len) { GenePhaseScore * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = GenePhaseScore_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->phase = (GenePhaseSegScore ** ) ckcalloc (len,sizeof(GenePhaseSegScore *))) == NULL) { warn("Warning, ckcalloc failed in GenePhaseScore_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_GenePhaseScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenePhaseScore *] * * Return [UNKN ] Undocumented return value [GenePhaseScore *] * */ GenePhaseScore * hard_link_GenePhaseScore(GenePhaseScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a GenePhaseScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GenePhaseScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenePhaseScore *] * */ GenePhaseScore * GenePhaseScore_alloc(void) { GenePhaseScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenePhaseScore *) ckalloc (sizeof(GenePhaseScore))) == NULL) { warn("GenePhaseScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->phase = NULL; out->len = out->maxlen = 0; out->gws = NULL; return out; } /* Function: free_GenePhaseScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenePhaseScore *] * * Return [UNKN ] Undocumented return value [GenePhaseScore *] * */ GenePhaseScore * free_GenePhaseScore(GenePhaseScore * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GenePhaseScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->phase != NULL) { for(i=0;ilen;i++) { if( obj->phase[i] != NULL) free_GenePhaseSegScore(obj->phase[i]); } ckfree(obj->phase); } if( obj->gws != NULL) free_GeneWiseScore(obj->gws); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/phasemodel.h0000644000175000001440000005665410670453714016444 0ustar philippusers#ifndef DYNAMITEphasemodelHEADERFILE #define DYNAMITEphasemodelHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "genewisemodel.h" #define GenePhaseModelLISTLENGTH 128 #define GenePhaseScoreLISTLENGTH 128 #define ProteinIntronListLISTLENGTH 30 struct Wise2_ProteinIntron { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int position; int phase; } ; /* ProteinIntron defined */ #ifndef DYNAMITE_DEFINED_ProteinIntron typedef struct Wise2_ProteinIntron Wise2_ProteinIntron; #define ProteinIntron Wise2_ProteinIntron #define DYNAMITE_DEFINED_ProteinIntron #endif struct Wise2_ProteinIntronList { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ProteinIntron ** intron; int len;/* len for above intron */ int maxlen; /* maxlen for above intron */ } ; /* ProteinIntronList defined */ #ifndef DYNAMITE_DEFINED_ProteinIntronList typedef struct Wise2_ProteinIntronList Wise2_ProteinIntronList; #define ProteinIntronList Wise2_ProteinIntronList #define DYNAMITE_DEFINED_ProteinIntronList #endif struct Wise2_PhasedProtein { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence * protein; ProteinIntronList * list; } ; /* PhasedProtein defined */ #ifndef DYNAMITE_DEFINED_PhasedProtein typedef struct Wise2_PhasedProtein Wise2_PhasedProtein; #define PhasedProtein Wise2_PhasedProtein #define DYNAMITE_DEFINED_PhasedProtein #endif struct Wise2_PhasedProteinPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability marked_intron; Probability unmarked_intron; int gap; int ext; boolean use_phase; char * intron_file; } ; /* PhasedProteinPara defined */ #ifndef DYNAMITE_DEFINED_PhasedProteinPara typedef struct Wise2_PhasedProteinPara Wise2_PhasedProteinPara; #define PhasedProteinPara Wise2_PhasedProteinPara #define DYNAMITE_DEFINED_PhasedProteinPara #endif struct Wise2_PhasedHMM { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ThreeStateModel * tsm; ProteinIntronList * list; } ; /* PhasedHMM defined */ #ifndef DYNAMITE_DEFINED_PhasedHMM typedef struct Wise2_PhasedHMM Wise2_PhasedHMM; #define PhasedHMM Wise2_PhasedHMM #define DYNAMITE_DEFINED_PhasedHMM #endif struct Wise2_GenePhaseSeg { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability intron_0; Probability intron_1; Probability intron_2; Probability insert_intron; } ; /* GenePhaseSeg defined */ #ifndef DYNAMITE_DEFINED_GenePhaseSeg typedef struct Wise2_GenePhaseSeg Wise2_GenePhaseSeg; #define GenePhaseSeg Wise2_GenePhaseSeg #define DYNAMITE_DEFINED_GenePhaseSeg #endif struct Wise2_GenePhaseModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GenePhaseSeg ** phase; int len;/* len for above phase */ int maxlen; /* maxlen for above phase */ GeneWise * gw; } ; /* GenePhaseModel defined */ #ifndef DYNAMITE_DEFINED_GenePhaseModel typedef struct Wise2_GenePhaseModel Wise2_GenePhaseModel; #define GenePhaseModel Wise2_GenePhaseModel #define DYNAMITE_DEFINED_GenePhaseModel #endif struct Wise2_GenePhaseSegScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score intron_0; Score intron_1; Score intron_2; Score insert_intron; } ; /* GenePhaseSegScore defined */ #ifndef DYNAMITE_DEFINED_GenePhaseSegScore typedef struct Wise2_GenePhaseSegScore Wise2_GenePhaseSegScore; #define GenePhaseSegScore Wise2_GenePhaseSegScore #define DYNAMITE_DEFINED_GenePhaseSegScore #endif struct Wise2_GenePhaseScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GenePhaseSegScore ** phase; int len;/* len for above phase */ int maxlen; /* maxlen for above phase */ GeneWiseScore * gws; } ; /* GenePhaseScore defined */ #ifndef DYNAMITE_DEFINED_GenePhaseScore typedef struct Wise2_GenePhaseScore Wise2_GenePhaseScore; #define GenePhaseScore Wise2_GenePhaseScore #define DYNAMITE_DEFINED_GenePhaseScore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_ProteinIntron(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ProteinIntron *] * * Return [UNKN ] Undocumented return value [ProteinIntron *] * */ ProteinIntron * Wise2_hard_link_ProteinIntron(ProteinIntron * obj); #define hard_link_ProteinIntron Wise2_hard_link_ProteinIntron /* Function: ProteinIntron_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ProteinIntron *] * */ ProteinIntron * Wise2_ProteinIntron_alloc(void); #define ProteinIntron_alloc Wise2_ProteinIntron_alloc /* Function: free_ProteinIntron(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ProteinIntron *] * * Return [UNKN ] Undocumented return value [ProteinIntron *] * */ ProteinIntron * Wise2_free_ProteinIntron(ProteinIntron * obj); #define free_ProteinIntron Wise2_free_ProteinIntron /* Function: add_ProteinIntronList(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ProteinIntronList *] * Arg: add [OWNER] Object to add to the list [ProteinIntron *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_ProteinIntronList(ProteinIntronList * obj,ProteinIntron * add); #define add_ProteinIntronList Wise2_add_ProteinIntronList /* Function: flush_ProteinIntronList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ProteinIntronList *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_ProteinIntronList(ProteinIntronList * obj); #define flush_ProteinIntronList Wise2_flush_ProteinIntronList /* Function: ProteinIntronList_alloc_std(void) * * Descrip: Equivalent to ProteinIntronList_alloc_len(ProteinIntronListLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ProteinIntronList *] * */ ProteinIntronList * Wise2_ProteinIntronList_alloc_std(void); #define ProteinIntronList_alloc_std Wise2_ProteinIntronList_alloc_std /* Function: ProteinIntronList_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ProteinIntronList *] * */ ProteinIntronList * Wise2_ProteinIntronList_alloc_len(int len); #define ProteinIntronList_alloc_len Wise2_ProteinIntronList_alloc_len /* Function: hard_link_ProteinIntronList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ProteinIntronList *] * * Return [UNKN ] Undocumented return value [ProteinIntronList *] * */ ProteinIntronList * Wise2_hard_link_ProteinIntronList(ProteinIntronList * obj); #define hard_link_ProteinIntronList Wise2_hard_link_ProteinIntronList /* Function: ProteinIntronList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ProteinIntronList *] * */ ProteinIntronList * Wise2_ProteinIntronList_alloc(void); #define ProteinIntronList_alloc Wise2_ProteinIntronList_alloc /* Function: free_ProteinIntronList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ProteinIntronList *] * * Return [UNKN ] Undocumented return value [ProteinIntronList *] * */ ProteinIntronList * Wise2_free_ProteinIntronList(ProteinIntronList * obj); #define free_ProteinIntronList Wise2_free_ProteinIntronList /* Function: hard_link_PhasedProtein(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PhasedProtein *] * * Return [UNKN ] Undocumented return value [PhasedProtein *] * */ PhasedProtein * Wise2_hard_link_PhasedProtein(PhasedProtein * obj); #define hard_link_PhasedProtein Wise2_hard_link_PhasedProtein /* Function: PhasedProtein_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PhasedProtein *] * */ PhasedProtein * Wise2_PhasedProtein_alloc(void); #define PhasedProtein_alloc Wise2_PhasedProtein_alloc /* Function: free_PhasedProtein(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PhasedProtein *] * * Return [UNKN ] Undocumented return value [PhasedProtein *] * */ PhasedProtein * Wise2_free_PhasedProtein(PhasedProtein * obj); #define free_PhasedProtein Wise2_free_PhasedProtein /* Function: hard_link_PhasedProteinPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PhasedProteinPara *] * * Return [UNKN ] Undocumented return value [PhasedProteinPara *] * */ PhasedProteinPara * Wise2_hard_link_PhasedProteinPara(PhasedProteinPara * obj); #define hard_link_PhasedProteinPara Wise2_hard_link_PhasedProteinPara /* Function: PhasedProteinPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PhasedProteinPara *] * */ PhasedProteinPara * Wise2_PhasedProteinPara_alloc(void); #define PhasedProteinPara_alloc Wise2_PhasedProteinPara_alloc /* Function: free_PhasedProteinPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PhasedProteinPara *] * * Return [UNKN ] Undocumented return value [PhasedProteinPara *] * */ PhasedProteinPara * Wise2_free_PhasedProteinPara(PhasedProteinPara * obj); #define free_PhasedProteinPara Wise2_free_PhasedProteinPara /* Function: hard_link_PhasedHMM(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PhasedHMM *] * * Return [UNKN ] Undocumented return value [PhasedHMM *] * */ PhasedHMM * Wise2_hard_link_PhasedHMM(PhasedHMM * obj); #define hard_link_PhasedHMM Wise2_hard_link_PhasedHMM /* Function: PhasedHMM_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PhasedHMM *] * */ PhasedHMM * Wise2_PhasedHMM_alloc(void); #define PhasedHMM_alloc Wise2_PhasedHMM_alloc /* Function: free_PhasedHMM(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PhasedHMM *] * * Return [UNKN ] Undocumented return value [PhasedHMM *] * */ PhasedHMM * Wise2_free_PhasedHMM(PhasedHMM * obj); #define free_PhasedHMM Wise2_free_PhasedHMM /* Function: hard_link_GenePhaseSeg(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenePhaseSeg *] * * Return [UNKN ] Undocumented return value [GenePhaseSeg *] * */ GenePhaseSeg * Wise2_hard_link_GenePhaseSeg(GenePhaseSeg * obj); #define hard_link_GenePhaseSeg Wise2_hard_link_GenePhaseSeg /* Function: GenePhaseSeg_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenePhaseSeg *] * */ GenePhaseSeg * Wise2_GenePhaseSeg_alloc(void); #define GenePhaseSeg_alloc Wise2_GenePhaseSeg_alloc /* Function: free_GenePhaseSeg(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenePhaseSeg *] * * Return [UNKN ] Undocumented return value [GenePhaseSeg *] * */ GenePhaseSeg * Wise2_free_GenePhaseSeg(GenePhaseSeg * obj); #define free_GenePhaseSeg Wise2_free_GenePhaseSeg /* Function: add_GenePhaseModel(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenePhaseModel *] * Arg: add [OWNER] Object to add to the list [GenePhaseSeg *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_GenePhaseModel(GenePhaseModel * obj,GenePhaseSeg * add); #define add_GenePhaseModel Wise2_add_GenePhaseModel /* Function: flush_GenePhaseModel(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenePhaseModel *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_GenePhaseModel(GenePhaseModel * obj); #define flush_GenePhaseModel Wise2_flush_GenePhaseModel /* Function: GenePhaseModel_alloc_std(void) * * Descrip: Equivalent to GenePhaseModel_alloc_len(GenePhaseModelLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GenePhaseModel *] * */ GenePhaseModel * Wise2_GenePhaseModel_alloc_std(void); #define GenePhaseModel_alloc_std Wise2_GenePhaseModel_alloc_std /* Function: GenePhaseModel_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GenePhaseModel *] * */ GenePhaseModel * Wise2_GenePhaseModel_alloc_len(int len); #define GenePhaseModel_alloc_len Wise2_GenePhaseModel_alloc_len /* Function: hard_link_GenePhaseModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenePhaseModel *] * * Return [UNKN ] Undocumented return value [GenePhaseModel *] * */ GenePhaseModel * Wise2_hard_link_GenePhaseModel(GenePhaseModel * obj); #define hard_link_GenePhaseModel Wise2_hard_link_GenePhaseModel /* Function: GenePhaseModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenePhaseModel *] * */ GenePhaseModel * Wise2_GenePhaseModel_alloc(void); #define GenePhaseModel_alloc Wise2_GenePhaseModel_alloc /* Function: free_GenePhaseModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenePhaseModel *] * * Return [UNKN ] Undocumented return value [GenePhaseModel *] * */ GenePhaseModel * Wise2_free_GenePhaseModel(GenePhaseModel * obj); #define free_GenePhaseModel Wise2_free_GenePhaseModel /* Function: hard_link_GenePhaseSegScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenePhaseSegScore *] * * Return [UNKN ] Undocumented return value [GenePhaseSegScore *] * */ GenePhaseSegScore * Wise2_hard_link_GenePhaseSegScore(GenePhaseSegScore * obj); #define hard_link_GenePhaseSegScore Wise2_hard_link_GenePhaseSegScore /* Function: GenePhaseSegScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenePhaseSegScore *] * */ GenePhaseSegScore * Wise2_GenePhaseSegScore_alloc(void); #define GenePhaseSegScore_alloc Wise2_GenePhaseSegScore_alloc /* Function: free_GenePhaseSegScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenePhaseSegScore *] * * Return [UNKN ] Undocumented return value [GenePhaseSegScore *] * */ GenePhaseSegScore * Wise2_free_GenePhaseSegScore(GenePhaseSegScore * obj); #define free_GenePhaseSegScore Wise2_free_GenePhaseSegScore /* Function: add_GenePhaseScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenePhaseScore *] * Arg: add [OWNER] Object to add to the list [GenePhaseSegScore *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_GenePhaseScore(GenePhaseScore * obj,GenePhaseSegScore * add); #define add_GenePhaseScore Wise2_add_GenePhaseScore /* Function: flush_GenePhaseScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenePhaseScore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_GenePhaseScore(GenePhaseScore * obj); #define flush_GenePhaseScore Wise2_flush_GenePhaseScore /* Function: GenePhaseScore_alloc_std(void) * * Descrip: Equivalent to GenePhaseScore_alloc_len(GenePhaseScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GenePhaseScore *] * */ GenePhaseScore * Wise2_GenePhaseScore_alloc_std(void); #define GenePhaseScore_alloc_std Wise2_GenePhaseScore_alloc_std /* Function: GenePhaseScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GenePhaseScore *] * */ GenePhaseScore * Wise2_GenePhaseScore_alloc_len(int len); #define GenePhaseScore_alloc_len Wise2_GenePhaseScore_alloc_len /* Function: hard_link_GenePhaseScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenePhaseScore *] * * Return [UNKN ] Undocumented return value [GenePhaseScore *] * */ GenePhaseScore * Wise2_hard_link_GenePhaseScore(GenePhaseScore * obj); #define hard_link_GenePhaseScore Wise2_hard_link_GenePhaseScore /* Function: GenePhaseScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenePhaseScore *] * */ GenePhaseScore * Wise2_GenePhaseScore_alloc(void); #define GenePhaseScore_alloc Wise2_GenePhaseScore_alloc /* Function: free_GenePhaseScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenePhaseScore *] * * Return [UNKN ] Undocumented return value [GenePhaseScore *] * */ GenePhaseScore * Wise2_free_GenePhaseScore(GenePhaseScore * obj); #define free_GenePhaseScore Wise2_free_GenePhaseScore /* Unplaced functions */ /* There has been no indication of the use of these functions */ ProteinIntronList * Wise2_read_ProteinIntronList(FILE * ifp); #define read_ProteinIntronList Wise2_read_ProteinIntronList ProteinIntronList * Wise2_read_ProteinIntronList_from_filename(char * f); #define read_ProteinIntronList_from_filename Wise2_read_ProteinIntronList_from_filename PhasedProteinPara * Wise2_new_PhasedProteinPara_from_argv(int * argc,char ** argv); #define new_PhasedProteinPara_from_argv Wise2_new_PhasedProteinPara_from_argv void Wise2_show_help_PhasedProteinPara(FILE * ofp); #define show_help_PhasedProteinPara Wise2_show_help_PhasedProteinPara void Wise2_write_fasta_PhasedProtein(PhasedProtein * pp,FILE * ofp); #define write_fasta_PhasedProtein Wise2_write_fasta_PhasedProtein PhasedProtein * Wise2_read_fasta_PhasedProtein_file(char * file); #define read_fasta_PhasedProtein_file Wise2_read_fasta_PhasedProtein_file PhasedProtein * Wise2_read_fasta_PhasedProtein(FILE * ifp); #define read_fasta_PhasedProtein Wise2_read_fasta_PhasedProtein GenePhaseModel * Wise2_GenePhaseModel_from_ThreeStateModel(ThreeStateModel * tsm,CodonMapper * cm,RandomModel * rm,CompMat * mat,PhasedProteinPara * ppp); #define GenePhaseModel_from_ThreeStateModel Wise2_GenePhaseModel_from_ThreeStateModel GenePhaseScore * Wise2_GenePhaseScore_from_GenePhaseModel(GenePhaseModel * gpm); #define GenePhaseScore_from_GenePhaseModel Wise2_GenePhaseScore_from_GenePhaseModel /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_ProteinIntronList(ProteinIntron ** list,int i,int j) ; #define swap_ProteinIntronList Wise2_swap_ProteinIntronList void Wise2_qsort_ProteinIntronList(ProteinIntron ** list,int left,int right,int (*comp)(ProteinIntron * ,ProteinIntron * )); #define qsort_ProteinIntronList Wise2_qsort_ProteinIntronList void Wise2_sort_ProteinIntronList(ProteinIntronList * obj,int (*comp)(ProteinIntron *, ProteinIntron *)); #define sort_ProteinIntronList Wise2_sort_ProteinIntronList boolean Wise2_expand_ProteinIntronList(ProteinIntronList * obj,int len); #define expand_ProteinIntronList Wise2_expand_ProteinIntronList void Wise2_swap_GenePhaseModel(GenePhaseSeg ** list,int i,int j) ; #define swap_GenePhaseModel Wise2_swap_GenePhaseModel void Wise2_qsort_GenePhaseModel(GenePhaseSeg ** list,int left,int right,int (*comp)(GenePhaseSeg * ,GenePhaseSeg * )); #define qsort_GenePhaseModel Wise2_qsort_GenePhaseModel void Wise2_sort_GenePhaseModel(GenePhaseModel * obj,int (*comp)(GenePhaseSeg *, GenePhaseSeg *)); #define sort_GenePhaseModel Wise2_sort_GenePhaseModel boolean Wise2_expand_GenePhaseModel(GenePhaseModel * obj,int len); #define expand_GenePhaseModel Wise2_expand_GenePhaseModel void Wise2_swap_GenePhaseScore(GenePhaseSegScore ** list,int i,int j) ; #define swap_GenePhaseScore Wise2_swap_GenePhaseScore void Wise2_qsort_GenePhaseScore(GenePhaseSegScore ** list,int left,int right,int (*comp)(GenePhaseSegScore * ,GenePhaseSegScore * )); #define qsort_GenePhaseScore Wise2_qsort_GenePhaseScore void Wise2_sort_GenePhaseScore(GenePhaseScore * obj,int (*comp)(GenePhaseSegScore *, GenePhaseSegScore *)); #define sort_GenePhaseScore Wise2_sort_GenePhaseScore boolean Wise2_expand_GenePhaseScore(GenePhaseScore * obj,int len); #define expand_GenePhaseScore Wise2_expand_GenePhaseScore #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/seqhit.typemap0000644000175000001440000000145210670453715017033 0ustar philippusers TYPEMAP Wise2_DnaSequenceHitList * T_Wise2_DnaSequenceHitList INPUT T_Wise2_DnaSequenceHitList $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_DnaSequenceHitList *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_DnaSequenceHitList sv_setref_pv($arg, "Wise2::DnaSequenceHitList", (void*) $var); TYPEMAP Wise2_SegmentHitList * T_Wise2_SegmentHitList INPUT T_Wise2_SegmentHitList $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_SegmentHitList *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_SegmentHitList sv_setref_pv($arg, "Wise2::SegmentHitList", (void*) $var); TYPEMAP Wise2_SegmentHit * T_Wise2_SegmentHit INPUT T_Wise2_SegmentHit $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_SegmentHit *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_SegmentHit sv_setref_pv($arg, "Wise2::SegmentHit", (void*) $var); wise-2.4.1/src/models/sywise.c0000644000175000001440000002337007502704706015626 0ustar philippusers#include "sywise20.h" #include "version.h" #include "genestats.h" #include "geneutil.h" #include "standardout.h" char * program_name = "sywise"; char * codon_table = "codon.table"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s pairwise-alignment-as-fasta\n",program_name); show_help_GeneModelParam(ofp); show_help_ShowGenomicRegionOptions(ofp); show_help_DPRunImpl(ofp); show_help_StandardOutputOptions(ofp); show_standard_options(ofp); } PairBaseModelScore * make_PairBaseModelScore(void) { PairBaseModelScore * out; PairBaseModel * m; m = simple_PairBaseModel(0.6,0.4,0.9); out= new_PairBaseModelScore(m); free_PairBaseModel(m); /* out = zero_PairBaseModelScore(); */ show_PairBaseModelScore(out,stdout); return out; } CodonTable * ct; PairBaseCodonModelScore * make_PairBaseCodonModelScore(CompProb * cp) { PairBaseCodonModelScore * out; PairBaseCodonModel * m; FILE * ifp; if( ct == NULL ) { fatal("Could not read codon table"); } assert(cp); /* m = very_simple_PairBaseCodonModel(0.8,1.0/20.0,0.2,0.2,ct); */ m = make_flat_PairBaseCodonModel(cp,0.1,0.01,ct); diagonal_tweak_PairBaseCodonModel(m,2.0,16.0,1.0/4.0); out = new_PairBaseCodonModelScore(m); /* flatten_diagonal_PairBaseCodonModelScore(out,ct); */ free_PairBaseCodonModel(m); /* show_PairBaseCodonModelScore(out,ct,stdout); */ return out; } void show_score_sequence(AlnBlock * alb,PairBaseSeq * pbs,PairBaseModelScore * m,FILE * ofp) { AlnColumn * alc; char seq1[20]; char seq2[20]; int match_score = 0; for(alc=alb->start;alc != NULL; alc=alc->next) { if( strcmp(alc->alu[1]->text_label,"CODON") == 0 ) { seq1[0] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start+1])); seq1[1] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start+2])); seq1[2] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start+3])); seq2[0] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start+1])); seq2[1] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start+2])); seq2[2] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start+3])); seq1[3] = '\0'; seq2[3] = '\0'; match_score = m->base[pbs->seq[alc->alu[1]->start+1]]; match_score += m->base[pbs->seq[alc->alu[1]->start+2]]; match_score += m->base[pbs->seq[alc->alu[1]->start+3]]; fprintf(ofp,"%s %5d %5d %s [%c] vs %s [%c] %-.2f %-.2f\n",alc->alu[1]->text_label,alc->alu[0]->start+1,alc->alu[1]->start+1,seq1,aminoacid_from_seq(ct,seq1),seq2,aminoacid_from_seq(ct,seq2),Score2Bits(alc->alu[0]->score[0]),Score2Bits(match_score)); } if( strstr(alc->alu[1]->text_label,"SS") != NULL ) { seq1[0] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start-3])); seq1[1] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start-2])); seq1[2] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start-1])); seq1[3] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start])); seq1[4] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start+1])); seq1[5] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start+2])); seq1[6] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start+3])); seq1[7] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start+4])); seq1[8] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start+5])); seq1[9] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start+6])); seq1[10] = char_for_base(anchor_base_from_pairbase(pbs->seq[alc->alu[1]->start+7])); seq2[0] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start-3])); seq2[1] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start-2])); seq2[2] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start-1])); seq2[3] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start])); seq2[4] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start+1])); seq2[5] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start+2])); seq2[6] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start+3])); seq2[7] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start+4])); seq2[8] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start+5])); seq2[9] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start+6])); seq2[10] = char_for_base(informant_base_from_pairbase(pbs->seq[alc->alu[1]->start+7])); seq1[11] = '\0'; seq2[11] = '\0'; fprintf(ofp,"%12s %5d %5d %.2f\n",alc->alu[1]->text_label,alc->alu[0]->start+1,alc->alu[1]->start+1,Score2Bits(alc->alu[0]->score[0])); fprintf(ofp," %s\n %s\n",seq1,seq2); } } } double id(int i) { return (double)i; } int main(int argc,char ** argv) { int i; DPRunImpl * dpri = NULL; GeneModelParam * gmp = NULL; GeneModel * gm = NULL; FILE * ifp; SeqAlign * al; PairBaseSeq * pbs; ComplexSequenceEval * splice5; ComplexSequenceEval * splice3; ComplexSequence * cseq; CompMat * score_mat; CompProb * comp_prob; RandomModel * rm; PairBaseCodonModelScore * codon_score; PairBaseModelScore* nonc_score; PairBaseCodonModelScore * start; PairBaseCodonModelScore * stop; SyExonScore * exonscore; PackAln * pal; AlnBlock * alb; Genomic * genomic; GenomicRegion * gr; GenomicRegion * gr2; Protein * trans; StandardOutputOptions * std_opt; ShowGenomicRegionOptions * sgro; char * dump_packaln = NULL; char * read_packaln = NULL; FILE * packifp = NULL; boolean show_trans = 1; boolean show_gene_raw = 0; ct = read_CodonTable_file(codon_table); /* score_mat = read_Blast_file_CompMat("blosum62.bla"); comp_prob = CompProb_from_halfbit(score_mat); */ rm = default_RandomModel(); comp_prob = read_Blast_file_CompProb("wag85"); fold_column_RandomModel_CompProb(comp_prob,rm); dpri = new_DPRunImpl_from_argv(&argc,argv); if( dpri == NULL ) { fatal("Unable to build DPRun implementation. Bad arguments"); } gmp = new_GeneModelParam_from_argv(&argc,argv); std_opt = new_StandardOutputOptions_from_argv(&argc,argv); sgro = new_ShowGenomicRegionOptions_from_argv(&argc,argv); dump_packaln = strip_out_assigned_argument(&argc,argv,"dump"); read_packaln = strip_out_assigned_argument(&argc,argv,"recover"); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 2 ) { show_help(stdout); exit(12); } if((gm=GeneModel_from_GeneModelParam(gmp)) == NULL ) { fatal("Could not build gene model"); } codon_score = make_PairBaseCodonModelScore(comp_prob); nonc_score = make_PairBaseModelScore(); splice5 = ComplexSequenceEval_from_pwmDNAScore_splice(gm->splice5score); splice3 = ComplexSequenceEval_from_pwmDNAScore_splice(gm->splice3score); if((ifp = openfile(argv[1],"r")) == NULL ) { fatal("Could not open file %s",argv[1]); } al = read_fasta_SeqAlign(ifp); assert(al); assert(al->len == 2); assert(al->seq[0]->len > 0); assert(al->seq[1]->len > 0); /* write_fasta_SeqAlign(al,stdout);*/ pbs = new_PairBaseSeq_SeqAlign(al); if( read_packaln == NULL ) { cseq = ComplexSequence_from_PairBaseSeq(pbs,splice5,splice3); } start = make_start_PairBaseCodonModelScore(ct); stop = make_stop_PairBaseCodonModelScore(ct); /* show_PairBaseCodonModelScore(stop,ct,stdout); */ /* for(i=0;ianchor->len;i++) { printf("%3d %c For %-6d %-6d %c Rev %-6d %-6d\n",i,pbs->anchor->seq[i], CSEQ_PAIR_5SS(cseq,i),CSEQ_PAIR_3SS(cseq,i), char_complement_base(pbs->anchor->seq[i]), CSEQ_REV_PAIR_5SS(cseq,i),CSEQ_REV_PAIR_3SS(cseq,i)); } */ /* show_ComplexSequence(cseq,stdout); */ exonscore = SyExonScore_flat_model(100,150,0.1,1.0); /* for(i=0;ilength;i++) { fprintf(stdout,"%d PairSeq is %d score %d\n",i,CSEQ_PAIR_PAIRBASE(cseq,i),nonc_score->base[CSEQ_PAIR_PAIRBASE(cseq,i)]); } exit(0); */ if( read_packaln != NULL ) { packifp = openfile(read_packaln,"r"); if( packifp == NULL ) { fatal("File %s is unopenable - ignoring dump command",dump_packaln); } else { pal = read_simple_PackAln(packifp); } } else { pal = PackAln_bestmemory_SyWise20(exonscore,cseq,codon_score,nonc_score,start,stop,Probability2Score(1.0/100.0),Probability2Score(1.0/10000.0),Probability2Score(1.0/10.0),NULL,dpri); } alb = convert_PackAln_to_AlnBlock_SyWise20(pal); if( dump_packaln != NULL ) { packifp = openfile(dump_packaln,"w"); if( packifp == NULL ) { warn("File %s is unopenable - ignoring dump command",dump_packaln); } else { show_simple_PackAln(pal,packifp); } } show_score_sequence(alb,pbs,nonc_score,stdout); /* show_StandardOutputOptions(std_opt,alb,pal,"//",stdout); */ genomic = Genomic_from_Sequence(al->seq[0]); gr = new_GenomicRegion(genomic); gr2 = new_GenomicRegion(genomic); add_Genes_to_GenomicRegion_new(gr,alb); show_GenomicRegionOptions(sgro,gr,ct,"//",stdout); return 0; } wise-2.4.1/src/models/seqhit.c0000644000175000001440000010133110670453715015573 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "seqhit.h" # line 53 "seqhit.dy" DnaSequenceHitList * new_DnaSequenceHitList(void) { DnaSequenceHitList * out; out = DnaSequenceHitList_alloc(); out->forward = SegmentHitList_alloc_std(); out->backward = SegmentHitList_alloc_std(); return out; } /* Function: show_DnaSequenceHitList(dsl,ofp) * * Descrip: shows a DnaSequenceHitsList - * * only really useful for debugging * * * Arg: dsl [UNKN ] Undocumented argument [DnaSequenceHitList *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 69 "seqhit.dy" void show_DnaSequenceHitList(DnaSequenceHitList * dsl,FILE * ofp) { show_SegmentHitList(dsl->forward,ofp); show_SegmentHitList(dsl->backward,ofp); } # line 75 "seqhit.dy" void show_SegmentHitList(SegmentHitList * shl,FILE * ofp) { int i; for(i=0;ilen;i++) show_SegmentHit(shl->seghit[i],ofp); } # line 83 "seqhit.dy" void show_SegmentHit(SegmentHit * sh,FILE * ofp) { fprintf(ofp,"%4d %4d %4d %4d %4.2f %s\n",sh->qstart,sh->qend,sh->tstart,sh->tend,sh->score,sh->name); } # line 88 "seqhit.dy" void sort_SegmentHitList_by_qstart(SegmentHitList * sgl) { sort_SegmentHitList(sgl,compare_SegmentHit_by_qstart); } # line 93 "seqhit.dy" int compare_SegmentHit_by_qstart(SegmentHit * one,SegmentHit * two) { return one->qstart - two->qstart; } # line 98 "seqhit.dy" DnaSequenceHitList * read_msptmp_DnaSequenceHitList(FILE * ifp) { DnaSequenceHitList * out; SegmentHit * sh; char buffer[MAXLINE]; char copy[MAXLINE]; int strand; out = new_DnaSequenceHitList(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { strcpy(copy,buffer); if( (sh = SegmentHit_from_msptmp_line(buffer,&strand)) == NULL ) { warn("Cannot parse [%s] as a MSP crunch line",copy); continue; } if( strand < 0 ) { add_SegmentHitList(out->backward,sh); } else { add_SegmentHitList(out->forward,sh); } } sort_SegmentHitList_by_qstart(out->forward); sort_SegmentHitList_by_qstart(out->backward); return out; } # line 128 "seqhit.dy" boolean verify_SegmentHit(SegmentHit * sh) { boolean ret = TRUE; if ( sh->qstart <= 0 ) { ret = FALSE; warn("Got a less than zero index in query start %d",sh->qstart); } if ( sh->qend <= 0 ) { ret = FALSE; warn("Got a less than zero index in query end %d",sh->qend); } if ( sh->tstart <= 0 ) { ret = FALSE; warn("Got a less than zero index in target start %d",sh->tstart); } if ( sh->tend <= 0 ) { ret = FALSE; warn("Got a less than zero index in target end %d",sh->tend); } return ret; } /* Function: read_MSPcrunch_DnaSequenceHitList(ifp) * * Descrip: Reads a MSPcrunch -x output file * * * Arg: ifp [UNKN ] input file to read [FILE *] * * Return [UNKN ] newly allocated structure [DnaSequenceHitList *] * */ # line 158 "seqhit.dy" DnaSequenceHitList * read_MSPcrunch_DnaSequenceHitList(FILE * ifp) { DnaSequenceHitList * out; SegmentHit * sh; char buffer[MAXLINE]; char copy[MAXLINE]; int strand; out = new_DnaSequenceHitList(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { strcpy(copy,buffer); if( (sh = SegmentHit_from_MSPcrunch_line(buffer,&strand)) == NULL ) { warn("Cannot parse [%s] as a MSP crunch line",copy); continue; } if( verify_SegmentHit(sh) == FALSE ) { warn("Segment hit read in from [%s] was considered bad. Discarding",copy); sh = free_SegmentHit(sh); continue; } if( strand < 0 ) { add_SegmentHitList(out->backward,sh); } else { add_SegmentHitList(out->forward,sh); } } sort_SegmentHitList_by_qstart(out->forward); sort_SegmentHitList_by_qstart(out->backward); /* fprintf(stderr,"We have %d forward and %d backward guys\n",out->forward->len,out->backward->len); */ return out; } # line 196 "seqhit.dy" SegmentHit * SegmentHit_from_msptmp_line(char * line,int * strand) { SegmentHit * out; char * runner; out = SegmentHit_alloc(); runner = strtok(line,spacestr); if( runner == NULL || is_double_string(runner,&out->score) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL ) goto error; if( *runner != '(' || runner[strlen(runner)-1] != ')' ) goto error; runner[strlen(runner)-1] = '\0'; runner++; if( is_integer_string(runner,strand) == FALSE) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->qstart) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->qend) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->tstart) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->tend) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL ) goto error; out->name = stringalloc(runner); return out; error : free_SegmentHit(out); return NULL; } # line 246 "seqhit.dy" SegmentHit * SegmentHit_from_MSPcrunch_line(char * line,int * strand) { SegmentHit * out; char * runner; out = SegmentHit_alloc(); runner = strtok(line,spacestr); if( runner == NULL || is_double_string(runner,&out->score) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL ) goto error; if( *runner != '(' || runner[strlen(runner)-1] != ')' ) goto error; runner[strlen(runner)-1] = '\0'; runner++; if( is_integer_string(runner,strand) == FALSE) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->qstart) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->qend) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->tstart) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->tend) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL ) goto error; out->name = stringalloc(runner); return out; error : free_SegmentHit(out); return NULL; } # line 271 "seqhit.c" /* Function: hard_link_SegmentHit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SegmentHit *] * * Return [UNKN ] Undocumented return value [SegmentHit *] * */ SegmentHit * hard_link_SegmentHit(SegmentHit * obj) { if( obj == NULL ) { warn("Trying to hard link to a SegmentHit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SegmentHit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SegmentHit *] * */ SegmentHit * SegmentHit_alloc(void) { SegmentHit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SegmentHit *) ckalloc (sizeof(SegmentHit))) == NULL) { warn("SegmentHit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->qstart = 0; out->qend = 0; out->tstart = 0; out->tend = 0; out->score = 0; out->next_hit = NULL; return out; } /* Function: free_SegmentHit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SegmentHit *] * * Return [UNKN ] Undocumented return value [SegmentHit *] * */ SegmentHit * free_SegmentHit(SegmentHit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SegmentHit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->next_hit != NULL) free_SegmentHit(obj->next_hit); ckfree(obj); return NULL; } /* Function: hard_link_SequenceHit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SequenceHit *] * * Return [UNKN ] Undocumented return value [SequenceHit *] * */ SequenceHit * hard_link_SequenceHit(SequenceHit * obj) { if( obj == NULL ) { warn("Trying to hard link to a SequenceHit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SequenceHit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SequenceHit *] * */ SequenceHit * SequenceHit_alloc(void) { SequenceHit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SequenceHit *) ckalloc (sizeof(SequenceHit))) == NULL) { warn("SequenceHit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->start = NULL; return out; } /* Function: free_SequenceHit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SequenceHit *] * * Return [UNKN ] Undocumented return value [SequenceHit *] * */ SequenceHit * free_SequenceHit(SequenceHit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SequenceHit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->start != NULL) free_SegmentHit(obj->start); ckfree(obj); return NULL; } /* Function: swap_SegmentHitList(list,i,j) * * Descrip: swap function: an internal for qsort_SegmentHitList * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [SegmentHit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SegmentHitList(SegmentHit ** list,int i,int j) { SegmentHit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SegmentHitList(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SegmentHitList which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [SegmentHit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SegmentHitList(SegmentHit ** list,int left,int right,int (*comp)(SegmentHit * ,SegmentHit * )) { int i,last; if( left >= right ) return; swap_SegmentHitList(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SegmentHitList (list,++last,i); } swap_SegmentHitList (list,left,last); qsort_SegmentHitList(list,left,last-1,comp); qsort_SegmentHitList(list,last+1,right,comp); } /* Function: sort_SegmentHitList(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SegmentHitList * * * Arg: obj [UNKN ] Object containing list [SegmentHitList *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SegmentHitList(SegmentHitList * obj,int (*comp)(SegmentHit *, SegmentHit *)) { qsort_SegmentHitList(obj->seghit,0,obj->len-1,comp); return; } /* Function: expand_SegmentHitList(obj,len) * * Descrip: Really an internal function for add_SegmentHitList * * * Arg: obj [UNKN ] Object which contains the list [SegmentHitList *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SegmentHitList(SegmentHitList * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SegmentHitList called with no need"); return TRUE; } if( (obj->seghit = (SegmentHit ** ) ckrealloc (obj->seghit,sizeof(SegmentHit *)*len)) == NULL) { warn("ckrealloc failed for expand_SegmentHitList, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SegmentHitList(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SegmentHitList *] * Arg: add [OWNER] Object to add to the list [SegmentHit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SegmentHitList(SegmentHitList * obj,SegmentHit * add) { if( obj->len >= obj->maxlen) { if( expand_SegmentHitList(obj,obj->len + SegmentHitListLISTLENGTH) == FALSE) return FALSE; } obj->seghit[obj->len++]=add; return TRUE; } /* Function: flush_SegmentHitList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SegmentHitList *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SegmentHitList(SegmentHitList * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->seghit[i] != NULL) { free_SegmentHit(obj->seghit[i]); obj->seghit[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SegmentHitList_alloc_std(void) * * Descrip: Equivalent to SegmentHitList_alloc_len(SegmentHitListLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SegmentHitList *] * */ SegmentHitList * SegmentHitList_alloc_std(void) { return SegmentHitList_alloc_len(SegmentHitListLISTLENGTH); } /* Function: SegmentHitList_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SegmentHitList *] * */ SegmentHitList * SegmentHitList_alloc_len(int len) { SegmentHitList * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SegmentHitList_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->seghit = (SegmentHit ** ) ckcalloc (len,sizeof(SegmentHit *))) == NULL) { warn("Warning, ckcalloc failed in SegmentHitList_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SegmentHitList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SegmentHitList *] * * Return [UNKN ] Undocumented return value [SegmentHitList *] * */ SegmentHitList * hard_link_SegmentHitList(SegmentHitList * obj) { if( obj == NULL ) { warn("Trying to hard link to a SegmentHitList object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SegmentHitList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SegmentHitList *] * */ SegmentHitList * SegmentHitList_alloc(void) { SegmentHitList * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SegmentHitList *) ckalloc (sizeof(SegmentHitList))) == NULL) { warn("SegmentHitList_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->seghit = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_SegmentHitList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SegmentHitList *] * * Return [UNKN ] Undocumented return value [SegmentHitList *] * */ SegmentHitList * free_SegmentHitList(SegmentHitList * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SegmentHitList obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->seghit != NULL) { for(i=0;ilen;i++) { if( obj->seghit[i] != NULL) free_SegmentHit(obj->seghit[i]); } ckfree(obj->seghit); } ckfree(obj); return NULL; } /* Function: hard_link_DnaSequenceHitList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaSequenceHitList *] * * Return [UNKN ] Undocumented return value [DnaSequenceHitList *] * */ DnaSequenceHitList * hard_link_DnaSequenceHitList(DnaSequenceHitList * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaSequenceHitList object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaSequenceHitList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaSequenceHitList *] * */ DnaSequenceHitList * DnaSequenceHitList_alloc(void) { DnaSequenceHitList * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaSequenceHitList *) ckalloc (sizeof(DnaSequenceHitList))) == NULL) { warn("DnaSequenceHitList_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->forward = NULL; out->backward = NULL; return out; } /* Function: free_DnaSequenceHitList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaSequenceHitList *] * * Return [UNKN ] Undocumented return value [DnaSequenceHitList *] * */ DnaSequenceHitList * free_DnaSequenceHitList(DnaSequenceHitList * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaSequenceHitList obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->forward != NULL) free_SegmentHitList(obj->forward); if( obj->backward != NULL) free_SegmentHitList(obj->backward); ckfree(obj); return NULL; } /* Function: replace_forward_DnaSequenceHitList(obj,forward) * * Descrip: Replace member variable forward * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DnaSequenceHitList *] * Arg: forward [OWNER] New value of the variable [SegmentHitList *] * * Return [SOFT ] member variable forward [boolean] * */ boolean replace_forward_DnaSequenceHitList(DnaSequenceHitList * obj,SegmentHitList * forward) { if( obj == NULL) { warn("In replacement function forward for object DnaSequenceHitList, got a NULL object"); return FALSE; } obj->forward = forward; return TRUE; } /* Function: access_forward_DnaSequenceHitList(obj) * * Descrip: Access member variable forward * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DnaSequenceHitList *] * * Return [SOFT ] member variable forward [SegmentHitList *] * */ SegmentHitList * access_forward_DnaSequenceHitList(DnaSequenceHitList * obj) { if( obj == NULL) { warn("In accessor function forward for object DnaSequenceHitList, got a NULL object"); return NULL; } return obj->forward; } /* Function: replace_backward_DnaSequenceHitList(obj,backward) * * Descrip: Replace member variable backward * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DnaSequenceHitList *] * Arg: backward [OWNER] New value of the variable [SegmentHitList *] * * Return [SOFT ] member variable backward [boolean] * */ boolean replace_backward_DnaSequenceHitList(DnaSequenceHitList * obj,SegmentHitList * backward) { if( obj == NULL) { warn("In replacement function backward for object DnaSequenceHitList, got a NULL object"); return FALSE; } obj->backward = backward; return TRUE; } /* Function: access_backward_DnaSequenceHitList(obj) * * Descrip: Access member variable backward * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DnaSequenceHitList *] * * Return [SOFT ] member variable backward [SegmentHitList *] * */ SegmentHitList * access_backward_DnaSequenceHitList(DnaSequenceHitList * obj) { if( obj == NULL) { warn("In accessor function backward for object DnaSequenceHitList, got a NULL object"); return NULL; } return obj->backward; } /* Function: access_seghit_SegmentHitList(obj,i) * * Descrip: Access members stored in the seghit list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [SegmentHitList *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [SegmentHit *] * */ SegmentHit * access_seghit_SegmentHitList(SegmentHitList * obj,int i) { if( obj == NULL) { warn("In accessor function seghit for object SegmentHitList, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function seghit for object SegmentHitList, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->seghit[i]; } /* Function: length_seghit_SegmentHitList(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [SegmentHitList *] * * Return [UNKN ] length of the list [int] * */ int length_seghit_SegmentHitList(SegmentHitList * obj) { if( obj == NULL) { warn("In length function seghit for object SegmentHitList, got a NULL object"); return -1; } return obj->len; } /* Function: replace_name_SegmentHit(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * Arg: name [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable name [boolean] * */ boolean replace_name_SegmentHit(SegmentHit * obj,char * name) { if( obj == NULL) { warn("In replacement function name for object SegmentHit, got a NULL object"); return FALSE; } obj->name = name; return TRUE; } /* Function: access_name_SegmentHit(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * * Return [SOFT ] member variable name [char *] * */ char * access_name_SegmentHit(SegmentHit * obj) { if( obj == NULL) { warn("In accessor function name for object SegmentHit, got a NULL object"); return NULL; } return obj->name; } /* Function: replace_qstart_SegmentHit(obj,qstart) * * Descrip: Replace member variable qstart * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * Arg: qstart [OWNER] New value of the variable [int] * * Return [SOFT ] member variable qstart [boolean] * */ boolean replace_qstart_SegmentHit(SegmentHit * obj,int qstart) { if( obj == NULL) { warn("In replacement function qstart for object SegmentHit, got a NULL object"); return FALSE; } obj->qstart = qstart; return TRUE; } /* Function: access_qstart_SegmentHit(obj) * * Descrip: Access member variable qstart * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * * Return [SOFT ] member variable qstart [int] * */ int access_qstart_SegmentHit(SegmentHit * obj) { if( obj == NULL) { warn("In accessor function qstart for object SegmentHit, got a NULL object"); return 0; } return obj->qstart; } /* Function: replace_qend_SegmentHit(obj,qend) * * Descrip: Replace member variable qend * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * Arg: qend [OWNER] New value of the variable [int] * * Return [SOFT ] member variable qend [boolean] * */ boolean replace_qend_SegmentHit(SegmentHit * obj,int qend) { if( obj == NULL) { warn("In replacement function qend for object SegmentHit, got a NULL object"); return FALSE; } obj->qend = qend; return TRUE; } /* Function: access_qend_SegmentHit(obj) * * Descrip: Access member variable qend * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * * Return [SOFT ] member variable qend [int] * */ int access_qend_SegmentHit(SegmentHit * obj) { if( obj == NULL) { warn("In accessor function qend for object SegmentHit, got a NULL object"); return 0; } return obj->qend; } /* Function: replace_tstart_SegmentHit(obj,tstart) * * Descrip: Replace member variable tstart * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * Arg: tstart [OWNER] New value of the variable [int] * * Return [SOFT ] member variable tstart [boolean] * */ boolean replace_tstart_SegmentHit(SegmentHit * obj,int tstart) { if( obj == NULL) { warn("In replacement function tstart for object SegmentHit, got a NULL object"); return FALSE; } obj->tstart = tstart; return TRUE; } /* Function: access_tstart_SegmentHit(obj) * * Descrip: Access member variable tstart * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * * Return [SOFT ] member variable tstart [int] * */ int access_tstart_SegmentHit(SegmentHit * obj) { if( obj == NULL) { warn("In accessor function tstart for object SegmentHit, got a NULL object"); return 0; } return obj->tstart; } /* Function: replace_tend_SegmentHit(obj,tend) * * Descrip: Replace member variable tend * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * Arg: tend [OWNER] New value of the variable [int] * * Return [SOFT ] member variable tend [boolean] * */ boolean replace_tend_SegmentHit(SegmentHit * obj,int tend) { if( obj == NULL) { warn("In replacement function tend for object SegmentHit, got a NULL object"); return FALSE; } obj->tend = tend; return TRUE; } /* Function: access_tend_SegmentHit(obj) * * Descrip: Access member variable tend * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * * Return [SOFT ] member variable tend [int] * */ int access_tend_SegmentHit(SegmentHit * obj) { if( obj == NULL) { warn("In accessor function tend for object SegmentHit, got a NULL object"); return 0; } return obj->tend; } /* Function: replace_score_SegmentHit(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * Arg: score [OWNER] New value of the variable [double] * * Return [SOFT ] member variable score [boolean] * */ boolean replace_score_SegmentHit(SegmentHit * obj,double score) { if( obj == NULL) { warn("In replacement function score for object SegmentHit, got a NULL object"); return FALSE; } obj->score = score; return TRUE; } /* Function: access_score_SegmentHit(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * * Return [SOFT ] member variable score [double] * */ double access_score_SegmentHit(SegmentHit * obj) { if( obj == NULL) { warn("In accessor function score for object SegmentHit, got a NULL object"); return 0; } return obj->score; } /* Function: replace_next_hit_SegmentHit(obj,next_hit) * * Descrip: Replace member variable next_hit * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * Arg: next_hit [OWNER] New value of the variable [SegmentHit *] * * Return [SOFT ] member variable next_hit [boolean] * */ boolean replace_next_hit_SegmentHit(SegmentHit * obj,SegmentHit * next_hit) { if( obj == NULL) { warn("In replacement function next_hit for object SegmentHit, got a NULL object"); return FALSE; } obj->next_hit = next_hit; return TRUE; } /* Function: access_next_hit_SegmentHit(obj) * * Descrip: Access member variable next_hit * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SegmentHit *] * * Return [SOFT ] member variable next_hit [SegmentHit *] * */ SegmentHit * access_next_hit_SegmentHit(SegmentHit * obj) { if( obj == NULL) { warn("In accessor function next_hit for object SegmentHit, got a NULL object"); return NULL; } return obj->next_hit; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/seqhit.h0000644000175000001440000003412510670453715015606 0ustar philippusers#ifndef DYNAMITEseqhitHEADERFILE #define DYNAMITEseqhitHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #define SegmentHitListLISTLENGTH 128 #ifndef DYNAMITE_DEFINED_SegmentHit typedef struct Wise2_SegmentHit Wise2_SegmentHit; #define SegmentHit Wise2_SegmentHit #define DYNAMITE_DEFINED_SegmentHit #endif struct Wise2_SegmentHit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; int qstart; int qend; int tstart; int tend; double score; SegmentHit * next_hit; /* for collecting hits together ;) */ } ; /* SegmentHit defined */ #ifndef DYNAMITE_DEFINED_SegmentHit typedef struct Wise2_SegmentHit Wise2_SegmentHit; #define SegmentHit Wise2_SegmentHit #define DYNAMITE_DEFINED_SegmentHit #endif struct Wise2_SequenceHit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; SegmentHit * start; } ; /* SequenceHit defined */ #ifndef DYNAMITE_DEFINED_SequenceHit typedef struct Wise2_SequenceHit Wise2_SequenceHit; #define SequenceHit Wise2_SequenceHit #define DYNAMITE_DEFINED_SequenceHit #endif struct Wise2_SegmentHitList { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SegmentHit ** seghit; int len;/* len for above seghit */ int maxlen; /* maxlen for above seghit */ } ; /* SegmentHitList defined */ #ifndef DYNAMITE_DEFINED_SegmentHitList typedef struct Wise2_SegmentHitList Wise2_SegmentHitList; #define SegmentHitList Wise2_SegmentHitList #define DYNAMITE_DEFINED_SegmentHitList #endif struct Wise2_DnaSequenceHitList { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SegmentHitList * forward; SegmentHitList * backward; } ; /* DnaSequenceHitList defined */ #ifndef DYNAMITE_DEFINED_DnaSequenceHitList typedef struct Wise2_DnaSequenceHitList Wise2_DnaSequenceHitList; #define DnaSequenceHitList Wise2_DnaSequenceHitList #define DYNAMITE_DEFINED_DnaSequenceHitList #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: show_DnaSequenceHitList(dsl,ofp) * * Descrip: shows a DnaSequenceHitsList - * * only really useful for debugging * * * Arg: dsl [UNKN ] Undocumented argument [DnaSequenceHitList *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_DnaSequenceHitList(DnaSequenceHitList * dsl,FILE * ofp); #define show_DnaSequenceHitList Wise2_show_DnaSequenceHitList /* Function: read_MSPcrunch_DnaSequenceHitList(ifp) * * Descrip: Reads a MSPcrunch -x output file * * * Arg: ifp [UNKN ] input file to read [FILE *] * * Return [UNKN ] newly allocated structure [DnaSequenceHitList *] * */ DnaSequenceHitList * Wise2_read_MSPcrunch_DnaSequenceHitList(FILE * ifp); #define read_MSPcrunch_DnaSequenceHitList Wise2_read_MSPcrunch_DnaSequenceHitList /* Function: hard_link_SegmentHit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SegmentHit *] * * Return [UNKN ] Undocumented return value [SegmentHit *] * */ SegmentHit * Wise2_hard_link_SegmentHit(SegmentHit * obj); #define hard_link_SegmentHit Wise2_hard_link_SegmentHit /* Function: SegmentHit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SegmentHit *] * */ SegmentHit * Wise2_SegmentHit_alloc(void); #define SegmentHit_alloc Wise2_SegmentHit_alloc /* Function: free_SegmentHit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SegmentHit *] * * Return [UNKN ] Undocumented return value [SegmentHit *] * */ SegmentHit * Wise2_free_SegmentHit(SegmentHit * obj); #define free_SegmentHit Wise2_free_SegmentHit /* Function: hard_link_SequenceHit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SequenceHit *] * * Return [UNKN ] Undocumented return value [SequenceHit *] * */ SequenceHit * Wise2_hard_link_SequenceHit(SequenceHit * obj); #define hard_link_SequenceHit Wise2_hard_link_SequenceHit /* Function: SequenceHit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SequenceHit *] * */ SequenceHit * Wise2_SequenceHit_alloc(void); #define SequenceHit_alloc Wise2_SequenceHit_alloc /* Function: free_SequenceHit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SequenceHit *] * * Return [UNKN ] Undocumented return value [SequenceHit *] * */ SequenceHit * Wise2_free_SequenceHit(SequenceHit * obj); #define free_SequenceHit Wise2_free_SequenceHit /* Function: add_SegmentHitList(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SegmentHitList *] * Arg: add [OWNER] Object to add to the list [SegmentHit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SegmentHitList(SegmentHitList * obj,SegmentHit * add); #define add_SegmentHitList Wise2_add_SegmentHitList /* Function: flush_SegmentHitList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SegmentHitList *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SegmentHitList(SegmentHitList * obj); #define flush_SegmentHitList Wise2_flush_SegmentHitList /* Function: SegmentHitList_alloc_std(void) * * Descrip: Equivalent to SegmentHitList_alloc_len(SegmentHitListLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SegmentHitList *] * */ SegmentHitList * Wise2_SegmentHitList_alloc_std(void); #define SegmentHitList_alloc_std Wise2_SegmentHitList_alloc_std /* Function: SegmentHitList_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SegmentHitList *] * */ SegmentHitList * Wise2_SegmentHitList_alloc_len(int len); #define SegmentHitList_alloc_len Wise2_SegmentHitList_alloc_len /* Function: hard_link_SegmentHitList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SegmentHitList *] * * Return [UNKN ] Undocumented return value [SegmentHitList *] * */ SegmentHitList * Wise2_hard_link_SegmentHitList(SegmentHitList * obj); #define hard_link_SegmentHitList Wise2_hard_link_SegmentHitList /* Function: SegmentHitList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SegmentHitList *] * */ SegmentHitList * Wise2_SegmentHitList_alloc(void); #define SegmentHitList_alloc Wise2_SegmentHitList_alloc /* Function: free_SegmentHitList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SegmentHitList *] * * Return [UNKN ] Undocumented return value [SegmentHitList *] * */ SegmentHitList * Wise2_free_SegmentHitList(SegmentHitList * obj); #define free_SegmentHitList Wise2_free_SegmentHitList /* Function: hard_link_DnaSequenceHitList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaSequenceHitList *] * * Return [UNKN ] Undocumented return value [DnaSequenceHitList *] * */ DnaSequenceHitList * Wise2_hard_link_DnaSequenceHitList(DnaSequenceHitList * obj); #define hard_link_DnaSequenceHitList Wise2_hard_link_DnaSequenceHitList /* Function: DnaSequenceHitList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaSequenceHitList *] * */ DnaSequenceHitList * Wise2_DnaSequenceHitList_alloc(void); #define DnaSequenceHitList_alloc Wise2_DnaSequenceHitList_alloc /* Function: free_DnaSequenceHitList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaSequenceHitList *] * * Return [UNKN ] Undocumented return value [DnaSequenceHitList *] * */ DnaSequenceHitList * Wise2_free_DnaSequenceHitList(DnaSequenceHitList * obj); #define free_DnaSequenceHitList Wise2_free_DnaSequenceHitList /* Unplaced functions */ /* There has been no indication of the use of these functions */ DnaSequenceHitList * Wise2_new_DnaSequenceHitList(void); #define new_DnaSequenceHitList Wise2_new_DnaSequenceHitList void Wise2_show_SegmentHitList(SegmentHitList * shl,FILE * ofp); #define show_SegmentHitList Wise2_show_SegmentHitList void Wise2_show_SegmentHit(SegmentHit * sh,FILE * ofp); #define show_SegmentHit Wise2_show_SegmentHit void Wise2_sort_SegmentHitList_by_qstart(SegmentHitList * sgl); #define sort_SegmentHitList_by_qstart Wise2_sort_SegmentHitList_by_qstart int Wise2_compare_SegmentHit_by_qstart(SegmentHit * one,SegmentHit * two); #define compare_SegmentHit_by_qstart Wise2_compare_SegmentHit_by_qstart DnaSequenceHitList * Wise2_read_msptmp_DnaSequenceHitList(FILE * ifp); #define read_msptmp_DnaSequenceHitList Wise2_read_msptmp_DnaSequenceHitList boolean Wise2_verify_SegmentHit(SegmentHit * sh); #define verify_SegmentHit Wise2_verify_SegmentHit SegmentHit * Wise2_SegmentHit_from_msptmp_line(char * line,int * strand); #define SegmentHit_from_msptmp_line Wise2_SegmentHit_from_msptmp_line SegmentHit * Wise2_SegmentHit_from_MSPcrunch_line(char * line,int * strand); #define SegmentHit_from_MSPcrunch_line Wise2_SegmentHit_from_MSPcrunch_line /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_forward_DnaSequenceHitList(DnaSequenceHitList * obj,SegmentHitList * forward); #define replace_forward_DnaSequenceHitList Wise2_replace_forward_DnaSequenceHitList boolean Wise2_replace_qstart_SegmentHit(SegmentHit * obj,int qstart); #define replace_qstart_SegmentHit Wise2_replace_qstart_SegmentHit SegmentHit * Wise2_access_next_hit_SegmentHit(SegmentHit * obj); #define access_next_hit_SegmentHit Wise2_access_next_hit_SegmentHit int Wise2_access_qstart_SegmentHit(SegmentHit * obj); #define access_qstart_SegmentHit Wise2_access_qstart_SegmentHit SegmentHitList * Wise2_access_forward_DnaSequenceHitList(DnaSequenceHitList * obj); #define access_forward_DnaSequenceHitList Wise2_access_forward_DnaSequenceHitList boolean Wise2_replace_qend_SegmentHit(SegmentHit * obj,int qend); #define replace_qend_SegmentHit Wise2_replace_qend_SegmentHit SegmentHitList * Wise2_access_backward_DnaSequenceHitList(DnaSequenceHitList * obj); #define access_backward_DnaSequenceHitList Wise2_access_backward_DnaSequenceHitList int Wise2_access_qend_SegmentHit(SegmentHit * obj); #define access_qend_SegmentHit Wise2_access_qend_SegmentHit int Wise2_length_seghit_SegmentHitList(SegmentHitList * obj); #define length_seghit_SegmentHitList Wise2_length_seghit_SegmentHitList boolean Wise2_replace_tstart_SegmentHit(SegmentHit * obj,int tstart); #define replace_tstart_SegmentHit Wise2_replace_tstart_SegmentHit char * Wise2_access_name_SegmentHit(SegmentHit * obj); #define access_name_SegmentHit Wise2_access_name_SegmentHit int Wise2_access_tstart_SegmentHit(SegmentHit * obj); #define access_tstart_SegmentHit Wise2_access_tstart_SegmentHit boolean Wise2_replace_backward_DnaSequenceHitList(DnaSequenceHitList * obj,SegmentHitList * backward); #define replace_backward_DnaSequenceHitList Wise2_replace_backward_DnaSequenceHitList boolean Wise2_replace_tend_SegmentHit(SegmentHit * obj,int tend); #define replace_tend_SegmentHit Wise2_replace_tend_SegmentHit boolean Wise2_replace_name_SegmentHit(SegmentHit * obj,char * name); #define replace_name_SegmentHit Wise2_replace_name_SegmentHit int Wise2_access_tend_SegmentHit(SegmentHit * obj); #define access_tend_SegmentHit Wise2_access_tend_SegmentHit SegmentHit * Wise2_access_seghit_SegmentHitList(SegmentHitList * obj,int i); #define access_seghit_SegmentHitList Wise2_access_seghit_SegmentHitList boolean Wise2_replace_score_SegmentHit(SegmentHit * obj,double score); #define replace_score_SegmentHit Wise2_replace_score_SegmentHit boolean Wise2_replace_next_hit_SegmentHit(SegmentHit * obj,SegmentHit * next_hit); #define replace_next_hit_SegmentHit Wise2_replace_next_hit_SegmentHit double Wise2_access_score_SegmentHit(SegmentHit * obj); #define access_score_SegmentHit Wise2_access_score_SegmentHit void Wise2_swap_SegmentHitList(SegmentHit ** list,int i,int j) ; #define swap_SegmentHitList Wise2_swap_SegmentHitList void Wise2_qsort_SegmentHitList(SegmentHit ** list,int left,int right,int (*comp)(SegmentHit * ,SegmentHit * )); #define qsort_SegmentHitList Wise2_qsort_SegmentHitList void Wise2_sort_SegmentHitList(SegmentHitList * obj,int (*comp)(SegmentHit *, SegmentHit *)); #define sort_SegmentHitList Wise2_sort_SegmentHitList boolean Wise2_expand_SegmentHitList(SegmentHitList * obj,int len); #define expand_SegmentHitList Wise2_expand_SegmentHitList #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/standardout.c0000644000175000001440000001022010670453715016622 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "standardout.h" # line 24 "standardout.dy" void show_help_StandardOutputOptions(FILE * ofp) { fprintf(ofp,"Standard alignment outputs\n"); fprintf(ofp," -alb show align block format\n"); fprintf(ofp," -pal show raw alignment\n"); fprintf(ofp," -calb show cumlative align block\n"); fprintf(ofp," -cpal show cumlative raw alignemnt\n"); } # line 35 "standardout.dy" StandardOutputOptions * new_StandardOutputOptions_from_argv(int * argc,char ** argv) { StandardOutputOptions * out; out = StandardOutputOptions_alloc(); out->show_alb = strip_out_boolean_argument(argc,argv,"alb"); out->show_pal = strip_out_boolean_argument(argc,argv,"pal"); out->show_cumlative_alb = strip_out_boolean_argument(argc,argv,"calb"); out->show_cumlative_pal = strip_out_boolean_argument(argc,argv,"cpal"); return out; } # line 50 "standardout.dy" void show_StandardOutputOptions(StandardOutputOptions * out,AlnBlock * alb,PackAln * pal,char * divide_str,FILE * ofp) { assert(out); assert(alb); assert(pal); assert(ofp); assert(divide_str); if( out->show_alb == TRUE ) { mapped_ascii_AlnBlock(alb,Score2Bits,0,ofp); fprintf(ofp,"%s\n",divide_str); } if( out->show_cumlative_alb == TRUE ) { mapped_ascii_AlnBlock(alb,Score2Bits,1,ofp); fprintf(ofp,"%s\n",divide_str); } if( out->show_cumlative_pal == TRUE ) { show_bits_and_cumlative_PackAln(pal,ofp); fprintf(ofp,"%s\n",divide_str); } if( out->show_pal == TRUE ) { show_simple_PackAln(pal,ofp); fprintf(ofp,"%s\n",divide_str); } return; } # line 68 "standardout.c" /* Function: hard_link_StandardOutputOptions(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [StandardOutputOptions *] * * Return [UNKN ] Undocumented return value [StandardOutputOptions *] * */ StandardOutputOptions * hard_link_StandardOutputOptions(StandardOutputOptions * obj) { if( obj == NULL ) { warn("Trying to hard link to a StandardOutputOptions object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: StandardOutputOptions_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [StandardOutputOptions *] * */ StandardOutputOptions * StandardOutputOptions_alloc(void) { StandardOutputOptions * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(StandardOutputOptions *) ckalloc (sizeof(StandardOutputOptions))) == NULL) { warn("StandardOutputOptions_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->show_alb = FALSE; out->show_pal = FALSE; out->show_cumlative_alb = FALSE; out->show_cumlative_pal = FALSE; return out; } /* Function: free_StandardOutputOptions(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [StandardOutputOptions *] * * Return [UNKN ] Undocumented return value [StandardOutputOptions *] * */ StandardOutputOptions * free_StandardOutputOptions(StandardOutputOptions * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a StandardOutputOptions obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/standardout.h0000644000175000001440000000605510670453715016642 0ustar philippusers#ifndef DYNAMITEstandardoutHEADERFILE #define DYNAMITEstandardoutHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" struct Wise2_StandardOutputOptions { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif boolean show_alb; boolean show_pal; boolean show_cumlative_alb; boolean show_cumlative_pal; } ; /* StandardOutputOptions defined */ #ifndef DYNAMITE_DEFINED_StandardOutputOptions typedef struct Wise2_StandardOutputOptions Wise2_StandardOutputOptions; #define StandardOutputOptions Wise2_StandardOutputOptions #define DYNAMITE_DEFINED_StandardOutputOptions #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_StandardOutputOptions(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [StandardOutputOptions *] * * Return [UNKN ] Undocumented return value [StandardOutputOptions *] * */ StandardOutputOptions * Wise2_hard_link_StandardOutputOptions(StandardOutputOptions * obj); #define hard_link_StandardOutputOptions Wise2_hard_link_StandardOutputOptions /* Function: StandardOutputOptions_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [StandardOutputOptions *] * */ StandardOutputOptions * Wise2_StandardOutputOptions_alloc(void); #define StandardOutputOptions_alloc Wise2_StandardOutputOptions_alloc /* Function: free_StandardOutputOptions(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [StandardOutputOptions *] * * Return [UNKN ] Undocumented return value [StandardOutputOptions *] * */ StandardOutputOptions * Wise2_free_StandardOutputOptions(StandardOutputOptions * obj); #define free_StandardOutputOptions Wise2_free_StandardOutputOptions /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_show_help_StandardOutputOptions(FILE * ofp); #define show_help_StandardOutputOptions Wise2_show_help_StandardOutputOptions StandardOutputOptions * Wise2_new_StandardOutputOptions_from_argv(int * argc,char ** argv); #define new_StandardOutputOptions_from_argv Wise2_new_StandardOutputOptions_from_argv void Wise2_show_StandardOutputOptions(StandardOutputOptions * out,AlnBlock * alb,PackAln * pal,char * divide_str,FILE * ofp); #define show_StandardOutputOptions Wise2_show_StandardOutputOptions /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/sw_wrap_api.h0000644000175000001440000002112410670453715016617 0ustar philippusers /* Helper functions in the module * * Wise2_Align_strings_ProteinSmithWaterman * Wise2_Align_Sequences_ProteinSmithWaterman * Wise2_Align_Proteins_SmithWaterman * Wise2_Align_Proteins_ABC * Wise2_Align_Sequences_ProteinABC * Wise2_Hscore_from_ProteinSW * Wise2_Hscore_from_ProteinABC * Wise2_Hscore_from_ProteinBA * /* These functions are not associated with an object */ /* Function: Wise2_Align_strings_ProteinSmithWaterman(one,two,comp,gap,ext,dpenv,dpri) * * Descrip: This is the most *stupidly* abstracted view of two sequences * getting aligned, being two strings. * * It would be much better if you used Sequence objects or Protein * objects to carry the proteins. * * * Arg: one string of the first sequence [char *] * Arg: two string of the second sequence [char *] * Arg: comp Comparison Matrix [Wise2_CompMat *] * Arg: gap gap penalty [int] * Arg: ext extension penalty [int] * Arg: dpenv Undocumented argument [Wise2_DPEnvelope *] * Arg: dpri Undocumented argument [Wise2_DPRunImpl *] * * Returns Undocumented return value [Wise2_AlnBlock *] * */ Wise2_AlnBlock * Wise2_Align_strings_ProteinSmithWaterman( char * one,char * two,Wise2_CompMat * comp,int gap,int ext,Wise2_DPEnvelope * dpenv,Wise2_DPRunImpl * dpri); /* Function: Wise2_Align_Sequences_ProteinSmithWaterman(one,two,comp,gap,ext,dpenv,dpri) * * Descrip: This function is a mid-level abstraction of * comparing two sequences, which could be * generic types (eg DNA!). This is tested * for and warnings are given but the alignment * is still calculated. To prevent this test * warning either make sure the Sequence types * are set to PROTEIN or, better still, use the * high level abstraction Align_Proteins_SmithWaterman * * Otherwise this performs a standard smith waterman * protein alignment... * * To display the alignment use write_pretty_seq_align * * * Arg: one First sequence to compare [Wise2_Sequence *] * Arg: two Second sequecne to compare [Wise2_Sequence *] * Arg: comp Comparison matrix to use [Wise2_CompMat *] * Arg: gap gap penalty. Must be negative or 0 [int] * Arg: ext ext penalty. Must be negative or 0 [int] * Arg: dpenv Undocumented argument [Wise2_DPEnvelope *] * Arg: dpri Undocumented argument [Wise2_DPRunImpl *] * * Returns new AlnBlock structure representing the alignment [Wise2_AlnBlock *] * */ Wise2_AlnBlock * Wise2_Align_Sequences_ProteinSmithWaterman( Wise2_Sequence * one,Wise2_Sequence * two,Wise2_CompMat * comp,int gap,int ext,Wise2_DPEnvelope * dpenv,Wise2_DPRunImpl * dpri); /* Function: Wise2_Align_Proteins_SmithWaterman(one,two,comp,gap,ext,dpenv,dpri) * * Descrip: This is the most correct way of aligning two Proteins, * using Protein objects, which can be assummed to be * proteins with no objections * * To display the alignment use write_pretty_Protein_align * * * * Arg: one Protein to align [Wise2_Protein *] * Arg: two Protein to align [Wise2_Protein *] * Arg: comp Comparison Matrix [Wise2_CompMat *] * Arg: gap gap penalty [int] * Arg: ext extension penalty [int] * Arg: dpenv Undocumented argument [Wise2_DPEnvelope *] * Arg: dpri Undocumented argument [Wise2_DPRunImpl *] * * Returns Undocumented return value [Wise2_AlnBlock *] * */ Wise2_AlnBlock * Wise2_Align_Proteins_SmithWaterman( Wise2_Protein * one,Wise2_Protein * two,Wise2_CompMat * comp,int gap,int ext,Wise2_DPEnvelope * dpenv,Wise2_DPRunImpl * dpri); /* Function: Wise2_Align_Proteins_ABC(one,two,comp,a,b,c,dpenv,dpri) * * Descrip: Analogous to Align_Proteins_SmithWaterman for ABC model * * * Arg: one protein to align [Wise2_Protein *] * Arg: two protein to align [Wise2_Protein *] * Arg: comp comparison matrix [Wise2_CompMat *] * Arg: a generalized affine gap cost a [int] * Arg: b generalized affine gap cost b [int] * Arg: c generalized affine gap cost c [int] * Arg: dpenv Undocumented argument [Wise2_DPEnvelope *] * Arg: dpri Undocumented argument [Wise2_DPRunImpl *] * * Returns Undocumented return value [Wise2_AlnBlock *] * */ Wise2_AlnBlock * Wise2_Align_Proteins_ABC( Wise2_Protein * one,Wise2_Protein * two,Wise2_CompMat * comp,int a,int b,int c,Wise2_DPEnvelope * dpenv,Wise2_DPRunImpl * dpri); /* Function: Wise2_Align_Sequences_ProteinABC(one,two,comp,a,b,c,dpenv,dpri) * * Descrip: Align_Sequences_ProteinABC * this function is analogous to Align_Sequences_ProteinSmithWaterman * but using the abc model * * * Arg: one Sequence to align [Wise2_Sequence *] * Arg: two Sequence to align [Wise2_Sequence *] * Arg: comp Comparison Matrix [Wise2_CompMat *] * Arg: a genearlized affine gap cost [int] * Arg: b genearlized affine gap cost [int] * Arg: c genearlized affine gap cost [int] * Arg: dpenv Undocumented argument [Wise2_DPEnvelope *] * Arg: dpri Undocumented argument [Wise2_DPRunImpl *] * * Returns Undocumented return value [Wise2_AlnBlock *] * */ Wise2_AlnBlock * Wise2_Align_Sequences_ProteinABC( Wise2_Sequence * one,Wise2_Sequence * two,Wise2_CompMat * comp,int a,int b,int c,Wise2_DPEnvelope * dpenv,Wise2_DPRunImpl * dpri); /* Function: Wise2_Hscore_from_ProteinSW(querydb,targetdb,comp,gap,ext,bits_cutoff,report_level,die_on_error,dbsi) * * Descrip: Runs a database psw search * * * Arg: querydb query database [Wise2_ProteinDB*] * Arg: targetdb target database [Wise2_ProteinDB*] * Arg: comp comparison matrix [Wise2_CompMat*] * Arg: gap gap penalty [int] * Arg: ext extension penalty [int] * Arg: bits_cutoff [double] * Arg: report_level [int] * Arg: die_on_error [boolean] * Arg: dbsi [Wise2_DBSearchImpl*] * * Returns Undocumented return value [Wise2_Hscore *] * */ Wise2_Hscore * Wise2_Hscore_from_ProteinSW( Wise2_ProteinDB* querydb,Wise2_ProteinDB* targetdb,Wise2_CompMat* comp,int gap,int ext,double bits_cutoff,int report_level,boolean die_on_error,Wise2_DBSearchImpl* dbsi); /* Function: Wise2_Hscore_from_ProteinABC(querydb,targetdb,comp,a,b,c,bits_cutoff,report_level,die_on_error,dbsi) * * Descrip: Runs a database abc search * * * Arg: querydb query database [Wise2_ProteinDB*] * Arg: targetdb target database [Wise2_ProteinDB*] * Arg: comp comparison matrix [Wise2_CompMat*] * Arg: a generalized affine gap cost a [int] * Arg: b generalized affine gap cost b [int] * Arg: c generalized affine gap cost c [int] * Arg: bits_cutoff [double] * Arg: report_level [int] * Arg: die_on_error [boolean] * Arg: dbsi [Wise2_DBSearchImpl*] * * Returns Undocumented return value [Wise2_Hscore *] * */ Wise2_Hscore * Wise2_Hscore_from_ProteinABC( Wise2_ProteinDB* querydb,Wise2_ProteinDB* targetdb,Wise2_CompMat* comp,int a,int b,int c,double bits_cutoff,int report_level,boolean die_on_error,Wise2_DBSearchImpl* dbsi); /* Function: Wise2_Hscore_from_ProteinBA(querydb,targetdb,comp,bentry,bexit,bfor_trans,b_self_trans,b3exit,bits_cutoff,report_level,dbsi) * * Descrip: Runs a database pba search * * * Arg: querydb query database [Wise2_ProteinDB*] * Arg: targetdb target database [Wise2_ProteinDB*] * Arg: comp comparison matrix [Wise2_CompMat*] * Arg: bentry [Score] * Arg: bexit [Score] * Arg: bfor_trans [Score] * Arg: b_self_trans [Score] * Arg: b3exit [Score] * Arg: bits_cutoff [double] * Arg: report_level [int] * Arg: dbsi [Wise2_DBSearchImpl*] * * Returns Undocumented return value [Wise2_Hscore *] * */ Wise2_Hscore * Wise2_Hscore_from_ProteinBA( Wise2_ProteinDB* querydb,Wise2_ProteinDB* targetdb,Wise2_CompMat* comp,Score bentry,Score bexit,Score bfor_trans,Score b_self_trans,Score b3exit,double bits_cutoff,int report_level,Wise2_DBSearchImpl* dbsi); wise-2.4.1/src/models/sw_wrap_api.t0000644000175000001440000000000010670453715016621 0ustar philippuserswise-2.4.1/src/models/gwrap.c0000644000175000001440000005636610670453714015436 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "gwrap.h" /* Function: GeneParameter21_wrap(gf,subs_error,indel_error,rmd,use_modelled_codon,use_modelled_splice,tie_intron_prob,ct,rnd_loop,cds_loop,rnd_to_model,link_loop,link_to_model) * * Descrip: A general wrap over the production of parameters for the * GeneWise programs. The geneparameter21 holds all the parameters, * and can be approximated for the 6:23 and 4:21 algorithms * * This function is the best way to make a GeneParameter21 object * as all the different options for how to make it or modify its * contents are laid out as arguments to this function * * * Arg: gf [READ ] Gene Frequency data structure, holding counts for splice sites etc [GeneFrequency21 *] * Arg: subs_error [UNKN ] substitution error on the dna sequence [double] * Arg: indel_error [UNKN ] rough estimate of the insertion/deletion per base error rate [double] * Arg: rmd [UNKN ] the random model of the DNA that is used [RandomModelDNA *] * Arg: use_modelled_codon [UNKN ] if TRUE, model codon frequency [boolean] * Arg: use_modelled_splice [UNKN ] if TRUE, make splice models from gf parameters [boolean] * Arg: tie_intron_prob [UNKN ] Undocumented argument [boolean] * Arg: ct [UNKN ] codon table which is used for codon->aa mapping [CodonTable *] * Arg: rnd_loop [UNKN ] Undocumented argument [Probability] * Arg: cds_loop [UNKN ] Undocumented argument [Probability] * Arg: rnd_to_model [UNKN ] Undocumented argument [Probability] * Arg: link_loop [UNKN ] Undocumented argument [Probability] * Arg: link_to_model [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] A newly allocated structure [GeneParameter21 *] * */ # line 71 "gwrap.dy" GeneParameter21 * GeneParameter21_wrap(GeneFrequency21 * gf,double subs_error,double indel_error,RandomModelDNA * rmd,boolean use_modelled_codon,boolean use_modelled_splice,boolean tie_intron_prob,CodonTable * ct,Probability rnd_loop,Probability cds_loop,Probability rnd_to_model,Probability link_loop,Probability link_to_model) { GeneParameter21 * out; int i; out = GeneParameter21_from_GeneFrequency21(gf,ct,rmd,rnd_loop,cds_loop,rnd_to_model,link_loop,link_to_model); if( use_modelled_codon == FALSE ) { out->cm = free_CodonMapper(out->cm); out->cm = flat_CodonMapper(ct); } if( use_modelled_splice == FALSE ) { out->cses = free_ComplexSequenceEvalSet(out->cses); out->cses = default_genomic_ComplexSequenceEvalSet(); out->modelled_splice = FALSE; } if( tie_intron_prob == TRUE ) { for(i=0;i<5;i++) out->gp->central[i] = rmd->base[i]; } /*** errors ***/ sprinkle_errors_over_CodonMapper(out->cm,subs_error); add_flat_error_probabilities_GeneParser21(out->gp,indel_error); GeneParser21_fold_in_RandomModelDNA(out->gp,rmd); fold_in_RandomModelDNA_into_RandomCodon(out->rc,rmd); return out; } /* Function: AlnBlock_from_protein_genewise_wrap(protein,pg,is_global,dna,comp,gap,ext,gpara,rmd,intergenic,alg,use_syn,rm,allN,startendmode,dpri,pal,gwp) * * Descrip: A function which aligns a Protein sequecne to a Genomic sequence * under the Comparison matrix comp and the gene paras in gpara. * * This is the best function for accessing GeneWise functionality * for a protein to dna comparison, allowing for introns. * * To make the protein object, you will first read in a generic * sequence object using something like read_fasta_Sequence and * then convert it to a protein object using new_Protein_from_Sequence * * To make the genomic object, you will first read in a generic * sequence object using something like read_fasta_Sequence and * then convert it to a genomic object using new_Genomic_from_Sequence * * To make a CompMat object you will use read_Blast_file_CompMat * from the compmat module. It is likely, if the Wise2 enviroment * has been set up correctly that read_Blast_file_CompMat("blosum62.bla") * will be fine. You should at the moment only use halfbit matrices * (blosum62 is one such matrix) * * To make the necessary random modules use the default construtors * in the randommodel module * * To make the gene parameter object use the GeneParameter21_wrap * function found in this module. It will need GeneFrequencies * read in using the read_GeneFrequency21_file function in * the genefrequency module. Again if Wise2 has been set up * correctly, read_GeneFrequency21_file("human.gf") should work * * To again a valid algorithm type use gwrap_alg_type_from_string * found in this module. gwrap_alg_type_from_string("623") would * be a good choice * * * This function basically makes a threestatemodel (standard HMM) from * the protein and the comparison matrix with the *scary* assumption that * the comparison matrix is in half bit form. It then calls * /AlnBlock_from_TSM_genewise_wrap to do the nasty stuff. * * * Arg: protein [UNKN ] protein sequence used in the comparison [Protein *] * Arg: pg [READ ] Potential gene - could be NULL - if rough exon positions are known [NullString] * Arg: is_global [UNKN ] has now become flag for local/global/end-biased switch [NullString] * Arg: dna [UNKN ] genomic DNA sequence used [Genomic *] * Arg: comp [UNKN ] protein comparison matrix *in half bits* [CompMat *] * Arg: gap [UNKN ] gap penalty (negative) [int] * Arg: ext [UNKN ] extension penalty (negative) [int] * Arg: gpara [UNKN ] Gene parameters. [GeneParameter21 *] * Arg: rmd [UNKN ] models to be compared to [RandomModelDNA *] * Arg: intergenic [UNKN ] model of random dna between genes [RandomModelDNA *] * Arg: alg [UNKN ] algorithm type [int] * Arg: use_syn [UNKN ] Undocumented argument [boolean] * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: startendmode [UNKN ] Undocumented argument [TSM_StartEndMode] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * Arg: pal [WRITE] Raw alginment to be saved if non-NULL [PackAln **] * Arg: gwp [UNKN ] Undocumented argument [GeneWiseRunPara *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 161 "gwrap.dy" AlnBlock * AlnBlock_from_protein_genewise_wrap(Protein * protein,Genomic * dna,CompMat * comp,int gap,int ext,GeneParameter21 * gpara,RandomModelDNA * rmd,RandomModelDNA * intergenic,int alg,boolean use_syn,RandomModel * rm,Probability allN,TSM_StartEndMode startendmode,DPRunImpl * dpri,PackAln ** pal,GeneWiseRunPara * gwp) { ThreeStateModel * tsm; RandomModel * rm2; AlnBlock * out; DPEnvelope * dpenv = NULL; if( protein == NULL || dna == NULL || comp == NULL || gpara == NULL || rmd == NULL ){ warn("trappable error in PackAln from protein sequence, passed some NULL objects, Complain!"); return NULL; } assert(dpri); rm2 = default_RandomModel(); if( gwp->use_hsp == TRUE ) { dpenv = DPEnvelope_from_protein_gen(protein->baseseq,dna->baseseq,comp,gpara->ct,gwp); } if( startendmode == TSM_default ) { startendmode = TSM_endbiased; } tsm = ThreeStateModel_from_half_bit_Sequence(protein,comp,rm2,gap,ext); set_startend_policy_ThreeStateModel(tsm,startendmode,30,halfbit2Probability(-15)); out = AlnBlock_from_TSM_genewise_wrap(tsm,dna,gpara,rmd,intergenic,use_syn,alg,allN,1,dpri,pal,dpenv); free_ThreeStateModel(tsm); free_RandomModel(rm2); return out; } /* Function: AlnBlock_from_TSM_genewise_wrap(tsm,gen,gpara,rmd,intergenic,use_syn,alg,allN,flat_insert,dpri,palpoi,dpenv) * * Descrip: A function which aligns a protein HMM (as found * in my threestatemodel structure) to a genomic DNA * sequence. * * At the moment you are unlikely to be reading in the * HMM structure yourself, so this is not something * you will be doing. * * The core algorithms for each method are found in * genewise21/geneloop21 etc files. * * * * Arg: tsm [UNKN ] protein TSM to be used in the comparison [ThreeStateModel *] * Arg: gen [UNKN ] genomic DNA sequence used [Genomic *] * Arg: gpara [UNKN ] Gene parameters. [GeneParameter21 *] * Arg: rmd [UNKN ] models to be compared to [RandomModelDNA *] * Arg: intergenic [UNKN ] model of random dna between genes [RandomModelDNA *] * Arg: use_syn [UNKN ] use a synchronous null model [boolean] * Arg: alg [UNKN ] algorithm type [int] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: flat_insert [UNKN ] Undocumented argument [boolean] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * Arg: palpoi [WRITE] Raw alginment to be saved if non-NULL [PackAln **] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 220 "gwrap.dy" AlnBlock * AlnBlock_from_TSM_genewise_wrap(ThreeStateModel * tsm,Genomic * gen,GeneParameter21 * gpara,RandomModelDNA * rmd,RandomModelDNA * intergenic,boolean use_syn,int alg,Probability allN,boolean flat_insert,DPRunImpl * dpri,PackAln ** palpoi,DPEnvelope * dpenv) { AlnBlock * out = NULL; PackAln * pal = NULL; ComplexSequence * cs = NULL; GeneWise * gw = NULL; GeneWiseScore * gws = NULL; RandomCodonScore * rcs = NULL ; GeneParser21Score * gps = NULL; GeneParser4Score * gp4s = NULL; RandomModelDNAScore * ids = NULL; GeneralGeneModelScore * ggms = NULL; /* for stretch models */ Sequence * dna; cDNAParserScore * cps = NULL; /* for estwise type algorithms */ GwLite * gwl = NULL; GwLiteScore * gwls = NULL; ComplexSequenceEval * tempcse; ComplexSequenceEvalSet * cses; dna = gen->baseseq; assert(tsm); assert(gen); assert(gpara); assert(rmd); assert(gpara->rc); assert(dpri); /*show_Genomic(gen,stderr);*/ /*show_GeneParser21(gpara->gp,stderr); */ if( tsm == NULL || dna == NULL || gpara == NULL || rmd == NULL){ warn("trappable error in PackAln from TSM sequence, passed some NULL objects, Complain!"); return NULL; } /*** prepare cses ***/ if( prepare_ComplexSequenceEvalSet(gpara->cses) == FALSE ) { warn("Unable to prepare complexsequenceevalset in TMS2DNA wrap"); goto exit; } if( alg == GWWRAP_333 || alg == GWWRAP_333L ) { cses = default_cDNA_ComplexSequenceEvalSet(); cs = new_ComplexSequence(gen->baseseq,cses); free_ComplexSequenceEvalSet(cses); } else if ( alg == GWWRAP_6LITE ) { /* yup. This is scary. */ tempcse = gpara->cses->cse[1]; gpara->cses->cse[1] = codon64_number_ComplexSequenceEval(); cs = new_ComplexSequence(gen->baseseq,gpara->cses); free_ComplexSequenceEval(gpara->cses->cse[1]); gpara->cses->cse[1] = tempcse; } else { if( (cs=evaluate_ComplexSequence_Genomic(gen,gpara->cses,0,Probability2Score(0.01))) == FALSE ) { warn("Unable to make ComplexSequence in TMS2DNA wrap"); goto exit; } } /*show_ComplexSequence(cs,stderr);*/ if( (gw=GeneWise_from_ThreeStateModel(tsm,gpara->gp,gpara->cm,allN,gpara->gwcm)) == NULL) { warn("Unable to make GeneWise model"); goto exit; } flatten_balance_scores_GeneWise(gw); /* show_GeneWiseSegment(gw->seg[0],stderr); */ if( use_syn == TRUE ) { if( tsm->rm == NULL ) { warn("Ugh - a threestatemodel without a random model. Not in this code matey"); goto exit; } GeneWise_fold_in_synchronised_RandomModel(gw,tsm->rm,gpara->cm,gpara->ct,0.5); flatten_RandomCodon(gpara->rc); } else { GeneWise_fold_in_RandomModelDNA(gw,rmd); } if( alg == GWWRAP_6LITE ) { gwl = GwLite_from_GeneWise(gw); gwls = GwLiteScore_from_GwLite(gwl); } if( flat_insert == TRUE ) { check_flat_insert(gw,1,0,gpara->cm->ct); } if( (gws = GeneWiseScore_from_GeneWise(gw)) == NULL) { warn("Unable to make GeneWiseScore model"); goto exit; } if( (gps = GeneParser21Score_from_GeneParser21(gpara->gp)) == NULL) { warn("Unable to make GeneParserScore model"); goto exit; } if( (rcs = RandomCodonScore_from_RandomCodon(gpara->rc)) == NULL) { warn("Unable to make RandomCodonScore model"); goto exit; } ids = folded_RandomModelDNAScore_from_2RMD(intergenic,rmd); gp4s = GeneParser4Score_from_GeneParser21Score(gps); gp4s->transition[GP4_INTRON2CDS] = Probability2Score(halfbit2Probability((-12+(5*-2)))); if( alg == GWWRAP_333 || alg == GWWRAP_333L ) { cps = cDNAParserScore_from_GeneParser21Score(gps); } if( alg == GWWRAP_623S ) { ggms = vanilla_GeneralGeneModelScore(gpara->ct,Bits2Probability(10),1.0,Bits2Probability(10)); } switch(alg) { case GWWRAP_2193 : pal = PackAln_bestmemory_GeneWise21(gws,cs,gps,rcs,ids,dpenv,dpri); out = convert_PackAln_to_AlnBlock_GeneWise21(pal); break; case GWWRAP_2193I : warn("Algorithm currently disabled! Sorry!"); break; /** pal = PackAln_dc_build_GeneLinker21(gws,cs,gps,rcs,ids); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneLinker21(pal,NULL); break; **/ case GWWRAP_2193L : pal = PackAln_bestmemory_GeneLoop21(gws,cs,gps,rcs,ids,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneLoop21(pal); break; case GWWRAP_623L : pal = PackAln_bestmemory_GeneLoop6(gws,cs,gp4s,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneLoop6(pal); break; case GWWRAP_623 : /* if( *palpoi != NULL ) { warn("For genewise623, Using given packaln, not calculating!"); pal = *palpoi; } else { pal = PackAln_bestmemory_GeneWise6(gws,cs,gp4s,dpenv,dpri); } */ gp4s->transition[GP4_INTRON2INTRON] = 0; /*fprintf(stderr,"Got intron2intron score of %d\n",gp4s->transition[GP4_INTRON2INTRON]);*/ pal = PackAln_bestmemory_GeneWise6(gws,cs,gp4s,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneWise6(pal); break; case GWWRAP_623S : pal = PackAln_bestmemory_GeneStretch6(gws,cs,gp4s,ggms,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneStretch6(pal); break; case GWWRAP_333 : cps = cDNAParserScore_from_GeneParser21Score(gps); pal = PackAln_bestmemory_EstWise3(gws,cs,cps,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_EstWise3(pal); break; case GWWRAP_333L : cps = cDNAParserScore_from_GeneParser21Score(gps); pal = PackAln_bestmemory_EstLoop3(gws,cs,cps,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_EstLoop3(pal); break; case GWWRAP_421 : pal = PackAln_bestmemory_GeneWise4(gws,cs,gp4s,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneWise4(pal); break; case GWWRAP_6LITE : pal = PackAln_bestmemory_GeneLiteModel(gwls,cs,gp4s,dpenv,dpri); if(pal == NULL) goto exit; out = convert_PackAln_to_AlnBlock_GeneLiteModel(pal); GwLite_AlnBlock_surgery(out); break; default : warn("A major problem. No valid algorithm type passed in"); goto exit; } map_phase0_codons_AlnBlock_GeneWise(out,gws,cs); if( palpoi != NULL ) { *palpoi = pal; pal = NULL; } goto exit; exit : if(pal != NULL) pal = free_PackAln(pal); if( cps != NULL ) cps = free_cDNAParserScore(cps); if( ids != NULL ) ids = free_RandomModelDNAScore(ids); if(cs != NULL ) cs = free_ComplexSequence(cs); if(gw != NULL ) gw = free_GeneWise(gw); if(gws != NULL ) gws = free_GeneWiseScore(gws); if(gps != NULL ) free_GeneParser21Score(gps); if(rcs != NULL ) rcs = free_RandomCodonScore(rcs); if(gp4s != NULL) gp4s = free_GeneParser4Score(gp4s); if( ggms != NULL ) ggms = free_GeneralGeneModelScore(ggms); return out; } /* Function: Hscore_from_TSM_genewise(tdb,gdb,gpara,rmd,intergenic,use_syn,alg,bits_cutoff,allN,report_level,die_on_error,flat_insert,dbsi) * * Descrip: Runs a database search of the genewise algorithm. * * This makes a high score object which you can then use * to retrieve enteries as well as print out the top score (!) * * * Arg: tdb [READ ] a database of profileHMMs [ThreeStateDB *] * Arg: gdb [READ ] a database of genomic sequence [GenomicDB *] * Arg: gpara [READ ] geneparameters [GeneParameter21 *] * Arg: rmd [READ ] random model to be compared with in non syn mode [RandomModelDNA *] * Arg: intergenic [READ ] random model of intergenic DNA (usually the same as rmd) [RandomModelDNA *] * Arg: use_syn [UNKN ] use synchronous random model [boolean] * Arg: alg [UNKN ] algorithm type [int] * Arg: bits_cutoff [UNKN ] cutoff in bits of the scores to store [double] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: report_level [UNKN ] stagger rate of reporting progress on stderr -1 means never [int] * Arg: die_on_error [UNKN ] if true, exits on error (not used at the moment) [boolean] * Arg: flat_insert [UNKN ] Undocumented argument [boolean] * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * * Return [UNKN ] a new Hscore object of the entire db search [Hscore *] * */ # line 515 "gwrap.dy" Hscore * Hscore_from_TSM_genewise(ThreeStateDB * tdb,GenomicDB * gdb,GeneParameter21 * gpara,RandomModelDNA * rmd,RandomModelDNA * intergenic,boolean use_syn,int alg,double bits_cutoff,Probability allN,int report_level,boolean die_on_error,boolean flat_insert,DBSearchImpl * dbsi) { Hscore * out = NULL; GeneWiseDB * gwdb = NULL; cDNADB * cdb = NULL; cDNAParserScore * cps= NULL; GeneParser21Score * gps = NULL; GeneParser4Score * gp4s = NULL; RandomCodonScore * rcs = NULL; RandomModelDNAScore * ids = NULL; cDNA * temp; Search_Return_Type ret; ComplexSequenceEval * tempcse; ret = SEARCH_ERROR; gwdb = new_GeneWiseDB(tdb,gpara,rmd,use_syn,allN); gwdb->flat_insert = flat_insert; if( gwdb == NULL ) { warn("Could not build a new GeneWiseDB from the objects provided. Exiting without completing the search"); goto exit; } if( (gps = GeneParser21Score_from_GeneParser21(gpara->gp)) == NULL) { warn("Unable to make GeneParserScore model"); goto exit; } if( (rcs = RandomCodonScore_from_RandomCodon(gpara->rc)) == NULL) { warn("Unable to make RandomCodonScore model"); goto exit; } ids = folded_RandomModelDNAScore_from_2RMD(intergenic,rmd); gp4s = GeneParser4Score_from_GeneParser21Score(gps); if( alg == GWWRAP_333 || alg == GWWRAP_333L ) { /* could be a single dna sequence */ if( gdb->is_single_seq == TRUE ) { temp = cDNA_from_Sequence(hard_link_Sequence(gdb->forw->seq)); cdb = new_cDNADB_from_single_seq(temp); free_cDNA(temp); /* hard linked by database */ } else { cdb = new_cDNADB(gdb->sdb); } } /*** allocate Hscore structure ***/ out = std_bits_Hscore(bits_cutoff,report_level); switch(alg) { case GWWRAP_2193 : ret = Wise2_search_GeneWise21(dbsi,out,gwdb,gdb,gps,rcs,ids); break; case GWWRAP_2193I : warn("Algorithm currently disabled! Sorry!"); break; case GWWRAP_2193L : warn("Unable to do db looping searches (sort of - pointless - )!"); break; case GWWRAP_623L : warn("Unable to do db looping searches (sort of - pointless - )!"); break; case GWWRAP_623 : ret = Wise2_search_GeneWise6(dbsi,out,gwdb,gdb,gp4s); break; case GWWRAP_6LITE : ret = Wise2_search_GeneLiteModel(dbsi,out,gwdb,gdb,gp4s); break; case GWWRAP_333 : cps = cDNAParserScore_from_GeneParser21Score(gps); ret = search_EstWise3(dbsi,out,gwdb,cdb,cps); break; case GWWRAP_333L : warn("Unable to do db looping searches (sort of - pointless - )!"); break; case GWWRAP_421 : ret = Wise2_search_GeneWise4(dbsi,out,gwdb,gdb,gp4s); break; default : warn("A major problem. No valid algorithm type passed in"); goto exit; } goto exit; exit : /* for 6LITE leaking a tiny amount of memory. Oh well... */ if( ids != NULL ) ids = free_RandomModelDNAScore(ids); if( cps != NULL ) free_cDNAParserScore(cps); if( cdb != NULL ) free_cDNADB(cdb); if(gps != NULL ) free_GeneParser21Score(gps); if(rcs != NULL ) rcs = free_RandomCodonScore(rcs); if(gp4s != NULL) gp4s = free_GeneParser4Score(gp4s); if( gwdb != NULL ) { free_GeneWiseDB(gwdb); } if( die_on_error == TRUE && ret == SEARCH_ERROR) { if( out != NULL ) { free_Hscore(out); } return NULL; } return out; } /* Function: cDNAParserScore_from_GeneParser21Score(gps) * * Descrip: Makes a cdna parser from a genewise parser. Basically * copies the indel penalties across. * * * Arg: gps [UNKN ] Undocumented argument [GeneParser21Score *] * * Return [UNKN ] Undocumented return value [cDNAParserScore *] * */ # line 661 "gwrap.dy" cDNAParserScore * cDNAParserScore_from_GeneParser21Score(GeneParser21Score * gps) { cDNAParserScore * out; out = cDNAParserScore_alloc(); out->trans[PCD_INSERT_2_BASE] = gps->transition[GP21_INSERT_2_BASE]; out->trans[PCD_INSERT_1_BASE] = gps->transition[GP21_INSERT_1_BASE]; out->trans[PCD_DELETE_2_BASE] = gps->transition[GP21_DELETE_2_BASE]; out->trans[PCD_DELETE_1_BASE] = gps->transition[GP21_DELETE_1_BASE]; return out; } /* Function: gwrap_alg_type_from_string(str) * * Descrip: Gives you the integer interpretation from * the string, which is one of * 2193 2193L, 623, 623L, 421, 2193LINK * * This integer can then be passed into routines * like AlnBlock_from_protein_genewise_wrap * * * * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 685 "gwrap.dy" int gwrap_alg_type_from_string(char * str) { int t; t = get_number_from_slashed_string(str,"2193/2193L/623/623L/421/2193LINK/333/333L/6LITE/623S/623P"); switch (t) { case 0 : return GWWRAP_2193; case 1 : return GWWRAP_2193L; case 2 : return GWWRAP_623; case 3 : return GWWRAP_623L; case 4 : return GWWRAP_421; case 5 : return GWWRAP_2193I; case 6 : return GWWRAP_333; case 7 : return GWWRAP_333L; case 8 : return GWWRAP_6LITE; case 9 : return GWWRAP_623S; case 10 : return GWWRAP_623P; default : warn("Cannot convert string %s into a valid genewise algorithm type\n",str); return -1; } } # line 707 "gwrap.c" #ifdef _cplusplus } #endif wise-2.4.1/src/models/gwrap.h0000644000175000001440000003015710670453714015431 0ustar philippusers#ifndef DYNAMITEgwrapHEADERFILE #define DYNAMITEgwrapHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "genewise6.h" #include "geneloop6.h" #include "genestretch6.h" #include "genewise4.h" #include "gwlite.h" #include "geneutil.h" #include "genewise21.h" #include "geneloop21.h" /** #include "genelink21.h" **/ #include "geneparameter.h" #include "genefrequency.h" #include "genestats.h" #include "seqhit.h" #include "estwise3.h" #include "estloop3.h" #include "genewisehsp.h" enum GWWRAP_ALG_TYPE { GWWRAP_2193 = 12, GWWRAP_2193L, GWWRAP_2193I, GWWRAP_623, GWWRAP_623L, GWWRAP_421, GWWRAP_6LITE, GWWRAP_333, GWWRAP_333L, GWWRAP_623S, GWWRAP_623P }; /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: GeneParameter21_wrap(gf,subs_error,indel_error,rmd,use_modelled_codon,use_modelled_splice,tie_intron_prob,ct,rnd_loop,cds_loop,rnd_to_model,link_loop,link_to_model) * * Descrip: A general wrap over the production of parameters for the * GeneWise programs. The geneparameter21 holds all the parameters, * and can be approximated for the 6:23 and 4:21 algorithms * * This function is the best way to make a GeneParameter21 object * as all the different options for how to make it or modify its * contents are laid out as arguments to this function * * * Arg: gf [READ ] Gene Frequency data structure, holding counts for splice sites etc [GeneFrequency21 *] * Arg: subs_error [UNKN ] substitution error on the dna sequence [double] * Arg: indel_error [UNKN ] rough estimate of the insertion/deletion per base error rate [double] * Arg: rmd [UNKN ] the random model of the DNA that is used [RandomModelDNA *] * Arg: use_modelled_codon [UNKN ] if TRUE, model codon frequency [boolean] * Arg: use_modelled_splice [UNKN ] if TRUE, make splice models from gf parameters [boolean] * Arg: tie_intron_prob [UNKN ] Undocumented argument [boolean] * Arg: ct [UNKN ] codon table which is used for codon->aa mapping [CodonTable *] * Arg: rnd_loop [UNKN ] Undocumented argument [Probability] * Arg: cds_loop [UNKN ] Undocumented argument [Probability] * Arg: rnd_to_model [UNKN ] Undocumented argument [Probability] * Arg: link_loop [UNKN ] Undocumented argument [Probability] * Arg: link_to_model [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] A newly allocated structure [GeneParameter21 *] * */ GeneParameter21 * Wise2_GeneParameter21_wrap(GeneFrequency21 * gf,double subs_error,double indel_error,RandomModelDNA * rmd,boolean use_modelled_codon,boolean use_modelled_splice,boolean tie_intron_prob,CodonTable * ct,Probability rnd_loop,Probability cds_loop,Probability rnd_to_model,Probability link_loop,Probability link_to_model); #define GeneParameter21_wrap Wise2_GeneParameter21_wrap /* Function: AlnBlock_from_protein_genewise_wrap(protein,pg,is_global,dna,comp,gap,ext,gpara,rmd,intergenic,alg,use_syn,rm,allN,startendmode,dpri,pal,gwp) * * Descrip: A function which aligns a Protein sequecne to a Genomic sequence * under the Comparison matrix comp and the gene paras in gpara. * * This is the best function for accessing GeneWise functionality * for a protein to dna comparison, allowing for introns. * * To make the protein object, you will first read in a generic * sequence object using something like read_fasta_Sequence and * then convert it to a protein object using new_Protein_from_Sequence * * To make the genomic object, you will first read in a generic * sequence object using something like read_fasta_Sequence and * then convert it to a genomic object using new_Genomic_from_Sequence * * To make a CompMat object you will use read_Blast_file_CompMat * from the compmat module. It is likely, if the Wise2 enviroment * has been set up correctly that read_Blast_file_CompMat("blosum62.bla") * will be fine. You should at the moment only use halfbit matrices * (blosum62 is one such matrix) * * To make the necessary random modules use the default construtors * in the randommodel module * * To make the gene parameter object use the GeneParameter21_wrap * function found in this module. It will need GeneFrequencies * read in using the read_GeneFrequency21_file function in * the genefrequency module. Again if Wise2 has been set up * correctly, read_GeneFrequency21_file("human.gf") should work * * To again a valid algorithm type use gwrap_alg_type_from_string * found in this module. gwrap_alg_type_from_string("623") would * be a good choice * * * This function basically makes a threestatemodel (standard HMM) from * the protein and the comparison matrix with the *scary* assumption that * the comparison matrix is in half bit form. It then calls * /AlnBlock_from_TSM_genewise_wrap to do the nasty stuff. * * * Arg: protein [UNKN ] protein sequence used in the comparison [Protein *] * Arg: pg [READ ] Potential gene - could be NULL - if rough exon positions are known [NullString] * Arg: is_global [UNKN ] has now become flag for local/global/end-biased switch [NullString] * Arg: dna [UNKN ] genomic DNA sequence used [Genomic *] * Arg: comp [UNKN ] protein comparison matrix *in half bits* [CompMat *] * Arg: gap [UNKN ] gap penalty (negative) [int] * Arg: ext [UNKN ] extension penalty (negative) [int] * Arg: gpara [UNKN ] Gene parameters. [GeneParameter21 *] * Arg: rmd [UNKN ] models to be compared to [RandomModelDNA *] * Arg: intergenic [UNKN ] model of random dna between genes [RandomModelDNA *] * Arg: alg [UNKN ] algorithm type [int] * Arg: use_syn [UNKN ] Undocumented argument [boolean] * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: startendmode [UNKN ] Undocumented argument [TSM_StartEndMode] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * Arg: pal [WRITE] Raw alginment to be saved if non-NULL [PackAln **] * Arg: gwp [UNKN ] Undocumented argument [GeneWiseRunPara *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_AlnBlock_from_protein_genewise_wrap(Protein * protein,Genomic * dna,CompMat * comp,int gap,int ext,GeneParameter21 * gpara,RandomModelDNA * rmd,RandomModelDNA * intergenic,int alg,boolean use_syn,RandomModel * rm,Probability allN,TSM_StartEndMode startendmode,DPRunImpl * dpri,PackAln ** pal,GeneWiseRunPara * gwp); #define AlnBlock_from_protein_genewise_wrap Wise2_AlnBlock_from_protein_genewise_wrap /* Function: AlnBlock_from_TSM_genewise_wrap(tsm,gen,gpara,rmd,intergenic,use_syn,alg,allN,flat_insert,dpri,palpoi,dpenv) * * Descrip: A function which aligns a protein HMM (as found * in my threestatemodel structure) to a genomic DNA * sequence. * * At the moment you are unlikely to be reading in the * HMM structure yourself, so this is not something * you will be doing. * * The core algorithms for each method are found in * genewise21/geneloop21 etc files. * * * * Arg: tsm [UNKN ] protein TSM to be used in the comparison [ThreeStateModel *] * Arg: gen [UNKN ] genomic DNA sequence used [Genomic *] * Arg: gpara [UNKN ] Gene parameters. [GeneParameter21 *] * Arg: rmd [UNKN ] models to be compared to [RandomModelDNA *] * Arg: intergenic [UNKN ] model of random dna between genes [RandomModelDNA *] * Arg: use_syn [UNKN ] use a synchronous null model [boolean] * Arg: alg [UNKN ] algorithm type [int] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: flat_insert [UNKN ] Undocumented argument [boolean] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * Arg: palpoi [WRITE] Raw alginment to be saved if non-NULL [PackAln **] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_AlnBlock_from_TSM_genewise_wrap(ThreeStateModel * tsm,Genomic * gen,GeneParameter21 * gpara,RandomModelDNA * rmd,RandomModelDNA * intergenic,boolean use_syn,int alg,Probability allN,boolean flat_insert,DPRunImpl * dpri,PackAln ** palpoi,DPEnvelope * dpenv); #define AlnBlock_from_TSM_genewise_wrap Wise2_AlnBlock_from_TSM_genewise_wrap /* Function: Hscore_from_TSM_genewise(tdb,gdb,gpara,rmd,intergenic,use_syn,alg,bits_cutoff,allN,report_level,die_on_error,flat_insert,dbsi) * * Descrip: Runs a database search of the genewise algorithm. * * This makes a high score object which you can then use * to retrieve enteries as well as print out the top score (!) * * * Arg: tdb [READ ] a database of profileHMMs [ThreeStateDB *] * Arg: gdb [READ ] a database of genomic sequence [GenomicDB *] * Arg: gpara [READ ] geneparameters [GeneParameter21 *] * Arg: rmd [READ ] random model to be compared with in non syn mode [RandomModelDNA *] * Arg: intergenic [READ ] random model of intergenic DNA (usually the same as rmd) [RandomModelDNA *] * Arg: use_syn [UNKN ] use synchronous random model [boolean] * Arg: alg [UNKN ] algorithm type [int] * Arg: bits_cutoff [UNKN ] cutoff in bits of the scores to store [double] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: report_level [UNKN ] stagger rate of reporting progress on stderr -1 means never [int] * Arg: die_on_error [UNKN ] if true, exits on error (not used at the moment) [boolean] * Arg: flat_insert [UNKN ] Undocumented argument [boolean] * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * * Return [UNKN ] a new Hscore object of the entire db search [Hscore *] * */ Hscore * Wise2_Hscore_from_TSM_genewise(ThreeStateDB * tdb,GenomicDB * gdb,GeneParameter21 * gpara,RandomModelDNA * rmd,RandomModelDNA * intergenic,boolean use_syn,int alg,double bits_cutoff,Probability allN,int report_level,boolean die_on_error,boolean flat_insert,DBSearchImpl * dbsi); #define Hscore_from_TSM_genewise Wise2_Hscore_from_TSM_genewise /* Function: gwrap_alg_type_from_string(str) * * Descrip: Gives you the integer interpretation from * the string, which is one of * 2193 2193L, 623, 623L, 421, 2193LINK * * This integer can then be passed into routines * like AlnBlock_from_protein_genewise_wrap * * * * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_gwrap_alg_type_from_string(char * str); #define gwrap_alg_type_from_string Wise2_gwrap_alg_type_from_string /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ cDNAParserScore * Wise2_cDNAParserScore_from_GeneParser21Score(GeneParser21Score * gps); #define cDNAParserScore_from_GeneParser21Score Wise2_cDNAParserScore_from_GeneParser21Score #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/slimdba.dy0000644000175000001440000000264407463470702016113 0ustar philippusers %{ #include "dyna.h" %} matrix SlimDnaMatchBlock query type="DNA" name="query" target type="DNA" name="target" resource type="DnaMatrix*" name="comp65" resource type="Score" name="g" resource type="Score" name="u" resource type="Score" name="v" resource type="Score" name="s" resource type="Score" name="b" state MATCH65 source MATCH65 offi="1" offj="1" calc="comp65->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + s" endsource source MATCH65 offi="0" offj="1" calc="g" target_label MI65 endsource source MATCH65 offi="1" offj="0" calc="g" query_label MI65 endsource source UNMATCHED_TARGET offi="1" offj="1" calc="comp65->score[DNA_BASE(query,i)][DNA_BASE(target,j)] + v" endsource query_label MM65 target_label MM65 endstate state UNMATCHED_QUERY offi="1" offj="0" source MATCH65 calc="b" endsource source UNMATCHED_QUERY calc="u" endsource source START !top !left calc="0" endsource query_label UM target_label UI endstate state UNMATCHED_TARGET offi="0" offj="1" source UNMATCHED_QUERY calc="v" endsource source UNMATCHED_TARGET calc="u" endsource target_label UM query_label UI endstate state START !special !start query_label START target_label START endstate state END !special !end source UNMATCHED_TARGET !right !bottom calc="0" endsource query_label END target_label END endstate endmatrix wise-2.4.1/src/models/seqaligndisplay.c0000644000175000001440000001771410670453715017502 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "seqaligndisplay.h" /* Function: write_pretty_Protein_align(alb,q,t,name,main,ofp) * * Descrip: This gives an interface into the * alignment display using Protein * objects * * * Arg: alb [UNKN ] alignment structure [AlnBlock *] * Arg: q [UNKN ] first sequence [Protein *] * Arg: t [UNKN ] second sequence [Protein *] * Arg: name [UNKN ] length of the name block [int] * Arg: main [UNKN ] length of the main block [int] * Arg: ofp [UNKN ] output file [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 30 "seqaligndisplay.dy" boolean write_pretty_Protein_align(AlnBlock * alb,Protein * q,Protein * t,int name,int main,FILE * ofp) { if( alb == NULL || q == NULL || t == NULL ) { warn("NULL objects being passed into write_pretty_Protein_align"); return FALSE; } return write_pretty_seq_align(alb,q->baseseq,t->baseseq,name,main,ofp); } /* Function: write_pretty_seq_align(alb,q,t,name,main,ofp) * * Descrip: This gives an interface into the alignment * display using sequences and files. A more * generic function is write_pretty_str_align * * * Arg: alb [UNKN ] alignment structure [AlnBlock *] * Arg: q [UNKN ] first sequence [Sequence *] * Arg: t [UNKN ] second sequence [Sequence *] * Arg: name [UNKN ] length of the name block [int] * Arg: main [UNKN ] length of the main block [int] * Arg: ofp [UNKN ] output file [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 53 "seqaligndisplay.dy" boolean write_pretty_seq_align(AlnBlock * alb,Sequence * q,Sequence * t,int name,int main,FILE * ofp) { char qname[64]; char tname[64]; btCanvas * btc; if( alb == NULL || q == NULL || t == NULL ) { warn("NULL objects being passed into write_pretty_seq_align"); return FALSE; } if( name > 64 ) { warn("Sorry - hard coded limited, can't have names longer than 64"); return FALSE; } if( strlen(q->name) > name ) { warn("Name %s is longer than allowed name block (%d). Truncating\n",q->name,name); strncpy(qname,q->name,name); qname[name] = '\0'; } else { strcpy(qname,q->name); } if( strlen(t->name) > name ) { warn("Name %s is longer than allowed name block (%d). Truncating\n",t->name,name); strncpy(tname,t->name,name); tname[name] = '\0'; } else { strcpy(tname,t->name); } btc = new_Ascii_btCanvas(ofp,name+6,main,0,3); /*+6 in case we want to put in numbers */ write_pretty_str_align_btc(alb,qname,q->seq,tname,t->seq,btc); /** destroy btc canvas **/ free_btCanvas(btc); return TRUE; } /* Function: write_pretty_str_align(alb,qname,query,tname,target,name,main,ofp) * * Descrip: This gives an interface into the alignment * display using strings and files. * * * Arg: alb [UNKN ] alignment structure [AlnBlock *] * Arg: qname [UNKN ] name of first sequence [char *] * Arg: query [UNKN ] first sequence [char *] * Arg: tname [UNKN ] name of second sequence [char *] * Arg: target [UNKN ] second sequence [char *] * Arg: name [UNKN ] length of the name block [int] * Arg: main [UNKN ] length of the main block [int] * Arg: ofp [UNKN ] output file [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 111 "seqaligndisplay.dy" boolean write_pretty_str_align(AlnBlock * alb,char * qname,char * query,char * tname,char * target,int name,int main,FILE * ofp) { boolean out; btCanvas * btc; btc = new_Ascii_btCanvas(ofp,name+6,main,0,3); /*+6 in case we want to put in numbers */ out = write_pretty_str_align_btc(alb,qname,query,tname,target,btc); /** destroy btc canvas **/ free_btCanvas(btc); return out; } /* Function: write_pretty_str_align_btc(alb,qname,query,tname,target,btc) * * Descrip: This function writes precisely * what you expect for a a simple alignment. * * We can reuse this routine all over the place because * we dont use any hard coded structure for the * query or the target sequence letters. ... but crap * type checking it has to be said! * * Also we use a generic btCanvas that could have * any implementation underneath (eg, ASCII, postscript etc). * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: qname [UNKN ] Undocumented argument [char *] * Arg: query [UNKN ] Undocumented argument [char *] * Arg: tname [UNKN ] Undocumented argument [char *] * Arg: target [UNKN ] Undocumented argument [char *] * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 139 "seqaligndisplay.dy" boolean write_pretty_str_align_btc(AlnBlock * alb,char * qname,char * query,char * tname,char * target,btCanvas * btc) { AlnColumn * alc; AlnUnit * q; AlnUnit * t; char buffer[14]; btPasteArea * btp; for(alc=alb->start;alc != NULL;) { /** put names in **/ btp = get_reserved_left_btCanvas(btc); paste_string_btPasteArea(btp,0,0,qname,BC_RIGHT,0); paste_string_btPasteArea(btp,0,2,tname,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[0]->start+1+1); paste_string_btPasteArea(btp,12,0,buffer,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[1]->start+1+1); paste_string_btPasteArea(btp,12,2,buffer,BC_RIGHT,0); free_btPasteArea(btp); /** now loop over this block **/ for(;alc != NULL && can_get_paste_area_btCanvas(btc,1) == TRUE;alc=alc->next) { q = alc->alu[0]; t = alc->alu[1]; /* * at the end, break */ if( strcmp(q->text_label,"END") == 0 ) { alc = NULL; break; } if( strcmp(t->text_label,"LOOP") == 0 ) { advance_line_btCanvas(btc); for(;alc != NULL && strcmp(alc->alu[1]->text_label,"LOOP") == 0;alc = alc->next) { ; } break; } /* * Get the paste area, length 1, depth will be 3 */ btp = get_paste_area_btCanvas(btc,1); /* * Write in the query sequence * */ if( strcmp(q->text_label,"SEQUENCE") == 0 || strstr(q->text_label,"BOUND") != NULL ) { paste_char_btPasteArea(btp,0,0,((int)query[q->start+1]),0); } else if( strcmp(q->text_label,"UNMATCHED_SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,0,tolower((int)query[q->start+1]),0); } else { /** is insert- we could check **/ if( strcmp(q->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",q->text_label); paste_char_btPasteArea(btp,0,0,'?',0); } else { paste_char_btPasteArea(btp,0,0,'-',0); } } /* * Write in the target sequence * */ if( strcmp(t->text_label,"SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,2,toupper((int)target[t->start+1]),0); } else if( strcmp(t->text_label,"UNMATCHED_SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,2,tolower((int)target[t->start+1]),0); } else { /** is insert- we could check **/ if( strcmp(t->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",t->text_label); paste_char_btPasteArea(btp,0,2,'?',0); } else { paste_char_btPasteArea(btp,0,2,'-',0); } } /* * Match line */ if( strcmp(q->text_label,"SEQUENCE") == 0 && strcmp(t->text_label,"SEQUENCE") == 0 ) { if( q->score[0] > 0 ) { if( query[q->start+1] == target[t->start+1] ) { paste_char_btPasteArea(btp,0,1,target[t->start+1],0); } else { paste_char_btPasteArea(btp,0,1,'+',0); } } } else paste_char_btPasteArea(btp,0,1,' ',0); free_btPasteArea(btp); } /* end of for this block */ advance_line_btCanvas(btc); } /* end of for the alignment */ return TRUE; /* we never returned false. Ooops! */ } # line 271 "seqaligndisplay.c" #ifdef _cplusplus } #endif wise-2.4.1/src/models/seqaligndisplay.h0000644000175000001440000001057410670453715017504 0ustar philippusers#ifndef DYNAMITEseqaligndisplayHEADERFILE #define DYNAMITEseqaligndisplayHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: write_pretty_Protein_align(alb,q,t,name,main,ofp) * * Descrip: This gives an interface into the * alignment display using Protein * objects * * * Arg: alb [UNKN ] alignment structure [AlnBlock *] * Arg: q [UNKN ] first sequence [Protein *] * Arg: t [UNKN ] second sequence [Protein *] * Arg: name [UNKN ] length of the name block [int] * Arg: main [UNKN ] length of the main block [int] * Arg: ofp [UNKN ] output file [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_write_pretty_Protein_align(AlnBlock * alb,Protein * q,Protein * t,int name,int main,FILE * ofp); #define write_pretty_Protein_align Wise2_write_pretty_Protein_align /* Function: write_pretty_seq_align(alb,q,t,name,main,ofp) * * Descrip: This gives an interface into the alignment * display using sequences and files. A more * generic function is write_pretty_str_align * * * Arg: alb [UNKN ] alignment structure [AlnBlock *] * Arg: q [UNKN ] first sequence [Sequence *] * Arg: t [UNKN ] second sequence [Sequence *] * Arg: name [UNKN ] length of the name block [int] * Arg: main [UNKN ] length of the main block [int] * Arg: ofp [UNKN ] output file [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_write_pretty_seq_align(AlnBlock * alb,Sequence * q,Sequence * t,int name,int main,FILE * ofp); #define write_pretty_seq_align Wise2_write_pretty_seq_align /* Function: write_pretty_str_align(alb,qname,query,tname,target,name,main,ofp) * * Descrip: This gives an interface into the alignment * display using strings and files. * * * Arg: alb [UNKN ] alignment structure [AlnBlock *] * Arg: qname [UNKN ] name of first sequence [char *] * Arg: query [UNKN ] first sequence [char *] * Arg: tname [UNKN ] name of second sequence [char *] * Arg: target [UNKN ] second sequence [char *] * Arg: name [UNKN ] length of the name block [int] * Arg: main [UNKN ] length of the main block [int] * Arg: ofp [UNKN ] output file [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_write_pretty_str_align(AlnBlock * alb,char * qname,char * query,char * tname,char * target,int name,int main,FILE * ofp); #define write_pretty_str_align Wise2_write_pretty_str_align /* Function: write_pretty_str_align_btc(alb,qname,query,tname,target,btc) * * Descrip: This function writes precisely * what you expect for a a simple alignment. * * We can reuse this routine all over the place because * we dont use any hard coded structure for the * query or the target sequence letters. ... but crap * type checking it has to be said! * * Also we use a generic btCanvas that could have * any implementation underneath (eg, ASCII, postscript etc). * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: qname [UNKN ] Undocumented argument [char *] * Arg: query [UNKN ] Undocumented argument [char *] * Arg: tname [UNKN ] Undocumented argument [char *] * Arg: target [UNKN ] Undocumented argument [char *] * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_write_pretty_str_align_btc(AlnBlock * alb,char * qname,char * query,char * tname,char * target,btCanvas * btc); #define write_pretty_str_align_btc Wise2_write_pretty_str_align_btc /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/seqhit_api.h0000644000175000001440000003460010670453715016435 0ustar philippusers /* Functions that create, manipulate or act on DnaSequenceHitList * * Wise2_show_DnaSequenceHitList * Wise2_read_MSPcrunch_DnaSequenceHitList * Wise2_hard_link_DnaSequenceHitList * Wise2_DnaSequenceHitList_alloc * Wise2_replace_forward_DnaSequenceHitList * Wise2_access_forward_DnaSequenceHitList * Wise2_replace_backward_DnaSequenceHitList * Wise2_access_backward_DnaSequenceHitList * Wise2_free_DnaSequenceHitList [destructor] * */ /* Functions that create, manipulate or act on SegmentHitList * * Wise2_hard_link_SegmentHitList * Wise2_SegmentHitList_alloc_std * Wise2_access_seghit_SegmentHitList * Wise2_length_seghit_SegmentHitList * Wise2_flush_SegmentHitList * Wise2_add_SegmentHitList * Wise2_free_SegmentHitList [destructor] * */ /* Functions that create, manipulate or act on SegmentHit * * Wise2_hard_link_SegmentHit * Wise2_SegmentHit_alloc * Wise2_replace_name_SegmentHit * Wise2_access_name_SegmentHit * Wise2_replace_qstart_SegmentHit * Wise2_access_qstart_SegmentHit * Wise2_replace_qend_SegmentHit * Wise2_access_qend_SegmentHit * Wise2_replace_tstart_SegmentHit * Wise2_access_tstart_SegmentHit * Wise2_replace_tend_SegmentHit * Wise2_access_tend_SegmentHit * Wise2_replace_score_SegmentHit * Wise2_access_score_SegmentHit * Wise2_replace_next_hit_SegmentHit * Wise2_access_next_hit_SegmentHit * Wise2_free_SegmentHit [destructor] * */ /* API for object DnaSequenceHitList */ /* Function: Wise2_show_DnaSequenceHitList(dsl,ofp) * * Descrip: shows a DnaSequenceHitsList - * * only really useful for debugging * * * Arg: dsl Undocumented argument [Wise2_DnaSequenceHitList *] * Arg: ofp Undocumented argument [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_show_DnaSequenceHitList( Wise2_DnaSequenceHitList * dsl,FILE * ofp); /* Function: Wise2_read_MSPcrunch_DnaSequenceHitList(ifp) * * Descrip: Reads a MSPcrunch -x output file * * * Arg: ifp input file to read [FILE *] * * Returns newly allocated structure [Wise2_DnaSequenceHitList *] * */ Wise2_DnaSequenceHitList * Wise2_read_MSPcrunch_DnaSequenceHitList( FILE * ifp); /* Function: Wise2_hard_link_DnaSequenceHitList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_DnaSequenceHitList *] * * Returns Undocumented return value [Wise2_DnaSequenceHitList *] * */ Wise2_DnaSequenceHitList * Wise2_hard_link_DnaSequenceHitList( Wise2_DnaSequenceHitList * obj); /* Function: Wise2_DnaSequenceHitList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_DnaSequenceHitList *] * */ Wise2_DnaSequenceHitList * Wise2_DnaSequenceHitList_alloc(); /* Function: Wise2_replace_forward_DnaSequenceHitList(obj,forward) * * Descrip: Replace member variable forward * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DnaSequenceHitList *] * Arg: forward New value of the variable [Wise2_SegmentHitList *] * * Returns member variable forward [boolean] * */ boolean Wise2_replace_forward_DnaSequenceHitList( Wise2_DnaSequenceHitList * obj,Wise2_SegmentHitList * forward); /* Function: Wise2_access_forward_DnaSequenceHitList(obj) * * Descrip: Access member variable forward * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DnaSequenceHitList *] * * Returns member variable forward [Wise2_SegmentHitList *] * */ Wise2_SegmentHitList * Wise2_access_forward_DnaSequenceHitList( Wise2_DnaSequenceHitList * obj); /* Function: Wise2_replace_backward_DnaSequenceHitList(obj,backward) * * Descrip: Replace member variable backward * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DnaSequenceHitList *] * Arg: backward New value of the variable [Wise2_SegmentHitList *] * * Returns member variable backward [boolean] * */ boolean Wise2_replace_backward_DnaSequenceHitList( Wise2_DnaSequenceHitList * obj,Wise2_SegmentHitList * backward); /* Function: Wise2_access_backward_DnaSequenceHitList(obj) * * Descrip: Access member variable backward * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DnaSequenceHitList *] * * Returns member variable backward [Wise2_SegmentHitList *] * */ Wise2_SegmentHitList * Wise2_access_backward_DnaSequenceHitList( Wise2_DnaSequenceHitList * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_DnaSequenceHitList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_DnaSequenceHitList *] * * Returns Undocumented return value [Wise2_DnaSequenceHitList *] * */ Wise2_DnaSequenceHitList * Wise2_free_DnaSequenceHitList( Wise2_DnaSequenceHitList * obj); /* API for object SegmentHitList */ /* Function: Wise2_hard_link_SegmentHitList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_SegmentHitList *] * * Returns Undocumented return value [Wise2_SegmentHitList *] * */ Wise2_SegmentHitList * Wise2_hard_link_SegmentHitList( Wise2_SegmentHitList * obj); /* Function: Wise2_SegmentHitList_alloc_std(void) * * Descrip: Equivalent to SegmentHitList_alloc_len(SegmentHitListLISTLENGTH) * * * * Returns Undocumented return value [Wise2_SegmentHitList *] * */ Wise2_SegmentHitList * Wise2_SegmentHitList_alloc_std(); /* Function: Wise2_access_seghit_SegmentHitList(obj,i) * * Descrip: Access members stored in the seghit list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_SegmentHitList *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_SegmentHit *] * */ Wise2_SegmentHit * Wise2_access_seghit_SegmentHitList( Wise2_SegmentHitList * obj,int i); /* Function: Wise2_length_seghit_SegmentHitList(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_SegmentHitList *] * * Returns length of the list [int] * */ int Wise2_length_seghit_SegmentHitList( Wise2_SegmentHitList * obj); /* Function: Wise2_flush_SegmentHitList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_SegmentHitList *] * * Returns Undocumented return value [int] * */ int Wise2_flush_SegmentHitList( Wise2_SegmentHitList * obj); /* Function: Wise2_add_SegmentHitList(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_SegmentHitList *] * Arg: add Object to add to the list [Wise2_SegmentHit *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_SegmentHitList( Wise2_SegmentHitList * obj,Wise2_SegmentHit * add); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_SegmentHitList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_SegmentHitList *] * * Returns Undocumented return value [Wise2_SegmentHitList *] * */ Wise2_SegmentHitList * Wise2_free_SegmentHitList( Wise2_SegmentHitList * obj); /* API for object SegmentHit */ /* Function: Wise2_hard_link_SegmentHit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_SegmentHit *] * * Returns Undocumented return value [Wise2_SegmentHit *] * */ Wise2_SegmentHit * Wise2_hard_link_SegmentHit( Wise2_SegmentHit * obj); /* Function: Wise2_SegmentHit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_SegmentHit *] * */ Wise2_SegmentHit * Wise2_SegmentHit_alloc(); /* Function: Wise2_replace_name_SegmentHit(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * Arg: name New value of the variable [char *] * * Returns member variable name [boolean] * */ boolean Wise2_replace_name_SegmentHit( Wise2_SegmentHit * obj,char * name); /* Function: Wise2_access_name_SegmentHit(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * * Returns member variable name [char *] * */ char * Wise2_access_name_SegmentHit( Wise2_SegmentHit * obj); /* Function: Wise2_replace_qstart_SegmentHit(obj,qstart) * * Descrip: Replace member variable qstart * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * Arg: qstart New value of the variable [int] * * Returns member variable qstart [boolean] * */ boolean Wise2_replace_qstart_SegmentHit( Wise2_SegmentHit * obj,int qstart); /* Function: Wise2_access_qstart_SegmentHit(obj) * * Descrip: Access member variable qstart * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * * Returns member variable qstart [int] * */ int Wise2_access_qstart_SegmentHit( Wise2_SegmentHit * obj); /* Function: Wise2_replace_qend_SegmentHit(obj,qend) * * Descrip: Replace member variable qend * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * Arg: qend New value of the variable [int] * * Returns member variable qend [boolean] * */ boolean Wise2_replace_qend_SegmentHit( Wise2_SegmentHit * obj,int qend); /* Function: Wise2_access_qend_SegmentHit(obj) * * Descrip: Access member variable qend * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * * Returns member variable qend [int] * */ int Wise2_access_qend_SegmentHit( Wise2_SegmentHit * obj); /* Function: Wise2_replace_tstart_SegmentHit(obj,tstart) * * Descrip: Replace member variable tstart * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * Arg: tstart New value of the variable [int] * * Returns member variable tstart [boolean] * */ boolean Wise2_replace_tstart_SegmentHit( Wise2_SegmentHit * obj,int tstart); /* Function: Wise2_access_tstart_SegmentHit(obj) * * Descrip: Access member variable tstart * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * * Returns member variable tstart [int] * */ int Wise2_access_tstart_SegmentHit( Wise2_SegmentHit * obj); /* Function: Wise2_replace_tend_SegmentHit(obj,tend) * * Descrip: Replace member variable tend * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * Arg: tend New value of the variable [int] * * Returns member variable tend [boolean] * */ boolean Wise2_replace_tend_SegmentHit( Wise2_SegmentHit * obj,int tend); /* Function: Wise2_access_tend_SegmentHit(obj) * * Descrip: Access member variable tend * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * * Returns member variable tend [int] * */ int Wise2_access_tend_SegmentHit( Wise2_SegmentHit * obj); /* Function: Wise2_replace_score_SegmentHit(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * Arg: score New value of the variable [double] * * Returns member variable score [boolean] * */ boolean Wise2_replace_score_SegmentHit( Wise2_SegmentHit * obj,double score); /* Function: Wise2_access_score_SegmentHit(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * * Returns member variable score [double] * */ double Wise2_access_score_SegmentHit( Wise2_SegmentHit * obj); /* Function: Wise2_replace_next_hit_SegmentHit(obj,next_hit) * * Descrip: Replace member variable next_hit * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * Arg: next_hit New value of the variable [Wise2_SegmentHit *] * * Returns member variable next_hit [boolean] * */ boolean Wise2_replace_next_hit_SegmentHit( Wise2_SegmentHit * obj,Wise2_SegmentHit * next_hit); /* Function: Wise2_access_next_hit_SegmentHit(obj) * * Descrip: Access member variable next_hit * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SegmentHit *] * * Returns member variable next_hit [Wise2_SegmentHit *] * */ Wise2_SegmentHit * Wise2_access_next_hit_SegmentHit( Wise2_SegmentHit * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_SegmentHit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_SegmentHit *] * * Returns Undocumented return value [Wise2_SegmentHit *] * */ Wise2_SegmentHit * Wise2_free_SegmentHit( Wise2_SegmentHit * obj); wise-2.4.1/src/models/seqhit_api.t0000644000175000001440000000026110670453715016445 0ustar philippuserstypedef struct Wise2_DnaSequenceHitList Wise2_DnaSequenceHitList; typedef struct Wise2_SegmentHitList Wise2_SegmentHitList; typedef struct Wise2_SegmentHit Wise2_SegmentHit; wise-2.4.1/src/models/geneparameter.dy0000644000175000001440000001674607646476537017346 0ustar philippusers/* Last edited: Apr 22 13:58 1997 (birney) */ %{ #include "geneparser21.h" #include "genefrequency.h" #include "splicesitemodeler.h" #include "complexevalset.h" #include "probability.h" #include "genestats.h" #define GeneParameter21LISTLENGTH 32 %} struct GeneWiseCodonModel double in_donor[64] double in_acceptor[64] double in_cds[64] struct GeneParameter21 GeneParser21 * gp; !hidden CodonMapper * cm; !hidden ComplexSequenceEvalSet * cses; !hidden SpliceSiteModel ** ss; !list !hidden // held only to be free'd when GeneParser21Set is free'd RandomCodon * rc; !hidden // needed to soak up the odd-and-sods of genes GeneWiseCodonModel * gwcm; !hidden CodonTable * ct; !hidden boolean modelled_splice !hidden !def="TRUE" // so we can alter balance scores. GeneModel * gms; !hidden %info GeneParameter21 keeps all the parameters for genewise algorithms in one tidy unit. This is also the switch between the old (compugen handled) and new statistics. This object can be made from either the old or the new statistics I have made the object complete opaque to scripting apis because the contents have to be coordinated quite well %% api object GeneParameter21 des free_GeneParameter21 endobject endapi %{ #include "geneparameter.h" GeneWiseCodonModel * GeneWiseCodonModel_from_GeneFrequencies(double * cds,GeneConsensus * donor,GeneConsensus * acceptor) { int i; int j,k,l; int codon,perm; int one,two,three; GeneWiseCodonModel * out; out = GeneWiseCodonModel_alloc(); for(i=0;i<64;i++) { out->in_donor[i] = out->in_acceptor[i] = out->in_cds[i] = 0.0000001; if( cds[i] < 0.00000001 ) { out->in_cds[i] = 0.0000001; } else { out->in_cds[i] = cds[i]; } } /** done cds **/ /** for splice site, need to figure out if any entry matches, and add it to the total **/ for(l=0;llen;l++) { one = base_from_char(donor->gsc[l]->string[0] == '-' ? 'N' : donor->gsc[l]->string[0]); two = base_from_char(donor->gsc[l]->string[1] == '-' ? 'N' : donor->gsc[l]->string[1]); three = base_from_char(donor->gsc[l]->string[2] == '-' ? 'N' : donor->gsc[l]->string[2]); codon = one*25 + two *5 + three; for(i=0;i<4;i++) for(j=0;j<4;j++) for(k=0;k<4;k++) { perm = permute_possible_random_bases(codon,i,j,k); /** now add this number /64 to its list **/ out->in_donor[perm] += donor->gsc[l]->number / 64.0; } } for(l=0;llen;l++) { one = base_from_char(acceptor->gsc[l]->string[3] == '-' ? 'N' : acceptor->gsc[l]->string[3]); two = base_from_char(acceptor->gsc[l]->string[4] == '-' ? 'N' : acceptor->gsc[l]->string[4]); three = base_from_char(acceptor->gsc[l]->string[5] == '-' ? 'N' : acceptor->gsc[l]->string[5]); codon = one*25 + two *5 + three; for(i=0;i<4;i++) for(j=0;j<4;j++) for(k=0;k<4;k++) { perm = permute_possible_random_bases(codon,i,j,k); /** now add this number /64 to its list **/ out->in_acceptor[perm] = acceptor->gsc[l]->number / 64.0; } } return out; } %func This actually makes the GeneParameter21 stuff from the new statistics %% GeneParameter21 * GeneParameter21_from_GeneModel(GeneModel * gm,CodonTable * ct,Probability rnd_loop,Probability cds_loop,Probability rnd_to_model,Probability link_loop,Probability link_to_model,Probability subs_error,Probability indel_error) { GeneParameter21 * out; CodonFrequency * cf; RandomModelDNAScore * rmds; ComplexSequenceEval * cse; int i; out = GeneParameter21_alloc_len(4); cf = CodonFrequence_from_raw_counts(gm->codon,ct); out->cm = new_CodonMapper(ct,cf); free_CodonFrequency(cf); out->ct = hard_link_CodonTable(ct); out->gp = std_GeneParser21(); for(i=0;i<5;i++) out->gp->central[i] = gm->rnd->base[i]; GeneParser21_fold_in_RandomModelDNA(out->gp,gm->rnd); out->gp->transition[GP21_CDS2CDS] = cds_loop; out->gp->transition[GP21_CDS2RND] = (1-cds_loop); out->gp->transition[GP21_RND2RND] = rnd_loop; /* fprintf(stderr,"Score is %f\n",out->transition[GP21_RND2RND]); */ out->gp->transition[GP21_RND2CDS] = (1-rnd_loop-rnd_to_model); out->gp->transition[GP21_RND2MODEL] = rnd_to_model; out->gp->transition[GP21_LINK2MODEL] = link_to_model; out->gp->transition[GP21_LINK2LINK] = link_loop; out->gp->transition[GP21_LINK2RND] = (1- link_loop - link_to_model) ; /** build random codon stuff, for soaking up "unused" cds **/ out->rc = RandomCodon_from_raw_CodonFrequency(gm->codon,ct); out->cses = new_ComplexSequenceEvalSet_from_GeneModel(gm); /*** errors ***/ sprinkle_errors_over_CodonMapper(out->cm,subs_error); add_flat_error_probabilities_GeneParser21(out->gp,indel_error); fold_in_RandomModelDNA_into_RandomCodon(out->rc,gm->rnd); return out; } GeneParameter21 * GeneParameter21_from_GeneFrequency21(GeneFrequency21 * gf,CodonTable * ct,RandomModelDNA * rmd,Probability rnd_loop,Probability cds_loop,Probability rnd_to_model,Probability link_loop,Probability link_to_model) { GeneParameter21 * out; CodonFrequency * cf; SpliceSiteModel * ssm; ComplexConsensi * cc; RandomModelDNAScore * rmds; ComplexSequenceEval * cse; out = GeneParameter21_alloc_len(4); out->gp = GeneParser21_from_GeneFrequency21_cds(gf,rnd_loop,cds_loop,rnd_to_model,link_loop,link_to_model); /** build a codon frequency, and then from that a codon mapper **/ cf = CodonFrequency_from_GeneFrequency21(gf,ct); out->cm = new_CodonMapper(ct,cf); out->ct = hard_link_CodonTable(ct); free_CodonFrequency(cf); out->gwcm = GeneWiseCodonModel_from_GeneFrequencies(gf->codon,gf->ss5,gf->ss3); /** build random codon stuff, for soaking up "unused" cds **/ out->rc = RandomCodon_from_raw_CodonFrequency(gf->codon,ct); /** make a new ComplexSequenceEvalSet **/ out->cses = ComplexSequenceEvalSet_alloc_len(6); out->cses->type = SEQUENCE_GENOMIC; /** put in the base/codon eval functions **/ add_ComplexSequenceEvalSet(out->cses,base_number_ComplexSequenceEval()); add_ComplexSequenceEvalSet(out->cses,codon_number_ComplexSequenceEval()); /** make a RandomModelDNAScore **/ rmds = RandomModelDNAScore_from_RandomModelDNA(rmd); /** for each splice site, build a complex consensi **/ /** model, then a splice site model for each offset **/ /** then both add it to the SpliceSite model list, **/ /** and attach a ComplexSequenceEval to the set **/ /** 5'SS **/ cc = ComplexConsensi_5SS_from_GeneFrequency(gf); /** only one offset, at 7 **/ ssm = std_5SS_SpliceSiteModel(0,cc,rmds); cse = ComplexSequenceEval_from_SpliceSiteModel(ssm); cse->left_lookback = 10; /** add to Set **/ add_GeneParameter21(out,ssm); /** add complexeval to cses **/ add_ComplexSequenceEvalSet(out->cses,cse); /** ok, free ComplexConsensi. Remember has been hard linked in std_5SS_Splice etc **/ free_ComplexConsensi(cc); /** 3'SS **/ cc = ComplexConsensi_3SS_from_GeneFrequency(gf); ssm = std_3SS_SpliceSiteModel(0,cc,rmds); cse = ComplexSequenceEval_from_SpliceSiteModel(ssm); cse->left_lookback = 6; add_GeneParameter21(out,ssm); add_ComplexSequenceEvalSet(out->cses,cse); /** ok, we can free the complex consensi for 3'SS **/ free_ComplexConsensi(cc); /** and free the randommodel DNA score, as that gets hard-linked as well **/ free_RandomModelDNAScore(rmds); /* * ok, here we would add the necessary repeat and coding info, * but for now... add flat zeros */ add_ComplexSequenceEvalSet(out->cses,flat_zero()); add_ComplexSequenceEvalSet(out->cses,flat_zero()); /** c'est tout **/ return out; } %} wise-2.4.1/src/models/geneparameter.xs0000644000175000001440000000123310670453714017324 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::GeneParameter21 Wise2_GeneParameter21 * hard_link_GeneParameter21(obj) Wise2_GeneParameter21 * obj CODE: RETVAL = Wise2_hard_link_GeneParameter21(obj); OUTPUT: RETVAL Wise2_GeneParameter21 * GeneParameter21_alloc_std() CODE: RETVAL = Wise2_GeneParameter21_alloc_std(); OUTPUT: RETVAL Wise2_GeneParameter21 * new(class) char * class PPCODE: Wise2_GeneParameter21 * out; out = Wise2_GeneParameter21_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_GeneParameter21 * obj CODE: Wise2_free_GeneParameter21(obj); MODULE = Wise2 PACKAGE = Wise2 wise-2.4.1/src/models/transregion.c0000644000175000001440000006711510670453715016644 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "transregion.h" # line 42 "transregion.dy" void show_help_TransFactorRegionPara(FILE * ofp) { fprintf(ofp,"TransFactor Region parameters\n"); fprintf(ofp," -tf_convert [hmm/window] use HMM or window for conversion, default HMM\n"); fprintf(ofp," -tf_density [0.2] minimum density of bases in a cluster for window\n"); fprintf(ofp," -tf_window [60] minimum window size of region\n"); fprintf(ofp," -tf_inprob [0.35] probability of a covered base in a region for HMM\n"); fprintf(ofp," -tf_outprob [0.2] probability of a covered base outside a region for HMM\n"); fprintf(ofp," -tf_entry [0.000001] probablity of entering a region\n"); fprintf(ofp," -tf_hmm_window [60] minimum window for HMM\n"); fprintf(ofp," -tf_gc_region [1.5] Expected ration of GC dinucleotides in regions vs out\n"); return; } # line 57 "transregion.dy" TransFactorRegionPara * new_TransFactorRegionPara_from_argv(int * argc,char ** argv) { TransFactorRegionPara * out; char * temp; out = TransFactorRegionPara_alloc(); temp = strip_out_assigned_argument(argc,argv,"tf_convert"); if( temp != NULL ) { if( strcmp(temp,"window") == 0 ) { out->type = TRANSREGION_PARA_WINDOW; } else if ( strcmp(temp,"hmm") == 0 ) { out->type = TRANSREGION_PARA_DP; } else { fatal("Could not interpret %s for tf_convert string",temp); } } strip_out_float_argument(argc,argv,"tf_density",&out->min_density); strip_out_integer_argument(argc,argv,"tf_window",&out->min_window); strip_out_integer_argument(argc,argv,"tf_hmm_window",&out->hmm_min_window); strip_out_float_argument(argc,argv,"tf_inprob",&out->in_region_prob); strip_out_float_argument(argc,argv,"tf_outprob",&out->out_region_prob); strip_out_float_argument(argc,argv,"tf_entry",&out->in_cost); strip_out_float_argument(argc,argv,"tf_gc_region",&out->gc_region_ratio); return out; } # line 86 "transregion.dy" void show_TransFactorRegionSet(TransFactorRegionSet * tfrs,FILE * ofp) { int i; int j; Sequence * temp; for(i=0;ilen;i++) { fprintf(ofp,"Region\t%s\t%d\t%d\t%.2f\t%.2f\n",tfrs->target->name,tfrs->region[i]->start+1,tfrs->region[i]->end,tfrs->region[i]->density,tfrs->region[i]->bits_score); fprintf(ofp,"motif\n"); for(j=0;jregion[i]->len;j++) { auto TransFactorMatch * tfm = tfrs->region[i]->match[j]; fprintf(ofp,"Motif\t%s\t%d\t%d\t%d\t%s\t%.2f\t%.*s\n",tfrs->target->name,tfm->start+1,tfm->end,tfm->strand,tfm->factor->name,tfm->bit_score,tfm->end-tfm->start,tfrs->target->seq+tfm->start); } fprintf(ofp,"end motif\n"); temp = trunc_Sequence(tfrs->target,tfrs->region[i]->start,tfrs->region[i]->end); write_fasta_Sequence(temp,ofp); free_Sequence(temp); fprintf(ofp,"end region\n"); } } # line 109 "transregion.dy" TransFactorRegionSet * new_TransFactorRegionSet(TransFactorMatchSet * tfms,TransFactorRegionPara * tfrp,DPRunImpl * dpri) { switch(tfrp->type) { case TRANSREGION_PARA_DP : return new_dp_TransFactorRegionSet(tfms,tfrp,dpri); break; case TRANSREGION_PARA_WINDOW : return new_window_TransFactorRegionSet(tfms,tfrp); break; default : fatal("Very weird. Bad type for TransFactorRegionPara"); } /* can't get here... but ... */ return NULL; } # line 127 "transregion.dy" TransFactorRegionSet * new_dp_TransFactorRegionSet(TransFactorMatchSet * tfms,TransFactorRegionPara * tfrp,DPRunImpl * dpri) { AlnBlock * alb; PackAln * pal; AlnColumn * alc; SequenceBaseCoverage * sbc; TransRegionModel * model; TransFactorRegionSet * out; TransFactorRegion * region; int i; int covered; int uncovered; assert(tfms); assert(tfrp); assert(dpri); sbc = new_SequenceBaseCoverage(tfms); fprintf(stderr,"Making model with %.2f vs %.2f\n",tfrp->in_region_prob,tfrp->out_region_prob); model = new_logodds_TransRegionModel(tfrp->in_region_prob,tfrp->out_region_prob,tfrp->in_cost,tfrp->gc_region_ratio); fprintf(stderr,"GC score is %d (%.2f)\n",model->gc_point,Score2Bits(model->gc_point)); pal = PackAln_bestmemory_TransRegionMatrix(model,sbc,NULL,dpri); alb = convert_PackAln_to_AlnBlock_TransRegionMatrix(pal); free_PackAln(pal); out = TransFactorRegionSet_alloc_std(); out->target = hard_link_Sequence(tfms->target); for(alc = alb->start;alc != NULL;alc = alc->next ) { if( strstr(alc->alu[1]->text_label,"REGION") != NULL ) { if( alc->alu[1]->end - alc->alu[1]->start < tfrp->hmm_min_window ) { continue; } region = TransFactorRegion_alloc_std(); add_TransFactorRegionSet(out,region); region->start = alc->alu[1]->start+1; region->end = alc->alu[1]->end; region->bits_score = Score2Bits(alc->alu[0]->score[0]); covered = 0; uncovered = 0; for(i=alc->alu[1]->start+1;ialu[1]->end;i++) { if(sbc->coverage[i] == 0 ) { uncovered++; } else { covered++; } } region->density = (double) covered / (double)(covered+uncovered); for(i=0;ilen;i++) { if( tfms->match[i]->end < region->start ) { continue; } if( tfms->match[i]->start > region->end ) { break; } add_TransFactorRegion(region,hard_link_TransFactorMatch(tfms->match[i])); } } } free_SequenceBaseCoverage(sbc); free_TransRegionModel(model); free_AlnBlock(alb); return out; } # line 215 "transregion.dy" TransFactorRegionSet * new_window_TransFactorRegionSet(TransFactorMatchSet * tfms,TransFactorRegionPara * tfrp) { int seqpos; int motifpos; int seq_trial; int motif_trial; int end; int covered_bases; int i; int temp_start; int last_covered_base; TransFactorRegionSet * out; TransFactorRegion * region; assert(tfms); assert(tfrp); out = TransFactorRegionSet_alloc_std(); out->target = hard_link_Sequence(tfms->target); if( tfms->len == 0 ) { /* not motifs... no regions! */ return out; } sort_by_start_TransFactorMatchSet(tfms); end = tfms->match[tfms->len-1]->start; for(seqpos = tfms->match[0]->start,motifpos = 0;seqpos < end && motifpos < tfms->len;) { /* see whether there is a potential region here */ covered_bases =0; last_covered_base = seqpos; for(seq_trial = seqpos, motif_trial = motifpos; seq_trial < end && seq_trial - seqpos < tfrp->min_window;seq_trial++) { for(;motif_trial < tfms->len;motif_trial++ ) { if( seq_trial >= tfms->match[motif_trial]->start && seq_trial < tfms->match[motif_trial]->end) { covered_bases++; last_covered_base = seq_trial; break; } if( seq_trial < tfms->match[motif_trial]->start ) { break; } } } if( seq_trial - seqpos < tfrp->min_window ) { break; } /* seq_trial is beyond window size... */ if( (double) covered_bases / (double) (seq_trial - seqpos) < tfrp->min_density ) { motifpos++; if( motifpos >= tfms->len ) { break; } else { seqpos = tfms->match[motifpos]->start; continue; /* next motif start point */ } } seq_trial = last_covered_base; /* has ok density now. Extend until we have bad density */ /* this is not a great extension - each new motif must be providing at least min_density bases */ for(motif_trial;motif_trial < tfms->len;motif_trial++) { if( seq_trial >= tfms->match[motif_trial]->end ) { continue; } if( (tfms->match[motif_trial]->end - tfms->match[motif_trial]->start) / (double) (tfms->match[motif_trial]->end - seq_trial) < tfrp->min_density ) { break; } else { temp_start = seq_trial > tfms->match[motif_trial]->start ? seq_trial : tfms->match[motif_trial]->start; seq_trial = tfms->match[motif_trial]->end; covered_bases += (tfms->match[motif_trial]->end - temp_start); } } /* we have a match! from seqpos to seq_trial and from motifpos to motiftrial */ region = TransFactorRegion_alloc_std(); region->start = seqpos; region->end = seq_trial; region->density = (double) covered_bases / (double) (seq_trial - seqpos); for(i=0;motifpos+i < motif_trial;i++) { add_TransFactorRegion(region,hard_link_TransFactorMatch(tfms->match[motifpos+i])); } add_TransFactorRegionSet(out,region); motifpos = motif_trial++; if( motifpos >= tfms->len ) { break; } seqpos = tfms->match[motifpos]->start; } return out; } # line 301 "transregion.c" /* Function: swap_TransFactorRegion(list,i,j) * * Descrip: swap function: an internal for qsort_TransFactorRegion * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [TransFactorMatch **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_TransFactorRegion(TransFactorMatch ** list,int i,int j) { TransFactorMatch * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_TransFactorRegion(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_TransFactorRegion which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [TransFactorMatch **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_TransFactorRegion(TransFactorMatch ** list,int left,int right,int (*comp)(TransFactorMatch * ,TransFactorMatch * )) { int i,last; if( left >= right ) return; swap_TransFactorRegion(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_TransFactorRegion (list,++last,i); } swap_TransFactorRegion (list,left,last); qsort_TransFactorRegion(list,left,last-1,comp); qsort_TransFactorRegion(list,last+1,right,comp); } /* Function: sort_TransFactorRegion(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_TransFactorRegion * * * Arg: obj [UNKN ] Object containing list [TransFactorRegion *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_TransFactorRegion(TransFactorRegion * obj,int (*comp)(TransFactorMatch *, TransFactorMatch *)) { qsort_TransFactorRegion(obj->match,0,obj->len-1,comp); return; } /* Function: expand_TransFactorRegion(obj,len) * * Descrip: Really an internal function for add_TransFactorRegion * * * Arg: obj [UNKN ] Object which contains the list [TransFactorRegion *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_TransFactorRegion(TransFactorRegion * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_TransFactorRegion called with no need"); return TRUE; } if( (obj->match = (TransFactorMatch ** ) ckrealloc (obj->match,sizeof(TransFactorMatch *)*len)) == NULL) { warn("ckrealloc failed for expand_TransFactorRegion, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_TransFactorRegion(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransFactorRegion *] * Arg: add [OWNER] Object to add to the list [TransFactorMatch *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_TransFactorRegion(TransFactorRegion * obj,TransFactorMatch * add) { if( obj->len >= obj->maxlen) { if( expand_TransFactorRegion(obj,obj->len + TransFactorRegionLISTLENGTH) == FALSE) return FALSE; } obj->match[obj->len++]=add; return TRUE; } /* Function: flush_TransFactorRegion(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransFactorRegion *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_TransFactorRegion(TransFactorRegion * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->match[i] != NULL) { free_TransFactorMatch(obj->match[i]); obj->match[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: TransFactorRegion_alloc_std(void) * * Descrip: Equivalent to TransFactorRegion_alloc_len(TransFactorRegionLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransFactorRegion *] * */ TransFactorRegion * TransFactorRegion_alloc_std(void) { return TransFactorRegion_alloc_len(TransFactorRegionLISTLENGTH); } /* Function: TransFactorRegion_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransFactorRegion *] * */ TransFactorRegion * TransFactorRegion_alloc_len(int len) { TransFactorRegion * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = TransFactorRegion_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->match = (TransFactorMatch ** ) ckcalloc (len,sizeof(TransFactorMatch *))) == NULL) { warn("Warning, ckcalloc failed in TransFactorRegion_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_TransFactorRegion(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorRegion *] * * Return [UNKN ] Undocumented return value [TransFactorRegion *] * */ TransFactorRegion * hard_link_TransFactorRegion(TransFactorRegion * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransFactorRegion object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransFactorRegion_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorRegion *] * */ TransFactorRegion * TransFactorRegion_alloc(void) { TransFactorRegion * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransFactorRegion *) ckalloc (sizeof(TransFactorRegion))) == NULL) { warn("TransFactorRegion_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->end = 0; out->match = NULL; out->len = out->maxlen = 0; out->density = 0; out->bits_score = 0; return out; } /* Function: free_TransFactorRegion(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorRegion *] * * Return [UNKN ] Undocumented return value [TransFactorRegion *] * */ TransFactorRegion * free_TransFactorRegion(TransFactorRegion * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransFactorRegion obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->match != NULL) { for(i=0;ilen;i++) { if( obj->match[i] != NULL) free_TransFactorMatch(obj->match[i]); } ckfree(obj->match); } ckfree(obj); return NULL; } /* Function: swap_TransFactorRegionSet(list,i,j) * * Descrip: swap function: an internal for qsort_TransFactorRegionSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [TransFactorRegion **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_TransFactorRegionSet(TransFactorRegion ** list,int i,int j) { TransFactorRegion * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_TransFactorRegionSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_TransFactorRegionSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [TransFactorRegion **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_TransFactorRegionSet(TransFactorRegion ** list,int left,int right,int (*comp)(TransFactorRegion * ,TransFactorRegion * )) { int i,last; if( left >= right ) return; swap_TransFactorRegionSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_TransFactorRegionSet (list,++last,i); } swap_TransFactorRegionSet (list,left,last); qsort_TransFactorRegionSet(list,left,last-1,comp); qsort_TransFactorRegionSet(list,last+1,right,comp); } /* Function: sort_TransFactorRegionSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_TransFactorRegionSet * * * Arg: obj [UNKN ] Object containing list [TransFactorRegionSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_TransFactorRegionSet(TransFactorRegionSet * obj,int (*comp)(TransFactorRegion *, TransFactorRegion *)) { qsort_TransFactorRegionSet(obj->region,0,obj->len-1,comp); return; } /* Function: expand_TransFactorRegionSet(obj,len) * * Descrip: Really an internal function for add_TransFactorRegionSet * * * Arg: obj [UNKN ] Object which contains the list [TransFactorRegionSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_TransFactorRegionSet(TransFactorRegionSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_TransFactorRegionSet called with no need"); return TRUE; } if( (obj->region = (TransFactorRegion ** ) ckrealloc (obj->region,sizeof(TransFactorRegion *)*len)) == NULL) { warn("ckrealloc failed for expand_TransFactorRegionSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_TransFactorRegionSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransFactorRegionSet *] * Arg: add [OWNER] Object to add to the list [TransFactorRegion *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_TransFactorRegionSet(TransFactorRegionSet * obj,TransFactorRegion * add) { if( obj->len >= obj->maxlen) { if( expand_TransFactorRegionSet(obj,obj->len + TransFactorRegionSetLISTLENGTH) == FALSE) return FALSE; } obj->region[obj->len++]=add; return TRUE; } /* Function: flush_TransFactorRegionSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransFactorRegionSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_TransFactorRegionSet(TransFactorRegionSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->region[i] != NULL) { free_TransFactorRegion(obj->region[i]); obj->region[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: TransFactorRegionSet_alloc_std(void) * * Descrip: Equivalent to TransFactorRegionSet_alloc_len(TransFactorRegionSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransFactorRegionSet *] * */ TransFactorRegionSet * TransFactorRegionSet_alloc_std(void) { return TransFactorRegionSet_alloc_len(TransFactorRegionSetLISTLENGTH); } /* Function: TransFactorRegionSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransFactorRegionSet *] * */ TransFactorRegionSet * TransFactorRegionSet_alloc_len(int len) { TransFactorRegionSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = TransFactorRegionSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->region = (TransFactorRegion ** ) ckcalloc (len,sizeof(TransFactorRegion *))) == NULL) { warn("Warning, ckcalloc failed in TransFactorRegionSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_TransFactorRegionSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorRegionSet *] * * Return [UNKN ] Undocumented return value [TransFactorRegionSet *] * */ TransFactorRegionSet * hard_link_TransFactorRegionSet(TransFactorRegionSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransFactorRegionSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransFactorRegionSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorRegionSet *] * */ TransFactorRegionSet * TransFactorRegionSet_alloc(void) { TransFactorRegionSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransFactorRegionSet *) ckalloc (sizeof(TransFactorRegionSet))) == NULL) { warn("TransFactorRegionSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->region = NULL; out->len = out->maxlen = 0; out->target = NULL; return out; } /* Function: free_TransFactorRegionSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorRegionSet *] * * Return [UNKN ] Undocumented return value [TransFactorRegionSet *] * */ TransFactorRegionSet * free_TransFactorRegionSet(TransFactorRegionSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransFactorRegionSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->region != NULL) { for(i=0;ilen;i++) { if( obj->region[i] != NULL) free_TransFactorRegion(obj->region[i]); } ckfree(obj->region); } if( obj->target != NULL) free_Sequence(obj->target); ckfree(obj); return NULL; } /* Function: hard_link_TransFactorRegionPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorRegionPara *] * * Return [UNKN ] Undocumented return value [TransFactorRegionPara *] * */ TransFactorRegionPara * hard_link_TransFactorRegionPara(TransFactorRegionPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransFactorRegionPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransFactorRegionPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorRegionPara *] * */ TransFactorRegionPara * TransFactorRegionPara_alloc(void) { TransFactorRegionPara * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransFactorRegionPara *) ckalloc (sizeof(TransFactorRegionPara))) == NULL) { warn("TransFactorRegionPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = TRANSREGION_PARA_DP; out->min_density = 0.3; out->min_window = 60; out->in_region_prob = 0.35; out->out_region_prob = 0.2; out->in_cost = 0.000001; out->hmm_min_window = 60; out->gc_region_ratio = 1.5; return out; } /* Function: free_TransFactorRegionPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorRegionPara *] * * Return [UNKN ] Undocumented return value [TransFactorRegionPara *] * */ TransFactorRegionPara * free_TransFactorRegionPara(TransFactorRegionPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransFactorRegionPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/transregion.h0000644000175000001440000003041310670453715016640 0ustar philippusers#ifndef DYNAMITEtransregionHEADERFILE #define DYNAMITEtransregionHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "transfactor.h" #include "transregiondp.h" #define TransFactorRegionLISTLENGTH 128 #define TransFactorRegionSetLISTLENGTH 128 #define TRANSREGION_PARA_DP 93 #define TRANSREGION_PARA_WINDOW 94 struct Wise2_TransFactorRegion { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start; int end; TransFactorMatch ** match; int len;/* len for above match */ int maxlen; /* maxlen for above match */ double density; double bits_score; } ; /* TransFactorRegion defined */ #ifndef DYNAMITE_DEFINED_TransFactorRegion typedef struct Wise2_TransFactorRegion Wise2_TransFactorRegion; #define TransFactorRegion Wise2_TransFactorRegion #define DYNAMITE_DEFINED_TransFactorRegion #endif struct Wise2_TransFactorRegionSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif TransFactorRegion ** region; int len;/* len for above region */ int maxlen; /* maxlen for above region */ Sequence * target; } ; /* TransFactorRegionSet defined */ #ifndef DYNAMITE_DEFINED_TransFactorRegionSet typedef struct Wise2_TransFactorRegionSet Wise2_TransFactorRegionSet; #define TransFactorRegionSet Wise2_TransFactorRegionSet #define DYNAMITE_DEFINED_TransFactorRegionSet #endif struct Wise2_TransFactorRegionPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; double min_density; int min_window; double in_region_prob; double out_region_prob; double in_cost; int hmm_min_window; double gc_region_ratio; } ; /* TransFactorRegionPara defined */ #ifndef DYNAMITE_DEFINED_TransFactorRegionPara typedef struct Wise2_TransFactorRegionPara Wise2_TransFactorRegionPara; #define TransFactorRegionPara Wise2_TransFactorRegionPara #define DYNAMITE_DEFINED_TransFactorRegionPara #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: add_TransFactorRegion(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransFactorRegion *] * Arg: add [OWNER] Object to add to the list [TransFactorMatch *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_TransFactorRegion(TransFactorRegion * obj,TransFactorMatch * add); #define add_TransFactorRegion Wise2_add_TransFactorRegion /* Function: flush_TransFactorRegion(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransFactorRegion *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_TransFactorRegion(TransFactorRegion * obj); #define flush_TransFactorRegion Wise2_flush_TransFactorRegion /* Function: TransFactorRegion_alloc_std(void) * * Descrip: Equivalent to TransFactorRegion_alloc_len(TransFactorRegionLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransFactorRegion *] * */ TransFactorRegion * Wise2_TransFactorRegion_alloc_std(void); #define TransFactorRegion_alloc_std Wise2_TransFactorRegion_alloc_std /* Function: TransFactorRegion_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransFactorRegion *] * */ TransFactorRegion * Wise2_TransFactorRegion_alloc_len(int len); #define TransFactorRegion_alloc_len Wise2_TransFactorRegion_alloc_len /* Function: hard_link_TransFactorRegion(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorRegion *] * * Return [UNKN ] Undocumented return value [TransFactorRegion *] * */ TransFactorRegion * Wise2_hard_link_TransFactorRegion(TransFactorRegion * obj); #define hard_link_TransFactorRegion Wise2_hard_link_TransFactorRegion /* Function: TransFactorRegion_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorRegion *] * */ TransFactorRegion * Wise2_TransFactorRegion_alloc(void); #define TransFactorRegion_alloc Wise2_TransFactorRegion_alloc /* Function: free_TransFactorRegion(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorRegion *] * * Return [UNKN ] Undocumented return value [TransFactorRegion *] * */ TransFactorRegion * Wise2_free_TransFactorRegion(TransFactorRegion * obj); #define free_TransFactorRegion Wise2_free_TransFactorRegion /* Function: add_TransFactorRegionSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransFactorRegionSet *] * Arg: add [OWNER] Object to add to the list [TransFactorRegion *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_TransFactorRegionSet(TransFactorRegionSet * obj,TransFactorRegion * add); #define add_TransFactorRegionSet Wise2_add_TransFactorRegionSet /* Function: flush_TransFactorRegionSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransFactorRegionSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_TransFactorRegionSet(TransFactorRegionSet * obj); #define flush_TransFactorRegionSet Wise2_flush_TransFactorRegionSet /* Function: TransFactorRegionSet_alloc_std(void) * * Descrip: Equivalent to TransFactorRegionSet_alloc_len(TransFactorRegionSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransFactorRegionSet *] * */ TransFactorRegionSet * Wise2_TransFactorRegionSet_alloc_std(void); #define TransFactorRegionSet_alloc_std Wise2_TransFactorRegionSet_alloc_std /* Function: TransFactorRegionSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransFactorRegionSet *] * */ TransFactorRegionSet * Wise2_TransFactorRegionSet_alloc_len(int len); #define TransFactorRegionSet_alloc_len Wise2_TransFactorRegionSet_alloc_len /* Function: hard_link_TransFactorRegionSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorRegionSet *] * * Return [UNKN ] Undocumented return value [TransFactorRegionSet *] * */ TransFactorRegionSet * Wise2_hard_link_TransFactorRegionSet(TransFactorRegionSet * obj); #define hard_link_TransFactorRegionSet Wise2_hard_link_TransFactorRegionSet /* Function: TransFactorRegionSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorRegionSet *] * */ TransFactorRegionSet * Wise2_TransFactorRegionSet_alloc(void); #define TransFactorRegionSet_alloc Wise2_TransFactorRegionSet_alloc /* Function: free_TransFactorRegionSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorRegionSet *] * * Return [UNKN ] Undocumented return value [TransFactorRegionSet *] * */ TransFactorRegionSet * Wise2_free_TransFactorRegionSet(TransFactorRegionSet * obj); #define free_TransFactorRegionSet Wise2_free_TransFactorRegionSet /* Function: hard_link_TransFactorRegionPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorRegionPara *] * * Return [UNKN ] Undocumented return value [TransFactorRegionPara *] * */ TransFactorRegionPara * Wise2_hard_link_TransFactorRegionPara(TransFactorRegionPara * obj); #define hard_link_TransFactorRegionPara Wise2_hard_link_TransFactorRegionPara /* Function: TransFactorRegionPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorRegionPara *] * */ TransFactorRegionPara * Wise2_TransFactorRegionPara_alloc(void); #define TransFactorRegionPara_alloc Wise2_TransFactorRegionPara_alloc /* Function: free_TransFactorRegionPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorRegionPara *] * * Return [UNKN ] Undocumented return value [TransFactorRegionPara *] * */ TransFactorRegionPara * Wise2_free_TransFactorRegionPara(TransFactorRegionPara * obj); #define free_TransFactorRegionPara Wise2_free_TransFactorRegionPara /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_show_help_TransFactorRegionPara(FILE * ofp); #define show_help_TransFactorRegionPara Wise2_show_help_TransFactorRegionPara TransFactorRegionPara * Wise2_new_TransFactorRegionPara_from_argv(int * argc,char ** argv); #define new_TransFactorRegionPara_from_argv Wise2_new_TransFactorRegionPara_from_argv void Wise2_show_TransFactorRegionSet(TransFactorRegionSet * tfrs,FILE * ofp); #define show_TransFactorRegionSet Wise2_show_TransFactorRegionSet TransFactorRegionSet * Wise2_new_TransFactorRegionSet(TransFactorMatchSet * tfms,TransFactorRegionPara * tfrp,DPRunImpl * dpri); #define new_TransFactorRegionSet Wise2_new_TransFactorRegionSet TransFactorRegionSet * Wise2_new_dp_TransFactorRegionSet(TransFactorMatchSet * tfms,TransFactorRegionPara * tfrp,DPRunImpl * dpri); #define new_dp_TransFactorRegionSet Wise2_new_dp_TransFactorRegionSet TransFactorRegionSet * Wise2_new_window_TransFactorRegionSet(TransFactorMatchSet * tfms,TransFactorRegionPara * tfrp); #define new_window_TransFactorRegionSet Wise2_new_window_TransFactorRegionSet /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_TransFactorRegion(TransFactorMatch ** list,int i,int j) ; #define swap_TransFactorRegion Wise2_swap_TransFactorRegion void Wise2_qsort_TransFactorRegion(TransFactorMatch ** list,int left,int right,int (*comp)(TransFactorMatch * ,TransFactorMatch * )); #define qsort_TransFactorRegion Wise2_qsort_TransFactorRegion void Wise2_sort_TransFactorRegion(TransFactorRegion * obj,int (*comp)(TransFactorMatch *, TransFactorMatch *)); #define sort_TransFactorRegion Wise2_sort_TransFactorRegion boolean Wise2_expand_TransFactorRegion(TransFactorRegion * obj,int len); #define expand_TransFactorRegion Wise2_expand_TransFactorRegion void Wise2_swap_TransFactorRegionSet(TransFactorRegion ** list,int i,int j) ; #define swap_TransFactorRegionSet Wise2_swap_TransFactorRegionSet void Wise2_qsort_TransFactorRegionSet(TransFactorRegion ** list,int left,int right,int (*comp)(TransFactorRegion * ,TransFactorRegion * )); #define qsort_TransFactorRegionSet Wise2_qsort_TransFactorRegionSet void Wise2_sort_TransFactorRegionSet(TransFactorRegionSet * obj,int (*comp)(TransFactorRegion *, TransFactorRegion *)); #define sort_TransFactorRegionSet Wise2_sort_TransFactorRegionSet boolean Wise2_expand_TransFactorRegionSet(TransFactorRegionSet * obj,int len); #define expand_TransFactorRegionSet Wise2_expand_TransFactorRegionSet #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/dnahmm.c0000644000175000001440000005720510670453713015552 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dnahmm.h" # line 55 "dnahmm.dy" DnaHmmScore * DnaHmmScore_from_DnaHmmProb(DnaHmmProb * dhp) { int i; DnaHmmScore * out; out = DnaHmmScore_alloc_len(dhp->len); for(i=0;ilen;i++) { add_DnaHmmScore(out,DnaHmmScoreUnit_from_DnaHmmProbUnit(dhp->unit[i])); } return out; } # line 69 "dnahmm.dy" void make_consensus_DnaHmmProb(DnaHmmProb * dhp) { int i; int j; double prob_max; int base; dhp->consensus = calloc(dhp->len+1,sizeof(char)); for(i=0;ilen;i++) { prob_max = -1.0; for(j=0;j<4;j++) { if( dhp->unit[i]->match[j] > prob_max ) { prob_max = dhp->unit[i]->match[j]; base = j; } } if( prob_max > 0.5 ) { dhp->consensus[i] = char_from_base(base); } else if ( prob_max > 0.3 ) { dhp->consensus[i] = tolower(char_from_base(base)); } else { dhp->consensus[i] = '.'; } } dhp->consensus[i] = '\0'; } # line 98 "dnahmm.dy" DnaHmmScoreUnit * DnaHmmScoreUnit_from_DnaHmmProbUnit(DnaHmmProbUnit * dpu) { DnaHmmScoreUnit * out; out = DnaHmmScoreUnit_alloc(); Probability2Score_move(dpu->match,out->match,DNA_HMM_ALPHABET); Probability2Score_move(dpu->insert,out->insert,DNA_HMM_ALPHABET); Probability2Score_move(dpu->transition,out->transition,DHMM_TRANSITION_LEN); return out; } # line 112 "dnahmm.dy" DnaHmmProb * new_DnaHmmProb_from_SeqAlign_ungapped(SeqAlign * sa,double simple_pseudocount) { DnaHmmProb * out; ColumnCount * cc; int i; assert(sa); out = DnaHmmProb_alloc_std(); out->ref_align = hard_link_SeqAlign(sa); for(i=0;iseq[0]->len;i++) { cc = ColumnCount_from_SeqAlign(sa,i); add_DnaHmmProb(out,new_DnaHmmProbUnit_from_ColumnCount_ungapped(cc,simple_pseudocount)); free_ColumnCount(cc); } out->unit[0]->transition[DHMM_START2MATCH] = 1.0; out->unit[out->len-1]->transition[DHMM_MATCH2END] = 1.0; return out; } # line 138 "dnahmm.dy" DnaHmmProbUnit * new_DnaHmmProbUnit_from_ColumnCount_ungapped(ColumnCount * cc,double simple_pseudocount) { DnaHmmProbUnit * out; double total; char base[] = "ATGC"; int i; out = DnaHmmProbUnit_alloc(); for(i=0,total = 0.0;i<4;i++) total += (cc->count[base[i]-'A'] + simple_pseudocount); for(i=0;i<4;i++) out->match[base_from_char(base[i])] = (cc->count[base[i]-'A'] + simple_pseudocount) / total; out->match[4] = 1.0; for(i=0;itransition[i] = 0.0; } out->transition[DHMM_MATCH2MATCH] = 1.0; return out; } # line 164 "dnahmm.dy" void set_N_DnaHmmProb(DnaHmmProb * dhp,Probability basen) { int i; for(i=0;ilen;i++) { dhp->unit[i]->match[BASE_N] = basen; dhp->unit[i]->insert[BASE_N] = basen; } } # line 175 "dnahmm.dy" void fold_RandomModelDNA_DnaHmmProb(DnaHmmProb * dhp,RandomModelDNA * d,Probability rnd_advance) { int i; int j; for(i=0;ilen;i++) { for(j=0;junit[i]->match[j] = dhp->unit[i]->match[j] / d->base[j]; dhp->unit[i]->insert[j] = dhp->unit[i]->insert[j] / d->base[j]; } for(j=0;junit[i]->transition[j] = dhp->unit[i]->transition[j] / rnd_advance; } } } # line 152 "dnahmm.c" /* Function: hard_link_DnaHmmProbUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaHmmProbUnit *] * * Return [UNKN ] Undocumented return value [DnaHmmProbUnit *] * */ DnaHmmProbUnit * hard_link_DnaHmmProbUnit(DnaHmmProbUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaHmmProbUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaHmmProbUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaHmmProbUnit *] * */ DnaHmmProbUnit * DnaHmmProbUnit_alloc(void) { DnaHmmProbUnit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaHmmProbUnit *) ckalloc (sizeof(DnaHmmProbUnit))) == NULL) { warn("DnaHmmProbUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* match[DNA_HMM_ALPHABET] is an array: no default possible */ /* insert[DNA_HMM_ALPHABET] is an array: no default possible */ /* transition[DHMM_TRANSITION_LEN] is an array: no default possible */ return out; } /* Function: free_DnaHmmProbUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaHmmProbUnit *] * * Return [UNKN ] Undocumented return value [DnaHmmProbUnit *] * */ DnaHmmProbUnit * free_DnaHmmProbUnit(DnaHmmProbUnit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaHmmProbUnit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_DnaHmmProb(list,i,j) * * Descrip: swap function: an internal for qsort_DnaHmmProb * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [DnaHmmProbUnit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_DnaHmmProb(DnaHmmProbUnit ** list,int i,int j) { DnaHmmProbUnit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_DnaHmmProb(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_DnaHmmProb which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [DnaHmmProbUnit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_DnaHmmProb(DnaHmmProbUnit ** list,int left,int right,int (*comp)(DnaHmmProbUnit * ,DnaHmmProbUnit * )) { int i,last; if( left >= right ) return; swap_DnaHmmProb(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_DnaHmmProb (list,++last,i); } swap_DnaHmmProb (list,left,last); qsort_DnaHmmProb(list,left,last-1,comp); qsort_DnaHmmProb(list,last+1,right,comp); } /* Function: sort_DnaHmmProb(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_DnaHmmProb * * * Arg: obj [UNKN ] Object containing list [DnaHmmProb *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_DnaHmmProb(DnaHmmProb * obj,int (*comp)(DnaHmmProbUnit *, DnaHmmProbUnit *)) { qsort_DnaHmmProb(obj->unit,0,obj->len-1,comp); return; } /* Function: expand_DnaHmmProb(obj,len) * * Descrip: Really an internal function for add_DnaHmmProb * * * Arg: obj [UNKN ] Object which contains the list [DnaHmmProb *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_DnaHmmProb(DnaHmmProb * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_DnaHmmProb called with no need"); return TRUE; } if( (obj->unit = (DnaHmmProbUnit ** ) ckrealloc (obj->unit,sizeof(DnaHmmProbUnit *)*len)) == NULL) { warn("ckrealloc failed for expand_DnaHmmProb, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_DnaHmmProb(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DnaHmmProb *] * Arg: add [OWNER] Object to add to the list [DnaHmmProbUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_DnaHmmProb(DnaHmmProb * obj,DnaHmmProbUnit * add) { if( obj->len >= obj->maxlen) { if( expand_DnaHmmProb(obj,obj->len + DnaHmmProbLISTLENGTH) == FALSE) return FALSE; } obj->unit[obj->len++]=add; return TRUE; } /* Function: flush_DnaHmmProb(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DnaHmmProb *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_DnaHmmProb(DnaHmmProb * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->unit[i] != NULL) { free_DnaHmmProbUnit(obj->unit[i]); obj->unit[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: DnaHmmProb_alloc_std(void) * * Descrip: Equivalent to DnaHmmProb_alloc_len(DnaHmmProbLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DnaHmmProb *] * */ DnaHmmProb * DnaHmmProb_alloc_std(void) { return DnaHmmProb_alloc_len(DnaHmmProbLISTLENGTH); } /* Function: DnaHmmProb_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DnaHmmProb *] * */ DnaHmmProb * DnaHmmProb_alloc_len(int len) { DnaHmmProb * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = DnaHmmProb_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->unit = (DnaHmmProbUnit ** ) ckcalloc (len,sizeof(DnaHmmProbUnit *))) == NULL) { warn("Warning, ckcalloc failed in DnaHmmProb_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_DnaHmmProb(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaHmmProb *] * * Return [UNKN ] Undocumented return value [DnaHmmProb *] * */ DnaHmmProb * hard_link_DnaHmmProb(DnaHmmProb * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaHmmProb object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaHmmProb_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaHmmProb *] * */ DnaHmmProb * DnaHmmProb_alloc(void) { DnaHmmProb * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaHmmProb *) ckalloc (sizeof(DnaHmmProb))) == NULL) { warn("DnaHmmProb_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->unit = NULL; out->len = out->maxlen = 0; out->ref_align = NULL; out->consensus = NULL; return out; } /* Function: free_DnaHmmProb(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaHmmProb *] * * Return [UNKN ] Undocumented return value [DnaHmmProb *] * */ DnaHmmProb * free_DnaHmmProb(DnaHmmProb * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaHmmProb obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->unit != NULL) { for(i=0;ilen;i++) { if( obj->unit[i] != NULL) free_DnaHmmProbUnit(obj->unit[i]); } ckfree(obj->unit); } if( obj->ref_align != NULL) free_SeqAlign(obj->ref_align); if( obj->consensus != NULL) ckfree(obj->consensus); ckfree(obj); return NULL; } /* Function: hard_link_DnaHmmScoreUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaHmmScoreUnit *] * * Return [UNKN ] Undocumented return value [DnaHmmScoreUnit *] * */ DnaHmmScoreUnit * hard_link_DnaHmmScoreUnit(DnaHmmScoreUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaHmmScoreUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaHmmScoreUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaHmmScoreUnit *] * */ DnaHmmScoreUnit * DnaHmmScoreUnit_alloc(void) { DnaHmmScoreUnit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaHmmScoreUnit *) ckalloc (sizeof(DnaHmmScoreUnit))) == NULL) { warn("DnaHmmScoreUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* match[DNA_HMM_ALPHABET] is an array: no default possible */ /* insert[DNA_HMM_ALPHABET] is an array: no default possible */ /* transition[DHMM_TRANSITION_LEN] is an array: no default possible */ return out; } /* Function: free_DnaHmmScoreUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaHmmScoreUnit *] * * Return [UNKN ] Undocumented return value [DnaHmmScoreUnit *] * */ DnaHmmScoreUnit * free_DnaHmmScoreUnit(DnaHmmScoreUnit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaHmmScoreUnit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_DnaHmmScore(list,i,j) * * Descrip: swap function: an internal for qsort_DnaHmmScore * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [DnaHmmScoreUnit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_DnaHmmScore(DnaHmmScoreUnit ** list,int i,int j) { DnaHmmScoreUnit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_DnaHmmScore(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_DnaHmmScore which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [DnaHmmScoreUnit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_DnaHmmScore(DnaHmmScoreUnit ** list,int left,int right,int (*comp)(DnaHmmScoreUnit * ,DnaHmmScoreUnit * )) { int i,last; if( left >= right ) return; swap_DnaHmmScore(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_DnaHmmScore (list,++last,i); } swap_DnaHmmScore (list,left,last); qsort_DnaHmmScore(list,left,last-1,comp); qsort_DnaHmmScore(list,last+1,right,comp); } /* Function: sort_DnaHmmScore(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_DnaHmmScore * * * Arg: obj [UNKN ] Object containing list [DnaHmmScore *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_DnaHmmScore(DnaHmmScore * obj,int (*comp)(DnaHmmScoreUnit *, DnaHmmScoreUnit *)) { qsort_DnaHmmScore(obj->unit,0,obj->len-1,comp); return; } /* Function: expand_DnaHmmScore(obj,len) * * Descrip: Really an internal function for add_DnaHmmScore * * * Arg: obj [UNKN ] Object which contains the list [DnaHmmScore *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_DnaHmmScore(DnaHmmScore * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_DnaHmmScore called with no need"); return TRUE; } if( (obj->unit = (DnaHmmScoreUnit ** ) ckrealloc (obj->unit,sizeof(DnaHmmScoreUnit *)*len)) == NULL) { warn("ckrealloc failed for expand_DnaHmmScore, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_DnaHmmScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DnaHmmScore *] * Arg: add [OWNER] Object to add to the list [DnaHmmScoreUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_DnaHmmScore(DnaHmmScore * obj,DnaHmmScoreUnit * add) { if( obj->len >= obj->maxlen) { if( expand_DnaHmmScore(obj,obj->len + DnaHmmScoreLISTLENGTH) == FALSE) return FALSE; } obj->unit[obj->len++]=add; return TRUE; } /* Function: flush_DnaHmmScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DnaHmmScore *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_DnaHmmScore(DnaHmmScore * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->unit[i] != NULL) { free_DnaHmmScoreUnit(obj->unit[i]); obj->unit[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: DnaHmmScore_alloc_std(void) * * Descrip: Equivalent to DnaHmmScore_alloc_len(DnaHmmScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DnaHmmScore *] * */ DnaHmmScore * DnaHmmScore_alloc_std(void) { return DnaHmmScore_alloc_len(DnaHmmScoreLISTLENGTH); } /* Function: DnaHmmScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DnaHmmScore *] * */ DnaHmmScore * DnaHmmScore_alloc_len(int len) { DnaHmmScore * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = DnaHmmScore_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->unit = (DnaHmmScoreUnit ** ) ckcalloc (len,sizeof(DnaHmmScoreUnit *))) == NULL) { warn("Warning, ckcalloc failed in DnaHmmScore_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_DnaHmmScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaHmmScore *] * * Return [UNKN ] Undocumented return value [DnaHmmScore *] * */ DnaHmmScore * hard_link_DnaHmmScore(DnaHmmScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaHmmScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaHmmScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaHmmScore *] * */ DnaHmmScore * DnaHmmScore_alloc(void) { DnaHmmScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaHmmScore *) ckalloc (sizeof(DnaHmmScore))) == NULL) { warn("DnaHmmScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->unit = NULL; out->len = out->maxlen = 0; out->ref_align = NULL; return out; } /* Function: free_DnaHmmScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaHmmScore *] * * Return [UNKN ] Undocumented return value [DnaHmmScore *] * */ DnaHmmScore * free_DnaHmmScore(DnaHmmScore * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaHmmScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->unit != NULL) { for(i=0;ilen;i++) { if( obj->unit[i] != NULL) free_DnaHmmScoreUnit(obj->unit[i]); } ckfree(obj->unit); } if( obj->ref_align != NULL) free_SeqAlign(obj->ref_align); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/dnahmm.h0000644000175000001440000003155410670453713015556 0ustar philippusers#ifndef DYNAMITEdnahmmHEADERFILE #define DYNAMITEdnahmmHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" enum dhmm_trans_type { DHMM_MATCH2MATCH = 0, DHMM_MATCH2INSERT, DHMM_MATCH2DELETE, DHMM_INSERT2MATCH, DHMM_INSERT2INSERT, DHMM_INSERT2DELETE, DHMM_DELETE2MATCH, DHMM_DELETE2INSERT, DHMM_DELETE2DELETE, DHMM_START2MATCH, DHMM_START2INSERT, DHMM_START2DELETE, DHMM_MATCH2END, DHMM_INSERT2END, DHMM_DELETE2END, DHMM_TRANSITION_LEN }; #define DNA_HMM_ALPHABET 5 #define DnaHmmProbLISTLENGTH 64 #define DnaHmmScoreLISTLENGTH 64 struct Wise2_DnaHmmProbUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability match[DNA_HMM_ALPHABET]; Probability insert[DNA_HMM_ALPHABET]; Probability transition[DHMM_TRANSITION_LEN]; } ; /* DnaHmmProbUnit defined */ #ifndef DYNAMITE_DEFINED_DnaHmmProbUnit typedef struct Wise2_DnaHmmProbUnit Wise2_DnaHmmProbUnit; #define DnaHmmProbUnit Wise2_DnaHmmProbUnit #define DYNAMITE_DEFINED_DnaHmmProbUnit #endif struct Wise2_DnaHmmProb { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DnaHmmProbUnit ** unit; int len;/* len for above unit */ int maxlen; /* maxlen for above unit */ SeqAlign * ref_align; char * consensus; } ; /* DnaHmmProb defined */ #ifndef DYNAMITE_DEFINED_DnaHmmProb typedef struct Wise2_DnaHmmProb Wise2_DnaHmmProb; #define DnaHmmProb Wise2_DnaHmmProb #define DYNAMITE_DEFINED_DnaHmmProb #endif struct Wise2_DnaHmmScoreUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score match[DNA_HMM_ALPHABET]; Score insert[DNA_HMM_ALPHABET]; Score transition[DHMM_TRANSITION_LEN]; } ; /* DnaHmmScoreUnit defined */ #ifndef DYNAMITE_DEFINED_DnaHmmScoreUnit typedef struct Wise2_DnaHmmScoreUnit Wise2_DnaHmmScoreUnit; #define DnaHmmScoreUnit Wise2_DnaHmmScoreUnit #define DYNAMITE_DEFINED_DnaHmmScoreUnit #endif struct Wise2_DnaHmmScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DnaHmmScoreUnit ** unit; int len;/* len for above unit */ int maxlen; /* maxlen for above unit */ SeqAlign * ref_align; } ; /* DnaHmmScore defined */ #ifndef DYNAMITE_DEFINED_DnaHmmScore typedef struct Wise2_DnaHmmScore Wise2_DnaHmmScore; #define DnaHmmScore Wise2_DnaHmmScore #define DYNAMITE_DEFINED_DnaHmmScore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_DnaHmmProbUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaHmmProbUnit *] * * Return [UNKN ] Undocumented return value [DnaHmmProbUnit *] * */ DnaHmmProbUnit * Wise2_hard_link_DnaHmmProbUnit(DnaHmmProbUnit * obj); #define hard_link_DnaHmmProbUnit Wise2_hard_link_DnaHmmProbUnit /* Function: DnaHmmProbUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaHmmProbUnit *] * */ DnaHmmProbUnit * Wise2_DnaHmmProbUnit_alloc(void); #define DnaHmmProbUnit_alloc Wise2_DnaHmmProbUnit_alloc /* Function: free_DnaHmmProbUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaHmmProbUnit *] * * Return [UNKN ] Undocumented return value [DnaHmmProbUnit *] * */ DnaHmmProbUnit * Wise2_free_DnaHmmProbUnit(DnaHmmProbUnit * obj); #define free_DnaHmmProbUnit Wise2_free_DnaHmmProbUnit /* Function: add_DnaHmmProb(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DnaHmmProb *] * Arg: add [OWNER] Object to add to the list [DnaHmmProbUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_DnaHmmProb(DnaHmmProb * obj,DnaHmmProbUnit * add); #define add_DnaHmmProb Wise2_add_DnaHmmProb /* Function: flush_DnaHmmProb(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DnaHmmProb *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_DnaHmmProb(DnaHmmProb * obj); #define flush_DnaHmmProb Wise2_flush_DnaHmmProb /* Function: DnaHmmProb_alloc_std(void) * * Descrip: Equivalent to DnaHmmProb_alloc_len(DnaHmmProbLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DnaHmmProb *] * */ DnaHmmProb * Wise2_DnaHmmProb_alloc_std(void); #define DnaHmmProb_alloc_std Wise2_DnaHmmProb_alloc_std /* Function: DnaHmmProb_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DnaHmmProb *] * */ DnaHmmProb * Wise2_DnaHmmProb_alloc_len(int len); #define DnaHmmProb_alloc_len Wise2_DnaHmmProb_alloc_len /* Function: hard_link_DnaHmmProb(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaHmmProb *] * * Return [UNKN ] Undocumented return value [DnaHmmProb *] * */ DnaHmmProb * Wise2_hard_link_DnaHmmProb(DnaHmmProb * obj); #define hard_link_DnaHmmProb Wise2_hard_link_DnaHmmProb /* Function: DnaHmmProb_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaHmmProb *] * */ DnaHmmProb * Wise2_DnaHmmProb_alloc(void); #define DnaHmmProb_alloc Wise2_DnaHmmProb_alloc /* Function: free_DnaHmmProb(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaHmmProb *] * * Return [UNKN ] Undocumented return value [DnaHmmProb *] * */ DnaHmmProb * Wise2_free_DnaHmmProb(DnaHmmProb * obj); #define free_DnaHmmProb Wise2_free_DnaHmmProb /* Function: hard_link_DnaHmmScoreUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaHmmScoreUnit *] * * Return [UNKN ] Undocumented return value [DnaHmmScoreUnit *] * */ DnaHmmScoreUnit * Wise2_hard_link_DnaHmmScoreUnit(DnaHmmScoreUnit * obj); #define hard_link_DnaHmmScoreUnit Wise2_hard_link_DnaHmmScoreUnit /* Function: DnaHmmScoreUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaHmmScoreUnit *] * */ DnaHmmScoreUnit * Wise2_DnaHmmScoreUnit_alloc(void); #define DnaHmmScoreUnit_alloc Wise2_DnaHmmScoreUnit_alloc /* Function: free_DnaHmmScoreUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaHmmScoreUnit *] * * Return [UNKN ] Undocumented return value [DnaHmmScoreUnit *] * */ DnaHmmScoreUnit * Wise2_free_DnaHmmScoreUnit(DnaHmmScoreUnit * obj); #define free_DnaHmmScoreUnit Wise2_free_DnaHmmScoreUnit /* Function: add_DnaHmmScore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DnaHmmScore *] * Arg: add [OWNER] Object to add to the list [DnaHmmScoreUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_DnaHmmScore(DnaHmmScore * obj,DnaHmmScoreUnit * add); #define add_DnaHmmScore Wise2_add_DnaHmmScore /* Function: flush_DnaHmmScore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DnaHmmScore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_DnaHmmScore(DnaHmmScore * obj); #define flush_DnaHmmScore Wise2_flush_DnaHmmScore /* Function: DnaHmmScore_alloc_std(void) * * Descrip: Equivalent to DnaHmmScore_alloc_len(DnaHmmScoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DnaHmmScore *] * */ DnaHmmScore * Wise2_DnaHmmScore_alloc_std(void); #define DnaHmmScore_alloc_std Wise2_DnaHmmScore_alloc_std /* Function: DnaHmmScore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DnaHmmScore *] * */ DnaHmmScore * Wise2_DnaHmmScore_alloc_len(int len); #define DnaHmmScore_alloc_len Wise2_DnaHmmScore_alloc_len /* Function: hard_link_DnaHmmScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaHmmScore *] * * Return [UNKN ] Undocumented return value [DnaHmmScore *] * */ DnaHmmScore * Wise2_hard_link_DnaHmmScore(DnaHmmScore * obj); #define hard_link_DnaHmmScore Wise2_hard_link_DnaHmmScore /* Function: DnaHmmScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaHmmScore *] * */ DnaHmmScore * Wise2_DnaHmmScore_alloc(void); #define DnaHmmScore_alloc Wise2_DnaHmmScore_alloc /* Function: free_DnaHmmScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaHmmScore *] * * Return [UNKN ] Undocumented return value [DnaHmmScore *] * */ DnaHmmScore * Wise2_free_DnaHmmScore(DnaHmmScore * obj); #define free_DnaHmmScore Wise2_free_DnaHmmScore /* Unplaced functions */ /* There has been no indication of the use of these functions */ DnaHmmScore * Wise2_DnaHmmScore_from_DnaHmmProb(DnaHmmProb * dhp); #define DnaHmmScore_from_DnaHmmProb Wise2_DnaHmmScore_from_DnaHmmProb void Wise2_make_consensus_DnaHmmProb(DnaHmmProb * dhp); #define make_consensus_DnaHmmProb Wise2_make_consensus_DnaHmmProb DnaHmmScoreUnit * Wise2_DnaHmmScoreUnit_from_DnaHmmProbUnit(DnaHmmProbUnit * dpu); #define DnaHmmScoreUnit_from_DnaHmmProbUnit Wise2_DnaHmmScoreUnit_from_DnaHmmProbUnit DnaHmmProb * Wise2_new_DnaHmmProb_from_SeqAlign_ungapped(SeqAlign * sa,double simple_pseudocount); #define new_DnaHmmProb_from_SeqAlign_ungapped Wise2_new_DnaHmmProb_from_SeqAlign_ungapped DnaHmmProbUnit * Wise2_new_DnaHmmProbUnit_from_ColumnCount_ungapped(ColumnCount * cc,double simple_pseudocount); #define new_DnaHmmProbUnit_from_ColumnCount_ungapped Wise2_new_DnaHmmProbUnit_from_ColumnCount_ungapped void Wise2_set_N_DnaHmmProb(DnaHmmProb * dhp,Probability basen); #define set_N_DnaHmmProb Wise2_set_N_DnaHmmProb void Wise2_fold_RandomModelDNA_DnaHmmProb(DnaHmmProb * dhp,RandomModelDNA * d,Probability rnd_advance); #define fold_RandomModelDNA_DnaHmmProb Wise2_fold_RandomModelDNA_DnaHmmProb /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_DnaHmmProb(DnaHmmProbUnit ** list,int i,int j) ; #define swap_DnaHmmProb Wise2_swap_DnaHmmProb void Wise2_qsort_DnaHmmProb(DnaHmmProbUnit ** list,int left,int right,int (*comp)(DnaHmmProbUnit * ,DnaHmmProbUnit * )); #define qsort_DnaHmmProb Wise2_qsort_DnaHmmProb void Wise2_sort_DnaHmmProb(DnaHmmProb * obj,int (*comp)(DnaHmmProbUnit *, DnaHmmProbUnit *)); #define sort_DnaHmmProb Wise2_sort_DnaHmmProb boolean Wise2_expand_DnaHmmProb(DnaHmmProb * obj,int len); #define expand_DnaHmmProb Wise2_expand_DnaHmmProb void Wise2_swap_DnaHmmScore(DnaHmmScoreUnit ** list,int i,int j) ; #define swap_DnaHmmScore Wise2_swap_DnaHmmScore void Wise2_qsort_DnaHmmScore(DnaHmmScoreUnit ** list,int left,int right,int (*comp)(DnaHmmScoreUnit * ,DnaHmmScoreUnit * )); #define qsort_DnaHmmScore Wise2_qsort_DnaHmmScore void Wise2_sort_DnaHmmScore(DnaHmmScore * obj,int (*comp)(DnaHmmScoreUnit *, DnaHmmScoreUnit *)); #define sort_DnaHmmScore Wise2_sort_DnaHmmScore boolean Wise2_expand_DnaHmmScore(DnaHmmScore * obj,int len); #define expand_DnaHmmScore Wise2_expand_DnaHmmScore #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/hmminfo.c0000644000175000001440000000077710670450317015742 0ustar philippusers#define WISE2_CROSS_HMMER2 #include "wise2xhmmer2.h" #include "threestatemodel.h" main(int argc,char ** argv) { int i; ThreeStateModel * tsm; int show_all = 1; tsm = HMMer2_read_ThreeStateModel(argv[1]); for(i=0;ilen;i++) { fprintf(stdout,"%d\t%.4f\t%c\n",i,information_from_ThreeStateUnit(tsm->unit[i],tsm->rm),tsm->unit[i]->display_char); } if( show_all == 1 ) { for(i=0;i<26;i++) { fprintf(stdout,"%d\t%c\t%f\n",i,(char)('A'+i),tsm->rm->aminoacid[i]); } } } wise-2.4.1/src/models/geneutil.c0000644000175000001440000007465310670453714016131 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "geneutil.h" /* Function: new_GenomicRegion_from_GeneWise(gen,pseudo,alb) * * Descrip: Makes a new GenomicRegion with the genes * predicted from this AlnBlock * * Really a wrapper around the add_Genes_to_GenomicRegion_GeneWise * and other functionality * * * Arg: gen [UNKN ] genomic sequence to use [Genomic *] * Arg: pseudo [UNKN ] If true, predicts frameshifted genes as pseudogenes [boolean] * Arg: alb [UNKN ] genewise alignment to predict genes from [AlnBlock *] * * Return [UNKN ] a newly allocated structure [GenomicRegion *] * */ # line 25 "geneutil.dy" GenomicRegion * new_GenomicRegion_from_GeneWise(Genomic * gen,boolean pseudo,AlnBlock * alb) { GenomicRegion * out; out = new_GenomicRegion(gen); add_Genes_to_GenomicRegion_new(out,alb); return out; } /* Function: add_Genes_to_GenomicRegion_GeneWise(gr,org_start,org_end,alb,root,pseudo,make_name) * * Descrip: Potential an Alnblock may have more * than one gene due to looping models * * This adds all the genes to gr * * * * Arg: gr [UNKN ] genomic region to add genes to [GenomicRegion *] * Arg: org_start [UNKN ] start point of the dna to which the alb was made from [int] * Arg: org_end [UNKN ] end point of the dna to which the alb was made from [int] * Arg: alb [UNKN ] logical label alignment [AlnBlock *] * Arg: root [UNKN ] the second argument to make_name [char *] * Arg: pseudo [UNKN ] If true, frameshifted genes are predicted as pseudo genes [boolean] * Arg: make_name [FUNCP] a pointer to a function to actually make the name of the gene [char * (*make_name] * * Return [UNKN ] Undocumented return value [int] * */ # line 51 "geneutil.dy" int add_Genes_to_GenomicRegion_GeneWise(GenomicRegion * gr,int org_start,int org_end,AlnBlock * alb,char * root,boolean pseudo,char * (*make_name)(Wise2_Genomic *,char *,int ,Wise2_Gene * )) { int count = 0; Gene * gene; AlnColumn * alc; alc = alb->start; while( (gene = Gene_from_AlnColumn_GeneWise(alc,org_start,org_end,pseudo,&alc)) != NULL ) { if( make_name != NULL ) { gene->name = (*make_name)(gr->genomic,root,gr->len,gene); } if( root != NULL ) { gene->seqname = stringalloc(root); } add_Gene_to_GenomicRegion(gr,gene); count++; if( alc == NULL ) break; } return count; } /* Function: add_Genes_to_GenomicRegion_new(gr,alb) * * Descrip: Adds genes using the new gene function * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * * Return [UNKN ] Undocumented return value [int] * */ # line 80 "geneutil.dy" int add_Genes_to_GenomicRegion_new(GenomicRegion * gr,AlnBlock * alb) { int count = 0; Gene * out; Transcript * tr; Transcript * new_tr; Translation * ts; Exon * exon; AlnBlock * coll; AlnColumn * alc; AlnColumn * exon_start; AlnColumn * intron_start; int trace = 1; int exon_start_coord; int is_reversed = 0; int temp; int i; coll = collapsed_AlnBlock(alb,1); /* find start */ for(alc = coll->start;alc != NULL;alc = alc->next ) { if( strstr(alc->alu[1]->text_label,"CODON") != NULL ) { if( trace ) fprintf(stderr,"Got %s as first codon\n",alc->alu[1]->text_label); /* got a gene */ out = Gene_alloc_len(1); add_Gene_to_GenomicRegion(gr,out); tr = Transcript_alloc_std(); /* don't add transcript yet, because reversing it requires arsing around with exons */ if( strstr(alc->alu[1]->text_label,"REV") != NULL ) { is_reversed = 1; } else { is_reversed = 0; } exon_start_coord = alc->alu[1]->start+1; out->start = exon_start_coord; /* first exon is different as there is no 3' splice site */ exon_start = alc; alc = alc->next; if( alc == NULL ) { warn("weird death in gene parsing"); return 1; } /* handle single exon genes */ if( strstr(alc->alu[1]->text_label,"SS") == NULL ) { /* single exon gene */ exon = Exon_alloc_std(); exon->start = 0; exon->end = alc->alu[1]->start+3 - exon_start->alu[1]->start; if( trace ) fprintf(stderr,"Single exon gene %s from %d to %d\n",alc->alu[1]->text_label,exon->start,exon->end); if( is_reversed == 0 ) { out->start = exon_start->alu[1]->start+1; out->end = alc->alu[1]->start+4; } else { out->end = exon_start->alu[1]->start; out->start = alc->alu[1]->start+3; } add_ex_Transcript(tr,exon); ts = Translation_alloc(); ts->start = 0; ts->end = length_Transcript(tr); ts->parent = tr; add_Transcript(tr,ts); tr->parent = out; add_Gene(out,tr); continue; } /* handle first exon */ exon = Exon_alloc_std(); add_ex_Transcript(tr,exon); exon->start = exon_start->alu[1]->start+1 - exon_start_coord; if( strstr(alc->alu[1]->text_label,"PHASE_0") != NULL) { exon->end = alc->alu[1]->start +1 - out->start; } else if ( strstr(alc->alu[1]->text_label,"PHASE_1") != NULL) { exon->end = alc->alu[1]->start +2 - out->start; } else if ( strstr(alc->alu[1]->text_label,"PHASE_2") != NULL) { exon->end = alc->alu[1]->start +3 - out->start; } /* loop over internal exons. Alc is current on leftmost splice site */ for( ;; ) { if( trace ) fprintf(stderr,"internal exon - this should be leftmost splice %s\n",alc->alu[1]->text_label); if( strstr(alc->next->alu[1]->text_label,"SS") != NULL ) { warn("Have a no-base intron. Conceptually possible, but highly unlikely. Probably misparamterisation somewhere..."); } else { alc = alc->next; if( trace ) fprintf(stderr,"internal exon - this should be INTRON %s\n",alc->alu[1]->text_label); } if( alc == NULL ) { warn("Weird death inside Intron of gene parsing"); return 1; } alc = alc->next; if( trace ) fprintf(stderr,"internal exon - this should be rightmost splice %s\n",alc->alu[1]->text_label); if( alc == NULL ) { warn("Weird death inside Intron of gene parsing"); return 1; } if( strstr(alc->alu[1]->text_label,"SS") == NULL ) { warn("At end of intron , non splice label %s",alc->alu[1]->text_label); return 1; } exon_start = alc; alc = alc->next; if( trace ) fprintf(stderr,"internal exon - this should be CODON %s\n",alc->alu[1]->text_label); if( alc == NULL ) { warn("Weird death inside Intron of gene parsing"); return 1; } alc = alc->next; if( alc == NULL ) { warn("Weird death inside Intron of gene parsing"); return 1; } if( trace ) fprintf(stderr,"internal exon - this should be 5SS %s\n",alc->alu[1]->text_label); /* should have a 3'SS whatever */ exon = Exon_alloc_std(); add_ex_Transcript(tr,exon); if( strstr(exon_start->alu[1]->text_label,"PHASE_0") != NULL) { exon->start = exon_start->alu[1]->start +4 - out->start; } else if ( strstr(exon_start->alu[1]->text_label,"PHASE_1") == NULL) { exon->start = exon_start->alu[1]->start +4 - out->start; } else if ( strstr(exon_start->alu[1]->text_label,"PHASE_2") == NULL) { exon->start = exon_start->alu[1]->start +4 - out->start; } if( strstr(alc->alu[1]->text_label,"SS") == NULL ) { fprintf(stderr,"Breaking with no 5'SS on %s with %d\n",alc->alu[1]->text_label,alc->alu[1]->start); exon->end = alc->alu[1]->start +1 - out->start; break; } else { if( strstr(alc->alu[1]->text_label,"PHASE_0") != NULL) { exon->end = alc->alu[1]->start +1 - out->start; } else if ( strstr(alc->alu[1]->text_label,"PHASE_1") != NULL) { exon->end = alc->alu[1]->start +2 - out->start; } else if ( strstr(alc->alu[1]->text_label,"PHASE_2") != NULL) { exon->end = alc->alu[1]->start +3 - out->start; } } /* alc is left on the 5'SS for the next exon */ } /* end of for (;;) over internal exons*/ /* end of a gene. exon is the last exon */ out->end = exon->end + out->start; ts = Translation_alloc(); ts->start = 0; ts->end = length_Transcript(tr); if( ts->end % 3 != 0 ) { warn("Transcript is not mod 3 size. It is %d doh!",ts->end); } if( is_reversed == 1 ) { if( trace ) fprintf(stderr,"Reversing gene %d to %d\n",out->start,out->end); temp = out->end; temp = temp; out->end = out->start; out->start = temp; /* reversed genes have an off by one convention */ out->end -= 1; out->start -= 1; /* now have to reverse transcript. doh! */ new_tr = Transcript_alloc_std(); temp = out->start - out->end; for(i=tr->ex_len-1;i >= 0;i-- ) { exon = Exon_alloc_std(); exon->start = temp - tr->exon[i]->end; exon->end = temp - tr->exon[i]->start; fprintf(stderr,"Adding exon %d %d which used to be %d %d\n",exon->start,exon->end,tr->exon[i]->start,tr->exon[i]->end); add_ex_Transcript(new_tr,exon); } free_Transcript(tr); tr = new_tr; } add_Gene(out,tr); ts->parent = tr; add_Transcript(tr,ts); tr->parent = out; } else { if( trace ) fprintf(stderr,"Skipping %s before codon\n",alc->alu[1]->text_label); /* do nothing if not a codon - march on */ } } /* free_AlnBlock(coll);*/ return 1; } /* Function: is_exon_AlnColumn_new(alc) * * Descrip: helper function for new system * * * Arg: alc [UNKN ] Undocumented argument [AlnColumn *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 321 "geneutil.dy" boolean is_exon_AlnColumn_new(AlnColumn * alc) { if( strstr(alc->alu[1]->text_label,"CODON") != NULL ) { return TRUE; } else { return FALSE; } } /* Function: is_splice_site_AlnColumn(alc,type,phase) * * Descrip: helper function for the new system * * * Arg: alc [UNKN ] Undocumented argument [AlnColumn *] * Arg: type [UNKN ] Undocumented argument [int *] * Arg: phase [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 335 "geneutil.dy" boolean is_splice_site_AlnColumn(AlnColumn * alc,int * type,int * phase) { if( strstr(alc->alu[1]->text_label,"SS") != NULL ) { if( strstr(alc->alu[1]->text_label,"5SS") != NULL ) { *type = 5; } else { *type = 3; } if( strstr(alc->alu[1]->text_label,"0") != NULL ) { *phase = 0; } else if ( strstr(alc->alu[1]->text_label,"1") != NULL ) { *phase = 1; } else if ( strstr(alc->alu[1]->text_label,"2") != NULL ) { *phase = 2; } return TRUE; } else { return FALSE; } } /* Function: Gene_from_AlnColumn_new(alc,end) * * Descrip: A new hope for building genes * * * Arg: alc [UNKN ] Undocumented argument [AlnColumn *] * Arg: end [UNKN ] Undocumented argument [AlnColumn **] * * Return [UNKN ] Undocumented return value [Gene *] * */ # line 362 "geneutil.dy" Gene * Gene_from_AlnColumn_new(AlnColumn * alc,AlnColumn ** end) { Gene * out; Transcript * tr; Translation * ts; Exon * ex; int exon_start; int exon_end; int phase_start; int phase_end; int is_reversed; int is_3ss; int phase; int type; int tmp; AlnColumn * prev; boolean end_gene = 0; while(alc != NULL && is_exon_AlnColumn_new(alc) == FALSE ) alc = alc->next; if( alc == NULL ) { *end = NULL; return NULL; } if( strstr(alc->alu[1]->text_label,"CODON") == NULL ) { warn("Bad news... exited from random columns, but not in a codon column, in a %s",alc->alu[1]->text_label); * end = NULL; return NULL; } /* we should have either a forward or reversed gene */ if( strstr(alc->alu[1]->text_label,"REV") != NULL ) { is_reversed = 1; } else { is_reversed = 0; } out = Gene_alloc_len(1); tr = Transcript_alloc_std(); add_Gene(out,tr); out->start = alc->alu[1]->start +1; phase_start = 0; exon_start = 0; /* by definition, the first exon is at the start*/ is_3ss = 0; for(;;) { if( strstr(alc->alu[1]->text_label,"GENE_EXIT") != NULL ) { break; } exon_start = alc->alu[1]->start+1 - out->start; if( is_3ss ) { if( phase_start == 0 ) { exon_start -= 3; } else if ( phase_start == 1 ) { exon_start -= 2; } else if ( phase_start == 2 ) { exon_start -= 1; } } /* this is at the start of exon */ /* go to the end of the exon */ for(; alc != NULL && is_exon_AlnColumn_new(alc);alc=alc->next) { fprintf(stdout,"Exonifying past %d %s\n",alc->alu[1]->start,alc->alu[1]->text_label); prev = alc; } /* irregardless of the fate of this exon, we now can put it * in, as if it was phase0-phase0 */ exon_end = prev->alu[1]->end +1 - out->start; ex = Exon_alloc_std(); fprintf(stdout,"Adding exon with %d-%d\n",ex->start,ex->end); add_ex_Transcript(tr,ex); ex->start = exon_start; ex->end = exon_end; if( alc != NULL && is_splice_site_AlnColumn(alc,&type,&phase) ) { phase_end = phase; } else { is_3ss = 0; phase_end = 0; end_gene = 1; } /* jigging the splice sites for the phases */ if( phase_end == 0 ) { ex->end = ex->end; } else if( phase_end == 1 ) { ex->end = ex->end +1; } else if( phase_end == 2 ) { ex->end = ex->end +2; } ex->phase = phase_start; if( end_gene == 1 ) { break; } for(; alc != NULL && !is_exon_AlnColumn_new(alc);alc=alc->next) { /* fprintf(stdout,"Moving past %d %s\n",alc->alu[1]->start,alc->alu[1]->text_label);*/ if( is_splice_site_AlnColumn(alc,&type,&phase) ) { is_3ss = 1; phase_start = phase; } if( strstr(alc->alu[1]->text_label,"GENE_EXIT") != NULL ) { /* fprintf(stdout,"Exiting %d %s\n",alc->alu[1]->start,alc->alu[1]->text_label); */ end_gene = 1; break; } } if( end_gene == 1 ) { break; } if( alc == NULL ) { break; } } *end = alc; out->end = ex->end + out->start; if( is_reversed == 1 ) { tmp = out->start; out->start = out->end; out->end = tmp; } ts = Translation_alloc(); ts->start = 0; ts->end = length_Transcript(tr); ts->parent = tr; add_Transcript(tr,ts); tr->parent = out; fprintf(stdout,"returning gene %d %d\n",out->start,out->end); return out; } /* Function: Gene_from_AlnColumn_GeneWise(alc,org_start,org_end,predict_pseudo_for_frameshift,end) * * Descrip: A wrap for making a gene structure from * an AlnBlock derived from one of the genewise * methods * * * Arg: alc [UNKN ] Alignment column in an AlnBlock produced by genewise [AlnColumn *] * Arg: org_start [UNKN ] offset that the genewise alignment was to the coordinate system [int] * Arg: org_end [UNKN ] emd that the genewise alignment was to the coordinate system [int] * Arg: predict_pseudo_for_frameshift [UNKN ] Undocumented argument [boolean] * Arg: end [WRITE] pointer to a AlnColumn * to say when it has finished with this gene [AlnColumn **] * * Return [UNKN ] Undocumented return value [Gene *] * */ # line 537 "geneutil.dy" Gene * Gene_from_AlnColumn_GeneWise(AlnColumn * alc,int org_start,int org_end,boolean predict_pseudo_for_frameshift,AlnColumn ** end) { Gene * out; Transcript * tr; Translation * ts; Exon * ex; AlnColumn * prev; SupportingFeature * sf; int score = 0; int dosf = 0; int phase = 0; int frame_break = 0; while(alc != NULL && is_random_AlnColumn_genewise(alc) == TRUE ) alc = alc->next; while (alc != NULL && strcmp(alc->alu[1]->text_label,"CODON") != 0 ) alc = alc->next; if( alc == NULL) return NULL; out = Gene_alloc_len(1); tr = Transcript_alloc_std(); add_Gene(out,tr); out->start = alc->alu[1]->start +1; score += alc->alu[0]->score[0]; for(;;) { /* fprintf(stderr,"Top loop - alc at %s %s\n",alc->alu[1]->text_label,alc->alu[0]->text_label); */ /* fprintf(stderr,"2 Score is %.2f %s %d %.2f\n",Score2Bits(score),alc->alu[1]->text_label,alc->alu[0]->score[0],Score2Bits(alc->alu[0]->score[0]));*/ ex = Exon_alloc_std(); add_ex_Transcript(tr,ex); /* * this is always the start of an exon */ dosf = 0; if( strcmp(alc->alu[1]->text_label,"CODON") == 0 ) { ex->start = alc->alu[1]->start+1 - out->start; /* coordinated in alignment coords */ dosf = 1; phase = 0; } else if ( strcmp(alc->alu[1]->text_label,"3SS_PHASE_0") == 0 ) { ex->start = alc->alu[1]->start +4 - out->start; dosf = 1; phase = 0; } else if ( strcmp(alc->alu[1]->text_label,"3SS_PHASE_1") == 0 ) { ex->start = alc->alu[1]->start +4 - out->start; phase = 1; } else if ( strcmp(alc->alu[1]->text_label,"3SS_PHASE_2") == 0 ) { ex->start = alc->alu[1]->start +4 - out->start; phase = 2; } else { ex->start = alc->alu[1]->start +1 - out->start; /* coordinated in alignment coords */ phase = -1; } ex->phase = phase; /* * Exons can start in INSERTs (yuk). In which case we don't * make a supporting feature */ if( dosf == 1 && strstartcmp(alc->alu[0]->text_label,"INSERT") != 0 ) { sf = SupportingFeature_alloc(); /* we fill in start and end from the exon at the moment. Not pretty */ sf->hstart = alc->alu[0]->start+1; sf->hstrand = 1; /* currently only got proteins. Thank the lord! */ sf->start = ex->start; } else { sf = NULL; /* make sure we don't generate a sf here */ } for(prev=alc,alc=alc->next;alc != NULL; ) { /* fprintf(stderr,"Exon loop - alc at %s %s %d\n",alc->alu[1]->text_label,alc->alu[0]->text_label,sf); */ score += alc->alu[0]->score[0]; /* fprintf(stderr,"1 Score is %.2f %s\n",Score2Bits(score),alc->alu[1]->text_label); */ if( is_frameshift_AlnColumn_genewise(alc) == TRUE && predict_pseudo_for_frameshift == TRUE ) { score += alc->alu[0]->score[0]; fprintf(stderr,"Score is %.2f\n",Score2Bits(score)); out->ispseudo = TRUE; alc = alc->next; continue; } if( is_random_AlnColumn_genewise(alc) == TRUE) break; if( strcmp(alc->alu[1]->text_label,"CODON") != 0 ) { if( strstartcmp(alc->alu[0]->text_label,"DELETE") == 0 ) { /* must add sf and start a new one */ /*fprintf(stderr,"Looking at alc at %s %s %d %d %d\n",alc->alu[1]->text_label,alc->alu[0]->text_label,prev,out,sf);*/ if( sf != NULL ) { sf->end = prev->alu[1]->end+1 - out->start; sf->hend = prev->alu[0]->end+1; add_Exon(ex,sf); sf = NULL; } /* * go the end of this delete run, which are residues in the query with no * target info */ while( alc->next != NULL && strstartcmp(alc->next->alu[0]->text_label,"DELETE") == 0 ) { alc = alc->next; } if( alc->next != NULL && strcmp(alc->next->alu[1]->text_label,"CODON") == 0 ) { /* the next position is the start of the new alignment */ sf = SupportingFeature_alloc(); sf->hstart = alc->next->alu[0]->start+1; sf->start = alc->next->alu[1]->start+1 - out->start; } else { sf = NULL; } } else { break; } } else { /* it is a codon match, but it could be an insert */ if( strstartcmp(alc->alu[0]->text_label,"INSERT") == 0) { /* break at this point, add this supporting feature */ if( sf != NULL ) { sf->end = prev->alu[1]->end+1 - out->start; sf->hend = prev->alu[0]->end+1; add_Exon(ex,sf); sf = NULL; } frame_break = 0; /* go to the end of this insert run, watching for frameshifts */ while( alc->next != NULL && strstartcmp(alc->next->alu[0]->text_label,"INSERT") == 0 ) { if( is_frameshift_AlnColumn_genewise(alc->next) == TRUE || is_random_AlnColumn_genewise(alc->next) == TRUE) { if( is_frameshift_AlnColumn_genewise(alc->next) == TRUE && predict_pseudo_for_frameshift == TRUE ) { out->ispseudo = TRUE; alc = alc->next; continue; } else { alc = alc->next; frame_break = 1; break; } } alc = alc->next; } if( frame_break == 1 ) { break; /* out of this gene */ } if( alc->next != NULL && strcmp(alc->next->alu[1]->text_label,"CODON") == 0 ) { /* the next position is the start of the new alignment */ sf = SupportingFeature_alloc(); /* do not understand why not having a +1 here is correct. Hmph */ sf->hstart = alc->next->alu[0]->start+1; sf->start = alc->next->alu[1]->start+1 - out->start; } else { sf = NULL; } } else { /* could be the start of a run from INSERT into match */ if( sf == NULL ) { sf = SupportingFeature_alloc(); /* we fill in start and end from the exon at the moment. Not pretty */ sf->hstart = alc->alu[0]->start+1; sf->hstrand = 1; /* currently only got proteins. Thank the lord! */ sf->start = alc->alu[1]->start+1 - out->start; } } } /* end of else it is a codon match */ prev = alc; alc = alc->next; } /* * The exon has ended. But why? */ if( sf != NULL ) { sf->hend = prev->alu[0]->end+1; add_Exon(ex,sf); } if( alc == NULL ) { out->end = prev->alu[1]->end +1; ex->end = out->end - out->start; if( sf != NULL ) { sf->end = ex->end; } break; } if( is_random_AlnColumn_genewise(alc) == TRUE) { out->end = prev->alu[1]->end +1; ex->end = out->end - out->start; if( sf != NULL ) { sf->end = ex->end; } break; } /* fprintf(stderr,"Exiting out of exon loop...\n");*/ if( strcmp(alc->alu[1]->text_label,"5SS_PHASE_0") == 0 ) { out->end = alc->alu[1]->start+1; phase = 0; } else if ( strcmp(alc->alu[1]->text_label,"5SS_PHASE_1") == 0 ) { out->end = alc->alu[1]->start+2; phase = 1; } else if ( strcmp(alc->alu[1]->text_label,"5SS_PHASE_2") == 0 ) { out->end = alc->alu[1]->start+3; phase = 2; } else { phase = 0; /* fixes from Steve, via an issue with Steve */ if ( strncmp(prev->alu[1]->text_label,"3SS_PHASE_0",11) == 0 ) { out->end = prev->alu[1]->end + 4; } else if ( strncmp(prev->alu[1]->text_label,"3SS_PHASE_1",11) == 0 ) { out->end = prev->alu[1]->end + 4; } else if ( strncmp(prev->alu[1]->text_label,"3SS_PHASE_1",11) == 0 ) { out->end = prev->alu[1]->end + 4; } else { out->end = prev->alu[1]->end +1; } ex->end = out->end - out->start; if( sf != NULL ) { sf->end = ex->end; } break; } /** set end of exon to the correct size from here **/ ex->end = out->end - out->start; /** sf is to the codon, not to the exon */ if( sf != NULL ) { if( phase == 0 ) { sf->end = ex->end; } else if ( phase == 1 ) { sf->end = ex->end-1; } else { sf->end = ex->end-2; } } while( alc != NULL && strstartcmp(alc->alu[1]->text_label,"3SS") != 0 ) { /* fprintf(stderr,"Intron loop - alc at %s %s %d\n",alc->alu[1]->text_label,alc->alu[0]->text_label,sf); */ alc = alc->next; score += alc->alu[0]->score[0]; } if( alc == NULL ) { warn("Got to the end of an alignment inside an intron. Oooops!"); break; } }/* back to for(;;) */ if( end != NULL ) *end = alc; if( org_start < org_end) { out->start += org_start-1; out->end += org_start-1; } else { /* fprintf(stderr,"was %d to %d\n",out->start,out->end); */ out->start = org_start-1 - out->start; out->end = org_start-1 - out->end; /* fprintf(stderr,"now %d to %d (%d)\n",out->start,out->end,org_start); */ } if( out->ispseudo == FALSE ) { ts = Translation_alloc(); ts->start = 0; ts->end = length_Transcript(tr); ts->parent = tr; add_Transcript(tr,ts); } tr->parent = out; out->bits = Score2Bits(score); return out; } /* Function: is_frameshift_AlnColumn_genewise(alc) * * Descrip: This function is to say what is a frameshift label * * * Arg: alc [UNKN ] Undocumented argument [const AlnColumn *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 854 "geneutil.dy" boolean is_frameshift_AlnColumn_genewise(const AlnColumn * alc) { if( strcmp(alc->alu[1]->text_label,"SEQUENCE_INSERTION") == 0 ) { return TRUE; } if( strcmp(alc->alu[1]->text_label,"SEQUENCE_DELETION") == 0 ) { return TRUE; } return FALSE; } /* Function: is_random_AlnColumn_genewise(alc) * * Descrip: This function is to say where this should * be skipped in alignment/gene prediction problems * * * Arg: alc [UNKN ] Undocumented argument [const AlnColumn *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 870 "geneutil.dy" boolean is_random_AlnColumn_genewise(const AlnColumn * alc) { char * la; la = alc->alu[1]->text_label; if( strcmp(la,"RANDOM_SEQUENCE") == 0 ) return TRUE; if( strcmp(la,"END") == 0 ) return TRUE; la = alc->alu[0]->text_label; if( strstr(la,"_RND_") != NULL ) return TRUE; return FALSE; } /* Function: is_intron_AlnColumn_genewise(alc) * * Descrip: This function is to say where things are introns * * * Arg: alc [UNKN ] Undocumented argument [const AlnColumn *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 894 "geneutil.dy" boolean is_intron_AlnColumn_genewise(const AlnColumn * alc) { char * la; la = alc->alu[1]->text_label; if( strcmp(la,"CENTRAL_INTRON") == 0 ) return TRUE; if( strcmp(la,"PYRIMIDINE_TRACT") == 0 ) return TRUE; if( strcmp(la,"SPACER") == 0 ) return TRUE; return FALSE; } #define GW_EXON_TYPE_UTR5 45 #define GW_EXON_TYPE_CDS 46 #define GW_EXON_TYPE_UTR3 47 #define GW_EXON_TYPE_NONE 48 # line 916 "geneutil.dy" int exon_type_AlnColumn_genomewise(AlnColumn * alc) { if( strcmp(alc->alu[1]->text_label,"CODON") == 0 ) { return GW_EXON_TYPE_CDS; } if( strcmp(alc->alu[1]->text_label,"UTR5") == 0 ) { return GW_EXON_TYPE_UTR5; } if( strcmp(alc->alu[1]->text_label,"UTR3") == 0 || strcmp(alc->alu[1]->text_label,"STOP_CODON") == 0) { return GW_EXON_TYPE_UTR3; } return GW_EXON_TYPE_NONE; } # line 934 "geneutil.dy" void show_utr_exon_genomewise(AlnBlock * alb,FILE * ofp) { AlnColumn * alc; int exon_start; int exon_end; int is_start; int phase; int endphase; int is_3ss; for(alc=alb->start;alc != NULL;) { /* find the first exon */ for(;alc != NULL && exon_type_AlnColumn_genomewise(alc) != GW_EXON_TYPE_UTR5;alc = alc->next) ; if( alc == NULL ) { break; } fprintf(ofp,"Gene\n"); if( alc != NULL && exon_type_AlnColumn_genomewise(alc) == GW_EXON_TYPE_UTR5 ) { is_start = 1; while( alc != NULL ) { /* while loop goes over all 5UTRs */ exon_start = alc->alu[1]->start+ (is_start ? 2 : 3); is_start = 0; for(;alc != NULL && exon_type_AlnColumn_genomewise(alc) == GW_EXON_TYPE_UTR5;alc = alc->next ) { ; } /* fprintf(stderr,"Broken out with %s\n",alc->alu[1]->text_label); */ if( strcmp(alc->alu[1]->text_label,"UTR5_INTRON") ==0 ) { /* ntron. should be +2-1 at the end of this, goes to 1*/ fprintf(ofp," utr5 %d %d\n",exon_start,alc->alu[1]->start+1); /* now loop through the intron */ for(;alc != NULL && strcmp(alc->alu[1]->text_label,"UTR5_INTRON") == 0;alc = alc->next ) { ; } if( alc == NULL || exon_type_AlnColumn_genomewise(alc) != GW_EXON_TYPE_UTR5 ) { break; /* while loop */ } else{ continue; /* another utr5 exon */ } } else { /* print this guy and break */ fprintf(ofp," utr5 %d %d\n",exon_start,alc->alu[1]->start+1); break; } } } /* we now should be at a CDS column */ if( alc != NULL && exon_type_AlnColumn_genomewise(alc) == GW_EXON_TYPE_CDS ) { is_start = 1; while( alc != NULL ) { /* while loop goes over all coding Exons */ /* fprintf(stderr,"Entering codoing loop with %s\n",alc->alu[1]->text_label); */ exon_start = alc->alu[1]->start+2; if( strstr(alc->alu[1]->text_label,"3SS") != NULL ) { is_3ss = 1; if( strstr(alc->alu[1]->text_label,"1") != NULL ) { phase = 1; } else if ( strstr(alc->alu[1]->text_label,"2") != NULL ) { phase = 2; } else { phase = 0; } alc = alc->next; } else { is_3ss = 0; phase = 0; } if( phase == 1 ) { exon_start += 3; } else if ( phase == 2) { exon_start += 3; } else if ( is_3ss ) { /* phase 0 and spliced needs adjusting */ exon_start += 3; } for(;alc != NULL && exon_type_AlnColumn_genomewise(alc) == GW_EXON_TYPE_CDS ;alc = alc->next ) { ; } if( strstr(alc->alu[1]->text_label,"5SS") != NULL ) { exon_end = alc->alu[1]->start+1; if( strstr(alc->alu[1]->text_label,"1") != NULL ) { endphase = 1; } else if ( strstr(alc->alu[1]->text_label,"2") != NULL ) { endphase = 2; } else { endphase = 0; } if( endphase == 1 ) { exon_end += 1; } else if( endphase == 2 ) { exon_end += 2; } /* no change for phase 0 */ /* intron. should be +1-1 at the end of this, goes to 0*/ fprintf(ofp," cds %d %d phase %d\n",exon_start,exon_end,phase); /* now loop through the intron */ for(alc= alc->next;alc != NULL && strstr(alc->alu[1]->text_label,"3SS") == NULL;alc = alc->next ) { ; } if( alc == NULL || strstr(alc->alu[1]->text_label,"3SS") == NULL ) { break; /* while loop */ } else{ continue; /* another cds exon */ } } else { fprintf(ofp," cds %d %d phase %d\n",exon_start,alc->alu[1]->start+1,phase); break; } } } if( alc != NULL && exon_type_AlnColumn_genomewise(alc) == GW_EXON_TYPE_UTR3 ) { is_start = 1; while( alc != NULL ) { /* while loop goes over all 3UTRs */ exon_start = alc->alu[1]->start+ (is_start ? 2 : 3); is_start = 0; for(;alc != NULL && exon_type_AlnColumn_genomewise(alc) == GW_EXON_TYPE_UTR3 ;alc = alc->next ) { ; } if( strstr(alc->alu[1]->text_label,"INTRON") != NULL ) { /* intron. should be +2-1 at the end of this, goes to 1*/ fprintf(ofp," utr3 %d %d\n",exon_start,alc->alu[1]->start+1); /* now loop through the intron */ for(;alc != NULL && strstr(alc->alu[1]->text_label,"INTRON") != NULL;alc = alc->next ) { ; } if( alc == NULL || exon_type_AlnColumn_genomewise(alc) != GW_EXON_TYPE_UTR3 ) { break; /* while loop */ } else{ continue; /* another utr3 exon */ } } else { fprintf(ofp," utr3 %d %d\n",exon_start,alc->alu[1]->start+1); break; } } } fprintf(ofp,"End\n"); /* back to next gene */ } } # line 1149 "geneutil.c" #ifdef _cplusplus } #endif wise-2.4.1/src/models/geneutil.h0000644000175000001440000001422410670453714016122 0ustar philippusers#ifndef DYNAMITEgeneutilHEADERFILE #define DYNAMITEgeneutilHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_GenomicRegion_from_GeneWise(gen,pseudo,alb) * * Descrip: Makes a new GenomicRegion with the genes * predicted from this AlnBlock * * Really a wrapper around the add_Genes_to_GenomicRegion_GeneWise * and other functionality * * * Arg: gen [UNKN ] genomic sequence to use [Genomic *] * Arg: pseudo [UNKN ] If true, predicts frameshifted genes as pseudogenes [boolean] * Arg: alb [UNKN ] genewise alignment to predict genes from [AlnBlock *] * * Return [UNKN ] a newly allocated structure [GenomicRegion *] * */ GenomicRegion * Wise2_new_GenomicRegion_from_GeneWise(Genomic * gen,boolean pseudo,AlnBlock * alb); #define new_GenomicRegion_from_GeneWise Wise2_new_GenomicRegion_from_GeneWise /* Function: add_Genes_to_GenomicRegion_GeneWise(gr,org_start,org_end,alb,root,pseudo,make_name) * * Descrip: Potential an Alnblock may have more * than one gene due to looping models * * This adds all the genes to gr * * * * Arg: gr [UNKN ] genomic region to add genes to [GenomicRegion *] * Arg: org_start [UNKN ] start point of the dna to which the alb was made from [int] * Arg: org_end [UNKN ] end point of the dna to which the alb was made from [int] * Arg: alb [UNKN ] logical label alignment [AlnBlock *] * Arg: root [UNKN ] the second argument to make_name [char *] * Arg: pseudo [UNKN ] If true, frameshifted genes are predicted as pseudo genes [boolean] * Arg: make_name [FUNCP] a pointer to a function to actually make the name of the gene [char * (*make_name] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_add_Genes_to_GenomicRegion_GeneWise(GenomicRegion * gr,int org_start,int org_end,AlnBlock * alb,char * root,boolean pseudo,char * (*make_name)(Wise2_Genomic *,char *,int ,Wise2_Gene * )); #define add_Genes_to_GenomicRegion_GeneWise Wise2_add_Genes_to_GenomicRegion_GeneWise /* Function: add_Genes_to_GenomicRegion_new(gr,alb) * * Descrip: Adds genes using the new gene function * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_add_Genes_to_GenomicRegion_new(GenomicRegion * gr,AlnBlock * alb); #define add_Genes_to_GenomicRegion_new Wise2_add_Genes_to_GenomicRegion_new /* Function: is_exon_AlnColumn_new(alc) * * Descrip: helper function for new system * * * Arg: alc [UNKN ] Undocumented argument [AlnColumn *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_exon_AlnColumn_new(AlnColumn * alc) ; #define is_exon_AlnColumn_new Wise2_is_exon_AlnColumn_new /* Function: is_splice_site_AlnColumn(alc,type,phase) * * Descrip: helper function for the new system * * * Arg: alc [UNKN ] Undocumented argument [AlnColumn *] * Arg: type [UNKN ] Undocumented argument [int *] * Arg: phase [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_splice_site_AlnColumn(AlnColumn * alc,int * type,int * phase); #define is_splice_site_AlnColumn Wise2_is_splice_site_AlnColumn /* Function: Gene_from_AlnColumn_new(alc,end) * * Descrip: A new hope for building genes * * * Arg: alc [UNKN ] Undocumented argument [AlnColumn *] * Arg: end [UNKN ] Undocumented argument [AlnColumn **] * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * Wise2_Gene_from_AlnColumn_new(AlnColumn * alc,AlnColumn ** end); #define Gene_from_AlnColumn_new Wise2_Gene_from_AlnColumn_new /* Function: Gene_from_AlnColumn_GeneWise(alc,org_start,org_end,predict_pseudo_for_frameshift,end) * * Descrip: A wrap for making a gene structure from * an AlnBlock derived from one of the genewise * methods * * * Arg: alc [UNKN ] Alignment column in an AlnBlock produced by genewise [AlnColumn *] * Arg: org_start [UNKN ] offset that the genewise alignment was to the coordinate system [int] * Arg: org_end [UNKN ] emd that the genewise alignment was to the coordinate system [int] * Arg: predict_pseudo_for_frameshift [UNKN ] Undocumented argument [boolean] * Arg: end [WRITE] pointer to a AlnColumn * to say when it has finished with this gene [AlnColumn **] * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * Wise2_Gene_from_AlnColumn_GeneWise(AlnColumn * alc,int org_start,int org_end,boolean predict_pseudo_for_frameshift,AlnColumn ** end); #define Gene_from_AlnColumn_GeneWise Wise2_Gene_from_AlnColumn_GeneWise /* Unplaced functions */ /* There has been no indication of the use of these functions */ int Wise2_exon_type_AlnColumn_genomewise(AlnColumn * alc) ; #define exon_type_AlnColumn_genomewise Wise2_exon_type_AlnColumn_genomewise void Wise2_show_utr_exon_genomewise(AlnBlock * alb,FILE * ofp); #define show_utr_exon_genomewise Wise2_show_utr_exon_genomewise /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_is_frameshift_AlnColumn_genewise(const AlnColumn * alc); #define is_frameshift_AlnColumn_genewise Wise2_is_frameshift_AlnColumn_genewise boolean Wise2_is_random_AlnColumn_genewise(const AlnColumn * alc); #define is_random_AlnColumn_genewise Wise2_is_random_AlnColumn_genewise boolean Wise2_is_intron_AlnColumn_genewise(const AlnColumn * alc); #define is_intron_AlnColumn_genewise Wise2_is_intron_AlnColumn_genewise #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/phasemodel.dy0000644000175000001440000002310710670452661016614 0ustar philippusers %{ #include "genewisemodel.h" #define GenePhaseModelLISTLENGTH 128 #define GenePhaseScoreLISTLENGTH 128 #define ProteinIntronListLISTLENGTH 30 %} struct ProteinIntron int position int phase struct ProteinIntronList ProteinIntron ** intron !list struct PhasedProtein Sequence * protein ProteinIntronList * list struct PhasedProteinPara Probability marked_intron !def="0.95" Probability unmarked_intron !def="0.000001" int gap !def="-12" int ext !def="-2" boolean use_phase char * intron_file struct PhasedHMM ThreeStateModel * tsm ProteinIntronList * list struct GenePhaseSeg Probability intron_0 Probability intron_1 Probability intron_2 Probability insert_intron struct GenePhaseModel GenePhaseSeg ** phase !list GeneWise * gw struct GenePhaseSegScore Score intron_0 Score intron_1 Score intron_2 Score insert_intron struct GenePhaseScore GenePhaseSegScore ** phase !list GeneWiseScore * gws %{ #include "phasemodel.h" ProteinIntronList * read_ProteinIntronList(FILE * ifp) { ProteinIntronList * out; ProteinIntron * in; char line[MAXLINE]; char * run1; char * run2; int pos; int phase; out = ProteinIntronList_alloc_std(); while( fgets(line,MAXLINE,ifp) != NULL ) { if( line[0] == '#' ) { continue; } if( !isnumber(line[0]) ) { warn("Bad looking line in intron file, %s",line); continue; } if( sscanf(line,"%d %d",&pos,&phase) != 2 ) { warn("Unable to parse line in intron file %s",line); continue; } if( phase > 2 || phase < 0 ) { warn("Got phase of %d, when must be between 0 and 2",phase); continue; } in = ProteinIntron_alloc(); pos--; in->position = pos; in->phase = phase; add_ProteinIntronList(out,in); } return out; } ProteinIntronList * read_ProteinIntronList_from_filename(char * f) { ProteinIntronList * pl; FILE * ifp; ifp = openfile(f,"r"); if( ifp == NULL ) { warn("Cannot open file %s",f); return NULL; } pl = read_ProteinIntronList(ifp); fclose(ifp); return pl; } PhasedProteinPara * new_PhasedProteinPara_from_argv(int * argc,char ** argv) { PhasedProteinPara * out; char * temp; out = PhasedProteinPara_alloc(); out->marked_intron = 0.95; out->unmarked_intron = 0.00001; out->use_phase = 0; strip_out_float_argument(argc,argv,"phase_marked",&out->marked_intron); strip_out_float_argument(argc,argv,"phase_unmarked",&out->unmarked_intron); /* strip_out_boolean_def_argument(argc,argv,"phase_model",&out->use_phase); */ if( (temp = strip_out_assigned_argument(argc,argv,"phase_file")) != NULL ) { out->intron_file = stringalloc(temp); } if( strip_out_boolean_argument(argc,argv,"phase_help") == TRUE ) { fprintf(stdout,"Phased marks provide the ability to restrict the position of introns\n"); fprintf(stdout,"relative to the protein sequence; ie, assuming conserved introns. This\n"); fprintf(stdout,"is most useful for fast evolving genes inside of relatively consistent\n"); fprintf(stdout,"clades, eg for fast evolving genes, such as cytokines, in vertebrates\n"); fprintf(stdout,"As moving between clades - say between Human and Drosophila - the intron\n"); fprintf(stdout,"positions change, using these options would actively hinder good gene prediction\n"); fprintf(stdout,"\n"); fprintf(stdout,"This option can be used for either HMMs or proteins, although it is harder\n"); fprintf(stdout,"to coordinate the HMM intron position than the protein positions.\n"); fprintf(stdout,"Two things need to occur to use the phase information\n"); fprintf(stdout," provide a phase mark file as -phase_file \n"); fprintf(stdout," use the algorithm type 623P (6 states, 23 transitions, phased introns)\n"); fprintf(stdout,"\n"); fprintf(stdout,"The phase model attempts to make a ATG to STOP gene, even if the protein match\n"); fprintf(stdout,"is not present across the entire gene. One major headache in this are introns in first\n"); fprintf(stdout,"ATG, which is not handled at the moment\n\n"); fprintf(stdout,"Genewise uses the protein position, in 1 coordinates, (first amino acid is 1)\n"); fprintf(stdout,"for the definition of the intron. For phase 0 introns, it should be labeled as\n"); fprintf(stdout,"the amino acid before the intron. For phase 1 and 2 introns, this is on the intron\n\n"); fprintf(stdout,"We suggest using a small spread of positions to cope with intron positioning errors\n"); fprintf(stdout," eg, defining an intron at position 4, phase 0, make postions 3,4 and 5 with position 0\n\n"); fprintf(stdout,"The phase file format is\n"); fprintf(stdout,"# lines starting with hash are comments\n"); fprintf(stdout,"# three tab delimited columns\n"); fprintf(stdout,"# \n"); fprintf(stdout,"# eg\n"); fprintf(stdout,"4 0\n"); exit(0); } return out; } void show_help_PhasedProteinPara(FILE * ofp) { fprintf(ofp,"Phased Protein/HMM parameters (separate from other options)\n"); fprintf(ofp," -phase_marked [0.95] Probability of marked introns\n"); fprintf(ofp," -phase_unmarked [0.00001] Probability of unmarked introns\n"); fprintf(ofp," -phase_file [filename] Intron positions and phases\n"); fprintf(ofp," -phase_help prints longer help on phase file and exits\n"); } void write_fasta_PhasedProtein(PhasedProtein * pp,FILE * ofp) { int i; int j; int line; assert(pp != NULL); write_fasta_Sequence(pp->protein,ofp); fprintf(ofp,">%s\n",pp->protein->name); for(i=0,j=0,line = 0;iprotein->len;i++) { if( line != 0 && line % 50 == 0 ) { fputc('\n',ofp); } fputc(pp->protein->seq[i],ofp); line++; if( j < pp->list->len && pp->list->intron[j]->position == i ) { fputc('0'+pp->list->intron[j]->phase,ofp); line++; j++; } } } PhasedProtein * read_fasta_PhasedProtein_file(char * file) { PhasedProtein * pp; FILE * ifp; ifp = openfile(file,"r"); pp = read_fasta_PhasedProtein(ifp); fclose(ifp); return pp; } PhasedProtein * read_fasta_PhasedProtein(FILE * ifp) { PhasedProtein * pp; ProteinIntron * intron; Sequence * input; int i; int j; char seqbuffer[10000]; char name[2000]; char c; pp = PhasedProtein_alloc(); pp->list = ProteinIntronList_alloc_std(); fgets(name,10000,ifp); assert(name[0] == '>'); for(i=1; !isspace(name[i]);i++) { ; } name[i] = '\0'; i = 0; while( (c = fgetc(ifp)) != EOF ) { if( c == '>' ) { ungetc('>',ifp); break; } if( isalpha(c) ) { seqbuffer[i++] = c; } else if( c == '0' || c == '1' || c == '2' ) { intron = ProteinIntron_alloc(); intron->position = i-1; intron->phase = c - '0'; add_ProteinIntronList(pp->list,intron); } } seqbuffer[i] = '\0'; pp->protein = Sequence_from_static_memory(name+1,seqbuffer); return pp; } GenePhaseModel * GenePhaseModel_from_ThreeStateModel(ThreeStateModel * tsm,CodonMapper * cm,RandomModel * rm,CompMat * mat,PhasedProteinPara * ppp) { GenePhaseModel * out; ProteinIntronList * pl; int i; int j; assert(ppp != NULL); assert(tsm != NULL); assert(rm != NULL); assert(mat != NULL); pl = read_ProteinIntronList_from_filename(ppp->intron_file); assert(pl != NULL); out = GenePhaseModel_alloc_std(); /* current set this at global */ for(i=0;ilen;i++) { tsm->unit[i]->transition[TSM_START2MATCH] = 0.0; tsm->unit[i]->transition[TSM_MATCH2END] = 0.0; } tsm->unit[0]->transition[TSM_START2MATCH] = 1.0; tsm->unit[tsm->len-1]->transition[TSM_MATCH2END] = 1.0; out->gw = GeneWise_from_ThreeStateModel_setfactor(tsm,0.95,cm,0.1); for(i=0,j=0;ilen;i++) { /* set to default first */ add_GenePhaseModel(out,GenePhaseSeg_alloc()); out->phase[i]->intron_0 = ppp->unmarked_intron; out->phase[i]->intron_1 = ppp->unmarked_intron; out->phase[i]->intron_2 = ppp->unmarked_intron; out->phase[i]->insert_intron = ppp->unmarked_intron; if( j < pl->len && i == pl->intron[j]->position ) { if( pl->intron[j]->phase == 0 ) { out->phase[i]->intron_0 = ppp->marked_intron; } if( pl->intron[j]->phase == 1 ) { out->phase[i]->intron_1 = ppp->marked_intron; } if( pl->intron[j]->phase == 2 ) { out->phase[i]->intron_2 = ppp->marked_intron; } out->gw->seg[i]->transition[GW_MATCH2MATCH] = (1.0 - ppp->marked_intron)*out->gw->seg[i]->transition[GW_MATCH2MATCH]; out->gw->seg[i]->transition[GW_MATCH2INSERT] = (1.0 - ppp->marked_intron)*out->gw->seg[i]->transition[GW_MATCH2INSERT]; out->gw->seg[i]->transition[GW_MATCH2DELETE] = (1.0 - ppp->marked_intron)*out->gw->seg[i]->transition[GW_MATCH2DELETE]; out->gw->seg[i]->transition[GW_DELETE2DELETE] = (1.0 - ppp->marked_intron)*out->gw->seg[i]->transition[GW_DELETE2DELETE]; out->gw->seg[i]->transition[GW_DELETE2MATCH] = (1.0 - ppp->marked_intron)*out->gw->seg[i]->transition[GW_DELETE2MATCH]; j++; } } return out; } GenePhaseScore * GenePhaseScore_from_GenePhaseModel(GenePhaseModel * gpm) { int i; GenePhaseScore * out; assert(gpm != NULL); assert(gpm->gw != NULL); assert(gpm->gw->len == gpm->len); out = GenePhaseScore_alloc_len(gpm->len); out->gws = GeneWiseScore_from_GeneWise(gpm->gw); for(i=0;ilen;i++) { add_GenePhaseScore(out,GenePhaseSegScore_alloc()); out->phase[i]->intron_0 = Probability2Score(gpm->phase[i]->intron_0); out->phase[i]->intron_1 = Probability2Score(gpm->phase[i]->intron_1); out->phase[i]->intron_2 = Probability2Score(gpm->phase[i]->intron_2); } return out; } %} wise-2.4.1/src/models/test_aligng.c0000644000175000001440000000152207502704706016576 0ustar philippusers#include "aligngenemodel.h" #include int main(int argc,char ** argv) { AlignGeneModelParam * agmp; SeqAlign * sal; Sequence * seq; CompProb * cp; CodonTable * ct; DnaProbMatrix * dm; dm = DnaProbMatrix_from_match(0.8,NMaskType_VARIABLE); ct = read_CodonTable_file("codon.table"); cp = read_Blast_file_CompProb("wag85"); sal = SeqAlign_alloc_std(); seq = new_Sequence_from_strings("new1","ATGGGG"); add_SeqAlign(sal,seq); seq = new_Sequence_from_strings("new2","ATGGGT"); add_SeqAlign(sal,seq); agmp = std_AlignGeneModelParam(cp,dm,ct); printf("Codon 1 %f vs %f Codon 2 %f v %f \n", coding_probability_AlignGeneModel(sal,2,agmp), non_coding_probability_AlignGeneModel(sal,2,agmp), coding_probability_AlignGeneModel(sal,5,agmp), non_coding_probability_AlignGeneModel(sal,5,agmp) ); } wise-2.4.1/src/models/genewise.c0000644000175000001440000007477410577565051016133 0ustar philippusers/* has to be before the others due to nasty namespace clashes */ #define WISE2_CROSS_HMMER2 #include "wise2xhmmer2.h" #include "dyna.h" #include "version.h" char * program_name = "genewise"; /* * program specific includes */ #include "gwrap.h" #include "genedisplay.h" #include "matchsum.h" #include "phasemodel.h" #include "genephase6.h" /* * program specific variables */ char * dna_seq_file = NULL; Genomic * gen = NULL; boolean is_embl = FALSE; char * tstart_str = NULL; int tstart = -1; char * tend_str = NULL; int tend = -1; boolean reverse = FALSE; boolean target_abs = FALSE; boolean do_both = FALSE; boolean use_tsm = FALSE; char * protein_file = NULL; Protein * pro = NULL; char * hmm_file = NULL; ThreeStateModel * tsm = NULL; char * hmm_name = NULL; char * potential_file = NULL; char * qstart_str = NULL; int qstart = -1; char * qend_str = NULL; int qend = -1; char * gene_file = NULL; GeneFrequency21 * gf = NULL; char * new_gene_file = NULL; GeneStats * gs = NULL; GeneModelParam * gmp = NULL; PhasedProteinPara * ppp = NULL; PhasedProtein * pp = NULL; boolean use_new_stats = 1; char * matrix_file = NULL; CompMat * mat = NULL; char * gap_str = "12"; int gap = 12; char * ext_str = "2"; int ext = 2; char * length_of_N_str = "0"; int length_of_N = 0; boolean flat_insert = TRUE; char * codon_file = NULL; CodonTable * ct = NULL; char * output_file = "-"; FILE * ofp = NULL; RandomModelDNA * rmd = NULL; char * allN_string = "1.0"; Probability allN = 1.0; char * subs_string = "0.000001"; double subs_error = 0.000001; char * indel_string = "0.000001"; double indel_error = 0.000001; char * cfreq_string = "flat"; boolean model_codon = FALSE; char * splice_string = "model"; boolean model_splice = TRUE; char * startend_string = "default"; TSM_StartEndMode startend = TSM_default; char * null_string = "syn"; boolean use_syn = FALSE; char * intron_string = "tied"; boolean use_tied_model = FALSE; int alg = GWWRAP_623; char * alg_str = NULL; char * kbyte_str = NULL; int kbyte = 10000; /* will be reset in build_defaults */ char * pal_file = NULL; boolean show_PackAln = FALSE; boolean show_cumlative_PackAln = FALSE; boolean show_AlnBlock = FALSE; boolean show_ace = FALSE; boolean show_gff = FALSE; boolean show_trans = FALSE; boolean show_pep = FALSE; boolean show_cdna = FALSE; boolean show_pretty = FALSE; boolean show_pretty_gene = FALSE; boolean show_supp_gene = FALSE; boolean show_gene_plain = FALSE; boolean show_match_sum = FALSE; boolean show_para = FALSE; boolean show_overlap = FALSE; boolean show_embl = FALSE; boolean show_diana = FALSE; boolean pseudo = FALSE; char * main_block_str = "50"; int main_block = 50; char * divide_str = "//"; Probability rnd_loop = 0.99; Probability cds_loop = 0.97; Probability rnd_to_model = (1 - 0.99) / 3; Probability link_loop = 0.98; Probability link_to_model = (1- 0.98) / 3; AlnBlock * alb; PackAln * pal; GenomicRegion * gr; GenomicRegion * embl; MatchSummarySet * mss; RandomModel * rm; DPRunImpl * dpri; GeneWiseRunPara * gwrp; void show_parameters(void) { fprintf(ofp,"%s %s (%s release)\n",program_name,VERSION_NUMBER,RELEASE_DAY); fprintf(ofp,"This program is freely distributed under a GPL. See source directory\n"); fprintf(ofp,"Copyright (c) GRL limited: portions of the code are from separate copyright\n\n"); if( use_tsm == FALSE) { fprintf(ofp,"Query protein: %s\n",pro->baseseq->name); fprintf(ofp,"Comp Matrix: %s\n",matrix_file); fprintf(ofp,"Gap open: %d\n",gap); fprintf(ofp,"Gap extension: %d\n",ext); } else fprintf(ofp,"Query model: %s\n",tsm->name); fprintf(ofp,"Start/End %s\n",startend_string); fprintf(ofp,"Target Sequence %s\n",gen->baseseq->name); fprintf(ofp,"Strand: %s\n",do_both == TRUE ? "both" : reverse == TRUE ? "reverse" : "forward"); fprintf(ofp,"Start/End (protein) %s\n",startend_string); show_info_GeneModelParam(gmp,ofp); fprintf(ofp,"Codon Table: %s\n",codon_file); fprintf(ofp,"Subs error: %2.2g\n",subs_error); fprintf(ofp,"Indel error: %2.2g\n",indel_error); fprintf(ofp,"Null model %s\n",null_string); fprintf(ofp,"Algorithm %s\n",alg_str); } boolean show_pretty_aln(void) { Protein * ps; fprintf(ofp,"\n%s output\nScore %4.2f bits over entire alignment\n",program_name,Score2Bits(pal->score)); if( alg == GWWRAP_2193L || alg == GWWRAP_2193) { fprintf(ofp,"Entrie alignment score contains unseen 'random' score segments\nYou should only use the per-alignments score printed below\nfor the bits score of the alignment\n\n"); } if( use_syn == FALSE ) { fprintf(ofp,"Scores as bits over a flat simple random model\n\n"); } else { fprintf(ofp,"Scores as bits over a synchronous coding model\n\n"); } if( use_tsm == FALSE ) { fprintf(ofp,"Warning: The bits scores is not probablistically correct for single seqs\nSee WWW help for more info\n\n"); protgene_ascii_display(alb,pro->baseseq->seq,pro->baseseq->name,pro->baseseq->offset,gen,ct,15,main_block,(alg == GWWRAP_623L || alg == GWWRAP_2193L || alg == GWWRAP_2193) ? TRUE : FALSE, ofp); } else { ps = pseudo_Protein_from_ThreeStateModel(tsm); protgene_ascii_display(alb,ps->baseseq->seq,ps->baseseq->name,ps->baseseq->offset,gen,ct,15,main_block,(alg == GWWRAP_623L || alg == GWWRAP_2193L || alg == GWWRAP_2193) ? TRUE : FALSE,ofp); free_Protein(ps); } fprintf(ofp,"%s\n",divide_str); return TRUE; } boolean show_output(void) { int i; cDNA * cdna; Protein * trans; GenomicOverlapResults * gor; AlnColumn * alt; if( show_pretty == TRUE ) { show_pretty_aln(); } if( show_match_sum == TRUE ) { show_MatchSummary_genewise_header(ofp); show_MatchSummarySet_genewise(mss,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_pretty_gene == TRUE ) { show_pretty_GenomicRegion(gr,0,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_supp_gene == TRUE ) { show_pretty_GenomicRegion(gr,1,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_embl == TRUE ) { write_Embl_FT_GenomicRegion(gr,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_diana == TRUE ) { write_Diana_FT_GenomicRegion(gr,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_overlap == TRUE ) { gor = Genomic_overlap(gr,embl); show_GenomicOverlapResults(gor,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_trans == TRUE ) { for(i=0;ilen;i++) { if( gr->gene[i]->ispseudo == TRUE ) { fprintf(ofp,"#Gene %d is a pseudo gene - no translation possible\n",i); } else { trans = get_Protein_from_Translation(gr->gene[i]->transcript[0]->translation[0],ct); write_fasta_Sequence(trans->baseseq,ofp); } } fprintf(ofp,"%s\n",divide_str); } if( show_pep == TRUE ) { alt = alb->start; for(;alt != NULL;) { trans = Protein_from_GeneWise_AlnColumn(gen->baseseq,alt,1,&alt,ct,is_random_AlnColumn_genewise); if ( trans == NULL ) break; write_fasta_Sequence(trans->baseseq,ofp); free_Protein(trans); } fprintf(ofp,"%s\n",divide_str); } if( show_cdna == TRUE ) { for(i=0;ilen;i++) { cdna = get_cDNA_from_Transcript(gr->gene[i]->transcript[0]); write_fasta_Sequence(cdna->baseseq,ofp); } fprintf(ofp,"%s\n",divide_str); } if( show_ace == TRUE ) { show_ace_GenomicRegion(gr,gen->baseseq->name,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_gff == TRUE ) { show_GFF_GenomicRegion(gr,gen->baseseq->name,"GeneWise",ofp); fprintf(ofp,"%s\n",divide_str); } if( show_gene_plain == TRUE ) { show_GenomicRegion(gr,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_AlnBlock == TRUE ) { mapped_ascii_AlnBlock(alb,Score2Bits,0,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_cumlative_PackAln == TRUE ) { show_bits_and_cumlative_PackAln(pal,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_PackAln == TRUE ) { show_simple_PackAln(pal,ofp); fprintf(ofp,"%s\n",divide_str); } return TRUE; } boolean build_alignment(void) { GeneParameter21 * gpara; GeneModel * gm; if( pal_file != NULL ) { pal = read_simple_PackAln_file(pal_file); } if( use_new_stats == 0 ) { gpara = GeneParameter21_wrap(gf,subs_error,indel_error,rmd,model_codon,model_splice,use_tied_model,ct,rnd_loop,cds_loop,rnd_to_model,link_loop,link_to_model); } else { gm = GeneModel_from_GeneStats(gs,gmp); gpara= GeneParameter21_from_GeneModel(gm,ct,rnd_loop,cds_loop,rnd_to_model,link_loop,link_to_model,subs_error,indel_error); } if( gpara == NULL ) { warn("Sorry - could not build gene parameters. Must be a bug of some sort"); return FALSE; } /* phased based proteins use a different source */ if( alg == GWWRAP_623P ) { alb = AlnBlock_from_phased_protein_wrap(pro,tsm,gen,gpara->cm,rm,mat,ppp,gpara,dpri,&pal); } else { if( use_tsm == FALSE) { alb = AlnBlock_from_protein_genewise_wrap(pro,gen,mat,-gap,-ext,gpara,rmd,rmd,alg,use_syn,rm,allN,startend,dpri,&pal,gwrp); } else { alb = AlnBlock_from_TSM_genewise_wrap(tsm,gen,gpara,rmd,rmd,use_syn,alg,allN,flat_insert,dpri,&pal,NULL); } } free_GeneParameter21(gpara); if( alb == NULL ) return FALSE; gr = new_GenomicRegion(gen); add_Genes_to_GenomicRegion_GeneWise(gr,gen->baseseq->offset,gen->baseseq->end,alb,use_tsm == TRUE ? tsm->name : pro->baseseq->name,pseudo,NULL); if( use_tsm == TRUE) mss = MatchSummarySet_from_AlnBlock_genewise(alb,tsm->name,1,gen->baseseq); else mss = MatchSummarySet_from_AlnBlock_genewise(alb,pro->baseseq->name,pro->baseseq->offset,gen->baseseq); return TRUE; } boolean free_temporary_objects(void) { alb = free_AlnBlock(alb); pal = free_PackAln(pal); mss = free_MatchSummarySet(mss); gr = free_GenomicRegion(gr); return TRUE; } boolean free_io_objects(void) { if( use_tsm == TRUE) { free_ThreeStateModel(tsm); } else { free_Protein(pro); } free_CodonTable(ct); if( gf != NULL ) { free_GeneFrequency21(gf); } free_RandomModelDNA(rmd); if( is_embl ) { free_GenomicRegion(embl); } free_Genomic(gen); return TRUE; } boolean build_objects(void) { boolean ret = TRUE; Protein * pro_temp; Genomic * gen_temp; FILE * ifp; startend = threestatemodel_mode_from_string(startend_string); if( startend == TSM_unknown ) { warn("String %s was unable to converted into a start/end policy\n",startend_string); ret = FALSE; } if( tstart_str != NULL ) { if( is_integer_string(tstart_str,&tstart) == FALSE || tstart < 0) { warn("Could not make %s out as target start",tstart); ret = FALSE; } } if( tend_str != NULL ) { if( is_integer_string(tend_str,&tend) == FALSE || tend < 0) { warn("Could not make %s out as target end",tend); ret = FALSE; } } if( is_integer_string(gap_str,&gap) == FALSE ) { warn("Could not make %s out as gap penalty (must be integer at the moment)",gap_str); ret = FALSE; } if( is_integer_string(ext_str,&ext) == FALSE ) { warn("Could not make %s out as gap penalty (must be integer at the moment)",ext_str); ret = FALSE; } if( is_embl == FALSE ) { if( (gen = read_fasta_file_Genomic(dna_seq_file,length_of_N)) == NULL ) { ret = FALSE; warn("Could not read genomic sequence in %s",dna_seq_file); gen = NULL; } } else { embl = read_EMBL_GenomicRegion_file(dna_seq_file); if( embl == NULL ) { warn("Could not read genomic EMBL file in %s",dna_seq_file); gen = NULL; ret = FALSE; } else { gen = hard_link_Genomic(embl->genomic); } } if( gen != NULL ) { if( tstart != -1 || tend != -1 ) { if( tstart == -1 ) tstart = 0; if( tend == -1 ) tend = gen->baseseq->len; gen_temp = truncate_Genomic(gen,tstart-1,tend); if( gen_temp == NULL ){ ret = FALSE; } else { free_Genomic(gen); gen = gen_temp; } } else { /* no truncation required */ } if( reverse == TRUE ) { if( tstart > tend ) { warn("You have already reversed the DNA by using %d - %d truncation. Re-reversing",tstart,tend); } gen_temp = reverse_complement_Genomic(gen); free_Genomic(gen); gen = gen_temp; } } /* * Can't truncate on GenomicRegion (for good reasons!). * but we want only a section of the EMBL file to be used * * So... swap genomic now. Positions in EMBL are still valid, * however - some genes will loose their sequence, which will be damaging. ;) */ if( is_embl ) { free_Genomic(embl->genomic); embl->genomic = hard_link_Genomic(gen); /* pointer could be dead anyway ;) */ } if( target_abs == TRUE ) { if( is_embl == TRUE ) { warn("Sorry you can't both use absolute positioning and EMBL files as I can't cope with all the coordinate remapping. You'll have to convert to fasta."); ret = FALSE; } gen->baseseq->offset = 1; gen->baseseq->end = strlen(gen->baseseq->seq); } if( alg_str != NULL ) { alg = gwrap_alg_type_from_string(alg_str); } else { if( use_tsm == TRUE ) { alg_str = "623L"; } else { alg_str = "623"; } alg = gwrap_alg_type_from_string(alg_str); } if( qstart_str != NULL ) { if( is_integer_string(qstart_str,&qstart) == FALSE || qstart < 0) { warn("Could not make %s out as query start",qstart); ret = FALSE; } } if( qend_str != NULL ) { if( is_integer_string(qend_str,&qend) == FALSE || qend < 0) { warn("Could not make %s out as query end",qend); ret = FALSE; } } if( use_tsm == FALSE ) { if( startend != TSM_default && startend != TSM_global && startend != TSM_local && startend != TSM_endbiased) { warn("Proteins can only have local/global/endbias startend policies set, not %s",startend_string); ret = FALSE; } if( (pro = read_fasta_file_Protein(protein_file)) == NULL ) { ret = FALSE; warn("Could not read Protein sequence in %s",protein_file); } else { if( qstart != -1 || qend != -1 ) { if( qstart == -1 ) qstart = 0; if( qend == -1 ) qend = pro->baseseq->len; pro_temp = truncate_Protein(pro,qstart-1,qend); if( pro_temp == NULL ){ ret = FALSE; } else { free_Protein(pro); pro = pro_temp; } } } } else { /** using a HMM **/ /*tsm = read_HMMer_1_7_ascii_file(hmm_file);*/ /*tsm = Wise2_read_ThreeStateModel_from_hmmer1_file(hmm_file);*/ tsm = HMMer2_read_ThreeStateModel(hmm_file); if( tsm == NULL ) { warn("Could not read hmm from %s\n",hmm_file); ret = FALSE; } else { display_char_in_ThreeStateModel(tsm); if( hmm_name != NULL ) { if( tsm->name != NULL ) ckfree(tsm->name); tsm->name = stringalloc(hmm_name); } if( tsm == NULL ) { warn("Could not read %s as a hmm",hmm_file); } /** have to set start/end **/ set_startend_policy_ThreeStateModel(tsm,startend,30,0.1); } } /* end of else tsm != NULL */ if( main_block_str != NULL ) { if( is_integer_string(main_block_str,&main_block) == FALSE ) { warn("Could not get maximum main_block number %s",main_block_str); ret = FALSE; } } if( is_double_string(subs_string,&subs_error) == FALSE ) { warn("Could not convert %s to a double",subs_error); ret = FALSE; } if( is_double_string(indel_string,&indel_error) == FALSE ) { warn("Could not convert %s to a double",indel_error); ret = FALSE; } if( is_double_string(allN_string,&allN) == FALSE ) { warn("Could not convert %s to a double",allN_string); ret = FALSE; } if( strcmp(cfreq_string,"model") == 0 ) { model_codon = TRUE; } else if ( strcmp(cfreq_string,"flat") == 0 ) { model_codon = FALSE; } else { warn("Cannot interpret [%s] as a codon modelling parameter\n",cfreq_string); ret = FALSE; } if( strcmp(splice_string,"model") == 0 ) { model_splice = TRUE; } else if ( strcmp(splice_string,"flat") == 0 ) { model_splice = FALSE; gmp->use_gtag_splice = TRUE; } else { warn("Cannot interpret [%s] as a splice modelling parameter\n",splice_string); ret = FALSE; } if( strcmp(null_string,"syn") == 0 ) { use_syn = TRUE; } else if ( strcmp(null_string,"flat") == 0 ) { use_syn = FALSE; } else { warn("Cannot interpret [%s] as a null model string\n",null_string); ret = FALSE; } if( strcmp(intron_string,"model") == 0 ) { use_tied_model = FALSE; } else if ( strcmp(intron_string,"tied") == 0 ) { use_tied_model = TRUE; } else { warn("Cannot interpret [%s] as a intron tieing switch\n",intron_string); ret = FALSE; } if( (rm = default_RandomModel()) == NULL) { warn("Could not make default random model\n"); ret = FALSE; } if( use_new_stats == 0 ) { if( (gf = read_GeneFrequency21_file(gene_file)) == NULL) { ret = FALSE; warn("Could not read a GeneFrequency file in %s",gene_file); } } else { if( (gs = GeneStats_from_GeneModelParam(gmp)) == NULL ){ ret=FALSE; warn("Could not read gene statistics in %s",new_gene_file); } } /* end of else using new gene stats */ if( (mat = read_Blast_file_CompMat(matrix_file)) == NULL) { if( use_tsm == TRUE ) { info("I could not read the Comparison matrix file in %s; however, you are using a HMM so it is not needed. Please set the WISECONFIGDIR or WISEPERSONALDIR variable correctly to prevent this message.",matrix_file); } else { warn("Could not read Comparison matrix file in %s",matrix_file); ret = FALSE; } } if( (ct = read_CodonTable_file(codon_file)) == NULL) { ret = FALSE; warn("Could not read codon table file in %s",codon_file); } if( (ofp = openfile(output_file,"W")) == NULL) { warn("Could not open %s as an output file",output_file); ret = FALSE; } rmd = RandomModelDNA_std(); return ret; } void build_defaults(void) { gene_file = "human.gf"; new_gene_file = "gene.stat"; codon_file = "codon.table"; matrix_file = "BLOSUM62.bla"; } void reverse_target(void) { Genomic * gen_temp; gen_temp = reverse_complement_Genomic(gen); free_temporary_objects(); free_Genomic(gen); gen = gen_temp; } void show_short_help(void) { fprintf(stdout,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(stdout,"This program is freely distributed under a GPL. See -version for more info\n"); fprintf(stdout,"Copyright (c) GRL limited: portions of the code are from separate copyrights\n\n"); fprintf(stdout,"genewise in fasta format\n"); fprintf(stdout," Options. In any order, '-' as filename (for any input) means stdin\n"); fprintf(stdout,"\nFor more help go %s -help.\n",program_name); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(ofp,"genewise in fasta format\n"); /* program specific help */ fprintf(ofp,"Dna sequence options\n"); fprintf(ofp," -u start position in dna\n"); fprintf(ofp," -v end position in dna\n"); fprintf(ofp," -trev Compare on the reverse strand\n"); fprintf(ofp," -tfor [default] Compare on the forward strand\n"); fprintf(ofp," -both Both strands\n"); fprintf(ofp," -tabs Report positions as absolute to truncated/reverse sequence\n"); fprintf(ofp," -fembl File is an EMBL file native format\n"); fprintf(ofp,"Protein comparison options\n"); fprintf(ofp," -s start position in protein\n"); fprintf(ofp," -t end position in protein\n"); fprintf(ofp," -[g]ap [%3d] gap penalty\n",gap); fprintf(ofp," -[e]xt [%3d] extension penalty\n",ext); fprintf(ofp," -[m]atrix [%s] Comparison matrix\n",matrix_file); fprintf(ofp,"HMM options\n"); fprintf(ofp," -hmmer Protein file is HMMer file (version 2 compatible)\n"); fprintf(ofp," -hname Use this as the name of the HMM, not filename\n"); show_help_GeneModelParam(ofp); fprintf(ofp," -splice [model/flat] [LEGACY only for -splice flat. use -splice_gtag]\n"); show_help_PhasedProteinPara(ofp); fprintf(ofp,"Other model options\n"); fprintf(ofp," -[no]newgene use new gene stats (default), no for reverting to old system\n"); fprintf(ofp," -init [%s] [default/global/local/wing/endbias] startend policy for the HMM/protein\n",startend_string); fprintf(ofp," -codon [%s] Codon file\n",codon_file); fprintf(ofp," -subs [%2.2g] Substitution error rate\n",subs_error); fprintf(ofp," -indel [%2.2g] Insertion/deletion error rate\n",indel_error); fprintf(ofp," -null [syn/flat] Random Model as synchronous or flat [default syn]\n"); fprintf(ofp," -alln [%s] Probability of matching a NNN codon\n",allN_string); fprintf(ofp," -insert [model/flat] Use protein insert model [default flat]\n"); fprintf(ofp,"Algorithm options\n"); fprintf(ofp," -alg [623/623L/623S/623P/2193/2193L] Algorithm used [default 623/623L]\n"); fprintf(ofp," (normally use 623 for proteins, 623L for HMMs and 623P for Phased Proteins)\n"); fprintf(ofp,"Output options [default -pretty -para]\n"); fprintf(ofp," -pretty show pretty ascii output\n"); fprintf(ofp," -pseudo Mark genes with frameshifts as pseudogenes\n"); fprintf(ofp," -genes show gene structure\n"); fprintf(ofp," -genesf show gene structure with supporting evidence\n"); fprintf(ofp," -embl show EMBL feature format with CDS key\n"); fprintf(ofp," -diana show EMBL feature format with misc_feature key (for diana)\n"); fprintf(ofp," -para show parameters\n"); fprintf(ofp," -sum show summary output\n"); /* lets not bring trouble on ourselves ;) */ /* fprintf(ofp," -over show EMBL overlap (only with EMBL format)\n"); */ fprintf(ofp," -cdna show cDNA\n"); fprintf(ofp," -trans show protein translation, breaking at frameshifts\n"); fprintf(ofp," -pep show protein translation, splicing frameshifts\n"); fprintf(ofp," -ace ace file gene structure\n"); fprintf(ofp," -gff Gene Feature Format file\n"); fprintf(ofp," -gener raw gene structure\n"); fprintf(ofp," -alb show logical AlnBlock alignment\n"); fprintf(ofp," -pal show raw matrix alignment\n"); fprintf(ofp," -block [%s] Length of main block in pretty output\n",main_block_str); fprintf(ofp," -divide [%s] divide string for multiple outputs\n",divide_str); show_help_GeneWiseRunPara(ofp); show_help_DPRunImpl(ofp); show_standard_options(ofp); exit(63); } void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) GRL 1998 and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney wrote the core code.\n"); fprintf(ofp," Portions of this code was from HMMer2, written by Sean Eddy\n"); exit(63); } int main(int argc,char ** argv) { int i; char * temp; build_defaults(); strip_out_standard_options(&argc,argv,show_help,show_version); potential_file = strip_out_assigned_argument(&argc,argv,"pg"); pal_file = strip_out_assigned_argument(&argc,argv,"pal_file"); if( (temp = strip_out_assigned_argument(&argc,argv,"gap")) != NULL ) gap_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"g")) != NULL ) gap_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"ext")) != NULL ) ext_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"e")) != NULL ) ext_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"matrix")) != NULL ) matrix_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"m")) != NULL ) matrix_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"s")) != NULL ) qstart_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"t")) != NULL ) qend_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"u")) != NULL ) tstart_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"v")) != NULL ) tend_str = temp; if( (strip_out_boolean_argument(&argc,argv,"trev")) == TRUE ) reverse = TRUE; if( (strip_out_boolean_argument(&argc,argv,"[no]newgene")) == TRUE ) use_new_stats = TRUE; if( (strip_out_boolean_argument(&argc,argv,"tfor")) == TRUE ){ if( reverse == TRUE ) { warn("You have specified both trev and tfor. Treating as both"); do_both = TRUE; reverse = FALSE; } else { reverse = FALSE; } } if( (temp = strip_out_assigned_argument(&argc,argv,"insert")) != NULL ) { if( strcmp(temp,"flat") == 0 ) { flat_insert = TRUE; } else { flat_insert = FALSE; } } if( (strip_out_boolean_argument(&argc,argv,"both")) == TRUE ) do_both = TRUE; if( (strip_out_boolean_argument(&argc,argv,"fembl")) == TRUE ) is_embl = TRUE; if( (strip_out_boolean_argument(&argc,argv,"tabs")) == TRUE ) target_abs = TRUE; pseudo = strip_out_boolean_argument(&argc,argv,"pseudo"); if( (temp = strip_out_assigned_argument(&argc,argv,"codon")) != NULL ) codon_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"gene")) != NULL ) gene_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"alg")) != NULL ) alg_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"kbyte")) != NULL ) kbyte_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"subs")) != NULL ) subs_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"indel")) != NULL ) indel_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"cfreq")) != NULL ) cfreq_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"splice")) != NULL ) { warn("deprecated command line option -splice. use -splice_gtag now"); splice_string = temp; } if( (temp = strip_out_assigned_argument(&argc,argv,"init")) != NULL ) startend_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"null")) != NULL ) null_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"intron")) != NULL ) intron_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"alln")) != NULL ) allN_string = temp; if( (strip_out_boolean_argument(&argc,argv,"hmmer")) == TRUE ) use_tsm = TRUE; if( (strip_out_boolean_argument(&argc,argv,"intie")) == TRUE ) use_tied_model = TRUE; if( (temp = strip_out_assigned_argument(&argc,argv,"hname")) != NULL ) hmm_name = temp; if( (strip_out_boolean_argument(&argc,argv,"pretty")) != FALSE ) show_pretty = TRUE; if( (strip_out_boolean_argument(&argc,argv,"gff")) != FALSE ) show_gff = TRUE; if( (strip_out_boolean_argument(&argc,argv,"diana")) != FALSE ) show_diana = TRUE; if( (strip_out_boolean_argument(&argc,argv,"embl")) != FALSE ) show_embl = TRUE; if( (strip_out_boolean_argument(&argc,argv,"genes")) != FALSE ) show_pretty_gene = TRUE; if( (strip_out_boolean_argument(&argc,argv,"genesf")) != FALSE ) show_supp_gene = TRUE; if( (strip_out_boolean_argument(&argc,argv,"para")) != FALSE ) show_para = TRUE; if( (strip_out_boolean_argument(&argc,argv,"trans")) != FALSE ) show_trans = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pep")) != FALSE ) show_pep = TRUE; if( (strip_out_boolean_argument(&argc,argv,"cdna")) != FALSE ) show_cdna = TRUE; if( (strip_out_boolean_argument(&argc,argv,"sum")) != FALSE ) show_match_sum = TRUE; if( (strip_out_boolean_argument(&argc,argv,"alb")) != FALSE ) show_AlnBlock = TRUE; if( (strip_out_boolean_argument(&argc,argv,"ace")) != FALSE ) show_ace = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pal")) != FALSE ) show_PackAln = TRUE; if( (strip_out_boolean_argument(&argc,argv,"gener")) != FALSE ) show_gene_plain = TRUE; if( (strip_out_boolean_argument(&argc,argv,"over")) != FALSE ) show_overlap = TRUE; if( (temp = strip_out_assigned_argument(&argc,argv,"divide")) != NULL ) divide_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"block")) != NULL ) main_block_str = temp; dpri = new_DPRunImpl_from_argv(&argc,argv); gmp = new_GeneModelParam_from_argv(&argc,argv); ppp = new_PhasedProteinPara_from_argv(&argc,argv); gwrp = new_GeneWiseRunPara_from_argv(&argc,argv); strip_out_remaining_options_with_warning(&argc,argv); if( argc != 3 ) { warn("Wrong number of arguments (expect 2)!\n"); if( argc > 1 ){ warn("Arg line looked like (after option processing)"); for(i=1;ibasematrix->matrix[((j+10)*7)+STATE][i+1] #define PseudoWise7_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+10] #define PseudoWise7_READ_OFF_ERROR -12 #define PseudoWise7_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+11)%11][((i+1)*7)+STATE] #define PseudoWise7_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+11)%11][STATE] #define PseudoWise7_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define PseudoWise7_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_PseudoWise7(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_PseudoWise7(PseudoWise7 * mat) { PseudoWise7_access_func_holder holder; holder.access_main = PseudoWise7_shatter_access_main; holder.access_special = PseudoWise7_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_PseudoWise7(mat,holder); } /* Function: PseudoWise7_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int PseudoWise7_shatter_access_main(PseudoWise7 * mat,int i,int j,int state) { return PseudoWise7_SHATTER_MATRIX(mat,i,j,state); } /* Function: PseudoWise7_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int PseudoWise7_shatter_access_special(PseudoWise7 * mat,int i,int j,int state) { return PseudoWise7_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_PseudoWise7(mat,dpenv) * * Descrip: This function calculates the PseudoWise7 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [PseudoWise7 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_PseudoWise7(PseudoWise7 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_6; int * SIG_1_5; int * SIG_1_4; int * SIG_0_3; int * SIG_0_6; int * SIG_0_5; int * SIG_0_4; int * SIG_1_0; int * SIG_0_2; int * SIG_0_1; int * SIG_0_8; int * SIG_0_9; int * SIG_0_10; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,7,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("PseudoWise7 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-6); SIG_1_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-5); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-6); SIG_0_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-5); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_0_8 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-8); SIG_0_9 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-9); SIG_0_10 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-10); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state SEQUENCE_INSERT to state MATCH */ temp = SIG_1_3[SEQUENCE_INSERT] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = PseudoWise7_SHATTER_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = SIG_1_6[INTRON_0] + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = SIG_1_5[INTRON_1] + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = SIG_1_4[INTRON_2] + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > PseudoWise7_SHATTER_SPECIAL(mat,i,j,END) ) { PseudoWise7_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state SEQUENCE_INSERT to state INSERT */ temp = SIG_0_3[SEQUENCE_INSERT] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = PseudoWise7_SHATTER_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = SIG_0_6[INTRON_0] + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = SIG_0_5[INTRON_1] + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = SIG_0_4[INTRON_2] + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[INSERT] = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > PseudoWise7_SHATTER_SPECIAL(mat,i,j,END) ) { PseudoWise7_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = PseudoWise7_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > PseudoWise7_SHATTER_SPECIAL(mat,i,j,END) ) { PseudoWise7_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state SEQUENCE_INSERT */ /* setting first movement to score */ score = SIG_0_2[MATCH] + mat->gp->transition[GP4_DELETE_1_BASE]; /* From state INSERT to state SEQUENCE_INSERT */ temp = SIG_0_2[INSERT] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state SEQUENCE_INSERT */ temp = SIG_0_1[MATCH] + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state SEQUENCE_INSERT */ temp = SIG_0_1[INSERT] + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state SEQUENCE_INSERT to state SEQUENCE_INSERT */ temp = SIG_0_1[SEQUENCE_INSERT] + mat->dna_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SEQUENCE_INSERT */ /* Add any movement independant score and put away */ SIG_0_0[SEQUENCE_INSERT] = score; /* Finished calculating state SEQUENCE_INSERT */ /* For state INTRON_0 */ /* setting first movement to score */ score = SIG_0_8[MATCH] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state INTRON_0 */ temp = SIG_0_8[INSERT] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = SIG_0_1[INTRON_0] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_0] = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SIG_0_9[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = SIG_0_9[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = SIG_0_1[INTRON_1] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_1] = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SIG_0_10[MATCH] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = SIG_0_10[INSERT] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = SIG_0_1[INTRON_2] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_2] = score; /* Finished calculating state INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_PseudoWise7(dbsi,out,querydb,targetdb,gp,dna_ext) * * Descrip: This function makes a database search of PseudoWise7 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: dna_ext [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_PseudoWise7(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp,Score dna_ext) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_PseudoWise7 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_PseudoWise7. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_PseudoWise7. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for PseudoWise7, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_PseudoWise7(out,querydb, targetdb ,gp,dna_ext); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_PseudoWise7 *) ckalloc(sizeof(struct thread_pool_holder_PseudoWise7)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->gp = gp; holder->dna_ext = dna_ext; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_PseudoWise7,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for PseudoWise7"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from PseudoWise7",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_PseudoWise7(ptr) * * Descrip: Infinite loop code foreach thread for PseudoWise7 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_PseudoWise7(void * ptr) { struct thread_pool_holder_PseudoWise7 * holder; int db_status; int score; DataScore * ds; GeneWiseScore* query; ComplexSequence* target; holder = (struct thread_pool_holder_PseudoWise7 *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for PseudoWise7"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for PseudoWise7"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_GeneWiseDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in PseudoWise7 search"); } query = hard_link_GeneWiseScore(holder->query); /* get query information into datascore */ dataentry_add_GeneWiseDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_GenomicDB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_GenomicDB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching PseudoWise7, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_GenomicDB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_GeneWiseScore(holder->query); /* get the next query object for the next thread */ holder->query = reload_GeneWiseDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching PseudoWise7, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_GeneWiseDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for PseudoWise7"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for PseudoWise7"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_GenomicDB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_PseudoWise7(query, target ,holder->gp,holder->dna_ext); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for PseudoWise7"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for PseudoWise7"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for PseudoWise7"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_GeneWiseScore(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for PseudoWise7"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_PseudoWise7(out,querydb,targetdb,gp,dna_ext) * * Descrip: This function makes a database search of PseudoWise7 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: dna_ext [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_PseudoWise7(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp,Score dna_ext) { GeneWiseScore* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GeneWiseDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching PseudoWise7, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_GenomicDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching PseudoWise7, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_PseudoWise7(query, target , gp, dna_ext); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("PseudoWise7 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GeneWiseDB(ds->query,query,querydb); dataentry_add_GenomicDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_GenomicDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching PseudoWise7, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_GenomicDB(target,targetdb); query = reload_GeneWiseDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching PseudoWise7, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GeneWiseDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_PseudoWise7(query,target,gp,dna_ext) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_PseudoWise7_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dna_ext [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_PseudoWise7(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,Score dna_ext) { int bestscore = NEGI; int i; int j; int k; PseudoWise7 * mat; mat = allocate_PseudoWise7_only(query, target , gp, dna_ext); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(11,(mat->leni + 1) * 7,11,2)) == NULL) { warn("Score only matrix for PseudoWise7 cannot be allocated, (asking for 10 by %d cells)",mat->leni*7); mat = free_PseudoWise7(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<12;j++) { for(i=(-1);ileni;i++) { for(k=0;k<7;k++) PseudoWise7_VSMALL_MATRIX(mat,i,j,k) = NEGI; } PseudoWise7_VSMALL_SPECIAL(mat,i,j,START) = 0; PseudoWise7_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = PseudoWise7_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state SEQUENCE_INSERT to state MATCH */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-1,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = PseudoWise7_VSMALL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-1,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > PseudoWise7_VSMALL_SPECIAL(mat,i,j,END) ) { PseudoWise7_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state SEQUENCE_INSERT to state INSERT */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = PseudoWise7_VSMALL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > PseudoWise7_VSMALL_SPECIAL(mat,i,j,END) ) { PseudoWise7_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = PseudoWise7_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = PseudoWise7_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ PseudoWise7_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > PseudoWise7_VSMALL_SPECIAL(mat,i,j,END) ) { PseudoWise7_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state SEQUENCE_INSERT */ /* setting first movement to score */ score = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state SEQUENCE_INSERT */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state SEQUENCE_INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-1,SEQUENCE_INSERT) + mat->dna_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SEQUENCE_INSERT */ /* Add any movement independant score and put away */ PseudoWise7_VSMALL_MATRIX(mat,i,j,SEQUENCE_INSERT) = score; /* Finished calculating state SEQUENCE_INSERT */ /* For state INTRON_0 */ /* setting first movement to score */ score = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state INTRON_0 */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ PseudoWise7_VSMALL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ PseudoWise7_VSMALL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = PseudoWise7_VSMALL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ PseudoWise7_VSMALL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < PseudoWise7_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = PseudoWise7_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_PseudoWise7(mat); return bestscore; } /* Function: PackAln_bestmemory_PseudoWise7(query,target,gp,dna_ext,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_PseudoWise7 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dna_ext [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_PseudoWise7(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,Score dna_ext,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; PseudoWise7 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 7 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_PseudoWise7(query, target , gp, dna_ext,dpri)) == NULL ) { warn("Unable to allocate large PseudoWise7 version"); return NULL; } calculate_dpenv_PseudoWise7(mat,dpenv); out = PackAln_read_Expl_PseudoWise7(mat); } else { mat = allocate_PseudoWise7_only(query, target , gp, dna_ext); calculate_shatter_PseudoWise7(mat,dpenv); out = PackAln_read_Shatter_PseudoWise7(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_PseudoWise7(query, target , gp, dna_ext)) == NULL ) { warn("Unable to allocate small PseudoWise7 version"); return NULL; } out = PackAln_calculate_Small_PseudoWise7(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_PseudoWise7(query, target , gp, dna_ext,dpri)) == NULL ) { warn("Unable to allocate large PseudoWise7 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_PseudoWise7(mat); out = PackAln_read_Expl_PseudoWise7(mat); } } } mat = free_PseudoWise7(mat); return out; } /* Function: allocate_PseudoWise7_only(query,target,gp,dna_ext) * * Descrip: This function only allocates the PseudoWise7 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dna_ext [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [PseudoWise7 *] * */ PseudoWise7 * allocate_PseudoWise7_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,Score dna_ext) { PseudoWise7 * out; if((out= PseudoWise7_alloc()) == NULL) { warn("Allocation of basic PseudoWise7 structure failed..."); return NULL; } out->query = query; out->target = target; out->gp = gp; out->dna_ext = dna_ext; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_PseudoWise7(query,target,gp,dna_ext,dpri) * * Descrip: This function allocates the PseudoWise7 structure * and the basematrix area for explicit memory implementations * It calls /allocate_PseudoWise7_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dna_ext [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PseudoWise7 *] * */ PseudoWise7 * allocate_Expl_PseudoWise7(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,Score dna_ext,DPRunImpl * dpri) { PseudoWise7 * out; out = allocate_PseudoWise7_only(query, target , gp, dna_ext); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+10)*7 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+10)*7,(out->leni+1),2,out->lenj+10)) == NULL) { warn("Explicit matrix PseudoWise7 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_PseudoWise7(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_PseudoWise7(out); return out; } /* Function: init_PseudoWise7(mat) * * Descrip: This function initates PseudoWise7 matrix when in explicit mode * Called in /allocate_Expl_PseudoWise7 * * * Arg: mat [UNKN ] PseudoWise7 which contains explicit basematrix memory [PseudoWise7 *] * */ void init_PseudoWise7(PseudoWise7 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-10);j<11;j++) { PseudoWise7_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,SEQUENCE_INSERT) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } } for(j= (-10);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { PseudoWise7_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,SEQUENCE_INSERT) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } PseudoWise7_EXPL_SPECIAL(mat,i,j,START) = 0; PseudoWise7_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_PseudoWise7(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by PseudoWise7 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * */ void recalculate_PackAln_PseudoWise7(PackAln * pal,PseudoWise7 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == SEQUENCE_INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (START+7) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == INTRON_0 ) { pau->score = ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == INTRON_1 ) { pau->score = ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == INTRON_2 ) { pau->score = ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == SEQUENCE_INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (START+7) ) { pau->score = (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 6 && prev->state == INTRON_0 ) { pau->score = ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 5 && prev->state == INTRON_1 ) { pau->score = ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 4 && prev->state == INTRON_2 ) { pau->score = ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->seg[i]->transition[GW_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (START+7) ) { pau->score = mat->query->seg[i]->transition[GW_START2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case SEQUENCE_INSERT : if( offi == 0 && offj == 2 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_DELETE_2_BASE] + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_2_BASE] + (0); continue; } if( offi == 0 && offj == 1 && prev->state == SEQUENCE_INSERT ) { pau->score = mat->dna_ext + (0); continue; } warn("In recaluclating PackAln with state SEQUENCE_INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_0 : if( offi == 0 && offj == 8 && prev->state == MATCH ) { pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == INSERT ) { pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_0 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_1 : if( offi == 0 && offj == 9 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_1 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_2 : if( offi == 0 && offj == 10 && prev->state == MATCH ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == INSERT ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_2 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+7) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+7) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define PseudoWise7_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+10)][(i+1)*7+state]) #define PseudoWise7_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+11)*8) % 88][(i+1)*7+state]) #define PseudoWise7_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+10)]) #define PseudoWise7_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) #define PseudoWise7_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+11)*8)+(shadow+1)) % 88)][(i+1)*7 + state]) #define PseudoWise7_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) #define PseudoWise7_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+10)% 10) * (leni+1) * 7) + ((i+1) * 7) + (state)]) #define PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+10)% 10) * (leni+1) * 56) + ((i+1) * 56) + (state * 8) + shadow+1]) #define PseudoWise7_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) /* Function: allocate_Small_PseudoWise7(query,target,gp,dna_ext) * * Descrip: This function allocates the PseudoWise7 structure * and the basematrix area for a small memory implementations * It calls /allocate_PseudoWise7_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dna_ext [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [PseudoWise7 *] * */ #define PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) PseudoWise7 * allocate_Small_PseudoWise7(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,Score dna_ext) { PseudoWise7 * out; out = allocate_PseudoWise7_only(query, target , gp, dna_ext); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(88,(out->leni + 1) * 7,16,out->lenj+10); if(out == NULL) { warn("Small shadow matrix PseudoWise7 cannot be allocated, (asking for 11 by %d main cells)",out->leni+2); free_PseudoWise7(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_PseudoWise7(mat,dpenv) * * Descrip: This function calculates an alignment for PseudoWise7 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_PseudoWise7 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_PseudoWise7 * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_PseudoWise7(PseudoWise7 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for PseudoWise7 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_PseudoWise7(mat,dpenv); score = start_end_find_end_PseudoWise7(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_PseudoWise7(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_PseudoWise7(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == PseudoWise7_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_PseudoWise7(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 7; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_PseudoWise7(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_PseudoWise7(mat) * * Descrip: This function calculates an alignment for PseudoWise7 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_PseudoWise7 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_PseudoWise7 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_PseudoWise7 * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_PseudoWise7(PseudoWise7 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_PseudoWise7(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_PseudoWise7(mat); return out; } /* Function: AlnRangeSet_from_PseudoWise7(mat) * * Descrip: This function reads off a start/end structure * for PseudoWise7 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_PseudoWise7 * If you have not calculated the matrix use * /AlnRange_calculate_Small_PseudoWise7 * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_PseudoWise7(PseudoWise7 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_PseudoWise7"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_PseudoWise7(mat,&jpos); state = END; while( (temp = AlnRange_build_PseudoWise7(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_PseudoWise7(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_PseudoWise7 * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_PseudoWise7(PseudoWise7 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_PseudoWise7"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_PseudoWise7(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_PseudoWise7 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = PseudoWise7_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_PseudoWise7(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == PseudoWise7_READ_OFF_ERROR) { warn("In AlnRange_build_PseudoWise7 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = PseudoWise7_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_PseudoWise7(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_PseudoWise7(PseudoWise7 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_PseudoWise7(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == PseudoWise7_READ_OFF_ERROR) { warn("In PseudoWise7 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In PseudoWise7 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In PseudoWise7 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_PseudoWise7(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_PseudoWise7(PseudoWise7 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = PseudoWise7_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In PseudoWise7 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = PseudoWise7_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON_2) ) { *reti = i - 1; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-4,INTRON_2); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON_1) ) { *reti = i - 1; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-5,INTRON_1); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON_1); } temp = cscore - (((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON_0) ) { *reti = i - 1; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-6,INTRON_0); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON_0); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 3,SEQUENCE_INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = SEQUENCE_INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-3,SEQUENCE_INSERT); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 3,SEQUENCE_INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1); } temp = cscore - (((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-3,DELETE); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 3,SEQUENCE_INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = SEQUENCE_INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-3,SEQUENCE_INSERT); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 3,SEQUENCE_INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SEQUENCE_INSERT : temp = cscore - (mat->dna_ext) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 1,SEQUENCE_INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = SEQUENCE_INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-1,SEQUENCE_INSERT); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 1,SEQUENCE_INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 2,MATCH) ) { *reti = i - 0; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-2,MATCH); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 2,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS])) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-8,INSERT); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-8,MATCH); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-9,INSERT); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-9,MATCH); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-10,INSERT); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-10,MATCH); } return PseudoWise7_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_PseudoWise7(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_PseudoWise7(PseudoWise7 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 7; add_PackAln(out,pau); } max_special_strip_PseudoWise7(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == PseudoWise7_READ_OFF_ERROR) { warn("In special strip read PseudoWise7, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read PseudoWise7, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 7; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_PseudoWise7(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_PseudoWise7(PseudoWise7 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = PseudoWise7_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for PseudoWise7, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In PseudoWise7 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = PseudoWise7_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ default: warn("Major problem (!) - in PseudoWise7 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_PseudoWise7(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_PseudoWise7(PseudoWise7 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = PseudoWise7_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In PseudoWise7 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_DC_SHADOW_SPECIAL(mat,i-1,j-3,START); } return PseudoWise7_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source SEQUENCE_INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in PseudoWise7 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == PseudoWise7_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_DC_SHADOW_SPECIAL(mat,i-0,j-3,START); } return PseudoWise7_DC_SHADOW_MATRIX(mat,i - 0,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source SEQUENCE_INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in PseudoWise7 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == PseudoWise7_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - PseudoWise7_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return PseudoWise7_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in PseudoWise7 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SEQUENCE_INSERT : /* Source SEQUENCE_INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in PseudoWise7 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : /* Source INTRON_0 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in PseudoWise7 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : /* Source INTRON_1 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in PseudoWise7 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : /* Source INTRON_2 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in PseudoWise7 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_PseudoWise7(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_PseudoWise7(PseudoWise7 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_PseudoWise7(mat,starti,startj,stopi,stopj); PseudoWise7_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ PseudoWise7_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; PseudoWise7_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; PseudoWise7_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; PseudoWise7_HIDDEN_MATRIX(mat,i,j,SEQUENCE_INSERT) = NEGI; PseudoWise7_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; PseudoWise7_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; PseudoWise7_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state SEQUENCE_INSERT to state MATCH */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state SEQUENCE_INSERT to state INSERT */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ PseudoWise7_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state SEQUENCE_INSERT */ /* setting first movement to score */ score = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state SEQUENCE_INSERT */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state SEQUENCE_INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-1,SEQUENCE_INSERT) + mat->dna_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SEQUENCE_INSERT */ /* Add any movement independant score and put away */ PseudoWise7_HIDDEN_MATRIX(mat,i,j,SEQUENCE_INSERT) = score; /* Finished calculating state SEQUENCE_INSERT */ /* For state INTRON_0 */ /* setting first movement to score */ score = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state INTRON_0 */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ PseudoWise7_HIDDEN_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ PseudoWise7_HIDDEN_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = PseudoWise7_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ PseudoWise7_HIDDEN_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } } return; } /* Function: init_hidden_PseudoWise7(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_PseudoWise7(PseudoWise7 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-10);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { PseudoWise7_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; PseudoWise7_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; PseudoWise7_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; PseudoWise7_HIDDEN_MATRIX(mat,i,j,SEQUENCE_INSERT) = NEGI; PseudoWise7_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; PseudoWise7_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; PseudoWise7_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; } } return; } /* Function: full_dc_PseudoWise7(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_PseudoWise7 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_PseudoWise7 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [PseudoWise7 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_PseudoWise7(PseudoWise7 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_PseudoWise7"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 50) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_PseudoWise7(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_PseudoWise7(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_PseudoWise7(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for PseudoWise7, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= PseudoWise7_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= PseudoWise7_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_PseudoWise7(mat,PseudoWise7_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),PseudoWise7_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),PseudoWise7_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_PseudoWise7(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_PseudoWise7(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_PseudoWise7(PseudoWise7 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_PseudoWise7(mat); PseudoWise7_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_PseudoWise7(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_PseudoWise7(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_PseudoWise7(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_PseudoWise7(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_PseudoWise7(PseudoWise7 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<10;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,SEQUENCE_INSERT) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,0) = (-100); PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,1) = (-100); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-100); PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = (-100); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-100); PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = (-100); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-100); PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = SEQUENCE_INSERT; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,SEQUENCE_INSERT,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score) { score = temp; if( j - 6 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-6; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_2; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = SEQUENCE_INSERT; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,SEQUENCE_INSERT,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score) { score = temp; if( j - 6 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-6; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score) { score = temp; if( j - 5 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score) { score = temp; if( j - 4 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_2; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ /* For state SEQUENCE_INSERT, pushing when j - offj <= mergej */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( j - 2 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,1) = j-2; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,2) = MATCH; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,5) = SEQUENCE_INSERT; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,k); } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,1) = j-2; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,2) = INSERT; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,5) = SEQUENCE_INSERT; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,1) = j-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,2) = MATCH; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,5) = SEQUENCE_INSERT; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,1) = j-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,2) = INSERT; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,5) = SEQUENCE_INSERT; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,SEQUENCE_INSERT) + mat->dna_ext; if( temp > score) { score = temp; if( j - 1 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,1) = j-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,2) = SEQUENCE_INSERT; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,5) = SEQUENCE_INSERT; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SEQUENCE_INSERT,k); } } /* Add any movement independant score */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,SEQUENCE_INSERT) = score; /* Finished with state SEQUENCE_INSERT */ /* For state INTRON_0, pushing when j - offj <= mergej */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); if( j - 8 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = MATCH; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score) { score = temp; if( j - 8 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INSERT; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INTRON_0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } } /* Add any movement independant score */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished with state INTRON_0 */ /* For state INTRON_1, pushing when j - offj <= mergej */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( j - 9 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = MATCH; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 9 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INSERT; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INTRON_1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } } /* Add any movement independant score */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished with state INTRON_1 */ /* For state INTRON_2, pushing when j - offj <= mergej */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( j - 10 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = MATCH; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score) { score = temp; if( j - 10 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INSERT; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } } temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-1; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INTRON_2; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } } /* Add any movement independant score */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished with state INTRON_2 */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_PseudoWise7(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_PseudoWise7(PseudoWise7 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,SEQUENCE_INSERT) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state SEQUENCE_INSERT to state MATCH */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,SEQUENCE_INSERT,k); } /* From state INSERT to state MATCH */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state INTRON_0 to state MATCH */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,k); } /* From state INTRON_1 to state MATCH */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,k); } /* From state INTRON_2 to state MATCH */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state SEQUENCE_INSERT to state INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,SEQUENCE_INSERT,k); } /* From state INSERT to state INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state DELETE to state INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } /* From state INTRON_0 to state INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } /* From state INTRON_1 to state INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } /* From state INTRON_2 to state INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state SEQUENCE_INSERT */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,k); /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state MATCH to state SEQUENCE_INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* From state SEQUENCE_INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,SEQUENCE_INSERT) + mat->dna_ext; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SEQUENCE_INSERT,k); } /* Ok - finished max calculation for SEQUENCE_INSERT */ /* Add any movement independant score and put away */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,SEQUENCE_INSERT) = score; for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SEQUENCE_INSERT */ /* For state INTRON_0 */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); /* From state INSERT to state INTRON_0 */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } /* From state INTRON_0 to state INTRON_0 */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); /* From state INSERT to state INTRON_1 */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } /* From state INTRON_1 to state INTRON_1 */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); /* From state INSERT to state INTRON_2 */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } /* From state INTRON_2 to state INTRON_2 */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_PseudoWise7(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_PseudoWise7(PseudoWise7 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,SEQUENCE_INSERT) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state SEQUENCE_INSERT to state MATCH */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state SEQUENCE_INSERT to state INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state SEQUENCE_INSERT */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state SEQUENCE_INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state SEQUENCE_INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,SEQUENCE_INSERT) + mat->dna_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SEQUENCE_INSERT */ /* Add any movement independant score and put away */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,SEQUENCE_INSERT) = score; /* Finished calculating state SEQUENCE_INSERT */ /* For state INTRON_0 */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state INTRON_0 */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = PseudoWise7_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_PseudoWise7(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * */ } void init_dc_PseudoWise7(PseudoWise7 * mat) { register int i; register int j; register int k; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,SEQUENCE_INSERT) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; for(k=0;k<7;k++) { PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,k) = (-1); PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = (-1); PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = (-1); PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = (-1); } } } return; } /* Function: start_end_find_end_PseudoWise7(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [PseudoWise7 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_PseudoWise7(PseudoWise7 * mat,int * endj) { register int j; register int max; register int maxj; max = PseudoWise7_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( PseudoWise7_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = PseudoWise7_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_PseudoWise7(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [PseudoWise7] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_PseudoWise7(PseudoWise7 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (10 * (leni + 1) * 7,sizeof(int)); shadow_pointers = (int *) calloc (10 * (leni + 1) * 7 * 8,sizeof(int)); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state SEQUENCE_INSERT to state MATCH */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,SEQUENCE_INSERT,0)); } /* From state INSERT to state MATCH */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state START to state MATCH */ temp = PseudoWise7_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_0 to state MATCH */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,0)); } /* From state INTRON_1 to state MATCH */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,0)); } /* From state INTRON_2 to state MATCH */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > PseudoWise7_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { PseudoWise7_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state SEQUENCE_INSERT to state INSERT */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,SEQUENCE_INSERT,0)); } /* From state INSERT to state INSERT */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state DELETE to state INSERT */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0)); } /* From state START to state INSERT */ temp = PseudoWise7_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [START] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_0 to state INSERT */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,0)); } /* From state INTRON_1 to state INSERT */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,0)); } /* From state INTRON_2 to state INSERT */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > PseudoWise7_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { PseudoWise7_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state START to state DELETE */ temp = PseudoWise7_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > PseudoWise7_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { PseudoWise7_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; PseudoWise7_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = DELETE; } /* Finished calculating state DELETE */ /* For state SEQUENCE_INSERT */ /* setting first movement to score */ score = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE] + (0); /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,0)); /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state MATCH to state SEQUENCE_INSERT */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); } /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* From state SEQUENCE_INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,SEQUENCE_INSERT) + mat->dna_ext +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,SEQUENCE_INSERT,0)); } /* Ok - finished max calculation for SEQUENCE_INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i,j,SEQUENCE_INSERT) = score; for(k=0;k<7;k++) PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state SEQUENCE_INSERT */ /* For state INTRON_0 */ /* setting first movement to score */ score = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]) + (0); /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,0)); /* From state INSERT to state INTRON_0 */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,0)); } /* From state INTRON_0 to state INTRON_0 */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,0)); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,0)); /* From state INSERT to state INTRON_1 */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,0)); } /* From state INTRON_1 to state INTRON_1 */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,0)); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,0)); /* From state INSERT to state INTRON_2 */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0)); } /* From state INTRON_2 to state INTRON_2 */ temp = PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,0)); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ PseudoWise7_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) PseudoWise7_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_PseudoWise7(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * */ void init_start_end_linear_PseudoWise7(PseudoWise7 * mat) { register int i; register int j; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,SEQUENCE_INSERT) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,SEQUENCE_INSERT,0) = (-1); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-1); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-1); PseudoWise7_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; PseudoWise7_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-1); } } for(j=(-10);jtarget->seq->len;j++) { PseudoWise7_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; PseudoWise7_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; PseudoWise7_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_PseudoWise7(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_PseudoWise7(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_PseudoWise7(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","FRAMESHIFT","INTRON_STATE","END" }; /* Function: AlnConvertSet_PseudoWise7(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","INSERT","SEQUENCE_DELETION","DNA_INSERTION","5SS_PHASE_0","CENTRAL_INTRON","5SS_PHASE_1","5SS_PHASE_2","END" }; AlnConvertSet * AlnConvertSet_PseudoWise7(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SEQUENCE_INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 7; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = MATCH; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SEQUENCE_INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 7; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INSERT; acu->offi = 0; acu->offj = 6; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 7; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = SEQUENCE_INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = SEQUENCE_INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = SEQUENCE_INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = SEQUENCE_INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SEQUENCE_INSERT; acu->state2 = SEQUENCE_INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[4]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[4]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[4]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[4]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[4]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[4]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 7; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[5]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = END + 7; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[5]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = END + 7; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[5]; acu->label2 = target_label[11]; add_collapse_label_AlnConvertSet(out,"INTRON_STATE","CENTRAL_INTRON"); return out; } /* Function: PackAln_read_Expl_PseudoWise7(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_PseudoWise7(PseudoWise7 * mat) { PseudoWise7_access_func_holder holder; holder.access_main = PseudoWise7_explicit_access_main; holder.access_special = PseudoWise7_explicit_access_special; return PackAln_read_generic_PseudoWise7(mat,holder); } /* Function: PseudoWise7_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int PseudoWise7_explicit_access_main(PseudoWise7 * mat,int i,int j,int state) { return PseudoWise7_EXPL_MATRIX(mat,i,j,state); } /* Function: PseudoWise7_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int PseudoWise7_explicit_access_special(PseudoWise7 * mat,int i,int j,int state) { return PseudoWise7_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_PseudoWise7(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: h [UNKN ] Undocumented argument [PseudoWise7_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_PseudoWise7(PseudoWise7 * mat,PseudoWise7_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_PseudoWise7(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in PseudoWise7_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 7; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_PseudoWise7(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_PseudoWise7(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == PseudoWise7_READ_OFF_ERROR || j == PseudoWise7_READ_OFF_ERROR || state == PseudoWise7_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in PseudoWise7_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 7; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_PseudoWise7(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [PseudoWise7_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_PseudoWise7(PseudoWise7 * mat,int * ri,int * rj,int * state,boolean * isspecial,PseudoWise7_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: PseudoWise7_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void PseudoWise7_debug_show_matrix(PseudoWise7 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",PseudoWise7_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",PseudoWise7_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",PseudoWise7_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"State SEQUENCE_INSERT %d\n",PseudoWise7_EXPL_MATRIX(mat,i,j,SEQUENCE_INSERT)); fprintf(ofp,"State INTRON_0 %d\n",PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_0)); fprintf(ofp,"State INTRON_1 %d\n",PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_1)); fprintf(ofp,"State INTRON_2 %d\n",PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_2)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_PseudoWise7(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [PseudoWise7_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_PseudoWise7(PseudoWise7 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,PseudoWise7_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = PseudoWise7_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In PseudoWise7 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,INTRON_2) ) { *reti = i - 1; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,INTRON_2); } return (*h.access_main)(mat,i - 1,j - 4,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,INTRON_1) ) { *reti = i - 1; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,INTRON_1); } return (*h.access_main)(mat,i - 1,j - 5,INTRON_1); } temp = cscore - (((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,INTRON_0) ) { *reti = i - 1; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,INTRON_0); } return (*h.access_main)(mat,i - 1,j - 6,INTRON_0); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START); } return (*h.access_main)(mat,i - 1,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,SEQUENCE_INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = SEQUENCE_INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,SEQUENCE_INSERT); } return (*h.access_main)(mat,i - 1,j - 3,SEQUENCE_INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 5,INTRON_1); } temp = cscore - (((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-6,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 6,INTRON_0); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,START); } return (*h.access_main)(mat,i - 0,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE); } return (*h.access_main)(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,SEQUENCE_INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = SEQUENCE_INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,SEQUENCE_INSERT); } return (*h.access_main)(mat,i - 0,j - 3,SEQUENCE_INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case SEQUENCE_INSERT : temp = cscore - (mat->dna_ext) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,SEQUENCE_INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = SEQUENCE_INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,SEQUENCE_INSERT); } return (*h.access_main)(mat,i - 0,j - 1,SEQUENCE_INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,MATCH) ) { *reti = i - 0; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,MATCH); } return (*h.access_main)(mat,i - 0,j - 2,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_0); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,INSERT); } return (*h.access_main)(mat,i - 0,j - 8,INSERT); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,MATCH); } return (*h.access_main)(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,INSERT); } return (*h.access_main)(mat,i - 0,j - 9,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,MATCH); } return (*h.access_main)(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT); } return (*h.access_main)(mat,i - 0,j - 10,INSERT); } temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,MATCH); } return (*h.access_main)(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_PseudoWise7(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [PseudoWise7_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_PseudoWise7(PseudoWise7 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,PseudoWise7_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = PseudoWise7_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In PseudoWise7 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in PseudoWise7 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_PseudoWise7(mat) * * Descrip: This function calculates the PseudoWise7 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_PseudoWise7 * * * Arg: mat [UNKN ] PseudoWise7 which contains explicit basematrix memory [PseudoWise7 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_PseudoWise7(PseudoWise7 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_PseudoWise7, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("PseudoWise7 Matrix calculation: "); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state SEQUENCE_INSERT to state MATCH */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = PseudoWise7_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > PseudoWise7_EXPL_SPECIAL(mat,i,j,END) ) { PseudoWise7_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = PseudoWise7_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state SEQUENCE_INSERT to state INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = PseudoWise7_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > PseudoWise7_EXPL_SPECIAL(mat,i,j,END) ) { PseudoWise7_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = PseudoWise7_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = PseudoWise7_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ PseudoWise7_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > PseudoWise7_EXPL_SPECIAL(mat,i,j,END) ) { PseudoWise7_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state SEQUENCE_INSERT */ /* setting first movement to score */ score = PseudoWise7_EXPL_MATRIX(mat,i-0,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state SEQUENCE_INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state SEQUENCE_INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-1,SEQUENCE_INSERT) + mat->dna_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SEQUENCE_INSERT */ /* Add any movement independant score and put away */ PseudoWise7_EXPL_MATRIX(mat,i,j,SEQUENCE_INSERT) = score; /* Finished calculating state SEQUENCE_INSERT */ /* For state INTRON_0 */ /* setting first movement to score */ score = PseudoWise7_EXPL_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state INTRON_0 */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = PseudoWise7_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = PseudoWise7_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_PseudoWise7(mat,dpenv) * * Descrip: This function calculates the PseudoWise7 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] PseudoWise7 which contains explicit basematrix memory [PseudoWise7 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_PseudoWise7(PseudoWise7 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_PseudoWise7, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-10;jleni;i++) { PseudoWise7_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,SEQUENCE_INSERT) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } } for(j=-10;jlenj;j++) { PseudoWise7_EXPL_SPECIAL(mat,i,j,START) = 0; PseudoWise7_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("PseudoWise7 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { PseudoWise7_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,SEQUENCE_INSERT) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = PseudoWise7_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state SEQUENCE_INSERT to state MATCH */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = PseudoWise7_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > PseudoWise7_EXPL_SPECIAL(mat,i,j,END) ) { PseudoWise7_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = PseudoWise7_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state SEQUENCE_INSERT to state INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-3,SEQUENCE_INSERT) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = PseudoWise7_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + ((((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+mat->query->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+CSEQ_GENOMIC_3SS(mat->target,(j-3)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_3SS]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-2))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->gp->transition[GP4_INTRON2CDS])+CSEQ_GENOMIC_3SS(mat->target,(j-1))); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); PseudoWise7_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > PseudoWise7_EXPL_SPECIAL(mat,i,j,END) ) { PseudoWise7_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = PseudoWise7_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = PseudoWise7_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = PseudoWise7_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ PseudoWise7_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > PseudoWise7_EXPL_SPECIAL(mat,i,j,END) ) { PseudoWise7_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ /* For state SEQUENCE_INSERT */ /* setting first movement to score */ score = PseudoWise7_EXPL_MATRIX(mat,i-0,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state SEQUENCE_INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state SEQUENCE_INSERT to state SEQUENCE_INSERT */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-1,SEQUENCE_INSERT) + mat->dna_ext; if( temp > score ) { score = temp; } /* Ok - finished max calculation for SEQUENCE_INSERT */ /* Add any movement independant score and put away */ PseudoWise7_EXPL_MATRIX(mat,i,j,SEQUENCE_INSERT) = score; /* Finished calculating state SEQUENCE_INSERT */ /* For state INTRON_0 */ /* setting first movement to score */ score = PseudoWise7_EXPL_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_MATCH_BALANCE_5SS]); /* From state INSERT to state INTRON_0 */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->seg[i]->transition[GW_INSERT_BALANCE_5SS]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = PseudoWise7_EXPL_MATRIX(mat,i-0,j-9,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_1 */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-9,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = PseudoWise7_EXPL_MATRIX(mat,i-0,j-10,MATCH) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); /* From state INSERT to state INTRON_2 */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-10,INSERT) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = PseudoWise7_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ PseudoWise7_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: PseudoWise7_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PseudoWise7 *] * */ PseudoWise7 * PseudoWise7_alloc(void) { PseudoWise7 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PseudoWise7 *) ckalloc (sizeof(PseudoWise7))) == NULL) { warn("PseudoWise7_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_PseudoWise7(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PseudoWise7 *] * * Return [UNKN ] Undocumented return value [PseudoWise7 *] * */ PseudoWise7 * free_PseudoWise7(PseudoWise7 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PseudoWise7 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->gp is linked in */ /* obj->dna_ext is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/pseudowise7.h0000644000175000001440000004662410670453715016576 0ustar philippusers#ifndef DYNAMITEpseudowise7HEADERFILE #define DYNAMITEpseudowise7HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "geneparser4.h" #include "genewisemodel.h" #include "genewisemodeldb.h" struct Wise2_PseudoWise7 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GeneWiseScore* query; ComplexSequence* target; GeneParser4Score * gp; Score dna_ext; } ; /* PseudoWise7 defined */ #ifndef DYNAMITE_DEFINED_PseudoWise7 typedef struct Wise2_PseudoWise7 Wise2_PseudoWise7; #define PseudoWise7 Wise2_PseudoWise7 #define DYNAMITE_DEFINED_PseudoWise7 #endif #ifdef PTHREAD struct thread_pool_holder_PseudoWise7 { GeneWiseScore* query; /* Query object placeholder */ GeneWiseDB* querydb;/* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ GenomicDB* targetdb;/* Target database object */ boolean target_init; GeneParser4Score * gp; Score dna_ext; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_PseudoWise7_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(PseudoWise7*,int,int,int); int (*access_special)(PseudoWise7*,int,int,int); } ; /* PseudoWise7_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_PseudoWise7_access_func_holder typedef struct Wise2_PseudoWise7_access_func_holder Wise2_PseudoWise7_access_func_holder; #define PseudoWise7_access_func_holder Wise2_PseudoWise7_access_func_holder #define DYNAMITE_DEFINED_PseudoWise7_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_PseudoWise7(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_PseudoWise7(PseudoWise7 * mat); #define PackAln_read_Shatter_PseudoWise7 Wise2_PackAln_read_Shatter_PseudoWise7 /* Function: calculate_shatter_PseudoWise7(mat,dpenv) * * Descrip: This function calculates the PseudoWise7 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [PseudoWise7 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_PseudoWise7(PseudoWise7 * mat,DPEnvelope * dpenv); #define calculate_shatter_PseudoWise7 Wise2_calculate_shatter_PseudoWise7 /* Function: search_PseudoWise7(dbsi,out,querydb,targetdb,gp,dna_ext) * * Descrip: This function makes a database search of PseudoWise7 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: dna_ext [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_PseudoWise7(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp,Score dna_ext); #define search_PseudoWise7 Wise2_search_PseudoWise7 /* Function: serial_search_PseudoWise7(out,querydb,targetdb,gp,dna_ext) * * Descrip: This function makes a database search of PseudoWise7 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: dna_ext [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_PseudoWise7(Hscore * out,GeneWiseDB* querydb,GenomicDB* targetdb ,GeneParser4Score * gp,Score dna_ext); #define serial_search_PseudoWise7 Wise2_serial_search_PseudoWise7 /* Function: PackAln_bestmemory_PseudoWise7(query,target,gp,dna_ext,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_PseudoWise7 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dna_ext [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_PseudoWise7(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,Score dna_ext,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_PseudoWise7 Wise2_PackAln_bestmemory_PseudoWise7 /* Function: allocate_Expl_PseudoWise7(query,target,gp,dna_ext,dpri) * * Descrip: This function allocates the PseudoWise7 structure * and the basematrix area for explicit memory implementations * It calls /allocate_PseudoWise7_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dna_ext [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PseudoWise7 *] * */ PseudoWise7 * Wise2_allocate_Expl_PseudoWise7(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,Score dna_ext,DPRunImpl * dpri); #define allocate_Expl_PseudoWise7 Wise2_allocate_Expl_PseudoWise7 /* Function: recalculate_PackAln_PseudoWise7(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by PseudoWise7 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * */ void Wise2_recalculate_PackAln_PseudoWise7(PackAln * pal,PseudoWise7 * mat); #define recalculate_PackAln_PseudoWise7 Wise2_recalculate_PackAln_PseudoWise7 /* Function: allocate_Small_PseudoWise7(query,target,gp,dna_ext) * * Descrip: This function allocates the PseudoWise7 structure * and the basematrix area for a small memory implementations * It calls /allocate_PseudoWise7_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: dna_ext [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [PseudoWise7 *] * */ PseudoWise7 * Wise2_allocate_Small_PseudoWise7(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,Score dna_ext); #define allocate_Small_PseudoWise7 Wise2_allocate_Small_PseudoWise7 /* Function: PackAln_calculate_Small_PseudoWise7(mat,dpenv) * * Descrip: This function calculates an alignment for PseudoWise7 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_PseudoWise7 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_PseudoWise7 * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_PseudoWise7(PseudoWise7 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_PseudoWise7 Wise2_PackAln_calculate_Small_PseudoWise7 /* Function: AlnRangeSet_calculate_Small_PseudoWise7(mat) * * Descrip: This function calculates an alignment for PseudoWise7 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_PseudoWise7 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_PseudoWise7 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_PseudoWise7 * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_PseudoWise7(PseudoWise7 * mat); #define AlnRangeSet_calculate_Small_PseudoWise7 Wise2_AlnRangeSet_calculate_Small_PseudoWise7 /* Function: AlnRangeSet_from_PseudoWise7(mat) * * Descrip: This function reads off a start/end structure * for PseudoWise7 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_PseudoWise7 * If you have not calculated the matrix use * /AlnRange_calculate_Small_PseudoWise7 * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_PseudoWise7(PseudoWise7 * mat); #define AlnRangeSet_from_PseudoWise7 Wise2_AlnRangeSet_from_PseudoWise7 /* Function: convert_PackAln_to_AlnBlock_PseudoWise7(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_PseudoWise7(PackAln * pal); #define convert_PackAln_to_AlnBlock_PseudoWise7 Wise2_convert_PackAln_to_AlnBlock_PseudoWise7 /* Function: PackAln_read_Expl_PseudoWise7(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_PseudoWise7(PseudoWise7 * mat); #define PackAln_read_Expl_PseudoWise7 Wise2_PackAln_read_Expl_PseudoWise7 /* Function: PackAln_read_generic_PseudoWise7(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [PseudoWise7 *] * Arg: h [UNKN ] Undocumented argument [PseudoWise7_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_PseudoWise7(PseudoWise7 * mat,PseudoWise7_access_func_holder h); #define PackAln_read_generic_PseudoWise7 Wise2_PackAln_read_generic_PseudoWise7 /* Function: calculate_PseudoWise7(mat) * * Descrip: This function calculates the PseudoWise7 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_PseudoWise7 * * * Arg: mat [UNKN ] PseudoWise7 which contains explicit basematrix memory [PseudoWise7 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_PseudoWise7(PseudoWise7 * mat); #define calculate_PseudoWise7 Wise2_calculate_PseudoWise7 /* Function: calculate_dpenv_PseudoWise7(mat,dpenv) * * Descrip: This function calculates the PseudoWise7 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] PseudoWise7 which contains explicit basematrix memory [PseudoWise7 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_PseudoWise7(PseudoWise7 * mat,DPEnvelope * dpenv); #define calculate_dpenv_PseudoWise7 Wise2_calculate_dpenv_PseudoWise7 /* Function: PseudoWise7_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PseudoWise7 *] * */ PseudoWise7 * Wise2_PseudoWise7_alloc(void); #define PseudoWise7_alloc Wise2_PseudoWise7_alloc /* Function: free_PseudoWise7(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PseudoWise7 *] * * Return [UNKN ] Undocumented return value [PseudoWise7 *] * */ PseudoWise7 * Wise2_free_PseudoWise7(PseudoWise7 * obj); #define free_PseudoWise7 Wise2_free_PseudoWise7 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_PseudoWise7_shatter_access_main(PseudoWise7 * mat,int i,int j,int state); #define PseudoWise7_shatter_access_main Wise2_PseudoWise7_shatter_access_main int Wise2_PseudoWise7_shatter_access_special(PseudoWise7 * mat,int i,int j,int state); #define PseudoWise7_shatter_access_special Wise2_PseudoWise7_shatter_access_special void * Wise2_thread_loop_PseudoWise7(void * ptr); #define thread_loop_PseudoWise7 Wise2_thread_loop_PseudoWise7 int Wise2_score_only_PseudoWise7(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,Score dna_ext); #define score_only_PseudoWise7 Wise2_score_only_PseudoWise7 PseudoWise7 * Wise2_allocate_PseudoWise7_only(GeneWiseScore* query,ComplexSequence* target ,GeneParser4Score * gp,Score dna_ext); #define allocate_PseudoWise7_only Wise2_allocate_PseudoWise7_only void Wise2_init_PseudoWise7(PseudoWise7 * mat); #define init_PseudoWise7 Wise2_init_PseudoWise7 AlnRange * Wise2_AlnRange_build_PseudoWise7(PseudoWise7 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_PseudoWise7 Wise2_AlnRange_build_PseudoWise7 boolean Wise2_read_hidden_PseudoWise7(PseudoWise7 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_PseudoWise7 Wise2_read_hidden_PseudoWise7 int Wise2_max_hidden_PseudoWise7(PseudoWise7 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_PseudoWise7 Wise2_max_hidden_PseudoWise7 boolean Wise2_read_special_strip_PseudoWise7(PseudoWise7 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_PseudoWise7 Wise2_read_special_strip_PseudoWise7 int Wise2_max_special_strip_PseudoWise7(PseudoWise7 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_PseudoWise7 Wise2_max_special_strip_PseudoWise7 int Wise2_max_matrix_to_special_PseudoWise7(PseudoWise7 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_PseudoWise7 Wise2_max_matrix_to_special_PseudoWise7 void Wise2_calculate_hidden_PseudoWise7(PseudoWise7 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_PseudoWise7 Wise2_calculate_hidden_PseudoWise7 void Wise2_init_hidden_PseudoWise7(PseudoWise7 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_PseudoWise7 Wise2_init_hidden_PseudoWise7 boolean Wise2_full_dc_PseudoWise7(PseudoWise7 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_PseudoWise7 Wise2_full_dc_PseudoWise7 boolean Wise2_do_dc_single_pass_PseudoWise7(PseudoWise7 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_PseudoWise7 Wise2_do_dc_single_pass_PseudoWise7 void Wise2_push_dc_at_merge_PseudoWise7(PseudoWise7 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_PseudoWise7 Wise2_push_dc_at_merge_PseudoWise7 void Wise2_follow_on_dc_PseudoWise7(PseudoWise7 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_PseudoWise7 Wise2_follow_on_dc_PseudoWise7 void Wise2_run_up_dc_PseudoWise7(PseudoWise7 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_PseudoWise7 Wise2_run_up_dc_PseudoWise7 void Wise2_init_dc_PseudoWise7(PseudoWise7 * mat); #define init_dc_PseudoWise7 Wise2_init_dc_PseudoWise7 int Wise2_start_end_find_end_PseudoWise7(PseudoWise7 * mat,int * endj); #define start_end_find_end_PseudoWise7 Wise2_start_end_find_end_PseudoWise7 boolean Wise2_dc_optimised_start_end_calc_PseudoWise7(PseudoWise7 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_PseudoWise7 Wise2_dc_optimised_start_end_calc_PseudoWise7 void Wise2_init_start_end_linear_PseudoWise7(PseudoWise7 * mat); #define init_start_end_linear_PseudoWise7 Wise2_init_start_end_linear_PseudoWise7 AlnConvertSet * Wise2_AlnConvertSet_PseudoWise7(void); #define AlnConvertSet_PseudoWise7 Wise2_AlnConvertSet_PseudoWise7 int Wise2_PseudoWise7_explicit_access_main(PseudoWise7 * mat,int i,int j,int state); #define PseudoWise7_explicit_access_main Wise2_PseudoWise7_explicit_access_main int Wise2_PseudoWise7_explicit_access_special(PseudoWise7 * mat,int i,int j,int state); #define PseudoWise7_explicit_access_special Wise2_PseudoWise7_explicit_access_special int Wise2_find_end_PseudoWise7(PseudoWise7 * mat,int * ri,int * rj,int * state,boolean * isspecial,PseudoWise7_access_func_holder h); #define find_end_PseudoWise7 Wise2_find_end_PseudoWise7 void Wise2_PseudoWise7_debug_show_matrix(PseudoWise7 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define PseudoWise7_debug_show_matrix Wise2_PseudoWise7_debug_show_matrix int Wise2_max_calc_PseudoWise7(PseudoWise7 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,PseudoWise7_access_func_holder h); #define max_calc_PseudoWise7 Wise2_max_calc_PseudoWise7 int Wise2_max_calc_special_PseudoWise7(PseudoWise7 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,PseudoWise7_access_func_holder h); #define max_calc_special_PseudoWise7 Wise2_max_calc_special_PseudoWise7 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/genewise21.dy0000644000175000001440000004744707313404545016457 0ustar philippusers %{ #include "dyna.h" #include "genewisemodel.h" #include "genewisemodeldb.h" %} matrix GeneWise21 query type="GENEWISEMODEL" name="query" field:len="len" target type="GENOMIC" name="target" resource type="GeneParser21Score *" name="gp21" resource type="RandomCodonScore *" name="rndcodon" resource type="RandomModelDNAScore *" name="rndbase" extern type="int" name="GW_*" extern type="int" name="GP21_*" state MATCH offi="1" offj="3" calc="GENOMIC_CDS_POT(target,j)" source MATCH calc="query->seg[i]->transition[GW_MATCH2MATCH] +query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2MATCH] +query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2MATCH] +query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source BEFORE_CODON offj="3" calc="query->seg[i]->transition[GW_START2MATCH] +query->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source SPACER_0M offi="1" offj="6" target_label 3SS_PHASE_0 calc="gp21->transition[GP21_SPACER2CDS] +query->seg[i]->match[GENOMIC_CODON(target,j)] +GENOMIC_3SS(target,j-3) + query->seg[i]->transition[GW_MATCH_BALANCE_3SS]" endsource source PY_0M offi="1" offj="6" target_label 3SS_PHASE_0 calc="gp21->transition[GP21_PY2CDS] +query->seg[i]->match[GENOMIC_CODON(target,j)] +GENOMIC_3SS(target,j-3) + query->seg[i]->transition[GW_MATCH_BALANCE_3SS]" endsource source SPACER_1M offi="1" offj="5" target_label 3SS_PHASE_1 calc="gp21->transition[GP21_SPACER2CDS] +GENOMIC_3SS(target,j-2)" endsource source PY_1M offi="1" offj="5" target_label 3SS_PHASE_1 calc="gp21->transition[GP21_PY2CDS] +GENOMIC_3SS(target,j-2)" endsource source SPACER_2M offi="1" offj="4" target_label 3SS_PHASE_2 calc="gp21->transition[GP21_SPACER2CDS] +GENOMIC_3SS(target,j-1)" endsource source PY_2M offi="1" offj="4" target_label 3SS_PHASE_2 calc="gp21->transition[GP21_PY2CDS] +GENOMIC_3SS(target,j-1)" endsource source MATCH offi="1" offj="2" target_label SEQUENCE_DELETION calc="gp21->transition[GP21_DELETE_1_BASE]" endsource source MATCH offi="1" offj="1" target_label SEQUENCE_DELETION calc="gp21->transition[GP21_DELETE_2_BASE]" endsource source MATCH offi="1" offj="4" target_label SEQUENCE_INSERTION calc="gp21->transition[GP21_INSERT_1_BASE]" endsource source MATCH offi="1" offj="5" target_label SEQUENCE_INSERTION calc="gp21->transition[GP21_INSERT_2_BASE]" endsource query_label MATCH_STATE target_label CODON endstate state INSERT offi="0" offj="3" calc="GENOMIC_CDS_POT(target,j)" source MATCH calc="query->seg[i]->transition[GW_MATCH2INSERT] +query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2INSERT] +query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2INSERT] +query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source BEFORE_CODON calc="query->seg[i]->transition[GW_START2INSERT] +query->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source SPACER_0I offi="1" offj="6" target_label 3SS_PHASE_0 calc="gp21->transition[GP21_SPACER2CDS] +query->seg[i]->insert[GENOMIC_CODON(target,j)] +GENOMIC_3SS(target,j-3) + query->seg[i]->transition[GW_MATCH_BALANCE_3SS]" endsource source SPACER_1I offi="1" offj="5" target_label 3SS_PHASE_1 calc="gp21->transition[GP21_SPACER2CDS] +GENOMIC_3SS(target,j-2)" endsource source SPACER_2I offi="1" offj="4" target_label 3SS_PHASE_2 calc="gp21->transition[GP21_SPACER2CDS] +GENOMIC_3SS(target,j-1)" endsource source PY_0I offi="1" offj="6" target_label 3SS_PHASE_0 calc="gp21->transition[GP21_PY2CDS] +query->seg[i]->insert[GENOMIC_CODON(target,j)] +GENOMIC_3SS(target,j-3) + query->seg[i]->transition[GW_MATCH_BALANCE_3SS]" endsource source PY_1I offi="1" offj="5" target_label 3SS_PHASE_1 calc="gp21->transition[GP21_PY2CDS] +GENOMIC_3SS(target,j-2)" endsource source PY_2I offi="1" offj="4" target_label 3SS_PHASE_2 calc="gp21->transition[GP21_PY2CDS] +GENOMIC_3SS(target,j-1)" endsource source INSERT offi="1" offj="2" target_label SEQUENCE_DELETION calc="gp21->transition[GP21_DELETE_1_BASE]" endsource source INSERT offi="1" offj="1" target_label SEQUENCE_DELETION calc="gp21->transition[GP21_DELETE_2_BASE]" endsource source INSERT offi="1" offj="4" target_label SEQUENCE_INSERTION calc="gp21->transition[GP21_INSERT_1_BASE]" endsource source INSERT offi="1" offj="5" target_label SEQUENCE_INSERTION calc="gp21->transition[GP21_INSERT_2_BASE]" endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="query->seg[i]->transition[GW_MATCH2DELETE]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2DELETE]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2DELETE]" endsource source BEFORE_CODON calc="query->seg[i]->transition[GW_START2DELETE]" endsource query_label DELETE_STATE target_label INSERT endstate # # # state CENTRAL_0M source MATCH offj="8" offi="0" target_label 5SS_PHASE_0 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->transition[GW_MATCH_BALANCE_5SS]" endsource source INSERT offj="8" offi="0" target_label 5SS_PHASE_0 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->transition[GW_INSERT_BALANCE_5SS]" endsource source DELETE offj="8" offi="0" target_label 5SS_PHASE_0 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_DELETE2MATCH]" endsource source CENTRAL_0M offj="1" offi="0" calc="gp21->central[ GENOMIC_BASE(target,j)] +gp21->transition[GP21_CENTRAL2CENTRAL]" endsource query_label INTRON_MATCH_0 target_label CENTRAL_INTRON endstate state PY_0M offj="1" offi="0" calc="gp21->py[GENOMIC_BASE(target,j)]" source CENTRAL_0M calc="gp21->transition[GP21_CENTRAL2PY]" endsource source PY_0M calc="gp21->transition[GP21_PY2PY]" endsource query_label INTRON_MATCH_0 target_label PYRIMIDINE_TRACT endstate state SPACER_0M offj="1" offi="0" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source PY_0M calc="gp21->transition[GP21_PY2SPACER]" endsource source SPACER_0M calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label INTRON_MATCH_0 target_label SPACER endstate state CENTRAL_1M source MATCH offj="9" offi="0" target_label 5SS_PHASE_1 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->transition[GW_MATCH_BALANCE_5SS]" endsource source INSERT offj="9" offi="0" target_label 5SS_PHASE_1 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->transition[GW_MATCH_BALANCE_5SS]" endsource source DELETE offj="9" offi="0" target_label 5SS_PHASE_1 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_DELETE2MATCH]" endsource source CENTRAL_1M offj="1" offi="0" calc="gp21->central[ GENOMIC_BASE(target,j)] +gp21->transition[GP21_CENTRAL2CENTRAL]" endsource query_label INTRON_MATCH_1 target_label CENTRAL_INTRON endstate state PY_1M offj="1" offi="0" calc="gp21->py[GENOMIC_BASE(target,j)]" source CENTRAL_1M calc="gp21->transition[GP21_CENTRAL2PY]" endsource source PY_1M calc="gp21->transition[GP21_PY2PY]" endsource query_label INTRON_MATCH_1 target_label PYRIMIDINE_TRACT endstate state SPACER_1M offj="1" offi="0" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source PY_1M calc="gp21->transition[GP21_PY2SPACER]" endsource source SPACER_1M calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label INTRON_MATCH_1 target_label SPACER endstate state CENTRAL_2M source MATCH offj="10" offi="0" target_label 5SS_PHASE_2 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->transition[GW_MATCH_BALANCE_5SS]" endsource source INSERT offj="10" offi="0" target_label 5SS_PHASE_2 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->transition[GW_MATCH_BALANCE_5SS]" endsource source DELETE offj="10" offi="0" target_label 5SS_PHASE_2 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_DELETE2MATCH]" endsource source CENTRAL_2M offj="1" offi="0" calc="gp21->central[ GENOMIC_BASE(target,j)] +gp21->transition[GP21_CENTRAL2CENTRAL]" endsource query_label INTRON_MATCH_2 target_label CENTRAL_INTRON endstate state PY_2M offj="1" offi="0" calc="gp21->py[GENOMIC_BASE(target,j)]" source CENTRAL_2M calc="gp21->transition[GP21_CENTRAL2PY]" endsource source PY_2M calc="gp21->transition[GP21_PY2PY]" endsource query_label INTRON_MATCH_2 target_label PYRIMIDINE_TRACT endstate state SPACER_2M offj="1" offi="0" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source PY_2M calc="gp21->transition[GP21_PY2SPACER]" endsource source SPACER_2M calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label INTRON_MATCH_2 target_label SPACER endstate # # Insert intron states now # # # state CENTRAL_0I source MATCH offj="8" offi="0" target_label 5SS_PHASE_0 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_MATCH2INSERT] + query->seg[i]->transition[GW_MATCH_BALANCE_5SS]" endsource source INSERT offj="8" offi="0" target_label 5SS_PHASE_0 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_INSERT2INSERT] + query->seg[i]->transition[GW_INSERT_BALANCE_5SS]" endsource source DELETE offj="8" offi="0" target_label 5SS_PHASE_0 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_DELETE2INSERT]" endsource source CENTRAL_0I offj="1" offi="0" calc="gp21->central[ GENOMIC_BASE(target,j)] +gp21->transition[GP21_CENTRAL2CENTRAL]" endsource query_label INTRON_INSERT_0 target_label CENTRAL_INTRON endstate state PY_0I offj="1" offi="0" calc="gp21->py[GENOMIC_BASE(target,j)]" source CENTRAL_0I calc="gp21->transition[GP21_CENTRAL2PY]" endsource source PY_0I calc="gp21->transition[GP21_PY2PY]" endsource query_label INTRON_INSERT_0 target_label PYRIMIDINE_TRACT endstate state SPACER_0I offj="1" offi="0" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source PY_0I calc="gp21->transition[GP21_PY2SPACER]" endsource source SPACER_0I calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label INTRON_INSERT_0 target_label SPACER endstate state CENTRAL_1I source MATCH offj="9" offi="0" target_label 5SS_PHASE_1 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_MATCH2INSERT] " endsource source INSERT offj="9" offi="0" target_label 5SS_PHASE_1 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_INSERT2INSERT] " endsource source DELETE offj="9" offi="0" target_label 5SS_PHASE_1 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_DELETE2INSERT] " endsource source CENTRAL_1I offj="1" offi="0" calc="gp21->central[ GENOMIC_BASE(target,j)] +gp21->transition[GP21_CENTRAL2CENTRAL]" endsource query_label INTRON_INSERT_1 target_label CENTRAL_INTRON endstate state PY_1I offj="1" offi="0" calc="gp21->py[GENOMIC_BASE(target,j)]" source CENTRAL_1I calc="gp21->transition[GP21_CENTRAL2PY]" endsource source PY_1I calc="gp21->transition[GP21_PY2PY]" endsource query_label INTRON_INSERT_1 target_label PYRIMIDINE_TRACT endstate state SPACER_1I offj="1" offi="0" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source PY_1I calc="gp21->transition[GP21_PY2SPACER]" endsource source SPACER_1I calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label INTRON_INSERT_1 target_label SPACER endstate state CENTRAL_2I source MATCH offj="10" offi="0" target_label 5SS_PHASE_2 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_MATCH2INSERT] " endsource source INSERT offj="10" offi="0" target_label 5SS_PHASE_2 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_INSERT2INSERT] " endsource source INSERT offj="10" offi="0" target_label 5SS_PHASE_2 calc="gp21->central[ GENOMIC_BASE(target,j)] +GENOMIC_5SS(target,j-7) +query->seg[i]->transition[GW_DELETE2INSERT] " endsource source CENTRAL_2I offj="1" offi="0" calc="gp21->central[ GENOMIC_BASE(target,j)] +gp21->transition[GP21_CENTRAL2CENTRAL]" endsource query_label INTRON_INSERT_2 target_label CENTRAL_INTRON endstate state PY_2I offj="1" offi="0" calc="gp21->py[GENOMIC_BASE(target,j)]" source CENTRAL_2I calc="gp21->transition[GP21_CENTRAL2PY]" endsource source PY_2I calc="gp21->transition[GP21_PY2PY]" endsource query_label INTRON_INSERT_2 target_label PYRIMIDINE_TRACT endstate state SPACER_2I offj="1" offi="0" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source PY_2I calc="gp21->transition[GP21_PY2SPACER]" endsource source SPACER_2I calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label INTRON_INSERT_2 target_label SPACER endstate state START !special !start endstate state END !special !end source AFTER_RND offj="1" !right calc="0" endsource target_label END query_label END endstate state BEFORE_RND !special source START offj="1" calc="rndbase->base[GENOMIC_BASE(target,j)]" endsource source BEFORE_RND offj="1" calc="rndbase->base[GENOMIC_BASE(target,j)] + gp21->transition[GP21_RND2RND]" endsource source BEFORE_CODON offj="1" calc="rndbase->base[GENOMIC_BASE(target,j)] + gp21->transition[GP21_CDS2RND]" endsource query_label BEFORE_RND_STATE target_label RANDOM_SEQUENCE endstate state BEFORE_CODON !special offj="3" source BEFORE_RND calc="rndcodon->codon[GENOMIC_CODON(target,j)] + gp21->transition[GP21_RND2CDS]" endsource source BEFORE_CODON calc="rndcodon->codon[GENOMIC_CODON(target,j)] + gp21->transition[GP21_CDS2CDS]" endsource source BEFORE_SPACER offj="5" calc="gp21->transition[GP21_SPACER2CDS] + rndcodon->codon[GENOMIC_CODON(target,j)] + GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source BEFORE_SPACER offj="4" calc="gp21->transition[GP21_SPACER2CDS] + GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source BEFORE_SPACER offj="3" calc="gp21->transition[GP21_SPACER2CDS] + GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource query_label BEFORE_RND_STATE target_label CODON endstate state BEFORE_CENTRAL !special source BEFORE_CENTRAL offj="1" calc="gp21->central[GENOMIC_BASE(target,j)] + gp21->transition[GP21_CENTRAL2CENTRAL]" endsource source BEFORE_CODON offj="8" calc="gp21->central[GENOMIC_BASE(target,j)] + GENOMIC_5SS(target,j-7) " target_label 5SS_PHASE_0 endsource source BEFORE_CODON offj="9" calc="gp21->central[GENOMIC_BASE(target,j)] + GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_1 endsource source BEFORE_CODON offj="10" calc="gp21->central[GENOMIC_BASE(target,j)] + GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_2 endsource query_label BEFORE_RND_STATE target_label CENTRAL_INTRON endstate state BEFORE_PY_TRACT !special offj="1" calc="gp21->py[GENOMIC_BASE(target,j)]" source BEFORE_CENTRAL calc="gp21->transition[GP21_CENTRAL2PY]" endsource source BEFORE_PY_TRACT calc="gp21->transition[GP21_PY2PY]" endsource query_label BEFORE_RND_STATE target_label PYRIMIDINE_TRACT endstate state BEFORE_SPACER !special offj="1" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source BEFORE_PY_TRACT offj="1" calc="gp21->transition[GP21_PY2SPACER]" endsource source BEFORE_SPACER offj="1" calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label BEFORE_RND_STATE target_label SPACER endstate state AFTER_RND !special source AFTER_RND offj="1" calc="rndbase->base[GENOMIC_BASE(target,j)] + gp21->transition[GP21_RND2RND]" endsource source AFTER_CODON offj="1" calc="rndbase->base[GENOMIC_BASE(target,j)] + gp21->transition[GP21_CDS2RND]" endsource query_label AFTER_RND_STATE target_label RANDOM_SEQUENCE endstate state AFTER_CODON !special source AFTER_RND offj="3" calc="rndcodon->codon[GENOMIC_CODON(target,j)] + gp21->transition[GP21_RND2CDS]" endsource source MATCH calc="query->seg[i]->transition[GW_MATCH2END]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2END]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2END]" endsource source AFTER_CODON offj="3" calc="rndcodon->codon[GENOMIC_CODON(target,j)] + gp21->transition[GP21_CDS2CDS]" endsource source AFTER_SPACER offj="5" calc="gp21->transition[GP21_SPACER2CDS] + rndcodon->codon[GENOMIC_CODON(target,j)] + GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source AFTER_SPACER offj="4" calc="gp21->transition[GP21_SPACER2CDS] + GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source AFTER_SPACER offj="3" calc="gp21->transition[GP21_SPACER2CDS] + GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource query_label AFTER_RND_STATE target_label CODON endstate state AFTER_CENTRAL !special source AFTER_CENTRAL offj="1" calc="gp21->central[GENOMIC_BASE(target,j)] + gp21->transition[GP21_CENTRAL2CENTRAL]" endsource source AFTER_CODON offj="8" calc="gp21->central[GENOMIC_BASE(target,j)] + GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_0 endsource source AFTER_CODON offj="9" calc="gp21->central[GENOMIC_BASE(target,j)] + GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_1 endsource source AFTER_CODON offj="10" calc="gp21->central[GENOMIC_BASE(target,j)] + GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_2 endsource query_label AFTER_RND_STATE target_label CENTRAL_INTRON endstate state AFTER_PY_TRACT !special offj="1" calc="gp21->py[GENOMIC_BASE(target,j)]" source AFTER_CENTRAL calc="gp21->transition[GP21_CENTRAL2PY]" endsource source AFTER_PY_TRACT calc="gp21->transition[GP21_PY2PY]" endsource query_label AFTER_RND_STATE target_label PYRIMIDINE_TRACT endstate state AFTER_SPACER !special offj="1" calc="gp21->spacer[GENOMIC_BASE(target,j)]" source AFTER_PY_TRACT calc="gp21->transition[GP21_PY2SPACER]" endsource source AFTER_SPACER calc="gp21->transition[GP21_SPACER2SPACER]" endsource query_label AFTER_RND_STATE target_label SPACER endstate # # # collapse BEFORE_RND_STATE RANDOM_SEQUENCE collapse AFTER_RND_STATE RANDOM_SEQUENCE collapse BEFORE_RND_STATE CENTRAL_INTRON collapse AFTER_RND_STATE CENTRAL_INTRON # # Collapse central states # collapse INTRON_MATCH_0 CENTRAL_INTRON collapse INTRON_MATCH_1 CENTRAL_INTRON collapse INTRON_MATCH_2 CENTRAL_INTRON collapse INTRON_INSERT_0 CENTRAL_INTRON collapse INTRON_INSERT_1 CENTRAL_INTRON collapse INTRON_INSERT_2 CENTRAL_INTRON endmatrix %{ #include "genewise21.h" %} wise-2.4.1/src/models/evopairwise.c0000644000175000001440000002152007660724036016636 0ustar philippusers#define WISE2_CROSS_HMMER2 #include "wise2xhmmer2.h" #include "threestatedp.h" #include "threestateloop.h" #include "seqaligndisplay.h" #include "version.h" #include "dnamatrix.h" char * program_name = "evopairwise"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s align_cds_pair hmm_set\n",program_name); show_help_DPRunImpl(ofp); show_standard_options(ofp); } Score logl_pseudogene(char * ref,char * diff,DnaProbMatrix * dm) { int i; Score s = 0; for(i=0;i<3;i++) { s += Probability2Score(dm->prob[base_from_char(ref[i])][base_from_char(diff[i])]); } return s; } Score logl_negative_selection(char * ref,char * diff,ThreeStateUnit * unit,CodonTable * ct,DnaProbMatrix * dm) { int i; Score s = 0; char ref_aa; char diff_aa; /* we have to assess this position having changed */ for(i=0;i<3;i++) { s += Probability2Score(dm->prob[base_from_char(ref[i])][base_from_char(diff[i])]); } /* if the position has not changed, then we know it could not have been selected */ ref_aa = aminoacid_from_seq(ct,ref); diff_aa = aminoacid_from_seq(ct,diff); if( ref_aa == diff_aa ) { return s; } /* else we add the difference in probability between the two amino acids */ /* fprintf(stdout,"%c vs %c has %d plays %d for total of %d\n",ref_aa,diff_aa, Probability2Score(unit->match_emission[ref_aa-'A']), Probability2Score(unit->match_emission[diff_aa-'A']), Probability2Score(unit->match_emission[diff_aa-'A']) - Probability2Score(unit->match_emission[ref_aa-'A']) ); */ s += Probability2Score(unit->match_emission[diff_aa-'A']) - Probability2Score(unit->match_emission[ref_aa-'A']); return s; } Score logl_positive_selection(char * ref,char * diff,RandomModel * rm,CodonTable *ct,DnaProbMatrix * dm) { int i; Score s = 0; char ref_aa; char diff_aa; /* we have to assess this position having changed */ for(i=0;i<3;i++) { s += Probability2Score(dm->prob[base_from_char(ref[i])][base_from_char(diff[i])]); } /* if the position has not changed, then we know it would have been selected */ ref_aa = aminoacid_from_seq(ct,ref); diff_aa = aminoacid_from_seq(ct,diff); if( ref_aa == diff_aa ) { return s; } /* else we add the probability of seeing this amino acid*/ s += Probability2Score(rm->aminoacid[diff_aa-'A']); return s; } void show_verbose_evo(AlnBlock * alb,ThreeStateModel * tsm,Sequence * ref,Sequence * diff,CodonTable * ct,FILE * ofp) { AlnColumn * alc; Protein * hmmp; Sequence * ref_trans; Sequence * diff_trans; DnaProbMatrix * negative_dm; DnaProbMatrix * pseudo_dm; int i; int count = 0; double est_mutation = 0.0; int dna_offset; Score total_pseudo = 0; Score total_neg = 0; Score pseudo = 0; Score neg = 0; int count_ref_positive = 0; int count_ref_negative = 0; int count_ref_negative_0_5 = 0; int count_ref_negative_5_10 = 0; int count_ref_negative_10_15 = 0; int syn_sites = 0; int nonsyn_sites = 0; int syn_changes = 0; int nonsyn_changes = 0; int diff_score; char diff_aa; char ref_aa; int score_ratio = 0; Score score_neg_5 = Probability2Score(Bits2Probability(-5.0)); Score score_neg_10 = Probability2Score(Bits2Probability(-10.0)); int k; for(i=0;ilen;i+=3) { /* if this has changed, then it is definitely non syn */ if( aminoacid_from_seq(ct,ref->seq+i) != aminoacid_from_seq(ct,diff->seq+i)) { for(k=0;k<3;k++) { if( ref->seq[i+k] != diff->seq[i+k] ) { nonsyn_changes++; } } } else { /* could still be syn change */ for(k=0;k<3;k++) { if( ref->seq[i+k] != diff->seq[i+k] ) { syn_changes++; } } } /* calculate the sites. There is always 2 non syn sites */ nonsyn_sites += 2; if( four_fold_sites_CodonTable(ct,ref->seq+i) > 0 ) { syn_sites++; } else { nonsyn_sites += 1; } } for(i=0;ilen;i++) { if( ref->seq[i] != diff->seq[i] ) { count++; } } est_mutation = (double)count / (double)ref->len; pseudo_dm = DnaProbMatrix_from_match(1.0 - est_mutation,NMaskType_BANNED); negative_dm = DnaProbMatrix_from_match(1.0 - (est_mutation*2),NMaskType_BANNED); ref_trans = translate_Sequence(ref,ct); diff_trans = translate_Sequence(diff,ct); hmmp = pseudo_Protein_from_ThreeStateModel(tsm); for(alc=alb->start;alc != NULL;alc = alc->next) { /* fprintf(stdout,"In position %s\n",alc->alu[0]->text_label); */ if( strcmp(alc->alu[0]->text_label,"SEQUENCE") == 0 && strcmp(alc->alu[1]->text_label,"SEQUENCE") == 0 ) { dna_offset = alc->alu[1]->end*3; pseudo = logl_pseudogene(ref->seq+dna_offset,diff->seq+dna_offset,pseudo_dm); neg = logl_negative_selection(ref->seq+dna_offset,diff->seq+dna_offset,tsm->unit[alc->alu[0]->end],ct, pseudo_dm); /* fprintf(ofp,"Position %d [%c], vs %d [%c,%c] Scores Negative %d, Pseudo %d\n", alc->alu[0]->end,hmmp->baseseq->seq[alc->alu[0]->end], alc->alu[1]->end,ref_trans->seq[alc->alu[1]->end],diff_trans->seq[alc->alu[1]->end], neg, pseudo ); */ ref_aa = ref_trans->seq[alc->alu[1]->end]; diff_aa = diff_trans->seq[alc->alu[1]->end]; if( ref_aa != diff_aa ) { score_ratio += Probability2Score(tsm->unit[alc->alu[0]->end]->match_emission[ref_aa-'A']) - Probability2Score(tsm->unit[alc->alu[0]->end]->match_emission[diff_aa-'A']); diff_score = Probability2Score(tsm->unit[alc->alu[0]->end]->match_emission[ref_aa-'A']) - Probability2Score(tsm->unit[alc->alu[0]->end]->match_emission[diff_aa-'A']); if( diff_score < 0) { count_ref_negative++; if( diff_score > score_neg_5 ) { count_ref_negative_0_5++; } else if ( diff_score > score_neg_10 ) { count_ref_negative_5_10++; } else { count_ref_negative_10_15++; } } else { count_ref_positive++; } } total_pseudo += pseudo; total_neg += neg; } } fprintf(ofp,"%s\t%s\t%.2f\t%d\t%d\t%d\t%d\t%d\n",ref->name,hmmp->baseseq->name,Score2Bits(score_ratio), count_ref_positive,count_ref_negative, count_ref_negative_0_5, count_ref_negative_5_10, count_ref_negative_10_15); /* fprintf(ofp,"%s,%s Total Pseudo %d vs Negative %d, Ratio %.4f Positive %d Negative %d Score %.2f Syn %d Changes %d NonSyn %d Changes %d\n",ref->name,hmmp->baseseq->name,total_pseudo,total_neg,Score2Bits(total_neg-total_pseudo),count_ref_positive,count_ref_negative,Score2Bits(score_ratio),syn_sites,syn_changes,nonsyn_sites,nonsyn_changes); */ free_Protein(hmmp); } int main(int argc,char ** argv) { int i; SequenceSet * in; Sequence * trans; ThreeStateDB * tsd; DPRunImpl * dpri; CodonTable * ct; int return_status; ThreeStateModel * tsm; ThreeStateScore * tss; Protein * hmmp; ComplexSequence * cs; ComplexSequenceEvalSet * cses; PackAln * pal; AlnBlock * alb; int show_align = 0; int show_alb = 0; int show_verbose = 1; int show_trans = 0; ct = read_CodonTable_file("codon.table"); cses = default_aminoacid_ComplexSequenceEvalSet(); dpri = new_DPRunImpl_from_argv(&argc,argv); strip_out_boolean_def_argument(&argc,argv,"pretty",&show_align); strip_out_boolean_def_argument(&argc,argv,"alb",&show_alb); strip_out_boolean_def_argument(&argc,argv,"trans",&show_trans); if( argc != 3 ) { show_help(stdout); exit(63); } in = read_fasta_SequenceSet_file(argv[1]); tsd = HMMer2_ThreeStateDB(argv[2]); assert(in); assert(tsd); assert(in->len == 2); trans = translate_Sequence(in->set[0],ct); if( show_trans ) { write_fasta_Sequence(trans,stdout); } cs = new_ComplexSequence(trans,cses); open_ThreeStateDB(tsd); while( (tsm = read_TSM_ThreeStateDB(tsd,&return_status)) != NULL ) { fold_RandomModel_into_ThreeStateModel(tsm,tsm->rm); set_startend_policy_ThreeStateModel(tsm,TSM_local,10,1.0); tss = ThreeStateScore_from_ThreeStateModel(tsm); hmmp = pseudo_Protein_from_ThreeStateModel(tsm); pal = PackAln_bestmemory_ThreeStateLoop(tss,cs,NULL,dpri); alb = convert_PackAln_to_AlnBlock_ThreeStateLoop(pal); if( show_alb ) { show_flat_AlnBlock(alb,stdout); } if( show_align ) { write_pretty_seq_align(alb,hmmp->baseseq,trans,15,50,stdout); } if( show_verbose ) { show_verbose_evo(alb,tsm,in->set[0],in->set[1],ct,stdout); } } } wise-2.4.1/src/models/geneoutput.dy0000644000175000001440000000550007572633244016674 0ustar philippusers %{ #include "dyna.h" #include "geneutil.h" %} struct GeneOutputData AlnBlock * alb; PackAln * pal; GenomicRegion * gr; Genomic * gen; CodonTable * ct; struct GeneOutputPara boolean show_genes !def="0" boolean show_gff !def="0" boolean show_trans !def="0" boolean show_cdna !def="0" boolean show_geneutr !def="0" boolean show_alb !def="0" boolean show_pal !def="0" boolean show_debug !def="0" char * divide_string %{ #include "geneoutput.h" void show_GeneOutput(GeneOutputData * data,GeneOutputPara * para,FILE * ofp) { Protein * trans; cDNA * cdna; int i; assert(data); assert(data->ct); assert(data->gr); assert(data->gen); if( para->show_genes ) { show_pretty_GenomicRegion(data->gr,0,ofp); fprintf(stdout,"%s\n",para->divide_string); } if( para->show_gff ) { show_GFF_GenomicRegion(data->gr,data->gen->baseseq->name,"genomwise",stdout); fprintf(stdout,"%s\n",para->divide_string); } if( para->show_trans ) { for(i=0;igr->len;i++) { if( data->gr->gene[i]->ispseudo == TRUE ) { fprintf(stdout,"#Gene %d is a pseudo gene - no translation possible\n",i); } else { trans = get_Protein_from_Translation(data->gr->gene[i]->transcript[0]->translation[0],data->ct); write_fasta_Sequence(trans->baseseq,ofp); } } fprintf(stdout,"%s\n",para->divide_string); } if( para->show_cdna ) { for(i=0;igr->len;i++) { cdna = get_cDNA_from_Transcript(data->gr->gene[i]->transcript[0]); write_fasta_Sequence(cdna->baseseq,ofp); } fprintf(stdout,"%s\n",para->divide_string); } if( para->show_geneutr ) { show_utr_exon_genomewise(data->alb,ofp); fprintf(stdout,"%s\n",para->divide_string); } } double id_map_func(int i) { return (double)i; } GeneOutputPara * new_GeneOutputPara_from_argv(int * argc,char ** argv) { GeneOutputPara * out; out = GeneOutputPara_alloc(); out->show_genes = 1; out->show_trans = 1; out->divide_string = stringalloc("//"); strip_out_boolean_def_argument(argc,argv,"geneutr",&out->show_geneutr); strip_out_boolean_def_argument(argc,argv,"genes",&out->show_genes); strip_out_boolean_def_argument(argc,argv,"trans",&out->show_trans); strip_out_boolean_def_argument(argc,argv,"gff",&out->show_gff); strip_out_boolean_def_argument(argc,argv,"cdna",&out->show_cdna); strip_out_boolean_def_argument(argc,argv,"genedebug",&out->show_debug); return out; } void show_help_GeneOutputPara(FILE * ofp) { fprintf(ofp,"Gene Output\n"); fprintf(ofp," -[no]genes show gene structure (default yes)\n"); fprintf(ofp," -[no]geneutr show gene structure with utrs (default no)\n"); fprintf(ofp," -[no]trans show protein translation (default yes)\n"); fprintf(ofp," -[no]gff show gff (default no)\n"); fprintf(ofp," -[no]genedebug show gene debug\n"); } wise-2.4.1/src/models/scanwisep.c0000644000175000001440000004133110420650634016265 0ustar philippusers#include #include "sw_wrap.h" #include "seqlookup.h" #include "subseqhash.h" #include "subseqlookup.h" #include "sequencedb.h" #include "hsp.h" #include "hitlist.h" #include "hsplookupscan.h" #include "version.h" #include "hsp2aln_sw.h" #include "proteinindexcons.h" #include "hspscaninterface.h" #include "client_multihspscan.h" #include #include #include "wise2_mott_bridge.h" #ifdef SCAN_CORBA #include "hspscan_corba_wrapper.h" #include "corba_singleton.h" #endif #ifdef SCAN_MYSQL #include "mysql_protein_index.h" #endif #ifdef SCAN_WISESERVER #include "net_hspscan.h" #endif #ifdef SCAN_COMPRESS #include "compressed_protein_index.h" #endif #define MICROSECOND (1.0/1000000.0) char * program_name = "scanwisep"; typedef struct { boolean use_corba; boolean use_mysql; boolean use_wiseserver; boolean use_compress; boolean use_multiscan; char * ior_file; char * direct_sequence; char * matrix_file; char * host; char * dbname; char * username; char * password; char * multiscan_file; int step; int port; } ScanWiseHSPImpl; #ifdef SCAN_CORBA Wise2Corba_Singleton * sorb; #endif HSPScanInterface * new_HSPScanInterface_from_ScanWiseHSPImpl(ScanWiseHSPImpl * i,ProteinIndexConstructor * pic,SeqLookupLoadPara * slp) { HSPScanInterface * out; SeqLookupInterface * sli; SequenceDB * db; Sequence * seq; CompMat * mat; int ret; int c; mat = read_Blast_file_CompMat(i->matrix_file); if( i->use_corba == FALSE && i->use_mysql == FALSE && i->use_wiseserver == FALSE && i->use_compress == FALSE && i->use_multiscan == FALSE) { if( i->direct_sequence == NULL ) { fatal("If no server based sequence, must have direct sequence"); } else { db = single_fasta_SequenceDB(i->direct_sequence); sli = new_SeqLookupInterface_from_ProteinIndexConstructor(pic); load_SequenceDB_SeqLookupLoadPara(slp,db,sli); free_SequenceDB(db); out = new_one_off_HSPScanInterface(sli,mat,15,40); } } else if( i->use_corba == TRUE ) { #ifdef SCAN_CORBA if( i->ior_file == NULL ) { fatal("Corba specified, but no ior file given"); } out = new_corba_HSPScan(sorb,i->ior_file,mat); #else fatal("Asking for CORBA, but scanwisep was not compiled with SCAN_CORBA defined."); #endif } else if ( i->use_mysql == TRUE ) { #ifdef SCAN_MYSQL out = new_HSPScanInterface_MysqlProteinIndex(i->host,i->dbname,i->username,i->password,mat,i->step); #else fatal("Asking for mysql, but scanwisep was not compiled with SCAN_MYSQL defined"); #endif } else if ( i->use_wiseserver == TRUE ) { #ifdef SCAN_WISESERVER out = new_wise_transfer_HSPScanInterface(i->host,i->port); #else fatal("Asking for wiseserver, but scanwisep was not compiled with SCAN_WISESERVER defined"); #endif } else if ( i->use_compress == TRUE ) { #ifdef SCAN_COMPRESS sli = new_direct_CompressedProteinLookup(); db = single_fasta_SequenceDB(i->direct_sequence); load_SequenceDB_SeqLookupLoadPara(slp,db,sli); free_SequenceDB(db); out = new_one_off_HSPScanInterface(sli,mat,15,40); #else fatal("Asking for compressed, but scanwisep was not compiled with SCAN_COMPRESS defined"); #endif } else if( i->use_multiscan == TRUE ) { if( i->multiscan_file == NULL ) { fatal("Must provide a file for a multiple server scan"); } out = new_multiclient_HSPScanInterface(i->multiscan_file); } assert(out != NULL); free_CompMat(mat); /* hard linked internally */ return out; } ScanWiseHSPImpl * new_ScanWiseHSPImpl_from_argv(int * argc,char ** argv) { ScanWiseHSPImpl * out; char * temp; out = malloc(sizeof(ScanWiseHSPImpl)); out->use_corba = FALSE; out->use_mysql = FALSE; out->use_compress = FALSE; out->use_multiscan = FALSE; out->ior_file = NULL; out->direct_sequence = NULL; out->matrix_file = "BLOSUM62.bla"; out->step = 32; out->host = "localhost"; out->port = 4050; strip_out_boolean_def_argument(argc,argv,"corba",&out->use_corba); strip_out_boolean_def_argument(argc,argv,"mysql",&out->use_mysql); strip_out_boolean_def_argument(argc,argv,"wiseserver",&out->use_wiseserver); strip_out_boolean_def_argument(argc,argv,"compress",&out->use_compress); strip_out_boolean_def_argument(argc,argv,"multi",&out->use_multiscan); if( (temp = strip_out_assigned_argument(argc,argv,"iorfile")) != NULL ) { out->ior_file = temp; } if( (temp = strip_out_assigned_argument(argc,argv,"multiserver")) != NULL ) { out->multiscan_file = temp; } if( (temp = strip_out_assigned_argument(argc,argv,"scan_host")) != NULL ) { out->host = temp; } strip_out_integer_argument(argc,argv,"scan_port",&out->port); if( (temp = strip_out_assigned_argument(argc,argv,"scan_dbname")) != NULL ) { out->dbname = temp; } if( (temp = strip_out_assigned_argument(argc,argv,"scan_username")) != NULL ) { out->username = temp; } if( (temp = strip_out_assigned_argument(argc,argv,"scan_password")) != NULL ) { out->password = temp; } strip_out_integer_argument(argc,argv,"scan_step",&out->step); if( (temp = strip_out_assigned_argument(argc,argv,"seqdb")) != NULL ) { out->direct_sequence = temp; } if( (temp = strip_out_assigned_argument(argc,argv,"seqdbmat")) != NULL ) { out->matrix_file = temp; } return out; } void show_help_ScanWiseHSPImpl(FILE * ofp) { fprintf(ofp,"HSP generation options\n"); #ifdef SCAN_CORBA fprintf(ofp," -[no]corba Use CORBA server for index (CORBA enabled)\n"); fprintf(ofp," -iorfile For CORBA cases, IOR file to use for CORBA access\n"); #else fprintf(ofp," -[no]corba Use CORBA server for index (CORBA not enabled. go make scanwisep_corba)\n"); #endif #ifdef SCAN_MYSQL fprintf(ofp," -[no]mysql Use mysql server for index (Mysql enabled)\n"); fprintf(ofp," -scan_host [localhost] host name for mysql server\n"); fprintf(ofp," -scan_username [] user name for mysql server\n"); fprintf(ofp," -scan_password password for mysql server\n"); fprintf(ofp," -scan_dbname database name for mysql server\n"); fprintf(ofp," -scan_step [32] seq step query block\n"); #else fprintf(ofp," -[no]mysql Use mysql server for index (Mysql not enabled. go make scanwisep_mysql)\n"); #endif #ifdef SCAN_WISESERVER fprintf(ofp," -[no]wiseserver Use wise socket based server for index (enabled)\n"); fprintf(ofp," -scan_host [localhost] host name for wise server\n"); fprintf(ofp," -scan_port [4050] port for wise server\n"); fprintf(ofp," -[no]multi Use multiple wiseservers at once\n"); fprintf(ofp," -multiserver Filename for multiple servers, format\n"); #else fprintf(ofp," -[no]wiseserver Use wise server for index (Wise server. go make scanwisep_wiseserver)\n"); #endif fprintf(ofp," -seqdb For local cases, sequence database fasta file\n"); fprintf(ofp," -seqdbmat For local cases, comparison matrix to use\n"); } /* * conversion from HSPs to HitList */ typedef enum HSP2HitListType { HSP2HitList_Ungapped = 445, HSP2HitList_Fulldp, HSP2HitList_Heuristic, HSP2HitList_None, HSP2HitList_Unknown } HSP2HitListType; typedef struct HSP2HitListImpl { HSP2HitListType type; boolean threaded; int no_threads; } HSP2HitListImpl; HSP2HitListType HSP2HitListType_string_convert(char * string) { if( strcmp(string,"ungapped") == 0 ) { return HSP2HitList_Ungapped; } if( strcmp(string,"fulldp") == 0 ) { return HSP2HitList_Fulldp; } if( strcmp(string,"heuristic") == 0 ) { return HSP2HitList_Heuristic; } if( strcmp(string,"none") == 0 ) { return HSP2HitList_None; } return HSP2HitList_Unknown; } struct convert_data_fulldp { HitList * hl; DPRunImpl * dpri; CompMat * mat; }; HitPair * HitPair_from_HSPset_sw(HSPset * set,DPRunImpl * dpri,CompMat * mat) { HitPair * out; HitAln * aln; int i; out = HitPair_alloc_std(); out->query = hard_link_Sequence(set->hsp[0]->query); out->target = hard_link_Sequence(set->hsp[0]->target); aln = HitAln_alloc(); aln->alb = Align_Sequences_ProteinSmithWaterman(out->query,out->target,mat,-12,-2,NULL,dpri); aln->raw_score = aln->alb->score; add_HitPair(out,aln); out->raw_score = aln->alb->score; return out; } HitList * HitList_from_LinearHSPmanager_sw(LinearHSPmanager * lm,DPRunImpl * dpri) { HitList * out; int i; struct convert_data_fulldp conv; out = HitList_alloc_std(); out->mat = hard_link_CompMat(lm->mat); for(i=0;ilen;i++) add_HitList(out,HitPair_from_HSPset_sw(lm->set[i],dpri,out->mat)); return out; } HSP2HitListImpl * new_HSP2HitListImpl_from_argv(int * argc,char ** argv) { HSP2HitListImpl * out; char * temp; out = malloc(sizeof(HSP2HitListImpl)); out->type = HSP2HitList_Heuristic; if( (temp = strip_out_assigned_argument(argc,argv,"hspconvert")) != NULL ) { out->type = HSP2HitListType_string_convert(temp); } strip_out_boolean_def_argument(argc,argv,"hspthread",&out->threaded); out->no_threads = 4; strip_out_integer_argument(argc,argv,"hspthreadno",&out->no_threads); return out; } void show_help_HSP2HitList(FILE * ofp) { fprintf(ofp,"Conversion from HSP to alignments\n"); fprintf(ofp," -hspconvert [ungapped/fulldp/heuristic] Conversion type - heuristic default\n"); fprintf(ofp," -hspthread multi-thread HSP conversion\n"); fprintf(ofp," -hspthreadno number of HSP threads (4 default)\n"); } HitList * HitList_from_HSP_HSP2HitListImpl(HSP2HitListImpl * conv,LinearHSPmanager * lm,DPRunImpl * dpri,HSPset2HitPairPara * hsp2hit) { HitList * processed = NULL; HitList * temp; int i; int topscore; assert(lm); assert(dpri); if( conv->type == HSP2HitList_Ungapped ) { processed = HitList_from_LinearHSPmanager(lm); } else if ( conv->type == HSP2HitList_None ) { processed = HitList_alloc_std(); return processed; } else if( conv->type == HSP2HitList_Fulldp ) { processed = HitList_from_LinearHSPmanager_sw(lm,dpri); } else if( conv->type == HSP2HitList_Heuristic ) { if( conv->threaded == FALSE ) { processed = HitList_from_LinearHSPmanager_heuristic(lm,dpri,hsp2hit); } else { processed = HitList_from_LinearHSPmanager_heuristic_threaded(lm,dpri,conv->no_threads,hsp2hit); } } else { fatal("Could not covert type %d for hit list conversion",conv->type); } /* if there is a best-in-genome step, do a final screen of the results */ if( hsp2hit->best_hit == TRUE && processed->len > 2) { temp = HitList_alloc_len(processed->len); topscore = processed->pair[0]->raw_score; for(i=0;ilen;i++) { if( ((double)(processed->pair[i]->raw_score - topscore))*100.0/topscore > hsp2hit->perc_hit_dropoff ) { break; } else { add_HitList(temp,hard_link_HitPair(processed->pair[i])); } } free_HitList(processed); processed= temp; } return processed; } void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s query_sequence_file_fasta\n",program_name); fprintf(ofp," -dbsize [number] effective db size for Evalue calculation [300000]\n"); fprintf(ofp," -[no]mott use Mott's statistics or not (default yes)\n"); show_help_ScanWiseHSPImpl(ofp); show_help_HSPScanInterfacePara(ofp); show_help_HSP2HitList(ofp); show_help_HSPset2HitPairPara(ofp); show_help_HitListOutputImpl(ofp); show_help_DPRunImpl(ofp); show_standard_options(ofp); fprintf(ofp,"The following options are only applicable to the -seqdb case\n"); show_help_SeqLookupLoadPara(ofp); show_help_ProteinIndexConstructor(ofp); } int main(int argc,char ** argv) { DPRunImpl * dpri = NULL; ScanWiseHSPImpl * scani = NULL; HSP2HitListImpl * hsp2hiti = NULL; HitListOutputImpl * hloi = NULL; ProteinIndexConstructor * pic = NULL; HSPScanInterface * hsi; HSPScanInterfacePara * para; SearchStatInterface * ssi; SearchStatInterface * ssl; SeqLookupLoadPara * slp; HSPset2HitPairPara * hsp2hit; CompMat * mat; SequenceDB * db; Sequence * seq; int ret; int i; int effective_db_size = 300000; int kk; int count = 0; LinearHSPmanager * lm; HitList * hl; boolean use_mott = 1; boolean trunc_best_hsp = 0; boolean verbose = 0; static struct rusage use; struct timeval t0, t1; gettimeofday(&t0, NULL); dpri = new_DPRunImpl_from_argv(&argc,argv); dpri->memory = DPIM_Explicit; scani = new_ScanWiseHSPImpl_from_argv(&argc,argv); hsp2hiti = new_HSP2HitListImpl_from_argv(&argc,argv); hloi = new_HitListOutputImpl_from_argv(&argc,argv); slp = new_SeqLookupLoadPara_from_argv(&argc,argv); pic = new_ProteinIndexConstructor_from_argv(&argc,argv); hsp2hit = new_HSPset2HitPairPara_from_argv(&argc,argv); para = new_HSPScanInterfacePara_from_argv(&argc,argv); verbose = strip_out_boolean_argument(&argc,argv,"verbose") ; strip_out_boolean_def_argument(&argc,argv,"mott",&use_mott); strip_out_boolean_def_argument(&argc,argv,"besthsp",&trunc_best_hsp); strip_out_integer_argument(&argc,argv,"dbsize",&effective_db_size); #ifdef SCAN_CORBA sorb = get_Wise2Corba_Singleton(&argc,argv,"orbit-local-orb"); #endif if( dpri == NULL ) { fatal("Unable to build DPRun implementation. Bad arguments"); } strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 2 ) { show_help(stdout); exit(12); } /* ugly, but we don't want to bounce matrices around the network... */ mat = read_Blast_file_CompMat("BLOSUM62.bla"); erroroff(REPORT); hsi = new_HSPScanInterface_from_ScanWiseHSPImpl(scani,pic,slp); ssi = new_Mott_SearchStatInterface(); ssl = new_lookup_SearchStatInterface(40,2.3); if( verbose ) { info("contacted database"); } db = single_fasta_SequenceDB(argv[1]); if( db == NULL ) { fatal("Could not open sequence db...\n"); } for(seq = init_SequenceDB(db,&ret); seq != NULL;seq = get_next_SequenceDB(db) ) { count++; for(i=0;ilen;i++) { if( !isalpha(seq->seq[i]) ) { fatal("Sequence position %d [%c] is not valid",i,seq->seq[i]); } seq->seq[i] = toupper(seq->seq[i]); } info("Processing %s",seq->name); getrusage(RUSAGE_SELF,&use); /* info("Before query %s %.3fu %.3fs\n", seq->name, use.ru_utime.tv_sec + use.ru_utime.tv_usec*MICROSECOND, use.ru_stime.tv_sec + use.ru_stime.tv_usec*MICROSECOND ); */ lm = (*hsi->scan_query)(hsi->data,seq,para); fprintf(stderr,"Got linear manager is %d entries\n",lm->len); if( lm->mat == NULL ) { lm->mat = hard_link_CompMat(mat); } getrusage(RUSAGE_SELF,&use); /* info("After query %s %.3fu %.3fs\n", seq->name, use.ru_utime.tv_sec + use.ru_utime.tv_usec*MICROSECOND, use.ru_stime.tv_sec + use.ru_stime.tv_usec*MICROSECOND ); */ sort_LinearHSPmanager(lm,compare_HSPset_score); if( trunc_best_hsp == 1 ) { for(kk=1;kklen;kk++) { free_HSPset(lm->set[kk]); lm->set[kk] = NULL; } lm->len = 1; } getrusage(RUSAGE_SELF,&use); /* info("After sort %s %.3fu %.3fs\n", seq->name, use.ru_utime.tv_sec + use.ru_utime.tv_usec*MICROSECOND, use.ru_stime.tv_sec + use.ru_stime.tv_usec*MICROSECOND ); */ hl = HitList_from_HSP_HSP2HitListImpl(hsp2hiti,lm,dpri,hsp2hit); getrusage(RUSAGE_SELF,&use); /* info("After conversion %s %.3fu %.3fs\n", seq->name, use.ru_utime.tv_sec + use.ru_utime.tv_usec*MICROSECOND, use.ru_stime.tv_sec + use.ru_stime.tv_usec*MICROSECOND ); */ free_LinearHSPmanager(lm); if( use_mott == 1 ) { apply_SearchStat_to_HitList(hl,ssi,effective_db_size); } else { for(kk=0;kklen;kk++) { hl->pair[kk]->bit_score = hl->pair[kk]->raw_score / 2.0; } } sort_HitList_by_score(hl); show_HitList_HitListOutputImpl(hloi,hl,stdout); getrusage(RUSAGE_SELF,&use); /* info("After output %s %.3fu %.3fs\n", seq->name, use.ru_utime.tv_sec + use.ru_utime.tv_usec*MICROSECOND, use.ru_stime.tv_sec + use.ru_stime.tv_usec*MICROSECOND ); */ free_HitList(hl); free_Sequence(seq); } free_DPRunImpl(dpri); free_HSPScanInterface(hsi); gettimeofday(&t1, NULL); fprintf(stderr, "[client stats] queries, time (s): %d %f\n", count, (t1.tv_sec - t0.tv_sec) + (t1.tv_usec - t0.tv_usec) * 1e-6); return 0; } wise-2.4.1/src/models/matchsum_api.h0000644000175000001440000003707010670453714016764 0ustar philippusers /* Functions that create, manipulate or act on MatchSummarySet * * Wise2_MatchSummarySet_from_AlnBlock_estwise * Wise2_MatchSummarySet_from_AlnBlock_genewise * Wise2_hard_link_MatchSummarySet * Wise2_MatchSummarySet_alloc_std * Wise2_access_ms_MatchSummarySet * Wise2_length_ms_MatchSummarySet * Wise2_flush_MatchSummarySet * Wise2_add_MatchSummarySet * Wise2_free_MatchSummarySet [destructor] * */ /* Functions that create, manipulate or act on MatchSummary * * Wise2_hard_link_MatchSummary * Wise2_MatchSummary_alloc * Wise2_replace_bits_MatchSummary * Wise2_access_bits_MatchSummary * Wise2_replace_qname_MatchSummary * Wise2_access_qname_MatchSummary * Wise2_replace_tname_MatchSummary * Wise2_access_tname_MatchSummary * Wise2_replace_qstart_MatchSummary * Wise2_access_qstart_MatchSummary * Wise2_replace_qend_MatchSummary * Wise2_access_qend_MatchSummary * Wise2_replace_tstart_MatchSummary * Wise2_access_tstart_MatchSummary * Wise2_replace_tend_MatchSummary * Wise2_access_tend_MatchSummary * Wise2_replace_qintron_MatchSummary * Wise2_access_qintron_MatchSummary * Wise2_replace_qframeshift_MatchSummary * Wise2_access_qframeshift_MatchSummary * Wise2_replace_tintron_MatchSummary * Wise2_access_tintron_MatchSummary * Wise2_replace_tframeshift_MatchSummary * Wise2_access_tframeshift_MatchSummary * Wise2_free_MatchSummary [destructor] * */ /* API for object MatchSummarySet */ /* Function: Wise2_MatchSummarySet_from_AlnBlock_estwise(alb,qname,offset,target) * * Descrip: Builds a MatchSummarySet from a * EstWise alignment. this makes * alot of assumptions about the labels * setc in alb, so make sure it was a * estwise alignment - however as you * can notice this is exactly the same * labels as found in genewise set * * * Arg: alb Undocumented argument [Wise2_AlnBlock *] * Arg: qname Undocumented argument [char *] * Arg: offset Undocumented argument [int] * Arg: target Undocumented argument [Wise2_Sequence *] * * Returns Undocumented return value [Wise2_MatchSummarySet *] * */ Wise2_MatchSummarySet * Wise2_MatchSummarySet_from_AlnBlock_estwise( Wise2_AlnBlock * alb,char * qname,int offset,Wise2_Sequence * target); /* Function: Wise2_MatchSummarySet_from_AlnBlock_genewise(alb,qname,protoff,target) * * Descrip: Builds a MatchSummarySet from a * GeneWise alignment. this makes * alot of assumptions about the labels * setc in alb, so make sure it was a * genewise alignment * * * Arg: alb Undocumented argument [Wise2_AlnBlock *] * Arg: qname Undocumented argument [char *] * Arg: protoff Undocumented argument [int] * Arg: target Undocumented argument [Wise2_Sequence *] * * Returns Undocumented return value [Wise2_MatchSummarySet *] * */ Wise2_MatchSummarySet * Wise2_MatchSummarySet_from_AlnBlock_genewise( Wise2_AlnBlock * alb,char * qname,int protoff,Wise2_Sequence * target); /* Function: Wise2_hard_link_MatchSummarySet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_MatchSummarySet *] * * Returns Undocumented return value [Wise2_MatchSummarySet *] * */ Wise2_MatchSummarySet * Wise2_hard_link_MatchSummarySet( Wise2_MatchSummarySet * obj); /* Function: Wise2_MatchSummarySet_alloc_std(void) * * Descrip: Equivalent to MatchSummarySet_alloc_len(MatchSummarySetLISTLENGTH) * * * * Returns Undocumented return value [Wise2_MatchSummarySet *] * */ Wise2_MatchSummarySet * Wise2_MatchSummarySet_alloc_std(); /* Function: Wise2_access_ms_MatchSummarySet(obj,i) * * Descrip: Access members stored in the ms list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_MatchSummarySet *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_MatchSummary *] * */ Wise2_MatchSummary * Wise2_access_ms_MatchSummarySet( Wise2_MatchSummarySet * obj,int i); /* Function: Wise2_length_ms_MatchSummarySet(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_MatchSummarySet *] * * Returns length of the list [int] * */ int Wise2_length_ms_MatchSummarySet( Wise2_MatchSummarySet * obj); /* Function: Wise2_flush_MatchSummarySet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_MatchSummarySet *] * * Returns Undocumented return value [int] * */ int Wise2_flush_MatchSummarySet( Wise2_MatchSummarySet * obj); /* Function: Wise2_add_MatchSummarySet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_MatchSummarySet *] * Arg: add Object to add to the list [Wise2_MatchSummary *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_MatchSummarySet( Wise2_MatchSummarySet * obj,Wise2_MatchSummary * add); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_MatchSummarySet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_MatchSummarySet *] * * Returns Undocumented return value [Wise2_MatchSummarySet *] * */ Wise2_MatchSummarySet * Wise2_free_MatchSummarySet( Wise2_MatchSummarySet * obj); /* API for object MatchSummary */ /* Function: Wise2_hard_link_MatchSummary(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_MatchSummary *] * * Returns Undocumented return value [Wise2_MatchSummary *] * */ Wise2_MatchSummary * Wise2_hard_link_MatchSummary( Wise2_MatchSummary * obj); /* Function: Wise2_MatchSummary_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_MatchSummary *] * */ Wise2_MatchSummary * Wise2_MatchSummary_alloc(); /* Function: Wise2_replace_bits_MatchSummary(obj,bits) * * Descrip: Replace member variable bits * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * Arg: bits New value of the variable [double] * * Returns member variable bits [boolean] * */ boolean Wise2_replace_bits_MatchSummary( Wise2_MatchSummary * obj,double bits); /* Function: Wise2_access_bits_MatchSummary(obj) * * Descrip: Access member variable bits * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * * Returns member variable bits [double] * */ double Wise2_access_bits_MatchSummary( Wise2_MatchSummary * obj); /* Function: Wise2_replace_qname_MatchSummary(obj,qname) * * Descrip: Replace member variable qname * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * Arg: qname New value of the variable [char *] * * Returns member variable qname [boolean] * */ boolean Wise2_replace_qname_MatchSummary( Wise2_MatchSummary * obj,char * qname); /* Function: Wise2_access_qname_MatchSummary(obj) * * Descrip: Access member variable qname * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * * Returns member variable qname [char *] * */ char * Wise2_access_qname_MatchSummary( Wise2_MatchSummary * obj); /* Function: Wise2_replace_tname_MatchSummary(obj,tname) * * Descrip: Replace member variable tname * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * Arg: tname New value of the variable [char *] * * Returns member variable tname [boolean] * */ boolean Wise2_replace_tname_MatchSummary( Wise2_MatchSummary * obj,char * tname); /* Function: Wise2_access_tname_MatchSummary(obj) * * Descrip: Access member variable tname * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * * Returns member variable tname [char *] * */ char * Wise2_access_tname_MatchSummary( Wise2_MatchSummary * obj); /* Function: Wise2_replace_qstart_MatchSummary(obj,qstart) * * Descrip: Replace member variable qstart * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * Arg: qstart New value of the variable [int] * * Returns member variable qstart [boolean] * */ boolean Wise2_replace_qstart_MatchSummary( Wise2_MatchSummary * obj,int qstart); /* Function: Wise2_access_qstart_MatchSummary(obj) * * Descrip: Access member variable qstart * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * * Returns member variable qstart [int] * */ int Wise2_access_qstart_MatchSummary( Wise2_MatchSummary * obj); /* Function: Wise2_replace_qend_MatchSummary(obj,qend) * * Descrip: Replace member variable qend * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * Arg: qend New value of the variable [int] * * Returns member variable qend [boolean] * */ boolean Wise2_replace_qend_MatchSummary( Wise2_MatchSummary * obj,int qend); /* Function: Wise2_access_qend_MatchSummary(obj) * * Descrip: Access member variable qend * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * * Returns member variable qend [int] * */ int Wise2_access_qend_MatchSummary( Wise2_MatchSummary * obj); /* Function: Wise2_replace_tstart_MatchSummary(obj,tstart) * * Descrip: Replace member variable tstart * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * Arg: tstart New value of the variable [int] * * Returns member variable tstart [boolean] * */ boolean Wise2_replace_tstart_MatchSummary( Wise2_MatchSummary * obj,int tstart); /* Function: Wise2_access_tstart_MatchSummary(obj) * * Descrip: Access member variable tstart * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * * Returns member variable tstart [int] * */ int Wise2_access_tstart_MatchSummary( Wise2_MatchSummary * obj); /* Function: Wise2_replace_tend_MatchSummary(obj,tend) * * Descrip: Replace member variable tend * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * Arg: tend New value of the variable [int] * * Returns member variable tend [boolean] * */ boolean Wise2_replace_tend_MatchSummary( Wise2_MatchSummary * obj,int tend); /* Function: Wise2_access_tend_MatchSummary(obj) * * Descrip: Access member variable tend * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * * Returns member variable tend [int] * */ int Wise2_access_tend_MatchSummary( Wise2_MatchSummary * obj); /* Function: Wise2_replace_qintron_MatchSummary(obj,qintron) * * Descrip: Replace member variable qintron * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * Arg: qintron New value of the variable [int] * * Returns member variable qintron [boolean] * */ boolean Wise2_replace_qintron_MatchSummary( Wise2_MatchSummary * obj,int qintron); /* Function: Wise2_access_qintron_MatchSummary(obj) * * Descrip: Access member variable qintron * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * * Returns member variable qintron [int] * */ int Wise2_access_qintron_MatchSummary( Wise2_MatchSummary * obj); /* Function: Wise2_replace_qframeshift_MatchSummary(obj,qframeshift) * * Descrip: Replace member variable qframeshift * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * Arg: qframeshift New value of the variable [int] * * Returns member variable qframeshift [boolean] * */ boolean Wise2_replace_qframeshift_MatchSummary( Wise2_MatchSummary * obj,int qframeshift); /* Function: Wise2_access_qframeshift_MatchSummary(obj) * * Descrip: Access member variable qframeshift * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * * Returns member variable qframeshift [int] * */ int Wise2_access_qframeshift_MatchSummary( Wise2_MatchSummary * obj); /* Function: Wise2_replace_tintron_MatchSummary(obj,tintron) * * Descrip: Replace member variable tintron * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * Arg: tintron New value of the variable [int] * * Returns member variable tintron [boolean] * */ boolean Wise2_replace_tintron_MatchSummary( Wise2_MatchSummary * obj,int tintron); /* Function: Wise2_access_tintron_MatchSummary(obj) * * Descrip: Access member variable tintron * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * * Returns member variable tintron [int] * */ int Wise2_access_tintron_MatchSummary( Wise2_MatchSummary * obj); /* Function: Wise2_replace_tframeshift_MatchSummary(obj,tframeshift) * * Descrip: Replace member variable tframeshift * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * Arg: tframeshift New value of the variable [int] * * Returns member variable tframeshift [boolean] * */ boolean Wise2_replace_tframeshift_MatchSummary( Wise2_MatchSummary * obj,int tframeshift); /* Function: Wise2_access_tframeshift_MatchSummary(obj) * * Descrip: Access member variable tframeshift * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_MatchSummary *] * * Returns member variable tframeshift [int] * */ int Wise2_access_tframeshift_MatchSummary( Wise2_MatchSummary * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_MatchSummary(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_MatchSummary *] * * Returns Undocumented return value [Wise2_MatchSummary *] * */ Wise2_MatchSummary * Wise2_free_MatchSummary( Wise2_MatchSummary * obj); wise-2.4.1/src/models/matchsum_api.t0000644000175000001440000000016410670453714016772 0ustar philippuserstypedef struct Wise2_MatchSummarySet Wise2_MatchSummarySet; typedef struct Wise2_MatchSummary Wise2_MatchSummary; wise-2.4.1/src/models/genomewise9.c0000644000175000001440000115210210670453714016533 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genomewise9.h" # line 5 "genomewise9.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define UTR5 0 #define UTR5_INTRON 1 #define START_CODON 2 #define CDS 3 #define CDS_INTRON_0 4 #define CDS_INTRON_1 5 #define CDS_INTRON_2 6 #define STOP_CODON 7 #define UTR3 8 #define UTR3_INTRON 9 #define PREGENE_INTERGENIC 0 #define POSTGENE_INTERGENIC 1 #define INTERGENIC 2 #define SPECIAL_UTR5 3 #define SPECIAL_UTR3 4 #define SPECIAL_CDS 5 #define START 6 #define END 7 #define GenomeWise9_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+10)*10)+STATE][i+0] #define GenomeWise9_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+10] #define GenomeWise9_READ_OFF_ERROR -11 #define GenomeWise9_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+11)%11][((i+0)*10)+STATE] #define GenomeWise9_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+11)%11][STATE] #define GenomeWise9_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define GenomeWise9_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_GenomeWise9(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_GenomeWise9(GenomeWise9 * mat) { GenomeWise9_access_func_holder holder; holder.access_main = GenomeWise9_shatter_access_main; holder.access_special = GenomeWise9_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_GenomeWise9(mat,holder); } /* Function: GenomeWise9_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GenomeWise9_shatter_access_main(GenomeWise9 * mat,int i,int j,int state) { return GenomeWise9_SHATTER_MATRIX(mat,i,j,state); } /* Function: GenomeWise9_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GenomeWise9_shatter_access_special(GenomeWise9 * mat,int i,int j,int state) { return GenomeWise9_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_GenomeWise9(mat,dpenv) * * Descrip: This function calculates the GenomeWise9 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GenomeWise9 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_GenomeWise9(GenomeWise9 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_0_1; int * SIG_0_3; int * SIG_0_6; int * SIG_0_5; int * SIG_0_4; int * SIG_0_2; int * SIG_0_8; int * SIG_0_9; int * SIG_0_10; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,10,lenj,8); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("GenomeWise9 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-6); SIG_0_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-5); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_8 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-8); SIG_0_9 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-9); SIG_0_10 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-10); /* For state UTR5 */ /* setting first movement to score */ score = SIG_0_1[UTR5] + GNE_UTR(mat->evi,i,mat->gen,j); /* From state UTR5_INTRON to state UTR5 */ temp = SIG_0_1[UTR5_INTRON] + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state SPECIAL_UTR5 to state UTR5 */ temp = GenomeWise9_SHATTER_SPECIAL(mat,i-0,j-1,SPECIAL_UTR5) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state START to state UTR5 */ temp = GenomeWise9_SHATTER_SPECIAL(mat,i-0,j-1,START) + GNE_UTR5_START(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state INTERGENIC to state UTR5 */ temp = GenomeWise9_SHATTER_SPECIAL(mat,i-0,j-1,INTERGENIC) + (GNE_UTR(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j)); if( temp > score ) { score = temp; } /* From state PREGENE_INTERGENIC to state UTR5 */ temp = GenomeWise9_SHATTER_SPECIAL(mat,i-0,j-1,PREGENE_INTERGENIC) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ SIG_0_0[UTR5] = score; /* state UTR5 is a source for special SPECIAL_UTR5 */ temp = score + (mat->switchcost) + (0) ; if( temp > GenomeWise9_SHATTER_SPECIAL(mat,i,j,SPECIAL_UTR5) ) { GenomeWise9_SHATTER_SPECIAL(mat,i,j,SPECIAL_UTR5) = temp; } /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = SIG_0_1[UTR5_INTRON] + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* From state UTR5 to state UTR5_INTRON */ temp = SIG_0_1[UTR5] + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ SIG_0_0[UTR5_INTRON] = score; /* Finished calculating state UTR5_INTRON */ /* For state START_CODON */ /* setting first movement to score */ score = SIG_0_3[UTR5_INTRON] + GNE_START_CODON(mat->evi,i,mat->gen,j); /* From state UTR5 to state START_CODON */ temp = SIG_0_3[UTR5] + GNE_START_CODON(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for START_CODON */ /* Add any movement independant score and put away */ SIG_0_0[START_CODON] = score; /* Finished calculating state START_CODON */ /* For state CDS */ /* setting first movement to score */ score = SIG_0_3[CDS] + GNE_CDS(mat->evi,i,mat->gen,j); /* From state CDS_INTRON_0 to state CDS */ temp = SIG_0_6[CDS_INTRON_0] + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-3),0); if( temp > score ) { score = temp; } /* From state CDS_INTRON_1 to state CDS */ temp = SIG_0_5[CDS_INTRON_1] + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-2),1); if( temp > score ) { score = temp; } /* From state CDS_INTRON_2 to state CDS */ temp = SIG_0_4[CDS_INTRON_2] + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-1),2); if( temp > score ) { score = temp; } /* From state CDS to state CDS */ temp = SIG_0_2[CDS] + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,2); if( temp > score ) { score = temp; } /* From state CDS to state CDS */ temp = SIG_0_4[CDS] + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,4); if( temp > score ) { score = temp; } /* From state UTR5 to state CDS */ temp = SIG_0_3[UTR5] + (GNE_CDS(mat->evi,i,mat->gen,j)+mat->non_start_codon); if( temp > score ) { score = temp; } /* From state START_CODON to state CDS */ temp = SIG_0_3[START_CODON] + GNE_CDS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state SPECIAL_CDS to state CDS */ temp = GenomeWise9_SHATTER_SPECIAL(mat,i-0,j-3,SPECIAL_CDS) + GNE_CDS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state INTERGENIC to state CDS */ temp = GenomeWise9_SHATTER_SPECIAL(mat,i-0,j-3,INTERGENIC) + (GNE_CDS(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS */ /* Add any movement independant score and put away */ SIG_0_0[CDS] = score; /* state CDS is a source for special INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_SHATTER_SPECIAL(mat,i,j,INTERGENIC) ) { GenomeWise9_SHATTER_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* state CDS is a source for special SPECIAL_CDS */ temp = score + ((mat->switchcost+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)])) + (0) ; if( temp > GenomeWise9_SHATTER_SPECIAL(mat,i,j,SPECIAL_CDS) ) { GenomeWise9_SHATTER_SPECIAL(mat,i,j,SPECIAL_CDS) = temp; } /* Finished calculating state CDS */ /* For state CDS_INTRON_0 */ /* setting first movement to score */ score = SIG_0_1[CDS_INTRON_0] + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_0 */ temp = SIG_0_8[CDS] + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),0); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_0 */ /* Add any movement independant score and put away */ SIG_0_0[CDS_INTRON_0] = score; /* Finished calculating state CDS_INTRON_0 */ /* For state CDS_INTRON_1 */ /* setting first movement to score */ score = SIG_0_1[CDS_INTRON_1] + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_1 */ temp = SIG_0_9[CDS] + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),1); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_1 */ /* Add any movement independant score and put away */ SIG_0_0[CDS_INTRON_1] = score; /* Finished calculating state CDS_INTRON_1 */ /* For state CDS_INTRON_2 */ /* setting first movement to score */ score = SIG_0_1[CDS_INTRON_2] + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_2 */ temp = SIG_0_10[CDS] + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),2); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_2 */ /* Add any movement independant score and put away */ SIG_0_0[CDS_INTRON_2] = score; /* Finished calculating state CDS_INTRON_2 */ /* For state STOP_CODON */ /* setting first movement to score */ score = SIG_0_3[CDS] + GNE_STOP_CODON(mat->evi,i,mat->gen,j); /* Ok - finished max calculation for STOP_CODON */ /* Add any movement independant score and put away */ SIG_0_0[STOP_CODON] = score; /* Finished calculating state STOP_CODON */ /* For state UTR3 */ /* setting first movement to score */ score = SIG_0_1[UTR3] + GNE_UTR(mat->evi,i,mat->gen,j); /* From state CDS to state UTR3 */ temp = SIG_0_1[CDS] + (GNE_UTR(mat->evi,i,mat->gen,j)+mat->non_stop_codon); if( temp > score ) { score = temp; } /* From state STOP_CODON to state UTR3 */ temp = SIG_0_1[STOP_CODON] + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state UTR3_INTRON to state UTR3 */ temp = SIG_0_1[UTR3_INTRON] + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Has restricted position */ if( (j-1) == 0 ) { /* From state INTERGENIC to state UTR3 */ temp = GenomeWise9_SHATTER_SPECIAL(mat,i-0,j-1,INTERGENIC) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ SIG_0_0[UTR3] = score; /* state UTR3 is a source for special POSTGENE_INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_SHATTER_SPECIAL(mat,i,j,POSTGENE_INTERGENIC) ) { GenomeWise9_SHATTER_SPECIAL(mat,i,j,POSTGENE_INTERGENIC) = temp; } /* state UTR3 is a source for special INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_SHATTER_SPECIAL(mat,i,j,INTERGENIC) ) { GenomeWise9_SHATTER_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* state UTR3 is a source for special SPECIAL_UTR3 */ temp = score + (mat->switchcost) + (0) ; if( temp > GenomeWise9_SHATTER_SPECIAL(mat,i,j,SPECIAL_UTR3) ) { GenomeWise9_SHATTER_SPECIAL(mat,i,j,SPECIAL_UTR3) = temp; } /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = SIG_0_1[UTR3_INTRON] + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* From state UTR3 to state UTR3_INTRON */ temp = SIG_0_1[UTR3] + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state SPECIAL_UTR3 to state UTR3_INTRON */ temp = GenomeWise9_SHATTER_SPECIAL(mat,i-0,j-1,SPECIAL_UTR3) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ SIG_0_0[UTR3_INTRON] = score; /* Finished calculating state UTR3_INTRON */ } /* Special state PREGENE_INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_SHATTER_SPECIAL(mat,0,j,PREGENE_INTERGENIC); /* Source START is a special source for PREGENE_INTERGENIC */ temp = GenomeWise9_SHATTER_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenomeWise9_SHATTER_SPECIAL(mat,0,j,PREGENE_INTERGENIC) = score; /* Finished updating state PREGENE_INTERGENIC */ /* Special state POSTGENE_INTERGENIC has no special to special movements */ /* Special state INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_SHATTER_SPECIAL(mat,0,j,INTERGENIC); /* Source INTERGENIC is a special source for INTERGENIC */ temp = GenomeWise9_SHATTER_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; /* Source CDS for state INTERGENIC is not special... already calculated */ /* Source UTR3 for state INTERGENIC is not special... already calculated */ /* Put back score... (now updated!) */ GenomeWise9_SHATTER_SPECIAL(mat,0,j,INTERGENIC) = score; /* Finished updating state INTERGENIC */ /* Special state SPECIAL_UTR5 has no special to special movements */ /* Special state SPECIAL_UTR3 has no special to special movements */ /* Special state SPECIAL_CDS has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_SHATTER_SPECIAL(mat,0,j,SPECIAL_CDS); /* Source CDS for state SPECIAL_CDS is not special... already calculated */ /* Source SPECIAL_CDS is a special source for SPECIAL_CDS */ temp = GenomeWise9_SHATTER_SPECIAL(mat,0,j - 3,SPECIAL_CDS) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenomeWise9_SHATTER_SPECIAL(mat,0,j,SPECIAL_CDS) = score; /* Finished updating state SPECIAL_CDS */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_SHATTER_SPECIAL(mat,0,j,END); /* Source INTERGENIC is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GenomeWise9_SHATTER_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GenomeWise9_SHATTER_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: search_GenomeWise9(dbsi,out,evi,targetdb,switchcost,newgenecost,non_start_codon,non_stop_codon,rndcodon) * * Descrip: This function makes a database search of GenomeWise9 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: evi [UNKN ] Undocumented argument [GenomeEvidenceSet*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: switchcost [UNKN ] Undocumented argument [int] * Arg: newgenecost [UNKN ] Undocumented argument [int] * Arg: non_start_codon [UNKN ] Undocumented argument [int] * Arg: non_stop_codon [UNKN ] Undocumented argument [int] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_GenomeWise9(DBSearchImpl * dbsi,Hscore * out,GenomeEvidenceSet* evi,GenomicDB* targetdb ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_GenomeWise9 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_GenomeWise9. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_GenomeWise9. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for GenomeWise9, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_GenomeWise9(out,evi, targetdb ,switchcost,newgenecost,non_start_codon,non_stop_codon,rndcodon); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_GenomeWise9 *) ckalloc(sizeof(struct thread_pool_holder_GenomeWise9)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->evi = evi; holder->targetdb = targetdb; holder->switchcost = switchcost; holder->newgenecost = newgenecost; holder->non_start_codon = non_start_codon; holder->non_stop_codon = non_stop_codon; holder->rndcodon = rndcodon; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_GenomeWise9,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for GenomeWise9"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from GenomeWise9",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_GenomeWise9(ptr) * * Descrip: dummy loop code foreach thread for GenomeWise9 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * thread_loop_GenomeWise9(void * ptr) { fatal("dummy thread loop function"); } /* Function: serial_search_GenomeWise9(out,evi,targetdb,switchcost,newgenecost,non_start_codon,non_stop_codon,rndcodon) * * Descrip: This function makes a database search of GenomeWise9 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: evi [UNKN ] Undocumented argument [GenomeEvidenceSet*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: switchcost [UNKN ] Undocumented argument [int] * Arg: newgenecost [UNKN ] Undocumented argument [int] * Arg: non_start_codon [UNKN ] Undocumented argument [int] * Arg: non_stop_codon [UNKN ] Undocumented argument [int] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_GenomeWise9(Hscore * out,GenomeEvidenceSet* evi,GenomicDB* targetdb ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon) { ComplexSequence* gen; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; gen = init_GenomicDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GenomeWise9, got a database init error on the target [gen] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_GenomeWise9(evi, gen , switchcost, newgenecost, non_start_codon, non_stop_codon, rndcodon); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("GenomeWise9 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GenomicDB(ds->target,gen,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); gen = reload_GenomicDB(gen,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GenomeWise9, Reload error on database gen, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break; /* Out of target loop */ target_pos++; } /* end of For all target entries */ close_GenomicDB(gen,targetdb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_GenomeWise9(evi,gen,switchcost,newgenecost,non_start_codon,non_stop_codon,rndcodon) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_GenomeWise9_only * * * Arg: evi [UNKN ] query data structure [GenomeEvidenceSet*] * Arg: gen [UNKN ] target data structure [ComplexSequence*] * Arg: switchcost [UNKN ] Resource [int] * Arg: newgenecost [UNKN ] Resource [int] * Arg: non_start_codon [UNKN ] Resource [int] * Arg: non_stop_codon [UNKN ] Resource [int] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_GenomeWise9(GenomeEvidenceSet* evi,ComplexSequence* gen ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon) { int bestscore = NEGI; int i; int j; int k; GenomeWise9 * mat; mat = allocate_GenomeWise9_only(evi, gen , switchcost, newgenecost, non_start_codon, non_stop_codon, rndcodon); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(11,(mat->leni + 0) * 10,11,8)) == NULL) { warn("Score only matrix for GenomeWise9 cannot be allocated, (asking for 10 by %d cells)",mat->leni*10); mat = free_GenomeWise9(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<12;j++) { for(i=(-0);ileni;i++) { for(k=0;k<10;k++) GenomeWise9_VSMALL_MATRIX(mat,i,j,k) = NEGI; } GenomeWise9_VSMALL_SPECIAL(mat,i,j,PREGENE_INTERGENIC) = NEGI; GenomeWise9_VSMALL_SPECIAL(mat,i,j,POSTGENE_INTERGENIC) = NEGI; GenomeWise9_VSMALL_SPECIAL(mat,i,j,INTERGENIC) = NEGI; GenomeWise9_VSMALL_SPECIAL(mat,i,j,SPECIAL_UTR5) = NEGI; GenomeWise9_VSMALL_SPECIAL(mat,i,j,SPECIAL_UTR3) = NEGI; GenomeWise9_VSMALL_SPECIAL(mat,i,j,SPECIAL_CDS) = NEGI; GenomeWise9_VSMALL_SPECIAL(mat,i,j,START) = 0; GenomeWise9_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state UTR5 */ /* setting first movement to score */ score = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR(mat->evi,i,mat->gen,j); /* From state UTR5_INTRON to state UTR5 */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state SPECIAL_UTR5 to state UTR5 */ temp = GenomeWise9_VSMALL_SPECIAL(mat,i-0,j-1,SPECIAL_UTR5) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state START to state UTR5 */ temp = GenomeWise9_VSMALL_SPECIAL(mat,i-0,j-1,START) + GNE_UTR5_START(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state INTERGENIC to state UTR5 */ temp = GenomeWise9_VSMALL_SPECIAL(mat,i-0,j-1,INTERGENIC) + (GNE_UTR(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j)); if( temp > score ) { score = temp; } /* From state PREGENE_INTERGENIC to state UTR5 */ temp = GenomeWise9_VSMALL_SPECIAL(mat,i-0,j-1,PREGENE_INTERGENIC) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ GenomeWise9_VSMALL_MATRIX(mat,i,j,UTR5) = score; /* state UTR5 is a source for special SPECIAL_UTR5 */ temp = score + (mat->switchcost) + (0) ; if( temp > GenomeWise9_VSMALL_SPECIAL(mat,i,j,SPECIAL_UTR5) ) { GenomeWise9_VSMALL_SPECIAL(mat,i,j,SPECIAL_UTR5) = temp; } /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* From state UTR5 to state UTR5_INTRON */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ GenomeWise9_VSMALL_MATRIX(mat,i,j,UTR5_INTRON) = score; /* Finished calculating state UTR5_INTRON */ /* For state START_CODON */ /* setting first movement to score */ score = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-3,UTR5_INTRON) + GNE_START_CODON(mat->evi,i,mat->gen,j); /* From state UTR5 to state START_CODON */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-3,UTR5) + GNE_START_CODON(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for START_CODON */ /* Add any movement independant score and put away */ GenomeWise9_VSMALL_MATRIX(mat,i,j,START_CODON) = score; /* Finished calculating state START_CODON */ /* For state CDS */ /* setting first movement to score */ score = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-3,CDS) + GNE_CDS(mat->evi,i,mat->gen,j); /* From state CDS_INTRON_0 to state CDS */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-6,CDS_INTRON_0) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-3),0); if( temp > score ) { score = temp; } /* From state CDS_INTRON_1 to state CDS */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-5,CDS_INTRON_1) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-2),1); if( temp > score ) { score = temp; } /* From state CDS_INTRON_2 to state CDS */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-4,CDS_INTRON_2) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-1),2); if( temp > score ) { score = temp; } /* From state CDS to state CDS */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-2,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,2); if( temp > score ) { score = temp; } /* From state CDS to state CDS */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-4,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,4); if( temp > score ) { score = temp; } /* From state UTR5 to state CDS */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-3,UTR5) + (GNE_CDS(mat->evi,i,mat->gen,j)+mat->non_start_codon); if( temp > score ) { score = temp; } /* From state START_CODON to state CDS */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-3,START_CODON) + GNE_CDS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state SPECIAL_CDS to state CDS */ temp = GenomeWise9_VSMALL_SPECIAL(mat,i-0,j-3,SPECIAL_CDS) + GNE_CDS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state INTERGENIC to state CDS */ temp = GenomeWise9_VSMALL_SPECIAL(mat,i-0,j-3,INTERGENIC) + (GNE_CDS(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS */ /* Add any movement independant score and put away */ GenomeWise9_VSMALL_MATRIX(mat,i,j,CDS) = score; /* state CDS is a source for special INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_VSMALL_SPECIAL(mat,i,j,INTERGENIC) ) { GenomeWise9_VSMALL_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* state CDS is a source for special SPECIAL_CDS */ temp = score + ((mat->switchcost+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)])) + (0) ; if( temp > GenomeWise9_VSMALL_SPECIAL(mat,i,j,SPECIAL_CDS) ) { GenomeWise9_VSMALL_SPECIAL(mat,i,j,SPECIAL_CDS) = temp; } /* Finished calculating state CDS */ /* For state CDS_INTRON_0 */ /* setting first movement to score */ score = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-1,CDS_INTRON_0) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_0 */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-8,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),0); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_0 */ /* Add any movement independant score and put away */ GenomeWise9_VSMALL_MATRIX(mat,i,j,CDS_INTRON_0) = score; /* Finished calculating state CDS_INTRON_0 */ /* For state CDS_INTRON_1 */ /* setting first movement to score */ score = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-1,CDS_INTRON_1) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_1 */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-9,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),1); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_1 */ /* Add any movement independant score and put away */ GenomeWise9_VSMALL_MATRIX(mat,i,j,CDS_INTRON_1) = score; /* Finished calculating state CDS_INTRON_1 */ /* For state CDS_INTRON_2 */ /* setting first movement to score */ score = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-1,CDS_INTRON_2) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_2 */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-10,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),2); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_2 */ /* Add any movement independant score and put away */ GenomeWise9_VSMALL_MATRIX(mat,i,j,CDS_INTRON_2) = score; /* Finished calculating state CDS_INTRON_2 */ /* For state STOP_CODON */ /* setting first movement to score */ score = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-3,CDS) + GNE_STOP_CODON(mat->evi,i,mat->gen,j); /* Ok - finished max calculation for STOP_CODON */ /* Add any movement independant score and put away */ GenomeWise9_VSMALL_MATRIX(mat,i,j,STOP_CODON) = score; /* Finished calculating state STOP_CODON */ /* For state UTR3 */ /* setting first movement to score */ score = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR(mat->evi,i,mat->gen,j); /* From state CDS to state UTR3 */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-1,CDS) + (GNE_UTR(mat->evi,i,mat->gen,j)+mat->non_stop_codon); if( temp > score ) { score = temp; } /* From state STOP_CODON to state UTR3 */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-1,STOP_CODON) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state UTR3_INTRON to state UTR3 */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Has restricted position */ if( (j-1) == 0 ) { /* From state INTERGENIC to state UTR3 */ temp = GenomeWise9_VSMALL_SPECIAL(mat,i-0,j-1,INTERGENIC) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ GenomeWise9_VSMALL_MATRIX(mat,i,j,UTR3) = score; /* state UTR3 is a source for special POSTGENE_INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_VSMALL_SPECIAL(mat,i,j,POSTGENE_INTERGENIC) ) { GenomeWise9_VSMALL_SPECIAL(mat,i,j,POSTGENE_INTERGENIC) = temp; } /* state UTR3 is a source for special INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_VSMALL_SPECIAL(mat,i,j,INTERGENIC) ) { GenomeWise9_VSMALL_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* state UTR3 is a source for special SPECIAL_UTR3 */ temp = score + (mat->switchcost) + (0) ; if( temp > GenomeWise9_VSMALL_SPECIAL(mat,i,j,SPECIAL_UTR3) ) { GenomeWise9_VSMALL_SPECIAL(mat,i,j,SPECIAL_UTR3) = temp; } /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* From state UTR3 to state UTR3_INTRON */ temp = GenomeWise9_VSMALL_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state SPECIAL_UTR3 to state UTR3_INTRON */ temp = GenomeWise9_VSMALL_SPECIAL(mat,i-0,j-1,SPECIAL_UTR3) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ GenomeWise9_VSMALL_MATRIX(mat,i,j,UTR3_INTRON) = score; /* Finished calculating state UTR3_INTRON */ } /* end of for all query positions */ /* Special state PREGENE_INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_VSMALL_SPECIAL(mat,0,j,PREGENE_INTERGENIC); /* Source START is a special source for PREGENE_INTERGENIC */ temp = GenomeWise9_VSMALL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenomeWise9_VSMALL_SPECIAL(mat,0,j,PREGENE_INTERGENIC) = score; /* Finished updating state PREGENE_INTERGENIC */ /* Special state POSTGENE_INTERGENIC has no special to special movements */ /* Special state INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_VSMALL_SPECIAL(mat,0,j,INTERGENIC); /* Source INTERGENIC is a special source for INTERGENIC */ temp = GenomeWise9_VSMALL_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; /* Source CDS for state INTERGENIC is not special... already calculated */ /* Source UTR3 for state INTERGENIC is not special... already calculated */ /* Put back score... (now updated!) */ GenomeWise9_VSMALL_SPECIAL(mat,0,j,INTERGENIC) = score; /* Finished updating state INTERGENIC */ /* Special state SPECIAL_UTR5 has no special to special movements */ /* Special state SPECIAL_UTR3 has no special to special movements */ /* Special state SPECIAL_CDS has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_VSMALL_SPECIAL(mat,0,j,SPECIAL_CDS); /* Source CDS for state SPECIAL_CDS is not special... already calculated */ /* Source SPECIAL_CDS is a special source for SPECIAL_CDS */ temp = GenomeWise9_VSMALL_SPECIAL(mat,0,j - 3,SPECIAL_CDS) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenomeWise9_VSMALL_SPECIAL(mat,0,j,SPECIAL_CDS) = score; /* Finished updating state SPECIAL_CDS */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_VSMALL_SPECIAL(mat,0,j,END); /* Source INTERGENIC is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GenomeWise9_VSMALL_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GenomeWise9_VSMALL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ if( bestscore < GenomeWise9_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = GenomeWise9_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_GenomeWise9(mat); return bestscore; } /* Function: PackAln_bestmemory_GenomeWise9(evi,gen,switchcost,newgenecost,non_start_codon,non_stop_codon,rndcodon,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GenomeWise9 * * * Arg: evi [UNKN ] query data structure [GenomeEvidenceSet*] * Arg: gen [UNKN ] target data structure [ComplexSequence*] * Arg: switchcost [UNKN ] Resource [int] * Arg: newgenecost [UNKN ] Resource [int] * Arg: non_start_codon [UNKN ] Resource [int] * Arg: non_stop_codon [UNKN ] Resource [int] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_GenomeWise9(GenomeEvidenceSet* evi,ComplexSequence* gen ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; GenomeWise9 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = evi->len * gen->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 10 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_GenomeWise9(evi, gen , switchcost, newgenecost, non_start_codon, non_stop_codon, rndcodon,dpri)) == NULL ) { warn("Unable to allocate large GenomeWise9 version"); return NULL; } calculate_dpenv_GenomeWise9(mat,dpenv); out = PackAln_read_Expl_GenomeWise9(mat); } else { mat = allocate_GenomeWise9_only(evi, gen , switchcost, newgenecost, non_start_codon, non_stop_codon, rndcodon); calculate_shatter_GenomeWise9(mat,dpenv); out = PackAln_read_Shatter_GenomeWise9(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_GenomeWise9(evi, gen , switchcost, newgenecost, non_start_codon, non_stop_codon, rndcodon)) == NULL ) { warn("Unable to allocate small GenomeWise9 version"); return NULL; } out = PackAln_calculate_Small_GenomeWise9(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_GenomeWise9(evi, gen , switchcost, newgenecost, non_start_codon, non_stop_codon, rndcodon,dpri)) == NULL ) { warn("Unable to allocate large GenomeWise9 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_GenomeWise9(mat); out = PackAln_read_Expl_GenomeWise9(mat); } } } mat = free_GenomeWise9(mat); return out; } /* Function: allocate_GenomeWise9_only(evi,gen,switchcost,newgenecost,non_start_codon,non_stop_codon,rndcodon) * * Descrip: This function only allocates the GenomeWise9 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: evi [UNKN ] query data structure [GenomeEvidenceSet*] * Arg: gen [UNKN ] target data structure [ComplexSequence*] * Arg: switchcost [UNKN ] Resource [int] * Arg: newgenecost [UNKN ] Resource [int] * Arg: non_start_codon [UNKN ] Resource [int] * Arg: non_stop_codon [UNKN ] Resource [int] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * * Return [UNKN ] Undocumented return value [GenomeWise9 *] * */ GenomeWise9 * allocate_GenomeWise9_only(GenomeEvidenceSet* evi,ComplexSequence* gen ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon) { GenomeWise9 * out; if((out= GenomeWise9_alloc()) == NULL) { warn("Allocation of basic GenomeWise9 structure failed..."); return NULL; } out->evi = evi; out->gen = gen; out->switchcost = switchcost; out->newgenecost = newgenecost; out->non_start_codon = non_start_codon; out->non_stop_codon = non_stop_codon; out->rndcodon = rndcodon; out->leni = evi->len; out->lenj = gen->seq->len; return out; } /* Function: allocate_Expl_GenomeWise9(evi,gen,switchcost,newgenecost,non_start_codon,non_stop_codon,rndcodon,dpri) * * Descrip: This function allocates the GenomeWise9 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GenomeWise9_only * * * Arg: evi [UNKN ] query data structure [GenomeEvidenceSet*] * Arg: gen [UNKN ] target data structure [ComplexSequence*] * Arg: switchcost [UNKN ] Resource [int] * Arg: newgenecost [UNKN ] Resource [int] * Arg: non_start_codon [UNKN ] Resource [int] * Arg: non_stop_codon [UNKN ] Resource [int] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GenomeWise9 *] * */ GenomeWise9 * allocate_Expl_GenomeWise9(GenomeEvidenceSet* evi,ComplexSequence* gen ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon,DPRunImpl * dpri) { GenomeWise9 * out; out = allocate_GenomeWise9_only(evi, gen , switchcost, newgenecost, non_start_codon, non_stop_codon, rndcodon); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+10)*10 && dpri->cache->maxlenj >= (out->leni+0)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+10)*10,(out->leni+0),8,out->lenj+10)) == NULL) { warn("Explicit matrix GenomeWise9 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_GenomeWise9(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_GenomeWise9(out); return out; } /* Function: init_GenomeWise9(mat) * * Descrip: This function initates GenomeWise9 matrix when in explicit mode * Called in /allocate_Expl_GenomeWise9 * * * Arg: mat [UNKN ] GenomeWise9 which contains explicit basematrix memory [GenomeWise9 *] * */ void init_GenomeWise9(GenomeWise9 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-0);ievi->len;i++) { for(j= (-10);j<11;j++) { GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,START_CODON) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_0) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_1) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_2) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,STOP_CODON) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; } } for(j= (-10);jgen->seq->len;j++) { for(i= (-0);i<1;i++) { GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,START_CODON) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_0) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_1) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_2) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,STOP_CODON) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; } GenomeWise9_EXPL_SPECIAL(mat,i,j,PREGENE_INTERGENIC) = NEGI; GenomeWise9_EXPL_SPECIAL(mat,i,j,POSTGENE_INTERGENIC) = NEGI; GenomeWise9_EXPL_SPECIAL(mat,i,j,INTERGENIC) = NEGI; GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_UTR5) = NEGI; GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_UTR3) = NEGI; GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_CDS) = NEGI; GenomeWise9_EXPL_SPECIAL(mat,i,j,START) = 0; GenomeWise9_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_GenomeWise9(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GenomeWise9 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * */ void recalculate_PackAln_GenomeWise9(PackAln * pal,GenomeWise9 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case UTR5 : if( offi == 0 && offj == 1 && prev->state == UTR5 ) { pau->score = GNE_UTR(mat->evi,i,mat->gen,j) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UTR5_INTRON ) { pau->score = GNE_UTR_3SS(mat->evi,i,mat->gen,j) + (0); continue; } if( offj == 1 && prev->state == (SPECIAL_UTR5+10) ) { pau->score = GNE_UTR(mat->evi,i,mat->gen,j) + (0); continue; } if( offj == 1 && prev->state == (START+10) ) { pau->score = GNE_UTR5_START(mat->evi,i,mat->gen,j) + (0); continue; } if( offj == 1 && prev->state == (INTERGENIC+10) ) { pau->score = (GNE_UTR(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j)) + (0); continue; } if( offj == 1 && prev->state == (PREGENE_INTERGENIC+10) ) { pau->score = GNE_UTR(mat->evi,i,mat->gen,j) + (0); continue; } warn("In recaluclating PackAln with state UTR5, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UTR5_INTRON : if( offi == 0 && offj == 1 && prev->state == UTR5_INTRON ) { pau->score = GNE_UTR_INTRON(mat->evi,i,mat->gen,j) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UTR5 ) { pau->score = GNE_UTR_5SS(mat->evi,i,mat->gen,j) + (0); continue; } warn("In recaluclating PackAln with state UTR5_INTRON, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case START_CODON : if( offi == 0 && offj == 3 && prev->state == UTR5_INTRON ) { pau->score = GNE_START_CODON(mat->evi,i,mat->gen,j) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == UTR5 ) { pau->score = GNE_START_CODON(mat->evi,i,mat->gen,j) + (0); continue; } warn("In recaluclating PackAln with state START_CODON, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CDS : if( offi == 0 && offj == 3 && prev->state == CDS ) { pau->score = GNE_CDS(mat->evi,i,mat->gen,j) + (0); continue; } if( offi == 0 && offj == 6 && prev->state == CDS_INTRON_0 ) { pau->score = GNE_CDS_3SS(mat->evi,i,mat->gen,(j-3),0) + (0); continue; } if( offi == 0 && offj == 5 && prev->state == CDS_INTRON_1 ) { pau->score = GNE_CDS_3SS(mat->evi,i,mat->gen,(j-2),1) + (0); continue; } if( offi == 0 && offj == 4 && prev->state == CDS_INTRON_2 ) { pau->score = GNE_CDS_3SS(mat->evi,i,mat->gen,(j-1),2) + (0); continue; } if( offi == 0 && offj == 2 && prev->state == CDS ) { pau->score = GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,2) + (0); continue; } if( offi == 0 && offj == 4 && prev->state == CDS ) { pau->score = GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,4) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == UTR5 ) { pau->score = (GNE_CDS(mat->evi,i,mat->gen,j)+mat->non_start_codon) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == START_CODON ) { pau->score = GNE_CDS(mat->evi,i,mat->gen,j) + (0); continue; } if( offj == 3 && prev->state == (SPECIAL_CDS+10) ) { pau->score = GNE_CDS(mat->evi,i,mat->gen,j) + (0); continue; } if( offj == 3 && prev->state == (INTERGENIC+10) ) { pau->score = (GNE_CDS(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j)) + (0); continue; } warn("In recaluclating PackAln with state CDS, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CDS_INTRON_0 : if( offi == 0 && offj == 1 && prev->state == CDS_INTRON_0 ) { pau->score = GNE_CDS_INTRON(mat->evi,i,mat->gen,j) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == CDS ) { pau->score = GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),0) + (0); continue; } warn("In recaluclating PackAln with state CDS_INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CDS_INTRON_1 : if( offi == 0 && offj == 1 && prev->state == CDS_INTRON_1 ) { pau->score = GNE_CDS_INTRON(mat->evi,i,mat->gen,j) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == CDS ) { pau->score = GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),1) + (0); continue; } warn("In recaluclating PackAln with state CDS_INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case CDS_INTRON_2 : if( offi == 0 && offj == 1 && prev->state == CDS_INTRON_2 ) { pau->score = GNE_CDS_INTRON(mat->evi,i,mat->gen,j) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == CDS ) { pau->score = GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),2) + (0); continue; } warn("In recaluclating PackAln with state CDS_INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case STOP_CODON : if( offi == 0 && offj == 3 && prev->state == CDS ) { pau->score = GNE_STOP_CODON(mat->evi,i,mat->gen,j) + (0); continue; } warn("In recaluclating PackAln with state STOP_CODON, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UTR3 : if( offi == 0 && offj == 1 && prev->state == UTR3 ) { pau->score = GNE_UTR(mat->evi,i,mat->gen,j) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == CDS ) { pau->score = (GNE_UTR(mat->evi,i,mat->gen,j)+mat->non_stop_codon) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == STOP_CODON ) { pau->score = GNE_UTR(mat->evi,i,mat->gen,j) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UTR3_INTRON ) { pau->score = GNE_UTR_3SS(mat->evi,i,mat->gen,j) + (0); continue; } if( offj == 1 && prev->state == (INTERGENIC+10) ) { pau->score = GNE_UTR(mat->evi,i,mat->gen,j) + (0); continue; } warn("In recaluclating PackAln with state UTR3, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UTR3_INTRON : if( offi == 0 && offj == 1 && prev->state == UTR3_INTRON ) { pau->score = GNE_UTR_INTRON(mat->evi,i,mat->gen,j) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UTR3 ) { pau->score = GNE_UTR_5SS(mat->evi,i,mat->gen,j) + (0); continue; } if( offj == 1 && prev->state == (SPECIAL_UTR3+10) ) { pau->score = GNE_UTR(mat->evi,i,mat->gen,j) + (0); continue; } warn("In recaluclating PackAln with state UTR3_INTRON, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (PREGENE_INTERGENIC+10) : if( offj == 1 && prev->state == (START+10) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state PREGENE_INTERGENIC, got a bad source state. Error!"); break; case (POSTGENE_INTERGENIC+10) : if( offj == 0 && prev->state == UTR3 ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = (mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j)) + (0); continue; } warn("In recaluclating PackAln with state POSTGENE_INTERGENIC, got a bad source state. Error!"); break; case (INTERGENIC+10) : if( offj == 1 && prev->state == (INTERGENIC+10) ) { pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == CDS ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = (mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j)) + (0); continue; } if( offj == 0 && prev->state == UTR3 ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = (mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j)) + (0); continue; } warn("In recaluclating PackAln with state INTERGENIC, got a bad source state. Error!"); break; case (SPECIAL_UTR5+10) : if( offj == 0 && prev->state == UTR5 ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->switchcost + (0); continue; } warn("In recaluclating PackAln with state SPECIAL_UTR5, got a bad source state. Error!"); break; case (SPECIAL_UTR3+10) : if( offj == 0 && prev->state == UTR3 ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->switchcost + (0); continue; } warn("In recaluclating PackAln with state SPECIAL_UTR3, got a bad source state. Error!"); break; case (SPECIAL_CDS+10) : if( offj == 0 && prev->state == CDS ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = (mat->switchcost+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)]) + (0); continue; } if( offj == 3 && prev->state == (SPECIAL_CDS+10) ) { pau->score = mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)] + (0); continue; } warn("In recaluclating PackAln with state SPECIAL_CDS, got a bad source state. Error!"); break; case (START+10) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+10) : if( offj == 1 && prev->state == (INTERGENIC+10) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define GenomeWise9_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+10)][(i+0)*10+state]) #define GenomeWise9_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+11)*8) % 88][(i+0)*10+state]) #define GenomeWise9_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+10)]) #define GenomeWise9_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) #define GenomeWise9_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+11)*8)+(shadow+1)) % 88)][(i+0)*10 + state]) #define GenomeWise9_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) #define GenomeWise9_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+10)% 10) * (leni+1) * 10) + ((i+0) * 10) + (state)]) #define GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+10)% 10) * (leni+1) * 80) + ((i+0) * 80) + (state * 8) + shadow+1]) #define GenomeWise9_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) /* Function: allocate_Small_GenomeWise9(evi,gen,switchcost,newgenecost,non_start_codon,non_stop_codon,rndcodon) * * Descrip: This function allocates the GenomeWise9 structure * and the basematrix area for a small memory implementations * It calls /allocate_GenomeWise9_only * * * Arg: evi [UNKN ] query data structure [GenomeEvidenceSet*] * Arg: gen [UNKN ] target data structure [ComplexSequence*] * Arg: switchcost [UNKN ] Resource [int] * Arg: newgenecost [UNKN ] Resource [int] * Arg: non_start_codon [UNKN ] Resource [int] * Arg: non_stop_codon [UNKN ] Resource [int] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * * Return [UNKN ] Undocumented return value [GenomeWise9 *] * */ #define GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) GenomeWise9 * allocate_Small_GenomeWise9(GenomeEvidenceSet* evi,ComplexSequence* gen ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon) { GenomeWise9 * out; out = allocate_GenomeWise9_only(evi, gen , switchcost, newgenecost, non_start_codon, non_stop_codon, rndcodon); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(88,(out->leni + 0) * 10,64,out->lenj+10); if(out == NULL) { warn("Small shadow matrix GenomeWise9 cannot be allocated, (asking for 11 by %d main cells)",out->leni+1); free_GenomeWise9(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_GenomeWise9(mat,dpenv) * * Descrip: This function calculates an alignment for GenomeWise9 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GenomeWise9 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GenomeWise9 * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_GenomeWise9(GenomeWise9 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for GenomeWise9 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_GenomeWise9(mat,dpenv); score = start_end_find_end_GenomeWise9(mat,&endj); out->score = score; stopstate = END; /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */ log_full_error(REPORT,0,"End at %d Score %d",endj,score); stop_reporting(); for(;;) { /*while there are more special bits to recover*/ start_reporting("Special cell aln end %d:",endj); if( read_special_strip_GenomeWise9(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) { warn("Problem in reading off special state system... going to return partial alignment"); break; } if( startstate == START || endj <= 0) { log_full_error(REPORT,0,"Recovered complete alignment"); stop_reporting(); break; } log_full_error(REPORT,0,"Finished to %d",endj); stop_reporting(); /* Ok... have to eat up another piece of matrix */ temp = startstate; starti = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0); startj = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1); startstate = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2); stopi = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3); stopj = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4); stopstate = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5); /* Get out the score of this block. V. important! */ temp = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6); totalj = stopj - startj; donej = 0; start_reporting("Main matrix aln [%d,%d]:",startj,stopj); if(full_dc_GenomeWise9(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) { warn("In the alignment GenomeWise9 [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj); return out; } /* now have to figure out which special we came from... yikes */ max_matrix_to_special_GenomeWise9(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == GenomeWise9_READ_OFF_ERROR) { warn("In GenomeWise9 read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj); invert_PackAln(out); recalculate_PackAln_GenomeWise9(out,mat); return out; } /* if at start, break, otherwise, back to eat another strip */ if( stopstate == START) { log_full_error(REPORT,0,"Recovered complete alignment "); stop_reporting(); break; } log_full_error(REPORT,0,"Finished alignment to %d ",startj); stop_reporting(); endj = stopj; /* stopstate is correct as it is */ } /* end of while there are more special bits to recover */ invert_PackAln(out); recalculate_PackAln_GenomeWise9(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_GenomeWise9(mat) * * Descrip: This function calculates an alignment for GenomeWise9 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GenomeWise9 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GenomeWise9 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GenomeWise9 * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_GenomeWise9(GenomeWise9 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_GenomeWise9(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_GenomeWise9(mat); return out; } /* Function: AlnRangeSet_from_GenomeWise9(mat) * * Descrip: This function reads off a start/end structure * for GenomeWise9 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GenomeWise9 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GenomeWise9 * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_GenomeWise9(GenomeWise9 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GenomeWise9"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_GenomeWise9(mat,&jpos); state = END; while( (temp = AlnRange_build_GenomeWise9(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_GenomeWise9(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_GenomeWise9 * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_GenomeWise9(GenomeWise9 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GenomeWise9"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_GenomeWise9(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_GenomeWise9 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = GenomeWise9_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_GenomeWise9(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == GenomeWise9_READ_OFF_ERROR) { warn("In AlnRange_build_GenomeWise9 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = GenomeWise9_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_GenomeWise9(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_GenomeWise9(GenomeWise9 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_GenomeWise9(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GenomeWise9_READ_OFF_ERROR) { warn("In GenomeWise9 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In GenomeWise9 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In GenomeWise9 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_GenomeWise9(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_GenomeWise9(GenomeWise9 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GenomeWise9_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->evi->len || j > mat->gen->seq->len) { warn("In GenomeWise9 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = GenomeWise9_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case UTR5 : /* Not allowing special sources.. skipping PREGENE_INTERGENIC */ /* Not allowing special sources.. skipping INTERGENIC */ /* Not allowing special sources.. skipping START */ /* Not allowing special sources.. skipping SPECIAL_UTR5 */ temp = cscore - (GNE_UTR_3SS(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5_INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR5_INTRON); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5_INTRON); } temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR5); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR5_INTRON : temp = cscore - (GNE_UTR_5SS(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR5); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5); } temp = cscore - (GNE_UTR_INTRON(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5_INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR5_INTRON); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR5_INTRON); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case START_CODON : temp = cscore - (GNE_START_CODON(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 3,UTR5) ) { *reti = i - 0; *retj = j - 3; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-3,UTR5); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 3,UTR5); } temp = cscore - (GNE_START_CODON(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 3,UTR5_INTRON) ) { *reti = i - 0; *retj = j - 3; *retstate = UTR5_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-3,UTR5_INTRON); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 3,UTR5_INTRON); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CDS : /* Not allowing special sources.. skipping INTERGENIC */ /* Not allowing special sources.. skipping SPECIAL_CDS */ temp = cscore - (GNE_CDS(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 3,START_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = START_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-3,START_CODON); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 3,START_CODON); } temp = cscore - ((GNE_CDS(mat->evi,i,mat->gen,j)+mat->non_start_codon)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 3,UTR5) ) { *reti = i - 0; *retj = j - 3; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-3,UTR5); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 3,UTR5); } temp = cscore - (GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,4)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 4,CDS) ) { *reti = i - 0; *retj = j - 4; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-4,CDS); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 4,CDS); } temp = cscore - (GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,2)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 2,CDS) ) { *reti = i - 0; *retj = j - 2; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-2,CDS); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 2,CDS); } temp = cscore - (GNE_CDS_3SS(mat->evi,i,mat->gen,(j-1),2)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 4,CDS_INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = CDS_INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-4,CDS_INTRON_2); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 4,CDS_INTRON_2); } temp = cscore - (GNE_CDS_3SS(mat->evi,i,mat->gen,(j-2),1)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 5,CDS_INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = CDS_INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-5,CDS_INTRON_1); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 5,CDS_INTRON_1); } temp = cscore - (GNE_CDS_3SS(mat->evi,i,mat->gen,(j-3),0)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 6,CDS_INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = CDS_INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-6,CDS_INTRON_0); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 6,CDS_INTRON_0); } temp = cscore - (GNE_CDS(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 3,CDS) ) { *reti = i - 0; *retj = j - 3; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-3,CDS); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 3,CDS); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CDS_INTRON_0 : temp = cscore - (GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),0)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 8,CDS) ) { *reti = i - 0; *retj = j - 8; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-8,CDS); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 8,CDS); } temp = cscore - (GNE_CDS_INTRON(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,CDS_INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = CDS_INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,CDS_INTRON_0); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,CDS_INTRON_0); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CDS_INTRON_1 : temp = cscore - (GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),1)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 9,CDS) ) { *reti = i - 0; *retj = j - 9; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-9,CDS); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 9,CDS); } temp = cscore - (GNE_CDS_INTRON(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,CDS_INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = CDS_INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,CDS_INTRON_1); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,CDS_INTRON_1); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CDS_INTRON_2 : temp = cscore - (GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),2)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 10,CDS) ) { *reti = i - 0; *retj = j - 10; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-10,CDS); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 10,CDS); } temp = cscore - (GNE_CDS_INTRON(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,CDS_INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = CDS_INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,CDS_INTRON_2); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,CDS_INTRON_2); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case STOP_CODON : temp = cscore - (GNE_STOP_CODON(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 3,CDS) ) { *reti = i - 0; *retj = j - 3; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-3,CDS); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 3,CDS); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR3 : /* Not allowing special sources.. skipping INTERGENIC */ temp = cscore - (GNE_UTR_3SS(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3_INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR3_INTRON); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3_INTRON); } temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,STOP_CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = STOP_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,STOP_CODON); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,STOP_CODON); } temp = cscore - ((GNE_UTR(mat->evi,i,mat->gen,j)+mat->non_stop_codon)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,CDS) ) { *reti = i - 0; *retj = j - 1; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,CDS); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,CDS); } temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR3); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR3_INTRON : /* Not allowing special sources.. skipping SPECIAL_UTR3 */ temp = cscore - (GNE_UTR_5SS(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR3); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3); } temp = cscore - (GNE_UTR_INTRON(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3_INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR3_INTRON); } return GenomeWise9_HIDDEN_MATRIX(mat,i - 0,j - 1,UTR3_INTRON); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_GenomeWise9(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_GenomeWise9(GenomeWise9 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 10; add_PackAln(out,pau); } max_special_strip_GenomeWise9(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GenomeWise9_READ_OFF_ERROR) { warn("In special strip read GenomeWise9, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read GenomeWise9, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 10; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_GenomeWise9(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_GenomeWise9(GenomeWise9 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = GenomeWise9_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for GenomeWise9, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->gen->seq->len) { warn("In GenomeWise9 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = GenomeWise9_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case PREGENE_INTERGENIC : /* source START is a special */ temp = cscore - (0) - (0); if( temp == GenomeWise9_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return GenomeWise9_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } case POSTGENE_INTERGENIC : /* Source UTR3 is not a special */ case INTERGENIC : /* Source UTR3 is not a special */ /* Source CDS is not a special */ /* source INTERGENIC is a special */ temp = cscore - (0) - (0); if( temp == GenomeWise9_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_DC_SHADOW_SPECIAL(mat,i-0,j-1,INTERGENIC); } return GenomeWise9_DC_SHADOW_MATRIX(mat,i - 0,j - 1,INTERGENIC) ; } case SPECIAL_UTR5 : /* Source UTR5 is not a special */ case SPECIAL_UTR3 : /* Source UTR3 is not a special */ case SPECIAL_CDS : /* source SPECIAL_CDS is a special */ temp = cscore - (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)]) - (0); if( temp == GenomeWise9_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,SPECIAL_CDS) ) { *reti = i - 0; *retj = j - 3; *retstate = SPECIAL_CDS; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_DC_SHADOW_SPECIAL(mat,i-0,j-3,SPECIAL_CDS); } return GenomeWise9_DC_SHADOW_MATRIX(mat,i - 0,j - 3,SPECIAL_CDS) ; } /* Source CDS is not a special */ case START : case END : /* source INTERGENIC is a special */ temp = cscore - (0) - (0); if( temp == GenomeWise9_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_DC_SHADOW_SPECIAL(mat,i-0,j-1,INTERGENIC); } return GenomeWise9_DC_SHADOW_MATRIX(mat,i - 0,j - 1,INTERGENIC) ; } default: warn("Major problem (!) - in GenomeWise9 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_GenomeWise9(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_GenomeWise9(GenomeWise9 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = GenomeWise9_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In GenomeWise9 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case UTR5 : temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,PREGENE_INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = PREGENE_INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_DC_SHADOW_SPECIAL(mat,i-0,j-1,PREGENE_INTERGENIC); } return GenomeWise9_DC_SHADOW_MATRIX(mat,i - 0,j - 1,PREGENE_INTERGENIC) ; } temp = cscore - ((GNE_UTR(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j))) - (0); if( temp == GenomeWise9_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_DC_SHADOW_SPECIAL(mat,i-0,j-1,INTERGENIC); } return GenomeWise9_DC_SHADOW_MATRIX(mat,i - 0,j - 1,INTERGENIC) ; } temp = cscore - (GNE_UTR5_START(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return GenomeWise9_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,SPECIAL_UTR5) ) { *reti = i - 0; *retj = j - 1; *retstate = SPECIAL_UTR5; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_DC_SHADOW_SPECIAL(mat,i-0,j-1,SPECIAL_UTR5); } return GenomeWise9_DC_SHADOW_MATRIX(mat,i - 0,j - 1,SPECIAL_UTR5) ; } /* Source UTR5_INTRON is not a special, should not get here! */ /* Source UTR5 is not a special, should not get here! */ warn("Major problem (!) - in GenomeWise9 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR5_INTRON : /* Source UTR5 is not a special, should not get here! */ /* Source UTR5_INTRON is not a special, should not get here! */ warn("Major problem (!) - in GenomeWise9 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case START_CODON : /* Source UTR5 is not a special, should not get here! */ /* Source UTR5_INTRON is not a special, should not get here! */ warn("Major problem (!) - in GenomeWise9 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CDS : temp = cscore - ((GNE_CDS(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j))) - (0); if( temp == GenomeWise9_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,INTERGENIC) ) { *reti = i - 0; *retj = j - 3; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_DC_SHADOW_SPECIAL(mat,i-0,j-3,INTERGENIC); } return GenomeWise9_DC_SHADOW_MATRIX(mat,i - 0,j - 3,INTERGENIC) ; } temp = cscore - (GNE_CDS(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,SPECIAL_CDS) ) { *reti = i - 0; *retj = j - 3; *retstate = SPECIAL_CDS; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_DC_SHADOW_SPECIAL(mat,i-0,j-3,SPECIAL_CDS); } return GenomeWise9_DC_SHADOW_MATRIX(mat,i - 0,j - 3,SPECIAL_CDS) ; } /* Source START_CODON is not a special, should not get here! */ /* Source UTR5 is not a special, should not get here! */ /* Source CDS is not a special, should not get here! */ /* Source CDS is not a special, should not get here! */ /* Source CDS_INTRON_2 is not a special, should not get here! */ /* Source CDS_INTRON_1 is not a special, should not get here! */ /* Source CDS_INTRON_0 is not a special, should not get here! */ /* Source CDS is not a special, should not get here! */ warn("Major problem (!) - in GenomeWise9 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CDS_INTRON_0 : /* Source CDS is not a special, should not get here! */ /* Source CDS_INTRON_0 is not a special, should not get here! */ warn("Major problem (!) - in GenomeWise9 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CDS_INTRON_1 : /* Source CDS is not a special, should not get here! */ /* Source CDS_INTRON_1 is not a special, should not get here! */ warn("Major problem (!) - in GenomeWise9 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CDS_INTRON_2 : /* Source CDS is not a special, should not get here! */ /* Source CDS_INTRON_2 is not a special, should not get here! */ warn("Major problem (!) - in GenomeWise9 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case STOP_CODON : /* Source CDS is not a special, should not get here! */ warn("Major problem (!) - in GenomeWise9 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR3 : temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_DC_SHADOW_SPECIAL(mat,i-0,j-1,INTERGENIC); } return GenomeWise9_DC_SHADOW_MATRIX(mat,i - 0,j - 1,INTERGENIC) ; } /* Source UTR3_INTRON is not a special, should not get here! */ /* Source STOP_CODON is not a special, should not get here! */ /* Source CDS is not a special, should not get here! */ /* Source UTR3 is not a special, should not get here! */ warn("Major problem (!) - in GenomeWise9 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR3_INTRON : temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == GenomeWise9_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,SPECIAL_UTR3) ) { *reti = i - 0; *retj = j - 1; *retstate = SPECIAL_UTR3; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenomeWise9_DC_SHADOW_SPECIAL(mat,i-0,j-1,SPECIAL_UTR3); } return GenomeWise9_DC_SHADOW_MATRIX(mat,i - 0,j - 1,SPECIAL_UTR3) ; } /* Source UTR3 is not a special, should not get here! */ /* Source UTR3_INTRON is not a special, should not get here! */ warn("Major problem (!) - in GenomeWise9 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_GenomeWise9(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_GenomeWise9(GenomeWise9 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_GenomeWise9(mat,starti,startj,stopi,stopj); GenomeWise9_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GenomeWise9_HIDDEN_MATRIX(mat,i,j,UTR5) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,START_CODON) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,CDS) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,CDS_INTRON_0) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,CDS_INTRON_1) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,CDS_INTRON_2) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,STOP_CODON) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,UTR3) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; continue; } /* end of Is not in envelope */ /* For state UTR5 */ /* setting first movement to score */ score = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR(mat->evi,i,mat->gen,j); /* From state UTR5_INTRON to state UTR5 */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ GenomeWise9_HIDDEN_MATRIX(mat,i,j,UTR5) = score; /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* From state UTR5 to state UTR5_INTRON */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ GenomeWise9_HIDDEN_MATRIX(mat,i,j,UTR5_INTRON) = score; /* Finished calculating state UTR5_INTRON */ /* For state START_CODON */ /* setting first movement to score */ score = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-3,UTR5_INTRON) + GNE_START_CODON(mat->evi,i,mat->gen,j); /* From state UTR5 to state START_CODON */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-3,UTR5) + GNE_START_CODON(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for START_CODON */ /* Add any movement independant score and put away */ GenomeWise9_HIDDEN_MATRIX(mat,i,j,START_CODON) = score; /* Finished calculating state START_CODON */ /* For state CDS */ /* setting first movement to score */ score = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-3,CDS) + GNE_CDS(mat->evi,i,mat->gen,j); /* From state CDS_INTRON_0 to state CDS */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-6,CDS_INTRON_0) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-3),0); if( temp > score ) { score = temp; } /* From state CDS_INTRON_1 to state CDS */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-5,CDS_INTRON_1) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-2),1); if( temp > score ) { score = temp; } /* From state CDS_INTRON_2 to state CDS */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-4,CDS_INTRON_2) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-1),2); if( temp > score ) { score = temp; } /* From state CDS to state CDS */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-2,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,2); if( temp > score ) { score = temp; } /* From state CDS to state CDS */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-4,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,4); if( temp > score ) { score = temp; } /* From state UTR5 to state CDS */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-3,UTR5) + (GNE_CDS(mat->evi,i,mat->gen,j)+mat->non_start_codon); if( temp > score ) { score = temp; } /* From state START_CODON to state CDS */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-3,START_CODON) + GNE_CDS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS */ /* Add any movement independant score and put away */ GenomeWise9_HIDDEN_MATRIX(mat,i,j,CDS) = score; /* Finished calculating state CDS */ /* For state CDS_INTRON_0 */ /* setting first movement to score */ score = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,CDS_INTRON_0) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_0 */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-8,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),0); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_0 */ /* Add any movement independant score and put away */ GenomeWise9_HIDDEN_MATRIX(mat,i,j,CDS_INTRON_0) = score; /* Finished calculating state CDS_INTRON_0 */ /* For state CDS_INTRON_1 */ /* setting first movement to score */ score = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,CDS_INTRON_1) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_1 */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-9,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),1); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_1 */ /* Add any movement independant score and put away */ GenomeWise9_HIDDEN_MATRIX(mat,i,j,CDS_INTRON_1) = score; /* Finished calculating state CDS_INTRON_1 */ /* For state CDS_INTRON_2 */ /* setting first movement to score */ score = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,CDS_INTRON_2) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_2 */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-10,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),2); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_2 */ /* Add any movement independant score and put away */ GenomeWise9_HIDDEN_MATRIX(mat,i,j,CDS_INTRON_2) = score; /* Finished calculating state CDS_INTRON_2 */ /* For state STOP_CODON */ /* setting first movement to score */ score = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-3,CDS) + GNE_STOP_CODON(mat->evi,i,mat->gen,j); /* Ok - finished max calculation for STOP_CODON */ /* Add any movement independant score and put away */ GenomeWise9_HIDDEN_MATRIX(mat,i,j,STOP_CODON) = score; /* Finished calculating state STOP_CODON */ /* For state UTR3 */ /* setting first movement to score */ score = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR(mat->evi,i,mat->gen,j); /* From state CDS to state UTR3 */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,CDS) + (GNE_UTR(mat->evi,i,mat->gen,j)+mat->non_stop_codon); if( temp > score ) { score = temp; } /* From state STOP_CODON to state UTR3 */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,STOP_CODON) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state UTR3_INTRON to state UTR3 */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ GenomeWise9_HIDDEN_MATRIX(mat,i,j,UTR3) = score; /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* From state UTR3 to state UTR3_INTRON */ temp = GenomeWise9_HIDDEN_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ GenomeWise9_HIDDEN_MATRIX(mat,i,j,UTR3_INTRON) = score; /* Finished calculating state UTR3_INTRON */ } } return; } /* Function: init_hidden_GenomeWise9(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_GenomeWise9(GenomeWise9 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-10);j<=stopj;j++) { for(i=(starti-0);i<=stopi;i++) { GenomeWise9_HIDDEN_MATRIX(mat,i,j,UTR5) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,START_CODON) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,CDS) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,CDS_INTRON_0) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,CDS_INTRON_1) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,CDS_INTRON_2) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,STOP_CODON) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,UTR3) = NEGI; GenomeWise9_HIDDEN_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; } } return; } /* Function: full_dc_GenomeWise9(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_GenomeWise9 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_GenomeWise9 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [GenomeWise9 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_GenomeWise9(GenomeWise9 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_GenomeWise9"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 50) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_GenomeWise9(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_GenomeWise9(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_GenomeWise9(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for GenomeWise9, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= GenomeWise9_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= GenomeWise9_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_GenomeWise9(mat,GenomeWise9_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),GenomeWise9_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),GenomeWise9_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_GenomeWise9(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_GenomeWise9(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_GenomeWise9(GenomeWise9 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_GenomeWise9(mat); GenomeWise9_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_GenomeWise9(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_GenomeWise9(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_GenomeWise9(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_GenomeWise9(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_GenomeWise9(GenomeWise9 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<10;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,0) = (-100); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,1) = (-100); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,0) = (-100); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,1) = (-100); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,START_CODON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,0) = (-100); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,1) = (-100); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,0) = (-100); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,1) = (-100); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_0) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,0) = (-100); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,1) = (-100); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_1) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,0) = (-100); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,1) = (-100); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_2) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,0) = (-100); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,1) = (-100); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,STOP_CODON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,STOP_CODON,0) = (-100); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,STOP_CODON,1) = (-100); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,0) = (-100); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,1) = (-100); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,0) = (-100); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,1) = (-100); continue; } /* end of Is not in envelope */ /* For state UTR5, pushing when j - offj <= mergej */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR(mat->evi,i,mat->gen,j); if( j - 1 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,1) = j-1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,2) = UTR5; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,5) = UTR5; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5,k); } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score) { score = temp; if( j - 1 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,1) = j-1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,2) = UTR5_INTRON; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,5) = UTR5; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5_INTRON,k); } } /* Add any movement independant score */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5) = score; /* Finished with state UTR5 */ /* For state UTR5_INTRON, pushing when j - offj <= mergej */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); if( j - 1 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,1) = j-1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,2) = UTR5_INTRON; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,5) = UTR5_INTRON; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5_INTRON,k); } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score) { score = temp; if( j - 1 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,1) = j-1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,2) = UTR5; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,5) = UTR5_INTRON; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5,k); } } /* Add any movement independant score */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = score; /* Finished with state UTR5_INTRON */ /* For state START_CODON, pushing when j - offj <= mergej */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,UTR5_INTRON) + GNE_START_CODON(mat->evi,i,mat->gen,j); if( j - 3 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,1) = j-3; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,2) = UTR5_INTRON; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,5) = START_CODON; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,UTR5_INTRON,k); } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,UTR5) + GNE_START_CODON(mat->evi,i,mat->gen,j); if( temp > score) { score = temp; if( j - 3 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,1) = j-3; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,2) = UTR5; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,5) = START_CODON; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,UTR5,k); } } /* Add any movement independant score */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,START_CODON) = score; /* Finished with state START_CODON */ /* For state CDS, pushing when j - offj <= mergej */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,CDS) + GNE_CDS(mat->evi,i,mat->gen,j); if( j - 3 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,1) = j-3; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,2) = CDS; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,5) = CDS; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CDS,k); } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-6,CDS_INTRON_0) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-3),0); if( temp > score) { score = temp; if( j - 6 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,1) = j-6; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,2) = CDS_INTRON_0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,5) = CDS; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,CDS_INTRON_0,k); } } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-5,CDS_INTRON_1) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-2),1); if( temp > score) { score = temp; if( j - 5 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,1) = j-5; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,2) = CDS_INTRON_1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,5) = CDS; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,CDS_INTRON_1,k); } } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-4,CDS_INTRON_2) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-1),2); if( temp > score) { score = temp; if( j - 4 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,1) = j-4; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,2) = CDS_INTRON_2; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,5) = CDS; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,CDS_INTRON_2,k); } } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-2,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,2); if( temp > score) { score = temp; if( j - 2 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,1) = j-2; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,2) = CDS; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,5) = CDS; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,CDS,k); } } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-4,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,4); if( temp > score) { score = temp; if( j - 4 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,1) = j-4; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,2) = CDS; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,5) = CDS; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,CDS,k); } } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,UTR5) + (GNE_CDS(mat->evi,i,mat->gen,j)+mat->non_start_codon); if( temp > score) { score = temp; if( j - 3 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,1) = j-3; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,2) = UTR5; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,5) = CDS; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,UTR5,k); } } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,START_CODON) + GNE_CDS(mat->evi,i,mat->gen,j); if( temp > score) { score = temp; if( j - 3 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,1) = j-3; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,2) = START_CODON; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,5) = CDS; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,START_CODON,k); } } /* Add any movement independant score */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS) = score; /* Finished with state CDS */ /* For state CDS_INTRON_0, pushing when j - offj <= mergej */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,CDS_INTRON_0) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); if( j - 1 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,1) = j-1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,2) = CDS_INTRON_0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,5) = CDS_INTRON_0; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CDS_INTRON_0,k); } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-8,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),0); if( temp > score) { score = temp; if( j - 8 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,1) = j-8; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,2) = CDS; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,5) = CDS_INTRON_0; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,CDS,k); } } /* Add any movement independant score */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_0) = score; /* Finished with state CDS_INTRON_0 */ /* For state CDS_INTRON_1, pushing when j - offj <= mergej */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,CDS_INTRON_1) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); if( j - 1 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,1) = j-1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,2) = CDS_INTRON_1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,5) = CDS_INTRON_1; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CDS_INTRON_1,k); } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-9,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),1); if( temp > score) { score = temp; if( j - 9 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,1) = j-9; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,2) = CDS; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,5) = CDS_INTRON_1; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,CDS,k); } } /* Add any movement independant score */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_1) = score; /* Finished with state CDS_INTRON_1 */ /* For state CDS_INTRON_2, pushing when j - offj <= mergej */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,CDS_INTRON_2) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); if( j - 1 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,1) = j-1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,2) = CDS_INTRON_2; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,5) = CDS_INTRON_2; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CDS_INTRON_2,k); } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-10,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),2); if( temp > score) { score = temp; if( j - 10 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,1) = j-10; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,2) = CDS; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,5) = CDS_INTRON_2; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,CDS,k); } } /* Add any movement independant score */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_2) = score; /* Finished with state CDS_INTRON_2 */ /* For state STOP_CODON, pushing when j - offj <= mergej */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,CDS) + GNE_STOP_CODON(mat->evi,i,mat->gen,j); if( j - 3 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,STOP_CODON,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,STOP_CODON,1) = j-3; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,STOP_CODON,2) = CDS; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,STOP_CODON,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,STOP_CODON,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,STOP_CODON,5) = STOP_CODON; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,STOP_CODON,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CDS,k); } /* Add any movement independant score */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,STOP_CODON) = score; /* Finished with state STOP_CODON */ /* For state UTR3, pushing when j - offj <= mergej */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR(mat->evi,i,mat->gen,j); if( j - 1 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,1) = j-1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,2) = UTR3; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,5) = UTR3; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3,k); } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,CDS) + (GNE_UTR(mat->evi,i,mat->gen,j)+mat->non_stop_codon); if( temp > score) { score = temp; if( j - 1 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,1) = j-1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,2) = CDS; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,5) = UTR3; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CDS,k); } } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,STOP_CODON) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score) { score = temp; if( j - 1 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,1) = j-1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,2) = STOP_CODON; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,5) = UTR3; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,STOP_CODON,k); } } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score) { score = temp; if( j - 1 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,1) = j-1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,2) = UTR3_INTRON; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,5) = UTR3; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3_INTRON,k); } } /* Add any movement independant score */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3) = score; /* Finished with state UTR3 */ /* For state UTR3_INTRON, pushing when j - offj <= mergej */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); if( j - 1 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,1) = j-1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,2) = UTR3_INTRON; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,5) = UTR3_INTRON; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3_INTRON,k); } temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score) { score = temp; if( j - 1 <= mergej) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,0) = i-0; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,1) = j-1; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,2) = UTR3; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,3) = i; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,4) = j; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,5) = UTR3_INTRON; } else { for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,k) = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3,k); } } /* Add any movement independant score */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = score; /* Finished with state UTR3_INTRON */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_GenomeWise9(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_GenomeWise9(GenomeWise9 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,START_CODON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_0) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_1) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_2) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,STOP_CODON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state UTR5 */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR(mat->evi,i,mat->gen,j); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5,k); /* From state UTR5_INTRON to state UTR5 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5_INTRON,k); } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5) = score; for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5_INTRON,k); /* From state UTR5 to state UTR5_INTRON */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5,k); } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = score; for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UTR5_INTRON */ /* For state START_CODON */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,UTR5_INTRON) + GNE_START_CODON(mat->evi,i,mat->gen,j); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,UTR5_INTRON,k); /* From state UTR5 to state START_CODON */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,UTR5) + GNE_START_CODON(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,UTR5,k); } /* Ok - finished max calculation for START_CODON */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,START_CODON) = score; for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state START_CODON */ /* For state CDS */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,CDS) + GNE_CDS(mat->evi,i,mat->gen,j); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CDS,k); /* From state CDS_INTRON_0 to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-6,CDS_INTRON_0) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-3),0); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,CDS_INTRON_0,k); } /* From state CDS_INTRON_1 to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-5,CDS_INTRON_1) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-2),1); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,CDS_INTRON_1,k); } /* From state CDS_INTRON_2 to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-4,CDS_INTRON_2) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-1),2); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,CDS_INTRON_2,k); } /* From state CDS to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-2,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,2); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,CDS,k); } /* From state CDS to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-4,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,4); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,CDS,k); } /* From state UTR5 to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,UTR5) + (GNE_CDS(mat->evi,i,mat->gen,j)+mat->non_start_codon); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,UTR5,k); } /* From state START_CODON to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,START_CODON) + GNE_CDS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,START_CODON,k); } /* Ok - finished max calculation for CDS */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS) = score; for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CDS */ /* For state CDS_INTRON_0 */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,CDS_INTRON_0) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CDS_INTRON_0,k); /* From state CDS to state CDS_INTRON_0 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-8,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),0); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,CDS,k); } /* Ok - finished max calculation for CDS_INTRON_0 */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_0) = score; for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CDS_INTRON_0 */ /* For state CDS_INTRON_1 */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,CDS_INTRON_1) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CDS_INTRON_1,k); /* From state CDS to state CDS_INTRON_1 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-9,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),1); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,CDS,k); } /* Ok - finished max calculation for CDS_INTRON_1 */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_1) = score; for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CDS_INTRON_1 */ /* For state CDS_INTRON_2 */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,CDS_INTRON_2) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CDS_INTRON_2,k); /* From state CDS to state CDS_INTRON_2 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-10,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),2); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,CDS,k); } /* Ok - finished max calculation for CDS_INTRON_2 */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_2) = score; for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CDS_INTRON_2 */ /* For state STOP_CODON */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,CDS) + GNE_STOP_CODON(mat->evi,i,mat->gen,j); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CDS,k); /* Ok - finished max calculation for STOP_CODON */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,STOP_CODON) = score; for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,STOP_CODON,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state STOP_CODON */ /* For state UTR3 */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR(mat->evi,i,mat->gen,j); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3,k); /* From state CDS to state UTR3 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,CDS) + (GNE_UTR(mat->evi,i,mat->gen,j)+mat->non_stop_codon); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CDS,k); } /* From state STOP_CODON to state UTR3 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,STOP_CODON) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,STOP_CODON,k); } /* From state UTR3_INTRON to state UTR3 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3_INTRON,k); } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3) = score; for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3_INTRON,k); /* From state UTR3 to state UTR3_INTRON */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3,k); } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = score; for(k=0;k<7;k++) GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UTR3_INTRON */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_GenomeWise9(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_GenomeWise9(GenomeWise9 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,START_CODON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_0) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_1) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_2) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,STOP_CODON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state UTR5 */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR(mat->evi,i,mat->gen,j); /* From state UTR5_INTRON to state UTR5 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5) = score; /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* From state UTR5 to state UTR5_INTRON */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = score; /* Finished calculating state UTR5_INTRON */ /* For state START_CODON */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,UTR5_INTRON) + GNE_START_CODON(mat->evi,i,mat->gen,j); /* From state UTR5 to state START_CODON */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,UTR5) + GNE_START_CODON(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for START_CODON */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,START_CODON) = score; /* Finished calculating state START_CODON */ /* For state CDS */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,CDS) + GNE_CDS(mat->evi,i,mat->gen,j); /* From state CDS_INTRON_0 to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-6,CDS_INTRON_0) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-3),0); if( temp > score ) { score = temp; } /* From state CDS_INTRON_1 to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-5,CDS_INTRON_1) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-2),1); if( temp > score ) { score = temp; } /* From state CDS_INTRON_2 to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-4,CDS_INTRON_2) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-1),2); if( temp > score ) { score = temp; } /* From state CDS to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-2,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,2); if( temp > score ) { score = temp; } /* From state CDS to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-4,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,4); if( temp > score ) { score = temp; } /* From state UTR5 to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,UTR5) + (GNE_CDS(mat->evi,i,mat->gen,j)+mat->non_start_codon); if( temp > score ) { score = temp; } /* From state START_CODON to state CDS */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,START_CODON) + GNE_CDS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS) = score; /* Finished calculating state CDS */ /* For state CDS_INTRON_0 */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,CDS_INTRON_0) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_0 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-8,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),0); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_0 */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_0) = score; /* Finished calculating state CDS_INTRON_0 */ /* For state CDS_INTRON_1 */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,CDS_INTRON_1) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_1 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-9,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),1); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_1 */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_1) = score; /* Finished calculating state CDS_INTRON_1 */ /* For state CDS_INTRON_2 */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,CDS_INTRON_2) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_2 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-10,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),2); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_2 */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_2) = score; /* Finished calculating state CDS_INTRON_2 */ /* For state STOP_CODON */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-3,CDS) + GNE_STOP_CODON(mat->evi,i,mat->gen,j); /* Ok - finished max calculation for STOP_CODON */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,STOP_CODON) = score; /* Finished calculating state STOP_CODON */ /* For state UTR3 */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR(mat->evi,i,mat->gen,j); /* From state CDS to state UTR3 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,CDS) + (GNE_UTR(mat->evi,i,mat->gen,j)+mat->non_stop_codon); if( temp > score ) { score = temp; } /* From state STOP_CODON to state UTR3 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,STOP_CODON) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state UTR3_INTRON to state UTR3 */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3) = score; /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* From state UTR3 to state UTR3_INTRON */ temp = GenomeWise9_DC_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = score; /* Finished calculating state UTR3_INTRON */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_GenomeWise9(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * */ } void init_dc_GenomeWise9(GenomeWise9 * mat) { register int i; register int j; register int k; for(j=0;j<12;j++) { for(i=(-0);ievi->len;i++) { GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,START_CODON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_0) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_1) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_2) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,STOP_CODON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3) = NEGI; GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; for(k=0;k<7;k++) { GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,k) = (-1); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,k) = (-1); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,k) = (-1); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,k) = (-1); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,k) = (-1); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,k) = (-1); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,k) = (-1); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,STOP_CODON,k) = (-1); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = (-1); GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,k) = (-1); } } } return; } /* Function: start_end_find_end_GenomeWise9(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [GenomeWise9 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_GenomeWise9(GenomeWise9 * mat,int * endj) { register int j; register int max; register int maxj; max = GenomeWise9_DC_SHADOW_SPECIAL(mat,0,mat->gen->seq->len-1,END); maxj = mat->gen->seq->len-1; for(j= mat->gen->seq->len-2 ;j >= 0 ;j--) { if( GenomeWise9_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = GenomeWise9_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_GenomeWise9(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [GenomeWise9] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_GenomeWise9(GenomeWise9 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->evi->len; lenj = mat->gen->seq->len; total = leni * lenj; score_pointers = (int *) calloc (10 * (leni + 0) * 10,sizeof(int)); shadow_pointers = (int *) calloc (10 * (leni + 0) * 10 * 8,sizeof(int)); for(j=0;jevi,i,mat->gen,j) + (0); /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5,0)); /* From state UTR5_INTRON to state UTR5 */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5_INTRON,0)); } /* From state SPECIAL_UTR5 to state UTR5 */ temp = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,SPECIAL_UTR5) + GNE_UTR(mat->evi,i,mat->gen,j) + (0); if( temp > score ) { score = temp; /* This state [SPECIAL_UTR5] is a special for UTR5... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= UTR5; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state START to state UTR5 */ temp = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,START) + GNE_UTR5_START(mat->evi,i,mat->gen,j) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for UTR5... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= UTR5; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTERGENIC to state UTR5 */ temp = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,INTERGENIC) + (GNE_UTR(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j)) + (0); if( temp > score ) { score = temp; /* This state [INTERGENIC] is a special for UTR5... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= UTR5; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state PREGENE_INTERGENIC to state UTR5 */ temp = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,PREGENE_INTERGENIC) + GNE_UTR(mat->evi,i,mat->gen,j) + (0); if( temp > score ) { score = temp; /* This state [PREGENE_INTERGENIC] is a special for UTR5... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= UTR5; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i,j,UTR5) = score; for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR5,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state UTR5 is a source for special SPECIAL_UTR5 */ temp = score + (mat->switchcost) + (0) ; if( temp > GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i,j,SPECIAL_UTR5) ) { GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i,j,SPECIAL_UTR5) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_UTR5,k) = GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR5,k); GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_UTR5,6) = GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR5,6); GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_UTR5,3) = i; GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_UTR5,4) = j; GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_UTR5,5) = UTR5; } /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j) + (0); /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5_INTRON,0)); /* From state UTR5 to state UTR5_INTRON */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR_5SS(mat->evi,i,mat->gen,j) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR5,0)); } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = score; for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UTR5_INTRON */ /* For state START_CODON */ /* setting first movement to score */ score = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,UTR5_INTRON) + GNE_START_CODON(mat->evi,i,mat->gen,j) + (0); /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,UTR5_INTRON,0)); /* From state UTR5 to state START_CODON */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,UTR5) + GNE_START_CODON(mat->evi,i,mat->gen,j) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,UTR5,0)); } /* Ok - finished max calculation for START_CODON */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i,j,START_CODON) = score; for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,START_CODON,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state START_CODON */ /* For state CDS */ /* setting first movement to score */ score = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,CDS) + GNE_CDS(mat->evi,i,mat->gen,j) + (0); /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CDS,0)); /* From state CDS_INTRON_0 to state CDS */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-6,CDS_INTRON_0) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-3),0) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 6,CDS_INTRON_0,0)); } /* From state CDS_INTRON_1 to state CDS */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,CDS_INTRON_1) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-2),1) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,CDS_INTRON_1,0)); } /* From state CDS_INTRON_2 to state CDS */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,CDS_INTRON_2) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-1),2) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,CDS_INTRON_2,0)); } /* From state CDS to state CDS */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,2) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,CDS,0)); } /* From state CDS to state CDS */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,4) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,CDS,0)); } /* From state UTR5 to state CDS */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,UTR5) + (GNE_CDS(mat->evi,i,mat->gen,j)+mat->non_start_codon) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,UTR5,0)); } /* From state START_CODON to state CDS */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,START_CODON) + GNE_CDS(mat->evi,i,mat->gen,j) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,START_CODON,0)); } /* From state SPECIAL_CDS to state CDS */ temp = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,SPECIAL_CDS) + GNE_CDS(mat->evi,i,mat->gen,j) + (0); if( temp > score ) { score = temp; /* This state [SPECIAL_CDS] is a special for CDS... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= CDS; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTERGENIC to state CDS */ temp = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,INTERGENIC) + (GNE_CDS(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j)) + (0); if( temp > score ) { score = temp; /* This state [INTERGENIC] is a special for CDS... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= CDS; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for CDS */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i,j,CDS) = score; for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CDS,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state CDS is a source for special INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i,j,INTERGENIC) ) { GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i,j,INTERGENIC) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,k) = GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CDS,k); GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,6) = GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CDS,6); GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,3) = i; GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,4) = j; GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,5) = CDS; } /* state CDS is a source for special SPECIAL_CDS */ temp = score + ((mat->switchcost+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)])) + (0) ; if( temp > GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i,j,SPECIAL_CDS) ) { GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i,j,SPECIAL_CDS) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_CDS,k) = GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CDS,k); GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_CDS,6) = GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CDS,6); GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_CDS,3) = i; GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_CDS,4) = j; GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_CDS,5) = CDS; } /* Finished calculating state CDS */ /* For state CDS_INTRON_0 */ /* setting first movement to score */ score = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CDS_INTRON_0) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j) + (0); /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CDS_INTRON_0,0)); /* From state CDS to state CDS_INTRON_0 */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),0) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,CDS,0)); } /* Ok - finished max calculation for CDS_INTRON_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i,j,CDS_INTRON_0) = score; for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CDS_INTRON_0 */ /* For state CDS_INTRON_1 */ /* setting first movement to score */ score = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CDS_INTRON_1) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j) + (0); /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CDS_INTRON_1,0)); /* From state CDS to state CDS_INTRON_1 */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),1) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,CDS,0)); } /* Ok - finished max calculation for CDS_INTRON_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i,j,CDS_INTRON_1) = score; for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CDS_INTRON_1 */ /* For state CDS_INTRON_2 */ /* setting first movement to score */ score = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CDS_INTRON_2) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j) + (0); /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CDS_INTRON_2,0)); /* From state CDS to state CDS_INTRON_2 */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),2) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,CDS,0)); } /* Ok - finished max calculation for CDS_INTRON_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i,j,CDS_INTRON_2) = score; for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CDS_INTRON_2 */ /* For state STOP_CODON */ /* setting first movement to score */ score = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,CDS) + GNE_STOP_CODON(mat->evi,i,mat->gen,j) + (0); /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CDS,0)); /* Ok - finished max calculation for STOP_CODON */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i,j,STOP_CODON) = score; for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,STOP_CODON,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state STOP_CODON */ /* For state UTR3 */ /* setting first movement to score */ score = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR(mat->evi,i,mat->gen,j) + (0); /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3,0)); /* From state CDS to state UTR3 */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,CDS) + (GNE_UTR(mat->evi,i,mat->gen,j)+mat->non_stop_codon) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,CDS,0)); } /* From state STOP_CODON to state UTR3 */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,STOP_CODON) + GNE_UTR(mat->evi,i,mat->gen,j) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,STOP_CODON,0)); } /* From state UTR3_INTRON to state UTR3 */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3_INTRON,0)); } /* From state INTERGENIC to state UTR3 */ temp = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,INTERGENIC) + GNE_UTR(mat->evi,i,mat->gen,j) + (0); if( temp > score ) { score = temp; /* This state [INTERGENIC] is a special for UTR3... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= UTR3; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i,j,UTR3) = score; for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR3,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state UTR3 is a source for special POSTGENE_INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i,j,POSTGENE_INTERGENIC) ) { GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i,j,POSTGENE_INTERGENIC) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,POSTGENE_INTERGENIC,k) = GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR3,k); GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,POSTGENE_INTERGENIC,6) = GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR3,6); GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,POSTGENE_INTERGENIC,3) = i; GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,POSTGENE_INTERGENIC,4) = j; GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,POSTGENE_INTERGENIC,5) = UTR3; } /* state UTR3 is a source for special INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i,j,INTERGENIC) ) { GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i,j,INTERGENIC) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,k) = GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR3,k); GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,6) = GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR3,6); GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,3) = i; GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,4) = j; GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,5) = UTR3; } /* state UTR3 is a source for special SPECIAL_UTR3 */ temp = score + (mat->switchcost) + (0) ; if( temp > GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i,j,SPECIAL_UTR3) ) { GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i,j,SPECIAL_UTR3) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_UTR3,k) = GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR3,k); GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_UTR3,6) = GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR3,6); GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_UTR3,3) = i; GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_UTR3,4) = j; GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_UTR3,5) = UTR3; } /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j) + (0); /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3_INTRON,0)); /* From state UTR3 to state UTR3_INTRON */ temp = GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR_5SS(mat->evi,i,mat->gen,j) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UTR3,0)); } /* From state SPECIAL_UTR3 to state UTR3_INTRON */ temp = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,SPECIAL_UTR3) + GNE_UTR(mat->evi,i,mat->gen,j) + (0); if( temp > score ) { score = temp; /* This state [SPECIAL_UTR3] is a special for UTR3_INTRON... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= UTR3_INTRON; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenomeWise9_DC_OPT_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = score; for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UTR3_INTRON */ } /* end of for each i position in strip */ /* Special state PREGENE_INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,0,j,PREGENE_INTERGENIC); /* Source START is a special source for PREGENE_INTERGENIC */ temp = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,PREGENE_INTERGENIC,k) = GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,START,k); } /* Put back score... (now updated!) */ GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,0,j,PREGENE_INTERGENIC) = score; /* Finished updating state PREGENE_INTERGENIC */ /* Special state POSTGENE_INTERGENIC has no special to special movements */ /* Special state INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,0,j,INTERGENIC); /* Source INTERGENIC is a special source for INTERGENIC */ temp = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,k) = GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,INTERGENIC,k); } /* Source CDS for state INTERGENIC is not special... already calculated */ /* Source UTR3 for state INTERGENIC is not special... already calculated */ /* Put back score... (now updated!) */ GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,0,j,INTERGENIC) = score; /* Finished updating state INTERGENIC */ /* Special state SPECIAL_UTR5 has no special to special movements */ /* Special state SPECIAL_UTR3 has no special to special movements */ /* Special state SPECIAL_CDS has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,0,j,SPECIAL_CDS); /* Source CDS for state SPECIAL_CDS is not special... already calculated */ /* Source SPECIAL_CDS is a special source for SPECIAL_CDS */ temp = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,SPECIAL_CDS) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,SPECIAL_CDS,k) = GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,SPECIAL_CDS,k); } /* Put back score... (now updated!) */ GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,0,j,SPECIAL_CDS) = score; /* Finished updating state SPECIAL_CDS */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,0,j,END); /* Source INTERGENIC is a special source for END */ temp = GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GenomeWise9_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,INTERGENIC,k); } /* Put back score... (now updated!) */ GenomeWise9_DC_OPT_SHADOW_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_GenomeWise9(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * */ void init_start_end_linear_GenomeWise9(GenomeWise9 * mat) { register int i; register int j; for(j=0;j<12;j++) { for(i=(-0);ievi->len;i++) { GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5,0) = (-1); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR5_INTRON,0) = (-1); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,START_CODON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,START_CODON,0) = (-1); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS,0) = (-1); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_0) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_0,0) = (-1); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_1) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_1,0) = (-1); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,CDS_INTRON_2) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,CDS_INTRON_2,0) = (-1); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,STOP_CODON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,STOP_CODON,0) = (-1); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3,0) = (-1); GenomeWise9_DC_SHADOW_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; GenomeWise9_DC_SHADOW_MATRIX_SP(mat,i,j,UTR3_INTRON,0) = (-1); } } for(j=(-10);jgen->seq->len;j++) { GenomeWise9_DC_SHADOW_SPECIAL(mat,0,j,PREGENE_INTERGENIC) = NEGI; GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,j,PREGENE_INTERGENIC,0) = (-1); GenomeWise9_DC_SHADOW_SPECIAL(mat,0,j,POSTGENE_INTERGENIC) = NEGI; GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,j,POSTGENE_INTERGENIC,0) = (-1); GenomeWise9_DC_SHADOW_SPECIAL(mat,0,j,INTERGENIC) = NEGI; GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,j,INTERGENIC,0) = (-1); GenomeWise9_DC_SHADOW_SPECIAL(mat,0,j,SPECIAL_UTR5) = NEGI; GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,j,SPECIAL_UTR5,0) = (-1); GenomeWise9_DC_SHADOW_SPECIAL(mat,0,j,SPECIAL_UTR3) = NEGI; GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,j,SPECIAL_UTR3,0) = (-1); GenomeWise9_DC_SHADOW_SPECIAL(mat,0,j,SPECIAL_CDS) = NEGI; GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,j,SPECIAL_CDS,0) = (-1); GenomeWise9_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; GenomeWise9_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; GenomeWise9_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_GenomeWise9(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_GenomeWise9(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_GenomeWise9(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "UTR5","START_CODON","CDS","CDS_INTRON","STOP_CODON","UTR3","INTERGENIC","SPECIAL","END" }; /* Function: AlnConvertSet_GenomeWise9(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "UTR5","UTR5_INTRON","CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","SEQUENCE_DELETION","CDS_INTRON","5SS_PHASE_0","5SS_PHASE_1","5SS_PHASE_2","STOP_CODON","UTR3","UTR3_INTRON","RANDOM_DNA","END" }; AlnConvertSet * AlnConvertSet_GenomeWise9(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5; acu->state2 = UTR5; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5_INTRON; acu->state2 = UTR5; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPECIAL_UTR5 + 10; acu->is_from_special = TRUE; acu->state2 = UTR5; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 10; acu->is_from_special = TRUE; acu->state2 = UTR5; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTERGENIC + 10; acu->is_from_special = TRUE; acu->state2 = UTR5; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = PREGENE_INTERGENIC + 10; acu->is_from_special = TRUE; acu->state2 = UTR5; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5_INTRON; acu->state2 = UTR5_INTRON; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5; acu->state2 = UTR5_INTRON; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5_INTRON; acu->state2 = START_CODON; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5; acu->state2 = START_CODON; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS; acu->state2 = CDS; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS_INTRON_0; acu->state2 = CDS; acu->offi = 0; acu->offj = 6; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS_INTRON_1; acu->state2 = CDS; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[2]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS_INTRON_2; acu->state2 = CDS; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[2]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS; acu->state2 = CDS; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS; acu->state2 = CDS; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5; acu->state2 = CDS; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START_CODON; acu->state2 = CDS; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPECIAL_CDS + 10; acu->is_from_special = TRUE; acu->state2 = CDS; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTERGENIC + 10; acu->is_from_special = TRUE; acu->state2 = CDS; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS_INTRON_0; acu->state2 = CDS_INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS; acu->state2 = CDS_INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS_INTRON_1; acu->state2 = CDS_INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS; acu->state2 = CDS_INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS_INTRON_2; acu->state2 = CDS_INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS; acu->state2 = CDS_INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS; acu->state2 = STOP_CODON; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3; acu->state2 = UTR3; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS; acu->state2 = UTR3; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = STOP_CODON; acu->state2 = UTR3; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3_INTRON; acu->state2 = UTR3; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTERGENIC + 10; acu->is_from_special = TRUE; acu->state2 = UTR3; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3_INTRON; acu->state2 = UTR3_INTRON; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[13]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3; acu->state2 = UTR3_INTRON; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[13]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPECIAL_UTR3 + 10; acu->is_from_special = TRUE; acu->state2 = UTR3_INTRON; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[13]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 10; acu->state2 = PREGENE_INTERGENIC + 10; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3; acu->state2 = POSTGENE_INTERGENIC + 10; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[6]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTERGENIC + 10; acu->state2 = INTERGENIC + 10; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS; acu->state2 = INTERGENIC + 10; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[6]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3; acu->state2 = INTERGENIC + 10; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[6]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR5; acu->state2 = SPECIAL_UTR5 + 10; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[7]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UTR3; acu->state2 = SPECIAL_UTR3 + 10; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[7]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CDS; acu->state2 = SPECIAL_CDS + 10; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[7]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = SPECIAL_CDS + 10; acu->state2 = SPECIAL_CDS + 10; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[7]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTERGENIC + 10; acu->state2 = END + 10; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[15]; add_collapse_label_AlnConvertSet(out,"UTR5","UTR5"); add_collapse_label_AlnConvertSet(out,"UTR3","UTR3"); add_collapse_label_AlnConvertSet(out,"UTR5","UTR5_INTRON"); add_collapse_label_AlnConvertSet(out,"UTR3","UTR3_INTRON"); add_collapse_label_AlnConvertSet(out,"INTERGENIC","RANDOM_DNA"); add_collapse_label_AlnConvertSet(out,"CDS_INTRON","CDS_INTRON"); return out; } /* Function: PackAln_read_Expl_GenomeWise9(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_GenomeWise9(GenomeWise9 * mat) { GenomeWise9_access_func_holder holder; holder.access_main = GenomeWise9_explicit_access_main; holder.access_special = GenomeWise9_explicit_access_special; return PackAln_read_generic_GenomeWise9(mat,holder); } /* Function: GenomeWise9_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GenomeWise9_explicit_access_main(GenomeWise9 * mat,int i,int j,int state) { return GenomeWise9_EXPL_MATRIX(mat,i,j,state); } /* Function: GenomeWise9_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GenomeWise9_explicit_access_special(GenomeWise9 * mat,int i,int j,int state) { return GenomeWise9_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_GenomeWise9(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: h [UNKN ] Undocumented argument [GenomeWise9_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_GenomeWise9(GenomeWise9 * mat,GenomeWise9_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_GenomeWise9(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in GenomeWise9_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 10; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_GenomeWise9(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_GenomeWise9(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == GenomeWise9_READ_OFF_ERROR || j == GenomeWise9_READ_OFF_ERROR || state == GenomeWise9_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in GenomeWise9_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 10; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_GenomeWise9(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [GenomeWise9_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_GenomeWise9(GenomeWise9 * mat,int * ri,int * rj,int * state,boolean * isspecial,GenomeWise9_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->gen->seq->len-1,END); maxj = mat->gen->seq->len-1; for(j= mat->gen->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: GenomeWise9_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void GenomeWise9_debug_show_matrix(GenomeWise9 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;ievi->len;i++) { for(j=startj;jgen->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State UTR5 %d\n",GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5)); fprintf(ofp,"State UTR5_INTRON %d\n",GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5_INTRON)); fprintf(ofp,"State START_CODON %d\n",GenomeWise9_EXPL_MATRIX(mat,i,j,START_CODON)); fprintf(ofp,"State CDS %d\n",GenomeWise9_EXPL_MATRIX(mat,i,j,CDS)); fprintf(ofp,"State CDS_INTRON_0 %d\n",GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_0)); fprintf(ofp,"State CDS_INTRON_1 %d\n",GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_1)); fprintf(ofp,"State CDS_INTRON_2 %d\n",GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_2)); fprintf(ofp,"State STOP_CODON %d\n",GenomeWise9_EXPL_MATRIX(mat,i,j,STOP_CODON)); fprintf(ofp,"State UTR3 %d\n",GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3)); fprintf(ofp,"State UTR3_INTRON %d\n",GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3_INTRON)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_GenomeWise9(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GenomeWise9_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_GenomeWise9(GenomeWise9 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GenomeWise9_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GenomeWise9_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->evi->len || j > mat->gen->seq->len) { warn("In GenomeWise9 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case UTR5 : temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,PREGENE_INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = PREGENE_INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,PREGENE_INTERGENIC); } return (*h.access_main)(mat,i - 0,j - 1,PREGENE_INTERGENIC); } temp = cscore - ((GNE_UTR(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,INTERGENIC); } return (*h.access_main)(mat,i - 0,j - 1,INTERGENIC); } temp = cscore - (GNE_UTR5_START(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_main)(mat,i - 0,j - 1,START); } temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,SPECIAL_UTR5) ) { *reti = i - 0; *retj = j - 1; *retstate = SPECIAL_UTR5; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,SPECIAL_UTR5); } return (*h.access_main)(mat,i - 0,j - 1,SPECIAL_UTR5); } temp = cscore - (GNE_UTR_3SS(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR5_INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR5_INTRON); } return (*h.access_main)(mat,i - 0,j - 1,UTR5_INTRON); } temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR5) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR5); } return (*h.access_main)(mat,i - 0,j - 1,UTR5); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR5_INTRON : temp = cscore - (GNE_UTR_5SS(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR5) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR5); } return (*h.access_main)(mat,i - 0,j - 1,UTR5); } temp = cscore - (GNE_UTR_INTRON(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR5_INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR5_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR5_INTRON); } return (*h.access_main)(mat,i - 0,j - 1,UTR5_INTRON); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case START_CODON : temp = cscore - (GNE_START_CODON(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,UTR5) ) { *reti = i - 0; *retj = j - 3; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,UTR5); } return (*h.access_main)(mat,i - 0,j - 3,UTR5); } temp = cscore - (GNE_START_CODON(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,UTR5_INTRON) ) { *reti = i - 0; *retj = j - 3; *retstate = UTR5_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,UTR5_INTRON); } return (*h.access_main)(mat,i - 0,j - 3,UTR5_INTRON); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CDS : temp = cscore - ((GNE_CDS(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,INTERGENIC) ) { *reti = i - 0; *retj = j - 3; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,INTERGENIC); } return (*h.access_main)(mat,i - 0,j - 3,INTERGENIC); } temp = cscore - (GNE_CDS(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,SPECIAL_CDS) ) { *reti = i - 0; *retj = j - 3; *retstate = SPECIAL_CDS; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,SPECIAL_CDS); } return (*h.access_main)(mat,i - 0,j - 3,SPECIAL_CDS); } temp = cscore - (GNE_CDS(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,START_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = START_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,START_CODON); } return (*h.access_main)(mat,i - 0,j - 3,START_CODON); } temp = cscore - ((GNE_CDS(mat->evi,i,mat->gen,j)+mat->non_start_codon)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,UTR5) ) { *reti = i - 0; *retj = j - 3; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,UTR5); } return (*h.access_main)(mat,i - 0,j - 3,UTR5); } temp = cscore - (GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,4)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,CDS) ) { *reti = i - 0; *retj = j - 4; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,CDS); } return (*h.access_main)(mat,i - 0,j - 4,CDS); } temp = cscore - (GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,2)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,CDS) ) { *reti = i - 0; *retj = j - 2; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,CDS); } return (*h.access_main)(mat,i - 0,j - 2,CDS); } temp = cscore - (GNE_CDS_3SS(mat->evi,i,mat->gen,(j-1),2)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,CDS_INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = CDS_INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,CDS_INTRON_2); } return (*h.access_main)(mat,i - 0,j - 4,CDS_INTRON_2); } temp = cscore - (GNE_CDS_3SS(mat->evi,i,mat->gen,(j-2),1)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,CDS_INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = CDS_INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,CDS_INTRON_1); } return (*h.access_main)(mat,i - 0,j - 5,CDS_INTRON_1); } temp = cscore - (GNE_CDS_3SS(mat->evi,i,mat->gen,(j-3),0)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 6,CDS_INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = CDS_INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-6,CDS_INTRON_0); } return (*h.access_main)(mat,i - 0,j - 6,CDS_INTRON_0); } temp = cscore - (GNE_CDS(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,CDS) ) { *reti = i - 0; *retj = j - 3; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,CDS); } return (*h.access_main)(mat,i - 0,j - 3,CDS); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CDS_INTRON_0 : temp = cscore - (GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),0)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,CDS) ) { *reti = i - 0; *retj = j - 8; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,CDS); } return (*h.access_main)(mat,i - 0,j - 8,CDS); } temp = cscore - (GNE_CDS_INTRON(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CDS_INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = CDS_INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CDS_INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,CDS_INTRON_0); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CDS_INTRON_1 : temp = cscore - (GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),1)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,CDS) ) { *reti = i - 0; *retj = j - 9; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,CDS); } return (*h.access_main)(mat,i - 0,j - 9,CDS); } temp = cscore - (GNE_CDS_INTRON(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CDS_INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = CDS_INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CDS_INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,CDS_INTRON_1); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case CDS_INTRON_2 : temp = cscore - (GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),2)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,CDS) ) { *reti = i - 0; *retj = j - 10; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,CDS); } return (*h.access_main)(mat,i - 0,j - 10,CDS); } temp = cscore - (GNE_CDS_INTRON(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CDS_INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = CDS_INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CDS_INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,CDS_INTRON_2); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case STOP_CODON : temp = cscore - (GNE_STOP_CODON(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,CDS) ) { *reti = i - 0; *retj = j - 3; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,CDS); } return (*h.access_main)(mat,i - 0,j - 3,CDS); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR3 : /* Has restricted position */ if( (j-1) == 0 ) { temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,INTERGENIC); } return (*h.access_main)(mat,i - 0,j - 1,INTERGENIC); } } temp = cscore - (GNE_UTR_3SS(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR3_INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR3_INTRON); } return (*h.access_main)(mat,i - 0,j - 1,UTR3_INTRON); } temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,STOP_CODON) ) { *reti = i - 0; *retj = j - 1; *retstate = STOP_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,STOP_CODON); } return (*h.access_main)(mat,i - 0,j - 1,STOP_CODON); } temp = cscore - ((GNE_UTR(mat->evi,i,mat->gen,j)+mat->non_stop_codon)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,CDS) ) { *reti = i - 0; *retj = j - 1; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,CDS); } return (*h.access_main)(mat,i - 0,j - 1,CDS); } temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR3) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR3); } return (*h.access_main)(mat,i - 0,j - 1,UTR3); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UTR3_INTRON : temp = cscore - (GNE_UTR(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,SPECIAL_UTR3) ) { *reti = i - 0; *retj = j - 1; *retstate = SPECIAL_UTR3; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,SPECIAL_UTR3); } return (*h.access_main)(mat,i - 0,j - 1,SPECIAL_UTR3); } temp = cscore - (GNE_UTR_5SS(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR3) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR3); } return (*h.access_main)(mat,i - 0,j - 1,UTR3); } temp = cscore - (GNE_UTR_INTRON(mat->evi,i,mat->gen,j)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UTR3_INTRON) ) { *reti = i - 0; *retj = j - 1; *retstate = UTR3_INTRON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UTR3_INTRON); } return (*h.access_main)(mat,i - 0,j - 1,UTR3_INTRON); } warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_GenomeWise9(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GenomeWise9_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_GenomeWise9(GenomeWise9 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GenomeWise9_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GenomeWise9_READ_OFF_ERROR; if( j < 0 || j > mat->gen->seq->len) { warn("In GenomeWise9 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case PREGENE_INTERGENIC : /* source START is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_special)(mat,i - 0,j - 1,START) ; } case POSTGENE_INTERGENIC : /* source UTR3 is from main matrix */ for(i= mat->evi->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,UTR3) ) { *reti = i - 0; *retj = j - 0; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,UTR3); } return (*h.access_main)(mat,i - 0,j - 0,UTR3) ; } } /* end of for i >= 0 */ case INTERGENIC : /* source UTR3 is from main matrix */ for(i= mat->evi->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,UTR3) ) { *reti = i - 0; *retj = j - 0; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,UTR3); } return (*h.access_main)(mat,i - 0,j - 0,UTR3) ; } } /* end of for i >= 0 */ /* source CDS is from main matrix */ for(i= mat->evi->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,CDS) ) { *reti = i - 0; *retj = j - 0; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,CDS); } return (*h.access_main)(mat,i - 0,j - 0,CDS) ; } } /* end of for i >= 0 */ /* source INTERGENIC is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,INTERGENIC); } return (*h.access_special)(mat,i - 0,j - 1,INTERGENIC) ; } case SPECIAL_UTR5 : /* source UTR5 is from main matrix */ for(i= mat->evi->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->switchcost) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,UTR5) ) { *reti = i - 0; *retj = j - 0; *retstate = UTR5; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,UTR5); } return (*h.access_main)(mat,i - 0,j - 0,UTR5) ; } } /* end of for i >= 0 */ case SPECIAL_UTR3 : /* source UTR3 is from main matrix */ for(i= mat->evi->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->switchcost) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,UTR3) ) { *reti = i - 0; *retj = j - 0; *retstate = UTR3; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,UTR3); } return (*h.access_main)(mat,i - 0,j - 0,UTR3) ; } } /* end of for i >= 0 */ case SPECIAL_CDS : /* source SPECIAL_CDS is a special */ temp = cscore - (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,SPECIAL_CDS) ) { *reti = i - 0; *retj = j - 3; *retstate = SPECIAL_CDS; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,SPECIAL_CDS); } return (*h.access_special)(mat,i - 0,j - 3,SPECIAL_CDS) ; } /* source CDS is from main matrix */ for(i= mat->evi->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - ((mat->switchcost+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,CDS) ) { *reti = i - 0; *retj = j - 0; *retstate = CDS; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,CDS); } return (*h.access_main)(mat,i - 0,j - 0,CDS) ; } } /* end of for i >= 0 */ case START : case END : /* source INTERGENIC is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,INTERGENIC); } return (*h.access_special)(mat,i - 0,j - 1,INTERGENIC) ; } default: warn("Major problem (!) - in GenomeWise9 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_GenomeWise9(mat) * * Descrip: This function calculates the GenomeWise9 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GenomeWise9 * * * Arg: mat [UNKN ] GenomeWise9 which contains explicit basematrix memory [GenomeWise9 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_GenomeWise9(GenomeWise9 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GenomeWise9, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("GenomeWise9 Matrix calculation: "); for(j=0;jevi,i,mat->gen,j); /* From state UTR5_INTRON to state UTR5 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state SPECIAL_UTR5 to state UTR5 */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-1,SPECIAL_UTR5) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state START to state UTR5 */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-1,START) + GNE_UTR5_START(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state INTERGENIC to state UTR5 */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-1,INTERGENIC) + (GNE_UTR(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j)); if( temp > score ) { score = temp; } /* From state PREGENE_INTERGENIC to state UTR5 */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-1,PREGENE_INTERGENIC) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5) = score; /* state UTR5 is a source for special SPECIAL_UTR5 */ temp = score + (mat->switchcost) + (0) ; if( temp > GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_UTR5) ) { GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_UTR5) = temp; } /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* From state UTR5 to state UTR5_INTRON */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5_INTRON) = score; /* Finished calculating state UTR5_INTRON */ /* For state START_CODON */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-3,UTR5_INTRON) + GNE_START_CODON(mat->evi,i,mat->gen,j); /* From state UTR5 to state START_CODON */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-3,UTR5) + GNE_START_CODON(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for START_CODON */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,START_CODON) = score; /* Finished calculating state START_CODON */ /* For state CDS */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-3,CDS) + GNE_CDS(mat->evi,i,mat->gen,j); /* From state CDS_INTRON_0 to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-6,CDS_INTRON_0) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-3),0); if( temp > score ) { score = temp; } /* From state CDS_INTRON_1 to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-5,CDS_INTRON_1) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-2),1); if( temp > score ) { score = temp; } /* From state CDS_INTRON_2 to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-4,CDS_INTRON_2) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-1),2); if( temp > score ) { score = temp; } /* From state CDS to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-2,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,2); if( temp > score ) { score = temp; } /* From state CDS to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-4,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,4); if( temp > score ) { score = temp; } /* From state UTR5 to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-3,UTR5) + (GNE_CDS(mat->evi,i,mat->gen,j)+mat->non_start_codon); if( temp > score ) { score = temp; } /* From state START_CODON to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-3,START_CODON) + GNE_CDS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state SPECIAL_CDS to state CDS */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-3,SPECIAL_CDS) + GNE_CDS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state INTERGENIC to state CDS */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-3,INTERGENIC) + (GNE_CDS(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,CDS) = score; /* state CDS is a source for special INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_EXPL_SPECIAL(mat,i,j,INTERGENIC) ) { GenomeWise9_EXPL_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* state CDS is a source for special SPECIAL_CDS */ temp = score + ((mat->switchcost+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)])) + (0) ; if( temp > GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_CDS) ) { GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_CDS) = temp; } /* Finished calculating state CDS */ /* For state CDS_INTRON_0 */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,CDS_INTRON_0) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_0 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-8,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),0); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_0 */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_0) = score; /* Finished calculating state CDS_INTRON_0 */ /* For state CDS_INTRON_1 */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,CDS_INTRON_1) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_1 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-9,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),1); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_1 */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_1) = score; /* Finished calculating state CDS_INTRON_1 */ /* For state CDS_INTRON_2 */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,CDS_INTRON_2) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_2 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-10,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),2); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_2 */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_2) = score; /* Finished calculating state CDS_INTRON_2 */ /* For state STOP_CODON */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-3,CDS) + GNE_STOP_CODON(mat->evi,i,mat->gen,j); /* Ok - finished max calculation for STOP_CODON */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,STOP_CODON) = score; /* Finished calculating state STOP_CODON */ /* For state UTR3 */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR(mat->evi,i,mat->gen,j); /* From state CDS to state UTR3 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,CDS) + (GNE_UTR(mat->evi,i,mat->gen,j)+mat->non_stop_codon); if( temp > score ) { score = temp; } /* From state STOP_CODON to state UTR3 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,STOP_CODON) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state UTR3_INTRON to state UTR3 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Has restricted position */ if( (j-1) == 0 ) { /* From state INTERGENIC to state UTR3 */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-1,INTERGENIC) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3) = score; /* state UTR3 is a source for special POSTGENE_INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_EXPL_SPECIAL(mat,i,j,POSTGENE_INTERGENIC) ) { GenomeWise9_EXPL_SPECIAL(mat,i,j,POSTGENE_INTERGENIC) = temp; } /* state UTR3 is a source for special INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_EXPL_SPECIAL(mat,i,j,INTERGENIC) ) { GenomeWise9_EXPL_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* state UTR3 is a source for special SPECIAL_UTR3 */ temp = score + (mat->switchcost) + (0) ; if( temp > GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_UTR3) ) { GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_UTR3) = temp; } /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* From state UTR3 to state UTR3_INTRON */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state SPECIAL_UTR3 to state UTR3_INTRON */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-1,SPECIAL_UTR3) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3_INTRON) = score; /* Finished calculating state UTR3_INTRON */ } /* Special state PREGENE_INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_EXPL_SPECIAL(mat,0,j,PREGENE_INTERGENIC); /* Source START is a special source for PREGENE_INTERGENIC */ temp = GenomeWise9_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenomeWise9_EXPL_SPECIAL(mat,0,j,PREGENE_INTERGENIC) = score; /* Finished updating state PREGENE_INTERGENIC */ /* Special state POSTGENE_INTERGENIC has no special to special movements */ /* Special state INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_EXPL_SPECIAL(mat,0,j,INTERGENIC); /* Source INTERGENIC is a special source for INTERGENIC */ temp = GenomeWise9_EXPL_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; /* Source CDS for state INTERGENIC is not special... already calculated */ /* Source UTR3 for state INTERGENIC is not special... already calculated */ /* Put back score... (now updated!) */ GenomeWise9_EXPL_SPECIAL(mat,0,j,INTERGENIC) = score; /* Finished updating state INTERGENIC */ /* Special state SPECIAL_UTR5 has no special to special movements */ /* Special state SPECIAL_UTR3 has no special to special movements */ /* Special state SPECIAL_CDS has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_EXPL_SPECIAL(mat,0,j,SPECIAL_CDS); /* Source CDS for state SPECIAL_CDS is not special... already calculated */ /* Source SPECIAL_CDS is a special source for SPECIAL_CDS */ temp = GenomeWise9_EXPL_SPECIAL(mat,0,j - 3,SPECIAL_CDS) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenomeWise9_EXPL_SPECIAL(mat,0,j,SPECIAL_CDS) = score; /* Finished updating state SPECIAL_CDS */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_EXPL_SPECIAL(mat,0,j,END); /* Source INTERGENIC is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GenomeWise9_EXPL_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GenomeWise9_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_GenomeWise9(mat,dpenv) * * Descrip: This function calculates the GenomeWise9 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GenomeWise9 which contains explicit basematrix memory [GenomeWise9 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_GenomeWise9(GenomeWise9 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GenomeWise9, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-10;jleni;i++) { GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,START_CODON) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_0) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_1) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_2) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,STOP_CODON) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; } } for(j=-10;jlenj;j++) { GenomeWise9_EXPL_SPECIAL(mat,i,j,PREGENE_INTERGENIC) = NEGI; GenomeWise9_EXPL_SPECIAL(mat,i,j,POSTGENE_INTERGENIC) = NEGI; GenomeWise9_EXPL_SPECIAL(mat,i,j,INTERGENIC) = NEGI; GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_UTR5) = NEGI; GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_UTR3) = NEGI; GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_CDS) = NEGI; GenomeWise9_EXPL_SPECIAL(mat,i,j,START) = 0; GenomeWise9_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("GenomeWise9 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5_INTRON) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,START_CODON) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_0) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_1) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_2) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,STOP_CODON) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3) = NEGI; GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3_INTRON) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state UTR5 */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR(mat->evi,i,mat->gen,j); /* From state UTR5_INTRON to state UTR5 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state SPECIAL_UTR5 to state UTR5 */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-1,SPECIAL_UTR5) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state START to state UTR5 */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-1,START) + GNE_UTR5_START(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state INTERGENIC to state UTR5 */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-1,INTERGENIC) + (GNE_UTR(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j)); if( temp > score ) { score = temp; } /* From state PREGENE_INTERGENIC to state UTR5 */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-1,PREGENE_INTERGENIC) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5 */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5) = score; /* state UTR5 is a source for special SPECIAL_UTR5 */ temp = score + (mat->switchcost) + (0) ; if( temp > GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_UTR5) ) { GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_UTR5) = temp; } /* Finished calculating state UTR5 */ /* For state UTR5_INTRON */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR5_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* From state UTR5 to state UTR5_INTRON */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR5) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR5_INTRON */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,UTR5_INTRON) = score; /* Finished calculating state UTR5_INTRON */ /* For state START_CODON */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-3,UTR5_INTRON) + GNE_START_CODON(mat->evi,i,mat->gen,j); /* From state UTR5 to state START_CODON */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-3,UTR5) + GNE_START_CODON(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for START_CODON */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,START_CODON) = score; /* Finished calculating state START_CODON */ /* For state CDS */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-3,CDS) + GNE_CDS(mat->evi,i,mat->gen,j); /* From state CDS_INTRON_0 to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-6,CDS_INTRON_0) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-3),0); if( temp > score ) { score = temp; } /* From state CDS_INTRON_1 to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-5,CDS_INTRON_1) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-2),1); if( temp > score ) { score = temp; } /* From state CDS_INTRON_2 to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-4,CDS_INTRON_2) + GNE_CDS_3SS(mat->evi,i,mat->gen,(j-1),2); if( temp > score ) { score = temp; } /* From state CDS to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-2,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,2); if( temp > score ) { score = temp; } /* From state CDS to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-4,CDS) + GNE_CDS_FRAMESHIFT(mat->evi,i,mat->gen,j,4); if( temp > score ) { score = temp; } /* From state UTR5 to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-3,UTR5) + (GNE_CDS(mat->evi,i,mat->gen,j)+mat->non_start_codon); if( temp > score ) { score = temp; } /* From state START_CODON to state CDS */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-3,START_CODON) + GNE_CDS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state SPECIAL_CDS to state CDS */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-3,SPECIAL_CDS) + GNE_CDS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state INTERGENIC to state CDS */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-3,INTERGENIC) + (GNE_CDS(mat->evi,i,mat->gen,j)+GNE_UTR5_START(mat->evi,i,mat->gen,j)); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,CDS) = score; /* state CDS is a source for special INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_EXPL_SPECIAL(mat,i,j,INTERGENIC) ) { GenomeWise9_EXPL_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* state CDS is a source for special SPECIAL_CDS */ temp = score + ((mat->switchcost+mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)])) + (0) ; if( temp > GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_CDS) ) { GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_CDS) = temp; } /* Finished calculating state CDS */ /* For state CDS_INTRON_0 */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,CDS_INTRON_0) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_0 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-8,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),0); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_0 */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_0) = score; /* Finished calculating state CDS_INTRON_0 */ /* For state CDS_INTRON_1 */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,CDS_INTRON_1) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_1 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-9,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),1); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_1 */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_1) = score; /* Finished calculating state CDS_INTRON_1 */ /* For state CDS_INTRON_2 */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,CDS_INTRON_2) + GNE_CDS_INTRON(mat->evi,i,mat->gen,j); /* From state CDS to state CDS_INTRON_2 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-10,CDS) + GNE_CDS_5SS(mat->evi,i,mat->gen,(j-7),2); if( temp > score ) { score = temp; } /* Ok - finished max calculation for CDS_INTRON_2 */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,CDS_INTRON_2) = score; /* Finished calculating state CDS_INTRON_2 */ /* For state STOP_CODON */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-3,CDS) + GNE_STOP_CODON(mat->evi,i,mat->gen,j); /* Ok - finished max calculation for STOP_CODON */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,STOP_CODON) = score; /* Finished calculating state STOP_CODON */ /* For state UTR3 */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR(mat->evi,i,mat->gen,j); /* From state CDS to state UTR3 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,CDS) + (GNE_UTR(mat->evi,i,mat->gen,j)+mat->non_stop_codon); if( temp > score ) { score = temp; } /* From state STOP_CODON to state UTR3 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,STOP_CODON) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state UTR3_INTRON to state UTR3 */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_3SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Has restricted position */ if( (j-1) == 0 ) { /* From state INTERGENIC to state UTR3 */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-1,INTERGENIC) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UTR3 */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3) = score; /* state UTR3 is a source for special POSTGENE_INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_EXPL_SPECIAL(mat,i,j,POSTGENE_INTERGENIC) ) { GenomeWise9_EXPL_SPECIAL(mat,i,j,POSTGENE_INTERGENIC) = temp; } /* state UTR3 is a source for special INTERGENIC */ temp = score + ((mat->newgenecost+GNE_UTR3_END(mat->evi,i,mat->gen,j))) + (0) ; if( temp > GenomeWise9_EXPL_SPECIAL(mat,i,j,INTERGENIC) ) { GenomeWise9_EXPL_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* state UTR3 is a source for special SPECIAL_UTR3 */ temp = score + (mat->switchcost) + (0) ; if( temp > GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_UTR3) ) { GenomeWise9_EXPL_SPECIAL(mat,i,j,SPECIAL_UTR3) = temp; } /* Finished calculating state UTR3 */ /* For state UTR3_INTRON */ /* setting first movement to score */ score = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR3_INTRON) + GNE_UTR_INTRON(mat->evi,i,mat->gen,j); /* From state UTR3 to state UTR3_INTRON */ temp = GenomeWise9_EXPL_MATRIX(mat,i-0,j-1,UTR3) + GNE_UTR_5SS(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* From state SPECIAL_UTR3 to state UTR3_INTRON */ temp = GenomeWise9_EXPL_SPECIAL(mat,i-0,j-1,SPECIAL_UTR3) + GNE_UTR(mat->evi,i,mat->gen,j); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UTR3_INTRON */ /* Add any movement independant score and put away */ GenomeWise9_EXPL_MATRIX(mat,i,j,UTR3_INTRON) = score; /* Finished calculating state UTR3_INTRON */ } /* Special state PREGENE_INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_EXPL_SPECIAL(mat,0,j,PREGENE_INTERGENIC); /* Source START is a special source for PREGENE_INTERGENIC */ temp = GenomeWise9_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenomeWise9_EXPL_SPECIAL(mat,0,j,PREGENE_INTERGENIC) = score; /* Finished updating state PREGENE_INTERGENIC */ /* Special state POSTGENE_INTERGENIC has no special to special movements */ /* Special state INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_EXPL_SPECIAL(mat,0,j,INTERGENIC); /* Source INTERGENIC is a special source for INTERGENIC */ temp = GenomeWise9_EXPL_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; /* Source CDS for state INTERGENIC is not special... already calculated */ /* Source UTR3 for state INTERGENIC is not special... already calculated */ /* Put back score... (now updated!) */ GenomeWise9_EXPL_SPECIAL(mat,0,j,INTERGENIC) = score; /* Finished updating state INTERGENIC */ /* Special state SPECIAL_UTR5 has no special to special movements */ /* Special state SPECIAL_UTR3 has no special to special movements */ /* Special state SPECIAL_CDS has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_EXPL_SPECIAL(mat,0,j,SPECIAL_CDS); /* Source CDS for state SPECIAL_CDS is not special... already calculated */ /* Source SPECIAL_CDS is a special source for SPECIAL_CDS */ temp = GenomeWise9_EXPL_SPECIAL(mat,0,j - 3,SPECIAL_CDS) + (mat->rndcodon->codon[CSEQ_GENOMIC_CODON(mat->gen,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenomeWise9_EXPL_SPECIAL(mat,0,j,SPECIAL_CDS) = score; /* Finished updating state SPECIAL_CDS */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenomeWise9_EXPL_SPECIAL(mat,0,j,END); /* Source INTERGENIC is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GenomeWise9_EXPL_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; } /* Put back score... (now updated!) */ GenomeWise9_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: GenomeWise9_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomeWise9 *] * */ GenomeWise9 * GenomeWise9_alloc(void) { GenomeWise9 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenomeWise9 *) ckalloc (sizeof(GenomeWise9))) == NULL) { warn("GenomeWise9_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_GenomeWise9(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomeWise9 *] * * Return [UNKN ] Undocumented return value [GenomeWise9 *] * */ GenomeWise9 * free_GenomeWise9(GenomeWise9 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GenomeWise9 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->evi is linked in */ /* obj->gen is linked in */ /* obj->switchcost is linked in */ /* obj->newgenecost is linked in */ /* obj->non_start_codon is linked in */ /* obj->non_stop_codon is linked in */ /* obj->rndcodon is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/genomewise9.h0000644000175000001440000005226510670453714016550 0ustar philippusers#ifndef DYNAMITEgenomewise9HEADERFILE #define DYNAMITEgenomewise9HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "genome_evidence.h" struct Wise2_GenomeWise9 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GenomeEvidenceSet* evi; ComplexSequence* gen; int switchcost; int newgenecost; int non_start_codon; int non_stop_codon; RandomCodonScore * rndcodon; } ; /* GenomeWise9 defined */ #ifndef DYNAMITE_DEFINED_GenomeWise9 typedef struct Wise2_GenomeWise9 Wise2_GenomeWise9; #define GenomeWise9 Wise2_GenomeWise9 #define DYNAMITE_DEFINED_GenomeWise9 #endif #ifdef PTHREAD struct thread_pool_holder_GenomeWise9 { GenomeEvidenceSet* evi; /* Static query data: never free'd */ ComplexSequence* gen; /* Target object placeholder */ GenomicDB* targetdb;/* Target database object */ boolean target_init; int switchcost; int newgenecost; int non_start_codon; int non_stop_codon; RandomCodonScore * rndcodon; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_GenomeWise9_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(GenomeWise9*,int,int,int); int (*access_special)(GenomeWise9*,int,int,int); } ; /* GenomeWise9_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_GenomeWise9_access_func_holder typedef struct Wise2_GenomeWise9_access_func_holder Wise2_GenomeWise9_access_func_holder; #define GenomeWise9_access_func_holder Wise2_GenomeWise9_access_func_holder #define DYNAMITE_DEFINED_GenomeWise9_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_GenomeWise9(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_GenomeWise9(GenomeWise9 * mat); #define PackAln_read_Shatter_GenomeWise9 Wise2_PackAln_read_Shatter_GenomeWise9 /* Function: calculate_shatter_GenomeWise9(mat,dpenv) * * Descrip: This function calculates the GenomeWise9 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GenomeWise9 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_GenomeWise9(GenomeWise9 * mat,DPEnvelope * dpenv); #define calculate_shatter_GenomeWise9 Wise2_calculate_shatter_GenomeWise9 /* Function: search_GenomeWise9(dbsi,out,evi,targetdb,switchcost,newgenecost,non_start_codon,non_stop_codon,rndcodon) * * Descrip: This function makes a database search of GenomeWise9 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: evi [UNKN ] Undocumented argument [GenomeEvidenceSet*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: switchcost [UNKN ] Undocumented argument [int] * Arg: newgenecost [UNKN ] Undocumented argument [int] * Arg: non_start_codon [UNKN ] Undocumented argument [int] * Arg: non_stop_codon [UNKN ] Undocumented argument [int] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_GenomeWise9(DBSearchImpl * dbsi,Hscore * out,GenomeEvidenceSet* evi,GenomicDB* targetdb ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon); #define search_GenomeWise9 Wise2_search_GenomeWise9 /* Function: serial_search_GenomeWise9(out,evi,targetdb,switchcost,newgenecost,non_start_codon,non_stop_codon,rndcodon) * * Descrip: This function makes a database search of GenomeWise9 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: evi [UNKN ] Undocumented argument [GenomeEvidenceSet*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: switchcost [UNKN ] Undocumented argument [int] * Arg: newgenecost [UNKN ] Undocumented argument [int] * Arg: non_start_codon [UNKN ] Undocumented argument [int] * Arg: non_stop_codon [UNKN ] Undocumented argument [int] * Arg: rndcodon [UNKN ] Undocumented argument [RandomCodonScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_GenomeWise9(Hscore * out,GenomeEvidenceSet* evi,GenomicDB* targetdb ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon); #define serial_search_GenomeWise9 Wise2_serial_search_GenomeWise9 /* Function: PackAln_bestmemory_GenomeWise9(evi,gen,switchcost,newgenecost,non_start_codon,non_stop_codon,rndcodon,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GenomeWise9 * * * Arg: evi [UNKN ] query data structure [GenomeEvidenceSet*] * Arg: gen [UNKN ] target data structure [ComplexSequence*] * Arg: switchcost [UNKN ] Resource [int] * Arg: newgenecost [UNKN ] Resource [int] * Arg: non_start_codon [UNKN ] Resource [int] * Arg: non_stop_codon [UNKN ] Resource [int] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_GenomeWise9(GenomeEvidenceSet* evi,ComplexSequence* gen ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_GenomeWise9 Wise2_PackAln_bestmemory_GenomeWise9 /* Function: allocate_Expl_GenomeWise9(evi,gen,switchcost,newgenecost,non_start_codon,non_stop_codon,rndcodon,dpri) * * Descrip: This function allocates the GenomeWise9 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GenomeWise9_only * * * Arg: evi [UNKN ] query data structure [GenomeEvidenceSet*] * Arg: gen [UNKN ] target data structure [ComplexSequence*] * Arg: switchcost [UNKN ] Resource [int] * Arg: newgenecost [UNKN ] Resource [int] * Arg: non_start_codon [UNKN ] Resource [int] * Arg: non_stop_codon [UNKN ] Resource [int] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GenomeWise9 *] * */ GenomeWise9 * Wise2_allocate_Expl_GenomeWise9(GenomeEvidenceSet* evi,ComplexSequence* gen ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon,DPRunImpl * dpri); #define allocate_Expl_GenomeWise9 Wise2_allocate_Expl_GenomeWise9 /* Function: recalculate_PackAln_GenomeWise9(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GenomeWise9 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * */ void Wise2_recalculate_PackAln_GenomeWise9(PackAln * pal,GenomeWise9 * mat); #define recalculate_PackAln_GenomeWise9 Wise2_recalculate_PackAln_GenomeWise9 /* Function: allocate_Small_GenomeWise9(evi,gen,switchcost,newgenecost,non_start_codon,non_stop_codon,rndcodon) * * Descrip: This function allocates the GenomeWise9 structure * and the basematrix area for a small memory implementations * It calls /allocate_GenomeWise9_only * * * Arg: evi [UNKN ] query data structure [GenomeEvidenceSet*] * Arg: gen [UNKN ] target data structure [ComplexSequence*] * Arg: switchcost [UNKN ] Resource [int] * Arg: newgenecost [UNKN ] Resource [int] * Arg: non_start_codon [UNKN ] Resource [int] * Arg: non_stop_codon [UNKN ] Resource [int] * Arg: rndcodon [UNKN ] Resource [RandomCodonScore *] * * Return [UNKN ] Undocumented return value [GenomeWise9 *] * */ GenomeWise9 * Wise2_allocate_Small_GenomeWise9(GenomeEvidenceSet* evi,ComplexSequence* gen ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon); #define allocate_Small_GenomeWise9 Wise2_allocate_Small_GenomeWise9 /* Function: PackAln_calculate_Small_GenomeWise9(mat,dpenv) * * Descrip: This function calculates an alignment for GenomeWise9 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GenomeWise9 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GenomeWise9 * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_GenomeWise9(GenomeWise9 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_GenomeWise9 Wise2_PackAln_calculate_Small_GenomeWise9 /* Function: AlnRangeSet_calculate_Small_GenomeWise9(mat) * * Descrip: This function calculates an alignment for GenomeWise9 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GenomeWise9 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GenomeWise9 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GenomeWise9 * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_GenomeWise9(GenomeWise9 * mat); #define AlnRangeSet_calculate_Small_GenomeWise9 Wise2_AlnRangeSet_calculate_Small_GenomeWise9 /* Function: AlnRangeSet_from_GenomeWise9(mat) * * Descrip: This function reads off a start/end structure * for GenomeWise9 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GenomeWise9 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GenomeWise9 * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_GenomeWise9(GenomeWise9 * mat); #define AlnRangeSet_from_GenomeWise9 Wise2_AlnRangeSet_from_GenomeWise9 /* Function: convert_PackAln_to_AlnBlock_GenomeWise9(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_GenomeWise9(PackAln * pal); #define convert_PackAln_to_AlnBlock_GenomeWise9 Wise2_convert_PackAln_to_AlnBlock_GenomeWise9 /* Function: PackAln_read_Expl_GenomeWise9(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_GenomeWise9(GenomeWise9 * mat); #define PackAln_read_Expl_GenomeWise9 Wise2_PackAln_read_Expl_GenomeWise9 /* Function: PackAln_read_generic_GenomeWise9(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GenomeWise9 *] * Arg: h [UNKN ] Undocumented argument [GenomeWise9_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_GenomeWise9(GenomeWise9 * mat,GenomeWise9_access_func_holder h); #define PackAln_read_generic_GenomeWise9 Wise2_PackAln_read_generic_GenomeWise9 /* Function: calculate_GenomeWise9(mat) * * Descrip: This function calculates the GenomeWise9 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GenomeWise9 * * * Arg: mat [UNKN ] GenomeWise9 which contains explicit basematrix memory [GenomeWise9 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_GenomeWise9(GenomeWise9 * mat); #define calculate_GenomeWise9 Wise2_calculate_GenomeWise9 /* Function: calculate_dpenv_GenomeWise9(mat,dpenv) * * Descrip: This function calculates the GenomeWise9 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GenomeWise9 which contains explicit basematrix memory [GenomeWise9 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_GenomeWise9(GenomeWise9 * mat,DPEnvelope * dpenv); #define calculate_dpenv_GenomeWise9 Wise2_calculate_dpenv_GenomeWise9 /* Function: GenomeWise9_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomeWise9 *] * */ GenomeWise9 * Wise2_GenomeWise9_alloc(void); #define GenomeWise9_alloc Wise2_GenomeWise9_alloc /* Function: free_GenomeWise9(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomeWise9 *] * * Return [UNKN ] Undocumented return value [GenomeWise9 *] * */ GenomeWise9 * Wise2_free_GenomeWise9(GenomeWise9 * obj); #define free_GenomeWise9 Wise2_free_GenomeWise9 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_GenomeWise9_shatter_access_main(GenomeWise9 * mat,int i,int j,int state); #define GenomeWise9_shatter_access_main Wise2_GenomeWise9_shatter_access_main int Wise2_GenomeWise9_shatter_access_special(GenomeWise9 * mat,int i,int j,int state); #define GenomeWise9_shatter_access_special Wise2_GenomeWise9_shatter_access_special void * Wise2_thread_loop_GenomeWise9(void * ptr); #define thread_loop_GenomeWise9 Wise2_thread_loop_GenomeWise9 int Wise2_score_only_GenomeWise9(GenomeEvidenceSet* evi,ComplexSequence* gen ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon); #define score_only_GenomeWise9 Wise2_score_only_GenomeWise9 GenomeWise9 * Wise2_allocate_GenomeWise9_only(GenomeEvidenceSet* evi,ComplexSequence* gen ,int switchcost,int newgenecost,int non_start_codon,int non_stop_codon,RandomCodonScore * rndcodon); #define allocate_GenomeWise9_only Wise2_allocate_GenomeWise9_only void Wise2_init_GenomeWise9(GenomeWise9 * mat); #define init_GenomeWise9 Wise2_init_GenomeWise9 AlnRange * Wise2_AlnRange_build_GenomeWise9(GenomeWise9 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_GenomeWise9 Wise2_AlnRange_build_GenomeWise9 boolean Wise2_read_hidden_GenomeWise9(GenomeWise9 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_GenomeWise9 Wise2_read_hidden_GenomeWise9 int Wise2_max_hidden_GenomeWise9(GenomeWise9 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_GenomeWise9 Wise2_max_hidden_GenomeWise9 boolean Wise2_read_special_strip_GenomeWise9(GenomeWise9 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_GenomeWise9 Wise2_read_special_strip_GenomeWise9 int Wise2_max_special_strip_GenomeWise9(GenomeWise9 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_GenomeWise9 Wise2_max_special_strip_GenomeWise9 int Wise2_max_matrix_to_special_GenomeWise9(GenomeWise9 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_GenomeWise9 Wise2_max_matrix_to_special_GenomeWise9 void Wise2_calculate_hidden_GenomeWise9(GenomeWise9 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_GenomeWise9 Wise2_calculate_hidden_GenomeWise9 void Wise2_init_hidden_GenomeWise9(GenomeWise9 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_GenomeWise9 Wise2_init_hidden_GenomeWise9 boolean Wise2_full_dc_GenomeWise9(GenomeWise9 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_GenomeWise9 Wise2_full_dc_GenomeWise9 boolean Wise2_do_dc_single_pass_GenomeWise9(GenomeWise9 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_GenomeWise9 Wise2_do_dc_single_pass_GenomeWise9 void Wise2_push_dc_at_merge_GenomeWise9(GenomeWise9 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_GenomeWise9 Wise2_push_dc_at_merge_GenomeWise9 void Wise2_follow_on_dc_GenomeWise9(GenomeWise9 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_GenomeWise9 Wise2_follow_on_dc_GenomeWise9 void Wise2_run_up_dc_GenomeWise9(GenomeWise9 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_GenomeWise9 Wise2_run_up_dc_GenomeWise9 void Wise2_init_dc_GenomeWise9(GenomeWise9 * mat); #define init_dc_GenomeWise9 Wise2_init_dc_GenomeWise9 int Wise2_start_end_find_end_GenomeWise9(GenomeWise9 * mat,int * endj); #define start_end_find_end_GenomeWise9 Wise2_start_end_find_end_GenomeWise9 boolean Wise2_dc_optimised_start_end_calc_GenomeWise9(GenomeWise9 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_GenomeWise9 Wise2_dc_optimised_start_end_calc_GenomeWise9 void Wise2_init_start_end_linear_GenomeWise9(GenomeWise9 * mat); #define init_start_end_linear_GenomeWise9 Wise2_init_start_end_linear_GenomeWise9 AlnConvertSet * Wise2_AlnConvertSet_GenomeWise9(void); #define AlnConvertSet_GenomeWise9 Wise2_AlnConvertSet_GenomeWise9 int Wise2_GenomeWise9_explicit_access_main(GenomeWise9 * mat,int i,int j,int state); #define GenomeWise9_explicit_access_main Wise2_GenomeWise9_explicit_access_main int Wise2_GenomeWise9_explicit_access_special(GenomeWise9 * mat,int i,int j,int state); #define GenomeWise9_explicit_access_special Wise2_GenomeWise9_explicit_access_special int Wise2_find_end_GenomeWise9(GenomeWise9 * mat,int * ri,int * rj,int * state,boolean * isspecial,GenomeWise9_access_func_holder h); #define find_end_GenomeWise9 Wise2_find_end_GenomeWise9 void Wise2_GenomeWise9_debug_show_matrix(GenomeWise9 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define GenomeWise9_debug_show_matrix Wise2_GenomeWise9_debug_show_matrix int Wise2_max_calc_GenomeWise9(GenomeWise9 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GenomeWise9_access_func_holder h); #define max_calc_GenomeWise9 Wise2_max_calc_GenomeWise9 int Wise2_max_calc_special_GenomeWise9(GenomeWise9 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GenomeWise9_access_func_holder h); #define max_calc_special_GenomeWise9 Wise2_max_calc_special_GenomeWise9 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/threestatedb.dy0000644000175000001440000003436607611245646017166 0ustar philippusers %{ #include "threestatemodel.h" #include "pfamhmmer1db.h" typedef enum { TSMDB_UNKNOWN, TSMDB_SINGLE, TSMDB_HMMER1PFAM, TSMDB_PROTEIN, TSMDB_GENERIC } TSMDB_Type; %} friend ThreeStateDB friend PfamHmmer1DB struct ThreeStateDB int dbtype !def="TSMDB_UNKNOWN" char * filename int type !def="TSM_default" !hidden FILE * current_file !link !def="NULL" RandomModel * rm // NB, this is hard-linked... long byte_position // this is the file position for the current model ThreeStateModel * single // for single db cases PfamHmmer1DB * phdb // for Pfam Hmmer1 style databases. SequenceDB * sdb // for protein databases CompMat * comp // for protein databases int gap // for protein databases int ext // for protein databases Sequence * seq_cache // needed for a bit of inter-function communication ThreeStateModel * (*reload_generic)(ThreeStateDB * tdb,int * return_status) !func // for generic parsing applications... boolean (*open_generic)(ThreeStateDB * tdb) !func boolean (*close_generic)(ThreeStateDB * tdb) !func boolean (*dataentry_add)(ThreeStateDB * tdb,DataEntry * en) !func boolean (*open_index_generic)(ThreeStateDB *tdb) !func ThreeStateModel * (*index_generic)(ThreeStateDB *tdb,DataEntry *de) !func boolean (*close_index_generic)(ThreeStateDB *tdb) !func void * data !link // whatever else the damn system wants to carry around with it! int hmm_model_start !def="-1" int hmm_model_end !def="-1" int current_no !def="0" %info ThreeStateDB is the object that represents a database of profile-HMMs. The object hold a variety of fields on some of which are occupied depending on the type. Realistically we need a more abstract class idea, which is implemented here anyway via the generic stuff, in hacky C-style pointers to function plus a void pointer. This object therefore houses a switch system around the different types including the generic system... but as the generic function stuff was bolted on later, some things are handled with explicit datastructures. It is quite messy ;). Apologies. To be cleaned up. The generic stuff was principly added in to allow a decoupling of this module from the HMMer2.o interface code which is held in wise2xhmmer.dy The old static datastructure code can be made via protein sequences which are then converted or a Pfam 2.0 style directory + HMMs file. %% api ThreeStateDB object ThreeStateDB des free_ThreeStateDB func indexed_ThreeStateModel_ThreeStateDB func new_proteindb_ThreeStateDB func new_PfamHmmer1DB_ThreeStateDB func new_single_ThreeStateDB endobject endapi %{ #include "threestatedb.h" %func opens database ready for calls to /indexed_ThreeStateModel_ThreeStateDB %arg mdb database to open for index calls %% boolean open_for_indexing_ThreeStateDB(ThreeStateDB * mdb) { switch(mdb->dbtype) { case TSMDB_SINGLE : return TRUE; case TSMDB_HMMER1PFAM : return TRUE; /* name is the index! */ case TSMDB_PROTEIN : return TRUE; /* sequence db's don't need opening for indexing */ case TSMDB_GENERIC : return ((*mdb->open_index_generic)(mdb)); default : warn("Unknown threestatemodel db type."); return FALSE; } } %func closes an indexable database %% boolean close_for_indexing_ThreeStateDB(ThreeStateDB * mdb) { switch(mdb->dbtype) { case TSMDB_GENERIC : return ((*mdb->close_index_generic)(mdb)); default : return TRUE; } } %func Set the search type of this threestatedb... %arg type to set can be any of the modes found in threestatemodel %% boolean set_search_type_ThreeStateDB(ThreeStateDB * tdb,char * type) { int ret; ret = threestatemodel_mode_from_string(type); if( ret == TSM_unknown ) { /* warning already issued */ return FALSE; } tdb->type = ret; return TRUE; } %func Retrieves a model from a database which has been opened for indexing by /open_for_indexing_ThreeStateDB The index information comes from the dataentry which should have been from a search of the ThreeStateDB. %simple indexed_model %arg mdb database where this is indexed en dataentry to pull the model from %% ThreeStateModel * indexed_ThreeStateModel_ThreeStateDB(ThreeStateDB * mdb,DataEntry * en) { Sequence * seq; Protein * pro; ThreeStateModel * tsm; switch(mdb->dbtype) { case TSMDB_SINGLE : return hard_link_ThreeStateModel(mdb->single); case TSMDB_HMMER1PFAM : tsm = ThreeStateModel_from_name_PfamHmmer1DB(mdb->phdb,en->name); set_startend_policy_ThreeStateModel(tsm,mdb->type,30,0.2); return tsm; case TSMDB_PROTEIN : seq = get_Sequence_from_SequenceDB(mdb->sdb,en); if( seq == NULL ) { warn("could not retrieve %s as a sequence from database",en->name); return NULL; } pro = Protein_from_Sequence(seq); if( pro == NULL ) { warn("Could not convert sequence to a protein. Exiting!"); return NULL; } /* convert protein to threestatemodel */ tsm = ThreeStateModel_from_half_bit_Sequence(pro,mdb->comp,mdb->rm,mdb->gap,mdb->ext); if( tsm == NULL ) { warn("Could not convert protein to threestatemode. Exiting!"); free_Protein(pro); return NULL; } free_Protein(pro); /* DB status already set by seqdb */ return tsm; case TSMDB_GENERIC : tsm = ((*mdb->index_generic)(mdb,en)); if( tsm == NULL ) { return NULL; } /* fprintf(stdout,"Setting %d as policy\n",mdb->type); */ set_startend_policy_ThreeStateModel(tsm,mdb->type,30,0.2); return tsm; default : warn("Unknown threestatedb type"); return NULL; } warn("Should never get here - in threestatedb reload!"); return NULL; } %func makes a new ThreeStateDB from a sequencedb (better be protein!) %arg sdb r sequence database to use comp r comparison matrix to use gap r gap open penalty ext r gap extensions penalty %% ThreeStateDB * new_proteindb_ThreeStateDB(SequenceDB * sdb,CompMat * comp,int gap,int ext) { ThreeStateDB * out; out = ThreeStateDB_alloc(); out->sdb = hard_link_SequenceDB(sdb); out->comp = hard_link_CompMat(comp); out->gap = gap; out->ext = ext; out->rm = default_RandomModel(); out->dbtype = TSMDB_PROTEIN; return out; } %func Making a new ThreeStateDB from a single model %arg tsm r a single ThreeStateModel rm r random model to be used in comparisons.. %% ThreeStateDB * new_single_ThreeStateDB(ThreeStateModel * tsm,RandomModel * rm) { ThreeStateDB * out; out = ThreeStateDB_alloc(); out->single = hard_link_ThreeStateModel(tsm); if( tsm->rm == NULL ) out->rm = hard_link_RandomModel(rm); else out->rm = hard_link_RandomModel(tsm->rm); out->dbtype = TSMDB_SINGLE; return out; } %func Makes a new PfamHmmer1DB from a filename indicating the directory %% ThreeStateDB * new_PfamHmmer1DB_ThreeStateDB(char * dirname) { ThreeStateDB * out; out = ThreeStateDB_alloc(); out->phdb = PfamHmmer1DB_from_dirname(dirname); out->dbtype = TSMDB_HMMER1PFAM; return out; } %func This function adds the internal entry information (eg indexing point) into the dataentry %% boolean dataentry_add_ThreeStateDB(DataEntry * de,ThreeStateScore * tss,ThreeStateDB * mdb) { switch(mdb->dbtype) { case TSMDB_SINGLE : de->name = stringalloc(mdb->single->name); return TRUE; case TSMDB_HMMER1PFAM : if( tss == NULL ) { } else { de->name = stringalloc(tss->name); } return TRUE; case TSMDB_PROTEIN : add_SequenceDB_info_DataEntry(mdb->sdb,de); return TRUE; case TSMDB_GENERIC : if( (*mdb->dataentry_add)(mdb,de) == FALSE ) { warn("Could not add dataentry info to the entry %s",tss->name); return FALSE; } else { return TRUE; } default : warn("Unknown threestatedb type"); return FALSE; } return TRUE; } %func Open function for ThreeStateDB. An internal for this file but also used by, for example, GeneWiseDB that wants to get at the underlying models, not the log-odds. %% boolean open_ThreeStateDB(ThreeStateDB * mdb) { int ret; int return_status; ThreeStateModel * temp; int count; mdb->current_no = 0; switch( mdb->dbtype ) { case TSMDB_SINGLE : return TRUE; /* should be fine! */ case TSMDB_HMMER1PFAM : if( mdb->phdb == NULL ) { warn("No hmmer1 db to open for threestatedb!"); return FALSE; } mdb->phdb->cur = 0; break; case TSMDB_PROTEIN : if( mdb->sdb == NULL ) { warn("Attempting to open a protein tsm with no sequence db!"); return FALSE; } mdb->seq_cache = init_SequenceDB(mdb->sdb,&ret); if( ret == DB_RETURN_ERROR ) { return FALSE; } if( ret == DB_RETURN_END ) { warn("Due to some bad coding, can't cope with single protein databases in tsmdbs. oooops!"); } break; case TSMDB_GENERIC : ((*mdb->open_generic)(mdb)); break; default : warn("Got an unrecognisable tsm db type in opening tsm %d",mdb->dbtype); return FALSE; } if( mdb->hmm_model_start != -1 && mdb->hmm_model_end != -1 ) { for(count=0;counthmm_model_start;count++) { temp = read_TSM_ThreeStateDB(mdb,&return_status); free_ThreeStateModel(temp); } } return TRUE; } %func Reads a threestatemodel out from the database. People will probably want the ThreeStateScore *not* the model, but some systems will want the model. %% ThreeStateModel * read_TSM_ThreeStateDB(ThreeStateDB * mdb,int * return_status) { ThreeStateModel * tsm; Protein * pro; Sequence * seq; if( mdb->hmm_model_end != -1 && mdb->current_no == mdb->hmm_model_end ) { *return_status = DB_RETURN_END; return NULL; } mdb->current_no++; switch( mdb->dbtype ) { case TSMDB_SINGLE : *return_status = DB_RETURN_END; if( mdb->single->rm == NULL ) { warn("Threestate model without an internal random model!"); mdb->single->rm = hard_link_RandomModel(mdb->rm); } return hard_link_ThreeStateModel(mdb->single); case TSMDB_HMMER1PFAM : tsm= read_next_TSM_PfamHmmer1DB(mdb->phdb,return_status); set_startend_policy_ThreeStateModel(tsm,mdb->type,30,0.2); return tsm; case TSMDB_PROTEIN : if( mdb->seq_cache != NULL ) { /* just after an open. Should actually use this sequence, and flush the cache */ pro = Protein_from_Sequence(hard_link_Sequence(mdb->seq_cache)); mdb->seq_cache = free_Sequence(mdb->seq_cache); *return_status = DB_RETURN_OK; } else { /* reload a sequence from a database */ seq = reload_SequenceDB(NULL,mdb->sdb,return_status); /* exit now if error */ if( *return_status == DB_RETURN_ERROR ) { return NULL; /* might have leaked memory. Ugh! */ } /* if we get NULL... for the moment, silent flag end */ if( seq == NULL ) { *return_status = DB_RETURN_END; return NULL; } pro = Protein_from_Sequence(seq); } if( pro == NULL ) { warn("Could not convert sequence to a protein. Exiting!"); *return_status = DB_RETURN_ERROR; return NULL; } /* convert protein to threestatemodel */ tsm = ThreeStateModel_from_half_bit_Sequence(pro,mdb->comp,mdb->rm,mdb->gap,mdb->ext); if( tsm == NULL ) { warn("Could not convert protein to threestatemode. Exiting!"); free_Protein(pro); *return_status = DB_RETURN_ERROR; return NULL; } /* DB status already set by seqdb */ return tsm; case TSMDB_GENERIC : tsm = ((*mdb->reload_generic)(mdb,return_status)); if( tsm == NULL ) { return NULL; /* means end of database */ } set_startend_policy_ThreeStateModel(tsm,mdb->type,30,0.2); return tsm; default : warn("Got an unrecognisable tsm db type in read-load"); return NULL; } } %func Init function for ThreeStateDB Is going to open file, read first model, complain if NULL, and convert to a score system. %arg mdb rw Model database return_status w return from database.h system %% ThreeStateScore * init_ThreeStateDB(ThreeStateDB * mdb,int * return_status) { ThreeStateModel * tsm; ThreeStateScore * tss; if( open_ThreeStateDB(mdb) == FALSE) { warn("Could not open ThreeStateDB, hence could not init it!"); *return_status = DB_RETURN_ERROR; return NULL; } tsm = read_TSM_ThreeStateDB(mdb,return_status); if( *return_status == DB_RETURN_ERROR) return NULL; set_startend_policy_ThreeStateModel(tsm,mdb->type,30,0.2); fold_RandomModel_into_ThreeStateModel(tsm,mdb->rm); tss = ThreeStateScore_from_ThreeStateModel(tsm); free_ThreeStateModel(tsm); *return_status = DB_RETURN_OK; return tss; } %func reloads the ThreeStateDB. Frees the previous score system (could recycle memory). Reads database. calls END if gets NULL from read_HMF_ThreeStateModel %arg tss the previous score system mdb model database system return_status w return from database.h system %% ThreeStateScore * reload_ThreeStateDB(ThreeStateScore * prev,ThreeStateDB * mdb,int * return_status) { ThreeStateModel * tsm; ThreeStateScore * tss; free_ThreeStateScore(prev); if( mdb->dbtype == TSMDB_SINGLE ) { *return_status = DB_RETURN_END; return NULL; } tsm = read_TSM_ThreeStateDB(mdb,return_status); if( *return_status != DB_RETURN_OK) return NULL; set_startend_policy_ThreeStateModel(tsm,mdb->type,30,0.2); fold_RandomModel_into_ThreeStateModel(tsm,mdb->rm); tss = ThreeStateScore_from_ThreeStateModel(tsm); free_ThreeStateModel(tsm); *return_status = DB_RETURN_OK; return tss; } %func closes ThreeStateDB At the moment, only needs to free previous and close the file %arg prev the last ThreeStateScore to be freed mdb Model database %% boolean close_ThreeStateDB(ThreeStateScore * prev,ThreeStateDB * mdb) { if( prev != NULL ) free_ThreeStateScore(prev); if( mdb == NULL ) { warn("Trying to close a NULL threestatedb - considering this an error!"); return FALSE; } switch(mdb->dbtype) { case TSMDB_SINGLE : return TRUE; case TSMDB_HMMER1PFAM : fclose(mdb->current_file); mdb->current_file = NULL; return TRUE; /* name is the index! */ case TSMDB_PROTEIN : close_SequenceDB(NULL,mdb->sdb); return TRUE; /* sequence db's don't need opening for indexing */ case TSMDB_GENERIC : return ((*mdb->close_index_generic)(mdb)); default : warn("Unknown threestatemodel db type."); return FALSE; } warn("Should never get here!"); return FALSE; } %} wise-2.4.1/src/models/threestatedb.xs0000644000175000001440000000367510670453715017200 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::ThreeStateDB Wise2_ThreeStateModel * indexed_model(mdb,en) Wise2_ThreeStateDB * mdb Wise2_DataEntry * en CODE: RETVAL = Wise2_indexed_ThreeStateModel_ThreeStateDB(mdb,en); OUTPUT: RETVAL Wise2_ThreeStateDB * new_proteindb_ThreeStateDB(sdb,comp,gap,ext) Wise2_SequenceDB * sdb Wise2_CompMat * comp int gap int ext CODE: RETVAL = Wise2_new_proteindb_ThreeStateDB(sdb,comp,gap,ext); OUTPUT: RETVAL Wise2_ThreeStateDB * new_PfamHmmer1DB_ThreeStateDB(dirname) char * dirname CODE: RETVAL = Wise2_new_PfamHmmer1DB_ThreeStateDB(dirname); OUTPUT: RETVAL Wise2_ThreeStateDB * new_single_ThreeStateDB(tsm,rm) Wise2_ThreeStateModel * tsm Wise2_RandomModel * rm CODE: RETVAL = Wise2_new_single_ThreeStateDB(tsm,rm); OUTPUT: RETVAL Wise2_ThreeStateDB * hard_link_ThreeStateDB(obj) Wise2_ThreeStateDB * obj CODE: RETVAL = Wise2_hard_link_ThreeStateDB(obj); OUTPUT: RETVAL Wise2_ThreeStateDB * alloc() CODE: RETVAL = Wise2_ThreeStateDB_alloc(); OUTPUT: RETVAL boolean set_dbtype(obj,dbtype) Wise2_ThreeStateDB * obj int dbtype CODE: RETVAL = Wise2_replace_dbtype_ThreeStateDB(obj,dbtype); OUTPUT: RETVAL int dbtype(obj) Wise2_ThreeStateDB * obj CODE: RETVAL = Wise2_access_dbtype_ThreeStateDB(obj); OUTPUT: RETVAL boolean set_filename(obj,filename) Wise2_ThreeStateDB * obj char * filename CODE: RETVAL = Wise2_replace_filename_ThreeStateDB(obj,Wise2_stringalloc(filename)); OUTPUT: RETVAL char * filename(obj) Wise2_ThreeStateDB * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_filename_ThreeStateDB(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_ThreeStateDB * new(class) char * class PPCODE: Wise2_ThreeStateDB * out; out = Wise2_ThreeStateDB_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_ThreeStateDB * obj CODE: Wise2_free_ThreeStateDB(obj); MODULE = Wise2 PACKAGE = Wise2 wise-2.4.1/src/models/threestatedp.dy0000644000175000001440000000336007454524263017172 0ustar philippusers %{ #include "threestatemodel.h" %} matrix ThreeStateProtein query type="ThreeStateScore*" name="query" target type="PROTEIN" name="target" state MATCH offi="1" offj="1" calc="query->unit[i]->match[AMINOACID(target,j)]" source MATCH calc="query->unit[i]->trans[TSM_MATCH2MATCH]" endsource source INSERT calc="query->unit[i]->trans[TSM_INSERT2MATCH]" endsource source DELETE calc="query->unit[i]->trans[TSM_DELETE2MATCH]" endsource source START calc="query->unit[i]->trans[TSM_START2MATCH]" endsource query_label SEQUENCE target_label SEQUENCE endstate state INSERT offi="0" offj="1" calc="query->unit[i]->insert[AMINOACID(target,j)]" source MATCH calc="query->unit[i]->trans[TSM_MATCH2INSERT]" endsource source INSERT calc="query->unit[i]->trans[TSM_INSERT2INSERT]" endsource source DELETE calc="query->unit[i]->trans[TSM_DELETE2INSERT]" endsource source START calc="query->unit[i]->trans[TSM_START2INSERT]" endsource query_label INSERT target_label SEQUENCE endstate state DELETE offi="1" offj="0" source MATCH calc="query->unit[i]->trans[TSM_MATCH2DELETE]" endsource source INSERT calc="query->unit[i]->trans[TSM_INSERT2DELETE]" endsource source DELETE calc="query->unit[i]->trans[TSM_DELETE2DELETE]" endsource source START calc="query->unit[i]->trans[TSM_START2DELETE]" endsource query_label SEQUENCE target_label INSERT endstate state START !special !start endstate state END !special !end source MATCH calc="query->unit[i]->trans[TSM_MATCH2END]" endsource source INSERT calc="query->unit[i]->trans[TSM_INSERT2END]" endsource source DELETE calc="query->unit[i]->trans[TSM_DELETE2END]" endsource query_label END target_label END endstate endmatrix wise-2.4.1/src/models/largeblockdp.dy0000644000175000001440000000361410045364634017123 0ustar philippusers %{ #include "dyna.h" %} matrix LargeBlockAligner query type="DNA" name="q" target type="DNA" name="t" resource type="DNACOMPMAT" name="dm" resource type="Score" name="real_ext" resource type="Score" name="block_open" resource type="Score" name="un_dual" resource type="Score" name="un_single" resource type="Score" name="gap_open" resource type="Score" name="gap_ext" state MATCH offi="1" offj="1" source MATCH calc="0" endsource source INSERT calc="0" endsource source DELETE calc="0" endsource source UNMATCHED calc="block_open" endsource source START calc="block_open" endsource calc="DNABASEMATCH(dm,DNA_BASE(q,i),DNA_BASE(t,j))+real_ext" query_label SEQUENCE target_label SEQUENCE endstate state INSERT offi="0" offj="1" source MATCH calc="gap_open" endsource source INSERT calc="gap_ext" endsource query_label INSERT target_label SEQUENCE endstate state DELETE offi="1" offj="0" source MATCH calc="gap_open" endsource source DELETE calc="gap_ext" endsource query_label SEQUENCE target_label INSERT endstate state UNMATCHED source MATCH offi="1" offj="1" calc="un_dual" endsource source START offi="1" offj="1" calc="un_dual" endsource source UNMATCHED offi="1" offj="1" calc="un_dual" endsource source UNMATCHED offi="0" offj="1" calc="un_single" query_label INSERT endsource source UNMATCHED offi="1" offj="0" calc="un_single" target_label INSERT endsource query_label UNMATCHED_SEQUENCE target_label UNMATCHED_SEQUENCE endstate state START !special !start endstate state END !special !end source MATCH calc="0" endsource query_label END target_label END source UNMATCHED calc="0" endsource query_label END target_label END endstate endmatrix %{ #include "largeblockdp.h" %} wise-2.4.1/src/models/genephase6.dy0000644000175000001440000002636110577565051016531 0ustar philippusers/* Last edited: Mar 11 16:47 1997 (birney) */ %{ #include "dyna.h" #include "geneparser4.h" #include "genewisemodeldb.h" #include "phasemodel.h" %} matrix GenePhase6 query type="GenePhaseScore*" name="query" field:len="len" target type="GENOMIC" name="target" resource type="GeneParser4Score *" name="gp" resource type="GeneralGeneModelScore *" name="general_model" extern name="GW_*" type="int" extern name="GP4_*" type="int" globaldefaultscore NEGI state MATCH offi="1" offj="3" calc="GENOMIC_CDS_POT(target,j)" source MATCH calc="query->gws->seg[i]->transition[GW_MATCH2MATCH] + query->gws->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->gws->seg[i]->transition[GW_INSERT2MATCH] + query->gws->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source DELETE calc="query->gws->seg[i]->transition[GW_DELETE2MATCH] + query->gws->seg[i]->match[GENOMIC_CODON(target,j)]" endsource source START calc="query->gws->seg[i]->transition[GW_START2MATCH] + query->gws->seg[i]->match[GENOMIC_CODON(target,j)] + general_model->start->codon[GENOMIC_CODON(target,j)]" endsource source BEFORE_MATCH_CODING calc="query->gws->seg[i]->transition[GW_START2MATCH] + query->gws->seg[i]->match[GENOMIC_CODON(target,j)]" endsource # source INTRON_0 offi="1" offj="6" calc="query->gws->seg[i]->match[GENOMIC_CODON(target,j)]+GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source INTRON_1 offi="1" offj="5" calc="GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source INTRON_2 offi="1" offj="4" calc="GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource # # Sequencing error transitions, at offsets 1,2,4,5 for delete 1,2 or insert 1,2 # source MATCH offi="1" offj="2" calc="gp->transition[GP4_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="1" calc="gp->transition[GP4_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="4" calc="gp->transition[GP4_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source MATCH offi="1" offj="5" calc="gp->transition[GP4_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource query_label MATCH_STATE target_label CODON endstate # state INSERT offi="0" offj="3" calc="GENOMIC_CDS_POT(target,j)" source MATCH calc="query->gws->seg[i]->transition[GW_MATCH2INSERT] + query->gws->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source INSERT calc="query->gws->seg[i]->transition[GW_INSERT2INSERT] + query->gws->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source DELETE calc="query->gws->seg[i]->transition[GW_DELETE2INSERT] + query->gws->seg[i]->insert[GENOMIC_CODON(target,j)]" endsource source LOOP calc="query->gws->seg[i]->transition[GW_START2INSERT] + query->gws->seg[i]->insert[GENOMIC_CODON(target,j)] + gp->transition[GP4_LOOP2MODEL]" endsource # # phase 0,1,2 introns can calculate whole amino acid for 0. # source INTRON_0 offi="0" offj="6" calc="query->gws->seg[i]->match[GENOMIC_CODON(target,j)]+GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source INTRON_1 offi="0" offj="5" calc="GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source INTRON_2 offi="0" offj="4" calc="GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource # # Sequencing error transitions: because insertions are "for free" usually, we will # only model sequence deletion here. Could produce odd results though! # source INSERT offi="0" offj="2" calc="gp->transition[GP4_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="1" calc="gp->transition[GP4_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="query->gws->seg[i]->transition[GW_MATCH2DELETE]" endsource source INSERT calc="query->gws->seg[i]->transition[GW_INSERT2DELETE]" endsource source DELETE calc="query->gws->seg[i]->transition[GW_DELETE2DELETE]" endsource query_label DELETE_STATE target_label INSERT endstate # # Intron state: 3 separate phases, and merge INSERT/MATCH information # state INTRON_0 offi="0" offj="1" source MATCH offj="8" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)+query->phase[i]->intron_0" target_label 5SS_PHASE_0 endsource source INSERT offj="8" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)+query->phase[i]->insert_intron" target_label 5SS_PHASE_0 endsource source INTRON_0 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state INTRON_1 offi="0" offj="1" source MATCH offj="9" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)+query->phase[i]->intron_1" target_label 5SS_PHASE_1 endsource source INSERT offj="9" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)+query->phase[i]->insert_intron" target_label 5SS_PHASE_1 endsource source INTRON_1 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state INTRON_2 offi="0" offj="1" source MATCH offj="10" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)+query->phase[i]->intron_2" target_label 5SS_PHASE_2 endsource source INSERT offj="10" offi="0" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)+query->phase[i]->insert_intron" target_label 5SS_PHASE_2 endsource source INTRON_2 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label INTRON_STATE endstate state LOOP !special source START offj="1" !left calc="0" endsource source MATCH calc="query->gws->seg[i]->transition[GW_MATCH2END]" endsource source INSERT calc="query->gws->seg[i]->transition[GW_INSERT2END]" endsource source DELETE calc="query->gws->seg[i]->transition[GW_DELETE2END]" endsource source LOOP offj="1" calc="gp->transition[GP4_LOOP2LOOP]" endsource query_label LOOP_STATE target_label RANDOM_SEQUENCE endstate state START !start !special defscore="0" endstate state END !end !special source LOOP offj="1" !right calc="0" endsource source AFTER_MATCH_CODING offj="3" calc="general_model->stop->codon[GENOMIC_CODON(target,j)]" endsource target_label END query_label END endstate state BEFORE_MATCH_CODING !special source START offj="3" calc="general_model->start->codon[GENOMIC_CODON(target,j)]" endsource source BEFORE_MATCH_CODING offj="3" calc="general_model->general->codon[GENOMIC_CODON(target,j)]" endsource source BEFORE_MATCH_INTRON_0 offj="6" calc="GENOMIC_3SS(target,j-3)" target_label 3SS_PHASE_0 endsource source BEFORE_MATCH_INTRON_1 offj="5" calc="GENOMIC_3SS(target,j-2)" target_label 3SS_PHASE_1 endsource source BEFORE_MATCH_INTRON_2 offj="4" calc="GENOMIC_3SS(target,j-1)" target_label 3SS_PHASE_2 endsource target_label CODON query_label BEFORE_MATCH endstate state BEFORE_MATCH_INTRON_0 !special source BEFORE_MATCH_CODING offj="1" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j)" target_label 5SS_PHASE_0 endsource source BEFORE_MATCH_INTRON_0 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label BEFORE_MATCH_INTRON endstate state BEFORE_MATCH_INTRON_1 !special source BEFORE_MATCH_CODING offj="9" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_1 endsource source BEFORE_MATCH_INTRON_1 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label BEFORE_MATCH_INTRON endstate state BEFORE_MATCH_INTRON_2 !special source BEFORE_MATCH_CODING offj="10" calc="gp->intron[GENOMIC_BASE(target,j)]+GENOMIC_5SS(target,j-7)" target_label 5SS_PHASE_2 endsource source BEFORE_MATCH_INTRON_2 offj="1" calc="gp->intron[GENOMIC_BASE(target,j)] + gp->transition[GP4_INTRON2INTRON]" target_label CENTRAL_INTRON endsource query_label BEFORE_MATCH_INTRON endstate state AFTER_MATCH_CODING !special source MATCH calc="query->gws->seg[i]->transition[GW_MATCH2END]" endsource source AFTER_MATCH_CODING offj="3" calc="general_model->general->codon[GENOMIC_CODON(target,j)]" endsource target_label CODON query_label AFTER_MATCH endstate # # collapse Intron labels! # collapse INTRON_STATE CENTRAL_INTRON collapse BEFORE_MATCH_INTRON CENTRAL_INTRON collapse AFTER_MATCH_INTRON CENTRAL_INTRON collapse LOOP_STATE RANDOM_SEQUENCE endmatrix %{ #include "genephase6.h" AlnBlock * AlnBlock_from_phased_protein_wrap(Protein * pro,ThreeStateModel * tsm,Genomic * gen,CodonMapper * cm,RandomModel * rm,CompMat * mat,PhasedProteinPara * ppp,GeneParameter21 * gpara,DPRunImpl * dpri,PackAln ** palret) { PackAln * pal; AlnBlock * alb; GeneParser21Score * gp21s; GeneParser4Score * gp4s; ComplexSequence * cs; ThreeStateModel * tsmin; GeneralGeneModelScore * ggms; GenePhaseModel * gpm; GenePhaseScore * gps; int i; assert(gen != NULL); assert(ppp != NULL); ggms = vanilla_GeneralGeneModelScore(gpara->ct,Bits2Probability(10),1.0,Bits2Probability(10)); if( tsm == NULL ) { if( pro == NULL ) { warn("Major problem - neither a protein nor a tsm passed into phase model"); return NULL; } tsmin = ThreeStateModel_alloc_len(pro->baseseq->len); if( pro->baseseq->name != NULL ) tsmin->name = stringalloc(pro->baseseq->name); else tsmin->name = stringalloc("NoName"); tsmin->rm = hard_link_RandomModel(rm); for(i=0;ibaseseq->len;i++) { add_ThreeStateModel(tsmin,ThreeStateUnit_from_half_bit_aminoacid(pro->baseseq->seq[i],mat,rm,ppp->gap,ppp->ext)); } } else { tsmin = hard_link_ThreeStateModel(tsm); } gpm = GenePhaseModel_from_ThreeStateModel(tsmin,cm,rm,mat,ppp); GeneWise_fold_in_synchronised_RandomModel(gpm->gw,rm,gpara->cm,gpara->ct,0.5); gps = GenePhaseScore_from_GenePhaseModel(gpm); if( (gp21s = GeneParser21Score_from_GeneParser21(gpara->gp)) == NULL) { warn("Unable to make GeneParserScore model"); return NULL; } gp4s = GeneParser4Score_from_GeneParser21Score(gp21s); if( (cs=evaluate_ComplexSequence_Genomic(gen,gpara->cses,0,Probability2Score(0.01))) == FALSE ) { warn("Unable to make ComplexSequence in TMS2DNA wrap"); } pal = PackAln_bestmemory_GenePhase6(gps,cs,gp4s,ggms,NULL,dpri); if( palret != NULL ) { *palret = pal; } alb = convert_PackAln_to_AlnBlock_GenePhase6(pal); free_GeneralGeneModelScore(ggms); free_GenePhaseModel(gpm); free_GenePhaseScore(gps); free_ComplexSequence(cs); free_GeneParser21Score(gp21s); free_GeneParser4Score(gp4s); free_ThreeStateModel(tsm); return alb; } %} wise-2.4.1/src/models/motifdiff.c0000644000175000001440000002047210076537364016256 0ustar philippusers#include "transfactor.h" #include "transregion.h" #include "version.h" #include "commandline.h" char * program_name = "motifdiff"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s motif-library sequence\n",program_name); fprintf(ofp," -lr motif library is in laurence's format\n"); fprintf(ofp," -ben motif library is in ben's IUPAC format\n"); fprintf(ofp," -[no]show_match - show all matches that pass criteria, default no\n"); fprintf(ofp," -[no]show_region - show only dense cluster regions, default yes\n"); fprintf(ofp," -circular [no] - for randomisation, number of positions to permute\n"); show_help_TransFactorBuildPara(ofp); show_help_TransFactorMatchPara(ofp); show_standard_options(ofp); } int main(int argc,char ** argv) { TransFactorSet * tfs; TransFactorSet * newtfs; /* only used as a temp when permuting */ TransFactorBuildPara * tfb; TransFactorMatchSetCompara * comp; TransFactorMatchPara * matchp; TransFactorComparaPara * comparap; TransFactorMatchSet * one; TransFactorMatchSet * two; boolean use_laurence = FALSE; boolean use_ben = FALSE; boolean show_matchset = FALSE; boolean show_region = FALSE; boolean show_compara = TRUE; boolean show_aln = FALSE; int end_on_seq = 0; int seq_count = 0; int rotate_number = 0; int z; int is_gapped; int one_pos; int two_pos; int one_j; int two_j; int found_match; int count; int id; double perc_id; FILE * ifp; SeqAlign * sa; int i; tfb = new_TransFactorBuildPara_from_argv(&argc,argv); matchp = new_TransFactorMatchPara_from_argv(&argc,argv); matchp->min_relative = 7.0; matchp->relative_prob_bits = 0.5; matchp->relative_prob = 0.5; matchp->type = TFM_RELATIVE; strip_out_boolean_def_argument(&argc,argv,"show_match",&show_matchset); strip_out_boolean_def_argument(&argc,argv,"show_region",&show_region); strip_out_integer_argument(&argc,argv,"circular",&rotate_number); if( strip_out_boolean_argument(&argc,argv,"lr") == TRUE ) { use_laurence = TRUE; } if( strip_out_boolean_argument(&argc,argv,"ben") == TRUE ) { use_ben = TRUE; } strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 3 ) { show_help(stdout); exit(12); } if( use_laurence == TRUE ) { tfs = read_laurence_TransFactorSet_file(argv[1]); } else if( use_ben == TRUE ) { tfs = read_ben_IUPAC_TransFactorSet_file(argv[1]); } else { tfs = read_TransFactorSet_file(argv[1]); } if( tfs->len == 0 ) { fatal("No transcription factors in set!"); } build_TransFactorSet(tfs,tfb); if( rotate_number > 0 ) { fprintf(stdout,"PERMUTED RESULTS - %d rotation\n",rotate_number); newtfs = circular_permuted_TransFactorSet(tfs,rotate_number); free_TransFactorSet(tfs); tfs = newtfs; } ifp = openfile(argv[2],"r"); if( ifp == NULL ) { fatal("Cannot open %s as input file",argv[2]); } fprintf(stderr,"Getting into main loop with %s\n",argv[2]); while( (sa = read_fasta_SeqAlign(ifp)) ) { for(i=0;ilen;i++) { sa->seq[i]->type = SEQUENCE_DNA; } if( sa == NULL ) { fatal("Could not read fasta alignment in %s",argv[2]); } if( sa->len != 2 ) { fatal("Has to be a pairwise alignment"); } fprintf(stderr,"About to calculate...\n"); one = calculate_TransFactorMatchSet(sa->seq[0],tfs,matchp); fprintf(stderr,"calculated transfactor match (one)\n"); two = calculate_TransFactorMatchSet(sa->seq[1],tfs,matchp); fprintf(stderr,"calculated transfactor match (two)\n"); sort_by_start_TransFactorMatchSet(one); sort_by_start_TransFactorMatchSet(two); fprintf(stderr,"Sorted\n"); one_pos = 0; two_pos = 0; for(i=0;iseq[0]->len;i++) { auto int seen_one = 0; auto int seen_two = 0; for(one_pos; one_pos < one->len && one->match[one_pos]->start < i;one_pos++) { ; } for(two_pos; two_pos < two->len && two->match[two_pos]->start < i;two_pos++) { ; } if( one_pos < one->len && one->match[one_pos]->start == i ) { seen_one = 1; } if( two_pos < two->len && two->match[two_pos]->start == i ) { seen_two = 1; } if( show_aln && (seen_one == 1 && seen_two == 1)) { fprintf(stdout,"Position %d %d,%d\n",i,seen_one,seen_two); fprintf(stdout," %.12s\n",one->target->seq+i); fprintf(stdout," %.12s\n",two->target->seq+i); } if( seen_one == 0 && seen_two == 0 ) { continue; /* nothing to do */ } is_gapped = FALSE; z = i -3; if( z < 0 ) { z = 0; } for(;zseq[0]->len;z++) { if( is_gapped_SeqAlign(sa,z) == TRUE ) { is_gapped = TRUE; break; } } if( seen_one == seen_two ) { id = 0; count = 0; for(z=one->match[one_pos]->start;zmatch[one_pos]->end;z++) { if( toupper(sa->seq[0]->seq[z]) == toupper(sa->seq[1]->seq[z]) ) { id++; } count++; } perc_id = (double)id/(double)count; } /* fprintf(stdout," %d %d at %d,%d with %d vs %d\n",seen_one,seen_two,one_pos,two_pos,one->match[one_pos]->start,two->match[two_pos]->start);*/ if( seen_one != seen_two ) { /* must have a mismatch */ /* we no longer want to output mismatches as we are looking at relatives */ /* if( one_pos >= one->len || two_pos >= two->len ) { printf("%s Mismatch at %d AT_END\n",(is_gapped == TRUE ? "GAPPED" : "SOLID"), i); } else { printf("%s Mismatch at %d [%d,%d] %s %d %s %d\n", (is_gapped == TRUE ? "GAPPED" : "SOLID"), i,seen_one,seen_two, one->match[one_pos]->factor->name,one->match[one_pos]->start, two->match[two_pos]->factor->name,two->match[two_pos]->start ); } */ } else { /* if 1,1 still need to check. Will do this later */ if( seen_one == seen_two && seen_one == 1 ) { if( one->match[one_pos]->factor != two->match[two_pos]->factor ) { /* more than one factor can match at the same position. Need to loop*/ found_match = 0; for(one_j=one_pos;one_j < one->len && one->match[one_pos]->start == one->match[one_j]->start;one_j++) { for(two_j=two_pos;two_j < two->len && two->match[two_pos]->start == two->match[two_j]->start;two_j++ ) { if( one->match[one_j]->factor == two->match[two_j]->factor && one->match[one_j]->strand == two->match[two_j]->strand ) { found_match = 1; printf("%s %.2f SAME %d %s %d %.2f %.2f %s %d %.2f %.2f\n", (is_gapped == TRUE ? "GAPPED" : "SOLID"), perc_id, i, one->match[one_j]->factor->name,one->match[one_j]->start, one->match[one_j]->bit_score,(one->match[one_j]->bit_score - Probability2Bits(one->match[one_j]->factor->max_prob)), two->match[two_j]->factor->name,two->match[two_j]->start, two->match[two_j]->bit_score,(two->match[two_j]->bit_score - Probability2Bits(two->match[two_j]->factor->max_prob))); break; } } } if( found_match == 0 ) { /* printf("mismatch-covered %d [%d,%d] %s %d %s %d\n",i,seen_one,seen_two, one->match[one_pos]->factor->name,one->match[one_pos]->start, two->match[two_pos]->factor->name,two->match[two_pos]->start ); */ } } else { if( one->match[one_pos]->strand == two->match[two_pos]->strand ) { printf("%s %.2f SAME %d %s %d %.2f %.2f %s %d %.2f %.2f\n", (is_gapped == TRUE ? "GAPPED" : "SOLID"), perc_id, i, one->match[one_pos]->factor->name,one->match[one_pos]->start, one->match[one_pos]->bit_score,(one->match[one_pos]->bit_score - Probability2Bits(one->match[one_pos]->factor->max_prob)), two->match[two_pos]->factor->name,two->match[two_pos]->start, two->match[two_pos]->bit_score,(two->match[two_pos]->bit_score - Probability2Bits(two->match[two_pos]->factor->max_prob)) ); } } } } } } } wise-2.4.1/src/models/cdparser_api.h0000644000175000001440000000350010670453713016734 0ustar philippusers /* Functions that create, manipulate or act on cDNAParser * * Wise2_hard_link_cDNAParser * Wise2_cDNAParser_alloc * Wise2_free_cDNAParser [destructor] * */ /* Helper functions in the module * * Wise2_flat_cDNAParser * /* API for object cDNAParser */ /* Function: Wise2_hard_link_cDNAParser(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_cDNAParser *] * * Returns Undocumented return value [Wise2_cDNAParser *] * */ Wise2_cDNAParser * Wise2_hard_link_cDNAParser( Wise2_cDNAParser * obj); /* Function: Wise2_cDNAParser_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_cDNAParser *] * */ Wise2_cDNAParser * Wise2_cDNAParser_alloc(); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_cDNAParser(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_cDNAParser *] * * Returns Undocumented return value [Wise2_cDNAParser *] * */ Wise2_cDNAParser * Wise2_free_cDNAParser( Wise2_cDNAParser * obj); /* These functions are not associated with an object */ /* Function: Wise2_flat_cDNAParser(p) * * Descrip: Makes a flat (ie, indels of 1 or 2 == p) * cDNA parser. This means that insertions * and deletions of both 1 or 2 bases are * all parameterised at the same probability * * * * Arg: p probability of an indel [Probability] * * Returns Undocumented return value [Wise2_cDNAParser *] * */ Wise2_cDNAParser * Wise2_flat_cDNAParser( Probability p); wise-2.4.1/src/models/cdparser_api.t0000644000175000001440000000006310670453713016751 0ustar philippuserstypedef struct Wise2_cDNAParser Wise2_cDNAParser; wise-2.4.1/src/models/genewisehsp.c0000644000175000001440000005301310670453714016621 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genewisehsp.h" # line 36 "genewisehsp.dy" GeneWiseRunPara * new_GeneWiseRunPara_from_argv(int * argc,char ** argv) { GeneWiseRunPara * out; out = GeneWiseRunPara_alloc(); out->use_hsp = FALSE; out->edge_query = 10; out->edge_target = 3000; out->splice_spread = 5; strip_out_boolean_def_argument(argc,argv,"gwhsp",&out->use_hsp); strip_out_boolean_def_argument(argc,argv,"gwdebug",&out->debug); strip_out_integer_argument(argc,argv,"gw_edgequery",&out->edge_query); strip_out_integer_argument(argc,argv,"gw_edgetarget",&out->edge_target); strip_out_integer_argument(argc,argv,"gw_splicespread",&out->splice_spread); return out; } # line 55 "genewisehsp.dy" void show_help_GeneWiseRunPara(FILE * ofp) { fprintf(ofp,"Genewise protein running heuristics\n"); fprintf(ofp," -[no]gwhsp use heuristics for proteins [FALSE currently]\n"); fprintf(ofp," -gw_edgequery at start/end, amount of protein area to expand [10]\n"); fprintf(ofp," -gw_edgetarget at start/end, amount of DNA area to expand [3000]\n"); fprintf(ofp," -gw_splicespread spread around splice sites in codons [5]\n"); fprintf(ofp," -gwdebug print out debugging of heuristics on stdout\n"); } # line 68 "genewisehsp.dy" DPEnvelope * DPEnvelope_from_protein_gen(Sequence * prot,Sequence * dna,CompMat * mat,CodonTable * ct,GeneWiseRunPara *p) { SeqLookupInterface * sli; HSPScanInterface * hsi; HSPScanInterfacePara para; Sequence * trans; int i; int j; int frame; char * temp_seq; int can_use = 0; LinearHSPmanager * lm; GeneWiseHSPmanager * gwh; GeneWiseHSPmanager * final; DPEnvelope * out; DPUnit * dpunit; int prev_query; int prev_target; SeqLookupLoadPara loadpara; info("Using HSP based heuristic for bounds calculation. Result may not be accurate (in particular for low similarity)"); loadpara.tile_freq = 1; sli = new_ghash_SeqLookupInterface(); (*sli->add_seq)(sli->data,prot,&loadpara); hsi = new_one_off_HSPScanInterface(sli,mat,15,5); para.min_score= 10; para.max_results = 750; para.use_protein_heuristic = FALSE; gwh = GeneWiseHSPmanager_alloc_std(); for(frame=0;frame<3;frame++) { temp_seq = calloc(1+dna->len/3,sizeof(char)); for(j=0,i=frame;i+3 < dna->len;i+=3,j++) { temp_seq[j] = aminoacid_from_seq(ct,dna->seq+i); } temp_seq[j]= '\0'; trans = Sequence_alloc(); trans->name = stringalloc("temp_seq"); trans->seq = temp_seq; trans->len = strlen(temp_seq); if( p->debug ) { info("starting scan in frame %d\n",frame); } lm = (*hsi->scan_query)(hsi->data,trans,¶); if( p->debug ) { info("Retrieved %d hits in frame %d\n",lm->len,frame); } if( lm->len > 0 ) { add_GeneWiseHSPmanager_HSPset(gwh,lm->set[0],frame); } free_LinearHSPmanager(lm); } /* if this is empty, do something! */ if( gwh->len == 0 ) { info("For genewise %s vs %s, no HSPs generated, heuristic failed",prot->name,dna->name); return NULL; } /* sort by score, descend list */ sort_GeneWiseHSPmanager(gwh,compare_GeneWiseHSP_score); if( p->debug == TRUE ) { for(i=0;ilen;i++) { fprintf(stdout,"GWHSP [Before] %d,%d to %d,%d %d\n", gwh->hsp[i]->query_start, gwh->hsp[i]->query_end, gwh->hsp[i]->target_start, gwh->hsp[i]->target_end, gwh->hsp[i]->score); } } final = GeneWiseHSPmanager_alloc_std(); for(i=0;ilen;i++) { can_use = 1; for(j=0;jlen;j++) { if( consistent_GeneWiseHSP(final->hsp[j],gwh->hsp[i]) == 0 ) { can_use = 0; break; } } if( can_use == 1 ) { if( p->debug == TRUE ) { fprintf(stdout,"GWHSP accepting %d,%d to %d,%d\n", gwh->hsp[i]->query_start, gwh->hsp[i]->query_end, gwh->hsp[i]->target_start, gwh->hsp[i]->target_end ); } add_GeneWiseHSPmanager(final,hard_link_GeneWiseHSP(gwh->hsp[i])); } else { if( p->debug == TRUE ) { fprintf(stdout,"GWHSP rejecting %d,%d to %d,%d\n", gwh->hsp[i]->query_start, gwh->hsp[i]->query_end, gwh->hsp[i]->target_start, gwh->hsp[i]->target_end ); } } } out = DPEnvelope_alloc_std(); sort_GeneWiseHSPmanager(final,compare_GeneWiseHSP_start); prev_query = final->hsp[0]->query_start - p->edge_query; prev_target = final->hsp[0]->target_start - p->edge_target; if( prev_query < 0 ) { prev_query = 0; } if( prev_target < 0 ) { prev_target = 0; } for(i=0;ilen;i++) { /* rectangle from previous exon to this one */ dpunit = DPUnit_alloc(); dpunit->type = DPENV_RECT; dpunit->starti = prev_query; dpunit->startj = prev_target; dpunit->height = final->hsp[i]->query_start - dpunit->starti + p->splice_spread; dpunit->length = final->hsp[i]->target_start - dpunit->startj + p->splice_spread*3; if( dpunit->height <= 0 || dpunit->length <= 0 ) { if( p->debug ) { fprintf(stdout,"On position %d , error with the jigging %d plays %d vs %d plays %d",i, final->hsp[i]->query_start,dpunit->starti,final->hsp[i]->target_start,dpunit->startj); } if( dpunit->height <= 0 ) { dpunit->height = 1; } if( dpunit->length <= 0 ) { dpunit->length = 1; } } if( p->debug ) { fprintf(stdout,"GWHSP Bridging to %d,%d to %d,%d from %dth element with %d,%d coordinate\n", dpunit->starti, dpunit->startj, dpunit->height, dpunit->length,i,final->hsp[i]->query_start, final->hsp[i]->target_start ); } add_DPEnvelope(out,dpunit); /* rectange for this exon */ dpunit = DPUnit_alloc(); dpunit->type = DPENV_RECT; dpunit->starti = final->hsp[i]->query_start - p->splice_spread; dpunit->startj = final->hsp[i]->target_start - p->splice_spread*3;; dpunit->height = final->hsp[i]->query_end - dpunit->starti + p->splice_spread; dpunit->length = final->hsp[i]->target_end - dpunit->startj + p->splice_spread*3; if( dpunit->height <= 0 || dpunit->length <= 0 ) { fatal("On exon position %d, error with the jigging of the positions",i); } if( p->debug ) { fprintf(stdout,"GWHSP Exon: %d,%d to %d,%d from %dth element with %d,%d coordinate\n", dpunit->starti, dpunit->startj, dpunit->height, dpunit->length,i,final->hsp[i]->query_start, final->hsp[i]->target_start ); } add_DPEnvelope(out,dpunit); prev_query = final->hsp[i]->query_end - p->splice_spread; prev_target = final->hsp[i]->target_end - p->splice_spread*3; } free_GeneWiseHSPmanager(gwh); free_GeneWiseHSPmanager(final); free_HSPScanInterface(hsi); if( p->debug ) { fprintf(stdout,"GWHSP - exited with %d DP units\n",out->len); fflush(stdout); } return out; } # line 291 "genewisehsp.dy" int consistent_GeneWiseHSP(GeneWiseHSP * true,GeneWiseHSP * proposed) { int query_centre; int target_centre; assert(true); assert(proposed); /* is this left or right of the true HSP */ query_centre = (proposed->query_start + proposed->query_end) / 2; target_centre = (proposed->target_start + proposed->target_end) / 2; /* overlap criteria first */ if( query_centre >= true->query_start && query_centre <= true->query_end ) { return 0; } /* left or right */ if( query_centre > true->query_end ) { if( target_centre < true->target_end ) { /* no - inconsistent */ return 0; } } else { if( target_centre > true->target_start ) { return 0; } } /* overlap */ if( target_centre >= true->target_start && target_centre <= true->target_end ) { return 0; } return 1; } # line 331 "genewisehsp.dy" int compare_GeneWiseHSP_start(GeneWiseHSP * one,GeneWiseHSP * two) { return one->query_start - two->query_start; } /* Function: compare_GeneWiseHSP_score(one,two) * * Descrip: internal for sort by score * * * Arg: one [UNKN ] Undocumented argument [GeneWiseHSP *] * Arg: two [UNKN ] Undocumented argument [GeneWiseHSP *] * * Return [UNKN ] Undocumented return value [int] * */ # line 340 "genewisehsp.dy" int compare_GeneWiseHSP_score(GeneWiseHSP * one,GeneWiseHSP * two) { return two->score - one->score; } # line 346 "genewisehsp.dy" void add_GeneWiseHSPmanager_HSPset(GeneWiseHSPmanager * gwh,HSPset * set,int frame) { int i; GeneWiseHSP * h; for(i=0;ilen;i++) { h = GeneWiseHSP_alloc(); h->query_start = set->hsp[i]->target_start; h->query_end = set->hsp[i]->target_start+set->hsp[i]->length; h->target_start = set->hsp[i]->query_start*3 + frame; h->target_end = (set->hsp[i]->query_start+set->hsp[i]->length)*3 + frame; h->score = set->hsp[i]->score; add_GeneWiseHSPmanager(gwh,h); } } # line 344 "genewisehsp.c" /* Function: hard_link_GeneWiseRunPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseRunPara *] * * Return [UNKN ] Undocumented return value [GeneWiseRunPara *] * */ GeneWiseRunPara * hard_link_GeneWiseRunPara(GeneWiseRunPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneWiseRunPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneWiseRunPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseRunPara *] * */ GeneWiseRunPara * GeneWiseRunPara_alloc(void) { GeneWiseRunPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWiseRunPara *) ckalloc (sizeof(GeneWiseRunPara))) == NULL) { warn("GeneWiseRunPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->use_hsp = TRUE; out->edge_query = 10; out->edge_target = 3000; out->splice_spread = 4; out->debug = FALSE; return out; } /* Function: free_GeneWiseRunPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseRunPara *] * * Return [UNKN ] Undocumented return value [GeneWiseRunPara *] * */ GeneWiseRunPara * free_GeneWiseRunPara(GeneWiseRunPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneWiseRunPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_GeneWiseHSP(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseHSP *] * * Return [UNKN ] Undocumented return value [GeneWiseHSP *] * */ GeneWiseHSP * hard_link_GeneWiseHSP(GeneWiseHSP * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneWiseHSP object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneWiseHSP_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseHSP *] * */ GeneWiseHSP * GeneWiseHSP_alloc(void) { GeneWiseHSP * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWiseHSP *) ckalloc (sizeof(GeneWiseHSP))) == NULL) { warn("GeneWiseHSP_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->query_start = 0; out->query_end = 0; out->target_start = 0; out->target_end = 0; out->score = 0; out->frame = 0; return out; } /* Function: free_GeneWiseHSP(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseHSP *] * * Return [UNKN ] Undocumented return value [GeneWiseHSP *] * */ GeneWiseHSP * free_GeneWiseHSP(GeneWiseHSP * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneWiseHSP obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_GeneWiseHSPmanager(list,i,j) * * Descrip: swap function: an internal for qsort_GeneWiseHSPmanager * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [GeneWiseHSP **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_GeneWiseHSPmanager(GeneWiseHSP ** list,int i,int j) { GeneWiseHSP * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_GeneWiseHSPmanager(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_GeneWiseHSPmanager which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [GeneWiseHSP **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_GeneWiseHSPmanager(GeneWiseHSP ** list,int left,int right,int (*comp)(GeneWiseHSP * ,GeneWiseHSP * )) { int i,last; if( left >= right ) return; swap_GeneWiseHSPmanager(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_GeneWiseHSPmanager (list,++last,i); } swap_GeneWiseHSPmanager (list,left,last); qsort_GeneWiseHSPmanager(list,left,last-1,comp); qsort_GeneWiseHSPmanager(list,last+1,right,comp); } /* Function: sort_GeneWiseHSPmanager(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_GeneWiseHSPmanager * * * Arg: obj [UNKN ] Object containing list [GeneWiseHSPmanager *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_GeneWiseHSPmanager(GeneWiseHSPmanager * obj,int (*comp)(GeneWiseHSP *, GeneWiseHSP *)) { qsort_GeneWiseHSPmanager(obj->hsp,0,obj->len-1,comp); return; } /* Function: expand_GeneWiseHSPmanager(obj,len) * * Descrip: Really an internal function for add_GeneWiseHSPmanager * * * Arg: obj [UNKN ] Object which contains the list [GeneWiseHSPmanager *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_GeneWiseHSPmanager(GeneWiseHSPmanager * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_GeneWiseHSPmanager called with no need"); return TRUE; } if( (obj->hsp = (GeneWiseHSP ** ) ckrealloc (obj->hsp,sizeof(GeneWiseHSP *)*len)) == NULL) { warn("ckrealloc failed for expand_GeneWiseHSPmanager, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_GeneWiseHSPmanager(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GeneWiseHSPmanager *] * Arg: add [OWNER] Object to add to the list [GeneWiseHSP *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_GeneWiseHSPmanager(GeneWiseHSPmanager * obj,GeneWiseHSP * add) { if( obj->len >= obj->maxlen) { if( expand_GeneWiseHSPmanager(obj,obj->len + GeneWiseHSPmanagerLISTLENGTH) == FALSE) return FALSE; } obj->hsp[obj->len++]=add; return TRUE; } /* Function: flush_GeneWiseHSPmanager(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GeneWiseHSPmanager *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GeneWiseHSPmanager(GeneWiseHSPmanager * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->hsp[i] != NULL) { free_GeneWiseHSP(obj->hsp[i]); obj->hsp[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: GeneWiseHSPmanager_alloc_std(void) * * Descrip: Equivalent to GeneWiseHSPmanager_alloc_len(GeneWiseHSPmanagerLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GeneWiseHSPmanager *] * */ GeneWiseHSPmanager * GeneWiseHSPmanager_alloc_std(void) { return GeneWiseHSPmanager_alloc_len(GeneWiseHSPmanagerLISTLENGTH); } /* Function: GeneWiseHSPmanager_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GeneWiseHSPmanager *] * */ GeneWiseHSPmanager * GeneWiseHSPmanager_alloc_len(int len) { GeneWiseHSPmanager * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = GeneWiseHSPmanager_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->hsp = (GeneWiseHSP ** ) ckcalloc (len,sizeof(GeneWiseHSP *))) == NULL) { warn("Warning, ckcalloc failed in GeneWiseHSPmanager_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_GeneWiseHSPmanager(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseHSPmanager *] * * Return [UNKN ] Undocumented return value [GeneWiseHSPmanager *] * */ GeneWiseHSPmanager * hard_link_GeneWiseHSPmanager(GeneWiseHSPmanager * obj) { if( obj == NULL ) { warn("Trying to hard link to a GeneWiseHSPmanager object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GeneWiseHSPmanager_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseHSPmanager *] * */ GeneWiseHSPmanager * GeneWiseHSPmanager_alloc(void) { GeneWiseHSPmanager * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GeneWiseHSPmanager *) ckalloc (sizeof(GeneWiseHSPmanager))) == NULL) { warn("GeneWiseHSPmanager_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->hsp = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_GeneWiseHSPmanager(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseHSPmanager *] * * Return [UNKN ] Undocumented return value [GeneWiseHSPmanager *] * */ GeneWiseHSPmanager * free_GeneWiseHSPmanager(GeneWiseHSPmanager * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GeneWiseHSPmanager obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->hsp != NULL) { for(i=0;ilen;i++) { if( obj->hsp[i] != NULL) free_GeneWiseHSP(obj->hsp[i]); } ckfree(obj->hsp); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/genewisehsp.h0000644000175000001440000002216210670453714016627 0ustar philippusers#ifndef DYNAMITEgenewisehspHEADERFILE #define DYNAMITEgenewisehspHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "subseqhash.h" #include "hsplookupscan.h" #define GeneWiseHSPmanagerLISTLENGTH 1024 struct Wise2_GeneWiseRunPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif boolean use_hsp; int edge_query; int edge_target; int splice_spread; boolean debug; } ; /* GeneWiseRunPara defined */ #ifndef DYNAMITE_DEFINED_GeneWiseRunPara typedef struct Wise2_GeneWiseRunPara Wise2_GeneWiseRunPara; #define GeneWiseRunPara Wise2_GeneWiseRunPara #define DYNAMITE_DEFINED_GeneWiseRunPara #endif struct Wise2_GeneWiseHSP { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int query_start; int query_end; int target_start; int target_end; int score; int frame; } ; /* GeneWiseHSP defined */ #ifndef DYNAMITE_DEFINED_GeneWiseHSP typedef struct Wise2_GeneWiseHSP Wise2_GeneWiseHSP; #define GeneWiseHSP Wise2_GeneWiseHSP #define DYNAMITE_DEFINED_GeneWiseHSP #endif struct Wise2_GeneWiseHSPmanager { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GeneWiseHSP ** hsp; int len;/* len for above hsp */ int maxlen; /* maxlen for above hsp */ } ; /* GeneWiseHSPmanager defined */ #ifndef DYNAMITE_DEFINED_GeneWiseHSPmanager typedef struct Wise2_GeneWiseHSPmanager Wise2_GeneWiseHSPmanager; #define GeneWiseHSPmanager Wise2_GeneWiseHSPmanager #define DYNAMITE_DEFINED_GeneWiseHSPmanager #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_GeneWiseRunPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseRunPara *] * * Return [UNKN ] Undocumented return value [GeneWiseRunPara *] * */ GeneWiseRunPara * Wise2_hard_link_GeneWiseRunPara(GeneWiseRunPara * obj); #define hard_link_GeneWiseRunPara Wise2_hard_link_GeneWiseRunPara /* Function: GeneWiseRunPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseRunPara *] * */ GeneWiseRunPara * Wise2_GeneWiseRunPara_alloc(void); #define GeneWiseRunPara_alloc Wise2_GeneWiseRunPara_alloc /* Function: free_GeneWiseRunPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseRunPara *] * * Return [UNKN ] Undocumented return value [GeneWiseRunPara *] * */ GeneWiseRunPara * Wise2_free_GeneWiseRunPara(GeneWiseRunPara * obj); #define free_GeneWiseRunPara Wise2_free_GeneWiseRunPara /* Function: hard_link_GeneWiseHSP(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseHSP *] * * Return [UNKN ] Undocumented return value [GeneWiseHSP *] * */ GeneWiseHSP * Wise2_hard_link_GeneWiseHSP(GeneWiseHSP * obj); #define hard_link_GeneWiseHSP Wise2_hard_link_GeneWiseHSP /* Function: GeneWiseHSP_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseHSP *] * */ GeneWiseHSP * Wise2_GeneWiseHSP_alloc(void); #define GeneWiseHSP_alloc Wise2_GeneWiseHSP_alloc /* Function: free_GeneWiseHSP(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseHSP *] * * Return [UNKN ] Undocumented return value [GeneWiseHSP *] * */ GeneWiseHSP * Wise2_free_GeneWiseHSP(GeneWiseHSP * obj); #define free_GeneWiseHSP Wise2_free_GeneWiseHSP /* Function: add_GeneWiseHSPmanager(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GeneWiseHSPmanager *] * Arg: add [OWNER] Object to add to the list [GeneWiseHSP *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_GeneWiseHSPmanager(GeneWiseHSPmanager * obj,GeneWiseHSP * add); #define add_GeneWiseHSPmanager Wise2_add_GeneWiseHSPmanager /* Function: flush_GeneWiseHSPmanager(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GeneWiseHSPmanager *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_GeneWiseHSPmanager(GeneWiseHSPmanager * obj); #define flush_GeneWiseHSPmanager Wise2_flush_GeneWiseHSPmanager /* Function: GeneWiseHSPmanager_alloc_std(void) * * Descrip: Equivalent to GeneWiseHSPmanager_alloc_len(GeneWiseHSPmanagerLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GeneWiseHSPmanager *] * */ GeneWiseHSPmanager * Wise2_GeneWiseHSPmanager_alloc_std(void); #define GeneWiseHSPmanager_alloc_std Wise2_GeneWiseHSPmanager_alloc_std /* Function: GeneWiseHSPmanager_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GeneWiseHSPmanager *] * */ GeneWiseHSPmanager * Wise2_GeneWiseHSPmanager_alloc_len(int len); #define GeneWiseHSPmanager_alloc_len Wise2_GeneWiseHSPmanager_alloc_len /* Function: hard_link_GeneWiseHSPmanager(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GeneWiseHSPmanager *] * * Return [UNKN ] Undocumented return value [GeneWiseHSPmanager *] * */ GeneWiseHSPmanager * Wise2_hard_link_GeneWiseHSPmanager(GeneWiseHSPmanager * obj); #define hard_link_GeneWiseHSPmanager Wise2_hard_link_GeneWiseHSPmanager /* Function: GeneWiseHSPmanager_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GeneWiseHSPmanager *] * */ GeneWiseHSPmanager * Wise2_GeneWiseHSPmanager_alloc(void); #define GeneWiseHSPmanager_alloc Wise2_GeneWiseHSPmanager_alloc /* Function: free_GeneWiseHSPmanager(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GeneWiseHSPmanager *] * * Return [UNKN ] Undocumented return value [GeneWiseHSPmanager *] * */ GeneWiseHSPmanager * Wise2_free_GeneWiseHSPmanager(GeneWiseHSPmanager * obj); #define free_GeneWiseHSPmanager Wise2_free_GeneWiseHSPmanager /* Unplaced functions */ /* There has been no indication of the use of these functions */ GeneWiseRunPara * Wise2_new_GeneWiseRunPara_from_argv(int * argc,char ** argv); #define new_GeneWiseRunPara_from_argv Wise2_new_GeneWiseRunPara_from_argv void Wise2_show_help_GeneWiseRunPara(FILE * ofp); #define show_help_GeneWiseRunPara Wise2_show_help_GeneWiseRunPara DPEnvelope * Wise2_DPEnvelope_from_protein_gen(Sequence * prot,Sequence * dna,CompMat * mat,CodonTable * ct,GeneWiseRunPara *p); #define DPEnvelope_from_protein_gen Wise2_DPEnvelope_from_protein_gen int Wise2_consistent_GeneWiseHSP(GeneWiseHSP * true,GeneWiseHSP * proposed); #define consistent_GeneWiseHSP Wise2_consistent_GeneWiseHSP int Wise2_compare_GeneWiseHSP_start(GeneWiseHSP * one,GeneWiseHSP * two); #define compare_GeneWiseHSP_start Wise2_compare_GeneWiseHSP_start void Wise2_add_GeneWiseHSPmanager_HSPset(GeneWiseHSPmanager * gwh,HSPset * set,int frame); #define add_GeneWiseHSPmanager_HSPset Wise2_add_GeneWiseHSPmanager_HSPset /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_compare_GeneWiseHSP_score(GeneWiseHSP * one,GeneWiseHSP * two); #define compare_GeneWiseHSP_score Wise2_compare_GeneWiseHSP_score void Wise2_swap_GeneWiseHSPmanager(GeneWiseHSP ** list,int i,int j) ; #define swap_GeneWiseHSPmanager Wise2_swap_GeneWiseHSPmanager void Wise2_qsort_GeneWiseHSPmanager(GeneWiseHSP ** list,int left,int right,int (*comp)(GeneWiseHSP * ,GeneWiseHSP * )); #define qsort_GeneWiseHSPmanager Wise2_qsort_GeneWiseHSPmanager void Wise2_sort_GeneWiseHSPmanager(GeneWiseHSPmanager * obj,int (*comp)(GeneWiseHSP *, GeneWiseHSP *)); #define sort_GeneWiseHSPmanager Wise2_sort_GeneWiseHSPmanager boolean Wise2_expand_GeneWiseHSPmanager(GeneWiseHSPmanager * obj,int len); #define expand_GeneWiseHSPmanager Wise2_expand_GeneWiseHSPmanager #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/genedisplay.pod0000644000175000001440000000345610670453714017152 0ustar philippusers=head1 NAME genedisplay module - part of the Wise2 package =head1 SYNOPSIS This module contains helper functions for the Wise2 package =head1 DESCRIPTION =over =item protein2genomic_ascii_display &Wise2::protein2genomic_ascii_display(alb,p,gen,ct,name,main,ofp) shows the alignment in alb between protsequence and protname with genomic into ofp with pretty formatting Argument alb [UNKN ] logical alignment [AlnBlock *] Argument p [UNKN ] protein sequence [Protein *] Argument gen [UNKN ] genomic dna to do the comparison [Genomic *] Argument ct [UNKN ] codon table for translation [CodonTable *] Argument name [UNKN ] length of name block [int] Argument main [UNKN ] length of main block [int] Argument ofp [UNKN ] output file [FILE *] Return [UNKN ] Undocumented return value [boolean] =item protcdna_ascii_display &Wise2::protcdna_ascii_display(alb,protsequence,protname,protoff,cdna,ct,name,main,mult,ofp) shows the alignment in alb between protsequence and protname with cdna into ofp with pretty formatting Argument alb [UNKN ] logical alignment [AlnBlock *] Argument protsequence [UNKN ] protein sequence - either real or an artifical consensus [char *] Argument protname [UNKN ] name of the protein [char *] Argument protoff [UNKN ] offset of the alb from the protein [int] Argument cdna [UNKN ] cdna of the match [cDNA *] Argument ct [UNKN ] codon table for translation [CodonTable *] Argument name [UNKN ] length of name block [int] Argument main [UNKN ] length of main block [int] Argument mult [UNKN ] is multi-match [boolean] Argument ofp [UNKN ] output file [FILE *] Return [UNKN ] Undocumented return value [boolean] =back wise-2.4.1/src/models/genedisplay.tex0000644000175000001440000000375610670453714017173 0ustar philippusers\section{genedisplay} \label{module_genedisplay} This module only contains factory methods \subsection{genedisplay factory methods} \subsubsection{protein2genomic_ascii_display} \begin{description} \item[External C] {\tt Wise2_protein2genomic_ascii_display (alb,p,gen,ct,name,main,ofp)} \item[Perl] {\tt &Wise2::protein2genomic_ascii_display (alb,p,gen,ct,name,main,ofp)} \end{description} Arguments \begin{description} \item[alb] [UNKN ] logical alignment [AlnBlock *] \item[p] [UNKN ] protein sequence [Protein *] \item[gen] [UNKN ] genomic dna to do the comparison [Genomic *] \item[ct] [UNKN ] codon table for translation [CodonTable *] \item[name] [UNKN ] length of name block [int] \item[main] [UNKN ] length of main block [int] \item[ofp] [UNKN ] output file [FILE *] \item[returns] [UNKN ] Undocumented return value [boolean] \end{description} shows the alignment in alb between protsequence and protname with genomic into ofp with pretty formatting \subsubsection{protcdna_ascii_display} \begin{description} \item[External C] {\tt Wise2_protcdna_ascii_display (alb,protsequence,protname,protoff,cdna,ct,name,main,mult,ofp)} \item[Perl] {\tt &Wise2::protcdna_ascii_display (alb,protsequence,protname,protoff,cdna,ct,name,main,mult,ofp)} \end{description} Arguments \begin{description} \item[alb] [UNKN ] logical alignment [AlnBlock *] \item[protsequence] [UNKN ] protein sequence - either real or an artifical consensus [char *] \item[protname] [UNKN ] name of the protein [char *] \item[protoff] [UNKN ] offset of the alb from the protein [int] \item[cdna] [UNKN ] cdna of the match [cDNA *] \item[ct] [UNKN ] codon table for translation [CodonTable *] \item[name] [UNKN ] length of name block [int] \item[main] [UNKN ] length of main block [int] \item[mult] [UNKN ] is multi-match [boolean] \item[ofp] [UNKN ] output file [FILE *] \item[returns] [UNKN ] Undocumented return value [boolean] \end{description} shows the alignment in alb between protsequence and protname with cdna into ofp with pretty formatting wise-2.4.1/src/models/transfactor.c0000644000175000001440000016262310670453715016637 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "transfactor.h" # line 78 "transfactor.dy" void show_context_match_TransFactorMatchSetCompara(TransFactorMatchSetCompara * tfmsc,int context,FILE *ofp) { int i; int j; int k; int p; char buffer[MAXLINE]; assert(tfmsc != NULL); assert(tfmsc->overall != NULL); for(i=0;ioverall->len;i++) { fprintf(ofp,"Match %d Factor %s %s %d %d %d %.2f %.2f\n",i,tfmsc->overall->match[i]->factor->name,tfmsc->overall->target->name, tfmsc->overall->match[i]->start, tfmsc->overall->match[i]->end, tfmsc->overall->match[i]->strand, tfmsc->overall->match[i]->bit_score, Probability2Bits(tfmsc->overall->match[i]->factor->max_prob) ); for(j=0;jsa->len;j++) { k = tfmsc->overall->match[i]->start - context; if( k <= 0 ) { k = 0; } for(p=0;koverall->match[i]->start;k++,p++) { buffer[p] = tolower(tfmsc->sa->seq[j]->seq[k]); } for(;koverall->match[i]->end;k++,p++) { buffer[p] = toupper(tfmsc->sa->seq[j]->seq[k]); } for(;koverall->match[i]->end+context;k++,p++) { buffer[p] = tolower(tfmsc->sa->seq[j]->seq[k]); } buffer[p] = '\0'; fprintf(ofp,"%40s %s\n",tfmsc->sa->seq[j]->name,buffer); } fprintf(ofp,"EndMatch\n"); } } # line 122 "transfactor.dy" TransFactorSet * circular_permuted_TransFactorSet(TransFactorSet * in,int rotate_number) { TransFactorSet * out; int i; TransFactor * f; assert(in != NULL); out = TransFactorSet_alloc_len(in->len); for(i=0;ilen;i++) { f = TransFactor_alloc(); f->name = stringalloc(in->factor[i]->name); f->pwm = circular_permuted_pwmDNA(in->factor[i]->pwm,rotate_number); f->seed = hard_link_SeqAlign(in->factor[i]->seed); add_TransFactorSet(out,f); } return out; } # line 145 "transfactor.dy" void show_TransFactorMatchSet(TransFactorMatchSet * tfms,FILE * ofp) { int i; assert(tfms != NULL); assert(ofp != NULL); assert(tfms->target != NULL); for(i=0;ilen;i++) { fprintf(ofp,"Motif\t%s\t%d\t%d\t%d\t%s\t%.2f\t%.*s\n",tfms->target->name,tfms->match[i]->start+1,tfms->match[i]->start+tfms->match[i]->factor->seed->seq[0]->len,tfms->match[i]->strand,tfms->match[i]->factor->name,tfms->match[i]->bit_score,tfms->match[i]->factor->seed->seq[0]->len,tfms->target->seq+tfms->match[i]->start); } } # line 161 "transfactor.dy" void show_help_TransFactorMatchPara(FILE * ofp) { fprintf(ofp,"TransFactor Match Parameters\n"); fprintf(ofp," -tfm_type [abs/rel/relmix] type of cutoff: absolute, relative, relative mixed\n"); fprintf(ofp," -tfm_cutoff (abs) bits cutoff for absolute matches, default 11.0\n"); fprintf(ofp," -tfm_rel [0.95] (rel/relmix) Relative to best possible score, accept if above irregardless of score\nn"); fprintf(ofp," -tfm_relsoft [0.9] (relmix) Relative to best possible score, accept if above this relative and bit score\n"); fprintf(ofp," -tfm_relbits [11.0] (relmix) If above relsoft and above this bits score, accept\n"); } # line 171 "transfactor.dy" void show_help_TransFactorComparaPara(FILE * ofp) { fprintf(ofp,"TransFactor comparative filter parameters\n"); fprintf(ofp," -tfc_type [precise/overlap/region] overlap criteria\n"); fprintf(ofp," -tfc_region [20] region length\n"); fprintf(ofp," -tfc_missing [0] number of sequences motif can be missing in\n"); } # line 179 "transfactor.dy" TransFactorComparaPara * new_TransFactorComparaPara_from_argv(int * argc,char ** argv) { char * temp; TransFactorComparaPara * out; out = TransFactorComparaPara_alloc(); temp = strip_out_assigned_argument(argc,argv,"tfc_type"); if( temp != NULL ) { if( strcmp(temp,"precise") == 0 ) { out->overlap_type = TFCOMPARA_OVERLAP_PRECISE; } else if ( strcmp(temp,"overlap") == 0 ) { out->overlap_type = TFCOMPARA_OVERLAP_OVERLAP; } else if( strcmp(temp,"region") == 0 ) { out->overlap_type = TFCOMPARA_OVERLAP_REGION; } else { warn("string %s is not a valid tf_compara overlap type",temp); return NULL; } } strip_out_integer_argument(argc,argv,"tfc_region",&out->overlap_len); strip_out_integer_argument(argc,argv,"tfc_missing",&out->missing_seq); return out; } # line 206 "transfactor.dy" TransFactorMatchSetCompara * calculate_TransFactorMatchSetCompara(SeqAlign * sa,TransFactorSet * tfs,TransFactorMatchPara * match_para,TransFactorComparaPara * para) { int i; int j; int k; int count; int found; TransFactorMatchSetCompara * out; out = TransFactorMatchSetCompara_alloc_len(sa->len); out->sa = hard_link_SeqAlign(sa); for(i=0;ilen;i++) { add_TransFactorMatchSetCompara(out,calculate_TransFactorMatchSet(sa->seq[i],tfs,match_para)); } out->overall = TransFactorMatchSet_alloc_std(); out->overall->target = hard_link_Sequence(out->tfms[0]->target); for(i=0;itfms[0]->len;i++) { count = 0; for(k=1;klen;k++) { found = 0; for(j=0;jtfms[k]->len;j++) { if( out->tfms[0]->match[i]->factor == out->tfms[k]->match[j]->factor ) { if( para->overlap_type == TFCOMPARA_OVERLAP_PRECISE ) { if( out->tfms[0]->match[i]->start == out->tfms[k]->match[j]->start ) { found = 1; break; } } else if ( para->overlap_type == TFCOMPARA_OVERLAP_OVERLAP ) { if( !(out->tfms[0]->match[i]->end < out->tfms[k]->match[j]->start || out->tfms[0]->match[i]->start > out->tfms[k]->match[j]->end ) ) { found = 1; break; } } else if ( para->overlap_type == TFCOMPARA_OVERLAP_REGION ) { if( !(out->tfms[0]->match[i]->end - para->overlap_len < out->tfms[k]->match[j]->start || out->tfms[0]->match[i]->start + para->overlap_len > out->tfms[k]->match[j]->end ) ) { found = 1; break; } } else { fatal("Bad overlap type in compara tf matching"); } } } if( found == 0 ) { count++; } } if( count <= para->missing_seq ) { add_TransFactorMatchSet(out->overall,hard_link_TransFactorMatch(out->tfms[0]->match[i])); } } return out; } # line 269 "transfactor.dy" void show_help_TransFactorBuildPara(FILE * ofp) { fprintf(ofp,"TransFactor Build Parameters\n"); fprintf(ofp," -tfb_pseudo simple pseudo count, default 0.3\n"); fprintf(ofp," -[no]tfb_warn warn on small sequence number [default yes]\n"); } # line 276 "transfactor.dy" TransFactorBuildPara * new_TransFactorBuildPara_from_argv(int * argc,char ** argv) { TransFactorBuildPara * out; out = TransFactorBuildPara_alloc(); out->pseudo_count = 0.3; out->rnd_dna = RandomModelDNA_std(); strip_out_float_argument(argc,argv,"tfb_pseudo",&out->pseudo_count); return out; } # line 290 "transfactor.dy" TransFactorMatchPara * new_TransFactorMatchPara_from_argv(int * argc,char ** argv) { char * temp; TransFactorMatchPara * out; out = TransFactorMatchPara_alloc(); out->type = TFM_RELATIVE_MIXED; out->relative_prob = 0.95; out->relative_prob_bits = 0.9; out->min_bits = 11.0; out->min_relative = 11.0; out->allow_N = 0; temp = strip_out_assigned_argument(argc,argv,"tfm_type"); if( temp != NULL ) { if( strcmp(temp,"abs") == 0 ) { out->type = TFM_ABSOLUTE; } else if ( strcmp(temp,"rel") == 0 ) { out->type = TFM_RELATIVE; } else if ( strcmp(temp,"relmix") == 0 ) { out->type = TFM_RELATIVE_MIXED; } else { warn("Could not understand %s as a match para type",temp); return NULL; } } strip_out_float_argument(argc,argv,"tfm_cutoff",&out->min_bits); strip_out_float_argument(argc,argv,"tfm_rel",&out->relative_prob); strip_out_float_argument(argc,argv,"tfm_relsoft",&out->relative_prob_bits); strip_out_float_argument(argc,argv,"tfm_relbits",&out->min_relative); assert(out->relative_prob <= 1.0 ); assert(out->relative_prob_bits <= 1.0 ); return out; } # line 328 "transfactor.dy" boolean build_TransFactorSet(TransFactorSet * tfs,TransFactorBuildPara * p) { int i; assert(tfs); assert(p); for(i=0;ilen;i++) { build_pwm_TransFactor(tfs->factor[i],p); } } # line 342 "transfactor.dy" boolean build_pwm_TransFactor(TransFactor * tf,TransFactorBuildPara * p) { assert(tf); assert(tf->seed); assert(p); tf->pwm = pwmDNA_from_SeqAlign(tf->seed,p->pseudo_count); fold_randommodel_pwmDNA(tf->pwm,p->rnd_dna); tf->max_prob = max_prob_TransFactor(tf); tf->min_prob = min_prob_TransFactor(tf); return TRUE; } # line 358 "transfactor.dy" TransFactorMatchSet * calculate_TransFactorMatchSet(Sequence * seq,TransFactorSet * tfs,TransFactorMatchPara * p) { int i; int j; int k; int len; double prob; double rev_prob; double cutoff; double t; TransFactorMatchSet * out; TransFactorMatch * m; Sequence * comp; assert(seq); assert(tfs); assert(p); comp = reverse_complement_Sequence(seq); assert(comp); out = TransFactorMatchSet_alloc_std(); out->target = hard_link_Sequence(seq); for(i=0;ilen;i++) { len = seq->len - tfs->factor[i]->pwm->len; /* adjust cutoff on a per motif basis */ switch(p->type ) { case TFM_ABSOLUTE : cutoff = Bits2Probability(p->min_bits); break; case TFM_RELATIVE : cutoff = Bits2Probability(Probability2Bits(tfs->factor[i]->max_prob)*p->relative_prob); break; case TFM_RELATIVE_MIXED : cutoff = Bits2Probability(Probability2Bits(tfs->factor[i]->max_prob)*p->relative_prob); t = Bits2Probability(Probability2Bits(tfs->factor[i]->max_prob)*p->relative_prob_bits); if( t > p->min_relative && t < cutoff) { cutoff = t; } break; default : fatal("Impossible - bad match parameter passed in"); } /* fprintf(stderr,"Cutoff is %.2f for factor %d (%.2f) vs %.2f (bits) and %.2f cutoff %.2f\n",cutoff,i,tfs->factor[i]->max_prob,Probability2Bits(tfs->factor[i]->max_prob),Probability2Bits(tfs->factor[i]->max_prob)*p->relative_prob,p->relative_prob); */ for(j=0;jfactor[i]->pwm->len;k++) { /* fprintf(stderr,"position is %d, chr %c base %d\n",j+k,seq->seq[j+k],base_from_char(seq->seq[j+k])); */ if( p->allow_N == 0 && base_from_char(seq->seq[j+k]) == BASE_N ) { prob *= 0.0; } if( p->allow_N == 0 && base_from_char(comp->seq[j+k]) == BASE_N ) { rev_prob *= 0.0; } prob *= tfs->factor[i]->pwm->pos[k]->emit[base_from_char(seq->seq[j+k])]; rev_prob *= tfs->factor[i]->pwm->pos[k]->emit[base_from_char(comp->seq[j+k])]; } if( prob > cutoff ) { m = TransFactorMatch_alloc(); m->start = j; m->end = j+tfs->factor[i]->seed->seq[0]->len; m->strand = 1; m->bit_score = Score2Bits(Probability2Score(prob)); m->factor = hard_link_TransFactor(tfs->factor[i]); add_TransFactorMatchSet(out,m); } if( rev_prob > cutoff ) { m = TransFactorMatch_alloc(); m->start = seq->len - j - tfs->factor[i]->seed->seq[0]->len;; m->end = seq->len - j; m->strand = -1; m->bit_score = Score2Bits(Probability2Score(rev_prob)); m->factor = hard_link_TransFactor(tfs->factor[i]); add_TransFactorMatchSet(out,m); } } } free_Sequence(comp); return out; } # line 459 "transfactor.dy" double min_prob_TransFactor(TransFactor * tf) { double sc; int i,j; double min; assert(tf != NULL); assert(tf->pwm != NULL); sc = 1.0; for(i=0;ipwm->len;i++) { min = tf->pwm->pos[i]->emit[0]; for(j=1;j<4;j++) { if( min > tf->pwm->pos[i]->emit[j] ) { min = tf->pwm->pos[i]->emit[j]; } } sc *= min; } return sc; } # line 483 "transfactor.dy" double max_prob_TransFactor(TransFactor * tf) { double sc; int i,j; int maxj; double max; assert(tf != NULL); assert(tf->pwm != NULL); sc = 1.0; for(i=0;ipwm->len;i++) { max = tf->pwm->pos[i]->emit[0]; maxj = 0; for(j=1;j<4;j++) { /* fprintf(stderr,"%d, comparing %.2f with %.2f\n",i,max,tf->pwm->pos[i]->emit[j]); */ if( max < tf->pwm->pos[i]->emit[j] ) { max = tf->pwm->pos[i]->emit[j]; maxj = j; } } /*fprintf(stderr,"At position %d, so far %.2f with %.2f (%d)\n",i,sc,max,maxj);*/ sc *= max; } /*fprintf(stderr,"Returning %.2f as max\n",sc);*/ return sc; } # line 514 "transfactor.dy" void write_TransFactorSet(TransFactorSet * tfs,FILE * ofp) { int i; for(i=0;ilen;i++) { write_TransFactor(tfs->factor[i],ofp); } } # line 524 "transfactor.dy" void write_TransFactor(TransFactor * tf,FILE * ofp) { double sc = 0.0; int i; int j; assert(tf); assert(tf->seed); if( tf->pwm != NULL ) { for(i=0;iseed->seq[0]->len;i++) { for(j=0;j<4;j++) { sc += 0.25 * tf->pwm->pos[i]->emit[j]; } } } else { sc = 0.0; } fprintf(ofp,"factor %s\n",tf->name); fprintf(ofp,"seed\n"); fprintf(ofp,"expected %.2f\n",sc); write_selex_SeqAlign(tf->seed,15,100,ofp); fprintf(ofp,"//\n"); fprintf(ofp,"end factor\n"); } # line 551 "transfactor.dy" TransFactorSet * read_TransFactorSet_file(char * filename) { TransFactorSet * tfs; FILE * ifp; assert(filename); ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s for TransFactorSet reading",filename); return NULL; } tfs = read_TransFactorSet(ifp); fclose(ifp); return tfs; } # line 573 "transfactor.dy" TransFactorSet * read_ben_IUPAC_TransFactorSet_file(char * filename) { TransFactorSet * tfs; FILE * ifp; assert(filename); ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s for TransFactorSet reading",filename); return NULL; } tfs = read_ben_IUPAC_TransFactorSet(ifp); fclose(ifp); return tfs; } static char iupac_map[17][5] = { {'A','A','.','.','.'}, {'C','C','.','.','.'}, {'G','G','.','.','.'}, {'T','T','.','.','.'}, {'M','A','C','.','.'}, {'R','A','G','.','.'}, {'W','A','T','.','.'}, {'S','C','G','.','.'}, {'Y','C','T','.','.'}, {'K','G','T','.','.'}, {'V','A','C','G','.'}, {'H','A','C','T','.'}, {'D','A','G','T','.'}, {'B','C','G','T','.'}, {'X','A','G','T','C'}, {'N','A','G','T','C'}, }; # line 613 "transfactor.dy" TransFactorSet * read_ben_IUPAC_TransFactorSet(FILE * ifp) { char buffer[MAXLINE]; TransFactorSet * out; TransFactor * temp; SeqAlign * align; Sequence * line; char lines [12][40]; char sbuffer[MAXLINE]; int motif_no = 1; int seq_no = 1; int i; int j; int k; int l; out = TransFactorSet_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == ' ' || buffer[0] == '#' ) { continue; } for(i=0;!isspace(buffer[i]);i++) { for(l=0;l<17;l++) { if( iupac_map[l][0] == buffer[i] ) { break; } } if( l == 17 ) { warn("Weird non IUPAC code [%c] in %s",buffer[i],buffer); break; } /* we make 12 fake sequences, using the IUPAC map, moving the k, the index in the possible nuc in the map when we hit . - this means A becomes 12 A's, Y becomes 6 C's and 6 T's etc */ for(j=0,k=1;j<12;j++,k++) { for(;iupac_map[l][k] == '.' && k < 5;k++) ; if( k == 5 ) { k = 1; } if( buffer[i] == 'N' ) { lines[j][i] = 'N'; } else { lines[j][i] = iupac_map[l][k]; } } } if( !isspace(buffer[i]) ) { continue; /* error scenario */ } else { buffer[i] = '\0'; } for(j=0;j<12;j++) { lines[j][i] = '\0'; } sprintf(sbuffer,"motif_%d_%s",motif_no,buffer); temp = TransFactor_alloc(); temp->name = stringalloc(sbuffer); align = SeqAlign_alloc_std(); for(j=0;j<12;j++) { sprintf(sbuffer,"fake_%d_%d",motif_no,j); line = Sequence_from_static_memory(sbuffer,lines[j]); add_SeqAlign(align,line); } temp->seed = trim_from_N_SeqAlign(align); free_SeqAlign(align); add_TransFactorSet(out,temp); motif_no++; } return out; } # line 706 "transfactor.dy" TransFactorSet * read_laurence_TransFactorSet_file(char * filename) { TransFactorSet * tfs; FILE * ifp; assert(filename); ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s for TransFactorSet reading",filename); return NULL; } tfs = read_laurence_TransFactorSet(ifp); fclose(ifp); return tfs; } # line 727 "transfactor.dy" TransFactorSet * read_laurence_TransFactorSet(FILE * ifp) { char buffer[MAXLINE]; TransFactorSet * out; TransFactor * temp; SeqAlign * align; Sequence * line; char sbuffer[MAXLINE]; int motif_no = 1; int seq_no = 1; int i; out = TransFactorSet_alloc_std(); sprintf(sbuffer,"motif_%d",motif_no); temp = TransFactor_alloc(); temp->name = stringalloc(sbuffer); align = SeqAlign_alloc_std(); while( fgets(buffer,MAXLINE,ifp) ) { if( buffer[0] == '#' ) { continue; } if( strstr(buffer,"degenerate") != NULL ) { temp->seed = trim_from_N_SeqAlign(align); free_SeqAlign(align); add_TransFactorSet(out,temp); seq_no = 1; motif_no++; sprintf(sbuffer,"motif_%d",motif_no); temp = TransFactor_alloc(); temp->name = stringalloc(sbuffer); align = SeqAlign_alloc_std(); continue; } if( buffer[0] == '=' ) { continue; } for(i=0;buffer[i] != '\0';i++) { if( buffer[i] != 'A' && buffer[i] != 'T' && buffer[i] != 'G' && buffer[i] != 'C' ) { buffer[i] = 'N'; } } line = Sequence_alloc(); sprintf(sbuffer,"motif_%d_seq_%d",motif_no,seq_no); seq_no++; line->name = stringalloc(sbuffer); line->seq = stringalloc(buffer); line->type = SEQUENCE_DNA; line->len = strlen(buffer); add_SeqAlign(align,line); } return out; } # line 798 "transfactor.dy" TransFactorSet * read_TransFactorSet(FILE * ifp) { char buffer[MAXLINE]; TransFactorSet * out; TransFactor * temp; out = TransFactorSet_alloc_std(); while( fgets(buffer,MAXLINE,ifp) ) { if( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"factor") == 0 ) { temp = read_TransFactor(buffer,ifp); if( temp == NULL ) { warn("No transfactor; skipping; parsing may have fallen down"); continue; } else { add_TransFactorSet(out,temp); } continue; } if( isalpha(buffer[0]) ) { warn("could not interpret in reading transfactorset %s",buffer); } } return out; } # line 832 "transfactor.dy" TransFactor * read_TransFactor(char * line,FILE * ifp) { char buffer[MAXLINE]; char * name; char * t; TransFactor * out; SeqAlign * temp; if( strstartcmp(line,"factor") != 0 ) { warn("Passed in a line [%s] which has no factor to the factor reader. Not good!",line); return NULL; } name = line + strlen("factor")+1; for(;isspace(*name);name++) ; if( *name == '\0' ) { warn("No name in factor - which is bad! %s\n",line); return NULL; } for(t=name;*t && !isspace(*t);t++) ; *t = '\0'; while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"seed") == 0 ) { temp = read_selex_SeqAlign(ifp); if( temp == NULL ) { warn("No sequence alignment for this factor. Skipping"); return NULL; } continue; } if( strstartcmp(buffer,"end") == 0 ) { break; } if( isalpha(buffer[0]) ) { warn("Uninterpretable line in transfactor %s",buffer); } } if( temp == NULL ) { warn("No seed alignment read. Impossible for %s",name); return NULL; } out = TransFactor_alloc(); out->seed = temp; out->name = stringalloc(name); return out; } # line 896 "transfactor.dy" int compare_start_TransFactorMatch(TransFactorMatch * a,TransFactorMatch * b) { return a->start - b->start; } # line 901 "transfactor.dy" void sort_by_start_TransFactorMatchSet(TransFactorMatchSet * t) { sort_TransFactorMatchSet(t,compare_start_TransFactorMatch); } # line 862 "transfactor.c" /* Function: hard_link_TransFactor(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactor *] * * Return [UNKN ] Undocumented return value [TransFactor *] * */ TransFactor * hard_link_TransFactor(TransFactor * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransFactor object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransFactor_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactor *] * */ TransFactor * TransFactor_alloc(void) { TransFactor * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransFactor *) ckalloc (sizeof(TransFactor))) == NULL) { warn("TransFactor_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->seed = NULL; out->pwm = NULL; out->full = NULL; out->max_prob = 0; out->min_prob = 0; return out; } /* Function: free_TransFactor(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactor *] * * Return [UNKN ] Undocumented return value [TransFactor *] * */ TransFactor * free_TransFactor(TransFactor * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransFactor obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->seed != NULL) free_SeqAlign(obj->seed); if( obj->pwm != NULL) free_pwmDNA(obj->pwm); if( obj->full != NULL) free_SeqAlign(obj->full); ckfree(obj); return NULL; } /* Function: swap_TransFactorSet(list,i,j) * * Descrip: swap function: an internal for qsort_TransFactorSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [TransFactor **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_TransFactorSet(TransFactor ** list,int i,int j) { TransFactor * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_TransFactorSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_TransFactorSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [TransFactor **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_TransFactorSet(TransFactor ** list,int left,int right,int (*comp)(TransFactor * ,TransFactor * )) { int i,last; if( left >= right ) return; swap_TransFactorSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_TransFactorSet (list,++last,i); } swap_TransFactorSet (list,left,last); qsort_TransFactorSet(list,left,last-1,comp); qsort_TransFactorSet(list,last+1,right,comp); } /* Function: sort_TransFactorSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_TransFactorSet * * * Arg: obj [UNKN ] Object containing list [TransFactorSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_TransFactorSet(TransFactorSet * obj,int (*comp)(TransFactor *, TransFactor *)) { qsort_TransFactorSet(obj->factor,0,obj->len-1,comp); return; } /* Function: expand_TransFactorSet(obj,len) * * Descrip: Really an internal function for add_TransFactorSet * * * Arg: obj [UNKN ] Object which contains the list [TransFactorSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_TransFactorSet(TransFactorSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_TransFactorSet called with no need"); return TRUE; } if( (obj->factor = (TransFactor ** ) ckrealloc (obj->factor,sizeof(TransFactor *)*len)) == NULL) { warn("ckrealloc failed for expand_TransFactorSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_TransFactorSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransFactorSet *] * Arg: add [OWNER] Object to add to the list [TransFactor *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_TransFactorSet(TransFactorSet * obj,TransFactor * add) { if( obj->len >= obj->maxlen) { if( expand_TransFactorSet(obj,obj->len + TransFactorSetLISTLENGTH) == FALSE) return FALSE; } obj->factor[obj->len++]=add; return TRUE; } /* Function: flush_TransFactorSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransFactorSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_TransFactorSet(TransFactorSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->factor[i] != NULL) { free_TransFactor(obj->factor[i]); obj->factor[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: TransFactorSet_alloc_std(void) * * Descrip: Equivalent to TransFactorSet_alloc_len(TransFactorSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransFactorSet *] * */ TransFactorSet * TransFactorSet_alloc_std(void) { return TransFactorSet_alloc_len(TransFactorSetLISTLENGTH); } /* Function: TransFactorSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransFactorSet *] * */ TransFactorSet * TransFactorSet_alloc_len(int len) { TransFactorSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = TransFactorSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->factor = (TransFactor ** ) ckcalloc (len,sizeof(TransFactor *))) == NULL) { warn("Warning, ckcalloc failed in TransFactorSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_TransFactorSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorSet *] * * Return [UNKN ] Undocumented return value [TransFactorSet *] * */ TransFactorSet * hard_link_TransFactorSet(TransFactorSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransFactorSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransFactorSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorSet *] * */ TransFactorSet * TransFactorSet_alloc(void) { TransFactorSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransFactorSet *) ckalloc (sizeof(TransFactorSet))) == NULL) { warn("TransFactorSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->factor = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_TransFactorSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorSet *] * * Return [UNKN ] Undocumented return value [TransFactorSet *] * */ TransFactorSet * free_TransFactorSet(TransFactorSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransFactorSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->factor != NULL) { for(i=0;ilen;i++) { if( obj->factor[i] != NULL) free_TransFactor(obj->factor[i]); } ckfree(obj->factor); } ckfree(obj); return NULL; } /* Function: hard_link_TransFactorMatch(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorMatch *] * * Return [UNKN ] Undocumented return value [TransFactorMatch *] * */ TransFactorMatch * hard_link_TransFactorMatch(TransFactorMatch * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransFactorMatch object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransFactorMatch_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorMatch *] * */ TransFactorMatch * TransFactorMatch_alloc(void) { TransFactorMatch * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransFactorMatch *) ckalloc (sizeof(TransFactorMatch))) == NULL) { warn("TransFactorMatch_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->end = 0; out->strand = 1; out->bit_score = 0; out->factor = NULL; return out; } /* Function: free_TransFactorMatch(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorMatch *] * * Return [UNKN ] Undocumented return value [TransFactorMatch *] * */ TransFactorMatch * free_TransFactorMatch(TransFactorMatch * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransFactorMatch obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->factor != NULL) free_TransFactor(obj->factor); ckfree(obj); return NULL; } /* Function: swap_TransFactorMatchSet(list,i,j) * * Descrip: swap function: an internal for qsort_TransFactorMatchSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [TransFactorMatch **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_TransFactorMatchSet(TransFactorMatch ** list,int i,int j) { TransFactorMatch * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_TransFactorMatchSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_TransFactorMatchSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [TransFactorMatch **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_TransFactorMatchSet(TransFactorMatch ** list,int left,int right,int (*comp)(TransFactorMatch * ,TransFactorMatch * )) { int i,last; if( left >= right ) return; swap_TransFactorMatchSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_TransFactorMatchSet (list,++last,i); } swap_TransFactorMatchSet (list,left,last); qsort_TransFactorMatchSet(list,left,last-1,comp); qsort_TransFactorMatchSet(list,last+1,right,comp); } /* Function: sort_TransFactorMatchSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_TransFactorMatchSet * * * Arg: obj [UNKN ] Object containing list [TransFactorMatchSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_TransFactorMatchSet(TransFactorMatchSet * obj,int (*comp)(TransFactorMatch *, TransFactorMatch *)) { qsort_TransFactorMatchSet(obj->match,0,obj->len-1,comp); return; } /* Function: expand_TransFactorMatchSet(obj,len) * * Descrip: Really an internal function for add_TransFactorMatchSet * * * Arg: obj [UNKN ] Object which contains the list [TransFactorMatchSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_TransFactorMatchSet(TransFactorMatchSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_TransFactorMatchSet called with no need"); return TRUE; } if( (obj->match = (TransFactorMatch ** ) ckrealloc (obj->match,sizeof(TransFactorMatch *)*len)) == NULL) { warn("ckrealloc failed for expand_TransFactorMatchSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_TransFactorMatchSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransFactorMatchSet *] * Arg: add [OWNER] Object to add to the list [TransFactorMatch *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_TransFactorMatchSet(TransFactorMatchSet * obj,TransFactorMatch * add) { if( obj->len >= obj->maxlen) { if( expand_TransFactorMatchSet(obj,obj->len + TransFactorMatchSetLISTLENGTH) == FALSE) return FALSE; } obj->match[obj->len++]=add; return TRUE; } /* Function: flush_TransFactorMatchSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransFactorMatchSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_TransFactorMatchSet(TransFactorMatchSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->match[i] != NULL) { free_TransFactorMatch(obj->match[i]); obj->match[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: TransFactorMatchSet_alloc_std(void) * * Descrip: Equivalent to TransFactorMatchSet_alloc_len(TransFactorMatchSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransFactorMatchSet *] * */ TransFactorMatchSet * TransFactorMatchSet_alloc_std(void) { return TransFactorMatchSet_alloc_len(TransFactorMatchSetLISTLENGTH); } /* Function: TransFactorMatchSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransFactorMatchSet *] * */ TransFactorMatchSet * TransFactorMatchSet_alloc_len(int len) { TransFactorMatchSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = TransFactorMatchSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->match = (TransFactorMatch ** ) ckcalloc (len,sizeof(TransFactorMatch *))) == NULL) { warn("Warning, ckcalloc failed in TransFactorMatchSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_TransFactorMatchSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorMatchSet *] * * Return [UNKN ] Undocumented return value [TransFactorMatchSet *] * */ TransFactorMatchSet * hard_link_TransFactorMatchSet(TransFactorMatchSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransFactorMatchSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransFactorMatchSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorMatchSet *] * */ TransFactorMatchSet * TransFactorMatchSet_alloc(void) { TransFactorMatchSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransFactorMatchSet *) ckalloc (sizeof(TransFactorMatchSet))) == NULL) { warn("TransFactorMatchSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->match = NULL; out->len = out->maxlen = 0; out->target = NULL; return out; } /* Function: free_TransFactorMatchSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorMatchSet *] * * Return [UNKN ] Undocumented return value [TransFactorMatchSet *] * */ TransFactorMatchSet * free_TransFactorMatchSet(TransFactorMatchSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransFactorMatchSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->match != NULL) { for(i=0;ilen;i++) { if( obj->match[i] != NULL) free_TransFactorMatch(obj->match[i]); } ckfree(obj->match); } if( obj->target != NULL) free_Sequence(obj->target); ckfree(obj); return NULL; } /* Function: swap_TransFactorMatchSetCompara(list,i,j) * * Descrip: swap function: an internal for qsort_TransFactorMatchSetCompara * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [TransFactorMatchSet **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_TransFactorMatchSetCompara(TransFactorMatchSet ** list,int i,int j) { TransFactorMatchSet * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_TransFactorMatchSetCompara(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_TransFactorMatchSetCompara which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [TransFactorMatchSet **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_TransFactorMatchSetCompara(TransFactorMatchSet ** list,int left,int right,int (*comp)(TransFactorMatchSet * ,TransFactorMatchSet * )) { int i,last; if( left >= right ) return; swap_TransFactorMatchSetCompara(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_TransFactorMatchSetCompara (list,++last,i); } swap_TransFactorMatchSetCompara (list,left,last); qsort_TransFactorMatchSetCompara(list,left,last-1,comp); qsort_TransFactorMatchSetCompara(list,last+1,right,comp); } /* Function: sort_TransFactorMatchSetCompara(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_TransFactorMatchSetCompara * * * Arg: obj [UNKN ] Object containing list [TransFactorMatchSetCompara *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_TransFactorMatchSetCompara(TransFactorMatchSetCompara * obj,int (*comp)(TransFactorMatchSet *, TransFactorMatchSet *)) { qsort_TransFactorMatchSetCompara(obj->tfms,0,obj->len-1,comp); return; } /* Function: expand_TransFactorMatchSetCompara(obj,len) * * Descrip: Really an internal function for add_TransFactorMatchSetCompara * * * Arg: obj [UNKN ] Object which contains the list [TransFactorMatchSetCompara *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_TransFactorMatchSetCompara(TransFactorMatchSetCompara * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_TransFactorMatchSetCompara called with no need"); return TRUE; } if( (obj->tfms = (TransFactorMatchSet ** ) ckrealloc (obj->tfms,sizeof(TransFactorMatchSet *)*len)) == NULL) { warn("ckrealloc failed for expand_TransFactorMatchSetCompara, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_TransFactorMatchSetCompara(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransFactorMatchSetCompara *] * Arg: add [OWNER] Object to add to the list [TransFactorMatchSet *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_TransFactorMatchSetCompara(TransFactorMatchSetCompara * obj,TransFactorMatchSet * add) { if( obj->len >= obj->maxlen) { if( expand_TransFactorMatchSetCompara(obj,obj->len + TransFactorMatchSetComparaLISTLENGTH) == FALSE) return FALSE; } obj->tfms[obj->len++]=add; return TRUE; } /* Function: flush_TransFactorMatchSetCompara(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransFactorMatchSetCompara *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_TransFactorMatchSetCompara(TransFactorMatchSetCompara * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->tfms[i] != NULL) { free_TransFactorMatchSet(obj->tfms[i]); obj->tfms[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: TransFactorMatchSetCompara_alloc_std(void) * * Descrip: Equivalent to TransFactorMatchSetCompara_alloc_len(TransFactorMatchSetComparaLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransFactorMatchSetCompara *] * */ TransFactorMatchSetCompara * TransFactorMatchSetCompara_alloc_std(void) { return TransFactorMatchSetCompara_alloc_len(TransFactorMatchSetComparaLISTLENGTH); } /* Function: TransFactorMatchSetCompara_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransFactorMatchSetCompara *] * */ TransFactorMatchSetCompara * TransFactorMatchSetCompara_alloc_len(int len) { TransFactorMatchSetCompara * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = TransFactorMatchSetCompara_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->tfms = (TransFactorMatchSet ** ) ckcalloc (len,sizeof(TransFactorMatchSet *))) == NULL) { warn("Warning, ckcalloc failed in TransFactorMatchSetCompara_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_TransFactorMatchSetCompara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorMatchSetCompara *] * * Return [UNKN ] Undocumented return value [TransFactorMatchSetCompara *] * */ TransFactorMatchSetCompara * hard_link_TransFactorMatchSetCompara(TransFactorMatchSetCompara * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransFactorMatchSetCompara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransFactorMatchSetCompara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorMatchSetCompara *] * */ TransFactorMatchSetCompara * TransFactorMatchSetCompara_alloc(void) { TransFactorMatchSetCompara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransFactorMatchSetCompara *) ckalloc (sizeof(TransFactorMatchSetCompara))) == NULL) { warn("TransFactorMatchSetCompara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->sa = NULL; out->tfms = NULL; out->len = out->maxlen = 0; out->overall = NULL; return out; } /* Function: free_TransFactorMatchSetCompara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorMatchSetCompara *] * * Return [UNKN ] Undocumented return value [TransFactorMatchSetCompara *] * */ TransFactorMatchSetCompara * free_TransFactorMatchSetCompara(TransFactorMatchSetCompara * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransFactorMatchSetCompara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->sa != NULL) free_SeqAlign(obj->sa); if( obj->tfms != NULL) { for(i=0;ilen;i++) { if( obj->tfms[i] != NULL) free_TransFactorMatchSet(obj->tfms[i]); } ckfree(obj->tfms); } if( obj->overall != NULL) free_TransFactorMatchSet(obj->overall); ckfree(obj); return NULL; } /* Function: hard_link_TransFactorComparaPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorComparaPara *] * * Return [UNKN ] Undocumented return value [TransFactorComparaPara *] * */ TransFactorComparaPara * hard_link_TransFactorComparaPara(TransFactorComparaPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransFactorComparaPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransFactorComparaPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorComparaPara *] * */ TransFactorComparaPara * TransFactorComparaPara_alloc(void) { TransFactorComparaPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransFactorComparaPara *) ckalloc (sizeof(TransFactorComparaPara))) == NULL) { warn("TransFactorComparaPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->overlap_type = TFCOMPARA_OVERLAP_PRECISE; out->overlap_len = 0; out->missing_seq = 0; return out; } /* Function: free_TransFactorComparaPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorComparaPara *] * * Return [UNKN ] Undocumented return value [TransFactorComparaPara *] * */ TransFactorComparaPara * free_TransFactorComparaPara(TransFactorComparaPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransFactorComparaPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_TransFactorBuildPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorBuildPara *] * * Return [UNKN ] Undocumented return value [TransFactorBuildPara *] * */ TransFactorBuildPara * hard_link_TransFactorBuildPara(TransFactorBuildPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransFactorBuildPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransFactorBuildPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorBuildPara *] * */ TransFactorBuildPara * TransFactorBuildPara_alloc(void) { TransFactorBuildPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransFactorBuildPara *) ckalloc (sizeof(TransFactorBuildPara))) == NULL) { warn("TransFactorBuildPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->rnd_dna = NULL; out->pseudo_count = 0.3; out->warn_on_small_seq = TRUE; return out; } /* Function: free_TransFactorBuildPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorBuildPara *] * * Return [UNKN ] Undocumented return value [TransFactorBuildPara *] * */ TransFactorBuildPara * free_TransFactorBuildPara(TransFactorBuildPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransFactorBuildPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->rnd_dna != NULL) free_RandomModelDNA(obj->rnd_dna); ckfree(obj); return NULL; } /* Function: hard_link_TransFactorMatchPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorMatchPara *] * * Return [UNKN ] Undocumented return value [TransFactorMatchPara *] * */ TransFactorMatchPara * hard_link_TransFactorMatchPara(TransFactorMatchPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransFactorMatchPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransFactorMatchPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorMatchPara *] * */ TransFactorMatchPara * TransFactorMatchPara_alloc(void) { TransFactorMatchPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransFactorMatchPara *) ckalloc (sizeof(TransFactorMatchPara))) == NULL) { warn("TransFactorMatchPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->min_bits = 11.0; out->min_relative = 11.0; out->relative_prob = 0; out->relative_prob_bits = 0; out->type = TFM_RELATIVE_MIXED; out->allow_N = 0; return out; } /* Function: free_TransFactorMatchPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorMatchPara *] * * Return [UNKN ] Undocumented return value [TransFactorMatchPara *] * */ TransFactorMatchPara * free_TransFactorMatchPara(TransFactorMatchPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransFactorMatchPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/transfactor.h0000644000175000001440000006450510670453715016644 0ustar philippusers#ifndef DYNAMITEtransfactorHEADERFILE #define DYNAMITEtransfactorHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "pwmdna.h" #include "hitlist.h" #define TransFactorSetLISTLENGTH 64 #define TransFactorMatchSetLISTLENGTH 64 #define TransFactorMatchSetComparaLISTLENGTH 8 #define TFCOMPARA_OVERLAP_PRECISE 37 #define TFCOMPARA_OVERLAP_OVERLAP 38 #define TFCOMPARA_OVERLAP_REGION 39 #define TFM_ABSOLUTE 84 #define TFM_RELATIVE 85 #define TFM_RELATIVE_MIXED 86 struct Wise2_TransFactor { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; SeqAlign * seed; pwmDNA * pwm; SeqAlign * full; double max_prob; double min_prob; } ; /* TransFactor defined */ #ifndef DYNAMITE_DEFINED_TransFactor typedef struct Wise2_TransFactor Wise2_TransFactor; #define TransFactor Wise2_TransFactor #define DYNAMITE_DEFINED_TransFactor #endif struct Wise2_TransFactorSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif TransFactor ** factor; int len;/* len for above factor */ int maxlen; /* maxlen for above factor */ } ; /* TransFactorSet defined */ #ifndef DYNAMITE_DEFINED_TransFactorSet typedef struct Wise2_TransFactorSet Wise2_TransFactorSet; #define TransFactorSet Wise2_TransFactorSet #define DYNAMITE_DEFINED_TransFactorSet #endif struct Wise2_TransFactorMatch { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start; int end; char strand; double bit_score; TransFactor * factor; } ; /* TransFactorMatch defined */ #ifndef DYNAMITE_DEFINED_TransFactorMatch typedef struct Wise2_TransFactorMatch Wise2_TransFactorMatch; #define TransFactorMatch Wise2_TransFactorMatch #define DYNAMITE_DEFINED_TransFactorMatch #endif struct Wise2_TransFactorMatchSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif TransFactorMatch ** match; int len;/* len for above match */ int maxlen; /* maxlen for above match */ Sequence * target; } ; /* TransFactorMatchSet defined */ #ifndef DYNAMITE_DEFINED_TransFactorMatchSet typedef struct Wise2_TransFactorMatchSet Wise2_TransFactorMatchSet; #define TransFactorMatchSet Wise2_TransFactorMatchSet #define DYNAMITE_DEFINED_TransFactorMatchSet #endif struct Wise2_TransFactorMatchSetCompara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeqAlign * sa; TransFactorMatchSet ** tfms; int len;/* len for above tfms */ int maxlen; /* maxlen for above tfms */ TransFactorMatchSet * overall; } ; /* TransFactorMatchSetCompara defined */ #ifndef DYNAMITE_DEFINED_TransFactorMatchSetCompara typedef struct Wise2_TransFactorMatchSetCompara Wise2_TransFactorMatchSetCompara; #define TransFactorMatchSetCompara Wise2_TransFactorMatchSetCompara #define DYNAMITE_DEFINED_TransFactorMatchSetCompara #endif struct Wise2_TransFactorComparaPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int overlap_type; int overlap_len; int missing_seq; } ; /* TransFactorComparaPara defined */ #ifndef DYNAMITE_DEFINED_TransFactorComparaPara typedef struct Wise2_TransFactorComparaPara Wise2_TransFactorComparaPara; #define TransFactorComparaPara Wise2_TransFactorComparaPara #define DYNAMITE_DEFINED_TransFactorComparaPara #endif struct Wise2_TransFactorBuildPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif RandomModelDNA * rnd_dna; double pseudo_count; boolean warn_on_small_seq; } ; /* TransFactorBuildPara defined */ #ifndef DYNAMITE_DEFINED_TransFactorBuildPara typedef struct Wise2_TransFactorBuildPara Wise2_TransFactorBuildPara; #define TransFactorBuildPara Wise2_TransFactorBuildPara #define DYNAMITE_DEFINED_TransFactorBuildPara #endif struct Wise2_TransFactorMatchPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif double min_bits; double min_relative; double relative_prob; double relative_prob_bits; char type; int allow_N; } ; /* TransFactorMatchPara defined */ #ifndef DYNAMITE_DEFINED_TransFactorMatchPara typedef struct Wise2_TransFactorMatchPara Wise2_TransFactorMatchPara; #define TransFactorMatchPara Wise2_TransFactorMatchPara #define DYNAMITE_DEFINED_TransFactorMatchPara #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_TransFactor(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactor *] * * Return [UNKN ] Undocumented return value [TransFactor *] * */ TransFactor * Wise2_hard_link_TransFactor(TransFactor * obj); #define hard_link_TransFactor Wise2_hard_link_TransFactor /* Function: TransFactor_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactor *] * */ TransFactor * Wise2_TransFactor_alloc(void); #define TransFactor_alloc Wise2_TransFactor_alloc /* Function: free_TransFactor(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactor *] * * Return [UNKN ] Undocumented return value [TransFactor *] * */ TransFactor * Wise2_free_TransFactor(TransFactor * obj); #define free_TransFactor Wise2_free_TransFactor /* Function: add_TransFactorSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransFactorSet *] * Arg: add [OWNER] Object to add to the list [TransFactor *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_TransFactorSet(TransFactorSet * obj,TransFactor * add); #define add_TransFactorSet Wise2_add_TransFactorSet /* Function: flush_TransFactorSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransFactorSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_TransFactorSet(TransFactorSet * obj); #define flush_TransFactorSet Wise2_flush_TransFactorSet /* Function: TransFactorSet_alloc_std(void) * * Descrip: Equivalent to TransFactorSet_alloc_len(TransFactorSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransFactorSet *] * */ TransFactorSet * Wise2_TransFactorSet_alloc_std(void); #define TransFactorSet_alloc_std Wise2_TransFactorSet_alloc_std /* Function: TransFactorSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransFactorSet *] * */ TransFactorSet * Wise2_TransFactorSet_alloc_len(int len); #define TransFactorSet_alloc_len Wise2_TransFactorSet_alloc_len /* Function: hard_link_TransFactorSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorSet *] * * Return [UNKN ] Undocumented return value [TransFactorSet *] * */ TransFactorSet * Wise2_hard_link_TransFactorSet(TransFactorSet * obj); #define hard_link_TransFactorSet Wise2_hard_link_TransFactorSet /* Function: TransFactorSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorSet *] * */ TransFactorSet * Wise2_TransFactorSet_alloc(void); #define TransFactorSet_alloc Wise2_TransFactorSet_alloc /* Function: free_TransFactorSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorSet *] * * Return [UNKN ] Undocumented return value [TransFactorSet *] * */ TransFactorSet * Wise2_free_TransFactorSet(TransFactorSet * obj); #define free_TransFactorSet Wise2_free_TransFactorSet /* Function: hard_link_TransFactorMatch(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorMatch *] * * Return [UNKN ] Undocumented return value [TransFactorMatch *] * */ TransFactorMatch * Wise2_hard_link_TransFactorMatch(TransFactorMatch * obj); #define hard_link_TransFactorMatch Wise2_hard_link_TransFactorMatch /* Function: TransFactorMatch_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorMatch *] * */ TransFactorMatch * Wise2_TransFactorMatch_alloc(void); #define TransFactorMatch_alloc Wise2_TransFactorMatch_alloc /* Function: free_TransFactorMatch(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorMatch *] * * Return [UNKN ] Undocumented return value [TransFactorMatch *] * */ TransFactorMatch * Wise2_free_TransFactorMatch(TransFactorMatch * obj); #define free_TransFactorMatch Wise2_free_TransFactorMatch /* Function: add_TransFactorMatchSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransFactorMatchSet *] * Arg: add [OWNER] Object to add to the list [TransFactorMatch *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_TransFactorMatchSet(TransFactorMatchSet * obj,TransFactorMatch * add); #define add_TransFactorMatchSet Wise2_add_TransFactorMatchSet /* Function: flush_TransFactorMatchSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransFactorMatchSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_TransFactorMatchSet(TransFactorMatchSet * obj); #define flush_TransFactorMatchSet Wise2_flush_TransFactorMatchSet /* Function: TransFactorMatchSet_alloc_std(void) * * Descrip: Equivalent to TransFactorMatchSet_alloc_len(TransFactorMatchSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransFactorMatchSet *] * */ TransFactorMatchSet * Wise2_TransFactorMatchSet_alloc_std(void); #define TransFactorMatchSet_alloc_std Wise2_TransFactorMatchSet_alloc_std /* Function: TransFactorMatchSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransFactorMatchSet *] * */ TransFactorMatchSet * Wise2_TransFactorMatchSet_alloc_len(int len); #define TransFactorMatchSet_alloc_len Wise2_TransFactorMatchSet_alloc_len /* Function: hard_link_TransFactorMatchSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorMatchSet *] * * Return [UNKN ] Undocumented return value [TransFactorMatchSet *] * */ TransFactorMatchSet * Wise2_hard_link_TransFactorMatchSet(TransFactorMatchSet * obj); #define hard_link_TransFactorMatchSet Wise2_hard_link_TransFactorMatchSet /* Function: TransFactorMatchSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorMatchSet *] * */ TransFactorMatchSet * Wise2_TransFactorMatchSet_alloc(void); #define TransFactorMatchSet_alloc Wise2_TransFactorMatchSet_alloc /* Function: free_TransFactorMatchSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorMatchSet *] * * Return [UNKN ] Undocumented return value [TransFactorMatchSet *] * */ TransFactorMatchSet * Wise2_free_TransFactorMatchSet(TransFactorMatchSet * obj); #define free_TransFactorMatchSet Wise2_free_TransFactorMatchSet /* Function: add_TransFactorMatchSetCompara(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransFactorMatchSetCompara *] * Arg: add [OWNER] Object to add to the list [TransFactorMatchSet *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_TransFactorMatchSetCompara(TransFactorMatchSetCompara * obj,TransFactorMatchSet * add); #define add_TransFactorMatchSetCompara Wise2_add_TransFactorMatchSetCompara /* Function: flush_TransFactorMatchSetCompara(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransFactorMatchSetCompara *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_TransFactorMatchSetCompara(TransFactorMatchSetCompara * obj); #define flush_TransFactorMatchSetCompara Wise2_flush_TransFactorMatchSetCompara /* Function: TransFactorMatchSetCompara_alloc_std(void) * * Descrip: Equivalent to TransFactorMatchSetCompara_alloc_len(TransFactorMatchSetComparaLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransFactorMatchSetCompara *] * */ TransFactorMatchSetCompara * Wise2_TransFactorMatchSetCompara_alloc_std(void); #define TransFactorMatchSetCompara_alloc_std Wise2_TransFactorMatchSetCompara_alloc_std /* Function: TransFactorMatchSetCompara_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransFactorMatchSetCompara *] * */ TransFactorMatchSetCompara * Wise2_TransFactorMatchSetCompara_alloc_len(int len); #define TransFactorMatchSetCompara_alloc_len Wise2_TransFactorMatchSetCompara_alloc_len /* Function: hard_link_TransFactorMatchSetCompara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorMatchSetCompara *] * * Return [UNKN ] Undocumented return value [TransFactorMatchSetCompara *] * */ TransFactorMatchSetCompara * Wise2_hard_link_TransFactorMatchSetCompara(TransFactorMatchSetCompara * obj); #define hard_link_TransFactorMatchSetCompara Wise2_hard_link_TransFactorMatchSetCompara /* Function: TransFactorMatchSetCompara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorMatchSetCompara *] * */ TransFactorMatchSetCompara * Wise2_TransFactorMatchSetCompara_alloc(void); #define TransFactorMatchSetCompara_alloc Wise2_TransFactorMatchSetCompara_alloc /* Function: free_TransFactorMatchSetCompara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorMatchSetCompara *] * * Return [UNKN ] Undocumented return value [TransFactorMatchSetCompara *] * */ TransFactorMatchSetCompara * Wise2_free_TransFactorMatchSetCompara(TransFactorMatchSetCompara * obj); #define free_TransFactorMatchSetCompara Wise2_free_TransFactorMatchSetCompara /* Function: hard_link_TransFactorComparaPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorComparaPara *] * * Return [UNKN ] Undocumented return value [TransFactorComparaPara *] * */ TransFactorComparaPara * Wise2_hard_link_TransFactorComparaPara(TransFactorComparaPara * obj); #define hard_link_TransFactorComparaPara Wise2_hard_link_TransFactorComparaPara /* Function: TransFactorComparaPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorComparaPara *] * */ TransFactorComparaPara * Wise2_TransFactorComparaPara_alloc(void); #define TransFactorComparaPara_alloc Wise2_TransFactorComparaPara_alloc /* Function: free_TransFactorComparaPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorComparaPara *] * * Return [UNKN ] Undocumented return value [TransFactorComparaPara *] * */ TransFactorComparaPara * Wise2_free_TransFactorComparaPara(TransFactorComparaPara * obj); #define free_TransFactorComparaPara Wise2_free_TransFactorComparaPara /* Function: hard_link_TransFactorBuildPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorBuildPara *] * * Return [UNKN ] Undocumented return value [TransFactorBuildPara *] * */ TransFactorBuildPara * Wise2_hard_link_TransFactorBuildPara(TransFactorBuildPara * obj); #define hard_link_TransFactorBuildPara Wise2_hard_link_TransFactorBuildPara /* Function: TransFactorBuildPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorBuildPara *] * */ TransFactorBuildPara * Wise2_TransFactorBuildPara_alloc(void); #define TransFactorBuildPara_alloc Wise2_TransFactorBuildPara_alloc /* Function: free_TransFactorBuildPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorBuildPara *] * * Return [UNKN ] Undocumented return value [TransFactorBuildPara *] * */ TransFactorBuildPara * Wise2_free_TransFactorBuildPara(TransFactorBuildPara * obj); #define free_TransFactorBuildPara Wise2_free_TransFactorBuildPara /* Function: hard_link_TransFactorMatchPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransFactorMatchPara *] * * Return [UNKN ] Undocumented return value [TransFactorMatchPara *] * */ TransFactorMatchPara * Wise2_hard_link_TransFactorMatchPara(TransFactorMatchPara * obj); #define hard_link_TransFactorMatchPara Wise2_hard_link_TransFactorMatchPara /* Function: TransFactorMatchPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransFactorMatchPara *] * */ TransFactorMatchPara * Wise2_TransFactorMatchPara_alloc(void); #define TransFactorMatchPara_alloc Wise2_TransFactorMatchPara_alloc /* Function: free_TransFactorMatchPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransFactorMatchPara *] * * Return [UNKN ] Undocumented return value [TransFactorMatchPara *] * */ TransFactorMatchPara * Wise2_free_TransFactorMatchPara(TransFactorMatchPara * obj); #define free_TransFactorMatchPara Wise2_free_TransFactorMatchPara /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_show_context_match_TransFactorMatchSetCompara(TransFactorMatchSetCompara * tfmsc,int context,FILE *ofp); #define show_context_match_TransFactorMatchSetCompara Wise2_show_context_match_TransFactorMatchSetCompara TransFactorSet * Wise2_circular_permuted_TransFactorSet(TransFactorSet * in,int rotate_number); #define circular_permuted_TransFactorSet Wise2_circular_permuted_TransFactorSet void Wise2_show_TransFactorMatchSet(TransFactorMatchSet * tfms,FILE * ofp); #define show_TransFactorMatchSet Wise2_show_TransFactorMatchSet void Wise2_show_help_TransFactorMatchPara(FILE * ofp); #define show_help_TransFactorMatchPara Wise2_show_help_TransFactorMatchPara void Wise2_show_help_TransFactorComparaPara(FILE * ofp); #define show_help_TransFactorComparaPara Wise2_show_help_TransFactorComparaPara TransFactorComparaPara * Wise2_new_TransFactorComparaPara_from_argv(int * argc,char ** argv); #define new_TransFactorComparaPara_from_argv Wise2_new_TransFactorComparaPara_from_argv TransFactorMatchSetCompara * Wise2_calculate_TransFactorMatchSetCompara(SeqAlign * sa,TransFactorSet * tfs,TransFactorMatchPara * match_para,TransFactorComparaPara * para); #define calculate_TransFactorMatchSetCompara Wise2_calculate_TransFactorMatchSetCompara void Wise2_show_help_TransFactorBuildPara(FILE * ofp); #define show_help_TransFactorBuildPara Wise2_show_help_TransFactorBuildPara TransFactorBuildPara * Wise2_new_TransFactorBuildPara_from_argv(int * argc,char ** argv); #define new_TransFactorBuildPara_from_argv Wise2_new_TransFactorBuildPara_from_argv TransFactorMatchPara * Wise2_new_TransFactorMatchPara_from_argv(int * argc,char ** argv); #define new_TransFactorMatchPara_from_argv Wise2_new_TransFactorMatchPara_from_argv boolean Wise2_build_TransFactorSet(TransFactorSet * tfs,TransFactorBuildPara * p); #define build_TransFactorSet Wise2_build_TransFactorSet boolean Wise2_build_pwm_TransFactor(TransFactor * tf,TransFactorBuildPara * p); #define build_pwm_TransFactor Wise2_build_pwm_TransFactor TransFactorMatchSet * Wise2_calculate_TransFactorMatchSet(Sequence * seq,TransFactorSet * tfs,TransFactorMatchPara * p); #define calculate_TransFactorMatchSet Wise2_calculate_TransFactorMatchSet double Wise2_min_prob_TransFactor(TransFactor * tf); #define min_prob_TransFactor Wise2_min_prob_TransFactor double Wise2_max_prob_TransFactor(TransFactor * tf); #define max_prob_TransFactor Wise2_max_prob_TransFactor void Wise2_write_TransFactorSet(TransFactorSet * tfs,FILE * ofp); #define write_TransFactorSet Wise2_write_TransFactorSet void Wise2_write_TransFactor(TransFactor * tf,FILE * ofp); #define write_TransFactor Wise2_write_TransFactor TransFactorSet * Wise2_read_TransFactorSet_file(char * filename); #define read_TransFactorSet_file Wise2_read_TransFactorSet_file TransFactorSet * Wise2_read_ben_IUPAC_TransFactorSet_file(char * filename); #define read_ben_IUPAC_TransFactorSet_file Wise2_read_ben_IUPAC_TransFactorSet_file TransFactorSet * Wise2_read_ben_IUPAC_TransFactorSet(FILE * ifp); #define read_ben_IUPAC_TransFactorSet Wise2_read_ben_IUPAC_TransFactorSet TransFactorSet * Wise2_read_laurence_TransFactorSet_file(char * filename); #define read_laurence_TransFactorSet_file Wise2_read_laurence_TransFactorSet_file TransFactorSet * Wise2_read_laurence_TransFactorSet(FILE * ifp); #define read_laurence_TransFactorSet Wise2_read_laurence_TransFactorSet TransFactorSet * Wise2_read_TransFactorSet(FILE * ifp); #define read_TransFactorSet Wise2_read_TransFactorSet TransFactor * Wise2_read_TransFactor(char * line,FILE * ifp); #define read_TransFactor Wise2_read_TransFactor int Wise2_compare_start_TransFactorMatch(TransFactorMatch * a,TransFactorMatch * b); #define compare_start_TransFactorMatch Wise2_compare_start_TransFactorMatch void Wise2_sort_by_start_TransFactorMatchSet(TransFactorMatchSet * t); #define sort_by_start_TransFactorMatchSet Wise2_sort_by_start_TransFactorMatchSet /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_TransFactorSet(TransFactor ** list,int i,int j) ; #define swap_TransFactorSet Wise2_swap_TransFactorSet void Wise2_qsort_TransFactorSet(TransFactor ** list,int left,int right,int (*comp)(TransFactor * ,TransFactor * )); #define qsort_TransFactorSet Wise2_qsort_TransFactorSet void Wise2_sort_TransFactorSet(TransFactorSet * obj,int (*comp)(TransFactor *, TransFactor *)); #define sort_TransFactorSet Wise2_sort_TransFactorSet boolean Wise2_expand_TransFactorSet(TransFactorSet * obj,int len); #define expand_TransFactorSet Wise2_expand_TransFactorSet void Wise2_swap_TransFactorMatchSet(TransFactorMatch ** list,int i,int j) ; #define swap_TransFactorMatchSet Wise2_swap_TransFactorMatchSet void Wise2_qsort_TransFactorMatchSet(TransFactorMatch ** list,int left,int right,int (*comp)(TransFactorMatch * ,TransFactorMatch * )); #define qsort_TransFactorMatchSet Wise2_qsort_TransFactorMatchSet void Wise2_sort_TransFactorMatchSet(TransFactorMatchSet * obj,int (*comp)(TransFactorMatch *, TransFactorMatch *)); #define sort_TransFactorMatchSet Wise2_sort_TransFactorMatchSet boolean Wise2_expand_TransFactorMatchSet(TransFactorMatchSet * obj,int len); #define expand_TransFactorMatchSet Wise2_expand_TransFactorMatchSet void Wise2_swap_TransFactorMatchSetCompara(TransFactorMatchSet ** list,int i,int j) ; #define swap_TransFactorMatchSetCompara Wise2_swap_TransFactorMatchSetCompara void Wise2_qsort_TransFactorMatchSetCompara(TransFactorMatchSet ** list,int left,int right,int (*comp)(TransFactorMatchSet * ,TransFactorMatchSet * )); #define qsort_TransFactorMatchSetCompara Wise2_qsort_TransFactorMatchSetCompara void Wise2_sort_TransFactorMatchSetCompara(TransFactorMatchSetCompara * obj,int (*comp)(TransFactorMatchSet *, TransFactorMatchSet *)); #define sort_TransFactorMatchSetCompara Wise2_sort_TransFactorMatchSetCompara boolean Wise2_expand_TransFactorMatchSetCompara(TransFactorMatchSetCompara * obj,int len); #define expand_TransFactorMatchSetCompara Wise2_expand_TransFactorMatchSetCompara #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/wise2xhmmer2.c0000644000175000001440000002744510670453715016647 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "wise2xhmmer2.h" #ifndef HMMER2_EXTERN_DEFINED #include "globals.h" #endif /* Function: bootstrap_HMMer2(void) * * Descrip: You need to call this function before you * call any other to get the HMMer2 system working ;) * * * */ # line 45 "wise2xhmmer2.dy" void bootstrap_HMMer2(void) { SetAlphabet(hmmAMINO); } /* Function: read_SeqAlign_HMMER(seqfile) * * Descrip: This function read a single SeqAlign from * the filename using the HMMER libraries * * * Arg: seqfile [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ # line 54 "wise2xhmmer2.dy" SeqAlign * read_SeqAlign_HMMER(char * seqfile) { AINFO ainfo; char ** data; int format; SeqAlign * out; int i; Sequence * temp; if (! SeqfileFormat(seqfile, &format, NULL) ) { switch (squid_errno) { case SQERR_NOFILE: warn("Alignment file %s could not be opened for reading", seqfile); return NULL; case SQERR_FORMAT: default: warn("Failed to determine format of alignment file %s", seqfile); } } /* attempt to read it in now */ if (! ReadAlignment(seqfile, format, &data, &ainfo)) { warn("Failed to read aligned sequence file %s", seqfile); return NULL; } /* make SeqAlign */ out = SeqAlign_alloc_len(ainfo.nseq); for (i = 0; i < ainfo.nseq; i++) { temp = new_Sequence_from_strings(ainfo.sqinfo[i].name,data[i]); add_SeqAlign(out,temp); } return out; } /* Function: HMMer2_read_ThreeStateModel(filename) * * Descrip: This function reads a single HMM from * filename for a ThreeStateModel * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 101 "wise2xhmmer2.dy" ThreeStateModel * HMMer2_read_ThreeStateModel(char * filename) { struct plan7_s *hmm; ThreeStateModel * out; HMMFILE * hmmfp; if( filename == NULL ) { warn("You have passed in a NULL filename into HMMer2_read_ThreeStateModel - unlikely to work!"); return NULL; } hmmfp = HMMFileOpen(filename,"HMMERDB"); if( hmmfp == NULL ) { warn("Could not open %s for HMM reading",filename); return NULL; } if( HMMFileRead(hmmfp, &hmm) == 0 ) { return NULL; } if( hmm == NULL ) { warn("Unable to read HMM file... "); return NULL; } out = ThreeStateModel_from_HMMer2(hmm); FreePlan7(hmm); return out; } /* Function: HMMer2_ThreeStateDB(filename) * * Descrip: This function makes a new ThreeStateDB * from a filename for the HMMer2 system. * * * Arg: filename [SOFT ] filename of the HMMer db [char *] * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ # line 140 "wise2xhmmer2.dy" ThreeStateDB * HMMer2_ThreeStateDB(char * filename) { ThreeStateDB * out; out = ThreeStateDB_alloc(); out->dbtype = TSMDB_GENERIC; out->filename = stringalloc(filename); out->reload_generic = reload_ThreeStateDB_HMMer2; out->open_generic = open_ThreeStateDB_HMMer2; out->close_generic = close_ThreeStateDB_HMMer2; out->dataentry_add = dataentry_ThreeStateDB_HMMer2; out->open_index_generic = open_for_indexing_ThreeStateDB_HMMer2; out->close_index_generic = close_for_indexing_ThreeStateDB_HMMer2; out->index_generic = index_ThreeStateDB_HMMer2; return out; } /* Function: open_for_indexing_ThreeStateDB_HMMer2(tdb) * * Descrip: This function is the generic wrapper for the * threestatedb open for indexing * * * Arg: tdb [UNKN ] Undocumented argument [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 163 "wise2xhmmer2.dy" boolean open_for_indexing_ThreeStateDB_HMMer2(ThreeStateDB * tdb) { return TRUE; /* nowt to do ! */ } /* Function: close_for_indexing_ThreeStateDB_HMMer2(tdb) * * Descrip: This function is the generic wrapper for the * threestatedb open for indexing * * * Arg: tdb [UNKN ] Undocumented argument [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 173 "wise2xhmmer2.dy" boolean close_for_indexing_ThreeStateDB_HMMer2(ThreeStateDB * tdb) { return TRUE; /* nowt to do ! */ } #ifdef HMMER_2_1_2 /* new style indexing */ ThreeStateModel * index_ThreeStateDB_HMMer2(ThreeStateDB * tdb,DataEntry *de) { struct plan7_s *hmm; ThreeStateModel * out; HMMFILE * hmmfp; hmmfp = HMMFileOpen(tdb->filename,"HMMERDB"); if( hmmfp == NULL ) { warn("Could not open %s as HMMER file\n",tdb->filename); return NULL; } if( hmmfp->gsi == NULL ) { warn("Could not retrieve sequences from HMMER database as it is not indexed!"); return NULL; } if( ! HMMFilePositionByName(hmmfp,de->name) ) { warn("Unable to find HMM %s in %s",de->name,tdb->filename); return NULL; } if( HMMFileRead(hmmfp, &hmm) == 0 ) { return NULL; } if( hmm == NULL ) { warn("Unable to read HMM file... "); return NULL; } out = ThreeStateModel_from_HMMer2(hmm); FreePlan7(hmm); HMMFileClose(hmmfp); return out; } #else /* use old style indexing */ /* Function: index_ThreeStateDB_HMMer2(tdb,*de) * * Descrip: This function is the generic wrapper for the * threestatedb get indexed * * * Arg: tdb [UNKN ] Undocumented argument [ThreeStateDB *] * Arg: *de [UNKN ] Undocumented argument [DataEntry] * * Return [UNKN ] Undocumented return value [ThreeStateModel*] * */ # line 225 "wise2xhmmer2.dy" ThreeStateModel* index_ThreeStateDB_HMMer2(ThreeStateDB * tdb,DataEntry *de) { struct plan7_s *hmm; ThreeStateModel * out; HMMFILE * hmmfp; hmmfp = HMMFileOpenFseek(tdb->filename,"HMMERDB",de->byte_position); if( hmmfp == NULL ) { warn("Could not open %s to byte position %d",tdb->filename,de->data[0]); return NULL; } if( HMMFileRead(hmmfp, &hmm) == 0 ) { return NULL; } if( hmm == NULL ) { warn("Unable to read HMM file... "); return NULL; } out = ThreeStateModel_from_HMMer2(hmm); FreePlan7(hmm); HMMFileClose(hmmfp); return out; } #endif /* HMMER_2_1_2 */ /* Function: dataentry_ThreeStateDB_HMMer2(tdb,en) * * Descrip: This function is the generic wrapper * for the threestatedb info for hmmer2 * * * Arg: tdb [UNKN ] Undocumented argument [ThreeStateDB *] * Arg: en [UNKN ] Undocumented argument [DataEntry *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 262 "wise2xhmmer2.dy" boolean dataentry_ThreeStateDB_HMMer2(ThreeStateDB * tdb,DataEntry * en) { HMMFILE * hmmfp; hmmfp = (HMMFILE *) (tdb->data); #ifdef HMMER_2_1_2 en->data[0] = 0; /* we rely on the fact that someone has already set the name */ #else en->data[0] = HMMFtell(hmmfp); en->byte_position = tdb->byte_position; #endif return TRUE; } /* Function: close_ThreeStateDB_HMMer2(tdb) * * Descrip: This function is the generic wrapper * for the threestatedb close for hmmer2 * * * Arg: tdb [UNKN ] Undocumented argument [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 286 "wise2xhmmer2.dy" boolean close_ThreeStateDB_HMMer2(ThreeStateDB * tdb) { HMMFILE * hmmfp; hmmfp = (HMMFILE *) (tdb->data); HMMFileClose(hmmfp); return TRUE; } /* Function: reload_ThreeStateDB_HMMer2(tdb,return_status) * * Descrip: This function is the generic wrapper * for the threestatedb relaod function for hmmer2 * * * Arg: tdb [UNKN ] Undocumented argument [ThreeStateDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 302 "wise2xhmmer2.dy" ThreeStateModel * reload_ThreeStateDB_HMMer2(ThreeStateDB * tdb,int * return_status) { struct plan7_s *hmm; ThreeStateModel * out; HMMFILE * hmmfp; hmmfp = (HMMFILE *) (tdb->data); #ifndef HMMER_2_1_2 tdb->byte_position = HMMFtell(hmmfp); #endif if( HMMFileRead(hmmfp, &hmm) == 0 ) { /* end of file */ *return_status = DB_RETURN_END; return NULL; } if( hmm == NULL ) { warn("Unable to read HMM file... "); *return_status = DB_RETURN_ERROR; } *return_status = DB_RETURN_OK; out = ThreeStateModel_from_HMMer2(hmm); FreePlan7(hmm); return out; } /* Function: open_ThreeStateDB_HMMer2(tdb) * * Descrip: This function is the generic wrapper * for the threestatedb open function * * * Arg: tdb [UNKN ] Undocumented argument [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 340 "wise2xhmmer2.dy" boolean open_ThreeStateDB_HMMer2(ThreeStateDB * tdb) { if( tdb->data != NULL ) { warn("Attempting to open an already open tdb. Ugh!"); return FALSE; } if( (tdb->data = (void *)HMMFileOpen(tdb->filename,"HMMERDB")) == NULL ) { warn("Could not open %s as a filename for hmmer2 directory",tdb->filename); return FALSE; } tdb->byte_position = 0; return TRUE; } /* Function: ThreeStateModel_from_HMMer2(p7) * * Descrip: This function converts a HMMer2 HMM into * a Wise2 HMM (threestatemodel). * * * Arg: p7 [UNKN ] Undocumented argument [struct plan7_s *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 363 "wise2xhmmer2.dy" ThreeStateModel * ThreeStateModel_from_HMMer2(struct plan7_s * p7) { ThreeStateModel * out; ThreeStateUnit * unit; int i,j; char * runner; if( p7 == NULL ) { warn("Can't make a ThreeStateModel from a NULL pointer... "); return NULL; } out = ThreeStateModel_alloc_len(p7->M); if( out == NULL ) return NULL; /* already complained*/ out->name = stringalloc(p7->name); #ifdef HMMER_2_1_2 if( p7->acc != NULL ) { out->accession = stringalloc(p7->acc); } else { out->accession = stringalloc(p7->name); } #else /* munge around accession number. Ugh! */ if( p7->desc != NULL ) { runner = strtok(p7->desc,spacestr); if( runner != NULL && strstartcmp(runner,"PF") == 0 ) { out->accession = stringalloc(runner); } else { out->accession = stringalloc(p7->name); } } #endif for(i=0;iM;i++) { unit = blank_ThreeStateUnit(); add_ThreeStateModel(out,unit); if( i != p7->M-1) { unit->transition[TSM_MATCH2MATCH]= p7->t[i+1][TMM]; unit->transition[TSM_MATCH2DELETE]= p7->t[i+1][TMD]; unit->transition[TSM_MATCH2INSERT]= p7->t[i+1][TMI]; unit->transition[TSM_INSERT2MATCH]= p7->t[i+1][TIM]; unit->transition[TSM_INSERT2INSERT]= p7->t[i+1][TII]; unit->transition[TSM_DELETE2MATCH]= p7->t[i+1][TDM]; unit->transition[TSM_DELETE2DELETE]= p7->t[i+1][TDD]; unit->transition[TSM_START2MATCH] = p7->begin[i+1]; unit->transition[TSM_MATCH2END] = p7->end[i+1]; } if( i == p7->M-1) { /* all probability onto end */ unit->transition[TSM_MATCH2END] = 1.0; } /* we have to map sean's probabilities over to ours */ for(j=0;jmatch_emission[Alphabet[j]-'A'] = p7->mat[i+1][j]; } if( i != p7->M-1) { for(j=0;jinsert_emission[Alphabet[j]-'A'] = p7->ins[i+1][j]; } } else { /* no insert position! - could leave as 0's? */ /* but this does upset some sensible error tracking code */ /* set it to 1/26 probs ;) */ for(j=0;jinsert_emission[Alphabet[j]-'A'] = p7->ins[1][j]; } } } out->rm = RandomModel_alloc(); for(i=0;i<26;i++) out->rm->aminoacid[i] = 1.0; for(j=0;jrm->aminoacid[Alphabet[j]-'A'] = p7->null[j]; } display_char_in_ThreeStateModel(out); return out; } # line 499 "wise2xhmmer2.c" #ifdef _cplusplus } #endif wise-2.4.1/src/models/wise2xhmmer2.h0000644000175000001440000001063110670453715016641 0ustar philippusers#ifndef DYNAMITEwise2xhmmer2HEADERFILE #define DYNAMITEwise2xhmmer2HEADERFILE #ifdef _cplusplus extern "C" { #endif /* include stdio etc */ #include "wisebase.h" /* include hmmer2 files */ /* we have to prevent some namespace clobbering between different versions of histogram */ #ifndef NO_HMMER_INCLUDES #include "structs.h" #include "funcs.h" #endif /* include dynamite files */ /*#include "dyna.h"*/ #include "seqalign.h" #include "threestatemodel.h" #include "threestatedb.h" /* quieten down gcc about struct p7 */ struct plan7_s; #ifndef DYNAMITE_DEFINED_ThreeStateDB typedef struct Wise2_ThreeStateDB Wise2_ThreeStateDB; #define ThreeStateDB Wise2_ThreeStateDB #define DYNAMITE_DEFINED_ThreeStateDB #endif #ifndef DYNAMITE_DEFINED_SeqAlign typedef struct Wise2_SeqAlign Wise2_SeqAlign; #define SeqAlign Wise2_SeqAlign #define DYNAMITE_DEFINED_SeqAlign #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: bootstrap_HMMer2(void) * * Descrip: You need to call this function before you * call any other to get the HMMer2 system working ;) * * * */ void Wise2_bootstrap_HMMer2(void); #define bootstrap_HMMer2 Wise2_bootstrap_HMMer2 /* Function: read_SeqAlign_HMMER(seqfile) * * Descrip: This function read a single SeqAlign from * the filename using the HMMER libraries * * * Arg: seqfile [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * Wise2_read_SeqAlign_HMMER(char * seqfile); #define read_SeqAlign_HMMER Wise2_read_SeqAlign_HMMER /* Function: HMMer2_read_ThreeStateModel(filename) * * Descrip: This function reads a single HMM from * filename for a ThreeStateModel * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_HMMer2_read_ThreeStateModel(char * filename); #define HMMer2_read_ThreeStateModel Wise2_HMMer2_read_ThreeStateModel /* Function: HMMer2_ThreeStateDB(filename) * * Descrip: This function makes a new ThreeStateDB * from a filename for the HMMer2 system. * * * Arg: filename [SOFT ] filename of the HMMer db [char *] * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ ThreeStateDB * Wise2_HMMer2_ThreeStateDB(char * filename); #define HMMer2_ThreeStateDB Wise2_HMMer2_ThreeStateDB /* Function: ThreeStateModel_from_HMMer2(p7) * * Descrip: This function converts a HMMer2 HMM into * a Wise2 HMM (threestatemodel). * * * Arg: p7 [UNKN ] Undocumented argument [struct plan7_s *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_ThreeStateModel_from_HMMer2(struct plan7_s * p7); #define ThreeStateModel_from_HMMer2 Wise2_ThreeStateModel_from_HMMer2 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_open_for_indexing_ThreeStateDB_HMMer2(ThreeStateDB * tdb); #define open_for_indexing_ThreeStateDB_HMMer2 Wise2_open_for_indexing_ThreeStateDB_HMMer2 boolean Wise2_close_for_indexing_ThreeStateDB_HMMer2(ThreeStateDB * tdb); #define close_for_indexing_ThreeStateDB_HMMer2 Wise2_close_for_indexing_ThreeStateDB_HMMer2 ThreeStateModel* Wise2_index_ThreeStateDB_HMMer2(ThreeStateDB * tdb,DataEntry *de); #define index_ThreeStateDB_HMMer2 Wise2_index_ThreeStateDB_HMMer2 boolean Wise2_dataentry_ThreeStateDB_HMMer2(ThreeStateDB * tdb,DataEntry * en); #define dataentry_ThreeStateDB_HMMer2 Wise2_dataentry_ThreeStateDB_HMMer2 boolean Wise2_close_ThreeStateDB_HMMer2(ThreeStateDB * tdb); #define close_ThreeStateDB_HMMer2 Wise2_close_ThreeStateDB_HMMer2 ThreeStateModel * Wise2_reload_ThreeStateDB_HMMer2(ThreeStateDB * tdb,int * return_status); #define reload_ThreeStateDB_HMMer2 Wise2_reload_ThreeStateDB_HMMer2 boolean Wise2_open_ThreeStateDB_HMMer2(ThreeStateDB * tdb) ; #define open_ThreeStateDB_HMMer2 Wise2_open_ThreeStateDB_HMMer2 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/cdparser.c0000644000175000001440000001442610670453713016107 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "cdparser.h" /* Function: removed_probability_from_cds_cdna(cdp) * * Descrip: Makes a convienient sum over all the transition * probabilities * * * Arg: cdp [UNKN ] Undocumented argument [cDNAParser *] * * Return [UNKN ] Undocumented return value [Probability] * */ # line 52 "cdparser.dy" Probability removed_probability_from_cds_cdna(cDNAParser * cdp) { return cdp->trans[PCD_INSERT_2_BASE] + cdp->trans[PCD_INSERT_1_BASE] + cdp->trans[PCD_DELETE_2_BASE] + cdp->trans[PCD_DELETE_1_BASE]; } /* Function: cDNAParserScore_from_cDNAParser(cdp) * * Descrip: Makes a new Score object from its probability * counterpart * * * Arg: cdp [UNKN ] Undocumented argument [cDNAParser *] * * Return [UNKN ] Undocumented return value [cDNAParserScore *] * */ # line 64 "cdparser.dy" cDNAParserScore * cDNAParserScore_from_cDNAParser(cDNAParser * cdp) { cDNAParserScore * out; out = cDNAParserScore_alloc(); Probability2Score_move(cdp->trans,out->trans,PCD_PARSER_TRANS_LEN); return out; } /* Function: flat_cDNAParser(p) * * Descrip: Makes a flat (ie, indels of 1 or 2 == p) * cDNA parser. This means that insertions * and deletions of both 1 or 2 bases are * all parameterised at the same probability * * * * Arg: p [READ ] probability of an indel [Probability] * * Return [UNKN ] Undocumented return value [cDNAParser *] * */ # line 84 "cdparser.dy" cDNAParser * flat_cDNAParser(Probability p) { cDNAParser * out; out = cDNAParser_alloc(); out->trans[PCD_INSERT_2_BASE] = p; out->trans[PCD_INSERT_1_BASE] = p; out->trans[PCD_DELETE_2_BASE] = p; out->trans[PCD_DELETE_1_BASE] = p; return out; } # line 72 "cdparser.c" /* Function: hard_link_cDNAParser(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [cDNAParser *] * * Return [UNKN ] Undocumented return value [cDNAParser *] * */ cDNAParser * hard_link_cDNAParser(cDNAParser * obj) { if( obj == NULL ) { warn("Trying to hard link to a cDNAParser object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: cDNAParser_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [cDNAParser *] * */ cDNAParser * cDNAParser_alloc(void) { cDNAParser * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(cDNAParser *) ckalloc (sizeof(cDNAParser))) == NULL) { warn("cDNAParser_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* trans[PCD_PARSER_TRANS_LEN] is an array: no default possible */ return out; } /* Function: free_cDNAParser(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [cDNAParser *] * * Return [UNKN ] Undocumented return value [cDNAParser *] * */ cDNAParser * free_cDNAParser(cDNAParser * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a cDNAParser obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_cDNAParserScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [cDNAParserScore *] * */ cDNAParserScore * hard_link_cDNAParserScore(cDNAParserScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a cDNAParserScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: cDNAParserScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [cDNAParserScore *] * */ cDNAParserScore * cDNAParserScore_alloc(void) { cDNAParserScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(cDNAParserScore *) ckalloc (sizeof(cDNAParserScore))) == NULL) { warn("cDNAParserScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* trans[PCD_PARSER_TRANS_LEN] is an array: no default possible */ return out; } /* Function: free_cDNAParserScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [cDNAParserScore *] * */ cDNAParserScore * free_cDNAParserScore(cDNAParserScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a cDNAParserScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/cdparser.h0000644000175000001440000001324410670453713016111 0ustar philippusers#ifndef DYNAMITEcdparserHEADERFILE #define DYNAMITEcdparserHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "probability.h" enum cDNAParserTrans { PCD_INSERT_2_BASE = 0, PCD_INSERT_1_BASE, PCD_DELETE_2_BASE, PCD_DELETE_1_BASE, PCD_PARSER_TRANS_LEN }; /* Object cDNAParser * * Descrip: This object holds the (very few) extra * transition information needed for the * estwise algorithm. It is sort of like * the 'gene model' part of sequencing * error (but very very simple) * * * */ struct Wise2_cDNAParser { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability trans[PCD_PARSER_TRANS_LEN]; } ; /* cDNAParser defined */ #ifndef DYNAMITE_DEFINED_cDNAParser typedef struct Wise2_cDNAParser Wise2_cDNAParser; #define cDNAParser Wise2_cDNAParser #define DYNAMITE_DEFINED_cDNAParser #endif /* Object cDNAParserScore * * Descrip: This object is the score counter * point to cDNAParser (which is * in probabilities). * * */ struct Wise2_cDNAParserScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score trans[PCD_PARSER_TRANS_LEN]; } ; /* cDNAParserScore defined */ #ifndef DYNAMITE_DEFINED_cDNAParserScore typedef struct Wise2_cDNAParserScore Wise2_cDNAParserScore; #define cDNAParserScore Wise2_cDNAParserScore #define DYNAMITE_DEFINED_cDNAParserScore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: removed_probability_from_cds_cdna(cdp) * * Descrip: Makes a convienient sum over all the transition * probabilities * * * Arg: cdp [UNKN ] Undocumented argument [cDNAParser *] * * Return [UNKN ] Undocumented return value [Probability] * */ Probability Wise2_removed_probability_from_cds_cdna(cDNAParser * cdp); #define removed_probability_from_cds_cdna Wise2_removed_probability_from_cds_cdna /* Function: cDNAParserScore_from_cDNAParser(cdp) * * Descrip: Makes a new Score object from its probability * counterpart * * * Arg: cdp [UNKN ] Undocumented argument [cDNAParser *] * * Return [UNKN ] Undocumented return value [cDNAParserScore *] * */ cDNAParserScore * Wise2_cDNAParserScore_from_cDNAParser(cDNAParser * cdp); #define cDNAParserScore_from_cDNAParser Wise2_cDNAParserScore_from_cDNAParser /* Function: flat_cDNAParser(p) * * Descrip: Makes a flat (ie, indels of 1 or 2 == p) * cDNA parser. This means that insertions * and deletions of both 1 or 2 bases are * all parameterised at the same probability * * * * Arg: p [READ ] probability of an indel [Probability] * * Return [UNKN ] Undocumented return value [cDNAParser *] * */ cDNAParser * Wise2_flat_cDNAParser(Probability p); #define flat_cDNAParser Wise2_flat_cDNAParser /* Function: hard_link_cDNAParser(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [cDNAParser *] * * Return [UNKN ] Undocumented return value [cDNAParser *] * */ cDNAParser * Wise2_hard_link_cDNAParser(cDNAParser * obj); #define hard_link_cDNAParser Wise2_hard_link_cDNAParser /* Function: cDNAParser_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [cDNAParser *] * */ cDNAParser * Wise2_cDNAParser_alloc(void); #define cDNAParser_alloc Wise2_cDNAParser_alloc /* Function: free_cDNAParser(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [cDNAParser *] * * Return [UNKN ] Undocumented return value [cDNAParser *] * */ cDNAParser * Wise2_free_cDNAParser(cDNAParser * obj); #define free_cDNAParser Wise2_free_cDNAParser /* Function: hard_link_cDNAParserScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [cDNAParserScore *] * */ cDNAParserScore * Wise2_hard_link_cDNAParserScore(cDNAParserScore * obj); #define hard_link_cDNAParserScore Wise2_hard_link_cDNAParserScore /* Function: cDNAParserScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [cDNAParserScore *] * */ cDNAParserScore * Wise2_cDNAParserScore_alloc(void); #define cDNAParserScore_alloc Wise2_cDNAParserScore_alloc /* Function: free_cDNAParserScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [cDNAParserScore *] * */ cDNAParserScore * Wise2_free_cDNAParserScore(cDNAParserScore * obj); #define free_cDNAParserScore Wise2_free_cDNAParserScore /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/clonewise.c0000644000175000001440000002242207313404543016264 0ustar philippusers #include "clonewisedp.h" #include "localclonewisedp.h" #include "version.h" /* * Yup - I know these are globals. It just ends up being * too much of a pain in the arse to coordinate the help printing * defaults with the parameters by passing around a void * structure * which you cast back just to prevent no globals. You want to do this - * feel free to send me a patch to this and also wisecommandline.[ch] and * port all the other wise main functions to use it! */ char * program_name = "genomewise"; int query_gap_start = 2; int query_gap_extend = 1; int target_gap_start = 2; int target_gap_extend = 1; int query_switch_cost = 10; int match_score = 10; int mismatch_score = -1; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s trusted-clone-path weak-clone-path\n",program_name); fprintf(ofp,"Algorithm\n"); /* fprintf(ofp," -spread smell area to use in comparing clones\n"); */ fprintf(ofp," -match [%d] clone match score\n",match_score); fprintf(ofp," -mismatch [%d] clone mismatch score\n",mismatch_score); fprintf(ofp," -wgap [%d] weak gap start cost\n",query_gap_start); fprintf(ofp," -wext [%d] weak gap extension\n",query_gap_extend); fprintf(ofp," -wswitch [%d] weak switch cost\n",query_switch_cost); fprintf(ofp," -tgap [%d] trusted gap start cost\n",target_gap_start); fprintf(ofp," -text [%d] trusted gap extension\n",target_gap_extend); fprintf(ofp,"Output\n"); fprintf(ofp," -[no]path show path format (default no)\n"); fprintf(ofp," -[no]zip show zip format (default yes)\n"); fprintf(ofp," -[no]alb show aln block format (default no)\n"); fprintf(ofp," -[no]pal show packaln format (default no)\n"); show_standard_options(ofp); } double id(int i) { return (double)i; } void debug_zip(AlnBlock * alb,MappedCloneSet * query,MappedCloneSet * target,FILE * ofp) { AlnColumn * alc; MappedCloneSet * temp; int i; /* descend each block, printing left and right info */ for(alc=alb->start;alc != NULL;alc = alc->next) { fprintf(ofp,"%4d %4d:%4d %12s:%12s -- ",alc->alu[0]->score[0],alc->alu[0]->end,alc->alu[1]->end,alc->alu[0]->text_label,alc->alu[1]->text_label); if( strstr(alc->alu[0]->text_label,"SKIP") != NULL || strstr(alc->alu[0]->text_label,"MATCH") != NULL ) { fprintf(ofp,"["); temp = subsection_MappedCloneSet(query,alc->alu[0]->end,alc->alu[0]->end,0); if( temp->len == 0 ) { fprintf(ofp,"]"); } for(i=0;ilen;i++) { fprintf(ofp,"%s%c",temp->clone[i]->clone_name,i+1 == temp->len ? ']' : ','); } free_MappedCloneSet(temp); } else { fprintf(ofp,"[]"); } if( strstr(alc->alu[1]->text_label,"SKIP") != NULL || strstr(alc->alu[1]->text_label,"MATCH") != NULL ) { fprintf(ofp,"["); temp = subsection_MappedCloneSet(target,alc->alu[1]->end,alc->alu[1]->end,0); if( temp->len == 0 ) { fprintf(ofp,"]"); } for(i=0;ilen;i++) { fprintf(ofp,"%s%c",temp->clone[i]->clone_name,i+1 == temp->len ? ']' : ','); } free_MappedCloneSet(temp); } else { fprintf(ofp,"[]"); } fprintf(ofp,"\n"); } } void extended_path(AlnBlock * alb,MappedCloneSet * query,MappedCloneSet * target,FILE * ofp) { AlnColumn * alc; AlnColumn * runner; int coord; int coord_runner; int startpos; int i; int j; int is_new; MappedCloneSet * temp; MappedCloneSet * seen_query; MappedCloneSet * seen_target; seen_query = MappedCloneSet_alloc_std(); seen_target = MappedCloneSet_alloc_std(); coord = 0; for(alc=alb->start;alc != NULL;alc = alc->next) { /* deal with weak first */ temp = subsection_MappedCloneSet(query,alc->alu[0]->end,alc->alu[0]->end,0); for(i=0;ilen;i++) { is_new = 1; for(j=0;jlen;j++) { if( temp->clone[i] == seen_query->clone[j] ) { is_new = 0; break; } } if( is_new == 0 ) { /* no need to print it out */ continue; } add_MappedCloneSet(seen_query,hard_link_MappedClone(temp->clone[i])); /* time to print it out */ startpos = coord; coord_runner = coord; for(runner = alc;runner != NULL && runner->alu[0]->end <= temp->clone[i]->end;runner=runner->next) coord_runner++; if( runner == NULL ) { continue; } fprintf(ofp,"QUERY\t%d\t%d\t%s\t%s\t%s\t%d\t%d\n",startpos,coord_runner,temp->clone[i]->clone_name,temp->clone[i]->accession,temp->clone[i]->contig,alc->alu[1]->end,runner->alu[1]->end); } free_MappedCloneSet(temp); /* Ooops. copy-and-paste. Bad Ewan! */ temp = subsection_MappedCloneSet(target,alc->alu[1]->end,alc->alu[1]->end,0); for(i=0;ilen;i++) { is_new = 1; for(j=0;jlen;j++) { if( temp->clone[i] == seen_target->clone[j] ) { is_new = 0; break; } } if( is_new == 0 ) { /* no need to print it out */ continue; } add_MappedCloneSet(seen_target,hard_link_MappedClone(temp->clone[i])); /* time to print it out */ startpos = coord; coord_runner = coord; for(runner = alc;runner != NULL && runner->alu[1]->end <= temp->clone[i]->end;runner=runner->next) coord_runner++; /* if the end is not there - skip this one? */ if( runner == NULL ) { continue; } fprintf(ofp,"TARGET\t%d\t%d\t%s\t%s\t%s\t%d\t%d\n",startpos,coord_runner,temp->clone[i]->clone_name,temp->clone[i]->accession,temp->clone[i]->contig,alc->alu[1]->end,runner->alu[1]->end); } free_MappedCloneSet(temp); coord++; } } int main (int argc,char ** argv) { MappedCloneSet * trusted; MappedCloneSet * weak; MappedCloneMatch * match; FILE * in; int kbyte = 10000; PackAln * pal; AlnBlock * alb; int spread = 30; boolean show_alb = 0; boolean show_pal = 0; boolean show_zip = 1; boolean show_path = 0; char * alg_string = "local"; char * temp; char * divide_string = "//"; strip_out_boolean_def_argument(&argc,argv,"alb",&show_alb); strip_out_boolean_def_argument(&argc,argv,"pal",&show_pal); strip_out_boolean_def_argument(&argc,argv,"zip",&show_zip); strip_out_boolean_def_argument(&argc,argv,"path",&show_path); strip_out_integer_argument(&argc,argv,"wgap",&query_gap_start); strip_out_integer_argument(&argc,argv,"wext",&query_gap_extend); strip_out_integer_argument(&argc,argv,"wswitch",&query_switch_cost); strip_out_integer_argument(&argc,argv,"tgap",&target_gap_start); strip_out_integer_argument(&argc,argv,"text",&target_gap_extend); strip_out_integer_argument(&argc,argv,"match",&match_score); strip_out_integer_argument(&argc,argv,"mismatch",&mismatch_score); temp =strip_out_assigned_argument(&argc,argv,"alg"); if( temp != NULL ) { alg_string = temp; } strip_out_integer_argument(&argc,argv,"spread",&spread); strip_out_integer_argument(&argc,argv,"kbyte",&kbyte); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 3 ) { show_help(stdout); exit(12); } in = fopen(argv[1],"r"); if( in == NULL ) { fatal("Unable to open %s",argv[1]); } trusted = read_MappedCloneSet(in); /* fprintf(stderr,"first start %d\n",trusted->clone[0]->start);*/ in = fopen(argv[2],"r"); if( in == NULL ) { fatal("Unable to open %s",argv[2]); } change_max_BaseMatrix_kbytes(kbyte); weak = read_MappedCloneSet(in); synchronise_MappedCloneSets(trusted,weak); /* fprintf(stderr,"score for 2,2 is %d\n",MappedCloneSet_match(weak,trusted,2,2,0,10,-5)); */ match = new_MappedCloneMatch(weak,trusted,match_score,mismatch_score); fprintf(stderr,"Match matrix calculated\n"); if( strcmp(alg_string,"global") == 0 ) { pal = PackAln_bestmemory_CloneWise(weak,trusted,match,-query_gap_start,-query_gap_extend,-target_gap_start,-target_gap_extend,spread,-query_switch_cost,NULL); alb = convert_PackAln_to_AlnBlock_CloneWise(pal); } else if ( strcmp(alg_string,"local") == 0 ) { pal = PackAln_bestmemory_LocalCloneWise(weak,trusted,match,-query_gap_start,-query_gap_extend,-target_gap_start,-target_gap_extend,spread,-query_switch_cost,NULL); alb = convert_PackAln_to_AlnBlock_LocalCloneWise(pal); } else { /* keep gcc happy */ pal = NULL; alb = NULL; fatal("Not a proper algorithm string %s",alg_string); } if( show_path ) { extended_path(alb,weak,trusted,stdout); fprintf(stdout,"%s\n",divide_string); } if( show_zip ) { debug_zip(alb,weak,trusted,stdout); fprintf(stdout,"%s\n",divide_string); } if( show_alb ) { mapped_ascii_AlnBlock(alb,id,1,stdout); fprintf(stdout,"%s\n",divide_string); } if( show_pal ) { show_simple_PackAln(pal,stdout); fprintf(stdout,"%s\n",divide_string); } return 0; } wise-2.4.1/src/models/statwise.c0000644000175000001440000000651207454521132016141 0ustar philippusers#include "statwise10.h" #include "version.h" #include "genestats.h" #include "geneutil.h" char * program_name = "statwise"; char * codon_table = "codon.table"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s sequence-as-fasta\n",program_name); show_help_GeneModelParam(ofp); show_help_DPRunImpl(ofp); show_standard_options(ofp); } CodonTable * ct; double id(int i) { return (double)i; } int main(int argc,char ** argv) { int i; DPRunImpl * dpri = NULL; GeneModelParam * gmp = NULL; GeneModel * gm = NULL; Sequence * seq; RandomCodon * rc; RandomModelDNA * rmd; RandomCodonScore * rcs; ComplexSequenceEval * splice5; ComplexSequenceEval * splice3; ComplexSequenceEvalSet * cses; ComplexSequence * cseq; SyExonScore * exonscore; PackAln * pal; AlnBlock * alb; Genomic * genomic; GenomicRegion * gr; Protein * trans; dpri = new_DPRunImpl_from_argv(&argc,argv); if( dpri == NULL ) { fatal("Unable to build DPRun implementation. Bad arguments"); } gmp = new_GeneModelParam_from_argv(&argc,argv); ct= read_CodonTable_file("codon.table"); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 2 ) { show_help(stdout); exit(12); } if((gm=GeneModel_from_GeneModelParam(gmp)) == NULL ) { fatal("Could not build gene model"); } seq = read_fasta_file_Sequence(argv[1]); assert(seq); cses = new_ComplexSequenceEvalSet_from_GeneModel(gm); cseq = new_ComplexSequence(seq,cses); rc = flat_RandomCodon(ct); rmd = RandomModelDNA_std(); fold_in_RandomModelDNA_into_RandomCodon(rc,rmd); rcs = RandomCodonScore_from_RandomCodon(rc); exonscore = SyExonScore_flat_model(200,250,0.1,0.1); /* for(i=0;ilength;i++) { fprintf(stdout,"%d PairSeq is %d score %d\n",i,CSEQ_PAIR_PAIRBASE(cseq,i),nonc_score->base[CSEQ_PAIR_PAIRBASE(cseq,i)]); } exit(0); */ /* show_RandomCodonScore(rcs,stdout); for(i=3;ilen;i++) { fprintf(stdout,"seq %d is %c with score %d\n",i,aminoacid_from_seq(ct,seq->seq+i-2),rcs->codon[CSEQ_GENOMIC_CODON(cseq,i)]); } exit(0); */ pal = PackAln_bestmemory_StatWise10(exonscore,cseq,rcs,Probability2Score(1.0/10.0),Probability2Score(1.0/10.0),NULL,dpri); alb = convert_PackAln_to_AlnBlock_StatWise10(pal); mapped_ascii_AlnBlock(alb,id,1,stdout); genomic = Genomic_from_Sequence(seq); gr = new_GenomicRegion(genomic); add_Genes_to_GenomicRegion_GeneWise(gr,1,seq->len,alb,"bollocks",0,NULL); for(i=0;ilen;i++) { if( gr->gene[i]->ispseudo == TRUE ) { fprintf(stdout,"#Gene %d is a pseudo gene - no translation possible\n",i); } else { trans = get_Protein_from_Translation(gr->gene[i]->transcript[0]->translation[0],ct); write_fasta_Sequence(trans->baseseq,stdout); } } return 0; } wise-2.4.1/src/models/localcispara.dy0000644000175000001440000000417610011714154017120 0ustar philippusers %{ #include "dyna.h" #define LCH_GAP 0.05 #define LCH_BLOCKOPEN 0.01 #define LCH_UNMATCHED_PEN 0.99 %} struct LocalCisHitProb DnaProbMatrix* comp65 DnaProbMatrix* comp75 DnaProbMatrix* comp85 DnaProbMatrix* comp95 Probability g Probability u Probability v Probability s Probability b struct LocalCisHitScore DnaMatrix* comp65 DnaMatrix* comp75 DnaMatrix* comp85 DnaMatrix* comp95 Score g Score u Score v Score s Score b %{ #include "localcispara.h" LocalCisHitScore * standard_LocalCisHitScore(NMaskType nmask) { LocalCisHitProb *p; LocalCisHitScore * out; p = standard_LocalCisHitProb(nmask); out = LocalCisHitScore_from_LocalCisHitProb(p); free_LocalCisHitProb(p); return out; } LocalCisHitProb * standard_LocalCisHitProb(NMaskType nmask) { LocalCisHitProb * out; out = LocalCisHitProb_alloc(); out->comp65 = DnaProbMatrix_from_match(0.65,nmask); flat_null_DnaProbMatrix(out->comp65); out->comp75 = DnaProbMatrix_from_match(0.75,nmask); flat_null_DnaProbMatrix(out->comp75); out->comp85 = DnaProbMatrix_from_match(0.85,nmask); flat_null_DnaProbMatrix(out->comp85); out->comp95 = DnaProbMatrix_from_match(0.95,nmask); flat_null_DnaProbMatrix(out->comp95); out->g = LCH_GAP / LCH_UNMATCHED_PEN; out->u = 1.0; out->v = (1.0- LCH_UNMATCHED_PEN)/(LCH_UNMATCHED_PEN); out->s = (1.0 - (LCH_GAP + LCH_GAP + LCH_BLOCKOPEN))/(LCH_UNMATCHED_PEN * LCH_UNMATCHED_PEN); out->b = (LCH_BLOCKOPEN/LCH_UNMATCHED_PEN); return out; } LocalCisHitScore * LocalCisHitScore_from_LocalCisHitProb(LocalCisHitProb * lchp) { LocalCisHitScore * lchs; lchs = LocalCisHitScore_alloc(); lchs->comp65 = DnaMatrix_from_DnaProbMatrix(lchp->comp65); lchs->comp75 = DnaMatrix_from_DnaProbMatrix(lchp->comp75); lchs->comp85 = DnaMatrix_from_DnaProbMatrix(lchp->comp85); lchs->comp95 = DnaMatrix_from_DnaProbMatrix(lchp->comp95); lchs->g = Probability2Score(lchp->g); lchs->u = Probability2Score(lchp->u); lchs->v = Probability2Score(lchp->v); lchs->s = Probability2Score(lchp->s); lchs->b = Probability2Score(lchp->b); return lchs; } %} wise-2.4.1/src/models/version.h0000644000175000001440000000016607313404550015765 0ustar philippusers #define VERSION_NUMBER "$Name: wise2-4-1 $" #define RELEASE_DAY "unreleased" #define COMPILE_DATE __DATE__ wise-2.4.1/src/models/cdparser.typemap0000644000175000001440000000036610670453713017342 0ustar philippusers TYPEMAP Wise2_cDNAParser * T_Wise2_cDNAParser INPUT T_Wise2_cDNAParser $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_cDNAParser *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_cDNAParser sv_setref_pv($arg, "Wise2::cDNAParser", (void*) $var); wise-2.4.1/src/models/oldpostwise.c0000644000175000001440000003675307313404547016670 0ustar philippusers#include "dyna.h" #include "version.h" #include "genedisplay.h" char * program_name = "postwise"; /* * program specific includes */ #include "gwrap.h" /* * program specific variables */ char * pgl_file = NULL; PotentialGeneList * pgl = NULL; char * exblx_file = NULL; DnaSequenceHitList * dsl= NULL; boolean use_msp_crunch = TRUE; char * fetch_string = "efetch swir:%s"; char * dna_file = NULL; Genomic * gen = NULL; GenomicRegion * gr = NULL; char * gene_file = NULL; GeneFrequency21 * gf = NULL; char * matrix_file = NULL; CompMat * mat = NULL; char * gap_str = "12"; int gap = 12; char * ext_str = "2"; int ext = 2; char * codon_file = NULL; CodonTable * ct = NULL; char * output_file = "-"; FILE * ofp = NULL; char * window_str = "500"; int window = 500; char * wing_str = "4000"; int wing = 4000; char * min_score_str = "100.0"; double min_score = 100.0; char * cut_off_str = "0.0"; double cut_off = 0.0; char * palg_str = "623"; int palg = GWWRAP_623; RandomModelDNA * rmd = NULL; boolean show_alignments = FALSE; boolean show_translation = FALSE; boolean show_cdna = FALSE; boolean show_ace = FALSE; boolean show_gff = FALSE; boolean show_gene_str = FALSE; boolean show_pretty_gene = FALSE; boolean show_raw_gene = FALSE; char * divide_str = "//"; Probability rnd_loop = 0.999; Probability cds_loop = 0.99; Probability rnd_to_model = (1 - 0.999) / 3; Probability link_loop = 0.98; Probability link_to_model = (1- 0.98) / 3; Probability subs_error = 0.00001; Probability indel_error = 0.00001; boolean model_codon = FALSE; boolean model_splice = TRUE; boolean tie_intron = TRUE; char * kbyte_str = NULL; int kbyte = 10000; /* will be reset in build_defaults */ char * make_ace_gene_name(Genomic * gen,char * protein_name,int number_in_gene,Gene * gene) { char buffer[128]; char * alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; int firstno,secondno; firstno = (int)floor(number_in_gene/26); number_in_gene -= firstno*26; sprintf(buffer,"%s.gw.%s.%c%c",gen->baseseq->name,protein_name,alpha[firstno],alpha[number_in_gene] ); return stringalloc(buffer); } boolean show_output(void) { int i; Protein * p; cDNA * c; Genomic * gentemp; Genomic * g; if( show_alignments == TRUE ) { for(i=0;ilen;i++) { if( pgl->pg[i]->homolog == NULL || pgl->pg[i]->alb == NULL ) { fprintf(ofp,"// Sorry - no prediction made, probably due to an error\n"); continue; } if( pgl->pg[i]->bitscore < cut_off ) { fprintf(ofp,"// Bits score %f below cut off %f\n", pgl->pg[i]->bitscore,cut_off); continue; } gentemp = truncate_Genomic(gr->genomic,pgl->pg[i]->guess_start,pgl->pg[i]->guess_end); if( gentemp == NULL ) { warn("Could not make truncation in output display. Bad...."); continue; } protgene_ascii_display(pgl->pg[i]->alb,pgl->pg[i]->homolog->baseseq->seq,pgl->pg[i]->homolog->baseseq->name,pgl->pg[i]->homolog->baseseq->offset,gentemp,ct,15,60,TRUE,ofp); free_Genomic(gentemp); } fprintf(ofp,"%s\n",divide_str); } if( show_ace == TRUE ) { show_ace_GenomicRegion(gr,gen->baseseq->name,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_gff == TRUE ) { show_GFF_GenomicRegion(gr,gen->baseseq->name,"GeneWise",ofp); fprintf(ofp,"%s\n",divide_str); } if( show_translation == TRUE ) { for(i=0;ilen;i++) { p = get_Protein_from_Translation(gr->gene[i]->transcript[0]->translation[0],ct); write_fasta_Sequence(p->baseseq,ofp); } fprintf(ofp,"%s\n",divide_str); } if( show_cdna == TRUE ) { for(i=0;ilen;i++) { c = get_cDNA_from_Transcript(gr->gene[i]->transcript[0]); write_fasta_Sequence(c->baseseq,ofp); } fprintf(ofp,"%s\n",divide_str); } if( show_pretty_gene == TRUE ) { show_pretty_GenomicRegion(gr,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_raw_gene == TRUE ) { show_GenomicRegion(gr,ofp); fprintf(ofp,"%s\n",divide_str); } } boolean build_gene_prediction(void) { int count; GeneParameter21 * gp; /* gp = GeneParameter21_wrap(gf,0.00001,0.00001,rmd,TRUE,TRUE,ct,0.1,0.1,0.1,0.1); */ change_max_BaseMatrix_kbytes(kbyte); log_full_error(INFO,0,"I have %d Potential Genes to resolve",pgl->len); gp = GeneParameter21_wrap(gf,subs_error,indel_error,rmd,model_codon,model_splice,tie_intron,ct,rnd_loop,cds_loop,rnd_to_model,link_loop,link_to_model); count = resolve_PotentialGenes_on_GenomicRegion(gr,pgl,palg,GWWRAP_623L,10,10,mat,-gap,-ext,gp,rmd,rmd,fetch_string,show_alignments == TRUE ? FALSE : TRUE,make_ace_gene_name,cut_off); free_GeneParameter21(gp); return TRUE; } boolean build_objects(void) { boolean ret = TRUE; FILE * ifp; if( is_integer_string(wing_str,&wing) == FALSE ) { warn("Wing amount [%s] is not an integer\n",wing_str); ret = FALSE; } if( is_integer_string(window_str,&window) == FALSE ) { warn("Window level [%s] is not an integer\n",window_str); ret = FALSE; } if( is_double_string(min_score_str,&min_score) == FALSE ) { warn("Minimum score [%s] is not a number\n",min_score_str); ret = FALSE; } if( is_double_string(cut_off_str,&cut_off) == FALSE ) { warn("Cut off string [%s] is not a number\n",cut_off_str); ret = FALSE; } if( use_msp_crunch == TRUE ) { ifp = openfile(exblx_file,"r"); if( ifp == NULL ) { warn("Could not open %s as a exblx file",exblx_file); ret = FALSE; } else { dsl = read_MSPcrunch_DnaSequenceHitList(ifp); if( dsl == NULL ) { warn("Could not read MSP crunch data in %s",exblx_file); ret = FALSE; } else { /*fprintf(stderr,"Passing in %d and %d\n",window,wing); */ /*show_DnaSequenceHitList(dsl,stdout);*/ pgl = PotentialGeneList_from_DnaSequenceHitList(dsl,window,wing,min_score); if( pgl == NULL ) { warn("Could not convert MSP crunch data in a potential gene list"); ret = FALSE; } /*show_PotentialGeneList(pgl,stdout);*/ } } } else { if( (pgl = read_PotentialGeneList_pgfasta_file(pgl_file)) == NULL ) { warn("Could not read Potential Genes in %s",pgl_file); ret = FALSE; } } if( pgl->len == 0 ) { warn("You have 0 Potential Genes. Considering this a bad thing!"); ret = FALSE; } if( (gen = read_fasta_file_Genomic(dna_file)) == NULL) { ret = FALSE; warn("Could not read dna sequence file in %s",gf); } else { gr = new_GenomicRegion(gen); } if( (gf = read_GeneFrequency21_file(gene_file)) == NULL) { ret = FALSE; warn("Could not read a GeneFrequency file in %s",gene_file); } if( kbyte_str != NULL ) { if( is_integer_string(kbyte_str,&kbyte) == FALSE ) { warn("Could not get maximum kbyte number %s",kbyte_str); ret = FALSE; } } if( (palg = gwrap_alg_type_from_string(palg_str)) == -1 ) { warn("Cannot use %s as a valid algorithm type",palg_str); ret = FALSE; } if( (mat = read_Blast_file_CompMat(matrix_file)) == NULL) { ret = FALSE; warn("Could not read Comparison matrix file in %s",matrix_file); } if( (ct = read_CodonTable_file(codon_file)) == NULL) { ret = FALSE; warn("Could not read codon table file in %s",codon_file); } if( is_integer_string(gap_str,&gap) == FALSE ) { warn("Gap [%s] is not an integer\n",gap_str); ret = FALSE; } if( is_integer_string(ext_str,&ext) == FALSE ) { warn("Gap [%s] is not an integer\n",ext_str); ret = FALSE; } if( (ofp = openfile(output_file,"W")) == NULL) { warn("Could not open %s as an output file",output_file); ret = FALSE; } rmd = RandomModelDNA_std(); return ret; } void build_defaults(void) { gene_file = "human.gf"; matrix_file = "blosum62.bla"; codon_file = "codon.table"; output_file = "-"; kbyte = get_max_BaseMatrix_kbytes(); } void show_short_help(void) { fprintf(stdout,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(stdout,"This program is freely distributed under a GPL. See -version for more info\n"); fprintf(stdout,"Copyright (c) GRL limited: portions of the code are from separate copyright\n\n"); fprintf(stdout,"postwise '-' means stdin\n"); fprintf(stdout," Options. In any order.\n"); fprintf(stdout," Region selection [-window,-wing,-fetch,-min,-cut]\n"); fprintf(stdout," Protein [-gap,-ext,-matrix]\n"); fprintf(stdout," Model [-codon,-gene]\n"); fprintf(stdout," Alg [-palg,-kbyte]\n"); fprintf(stdout," Output [-pretty,-ace,-gff,-genes,-trans,-divide,-cdna]\n"); fprintf(stdout," Standard [-help,-version,-silent,-quiet,-errorlog]\n"); fprintf(stdout,"\nFor more help go %s -help.\n",program_name); fprintf(stdout,"\nSee WWW help at http://www.sanger.ac.uk/Software/Wise2/postwise.shtml\n"); exit(63); } void show_help(char * help_arg) { fprintf(stdout,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(stdout,"postwise \nOutput on stdout\n"); /* program specific help */ fprintf(stdout," -gap [%3d] gap penalty\n",gap); fprintf(stdout," -ext [%3d] extension penalty\n",gap); fprintf(stdout," -matrix [%s] Comparison matrix\n",matrix_file); fprintf(stdout," -codon [%s] Codon file\n",codon_file); fprintf(stdout," -gene [%s] Gene parameter file\n",gene_file); fprintf(stdout," -fasta Input file is fasta 'munged' format for proteins\n"); fprintf(stdout,"Options for converting msp crunch output\n"); fprintf(stdout," -fetch [%s] Pipe to open to fetch protein sequences\n",fetch_string); fprintf(stdout," -window [%s] Window size of dna to consider\n",window_str); fprintf(stdout," -wing [%s] Size of 'wing' sequences on each end\n",wing_str); fprintf(stdout," -min [%s] Minimum blast score to trigger genewise\n",min_score_str); fprintf(stdout," -cut [%s] Minimum genewise score to predict on\n",cut_off_str); fprintf(stdout,"Output options\n"); fprintf(stdout," -pretty show pretty alignment format\n"); fprintf(stdout," -ace show ace subsequence model\n"); fprintf(stdout," -gff Gene feature format output\n"); fprintf(stdout," -gener show raw gene structure output\n"); fprintf(stdout," -trans show translation\n"); fprintf(stdout," -cDNA show cDNA\n"); fprintf(stdout," -divide [%s] divide string for outputs\n",divide_str); fprintf(stdout,"Algorithm options\n"); fprintf(stdout," -palg [%s] Algorithm for protein alignments\n",palg_str); fprintf(stdout," -kbyte [%5d] Max number of kilobytes used in main calculation\n",kbyte); fprintf(stdout,"Standard options\n"); fprintf(stdout," -help help\n -version show version and compile info\n -silent No messages on stderr\n -quiet No report on stderr\n -erroroffstd No warning messages to stderr\n -errorlog [file] Log warning messages to file\n"); fprintf(stdout,"\nSee WWW help at http://www.sanger.ac.uk/Software/Wise2/postwise.shtml\n"); exit(63); } void show_version(void) { fprintf(stdout,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(stdout,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(stdout,"The source code is copyright (c) GRL 1998 and others\n"); fprintf(stdout,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(stdout,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(stdout,"Credits: Ewan Birney wrote the core code.\n"); fprintf(stdout," Portions of this code is from HMMer1, written by Sean Eddy\n"); exit(63); } int main(int argc,char ** argv) { int i; char * help; char * errlog; FILE * efp; char * temp; build_defaults(); if( strip_out_boolean_argument(&argc,argv,"help") == TRUE ) { show_help(NULL); } if( (strip_out_boolean_argument(&argc,argv,"version")) == TRUE ) { show_version(); } if( (strip_out_boolean_argument(&argc,argv,"silent")) == TRUE ) { erroroff(REPORT); erroroff(INFO); erroroff(WARNING); } if( (strip_out_boolean_argument(&argc,argv,"quiet")) == TRUE ) { erroroff(REPORT); erroroff(INFO); } if( (strip_out_boolean_argument(&argc,argv,"erroroffstd")) == TRUE ) { errorstderroff(WARNING); } if( (errlog=strip_out_assigned_argument(&argc,argv,"errlog")) != NULL ) { if( add_log_filename(errlog) == FALSE ) { fatal("Could not use %s as a error log file\n",errlog); } else { warn("Logging errors to %s as well as stderr",errlog); errorlogon(WARNING); } } if( (temp = strip_out_assigned_argument(&argc,argv,"gap")) != NULL ) gap_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"ext")) != NULL ) ext_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"matrix")) != NULL ) matrix_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"codon")) != NULL ) codon_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"gene")) != NULL ) gene_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"fetch")) != NULL ) fetch_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"window")) != NULL ) window_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"wing")) != NULL ) wing_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"min")) != NULL ) min_score_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"cut")) != NULL ) cut_off_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"palg")) != NULL ) palg_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"divide")) != NULL ) divide_str = temp; if( strip_out_boolean_argument(&argc,argv,"ace") == TRUE ) show_ace = TRUE; if( strip_out_boolean_argument(&argc,argv,"pretty") == TRUE ) show_alignments = TRUE; if( strip_out_boolean_argument(&argc,argv,"gener") == TRUE ) show_raw_gene = TRUE; if( strip_out_boolean_argument(&argc,argv,"gff") == TRUE ) show_gff = TRUE; if( strip_out_boolean_argument(&argc,argv,"trans") == TRUE ) show_translation = TRUE; if( strip_out_boolean_argument(&argc,argv,"cdna") == TRUE ) show_cdna = TRUE; if( strip_out_boolean_argument(&argc,argv,"genes") == TRUE ) show_pretty_gene = TRUE; if( strip_out_boolean_argument(&argc,argv,"fasta") == TRUE ) use_msp_crunch = FALSE; if( (temp = strip_out_assigned_argument(&argc,argv,"kbyte")) != NULL ) kbyte_str = temp; if( show_gff == FALSE && show_ace == FALSE && show_translation == FALSE && show_pretty_gene == FALSE ) { show_alignments = TRUE; show_translation = TRUE; show_pretty_gene = TRUE; } strip_out_remaining_options_with_warning(&argc,argv); if( argc != 3 ) { warn("Wrong number of arguments (expect 2)! Arg line looked like (after option processing)"); for(i=1;iforward = SegmentHitList_alloc_std(); out->backward = SegmentHitList_alloc_std(); return out; } %func shows a DnaSequenceHitsList - only really useful for debugging %% void show_DnaSequenceHitList(DnaSequenceHitList * dsl,FILE * ofp) { show_SegmentHitList(dsl->forward,ofp); show_SegmentHitList(dsl->backward,ofp); } void show_SegmentHitList(SegmentHitList * shl,FILE * ofp) { int i; for(i=0;ilen;i++) show_SegmentHit(shl->seghit[i],ofp); } void show_SegmentHit(SegmentHit * sh,FILE * ofp) { fprintf(ofp,"%4d %4d %4d %4d %4.2f %s\n",sh->qstart,sh->qend,sh->tstart,sh->tend,sh->score,sh->name); } void sort_SegmentHitList_by_qstart(SegmentHitList * sgl) { sort_SegmentHitList(sgl,compare_SegmentHit_by_qstart); } int compare_SegmentHit_by_qstart(SegmentHit * one,SegmentHit * two) { return one->qstart - two->qstart; } DnaSequenceHitList * read_msptmp_DnaSequenceHitList(FILE * ifp) { DnaSequenceHitList * out; SegmentHit * sh; char buffer[MAXLINE]; char copy[MAXLINE]; int strand; out = new_DnaSequenceHitList(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { strcpy(copy,buffer); if( (sh = SegmentHit_from_msptmp_line(buffer,&strand)) == NULL ) { warn("Cannot parse [%s] as a MSP crunch line",copy); continue; } if( strand < 0 ) { add_SegmentHitList(out->backward,sh); } else { add_SegmentHitList(out->forward,sh); } } sort_SegmentHitList_by_qstart(out->forward); sort_SegmentHitList_by_qstart(out->backward); return out; } boolean verify_SegmentHit(SegmentHit * sh) { boolean ret = TRUE; if ( sh->qstart <= 0 ) { ret = FALSE; warn("Got a less than zero index in query start %d",sh->qstart); } if ( sh->qend <= 0 ) { ret = FALSE; warn("Got a less than zero index in query end %d",sh->qend); } if ( sh->tstart <= 0 ) { ret = FALSE; warn("Got a less than zero index in target start %d",sh->tstart); } if ( sh->tend <= 0 ) { ret = FALSE; warn("Got a less than zero index in target end %d",sh->tend); } return ret; } %func Reads a MSPcrunch -x output file %arg ifp input file to read return newly allocated structure %% DnaSequenceHitList * read_MSPcrunch_DnaSequenceHitList(FILE * ifp) { DnaSequenceHitList * out; SegmentHit * sh; char buffer[MAXLINE]; char copy[MAXLINE]; int strand; out = new_DnaSequenceHitList(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { strcpy(copy,buffer); if( (sh = SegmentHit_from_MSPcrunch_line(buffer,&strand)) == NULL ) { warn("Cannot parse [%s] as a MSP crunch line",copy); continue; } if( verify_SegmentHit(sh) == FALSE ) { warn("Segment hit read in from [%s] was considered bad. Discarding",copy); sh = free_SegmentHit(sh); continue; } if( strand < 0 ) { add_SegmentHitList(out->backward,sh); } else { add_SegmentHitList(out->forward,sh); } } sort_SegmentHitList_by_qstart(out->forward); sort_SegmentHitList_by_qstart(out->backward); /* fprintf(stderr,"We have %d forward and %d backward guys\n",out->forward->len,out->backward->len); */ return out; } SegmentHit * SegmentHit_from_msptmp_line(char * line,int * strand) { SegmentHit * out; char * runner; out = SegmentHit_alloc(); runner = strtok(line,spacestr); if( runner == NULL || is_double_string(runner,&out->score) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL ) goto error; if( *runner != '(' || runner[strlen(runner)-1] != ')' ) goto error; runner[strlen(runner)-1] = '\0'; runner++; if( is_integer_string(runner,strand) == FALSE) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->qstart) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->qend) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->tstart) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->tend) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL ) goto error; out->name = stringalloc(runner); return out; error : free_SegmentHit(out); return NULL; } SegmentHit * SegmentHit_from_MSPcrunch_line(char * line,int * strand) { SegmentHit * out; char * runner; out = SegmentHit_alloc(); runner = strtok(line,spacestr); if( runner == NULL || is_double_string(runner,&out->score) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL ) goto error; if( *runner != '(' || runner[strlen(runner)-1] != ')' ) goto error; runner[strlen(runner)-1] = '\0'; runner++; if( is_integer_string(runner,strand) == FALSE) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->qstart) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->qend) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->tstart) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL || is_integer_string(runner,&out->tend) == FALSE ) goto error; if( (runner=strtok(NULL,spacestr)) == NULL ) goto error; out->name = stringalloc(runner); return out; error : free_SegmentHit(out); return NULL; } %} wise-2.4.1/src/models/seqhit.xs0000644000175000001440000001367010670453715016013 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::DnaSequenceHitList void show_DnaSequenceHitList(dsl,ofp) Wise2_DnaSequenceHitList * dsl FILE * ofp CODE: Wise2_show_DnaSequenceHitList(dsl,ofp); Wise2_DnaSequenceHitList * read_MSPcrunch_DnaSequenceHitList(ifp) FILE * ifp CODE: RETVAL = Wise2_read_MSPcrunch_DnaSequenceHitList(ifp); OUTPUT: RETVAL Wise2_DnaSequenceHitList * hard_link_DnaSequenceHitList(obj) Wise2_DnaSequenceHitList * obj CODE: RETVAL = Wise2_hard_link_DnaSequenceHitList(obj); OUTPUT: RETVAL Wise2_DnaSequenceHitList * alloc() CODE: RETVAL = Wise2_DnaSequenceHitList_alloc(); OUTPUT: RETVAL boolean set_forward(obj,forward) Wise2_DnaSequenceHitList * obj Wise2_SegmentHitList * forward CODE: RETVAL = Wise2_replace_forward_DnaSequenceHitList(obj,Wise2_hard_link_SegmentHitList(forward)); OUTPUT: RETVAL Wise2_SegmentHitList * forward(obj) Wise2_DnaSequenceHitList * obj INIT: Wise2_SegmentHitList * temp; CODE: temp = Wise2_hard_link_SegmentHitList(Wise2_access_forward_DnaSequenceHitList(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_backward(obj,backward) Wise2_DnaSequenceHitList * obj Wise2_SegmentHitList * backward CODE: RETVAL = Wise2_replace_backward_DnaSequenceHitList(obj,Wise2_hard_link_SegmentHitList(backward)); OUTPUT: RETVAL Wise2_SegmentHitList * backward(obj) Wise2_DnaSequenceHitList * obj INIT: Wise2_SegmentHitList * temp; CODE: temp = Wise2_hard_link_SegmentHitList(Wise2_access_backward_DnaSequenceHitList(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_DnaSequenceHitList * new(class) char * class PPCODE: Wise2_DnaSequenceHitList * out; out = Wise2_DnaSequenceHitList_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_DnaSequenceHitList * obj CODE: Wise2_free_DnaSequenceHitList(obj); MODULE = Wise2 PACKAGE = Wise2::SegmentHitList Wise2_SegmentHitList * hard_link_SegmentHitList(obj) Wise2_SegmentHitList * obj CODE: RETVAL = Wise2_hard_link_SegmentHitList(obj); OUTPUT: RETVAL Wise2_SegmentHitList * SegmentHitList_alloc_std() CODE: RETVAL = Wise2_SegmentHitList_alloc_std(); OUTPUT: RETVAL Wise2_SegmentHit * seghit(obj,i) Wise2_SegmentHitList * obj int i INIT: Wise2_SegmentHit * temp; CODE: temp = Wise2_hard_link_SegmentHit(Wise2_access_seghit_SegmentHitList(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_seghit(obj) Wise2_SegmentHitList * obj CODE: RETVAL = Wise2_length_seghit_SegmentHitList(obj); OUTPUT: RETVAL int flush_seghit(obj) Wise2_SegmentHitList * obj CODE: RETVAL = Wise2_flush_SegmentHitList(obj); OUTPUT: RETVAL boolean add_seghit(obj,add) Wise2_SegmentHitList * obj Wise2_SegmentHit * add CODE: RETVAL = Wise2_add_SegmentHitList(obj,Wise2_hard_link_SegmentHit(add)); OUTPUT: RETVAL Wise2_SegmentHitList * new(class) char * class PPCODE: Wise2_SegmentHitList * out; out = Wise2_SegmentHitList_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_SegmentHitList * obj CODE: Wise2_free_SegmentHitList(obj); void each_seghit(obj) Wise2_SegmentHitList * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_seghit_SegmentHitList(obj); for(i=0;ibasematrix->matrix[((j+1)*7)+STATE][i+1] #define BigDnaMatchBlock_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define BigDnaMatchBlock_READ_OFF_ERROR -3 #define BigDnaMatchBlock_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*7)+STATE] #define BigDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define BigDnaMatchBlock_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define BigDnaMatchBlock_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_BigDnaMatchBlock(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_BigDnaMatchBlock(BigDnaMatchBlock * mat) { BigDnaMatchBlock_access_func_holder holder; holder.access_main = BigDnaMatchBlock_shatter_access_main; holder.access_special = BigDnaMatchBlock_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_BigDnaMatchBlock(mat,holder); } /* Function: BigDnaMatchBlock_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int BigDnaMatchBlock_shatter_access_main(BigDnaMatchBlock * mat,int i,int j,int state) { return BigDnaMatchBlock_SHATTER_MATRIX(mat,i,j,state); } /* Function: BigDnaMatchBlock_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int BigDnaMatchBlock_shatter_access_special(BigDnaMatchBlock * mat,int i,int j,int state) { return BigDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_BigDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the BigDnaMatchBlock matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [BigDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_BigDnaMatchBlock(BigDnaMatchBlock * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,7,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("BigDnaMatchBlock Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH55 */ /* setting first movement to score */ score = SIG_1_1[MATCH55] + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH55 to state MATCH55 */ temp = SIG_0_1[MATCH55] + mat->g55; if( temp > score ) { score = temp; } /* From state MATCH55 to state MATCH55 */ temp = SIG_1_0[MATCH55] + mat->g55; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH55 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH55 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH55] = score; /* Finished calculating state MATCH55 */ /* For state MATCH65 */ /* setting first movement to score */ score = SIG_1_1[MATCH65] + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = SIG_0_1[MATCH65] + mat->g65; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = SIG_1_0[MATCH65] + mat->g65; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH65] = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = SIG_1_1[MATCH75] + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH75 to state MATCH75 */ temp = SIG_0_1[MATCH75] + mat->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = SIG_1_0[MATCH75] + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH75] = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = SIG_1_1[MATCH85] + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH85 to state MATCH85 */ temp = SIG_0_1[MATCH85] + mat->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = SIG_1_0[MATCH85] + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH85] = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = SIG_1_1[MATCH95] + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH95 to state MATCH95 */ temp = SIG_0_1[MATCH95] + mat->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = SIG_1_0[MATCH95] + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH95] = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = SIG_1_0[MATCH55] + mat->b; /* From state MATCH65 to state UNMATCHED_QUERY */ temp = SIG_1_0[MATCH65] + mat->b; if( temp > score ) { score = temp; } /* From state MATCH75 to state UNMATCHED_QUERY */ temp = SIG_1_0[MATCH75] + mat->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = SIG_1_0[MATCH85] + mat->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = SIG_1_0[MATCH95] + mat->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = SIG_1_0[UNMATCHED_QUERY] + mat->u; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_SHATTER_SPECIAL(mat,i-1,j-0,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ SIG_0_0[UNMATCHED_QUERY] = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = SIG_0_1[UNMATCHED_QUERY] + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = SIG_0_1[UNMATCHED_TARGET] + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ SIG_0_0[UNMATCHED_TARGET] = score; /* state UNMATCHED_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > BigDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) ) { BigDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state UNMATCHED_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_BigDnaMatchBlock(dbsi,out,query,target,comp55,comp65,comp75,comp85,comp95,g,g65,g55,u,v,s,b) * * Descrip: This function makes a database search of BigDnaMatchBlock * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp55 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp65 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp75 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp85 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp95 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: g [UNKN ] Undocumented argument [Score] * Arg: g65 [UNKN ] Undocumented argument [Score] * Arg: g55 [UNKN ] Undocumented argument [Score] * Arg: u [UNKN ] Undocumented argument [Score] * Arg: v [UNKN ] Undocumented argument [Score] * Arg: s [UNKN ] Undocumented argument [Score] * Arg: b [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_BigDnaMatchBlock(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b) { if( out == NULL ) { warn("Passed in a null Hscore object into search_BigDnaMatchBlock. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_BigDnaMatchBlock. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for BigDnaMatchBlock, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_BigDnaMatchBlock(out,query,target ,comp55,comp65,comp75,comp85,comp95,g,g65,g55,u,v,s,b); case DBSearchImpl_Pthreads : warn("This matrix BigDnaMatchBlock was not dyc compiled with thread support"); return SEARCH_ERROR; default : warn("database search implementation %s was not provided in the compiled dynamite file from BigDnaMatchBlock",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: serial_search_BigDnaMatchBlock(out,query,target,comp55,comp65,comp75,comp85,comp95,g,g65,g55,u,v,s,b) * * Descrip: This function makes a database search of BigDnaMatchBlock * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp55 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp65 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp75 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp85 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp95 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: g [UNKN ] Undocumented argument [Score] * Arg: g65 [UNKN ] Undocumented argument [Score] * Arg: g55 [UNKN ] Undocumented argument [Score] * Arg: u [UNKN ] Undocumented argument [Score] * Arg: v [UNKN ] Undocumented argument [Score] * Arg: s [UNKN ] Undocumented argument [Score] * Arg: b [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_BigDnaMatchBlock(Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_BigDnaMatchBlock(query, target , comp55, comp65, comp75, comp85, comp95, g, g65, g55, u, v, s, b); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("BigDnaMatchBlock search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_BigDnaMatchBlock(query,target,comp55,comp65,comp75,comp85,comp95,g,g65,g55,u,v,s,b) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_BigDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp55 [UNKN ] Resource [DnaMatrix*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: g65 [UNKN ] Resource [Score] * Arg: g55 [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_BigDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b) { int bestscore = NEGI; int i; int j; int k; BigDnaMatchBlock * mat; mat = allocate_BigDnaMatchBlock_only(query, target , comp55, comp65, comp75, comp85, comp95, g, g65, g55, u, v, s, b); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 7,2,2)) == NULL) { warn("Score only matrix for BigDnaMatchBlock cannot be allocated, (asking for 1 by %d cells)",mat->leni*7); mat = free_BigDnaMatchBlock(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<7;k++) BigDnaMatchBlock_VSMALL_MATRIX(mat,i,j,k) = NEGI; } BigDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,START) = 0; BigDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH55 */ /* setting first movement to score */ score = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH55) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH55) + mat->g55; if( temp > score ) { score = temp; } /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH55) + mat->g55; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH55 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH55 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH55) = score; /* Finished calculating state MATCH55 */ /* For state MATCH65 */ /* setting first movement to score */ score = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH65) + mat->g65; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH65) + mat->g65; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH75) = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH85) = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH95) = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH55) + mat->b; /* From state MATCH65 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH75 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_VSMALL_SPECIAL(mat,i-1,j-0,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ BigDnaMatchBlock_VSMALL_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = BigDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ BigDnaMatchBlock_VSMALL_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* state UNMATCHED_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > BigDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) ) { BigDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state UNMATCHED_TARGET */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < BigDnaMatchBlock_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = BigDnaMatchBlock_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_BigDnaMatchBlock(mat); return bestscore; } /* Function: PackAln_bestmemory_BigDnaMatchBlock(query,target,comp55,comp65,comp75,comp85,comp95,g,g65,g55,u,v,s,b,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_BigDnaMatchBlock * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp55 [UNKN ] Resource [DnaMatrix*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: g65 [UNKN ] Resource [Score] * Arg: g55 [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_BigDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; BigDnaMatchBlock * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->seq->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 7 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_BigDnaMatchBlock(query, target , comp55, comp65, comp75, comp85, comp95, g, g65, g55, u, v, s, b,dpri)) == NULL ) { warn("Unable to allocate large BigDnaMatchBlock version"); return NULL; } calculate_dpenv_BigDnaMatchBlock(mat,dpenv); out = PackAln_read_Expl_BigDnaMatchBlock(mat); } else { mat = allocate_BigDnaMatchBlock_only(query, target , comp55, comp65, comp75, comp85, comp95, g, g65, g55, u, v, s, b); calculate_shatter_BigDnaMatchBlock(mat,dpenv); out = PackAln_read_Shatter_BigDnaMatchBlock(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_BigDnaMatchBlock(query, target , comp55, comp65, comp75, comp85, comp95, g, g65, g55, u, v, s, b)) == NULL ) { warn("Unable to allocate small BigDnaMatchBlock version"); return NULL; } out = PackAln_calculate_Small_BigDnaMatchBlock(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_BigDnaMatchBlock(query, target , comp55, comp65, comp75, comp85, comp95, g, g65, g55, u, v, s, b,dpri)) == NULL ) { warn("Unable to allocate large BigDnaMatchBlock version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_BigDnaMatchBlock(mat); out = PackAln_read_Expl_BigDnaMatchBlock(mat); } } } mat = free_BigDnaMatchBlock(mat); return out; } /* Function: allocate_BigDnaMatchBlock_only(query,target,comp55,comp65,comp75,comp85,comp95,g,g65,g55,u,v,s,b) * * Descrip: This function only allocates the BigDnaMatchBlock structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp55 [UNKN ] Resource [DnaMatrix*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: g65 [UNKN ] Resource [Score] * Arg: g55 [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [BigDnaMatchBlock *] * */ BigDnaMatchBlock * allocate_BigDnaMatchBlock_only(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b) { BigDnaMatchBlock * out; if((out= BigDnaMatchBlock_alloc()) == NULL) { warn("Allocation of basic BigDnaMatchBlock structure failed..."); return NULL; } out->query = query; out->target = target; out->comp55 = comp55; out->comp65 = comp65; out->comp75 = comp75; out->comp85 = comp85; out->comp95 = comp95; out->g = g; out->g65 = g65; out->g55 = g55; out->u = u; out->v = v; out->s = s; out->b = b; out->leni = query->seq->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_BigDnaMatchBlock(query,target,comp55,comp65,comp75,comp85,comp95,g,g65,g55,u,v,s,b,dpri) * * Descrip: This function allocates the BigDnaMatchBlock structure * and the basematrix area for explicit memory implementations * It calls /allocate_BigDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp55 [UNKN ] Resource [DnaMatrix*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: g65 [UNKN ] Resource [Score] * Arg: g55 [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [BigDnaMatchBlock *] * */ BigDnaMatchBlock * allocate_Expl_BigDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b,DPRunImpl * dpri) { BigDnaMatchBlock * out; out = allocate_BigDnaMatchBlock_only(query, target , comp55, comp65, comp75, comp85, comp95, g, g65, g55, u, v, s, b); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*7 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*7,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix BigDnaMatchBlock cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_BigDnaMatchBlock(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_BigDnaMatchBlock(out); return out; } /* Function: init_BigDnaMatchBlock(mat) * * Descrip: This function initates BigDnaMatchBlock matrix when in explicit mode * Called in /allocate_Expl_BigDnaMatchBlock * * * Arg: mat [UNKN ] BigDnaMatchBlock which contains explicit basematrix memory [BigDnaMatchBlock *] * */ void init_BigDnaMatchBlock(BigDnaMatchBlock * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->seq->len;i++) { for(j= (-1);j<2;j++) { BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH55) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } } for(j= (-1);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH55) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } BigDnaMatchBlock_EXPL_SPECIAL(mat,i,j,START) = 0; BigDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_BigDnaMatchBlock(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by BigDnaMatchBlock * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * */ void recalculate_PackAln_BigDnaMatchBlock(PackAln * pal,BigDnaMatchBlock * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH55 : if( offi == 1 && offj == 1 && prev->state == MATCH55 ) { pau->score = (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH55 ) { pau->score = mat->g55 + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH55 ) { pau->score = mat->g55 + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH55, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case MATCH65 : if( offi == 1 && offj == 1 && prev->state == MATCH65 ) { pau->score = (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH65 ) { pau->score = mat->g65 + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH65 ) { pau->score = mat->g65 + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH65, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case MATCH75 : if( offi == 1 && offj == 1 && prev->state == MATCH75 ) { pau->score = (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH75 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH75 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH75, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case MATCH85 : if( offi == 1 && offj == 1 && prev->state == MATCH85 ) { pau->score = (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH85 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH85 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH85, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case MATCH95 : if( offi == 1 && offj == 1 && prev->state == MATCH95 ) { pau->score = (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH95 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH95 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH95, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UNMATCHED_QUERY : if( offi == 1 && offj == 0 && prev->state == MATCH55 ) { pau->score = mat->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH65 ) { pau->score = mat->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH75 ) { pau->score = mat->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH85 ) { pau->score = mat->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH95 ) { pau->score = mat->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == UNMATCHED_QUERY ) { pau->score = mat->u + (0); continue; } if( offj == 0 && prev->state == (START+7) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state UNMATCHED_QUERY, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UNMATCHED_TARGET : if( offi == 0 && offj == 1 && prev->state == UNMATCHED_QUERY ) { pau->score = mat->v + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = mat->u + (0); continue; } warn("In recaluclating PackAln with state UNMATCHED_TARGET, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+7) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+7) : if( offj == 0 && prev->state == UNMATCHED_TARGET ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define BigDnaMatchBlock_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*7+state]) #define BigDnaMatchBlock_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*7+state]) #define BigDnaMatchBlock_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define BigDnaMatchBlock_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*7 + state]) #define BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 7) + ((i+1) * 7) + (state)]) #define BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 56) + ((i+1) * 56) + (state * 8) + shadow+1]) #define BigDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_BigDnaMatchBlock(query,target,comp55,comp65,comp75,comp85,comp95,g,g65,g55,u,v,s,b) * * Descrip: This function allocates the BigDnaMatchBlock structure * and the basematrix area for a small memory implementations * It calls /allocate_BigDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp55 [UNKN ] Resource [DnaMatrix*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: g65 [UNKN ] Resource [Score] * Arg: g55 [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [BigDnaMatchBlock *] * */ #define BigDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) BigDnaMatchBlock * allocate_Small_BigDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b) { BigDnaMatchBlock * out; out = allocate_BigDnaMatchBlock_only(query, target , comp55, comp65, comp75, comp85, comp95, g, g65, g55, u, v, s, b); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 7,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix BigDnaMatchBlock cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_BigDnaMatchBlock(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_BigDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates an alignment for BigDnaMatchBlock structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_BigDnaMatchBlock * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_BigDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_BigDnaMatchBlock(BigDnaMatchBlock * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for BigDnaMatchBlock due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_BigDnaMatchBlock(mat,dpenv); score = start_end_find_end_BigDnaMatchBlock(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_BigDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_BigDnaMatchBlock(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == BigDnaMatchBlock_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_BigDnaMatchBlock(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 7; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_BigDnaMatchBlock(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_BigDnaMatchBlock(mat) * * Descrip: This function calculates an alignment for BigDnaMatchBlock structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_BigDnaMatchBlock * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_BigDnaMatchBlock * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_BigDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_BigDnaMatchBlock(BigDnaMatchBlock * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_BigDnaMatchBlock(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_BigDnaMatchBlock(mat); return out; } /* Function: AlnRangeSet_from_BigDnaMatchBlock(mat) * * Descrip: This function reads off a start/end structure * for BigDnaMatchBlock structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_BigDnaMatchBlock * If you have not calculated the matrix use * /AlnRange_calculate_Small_BigDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_BigDnaMatchBlock(BigDnaMatchBlock * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_BigDnaMatchBlock"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_BigDnaMatchBlock(mat,&jpos); state = END; while( (temp = AlnRange_build_BigDnaMatchBlock(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_BigDnaMatchBlock(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_BigDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_BigDnaMatchBlock(BigDnaMatchBlock * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_BigDnaMatchBlock"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_BigDnaMatchBlock(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_BigDnaMatchBlock alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = BigDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_BigDnaMatchBlock(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == BigDnaMatchBlock_READ_OFF_ERROR) { warn("In AlnRange_build_BigDnaMatchBlock alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = BigDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_BigDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_BigDnaMatchBlock(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == BigDnaMatchBlock_READ_OFF_ERROR) { warn("In BigDnaMatchBlock hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In BigDnaMatchBlock hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In BigDnaMatchBlock hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_BigDnaMatchBlock(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_BigDnaMatchBlock(BigDnaMatchBlock * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = BigDnaMatchBlock_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In BigDnaMatchBlock matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH55 : temp = cscore - ((mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g55) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH55) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH55; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH55); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH55); } temp = cscore - (mat->g55) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH55) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH55; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH55); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH55); } temp = cscore - ((mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH55) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH55; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH55); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH55); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH65 : temp = cscore - ((mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g65) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65); } temp = cscore - (mat->g65) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH65) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH65); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH65); } temp = cscore - ((mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH65) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH65); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH65); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH75 : temp = cscore - ((mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH75) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH75); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH75); } temp = cscore - (mat->g) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH75) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH75); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH75); } temp = cscore - ((mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH75) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH75); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH75); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH85 : temp = cscore - ((mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH85) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH85); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH85); } temp = cscore - (mat->g) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH85) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH85); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH85); } temp = cscore - ((mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH85) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH85); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH85); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH95 : temp = cscore - ((mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH95) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH95); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH95); } temp = cscore - (mat->g) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH95) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH95); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH95); } temp = cscore - ((mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH95) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH95); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH95); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_QUERY : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->u) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,UNMATCHED_QUERY) ) { *reti = i - 1; *retj = j - 0; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,UNMATCHED_QUERY); } temp = cscore - (mat->b) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH95) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH95); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH95); } temp = cscore - (mat->b) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH85) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH85); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH85); } temp = cscore - (mat->b) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH75) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH75); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH75); } temp = cscore - (mat->b) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65); } temp = cscore - (mat->b) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH55) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH55; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH55); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH55); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_TARGET : temp = cscore - (mat->u) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_TARGET) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->v) - (0); if( temp == BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_QUERY) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY); } return BigDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_QUERY); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_BigDnaMatchBlock(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_BigDnaMatchBlock(BigDnaMatchBlock * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 7; add_PackAln(out,pau); } max_special_strip_BigDnaMatchBlock(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == BigDnaMatchBlock_READ_OFF_ERROR) { warn("In special strip read BigDnaMatchBlock, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read BigDnaMatchBlock, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 7; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_BigDnaMatchBlock(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_BigDnaMatchBlock(BigDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = BigDnaMatchBlock_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for BigDnaMatchBlock, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In BigDnaMatchBlock matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = BigDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source UNMATCHED_TARGET is not a special */ default: warn("Major problem (!) - in BigDnaMatchBlock special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_BigDnaMatchBlock(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_BigDnaMatchBlock(BigDnaMatchBlock * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = BigDnaMatchBlock_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In BigDnaMatchBlock matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH55 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source MATCH55 is not a special, should not get here! */ /* Source MATCH55 is not a special, should not get here! */ /* Source MATCH55 is not a special, should not get here! */ warn("Major problem (!) - in BigDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH65 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ warn("Major problem (!) - in BigDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH75 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source MATCH75 is not a special, should not get here! */ /* Source MATCH75 is not a special, should not get here! */ /* Source MATCH75 is not a special, should not get here! */ warn("Major problem (!) - in BigDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH85 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source MATCH85 is not a special, should not get here! */ /* Source MATCH85 is not a special, should not get here! */ /* Source MATCH85 is not a special, should not get here! */ warn("Major problem (!) - in BigDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH95 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source MATCH95 is not a special, should not get here! */ /* Source MATCH95 is not a special, should not get here! */ /* Source MATCH95 is not a special, should not get here! */ warn("Major problem (!) - in BigDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_QUERY : temp = cscore - (0) - (0); if( temp == BigDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - BigDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source UNMATCHED_QUERY is not a special, should not get here! */ /* Source MATCH95 is not a special, should not get here! */ /* Source MATCH85 is not a special, should not get here! */ /* Source MATCH75 is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ /* Source MATCH55 is not a special, should not get here! */ warn("Major problem (!) - in BigDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_TARGET : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source UNMATCHED_QUERY is not a special, should not get here! */ warn("Major problem (!) - in BigDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_BigDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_BigDnaMatchBlock(mat,starti,startj,stopi,stopj); BigDnaMatchBlock_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH55) = NEGI; BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH65) = NEGI; BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH75) = NEGI; BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH85) = NEGI; BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH95) = NEGI; BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH55 */ /* setting first movement to score */ score = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH55) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH55) + mat->g55; if( temp > score ) { score = temp; } /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH55) + mat->g55; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH55 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH55 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH55) = score; /* Finished calculating state MATCH55 */ /* For state MATCH65 */ /* setting first movement to score */ score = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH65) + mat->g65; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65) + mat->g65; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH75) = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH85) = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH95) = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH55) + mat->b; /* From state MATCH65 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH75 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = BigDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished calculating state UNMATCHED_TARGET */ } } return; } /* Function: init_hidden_BigDnaMatchBlock(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH55) = NEGI; BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH65) = NEGI; BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH75) = NEGI; BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH85) = NEGI; BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH95) = NEGI; BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; BigDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } } return; } /* Function: full_dc_BigDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_BigDnaMatchBlock * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_BigDnaMatchBlock to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [BigDnaMatchBlock *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_BigDnaMatchBlock"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_BigDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_BigDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_BigDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for BigDnaMatchBlock, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_BigDnaMatchBlock(mat,BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_BigDnaMatchBlock(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_BigDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_BigDnaMatchBlock(mat); BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_BigDnaMatchBlock(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_BigDnaMatchBlock(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_BigDnaMatchBlock(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_BigDnaMatchBlock(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH55) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,0) = (-100); BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,1) = (-100); BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = (-100); BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = (-100); BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = (-100); BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = (-100); BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = (-100); BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = (-100); BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = (-100); BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = (-100); BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = (-100); BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = (-100); BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = (-100); BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH55, pushing when j - offj <= mergej */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH55) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,2) = MATCH55; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,5) = MATCH55; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH55,k); } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH55) + mat->g55; if( temp > score) { score = temp; if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,0) = i-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,2) = MATCH55; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,5) = MATCH55; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH55,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH55) + mat->g55; if( temp > score) { score = temp; if( j - 0 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,1) = j-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,2) = MATCH55; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,5) = MATCH55; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH55,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,2) = UNMATCHED_TARGET; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,5) = MATCH55; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH55) = score; /* Finished with state MATCH55 */ /* For state MATCH65, pushing when j - offj <= mergej */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = MATCH65; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH65,k); } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->g65; if( temp > score) { score = temp; if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = MATCH65; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH65,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->g65; if( temp > score) { score = temp; if( j - 0 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = MATCH65; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = UNMATCHED_TARGET; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = score; /* Finished with state MATCH65 */ /* For state MATCH75, pushing when j - offj <= mergej */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,2) = MATCH75; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,5) = MATCH75; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH75,k); } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score) { score = temp; if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = i-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,2) = MATCH75; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,5) = MATCH75; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH75,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score) { score = temp; if( j - 0 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = j-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,2) = MATCH75; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,5) = MATCH75; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,2) = UNMATCHED_TARGET; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,5) = MATCH75; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = score; /* Finished with state MATCH75 */ /* For state MATCH85, pushing when j - offj <= mergej */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,2) = MATCH85; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,5) = MATCH85; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH85,k); } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score) { score = temp; if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = i-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,2) = MATCH85; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,5) = MATCH85; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH85,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score) { score = temp; if( j - 0 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = j-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,2) = MATCH85; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,5) = MATCH85; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,2) = UNMATCHED_TARGET; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,5) = MATCH85; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = score; /* Finished with state MATCH85 */ /* For state MATCH95, pushing when j - offj <= mergej */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,2) = MATCH95; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,5) = MATCH95; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH95,k); } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score) { score = temp; if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = i-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,2) = MATCH95; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,5) = MATCH95; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH95,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score) { score = temp; if( j - 0 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = j-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,2) = MATCH95; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,5) = MATCH95; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,2) = UNMATCHED_TARGET; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,5) = MATCH95; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = score; /* Finished with state MATCH95 */ /* For state UNMATCHED_QUERY, pushing when j - offj <= mergej */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH55) + mat->b; if( j - 0 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH55; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH55,k); } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; if( temp > score) { score = temp; if( j - 0 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH65; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score) { score = temp; if( j - 0 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH75; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score) { score = temp; if( j - 0 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH85; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score) { score = temp; if( j - 0 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH95; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,k); } } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score) { score = temp; if( j - 0 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = UNMATCHED_QUERY; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED_QUERY,k); } } /* Add any movement independant score */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished with state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET, pushing when j - offj <= mergej */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = i-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,2) = UNMATCHED_QUERY; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,5) = UNMATCHED_TARGET; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_QUERY,k); } temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score) { score = temp; if( j - 1 <= mergej) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = i-0; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,1) = j-1; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,2) = UNMATCHED_TARGET; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,3) = i; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,4) = j; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,5) = UNMATCHED_TARGET; } else { for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished with state UNMATCHED_TARGET */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_BigDnaMatchBlock(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH55) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH55 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH55) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH55,k); /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH55) + mat->g55; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH55,k); } /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH55) + mat->g55; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH55,k); } /* From state UNMATCHED_TARGET to state MATCH55 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH55 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH55) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH55 */ /* For state MATCH65 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH65,k); /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->g65; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH65,k); } /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->g65; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH75,k); /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH75,k); } /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,k); } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH85,k); /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH85,k); } /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,k); } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH95,k); /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH95,k); } /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,k); } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH55) + mat->b; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH55,k); /* From state MATCH65 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); } /* From state MATCH75 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,k); } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,k); } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,k); } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED_QUERY,k); } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_QUERY,k); /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED_TARGET */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_BigDnaMatchBlock(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH55) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH55 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH55) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH55) + mat->g55; if( temp > score ) { score = temp; } /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH55) + mat->g55; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH55 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH55 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH55) = score; /* Finished calculating state MATCH55 */ /* For state MATCH65 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->g65; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->g65; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH55) + mat->b; /* From state MATCH65 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH75 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished calculating state UNMATCHED_TARGET */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_BigDnaMatchBlock(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * */ } void init_dc_BigDnaMatchBlock(BigDnaMatchBlock * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH55) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; for(k=0;k<7;k++) { BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,k) = (-1); BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = (-1); BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = (-1); BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = (-1); BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = (-1); BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = (-1); BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = (-1); } } } return; } /* Function: start_end_find_end_BigDnaMatchBlock(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [BigDnaMatchBlock *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_BigDnaMatchBlock(BigDnaMatchBlock * mat,int * endj) { register int j; register int max; register int maxj; max = BigDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( BigDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = BigDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_BigDnaMatchBlock(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [BigDnaMatchBlock] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_BigDnaMatchBlock(BigDnaMatchBlock *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->seq->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 7,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 7 * 8,sizeof(int)); for(j=0;jcomp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH55,0)); /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH55) + mat->g55 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH55,0)); } /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH55) + mat->g55 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH55,0)); } /* From state UNMATCHED_TARGET to state MATCH55 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH55 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH55) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH55,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH55 */ /* For state MATCH65 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH65,0)); /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->g65 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH65,0)); } /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->g65 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,0)); } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH65) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH75,0)); /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH75) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH75,0)); } /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,0)); } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH75) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH75,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH85,0)); /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH85) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH85,0)); } /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,0)); } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH85) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH85,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH95,0)); /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH95) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH95,0)); } /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,0)); } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH95) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH95,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH55) + mat->b + (0); /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH55,0)); /* From state MATCH65 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->b +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,0)); } /* From state MATCH75 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH75) + mat->b +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH75,0)); } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH85) + mat->b +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH85,0)); } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH95) + mat->b +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH95,0)); } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED_QUERY,0)); } /* From state START to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + 0 + (0); if( temp > score ) { score = temp; /* This state [START] is a special for UNMATCHED_QUERY... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= UNMATCHED_QUERY; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v + (0); /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_QUERY,0)); /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; for(k=0;k<7;k++) BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state UNMATCHED_TARGET is a source for special END */ temp = score + (0) + (0) ; if( temp > BigDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { BigDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) BigDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k); BigDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = BigDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,6); BigDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; BigDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; BigDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = UNMATCHED_TARGET; } /* Finished calculating state UNMATCHED_TARGET */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_BigDnaMatchBlock(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * */ void init_start_end_linear_BigDnaMatchBlock(BigDnaMatchBlock * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH55) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH55,0) = (-1); BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = (-1); BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH75) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH75,0) = (-1); BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH85) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH85,0) = (-1); BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH95) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH95,0) = (-1); BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = (-1); BigDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; BigDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = (-1); } } for(j=(-1);jtarget->seq->len;j++) { BigDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; BigDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; BigDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_BigDnaMatchBlock(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_BigDnaMatchBlock(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_BigDnaMatchBlock(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MM55","MI55","MM65","MI65","MM75","MI75","MM85","MI85","MM95","MI95","UM","UI","END" }; /* Function: AlnConvertSet_BigDnaMatchBlock(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "MM55","MI55","MM65","MI65","MM75","MI75","MM85","MI85","MM95","MI95","UI","UM","END" }; AlnConvertSet * AlnConvertSet_BigDnaMatchBlock(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH55; acu->state2 = MATCH55; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH55; acu->state2 = MATCH55; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH55; acu->state2 = MATCH55; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH55; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = MATCH65; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = MATCH65; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = MATCH65; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH65; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH75; acu->state2 = MATCH75; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH75; acu->state2 = MATCH75; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH75; acu->state2 = MATCH75; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[5]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH75; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH85; acu->state2 = MATCH85; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH85; acu->state2 = MATCH85; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH85; acu->state2 = MATCH85; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[7]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH85; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[6]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH95; acu->state2 = MATCH95; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH95; acu->state2 = MATCH95; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH95; acu->state2 = MATCH95; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[9]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH95; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[8]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH55; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH75; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH85; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH95; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_QUERY; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 7; acu->is_from_special = TRUE; acu->state2 = UNMATCHED_QUERY; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[10]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_QUERY; acu->state2 = UNMATCHED_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[11]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = UNMATCHED_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[11]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = END + 7; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[12]; acu->label2 = target_label[12]; return out; } /* Function: PackAln_read_Expl_BigDnaMatchBlock(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_BigDnaMatchBlock(BigDnaMatchBlock * mat) { BigDnaMatchBlock_access_func_holder holder; holder.access_main = BigDnaMatchBlock_explicit_access_main; holder.access_special = BigDnaMatchBlock_explicit_access_special; return PackAln_read_generic_BigDnaMatchBlock(mat,holder); } /* Function: BigDnaMatchBlock_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int BigDnaMatchBlock_explicit_access_main(BigDnaMatchBlock * mat,int i,int j,int state) { return BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,state); } /* Function: BigDnaMatchBlock_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int BigDnaMatchBlock_explicit_access_special(BigDnaMatchBlock * mat,int i,int j,int state) { return BigDnaMatchBlock_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_BigDnaMatchBlock(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: h [UNKN ] Undocumented argument [BigDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_BigDnaMatchBlock(BigDnaMatchBlock * mat,BigDnaMatchBlock_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_BigDnaMatchBlock(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in BigDnaMatchBlock_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 7; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_BigDnaMatchBlock(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_BigDnaMatchBlock(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == BigDnaMatchBlock_READ_OFF_ERROR || j == BigDnaMatchBlock_READ_OFF_ERROR || state == BigDnaMatchBlock_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in BigDnaMatchBlock_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 7; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_BigDnaMatchBlock(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [BigDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_BigDnaMatchBlock(BigDnaMatchBlock * mat,int * ri,int * rj,int * state,boolean * isspecial,BigDnaMatchBlock_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: BigDnaMatchBlock_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void BigDnaMatchBlock_debug_show_matrix(BigDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->seq->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH55 %d\n",BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH55)); fprintf(ofp,"State MATCH65 %d\n",BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65)); fprintf(ofp,"State MATCH75 %d\n",BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75)); fprintf(ofp,"State MATCH85 %d\n",BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85)); fprintf(ofp,"State MATCH95 %d\n",BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95)); fprintf(ofp,"State UNMATCHED_QUERY %d\n",BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY)); fprintf(ofp,"State UNMATCHED_TARGET %d\n",BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_BigDnaMatchBlock(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [BigDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_BigDnaMatchBlock(BigDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,BigDnaMatchBlock_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = BigDnaMatchBlock_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In BigDnaMatchBlock matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH55 : temp = cscore - ((mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g55) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH55) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH55; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH55); } return (*h.access_main)(mat,i - 1,j - 0,MATCH55); } temp = cscore - (mat->g55) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH55) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH55; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH55); } return (*h.access_main)(mat,i - 0,j - 1,MATCH55); } temp = cscore - ((mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH55) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH55; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH55); } return (*h.access_main)(mat,i - 1,j - 1,MATCH55); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH65 : temp = cscore - ((mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g65) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH65); } return (*h.access_main)(mat,i - 1,j - 0,MATCH65); } temp = cscore - (mat->g65) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH65) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH65); } return (*h.access_main)(mat,i - 0,j - 1,MATCH65); } temp = cscore - ((mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH65) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH65); } return (*h.access_main)(mat,i - 1,j - 1,MATCH65); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH75 : temp = cscore - ((mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH75) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH75); } return (*h.access_main)(mat,i - 1,j - 0,MATCH75); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH75) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH75); } return (*h.access_main)(mat,i - 0,j - 1,MATCH75); } temp = cscore - ((mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH75) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH75); } return (*h.access_main)(mat,i - 1,j - 1,MATCH75); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH85 : temp = cscore - ((mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH85) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH85); } return (*h.access_main)(mat,i - 1,j - 0,MATCH85); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH85) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH85); } return (*h.access_main)(mat,i - 0,j - 1,MATCH85); } temp = cscore - ((mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH85) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH85); } return (*h.access_main)(mat,i - 1,j - 1,MATCH85); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case MATCH95 : temp = cscore - ((mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH95) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH95); } return (*h.access_main)(mat,i - 1,j - 0,MATCH95); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH95) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH95); } return (*h.access_main)(mat,i - 0,j - 1,MATCH95); } temp = cscore - ((mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH95) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH95); } return (*h.access_main)(mat,i - 1,j - 1,MATCH95); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_QUERY : /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } } temp = cscore - (mat->u) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,UNMATCHED_QUERY) ) { *reti = i - 1; *retj = j - 0; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,UNMATCHED_QUERY); } return (*h.access_main)(mat,i - 1,j - 0,UNMATCHED_QUERY); } temp = cscore - (mat->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH95) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH95; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH95); } return (*h.access_main)(mat,i - 1,j - 0,MATCH95); } temp = cscore - (mat->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH85) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH85; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH85); } return (*h.access_main)(mat,i - 1,j - 0,MATCH85); } temp = cscore - (mat->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH75) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH75; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH75); } return (*h.access_main)(mat,i - 1,j - 0,MATCH75); } temp = cscore - (mat->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH65); } return (*h.access_main)(mat,i - 1,j - 0,MATCH65); } temp = cscore - (mat->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH55) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH55; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH55); } return (*h.access_main)(mat,i - 1,j - 0,MATCH55); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_TARGET : temp = cscore - (mat->u) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_TARGET) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->v) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_QUERY) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UNMATCHED_QUERY); } return (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_QUERY); } warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_BigDnaMatchBlock(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [BigDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_BigDnaMatchBlock(BigDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,BigDnaMatchBlock_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = BigDnaMatchBlock_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In BigDnaMatchBlock matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source UNMATCHED_TARGET is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,UNMATCHED_TARGET) ) { *reti = i - 0; *retj = j - 0; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 0,j - 0,UNMATCHED_TARGET) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in BigDnaMatchBlock read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_BigDnaMatchBlock(mat) * * Descrip: This function calculates the BigDnaMatchBlock matrix when in explicit mode * To allocate the matrix use /allocate_Expl_BigDnaMatchBlock * * * Arg: mat [UNKN ] BigDnaMatchBlock which contains explicit basematrix memory [BigDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_BigDnaMatchBlock(BigDnaMatchBlock * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_BigDnaMatchBlock, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("BigDnaMatchBlock Matrix calculation: "); for(j=0;jcomp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH55) + mat->g55; if( temp > score ) { score = temp; } /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH55) + mat->g55; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH55 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH55 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH55) = score; /* Finished calculating state MATCH55 */ /* For state MATCH65 */ /* setting first movement to score */ score = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH65) + mat->g65; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->g65; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH55) + mat->b; /* From state MATCH65 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH75 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-0,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* state UNMATCHED_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > BigDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { BigDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state UNMATCHED_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_BigDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the BigDnaMatchBlock matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] BigDnaMatchBlock which contains explicit basematrix memory [BigDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_BigDnaMatchBlock(BigDnaMatchBlock * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_BigDnaMatchBlock, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH55) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } } for(j=-1;jlenj;j++) { BigDnaMatchBlock_EXPL_SPECIAL(mat,i,j,START) = 0; BigDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("BigDnaMatchBlock Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH55) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH55 */ /* setting first movement to score */ score = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH55) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH55) + mat->g55; if( temp > score ) { score = temp; } /* From state MATCH55 to state MATCH55 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH55) + mat->g55; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH55 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp55->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH55 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH55) = score; /* Finished calculating state MATCH55 */ /* For state MATCH65 */ /* setting first movement to score */ score = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH65) + mat->g65; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->g65; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state MATCH75 */ /* setting first movement to score */ score = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH75) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH75 to state MATCH75 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH75) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH75 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp75->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH75 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH75) = score; /* Finished calculating state MATCH75 */ /* For state MATCH85 */ /* setting first movement to score */ score = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH85) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH85 to state MATCH85 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH85) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH85 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp85->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH85 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH85) = score; /* Finished calculating state MATCH85 */ /* For state MATCH95 */ /* setting first movement to score */ score = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH95) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH95 to state MATCH95 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH95) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH95 */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp95->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH95 */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH95) = score; /* Finished calculating state MATCH95 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH55) + mat->b; /* From state MATCH65 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH75 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH75) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH85 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH85) + mat->b; if( temp > score ) { score = temp; } /* From state MATCH95 to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH95) + mat->b; if( temp > score ) { score = temp; } /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state UNMATCHED_QUERY */ temp = BigDnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-0,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = BigDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ BigDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* state UNMATCHED_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > BigDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { BigDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state UNMATCHED_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: BigDnaMatchBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [BigDnaMatchBlock *] * */ BigDnaMatchBlock * BigDnaMatchBlock_alloc(void) { BigDnaMatchBlock * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(BigDnaMatchBlock *) ckalloc (sizeof(BigDnaMatchBlock))) == NULL) { warn("BigDnaMatchBlock_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_BigDnaMatchBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [BigDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [BigDnaMatchBlock *] * */ BigDnaMatchBlock * free_BigDnaMatchBlock(BigDnaMatchBlock * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a BigDnaMatchBlock obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->comp55 is linked in */ /* obj->comp65 is linked in */ /* obj->comp75 is linked in */ /* obj->comp85 is linked in */ /* obj->comp95 is linked in */ /* obj->g is linked in */ /* obj->g65 is linked in */ /* obj->g55 is linked in */ /* obj->u is linked in */ /* obj->v is linked in */ /* obj->s is linked in */ /* obj->b is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/bigdba.h0000644000175000001440000005724510670453713015527 0ustar philippusers#ifndef DYNAMITEbigdbaHEADERFILE #define DYNAMITEbigdbaHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" struct Wise2_BigDnaMatchBlock { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; ComplexSequence* query; ComplexSequence* target; DnaMatrix* comp55; DnaMatrix* comp65; DnaMatrix* comp75; DnaMatrix* comp85; DnaMatrix* comp95; Score g; Score g65; Score g55; Score u; Score v; Score s; Score b; } ; /* BigDnaMatchBlock defined */ #ifndef DYNAMITE_DEFINED_BigDnaMatchBlock typedef struct Wise2_BigDnaMatchBlock Wise2_BigDnaMatchBlock; #define BigDnaMatchBlock Wise2_BigDnaMatchBlock #define DYNAMITE_DEFINED_BigDnaMatchBlock #endif struct Wise2_BigDnaMatchBlock_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(BigDnaMatchBlock*,int,int,int); int (*access_special)(BigDnaMatchBlock*,int,int,int); } ; /* BigDnaMatchBlock_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_BigDnaMatchBlock_access_func_holder typedef struct Wise2_BigDnaMatchBlock_access_func_holder Wise2_BigDnaMatchBlock_access_func_holder; #define BigDnaMatchBlock_access_func_holder Wise2_BigDnaMatchBlock_access_func_holder #define DYNAMITE_DEFINED_BigDnaMatchBlock_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_BigDnaMatchBlock(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_BigDnaMatchBlock(BigDnaMatchBlock * mat); #define PackAln_read_Shatter_BigDnaMatchBlock Wise2_PackAln_read_Shatter_BigDnaMatchBlock /* Function: calculate_shatter_BigDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the BigDnaMatchBlock matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [BigDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_BigDnaMatchBlock(BigDnaMatchBlock * mat,DPEnvelope * dpenv); #define calculate_shatter_BigDnaMatchBlock Wise2_calculate_shatter_BigDnaMatchBlock /* Function: search_BigDnaMatchBlock(dbsi,out,query,target,comp55,comp65,comp75,comp85,comp95,g,g65,g55,u,v,s,b) * * Descrip: This function makes a database search of BigDnaMatchBlock * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp55 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp65 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp75 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp85 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp95 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: g [UNKN ] Undocumented argument [Score] * Arg: g65 [UNKN ] Undocumented argument [Score] * Arg: g55 [UNKN ] Undocumented argument [Score] * Arg: u [UNKN ] Undocumented argument [Score] * Arg: v [UNKN ] Undocumented argument [Score] * Arg: s [UNKN ] Undocumented argument [Score] * Arg: b [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_BigDnaMatchBlock(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b); #define search_BigDnaMatchBlock Wise2_search_BigDnaMatchBlock /* Function: serial_search_BigDnaMatchBlock(out,query,target,comp55,comp65,comp75,comp85,comp95,g,g65,g55,u,v,s,b) * * Descrip: This function makes a database search of BigDnaMatchBlock * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp55 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp65 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp75 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp85 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: comp95 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: g [UNKN ] Undocumented argument [Score] * Arg: g65 [UNKN ] Undocumented argument [Score] * Arg: g55 [UNKN ] Undocumented argument [Score] * Arg: u [UNKN ] Undocumented argument [Score] * Arg: v [UNKN ] Undocumented argument [Score] * Arg: s [UNKN ] Undocumented argument [Score] * Arg: b [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_BigDnaMatchBlock(Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b); #define serial_search_BigDnaMatchBlock Wise2_serial_search_BigDnaMatchBlock /* Function: PackAln_bestmemory_BigDnaMatchBlock(query,target,comp55,comp65,comp75,comp85,comp95,g,g65,g55,u,v,s,b,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_BigDnaMatchBlock * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp55 [UNKN ] Resource [DnaMatrix*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: g65 [UNKN ] Resource [Score] * Arg: g55 [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_BigDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_BigDnaMatchBlock Wise2_PackAln_bestmemory_BigDnaMatchBlock /* Function: allocate_Expl_BigDnaMatchBlock(query,target,comp55,comp65,comp75,comp85,comp95,g,g65,g55,u,v,s,b,dpri) * * Descrip: This function allocates the BigDnaMatchBlock structure * and the basematrix area for explicit memory implementations * It calls /allocate_BigDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp55 [UNKN ] Resource [DnaMatrix*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: g65 [UNKN ] Resource [Score] * Arg: g55 [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [BigDnaMatchBlock *] * */ BigDnaMatchBlock * Wise2_allocate_Expl_BigDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b,DPRunImpl * dpri); #define allocate_Expl_BigDnaMatchBlock Wise2_allocate_Expl_BigDnaMatchBlock /* Function: recalculate_PackAln_BigDnaMatchBlock(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by BigDnaMatchBlock * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * */ void Wise2_recalculate_PackAln_BigDnaMatchBlock(PackAln * pal,BigDnaMatchBlock * mat); #define recalculate_PackAln_BigDnaMatchBlock Wise2_recalculate_PackAln_BigDnaMatchBlock /* Function: allocate_Small_BigDnaMatchBlock(query,target,comp55,comp65,comp75,comp85,comp95,g,g65,g55,u,v,s,b) * * Descrip: This function allocates the BigDnaMatchBlock structure * and the basematrix area for a small memory implementations * It calls /allocate_BigDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp55 [UNKN ] Resource [DnaMatrix*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: comp75 [UNKN ] Resource [DnaMatrix*] * Arg: comp85 [UNKN ] Resource [DnaMatrix*] * Arg: comp95 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: g65 [UNKN ] Resource [Score] * Arg: g55 [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [BigDnaMatchBlock *] * */ BigDnaMatchBlock * Wise2_allocate_Small_BigDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b); #define allocate_Small_BigDnaMatchBlock Wise2_allocate_Small_BigDnaMatchBlock /* Function: PackAln_calculate_Small_BigDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates an alignment for BigDnaMatchBlock structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_BigDnaMatchBlock * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_BigDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_BigDnaMatchBlock(BigDnaMatchBlock * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_BigDnaMatchBlock Wise2_PackAln_calculate_Small_BigDnaMatchBlock /* Function: AlnRangeSet_calculate_Small_BigDnaMatchBlock(mat) * * Descrip: This function calculates an alignment for BigDnaMatchBlock structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_BigDnaMatchBlock * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_BigDnaMatchBlock * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_BigDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_BigDnaMatchBlock(BigDnaMatchBlock * mat); #define AlnRangeSet_calculate_Small_BigDnaMatchBlock Wise2_AlnRangeSet_calculate_Small_BigDnaMatchBlock /* Function: AlnRangeSet_from_BigDnaMatchBlock(mat) * * Descrip: This function reads off a start/end structure * for BigDnaMatchBlock structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_BigDnaMatchBlock * If you have not calculated the matrix use * /AlnRange_calculate_Small_BigDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_BigDnaMatchBlock(BigDnaMatchBlock * mat); #define AlnRangeSet_from_BigDnaMatchBlock Wise2_AlnRangeSet_from_BigDnaMatchBlock /* Function: convert_PackAln_to_AlnBlock_BigDnaMatchBlock(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_BigDnaMatchBlock(PackAln * pal); #define convert_PackAln_to_AlnBlock_BigDnaMatchBlock Wise2_convert_PackAln_to_AlnBlock_BigDnaMatchBlock /* Function: PackAln_read_Expl_BigDnaMatchBlock(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_BigDnaMatchBlock(BigDnaMatchBlock * mat); #define PackAln_read_Expl_BigDnaMatchBlock Wise2_PackAln_read_Expl_BigDnaMatchBlock /* Function: PackAln_read_generic_BigDnaMatchBlock(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [BigDnaMatchBlock *] * Arg: h [UNKN ] Undocumented argument [BigDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_BigDnaMatchBlock(BigDnaMatchBlock * mat,BigDnaMatchBlock_access_func_holder h); #define PackAln_read_generic_BigDnaMatchBlock Wise2_PackAln_read_generic_BigDnaMatchBlock /* Function: calculate_BigDnaMatchBlock(mat) * * Descrip: This function calculates the BigDnaMatchBlock matrix when in explicit mode * To allocate the matrix use /allocate_Expl_BigDnaMatchBlock * * * Arg: mat [UNKN ] BigDnaMatchBlock which contains explicit basematrix memory [BigDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_BigDnaMatchBlock(BigDnaMatchBlock * mat); #define calculate_BigDnaMatchBlock Wise2_calculate_BigDnaMatchBlock /* Function: calculate_dpenv_BigDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the BigDnaMatchBlock matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] BigDnaMatchBlock which contains explicit basematrix memory [BigDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_BigDnaMatchBlock(BigDnaMatchBlock * mat,DPEnvelope * dpenv); #define calculate_dpenv_BigDnaMatchBlock Wise2_calculate_dpenv_BigDnaMatchBlock /* Function: BigDnaMatchBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [BigDnaMatchBlock *] * */ BigDnaMatchBlock * Wise2_BigDnaMatchBlock_alloc(void); #define BigDnaMatchBlock_alloc Wise2_BigDnaMatchBlock_alloc /* Function: free_BigDnaMatchBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [BigDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [BigDnaMatchBlock *] * */ BigDnaMatchBlock * Wise2_free_BigDnaMatchBlock(BigDnaMatchBlock * obj); #define free_BigDnaMatchBlock Wise2_free_BigDnaMatchBlock /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_BigDnaMatchBlock_shatter_access_main(BigDnaMatchBlock * mat,int i,int j,int state); #define BigDnaMatchBlock_shatter_access_main Wise2_BigDnaMatchBlock_shatter_access_main int Wise2_BigDnaMatchBlock_shatter_access_special(BigDnaMatchBlock * mat,int i,int j,int state); #define BigDnaMatchBlock_shatter_access_special Wise2_BigDnaMatchBlock_shatter_access_special int Wise2_score_only_BigDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b); #define score_only_BigDnaMatchBlock Wise2_score_only_BigDnaMatchBlock BigDnaMatchBlock * Wise2_allocate_BigDnaMatchBlock_only(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp55,DnaMatrix* comp65,DnaMatrix* comp75,DnaMatrix* comp85,DnaMatrix* comp95,Score g,Score g65,Score g55,Score u,Score v,Score s,Score b); #define allocate_BigDnaMatchBlock_only Wise2_allocate_BigDnaMatchBlock_only void Wise2_init_BigDnaMatchBlock(BigDnaMatchBlock * mat); #define init_BigDnaMatchBlock Wise2_init_BigDnaMatchBlock AlnRange * Wise2_AlnRange_build_BigDnaMatchBlock(BigDnaMatchBlock * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_BigDnaMatchBlock Wise2_AlnRange_build_BigDnaMatchBlock boolean Wise2_read_hidden_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_BigDnaMatchBlock Wise2_read_hidden_BigDnaMatchBlock int Wise2_max_hidden_BigDnaMatchBlock(BigDnaMatchBlock * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_BigDnaMatchBlock Wise2_max_hidden_BigDnaMatchBlock boolean Wise2_read_special_strip_BigDnaMatchBlock(BigDnaMatchBlock * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_BigDnaMatchBlock Wise2_read_special_strip_BigDnaMatchBlock int Wise2_max_special_strip_BigDnaMatchBlock(BigDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_BigDnaMatchBlock Wise2_max_special_strip_BigDnaMatchBlock int Wise2_max_matrix_to_special_BigDnaMatchBlock(BigDnaMatchBlock * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_BigDnaMatchBlock Wise2_max_matrix_to_special_BigDnaMatchBlock void Wise2_calculate_hidden_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_BigDnaMatchBlock Wise2_calculate_hidden_BigDnaMatchBlock void Wise2_init_hidden_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_BigDnaMatchBlock Wise2_init_hidden_BigDnaMatchBlock boolean Wise2_full_dc_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_BigDnaMatchBlock Wise2_full_dc_BigDnaMatchBlock boolean Wise2_do_dc_single_pass_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_BigDnaMatchBlock Wise2_do_dc_single_pass_BigDnaMatchBlock void Wise2_push_dc_at_merge_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_BigDnaMatchBlock Wise2_push_dc_at_merge_BigDnaMatchBlock void Wise2_follow_on_dc_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_BigDnaMatchBlock Wise2_follow_on_dc_BigDnaMatchBlock void Wise2_run_up_dc_BigDnaMatchBlock(BigDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_BigDnaMatchBlock Wise2_run_up_dc_BigDnaMatchBlock void Wise2_init_dc_BigDnaMatchBlock(BigDnaMatchBlock * mat); #define init_dc_BigDnaMatchBlock Wise2_init_dc_BigDnaMatchBlock int Wise2_start_end_find_end_BigDnaMatchBlock(BigDnaMatchBlock * mat,int * endj); #define start_end_find_end_BigDnaMatchBlock Wise2_start_end_find_end_BigDnaMatchBlock boolean Wise2_dc_optimised_start_end_calc_BigDnaMatchBlock(BigDnaMatchBlock *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_BigDnaMatchBlock Wise2_dc_optimised_start_end_calc_BigDnaMatchBlock void Wise2_init_start_end_linear_BigDnaMatchBlock(BigDnaMatchBlock * mat); #define init_start_end_linear_BigDnaMatchBlock Wise2_init_start_end_linear_BigDnaMatchBlock AlnConvertSet * Wise2_AlnConvertSet_BigDnaMatchBlock(void); #define AlnConvertSet_BigDnaMatchBlock Wise2_AlnConvertSet_BigDnaMatchBlock int Wise2_BigDnaMatchBlock_explicit_access_main(BigDnaMatchBlock * mat,int i,int j,int state); #define BigDnaMatchBlock_explicit_access_main Wise2_BigDnaMatchBlock_explicit_access_main int Wise2_BigDnaMatchBlock_explicit_access_special(BigDnaMatchBlock * mat,int i,int j,int state); #define BigDnaMatchBlock_explicit_access_special Wise2_BigDnaMatchBlock_explicit_access_special int Wise2_find_end_BigDnaMatchBlock(BigDnaMatchBlock * mat,int * ri,int * rj,int * state,boolean * isspecial,BigDnaMatchBlock_access_func_holder h); #define find_end_BigDnaMatchBlock Wise2_find_end_BigDnaMatchBlock void Wise2_BigDnaMatchBlock_debug_show_matrix(BigDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define BigDnaMatchBlock_debug_show_matrix Wise2_BigDnaMatchBlock_debug_show_matrix int Wise2_max_calc_BigDnaMatchBlock(BigDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,BigDnaMatchBlock_access_func_holder h); #define max_calc_BigDnaMatchBlock Wise2_max_calc_BigDnaMatchBlock int Wise2_max_calc_special_BigDnaMatchBlock(BigDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,BigDnaMatchBlock_access_func_holder h); #define max_calc_special_BigDnaMatchBlock Wise2_max_calc_special_BigDnaMatchBlock #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/estslim3.c0000644000175000001440000053334010670453713016050 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "estslim3.h" # line 5 "estslim3.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define START 0 #define END 1 #define EstSlim3_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+4)*3)+STATE][i+1] #define EstSlim3_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+4] #define EstSlim3_READ_OFF_ERROR -6 #define EstSlim3_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+5)%5][((i+1)*3)+STATE] #define EstSlim3_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+5)%5][STATE] #define EstSlim3_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define EstSlim3_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_EstSlim3(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_EstSlim3(EstSlim3 * mat) { EstSlim3_access_func_holder holder; holder.access_main = EstSlim3_shatter_access_main; holder.access_special = EstSlim3_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_EstSlim3(mat,holder); } /* Function: EstSlim3_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstSlim3_shatter_access_main(EstSlim3 * mat,int i,int j,int state) { return EstSlim3_SHATTER_MATRIX(mat,i,j,state); } /* Function: EstSlim3_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstSlim3_shatter_access_special(EstSlim3 * mat,int i,int j,int state) { return EstSlim3_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_EstSlim3(mat,dpenv) * * Descrip: This function calculates the EstSlim3 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EstSlim3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_EstSlim3(EstSlim3 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_2; int * SIG_1_4; int * SIG_0_3; int * SIG_0_2; int * SIG_0_4; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("EstSlim3 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstSlim3_SHATTER_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_4[MATCH] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlim3_SHATTER_SPECIAL(mat,i,j,END) ) { EstSlim3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstSlim3_SHATTER_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_2[INSERT] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_4[INSERT] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ SIG_0_0[INSERT] = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlim3_SHATTER_SPECIAL(mat,i,j,END) ) { EstSlim3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstSlim3_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlim3_SHATTER_SPECIAL(mat,i,j,END) ) { EstSlim3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_EstSlim3(dbsi,out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstSlim3 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_EstSlim3(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_EstSlim3 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_EstSlim3. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_EstSlim3. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for EstSlim3, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_EstSlim3(out,querydb, targetdb ,cp); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_EstSlim3 *) ckalloc(sizeof(struct thread_pool_holder_EstSlim3)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->cp = cp; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_EstSlim3,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for EstSlim3"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from EstSlim3",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_EstSlim3(ptr) * * Descrip: Infinite loop code foreach thread for EstSlim3 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_EstSlim3(void * ptr) { struct thread_pool_holder_EstSlim3 * holder; int db_status; int score; DataScore * ds; GeneWiseScore* query; ComplexSequence* target; holder = (struct thread_pool_holder_EstSlim3 *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for EstSlim3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstSlim3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_GeneWiseDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in EstSlim3 search"); } query = hard_link_GeneWiseScore(holder->query); /* get query information into datascore */ dataentry_add_GeneWiseDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_cDNADB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_cDNADB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching EstSlim3, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_cDNADB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_GeneWiseScore(holder->query); /* get the next query object for the next thread */ holder->query = reload_GeneWiseDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching EstSlim3, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_GeneWiseDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstSlim3"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstSlim3"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_cDNADB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_EstSlim3(query, target ,holder->cp); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for EstSlim3"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for EstSlim3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for EstSlim3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_GeneWiseScore(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstSlim3"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_EstSlim3(out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstSlim3 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_EstSlim3(Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp) { GeneWiseScore* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GeneWiseDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstSlim3, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_cDNADB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstSlim3, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_EstSlim3(query, target , cp); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("EstSlim3 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GeneWiseDB(ds->query,query,querydb); dataentry_add_cDNADB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_cDNADB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstSlim3, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_cDNADB(target,targetdb); query = reload_GeneWiseDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching EstSlim3, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GeneWiseDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_EstSlim3(query,target,cp) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_EstSlim3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_EstSlim3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp) { int bestscore = NEGI; int i; int j; int k; EstSlim3 * mat; mat = allocate_EstSlim3_only(query, target , cp); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(5,(mat->leni + 1) * 3,5,2)) == NULL) { warn("Score only matrix for EstSlim3 cannot be allocated, (asking for 4 by %d cells)",mat->leni*3); mat = free_EstSlim3(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<6;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) EstSlim3_VSMALL_MATRIX(mat,i,j,k) = NEGI; } EstSlim3_VSMALL_SPECIAL(mat,i,j,START) = 0; EstSlim3_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = EstSlim3_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstSlim3_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstSlim3_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstSlim3_VSMALL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlim3_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlim3_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstSlim3_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlim3_VSMALL_SPECIAL(mat,i,j,END) ) { EstSlim3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlim3_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstSlim3_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstSlim3_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstSlim3_VSMALL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlim3_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlim3_VSMALL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstSlim3_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlim3_VSMALL_SPECIAL(mat,i,j,END) ) { EstSlim3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlim3_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstSlim3_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstSlim3_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstSlim3_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstSlim3_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlim3_VSMALL_SPECIAL(mat,i,j,END) ) { EstSlim3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < EstSlim3_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = EstSlim3_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_EstSlim3(mat); return bestscore; } /* Function: PackAln_bestmemory_EstSlim3(query,target,cp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EstSlim3 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_EstSlim3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; EstSlim3 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_EstSlim3(query, target , cp,dpri)) == NULL ) { warn("Unable to allocate large EstSlim3 version"); return NULL; } calculate_dpenv_EstSlim3(mat,dpenv); out = PackAln_read_Expl_EstSlim3(mat); } else { mat = allocate_EstSlim3_only(query, target , cp); calculate_shatter_EstSlim3(mat,dpenv); out = PackAln_read_Shatter_EstSlim3(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_EstSlim3(query, target , cp)) == NULL ) { warn("Unable to allocate small EstSlim3 version"); return NULL; } out = PackAln_calculate_Small_EstSlim3(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_EstSlim3(query, target , cp,dpri)) == NULL ) { warn("Unable to allocate large EstSlim3 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_EstSlim3(mat); out = PackAln_read_Expl_EstSlim3(mat); } } } mat = free_EstSlim3(mat); return out; } /* Function: allocate_EstSlim3_only(query,target,cp) * * Descrip: This function only allocates the EstSlim3 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstSlim3 *] * */ EstSlim3 * allocate_EstSlim3_only(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp) { EstSlim3 * out; if((out= EstSlim3_alloc()) == NULL) { warn("Allocation of basic EstSlim3 structure failed..."); return NULL; } out->query = query; out->target = target; out->cp = cp; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_EstSlim3(query,target,cp,dpri) * * Descrip: This function allocates the EstSlim3 structure * and the basematrix area for explicit memory implementations * It calls /allocate_EstSlim3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EstSlim3 *] * */ EstSlim3 * allocate_Expl_EstSlim3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPRunImpl * dpri) { EstSlim3 * out; out = allocate_EstSlim3_only(query, target , cp); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+4)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+4)*3,(out->leni+1),2,out->lenj+4)) == NULL) { warn("Explicit matrix EstSlim3 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_EstSlim3(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_EstSlim3(out); return out; } /* Function: init_EstSlim3(mat) * * Descrip: This function initates EstSlim3 matrix when in explicit mode * Called in /allocate_Expl_EstSlim3 * * * Arg: mat [UNKN ] EstSlim3 which contains explicit basematrix memory [EstSlim3 *] * */ void init_EstSlim3(EstSlim3 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-4);j<5;j++) { EstSlim3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstSlim3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstSlim3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j= (-4);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { EstSlim3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstSlim3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstSlim3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } EstSlim3_EXPL_SPECIAL(mat,i,j,START) = 0; EstSlim3_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_EstSlim3(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EstSlim3 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * */ void recalculate_PackAln_EstSlim3(PackAln * pal,EstSlim3 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (START+3) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 1 && offj == 4 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (START+3) ) { pau->score = (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->seg[i]->transition[GW_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (START+3) ) { pau->score = mat->query->seg[i]->transition[GW_START2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+3) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define EstSlim3_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+4)][(i+1)*3+state]) #define EstSlim3_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+5)*8) % 40][(i+1)*3+state]) #define EstSlim3_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+4)]) #define EstSlim3_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+4)]) #define EstSlim3_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+5)*8)+(shadow+1)) % 40)][(i+1)*3 + state]) #define EstSlim3_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+4)]) #define EstSlim3_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+4)% 4) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define EstSlim3_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+4)% 4) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define EstSlim3_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+4)]) /* Function: allocate_Small_EstSlim3(query,target,cp) * * Descrip: This function allocates the EstSlim3 structure * and the basematrix area for a small memory implementations * It calls /allocate_EstSlim3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstSlim3 *] * */ #define EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+4)]) EstSlim3 * allocate_Small_EstSlim3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp) { EstSlim3 * out; out = allocate_EstSlim3_only(query, target , cp); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(40,(out->leni + 1) * 3,16,out->lenj+4); if(out == NULL) { warn("Small shadow matrix EstSlim3 cannot be allocated, (asking for 5 by %d main cells)",out->leni+2); free_EstSlim3(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_EstSlim3(mat,dpenv) * * Descrip: This function calculates an alignment for EstSlim3 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EstSlim3 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EstSlim3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_EstSlim3(EstSlim3 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for EstSlim3 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_EstSlim3(mat,dpenv); score = start_end_find_end_EstSlim3(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_EstSlim3(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_EstSlim3(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == EstSlim3_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_EstSlim3(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 3; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_EstSlim3(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_EstSlim3(mat) * * Descrip: This function calculates an alignment for EstSlim3 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EstSlim3 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EstSlim3 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EstSlim3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_EstSlim3(EstSlim3 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_EstSlim3(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_EstSlim3(mat); return out; } /* Function: AlnRangeSet_from_EstSlim3(mat) * * Descrip: This function reads off a start/end structure * for EstSlim3 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EstSlim3 * If you have not calculated the matrix use * /AlnRange_calculate_Small_EstSlim3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_EstSlim3(EstSlim3 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EstSlim3"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_EstSlim3(mat,&jpos); state = END; while( (temp = AlnRange_build_EstSlim3(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_EstSlim3(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_EstSlim3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_EstSlim3(EstSlim3 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EstSlim3"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_EstSlim3(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_EstSlim3 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = EstSlim3_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_EstSlim3(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == EstSlim3_READ_OFF_ERROR) { warn("In AlnRange_build_EstSlim3 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = EstSlim3_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_EstSlim3(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_EstSlim3(EstSlim3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_EstSlim3(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EstSlim3_READ_OFF_ERROR) { warn("In EstSlim3 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In EstSlim3 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In EstSlim3 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_EstSlim3(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_EstSlim3(EstSlim3 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstSlim3_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In EstSlim3 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = EstSlim3_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_HIDDEN_MATRIX(mat,i-1,j-4,MATCH); } return EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in EstSlim3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstSlim3_HIDDEN_MATRIX(mat,i - 0,j - 4,INSERT) ) { *reti = i - 0; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_HIDDEN_MATRIX(mat,i-0,j-4,INSERT); } return EstSlim3_HIDDEN_MATRIX(mat,i - 0,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstSlim3_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return EstSlim3_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlim3_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_HIDDEN_MATRIX(mat,i-0,j-3,DELETE); } return EstSlim3_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlim3_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return EstSlim3_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlim3_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return EstSlim3_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in EstSlim3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return EstSlim3_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in EstSlim3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstSlim3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_EstSlim3(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_EstSlim3(EstSlim3 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > EstSlim3_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_EstSlim3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EstSlim3_READ_OFF_ERROR) { warn("In special strip read EstSlim3, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < EstSlim3_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read EstSlim3, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_EstSlim3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_EstSlim3(EstSlim3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = EstSlim3_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for EstSlim3, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In EstSlim3 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = EstSlim3_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ default: warn("Major problem (!) - in EstSlim3 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_EstSlim3(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_EstSlim3(EstSlim3 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = EstSlim3_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In EstSlim3 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlim3_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_DC_SHADOW_SPECIAL(mat,i-1,j-3,START); } return EstSlim3_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstSlim3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstSlim3_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_DC_SHADOW_SPECIAL(mat,i-0,j-3,START); } return EstSlim3_DC_SHADOW_MATRIX(mat,i - 0,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstSlim3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == EstSlim3_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstSlim3_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return EstSlim3_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstSlim3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstSlim3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_EstSlim3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_EstSlim3(EstSlim3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_EstSlim3(mat,starti,startj,stopi,stopj); EstSlim3_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstSlim3_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; EstSlim3_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; EstSlim3_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = EstSlim3_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstSlim3_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstSlim3_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlim3_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlim3_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstSlim3_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlim3_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstSlim3_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstSlim3_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlim3_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlim3_HIDDEN_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstSlim3_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlim3_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstSlim3_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstSlim3_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstSlim3_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } } return; } /* Function: init_hidden_EstSlim3(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_EstSlim3(EstSlim3 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-4);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { EstSlim3_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; EstSlim3_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; EstSlim3_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; } } return; } /* Function: full_dc_EstSlim3(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_EstSlim3 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_EstSlim3 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [EstSlim3 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_EstSlim3(EstSlim3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_EstSlim3"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 20) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_EstSlim3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_EstSlim3(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_EstSlim3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for EstSlim3, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= EstSlim3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= EstSlim3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = EstSlim3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_EstSlim3(mat,EstSlim3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),EstSlim3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),EstSlim3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_EstSlim3(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_EstSlim3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_EstSlim3(EstSlim3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_EstSlim3(mat); EstSlim3_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_EstSlim3(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_EstSlim3(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_EstSlim3(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_EstSlim3(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_EstSlim3(EstSlim3 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<4;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstSlim3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); EstSlim3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); EstSlim3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( j - 3 <= mergej) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } } /* Add any movement independant score */ EstSlim3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( j - 3 <= mergej) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } } temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,k); } } /* Add any movement independant score */ EstSlim3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ EstSlim3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_EstSlim3(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_EstSlim3(EstSlim3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstSlim3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstSlim3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstSlim3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state MATCH to state MATCH */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstSlim3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state DELETE to state INSERT */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } /* From state INSERT to state INSERT */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstSlim3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstSlim3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstSlim3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_EstSlim3(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_EstSlim3(EstSlim3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstSlim3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstSlim3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstSlim3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstSlim3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstSlim3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstSlim3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstSlim3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_EstSlim3(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * */ } void init_dc_EstSlim3(EstSlim3 * mat) { register int i; register int j; register int k; for(j=0;j<6;j++) { for(i=(-1);iquery->len;i++) { EstSlim3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstSlim3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstSlim3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; for(k=0;k<7;k++) { EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); } } } return; } /* Function: start_end_find_end_EstSlim3(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [EstSlim3 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_EstSlim3(EstSlim3 * mat,int * endj) { register int j; register int max; register int maxj; max = EstSlim3_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( EstSlim3_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = EstSlim3_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_EstSlim3(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [EstSlim3] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_EstSlim3(EstSlim3 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (4 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (4 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state START to state MATCH */ temp = EstSlim3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state MATCH to state MATCH */ temp = EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlim3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstSlim3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state DELETE to state INSERT */ temp = EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0)); } /* From state START to state INSERT */ temp = EstSlim3_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INSERT to state INSERT */ temp = EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlim3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstSlim3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state START to state DELETE */ temp = EstSlim3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstSlim3_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlim3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstSlim3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstSlim3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstSlim3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = DELETE; } /* Finished calculating state DELETE */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_EstSlim3(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * */ void init_start_end_linear_EstSlim3(EstSlim3 * mat) { register int i; register int j; for(j=0;j<6;j++) { for(i=(-1);iquery->len;i++) { EstSlim3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); EstSlim3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); EstSlim3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; EstSlim3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); } } for(j=(-4);jtarget->seq->len;j++) { EstSlim3_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; EstSlim3_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; EstSlim3_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_EstSlim3(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_EstSlim3(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_EstSlim3(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","END" }; /* Function: AlnConvertSet_EstSlim3(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","END" }; AlnConvertSet * AlnConvertSet_EstSlim3(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; return out; } /* Function: PackAln_read_Expl_EstSlim3(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_EstSlim3(EstSlim3 * mat) { EstSlim3_access_func_holder holder; holder.access_main = EstSlim3_explicit_access_main; holder.access_special = EstSlim3_explicit_access_special; return PackAln_read_generic_EstSlim3(mat,holder); } /* Function: EstSlim3_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstSlim3_explicit_access_main(EstSlim3 * mat,int i,int j,int state) { return EstSlim3_EXPL_MATRIX(mat,i,j,state); } /* Function: EstSlim3_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstSlim3_explicit_access_special(EstSlim3 * mat,int i,int j,int state) { return EstSlim3_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_EstSlim3(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: h [UNKN ] Undocumented argument [EstSlim3_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_EstSlim3(EstSlim3 * mat,EstSlim3_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_EstSlim3(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in EstSlim3_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_EstSlim3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_EstSlim3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == EstSlim3_READ_OFF_ERROR || j == EstSlim3_READ_OFF_ERROR || state == EstSlim3_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in EstSlim3_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_EstSlim3(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [EstSlim3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_EstSlim3(EstSlim3 * mat,int * ri,int * rj,int * state,boolean * isspecial,EstSlim3_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: EstSlim3_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void EstSlim3_debug_show_matrix(EstSlim3 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",EstSlim3_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",EstSlim3_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",EstSlim3_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_EstSlim3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EstSlim3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_EstSlim3(EstSlim3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstSlim3_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstSlim3_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In EstSlim3 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH); } return (*h.access_main)(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START); } return (*h.access_main)(mat,i - 1,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in EstSlim3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,INSERT) ) { *reti = i - 0; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INSERT); } return (*h.access_main)(mat,i - 0,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,START); } return (*h.access_main)(mat,i - 0,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE); } return (*h.access_main)(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in EstSlim3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in EstSlim3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstSlim3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_EstSlim3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EstSlim3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_EstSlim3(EstSlim3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstSlim3_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstSlim3_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In EstSlim3 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in EstSlim3 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_EstSlim3(mat) * * Descrip: This function calculates the EstSlim3 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EstSlim3 * * * Arg: mat [UNKN ] EstSlim3 which contains explicit basematrix memory [EstSlim3 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_EstSlim3(EstSlim3 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EstSlim3, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("EstSlim3 Matrix calculation: "); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstSlim3_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstSlim3_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstSlim3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlim3_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlim3_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstSlim3_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlim3_EXPL_SPECIAL(mat,i,j,END) ) { EstSlim3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlim3_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstSlim3_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstSlim3_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstSlim3_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlim3_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlim3_EXPL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstSlim3_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlim3_EXPL_SPECIAL(mat,i,j,END) ) { EstSlim3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlim3_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstSlim3_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstSlim3_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstSlim3_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstSlim3_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlim3_EXPL_SPECIAL(mat,i,j,END) ) { EstSlim3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_EstSlim3(mat,dpenv) * * Descrip: This function calculates the EstSlim3 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EstSlim3 which contains explicit basematrix memory [EstSlim3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_EstSlim3(EstSlim3 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EstSlim3, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-4;jleni;i++) { EstSlim3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstSlim3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstSlim3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j=-4;jlenj;j++) { EstSlim3_EXPL_SPECIAL(mat,i,j,START) = 0; EstSlim3_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("EstSlim3 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { EstSlim3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstSlim3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstSlim3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = EstSlim3_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstSlim3_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstSlim3_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstSlim3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlim3_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstSlim3_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstSlim3_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstSlim3_EXPL_SPECIAL(mat,i,j,END) ) { EstSlim3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstSlim3_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstSlim3_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstSlim3_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = EstSlim3_EXPL_SPECIAL(mat,i-0,j-3,START) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlim3_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstSlim3_EXPL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstSlim3_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstSlim3_EXPL_SPECIAL(mat,i,j,END) ) { EstSlim3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstSlim3_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstSlim3_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstSlim3_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = EstSlim3_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstSlim3_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstSlim3_EXPL_SPECIAL(mat,i,j,END) ) { EstSlim3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: EstSlim3_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstSlim3 *] * */ EstSlim3 * EstSlim3_alloc(void) { EstSlim3 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EstSlim3 *) ckalloc (sizeof(EstSlim3))) == NULL) { warn("EstSlim3_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_EstSlim3(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstSlim3 *] * * Return [UNKN ] Undocumented return value [EstSlim3 *] * */ EstSlim3 * free_EstSlim3(EstSlim3 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EstSlim3 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->cp is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/estslim3.h0000644000175000001440000004421010670453713016046 0ustar philippusers#ifndef DYNAMITEestslim3HEADERFILE #define DYNAMITEestslim3HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "cdparser.h" #include "genewisemodel.h" #include "genewisemodeldb.h" struct Wise2_EstSlim3 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GeneWiseScore* query; ComplexSequence* target; cDNAParserScore * cp; } ; /* EstSlim3 defined */ #ifndef DYNAMITE_DEFINED_EstSlim3 typedef struct Wise2_EstSlim3 Wise2_EstSlim3; #define EstSlim3 Wise2_EstSlim3 #define DYNAMITE_DEFINED_EstSlim3 #endif #ifdef PTHREAD struct thread_pool_holder_EstSlim3 { GeneWiseScore* query; /* Query object placeholder */ GeneWiseDB* querydb;/* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ cDNADB* targetdb; /* Target database object */ boolean target_init; cDNAParserScore * cp; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_EstSlim3_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(EstSlim3*,int,int,int); int (*access_special)(EstSlim3*,int,int,int); } ; /* EstSlim3_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_EstSlim3_access_func_holder typedef struct Wise2_EstSlim3_access_func_holder Wise2_EstSlim3_access_func_holder; #define EstSlim3_access_func_holder Wise2_EstSlim3_access_func_holder #define DYNAMITE_DEFINED_EstSlim3_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_EstSlim3(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_EstSlim3(EstSlim3 * mat); #define PackAln_read_Shatter_EstSlim3 Wise2_PackAln_read_Shatter_EstSlim3 /* Function: calculate_shatter_EstSlim3(mat,dpenv) * * Descrip: This function calculates the EstSlim3 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EstSlim3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_EstSlim3(EstSlim3 * mat,DPEnvelope * dpenv); #define calculate_shatter_EstSlim3 Wise2_calculate_shatter_EstSlim3 /* Function: search_EstSlim3(dbsi,out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstSlim3 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_EstSlim3(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp); #define search_EstSlim3 Wise2_search_EstSlim3 /* Function: serial_search_EstSlim3(out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstSlim3 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_EstSlim3(Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp); #define serial_search_EstSlim3 Wise2_serial_search_EstSlim3 /* Function: PackAln_bestmemory_EstSlim3(query,target,cp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EstSlim3 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_EstSlim3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_EstSlim3 Wise2_PackAln_bestmemory_EstSlim3 /* Function: allocate_Expl_EstSlim3(query,target,cp,dpri) * * Descrip: This function allocates the EstSlim3 structure * and the basematrix area for explicit memory implementations * It calls /allocate_EstSlim3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EstSlim3 *] * */ EstSlim3 * Wise2_allocate_Expl_EstSlim3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPRunImpl * dpri); #define allocate_Expl_EstSlim3 Wise2_allocate_Expl_EstSlim3 /* Function: recalculate_PackAln_EstSlim3(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EstSlim3 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * */ void Wise2_recalculate_PackAln_EstSlim3(PackAln * pal,EstSlim3 * mat); #define recalculate_PackAln_EstSlim3 Wise2_recalculate_PackAln_EstSlim3 /* Function: allocate_Small_EstSlim3(query,target,cp) * * Descrip: This function allocates the EstSlim3 structure * and the basematrix area for a small memory implementations * It calls /allocate_EstSlim3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstSlim3 *] * */ EstSlim3 * Wise2_allocate_Small_EstSlim3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp); #define allocate_Small_EstSlim3 Wise2_allocate_Small_EstSlim3 /* Function: PackAln_calculate_Small_EstSlim3(mat,dpenv) * * Descrip: This function calculates an alignment for EstSlim3 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EstSlim3 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EstSlim3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_EstSlim3(EstSlim3 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_EstSlim3 Wise2_PackAln_calculate_Small_EstSlim3 /* Function: AlnRangeSet_calculate_Small_EstSlim3(mat) * * Descrip: This function calculates an alignment for EstSlim3 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EstSlim3 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EstSlim3 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EstSlim3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_EstSlim3(EstSlim3 * mat); #define AlnRangeSet_calculate_Small_EstSlim3 Wise2_AlnRangeSet_calculate_Small_EstSlim3 /* Function: AlnRangeSet_from_EstSlim3(mat) * * Descrip: This function reads off a start/end structure * for EstSlim3 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EstSlim3 * If you have not calculated the matrix use * /AlnRange_calculate_Small_EstSlim3 * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_EstSlim3(EstSlim3 * mat); #define AlnRangeSet_from_EstSlim3 Wise2_AlnRangeSet_from_EstSlim3 /* Function: convert_PackAln_to_AlnBlock_EstSlim3(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_EstSlim3(PackAln * pal); #define convert_PackAln_to_AlnBlock_EstSlim3 Wise2_convert_PackAln_to_AlnBlock_EstSlim3 /* Function: PackAln_read_Expl_EstSlim3(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_EstSlim3(EstSlim3 * mat); #define PackAln_read_Expl_EstSlim3 Wise2_PackAln_read_Expl_EstSlim3 /* Function: PackAln_read_generic_EstSlim3(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstSlim3 *] * Arg: h [UNKN ] Undocumented argument [EstSlim3_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_EstSlim3(EstSlim3 * mat,EstSlim3_access_func_holder h); #define PackAln_read_generic_EstSlim3 Wise2_PackAln_read_generic_EstSlim3 /* Function: calculate_EstSlim3(mat) * * Descrip: This function calculates the EstSlim3 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EstSlim3 * * * Arg: mat [UNKN ] EstSlim3 which contains explicit basematrix memory [EstSlim3 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_EstSlim3(EstSlim3 * mat); #define calculate_EstSlim3 Wise2_calculate_EstSlim3 /* Function: calculate_dpenv_EstSlim3(mat,dpenv) * * Descrip: This function calculates the EstSlim3 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EstSlim3 which contains explicit basematrix memory [EstSlim3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_EstSlim3(EstSlim3 * mat,DPEnvelope * dpenv); #define calculate_dpenv_EstSlim3 Wise2_calculate_dpenv_EstSlim3 /* Function: EstSlim3_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstSlim3 *] * */ EstSlim3 * Wise2_EstSlim3_alloc(void); #define EstSlim3_alloc Wise2_EstSlim3_alloc /* Function: free_EstSlim3(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstSlim3 *] * * Return [UNKN ] Undocumented return value [EstSlim3 *] * */ EstSlim3 * Wise2_free_EstSlim3(EstSlim3 * obj); #define free_EstSlim3 Wise2_free_EstSlim3 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_EstSlim3_shatter_access_main(EstSlim3 * mat,int i,int j,int state); #define EstSlim3_shatter_access_main Wise2_EstSlim3_shatter_access_main int Wise2_EstSlim3_shatter_access_special(EstSlim3 * mat,int i,int j,int state); #define EstSlim3_shatter_access_special Wise2_EstSlim3_shatter_access_special void * Wise2_thread_loop_EstSlim3(void * ptr); #define thread_loop_EstSlim3 Wise2_thread_loop_EstSlim3 int Wise2_score_only_EstSlim3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp); #define score_only_EstSlim3 Wise2_score_only_EstSlim3 EstSlim3 * Wise2_allocate_EstSlim3_only(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp); #define allocate_EstSlim3_only Wise2_allocate_EstSlim3_only void Wise2_init_EstSlim3(EstSlim3 * mat); #define init_EstSlim3 Wise2_init_EstSlim3 AlnRange * Wise2_AlnRange_build_EstSlim3(EstSlim3 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_EstSlim3 Wise2_AlnRange_build_EstSlim3 boolean Wise2_read_hidden_EstSlim3(EstSlim3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_EstSlim3 Wise2_read_hidden_EstSlim3 int Wise2_max_hidden_EstSlim3(EstSlim3 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_EstSlim3 Wise2_max_hidden_EstSlim3 boolean Wise2_read_special_strip_EstSlim3(EstSlim3 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_EstSlim3 Wise2_read_special_strip_EstSlim3 int Wise2_max_special_strip_EstSlim3(EstSlim3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_EstSlim3 Wise2_max_special_strip_EstSlim3 int Wise2_max_matrix_to_special_EstSlim3(EstSlim3 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_EstSlim3 Wise2_max_matrix_to_special_EstSlim3 void Wise2_calculate_hidden_EstSlim3(EstSlim3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_EstSlim3 Wise2_calculate_hidden_EstSlim3 void Wise2_init_hidden_EstSlim3(EstSlim3 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_EstSlim3 Wise2_init_hidden_EstSlim3 boolean Wise2_full_dc_EstSlim3(EstSlim3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_EstSlim3 Wise2_full_dc_EstSlim3 boolean Wise2_do_dc_single_pass_EstSlim3(EstSlim3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_EstSlim3 Wise2_do_dc_single_pass_EstSlim3 void Wise2_push_dc_at_merge_EstSlim3(EstSlim3 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_EstSlim3 Wise2_push_dc_at_merge_EstSlim3 void Wise2_follow_on_dc_EstSlim3(EstSlim3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_EstSlim3 Wise2_follow_on_dc_EstSlim3 void Wise2_run_up_dc_EstSlim3(EstSlim3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_EstSlim3 Wise2_run_up_dc_EstSlim3 void Wise2_init_dc_EstSlim3(EstSlim3 * mat); #define init_dc_EstSlim3 Wise2_init_dc_EstSlim3 int Wise2_start_end_find_end_EstSlim3(EstSlim3 * mat,int * endj); #define start_end_find_end_EstSlim3 Wise2_start_end_find_end_EstSlim3 boolean Wise2_dc_optimised_start_end_calc_EstSlim3(EstSlim3 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_EstSlim3 Wise2_dc_optimised_start_end_calc_EstSlim3 void Wise2_init_start_end_linear_EstSlim3(EstSlim3 * mat); #define init_start_end_linear_EstSlim3 Wise2_init_start_end_linear_EstSlim3 AlnConvertSet * Wise2_AlnConvertSet_EstSlim3(void); #define AlnConvertSet_EstSlim3 Wise2_AlnConvertSet_EstSlim3 int Wise2_EstSlim3_explicit_access_main(EstSlim3 * mat,int i,int j,int state); #define EstSlim3_explicit_access_main Wise2_EstSlim3_explicit_access_main int Wise2_EstSlim3_explicit_access_special(EstSlim3 * mat,int i,int j,int state); #define EstSlim3_explicit_access_special Wise2_EstSlim3_explicit_access_special int Wise2_find_end_EstSlim3(EstSlim3 * mat,int * ri,int * rj,int * state,boolean * isspecial,EstSlim3_access_func_holder h); #define find_end_EstSlim3 Wise2_find_end_EstSlim3 void Wise2_EstSlim3_debug_show_matrix(EstSlim3 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define EstSlim3_debug_show_matrix Wise2_EstSlim3_debug_show_matrix int Wise2_max_calc_EstSlim3(EstSlim3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstSlim3_access_func_holder h); #define max_calc_EstSlim3 Wise2_max_calc_EstSlim3 int Wise2_max_calc_special_EstSlim3(EstSlim3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstSlim3_access_func_holder h); #define max_calc_special_EstSlim3 Wise2_max_calc_special_EstSlim3 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/geneparameter.typemap0000644000175000001440000000042410670453714020352 0ustar philippusers TYPEMAP Wise2_GeneParameter21 * T_Wise2_GeneParameter21 INPUT T_Wise2_GeneParameter21 $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_GeneParameter21 *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_GeneParameter21 sv_setref_pv($arg, "Wise2::GeneParameter21", (void*) $var); wise-2.4.1/src/models/aligngenemodel.dy0000644000175000001440000006120507657732677017471 0ustar philippusers %{ #include "dyna.h" #include "pwmdna.h" #include "genestats.h" typedef struct align_gene_codon { char seq[3]; double weight; } AlignGeneCodon; %} struct NonCodingSimpleModel Probability identical Probability one_off Probability two_off struct SpliceSiteProb pwmDNA * pwm int offset struct AlignGeneColumnStore AlignGeneCodon * codon int len struct AlignGeneModel int len Probability * forward_coding Probability * reverse_coding Probability * splice5_forward Probability * splice3_forward Probability * splice5_reverse Probability * splice3_reverse SeqAlign * align Sequence * anchor double * change_rate struct AlignGeneModelScore int len Score * forward_coding Score * reverse_coding Score * splice5_forward Score * splice3_forward Score * splice5_reverse Score * splice3_reverse SeqAlign * align Sequence * anchor struct AlignGeneModelParam CompProb * protein RandomModel * rm CodonMapper * cm CodonTable * ct DnaProbMatrix * dm SpliceSiteProb * ss5 SpliceSiteProb * ss3 GeneStats * gs Probability total_weight !def="2" boolean tolerate_nonanchor_stops !def="TRUE" Probability nonanchor_stop !def=0.00001; NonCodingSimpleModel * ncsm double coding_window_thres !def=2.0 double noncoding_window_thres !def=2.0 double coding_window_bonus !def=4.0 double noncoding_window_pen !def=0.1 %{ #include "aligngenemodel.h" Probability weighted_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp) { int aa; int seq_no; Probability out; Probability aa_prob; int codon; out = 0.0; for(aa=0;aa<26;aa++) { if( agmp->rm->aminoacid[aa] < 0.0000000001 ) { continue; } aa_prob = agmp->rm->aminoacid[aa]; for(seq_no=0;seq_nolen;seq_no++) { if( !isalpha(store->codon[seq_no].seq[0]) || !isalpha(store->codon[seq_no].seq[1]) || !isalpha(store->codon[seq_no].seq[2]) ) { return 0.5; } codon = codon_from_seq(store->codon[seq_no].seq); if( is_stop_codon(codon,agmp->ct) ) { if( seq_no > 0 && agmp->tolerate_nonanchor_stops ) { return agmp->nonanchor_stop; } else { return 0.0; } } aa_prob *= agmp->protein->comp[aa][aminoacid_from_codon(agmp->ct,codon)-'A'] * store->codon[seq_no].weight; } out += aa_prob; } return out; } void window_AlignGeneModel(SeqAlign * sal,AlignGeneModel * agm,AlignGeneModelParam * agmp) { int i; int j; int k; int count; int win_count; double average_change; int change; double * change_array; change_array = calloc(agm->len,sizeof(double)); fprintf(stderr,"Got Window at %f and non window at %f\n",agmp->coding_window_bonus,agmp->noncoding_window_pen); for(i=1;ilen;i++) { average_change = 0.0; count = 0; for(j=0;jseq[0]->len-32;j++) { change = 0; win_count = 0; for(k = 0;k<31;k++) { if( sal->seq[0]->seq[j+k] != sal->seq[i]->seq[j+k] && sal->seq[i]->seq[j+k] != '~') { change++; } if( sal->seq[i]->seq[j+k] != '~' ) { win_count++; } } if( win_count == 0 ) { change_array[j+15] = 0.9; continue; } change_array[j+15] = ((double) change) / win_count; average_change += change_array[j+15]; count++; /* fprintf(stdout,"Got %f, running average %f\n",change_array[j+15],average_change/(double)count);*/ } average_change = average_change / (double) count; fprintf(stdout,"For %s, Average change is %f\n",sal->seq[i]->name,average_change); for(j=15;jseq[0]->len-16;j++) { if( change_array[j] < (average_change/agmp->coding_window_thres) ) { /* fprintf(stdout,"At position %d in %s giving coding bonus\n",j,sal->seq[i]->name);*/ agm->forward_coding[j] *= agmp->coding_window_bonus; agm->reverse_coding[j] *= agmp->coding_window_bonus; } if( change_array[j] > (average_change * agmp->noncoding_window_thres) ) { /* fprintf(stdout,"At position %d in %s giving penalty\n",j,sal->seq[i]->name);*/ agm->forward_coding[j] *= agmp->noncoding_window_pen; agm->reverse_coding[j] *= agmp->noncoding_window_pen; } } } free(change_array); return; } NonCodingSimpleModel * create_NonCodingSimpleModel(Probability change) { NonCodingSimpleModel * out; out = NonCodingSimpleModel_alloc(); out->one_off = change * (1.0-change) * (1.0-change) * 3; out->two_off = change * change * (1.0-change) * 3; out->identical = 1.0 - (out->one_off + out->two_off); return out; } Probability simple_non_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp) { int i; int j; int k; Probability out = 1.0; Probability col = 0.0; Probability c = 0.0; for(k=0;k<3;k++) { col = 0.0; for(j=0;j<4;j++) { c= 0.25; for(i=0;ilen;i++) { if( store->codon[i].seq[2-k] == '-' || store->codon[i].seq[2-k] == '~') { return 0.5; } c *= agmp->dm->prob[j][base_from_char(store->codon[i].seq[2-k])]; } col += c; } out *= col; } return out; } Probability weighted_non_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp) { int i; int j; int k; Probability out = 1.0; Probability col = 0.0; Probability c = 0.0; for(k=0;k<3;k++) { col = 0.0; for(j=0;j<4;j++) { c= 0.25; for(i=0;ilen;i++) { if( store->codon[i].seq[2-k] == '-' || store->codon[i].seq[2-k] == '~') { return 0.5; } c *= agmp->dm->prob[j][base_from_char(store->codon[i].seq[2-k])]; } col += c; } out *= col; } return out; } Probability weighted_simple_non_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp) { int i; int j; int k; Probability out = 1.0; Probability col = 0.0; Probability c = 0.0; for(k=0;k<3;k++) { col = 0.0; for(j=0;j<4;j++) { c= 0.25; for(i=0;ilen;i++) { if( store->codon[i].seq[2-k] == '-' ) { return 0.5; } c *= agmp->dm->prob[j][base_from_char(store->codon[i].seq[2-k])]; } col += c; } out *= col; } return out; } Probability simple_coding_AlignGeneColumn(AlignGeneColumnStore * store,AlignGeneModelParam * agmp) { int i; int j; int codon; Probability out = 0.0; Probability c = 0.0; Probability f; assert(store); assert(agmp); for(j=0;j<26;j++) { if( agmp->rm->aminoacid[j] < 0.0000000001 ) { continue; } c = agmp->rm->aminoacid[j]; for(i=0;ilen;i++) { if( !isalpha(store->codon[i].seq[0]) || !isalpha(store->codon[i].seq[1]) || !isalpha(store->codon[i].seq[2]) ) { return 0.0; } codon = codon_from_seq(store->codon[i].seq); if( is_stop_codon(codon,agmp->ct) ) { return 0.0; } f = agmp->protein->comp[j][aminoacid_from_codon(agmp->ct,codon)-'A']; /* fprintf(stdout,"For amino acid %c, match %.4f cum %.4f\n",j+'A', agmp->protein->comp[j][aminoacid_from_codon(agmp->ct,codon)-'A'], c); */ /* c = c*f;*/ c = c*f; /* fprintf(stdout,"Refactoring by %f\n",store->codon[i].weight); */ /* c = c*100; */ } out += c; } /* fprintf(stdout,"final %.4f\n",out);*/ return out; } boolean fill_reverse_AlignGeneColumn(AlignGeneColumnStore * store,SeqAlign * sa,int forward_codon_end) { int i; assert(store); assert(sa); assert(store->len == sa->len); assert(forward_codon_end >= 0 && forward_codon_end < sa->seq[0]->len); for(i=0;ilen;i++) { store->codon[i].seq[0] = char_complement_base(sa->seq[i]->seq[forward_codon_end]); store->codon[i].seq[1] = char_complement_base(sa->seq[i]->seq[forward_codon_end-1]); store->codon[i].seq[2] = char_complement_base(sa->seq[i]->seq[forward_codon_end-2]); store->codon[i].weight = sa->seq[i]->weight; } return TRUE; } boolean fill_forward_AlignGeneColumn(AlignGeneColumnStore * store,SeqAlign * sa,int codon_end) { int i; assert(store); assert(sa); assert(store->len == sa->len); assert(codon_end >= 0 && codon_end < sa->seq[0]->len); for(i=0;ilen;i++) { store->codon[i].seq[0] = sa->seq[i]->seq[codon_end-2]; store->codon[i].seq[1] = sa->seq[i]->seq[codon_end-1]; store->codon[i].seq[2] = sa->seq[i]->seq[codon_end]; store->codon[i].weight = sa->seq[i]->weight; } return TRUE; } AlignGeneColumnStore * new_empty_AlignGeneColumnStore(int len) { AlignGeneColumnStore * out; out = AlignGeneColumnStore_alloc(); out->codon = calloc(len,sizeof(AlignGeneCodon)); out->len = len; return out; } AlignGeneCodon * free_AlignGeneCodon(AlignGeneCodon * c) { ckfree(c); return NULL; } AlignGeneModel * new_AlignGeneModel(int len) { AlignGeneModel * out; out = AlignGeneModel_alloc(); out->len = len; out->forward_coding = calloc(len,sizeof(Probability)); out->reverse_coding = calloc(len,sizeof(Probability)); out->splice5_forward = calloc(len,sizeof(Probability)); out->splice3_forward = calloc(len,sizeof(Probability)); out->splice5_reverse = calloc(len,sizeof(Probability)); out->splice3_reverse = calloc(len,sizeof(Probability)); out->change_rate = calloc(len,sizeof(double)); out->align = NULL; out->anchor = NULL; return out; } void show_AlignGeneModel(AlignGeneModel * agm,SeqAlign * sal,CodonTable * ct,GenomicRegion * gr,FILE * ofp,AlignGeneModelParam * agmp) { int i; int j; int * should_show; int ex_len; int k; AlignGeneColumnStore * store; int tr_len; int phase_score[3]; int total_phase_0 = 0; int phase; int * phase_array; int pos; int count = 0; fprintf(stderr,"Gene model at %d with %d\n",gr,gr->len); should_show = calloc(agm->len,sizeof(int)); phase_array = calloc(agm->len,sizeof(int)); fprintf(stderr,"Gene model at %d with %d\n",gr,gr->len); if( gr != NULL ) { if( gr->len == 0 ) { warn("genomic region given, but no genes on region!"); } for(i=0;ilen;i++) should_show[i] = 0; } else { for(i=0;ilen;i++) should_show[i] = 1; } if( gr != NULL ) { for( i=0;ilen;i++) { tr_len = 3; for( j=0;jgene[i]->transcript[0]->ex_len; j++) { ex_len = gr->gene[i]->transcript[0]->exon[j]->end - gr->gene[i]->transcript[0]->exon[j]->start; phase_score[0] = 0; phase_score[1] = 0; phase_score[2] = 0; /* deal with splice sites etc */ pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start-4; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start-3; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start-2; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start-1; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start+ex_len+1; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start+ex_len; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start+ex_len+2; should_show[pos] = 1; pos = gr->gene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start+ex_len+3; should_show[pos] = 1; for(k=0;kgene[i]->start+gr->gene[i]->transcript[0]->exon[j]->start+k; phase_score[phase] += Probability2Score(agm->forward_coding[pos]); phase_array[pos] = phase_score[phase]; /* printf("%d Adding %d in to %d with %f\n",phase,Probability2Score(agm->forward_coding[pos]),phase_score[phase],Score2Bits(phase_score[phase])); */ if( phase == 0 ) { total_phase_0 += Probability2Score(agm->forward_coding[i]); should_show[pos] = 2; } else { should_show[pos] = 1; } tr_len++; } } } } store = new_empty_AlignGeneColumnStore(sal->len); for(i=0;ilen;i++) { if( should_show[i] == 0 ) { continue; } if( i > 0 && should_show[i-1] == 0 ) { /* just had a discontinuity */ fprintf(ofp,"\n ---\n"); } fill_forward_AlignGeneColumn(store,sal,i); fprintf(ofp,"%c %4d %2.4f Bits: %2.4f [%1.6f vs %1.6f cum % 8.1f] %2.4f %2.4f | %2.4f %2.4f %2.4f ", should_show[i] == 2 ? '*' : '-', i, agm->forward_coding[i], Score2Bits(Probability2Score(agm->forward_coding[i])), weighted_coding_AlignGeneColumn(store,agmp), weighted_non_coding_AlignGeneColumn(store,agmp), gr == NULL ? 0.0 : Score2Bits(phase_array[i]), agm->splice5_forward[i], agm->splice3_forward[i], agm->reverse_coding[i],agm->splice5_reverse[i], agm->splice3_reverse[i] ); for(j=0;jlen;j++) { fprintf(ofp,"%c",sal->seq[j]->seq[i]); } fprintf(ofp,"|"); for(j=0;jlen;j++) { fprintf(ofp,"%c",char_complement_base(sal->seq[j]->seq[i])); } fprintf(ofp," "); if( i > 3 ) { for(j=0;jlen;j++) { if( sal->seq[j]->seq[i-2] == '~' || sal->seq[j]->seq[i-2] == '-' || sal->seq[j]->seq[i-1] == '~' || sal->seq[j]->seq[i-1] == '-' || sal->seq[j]->seq[i] == '~' || sal->seq[j]->seq[i] == '-' ) { fprintf(ofp,"?"); } else { if( sal->seq[0]->seq[i-2] != sal->seq[1]->seq[i-2] || sal->seq[0]->seq[i-1] != sal->seq[1]->seq[i-1] || sal->seq[0]->seq[i] != sal->seq[1]->seq[i]) { fprintf(ofp,"%c",aminoacid_from_seq(ct,sal->seq[j]->seq+i-2)); } else { fprintf(ofp,"%c",tolower(aminoacid_from_seq(ct,sal->seq[j]->seq+i-2))); } } } if( agm->forward_coding[i] > 15.0 ) { fprintf(ofp,"*"); } } fprintf(ofp,"\n"); } } AlignGeneModel * create_AlignGeneModel(SeqAlign * sal,AlignGeneModelParam * agmp) { AlignGeneModel * out; int i; int j; Probability ss5p; Probability ss3p; AlignGeneColumnStore * store; Sequence * rev; assert(agmp); assert(agmp->ct); assert(agmp->protein); assert(agmp->dm); out = new_AlignGeneModel(sal->seq[0]->len); reweight_SeqAlign(sal); for(i=0;ilen;i++) { fprintf(stdout,"%s weight %f\n",sal->seq[i]->name,sal->seq[i]->weight); } store = new_empty_AlignGeneColumnStore(sal->len); for(i=0;iseq[0]->len;i++) { if( i > 2 ) { fill_forward_AlignGeneColumn(store,sal,i); /* fprintf(stdout,"%d %f vs %f [%f] | %f vs %f %c%c%c %c%c%c\n",i, simple_coding_AlignGeneColumn(store,agmp), weighted_coding_AlignGeneColumn(store,agmp), simple_coding_AlignGeneColumn(store,agmp)/weighted_coding_AlignGeneColumn(store,agmp), simple_non_coding_AlignGeneColumn(store,agmp), non_coding_probability_AlignGeneModel(sal,i,agmp), store->codon[0].seq[0], store->codon[0].seq[1], store->codon[0].seq[2], store->codon[1].seq[0], store->codon[1].seq[1], store->codon[1].seq[2]); */ out->forward_coding[i] = weighted_coding_AlignGeneColumn(store,agmp)*agmp->total_weight/ (weighted_non_coding_AlignGeneColumn(store,agmp)); } ss5p = 1.0; ss3p = 1.0; for(j=0;j<1;j++) { if( sal->seq[j]->seq[i] == 'G' && sal->seq[j]->seq[i+1] == 'T' && i < sal->seq[j]->len-2) ss5p *= prob_SpliceSiteProb(agmp->ss5,sal->seq[j],i); else ss5p = 0.00000001; if( sal->seq[j]->seq[i] == 'G' && sal->seq[j]->seq[i-1] == 'A' && i > 2 ) ss3p *= prob_SpliceSiteProb(agmp->ss3,sal->seq[j],i); else ss3p = 0.000000001; } if( ss5p > 4 ) { ss5p = 4.0; } if( ss3p > 4 ) { ss3p = 4.0; } out->splice5_forward[i] = ss5p; out->splice3_forward[i] = ss3p; } rev = reverse_complement_Sequence(sal->seq[0]); for(i=0;iseq[0]->len;i++) { if( i > 2 ) { fill_reverse_AlignGeneColumn(store,sal,i); out->reverse_coding[i] = weighted_coding_AlignGeneColumn(store,agmp)*agmp->total_weight/ (weighted_non_coding_AlignGeneColumn(store,agmp)); } if( rev->seq[rev->len-i] == 'G' && rev->seq[rev->len-i-1] == 'T' && i > 2) out->splice5_reverse[i] = prob_SpliceSiteProb(agmp->ss5,rev,rev->len-i); else out->splice5_reverse[i] = 0.00000001; if( rev->seq[rev->len-i] == 'G' && rev->seq[rev->len-i+1] == 'A' && i < rev->len -2) out->splice3_reverse[i] = prob_SpliceSiteProb(agmp->ss3,rev,rev->len-i); else out->splice3_reverse[i] = 0.00000001; if( out->splice5_reverse[i] > 4 ) { out->splice5_reverse[i] = 4.0; } if( out->splice3_reverse[i] > 4 ) { out->splice3_reverse[i] = 4.0; } /* out->splice5_reverse[i] = 1.0; out->splice3_reverse[i] = 1.0; */ } free_AlignGeneColumnStore(store); free_Sequence(rev); window_AlignGeneModel(sal,out,agmp); out->align = hard_link_SeqAlign(sal); out->anchor = hard_link_Sequence(sal->seq[0]); return out; } Probability prob_SpliceSiteProb(SpliceSiteProb * ssp,Sequence * seq,int pos) { assert(ssp); assert(seq); if( pos<= ssp->offset ) { return 0.0; } return prob_pwmDNA_string(ssp->pwm,seq->seq-ssp->offset+1+pos); } Probability non_coding_probability_AlignGeneModel(SeqAlign * sal,int codon_end_pos,AlignGeneModelParam * agmp) { int i; int j; int k; Probability out = 1.0; Probability col = 0.0; Probability c = 0.0; for(k=0;k<3;k++) { for(j=0;j<4;j++) { c= 0.25; for(i=0;ilen;i++) { if( sal->seq[i]->seq[codon_end_pos-k] == '-' ) { return 0.5; } c *= agmp->dm->prob[j][base_from_char(sal->seq[i]->seq[codon_end_pos-k])]; } col += c; } out *= col; } return out; } Probability coding_probability_AlignGeneModel(SeqAlign * sal,int codon_end_pos,AlignGeneModelParam * agmp) { int i; int j; int codon; Probability out = 0.0; Probability c = 0.0; Probability f; assert(sal); assert(agmp); assert(agmp->rm); assert(agmp->protein); /* fprintf(stdout,"Testing %c%c%c [%c] vs %c%c%c [%c]\n", sal->seq[0]->seq[codon_end_pos-2], sal->seq[0]->seq[codon_end_pos-1], sal->seq[0]->seq[codon_end_pos], aminoacid_from_codon(agmp->ct,codon_from_seq(sal->seq[0]->seq+codon_end_pos-2)), sal->seq[1]->seq[codon_end_pos-2], sal->seq[1]->seq[codon_end_pos-1], sal->seq[1]->seq[codon_end_pos], aminoacid_from_codon(agmp->ct,codon_from_seq(sal->seq[1]->seq+codon_end_pos-2)) ); */ for(j=0;j<26;j++) { if( agmp->rm->aminoacid[j] < 0.0000000001 ) { continue; } c = agmp->rm->aminoacid[j]; for(i=0;ilen;i++) { if( !isalpha(sal->seq[i]->seq[codon_end_pos-2]) || !isalpha(sal->seq[i]->seq[codon_end_pos-1]) || !isalpha(sal->seq[i]->seq[codon_end_pos]) ) { return 0.0; } codon = codon_from_seq(sal->seq[i]->seq+codon_end_pos-2); if( is_stop_codon(codon,agmp->ct) ) { return 0.0; } f = agmp->protein->comp[j][aminoacid_from_codon(agmp->ct,codon)-'A']; /* fprintf(stdout,"For amino acid %c, match %.4f cum %.4f\n",j+'A', agmp->protein->comp[j][aminoacid_from_codon(agmp->ct,codon)-'A'], c); */ c = c*f; } out += c; } /* fprintf(stdout,"final %.4f\n",out);*/ return out; } AlignGeneModelParam * new_AlignGeneModelParam_from_argv(int * argc,char ** argv) { AlignGeneModelParam * out; CompProb * cp; DnaProbMatrix * dm; GeneModelParam * gmp; GeneStats * gs; char * temp; double temp_prob; out = AlignGeneModelParam_alloc(); if( (temp = strip_out_assigned_argument(argc,argv,"am_codon")) == NULL ) { temp = "codon.table"; } out->ct = read_CodonTable_file(temp); assert(out->ct); if( (temp = strip_out_assigned_argument(argc,argv,"am_protein")) == NULL ) { temp = "wag85"; } out->protein = read_Blast_file_CompProb(temp); assert(out->protein); temp_prob = 0.85; strip_out_float_argument(argc,argv,"am_dna",&temp_prob); out->dm = DnaProbMatrix_from_match(0.85,NMaskType_VARIABLE); gmp = new_GeneModelParam_from_argv(argc,argv); if((gs=GeneStats_from_GeneModelParam(gmp)) == NULL ) { fatal("Could not build gene stats"); } out->gs = gs; out->rm = default_RandomModel(); out->ss5 = SpliceSiteProb_alloc(); out->ss5->pwm = pwmDNA_from_SeqAlign(gs->splice5,1); out->ss5->offset = gs->splice5_offset; fold_randommodel_pwmDNA(out->ss5->pwm,gs->rnd); out->ss3 = SpliceSiteProb_alloc(); out->ss3->pwm = pwmDNA_from_SeqAlign(gs->splice3,1); out->ss3->offset = gs->splice3_offset; fold_randommodel_pwmDNA(out->ss3->pwm,gs->rnd); out->nonanchor_stop = 0.001; strip_out_float_argument(argc,argv,"am_nonanchor_stop_pen",&out->nonanchor_stop); out->tolerate_nonanchor_stops = 1; strip_out_boolean_def_argument(argc,argv,"am_nonanchor_stop",&out->tolerate_nonanchor_stops); out->coding_window_thres = 3.0; strip_out_float_argument(argc,argv,"am_coding_bonus_thres",&out->coding_window_thres); out->noncoding_window_thres = 2.0; strip_out_float_argument(argc,argv,"am_noncoding_bonus_thres",&out->noncoding_window_thres); out->coding_window_bonus = 4.0; strip_out_float_argument(argc,argv,"am_coding_bonus_factor",&out->coding_window_bonus); out->noncoding_window_pen = 0.25; strip_out_float_argument(argc,argv,"am_noncoding_bonus_factor",&out->noncoding_window_pen); out->total_weight = 0.5; strip_out_float_argument(argc,argv,"am_overall_coding",&out->total_weight); return out; } void show_help_AlignGeneModelParam(FILE * ofp) { fprintf(ofp,"Align Gene Model Parameters\n"); fprintf(ofp," -am_codon [codon.table] codon table\n"); fprintf(ofp," -am_protein [wag85] protein comparison probabilities\n"); fprintf(ofp," -am_dna [0.85] DNA non coding model match probability\n"); fprintf(ofp," -[no]am_nonanchor_stop allow stops in non anchor sequences [true]\n"); fprintf(ofp," -am_nonanchor_stop_pen penalty for non anchor stops when allowed [0.001]\n"); fprintf(ofp," -am_coding_bonus_thres coding threshold to use conservation window [3.0]\n"); fprintf(ofp," -am_noncoding_bonus_thres nonc threshold to use conservation window [2.0]\n"); fprintf(ofp," -am_coding_bonus_factor coding bonus factor when windowed [4.0]\n"); fprintf(ofp," -am_noncoding_bonus_factor nonc bonus factor when windowed [0.25]\n"); fprintf(ofp," -am_overall_coding overall per column \"odds-prior\" for coding [0.5]\n"); fprintf(ofp,"Gene Model statistics used by AlignModel\n"); show_help_GeneModelParam(ofp); return; } AlignGeneModelParam * std_AlignGeneModelParam(CompProb * cp,DnaProbMatrix * dm,CodonTable * ct,GeneStats * gs,Probability change) { AlignGeneModelParam * out; out = AlignGeneModelParam_alloc(); assert(cp); assert(dm); assert(ct); assert(gs); assert(gs->splice5); assert(gs->splice5->len > 1); assert(gs->splice5->seq[0]->len > 0); assert(gs->splice3); assert(gs->splice3->len > 1); assert(gs->splice3->seq[0]->len > 0); out->ncsm = create_NonCodingSimpleModel(change); out->protein = hard_link_CompProb(cp); out->rm = default_RandomModel(); out->ct = hard_link_CodonTable(ct); out->dm = hard_link_DnaProbMatrix(dm); out->ss5 = SpliceSiteProb_alloc(); out->ss5->pwm = pwmDNA_from_SeqAlign(gs->splice5,1); out->ss5->offset = gs->splice5_offset; fold_randommodel_pwmDNA(out->ss5->pwm,gs->rnd); /* show_pwmDNA_col(out->ss5->pwm,stdout); fprintf(stdout,"\n"); */ out->ss3 = SpliceSiteProb_alloc(); out->ss3->pwm = pwmDNA_from_SeqAlign(gs->splice3,1); out->ss3->offset = gs->splice3_offset; fold_randommodel_pwmDNA(out->ss3->pwm,gs->rnd); /* show_pwmDNA_col(out->ss3->pwm,stdout); fprintf(stdout,"\n"); */ out->nonanchor_stop = 0.001; out->coding_window_thres = 3.0; out->noncoding_window_thres = 2.0; out->coding_window_bonus = 4.0; out->noncoding_window_pen = 0.25; out->tolerate_nonanchor_stops = 1; out->total_weight = 0.5; return out; } AlignGeneModelScore * AlignGeneModelScore_from_AlignGeneModel(AlignGeneModel * agm) { AlignGeneModelScore * out; out = AlignGeneModelScore_alloc(); out->len = agm->len; out->forward_coding = calloc(agm->len,sizeof(Score)); out->reverse_coding = calloc(agm->len,sizeof(Score)); out->splice5_forward = calloc(agm->len,sizeof(Score)); out->splice3_forward = calloc(agm->len,sizeof(Score)); out->splice5_reverse = calloc(agm->len,sizeof(Score)); out->splice3_reverse = calloc(agm->len,sizeof(Score)); Probability2Score_move(agm->forward_coding,out->forward_coding,agm->len); Probability2Score_move(agm->reverse_coding,out->reverse_coding,agm->len); Probability2Score_move(agm->splice5_forward,out->splice5_forward,agm->len); Probability2Score_move(agm->splice3_forward,out->splice3_forward,agm->len); Probability2Score_move(agm->splice5_reverse,out->splice5_reverse,agm->len); Probability2Score_move(agm->splice3_reverse,out->splice3_reverse,agm->len); out->align = hard_link_SeqAlign(agm->align); out->anchor = hard_link_Sequence(agm->anchor); return out; } Probability * free_Probability(Probability * p) { ckfree(p); return NULL; } Score * free_Score(Score * p) { ckfree(p); return NULL; } wise-2.4.1/src/models/testdna.c0000644000175000001440000000075507313404550015741 0ustar philippusers#include "dnaalign.h" #include "seqaligndisplay.h" main(int argc,char ** argv) { Sequence * one; Sequence * two; DnaMatrix * mat; DnaStartEnd * dse; AlnBlock * alb; one = read_fasta_file_Sequence(argv[1]); two = read_fasta_file_Sequence(argv[2]); mat = identity_DnaMatrix(4,-1); dse = DnaStartEnd_from_policy("local"); alb = make_align_dnaalign(one,two,mat,dse,-5,-1,-5,-1); dump_ascii_AlnBlock(alb,stdout); write_pretty_seq_align(alb,one,two,12,60,stdout); } wise-2.4.1/src/models/est_evidence.c0000644000175000001440000006201110670453713016732 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "est_evidence.h" # line 33 "est_evidence.dy" int indicate_intron_used(GenomeEvidenceSet * set,AlnBlock * alb) { AlnColumn * alc; int i; int j; int has_used = 0; for(alc=alb->start;alc!=NULL;alc=alc->next ) { if( strstartcmp(alc->alu[1]->text_label,"5SS") == 0 ) { for(i=0;ilen;i++) { auto EstEvidence * evi; evi = (EstEvidence*) set->geu[i]->data; for(j=0;jlen;j++) { if( abs(evi->exon[i]->end - alc->alu[1]->start) < 4 ) { /* this is used */ if( evi->exon[i]->used != 1 ) { evi->exon[i]->used = 1; has_used = 1; } } } } } } return has_used; } # line 62 "est_evidence.dy" GenomeEvidenceSet * read_est_evidence(FILE * ifp,CodonTable * ct) { char buffer[MAXLINE]; GenomeEvidenceUnit * geu; EstEvidence * evi; EstExon * exon; GenomeEvidenceSet * ges; EstIndel * indel; assert(ct); assert(ifp); ges = GenomeEvidenceSet_alloc_std(); evi = EstEvidence_alloc_std(); evi->ct = hard_link_CodonTable(ct); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '#' ) { continue; } if( strstartcmp(buffer,"//") == 0 ) { geu = new_est_GenomeEvidenceUnit(evi); add_GenomeEvidenceSet(ges,geu); evi = EstEvidence_alloc_std(); evi->ct = hard_link_CodonTable(ct); continue; } if( strstartcmp(buffer,"exon") == 0 ) { exon = EstExon_alloc(); exon->intron_3_score = 0; if( sscanf(buffer,"exon %d %d %d",&exon->start,&exon->end,&exon->intron_3_score) < 2 ) { fatal("Unable to read exon line as evidence [%s]"); } exon->start--; exon->end--; add_EstEvidence(evi,exon); } else if( strstartcmp(buffer,"cds") == 0 ) { exon = EstExon_alloc(); sscanf(buffer,"cds %d %d %d",&exon->start,&exon->end,&exon->phase); exon->start--; exon->end--; if( exon->phase > 2 || exon->phase < 0 ) { fprintf(stderr,"Exon has a non clear phase - %d\n",exon->phase); return NULL; } exon->is_coding = TRUE; add_EstEvidence(evi,exon); } else if ( strstartcmp(buffer,"indel") == 0 ) { indel = EstIndel_alloc(); sscanf(buffer,"indel %d %d",&indel->start,&indel->end); indel->start--; indel->end--; add_indel_EstEvidence(evi,indel); } else { fprintf(stderr,"Unable to read as est evidence - %s",buffer); } } if( evi->len > 0 ) { geu = new_est_GenomeEvidenceUnit(evi); add_GenomeEvidenceSet(ges,geu); } return ges; } # line 128 "est_evidence.dy" GenomeEvidenceUnit * new_est_GenomeEvidenceUnit(EstEvidence * evi) { GenomeEvidenceUnit * in; in = GenomeEvidenceUnit_alloc(); in->cds_3SS = est_cds_3SS; in->cds_5SS = est_cds_5SS; in->utr_3SS = est_3ss; in->utr_5SS = est_5ss; in->cds_pot = est_cds_pot; in->utr_pot = est_utr_pot; in->cds_intron_pot = est_intron_pot; in->utr_intron_pot = est_intron_pot; in->geu_free = free_EstEvidence; in->frameshift_cds = est_cds_frameshift; in->stop_pot = est_stop_pot; in->start_pot = est_start_pot; in->utr3_end = est_utr3_end; in->utr5_start = est_utr5_start; in->data = (void*) evi; return in; } # line 154 "est_evidence.dy" int est_utr5_start(void * data,ComplexSequence *seq,int jposition) { EstEvidence * est; est = (EstEvidence *)data; if( est->exon[0]->start == jposition ) { return 0; } else { return -80000; } } # line 167 "est_evidence.dy" int est_utr3_end(void * data,ComplexSequence *seq,int jposition) { EstEvidence * est; est = (EstEvidence *)data; if( est->exon[est->len-1]->end == jposition ) { return 0; } else { return -80000; } } # line 180 "est_evidence.dy" int est_start_pot(void * data,ComplexSequence *seq,int jposition) { EstEvidence * est; int i; int codon; int atg = (BASE_A*25+BASE_T*5+BASE_G); est = (EstEvidence *)data; codon = CSEQ_GENOMIC_CODON(seq,jposition); if( is_stop_codon(codon,est->ct) ) { return -10000; } else if( codon == atg ) { return 1200; } else { return 0; } } # line 200 "est_evidence.dy" int est_stop_pot(void * data,ComplexSequence *seq,int jposition) { EstEvidence * est; int i; est = (EstEvidence *)data; if( is_stop_codon(CSEQ_GENOMIC_CODON(seq,jposition),est->ct) ) { return 100; } else { return -1000; } } # line 214 "est_evidence.dy" int est_cds_frameshift(void * data,ComplexSequence * seq,int jposition,int jump) { EstEvidence * est; int i; est = (EstEvidence *)data; for(i=1;iindel_len;i++) { if( jposition >= est->indel[i]->start && jposition <= est->indel[i]->end ) { return 0; } } return -10000; } # line 231 "est_evidence.dy" int est_cds_3SS(void * data,ComplexSequence *seq,int jposition,int phase) { switch(phase) { case 0 : return est_3ss(data,seq,jposition); case 1 : return est_3ss(data,seq,jposition); case 2 : return est_3ss(data,seq,jposition); default : return -100000; } } # line 241 "est_evidence.dy" int est_cds_5SS(void * data,ComplexSequence *seq,int jposition,int phase) { switch(phase) { case 0 : return est_5ss(data,seq,jposition); case 1 : return est_5ss(data,seq,jposition); case 2 : return est_5ss(data,seq,jposition); default : return -100000; } } # line 252 "est_evidence.dy" int est_intron_pot(void * data,ComplexSequence *seq,int jposition) { EstEvidence * est; int i; est = (EstEvidence *)data; for(i=1;ilen;i++) { if( (est->exon[i-1]->end <= jposition) && (jposition <= est->exon[i]->start) ) { return 0; } if( (est->exon[i]->start < jposition) && (jposition < est->exon[i]->end) ) { return -1000; } } return -10; } # line 272 "est_evidence.dy" int est_cds_pot(void * data,ComplexSequence *seq,int jposition) { int i; EstEvidence * est; int relative_frame; est = (EstEvidence *)data; for(i=0;ilen;i++) { if( est->exon[i]->start <= jposition && jposition <= est->exon[i]->end ) { if( is_stop_codon(CSEQ_GENOMIC_CODON(seq,jposition),est->ct) ) { return -1000000; } else { if( est->exon[i]->is_coding == TRUE ) { /* phase calculation. difference between start and position */ /* more complex than it looks due to convention of where a codon lies and the phase convention */ relative_frame = (jposition-est->exon[i]->start)%3; if( relative_frame == 2 && est->exon[i]->phase == 0 ) { return 125; } else if ( relative_frame == 1 && est->exon[i]->phase == 1 ) { return 125; } else if ( relative_frame == 0 && est->exon[i]->phase == 2) { return 125; } } else { /* not coding exon - return 45 */ return 80; } } } } /* we have to return same as stop codon penalty, otherwise we can just dodge stop codons using evidence lines */ return -1000000; } # line 314 "est_evidence.dy" int est_3ss(void * data,ComplexSequence *seq,int jposition) { int i; EstEvidence * est; est = (EstEvidence *)data; if( jposition == 0 ) { return -10000; } for(i=0;ilen;i++) { if( jposition+1 == est->exon[i]->start ) { return 50; } if( abs(jposition+1 - est->exon[i]->start) < est->in_smell && seq->seq->seq[jposition] == 'G' && seq->seq->seq[jposition-1] == 'A' ) { return -400; } } return -10000; } # line 341 "est_evidence.dy" int est_5ss(void * data,ComplexSequence * seq,int jposition) { int i; EstEvidence * est; est = (EstEvidence *)data; if( jposition == 0 || jposition >= seq->seq->len+2 ) { return -10000; } for(i=0;ilen;i++) { if( jposition-1 == est->exon[i]->end ) { if( est->exon[i]->used == 0 ) { return 500+est->exon[i]->intron_3_score; } else { return 10+est->exon[i]->intron_3_score; } } if( abs(jposition-1 - est->exon[i]->end) < est->in_smell && seq->seq->seq[jposition] == 'G' && seq->seq->seq[jposition+1] == 'T' ) { return -400; } } return -10000; } # line 370 "est_evidence.dy" int est_utr_pot(void * data,ComplexSequence *seq,int jposition) { int i; EstEvidence * est; est = (EstEvidence *)data; for(i=0;ilen;i++) { if( est->exon[i]->start <= jposition && jposition <= est->exon[i]->end ) { return +10; } } return -10; } # line 377 "est_evidence.c" /* Function: hard_link_EstExon(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EstExon *] * * Return [UNKN ] Undocumented return value [EstExon *] * */ EstExon * hard_link_EstExon(EstExon * obj) { if( obj == NULL ) { warn("Trying to hard link to a EstExon object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: EstExon_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstExon *] * */ EstExon * EstExon_alloc(void) { EstExon * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EstExon *) ckalloc (sizeof(EstExon))) == NULL) { warn("EstExon_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->end = 0; out->is_coding = FALSE; out->phase = 0; out->used = 0; out->intron_3_score = 0; return out; } /* Function: free_EstExon(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstExon *] * * Return [UNKN ] Undocumented return value [EstExon *] * */ EstExon * free_EstExon(EstExon * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EstExon obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_EstIndel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EstIndel *] * * Return [UNKN ] Undocumented return value [EstIndel *] * */ EstIndel * hard_link_EstIndel(EstIndel * obj) { if( obj == NULL ) { warn("Trying to hard link to a EstIndel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: EstIndel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstIndel *] * */ EstIndel * EstIndel_alloc(void) { EstIndel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EstIndel *) ckalloc (sizeof(EstIndel))) == NULL) { warn("EstIndel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->end = 0; return out; } /* Function: free_EstIndel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstIndel *] * * Return [UNKN ] Undocumented return value [EstIndel *] * */ EstIndel * free_EstIndel(EstIndel * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EstIndel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_EstEvidence(list,i,j) * * Descrip: swap function: an internal for qsort_EstEvidence * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [EstExon **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_EstEvidence(EstExon ** list,int i,int j) { EstExon * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_EstEvidence(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_EstEvidence which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [EstExon **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_EstEvidence(EstExon ** list,int left,int right,int (*comp)(EstExon * ,EstExon * )) { int i,last; if( left >= right ) return; swap_EstEvidence(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_EstEvidence (list,++last,i); } swap_EstEvidence (list,left,last); qsort_EstEvidence(list,left,last-1,comp); qsort_EstEvidence(list,last+1,right,comp); } /* Function: sort_EstEvidence(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_EstEvidence * * * Arg: obj [UNKN ] Object containing list [EstEvidence *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_EstEvidence(EstEvidence * obj,int (*comp)(EstExon *, EstExon *)) { qsort_EstEvidence(obj->exon,0,obj->len-1,comp); return; } /* Function: expand_EstEvidence(obj,len) * * Descrip: Really an internal function for add_EstEvidence * * * Arg: obj [UNKN ] Object which contains the list [EstEvidence *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_EstEvidence(EstEvidence * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_EstEvidence called with no need"); return TRUE; } if( (obj->exon = (EstExon ** ) ckrealloc (obj->exon,sizeof(EstExon *)*len)) == NULL) { warn("ckrealloc failed for expand_EstEvidence, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_EstEvidence(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [EstEvidence *] * Arg: add [OWNER] Object to add to the list [EstExon *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_EstEvidence(EstEvidence * obj,EstExon * add) { if( obj->len >= obj->maxlen) { if( expand_EstEvidence(obj,obj->len + EstEvidenceLISTLENGTH) == FALSE) return FALSE; } obj->exon[obj->len++]=add; return TRUE; } /* Function: flush_EstEvidence(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [EstEvidence *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_EstEvidence(EstEvidence * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->exon[i] != NULL) { free_EstExon(obj->exon[i]); obj->exon[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: swap_indel_EstEvidence(list,i,j) * * Descrip: swap function: an internal for qsort_indel_EstEvidence * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [EstIndel **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_indel_EstEvidence(EstIndel ** list,int i,int j) { EstIndel * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_indel_EstEvidence(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_indel_EstEvidence which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [EstIndel **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_indel_EstEvidence(EstIndel ** list,int left,int right,int (*comp)(EstIndel * ,EstIndel * )) { int i,last; if( left >= right ) return; swap_indel_EstEvidence(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_indel_EstEvidence (list,++last,i); } swap_indel_EstEvidence (list,left,last); qsort_indel_EstEvidence(list,left,last-1,comp); qsort_indel_EstEvidence(list,last+1,right,comp); } /* Function: sort_indel_EstEvidence(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_indel_EstEvidence * * * Arg: obj [UNKN ] Object containing list [EstEvidence *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_indel_EstEvidence(EstEvidence * obj,int (*comp)(EstIndel *, EstIndel *)) { qsort_indel_EstEvidence(obj->indel,0,obj->indel_len-1,comp); return; } /* Function: expand_indel_EstEvidence(obj,len) * * Descrip: Really an internal function for add_indel_EstEvidence * * * Arg: obj [UNKN ] Object which contains the list [EstEvidence *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_indel_EstEvidence(EstEvidence * obj,int len) { if( obj->indel_maxlen > obj->indel_len ) { warn("expand_EstEvidenceindel_ called with no need"); return TRUE; } if( (obj->indel = (EstIndel ** ) ckrealloc (obj->indel,sizeof(EstIndel *)*len)) == NULL) { warn("ckrealloc failed for expand_EstEvidence, returning FALSE"); return FALSE; } obj->indel_maxlen = len; return TRUE; } /* Function: add_indel_EstEvidence(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [EstEvidence *] * Arg: add [OWNER] Object to add to the list [EstIndel *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_indel_EstEvidence(EstEvidence * obj,EstIndel * add) { if( obj->indel_len >= obj->indel_maxlen) { if( expand_indel_EstEvidence(obj,obj->indel_len + EstEvidenceLISTLENGTH) == FALSE) return FALSE; } obj->indel[obj->indel_len++]=add; return TRUE; } /* Function: flush_indel_EstEvidence(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [EstEvidence *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_indel_EstEvidence(EstEvidence * obj) { int i; for(i=0;iindel_len;i++) { /*for i over list length*/ if( obj->indel[i] != NULL) { free_EstIndel(obj->indel[i]); obj->indel[i] = NULL; } } /* end of for i over list length */ obj->indel_len = 0; return i; } /* Function: EstEvidence_alloc_std(void) * * Descrip: Equivalent to EstEvidence_alloc_len(EstEvidenceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [EstEvidence *] * */ EstEvidence * EstEvidence_alloc_std(void) { return EstEvidence_alloc_len(EstEvidenceLISTLENGTH); } /* Function: EstEvidence_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [EstEvidence *] * */ EstEvidence * EstEvidence_alloc_len(int len) { EstEvidence * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = EstEvidence_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->exon = (EstExon ** ) ckcalloc (len,sizeof(EstExon *))) == NULL) { warn("Warning, ckcalloc failed in EstEvidence_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; if((out->indel = (EstIndel ** ) ckcalloc (len,sizeof(EstIndel *))) == NULL) { warn("Warning, ckcalloc failed in EstEvidence_alloc_len"); return NULL; } out->indel_len = 0; out->indel_maxlen = len; return out; } /* Function: hard_link_EstEvidence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EstEvidence *] * * Return [UNKN ] Undocumented return value [EstEvidence *] * */ EstEvidence * hard_link_EstEvidence(EstEvidence * obj) { if( obj == NULL ) { warn("Trying to hard link to a EstEvidence object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: EstEvidence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstEvidence *] * */ EstEvidence * EstEvidence_alloc(void) { EstEvidence * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EstEvidence *) ckalloc (sizeof(EstEvidence))) == NULL) { warn("EstEvidence_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->exon = NULL; out->len = out->maxlen = 0; out->indel = NULL; out->indel_len = out->indel_maxlen = 0; out->ct = NULL; out->in_smell = 8; return out; } /* Function: free_EstEvidence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstEvidence *] * * Return [UNKN ] Undocumented return value [EstEvidence *] * */ EstEvidence * free_EstEvidence(EstEvidence * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EstEvidence obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->exon != NULL) { for(i=0;ilen;i++) { if( obj->exon[i] != NULL) free_EstExon(obj->exon[i]); } ckfree(obj->exon); } if( obj->indel != NULL) { for(i=0;iindel_len;i++) { if( obj->indel[i] != NULL) free_EstIndel(obj->indel[i]); } ckfree(obj->indel); } if( obj->ct != NULL) free_CodonTable(obj->ct); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/est_evidence.h0000644000175000001440000002513110670453713016741 0ustar philippusers#ifndef DYNAMITEest_evidenceHEADERFILE #define DYNAMITEest_evidenceHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "genome_evidence.h" #include "aln.h" #define EstEvidenceLISTLENGTH 24 struct Wise2_EstExon { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start; int end; boolean is_coding; int phase; int used; int intron_3_score; } ; /* EstExon defined */ #ifndef DYNAMITE_DEFINED_EstExon typedef struct Wise2_EstExon Wise2_EstExon; #define EstExon Wise2_EstExon #define DYNAMITE_DEFINED_EstExon #endif struct Wise2_EstIndel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start; int end; } ; /* EstIndel defined */ #ifndef DYNAMITE_DEFINED_EstIndel typedef struct Wise2_EstIndel Wise2_EstIndel; #define EstIndel Wise2_EstIndel #define DYNAMITE_DEFINED_EstIndel #endif struct Wise2_EstEvidence { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif EstExon ** exon; int len;/* len for above exon */ int maxlen; /* maxlen for above exon */ EstIndel ** indel; int indel_len; /* len for above indel */ int indel_maxlen; /* maxlen for above indel */ CodonTable * ct; int in_smell; } ; /* EstEvidence defined */ #ifndef DYNAMITE_DEFINED_EstEvidence typedef struct Wise2_EstEvidence Wise2_EstEvidence; #define EstEvidence Wise2_EstEvidence #define DYNAMITE_DEFINED_EstEvidence #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_EstExon(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EstExon *] * * Return [UNKN ] Undocumented return value [EstExon *] * */ EstExon * Wise2_hard_link_EstExon(EstExon * obj); #define hard_link_EstExon Wise2_hard_link_EstExon /* Function: EstExon_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstExon *] * */ EstExon * Wise2_EstExon_alloc(void); #define EstExon_alloc Wise2_EstExon_alloc /* Function: free_EstExon(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstExon *] * * Return [UNKN ] Undocumented return value [EstExon *] * */ EstExon * Wise2_free_EstExon(EstExon * obj); #define free_EstExon Wise2_free_EstExon /* Function: hard_link_EstIndel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EstIndel *] * * Return [UNKN ] Undocumented return value [EstIndel *] * */ EstIndel * Wise2_hard_link_EstIndel(EstIndel * obj); #define hard_link_EstIndel Wise2_hard_link_EstIndel /* Function: EstIndel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstIndel *] * */ EstIndel * Wise2_EstIndel_alloc(void); #define EstIndel_alloc Wise2_EstIndel_alloc /* Function: free_EstIndel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstIndel *] * * Return [UNKN ] Undocumented return value [EstIndel *] * */ EstIndel * Wise2_free_EstIndel(EstIndel * obj); #define free_EstIndel Wise2_free_EstIndel /* Function: add_EstEvidence(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [EstEvidence *] * Arg: add [OWNER] Object to add to the list [EstExon *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_EstEvidence(EstEvidence * obj,EstExon * add); #define add_EstEvidence Wise2_add_EstEvidence /* Function: flush_EstEvidence(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [EstEvidence *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_EstEvidence(EstEvidence * obj); #define flush_EstEvidence Wise2_flush_EstEvidence /* Function: add_indel_EstEvidence(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [EstEvidence *] * Arg: add [OWNER] Object to add to the list [EstIndel *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_indel_EstEvidence(EstEvidence * obj,EstIndel * add); #define add_indel_EstEvidence Wise2_add_indel_EstEvidence /* Function: flush_indel_EstEvidence(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [EstEvidence *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_indel_EstEvidence(EstEvidence * obj); #define flush_indel_EstEvidence Wise2_flush_indel_EstEvidence /* Function: EstEvidence_alloc_std(void) * * Descrip: Equivalent to EstEvidence_alloc_len(EstEvidenceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [EstEvidence *] * */ EstEvidence * Wise2_EstEvidence_alloc_std(void); #define EstEvidence_alloc_std Wise2_EstEvidence_alloc_std /* Function: EstEvidence_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [EstEvidence *] * */ EstEvidence * Wise2_EstEvidence_alloc_len(int len); #define EstEvidence_alloc_len Wise2_EstEvidence_alloc_len /* Function: hard_link_EstEvidence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EstEvidence *] * * Return [UNKN ] Undocumented return value [EstEvidence *] * */ EstEvidence * Wise2_hard_link_EstEvidence(EstEvidence * obj); #define hard_link_EstEvidence Wise2_hard_link_EstEvidence /* Function: EstEvidence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstEvidence *] * */ EstEvidence * Wise2_EstEvidence_alloc(void); #define EstEvidence_alloc Wise2_EstEvidence_alloc /* Function: free_EstEvidence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstEvidence *] * * Return [UNKN ] Undocumented return value [EstEvidence *] * */ EstEvidence * Wise2_free_EstEvidence(EstEvidence * obj); #define free_EstEvidence Wise2_free_EstEvidence /* Unplaced functions */ /* There has been no indication of the use of these functions */ int Wise2_indicate_intron_used(GenomeEvidenceSet * set,AlnBlock * alb); #define indicate_intron_used Wise2_indicate_intron_used GenomeEvidenceSet * Wise2_read_est_evidence(FILE * ifp,CodonTable * ct); #define read_est_evidence Wise2_read_est_evidence GenomeEvidenceUnit * Wise2_new_est_GenomeEvidenceUnit(EstEvidence * evi); #define new_est_GenomeEvidenceUnit Wise2_new_est_GenomeEvidenceUnit int Wise2_est_utr5_start(void * data,ComplexSequence *seq,int jposition); #define est_utr5_start Wise2_est_utr5_start int Wise2_est_utr3_end(void * data,ComplexSequence *seq,int jposition); #define est_utr3_end Wise2_est_utr3_end int Wise2_est_start_pot(void * data,ComplexSequence *seq,int jposition); #define est_start_pot Wise2_est_start_pot int Wise2_est_stop_pot(void * data,ComplexSequence *seq,int jposition); #define est_stop_pot Wise2_est_stop_pot int Wise2_est_cds_frameshift(void * data,ComplexSequence * seq,int jposition,int jump); #define est_cds_frameshift Wise2_est_cds_frameshift int Wise2_est_cds_3SS(void * data,ComplexSequence *seq,int jposition,int phase); #define est_cds_3SS Wise2_est_cds_3SS int Wise2_est_cds_5SS(void * data,ComplexSequence *seq,int jposition,int phase); #define est_cds_5SS Wise2_est_cds_5SS int Wise2_est_intron_pot(void * data,ComplexSequence *seq,int jposition); #define est_intron_pot Wise2_est_intron_pot int Wise2_est_cds_pot(void * data,ComplexSequence *seq,int jposition); #define est_cds_pot Wise2_est_cds_pot int Wise2_est_3ss(void * data,ComplexSequence *seq,int jposition); #define est_3ss Wise2_est_3ss int Wise2_est_5ss(void * data,ComplexSequence * seq,int jposition); #define est_5ss Wise2_est_5ss int Wise2_est_utr_pot(void * data,ComplexSequence *seq,int jposition); #define est_utr_pot Wise2_est_utr_pot /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_EstEvidence(EstExon ** list,int i,int j) ; #define swap_EstEvidence Wise2_swap_EstEvidence void Wise2_qsort_EstEvidence(EstExon ** list,int left,int right,int (*comp)(EstExon * ,EstExon * )); #define qsort_EstEvidence Wise2_qsort_EstEvidence void Wise2_sort_EstEvidence(EstEvidence * obj,int (*comp)(EstExon *, EstExon *)); #define sort_EstEvidence Wise2_sort_EstEvidence boolean Wise2_expand_EstEvidence(EstEvidence * obj,int len); #define expand_EstEvidence Wise2_expand_EstEvidence void Wise2_swap_indel_EstEvidence(EstIndel ** list,int i,int j) ; #define swap_indel_EstEvidence Wise2_swap_indel_EstEvidence void Wise2_qsort_indel_EstEvidence(EstIndel ** list,int left,int right,int (*comp)(EstIndel * ,EstIndel * )); #define qsort_indel_EstEvidence Wise2_qsort_indel_EstEvidence void Wise2_sort_indel_EstEvidence(EstEvidence * obj,int (*comp)(EstIndel *, EstIndel *)); #define sort_indel_EstEvidence Wise2_sort_indel_EstEvidence boolean Wise2_expand_indel_EstEvidence(EstEvidence * obj,int len); #define expand_indel_EstEvidence Wise2_expand_indel_EstEvidence #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/geneparser21.dy0000644000175000001440000001672507313404545016777 0ustar philippusers/* Last edited: Apr 23 17:21 1997 (birney) */ %{ #include "probability.h" #include "dyna.h" #include "randommodel.h" #include "genefrequency.h" enum { GP21_CDS2CENTRAL = 0, GP21_CENTRAL2CENTRAL, GP21_CENTRAL2PY, GP21_PY2PY, GP21_PY2SPACER, GP21_PY2CDS, GP21_SPACER2SPACER, GP21_SPACER2CDS, GP21_INSERT_1_BASE, GP21_INSERT_2_BASE, GP21_DELETE_1_BASE, GP21_DELETE_2_BASE, GP21_CDS2CDS, /* this is for gene parsing outside of the *Wise set */ GP21_RND2CDS, GP21_CDS2RND, GP21_RND2RND, GP21_RND2MODEL, GP21_LINK2MODEL, /* this is for link models */ GP21_LINK2LINK, GP21_LINK2RND, GENEPARSER21_TRANSITION_LEN }; #define GENEPARSER21_EMISSION_LEN 5 #define GeneParser21SetLISTLENGTH 32 %} struct GeneParser21 Probability transition[GENEPARSER21_TRANSITION_LEN] Probability central[GENEPARSER21_EMISSION_LEN] Probability py[GENEPARSER21_EMISSION_LEN] Probability spacer[GENEPARSER21_EMISSION_LEN] struct GeneParser21Score Score transition[GENEPARSER21_TRANSITION_LEN] Score central[GENEPARSER21_EMISSION_LEN] Score py[GENEPARSER21_EMISSION_LEN] Score spacer[GENEPARSER21_EMISSION_LEN] %{ #include "geneparser21.h" RandomModelDNA * fudged_mixed_RandomModelDNA_from_GeneParser21(GeneParser21 * gp,RandomModelDNA * rnd) { RandomModelDNA * out; int i; out = RandomModelDNA_alloc(); #define PROBMAX(this,that) (this > that ? this : that) for(i=0;i<5;i++) { out->base[i] = PROBMAX(PROBMAX(gp->central[i],gp->py[i]),PROBMAX(gp->spacer[i],rnd->base[i]))/rnd->base[i]; } #undef PROBMAX return out; } /*** Adds the error probabilities ***/ void add_flat_error_probabilities_GeneParser21(GeneParser21 * gp21,Probability error) { add_error_probabilities_GeneParser21(gp21,error,error,error,error); } void add_error_probabilities_GeneParser21(GeneParser21 * gp21,Probability insert_1,Probability insert_2,Probability delete_1,Probability delete_2) { gp21->transition[GP21_INSERT_1_BASE] = insert_1; gp21->transition[GP21_INSERT_2_BASE] = insert_2; gp21->transition[GP21_DELETE_1_BASE] = delete_1; gp21->transition[GP21_DELETE_2_BASE] = delete_2; } /**** Makes the GeneParser21 structure, which essentially has transition probabilities for geneparsing this sets everything to zero and then only allocates gene parsing probs. Frameshifting error is not delt with here. ****/ GeneParser21 * GeneParser21_from_GeneFrequency21_cds(GeneFrequency21 * gf,Probability rnd_loop,Probability cds_loop,Probability rnd_to_model,Probability link_loop,Probability link_to_model) { GeneParser21 * out; register int i; double total; out = GeneParser21_alloc(); set_Probability_array(out->transition,0.0,GENEPARSER21_TRANSITION_LEN); set_Probability_array(out->central,0.0,GENEPARSER21_EMISSION_LEN); set_Probability_array(out->spacer,0.0,GENEPARSER21_EMISSION_LEN); set_Probability_array(out->py,0.0,GENEPARSER21_EMISSION_LEN); total = sum_Probability_array(gf->central,4); for(i=0;i<4;i++) { out->central[i] = gf->central[i]/total; } out->central[4] = 1.0; total = sum_Probability_array(gf->py,4); for(i=0;i<4;i++) { out->py[i] = gf->py[i]/total; } out->py[4] = 1.0; total = sum_Probability_array(gf->spacer,4); for(i=0;i<4;i++) { out->spacer[i] = gf->spacer[i]/total; } out->spacer[4] = 1.0; out->transition[GP21_CENTRAL2CENTRAL] = gf->transition[GF21_CENTRAL_STAY]; out->transition[GP21_CENTRAL2PY] = 1- gf->transition[GF21_CENTRAL_STAY]; out->transition[GP21_PY2PY] = gf->transition[GF21_PY_STAY]; out->transition[GP21_PY2SPACER] = 1 - gf->transition[GF21_PY_STAY] * (1-gf->transition[GF21_NO_SPACER]); out->transition[GP21_PY2CDS] = 1 - gf->transition[GF21_PY_STAY] * (gf->transition[GF21_NO_SPACER]); out->transition[GP21_SPACER2SPACER] = gf->transition[GF21_SPACER_STAY]; out->transition[GP21_SPACER2CDS] = 1 - gf->transition[GF21_SPACER_STAY]; out->transition[GP21_CDS2CDS] = cds_loop; out->transition[GP21_CDS2RND] = (1-cds_loop); out->transition[GP21_RND2RND] = rnd_loop; /* fprintf(stderr,"Score is %f\n",out->transition[GP21_RND2RND]); */ out->transition[GP21_RND2CDS] = (1-rnd_loop-rnd_to_model); out->transition[GP21_RND2MODEL] = rnd_to_model; out->transition[GP21_LINK2MODEL] = link_to_model; out->transition[GP21_LINK2LINK] = link_loop; out->transition[GP21_LINK2RND] = (1- link_loop - link_to_model) ; return out; } RandomModelDNA * RandomModelDNA_from_central_GeneParser21(GeneParser21 *gp21) { RandomModelDNA * rmd; rmd = RandomModelDNA_alloc(); if( rmd == NULL ) return NULL; rmd->base[BASE_A] = gp21->central[BASE_A]; rmd->base[BASE_T] = gp21->central[BASE_T]; rmd->base[BASE_G] = gp21->central[BASE_G]; rmd->base[BASE_C] = gp21->central[BASE_C]; rmd->base[BASE_N] = gp21->central[BASE_N]; return rmd; } void show_GeneParser21(GeneParser21 * gp21,FILE * ofp) { fprintf(ofp,"Central emissions\n"); show_Probability_array(gp21->central,GENEPARSER21_EMISSION_LEN,ofp); fprintf(ofp,"\nPyrimidine emissions\n"); show_Probability_array(gp21->py,GENEPARSER21_EMISSION_LEN,ofp); fprintf(ofp,"\nSpacer emissions\n"); show_Probability_array(gp21->spacer,GENEPARSER21_EMISSION_LEN,ofp); fprintf(ofp,"\nTransitions\n"); show_Probability_array(gp21->transition,GENEPARSER21_TRANSITION_LEN,ofp); } GeneParser21 * std_GeneParser21(void) { GeneParser21 * out; out = GeneParser21_alloc(); out->central[BASE_T] = 0.25; out->central[BASE_G] = 0.25; out->central[BASE_C] = 0.25; out->central[BASE_A] = 0.25; out->py[BASE_T] = 0.4; out->py[BASE_C] = 0.4; out->py[BASE_G] = 0.1; out->py[BASE_A] = 0.1; out->spacer[BASE_T] = 0.4; out->spacer[BASE_G] = 0.2; out->spacer[BASE_C] = 0.2; out->spacer[BASE_A] = 0.2; out->central[BASE_N] = out->py[BASE_N] = out->spacer[BASE_N] = 1.0; out->transition[GP21_CDS2CENTRAL] = 0.0; out->transition[GP21_CENTRAL2CENTRAL] = 0.998; out->transition[GP21_CENTRAL2PY] = 0.002; out->transition[GP21_PY2PY] = 0.94; out->transition[GP21_PY2CDS] = 0.01; out->transition[GP21_PY2SPACER] = 0.05; out->transition[GP21_SPACER2SPACER] = 0.9; out->transition[GP21_SPACER2CDS] = 0.1; out->transition[GP21_INSERT_1_BASE] = 0.001; out->transition[GP21_INSERT_2_BASE] = 0.001; out->transition[GP21_DELETE_1_BASE] = 0.002; out->transition[GP21_DELETE_2_BASE] = 0.003; return out; } Probability removed_probability_from_cds(GeneParser21 * gp21) { Probability ret; ret = gp21->transition[GP21_INSERT_1_BASE] + gp21->transition[GP21_INSERT_2_BASE] + gp21->transition[GP21_DELETE_2_BASE] + gp21->transition[GP21_DELETE_1_BASE]; return ret; } void GeneParser21_fold_in_RandomModelDNA(GeneParser21 * gp21,RandomModelDNA * rmd) { (void)Probability_array_divide(gp21->central,gp21->central,rmd->base,5); (void)Probability_array_divide(gp21->py,gp21->py,rmd->base,5); (void)Probability_array_divide(gp21->spacer,gp21->spacer,rmd->base,5); } GeneParser21Score * GeneParser21Score_from_GeneParser21(GeneParser21 * gp21) { GeneParser21Score * out; out = GeneParser21Score_alloc(); if( out == NULL ) return NULL; Probability2Score_move(gp21->transition,out->transition,GENEPARSER21_TRANSITION_LEN); Probability2Score_move(gp21->central, out->central, GENEPARSER21_EMISSION_LEN); Probability2Score_move(gp21->py, out->py, GENEPARSER21_EMISSION_LEN); Probability2Score_move(gp21->spacer, out->spacer, GENEPARSER21_EMISSION_LEN); return out; } %} wise-2.4.1/src/models/localcishit.c0000644000175000001440000007011710670453714016602 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "localcishit.h" # line 49 "localcishit.dy" HitList * HitList_from_LocalCisHitSet(LocalCisHitSet * in) { HitList * out; HitPair * p; HitAln * a; int i; out = HitList_alloc_std(); for(i=0;ilen;i++) { p = HitPair_alloc_std(); add_HitList(out,p); p->query = hard_link_Sequence(in->lch[i]->query); p->target = hard_link_Sequence(in->lch[i]->target); p->raw_score = in->lch[i]->score; p->bit_score = Score2Bits(p->raw_score); p->target_reversed = in->lch[i]->target_rev; a = HitAln_alloc(); add_HitPair(p,a); a->alb = hard_link_AlnBlock(in->lch[i]->alb); a->raw_score = p->raw_score; a->bit_score = p->bit_score; } out->write_btc_func = show_pretty_Seq_dba_align_btcanvas; return out; } # line 80 "localcishit.dy" LocalCisHitSet * expand_to_subhits_LocalCisHitSet(LocalCisHitSet * in) { int i; AlnBlock * new; AlnColumn * alc; LocalCisHitSet * out; int qstart; int tstart; int qend; int tend; int score_start; int score; out = LocalCisHitSet_alloc_std(); for(i=0;in->len;i++) { for(alc=in->lch[i]->alb->start;alc != NULL;alc = alc->next ) { if( strcmp(alc->alu[0]->text_label,"UNMATCHED_QUERY") == 0 ) { break; } } if( alc == NULL ) { /* just one hit */ add_LocalCisHitSet(out,hard_link_LocalCisHit(in->lch[i])); } else { for(alc=in->lch[i]->alb->start;alc != NULL;alc = alc->next) { if( strstr(alc->alu[0]->text_label,"MM") != NULL ) { /* start here */ qstart = alc->alu[0]->start; tstart = alc->alu[1]->start; score = 0; new = AlnBlock_alloc(); new->start = alc; for(;alc != NULL && strstr(alc->alu[0]->text_label,"UNMATCHED") == NULL; alc = alc->next) { } } } fatal("Ewan has not implemented subhit expansion!"); } } return out; } # line 127 "localcishit.dy" void show_help_LocalCisHitSetPara(FILE * ofp) { fprintf(ofp,"Local Hit expansion parameters\n"); fprintf(ofp," -lhwindow - sequence window given to alignment [50]\n"); fprintf(ofp," -lhseed - seed score cutoff [10.0 bits]\n"); fprintf(ofp," -lhaln - aln score cutoff [8.0 bits]\n"); fprintf(ofp," -lhscore - sort final list by score (default by position)\n"); fprintf(ofp," -lhreject [none/query/both] - overlap rejection criteria in greedy assembly [query]\n"); fprintf(ofp," -lhmax [20000] - maximum number of processed hits\n"); } # line 139 "localcishit.dy" LocalCisHitSetPara * new_LocalCisHitSetPara_from_argv(int * argc,char ** argv) { LocalCisHitSetPara * setpara; char * temp; setpara = LocalCisHitSetPara_alloc(); setpara->expansion_size = 50; setpara->seed_bit_trigger = 10.0; setpara->aln_cutoff = 8.0; setpara->sort_by_score = 0; setpara->max = 20000; setpara->type = LocalCisGreedy_Query; strip_out_integer_argument(argc,argv,"lhwindow",&setpara->expansion_size); strip_out_integer_argument(argc,argv,"lhmax",&setpara->max); strip_out_float_argument(argc,argv,"lhseed",&setpara->seed_bit_trigger); strip_out_float_argument(argc,argv,"lhaln",&setpara->aln_cutoff); strip_out_boolean_def_argument(argc,argv,"lhscore",&setpara->sort_by_score); temp = strip_out_assigned_argument(argc,argv,"lhreject"); if( temp != NULL ) { if( strcmp(temp,"none") == 0) { setpara->type = LocalCisGreedy_None; } else if ( strcmp(temp,"query") == 0 ) { setpara->type = LocalCisGreedy_Query; } else if ( strcmp(temp,"both") == 0){ setpara->type = LocalCisGreedy_Both; } else { fatal("Bad parameter for lhreject %s",temp); } } return setpara; } # line 175 "localcishit.dy" void show_pretty_LocalCisHitSet(LocalCisHitSet * lchs,FILE * ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,">%s %5d,%5d %s %5d,%5d [%c] Bits %.2f\n", lchs->lch[i]->query->name, lchs->lch[i]->start_q+1, lchs->lch[i]->end_q, lchs->lch[i]->target->name, lchs->lch[i]->start_t+1, lchs->lch[i]->end_t, lchs->lch[i]->target_rev == 1 ? '-' : '+', Score2Bits(lchs->lch[i]->score) ); fprintf(ofp,"\n"); show_pretty_dba_align(lchs->lch[i]->alb,lchs->lch[i]->query,lchs->lch[i]->target,ofp); } } # line 199 "localcishit.dy" void show_summary_LocalCisHitSet(LocalCisHitSet * lchs,FILE * ofp) { int i; assert(lchs); assert(ofp); for(i=0;ilen;i++) { fprintf(ofp,"Query %5d,%5d Target %5d,%5d [%c] Bits %.2f\n", lchs->lch[i]->start_q+1, lchs->lch[i]->end_q, lchs->lch[i]->start_t+1, lchs->lch[i]->end_t, lchs->lch[i]->target_rev == 1 ? '-' : '+', Score2Bits(lchs->lch[i]->score) ); } } # line 221 "localcishit.dy" LocalCisHitSet * greedy_weed_LocalCisHitSet(LocalCisHitSet * set,LocalCisHitSetPara *p) { LocalCisHitSet * out; int i; int j; int is_valid; sort_LocalCisHitSet_by_score(set); out = LocalCisHitSet_alloc_std(); for(i=0;ilen;i++) { if( Score2Bits(set->lch[i]->score) < p->aln_cutoff) { break; } is_valid = 1; if( p->type != LocalCisGreedy_None ) { for(j=0;jlen;j++) { if( is_query_overlap_LocalCisHit(set->lch[i],out->lch[j]) == 1 ) { is_valid = 0; break; } } if( is_valid == 1 && p->type == LocalCisGreedy_Both ) { for(j=0;jlen;j++) { if( is_target_overlap_LocalCisHit(set->lch[i],out->lch[j]) == 1 ) { is_valid = 0; break; } } } } if( is_valid == 1 ) { add_LocalCisHitSet(out,hard_link_LocalCisHit(set->lch[i])); } } if( p->sort_by_score == 0 ) { sort_LocalCisHitSet_by_start(out); } return out; } # line 270 "localcishit.dy" void sort_LocalCisHitSet_by_score(LocalCisHitSet * set) { sort_LocalCisHitSet(set,compare_LocalCisHit_score); } # line 275 "localcishit.dy" void sort_LocalCisHitSet_by_start(LocalCisHitSet * set) { sort_LocalCisHitSet(set,compare_LocalCisHit_start); } # line 280 "localcishit.dy" int compare_LocalCisHit_score(LocalCisHit * a,LocalCisHit * b) { return b->score - a->score; } # line 285 "localcishit.dy" int compare_LocalCisHit_start(LocalCisHit * a,LocalCisHit * b) { return a->start_q - b->start_q; } # line 290 "localcishit.dy" int is_query_overlap_LocalCisHit(LocalCisHit * a,LocalCisHit * b) { if( a->start_q > b->end_q || a->end_q < b->start_q ) { return 0; } else { return 1; } } # line 299 "localcishit.dy" int is_target_overlap_LocalCisHit(LocalCisHit * a,LocalCisHit * b) { if( a->start_t > b->end_t || a->end_t < b->start_t ) { return 0; } else { return 1; } } # line 309 "localcishit.dy" int is_consumed_HSP(HSP * a,int q_start,int q_end,int t_start,int t_end) { int qcentre; int tcentre; /* find centre of hit, and see if it is in the system */ qcentre = a->query_start + (a->length/2); tcentre = a->target_start + (a->length/2); if( qcentre >= q_start && qcentre <= q_end && tcentre >= t_start && tcentre <= t_end ) { return 1; } else { return 0; } } # line 326 "localcishit.dy" LocalCisHitSet * make_LocalCisHitSet(Sequence * query,Sequence * target,Sequence * target_rev,HSPset * forward,HSPset * reverse,LocalCisHitSetPara * p,LocalCisHitScore * scorepara,TransFactorMatchSet * tfms_query,TransFactorMatchSet * tfms_target,TransFactorMatchSet * tfms_target_rev,MotifMatrixScore * mms,boolean use_motif,DPRunImpl * dpri) { LocalCisHitSet * set; LocalCisHit * lch; int i,j; int * forward_used; int * reverse_used; int q_start; int q_end; int t_start; int t_end; int temp_q_start; int temp_q_end; int temp_t_start; int temp_t_end; assert(query); assert(target); assert(target_rev); assert(forward); assert(reverse); sort_HSPset_by_score(forward); sort_HSPset_by_score(reverse); set = LocalCisHitSet_alloc_std(); forward_used = calloc(forward->len,sizeof(int)); for(i=0;ilen;i++) { forward_used[i] = 0; } for(i=0;ilen && i < p->max;i++) { /* fprintf(stderr,"Looking at hsp set %d %d %f score vs trigger %f\n",i,forward->hsp[i]->score,Score2Bits(forward->hsp[i]->score),p->seed_bit_trigger); */ if( forward_used[i] == 0 && Score2Bits(forward->hsp[i]->score) > p->seed_bit_trigger ) { forward_used[i] = 1; q_start = forward->hsp[i]->query_start-p->expansion_size; q_end = forward->hsp[i]->query_start+forward->hsp[i]->length+p->expansion_size; t_start = forward->hsp[i]->target_start-p->expansion_size; t_end = forward->hsp[i]->target_start+forward->hsp[i]->length+p->expansion_size; for(j=i;jlen && j < p->max;j++) { if( forward_used[j] == 1 ) { continue; } if( is_consumed_HSP(forward->hsp[j],q_start,q_end,t_start,t_end) ) { forward_used[j] = 1; /*info("consuming forward %d by %d\n",j,i);*/ temp_q_start = forward->hsp[j]->query_start-p->expansion_size; temp_q_end = forward->hsp[j]->query_start+forward->hsp[i]->length+p->expansion_size; temp_t_start = forward->hsp[j]->target_start-p->expansion_size; temp_t_end = forward->hsp[j]->target_start+forward->hsp[i]->length+p->expansion_size; q_start = temp_q_start < q_start ? temp_q_start : q_start; t_start = temp_t_start < t_start ? temp_t_start : t_start; t_end = temp_t_end > t_end ? temp_t_end : t_end; q_end = temp_q_end > q_end ? temp_q_end : q_end; } } /* now build local cis hit */ if( use_motif == 0 ) { lch = make_LocalCisHit(query,target,0, q_start, q_end, t_start, t_end, scorepara,dpri ); } else { lch = make_motif_LocalCisHit(query,target,0, q_start, q_end, t_start, t_end, tfms_query, tfms_target, mms,dpri ); } add_LocalCisHitSet(set,lch); } else { break; } } reverse_used = calloc(reverse->len,sizeof(int)); for(i=0;ilen;i++) { reverse_used[i] = 0; } for(i=0;ilen && i < p->max ;i++) { if( reverse_used[i] == 0 && Score2Bits(reverse->hsp[i]->score) > p->seed_bit_trigger ) { reverse_used[i] = 1; q_start = reverse->hsp[i]->query_start-p->expansion_size; q_end = reverse->hsp[i]->query_start+reverse->hsp[i]->length+p->expansion_size; t_start = reverse->hsp[i]->target_start-p->expansion_size; t_end = reverse->hsp[i]->target_start+reverse->hsp[i]->length+p->expansion_size; for(j=i;jlen && j < p->max ;j++) { if( reverse_used[j] == 1 ) { continue; } if( is_consumed_HSP(reverse->hsp[j],q_start,q_end,t_start,t_end) ) { reverse_used[j] = 1; /*info("consuming reverse %d by %d\n",j,i);*/ temp_q_start = reverse->hsp[j]->query_start-p->expansion_size; temp_q_end = reverse->hsp[j]->query_start+reverse->hsp[i]->length+p->expansion_size; temp_t_start = reverse->hsp[j]->target_start-p->expansion_size; temp_t_end = reverse->hsp[j]->target_start+reverse->hsp[i]->length+p->expansion_size; q_start = temp_q_start < q_start ? temp_q_start : q_start; t_start = temp_t_start < t_start ? temp_t_start : t_start; t_end = temp_t_end > t_end ? temp_t_end : t_end; q_end = temp_q_end > q_end ? temp_q_end : q_end; } } if( use_motif == 0 ) { lch = make_LocalCisHit(query,target_rev,1, q_start, q_end, t_start, t_end, scorepara,dpri ); } else { lch = make_motif_LocalCisHit(query,target_rev,1, q_start, q_end, t_start, t_end, tfms_query, tfms_target_rev, mms,dpri ); } add_LocalCisHitSet(set,lch); } else { break; } } return set; } # line 495 "localcishit.dy" LocalCisHit * make_LocalCisHit(Sequence * query,Sequence * target,int is_reversed,int guess_q_start,int guess_q_end,int guess_t_start,int guess_t_end,LocalCisHitScore * score,DPRunImpl * dpri) { LocalCisHit * out; Sequence * temp_q; Sequence * temp_t; ComplexSequence * q_cseq; ComplexSequence * t_cseq; ComplexSequenceEvalSet * cses; PackAln * pal; AlnBlock * alb; int i; assert(query); assert(target); assert(score); if( guess_q_start < 0 ) { guess_q_start = 0; } if( guess_q_end >= query->len ) { guess_q_end = query->len-1; } if( guess_t_start < 0 ) { guess_t_start = 0; } if( guess_t_end >= target->len ) { guess_t_end = target->len-1; } temp_q = trunc_Sequence(query,guess_q_start,guess_q_end); temp_t = trunc_Sequence(target,guess_t_start,guess_t_end); cses = default_DNA_ComplexSequenceEvalSet(); q_cseq = new_ComplexSequence(temp_q,cses); t_cseq = new_ComplexSequence(temp_t,cses); assert(q_cseq); assert(t_cseq); pal = PackAln_bestmemory_LocalDnaMatchBlock(q_cseq,t_cseq,score,NULL,dpri); assert(pal); for(i=0;ilen;i++) { pal->pau[i]->i = pal->pau[i]->i + guess_q_start; pal->pau[i]->j = pal->pau[i]->j + guess_t_start; } alb = convert_PackAln_to_AlnBlock_LocalDnaMatchBlock(pal); out = LocalCisHit_alloc(); out->start_q = pal->pau[0]->i; out->end_q = pal->pau[pal->len-2]->i; out->start_t = pal->pau[0]->j; out->end_t = pal->pau[pal->len-1]->j; out->score = pal->score; out->target_rev = is_reversed; out->alb = alb; out->query = hard_link_Sequence(query); out->target = hard_link_Sequence(target); free_PackAln(pal); return out; } # line 571 "localcishit.dy" LocalCisHit * make_motif_LocalCisHit(Sequence * query,Sequence * target,int is_reversed,int guess_q_start,int guess_q_end,int guess_t_start,int guess_t_end,TransFactorMatchSet * tfms_query,TransFactorMatchSet * tfms_target,MotifMatrixScore * mms,DPRunImpl * dpri) { LocalCisHit * out; Sequence * temp_q; Sequence * temp_t; ComplexSequence * q_cseq; ComplexSequence * t_cseq; ComplexSequenceEvalSet * cses; MotifConsMatrix * mcm; PackAln * pal; AlnBlock * alb; int i; assert(query != NULL); assert(target != NULL); assert(mms != NULL); assert(tfms_query != NULL); assert(tfms_target != NULL); if( guess_q_start < 0 ) { guess_q_start = 0; } if( guess_q_end >= query->len ) { guess_q_end = query->len-1; } if( guess_t_start < 0 ) { guess_t_start = 0; } if( guess_t_end >= target->len ) { guess_t_end = target->len-1; } temp_q = trunc_Sequence(query,guess_q_start,guess_q_end); temp_t = trunc_Sequence(target,guess_t_start,guess_t_end); cses = default_DNA_ComplexSequenceEvalSet(); q_cseq = new_ComplexSequence(temp_q,cses); t_cseq = new_ComplexSequence(temp_t,cses); assert(q_cseq); assert(t_cseq); mcm = new_MotifConsMatrix(tfms_query,guess_q_start,guess_q_end,tfms_target,guess_t_start,guess_t_end); pal = PackAln_bestmemory_LocalMotifMatrix(q_cseq,t_cseq,mcm,mms,NULL,dpri); assert(pal); for(i=0;ilen;i++) { pal->pau[i]->i = pal->pau[i]->i + guess_q_start; pal->pau[i]->j = pal->pau[i]->j + guess_t_start; } alb = convert_PackAln_to_AlnBlock_LocalMotifMatrix(pal); out = LocalCisHit_alloc(); out->start_q = pal->pau[0]->i; out->end_q = pal->pau[pal->len-2]->i; out->start_t = pal->pau[0]->j; out->end_t = pal->pau[pal->len-1]->j; out->score = pal->score; out->target_rev = is_reversed; out->alb = alb; out->query = hard_link_Sequence(query); out->target = hard_link_Sequence(target); free_PackAln(pal); return out; } # line 633 "localcishit.c" /* Function: hard_link_LocalCisHit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LocalCisHit *] * * Return [UNKN ] Undocumented return value [LocalCisHit *] * */ LocalCisHit * hard_link_LocalCisHit(LocalCisHit * obj) { if( obj == NULL ) { warn("Trying to hard link to a LocalCisHit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LocalCisHit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalCisHit *] * */ LocalCisHit * LocalCisHit_alloc(void) { LocalCisHit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LocalCisHit *) ckalloc (sizeof(LocalCisHit))) == NULL) { warn("LocalCisHit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start_q = 0; out->end_q = 0; out->start_t = 0; out->end_t = 0; out->target_rev = 0; out->alb = NULL; out->score = 0; out->query = NULL; out->target = NULL; return out; } /* Function: free_LocalCisHit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalCisHit *] * * Return [UNKN ] Undocumented return value [LocalCisHit *] * */ LocalCisHit * free_LocalCisHit(LocalCisHit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LocalCisHit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->alb != NULL) free_AlnBlock(obj->alb); if( obj->query != NULL) free_Sequence(obj->query); if( obj->target != NULL) free_Sequence(obj->target); ckfree(obj); return NULL; } /* Function: swap_LocalCisHitSet(list,i,j) * * Descrip: swap function: an internal for qsort_LocalCisHitSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [LocalCisHit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_LocalCisHitSet(LocalCisHit ** list,int i,int j) { LocalCisHit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_LocalCisHitSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_LocalCisHitSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [LocalCisHit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_LocalCisHitSet(LocalCisHit ** list,int left,int right,int (*comp)(LocalCisHit * ,LocalCisHit * )) { int i,last; if( left >= right ) return; swap_LocalCisHitSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_LocalCisHitSet (list,++last,i); } swap_LocalCisHitSet (list,left,last); qsort_LocalCisHitSet(list,left,last-1,comp); qsort_LocalCisHitSet(list,last+1,right,comp); } /* Function: sort_LocalCisHitSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_LocalCisHitSet * * * Arg: obj [UNKN ] Object containing list [LocalCisHitSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_LocalCisHitSet(LocalCisHitSet * obj,int (*comp)(LocalCisHit *, LocalCisHit *)) { qsort_LocalCisHitSet(obj->lch,0,obj->len-1,comp); return; } /* Function: expand_LocalCisHitSet(obj,len) * * Descrip: Really an internal function for add_LocalCisHitSet * * * Arg: obj [UNKN ] Object which contains the list [LocalCisHitSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_LocalCisHitSet(LocalCisHitSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_LocalCisHitSet called with no need"); return TRUE; } if( (obj->lch = (LocalCisHit ** ) ckrealloc (obj->lch,sizeof(LocalCisHit *)*len)) == NULL) { warn("ckrealloc failed for expand_LocalCisHitSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_LocalCisHitSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LocalCisHitSet *] * Arg: add [OWNER] Object to add to the list [LocalCisHit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_LocalCisHitSet(LocalCisHitSet * obj,LocalCisHit * add) { if( obj->len >= obj->maxlen) { if( expand_LocalCisHitSet(obj,obj->len + LocalCisHitSetLISTLENGTH) == FALSE) return FALSE; } obj->lch[obj->len++]=add; return TRUE; } /* Function: flush_LocalCisHitSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LocalCisHitSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_LocalCisHitSet(LocalCisHitSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->lch[i] != NULL) { free_LocalCisHit(obj->lch[i]); obj->lch[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: LocalCisHitSet_alloc_std(void) * * Descrip: Equivalent to LocalCisHitSet_alloc_len(LocalCisHitSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [LocalCisHitSet *] * */ LocalCisHitSet * LocalCisHitSet_alloc_std(void) { return LocalCisHitSet_alloc_len(LocalCisHitSetLISTLENGTH); } /* Function: LocalCisHitSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [LocalCisHitSet *] * */ LocalCisHitSet * LocalCisHitSet_alloc_len(int len) { LocalCisHitSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = LocalCisHitSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->lch = (LocalCisHit ** ) ckcalloc (len,sizeof(LocalCisHit *))) == NULL) { warn("Warning, ckcalloc failed in LocalCisHitSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_LocalCisHitSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LocalCisHitSet *] * * Return [UNKN ] Undocumented return value [LocalCisHitSet *] * */ LocalCisHitSet * hard_link_LocalCisHitSet(LocalCisHitSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a LocalCisHitSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LocalCisHitSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalCisHitSet *] * */ LocalCisHitSet * LocalCisHitSet_alloc(void) { LocalCisHitSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LocalCisHitSet *) ckalloc (sizeof(LocalCisHitSet))) == NULL) { warn("LocalCisHitSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->lch = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_LocalCisHitSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalCisHitSet *] * * Return [UNKN ] Undocumented return value [LocalCisHitSet *] * */ LocalCisHitSet * free_LocalCisHitSet(LocalCisHitSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LocalCisHitSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->lch != NULL) { for(i=0;ilen;i++) { if( obj->lch[i] != NULL) free_LocalCisHit(obj->lch[i]); } ckfree(obj->lch); } ckfree(obj); return NULL; } /* Function: hard_link_LocalCisHitSetPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LocalCisHitSetPara *] * * Return [UNKN ] Undocumented return value [LocalCisHitSetPara *] * */ LocalCisHitSetPara * hard_link_LocalCisHitSetPara(LocalCisHitSetPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a LocalCisHitSetPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LocalCisHitSetPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalCisHitSetPara *] * */ LocalCisHitSetPara * LocalCisHitSetPara_alloc(void) { LocalCisHitSetPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LocalCisHitSetPara *) ckalloc (sizeof(LocalCisHitSetPara))) == NULL) { warn("LocalCisHitSetPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->seed_bit_trigger = 0; out->expansion_size = 0; out->aln_cutoff = 0; out->sort_by_score = FALSE; out->max = 0; out->type = LocalCisGreedy_Query; return out; } /* Function: free_LocalCisHitSetPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalCisHitSetPara *] * * Return [UNKN ] Undocumented return value [LocalCisHitSetPara *] * */ LocalCisHitSetPara * free_LocalCisHitSetPara(LocalCisHitSetPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LocalCisHitSetPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/localcishit.h0000644000175000001440000002623410670453714016610 0ustar philippusers#ifndef DYNAMITElocalcishitHEADERFILE #define DYNAMITElocalcishitHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "hsp.h" #include "localdba.h" #include "dbadisplay.h" #include "hitlist.h" #include "motifmatrix.h" #include "motifmatrixdp.h" #define LocalCisHitSetLISTLENGTH 128 typedef enum LocalCisGreedyType { LocalCisGreedy_None = 55, LocalCisGreedy_Query, LocalCisGreedy_Both } LocalCisGreedyType; struct Wise2_LocalCisHit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start_q; int end_q; int start_t; int end_t; int target_rev; AlnBlock * alb; /* relative to absolute coords */ int score; Sequence * query; Sequence * target; } ; /* LocalCisHit defined */ #ifndef DYNAMITE_DEFINED_LocalCisHit typedef struct Wise2_LocalCisHit Wise2_LocalCisHit; #define LocalCisHit Wise2_LocalCisHit #define DYNAMITE_DEFINED_LocalCisHit #endif struct Wise2_LocalCisHitSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif LocalCisHit ** lch; int len;/* len for above lch */ int maxlen; /* maxlen for above lch */ } ; /* LocalCisHitSet defined */ #ifndef DYNAMITE_DEFINED_LocalCisHitSet typedef struct Wise2_LocalCisHitSet Wise2_LocalCisHitSet; #define LocalCisHitSet Wise2_LocalCisHitSet #define DYNAMITE_DEFINED_LocalCisHitSet #endif struct Wise2_LocalCisHitSetPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif double seed_bit_trigger; int expansion_size; double aln_cutoff; boolean sort_by_score; int max; LocalCisGreedyType type; } ; /* LocalCisHitSetPara defined */ #ifndef DYNAMITE_DEFINED_LocalCisHitSetPara typedef struct Wise2_LocalCisHitSetPara Wise2_LocalCisHitSetPara; #define LocalCisHitSetPara Wise2_LocalCisHitSetPara #define DYNAMITE_DEFINED_LocalCisHitSetPara #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_LocalCisHit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LocalCisHit *] * * Return [UNKN ] Undocumented return value [LocalCisHit *] * */ LocalCisHit * Wise2_hard_link_LocalCisHit(LocalCisHit * obj); #define hard_link_LocalCisHit Wise2_hard_link_LocalCisHit /* Function: LocalCisHit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalCisHit *] * */ LocalCisHit * Wise2_LocalCisHit_alloc(void); #define LocalCisHit_alloc Wise2_LocalCisHit_alloc /* Function: free_LocalCisHit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalCisHit *] * * Return [UNKN ] Undocumented return value [LocalCisHit *] * */ LocalCisHit * Wise2_free_LocalCisHit(LocalCisHit * obj); #define free_LocalCisHit Wise2_free_LocalCisHit /* Function: add_LocalCisHitSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LocalCisHitSet *] * Arg: add [OWNER] Object to add to the list [LocalCisHit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_LocalCisHitSet(LocalCisHitSet * obj,LocalCisHit * add); #define add_LocalCisHitSet Wise2_add_LocalCisHitSet /* Function: flush_LocalCisHitSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LocalCisHitSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_LocalCisHitSet(LocalCisHitSet * obj); #define flush_LocalCisHitSet Wise2_flush_LocalCisHitSet /* Function: LocalCisHitSet_alloc_std(void) * * Descrip: Equivalent to LocalCisHitSet_alloc_len(LocalCisHitSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [LocalCisHitSet *] * */ LocalCisHitSet * Wise2_LocalCisHitSet_alloc_std(void); #define LocalCisHitSet_alloc_std Wise2_LocalCisHitSet_alloc_std /* Function: LocalCisHitSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [LocalCisHitSet *] * */ LocalCisHitSet * Wise2_LocalCisHitSet_alloc_len(int len); #define LocalCisHitSet_alloc_len Wise2_LocalCisHitSet_alloc_len /* Function: hard_link_LocalCisHitSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LocalCisHitSet *] * * Return [UNKN ] Undocumented return value [LocalCisHitSet *] * */ LocalCisHitSet * Wise2_hard_link_LocalCisHitSet(LocalCisHitSet * obj); #define hard_link_LocalCisHitSet Wise2_hard_link_LocalCisHitSet /* Function: LocalCisHitSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalCisHitSet *] * */ LocalCisHitSet * Wise2_LocalCisHitSet_alloc(void); #define LocalCisHitSet_alloc Wise2_LocalCisHitSet_alloc /* Function: free_LocalCisHitSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalCisHitSet *] * * Return [UNKN ] Undocumented return value [LocalCisHitSet *] * */ LocalCisHitSet * Wise2_free_LocalCisHitSet(LocalCisHitSet * obj); #define free_LocalCisHitSet Wise2_free_LocalCisHitSet /* Function: hard_link_LocalCisHitSetPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LocalCisHitSetPara *] * * Return [UNKN ] Undocumented return value [LocalCisHitSetPara *] * */ LocalCisHitSetPara * Wise2_hard_link_LocalCisHitSetPara(LocalCisHitSetPara * obj); #define hard_link_LocalCisHitSetPara Wise2_hard_link_LocalCisHitSetPara /* Function: LocalCisHitSetPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LocalCisHitSetPara *] * */ LocalCisHitSetPara * Wise2_LocalCisHitSetPara_alloc(void); #define LocalCisHitSetPara_alloc Wise2_LocalCisHitSetPara_alloc /* Function: free_LocalCisHitSetPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LocalCisHitSetPara *] * * Return [UNKN ] Undocumented return value [LocalCisHitSetPara *] * */ LocalCisHitSetPara * Wise2_free_LocalCisHitSetPara(LocalCisHitSetPara * obj); #define free_LocalCisHitSetPara Wise2_free_LocalCisHitSetPara /* Unplaced functions */ /* There has been no indication of the use of these functions */ HitList * Wise2_HitList_from_LocalCisHitSet(LocalCisHitSet * in); #define HitList_from_LocalCisHitSet Wise2_HitList_from_LocalCisHitSet LocalCisHitSet * Wise2_expand_to_subhits_LocalCisHitSet(LocalCisHitSet * in); #define expand_to_subhits_LocalCisHitSet Wise2_expand_to_subhits_LocalCisHitSet void Wise2_show_help_LocalCisHitSetPara(FILE * ofp); #define show_help_LocalCisHitSetPara Wise2_show_help_LocalCisHitSetPara LocalCisHitSetPara * Wise2_new_LocalCisHitSetPara_from_argv(int * argc,char ** argv); #define new_LocalCisHitSetPara_from_argv Wise2_new_LocalCisHitSetPara_from_argv void Wise2_show_pretty_LocalCisHitSet(LocalCisHitSet * lchs,FILE * ofp); #define show_pretty_LocalCisHitSet Wise2_show_pretty_LocalCisHitSet void Wise2_show_summary_LocalCisHitSet(LocalCisHitSet * lchs,FILE * ofp); #define show_summary_LocalCisHitSet Wise2_show_summary_LocalCisHitSet LocalCisHitSet * Wise2_greedy_weed_LocalCisHitSet(LocalCisHitSet * set,LocalCisHitSetPara *p); #define greedy_weed_LocalCisHitSet Wise2_greedy_weed_LocalCisHitSet void Wise2_sort_LocalCisHitSet_by_score(LocalCisHitSet * set); #define sort_LocalCisHitSet_by_score Wise2_sort_LocalCisHitSet_by_score void Wise2_sort_LocalCisHitSet_by_start(LocalCisHitSet * set); #define sort_LocalCisHitSet_by_start Wise2_sort_LocalCisHitSet_by_start int Wise2_compare_LocalCisHit_score(LocalCisHit * a,LocalCisHit * b); #define compare_LocalCisHit_score Wise2_compare_LocalCisHit_score int Wise2_compare_LocalCisHit_start(LocalCisHit * a,LocalCisHit * b); #define compare_LocalCisHit_start Wise2_compare_LocalCisHit_start int Wise2_is_query_overlap_LocalCisHit(LocalCisHit * a,LocalCisHit * b); #define is_query_overlap_LocalCisHit Wise2_is_query_overlap_LocalCisHit int Wise2_is_target_overlap_LocalCisHit(LocalCisHit * a,LocalCisHit * b); #define is_target_overlap_LocalCisHit Wise2_is_target_overlap_LocalCisHit int Wise2_is_consumed_HSP(HSP * a,int q_start,int q_end,int t_start,int t_end); #define is_consumed_HSP Wise2_is_consumed_HSP LocalCisHitSet * Wise2_make_LocalCisHitSet(Sequence * query,Sequence * target,Sequence * target_rev,HSPset * forward,HSPset * reverse,LocalCisHitSetPara * p,LocalCisHitScore * scorepara,TransFactorMatchSet * tfms_query,TransFactorMatchSet * tfms_target,TransFactorMatchSet * tfms_target_rev,MotifMatrixScore * mms,boolean use_motif,DPRunImpl * dpri); #define make_LocalCisHitSet Wise2_make_LocalCisHitSet LocalCisHit * Wise2_make_LocalCisHit(Sequence * query,Sequence * target,int is_reversed,int guess_q_start,int guess_q_end,int guess_t_start,int guess_t_end,LocalCisHitScore * score,DPRunImpl * dpri); #define make_LocalCisHit Wise2_make_LocalCisHit LocalCisHit * Wise2_make_motif_LocalCisHit(Sequence * query,Sequence * target,int is_reversed,int guess_q_start,int guess_q_end,int guess_t_start,int guess_t_end,TransFactorMatchSet * tfms_query,TransFactorMatchSet * tfms_target,MotifMatrixScore * mms,DPRunImpl * dpri); #define make_motif_LocalCisHit Wise2_make_motif_LocalCisHit /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_LocalCisHitSet(LocalCisHit ** list,int i,int j) ; #define swap_LocalCisHitSet Wise2_swap_LocalCisHitSet void Wise2_qsort_LocalCisHitSet(LocalCisHit ** list,int left,int right,int (*comp)(LocalCisHit * ,LocalCisHit * )); #define qsort_LocalCisHitSet Wise2_qsort_LocalCisHitSet void Wise2_sort_LocalCisHitSet(LocalCisHitSet * obj,int (*comp)(LocalCisHit *, LocalCisHit *)); #define sort_LocalCisHitSet Wise2_sort_LocalCisHitSet boolean Wise2_expand_LocalCisHitSet(LocalCisHitSet * obj,int len); #define expand_LocalCisHitSet Wise2_expand_LocalCisHitSet #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/estfrag3.dy0000644000175000001440000001357007313404543016210 0ustar philippusers/* Last edited: Apr 24 15:04 1997 (birney) */ %{ #include "dyna.h" #include "cdparser.h" #include "genewisemodel.h" #include "genewisemodeldb.h" %} type CDNA_HMM real GeneWiseScore* dbtype GeneWiseDB* init init_GeneWiseDB reload reload_GeneWiseDB close close_GeneWiseDB addentry dataentry_add_GeneWiseDB maxlen 1500 endtype matrix EstFrag3 query type="CDNA_HMM" name="query" field:len="len" target type="CDNA" name="target" resource type="cDNAParserScore *" name="cp" resource type="Score" name="start_frag" resource type="Score" name="end_frag" extern name="GW_*" type="int" extern name="PCD_*" type="int" globaldefaultscore NEGI state MATCH offi="1" offj="3" source MATCH calc="query->seg[i]->transition[GW_MATCH2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2MATCH] + query->seg[i]->match[CDNA_CODON(target,j)]" endsource source START !left calc="start_frag + query->seg[i]->match[CDNA_CODON(target,j)]" endsource # # Sequencing error transitions, at offsets 1,2,4,5 for delete 1,2 or insert 1,2 # source MATCH offi="1" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="1" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source MATCH offi="1" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource source INSERT offi="1" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="1" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="1" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source INSERT offi="1" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource source DELETE offi="1" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source DELETE offi="1" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source DELETE offi="1" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source DELETE offi="1" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource query_label MATCH_STATE target_label CODON endstate # # Insert state: does not move along model, produces DNA sequence... # state INSERT offi="0" offj="3" source MATCH calc="query->seg[i]->transition[GW_MATCH2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource source START calc="query->seg[i]->transition[GW_START2INSERT] + query->seg[i]->insert[CDNA_CODON(target,j)]" endsource # # Sequencing error transitions # source INSERT offi="0" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source INSERT offi="0" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source INSERT offi="0" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource source MATCH offi="0" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="0" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source MATCH offi="0" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source MATCH offi="0" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource source DELETE offi="0" offj="2" calc="cp->trans[PCD_DELETE_1_BASE]" target_label SEQUENCE_DELETION endsource source DELETE offi="0" offj="1" calc="cp->trans[PCD_DELETE_2_BASE]" target_label SEQUENCE_DELETION endsource source DELETE offi="0" offj="4" calc="cp->trans[PCD_INSERT_1_BASE]" target_label SEQUENCE_INSERTION endsource source DELETE offi="0" offj="5" calc="cp->trans[PCD_INSERT_2_BASE]" target_label SEQUENCE_INSERTION endsource query_label INSERT_STATE target_label CODON endstate state DELETE offi="1" offj="0" source MATCH calc="query->seg[i]->transition[GW_MATCH2DELETE]" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2DELETE]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2DELETE]" endsource source START calc="query->seg[i]->transition[GW_START2DELETE]" endsource query_label DELETE_STATE target_label INSERT endstate state START !start !special defscore="0" endstate state END !end !special source MATCH calc="query->seg[i]->transition[GW_MATCH2END]" endsource source MATCH !right calc="end_frag" endsource source INSERT calc="query->seg[i]->transition[GW_INSERT2END]" endsource source DELETE calc="query->seg[i]->transition[GW_DELETE2END]" endsource target_label END query_label END endstate endmatrix wise-2.4.1/src/models/estloop3.c0000644000175000001440000107213210670453713016053 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "estloop3.h" # line 5 "estloop3.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define LOOP 0 #define START 1 #define END 2 #define EstLoop3_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+5)*3)+STATE][i+1] #define EstLoop3_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+5] #define EstLoop3_READ_OFF_ERROR -7 #define EstLoop3_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+6)%6][((i+1)*3)+STATE] #define EstLoop3_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+6)%6][STATE] #define EstLoop3_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define EstLoop3_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_EstLoop3(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_EstLoop3(EstLoop3 * mat) { EstLoop3_access_func_holder holder; holder.access_main = EstLoop3_shatter_access_main; holder.access_special = EstLoop3_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_EstLoop3(mat,holder); } /* Function: EstLoop3_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstLoop3_shatter_access_main(EstLoop3 * mat,int i,int j,int state) { return EstLoop3_SHATTER_MATRIX(mat,i,j,state); } /* Function: EstLoop3_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstLoop3_shatter_access_special(EstLoop3 * mat,int i,int j,int state) { return EstLoop3_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_EstLoop3(mat,dpenv) * * Descrip: This function calculates the EstLoop3 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EstLoop3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_EstLoop3(EstLoop3 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_2; int * SIG_1_1; int * SIG_1_4; int * SIG_1_5; int * SIG_0_3; int * SIG_0_2; int * SIG_0_1; int * SIG_0_4; int * SIG_0_5; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,3); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("EstLoop3 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_1_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-5); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_0_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-5); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = EstLoop3_SHATTER_SPECIAL(mat,i-1,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstLoop3_SHATTER_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_1[MATCH] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_4[MATCH] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_5[MATCH] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_2[INSERT] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_1[INSERT] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_4[INSERT] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_5[INSERT] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_2[DELETE] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_1[DELETE] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_4[DELETE] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_5[DELETE] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ SIG_0_0[MATCH] = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstLoop3_SHATTER_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstLoop3_SHATTER_SPECIAL(mat,i,j,END) ) { EstLoop3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_3[DELETE] + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = EstLoop3_SHATTER_SPECIAL(mat,i-0,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_2[INSERT] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_4[INSERT] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_5[INSERT] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = SIG_0_2[MATCH] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = SIG_0_1[MATCH] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = SIG_0_4[MATCH] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = SIG_0_5[MATCH] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_2[DELETE] + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_1[DELETE] + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_4[DELETE] + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_5[DELETE] + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ SIG_0_0[INSERT] = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstLoop3_SHATTER_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstLoop3_SHATTER_SPECIAL(mat,i,j,END) ) { EstLoop3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state LOOP to state DELETE */ temp = EstLoop3_SHATTER_SPECIAL(mat,i-1,j-0,LOOP) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstLoop3_SHATTER_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstLoop3_SHATTER_SPECIAL(mat,i,j,END) ) { EstLoop3_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstLoop3_SHATTER_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = EstLoop3_SHATTER_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = EstLoop3_SHATTER_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ EstLoop3_SHATTER_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstLoop3_SHATTER_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = EstLoop3_SHATTER_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Put back score... (now updated!) */ EstLoop3_SHATTER_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: search_EstLoop3(dbsi,out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstLoop3 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_EstLoop3(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_EstLoop3 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_EstLoop3. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_EstLoop3. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for EstLoop3, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_EstLoop3(out,querydb, targetdb ,cp); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_EstLoop3 *) ckalloc(sizeof(struct thread_pool_holder_EstLoop3)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->querydb = querydb; holder->targetdb = targetdb; holder->cp = cp; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_EstLoop3,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for EstLoop3"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from EstLoop3",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_EstLoop3(ptr) * * Descrip: Infinite loop code foreach thread for EstLoop3 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ #ifdef PTHREAD void * thread_loop_EstLoop3(void * ptr) { struct thread_pool_holder_EstLoop3 * holder; int db_status; int score; DataScore * ds; GeneWiseScore* query; ComplexSequence* target; holder = (struct thread_pool_holder_EstLoop3 *) ptr; if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Entering infinite loop for thread...\n"); while(1) { /*Infinite loop over all models*/ /* Get input lock */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for main reload\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for EstLoop3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for main reload\n"); if( holder->search_has_ended == TRUE ) { if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Database search finished for me!...\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstLoop3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released lock and broken out of loop\n"); break; } /* Get storage space now, as we have to read in the info for the db now */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Getting new DataScore from storage...\n"); ds = new_DataScore(); /* We need to get our query object */ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting query database...\n"); if( holder->query_init == FALSE) { holder->query = init_GeneWiseDB(holder->querydb,&db_status); holder->query_init = TRUE; if( db_status == DB_RETURN_ERROR ) fatal("Unable to initalise query database in EstLoop3 search"); } query = hard_link_GeneWiseScore(holder->query); /* get query information into datascore */ dataentry_add_GeneWiseDB(ds->query,query,holder->querydb); if( holder->target_init == FALSE ) { /*if the db has not been init'd*/ if ( holder->dbsi->trace_level >= 3 ) fprintf(holder->dbsi->trace_file,"Starting target database...\n"); target = init_cDNADB(holder->targetdb,&db_status); holder->target_init = TRUE; } /* end of if the db has not been init'd */ else { /*Normal reload*/ target = reload_cDNADB(NULL,holder->targetdb,&db_status); } /* end of Normal reload */ /* Check to see what the reload is like */ if( db_status == DB_RETURN_ERROR ) { fatal("In searching EstLoop3, Reload error on database target, in threads"); } if( db_status == DB_RETURN_END) { /*End of target database*/ /* close target database and schedule it for initalisation by next thread */ close_cDNADB(NULL,holder->targetdb); holder->target_init = FALSE; if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Target Database to be reloaded...\n"); /* free'ing the query object */ free_GeneWiseScore(holder->query); /* get the next query object for the next thread */ holder->query = reload_GeneWiseDB(NULL,holder->querydb,&db_status); if( db_status == DB_RETURN_ERROR ) fatal("In searching EstLoop3, reload error on database query, in threads"); if( db_status == DB_RETURN_END ) { /*last load!*/ /* End of target and query database - finished search! */ close_GeneWiseDB(NULL,holder->querydb); holder->search_has_ended = TRUE; } /* end of last load! */ /* release input mutex */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after end of target\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstLoop3"); continue; } /* end of End of target database */ else { /*Normal reload*/ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock for normal reload\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstLoop3"); } /* end of Normal reload */ /* get target information into datascore */ dataentry_add_cDNADB(ds->target,target,holder->targetdb); /* Now there is a new query/target pair ready for comparison */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"A new pair to be compared...\n"); score = score_only_EstLoop3(query, target ,holder->cp); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Getting output lock\n"); /* Getting lock on output */ if( pthread_mutex_lock(&(holder->output_lock))!= 0 ) fatal("Error on getting output lock for EstLoop3"); /* If the score is less than cutoff, schedule the datascore for reuse */ if( should_store_Hscore(holder->out,score) != TRUE) { free_DataScore(ds); } else { /*storing score*/ ds->score = score; add_Hscore(holder->out,ds); } /* end of storing score */ if( pthread_mutex_unlock(&(holder->output_lock))!= 0 ) fatal("Error on releasing output lock for EstLoop3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Released output lock\n"); /* Now free database objects */ if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"About to get input lock for free func\n"); if( pthread_mutex_lock(&(holder->input_lock))!= 0 ) fatal("Error on getting input lock for EstLoop3"); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Got input lock for free func\n"); free_GeneWiseScore(query); free_ComplexSequence(target); if ( holder->dbsi->trace_level >= 2 ) fprintf(holder->dbsi->trace_file,"Releasing input lock after free'ing\n"); if( pthread_mutex_unlock(&(holder->input_lock))!= 0 ) fatal("Error in releasing input lock for EstLoop3"); } /* end of Infinite loop over all models */ if ( holder->dbsi->trace_level >= 1 ) fprintf(holder->dbsi->trace_file,"Exiting forever loop\n"); return NULL; } /* Function: serial_search_EstLoop3(out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstLoop3 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ #endif /* PTHREAD */ Search_Return_Type serial_search_EstLoop3(Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp) { GeneWiseScore* query; ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); query = init_GeneWiseDB(querydb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstLoop3, got a database reload error on the query [query] database"); return SEARCH_ERROR; } for(;;) { /*For all query entries*/ target_pos = 0; target = init_cDNADB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstLoop3, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_EstLoop3(query, target , cp); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("EstLoop3 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GeneWiseDB(ds->query,query,querydb); dataentry_add_cDNADB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_cDNADB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching EstLoop3, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break;/* Out of target loop */ target_pos++; } /* end of For all target entries */ close_cDNADB(target,targetdb); query = reload_GeneWiseDB(query,querydb,&db_status); if( db_status == DB_RETURN_ERROR) { warn("In searching EstLoop3, Reload error on database query, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END) break; /* Out of query loop */ query_pos++; } /* end of For all query entries */ close_GeneWiseDB(query,querydb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_EstLoop3(query,target,cp) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_EstLoop3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_EstLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp) { int bestscore = NEGI; int i; int j; int k; EstLoop3 * mat; mat = allocate_EstLoop3_only(query, target , cp); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(6,(mat->leni + 1) * 3,6,3)) == NULL) { warn("Score only matrix for EstLoop3 cannot be allocated, (asking for 5 by %d cells)",mat->leni*3); mat = free_EstLoop3(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<7;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) EstLoop3_VSMALL_MATRIX(mat,i,j,k) = NEGI; } EstLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) = NEGI; EstLoop3_VSMALL_SPECIAL(mat,i,j,START) = 0; EstLoop3_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = EstLoop3_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = EstLoop3_VSMALL_SPECIAL(mat,i-1,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstLoop3_VSMALL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstLoop3_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstLoop3_VSMALL_SPECIAL(mat,i,j,END) ) { EstLoop3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstLoop3_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = EstLoop3_VSMALL_SPECIAL(mat,i-0,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_VSMALL_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstLoop3_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstLoop3_VSMALL_SPECIAL(mat,i,j,END) ) { EstLoop3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstLoop3_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstLoop3_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state LOOP to state DELETE */ temp = EstLoop3_VSMALL_SPECIAL(mat,i-1,j-0,LOOP) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstLoop3_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstLoop3_VSMALL_SPECIAL(mat,i,j,END) ) { EstLoop3_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* end of for all query positions */ /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstLoop3_VSMALL_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = EstLoop3_VSMALL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = EstLoop3_VSMALL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ EstLoop3_VSMALL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstLoop3_VSMALL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = EstLoop3_VSMALL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Put back score... (now updated!) */ EstLoop3_VSMALL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ if( bestscore < EstLoop3_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = EstLoop3_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_EstLoop3(mat); return bestscore; } /* Function: PackAln_bestmemory_EstLoop3(query,target,cp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EstLoop3 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_EstLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; EstLoop3 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_EstLoop3(query, target , cp,dpri)) == NULL ) { warn("Unable to allocate large EstLoop3 version"); return NULL; } calculate_dpenv_EstLoop3(mat,dpenv); out = PackAln_read_Expl_EstLoop3(mat); } else { mat = allocate_EstLoop3_only(query, target , cp); calculate_shatter_EstLoop3(mat,dpenv); out = PackAln_read_Shatter_EstLoop3(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_EstLoop3(query, target , cp)) == NULL ) { warn("Unable to allocate small EstLoop3 version"); return NULL; } out = PackAln_calculate_Small_EstLoop3(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_EstLoop3(query, target , cp,dpri)) == NULL ) { warn("Unable to allocate large EstLoop3 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_EstLoop3(mat); out = PackAln_read_Expl_EstLoop3(mat); } } } mat = free_EstLoop3(mat); return out; } /* Function: allocate_EstLoop3_only(query,target,cp) * * Descrip: This function only allocates the EstLoop3 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstLoop3 *] * */ EstLoop3 * allocate_EstLoop3_only(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp) { EstLoop3 * out; if((out= EstLoop3_alloc()) == NULL) { warn("Allocation of basic EstLoop3 structure failed..."); return NULL; } out->query = query; out->target = target; out->cp = cp; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_EstLoop3(query,target,cp,dpri) * * Descrip: This function allocates the EstLoop3 structure * and the basematrix area for explicit memory implementations * It calls /allocate_EstLoop3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EstLoop3 *] * */ EstLoop3 * allocate_Expl_EstLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPRunImpl * dpri) { EstLoop3 * out; out = allocate_EstLoop3_only(query, target , cp); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+5)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+5)*3,(out->leni+1),3,out->lenj+5)) == NULL) { warn("Explicit matrix EstLoop3 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_EstLoop3(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_EstLoop3(out); return out; } /* Function: init_EstLoop3(mat) * * Descrip: This function initates EstLoop3 matrix when in explicit mode * Called in /allocate_Expl_EstLoop3 * * * Arg: mat [UNKN ] EstLoop3 which contains explicit basematrix memory [EstLoop3 *] * */ void init_EstLoop3(EstLoop3 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-5);j<6;j++) { EstLoop3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstLoop3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstLoop3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j= (-5);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { EstLoop3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstLoop3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstLoop3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = NEGI; EstLoop3_EXPL_SPECIAL(mat,i,j,START) = 0; EstLoop3_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_EstLoop3(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EstLoop3 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * */ void recalculate_PackAln_EstLoop3(PackAln * pal,EstLoop3 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (LOOP+3) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (START+3) ) { pau->score = (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 1 && offj == 4 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 1 && offj == 5 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } if( offi == 1 && offj == 2 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 1 && offj == 4 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 1 && offj == 5 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } if( offi == 1 && offj == 2 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 1 && offj == 1 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 1 && offj == 4 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 1 && offj == 5 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offj == 3 && prev->state == (LOOP+3) ) { pau->score = (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 0 && offj == 5 && prev->state == INSERT ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } if( offi == 0 && offj == 2 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 0 && offj == 5 && prev->state == MATCH ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } if( offi == 0 && offj == 2 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_DELETE_1_BASE] + (0); continue; } if( offi == 0 && offj == 1 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_DELETE_2_BASE] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_INSERT_1_BASE] + (0); continue; } if( offi == 0 && offj == 5 && prev->state == DELETE ) { pau->score = mat->cp->trans[PCD_INSERT_2_BASE] + (0); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->seg[i]->transition[GW_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (LOOP+3) ) { pau->score = mat->query->seg[i]->transition[GW_START2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (LOOP+3) : if( offj == 1 && prev->state == (START+3) ) { pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } if( offj == 1 && prev->state == (LOOP+3) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state LOOP, got a bad source state. Error!"); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+3) : if( offj == 1 && prev->state == (LOOP+3) ) { pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->seg[i]->transition[GW_DELETE2END] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define EstLoop3_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+5)][(i+1)*3+state]) #define EstLoop3_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+6)*8) % 48][(i+1)*3+state]) #define EstLoop3_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+5)]) #define EstLoop3_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+5)]) #define EstLoop3_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+6)*8)+(shadow+1)) % 48)][(i+1)*3 + state]) #define EstLoop3_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+5)]) #define EstLoop3_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+5)% 5) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define EstLoop3_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+5)% 5) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define EstLoop3_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+5)]) /* Function: allocate_Small_EstLoop3(query,target,cp) * * Descrip: This function allocates the EstLoop3 structure * and the basematrix area for a small memory implementations * It calls /allocate_EstLoop3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstLoop3 *] * */ #define EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+5)]) EstLoop3 * allocate_Small_EstLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp) { EstLoop3 * out; out = allocate_EstLoop3_only(query, target , cp); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(48,(out->leni + 1) * 3,24,out->lenj+5); if(out == NULL) { warn("Small shadow matrix EstLoop3 cannot be allocated, (asking for 6 by %d main cells)",out->leni+2); free_EstLoop3(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_EstLoop3(mat,dpenv) * * Descrip: This function calculates an alignment for EstLoop3 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EstLoop3 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EstLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_EstLoop3(EstLoop3 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for EstLoop3 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_EstLoop3(mat,dpenv); score = start_end_find_end_EstLoop3(mat,&endj); out->score = score; stopstate = END; /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */ log_full_error(REPORT,0,"End at %d Score %d",endj,score); stop_reporting(); for(;;) { /*while there are more special bits to recover*/ start_reporting("Special cell aln end %d:",endj); if( read_special_strip_EstLoop3(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) { warn("Problem in reading off special state system... going to return partial alignment"); break; } if( startstate == START || endj <= 0) { log_full_error(REPORT,0,"Recovered complete alignment"); stop_reporting(); break; } log_full_error(REPORT,0,"Finished to %d",endj); stop_reporting(); /* Ok... have to eat up another piece of matrix */ temp = startstate; starti = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0); startj = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1); startstate = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2); stopi = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3); stopj = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4); stopstate = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5); /* Get out the score of this block. V. important! */ temp = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6); totalj = stopj - startj; donej = 0; start_reporting("Main matrix aln [%d,%d]:",startj,stopj); if(full_dc_EstLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) { warn("In the alignment EstLoop3 [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj); return out; } /* now have to figure out which special we came from... yikes */ max_matrix_to_special_EstLoop3(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == EstLoop3_READ_OFF_ERROR) { warn("In EstLoop3 read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj); invert_PackAln(out); recalculate_PackAln_EstLoop3(out,mat); return out; } /* if at start, break, otherwise, back to eat another strip */ if( stopstate == START) { log_full_error(REPORT,0,"Recovered complete alignment "); stop_reporting(); break; } log_full_error(REPORT,0,"Finished alignment to %d ",startj); stop_reporting(); endj = stopj; /* stopstate is correct as it is */ } /* end of while there are more special bits to recover */ invert_PackAln(out); recalculate_PackAln_EstLoop3(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_EstLoop3(mat) * * Descrip: This function calculates an alignment for EstLoop3 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EstLoop3 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EstLoop3 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EstLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_EstLoop3(EstLoop3 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_EstLoop3(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_EstLoop3(mat); return out; } /* Function: AlnRangeSet_from_EstLoop3(mat) * * Descrip: This function reads off a start/end structure * for EstLoop3 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EstLoop3 * If you have not calculated the matrix use * /AlnRange_calculate_Small_EstLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_EstLoop3(EstLoop3 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EstLoop3"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_EstLoop3(mat,&jpos); state = END; while( (temp = AlnRange_build_EstLoop3(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_EstLoop3(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_EstLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_EstLoop3(EstLoop3 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_EstLoop3"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_EstLoop3(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_EstLoop3 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = EstLoop3_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_EstLoop3(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == EstLoop3_READ_OFF_ERROR) { warn("In AlnRange_build_EstLoop3 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = EstLoop3_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_EstLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_EstLoop3(EstLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_EstLoop3(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EstLoop3_READ_OFF_ERROR) { warn("In EstLoop3 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In EstLoop3 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In EstLoop3 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_EstLoop3(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_EstLoop3(EstLoop3 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstLoop3_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In EstLoop3 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = EstLoop3_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 5,DELETE) ) { *reti = i - 1; *retj = j - 5; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-5,DELETE); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 5,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 4,DELETE) ) { *reti = i - 1; *retj = j - 4; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-4,DELETE); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 4,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-1,DELETE); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 2,DELETE) ) { *reti = i - 1; *retj = j - 2; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-2,DELETE); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 2,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 5,INSERT) ) { *reti = i - 1; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-5,INSERT); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 5,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 4,INSERT) ) { *reti = i - 1; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-4,INSERT); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 2,INSERT) ) { *reti = i - 1; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-2,INSERT); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 2,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-5,MATCH); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-4,MATCH); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } /* Not allowing special sources.. skipping START */ /* Not allowing special sources.. skipping LOOP */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in EstLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 5,DELETE) ) { *reti = i - 0; *retj = j - 5; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-5,DELETE); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 5,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 4,DELETE) ) { *reti = i - 0; *retj = j - 4; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-4,DELETE); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 4,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 1,DELETE) ) { *reti = i - 0; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-1,DELETE); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 1,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 2,DELETE) ) { *reti = i - 0; *retj = j - 2; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-2,DELETE); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 2,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 5,MATCH) ) { *reti = i - 0; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-5,MATCH); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 5,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 4,MATCH) ) { *reti = i - 0; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-4,MATCH); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 2,MATCH) ) { *reti = i - 0; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-2,MATCH); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 2,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 5,INSERT) ) { *reti = i - 0; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-5,INSERT); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 5,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 4,INSERT) ) { *reti = i - 0; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-4,INSERT); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } /* Not allowing special sources.. skipping LOOP */ temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-3,DELETE); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return EstLoop3_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in EstLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Not allowing special sources.. skipping LOOP */ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return EstLoop3_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in EstLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_EstLoop3(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_EstLoop3(EstLoop3 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > EstLoop3_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_EstLoop3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == EstLoop3_READ_OFF_ERROR) { warn("In special strip read EstLoop3, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < EstLoop3_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read EstLoop3, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_EstLoop3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_EstLoop3(EstLoop3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = EstLoop3_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for EstLoop3, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In EstLoop3 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = EstLoop3_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case LOOP : /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == EstLoop3_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_DC_SHADOW_SPECIAL(mat,i-0,j-1,LOOP); } return EstLoop3_DC_SHADOW_MATRIX(mat,i - 0,j - 1,LOOP) ; } /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ /* source START is a special */ temp = cscore - (0) - (0); if( temp == EstLoop3_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return EstLoop3_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } case START : case END : /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == EstLoop3_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_DC_SHADOW_SPECIAL(mat,i-0,j-1,LOOP); } return EstLoop3_DC_SHADOW_MATRIX(mat,i - 0,j - 1,LOOP) ; } default: warn("Major problem (!) - in EstLoop3 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_EstLoop3(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_EstLoop3(EstLoop3 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = EstLoop3_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In EstLoop3 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstLoop3_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_DC_SHADOW_SPECIAL(mat,i-1,j-3,START); } return EstLoop3_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ; } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstLoop3_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,LOOP) ) { *reti = i - 1; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_DC_SHADOW_SPECIAL(mat,i-1,j-3,LOOP); } return EstLoop3_DC_SHADOW_MATRIX(mat,i - 1,j - 3,LOOP) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstLoop3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source DELETE is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == EstLoop3_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,LOOP) ) { *reti = i - 0; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_DC_SHADOW_SPECIAL(mat,i-0,j-3,LOOP); } return EstLoop3_DC_SHADOW_MATRIX(mat,i - 0,j - 3,LOOP) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstLoop3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == EstLoop3_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,LOOP) ) { *reti = i - 1; *retj = j - 0; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - EstLoop3_DC_SHADOW_SPECIAL(mat,i-1,j-0,LOOP); } return EstLoop3_DC_SHADOW_MATRIX(mat,i - 1,j - 0,LOOP) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in EstLoop3 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_EstLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_EstLoop3(EstLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_EstLoop3(mat,starti,startj,stopi,stopj); EstLoop3_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstLoop3_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; EstLoop3_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; EstLoop3_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstLoop3_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstLoop3_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstLoop3_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstLoop3_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } } return; } /* Function: init_hidden_EstLoop3(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_EstLoop3(EstLoop3 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-5);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { EstLoop3_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; EstLoop3_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; EstLoop3_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; } } return; } /* Function: full_dc_EstLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_EstLoop3 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_EstLoop3 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [EstLoop3 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_EstLoop3(EstLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_EstLoop3"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 25) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_EstLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_EstLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_EstLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for EstLoop3, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= EstLoop3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= EstLoop3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = EstLoop3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_EstLoop3(mat,EstLoop3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),EstLoop3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),EstLoop3_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_EstLoop3(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_EstLoop3(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_EstLoop3(EstLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_EstLoop3(mat); EstLoop3_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_EstLoop3(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_EstLoop3(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_EstLoop3(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_EstLoop3(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_EstLoop3(EstLoop3 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<5;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); EstLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); EstLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( j - 3 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,DELETE,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,DELETE,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,DELETE,k); } } /* Add any movement independant score */ EstLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( j - 3 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INSERT,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,MATCH,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,MATCH,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,DELETE,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,DELETE,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,DELETE,k); } } /* Add any movement independant score */ EstLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ EstLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_EstLoop3(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_EstLoop3(EstLoop3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state MATCH to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } /* From state MATCH to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } /* From state MATCH to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } /* From state INSERT to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,k); } /* From state INSERT to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* From state INSERT to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,k); } /* From state INSERT to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,k); } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,DELETE,k); } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,DELETE,k); } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,DELETE,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } /* From state INSERT to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* From state INSERT to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,k); } /* From state INSERT to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INSERT,k); } /* From state MATCH to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,k); } /* From state MATCH to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } /* From state MATCH to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,MATCH,k); } /* From state MATCH to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,MATCH,k); } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,DELETE,k); } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,k); } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,DELETE,k); } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,DELETE,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = EstLoop3_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_EstLoop3(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_EstLoop3(EstLoop3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ EstLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstLoop3_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_EstLoop3(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * */ } void init_dc_EstLoop3(EstLoop3 * mat) { register int i; register int j; register int k; for(j=0;j<7;j++) { for(i=(-1);iquery->len;i++) { EstLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; for(k=0;k<7;k++) { EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); } } } return; } /* Function: start_end_find_end_EstLoop3(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [EstLoop3 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_EstLoop3(EstLoop3 * mat,int * endj) { register int j; register int max; register int maxj; max = EstLoop3_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( EstLoop3_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = EstLoop3_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_EstLoop3(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [EstLoop3] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_EstLoop3(EstLoop3 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (5 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (5 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state LOOP to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [LOOP] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state START to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state MATCH to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); } /* From state MATCH to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0)); } /* From state MATCH to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,0)); } /* From state INSERT to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,INSERT,0)); } /* From state INSERT to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* From state INSERT to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INSERT,0)); } /* From state INSERT to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INSERT,0)); } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,DELETE,0)); } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,0)); } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,DELETE,0)); } /* From state DELETE to state MATCH */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,DELETE,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = MATCH; } /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0)); } /* From state LOOP to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* This state [LOOP] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INSERT to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* From state INSERT to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INSERT,0)); } /* From state INSERT to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INSERT,0)); } /* From state MATCH to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,MATCH,0)); } /* From state MATCH to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); } /* From state MATCH to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,MATCH,0)); } /* From state MATCH to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,MATCH,0)); } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,DELETE,0)); } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,0)); } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,DELETE,0)); } /* From state DELETE to state INSERT */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,DELETE,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = INSERT; } /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state LOOP to state DELETE */ temp = EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,LOOP) + mat->query->seg[i]->transition[GW_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [LOOP] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ EstLoop3_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = DELETE; } /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = EstLoop3_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = DELETE; } /* Finished calculating state DELETE */ } /* end of for each i position in strip */ /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ temp = EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,START,k); } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,LOOP,k); } /* Put back score... (now updated!) */ EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ temp = EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = EstLoop3_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,LOOP,k); } /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Put back score... (now updated!) */ EstLoop3_DC_OPT_SHADOW_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_EstLoop3(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * */ void init_start_end_linear_EstLoop3(EstLoop3 * mat) { register int i; register int j; for(j=0;j<7;j++) { for(i=(-1);iquery->len;i++) { EstLoop3_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); EstLoop3_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); EstLoop3_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; EstLoop3_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); } } for(j=(-5);jtarget->seq->len;j++) { EstLoop3_DC_SHADOW_SPECIAL(mat,0,j,LOOP) = NEGI; EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,j,LOOP,0) = (-1); EstLoop3_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; EstLoop3_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; EstLoop3_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_EstLoop3(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_EstLoop3(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_EstLoop3(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","LOOP","END" }; /* Function: AlnConvertSet_EstLoop3(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","RANDOM_SEQUENCE","END" }; AlnConvertSet * AlnConvertSet_EstLoop3(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 3; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 3; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 3; acu->state2 = LOOP + 3; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 3; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[5]; add_collapse_label_AlnConvertSet(out,"LOOP","RANDOM_SEQUENCE"); return out; } /* Function: PackAln_read_Expl_EstLoop3(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_EstLoop3(EstLoop3 * mat) { EstLoop3_access_func_holder holder; holder.access_main = EstLoop3_explicit_access_main; holder.access_special = EstLoop3_explicit_access_special; return PackAln_read_generic_EstLoop3(mat,holder); } /* Function: EstLoop3_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstLoop3_explicit_access_main(EstLoop3 * mat,int i,int j,int state) { return EstLoop3_EXPL_MATRIX(mat,i,j,state); } /* Function: EstLoop3_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int EstLoop3_explicit_access_special(EstLoop3 * mat,int i,int j,int state) { return EstLoop3_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_EstLoop3(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: h [UNKN ] Undocumented argument [EstLoop3_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_EstLoop3(EstLoop3 * mat,EstLoop3_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_EstLoop3(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in EstLoop3_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_EstLoop3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_EstLoop3(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == EstLoop3_READ_OFF_ERROR || j == EstLoop3_READ_OFF_ERROR || state == EstLoop3_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in EstLoop3_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_EstLoop3(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [EstLoop3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_EstLoop3(EstLoop3 * mat,int * ri,int * rj,int * state,boolean * isspecial,EstLoop3_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: EstLoop3_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void EstLoop3_debug_show_matrix(EstLoop3 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",EstLoop3_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",EstLoop3_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",EstLoop3_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_EstLoop3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EstLoop3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_EstLoop3(EstLoop3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstLoop3_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstLoop3_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In EstLoop3 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 5,DELETE) ) { *reti = i - 1; *retj = j - 5; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,DELETE); } return (*h.access_main)(mat,i - 1,j - 5,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 4,DELETE) ) { *reti = i - 1; *retj = j - 4; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,DELETE); } return (*h.access_main)(mat,i - 1,j - 4,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,DELETE); } return (*h.access_main)(mat,i - 1,j - 1,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,DELETE) ) { *reti = i - 1; *retj = j - 2; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,DELETE); } return (*h.access_main)(mat,i - 1,j - 2,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 5,INSERT) ) { *reti = i - 1; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,INSERT); } return (*h.access_main)(mat,i - 1,j - 5,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 4,INSERT) ) { *reti = i - 1; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,INSERT); } return (*h.access_main)(mat,i - 1,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,INSERT) ) { *reti = i - 1; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,INSERT); } return (*h.access_main)(mat,i - 1,j - 2,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,MATCH); } return (*h.access_main)(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH); } return (*h.access_main)(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START); } return (*h.access_main)(mat,i - 1,j - 3,START); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 3,LOOP) ) { *reti = i - 1; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,LOOP); } return (*h.access_main)(mat,i - 1,j - 3,LOOP); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in EstLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,DELETE) ) { *reti = i - 0; *retj = j - 5; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,DELETE); } return (*h.access_main)(mat,i - 0,j - 5,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,DELETE) ) { *reti = i - 0; *retj = j - 4; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,DELETE); } return (*h.access_main)(mat,i - 0,j - 4,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,DELETE) ) { *reti = i - 0; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,DELETE); } return (*h.access_main)(mat,i - 0,j - 1,DELETE); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,DELETE) ) { *reti = i - 0; *retj = j - 2; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,DELETE); } return (*h.access_main)(mat,i - 0,j - 2,DELETE); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,MATCH) ) { *reti = i - 0; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,MATCH); } return (*h.access_main)(mat,i - 0,j - 5,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,MATCH) ) { *reti = i - 0; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,MATCH); } return (*h.access_main)(mat,i - 0,j - 4,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,MATCH) ) { *reti = i - 0; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,MATCH); } return (*h.access_main)(mat,i - 0,j - 2,MATCH); } temp = cscore - (mat->cp->trans[PCD_INSERT_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,INSERT) ) { *reti = i - 0; *retj = j - 5; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,INSERT); } return (*h.access_main)(mat,i - 0,j - 5,INSERT); } temp = cscore - (mat->cp->trans[PCD_INSERT_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,INSERT) ) { *reti = i - 0; *retj = j - 4; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INSERT); } return (*h.access_main)(mat,i - 0,j - 4,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_2_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->cp->trans[PCD_DELETE_1_BASE]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,LOOP) ) { *reti = i - 0; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,LOOP); } return (*h.access_main)(mat,i - 0,j - 3,LOOP); } temp = cscore - ((mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE); } return (*h.access_main)(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in EstLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->seg[i]->transition[GW_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,LOOP) ) { *reti = i - 1; *retj = j - 0; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,LOOP); } return (*h.access_main)(mat,i - 1,j - 0,LOOP); } temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in EstLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in EstLoop3 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_EstLoop3(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [EstLoop3_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_EstLoop3(EstLoop3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstLoop3_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = EstLoop3_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In EstLoop3 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case LOOP : /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,LOOP); } return (*h.access_special)(mat,i - 0,j - 1,LOOP) ; } /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ /* source START is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_special)(mat,i - 0,j - 1,START) ; } case START : case END : /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,LOOP); } return (*h.access_special)(mat,i - 0,j - 1,LOOP) ; } default: warn("Major problem (!) - in EstLoop3 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_EstLoop3(mat) * * Descrip: This function calculates the EstLoop3 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EstLoop3 * * * Arg: mat [UNKN ] EstLoop3 which contains explicit basematrix memory [EstLoop3 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_EstLoop3(EstLoop3 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EstLoop3, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("EstLoop3 Matrix calculation: "); for(j=0;jquery->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = EstLoop3_EXPL_SPECIAL(mat,i-1,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstLoop3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstLoop3_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstLoop3_EXPL_SPECIAL(mat,i,j,END) ) { EstLoop3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstLoop3_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = EstLoop3_EXPL_SPECIAL(mat,i-0,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstLoop3_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstLoop3_EXPL_SPECIAL(mat,i,j,END) ) { EstLoop3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstLoop3_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state LOOP to state DELETE */ temp = EstLoop3_EXPL_SPECIAL(mat,i-1,j-0,LOOP) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstLoop3_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstLoop3_EXPL_SPECIAL(mat,i,j,END) ) { EstLoop3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstLoop3_EXPL_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = EstLoop3_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = EstLoop3_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ EstLoop3_EXPL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstLoop3_EXPL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = EstLoop3_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Put back score... (now updated!) */ EstLoop3_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_EstLoop3(mat,dpenv) * * Descrip: This function calculates the EstLoop3 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EstLoop3 which contains explicit basematrix memory [EstLoop3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_EstLoop3(EstLoop3 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_EstLoop3, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-5;jleni;i++) { EstLoop3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstLoop3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstLoop3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j=-5;jlenj;j++) { EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = NEGI; EstLoop3_EXPL_SPECIAL(mat,i,j,START) = 0; EstLoop3_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("EstLoop3 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { EstLoop3_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; EstLoop3_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; EstLoop3_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = EstLoop3_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state MATCH */ temp = EstLoop3_EXPL_SPECIAL(mat,i-1,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = EstLoop3_EXPL_SPECIAL(mat,i-1,j-3,START) + (mat->query->seg[i]->transition[GW_START2MATCH]+mat->query->seg[i]->match[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ EstLoop3_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state MATCH is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > EstLoop3_EXPL_SPECIAL(mat,i,j,END) ) { EstLoop3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = EstLoop3_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->seg[i]->transition[GW_MATCH2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->seg[i]->transition[GW_INSERT2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->seg[i]->transition[GW_DELETE2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = EstLoop3_EXPL_SPECIAL(mat,i-0,j-3,LOOP) + (mat->query->seg[i]->transition[GW_START2INSERT]+mat->query->seg[i]->insert[CSEQ_CDNA_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-4,INSERT) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-5,INSERT) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-2,MATCH) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-4,MATCH) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-5,MATCH) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-2,DELETE) + mat->cp->trans[PCD_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-1,DELETE) + mat->cp->trans[PCD_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-4,DELETE) + mat->cp->trans[PCD_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = EstLoop3_EXPL_MATRIX(mat,i-0,j-5,DELETE) + mat->cp->trans[PCD_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ EstLoop3_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state INSERT is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > EstLoop3_EXPL_SPECIAL(mat,i,j,END) ) { EstLoop3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = EstLoop3_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = EstLoop3_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state LOOP to state DELETE */ temp = EstLoop3_EXPL_SPECIAL(mat,i-1,j-0,LOOP) + mat->query->seg[i]->transition[GW_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ EstLoop3_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) ) { EstLoop3_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state DELETE is a source for special END */ temp = score + (mat->query->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > EstLoop3_EXPL_SPECIAL(mat,i,j,END) ) { EstLoop3_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstLoop3_EXPL_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = EstLoop3_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = EstLoop3_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ EstLoop3_EXPL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = EstLoop3_EXPL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = EstLoop3_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state END is not special... already calculated */ /* Source INSERT for state END is not special... already calculated */ /* Source DELETE for state END is not special... already calculated */ /* Put back score... (now updated!) */ EstLoop3_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: EstLoop3_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstLoop3 *] * */ EstLoop3 * EstLoop3_alloc(void) { EstLoop3 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EstLoop3 *) ckalloc (sizeof(EstLoop3))) == NULL) { warn("EstLoop3_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_EstLoop3(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstLoop3 *] * * Return [UNKN ] Undocumented return value [EstLoop3 *] * */ EstLoop3 * free_EstLoop3(EstLoop3 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EstLoop3 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->cp is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/estloop3.h0000644000175000001440000004421110670453713016054 0ustar philippusers#ifndef DYNAMITEestloop3HEADERFILE #define DYNAMITEestloop3HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "cdparser.h" #include "genewisemodel.h" #include "genewisemodeldb.h" struct Wise2_EstLoop3 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GeneWiseScore* query; ComplexSequence* target; cDNAParserScore * cp; } ; /* EstLoop3 defined */ #ifndef DYNAMITE_DEFINED_EstLoop3 typedef struct Wise2_EstLoop3 Wise2_EstLoop3; #define EstLoop3 Wise2_EstLoop3 #define DYNAMITE_DEFINED_EstLoop3 #endif #ifdef PTHREAD struct thread_pool_holder_EstLoop3 { GeneWiseScore* query; /* Query object placeholder */ GeneWiseDB* querydb;/* Query database object */ boolean query_init; ComplexSequence* target;/* Target object placeholder */ cDNADB* targetdb; /* Target database object */ boolean target_init; cDNAParserScore * cp; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_EstLoop3_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(EstLoop3*,int,int,int); int (*access_special)(EstLoop3*,int,int,int); } ; /* EstLoop3_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_EstLoop3_access_func_holder typedef struct Wise2_EstLoop3_access_func_holder Wise2_EstLoop3_access_func_holder; #define EstLoop3_access_func_holder Wise2_EstLoop3_access_func_holder #define DYNAMITE_DEFINED_EstLoop3_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_EstLoop3(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_EstLoop3(EstLoop3 * mat); #define PackAln_read_Shatter_EstLoop3 Wise2_PackAln_read_Shatter_EstLoop3 /* Function: calculate_shatter_EstLoop3(mat,dpenv) * * Descrip: This function calculates the EstLoop3 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [EstLoop3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_EstLoop3(EstLoop3 * mat,DPEnvelope * dpenv); #define calculate_shatter_EstLoop3 Wise2_calculate_shatter_EstLoop3 /* Function: search_EstLoop3(dbsi,out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstLoop3 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_EstLoop3(DBSearchImpl * dbsi,Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp); #define search_EstLoop3 Wise2_search_EstLoop3 /* Function: serial_search_EstLoop3(out,querydb,targetdb,cp) * * Descrip: This function makes a database search of EstLoop3 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: querydb [UNKN ] Undocumented argument [GeneWiseDB*] * Arg: targetdb [UNKN ] Undocumented argument [cDNADB*] * Arg: cp [UNKN ] Undocumented argument [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_EstLoop3(Hscore * out,GeneWiseDB* querydb,cDNADB* targetdb ,cDNAParserScore * cp); #define serial_search_EstLoop3 Wise2_serial_search_EstLoop3 /* Function: PackAln_bestmemory_EstLoop3(query,target,cp,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_EstLoop3 * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_EstLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_EstLoop3 Wise2_PackAln_bestmemory_EstLoop3 /* Function: allocate_Expl_EstLoop3(query,target,cp,dpri) * * Descrip: This function allocates the EstLoop3 structure * and the basematrix area for explicit memory implementations * It calls /allocate_EstLoop3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [EstLoop3 *] * */ EstLoop3 * Wise2_allocate_Expl_EstLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp,DPRunImpl * dpri); #define allocate_Expl_EstLoop3 Wise2_allocate_Expl_EstLoop3 /* Function: recalculate_PackAln_EstLoop3(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by EstLoop3 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * */ void Wise2_recalculate_PackAln_EstLoop3(PackAln * pal,EstLoop3 * mat); #define recalculate_PackAln_EstLoop3 Wise2_recalculate_PackAln_EstLoop3 /* Function: allocate_Small_EstLoop3(query,target,cp) * * Descrip: This function allocates the EstLoop3 structure * and the basematrix area for a small memory implementations * It calls /allocate_EstLoop3_only * * * Arg: query [UNKN ] query data structure [GeneWiseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: cp [UNKN ] Resource [cDNAParserScore *] * * Return [UNKN ] Undocumented return value [EstLoop3 *] * */ EstLoop3 * Wise2_allocate_Small_EstLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp); #define allocate_Small_EstLoop3 Wise2_allocate_Small_EstLoop3 /* Function: PackAln_calculate_Small_EstLoop3(mat,dpenv) * * Descrip: This function calculates an alignment for EstLoop3 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_EstLoop3 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_EstLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_EstLoop3(EstLoop3 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_EstLoop3 Wise2_PackAln_calculate_Small_EstLoop3 /* Function: AlnRangeSet_calculate_Small_EstLoop3(mat) * * Descrip: This function calculates an alignment for EstLoop3 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_EstLoop3 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_EstLoop3 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_EstLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_EstLoop3(EstLoop3 * mat); #define AlnRangeSet_calculate_Small_EstLoop3 Wise2_AlnRangeSet_calculate_Small_EstLoop3 /* Function: AlnRangeSet_from_EstLoop3(mat) * * Descrip: This function reads off a start/end structure * for EstLoop3 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_EstLoop3 * If you have not calculated the matrix use * /AlnRange_calculate_Small_EstLoop3 * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_EstLoop3(EstLoop3 * mat); #define AlnRangeSet_from_EstLoop3 Wise2_AlnRangeSet_from_EstLoop3 /* Function: convert_PackAln_to_AlnBlock_EstLoop3(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_EstLoop3(PackAln * pal); #define convert_PackAln_to_AlnBlock_EstLoop3 Wise2_convert_PackAln_to_AlnBlock_EstLoop3 /* Function: PackAln_read_Expl_EstLoop3(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_EstLoop3(EstLoop3 * mat); #define PackAln_read_Expl_EstLoop3 Wise2_PackAln_read_Expl_EstLoop3 /* Function: PackAln_read_generic_EstLoop3(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [EstLoop3 *] * Arg: h [UNKN ] Undocumented argument [EstLoop3_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_EstLoop3(EstLoop3 * mat,EstLoop3_access_func_holder h); #define PackAln_read_generic_EstLoop3 Wise2_PackAln_read_generic_EstLoop3 /* Function: calculate_EstLoop3(mat) * * Descrip: This function calculates the EstLoop3 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_EstLoop3 * * * Arg: mat [UNKN ] EstLoop3 which contains explicit basematrix memory [EstLoop3 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_EstLoop3(EstLoop3 * mat); #define calculate_EstLoop3 Wise2_calculate_EstLoop3 /* Function: calculate_dpenv_EstLoop3(mat,dpenv) * * Descrip: This function calculates the EstLoop3 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] EstLoop3 which contains explicit basematrix memory [EstLoop3 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_EstLoop3(EstLoop3 * mat,DPEnvelope * dpenv); #define calculate_dpenv_EstLoop3 Wise2_calculate_dpenv_EstLoop3 /* Function: EstLoop3_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EstLoop3 *] * */ EstLoop3 * Wise2_EstLoop3_alloc(void); #define EstLoop3_alloc Wise2_EstLoop3_alloc /* Function: free_EstLoop3(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EstLoop3 *] * * Return [UNKN ] Undocumented return value [EstLoop3 *] * */ EstLoop3 * Wise2_free_EstLoop3(EstLoop3 * obj); #define free_EstLoop3 Wise2_free_EstLoop3 /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_EstLoop3_shatter_access_main(EstLoop3 * mat,int i,int j,int state); #define EstLoop3_shatter_access_main Wise2_EstLoop3_shatter_access_main int Wise2_EstLoop3_shatter_access_special(EstLoop3 * mat,int i,int j,int state); #define EstLoop3_shatter_access_special Wise2_EstLoop3_shatter_access_special void * Wise2_thread_loop_EstLoop3(void * ptr); #define thread_loop_EstLoop3 Wise2_thread_loop_EstLoop3 int Wise2_score_only_EstLoop3(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp); #define score_only_EstLoop3 Wise2_score_only_EstLoop3 EstLoop3 * Wise2_allocate_EstLoop3_only(GeneWiseScore* query,ComplexSequence* target ,cDNAParserScore * cp); #define allocate_EstLoop3_only Wise2_allocate_EstLoop3_only void Wise2_init_EstLoop3(EstLoop3 * mat); #define init_EstLoop3 Wise2_init_EstLoop3 AlnRange * Wise2_AlnRange_build_EstLoop3(EstLoop3 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_EstLoop3 Wise2_AlnRange_build_EstLoop3 boolean Wise2_read_hidden_EstLoop3(EstLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_EstLoop3 Wise2_read_hidden_EstLoop3 int Wise2_max_hidden_EstLoop3(EstLoop3 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_EstLoop3 Wise2_max_hidden_EstLoop3 boolean Wise2_read_special_strip_EstLoop3(EstLoop3 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_EstLoop3 Wise2_read_special_strip_EstLoop3 int Wise2_max_special_strip_EstLoop3(EstLoop3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_EstLoop3 Wise2_max_special_strip_EstLoop3 int Wise2_max_matrix_to_special_EstLoop3(EstLoop3 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_EstLoop3 Wise2_max_matrix_to_special_EstLoop3 void Wise2_calculate_hidden_EstLoop3(EstLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_EstLoop3 Wise2_calculate_hidden_EstLoop3 void Wise2_init_hidden_EstLoop3(EstLoop3 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_EstLoop3 Wise2_init_hidden_EstLoop3 boolean Wise2_full_dc_EstLoop3(EstLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_EstLoop3 Wise2_full_dc_EstLoop3 boolean Wise2_do_dc_single_pass_EstLoop3(EstLoop3 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_EstLoop3 Wise2_do_dc_single_pass_EstLoop3 void Wise2_push_dc_at_merge_EstLoop3(EstLoop3 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_EstLoop3 Wise2_push_dc_at_merge_EstLoop3 void Wise2_follow_on_dc_EstLoop3(EstLoop3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_EstLoop3 Wise2_follow_on_dc_EstLoop3 void Wise2_run_up_dc_EstLoop3(EstLoop3 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_EstLoop3 Wise2_run_up_dc_EstLoop3 void Wise2_init_dc_EstLoop3(EstLoop3 * mat); #define init_dc_EstLoop3 Wise2_init_dc_EstLoop3 int Wise2_start_end_find_end_EstLoop3(EstLoop3 * mat,int * endj); #define start_end_find_end_EstLoop3 Wise2_start_end_find_end_EstLoop3 boolean Wise2_dc_optimised_start_end_calc_EstLoop3(EstLoop3 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_EstLoop3 Wise2_dc_optimised_start_end_calc_EstLoop3 void Wise2_init_start_end_linear_EstLoop3(EstLoop3 * mat); #define init_start_end_linear_EstLoop3 Wise2_init_start_end_linear_EstLoop3 AlnConvertSet * Wise2_AlnConvertSet_EstLoop3(void); #define AlnConvertSet_EstLoop3 Wise2_AlnConvertSet_EstLoop3 int Wise2_EstLoop3_explicit_access_main(EstLoop3 * mat,int i,int j,int state); #define EstLoop3_explicit_access_main Wise2_EstLoop3_explicit_access_main int Wise2_EstLoop3_explicit_access_special(EstLoop3 * mat,int i,int j,int state); #define EstLoop3_explicit_access_special Wise2_EstLoop3_explicit_access_special int Wise2_find_end_EstLoop3(EstLoop3 * mat,int * ri,int * rj,int * state,boolean * isspecial,EstLoop3_access_func_holder h); #define find_end_EstLoop3 Wise2_find_end_EstLoop3 void Wise2_EstLoop3_debug_show_matrix(EstLoop3 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define EstLoop3_debug_show_matrix Wise2_EstLoop3_debug_show_matrix int Wise2_max_calc_EstLoop3(EstLoop3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstLoop3_access_func_holder h); #define max_calc_EstLoop3 Wise2_max_calc_EstLoop3 int Wise2_max_calc_special_EstLoop3(EstLoop3 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,EstLoop3_access_func_holder h); #define max_calc_special_EstLoop3 Wise2_max_calc_special_EstLoop3 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/dnaprofileengine.c0000644000175000001440000012132710670453713017614 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dnaprofileengine.h" # line 66 "dnaprofileengine.dy" TransFactorSet * TransFactorSet_from_DnaProfileSet(DnaProfileSet * in) { int i; char name_buf[512]; TransFactorSet * out; out = TransFactorSet_alloc_len(in->len); } # line 79 "dnaprofileengine.dy" DnaProfileNode * balanced_4_Sequence_fasta_stream(FILE * ifp) { Sequence * one; Sequence * two; Sequence * three; Sequence * four; DnaProfileNode * leafone; DnaProfileNode * leaftwo; DnaProfileNode * leafthree; DnaProfileNode * leaffour; DnaProfileNode * midonetwo; DnaProfileNode * midthreefour; DnaProfileNode * root; one = read_fasta_Sequence(ifp); fprintf(stderr,"Got 1 %s\n",one->name); two = read_fasta_Sequence(ifp); fprintf(stderr,"Got 2 %s\n",two->name); three = read_fasta_Sequence(ifp); fprintf(stderr,"Got 3 %s\n",three->name); four = read_fasta_Sequence(ifp); fprintf(stderr,"Got 4 %s\n",four->name); assert(four != NULL); leafone = new_leaf_DnaProfileNode(one); leaftwo = new_leaf_DnaProfileNode(two); leafthree = new_leaf_DnaProfileNode(three); leaffour = new_leaf_DnaProfileNode(four); midonetwo = DnaProfileNode_alloc(); midonetwo->type = DnaProfileNode_SET; midonetwo->left = leafone; midonetwo->right = leaftwo; midthreefour = DnaProfileNode_alloc(); midthreefour->type = DnaProfileNode_SET; midthreefour->left = leafthree; midthreefour->right = leaffour; root = DnaProfileNode_alloc(); root->type = DnaProfileNode_SET; root->left = midonetwo; root->right = midthreefour; return root; } # line 131 "dnaprofileengine.dy" DnaProfileNode * simple_cascade_Sequence_fasta_stream(FILE * ifp) { DnaProfileNode * head; DnaProfileNode * leaf; DnaProfileNode * first; DnaProfileNode * temp; Sequence * read; read = read_fasta_Sequence(ifp); uppercase_Sequence(read); if( read == NULL ) { fatal("Attempting to build a cascade with only no sequences! impossible!"); } first = new_leaf_DnaProfileNode(read); read = read_fasta_Sequence(ifp); uppercase_Sequence(read); if( read == NULL ) { fatal("Attempting to build a cascade with only one sequence! impossible!"); } leaf = new_leaf_DnaProfileNode(read); head = DnaProfileNode_alloc(); head->type = DnaProfileNode_SET; head->left = first; head->right = leaf; /* now loop over all remaining sequences */ while( (read = read_fasta_Sequence(ifp)) != NULL ) { uppercase_Sequence(read); leaf = new_leaf_DnaProfileNode(read); temp = DnaProfileNode_alloc(); temp->type = DnaProfileNode_SET; temp->left = head; temp->right = leaf; head = temp; } return head; } # line 179 "dnaprofileengine.dy" DnaProfileNode * new_leaf_DnaProfileNode(Sequence * seq) { DnaProfileNode * out; assert(seq != NULL); out = DnaProfileNode_alloc(); out->type = DnaProfileNode_LEAF; out->leaf = seq; return out; } # line 196 "dnaprofileengine.dy" void populate_DnaProfileNode_from_root(DnaProfileNode * root,DnaProfileEnginePara * dpep) { assert(root != NULL); if( root->left->type == DnaProfileNode_SET ) { populate_DnaProfileNode_from_root(root->left,dpep); } if( root->right->type == DnaProfileNode_SET ) { populate_DnaProfileNode_from_root(root->right,dpep); } /* left and right now populated */ root->set = join_two_DnaProfileNode(root->left,root->right,dpep); } # line 211 "dnaprofileengine.dy" DnaProfileSet * join_two_DnaProfileNode(DnaProfileNode * left,DnaProfileNode * right,DnaProfileEnginePara * dpep) { /* big switch around the types of left and right */ fprintf(stderr,"Entering join with %d vs %d\n",left->type,right->type); if( left->type == DnaProfileNode_LEAF && right->type == DnaProfileNode_LEAF ) { assert(left->leaf); assert(right->leaf); return DnaProfileSet_from_leaf_leaf(left->leaf,right->leaf,dpep); } if( left->type == DnaProfileNode_SET && right->type == DnaProfileNode_LEAF ) { assert(left->set); assert(right->leaf); return DnaProfileSet_from_leaf_node(right->leaf,left->set,dpep); } if( left->type == DnaProfileNode_LEAF && right->type == DnaProfileNode_SET ) { assert(left->leaf); assert(right->set); return DnaProfileSet_from_leaf_node(left->leaf,right->set,dpep); } if( left->type == DnaProfileNode_SET && right->type == DnaProfileNode_SET ) { assert(left->set); assert(right->set); return DnaProfileSet_from_node_node(left->set,right->set,dpep); } fatal("Should not get here. Weird no leaf/node case"); return NULL; } # line 251 "dnaprofileengine.dy" DnaProfileEnginePara * new_DnaProfileEnginePara_from_argv(int * argc,char ** argv) { DnaProfileEnginePara * out; out = DnaProfileEnginePara_alloc(); out->dpri = new_DPRunImpl_from_argv(argc,argv); out->setpara = new_LocalCisHitSetPara_from_argv(argc,argv); out->lchs = standard_LocalCisHitScore(NMaskType_VARIABLE); out->rm = RandomModelDNA_std(); out->pseudo = 0.5; out->open_unmatched = 0.001; out->ext_unmatched = 0.8; out->gap_unmatched = 0.5; out->seq_id = 0.8; out->m2i = 0.1; out->m2d = 0.1; out->i2i = 0.8; out->d2d = 0.8; out->min_seq_prof = 400; strip_out_float_argument(argc,argv,"dnap_pseudo",&out->pseudo); strip_out_float_argument(argc,argv,"dnap_open_un",&out->open_unmatched); strip_out_float_argument(argc,argv,"dnap_ext_un",&out->ext_unmatched); strip_out_float_argument(argc,argv,"dnap_gap_un",&out->ext_unmatched); strip_out_float_argument(argc,argv,"dnap_seq_self",&out->seq_id); strip_out_float_argument(argc,argv,"dnap_m2i",&out->m2i); strip_out_float_argument(argc,argv,"dnap_m2d",&out->m2d); strip_out_float_argument(argc,argv,"dnap_i2i",&out->i2i); strip_out_float_argument(argc,argv,"dnap_d2d",&out->d2d); strip_out_integer_argument(argc,argv,"dnap_min_seq_prof",&out->min_seq_prof); return out; } # line 290 "dnaprofileengine.dy" void show_help_DnaProfileEnginePara(FILE * ofp) { fprintf(ofp,"DnaProfile build/matching parameters\n"); fprintf(ofp," -dnap_pseudo [0.1] pseudo count used in profile construction\n"); fprintf(ofp," -dnap_open_un [0.4] unmatched probability open\n"); fprintf(ofp," -dnap_ext_un [0.95] unmatched extend probability\n"); fprintf(ofp," -dnap_ext_un [0.5] unmatched gap probability\n"); fprintf(ofp," -dnap_seq_self [0.8] %% identity for pure sequence matching\n"); fprintf(ofp," -dnap_m2i [0.1] Match 2 insert transition in dnaprofiles\n"); fprintf(ofp," -dnap_m2d [0.1] Match 2 delete transitions in dnaprofiles\n"); fprintf(ofp," -dnap_i2i [0.8] Insert 2 Insert transition in dnaprofiles\n"); fprintf(ofp," -dnap_d2d [0.8] Delete 2 Delete transition in dnaprofiles\n"); fprintf(ofp," -dnap_min_seq_prof [400] minimum score for sequence profile matching\n"); fprintf(ofp,"Local CisHit para for sequence to sequnence matching\n"); show_help_LocalCisHitSetPara(ofp); show_help_DPRunImpl(ofp); } # line 311 "dnaprofileengine.dy" DnaProfileSet * filter_DnaProfileSet(DnaProfileSet * in,int min_length,int min_score) { int i; DnaProfileSet * out; out = DnaProfileSet_alloc_std(); for(i=0;ilen;i++) { if( in->dnap[i]->sa->seq[0]->len <= min_length ) { continue; } add_DnaProfileSet(out,hard_link_DnaProfile(in->dnap[i])); } return out; } # line 330 "dnaprofileengine.dy" DnaProfileSet * DnaProfileSet_from_leaf_leaf(Sequence * one,Sequence * two,DnaProfileEnginePara * dpep) { DnaProfileSet * out; DnaMatrix * dm; DnaProbMatrix * dmp; PairwiseShortDna * psd; LocalCisHitSet * set; Sequence * two_rev; DnaProfile * dp; SeqAlign * sa; Sequence * temp1; Sequence * temp2; char * temp_seq1; char * temp_seq2; int unmatched; int seq1_i,seq2_i; AlnColumn * alc; int i; two_rev = reverse_complement_Sequence(two); dmp = DnaProbMatrix_from_match(0.65,NMaskType_BANNED); assert(dmp); flat_null_DnaProbMatrix(dmp); dm = DnaMatrix_from_DnaProbMatrix(dmp); show_DnaMatrix(dm,stderr); psd = query_to_reverse_target(one,two,dm,0,one->len,0,two->len); set = make_LocalCisHitSet(one,two,two_rev,psd->forward,psd->reverse,dpep->setpara,dpep->lchs,NULL,NULL,NULL,NULL,0,dpep->dpri); temp_seq1 = calloc(one->len > two->len ? one->len : two->len,sizeof(char)); temp_seq2 = calloc(one->len > two->len ? one->len : two->len,sizeof(char)); out = DnaProfileSet_alloc_std(); for(i=0;ilen;i++) { unmatched = 1; sa = NULL; /* * Main loop over DBA style alignment. We need to make one * DnaProfile per matching block, which are separated by unmatched * blocks. Could potentially be no blocks. * * Extra annoyance provided by the "wrong" convention being used in * DBA alignments, meaning that "inserts" label the "sequence" containing * strand, not the non-sequence containing strand. Stupid, but dbadisplay * uses this convention, so if we changed, would have to fix lots of exisiting * code. Not ideal. * */ for(alc=set->lch[i]->alb->start;alc != NULL;alc=alc->next) { /* hitting an unmatched block */ if( unmatched == 0 && (strcmp(alc->alu[0]->text_label,"UM") == 0 || strcmp(alc->alu[0]->text_label,"UI") == 0 || strcmp(alc->alu[0]->text_label,"END") == 0) ) { /* if we have an alignment, put it away now */ if( sa != NULL ) { temp_seq1[seq1_i] = '\0'; temp_seq2[seq2_i] = '\0'; temp1 = Sequence_from_static_memory(one->name,temp_seq1); temp2 = Sequence_from_static_memory(two->name,temp_seq2); add_SeqAlign(sa,temp1); add_SeqAlign(sa,temp2); dp = naive_DnaProfile_from_SeqAlign(sa,0.15,0.1,0.1,0.8,0.8); fold_RandomModel_DnaProfile(dp,dpep->rm); add_DnaProfileSet(out,dp); free_SeqAlign(sa); /* hard linked inside DP */ sa = NULL; } continue; } else if( unmatched == 1 && (strstartcmp(alc->alu[0]->text_label,"MM") == 0 || strstartcmp(alc->alu[0]->text_label,"MI") == 0 ) ) { unmatched = 0; sa = SeqAlign_alloc_len(2); seq1_i = 0; seq2_i = 0; } /* only if we are in a matched block */ if( unmatched == 0 ) { /* Bloody twisted DBA convention - Niclas has alot to answer for. Evil stuff -- MI is on the wrong strand! */ if( strstartcmp(alc->alu[0]->text_label,"MI") == 0 ) { /* means 0 has sequence, other has gap */ temp_seq1[seq1_i++] = one->seq[alc->alu[0]->end]; temp_seq2[seq2_i++] = '-'; } else if ( strstartcmp(alc->alu[1]->text_label,"MI") == 0 ) { temp_seq1[seq1_i++] = '-'; temp_seq2[seq2_i++] = two->seq[alc->alu[1]->end]; } else if ( strstartcmp(alc->alu[0]->text_label,"MM") == 0 && strstartcmp(alc->alu[1]->text_label,"MM") == 0 ) { temp_seq1[seq1_i++] = one->seq[alc->alu[0]->end]; temp_seq2[seq2_i++] = two->seq[alc->alu[1]->end]; } else { warn("Impossible label pair reached in matched block local cis hit stuff, %s,%s",alc->alu[0]->text_label,alc->alu[1]->text_label); } } } } free(temp_seq1); free(temp_seq2); free_PairwiseShortDna(psd); free_LocalCisHitSet(set); free_DnaMatrix(dm); free_DnaProbMatrix(dmp); return out; } # line 462 "dnaprofileengine.dy" DnaProfileSet * DnaProfileSet_from_node_node(DnaProfileSet * one,DnaProfileSet * two,DnaProfileEnginePara * dpep) { DnaProfile * new_dnap; DnaProfileSet * out; DnaProfileMatchPairSet * dpmps; SeqAlign * sa; int i; int j; dpmps = DnaProfileMatchPairSet_alloc_std(); for(i=0;ilen;i++) { for(j=0;jlen;j++) { add_DnaProfileMatchPairSet(dpmps,DnaProfileMatchPair_from_DnaProfile(one->dnap[i],two->dnap[j],dpep)); } } sort_DnaProfileMatchPairSet_by_score(dpmps); out = DnaProfileSet_alloc_std(); for(i=0;ilen;i++) { /* check this profile has not already been used */ /* not done yet */ if( dpmps->pair[i]->score < dpep->min_seq_prof ) { fprintf(stderr,"Warning... rejecting match due to score %d vs %d\n",dpmps->pair[i]->score,dpep->min_seq_prof); break; } sa = merged_SeqAlign(dpmps->pair[i]->query,dpmps->pair[i]->target,dpmps->pair[i]->alb); fprintf(stderr,"Node/Node Accepting score at %d length %d\n",dpmps->pair[i]->score,sa->seq[0]->len); new_dnap = naive_DnaProfile_from_SeqAlign(sa,dpep->pseudo,dpep->m2i,dpep->m2d,dpep->i2i,dpep->d2d); assert(new_dnap != NULL); /* need to log-odds dnap here */ fold_RandomModel_DnaProfile(new_dnap,dpep->rm); add_DnaProfileSet(out,new_dnap); } fprintf(stderr,"Returing %d profiles\n",out->len); return out; } # line 514 "dnaprofileengine.dy" DnaProfileSet * DnaProfileSet_from_leaf_node(Sequence * one,DnaProfileSet * two,DnaProfileEnginePara * dpep) { DnaProfileSet * out; DnaProfile * dnap; DnaProfile * dnapr; DnaProfileMatchPairSet * dpmps; Sequence * rev; SeqAlign * sa; DnaProfile * new_dnap; int i; int j; dpmps = DnaProfileMatchPairSet_alloc_std(); out = DnaProfileSet_alloc_std(); rev = reverse_complement_Sequence(one); dnap = naive_DnaProfile_from_Sequence(one,dpep->seq_id,dpep->m2i,dpep->m2d,dpep->i2i,dpep->d2d); dnapr = naive_DnaProfile_from_Sequence(rev,dpep->seq_id,dpep->m2i,dpep->m2d,dpep->i2i,dpep->d2d); fold_RandomModel_DnaProfile(dnap,dpep->rm); fold_RandomModel_DnaProfile(dnapr,dpep->rm); for(i=0;ilen;i++) { fprintf(stderr,"Processing %d\n",i); add_DnaProfileMatchPairSet(dpmps,DnaProfileMatchPair_from_DnaProfile(dnap,two->dnap[i],dpep)); add_DnaProfileMatchPairSet(dpmps,DnaProfileMatchPair_from_DnaProfile(dnapr,two->dnap[i],dpep)); } fprintf(stderr,"Sorting....\n"); sort_DnaProfileMatchPairSet_by_score(dpmps); for(i=0;ilen;i++) { /* check this profile has not already been used */ /* not done yet */ if( dpmps->pair[i]->score < dpep->min_seq_prof ) { fprintf(stderr,"Warning... rejecting match due to score %d vs %d\n",dpmps->pair[i]->score,dpep->min_seq_prof); break; } sa = merged_SeqAlign(dpmps->pair[i]->query,dpmps->pair[i]->target,dpmps->pair[i]->alb); new_dnap = naive_DnaProfile_from_SeqAlign(sa,dpep->pseudo,dpep->m2i,dpep->m2d,dpep->i2i,dpep->d2d); /* need to log-odds dnap here */ fold_RandomModel_DnaProfile(new_dnap,dpep->rm); add_DnaProfileSet(out,new_dnap); } fprintf(stderr,"Freeing DNA profiles...\n"); free_DnaProfile(dnap); free_DnaProfile(dnapr); fprintf(stderr,"Freeing sequences\n"); free_Sequence(rev); return out; } # line 587 "dnaprofileengine.dy" DnaProfileMatchPair * DnaProfileMatchPair_from_DnaProfile(DnaProfile * query,DnaProfile * target,DnaProfileEnginePara * dpep) { DnaProfileMatchPair * out; DnaProfileScore * query_s; DnaProfileScore * target_s; DnaProfileMatchScore * match; PackAln * pal; assert(query != NULL); assert(target != NULL); /* assert(query->len > 4 ); assert(target->len > 4); */ out = DnaProfileMatchPair_alloc(); out->query = hard_link_DnaProfile(query); out->target = hard_link_DnaProfile(target); query_s = DnaProfileScore_from_DnaProfile(query); target_s = DnaProfileScore_from_DnaProfile(target); fprintf(stderr,"Matching %d to %d\n",query->len,target->len); match= new_ALLR_DnaProfileMatchScore(query,target); pal = PackAln_bestmemory_DnaProfileMat(query_s,target_s,match,Probability2Score(dpep->open_unmatched),Probability2Score(dpep->ext_unmatched),Probability2Score(dpep->gap_unmatched),NULL,dpep->dpri); fprintf(stderr,"...Made pal %d\n",pal); out->alb = convert_PackAln_to_AlnBlock_DnaProfileMat(pal); out->score = pal->score; fprintf(stderr,"...freeing pal\n"); free_PackAln(pal); fprintf(stderr,"...freeing match\n"); free_DnaProfileMatchScore(match); fprintf(stderr,"...freeing query\n"); free_DnaProfileScore(query_s); fprintf(stderr,"...freeing target\n"); free_DnaProfileScore(target_s); return out; } # line 640 "dnaprofileengine.dy" void sort_DnaProfileMatchPairSet_by_score(DnaProfileMatchPairSet * set) { sort_DnaProfileMatchPairSet(set,compare_DnaProfileMatchPair); } # line 645 "dnaprofileengine.dy" int compare_DnaProfileMatchPair(DnaProfileMatchPair * one,DnaProfileMatchPair * two) { return two->score - one->score; } # line 651 "dnaprofileengine.dy" void show_DnaProfileSet(DnaProfileSet * dnaps,RandomModelDNA * rm,FILE * ofp) { int i; for(i=0;ilen;i++) { show_DnaProfile(dnaps->dnap[i],rm,ofp); } } # line 617 "dnaprofileengine.c" /* Function: hard_link_DnaProfileEnginePara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileEnginePara *] * * Return [UNKN ] Undocumented return value [DnaProfileEnginePara *] * */ DnaProfileEnginePara * hard_link_DnaProfileEnginePara(DnaProfileEnginePara * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaProfileEnginePara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaProfileEnginePara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileEnginePara *] * */ DnaProfileEnginePara * DnaProfileEnginePara_alloc(void) { DnaProfileEnginePara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaProfileEnginePara *) ckalloc (sizeof(DnaProfileEnginePara))) == NULL) { warn("DnaProfileEnginePara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->dpri = NULL; out->rm = NULL; out->setpara = NULL; out->lchs = NULL; out->pseudo = 0.0; out->open_unmatched = 0.0; out->ext_unmatched = 0.0; out->gap_unmatched = 0.0; out->seq_id = 0.0; out->m2i = 0.0; out->m2d = 0.0; out->i2i = 0.0; out->d2d = 0.0; out->min_seq_prof = 0; return out; } /* Function: free_DnaProfileEnginePara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileEnginePara *] * * Return [UNKN ] Undocumented return value [DnaProfileEnginePara *] * */ DnaProfileEnginePara * free_DnaProfileEnginePara(DnaProfileEnginePara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaProfileEnginePara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->dpri != NULL) free_DPRunImpl(obj->dpri); if( obj->rm != NULL) free_RandomModelDNA(obj->rm); if( obj->setpara != NULL) free_LocalCisHitSetPara(obj->setpara); if( obj->lchs != NULL) free_LocalCisHitScore(obj->lchs); ckfree(obj); return NULL; } /* Function: swap_DnaProfileSet(list,i,j) * * Descrip: swap function: an internal for qsort_DnaProfileSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [DnaProfile **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_DnaProfileSet(DnaProfile ** list,int i,int j) { DnaProfile * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_DnaProfileSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_DnaProfileSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [DnaProfile **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_DnaProfileSet(DnaProfile ** list,int left,int right,int (*comp)(DnaProfile * ,DnaProfile * )) { int i,last; if( left >= right ) return; swap_DnaProfileSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_DnaProfileSet (list,++last,i); } swap_DnaProfileSet (list,left,last); qsort_DnaProfileSet(list,left,last-1,comp); qsort_DnaProfileSet(list,last+1,right,comp); } /* Function: sort_DnaProfileSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_DnaProfileSet * * * Arg: obj [UNKN ] Object containing list [DnaProfileSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_DnaProfileSet(DnaProfileSet * obj,int (*comp)(DnaProfile *, DnaProfile *)) { qsort_DnaProfileSet(obj->dnap,0,obj->len-1,comp); return; } /* Function: expand_DnaProfileSet(obj,len) * * Descrip: Really an internal function for add_DnaProfileSet * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_DnaProfileSet(DnaProfileSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_DnaProfileSet called with no need"); return TRUE; } if( (obj->dnap = (DnaProfile ** ) ckrealloc (obj->dnap,sizeof(DnaProfile *)*len)) == NULL) { warn("ckrealloc failed for expand_DnaProfileSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_DnaProfileSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileSet *] * Arg: add [OWNER] Object to add to the list [DnaProfile *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_DnaProfileSet(DnaProfileSet * obj,DnaProfile * add) { if( obj->len >= obj->maxlen) { if( expand_DnaProfileSet(obj,obj->len + DnaProfileSetLISTLENGTH) == FALSE) return FALSE; } obj->dnap[obj->len++]=add; return TRUE; } /* Function: flush_DnaProfileSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_DnaProfileSet(DnaProfileSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->dnap[i] != NULL) { free_DnaProfile(obj->dnap[i]); obj->dnap[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: DnaProfileSet_alloc_std(void) * * Descrip: Equivalent to DnaProfileSet_alloc_len(DnaProfileSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DnaProfileSet *] * */ DnaProfileSet * DnaProfileSet_alloc_std(void) { return DnaProfileSet_alloc_len(DnaProfileSetLISTLENGTH); } /* Function: DnaProfileSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DnaProfileSet *] * */ DnaProfileSet * DnaProfileSet_alloc_len(int len) { DnaProfileSet * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = DnaProfileSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->dnap = (DnaProfile ** ) ckcalloc (len,sizeof(DnaProfile *))) == NULL) { warn("Warning, ckcalloc failed in DnaProfileSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_DnaProfileSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileSet *] * * Return [UNKN ] Undocumented return value [DnaProfileSet *] * */ DnaProfileSet * hard_link_DnaProfileSet(DnaProfileSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaProfileSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaProfileSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileSet *] * */ DnaProfileSet * DnaProfileSet_alloc(void) { DnaProfileSet * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaProfileSet *) ckalloc (sizeof(DnaProfileSet))) == NULL) { warn("DnaProfileSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->dnap = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_DnaProfileSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileSet *] * * Return [UNKN ] Undocumented return value [DnaProfileSet *] * */ DnaProfileSet * free_DnaProfileSet(DnaProfileSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaProfileSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->dnap != NULL) { for(i=0;ilen;i++) { if( obj->dnap[i] != NULL) free_DnaProfile(obj->dnap[i]); } ckfree(obj->dnap); } ckfree(obj); return NULL; } /* Function: hard_link_DnaProfileNode(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileNode *] * * Return [UNKN ] Undocumented return value [DnaProfileNode *] * */ DnaProfileNode * hard_link_DnaProfileNode(DnaProfileNode * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaProfileNode object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaProfileNode_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileNode *] * */ DnaProfileNode * DnaProfileNode_alloc(void) { DnaProfileNode * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaProfileNode *) ckalloc (sizeof(DnaProfileNode))) == NULL) { warn("DnaProfileNode_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = 0; out->leaf = NULL; out->set = NULL; out->left = NULL; out->right = NULL; return out; } /* Function: free_DnaProfileNode(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileNode *] * * Return [UNKN ] Undocumented return value [DnaProfileNode *] * */ DnaProfileNode * free_DnaProfileNode(DnaProfileNode * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaProfileNode obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->leaf != NULL) free_Sequence(obj->leaf); if( obj->set != NULL) free_DnaProfileSet(obj->set); if( obj->left != NULL) free_DnaProfileNode(obj->left); if( obj->right != NULL) free_DnaProfileNode(obj->right); /* obj->parent is linked in */ ckfree(obj); return NULL; } /* Function: hard_link_DnaProfileMatchPair(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileMatchPair *] * * Return [UNKN ] Undocumented return value [DnaProfileMatchPair *] * */ DnaProfileMatchPair * hard_link_DnaProfileMatchPair(DnaProfileMatchPair * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaProfileMatchPair object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaProfileMatchPair_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileMatchPair *] * */ DnaProfileMatchPair * DnaProfileMatchPair_alloc(void) { DnaProfileMatchPair * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaProfileMatchPair *) ckalloc (sizeof(DnaProfileMatchPair))) == NULL) { warn("DnaProfileMatchPair_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->query = NULL; out->target = NULL; out->alb = NULL; out->score = 0; out->accepted = 0; return out; } /* Function: free_DnaProfileMatchPair(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileMatchPair *] * * Return [UNKN ] Undocumented return value [DnaProfileMatchPair *] * */ DnaProfileMatchPair * free_DnaProfileMatchPair(DnaProfileMatchPair * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaProfileMatchPair obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->query != NULL) free_DnaProfile(obj->query); if( obj->target != NULL) free_DnaProfile(obj->target); if( obj->alb != NULL) free_AlnBlock(obj->alb); ckfree(obj); return NULL; } /* Function: swap_DnaProfileMatchPairSet(list,i,j) * * Descrip: swap function: an internal for qsort_DnaProfileMatchPairSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [DnaProfileMatchPair **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_DnaProfileMatchPairSet(DnaProfileMatchPair ** list,int i,int j) { DnaProfileMatchPair * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_DnaProfileMatchPairSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_DnaProfileMatchPairSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [DnaProfileMatchPair **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_DnaProfileMatchPairSet(DnaProfileMatchPair ** list,int left,int right,int (*comp)(DnaProfileMatchPair * ,DnaProfileMatchPair * )) { int i,last; if( left >= right ) return; swap_DnaProfileMatchPairSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_DnaProfileMatchPairSet (list,++last,i); } swap_DnaProfileMatchPairSet (list,left,last); qsort_DnaProfileMatchPairSet(list,left,last-1,comp); qsort_DnaProfileMatchPairSet(list,last+1,right,comp); } /* Function: sort_DnaProfileMatchPairSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_DnaProfileMatchPairSet * * * Arg: obj [UNKN ] Object containing list [DnaProfileMatchPairSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_DnaProfileMatchPairSet(DnaProfileMatchPairSet * obj,int (*comp)(DnaProfileMatchPair *, DnaProfileMatchPair *)) { qsort_DnaProfileMatchPairSet(obj->pair,0,obj->len-1,comp); return; } /* Function: expand_DnaProfileMatchPairSet(obj,len) * * Descrip: Really an internal function for add_DnaProfileMatchPairSet * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileMatchPairSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_DnaProfileMatchPairSet(DnaProfileMatchPairSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_DnaProfileMatchPairSet called with no need"); return TRUE; } if( (obj->pair = (DnaProfileMatchPair ** ) ckrealloc (obj->pair,sizeof(DnaProfileMatchPair *)*len)) == NULL) { warn("ckrealloc failed for expand_DnaProfileMatchPairSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_DnaProfileMatchPairSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileMatchPairSet *] * Arg: add [OWNER] Object to add to the list [DnaProfileMatchPair *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_DnaProfileMatchPairSet(DnaProfileMatchPairSet * obj,DnaProfileMatchPair * add) { if( obj->len >= obj->maxlen) { if( expand_DnaProfileMatchPairSet(obj,obj->len + DnaProfileMatchPairSetLISTLENGTH) == FALSE) return FALSE; } obj->pair[obj->len++]=add; return TRUE; } /* Function: flush_DnaProfileMatchPairSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileMatchPairSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_DnaProfileMatchPairSet(DnaProfileMatchPairSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->pair[i] != NULL) { free_DnaProfileMatchPair(obj->pair[i]); obj->pair[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: DnaProfileMatchPairSet_alloc_std(void) * * Descrip: Equivalent to DnaProfileMatchPairSet_alloc_len(DnaProfileMatchPairSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DnaProfileMatchPairSet *] * */ DnaProfileMatchPairSet * DnaProfileMatchPairSet_alloc_std(void) { return DnaProfileMatchPairSet_alloc_len(DnaProfileMatchPairSetLISTLENGTH); } /* Function: DnaProfileMatchPairSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DnaProfileMatchPairSet *] * */ DnaProfileMatchPairSet * DnaProfileMatchPairSet_alloc_len(int len) { DnaProfileMatchPairSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = DnaProfileMatchPairSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->pair = (DnaProfileMatchPair ** ) ckcalloc (len,sizeof(DnaProfileMatchPair *))) == NULL) { warn("Warning, ckcalloc failed in DnaProfileMatchPairSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_DnaProfileMatchPairSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileMatchPairSet *] * * Return [UNKN ] Undocumented return value [DnaProfileMatchPairSet *] * */ DnaProfileMatchPairSet * hard_link_DnaProfileMatchPairSet(DnaProfileMatchPairSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaProfileMatchPairSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaProfileMatchPairSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileMatchPairSet *] * */ DnaProfileMatchPairSet * DnaProfileMatchPairSet_alloc(void) { DnaProfileMatchPairSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaProfileMatchPairSet *) ckalloc (sizeof(DnaProfileMatchPairSet))) == NULL) { warn("DnaProfileMatchPairSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->pair = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_DnaProfileMatchPairSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileMatchPairSet *] * * Return [UNKN ] Undocumented return value [DnaProfileMatchPairSet *] * */ DnaProfileMatchPairSet * free_DnaProfileMatchPairSet(DnaProfileMatchPairSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaProfileMatchPairSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->pair != NULL) { for(i=0;ilen;i++) { if( obj->pair[i] != NULL) free_DnaProfileMatchPair(obj->pair[i]); } ckfree(obj->pair); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/dnaprofileengine.h0000644000175000001440000004270210670453713017620 0ustar philippusers#ifndef DYNAMITEdnaprofileengineHEADERFILE #define DYNAMITEdnaprofileengineHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dnaprofile.h" #include "dnaprofiledp.h" #include "localcishit.h" #include "pairwiseshortdna.h" #define DnaProfileNode_LEAF 67 #define DnaProfileNode_SET 68 #define DnaProfileNode_UNCALC 69 #define DnaProfileSetLISTLENGTH 128 #define DnaProfileMatchPairSetLISTLENGTH 128 struct Wise2_DnaProfileEnginePara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DPRunImpl * dpri; RandomModelDNA * rm; LocalCisHitSetPara * setpara; LocalCisHitScore * lchs; Probability pseudo; Probability open_unmatched; Probability ext_unmatched; Probability gap_unmatched; Probability seq_id; Probability m2i; Probability m2d; Probability i2i; Probability d2d; Score min_seq_prof; } ; /* DnaProfileEnginePara defined */ #ifndef DYNAMITE_DEFINED_DnaProfileEnginePara typedef struct Wise2_DnaProfileEnginePara Wise2_DnaProfileEnginePara; #define DnaProfileEnginePara Wise2_DnaProfileEnginePara #define DYNAMITE_DEFINED_DnaProfileEnginePara #endif struct Wise2_DnaProfileSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DnaProfile ** dnap; int len;/* len for above dnap */ int maxlen; /* maxlen for above dnap */ } ; /* DnaProfileSet defined */ #ifndef DYNAMITE_DEFINED_DnaProfileSet typedef struct Wise2_DnaProfileSet Wise2_DnaProfileSet; #define DnaProfileSet Wise2_DnaProfileSet #define DYNAMITE_DEFINED_DnaProfileSet #endif #ifndef DYNAMITE_DEFINED_DnaProfileNode typedef struct Wise2_DnaProfileNode Wise2_DnaProfileNode; #define DnaProfileNode Wise2_DnaProfileNode #define DYNAMITE_DEFINED_DnaProfileNode #endif struct Wise2_DnaProfileNode { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; Sequence * leaf; DnaProfileSet * set; DnaProfileNode * left; DnaProfileNode * right; DnaProfileNode * parent; } ; /* DnaProfileNode defined */ #ifndef DYNAMITE_DEFINED_DnaProfileNode typedef struct Wise2_DnaProfileNode Wise2_DnaProfileNode; #define DnaProfileNode Wise2_DnaProfileNode #define DYNAMITE_DEFINED_DnaProfileNode #endif struct Wise2_DnaProfileMatchPair { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DnaProfile * query; DnaProfile * target; AlnBlock * alb; int score; int accepted; } ; /* DnaProfileMatchPair defined */ #ifndef DYNAMITE_DEFINED_DnaProfileMatchPair typedef struct Wise2_DnaProfileMatchPair Wise2_DnaProfileMatchPair; #define DnaProfileMatchPair Wise2_DnaProfileMatchPair #define DYNAMITE_DEFINED_DnaProfileMatchPair #endif struct Wise2_DnaProfileMatchPairSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DnaProfileMatchPair ** pair; int len;/* len for above pair */ int maxlen; /* maxlen for above pair */ } ; /* DnaProfileMatchPairSet defined */ #ifndef DYNAMITE_DEFINED_DnaProfileMatchPairSet typedef struct Wise2_DnaProfileMatchPairSet Wise2_DnaProfileMatchPairSet; #define DnaProfileMatchPairSet Wise2_DnaProfileMatchPairSet #define DYNAMITE_DEFINED_DnaProfileMatchPairSet #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_DnaProfileEnginePara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileEnginePara *] * * Return [UNKN ] Undocumented return value [DnaProfileEnginePara *] * */ DnaProfileEnginePara * Wise2_hard_link_DnaProfileEnginePara(DnaProfileEnginePara * obj); #define hard_link_DnaProfileEnginePara Wise2_hard_link_DnaProfileEnginePara /* Function: DnaProfileEnginePara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileEnginePara *] * */ DnaProfileEnginePara * Wise2_DnaProfileEnginePara_alloc(void); #define DnaProfileEnginePara_alloc Wise2_DnaProfileEnginePara_alloc /* Function: free_DnaProfileEnginePara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileEnginePara *] * * Return [UNKN ] Undocumented return value [DnaProfileEnginePara *] * */ DnaProfileEnginePara * Wise2_free_DnaProfileEnginePara(DnaProfileEnginePara * obj); #define free_DnaProfileEnginePara Wise2_free_DnaProfileEnginePara /* Function: add_DnaProfileSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileSet *] * Arg: add [OWNER] Object to add to the list [DnaProfile *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_DnaProfileSet(DnaProfileSet * obj,DnaProfile * add); #define add_DnaProfileSet Wise2_add_DnaProfileSet /* Function: flush_DnaProfileSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_DnaProfileSet(DnaProfileSet * obj); #define flush_DnaProfileSet Wise2_flush_DnaProfileSet /* Function: DnaProfileSet_alloc_std(void) * * Descrip: Equivalent to DnaProfileSet_alloc_len(DnaProfileSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DnaProfileSet *] * */ DnaProfileSet * Wise2_DnaProfileSet_alloc_std(void); #define DnaProfileSet_alloc_std Wise2_DnaProfileSet_alloc_std /* Function: DnaProfileSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DnaProfileSet *] * */ DnaProfileSet * Wise2_DnaProfileSet_alloc_len(int len); #define DnaProfileSet_alloc_len Wise2_DnaProfileSet_alloc_len /* Function: hard_link_DnaProfileSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileSet *] * * Return [UNKN ] Undocumented return value [DnaProfileSet *] * */ DnaProfileSet * Wise2_hard_link_DnaProfileSet(DnaProfileSet * obj); #define hard_link_DnaProfileSet Wise2_hard_link_DnaProfileSet /* Function: DnaProfileSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileSet *] * */ DnaProfileSet * Wise2_DnaProfileSet_alloc(void); #define DnaProfileSet_alloc Wise2_DnaProfileSet_alloc /* Function: free_DnaProfileSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileSet *] * * Return [UNKN ] Undocumented return value [DnaProfileSet *] * */ DnaProfileSet * Wise2_free_DnaProfileSet(DnaProfileSet * obj); #define free_DnaProfileSet Wise2_free_DnaProfileSet /* Function: hard_link_DnaProfileNode(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileNode *] * * Return [UNKN ] Undocumented return value [DnaProfileNode *] * */ DnaProfileNode * Wise2_hard_link_DnaProfileNode(DnaProfileNode * obj); #define hard_link_DnaProfileNode Wise2_hard_link_DnaProfileNode /* Function: DnaProfileNode_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileNode *] * */ DnaProfileNode * Wise2_DnaProfileNode_alloc(void); #define DnaProfileNode_alloc Wise2_DnaProfileNode_alloc /* Function: free_DnaProfileNode(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileNode *] * * Return [UNKN ] Undocumented return value [DnaProfileNode *] * */ DnaProfileNode * Wise2_free_DnaProfileNode(DnaProfileNode * obj); #define free_DnaProfileNode Wise2_free_DnaProfileNode /* Function: hard_link_DnaProfileMatchPair(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileMatchPair *] * * Return [UNKN ] Undocumented return value [DnaProfileMatchPair *] * */ DnaProfileMatchPair * Wise2_hard_link_DnaProfileMatchPair(DnaProfileMatchPair * obj); #define hard_link_DnaProfileMatchPair Wise2_hard_link_DnaProfileMatchPair /* Function: DnaProfileMatchPair_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileMatchPair *] * */ DnaProfileMatchPair * Wise2_DnaProfileMatchPair_alloc(void); #define DnaProfileMatchPair_alloc Wise2_DnaProfileMatchPair_alloc /* Function: free_DnaProfileMatchPair(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileMatchPair *] * * Return [UNKN ] Undocumented return value [DnaProfileMatchPair *] * */ DnaProfileMatchPair * Wise2_free_DnaProfileMatchPair(DnaProfileMatchPair * obj); #define free_DnaProfileMatchPair Wise2_free_DnaProfileMatchPair /* Function: add_DnaProfileMatchPairSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileMatchPairSet *] * Arg: add [OWNER] Object to add to the list [DnaProfileMatchPair *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_DnaProfileMatchPairSet(DnaProfileMatchPairSet * obj,DnaProfileMatchPair * add); #define add_DnaProfileMatchPairSet Wise2_add_DnaProfileMatchPairSet /* Function: flush_DnaProfileMatchPairSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DnaProfileMatchPairSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_DnaProfileMatchPairSet(DnaProfileMatchPairSet * obj); #define flush_DnaProfileMatchPairSet Wise2_flush_DnaProfileMatchPairSet /* Function: DnaProfileMatchPairSet_alloc_std(void) * * Descrip: Equivalent to DnaProfileMatchPairSet_alloc_len(DnaProfileMatchPairSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DnaProfileMatchPairSet *] * */ DnaProfileMatchPairSet * Wise2_DnaProfileMatchPairSet_alloc_std(void); #define DnaProfileMatchPairSet_alloc_std Wise2_DnaProfileMatchPairSet_alloc_std /* Function: DnaProfileMatchPairSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DnaProfileMatchPairSet *] * */ DnaProfileMatchPairSet * Wise2_DnaProfileMatchPairSet_alloc_len(int len); #define DnaProfileMatchPairSet_alloc_len Wise2_DnaProfileMatchPairSet_alloc_len /* Function: hard_link_DnaProfileMatchPairSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileMatchPairSet *] * * Return [UNKN ] Undocumented return value [DnaProfileMatchPairSet *] * */ DnaProfileMatchPairSet * Wise2_hard_link_DnaProfileMatchPairSet(DnaProfileMatchPairSet * obj); #define hard_link_DnaProfileMatchPairSet Wise2_hard_link_DnaProfileMatchPairSet /* Function: DnaProfileMatchPairSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileMatchPairSet *] * */ DnaProfileMatchPairSet * Wise2_DnaProfileMatchPairSet_alloc(void); #define DnaProfileMatchPairSet_alloc Wise2_DnaProfileMatchPairSet_alloc /* Function: free_DnaProfileMatchPairSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileMatchPairSet *] * * Return [UNKN ] Undocumented return value [DnaProfileMatchPairSet *] * */ DnaProfileMatchPairSet * Wise2_free_DnaProfileMatchPairSet(DnaProfileMatchPairSet * obj); #define free_DnaProfileMatchPairSet Wise2_free_DnaProfileMatchPairSet /* Unplaced functions */ /* There has been no indication of the use of these functions */ TransFactorSet * Wise2_TransFactorSet_from_DnaProfileSet(DnaProfileSet * in); #define TransFactorSet_from_DnaProfileSet Wise2_TransFactorSet_from_DnaProfileSet DnaProfileNode * Wise2_balanced_4_Sequence_fasta_stream(FILE * ifp); #define balanced_4_Sequence_fasta_stream Wise2_balanced_4_Sequence_fasta_stream DnaProfileNode * Wise2_simple_cascade_Sequence_fasta_stream(FILE * ifp); #define simple_cascade_Sequence_fasta_stream Wise2_simple_cascade_Sequence_fasta_stream DnaProfileNode * Wise2_new_leaf_DnaProfileNode(Sequence * seq); #define new_leaf_DnaProfileNode Wise2_new_leaf_DnaProfileNode void Wise2_populate_DnaProfileNode_from_root(DnaProfileNode * root,DnaProfileEnginePara * dpep); #define populate_DnaProfileNode_from_root Wise2_populate_DnaProfileNode_from_root DnaProfileSet * Wise2_join_two_DnaProfileNode(DnaProfileNode * left,DnaProfileNode * right,DnaProfileEnginePara * dpep); #define join_two_DnaProfileNode Wise2_join_two_DnaProfileNode DnaProfileEnginePara * Wise2_new_DnaProfileEnginePara_from_argv(int * argc,char ** argv); #define new_DnaProfileEnginePara_from_argv Wise2_new_DnaProfileEnginePara_from_argv void Wise2_show_help_DnaProfileEnginePara(FILE * ofp); #define show_help_DnaProfileEnginePara Wise2_show_help_DnaProfileEnginePara DnaProfileSet * Wise2_filter_DnaProfileSet(DnaProfileSet * in,int min_length,int min_score); #define filter_DnaProfileSet Wise2_filter_DnaProfileSet DnaProfileSet * Wise2_DnaProfileSet_from_leaf_leaf(Sequence * one,Sequence * two,DnaProfileEnginePara * dpep); #define DnaProfileSet_from_leaf_leaf Wise2_DnaProfileSet_from_leaf_leaf DnaProfileSet * Wise2_DnaProfileSet_from_node_node(DnaProfileSet * one,DnaProfileSet * two,DnaProfileEnginePara * dpep); #define DnaProfileSet_from_node_node Wise2_DnaProfileSet_from_node_node DnaProfileSet * Wise2_DnaProfileSet_from_leaf_node(Sequence * one,DnaProfileSet * two,DnaProfileEnginePara * dpep); #define DnaProfileSet_from_leaf_node Wise2_DnaProfileSet_from_leaf_node DnaProfileMatchPair * Wise2_DnaProfileMatchPair_from_DnaProfile(DnaProfile * query,DnaProfile * target,DnaProfileEnginePara * dpep); #define DnaProfileMatchPair_from_DnaProfile Wise2_DnaProfileMatchPair_from_DnaProfile void Wise2_sort_DnaProfileMatchPairSet_by_score(DnaProfileMatchPairSet * set); #define sort_DnaProfileMatchPairSet_by_score Wise2_sort_DnaProfileMatchPairSet_by_score int Wise2_compare_DnaProfileMatchPair(DnaProfileMatchPair * one,DnaProfileMatchPair * two); #define compare_DnaProfileMatchPair Wise2_compare_DnaProfileMatchPair void Wise2_show_DnaProfileSet(DnaProfileSet * dnaps,RandomModelDNA * rm,FILE * ofp); #define show_DnaProfileSet Wise2_show_DnaProfileSet /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_DnaProfileSet(DnaProfile ** list,int i,int j) ; #define swap_DnaProfileSet Wise2_swap_DnaProfileSet void Wise2_qsort_DnaProfileSet(DnaProfile ** list,int left,int right,int (*comp)(DnaProfile * ,DnaProfile * )); #define qsort_DnaProfileSet Wise2_qsort_DnaProfileSet void Wise2_sort_DnaProfileSet(DnaProfileSet * obj,int (*comp)(DnaProfile *, DnaProfile *)); #define sort_DnaProfileSet Wise2_sort_DnaProfileSet boolean Wise2_expand_DnaProfileSet(DnaProfileSet * obj,int len); #define expand_DnaProfileSet Wise2_expand_DnaProfileSet void Wise2_swap_DnaProfileMatchPairSet(DnaProfileMatchPair ** list,int i,int j) ; #define swap_DnaProfileMatchPairSet Wise2_swap_DnaProfileMatchPairSet void Wise2_qsort_DnaProfileMatchPairSet(DnaProfileMatchPair ** list,int left,int right,int (*comp)(DnaProfileMatchPair * ,DnaProfileMatchPair * )); #define qsort_DnaProfileMatchPairSet Wise2_qsort_DnaProfileMatchPairSet void Wise2_sort_DnaProfileMatchPairSet(DnaProfileMatchPairSet * obj,int (*comp)(DnaProfileMatchPair *, DnaProfileMatchPair *)); #define sort_DnaProfileMatchPairSet Wise2_sort_DnaProfileMatchPairSet boolean Wise2_expand_DnaProfileMatchPairSet(DnaProfileMatchPairSet * obj,int len); #define expand_DnaProfileMatchPairSet Wise2_expand_DnaProfileMatchPairSet #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/genewisemodeldb.dy0000644000175000001440000002227007611245646017634 0ustar philippusers %{ #include "dyna.h" #include "genewisemodel.h" #include "threestatedb.h" #include "gwlitemodel.h" %} struct GeneWiseDB ThreeStateDB * tdb double cds_factor; CodonMapper * cm // NB, hard linked. RandomModelDNA * rmd // NB hard linked GeneWiseScore * gws // hardlinked, only if single. GeneParameter21 * gpara // if a genomic model - est models wont use this! boolean is_single !def="FALSE" boolean is_syn !def="TRUE" Probability allN !def="1.0" boolean flat_insert !def=FALSE GwLiteScore * gwls // only if single %info This is a database of genewisemodels for database searching versions of genewise and estwise type algorithms. The actual HMM database streaming happens via the ThreeStateDB (tdb). This object holds the necessary conversion system for the HMM database as it is mapped into the genewisemodel %% %{ #include "genewisemodeldb.h" %func inits a genewise database. Remember this is used for both genomic and cdna searches %% GeneWiseScore * init_GeneWiseDB(GeneWiseDB * gdb,int * return_status) { ThreeStateModel * tsm; GeneWise * gw; GeneWiseScore * gws; *return_status = DB_RETURN_ERROR; if( gdb->is_single == TRUE ) { *return_status = DB_RETURN_OK; return gdb->gws; } if( open_ThreeStateDB(gdb->tdb) == FALSE ) { warn("Could not open three state db, so no genewisemodel possible!"); return NULL; } tsm = read_TSM_ThreeStateDB(gdb->tdb,return_status); if( *return_status == DB_RETURN_ERROR) { warn("Cannot read a ThreeStateModelDB for the GeneWiseDB. Problem!"); return NULL; } gw = GeneWise_from_ThreeStateModel_GDB(tsm,gdb); gws = GeneWiseScore_from_GeneWise(gw); free_ThreeStateModel(tsm); free_GeneWise(gw); return gws; } %func Reloads a genewise database %% GeneWiseScore * reload_GeneWiseDB(GeneWiseScore * prev,GeneWiseDB * gdb,int * return_status) { ThreeStateModel * tsm; GeneWise * gw; GeneWiseScore * gws; if( gdb->is_single == TRUE ) { *return_status = DB_RETURN_END; return NULL; } if( prev != NULL) free_GeneWiseScore(prev); *return_status = DB_RETURN_ERROR; tsm = read_TSM_ThreeStateDB(gdb->tdb,return_status); if( *return_status != DB_RETURN_OK) { if( *return_status == DB_RETURN_END) { return NULL; } warn("Cannot read a ThreeStateModelDB for the GeneWiseDB. Problem!"); return NULL; } gw = GeneWise_from_ThreeStateModel_GDB(tsm,gdb); gws = GeneWiseScore_from_GeneWise(gw); free_ThreeStateModel(tsm); free_GeneWise(gw); *return_status = DB_RETURN_OK; return gws; } %func closes a GeneWiseDB %% boolean close_GeneWiseDB(GeneWiseScore * gws,GeneWiseDB * gdb) { if( gdb->is_single == TRUE ) { return TRUE; } if( gws != NULL) free_GeneWiseScore(gws); return close_ThreeStateDB(NULL,gdb->tdb); } %func adds dataentry stuff to a query. Relies completely on threestatedb %% boolean dataentry_add_GeneWiseDB(DataEntry * de,GeneWiseScore * gws,GeneWiseDB * gdb) { if( gdb->is_single == TRUE) { if ( gdb->gws->name == NULL ) { warn("No name for a single GeneWiseDB unit."); de->name = stringalloc("NoName"); } else { de->name = stringalloc(gdb->gws->name); } return TRUE; } /*de->name = stringalloc(gws->name);*/ /* otherwise, pass it on to tdb */ dataentry_add_ThreeStateDB(de,NULL,gdb->tdb); if( de->name == NULL ) { if( gws->name != NULL ) { de->name = stringalloc(gws->name); } } return TRUE; } %func Makes a genewise models from the threestatemodel and parameters held in the GeneWiseDB %type internal %% GeneWise * GeneWise_from_ThreeStateModel_GDB(ThreeStateModel * tsm,GeneWiseDB * gdb) { int i; GeneWise * out; if( gdb->gpara != NULL ) { out=GeneWise_from_ThreeStateModel(tsm,gdb->gpara->gp,gdb->gpara->cm,gdb->allN,gdb->gpara->gwcm); if( out == NULL ) { return NULL; } if( gdb->gpara->modelled_splice == FALSE) flatten_balance_scores_GeneWise(out); } else { out = GeneWise_alloc_len(tsm->len); out->name = stringalloc(tsm->name); for(i=0;ilen;i++) { add_GeneWise(out,GeneWiseSegment_from_ThreeStateUnit(tsm->unit[i],gdb->cds_factor,gdb->cm,NULL,gdb->allN)); } } if( gdb->is_syn == TRUE ) { if( tsm->rm == NULL ) { warn("Bad error. ThreeStateModel does not have a random model!"); return free_GeneWise(out); } GeneWise_fold_in_synchronised_RandomModel(out,tsm->rm,gdb->cm,gdb->cm->ct,0.5); } else { GeneWise_fold_in_RandomModelDNA(out,gdb->rmd); } if( gdb->flat_insert == TRUE ) { check_flat_insert(out,1,0,gdb->cm->ct); } return out; } %func makes a new GeneWiseDB from its component parts, assumming a cDNA db. All the objects are hard-linked internally, so you can, if you wish, free them once passing them into this function %arg tdb three state model db to use cp codon parser function to remove from match state rmd random model (dna) syn if ture, use a synchronous coding model vs internally stored tdb rm's %% GeneWiseDB * new_GeneWiseDB_cdna(ThreeStateDB * tdb,cDNAParser * cp,CodonMapper * cm,RandomModelDNA * rmd,boolean use_syn,boolean flat_insert,Probability allN) { GeneWiseDB * out; out = GeneWiseDB_alloc(); out->tdb = hard_link_ThreeStateDB(tdb); out->is_single = FALSE; out->rmd = hard_link_RandomModelDNA(rmd); out->cm = hard_link_CodonMapper(cm); out->cds_factor = (1.0 - removed_probability_from_cds_cdna(cp)); out->is_syn = use_syn; out->allN = allN; out->flat_insert = flat_insert; return out; } %func makes a new GeneWiseDB from its component parts. All the objects are hard-linked internally, so you can, if you wish, free them once passing them into this function %% GeneWiseDB * new_GeneWiseDB(ThreeStateDB * tdb,GeneParameter21 * gp,RandomModelDNA * rmd,boolean use_syn,Probability allN) { GeneWiseDB * out; out = GeneWiseDB_alloc(); out->tdb = hard_link_ThreeStateDB(tdb); out->is_single = FALSE; out->rmd = hard_link_RandomModelDNA(rmd); out->gpara = hard_link_GeneParameter21(gp); out->cm = hard_link_CodonMapper(gp->cm); out->is_syn = use_syn; out->allN = allN; return out; } %func makes a new GeneWiseDB from a single GeneWiseScore. It hard links it, so you should free it afterwards in its own scope. %% GeneWiseDB * new_single_GeneWiseDB(GeneWiseScore * gws) { GeneWiseDB * out; out = GeneWiseDB_alloc(); out->gws = hard_link_GeneWiseScore(gws); out->is_single = TRUE; return out; } %func inits a genewise database for gwlite models %% GwLiteScore * init_GwLite_GeneWiseDB(GeneWiseDB * gdb,int * return_status) { ThreeStateModel * tsm; GeneWise * gw; GwLite * gl; GwLiteScore * gws; *return_status = DB_RETURN_ERROR; if( gdb->is_single == TRUE ) { *return_status = DB_RETURN_OK; /* at the moment, die horribly */ fatal("Apologies. We don't handle single genewise model databases for gwlite yet"); return gdb->gwls; } if( open_ThreeStateDB(gdb->tdb) == FALSE ) { warn("Could not open three state db, so no genewisemodel possible!"); return NULL; } tsm = read_TSM_ThreeStateDB(gdb->tdb,return_status); if( *return_status == DB_RETURN_ERROR) { warn("Cannot read a ThreeStateModelDB for the GeneWiseDB. Problem!"); return NULL; } gw = GeneWise_from_ThreeStateModel_GDB(tsm,gdb); gl = GwLite_from_GeneWise(gw); gws = GwLiteScore_from_GwLite(gl); free_ThreeStateModel(tsm); free_GeneWise(gw); free_GwLite(gl); return gws; } %func Reloads a genewise database for a GwLite database %% GwLiteScore * reload_GwLite_GeneWiseDB(GwLiteScore * prev,GeneWiseDB * gdb,int * return_status) { ThreeStateModel * tsm; GeneWise * gw; GwLite * gl; GwLiteScore * gws; if( gdb->is_single == TRUE ) { *return_status = DB_RETURN_END; return NULL; } if( prev != NULL) free_GwLiteScore(prev); *return_status = DB_RETURN_ERROR; tsm = read_TSM_ThreeStateDB(gdb->tdb,return_status); if( *return_status != DB_RETURN_OK) { if( *return_status == DB_RETURN_END) { return NULL; } warn("Cannot read a ThreeStateModelDB for the GeneWiseDB. Problem!"); return NULL; } gw = GeneWise_from_ThreeStateModel_GDB(tsm,gdb); gl = GwLite_from_GeneWise(gw); gws = GwLiteScore_from_GwLite(gl); free_ThreeStateModel(tsm); free_GeneWise(gw); free_GwLite(gl); *return_status = DB_RETURN_OK; return gws; } %func closes a GeneWiseDB %% boolean close_GwLite_GeneWiseDB(GwLiteScore * gws,GeneWiseDB * gdb) { if( gdb->is_single == TRUE ) { return TRUE; } if( gws != NULL) free_GwLiteScore(gws); return close_ThreeStateDB(NULL,gdb->tdb); } %func adds dataentry stuff to a query. Relies completely on threestatedb %% boolean dataentry_add_GwLite_GeneWiseDB(DataEntry * de,GwLiteScore * gws,GeneWiseDB * gdb) { if( gdb->is_single == TRUE) { if ( gdb->gws->name == NULL ) { warn("No name for a single GeneWiseDB unit."); de->name = stringalloc("NoName"); } else { de->name = stringalloc(gdb->gws->name); } return TRUE; } /*de->name = stringalloc(gws->name);*/ /* otherwise, pass it on to tdb */ dataentry_add_ThreeStateDB(de,NULL,gdb->tdb); if( de->name == NULL ) { if( gws->name != NULL ) { de->name = stringalloc(gws->name); } } return TRUE; } %} wise-2.4.1/src/models/alignwisedp.c0000644000175000001440000070225610670453713016617 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "alignwisedp.h" # line 7 "alignwisedp.c" /* Function: hard_link_AlignGeneModelFrame(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlignGeneModelFrame *] * * Return [UNKN ] Undocumented return value [AlignGeneModelFrame *] * */ AlignGeneModelFrame * hard_link_AlignGeneModelFrame(AlignGeneModelFrame * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlignGeneModelFrame object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlignGeneModelFrame_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlignGeneModelFrame *] * */ AlignGeneModelFrame * AlignGeneModelFrame_alloc(void) { AlignGeneModelFrame * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlignGeneModelFrame *) ckalloc (sizeof(AlignGeneModelFrame))) == NULL) { warn("AlignGeneModelFrame_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->len = 0; return out; } /* Function: free_AlignGeneModelFrame(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlignGeneModelFrame *] * * Return [UNKN ] Undocumented return value [AlignGeneModelFrame *] * */ AlignGeneModelFrame * free_AlignGeneModelFrame(AlignGeneModelFrame * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AlignGeneModelFrame obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define CODON 0 #define INTRON_0 1 #define INTRON_1 2 #define INTRON_2 3 #define REVERSE_CODON 4 #define REVERSE_INTRON_0 5 #define REVERSE_INTRON_1 6 #define REVERSE_INTRON_2 7 #define START 0 #define INTERGENIC 1 #define END 2 #define AlignWise_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+10)*8)+STATE][i+0] #define AlignWise_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+10] #define AlignWise_READ_OFF_ERROR -11 #define AlignWise_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+11)%11][((i+0)*8)+STATE] #define AlignWise_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+11)%11][STATE] #define AlignWise_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define AlignWise_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_AlignWise(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_AlignWise(AlignWise * mat) { AlignWise_access_func_holder holder; holder.access_main = AlignWise_shatter_access_main; holder.access_special = AlignWise_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_AlignWise(mat,holder); } /* Function: AlignWise_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int AlignWise_shatter_access_main(AlignWise * mat,int i,int j,int state) { return AlignWise_SHATTER_MATRIX(mat,i,j,state); } /* Function: AlignWise_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int AlignWise_shatter_access_special(AlignWise * mat,int i,int j,int state) { return AlignWise_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_AlignWise(mat,dpenv) * * Descrip: This function calculates the AlignWise matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [AlignWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_AlignWise(AlignWise * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_0_3; int * SIG_0_6; int * SIG_0_5; int * SIG_0_4; int * SIG_0_8; int * SIG_0_1; int * SIG_0_9; int * SIG_0_10; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,8,lenj,3); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("AlignWise Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-6); SIG_0_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-5); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_0_8 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-8); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_0_9 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-9); SIG_0_10 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-10); /* For state CODON */ /* setting first movement to score */ score = SIG_0_3[CODON] + mat->align->forward_coding[j]; /* From state INTERGENIC to state CODON */ temp = AlignWise_SHATTER_SPECIAL(mat,i-0,j-3,INTERGENIC) + mat->align->forward_coding[j]; if( temp > score ) { score = temp; } /* From state INTRON_0 to state CODON */ temp = SIG_0_6[INTRON_0] + (mat->align->splice3_forward[(j-3)]+mat->align->forward_coding[j]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state CODON */ temp = SIG_0_5[INTRON_1] + mat->align->splice3_forward[(j-2)]; if( temp > score ) { score = temp; } /* From state INTRON_2 to state CODON */ temp = SIG_0_4[INTRON_2] + mat->align->splice3_forward[(j-1)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ SIG_0_0[CODON] = score; /* state CODON is a source for special INTERGENIC */ temp = score + (mat->geneopen) + (0) ; if( temp > AlignWise_SHATTER_SPECIAL(mat,i,j,INTERGENIC) ) { AlignWise_SHATTER_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = SIG_0_8[CODON] + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_0 to state INTRON_0 */ temp = SIG_0_1[INTRON_0] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_0] = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SIG_0_9[CODON] + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_1 to state INTRON_1 */ temp = SIG_0_1[INTRON_1] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_1] = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SIG_0_10[CODON] + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_2 to state INTRON_2 */ temp = SIG_0_1[INTRON_2] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_2] = score; /* Finished calculating state INTRON_2 */ /* For state REVERSE_CODON */ /* setting first movement to score */ score = SIG_0_3[REVERSE_CODON] + mat->align->reverse_coding[j]; /* From state INTERGENIC to state REVERSE_CODON */ temp = AlignWise_SHATTER_SPECIAL(mat,i-0,j-3,INTERGENIC) + mat->align->reverse_coding[j]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_0 to state REVERSE_CODON */ temp = SIG_0_6[REVERSE_INTRON_0] + mat->align->splice5_reverse[(j-3)]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_1 to state REVERSE_CODON */ temp = SIG_0_5[REVERSE_INTRON_1] + mat->align->splice5_reverse[(j-2)]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_2 to state REVERSE_CODON */ temp = SIG_0_4[REVERSE_INTRON_2] + mat->align->splice5_reverse[(j-1)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_CODON */ /* Add any movement independant score and put away */ SIG_0_0[REVERSE_CODON] = score; /* state REVERSE_CODON is a source for special INTERGENIC */ temp = score + (mat->geneopen) + (0) ; if( temp > AlignWise_SHATTER_SPECIAL(mat,i,j,INTERGENIC) ) { AlignWise_SHATTER_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* Finished calculating state REVERSE_CODON */ /* For state REVERSE_INTRON_0 */ /* setting first movement to score */ score = SIG_0_8[REVERSE_CODON] + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_0 to state REVERSE_INTRON_0 */ temp = SIG_0_1[REVERSE_INTRON_0] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_0 */ /* Add any movement independant score and put away */ SIG_0_0[REVERSE_INTRON_0] = score; /* Finished calculating state REVERSE_INTRON_0 */ /* For state REVERSE_INTRON_1 */ /* setting first movement to score */ score = SIG_0_9[REVERSE_CODON] + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_1 to state REVERSE_INTRON_1 */ temp = SIG_0_1[REVERSE_INTRON_1] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_1 */ /* Add any movement independant score and put away */ SIG_0_0[REVERSE_INTRON_1] = score; /* Finished calculating state REVERSE_INTRON_1 */ /* For state REVERSE_INTRON_2 */ /* setting first movement to score */ score = SIG_0_10[REVERSE_CODON] + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_2 to state REVERSE_INTRON_2 */ temp = SIG_0_1[REVERSE_INTRON_2] + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_2 */ /* Add any movement independant score and put away */ SIG_0_0[REVERSE_INTRON_2] = score; /* Finished calculating state REVERSE_INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = AlignWise_SHATTER_SPECIAL(mat,0,j,INTERGENIC); /* Source START is a special source for INTERGENIC */ temp = AlignWise_SHATTER_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Source INTERGENIC is a special source for INTERGENIC */ temp = AlignWise_SHATTER_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; /* Source CODON for state INTERGENIC is not special... already calculated */ /* Source REVERSE_CODON for state INTERGENIC is not special... already calculated */ /* Put back score... (now updated!) */ AlignWise_SHATTER_SPECIAL(mat,0,j,INTERGENIC) = score; /* Finished updating state INTERGENIC */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = AlignWise_SHATTER_SPECIAL(mat,0,j,END); /* Source INTERGENIC is a special source for END */ temp = AlignWise_SHATTER_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ AlignWise_SHATTER_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: search_AlignWise(dbsi,out,model,align,intronopen,geneopen) * * Descrip: This function makes a database search of AlignWise * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: model [UNKN ] Undocumented argument [AlignGeneModelFrame*] * Arg: align [UNKN ] Undocumented argument [AlignGeneModelScore*] * Arg: intronopen [UNKN ] Undocumented argument [Score] * Arg: geneopen [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_AlignWise(DBSearchImpl * dbsi,Hscore * out,AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_AlignWise * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_AlignWise. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_AlignWise. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for AlignWise, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_AlignWise(out,model,align ,intronopen,geneopen); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_AlignWise *) ckalloc(sizeof(struct thread_pool_holder_AlignWise)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->model = model; holder->align = align; holder->intronopen = intronopen; holder->geneopen = geneopen; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_AlignWise,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for AlignWise"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from AlignWise",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_AlignWise(ptr) * * Descrip: dummy loop code foreach thread for AlignWise * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * thread_loop_AlignWise(void * ptr) { fatal("dummy thread loop function"); } /* Function: serial_search_AlignWise(out,model,align,intronopen,geneopen) * * Descrip: This function makes a database search of AlignWise * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: model [UNKN ] Undocumented argument [AlignGeneModelFrame*] * Arg: align [UNKN ] Undocumented argument [AlignGeneModelScore*] * Arg: intronopen [UNKN ] Undocumented argument [Score] * Arg: geneopen [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_AlignWise(Hscore * out,AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_AlignWise(model, align , intronopen, geneopen); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("AlignWise search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_AlignWise(model,align,intronopen,geneopen) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_AlignWise_only * * * Arg: model [UNKN ] query data structure [AlignGeneModelFrame*] * Arg: align [UNKN ] target data structure [AlignGeneModelScore*] * Arg: intronopen [UNKN ] Resource [Score] * Arg: geneopen [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_AlignWise(AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen) { int bestscore = NEGI; int i; int j; int k; AlignWise * mat; mat = allocate_AlignWise_only(model, align , intronopen, geneopen); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(11,(mat->leni + 0) * 8,11,3)) == NULL) { warn("Score only matrix for AlignWise cannot be allocated, (asking for 10 by %d cells)",mat->leni*8); mat = free_AlignWise(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<12;j++) { for(i=(-0);ileni;i++) { for(k=0;k<8;k++) AlignWise_VSMALL_MATRIX(mat,i,j,k) = NEGI; } AlignWise_VSMALL_SPECIAL(mat,i,j,START) = 0; AlignWise_VSMALL_SPECIAL(mat,i,j,INTERGENIC) = NEGI; AlignWise_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state CODON */ /* setting first movement to score */ score = AlignWise_VSMALL_MATRIX(mat,i-0,j-3,CODON) + mat->align->forward_coding[j]; /* From state INTERGENIC to state CODON */ temp = AlignWise_VSMALL_SPECIAL(mat,i-0,j-3,INTERGENIC) + mat->align->forward_coding[j]; if( temp > score ) { score = temp; } /* From state INTRON_0 to state CODON */ temp = AlignWise_VSMALL_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->align->splice3_forward[(j-3)]+mat->align->forward_coding[j]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state CODON */ temp = AlignWise_VSMALL_MATRIX(mat,i-0,j-5,INTRON_1) + mat->align->splice3_forward[(j-2)]; if( temp > score ) { score = temp; } /* From state INTRON_2 to state CODON */ temp = AlignWise_VSMALL_MATRIX(mat,i-0,j-4,INTRON_2) + mat->align->splice3_forward[(j-1)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ AlignWise_VSMALL_MATRIX(mat,i,j,CODON) = score; /* state CODON is a source for special INTERGENIC */ temp = score + (mat->geneopen) + (0) ; if( temp > AlignWise_VSMALL_SPECIAL(mat,i,j,INTERGENIC) ) { AlignWise_VSMALL_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = AlignWise_VSMALL_MATRIX(mat,i-0,j-8,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_0 to state INTRON_0 */ temp = AlignWise_VSMALL_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ AlignWise_VSMALL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = AlignWise_VSMALL_MATRIX(mat,i-0,j-9,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_1 to state INTRON_1 */ temp = AlignWise_VSMALL_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ AlignWise_VSMALL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = AlignWise_VSMALL_MATRIX(mat,i-0,j-10,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_2 to state INTRON_2 */ temp = AlignWise_VSMALL_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ AlignWise_VSMALL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state REVERSE_CODON */ /* setting first movement to score */ score = AlignWise_VSMALL_MATRIX(mat,i-0,j-3,REVERSE_CODON) + mat->align->reverse_coding[j]; /* From state INTERGENIC to state REVERSE_CODON */ temp = AlignWise_VSMALL_SPECIAL(mat,i-0,j-3,INTERGENIC) + mat->align->reverse_coding[j]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_0 to state REVERSE_CODON */ temp = AlignWise_VSMALL_MATRIX(mat,i-0,j-6,REVERSE_INTRON_0) + mat->align->splice5_reverse[(j-3)]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_1 to state REVERSE_CODON */ temp = AlignWise_VSMALL_MATRIX(mat,i-0,j-5,REVERSE_INTRON_1) + mat->align->splice5_reverse[(j-2)]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_2 to state REVERSE_CODON */ temp = AlignWise_VSMALL_MATRIX(mat,i-0,j-4,REVERSE_INTRON_2) + mat->align->splice5_reverse[(j-1)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_CODON */ /* Add any movement independant score and put away */ AlignWise_VSMALL_MATRIX(mat,i,j,REVERSE_CODON) = score; /* state REVERSE_CODON is a source for special INTERGENIC */ temp = score + (mat->geneopen) + (0) ; if( temp > AlignWise_VSMALL_SPECIAL(mat,i,j,INTERGENIC) ) { AlignWise_VSMALL_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* Finished calculating state REVERSE_CODON */ /* For state REVERSE_INTRON_0 */ /* setting first movement to score */ score = AlignWise_VSMALL_MATRIX(mat,i-0,j-8,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_0 to state REVERSE_INTRON_0 */ temp = AlignWise_VSMALL_MATRIX(mat,i-0,j-1,REVERSE_INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_0 */ /* Add any movement independant score and put away */ AlignWise_VSMALL_MATRIX(mat,i,j,REVERSE_INTRON_0) = score; /* Finished calculating state REVERSE_INTRON_0 */ /* For state REVERSE_INTRON_1 */ /* setting first movement to score */ score = AlignWise_VSMALL_MATRIX(mat,i-0,j-9,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_1 to state REVERSE_INTRON_1 */ temp = AlignWise_VSMALL_MATRIX(mat,i-0,j-1,REVERSE_INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_1 */ /* Add any movement independant score and put away */ AlignWise_VSMALL_MATRIX(mat,i,j,REVERSE_INTRON_1) = score; /* Finished calculating state REVERSE_INTRON_1 */ /* For state REVERSE_INTRON_2 */ /* setting first movement to score */ score = AlignWise_VSMALL_MATRIX(mat,i-0,j-10,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_2 to state REVERSE_INTRON_2 */ temp = AlignWise_VSMALL_MATRIX(mat,i-0,j-1,REVERSE_INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_2 */ /* Add any movement independant score and put away */ AlignWise_VSMALL_MATRIX(mat,i,j,REVERSE_INTRON_2) = score; /* Finished calculating state REVERSE_INTRON_2 */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = AlignWise_VSMALL_SPECIAL(mat,0,j,INTERGENIC); /* Source START is a special source for INTERGENIC */ temp = AlignWise_VSMALL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Source INTERGENIC is a special source for INTERGENIC */ temp = AlignWise_VSMALL_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; /* Source CODON for state INTERGENIC is not special... already calculated */ /* Source REVERSE_CODON for state INTERGENIC is not special... already calculated */ /* Put back score... (now updated!) */ AlignWise_VSMALL_SPECIAL(mat,0,j,INTERGENIC) = score; /* Finished updating state INTERGENIC */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = AlignWise_VSMALL_SPECIAL(mat,0,j,END); /* Source INTERGENIC is a special source for END */ temp = AlignWise_VSMALL_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ AlignWise_VSMALL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ if( bestscore < AlignWise_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = AlignWise_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_AlignWise(mat); return bestscore; } /* Function: PackAln_bestmemory_AlignWise(model,align,intronopen,geneopen,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_AlignWise * * * Arg: model [UNKN ] query data structure [AlignGeneModelFrame*] * Arg: align [UNKN ] target data structure [AlignGeneModelScore*] * Arg: intronopen [UNKN ] Resource [Score] * Arg: geneopen [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_AlignWise(AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; AlignWise * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = model->len * align->len; if( dpri->memory == DPIM_Default ) { if( (total * 8 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_AlignWise(model, align , intronopen, geneopen,dpri)) == NULL ) { warn("Unable to allocate large AlignWise version"); return NULL; } calculate_dpenv_AlignWise(mat,dpenv); out = PackAln_read_Expl_AlignWise(mat); } else { mat = allocate_AlignWise_only(model, align , intronopen, geneopen); calculate_shatter_AlignWise(mat,dpenv); out = PackAln_read_Shatter_AlignWise(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_AlignWise(model, align , intronopen, geneopen)) == NULL ) { warn("Unable to allocate small AlignWise version"); return NULL; } out = PackAln_calculate_Small_AlignWise(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_AlignWise(model, align , intronopen, geneopen,dpri)) == NULL ) { warn("Unable to allocate large AlignWise version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_AlignWise(mat); out = PackAln_read_Expl_AlignWise(mat); } } } mat = free_AlignWise(mat); return out; } /* Function: allocate_AlignWise_only(model,align,intronopen,geneopen) * * Descrip: This function only allocates the AlignWise structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: model [UNKN ] query data structure [AlignGeneModelFrame*] * Arg: align [UNKN ] target data structure [AlignGeneModelScore*] * Arg: intronopen [UNKN ] Resource [Score] * Arg: geneopen [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [AlignWise *] * */ AlignWise * allocate_AlignWise_only(AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen) { AlignWise * out; if((out= AlignWise_alloc()) == NULL) { warn("Allocation of basic AlignWise structure failed..."); return NULL; } out->model = model; out->align = align; out->intronopen = intronopen; out->geneopen = geneopen; out->leni = model->len; out->lenj = align->len; return out; } /* Function: allocate_Expl_AlignWise(model,align,intronopen,geneopen,dpri) * * Descrip: This function allocates the AlignWise structure * and the basematrix area for explicit memory implementations * It calls /allocate_AlignWise_only * * * Arg: model [UNKN ] query data structure [AlignGeneModelFrame*] * Arg: align [UNKN ] target data structure [AlignGeneModelScore*] * Arg: intronopen [UNKN ] Resource [Score] * Arg: geneopen [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [AlignWise *] * */ AlignWise * allocate_Expl_AlignWise(AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen,DPRunImpl * dpri) { AlignWise * out; out = allocate_AlignWise_only(model, align , intronopen, geneopen); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+10)*8 && dpri->cache->maxlenj >= (out->leni+0)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+10)*8,(out->leni+0),3,out->lenj+10)) == NULL) { warn("Explicit matrix AlignWise cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_AlignWise(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_AlignWise(out); return out; } /* Function: init_AlignWise(mat) * * Descrip: This function initates AlignWise matrix when in explicit mode * Called in /allocate_Expl_AlignWise * * * Arg: mat [UNKN ] AlignWise which contains explicit basematrix memory [AlignWise *] * */ void init_AlignWise(AlignWise * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-0);imodel->len;i++) { for(j= (-10);j<11;j++) { AlignWise_EXPL_MATRIX(mat,i,j,CODON) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_CODON) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_0) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_1) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_2) = NEGI; } } for(j= (-10);jalign->len;j++) { for(i= (-0);i<1;i++) { AlignWise_EXPL_MATRIX(mat,i,j,CODON) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_CODON) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_0) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_1) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_2) = NEGI; } AlignWise_EXPL_SPECIAL(mat,i,j,START) = 0; AlignWise_EXPL_SPECIAL(mat,i,j,INTERGENIC) = NEGI; AlignWise_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_AlignWise(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by AlignWise * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * */ void recalculate_PackAln_AlignWise(PackAln * pal,AlignWise * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case CODON : if( offi == 0 && offj == 3 && prev->state == CODON ) { pau->score = mat->align->forward_coding[j] + (0); continue; } if( offj == 3 && prev->state == (INTERGENIC+8) ) { pau->score = mat->align->forward_coding[j] + (0); continue; } if( offi == 0 && offj == 6 && prev->state == INTRON_0 ) { pau->score = (mat->align->splice3_forward[(j-3)]+mat->align->forward_coding[j]) + (0); continue; } if( offi == 0 && offj == 5 && prev->state == INTRON_1 ) { pau->score = mat->align->splice3_forward[(j-2)] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == INTRON_2 ) { pau->score = mat->align->splice3_forward[(j-1)] + (0); continue; } warn("In recaluclating PackAln with state CODON, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_0 : if( offi == 0 && offj == 8 && prev->state == CODON ) { pau->score = (mat->align->splice5_forward[(j-7)]+mat->intronopen) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_0 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_1 : if( offi == 0 && offj == 9 && prev->state == CODON ) { pau->score = (mat->align->splice5_forward[(j-7)]+mat->intronopen) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_1 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_2 : if( offi == 0 && offj == 10 && prev->state == CODON ) { pau->score = (mat->align->splice5_forward[(j-7)]+mat->intronopen) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_2 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case REVERSE_CODON : if( offi == 0 && offj == 3 && prev->state == REVERSE_CODON ) { pau->score = mat->align->reverse_coding[j] + (0); continue; } if( offj == 3 && prev->state == (INTERGENIC+8) ) { pau->score = mat->align->reverse_coding[j] + (0); continue; } if( offi == 0 && offj == 6 && prev->state == REVERSE_INTRON_0 ) { pau->score = mat->align->splice5_reverse[(j-3)] + (0); continue; } if( offi == 0 && offj == 5 && prev->state == REVERSE_INTRON_1 ) { pau->score = mat->align->splice5_reverse[(j-2)] + (0); continue; } if( offi == 0 && offj == 4 && prev->state == REVERSE_INTRON_2 ) { pau->score = mat->align->splice5_reverse[(j-1)] + (0); continue; } warn("In recaluclating PackAln with state REVERSE_CODON, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case REVERSE_INTRON_0 : if( offi == 0 && offj == 8 && prev->state == REVERSE_CODON ) { pau->score = (mat->align->splice3_reverse[(j-7)]+mat->intronopen) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == REVERSE_INTRON_0 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state REVERSE_INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case REVERSE_INTRON_1 : if( offi == 0 && offj == 9 && prev->state == REVERSE_CODON ) { pau->score = (mat->align->splice3_reverse[(j-7)]+mat->intronopen) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == REVERSE_INTRON_1 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state REVERSE_INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case REVERSE_INTRON_2 : if( offi == 0 && offj == 10 && prev->state == REVERSE_CODON ) { pau->score = (mat->align->splice3_reverse[(j-7)]+mat->intronopen) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == REVERSE_INTRON_2 ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state REVERSE_INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+8) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (INTERGENIC+8) : if( offj == 1 && prev->state == (START+8) ) { pau->score = 0 + (0); continue; } if( offj == 1 && prev->state == (INTERGENIC+8) ) { pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == CODON ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->geneopen + (0); continue; } if( offj == 0 && prev->state == REVERSE_CODON ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->geneopen + (0); continue; } warn("In recaluclating PackAln with state INTERGENIC, got a bad source state. Error!"); break; case (END+8) : if( offj == 1 && prev->state == (INTERGENIC+8) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define AlignWise_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+10)][(i+0)*8+state]) #define AlignWise_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+11)*8) % 88][(i+0)*8+state]) #define AlignWise_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+10)]) #define AlignWise_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) #define AlignWise_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+11)*8)+(shadow+1)) % 88)][(i+0)*8 + state]) #define AlignWise_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) #define AlignWise_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+10)% 10) * (leni+1) * 8) + ((i+0) * 8) + (state)]) #define AlignWise_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+10)% 10) * (leni+1) * 64) + ((i+0) * 64) + (state * 8) + shadow+1]) #define AlignWise_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) /* Function: allocate_Small_AlignWise(model,align,intronopen,geneopen) * * Descrip: This function allocates the AlignWise structure * and the basematrix area for a small memory implementations * It calls /allocate_AlignWise_only * * * Arg: model [UNKN ] query data structure [AlignGeneModelFrame*] * Arg: align [UNKN ] target data structure [AlignGeneModelScore*] * Arg: intronopen [UNKN ] Resource [Score] * Arg: geneopen [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [AlignWise *] * */ #define AlignWise_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) AlignWise * allocate_Small_AlignWise(AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen) { AlignWise * out; out = allocate_AlignWise_only(model, align , intronopen, geneopen); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(88,(out->leni + 0) * 8,24,out->lenj+10); if(out == NULL) { warn("Small shadow matrix AlignWise cannot be allocated, (asking for 11 by %d main cells)",out->leni+1); free_AlignWise(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_AlignWise(mat,dpenv) * * Descrip: This function calculates an alignment for AlignWise structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_AlignWise * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_AlignWise * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_AlignWise(AlignWise * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for AlignWise due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_AlignWise(mat,dpenv); score = start_end_find_end_AlignWise(mat,&endj); out->score = score; stopstate = END; /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */ log_full_error(REPORT,0,"End at %d Score %d",endj,score); stop_reporting(); for(;;) { /*while there are more special bits to recover*/ start_reporting("Special cell aln end %d:",endj); if( read_special_strip_AlignWise(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) { warn("Problem in reading off special state system... going to return partial alignment"); break; } if( startstate == START || endj <= 0) { log_full_error(REPORT,0,"Recovered complete alignment"); stop_reporting(); break; } log_full_error(REPORT,0,"Finished to %d",endj); stop_reporting(); /* Ok... have to eat up another piece of matrix */ temp = startstate; starti = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0); startj = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1); startstate = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2); stopi = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3); stopj = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4); stopstate = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5); /* Get out the score of this block. V. important! */ temp = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6); totalj = stopj - startj; donej = 0; start_reporting("Main matrix aln [%d,%d]:",startj,stopj); if(full_dc_AlignWise(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) { warn("In the alignment AlignWise [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj); return out; } /* now have to figure out which special we came from... yikes */ max_matrix_to_special_AlignWise(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == AlignWise_READ_OFF_ERROR) { warn("In AlignWise read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj); invert_PackAln(out); recalculate_PackAln_AlignWise(out,mat); return out; } /* if at start, break, otherwise, back to eat another strip */ if( stopstate == START) { log_full_error(REPORT,0,"Recovered complete alignment "); stop_reporting(); break; } log_full_error(REPORT,0,"Finished alignment to %d ",startj); stop_reporting(); endj = stopj; /* stopstate is correct as it is */ } /* end of while there are more special bits to recover */ invert_PackAln(out); recalculate_PackAln_AlignWise(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_AlignWise(mat) * * Descrip: This function calculates an alignment for AlignWise structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_AlignWise * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_AlignWise * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_AlignWise * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_AlignWise(AlignWise * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_AlignWise(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_AlignWise(mat); return out; } /* Function: AlnRangeSet_from_AlignWise(mat) * * Descrip: This function reads off a start/end structure * for AlignWise structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_AlignWise * If you have not calculated the matrix use * /AlnRange_calculate_Small_AlignWise * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_AlignWise(AlignWise * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_AlignWise"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_AlignWise(mat,&jpos); state = END; while( (temp = AlnRange_build_AlignWise(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_AlignWise(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_AlignWise * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_AlignWise(AlignWise * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_AlignWise"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_AlignWise(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_AlignWise alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = AlignWise_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_AlignWise(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == AlignWise_READ_OFF_ERROR) { warn("In AlnRange_build_AlignWise alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = AlignWise_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_AlignWise(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_AlignWise(AlignWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_AlignWise(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == AlignWise_READ_OFF_ERROR) { warn("In AlignWise hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In AlignWise hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In AlignWise hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_AlignWise(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_AlignWise(AlignWise * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = AlignWise_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->model->len || j > mat->align->len) { warn("In AlignWise matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = AlignWise_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case CODON : temp = cscore - (mat->align->splice3_forward[(j-1)]) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (mat->align->splice3_forward[(j-2)]) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1); } temp = cscore - ((mat->align->splice3_forward[(j-3)]+mat->align->forward_coding[j])) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0); } /* Not allowing special sources.. skipping INTERGENIC */ temp = cscore - (mat->align->forward_coding[j]) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 3,CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-3,CODON); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 3,CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - (0) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((mat->align->splice5_forward[(j-7)]+mat->intronopen)) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 8,CODON) ) { *reti = i - 0; *retj = j - 8; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-8,CODON); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 8,CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - (0) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((mat->align->splice5_forward[(j-7)]+mat->intronopen)) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 9,CODON) ) { *reti = i - 0; *retj = j - 9; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-9,CODON); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 9,CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - (0) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((mat->align->splice5_forward[(j-7)]+mat->intronopen)) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 10,CODON) ) { *reti = i - 0; *retj = j - 10; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-10,CODON); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 10,CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REVERSE_CODON : temp = cscore - (mat->align->splice5_reverse[(j-1)]) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 4,REVERSE_INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = REVERSE_INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-4,REVERSE_INTRON_2); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 4,REVERSE_INTRON_2); } temp = cscore - (mat->align->splice5_reverse[(j-2)]) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 5,REVERSE_INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = REVERSE_INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-5,REVERSE_INTRON_1); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 5,REVERSE_INTRON_1); } temp = cscore - (mat->align->splice5_reverse[(j-3)]) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 6,REVERSE_INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = REVERSE_INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-6,REVERSE_INTRON_0); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 6,REVERSE_INTRON_0); } /* Not allowing special sources.. skipping INTERGENIC */ temp = cscore - (mat->align->reverse_coding[j]) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 3,REVERSE_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = REVERSE_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-3,REVERSE_CODON); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 3,REVERSE_CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REVERSE_INTRON_0 : temp = cscore - (0) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 1,REVERSE_INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = REVERSE_INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-1,REVERSE_INTRON_0); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 1,REVERSE_INTRON_0); } temp = cscore - ((mat->align->splice3_reverse[(j-7)]+mat->intronopen)) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 8,REVERSE_CODON) ) { *reti = i - 0; *retj = j - 8; *retstate = REVERSE_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-8,REVERSE_CODON); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 8,REVERSE_CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REVERSE_INTRON_1 : temp = cscore - (0) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 1,REVERSE_INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = REVERSE_INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-1,REVERSE_INTRON_1); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 1,REVERSE_INTRON_1); } temp = cscore - ((mat->align->splice3_reverse[(j-7)]+mat->intronopen)) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 9,REVERSE_CODON) ) { *reti = i - 0; *retj = j - 9; *retstate = REVERSE_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-9,REVERSE_CODON); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 9,REVERSE_CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REVERSE_INTRON_2 : temp = cscore - (0) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 1,REVERSE_INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = REVERSE_INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-1,REVERSE_INTRON_2); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 1,REVERSE_INTRON_2); } temp = cscore - ((mat->align->splice3_reverse[(j-7)]+mat->intronopen)) - (0); if( temp == AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 10,REVERSE_CODON) ) { *reti = i - 0; *retj = j - 10; *retstate = REVERSE_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_HIDDEN_MATRIX(mat,i-0,j-10,REVERSE_CODON); } return AlignWise_HIDDEN_MATRIX(mat,i - 0,j - 10,REVERSE_CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_AlignWise(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_AlignWise(AlignWise * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > AlignWise_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 8; add_PackAln(out,pau); } max_special_strip_AlignWise(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == AlignWise_READ_OFF_ERROR) { warn("In special strip read AlignWise, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < AlignWise_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read AlignWise, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 8; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_AlignWise(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_AlignWise(AlignWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = AlignWise_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for AlignWise, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->align->len) { warn("In AlignWise matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = AlignWise_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case INTERGENIC : /* Source REVERSE_CODON is not a special */ /* Source CODON is not a special */ /* source INTERGENIC is a special */ temp = cscore - (0) - (0); if( temp == AlignWise_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_DC_SHADOW_SPECIAL(mat,i-0,j-1,INTERGENIC); } return AlignWise_DC_SHADOW_MATRIX(mat,i - 0,j - 1,INTERGENIC) ; } /* source START is a special */ temp = cscore - (0) - (0); if( temp == AlignWise_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return AlignWise_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } case END : /* source INTERGENIC is a special */ temp = cscore - (0) - (0); if( temp == AlignWise_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_DC_SHADOW_SPECIAL(mat,i-0,j-1,INTERGENIC); } return AlignWise_DC_SHADOW_MATRIX(mat,i - 0,j - 1,INTERGENIC) ; } default: warn("Major problem (!) - in AlignWise special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_AlignWise(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_AlignWise(AlignWise * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = AlignWise_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In AlignWise matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case CODON : /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ temp = cscore - (mat->align->forward_coding[j]) - (0); if( temp == AlignWise_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,INTERGENIC) ) { *reti = i - 0; *retj = j - 3; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_DC_SHADOW_SPECIAL(mat,i-0,j-3,INTERGENIC); } return AlignWise_DC_SHADOW_MATRIX(mat,i - 0,j - 3,INTERGENIC) ; } /* Source CODON is not a special, should not get here! */ warn("Major problem (!) - in AlignWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : /* Source INTRON_0 is not a special, should not get here! */ /* Source CODON is not a special, should not get here! */ warn("Major problem (!) - in AlignWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : /* Source INTRON_1 is not a special, should not get here! */ /* Source CODON is not a special, should not get here! */ warn("Major problem (!) - in AlignWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : /* Source INTRON_2 is not a special, should not get here! */ /* Source CODON is not a special, should not get here! */ warn("Major problem (!) - in AlignWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REVERSE_CODON : /* Source REVERSE_INTRON_2 is not a special, should not get here! */ /* Source REVERSE_INTRON_1 is not a special, should not get here! */ /* Source REVERSE_INTRON_0 is not a special, should not get here! */ temp = cscore - (mat->align->reverse_coding[j]) - (0); if( temp == AlignWise_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,INTERGENIC) ) { *reti = i - 0; *retj = j - 3; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - AlignWise_DC_SHADOW_SPECIAL(mat,i-0,j-3,INTERGENIC); } return AlignWise_DC_SHADOW_MATRIX(mat,i - 0,j - 3,INTERGENIC) ; } /* Source REVERSE_CODON is not a special, should not get here! */ warn("Major problem (!) - in AlignWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REVERSE_INTRON_0 : /* Source REVERSE_INTRON_0 is not a special, should not get here! */ /* Source REVERSE_CODON is not a special, should not get here! */ warn("Major problem (!) - in AlignWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REVERSE_INTRON_1 : /* Source REVERSE_INTRON_1 is not a special, should not get here! */ /* Source REVERSE_CODON is not a special, should not get here! */ warn("Major problem (!) - in AlignWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REVERSE_INTRON_2 : /* Source REVERSE_INTRON_2 is not a special, should not get here! */ /* Source REVERSE_CODON is not a special, should not get here! */ warn("Major problem (!) - in AlignWise matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_AlignWise(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_AlignWise(AlignWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_AlignWise(mat,starti,startj,stopi,stopj); AlignWise_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ AlignWise_HIDDEN_MATRIX(mat,i,j,CODON) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,REVERSE_CODON) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,REVERSE_INTRON_0) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,REVERSE_INTRON_1) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,REVERSE_INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ /* For state CODON */ /* setting first movement to score */ score = AlignWise_HIDDEN_MATRIX(mat,i-0,j-3,CODON) + mat->align->forward_coding[j]; /* From state INTRON_0 to state CODON */ temp = AlignWise_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->align->splice3_forward[(j-3)]+mat->align->forward_coding[j]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state CODON */ temp = AlignWise_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1) + mat->align->splice3_forward[(j-2)]; if( temp > score ) { score = temp; } /* From state INTRON_2 to state CODON */ temp = AlignWise_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2) + mat->align->splice3_forward[(j-1)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ AlignWise_HIDDEN_MATRIX(mat,i,j,CODON) = score; /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = AlignWise_HIDDEN_MATRIX(mat,i-0,j-8,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_0 to state INTRON_0 */ temp = AlignWise_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ AlignWise_HIDDEN_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = AlignWise_HIDDEN_MATRIX(mat,i-0,j-9,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_1 to state INTRON_1 */ temp = AlignWise_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ AlignWise_HIDDEN_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = AlignWise_HIDDEN_MATRIX(mat,i-0,j-10,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_2 to state INTRON_2 */ temp = AlignWise_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ AlignWise_HIDDEN_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state REVERSE_CODON */ /* setting first movement to score */ score = AlignWise_HIDDEN_MATRIX(mat,i-0,j-3,REVERSE_CODON) + mat->align->reverse_coding[j]; /* From state REVERSE_INTRON_0 to state REVERSE_CODON */ temp = AlignWise_HIDDEN_MATRIX(mat,i-0,j-6,REVERSE_INTRON_0) + mat->align->splice5_reverse[(j-3)]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_1 to state REVERSE_CODON */ temp = AlignWise_HIDDEN_MATRIX(mat,i-0,j-5,REVERSE_INTRON_1) + mat->align->splice5_reverse[(j-2)]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_2 to state REVERSE_CODON */ temp = AlignWise_HIDDEN_MATRIX(mat,i-0,j-4,REVERSE_INTRON_2) + mat->align->splice5_reverse[(j-1)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_CODON */ /* Add any movement independant score and put away */ AlignWise_HIDDEN_MATRIX(mat,i,j,REVERSE_CODON) = score; /* Finished calculating state REVERSE_CODON */ /* For state REVERSE_INTRON_0 */ /* setting first movement to score */ score = AlignWise_HIDDEN_MATRIX(mat,i-0,j-8,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_0 to state REVERSE_INTRON_0 */ temp = AlignWise_HIDDEN_MATRIX(mat,i-0,j-1,REVERSE_INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_0 */ /* Add any movement independant score and put away */ AlignWise_HIDDEN_MATRIX(mat,i,j,REVERSE_INTRON_0) = score; /* Finished calculating state REVERSE_INTRON_0 */ /* For state REVERSE_INTRON_1 */ /* setting first movement to score */ score = AlignWise_HIDDEN_MATRIX(mat,i-0,j-9,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_1 to state REVERSE_INTRON_1 */ temp = AlignWise_HIDDEN_MATRIX(mat,i-0,j-1,REVERSE_INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_1 */ /* Add any movement independant score and put away */ AlignWise_HIDDEN_MATRIX(mat,i,j,REVERSE_INTRON_1) = score; /* Finished calculating state REVERSE_INTRON_1 */ /* For state REVERSE_INTRON_2 */ /* setting first movement to score */ score = AlignWise_HIDDEN_MATRIX(mat,i-0,j-10,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_2 to state REVERSE_INTRON_2 */ temp = AlignWise_HIDDEN_MATRIX(mat,i-0,j-1,REVERSE_INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_2 */ /* Add any movement independant score and put away */ AlignWise_HIDDEN_MATRIX(mat,i,j,REVERSE_INTRON_2) = score; /* Finished calculating state REVERSE_INTRON_2 */ } } return; } /* Function: init_hidden_AlignWise(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_AlignWise(AlignWise * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-10);j<=stopj;j++) { for(i=(starti-0);i<=stopi;i++) { AlignWise_HIDDEN_MATRIX(mat,i,j,CODON) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,REVERSE_CODON) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,REVERSE_INTRON_0) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,REVERSE_INTRON_1) = NEGI; AlignWise_HIDDEN_MATRIX(mat,i,j,REVERSE_INTRON_2) = NEGI; } } return; } /* Function: full_dc_AlignWise(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_AlignWise * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_AlignWise to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [AlignWise *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_AlignWise(AlignWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_AlignWise"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 50) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_AlignWise(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_AlignWise(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_AlignWise(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for AlignWise, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= AlignWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= AlignWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = AlignWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_AlignWise(mat,AlignWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),AlignWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),AlignWise_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_AlignWise(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_AlignWise(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_AlignWise(AlignWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_AlignWise(mat); AlignWise_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_AlignWise(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_AlignWise(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_AlignWise(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_AlignWise(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_AlignWise(AlignWise * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<10;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ AlignWise_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = (-100); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = (-100); AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-100); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = (-100); AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-100); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = (-100); AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-100); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = (-100); AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_CODON) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,0) = (-100); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,1) = (-100); AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_0) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,0) = (-100); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,1) = (-100); AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_1) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,0) = (-100); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,1) = (-100); AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_2) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,0) = (-100); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,1) = (-100); continue; } /* end of Is not in envelope */ /* For state CODON, pushing when j - offj <= mergej */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + mat->align->forward_coding[j]; if( j - 3 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-3; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = CODON; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,k); } temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->align->splice3_forward[(j-3)]+mat->align->forward_coding[j]); if( temp > score) { score = temp; if( j - 6 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-6; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = INTRON_0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } } temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + mat->align->splice3_forward[(j-2)]; if( temp > score) { score = temp; if( j - 5 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-5; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = INTRON_1; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } } temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + mat->align->splice3_forward[(j-1)]; if( temp > score) { score = temp; if( j - 4 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,1) = j-4; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,2) = INTRON_2; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,5) = CODON; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } } /* Add any movement independant score */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,CODON) = score; /* Finished with state CODON */ /* For state INTRON_0, pushing when j - offj <= mergej */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-8,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); if( j - 8 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = CODON; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,CODON,k); } temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INTRON_0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } } /* Add any movement independant score */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished with state INTRON_0 */ /* For state INTRON_1, pushing when j - offj <= mergej */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-9,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); if( j - 9 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = CODON; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,CODON,k); } temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-1; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INTRON_1; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } } /* Add any movement independant score */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished with state INTRON_1 */ /* For state INTRON_2, pushing when j - offj <= mergej */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-10,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); if( j - 10 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = CODON; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,CODON,k); } temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-1; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INTRON_2; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } } /* Add any movement independant score */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished with state INTRON_2 */ /* For state REVERSE_CODON, pushing when j - offj <= mergej */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-3,REVERSE_CODON) + mat->align->reverse_coding[j]; if( j - 3 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,1) = j-3; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,2) = REVERSE_CODON; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,5) = REVERSE_CODON; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,REVERSE_CODON,k); } temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-6,REVERSE_INTRON_0) + mat->align->splice5_reverse[(j-3)]; if( temp > score) { score = temp; if( j - 6 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,1) = j-6; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,2) = REVERSE_INTRON_0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,5) = REVERSE_CODON; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,REVERSE_INTRON_0,k); } } temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-5,REVERSE_INTRON_1) + mat->align->splice5_reverse[(j-2)]; if( temp > score) { score = temp; if( j - 5 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,1) = j-5; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,2) = REVERSE_INTRON_1; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,5) = REVERSE_CODON; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,REVERSE_INTRON_1,k); } } temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-4,REVERSE_INTRON_2) + mat->align->splice5_reverse[(j-1)]; if( temp > score) { score = temp; if( j - 4 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,1) = j-4; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,2) = REVERSE_INTRON_2; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,5) = REVERSE_CODON; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,REVERSE_INTRON_2,k); } } /* Add any movement independant score */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_CODON) = score; /* Finished with state REVERSE_CODON */ /* For state REVERSE_INTRON_0, pushing when j - offj <= mergej */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-8,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); if( j - 8 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,1) = j-8; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,2) = REVERSE_CODON; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,5) = REVERSE_INTRON_0; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,REVERSE_CODON,k); } temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,REVERSE_INTRON_0) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,1) = j-1; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,2) = REVERSE_INTRON_0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,5) = REVERSE_INTRON_0; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REVERSE_INTRON_0,k); } } /* Add any movement independant score */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_0) = score; /* Finished with state REVERSE_INTRON_0 */ /* For state REVERSE_INTRON_1, pushing when j - offj <= mergej */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-9,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); if( j - 9 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,1) = j-9; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,2) = REVERSE_CODON; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,5) = REVERSE_INTRON_1; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,REVERSE_CODON,k); } temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,REVERSE_INTRON_1) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,1) = j-1; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,2) = REVERSE_INTRON_1; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,5) = REVERSE_INTRON_1; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REVERSE_INTRON_1,k); } } /* Add any movement independant score */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_1) = score; /* Finished with state REVERSE_INTRON_1 */ /* For state REVERSE_INTRON_2, pushing when j - offj <= mergej */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-10,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); if( j - 10 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,1) = j-10; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,2) = REVERSE_CODON; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,5) = REVERSE_INTRON_2; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,REVERSE_CODON,k); } temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,REVERSE_INTRON_2) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,0) = i-0; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,1) = j-1; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,2) = REVERSE_INTRON_2; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,3) = i; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,4) = j; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,5) = REVERSE_INTRON_2; } else { for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,k) = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REVERSE_INTRON_2,k); } } /* Add any movement independant score */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_2) = score; /* Finished with state REVERSE_INTRON_2 */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_AlignWise(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_AlignWise(AlignWise * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ AlignWise_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_CODON) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_0) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_1) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state CODON */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + mat->align->forward_coding[j]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,k); /* From state INTRON_0 to state CODON */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->align->splice3_forward[(j-3)]+mat->align->forward_coding[j]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } /* From state INTRON_1 to state CODON */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + mat->align->splice3_forward[(j-2)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } /* From state INTRON_2 to state CODON */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + mat->align->splice3_forward[(j-1)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,CODON) = score; for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-8,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,CODON,k); /* From state INTRON_0 to state INTRON_0 */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-9,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,CODON,k); /* From state INTRON_1 to state INTRON_1 */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-10,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,CODON,k); /* From state INTRON_2 to state INTRON_2 */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ /* For state REVERSE_CODON */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-3,REVERSE_CODON) + mat->align->reverse_coding[j]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,REVERSE_CODON,k); /* From state REVERSE_INTRON_0 to state REVERSE_CODON */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-6,REVERSE_INTRON_0) + mat->align->splice5_reverse[(j-3)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,REVERSE_INTRON_0,k); } /* From state REVERSE_INTRON_1 to state REVERSE_CODON */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-5,REVERSE_INTRON_1) + mat->align->splice5_reverse[(j-2)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,REVERSE_INTRON_1,k); } /* From state REVERSE_INTRON_2 to state REVERSE_CODON */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-4,REVERSE_INTRON_2) + mat->align->splice5_reverse[(j-1)]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,REVERSE_INTRON_2,k); } /* Ok - finished max calculation for REVERSE_CODON */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_CODON) = score; for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REVERSE_CODON */ /* For state REVERSE_INTRON_0 */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-8,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,REVERSE_CODON,k); /* From state REVERSE_INTRON_0 to state REVERSE_INTRON_0 */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,REVERSE_INTRON_0) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REVERSE_INTRON_0,k); } /* Ok - finished max calculation for REVERSE_INTRON_0 */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_0) = score; for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REVERSE_INTRON_0 */ /* For state REVERSE_INTRON_1 */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-9,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,REVERSE_CODON,k); /* From state REVERSE_INTRON_1 to state REVERSE_INTRON_1 */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,REVERSE_INTRON_1) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REVERSE_INTRON_1,k); } /* Ok - finished max calculation for REVERSE_INTRON_1 */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_1) = score; for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REVERSE_INTRON_1 */ /* For state REVERSE_INTRON_2 */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-10,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,REVERSE_CODON,k); /* From state REVERSE_INTRON_2 to state REVERSE_INTRON_2 */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,REVERSE_INTRON_2) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = AlignWise_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REVERSE_INTRON_2,k); } /* Ok - finished max calculation for REVERSE_INTRON_2 */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_2) = score; for(k=0;k<7;k++) AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REVERSE_INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_AlignWise(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_AlignWise(AlignWise * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ AlignWise_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_CODON) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_0) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_1) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state CODON */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-3,CODON) + mat->align->forward_coding[j]; /* From state INTRON_0 to state CODON */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->align->splice3_forward[(j-3)]+mat->align->forward_coding[j]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state CODON */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + mat->align->splice3_forward[(j-2)]; if( temp > score ) { score = temp; } /* From state INTRON_2 to state CODON */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + mat->align->splice3_forward[(j-1)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,CODON) = score; /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-8,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_0 to state INTRON_0 */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-9,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_1 to state INTRON_1 */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-10,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_2 to state INTRON_2 */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state REVERSE_CODON */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-3,REVERSE_CODON) + mat->align->reverse_coding[j]; /* From state REVERSE_INTRON_0 to state REVERSE_CODON */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-6,REVERSE_INTRON_0) + mat->align->splice5_reverse[(j-3)]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_1 to state REVERSE_CODON */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-5,REVERSE_INTRON_1) + mat->align->splice5_reverse[(j-2)]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_2 to state REVERSE_CODON */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-4,REVERSE_INTRON_2) + mat->align->splice5_reverse[(j-1)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_CODON */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_CODON) = score; /* Finished calculating state REVERSE_CODON */ /* For state REVERSE_INTRON_0 */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-8,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_0 to state REVERSE_INTRON_0 */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,REVERSE_INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_0 */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_0) = score; /* Finished calculating state REVERSE_INTRON_0 */ /* For state REVERSE_INTRON_1 */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-9,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_1 to state REVERSE_INTRON_1 */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,REVERSE_INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_1 */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_1) = score; /* Finished calculating state REVERSE_INTRON_1 */ /* For state REVERSE_INTRON_2 */ /* setting first movement to score */ score = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-10,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_2 to state REVERSE_INTRON_2 */ temp = AlignWise_DC_SHADOW_MATRIX(mat,i-0,j-1,REVERSE_INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_2 */ /* Add any movement independant score and put away */ AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_2) = score; /* Finished calculating state REVERSE_INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_AlignWise(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * */ } void init_dc_AlignWise(AlignWise * mat) { register int i; register int j; register int k; for(j=0;j<12;j++) { for(i=(-0);imodel->len;i++) { AlignWise_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_CODON) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_0) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_1) = NEGI; AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_2) = NEGI; for(k=0;k<7;k++) { AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = (-1); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = (-1); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = (-1); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = (-1); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,k) = (-1); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,k) = (-1); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,k) = (-1); AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,k) = (-1); } } } return; } /* Function: start_end_find_end_AlignWise(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [AlignWise *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_AlignWise(AlignWise * mat,int * endj) { register int j; register int max; register int maxj; max = AlignWise_DC_SHADOW_SPECIAL(mat,0,mat->align->len-1,END); maxj = mat->align->len-1; for(j= mat->align->len-2 ;j >= 0 ;j--) { if( AlignWise_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = AlignWise_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_AlignWise(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [AlignWise] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_AlignWise(AlignWise *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->model->len; lenj = mat->align->len; total = leni * lenj; score_pointers = (int *) calloc (10 * (leni + 0) * 8,sizeof(int)); shadow_pointers = (int *) calloc (10 * (leni + 0) * 8 * 8,sizeof(int)); for(j=0;jalign->forward_coding[j] + (0); /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,CODON,0)); /* From state INTERGENIC to state CODON */ temp = AlignWise_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,INTERGENIC) + mat->align->forward_coding[j] + (0); if( temp > score ) { score = temp; /* This state [INTERGENIC] is a special for CODON... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= CODON; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_0 to state CODON */ temp = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->align->splice3_forward[(j-3)]+mat->align->forward_coding[j]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,0)); } /* From state INTRON_1 to state CODON */ temp = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + mat->align->splice3_forward[(j-2)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,0)); } /* From state INTRON_2 to state CODON */ temp = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + mat->align->splice3_forward[(j-1)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,0)); } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ AlignWise_DC_OPT_SHADOW_MATRIX(mat,i,j,CODON) = score; for(k=0;k<7;k++) AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CODON,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state CODON is a source for special INTERGENIC */ temp = score + (mat->geneopen) + (0) ; if( temp > AlignWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,INTERGENIC) ) { AlignWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,INTERGENIC) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,k) = AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CODON,k); AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,6) = AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,CODON,6); AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,3) = i; AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,4) = j; AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,5) = CODON; } /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen) + (0); /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,CODON,0)); /* From state INTRON_0 to state INTRON_0 */ temp = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,0)); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ AlignWise_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen) + (0); /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,CODON,0)); /* From state INTRON_1 to state INTRON_1 */ temp = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,0)); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ AlignWise_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen) + (0); /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,CODON,0)); /* From state INTRON_2 to state INTRON_2 */ temp = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,0)); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ AlignWise_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ /* For state REVERSE_CODON */ /* setting first movement to score */ score = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,REVERSE_CODON) + mat->align->reverse_coding[j] + (0); /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,REVERSE_CODON,0)); /* From state INTERGENIC to state REVERSE_CODON */ temp = AlignWise_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,INTERGENIC) + mat->align->reverse_coding[j] + (0); if( temp > score ) { score = temp; /* This state [INTERGENIC] is a special for REVERSE_CODON... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= REVERSE_CODON; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state REVERSE_INTRON_0 to state REVERSE_CODON */ temp = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-6,REVERSE_INTRON_0) + mat->align->splice5_reverse[(j-3)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 6,REVERSE_INTRON_0,0)); } /* From state REVERSE_INTRON_1 to state REVERSE_CODON */ temp = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,REVERSE_INTRON_1) + mat->align->splice5_reverse[(j-2)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,REVERSE_INTRON_1,0)); } /* From state REVERSE_INTRON_2 to state REVERSE_CODON */ temp = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,REVERSE_INTRON_2) + mat->align->splice5_reverse[(j-1)] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,REVERSE_INTRON_2,0)); } /* Ok - finished max calculation for REVERSE_CODON */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ AlignWise_DC_OPT_SHADOW_MATRIX(mat,i,j,REVERSE_CODON) = score; for(k=0;k<7;k++) AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state REVERSE_CODON is a source for special INTERGENIC */ temp = score + (mat->geneopen) + (0) ; if( temp > AlignWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,INTERGENIC) ) { AlignWise_DC_OPT_SHADOW_SPECIAL(mat,i,j,INTERGENIC) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,k) = AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,k); AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,6) = AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,6); AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,3) = i; AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,4) = j; AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,5) = REVERSE_CODON; } /* Finished calculating state REVERSE_CODON */ /* For state REVERSE_INTRON_0 */ /* setting first movement to score */ score = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen) + (0); /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,REVERSE_CODON,0)); /* From state REVERSE_INTRON_0 to state REVERSE_INTRON_0 */ temp = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REVERSE_INTRON_0) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REVERSE_INTRON_0,0)); } /* Ok - finished max calculation for REVERSE_INTRON_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ AlignWise_DC_OPT_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_0) = score; for(k=0;k<7;k++) AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REVERSE_INTRON_0 */ /* For state REVERSE_INTRON_1 */ /* setting first movement to score */ score = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen) + (0); /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,REVERSE_CODON,0)); /* From state REVERSE_INTRON_1 to state REVERSE_INTRON_1 */ temp = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REVERSE_INTRON_1) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REVERSE_INTRON_1,0)); } /* Ok - finished max calculation for REVERSE_INTRON_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ AlignWise_DC_OPT_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_1) = score; for(k=0;k<7;k++) AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REVERSE_INTRON_1 */ /* For state REVERSE_INTRON_2 */ /* setting first movement to score */ score = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen) + (0); /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,REVERSE_CODON,0)); /* From state REVERSE_INTRON_2 to state REVERSE_INTRON_2 */ temp = AlignWise_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,REVERSE_INTRON_2) + 0 +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,REVERSE_INTRON_2,0)); } /* Ok - finished max calculation for REVERSE_INTRON_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ AlignWise_DC_OPT_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_2) = score; for(k=0;k<7;k++) AlignWise_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state REVERSE_INTRON_2 */ } /* end of for each i position in strip */ /* Special state START has no special to special movements */ /* Special state INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = AlignWise_DC_OPT_SHADOW_SPECIAL(mat,0,j,INTERGENIC); /* Source START is a special source for INTERGENIC */ temp = AlignWise_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,k) = AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,START,k); } /* Source INTERGENIC is a special source for INTERGENIC */ temp = AlignWise_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,INTERGENIC,k) = AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,INTERGENIC,k); } /* Source CODON for state INTERGENIC is not special... already calculated */ /* Source REVERSE_CODON for state INTERGENIC is not special... already calculated */ /* Put back score... (now updated!) */ AlignWise_DC_OPT_SHADOW_SPECIAL(mat,0,j,INTERGENIC) = score; /* Finished updating state INTERGENIC */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = AlignWise_DC_OPT_SHADOW_SPECIAL(mat,0,j,END); /* Source INTERGENIC is a special source for END */ temp = AlignWise_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = AlignWise_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,INTERGENIC,k); } /* Put back score... (now updated!) */ AlignWise_DC_OPT_SHADOW_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_AlignWise(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * */ void init_start_end_linear_AlignWise(AlignWise * mat) { register int i; register int j; for(j=0;j<12;j++) { for(i=(-0);imodel->len;i++) { AlignWise_DC_SHADOW_MATRIX(mat,i,j,CODON) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,CODON,0) = (-1); AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-1); AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-1); AlignWise_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-1); AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_CODON) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_CODON,0) = (-1); AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_0) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_0,0) = (-1); AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_1) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_1,0) = (-1); AlignWise_DC_SHADOW_MATRIX(mat,i,j,REVERSE_INTRON_2) = NEGI; AlignWise_DC_SHADOW_MATRIX_SP(mat,i,j,REVERSE_INTRON_2,0) = (-1); } } for(j=(-10);jalign->len;j++) { AlignWise_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; AlignWise_DC_SHADOW_SPECIAL(mat,0,j,INTERGENIC) = NEGI; AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,j,INTERGENIC,0) = (-1); AlignWise_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; AlignWise_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_AlignWise(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_AlignWise(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_AlignWise(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "EXON_STATE","INTRON_STATE","REV_EXON_STATE","REV_INTRON_STATE","INTERGENIC","END" }; /* Function: AlnConvertSet_AlignWise(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","5SS_PHASE_0","INTRON","5SS_PHASE_1","5SS_PHASE_2","REV_CODON","REV_5SS_PHASE_0","REV_5SS_PHASE_1","REV_5SS_PHASE_2","REV_3SS_PHASE_0","REV_INTRON","REV_3SS_PHASE_1","REV_3SS_PHASE_2","SEQUENCE","STOP","END" }; AlnConvertSet * AlnConvertSet_AlignWise(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = CODON; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTERGENIC + 8; acu->is_from_special = TRUE; acu->state2 = CODON; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = CODON; acu->offi = 0; acu->offj = 6; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = CODON; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = CODON; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[1]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[1]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REVERSE_CODON; acu->state2 = REVERSE_CODON; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTERGENIC + 8; acu->is_from_special = TRUE; acu->state2 = REVERSE_CODON; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[2]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REVERSE_INTRON_0; acu->state2 = REVERSE_CODON; acu->offi = 0; acu->offj = 6; acu->label1 = query_label[2]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REVERSE_INTRON_1; acu->state2 = REVERSE_CODON; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[2]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REVERSE_INTRON_2; acu->state2 = REVERSE_CODON; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[2]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REVERSE_CODON; acu->state2 = REVERSE_INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REVERSE_INTRON_0; acu->state2 = REVERSE_INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[13]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REVERSE_CODON; acu->state2 = REVERSE_INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[3]; acu->label2 = target_label[14]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REVERSE_INTRON_1; acu->state2 = REVERSE_INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[13]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REVERSE_CODON; acu->state2 = REVERSE_INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[3]; acu->label2 = target_label[15]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REVERSE_INTRON_2; acu->state2 = REVERSE_INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[13]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 8; acu->state2 = INTERGENIC + 8; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[16]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTERGENIC + 8; acu->state2 = INTERGENIC + 8; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[16]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = CODON; acu->state2 = INTERGENIC + 8; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[17]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = REVERSE_CODON; acu->state2 = INTERGENIC + 8; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTERGENIC + 8; acu->state2 = END + 8; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[18]; add_collapse_label_AlnConvertSet(out,"INTRON_STATE","INTRON"); add_collapse_label_AlnConvertSet(out,"REV_INTRON_STATE","REV_INTRON"); add_collapse_label_AlnConvertSet(out,"INTERGENIC","SEQUENCE"); return out; } /* Function: PackAln_read_Expl_AlignWise(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_AlignWise(AlignWise * mat) { AlignWise_access_func_holder holder; holder.access_main = AlignWise_explicit_access_main; holder.access_special = AlignWise_explicit_access_special; return PackAln_read_generic_AlignWise(mat,holder); } /* Function: AlignWise_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int AlignWise_explicit_access_main(AlignWise * mat,int i,int j,int state) { return AlignWise_EXPL_MATRIX(mat,i,j,state); } /* Function: AlignWise_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int AlignWise_explicit_access_special(AlignWise * mat,int i,int j,int state) { return AlignWise_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_AlignWise(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: h [UNKN ] Undocumented argument [AlignWise_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_AlignWise(AlignWise * mat,AlignWise_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_AlignWise(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in AlignWise_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 8; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_AlignWise(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_AlignWise(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == AlignWise_READ_OFF_ERROR || j == AlignWise_READ_OFF_ERROR || state == AlignWise_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in AlignWise_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 8; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_AlignWise(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [AlignWise_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_AlignWise(AlignWise * mat,int * ri,int * rj,int * state,boolean * isspecial,AlignWise_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->align->len-1,END); maxj = mat->align->len-1; for(j= mat->align->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: AlignWise_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void AlignWise_debug_show_matrix(AlignWise * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;imodel->len;i++) { for(j=startj;jalign->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State CODON %d\n",AlignWise_EXPL_MATRIX(mat,i,j,CODON)); fprintf(ofp,"State INTRON_0 %d\n",AlignWise_EXPL_MATRIX(mat,i,j,INTRON_0)); fprintf(ofp,"State INTRON_1 %d\n",AlignWise_EXPL_MATRIX(mat,i,j,INTRON_1)); fprintf(ofp,"State INTRON_2 %d\n",AlignWise_EXPL_MATRIX(mat,i,j,INTRON_2)); fprintf(ofp,"State REVERSE_CODON %d\n",AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_CODON)); fprintf(ofp,"State REVERSE_INTRON_0 %d\n",AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_0)); fprintf(ofp,"State REVERSE_INTRON_1 %d\n",AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_1)); fprintf(ofp,"State REVERSE_INTRON_2 %d\n",AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_2)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_AlignWise(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [AlignWise_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_AlignWise(AlignWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,AlignWise_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = AlignWise_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->model->len || j > mat->align->len) { warn("In AlignWise matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case CODON : temp = cscore - (mat->align->splice3_forward[(j-1)]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (mat->align->splice3_forward[(j-2)]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 5,INTRON_1); } temp = cscore - ((mat->align->splice3_forward[(j-3)]+mat->align->forward_coding[j])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-6,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 6,INTRON_0); } temp = cscore - (mat->align->forward_coding[j]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,INTERGENIC) ) { *reti = i - 0; *retj = j - 3; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,INTERGENIC); } return (*h.access_main)(mat,i - 0,j - 3,INTERGENIC); } temp = cscore - (mat->align->forward_coding[j]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,CODON); } return (*h.access_main)(mat,i - 0,j - 3,CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_0); } temp = cscore - ((mat->align->splice5_forward[(j-7)]+mat->intronopen)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,CODON) ) { *reti = i - 0; *retj = j - 8; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,CODON); } return (*h.access_main)(mat,i - 0,j - 8,CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_1); } temp = cscore - ((mat->align->splice5_forward[(j-7)]+mat->intronopen)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,CODON) ) { *reti = i - 0; *retj = j - 9; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,CODON); } return (*h.access_main)(mat,i - 0,j - 9,CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_2); } temp = cscore - ((mat->align->splice5_forward[(j-7)]+mat->intronopen)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,CODON) ) { *reti = i - 0; *retj = j - 10; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,CODON); } return (*h.access_main)(mat,i - 0,j - 10,CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REVERSE_CODON : temp = cscore - (mat->align->splice5_reverse[(j-1)]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 4,REVERSE_INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = REVERSE_INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,REVERSE_INTRON_2); } return (*h.access_main)(mat,i - 0,j - 4,REVERSE_INTRON_2); } temp = cscore - (mat->align->splice5_reverse[(j-2)]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 5,REVERSE_INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = REVERSE_INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,REVERSE_INTRON_1); } return (*h.access_main)(mat,i - 0,j - 5,REVERSE_INTRON_1); } temp = cscore - (mat->align->splice5_reverse[(j-3)]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 6,REVERSE_INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = REVERSE_INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-6,REVERSE_INTRON_0); } return (*h.access_main)(mat,i - 0,j - 6,REVERSE_INTRON_0); } temp = cscore - (mat->align->reverse_coding[j]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,INTERGENIC) ) { *reti = i - 0; *retj = j - 3; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,INTERGENIC); } return (*h.access_main)(mat,i - 0,j - 3,INTERGENIC); } temp = cscore - (mat->align->reverse_coding[j]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 3,REVERSE_CODON) ) { *reti = i - 0; *retj = j - 3; *retstate = REVERSE_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,REVERSE_CODON); } return (*h.access_main)(mat,i - 0,j - 3,REVERSE_CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REVERSE_INTRON_0 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REVERSE_INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = REVERSE_INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REVERSE_INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,REVERSE_INTRON_0); } temp = cscore - ((mat->align->splice3_reverse[(j-7)]+mat->intronopen)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,REVERSE_CODON) ) { *reti = i - 0; *retj = j - 8; *retstate = REVERSE_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,REVERSE_CODON); } return (*h.access_main)(mat,i - 0,j - 8,REVERSE_CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REVERSE_INTRON_1 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REVERSE_INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = REVERSE_INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REVERSE_INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,REVERSE_INTRON_1); } temp = cscore - ((mat->align->splice3_reverse[(j-7)]+mat->intronopen)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,REVERSE_CODON) ) { *reti = i - 0; *retj = j - 9; *retstate = REVERSE_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,REVERSE_CODON); } return (*h.access_main)(mat,i - 0,j - 9,REVERSE_CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); case REVERSE_INTRON_2 : temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,REVERSE_INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = REVERSE_INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,REVERSE_INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,REVERSE_INTRON_2); } temp = cscore - ((mat->align->splice3_reverse[(j-7)]+mat->intronopen)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,REVERSE_CODON) ) { *reti = i - 0; *retj = j - 10; *retstate = REVERSE_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,REVERSE_CODON); } return (*h.access_main)(mat,i - 0,j - 10,REVERSE_CODON); } warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_AlignWise(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [AlignWise_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_AlignWise(AlignWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,AlignWise_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = AlignWise_READ_OFF_ERROR; if( j < 0 || j > mat->align->len) { warn("In AlignWise matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case INTERGENIC : /* source REVERSE_CODON is from main matrix */ for(i= mat->model->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->geneopen) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,REVERSE_CODON) ) { *reti = i - 0; *retj = j - 0; *retstate = REVERSE_CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,REVERSE_CODON); } return (*h.access_main)(mat,i - 0,j - 0,REVERSE_CODON) ; } } /* end of for i >= 0 */ /* source CODON is from main matrix */ for(i= mat->model->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->geneopen) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,CODON) ) { *reti = i - 0; *retj = j - 0; *retstate = CODON; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,CODON); } return (*h.access_main)(mat,i - 0,j - 0,CODON) ; } } /* end of for i >= 0 */ /* source INTERGENIC is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,INTERGENIC); } return (*h.access_special)(mat,i - 0,j - 1,INTERGENIC) ; } /* source START is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_special)(mat,i - 0,j - 1,START) ; } case END : /* source INTERGENIC is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,INTERGENIC) ) { *reti = i - 0; *retj = j - 1; *retstate = INTERGENIC; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,INTERGENIC); } return (*h.access_special)(mat,i - 0,j - 1,INTERGENIC) ; } default: warn("Major problem (!) - in AlignWise read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_AlignWise(mat) * * Descrip: This function calculates the AlignWise matrix when in explicit mode * To allocate the matrix use /allocate_Expl_AlignWise * * * Arg: mat [UNKN ] AlignWise which contains explicit basematrix memory [AlignWise *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_AlignWise(AlignWise * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_AlignWise, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("AlignWise Matrix calculation: "); for(j=0;jalign->forward_coding[j]; /* From state INTERGENIC to state CODON */ temp = AlignWise_EXPL_SPECIAL(mat,i-0,j-3,INTERGENIC) + mat->align->forward_coding[j]; if( temp > score ) { score = temp; } /* From state INTRON_0 to state CODON */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->align->splice3_forward[(j-3)]+mat->align->forward_coding[j]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state CODON */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + mat->align->splice3_forward[(j-2)]; if( temp > score ) { score = temp; } /* From state INTRON_2 to state CODON */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + mat->align->splice3_forward[(j-1)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,CODON) = score; /* state CODON is a source for special INTERGENIC */ temp = score + (mat->geneopen) + (0) ; if( temp > AlignWise_EXPL_SPECIAL(mat,i,j,INTERGENIC) ) { AlignWise_EXPL_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-8,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_0 to state INTRON_0 */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-9,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_1 to state INTRON_1 */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-10,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_2 to state INTRON_2 */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state REVERSE_CODON */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-3,REVERSE_CODON) + mat->align->reverse_coding[j]; /* From state INTERGENIC to state REVERSE_CODON */ temp = AlignWise_EXPL_SPECIAL(mat,i-0,j-3,INTERGENIC) + mat->align->reverse_coding[j]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_0 to state REVERSE_CODON */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-6,REVERSE_INTRON_0) + mat->align->splice5_reverse[(j-3)]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_1 to state REVERSE_CODON */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-5,REVERSE_INTRON_1) + mat->align->splice5_reverse[(j-2)]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_2 to state REVERSE_CODON */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-4,REVERSE_INTRON_2) + mat->align->splice5_reverse[(j-1)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_CODON */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_CODON) = score; /* state REVERSE_CODON is a source for special INTERGENIC */ temp = score + (mat->geneopen) + (0) ; if( temp > AlignWise_EXPL_SPECIAL(mat,i,j,INTERGENIC) ) { AlignWise_EXPL_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* Finished calculating state REVERSE_CODON */ /* For state REVERSE_INTRON_0 */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-8,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_0 to state REVERSE_INTRON_0 */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-1,REVERSE_INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_0 */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_0) = score; /* Finished calculating state REVERSE_INTRON_0 */ /* For state REVERSE_INTRON_1 */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-9,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_1 to state REVERSE_INTRON_1 */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-1,REVERSE_INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_1 */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_1) = score; /* Finished calculating state REVERSE_INTRON_1 */ /* For state REVERSE_INTRON_2 */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-10,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_2 to state REVERSE_INTRON_2 */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-1,REVERSE_INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_2 */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_2) = score; /* Finished calculating state REVERSE_INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = AlignWise_EXPL_SPECIAL(mat,0,j,INTERGENIC); /* Source START is a special source for INTERGENIC */ temp = AlignWise_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Source INTERGENIC is a special source for INTERGENIC */ temp = AlignWise_EXPL_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; /* Source CODON for state INTERGENIC is not special... already calculated */ /* Source REVERSE_CODON for state INTERGENIC is not special... already calculated */ /* Put back score... (now updated!) */ AlignWise_EXPL_SPECIAL(mat,0,j,INTERGENIC) = score; /* Finished updating state INTERGENIC */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = AlignWise_EXPL_SPECIAL(mat,0,j,END); /* Source INTERGENIC is a special source for END */ temp = AlignWise_EXPL_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ AlignWise_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_AlignWise(mat,dpenv) * * Descrip: This function calculates the AlignWise matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] AlignWise which contains explicit basematrix memory [AlignWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_AlignWise(AlignWise * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_AlignWise, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-10;jleni;i++) { AlignWise_EXPL_MATRIX(mat,i,j,CODON) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_CODON) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_0) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_1) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_2) = NEGI; } } for(j=-10;jlenj;j++) { AlignWise_EXPL_SPECIAL(mat,i,j,START) = 0; AlignWise_EXPL_SPECIAL(mat,i,j,INTERGENIC) = NEGI; AlignWise_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("AlignWise Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { AlignWise_EXPL_MATRIX(mat,i,j,CODON) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_CODON) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_0) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_1) = NEGI; AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_2) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state CODON */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-3,CODON) + mat->align->forward_coding[j]; /* From state INTERGENIC to state CODON */ temp = AlignWise_EXPL_SPECIAL(mat,i-0,j-3,INTERGENIC) + mat->align->forward_coding[j]; if( temp > score ) { score = temp; } /* From state INTRON_0 to state CODON */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->align->splice3_forward[(j-3)]+mat->align->forward_coding[j]); if( temp > score ) { score = temp; } /* From state INTRON_1 to state CODON */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + mat->align->splice3_forward[(j-2)]; if( temp > score ) { score = temp; } /* From state INTRON_2 to state CODON */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + mat->align->splice3_forward[(j-1)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for CODON */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,CODON) = score; /* state CODON is a source for special INTERGENIC */ temp = score + (mat->geneopen) + (0) ; if( temp > AlignWise_EXPL_SPECIAL(mat,i,j,INTERGENIC) ) { AlignWise_EXPL_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* Finished calculating state CODON */ /* For state INTRON_0 */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-8,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_0 to state INTRON_0 */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-9,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_1 to state INTRON_1 */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-10,CODON) + (mat->align->splice5_forward[(j-7)]+mat->intronopen); /* From state INTRON_2 to state INTRON_2 */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ /* For state REVERSE_CODON */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-3,REVERSE_CODON) + mat->align->reverse_coding[j]; /* From state INTERGENIC to state REVERSE_CODON */ temp = AlignWise_EXPL_SPECIAL(mat,i-0,j-3,INTERGENIC) + mat->align->reverse_coding[j]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_0 to state REVERSE_CODON */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-6,REVERSE_INTRON_0) + mat->align->splice5_reverse[(j-3)]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_1 to state REVERSE_CODON */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-5,REVERSE_INTRON_1) + mat->align->splice5_reverse[(j-2)]; if( temp > score ) { score = temp; } /* From state REVERSE_INTRON_2 to state REVERSE_CODON */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-4,REVERSE_INTRON_2) + mat->align->splice5_reverse[(j-1)]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_CODON */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_CODON) = score; /* state REVERSE_CODON is a source for special INTERGENIC */ temp = score + (mat->geneopen) + (0) ; if( temp > AlignWise_EXPL_SPECIAL(mat,i,j,INTERGENIC) ) { AlignWise_EXPL_SPECIAL(mat,i,j,INTERGENIC) = temp; } /* Finished calculating state REVERSE_CODON */ /* For state REVERSE_INTRON_0 */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-8,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_0 to state REVERSE_INTRON_0 */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-1,REVERSE_INTRON_0) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_0 */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_0) = score; /* Finished calculating state REVERSE_INTRON_0 */ /* For state REVERSE_INTRON_1 */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-9,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_1 to state REVERSE_INTRON_1 */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-1,REVERSE_INTRON_1) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_1 */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_1) = score; /* Finished calculating state REVERSE_INTRON_1 */ /* For state REVERSE_INTRON_2 */ /* setting first movement to score */ score = AlignWise_EXPL_MATRIX(mat,i-0,j-10,REVERSE_CODON) + (mat->align->splice3_reverse[(j-7)]+mat->intronopen); /* From state REVERSE_INTRON_2 to state REVERSE_INTRON_2 */ temp = AlignWise_EXPL_MATRIX(mat,i-0,j-1,REVERSE_INTRON_2) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for REVERSE_INTRON_2 */ /* Add any movement independant score and put away */ AlignWise_EXPL_MATRIX(mat,i,j,REVERSE_INTRON_2) = score; /* Finished calculating state REVERSE_INTRON_2 */ } /* Special state START has no special to special movements */ /* Special state INTERGENIC has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = AlignWise_EXPL_SPECIAL(mat,0,j,INTERGENIC); /* Source START is a special source for INTERGENIC */ temp = AlignWise_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; /* Source INTERGENIC is a special source for INTERGENIC */ temp = AlignWise_EXPL_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; /* Source CODON for state INTERGENIC is not special... already calculated */ /* Source REVERSE_CODON for state INTERGENIC is not special... already calculated */ /* Put back score... (now updated!) */ AlignWise_EXPL_SPECIAL(mat,0,j,INTERGENIC) = score; /* Finished updating state INTERGENIC */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = AlignWise_EXPL_SPECIAL(mat,0,j,END); /* Source INTERGENIC is a special source for END */ temp = AlignWise_EXPL_SPECIAL(mat,0,j - 1,INTERGENIC) + (0) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ AlignWise_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ } stop_reporting(); return TRUE; } /* Function: AlignWise_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlignWise *] * */ AlignWise * AlignWise_alloc(void) { AlignWise * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlignWise *) ckalloc (sizeof(AlignWise))) == NULL) { warn("AlignWise_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_AlignWise(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlignWise *] * * Return [UNKN ] Undocumented return value [AlignWise *] * */ AlignWise * free_AlignWise(AlignWise * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AlignWise obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->model is linked in */ /* obj->align is linked in */ /* obj->intronopen is linked in */ /* obj->geneopen is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/alignwisedp.h0000644000175000001440000005076110670453713016621 0ustar philippusers#ifndef DYNAMITEalignwisedpHEADERFILE #define DYNAMITEalignwisedpHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "aligngenemodel.h" struct Wise2_AlignGeneModelFrame { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int len; } ; /* AlignGeneModelFrame defined */ #ifndef DYNAMITE_DEFINED_AlignGeneModelFrame typedef struct Wise2_AlignGeneModelFrame Wise2_AlignGeneModelFrame; #define AlignGeneModelFrame Wise2_AlignGeneModelFrame #define DYNAMITE_DEFINED_AlignGeneModelFrame #endif struct Wise2_AlignWise { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; AlignGeneModelFrame* model; AlignGeneModelScore* align; Score intronopen; Score geneopen; } ; /* AlignWise defined */ #ifndef DYNAMITE_DEFINED_AlignWise typedef struct Wise2_AlignWise Wise2_AlignWise; #define AlignWise Wise2_AlignWise #define DYNAMITE_DEFINED_AlignWise #endif #ifdef PTHREAD struct thread_pool_holder_AlignWise { AlignGeneModelFrame* model; /* Static query data: never free'd */ AlignGeneModelScore* align; /* Static target data: never free'd */ Score intronopen; Score geneopen; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_AlignWise_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(AlignWise*,int,int,int); int (*access_special)(AlignWise*,int,int,int); } ; /* AlignWise_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_AlignWise_access_func_holder typedef struct Wise2_AlignWise_access_func_holder Wise2_AlignWise_access_func_holder; #define AlignWise_access_func_holder Wise2_AlignWise_access_func_holder #define DYNAMITE_DEFINED_AlignWise_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_AlignGeneModelFrame(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlignGeneModelFrame *] * * Return [UNKN ] Undocumented return value [AlignGeneModelFrame *] * */ AlignGeneModelFrame * Wise2_hard_link_AlignGeneModelFrame(AlignGeneModelFrame * obj); #define hard_link_AlignGeneModelFrame Wise2_hard_link_AlignGeneModelFrame /* Function: AlignGeneModelFrame_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlignGeneModelFrame *] * */ AlignGeneModelFrame * Wise2_AlignGeneModelFrame_alloc(void); #define AlignGeneModelFrame_alloc Wise2_AlignGeneModelFrame_alloc /* Function: free_AlignGeneModelFrame(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlignGeneModelFrame *] * * Return [UNKN ] Undocumented return value [AlignGeneModelFrame *] * */ AlignGeneModelFrame * Wise2_free_AlignGeneModelFrame(AlignGeneModelFrame * obj); #define free_AlignGeneModelFrame Wise2_free_AlignGeneModelFrame /* Function: PackAln_read_Shatter_AlignWise(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_AlignWise(AlignWise * mat); #define PackAln_read_Shatter_AlignWise Wise2_PackAln_read_Shatter_AlignWise /* Function: calculate_shatter_AlignWise(mat,dpenv) * * Descrip: This function calculates the AlignWise matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [AlignWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_AlignWise(AlignWise * mat,DPEnvelope * dpenv); #define calculate_shatter_AlignWise Wise2_calculate_shatter_AlignWise /* Function: search_AlignWise(dbsi,out,model,align,intronopen,geneopen) * * Descrip: This function makes a database search of AlignWise * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: model [UNKN ] Undocumented argument [AlignGeneModelFrame*] * Arg: align [UNKN ] Undocumented argument [AlignGeneModelScore*] * Arg: intronopen [UNKN ] Undocumented argument [Score] * Arg: geneopen [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_AlignWise(DBSearchImpl * dbsi,Hscore * out,AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen); #define search_AlignWise Wise2_search_AlignWise /* Function: serial_search_AlignWise(out,model,align,intronopen,geneopen) * * Descrip: This function makes a database search of AlignWise * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: model [UNKN ] Undocumented argument [AlignGeneModelFrame*] * Arg: align [UNKN ] Undocumented argument [AlignGeneModelScore*] * Arg: intronopen [UNKN ] Undocumented argument [Score] * Arg: geneopen [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_AlignWise(Hscore * out,AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen); #define serial_search_AlignWise Wise2_serial_search_AlignWise /* Function: PackAln_bestmemory_AlignWise(model,align,intronopen,geneopen,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_AlignWise * * * Arg: model [UNKN ] query data structure [AlignGeneModelFrame*] * Arg: align [UNKN ] target data structure [AlignGeneModelScore*] * Arg: intronopen [UNKN ] Resource [Score] * Arg: geneopen [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_AlignWise(AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_AlignWise Wise2_PackAln_bestmemory_AlignWise /* Function: allocate_Expl_AlignWise(model,align,intronopen,geneopen,dpri) * * Descrip: This function allocates the AlignWise structure * and the basematrix area for explicit memory implementations * It calls /allocate_AlignWise_only * * * Arg: model [UNKN ] query data structure [AlignGeneModelFrame*] * Arg: align [UNKN ] target data structure [AlignGeneModelScore*] * Arg: intronopen [UNKN ] Resource [Score] * Arg: geneopen [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [AlignWise *] * */ AlignWise * Wise2_allocate_Expl_AlignWise(AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen,DPRunImpl * dpri); #define allocate_Expl_AlignWise Wise2_allocate_Expl_AlignWise /* Function: recalculate_PackAln_AlignWise(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by AlignWise * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * */ void Wise2_recalculate_PackAln_AlignWise(PackAln * pal,AlignWise * mat); #define recalculate_PackAln_AlignWise Wise2_recalculate_PackAln_AlignWise /* Function: allocate_Small_AlignWise(model,align,intronopen,geneopen) * * Descrip: This function allocates the AlignWise structure * and the basematrix area for a small memory implementations * It calls /allocate_AlignWise_only * * * Arg: model [UNKN ] query data structure [AlignGeneModelFrame*] * Arg: align [UNKN ] target data structure [AlignGeneModelScore*] * Arg: intronopen [UNKN ] Resource [Score] * Arg: geneopen [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [AlignWise *] * */ AlignWise * Wise2_allocate_Small_AlignWise(AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen); #define allocate_Small_AlignWise Wise2_allocate_Small_AlignWise /* Function: PackAln_calculate_Small_AlignWise(mat,dpenv) * * Descrip: This function calculates an alignment for AlignWise structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_AlignWise * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_AlignWise * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_AlignWise(AlignWise * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_AlignWise Wise2_PackAln_calculate_Small_AlignWise /* Function: AlnRangeSet_calculate_Small_AlignWise(mat) * * Descrip: This function calculates an alignment for AlignWise structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_AlignWise * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_AlignWise * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_AlignWise * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_AlignWise(AlignWise * mat); #define AlnRangeSet_calculate_Small_AlignWise Wise2_AlnRangeSet_calculate_Small_AlignWise /* Function: AlnRangeSet_from_AlignWise(mat) * * Descrip: This function reads off a start/end structure * for AlignWise structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_AlignWise * If you have not calculated the matrix use * /AlnRange_calculate_Small_AlignWise * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_AlignWise(AlignWise * mat); #define AlnRangeSet_from_AlignWise Wise2_AlnRangeSet_from_AlignWise /* Function: convert_PackAln_to_AlnBlock_AlignWise(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_AlignWise(PackAln * pal); #define convert_PackAln_to_AlnBlock_AlignWise Wise2_convert_PackAln_to_AlnBlock_AlignWise /* Function: PackAln_read_Expl_AlignWise(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_AlignWise(AlignWise * mat); #define PackAln_read_Expl_AlignWise Wise2_PackAln_read_Expl_AlignWise /* Function: PackAln_read_generic_AlignWise(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [AlignWise *] * Arg: h [UNKN ] Undocumented argument [AlignWise_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_AlignWise(AlignWise * mat,AlignWise_access_func_holder h); #define PackAln_read_generic_AlignWise Wise2_PackAln_read_generic_AlignWise /* Function: calculate_AlignWise(mat) * * Descrip: This function calculates the AlignWise matrix when in explicit mode * To allocate the matrix use /allocate_Expl_AlignWise * * * Arg: mat [UNKN ] AlignWise which contains explicit basematrix memory [AlignWise *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_AlignWise(AlignWise * mat); #define calculate_AlignWise Wise2_calculate_AlignWise /* Function: calculate_dpenv_AlignWise(mat,dpenv) * * Descrip: This function calculates the AlignWise matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] AlignWise which contains explicit basematrix memory [AlignWise *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_AlignWise(AlignWise * mat,DPEnvelope * dpenv); #define calculate_dpenv_AlignWise Wise2_calculate_dpenv_AlignWise /* Function: AlignWise_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlignWise *] * */ AlignWise * Wise2_AlignWise_alloc(void); #define AlignWise_alloc Wise2_AlignWise_alloc /* Function: free_AlignWise(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlignWise *] * * Return [UNKN ] Undocumented return value [AlignWise *] * */ AlignWise * Wise2_free_AlignWise(AlignWise * obj); #define free_AlignWise Wise2_free_AlignWise /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_AlignWise_shatter_access_main(AlignWise * mat,int i,int j,int state); #define AlignWise_shatter_access_main Wise2_AlignWise_shatter_access_main int Wise2_AlignWise_shatter_access_special(AlignWise * mat,int i,int j,int state); #define AlignWise_shatter_access_special Wise2_AlignWise_shatter_access_special void * Wise2_thread_loop_AlignWise(void * ptr); #define thread_loop_AlignWise Wise2_thread_loop_AlignWise int Wise2_score_only_AlignWise(AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen); #define score_only_AlignWise Wise2_score_only_AlignWise AlignWise * Wise2_allocate_AlignWise_only(AlignGeneModelFrame* model,AlignGeneModelScore* align ,Score intronopen,Score geneopen); #define allocate_AlignWise_only Wise2_allocate_AlignWise_only void Wise2_init_AlignWise(AlignWise * mat); #define init_AlignWise Wise2_init_AlignWise AlnRange * Wise2_AlnRange_build_AlignWise(AlignWise * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_AlignWise Wise2_AlnRange_build_AlignWise boolean Wise2_read_hidden_AlignWise(AlignWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_AlignWise Wise2_read_hidden_AlignWise int Wise2_max_hidden_AlignWise(AlignWise * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_AlignWise Wise2_max_hidden_AlignWise boolean Wise2_read_special_strip_AlignWise(AlignWise * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_AlignWise Wise2_read_special_strip_AlignWise int Wise2_max_special_strip_AlignWise(AlignWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_AlignWise Wise2_max_special_strip_AlignWise int Wise2_max_matrix_to_special_AlignWise(AlignWise * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_AlignWise Wise2_max_matrix_to_special_AlignWise void Wise2_calculate_hidden_AlignWise(AlignWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_AlignWise Wise2_calculate_hidden_AlignWise void Wise2_init_hidden_AlignWise(AlignWise * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_AlignWise Wise2_init_hidden_AlignWise boolean Wise2_full_dc_AlignWise(AlignWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_AlignWise Wise2_full_dc_AlignWise boolean Wise2_do_dc_single_pass_AlignWise(AlignWise * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_AlignWise Wise2_do_dc_single_pass_AlignWise void Wise2_push_dc_at_merge_AlignWise(AlignWise * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_AlignWise Wise2_push_dc_at_merge_AlignWise void Wise2_follow_on_dc_AlignWise(AlignWise * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_AlignWise Wise2_follow_on_dc_AlignWise void Wise2_run_up_dc_AlignWise(AlignWise * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_AlignWise Wise2_run_up_dc_AlignWise void Wise2_init_dc_AlignWise(AlignWise * mat); #define init_dc_AlignWise Wise2_init_dc_AlignWise int Wise2_start_end_find_end_AlignWise(AlignWise * mat,int * endj); #define start_end_find_end_AlignWise Wise2_start_end_find_end_AlignWise boolean Wise2_dc_optimised_start_end_calc_AlignWise(AlignWise *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_AlignWise Wise2_dc_optimised_start_end_calc_AlignWise void Wise2_init_start_end_linear_AlignWise(AlignWise * mat); #define init_start_end_linear_AlignWise Wise2_init_start_end_linear_AlignWise AlnConvertSet * Wise2_AlnConvertSet_AlignWise(void); #define AlnConvertSet_AlignWise Wise2_AlnConvertSet_AlignWise int Wise2_AlignWise_explicit_access_main(AlignWise * mat,int i,int j,int state); #define AlignWise_explicit_access_main Wise2_AlignWise_explicit_access_main int Wise2_AlignWise_explicit_access_special(AlignWise * mat,int i,int j,int state); #define AlignWise_explicit_access_special Wise2_AlignWise_explicit_access_special int Wise2_find_end_AlignWise(AlignWise * mat,int * ri,int * rj,int * state,boolean * isspecial,AlignWise_access_func_holder h); #define find_end_AlignWise Wise2_find_end_AlignWise void Wise2_AlignWise_debug_show_matrix(AlignWise * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define AlignWise_debug_show_matrix Wise2_AlignWise_debug_show_matrix int Wise2_max_calc_AlignWise(AlignWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,AlignWise_access_func_holder h); #define max_calc_AlignWise Wise2_max_calc_AlignWise int Wise2_max_calc_special_AlignWise(AlignWise * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,AlignWise_access_func_holder h); #define max_calc_special_AlignWise Wise2_max_calc_special_AlignWise #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/cdparser.pod0000644000175000001440000000252010670453713016437 0ustar philippusers=head1 NAME cdparser module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item cDNAParser =back =head1 DESCRIPTION =head2 Object cDNAParser =over =item trans[PCD_PARSER_TRANS_LEN] Type [Probability] Scalar No documentation =back This object holds the (very few) extra transition information needed for the estwise algorithm. It is sort of like the 'gene model' part of sequencing error (but very very simple) =head2 Member functions of cDNAParser =over =item hard_link_cDNAParser &Wise2::cDNAParser::hard_link_cDNAParser(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [cDNAParser *] Return [UNKN ] Undocumented return value [cDNAParser *] =item alloc &Wise2::cDNAParser::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [cDNAParser *] =back =over =item flat_cDNAParser &Wise2::flat_cDNAParser(p) Makes a flat (ie, indels of 1 or 2 == p) cDNA parser. This means that insertions and deletions of both 1 or 2 bases are all parameterised at the same probability Argument p [READ ] probability of an indel [Probability] Return [UNKN ] Undocumented return value [cDNAParser *] =back wise-2.4.1/src/models/cdparser.tex0000644000175000001440000000234610670453713016463 0ustar philippusers\section{cdparser} \label{module_cdparser} This module contains the following objects \begin{itemize} \item \ref{object_cDNAParser} cDNAParser \item This module also contains some factory methods \end{itemize} \subsection{cdparser factory methods} \subsubsection{flat_cDNAParser} \begin{description} \item[External C] {\tt Wise2_flat_cDNAParser (p)} \item[Perl] {\tt &Wise2::flat_cDNAParser (p)} \end{description} Arguments \begin{description} \item[p] [READ ] probability of an indel [Probability] \item[returns] [UNKN ] Undocumented return value [cDNAParser *] \end{description} Makes a flat (ie, indels of 1 or 2 == p) cDNA parser. This means that insertions and deletions of both 1 or 2 bases are all parameterised at the same probability \subsection{Object cDNAParser} \label{object_cDNAParser} The cDNAParser object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{trans[PCD_PARSER_TRANS_LEN]} Type [Probability : Scalar] No documentation \end{description} This object holds the (very few) extra transition information needed for the estwise algorithm. It is sort of like the 'gene model' part of sequencing error (but very very simple) Member functions of cDNAParser wise-2.4.1/src/models/hsp2aln_sw.dy0000644000175000001440000002010110345352771016542 0ustar philippusers %{ #include "sw_wrap.h" #include "hitlist.h" #include "hsp.h" #define Hsp2AlnHelperLISTLENGTH 20 #ifdef PTHREAD #include "pthread.h" struct hsp2aln_thread_manager { pthread_mutex_t input_lock; pthread_mutex_t output_lock; pthread_t * pool; int thread_size; int current_pos; LinearHSPmanager * input; HitList * output; DPRunImpl * dpri; struct Wise2_HSPset2HitPairPara * para; int topscore; }; #endif %} struct HSPset2HitPairPara int hsp_width !def="40" int hsp_length !def="90" int no_subalns !def="0" int no_hitalns !def="0" boolean best_hit !def="FALSE" double perc_hit_dropoff !def="10.0" boolean debug !def="FALSE" int poor_score_factor !def="2" int poor_score !def="100" struct Hsp2AlnHelper DPEnvelope ** dpenv !list struct Hsp2AlnPara int align_size %{ #include "hsp2aln_sw.h" #ifdef PTHREAD HitList * HitList_from_LinearHSPmanager_heuristic_threaded(LinearHSPmanager * lm,DPRunImpl * dpri,int thr_no,HSPset2HitPairPara * para) { struct hsp2aln_thread_manager tm; pthread_attr_t pat; int i; pthread_attr_init(&pat); #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ tm.input = lm; tm.current_pos = 0; tm.output = HitList_alloc_std(); tm.dpri = dpri; tm.para = para; tm.topscore = lm->set[0]->score; if( pthread_mutex_init(&(tm.input_lock),NULL) != 0 ) { fatal("Unable to make input mutex"); } if( pthread_mutex_init(&(tm.output_lock),NULL) != 0 ) { fatal("Unable to make output mutex"); } tm.pool = ckcalloc(thr_no,sizeof(pthread_t)); for(i=0;idpri); while(1) { /* get input lock, die if at end */ if( pthread_mutex_lock(&(tm->input_lock)) != 0 ) fatal("bad error getting input lock"); if( tm->current_pos >= tm->input->len || tm->para->no_hitalns > 0 && tm->current_pos > tm->para->no_hitalns || (tm->para->best_hit == TRUE && (((double)(tm->topscore - tm->input->set[tm->current_pos]->score))*100.0/tm->topscore) > tm->para->perc_hit_dropoff) ) { /* end of this thread */ if( pthread_mutex_unlock(&(tm->input_lock))!= 0 ) fatal("Error in releasing input lock for ProteinSW"); break; } else { /* get a HSPset */ set= tm->input->set[tm->current_pos++]; /* release the lock */ if( pthread_mutex_unlock(&(tm->input_lock))!= 0 ) fatal("Error in releasing input lock for ProteinSW"); } /* now got a set in HSPset */ pair = HitPair_from_HSPset_heuristic(set,thread_dpri,tm->input->mat,tm->para); if( pthread_mutex_lock(&(tm->output_lock))!= 0 ) fatal("Error on getting output lock"); add_HitList(tm->output,pair); if( pthread_mutex_unlock(&(tm->output_lock))!= 0 ) fatal("Error on getting output lock"); } free_DPRunImpl(thread_dpri); return NULL; } #else HitList * HitList_from_LinearHSPmanager_heuristic_threaded(LinearHSPmanager * lm,DPRunImpl * dpri,int thr_no,HSPset2HitPairPara * para) { fatal("Not compiled with pthreads"); return NULL; } #endif HitList * HitList_from_LinearHSPmanager_heuristic(LinearHSPmanager * lm,DPRunImpl * dpri,HSPset2HitPairPara * para) { HitList * out; int i; int topscore; out = HitList_alloc_std(); out->mat = hard_link_CompMat(lm->mat); if( lm->len <= 0 ) { return out; } topscore = lm->set[0]->score; for(i=0;ilen;i++) { if( para->no_hitalns > 0 && i > para->no_hitalns ) { break; } if( para->best_hit == TRUE && (((double)(topscore - lm->set[i]->score))*100.0/topscore) > para->perc_hit_dropoff ) { break; } add_HitList(out,HitPair_from_HSPset_heuristic(lm->set[i],dpri,lm->mat,para)); } return out; } HitPair * HitPair_from_HSPset_heuristic(HSPset * set,DPRunImpl * dpri,CompMat * mat,HSPset2HitPairPara *p) { HitPair * out; HitAln * aln; int i; int total_score = 0; Hsp2AlnHelper * helper; out = HitPair_alloc_std(); out->query = hard_link_Sequence(set->hsp[0]->query); out->target = hard_link_Sequence(set->hsp[0]->target); out->query->type = SEQUENCE_PROTEIN; out->target->type = SEQUENCE_PROTEIN; helper = build_HSP2AlnHelper(set,p->hsp_width,p->hsp_length,p->poor_score,p->poor_score_factor); for(i=0;ilen;i++) { if( p->no_subalns != 0 && i > p->no_subalns ) { break; } aln = HitAln_alloc(); if( p->debug == TRUE ) { fprintf(stdout,"For %s to %s, DPENV is\n",out->query->name,out->target->name); show_DPEnvelope(helper->dpenv[i],stdout); fprintf(stdout,"\n-----------\n"); } aln->alb = Align_Sequences_ProteinSmithWaterman(out->query,out->target,mat,-12,-2,helper->dpenv[i],dpri); aln->raw_score = aln->alb->score; total_score += aln->raw_score; add_HitPair(out,aln); break; } free_Hsp2AlnHelper(helper); out->raw_score = total_score; return out; } Hsp2AlnHelper * build_HSP2AlnHelper(HSPset * set,int width,int tail,int min_score,int small_factor) { Hsp2AlnHelper * out; DPEnvelope * dpenv; DPUnit * dpunit; int i; int j; int k; int eaten; int factor = 1; out = Hsp2AlnHelper_alloc_std(); sort_HSPset_by_score(set); for(i=0;ilen;i++) { dpunit = DPUnit_alloc(); dpunit->starti = set->hsp[i]->query_start - (tail*factor); dpunit->startj = set->hsp[i]->target_start - (tail*factor); dpunit->type = DPENV_DIAG; dpunit->height = (width*factor); dpunit->length = set->hsp[i]->length + 2*(tail*factor); eaten = 0; for(j=0;jlen;j++) { for(k=0;kdpenv[j]->len;k++) { if( overlap_DPUnit(out->dpenv[j]->dpu[k],dpunit) == TRUE ) { add_DPEnvelope(out->dpenv[j],dpunit); eaten = 1; break; } } if( eaten == 1 ) { break; } } if( eaten == 0 ) { dpenv = DPEnvelope_alloc_std(); add_DPEnvelope(dpenv,dpunit); add_Hsp2AlnHelper(out,dpenv); } } return out; } void show_help_HSPset2HitPairPara(FILE * ofp) { fprintf(ofp,"Converting HSP sets to HitPair heuristic parameters\n"); fprintf(ofp," -hsp2hit_width [no] width around each HSP to consider\n"); fprintf(ofp," -hsp2hit_length [no] length around each HSP to consider\n"); fprintf(ofp," -hsp2hit_subaln [no] number of HSP subalignments to consider (disabled)\n"); fprintf(ofp," -hsp2hit_hitaln [no] number of hitpairs to assess\n"); fprintf(ofp," -[no]hsp2hit_best use best-in-search truncation (default no)\n"); fprintf(ofp," -hsp2hit_best_perc [10] percentage off best score taken in best-in-search truncation\n"); fprintf(ofp," -[no]hsp2hit_debug print debugging features on stdout (default no)\n"); } HSPset2HitPairPara * new_HSPset2HitPairPara_from_argv(int * argc,char ** argv) { HSPset2HitPairPara * out; out = HSPset2HitPairPara_alloc(); strip_out_integer_argument(argc,argv,"hsp2hit_width",&out->hsp_width); strip_out_integer_argument(argc,argv,"hsp2hit_length",&out->hsp_length); strip_out_integer_argument(argc,argv,"hsp2hit_subaln",&out->no_subalns); strip_out_integer_argument(argc,argv,"hsp2hit_hitaln",&out->no_hitalns); strip_out_boolean_def_argument(argc,argv,"hsp2hit_best",&out->best_hit); strip_out_boolean_def_argument(argc,argv,"hsp2hit_debug",&out->debug); strip_out_float_argument(argc,argv,"hsp2hit_best_perc",&out->perc_hit_dropoff); return out; } %} wise-2.4.1/src/models/estwise.c0000644000175000001440000004723207705225351015770 0ustar philippusers /* has to be before the others due to nasty namespace clashes */ #define WISE2_CROSS_HMMER2 #include "wise2xhmmer2.h" #include "dyna.h" #include "version.h" char * program_name = "estwise"; /* * program specific includes */ #include "estwrap.h" #include "genedisplay.h" #include "matchsum.h" /* * program specific variables */ char * dna_seq_file = NULL; cDNA * cdna = NULL; char * tstart_str = NULL; int tstart = -1; char * tend_str = NULL; int tend = -1; boolean reverse = FALSE; boolean target_abs = FALSE; boolean use_tsm = FALSE; char * protein_file = NULL; Protein * pro = NULL; char * hmm_file = NULL; ThreeStateModel * tsm = NULL; char * hmm_name = NULL; char * qstart_str = NULL; int qstart = -1; char * qend_str = NULL; int qend = -1; char * matrix_file = NULL; CompMat * mat = NULL; char * gap_str = "12"; int gap = 12; char * ext_str = "2"; int ext = 2; char * codon_file = NULL; CodonTable * ct = NULL; char * output_file = "-"; FILE * ofp = NULL; RandomModelDNA * rmd = NULL; char * subs_string = "0.01"; double subs_error = 0.01; char * indel_string = "0.01"; double indel_error = 0.01; char * null_string = "syn"; boolean use_syn = FALSE; boolean force_flat_insert= FALSE; boolean should_set_hmm = FALSE; char * allN_string = "1.0"; Probability allN = 1.0; char * startend_string = "default"; int startend = TSM_default; int alg = ESTWISE_3; char * alg_str = NULL; boolean show_PackAln = FALSE; boolean show_AlnBlock = FALSE; boolean show_pretty = FALSE; boolean show_pep = FALSE; boolean show_para = FALSE; boolean show_match_sum = FALSE; boolean do_both = TRUE; char * main_block_str = "50"; int main_block = 50; char * divide_str = "//"; AlnBlock * alb; PackAln * pal; cDNAParser * cp; RandomModel * rm; CodonMapper * cm; MatchSummarySet * mss; DPRunImpl * dpri = NULL; void show_parameters(void) { fprintf(ofp,"%s %s (%s release)\n",program_name,VERSION_NUMBER,RELEASE_DAY); fprintf(ofp,"This program is freely distributed under a GPL. See source directory\n"); fprintf(ofp,"Copyright (c) GRL limited: portions of the code are from separate copyrights\n\n"); if( use_tsm == FALSE) { fprintf(ofp,"Query protein: %s\n",pro->baseseq->name); fprintf(ofp,"Comp Matrix: %s\n",matrix_file); fprintf(ofp,"Gap open: %d\n",gap); fprintf(ofp,"Gap extension: %d\n",ext); } else fprintf(ofp,"Query model: %s\n",tsm->name); fprintf(ofp,"Start/End %s\n",startend_string); fprintf(ofp,"Target Sequence %s\n",cdna->baseseq->name); fprintf(ofp,"Strand: %s\n",do_both == TRUE ? "both" : reverse == TRUE ? "reverse" : "forward"); fprintf(ofp,"Codon Table: %s\n",codon_file); fprintf(ofp,"Subs error: %2.2g\n",subs_error); fprintf(ofp,"Indel error: %2.2g\n",indel_error); fprintf(ofp,"Algorithm %s\n",alg_str); } boolean show_output(void) { Protein * ps; AlnColumn * alt; Protein * trans; if( show_pretty == TRUE ) { fprintf(ofp,"\n%s output\nScore %4.2f bits over entire alignment\n",program_name,Score2Bits(pal->score)); if( use_syn == TRUE) { fprintf(ofp,"Score reported as bits over a synchronised coding sequence model\n\n"); } else { fprintf(ofp,"Score reported as bits over a flat random model\n\n"); } if( use_tsm == FALSE ) protcdna_ascii_display(alb,pro->baseseq->seq,pro->baseseq->name,pro->baseseq->offset,cdna,ct,15,main_block,alg == ESTLOOP_3 ? TRUE : FALSE,ofp); else { ps = pseudo_Protein_from_ThreeStateModel(tsm); protcdna_ascii_display(alb,ps->baseseq->seq,ps->baseseq->name,ps->baseseq->offset,cdna,ct,15,main_block,alg == ESTLOOP_3 ? TRUE : FALSE,ofp); free_Protein(ps); } fprintf(ofp,"%s\n",divide_str); } if( show_match_sum == TRUE ) { show_MatchSummary_estwise_header(ofp); show_MatchSummarySet_estwise(mss,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_pep == TRUE ) { alt = alb->start; for(;alt != NULL;) { trans = Protein_from_GeneWise_AlnColumn(cdna->baseseq,alt,1,&alt,ct,is_random_AlnColumn_genewise); if ( trans == NULL ) break; write_fasta_Sequence(trans->baseseq,ofp); free_Protein(trans); } fprintf(ofp,"%s\n",divide_str); } if( show_AlnBlock == TRUE ) { mapped_ascii_AlnBlock(alb,Score2Bits,0,ofp); fprintf(ofp,"%s\n",divide_str); } if( show_PackAln == TRUE ) { show_simple_PackAln(pal,ofp); fprintf(ofp,"%s\n",divide_str); } return TRUE; } boolean free_temporary_objects(void) { free_AlnBlock(alb); free_PackAln(pal); free_MatchSummarySet(mss); return TRUE; } boolean free_io_objects(void) { if( use_tsm == TRUE) { free_ThreeStateModel(tsm); } else { free_Protein(pro); } free_CodonTable(ct); free_RandomModelDNA(rmd); free_cDNA(cdna); return TRUE; } void reverse_target(void) { cDNA * cd_temp; cd_temp = cDNA_from_Sequence(reverse_complement_Sequence(cdna->baseseq)); free_temporary_objects(); free_cDNA(cdna); cdna = cd_temp; } boolean build_alignment(void) { if( use_tsm == FALSE ) { alb = AlnBlock_from_Protein_estwise_wrap(pro,cdna,cp,cm,ct,mat,-gap,-ext,startend == TSM_global ? 1 : 0,rmd,alg,rm,use_syn,allN,dpri,&pal); } else { alb = AlnBlock_from_TSM_estwise_wrap(tsm,cdna,cp,cm,ct,rmd,alg,use_syn,force_flat_insert,allN,dpri,&pal); } if( alb == NULL ) return FALSE; if( use_tsm ) { mss = MatchSummarySet_from_AlnBlock_estwise(alb,tsm->name,1,cdna->baseseq); } else { mss = MatchSummarySet_from_AlnBlock_estwise(alb,pro->baseseq->name,pro->baseseq->offset,cdna->baseseq); } return TRUE; } boolean build_objects(void) { boolean ret = TRUE; Protein * pro_temp; cDNA * cdna_temp; startend = threestatemodel_mode_from_string(startend_string); if( startend == TSM_unknown ) { warn("String %s was unable to converted into a start/end policy\n",startend_string); ret = FALSE; } if( tstart_str != NULL ) { if( is_integer_string(tstart_str,&tstart) == FALSE || tstart < 0) { warn("Could not make %s out as target start",tstart); ret = FALSE; } } if( is_integer_string(gap_str,&gap) == FALSE ) { warn("Could not make %s out as gap penalty (must be integer at the moment)",gap_str); ret = FALSE; } if( is_integer_string(ext_str,&ext) == FALSE ) { warn("Could not make %s out as gap penalty (must be integer at the moment)",ext_str); ret = FALSE; } if( tend_str != NULL ) { if( is_integer_string(tend_str,&tend) == FALSE || tend < 0) { warn("Could not make %s out as target end",tend); ret = FALSE; } } if( (cdna = read_fasta_file_cDNA(dna_seq_file)) == NULL ) { ret = FALSE; warn("Could not read cdnaomic sequence in %s",dna_seq_file); } else { if( tstart != -1 || tend != -1 ) { if( tstart == -1 ) tstart = 0; if( tend == -1 ) tend = cdna->baseseq->len; cdna_temp = truncate_cDNA(cdna,tstart,tend); if( cdna_temp == NULL ){ ret = FALSE; } else { free_cDNA(cdna); cdna = cdna_temp; } } } if( reverse == TRUE ) { if( tstart > tend ) { warn("You have already reversed the DNA by using %d - %d truncation. Re-reversing",tstart,tend); } cdna_temp = cDNA_from_Sequence(reverse_complement_Sequence(cdna->baseseq)); free_cDNA(cdna); cdna = cdna_temp; } if( target_abs == TRUE ) { cdna->baseseq->offset = 1; cdna->baseseq->end = strlen(cdna->baseseq->seq); } if( qstart_str != NULL ) { if( is_integer_string(qstart_str,&qstart) == FALSE || qstart < 0) { warn("Could not make %s out as query start",qstart); ret = FALSE; } } if( qend_str != NULL ) { if( is_integer_string(qend_str,&qend) == FALSE || qend < 0) { warn("Could not make %s out as query end",qend); ret = FALSE; } } if( use_tsm == FALSE ) { if( startend != TSM_default && startend != TSM_global && startend != TSM_local ) { warn("Proteins can only have local/global startend policies set, not %s",startend_string); ret = FALSE; } if( (pro = read_fasta_file_Protein(protein_file)) == NULL ) { ret = FALSE; warn("Could not read Protein sequence in %s",protein_file); } else { if( qstart != -1 || qend != -1 ) { if( qstart == -1 ) qstart = 0; if( qend == -1 ) qend = pro->baseseq->len; pro_temp = truncate_Protein(pro,qstart,qend); if( pro_temp == NULL ){ ret = FALSE; } else { free_Protein(pro); pro = pro_temp; } } } } else { /** using a HMM **/ tsm = HMMer2_read_ThreeStateModel(hmm_file); if( tsm == NULL ) { warn("Could not read hmm from %s\n",hmm_file); ret = FALSE; } else { display_char_in_ThreeStateModel(tsm); if( hmm_name != NULL ) { ckfree(tsm->name); tsm->name = stringalloc(hmm_name); } if( tsm == NULL ) { warn("Could not read %s as a hmm",hmm_file); } /** have to set start/end **/ /** already calculated **/ set_startend_policy_ThreeStateModel(tsm,startend,15,0.2); } } /* end of if HMM */ if( strcmp(null_string,"syn") == 0 ) { use_syn = TRUE; } else if ( strcmp(null_string,"flat") == 0 ) { use_syn = FALSE; } else { warn("Cannot interpret [%s] as a null model string\n",null_string); ret = FALSE; } if( main_block_str != NULL ) { if( is_integer_string(main_block_str,&main_block) == FALSE ) { warn("Could not get maximum main_block number %s",main_block_str); ret = FALSE; } } if( alg_str != NULL ) { alg = alg_estwrap_from_string(alg_str); } else { if( use_tsm == TRUE ) { alg_str = "312L"; } else { alg_str = "312"; } alg = alg_estwrap_from_string(alg_str); } if( is_double_string(allN_string,&allN) == FALSE ) { warn("Could not convert %s to a double",allN_string); ret = FALSE; } if( is_double_string(subs_string,&subs_error) == FALSE ) { warn("Could not convert %s to a double",subs_error); ret = FALSE; } if( is_double_string(indel_string,&indel_error) == FALSE ) { warn("Could not convert %s to a double",indel_error); ret = FALSE; } if( (mat = read_Blast_file_CompMat(matrix_file)) == NULL) { ret = FALSE; warn("Could not read Comparison matrix file in %s",matrix_file); } if( (ct = read_CodonTable_file(codon_file)) == NULL) { ret = FALSE; warn("Could not read codon table file in %s",codon_file); } if( (ofp = openfile(output_file,"W")) == NULL) { warn("Could not open %s as an output file",output_file); ret = FALSE; } rmd = RandomModelDNA_std(); rm = default_RandomModel(); if( rm == NULL ) { warn("No random model. Ugh!"); ret = FALSE; } cp = flat_cDNAParser(indel_error); cm = flat_CodonMapper(ct); sprinkle_errors_over_CodonMapper(cm,subs_error); return ret; } void build_defaults(void) { codon_file = "codon.table"; matrix_file = "BLOSUM62.bla"; } void show_short_help(void) { fprintf(stdout,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(stdout,"This program is freely distributed under a GPL. See -version for more info\n"); fprintf(stdout,"Copyright (c) GRL limited: portions of the code are from separate copyright\n\n"); fprintf(stdout,"estwise in fasta format\n"); fprintf(stdout," Options. In any order, '-' as filename (for any input) means stdin\n"); fprintf(stdout," Dna [-u,-v,-trev,-tfor,-both,-tabs]\n"); fprintf(stdout," Protein [-s,-t,-g,-e,-m]\n"); fprintf(stdout," HMM [-hmmer,-hname]\n"); fprintf(stdout," Model [-codon,-subs,-indel,-null]\n Alg [-kbyte,-alg]\n"); fprintf(stdout," Output [-pretty,-para,-sum,-alb,-pal,-block,-divide]\n"); fprintf(stdout," Standard [-help,-version,-silent,-quiet,-errorlog]\n"); fprintf(stdout,"\nFor more help go %s -help.\n",program_name); fprintf(stdout,"\nSee WWW help at http://www.sanger.ac.uk/Software/Wise2/\n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(ofp,"estwise in fasta format\n"); /* program specific help */ fprintf(ofp,"Dna sequence options\n"); fprintf(ofp," -u start position in dna\n"); fprintf(ofp," -v end position in dna\n"); fprintf(ofp," -trev reverse complement dna\n"); fprintf(ofp," -tfor use forward strands only\n"); fprintf(ofp," -both [default] do both strands\n"); fprintf(ofp," -tabs Positions reported as absolute to DNA\n"); fprintf(ofp,"Protein comparison options\n"); fprintf(ofp," -s start position in protein\n"); fprintf(ofp," -t end position in protein\n"); fprintf(ofp," -[g]ap [%3d] gap penalty\n",gap); fprintf(ofp," -[e]xt [%3d] extension penalty\n",ext); fprintf(ofp," -[m]atrix [%s] Comparison matrix\n",matrix_file); fprintf(ofp,"HMM options\n"); fprintf(ofp," -hmmer Protein file is HMMer file (version 2 compatible)\n"); fprintf(ofp," -hname Name of HMM rather than using the filename\n"); fprintf(ofp,"Model options\n"); fprintf(ofp," -init [%s] [default/global/local/wing] start end policy of HMM/protein match\n",startend_string); fprintf(ofp," -subs [%2.2g] Substitution error rate\n",subs_error); fprintf(ofp," -indel [%2.2g] Insertion/deletion error rate\n",indel_error); fprintf(ofp," -null [syn/flat] Random Model as synchronous or flat [default syn]\n"); fprintf(ofp," -alln [%s] Probability of matching a NNN codon\n",allN_string); fprintf(ofp,"Algorithm options\n"); fprintf(ofp," -alg [333,333L,312,312L,333F] Algorithm used\n"); fprintf(ofp,"Output options [default -pretty -para]\n"); fprintf(ofp," -pretty show pretty ascii output\n"); fprintf(ofp," -para show parameters\n"); fprintf(ofp," -sum show summary information\n"); fprintf(ofp," -pep show protein translation, splicing frameshifts\n"); fprintf(ofp," -alb show logical AlnBlock alignment\n"); fprintf(ofp," -pal show raw matrix alignment\n"); fprintf(ofp," -block [%s] Length of main block in pretty output\n",main_block_str); fprintf(ofp," -divide [%s] divide string for multiple outputs\n",divide_str); show_help_DPRunImpl(ofp); show_standard_options(ofp); fprintf(ofp,"\nSee WWW help at http://www.sanger.ac.uk/Software/Wise2/\n"); exit(63); } void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) GRL 1998 and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney wrote the core code.\n"); fprintf(ofp," Portions of this code is from HMMer2, written by Sean Eddy\n"); exit(63); } int main(int argc,char ** argv) { int i; char * temp; build_defaults(); bootstrap_HMMer2(); strip_out_standard_options(&argc,argv,show_help,show_version); dpri = new_DPRunImpl_from_argv(&argc,argv); if( (temp = strip_out_assigned_argument(&argc,argv,"gap")) != NULL ) gap_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"g")) != NULL ) gap_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"ext")) != NULL ) ext_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"init")) != NULL ) { startend_string = temp; } if( (temp = strip_out_assigned_argument(&argc,argv,"e")) != NULL ) ext_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"matrix")) != NULL ) matrix_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"m")) != NULL ) matrix_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"s")) != NULL ) qstart_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"t")) != NULL ) qend_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"u")) != NULL ) tstart_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"v")) != NULL ) tend_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"codon")) != NULL ) codon_file = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"null")) != NULL ) null_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"alg")) != NULL ) alg_str = temp; if( (strip_out_boolean_argument(&argc,argv,"hmmer")) == TRUE ) use_tsm = TRUE; if( (temp = strip_out_assigned_argument(&argc,argv,"hname")) != NULL ) hmm_name = temp; if( (strip_out_boolean_argument(&argc,argv,"trev")) == TRUE ) { do_both = FALSE; reverse = TRUE; } if( (strip_out_boolean_argument(&argc,argv,"tfor")) == TRUE ) { if( reverse == TRUE ) { warn("You have specified both trev and tfor. Interpreting as both strands"); do_both = TRUE; } else { do_both = FALSE; reverse = FALSE; } } if( (temp = strip_out_assigned_argument(&argc,argv,"subs")) != NULL ) subs_string = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"indel")) != NULL ) indel_string = temp; if( (strip_out_boolean_argument(&argc,argv,"both")) == TRUE ) do_both = TRUE; if( (strip_out_boolean_argument(&argc,argv,"tabs")) == TRUE ) target_abs = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pretty")) != FALSE ) show_pretty = TRUE; if( (strip_out_boolean_argument(&argc,argv,"para")) != FALSE ) show_para = TRUE; if( (strip_out_boolean_argument(&argc,argv,"sum")) != FALSE ) show_match_sum = TRUE; if( (strip_out_boolean_argument(&argc,argv,"pep")) != FALSE ) show_pep = TRUE; if( (strip_out_boolean_argument(&argc,argv,"alb")) != FALSE ) show_AlnBlock = TRUE; if( (temp = strip_out_assigned_argument(&argc,argv,"alln")) != NULL ) allN_string = temp; if( (strip_out_boolean_argument(&argc,argv,"pal")) != FALSE ) show_PackAln = TRUE; if( (temp = strip_out_assigned_argument(&argc,argv,"divide")) != NULL ) divide_str = temp; if( (temp = strip_out_assigned_argument(&argc,argv,"block")) != NULL ) main_block_str = temp; strip_out_remaining_options_with_warning(&argc,argv); if( argc != 3 ) { warn("Wrong number of arguments (expect 2)! Arg line looked like (after option processing)"); for(i=1;ifolded_random == TRUE); assert(t->folded_random == TRUE); length_q = q->sa->len; length_t = t->sa->len; out = DnaProfileMatchScore_alloc_matrix(q->len,t->len); assert(out != NULL); for(i=0;ilen;i++) { for(j=0;jlen;j++) { /* Sum_all_bases( count_bt.ln(fr_bq/rnd_b) + count_bq.ln(fr_bt/rnd_b) ) / Sum_all_bases( count_bt + count_bq ) */ score = 0.0; total = 0.0; for(k=0;k<4;k++) { score += (length_t * t->col[j]->emit[k]) * (log(q->col[i]->emit[k])); score += (length_q * q->col[i]->emit[k]) * (log(t->col[j]->emit[k])); total += (length_t * t->col[j]->emit[k]) + (length_q * q->col[i]->emit[k]); } score = score / total; out->score[i][j] = (int)(score * (double)INTEGER_FACTOR); } } return out; } # line 142 "dnaprofiledp.dy" DnaProfileMatchScore * new_DnaProfileMatchScore(DnaProfileScore * q,DnaProfileScore * t) { int i,j; int k; DnaProfileMatchScore * out; int score; assert(q != NULL); assert(t != NULL); out = DnaProfileMatchScore_alloc_matrix(q->len,t->len); for(i=0;ilen;i++) { for(j=0;jlen;j++) { score =0; for(k=0;k<4;k++) { if( q->col[i]->emit[k] > 0 || t->col[j]->emit[k] > 0 ) { score += ((q->col[i]->emit[k] + t->col[j]->emit[k]) / 4); } } out->score[i][j] = score; } } return out; } # line 85 "dnaprofiledp.c" /* Function: DnaProfileMatchScore_alloc_matrix(leni,lenj) * * Descrip: Allocates structure and matrix * * * Arg: leni [UNKN ] Length of first dimension of matrix [int] * Arg: lenj [UNKN ] Length of second dimension of matrix [int] * * Return [UNKN ] Undocumented return value [DnaProfileMatchScore *] * */ DnaProfileMatchScore * DnaProfileMatchScore_alloc_matrix(int leni,int lenj) { DnaProfileMatchScore * out; /* out is exported */ register int i; /* for stepping down matrix */ register int j; /* for stepping across matrix */ /* Call alloc function, return NULL if NULL */ if((out = DnaProfileMatchScore_alloc()) == NULL) return NULL; /* Allocate memory for score */ if((out->score = (Score **) ckcalloc (leni,sizeof(Score *))) == NULL) { warn("Memory allocation problem in matrix for DnaProfileMatchScore score, first pointer set"); ckfree(out); return NULL; } /* Add NULL to all matrix pointers so free can be called */ for(i=0;iscore[i] = NULL; /* Allocate each matrix row */ for(i=0;iscore[i] = (Score *) ckcalloc (lenj,sizeof(Score )); if( out->score[i] == NULL) { warn("Failed alloc on %d, calling free and returning NULL",i); free_DnaProfileMatchScore(out); return NULL; } } for(i=0;iscore[i][j] = NULL; } out->leni=out->maxleni=leni; out->lenj=out->maxlenj=lenj; return out; } /* Function: expand_DnaProfileMatchScore(obj,leni,lenj) * * Descrip: Expands matrix. Rarely used * * * Arg: obj [UNKN ] Undocumented argument [DnaProfileMatchScore *] * Arg: leni [UNKN ] Undocumented argument [int] * Arg: lenj [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_DnaProfileMatchScore(DnaProfileMatchScore * obj,int leni,int lenj) { int i; int actualj; if( obj == NULL) { warn("Trying to expand a DnaProfileMatchScore but is NULL!"); return FALSE; } if( leni <= obj->maxleni && lenj <= obj->maxlenj) return TRUE; if( obj->maxleni < leni ) { if( (obj->score=(Score **) ckrealloc (obj->score,sizeof(Score *)*leni)) == NULL) return FALSE; obj->maxleni=obj->leni=leni; } if( lenj > obj->maxlenj ) actualj = lenj; else actualj = obj->maxlenj; for(i=0;ileni;i++) { if((obj->score[i] = (Score *) realloc (obj->score[i],sizeof(Score ) * actualj)) == NULL) return FALSE; } return TRUE; } /* Function: hard_link_DnaProfileMatchScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileMatchScore *] * * Return [UNKN ] Undocumented return value [DnaProfileMatchScore *] * */ DnaProfileMatchScore * hard_link_DnaProfileMatchScore(DnaProfileMatchScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaProfileMatchScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaProfileMatchScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileMatchScore *] * */ DnaProfileMatchScore * DnaProfileMatchScore_alloc(void) { DnaProfileMatchScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaProfileMatchScore *) ckalloc (sizeof(DnaProfileMatchScore))) == NULL) { warn("DnaProfileMatchScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->score = NULL; out->leni=out->maxleni=0; out->lenj=out->maxlenj=0; return out; } /* Function: free_DnaProfileMatchScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileMatchScore *] * * Return [UNKN ] Undocumented return value [DnaProfileMatchScore *] * */ DnaProfileMatchScore * free_DnaProfileMatchScore(DnaProfileMatchScore * obj) { int return_early = 0; int i; int j; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaProfileMatchScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->score != NULL) { for(i=0;ileni;i++) { if( obj->score[i] != NULL) ckfree(obj->score[i]); } ckfree(obj->score); } ckfree(obj); return NULL; } /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:31 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define UNMATCHED 1 #define INSERT 2 #define DELETE 3 #define START 0 #define END 1 #define DnaProfileMat_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*4)+STATE][i+1] #define DnaProfileMat_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define DnaProfileMat_READ_OFF_ERROR -3 #define DnaProfileMat_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*4)+STATE] #define DnaProfileMat_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define DnaProfileMat_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define DnaProfileMat_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_DnaProfileMat(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_DnaProfileMat(DnaProfileMat * mat) { DnaProfileMat_access_func_holder holder; holder.access_main = DnaProfileMat_shatter_access_main; holder.access_special = DnaProfileMat_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_DnaProfileMat(mat,holder); } /* Function: DnaProfileMat_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int DnaProfileMat_shatter_access_main(DnaProfileMat * mat,int i,int j,int state) { return DnaProfileMat_SHATTER_MATRIX(mat,i,j,state); } /* Function: DnaProfileMat_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int DnaProfileMat_shatter_access_special(DnaProfileMat * mat,int i,int j,int state) { return DnaProfileMat_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_DnaProfileMat(mat,dpenv) * * Descrip: This function calculates the DnaProfileMat matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [DnaProfileMat *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_DnaProfileMat(DnaProfileMat * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,4,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("DnaProfileMat Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_1[MATCH] + 0; /* From state UNMATCHED to state MATCH */ temp = SIG_1_1[UNMATCHED] + 0; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = SIG_1_1[INSERT] + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_1[DELETE] + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = DnaProfileMat_SHATTER_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->m->score[i][j]; SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > DnaProfileMat_SHATTER_SPECIAL(mat,i,j,END) ) { DnaProfileMat_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state UNMATCHED */ /* setting first movement to score */ score = SIG_1_1[MATCH] + mat->open_unmatched; /* From state UNMATCHED to state UNMATCHED */ temp = SIG_1_1[UNMATCHED] + mat->ext_unmatched; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = SIG_0_1[UNMATCHED] + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = SIG_1_0[UNMATCHED] + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ SIG_0_0[UNMATCHED] = score; /* Finished calculating state UNMATCHED */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_1[MATCH] + (mat->q->col[i]->trans[DnaProfile_M2I]+mat->t->col[j]->trans[DnaProfile_M2D]); /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + (mat->q->col[i]->trans[DnaProfile_I2I]+mat->t->col[j]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ SIG_0_0[INSERT] = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + (mat->t->col[j]->trans[DnaProfile_M2I]+mat->q->col[i]->trans[DnaProfile_M2D]); /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + (mat->t->col[j]->trans[DnaProfile_I2I]+mat->q->col[i]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_DnaProfileMat(dbsi,out,q,t,m,open_unmatched,ext_unmatched,gap_unmatched) * * Descrip: This function makes a database search of DnaProfileMat * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [DnaProfileScore *] * Arg: t [UNKN ] Undocumented argument [DnaProfileScore *] * Arg: m [UNKN ] Undocumented argument [DnaProfileMatchScore*] * Arg: open_unmatched [UNKN ] Undocumented argument [Score] * Arg: ext_unmatched [UNKN ] Undocumented argument [Score] * Arg: gap_unmatched [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_DnaProfileMat(DBSearchImpl * dbsi,Hscore * out,DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_DnaProfileMat * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_DnaProfileMat. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_DnaProfileMat. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for DnaProfileMat, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_DnaProfileMat(out,q,t ,m,open_unmatched,ext_unmatched,gap_unmatched); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_DnaProfileMat *) ckalloc(sizeof(struct thread_pool_holder_DnaProfileMat)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->q = q; holder->t = t; holder->m = m; holder->open_unmatched = open_unmatched; holder->ext_unmatched = ext_unmatched; holder->gap_unmatched = gap_unmatched; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_DnaProfileMat,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for DnaProfileMat"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from DnaProfileMat",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_DnaProfileMat(ptr) * * Descrip: dummy loop code foreach thread for DnaProfileMat * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * thread_loop_DnaProfileMat(void * ptr) { fatal("dummy thread loop function"); } /* Function: serial_search_DnaProfileMat(out,q,t,m,open_unmatched,ext_unmatched,gap_unmatched) * * Descrip: This function makes a database search of DnaProfileMat * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [DnaProfileScore *] * Arg: t [UNKN ] Undocumented argument [DnaProfileScore *] * Arg: m [UNKN ] Undocumented argument [DnaProfileMatchScore*] * Arg: open_unmatched [UNKN ] Undocumented argument [Score] * Arg: ext_unmatched [UNKN ] Undocumented argument [Score] * Arg: gap_unmatched [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_DnaProfileMat(Hscore * out,DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_DnaProfileMat(q, t , m, open_unmatched, ext_unmatched, gap_unmatched); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("DnaProfileMat search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_DnaProfileMat(q,t,m,open_unmatched,ext_unmatched,gap_unmatched) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_DnaProfileMat_only * * * Arg: q [UNKN ] query data structure [DnaProfileScore *] * Arg: t [UNKN ] target data structure [DnaProfileScore *] * Arg: m [UNKN ] Resource [DnaProfileMatchScore*] * Arg: open_unmatched [UNKN ] Resource [Score] * Arg: ext_unmatched [UNKN ] Resource [Score] * Arg: gap_unmatched [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_DnaProfileMat(DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched) { int bestscore = NEGI; int i; int j; int k; DnaProfileMat * mat; mat = allocate_DnaProfileMat_only(q, t , m, open_unmatched, ext_unmatched, gap_unmatched); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 4,2,2)) == NULL) { warn("Score only matrix for DnaProfileMat cannot be allocated, (asking for 1 by %d cells)",mat->leni*4); mat = free_DnaProfileMat(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<4;k++) DnaProfileMat_VSMALL_MATRIX(mat,i,j,k) = NEGI; } DnaProfileMat_VSMALL_SPECIAL(mat,i,j,START) = 0; DnaProfileMat_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = DnaProfileMat_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state UNMATCHED to state MATCH */ temp = DnaProfileMat_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED) + 0; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = DnaProfileMat_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = DnaProfileMat_VSMALL_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = DnaProfileMat_VSMALL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->m->score[i][j]; DnaProfileMat_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > DnaProfileMat_VSMALL_SPECIAL(mat,i,j,END) ) { DnaProfileMat_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state UNMATCHED */ /* setting first movement to score */ score = DnaProfileMat_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->open_unmatched; /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->ext_unmatched; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_VSMALL_MATRIX(mat,i-0,j-1,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_VSMALL_MATRIX(mat,i-1,j-0,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ DnaProfileMat_VSMALL_MATRIX(mat,i,j,UNMATCHED) = score; /* Finished calculating state UNMATCHED */ /* For state INSERT */ /* setting first movement to score */ score = DnaProfileMat_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + (mat->q->col[i]->trans[DnaProfile_M2I]+mat->t->col[j]->trans[DnaProfile_M2D]); /* From state INSERT to state INSERT */ temp = DnaProfileMat_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + (mat->q->col[i]->trans[DnaProfile_I2I]+mat->t->col[j]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ DnaProfileMat_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaProfileMat_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + (mat->t->col[j]->trans[DnaProfile_M2I]+mat->q->col[i]->trans[DnaProfile_M2D]); /* From state INSERT to state DELETE */ temp = DnaProfileMat_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + (mat->t->col[j]->trans[DnaProfile_I2I]+mat->q->col[i]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ DnaProfileMat_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < DnaProfileMat_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = DnaProfileMat_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_DnaProfileMat(mat); return bestscore; } /* Function: PackAln_bestmemory_DnaProfileMat(q,t,m,open_unmatched,ext_unmatched,gap_unmatched,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_DnaProfileMat * * * Arg: q [UNKN ] query data structure [DnaProfileScore *] * Arg: t [UNKN ] target data structure [DnaProfileScore *] * Arg: m [UNKN ] Resource [DnaProfileMatchScore*] * Arg: open_unmatched [UNKN ] Resource [Score] * Arg: ext_unmatched [UNKN ] Resource [Score] * Arg: gap_unmatched [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_DnaProfileMat(DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; DnaProfileMat * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = q->len * t->len; if( dpri->memory == DPIM_Default ) { if( (total * 4 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_DnaProfileMat(q, t , m, open_unmatched, ext_unmatched, gap_unmatched,dpri)) == NULL ) { warn("Unable to allocate large DnaProfileMat version"); return NULL; } calculate_dpenv_DnaProfileMat(mat,dpenv); out = PackAln_read_Expl_DnaProfileMat(mat); } else { mat = allocate_DnaProfileMat_only(q, t , m, open_unmatched, ext_unmatched, gap_unmatched); calculate_shatter_DnaProfileMat(mat,dpenv); out = PackAln_read_Shatter_DnaProfileMat(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_DnaProfileMat(q, t , m, open_unmatched, ext_unmatched, gap_unmatched)) == NULL ) { warn("Unable to allocate small DnaProfileMat version"); return NULL; } out = PackAln_calculate_Small_DnaProfileMat(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_DnaProfileMat(q, t , m, open_unmatched, ext_unmatched, gap_unmatched,dpri)) == NULL ) { warn("Unable to allocate large DnaProfileMat version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_DnaProfileMat(mat); out = PackAln_read_Expl_DnaProfileMat(mat); } } } mat = free_DnaProfileMat(mat); return out; } /* Function: allocate_DnaProfileMat_only(q,t,m,open_unmatched,ext_unmatched,gap_unmatched) * * Descrip: This function only allocates the DnaProfileMat structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: q [UNKN ] query data structure [DnaProfileScore *] * Arg: t [UNKN ] target data structure [DnaProfileScore *] * Arg: m [UNKN ] Resource [DnaProfileMatchScore*] * Arg: open_unmatched [UNKN ] Resource [Score] * Arg: ext_unmatched [UNKN ] Resource [Score] * Arg: gap_unmatched [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [DnaProfileMat *] * */ DnaProfileMat * allocate_DnaProfileMat_only(DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched) { DnaProfileMat * out; if((out= DnaProfileMat_alloc()) == NULL) { warn("Allocation of basic DnaProfileMat structure failed..."); return NULL; } out->q = q; out->t = t; out->m = m; out->open_unmatched = open_unmatched; out->ext_unmatched = ext_unmatched; out->gap_unmatched = gap_unmatched; out->leni = q->len; out->lenj = t->len; return out; } /* Function: allocate_Expl_DnaProfileMat(q,t,m,open_unmatched,ext_unmatched,gap_unmatched,dpri) * * Descrip: This function allocates the DnaProfileMat structure * and the basematrix area for explicit memory implementations * It calls /allocate_DnaProfileMat_only * * * Arg: q [UNKN ] query data structure [DnaProfileScore *] * Arg: t [UNKN ] target data structure [DnaProfileScore *] * Arg: m [UNKN ] Resource [DnaProfileMatchScore*] * Arg: open_unmatched [UNKN ] Resource [Score] * Arg: ext_unmatched [UNKN ] Resource [Score] * Arg: gap_unmatched [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [DnaProfileMat *] * */ DnaProfileMat * allocate_Expl_DnaProfileMat(DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched,DPRunImpl * dpri) { DnaProfileMat * out; out = allocate_DnaProfileMat_only(q, t , m, open_unmatched, ext_unmatched, gap_unmatched); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*4 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*4,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix DnaProfileMat cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_DnaProfileMat(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_DnaProfileMat(out); return out; } /* Function: init_DnaProfileMat(mat) * * Descrip: This function initates DnaProfileMat matrix when in explicit mode * Called in /allocate_Expl_DnaProfileMat * * * Arg: mat [UNKN ] DnaProfileMat which contains explicit basematrix memory [DnaProfileMat *] * */ void init_DnaProfileMat(DnaProfileMat * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iq->len;i++) { for(j= (-1);j<2;j++) { DnaProfileMat_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; DnaProfileMat_EXPL_MATRIX(mat,i,j,UNMATCHED) = NEGI; DnaProfileMat_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; DnaProfileMat_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j= (-1);jt->len;j++) { for(i= (-1);i<2;i++) { DnaProfileMat_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; DnaProfileMat_EXPL_MATRIX(mat,i,j,UNMATCHED) = NEGI; DnaProfileMat_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; DnaProfileMat_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } DnaProfileMat_EXPL_SPECIAL(mat,i,j,START) = 0; DnaProfileMat_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_DnaProfileMat(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by DnaProfileMat * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * */ void recalculate_PackAln_DnaProfileMat(PackAln * pal,DnaProfileMat * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = 0 + (mat->m->score[i][j]); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED ) { pau->score = 0 + (mat->m->score[i][j]); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = 0 + (mat->m->score[i][j]); continue; } if( offi == 1 && offj == 1 && prev->state == DELETE ) { pau->score = 0 + (mat->m->score[i][j]); continue; } if( offj == 1 && prev->state == (START+4) ) { pau->score = 0 + (mat->m->score[i][j]); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UNMATCHED : if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->open_unmatched + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED ) { pau->score = mat->ext_unmatched + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UNMATCHED ) { pau->score = (mat->ext_unmatched+mat->gap_unmatched) + (0); continue; } if( offi == 1 && offj == 0 && prev->state == UNMATCHED ) { pau->score = (mat->ext_unmatched+mat->gap_unmatched) + (0); continue; } warn("In recaluclating PackAln with state UNMATCHED, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = (mat->q->col[i]->trans[DnaProfile_M2I]+mat->t->col[j]->trans[DnaProfile_M2D]) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = (mat->q->col[i]->trans[DnaProfile_I2I]+mat->t->col[j]->trans[DnaProfile_D2D]) + (0); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = (mat->t->col[j]->trans[DnaProfile_M2I]+mat->q->col[i]->trans[DnaProfile_M2D]) + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = (mat->t->col[j]->trans[DnaProfile_I2I]+mat->q->col[i]->trans[DnaProfile_D2D]) + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+4) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+4) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define DnaProfileMat_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*4+state]) #define DnaProfileMat_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*4+state]) #define DnaProfileMat_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define DnaProfileMat_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define DnaProfileMat_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*4 + state]) #define DnaProfileMat_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define DnaProfileMat_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 4) + ((i+1) * 4) + (state)]) #define DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 32) + ((i+1) * 32) + (state * 8) + shadow+1]) #define DnaProfileMat_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_DnaProfileMat(q,t,m,open_unmatched,ext_unmatched,gap_unmatched) * * Descrip: This function allocates the DnaProfileMat structure * and the basematrix area for a small memory implementations * It calls /allocate_DnaProfileMat_only * * * Arg: q [UNKN ] query data structure [DnaProfileScore *] * Arg: t [UNKN ] target data structure [DnaProfileScore *] * Arg: m [UNKN ] Resource [DnaProfileMatchScore*] * Arg: open_unmatched [UNKN ] Resource [Score] * Arg: ext_unmatched [UNKN ] Resource [Score] * Arg: gap_unmatched [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [DnaProfileMat *] * */ #define DnaProfileMat_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) DnaProfileMat * allocate_Small_DnaProfileMat(DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched) { DnaProfileMat * out; out = allocate_DnaProfileMat_only(q, t , m, open_unmatched, ext_unmatched, gap_unmatched); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 4,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix DnaProfileMat cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_DnaProfileMat(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_DnaProfileMat(mat,dpenv) * * Descrip: This function calculates an alignment for DnaProfileMat structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_DnaProfileMat * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_DnaProfileMat * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_DnaProfileMat(DnaProfileMat * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for DnaProfileMat due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_DnaProfileMat(mat,dpenv); score = start_end_find_end_DnaProfileMat(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_DnaProfileMat(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_DnaProfileMat(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == DnaProfileMat_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_DnaProfileMat(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 4; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_DnaProfileMat(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_DnaProfileMat(mat) * * Descrip: This function calculates an alignment for DnaProfileMat structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_DnaProfileMat * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_DnaProfileMat * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_DnaProfileMat * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_DnaProfileMat(DnaProfileMat * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_DnaProfileMat(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_DnaProfileMat(mat); return out; } /* Function: AlnRangeSet_from_DnaProfileMat(mat) * * Descrip: This function reads off a start/end structure * for DnaProfileMat structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_DnaProfileMat * If you have not calculated the matrix use * /AlnRange_calculate_Small_DnaProfileMat * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_DnaProfileMat(DnaProfileMat * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_DnaProfileMat"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_DnaProfileMat(mat,&jpos); state = END; while( (temp = AlnRange_build_DnaProfileMat(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_DnaProfileMat(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_DnaProfileMat * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_DnaProfileMat(DnaProfileMat * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_DnaProfileMat"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_DnaProfileMat(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_DnaProfileMat alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = DnaProfileMat_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_DnaProfileMat(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == DnaProfileMat_READ_OFF_ERROR) { warn("In AlnRange_build_DnaProfileMat alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = DnaProfileMat_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_DnaProfileMat(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_DnaProfileMat(DnaProfileMat * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_DnaProfileMat(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == DnaProfileMat_READ_OFF_ERROR) { warn("In DnaProfileMat hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In DnaProfileMat hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In DnaProfileMat hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_DnaProfileMat(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_DnaProfileMat(DnaProfileMat * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = DnaProfileMat_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->q->len || j > mat->t->len) { warn("In DnaProfileMat matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = DnaProfileMat_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Not allowing special sources.. skipping START */ temp = cscore - (0) - (mat->m->score[i][j]); if( temp == DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-1,DELETE); } return DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE); } temp = cscore - (0) - (mat->m->score[i][j]); if( temp == DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (0) - (mat->m->score[i][j]); if( temp == DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED); } return DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED); } temp = cscore - (0) - (mat->m->score[i][j]); if( temp == DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in DnaProfileMat read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED : temp = cscore - ((mat->ext_unmatched+mat->gap_unmatched)) - (0); if( temp == DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 0,UNMATCHED) ) { *reti = i - 1; *retj = j - 0; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-0,UNMATCHED); } return DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 0,UNMATCHED); } temp = cscore - ((mat->ext_unmatched+mat->gap_unmatched)) - (0); if( temp == DnaProfileMat_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaProfileMat_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED); } return DnaProfileMat_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED); } temp = cscore - (mat->ext_unmatched) - (0); if( temp == DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED); } return DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED); } temp = cscore - (mat->open_unmatched) - (0); if( temp == DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in DnaProfileMat read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - ((mat->q->col[i]->trans[DnaProfile_I2I]+mat->t->col[j]->trans[DnaProfile_D2D])) - (0); if( temp == DnaProfileMat_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaProfileMat_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return DnaProfileMat_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - ((mat->q->col[i]->trans[DnaProfile_M2I]+mat->t->col[j]->trans[DnaProfile_M2D])) - (0); if( temp == DnaProfileMat_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaProfileMat_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return DnaProfileMat_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in DnaProfileMat read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - ((mat->t->col[j]->trans[DnaProfile_I2I]+mat->q->col[i]->trans[DnaProfile_D2D])) - (0); if( temp == DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - ((mat->t->col[j]->trans[DnaProfile_M2I]+mat->q->col[i]->trans[DnaProfile_M2D])) - (0); if( temp == DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return DnaProfileMat_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in DnaProfileMat read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in DnaProfileMat read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_DnaProfileMat(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_DnaProfileMat(DnaProfileMat * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 4; add_PackAln(out,pau); } max_special_strip_DnaProfileMat(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == DnaProfileMat_READ_OFF_ERROR) { warn("In special strip read DnaProfileMat, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read DnaProfileMat, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 4; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_DnaProfileMat(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_DnaProfileMat(DnaProfileMat * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = DnaProfileMat_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for DnaProfileMat, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->t->len) { warn("In DnaProfileMat matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = DnaProfileMat_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source MATCH is not a special */ default: warn("Major problem (!) - in DnaProfileMat special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_DnaProfileMat(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_DnaProfileMat(DnaProfileMat * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = DnaProfileMat_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In DnaProfileMat matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : temp = cscore - (0) - (mat->m->score[i][j]); if( temp == DnaProfileMat_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - DnaProfileMat_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return DnaProfileMat_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source UNMATCHED is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in DnaProfileMat matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED : /* Source UNMATCHED is not a special, should not get here! */ /* Source UNMATCHED is not a special, should not get here! */ /* Source UNMATCHED is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in DnaProfileMat matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in DnaProfileMat matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in DnaProfileMat matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in DnaProfileMat read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_DnaProfileMat(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_DnaProfileMat(DnaProfileMat * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_DnaProfileMat(mat,starti,startj,stopi,stopj); DnaProfileMat_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ DnaProfileMat_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; DnaProfileMat_HIDDEN_MATRIX(mat,i,j,UNMATCHED) = NEGI; DnaProfileMat_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; DnaProfileMat_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state UNMATCHED to state MATCH */ temp = DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED) + 0; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->m->score[i][j]; DnaProfileMat_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state UNMATCHED */ /* setting first movement to score */ score = DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->open_unmatched; /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->ext_unmatched; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-0,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ DnaProfileMat_HIDDEN_MATRIX(mat,i,j,UNMATCHED) = score; /* Finished calculating state UNMATCHED */ /* For state INSERT */ /* setting first movement to score */ score = DnaProfileMat_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + (mat->q->col[i]->trans[DnaProfile_M2I]+mat->t->col[j]->trans[DnaProfile_M2D]); /* From state INSERT to state INSERT */ temp = DnaProfileMat_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + (mat->q->col[i]->trans[DnaProfile_I2I]+mat->t->col[j]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ DnaProfileMat_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + (mat->t->col[j]->trans[DnaProfile_M2I]+mat->q->col[i]->trans[DnaProfile_M2D]); /* From state INSERT to state DELETE */ temp = DnaProfileMat_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + (mat->t->col[j]->trans[DnaProfile_I2I]+mat->q->col[i]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ DnaProfileMat_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } } return; } /* Function: init_hidden_DnaProfileMat(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_DnaProfileMat(DnaProfileMat * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { DnaProfileMat_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; DnaProfileMat_HIDDEN_MATRIX(mat,i,j,UNMATCHED) = NEGI; DnaProfileMat_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; DnaProfileMat_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; } } return; } /* Function: full_dc_DnaProfileMat(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_DnaProfileMat * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_DnaProfileMat to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [DnaProfileMat *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_DnaProfileMat(DnaProfileMat * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_DnaProfileMat"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_DnaProfileMat(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_DnaProfileMat(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_DnaProfileMat(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for DnaProfileMat, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_DnaProfileMat(mat,DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_DnaProfileMat(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_DnaProfileMat(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_DnaProfileMat(DnaProfileMat * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_DnaProfileMat(mat); DnaProfileMat_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_DnaProfileMat(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_DnaProfileMat(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_DnaProfileMat(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_DnaProfileMat(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_DnaProfileMat(DnaProfileMat * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,0) = (-100); DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,1) = (-100); DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; if( j - 1 <= mergej) { DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = UNMATCHED; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED,k); } } temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } } /* Add any movement independant score */ score += mat->m->score[i][j]; DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state UNMATCHED, pushing when j - offj <= mergej */ score = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->open_unmatched; if( j - 1 <= mergej) { DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,0) = i-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,1) = j-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,2) = MATCH; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,3) = i; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,4) = j; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,5) = UNMATCHED; } else { for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->ext_unmatched; if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,0) = i-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,1) = j-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,2) = UNMATCHED; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,3) = i; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,4) = j; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,5) = UNMATCHED; } else { for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED,k); } } temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,0) = i-0; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,1) = j-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,2) = UNMATCHED; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,3) = i; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,4) = j; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,5) = UNMATCHED; } else { for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED,k); } } temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score) { score = temp; if( j - 0 <= mergej) { DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,0) = i-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,1) = j-0; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,2) = UNMATCHED; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,3) = i; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,4) = j; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,5) = UNMATCHED; } else { for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED,k); } } /* Add any movement independant score */ DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = score; /* Finished with state UNMATCHED */ /* For state INSERT, pushing when j - offj <= mergej */ score = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->q->col[i]->trans[DnaProfile_M2I]+mat->t->col[j]->trans[DnaProfile_M2D]); if( j - 1 <= mergej) { DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + (mat->q->col[i]->trans[DnaProfile_I2I]+mat->t->col[j]->trans[DnaProfile_D2D]); if( temp > score) { score = temp; if( j - 1 <= mergej) { DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } /* Add any movement independant score */ DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (mat->t->col[j]->trans[DnaProfile_M2I]+mat->q->col[i]->trans[DnaProfile_M2D]); if( j - 0 <= mergej) { DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + (mat->t->col[j]->trans[DnaProfile_I2I]+mat->q->col[i]->trans[DnaProfile_D2D]); if( temp > score) { score = temp; if( j - 0 <= mergej) { DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } /* Add any movement independant score */ DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_DnaProfileMat(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_DnaProfileMat(DnaProfileMat * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); /* From state UNMATCHED to state MATCH */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED,k); } /* From state INSERT to state MATCH */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* From state DELETE to state MATCH */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->m->score[i][j]; DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state UNMATCHED */ /* setting first movement to score */ score = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->open_unmatched; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->ext_unmatched; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED,k); } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED,k); } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED,k); } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = score; for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED */ /* For state INSERT */ /* setting first movement to score */ score = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->q->col[i]->trans[DnaProfile_M2I]+mat->t->col[j]->trans[DnaProfile_M2D]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); /* From state INSERT to state INSERT */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + (mat->q->col[i]->trans[DnaProfile_I2I]+mat->t->col[j]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (mat->t->col[j]->trans[DnaProfile_M2I]+mat->q->col[i]->trans[DnaProfile_M2D]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + (mat->t->col[j]->trans[DnaProfile_I2I]+mat->q->col[i]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_DnaProfileMat(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_DnaProfileMat(DnaProfileMat * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state UNMATCHED to state MATCH */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + 0; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->m->score[i][j]; DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state UNMATCHED */ /* setting first movement to score */ score = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->open_unmatched; /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->ext_unmatched; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = score; /* Finished calculating state UNMATCHED */ /* For state INSERT */ /* setting first movement to score */ score = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->q->col[i]->trans[DnaProfile_M2I]+mat->t->col[j]->trans[DnaProfile_M2D]); /* From state INSERT to state INSERT */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + (mat->q->col[i]->trans[DnaProfile_I2I]+mat->t->col[j]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (mat->t->col[j]->trans[DnaProfile_M2I]+mat->q->col[i]->trans[DnaProfile_M2D]); /* From state INSERT to state DELETE */ temp = DnaProfileMat_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + (mat->t->col[j]->trans[DnaProfile_I2I]+mat->q->col[i]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_DnaProfileMat(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * */ } void init_dc_DnaProfileMat(DnaProfileMat * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iq->len;i++) { DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; for(k=0;k<7;k++) { DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = (-1); DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); } } } return; } /* Function: start_end_find_end_DnaProfileMat(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [DnaProfileMat *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_DnaProfileMat(DnaProfileMat * mat,int * endj) { register int j; register int max; register int maxj; max = DnaProfileMat_DC_SHADOW_SPECIAL(mat,0,mat->t->len-1,END); maxj = mat->t->len-1; for(j= mat->t->len-2 ;j >= 0 ;j--) { if( DnaProfileMat_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = DnaProfileMat_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_DnaProfileMat(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [DnaProfileMat] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_DnaProfileMat(DnaProfileMat *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->q->len; lenj = mat->t->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 4,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 4 * 8,sizeof(int)); for(j=0;jm->score[i][j]); /* assign local shadown pointer */ localsp = &(DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); /* From state UNMATCHED to state MATCH */ temp = DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + 0 +(mat->m->score[i][j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED,0)); } /* From state INSERT to state MATCH */ temp = DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + 0 +(mat->m->score[i][j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* From state DELETE to state MATCH */ temp = DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + 0 +(mat->m->score[i][j]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,0)); } /* From state START to state MATCH */ temp = DnaProfileMat_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + 0 + (mat->m->score[i][j]); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > DnaProfileMat_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { DnaProfileMat_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) DnaProfileMat_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); DnaProfileMat_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); DnaProfileMat_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; DnaProfileMat_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; DnaProfileMat_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state UNMATCHED */ /* setting first movement to score */ score = DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->open_unmatched + (0); /* assign local shadown pointer */ localsp = &(DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->ext_unmatched +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED,0)); } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED,0)); } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED,0)); } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i,j,UNMATCHED) = score; for(k=0;k<7;k++) DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED */ /* For state INSERT */ /* setting first movement to score */ score = DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + (mat->q->col[i]->trans[DnaProfile_M2I]+mat->t->col[j]->trans[DnaProfile_M2D]) + (0); /* assign local shadown pointer */ localsp = &(DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); /* From state INSERT to state INSERT */ temp = DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + (mat->q->col[i]->trans[DnaProfile_I2I]+mat->t->col[j]->trans[DnaProfile_D2D]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + (mat->t->col[j]->trans[DnaProfile_M2I]+mat->q->col[i]->trans[DnaProfile_M2D]) + (0); /* assign local shadown pointer */ localsp = &(DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + (mat->t->col[j]->trans[DnaProfile_I2I]+mat->q->col[i]->trans[DnaProfile_D2D]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ DnaProfileMat_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) DnaProfileMat_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_DnaProfileMat(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * */ void init_start_end_linear_DnaProfileMat(DnaProfileMat * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iq->len;i++) { DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED,0) = (-1); DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); DnaProfileMat_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; DnaProfileMat_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); } } for(j=(-1);jt->len;j++) { DnaProfileMat_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; DnaProfileMat_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; DnaProfileMat_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_DnaProfileMat(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_DnaProfileMat(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_DnaProfileMat(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH","SEQ_UNMATCHED","PAUSED_UNMATCHED","PAUSE","INSERT","END" }; /* Function: AlnConvertSet_DnaProfileMat(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "MATCH","SEQ_UNMATCHED","PAUSED_UNMATCHED","INSERT","PAUSE","END" }; AlnConvertSet * AlnConvertSet_DnaProfileMat(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 4; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = UNMATCHED; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED; acu->state2 = UNMATCHED; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED; acu->state2 = UNMATCHED; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[2]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED; acu->state2 = UNMATCHED; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 4; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[5]; acu->label2 = target_label[5]; return out; } /* Function: PackAln_read_Expl_DnaProfileMat(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_DnaProfileMat(DnaProfileMat * mat) { DnaProfileMat_access_func_holder holder; holder.access_main = DnaProfileMat_explicit_access_main; holder.access_special = DnaProfileMat_explicit_access_special; return PackAln_read_generic_DnaProfileMat(mat,holder); } /* Function: DnaProfileMat_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int DnaProfileMat_explicit_access_main(DnaProfileMat * mat,int i,int j,int state) { return DnaProfileMat_EXPL_MATRIX(mat,i,j,state); } /* Function: DnaProfileMat_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int DnaProfileMat_explicit_access_special(DnaProfileMat * mat,int i,int j,int state) { return DnaProfileMat_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_DnaProfileMat(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: h [UNKN ] Undocumented argument [DnaProfileMat_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_DnaProfileMat(DnaProfileMat * mat,DnaProfileMat_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_DnaProfileMat(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in DnaProfileMat_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 4; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_DnaProfileMat(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_DnaProfileMat(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == DnaProfileMat_READ_OFF_ERROR || j == DnaProfileMat_READ_OFF_ERROR || state == DnaProfileMat_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in DnaProfileMat_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 4; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_DnaProfileMat(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [DnaProfileMat_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_DnaProfileMat(DnaProfileMat * mat,int * ri,int * rj,int * state,boolean * isspecial,DnaProfileMat_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->t->len-1,END); maxj = mat->t->len-1; for(j= mat->t->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: DnaProfileMat_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void DnaProfileMat_debug_show_matrix(DnaProfileMat * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iq->len;i++) { for(j=startj;jt->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",DnaProfileMat_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State UNMATCHED %d\n",DnaProfileMat_EXPL_MATRIX(mat,i,j,UNMATCHED)); fprintf(ofp,"State INSERT %d\n",DnaProfileMat_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",DnaProfileMat_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_DnaProfileMat(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [DnaProfileMat_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_DnaProfileMat(DnaProfileMat * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,DnaProfileMat_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = DnaProfileMat_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->q->len || j > mat->t->len) { warn("In DnaProfileMat matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (0) - (mat->m->score[i][j]); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (0) - (mat->m->score[i][j]); if( temp == (*h.access_main)(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,DELETE); } return (*h.access_main)(mat,i - 1,j - 1,DELETE); } temp = cscore - (0) - (mat->m->score[i][j]); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (0) - (mat->m->score[i][j]); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED); } temp = cscore - (0) - (mat->m->score[i][j]); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in DnaProfileMat read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED : temp = cscore - ((mat->ext_unmatched+mat->gap_unmatched)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,UNMATCHED) ) { *reti = i - 1; *retj = j - 0; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,UNMATCHED); } return (*h.access_main)(mat,i - 1,j - 0,UNMATCHED); } temp = cscore - ((mat->ext_unmatched+mat->gap_unmatched)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UNMATCHED) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UNMATCHED); } return (*h.access_main)(mat,i - 0,j - 1,UNMATCHED); } temp = cscore - (mat->ext_unmatched) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED); } temp = cscore - (mat->open_unmatched) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in DnaProfileMat read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - ((mat->q->col[i]->trans[DnaProfile_I2I]+mat->t->col[j]->trans[DnaProfile_D2D])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - ((mat->q->col[i]->trans[DnaProfile_M2I]+mat->t->col[j]->trans[DnaProfile_M2D])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in DnaProfileMat read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - ((mat->t->col[j]->trans[DnaProfile_I2I]+mat->q->col[i]->trans[DnaProfile_D2D])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - ((mat->t->col[j]->trans[DnaProfile_M2I]+mat->q->col[i]->trans[DnaProfile_M2D])) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in DnaProfileMat read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in DnaProfileMat read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_DnaProfileMat(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [DnaProfileMat_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_DnaProfileMat(DnaProfileMat * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,DnaProfileMat_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = DnaProfileMat_READ_OFF_ERROR; if( j < 0 || j > mat->t->len) { warn("In DnaProfileMat matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source MATCH is from main matrix */ for(i= mat->q->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in DnaProfileMat read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_DnaProfileMat(mat) * * Descrip: This function calculates the DnaProfileMat matrix when in explicit mode * To allocate the matrix use /allocate_Expl_DnaProfileMat * * * Arg: mat [UNKN ] DnaProfileMat which contains explicit basematrix memory [DnaProfileMat *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_DnaProfileMat(DnaProfileMat * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_DnaProfileMat, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("DnaProfileMat Matrix calculation: "); for(j=0;j score ) { score = temp; } /* From state INSERT to state MATCH */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = DnaProfileMat_EXPL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->m->score[i][j]; DnaProfileMat_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > DnaProfileMat_EXPL_SPECIAL(mat,i,j,END) ) { DnaProfileMat_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state UNMATCHED */ /* setting first movement to score */ score = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->open_unmatched; /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->ext_unmatched; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-0,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ DnaProfileMat_EXPL_MATRIX(mat,i,j,UNMATCHED) = score; /* Finished calculating state UNMATCHED */ /* For state INSERT */ /* setting first movement to score */ score = DnaProfileMat_EXPL_MATRIX(mat,i-0,j-1,MATCH) + (mat->q->col[i]->trans[DnaProfile_M2I]+mat->t->col[j]->trans[DnaProfile_M2D]); /* From state INSERT to state INSERT */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-0,j-1,INSERT) + (mat->q->col[i]->trans[DnaProfile_I2I]+mat->t->col[j]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ DnaProfileMat_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-0,MATCH) + (mat->t->col[j]->trans[DnaProfile_M2I]+mat->q->col[i]->trans[DnaProfile_M2D]); /* From state INSERT to state DELETE */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-0,INSERT) + (mat->t->col[j]->trans[DnaProfile_I2I]+mat->q->col[i]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ DnaProfileMat_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_DnaProfileMat(mat,dpenv) * * Descrip: This function calculates the DnaProfileMat matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] DnaProfileMat which contains explicit basematrix memory [DnaProfileMat *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_DnaProfileMat(DnaProfileMat * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_DnaProfileMat, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { DnaProfileMat_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; DnaProfileMat_EXPL_MATRIX(mat,i,j,UNMATCHED) = NEGI; DnaProfileMat_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; DnaProfileMat_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j=-1;jlenj;j++) { DnaProfileMat_EXPL_SPECIAL(mat,i,j,START) = 0; DnaProfileMat_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("DnaProfileMat Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { DnaProfileMat_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; DnaProfileMat_EXPL_MATRIX(mat,i,j,UNMATCHED) = NEGI; DnaProfileMat_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; DnaProfileMat_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-1,MATCH) + 0; /* From state UNMATCHED to state MATCH */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED) + 0; if( temp > score ) { score = temp; } /* From state INSERT to state MATCH */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-1,INSERT) + 0; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-1,DELETE) + 0; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = DnaProfileMat_EXPL_SPECIAL(mat,i-1,j-1,START) + 0; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->m->score[i][j]; DnaProfileMat_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (0) + (0) ; if( temp > DnaProfileMat_EXPL_SPECIAL(mat,i,j,END) ) { DnaProfileMat_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state UNMATCHED */ /* setting first movement to score */ score = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->open_unmatched; /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED) + mat->ext_unmatched; if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; } /* From state UNMATCHED to state UNMATCHED */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-0,UNMATCHED) + (mat->ext_unmatched+mat->gap_unmatched); if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED */ /* Add any movement independant score and put away */ DnaProfileMat_EXPL_MATRIX(mat,i,j,UNMATCHED) = score; /* Finished calculating state UNMATCHED */ /* For state INSERT */ /* setting first movement to score */ score = DnaProfileMat_EXPL_MATRIX(mat,i-0,j-1,MATCH) + (mat->q->col[i]->trans[DnaProfile_M2I]+mat->t->col[j]->trans[DnaProfile_M2D]); /* From state INSERT to state INSERT */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-0,j-1,INSERT) + (mat->q->col[i]->trans[DnaProfile_I2I]+mat->t->col[j]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ DnaProfileMat_EXPL_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-0,MATCH) + (mat->t->col[j]->trans[DnaProfile_M2I]+mat->q->col[i]->trans[DnaProfile_M2D]); /* From state INSERT to state DELETE */ temp = DnaProfileMat_EXPL_MATRIX(mat,i-1,j-0,INSERT) + (mat->t->col[j]->trans[DnaProfile_I2I]+mat->q->col[i]->trans[DnaProfile_D2D]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ DnaProfileMat_EXPL_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: DnaProfileMat_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileMat *] * */ DnaProfileMat * DnaProfileMat_alloc(void) { DnaProfileMat * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaProfileMat *) ckalloc (sizeof(DnaProfileMat))) == NULL) { warn("DnaProfileMat_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_DnaProfileMat(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileMat *] * * Return [UNKN ] Undocumented return value [DnaProfileMat *] * */ DnaProfileMat * free_DnaProfileMat(DnaProfileMat * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaProfileMat obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->q is linked in */ /* obj->t is linked in */ /* obj->m is linked in */ /* obj->open_unmatched is linked in */ /* obj->ext_unmatched is linked in */ /* obj->gap_unmatched is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/dnaprofiledp.h0000644000175000001440000005767210670453713016772 0ustar philippusers#ifndef DYNAMITEdnaprofiledpHEADERFILE #define DYNAMITEdnaprofiledpHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dnaprofile.h" struct Wise2_DnaProfileMatchScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score ** score; int leni; /* leni for above score */ int maxleni;/* max length for above pointer set */ int lenj; /* lenj for above score */ int maxlenj;/* max length for above pointer set */ } ; /* DnaProfileMatchScore defined */ #ifndef DYNAMITE_DEFINED_DnaProfileMatchScore typedef struct Wise2_DnaProfileMatchScore Wise2_DnaProfileMatchScore; #define DnaProfileMatchScore Wise2_DnaProfileMatchScore #define DYNAMITE_DEFINED_DnaProfileMatchScore #endif struct Wise2_DnaProfileMat { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; DnaProfileScore * q; DnaProfileScore * t; DnaProfileMatchScore* m; Score open_unmatched; Score ext_unmatched; Score gap_unmatched; } ; /* DnaProfileMat defined */ #ifndef DYNAMITE_DEFINED_DnaProfileMat typedef struct Wise2_DnaProfileMat Wise2_DnaProfileMat; #define DnaProfileMat Wise2_DnaProfileMat #define DYNAMITE_DEFINED_DnaProfileMat #endif #ifdef PTHREAD struct thread_pool_holder_DnaProfileMat { DnaProfileScore * q;/* Static query data: never free'd */ DnaProfileScore * t;/* Static target data: never free'd */ DnaProfileMatchScore* m; Score open_unmatched; Score ext_unmatched; Score gap_unmatched; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_DnaProfileMat_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(DnaProfileMat*,int,int,int); int (*access_special)(DnaProfileMat*,int,int,int); } ; /* DnaProfileMat_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_DnaProfileMat_access_func_holder typedef struct Wise2_DnaProfileMat_access_func_holder Wise2_DnaProfileMat_access_func_holder; #define DnaProfileMat_access_func_holder Wise2_DnaProfileMat_access_func_holder #define DYNAMITE_DEFINED_DnaProfileMat_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: DnaProfileMatchScore_alloc_matrix(leni,lenj) * * Descrip: Allocates structure and matrix * * * Arg: leni [UNKN ] Length of first dimension of matrix [int] * Arg: lenj [UNKN ] Length of second dimension of matrix [int] * * Return [UNKN ] Undocumented return value [DnaProfileMatchScore *] * */ DnaProfileMatchScore * Wise2_DnaProfileMatchScore_alloc_matrix(int leni,int lenj); #define DnaProfileMatchScore_alloc_matrix Wise2_DnaProfileMatchScore_alloc_matrix /* Function: hard_link_DnaProfileMatchScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProfileMatchScore *] * * Return [UNKN ] Undocumented return value [DnaProfileMatchScore *] * */ DnaProfileMatchScore * Wise2_hard_link_DnaProfileMatchScore(DnaProfileMatchScore * obj); #define hard_link_DnaProfileMatchScore Wise2_hard_link_DnaProfileMatchScore /* Function: DnaProfileMatchScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileMatchScore *] * */ DnaProfileMatchScore * Wise2_DnaProfileMatchScore_alloc(void); #define DnaProfileMatchScore_alloc Wise2_DnaProfileMatchScore_alloc /* Function: free_DnaProfileMatchScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileMatchScore *] * * Return [UNKN ] Undocumented return value [DnaProfileMatchScore *] * */ DnaProfileMatchScore * Wise2_free_DnaProfileMatchScore(DnaProfileMatchScore * obj); #define free_DnaProfileMatchScore Wise2_free_DnaProfileMatchScore /* Function: PackAln_read_Shatter_DnaProfileMat(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_DnaProfileMat(DnaProfileMat * mat); #define PackAln_read_Shatter_DnaProfileMat Wise2_PackAln_read_Shatter_DnaProfileMat /* Function: calculate_shatter_DnaProfileMat(mat,dpenv) * * Descrip: This function calculates the DnaProfileMat matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [DnaProfileMat *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_DnaProfileMat(DnaProfileMat * mat,DPEnvelope * dpenv); #define calculate_shatter_DnaProfileMat Wise2_calculate_shatter_DnaProfileMat /* Function: search_DnaProfileMat(dbsi,out,q,t,m,open_unmatched,ext_unmatched,gap_unmatched) * * Descrip: This function makes a database search of DnaProfileMat * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [DnaProfileScore *] * Arg: t [UNKN ] Undocumented argument [DnaProfileScore *] * Arg: m [UNKN ] Undocumented argument [DnaProfileMatchScore*] * Arg: open_unmatched [UNKN ] Undocumented argument [Score] * Arg: ext_unmatched [UNKN ] Undocumented argument [Score] * Arg: gap_unmatched [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_DnaProfileMat(DBSearchImpl * dbsi,Hscore * out,DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched); #define search_DnaProfileMat Wise2_search_DnaProfileMat /* Function: serial_search_DnaProfileMat(out,q,t,m,open_unmatched,ext_unmatched,gap_unmatched) * * Descrip: This function makes a database search of DnaProfileMat * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: q [UNKN ] Undocumented argument [DnaProfileScore *] * Arg: t [UNKN ] Undocumented argument [DnaProfileScore *] * Arg: m [UNKN ] Undocumented argument [DnaProfileMatchScore*] * Arg: open_unmatched [UNKN ] Undocumented argument [Score] * Arg: ext_unmatched [UNKN ] Undocumented argument [Score] * Arg: gap_unmatched [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_DnaProfileMat(Hscore * out,DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched); #define serial_search_DnaProfileMat Wise2_serial_search_DnaProfileMat /* Function: PackAln_bestmemory_DnaProfileMat(q,t,m,open_unmatched,ext_unmatched,gap_unmatched,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_DnaProfileMat * * * Arg: q [UNKN ] query data structure [DnaProfileScore *] * Arg: t [UNKN ] target data structure [DnaProfileScore *] * Arg: m [UNKN ] Resource [DnaProfileMatchScore*] * Arg: open_unmatched [UNKN ] Resource [Score] * Arg: ext_unmatched [UNKN ] Resource [Score] * Arg: gap_unmatched [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_DnaProfileMat(DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_DnaProfileMat Wise2_PackAln_bestmemory_DnaProfileMat /* Function: allocate_Expl_DnaProfileMat(q,t,m,open_unmatched,ext_unmatched,gap_unmatched,dpri) * * Descrip: This function allocates the DnaProfileMat structure * and the basematrix area for explicit memory implementations * It calls /allocate_DnaProfileMat_only * * * Arg: q [UNKN ] query data structure [DnaProfileScore *] * Arg: t [UNKN ] target data structure [DnaProfileScore *] * Arg: m [UNKN ] Resource [DnaProfileMatchScore*] * Arg: open_unmatched [UNKN ] Resource [Score] * Arg: ext_unmatched [UNKN ] Resource [Score] * Arg: gap_unmatched [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [DnaProfileMat *] * */ DnaProfileMat * Wise2_allocate_Expl_DnaProfileMat(DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched,DPRunImpl * dpri); #define allocate_Expl_DnaProfileMat Wise2_allocate_Expl_DnaProfileMat /* Function: recalculate_PackAln_DnaProfileMat(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by DnaProfileMat * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * */ void Wise2_recalculate_PackAln_DnaProfileMat(PackAln * pal,DnaProfileMat * mat); #define recalculate_PackAln_DnaProfileMat Wise2_recalculate_PackAln_DnaProfileMat /* Function: allocate_Small_DnaProfileMat(q,t,m,open_unmatched,ext_unmatched,gap_unmatched) * * Descrip: This function allocates the DnaProfileMat structure * and the basematrix area for a small memory implementations * It calls /allocate_DnaProfileMat_only * * * Arg: q [UNKN ] query data structure [DnaProfileScore *] * Arg: t [UNKN ] target data structure [DnaProfileScore *] * Arg: m [UNKN ] Resource [DnaProfileMatchScore*] * Arg: open_unmatched [UNKN ] Resource [Score] * Arg: ext_unmatched [UNKN ] Resource [Score] * Arg: gap_unmatched [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [DnaProfileMat *] * */ DnaProfileMat * Wise2_allocate_Small_DnaProfileMat(DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched); #define allocate_Small_DnaProfileMat Wise2_allocate_Small_DnaProfileMat /* Function: PackAln_calculate_Small_DnaProfileMat(mat,dpenv) * * Descrip: This function calculates an alignment for DnaProfileMat structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_DnaProfileMat * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_DnaProfileMat * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_DnaProfileMat(DnaProfileMat * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_DnaProfileMat Wise2_PackAln_calculate_Small_DnaProfileMat /* Function: AlnRangeSet_calculate_Small_DnaProfileMat(mat) * * Descrip: This function calculates an alignment for DnaProfileMat structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_DnaProfileMat * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_DnaProfileMat * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_DnaProfileMat * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_DnaProfileMat(DnaProfileMat * mat); #define AlnRangeSet_calculate_Small_DnaProfileMat Wise2_AlnRangeSet_calculate_Small_DnaProfileMat /* Function: AlnRangeSet_from_DnaProfileMat(mat) * * Descrip: This function reads off a start/end structure * for DnaProfileMat structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_DnaProfileMat * If you have not calculated the matrix use * /AlnRange_calculate_Small_DnaProfileMat * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_DnaProfileMat(DnaProfileMat * mat); #define AlnRangeSet_from_DnaProfileMat Wise2_AlnRangeSet_from_DnaProfileMat /* Function: convert_PackAln_to_AlnBlock_DnaProfileMat(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_DnaProfileMat(PackAln * pal); #define convert_PackAln_to_AlnBlock_DnaProfileMat Wise2_convert_PackAln_to_AlnBlock_DnaProfileMat /* Function: PackAln_read_Expl_DnaProfileMat(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_DnaProfileMat(DnaProfileMat * mat); #define PackAln_read_Expl_DnaProfileMat Wise2_PackAln_read_Expl_DnaProfileMat /* Function: PackAln_read_generic_DnaProfileMat(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [DnaProfileMat *] * Arg: h [UNKN ] Undocumented argument [DnaProfileMat_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_DnaProfileMat(DnaProfileMat * mat,DnaProfileMat_access_func_holder h); #define PackAln_read_generic_DnaProfileMat Wise2_PackAln_read_generic_DnaProfileMat /* Function: calculate_DnaProfileMat(mat) * * Descrip: This function calculates the DnaProfileMat matrix when in explicit mode * To allocate the matrix use /allocate_Expl_DnaProfileMat * * * Arg: mat [UNKN ] DnaProfileMat which contains explicit basematrix memory [DnaProfileMat *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_DnaProfileMat(DnaProfileMat * mat); #define calculate_DnaProfileMat Wise2_calculate_DnaProfileMat /* Function: calculate_dpenv_DnaProfileMat(mat,dpenv) * * Descrip: This function calculates the DnaProfileMat matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] DnaProfileMat which contains explicit basematrix memory [DnaProfileMat *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_DnaProfileMat(DnaProfileMat * mat,DPEnvelope * dpenv); #define calculate_dpenv_DnaProfileMat Wise2_calculate_dpenv_DnaProfileMat /* Function: DnaProfileMat_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProfileMat *] * */ DnaProfileMat * Wise2_DnaProfileMat_alloc(void); #define DnaProfileMat_alloc Wise2_DnaProfileMat_alloc /* Function: free_DnaProfileMat(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProfileMat *] * * Return [UNKN ] Undocumented return value [DnaProfileMat *] * */ DnaProfileMat * Wise2_free_DnaProfileMat(DnaProfileMat * obj); #define free_DnaProfileMat Wise2_free_DnaProfileMat /* Unplaced functions */ /* There has been no indication of the use of these functions */ DnaProfileMatchScore * Wise2_new_ALLR_DnaProfileMatchScore(DnaProfile * q,DnaProfile * t); #define new_ALLR_DnaProfileMatchScore Wise2_new_ALLR_DnaProfileMatchScore DnaProfileMatchScore * Wise2_new_DnaProfileMatchScore(DnaProfileScore * q,DnaProfileScore * t); #define new_DnaProfileMatchScore Wise2_new_DnaProfileMatchScore /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_expand_DnaProfileMatchScore(DnaProfileMatchScore * obj,int leni,int lenj); #define expand_DnaProfileMatchScore Wise2_expand_DnaProfileMatchScore int Wise2_DnaProfileMat_shatter_access_main(DnaProfileMat * mat,int i,int j,int state); #define DnaProfileMat_shatter_access_main Wise2_DnaProfileMat_shatter_access_main int Wise2_DnaProfileMat_shatter_access_special(DnaProfileMat * mat,int i,int j,int state); #define DnaProfileMat_shatter_access_special Wise2_DnaProfileMat_shatter_access_special void * Wise2_thread_loop_DnaProfileMat(void * ptr); #define thread_loop_DnaProfileMat Wise2_thread_loop_DnaProfileMat int Wise2_score_only_DnaProfileMat(DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched); #define score_only_DnaProfileMat Wise2_score_only_DnaProfileMat DnaProfileMat * Wise2_allocate_DnaProfileMat_only(DnaProfileScore * q,DnaProfileScore * t ,DnaProfileMatchScore* m,Score open_unmatched,Score ext_unmatched,Score gap_unmatched); #define allocate_DnaProfileMat_only Wise2_allocate_DnaProfileMat_only void Wise2_init_DnaProfileMat(DnaProfileMat * mat); #define init_DnaProfileMat Wise2_init_DnaProfileMat AlnRange * Wise2_AlnRange_build_DnaProfileMat(DnaProfileMat * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_DnaProfileMat Wise2_AlnRange_build_DnaProfileMat boolean Wise2_read_hidden_DnaProfileMat(DnaProfileMat * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_DnaProfileMat Wise2_read_hidden_DnaProfileMat int Wise2_max_hidden_DnaProfileMat(DnaProfileMat * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_DnaProfileMat Wise2_max_hidden_DnaProfileMat boolean Wise2_read_special_strip_DnaProfileMat(DnaProfileMat * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_DnaProfileMat Wise2_read_special_strip_DnaProfileMat int Wise2_max_special_strip_DnaProfileMat(DnaProfileMat * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_DnaProfileMat Wise2_max_special_strip_DnaProfileMat int Wise2_max_matrix_to_special_DnaProfileMat(DnaProfileMat * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_DnaProfileMat Wise2_max_matrix_to_special_DnaProfileMat void Wise2_calculate_hidden_DnaProfileMat(DnaProfileMat * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_DnaProfileMat Wise2_calculate_hidden_DnaProfileMat void Wise2_init_hidden_DnaProfileMat(DnaProfileMat * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_DnaProfileMat Wise2_init_hidden_DnaProfileMat boolean Wise2_full_dc_DnaProfileMat(DnaProfileMat * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_DnaProfileMat Wise2_full_dc_DnaProfileMat boolean Wise2_do_dc_single_pass_DnaProfileMat(DnaProfileMat * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_DnaProfileMat Wise2_do_dc_single_pass_DnaProfileMat void Wise2_push_dc_at_merge_DnaProfileMat(DnaProfileMat * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_DnaProfileMat Wise2_push_dc_at_merge_DnaProfileMat void Wise2_follow_on_dc_DnaProfileMat(DnaProfileMat * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_DnaProfileMat Wise2_follow_on_dc_DnaProfileMat void Wise2_run_up_dc_DnaProfileMat(DnaProfileMat * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_DnaProfileMat Wise2_run_up_dc_DnaProfileMat void Wise2_init_dc_DnaProfileMat(DnaProfileMat * mat); #define init_dc_DnaProfileMat Wise2_init_dc_DnaProfileMat int Wise2_start_end_find_end_DnaProfileMat(DnaProfileMat * mat,int * endj); #define start_end_find_end_DnaProfileMat Wise2_start_end_find_end_DnaProfileMat boolean Wise2_dc_optimised_start_end_calc_DnaProfileMat(DnaProfileMat *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_DnaProfileMat Wise2_dc_optimised_start_end_calc_DnaProfileMat void Wise2_init_start_end_linear_DnaProfileMat(DnaProfileMat * mat); #define init_start_end_linear_DnaProfileMat Wise2_init_start_end_linear_DnaProfileMat AlnConvertSet * Wise2_AlnConvertSet_DnaProfileMat(void); #define AlnConvertSet_DnaProfileMat Wise2_AlnConvertSet_DnaProfileMat int Wise2_DnaProfileMat_explicit_access_main(DnaProfileMat * mat,int i,int j,int state); #define DnaProfileMat_explicit_access_main Wise2_DnaProfileMat_explicit_access_main int Wise2_DnaProfileMat_explicit_access_special(DnaProfileMat * mat,int i,int j,int state); #define DnaProfileMat_explicit_access_special Wise2_DnaProfileMat_explicit_access_special int Wise2_find_end_DnaProfileMat(DnaProfileMat * mat,int * ri,int * rj,int * state,boolean * isspecial,DnaProfileMat_access_func_holder h); #define find_end_DnaProfileMat Wise2_find_end_DnaProfileMat void Wise2_DnaProfileMat_debug_show_matrix(DnaProfileMat * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define DnaProfileMat_debug_show_matrix Wise2_DnaProfileMat_debug_show_matrix int Wise2_max_calc_DnaProfileMat(DnaProfileMat * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,DnaProfileMat_access_func_holder h); #define max_calc_DnaProfileMat Wise2_max_calc_DnaProfileMat int Wise2_max_calc_special_DnaProfileMat(DnaProfileMat * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,DnaProfileMat_access_func_holder h); #define max_calc_special_DnaProfileMat Wise2_max_calc_special_DnaProfileMat #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/estwrap.c0000644000175000001440000003211410670453713015763 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "estwrap.h" /* Function: string_from_alg_estwrap(alg_type) * * Descrip: Returns the string form of the algorithm * * * Arg: alg_type [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [char *] * */ # line 36 "estwrap.dy" char * string_from_alg_estwrap(int alg_type) { switch(alg_type) { case ESTWISE_3 : return "333"; case ESTSLIM_3 : return "312"; case ESTLOOP_3 : return "333L"; case ESTQUICK_3 : return "312Q"; default : return "No algorithm type specd"; } } /* Function: alg_estwrap_from_string(str) * * Descrip: This function returns the algorithm type * for an est search from the string * * * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 51 "estwrap.dy" int alg_estwrap_from_string(char * str) { int t; t = get_number_from_slashed_string(str,"333/333L/333F/312/312L/312Q"); switch (t) { case 0 : return ESTWISE_3; case 1 : return ESTLOOP_3; case 2 : return ESTFRAG_3; case 3 : return ESTSLIM_3; case 4 : return ESTSLIM_L; case 5 : return ESTQUICK_3; default : warn("Cannot convert string %s into a valid estwise algorithm type\n",str); return -1; } } /* Function: AlnBlock_from_Protein_estwise_wrap(pro,cdna,cp,cm,ct,comp,gap,ext,is_global,rmd,alg,rm,use_syn,allN,dpri,palpoi) * * Descrip: This function is the guts for the est single alignment * mode. * * It uses /AlnBlock_from_TSM_estwise_wrap for the * heavy part of the call * * * Arg: pro [READ ] protein to be used in the comparison [Protein *] * Arg: cdna [READ ] cdna to be compared to [cDNA *] * Arg: cp [READ ] cdna parser indicating insertion deletion probabilities [cDNAParser *] * Arg: cm [READ ] codon mapper indicating substitution errors etc [CodonMapper *] * Arg: ct [READ ] codon table for the codon->amino acid mappings [CodonTable *] * Arg: comp [READ ] comparison matrix to use [CompMat *] * Arg: gap [UNKN ] gap penalty [int] * Arg: ext [UNKN ] extension penalty [int] * Arg: is_global [UNKN ] if true, global start-end in protein is used [boolean] * Arg: rmd [UNKN ] random model of dna to use [RandomModelDNA *] * Arg: alg [UNKN ] est algorithm type to use [int] * Arg: rm [UNKN ] random protein model for use with compmat [RandomModel *] * Arg: use_syn [UNKN ] if true, uses a synchronous coding model [boolean] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * Arg: palpoi [WRITE] the raw packed alignment output if wanted [PackAln **] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 92 "estwrap.dy" AlnBlock * AlnBlock_from_Protein_estwise_wrap(Protein * pro,cDNA * cdna,cDNAParser * cp,CodonMapper * cm,CodonTable * ct,CompMat * comp,int gap,int ext,boolean is_global,RandomModelDNA * rmd,int alg,RandomModel * rm,boolean use_syn,Probability allN,DPRunImpl * dpri,PackAln ** palpoi) { ThreeStateModel * tsm; AlnBlock * out; if( pro == NULL || cdna == NULL || comp == NULL || rm == NULL || dpri == NULL){ warn("trappable error in PackAln from protein sequence vs cDNA, passed some NULL objects, Complain!"); return NULL; } rm = default_RandomModel(); if( is_global == TRUE) tsm = global_ThreeStateModel_from_half_bit_Sequence(pro,comp,rm,gap,ext); else tsm = ThreeStateModel_from_half_bit_Sequence(pro,comp,rm,gap,ext); out = AlnBlock_from_TSM_estwise_wrap(tsm,cdna,cp,cm,ct,rmd,alg,use_syn,FALSE,allN,dpri,palpoi); free_ThreeStateModel(tsm); free_RandomModel(rm); return out; } /* Function: AlnBlock_from_TSM_estwise_wrap(tsm,cdna,cp,cm,ct,rmd,alg,use_syn,force_flat_insert,allN,dpri,palpoi) * * Descrip: This function is the basic wrap for Protein models * vs cDNA sequences. * * * Arg: tsm [READ ] threestatemodel to be compared to the dna [ThreeStateModel *] * Arg: cdna [READ ] cdna to be compared to [cDNA *] * Arg: cp [READ ] cdna parser indicating insertion deletion probabilities [cDNAParser *] * Arg: cm [READ ] codon mapper indicating substitution errors etc [CodonMapper *] * Arg: ct [READ ] codon table for the codon->amino acid mappings [CodonTable *] * Arg: rmd [UNKN ] random model of dna to use [RandomModelDNA *] * Arg: alg [UNKN ] est algorithm type to use [int] * Arg: use_syn [UNKN ] if true, uses a synchronous coding model [boolean] * Arg: force_flat_insert [UNKN ] Undocumented argument [boolean] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * Arg: palpoi [WRITE] the raw packed alignment output if wanted [PackAln **] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 136 "estwrap.dy" AlnBlock * AlnBlock_from_TSM_estwise_wrap(ThreeStateModel * tsm,cDNA * cdna,cDNAParser * cp,CodonMapper * cm,CodonTable * ct,RandomModelDNA * rmd,int alg,boolean use_syn,boolean force_flat_insert,Probability allN,DPRunImpl * dpri,PackAln ** palpoi) { AlnBlock * out; PackAln * pal; cDNAParserScore * cps = NULL ; GeneWise * gw = NULL ; GeneWiseScore * gws = NULL ; ComplexSequence * cs = NULL ; ComplexSequenceEvalSet * cses = NULL ; if( tsm == NULL || cdna == NULL || cp == NULL || rmd == NULL || dpri == NULL){ warn("trappable error in AlnBlock estwise wrap, passed some NULL objects, Complain!"); return NULL; } if( (gw=GeneWise_from_ThreeStateModel_cdna(tsm,cp,cm,allN)) == NULL) { warn("Unable to make GeneWise model in estwise wrap"); goto exit; } if( use_syn == TRUE ) { if( tsm->rm == NULL ) { warn("A three state model with no random model! Ugh!"); goto exit; } GeneWise_fold_in_synchronised_RandomModel(gw,tsm->rm,cm,ct,0.5); if( force_flat_insert == TRUE ) { check_flat_insert(gw,TRUE,FALSE,ct); } } else { GeneWise_fold_in_RandomModelDNA(gw,rmd); } if( (gws = GeneWiseScore_from_GeneWise(gw)) == NULL) { warn("Unable to make GeneWiseScore model in estwise wrap"); goto exit; } if( (cps = cDNAParserScore_from_cDNAParser(cp)) == NULL ) { warn("Unable to make cDNAParserScore in estwise wrap"); goto exit; } cses = default_cDNA_ComplexSequenceEvalSet(); cs = new_ComplexSequence(cdna->baseseq,cses); cses = free_ComplexSequenceEvalSet(cses); switch(alg) { case ESTWISE_3 : pal = PackAln_bestmemory_EstWise3(gws,cs,cps,NULL,dpri); out = convert_PackAln_to_AlnBlock_EstWise3(pal); break; case ESTLOOP_3 : pal = PackAln_bestmemory_EstLoop3(gws,cs,cps,NULL,dpri); out = convert_PackAln_to_AlnBlock_EstLoop3(pal); break; case ESTSLIM_3 : pal = PackAln_bestmemory_EstSlim3(gws,cs,cps,NULL,dpri); out = convert_PackAln_to_AlnBlock_EstLoop3(pal); break; case ESTSLIM_L : pal = PackAln_bestmemory_EstSlimLoop3(gws,cs,cps,NULL,dpri); out = convert_PackAln_to_AlnBlock_EstSlimLoop3(pal); break; case ESTFRAG_3 : pal = PackAln_bestmemory_EstFrag3(gws,cs,cps,0,0,NULL,dpri); out = convert_PackAln_to_AlnBlock_EstFrag3(pal); break; default : warn("No algorithm type specified. Not good news!"); goto exit; } if( palpoi != NULL) { *palpoi = pal; } else { free_PackAln(pal); } goto exit; exit : if( cps != NULL ) free_cDNAParserScore(cps); if( gw != NULL ) free_GeneWise(gw); if( gws != NULL) free_GeneWiseScore(gws); if( cs != NULL) free_ComplexSequence(cs); if( cses != NULL) free_ComplexSequenceEvalSet(cses); return out; } /* Function: Hscore_from_TSM_estwise(tdb,cdb,cp,cm,rmd,use_syn,alg,bits_cutoff,allN,flat_insert,report_level,die_on_error,dbsi) * * Descrip: Runs a database search for the estwise set * of algorithms * * * Arg: tdb [READ ] a three state model database [ThreeStateDB *] * Arg: cdb [READ ] a dna sequence database [cDNADB *] * Arg: cp [READ ] the codon parser for this comparison [cDNAParser *] * Arg: cm [READ ] the codon mapper for this comparison [CodonMapper *] * Arg: rmd [READ ] random model used for the dna sequence comparison [RandomModelDNA *] * Arg: use_syn [UNKN ] whether a synchronous coding model should be used or not [boolean] * Arg: alg [UNKN ] algorithm to use [int] * Arg: bits_cutoff [UNKN ] Undocumented argument [double] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: flat_insert [UNKN ] Undocumented argument [boolean] * Arg: report_level [UNKN ] Undocumented argument [int] * Arg: die_on_error [UNKN ] if true, dies if there is an error [boolean] * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * * Return [OWNER] a newly allocated Hscore structure of the search [Hscore *] * */ # line 262 "estwrap.dy" Hscore * Hscore_from_TSM_estwise(ThreeStateDB * tdb,cDNADB * cdb,cDNAParser * cp,CodonMapper * cm,RandomModelDNA * rmd,boolean use_syn,int alg,double bits_cutoff,Probability allN,boolean flat_insert,int report_level,boolean die_on_error,DBSearchImpl * dbsi) { Hscore * out = NULL; GeneWiseDB * gwdb; cDNAParserScore * cps = NULL ; GeneWiseQuickDB * gwq; Search_Return_Type ret; ret = SEARCH_ERROR; if( alg == ESTQUICK_3 && tdb->type != TSMDB_SINGLE ) { warn("Can only currently use estquick in a single mode search"); return NULL; } gwdb = new_GeneWiseDB_cdna(tdb,cp,cm,rmd,use_syn,allN,flat_insert); if( gwdb == NULL ) { warn("Could not build a new GeneWiseDB from the objects provided. Exiting without completing the search"); goto exit; } if( (cps = cDNAParserScore_from_cDNAParser(cp)) == NULL ) { warn("Unable to make cDNAParserScore in estwise wrap"); goto exit; } /*** allocate Hscore structure ***/ out = std_bits_Hscore(bits_cutoff,report_level); switch(alg) { case ESTWISE_3 : ret = search_EstWise3(dbsi,out,gwdb,cdb,cps); break; case ESTSLIM_3 : ret = search_EstSlim3(dbsi,out,gwdb,cdb,cps); break; case ESTQUICK_3 : gwq = GeneWiseQuickDB_from_GeneWiseDB(gwdb); ret = search_EstQuick3(dbsi,out,gwq,cdb,cps); free_GeneWiseQuickDB(gwq); break; default : warn("A major problem. No valid algorithm type passed in"); goto exit; } goto exit; exit : if( gwdb != NULL ) { free_GeneWiseDB(gwdb); } if( cps != NULL ) free_cDNAParserScore(cps); return out; } /* Function: write_mul_estwise_AlnBlock(alb,ct,ofp) * * Descrip: writes an mul format protein multiple * alignment from an AlnBlock with the first * sequence an HMM/protein and ignored, and * the second and subsequent sequences cdna sequences * which are then translated into proteins * * This relies considerably on the alb being made * correctly, and if it is not, then god help you. * * the estwisedb programs makes the alb correctly * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 343 "estwrap.dy" void write_mul_estwise_AlnBlock(AlnBlock * alb,CodonTable * ct,FILE * ofp) { char namebuffer[128]; AlnSequence * als; AlnUnit *ale; AlnColumn * alc; Sequence * seq; int i; assert(alb); assert(ct); for(i=1;ilen;i++) { als = alb->seq[i]; if( als->data == NULL ) { warn("For sequence %d in the estwise alnblock, no attached sequence, and so cannot write. Skipping",i); continue; } seq = (Sequence *) als->data; /* scared? I am! */ for(alc = alb->start,ale=NULL;alc->next != NULL;alc = alc->next) if( strstr(alc->alu[i]->text_label,"CODON") != NULL ) { ale = alc->alu[i]; } if( ale == NULL ) { warn("Unable to find even a codon matching this. Exiting for sequence %s in mul output",seq->name); continue; } /* fprintf(stdout,"Ale is %d-%d %s\n",ale->start,ale->end,ale->text_label);*/ if( is_reversed_Sequence(seq) ) sprintf(namebuffer,"%s/%d-%d",seq->name,ale->end,als->start->start+1); else sprintf(namebuffer,"%s/%d-%d",seq->name,als->start->start+2,ale->end+1); fprintf(ofp,"%-30s ",namebuffer); for(alc = alb->start;alc != NULL;alc = alc->next ) { if( strstr(alc->alu[i]->text_label,"CODON") != NULL ) { fputc(aminoacid_from_seq(ct,seq->seq+alc->alu[i]->start+1),ofp); } else if( strstr(alc->alu[i]->text_label,"INSERT") != NULL ) { fputc('-',ofp); } else { fputc('X',ofp); } } fputc('\n',ofp); } } # line 410 "estwrap.c" #ifdef _cplusplus } #endif wise-2.4.1/src/models/estwrap.h0000644000175000001440000001746310670453713016002 0ustar philippusers#ifndef DYNAMITEestwrapHEADERFILE #define DYNAMITEestwrapHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "estwise3.h" #include "estloop3.h" #include "estfrag3.h" #include "estslim3.h" #include "estquick3.h" #include "estslimloop.h" typedef enum est_alg_type { ESTWISE_3, ESTLOOP_3, ESTSLIM_3, ESTQUICK_3, ESTFRAG_3, ESTSLIM_L } est_alg_type; /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: string_from_alg_estwrap(alg_type) * * Descrip: Returns the string form of the algorithm * * * Arg: alg_type [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_string_from_alg_estwrap(int alg_type); #define string_from_alg_estwrap Wise2_string_from_alg_estwrap /* Function: alg_estwrap_from_string(str) * * Descrip: This function returns the algorithm type * for an est search from the string * * * Arg: str [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_alg_estwrap_from_string(char * str); #define alg_estwrap_from_string Wise2_alg_estwrap_from_string /* Function: AlnBlock_from_Protein_estwise_wrap(pro,cdna,cp,cm,ct,comp,gap,ext,is_global,rmd,alg,rm,use_syn,allN,dpri,palpoi) * * Descrip: This function is the guts for the est single alignment * mode. * * It uses /AlnBlock_from_TSM_estwise_wrap for the * heavy part of the call * * * Arg: pro [READ ] protein to be used in the comparison [Protein *] * Arg: cdna [READ ] cdna to be compared to [cDNA *] * Arg: cp [READ ] cdna parser indicating insertion deletion probabilities [cDNAParser *] * Arg: cm [READ ] codon mapper indicating substitution errors etc [CodonMapper *] * Arg: ct [READ ] codon table for the codon->amino acid mappings [CodonTable *] * Arg: comp [READ ] comparison matrix to use [CompMat *] * Arg: gap [UNKN ] gap penalty [int] * Arg: ext [UNKN ] extension penalty [int] * Arg: is_global [UNKN ] if true, global start-end in protein is used [boolean] * Arg: rmd [UNKN ] random model of dna to use [RandomModelDNA *] * Arg: alg [UNKN ] est algorithm type to use [int] * Arg: rm [UNKN ] random protein model for use with compmat [RandomModel *] * Arg: use_syn [UNKN ] if true, uses a synchronous coding model [boolean] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * Arg: palpoi [WRITE] the raw packed alignment output if wanted [PackAln **] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_AlnBlock_from_Protein_estwise_wrap(Protein * pro,cDNA * cdna,cDNAParser * cp,CodonMapper * cm,CodonTable * ct,CompMat * comp,int gap,int ext,boolean is_global,RandomModelDNA * rmd,int alg,RandomModel * rm,boolean use_syn,Probability allN,DPRunImpl * dpri,PackAln ** palpoi); #define AlnBlock_from_Protein_estwise_wrap Wise2_AlnBlock_from_Protein_estwise_wrap /* Function: AlnBlock_from_TSM_estwise_wrap(tsm,cdna,cp,cm,ct,rmd,alg,use_syn,force_flat_insert,allN,dpri,palpoi) * * Descrip: This function is the basic wrap for Protein models * vs cDNA sequences. * * * Arg: tsm [READ ] threestatemodel to be compared to the dna [ThreeStateModel *] * Arg: cdna [READ ] cdna to be compared to [cDNA *] * Arg: cp [READ ] cdna parser indicating insertion deletion probabilities [cDNAParser *] * Arg: cm [READ ] codon mapper indicating substitution errors etc [CodonMapper *] * Arg: ct [READ ] codon table for the codon->amino acid mappings [CodonTable *] * Arg: rmd [UNKN ] random model of dna to use [RandomModelDNA *] * Arg: alg [UNKN ] est algorithm type to use [int] * Arg: use_syn [UNKN ] if true, uses a synchronous coding model [boolean] * Arg: force_flat_insert [UNKN ] Undocumented argument [boolean] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * Arg: palpoi [WRITE] the raw packed alignment output if wanted [PackAln **] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_AlnBlock_from_TSM_estwise_wrap(ThreeStateModel * tsm,cDNA * cdna,cDNAParser * cp,CodonMapper * cm,CodonTable * ct,RandomModelDNA * rmd,int alg,boolean use_syn,boolean force_flat_insert,Probability allN,DPRunImpl * dpri,PackAln ** palpoi); #define AlnBlock_from_TSM_estwise_wrap Wise2_AlnBlock_from_TSM_estwise_wrap /* Function: Hscore_from_TSM_estwise(tdb,cdb,cp,cm,rmd,use_syn,alg,bits_cutoff,allN,flat_insert,report_level,die_on_error,dbsi) * * Descrip: Runs a database search for the estwise set * of algorithms * * * Arg: tdb [READ ] a three state model database [ThreeStateDB *] * Arg: cdb [READ ] a dna sequence database [cDNADB *] * Arg: cp [READ ] the codon parser for this comparison [cDNAParser *] * Arg: cm [READ ] the codon mapper for this comparison [CodonMapper *] * Arg: rmd [READ ] random model used for the dna sequence comparison [RandomModelDNA *] * Arg: use_syn [UNKN ] whether a synchronous coding model should be used or not [boolean] * Arg: alg [UNKN ] algorithm to use [int] * Arg: bits_cutoff [UNKN ] Undocumented argument [double] * Arg: allN [UNKN ] Undocumented argument [Probability] * Arg: flat_insert [UNKN ] Undocumented argument [boolean] * Arg: report_level [UNKN ] Undocumented argument [int] * Arg: die_on_error [UNKN ] if true, dies if there is an error [boolean] * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * * Return [OWNER] a newly allocated Hscore structure of the search [Hscore *] * */ Hscore * Wise2_Hscore_from_TSM_estwise(ThreeStateDB * tdb,cDNADB * cdb,cDNAParser * cp,CodonMapper * cm,RandomModelDNA * rmd,boolean use_syn,int alg,double bits_cutoff,Probability allN,boolean flat_insert,int report_level,boolean die_on_error,DBSearchImpl * dbsi); #define Hscore_from_TSM_estwise Wise2_Hscore_from_TSM_estwise /* Function: write_mul_estwise_AlnBlock(alb,ct,ofp) * * Descrip: writes an mul format protein multiple * alignment from an AlnBlock with the first * sequence an HMM/protein and ignored, and * the second and subsequent sequences cdna sequences * which are then translated into proteins * * This relies considerably on the alb being made * correctly, and if it is not, then god help you. * * the estwisedb programs makes the alb correctly * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_write_mul_estwise_AlnBlock(AlnBlock * alb,CodonTable * ct,FILE * ofp); #define write_mul_estwise_AlnBlock Wise2_write_mul_estwise_AlnBlock /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/seqlist.c0000644000175000001440000000050707562704074015770 0ustar philippusers#include "dyna.h" int main(int argc,char ** argv) { int start; int end; Sequence * in; int i; in = read_fasta_file_Sequence(argv[1]); start = atoi(argv[2]); end = atoi(argv[3]); for(i = start;i<= end;i++) { fprintf(stdout,"%d %c [%c]\n",i,in->seq[i-1],char_complement_base(in->seq[i-1])); } } wise-2.4.1/src/models/motifmatrix.dy0000644000175000001440000001152410011715071017020 0ustar philippusers %{ #include "transregion.h" %} struct MotifMatrixPara Probability comp_in_match Probability comp_out_match Probability comp_spacer Probability region_in Probability motif_indel Probability cons_indel Probability spacer_indel Probability spacer_to_cons Probability spacer_to_motif Probability spacer_duration Probability motif_duration Probability cons_duration struct MotifMatrixScore DnaMatrix * comp_in_motif DnaMatrix * comp_out_motif DnaMatrix * comp_spacer Score region_in Score motif_indel Score cons_indel Score spacer_indel Score spacer_to_cons Score spacer_to_motif Score spacer_duration Score motif_duration Score cons_duration struct MotifConsMatrix char ** mat !matrix %{ #include "motifmatrix.h" MotifMatrixScore * MotifMatrixScore_from_MotifMatrixPara(MotifMatrixPara * mmp) { MotifMatrixScore * out; DnaProbMatrix * dmp; out = MotifMatrixScore_alloc(); dmp = DnaProbMatrix_from_match(mmp->comp_in_match,NMaskType_BANNED); assert(dmp); flat_null_DnaProbMatrix(dmp); out->comp_in_motif = DnaMatrix_from_DnaProbMatrix(dmp); free_DnaProbMatrix(dmp); dmp = DnaProbMatrix_from_match(mmp->comp_out_match,NMaskType_BANNED); assert(dmp); flat_null_DnaProbMatrix(dmp); out->comp_out_motif = DnaMatrix_from_DnaProbMatrix(dmp); free_DnaProbMatrix(dmp); dmp = DnaProbMatrix_from_match(mmp->comp_spacer,NMaskType_BANNED); assert(dmp); flat_null_DnaProbMatrix(dmp); out->comp_spacer = DnaMatrix_from_DnaProbMatrix(dmp); free_DnaProbMatrix(dmp); out->region_in = Probability2Score(mmp->region_in); out->motif_indel = Probability2Score(mmp->motif_indel); out->cons_indel = Probability2Score(mmp->cons_indel); out->spacer_indel = Probability2Score(mmp->spacer_indel); out->spacer_to_cons = Probability2Score(mmp->spacer_to_cons); out->spacer_to_motif = Probability2Score(mmp->spacer_to_motif); out->spacer_duration = Probability2Score(mmp->spacer_duration); out->motif_duration = Probability2Score(mmp->motif_duration); out->cons_duration = Probability2Score(mmp->cons_duration); return out; } MotifMatrixPara * new_MotifMatrixPara_from_argv(int * argc,char ** argv) { MotifMatrixPara * out; out = MotifMatrixPara_alloc(); out->comp_in_match = 0.9; out->comp_out_match = 0.75; out->comp_spacer = 0.35; out->region_in = 0.0001; out->motif_indel = 0.00001; out->cons_indel = 0.025; out->spacer_indel = 0.1; out->spacer_duration = 0.2; out->motif_duration = 0.9; out->cons_duration = 0.7; out->spacer_to_motif = 0.05; out->spacer_to_cons = 0.000001; strip_out_float_argument(argc,argv,"mm_motif",&out->comp_in_match); strip_out_float_argument(argc,argv,"mm_cons",&out->comp_out_match); strip_out_float_argument(argc,argv,"mm_spacer",&out->comp_spacer); strip_out_float_argument(argc,argv,"mm_motif_indel",&out->motif_indel); strip_out_float_argument(argc,argv,"mm_cons_indel",&out->cons_indel); strip_out_float_argument(argc,argv,"mm_spacer_indel",&out->spacer_indel); strip_out_float_argument(argc,argv,"mm_switch_motif",&out->spacer_to_motif); strip_out_float_argument(argc,argv,"mm_switch_cons",&out->spacer_to_cons); return out; } void show_help_MotifMatrixPara(FILE * ofp) { fprintf(ofp,"Motif Matrix matching paramters\n"); fprintf(ofp," -mm_motif [0.9] Probability of a match in a motif\n"); fprintf(ofp," -mm_cons [0.75] Probability of a match in a non-motif conserved\n"); fprintf(ofp," -mm_spacer[0.35] Probability of a match in a spacer\n"); fprintf(ofp," -mm_motif_indel [0.00001] indel inside a motif\n"); fprintf(ofp," -mm_cons_indel [0.025] indel inside a conserved region\n"); fprintf(ofp," -mm_spacer_indel [0.1] indel inside a spacer\n"); fprintf(ofp," -mm_switch_motif [0.05] cost of switching to motif match\n"); fprintf(ofp," -mm_switch_cons [0.000001] cost of switching to conserved match\n"); } MotifConsMatrix * new_MotifConsMatrix(TransFactorMatchSet * one,int starti,int endi,TransFactorMatchSet * two,int startj,int endj) { int i; int j; int l; int k; int z; MotifConsMatrix * out; int motif_len; assert(one != NULL); assert(two != NULL); out = MotifConsMatrix_alloc_matrix(endi-starti,endj-startj); for(i=0;i< (endi-starti);i++) { for(j=0;j< (endj-startj) ;j++) { out->mat[i][j] = 0; } } for(l=0;llen;l++) { if( one->match[l]->start < starti || one->match[l]->end > endi ) { continue; } for(k=0;klen;k++) { if( two->match[k]->start < startj || two->match[k]->end > endj ) { continue; } if( two->match[k]->factor != one->match[l]->factor ) { continue; } motif_len = one->match[l]->end - one->match[l]->start; for(z=0;zmat[one->match[l]->start-starti+z][two->match[k]->start-startj+z] = 1; } } } return out; } wise-2.4.1/src/models/genefrequency.typemap0000644000175000001440000000145210670453714020375 0ustar philippusers TYPEMAP Wise2_GeneFrequency21 * T_Wise2_GeneFrequency21 INPUT T_Wise2_GeneFrequency21 $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_GeneFrequency21 *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_GeneFrequency21 sv_setref_pv($arg, "Wise2::GeneFrequency21", (void*) $var); TYPEMAP Wise2_GeneConsensus * T_Wise2_GeneConsensus INPUT T_Wise2_GeneConsensus $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_GeneConsensus *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_GeneConsensus sv_setref_pv($arg, "Wise2::GeneConsensus", (void*) $var); TYPEMAP Wise2_GeneSingleCons * T_Wise2_GeneSingleCons INPUT T_Wise2_GeneSingleCons $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_GeneSingleCons *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_GeneSingleCons sv_setref_pv($arg, "Wise2::GeneSingleCons", (void*) $var); wise-2.4.1/src/models/slimdba.c0000644000175000001440000041462210670453715015723 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "slimdba.h" # line 5 "slimdba.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:33 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH65 0 #define UNMATCHED_QUERY 1 #define UNMATCHED_TARGET 2 #define START 0 #define END 1 #define SlimDnaMatchBlock_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*3)+STATE][i+1] #define SlimDnaMatchBlock_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define SlimDnaMatchBlock_READ_OFF_ERROR -3 #define SlimDnaMatchBlock_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*3)+STATE] #define SlimDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define SlimDnaMatchBlock_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define SlimDnaMatchBlock_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_SlimDnaMatchBlock(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_SlimDnaMatchBlock(SlimDnaMatchBlock * mat) { SlimDnaMatchBlock_access_func_holder holder; holder.access_main = SlimDnaMatchBlock_shatter_access_main; holder.access_special = SlimDnaMatchBlock_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_SlimDnaMatchBlock(mat,holder); } /* Function: SlimDnaMatchBlock_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int SlimDnaMatchBlock_shatter_access_main(SlimDnaMatchBlock * mat,int i,int j,int state) { return SlimDnaMatchBlock_SHATTER_MATRIX(mat,i,j,state); } /* Function: SlimDnaMatchBlock_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int SlimDnaMatchBlock_shatter_access_special(SlimDnaMatchBlock * mat,int i,int j,int state) { return SlimDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_SlimDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the SlimDnaMatchBlock matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [SlimDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("SlimDnaMatchBlock Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH65 */ /* setting first movement to score */ score = SIG_1_1[MATCH65] + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = SIG_0_1[MATCH65] + mat->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = SIG_1_0[MATCH65] + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = SIG_1_1[UNMATCHED_TARGET] + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ SIG_0_0[MATCH65] = score; /* Finished calculating state MATCH65 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = SIG_1_0[MATCH65] + mat->b; /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = SIG_1_0[UNMATCHED_QUERY] + mat->u; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state UNMATCHED_QUERY */ temp = SlimDnaMatchBlock_SHATTER_SPECIAL(mat,i-1,j-0,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ SIG_0_0[UNMATCHED_QUERY] = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = SIG_0_1[UNMATCHED_QUERY] + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = SIG_0_1[UNMATCHED_TARGET] + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ SIG_0_0[UNMATCHED_TARGET] = score; /* state UNMATCHED_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > SlimDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) ) { SlimDnaMatchBlock_SHATTER_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state UNMATCHED_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_SlimDnaMatchBlock(dbsi,out,query,target,comp65,g,u,v,s,b) * * Descrip: This function makes a database search of SlimDnaMatchBlock * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp65 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: g [UNKN ] Undocumented argument [Score] * Arg: u [UNKN ] Undocumented argument [Score] * Arg: v [UNKN ] Undocumented argument [Score] * Arg: s [UNKN ] Undocumented argument [Score] * Arg: b [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_SlimDnaMatchBlock(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b) { if( out == NULL ) { warn("Passed in a null Hscore object into search_SlimDnaMatchBlock. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_SlimDnaMatchBlock. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for SlimDnaMatchBlock, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_SlimDnaMatchBlock(out,query,target ,comp65,g,u,v,s,b); case DBSearchImpl_Pthreads : warn("This matrix SlimDnaMatchBlock was not dyc compiled with thread support"); return SEARCH_ERROR; default : warn("database search implementation %s was not provided in the compiled dynamite file from SlimDnaMatchBlock",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: serial_search_SlimDnaMatchBlock(out,query,target,comp65,g,u,v,s,b) * * Descrip: This function makes a database search of SlimDnaMatchBlock * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp65 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: g [UNKN ] Undocumented argument [Score] * Arg: u [UNKN ] Undocumented argument [Score] * Arg: v [UNKN ] Undocumented argument [Score] * Arg: s [UNKN ] Undocumented argument [Score] * Arg: b [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_SlimDnaMatchBlock(Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b) { int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; /* No maximum length - allocated on-the-fly */ score = score_only_SlimDnaMatchBlock(query, target , comp65, g, u, v, s, b); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("SlimDnaMatchBlock search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_SlimDnaMatchBlock(query,target,comp65,g,u,v,s,b) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_SlimDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_SlimDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b) { int bestscore = NEGI; int i; int j; int k; SlimDnaMatchBlock * mat; mat = allocate_SlimDnaMatchBlock_only(query, target , comp65, g, u, v, s, b); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 3,2,2)) == NULL) { warn("Score only matrix for SlimDnaMatchBlock cannot be allocated, (asking for 1 by %d cells)",mat->leni*3); mat = free_SlimDnaMatchBlock(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) SlimDnaMatchBlock_VSMALL_MATRIX(mat,i,j,k) = NEGI; } SlimDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,START) = 0; SlimDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH65 */ /* setting first movement to score */ score = SlimDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = SlimDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_VSMALL_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = SlimDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = SlimDnaMatchBlock_VSMALL_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state UNMATCHED_QUERY */ temp = SlimDnaMatchBlock_VSMALL_SPECIAL(mat,i-1,j-0,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_VSMALL_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = SlimDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = SlimDnaMatchBlock_VSMALL_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_VSMALL_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* state UNMATCHED_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > SlimDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) ) { SlimDnaMatchBlock_VSMALL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state UNMATCHED_TARGET */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < SlimDnaMatchBlock_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = SlimDnaMatchBlock_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_SlimDnaMatchBlock(mat); return bestscore; } /* Function: PackAln_bestmemory_SlimDnaMatchBlock(query,target,comp65,g,u,v,s,b,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_SlimDnaMatchBlock * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_SlimDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; SlimDnaMatchBlock * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->seq->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_SlimDnaMatchBlock(query, target , comp65, g, u, v, s, b,dpri)) == NULL ) { warn("Unable to allocate large SlimDnaMatchBlock version"); return NULL; } calculate_dpenv_SlimDnaMatchBlock(mat,dpenv); out = PackAln_read_Expl_SlimDnaMatchBlock(mat); } else { mat = allocate_SlimDnaMatchBlock_only(query, target , comp65, g, u, v, s, b); calculate_shatter_SlimDnaMatchBlock(mat,dpenv); out = PackAln_read_Shatter_SlimDnaMatchBlock(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_SlimDnaMatchBlock(query, target , comp65, g, u, v, s, b)) == NULL ) { warn("Unable to allocate small SlimDnaMatchBlock version"); return NULL; } out = PackAln_calculate_Small_SlimDnaMatchBlock(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_SlimDnaMatchBlock(query, target , comp65, g, u, v, s, b,dpri)) == NULL ) { warn("Unable to allocate large SlimDnaMatchBlock version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_SlimDnaMatchBlock(mat); out = PackAln_read_Expl_SlimDnaMatchBlock(mat); } } } mat = free_SlimDnaMatchBlock(mat); return out; } /* Function: allocate_SlimDnaMatchBlock_only(query,target,comp65,g,u,v,s,b) * * Descrip: This function only allocates the SlimDnaMatchBlock structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [SlimDnaMatchBlock *] * */ SlimDnaMatchBlock * allocate_SlimDnaMatchBlock_only(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b) { SlimDnaMatchBlock * out; if((out= SlimDnaMatchBlock_alloc()) == NULL) { warn("Allocation of basic SlimDnaMatchBlock structure failed..."); return NULL; } out->query = query; out->target = target; out->comp65 = comp65; out->g = g; out->u = u; out->v = v; out->s = s; out->b = b; out->leni = query->seq->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_SlimDnaMatchBlock(query,target,comp65,g,u,v,s,b,dpri) * * Descrip: This function allocates the SlimDnaMatchBlock structure * and the basematrix area for explicit memory implementations * It calls /allocate_SlimDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [SlimDnaMatchBlock *] * */ SlimDnaMatchBlock * allocate_Expl_SlimDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b,DPRunImpl * dpri) { SlimDnaMatchBlock * out; out = allocate_SlimDnaMatchBlock_only(query, target , comp65, g, u, v, s, b); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*3,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix SlimDnaMatchBlock cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_SlimDnaMatchBlock(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_SlimDnaMatchBlock(out); return out; } /* Function: init_SlimDnaMatchBlock(mat) * * Descrip: This function initates SlimDnaMatchBlock matrix when in explicit mode * Called in /allocate_Expl_SlimDnaMatchBlock * * * Arg: mat [UNKN ] SlimDnaMatchBlock which contains explicit basematrix memory [SlimDnaMatchBlock *] * */ void init_SlimDnaMatchBlock(SlimDnaMatchBlock * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->seq->len;i++) { for(j= (-1);j<2;j++) { SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } } for(j= (-1);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } SlimDnaMatchBlock_EXPL_SPECIAL(mat,i,j,START) = 0; SlimDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_SlimDnaMatchBlock(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by SlimDnaMatchBlock * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * */ void recalculate_PackAln_SlimDnaMatchBlock(PackAln * pal,SlimDnaMatchBlock * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH65 : if( offi == 1 && offj == 1 && prev->state == MATCH65 ) { pau->score = (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == MATCH65 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 0 && prev->state == MATCH65 ) { pau->score = mat->g + (0); continue; } if( offi == 1 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) + (0); continue; } warn("In recaluclating PackAln with state MATCH65, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UNMATCHED_QUERY : if( offi == 1 && offj == 0 && prev->state == MATCH65 ) { pau->score = mat->b + (0); continue; } if( offi == 1 && offj == 0 && prev->state == UNMATCHED_QUERY ) { pau->score = mat->u + (0); continue; } if( offj == 0 && prev->state == (START+3) ) { pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state UNMATCHED_QUERY, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case UNMATCHED_TARGET : if( offi == 0 && offj == 1 && prev->state == UNMATCHED_QUERY ) { pau->score = mat->v + (0); continue; } if( offi == 0 && offj == 1 && prev->state == UNMATCHED_TARGET ) { pau->score = mat->u + (0); continue; } warn("In recaluclating PackAln with state UNMATCHED_TARGET, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+3) : if( offj == 0 && prev->state == UNMATCHED_TARGET ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = 0 + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define SlimDnaMatchBlock_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*3+state]) #define SlimDnaMatchBlock_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*3+state]) #define SlimDnaMatchBlock_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define SlimDnaMatchBlock_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*3 + state]) #define SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define SlimDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_SlimDnaMatchBlock(query,target,comp65,g,u,v,s,b) * * Descrip: This function allocates the SlimDnaMatchBlock structure * and the basematrix area for a small memory implementations * It calls /allocate_SlimDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [SlimDnaMatchBlock *] * */ #define SlimDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) SlimDnaMatchBlock * allocate_Small_SlimDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b) { SlimDnaMatchBlock * out; out = allocate_SlimDnaMatchBlock_only(query, target , comp65, g, u, v, s, b); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 3,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix SlimDnaMatchBlock cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_SlimDnaMatchBlock(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_SlimDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates an alignment for SlimDnaMatchBlock structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_SlimDnaMatchBlock * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_SlimDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for SlimDnaMatchBlock due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_SlimDnaMatchBlock(mat,dpenv); score = start_end_find_end_SlimDnaMatchBlock(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_SlimDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_SlimDnaMatchBlock(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == SlimDnaMatchBlock_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_SlimDnaMatchBlock(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 3; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_SlimDnaMatchBlock(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_SlimDnaMatchBlock(mat) * * Descrip: This function calculates an alignment for SlimDnaMatchBlock structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_SlimDnaMatchBlock * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_SlimDnaMatchBlock * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_SlimDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_SlimDnaMatchBlock(SlimDnaMatchBlock * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_SlimDnaMatchBlock(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_SlimDnaMatchBlock(mat); return out; } /* Function: AlnRangeSet_from_SlimDnaMatchBlock(mat) * * Descrip: This function reads off a start/end structure * for SlimDnaMatchBlock structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_SlimDnaMatchBlock * If you have not calculated the matrix use * /AlnRange_calculate_Small_SlimDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_SlimDnaMatchBlock(SlimDnaMatchBlock * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_SlimDnaMatchBlock"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_SlimDnaMatchBlock(mat,&jpos); state = END; while( (temp = AlnRange_build_SlimDnaMatchBlock(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_SlimDnaMatchBlock(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_SlimDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_SlimDnaMatchBlock"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_SlimDnaMatchBlock(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_SlimDnaMatchBlock alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = SlimDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_SlimDnaMatchBlock(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == SlimDnaMatchBlock_READ_OFF_ERROR) { warn("In AlnRange_build_SlimDnaMatchBlock alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = SlimDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_SlimDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_SlimDnaMatchBlock(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == SlimDnaMatchBlock_READ_OFF_ERROR) { warn("In SlimDnaMatchBlock hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In SlimDnaMatchBlock hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In SlimDnaMatchBlock hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_SlimDnaMatchBlock(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = SlimDnaMatchBlock_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In SlimDnaMatchBlock matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH65 : temp = cscore - ((mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET); } return SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65); } return SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65); } temp = cscore - (mat->g) - (0); if( temp == SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH65) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH65); } return SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH65); } temp = cscore - ((mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH65) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH65); } return SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH65); } warn("Major problem (!) - in SlimDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_QUERY : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->u) - (0); if( temp == SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,UNMATCHED_QUERY) ) { *reti = i - 1; *retj = j - 0; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY); } return SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,UNMATCHED_QUERY); } temp = cscore - (mat->b) - (0); if( temp == SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65); } return SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH65); } warn("Major problem (!) - in SlimDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_TARGET : temp = cscore - (mat->u) - (0); if( temp == SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_TARGET) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET); } return SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->v) - (0); if( temp == SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_QUERY) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY); } return SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i - 0,j - 1,UNMATCHED_QUERY); } warn("Major problem (!) - in SlimDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in SlimDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_SlimDnaMatchBlock(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_SlimDnaMatchBlock(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == SlimDnaMatchBlock_READ_OFF_ERROR) { warn("In special strip read SlimDnaMatchBlock, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read SlimDnaMatchBlock, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_SlimDnaMatchBlock(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = SlimDnaMatchBlock_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for SlimDnaMatchBlock, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In SlimDnaMatchBlock matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = SlimDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source UNMATCHED_TARGET is not a special */ default: warn("Major problem (!) - in SlimDnaMatchBlock special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_SlimDnaMatchBlock(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = SlimDnaMatchBlock_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In SlimDnaMatchBlock matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH65 : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ warn("Major problem (!) - in SlimDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_QUERY : temp = cscore - (0) - (0); if( temp == SlimDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - SlimDnaMatchBlock_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source UNMATCHED_QUERY is not a special, should not get here! */ /* Source MATCH65 is not a special, should not get here! */ warn("Major problem (!) - in SlimDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_TARGET : /* Source UNMATCHED_TARGET is not a special, should not get here! */ /* Source UNMATCHED_QUERY is not a special, should not get here! */ warn("Major problem (!) - in SlimDnaMatchBlock matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in SlimDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_SlimDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_SlimDnaMatchBlock(mat,starti,startj,stopi,stopj); SlimDnaMatchBlock_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH65) = NEGI; SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH65 */ /* setting first movement to score */ score = SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished calculating state UNMATCHED_TARGET */ } } return; } /* Function: init_hidden_SlimDnaMatchBlock(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,MATCH65) = NEGI; SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; SlimDnaMatchBlock_HIDDEN_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } } return; } /* Function: full_dc_SlimDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_SlimDnaMatchBlock * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_SlimDnaMatchBlock to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [SlimDnaMatchBlock *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_SlimDnaMatchBlock"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_SlimDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_SlimDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_SlimDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for SlimDnaMatchBlock, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_SlimDnaMatchBlock(mat,SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_SlimDnaMatchBlock(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_SlimDnaMatchBlock(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_SlimDnaMatchBlock(mat); SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_SlimDnaMatchBlock(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_SlimDnaMatchBlock(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_SlimDnaMatchBlock(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_SlimDnaMatchBlock(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = (-100); SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = (-100); SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = (-100); SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = (-100); SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = (-100); SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH65, pushing when j - offj <= mergej */ score = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); if( j - 1 <= mergej) { SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-1; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-1; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = MATCH65; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH65,k); } temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score) { score = temp; if( j - 1 <= mergej) { SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-0; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-1; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = MATCH65; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH65,k); } } temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score) { score = temp; if( j - 0 <= mergej) { SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-1; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-0; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = MATCH65; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); } } temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score) { score = temp; if( j - 1 <= mergej) { SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = i-1; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,1) = j-1; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,2) = UNMATCHED_TARGET; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,3) = i; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,4) = j; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,5) = MATCH65; } else { for(k=0;k<7;k++) SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = score; /* Finished with state MATCH65 */ /* For state UNMATCHED_QUERY, pushing when j - offj <= mergej */ score = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; if( j - 0 <= mergej) { SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = MATCH65; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); } temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score) { score = temp; if( j - 0 <= mergej) { SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = i-1; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,1) = j-0; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,2) = UNMATCHED_QUERY; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,3) = i; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,4) = j; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,5) = UNMATCHED_QUERY; } else { for(k=0;k<7;k++) SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED_QUERY,k); } } /* Add any movement independant score */ SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished with state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET, pushing when j - offj <= mergej */ score = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; if( j - 1 <= mergej) { SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = i-0; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,1) = j-1; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,2) = UNMATCHED_QUERY; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,3) = i; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,4) = j; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,5) = UNMATCHED_TARGET; } else { for(k=0;k<7;k++) SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_QUERY,k); } temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score) { score = temp; if( j - 1 <= mergej) { SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = i-0; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,1) = j-1; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,2) = UNMATCHED_TARGET; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,3) = i; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,4) = j; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,5) = UNMATCHED_TARGET; } else { for(k=0;k<7;k++) SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_TARGET,k); } } /* Add any movement independant score */ SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished with state UNMATCHED_TARGET */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_SlimDnaMatchBlock(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH65 */ /* setting first movement to score */ score = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH65,k); /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH65,k); } /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = score; for(k=0;k<7;k++) SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH65 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,k); /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED_QUERY,k); } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; for(k=0;k<7;k++) SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_QUERY,k); /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_TARGET,k); } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; for(k=0;k<7;k++) SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED_TARGET */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_SlimDnaMatchBlock(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH65 */ /* setting first movement to score */ score = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* Finished calculating state UNMATCHED_TARGET */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_SlimDnaMatchBlock(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * */ } void init_dc_SlimDnaMatchBlock(SlimDnaMatchBlock * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; for(k=0;k<7;k++) { SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = (-1); SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = (-1); SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = (-1); } } } return; } /* Function: start_end_find_end_SlimDnaMatchBlock(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [SlimDnaMatchBlock *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int * endj) { register int j; register int max; register int maxj; max = SlimDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( SlimDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = SlimDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_SlimDnaMatchBlock(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [SlimDnaMatchBlock] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_SlimDnaMatchBlock(SlimDnaMatchBlock *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->seq->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jcomp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s) + (0); /* assign local shadown pointer */ localsp = &(SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH65,0)); /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH65) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH65,0)); } /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->g +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,0)); } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH65) = score; for(k=0;k<7;k++) SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH65,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH65 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH65) + mat->b + (0); /* assign local shadown pointer */ localsp = &(SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH65,0)); /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,UNMATCHED_QUERY,0)); } /* From state START to state UNMATCHED_QUERY */ temp = SlimDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + 0 + (0); if( temp > score ) { score = temp; /* This state [START] is a special for UNMATCHED_QUERY... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= UNMATCHED_QUERY; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; for(k=0;k<7;k++) SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v + (0); /* assign local shadown pointer */ localsp = &(SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_QUERY,0)); /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,UNMATCHED_TARGET,0)); } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; for(k=0;k<7;k++) SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state UNMATCHED_TARGET is a source for special END */ temp = score + (0) + (0) ; if( temp > SlimDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { SlimDnaMatchBlock_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) SlimDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,k); SlimDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = SlimDnaMatchBlock_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,6); SlimDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; SlimDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; SlimDnaMatchBlock_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = UNMATCHED_TARGET; } /* Finished calculating state UNMATCHED_TARGET */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_SlimDnaMatchBlock(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * */ void init_start_end_linear_SlimDnaMatchBlock(SlimDnaMatchBlock * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iquery->seq->len;i++) { SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,MATCH65) = NEGI; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH65,0) = (-1); SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_QUERY,0) = (-1); SlimDnaMatchBlock_DC_SHADOW_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; SlimDnaMatchBlock_DC_SHADOW_MATRIX_SP(mat,i,j,UNMATCHED_TARGET,0) = (-1); } } for(j=(-1);jtarget->seq->len;j++) { SlimDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; SlimDnaMatchBlock_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; SlimDnaMatchBlock_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_SlimDnaMatchBlock(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_SlimDnaMatchBlock(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_SlimDnaMatchBlock(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MM65","MI65","UM","UI","END" }; /* Function: AlnConvertSet_SlimDnaMatchBlock(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "MM65","MI65","UI","UM","END" }; AlnConvertSet * AlnConvertSet_SlimDnaMatchBlock(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = MATCH65; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = MATCH65; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = MATCH65; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = MATCH65; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH65; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_QUERY; acu->state2 = UNMATCHED_QUERY; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = UNMATCHED_QUERY; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_QUERY; acu->state2 = UNMATCHED_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = UNMATCHED_TARGET; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = UNMATCHED_TARGET; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[4]; return out; } /* Function: PackAln_read_Expl_SlimDnaMatchBlock(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_SlimDnaMatchBlock(SlimDnaMatchBlock * mat) { SlimDnaMatchBlock_access_func_holder holder; holder.access_main = SlimDnaMatchBlock_explicit_access_main; holder.access_special = SlimDnaMatchBlock_explicit_access_special; return PackAln_read_generic_SlimDnaMatchBlock(mat,holder); } /* Function: SlimDnaMatchBlock_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int SlimDnaMatchBlock_explicit_access_main(SlimDnaMatchBlock * mat,int i,int j,int state) { return SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,state); } /* Function: SlimDnaMatchBlock_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int SlimDnaMatchBlock_explicit_access_special(SlimDnaMatchBlock * mat,int i,int j,int state) { return SlimDnaMatchBlock_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_SlimDnaMatchBlock(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: h [UNKN ] Undocumented argument [SlimDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,SlimDnaMatchBlock_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_SlimDnaMatchBlock(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in SlimDnaMatchBlock_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_SlimDnaMatchBlock(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_SlimDnaMatchBlock(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == SlimDnaMatchBlock_READ_OFF_ERROR || j == SlimDnaMatchBlock_READ_OFF_ERROR || state == SlimDnaMatchBlock_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in SlimDnaMatchBlock_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_SlimDnaMatchBlock(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [SlimDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int * ri,int * rj,int * state,boolean * isspecial,SlimDnaMatchBlock_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: SlimDnaMatchBlock_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void SlimDnaMatchBlock_debug_show_matrix(SlimDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->seq->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH65 %d\n",SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65)); fprintf(ofp,"State UNMATCHED_QUERY %d\n",SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY)); fprintf(ofp,"State UNMATCHED_TARGET %d\n",SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_SlimDnaMatchBlock(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [SlimDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,SlimDnaMatchBlock_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = SlimDnaMatchBlock_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->seq->len || j > mat->target->seq->len) { warn("In SlimDnaMatchBlock matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH65 : temp = cscore - ((mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET) ) { *reti = i - 1; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 1,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH65); } return (*h.access_main)(mat,i - 1,j - 0,MATCH65); } temp = cscore - (mat->g) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH65) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH65); } return (*h.access_main)(mat,i - 0,j - 1,MATCH65); } temp = cscore - ((mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s)) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH65) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH65); } return (*h.access_main)(mat,i - 1,j - 1,MATCH65); } warn("Major problem (!) - in SlimDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_QUERY : /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } } temp = cscore - (mat->u) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,UNMATCHED_QUERY) ) { *reti = i - 1; *retj = j - 0; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,UNMATCHED_QUERY); } return (*h.access_main)(mat,i - 1,j - 0,UNMATCHED_QUERY); } temp = cscore - (mat->b) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH65) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH65; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH65); } return (*h.access_main)(mat,i - 1,j - 0,MATCH65); } warn("Major problem (!) - in SlimDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); case UNMATCHED_TARGET : temp = cscore - (mat->u) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_TARGET) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_TARGET); } temp = cscore - (mat->v) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_QUERY) ) { *reti = i - 0; *retj = j - 1; *retstate = UNMATCHED_QUERY; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,UNMATCHED_QUERY); } return (*h.access_main)(mat,i - 0,j - 1,UNMATCHED_QUERY); } warn("Major problem (!) - in SlimDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in SlimDnaMatchBlock read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_SlimDnaMatchBlock(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [SlimDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,SlimDnaMatchBlock_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = SlimDnaMatchBlock_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In SlimDnaMatchBlock matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source UNMATCHED_TARGET is from main matrix */ for(i= mat->query->seq->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (0) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,UNMATCHED_TARGET) ) { *reti = i - 0; *retj = j - 0; *retstate = UNMATCHED_TARGET; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,UNMATCHED_TARGET); } return (*h.access_main)(mat,i - 0,j - 0,UNMATCHED_TARGET) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in SlimDnaMatchBlock read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_SlimDnaMatchBlock(mat) * * Descrip: This function calculates the SlimDnaMatchBlock matrix when in explicit mode * To allocate the matrix use /allocate_Expl_SlimDnaMatchBlock * * * Arg: mat [UNKN ] SlimDnaMatchBlock which contains explicit basematrix memory [SlimDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_SlimDnaMatchBlock(SlimDnaMatchBlock * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_SlimDnaMatchBlock, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("SlimDnaMatchBlock Matrix calculation: "); for(j=0;jcomp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state UNMATCHED_QUERY */ temp = SlimDnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-0,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* state UNMATCHED_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > SlimDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { SlimDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state UNMATCHED_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_SlimDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the SlimDnaMatchBlock matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] SlimDnaMatchBlock which contains explicit basematrix memory [SlimDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_SlimDnaMatchBlock, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; } } for(j=-1;jlenj;j++) { SlimDnaMatchBlock_EXPL_SPECIAL(mat,i,j,START) = 0; SlimDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("SlimDnaMatchBlock Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = NEGI; SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = NEGI; SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH65 */ /* setting first movement to score */ score = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,MATCH65) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->s); /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state MATCH65 to state MATCH65 */ temp = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->g; if( temp > score ) { score = temp; } /* From state UNMATCHED_TARGET to state MATCH65 */ temp = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-1,UNMATCHED_TARGET) + (mat->comp65->score[CSEQ_DNA_BASE(mat->query,i)][CSEQ_DNA_BASE(mat->target,j)]+mat->v); if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH65 */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,MATCH65) = score; /* Finished calculating state MATCH65 */ /* For state UNMATCHED_QUERY */ /* setting first movement to score */ score = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,MATCH65) + mat->b; /* From state UNMATCHED_QUERY to state UNMATCHED_QUERY */ temp = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-1,j-0,UNMATCHED_QUERY) + mat->u; if( temp > score ) { score = temp; } /* Has restricted position */ if( (i-1) == 0 && (j-0) == 0 ) { /* From state START to state UNMATCHED_QUERY */ temp = SlimDnaMatchBlock_EXPL_SPECIAL(mat,i-1,j-0,START) + 0; if( temp > score ) { score = temp; } } /* Ok - finished max calculation for UNMATCHED_QUERY */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_QUERY) = score; /* Finished calculating state UNMATCHED_QUERY */ /* For state UNMATCHED_TARGET */ /* setting first movement to score */ score = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_QUERY) + mat->v; /* From state UNMATCHED_TARGET to state UNMATCHED_TARGET */ temp = SlimDnaMatchBlock_EXPL_MATRIX(mat,i-0,j-1,UNMATCHED_TARGET) + mat->u; if( temp > score ) { score = temp; } /* Ok - finished max calculation for UNMATCHED_TARGET */ /* Add any movement independant score and put away */ SlimDnaMatchBlock_EXPL_MATRIX(mat,i,j,UNMATCHED_TARGET) = score; /* state UNMATCHED_TARGET is a source for special END */ /* Has restricted position */ if( i == mat->leni-1 && j == mat->lenj-1 ) { temp = score + (0) + (0) ; if( temp > SlimDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) ) { SlimDnaMatchBlock_EXPL_SPECIAL(mat,i,j,END) = temp; } } /* Finished calculating state UNMATCHED_TARGET */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: SlimDnaMatchBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SlimDnaMatchBlock *] * */ SlimDnaMatchBlock * SlimDnaMatchBlock_alloc(void) { SlimDnaMatchBlock * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SlimDnaMatchBlock *) ckalloc (sizeof(SlimDnaMatchBlock))) == NULL) { warn("SlimDnaMatchBlock_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_SlimDnaMatchBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SlimDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [SlimDnaMatchBlock *] * */ SlimDnaMatchBlock * free_SlimDnaMatchBlock(SlimDnaMatchBlock * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SlimDnaMatchBlock obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->comp65 is linked in */ /* obj->g is linked in */ /* obj->u is linked in */ /* obj->v is linked in */ /* obj->s is linked in */ /* obj->b is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/slimdba.h0000644000175000001440000005254610670453715015733 0ustar philippusers#ifndef DYNAMITEslimdbaHEADERFILE #define DYNAMITEslimdbaHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" struct Wise2_SlimDnaMatchBlock { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; ComplexSequence* query; ComplexSequence* target; DnaMatrix* comp65; Score g; Score u; Score v; Score s; Score b; } ; /* SlimDnaMatchBlock defined */ #ifndef DYNAMITE_DEFINED_SlimDnaMatchBlock typedef struct Wise2_SlimDnaMatchBlock Wise2_SlimDnaMatchBlock; #define SlimDnaMatchBlock Wise2_SlimDnaMatchBlock #define DYNAMITE_DEFINED_SlimDnaMatchBlock #endif struct Wise2_SlimDnaMatchBlock_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(SlimDnaMatchBlock*,int,int,int); int (*access_special)(SlimDnaMatchBlock*,int,int,int); } ; /* SlimDnaMatchBlock_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_SlimDnaMatchBlock_access_func_holder typedef struct Wise2_SlimDnaMatchBlock_access_func_holder Wise2_SlimDnaMatchBlock_access_func_holder; #define SlimDnaMatchBlock_access_func_holder Wise2_SlimDnaMatchBlock_access_func_holder #define DYNAMITE_DEFINED_SlimDnaMatchBlock_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_SlimDnaMatchBlock(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_SlimDnaMatchBlock(SlimDnaMatchBlock * mat); #define PackAln_read_Shatter_SlimDnaMatchBlock Wise2_PackAln_read_Shatter_SlimDnaMatchBlock /* Function: calculate_shatter_SlimDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the SlimDnaMatchBlock matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [SlimDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,DPEnvelope * dpenv); #define calculate_shatter_SlimDnaMatchBlock Wise2_calculate_shatter_SlimDnaMatchBlock /* Function: search_SlimDnaMatchBlock(dbsi,out,query,target,comp65,g,u,v,s,b) * * Descrip: This function makes a database search of SlimDnaMatchBlock * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp65 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: g [UNKN ] Undocumented argument [Score] * Arg: u [UNKN ] Undocumented argument [Score] * Arg: v [UNKN ] Undocumented argument [Score] * Arg: s [UNKN ] Undocumented argument [Score] * Arg: b [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_SlimDnaMatchBlock(DBSearchImpl * dbsi,Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b); #define search_SlimDnaMatchBlock Wise2_search_SlimDnaMatchBlock /* Function: serial_search_SlimDnaMatchBlock(out,query,target,comp65,g,u,v,s,b) * * Descrip: This function makes a database search of SlimDnaMatchBlock * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ComplexSequence*] * Arg: target [UNKN ] Undocumented argument [ComplexSequence*] * Arg: comp65 [UNKN ] Undocumented argument [DnaMatrix*] * Arg: g [UNKN ] Undocumented argument [Score] * Arg: u [UNKN ] Undocumented argument [Score] * Arg: v [UNKN ] Undocumented argument [Score] * Arg: s [UNKN ] Undocumented argument [Score] * Arg: b [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_SlimDnaMatchBlock(Hscore * out,ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b); #define serial_search_SlimDnaMatchBlock Wise2_serial_search_SlimDnaMatchBlock /* Function: PackAln_bestmemory_SlimDnaMatchBlock(query,target,comp65,g,u,v,s,b,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_SlimDnaMatchBlock * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_SlimDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_SlimDnaMatchBlock Wise2_PackAln_bestmemory_SlimDnaMatchBlock /* Function: allocate_Expl_SlimDnaMatchBlock(query,target,comp65,g,u,v,s,b,dpri) * * Descrip: This function allocates the SlimDnaMatchBlock structure * and the basematrix area for explicit memory implementations * It calls /allocate_SlimDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [SlimDnaMatchBlock *] * */ SlimDnaMatchBlock * Wise2_allocate_Expl_SlimDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b,DPRunImpl * dpri); #define allocate_Expl_SlimDnaMatchBlock Wise2_allocate_Expl_SlimDnaMatchBlock /* Function: recalculate_PackAln_SlimDnaMatchBlock(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by SlimDnaMatchBlock * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * */ void Wise2_recalculate_PackAln_SlimDnaMatchBlock(PackAln * pal,SlimDnaMatchBlock * mat); #define recalculate_PackAln_SlimDnaMatchBlock Wise2_recalculate_PackAln_SlimDnaMatchBlock /* Function: allocate_Small_SlimDnaMatchBlock(query,target,comp65,g,u,v,s,b) * * Descrip: This function allocates the SlimDnaMatchBlock structure * and the basematrix area for a small memory implementations * It calls /allocate_SlimDnaMatchBlock_only * * * Arg: query [UNKN ] query data structure [ComplexSequence*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: comp65 [UNKN ] Resource [DnaMatrix*] * Arg: g [UNKN ] Resource [Score] * Arg: u [UNKN ] Resource [Score] * Arg: v [UNKN ] Resource [Score] * Arg: s [UNKN ] Resource [Score] * Arg: b [UNKN ] Resource [Score] * * Return [UNKN ] Undocumented return value [SlimDnaMatchBlock *] * */ SlimDnaMatchBlock * Wise2_allocate_Small_SlimDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b); #define allocate_Small_SlimDnaMatchBlock Wise2_allocate_Small_SlimDnaMatchBlock /* Function: PackAln_calculate_Small_SlimDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates an alignment for SlimDnaMatchBlock structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_SlimDnaMatchBlock * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_SlimDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_SlimDnaMatchBlock Wise2_PackAln_calculate_Small_SlimDnaMatchBlock /* Function: AlnRangeSet_calculate_Small_SlimDnaMatchBlock(mat) * * Descrip: This function calculates an alignment for SlimDnaMatchBlock structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_SlimDnaMatchBlock * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_SlimDnaMatchBlock * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_SlimDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_SlimDnaMatchBlock(SlimDnaMatchBlock * mat); #define AlnRangeSet_calculate_Small_SlimDnaMatchBlock Wise2_AlnRangeSet_calculate_Small_SlimDnaMatchBlock /* Function: AlnRangeSet_from_SlimDnaMatchBlock(mat) * * Descrip: This function reads off a start/end structure * for SlimDnaMatchBlock structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_SlimDnaMatchBlock * If you have not calculated the matrix use * /AlnRange_calculate_Small_SlimDnaMatchBlock * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_SlimDnaMatchBlock(SlimDnaMatchBlock * mat); #define AlnRangeSet_from_SlimDnaMatchBlock Wise2_AlnRangeSet_from_SlimDnaMatchBlock /* Function: convert_PackAln_to_AlnBlock_SlimDnaMatchBlock(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_SlimDnaMatchBlock(PackAln * pal); #define convert_PackAln_to_AlnBlock_SlimDnaMatchBlock Wise2_convert_PackAln_to_AlnBlock_SlimDnaMatchBlock /* Function: PackAln_read_Expl_SlimDnaMatchBlock(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_SlimDnaMatchBlock(SlimDnaMatchBlock * mat); #define PackAln_read_Expl_SlimDnaMatchBlock Wise2_PackAln_read_Expl_SlimDnaMatchBlock /* Function: PackAln_read_generic_SlimDnaMatchBlock(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [SlimDnaMatchBlock *] * Arg: h [UNKN ] Undocumented argument [SlimDnaMatchBlock_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,SlimDnaMatchBlock_access_func_holder h); #define PackAln_read_generic_SlimDnaMatchBlock Wise2_PackAln_read_generic_SlimDnaMatchBlock /* Function: calculate_SlimDnaMatchBlock(mat) * * Descrip: This function calculates the SlimDnaMatchBlock matrix when in explicit mode * To allocate the matrix use /allocate_Expl_SlimDnaMatchBlock * * * Arg: mat [UNKN ] SlimDnaMatchBlock which contains explicit basematrix memory [SlimDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_SlimDnaMatchBlock(SlimDnaMatchBlock * mat); #define calculate_SlimDnaMatchBlock Wise2_calculate_SlimDnaMatchBlock /* Function: calculate_dpenv_SlimDnaMatchBlock(mat,dpenv) * * Descrip: This function calculates the SlimDnaMatchBlock matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] SlimDnaMatchBlock which contains explicit basematrix memory [SlimDnaMatchBlock *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,DPEnvelope * dpenv); #define calculate_dpenv_SlimDnaMatchBlock Wise2_calculate_dpenv_SlimDnaMatchBlock /* Function: SlimDnaMatchBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SlimDnaMatchBlock *] * */ SlimDnaMatchBlock * Wise2_SlimDnaMatchBlock_alloc(void); #define SlimDnaMatchBlock_alloc Wise2_SlimDnaMatchBlock_alloc /* Function: free_SlimDnaMatchBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SlimDnaMatchBlock *] * * Return [UNKN ] Undocumented return value [SlimDnaMatchBlock *] * */ SlimDnaMatchBlock * Wise2_free_SlimDnaMatchBlock(SlimDnaMatchBlock * obj); #define free_SlimDnaMatchBlock Wise2_free_SlimDnaMatchBlock /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_SlimDnaMatchBlock_shatter_access_main(SlimDnaMatchBlock * mat,int i,int j,int state); #define SlimDnaMatchBlock_shatter_access_main Wise2_SlimDnaMatchBlock_shatter_access_main int Wise2_SlimDnaMatchBlock_shatter_access_special(SlimDnaMatchBlock * mat,int i,int j,int state); #define SlimDnaMatchBlock_shatter_access_special Wise2_SlimDnaMatchBlock_shatter_access_special int Wise2_score_only_SlimDnaMatchBlock(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b); #define score_only_SlimDnaMatchBlock Wise2_score_only_SlimDnaMatchBlock SlimDnaMatchBlock * Wise2_allocate_SlimDnaMatchBlock_only(ComplexSequence* query,ComplexSequence* target ,DnaMatrix* comp65,Score g,Score u,Score v,Score s,Score b); #define allocate_SlimDnaMatchBlock_only Wise2_allocate_SlimDnaMatchBlock_only void Wise2_init_SlimDnaMatchBlock(SlimDnaMatchBlock * mat); #define init_SlimDnaMatchBlock Wise2_init_SlimDnaMatchBlock AlnRange * Wise2_AlnRange_build_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_SlimDnaMatchBlock Wise2_AlnRange_build_SlimDnaMatchBlock boolean Wise2_read_hidden_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_SlimDnaMatchBlock Wise2_read_hidden_SlimDnaMatchBlock int Wise2_max_hidden_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_SlimDnaMatchBlock Wise2_max_hidden_SlimDnaMatchBlock boolean Wise2_read_special_strip_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_SlimDnaMatchBlock Wise2_read_special_strip_SlimDnaMatchBlock int Wise2_max_special_strip_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_SlimDnaMatchBlock Wise2_max_special_strip_SlimDnaMatchBlock int Wise2_max_matrix_to_special_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_SlimDnaMatchBlock Wise2_max_matrix_to_special_SlimDnaMatchBlock void Wise2_calculate_hidden_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_SlimDnaMatchBlock Wise2_calculate_hidden_SlimDnaMatchBlock void Wise2_init_hidden_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_SlimDnaMatchBlock Wise2_init_hidden_SlimDnaMatchBlock boolean Wise2_full_dc_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_SlimDnaMatchBlock Wise2_full_dc_SlimDnaMatchBlock boolean Wise2_do_dc_single_pass_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_SlimDnaMatchBlock Wise2_do_dc_single_pass_SlimDnaMatchBlock void Wise2_push_dc_at_merge_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_SlimDnaMatchBlock Wise2_push_dc_at_merge_SlimDnaMatchBlock void Wise2_follow_on_dc_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_SlimDnaMatchBlock Wise2_follow_on_dc_SlimDnaMatchBlock void Wise2_run_up_dc_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_SlimDnaMatchBlock Wise2_run_up_dc_SlimDnaMatchBlock void Wise2_init_dc_SlimDnaMatchBlock(SlimDnaMatchBlock * mat); #define init_dc_SlimDnaMatchBlock Wise2_init_dc_SlimDnaMatchBlock int Wise2_start_end_find_end_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int * endj); #define start_end_find_end_SlimDnaMatchBlock Wise2_start_end_find_end_SlimDnaMatchBlock boolean Wise2_dc_optimised_start_end_calc_SlimDnaMatchBlock(SlimDnaMatchBlock *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_SlimDnaMatchBlock Wise2_dc_optimised_start_end_calc_SlimDnaMatchBlock void Wise2_init_start_end_linear_SlimDnaMatchBlock(SlimDnaMatchBlock * mat); #define init_start_end_linear_SlimDnaMatchBlock Wise2_init_start_end_linear_SlimDnaMatchBlock AlnConvertSet * Wise2_AlnConvertSet_SlimDnaMatchBlock(void); #define AlnConvertSet_SlimDnaMatchBlock Wise2_AlnConvertSet_SlimDnaMatchBlock int Wise2_SlimDnaMatchBlock_explicit_access_main(SlimDnaMatchBlock * mat,int i,int j,int state); #define SlimDnaMatchBlock_explicit_access_main Wise2_SlimDnaMatchBlock_explicit_access_main int Wise2_SlimDnaMatchBlock_explicit_access_special(SlimDnaMatchBlock * mat,int i,int j,int state); #define SlimDnaMatchBlock_explicit_access_special Wise2_SlimDnaMatchBlock_explicit_access_special int Wise2_find_end_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int * ri,int * rj,int * state,boolean * isspecial,SlimDnaMatchBlock_access_func_holder h); #define find_end_SlimDnaMatchBlock Wise2_find_end_SlimDnaMatchBlock void Wise2_SlimDnaMatchBlock_debug_show_matrix(SlimDnaMatchBlock * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define SlimDnaMatchBlock_debug_show_matrix Wise2_SlimDnaMatchBlock_debug_show_matrix int Wise2_max_calc_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,SlimDnaMatchBlock_access_func_holder h); #define max_calc_SlimDnaMatchBlock Wise2_max_calc_SlimDnaMatchBlock int Wise2_max_calc_special_SlimDnaMatchBlock(SlimDnaMatchBlock * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,SlimDnaMatchBlock_access_func_holder h); #define max_calc_special_SlimDnaMatchBlock Wise2_max_calc_special_SlimDnaMatchBlock #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/threestatedb_api.h0000644000175000001440000001241710670453715017620 0ustar philippusers /* Functions that create, manipulate or act on ThreeStateDB * * Wise2_indexed_ThreeStateModel_ThreeStateDB * Wise2_new_proteindb_ThreeStateDB * Wise2_new_PfamHmmer1DB_ThreeStateDB * Wise2_new_single_ThreeStateDB * Wise2_hard_link_ThreeStateDB * Wise2_ThreeStateDB_alloc * Wise2_replace_dbtype_ThreeStateDB * Wise2_access_dbtype_ThreeStateDB * Wise2_replace_filename_ThreeStateDB * Wise2_access_filename_ThreeStateDB * Wise2_free_ThreeStateDB [destructor] * */ /* API for object ThreeStateDB */ /* Function: Wise2_indexed_ThreeStateModel_ThreeStateDB(mdb,en) * * Descrip: Retrieves a model from a database which has been opened * for indexing by /open_for_indexing_ThreeStateDB * * The index information comes from the dataentry which should * have been from a search of the ThreeStateDB. * * * Arg: mdb database where this is indexed [Wise2_ThreeStateDB *] * Arg: en dataentry to pull the model from [Wise2_DataEntry *] * * Returns Undocumented return value [Wise2_ThreeStateModel *] * */ Wise2_ThreeStateModel * Wise2_indexed_ThreeStateModel_ThreeStateDB( Wise2_ThreeStateDB * mdb,Wise2_DataEntry * en); /* Function: Wise2_new_proteindb_ThreeStateDB(sdb,comp,gap,ext) * * Descrip: makes a new ThreeStateDB from a * sequencedb (better be protein!) * * * * Arg: sdb sequence database to use [Wise2_SequenceDB *] * Arg: comp comparison matrix to use [Wise2_CompMat *] * Arg: gap gap open penalty [int] * Arg: ext gap extensions penalty [int] * * Returns Undocumented return value [Wise2_ThreeStateDB *] * */ Wise2_ThreeStateDB * Wise2_new_proteindb_ThreeStateDB( Wise2_SequenceDB * sdb,Wise2_CompMat * comp,int gap,int ext); /* Function: Wise2_new_PfamHmmer1DB_ThreeStateDB(dirname) * * Descrip: Makes a new PfamHmmer1DB from a filename * indicating the directory * * * Arg: dirname Undocumented argument [char *] * * Returns Undocumented return value [Wise2_ThreeStateDB *] * */ Wise2_ThreeStateDB * Wise2_new_PfamHmmer1DB_ThreeStateDB( char * dirname); /* Function: Wise2_new_single_ThreeStateDB(tsm,rm) * * Descrip: Making a new ThreeStateDB from a single * model * * * * Arg: tsm a single ThreeStateModel [Wise2_ThreeStateModel *] * Arg: rm random model to be used in comparisons.. [Wise2_RandomModel *] * * Returns Undocumented return value [Wise2_ThreeStateDB *] * */ Wise2_ThreeStateDB * Wise2_new_single_ThreeStateDB( Wise2_ThreeStateModel * tsm,Wise2_RandomModel * rm); /* Function: Wise2_hard_link_ThreeStateDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_ThreeStateDB *] * * Returns Undocumented return value [Wise2_ThreeStateDB *] * */ Wise2_ThreeStateDB * Wise2_hard_link_ThreeStateDB( Wise2_ThreeStateDB * obj); /* Function: Wise2_ThreeStateDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_ThreeStateDB *] * */ Wise2_ThreeStateDB * Wise2_ThreeStateDB_alloc(); /* Function: Wise2_replace_dbtype_ThreeStateDB(obj,dbtype) * * Descrip: Replace member variable dbtype * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateDB *] * Arg: dbtype New value of the variable [int] * * Returns member variable dbtype [boolean] * */ boolean Wise2_replace_dbtype_ThreeStateDB( Wise2_ThreeStateDB * obj,int dbtype); /* Function: Wise2_access_dbtype_ThreeStateDB(obj) * * Descrip: Access member variable dbtype * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateDB *] * * Returns member variable dbtype [int] * */ int Wise2_access_dbtype_ThreeStateDB( Wise2_ThreeStateDB * obj); /* Function: Wise2_replace_filename_ThreeStateDB(obj,filename) * * Descrip: Replace member variable filename * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateDB *] * Arg: filename New value of the variable [char *] * * Returns member variable filename [boolean] * */ boolean Wise2_replace_filename_ThreeStateDB( Wise2_ThreeStateDB * obj,char * filename); /* Function: Wise2_access_filename_ThreeStateDB(obj) * * Descrip: Access member variable filename * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ThreeStateDB *] * * Returns member variable filename [char *] * */ char * Wise2_access_filename_ThreeStateDB( Wise2_ThreeStateDB * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_ThreeStateDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_ThreeStateDB *] * * Returns Undocumented return value [Wise2_ThreeStateDB *] * */ Wise2_ThreeStateDB * Wise2_free_ThreeStateDB( Wise2_ThreeStateDB * obj); wise-2.4.1/src/models/threestatedb_api.t0000644000175000001440000000006710670453715017632 0ustar philippuserstypedef struct Wise2_ThreeStateDB Wise2_ThreeStateDB; wise-2.4.1/src/models/threestatedb.c0000644000175000001440000005256410670453715016771 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "threestatedb.h" /* Function: open_for_indexing_ThreeStateDB(mdb) * * Descrip: opens database ready for calls to * /indexed_ThreeStateModel_ThreeStateDB * * * * Arg: mdb [UNKN ] database to open for index calls [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 92 "threestatedb.dy" boolean open_for_indexing_ThreeStateDB(ThreeStateDB * mdb) { switch(mdb->dbtype) { case TSMDB_SINGLE : return TRUE; case TSMDB_HMMER1PFAM : return TRUE; /* name is the index! */ case TSMDB_PROTEIN : return TRUE; /* sequence db's don't need opening for indexing */ case TSMDB_GENERIC : return ((*mdb->open_index_generic)(mdb)); default : warn("Unknown threestatemodel db type."); return FALSE; } } /* Function: close_for_indexing_ThreeStateDB(mdb) * * Descrip: closes an indexable database * * * Arg: mdb [UNKN ] Undocumented argument [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 113 "threestatedb.dy" boolean close_for_indexing_ThreeStateDB(ThreeStateDB * mdb) { switch(mdb->dbtype) { case TSMDB_GENERIC : return ((*mdb->close_index_generic)(mdb)); default : return TRUE; } } /* Function: set_search_type_ThreeStateDB(tdb,type) * * Descrip: Set the search type of this threestatedb... * * * Arg: tdb [UNKN ] Undocumented argument [ThreeStateDB *] * Arg: type [UNKN ] to set can be any of the modes found in threestatemodel [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 128 "threestatedb.dy" boolean set_search_type_ThreeStateDB(ThreeStateDB * tdb,char * type) { int ret; ret = threestatemodel_mode_from_string(type); if( ret == TSM_unknown ) { /* warning already issued */ return FALSE; } tdb->type = ret; return TRUE; } /* Function: indexed_ThreeStateModel_ThreeStateDB(mdb,en) * * Descrip: Retrieves a model from a database which has been opened * for indexing by /open_for_indexing_ThreeStateDB * * The index information comes from the dataentry which should * have been from a search of the ThreeStateDB. * * * Arg: mdb [UNKN ] database where this is indexed [ThreeStateDB *] * Arg: en [UNKN ] dataentry to pull the model from [DataEntry *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 156 "threestatedb.dy" ThreeStateModel * indexed_ThreeStateModel_ThreeStateDB(ThreeStateDB * mdb,DataEntry * en) { Sequence * seq; Protein * pro; ThreeStateModel * tsm; switch(mdb->dbtype) { case TSMDB_SINGLE : return hard_link_ThreeStateModel(mdb->single); case TSMDB_HMMER1PFAM : tsm = ThreeStateModel_from_name_PfamHmmer1DB(mdb->phdb,en->name); set_startend_policy_ThreeStateModel(tsm,mdb->type,30,0.2); return tsm; case TSMDB_PROTEIN : seq = get_Sequence_from_SequenceDB(mdb->sdb,en); if( seq == NULL ) { warn("could not retrieve %s as a sequence from database",en->name); return NULL; } pro = Protein_from_Sequence(seq); if( pro == NULL ) { warn("Could not convert sequence to a protein. Exiting!"); return NULL; } /* convert protein to threestatemodel */ tsm = ThreeStateModel_from_half_bit_Sequence(pro,mdb->comp,mdb->rm,mdb->gap,mdb->ext); if( tsm == NULL ) { warn("Could not convert protein to threestatemode. Exiting!"); free_Protein(pro); return NULL; } free_Protein(pro); /* DB status already set by seqdb */ return tsm; case TSMDB_GENERIC : tsm = ((*mdb->index_generic)(mdb,en)); if( tsm == NULL ) { return NULL; } /* fprintf(stdout,"Setting %d as policy\n",mdb->type); */ set_startend_policy_ThreeStateModel(tsm,mdb->type,30,0.2); return tsm; default : warn("Unknown threestatedb type"); return NULL; } warn("Should never get here - in threestatedb reload!"); return NULL; } /* Function: new_proteindb_ThreeStateDB(sdb,comp,gap,ext) * * Descrip: makes a new ThreeStateDB from a * sequencedb (better be protein!) * * * * Arg: sdb [READ ] sequence database to use [SequenceDB *] * Arg: comp [READ ] comparison matrix to use [CompMat *] * Arg: gap [READ ] gap open penalty [int] * Arg: ext [READ ] gap extensions penalty [int] * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ # line 229 "threestatedb.dy" ThreeStateDB * new_proteindb_ThreeStateDB(SequenceDB * sdb,CompMat * comp,int gap,int ext) { ThreeStateDB * out; out = ThreeStateDB_alloc(); out->sdb = hard_link_SequenceDB(sdb); out->comp = hard_link_CompMat(comp); out->gap = gap; out->ext = ext; out->rm = default_RandomModel(); out->dbtype = TSMDB_PROTEIN; return out; } /* Function: new_single_ThreeStateDB(tsm,rm) * * Descrip: Making a new ThreeStateDB from a single * model * * * * Arg: tsm [READ ] a single ThreeStateModel [ThreeStateModel *] * Arg: rm [READ ] random model to be used in comparisons.. [RandomModel *] * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ # line 252 "threestatedb.dy" ThreeStateDB * new_single_ThreeStateDB(ThreeStateModel * tsm,RandomModel * rm) { ThreeStateDB * out; out = ThreeStateDB_alloc(); out->single = hard_link_ThreeStateModel(tsm); if( tsm->rm == NULL ) out->rm = hard_link_RandomModel(rm); else out->rm = hard_link_RandomModel(tsm->rm); out->dbtype = TSMDB_SINGLE; return out; } /* Function: new_PfamHmmer1DB_ThreeStateDB(dirname) * * Descrip: Makes a new PfamHmmer1DB from a filename * indicating the directory * * * Arg: dirname [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ # line 271 "threestatedb.dy" ThreeStateDB * new_PfamHmmer1DB_ThreeStateDB(char * dirname) { ThreeStateDB * out; out = ThreeStateDB_alloc(); out->phdb = PfamHmmer1DB_from_dirname(dirname); out->dbtype = TSMDB_HMMER1PFAM; return out; } /* Function: dataentry_add_ThreeStateDB(de,tss,mdb) * * Descrip: This function adds the internal entry information * (eg indexing point) into the dataentry * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: tss [UNKN ] Undocumented argument [ThreeStateScore *] * Arg: mdb [UNKN ] Undocumented argument [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 288 "threestatedb.dy" boolean dataentry_add_ThreeStateDB(DataEntry * de,ThreeStateScore * tss,ThreeStateDB * mdb) { switch(mdb->dbtype) { case TSMDB_SINGLE : de->name = stringalloc(mdb->single->name); return TRUE; case TSMDB_HMMER1PFAM : if( tss == NULL ) { } else { de->name = stringalloc(tss->name); } return TRUE; case TSMDB_PROTEIN : add_SequenceDB_info_DataEntry(mdb->sdb,de); return TRUE; case TSMDB_GENERIC : if( (*mdb->dataentry_add)(mdb,de) == FALSE ) { warn("Could not add dataentry info to the entry %s",tss->name); return FALSE; } else { return TRUE; } default : warn("Unknown threestatedb type"); return FALSE; } return TRUE; } /* Function: open_ThreeStateDB(mdb) * * Descrip: Open function for ThreeStateDB. * An internal for this file but also * used by, for example, GeneWiseDB that * wants to get at the underlying models, * not the log-odds. * * * Arg: mdb [UNKN ] Undocumented argument [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 329 "threestatedb.dy" boolean open_ThreeStateDB(ThreeStateDB * mdb) { int ret; int return_status; ThreeStateModel * temp; int count; mdb->current_no = 0; switch( mdb->dbtype ) { case TSMDB_SINGLE : return TRUE; /* should be fine! */ case TSMDB_HMMER1PFAM : if( mdb->phdb == NULL ) { warn("No hmmer1 db to open for threestatedb!"); return FALSE; } mdb->phdb->cur = 0; break; case TSMDB_PROTEIN : if( mdb->sdb == NULL ) { warn("Attempting to open a protein tsm with no sequence db!"); return FALSE; } mdb->seq_cache = init_SequenceDB(mdb->sdb,&ret); if( ret == DB_RETURN_ERROR ) { return FALSE; } if( ret == DB_RETURN_END ) { warn("Due to some bad coding, can't cope with single protein databases in tsmdbs. oooops!"); } break; case TSMDB_GENERIC : ((*mdb->open_generic)(mdb)); break; default : warn("Got an unrecognisable tsm db type in opening tsm %d",mdb->dbtype); return FALSE; } if( mdb->hmm_model_start != -1 && mdb->hmm_model_end != -1 ) { for(count=0;counthmm_model_start;count++) { temp = read_TSM_ThreeStateDB(mdb,&return_status); free_ThreeStateModel(temp); } } return TRUE; } /* Function: read_TSM_ThreeStateDB(mdb,return_status) * * Descrip: Reads a threestatemodel out from the * database. People will probably want the * ThreeStateScore *not* the model, but some * systems will want the model. * * * Arg: mdb [UNKN ] Undocumented argument [ThreeStateDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ # line 388 "threestatedb.dy" ThreeStateModel * read_TSM_ThreeStateDB(ThreeStateDB * mdb,int * return_status) { ThreeStateModel * tsm; Protein * pro; Sequence * seq; if( mdb->hmm_model_end != -1 && mdb->current_no == mdb->hmm_model_end ) { *return_status = DB_RETURN_END; return NULL; } mdb->current_no++; switch( mdb->dbtype ) { case TSMDB_SINGLE : *return_status = DB_RETURN_END; if( mdb->single->rm == NULL ) { warn("Threestate model without an internal random model!"); mdb->single->rm = hard_link_RandomModel(mdb->rm); } return hard_link_ThreeStateModel(mdb->single); case TSMDB_HMMER1PFAM : tsm= read_next_TSM_PfamHmmer1DB(mdb->phdb,return_status); set_startend_policy_ThreeStateModel(tsm,mdb->type,30,0.2); return tsm; case TSMDB_PROTEIN : if( mdb->seq_cache != NULL ) { /* just after an open. Should actually use this sequence, and flush the cache */ pro = Protein_from_Sequence(hard_link_Sequence(mdb->seq_cache)); mdb->seq_cache = free_Sequence(mdb->seq_cache); *return_status = DB_RETURN_OK; } else { /* reload a sequence from a database */ seq = reload_SequenceDB(NULL,mdb->sdb,return_status); /* exit now if error */ if( *return_status == DB_RETURN_ERROR ) { return NULL; /* might have leaked memory. Ugh! */ } /* if we get NULL... for the moment, silent flag end */ if( seq == NULL ) { *return_status = DB_RETURN_END; return NULL; } pro = Protein_from_Sequence(seq); } if( pro == NULL ) { warn("Could not convert sequence to a protein. Exiting!"); *return_status = DB_RETURN_ERROR; return NULL; } /* convert protein to threestatemodel */ tsm = ThreeStateModel_from_half_bit_Sequence(pro,mdb->comp,mdb->rm,mdb->gap,mdb->ext); if( tsm == NULL ) { warn("Could not convert protein to threestatemode. Exiting!"); free_Protein(pro); *return_status = DB_RETURN_ERROR; return NULL; } /* DB status already set by seqdb */ return tsm; case TSMDB_GENERIC : tsm = ((*mdb->reload_generic)(mdb,return_status)); if( tsm == NULL ) { return NULL; /* means end of database */ } set_startend_policy_ThreeStateModel(tsm,mdb->type,30,0.2); return tsm; default : warn("Got an unrecognisable tsm db type in read-load"); return NULL; } } /* Function: init_ThreeStateDB(mdb,return_status) * * Descrip: Init function for ThreeStateDB * * Is going to open file, read first model, complain if * NULL, and convert to a score system. * * * Arg: mdb [RW ] Model database [ThreeStateDB *] * Arg: return_status [WRITE] return from database.h system [int *] * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ # line 486 "threestatedb.dy" ThreeStateScore * init_ThreeStateDB(ThreeStateDB * mdb,int * return_status) { ThreeStateModel * tsm; ThreeStateScore * tss; if( open_ThreeStateDB(mdb) == FALSE) { warn("Could not open ThreeStateDB, hence could not init it!"); *return_status = DB_RETURN_ERROR; return NULL; } tsm = read_TSM_ThreeStateDB(mdb,return_status); if( *return_status == DB_RETURN_ERROR) return NULL; set_startend_policy_ThreeStateModel(tsm,mdb->type,30,0.2); fold_RandomModel_into_ThreeStateModel(tsm,mdb->rm); tss = ThreeStateScore_from_ThreeStateModel(tsm); free_ThreeStateModel(tsm); *return_status = DB_RETURN_OK; return tss; } /* Function: reload_ThreeStateDB(prev,tss,mdb,return_status) * * Descrip: reloads the ThreeStateDB. * * Frees the previous score system (could recycle memory). * Reads database. calls END if gets NULL from read_HMF_ThreeStateModel * * * Arg: prev [UNKN ] Undocumented argument [ThreeStateScore *] * Arg: tss [UNKN ] the previous score system [NullString] * Arg: mdb [UNKN ] model database system [ThreeStateDB *] * Arg: return_status [WRITE] return from database.h system [int *] * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ # line 525 "threestatedb.dy" ThreeStateScore * reload_ThreeStateDB(ThreeStateScore * prev,ThreeStateDB * mdb,int * return_status) { ThreeStateModel * tsm; ThreeStateScore * tss; free_ThreeStateScore(prev); if( mdb->dbtype == TSMDB_SINGLE ) { *return_status = DB_RETURN_END; return NULL; } tsm = read_TSM_ThreeStateDB(mdb,return_status); if( *return_status != DB_RETURN_OK) return NULL; set_startend_policy_ThreeStateModel(tsm,mdb->type,30,0.2); fold_RandomModel_into_ThreeStateModel(tsm,mdb->rm); tss = ThreeStateScore_from_ThreeStateModel(tsm); free_ThreeStateModel(tsm); *return_status = DB_RETURN_OK; return tss; } /* Function: close_ThreeStateDB(prev,mdb) * * Descrip: closes ThreeStateDB * * At the moment, only needs to free previous * and close the file * * * Arg: prev [UNKN ] the last ThreeStateScore to be freed [ThreeStateScore *] * Arg: mdb [UNKN ] Model database [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 566 "threestatedb.dy" boolean close_ThreeStateDB(ThreeStateScore * prev,ThreeStateDB * mdb) { if( prev != NULL ) free_ThreeStateScore(prev); if( mdb == NULL ) { warn("Trying to close a NULL threestatedb - considering this an error!"); return FALSE; } switch(mdb->dbtype) { case TSMDB_SINGLE : return TRUE; case TSMDB_HMMER1PFAM : fclose(mdb->current_file); mdb->current_file = NULL; return TRUE; /* name is the index! */ case TSMDB_PROTEIN : close_SequenceDB(NULL,mdb->sdb); return TRUE; /* sequence db's don't need opening for indexing */ case TSMDB_GENERIC : return ((*mdb->close_index_generic)(mdb)); default : warn("Unknown threestatemodel db type."); return FALSE; } warn("Should never get here!"); return FALSE; } # line 583 "threestatedb.c" /* Function: hard_link_ThreeStateDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ ThreeStateDB * hard_link_ThreeStateDB(ThreeStateDB * obj) { if( obj == NULL ) { warn("Trying to hard link to a ThreeStateDB object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ThreeStateDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ ThreeStateDB * ThreeStateDB_alloc(void) { ThreeStateDB * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ThreeStateDB *) ckalloc (sizeof(ThreeStateDB))) == NULL) { warn("ThreeStateDB_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->dbtype = TSMDB_UNKNOWN; out->filename = NULL; out->type = TSM_default; out->rm = NULL; out->byte_position = 0; out->single = NULL; out->phdb = NULL; out->sdb = NULL; out->comp = NULL; out->gap = 0; out->ext = 0; out->seq_cache = NULL; out->reload_generic = NULL; out->open_generic = NULL; out->close_generic = NULL; out->dataentry_add = NULL; out->open_index_generic = NULL; out->index_generic = NULL; out->close_index_generic = NULL; out->hmm_model_start = -1; out->hmm_model_end = -1; out->current_no = 0; return out; } /* Function: free_ThreeStateDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ ThreeStateDB * free_ThreeStateDB(ThreeStateDB * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ThreeStateDB obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->filename != NULL) ckfree(obj->filename); /* obj->current_file is linked in */ if( obj->rm != NULL) free_RandomModel(obj->rm); if( obj->single != NULL) free_ThreeStateModel(obj->single); if( obj->phdb != NULL) free_PfamHmmer1DB(obj->phdb); if( obj->sdb != NULL) free_SequenceDB(obj->sdb); if( obj->comp != NULL) free_CompMat(obj->comp); if( obj->seq_cache != NULL) free_Sequence(obj->seq_cache); /* obj->reload_generic is a function pointer */ /* obj->open_generic is a function pointer */ /* obj->close_generic is a function pointer */ /* obj->dataentry_add is a function pointer */ /* obj->open_index_generic is a function pointer */ /* obj->index_generic is a function pointer */ /* obj->close_index_generic is a function pointer */ /* obj->data is linked in */ ckfree(obj); return NULL; } /* Function: replace_dbtype_ThreeStateDB(obj,dbtype) * * Descrip: Replace member variable dbtype * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateDB *] * Arg: dbtype [OWNER] New value of the variable [int] * * Return [SOFT ] member variable dbtype [boolean] * */ boolean replace_dbtype_ThreeStateDB(ThreeStateDB * obj,int dbtype) { if( obj == NULL) { warn("In replacement function dbtype for object ThreeStateDB, got a NULL object"); return FALSE; } obj->dbtype = dbtype; return TRUE; } /* Function: access_dbtype_ThreeStateDB(obj) * * Descrip: Access member variable dbtype * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateDB *] * * Return [SOFT ] member variable dbtype [int] * */ int access_dbtype_ThreeStateDB(ThreeStateDB * obj) { if( obj == NULL) { warn("In accessor function dbtype for object ThreeStateDB, got a NULL object"); return 0; } return obj->dbtype; } /* Function: replace_filename_ThreeStateDB(obj,filename) * * Descrip: Replace member variable filename * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateDB *] * Arg: filename [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable filename [boolean] * */ boolean replace_filename_ThreeStateDB(ThreeStateDB * obj,char * filename) { if( obj == NULL) { warn("In replacement function filename for object ThreeStateDB, got a NULL object"); return FALSE; } obj->filename = filename; return TRUE; } /* Function: access_filename_ThreeStateDB(obj) * * Descrip: Access member variable filename * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ThreeStateDB *] * * Return [SOFT ] member variable filename [char *] * */ char * access_filename_ThreeStateDB(ThreeStateDB * obj) { if( obj == NULL) { warn("In accessor function filename for object ThreeStateDB, got a NULL object"); return NULL; } return obj->filename; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/threestatedb.h0000644000175000001440000003133010670453715016762 0ustar philippusers#ifndef DYNAMITEthreestatedbHEADERFILE #define DYNAMITEthreestatedbHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "threestatemodel.h" #include "pfamhmmer1db.h" typedef enum { TSMDB_UNKNOWN, TSMDB_SINGLE, TSMDB_HMMER1PFAM, TSMDB_PROTEIN, TSMDB_GENERIC } TSMDB_Type; #ifndef DYNAMITE_DEFINED_ThreeStateDB typedef struct Wise2_ThreeStateDB Wise2_ThreeStateDB; #define ThreeStateDB Wise2_ThreeStateDB #define DYNAMITE_DEFINED_ThreeStateDB #endif #ifndef DYNAMITE_DEFINED_PfamHmmer1DB typedef struct Wise2_PfamHmmer1DB Wise2_PfamHmmer1DB; #define PfamHmmer1DB Wise2_PfamHmmer1DB #define DYNAMITE_DEFINED_PfamHmmer1DB #endif /* Object ThreeStateDB * * Descrip: ThreeStateDB is the object that represents * a database of profile-HMMs. * * The object hold a variety of fields on some of which are * occupied depending on the type. * * Realistically we need a more abstract class idea, which is * implemented here anyway via the generic stuff, in hacky * C-style pointers to function plus a void pointer. This object * therefore houses a switch system around the different types * including the generic system... but as the generic function * stuff was bolted on later, some things are handled with * explicit datastructures. It is quite messy ;). Apologies. * To be cleaned up. * * The generic stuff was principly added in to allow a decoupling of this module * from the HMMer2.o interface code which is held in wise2xhmmer.dy * * The old static datastructure code can be * made via protein sequences which are then converted or a * Pfam 2.0 style directory + HMMs file. * * */ struct Wise2_ThreeStateDB { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int dbtype; char * filename; int type; FILE * current_file; RandomModel * rm; /* NB, this is hard-linked... */ long byte_position; /* this is the file position for the current model */ ThreeStateModel * single; /* for single db cases */ PfamHmmer1DB * phdb; /* for Pfam Hmmer1 style databases. */ SequenceDB * sdb; /* for protein databases */ CompMat * comp; /* for protein databases */ int gap; /* for protein databases */ int ext; /* for protein databases */ Sequence * seq_cache; /* needed for a bit of inter-function communication */ ThreeStateModel * (*reload_generic)(ThreeStateDB * tdb,int * return_status); boolean (*open_generic)(ThreeStateDB * tdb); boolean (*close_generic)(ThreeStateDB * tdb); boolean (*dataentry_add)(ThreeStateDB * tdb,DataEntry * en); boolean (*open_index_generic)(ThreeStateDB *tdb); ThreeStateModel * (*index_generic)(ThreeStateDB *tdb,DataEntry *de); boolean (*close_index_generic)(ThreeStateDB *tdb); void * data; /* whatever else the damn system wants to carry around with it! */ int hmm_model_start; int hmm_model_end; int current_no; } ; /* ThreeStateDB defined */ #ifndef DYNAMITE_DEFINED_ThreeStateDB typedef struct Wise2_ThreeStateDB Wise2_ThreeStateDB; #define ThreeStateDB Wise2_ThreeStateDB #define DYNAMITE_DEFINED_ThreeStateDB #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: open_for_indexing_ThreeStateDB(mdb) * * Descrip: opens database ready for calls to * /indexed_ThreeStateModel_ThreeStateDB * * * * Arg: mdb [UNKN ] database to open for index calls [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_open_for_indexing_ThreeStateDB(ThreeStateDB * mdb); #define open_for_indexing_ThreeStateDB Wise2_open_for_indexing_ThreeStateDB /* Function: close_for_indexing_ThreeStateDB(mdb) * * Descrip: closes an indexable database * * * Arg: mdb [UNKN ] Undocumented argument [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_close_for_indexing_ThreeStateDB(ThreeStateDB * mdb); #define close_for_indexing_ThreeStateDB Wise2_close_for_indexing_ThreeStateDB /* Function: set_search_type_ThreeStateDB(tdb,type) * * Descrip: Set the search type of this threestatedb... * * * Arg: tdb [UNKN ] Undocumented argument [ThreeStateDB *] * Arg: type [UNKN ] to set can be any of the modes found in threestatemodel [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_set_search_type_ThreeStateDB(ThreeStateDB * tdb,char * type); #define set_search_type_ThreeStateDB Wise2_set_search_type_ThreeStateDB /* Function: indexed_ThreeStateModel_ThreeStateDB(mdb,en) * * Descrip: Retrieves a model from a database which has been opened * for indexing by /open_for_indexing_ThreeStateDB * * The index information comes from the dataentry which should * have been from a search of the ThreeStateDB. * * * Arg: mdb [UNKN ] database where this is indexed [ThreeStateDB *] * Arg: en [UNKN ] dataentry to pull the model from [DataEntry *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_indexed_ThreeStateModel_ThreeStateDB(ThreeStateDB * mdb,DataEntry * en); #define indexed_ThreeStateModel_ThreeStateDB Wise2_indexed_ThreeStateModel_ThreeStateDB /* Function: new_proteindb_ThreeStateDB(sdb,comp,gap,ext) * * Descrip: makes a new ThreeStateDB from a * sequencedb (better be protein!) * * * * Arg: sdb [READ ] sequence database to use [SequenceDB *] * Arg: comp [READ ] comparison matrix to use [CompMat *] * Arg: gap [READ ] gap open penalty [int] * Arg: ext [READ ] gap extensions penalty [int] * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ ThreeStateDB * Wise2_new_proteindb_ThreeStateDB(SequenceDB * sdb,CompMat * comp,int gap,int ext); #define new_proteindb_ThreeStateDB Wise2_new_proteindb_ThreeStateDB /* Function: new_single_ThreeStateDB(tsm,rm) * * Descrip: Making a new ThreeStateDB from a single * model * * * * Arg: tsm [READ ] a single ThreeStateModel [ThreeStateModel *] * Arg: rm [READ ] random model to be used in comparisons.. [RandomModel *] * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ ThreeStateDB * Wise2_new_single_ThreeStateDB(ThreeStateModel * tsm,RandomModel * rm); #define new_single_ThreeStateDB Wise2_new_single_ThreeStateDB /* Function: new_PfamHmmer1DB_ThreeStateDB(dirname) * * Descrip: Makes a new PfamHmmer1DB from a filename * indicating the directory * * * Arg: dirname [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ ThreeStateDB * Wise2_new_PfamHmmer1DB_ThreeStateDB(char * dirname); #define new_PfamHmmer1DB_ThreeStateDB Wise2_new_PfamHmmer1DB_ThreeStateDB /* Function: dataentry_add_ThreeStateDB(de,tss,mdb) * * Descrip: This function adds the internal entry information * (eg indexing point) into the dataentry * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: tss [UNKN ] Undocumented argument [ThreeStateScore *] * Arg: mdb [UNKN ] Undocumented argument [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_dataentry_add_ThreeStateDB(DataEntry * de,ThreeStateScore * tss,ThreeStateDB * mdb); #define dataentry_add_ThreeStateDB Wise2_dataentry_add_ThreeStateDB /* Function: open_ThreeStateDB(mdb) * * Descrip: Open function for ThreeStateDB. * An internal for this file but also * used by, for example, GeneWiseDB that * wants to get at the underlying models, * not the log-odds. * * * Arg: mdb [UNKN ] Undocumented argument [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_open_ThreeStateDB(ThreeStateDB * mdb); #define open_ThreeStateDB Wise2_open_ThreeStateDB /* Function: read_TSM_ThreeStateDB(mdb,return_status) * * Descrip: Reads a threestatemodel out from the * database. People will probably want the * ThreeStateScore *not* the model, but some * systems will want the model. * * * Arg: mdb [UNKN ] Undocumented argument [ThreeStateDB *] * Arg: return_status [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [ThreeStateModel *] * */ ThreeStateModel * Wise2_read_TSM_ThreeStateDB(ThreeStateDB * mdb,int * return_status); #define read_TSM_ThreeStateDB Wise2_read_TSM_ThreeStateDB /* Function: init_ThreeStateDB(mdb,return_status) * * Descrip: Init function for ThreeStateDB * * Is going to open file, read first model, complain if * NULL, and convert to a score system. * * * Arg: mdb [RW ] Model database [ThreeStateDB *] * Arg: return_status [WRITE] return from database.h system [int *] * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ ThreeStateScore * Wise2_init_ThreeStateDB(ThreeStateDB * mdb,int * return_status); #define init_ThreeStateDB Wise2_init_ThreeStateDB /* Function: reload_ThreeStateDB(prev,tss,mdb,return_status) * * Descrip: reloads the ThreeStateDB. * * Frees the previous score system (could recycle memory). * Reads database. calls END if gets NULL from read_HMF_ThreeStateModel * * * Arg: prev [UNKN ] Undocumented argument [ThreeStateScore *] * Arg: tss [UNKN ] the previous score system [NullString] * Arg: mdb [UNKN ] model database system [ThreeStateDB *] * Arg: return_status [WRITE] return from database.h system [int *] * * Return [UNKN ] Undocumented return value [ThreeStateScore *] * */ ThreeStateScore * Wise2_reload_ThreeStateDB(ThreeStateScore * prev,ThreeStateDB * mdb,int * return_status); #define reload_ThreeStateDB Wise2_reload_ThreeStateDB /* Function: close_ThreeStateDB(prev,mdb) * * Descrip: closes ThreeStateDB * * At the moment, only needs to free previous * and close the file * * * Arg: prev [UNKN ] the last ThreeStateScore to be freed [ThreeStateScore *] * Arg: mdb [UNKN ] Model database [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_close_ThreeStateDB(ThreeStateScore * prev,ThreeStateDB * mdb); #define close_ThreeStateDB Wise2_close_ThreeStateDB /* Function: hard_link_ThreeStateDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ ThreeStateDB * Wise2_hard_link_ThreeStateDB(ThreeStateDB * obj); #define hard_link_ThreeStateDB Wise2_hard_link_ThreeStateDB /* Function: ThreeStateDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ ThreeStateDB * Wise2_ThreeStateDB_alloc(void); #define ThreeStateDB_alloc Wise2_ThreeStateDB_alloc /* Function: free_ThreeStateDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateDB *] * * Return [UNKN ] Undocumented return value [ThreeStateDB *] * */ ThreeStateDB * Wise2_free_ThreeStateDB(ThreeStateDB * obj); #define free_ThreeStateDB Wise2_free_ThreeStateDB /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_access_dbtype_ThreeStateDB(ThreeStateDB * obj); #define access_dbtype_ThreeStateDB Wise2_access_dbtype_ThreeStateDB boolean Wise2_replace_filename_ThreeStateDB(ThreeStateDB * obj,char * filename); #define replace_filename_ThreeStateDB Wise2_replace_filename_ThreeStateDB boolean Wise2_replace_dbtype_ThreeStateDB(ThreeStateDB * obj,int dbtype); #define replace_dbtype_ThreeStateDB Wise2_replace_dbtype_ThreeStateDB char * Wise2_access_filename_ThreeStateDB(ThreeStateDB * obj); #define access_filename_ThreeStateDB Wise2_access_filename_ThreeStateDB #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/threestatedp.c0000644000175000001440000046210610670453715017004 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "threestatedp.h" # line 5 "threestatedp.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:33 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define START 0 #define END 1 #define ThreeStateProtein_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+1)*3)+STATE][i+1] #define ThreeStateProtein_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+1] #define ThreeStateProtein_READ_OFF_ERROR -3 #define ThreeStateProtein_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+2)%2][((i+1)*3)+STATE] #define ThreeStateProtein_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+2)%2][STATE] #define ThreeStateProtein_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define ThreeStateProtein_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_ThreeStateProtein(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_ThreeStateProtein(ThreeStateProtein * mat) { ThreeStateProtein_access_func_holder holder; holder.access_main = ThreeStateProtein_shatter_access_main; holder.access_special = ThreeStateProtein_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_ThreeStateProtein(mat,holder); } /* Function: ThreeStateProtein_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ThreeStateProtein_shatter_access_main(ThreeStateProtein * mat,int i,int j,int state) { return ThreeStateProtein_SHATTER_MATRIX(mat,i,j,state); } /* Function: ThreeStateProtein_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ThreeStateProtein_shatter_access_special(ThreeStateProtein * mat,int i,int j,int state) { return ThreeStateProtein_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_ThreeStateProtein(mat,dpenv) * * Descrip: This function calculates the ThreeStateProtein matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [ThreeStateProtein *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_ThreeStateProtein(ThreeStateProtein * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_1; int * SIG_0_1; int * SIG_1_0; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,3,lenj,2); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("ThreeStateProtein Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_1[MATCH] + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = SIG_1_1[INSERT] + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_1[DELETE] + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = ThreeStateProtein_SHATTER_SPECIAL(mat,i-1,j-1,START) + mat->query->unit[i]->trans[TSM_START2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; SIG_0_0[MATCH] = score; /* state MATCH is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_MATCH2END]) + (0) ; if( temp > ThreeStateProtein_SHATTER_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_1[MATCH] + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_1[DELETE] + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = ThreeStateProtein_SHATTER_SPECIAL(mat,i-0,j-1,START) + mat->query->unit[i]->trans[TSM_START2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; SIG_0_0[INSERT] = score; /* state INSERT is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_INSERT2END]) + (0) ; if( temp > ThreeStateProtein_SHATTER_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = ThreeStateProtein_SHATTER_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->trans[TSM_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_DELETE2END]) + (0) ; if( temp > ThreeStateProtein_SHATTER_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_SHATTER_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: search_ThreeStateProtein(dbsi,out,query,targetdb) * * Descrip: This function makes a database search of ThreeStateProtein * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ThreeStateScore*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_ThreeStateProtein(DBSearchImpl * dbsi,Hscore * out,ThreeStateScore* query,ProteinDB* targetdb ) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_ThreeStateProtein * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_ThreeStateProtein. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_ThreeStateProtein. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for ThreeStateProtein, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_ThreeStateProtein(out,query, targetdb ); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_ThreeStateProtein *) ckalloc(sizeof(struct thread_pool_holder_ThreeStateProtein)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->query = query; holder->targetdb = targetdb; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_ThreeStateProtein,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for ThreeStateProtein"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from ThreeStateProtein",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_ThreeStateProtein(ptr) * * Descrip: dummy loop code foreach thread for ThreeStateProtein * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * thread_loop_ThreeStateProtein(void * ptr) { fatal("dummy thread loop function"); } /* Function: serial_search_ThreeStateProtein(out,query,targetdb) * * Descrip: This function makes a database search of ThreeStateProtein * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ThreeStateScore*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_ThreeStateProtein(Hscore * out,ThreeStateScore* query,ProteinDB* targetdb ) { ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; target = init_ProteinDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching ThreeStateProtein, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_ThreeStateProtein(query, target ); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("ThreeStateProtein search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_ProteinDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_ProteinDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching ThreeStateProtein, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break; /* Out of target loop */ target_pos++; } /* end of For all target entries */ close_ProteinDB(target,targetdb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_ThreeStateProtein(query,target) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_ThreeStateProtein_only * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_ThreeStateProtein(ThreeStateScore* query,ComplexSequence* target ) { int bestscore = NEGI; int i; int j; int k; ThreeStateProtein * mat; mat = allocate_ThreeStateProtein_only(query, target ); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(2,(mat->leni + 1) * 3,2,2)) == NULL) { warn("Score only matrix for ThreeStateProtein cannot be allocated, (asking for 1 by %d cells)",mat->leni*3); mat = free_ThreeStateProtein(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<3;j++) { for(i=(-1);ileni;i++) { for(k=0;k<3;k++) ThreeStateProtein_VSMALL_MATRIX(mat,i,j,k) = NEGI; } ThreeStateProtein_VSMALL_SPECIAL(mat,i,j,START) = 0; ThreeStateProtein_VSMALL_SPECIAL(mat,i,j,END) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = ThreeStateProtein_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = ThreeStateProtein_VSMALL_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ThreeStateProtein_VSMALL_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = ThreeStateProtein_VSMALL_SPECIAL(mat,i-1,j-1,START) + mat->query->unit[i]->trans[TSM_START2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_MATCH2END]) + (0) ; if( temp > ThreeStateProtein_VSMALL_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateProtein_VSMALL_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = ThreeStateProtein_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = ThreeStateProtein_VSMALL_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = ThreeStateProtein_VSMALL_SPECIAL(mat,i-0,j-1,START) + mat->query->unit[i]->trans[TSM_START2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_INSERT2END]) + (0) ; if( temp > ThreeStateProtein_VSMALL_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateProtein_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = ThreeStateProtein_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = ThreeStateProtein_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = ThreeStateProtein_VSMALL_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->trans[TSM_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ThreeStateProtein_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_DELETE2END]) + (0) ; if( temp > ThreeStateProtein_VSMALL_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_VSMALL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* end of for all query positions */ /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ if( bestscore < ThreeStateProtein_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = ThreeStateProtein_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_ThreeStateProtein(mat); return bestscore; } /* Function: PackAln_bestmemory_ThreeStateProtein(query,target,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_ThreeStateProtein * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_ThreeStateProtein(ThreeStateScore* query,ComplexSequence* target ,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; ThreeStateProtein * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 3 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_ThreeStateProtein(query, target ,dpri)) == NULL ) { warn("Unable to allocate large ThreeStateProtein version"); return NULL; } calculate_dpenv_ThreeStateProtein(mat,dpenv); out = PackAln_read_Expl_ThreeStateProtein(mat); } else { mat = allocate_ThreeStateProtein_only(query, target ); calculate_shatter_ThreeStateProtein(mat,dpenv); out = PackAln_read_Shatter_ThreeStateProtein(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_ThreeStateProtein(query, target )) == NULL ) { warn("Unable to allocate small ThreeStateProtein version"); return NULL; } out = PackAln_calculate_Small_ThreeStateProtein(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_ThreeStateProtein(query, target ,dpri)) == NULL ) { warn("Unable to allocate large ThreeStateProtein version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_ThreeStateProtein(mat); out = PackAln_read_Expl_ThreeStateProtein(mat); } } } mat = free_ThreeStateProtein(mat); return out; } /* Function: allocate_ThreeStateProtein_only(query,target) * * Descrip: This function only allocates the ThreeStateProtein structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * * Return [UNKN ] Undocumented return value [ThreeStateProtein *] * */ ThreeStateProtein * allocate_ThreeStateProtein_only(ThreeStateScore* query,ComplexSequence* target ) { ThreeStateProtein * out; if((out= ThreeStateProtein_alloc()) == NULL) { warn("Allocation of basic ThreeStateProtein structure failed..."); return NULL; } out->query = query; out->target = target; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_ThreeStateProtein(query,target,dpri) * * Descrip: This function allocates the ThreeStateProtein structure * and the basematrix area for explicit memory implementations * It calls /allocate_ThreeStateProtein_only * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [ThreeStateProtein *] * */ ThreeStateProtein * allocate_Expl_ThreeStateProtein(ThreeStateScore* query,ComplexSequence* target ,DPRunImpl * dpri) { ThreeStateProtein * out; out = allocate_ThreeStateProtein_only(query, target ); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+1)*3 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+1)*3,(out->leni+1),2,out->lenj+1)) == NULL) { warn("Explicit matrix ThreeStateProtein cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_ThreeStateProtein(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_ThreeStateProtein(out); return out; } /* Function: init_ThreeStateProtein(mat) * * Descrip: This function initates ThreeStateProtein matrix when in explicit mode * Called in /allocate_Expl_ThreeStateProtein * * * Arg: mat [UNKN ] ThreeStateProtein which contains explicit basematrix memory [ThreeStateProtein *] * */ void init_ThreeStateProtein(ThreeStateProtein * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-1);j<2;j++) { ThreeStateProtein_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateProtein_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateProtein_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j= (-1);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { ThreeStateProtein_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateProtein_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateProtein_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } ThreeStateProtein_EXPL_SPECIAL(mat,i,j,START) = 0; ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) = NEGI; } return; } /* Function: recalculate_PackAln_ThreeStateProtein(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by ThreeStateProtein * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * */ void recalculate_PackAln_ThreeStateProtein(PackAln * pal,ThreeStateProtein * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->query->unit[i]->trans[TSM_MATCH2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 1 && offj == 1 && prev->state == INSERT ) { pau->score = mat->query->unit[i]->trans[TSM_INSERT2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 1 && offj == 1 && prev->state == DELETE ) { pau->score = mat->query->unit[i]->trans[TSM_DELETE2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offj == 1 && prev->state == (START+3) ) { pau->score = mat->query->unit[i]->trans[TSM_START2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 1 && prev->state == MATCH ) { pau->score = mat->query->unit[i]->trans[TSM_MATCH2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->query->unit[i]->trans[TSM_INSERT2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offi == 0 && offj == 1 && prev->state == DELETE ) { pau->score = mat->query->unit[i]->trans[TSM_DELETE2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } if( offj == 1 && prev->state == (START+3) ) { pau->score = mat->query->unit[i]->trans[TSM_START2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->unit[i]->trans[TSM_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->unit[i]->trans[TSM_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->unit[i]->trans[TSM_DELETE2DELETE] + (0); continue; } if( offj == 0 && prev->state == (START+3) ) { pau->score = mat->query->unit[i]->trans[TSM_START2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (START+3) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+3) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->unit[i]->trans[TSM_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->unit[i]->trans[TSM_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->unit[i]->trans[TSM_DELETE2END] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define ThreeStateProtein_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+1)][(i+1)*3+state]) #define ThreeStateProtein_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+2)*8) % 16][(i+1)*3+state]) #define ThreeStateProtein_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+1)]) #define ThreeStateProtein_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) #define ThreeStateProtein_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+2)*8)+(shadow+1)) % 16)][(i+1)*3 + state]) #define ThreeStateProtein_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) #define ThreeStateProtein_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+1)% 1) * (leni+1) * 3) + ((i+1) * 3) + (state)]) #define ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+1)% 1) * (leni+1) * 24) + ((i+1) * 24) + (state * 8) + shadow+1]) #define ThreeStateProtein_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+1)]) /* Function: allocate_Small_ThreeStateProtein(query,target) * * Descrip: This function allocates the ThreeStateProtein structure * and the basematrix area for a small memory implementations * It calls /allocate_ThreeStateProtein_only * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * * Return [UNKN ] Undocumented return value [ThreeStateProtein *] * */ #define ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+1)]) ThreeStateProtein * allocate_Small_ThreeStateProtein(ThreeStateScore* query,ComplexSequence* target ) { ThreeStateProtein * out; out = allocate_ThreeStateProtein_only(query, target ); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(16,(out->leni + 1) * 3,16,out->lenj+1); if(out == NULL) { warn("Small shadow matrix ThreeStateProtein cannot be allocated, (asking for 2 by %d main cells)",out->leni+2); free_ThreeStateProtein(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_ThreeStateProtein(mat,dpenv) * * Descrip: This function calculates an alignment for ThreeStateProtein structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_ThreeStateProtein * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_ThreeStateProtein * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_ThreeStateProtein(ThreeStateProtein * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for ThreeStateProtein due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_ThreeStateProtein(mat,dpenv); score = start_end_find_end_ThreeStateProtein(mat,&endj); out->score = score; stopstate = END; /* No special to specials: one matrix alignment: simply remove and get */ starti = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,0); startj = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,1); startstate = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,2); stopi = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,3); stopj = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,4); stopstate = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,5); temp = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,endj,END,6); log_full_error(REPORT,0,"[%d,%d][%d,%d] Score %d",starti,startj,stopi,stopj,score); stop_reporting(); start_reporting("Recovering alignment: "); /* Figuring how much j we have to align for reporting purposes */ donej = 0; totalj = stopj - startj; full_dc_ThreeStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv); /* Although we have no specials, need to get start. Better to check than assume */ max_matrix_to_special_ThreeStateProtein(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == ThreeStateProtein_READ_OFF_ERROR || stopstate != START ) { warn("Problem in reading off special state system, hit a non start state (or an internal error) in a single alignment mode"); invert_PackAln(out); recalculate_PackAln_ThreeStateProtein(out,mat); return out; } /* Ok. Put away start start... */ pau = PackAlnUnit_alloc(); pau->i = stopi; pau->j = stopj; pau->state = stopstate + 3; add_PackAln(out,pau); log_full_error(REPORT,0,"Alignment recovered"); stop_reporting(); invert_PackAln(out); recalculate_PackAln_ThreeStateProtein(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_ThreeStateProtein(mat) * * Descrip: This function calculates an alignment for ThreeStateProtein structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_ThreeStateProtein * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_ThreeStateProtein * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_ThreeStateProtein * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_ThreeStateProtein(ThreeStateProtein * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_ThreeStateProtein(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_ThreeStateProtein(mat); return out; } /* Function: AlnRangeSet_from_ThreeStateProtein(mat) * * Descrip: This function reads off a start/end structure * for ThreeStateProtein structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_ThreeStateProtein * If you have not calculated the matrix use * /AlnRange_calculate_Small_ThreeStateProtein * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_ThreeStateProtein(ThreeStateProtein * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_ThreeStateProtein"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_ThreeStateProtein(mat,&jpos); state = END; while( (temp = AlnRange_build_ThreeStateProtein(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_ThreeStateProtein(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_ThreeStateProtein * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_ThreeStateProtein(ThreeStateProtein * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_ThreeStateProtein"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_ThreeStateProtein(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_ThreeStateProtein alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = ThreeStateProtein_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_ThreeStateProtein(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == ThreeStateProtein_READ_OFF_ERROR) { warn("In AlnRange_build_ThreeStateProtein alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = ThreeStateProtein_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_ThreeStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_ThreeStateProtein(ThreeStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_ThreeStateProtein(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == ThreeStateProtein_READ_OFF_ERROR) { warn("In ThreeStateProtein hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In ThreeStateProtein hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In ThreeStateProtein hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_ThreeStateProtein(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_ThreeStateProtein(ThreeStateProtein * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = ThreeStateProtein_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In ThreeStateProtein matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = ThreeStateProtein_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,DELETE); } return ThreeStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,DELETE); } temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,INSERT); } return ThreeStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return ThreeStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in ThreeStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,DELETE) ) { *reti = i - 0; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,DELETE); } return ThreeStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,DELETE); } temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return ThreeStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,MATCH); } return ThreeStateProtein_HIDDEN_MATRIX(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in ThreeStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Not allowing special sources.. skipping START */ temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2DELETE]) - (0); if( temp == ThreeStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return ThreeStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2DELETE]) - (0); if( temp == ThreeStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return ThreeStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2DELETE]) - (0); if( temp == ThreeStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return ThreeStateProtein_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in ThreeStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in ThreeStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_ThreeStateProtein(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_ThreeStateProtein(ThreeStateProtein * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } max_special_strip_ThreeStateProtein(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == ThreeStateProtein_READ_OFF_ERROR) { warn("In special strip read ThreeStateProtein, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read ThreeStateProtein, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 3; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_ThreeStateProtein(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_ThreeStateProtein(ThreeStateProtein * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = ThreeStateProtein_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for ThreeStateProtein, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In ThreeStateProtein matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = ThreeStateProtein_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ default: warn("Major problem (!) - in ThreeStateProtein special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_ThreeStateProtein(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_ThreeStateProtein(ThreeStateProtein * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = ThreeStateProtein_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In ThreeStateProtein matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->query->unit[i]->trans[TSM_START2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateProtein_DC_SHADOW_SPECIAL(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateProtein_DC_SHADOW_SPECIAL(mat,i-1,j-1,START); } return ThreeStateProtein_DC_SHADOW_MATRIX(mat,i - 1,j - 1,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in ThreeStateProtein matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->query->unit[i]->trans[TSM_START2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == ThreeStateProtein_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateProtein_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return ThreeStateProtein_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in ThreeStateProtein matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->unit[i]->trans[TSM_START2DELETE]) - (0); if( temp == ThreeStateProtein_DC_SHADOW_SPECIAL(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - ThreeStateProtein_DC_SHADOW_SPECIAL(mat,i-1,j-0,START); } return ThreeStateProtein_DC_SHADOW_MATRIX(mat,i - 1,j - 0,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in ThreeStateProtein matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in ThreeStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_ThreeStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_ThreeStateProtein(ThreeStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_ThreeStateProtein(mat,starti,startj,stopi,stopj); ThreeStateProtein_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ThreeStateProtein_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateProtein_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateProtein_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = ThreeStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = ThreeStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ThreeStateProtein_HIDDEN_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = ThreeStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = ThreeStateProtein_HIDDEN_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = ThreeStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = ThreeStateProtein_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ThreeStateProtein_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } } return; } /* Function: init_hidden_ThreeStateProtein(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_ThreeStateProtein(ThreeStateProtein * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-1);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { ThreeStateProtein_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateProtein_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateProtein_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; } } return; } /* Function: full_dc_ThreeStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_ThreeStateProtein * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_ThreeStateProtein to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [ThreeStateProtein *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_ThreeStateProtein(ThreeStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_ThreeStateProtein"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 5) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_ThreeStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_ThreeStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_ThreeStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for ThreeStateProtein, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_ThreeStateProtein(mat,ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_ThreeStateProtein(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_ThreeStateProtein(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_ThreeStateProtein(ThreeStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_ThreeStateProtein(mat); ThreeStateProtein_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_ThreeStateProtein(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_ThreeStateProtein(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_ThreeStateProtein(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_ThreeStateProtein(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_ThreeStateProtein(ThreeStateProtein * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<1;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; if( j - 1 <= mergej) { ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score) { score = temp; if( j - 1 <= mergej) { ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } } temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score) { score = temp; if( j - 1 <= mergej) { ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } } /* Add any movement independant score */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; if( j - 1 <= mergej) { ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); } temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score) { score = temp; if( j - 1 <= mergej) { ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score) { score = temp; if( j - 1 <= mergej) { ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,k); } } /* Add any movement independant score */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; if( j - 0 <= mergej) { ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_ThreeStateProtein(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_ThreeStateProtein(ThreeStateProtein * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); /* From state INSERT to state MATCH */ temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,k); } /* From state DELETE to state MATCH */ temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,k); /* From state INSERT to state INSERT */ temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* From state DELETE to state INSERT */ temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_ThreeStateProtein(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_ThreeStateProtein(ThreeStateProtein * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = ThreeStateProtein_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_ThreeStateProtein(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * */ } void init_dc_ThreeStateProtein(ThreeStateProtein * mat) { register int i; register int j; register int k; for(j=0;j<3;j++) { for(i=(-1);iquery->len;i++) { ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; for(k=0;k<7;k++) { ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); } } } return; } /* Function: start_end_find_end_ThreeStateProtein(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [ThreeStateProtein *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_ThreeStateProtein(ThreeStateProtein * mat,int * endj) { register int j; register int max; register int maxj; max = ThreeStateProtein_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( ThreeStateProtein_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = ThreeStateProtein_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_ThreeStateProtein(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [ThreeStateProtein] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_ThreeStateProtein(ThreeStateProtein *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (1 * (leni + 1) * 3,sizeof(int)); shadow_pointers = (int *) calloc (1 * (leni + 1) * 3 * 8,sizeof(int)); for(j=0;jquery->unit[i]->trans[TSM_MATCH2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); /* assign local shadown pointer */ localsp = &(ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); /* From state INSERT to state MATCH */ temp = ThreeStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH] +(mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,INSERT,0)); } /* From state DELETE to state MATCH */ temp = ThreeStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH] +(mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,DELETE,0)); } /* From state START to state MATCH */ temp = ThreeStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-1,START) + mat->query->unit[i]->trans[TSM_START2MATCH] + (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ ThreeStateProtein_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_MATCH2END]) + (0) ; if( temp > ThreeStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); /* assign local shadown pointer */ localsp = &(ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,MATCH,0)); /* From state INSERT to state INSERT */ temp = ThreeStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT] +(mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* From state DELETE to state INSERT */ temp = ThreeStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT] +(mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,DELETE,0)); } /* From state START to state INSERT */ temp = ThreeStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-1,START) + mat->query->unit[i]->trans[TSM_START2INSERT] + (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp > score ) { score = temp; /* This state [START] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ ThreeStateProtein_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_INSERT2END]) + (0) ; if( temp > ThreeStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = ThreeStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = ThreeStateProtein_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* From state START to state DELETE */ temp = ThreeStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->trans[TSM_START2DELETE] + (0); if( temp > score ) { score = temp; /* This state [START] is a special for DELETE... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= DELETE; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ ThreeStateProtein_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_DELETE2END]) + (0) ; if( temp > ThreeStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_DC_OPT_SHADOW_SPECIAL(mat,i,j,END) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,6) = ThreeStateProtein_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,3) = i; ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,4) = j; ThreeStateProtein_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,5) = DELETE; } /* Finished calculating state DELETE */ } /* end of for each i position in strip */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_ThreeStateProtein(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * */ void init_start_end_linear_ThreeStateProtein(ThreeStateProtein * mat) { register int i; register int j; for(j=0;j<3;j++) { for(i=(-1);iquery->len;i++) { ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); ThreeStateProtein_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; ThreeStateProtein_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); } } for(j=(-1);jtarget->seq->len;j++) { ThreeStateProtein_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; ThreeStateProtein_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; ThreeStateProtein_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_ThreeStateProtein(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_ThreeStateProtein(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_ThreeStateProtein(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "SEQUENCE","INSERT","END" }; /* Function: AlnConvertSet_ThreeStateProtein(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "SEQUENCE","INSERT","END" }; AlnConvertSet * AlnConvertSet_ThreeStateProtein(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 3; acu->is_from_special = TRUE; acu->state2 = DELETE; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = END + 3; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[2]; return out; } /* Function: PackAln_read_Expl_ThreeStateProtein(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_ThreeStateProtein(ThreeStateProtein * mat) { ThreeStateProtein_access_func_holder holder; holder.access_main = ThreeStateProtein_explicit_access_main; holder.access_special = ThreeStateProtein_explicit_access_special; return PackAln_read_generic_ThreeStateProtein(mat,holder); } /* Function: ThreeStateProtein_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ThreeStateProtein_explicit_access_main(ThreeStateProtein * mat,int i,int j,int state) { return ThreeStateProtein_EXPL_MATRIX(mat,i,j,state); } /* Function: ThreeStateProtein_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int ThreeStateProtein_explicit_access_special(ThreeStateProtein * mat,int i,int j,int state) { return ThreeStateProtein_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_ThreeStateProtein(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: h [UNKN ] Undocumented argument [ThreeStateProtein_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_ThreeStateProtein(ThreeStateProtein * mat,ThreeStateProtein_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_ThreeStateProtein(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in ThreeStateProtein_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_ThreeStateProtein(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_ThreeStateProtein(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == ThreeStateProtein_READ_OFF_ERROR || j == ThreeStateProtein_READ_OFF_ERROR || state == ThreeStateProtein_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in ThreeStateProtein_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 3; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_ThreeStateProtein(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [ThreeStateProtein_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_ThreeStateProtein(ThreeStateProtein * mat,int * ri,int * rj,int * state,boolean * isspecial,ThreeStateProtein_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: ThreeStateProtein_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void ThreeStateProtein_debug_show_matrix(ThreeStateProtein * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",ThreeStateProtein_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",ThreeStateProtein_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",ThreeStateProtein_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_ThreeStateProtein(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [ThreeStateProtein_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_ThreeStateProtein(ThreeStateProtein * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ThreeStateProtein_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = ThreeStateProtein_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In ThreeStateProtein matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->query->unit[i]->trans[TSM_START2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 1,j - 1,START) ) { *reti = i - 1; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-1,START); } return (*h.access_main)(mat,i - 1,j - 1,START); } temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 1,j - 1,DELETE) ) { *reti = i - 1; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,DELETE); } return (*h.access_main)(mat,i - 1,j - 1,DELETE); } temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 1,j - 1,INSERT) ) { *reti = i - 1; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,INSERT); } return (*h.access_main)(mat,i - 1,j - 1,INSERT); } temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2MATCH]) - (mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } warn("Major problem (!) - in ThreeStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->query->unit[i]->trans[TSM_START2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_main)(mat,i - 0,j - 1,START); } temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,DELETE) ) { *reti = i - 0; *retj = j - 1; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,DELETE); } return (*h.access_main)(mat,i - 0,j - 1,DELETE); } temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2INSERT]) - (mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]); if( temp == (*h.access_main)(mat,i - 0,j - 1,MATCH) ) { *reti = i - 0; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,MATCH); } return (*h.access_main)(mat,i - 0,j - 1,MATCH); } warn("Major problem (!) - in ThreeStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->unit[i]->trans[TSM_START2DELETE]) - (0); if( temp == (*h.access_special)(mat,i - 1,j - 0,START) ) { *reti = i - 1; *retj = j - 0; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-0,START); } return (*h.access_main)(mat,i - 1,j - 0,START); } temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in ThreeStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in ThreeStateProtein read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_ThreeStateProtein(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [ThreeStateProtein_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_ThreeStateProtein(ThreeStateProtein * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ThreeStateProtein_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = ThreeStateProtein_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In ThreeStateProtein matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case START : case END : /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->unit[i]->trans[TSM_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->unit[i]->trans[TSM_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->unit[i]->trans[TSM_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in ThreeStateProtein read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_ThreeStateProtein(mat) * * Descrip: This function calculates the ThreeStateProtein matrix when in explicit mode * To allocate the matrix use /allocate_Expl_ThreeStateProtein * * * Arg: mat [UNKN ] ThreeStateProtein which contains explicit basematrix memory [ThreeStateProtein *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_ThreeStateProtein(ThreeStateProtein * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_ThreeStateProtein, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("ThreeStateProtein Matrix calculation: "); for(j=0;jquery->unit[i]->trans[TSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = ThreeStateProtein_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ThreeStateProtein_EXPL_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = ThreeStateProtein_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->query->unit[i]->trans[TSM_START2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_MATCH2END]) + (0) ; if( temp > ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateProtein_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = ThreeStateProtein_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = ThreeStateProtein_EXPL_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = ThreeStateProtein_EXPL_SPECIAL(mat,i-0,j-1,START) + mat->query->unit[i]->trans[TSM_START2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_INSERT2END]) + (0) ; if( temp > ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateProtein_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = ThreeStateProtein_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = ThreeStateProtein_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = ThreeStateProtein_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->trans[TSM_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ThreeStateProtein_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_DELETE2END]) + (0) ; if( temp > ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_ThreeStateProtein(mat,dpenv) * * Descrip: This function calculates the ThreeStateProtein matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] ThreeStateProtein which contains explicit basematrix memory [ThreeStateProtein *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_ThreeStateProtein(ThreeStateProtein * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_ThreeStateProtein, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-1;jleni;i++) { ThreeStateProtein_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateProtein_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateProtein_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; } } for(j=-1;jlenj;j++) { ThreeStateProtein_EXPL_SPECIAL(mat,i,j,START) = 0; ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) = NEGI; } start_reporting("ThreeStateProtein Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { ThreeStateProtein_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; ThreeStateProtein_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; ThreeStateProtein_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = ThreeStateProtein_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2MATCH]; /* From state INSERT to state MATCH */ temp = ThreeStateProtein_EXPL_MATRIX(mat,i-1,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2MATCH]; if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = ThreeStateProtein_EXPL_MATRIX(mat,i-1,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2MATCH]; if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = ThreeStateProtein_EXPL_SPECIAL(mat,i-1,j-1,START) + mat->query->unit[i]->trans[TSM_START2MATCH]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->match[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_MATCH2END]) + (0) ; if( temp > ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = ThreeStateProtein_EXPL_MATRIX(mat,i-0,j-1,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2INSERT]; /* From state INSERT to state INSERT */ temp = ThreeStateProtein_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2INSERT]; if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = ThreeStateProtein_EXPL_MATRIX(mat,i-0,j-1,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2INSERT]; if( temp > score ) { score = temp; } /* From state START to state INSERT */ temp = ThreeStateProtein_EXPL_SPECIAL(mat,i-0,j-1,START) + mat->query->unit[i]->trans[TSM_START2INSERT]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += mat->query->unit[i]->insert[CSEQ_PROTEIN_AMINOACID(mat->target,j)]; ThreeStateProtein_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_INSERT2END]) + (0) ; if( temp > ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = ThreeStateProtein_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->unit[i]->trans[TSM_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = ThreeStateProtein_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->unit[i]->trans[TSM_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = ThreeStateProtein_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->unit[i]->trans[TSM_DELETE2DELETE]; if( temp > score ) { score = temp; } /* From state START to state DELETE */ temp = ThreeStateProtein_EXPL_SPECIAL(mat,i-1,j-0,START) + mat->query->unit[i]->trans[TSM_START2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ ThreeStateProtein_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special END */ temp = score + (mat->query->unit[i]->trans[TSM_DELETE2END]) + (0) ; if( temp > ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) ) { ThreeStateProtein_EXPL_SPECIAL(mat,i,j,END) = temp; } /* Finished calculating state DELETE */ } /* Special state START has no special to special movements */ /* Special state END has no special to special movements */ } stop_reporting(); return TRUE; } /* Function: ThreeStateProtein_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateProtein *] * */ ThreeStateProtein * ThreeStateProtein_alloc(void) { ThreeStateProtein * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ThreeStateProtein *) ckalloc (sizeof(ThreeStateProtein))) == NULL) { warn("ThreeStateProtein_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_ThreeStateProtein(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateProtein *] * * Return [UNKN ] Undocumented return value [ThreeStateProtein *] * */ ThreeStateProtein * free_ThreeStateProtein(ThreeStateProtein * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ThreeStateProtein obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/threestatedp.h0000644000175000001440000004755210670453715017015 0ustar philippusers#ifndef DYNAMITEthreestatedpHEADERFILE #define DYNAMITEthreestatedpHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "threestatemodel.h" struct Wise2_ThreeStateProtein { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; ThreeStateScore* query; ComplexSequence* target; } ; /* ThreeStateProtein defined */ #ifndef DYNAMITE_DEFINED_ThreeStateProtein typedef struct Wise2_ThreeStateProtein Wise2_ThreeStateProtein; #define ThreeStateProtein Wise2_ThreeStateProtein #define DYNAMITE_DEFINED_ThreeStateProtein #endif #ifdef PTHREAD struct thread_pool_holder_ThreeStateProtein { ThreeStateScore* query; /* Static query data: never free'd */ ComplexSequence* target;/* Target object placeholder */ ProteinDB* targetdb;/* Target database object */ boolean target_init; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_ThreeStateProtein_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(ThreeStateProtein*,int,int,int); int (*access_special)(ThreeStateProtein*,int,int,int); } ; /* ThreeStateProtein_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_ThreeStateProtein_access_func_holder typedef struct Wise2_ThreeStateProtein_access_func_holder Wise2_ThreeStateProtein_access_func_holder; #define ThreeStateProtein_access_func_holder Wise2_ThreeStateProtein_access_func_holder #define DYNAMITE_DEFINED_ThreeStateProtein_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_ThreeStateProtein(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_ThreeStateProtein(ThreeStateProtein * mat); #define PackAln_read_Shatter_ThreeStateProtein Wise2_PackAln_read_Shatter_ThreeStateProtein /* Function: calculate_shatter_ThreeStateProtein(mat,dpenv) * * Descrip: This function calculates the ThreeStateProtein matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [ThreeStateProtein *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_ThreeStateProtein(ThreeStateProtein * mat,DPEnvelope * dpenv); #define calculate_shatter_ThreeStateProtein Wise2_calculate_shatter_ThreeStateProtein /* Function: search_ThreeStateProtein(dbsi,out,query,targetdb) * * Descrip: This function makes a database search of ThreeStateProtein * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ThreeStateScore*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_ThreeStateProtein(DBSearchImpl * dbsi,Hscore * out,ThreeStateScore* query,ProteinDB* targetdb ); #define search_ThreeStateProtein Wise2_search_ThreeStateProtein /* Function: serial_search_ThreeStateProtein(out,query,targetdb) * * Descrip: This function makes a database search of ThreeStateProtein * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [ThreeStateScore*] * Arg: targetdb [UNKN ] Undocumented argument [ProteinDB*] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_ThreeStateProtein(Hscore * out,ThreeStateScore* query,ProteinDB* targetdb ); #define serial_search_ThreeStateProtein Wise2_serial_search_ThreeStateProtein /* Function: PackAln_bestmemory_ThreeStateProtein(query,target,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_ThreeStateProtein * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_ThreeStateProtein(ThreeStateScore* query,ComplexSequence* target ,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_ThreeStateProtein Wise2_PackAln_bestmemory_ThreeStateProtein /* Function: allocate_Expl_ThreeStateProtein(query,target,dpri) * * Descrip: This function allocates the ThreeStateProtein structure * and the basematrix area for explicit memory implementations * It calls /allocate_ThreeStateProtein_only * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [ThreeStateProtein *] * */ ThreeStateProtein * Wise2_allocate_Expl_ThreeStateProtein(ThreeStateScore* query,ComplexSequence* target ,DPRunImpl * dpri); #define allocate_Expl_ThreeStateProtein Wise2_allocate_Expl_ThreeStateProtein /* Function: recalculate_PackAln_ThreeStateProtein(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by ThreeStateProtein * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * */ void Wise2_recalculate_PackAln_ThreeStateProtein(PackAln * pal,ThreeStateProtein * mat); #define recalculate_PackAln_ThreeStateProtein Wise2_recalculate_PackAln_ThreeStateProtein /* Function: allocate_Small_ThreeStateProtein(query,target) * * Descrip: This function allocates the ThreeStateProtein structure * and the basematrix area for a small memory implementations * It calls /allocate_ThreeStateProtein_only * * * Arg: query [UNKN ] query data structure [ThreeStateScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * * Return [UNKN ] Undocumented return value [ThreeStateProtein *] * */ ThreeStateProtein * Wise2_allocate_Small_ThreeStateProtein(ThreeStateScore* query,ComplexSequence* target ); #define allocate_Small_ThreeStateProtein Wise2_allocate_Small_ThreeStateProtein /* Function: PackAln_calculate_Small_ThreeStateProtein(mat,dpenv) * * Descrip: This function calculates an alignment for ThreeStateProtein structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_ThreeStateProtein * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_ThreeStateProtein * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_ThreeStateProtein(ThreeStateProtein * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_ThreeStateProtein Wise2_PackAln_calculate_Small_ThreeStateProtein /* Function: AlnRangeSet_calculate_Small_ThreeStateProtein(mat) * * Descrip: This function calculates an alignment for ThreeStateProtein structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_ThreeStateProtein * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_ThreeStateProtein * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_ThreeStateProtein * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_ThreeStateProtein(ThreeStateProtein * mat); #define AlnRangeSet_calculate_Small_ThreeStateProtein Wise2_AlnRangeSet_calculate_Small_ThreeStateProtein /* Function: AlnRangeSet_from_ThreeStateProtein(mat) * * Descrip: This function reads off a start/end structure * for ThreeStateProtein structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_ThreeStateProtein * If you have not calculated the matrix use * /AlnRange_calculate_Small_ThreeStateProtein * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_ThreeStateProtein(ThreeStateProtein * mat); #define AlnRangeSet_from_ThreeStateProtein Wise2_AlnRangeSet_from_ThreeStateProtein /* Function: convert_PackAln_to_AlnBlock_ThreeStateProtein(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_ThreeStateProtein(PackAln * pal); #define convert_PackAln_to_AlnBlock_ThreeStateProtein Wise2_convert_PackAln_to_AlnBlock_ThreeStateProtein /* Function: PackAln_read_Expl_ThreeStateProtein(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_ThreeStateProtein(ThreeStateProtein * mat); #define PackAln_read_Expl_ThreeStateProtein Wise2_PackAln_read_Expl_ThreeStateProtein /* Function: PackAln_read_generic_ThreeStateProtein(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [ThreeStateProtein *] * Arg: h [UNKN ] Undocumented argument [ThreeStateProtein_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_ThreeStateProtein(ThreeStateProtein * mat,ThreeStateProtein_access_func_holder h); #define PackAln_read_generic_ThreeStateProtein Wise2_PackAln_read_generic_ThreeStateProtein /* Function: calculate_ThreeStateProtein(mat) * * Descrip: This function calculates the ThreeStateProtein matrix when in explicit mode * To allocate the matrix use /allocate_Expl_ThreeStateProtein * * * Arg: mat [UNKN ] ThreeStateProtein which contains explicit basematrix memory [ThreeStateProtein *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_ThreeStateProtein(ThreeStateProtein * mat); #define calculate_ThreeStateProtein Wise2_calculate_ThreeStateProtein /* Function: calculate_dpenv_ThreeStateProtein(mat,dpenv) * * Descrip: This function calculates the ThreeStateProtein matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] ThreeStateProtein which contains explicit basematrix memory [ThreeStateProtein *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_ThreeStateProtein(ThreeStateProtein * mat,DPEnvelope * dpenv); #define calculate_dpenv_ThreeStateProtein Wise2_calculate_dpenv_ThreeStateProtein /* Function: ThreeStateProtein_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ThreeStateProtein *] * */ ThreeStateProtein * Wise2_ThreeStateProtein_alloc(void); #define ThreeStateProtein_alloc Wise2_ThreeStateProtein_alloc /* Function: free_ThreeStateProtein(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ThreeStateProtein *] * * Return [UNKN ] Undocumented return value [ThreeStateProtein *] * */ ThreeStateProtein * Wise2_free_ThreeStateProtein(ThreeStateProtein * obj); #define free_ThreeStateProtein Wise2_free_ThreeStateProtein /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_ThreeStateProtein_shatter_access_main(ThreeStateProtein * mat,int i,int j,int state); #define ThreeStateProtein_shatter_access_main Wise2_ThreeStateProtein_shatter_access_main int Wise2_ThreeStateProtein_shatter_access_special(ThreeStateProtein * mat,int i,int j,int state); #define ThreeStateProtein_shatter_access_special Wise2_ThreeStateProtein_shatter_access_special void * Wise2_thread_loop_ThreeStateProtein(void * ptr); #define thread_loop_ThreeStateProtein Wise2_thread_loop_ThreeStateProtein int Wise2_score_only_ThreeStateProtein(ThreeStateScore* query,ComplexSequence* target ); #define score_only_ThreeStateProtein Wise2_score_only_ThreeStateProtein ThreeStateProtein * Wise2_allocate_ThreeStateProtein_only(ThreeStateScore* query,ComplexSequence* target ); #define allocate_ThreeStateProtein_only Wise2_allocate_ThreeStateProtein_only void Wise2_init_ThreeStateProtein(ThreeStateProtein * mat); #define init_ThreeStateProtein Wise2_init_ThreeStateProtein AlnRange * Wise2_AlnRange_build_ThreeStateProtein(ThreeStateProtein * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_ThreeStateProtein Wise2_AlnRange_build_ThreeStateProtein boolean Wise2_read_hidden_ThreeStateProtein(ThreeStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_ThreeStateProtein Wise2_read_hidden_ThreeStateProtein int Wise2_max_hidden_ThreeStateProtein(ThreeStateProtein * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_ThreeStateProtein Wise2_max_hidden_ThreeStateProtein boolean Wise2_read_special_strip_ThreeStateProtein(ThreeStateProtein * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_ThreeStateProtein Wise2_read_special_strip_ThreeStateProtein int Wise2_max_special_strip_ThreeStateProtein(ThreeStateProtein * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_ThreeStateProtein Wise2_max_special_strip_ThreeStateProtein int Wise2_max_matrix_to_special_ThreeStateProtein(ThreeStateProtein * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_ThreeStateProtein Wise2_max_matrix_to_special_ThreeStateProtein void Wise2_calculate_hidden_ThreeStateProtein(ThreeStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_ThreeStateProtein Wise2_calculate_hidden_ThreeStateProtein void Wise2_init_hidden_ThreeStateProtein(ThreeStateProtein * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_ThreeStateProtein Wise2_init_hidden_ThreeStateProtein boolean Wise2_full_dc_ThreeStateProtein(ThreeStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_ThreeStateProtein Wise2_full_dc_ThreeStateProtein boolean Wise2_do_dc_single_pass_ThreeStateProtein(ThreeStateProtein * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_ThreeStateProtein Wise2_do_dc_single_pass_ThreeStateProtein void Wise2_push_dc_at_merge_ThreeStateProtein(ThreeStateProtein * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_ThreeStateProtein Wise2_push_dc_at_merge_ThreeStateProtein void Wise2_follow_on_dc_ThreeStateProtein(ThreeStateProtein * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_ThreeStateProtein Wise2_follow_on_dc_ThreeStateProtein void Wise2_run_up_dc_ThreeStateProtein(ThreeStateProtein * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_ThreeStateProtein Wise2_run_up_dc_ThreeStateProtein void Wise2_init_dc_ThreeStateProtein(ThreeStateProtein * mat); #define init_dc_ThreeStateProtein Wise2_init_dc_ThreeStateProtein int Wise2_start_end_find_end_ThreeStateProtein(ThreeStateProtein * mat,int * endj); #define start_end_find_end_ThreeStateProtein Wise2_start_end_find_end_ThreeStateProtein boolean Wise2_dc_optimised_start_end_calc_ThreeStateProtein(ThreeStateProtein *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_ThreeStateProtein Wise2_dc_optimised_start_end_calc_ThreeStateProtein void Wise2_init_start_end_linear_ThreeStateProtein(ThreeStateProtein * mat); #define init_start_end_linear_ThreeStateProtein Wise2_init_start_end_linear_ThreeStateProtein AlnConvertSet * Wise2_AlnConvertSet_ThreeStateProtein(void); #define AlnConvertSet_ThreeStateProtein Wise2_AlnConvertSet_ThreeStateProtein int Wise2_ThreeStateProtein_explicit_access_main(ThreeStateProtein * mat,int i,int j,int state); #define ThreeStateProtein_explicit_access_main Wise2_ThreeStateProtein_explicit_access_main int Wise2_ThreeStateProtein_explicit_access_special(ThreeStateProtein * mat,int i,int j,int state); #define ThreeStateProtein_explicit_access_special Wise2_ThreeStateProtein_explicit_access_special int Wise2_find_end_ThreeStateProtein(ThreeStateProtein * mat,int * ri,int * rj,int * state,boolean * isspecial,ThreeStateProtein_access_func_holder h); #define find_end_ThreeStateProtein Wise2_find_end_ThreeStateProtein void Wise2_ThreeStateProtein_debug_show_matrix(ThreeStateProtein * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define ThreeStateProtein_debug_show_matrix Wise2_ThreeStateProtein_debug_show_matrix int Wise2_max_calc_ThreeStateProtein(ThreeStateProtein * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ThreeStateProtein_access_func_holder h); #define max_calc_ThreeStateProtein Wise2_max_calc_ThreeStateProtein int Wise2_max_calc_special_ThreeStateProtein(ThreeStateProtein * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,ThreeStateProtein_access_func_holder h); #define max_calc_special_ThreeStateProtein Wise2_max_calc_special_ThreeStateProtein #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/genephase6.c0000644000175000001440000127334510670453714016342 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genephase6.h" # line 289 "genephase6.dy" AlnBlock * AlnBlock_from_phased_protein_wrap(Protein * pro,ThreeStateModel * tsm,Genomic * gen,CodonMapper * cm,RandomModel * rm,CompMat * mat,PhasedProteinPara * ppp,GeneParameter21 * gpara,DPRunImpl * dpri,PackAln ** palret) { PackAln * pal; AlnBlock * alb; GeneParser21Score * gp21s; GeneParser4Score * gp4s; ComplexSequence * cs; ThreeStateModel * tsmin; GeneralGeneModelScore * ggms; GenePhaseModel * gpm; GenePhaseScore * gps; int i; assert(gen != NULL); assert(ppp != NULL); ggms = vanilla_GeneralGeneModelScore(gpara->ct,Bits2Probability(10),1.0,Bits2Probability(10)); if( tsm == NULL ) { if( pro == NULL ) { warn("Major problem - neither a protein nor a tsm passed into phase model"); return NULL; } tsmin = ThreeStateModel_alloc_len(pro->baseseq->len); if( pro->baseseq->name != NULL ) tsmin->name = stringalloc(pro->baseseq->name); else tsmin->name = stringalloc("NoName"); tsmin->rm = hard_link_RandomModel(rm); for(i=0;ibaseseq->len;i++) { add_ThreeStateModel(tsmin,ThreeStateUnit_from_half_bit_aminoacid(pro->baseseq->seq[i],mat,rm,ppp->gap,ppp->ext)); } } else { tsmin = hard_link_ThreeStateModel(tsm); } gpm = GenePhaseModel_from_ThreeStateModel(tsmin,cm,rm,mat,ppp); GeneWise_fold_in_synchronised_RandomModel(gpm->gw,rm,gpara->cm,gpara->ct,0.5); gps = GenePhaseScore_from_GenePhaseModel(gpm); if( (gp21s = GeneParser21Score_from_GeneParser21(gpara->gp)) == NULL) { warn("Unable to make GeneParserScore model"); return NULL; } gp4s = GeneParser4Score_from_GeneParser21Score(gp21s); if( (cs=evaluate_ComplexSequence_Genomic(gen,gpara->cses,0,Probability2Score(0.01))) == FALSE ) { warn("Unable to make ComplexSequence in TMS2DNA wrap"); } pal = PackAln_bestmemory_GenePhase6(gps,cs,gp4s,ggms,NULL,dpri); if( palret != NULL ) { *palret = pal; } alb = convert_PackAln_to_AlnBlock_GenePhase6(pal); free_GeneralGeneModelScore(ggms); free_GenePhaseModel(gpm); free_GenePhaseScore(gps); free_ComplexSequence(cs); free_GeneParser21Score(gp21s); free_GeneParser4Score(gp4s); free_ThreeStateModel(tsm); return alb; } # line 87 "genephase6.c" /***************** C functions ****************/ /* Written using dynamite */ /* Sat Sep 8 09:05:32 2007 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Users/birney/dynamite */ /*************************************************/ /* Please report any problems or bugs to */ /* Ewan Birney, birney@sanger.ac.uk */ /* basic set of macros to map states to numbers */ #define MATCH 0 #define INSERT 1 #define DELETE 2 #define INTRON_0 3 #define INTRON_1 4 #define INTRON_2 5 #define LOOP 0 #define START 1 #define END 2 #define BEFORE_MATCH_CODING 3 #define BEFORE_MATCH_INTRON_0 4 #define BEFORE_MATCH_INTRON_1 5 #define BEFORE_MATCH_INTRON_2 6 #define AFTER_MATCH_CODING 7 #define GenePhase6_EXPL_MATRIX(this_matrix,i,j,STATE) this_matrix->basematrix->matrix[((j+10)*6)+STATE][i+1] #define GenePhase6_EXPL_SPECIAL(matrix,i,j,STATE) matrix->basematrix->specmatrix[STATE][j+10] #define GenePhase6_READ_OFF_ERROR -12 #define GenePhase6_VSMALL_MATRIX(mat,i,j,STATE) mat->basematrix->matrix[(j+11)%11][((i+1)*6)+STATE] #define GenePhase6_VSMALL_SPECIAL(mat,i,j,STATE) mat->basematrix->specmatrix[(j+11)%11][STATE] #define GenePhase6_SHATTER_SPECIAL(matrix,i,j,STATE) matrix->shatter->special[STATE][j] #define GenePhase6_SHATTER_MATRIX(matrix,i,j,STATE) fetch_cell_value_ShatterMatrix(mat->shatter,i,j,STATE) /* Function: PackAln_read_Shatter_GenePhase6(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Shatter_GenePhase6(GenePhase6 * mat) { GenePhase6_access_func_holder holder; holder.access_main = GenePhase6_shatter_access_main; holder.access_special = GenePhase6_shatter_access_special; assert(mat); assert(mat->shatter); return PackAln_read_generic_GenePhase6(mat,holder); } /* Function: GenePhase6_shatter_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GenePhase6_shatter_access_main(GenePhase6 * mat,int i,int j,int state) { return GenePhase6_SHATTER_MATRIX(mat,i,j,state); } /* Function: GenePhase6_shatter_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GenePhase6_shatter_access_special(GenePhase6 * mat,int i,int j,int state) { return GenePhase6_SHATTER_SPECIAL(mat,i,j,state); } /* Function: calculate_shatter_GenePhase6(mat,dpenv) * * Descrip: This function calculates the GenePhase6 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GenePhase6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_shatter_GenePhase6(GenePhase6 * mat,DPEnvelope * dpenv) { int i; int j; int k; int should_calc; int leni; int lenj; int tot; int num; int starti; int startj; int endi; int endj; int * SIG_0_0; int * SIG_1_3; int * SIG_1_6; int * SIG_1_5; int * SIG_1_4; int * SIG_1_2; int * SIG_1_1; int * SIG_0_3; int * SIG_0_6; int * SIG_0_5; int * SIG_0_4; int * SIG_0_2; int * SIG_0_1; int * SIG_1_0; int * SIG_0_8; int * SIG_0_9; int * SIG_0_10; leni = mat->leni; lenj = mat->lenj; mat->shatter = new_ShatterMatrix(dpenv,6,lenj,8); prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; start_reporting("GenePhase6 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i < (u->starti+u->height) && j < (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) continue; SIG_0_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i,j); SIG_1_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-3); SIG_1_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-6); SIG_1_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-5); SIG_1_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-4); SIG_1_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-2); SIG_1_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-1); SIG_0_3 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-3); SIG_0_6 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-6); SIG_0_5 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-5); SIG_0_4 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-4); SIG_0_2 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-2); SIG_0_1 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-1); SIG_1_0 = fetch_cell_from_ShatterMatrix(mat->shatter,i-1,j-0); SIG_0_8 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-8); SIG_0_9 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-9); SIG_0_10 = fetch_cell_from_ShatterMatrix(mat->shatter,i-0,j-10); /* For state MATCH */ /* setting first movement to score */ score = SIG_1_3[MATCH] + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = SIG_1_3[INSERT] + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = SIG_1_3[DELETE] + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GenePhase6_SHATTER_SPECIAL(mat,i-1,j-3,START) + ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_MATCH_CODING to state MATCH */ temp = GenePhase6_SHATTER_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = SIG_1_6[INTRON_0] + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = SIG_1_5[INTRON_1] + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = SIG_1_4[INTRON_2] + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_2[MATCH] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_1[MATCH] + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_4[MATCH] + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = SIG_1_5[MATCH] + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[MATCH] = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GenePhase6_SHATTER_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* state MATCH is a source for special AFTER_MATCH_CODING */ temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GenePhase6_SHATTER_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) { GenePhase6_SHATTER_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = SIG_0_3[MATCH] + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = SIG_0_3[INSERT] + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = SIG_0_3[DELETE] + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = GenePhase6_SHATTER_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = SIG_0_6[INTRON_0] + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = SIG_0_5[INTRON_1] + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = SIG_0_4[INTRON_2] + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_2[INSERT] + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = SIG_0_1[INSERT] + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); SIG_0_0[INSERT] = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GenePhase6_SHATTER_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = SIG_1_0[MATCH] + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = SIG_1_0[INSERT] + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = SIG_1_0[DELETE] + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ SIG_0_0[DELETE] = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GenePhase6_SHATTER_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_SHATTER_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = SIG_0_8[MATCH] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0); /* From state INSERT to state INTRON_0 */ temp = SIG_0_8[INSERT] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = SIG_0_1[INTRON_0] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_0] = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = SIG_0_9[MATCH] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1); /* From state INSERT to state INTRON_1 */ temp = SIG_0_9[INSERT] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = SIG_0_1[INTRON_1] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_1] = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = SIG_0_10[MATCH] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2); /* From state INSERT to state INTRON_2 */ temp = SIG_0_10[INSERT] + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = SIG_0_1[INTRON_2] + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ SIG_0_0[INTRON_2] = score; /* Finished calculating state INTRON_2 */ } /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_SHATTER_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_SHATTER_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_SHATTER_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Source AFTER_MATCH_CODING is a special source for END */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_SHATTER_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_CODING); /* Source START is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 6,BEFORE_MATCH_INTRON_0) + (CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 5,BEFORE_MATCH_INTRON_1) + (CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 4,BEFORE_MATCH_INTRON_2) + (CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score; /* Finished updating state BEFORE_MATCH_CODING */ /* Special state BEFORE_MATCH_INTRON_0 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_0 */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_INTRON_0 */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_0) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0) = score; /* Finished updating state BEFORE_MATCH_INTRON_0 */ /* Special state BEFORE_MATCH_INTRON_1 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_1 */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 9,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_INTRON_1 */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_1) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1) = score; /* Finished updating state BEFORE_MATCH_INTRON_1 */ /* Special state BEFORE_MATCH_INTRON_2 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_2 */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 10,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_INTRON_2 */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_2) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_SHATTER_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2) = score; /* Finished updating state BEFORE_MATCH_INTRON_2 */ /* Special state AFTER_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_SHATTER_SPECIAL(mat,0,j,AFTER_MATCH_CODING); /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */ temp = GenePhase6_SHATTER_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_SHATTER_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score; /* Finished updating state AFTER_MATCH_CODING */ } stop_reporting(); return TRUE; } /* Function: search_GenePhase6(dbsi,out,query,targetdb,gp,general_model) * * Descrip: This function makes a database search of GenePhase6 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [GenePhaseScore*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: general_model [UNKN ] Undocumented argument [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type search_GenePhase6(DBSearchImpl * dbsi,Hscore * out,GenePhaseScore* query,GenomicDB* targetdb ,GeneParser4Score * gp,GeneralGeneModelScore * general_model) { #ifdef PTHREAD int i; int thr_no; pthread_attr_t pat; struct thread_pool_holder_GenePhase6 * holder; #endif if( out == NULL ) { warn("Passed in a null Hscore object into search_GenePhase6. Can't process results!"); return SEARCH_ERROR; } if( dbsi == NULL ) { warn("Passed in a null DBSearchImpl object into search_GenePhase6. Can't process results!"); return SEARCH_ERROR; } if( dbsi->trace_level > 5 ) warn("Asking for trace level of %d in database search for GenePhase6, but it was compiled with a trace level of -2139062144. Not all trace statements can be shown",dbsi->trace_level); switch(dbsi->type) { /*switch on implementation*/ case DBSearchImpl_Serial : return serial_search_GenePhase6(out,query, targetdb ,gp,general_model); case DBSearchImpl_Pthreads : #ifdef PTHREAD holder = (struct thread_pool_holder_GenePhase6 *) ckalloc(sizeof(struct thread_pool_holder_GenePhase6)); if( holder == NULL ) { warn("Unable to allocated thread pool datastructure..."); return SEARCH_ERROR; } holder->out = out; holder->dbsi = dbsi; holder->query = query; holder->targetdb = targetdb; holder->gp = gp; holder->general_model = general_model; if( pthread_mutex_init(&(holder->input_lock),NULL) != 0 ) fatal("Unable to iniated input mutex lock"); if( pthread_mutex_init(&(holder->output_lock),NULL) != 0 ) fatal("Unable to iniated output mutex lock"); /* Let us rock! */ thr_no = number_of_threads_DBSearchImpl(dbsi); holder->pool = ckcalloc (thr_no,sizeof(pthread_t)); if( holder->pool == NULL ) { warn("Unable to allocated thread pools"); return SEARCH_ERROR; } /* Build a thread attribute to make sure we get the most out of SMP boxes */ pthread_attr_init(&pat); /* Give thread libraries a hint that threads should be kernel threads */ #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(thr_no+1); #endif /* set concurrency */ for(i=0;ipool+i,&pat,thread_loop_GenePhase6,(void *)holder) ) fatal("Unable to create a thread!"); } /* Now - wait for all the threads to exit */ for(i=0;ipool[i],NULL) != 0 ) fatal("Unable to join a thread!"); } /* Deallocate the thread structures */ ckfree(holder->pool); ckfree(holder); return SEARCH_OK; #else /* not compiled with threads */ warn("You did not specifiy the PTHREAD compile when compiled the C code for GenePhase6"); #endif /* finished threads */ default : warn("database search implementation %s was not provided in the compiled dynamite file from GenePhase6",impl_string_DBSearchImpl(dbsi)); return SEARCH_ERROR; } /* end of switch on implementation */ } /* Function: thread_loop_GenePhase6(ptr) * * Descrip: dummy loop code foreach thread for GenePhase6 * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * thread_loop_GenePhase6(void * ptr) { fatal("dummy thread loop function"); } /* Function: serial_search_GenePhase6(out,query,targetdb,gp,general_model) * * Descrip: This function makes a database search of GenePhase6 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [GenePhaseScore*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: general_model [UNKN ] Undocumented argument [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type serial_search_GenePhase6(Hscore * out,GenePhaseScore* query,GenomicDB* targetdb ,GeneParser4Score * gp,GeneralGeneModelScore * general_model) { ComplexSequence* target; int db_status; int score; int query_pos = 0; int target_pos = 0; DataScore * ds; push_errormsg_stack("Before any actual search in db searching"); target_pos = 0; target = init_GenomicDB(targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GenePhase6, got a database init error on the target [target] database"); return SEARCH_ERROR; } for(;;) { /*For all target entries*/ /* No maximum length - allocated on-the-fly */ score = score_only_GenePhase6(query, target , gp, general_model); if( should_store_Hscore(out,score) == TRUE ) { /*if storing datascore*/ ds = new_DataScore_from_storage(out); if( ds == NULL ) { warn("GenePhase6 search had a memory error in allocating a new_DataScore (?a leak somewhere - DataScore is a very small datastructure"); return SEARCH_ERROR; } /* Now: add query/target information to the entry */ dataentry_add_GenomicDB(ds->target,target,targetdb); ds->score = score; add_Hscore(out,ds); } /* end of if storing datascore */ pop_errormsg_stack(); push_errormsg_stack("DB searching: just finished [Query Pos: %d] [Target Pos: %d]",query_pos,target_pos); target = reload_GenomicDB(target,targetdb,&db_status); if( db_status == DB_RETURN_ERROR ) { warn("In searching GenePhase6, Reload error on database target, position %d,%d",query_pos,target_pos); return SEARCH_ERROR; } if( db_status == DB_RETURN_END ) break; /* Out of target loop */ target_pos++; } /* end of For all target entries */ close_GenomicDB(target,targetdb); pop_errormsg_stack(); return SEARCH_OK; } /* Function: score_only_GenePhase6(query,target,gp,general_model) * * Descrip: This function just calculates the score for the matrix * I am pretty sure we can do this better, but hey, for the moment... * It calls /allocate_GenePhase6_only * * * Arg: query [UNKN ] query data structure [GenePhaseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [int] * */ int score_only_GenePhase6(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model) { int bestscore = NEGI; int i; int j; int k; GenePhase6 * mat; mat = allocate_GenePhase6_only(query, target , gp, general_model); if( mat == NULL ) { warn("Memory allocation error in the db search - unable to communicate to calling function. this spells DIASTER!"); return NEGI; } if((mat->basematrix = BaseMatrix_alloc_matrix_and_specials(11,(mat->leni + 1) * 6,11,8)) == NULL) { warn("Score only matrix for GenePhase6 cannot be allocated, (asking for 10 by %d cells)",mat->leni*6); mat = free_GenePhase6(mat); return 0; } mat->basematrix->type = BASEMATRIX_TYPE_VERYSMALL; /* Now, initiate matrix */ for(j=0;j<12;j++) { for(i=(-1);ileni;i++) { for(k=0;k<6;k++) GenePhase6_VSMALL_MATRIX(mat,i,j,k) = NEGI; } GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) = NEGI; GenePhase6_VSMALL_SPECIAL(mat,i,j,START) = 0; GenePhase6_VSMALL_SPECIAL(mat,i,j,END) = NEGI; GenePhase6_VSMALL_SPECIAL(mat,i,j,BEFORE_MATCH_CODING) = NEGI; GenePhase6_VSMALL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_0) = NEGI; GenePhase6_VSMALL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_1) = NEGI; GenePhase6_VSMALL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_2) = NEGI; GenePhase6_VSMALL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = NEGI; } /* Ok, lets do-o-o-o-o it */ for(j=0;jlenj;j++) { /*for all target positions*/ auto int score; auto int temp; for(i=0;ileni;i++) { /*for all query positions*/ /* For state MATCH */ /* setting first movement to score */ score = GenePhase6_VSMALL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GenePhase6_VSMALL_SPECIAL(mat,i-1,j-3,START) + ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_MATCH_CODING to state MATCH */ temp = GenePhase6_VSMALL_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_VSMALL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* state MATCH is a source for special AFTER_MATCH_CODING */ temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GenePhase6_VSMALL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) { GenePhase6_VSMALL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GenePhase6_VSMALL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = GenePhase6_VSMALL_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_VSMALL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GenePhase6_VSMALL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GenePhase6_VSMALL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GenePhase6_VSMALL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_VSMALL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GenePhase6_VSMALL_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0); /* From state INSERT to state INTRON_0 */ temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GenePhase6_VSMALL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GenePhase6_VSMALL_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1); /* From state INSERT to state INTRON_1 */ temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GenePhase6_VSMALL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GenePhase6_VSMALL_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2); /* From state INSERT to state INTRON_2 */ temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GenePhase6_VSMALL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GenePhase6_VSMALL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of for all query positions */ /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_VSMALL_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_VSMALL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_VSMALL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Source AFTER_MATCH_CODING is a special source for END */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_VSMALL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING); /* Source START is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 6,BEFORE_MATCH_INTRON_0) + (CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 5,BEFORE_MATCH_INTRON_1) + (CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 4,BEFORE_MATCH_INTRON_2) + (CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score; /* Finished updating state BEFORE_MATCH_CODING */ /* Special state BEFORE_MATCH_INTRON_0 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_0 */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_INTRON_0 */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_0) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0) = score; /* Finished updating state BEFORE_MATCH_INTRON_0 */ /* Special state BEFORE_MATCH_INTRON_1 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_1 */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 9,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_INTRON_1 */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_1) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1) = score; /* Finished updating state BEFORE_MATCH_INTRON_1 */ /* Special state BEFORE_MATCH_INTRON_2 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_2 */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 10,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_INTRON_2 */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_2) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_VSMALL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2) = score; /* Finished updating state BEFORE_MATCH_INTRON_2 */ /* Special state AFTER_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_VSMALL_SPECIAL(mat,0,j,AFTER_MATCH_CODING); /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */ temp = GenePhase6_VSMALL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_VSMALL_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score; /* Finished updating state AFTER_MATCH_CODING */ if( bestscore < GenePhase6_VSMALL_SPECIAL(mat,0,j,END) ) bestscore = GenePhase6_VSMALL_SPECIAL(mat,0,j,END); } /* end of for all target positions */ mat = free_GenePhase6(mat); return bestscore; } /* Function: PackAln_bestmemory_GenePhase6(query,target,gp,general_model,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GenePhase6 * * * Arg: query [UNKN ] query data structure [GenePhaseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_bestmemory_GenePhase6(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model,DPEnvelope * dpenv,DPRunImpl * dpri) { long long total; GenePhase6 * mat; PackAln * out; DebugMatrix * de; DPRunImplMemory strategy; assert(dpri); total = query->len * target->seq->len; if( dpri->memory == DPIM_Default ) { if( (total * 6 * sizeof(int)) > 1000*dpri->kbyte_size) { strategy = DPIM_Linear; } else { strategy = DPIM_Explicit; } } else { strategy = dpri->memory; } if( dpenv != NULL ) { if( strategy == DPIM_Explicit) { if( (mat=allocate_Expl_GenePhase6(query, target , gp, general_model,dpri)) == NULL ) { warn("Unable to allocate large GenePhase6 version"); return NULL; } calculate_dpenv_GenePhase6(mat,dpenv); out = PackAln_read_Expl_GenePhase6(mat); } else { mat = allocate_GenePhase6_only(query, target , gp, general_model); calculate_shatter_GenePhase6(mat,dpenv); out = PackAln_read_Shatter_GenePhase6(mat); } } else { if( strategy == DPIM_Linear ) { /* use small implementation */ if( (mat=allocate_Small_GenePhase6(query, target , gp, general_model)) == NULL ) { warn("Unable to allocate small GenePhase6 version"); return NULL; } out = PackAln_calculate_Small_GenePhase6(mat,dpenv); } else { /* use Large implementation */ if( (mat=allocate_Expl_GenePhase6(query, target , gp, general_model,dpri)) == NULL ) { warn("Unable to allocate large GenePhase6 version"); return NULL; } if( dpri->debug == TRUE) { fatal("Asked for dydebug, but dynamite file not compiled with -g. Need to recompile dynamite source"); } else { calculate_GenePhase6(mat); out = PackAln_read_Expl_GenePhase6(mat); } } } mat = free_GenePhase6(mat); return out; } /* Function: allocate_GenePhase6_only(query,target,gp,general_model) * * Descrip: This function only allocates the GenePhase6 structure * checks types where possible and determines leni and lenj * The basematrix area is delt with elsewhere * * * Arg: query [UNKN ] query data structure [GenePhaseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [GenePhase6 *] * */ GenePhase6 * allocate_GenePhase6_only(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model) { GenePhase6 * out; if((out= GenePhase6_alloc()) == NULL) { warn("Allocation of basic GenePhase6 structure failed..."); return NULL; } out->query = query; out->target = target; out->gp = gp; out->general_model = general_model; out->leni = query->len; out->lenj = target->seq->len; return out; } /* Function: allocate_Expl_GenePhase6(query,target,gp,general_model,dpri) * * Descrip: This function allocates the GenePhase6 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GenePhase6_only * * * Arg: query [UNKN ] query data structure [GenePhaseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GenePhase6 *] * */ GenePhase6 * allocate_Expl_GenePhase6(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model,DPRunImpl * dpri) { GenePhase6 * out; out = allocate_GenePhase6_only(query, target , gp, general_model); if( out == NULL ) return NULL; if( dpri->should_cache == TRUE ) { if( dpri->cache != NULL ) { if( dpri->cache->maxleni >= (out->lenj+10)*6 && dpri->cache->maxlenj >= (out->leni+1)) out->basematrix = hard_link_BaseMatrix(dpri->cache); else dpri->cache = free_BaseMatrix(dpri->cache); } } if( out->basematrix == NULL ) { if( (out->basematrix = BaseMatrix_alloc_matrix_and_specials((out->lenj+10)*6,(out->leni+1),8,out->lenj+10)) == NULL) { warn("Explicit matrix GenePhase6 cannot be allocated, (asking for %d by %d main cells)",out->leni,out->lenj); free_GenePhase6(out); return NULL; } } if( dpri->should_cache == TRUE && dpri->cache == NULL) dpri->cache = hard_link_BaseMatrix(out->basematrix); out->basematrix->type = BASEMATRIX_TYPE_EXPLICIT; init_GenePhase6(out); return out; } /* Function: init_GenePhase6(mat) * * Descrip: This function initates GenePhase6 matrix when in explicit mode * Called in /allocate_Expl_GenePhase6 * * * Arg: mat [UNKN ] GenePhase6 which contains explicit basematrix memory [GenePhase6 *] * */ void init_GenePhase6(GenePhase6 * mat) { register int i; register int j; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT) { warn("Cannot iniate matrix, is not an explicit memory type and you have assummed that"); return; } for(i= (-1);iquery->len;i++) { for(j= (-10);j<11;j++) { GenePhase6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } } for(j= (-10);jtarget->seq->len;j++) { for(i= (-1);i<2;i++) { GenePhase6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = NEGI; GenePhase6_EXPL_SPECIAL(mat,i,j,START) = 0; GenePhase6_EXPL_SPECIAL(mat,i,j,END) = NEGI; GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_CODING) = NEGI; GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_0) = NEGI; GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_1) = NEGI; GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_2) = NEGI; GenePhase6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = NEGI; } return; } /* Function: recalculate_PackAln_GenePhase6(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GenePhase6 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * */ void recalculate_PackAln_GenePhase6(PackAln * pal,GenePhase6 * mat) { int i,j,k,offi,offj; PackAlnUnit * prev; PackAlnUnit * pau; for(k=1,prev=pal->pau[0];k < pal->len;k++,prev=pau) { pau = pal->pau[k]; i = pau->i; j = pau->j; offi = pau->i - prev->i; offj = pau->j - prev->j; switch(pau->state) { case MATCH : if( offi == 1 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (START+6) ) { pau->score = ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (BEFORE_MATCH_CODING+6) ) { pau->score = (mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 6 && prev->state == INTRON_0 ) { pau->score = (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == INTRON_1 ) { pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-2)) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == INTRON_2 ) { pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-1)) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 2 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 1 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 4 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_INSERT_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 1 && offj == 5 && prev->state == MATCH ) { pau->score = mat->gp->transition[GP4_INSERT_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state MATCH, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INSERT : if( offi == 0 && offj == 3 && prev->state == MATCH ) { pau->score = (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == INSERT ) { pau->score = (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 3 && prev->state == DELETE ) { pau->score = (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offj == 3 && prev->state == (LOOP+6) ) { pau->score = ((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 6 && prev->state == INTRON_0 ) { pau->score = (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 5 && prev->state == INTRON_1 ) { pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-2)) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 4 && prev->state == INTRON_2 ) { pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-1)) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 2 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_1_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } if( offi == 0 && offj == 1 && prev->state == INSERT ) { pau->score = mat->gp->transition[GP4_DELETE_2_BASE] + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); continue; } warn("In recaluclating PackAln with state INSERT, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case DELETE : if( offi == 1 && offj == 0 && prev->state == MATCH ) { pau->score = mat->query->gws->seg[i]->transition[GW_MATCH2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == INSERT ) { pau->score = mat->query->gws->seg[i]->transition[GW_INSERT2DELETE] + (0); continue; } if( offi == 1 && offj == 0 && prev->state == DELETE ) { pau->score = mat->query->gws->seg[i]->transition[GW_DELETE2DELETE] + (0); continue; } warn("In recaluclating PackAln with state DELETE, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_0 : if( offi == 0 && offj == 8 && prev->state == MATCH ) { pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0) + (0); continue; } if( offi == 0 && offj == 8 && prev->state == INSERT ) { pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_0 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_0, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_1 : if( offi == 0 && offj == 9 && prev->state == MATCH ) { pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1) + (0); continue; } if( offi == 0 && offj == 9 && prev->state == INSERT ) { pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_1 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_1, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case INTRON_2 : if( offi == 0 && offj == 10 && prev->state == MATCH ) { pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2) + (0); continue; } if( offi == 0 && offj == 10 && prev->state == INSERT ) { pau->score = ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron) + (0); continue; } if( offi == 0 && offj == 1 && prev->state == INTRON_2 ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state INTRON_2, from [%d,%d,%d], got a bad source state. Error!",offi,offj,prev->state); break; case (LOOP+6) : if( offj == 1 && prev->state == (START+6) ) { pau->score = 0 + (0); continue; } if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->gws->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 0 && prev->state == INSERT ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->gws->seg[i]->transition[GW_INSERT2END] + (0); continue; } if( offj == 0 && prev->state == DELETE ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->gws->seg[i]->transition[GW_DELETE2END] + (0); continue; } if( offj == 1 && prev->state == (LOOP+6) ) { pau->score = mat->gp->transition[GP4_LOOP2LOOP] + (0); continue; } warn("In recaluclating PackAln with state LOOP, got a bad source state. Error!"); break; case (START+6) : warn("In recaluclating PackAln with state START, got a bad source state. Error!"); break; case (END+6) : if( offj == 1 && prev->state == (LOOP+6) ) { pau->score = 0 + (0); continue; } if( offj == 3 && prev->state == (AFTER_MATCH_CODING+6) ) { pau->score = mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)] + (0); continue; } warn("In recaluclating PackAln with state END, got a bad source state. Error!"); break; case (BEFORE_MATCH_CODING+6) : if( offj == 3 && prev->state == (START+6) ) { pau->score = mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)] + (0); continue; } if( offj == 3 && prev->state == (BEFORE_MATCH_CODING+6) ) { pau->score = mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)] + (0); continue; } if( offj == 6 && prev->state == (BEFORE_MATCH_INTRON_0+6) ) { pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-3)) + (0); continue; } if( offj == 5 && prev->state == (BEFORE_MATCH_INTRON_1+6) ) { pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-2)) + (0); continue; } if( offj == 4 && prev->state == (BEFORE_MATCH_INTRON_2+6) ) { pau->score = CSEQ_GENOMIC_3SS(mat->target,(j-1)) + (0); continue; } warn("In recaluclating PackAln with state BEFORE_MATCH_CODING, got a bad source state. Error!"); break; case (BEFORE_MATCH_INTRON_0+6) : if( offj == 1 && prev->state == (BEFORE_MATCH_CODING+6) ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j)) + (0); continue; } if( offj == 1 && prev->state == (BEFORE_MATCH_INTRON_0+6) ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state BEFORE_MATCH_INTRON_0, got a bad source state. Error!"); break; case (BEFORE_MATCH_INTRON_1+6) : if( offj == 9 && prev->state == (BEFORE_MATCH_CODING+6) ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offj == 1 && prev->state == (BEFORE_MATCH_INTRON_1+6) ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state BEFORE_MATCH_INTRON_1, got a bad source state. Error!"); break; case (BEFORE_MATCH_INTRON_2+6) : if( offj == 10 && prev->state == (BEFORE_MATCH_CODING+6) ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7))) + (0); continue; } if( offj == 1 && prev->state == (BEFORE_MATCH_INTRON_2+6) ) { pau->score = (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) + (0); continue; } warn("In recaluclating PackAln with state BEFORE_MATCH_INTRON_2, got a bad source state. Error!"); break; case (AFTER_MATCH_CODING+6) : if( offj == 0 && prev->state == MATCH ) { /* i here comes from the previous state ;) - not the real one */ i = prev->i; pau->score = mat->query->gws->seg[i]->transition[GW_MATCH2END] + (0); continue; } if( offj == 3 && prev->state == (AFTER_MATCH_CODING+6) ) { pau->score = mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)] + (0); continue; } warn("In recaluclating PackAln with state AFTER_MATCH_CODING, got a bad source state. Error!"); break; default : warn("In recaluclating PackAln got a bad recipient state. Error!"); } prev = pau; } return; } /* divide and conquor macros are next */ #define GenePhase6_HIDDEN_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[(j-hiddenj+10)][(i+1)*6+state]) #define GenePhase6_DC_SHADOW_MATRIX(thismatrix,i,j,state) (thismatrix->basematrix->matrix[((j+11)*8) % 88][(i+1)*6+state]) #define GenePhase6_HIDDEN_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state][(j+10)]) #define GenePhase6_DC_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) #define GenePhase6_DC_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->matrix[((((j+11)*8)+(shadow+1)) % 88)][(i+1)*6 + state]) #define GenePhase6_DC_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) #define GenePhase6_DC_OPT_SHADOW_MATRIX(thismatrix,i,j,state) (score_pointers[(((j+10)% 10) * (leni+1) * 6) + ((i+1) * 6) + (state)]) #define GenePhase6_DC_OPT_SHADOW_MATRIX_SP(thismatrix,i,j,state,shadow) (shadow_pointers[(((j+10)% 10) * (leni+1) * 48) + ((i+1) * 48) + (state * 8) + shadow+1]) #define GenePhase6_DC_OPT_SHADOW_SPECIAL(thismatrix,i,j,state) (thismatrix->basematrix->specmatrix[state*8][(j+10)]) /* Function: allocate_Small_GenePhase6(query,target,gp,general_model) * * Descrip: This function allocates the GenePhase6 structure * and the basematrix area for a small memory implementations * It calls /allocate_GenePhase6_only * * * Arg: query [UNKN ] query data structure [GenePhaseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [GenePhase6 *] * */ #define GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(thismatrix,i,j,state,shadow) (thismatrix->basematrix->specmatrix[state*8 +shadow+1][(j+10)]) GenePhase6 * allocate_Small_GenePhase6(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model) { GenePhase6 * out; out = allocate_GenePhase6_only(query, target , gp, general_model); if( out == NULL ) return NULL; out->basematrix = BaseMatrix_alloc_matrix_and_specials(88,(out->leni + 1) * 6,64,out->lenj+10); if(out == NULL) { warn("Small shadow matrix GenePhase6 cannot be allocated, (asking for 11 by %d main cells)",out->leni+2); free_GenePhase6(out); return NULL; } out->basematrix->type = BASEMATRIX_TYPE_SHADOW; return out; } /* Function: PackAln_calculate_Small_GenePhase6(mat,dpenv) * * Descrip: This function calculates an alignment for GenePhase6 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GenePhase6 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GenePhase6 * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_calculate_Small_GenePhase6(GenePhase6 * mat,DPEnvelope * dpenv) { int endj; int score; PackAln * out; PackAlnUnit * pau; int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int temp; int donej; /* This is for reporting, will be passed as a & arg in */ int totalj; /* This also is for reporting, but as is not changed, can be passed by value */ if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW ) { warn("Could not calculate packaln small for GenePhase6 due to wrong type of matrix"); return NULL; } out = PackAln_alloc_std(); start_reporting("Find start end points: "); dc_optimised_start_end_calc_GenePhase6(mat,dpenv); score = start_end_find_end_GenePhase6(mat,&endj); out->score = score; stopstate = END; /* Special to specials: have to eat up in strip and then drop back to full_dc for intervening bits */ log_full_error(REPORT,0,"End at %d Score %d",endj,score); stop_reporting(); for(;;) { /*while there are more special bits to recover*/ start_reporting("Special cell aln end %d:",endj); if( read_special_strip_GenePhase6(mat,0,endj,stopstate,&endj,&startstate,out) == FALSE ) { warn("Problem in reading off special state system... going to return partial alignment"); break; } if( startstate == START || endj <= 0) { log_full_error(REPORT,0,"Recovered complete alignment"); stop_reporting(); break; } log_full_error(REPORT,0,"Finished to %d",endj); stop_reporting(); /* Ok... have to eat up another piece of matrix */ temp = startstate; starti = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,0); startj = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,1); startstate = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,2); stopi = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,3); stopj = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,4); stopstate = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,5); /* Get out the score of this block. V. important! */ temp = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,endj,temp,6); totalj = stopj - startj; donej = 0; start_reporting("Main matrix aln [%d,%d]:",startj,stopj); if(full_dc_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,out,&donej,totalj,dpenv) == FALSE) { warn("In the alignment GenePhase6 [%d,%d][%d,%d], got a problem. Please report bug ... giving you back a partial alignment",starti,startj,stopi,stopj); return out; } /* now have to figure out which special we came from... yikes */ max_matrix_to_special_GenePhase6(mat,starti,startj,startstate,temp,&stopi,&stopj,&stopstate,&temp,NULL); if( stopi == GenePhase6_READ_OFF_ERROR) { warn("In GenePhase6 read off ending at %d ... got a bad matrix to special read off... returning partial alignment",startj); invert_PackAln(out); recalculate_PackAln_GenePhase6(out,mat); return out; } /* if at start, break, otherwise, back to eat another strip */ if( stopstate == START) { log_full_error(REPORT,0,"Recovered complete alignment "); stop_reporting(); break; } log_full_error(REPORT,0,"Finished alignment to %d ",startj); stop_reporting(); endj = stopj; /* stopstate is correct as it is */ } /* end of while there are more special bits to recover */ invert_PackAln(out); recalculate_PackAln_GenePhase6(out,mat); return out; } /* Function: AlnRangeSet_calculate_Small_GenePhase6(mat) * * Descrip: This function calculates an alignment for GenePhase6 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GenePhase6 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GenePhase6 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GenePhase6 * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_calculate_Small_GenePhase6(GenePhase6 * mat) { AlnRangeSet * out; start_reporting("Find start end points: "); dc_optimised_start_end_calc_GenePhase6(mat,NULL); log_full_error(REPORT,0,"Calculated"); out = AlnRangeSet_from_GenePhase6(mat); return out; } /* Function: AlnRangeSet_from_GenePhase6(mat) * * Descrip: This function reads off a start/end structure * for GenePhase6 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GenePhase6 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GenePhase6 * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_from_GenePhase6(GenePhase6 * mat) { AlnRangeSet * out; AlnRange * temp; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GenePhase6"); return NULL; } out = AlnRangeSet_alloc_std(); /* Find the end position */ out->score = start_end_find_end_GenePhase6(mat,&jpos); state = END; while( (temp = AlnRange_build_GenePhase6(mat,jpos,state,&jpos,&state)) != NULL) add_AlnRangeSet(out,temp); return out; } /* Function: AlnRange_build_GenePhase6(mat,stopj,stopspecstate,startj,startspecstate) * * Descrip: This function calculates a single start/end set in linear space * Really a sub-routine for /AlnRangeSet_from_PackAln_GenePhase6 * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopspecstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startspecstate [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_build_GenePhase6(GenePhase6 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate) { AlnRange * out; int jpos; int state; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("Bad error! - non shadow matrix type in AlnRangeSet_from_GenePhase6"); return NULL; } /* Assumme that we have specials (we should!). Read back along the specials till we have the finish point */ if( read_special_strip_GenePhase6(mat,0,stopj,stopspecstate,&jpos,&state,NULL) == FALSE) { warn("In AlnRanger_build_GenePhase6 alignment ending at %d, unable to read back specials. Will (evenutally) return a partial range set... BEWARE!",stopj); return NULL; } if( state == START || jpos <= 0) return NULL; out = AlnRange_alloc(); out->starti = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,0); out->startj = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,1); out->startstate = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,2); out->stopi = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,3); out->stopj = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,4); out->stopstate = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,5); out->startscore = GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,jpos,state,6); out->stopscore = GenePhase6_DC_SHADOW_SPECIAL(mat,0,jpos,state); /* Now, we have to figure out where this state came from in the specials */ max_matrix_to_special_GenePhase6(mat,out->starti,out->startj,out->startstate,out->startscore,&jpos,startj,startspecstate,&state,NULL); if( jpos == GenePhase6_READ_OFF_ERROR) { warn("In AlnRange_build_GenePhase6 alignment ending at %d, with aln range between %d-%d in j, unable to find source special, returning this range, but this could get tricky!",stopj,out->startj,out->stopj); return out; } /* Put in the correct score for startstate, from the special */ out->startscore = GenePhase6_DC_SHADOW_SPECIAL(mat,0,*startj,*startspecstate); /* The correct j coords have been put into startj, startspecstate... so just return out */ return out; } /* Function: read_hidden_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_hidden_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; /* We don't need hiddenj here, 'cause matrix access handled by max funcs */ PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = FALSE; while( i >= starti && j >= startj) { /* Put away current i,j,state */ pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); max_hidden_GenePhase6(mat,startj,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GenePhase6_READ_OFF_ERROR) { warn("In GenePhase6 hidden read off, between %d:%d,%d:%d - at got bad read off. Problem!",starti,startj,stopi,stopj); return FALSE; } if( i == starti && j == startj && state == startstate) { /* Put away final state (start of this block) */ pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state; add_PackAln(out,pau); return TRUE; } if( i == starti && j == startj) { warn("In GenePhase6 hidden read off, between %d:%d,%d:%d - hit start cell, but not in start state. Can't be good!.",starti,startj,stopi,stopj); return FALSE; } } warn("In GenePhase6 hidden read off, between %d:%d,%d:%d - gone past start cell (now in %d,%d,%d), can't be good news!.",starti,startj,stopi,stopj,i,j,state); return FALSE; } /* Function: max_hidden_GenePhase6(mat,hiddenj,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: hiddenj [UNKN ] Undocumented argument [int] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_hidden_GenePhase6(GenePhase6 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GenePhase6_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GenePhase6 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = GenePhase6_HIDDEN_MATRIX(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp->transition[GP4_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-5,MATCH); } return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->gp->transition[GP4_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-4,MATCH); } return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-1,MATCH); } return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-2,MATCH); } return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 2,MATCH); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON_2) ) { *reti = i - 1; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-4,INTRON_2); } return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 4,INTRON_2); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON_1) ) { *reti = i - 1; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-5,INTRON_1); } return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 5,INTRON_1); } temp = cscore - ((mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON_0) ) { *reti = i - 1; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-6,INTRON_0); } return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 6,INTRON_0); } /* Not allowing special sources.. skipping BEFORE_MATCH_CODING */ /* Not allowing special sources.. skipping START */ temp = cscore - ((mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-3,DELETE); } return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-3,INSERT); } return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-3,MATCH); } return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INSERT); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-2,INSERT); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 2,INSERT); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 5,INTRON_1); } temp = cscore - ((mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 6,INTRON_0); } /* Not allowing special sources.. skipping LOOP */ temp = cscore - ((mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-3,DELETE); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-3,INSERT); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-3,MATCH); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->gws->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-0,DELETE); } return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->gws->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-0,INSERT); } return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->gws->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-1,j-0,MATCH); } return GenePhase6_HIDDEN_MATRIX(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_0); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron)) - (0); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-8,INSERT); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 8,INSERT); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0)) - (0); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-8,MATCH); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_1); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron)) - (0); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-9,INSERT); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 9,INSERT); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1)) - (0); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-9,MATCH); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 1,INTRON_2); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron)) - (0); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-10,INSERT); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 10,INSERT); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2)) - (0); if( temp == GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_HIDDEN_MATRIX(mat,i-0,j-10,MATCH); } return GenePhase6_HIDDEN_MATRIX(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: read_special_strip_GenePhase6(mat,stopi,stopj,stopstate,startj,startstate,out) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int *] * Arg: startstate [UNKN ] Undocumented argument [int *] * Arg: out [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean read_special_strip_GenePhase6(GenePhase6 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out) { int i; int j; int state; int cellscore; int isspecial; PackAlnUnit * pau; /* stop position is on the path */ i = stopi; j = stopj; state= stopstate; isspecial = TRUE; /* Loop until state has the same j as its stop in shadow pointers */ /* This will be the state is came out from, OR it has hit !start */ /* We may not want to get the alignment, in which case out will be NULL */ while( j > GenePhase6_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4) && state != START) { /*while more specials to eat up*/ /* Put away current state, if we should */ if(out != NULL) { pau = PackAlnUnit_alloc(); /* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } max_special_strip_GenePhase6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore); if( i == GenePhase6_READ_OFF_ERROR) { warn("In special strip read GenePhase6, got a bad read off error. Sorry!"); return FALSE; } } /* end of while more specials to eat up */ /* check to see we have not gone too far! */ if( state != START && j < GenePhase6_DC_SHADOW_SPECIAL_SP(mat,i,j,state,4)) { warn("In special strip read GenePhase6, at special [%d] state [%d] overshot!",j,state); return FALSE; } /* Put away last state */ if(out != NULL) { pau = PackAlnUnit_alloc();/* Should deal with memory overflow */ pau->i = i; pau->j = j; pau->state = state + 6; add_PackAln(out,pau); } /* Put away where we are in startj and startstate */ *startj = j; *startstate = state; return TRUE; } /* Function: max_special_strip_GenePhase6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore) * * Descrip: A pretty intense internal function. Deals with read-off only in specials * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_special_strip_GenePhase6(GenePhase6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; int cscore; *reti = (*retj) = (*retstate) = GenePhase6_READ_OFF_ERROR; if( isspecial == FALSE ) { warn("In special strip max function for GenePhase6, got a non special start point. Problem! (bad!)"); return (-1); } if( j < 0 || j > mat->target->seq->len) { warn("In GenePhase6 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = GenePhase6_DC_SHADOW_SPECIAL(mat,i,j,state); switch(state) { /*switch on special states*/ case LOOP : /* source LOOP is a special */ temp = cscore - (mat->gp->transition[GP4_LOOP2LOOP]) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,LOOP); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,LOOP) ; } /* Source DELETE is not a special */ /* Source INSERT is not a special */ /* Source MATCH is not a special */ /* source START is a special */ temp = cscore - (0) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,START); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,START) ; } case START : case END : /* source AFTER_MATCH_CODING is a special */ temp = cscore - (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,AFTER_MATCH_CODING) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-3,AFTER_MATCH_CODING); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,AFTER_MATCH_CODING) ; } /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,LOOP); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,LOOP) ; } case BEFORE_MATCH_CODING : /* source BEFORE_MATCH_INTRON_2 is a special */ temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 4,BEFORE_MATCH_INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = BEFORE_MATCH_INTRON_2; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-4,BEFORE_MATCH_INTRON_2); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 4,BEFORE_MATCH_INTRON_2) ; } /* source BEFORE_MATCH_INTRON_1 is a special */ temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 5,BEFORE_MATCH_INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = BEFORE_MATCH_INTRON_1; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-5,BEFORE_MATCH_INTRON_1); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 5,BEFORE_MATCH_INTRON_1) ; } /* source BEFORE_MATCH_INTRON_0 is a special */ temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-3))) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 6,BEFORE_MATCH_INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = BEFORE_MATCH_INTRON_0; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-6,BEFORE_MATCH_INTRON_0); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 6,BEFORE_MATCH_INTRON_0) ; } /* source BEFORE_MATCH_CODING is a special */ temp = cscore - (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,BEFORE_MATCH_CODING) ) { *reti = i - 0; *retj = j - 3; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-3,BEFORE_MATCH_CODING); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,BEFORE_MATCH_CODING) ; } /* source START is a special */ temp = cscore - (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-3,START); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,START) ; } case BEFORE_MATCH_INTRON_0 : /* source BEFORE_MATCH_INTRON_0 is a special */ temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_MATCH_INTRON_0; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_MATCH_INTRON_0); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_0) ; } /* source BEFORE_MATCH_CODING is a special */ temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_MATCH_CODING) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_MATCH_CODING); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_MATCH_CODING) ; } case BEFORE_MATCH_INTRON_1 : /* source BEFORE_MATCH_INTRON_1 is a special */ temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_MATCH_INTRON_1; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_MATCH_INTRON_1); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_1) ; } /* source BEFORE_MATCH_CODING is a special */ temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 9,BEFORE_MATCH_CODING) ) { *reti = i - 0; *retj = j - 9; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-9,BEFORE_MATCH_CODING); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 9,BEFORE_MATCH_CODING) ; } case BEFORE_MATCH_INTRON_2 : /* source BEFORE_MATCH_INTRON_2 is a special */ temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_MATCH_INTRON_2; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-1,BEFORE_MATCH_INTRON_2); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_2) ; } /* source BEFORE_MATCH_CODING is a special */ temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 10,BEFORE_MATCH_CODING) ) { *reti = i - 0; *retj = j - 10; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-10,BEFORE_MATCH_CODING); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 10,BEFORE_MATCH_CODING) ; } case AFTER_MATCH_CODING : /* source AFTER_MATCH_CODING is a special */ temp = cscore - (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,AFTER_MATCH_CODING) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-3,AFTER_MATCH_CODING); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,AFTER_MATCH_CODING) ; } /* Source MATCH is not a special */ default: warn("Major problem (!) - in GenePhase6 special strip read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: max_matrix_to_special_GenePhase6(mat,i,j,state,cscore,reti,retj,retstate,retspecial,cellscore) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: cscore [UNKN ] Undocumented argument [int] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [int] * */ int max_matrix_to_special_GenePhase6(GenePhase6 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore) { int temp; *reti = (*retj) = (*retstate) = GenePhase6_READ_OFF_ERROR; if( j < 0 || j > mat->lenj) { warn("In GenePhase6 matrix to special read off - out of bounds on matrix [j is %d in special]",j); return -1; } switch(state) { /*Switch state */ case MATCH : /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ temp = cscore - ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,BEFORE_MATCH_CODING) ) { *reti = i - 1; *retj = j - 3; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 1,j - 3,BEFORE_MATCH_CODING) ; } temp = cscore - (((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-1,j-3,START); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 1,j - 3,START) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GenePhase6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : /* Source INSERT is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source INTRON_2 is not a special, should not get here! */ /* Source INTRON_1 is not a special, should not get here! */ /* Source INTRON_0 is not a special, should not get here! */ temp = cscore - (((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == GenePhase6_DC_SHADOW_SPECIAL(mat,i - 0,j - 3,LOOP) ) { *reti = i - 0; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - GenePhase6_DC_SHADOW_SPECIAL(mat,i-0,j-3,LOOP); } return GenePhase6_DC_SHADOW_MATRIX(mat,i - 0,j - 3,LOOP) ; } /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GenePhase6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : /* Source DELETE is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GenePhase6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : /* Source INTRON_0 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GenePhase6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : /* Source INTRON_1 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GenePhase6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : /* Source INTRON_2 is not a special, should not get here! */ /* Source INSERT is not a special, should not get here! */ /* Source MATCH is not a special, should not get here! */ warn("Major problem (!) - in GenePhase6 matrix to special read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: calculate_hidden_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void calculate_hidden_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv) { register int i; register int j; register int score; register int temp; register int hiddenj; hiddenj = startj; init_hidden_GenePhase6(mat,starti,startj,stopi,stopj); GenePhase6_HIDDEN_MATRIX(mat,starti,startj,startstate) = 0; for(j=startj;j<=stopj;j++) { for(i=starti;i<=stopi;i++) { /* Should *not* do very first cell as this is the one set to zero in one state! */ if( i == starti && j == startj ) continue; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GenePhase6_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GenePhase6_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GenePhase6_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ /* For state MATCH */ /* setting first movement to score */ score = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_HIDDEN_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_HIDDEN_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GenePhase6_HIDDEN_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0); /* From state INSERT to state INTRON_0 */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1); /* From state INSERT to state INTRON_1 */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2); /* From state INSERT to state INTRON_2 */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GenePhase6_HIDDEN_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } } return; } /* Function: init_hidden_GenePhase6(mat,starti,startj,stopi,stopj) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * */ void init_hidden_GenePhase6(GenePhase6 * mat,int starti,int startj,int stopi,int stopj) { register int i; register int j; register int hiddenj; hiddenj = startj; for(j=(startj-10);j<=stopj;j++) { for(i=(starti-1);i<=stopi;i++) { GenePhase6_HIDDEN_MATRIX(mat,i,j,MATCH) = NEGI; GenePhase6_HIDDEN_MATRIX(mat,i,j,INSERT) = NEGI; GenePhase6_HIDDEN_MATRIX(mat,i,j,DELETE) = NEGI; GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_0) = NEGI; GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_1) = NEGI; GenePhase6_HIDDEN_MATRIX(mat,i,j,INTRON_2) = NEGI; } } return; } /* Function: full_dc_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,out,donej,totalj,dpenv) * * Descrip: The main divide-and-conquor routine. Basically, call /PackAln_calculate_small_GenePhase6 * Not this function, which is pretty hard core. * Function is given start/end points (in main matrix) for alignment * It does some checks, decides whether start/end in j is small enough for explicit calc * - if yes, calculates it, reads off into PackAln (out), adds the j distance to donej and returns TRUE * - if no, uses /do_dc_single_pass_GenePhase6 to get mid-point * saves midpoint, and calls itself to do right portion then left portion * right then left ensures PackAln is added the 'right' way, ie, back-to-front * returns FALSE on any error, with a warning * * * Arg: mat [UNKN ] Matrix with small memory implementation [GenePhase6 *] * Arg: starti [UNKN ] Start position in i [int] * Arg: startj [UNKN ] Start position in j [int] * Arg: startstate [UNKN ] Start position state number [int] * Arg: stopi [UNKN ] Stop position in i [int] * Arg: stopj [UNKN ] Stop position in j [int] * Arg: stopstate [UNKN ] Stop position state number [int] * Arg: out [UNKN ] PackAln structure to put alignment into [PackAln *] * Arg: donej [UNKN ] pointer to a number with the amount of alignment done [int *] * Arg: totalj [UNKN ] total amount of alignment to do (in j coordinates) [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean full_dc_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv) { int lstarti; int lstartj; int lstate; if( mat->basematrix->type != BASEMATRIX_TYPE_SHADOW) { warn("*Very* bad error! - non shadow matrix type in full_dc_GenePhase6"); return FALSE; } if( starti == -1 || startj == -1 || startstate == -1 || stopi == -1 || stopstate == -1) { warn("In full dc program, passed bad indices, indices passed were %d:%d[%d] to %d:%d[%d]\n",starti,startj,startstate,stopi,stopj,stopstate); return FALSE; } if( stopj - startj < 50) { log_full_error(REPORT,0,"[%d,%d][%d,%d] Explicit read off",starti,startj,stopi,stopj);/* Build hidden explicit matrix */ calculate_hidden_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv); *donej += (stopj - startj); /* Now read it off into out */ if( read_hidden_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,out) == FALSE) { warn("In full dc, at %d:%d,%d:%d got a bad hidden explicit read off... ",starti,startj,stopi,stopj); return FALSE; } return TRUE; } /* In actual divide and conquor */ if( do_dc_single_pass_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,(int)(*donej*100)/totalj) == FALSE) { warn("In divide and conquor for GenePhase6, at bound %d:%d to %d:%d, unable to calculate midpoint. Problem!",starti,startj,stopi,stopj); return FALSE; } /* Ok... now we have to call on each side of the matrix */ /* We have to retrieve left hand side positions, as they will be vapped by the time we call LHS */ lstarti= GenePhase6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,0); lstartj= GenePhase6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,1); lstate = GenePhase6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,2); /* Call on right hand side: this lets us do the correct read off */ if( full_dc_GenePhase6(mat,GenePhase6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,3),GenePhase6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,4),GenePhase6_DC_SHADOW_MATRIX_SP(mat,stopi,stopj,stopstate,5),stopi,stopj,stopstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } /* Call on left hand side */ if( full_dc_GenePhase6(mat,starti,startj,startstate,lstarti,lstartj,lstate,out,donej,totalj,dpenv) == FALSE) { /* Warning already issued, simply chained back up to top */ return FALSE; } return TRUE; } /* Function: do_dc_single_pass_GenePhase6(mat,starti,startj,startstate,stopi,stopj,stopstate,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: startstate [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: stopstate [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean do_dc_single_pass_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done) { int halfj; halfj = startj + ((stopj - startj)/2); init_dc_GenePhase6(mat); GenePhase6_DC_SHADOW_MATRIX(mat,starti,startj,startstate) = 0; run_up_dc_GenePhase6(mat,starti,stopi,startj,halfj-1,dpenv,perc_done); push_dc_at_merge_GenePhase6(mat,starti,stopi,halfj,&halfj,dpenv); follow_on_dc_GenePhase6(mat,starti,stopi,halfj,stopj,dpenv,perc_done); return TRUE; } /* Function: push_dc_at_merge_GenePhase6(mat,starti,stopi,startj,stopj,dpenv) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * */ void push_dc_at_merge_GenePhase6(GenePhase6 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv) { register int i; register int j; register int k; register int count; register int mergej;/* Sources below this j will be stamped by triples */ register int score; register int temp; mergej = startj -1; for(count=0,j=startj;count<10;count++,j++) { for(i=starti;i<=stopi;i++) { if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-100); GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = (-100); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-100); GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = (-100); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-100); GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = (-100); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-100); GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = (-100); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-100); GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = (-100); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-100); GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = (-100); continue; } /* end of Is not in envelope */ /* For state MATCH, pushing when j - offj <= mergej */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INSERT; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-3; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = DELETE; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score) { score = temp; if( j - 6 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-6; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score) { score = temp; if( j - 5 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score) { score = temp; if( j - 4 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = INTRON_2; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-2; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score) { score = temp; if( j - 4 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-4; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score) { score = temp; if( j - 5 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = i-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,1) = j-5; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,2) = MATCH; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,5) = MATCH; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished with state MATCH */ /* For state INSERT, pushing when j - offj <= mergej */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( j - 3 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = MATCH; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score) { score = temp; if( j - 3 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-3; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = DELETE; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score) { score = temp; if( j - 6 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-6; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score) { score = temp; if( j - 5 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-5; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score) { score = temp; if( j - 4 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-4; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INTRON_2; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score) { score = temp; if( j - 2 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-2; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score) { score = temp; if( j - 1 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,1) = j-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,2) = INSERT; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,5) = INSERT; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } } /* Add any movement independant score */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished with state INSERT */ /* For state DELETE, pushing when j - offj <= mergej */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE]; if( j - 0 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = MATCH; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = INSERT; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score) { score = temp; if( j - 0 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = i-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,1) = j-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,2) = DELETE; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,5) = DELETE; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } } /* Add any movement independant score */ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished with state DELETE */ /* For state INTRON_0, pushing when j - offj <= mergej */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0); if( j - 8 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = MATCH; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score) { score = temp; if( j - 8 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-8; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INSERT; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,1) = j-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,2) = INTRON_0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,5) = INTRON_0; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } } /* Add any movement independant score */ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished with state INTRON_0 */ /* For state INTRON_1, pushing when j - offj <= mergej */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1); if( j - 9 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = MATCH; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score) { score = temp; if( j - 9 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-9; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INSERT; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,1) = j-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,2) = INTRON_1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,5) = INTRON_1; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } } /* Add any movement independant score */ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished with state INTRON_1 */ /* For state INTRON_2, pushing when j - offj <= mergej */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2); if( j - 10 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = MATCH; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score) { score = temp; if( j - 10 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-10; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INSERT; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } } temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score) { score = temp; if( j - 1 <= mergej) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = i-0; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,1) = j-1; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,2) = INTRON_2; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,3) = i; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,4) = j; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,5) = INTRON_2; } else { for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } } /* Add any movement independant score */ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished with state INTRON_2 */ } } /* Put back j into * stop j so that calling function gets it correct */ if( stopj == NULL) warn("Bad news... NULL stopj pointer in push dc function. This means that calling function does not know how many cells I have done!"); else *stopj = j; return; } /* Function: follow_on_dc_GenePhase6(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ void follow_on_dc_GenePhase6(GenePhase6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { int i; int j; int k; int score; int temp; int localshadow[7]; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]After mid-j %5d Cells done %d%%%%",perc_done,startj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,k); /* From state INSERT to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,k); } /* From state DELETE to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,k); } /* From state INTRON_0 to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,k); } /* From state INTRON_1 to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,k); } /* From state INTRON_2 to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,k); } /* From state MATCH to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,k); } /* From state MATCH to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,k); } /* From state MATCH to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,k); } /* From state MATCH to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,k); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,k); /* From state INSERT to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,k); } /* From state DELETE to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,k); } /* From state INTRON_0 to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,k); } /* From state INTRON_1 to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,k); } /* From state INTRON_2 to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,k); } /* From state INSERT to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,k); } /* From state INSERT to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,k); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE]; /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,k); /* From state INSERT to state DELETE */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,k); } /* From state DELETE to state DELETE */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,k); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,k); /* From state INSERT to state INTRON_0 */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,k); } /* From state INTRON_0 to state INTRON_0 */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,k); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,k); /* From state INSERT to state INTRON_1 */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,k); } /* From state INTRON_1 to state INTRON_1 */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,k); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2); /* shift first shadow numbers */ for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,k); /* From state INSERT to state INTRON_2 */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,k); } /* From state INTRON_2 to state INTRON_2 */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; for(k=0;k<7;k++) localshadow[k] = GenePhase6_DC_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,k); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localshadow[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: run_up_dc_GenePhase6(mat,starti,stopi,startj,stopj,dpenv,perc_done) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: perc_done [UNKN ] Undocumented argument [int] * */ } void run_up_dc_GenePhase6(GenePhase6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done) { register int i; register int j; register int score; register int temp; long int total; long int num; total = (stopi - starti+1) * (stopj - startj+1); if( total <= 0 ) total = 1; num = 0; for(j=startj;j<=stopj;j++) { /*for each valid j column*/ for(i=starti;i<=stopi;i++) { /*this is strip*/ if( j == startj && i == starti) continue; num++; if( dpenv != NULL && is_in_DPEnvelope(dpenv,i,j) == FALSE ) { /*Is not in envelope*/ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } /* end of Is not in envelope */ if( num % 1000 == 0 ) log_full_error(REPORT,0,"[%d%%%% done]Before mid-j %5d Cells done %d%%%%",perc_done,stopj,(num*100)/total); /* For state MATCH */ /* setting first movement to score */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = score; /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = score; /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = score; /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0); /* From state INSERT to state INTRON_0 */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1); /* From state INSERT to state INTRON_1 */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2); /* From state INSERT to state INTRON_2 */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GenePhase6_DC_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* end of this is strip */ } /* end of for each valid j column */ /* Function: init_dc_GenePhase6(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * */ } void init_dc_GenePhase6(GenePhase6 * mat) { register int i; register int j; register int k; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; for(k=0;k<7;k++) { GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = (-1); GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = (-1); GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = (-1); GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = (-1); GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = (-1); GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = (-1); } } } return; } /* Function: start_end_find_end_GenePhase6(mat,endj) * * Descrip: First function used to find end of the best path in the special state !end * * * Arg: mat [UNKN ] Matrix in small mode [GenePhase6 *] * Arg: endj [WRITE] position of end in j (meaningless in i) [int *] * * Return [UNKN ] Undocumented return value [int] * */ int start_end_find_end_GenePhase6(GenePhase6 * mat,int * endj) { register int j; register int max; register int maxj; max = GenePhase6_DC_SHADOW_SPECIAL(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,END) > max ) { max = GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,END); maxj = j; } } if( endj != NULL) *endj = maxj; return max; } /* Function: dc_optimised_start_end_calc_GenePhase6(*mat,dpenv) * * Descrip: Calculates special strip, leaving start/end/score points in shadow matrix * Works off specially laid out memory from steve searle * * * Arg: *mat [UNKN ] Undocumented argument [GenePhase6] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean dc_optimised_start_end_calc_GenePhase6(GenePhase6 *mat,DPEnvelope * dpenv) { int i; int j; int k; int score; int temp; int leni; int lenj; int localshadow[7]; long int total; long int num=0; int * score_pointers; int * shadow_pointers; int * localsp; leni = mat->query->len; lenj = mat->target->seq->len; total = leni * lenj; score_pointers = (int *) calloc (10 * (leni + 1) * 6,sizeof(int)); shadow_pointers = (int *) calloc (10 * (leni + 1) * 6 * 8,sizeof(int)); for(j=0;jquery->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,MATCH,0)); /* From state INSERT to state MATCH */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,INSERT,0)); } /* From state DELETE to state MATCH */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 3,DELETE,0)); } /* From state START to state MATCH */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,START) + ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [START] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state BEFORE_MATCH_CODING to state MATCH */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [BEFORE_MATCH_CODING] is a special for MATCH... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= MATCH; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_0 to state MATCH */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 6,INTRON_0,0)); } /* From state INTRON_1 to state MATCH */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,INTRON_1,0)); } /* From state INTRON_2 to state MATCH */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,INTRON_2,0)); } /* From state MATCH to state MATCH */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 2,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 1,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 4,MATCH,0)); } /* From state MATCH to state MATCH */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 5,MATCH,0)); } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,MATCH) = score; for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state MATCH is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = MATCH; } /* state MATCH is a source for special AFTER_MATCH_CODING */ temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) { GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,k); GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,6) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,MATCH,6); GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,3) = i; GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,4) = j; GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,5) = MATCH; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,MATCH,0)); /* From state INSERT to state INSERT */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,INSERT,0)); } /* From state DELETE to state INSERT */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 3,DELETE,0)); } /* From state LOOP to state INSERT */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]) + (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* This state [LOOP] is a special for INSERT... push top shadow pointers here */ localshadow[0]= i; localshadow[1]= j; localshadow[2]= INSERT; localshadow[3]= (-1); localshadow[4]= (-1); localshadow[5]= (-1); localshadow[6]= score; localsp = localshadow; } /* From state INTRON_0 to state INSERT */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 6,INTRON_0,0)); } /* From state INTRON_1 to state INSERT */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 5,INTRON_1,0)); } /* From state INTRON_2 to state INSERT */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)) +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 4,INTRON_2,0)); } /* From state INSERT to state INSERT */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 2,INSERT,0)); } /* From state INSERT to state INSERT */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE] +(CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INSERT,0)); } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,INSERT) = score; for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state INSERT is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,k); GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INSERT,6); GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = INSERT; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE] + (0); /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,MATCH,0)); /* From state INSERT to state DELETE */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,INSERT,0)); } /* From state DELETE to state DELETE */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE] +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 1,j - 0,DELETE,0)); } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,DELETE) = score; for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k) = localsp[k]; /* Now figure out if any specials need this score */ /* state DELETE is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,i,j,LOOP) = temp; /* Have to push only bottem half of system here */ for(k=0;k<3;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,k); GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,6) = GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,DELETE,6); GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,3) = i; GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,4) = j; GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,5) = DELETE; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0) + (0); /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,MATCH,0)); /* From state INSERT to state INTRON_0 */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 8,INSERT,0)); } /* From state INTRON_0 to state INTRON_0 */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_0,0)); } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_0) = score; for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1) + (0); /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,MATCH,0)); /* From state INSERT to state INTRON_1 */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 9,INSERT,0)); } /* From state INTRON_1 to state INTRON_1 */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_1,0)); } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_1) = score; for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2) + (0); /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,MATCH,0)); /* From state INSERT to state INTRON_2 */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 10,INSERT,0)); } /* From state INTRON_2 to state INTRON_2 */ temp = GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]) +(0); if( temp > score ) { score = temp; /* assign local shadown pointer */ localsp = &(GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i - 0,j - 1,INTRON_2,0)); } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ /* Actually, already done inside scores */ GenePhase6_DC_OPT_SHADOW_MATRIX(mat,i,j,INTRON_2) = score; for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,k) = localsp[k]; /* Now figure out if any specials need this score */ /* Finished calculating state INTRON_2 */ } /* end of for each i position in strip */ /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,START,k); } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,LOOP,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,LOOP,k); } /* Put back score... (now updated!) */ GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,LOOP,k); } /* Source AFTER_MATCH_CODING is a special source for END */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,END,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,AFTER_MATCH_CODING,k); } /* Put back score... (now updated!) */ GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_CODING); /* Source START is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,START,k); } /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,BEFORE_MATCH_CODING,k); } /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 6,BEFORE_MATCH_INTRON_0) + (CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 6,BEFORE_MATCH_INTRON_0,k); } /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 5,BEFORE_MATCH_INTRON_1) + (CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 5,BEFORE_MATCH_INTRON_1,k); } /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 4,BEFORE_MATCH_INTRON_2) + (CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 4,BEFORE_MATCH_INTRON_2,k); } /* Put back score... (now updated!) */ GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score; /* Finished updating state BEFORE_MATCH_CODING */ /* Special state BEFORE_MATCH_INTRON_0 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_0 */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_INTRON_0,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_MATCH_CODING,k); } /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_INTRON_0 */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_0) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_INTRON_0,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_0,k); } /* Put back score... (now updated!) */ GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0) = score; /* Finished updating state BEFORE_MATCH_INTRON_0 */ /* Special state BEFORE_MATCH_INTRON_1 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_1 */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 9,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_INTRON_1,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 9,BEFORE_MATCH_CODING,k); } /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_INTRON_1 */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_1) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_INTRON_1,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_1,k); } /* Put back score... (now updated!) */ GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1) = score; /* Finished updating state BEFORE_MATCH_INTRON_1 */ /* Special state BEFORE_MATCH_INTRON_2 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_2 */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 10,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_INTRON_2,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 10,BEFORE_MATCH_CODING,k); } /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_INTRON_2 */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_2) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,BEFORE_MATCH_INTRON_2,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_2,k); } /* Put back score... (now updated!) */ GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2) = score; /* Finished updating state BEFORE_MATCH_INTRON_2 */ /* Special state AFTER_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_MATCH_CODING); /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */ temp = GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) { score = temp; /* Also got to propagate shadows */ for(k=0;k<7;k++) GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i,j,AFTER_MATCH_CODING,k) = GenePhase6_DC_OPT_SHADOW_SPECIAL_SP(mat,i - 0,j - 3,AFTER_MATCH_CODING,k); } /* Put back score... (now updated!) */ GenePhase6_DC_OPT_SHADOW_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score; /* Finished updating state AFTER_MATCH_CODING */ } /* end of for each j strip */ free(score_pointers); free(shadow_pointers); return TRUE; } /* Function: init_start_end_linear_GenePhase6(mat) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * */ void init_start_end_linear_GenePhase6(GenePhase6 * mat) { register int i; register int j; for(j=0;j<12;j++) { for(i=(-1);iquery->len;i++) { GenePhase6_DC_SHADOW_MATRIX(mat,i,j,MATCH) = NEGI; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,MATCH,0) = (-1); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INSERT) = NEGI; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INSERT,0) = (-1); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,DELETE) = NEGI; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,DELETE,0) = (-1); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_0) = NEGI; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_0,0) = (-1); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_1) = NEGI; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_1,0) = (-1); GenePhase6_DC_SHADOW_MATRIX(mat,i,j,INTRON_2) = NEGI; GenePhase6_DC_SHADOW_MATRIX_SP(mat,i,j,INTRON_2,0) = (-1); } } for(j=(-10);jtarget->seq->len;j++) { GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,LOOP) = NEGI; GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,LOOP,0) = (-1); GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,START) = 0; GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,START,0) = j; GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,END) = NEGI; GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,END,0) = (-1); GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = NEGI; GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_MATCH_CODING,0) = (-1); GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0) = NEGI; GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_MATCH_INTRON_0,0) = (-1); GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1) = NEGI; GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_MATCH_INTRON_1,0) = (-1); GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2) = NEGI; GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,BEFORE_MATCH_INTRON_2,0) = (-1); GenePhase6_DC_SHADOW_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = NEGI; GenePhase6_DC_SHADOW_SPECIAL_SP(mat,0,j,AFTER_MATCH_CODING,0) = (-1); } return; } /* Function: convert_PackAln_to_AlnBlock_GenePhase6(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * convert_PackAln_to_AlnBlock_GenePhase6(PackAln * pal) { AlnConvertSet * acs; AlnBlock * alb; acs = AlnConvertSet_GenePhase6(); alb = AlnBlock_from_PackAln(acs,pal); free_AlnConvertSet(acs); return alb; } static char * query_label[] = { "MATCH_STATE","INSERT_STATE","DELETE_STATE","INTRON_STATE","LOOP_STATE","END","BEFORE_MATCH","BEFORE_MATCH_INTRON","AFTER_MATCH" }; /* Function: AlnConvertSet_GenePhase6(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ static char * target_label[] = { "CODON","3SS_PHASE_0","3SS_PHASE_1","3SS_PHASE_2","SEQUENCE_DELETION","SEQUENCE_INSERTION","INSERT","5SS_PHASE_0","CENTRAL_INTRON","5SS_PHASE_1","5SS_PHASE_2","RANDOM_SEQUENCE","END" }; AlnConvertSet * AlnConvertSet_GenePhase6(void) { AlnConvertUnit * acu; AlnConvertSet * out; out = AlnConvertSet_alloc_std(); acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = MATCH; acu->offi = 1; acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_MATCH_CODING + 6; acu->is_from_special = TRUE; acu->state2 = MATCH; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[0]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = MATCH; acu->offi = 1; acu->offj = 6; acu->label1 = query_label[0]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 2; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 1; acu->label1 = query_label[0]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 4; acu->label1 = query_label[0]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = MATCH; acu->offi = 1; acu->offj = 5; acu->label1 = query_label[0]; acu->label2 = target_label[5]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = INSERT; acu->offi = 0; acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 6; acu->is_from_special = TRUE; acu->state2 = INSERT; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[1]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INSERT; acu->offi = 0; acu->offj = 6; acu->label1 = query_label[1]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INSERT; acu->offi = 0; acu->offj = 5; acu->label1 = query_label[1]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INSERT; acu->offi = 0; acu->offj = 4; acu->label1 = query_label[1]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 2; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INSERT; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[1]; acu->label2 = target_label[4]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = DELETE; acu->offi = 1; acu->offj = 0; acu->label1 = query_label[2]; acu->label2 = target_label[6]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 8; acu->label1 = query_label[3]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_0; acu->state2 = INTRON_0; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 9; acu->label1 = query_label[3]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_1; acu->state2 = INTRON_1; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 10; acu->label1 = query_label[3]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INTRON_2; acu->state2 = INTRON_2; acu->offi = 0; acu->offj = 1; acu->label1 = query_label[3]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->state2 = LOOP + 6; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = LOOP + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = INSERT; acu->state2 = LOOP + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = DELETE; acu->state2 = LOOP + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 6; acu->state2 = LOOP + 6; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[4]; acu->label2 = target_label[11]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = LOOP + 6; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[5]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_MATCH_CODING + 6; acu->state2 = END + 6; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[5]; acu->label2 = target_label[12]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = START + 6; acu->state2 = BEFORE_MATCH_CODING + 6; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[6]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_MATCH_CODING + 6; acu->state2 = BEFORE_MATCH_CODING + 6; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[6]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_MATCH_INTRON_0 + 6; acu->state2 = BEFORE_MATCH_CODING + 6; acu->offi = (-1); acu->offj = 6; acu->label1 = query_label[6]; acu->label2 = target_label[1]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_MATCH_INTRON_1 + 6; acu->state2 = BEFORE_MATCH_CODING + 6; acu->offi = (-1); acu->offj = 5; acu->label1 = query_label[6]; acu->label2 = target_label[2]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_MATCH_INTRON_2 + 6; acu->state2 = BEFORE_MATCH_CODING + 6; acu->offi = (-1); acu->offj = 4; acu->label1 = query_label[6]; acu->label2 = target_label[3]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_MATCH_CODING + 6; acu->state2 = BEFORE_MATCH_INTRON_0 + 6; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[7]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_MATCH_INTRON_0 + 6; acu->state2 = BEFORE_MATCH_INTRON_0 + 6; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_MATCH_CODING + 6; acu->state2 = BEFORE_MATCH_INTRON_1 + 6; acu->offi = (-1); acu->offj = 9; acu->label1 = query_label[7]; acu->label2 = target_label[9]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_MATCH_INTRON_1 + 6; acu->state2 = BEFORE_MATCH_INTRON_1 + 6; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_MATCH_CODING + 6; acu->state2 = BEFORE_MATCH_INTRON_2 + 6; acu->offi = (-1); acu->offj = 10; acu->label1 = query_label[7]; acu->label2 = target_label[10]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = BEFORE_MATCH_INTRON_2 + 6; acu->state2 = BEFORE_MATCH_INTRON_2 + 6; acu->offi = (-1); acu->offj = 1; acu->label1 = query_label[7]; acu->label2 = target_label[8]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = MATCH; acu->state2 = AFTER_MATCH_CODING + 6; acu->offi = (-1); acu->offj = 0; acu->label1 = query_label[8]; acu->label2 = target_label[0]; acu = AlnConvertUnit_alloc(); add_AlnConvertSet(out,acu); acu->state1 = AFTER_MATCH_CODING + 6; acu->state2 = AFTER_MATCH_CODING + 6; acu->offi = (-1); acu->offj = 3; acu->label1 = query_label[8]; acu->label2 = target_label[0]; add_collapse_label_AlnConvertSet(out,"INTRON_STATE","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"BEFORE_MATCH_INTRON","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"AFTER_MATCH_INTRON","CENTRAL_INTRON"); add_collapse_label_AlnConvertSet(out,"LOOP_STATE","RANDOM_SEQUENCE"); return out; } /* Function: PackAln_read_Expl_GenePhase6(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_Expl_GenePhase6(GenePhase6 * mat) { GenePhase6_access_func_holder holder; holder.access_main = GenePhase6_explicit_access_main; holder.access_special = GenePhase6_explicit_access_special; return PackAln_read_generic_GenePhase6(mat,holder); } /* Function: GenePhase6_explicit_access_main(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GenePhase6_explicit_access_main(GenePhase6 * mat,int i,int j,int state) { return GenePhase6_EXPL_MATRIX(mat,i,j,state); } /* Function: GenePhase6_explicit_access_special(mat,i,j,state) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int GenePhase6_explicit_access_special(GenePhase6 * mat,int i,int j,int state) { return GenePhase6_EXPL_SPECIAL(mat,i,j,state); } /* Function: PackAln_read_generic_GenePhase6(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: h [UNKN ] Undocumented argument [GenePhase6_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_read_generic_GenePhase6(GenePhase6 * mat,GenePhase6_access_func_holder h) { register PackAln * out; int i; int j; int state; int cellscore = (-1); boolean isspecial; PackAlnUnit * pau = NULL; PackAlnUnit * prev = NULL; assert(mat); assert(h.access_main); assert(h.access_special); out = PackAln_alloc_std(); if( out == NULL ) return NULL; out->score = find_end_GenePhase6(mat,&i,&j,&state,&isspecial,h); /* Add final end transition (at the moment we have not got the score! */ if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed the first PackAlnUnit alloc, %d length of Alignment in GenePhase6_basic_read, returning a mess.(Sorry!)",out->len); return out; } /* Put in positions for end trans. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev=pau; while( state != START || isspecial != TRUE) { /*while state != START*/ if( isspecial == TRUE ) max_calc_special_GenePhase6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); else max_calc_GenePhase6(mat,i,j,state,isspecial,&i,&j,&state,&isspecial,&cellscore,h); if(i == GenePhase6_READ_OFF_ERROR || j == GenePhase6_READ_OFF_ERROR || state == GenePhase6_READ_OFF_ERROR ) { warn("Problem - hit bad read off system, exiting now"); break; } if( (pau= PackAlnUnit_alloc()) == NULL || add_PackAln(out,pau) == FALSE ) { warn("Failed a PackAlnUnit alloc, %d length of Alignment in GenePhase6_basic_read, returning partial alignment",out->len); break; } /* Put in positions for block. Remember that coordinates in C style */ pau->i = i; pau->j = j; if( isspecial != TRUE) pau->state = state; else pau->state = state + 6; prev->score = cellscore; prev = pau; } /* end of while state != START */ invert_PackAln(out); return out; } /* Function: find_end_GenePhase6(mat,ri,rj,state,isspecial,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: ri [UNKN ] Undocumented argument [int *] * Arg: rj [UNKN ] Undocumented argument [int *] * Arg: state [UNKN ] Undocumented argument [int *] * Arg: isspecial [UNKN ] Undocumented argument [boolean *] * Arg: h [UNKN ] Undocumented argument [GenePhase6_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int find_end_GenePhase6(GenePhase6 * mat,int * ri,int * rj,int * state,boolean * isspecial,GenePhase6_access_func_holder h) { int j; int max; int maxj; int temp; max = (*h.access_special)(mat,0,mat->target->seq->len-1,END); maxj = mat->target->seq->len-1; for(j= mat->target->seq->len-2 ;j >= 0 ;j--) { if( (temp =(*h.access_special)(mat,0,j,END)) > max ) { max = temp; maxj = j; } } if( ri != NULL) *ri = 0; if( rj != NULL) *rj = maxj; if( state != NULL) *state = END; if( isspecial != NULL) *isspecial = TRUE; return max; } /* Function: GenePhase6_debug_show_matrix(mat,starti,stopi,startj,stopj,ofp) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: starti [UNKN ] Undocumented argument [int] * Arg: stopi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: stopj [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void GenePhase6_debug_show_matrix(GenePhase6 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp) { register int i; register int j; for(i=starti;iquery->len;i++) { for(j=startj;jtarget->seq->len;j++) { fprintf(ofp,"Cell [%d - %d]\n",i,j); fprintf(ofp,"State MATCH %d\n",GenePhase6_EXPL_MATRIX(mat,i,j,MATCH)); fprintf(ofp,"State INSERT %d\n",GenePhase6_EXPL_MATRIX(mat,i,j,INSERT)); fprintf(ofp,"State DELETE %d\n",GenePhase6_EXPL_MATRIX(mat,i,j,DELETE)); fprintf(ofp,"State INTRON_0 %d\n",GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0)); fprintf(ofp,"State INTRON_1 %d\n",GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1)); fprintf(ofp,"State INTRON_2 %d\n",GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2)); fprintf(ofp,"\n\n"); } } } /* Function: max_calc_GenePhase6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GenePhase6_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_GenePhase6(GenePhase6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GenePhase6_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GenePhase6_READ_OFF_ERROR; if( i < 0 || j < 0 || i > mat->query->len || j > mat->target->seq->len) { warn("In GenePhase6 matrix special read off - out of bounds on matrix [i,j is %d,%d state %d in standard matrix]",i,j,state); return -1; } /* Then you have to select the correct switch statement to figure out the readoff */ /* Somewhat odd - reverse the order of calculation and return as soon as it is correct */ cscore = (*h.access_main)(mat,i,j,state); switch(state) { /*Switch state */ case MATCH : temp = cscore - (mat->gp->transition[GP4_INSERT_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,MATCH) ) { *reti = i - 1; *retj = j - 5; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,MATCH); } return (*h.access_main)(mat,i - 1,j - 5,MATCH); } temp = cscore - (mat->gp->transition[GP4_INSERT_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,MATCH) ) { *reti = i - 1; *retj = j - 4; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,MATCH); } return (*h.access_main)(mat,i - 1,j - 4,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 1,MATCH) ) { *reti = i - 1; *retj = j - 1; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-1,MATCH); } return (*h.access_main)(mat,i - 1,j - 1,MATCH); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 2,MATCH) ) { *reti = i - 1; *retj = j - 2; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-2,MATCH); } return (*h.access_main)(mat,i - 1,j - 2,MATCH); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 4,INTRON_2) ) { *reti = i - 1; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-4,INTRON_2); } return (*h.access_main)(mat,i - 1,j - 4,INTRON_2); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 5,INTRON_1) ) { *reti = i - 1; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-5,INTRON_1); } return (*h.access_main)(mat,i - 1,j - 5,INTRON_1); } temp = cscore - ((mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 6,INTRON_0) ) { *reti = i - 1; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-6,INTRON_0); } return (*h.access_main)(mat,i - 1,j - 6,INTRON_0); } temp = cscore - ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 1,j - 3,BEFORE_MATCH_CODING) ) { *reti = i - 1; *retj = j - 3; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,BEFORE_MATCH_CODING); } return (*h.access_main)(mat,i - 1,j - 3,BEFORE_MATCH_CODING); } temp = cscore - (((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 1,j - 3,START) ) { *reti = i - 1; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-1,j-3,START); } return (*h.access_main)(mat,i - 1,j - 3,START); } temp = cscore - ((mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,DELETE) ) { *reti = i - 1; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,DELETE); } return (*h.access_main)(mat,i - 1,j - 3,DELETE); } temp = cscore - ((mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,INSERT) ) { *reti = i - 1; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,INSERT); } return (*h.access_main)(mat,i - 1,j - 3,INSERT); } temp = cscore - ((mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 1,j - 3,MATCH) ) { *reti = i - 1; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-3,MATCH); } return (*h.access_main)(mat,i - 1,j - 3,MATCH); } warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INSERT : temp = cscore - (mat->gp->transition[GP4_DELETE_2_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 1,INSERT) ) { *reti = i - 0; *retj = j - 1; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INSERT); } return (*h.access_main)(mat,i - 0,j - 1,INSERT); } temp = cscore - (mat->gp->transition[GP4_DELETE_1_BASE]) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 2,INSERT) ) { *reti = i - 0; *retj = j - 2; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-2,INSERT); } return (*h.access_main)(mat,i - 0,j - 2,INSERT); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 4,INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-4,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 4,INTRON_2); } temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 5,INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-5,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 5,INTRON_1); } temp = cscore - ((mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3)))) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 6,INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-6,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 6,INTRON_0); } temp = cscore - (((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_special)(mat,i - 0,j - 3,LOOP) ) { *reti = i - 0; *retj = j - 3; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,LOOP); } return (*h.access_main)(mat,i - 0,j - 3,LOOP); } temp = cscore - ((mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,DELETE) ) { *reti = i - 0; *retj = j - 3; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,DELETE); } return (*h.access_main)(mat,i - 0,j - 3,DELETE); } temp = cscore - ((mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,INSERT) ) { *reti = i - 0; *retj = j - 3; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,INSERT); } return (*h.access_main)(mat,i - 0,j - 3,INSERT); } temp = cscore - ((mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])) - (CSEQ_GENOMIC_CDSPOT(mat->target,j)); if( temp == (*h.access_main)(mat,i - 0,j - 3,MATCH) ) { *reti = i - 0; *retj = j - 3; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-3,MATCH); } return (*h.access_main)(mat,i - 0,j - 3,MATCH); } warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case DELETE : temp = cscore - (mat->query->gws->seg[i]->transition[GW_DELETE2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,DELETE) ) { *reti = i - 1; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,DELETE); } return (*h.access_main)(mat,i - 1,j - 0,DELETE); } temp = cscore - (mat->query->gws->seg[i]->transition[GW_INSERT2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,INSERT) ) { *reti = i - 1; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,INSERT); } return (*h.access_main)(mat,i - 1,j - 0,INSERT); } temp = cscore - (mat->query->gws->seg[i]->transition[GW_MATCH2DELETE]) - (0); if( temp == (*h.access_main)(mat,i - 1,j - 0,MATCH) ) { *reti = i - 1; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-1,j-0,MATCH); } return (*h.access_main)(mat,i - 1,j - 0,MATCH); } warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_0 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_0; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_0); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_0); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,INSERT) ) { *reti = i - 0; *retj = j - 8; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,INSERT); } return (*h.access_main)(mat,i - 0,j - 8,INSERT); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 8,MATCH) ) { *reti = i - 0; *retj = j - 8; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-8,MATCH); } return (*h.access_main)(mat,i - 0,j - 8,MATCH); } warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_1 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_1; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_1); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_1); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,INSERT) ) { *reti = i - 0; *retj = j - 9; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,INSERT); } return (*h.access_main)(mat,i - 0,j - 9,INSERT); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 9,MATCH) ) { *reti = i - 0; *retj = j - 9; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-9,MATCH); } return (*h.access_main)(mat,i - 0,j - 9,MATCH); } warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); case INTRON_2 : temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 1,INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = INTRON_2; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-1,INTRON_2); } return (*h.access_main)(mat,i - 0,j - 1,INTRON_2); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,INSERT) ) { *reti = i - 0; *retj = j - 10; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,INSERT); } return (*h.access_main)(mat,i - 0,j - 10,INSERT); } temp = cscore - (((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2)) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 10,MATCH) ) { *reti = i - 0; *retj = j - 10; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-10,MATCH); } return (*h.access_main)(mat,i - 0,j - 10,MATCH); } warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); default: warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found!",i,j,state); return (-1); } /* end of Switch state */ } /* Function: max_calc_special_GenePhase6(mat,i,j,state,isspecial,reti,retj,retstate,retspecial,cellscore,h) * * Descrip: No Description * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * Arg: isspecial [UNKN ] Undocumented argument [boolean] * Arg: reti [UNKN ] Undocumented argument [int *] * Arg: retj [UNKN ] Undocumented argument [int *] * Arg: retstate [UNKN ] Undocumented argument [int *] * Arg: retspecial [UNKN ] Undocumented argument [boolean *] * Arg: cellscore [UNKN ] Undocumented argument [int *] * Arg: h [UNKN ] Undocumented argument [GenePhase6_access_func_holder] * * Return [UNKN ] Undocumented return value [int] * */ int max_calc_special_GenePhase6(GenePhase6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GenePhase6_access_func_holder h) { register int temp; register int cscore; *reti = (*retj) = (*retstate) = GenePhase6_READ_OFF_ERROR; if( j < 0 || j > mat->target->seq->len) { warn("In GenePhase6 matrix special read off - out of bounds on matrix [j is %d in special]",j); return -1; } cscore = (*h.access_special)(mat,i,j,state); switch(state) { /*switch on special states*/ case LOOP : /* source LOOP is a special */ temp = cscore - (mat->gp->transition[GP4_LOOP2LOOP]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,LOOP); } return (*h.access_special)(mat,i - 0,j - 1,LOOP) ; } /* source DELETE is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->gws->seg[i]->transition[GW_DELETE2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,DELETE) ) { *reti = i - 0; *retj = j - 0; *retstate = DELETE; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,DELETE); } return (*h.access_main)(mat,i - 0,j - 0,DELETE) ; } } /* end of for i >= 0 */ /* source INSERT is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->gws->seg[i]->transition[GW_INSERT2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,INSERT) ) { *reti = i - 0; *retj = j - 0; *retstate = INSERT; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,INSERT); } return (*h.access_main)(mat,i - 0,j - 0,INSERT) ; } } /* end of for i >= 0 */ /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->gws->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ /* source START is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,START) ) { *reti = i - 0; *retj = j - 1; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,START); } return (*h.access_special)(mat,i - 0,j - 1,START) ; } case START : case END : /* source AFTER_MATCH_CODING is a special */ temp = cscore - (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,AFTER_MATCH_CODING) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,AFTER_MATCH_CODING); } return (*h.access_special)(mat,i - 0,j - 3,AFTER_MATCH_CODING) ; } /* source LOOP is a special */ temp = cscore - (0) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,LOOP) ) { *reti = i - 0; *retj = j - 1; *retstate = LOOP; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,LOOP); } return (*h.access_special)(mat,i - 0,j - 1,LOOP) ; } case BEFORE_MATCH_CODING : /* source BEFORE_MATCH_INTRON_2 is a special */ temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-1))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 4,BEFORE_MATCH_INTRON_2) ) { *reti = i - 0; *retj = j - 4; *retstate = BEFORE_MATCH_INTRON_2; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-4,BEFORE_MATCH_INTRON_2); } return (*h.access_special)(mat,i - 0,j - 4,BEFORE_MATCH_INTRON_2) ; } /* source BEFORE_MATCH_INTRON_1 is a special */ temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-2))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 5,BEFORE_MATCH_INTRON_1) ) { *reti = i - 0; *retj = j - 5; *retstate = BEFORE_MATCH_INTRON_1; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-5,BEFORE_MATCH_INTRON_1); } return (*h.access_special)(mat,i - 0,j - 5,BEFORE_MATCH_INTRON_1) ; } /* source BEFORE_MATCH_INTRON_0 is a special */ temp = cscore - (CSEQ_GENOMIC_3SS(mat->target,(j-3))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 6,BEFORE_MATCH_INTRON_0) ) { *reti = i - 0; *retj = j - 6; *retstate = BEFORE_MATCH_INTRON_0; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-6,BEFORE_MATCH_INTRON_0); } return (*h.access_special)(mat,i - 0,j - 6,BEFORE_MATCH_INTRON_0) ; } /* source BEFORE_MATCH_CODING is a special */ temp = cscore - (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,BEFORE_MATCH_CODING) ) { *reti = i - 0; *retj = j - 3; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,BEFORE_MATCH_CODING); } return (*h.access_special)(mat,i - 0,j - 3,BEFORE_MATCH_CODING) ; } /* source START is a special */ temp = cscore - (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,START) ) { *reti = i - 0; *retj = j - 3; *retstate = START; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,START); } return (*h.access_special)(mat,i - 0,j - 3,START) ; } case BEFORE_MATCH_INTRON_0 : /* source BEFORE_MATCH_INTRON_0 is a special */ temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_0) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_MATCH_INTRON_0; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_MATCH_INTRON_0); } return (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_0) ; } /* source BEFORE_MATCH_CODING is a special */ temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_CODING) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_MATCH_CODING); } return (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_CODING) ; } case BEFORE_MATCH_INTRON_1 : /* source BEFORE_MATCH_INTRON_1 is a special */ temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_1) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_MATCH_INTRON_1; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_MATCH_INTRON_1); } return (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_1) ; } /* source BEFORE_MATCH_CODING is a special */ temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 9,BEFORE_MATCH_CODING) ) { *reti = i - 0; *retj = j - 9; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-9,BEFORE_MATCH_CODING); } return (*h.access_special)(mat,i - 0,j - 9,BEFORE_MATCH_CODING) ; } case BEFORE_MATCH_INTRON_2 : /* source BEFORE_MATCH_INTRON_2 is a special */ temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_2) ) { *reti = i - 0; *retj = j - 1; *retstate = BEFORE_MATCH_INTRON_2; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-1,BEFORE_MATCH_INTRON_2); } return (*h.access_special)(mat,i - 0,j - 1,BEFORE_MATCH_INTRON_2) ; } /* source BEFORE_MATCH_CODING is a special */ temp = cscore - ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 10,BEFORE_MATCH_CODING) ) { *reti = i - 0; *retj = j - 10; *retstate = BEFORE_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-10,BEFORE_MATCH_CODING); } return (*h.access_special)(mat,i - 0,j - 10,BEFORE_MATCH_CODING) ; } case AFTER_MATCH_CODING : /* source AFTER_MATCH_CODING is a special */ temp = cscore - (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) - (0); if( temp == (*h.access_special)(mat,i - 0,j - 3,AFTER_MATCH_CODING) ) { *reti = i - 0; *retj = j - 3; *retstate = AFTER_MATCH_CODING; *retspecial = TRUE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_special)(mat,i-0,j-3,AFTER_MATCH_CODING); } return (*h.access_special)(mat,i - 0,j - 3,AFTER_MATCH_CODING) ; } /* source MATCH is from main matrix */ for(i= mat->query->len-1;i >= 0 ;i--) { /*for i >= 0*/ temp = cscore - (mat->query->gws->seg[i]->transition[GW_MATCH2END]) - (0); if( temp == (*h.access_main)(mat,i - 0,j - 0,MATCH) ) { *reti = i - 0; *retj = j - 0; *retstate = MATCH; *retspecial = FALSE; if( cellscore != NULL) { *cellscore = cscore - (*h.access_main)(mat,i-0,j-0,MATCH); } return (*h.access_main)(mat,i - 0,j - 0,MATCH) ; } } /* end of for i >= 0 */ default: warn("Major problem (!) - in GenePhase6 read off, position %d,%d state %d no source found dropped into default on source switch!",i,j,state); return (-1); } /* end of switch on special states */ } /* Function: calculate_GenePhase6(mat) * * Descrip: This function calculates the GenePhase6 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GenePhase6 * * * Arg: mat [UNKN ] GenePhase6 which contains explicit basematrix memory [GenePhase6 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_GenePhase6(GenePhase6 * mat) { int i; int j; int leni; int lenj; int tot; int num; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GenePhase6, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } leni = mat->leni; lenj = mat->lenj; tot = leni * lenj; num = 0; start_reporting("GenePhase6 Matrix calculation: "); for(j=0;jquery->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GenePhase6_EXPL_SPECIAL(mat,i-1,j-3,START) + ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_MATCH_CODING to state MATCH */ temp = GenePhase6_EXPL_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state MATCH is a source for special AFTER_MATCH_CODING */ temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) { GenePhase6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GenePhase6_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = GenePhase6_EXPL_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GenePhase6_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GenePhase6_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GenePhase6_EXPL_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0); /* From state INSERT to state INTRON_0 */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GenePhase6_EXPL_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1); /* From state INSERT to state INTRON_1 */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GenePhase6_EXPL_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2); /* From state INSERT to state INTRON_2 */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Source AFTER_MATCH_CODING is a special source for END */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING); /* Source START is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 6,BEFORE_MATCH_INTRON_0) + (CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 5,BEFORE_MATCH_INTRON_1) + (CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 4,BEFORE_MATCH_INTRON_2) + (CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score; /* Finished updating state BEFORE_MATCH_CODING */ /* Special state BEFORE_MATCH_INTRON_0 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_0 */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_INTRON_0 */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_0) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0) = score; /* Finished updating state BEFORE_MATCH_INTRON_0 */ /* Special state BEFORE_MATCH_INTRON_1 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_1 */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 9,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_INTRON_1 */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_1) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1) = score; /* Finished updating state BEFORE_MATCH_INTRON_1 */ /* Special state BEFORE_MATCH_INTRON_2 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_2 */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 10,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_INTRON_2 */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_2) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2) = score; /* Finished updating state BEFORE_MATCH_INTRON_2 */ /* Special state AFTER_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,AFTER_MATCH_CODING); /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score; /* Finished updating state AFTER_MATCH_CODING */ } stop_reporting(); return TRUE; } /* Function: calculate_dpenv_GenePhase6(mat,dpenv) * * Descrip: This function calculates the GenePhase6 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GenePhase6 which contains explicit basematrix memory [GenePhase6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean calculate_dpenv_GenePhase6(GenePhase6 * mat,DPEnvelope * dpenv) { int i; int j; int k; int starti; int startj; int endi; int endj; int tot; int num; int should_calc; if( mat->basematrix->type != BASEMATRIX_TYPE_EXPLICIT ) { warn("in calculate_GenePhase6, passed a non Explicit matrix type, cannot calculate!"); return FALSE; } prepare_DPEnvelope(dpenv); starti = dpenv->starti; if( starti < 0 ) starti = 0; startj = dpenv->startj; if( startj < 0 ) startj = 0; endi = dpenv->endi; if( endi > mat->leni ) endi = mat->leni; endj = dpenv->endj; if( endj > mat->lenj ) endj = mat->lenj; tot = (endi-starti) * (endj-startj); num = 0; for(j=startj-10;jleni;i++) { GenePhase6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; } } for(j=-10;jlenj;j++) { GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = NEGI; GenePhase6_EXPL_SPECIAL(mat,i,j,START) = 0; GenePhase6_EXPL_SPECIAL(mat,i,j,END) = NEGI; GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_CODING) = NEGI; GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_0) = NEGI; GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_1) = NEGI; GenePhase6_EXPL_SPECIAL(mat,i,j,BEFORE_MATCH_INTRON_2) = NEGI; GenePhase6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = NEGI; } start_reporting("GenePhase6 Matrix calculation: "); for(j=startj;jlen;k++) { auto DPUnit * u; u = dpenv->dpu[k]; switch(u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length)) should_calc = 1; break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) should_calc = 1; break; } if( should_calc == 1 ) break; } if( should_calc == 0) { GenePhase6_EXPL_MATRIX(mat,i,j,MATCH) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INSERT) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,DELETE) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1) = NEGI; GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2) = NEGI; continue; } if( num%1000 == 0 ) log_full_error(REPORT,0,"[%7d] Cells %2d%%%%",num,num*100/tot); num++; /* For state MATCH */ /* setting first movement to score */ score = GenePhase6_EXPL_MATRIX(mat,i-1,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state START to state MATCH */ temp = GenePhase6_EXPL_SPECIAL(mat,i-1,j-3,START) + ((mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state BEFORE_MATCH_CODING to state MATCH */ temp = GenePhase6_EXPL_SPECIAL(mat,i-1,j-3,BEFORE_MATCH_CODING) + (mat->query->gws->seg[i]->transition[GW_START2MATCH]+mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-2,MATCH) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-1,MATCH) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-4,MATCH) + mat->gp->transition[GP4_INSERT_1_BASE]; if( temp > score ) { score = temp; } /* From state MATCH to state MATCH */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-5,MATCH) + mat->gp->transition[GP4_INSERT_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for MATCH */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_EXPL_MATRIX(mat,i,j,MATCH) = score; /* state MATCH is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* state MATCH is a source for special AFTER_MATCH_CODING */ temp = score + (mat->query->gws->seg[i]->transition[GW_MATCH2END]) + (0) ; if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) ) { GenePhase6_EXPL_SPECIAL(mat,i,j,AFTER_MATCH_CODING) = temp; } /* Finished calculating state MATCH */ /* For state INSERT */ /* setting first movement to score */ score = GenePhase6_EXPL_MATRIX(mat,i-0,j-3,MATCH) + (mat->query->gws->seg[i]->transition[GW_MATCH2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); /* From state INSERT to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-3,INSERT) + (mat->query->gws->seg[i]->transition[GW_INSERT2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state DELETE to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-3,DELETE) + (mat->query->gws->seg[i]->transition[GW_DELETE2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)]); if( temp > score ) { score = temp; } /* From state LOOP to state INSERT */ temp = GenePhase6_EXPL_SPECIAL(mat,i-0,j-3,LOOP) + ((mat->query->gws->seg[i]->transition[GW_START2INSERT]+mat->query->gws->seg[i]->insert[CSEQ_GENOMIC_CODON(mat->target,j)])+mat->gp->transition[GP4_LOOP2MODEL]); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-6,INTRON_0) + (mat->query->gws->seg[i]->match[CSEQ_GENOMIC_CODON(mat->target,j)]+CSEQ_GENOMIC_3SS(mat->target,(j-3))); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-5,INTRON_1) + CSEQ_GENOMIC_3SS(mat->target,(j-2)); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-4,INTRON_2) + CSEQ_GENOMIC_3SS(mat->target,(j-1)); if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-2,INSERT) + mat->gp->transition[GP4_DELETE_1_BASE]; if( temp > score ) { score = temp; } /* From state INSERT to state INSERT */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INSERT) + mat->gp->transition[GP4_DELETE_2_BASE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for INSERT */ /* Add any movement independant score and put away */ score += CSEQ_GENOMIC_CDSPOT(mat->target,j); GenePhase6_EXPL_MATRIX(mat,i,j,INSERT) = score; /* state INSERT is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_INSERT2END]) + (0) ; if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state INSERT */ /* For state DELETE */ /* setting first movement to score */ score = GenePhase6_EXPL_MATRIX(mat,i-1,j-0,MATCH) + mat->query->gws->seg[i]->transition[GW_MATCH2DELETE]; /* From state INSERT to state DELETE */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-0,INSERT) + mat->query->gws->seg[i]->transition[GW_INSERT2DELETE]; if( temp > score ) { score = temp; } /* From state DELETE to state DELETE */ temp = GenePhase6_EXPL_MATRIX(mat,i-1,j-0,DELETE) + mat->query->gws->seg[i]->transition[GW_DELETE2DELETE]; if( temp > score ) { score = temp; } /* Ok - finished max calculation for DELETE */ /* Add any movement independant score and put away */ GenePhase6_EXPL_MATRIX(mat,i,j,DELETE) = score; /* state DELETE is a source for special LOOP */ temp = score + (mat->query->gws->seg[i]->transition[GW_DELETE2END]) + (0) ; if( temp > GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) ) { GenePhase6_EXPL_SPECIAL(mat,i,j,LOOP) = temp; } /* Finished calculating state DELETE */ /* For state INTRON_0 */ /* setting first movement to score */ score = GenePhase6_EXPL_MATRIX(mat,i-0,j-8,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_0); /* From state INSERT to state INTRON_0 */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-8,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_0 to state INTRON_0 */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INTRON_0) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_0 */ /* Add any movement independant score and put away */ GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_0) = score; /* Finished calculating state INTRON_0 */ /* For state INTRON_1 */ /* setting first movement to score */ score = GenePhase6_EXPL_MATRIX(mat,i-0,j-9,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_1); /* From state INSERT to state INTRON_1 */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-9,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_1 to state INTRON_1 */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INTRON_1) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_1 */ /* Add any movement independant score and put away */ GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_1) = score; /* Finished calculating state INTRON_1 */ /* For state INTRON_2 */ /* setting first movement to score */ score = GenePhase6_EXPL_MATRIX(mat,i-0,j-10,MATCH) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->intron_2); /* From state INSERT to state INTRON_2 */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-10,INSERT) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))+mat->query->phase[i]->insert_intron); if( temp > score ) { score = temp; } /* From state INTRON_2 to state INTRON_2 */ temp = GenePhase6_EXPL_MATRIX(mat,i-0,j-1,INTRON_2) + (mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON]); if( temp > score ) { score = temp; } /* Ok - finished max calculation for INTRON_2 */ /* Add any movement independant score and put away */ GenePhase6_EXPL_MATRIX(mat,i,j,INTRON_2) = score; /* Finished calculating state INTRON_2 */ } /* Special state LOOP has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,LOOP); /* Source START is a special source for LOOP */ /* Has restricted position */ if( (j-1) == 0 ) { temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,START) + (0) + (0); if( temp > score ) score = temp; } /* Source MATCH for state LOOP is not special... already calculated */ /* Source INSERT for state LOOP is not special... already calculated */ /* Source DELETE for state LOOP is not special... already calculated */ /* Source LOOP is a special source for LOOP */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (mat->gp->transition[GP4_LOOP2LOOP]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,LOOP) = score; /* Finished updating state LOOP */ /* Special state START has no special to special movements */ /* Special state END has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,END); /* Source LOOP is a special source for END */ /* Has restricted position */ if( j == mat->lenj-1 ) { temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,LOOP) + (0) + (0); if( temp > score ) score = temp; } /* Source AFTER_MATCH_CODING is a special source for END */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->stop->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,END) = score; /* Finished updating state END */ /* Special state BEFORE_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING); /* Source START is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,START) + (mat->general_model->start->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,BEFORE_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 6,BEFORE_MATCH_INTRON_0) + (CSEQ_GENOMIC_3SS(mat->target,(j-3))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 5,BEFORE_MATCH_INTRON_1) + (CSEQ_GENOMIC_3SS(mat->target,(j-2))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_CODING */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 4,BEFORE_MATCH_INTRON_2) + (CSEQ_GENOMIC_3SS(mat->target,(j-1))) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_CODING) = score; /* Finished updating state BEFORE_MATCH_CODING */ /* Special state BEFORE_MATCH_INTRON_0 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_0 */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,j))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_0 is a special source for BEFORE_MATCH_INTRON_0 */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_0) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_0) = score; /* Finished updating state BEFORE_MATCH_INTRON_0 */ /* Special state BEFORE_MATCH_INTRON_1 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_1 */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 9,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_1 is a special source for BEFORE_MATCH_INTRON_1 */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_1) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_1) = score; /* Finished updating state BEFORE_MATCH_INTRON_1 */ /* Special state BEFORE_MATCH_INTRON_2 has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2); /* Source BEFORE_MATCH_CODING is a special source for BEFORE_MATCH_INTRON_2 */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 10,BEFORE_MATCH_CODING) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+CSEQ_GENOMIC_5SS(mat->target,(j-7)))) + (0); if( temp > score ) score = temp; /* Source BEFORE_MATCH_INTRON_2 is a special source for BEFORE_MATCH_INTRON_2 */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 1,BEFORE_MATCH_INTRON_2) + ((mat->gp->intron[CSEQ_GENOMIC_BASE(mat->target,j)]+mat->gp->transition[GP4_INTRON2INTRON])) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,BEFORE_MATCH_INTRON_2) = score; /* Finished updating state BEFORE_MATCH_INTRON_2 */ /* Special state AFTER_MATCH_CODING has special to speical */ /* Set score to current score (remember, state probably updated during main loop */ score = GenePhase6_EXPL_SPECIAL(mat,0,j,AFTER_MATCH_CODING); /* Source MATCH for state AFTER_MATCH_CODING is not special... already calculated */ /* Source AFTER_MATCH_CODING is a special source for AFTER_MATCH_CODING */ temp = GenePhase6_EXPL_SPECIAL(mat,0,j - 3,AFTER_MATCH_CODING) + (mat->general_model->general->codon[CSEQ_GENOMIC_CODON(mat->target,j)]) + (0); if( temp > score ) score = temp; /* Put back score... (now updated!) */ GenePhase6_EXPL_SPECIAL(mat,0,j,AFTER_MATCH_CODING) = score; /* Finished updating state AFTER_MATCH_CODING */ } stop_reporting(); return TRUE; } /* Function: GenePhase6_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenePhase6 *] * */ GenePhase6 * GenePhase6_alloc(void) { GenePhase6 * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenePhase6 *) ckalloc (sizeof(GenePhase6))) == NULL) { warn("GenePhase6_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->basematrix = NULL; out->shatter = NULL; out->leni = 0; out->lenj = 0; return out; } /* Function: free_GenePhase6(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenePhase6 *] * * Return [UNKN ] Undocumented return value [GenePhase6 *] * */ GenePhase6 * free_GenePhase6(GenePhase6 * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GenePhase6 obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->basematrix != NULL) free_BaseMatrix(obj->basematrix); if( obj->shatter != NULL) free_ShatterMatrix(obj->shatter); /* obj->query is linked in */ /* obj->target is linked in */ /* obj->gp is linked in */ /* obj->general_model is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/genephase6.h0000644000175000001440000004755010670453714016343 0ustar philippusers#ifndef DYNAMITEgenephase6HEADERFILE #define DYNAMITEgenephase6HEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "geneparser4.h" #include "genewisemodeldb.h" #include "phasemodel.h" struct Wise2_GenePhase6 { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif BaseMatrix * basematrix; ShatterMatrix * shatter; int leni; int lenj; GenePhaseScore* query; ComplexSequence* target; GeneParser4Score * gp; GeneralGeneModelScore * general_model; } ; /* GenePhase6 defined */ #ifndef DYNAMITE_DEFINED_GenePhase6 typedef struct Wise2_GenePhase6 Wise2_GenePhase6; #define GenePhase6 Wise2_GenePhase6 #define DYNAMITE_DEFINED_GenePhase6 #endif #ifdef PTHREAD struct thread_pool_holder_GenePhase6 { GenePhaseScore* query; /* Static query data: never free'd */ ComplexSequence* target;/* Target object placeholder */ GenomicDB* targetdb;/* Target database object */ boolean target_init; GeneParser4Score * gp; GeneralGeneModelScore * general_model; pthread_mutex_t input_lock; pthread_mutex_t output_lock; Hscore * out; pthread_t * pool; int number_of_threads; boolean search_has_ended; DBSearchImpl * dbsi; } ; #endif /* PTHREAD */ struct Wise2_GenePhase6_access_func_holder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int (*access_main)(GenePhase6*,int,int,int); int (*access_special)(GenePhase6*,int,int,int); } ; /* GenePhase6_access_func_holder defined */ #ifndef DYNAMITE_DEFINED_GenePhase6_access_func_holder typedef struct Wise2_GenePhase6_access_func_holder Wise2_GenePhase6_access_func_holder; #define GenePhase6_access_func_holder Wise2_GenePhase6_access_func_holder #define DYNAMITE_DEFINED_GenePhase6_access_func_holder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: PackAln_read_Shatter_GenePhase6(mat) * * Descrip: Reads off PackAln from shatter matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Shatter_GenePhase6(GenePhase6 * mat); #define PackAln_read_Shatter_GenePhase6 Wise2_PackAln_read_Shatter_GenePhase6 /* Function: calculate_shatter_GenePhase6(mat,dpenv) * * Descrip: This function calculates the GenePhase6 matrix when in shatter mode * * * Arg: mat [UNKN ] (null) [GenePhase6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_shatter_GenePhase6(GenePhase6 * mat,DPEnvelope * dpenv); #define calculate_shatter_GenePhase6 Wise2_calculate_shatter_GenePhase6 /* Function: search_GenePhase6(dbsi,out,query,targetdb,gp,general_model) * * Descrip: This function makes a database search of GenePhase6 * It uses the dbsi structure to choose which implementation * to use of the database searching. This way at run time you * can switch between single threaded/multi-threaded or hardware * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [GenePhaseScore*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: general_model [UNKN ] Undocumented argument [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_search_GenePhase6(DBSearchImpl * dbsi,Hscore * out,GenePhaseScore* query,GenomicDB* targetdb ,GeneParser4Score * gp,GeneralGeneModelScore * general_model); #define search_GenePhase6 Wise2_search_GenePhase6 /* Function: serial_search_GenePhase6(out,query,targetdb,gp,general_model) * * Descrip: This function makes a database search of GenePhase6 * It is a single processor implementation * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: query [UNKN ] Undocumented argument [GenePhaseScore*] * Arg: targetdb [UNKN ] Undocumented argument [GenomicDB*] * Arg: gp [UNKN ] Undocumented argument [GeneParser4Score *] * Arg: general_model [UNKN ] Undocumented argument [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [Search_Return_Type] * */ Search_Return_Type Wise2_serial_search_GenePhase6(Hscore * out,GenePhaseScore* query,GenomicDB* targetdb ,GeneParser4Score * gp,GeneralGeneModelScore * general_model); #define serial_search_GenePhase6 Wise2_serial_search_GenePhase6 /* Function: PackAln_bestmemory_GenePhase6(query,target,gp,general_model,dpenv,dpri) * * Descrip: This function chooses the best memory set-up for the alignment * using calls to basematrix, and then implements either a large * or small memory model. * * It is the best function to use if you just want an alignment * * If you want a label alignment, you will need * /convert_PackAln_to_AlnBlock_GenePhase6 * * * Arg: query [UNKN ] query data structure [GenePhaseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_bestmemory_GenePhase6(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model,DPEnvelope * dpenv,DPRunImpl * dpri); #define PackAln_bestmemory_GenePhase6 Wise2_PackAln_bestmemory_GenePhase6 /* Function: allocate_Expl_GenePhase6(query,target,gp,general_model,dpri) * * Descrip: This function allocates the GenePhase6 structure * and the basematrix area for explicit memory implementations * It calls /allocate_GenePhase6_only * * * Arg: query [UNKN ] query data structure [GenePhaseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [GenePhase6 *] * */ GenePhase6 * Wise2_allocate_Expl_GenePhase6(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model,DPRunImpl * dpri); #define allocate_Expl_GenePhase6 Wise2_allocate_Expl_GenePhase6 /* Function: recalculate_PackAln_GenePhase6(pal,mat) * * Descrip: This function recalculates the PackAln structure produced by GenePhase6 * For example, in linear space methods this is used to score them * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * */ void Wise2_recalculate_PackAln_GenePhase6(PackAln * pal,GenePhase6 * mat); #define recalculate_PackAln_GenePhase6 Wise2_recalculate_PackAln_GenePhase6 /* Function: allocate_Small_GenePhase6(query,target,gp,general_model) * * Descrip: This function allocates the GenePhase6 structure * and the basematrix area for a small memory implementations * It calls /allocate_GenePhase6_only * * * Arg: query [UNKN ] query data structure [GenePhaseScore*] * Arg: target [UNKN ] target data structure [ComplexSequence*] * Arg: gp [UNKN ] Resource [GeneParser4Score *] * Arg: general_model [UNKN ] Resource [GeneralGeneModelScore *] * * Return [UNKN ] Undocumented return value [GenePhase6 *] * */ GenePhase6 * Wise2_allocate_Small_GenePhase6(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model); #define allocate_Small_GenePhase6 Wise2_allocate_Small_GenePhase6 /* Function: PackAln_calculate_Small_GenePhase6(mat,dpenv) * * Descrip: This function calculates an alignment for GenePhase6 structure in linear space * If you want only the start/end points * use /AlnRangeSet_calculate_Small_GenePhase6 * * The function basically * finds start/end points * foreach start/end point * calls /full_dc_GenePhase6 * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_calculate_Small_GenePhase6(GenePhase6 * mat,DPEnvelope * dpenv); #define PackAln_calculate_Small_GenePhase6 Wise2_PackAln_calculate_Small_GenePhase6 /* Function: AlnRangeSet_calculate_Small_GenePhase6(mat) * * Descrip: This function calculates an alignment for GenePhase6 structure in linear space * If you want the full alignment, use /PackAln_calculate_Small_GenePhase6 * If you have already got the full alignment, but want the range set, use /AlnRangeSet_from_PackAln_GenePhase6 * If you have got the small matrix but not the alignment, use /AlnRangeSet_from_GenePhase6 * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_calculate_Small_GenePhase6(GenePhase6 * mat); #define AlnRangeSet_calculate_Small_GenePhase6 Wise2_AlnRangeSet_calculate_Small_GenePhase6 /* Function: AlnRangeSet_from_GenePhase6(mat) * * Descrip: This function reads off a start/end structure * for GenePhase6 structure in linear space * If you want the full alignment use * /PackAln_calculate_Small_GenePhase6 * If you have not calculated the matrix use * /AlnRange_calculate_Small_GenePhase6 * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_from_GenePhase6(GenePhase6 * mat); #define AlnRangeSet_from_GenePhase6 Wise2_AlnRangeSet_from_GenePhase6 /* Function: convert_PackAln_to_AlnBlock_GenePhase6(pal) * * Descrip: Converts a path alignment to a label alignment * The label alignment is probably much more useful than the path * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_convert_PackAln_to_AlnBlock_GenePhase6(PackAln * pal); #define convert_PackAln_to_AlnBlock_GenePhase6 Wise2_convert_PackAln_to_AlnBlock_GenePhase6 /* Function: PackAln_read_Expl_GenePhase6(mat) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_Expl_GenePhase6(GenePhase6 * mat); #define PackAln_read_Expl_GenePhase6 Wise2_PackAln_read_Expl_GenePhase6 /* Function: PackAln_read_generic_GenePhase6(mat,h) * * Descrip: Reads off PackAln from explicit matrix structure * * * Arg: mat [UNKN ] Undocumented argument [GenePhase6 *] * Arg: h [UNKN ] Undocumented argument [GenePhase6_access_func_holder] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_read_generic_GenePhase6(GenePhase6 * mat,GenePhase6_access_func_holder h); #define PackAln_read_generic_GenePhase6 Wise2_PackAln_read_generic_GenePhase6 /* Function: calculate_GenePhase6(mat) * * Descrip: This function calculates the GenePhase6 matrix when in explicit mode * To allocate the matrix use /allocate_Expl_GenePhase6 * * * Arg: mat [UNKN ] GenePhase6 which contains explicit basematrix memory [GenePhase6 *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_GenePhase6(GenePhase6 * mat); #define calculate_GenePhase6 Wise2_calculate_GenePhase6 /* Function: calculate_dpenv_GenePhase6(mat,dpenv) * * Descrip: This function calculates the GenePhase6 matrix when in explicit mode, subject to the envelope * * * Arg: mat [UNKN ] GenePhase6 which contains explicit basematrix memory [GenePhase6 *] * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_calculate_dpenv_GenePhase6(GenePhase6 * mat,DPEnvelope * dpenv); #define calculate_dpenv_GenePhase6 Wise2_calculate_dpenv_GenePhase6 /* Function: GenePhase6_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenePhase6 *] * */ GenePhase6 * Wise2_GenePhase6_alloc(void); #define GenePhase6_alloc Wise2_GenePhase6_alloc /* Function: free_GenePhase6(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenePhase6 *] * * Return [UNKN ] Undocumented return value [GenePhase6 *] * */ GenePhase6 * Wise2_free_GenePhase6(GenePhase6 * obj); #define free_GenePhase6 Wise2_free_GenePhase6 /* Unplaced functions */ /* There has been no indication of the use of these functions */ AlnBlock * Wise2_AlnBlock_from_phased_protein_wrap(Protein * pro,ThreeStateModel * tsm,Genomic * gen,CodonMapper * cm,RandomModel * rm,CompMat * mat,PhasedProteinPara * ppp,GeneParameter21 * gpara,DPRunImpl * dpri,PackAln ** palret); #define AlnBlock_from_phased_protein_wrap Wise2_AlnBlock_from_phased_protein_wrap /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_GenePhase6_shatter_access_main(GenePhase6 * mat,int i,int j,int state); #define GenePhase6_shatter_access_main Wise2_GenePhase6_shatter_access_main int Wise2_GenePhase6_shatter_access_special(GenePhase6 * mat,int i,int j,int state); #define GenePhase6_shatter_access_special Wise2_GenePhase6_shatter_access_special void * Wise2_thread_loop_GenePhase6(void * ptr); #define thread_loop_GenePhase6 Wise2_thread_loop_GenePhase6 int Wise2_score_only_GenePhase6(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model); #define score_only_GenePhase6 Wise2_score_only_GenePhase6 GenePhase6 * Wise2_allocate_GenePhase6_only(GenePhaseScore* query,ComplexSequence* target ,GeneParser4Score * gp,GeneralGeneModelScore * general_model); #define allocate_GenePhase6_only Wise2_allocate_GenePhase6_only void Wise2_init_GenePhase6(GenePhase6 * mat); #define init_GenePhase6 Wise2_init_GenePhase6 AlnRange * Wise2_AlnRange_build_GenePhase6(GenePhase6 * mat,int stopj,int stopspecstate,int * startj,int * startspecstate); #define AlnRange_build_GenePhase6 Wise2_AlnRange_build_GenePhase6 boolean Wise2_read_hidden_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out); #define read_hidden_GenePhase6 Wise2_read_hidden_GenePhase6 int Wise2_max_hidden_GenePhase6(GenePhase6 * mat,int hiddenj,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_hidden_GenePhase6 Wise2_max_hidden_GenePhase6 boolean Wise2_read_special_strip_GenePhase6(GenePhase6 * mat,int stopi,int stopj,int stopstate,int * startj,int * startstate,PackAln * out); #define read_special_strip_GenePhase6 Wise2_read_special_strip_GenePhase6 int Wise2_max_special_strip_GenePhase6(GenePhase6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_special_strip_GenePhase6 Wise2_max_special_strip_GenePhase6 int Wise2_max_matrix_to_special_GenePhase6(GenePhase6 * mat,int i,int j,int state,int cscore,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore); #define max_matrix_to_special_GenePhase6 Wise2_max_matrix_to_special_GenePhase6 void Wise2_calculate_hidden_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv); #define calculate_hidden_GenePhase6 Wise2_calculate_hidden_GenePhase6 void Wise2_init_hidden_GenePhase6(GenePhase6 * mat,int starti,int startj,int stopi,int stopj); #define init_hidden_GenePhase6 Wise2_init_hidden_GenePhase6 boolean Wise2_full_dc_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,PackAln * out,int * donej,int totalj,DPEnvelope * dpenv); #define full_dc_GenePhase6 Wise2_full_dc_GenePhase6 boolean Wise2_do_dc_single_pass_GenePhase6(GenePhase6 * mat,int starti,int startj,int startstate,int stopi,int stopj,int stopstate,DPEnvelope * dpenv,int perc_done); #define do_dc_single_pass_GenePhase6 Wise2_do_dc_single_pass_GenePhase6 void Wise2_push_dc_at_merge_GenePhase6(GenePhase6 * mat,int starti,int stopi,int startj,int * stopj,DPEnvelope * dpenv); #define push_dc_at_merge_GenePhase6 Wise2_push_dc_at_merge_GenePhase6 void Wise2_follow_on_dc_GenePhase6(GenePhase6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define follow_on_dc_GenePhase6 Wise2_follow_on_dc_GenePhase6 void Wise2_run_up_dc_GenePhase6(GenePhase6 * mat,int starti,int stopi,int startj,int stopj,DPEnvelope * dpenv,int perc_done); #define run_up_dc_GenePhase6 Wise2_run_up_dc_GenePhase6 void Wise2_init_dc_GenePhase6(GenePhase6 * mat); #define init_dc_GenePhase6 Wise2_init_dc_GenePhase6 int Wise2_start_end_find_end_GenePhase6(GenePhase6 * mat,int * endj); #define start_end_find_end_GenePhase6 Wise2_start_end_find_end_GenePhase6 boolean Wise2_dc_optimised_start_end_calc_GenePhase6(GenePhase6 *mat,DPEnvelope * dpenv); #define dc_optimised_start_end_calc_GenePhase6 Wise2_dc_optimised_start_end_calc_GenePhase6 void Wise2_init_start_end_linear_GenePhase6(GenePhase6 * mat); #define init_start_end_linear_GenePhase6 Wise2_init_start_end_linear_GenePhase6 AlnConvertSet * Wise2_AlnConvertSet_GenePhase6(void); #define AlnConvertSet_GenePhase6 Wise2_AlnConvertSet_GenePhase6 int Wise2_GenePhase6_explicit_access_main(GenePhase6 * mat,int i,int j,int state); #define GenePhase6_explicit_access_main Wise2_GenePhase6_explicit_access_main int Wise2_GenePhase6_explicit_access_special(GenePhase6 * mat,int i,int j,int state); #define GenePhase6_explicit_access_special Wise2_GenePhase6_explicit_access_special int Wise2_find_end_GenePhase6(GenePhase6 * mat,int * ri,int * rj,int * state,boolean * isspecial,GenePhase6_access_func_holder h); #define find_end_GenePhase6 Wise2_find_end_GenePhase6 void Wise2_GenePhase6_debug_show_matrix(GenePhase6 * mat,int starti,int stopi,int startj,int stopj,FILE * ofp); #define GenePhase6_debug_show_matrix Wise2_GenePhase6_debug_show_matrix int Wise2_max_calc_GenePhase6(GenePhase6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GenePhase6_access_func_holder h); #define max_calc_GenePhase6 Wise2_max_calc_GenePhase6 int Wise2_max_calc_special_GenePhase6(GenePhase6 * mat,int i,int j,int state,boolean isspecial,int * reti,int * retj,int * retstate,boolean * retspecial,int * cellscore,GenePhase6_access_func_holder h); #define max_calc_special_GenePhase6 Wise2_max_calc_special_GenePhase6 #ifdef _cplusplus } #endif #endif wise-2.4.1/src/models/matchsum.typemap0000644000175000001440000000102610670453714017353 0ustar philippusers TYPEMAP Wise2_MatchSummarySet * T_Wise2_MatchSummarySet INPUT T_Wise2_MatchSummarySet $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_MatchSummarySet *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_MatchSummarySet sv_setref_pv($arg, "Wise2::MatchSummarySet", (void*) $var); TYPEMAP Wise2_MatchSummary * T_Wise2_MatchSummary INPUT T_Wise2_MatchSummary $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_MatchSummary *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_MatchSummary sv_setref_pv($arg, "Wise2::MatchSummary", (void*) $var); wise-2.4.1/src/models/seqhit.pod0000644000175000001440000002324310670453715016140 0ustar philippusers=head1 NAME seqhit module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item DnaSequenceHitList =item SegmentHitList =item SegmentHit =back =head1 DESCRIPTION =head2 Object DnaSequenceHitList =over =item forward Type [SegmentHitList *] Scalar No documentation =item backward Type [SegmentHitList *] Scalar No documentation =back No documentation for DnaSequenceHitList =head2 Member functions of DnaSequenceHitList =over =item show_DnaSequenceHitList &Wise2::DnaSequenceHitList::show_DnaSequenceHitList(dsl,ofp) shows a DnaSequenceHitsList - only really useful for debugging Argument dsl [UNKN ] Undocumented argument [DnaSequenceHitList *] Argument ofp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [void] =item read_MSPcrunch_DnaSequenceHitList &Wise2::DnaSequenceHitList::read_MSPcrunch_DnaSequenceHitList(ifp) Reads a MSPcrunch -x output file Argument ifp [UNKN ] input file to read [FILE *] Return [UNKN ] newly allocated structure [DnaSequenceHitList *] =item hard_link_DnaSequenceHitList &Wise2::DnaSequenceHitList::hard_link_DnaSequenceHitList(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [DnaSequenceHitList *] Return [UNKN ] Undocumented return value [DnaSequenceHitList *] =item alloc &Wise2::DnaSequenceHitList::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [DnaSequenceHitList *] =item set_forward &Wise2::DnaSequenceHitList::set_forward(obj,forward) Replace member variable forward For use principly by API functions Argument obj [UNKN ] Object holding the variable [DnaSequenceHitList *] Argument forward [OWNER] New value of the variable [SegmentHitList *] Return [SOFT ] member variable forward [boolean] =item forward &Wise2::DnaSequenceHitList::forward(obj) Access member variable forward For use principly by API functions Argument obj [UNKN ] Object holding the variable [DnaSequenceHitList *] Return [SOFT ] member variable forward [SegmentHitList *] =item set_backward &Wise2::DnaSequenceHitList::set_backward(obj,backward) Replace member variable backward For use principly by API functions Argument obj [UNKN ] Object holding the variable [DnaSequenceHitList *] Argument backward [OWNER] New value of the variable [SegmentHitList *] Return [SOFT ] member variable backward [boolean] =item backward &Wise2::DnaSequenceHitList::backward(obj) Access member variable backward For use principly by API functions Argument obj [UNKN ] Object holding the variable [DnaSequenceHitList *] Return [SOFT ] member variable backward [SegmentHitList *] =back =head2 Object SegmentHitList =over =item seghit Type [SegmentHit **] List No documentation =back No documentation for SegmentHitList =head2 Member functions of SegmentHitList =over =item hard_link_SegmentHitList &Wise2::SegmentHitList::hard_link_SegmentHitList(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [SegmentHitList *] Return [UNKN ] Undocumented return value [SegmentHitList *] =item SegmentHitList_alloc_std &Wise2::SegmentHitList::SegmentHitList_alloc_std(void) Equivalent to SegmentHitList_alloc_len(SegmentHitListLISTLENGTH) Return [UNKN ] Undocumented return value [SegmentHitList *] =item seghit &Wise2::SegmentHitList::seghit(obj,i) Access members stored in the seghit list For use principly by API functions Argument obj [UNKN ] Object holding the list [SegmentHitList *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [SegmentHit *] =item length_seghit &Wise2::SegmentHitList::length_seghit(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [SegmentHitList *] Return [UNKN ] length of the list [int] =item flush_seghit &Wise2::SegmentHitList::flush_seghit(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [SegmentHitList *] Return [UNKN ] Undocumented return value [int] =item add_seghit &Wise2::SegmentHitList::add_seghit(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [SegmentHitList *] Argument add [OWNER] Object to add to the list [SegmentHit *] Return [UNKN ] Undocumented return value [boolean] =back =head2 Object SegmentHit =over =item name Type [char *] Scalar No documentation =item qstart Type [int] Scalar No documentation =item qend Type [int] Scalar No documentation =item tstart Type [int] Scalar No documentation =item tend Type [int] Scalar No documentation =item score Type [double] Scalar No documentation =item next_hit Type [SegmentHit *] Scalar for collecting hits together ;) =back No documentation for SegmentHit =head2 Member functions of SegmentHit =over =item hard_link_SegmentHit &Wise2::SegmentHit::hard_link_SegmentHit(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [SegmentHit *] Return [UNKN ] Undocumented return value [SegmentHit *] =item alloc &Wise2::SegmentHit::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [SegmentHit *] =item set_name &Wise2::SegmentHit::set_name(obj,name) Replace member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Argument name [OWNER] New value of the variable [char *] Return [SOFT ] member variable name [boolean] =item name &Wise2::SegmentHit::name(obj) Access member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Return [SOFT ] member variable name [char *] =item set_qstart &Wise2::SegmentHit::set_qstart(obj,qstart) Replace member variable qstart For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Argument qstart [OWNER] New value of the variable [int] Return [SOFT ] member variable qstart [boolean] =item qstart &Wise2::SegmentHit::qstart(obj) Access member variable qstart For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Return [SOFT ] member variable qstart [int] =item set_qend &Wise2::SegmentHit::set_qend(obj,qend) Replace member variable qend For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Argument qend [OWNER] New value of the variable [int] Return [SOFT ] member variable qend [boolean] =item qend &Wise2::SegmentHit::qend(obj) Access member variable qend For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Return [SOFT ] member variable qend [int] =item set_tstart &Wise2::SegmentHit::set_tstart(obj,tstart) Replace member variable tstart For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Argument tstart [OWNER] New value of the variable [int] Return [SOFT ] member variable tstart [boolean] =item tstart &Wise2::SegmentHit::tstart(obj) Access member variable tstart For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Return [SOFT ] member variable tstart [int] =item set_tend &Wise2::SegmentHit::set_tend(obj,tend) Replace member variable tend For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Argument tend [OWNER] New value of the variable [int] Return [SOFT ] member variable tend [boolean] =item tend &Wise2::SegmentHit::tend(obj) Access member variable tend For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Return [SOFT ] member variable tend [int] =item set_score &Wise2::SegmentHit::set_score(obj,score) Replace member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Argument score [OWNER] New value of the variable [double] Return [SOFT ] member variable score [boolean] =item score &Wise2::SegmentHit::score(obj) Access member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Return [SOFT ] member variable score [double] =item set_next_hit &Wise2::SegmentHit::set_next_hit(obj,next_hit) Replace member variable next_hit For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Argument next_hit [OWNER] New value of the variable [SegmentHit *] Return [SOFT ] member variable next_hit [boolean] =item next_hit &Wise2::SegmentHit::next_hit(obj) Access member variable next_hit For use principly by API functions Argument obj [UNKN ] Object holding the variable [SegmentHit *] Return [SOFT ] member variable next_hit [SegmentHit *] =back wise-2.4.1/src/models/seqhit.tex0000644000175000001440000000534210670453715016156 0ustar philippusers\section{seqhit} \label{module_seqhit} This module contains the following objects \begin{itemize} \item \ref{object_DnaSequenceHitList} DnaSequenceHitList \item \ref{object_SegmentHitList} SegmentHitList \item \ref{object_SegmentHit} SegmentHit \end{itemize} \subsection{Object DnaSequenceHitList} \label{object_DnaSequenceHitList} The DnaSequenceHitList object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{forward} Type [SegmentHitList * : Scalar] No documentation \item{backward} Type [SegmentHitList * : Scalar] No documentation \end{description} No documentation for DnaSequenceHitList Member functions of DnaSequenceHitList \subsubsection{show_DnaSequenceHitList} \begin{description} \item[External C] {\tt Wise2_show_DnaSequenceHitList (dsl,ofp)} \item[Perl] {\tt &Wise2::DnaSequenceHitList::show_DnaSequenceHitList (dsl,ofp)} \item[Perl-OOP call] {\tt $obj->show_DnaSequenceHitList(ofp)} \end{description} Arguments \begin{description} \item[dsl] [UNKN ] Undocumented argument [DnaSequenceHitList *] \item[ofp] [UNKN ] Undocumented argument [FILE *] \item[returns] Nothing - no return value \end{description} shows a DnaSequenceHitsList - only really useful for debugging \subsubsection{read_MSPcrunch_DnaSequenceHitList} \begin{description} \item[External C] {\tt Wise2_read_MSPcrunch_DnaSequenceHitList (ifp)} \item[Perl] {\tt &Wise2::DnaSequenceHitList::read_MSPcrunch_DnaSequenceHitList (ifp)} \item[Perl-OOP call] {\tt $obj->read_MSPcrunch_DnaSequenceHitList()} \end{description} Arguments \begin{description} \item[ifp] [UNKN ] input file to read [FILE *] \item[returns] [UNKN ] newly allocated structure [DnaSequenceHitList *] \end{description} Reads a MSPcrunch -x output file \subsection{Object SegmentHitList} \label{object_SegmentHitList} The SegmentHitList object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{seghit} Type [SegmentHit ** : List] No documentation \end{description} No documentation for SegmentHitList Member functions of SegmentHitList \subsection{Object SegmentHit} \label{object_SegmentHit} The SegmentHit object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{name} Type [char * : Scalar] No documentation \item{qstart} Type [int : Scalar] No documentation \item{qend} Type [int : Scalar] No documentation \item{tstart} Type [int : Scalar] No documentation \item{tend} Type [int : Scalar] No documentation \item{score} Type [double : Scalar] No documentation \item{next_hit} Type [SegmentHit * : Scalar] for collecting hits together ;) \end{description} No documentation for SegmentHit Member functions of SegmentHit wise-2.4.1/src/models/motifmatrix.c0000644000175000001440000003572510670453714016655 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "motifmatrix.h" # line 46 "motifmatrix.dy" MotifMatrixScore * MotifMatrixScore_from_MotifMatrixPara(MotifMatrixPara * mmp) { MotifMatrixScore * out; DnaProbMatrix * dmp; out = MotifMatrixScore_alloc(); dmp = DnaProbMatrix_from_match(mmp->comp_in_match,NMaskType_BANNED); assert(dmp); flat_null_DnaProbMatrix(dmp); out->comp_in_motif = DnaMatrix_from_DnaProbMatrix(dmp); free_DnaProbMatrix(dmp); dmp = DnaProbMatrix_from_match(mmp->comp_out_match,NMaskType_BANNED); assert(dmp); flat_null_DnaProbMatrix(dmp); out->comp_out_motif = DnaMatrix_from_DnaProbMatrix(dmp); free_DnaProbMatrix(dmp); dmp = DnaProbMatrix_from_match(mmp->comp_spacer,NMaskType_BANNED); assert(dmp); flat_null_DnaProbMatrix(dmp); out->comp_spacer = DnaMatrix_from_DnaProbMatrix(dmp); free_DnaProbMatrix(dmp); out->region_in = Probability2Score(mmp->region_in); out->motif_indel = Probability2Score(mmp->motif_indel); out->cons_indel = Probability2Score(mmp->cons_indel); out->spacer_indel = Probability2Score(mmp->spacer_indel); out->spacer_to_cons = Probability2Score(mmp->spacer_to_cons); out->spacer_to_motif = Probability2Score(mmp->spacer_to_motif); out->spacer_duration = Probability2Score(mmp->spacer_duration); out->motif_duration = Probability2Score(mmp->motif_duration); out->cons_duration = Probability2Score(mmp->cons_duration); return out; } # line 90 "motifmatrix.dy" MotifMatrixPara * new_MotifMatrixPara_from_argv(int * argc,char ** argv) { MotifMatrixPara * out; out = MotifMatrixPara_alloc(); out->comp_in_match = 0.9; out->comp_out_match = 0.75; out->comp_spacer = 0.35; out->region_in = 0.0001; out->motif_indel = 0.00001; out->cons_indel = 0.025; out->spacer_indel = 0.1; out->spacer_duration = 0.2; out->motif_duration = 0.9; out->cons_duration = 0.7; out->spacer_to_motif = 0.05; out->spacer_to_cons = 0.000001; strip_out_float_argument(argc,argv,"mm_motif",&out->comp_in_match); strip_out_float_argument(argc,argv,"mm_cons",&out->comp_out_match); strip_out_float_argument(argc,argv,"mm_spacer",&out->comp_spacer); strip_out_float_argument(argc,argv,"mm_motif_indel",&out->motif_indel); strip_out_float_argument(argc,argv,"mm_cons_indel",&out->cons_indel); strip_out_float_argument(argc,argv,"mm_spacer_indel",&out->spacer_indel); strip_out_float_argument(argc,argv,"mm_switch_motif",&out->spacer_to_motif); strip_out_float_argument(argc,argv,"mm_switch_cons",&out->spacer_to_cons); return out; } # line 121 "motifmatrix.dy" void show_help_MotifMatrixPara(FILE * ofp) { fprintf(ofp,"Motif Matrix matching paramters\n"); fprintf(ofp," -mm_motif [0.9] Probability of a match in a motif\n"); fprintf(ofp," -mm_cons [0.75] Probability of a match in a non-motif conserved\n"); fprintf(ofp," -mm_spacer[0.35] Probability of a match in a spacer\n"); fprintf(ofp," -mm_motif_indel [0.00001] indel inside a motif\n"); fprintf(ofp," -mm_cons_indel [0.025] indel inside a conserved region\n"); fprintf(ofp," -mm_spacer_indel [0.1] indel inside a spacer\n"); fprintf(ofp," -mm_switch_motif [0.05] cost of switching to motif match\n"); fprintf(ofp," -mm_switch_cons [0.000001] cost of switching to conserved match\n"); } # line 135 "motifmatrix.dy" MotifConsMatrix * new_MotifConsMatrix(TransFactorMatchSet * one,int starti,int endi,TransFactorMatchSet * two,int startj,int endj) { int i; int j; int l; int k; int z; MotifConsMatrix * out; int motif_len; assert(one != NULL); assert(two != NULL); out = MotifConsMatrix_alloc_matrix(endi-starti,endj-startj); for(i=0;i< (endi-starti);i++) { for(j=0;j< (endj-startj) ;j++) { out->mat[i][j] = 0; } } for(l=0;llen;l++) { if( one->match[l]->start < starti || one->match[l]->end > endi ) { continue; } for(k=0;klen;k++) { if( two->match[k]->start < startj || two->match[k]->end > endj ) { continue; } if( two->match[k]->factor != one->match[l]->factor ) { continue; } motif_len = one->match[l]->end - one->match[l]->start; for(z=0;zmat[one->match[l]->start-starti+z][two->match[k]->start-startj+z] = 1; } } } return out; } # line 145 "motifmatrix.c" /* Function: hard_link_MotifMatrixPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MotifMatrixPara *] * * Return [UNKN ] Undocumented return value [MotifMatrixPara *] * */ MotifMatrixPara * hard_link_MotifMatrixPara(MotifMatrixPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a MotifMatrixPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: MotifMatrixPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MotifMatrixPara *] * */ MotifMatrixPara * MotifMatrixPara_alloc(void) { MotifMatrixPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(MotifMatrixPara *) ckalloc (sizeof(MotifMatrixPara))) == NULL) { warn("MotifMatrixPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->comp_in_match = 0.0; out->comp_out_match = 0.0; out->comp_spacer = 0.0; out->region_in = 0.0; out->motif_indel = 0.0; out->cons_indel = 0.0; out->spacer_indel = 0.0; out->spacer_to_cons = 0.0; out->spacer_to_motif = 0.0; out->spacer_duration = 0.0; out->motif_duration = 0.0; out->cons_duration = 0.0; return out; } /* Function: free_MotifMatrixPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MotifMatrixPara *] * * Return [UNKN ] Undocumented return value [MotifMatrixPara *] * */ MotifMatrixPara * free_MotifMatrixPara(MotifMatrixPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a MotifMatrixPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_MotifMatrixScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MotifMatrixScore *] * * Return [UNKN ] Undocumented return value [MotifMatrixScore *] * */ MotifMatrixScore * hard_link_MotifMatrixScore(MotifMatrixScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a MotifMatrixScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: MotifMatrixScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MotifMatrixScore *] * */ MotifMatrixScore * MotifMatrixScore_alloc(void) { MotifMatrixScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(MotifMatrixScore *) ckalloc (sizeof(MotifMatrixScore))) == NULL) { warn("MotifMatrixScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->comp_in_motif = NULL; out->comp_out_motif = NULL; out->comp_spacer = NULL; out->region_in = 0; out->motif_indel = 0; out->cons_indel = 0; out->spacer_indel = 0; out->spacer_to_cons = 0; out->spacer_to_motif = 0; out->spacer_duration = 0; out->motif_duration = 0; out->cons_duration = 0; return out; } /* Function: free_MotifMatrixScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MotifMatrixScore *] * * Return [UNKN ] Undocumented return value [MotifMatrixScore *] * */ MotifMatrixScore * free_MotifMatrixScore(MotifMatrixScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a MotifMatrixScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->comp_in_motif != NULL) free_DnaMatrix(obj->comp_in_motif); if( obj->comp_out_motif != NULL) free_DnaMatrix(obj->comp_out_motif); if( obj->comp_spacer != NULL) free_DnaMatrix(obj->comp_spacer); ckfree(obj); return NULL; } /* Function: MotifConsMatrix_alloc_matrix(leni,lenj) * * Descrip: Allocates structure and matrix * * * Arg: leni [UNKN ] Length of first dimension of matrix [int] * Arg: lenj [UNKN ] Length of second dimension of matrix [int] * * Return [UNKN ] Undocumented return value [MotifConsMatrix *] * */ MotifConsMatrix * MotifConsMatrix_alloc_matrix(int leni,int lenj) { MotifConsMatrix * out; /* out is exported */ register int i; /* for stepping down matrix */ register int j; /* for stepping across matrix */ /* Call alloc function, return NULL if NULL */ if((out = MotifConsMatrix_alloc()) == NULL) return NULL; /* Allocate memory for mat */ if((out->mat = (char **) ckcalloc (leni,sizeof(char *))) == NULL) { warn("Memory allocation problem in matrix for MotifConsMatrix mat, first pointer set"); ckfree(out); return NULL; } /* Add NULL to all matrix pointers so free can be called */ for(i=0;imat[i] = NULL; /* Allocate each matrix row */ for(i=0;imat[i] = (char *) ckcalloc (lenj,sizeof(char )); if( out->mat[i] == NULL) { warn("Failed alloc on %d, calling free and returning NULL",i); free_MotifConsMatrix(out); return NULL; } } for(i=0;imat[i][j] = NULL; } out->leni=out->maxleni=leni; out->lenj=out->maxlenj=lenj; return out; } /* Function: expand_MotifConsMatrix(obj,leni,lenj) * * Descrip: Expands matrix. Rarely used * * * Arg: obj [UNKN ] Undocumented argument [MotifConsMatrix *] * Arg: leni [UNKN ] Undocumented argument [int] * Arg: lenj [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_MotifConsMatrix(MotifConsMatrix * obj,int leni,int lenj) { int i; int actualj; if( obj == NULL) { warn("Trying to expand a MotifConsMatrix but is NULL!"); return FALSE; } if( leni <= obj->maxleni && lenj <= obj->maxlenj) return TRUE; if( obj->maxleni < leni ) { if( (obj->mat=(char **) ckrealloc (obj->mat,sizeof(char *)*leni)) == NULL) return FALSE; obj->maxleni=obj->leni=leni; } if( lenj > obj->maxlenj ) actualj = lenj; else actualj = obj->maxlenj; for(i=0;ileni;i++) { if((obj->mat[i] = (char *) realloc (obj->mat[i],sizeof(char ) * actualj)) == NULL) return FALSE; } return TRUE; } /* Function: hard_link_MotifConsMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MotifConsMatrix *] * * Return [UNKN ] Undocumented return value [MotifConsMatrix *] * */ MotifConsMatrix * hard_link_MotifConsMatrix(MotifConsMatrix * obj) { if( obj == NULL ) { warn("Trying to hard link to a MotifConsMatrix object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: MotifConsMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MotifConsMatrix *] * */ MotifConsMatrix * MotifConsMatrix_alloc(void) { MotifConsMatrix * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(MotifConsMatrix *) ckalloc (sizeof(MotifConsMatrix))) == NULL) { warn("MotifConsMatrix_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->mat = NULL; out->leni=out->maxleni=0; out->lenj=out->maxlenj=0; return out; } /* Function: free_MotifConsMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MotifConsMatrix *] * * Return [UNKN ] Undocumented return value [MotifConsMatrix *] * */ MotifConsMatrix * free_MotifConsMatrix(MotifConsMatrix * obj) { int return_early = 0; int i; int j; if( obj == NULL) { warn("Attempting to free a NULL pointer to a MotifConsMatrix obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->mat != NULL) { for(i=0;ileni;i++) { if( obj->mat[i] != NULL) ckfree(obj->mat[i]); } ckfree(obj->mat); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/models/motifmatrix.h0000644000175000001440000001706610670453714016660 0ustar philippusers#ifndef DYNAMITEmotifmatrixHEADERFILE #define DYNAMITEmotifmatrixHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "transregion.h" struct Wise2_MotifMatrixPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability comp_in_match; Probability comp_out_match; Probability comp_spacer; Probability region_in; Probability motif_indel; Probability cons_indel; Probability spacer_indel; Probability spacer_to_cons; Probability spacer_to_motif; Probability spacer_duration; Probability motif_duration; Probability cons_duration; } ; /* MotifMatrixPara defined */ #ifndef DYNAMITE_DEFINED_MotifMatrixPara typedef struct Wise2_MotifMatrixPara Wise2_MotifMatrixPara; #define MotifMatrixPara Wise2_MotifMatrixPara #define DYNAMITE_DEFINED_MotifMatrixPara #endif struct Wise2_MotifMatrixScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DnaMatrix * comp_in_motif; DnaMatrix * comp_out_motif; DnaMatrix * comp_spacer; Score region_in; Score motif_indel; Score cons_indel; Score spacer_indel; Score spacer_to_cons; Score spacer_to_motif; Score spacer_duration; Score motif_duration; Score cons_duration; } ; /* MotifMatrixScore defined */ #ifndef DYNAMITE_DEFINED_MotifMatrixScore typedef struct Wise2_MotifMatrixScore Wise2_MotifMatrixScore; #define MotifMatrixScore Wise2_MotifMatrixScore #define DYNAMITE_DEFINED_MotifMatrixScore #endif struct Wise2_MotifConsMatrix { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char ** mat; int leni; /* leni for above mat */ int maxleni;/* max length for above pointer set */ int lenj; /* lenj for above mat */ int maxlenj;/* max length for above pointer set */ } ; /* MotifConsMatrix defined */ #ifndef DYNAMITE_DEFINED_MotifConsMatrix typedef struct Wise2_MotifConsMatrix Wise2_MotifConsMatrix; #define MotifConsMatrix Wise2_MotifConsMatrix #define DYNAMITE_DEFINED_MotifConsMatrix #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_MotifMatrixPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MotifMatrixPara *] * * Return [UNKN ] Undocumented return value [MotifMatrixPara *] * */ MotifMatrixPara * Wise2_hard_link_MotifMatrixPara(MotifMatrixPara * obj); #define hard_link_MotifMatrixPara Wise2_hard_link_MotifMatrixPara /* Function: MotifMatrixPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MotifMatrixPara *] * */ MotifMatrixPara * Wise2_MotifMatrixPara_alloc(void); #define MotifMatrixPara_alloc Wise2_MotifMatrixPara_alloc /* Function: free_MotifMatrixPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MotifMatrixPara *] * * Return [UNKN ] Undocumented return value [MotifMatrixPara *] * */ MotifMatrixPara * Wise2_free_MotifMatrixPara(MotifMatrixPara * obj); #define free_MotifMatrixPara Wise2_free_MotifMatrixPara /* Function: hard_link_MotifMatrixScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MotifMatrixScore *] * * Return [UNKN ] Undocumented return value [MotifMatrixScore *] * */ MotifMatrixScore * Wise2_hard_link_MotifMatrixScore(MotifMatrixScore * obj); #define hard_link_MotifMatrixScore Wise2_hard_link_MotifMatrixScore /* Function: MotifMatrixScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MotifMatrixScore *] * */ MotifMatrixScore * Wise2_MotifMatrixScore_alloc(void); #define MotifMatrixScore_alloc Wise2_MotifMatrixScore_alloc /* Function: free_MotifMatrixScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MotifMatrixScore *] * * Return [UNKN ] Undocumented return value [MotifMatrixScore *] * */ MotifMatrixScore * Wise2_free_MotifMatrixScore(MotifMatrixScore * obj); #define free_MotifMatrixScore Wise2_free_MotifMatrixScore /* Function: MotifConsMatrix_alloc_matrix(leni,lenj) * * Descrip: Allocates structure and matrix * * * Arg: leni [UNKN ] Length of first dimension of matrix [int] * Arg: lenj [UNKN ] Length of second dimension of matrix [int] * * Return [UNKN ] Undocumented return value [MotifConsMatrix *] * */ MotifConsMatrix * Wise2_MotifConsMatrix_alloc_matrix(int leni,int lenj); #define MotifConsMatrix_alloc_matrix Wise2_MotifConsMatrix_alloc_matrix /* Function: hard_link_MotifConsMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [MotifConsMatrix *] * * Return [UNKN ] Undocumented return value [MotifConsMatrix *] * */ MotifConsMatrix * Wise2_hard_link_MotifConsMatrix(MotifConsMatrix * obj); #define hard_link_MotifConsMatrix Wise2_hard_link_MotifConsMatrix /* Function: MotifConsMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [MotifConsMatrix *] * */ MotifConsMatrix * Wise2_MotifConsMatrix_alloc(void); #define MotifConsMatrix_alloc Wise2_MotifConsMatrix_alloc /* Function: free_MotifConsMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [MotifConsMatrix *] * * Return [UNKN ] Undocumented return value [MotifConsMatrix *] * */ MotifConsMatrix * Wise2_free_MotifConsMatrix(MotifConsMatrix * obj); #define free_MotifConsMatrix Wise2_free_MotifConsMatrix /* Unplaced functions */ /* There has been no indication of the use of these functions */ MotifMatrixScore * Wise2_MotifMatrixScore_from_MotifMatrixPara(MotifMatrixPara * mmp); #define MotifMatrixScore_from_MotifMatrixPara Wise2_MotifMatrixScore_from_MotifMatrixPara MotifMatrixPara * Wise2_new_MotifMatrixPara_from_argv(int * argc,char ** argv); #define new_MotifMatrixPara_from_argv Wise2_new_MotifMatrixPara_from_argv void Wise2_show_help_MotifMatrixPara(FILE * ofp); #define show_help_MotifMatrixPara Wise2_show_help_MotifMatrixPara MotifConsMatrix * Wise2_new_MotifConsMatrix(TransFactorMatchSet * one,int starti,int endi,TransFactorMatchSet * two,int startj,int endj); #define new_MotifConsMatrix Wise2_new_MotifConsMatrix /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_expand_MotifConsMatrix(MotifConsMatrix * obj,int leni,int lenj); #define expand_MotifConsMatrix Wise2_expand_MotifConsMatrix #ifdef _cplusplus } #endif #endif wise-2.4.1/src/socket/0000755000175000001440000000000010670453715014140 5ustar philippuserswise-2.4.1/src/socket/simplebufferedserver.dy0000644000175000001440000000660610247063772020731 0ustar philippusers %{ #include "wisebase.h" #include typedef char BufferedString; #define SimpleBufferedServerLISTLENGTH 1024 %} struct SimpleBufferedServer int socket BufferedString ** buffer !list int current_read %{ #include "simplebufferedserver.h" #include #include #include #include #include #include void write_buffer_simple_buffered_server_impl(void * handle,char * string) { SimpleBufferedServer * sbs = (SimpleBufferedServer*) handle; add_string_SimpleBufferedServer(sbs,string); } void write_bufferf_simple_buffered_server_impl(void * handle,char * format,...) { SimpleBufferedServer * sbs = (SimpleBufferedServer*) handle; char buffer[1024]; va_list ap; va_start(ap,format); vsprintf(buffer,format,ap); add_string_SimpleBufferedServer(sbs,buffer); return; } void close_and_free_simple_buffered_server(void * handle) { /* no-op, as this is not the owner */ return; } void add_string_SimpleBufferedServer(SimpleBufferedServer * sbs,char * unallocated_string) { add_SimpleBufferedServer(sbs,stringalloc(unallocated_string)); } Wise2WriteStreamInterface * WriteStream_from_SimpleBufferedServer(SimpleBufferedServer * sbs) { Wise2WriteStreamInterface * out; out = malloc(sizeof(Wise2WriteStreamInterface)); out->write_buffer = write_buffer_simple_buffered_server_impl; out->write_bufferf = write_bufferf_simple_buffered_server_impl; out->close_and_free_handle = close_and_free_simple_buffered_server; out->handle = (void *) sbs; return out; } SimpleBufferedServer * new_SimpleBufferedServer(int port) { struct sockaddr_in server; struct sockaddr * name; SimpleBufferedServer * out; int yes = 1; out = SimpleBufferedServer_alloc_std(); out->socket = socket(AF_INET, SOCK_STREAM, 0); server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(port); setsockopt(out->socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes); /* If setsockopt() fails, we're not too unhappy, so no check */ if (bind(out->socket, (struct sockaddr *)&server, sizeof(server))) { /* Probably tried to bind to a port that was already in use... */ fatal(strerror(errno)); } return out; } char * free_BufferedString(char * str) { free(str); } void listen_and_respond_SimpleBufferedServer(SimpleBufferedServer * sbs) { int i; char buf[1024]; int ret; int len; int curr; int ms; int new_socket; listen(sbs->socket, 5); while( 1 ) { fprintf(stderr,"blocking at accept...\n"); ms = accept(sbs->socket, 0, 0); fprintf(stderr,"Accepted socket...\n"); read(ms,buf,sizeof(buf)); fprintf(stderr,"Read buffer...\n"); if( strstartcmp(buf,"") == 0 ) { for(i=0;ilen;i++) { fprintf(stderr,"Going to send position %d\n",i); len = strlen(sbs->buffer[i]); curr = 0; while( curr < len ) { fprintf(stderr,"Going to send at position %d\n",curr); ret = write(ms,sbs->buffer[i]+curr,len-curr); if( ret == -1 ) { warn("error sending with %d\n",errno); } fprintf(stderr,"...sent at position %d, sent %d bytes [%.6s]\n",curr,ret,sbs->buffer[i]); if( ret+curr >= len ) { break; } curr += ret; sleep(2); } } buf[0] = '\0'; write(ms,buf,1); close(ms); } else { fatal("Bad client initialisation string...%s\n",buf); } } } %} wise-2.4.1/src/socket/anonobj.dy0000644000175000001440000000177507732124027016132 0ustar philippusers %{ #include "wisebase.h" #define AnonymousObjectListLISTLENGTH 16 %} struct AnonymousObject void * obj !link char * type void (*free_object)(void *) !func struct AnonymousObjectList AnonymousObject ** anon !list %{ #include "anonobj.h" %func frees an anonymous object %% !deconstructor AnonymousObject * free_AnonymousObject(AnonymousObject * ao) { int return_early = 0; #ifdef PTHREAD assert(pthread_mutex_lock(&(ao->dynamite_mutex)) == 0); #endif if( ao->dynamite_hard_link > 1) { return_early = 1; ao->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(ao->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( ao->obj != NULL ) { if( ao->free_object == NULL ) { warn("With object of %s, no registered free function, but with a present object. Likely to be leaking memory now",ao->type); } else { (*ao->free_object)(ao->obj); } } free(ao); return NULL; } %} wise-2.4.1/src/socket/transferinterface.c0000644000175000001440000003247410670453715020023 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "transferinterface.h" # line 29 "transferinterface.dy" TransferedFunctionCall * test_stringcat_TransferedFunctionCall(void) { TransferedFunctionCall * out; out = TransferedFunctionCall_alloc_std(); out->name = stringalloc("stringcat"); out->returned_type = new_string_Marshaller(); add_TransferedFunctionCall(out,new_string_Marshaller()); add_TransferedFunctionCall(out,new_string_Marshaller()); return out; } # line 44 "transferinterface.dy" TransferedObjectMarshaller * new_string_Marshaller(void) { TransferedObjectMarshaller * out; out = TransferedObjectMarshaller_alloc(); out->object_to_stream = object_to_stream_string; out->stream_to_object = stream_to_object_string; return out; } # line 54 "transferinterface.dy" void object_to_stream_string(void * obj,Wise2WriteStreamInterface* write) { char * string = (char *) obj; fprintf(stderr,"Writing to buffer with string [%s]\n",string); (*write->write_buffer)(write->handle,string); (*write->write_buffer)(write->handle,"\n//\n"); } # line 63 "transferinterface.dy" void * stream_to_object_string(Wise2ReadStreamInterface * read) { char buffer[1024]; char * out; int i; fprintf(stderr,"reading string...\n"); WISE2_READ_BUFFER(buffer,1024,read); fprintf(stderr,"read buffer %s...\n",buffer); for(i=0;i<1024;i++) { if( buffer[i] == '\n' || buffer[i] == '\r' || buffer[i] == '\0' ) { break; } } buffer[i] = '\0'; out = stringalloc(buffer); WISE2_READ_BUFFER(buffer,1024,read); fprintf(stderr,"discarding buffer... %s, have string %s\n",buffer,out); return out; } # line 74 "transferinterface.c" /* Function: hard_link_TransferedObjectMarshaller(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransferedObjectMarshaller *] * * Return [UNKN ] Undocumented return value [TransferedObjectMarshaller *] * */ TransferedObjectMarshaller * hard_link_TransferedObjectMarshaller(TransferedObjectMarshaller * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransferedObjectMarshaller object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransferedObjectMarshaller_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransferedObjectMarshaller *] * */ TransferedObjectMarshaller * TransferedObjectMarshaller_alloc(void) { TransferedObjectMarshaller * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransferedObjectMarshaller *) ckalloc (sizeof(TransferedObjectMarshaller))) == NULL) { warn("TransferedObjectMarshaller_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->object_to_stream = NULL; out->stream_to_object = NULL; out->untyped_free_object = NULL; return out; } /* Function: free_TransferedObjectMarshaller(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransferedObjectMarshaller *] * * Return [UNKN ] Undocumented return value [TransferedObjectMarshaller *] * */ TransferedObjectMarshaller * free_TransferedObjectMarshaller(TransferedObjectMarshaller * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransferedObjectMarshaller obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->object_to_stream is a function pointer */ /* obj->stream_to_object is a function pointer */ /* obj->object_type is linked in */ /* obj->untyped_free_object is a function pointer */ ckfree(obj); return NULL; } /* Function: swap_TransferedFunctionCall(list,i,j) * * Descrip: swap function: an internal for qsort_TransferedFunctionCall * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [TransferedObjectMarshaller **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_TransferedFunctionCall(TransferedObjectMarshaller ** list,int i,int j) { TransferedObjectMarshaller * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_TransferedFunctionCall(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_TransferedFunctionCall which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [TransferedObjectMarshaller **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_TransferedFunctionCall(TransferedObjectMarshaller ** list,int left,int right,int (*comp)(TransferedObjectMarshaller * ,TransferedObjectMarshaller * )) { int i,last; if( left >= right ) return; swap_TransferedFunctionCall(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_TransferedFunctionCall (list,++last,i); } swap_TransferedFunctionCall (list,left,last); qsort_TransferedFunctionCall(list,left,last-1,comp); qsort_TransferedFunctionCall(list,last+1,right,comp); } /* Function: sort_TransferedFunctionCall(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_TransferedFunctionCall * * * Arg: obj [UNKN ] Object containing list [TransferedFunctionCall *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_TransferedFunctionCall(TransferedFunctionCall * obj,int (*comp)(TransferedObjectMarshaller *, TransferedObjectMarshaller *)) { qsort_TransferedFunctionCall(obj->input,0,obj->len-1,comp); return; } /* Function: expand_TransferedFunctionCall(obj,len) * * Descrip: Really an internal function for add_TransferedFunctionCall * * * Arg: obj [UNKN ] Object which contains the list [TransferedFunctionCall *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_TransferedFunctionCall(TransferedFunctionCall * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_TransferedFunctionCall called with no need"); return TRUE; } if( (obj->input = (TransferedObjectMarshaller ** ) ckrealloc (obj->input,sizeof(TransferedObjectMarshaller *)*len)) == NULL) { warn("ckrealloc failed for expand_TransferedFunctionCall, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_TransferedFunctionCall(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransferedFunctionCall *] * Arg: add [OWNER] Object to add to the list [TransferedObjectMarshaller *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_TransferedFunctionCall(TransferedFunctionCall * obj,TransferedObjectMarshaller * add) { if( obj->len >= obj->maxlen) { if( expand_TransferedFunctionCall(obj,obj->len + TransferedFunctionCallLISTLENGTH) == FALSE) return FALSE; } obj->input[obj->len++]=add; return TRUE; } /* Function: flush_TransferedFunctionCall(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransferedFunctionCall *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_TransferedFunctionCall(TransferedFunctionCall * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->input[i] != NULL) { free_TransferedObjectMarshaller(obj->input[i]); obj->input[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: TransferedFunctionCall_alloc_std(void) * * Descrip: Equivalent to TransferedFunctionCall_alloc_len(TransferedFunctionCallLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransferedFunctionCall *] * */ TransferedFunctionCall * TransferedFunctionCall_alloc_std(void) { return TransferedFunctionCall_alloc_len(TransferedFunctionCallLISTLENGTH); } /* Function: TransferedFunctionCall_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransferedFunctionCall *] * */ TransferedFunctionCall * TransferedFunctionCall_alloc_len(int len) { TransferedFunctionCall * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = TransferedFunctionCall_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->input = (TransferedObjectMarshaller ** ) ckcalloc (len,sizeof(TransferedObjectMarshaller *))) == NULL) { warn("Warning, ckcalloc failed in TransferedFunctionCall_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_TransferedFunctionCall(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransferedFunctionCall *] * * Return [UNKN ] Undocumented return value [TransferedFunctionCall *] * */ TransferedFunctionCall * hard_link_TransferedFunctionCall(TransferedFunctionCall * obj) { if( obj == NULL ) { warn("Trying to hard link to a TransferedFunctionCall object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TransferedFunctionCall_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransferedFunctionCall *] * */ TransferedFunctionCall * TransferedFunctionCall_alloc(void) { TransferedFunctionCall * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TransferedFunctionCall *) ckalloc (sizeof(TransferedFunctionCall))) == NULL) { warn("TransferedFunctionCall_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->returned_type = NULL; out->input = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_TransferedFunctionCall(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransferedFunctionCall *] * * Return [UNKN ] Undocumented return value [TransferedFunctionCall *] * */ TransferedFunctionCall * free_TransferedFunctionCall(TransferedFunctionCall * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TransferedFunctionCall obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->returned_type != NULL) free_TransferedObjectMarshaller(obj->returned_type); if( obj->input != NULL) { for(i=0;ilen;i++) { if( obj->input[i] != NULL) free_TransferedObjectMarshaller(obj->input[i]); } ckfree(obj->input); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/socket/transferinterface.h0000644000175000001440000001767110670453715020032 0ustar philippusers#ifndef DYNAMITEtransferinterfaceHEADERFILE #define DYNAMITEtransferinterfaceHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #define TransferedFunctionCallLISTLENGTH 16 struct Wise2_TransferedObjectMarshaller { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif void (*object_to_stream)(void *,Wise2WriteStreamInterface*); void * (*stream_to_object)(Wise2ReadStreamInterface*); char * object_type; void (*untyped_free_object)(void *); } ; /* TransferedObjectMarshaller defined */ #ifndef DYNAMITE_DEFINED_TransferedObjectMarshaller typedef struct Wise2_TransferedObjectMarshaller Wise2_TransferedObjectMarshaller; #define TransferedObjectMarshaller Wise2_TransferedObjectMarshaller #define DYNAMITE_DEFINED_TransferedObjectMarshaller #endif struct Wise2_TransferedFunctionCall { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; TransferedObjectMarshaller * returned_type; TransferedObjectMarshaller ** input; int len;/* len for above input */ int maxlen; /* maxlen for above input */ } ; /* TransferedFunctionCall defined */ #ifndef DYNAMITE_DEFINED_TransferedFunctionCall typedef struct Wise2_TransferedFunctionCall Wise2_TransferedFunctionCall; #define TransferedFunctionCall Wise2_TransferedFunctionCall #define DYNAMITE_DEFINED_TransferedFunctionCall #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_TransferedObjectMarshaller(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransferedObjectMarshaller *] * * Return [UNKN ] Undocumented return value [TransferedObjectMarshaller *] * */ TransferedObjectMarshaller * Wise2_hard_link_TransferedObjectMarshaller(TransferedObjectMarshaller * obj); #define hard_link_TransferedObjectMarshaller Wise2_hard_link_TransferedObjectMarshaller /* Function: TransferedObjectMarshaller_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransferedObjectMarshaller *] * */ TransferedObjectMarshaller * Wise2_TransferedObjectMarshaller_alloc(void); #define TransferedObjectMarshaller_alloc Wise2_TransferedObjectMarshaller_alloc /* Function: free_TransferedObjectMarshaller(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransferedObjectMarshaller *] * * Return [UNKN ] Undocumented return value [TransferedObjectMarshaller *] * */ TransferedObjectMarshaller * Wise2_free_TransferedObjectMarshaller(TransferedObjectMarshaller * obj); #define free_TransferedObjectMarshaller Wise2_free_TransferedObjectMarshaller /* Function: add_TransferedFunctionCall(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TransferedFunctionCall *] * Arg: add [OWNER] Object to add to the list [TransferedObjectMarshaller *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_TransferedFunctionCall(TransferedFunctionCall * obj,TransferedObjectMarshaller * add); #define add_TransferedFunctionCall Wise2_add_TransferedFunctionCall /* Function: flush_TransferedFunctionCall(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TransferedFunctionCall *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_TransferedFunctionCall(TransferedFunctionCall * obj); #define flush_TransferedFunctionCall Wise2_flush_TransferedFunctionCall /* Function: TransferedFunctionCall_alloc_std(void) * * Descrip: Equivalent to TransferedFunctionCall_alloc_len(TransferedFunctionCallLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TransferedFunctionCall *] * */ TransferedFunctionCall * Wise2_TransferedFunctionCall_alloc_std(void); #define TransferedFunctionCall_alloc_std Wise2_TransferedFunctionCall_alloc_std /* Function: TransferedFunctionCall_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TransferedFunctionCall *] * */ TransferedFunctionCall * Wise2_TransferedFunctionCall_alloc_len(int len); #define TransferedFunctionCall_alloc_len Wise2_TransferedFunctionCall_alloc_len /* Function: hard_link_TransferedFunctionCall(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TransferedFunctionCall *] * * Return [UNKN ] Undocumented return value [TransferedFunctionCall *] * */ TransferedFunctionCall * Wise2_hard_link_TransferedFunctionCall(TransferedFunctionCall * obj); #define hard_link_TransferedFunctionCall Wise2_hard_link_TransferedFunctionCall /* Function: TransferedFunctionCall_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TransferedFunctionCall *] * */ TransferedFunctionCall * Wise2_TransferedFunctionCall_alloc(void); #define TransferedFunctionCall_alloc Wise2_TransferedFunctionCall_alloc /* Function: free_TransferedFunctionCall(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TransferedFunctionCall *] * * Return [UNKN ] Undocumented return value [TransferedFunctionCall *] * */ TransferedFunctionCall * Wise2_free_TransferedFunctionCall(TransferedFunctionCall * obj); #define free_TransferedFunctionCall Wise2_free_TransferedFunctionCall /* Unplaced functions */ /* There has been no indication of the use of these functions */ TransferedFunctionCall * Wise2_test_stringcat_TransferedFunctionCall(void); #define test_stringcat_TransferedFunctionCall Wise2_test_stringcat_TransferedFunctionCall TransferedObjectMarshaller * Wise2_new_string_Marshaller(void); #define new_string_Marshaller Wise2_new_string_Marshaller void Wise2_object_to_stream_string(void * obj,Wise2WriteStreamInterface* write); #define object_to_stream_string Wise2_object_to_stream_string void * Wise2_stream_to_object_string(Wise2ReadStreamInterface * read); #define stream_to_object_string Wise2_stream_to_object_string /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_TransferedFunctionCall(TransferedObjectMarshaller ** list,int i,int j) ; #define swap_TransferedFunctionCall Wise2_swap_TransferedFunctionCall void Wise2_qsort_TransferedFunctionCall(TransferedObjectMarshaller ** list,int left,int right,int (*comp)(TransferedObjectMarshaller * ,TransferedObjectMarshaller * )); #define qsort_TransferedFunctionCall Wise2_qsort_TransferedFunctionCall void Wise2_sort_TransferedFunctionCall(TransferedFunctionCall * obj,int (*comp)(TransferedObjectMarshaller *, TransferedObjectMarshaller *)); #define sort_TransferedFunctionCall Wise2_sort_TransferedFunctionCall boolean Wise2_expand_TransferedFunctionCall(TransferedFunctionCall * obj,int len); #define expand_TransferedFunctionCall Wise2_expand_TransferedFunctionCall #ifdef _cplusplus } #endif #endif wise-2.4.1/src/socket/makefile0000644000175000001440000000314207734315457015647 0ustar philippusers .SUFFIXES : .dy CC = cc INCFLAGS = -I../base/ CFLAGS = -O2 -g -c -pthread -DUNIX -I../base/ LFLAGS = -g -L../base/ -lm AR_OPTIONS = ru RANLIB_NEEDED = 0 SOCKET_OBJ = functionserver.o \ functionclient.o \ anonobj.o \ transferinterface.o \ directsocketwrite.o libwisesocket.a : $(SOCKET_OBJ) ar $(AR_OPTIONS) libwisesocket.a $? -if test -x /bin/ranlib; then /bin/ranlib libwisesocket.a; else exit 0; fi -if test -x /usr/bin/ranlib; then /usr/bin/ranlib libwisesocket.a; else exit 0; fi test_server : test_cat_server.o simplebufferedserver.o $(CC) -g -o test_server test_cat_server.o simplebufferedserver.o ../base/wisestreaminterface.o ../base/libwisebase.a test_strcat_server : test_strcat_server.o functionserver.o transferinterface.o directsocketwrite.o anonobj.o $(CC) -g -o test_strcat_server test_strcat_server.o functionserver.o transferinterface.o directsocketwrite.o anonobj.o ../base/wisestreaminterface.o ../base/libwisebase.a test_strcat_client : test_strcat_client.o functionclient.o anonobj.o transferinterface.o directsocketwrite.o $(CC) -g -o test_strcat_client test_strcat_client.o anonobj.o functionclient.o transferinterface.o directsocketwrite.o ../base/wisestreaminterface.o ../base/libwisebase.a test_client : test_cat_client.o simplesocketclient.o $(CC) -g -o test_client test_cat_client.o simplesocketclient.o ../base/wisestreaminterface.o ../base/libwisebase.a .c.o : $(CC) $(CFLAGS) $(INCFLAGS) $? init : dyc $(DFLAGS) *.dy DFLAGS = -l -n Wise2_ -a _api.h -b _api.t -latex -perl .dy.c : dyc $(DFLAGS) $< .dy.o : dyc $(DFLAGS) $< $(CC) $(CFLAGS) $*.c wise-2.4.1/src/socket/directsocketwrite.dy0000644000175000001440000000314107734316544020240 0ustar philippusers %{ #include "wisebase.h" %} struct DirectSocketWrite int socket %{ #include "directsocketwrite.h" void write_buffer_direct_socket_server_impl(void * handle,char * string) { DirectSocketWrite * dsw = (DirectSocketWrite*) handle; write_DirectSocketWrite(dsw,string); } void write_bufferf_direct_socket_server_impl(void * handle,char * format,...) { DirectSocketWrite * dsw = (DirectSocketWrite*) handle; char buffer[1024]; va_list ap; va_start(ap,format); vsprintf(buffer,format,ap); write_DirectSocketWrite(dsw,buffer); return; } void close_and_free_direct_socket_server(void * handle) { DirectSocketWrite * dsw = (DirectSocketWrite*) handle; free_DirectSocketWrite(dsw); return; } Wise2WriteStreamInterface * WriteStream_from_socket(int socket) { Wise2WriteStreamInterface * out; DirectSocketWrite * dsw; dsw = DirectSocketWrite_alloc(); dsw->socket = socket; out = malloc(sizeof(Wise2WriteStreamInterface)); out->write_buffer = write_buffer_direct_socket_server_impl; out->write_bufferf = write_bufferf_direct_socket_server_impl; out->close_and_free_handle = close_and_free_direct_socket_server; out->handle = (void *) dsw; return out; } boolean write_DirectSocketWrite(DirectSocketWrite * dsw,char * string) { int curr; int length; int ret; length = strlen(string); curr = 0; while( curr < length ) { ret = write(dsw->socket,string+curr,length-curr); if( ret == -1 ) { /* warn("Error sending with %d\n",errno); */ break; } if( ret+curr >= length ) { break; } curr += ret; } return TRUE; } %} wise-2.4.1/src/socket/functionserver.dy0000644000175000001440000001227010414207325017542 0ustar philippusers %{ #include "wisebase.h" #include "simplebufferedserver.h" #include "transferinterface.h" #include "directsocketwrite.h" #include "anonobj.h" #define FunctionServerLISTLENGTH 16 %} struct FunctionImplementation TransferedFunctionCall * transfer AnonymousObject* (*implementation)(void * h,AnonymousObjectList*) !func void * handle !link struct FunctionServer FunctionImplementation ** fi !list int socket %{ #include "functionserver.h" #include #include #include #include #include #include #include /* errno */ #include /* strerror() */ #include #include /* gettimeofday() */ #include void main_loop_forking_FunctionServer(FunctionServer * fs,int verbose) { int new_socket; char buf[1024]; int i; int j; AnonymousObject * anon; AnonymousObjectList * aol; FILE * ifp; FILE * ofp; Wise2ReadStreamInterface * rs; Wise2WriteStreamInterface * ws; struct sigaction sigchange; ssize_t bytes_in; assert(fs != NULL); /* * ignore child signals */ sigchange.sa_handler = SIG_IGN; sigemptyset(&sigchange.sa_mask); listen(fs->socket,30); if( (sigaction(SIGCHLD,&sigchange,NULL) == -1)) { fatal("Unable to set signal handling behaviour"); } while( 1 ) { if( verbose ) { info("Blocking on accept in main loop"); } new_socket = accept(fs->socket,0,0); if( fork() == 0 ) { int count = 0; /* forked process for client */ struct timeval t0, t1 , t2 , t3; gettimeofday(&t0, NULL); if( verbose ) { info("Accepted connection"); } /* loop around possible multiple functions */ while( 1 ) { ++count; if ((bytes_in = read(new_socket,buf,sizeof(buf))) == -1) { fatal(strerror(errno)); } /* Terminate the recieved string */ buf[bytes_in] = '\0'; if( strncmp(buf,"FINISH",6) == 0) { if( verbose ) { info("Finished connection"); } break; } for (i = 0; i < fs->len; i++) { if (strncmp(buf, fs->fi[i]->transfer->name, strlen(fs->fi[i]->transfer->name)) == 0 ) { break; } } if( i >= fs->len ) { warn("Client asked for %s, unable to respond\n",buf); strcpy(buf,"NOT FOUND"); buf[9] = '\0'; write(new_socket,buf,9); close(new_socket); /* exit out of child process */ exit(0); } if( verbose ) info("Found %s for client, processing",fs->fi[i]->transfer->name); /* read the inputs, ask for data */ strcpy(buf,"SEND\n\0"); write(new_socket,buf,6); /* now inputs */ aol = AnonymousObjectList_alloc_len(fs->fi[i]->transfer->len); ifp = fdopen(new_socket,"r"); rs = ReadStream_from_FILE(ifp); for(j=0;jfi[i]->transfer->len;j++) { anon = AnonymousObject_alloc(); anon->obj = (*fs->fi[i]->transfer->input[j]->stream_to_object)(rs); anon->free_object = fs->fi[i]->transfer->input[j]->untyped_free_object; add_AnonymousObjectList(aol,anon); } /* call function */ gettimeofday(&t1, NULL); anon = (*fs->fi[i]->implementation)(fs->fi[i]->handle,aol); gettimeofday(&t2, NULL); /* send data back */ if( verbose ) { info("implementation successful, preparing to send result"); } ws = WriteStream_from_socket(new_socket); (*fs->fi[i]->transfer->returned_type->object_to_stream)(anon->obj,ws); /* handle server side memory */ free_AnonymousObjectList(aol); free_AnonymousObject(anon); strcpy(buf,"DONE\n"); write(new_socket,buf,5); if( verbose ) { info("sent return object"); } gettimeofday(&t3, NULL); } close(new_socket); info("Exiting child having closed socket"); /* client exits */ exit(0); } else { /* fork != 0 */ /* parent needs to close socket as well */ close(new_socket); /* main server, back to accept */ } } /* main loop */ close(fs->socket); } FunctionServer * new_FunctionServer(int port) { struct sockaddr_in server; struct sockaddr * name; FunctionServer * out; int yes = 1; out = FunctionServer_alloc_std(); out->socket = socket(AF_INET, SOCK_STREAM, 0); server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(port); setsockopt(out->socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes); /* If setsockopt() fails, we're not too unhappy, so no check */ if (bind(out->socket, (struct sockaddr *)&server, sizeof(server))) { /* Probably tried to bind to a port that was already in use... */ fatal(strerror(errno)); } return out; } FunctionImplementation * test_strcat_FunctionImplementation(void) { FunctionImplementation * out; out = FunctionImplementation_alloc(); out->transfer = test_stringcat_TransferedFunctionCall(); out->implementation = test_strcat_implementation; return out; } AnonymousObject * test_strcat_implementation(void * h,AnonymousObjectList * aol) { char buffer[1024]; char * one; char * two; AnonymousObject * ret; assert(aol != NULL); assert(aol->len == 2); one = (char*)aol->anon[0]->obj; two = (char*)aol->anon[1]->obj; ret = AnonymousObject_alloc(); strcpy(buffer,one); strcat(buffer,two); ret->obj = stringalloc(buffer); return ret; } %} wise-2.4.1/src/socket/functionserver.c0000644000175000001440000003713110670453715017365 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "functionserver.h" #include #include #include #include #include #include #include /* errno */ #include /* strerror() */ #include #include /* gettimeofday() */ #include # line 45 "functionserver.dy" void main_loop_forking_FunctionServer(FunctionServer * fs,int verbose) { int new_socket; char buf[1024]; int i; int j; AnonymousObject * anon; AnonymousObjectList * aol; FILE * ifp; FILE * ofp; Wise2ReadStreamInterface * rs; Wise2WriteStreamInterface * ws; struct sigaction sigchange; ssize_t bytes_in; assert(fs != NULL); /* * ignore child signals */ sigchange.sa_handler = SIG_IGN; sigemptyset(&sigchange.sa_mask); listen(fs->socket,30); if( (sigaction(SIGCHLD,&sigchange,NULL) == -1)) { fatal("Unable to set signal handling behaviour"); } while( 1 ) { if( verbose ) { info("Blocking on accept in main loop"); } new_socket = accept(fs->socket,0,0); if( fork() == 0 ) { int count = 0; /* forked process for client */ struct timeval t0, t1 , t2 , t3; gettimeofday(&t0, NULL); if( verbose ) { info("Accepted connection"); } /* loop around possible multiple functions */ while( 1 ) { ++count; if ((bytes_in = read(new_socket,buf,sizeof(buf))) == -1) { fatal(strerror(errno)); } /* Terminate the recieved string */ buf[bytes_in] = '\0'; if( strncmp(buf,"FINISH",6) == 0) { if( verbose ) { info("Finished connection"); } break; } for (i = 0; i < fs->len; i++) { if (strncmp(buf, fs->fi[i]->transfer->name, strlen(fs->fi[i]->transfer->name)) == 0 ) { break; } } if( i >= fs->len ) { warn("Client asked for %s, unable to respond\n",buf); strcpy(buf,"NOT FOUND"); buf[9] = '\0'; write(new_socket,buf,9); close(new_socket); /* exit out of child process */ exit(0); } if( verbose ) info("Found %s for client, processing",fs->fi[i]->transfer->name); /* read the inputs, ask for data */ strcpy(buf,"SEND\n\0"); write(new_socket,buf,6); /* now inputs */ aol = AnonymousObjectList_alloc_len(fs->fi[i]->transfer->len); ifp = fdopen(new_socket,"r"); rs = ReadStream_from_FILE(ifp); for(j=0;jfi[i]->transfer->len;j++) { anon = AnonymousObject_alloc(); anon->obj = (*fs->fi[i]->transfer->input[j]->stream_to_object)(rs); anon->free_object = fs->fi[i]->transfer->input[j]->untyped_free_object; add_AnonymousObjectList(aol,anon); } /* call function */ gettimeofday(&t1, NULL); anon = (*fs->fi[i]->implementation)(fs->fi[i]->handle,aol); gettimeofday(&t2, NULL); /* send data back */ if( verbose ) { info("implementation successful, preparing to send result"); } ws = WriteStream_from_socket(new_socket); (*fs->fi[i]->transfer->returned_type->object_to_stream)(anon->obj,ws); /* handle server side memory */ free_AnonymousObjectList(aol); free_AnonymousObject(anon); strcpy(buf,"DONE\n"); write(new_socket,buf,5); if( verbose ) { info("sent return object"); } gettimeofday(&t3, NULL); } close(new_socket); info("Exiting child having closed socket"); /* client exits */ exit(0); } else { /* fork != 0 */ /* parent needs to close socket as well */ close(new_socket); /* main server, back to accept */ } } /* main loop */ close(fs->socket); } # line 213 "functionserver.dy" FunctionServer * new_FunctionServer(int port) { struct sockaddr_in server; struct sockaddr * name; FunctionServer * out; int yes = 1; out = FunctionServer_alloc_std(); out->socket = socket(AF_INET, SOCK_STREAM, 0); server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(port); setsockopt(out->socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes); /* If setsockopt() fails, we're not too unhappy, so no check */ if (bind(out->socket, (struct sockaddr *)&server, sizeof(server))) { /* Probably tried to bind to a port that was already in use... */ fatal(strerror(errno)); } return out; } # line 239 "functionserver.dy" FunctionImplementation * test_strcat_FunctionImplementation(void) { FunctionImplementation * out; out = FunctionImplementation_alloc(); out->transfer = test_stringcat_TransferedFunctionCall(); out->implementation = test_strcat_implementation; return out; } # line 250 "functionserver.dy" AnonymousObject * test_strcat_implementation(void * h,AnonymousObjectList * aol) { char buffer[1024]; char * one; char * two; AnonymousObject * ret; assert(aol != NULL); assert(aol->len == 2); one = (char*)aol->anon[0]->obj; two = (char*)aol->anon[1]->obj; ret = AnonymousObject_alloc(); strcpy(buffer,one); strcat(buffer,two); ret->obj = stringalloc(buffer); return ret; } # line 253 "functionserver.c" /* Function: hard_link_FunctionImplementation(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FunctionImplementation *] * * Return [UNKN ] Undocumented return value [FunctionImplementation *] * */ FunctionImplementation * hard_link_FunctionImplementation(FunctionImplementation * obj) { if( obj == NULL ) { warn("Trying to hard link to a FunctionImplementation object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: FunctionImplementation_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FunctionImplementation *] * */ FunctionImplementation * FunctionImplementation_alloc(void) { FunctionImplementation * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FunctionImplementation *) ckalloc (sizeof(FunctionImplementation))) == NULL) { warn("FunctionImplementation_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->transfer = NULL; out->implementation = NULL; return out; } /* Function: free_FunctionImplementation(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FunctionImplementation *] * * Return [UNKN ] Undocumented return value [FunctionImplementation *] * */ FunctionImplementation * free_FunctionImplementation(FunctionImplementation * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FunctionImplementation obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->transfer != NULL) free_TransferedFunctionCall(obj->transfer); /* obj->implementation is a function pointer */ /* obj->handle is linked in */ ckfree(obj); return NULL; } /* Function: swap_FunctionServer(list,i,j) * * Descrip: swap function: an internal for qsort_FunctionServer * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [FunctionImplementation **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_FunctionServer(FunctionImplementation ** list,int i,int j) { FunctionImplementation * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_FunctionServer(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_FunctionServer which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [FunctionImplementation **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_FunctionServer(FunctionImplementation ** list,int left,int right,int (*comp)(FunctionImplementation * ,FunctionImplementation * )) { int i,last; if( left >= right ) return; swap_FunctionServer(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_FunctionServer (list,++last,i); } swap_FunctionServer (list,left,last); qsort_FunctionServer(list,left,last-1,comp); qsort_FunctionServer(list,last+1,right,comp); } /* Function: sort_FunctionServer(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_FunctionServer * * * Arg: obj [UNKN ] Object containing list [FunctionServer *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_FunctionServer(FunctionServer * obj,int (*comp)(FunctionImplementation *, FunctionImplementation *)) { qsort_FunctionServer(obj->fi,0,obj->len-1,comp); return; } /* Function: expand_FunctionServer(obj,len) * * Descrip: Really an internal function for add_FunctionServer * * * Arg: obj [UNKN ] Object which contains the list [FunctionServer *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_FunctionServer(FunctionServer * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_FunctionServer called with no need"); return TRUE; } if( (obj->fi = (FunctionImplementation ** ) ckrealloc (obj->fi,sizeof(FunctionImplementation *)*len)) == NULL) { warn("ckrealloc failed for expand_FunctionServer, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_FunctionServer(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FunctionServer *] * Arg: add [OWNER] Object to add to the list [FunctionImplementation *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_FunctionServer(FunctionServer * obj,FunctionImplementation * add) { if( obj->len >= obj->maxlen) { if( expand_FunctionServer(obj,obj->len + FunctionServerLISTLENGTH) == FALSE) return FALSE; } obj->fi[obj->len++]=add; return TRUE; } /* Function: flush_FunctionServer(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FunctionServer *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_FunctionServer(FunctionServer * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->fi[i] != NULL) { free_FunctionImplementation(obj->fi[i]); obj->fi[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: FunctionServer_alloc_std(void) * * Descrip: Equivalent to FunctionServer_alloc_len(FunctionServerLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FunctionServer *] * */ FunctionServer * FunctionServer_alloc_std(void) { return FunctionServer_alloc_len(FunctionServerLISTLENGTH); } /* Function: FunctionServer_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FunctionServer *] * */ FunctionServer * FunctionServer_alloc_len(int len) { FunctionServer * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = FunctionServer_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->fi = (FunctionImplementation ** ) ckcalloc (len,sizeof(FunctionImplementation *))) == NULL) { warn("Warning, ckcalloc failed in FunctionServer_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_FunctionServer(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FunctionServer *] * * Return [UNKN ] Undocumented return value [FunctionServer *] * */ FunctionServer * hard_link_FunctionServer(FunctionServer * obj) { if( obj == NULL ) { warn("Trying to hard link to a FunctionServer object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: FunctionServer_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FunctionServer *] * */ FunctionServer * FunctionServer_alloc(void) { FunctionServer * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FunctionServer *) ckalloc (sizeof(FunctionServer))) == NULL) { warn("FunctionServer_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->fi = NULL; out->len = out->maxlen = 0; out->socket = 0; return out; } /* Function: free_FunctionServer(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FunctionServer *] * * Return [UNKN ] Undocumented return value [FunctionServer *] * */ FunctionServer * free_FunctionServer(FunctionServer * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FunctionServer obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->fi != NULL) { for(i=0;ilen;i++) { if( obj->fi[i] != NULL) free_FunctionImplementation(obj->fi[i]); } ckfree(obj->fi); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/socket/functionserver.h0000644000175000001440000001635010670453715017372 0ustar philippusers#ifndef DYNAMITEfunctionserverHEADERFILE #define DYNAMITEfunctionserverHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "simplebufferedserver.h" #include "transferinterface.h" #include "directsocketwrite.h" #include "anonobj.h" #define FunctionServerLISTLENGTH 16 struct Wise2_FunctionImplementation { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif TransferedFunctionCall * transfer; AnonymousObject* (*implementation)(void * h,AnonymousObjectList*); void * handle; } ; /* FunctionImplementation defined */ #ifndef DYNAMITE_DEFINED_FunctionImplementation typedef struct Wise2_FunctionImplementation Wise2_FunctionImplementation; #define FunctionImplementation Wise2_FunctionImplementation #define DYNAMITE_DEFINED_FunctionImplementation #endif struct Wise2_FunctionServer { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif FunctionImplementation ** fi; int len;/* len for above fi */ int maxlen; /* maxlen for above fi */ int socket; } ; /* FunctionServer defined */ #ifndef DYNAMITE_DEFINED_FunctionServer typedef struct Wise2_FunctionServer Wise2_FunctionServer; #define FunctionServer Wise2_FunctionServer #define DYNAMITE_DEFINED_FunctionServer #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_FunctionImplementation(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FunctionImplementation *] * * Return [UNKN ] Undocumented return value [FunctionImplementation *] * */ FunctionImplementation * Wise2_hard_link_FunctionImplementation(FunctionImplementation * obj); #define hard_link_FunctionImplementation Wise2_hard_link_FunctionImplementation /* Function: FunctionImplementation_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FunctionImplementation *] * */ FunctionImplementation * Wise2_FunctionImplementation_alloc(void); #define FunctionImplementation_alloc Wise2_FunctionImplementation_alloc /* Function: free_FunctionImplementation(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FunctionImplementation *] * * Return [UNKN ] Undocumented return value [FunctionImplementation *] * */ FunctionImplementation * Wise2_free_FunctionImplementation(FunctionImplementation * obj); #define free_FunctionImplementation Wise2_free_FunctionImplementation /* Function: add_FunctionServer(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FunctionServer *] * Arg: add [OWNER] Object to add to the list [FunctionImplementation *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_FunctionServer(FunctionServer * obj,FunctionImplementation * add); #define add_FunctionServer Wise2_add_FunctionServer /* Function: flush_FunctionServer(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FunctionServer *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_FunctionServer(FunctionServer * obj); #define flush_FunctionServer Wise2_flush_FunctionServer /* Function: FunctionServer_alloc_std(void) * * Descrip: Equivalent to FunctionServer_alloc_len(FunctionServerLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FunctionServer *] * */ FunctionServer * Wise2_FunctionServer_alloc_std(void); #define FunctionServer_alloc_std Wise2_FunctionServer_alloc_std /* Function: FunctionServer_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FunctionServer *] * */ FunctionServer * Wise2_FunctionServer_alloc_len(int len); #define FunctionServer_alloc_len Wise2_FunctionServer_alloc_len /* Function: hard_link_FunctionServer(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FunctionServer *] * * Return [UNKN ] Undocumented return value [FunctionServer *] * */ FunctionServer * Wise2_hard_link_FunctionServer(FunctionServer * obj); #define hard_link_FunctionServer Wise2_hard_link_FunctionServer /* Function: FunctionServer_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FunctionServer *] * */ FunctionServer * Wise2_FunctionServer_alloc(void); #define FunctionServer_alloc Wise2_FunctionServer_alloc /* Function: free_FunctionServer(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FunctionServer *] * * Return [UNKN ] Undocumented return value [FunctionServer *] * */ FunctionServer * Wise2_free_FunctionServer(FunctionServer * obj); #define free_FunctionServer Wise2_free_FunctionServer /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_main_loop_forking_FunctionServer(FunctionServer * fs,int verbose); #define main_loop_forking_FunctionServer Wise2_main_loop_forking_FunctionServer FunctionServer * Wise2_new_FunctionServer(int port); #define new_FunctionServer Wise2_new_FunctionServer FunctionImplementation * Wise2_test_strcat_FunctionImplementation(void); #define test_strcat_FunctionImplementation Wise2_test_strcat_FunctionImplementation AnonymousObject * Wise2_test_strcat_implementation(void * h,AnonymousObjectList * aol); #define test_strcat_implementation Wise2_test_strcat_implementation /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_FunctionServer(FunctionImplementation ** list,int i,int j) ; #define swap_FunctionServer Wise2_swap_FunctionServer void Wise2_qsort_FunctionServer(FunctionImplementation ** list,int left,int right,int (*comp)(FunctionImplementation * ,FunctionImplementation * )); #define qsort_FunctionServer Wise2_qsort_FunctionServer void Wise2_sort_FunctionServer(FunctionServer * obj,int (*comp)(FunctionImplementation *, FunctionImplementation *)); #define sort_FunctionServer Wise2_sort_FunctionServer boolean Wise2_expand_FunctionServer(FunctionServer * obj,int len); #define expand_FunctionServer Wise2_expand_FunctionServer #ifdef _cplusplus } #endif #endif wise-2.4.1/src/socket/simplesocketclient.dy0000644000175000001440000000407507723613123020401 0ustar philippusers %{ #include "wisebase.h" #include #include #include #include #include #include #include typedef struct Wise2_SimpleRead_Socket { int socket; FILE * socket_ifp; boolean has_ended; char buffer[1024]; char * curr_read; int curr_len; } Wise2_SimpleRead_Socket; %} %{ #include "simplesocketclient.h" char * read_buffer_simple_socket_impl(void * handle,char * buffer,int maxsize) { int ret; Wise2_SimpleRead_Socket * s = (Wise2_SimpleRead_Socket *) handle; char * r; if( s->has_ended == TRUE ) { return NULL; } return fgets(buffer,maxsize,s->socket_ifp); } boolean is_end_simple_socket_impl(void * handle) { Wise2_SimpleRead_Socket * s = (Wise2_SimpleRead_Socket *) handle; if( s->has_ended == TRUE ) { return TRUE; } else { return FALSE; } } void close_and_free_simple_socket_impl(void * handle) { Wise2_SimpleRead_Socket * s = (Wise2_SimpleRead_Socket *) handle; close( s->socket ); free(s); } Wise2ReadStreamInterface * open_simple_socket_for_reading(char * hostname,int port_number) { Wise2ReadStreamInterface * out; Wise2_SimpleRead_Socket * handle; struct sockaddr_in server; struct hostent * hp; out = malloc(sizeof(Wise2ReadStreamInterface)); out->read_buffer = read_buffer_simple_socket_impl; out->is_end = is_end_simple_socket_impl; out->close_and_free_handle = close_and_free_simple_socket_impl; handle = malloc(sizeof(Wise2_SimpleRead_Socket)); handle->has_ended = 0; handle->socket = socket(AF_INET, SOCK_STREAM, 0); server.sin_family = AF_INET; hp = gethostbyname(hostname); bcopy( hp->h_addr, &server.sin_addr, hp->h_length); server.sin_port = htons(port_number); connect(handle->socket, &server, sizeof(server)); /* fcntl(handle->socket,F_SETFL,*/ write(handle->socket,"\n",strlen("\n")); fprintf(stderr,"written start...\n"); handle->socket_ifp = fdopen(handle->socket,"r"); out->handle = (void *) handle; return out; } %} wise-2.4.1/src/socket/simplesocketclient.c0000644000175000001440000000366310670453715020215 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "simplesocketclient.h" # line 31 "simplesocketclient.dy" char * read_buffer_simple_socket_impl(void * handle,char * buffer,int maxsize) { int ret; Wise2_SimpleRead_Socket * s = (Wise2_SimpleRead_Socket *) handle; char * r; if( s->has_ended == TRUE ) { return NULL; } return fgets(buffer,maxsize,s->socket_ifp); } # line 44 "simplesocketclient.dy" boolean is_end_simple_socket_impl(void * handle) { Wise2_SimpleRead_Socket * s = (Wise2_SimpleRead_Socket *) handle; if( s->has_ended == TRUE ) { return TRUE; } else { return FALSE; } } # line 57 "simplesocketclient.dy" void close_and_free_simple_socket_impl(void * handle) { Wise2_SimpleRead_Socket * s = (Wise2_SimpleRead_Socket *) handle; close( s->socket ); free(s); } # line 65 "simplesocketclient.dy" Wise2ReadStreamInterface * open_simple_socket_for_reading(char * hostname,int port_number) { Wise2ReadStreamInterface * out; Wise2_SimpleRead_Socket * handle; struct sockaddr_in server; struct hostent * hp; out = malloc(sizeof(Wise2ReadStreamInterface)); out->read_buffer = read_buffer_simple_socket_impl; out->is_end = is_end_simple_socket_impl; out->close_and_free_handle = close_and_free_simple_socket_impl; handle = malloc(sizeof(Wise2_SimpleRead_Socket)); handle->has_ended = 0; handle->socket = socket(AF_INET, SOCK_STREAM, 0); server.sin_family = AF_INET; hp = gethostbyname(hostname); bcopy( hp->h_addr, &server.sin_addr, hp->h_length); server.sin_port = htons(port_number); connect(handle->socket, &server, sizeof(server)); /* fcntl(handle->socket,F_SETFL,*/ write(handle->socket,"\n",strlen("\n")); fprintf(stderr,"written start...\n"); handle->socket_ifp = fdopen(handle->socket,"r"); out->handle = (void *) handle; return out; } # line 82 "simplesocketclient.c" #ifdef _cplusplus } #endif wise-2.4.1/src/socket/simplesocketclient.h0000644000175000001440000000322710670453715020216 0ustar philippusers#ifndef DYNAMITEsimplesocketclientHEADERFILE #define DYNAMITEsimplesocketclientHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include #include #include #include #include #include #include typedef struct Wise2_SimpleRead_Socket { int socket; FILE * socket_ifp; boolean has_ended; char buffer[1024]; char * curr_read; int curr_len; } Wise2_SimpleRead_Socket; /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Unplaced functions */ /* There has been no indication of the use of these functions */ char * Wise2_read_buffer_simple_socket_impl(void * handle,char * buffer,int maxsize); #define read_buffer_simple_socket_impl Wise2_read_buffer_simple_socket_impl boolean Wise2_is_end_simple_socket_impl(void * handle); #define is_end_simple_socket_impl Wise2_is_end_simple_socket_impl void Wise2_close_and_free_simple_socket_impl(void * handle); #define close_and_free_simple_socket_impl Wise2_close_and_free_simple_socket_impl Wise2ReadStreamInterface * Wise2_open_simple_socket_for_reading(char * hostname,int port_number); #define open_simple_socket_for_reading Wise2_open_simple_socket_for_reading /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/socket/simplebufferedserver.c0000644000175000001440000002764510670453715020545 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "simplebufferedserver.h" #include #include #include #include #include #include # line 33 "simplebufferedserver.dy" void write_buffer_simple_buffered_server_impl(void * handle,char * string) { SimpleBufferedServer * sbs = (SimpleBufferedServer*) handle; add_string_SimpleBufferedServer(sbs,string); } # line 40 "simplebufferedserver.dy" void write_bufferf_simple_buffered_server_impl(void * handle,char * format,...) { SimpleBufferedServer * sbs = (SimpleBufferedServer*) handle; char buffer[1024]; va_list ap; va_start(ap,format); vsprintf(buffer,format,ap); add_string_SimpleBufferedServer(sbs,buffer); return; } # line 55 "simplebufferedserver.dy" void close_and_free_simple_buffered_server(void * handle) { /* no-op, as this is not the owner */ return; } # line 61 "simplebufferedserver.dy" void add_string_SimpleBufferedServer(SimpleBufferedServer * sbs,char * unallocated_string) { add_SimpleBufferedServer(sbs,stringalloc(unallocated_string)); } # line 67 "simplebufferedserver.dy" Wise2WriteStreamInterface * WriteStream_from_SimpleBufferedServer(SimpleBufferedServer * sbs) { Wise2WriteStreamInterface * out; out = malloc(sizeof(Wise2WriteStreamInterface)); out->write_buffer = write_buffer_simple_buffered_server_impl; out->write_bufferf = write_bufferf_simple_buffered_server_impl; out->close_and_free_handle = close_and_free_simple_buffered_server; out->handle = (void *) sbs; return out; } # line 82 "simplebufferedserver.dy" SimpleBufferedServer * new_SimpleBufferedServer(int port) { struct sockaddr_in server; struct sockaddr * name; SimpleBufferedServer * out; int yes = 1; out = SimpleBufferedServer_alloc_std(); out->socket = socket(AF_INET, SOCK_STREAM, 0); server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(port); setsockopt(out->socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes); /* If setsockopt() fails, we're not too unhappy, so no check */ if (bind(out->socket, (struct sockaddr *)&server, sizeof(server))) { /* Probably tried to bind to a port that was already in use... */ fatal(strerror(errno)); } return out; } # line 108 "simplebufferedserver.dy" char * free_BufferedString(char * str) { free(str); } # line 113 "simplebufferedserver.dy" void listen_and_respond_SimpleBufferedServer(SimpleBufferedServer * sbs) { int i; char buf[1024]; int ret; int len; int curr; int ms; int new_socket; listen(sbs->socket, 5); while( 1 ) { fprintf(stderr,"blocking at accept...\n"); ms = accept(sbs->socket, 0, 0); fprintf(stderr,"Accepted socket...\n"); read(ms,buf,sizeof(buf)); fprintf(stderr,"Read buffer...\n"); if( strstartcmp(buf,"") == 0 ) { for(i=0;ilen;i++) { fprintf(stderr,"Going to send position %d\n",i); len = strlen(sbs->buffer[i]); curr = 0; while( curr < len ) { fprintf(stderr,"Going to send at position %d\n",curr); ret = write(ms,sbs->buffer[i]+curr,len-curr); if( ret == -1 ) { warn("error sending with %d\n",errno); } fprintf(stderr,"...sent at position %d, sent %d bytes [%.6s]\n",curr,ret,sbs->buffer[i]); if( ret+curr >= len ) { break; } curr += ret; sleep(2); } } buf[0] = '\0'; write(ms,buf,1); close(ms); } else { fatal("Bad client initialisation string...%s\n",buf); } } } # line 150 "simplebufferedserver.c" /* Function: swap_SimpleBufferedServer(list,i,j) * * Descrip: swap function: an internal for qsort_SimpleBufferedServer * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [BufferedString **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SimpleBufferedServer(BufferedString ** list,int i,int j) { BufferedString * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SimpleBufferedServer(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SimpleBufferedServer which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [BufferedString **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SimpleBufferedServer(BufferedString ** list,int left,int right,int (*comp)(BufferedString * ,BufferedString * )) { int i,last; if( left >= right ) return; swap_SimpleBufferedServer(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SimpleBufferedServer (list,++last,i); } swap_SimpleBufferedServer (list,left,last); qsort_SimpleBufferedServer(list,left,last-1,comp); qsort_SimpleBufferedServer(list,last+1,right,comp); } /* Function: sort_SimpleBufferedServer(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SimpleBufferedServer * * * Arg: obj [UNKN ] Object containing list [SimpleBufferedServer *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SimpleBufferedServer(SimpleBufferedServer * obj,int (*comp)(BufferedString *, BufferedString *)) { qsort_SimpleBufferedServer(obj->buffer,0,obj->len-1,comp); return; } /* Function: expand_SimpleBufferedServer(obj,len) * * Descrip: Really an internal function for add_SimpleBufferedServer * * * Arg: obj [UNKN ] Object which contains the list [SimpleBufferedServer *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SimpleBufferedServer(SimpleBufferedServer * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SimpleBufferedServer called with no need"); return TRUE; } if( (obj->buffer = (BufferedString ** ) ckrealloc (obj->buffer,sizeof(BufferedString *)*len)) == NULL) { warn("ckrealloc failed for expand_SimpleBufferedServer, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SimpleBufferedServer(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SimpleBufferedServer *] * Arg: add [OWNER] Object to add to the list [BufferedString *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SimpleBufferedServer(SimpleBufferedServer * obj,BufferedString * add) { if( obj->len >= obj->maxlen) { if( expand_SimpleBufferedServer(obj,obj->len + SimpleBufferedServerLISTLENGTH) == FALSE) return FALSE; } obj->buffer[obj->len++]=add; return TRUE; } /* Function: flush_SimpleBufferedServer(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SimpleBufferedServer *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SimpleBufferedServer(SimpleBufferedServer * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->buffer[i] != NULL) { free_BufferedString(obj->buffer[i]); obj->buffer[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SimpleBufferedServer_alloc_std(void) * * Descrip: Equivalent to SimpleBufferedServer_alloc_len(SimpleBufferedServerLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SimpleBufferedServer *] * */ SimpleBufferedServer * SimpleBufferedServer_alloc_std(void) { return SimpleBufferedServer_alloc_len(SimpleBufferedServerLISTLENGTH); } /* Function: SimpleBufferedServer_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SimpleBufferedServer *] * */ SimpleBufferedServer * SimpleBufferedServer_alloc_len(int len) { SimpleBufferedServer * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SimpleBufferedServer_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->buffer = (BufferedString ** ) ckcalloc (len,sizeof(BufferedString *))) == NULL) { warn("Warning, ckcalloc failed in SimpleBufferedServer_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SimpleBufferedServer(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SimpleBufferedServer *] * * Return [UNKN ] Undocumented return value [SimpleBufferedServer *] * */ SimpleBufferedServer * hard_link_SimpleBufferedServer(SimpleBufferedServer * obj) { if( obj == NULL ) { warn("Trying to hard link to a SimpleBufferedServer object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SimpleBufferedServer_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SimpleBufferedServer *] * */ SimpleBufferedServer * SimpleBufferedServer_alloc(void) { SimpleBufferedServer * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SimpleBufferedServer *) ckalloc (sizeof(SimpleBufferedServer))) == NULL) { warn("SimpleBufferedServer_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->socket = 0; out->buffer = NULL; out->len = out->maxlen = 0; out->current_read = 0; return out; } /* Function: free_SimpleBufferedServer(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SimpleBufferedServer *] * * Return [UNKN ] Undocumented return value [SimpleBufferedServer *] * */ SimpleBufferedServer * free_SimpleBufferedServer(SimpleBufferedServer * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SimpleBufferedServer obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->buffer != NULL) { for(i=0;ilen;i++) { if( obj->buffer[i] != NULL) free_BufferedString(obj->buffer[i]); } ckfree(obj->buffer); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/socket/simplebufferedserver.h0000644000175000001440000001457510670453715020550 0ustar philippusers#ifndef DYNAMITEsimplebufferedserverHEADERFILE #define DYNAMITEsimplebufferedserverHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include typedef char BufferedString; #define SimpleBufferedServerLISTLENGTH 1024 struct Wise2_SimpleBufferedServer { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int socket; BufferedString ** buffer; int len;/* len for above buffer */ int maxlen; /* maxlen for above buffer */ int current_read; } ; /* SimpleBufferedServer defined */ #ifndef DYNAMITE_DEFINED_SimpleBufferedServer typedef struct Wise2_SimpleBufferedServer Wise2_SimpleBufferedServer; #define SimpleBufferedServer Wise2_SimpleBufferedServer #define DYNAMITE_DEFINED_SimpleBufferedServer #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: add_SimpleBufferedServer(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SimpleBufferedServer *] * Arg: add [OWNER] Object to add to the list [BufferedString *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SimpleBufferedServer(SimpleBufferedServer * obj,BufferedString * add); #define add_SimpleBufferedServer Wise2_add_SimpleBufferedServer /* Function: flush_SimpleBufferedServer(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SimpleBufferedServer *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SimpleBufferedServer(SimpleBufferedServer * obj); #define flush_SimpleBufferedServer Wise2_flush_SimpleBufferedServer /* Function: SimpleBufferedServer_alloc_std(void) * * Descrip: Equivalent to SimpleBufferedServer_alloc_len(SimpleBufferedServerLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SimpleBufferedServer *] * */ SimpleBufferedServer * Wise2_SimpleBufferedServer_alloc_std(void); #define SimpleBufferedServer_alloc_std Wise2_SimpleBufferedServer_alloc_std /* Function: SimpleBufferedServer_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SimpleBufferedServer *] * */ SimpleBufferedServer * Wise2_SimpleBufferedServer_alloc_len(int len); #define SimpleBufferedServer_alloc_len Wise2_SimpleBufferedServer_alloc_len /* Function: hard_link_SimpleBufferedServer(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SimpleBufferedServer *] * * Return [UNKN ] Undocumented return value [SimpleBufferedServer *] * */ SimpleBufferedServer * Wise2_hard_link_SimpleBufferedServer(SimpleBufferedServer * obj); #define hard_link_SimpleBufferedServer Wise2_hard_link_SimpleBufferedServer /* Function: SimpleBufferedServer_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SimpleBufferedServer *] * */ SimpleBufferedServer * Wise2_SimpleBufferedServer_alloc(void); #define SimpleBufferedServer_alloc Wise2_SimpleBufferedServer_alloc /* Function: free_SimpleBufferedServer(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SimpleBufferedServer *] * * Return [UNKN ] Undocumented return value [SimpleBufferedServer *] * */ SimpleBufferedServer * Wise2_free_SimpleBufferedServer(SimpleBufferedServer * obj); #define free_SimpleBufferedServer Wise2_free_SimpleBufferedServer /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_write_buffer_simple_buffered_server_impl(void * handle,char * string); #define write_buffer_simple_buffered_server_impl Wise2_write_buffer_simple_buffered_server_impl void Wise2_write_bufferf_simple_buffered_server_impl(void * handle,char * format,...); #define write_bufferf_simple_buffered_server_impl Wise2_write_bufferf_simple_buffered_server_impl void Wise2_close_and_free_simple_buffered_server(void * handle); #define close_and_free_simple_buffered_server Wise2_close_and_free_simple_buffered_server void Wise2_add_string_SimpleBufferedServer(SimpleBufferedServer * sbs,char * unallocated_string); #define add_string_SimpleBufferedServer Wise2_add_string_SimpleBufferedServer Wise2WriteStreamInterface * Wise2_WriteStream_from_SimpleBufferedServer(SimpleBufferedServer * sbs); #define WriteStream_from_SimpleBufferedServer Wise2_WriteStream_from_SimpleBufferedServer SimpleBufferedServer * Wise2_new_SimpleBufferedServer(int port); #define new_SimpleBufferedServer Wise2_new_SimpleBufferedServer char * Wise2_free_BufferedString(char * str); #define free_BufferedString Wise2_free_BufferedString void Wise2_listen_and_respond_SimpleBufferedServer(SimpleBufferedServer * sbs); #define listen_and_respond_SimpleBufferedServer Wise2_listen_and_respond_SimpleBufferedServer /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_SimpleBufferedServer(BufferedString ** list,int i,int j) ; #define swap_SimpleBufferedServer Wise2_swap_SimpleBufferedServer void Wise2_qsort_SimpleBufferedServer(BufferedString ** list,int left,int right,int (*comp)(BufferedString * ,BufferedString * )); #define qsort_SimpleBufferedServer Wise2_qsort_SimpleBufferedServer void Wise2_sort_SimpleBufferedServer(SimpleBufferedServer * obj,int (*comp)(BufferedString *, BufferedString *)); #define sort_SimpleBufferedServer Wise2_sort_SimpleBufferedServer boolean Wise2_expand_SimpleBufferedServer(SimpleBufferedServer * obj,int len); #define expand_SimpleBufferedServer Wise2_expand_SimpleBufferedServer #ifdef _cplusplus } #endif #endif wise-2.4.1/src/socket/transferinterface.dy0000644000175000001440000000361307732124027020202 0ustar philippusers %{ #include "wisebase.h" #define TransferedFunctionCallLISTLENGTH 16 %} struct TransferedObjectMarshaller void (*object_to_stream)(void *,Wise2WriteStreamInterface*) !func void * (*stream_to_object)(Wise2ReadStreamInterface*) !func char * object_type !link void (*untyped_free_object)(void *) !func struct TransferedFunctionCall char * name TransferedObjectMarshaller * returned_type TransferedObjectMarshaller ** input !list %{ #include "transferinterface.h" TransferedFunctionCall * test_stringcat_TransferedFunctionCall(void) { TransferedFunctionCall * out; out = TransferedFunctionCall_alloc_std(); out->name = stringalloc("stringcat"); out->returned_type = new_string_Marshaller(); add_TransferedFunctionCall(out,new_string_Marshaller()); add_TransferedFunctionCall(out,new_string_Marshaller()); return out; } TransferedObjectMarshaller * new_string_Marshaller(void) { TransferedObjectMarshaller * out; out = TransferedObjectMarshaller_alloc(); out->object_to_stream = object_to_stream_string; out->stream_to_object = stream_to_object_string; return out; } void object_to_stream_string(void * obj,Wise2WriteStreamInterface* write) { char * string = (char *) obj; fprintf(stderr,"Writing to buffer with string [%s]\n",string); (*write->write_buffer)(write->handle,string); (*write->write_buffer)(write->handle,"\n//\n"); } void * stream_to_object_string(Wise2ReadStreamInterface * read) { char buffer[1024]; char * out; int i; fprintf(stderr,"reading string...\n"); WISE2_READ_BUFFER(buffer,1024,read); fprintf(stderr,"read buffer %s...\n",buffer); for(i=0;i<1024;i++) { if( buffer[i] == '\n' || buffer[i] == '\r' || buffer[i] == '\0' ) { break; } } buffer[i] = '\0'; out = stringalloc(buffer); WISE2_READ_BUFFER(buffer,1024,read); fprintf(stderr,"discarding buffer... %s, have string %s\n",buffer,out); return out; } %} wise-2.4.1/src/socket/functionclient.c0000644000175000001440000003425210670453715017336 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "functionclient.h" #include #include #include #include #include #include #include #include /* errno */ /* Function: free_FunctionProxyCoordinator(obj) * * Descrip: provides specific destructor for FunctionProxyCoordinators * * * Arg: obj [UNKN ] Undocumented argument [FunctionProxyCoordinator *] * * Return [UNKN ] Undocumented return value [FunctionProxyCoordinator *] * */ # line 41 "functionclient.dy" FunctionProxyCoordinator * free_FunctionProxyCoordinator(FunctionProxyCoordinator * obj) { int i; int return_early = 0; char buffer[1024]; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FunctionProxy obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* send FINISH to server */ strcpy(buffer,"FINISH"); if (write(obj->socket, buffer, 6) == -1) { fprintf(stderr, "write() failed\n"); fatal(strerror(errno)); } close(obj->socket); for(i=0;ilen;i++) { if( obj->proxy[i] != NULL ) { free_FunctionProxy(obj->proxy[i]); } } ckfree(obj); return NULL; } # line 88 "functionclient.dy" AnonymousObject * dispatch_FunctionProxy(FunctionProxyCoordinator * fpc,char * function_call,AnonymousObjectList * args) { int i,j; AnonymousObject * ret; char buffer[1024]; FILE * ifp; Wise2WriteStreamInterface * ws; Wise2ReadStreamInterface * rs; assert(fpc != NULL); assert(function_call != NULL); assert(args != NULL); for(i=0;ilen;i++) { if( strcmp(fpc->proxy[i]->transfer->name,function_call) == 0 ) { break; } } if( i >= fpc->len ) { warn("In FunctionProxyCoordinator attached to %s,%d, function call %s has not been registered",fpc->host,fpc->port,function_call); return NULL; } else { fprintf(stderr,"Function proxy is ok with %s\n",function_call); } /* ok, go into cycle */ warn("Ewan has not protected this write from resend"); if (write(fpc->socket, function_call, strlen(function_call)) == -1) { fprintf(stderr, "write() failed\n"); fatal(strerror(errno)); } if (read(fpc->socket, buffer, 1024) == -1) { fprintf(stderr, "read() failed\n"); fatal(strerror(errno)); } if( strncmp(buffer,"NOT FOUND",9) == 0 ) { warn("In FunctionProxyCoordinator attached to %s,%d, function call %s is not present on server",fpc->host,fpc->port,function_call); return NULL; } else if( strncmp(buffer,"SEND",4) == 0 ) { fprintf(stderr,"Function call %s was accepted, sending data\n",function_call); } else { warn("In FunctionProxyCoordinator attached to %s, %d, " "function call %s triggered unknown response ('%s')", fpc->host, fpc->port, function_call, buffer); return NULL; } ws = WriteStream_from_socket(fpc->socket); for(j=0;jproxy[i]->transfer->len;j++) { (*fpc->proxy[i]->transfer->input[j]->object_to_stream)(args->anon[j]->obj,ws); } if ((ifp = fdopen(fpc->socket,"r")) == NULL) { fprintf(stderr, "fdopen() failed\n"); fatal(strerror(errno)); } rs = ReadStream_from_FILE(ifp); ret = AnonymousObject_alloc(); ret->obj = (*fpc->proxy[i]->transfer->returned_type->stream_to_object)(rs); ret->free_object = fpc->proxy[i]->transfer->returned_type->untyped_free_object; return ret; } # line 163 "functionclient.dy" FunctionProxy * new_FunctionProxy(TransferedFunctionCall * t) { FunctionProxy * out; out = FunctionProxy_alloc(); out->transfer = t; return out; } # line 174 "functionclient.dy" FunctionProxyCoordinator * new_FunctionProxyCoordinator(char * host,int port) { FunctionProxyCoordinator * out; struct sockaddr_in server; struct hostent * hp; out = FunctionProxyCoordinator_alloc_std(); out->host = stringalloc(host); out->port = port; out->socket = socket(AF_INET, SOCK_STREAM, 0); server.sin_family = AF_INET; hp = gethostbyname(host); bcopy( hp->h_addr, &server.sin_addr, hp->h_length); server.sin_port = htons(port); connect(out->socket, &server, sizeof(server)); return out; } # line 189 "functionclient.c" /* Function: hard_link_FunctionProxy(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FunctionProxy *] * * Return [UNKN ] Undocumented return value [FunctionProxy *] * */ FunctionProxy * hard_link_FunctionProxy(FunctionProxy * obj) { if( obj == NULL ) { warn("Trying to hard link to a FunctionProxy object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: FunctionProxy_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FunctionProxy *] * */ FunctionProxy * FunctionProxy_alloc(void) { FunctionProxy * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FunctionProxy *) ckalloc (sizeof(FunctionProxy))) == NULL) { warn("FunctionProxy_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->transfer = NULL; return out; } /* Function: free_FunctionProxy(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FunctionProxy *] * * Return [UNKN ] Undocumented return value [FunctionProxy *] * */ FunctionProxy * free_FunctionProxy(FunctionProxy * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FunctionProxy obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->transfer != NULL) free_TransferedFunctionCall(obj->transfer); ckfree(obj); return NULL; } /* Function: swap_FunctionProxyCoordinator(list,i,j) * * Descrip: swap function: an internal for qsort_FunctionProxyCoordinator * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [FunctionProxy **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_FunctionProxyCoordinator(FunctionProxy ** list,int i,int j) { FunctionProxy * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_FunctionProxyCoordinator(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_FunctionProxyCoordinator which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [FunctionProxy **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_FunctionProxyCoordinator(FunctionProxy ** list,int left,int right,int (*comp)(FunctionProxy * ,FunctionProxy * )) { int i,last; if( left >= right ) return; swap_FunctionProxyCoordinator(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_FunctionProxyCoordinator (list,++last,i); } swap_FunctionProxyCoordinator (list,left,last); qsort_FunctionProxyCoordinator(list,left,last-1,comp); qsort_FunctionProxyCoordinator(list,last+1,right,comp); } /* Function: sort_FunctionProxyCoordinator(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_FunctionProxyCoordinator * * * Arg: obj [UNKN ] Object containing list [FunctionProxyCoordinator *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_FunctionProxyCoordinator(FunctionProxyCoordinator * obj,int (*comp)(FunctionProxy *, FunctionProxy *)) { qsort_FunctionProxyCoordinator(obj->proxy,0,obj->len-1,comp); return; } /* Function: expand_FunctionProxyCoordinator(obj,len) * * Descrip: Really an internal function for add_FunctionProxyCoordinator * * * Arg: obj [UNKN ] Object which contains the list [FunctionProxyCoordinator *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_FunctionProxyCoordinator(FunctionProxyCoordinator * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_FunctionProxyCoordinator called with no need"); return TRUE; } if( (obj->proxy = (FunctionProxy ** ) ckrealloc (obj->proxy,sizeof(FunctionProxy *)*len)) == NULL) { warn("ckrealloc failed for expand_FunctionProxyCoordinator, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_FunctionProxyCoordinator(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FunctionProxyCoordinator *] * Arg: add [OWNER] Object to add to the list [FunctionProxy *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_FunctionProxyCoordinator(FunctionProxyCoordinator * obj,FunctionProxy * add) { if( obj->len >= obj->maxlen) { if( expand_FunctionProxyCoordinator(obj,obj->len + FunctionProxyCoordinatorLISTLENGTH) == FALSE) return FALSE; } obj->proxy[obj->len++]=add; return TRUE; } /* Function: flush_FunctionProxyCoordinator(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FunctionProxyCoordinator *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_FunctionProxyCoordinator(FunctionProxyCoordinator * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->proxy[i] != NULL) { free_FunctionProxy(obj->proxy[i]); obj->proxy[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: FunctionProxyCoordinator_alloc_std(void) * * Descrip: Equivalent to FunctionProxyCoordinator_alloc_len(FunctionProxyCoordinatorLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FunctionProxyCoordinator *] * */ FunctionProxyCoordinator * FunctionProxyCoordinator_alloc_std(void) { return FunctionProxyCoordinator_alloc_len(FunctionProxyCoordinatorLISTLENGTH); } /* Function: FunctionProxyCoordinator_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FunctionProxyCoordinator *] * */ FunctionProxyCoordinator * FunctionProxyCoordinator_alloc_len(int len) { FunctionProxyCoordinator * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = FunctionProxyCoordinator_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->proxy = (FunctionProxy ** ) ckcalloc (len,sizeof(FunctionProxy *))) == NULL) { warn("Warning, ckcalloc failed in FunctionProxyCoordinator_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_FunctionProxyCoordinator(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FunctionProxyCoordinator *] * * Return [UNKN ] Undocumented return value [FunctionProxyCoordinator *] * */ FunctionProxyCoordinator * hard_link_FunctionProxyCoordinator(FunctionProxyCoordinator * obj) { if( obj == NULL ) { warn("Trying to hard link to a FunctionProxyCoordinator object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: FunctionProxyCoordinator_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FunctionProxyCoordinator *] * */ FunctionProxyCoordinator * FunctionProxyCoordinator_alloc(void) { FunctionProxyCoordinator * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FunctionProxyCoordinator *) ckalloc (sizeof(FunctionProxyCoordinator))) == NULL) { warn("FunctionProxyCoordinator_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->proxy = NULL; out->len = out->maxlen = 0; out->socket = 0; out->host = NULL; out->port = 0; return out; } #ifdef _cplusplus } #endif wise-2.4.1/src/socket/functionclient.h0000644000175000001440000001647710670453715017354 0ustar philippusers#ifndef DYNAMITEfunctionclientHEADERFILE #define DYNAMITEfunctionclientHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "transferinterface.h" #include "anonobj.h" #include "directsocketwrite.h" #define FunctionProxyCoordinatorLISTLENGTH 16 struct Wise2_FunctionProxy { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif TransferedFunctionCall * transfer; } ; /* FunctionProxy defined */ #ifndef DYNAMITE_DEFINED_FunctionProxy typedef struct Wise2_FunctionProxy Wise2_FunctionProxy; #define FunctionProxy Wise2_FunctionProxy #define DYNAMITE_DEFINED_FunctionProxy #endif struct Wise2_FunctionProxyCoordinator { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif FunctionProxy ** proxy; int len;/* len for above proxy */ int maxlen; /* maxlen for above proxy */ int socket; char * host; int port; } ; /* FunctionProxyCoordinator defined */ #ifndef DYNAMITE_DEFINED_FunctionProxyCoordinator typedef struct Wise2_FunctionProxyCoordinator Wise2_FunctionProxyCoordinator; #define FunctionProxyCoordinator Wise2_FunctionProxyCoordinator #define DYNAMITE_DEFINED_FunctionProxyCoordinator #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: free_FunctionProxyCoordinator(obj) * * Descrip: provides specific destructor for FunctionProxyCoordinators * * * Arg: obj [UNKN ] Undocumented argument [FunctionProxyCoordinator *] * * Return [UNKN ] Undocumented return value [FunctionProxyCoordinator *] * */ FunctionProxyCoordinator * Wise2_free_FunctionProxyCoordinator(FunctionProxyCoordinator * obj); #define free_FunctionProxyCoordinator Wise2_free_FunctionProxyCoordinator /* Function: hard_link_FunctionProxy(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FunctionProxy *] * * Return [UNKN ] Undocumented return value [FunctionProxy *] * */ FunctionProxy * Wise2_hard_link_FunctionProxy(FunctionProxy * obj); #define hard_link_FunctionProxy Wise2_hard_link_FunctionProxy /* Function: FunctionProxy_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FunctionProxy *] * */ FunctionProxy * Wise2_FunctionProxy_alloc(void); #define FunctionProxy_alloc Wise2_FunctionProxy_alloc /* Function: free_FunctionProxy(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FunctionProxy *] * * Return [UNKN ] Undocumented return value [FunctionProxy *] * */ FunctionProxy * Wise2_free_FunctionProxy(FunctionProxy * obj); #define free_FunctionProxy Wise2_free_FunctionProxy /* Function: add_FunctionProxyCoordinator(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [FunctionProxyCoordinator *] * Arg: add [OWNER] Object to add to the list [FunctionProxy *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_FunctionProxyCoordinator(FunctionProxyCoordinator * obj,FunctionProxy * add); #define add_FunctionProxyCoordinator Wise2_add_FunctionProxyCoordinator /* Function: flush_FunctionProxyCoordinator(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [FunctionProxyCoordinator *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_FunctionProxyCoordinator(FunctionProxyCoordinator * obj); #define flush_FunctionProxyCoordinator Wise2_flush_FunctionProxyCoordinator /* Function: FunctionProxyCoordinator_alloc_std(void) * * Descrip: Equivalent to FunctionProxyCoordinator_alloc_len(FunctionProxyCoordinatorLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [FunctionProxyCoordinator *] * */ FunctionProxyCoordinator * Wise2_FunctionProxyCoordinator_alloc_std(void); #define FunctionProxyCoordinator_alloc_std Wise2_FunctionProxyCoordinator_alloc_std /* Function: FunctionProxyCoordinator_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [FunctionProxyCoordinator *] * */ FunctionProxyCoordinator * Wise2_FunctionProxyCoordinator_alloc_len(int len); #define FunctionProxyCoordinator_alloc_len Wise2_FunctionProxyCoordinator_alloc_len /* Function: hard_link_FunctionProxyCoordinator(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FunctionProxyCoordinator *] * * Return [UNKN ] Undocumented return value [FunctionProxyCoordinator *] * */ FunctionProxyCoordinator * Wise2_hard_link_FunctionProxyCoordinator(FunctionProxyCoordinator * obj); #define hard_link_FunctionProxyCoordinator Wise2_hard_link_FunctionProxyCoordinator /* Function: FunctionProxyCoordinator_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FunctionProxyCoordinator *] * */ FunctionProxyCoordinator * Wise2_FunctionProxyCoordinator_alloc(void); #define FunctionProxyCoordinator_alloc Wise2_FunctionProxyCoordinator_alloc /* Unplaced functions */ /* There has been no indication of the use of these functions */ AnonymousObject * Wise2_dispatch_FunctionProxy(FunctionProxyCoordinator * fpc,char * function_call,AnonymousObjectList * args); #define dispatch_FunctionProxy Wise2_dispatch_FunctionProxy FunctionProxy * Wise2_new_FunctionProxy(TransferedFunctionCall * t); #define new_FunctionProxy Wise2_new_FunctionProxy FunctionProxyCoordinator * Wise2_new_FunctionProxyCoordinator(char * host,int port); #define new_FunctionProxyCoordinator Wise2_new_FunctionProxyCoordinator /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_FunctionProxyCoordinator(FunctionProxy ** list,int i,int j) ; #define swap_FunctionProxyCoordinator Wise2_swap_FunctionProxyCoordinator void Wise2_qsort_FunctionProxyCoordinator(FunctionProxy ** list,int left,int right,int (*comp)(FunctionProxy * ,FunctionProxy * )); #define qsort_FunctionProxyCoordinator Wise2_qsort_FunctionProxyCoordinator void Wise2_sort_FunctionProxyCoordinator(FunctionProxyCoordinator * obj,int (*comp)(FunctionProxy *, FunctionProxy *)); #define sort_FunctionProxyCoordinator Wise2_sort_FunctionProxyCoordinator boolean Wise2_expand_FunctionProxyCoordinator(FunctionProxyCoordinator * obj,int len); #define expand_FunctionProxyCoordinator Wise2_expand_FunctionProxyCoordinator #ifdef _cplusplus } #endif #endif wise-2.4.1/src/socket/anonobj.c0000644000175000001440000002516410670453715015742 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "anonobj.h" /* Function: free_AnonymousObject(ao) * * Descrip: frees an anonymous object * * * Arg: ao [UNKN ] Undocumented argument [AnonymousObject *] * * Return [UNKN ] Undocumented return value [AnonymousObject *] * */ # line 26 "anonobj.dy" AnonymousObject * free_AnonymousObject(AnonymousObject * ao) { int return_early = 0; #ifdef PTHREAD assert(pthread_mutex_lock(&(ao->dynamite_mutex)) == 0); #endif if( ao->dynamite_hard_link > 1) { return_early = 1; ao->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(ao->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( ao->obj != NULL ) { if( ao->free_object == NULL ) { warn("With object of %s, no registered free function, but with a present object. Likely to be leaking memory now",ao->type); } else { (*ao->free_object)(ao->obj); } } free(ao); return NULL; } # line 47 "anonobj.c" /* Function: hard_link_AnonymousObject(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AnonymousObject *] * * Return [UNKN ] Undocumented return value [AnonymousObject *] * */ AnonymousObject * hard_link_AnonymousObject(AnonymousObject * obj) { if( obj == NULL ) { warn("Trying to hard link to a AnonymousObject object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AnonymousObject_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AnonymousObject *] * */ AnonymousObject * AnonymousObject_alloc(void) { AnonymousObject * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AnonymousObject *) ckalloc (sizeof(AnonymousObject))) == NULL) { warn("AnonymousObject_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = NULL; out->free_object = NULL; return out; } /* Function: swap_AnonymousObjectList(list,i,j) * * Descrip: swap function: an internal for qsort_AnonymousObjectList * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [AnonymousObject **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_AnonymousObjectList(AnonymousObject ** list,int i,int j) { AnonymousObject * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_AnonymousObjectList(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_AnonymousObjectList which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [AnonymousObject **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_AnonymousObjectList(AnonymousObject ** list,int left,int right,int (*comp)(AnonymousObject * ,AnonymousObject * )) { int i,last; if( left >= right ) return; swap_AnonymousObjectList(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_AnonymousObjectList (list,++last,i); } swap_AnonymousObjectList (list,left,last); qsort_AnonymousObjectList(list,left,last-1,comp); qsort_AnonymousObjectList(list,last+1,right,comp); } /* Function: sort_AnonymousObjectList(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_AnonymousObjectList * * * Arg: obj [UNKN ] Object containing list [AnonymousObjectList *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_AnonymousObjectList(AnonymousObjectList * obj,int (*comp)(AnonymousObject *, AnonymousObject *)) { qsort_AnonymousObjectList(obj->anon,0,obj->len-1,comp); return; } /* Function: expand_AnonymousObjectList(obj,len) * * Descrip: Really an internal function for add_AnonymousObjectList * * * Arg: obj [UNKN ] Object which contains the list [AnonymousObjectList *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_AnonymousObjectList(AnonymousObjectList * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_AnonymousObjectList called with no need"); return TRUE; } if( (obj->anon = (AnonymousObject ** ) ckrealloc (obj->anon,sizeof(AnonymousObject *)*len)) == NULL) { warn("ckrealloc failed for expand_AnonymousObjectList, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_AnonymousObjectList(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AnonymousObjectList *] * Arg: add [OWNER] Object to add to the list [AnonymousObject *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_AnonymousObjectList(AnonymousObjectList * obj,AnonymousObject * add) { if( obj->len >= obj->maxlen) { if( expand_AnonymousObjectList(obj,obj->len + AnonymousObjectListLISTLENGTH) == FALSE) return FALSE; } obj->anon[obj->len++]=add; return TRUE; } /* Function: flush_AnonymousObjectList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AnonymousObjectList *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_AnonymousObjectList(AnonymousObjectList * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->anon[i] != NULL) { free_AnonymousObject(obj->anon[i]); obj->anon[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: AnonymousObjectList_alloc_std(void) * * Descrip: Equivalent to AnonymousObjectList_alloc_len(AnonymousObjectListLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AnonymousObjectList *] * */ AnonymousObjectList * AnonymousObjectList_alloc_std(void) { return AnonymousObjectList_alloc_len(AnonymousObjectListLISTLENGTH); } /* Function: AnonymousObjectList_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AnonymousObjectList *] * */ AnonymousObjectList * AnonymousObjectList_alloc_len(int len) { AnonymousObjectList * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = AnonymousObjectList_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->anon = (AnonymousObject ** ) ckcalloc (len,sizeof(AnonymousObject *))) == NULL) { warn("Warning, ckcalloc failed in AnonymousObjectList_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_AnonymousObjectList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AnonymousObjectList *] * * Return [UNKN ] Undocumented return value [AnonymousObjectList *] * */ AnonymousObjectList * hard_link_AnonymousObjectList(AnonymousObjectList * obj) { if( obj == NULL ) { warn("Trying to hard link to a AnonymousObjectList object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AnonymousObjectList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AnonymousObjectList *] * */ AnonymousObjectList * AnonymousObjectList_alloc(void) { AnonymousObjectList * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AnonymousObjectList *) ckalloc (sizeof(AnonymousObjectList))) == NULL) { warn("AnonymousObjectList_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->anon = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_AnonymousObjectList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AnonymousObjectList *] * * Return [UNKN ] Undocumented return value [AnonymousObjectList *] * */ AnonymousObjectList * free_AnonymousObjectList(AnonymousObjectList * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AnonymousObjectList obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->anon != NULL) { for(i=0;ilen;i++) { if( obj->anon[i] != NULL) free_AnonymousObject(obj->anon[i]); } ckfree(obj->anon); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/socket/anonobj.h0000644000175000001440000001472210670453715015745 0ustar philippusers#ifndef DYNAMITEanonobjHEADERFILE #define DYNAMITEanonobjHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #define AnonymousObjectListLISTLENGTH 16 struct Wise2_AnonymousObject { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif void * obj; char * type; void (*free_object)(void *); } ; /* AnonymousObject defined */ #ifndef DYNAMITE_DEFINED_AnonymousObject typedef struct Wise2_AnonymousObject Wise2_AnonymousObject; #define AnonymousObject Wise2_AnonymousObject #define DYNAMITE_DEFINED_AnonymousObject #endif struct Wise2_AnonymousObjectList { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif AnonymousObject ** anon; int len;/* len for above anon */ int maxlen; /* maxlen for above anon */ } ; /* AnonymousObjectList defined */ #ifndef DYNAMITE_DEFINED_AnonymousObjectList typedef struct Wise2_AnonymousObjectList Wise2_AnonymousObjectList; #define AnonymousObjectList Wise2_AnonymousObjectList #define DYNAMITE_DEFINED_AnonymousObjectList #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: free_AnonymousObject(ao) * * Descrip: frees an anonymous object * * * Arg: ao [UNKN ] Undocumented argument [AnonymousObject *] * * Return [UNKN ] Undocumented return value [AnonymousObject *] * */ AnonymousObject * Wise2_free_AnonymousObject(AnonymousObject * ao); #define free_AnonymousObject Wise2_free_AnonymousObject /* Function: hard_link_AnonymousObject(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AnonymousObject *] * * Return [UNKN ] Undocumented return value [AnonymousObject *] * */ AnonymousObject * Wise2_hard_link_AnonymousObject(AnonymousObject * obj); #define hard_link_AnonymousObject Wise2_hard_link_AnonymousObject /* Function: AnonymousObject_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AnonymousObject *] * */ AnonymousObject * Wise2_AnonymousObject_alloc(void); #define AnonymousObject_alloc Wise2_AnonymousObject_alloc /* Function: add_AnonymousObjectList(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AnonymousObjectList *] * Arg: add [OWNER] Object to add to the list [AnonymousObject *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_AnonymousObjectList(AnonymousObjectList * obj,AnonymousObject * add); #define add_AnonymousObjectList Wise2_add_AnonymousObjectList /* Function: flush_AnonymousObjectList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AnonymousObjectList *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_AnonymousObjectList(AnonymousObjectList * obj); #define flush_AnonymousObjectList Wise2_flush_AnonymousObjectList /* Function: AnonymousObjectList_alloc_std(void) * * Descrip: Equivalent to AnonymousObjectList_alloc_len(AnonymousObjectListLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AnonymousObjectList *] * */ AnonymousObjectList * Wise2_AnonymousObjectList_alloc_std(void); #define AnonymousObjectList_alloc_std Wise2_AnonymousObjectList_alloc_std /* Function: AnonymousObjectList_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AnonymousObjectList *] * */ AnonymousObjectList * Wise2_AnonymousObjectList_alloc_len(int len); #define AnonymousObjectList_alloc_len Wise2_AnonymousObjectList_alloc_len /* Function: hard_link_AnonymousObjectList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AnonymousObjectList *] * * Return [UNKN ] Undocumented return value [AnonymousObjectList *] * */ AnonymousObjectList * Wise2_hard_link_AnonymousObjectList(AnonymousObjectList * obj); #define hard_link_AnonymousObjectList Wise2_hard_link_AnonymousObjectList /* Function: AnonymousObjectList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AnonymousObjectList *] * */ AnonymousObjectList * Wise2_AnonymousObjectList_alloc(void); #define AnonymousObjectList_alloc Wise2_AnonymousObjectList_alloc /* Function: free_AnonymousObjectList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AnonymousObjectList *] * * Return [UNKN ] Undocumented return value [AnonymousObjectList *] * */ AnonymousObjectList * Wise2_free_AnonymousObjectList(AnonymousObjectList * obj); #define free_AnonymousObjectList Wise2_free_AnonymousObjectList /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_AnonymousObjectList(AnonymousObject ** list,int i,int j) ; #define swap_AnonymousObjectList Wise2_swap_AnonymousObjectList void Wise2_qsort_AnonymousObjectList(AnonymousObject ** list,int left,int right,int (*comp)(AnonymousObject * ,AnonymousObject * )); #define qsort_AnonymousObjectList Wise2_qsort_AnonymousObjectList void Wise2_sort_AnonymousObjectList(AnonymousObjectList * obj,int (*comp)(AnonymousObject *, AnonymousObject *)); #define sort_AnonymousObjectList Wise2_sort_AnonymousObjectList boolean Wise2_expand_AnonymousObjectList(AnonymousObjectList * obj,int len); #define expand_AnonymousObjectList Wise2_expand_AnonymousObjectList #ifdef _cplusplus } #endif #endif wise-2.4.1/src/socket/functionclient.dy0000644000175000001440000001053507737751307017536 0ustar philippusers %{ #include "transferinterface.h" #include "anonobj.h" #include "directsocketwrite.h" #define FunctionProxyCoordinatorLISTLENGTH 16 %} struct FunctionProxy TransferedFunctionCall * transfer struct FunctionProxyCoordinator FunctionProxy ** proxy !list int socket char * host int port %{ #include "functionclient.h" #include #include #include #include #include #include #include #include /* errno */ %func provides specific destructor for FunctionProxyCoordinators %% !deconstructor FunctionProxyCoordinator * free_FunctionProxyCoordinator(FunctionProxyCoordinator * obj) { int i; int return_early = 0; char buffer[1024]; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FunctionProxy obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* send FINISH to server */ strcpy(buffer,"FINISH"); if (write(obj->socket, buffer, 6) == -1) { fprintf(stderr, "write() failed\n"); fatal(strerror(errno)); } close(obj->socket); for(i=0;ilen;i++) { if( obj->proxy[i] != NULL ) { free_FunctionProxy(obj->proxy[i]); } } ckfree(obj); return NULL; } AnonymousObject * dispatch_FunctionProxy(FunctionProxyCoordinator * fpc,char * function_call,AnonymousObjectList * args) { int i,j; AnonymousObject * ret; char buffer[1024]; FILE * ifp; Wise2WriteStreamInterface * ws; Wise2ReadStreamInterface * rs; assert(fpc != NULL); assert(function_call != NULL); assert(args != NULL); for(i=0;ilen;i++) { if( strcmp(fpc->proxy[i]->transfer->name,function_call) == 0 ) { break; } } if( i >= fpc->len ) { warn("In FunctionProxyCoordinator attached to %s,%d, function call %s has not been registered",fpc->host,fpc->port,function_call); return NULL; } else { fprintf(stderr,"Function proxy is ok with %s\n",function_call); } /* ok, go into cycle */ warn("Ewan has not protected this write from resend"); if (write(fpc->socket, function_call, strlen(function_call)) == -1) { fprintf(stderr, "write() failed\n"); fatal(strerror(errno)); } if (read(fpc->socket, buffer, 1024) == -1) { fprintf(stderr, "read() failed\n"); fatal(strerror(errno)); } if( strncmp(buffer,"NOT FOUND",9) == 0 ) { warn("In FunctionProxyCoordinator attached to %s,%d, function call %s is not present on server",fpc->host,fpc->port,function_call); return NULL; } else if( strncmp(buffer,"SEND",4) == 0 ) { fprintf(stderr,"Function call %s was accepted, sending data\n",function_call); } else { warn("In FunctionProxyCoordinator attached to %s, %d, " "function call %s triggered unknown response ('%s')", fpc->host, fpc->port, function_call, buffer); return NULL; } ws = WriteStream_from_socket(fpc->socket); for(j=0;jproxy[i]->transfer->len;j++) { (*fpc->proxy[i]->transfer->input[j]->object_to_stream)(args->anon[j]->obj,ws); } if ((ifp = fdopen(fpc->socket,"r")) == NULL) { fprintf(stderr, "fdopen() failed\n"); fatal(strerror(errno)); } rs = ReadStream_from_FILE(ifp); ret = AnonymousObject_alloc(); ret->obj = (*fpc->proxy[i]->transfer->returned_type->stream_to_object)(rs); ret->free_object = fpc->proxy[i]->transfer->returned_type->untyped_free_object; return ret; } FunctionProxy * new_FunctionProxy(TransferedFunctionCall * t) { FunctionProxy * out; out = FunctionProxy_alloc(); out->transfer = t; return out; } FunctionProxyCoordinator * new_FunctionProxyCoordinator(char * host,int port) { FunctionProxyCoordinator * out; struct sockaddr_in server; struct hostent * hp; out = FunctionProxyCoordinator_alloc_std(); out->host = stringalloc(host); out->port = port; out->socket = socket(AF_INET, SOCK_STREAM, 0); server.sin_family = AF_INET; hp = gethostbyname(host); bcopy( hp->h_addr, &server.sin_addr, hp->h_length); server.sin_port = htons(port); connect(out->socket, &server, sizeof(server)); return out; } %} wise-2.4.1/src/socket/directsocketwrite.c0000644000175000001440000001006210670453715020041 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "directsocketwrite.h" # line 17 "directsocketwrite.dy" void write_buffer_direct_socket_server_impl(void * handle,char * string) { DirectSocketWrite * dsw = (DirectSocketWrite*) handle; write_DirectSocketWrite(dsw,string); } # line 24 "directsocketwrite.dy" void write_bufferf_direct_socket_server_impl(void * handle,char * format,...) { DirectSocketWrite * dsw = (DirectSocketWrite*) handle; char buffer[1024]; va_list ap; va_start(ap,format); vsprintf(buffer,format,ap); write_DirectSocketWrite(dsw,buffer); return; } # line 39 "directsocketwrite.dy" void close_and_free_direct_socket_server(void * handle) { DirectSocketWrite * dsw = (DirectSocketWrite*) handle; free_DirectSocketWrite(dsw); return; } # line 48 "directsocketwrite.dy" Wise2WriteStreamInterface * WriteStream_from_socket(int socket) { Wise2WriteStreamInterface * out; DirectSocketWrite * dsw; dsw = DirectSocketWrite_alloc(); dsw->socket = socket; out = malloc(sizeof(Wise2WriteStreamInterface)); out->write_buffer = write_buffer_direct_socket_server_impl; out->write_bufferf = write_bufferf_direct_socket_server_impl; out->close_and_free_handle = close_and_free_direct_socket_server; out->handle = (void *) dsw; return out; } # line 69 "directsocketwrite.dy" boolean write_DirectSocketWrite(DirectSocketWrite * dsw,char * string) { int curr; int length; int ret; length = strlen(string); curr = 0; while( curr < length ) { ret = write(dsw->socket,string+curr,length-curr); if( ret == -1 ) { /* warn("Error sending with %d\n",errno); */ break; } if( ret+curr >= length ) { break; } curr += ret; } return TRUE; } # line 89 "directsocketwrite.c" /* Function: hard_link_DirectSocketWrite(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DirectSocketWrite *] * * Return [UNKN ] Undocumented return value [DirectSocketWrite *] * */ DirectSocketWrite * hard_link_DirectSocketWrite(DirectSocketWrite * obj) { if( obj == NULL ) { warn("Trying to hard link to a DirectSocketWrite object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DirectSocketWrite_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DirectSocketWrite *] * */ DirectSocketWrite * DirectSocketWrite_alloc(void) { DirectSocketWrite * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DirectSocketWrite *) ckalloc (sizeof(DirectSocketWrite))) == NULL) { warn("DirectSocketWrite_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->socket = 0; return out; } /* Function: free_DirectSocketWrite(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DirectSocketWrite *] * * Return [UNKN ] Undocumented return value [DirectSocketWrite *] * */ DirectSocketWrite * free_DirectSocketWrite(DirectSocketWrite * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DirectSocketWrite obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/socket/directsocketwrite.h0000644000175000001440000000615210670453715020053 0ustar philippusers#ifndef DYNAMITEdirectsocketwriteHEADERFILE #define DYNAMITEdirectsocketwriteHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" struct Wise2_DirectSocketWrite { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int socket; } ; /* DirectSocketWrite defined */ #ifndef DYNAMITE_DEFINED_DirectSocketWrite typedef struct Wise2_DirectSocketWrite Wise2_DirectSocketWrite; #define DirectSocketWrite Wise2_DirectSocketWrite #define DYNAMITE_DEFINED_DirectSocketWrite #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_DirectSocketWrite(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DirectSocketWrite *] * * Return [UNKN ] Undocumented return value [DirectSocketWrite *] * */ DirectSocketWrite * Wise2_hard_link_DirectSocketWrite(DirectSocketWrite * obj); #define hard_link_DirectSocketWrite Wise2_hard_link_DirectSocketWrite /* Function: DirectSocketWrite_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DirectSocketWrite *] * */ DirectSocketWrite * Wise2_DirectSocketWrite_alloc(void); #define DirectSocketWrite_alloc Wise2_DirectSocketWrite_alloc /* Function: free_DirectSocketWrite(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DirectSocketWrite *] * * Return [UNKN ] Undocumented return value [DirectSocketWrite *] * */ DirectSocketWrite * Wise2_free_DirectSocketWrite(DirectSocketWrite * obj); #define free_DirectSocketWrite Wise2_free_DirectSocketWrite /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_write_buffer_direct_socket_server_impl(void * handle,char * string); #define write_buffer_direct_socket_server_impl Wise2_write_buffer_direct_socket_server_impl void Wise2_write_bufferf_direct_socket_server_impl(void * handle,char * format,...); #define write_bufferf_direct_socket_server_impl Wise2_write_bufferf_direct_socket_server_impl void Wise2_close_and_free_direct_socket_server(void * handle); #define close_and_free_direct_socket_server Wise2_close_and_free_direct_socket_server Wise2WriteStreamInterface * Wise2_WriteStream_from_socket(int socket); #define WriteStream_from_socket Wise2_WriteStream_from_socket boolean Wise2_write_DirectSocketWrite(DirectSocketWrite * dsw,char * string); #define write_DirectSocketWrite Wise2_write_DirectSocketWrite /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/0000755000175000001440000000000010670453716014443 5ustar philippuserswise-2.4.1/src/dnaindex/kmer_index_interface.c0000644000175000001440000000046010670453716020754 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "kmer_index_interface.h" # line 26 "kmer_index_interface.dy" void free_KmerIndexInterface(KmerIndexInterface * kii) { assert(kii); (*kii->free_handle)(kii->handle); free(kii); } # line 21 "kmer_index_interface.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/kmer_index_interface.h0000644000175000001440000000226410670453716020765 0ustar philippusers#ifndef DYNAMITEkmer_index_interfaceHEADERFILE #define DYNAMITEkmer_index_interfaceHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" /* this brings in kmer_t */ #include "dnamapping.h" typedef struct KmerIndexInterface { void* (*retrieve_by_kmer)(void *,kmer_t); boolean (*insert_by_kmer)(void*,kmer_t,void*); void (*free_handle)(void*); kmer_t (*next_filled_kmer)(void *,kmer_t); void * handle; int kmer_size; } KmerIndexInterface; /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_free_KmerIndexInterface(KmerIndexInterface * kii); #define free_KmerIndexInterface Wise2_free_KmerIndexInterface /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/kmer_assembly_error.dy0000644000175000001440000004033310064313517021041 0ustar philippusers %{ #include "kmer_assembly.h" #include "kmer_assembly_untangler.h" %} %{ #include "kmer_assembly_error.h" boolean lift_indel_error_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyPath * real,KmerAssemblyPath * error,long int * start_labels,int label_len,int error_position,int error_len) { int i,j,k,true; for(i=0,true=0;istack_len && truestack_len;i++,true++) { if( i == error_position ) { if( error_len > 0 ) { for(j=0;jstack[i] == NULL ) { fprintf(stderr,"issue - error path is missing a link!"); } else { remove_sequence_label_KmerAssemblyLink(error->stack[i],start_labels[k]+i); } if( real->stack[true] == NULL ) { fprintf(stderr,"issue - true path is missing a link!"); } else { add_sequence_label_KmerAssemblyLink(real->stack[true],start_labels[k]+i); } if( error->stack[i] != NULL && error->stack[i]->sequence_label_len == 0 ) { detach_KmerAssemblyLink(kai,error->stack[i]); } } } return TRUE; } boolean lift_forward_error_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyPath * real,KmerAssemblyPath * error,long int * start_labels,int label_len) { int i,k; for(i=0;istack_len;i++) { for(k=0;kstack[i],start_labels[k]+i); add_sequence_label_KmerAssemblyLink(real->stack[i],start_labels[k]+i); if( error->stack[i]->sequence_label_len == 0 ) { detach_KmerAssemblyLink(kai,error->stack[i]); } } } return TRUE; } int mark_tangles_KmerAssembly(KmerAssemblyIndex * kai) { int i; kmer_t kmer; KmerAssemblyNode * node; char buffer[256]; int count = 0; kmer = -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); if( node->prev_len > 1 ) { reverse_map_dna_number(node->number,kai->kii->kmer_size,buffer); buffer[kai->kii->kmer_size] = '\0'; fprintf(stderr,"Marking node (%ld) [%s] as next tangled\n",node->number,buffer); count++; for(i=0;iprev_len;i++) { node->prev[i]->state |= KMER_ASSEMBLY_NEXT_TANGLED; } } if( node->next_len > 1 ) { reverse_map_dna_number(node->number,kai->kii->kmer_size,buffer); buffer[kai->kii->kmer_size] = '\0'; fprintf(stderr,"Marking node (%ld) [%s] as prev tangled\n",node->number,buffer); count++; for(i=0;inext_len;i++) { node->next[i]->state |= KMER_ASSEMBLY_PREV_TANGLED; } } } return count; } int resolve_forward_errors_KmerAssembly(KmerAssemblyIndex * kai,int depth,int verbose,int max_path_enum) { int i; int total = 0; kmer_t kmer; KmerAssemblyNode * node; char buffer[128]; SinglePosSequence * sps; assert(kai != NULL); assert(kai->kii != NULL ); assert(kai->kii->next_filled_kmer != NULL); kmer = -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); assert(node != NULL); if( node->next_len < 2 ) { continue; } for(i=0;inext_len;i++) { if( node->next[i]->sequence_label_len <= depth ) { if( verbose ) { reverse_map_dna_number(node->next[i]->next->number,kai->kii->kmer_size,buffer); buffer[kai->kii->kmer_size] = '\0'; sps = lookup_Sequence_SinglePosSpace(kai->sps,node->next[i]->sequence_label[0]); fprintf(stderr,"Attempting to resolve error [%s] from sequence %s, depth %d\n",buffer,((AssemblySequence*)sps->data)->seq->name,node->next[i]->sequence_label_len); } total += attempt_resolve_forward_error_KmerAssembly(kai,node,depth,max_path_enum); break; } } } return total; } void remove_errors_KmerAssemblyIndex(KmerAssemblyIndex * kai,int max_error_depth) { int i; kmer_t kmer; KmerAssemblyNode * node; assert(kai != NULL); assert(kai->kii != NULL); assert(kai->kii->next_filled_kmer != NULL); kmer = -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); assert(node); if( node->next_len > 1 ) { for(i=0;inext_len;i++) { if( node->next[i]->sequence_label_len <= max_error_depth ) { detach_KmerAssemblyLink(kai,node->next[i]); } } } if( node->prev_len > 1 ) { for(i=0;iprev_len;i++) { if( node->prev[i]->sequence_label_len <= max_error_depth ) { detach_KmerAssemblyLink(kai,node->prev[i]); } } } } } int attempt_resolve_forward_error_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyNode * node,int depth,int max_path_enum) { int success; int i,j,k; KmerAssemblyPath * final_real; KmerAssemblyPath * final_error; char * alphabet = "ATGC"; char buffer[256]; char next[256]; char selfbase; kmer_t new_number; int no_success = 0; int no_failures = 0; assert(kai != NULL); assert(node != NULL); final_real = new_KmerAssemblyPath(); final_error = new_KmerAssemblyPath(); if( node->next_len == 0 ) { warn("No outgoing links, therefore no errors"); return TRUE; } if( node->next_len == 0 ) { warn("Only one outgoing link, so no error"); return TRUE; } /* look for links with depth outgoing */ for(i=0;inext_len;i++) { if( node->next[i]->sequence_label_len <= depth ) { /* see whether this is an error*/ success = 0; reverse_map_dna_number(node->next[i]->next->number,kai->kii->kmer_size,buffer); selfbase = buffer[kai->kii->kmer_size-1]; /* test each base */ for(j=0;j<4;j++) { if( alphabet[j] == selfbase ) { continue; } buffer[kai->kii->kmer_size-1] = alphabet[j]; new_number = forward_dna_number_from_string(buffer,kai->kii->kmer_size); for(k=0;knext_len;k++) { if( k == i ) { continue; } if( new_number == node->next[k]->next->number ) { /* potential fix */ final_error->stack_len = 0; final_real->stack_len = 0; fprintf(stderr,"Found potential fix of %c to %c in %.*s (real:%c (%d), error:%c (%d))\n",selfbase,alphabet[j],kai->kii->kmer_size,buffer,node->next[k]->base,k,node->next[i]->base,i); /* consider potential insertion of one base */ if( find_indel_path_KmerAssembly(node->next[k],node->next[i],-1,kai->kii->kmer_size-1,final_real,final_error,kai->kii->kmer_size+1,max_path_enum) == TRUE ) { fprintf(stderr,"SUCCESS in insertion modelling\n"); lift_indel_error_KmerAssembly(kai,final_real,final_error,node->next[i]->sequence_label,node->next[i]->sequence_label_len,kai->kii->kmer_size-1,-1); success = 1; break; } if( find_indel_path_KmerAssembly(node->next[k],node->next[i],1,kai->kii->kmer_size-1,final_real,final_error,kai->kii->kmer_size+1,max_path_enum) == TRUE ) { fprintf(stderr,"SUCCESS in deletion modelling\n"); lift_indel_error_KmerAssembly(kai,final_real,final_error,node->next[i]->sequence_label,node->next[i]->sequence_label_len,kai->kii->kmer_size-1,1); success = 1; break; } /* otherwise substitution is all we can really suggest... */ if( find_error_path_KmerAssembly(node->next[k],node->next[i],alphabet[j],kai->kii->kmer_size-1,final_real,final_error,kai->kii->kmer_size+1,max_path_enum) == TRUE ) { /* fix error */ /* fprintf(stderr,"Found Error: Real\n"); show_KmerAssemblyPath(final_real,stderr); fprintf(stderr," Error\n"); show_KmerAssemblyPath(final_error,stderr); fprintf(stderr,"\n"); */ fprintf(stderr,"SUCCESS in substitution modelling\n"); lift_forward_error_KmerAssembly(kai,final_real,final_error,node->next[i]->sequence_label,node->next[i]->sequence_label_len); success = 1; break; } } } } if( success == 0 ) { no_failures++; } else { no_success++; } } } free_KmerAssemblyPath(final_real); free_KmerAssemblyPath(final_error); return no_success; } boolean find_indel_path_KmerAssembly(KmerAssemblyLink *real,KmerAssemblyLink * error,int delete_length,int proposed_position,KmerAssemblyPath * final_real,KmerAssemblyPath * final_error,int max_search,int max_path_enum) { int current_path = 1; return extend_indel_path_KmerAssembly(real,error,0,0,delete_length,proposed_position,final_real,final_error,max_search,¤t_path,max_path_enum); } boolean extend_indel_path_KmerAssembly(KmerAssemblyLink* real,KmerAssemblyLink * error,int real_pos,int error_pos,int delete_length,int proposed_position,KmerAssemblyPath * final_real,KmerAssemblyPath * final_error,int max_search,int *current_path,int max_path_enum) { int real_start; int error_start; int k; int i,j; KmerAssemblyLink * temp_real[256]; KmerAssemblyLink * temp_error[256]; if( max_search > 256 ) { fatal("Madness. Max search greater than 256 - shouldn't happen!"); } if( max_path_enum < *current_path ) { fprintf(stderr,"Terminating due too many paths\n"); return FALSE; } real_start = real_pos; error_start = error_pos; /* fprintf(stderr,"Entering into extension code with real %d, error %d\n",real_pos,error_pos);*/ while( real != NULL && error != NULL ) { if( proposed_position != real_pos ) { if( real->base != error->base ) { fprintf(stderr,"in considering indel (%d, path %d), real (%c) and error (%c) do not agree at position %d,%d\n",delete_length,current_path,real->base,error->base,real_pos,error_pos); return FALSE; } } else { if( delete_length > 0 ) { /* we move along in the real positions by delete number */ for(k=0;knext->next[0]; if( real == NULL ) { return FALSE; } if( real->next->next_len > 1 ) { fprintf(stderr,"Cannot handle over branched cases in indel area\n"); return FALSE; } } } else { /* we move along in the error positions by the delete number */ delete_length = abs(delete_length); for(k=0;knext->next[0]; if( error == NULL ) { return FALSE; } if( error->next->next_len > 1 ) { fprintf(stderr,"Cannot handle over branched cases in indel area\n"); return FALSE; } } } } temp_real[real_pos++] = real; temp_error[error_pos++] = error; if( real_pos > max_search ) { /* will return TRUE after loop */ break; } if( real == error ) { /* same node, therefore the streams have successfully merged */ break; } if( real->next->next_len == 1 && error->next->next_len == 1 ) { real = real->next->next[0]; error = error->next->next[0]; continue; } /* this is a tail position */ if( error->next->next_len == 0 ) { /* will return TRUE after loop */ break; } /* recursively call for each possible path: if any return true, return TRUE */ /* fprintf(stderr,"paths are branching, real with %d, error with %d\n",real->next->next_len,error->next->next_len);*/ if( real->next->next_len > 1 || error->next->next_len > 1 ) { for(i=0;inext->next_len;i++) { for(j=0;jnext->next_len;j++) { (*current_path)++; if( extend_indel_path_KmerAssembly(real->next->next[i],error->next->next[j],real_pos,error_pos,delete_length,proposed_position,final_real,final_error,max_search,current_path,max_path_enum) == TRUE ) { break; } } } /* fprintf(stderr,"Recursively unable to find path\n");*/ /* unable to find a good path */ return FALSE; } fprintf(stderr,"should be impossible to reach here, all other options have been considered"); return FALSE; } /* have to put the right path into the path datastructures */ /* we might have to extend the path datastructures */ if( final_real->max_stack < real_pos || final_error->max_stack < error_pos ) { fatal("Have to extend path; should be easy, but not done yet"); } if( final_real->stack_len < real_pos ) { /* first return */ final_real->stack_len = real_pos; } if( final_error->stack_len < error_pos ) { /* first return */ final_error->stack_len = error_pos; } for(i=real_start;istack[i] = temp_real[i]; } for(i=error_start;istack[i] = temp_error[i]; } return TRUE; } boolean find_error_path_KmerAssembly(KmerAssemblyLink * start_real,KmerAssemblyLink * start_error,char proposed_fix,int proposed_fix_position,KmerAssemblyPath * final_real,KmerAssemblyPath * final_error,int max_search,int max_path_enum) { int current_path = 1; return extend_error_path_KmerAssembly(start_real,start_error,0,proposed_fix,proposed_fix_position,final_real,final_error,max_search,¤t_path,max_path_enum); } boolean extend_error_path_KmerAssembly(KmerAssemblyLink * real,KmerAssemblyLink * error,int current_pos,char proposed_fix,int proposed_fix_position,KmerAssemblyPath * final_real,KmerAssemblyPath * final_error,int max_search,int * current_path,int max_path_enum) { int i; int j; int temp_pos; int startpos = current_pos; KmerAssemblyLink * temp_real[256]; KmerAssemblyLink * temp_error[256]; if( max_search > 256 ) { fatal("Madness. Max search greater than 256 - shouldn't happen!"); } if( max_path_enum < *current_path ) { fprintf(stderr,"Terminating due too many paths\n"); return FALSE; } temp_pos = current_pos; /* fprintf(stderr,"Entering into extension code with %d temp_pos\n",temp_pos);*/ while( real != NULL && error != NULL ) { if( proposed_fix_position != temp_pos ) { if( real->base != error->base ) { /* fprintf(stderr,"real (%c) and error (%c) do not agree at position %d\n",real->base,error->base,temp_pos); */ return FALSE; } } else if ( real->base != proposed_fix ) { fprintf(stderr,"In fixed position real (%c) and proposed (%c) do not agree\n",real->base,proposed_fix); return FALSE; } temp_real[temp_pos] = real; temp_error[temp_pos] = error; temp_pos++; if( temp_pos > max_search ) { /* will return TRUE after loop */ break; } if( real->next->next_len == 1 && error->next->next_len == 1 ) { real = real->next->next[0]; error = error->next->next[0]; continue; } /* this is a tail position */ if( error->next->next_len == 0 ) { /* will return TRUE after loop */ break; } /* recursively call for each possible path: if any return true, return TRUE */ /* fprintf(stderr,"paths are branching, real with %d, error with %d\n",real->next->next_len,error->next->next_len);*/ if( real->next->next_len > 1 || error->next->next_len > 1 ) { for(i=0;inext->next_len;i++) { for(j=0;jnext->next_len;j++) { (*current_path)++; if( extend_error_path_KmerAssembly(real->next->next[i],error->next->next[j],temp_pos,proposed_fix,proposed_fix_position,final_real,final_error,max_search,current_path,max_path_enum) == TRUE ) { break; } } } /* fprintf(stderr,"Recursively unable to find path\n");*/ /* unable to find a good path */ return FALSE; } fprintf(stderr,"should be impossible to reach here, all other options have been considered"); return FALSE; } /* have to put the right path into the path datastructures */ /* we might have to extend the path datastructures */ if( final_real->max_stack < temp_pos || final_error->max_stack < temp_pos ) { fatal("Have to extend path; should be easy, but not done yet"); } if( final_real->stack_len < temp_pos ) { /* first return */ final_real->stack_len = temp_pos; final_error->stack_len = temp_pos; } for(i=startpos;istack[i] = temp_real[i]; final_error->stack[i] = temp_error[i]; } return TRUE; } wise-2.4.1/src/dnaindex/assembly.dy0000644000175000001440000001105610123610065016604 0ustar philippusers %{ #include "sequence.h" #include "largeseqreader.h" #define AssemblySequenceLISTLENGTH 8 #define AssemblyContigLISTLENGTH 512 #define AssemblyLISTLENGTH 1024 #define AssemblyOpaqueTypeSetLISTLENGTH 16 %} struct AssemblySequenceEdit char type char base friend AssemblySequence struct AssemblyOpaqueType int int_type char base struct AssemblyOpaqueTypeSet AssemblyOpaqueType ** type !list struct AssemblyOpaqueFeature int start int length AssemblyOpaqueType * type !link struct AssemblySequence Sequence * seq double * quality AssemblySequenceEdit ** edit !list char state AssemblySequence * mirror !link AssemblySequence * pair !link char mirror_seq !def="0" AssemblyOpaqueFeature ** opaque !list !len="opq_" Sequence * orig int * abrev_repeat struct AssemblySequencePlacement AssemblySequence * aseq; long int contig_start long int contig_end int seq_start int seq_end boolean ungapped struct AssemblyContig Sequence * consensus AssemblySequencePlacement ** reads !list boolean clean_start boolean clean_end int max_depth struct Assembly AssemblyContig ** contig !list AssemblySequence ** chaff !list !len="chaff_" struct AssemblyOutputPara int min_size %{ #include "assembly.h" void show_help_AssemblyOutputPara(FILE * ofp) { fprintf(ofp,"Assembly Output options\n"); fprintf(ofp," -as_min_size [500] min size of contig to show\n"); } AssemblyOutputPara * new_AssemblyOutputPara_from_argv(int * argc,char ** argv) { AssemblyOutputPara * out; out = AssemblyOutputPara_alloc(); out->min_size = 500; strip_out_integer_argument(argc,argv,"as_min_size",&out->min_size); return out; } AssemblyOpaqueTypeSet * homopolymer_AssemblyOpaqueTypeSet(void) { AssemblyOpaqueTypeSet * out; AssemblyOpaqueType * t; char * base = "ATGC"; int i; out = AssemblyOpaqueTypeSet_alloc_std(); for(i=0;i<4;i++) { t = new_homopolymer_AssemblyOpaqueType(i,base[i]); add_AssemblyOpaqueTypeSet(out,t); } return out; } int annotate_AssemblyOpaqueFeatures(AssemblyOpaqueTypeSet * aots,AssemblySequence * aseq,int kmer_size) { int count = 0; int i,j; int k; AssemblyOpaqueFeature * aof; AssemblyOpaqueFeature * prev; for(i=0;ilen;i++) { prev = NULL; for(j=0;jlen;) { if( aseq->seq->seq[j] == aots->type[i]->base ) { for(k=0;kseq->seq[j+k] != aots->type[i]->base ) { break; } } if( k < kmer_size ) { j += k; continue; } /* else, is a good position, extend to the end of this run */ for(;k+jlen;k++) { if( aseq->seq->seq[j+k] != aots->type[i]->base ) { break; } } /* if the start is within kmer of prev, then simply extend prev */ if( prev != NULL && prev->start+prev->length+kmer_size >= j ) { prev->length = j+k - prev->start; } else { /* new feature */ aof = AssemblyOpaqueFeature_alloc(); aof->start = j; aof->length = k; aof->type = aots->type[i]; add_opq_AssemblySequence(aseq,aof); prev = aof; count++; } } else { j++; } } } return count; } void show_AssemblySequence(AssemblySequence * aseq,FILE * ofp) { int i; assert(aseq!=NULL); for(i=0;iopq_len;i++) { fprintf(ofp,"Opaque type %c from %d to %d\n",aseq->opaque[i]->type->base,aseq->opaque[i]->start,aseq->opaque[i]->start+aseq->opaque[i]->length); } write_fasta_Sequence(aseq->seq,ofp); fprintf(ofp,"//\n"); } AssemblyOpaqueType * new_homopolymer_AssemblyOpaqueType(int int_type,char base) { AssemblyOpaqueType * out; out = AssemblyOpaqueType_alloc(); out->base = base; out->int_type = int_type; return out; } AssemblySequence * read_plain_fasta_AssemblySequence(FILE * ifp,int report_log,FILE * report) { AssemblySequence * out; Sequence * seq; seq = read_large_dna_Sequence(ifp,report_log,report); if( seq == NULL ) { return NULL; } out = AssemblySequence_alloc_std(); out->seq = seq; return out; } AssemblySequence * mirrored_AssemblySequence(AssemblySequence * aseq) { AssemblySequence * out; out = AssemblySequence_alloc(); out->seq = reverse_complement_Sequence(aseq->seq); out->mirror_seq = 1; out->mirror = aseq; aseq->mirror = out; return out; } void dump_contigs_as_fasta_Assembly(Assembly * assembly,AssemblyOutputPara * aop,FILE * ofp) { int i; for(i=0;ilen;i++) { AssemblyContig * c = assembly->contig[i]; if( aop->min_size > c->consensus->len ) { continue; } fprintf(ofp,">%s max_depth=%d clean_start=%d clean_end=%d\n",c->consensus->name,c->max_depth,c->clean_start,c->clean_end); show_line(c->consensus->seq,60,ofp); } } %} wise-2.4.1/src/dnaindex/test_compara.c0000644000175000001440000000535407721411132017264 0ustar philippusers#include "comparapath.h" #include "largeseqreader.h" #include "kmer_direct.h" #include "kmer_hash.h" #include #include "hitlist.h" void print_timing( struct timeval *tv1, struct timeval *tv2, const char *str ){ double diff = 1000000.0*(tv2->tv_sec - tv1->tv_sec) + (tv2->tv_usec - tv1->tv_usec); diff /= 1000000.0; fprintf(stderr, "TIMING: %8.3f %s\n", diff, str); } int main(int argc,char ** argv) { struct timeval tv1, tv2, tv3, tv4, tv5, tv6, tv7, tv8, tv9, tv10; ComparaIndex * ci; Sequence * seq1; Sequence * seq2; int i; HitList * hl; HitListOutputImpl * hloi; LinearHSPmanager * lm; ComparaLinkStart * q; ComparaLinkStart * t; KmerIndexInterface * kii; HSPset * out; long int spline; kii = new_KmerDirectIndex(12); /* kii = new_KmerHashIndex(22);*/ hloi = new_HitListOutputImpl_from_argv(&argc,argv); ci = new_ComparaIndex(kii); /* fprintf(stderr,"Ratio to genome is %.2f\n",(double)3000000000 / (double) ci->index_len);*/ gettimeofday(&tv1, NULL); seq1 = read_large_dna_Sequence_file(argv[1],10000000); gettimeofday(&tv2, NULL); seq2 = read_large_dna_Sequence_file(argv[2],10000000); printf("add_Sequence_ComparaIndex(ci,seq1,0,1000,0)\n"); gettimeofday(&tv3, NULL); q = add_Sequence_ComparaIndex(ci,seq1,0,5000000,0); printf("add_Sequence_ComparaIndex(ci,seq2,0,5000000,0)\n"); gettimeofday(&tv4, NULL); t = add_Sequence_ComparaIndex(ci,seq2,1,5000000,0); printf("insert_revcom_Splines(ci)\n"); gettimeofday(&tv5, NULL); spline = insert_revcom_Splines(ci,q); fprintf(stdout,"Inserted %ld splines\n",spline); printf("HSPset_from_ComparaIndex(ci,q)\n"); gettimeofday(&tv6, NULL); out = HSPset_from_ComparaIndex(ci,q); lm = LinearHSPmanager_alloc_std(); add_LinearHSPmanager(lm,out); printf("HitList_from_LinearHSPmanager(lm)\n"); gettimeofday(&tv7, NULL); /* hl = HitList_from_LinearHSPmanager(lm);*/ printf("show_stats_ComparaIndex(ci,q,stdout)\n"); gettimeofday(&tv8, NULL); show_stats_ComparaIndex(ci,q,stdout); printf("show_HSPset(out,stdout)\n"); gettimeofday(&tv9, NULL); show_HSPset(out,stdout); gettimeofday(&tv10, NULL); fflush(stdout); /* free_KmerHashIndex(kii->handle);*/ /* show_HitList_HitListOutputImpl(hloi,hl,stdout);*/ print_timing(&tv1, &tv2, "read seq1"); print_timing(&tv2, &tv3, "read seq2"); print_timing(&tv3, &tv4, "add seq1"); print_timing(&tv4, &tv5, "add seq2"); print_timing(&tv5, &tv6, "insert_revcom_Splines"); print_timing(&tv6, &tv7, "HSPset_from_ComparaIndex"); print_timing(&tv7, &tv8, "HitList_from_LinearHSPmanager"); print_timing(&tv8, &tv9, "show_stats_ComparaIndex"); print_timing(&tv9, &tv10, "show_HSPset"); print_timing(&tv1, &tv10, "TOTAL"); fflush(stderr); } wise-2.4.1/src/dnaindex/shotgun.dy0000644000175000001440000000236507667662122016503 0ustar philippusers %{ #include "sequence.h" %} struct ShotgunPara int read_length int insert_size int number int forward_only %{ #include "shotgun.h" %func Generates a file of Shotgun reads from a particular sequence randomly %% void generate_shotgun_reads(ShotgunPara * shot,Sequence * input,FILE * ofp) { int i; int j; int pos; Sequence * rev; Sequence * out; char * seqstr; char buffer[MAXLINE]; init_random(); seqstr = calloc(shot->read_length+1,sizeof(char)); rev = reverse_complement_Sequence(input); for(i=0;inumber;i++) { pos = random_integer(input->len-shot->insert_size); fprintf(stderr,"position at %d\n",pos); for(j=0;jread_length;j++) { seqstr[j] = input->seq[pos+j]; } seqstr[j] = '\0'; sprintf(buffer,"Read.%d.f",i); out = new_Sequence_from_strings(buffer,seqstr); write_fasta_Sequence(out,ofp); if( shot->forward_only == 1 ) { continue; } for(j=0;jread_length;j++) { seqstr[j] = rev->seq[rev->len-(pos+shot->insert_size+j)]; } seqstr[j] = '\0'; sprintf(buffer,"Read.%d.r",i); out = new_Sequence_from_strings(buffer,seqstr); write_fasta_Sequence(out,ofp); } free_Sequence(rev); free(seqstr); } %} wise-2.4.1/src/dnaindex/calculate_compara_n50.pl0000644000175000001440000000332307730362752021124 0ustar philippusers my %len = ( '1' => 210989981, '10' => 127014353, '10_random' => 593526, '11' => 129303236, '11_random' => 0, '12' => 125990086, '12_random' => 294697, '13' => 93269031, '13_random' => 262883, '14' => 86368090, '14_random' => 418315, '15' => 74363214, '15_random' => 118395, '16' => 73084034, '16_random' => 1338419, '17' => 73859773, '17_random' => 219907, '18' => 72035922, '18_random' => 316662, '19' => 53798088, '19_random' => 0, '1_random' => 2549662, '2' => 221356626, '20' => 61555802, '21' => 33823978, '22' => 33785749, '2_random' => 735116, '3' => 185824536, '3_random' => 582736, '4' => 169058312, '4_random' => 1250162, '5' => 166043302, '5_random' => 1959775, '6' => 158660857, '7' => 147591730, '7_random' => 605209, '8' => 124912316, '8_random' => 0, '9' => 109839313, '9_random' => 643757, 'NA_random' => 7926661, 'UL_random' => 11960799, 'X' => 124872836, 'X_random' => 5188694, 'Y' => 21805613, ); use strict; my $total = 0; my @lengths; my $q; while( <> ) { /chr/ || next; #1024 chr7 0 1024 chr7 171263 170239 - my ($len,$a,$startx,$endx,$b,$starty,$endy) = split; if( $total < $endx ) { $total = $endx; } $q = $a; push(@lengths,$len); } $q =~ s/query_chr//; $total = $len{$q}; #$total = 3_000_000_000; @lengths = sort { $b <=> $a } @lengths; my $top = $lengths[0]; my $run = 0; foreach my $len ( @lengths ) { if( $run+$len > $total / 2 ) { print "$q N50 $len LONGEST $top LENGTH $total\n"; last; } $run += $len; #print STDERR "got $run with $len\n"; } wise-2.4.1/src/dnaindex/kmer_glib_index.dy0000644000175000001440000000510210064320464020107 0ustar philippusers %{ #include "kmer_index_interface.h" #include "glib.h" typedef struct KmerGlibIndex { GHashTable * hash; kmer_t index_length; kmer_t * active_index; int kmer_pos; int active_index_length; } KmerGlibIndex; %} %{ #include "kmer_glib_index.h" KmerIndexInterface * new_interface_KmerGlibIndex(int kmer_size) { KmerIndexInterface * out; KmerGlibIndex * kgi; assert(kmer_size < 16); kgi = new_KmerGlibIndex(); out = malloc(sizeof(KmerIndexInterface)); out->retrieve_by_kmer = retrieve_by_kmer_KmerGlibIndex; out->insert_by_kmer = insert_by_kmer_KmerGlibIndex; out->free_handle = free_KmerGlibIndex; out->next_filled_kmer = next_filled_kmer_KmerGlibIndex; out->handle = (void*) kgi; out->kmer_size = kmer_size; return out; } kmer_t next_filled_kmer_KmerGlibIndex(void * handle,kmer_t prev) { KmerGlibIndex * kgi = (KmerGlibIndex*) handle; if( prev == -1 ) { if( kgi->active_index == NULL ) { make_active_kmer_KmerGlibIndex(kgi); } kgi->kmer_pos = 0; } if( kgi->kmer_pos < kgi->active_index_length ) { return kgi->active_index[kgi->kmer_pos++]; } else { return -1; } } void * retrieve_by_kmer_KmerGlibIndex(void * handle,kmer_t kmer) { KmerGlibIndex * kgi = (KmerGlibIndex*) handle; return (void*) g_hash_table_lookup(kgi->hash,(gconstpointer)kmer); } boolean insert_by_kmer_KmerGlibIndex(void * handle,kmer_t kmer,void * poi) { KmerGlibIndex * kgi = (KmerGlibIndex*) handle; g_hash_table_insert(kgi->hash,(gpointer)kmer,poi); return TRUE; } void free_KmerGlibIndex(void * handle) { KmerGlibIndex * kgi = (KmerGlibIndex*) handle; assert(kgi); warn("Not freeing glib hash, so leaking memory here"); free(kgi); } boolean make_active_kmer_KmerGlibIndex(void * handle) { KmerGlibIndex * kgi = (KmerGlibIndex*) handle; int size; assert(kgi); size = g_hash_table_size(kgi->hash); kgi->active_index = calloc(size,sizeof(kmer_t)); kgi->active_index_length = size; kgi->kmer_pos = 0; g_hash_table_foreach(kgi->hash,retrieve_active_kmer_KmerGlibIndex,(gpointer)kgi); kgi->kmer_pos = 0; return TRUE; } void retrieve_active_kmer_KmerGlibIndex(gpointer key,gpointer value,gpointer user_data) { KmerGlibIndex * kgi = (KmerGlibIndex*) user_data; kgi->active_index[kgi->kmer_pos++] = (kmer_t) key; } KmerGlibIndex * new_KmerGlibIndex(void) { KmerGlibIndex * out; out = malloc(sizeof(KmerGlibIndex)); out->hash = g_hash_table_new(g_direct_hash,g_direct_equal); out->active_index = NULL; out->kmer_pos = 0; out->active_index_length = 0; return out; } wise-2.4.1/src/dnaindex/assembly_sanger_project.dy0000644000175000001440000001073207742733021021704 0ustar philippusers %{ #include "assembly_stream_interface.h" #include #include %} struct SangerProjectDirectory DIR * dir char * extension char * directory %{ #include "assembly_sanger_project.h" AssemblySequence * next_AssemblySequence_sanger_impl(void * h) { char buffer[MAXLINE]; AssemblySequence * aseq; char * run; FILE * ifp; SangerProjectDirectory * s = (SangerProjectDirectory *) h; struct dirent * dirp; while( (dirp = readdir(s->dir)) != NULL ) { if( (run = strstr(dirp->d_name,s->extension)) != NULL ) { /* should check it is at the end */ if( strcmp(run,s->extension) != 0 ) { /* not at end */ continue; } sprintf(buffer,"%s/%s",s->directory,dirp->d_name); ifp = fopen(buffer,"r"); if( ifp == NULL ) { warn("This is crazy! name is in directory but cannot open file. Yikes"); return NULL; } aseq = read_clipped_sanger_AssemblySequence(ifp); fclose(ifp); return aseq; } } return NULL; } AssemblySequence * read_clipped_sanger_AssemblySequence(FILE * ifp) { AssemblySequence * out; Sequence * in; char * seqstr; char * run; int maxlen; int curr_pos; int in_seq = 0; int clip_start = -1; int clip_end = -1; int temp; char buffer[512]; char name[60]; seqstr = malloc(sizeof(char)*1028); maxlen = 1028; curr_pos = 0; while( fgets(buffer,512,ifp) != NULL ) { if( strstartcmp(buffer,"ID") == 0 ) { sscanf(buffer,"ID %s",name); continue; } if( strstartcmp(buffer,"QL") == 0 ) { sscanf(buffer,"QL %d",&clip_start); continue; } if( strstartcmp(buffer,"SL") == 0 ) { sscanf(buffer,"SL %d",&temp); if( temp > clip_start ) { clip_start = temp; } continue; } if( strstartcmp(buffer,"QR") == 0 ) { sscanf(buffer,"QR %d",&clip_end); continue; } if( strstartcmp(buffer,"SQ") == 0 ) { in_seq = 1; continue; } if( strstartcmp(buffer,"//") == 0 ) { in_seq = 0; continue; } if( in_seq == 1 ) { for(run=buffer;*run;run++) { if( !isspace(*run) ) { if( *run == '-' ) { seqstr[curr_pos++] = 'N'; } else { seqstr[curr_pos++] = *run; } } if( curr_pos >= maxlen ) { maxlen *= 2; seqstr = realloc(seqstr,sizeof(char)*(maxlen)); } } } } seqstr[curr_pos] = '\0'; if( clip_start == -1 ) { warn("No start clipping point found"); clip_start = 1; } if( clip_end == -1 ) { warn("No end clipping point found"); clip_end = strlen(seqstr); } /* seq to C coords*/ clip_start--; seqstr[clip_end] = '\0'; in = Sequence_from_static_memory(name,seqstr+clip_start); in->type = SEQUENCE_DNA; out = AssemblySequence_alloc_std(); out->seq = in; return out; } void free_handle_sanger_impl(void * h) { SangerProjectDirectory * s = (SangerProjectDirectory *) h; free_SangerProjectDirectory(s); } AssemblySequenceStream * new_sanger_project_AssemblySequenceStream(char * dir_name,char * extension) { AssemblySequenceStream * out; SangerProjectDirectory * spd; spd = new_SangerProjectDirectory(dir_name,extension); out = AssemblySequenceStream_alloc(); out->handle = (void*) spd; out->next_AssemblySequence = next_AssemblySequence_sanger_impl; out->free_handle = free_handle_sanger_impl; return out; } SangerProjectDirectory * new_SangerProjectDirectory(char * dir_name,char * extension) { DIR * d; SangerProjectDirectory * out; d = opendir(dir_name); if( d == NULL ) { warn("Could not open directory %s",dir_name); return NULL; } out = SangerProjectDirectory_alloc(); out->dir = d; out->extension = stringalloc(extension); out->directory = stringalloc(dir_name); return out; } %func deconstructor %% !deconstructor SangerProjectDirectory * free_SangerProjectDirectory(SangerProjectDirectory * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Sanger Project obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; closedir(obj->dir); if( obj->extension != NULL ) { free(obj->extension); } free(obj); return NULL; } %} wise-2.4.1/src/dnaindex/make_shotgun.c0000644000175000001440000000041607667356503017304 0ustar philippusers#include "shotgun.h" int main(int argc,char ** argv) { Sequence * input; ShotgunPara p; p.read_length = 500; p.insert_size = 200; p.number = 4000; p.forward_only = 1; input = read_fasta_Sequence(stdin); generate_shotgun_reads(&p,input,stdout); } wise-2.4.1/src/dnaindex/kmer_assembly_contig.dy0000644000175000001440000001520607742733021021201 0ustar philippusers %{ #include "kmer_assembly.h" #include "assembly.h" #define KmerAssemblyContigSetLISTLENGTH 256 %} friend KmerAssemblyContig struct KmerAssemblyContig KmerAssemblyNode * start !link KmerAssemblyNode * end !link int len; boolean clean_start boolean clean_end int max_depth KmerAssemblyContig * mirror int is_mirror !def="0" struct KmerAssemblyContigSet KmerAssemblyContig ** contig !list KmerAssemblyIndex * kai !link struct KmerAssemblyContigPara int minimum_len !def="50" int minimum_depth !def="1" %{ #include "kmer_assembly_contig.h" KmerAssemblyContig * find_strict_mirrored_KmerAssemblyContig(KmerAssemblyContigSet * kcs,KmerAssemblyContig * c) { int i; kmer_t start_rev; kmer_t end_rev; assert(kcs != NULL); assert(kcs->kai != NULL); assert(c != NULL); start_rev = reverse_complement_dna_number(c->start->number,kcs->kai->kii->kmer_size); end_rev = reverse_complement_dna_number(c->end->number,kcs->kai->kii->kmer_size); for(i=0;i < kcs->len;i++) { if( kcs->contig[i]->mirror != NULL || kcs->contig[i]->is_mirror == 1) { continue; } /* fprintf(stderr,"Looking at %ld,%ld vs %ld,%ld\n",kcs->contig[i]->start->number,start_rev,kcs->contig[i]->end->number,end_rev);*/ if( kcs->contig[i]->start->number == end_rev && kcs->contig[i]->end->number == start_rev ) { /* should check labels */ warn("Note to Ewan: Should check labels"); return kcs->contig[i]; } } return NULL; } KmerAssemblyContigSet * KmerAssemblyContigSet_from_KmerAssemblyIndex(KmerAssemblyIndex * kai) { KmerAssemblyContigSet * out; KmerAssemblyContigSet * final; kmer_t kmer; KmerAssemblyNode * node; KmerAssemblyContig * contig; boolean is_left_end; int i; assert(kai != NULL); assert(kai->kii != NULL ); assert(kai->kii->next_filled_kmer != NULL); out = KmerAssemblyContigSet_alloc_std(); out->kai = kai; kmer = -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); fprintf(stderr,"CONTIG BUILD\n"); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); for(;node != NULL; node = node->node_chain ) { if( node->next_len == 0 ) { continue; } /* test to see if it is start; no back link or all TANGLED links */ is_left_end = 0; if( node->prev_len == 0 ) { is_left_end = 1; /* this is the other main case, test before we do loop */ } else if( node->prev_len == 1 && !(node->prev[0]->state & KMER_ASSEMBLY_PREV_TANGLED) ) { is_left_end = 0; } else { for(i=0;iprev_len;i++) { fprintf(stderr,"Node position %d, state %d\n",i,node->prev[i]->state); if( !(node->prev[i]->state & KMER_ASSEMBLY_NEXT_TANGLED) ) { is_left_end = 0; break; } } if( i >= node->prev_len ) { is_left_end = 1; } } if( is_left_end == 0 && node->prev_len > 1 ) { fprintf(stderr,"Very weird: multi-prev but not left end, number is %d, state of 0 %d\n",node->prev_len,node->prev[0]->state); } if( is_left_end && node->next_len == 1) { contig = new_KmerAssemblyContig(node); add_KmerAssemblyContigSet(out,contig); } } } return out; } KmerAssemblyContig * new_KmerAssemblyContig(KmerAssemblyNode * node) { KmerAssemblyContig * out; KmerAssemblyLink * link; int len; assert(node != NULL); if( node->next_len != 1 ) { warn("Cannot build a KmerAssemblyContig from a node with %d out going links",node->next_len); } out = KmerAssemblyContig_alloc(); out->start = node; out->max_depth = 0; if( node->prev_len > 1 ) { out->clean_start = 0; } else { out->clean_start = 1; } len = 0; for(link = node->next[0];link != NULL && link->next->next_len == 1; link = link->next->next[0],len++) { if( link->state & KMER_ASSEMBLY_PREV_TANGLED ) { break; } if( link->prev->prev_len > 1 ) { fprintf(stderr,"Assembly is still tangled!"); break; /* bad end found */ } if( link->sequence_label_len > out->max_depth ) { out->max_depth = link->sequence_label_len; } } out->end = link->next; if( link->next->next_len != 0 ) { out->clean_end = 0; } else { out->clean_end = 1; } out->len = len; return out; } Assembly * Assembly_from_KmerAssemblyIndex(KmerAssemblyIndex * kai,KmerAssemblyContigPara * p) { Assembly * out; KmerAssemblyContigSet * kacs; KmerAssemblyContigSet * final; KmerAssemblyContig * mirror; int i; kacs = KmerAssemblyContigSet_from_KmerAssemblyIndex(kai); final = KmerAssemblyContigSet_alloc_std(); for(i=0;ilen;i++) { if( kacs->contig[i]->is_mirror == 1 ) { continue; } if( kacs->contig[i]->mirror == NULL ) { if( (mirror = find_strict_mirrored_KmerAssemblyContig(kacs,kacs->contig[i])) != NULL ) { kacs->contig[i]->mirror = hard_link_KmerAssemblyContig(mirror); mirror->is_mirror = 1; add_KmerAssemblyContigSet(final,hard_link_KmerAssemblyContig(kacs->contig[i])); } else { warn("Unable to mirror contig, adding anyway"); add_KmerAssemblyContigSet(final,hard_link_KmerAssemblyContig(kacs->contig[i])); } } } out = Assembly_from_KmerAssemblyContigSet(final,p); free_KmerAssemblyContigSet(kacs); free_KmerAssemblyContigSet(final); return out; } Assembly * Assembly_from_KmerAssemblyContigSet(KmerAssemblyContigSet * kacs,KmerAssemblyContigPara * p) { Assembly * out; AssemblyContig * ac; int i; assert(kacs != NULL); assert(p != NULL); out = Assembly_alloc_std(); for(i=0;ilen;i++) { if( kacs->contig[i]->len > p->minimum_len && kacs->contig[i]->max_depth >= p->minimum_depth ) { ac = AssemblyContig_from_KmerAssemblyContig(kacs->contig[i]); add_Assembly(out,ac); } } return out; } AssemblyContig * AssemblyContig_from_KmerAssemblyContig(KmerAssemblyContig * kac) { AssemblyContig * out; KmerAssemblyLink * link; Sequence * con; int i; char buffer[512]; con = Sequence_alloc(); con->seq = calloc(kac->len+1,sizeof(char)); con->len = kac->len; con->maxlen = con->len; sprintf(buffer,"contig_%ld",(long int)kac); con->name = stringalloc(buffer); out = AssemblyContig_alloc_std(); fprintf(stderr,"Starting contig fetching...\n"); for(i=0,link = kac->start->next[0] ;link != NULL && link->next->next_len == 1;link = link->next->next[0],i++) { con->seq[i] = link->base; /* NOT DEALING WITH READ PLACEMENT YET */ if( link->next == kac->end ) { break; } } out->clean_start = kac->clean_start; out->clean_end = kac->clean_end; out->max_depth = kac->max_depth; con->seq[i] = '\0'; con->len = strlen(con->seq); out->consensus = con; return out; } %} wise-2.4.1/src/dnaindex/test_dnanumber.c0000644000175000001440000000117407637404143017623 0ustar philippusers#include "dnanumber.h" int main(int argc,char ** argv) { /* char * forward = "GATTGTATTGT"; char * backward = "ACAATACAATC"; */ char * forward = "AGATTGTATTGT"; char * backward = "GGTTGCAATACAATC"; DnaNumber for_n; DnaNumber back_n; for_n = dna_number_from_string(forward,11); back_n = dna_number_from_string(backward,11); printf("Got %s with %d (%d) %c\n",forward,for_n.number,for_n.flipped,first_char_from_dnanumber(for_n.number,11,for_n.flipped)); printf("Got %s with %d (%d) %c\n",backward,back_n.number,back_n.flipped,first_char_from_dnanumber(back_n.number,11,back_n.flipped)); } wise-2.4.1/src/dnaindex/compressed_protein_index.c0000644000175000001440000002773110670453716021714 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "compressed_protein_index.h" # line 39 "compressed_protein_index.dy" SeqLookupResultStruct * get_next_CompressedProteinClient(void * data,SeqLookupResultStruct * prev) { CompressedProteinClient * cl = (CompressedProteinClient *)data; /* fprintf(stdout," entering with point %d max %d\n",cl->point,cl->current); */ if( prev == NULL ) { assert(cl->point == 0); } else { assert(&(cl->res[cl->point-1]) == prev); } if( cl->point == cl->current ) { return NULL; } else { return &cl->res[cl->point++]; } } # line 61 "compressed_protein_index.dy" boolean is_more_CompressedProteinClient(void * data) { CompressedProteinClient * cl = (CompressedProteinClient *)data; if( cl->point < cl->current ) { return TRUE; } else { return FALSE; } } # line 73 "compressed_protein_index.dy" void free_SeqLookupResultInterface_CompressedProteinClient(void * data) { /* no op*/ return; } # line 80 "compressed_protein_index.dy" SeqLookupResultInterface * lookup_CompressedProteinClient(void * data,int seq_number) { CompressedProteinClient * cl = (CompressedProteinClient *)data; int i; CompressedProteinHead * h; SeqLookupResultInterface * out; SinglePosSequence * pos; int len; out = SeqLookupResultInterface_alloc(); h = (CompressedProteinHead*)(*cl->index->kii->retrieve_by_kmer)(cl->index->kii->handle,(kmer_t)seq_number); if( h == NULL ) { cl->current = 0; cl->point = 0; } else { for(i=0;imaxlen;i++) { if( h->positions[i] == -1 ) { break; } } assert(i < h->maxlen); len = i; if( cl->maxlen < len ) { cl->maxlen = cl->maxlen * 2; cl->res = realloc(cl->res,sizeof(SeqLookupResultStruct)*cl->maxlen); } for(i=0;iindex->sps,h->positions[i]); cl->res[i].seq = (Sequence*)pos->data; cl->res[i].pos = (int)(h->positions[i] - pos->start); } cl->current = len; cl->point = 0; } out->data = cl; out->next = get_next_CompressedProteinClient; out->is_more = is_more_CompressedProteinClient; out->free_data = free_SeqLookupResultInterface_CompressedProteinClient; return out; } # line 125 "compressed_protein_index.dy" boolean is_populated_CompressedProteinClient(void * data,int seq_number) { CompressedProteinHead * h; CompressedProteinClient * cl = (CompressedProteinClient *)data; h = (CompressedProteinHead*)(*cl->index->kii->retrieve_by_kmer)(cl->index->kii->handle,(kmer_t)seq_number); if( h == NULL ) { return FALSE; } else { return TRUE; } } # line 140 "compressed_protein_index.dy" void free_Client_CompressedProteinClient(void * data) { CompressedProteinClient * cl = (CompressedProteinClient *)data; free(cl->res); free_CompressedProteinClient(cl); } # line 149 "compressed_protein_index.dy" SeqLookupInterface * new_direct_CompressedProteinLookup(void) { KmerIndexInterface * kii; kii = new_KmerDirectIndex(12); return new_CompressedProteinLookup(kii); } # line 159 "compressed_protein_index.dy" SeqLookupInterface * new_CompressedProteinLookup(KmerIndexInterface * kii) { CompressedProteinIndex * cpi; SeqLookupInterface * out; out = SeqLookupInterface_alloc_std(); cpi = CompressedProteinIndex_alloc(); cpi->kii = kii; cpi->sps = new_SinglePosSpace(1,1000); out->data = (void*)cpi; out->get_client = get_client_CompressedProteinIndex; out->add_seq = add_seq_CompressedProteinIndex; out->lookup_array_head = NULL; out->add_direct_number = add_direct_number_CompressedProteinIndex; out->free_data = free_data_CompressedProteinIndex; return out; } # line 183 "compressed_protein_index.dy" SeqLookupClientInterface * get_client_CompressedProteinIndex(void * data) { SeqLookupClientInterface * out; CompressedProteinClient * cl; cl = new_CompressedProteinClient(); out = SeqLookupClientInterface_alloc(); cl->index = (CompressedProteinIndex*)data; assert(cl->index != NULL); out->data = (void*)cl; out->lookup = lookup_CompressedProteinClient; out->is_populated = is_populated_CompressedProteinClient; out->free_data = free_Client_CompressedProteinClient; return out; } # line 205 "compressed_protein_index.dy" CompressedProteinClient * new_CompressedProteinClient(void) { CompressedProteinClient * out; out = CompressedProteinClient_alloc(); out->res = calloc(COMPRESSED_PROTEIN_CLIENT_INITIAL,sizeof(SeqLookupResultStruct)); out->current = 0; out->maxlen = COMPRESSED_PROTEIN_CLIENT_INITIAL; return out; } # line 219 "compressed_protein_index.dy" boolean add_direct_number_CompressedProteinIndex(void * data,int seq_number,Sequence * target, int pos) { fatal("For compressed protein indexes, impossible to add numbers directly"); return NULL; } # line 226 "compressed_protein_index.dy" ArraySeqHead * lookup_array_head_CompressedProteinIndex(void * data,int seq_number) { fatal("For compressed protein indexes, arrayseqhead lookup is not feasible"); return NULL; } # line 234 "compressed_protein_index.dy" boolean add_seq_CompressedProteinIndex(void * data,Sequence * seq,SeqLookupLoadPara * para) { long int offset; int no; int i; void * kmer_data; CompressedProteinHead * h; CompressedProteinIndex * cpi = (CompressedProteinIndex *) data; assert(cpi != NULL); assert(seq != NULL); offset = add_Sequence_SinglePosSpace(cpi->sps,(long int)seq->len,(void *) seq); for(i=0;ilen-5;) { no = seq_number_aa_5mer(seq->seq+i); if( (kmer_data = (*cpi->kii->retrieve_by_kmer)(cpi->kii->handle,(kmer_t)no)) == NULL ) { h = new_CompressedProteinHead(); (*cpi->kii->insert_by_kmer)(cpi->kii->handle,(kmer_t)no,(void*)h); } else { h = (CompressedProteinHead*) kmer_data; } add_pos_CompressedProteinHead(h,(int)offset+i); i += para->tile_freq; } return TRUE; } # line 264 "compressed_protein_index.dy" void free_data_CompressedProteinIndex(void * d) { CompressedProteinIndex * cpi = (CompressedProteinIndex *)d; assert(cpi != NULL); free_CompressedProteinIndex(cpi); } # line 275 "compressed_protein_index.dy" boolean add_pos_CompressedProteinHead(CompressedProteinHead * c,int pos) { int i; assert(c != NULL); for(i=0;imaxlen;i++) { if( c->positions[i] == -1 ) { break; } } assert(i < c->maxlen); if( i+2 == c->maxlen ) { c->maxlen += COMPRESSED_EXPAND; c->positions = realloc(c->positions,sizeof(int)*c->maxlen); } c->positions[i] = pos; c->positions[i+1] = -1; return TRUE; } # line 300 "compressed_protein_index.dy" CompressedProteinHead * new_CompressedProteinHead(void) { CompressedProteinHead * out; out = malloc(sizeof(CompressedProteinHead)); assert(out != NULL); out->maxlen = COMPRESSED_INITIAL_SIZE; out->positions = malloc(sizeof(int)*out->maxlen); out->positions[0] = -1; return out; } # line 298 "compressed_protein_index.c" /* Function: hard_link_CompressedProteinIndex(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CompressedProteinIndex *] * * Return [UNKN ] Undocumented return value [CompressedProteinIndex *] * */ CompressedProteinIndex * hard_link_CompressedProteinIndex(CompressedProteinIndex * obj) { if( obj == NULL ) { warn("Trying to hard link to a CompressedProteinIndex object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CompressedProteinIndex_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CompressedProteinIndex *] * */ CompressedProteinIndex * CompressedProteinIndex_alloc(void) { CompressedProteinIndex * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CompressedProteinIndex *) ckalloc (sizeof(CompressedProteinIndex))) == NULL) { warn("CompressedProteinIndex_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->kii = NULL; out->sps = NULL; return out; } /* Function: free_CompressedProteinIndex(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CompressedProteinIndex *] * * Return [UNKN ] Undocumented return value [CompressedProteinIndex *] * */ CompressedProteinIndex * free_CompressedProteinIndex(CompressedProteinIndex * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CompressedProteinIndex obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->kii != NULL) free_KmerIndexInterface(obj->kii); if( obj->sps != NULL) free_SinglePosSpace(obj->sps); ckfree(obj); return NULL; } /* Function: hard_link_CompressedProteinClient(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CompressedProteinClient *] * * Return [UNKN ] Undocumented return value [CompressedProteinClient *] * */ CompressedProteinClient * hard_link_CompressedProteinClient(CompressedProteinClient * obj) { if( obj == NULL ) { warn("Trying to hard link to a CompressedProteinClient object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CompressedProteinClient_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CompressedProteinClient *] * */ CompressedProteinClient * CompressedProteinClient_alloc(void) { CompressedProteinClient * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CompressedProteinClient *) ckalloc (sizeof(CompressedProteinClient))) == NULL) { warn("CompressedProteinClient_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->maxlen = 0; out->current = 0; out->point = 0; return out; } /* Function: free_CompressedProteinClient(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CompressedProteinClient *] * * Return [UNKN ] Undocumented return value [CompressedProteinClient *] * */ CompressedProteinClient * free_CompressedProteinClient(CompressedProteinClient * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CompressedProteinClient obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->res is linked in */ /* obj->index is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/compressed_protein_index.h0000644000175000001440000001653110670453716021715 0ustar philippusers#ifndef DYNAMITEcompressed_protein_indexHEADERFILE #define DYNAMITEcompressed_protein_indexHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "seqlookup.h" #include "kmer_index_interface.h" #include "kmer_direct.h" #include "singleseqspace.h" typedef struct CompressedProteinHead { int * positions; int maxlen; } CompressedProteinHead; #define COMPRESSED_INITIAL_SIZE 50 #define COMPRESSED_EXPAND 50 #define COMPRESSED_PROTEIN_CLIENT_INITIAL 16 struct Wise2_CompressedProteinIndex { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif KmerIndexInterface * kii; SinglePosSpace * sps; } ; /* CompressedProteinIndex defined */ #ifndef DYNAMITE_DEFINED_CompressedProteinIndex typedef struct Wise2_CompressedProteinIndex Wise2_CompressedProteinIndex; #define CompressedProteinIndex Wise2_CompressedProteinIndex #define DYNAMITE_DEFINED_CompressedProteinIndex #endif struct Wise2_CompressedProteinClient { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeqLookupResultStruct * res; /* actually we'll free this on demand */ int maxlen; int current; int point; CompressedProteinIndex * index; } ; /* CompressedProteinClient defined */ #ifndef DYNAMITE_DEFINED_CompressedProteinClient typedef struct Wise2_CompressedProteinClient Wise2_CompressedProteinClient; #define CompressedProteinClient Wise2_CompressedProteinClient #define DYNAMITE_DEFINED_CompressedProteinClient #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_CompressedProteinIndex(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CompressedProteinIndex *] * * Return [UNKN ] Undocumented return value [CompressedProteinIndex *] * */ CompressedProteinIndex * Wise2_hard_link_CompressedProteinIndex(CompressedProteinIndex * obj); #define hard_link_CompressedProteinIndex Wise2_hard_link_CompressedProteinIndex /* Function: CompressedProteinIndex_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CompressedProteinIndex *] * */ CompressedProteinIndex * Wise2_CompressedProteinIndex_alloc(void); #define CompressedProteinIndex_alloc Wise2_CompressedProteinIndex_alloc /* Function: free_CompressedProteinIndex(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CompressedProteinIndex *] * * Return [UNKN ] Undocumented return value [CompressedProteinIndex *] * */ CompressedProteinIndex * Wise2_free_CompressedProteinIndex(CompressedProteinIndex * obj); #define free_CompressedProteinIndex Wise2_free_CompressedProteinIndex /* Function: hard_link_CompressedProteinClient(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CompressedProteinClient *] * * Return [UNKN ] Undocumented return value [CompressedProteinClient *] * */ CompressedProteinClient * Wise2_hard_link_CompressedProteinClient(CompressedProteinClient * obj); #define hard_link_CompressedProteinClient Wise2_hard_link_CompressedProteinClient /* Function: CompressedProteinClient_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CompressedProteinClient *] * */ CompressedProteinClient * Wise2_CompressedProteinClient_alloc(void); #define CompressedProteinClient_alloc Wise2_CompressedProteinClient_alloc /* Function: free_CompressedProteinClient(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CompressedProteinClient *] * * Return [UNKN ] Undocumented return value [CompressedProteinClient *] * */ CompressedProteinClient * Wise2_free_CompressedProteinClient(CompressedProteinClient * obj); #define free_CompressedProteinClient Wise2_free_CompressedProteinClient /* Unplaced functions */ /* There has been no indication of the use of these functions */ SeqLookupResultStruct * Wise2_get_next_CompressedProteinClient(void * data,SeqLookupResultStruct * prev); #define get_next_CompressedProteinClient Wise2_get_next_CompressedProteinClient boolean Wise2_is_more_CompressedProteinClient(void * data); #define is_more_CompressedProteinClient Wise2_is_more_CompressedProteinClient void Wise2_free_SeqLookupResultInterface_CompressedProteinClient(void * data); #define free_SeqLookupResultInterface_CompressedProteinClient Wise2_free_SeqLookupResultInterface_CompressedProteinClient SeqLookupResultInterface * Wise2_lookup_CompressedProteinClient(void * data,int seq_number); #define lookup_CompressedProteinClient Wise2_lookup_CompressedProteinClient boolean Wise2_is_populated_CompressedProteinClient(void * data,int seq_number); #define is_populated_CompressedProteinClient Wise2_is_populated_CompressedProteinClient void Wise2_free_Client_CompressedProteinClient(void * data); #define free_Client_CompressedProteinClient Wise2_free_Client_CompressedProteinClient SeqLookupInterface * Wise2_new_direct_CompressedProteinLookup(void); #define new_direct_CompressedProteinLookup Wise2_new_direct_CompressedProteinLookup SeqLookupInterface * Wise2_new_CompressedProteinLookup(KmerIndexInterface * kii); #define new_CompressedProteinLookup Wise2_new_CompressedProteinLookup SeqLookupClientInterface * Wise2_get_client_CompressedProteinIndex(void * data); #define get_client_CompressedProteinIndex Wise2_get_client_CompressedProteinIndex CompressedProteinClient * Wise2_new_CompressedProteinClient(void) ; #define new_CompressedProteinClient Wise2_new_CompressedProteinClient boolean Wise2_add_direct_number_CompressedProteinIndex(void * data,int seq_number,Sequence * target, int pos) ; #define add_direct_number_CompressedProteinIndex Wise2_add_direct_number_CompressedProteinIndex ArraySeqHead * Wise2_lookup_array_head_CompressedProteinIndex(void * data,int seq_number); #define lookup_array_head_CompressedProteinIndex Wise2_lookup_array_head_CompressedProteinIndex boolean Wise2_add_seq_CompressedProteinIndex(void * data,Sequence * seq,SeqLookupLoadPara * para); #define add_seq_CompressedProteinIndex Wise2_add_seq_CompressedProteinIndex void Wise2_free_data_CompressedProteinIndex(void * d); #define free_data_CompressedProteinIndex Wise2_free_data_CompressedProteinIndex boolean Wise2_add_pos_CompressedProteinHead(CompressedProteinHead * c,int pos); #define add_pos_CompressedProteinHead Wise2_add_pos_CompressedProteinHead CompressedProteinHead * Wise2_new_CompressedProteinHead(void); #define new_CompressedProteinHead Wise2_new_CompressedProteinHead /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/comparapath.dy0000644000175000001440000004510507730362752017307 0ustar philippusers %{ #include "sequence.h" #include "largeseqreader.h" #include "singleseqspace.h" #include "dnamapping.h" #include "kmer_index_interface.h" #include "kmer_direct.h" #include "hsp.h" #define COMPARALINK_START 8 #define COMPARALINK_LINEAR 256 #define COMPARA_NOTHING 0 #define COMPARA_QUERY_UNIQUE 1 #define COMPARA_QUERY_MULTIPLE 2 #define COMPARA_TARGET_UNIQUE 4 #define COMPARA_TARGET_MULTIPLE 8 #define COMPARA_SPLINE_FLIPPED 16 #define COMPARA_IS_REPEATED 32 #define COMPARA_IS_JOINT_FORWARD(a) is_joint_forward(a) #define COMPARA_IS_JOINT_REVERSE(a) is_joint_reverse(a) #define COMPARA_IS_JOINT_FORWARD_MACRO(a) (((a->state&COMPARA_QUERY_UNIQUE) && (a->state&COMPARA_TARGET_UNIQUE) && a->spline != NULL) ? 1 : 0) #define COMPARA_IS_JOINT_REVERSE_MACRO(a) (((a->spline != NULL) && (((a->spline->state & COMPARA_QUERY_UNIQUE) && (a->state & COMPARA_TARGET_UNIQUE)) || ((a->spline->state & COMPARA_TARGET_UNIQUE) && (a->state & COMPARA_QUERY_UNIQUE)))) ? 1 : 0) typedef struct ComparaHead { struct ComparaHead * next_query; long int position[2]; struct ComparaHead * spline; long int number; char size; char state; } ComparaHead; typedef struct ComparaLinkStart { ComparaHead * start; Sequence * seq; } ComparaLinkStart; typedef struct ComparaHeadBlockAllocator { ComparaHead ** block; int current_block; int current_unit; int unit_length; int block_length; } ComparaHeadBlockAllocator; #define COMPARAHEAD_BA_BLOCK_LENGTH 10000 #define COMPARAHEAD_BA_UNIT_LENGTH 10000 typedef struct ComparaIndex { KmerIndexInterface * kii; ComparaLinkStart ** linkstart; int current_link; int link_len; SinglePosSpace * sps; ComparaHeadBlockAllocator * blockalloc; } ComparaIndex; #define COMPARAINDEX_LINK_START 16 #define COMPARAINDEX_LINK_LINEAR 256 #define ComparaLinkStartSetLISTLENGTH 256 #define SetofHSPsetLISTLENGTH 256 %} struct ComparaLinkStartSet ComparaLinkStart ** cls !list struct SetofHSPset HSPset ** hspset !list %{ #include "comparapath.h" ComparaLinkStart * free_ComparaLinkStart(ComparaLinkStart * cls) { free(cls); return NULL; } void show_SetofHSPset(SetofHSPset * set,FILE * ofp) { int i; for(i=0;ilen;i++) { show_HSPset(set->hspset[i],ofp); } } SetofHSPset * SetofHSPset_from_ComparaIndex(ComparaIndex * ci,ComparaLinkStartSet * clss,FILE * logfp) { int i; HSPset * hsp; SetofHSPset * out; assert(ci != NULL); assert(clss != NULL); out = SetofHSPset_alloc_std(); for(i=0;ilen;i++) { if( clss->cls[i]->start != NULL ) { fprintf(logfp,"Considering sequence %s\n",clss->cls[i]->seq->name); fflush(logfp); hsp = HSPset_from_ComparaIndex(ci,clss->cls[i],logfp); add_SetofHSPset(out,hsp); } } return out; } HSPset * HSPset_from_ComparaIndex(ComparaIndex * ci,ComparaLinkStart * cls,FILE * logfp) { HSPset * out; HSP * hsp; ComparaHead * current; long int target_pos; ComparaHead * current_head; ComparaHead * prev = NULL; SinglePosSequence * query = NULL; SinglePosSequence * target = NULL; long int start_pos; long int next_report_post; long int last_pos; long int unplaced = 0; out = HSPset_alloc_std(); query = lookup_Sequence_SinglePosSpace(ci->sps,cls->start->position[0]); start_pos = cls->start->position[0]; next_report_post = start_pos; for(current = cls->start;current != NULL;) { if( current->next_query == current ) { fprintf(logfp,"Impossible; loop in next_query list, causing massive problems. have to abort"); fflush(logfp); fatal("loop in next query, cannot contiue"); } last_pos = current->position[0]; current_head = current; if( current_head == prev || (prev != NULL && current_head->position[0] == prev->position[0]) ) { fprintf(logfp,"Dangerous case of unmoving loop; artificalling moving on from position %ld\n",current->position[0]); fflush(logfp); current = current->next_query; current_head = current; if( current == NULL ) { break; } } prev = current; if( current->position[0] >= next_report_post ) { fprintf(logfp,"Seen %ld unplaced vs %ld positions\n",unplaced,current->position[0] - start_pos); fprintf(logfp,"Considering positions %ld,%ld with size %d and spline %ld, (current %ld, prev %ld next %ld)\n",current->position[0],current->position[1],current->size,current->spline,current,prev,current->next_query); next_report_post += 10000000; } if( COMPARA_IS_JOINT_FORWARD(current_head) ) { /* fprintf(logfp,"Found forward, with state %d (len %d)\n",current_head->state,current_head->size); fflush(logfp); */ target_pos = current_head->position[1]; if( target == NULL || target->end > target_pos || target->start < target_pos ) { target = lookup_Sequence_SinglePosSpace(ci->sps,target_pos); } assert(target); assert(target->data); /* fprintf(logfp," ...forward is %s %ld\n",((Sequence*)target->data)->name,target_pos - target->start); fflush(logfp); */ hsp = new_dna_identical_HSP((Sequence*)query->data,(Sequence*)target->data,current->position[0] - query->start,target_pos - target->start,0); add_HSPset(out,hsp); for(;current != NULL && (current->position[0] - query->start) < hsp->query_start + hsp->length;current = current->next_query) ; } else if ( COMPARA_IS_JOINT_REVERSE(current_head) ) { /* fprintf(logfp,"Found reverse, with state %d (len %d)\n",current_head->state,current_head->size); fflush(logfp); */ target_pos = current_head->spline->position[0]; if( target == NULL || target->end > target_pos || target->start < target_pos ) { target = lookup_Sequence_SinglePosSpace(ci->sps,target_pos); } /* fprintf(logfp," ...reverse is %s %ld\n",((Sequence *)target->data)->name,target_pos - target->start); fflush(logfp); */ hsp = new_dna_identical_HSP((Sequence*)query->data,(Sequence*)target->data,current->position[0] - query->start,target_pos - target->start + ci->kii->kmer_size -1,1); add_HSPset(out,hsp); for(;current != NULL && (current->position[0] - query->start) < hsp->query_start + hsp->length;current = current->next_query) ; } else { unplaced++; current = current->next_query; } } fprintf(logfp,"PLACED %s %ld unplaced positions vs %ld considered\n",cls->seq->name,unplaced,last_pos - start_pos); fflush(logfp); return out; } boolean is_joint_forward(ComparaHead * h) { if( h->spline != NULL ) { return 0; } if( (h->state & COMPARA_QUERY_UNIQUE) && (h->state & COMPARA_TARGET_UNIQUE) ) { return 1; } return 0; } boolean is_joint_reverse(ComparaHead * h) { if( h->spline == NULL ) { return 0; } if( (h->state & COMPARA_QUERY_UNIQUE) && (h->spline->state & COMPARA_TARGET_UNIQUE) && !(h->spline->state & COMPARA_QUERY_UNIQUE) && !(h->spline->state & COMPARA_QUERY_MULTIPLE) ) { return 1; } /* if( (h->spline->state & COMPARA_QUERY_UNIQUE) && (h->state & COMPARA_TARGET_UNIQUE) && !(h->spline->state & COMPARA_TARGET_UNIQUE) && !(h->spline->state & COMPARA_TARGET_MULTIPLE) ) { return 1; } */ return 0; } void show_distrib_ComparaIndex(ComparaIndex * ci,ComparaLinkStart * cls,FILE * ofp) { long len = 0; int count[4]; int i; ComparaHead * current; ComparaHead * chead; for(i=0;i<4;i++) { count[i] =0; } for(current = cls->start;current != NULL;current = current->next_query) { chead = current; if( chead == NULL ) { continue; } count[(int)chead->size]++; len++; } fprintf(ofp,"Seen %ld links...\n",len); for(i=0;i<3;i++) { fprintf(ofp,"%5d %d\n",i,count[i]); } } void show_stats_ComparaIndex(ComparaIndex * ci,ComparaLinkStart * cls,FILE * ofp) { int i; int t_unique = 0; int q_unique = 0; int joint = 0; int rev_joint =0; int t_multiple = 0; int q_multiple = 0; ComparaHead *chead; ComparaHead * current; for(current = cls->start;current != NULL;current = current->next_query) { i = current->number; chead = current; if( chead == NULL ) { continue; } if( chead->state & COMPARA_TARGET_UNIQUE ) t_unique++; if( chead->state & COMPARA_QUERY_UNIQUE ) q_unique++; if( (chead->state & COMPARA_TARGET_UNIQUE) && (chead->state & COMPARA_QUERY_UNIQUE) ) joint++; if( chead->spline != NULL ) { /* currently only put in if spline is unique */ if( ((chead->state & COMPARA_TARGET_UNIQUE) && (chead->spline->state & COMPARA_QUERY_UNIQUE)) || ((chead->state & COMPARA_QUERY_UNIQUE) && (chead->spline->state & COMPARA_TARGET_UNIQUE)) ) rev_joint++; } if( chead->state & COMPARA_TARGET_MULTIPLE ) t_multiple++; if( chead->state & COMPARA_QUERY_MULTIPLE ) q_multiple++; } fprintf(ofp,"Target %d unique positions, %d (rev: %d) shared (%.2f %%)\n",t_unique,joint,rev_joint,((joint+rev_joint)*100.0)/(t_unique*1.0)); fprintf(ofp,"Query %d unique positions, %d (rev: %d) shared (%.2f %%)\n",q_unique,joint,rev_joint,((joint+rev_joint)*100.0)/(q_unique*1.0)); } long int insert_revcom_Splines_in_set(ComparaIndex * ci,ComparaLinkStartSet * clss,FILE * logfp) { int i; long int out = 0; for(i=0;ilen;i++) { if( clss->cls[i]->start != NULL ) { out += insert_revcom_Splines(ci,clss->cls[i],logfp); } } return out; } long int insert_revcom_Splines(ComparaIndex * ci,ComparaLinkStart * cls,FILE * logfp) { long int total = 0; kmer_t rev; ComparaHead *chead; ComparaHead * revhead; ComparaHead * current; long int count = 0; for(current = cls->start ; current != NULL ; current = current->next_query) { chead = current; if( chead == NULL ) { continue; } if( count % 1000000 == 0 ) { fprintf(logfp,"Splines for %s, considered %ld positions\n",cls->seq->name,count); fflush(logfp); } count++; rev = reverse_complement_dna_number(current->number,ci->kii->kmer_size); revhead = (ComparaHead*) (*ci->kii->retrieve_by_kmer)(ci->kii->handle,rev); if( revhead == NULL ) { continue; } /* reverse_map_dna_number(current->number,ci->kii->kmer_size,forward); reverse_map_dna_number(rev,ci->kii->kmer_size,reverse); forward[ci->kii->kmer_size] = reverse[ci->kii->kmer_size] = '\0'; fprintf(stderr,"Inserting spline at %ld with %s vs %s\n",current->position,forward,reverse); */ chead->spline = revhead; revhead->spline = chead; total++; } return total; } ComparaLinkStartSet * add_Sequence_stream_ComparaIndex(ComparaIndex * ci,FILE * ifp,boolean is_target,int lognumber,int test_rev,FILE * logfp,char * tag) { Sequence * input; ComparaLinkStartSet * clss; ComparaLinkStart * cls; char buffer[512]; /** 101001010100101010010 1001101 */ int skip_query[] = {1,0,1,0,0,1,0}; int skip_target[] = {1,0,0,1,1,0,1}; clss = ComparaLinkStartSet_alloc_std(); while( (input = read_large_dna_Sequence(ifp,lognumber,logfp)) != NULL ) { if( tag != NULL ) { sprintf(buffer,"%s_%s",tag,input->name); free(input->name); input->name = stringalloc(buffer); } if( is_target ) { cls = add_Sequence_ComparaIndex(ci,input,is_target,lognumber,0,7,skip_target,test_rev,logfp); } else { cls = add_Sequence_ComparaIndex(ci,input,is_target,lognumber,0,7,skip_query,test_rev,logfp); } add_ComparaLinkStartSet(clss,cls); } return clss; } ComparaLinkStart * add_Sequence_ComparaIndex(ComparaIndex * ci,Sequence * seq,boolean is_target,int lognumber,long truncate,int skipsize,int * skipflag,int test_rev,FILE * logfp) { int i; ComparaLinkStart * cls; long int pos_start; kmer_t number; ComparaHead * prev = NULL; ComparaHead *chead; int j; int s; char base; kmer_t rev_number; ComparaHead * revhead; char * base_numbers; long int base_nos[100]; int k; kmer_t skipped = 0; kmer_t repeated = 0; kmer_t seen_repeats = 0; assert(ci != NULL); assert(seq != NULL); assert(ci != NULL); assert(ci->kii != NULL); s = 1; for(i=0;ikii->kmer_size;i++) { base_nos[i] = s; s = s*4; } cls= new_ComparaLinkStart(seq); cls->start = NULL; pos_start = add_Sequence_SinglePosSpace(ci->sps,seq->len,(void*)seq); fprintf(logfp,"Loading position starting at %ld\n",pos_start); base_numbers = map_to_basepair_numbers(seq->seq,seq->len); for(i=0;ilen - ci->kii->kmer_size;) { for(s=0;slen - ci->kii->kmer_size;s++,i++) { if( lognumber != 0 && i % lognumber == 0 ) { fprintf(logfp,"Loading position %d (%ld skipped, %ld repeated, %ld repeats) from %s\n",i,skipped,repeated,seen_repeats,seq->name); fflush(logfp); } if( skipsize > 1 ) { if( skipflag[s] == 0 ) { continue; } } if( truncate != 0 && i > truncate ) { break; } for(j=0;jkii->kmer_size;j++) { /* if( seq->seq[i+j] == 'N' || islower(seq->seq[i+j]) ) {*/ base = base_from_char(toupper(seq->seq[i+j])); if( base >= 4 ) { break; } } if( j < ci->kii->kmer_size ) { skipped++; continue; } /* number = forward_dna_number_from_string(seq->seq+i,ci->kii->kmer_size); */ number = 0; for(k=0;kkii->kmer_size;k++) { number = number + (base_numbers[i+k]*base_nos[k]); } if( number < 0 ) { fprintf(logfp,"Yikes. Got bad number %ld at position %d, %.*s\n",number,i,ci->kii->kmer_size,seq->seq+i); } assert(number>= 0); chead = (ComparaHead*) (*ci->kii->retrieve_by_kmer)(ci->kii->handle,number); if( chead == NULL && is_target == 1 && test_rev == 1 ) { /* have to test reverse strand, otherwise pointless to put in */ rev_number = reverse_complement_dna_number(number,ci->kii->kmer_size); revhead = (ComparaHead*) (*ci->kii->retrieve_by_kmer)(ci->kii->handle,rev_number); if( revhead == NULL ) { continue; } } if( chead != NULL ) { if( is_target == 0 ) { seen_repeats++; chead->state |= COMPARA_IS_REPEATED; chead->state = chead->state | COMPARA_QUERY_MULTIPLE; continue; } if( (chead->state & COMPARA_IS_REPEATED) ) { seen_repeats++; continue; } if( chead->size >= 2 ) { chead->state |= COMPARA_IS_REPEATED; repeated++; continue; } } if( chead == NULL ) { chead = new_ComparaHead(ci->blockalloc); if( chead == NULL ) { warn("Unable to make new ComparaHead for position %lld\n",i); assert(chead); } chead->number = number; (*ci->kii->insert_by_kmer)(ci->kii->handle,number,chead); if( is_target ) { chead->state = COMPARA_TARGET_UNIQUE; } else { chead->state = COMPARA_QUERY_UNIQUE; } } else { /* must change state... */ if( is_target ) { if( (chead->state & COMPARA_TARGET_UNIQUE) ) { chead->state = chead->state & (~COMPARA_TARGET_UNIQUE); chead->state = chead->state | COMPARA_TARGET_MULTIPLE; } else if( !(chead->state & COMPARA_TARGET_MULTIPLE) ) { chead->state = chead->state | COMPARA_TARGET_UNIQUE; } } else { if( (chead->state & COMPARA_QUERY_UNIQUE) ) { chead->state = chead->state & (~COMPARA_QUERY_UNIQUE); chead->state = chead->state | COMPARA_QUERY_MULTIPLE; } else if ( !(chead->state & COMPARA_QUERY_MULTIPLE) ) { chead->state = chead->state | COMPARA_QUERY_UNIQUE; } } } new_position_in_ComparaHead(chead,pos_start+i); if( cls->start == NULL ) { if( chead == NULL ) { warn("Very weird; NULL chead at start assignment"); } else { cls->start = chead; } } if( is_target == 0 && prev != NULL ) { prev->next_query = chead; chead->next_query = NULL; } prev = chead; } } free(base_numbers); return cls; } ComparaIndex * new_ComparaIndex(KmerIndexInterface * kii) { ComparaIndex * out; assert(kii); out = malloc(sizeof(ComparaIndex)); out->kii = kii; out->linkstart = calloc(COMPARAINDEX_LINK_START,sizeof(ComparaLinkStart*)); out->current_link = 0; out->link_len = COMPARAINDEX_LINK_START; out->sps = new_SinglePosSpace(1,50000); out->blockalloc = new_ComparaHeadBlockAllocator(COMPARAHEAD_BA_BLOCK_LENGTH,COMPARAHEAD_BA_UNIT_LENGTH); return out; } ComparaLinkStart * new_ComparaLinkStart(Sequence * seq) { ComparaLinkStart * out; out = malloc(sizeof(ComparaLinkStart)); out->start = NULL; out->seq = seq; return out; } void add_ComparaLinkStart_to_ComparaIndex(ComparaIndex * ci,ComparaLinkStart * cls) { assert(ci); assert(cls); if( ci->current_link >= ci->link_len ) { if( ci->link_len > COMPARAINDEX_LINK_LINEAR ) { ci->linkstart = realloc(ci->linkstart,sizeof(ComparaLinkStart*)*(ci->link_len + COMPARAINDEX_LINK_LINEAR)); ci->link_len = ci->link_len + COMPARAINDEX_LINK_LINEAR; } else { ci->linkstart = realloc(ci->linkstart,sizeof(ComparaLinkStart*)*(ci->link_len*2)); ci->link_len = ci->link_len*2; } } ci->linkstart[ci->current_link++] = cls; } ComparaHead * new_ComparaHead(ComparaHeadBlockAllocator * ba) { ComparaHead * out; out = new_ComparaHead_from_ComparaHeadBlockAllocator(ba); assert(out != NULL); out->size = 0; out->position[0] = -1; out->position[1] = -1; out->state = COMPARA_NOTHING; out->spline = NULL; return out; } void new_position_in_ComparaHead(ComparaHead * h,long int position) { assert(h != NULL); if( h->size == 2 ) { h->state |= COMPARA_IS_REPEATED; return; } h->position[(int)h->size] = position; h->size++; return; } ComparaHeadBlockAllocator * new_ComparaHeadBlockAllocator(int block_length,int unit_length) { ComparaHeadBlockAllocator * out; out = (ComparaHeadBlockAllocator*) malloc(sizeof(ComparaHeadBlockAllocator)); out->current_block = 0; out->current_unit = 0; out->unit_length = unit_length; out->block_length = block_length; out->block = calloc(block_length,sizeof(ComparaHead*)); out->block[0] = calloc(unit_length,sizeof(ComparaHead)); return out; } ComparaHead * new_ComparaHead_from_ComparaHeadBlockAllocator(ComparaHeadBlockAllocator * chba) { ComparaHead * ret; assert(chba != NULL); if( chba->current_unit >= chba->unit_length ) { if( chba->current_block >= chba->block_length ) { chba->block = realloc(chba->block,sizeof(ComparaHead*)*(2*chba->block_length)); chba->block_length *= 2; } chba->current_block++; chba->block[chba->current_block] = calloc(chba->unit_length,sizeof(ComparaHead)); chba->current_unit = 0; } ret = chba->block[chba->current_block]+(chba->current_unit); chba->current_unit++; return ret; } %} wise-2.4.1/src/dnaindex/assembly_stream_fasta.c0000644000175000001440000000124510670453716021161 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "assembly_stream_fasta.h" # line 17 "assembly_stream_fasta.dy" AssemblySequenceStream * plain_fasta_AssemblySequenceStream(FILE * ifp) { AssemblySequenceStream * out; out = AssemblySequenceStream_alloc(); out->handle = (void*) ifp; out->next_AssemblySequence = next_AssemblySequence_fasta_impl; out->free_handle = NULL; /* it is a no-op */ return out; } # line 32 "assembly_stream_fasta.dy" AssemblySequence * next_AssemblySequence_fasta_impl(void * h) { FILE * ifp = (FILE *) h; return read_plain_fasta_AssemblySequence(ifp,0,NULL); } # line 32 "assembly_stream_fasta.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/assembly_stream_fasta.h0000644000175000001440000000210110670453716021156 0ustar philippusers#ifndef DYNAMITEassembly_stream_fastaHEADERFILE #define DYNAMITEassembly_stream_fastaHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "assembly_stream_interface.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Unplaced functions */ /* There has been no indication of the use of these functions */ AssemblySequenceStream * Wise2_plain_fasta_AssemblySequenceStream(FILE * ifp); #define plain_fasta_AssemblySequenceStream Wise2_plain_fasta_AssemblySequenceStream AssemblySequence * Wise2_next_AssemblySequence_fasta_impl(void * h); #define next_AssemblySequence_fasta_impl Wise2_next_AssemblySequence_fasta_impl /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/kmer_hash.dy0000644000175000001440000002032010117345736016735 0ustar philippusers %{ #include "kmer_index_interface.h" #define KMER_HASH_BITS 24 #define KMER_HASH_MASK 0x0000000000ffffffL #define KMER_HASH_BUCKETS 16777216 /* #define KMER_HASH_BITS 28 #define KMER_HASH_MASK 0x000000000fffffffL #define KMER_HASH_BUCKETS (16777216*16) */ typedef struct KmerHashBucket { void **index; kmer_t *kmer; int length; int buflen; } KmerHashBucket; typedef struct KmerHashIndex { KmerHashBucket *bucket; kmer_t min_kmer; kmer_t max_kmer; } KmerHashIndex; %} %{ #include "kmer_hash.h" static int crc_table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; int crc32(int crc, const char *buf, int len) { if (buf == NULL) return 0; crc = crc ^ 0xffffffff; while(len--){ crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); } return crc ^ 0xffffffff; } KmerIndexInterface * new_KmerHashIndex(int kmer_size) { KmerIndexInterface * out; KmerHashIndex * khi; khi = malloc(sizeof(KmerHashIndex)); khi->bucket = calloc(KMER_HASH_BUCKETS,sizeof(KmerHashBucket)); if( khi->bucket == NULL ) { warn("could not allocate hash table of size %ld\n",KMER_HASH_BUCKETS); return NULL; } khi->min_kmer = 0xffffffff; khi->max_kmer = 0x00000000; out = malloc(sizeof(KmerIndexInterface)); out->retrieve_by_kmer = retrieve_by_kmer_KmerHashIndex; out->insert_by_kmer = insert_by_kmer_KmerHashIndex; out->free_handle = free_KmerHashIndex; out->next_filled_kmer = next_filled_kmer_KmerHashIndex; out->handle = (void*) khi; out->kmer_size = kmer_size; return out; } kmer_t hash_kmer(kmer_t kmer) { kmer_t hash = kmer; /* kmer >>= 24; hash ^= kmer; */ /* kmer <<= 5; hash ^= kmer; kmer <<= 5; hash ^= kmer; kmer <<= 5; hash ^= kmer; kmer <<= 5; hash ^= kmer; kmer <<= 5; hash ^= kmer; */ /* kmer >>= 28; hash ^= kmer; */ hash = crc32(0, (char*)&kmer, sizeof(kmer_t)); hash &= KMER_HASH_MASK; return hash; } void * retrieve_by_kmer_KmerHashIndex(void * handle,kmer_t kmer) { kmer_t hashval = hash_kmer(kmer); KmerHashIndex *khi = (KmerHashIndex*) handle; KmerHashBucket *khb; int i; assert(khi); khb = &khi->bucket[hashval]; if(!khb->index) return NULL; for(i = 0; i < khb->length; ++i){ if(khb->kmer[i] == kmer){ return khb->index[i]; } } return NULL; } kmer_t next_filled_kmer_KmerHashIndex(void * handle,kmer_t kmer) { kmer_t hashval; KmerHashIndex *khi = (KmerHashIndex*) handle; KmerHashBucket *khb; int i; assert(khi); /* starting bucket */ if( kmer == -1 ) { for(i=0;ibucket[i].index != NULL ) { return khi->bucket[i].kmer[0]; } } } /* else we've got a real one */ hashval = hash_kmer(kmer); khb = &khi->bucket[hashval]; assert(khb != NULL); for(i=0;ilength;i++) { if( kmer == khb->kmer[i] ) { break; } } /* as we give out these numbers, they must be here! */ assert(i < khb->length); if( i+1 == khb->length ) { /* next hashval needed */ for(i=hashval+1;ibucket[i].index != NULL ) { return khi->bucket[i].kmer[0]; } } /* out of buckets - return -1 */ return -1; } else { /* return next position in this bucket */ return khb->kmer[i+1]; } } boolean insert_by_kmer_KmerHashIndex(void * handle,kmer_t kmer,void * poi) { kmer_t hashval = hash_kmer(kmer); KmerHashIndex *khi = (KmerHashIndex*) handle; KmerHashBucket *khb; int i; assert(khi); if(kmer > khi->max_kmer) khi->max_kmer = kmer; if(kmer < khi->min_kmer) khi->min_kmer = kmer; khb = &khi->bucket[hashval]; if(khb->index == NULL){ khb->index = (void**)malloc(sizeof(void*)*8); if(khb->index == NULL){ fprintf(stderr, "Out of memory\n"); exit(1); } khb->kmer = (kmer_t*)malloc(sizeof(kmer_t)*8); if(khb->kmer == NULL){ fprintf(stderr, "Out of memory\n"); exit(1); } khb->buflen = 8; } if(khb->length >= khb->buflen){ khb->index = (void**)realloc(khb->index, sizeof(void*)*(khb->buflen*2)); if(khb->index == NULL){ fprintf(stderr, "Out of memory\n"); exit(1); } khb->kmer = (kmer_t*)realloc(khb->kmer, sizeof(kmer_t)*(khb->buflen*2)); if(khb->kmer == NULL){ fprintf(stderr, "Out of memory\n"); exit(1); } khb->buflen *= 2; } khb->kmer[khb->length] = kmer; khb->index[khb->length] = poi; khb->length++; return TRUE; } void free_KmerHashIndex(void * handle) { int i; int lenhist[10]; KmerHashIndex *khi = (KmerHashIndex*) handle; KmerHashBucket *khb; assert(khi); for(i = 0; i < 10; ++i) lenhist[i] = 0; for(i = 0; i < KMER_HASH_BUCKETS; ++i){ khb = &khi->bucket[i]; if(khb->length >= 10){ lenhist[9]++; } else { lenhist[khb->length]++; } if(khb->index) free(khb->index); if(khb->kmer) free(khb->kmer); } free(khi->bucket); fprintf(stderr, "min_kmer: %016lx\n", khi->min_kmer); fprintf(stderr, "max_kmer: %016lx\n", khi->max_kmer); free(khi); for(i = 0; i < 9; ++i){ fprintf(stderr, "%2d:%8d\n", i, lenhist[i]); } fprintf(stderr, "9+:%8d\n", lenhist[9]); return; } wise-2.4.1/src/dnaindex/kmer_index_interface.dy0000644000175000001440000000102107714402735021140 0ustar philippusers %{ #include "dyna.h" /* this brings in kmer_t */ #include "dnamapping.h" typedef struct KmerIndexInterface { void* (*retrieve_by_kmer)(void *,kmer_t); boolean (*insert_by_kmer)(void*,kmer_t,void*); void (*free_handle)(void*); kmer_t (*next_filled_kmer)(void *,kmer_t); void * handle; int kmer_size; } KmerIndexInterface; %} %{ #include "kmer_index_interface.h" void free_KmerIndexInterface(KmerIndexInterface * kii) { assert(kii); (*kii->free_handle)(kii->handle); free(kii); } %} wise-2.4.1/src/dnaindex/largeseqreader.dy0000644000175000001440000000371410116562253017764 0ustar philippusers %{ #include "sequence.h" #define LINEAR_LARGEFASTA_READ 50000000 %} %{ #include "largeseqreader.h" #include Sequence * read_large_dna_Sequence_file(char * filename,int report,FILE * logfp) { Sequence * out; FILE * ifp; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %d as a filename",filename); return NULL; } out = read_large_dna_Sequence(ifp,report,logfp); fclose(ifp); return out; } Sequence * read_large_dna_Sequence(FILE * ifp,int report,FILE * logfp) { Sequence * out; char * seqbuffer; long maxlen; long current; char c; char name[512]; c = fgetc(ifp); if( c == EOF ) { return NULL; } if( c != '>' ) { warn("First character not >, %c, not FASTA",c); return NULL; } current =0; while( (c=fgetc(ifp)) != EOF ) { if( isspace(c) ) { break; } name[current++] = c; } name[current] = '\0'; if( c != '\n' ) { while( (c=fgetc(ifp)) != EOF ) { if( c == '\n' ) { break; } } } current = 0; seqbuffer = calloc(4096,sizeof(char)); maxlen = 4096; while( (c=fgetc(ifp)) != EOF ) { if( c == '>' ) { break; } if( !isalpha(c) ) { continue; } if( logfp != NULL && report > 0 && current % report == 0) { fprintf(logfp,"Loaded %ld positions into %s\n",current,name); fflush(logfp); } if( current >= maxlen-1 ) { if( maxlen < LINEAR_LARGEFASTA_READ ) { seqbuffer = realloc(seqbuffer,maxlen*2*sizeof(char)); maxlen = maxlen * 2; } else { seqbuffer = realloc(seqbuffer,(maxlen+ LINEAR_LARGEFASTA_READ)*sizeof(char)); maxlen = maxlen + LINEAR_LARGEFASTA_READ; } } seqbuffer[current++] = c; } seqbuffer[current] = '\0'; if( c == '>' ) { ungetc(c,ifp); } out = Sequence_alloc(); out->name = stringalloc(name); out->seq = seqbuffer; out->len = current; out->maxlen = maxlen; out->type = SEQUENCE_DNA; return out; } %} wise-2.4.1/src/dnaindex/assembly.c0000644000175000001440000016472110670453716016441 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "assembly.h" # line 80 "assembly.dy" void show_help_AssemblyOutputPara(FILE * ofp) { fprintf(ofp,"Assembly Output options\n"); fprintf(ofp," -as_min_size [500] min size of contig to show\n"); } # line 87 "assembly.dy" AssemblyOutputPara * new_AssemblyOutputPara_from_argv(int * argc,char ** argv) { AssemblyOutputPara * out; out = AssemblyOutputPara_alloc(); out->min_size = 500; strip_out_integer_argument(argc,argv,"as_min_size",&out->min_size); return out; } # line 100 "assembly.dy" AssemblyOpaqueTypeSet * homopolymer_AssemblyOpaqueTypeSet(void) { AssemblyOpaqueTypeSet * out; AssemblyOpaqueType * t; char * base = "ATGC"; int i; out = AssemblyOpaqueTypeSet_alloc_std(); for(i=0;i<4;i++) { t = new_homopolymer_AssemblyOpaqueType(i,base[i]); add_AssemblyOpaqueTypeSet(out,t); } return out; } # line 118 "assembly.dy" int annotate_AssemblyOpaqueFeatures(AssemblyOpaqueTypeSet * aots,AssemblySequence * aseq,int kmer_size) { int count = 0; int i,j; int k; AssemblyOpaqueFeature * aof; AssemblyOpaqueFeature * prev; for(i=0;ilen;i++) { prev = NULL; for(j=0;jlen;) { if( aseq->seq->seq[j] == aots->type[i]->base ) { for(k=0;kseq->seq[j+k] != aots->type[i]->base ) { break; } } if( k < kmer_size ) { j += k; continue; } /* else, is a good position, extend to the end of this run */ for(;k+jlen;k++) { if( aseq->seq->seq[j+k] != aots->type[i]->base ) { break; } } /* if the start is within kmer of prev, then simply extend prev */ if( prev != NULL && prev->start+prev->length+kmer_size >= j ) { prev->length = j+k - prev->start; } else { /* new feature */ aof = AssemblyOpaqueFeature_alloc(); aof->start = j; aof->length = k; aof->type = aots->type[i]; add_opq_AssemblySequence(aseq,aof); prev = aof; count++; } } else { j++; } } } return count; } # line 172 "assembly.dy" void show_AssemblySequence(AssemblySequence * aseq,FILE * ofp) { int i; assert(aseq!=NULL); for(i=0;iopq_len;i++) { fprintf(ofp,"Opaque type %c from %d to %d\n",aseq->opaque[i]->type->base,aseq->opaque[i]->start,aseq->opaque[i]->start+aseq->opaque[i]->length); } write_fasta_Sequence(aseq->seq,ofp); fprintf(ofp,"//\n"); } # line 185 "assembly.dy" AssemblyOpaqueType * new_homopolymer_AssemblyOpaqueType(int int_type,char base) { AssemblyOpaqueType * out; out = AssemblyOpaqueType_alloc(); out->base = base; out->int_type = int_type; return out; } # line 196 "assembly.dy" AssemblySequence * read_plain_fasta_AssemblySequence(FILE * ifp,int report_log,FILE * report) { AssemblySequence * out; Sequence * seq; seq = read_large_dna_Sequence(ifp,report_log,report); if( seq == NULL ) { return NULL; } out = AssemblySequence_alloc_std(); out->seq = seq; return out; } # line 214 "assembly.dy" AssemblySequence * mirrored_AssemblySequence(AssemblySequence * aseq) { AssemblySequence * out; out = AssemblySequence_alloc(); out->seq = reverse_complement_Sequence(aseq->seq); out->mirror_seq = 1; out->mirror = aseq; aseq->mirror = out; return out; } # line 228 "assembly.dy" void dump_contigs_as_fasta_Assembly(Assembly * assembly,AssemblyOutputPara * aop,FILE * ofp) { int i; for(i=0;ilen;i++) { AssemblyContig * c = assembly->contig[i]; if( aop->min_size > c->consensus->len ) { continue; } fprintf(ofp,">%s max_depth=%d clean_start=%d clean_end=%d\n",c->consensus->name,c->max_depth,c->clean_start,c->clean_end); show_line(c->consensus->seq,60,ofp); } } # line 181 "assembly.c" /* Function: hard_link_AssemblySequenceEdit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblySequenceEdit *] * * Return [UNKN ] Undocumented return value [AssemblySequenceEdit *] * */ AssemblySequenceEdit * hard_link_AssemblySequenceEdit(AssemblySequenceEdit * obj) { if( obj == NULL ) { warn("Trying to hard link to a AssemblySequenceEdit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AssemblySequenceEdit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblySequenceEdit *] * */ AssemblySequenceEdit * AssemblySequenceEdit_alloc(void) { AssemblySequenceEdit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AssemblySequenceEdit *) ckalloc (sizeof(AssemblySequenceEdit))) == NULL) { warn("AssemblySequenceEdit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = 'u'; out->base = 'u'; return out; } /* Function: free_AssemblySequenceEdit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblySequenceEdit *] * * Return [UNKN ] Undocumented return value [AssemblySequenceEdit *] * */ AssemblySequenceEdit * free_AssemblySequenceEdit(AssemblySequenceEdit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AssemblySequenceEdit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_AssemblyOpaqueType(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblyOpaqueType *] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueType *] * */ AssemblyOpaqueType * hard_link_AssemblyOpaqueType(AssemblyOpaqueType * obj) { if( obj == NULL ) { warn("Trying to hard link to a AssemblyOpaqueType object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AssemblyOpaqueType_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblyOpaqueType *] * */ AssemblyOpaqueType * AssemblyOpaqueType_alloc(void) { AssemblyOpaqueType * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AssemblyOpaqueType *) ckalloc (sizeof(AssemblyOpaqueType))) == NULL) { warn("AssemblyOpaqueType_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->int_type = 0; out->base = 'u'; return out; } /* Function: free_AssemblyOpaqueType(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblyOpaqueType *] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueType *] * */ AssemblyOpaqueType * free_AssemblyOpaqueType(AssemblyOpaqueType * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AssemblyOpaqueType obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_AssemblyOpaqueTypeSet(list,i,j) * * Descrip: swap function: an internal for qsort_AssemblyOpaqueTypeSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [AssemblyOpaqueType **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_AssemblyOpaqueTypeSet(AssemblyOpaqueType ** list,int i,int j) { AssemblyOpaqueType * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_AssemblyOpaqueTypeSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_AssemblyOpaqueTypeSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [AssemblyOpaqueType **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_AssemblyOpaqueTypeSet(AssemblyOpaqueType ** list,int left,int right,int (*comp)(AssemblyOpaqueType * ,AssemblyOpaqueType * )) { int i,last; if( left >= right ) return; swap_AssemblyOpaqueTypeSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_AssemblyOpaqueTypeSet (list,++last,i); } swap_AssemblyOpaqueTypeSet (list,left,last); qsort_AssemblyOpaqueTypeSet(list,left,last-1,comp); qsort_AssemblyOpaqueTypeSet(list,last+1,right,comp); } /* Function: sort_AssemblyOpaqueTypeSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_AssemblyOpaqueTypeSet * * * Arg: obj [UNKN ] Object containing list [AssemblyOpaqueTypeSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_AssemblyOpaqueTypeSet(AssemblyOpaqueTypeSet * obj,int (*comp)(AssemblyOpaqueType *, AssemblyOpaqueType *)) { qsort_AssemblyOpaqueTypeSet(obj->type,0,obj->len-1,comp); return; } /* Function: expand_AssemblyOpaqueTypeSet(obj,len) * * Descrip: Really an internal function for add_AssemblyOpaqueTypeSet * * * Arg: obj [UNKN ] Object which contains the list [AssemblyOpaqueTypeSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_AssemblyOpaqueTypeSet(AssemblyOpaqueTypeSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_AssemblyOpaqueTypeSet called with no need"); return TRUE; } if( (obj->type = (AssemblyOpaqueType ** ) ckrealloc (obj->type,sizeof(AssemblyOpaqueType *)*len)) == NULL) { warn("ckrealloc failed for expand_AssemblyOpaqueTypeSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_AssemblyOpaqueTypeSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AssemblyOpaqueTypeSet *] * Arg: add [OWNER] Object to add to the list [AssemblyOpaqueType *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_AssemblyOpaqueTypeSet(AssemblyOpaqueTypeSet * obj,AssemblyOpaqueType * add) { if( obj->len >= obj->maxlen) { if( expand_AssemblyOpaqueTypeSet(obj,obj->len + AssemblyOpaqueTypeSetLISTLENGTH) == FALSE) return FALSE; } obj->type[obj->len++]=add; return TRUE; } /* Function: flush_AssemblyOpaqueTypeSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AssemblyOpaqueTypeSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_AssemblyOpaqueTypeSet(AssemblyOpaqueTypeSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->type[i] != NULL) { free_AssemblyOpaqueType(obj->type[i]); obj->type[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: AssemblyOpaqueTypeSet_alloc_std(void) * * Descrip: Equivalent to AssemblyOpaqueTypeSet_alloc_len(AssemblyOpaqueTypeSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AssemblyOpaqueTypeSet *] * */ AssemblyOpaqueTypeSet * AssemblyOpaqueTypeSet_alloc_std(void) { return AssemblyOpaqueTypeSet_alloc_len(AssemblyOpaqueTypeSetLISTLENGTH); } /* Function: AssemblyOpaqueTypeSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueTypeSet *] * */ AssemblyOpaqueTypeSet * AssemblyOpaqueTypeSet_alloc_len(int len) { AssemblyOpaqueTypeSet * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = AssemblyOpaqueTypeSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->type = (AssemblyOpaqueType ** ) ckcalloc (len,sizeof(AssemblyOpaqueType *))) == NULL) { warn("Warning, ckcalloc failed in AssemblyOpaqueTypeSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_AssemblyOpaqueTypeSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblyOpaqueTypeSet *] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueTypeSet *] * */ AssemblyOpaqueTypeSet * hard_link_AssemblyOpaqueTypeSet(AssemblyOpaqueTypeSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a AssemblyOpaqueTypeSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AssemblyOpaqueTypeSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblyOpaqueTypeSet *] * */ AssemblyOpaqueTypeSet * AssemblyOpaqueTypeSet_alloc(void) { AssemblyOpaqueTypeSet * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AssemblyOpaqueTypeSet *) ckalloc (sizeof(AssemblyOpaqueTypeSet))) == NULL) { warn("AssemblyOpaqueTypeSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_AssemblyOpaqueTypeSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblyOpaqueTypeSet *] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueTypeSet *] * */ AssemblyOpaqueTypeSet * free_AssemblyOpaqueTypeSet(AssemblyOpaqueTypeSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AssemblyOpaqueTypeSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->type != NULL) { for(i=0;ilen;i++) { if( obj->type[i] != NULL) free_AssemblyOpaqueType(obj->type[i]); } ckfree(obj->type); } ckfree(obj); return NULL; } /* Function: hard_link_AssemblyOpaqueFeature(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblyOpaqueFeature *] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueFeature *] * */ AssemblyOpaqueFeature * hard_link_AssemblyOpaqueFeature(AssemblyOpaqueFeature * obj) { if( obj == NULL ) { warn("Trying to hard link to a AssemblyOpaqueFeature object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AssemblyOpaqueFeature_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblyOpaqueFeature *] * */ AssemblyOpaqueFeature * AssemblyOpaqueFeature_alloc(void) { AssemblyOpaqueFeature * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AssemblyOpaqueFeature *) ckalloc (sizeof(AssemblyOpaqueFeature))) == NULL) { warn("AssemblyOpaqueFeature_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->length = 0; return out; } /* Function: free_AssemblyOpaqueFeature(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblyOpaqueFeature *] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueFeature *] * */ AssemblyOpaqueFeature * free_AssemblyOpaqueFeature(AssemblyOpaqueFeature * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AssemblyOpaqueFeature obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->type is linked in */ ckfree(obj); return NULL; } /* Function: swap_AssemblySequence(list,i,j) * * Descrip: swap function: an internal for qsort_AssemblySequence * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [AssemblySequenceEdit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_AssemblySequence(AssemblySequenceEdit ** list,int i,int j) { AssemblySequenceEdit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_AssemblySequence(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_AssemblySequence which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [AssemblySequenceEdit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_AssemblySequence(AssemblySequenceEdit ** list,int left,int right,int (*comp)(AssemblySequenceEdit * ,AssemblySequenceEdit * )) { int i,last; if( left >= right ) return; swap_AssemblySequence(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_AssemblySequence (list,++last,i); } swap_AssemblySequence (list,left,last); qsort_AssemblySequence(list,left,last-1,comp); qsort_AssemblySequence(list,last+1,right,comp); } /* Function: sort_AssemblySequence(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_AssemblySequence * * * Arg: obj [UNKN ] Object containing list [AssemblySequence *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_AssemblySequence(AssemblySequence * obj,int (*comp)(AssemblySequenceEdit *, AssemblySequenceEdit *)) { qsort_AssemblySequence(obj->edit,0,obj->len-1,comp); return; } /* Function: expand_AssemblySequence(obj,len) * * Descrip: Really an internal function for add_AssemblySequence * * * Arg: obj [UNKN ] Object which contains the list [AssemblySequence *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_AssemblySequence(AssemblySequence * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_AssemblySequence called with no need"); return TRUE; } if( (obj->edit = (AssemblySequenceEdit ** ) ckrealloc (obj->edit,sizeof(AssemblySequenceEdit *)*len)) == NULL) { warn("ckrealloc failed for expand_AssemblySequence, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_AssemblySequence(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AssemblySequence *] * Arg: add [OWNER] Object to add to the list [AssemblySequenceEdit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_AssemblySequence(AssemblySequence * obj,AssemblySequenceEdit * add) { if( obj->len >= obj->maxlen) { if( expand_AssemblySequence(obj,obj->len + AssemblySequenceLISTLENGTH) == FALSE) return FALSE; } obj->edit[obj->len++]=add; return TRUE; } /* Function: flush_AssemblySequence(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AssemblySequence *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_AssemblySequence(AssemblySequence * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->edit[i] != NULL) { free_AssemblySequenceEdit(obj->edit[i]); obj->edit[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: swap_opq_AssemblySequence(list,i,j) * * Descrip: swap function: an internal for qsort_opq_AssemblySequence * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [AssemblyOpaqueFeature **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_opq_AssemblySequence(AssemblyOpaqueFeature ** list,int i,int j) { AssemblyOpaqueFeature * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_opq_AssemblySequence(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_opq_AssemblySequence which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [AssemblyOpaqueFeature **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_opq_AssemblySequence(AssemblyOpaqueFeature ** list,int left,int right,int (*comp)(AssemblyOpaqueFeature * ,AssemblyOpaqueFeature * )) { int i,last; if( left >= right ) return; swap_opq_AssemblySequence(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_opq_AssemblySequence (list,++last,i); } swap_opq_AssemblySequence (list,left,last); qsort_opq_AssemblySequence(list,left,last-1,comp); qsort_opq_AssemblySequence(list,last+1,right,comp); } /* Function: sort_opq_AssemblySequence(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_opq_AssemblySequence * * * Arg: obj [UNKN ] Object containing list [AssemblySequence *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_opq_AssemblySequence(AssemblySequence * obj,int (*comp)(AssemblyOpaqueFeature *, AssemblyOpaqueFeature *)) { qsort_opq_AssemblySequence(obj->opaque,0,obj->opq_len-1,comp); return; } /* Function: expand_opq_AssemblySequence(obj,len) * * Descrip: Really an internal function for add_opq_AssemblySequence * * * Arg: obj [UNKN ] Object which contains the list [AssemblySequence *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_opq_AssemblySequence(AssemblySequence * obj,int len) { if( obj->opq_maxlen > obj->opq_len ) { warn("expand_AssemblySequenceopq_ called with no need"); return TRUE; } if( (obj->opaque = (AssemblyOpaqueFeature ** ) ckrealloc (obj->opaque,sizeof(AssemblyOpaqueFeature *)*len)) == NULL) { warn("ckrealloc failed for expand_AssemblySequence, returning FALSE"); return FALSE; } obj->opq_maxlen = len; return TRUE; } /* Function: add_opq_AssemblySequence(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AssemblySequence *] * Arg: add [OWNER] Object to add to the list [AssemblyOpaqueFeature *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_opq_AssemblySequence(AssemblySequence * obj,AssemblyOpaqueFeature * add) { if( obj->opq_len >= obj->opq_maxlen) { if( expand_opq_AssemblySequence(obj,obj->opq_len + AssemblySequenceLISTLENGTH) == FALSE) return FALSE; } obj->opaque[obj->opq_len++]=add; return TRUE; } /* Function: flush_opq_AssemblySequence(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AssemblySequence *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_opq_AssemblySequence(AssemblySequence * obj) { int i; for(i=0;iopq_len;i++) { /*for i over list length*/ if( obj->opaque[i] != NULL) { free_AssemblyOpaqueFeature(obj->opaque[i]); obj->opaque[i] = NULL; } } /* end of for i over list length */ obj->opq_len = 0; return i; } /* Function: AssemblySequence_alloc_std(void) * * Descrip: Equivalent to AssemblySequence_alloc_len(AssemblySequenceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AssemblySequence *] * */ AssemblySequence * AssemblySequence_alloc_std(void) { return AssemblySequence_alloc_len(AssemblySequenceLISTLENGTH); } /* Function: AssemblySequence_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AssemblySequence *] * */ AssemblySequence * AssemblySequence_alloc_len(int len) { AssemblySequence * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = AssemblySequence_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->edit = (AssemblySequenceEdit ** ) ckcalloc (len,sizeof(AssemblySequenceEdit *))) == NULL) { warn("Warning, ckcalloc failed in AssemblySequence_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; if((out->opaque = (AssemblyOpaqueFeature ** ) ckcalloc (len,sizeof(AssemblyOpaqueFeature *))) == NULL) { warn("Warning, ckcalloc failed in AssemblySequence_alloc_len"); return NULL; } out->opq_len = 0; out->opq_maxlen = len; return out; } /* Function: hard_link_AssemblySequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblySequence *] * * Return [UNKN ] Undocumented return value [AssemblySequence *] * */ AssemblySequence * hard_link_AssemblySequence(AssemblySequence * obj) { if( obj == NULL ) { warn("Trying to hard link to a AssemblySequence object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AssemblySequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblySequence *] * */ AssemblySequence * AssemblySequence_alloc(void) { AssemblySequence * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AssemblySequence *) ckalloc (sizeof(AssemblySequence))) == NULL) { warn("AssemblySequence_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->seq = NULL; out->quality = NULL; out->edit = NULL; out->len = out->maxlen = 0; out->state = 'u'; out->mirror_seq = 0; out->opaque = NULL; out->opq_len = out->opq_maxlen = 0; out->orig = NULL; out->abrev_repeat = NULL; return out; } /* Function: free_AssemblySequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblySequence *] * * Return [UNKN ] Undocumented return value [AssemblySequence *] * */ AssemblySequence * free_AssemblySequence(AssemblySequence * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AssemblySequence obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->seq != NULL) free_Sequence(obj->seq); if( obj->quality != NULL) ckfree(obj->quality); if( obj->edit != NULL) { for(i=0;ilen;i++) { if( obj->edit[i] != NULL) free_AssemblySequenceEdit(obj->edit[i]); } ckfree(obj->edit); } /* obj->mirror is linked in */ /* obj->pair is linked in */ if( obj->opaque != NULL) { for(i=0;iopq_len;i++) { if( obj->opaque[i] != NULL) free_AssemblyOpaqueFeature(obj->opaque[i]); } ckfree(obj->opaque); } if( obj->orig != NULL) free_Sequence(obj->orig); if( obj->abrev_repeat != NULL) ckfree(obj->abrev_repeat); ckfree(obj); return NULL; } /* Function: hard_link_AssemblySequencePlacement(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblySequencePlacement *] * * Return [UNKN ] Undocumented return value [AssemblySequencePlacement *] * */ AssemblySequencePlacement * hard_link_AssemblySequencePlacement(AssemblySequencePlacement * obj) { if( obj == NULL ) { warn("Trying to hard link to a AssemblySequencePlacement object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AssemblySequencePlacement_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblySequencePlacement *] * */ AssemblySequencePlacement * AssemblySequencePlacement_alloc(void) { AssemblySequencePlacement * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AssemblySequencePlacement *) ckalloc (sizeof(AssemblySequencePlacement))) == NULL) { warn("AssemblySequencePlacement_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->aseq = NULL; out->contig_start = 0; out->contig_end = 0; out->seq_start = 0; out->seq_end = 0; out->ungapped = FALSE; return out; } /* Function: free_AssemblySequencePlacement(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblySequencePlacement *] * * Return [UNKN ] Undocumented return value [AssemblySequencePlacement *] * */ AssemblySequencePlacement * free_AssemblySequencePlacement(AssemblySequencePlacement * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AssemblySequencePlacement obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->aseq != NULL) free_AssemblySequence(obj->aseq); ckfree(obj); return NULL; } /* Function: swap_AssemblyContig(list,i,j) * * Descrip: swap function: an internal for qsort_AssemblyContig * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [AssemblySequencePlacement **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_AssemblyContig(AssemblySequencePlacement ** list,int i,int j) { AssemblySequencePlacement * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_AssemblyContig(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_AssemblyContig which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [AssemblySequencePlacement **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_AssemblyContig(AssemblySequencePlacement ** list,int left,int right,int (*comp)(AssemblySequencePlacement * ,AssemblySequencePlacement * )) { int i,last; if( left >= right ) return; swap_AssemblyContig(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_AssemblyContig (list,++last,i); } swap_AssemblyContig (list,left,last); qsort_AssemblyContig(list,left,last-1,comp); qsort_AssemblyContig(list,last+1,right,comp); } /* Function: sort_AssemblyContig(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_AssemblyContig * * * Arg: obj [UNKN ] Object containing list [AssemblyContig *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_AssemblyContig(AssemblyContig * obj,int (*comp)(AssemblySequencePlacement *, AssemblySequencePlacement *)) { qsort_AssemblyContig(obj->reads,0,obj->len-1,comp); return; } /* Function: expand_AssemblyContig(obj,len) * * Descrip: Really an internal function for add_AssemblyContig * * * Arg: obj [UNKN ] Object which contains the list [AssemblyContig *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_AssemblyContig(AssemblyContig * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_AssemblyContig called with no need"); return TRUE; } if( (obj->reads = (AssemblySequencePlacement ** ) ckrealloc (obj->reads,sizeof(AssemblySequencePlacement *)*len)) == NULL) { warn("ckrealloc failed for expand_AssemblyContig, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_AssemblyContig(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AssemblyContig *] * Arg: add [OWNER] Object to add to the list [AssemblySequencePlacement *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_AssemblyContig(AssemblyContig * obj,AssemblySequencePlacement * add) { if( obj->len >= obj->maxlen) { if( expand_AssemblyContig(obj,obj->len + AssemblyContigLISTLENGTH) == FALSE) return FALSE; } obj->reads[obj->len++]=add; return TRUE; } /* Function: flush_AssemblyContig(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AssemblyContig *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_AssemblyContig(AssemblyContig * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->reads[i] != NULL) { free_AssemblySequencePlacement(obj->reads[i]); obj->reads[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: AssemblyContig_alloc_std(void) * * Descrip: Equivalent to AssemblyContig_alloc_len(AssemblyContigLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AssemblyContig *] * */ AssemblyContig * AssemblyContig_alloc_std(void) { return AssemblyContig_alloc_len(AssemblyContigLISTLENGTH); } /* Function: AssemblyContig_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AssemblyContig *] * */ AssemblyContig * AssemblyContig_alloc_len(int len) { AssemblyContig * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = AssemblyContig_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->reads = (AssemblySequencePlacement ** ) ckcalloc (len,sizeof(AssemblySequencePlacement *))) == NULL) { warn("Warning, ckcalloc failed in AssemblyContig_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_AssemblyContig(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblyContig *] * * Return [UNKN ] Undocumented return value [AssemblyContig *] * */ AssemblyContig * hard_link_AssemblyContig(AssemblyContig * obj) { if( obj == NULL ) { warn("Trying to hard link to a AssemblyContig object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AssemblyContig_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblyContig *] * */ AssemblyContig * AssemblyContig_alloc(void) { AssemblyContig * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AssemblyContig *) ckalloc (sizeof(AssemblyContig))) == NULL) { warn("AssemblyContig_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->consensus = NULL; out->reads = NULL; out->len = out->maxlen = 0; out->clean_start = FALSE; out->clean_end = FALSE; out->max_depth = 0; return out; } /* Function: free_AssemblyContig(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblyContig *] * * Return [UNKN ] Undocumented return value [AssemblyContig *] * */ AssemblyContig * free_AssemblyContig(AssemblyContig * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AssemblyContig obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->consensus != NULL) free_Sequence(obj->consensus); if( obj->reads != NULL) { for(i=0;ilen;i++) { if( obj->reads[i] != NULL) free_AssemblySequencePlacement(obj->reads[i]); } ckfree(obj->reads); } ckfree(obj); return NULL; } /* Function: swap_Assembly(list,i,j) * * Descrip: swap function: an internal for qsort_Assembly * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [AssemblyContig **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Assembly(AssemblyContig ** list,int i,int j) { AssemblyContig * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Assembly(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Assembly which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [AssemblyContig **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Assembly(AssemblyContig ** list,int left,int right,int (*comp)(AssemblyContig * ,AssemblyContig * )) { int i,last; if( left >= right ) return; swap_Assembly(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Assembly (list,++last,i); } swap_Assembly (list,left,last); qsort_Assembly(list,left,last-1,comp); qsort_Assembly(list,last+1,right,comp); } /* Function: sort_Assembly(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Assembly * * * Arg: obj [UNKN ] Object containing list [Assembly *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Assembly(Assembly * obj,int (*comp)(AssemblyContig *, AssemblyContig *)) { qsort_Assembly(obj->contig,0,obj->len-1,comp); return; } /* Function: expand_Assembly(obj,len) * * Descrip: Really an internal function for add_Assembly * * * Arg: obj [UNKN ] Object which contains the list [Assembly *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Assembly(Assembly * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Assembly called with no need"); return TRUE; } if( (obj->contig = (AssemblyContig ** ) ckrealloc (obj->contig,sizeof(AssemblyContig *)*len)) == NULL) { warn("ckrealloc failed for expand_Assembly, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Assembly(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Assembly *] * Arg: add [OWNER] Object to add to the list [AssemblyContig *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Assembly(Assembly * obj,AssemblyContig * add) { if( obj->len >= obj->maxlen) { if( expand_Assembly(obj,obj->len + AssemblyLISTLENGTH) == FALSE) return FALSE; } obj->contig[obj->len++]=add; return TRUE; } /* Function: flush_Assembly(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Assembly *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Assembly(Assembly * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->contig[i] != NULL) { free_AssemblyContig(obj->contig[i]); obj->contig[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: swap_chaff_Assembly(list,i,j) * * Descrip: swap function: an internal for qsort_chaff_Assembly * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [AssemblySequence **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_chaff_Assembly(AssemblySequence ** list,int i,int j) { AssemblySequence * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_chaff_Assembly(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_chaff_Assembly which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [AssemblySequence **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_chaff_Assembly(AssemblySequence ** list,int left,int right,int (*comp)(AssemblySequence * ,AssemblySequence * )) { int i,last; if( left >= right ) return; swap_chaff_Assembly(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_chaff_Assembly (list,++last,i); } swap_chaff_Assembly (list,left,last); qsort_chaff_Assembly(list,left,last-1,comp); qsort_chaff_Assembly(list,last+1,right,comp); } /* Function: sort_chaff_Assembly(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_chaff_Assembly * * * Arg: obj [UNKN ] Object containing list [Assembly *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_chaff_Assembly(Assembly * obj,int (*comp)(AssemblySequence *, AssemblySequence *)) { qsort_chaff_Assembly(obj->chaff,0,obj->chaff_len-1,comp); return; } /* Function: expand_chaff_Assembly(obj,len) * * Descrip: Really an internal function for add_chaff_Assembly * * * Arg: obj [UNKN ] Object which contains the list [Assembly *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_chaff_Assembly(Assembly * obj,int len) { if( obj->chaff_maxlen > obj->chaff_len ) { warn("expand_Assemblychaff_ called with no need"); return TRUE; } if( (obj->chaff = (AssemblySequence ** ) ckrealloc (obj->chaff,sizeof(AssemblySequence *)*len)) == NULL) { warn("ckrealloc failed for expand_Assembly, returning FALSE"); return FALSE; } obj->chaff_maxlen = len; return TRUE; } /* Function: add_chaff_Assembly(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Assembly *] * Arg: add [OWNER] Object to add to the list [AssemblySequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_chaff_Assembly(Assembly * obj,AssemblySequence * add) { if( obj->chaff_len >= obj->chaff_maxlen) { if( expand_chaff_Assembly(obj,obj->chaff_len + AssemblyLISTLENGTH) == FALSE) return FALSE; } obj->chaff[obj->chaff_len++]=add; return TRUE; } /* Function: flush_chaff_Assembly(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Assembly *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_chaff_Assembly(Assembly * obj) { int i; for(i=0;ichaff_len;i++) { /*for i over list length*/ if( obj->chaff[i] != NULL) { free_AssemblySequence(obj->chaff[i]); obj->chaff[i] = NULL; } } /* end of for i over list length */ obj->chaff_len = 0; return i; } /* Function: Assembly_alloc_std(void) * * Descrip: Equivalent to Assembly_alloc_len(AssemblyLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Assembly *] * */ Assembly * Assembly_alloc_std(void) { return Assembly_alloc_len(AssemblyLISTLENGTH); } /* Function: Assembly_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Assembly *] * */ Assembly * Assembly_alloc_len(int len) { Assembly * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Assembly_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->contig = (AssemblyContig ** ) ckcalloc (len,sizeof(AssemblyContig *))) == NULL) { warn("Warning, ckcalloc failed in Assembly_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; if((out->chaff = (AssemblySequence ** ) ckcalloc (len,sizeof(AssemblySequence *))) == NULL) { warn("Warning, ckcalloc failed in Assembly_alloc_len"); return NULL; } out->chaff_len = 0; out->chaff_maxlen = len; return out; } /* Function: hard_link_Assembly(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Assembly *] * * Return [UNKN ] Undocumented return value [Assembly *] * */ Assembly * hard_link_Assembly(Assembly * obj) { if( obj == NULL ) { warn("Trying to hard link to a Assembly object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Assembly_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Assembly *] * */ Assembly * Assembly_alloc(void) { Assembly * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Assembly *) ckalloc (sizeof(Assembly))) == NULL) { warn("Assembly_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->contig = NULL; out->len = out->maxlen = 0; out->chaff = NULL; out->chaff_len = out->chaff_maxlen = 0; return out; } /* Function: free_Assembly(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Assembly *] * * Return [UNKN ] Undocumented return value [Assembly *] * */ Assembly * free_Assembly(Assembly * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Assembly obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->contig != NULL) { for(i=0;ilen;i++) { if( obj->contig[i] != NULL) free_AssemblyContig(obj->contig[i]); } ckfree(obj->contig); } if( obj->chaff != NULL) { for(i=0;ichaff_len;i++) { if( obj->chaff[i] != NULL) free_AssemblySequence(obj->chaff[i]); } ckfree(obj->chaff); } ckfree(obj); return NULL; } /* Function: hard_link_AssemblyOutputPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblyOutputPara *] * * Return [UNKN ] Undocumented return value [AssemblyOutputPara *] * */ AssemblyOutputPara * hard_link_AssemblyOutputPara(AssemblyOutputPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a AssemblyOutputPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AssemblyOutputPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblyOutputPara *] * */ AssemblyOutputPara * AssemblyOutputPara_alloc(void) { AssemblyOutputPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AssemblyOutputPara *) ckalloc (sizeof(AssemblyOutputPara))) == NULL) { warn("AssemblyOutputPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->min_size = 0; return out; } /* Function: free_AssemblyOutputPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblyOutputPara *] * * Return [UNKN ] Undocumented return value [AssemblyOutputPara *] * */ AssemblyOutputPara * free_AssemblyOutputPara(AssemblyOutputPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AssemblyOutputPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/assembly.h0000644000175000001440000007543710670453716016453 0ustar philippusers#ifndef DYNAMITEassemblyHEADERFILE #define DYNAMITEassemblyHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #include "largeseqreader.h" #define AssemblySequenceLISTLENGTH 8 #define AssemblyContigLISTLENGTH 512 #define AssemblyLISTLENGTH 1024 #define AssemblyOpaqueTypeSetLISTLENGTH 16 struct Wise2_AssemblySequenceEdit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char type; char base; } ; /* AssemblySequenceEdit defined */ #ifndef DYNAMITE_DEFINED_AssemblySequenceEdit typedef struct Wise2_AssemblySequenceEdit Wise2_AssemblySequenceEdit; #define AssemblySequenceEdit Wise2_AssemblySequenceEdit #define DYNAMITE_DEFINED_AssemblySequenceEdit #endif #ifndef DYNAMITE_DEFINED_AssemblySequence typedef struct Wise2_AssemblySequence Wise2_AssemblySequence; #define AssemblySequence Wise2_AssemblySequence #define DYNAMITE_DEFINED_AssemblySequence #endif struct Wise2_AssemblyOpaqueType { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int int_type; char base; } ; /* AssemblyOpaqueType defined */ #ifndef DYNAMITE_DEFINED_AssemblyOpaqueType typedef struct Wise2_AssemblyOpaqueType Wise2_AssemblyOpaqueType; #define AssemblyOpaqueType Wise2_AssemblyOpaqueType #define DYNAMITE_DEFINED_AssemblyOpaqueType #endif struct Wise2_AssemblyOpaqueTypeSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif AssemblyOpaqueType ** type; int len;/* len for above type */ int maxlen; /* maxlen for above type */ } ; /* AssemblyOpaqueTypeSet defined */ #ifndef DYNAMITE_DEFINED_AssemblyOpaqueTypeSet typedef struct Wise2_AssemblyOpaqueTypeSet Wise2_AssemblyOpaqueTypeSet; #define AssemblyOpaqueTypeSet Wise2_AssemblyOpaqueTypeSet #define DYNAMITE_DEFINED_AssemblyOpaqueTypeSet #endif struct Wise2_AssemblyOpaqueFeature { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start; int length; AssemblyOpaqueType * type; } ; /* AssemblyOpaqueFeature defined */ #ifndef DYNAMITE_DEFINED_AssemblyOpaqueFeature typedef struct Wise2_AssemblyOpaqueFeature Wise2_AssemblyOpaqueFeature; #define AssemblyOpaqueFeature Wise2_AssemblyOpaqueFeature #define DYNAMITE_DEFINED_AssemblyOpaqueFeature #endif struct Wise2_AssemblySequence { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence * seq; double * quality; AssemblySequenceEdit ** edit; int len;/* len for above edit */ int maxlen; /* maxlen for above edit */ char state; AssemblySequence * mirror; AssemblySequence * pair; char mirror_seq; AssemblyOpaqueFeature ** opaque; int opq_len;/* len for above opaque */ int opq_maxlen; /* maxlen for above opaque */ Sequence * orig; int * abrev_repeat; } ; /* AssemblySequence defined */ #ifndef DYNAMITE_DEFINED_AssemblySequence typedef struct Wise2_AssemblySequence Wise2_AssemblySequence; #define AssemblySequence Wise2_AssemblySequence #define DYNAMITE_DEFINED_AssemblySequence #endif struct Wise2_AssemblySequencePlacement { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif AssemblySequence * aseq; long contig_start; long contig_end; int seq_start; int seq_end; boolean ungapped; } ; /* AssemblySequencePlacement defined */ #ifndef DYNAMITE_DEFINED_AssemblySequencePlacement typedef struct Wise2_AssemblySequencePlacement Wise2_AssemblySequencePlacement; #define AssemblySequencePlacement Wise2_AssemblySequencePlacement #define DYNAMITE_DEFINED_AssemblySequencePlacement #endif struct Wise2_AssemblyContig { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence * consensus; AssemblySequencePlacement ** reads; int len;/* len for above reads */ int maxlen; /* maxlen for above reads */ boolean clean_start; boolean clean_end; int max_depth; } ; /* AssemblyContig defined */ #ifndef DYNAMITE_DEFINED_AssemblyContig typedef struct Wise2_AssemblyContig Wise2_AssemblyContig; #define AssemblyContig Wise2_AssemblyContig #define DYNAMITE_DEFINED_AssemblyContig #endif struct Wise2_Assembly { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif AssemblyContig ** contig; int len;/* len for above contig */ int maxlen; /* maxlen for above contig */ AssemblySequence ** chaff; int chaff_len; /* len for above chaff */ int chaff_maxlen; /* maxlen for above chaff */ } ; /* Assembly defined */ #ifndef DYNAMITE_DEFINED_Assembly typedef struct Wise2_Assembly Wise2_Assembly; #define Assembly Wise2_Assembly #define DYNAMITE_DEFINED_Assembly #endif struct Wise2_AssemblyOutputPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int min_size; } ; /* AssemblyOutputPara defined */ #ifndef DYNAMITE_DEFINED_AssemblyOutputPara typedef struct Wise2_AssemblyOutputPara Wise2_AssemblyOutputPara; #define AssemblyOutputPara Wise2_AssemblyOutputPara #define DYNAMITE_DEFINED_AssemblyOutputPara #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_AssemblySequenceEdit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblySequenceEdit *] * * Return [UNKN ] Undocumented return value [AssemblySequenceEdit *] * */ AssemblySequenceEdit * Wise2_hard_link_AssemblySequenceEdit(AssemblySequenceEdit * obj); #define hard_link_AssemblySequenceEdit Wise2_hard_link_AssemblySequenceEdit /* Function: AssemblySequenceEdit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblySequenceEdit *] * */ AssemblySequenceEdit * Wise2_AssemblySequenceEdit_alloc(void); #define AssemblySequenceEdit_alloc Wise2_AssemblySequenceEdit_alloc /* Function: free_AssemblySequenceEdit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblySequenceEdit *] * * Return [UNKN ] Undocumented return value [AssemblySequenceEdit *] * */ AssemblySequenceEdit * Wise2_free_AssemblySequenceEdit(AssemblySequenceEdit * obj); #define free_AssemblySequenceEdit Wise2_free_AssemblySequenceEdit /* Function: hard_link_AssemblyOpaqueType(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblyOpaqueType *] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueType *] * */ AssemblyOpaqueType * Wise2_hard_link_AssemblyOpaqueType(AssemblyOpaqueType * obj); #define hard_link_AssemblyOpaqueType Wise2_hard_link_AssemblyOpaqueType /* Function: AssemblyOpaqueType_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblyOpaqueType *] * */ AssemblyOpaqueType * Wise2_AssemblyOpaqueType_alloc(void); #define AssemblyOpaqueType_alloc Wise2_AssemblyOpaqueType_alloc /* Function: free_AssemblyOpaqueType(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblyOpaqueType *] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueType *] * */ AssemblyOpaqueType * Wise2_free_AssemblyOpaqueType(AssemblyOpaqueType * obj); #define free_AssemblyOpaqueType Wise2_free_AssemblyOpaqueType /* Function: add_AssemblyOpaqueTypeSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AssemblyOpaqueTypeSet *] * Arg: add [OWNER] Object to add to the list [AssemblyOpaqueType *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_AssemblyOpaqueTypeSet(AssemblyOpaqueTypeSet * obj,AssemblyOpaqueType * add); #define add_AssemblyOpaqueTypeSet Wise2_add_AssemblyOpaqueTypeSet /* Function: flush_AssemblyOpaqueTypeSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AssemblyOpaqueTypeSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_AssemblyOpaqueTypeSet(AssemblyOpaqueTypeSet * obj); #define flush_AssemblyOpaqueTypeSet Wise2_flush_AssemblyOpaqueTypeSet /* Function: AssemblyOpaqueTypeSet_alloc_std(void) * * Descrip: Equivalent to AssemblyOpaqueTypeSet_alloc_len(AssemblyOpaqueTypeSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AssemblyOpaqueTypeSet *] * */ AssemblyOpaqueTypeSet * Wise2_AssemblyOpaqueTypeSet_alloc_std(void); #define AssemblyOpaqueTypeSet_alloc_std Wise2_AssemblyOpaqueTypeSet_alloc_std /* Function: AssemblyOpaqueTypeSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueTypeSet *] * */ AssemblyOpaqueTypeSet * Wise2_AssemblyOpaqueTypeSet_alloc_len(int len); #define AssemblyOpaqueTypeSet_alloc_len Wise2_AssemblyOpaqueTypeSet_alloc_len /* Function: hard_link_AssemblyOpaqueTypeSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblyOpaqueTypeSet *] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueTypeSet *] * */ AssemblyOpaqueTypeSet * Wise2_hard_link_AssemblyOpaqueTypeSet(AssemblyOpaqueTypeSet * obj); #define hard_link_AssemblyOpaqueTypeSet Wise2_hard_link_AssemblyOpaqueTypeSet /* Function: AssemblyOpaqueTypeSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblyOpaqueTypeSet *] * */ AssemblyOpaqueTypeSet * Wise2_AssemblyOpaqueTypeSet_alloc(void); #define AssemblyOpaqueTypeSet_alloc Wise2_AssemblyOpaqueTypeSet_alloc /* Function: free_AssemblyOpaqueTypeSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblyOpaqueTypeSet *] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueTypeSet *] * */ AssemblyOpaqueTypeSet * Wise2_free_AssemblyOpaqueTypeSet(AssemblyOpaqueTypeSet * obj); #define free_AssemblyOpaqueTypeSet Wise2_free_AssemblyOpaqueTypeSet /* Function: hard_link_AssemblyOpaqueFeature(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblyOpaqueFeature *] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueFeature *] * */ AssemblyOpaqueFeature * Wise2_hard_link_AssemblyOpaqueFeature(AssemblyOpaqueFeature * obj); #define hard_link_AssemblyOpaqueFeature Wise2_hard_link_AssemblyOpaqueFeature /* Function: AssemblyOpaqueFeature_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblyOpaqueFeature *] * */ AssemblyOpaqueFeature * Wise2_AssemblyOpaqueFeature_alloc(void); #define AssemblyOpaqueFeature_alloc Wise2_AssemblyOpaqueFeature_alloc /* Function: free_AssemblyOpaqueFeature(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblyOpaqueFeature *] * * Return [UNKN ] Undocumented return value [AssemblyOpaqueFeature *] * */ AssemblyOpaqueFeature * Wise2_free_AssemblyOpaqueFeature(AssemblyOpaqueFeature * obj); #define free_AssemblyOpaqueFeature Wise2_free_AssemblyOpaqueFeature /* Function: add_AssemblySequence(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AssemblySequence *] * Arg: add [OWNER] Object to add to the list [AssemblySequenceEdit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_AssemblySequence(AssemblySequence * obj,AssemblySequenceEdit * add); #define add_AssemblySequence Wise2_add_AssemblySequence /* Function: flush_AssemblySequence(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AssemblySequence *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_AssemblySequence(AssemblySequence * obj); #define flush_AssemblySequence Wise2_flush_AssemblySequence /* Function: add_opq_AssemblySequence(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AssemblySequence *] * Arg: add [OWNER] Object to add to the list [AssemblyOpaqueFeature *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_opq_AssemblySequence(AssemblySequence * obj,AssemblyOpaqueFeature * add); #define add_opq_AssemblySequence Wise2_add_opq_AssemblySequence /* Function: flush_opq_AssemblySequence(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AssemblySequence *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_opq_AssemblySequence(AssemblySequence * obj); #define flush_opq_AssemblySequence Wise2_flush_opq_AssemblySequence /* Function: AssemblySequence_alloc_std(void) * * Descrip: Equivalent to AssemblySequence_alloc_len(AssemblySequenceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AssemblySequence *] * */ AssemblySequence * Wise2_AssemblySequence_alloc_std(void); #define AssemblySequence_alloc_std Wise2_AssemblySequence_alloc_std /* Function: AssemblySequence_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AssemblySequence *] * */ AssemblySequence * Wise2_AssemblySequence_alloc_len(int len); #define AssemblySequence_alloc_len Wise2_AssemblySequence_alloc_len /* Function: hard_link_AssemblySequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblySequence *] * * Return [UNKN ] Undocumented return value [AssemblySequence *] * */ AssemblySequence * Wise2_hard_link_AssemblySequence(AssemblySequence * obj); #define hard_link_AssemblySequence Wise2_hard_link_AssemblySequence /* Function: AssemblySequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblySequence *] * */ AssemblySequence * Wise2_AssemblySequence_alloc(void); #define AssemblySequence_alloc Wise2_AssemblySequence_alloc /* Function: free_AssemblySequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblySequence *] * * Return [UNKN ] Undocumented return value [AssemblySequence *] * */ AssemblySequence * Wise2_free_AssemblySequence(AssemblySequence * obj); #define free_AssemblySequence Wise2_free_AssemblySequence /* Function: hard_link_AssemblySequencePlacement(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblySequencePlacement *] * * Return [UNKN ] Undocumented return value [AssemblySequencePlacement *] * */ AssemblySequencePlacement * Wise2_hard_link_AssemblySequencePlacement(AssemblySequencePlacement * obj); #define hard_link_AssemblySequencePlacement Wise2_hard_link_AssemblySequencePlacement /* Function: AssemblySequencePlacement_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblySequencePlacement *] * */ AssemblySequencePlacement * Wise2_AssemblySequencePlacement_alloc(void); #define AssemblySequencePlacement_alloc Wise2_AssemblySequencePlacement_alloc /* Function: free_AssemblySequencePlacement(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblySequencePlacement *] * * Return [UNKN ] Undocumented return value [AssemblySequencePlacement *] * */ AssemblySequencePlacement * Wise2_free_AssemblySequencePlacement(AssemblySequencePlacement * obj); #define free_AssemblySequencePlacement Wise2_free_AssemblySequencePlacement /* Function: add_AssemblyContig(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AssemblyContig *] * Arg: add [OWNER] Object to add to the list [AssemblySequencePlacement *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_AssemblyContig(AssemblyContig * obj,AssemblySequencePlacement * add); #define add_AssemblyContig Wise2_add_AssemblyContig /* Function: flush_AssemblyContig(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AssemblyContig *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_AssemblyContig(AssemblyContig * obj); #define flush_AssemblyContig Wise2_flush_AssemblyContig /* Function: AssemblyContig_alloc_std(void) * * Descrip: Equivalent to AssemblyContig_alloc_len(AssemblyContigLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AssemblyContig *] * */ AssemblyContig * Wise2_AssemblyContig_alloc_std(void); #define AssemblyContig_alloc_std Wise2_AssemblyContig_alloc_std /* Function: AssemblyContig_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AssemblyContig *] * */ AssemblyContig * Wise2_AssemblyContig_alloc_len(int len); #define AssemblyContig_alloc_len Wise2_AssemblyContig_alloc_len /* Function: hard_link_AssemblyContig(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblyContig *] * * Return [UNKN ] Undocumented return value [AssemblyContig *] * */ AssemblyContig * Wise2_hard_link_AssemblyContig(AssemblyContig * obj); #define hard_link_AssemblyContig Wise2_hard_link_AssemblyContig /* Function: AssemblyContig_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblyContig *] * */ AssemblyContig * Wise2_AssemblyContig_alloc(void); #define AssemblyContig_alloc Wise2_AssemblyContig_alloc /* Function: free_AssemblyContig(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblyContig *] * * Return [UNKN ] Undocumented return value [AssemblyContig *] * */ AssemblyContig * Wise2_free_AssemblyContig(AssemblyContig * obj); #define free_AssemblyContig Wise2_free_AssemblyContig /* Function: add_Assembly(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Assembly *] * Arg: add [OWNER] Object to add to the list [AssemblyContig *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_Assembly(Assembly * obj,AssemblyContig * add); #define add_Assembly Wise2_add_Assembly /* Function: flush_Assembly(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Assembly *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_Assembly(Assembly * obj); #define flush_Assembly Wise2_flush_Assembly /* Function: add_chaff_Assembly(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Assembly *] * Arg: add [OWNER] Object to add to the list [AssemblySequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_chaff_Assembly(Assembly * obj,AssemblySequence * add); #define add_chaff_Assembly Wise2_add_chaff_Assembly /* Function: flush_chaff_Assembly(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Assembly *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_chaff_Assembly(Assembly * obj); #define flush_chaff_Assembly Wise2_flush_chaff_Assembly /* Function: Assembly_alloc_std(void) * * Descrip: Equivalent to Assembly_alloc_len(AssemblyLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Assembly *] * */ Assembly * Wise2_Assembly_alloc_std(void); #define Assembly_alloc_std Wise2_Assembly_alloc_std /* Function: Assembly_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Assembly *] * */ Assembly * Wise2_Assembly_alloc_len(int len); #define Assembly_alloc_len Wise2_Assembly_alloc_len /* Function: hard_link_Assembly(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Assembly *] * * Return [UNKN ] Undocumented return value [Assembly *] * */ Assembly * Wise2_hard_link_Assembly(Assembly * obj); #define hard_link_Assembly Wise2_hard_link_Assembly /* Function: Assembly_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Assembly *] * */ Assembly * Wise2_Assembly_alloc(void); #define Assembly_alloc Wise2_Assembly_alloc /* Function: free_Assembly(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Assembly *] * * Return [UNKN ] Undocumented return value [Assembly *] * */ Assembly * Wise2_free_Assembly(Assembly * obj); #define free_Assembly Wise2_free_Assembly /* Function: hard_link_AssemblyOutputPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblyOutputPara *] * * Return [UNKN ] Undocumented return value [AssemblyOutputPara *] * */ AssemblyOutputPara * Wise2_hard_link_AssemblyOutputPara(AssemblyOutputPara * obj); #define hard_link_AssemblyOutputPara Wise2_hard_link_AssemblyOutputPara /* Function: AssemblyOutputPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblyOutputPara *] * */ AssemblyOutputPara * Wise2_AssemblyOutputPara_alloc(void); #define AssemblyOutputPara_alloc Wise2_AssemblyOutputPara_alloc /* Function: free_AssemblyOutputPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblyOutputPara *] * * Return [UNKN ] Undocumented return value [AssemblyOutputPara *] * */ AssemblyOutputPara * Wise2_free_AssemblyOutputPara(AssemblyOutputPara * obj); #define free_AssemblyOutputPara Wise2_free_AssemblyOutputPara /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_show_help_AssemblyOutputPara(FILE * ofp); #define show_help_AssemblyOutputPara Wise2_show_help_AssemblyOutputPara AssemblyOutputPara * Wise2_new_AssemblyOutputPara_from_argv(int * argc,char ** argv); #define new_AssemblyOutputPara_from_argv Wise2_new_AssemblyOutputPara_from_argv AssemblyOpaqueTypeSet * Wise2_homopolymer_AssemblyOpaqueTypeSet(void); #define homopolymer_AssemblyOpaqueTypeSet Wise2_homopolymer_AssemblyOpaqueTypeSet int Wise2_annotate_AssemblyOpaqueFeatures(AssemblyOpaqueTypeSet * aots,AssemblySequence * aseq,int kmer_size); #define annotate_AssemblyOpaqueFeatures Wise2_annotate_AssemblyOpaqueFeatures void Wise2_show_AssemblySequence(AssemblySequence * aseq,FILE * ofp); #define show_AssemblySequence Wise2_show_AssemblySequence AssemblyOpaqueType * Wise2_new_homopolymer_AssemblyOpaqueType(int int_type,char base); #define new_homopolymer_AssemblyOpaqueType Wise2_new_homopolymer_AssemblyOpaqueType AssemblySequence * Wise2_read_plain_fasta_AssemblySequence(FILE * ifp,int report_log,FILE * report); #define read_plain_fasta_AssemblySequence Wise2_read_plain_fasta_AssemblySequence AssemblySequence * Wise2_mirrored_AssemblySequence(AssemblySequence * aseq); #define mirrored_AssemblySequence Wise2_mirrored_AssemblySequence void Wise2_dump_contigs_as_fasta_Assembly(Assembly * assembly,AssemblyOutputPara * aop,FILE * ofp); #define dump_contigs_as_fasta_Assembly Wise2_dump_contigs_as_fasta_Assembly /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_AssemblyOpaqueTypeSet(AssemblyOpaqueType ** list,int i,int j) ; #define swap_AssemblyOpaqueTypeSet Wise2_swap_AssemblyOpaqueTypeSet void Wise2_qsort_AssemblyOpaqueTypeSet(AssemblyOpaqueType ** list,int left,int right,int (*comp)(AssemblyOpaqueType * ,AssemblyOpaqueType * )); #define qsort_AssemblyOpaqueTypeSet Wise2_qsort_AssemblyOpaqueTypeSet void Wise2_sort_AssemblyOpaqueTypeSet(AssemblyOpaqueTypeSet * obj,int (*comp)(AssemblyOpaqueType *, AssemblyOpaqueType *)); #define sort_AssemblyOpaqueTypeSet Wise2_sort_AssemblyOpaqueTypeSet boolean Wise2_expand_AssemblyOpaqueTypeSet(AssemblyOpaqueTypeSet * obj,int len); #define expand_AssemblyOpaqueTypeSet Wise2_expand_AssemblyOpaqueTypeSet void Wise2_swap_AssemblySequence(AssemblySequenceEdit ** list,int i,int j) ; #define swap_AssemblySequence Wise2_swap_AssemblySequence void Wise2_qsort_AssemblySequence(AssemblySequenceEdit ** list,int left,int right,int (*comp)(AssemblySequenceEdit * ,AssemblySequenceEdit * )); #define qsort_AssemblySequence Wise2_qsort_AssemblySequence void Wise2_sort_AssemblySequence(AssemblySequence * obj,int (*comp)(AssemblySequenceEdit *, AssemblySequenceEdit *)); #define sort_AssemblySequence Wise2_sort_AssemblySequence boolean Wise2_expand_AssemblySequence(AssemblySequence * obj,int len); #define expand_AssemblySequence Wise2_expand_AssemblySequence void Wise2_swap_opq_AssemblySequence(AssemblyOpaqueFeature ** list,int i,int j) ; #define swap_opq_AssemblySequence Wise2_swap_opq_AssemblySequence void Wise2_qsort_opq_AssemblySequence(AssemblyOpaqueFeature ** list,int left,int right,int (*comp)(AssemblyOpaqueFeature * ,AssemblyOpaqueFeature * )); #define qsort_opq_AssemblySequence Wise2_qsort_opq_AssemblySequence void Wise2_sort_opq_AssemblySequence(AssemblySequence * obj,int (*comp)(AssemblyOpaqueFeature *, AssemblyOpaqueFeature *)); #define sort_opq_AssemblySequence Wise2_sort_opq_AssemblySequence boolean Wise2_expand_opq_AssemblySequence(AssemblySequence * obj,int len); #define expand_opq_AssemblySequence Wise2_expand_opq_AssemblySequence void Wise2_swap_AssemblyContig(AssemblySequencePlacement ** list,int i,int j) ; #define swap_AssemblyContig Wise2_swap_AssemblyContig void Wise2_qsort_AssemblyContig(AssemblySequencePlacement ** list,int left,int right,int (*comp)(AssemblySequencePlacement * ,AssemblySequencePlacement * )); #define qsort_AssemblyContig Wise2_qsort_AssemblyContig void Wise2_sort_AssemblyContig(AssemblyContig * obj,int (*comp)(AssemblySequencePlacement *, AssemblySequencePlacement *)); #define sort_AssemblyContig Wise2_sort_AssemblyContig boolean Wise2_expand_AssemblyContig(AssemblyContig * obj,int len); #define expand_AssemblyContig Wise2_expand_AssemblyContig void Wise2_swap_Assembly(AssemblyContig ** list,int i,int j) ; #define swap_Assembly Wise2_swap_Assembly void Wise2_qsort_Assembly(AssemblyContig ** list,int left,int right,int (*comp)(AssemblyContig * ,AssemblyContig * )); #define qsort_Assembly Wise2_qsort_Assembly void Wise2_sort_Assembly(Assembly * obj,int (*comp)(AssemblyContig *, AssemblyContig *)); #define sort_Assembly Wise2_sort_Assembly boolean Wise2_expand_Assembly(Assembly * obj,int len); #define expand_Assembly Wise2_expand_Assembly void Wise2_swap_chaff_Assembly(AssemblySequence ** list,int i,int j) ; #define swap_chaff_Assembly Wise2_swap_chaff_Assembly void Wise2_qsort_chaff_Assembly(AssemblySequence ** list,int left,int right,int (*comp)(AssemblySequence * ,AssemblySequence * )); #define qsort_chaff_Assembly Wise2_qsort_chaff_Assembly void Wise2_sort_chaff_Assembly(Assembly * obj,int (*comp)(AssemblySequence *, AssemblySequence *)); #define sort_chaff_Assembly Wise2_sort_chaff_Assembly boolean Wise2_expand_chaff_Assembly(Assembly * obj,int len); #define expand_chaff_Assembly Wise2_expand_chaff_Assembly #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/findbad_kmer.c0000644000175000001440000000734410117345736017222 0ustar philippusers #include "../models/version.h" #include "kmer_direct.h" #include "kmer_hash.h" #include "kmer_glib_index.h" #include "singleseqspace.h" #include "kmer_count.h" char * program_name = "findbad_kmer"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s fasta-file\n",program_name); fprintf(ofp,"Kmer options\n"); fprintf(ofp," -min_count 4 minimum count for reporting\n"); fprintf(ofp," -kmer [12] kmer size for kmer-graph\n"); fprintf(ofp," -[no]use_hash [default no] use 28bit hash for large kmer sizes\n"); fprintf(ofp," -[no]use_glib [default no] use glib based pure hash, up to 15mers\n"); } int main(int argc,char ** argv) { KmerCountAllocator * kca; KmerCount * count; char buffer[200]; KmerIndexInterface * kii; FILE * ifp; Sequence * seq; Sequence * tseq; char c; int kmer_size = 12; boolean use_28bithash = 0; boolean use_glib = 0; boolean show_stdout = TRUE; int min_count = 4; int rev; SinglePosSpace * sps; kmer_t next_number; long int i; int j; char * seq_str; strip_out_integer_argument(&argc,argv,"kmer",&kmer_size); strip_out_boolean_def_argument(&argc,argv,"use_hash",&use_28bithash); strip_out_boolean_def_argument(&argc,argv,"use_glib",&use_glib); strip_out_integer_argument(&argc,argv,"min_count",&min_count); if( argc != 2 ) { show_help(stdout); exit(12); } kca = new_KmerCountAllocator(); if( use_28bithash == TRUE ) { kii = new_KmerHashIndex(kmer_size); } else if( use_glib == TRUE ) { kii = new_interface_KmerGlibIndex(kmer_size); } else { kii = new_KmerDirectIndex(kmer_size); } sps = new_SinglePosSpace(1,2000); ifp = openfile(argv[1],"r"); if( ifp == NULL ) { fatal("Could not open file %s",argv[1]); } while( (seq = read_fasta_Sequence(ifp)) != NULL ) { fprintf(stderr,"Handling sequence %s\n",seq->name); for(rev =0;rev < 2;rev++) { if( rev == 1 ) { tseq = seq; seq = reverse_complement_Sequence(seq); free_Sequence(tseq); } for(i=0;ilen - kii->kmer_size;i++) { for(j=0;j< kii->kmer_size+1;j++) { c = toupper(seq->seq[(int)(i+j)]); if( c != 'A' && c != 'T' && c != 'G' && c != 'C' ) { break; } } if( j < kii->kmer_size+1 ) { continue; } seq_str = seq->seq; /* fprintf(stderr,"Handling sequence %s.. %d\n",seq->name,i);*/ next_number = forward_dna_number_from_string(seq_str+i, kii->kmer_size); count = (KmerCount*) (*kii->retrieve_by_kmer)(kii->handle,next_number); if( count != NULL ) { count->count++; } else { count = new_KmerCount_KmerCountAllocator(kca); count->count = 1; (*kii->insert_by_kmer)(kii->handle,next_number,count); } } } free_Sequence(seq); } if( show_stdout ) { next_number = -1; while( (next_number = (*kii->next_filled_kmer)(kii->handle,next_number)) != -1 ) { /* fprintf(stderr,"Traversed with %ld\n",next_number); */ count = (KmerCount*) (*kii->retrieve_by_kmer)(kii->handle,next_number); if( count->count >= min_count ) { reverse_map_dna_number(next_number,kii->kmer_size,buffer); buffer[kii->kmer_size] = '\0'; fprintf(stdout,"%s %d\n",buffer,count->count); } } } return 0; } wise-2.4.1/src/dnaindex/largeseqreader.c0000644000175000001440000000403010670453716017572 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "largeseqreader.h" #include # line 15 "largeseqreader.dy" Sequence * read_large_dna_Sequence_file(char * filename,int report,FILE * logfp) { Sequence * out; FILE * ifp; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %d as a filename",filename); return NULL; } out = read_large_dna_Sequence(ifp,report,logfp); fclose(ifp); return out; } # line 34 "largeseqreader.dy" Sequence * read_large_dna_Sequence(FILE * ifp,int report,FILE * logfp) { Sequence * out; char * seqbuffer; long maxlen; long current; char c; char name[512]; c = fgetc(ifp); if( c == EOF ) { return NULL; } if( c != '>' ) { warn("First character not >, %c, not FASTA",c); return NULL; } current =0; while( (c=fgetc(ifp)) != EOF ) { if( isspace(c) ) { break; } name[current++] = c; } name[current] = '\0'; if( c != '\n' ) { while( (c=fgetc(ifp)) != EOF ) { if( c == '\n' ) { break; } } } current = 0; seqbuffer = calloc(4096,sizeof(char)); maxlen = 4096; while( (c=fgetc(ifp)) != EOF ) { if( c == '>' ) { break; } if( !isalpha(c) ) { continue; } if( logfp != NULL && report > 0 && current % report == 0) { fprintf(logfp,"Loaded %ld positions into %s\n",current,name); fflush(logfp); } if( current >= maxlen-1 ) { if( maxlen < LINEAR_LARGEFASTA_READ ) { seqbuffer = realloc(seqbuffer,maxlen*2*sizeof(char)); maxlen = maxlen * 2; } else { seqbuffer = realloc(seqbuffer,(maxlen+ LINEAR_LARGEFASTA_READ)*sizeof(char)); maxlen = maxlen + LINEAR_LARGEFASTA_READ; } } seqbuffer[current++] = c; } seqbuffer[current] = '\0'; if( c == '>' ) { ungetc(c,ifp); } out = Sequence_alloc(); out->name = stringalloc(name); out->seq = seqbuffer; out->len = current; out->maxlen = maxlen; out->type = SEQUENCE_DNA; return out; } # line 112 "largeseqreader.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/largeseqreader.h0000644000175000001440000000207410670453716017605 0ustar philippusers#ifndef DYNAMITElargeseqreaderHEADERFILE #define DYNAMITElargeseqreaderHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #define LINEAR_LARGEFASTA_READ 50000000 /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Unplaced functions */ /* There has been no indication of the use of these functions */ Sequence * Wise2_read_large_dna_Sequence_file(char * filename,int report,FILE * logfp); #define read_large_dna_Sequence_file Wise2_read_large_dna_Sequence_file Sequence * Wise2_read_large_dna_Sequence(FILE * ifp,int report,FILE * logfp); #define read_large_dna_Sequence Wise2_read_large_dna_Sequence /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/kwise.c0000644000175000001440000001121710064313520015714 0ustar philippusers#include "../models/version.h" #include "assembly_stream_cons.h" #include "kmer_direct.h" #include "kmer_hash.h" #include "kmer_glib_index.h" #include "kmer_assembly_untangler.h" #include "kmer_assembly_error.h" #include "kmer_assembly_contig.h" #include "assembly.h" char * program_name = "kwise"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s \n",program_name); fprintf(ofp," assembles sequences into contigs\n"); fprintf(ofp,"Kmer options\n"); fprintf(ofp," -kmer [12] kmer size for kmer-graph\n"); fprintf(ofp," -[no]use_hash [default no] use 28bit hash for large kmer sizes\n"); fprintf(ofp," -[no]use_glib [default no] use glib based pure hash, up to 15mers\n"); fprintf(ofp,"Read entry control\n"); fprintf(ofp," -read_no [number] maximum number of reads to enter (useful for debugging)\n"); show_help_AssemblyStreamConstructor(ofp); fprintf(ofp,"Statistics and Logging options\n"); fprintf(ofp," -stats write kmer index stats to file\n"); show_standard_options(ofp); } int main(int argc,char ** argv) { KmerAssemblyContigPara * p; KmerIndexInterface * kii; KmerAssemblyIndex * kai; int kmer_size = 12; boolean use_28bithash = 0; boolean use_glib = 0; int read_no = 0; long int r = 0; boolean add_rev = 1; boolean remove_error = 1; char * stats_file; FILE * stats = NULL; SinglePosSpace * sps; AssemblyStreamConstructor * acs; AssemblySequenceStream * ass; AssemblySequence * aseq; AssemblySequence * mirror; Assembly * assembly; char * fasta_read = NULL; FILE * fasta_read_fp = NULL; /* no options, and have to have at least one option */ if( argc == 1 ) { show_help(stdout); exit(12); } acs = new_AssemblyStreamConstructor_from_argv(&argc,argv); strip_out_integer_argument(&argc,argv,"kmer",&kmer_size); strip_out_boolean_def_argument(&argc,argv,"use_hash",&use_28bithash); strip_out_boolean_def_argument(&argc,argv,"use_glib",&use_glib); strip_out_boolean_def_argument(&argc,argv,"both",&add_rev); strip_out_boolean_def_argument(&argc,argv,"error",&remove_error); stats_file = strip_out_assigned_argument(&argc,argv,"stats"); fasta_read = strip_out_assigned_argument(&argc,argv,"fasta_read"); strip_out_integer_argument(&argc,argv,"read_no",&read_no); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 1 ) { show_help(stdout); exit(12); } if( fasta_read != NULL ) { fasta_read_fp = openfile(fasta_read,"w"); if( fasta_read_fp == NULL ) { fatal("Asked for a read stream in %s, but unable to open as read file...",fasta_read); } } p = KmerAssemblyContigPara_alloc(); p->minimum_len = 0; p->minimum_depth = 1; ass = new_AssemblySequenceStream_from_AssemblyStreamConstructor(acs); if( stats_file != NULL ) { stats = openfile(stats_file,"w"); if( stats == NULL ) { fatal("Could not open stats file [%s]",stats_file); } } if( use_28bithash == TRUE ) { kii = new_KmerHashIndex(kmer_size); } else if( use_glib == TRUE ) { kii = new_interface_KmerGlibIndex(kmer_size); } else { kii = new_KmerDirectIndex(kmer_size); } sps = new_SinglePosSpace(1,2000); kai = new_KmerAssemblyIndex(kii,sps); while( (aseq = (*ass->next_AssemblySequence)(ass->handle)) ) { fprintf(stderr,"Loading in %s\n",aseq->seq->name); if( fasta_read_fp != NULL ) { write_fasta_Sequence(aseq->seq,fasta_read_fp); } add_AssemblySequence_KmerAssemblyIndex(kai,aseq,1000000); if( add_rev == 1 ) { mirror = mirrored_AssemblySequence(aseq); add_AssemblySequence_KmerAssemblyIndex(kai,mirror,1000000); } r++; if( read_no > 0 && r > read_no) { break; } } if( remove_error == 1 ) { resolve_forward_errors_KmerAssembly(kai,1,1,250); remove_errors_KmerAssemblyIndex(kai,1); } untangle_KmerAssembly(kai); mark_tangles_KmerAssembly(kai); assembly = Assembly_from_KmerAssemblyIndex(kai,p); if( stats != NULL) show_extensive_stats_KmerAssemblyIndex(kai,stats); dump_contigs_as_fasta_Assembly(assembly,stdout); return 0; } wise-2.4.1/src/dnaindex/test_euler.c0000644000175000001440000000615007706577312016771 0ustar philippusers#include "eulerindex.h" int main(int argc,char ** argv) { EulerGraph * eg; Sequence * dna; int i; int j; eg = new_EulerGraph(13); while( (dna = read_fasta_Sequence(stdin)) != NULL ) { store_Sequence_EulerGraph(eg,dna); } for(i=0;inode_len;i++) { if( eg->node[i] != NULL && eg->node[i]->link_len > 1) { for(j=0;jnode[i]->link_len;j++) { if( eg->node[i]->link[j]->depth == 1 ) { fprintf(stderr,"Link has depth %d\n",eg->node[i]->link[j]->depth); if( can_resolve_error_EulerGraph(eg,eg->node[i]->link[j]) ) { fprintf(stderr,"....resolving...\n"); if( resolve_error_EulerGraph(eg,eg->node[i]->link[j]) == FALSE ) { remove_EulerLink_forward_EulerNode(eg->node[i],eg->node[i]->link[j]); } } else { remove_EulerLink_forward_EulerNode(eg->node[i],eg->node[i]->link[j]); } } } } } /* removing remaining single links etc */ for(i=0;inode_len;i++) { if( eg->node[i] != NULL && eg->node[i]->link_len > 1) { for(j=0;jnode[i]->link_len;j++) { if( eg->node[i]->link[j]->depth < 10 ) { remove_EulerLink_forward_EulerNode(eg->node[i],eg->node[i]->link[j]); j--; } } } if( eg->node[i] != NULL && eg->node[i]->back_len > 1) { for(j=0;jnode[i]->back_len;j++) { if( eg->node[i]->back[j]->depth < 10 ) { fprintf(stderr,"...REMOVING... %d (%d)\n",i,eg->node[i]->back_len); remove_EulerLink_backward_EulerNode(eg->node[i],eg->node[i]->back[j]); j--; fprintf(stderr," ...now %d (%d)\n",i,eg->node[i]->back_len); } } } } /* here goes the tangles... */ for(i=0;inode_len;i++) { if( eg->node[i] != NULL && (eg->node[i]->link_len > 1 || eg->node[i]->back_len > 1)) { fprintf(stderr,"BEFORE UNTANGLE:%d has leaving %d and joining %d\n",eg->node[i]->number,eg->node[i]->link_len,eg->node[i]->back_len); for(j=0;jnode[i]->link_len;j++) { fprintf(stderr,"...link has %d depth\n",eg->node[i]->link[j]->depth); } for(j=0;jnode[i]->back_len;j++) { fprintf(stderr,"...back has %d depth\n",eg->node[i]->back[j]->depth); } } } for(i=0;inode_len;i++) { if( eg->node[i] != NULL && eg->node[i]->link_len > 1 ) { fprintf(stderr,"MAIN: Attempting to untangle %d\n",i); untangle_from_split_EulerNode(eg,eg->node[i],100); } } for(i=0;inode_len;i++) { if( eg->node[i] != NULL && (eg->node[i]->link_len > 1 || eg->node[i]->back_len > 1)) { fprintf(stderr,"AFTER UNTANGLE:%d has leaving %d and joining %d\n",eg->node[i]->number,eg->node[i]->link_len,eg->node[i]->back_len); } } /* this artificially breaks at tangles */ /* for(i=0;inode_len;i++) { if( eg->node[i] != NULL && eg->node[i]->link_len > 1 ) { warn("Breaking at tangle at %d\n",i); for(j=0;jnode[i]->link_len;j++) { eg->node[i]->link[j]->next->is_leftmost = 1; } } } */ for(i=0;inode_len;i++) { if( eg->node[i] != NULL && eg->node[i]->is_leftmost == 1 ) { dna = read_Sequence_EulerNode(eg->node[i]); write_fasta_Sequence(dna,stdout); free_Sequence(dna); } } } wise-2.4.1/src/dnaindex/kmer_direct.c0000644000175000001440000000353310670453716017103 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "kmer_direct.h" # line 18 "kmer_direct.dy" KmerIndexInterface * new_KmerDirectIndex(int kmer_size) { KmerIndexInterface * out; KmerDirectIndex * kdi; kmer_t len = 1; int i; for(i=0;iindex = calloc(len,sizeof(void*)); if( kdi->index == NULL ) { warn("could not build index of size %lld pointers\n",len); return NULL; } kdi->index_length = len; out = malloc(sizeof(KmerIndexInterface)); out->retrieve_by_kmer = retrieve_by_kmer_KmerDirectIndex; out->insert_by_kmer = insert_by_kmer_KmerDirectIndex; out->free_handle = free_KmerDirectIndex; out->next_filled_kmer = next_filled_kmer_KmerDirectIndex; out->handle = (void*) kdi; out->kmer_size = kmer_size; return out; } # line 52 "kmer_direct.dy" kmer_t next_filled_kmer_KmerDirectIndex(void * handle,kmer_t kmer) { KmerDirectIndex * ind = (KmerDirectIndex*) handle; assert(ind); for(kmer++;kmer < ind->index_length;kmer++) { if( ind->index[kmer] != NULL ) { return kmer; } } return -1; } # line 68 "kmer_direct.dy" void * retrieve_by_kmer_KmerDirectIndex(void * handle,kmer_t kmer) { KmerDirectIndex * ind = (KmerDirectIndex*) handle; assert(ind != NULL); assert(kmer < ind->index_length); return ind->index[kmer]; } # line 78 "kmer_direct.dy" boolean insert_by_kmer_KmerDirectIndex(void * handle,kmer_t kmer,void * poi) { KmerDirectIndex * in = (KmerDirectIndex*) handle; assert(in != NULL); assert(kmer < in->index_length); in->index[kmer] = poi; return TRUE; } # line 89 "kmer_direct.dy" void free_KmerDirectIndex(void * handle) { KmerDirectIndex * in = (KmerDirectIndex*) handle; assert(in); free(in->index); free(in); return; } # line 89 "kmer_direct.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/kmer_direct.h0000644000175000001440000000277510670453716017117 0ustar philippusers#ifndef DYNAMITEkmer_directHEADERFILE #define DYNAMITEkmer_directHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "kmer_index_interface.h" typedef struct KmerDirectIndex { void ** index; kmer_t index_length; } KmerDirectIndex; /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Unplaced functions */ /* There has been no indication of the use of these functions */ KmerIndexInterface * Wise2_new_KmerDirectIndex(int kmer_size); #define new_KmerDirectIndex Wise2_new_KmerDirectIndex kmer_t Wise2_next_filled_kmer_KmerDirectIndex(void * handle,kmer_t kmer); #define next_filled_kmer_KmerDirectIndex Wise2_next_filled_kmer_KmerDirectIndex void * Wise2_retrieve_by_kmer_KmerDirectIndex(void * handle,kmer_t kmer); #define retrieve_by_kmer_KmerDirectIndex Wise2_retrieve_by_kmer_KmerDirectIndex boolean Wise2_insert_by_kmer_KmerDirectIndex(void * handle,kmer_t kmer,void * poi); #define insert_by_kmer_KmerDirectIndex Wise2_insert_by_kmer_KmerDirectIndex void Wise2_free_KmerDirectIndex(void * handle); #define free_KmerDirectIndex Wise2_free_KmerDirectIndex /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/make_shotgun.pl0000644000175000001440000000225410117345736017465 0ustar philippusers use Bio::SeqIO; my $seqin = Bio::SeqIO->new( -format => 'fasta'); my $seqout = Bio::SeqIO->new( -file => '>-' ); my $seq_size = shift; if( ! defined $seq_size ) { print STDERR "no read size set, going to use 500\n"; $seq_size = 500; } my $coverage = shift; if( !defined $coverage ) { $coverage = 5; } my $seq = $seqin->next_seq(); my $error = 0; my $rev = 1; my $insert = 1; my $del = 1; my @alphabet = ('A' , 'T' , 'G' , 'C' ); my $reads = $seq->length * 5 / $seq_size; foreach my $i ( 1 .. $reads ) { $start = int(rand($seq->length-$seq_size)); my $subseq = $seq->trunc($start+1,$start+$seq_size); $subseq->id(($seq->id.".".$start.".".($start+$seq_size))); if( $error != 0 ) { my $seqstr = $subseq->seq(); foreach my $j ( 1 ..$seq_size ) { if( $random == 1 && int(rand(1000)) < 2 ) { my $new = $alphabet[int(rand(4))]; print STDERR "[$i] Randomising a position $j... ",substr($seqstr,$j,1)," to $new on ".$subseq->id,"\n"; substr($seqstr,$j,1) = $new; } } $subseq->seq($seqstr); } if( $rev != 0 ) { if( int(rand(10)) < 5 ) { $seq = $seq->revcom(); } } $seqout->write_seq($subseq); } wise-2.4.1/src/dnaindex/dnanumber.c0000644000175000001440000001163510670453716016570 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dnanumber.h" # line 23 "dnanumber.dy" DnaNumberSequence * new_DnaNumberSequence(Sequence * seq,int nmer_size) { int i; DnaNumberSequence * out; assert(seq); out = DnaNumberSequence_alloc(); out->seq = malloc(sizeof(DnaNumber)*seq->len); for(i=0;ilen;i++) out->seq[i] = dna_number_from_string(seq->seq+i,nmer_size); out->orig = hard_link_Sequence(seq); out->len = seq->len-nmer_size-1; return out; } # line 41 "dnanumber.dy" char first_char_from_dnanumber(int dnanumber,int nmer_size,int flipped) { int base = 1; int basepair; int power; int i; if( flipped == 1 ) { /* first number is therefore lowest bit */ basepair = dnanumber % 4; /* fprintf(stderr,"Going to use %d as number\n",basepair);*/ basepair = complement_base(basepair); return char_from_base(basepair); } else { for(i=0;i backward ) { out.flipped = 0; break; } if( backward > forward ) { out.flipped = 1; break; } } assert(out.flipped != 2); if( out.flipped == 0 ) { for(i=0;idynamite_hard_link++; return obj; } /* Function: DnaNumberSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaNumberSequence *] * */ DnaNumberSequence * DnaNumberSequence_alloc(void) { DnaNumberSequence * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaNumberSequence *) ckalloc (sizeof(DnaNumberSequence))) == NULL) { warn("DnaNumberSequence_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->seq = NULL; out->len = 0; out->orig = NULL; return out; } /* Function: free_DnaNumberSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaNumberSequence *] * * Return [UNKN ] Undocumented return value [DnaNumberSequence *] * */ DnaNumberSequence * free_DnaNumberSequence(DnaNumberSequence * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaNumberSequence obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->seq != NULL) free_DnaNumber(obj->seq); if( obj->orig != NULL) free_Sequence(obj->orig); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/dnanumber.h0000644000175000001440000000625510670453716016577 0ustar philippusers#ifndef DYNAMITEdnanumberHEADERFILE #define DYNAMITEdnanumberHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "codon.h" #include "sequence.h" typedef struct { int number; char flipped; } DnaNumber; struct Wise2_DnaNumberSequence { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DnaNumber * seq; int len; Sequence * orig; } ; /* DnaNumberSequence defined */ #ifndef DYNAMITE_DEFINED_DnaNumberSequence typedef struct Wise2_DnaNumberSequence Wise2_DnaNumberSequence; #define DnaNumberSequence Wise2_DnaNumberSequence #define DYNAMITE_DEFINED_DnaNumberSequence #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: free_DnaNumber(dn) * * Descrip: dummy free * * * Arg: dn [UNKN ] Undocumented argument [DnaNumber *] * * Return [UNKN ] Undocumented return value [DnaNumber *] * */ DnaNumber * Wise2_free_DnaNumber(DnaNumber * dn); #define free_DnaNumber Wise2_free_DnaNumber /* Function: hard_link_DnaNumberSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaNumberSequence *] * * Return [UNKN ] Undocumented return value [DnaNumberSequence *] * */ DnaNumberSequence * Wise2_hard_link_DnaNumberSequence(DnaNumberSequence * obj); #define hard_link_DnaNumberSequence Wise2_hard_link_DnaNumberSequence /* Function: DnaNumberSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaNumberSequence *] * */ DnaNumberSequence * Wise2_DnaNumberSequence_alloc(void); #define DnaNumberSequence_alloc Wise2_DnaNumberSequence_alloc /* Function: free_DnaNumberSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaNumberSequence *] * * Return [UNKN ] Undocumented return value [DnaNumberSequence *] * */ DnaNumberSequence * Wise2_free_DnaNumberSequence(DnaNumberSequence * obj); #define free_DnaNumberSequence Wise2_free_DnaNumberSequence /* Unplaced functions */ /* There has been no indication of the use of these functions */ DnaNumberSequence * Wise2_new_DnaNumberSequence(Sequence * seq,int nmer_size); #define new_DnaNumberSequence Wise2_new_DnaNumberSequence char Wise2_first_char_from_dnanumber(int dnanumber,int nmer_size,int flipped); #define first_char_from_dnanumber Wise2_first_char_from_dnanumber DnaNumber Wise2_dna_number_from_string(char * str,int nmer_size); #define dna_number_from_string Wise2_dna_number_from_string /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/singleseqspace.c0000644000175000001440000003614510670453716017626 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "singleseqspace.h" /* Function: lookup_Sequence_SinglePosSpace(space,pos) * * Descrip: New return using binary choping * * * Arg: space [UNKN ] Undocumented argument [SinglePosSpace *] * Arg: pos [UNKN ] Undocumented argument [long] * * Return [UNKN ] Undocumented return value [SinglePosSequence *] * */ # line 36 "singleseqspace.dy" SinglePosSequence * lookup_Sequence_SinglePosSpace(SinglePosSpace * space,long pos) { int index_pos; assert(pos < space->current_end); assert(pos >= 0); if( space->is_static != 0 ) { /* can make explicit calculation for position */ index_pos = (int) (pos / space->average_len); if( space->sns[index_pos]->start == -1 ) { /* was a padding position */ for(index_pos--;index_pos >= 0 && space->sns[index_pos]->start == -1;index_pos--) { /*fprintf(stderr,"Regressed %d with %d [pos %d]\n",index_pos,space->sns[index_pos]->start,pos);*/ } assert(index_pos >= 0 ); } if( space->sns[index_pos] == NULL ) { fatal("Going to return %d for %d with %d - max %d\n",index_pos,pos,space->average_len,space->current_end); } return space->sns[index_pos]; } assert(pos < space->current_end); index_pos = find_position_SinglePosSpace(space,0,space->len-1,pos); return space->sns[index_pos]; } /* Function: find_position_SinglePosSpace(space,lower,higher,position) * * Descrip: Recursive function for finding position * * * Arg: space [UNKN ] Undocumented argument [SinglePosSpace *] * Arg: lower [UNKN ] Undocumented argument [int] * Arg: higher [UNKN ] Undocumented argument [int] * Arg: position [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ # line 75 "singleseqspace.dy" int find_position_SinglePosSpace(SinglePosSpace * space,int lower,int higher,int position) { int mid; /* fprintf(stderr,"To find position %d Entering with.... %d to %d\n",position,lower,higher); */ if( lower+2 >= higher ) { if( position >= space->sns[lower]->start && position < space->sns[lower]->end ) return lower; if( position >= space->sns[higher]->start && position < space->sns[higher]->end ) return higher; } mid = (lower + (int)((higher-lower)/2)); if( position >= space->sns[mid]->start && position < space->sns[mid]->end ) return mid; if( position >= space->sns[mid]->end ) { /* top half */ return find_position_SinglePosSpace(space,mid,higher,position); } else { return find_position_SinglePosSpace(space,lower,mid,position); } } /* Function: add_Sequence_SinglePosSpace(space,length,data) * * Descrip: Adds a sequence to a single number space, giving out the start * position for this sequence * * * Arg: space [UNKN ] Undocumented argument [SinglePosSpace *] * Arg: length [UNKN ] Undocumented argument [long int] * Arg: data [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [long int] * */ # line 109 "singleseqspace.dy" long int add_Sequence_SinglePosSpace(SinglePosSpace * space,long int length,void * data) { int seq_size = 1; int i; SinglePosSequence * a; SinglePosSequence * dummy; assert(space); assert(data); assert(length >= 0); a = SinglePosSequence_alloc(); a->start = space->current_end; if( space->is_static != 0 ) { if( length > space->max_length ) { seq_size = (length / space->max_length) +1; } else { seq_size = 1; } a->end = space->current_end + (space->max_length*seq_size); space->average_len = space->max_length; } else { a->end = space->current_end + length; space->average_len = a->end / length; } a->data = data; add_SinglePosSpace(space,a); /* pad for long sequences */ if( seq_size > 1 ) { for(i=1;istart = -1; dummy->end = -1; dummy->data = NULL; add_SinglePosSpace(space,dummy); } } space->current_end = a->end; return a->start; } /* Function: new_SinglePosSpace(has_maxlen,max_length) * * Descrip: Provides a new single number space * * * Arg: has_maxlen [UNKN ] Undocumented argument [int] * Arg: max_length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SinglePosSpace *] * */ # line 163 "singleseqspace.dy" SinglePosSpace * new_SinglePosSpace(int has_maxlen,int max_length) { SinglePosSpace * out; out = SinglePosSpace_alloc_std(); out->is_static = has_maxlen; out->max_length = max_length; return out; } # line 181 "singleseqspace.c" /* Function: hard_link_SinglePosSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SinglePosSequence *] * * Return [UNKN ] Undocumented return value [SinglePosSequence *] * */ SinglePosSequence * hard_link_SinglePosSequence(SinglePosSequence * obj) { if( obj == NULL ) { warn("Trying to hard link to a SinglePosSequence object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SinglePosSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SinglePosSequence *] * */ SinglePosSequence * SinglePosSequence_alloc(void) { SinglePosSequence * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SinglePosSequence *) ckalloc (sizeof(SinglePosSequence))) == NULL) { warn("SinglePosSequence_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->end = 0; return out; } /* Function: free_SinglePosSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SinglePosSequence *] * * Return [UNKN ] Undocumented return value [SinglePosSequence *] * */ SinglePosSequence * free_SinglePosSequence(SinglePosSequence * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SinglePosSequence obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->data is linked in */ ckfree(obj); return NULL; } /* Function: swap_SinglePosSpace(list,i,j) * * Descrip: swap function: an internal for qsort_SinglePosSpace * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [SinglePosSequence **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SinglePosSpace(SinglePosSequence ** list,int i,int j) { SinglePosSequence * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SinglePosSpace(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SinglePosSpace which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [SinglePosSequence **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SinglePosSpace(SinglePosSequence ** list,int left,int right,int (*comp)(SinglePosSequence * ,SinglePosSequence * )) { int i,last; if( left >= right ) return; swap_SinglePosSpace(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SinglePosSpace (list,++last,i); } swap_SinglePosSpace (list,left,last); qsort_SinglePosSpace(list,left,last-1,comp); qsort_SinglePosSpace(list,last+1,right,comp); } /* Function: sort_SinglePosSpace(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SinglePosSpace * * * Arg: obj [UNKN ] Object containing list [SinglePosSpace *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SinglePosSpace(SinglePosSpace * obj,int (*comp)(SinglePosSequence *, SinglePosSequence *)) { qsort_SinglePosSpace(obj->sns,0,obj->len-1,comp); return; } /* Function: expand_SinglePosSpace(obj,len) * * Descrip: Really an internal function for add_SinglePosSpace * * * Arg: obj [UNKN ] Object which contains the list [SinglePosSpace *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SinglePosSpace(SinglePosSpace * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SinglePosSpace called with no need"); return TRUE; } if( (obj->sns = (SinglePosSequence ** ) ckrealloc (obj->sns,sizeof(SinglePosSequence *)*len)) == NULL) { warn("ckrealloc failed for expand_SinglePosSpace, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SinglePosSpace(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SinglePosSpace *] * Arg: add [OWNER] Object to add to the list [SinglePosSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SinglePosSpace(SinglePosSpace * obj,SinglePosSequence * add) { if( obj->len >= obj->maxlen) { if( expand_SinglePosSpace(obj,obj->len + SinglePosSpaceLISTLENGTH) == FALSE) return FALSE; } obj->sns[obj->len++]=add; return TRUE; } /* Function: flush_SinglePosSpace(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SinglePosSpace *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SinglePosSpace(SinglePosSpace * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->sns[i] != NULL) { free_SinglePosSequence(obj->sns[i]); obj->sns[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SinglePosSpace_alloc_std(void) * * Descrip: Equivalent to SinglePosSpace_alloc_len(SinglePosSpaceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SinglePosSpace *] * */ SinglePosSpace * SinglePosSpace_alloc_std(void) { return SinglePosSpace_alloc_len(SinglePosSpaceLISTLENGTH); } /* Function: SinglePosSpace_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SinglePosSpace *] * */ SinglePosSpace * SinglePosSpace_alloc_len(int len) { SinglePosSpace * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SinglePosSpace_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->sns = (SinglePosSequence ** ) ckcalloc (len,sizeof(SinglePosSequence *))) == NULL) { warn("Warning, ckcalloc failed in SinglePosSpace_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SinglePosSpace(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SinglePosSpace *] * * Return [UNKN ] Undocumented return value [SinglePosSpace *] * */ SinglePosSpace * hard_link_SinglePosSpace(SinglePosSpace * obj) { if( obj == NULL ) { warn("Trying to hard link to a SinglePosSpace object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SinglePosSpace_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SinglePosSpace *] * */ SinglePosSpace * SinglePosSpace_alloc(void) { SinglePosSpace * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SinglePosSpace *) ckalloc (sizeof(SinglePosSpace))) == NULL) { warn("SinglePosSpace_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->current_end = 0; out->sns = NULL; out->len = out->maxlen = 0; out->average_len = 0; out->is_static = 0; out->max_length = 1000; return out; } /* Function: free_SinglePosSpace(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SinglePosSpace *] * * Return [UNKN ] Undocumented return value [SinglePosSpace *] * */ SinglePosSpace * free_SinglePosSpace(SinglePosSpace * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SinglePosSpace obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->sns != NULL) { for(i=0;ilen;i++) { if( obj->sns[i] != NULL) free_SinglePosSequence(obj->sns[i]); } ckfree(obj->sns); } /* obj->last_accessed is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/singleseqspace.h0000644000175000001440000002102310670453716017620 0ustar philippusers#ifndef DYNAMITEsingleseqspaceHEADERFILE #define DYNAMITEsingleseqspaceHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #define SinglePosSpaceLISTLENGTH 1024 struct Wise2_SinglePosSequence { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif long start; long end; void * data; } ; /* SinglePosSequence defined */ #ifndef DYNAMITE_DEFINED_SinglePosSequence typedef struct Wise2_SinglePosSequence Wise2_SinglePosSequence; #define SinglePosSequence Wise2_SinglePosSequence #define DYNAMITE_DEFINED_SinglePosSequence #endif struct Wise2_SinglePosSpace { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif long current_end; SinglePosSequence ** sns; int len;/* len for above sns */ int maxlen; /* maxlen for above sns */ SinglePosSequence * last_accessed; int average_len; int is_static; int max_length; } ; /* SinglePosSpace defined */ #ifndef DYNAMITE_DEFINED_SinglePosSpace typedef struct Wise2_SinglePosSpace Wise2_SinglePosSpace; #define SinglePosSpace Wise2_SinglePosSpace #define DYNAMITE_DEFINED_SinglePosSpace #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: lookup_Sequence_SinglePosSpace(space,pos) * * Descrip: New return using binary choping * * * Arg: space [UNKN ] Undocumented argument [SinglePosSpace *] * Arg: pos [UNKN ] Undocumented argument [long] * * Return [UNKN ] Undocumented return value [SinglePosSequence *] * */ SinglePosSequence * Wise2_lookup_Sequence_SinglePosSpace(SinglePosSpace * space,long pos); #define lookup_Sequence_SinglePosSpace Wise2_lookup_Sequence_SinglePosSpace /* Function: find_position_SinglePosSpace(space,lower,higher,position) * * Descrip: Recursive function for finding position * * * Arg: space [UNKN ] Undocumented argument [SinglePosSpace *] * Arg: lower [UNKN ] Undocumented argument [int] * Arg: higher [UNKN ] Undocumented argument [int] * Arg: position [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_find_position_SinglePosSpace(SinglePosSpace * space,int lower,int higher,int position); #define find_position_SinglePosSpace Wise2_find_position_SinglePosSpace /* Function: add_Sequence_SinglePosSpace(space,length,data) * * Descrip: Adds a sequence to a single number space, giving out the start * position for this sequence * * * Arg: space [UNKN ] Undocumented argument [SinglePosSpace *] * Arg: length [UNKN ] Undocumented argument [long int] * Arg: data [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [long int] * */ long int Wise2_add_Sequence_SinglePosSpace(SinglePosSpace * space,long int length,void * data); #define add_Sequence_SinglePosSpace Wise2_add_Sequence_SinglePosSpace /* Function: new_SinglePosSpace(has_maxlen,max_length) * * Descrip: Provides a new single number space * * * Arg: has_maxlen [UNKN ] Undocumented argument [int] * Arg: max_length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SinglePosSpace *] * */ SinglePosSpace * Wise2_new_SinglePosSpace(int has_maxlen,int max_length); #define new_SinglePosSpace Wise2_new_SinglePosSpace /* Function: hard_link_SinglePosSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SinglePosSequence *] * * Return [UNKN ] Undocumented return value [SinglePosSequence *] * */ SinglePosSequence * Wise2_hard_link_SinglePosSequence(SinglePosSequence * obj); #define hard_link_SinglePosSequence Wise2_hard_link_SinglePosSequence /* Function: SinglePosSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SinglePosSequence *] * */ SinglePosSequence * Wise2_SinglePosSequence_alloc(void); #define SinglePosSequence_alloc Wise2_SinglePosSequence_alloc /* Function: free_SinglePosSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SinglePosSequence *] * * Return [UNKN ] Undocumented return value [SinglePosSequence *] * */ SinglePosSequence * Wise2_free_SinglePosSequence(SinglePosSequence * obj); #define free_SinglePosSequence Wise2_free_SinglePosSequence /* Function: add_SinglePosSpace(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SinglePosSpace *] * Arg: add [OWNER] Object to add to the list [SinglePosSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SinglePosSpace(SinglePosSpace * obj,SinglePosSequence * add); #define add_SinglePosSpace Wise2_add_SinglePosSpace /* Function: flush_SinglePosSpace(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SinglePosSpace *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SinglePosSpace(SinglePosSpace * obj); #define flush_SinglePosSpace Wise2_flush_SinglePosSpace /* Function: SinglePosSpace_alloc_std(void) * * Descrip: Equivalent to SinglePosSpace_alloc_len(SinglePosSpaceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SinglePosSpace *] * */ SinglePosSpace * Wise2_SinglePosSpace_alloc_std(void); #define SinglePosSpace_alloc_std Wise2_SinglePosSpace_alloc_std /* Function: SinglePosSpace_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SinglePosSpace *] * */ SinglePosSpace * Wise2_SinglePosSpace_alloc_len(int len); #define SinglePosSpace_alloc_len Wise2_SinglePosSpace_alloc_len /* Function: hard_link_SinglePosSpace(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SinglePosSpace *] * * Return [UNKN ] Undocumented return value [SinglePosSpace *] * */ SinglePosSpace * Wise2_hard_link_SinglePosSpace(SinglePosSpace * obj); #define hard_link_SinglePosSpace Wise2_hard_link_SinglePosSpace /* Function: SinglePosSpace_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SinglePosSpace *] * */ SinglePosSpace * Wise2_SinglePosSpace_alloc(void); #define SinglePosSpace_alloc Wise2_SinglePosSpace_alloc /* Function: free_SinglePosSpace(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SinglePosSpace *] * * Return [UNKN ] Undocumented return value [SinglePosSpace *] * */ SinglePosSpace * Wise2_free_SinglePosSpace(SinglePosSpace * obj); #define free_SinglePosSpace Wise2_free_SinglePosSpace /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_SinglePosSpace(SinglePosSequence ** list,int i,int j) ; #define swap_SinglePosSpace Wise2_swap_SinglePosSpace void Wise2_qsort_SinglePosSpace(SinglePosSequence ** list,int left,int right,int (*comp)(SinglePosSequence * ,SinglePosSequence * )); #define qsort_SinglePosSpace Wise2_qsort_SinglePosSpace void Wise2_sort_SinglePosSpace(SinglePosSpace * obj,int (*comp)(SinglePosSequence *, SinglePosSequence *)); #define sort_SinglePosSpace Wise2_sort_SinglePosSpace boolean Wise2_expand_SinglePosSpace(SinglePosSpace * obj,int len); #define expand_SinglePosSpace Wise2_expand_SinglePosSpace #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/makefile0000644000175000001440000000666010345256467016156 0ustar philippusers .SUFFIXES : .dy ASSEMBLY_OBJ = kmer_assembly.o \ kmer_index_interface.o \ kmer_direct.o \ kmer_hash.o \ kmer_count.o \ kmer_glib_index.o \ singleseqspace.o \ dnamapping.o \ largeseqreader.o \ kmer_assembly_untangler.o \ kmer_assembly_contig.o \ kmer_assembly_error.o \ assembly.o \ assembly_stream_interface.o \ assembly_stream_fasta.o \ assembly_sanger_project.o \ assembly_stream_cons.o \ compressed_protein_index.o all: $(ASSEMBLY_OBJ) kwise : kwise.o $(ASSEMBLY_OBJ) $(CC) -o kwise kwise.o $(ASSEMBLY_OBJ) -ldyna -lwisebase $(LFLAGS) `glib-config --libs` arraymatcher : arraymatcher.o $(ASSEMBLY_OBJ) $(CC) -o arraymatcher arraymatcher.o $(ASSEMBLY_OBJ) -ldyna -lwisebase $(LFLAGS) `glib-config --libs` findbad_kmer : findbad_kmer.o $(ASSEMBLY_OBJ) $(CC) -o findbad_kmer findbad_kmer.o $(ASSEMBLY_OBJ) -ldyna -lwisebase $(LFLAGS) `glib-config --libs` make_shotgun : make_shotgun.o shotgun.o $(CC) -o make_shotgun make_shotgun.o shotgun.o -ldyna -lwisebase $(LFLAGS) test_dnanumber : test_dnanumber.o dnanumber.o $(CC) -o test_dnanumber test_dnanumber.o dnanumber.o -ldyna -lwisebase $(LFLAGS) test_linkindex : test_linkindex.o linkindex.o dnanumber.o $(CC) -o test_linkindex test_linkindex.o linkindex.o dnanumber.o -ldyna -lwisebase $(LFLAGS) test_forwardindex : test_forwardindex.o forwardindex.o $(CC) -o test_forwardindex test_forwardindex.o forwardindex.o -ldyna -lwisebase $(LFLAGS) test_euler : test_euler.o eulerindex.o singleseqspace.o $(CC) -o test_euler test_euler.o eulerindex.o singleseqspace.o -ldyna -lwisebase $(LFLAGS) test_kmer : test_kmer.o kmer_assembly.o kmer_index_interface.o kmer_direct.o singleseqspace.o dnamapping.o largeseqreader.o kmer_assembly_untangler.o kmer_assembly_contig.o kmer_assembly_error.o assembly.o $(CC) -o test_kmer test_kmer.o kmer_assembly.o kmer_index_interface.o kmer_direct.o singleseqspace.o dnamapping.o largeseqreader.o kmer_assembly_untangler.o kmer_assembly_error.o kmer_assembly_contig.o assembly.o -ldyna -lwisebase $(LFLAGS) kmer_stat : kmer_stat.o kmer_assembly.o kmer_index_interface.o kmer_direct.o singleseqspace.o dnamapping.o largeseqreader.o $(CC) -o kmer_stat kmer_stat.o kmer_assembly.o kmer_index_interface.o kmer_direct.o singleseqspace.o dnamapping.o largeseqreader.o -ldyna -lwisebase $(LFLAGS) test_compara : test_compara.o comparapath.o dnamapping.o singleseqspace.o chhash.o largeseqreader.o kmer_direct.o kmer_hash.o $(CC) -o test_compara test_compara.o comparapath.o dnamapping.o singleseqspace.o chhash.o largeseqreader.o kmer_direct.o kmer_hash.o -ldyna -lwisebase $(LFLAGS) bigseqwise : bigseqwise.o comparapath.o dnamapping.o singleseqspace.o chhash.o largeseqreader.o kmer_direct.o kmer_hash.o $(CC) -o bigseqwise bigseqwise.o comparapath.o dnamapping.o singleseqspace.o chhash.o largeseqreader.o kmer_direct.o kmer_hash.o -ldyna -lwisebase $(LFLAGS) show_euler : show_euler.o eulerindex.o singleseqspace.o $(CC) -o show_euler show_euler.o eulerindex.o singleseqspace.o -ldyna -lwisebase $(LFLAGS) CC = cc CFLAGS = -pthread -c -DHAS_PTHREAD_SETSCOPE -g -DUNIX -I../base/ -I../dynlibsrc/ `glib-config --cflags` LFLAGS = -g -L../base/ -L../dynlibsrc/ -lpthread `glib-config --libs` -lm .c.o : $(CC) $(CFLAGS) $(INCFLAGS) $? INCFLAGS = -I../base/ -I../dynlibsrc/ -I../models DFLAGS = -l -n Wise2_ -pthreads -dbtrace 5 -nocwarn .dy.c : dyc $(DFLAGS) $< .dy.o : dyc $(DFLAGS) $< $(CC) $(CFLAGS) $*.c init : dyc $(DFLAGS) *.dy wise-2.4.1/src/dnaindex/chhash.c0000644000175000001440000000425207711230343016037 0ustar philippusers#include #include #include "chhash.h" void chhash_init_bucket( CHBucket *b ){ b->num_entries = 0; b->buffer_size = 0; b->entry = NULL; b->index = NULL; } void chhash_fini_bucket( CHBucket *b ){ free(b->index); free(b->entry); } void chhash_init_hash( CHHash *hash ){ int i; hash->bucket = (CHBucket*)malloc(sizeof(CHBucket)*CHHASH_ENTRIES); if(!hash->bucket){ fprintf(stderr, "Cannot allocate buckets\n"); exit(1); } for(i = 0; i < CHHASH_ENTRIES; ++i){ chhash_init_bucket(&(hash->bucket[i])); } } void chhash_fini_hash( CHHash *hash ){ int i; for(i = 0; i < CHHASH_ENTRIES; ++i){ chhash_fini_bucket(&(hash->bucket[i])); } free(hash->bucket); } void chhash_bucket_put( CHBucket *b, ComparaHead *ch, long long pos ){ int i; for(i = 0; i < b->num_entries; ++i){ if(b->index[i] == pos){ b->entry[i] = ch; return; } } if(b->num_entries >= b->buffer_size){ b->buffer_size += 1024; b->entry = realloc(b->entry, sizeof(struct ComparaHead*)*b->buffer_size); if(!b->entry){ exit(1); } b->index = realloc(b->index, sizeof(long long)*b->buffer_size); if(!b->index){ exit(1); } } b->entry[b->num_entries] = ch; b->index[b->num_entries] = pos; b->num_entries++; } ComparaHead *chhash_bucket_get( CHBucket *b, long long pos ){ int i; for(i = 0; i < b->num_entries; ++i){ if(b->index[i] == pos){ return b->entry[i]; } } return NULL; } void chhash_put( CHHash *h, ComparaHead *ch, long long pos ){ long long bno = pos & CHHASH_MASK; chhash_bucket_put(&h->bucket[bno], ch, pos); } ComparaHead *chhash_get( CHHash *h, long long pos ){ long long bno = pos & CHHASH_MASK; return chhash_bucket_get(&h->bucket[bno], pos); } void chhash_stats( CHHash *hash ){ int i; int empty = 0; CHBucket *b; printf("Hash chains longer than 1\n"); for(i = 0; i < CHHASH_ENTRIES; ++i){ b = &(hash->bucket[i]); if(b->num_entries == 0){ empty++; continue; } if(b->num_entries > 1){ printf("%12d: %d ", i, b->num_entries); } } printf("\n"); printf("Empty Chains: %d/%d\n", empty, CHHASH_ENTRIES); } wise-2.4.1/src/dnaindex/chhash.h0000644000175000001440000000141207711231571016043 0ustar philippusers#ifndef CHHASH_H #define CHHASH_H #define CHHASH_BITS 24 #define CHHASH_MASK 0x0000000000ffffffL #define CHHASH_ENTRIES 16777216 typedef struct ComparaHead ComparaHead; typedef struct chbucket { int num_entries; int buffer_size; struct ComparaHead **entry; long long *index; } CHBucket; typedef struct chhash { CHBucket *bucket; } CHHash; void chhash_init_bucket(CHBucket*); void chhash_fini_bucket(CHBucket*); void chhash_init_hash(CHHash*); void chhash_fini_hash(CHHash*); void chhash_bucket_put(CHBucket*, ComparaHead*, long long pos); ComparaHead *chhash_bucket_get(CHBucket*, long long pos); void chhash_put(CHHash*, ComparaHead*, long long pos); ComparaHead *chhash_get(CHHash*, long long pos); void chhash_stats(CHHash*); #endif /* !CHHASH_H */ wise-2.4.1/src/dnaindex/kmer_assembly_untangler.dy0000644000175000001440000005046310064313520021706 0ustar philippusers %{ #include "kmer_assembly.h" #define KmerAssemblyPath_MAX_STACK 1024 #define MAX_TANGLE_DEPTH 10000 %} struct KmerAssemblyPath KmerAssemblyLink ** stack int stack_len int max_stack boolean right_tail boolean left_tail struct KmerTangleResolver long int start_label[MAX_TANGLE_DEPTH] SinglePosSequence * start_pos[MAX_TANGLE_DEPTH] !link int distance_to_end[MAX_TANGLE_DEPTH] int max_end int label_len int max_path %{ #include "kmer_assembly_untangler.h" void show_KmerAssemblyPath(KmerAssemblyIndex * kai,KmerAssemblyPath * kap,FILE * ofp) { int i; char forw[512]; char back[512]; for(i=0;istack_len;i++) { reverse_map_dna_number(kap->stack[i]->prev->number,kai->kii->kmer_size,back); reverse_map_dna_number(kap->stack[i]->next->number,kai->kii->kmer_size,forw); back[kai->kii->kmer_size] ='\0'; forw[kai->kii->kmer_size] ='\0'; fprintf(ofp,"%3d memory %d, from [%s] to [%s], base %c\n",i,(int)kap->stack[i],back,forw,kap->stack[i]->base); } } void push_KmerAssemblyPath(KmerAssemblyPath * kap,KmerAssemblyLink * kal) { assert(kap != NULL); assert(kal != NULL); if( kap->stack_len >= kap->max_stack) { fatal("Bugger it. Max stack over flow, could be made growable. Complain to Ewan... ;)"); } kap->stack[kap->stack_len++] = kal; } KmerAssemblyLink * pop_KmerAssemblyPath(KmerAssemblyPath * kap) { assert(kap != NULL); if( kap->stack_len <= 0 ) { return NULL; } return kap->stack[kap->stack_len--]; } KmerAssemblyPath * new_KmerAssemblyPath(void) { KmerAssemblyPath * out; out = KmerAssemblyPath_alloc(); out->stack = (KmerAssemblyLink**) calloc(KmerAssemblyPath_MAX_STACK,sizeof(KmerAssemblyLink*)); out->stack_len = 0; out->max_stack = KmerAssemblyPath_MAX_STACK; return out; } int untangle_KmerAssembly(KmerAssemblyIndex * kai) { int total = 0; int i; kmer_t kmer; KmerAssemblyNode * node; KmerAssemblyLink * link_set[1024]; int node_len; char buffer[256]; int fully_untangled = 0; assert(kai != NULL); assert(kai->kii != NULL ); assert(kai->kii->next_filled_kmer != NULL); kmer = -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); if( node->next_len > 1 || node->prev_len > 1 ) { reverse_map_dna_number(node->number,kai->kii->kmer_size,buffer); buffer[kai->kii->kmer_size] = '\0'; fprintf(stderr,"TANGLE: Node %ld, %s has forward %d and back %d links\n",node->number,buffer,node->next_len,node->prev_len); } if( node->prev_len < 2 ) { continue; } if( node->prev_len > 1024 ) { fatal("Insane - over 1024 possible back links, can't cope"); } /* we have to put this into temporary memory*/ for(i=0;iprev_len;i++) { link_set[i] = node->prev[i]; } node_len = node->prev_len; for(i=0;iprev[i]->prev->number,node->number); if( attempt_forward_untangle_KmerAssembly(kai,node->prev[i],500) == TRUE ) { total++; if( node->prev_len == 1 ) { fully_untangled = 1; /* fully untangled on left hand side. Assumme is ok on right side? * break this loop */ break; } } } reverse_map_dna_number(node->number,kai->kii->kmer_size,buffer); buffer[kai->kii->kmer_size] = '\0'; if( fully_untangled == 1 ) { fprintf(stderr,"RESOLVED: Node %ld [%s] Fully untangled now...\n",node->number,buffer); } else { fprintf(stderr,"UNRESOLVED: Node %ld [%s] still tangled...\n",node->number,buffer); } } return total; } boolean recursive_untangle_KmerAssembly(KmerTangleResolver * res,KmerAssemblyIndex * kai,KmerAssemblyLink * current,KmerAssemblyPath * p,int current_pos) { KmerAssemblyLink * temp_link[500]; int start_pos = current_pos; int j; int i; while( 1 ) { if( current_pos > res->max_path ) { return FALSE; } /* belts and braces; should never reach here */ if( current == NULL || current->next == NULL ) { warn("Belt and braces test to ensure no path overrun"); return FALSE; } /* if the link is simple, just move along. We might want to check all labels are still valid in here to find right tails */ /* no matter what the next decision is, this position is on the valid path. push into the temporary array */ temp_link[current_pos] = current; current_pos++; if( current->next->next_len == 1 ) { /* check that this is not a buried tail */ if( no_longer_active_KmerTangleResolver(res,current,current_pos) == TRUE ) { p->right_tail = TRUE; break; } current = current->next->next[0]; continue; } /* if is the end of this path, must be false */ if( current->next->next_len == 0 ) { return FALSE; } fprintf(stderr,"Looking at split node with %d outgoing paths\n",current->next->next_len); /* for each possible link out */ for(j=0;jnext->next_len;j++) { assert(current->next->next[j] != NULL); if( is_righthand_link_KmerTangleResolver(res,current->next->next[j],current_pos-1) == TRUE ) { fprintf(stderr,"Is valid!\n"); temp_link[current_pos] = current->next->next[j]; current_pos++; break; } } /* if j < length, then we have a valid rightside */ if( j < current->next->next_len ) { break; } /* no links are possible; recurse down links */ for(j=0;jnext->next_len;j++) { assert(current->next->next[j] != NULL); if( recursive_untangle_KmerAssembly(res,kai,current->next->next[j],p,current_pos) == TRUE ) { break; } } if( j < current->next->next_len ) { break; } else { /* done all possible recursions, return FALSE */ return FALSE; } } /* path is true; fill up path and return */ if( p->max_stack < current_pos ) { fatal("Path overflow, just need to extend data here. Talk to Ewan"); } if( p->stack_len < current_pos ) { p->stack_len = current_pos; } /* this puts the temporary links into the path structure for final use */ for(i=start_pos;istack[i] = temp_link[i]; } return TRUE; } KmerTangleResolver * new_KmerTangleResolver(KmerAssemblyIndex * kai,KmerAssemblyLink * leftmost,int max_path) { int i; KmerTangleResolver * out; if( leftmost->sequence_label_len > MAX_TANGLE_DEPTH ) { fatal("We need to move to dynamic memory for tangle resolver, have depth of %d\n",leftmost->sequence_label_len); } out = KmerTangleResolver_alloc(); out->max_end = 0; for(i=0;isequence_label_len;i++) { out->start_label[i] = leftmost->sequence_label[i]; out->start_pos[i] = lookup_Sequence_SinglePosSpace(kai->sps,leftmost->sequence_label[i]); out->distance_to_end[i] = ((Sequence*)out->start_pos[i]->data)->len - ((int)(out->start_label[i] - out->start_pos[i]->start)); if( out->distance_to_end[i] > out->max_end ) { out->max_end = out->distance_to_end[i]; } } out->label_len = leftmost->sequence_label_len; out->max_path = max_path; return out; } boolean no_longer_active_KmerTangleResolver(KmerTangleResolver * res,KmerAssemblyLink * current,int pathlen) { int i; int j; for(i=0;ilabel_len;i++) { for(j=0;jsequence_label_len;j++) { fprintf(stderr,"Comparing %ld to %ld (%d)\n",res->start_label[i]+pathlen,current->sequence_label[j]+1,pathlen); if( res->start_label[i]+pathlen == current->sequence_label[j]+1 ) { fprintf(stderr,"...returning FALSE...\n"); return FALSE; } } } fprintf(stderr,"Inactive Resolver!\n"); return TRUE; } boolean is_righthand_link_KmerTangleResolver(KmerTangleResolver * res,KmerAssemblyLink * rightside,int pathlen) { int i; int j; int start_label_ok[MAX_TANGLE_DEPTH]; assert(res->label_len < MAX_TANGLE_DEPTH); assert(rightside->sequence_label_len < MAX_TANGLE_DEPTH); /* have to find all transfered links */ for(i=0;ilabel_len;i++) { if( pathlen + res->start_label[i] >= res->start_pos[i]->start + ((Sequence*)(res->start_pos[i])->data)->len ) { start_label_ok[i] = 0; } else { start_label_ok[i] = -1; } } for(j=0;jsequence_label_len;j++) { for(i=0;ilabel_len;i++) { if( rightside->sequence_label[j] - res->start_label[i] == pathlen+1 ) { start_label_ok[i] = 1; break; } } } for(i=0;ilabel_len;i++) { if( start_label_ok[i] == -1 ) { return FALSE; } } return TRUE; } boolean attempt_forward_untangle_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyLink * left_input,int max_search) { KmerAssemblyPath * path; KmerAssemblyPath * newpath; KmerTangleResolver * kres; boolean ret = FALSE; path = new_KmerAssemblyPath(); kres = new_KmerTangleResolver(kai,left_input,max_search); if( recursive_untangle_KmerAssembly(kres,kai,left_input,path,0) == TRUE ) { ret = TRUE; fprintf(stderr,"Successful untangling...\n"); show_KmerAssemblyPath(kai,path,stderr); if( path->right_tail == TRUE ) { lift_forward_tangled_tail(kai,path,kres->start_label,kres->label_len); } else { newpath = lift_forward_tangled_KmerAssemblyPath(kai,path,kres->start_label,kres->label_len); } } fprintf(stderr,"returning from attempt\n"); free_KmerAssemblyPath(path); free_KmerAssemblyPath(newpath); free_KmerTangleResolver(kres); return ret; } boolean old_attempt_forward_untangle_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyLink * left_input,int max_search) { int i; int j; int k,l; int have_link; long int start_label[MAX_TANGLE_DEPTH]; long int end_label[MAX_TANGLE_DEPTH]; SinglePosSequence * start_pos[MAX_TANGLE_DEPTH]; SinglePosSequence * end_pos[MAX_TANGLE_DEPTH]; char buffer[128]; int start_len; int end_len; int pathlen = 0; long int transferred_label[MAX_TANGLE_DEPTH]; SinglePosSequence * transferred_pos[MAX_TANGLE_DEPTH]; int transferred_len; KmerAssemblyLink * current; KmerAssemblyPath * path; KmerAssemblyPath * newpath; assert(kai != NULL); assert(left_input != NULL); if( left_input->sequence_label_len > MAX_TANGLE_DEPTH ) { fatal("Ach, bugger it, overflow on fixed buffer length for forward untangle. Easily fixed; talk to Ewan"); } for(i=0;isequence_label_len;i++) { start_pos[i] = lookup_Sequence_SinglePosSpace(kai->sps,left_input->sequence_label[i]); start_label[i] = left_input->sequence_label[i]; } start_len = left_input->sequence_label_len; reverse_map_dna_number(left_input->next->number,kai->kii->kmer_size,buffer); buffer[kai->kii->kmer_size] = '\0'; fprintf(stderr,"Entering mapping code with %s depth %d\n",buffer,left_input->sequence_label_len); path = new_KmerAssemblyPath(); push_KmerAssemblyPath(path,left_input); for(pathlen=0,current = left_input;current != NULL && pathlen < max_search;) { fprintf(stderr,"looking at node %ld with path length %d, next length %d depth %d\n",current->next->number,pathlen,current->next->next_len,current->sequence_label_len); assert(current->next != NULL); if( current->next->next_len == 1 ) { pathlen++; current = current->next->next[0]; push_KmerAssemblyPath(path,current); continue; } if( current->next->next_len == 0 ) { return FALSE; } fprintf(stderr,"Looking at split out node %d, %d\n",current->next->next_len,pathlen); /* > 1, so should have our paths somewhere in here */ /* pull out exit sps... */ for(j=0;jnext->next_len;j++) { assert(current->next->next[j] != NULL); fprintf(stderr,"... paths are of size %d\n",pathlen); if( current->next->next[j]->sequence_label_len > MAX_TANGLE_DEPTH ) { warn("YIKES... unable to untangle, because over Max tangle depth, at %d\n",current->next->next[j]->sequence_label_len); return FALSE; } for(i=0;inext->next[j]->sequence_label_len;i++) { end_pos[i] = lookup_Sequence_SinglePosSpace(kai->sps,current->next->next[j]->sequence_label[i]); end_label[i] = current->next->next[j]->sequence_label[i]; } end_len = current->next->next[j]->sequence_label_len; transferred_len =0; have_link = 0; /* match pos to proposed, set labels to -1 when matched */ for(l=0;lnext->next[j]); newpath = lift_forward_tangled_KmerAssemblyPath(kai,path,transferred_label,transferred_len); /* we should check if we have any tails */ transferred_len = 0; have_link = 0; for(l=0;lkii->kmer_size,start_pos[l]->start,((Sequence*)start_pos[l]->data)->len); */ if( start_label[l] + pathlen + kai->kii->kmer_size > start_pos[l]->start + ((Sequence*)start_pos[l]->data)->len ) { /* yup, got a tail */ /* fprintf(stderr,"Got a tail label...\n"); */ transferred_label[transferred_len] = start_label[l]; transferred_pos[transferred_len] = start_pos[l]; transferred_len++; have_link = 1; } } if( have_link == 1 ) { /* fprintf(stderr," ..forward TAIL.. untangling...\n"); */ fatal("Duff function!"); } transferred_len = 0; have_link = 0; for(l=0;lstart ) { /* yup, got a tail */ transferred_label[transferred_len] = end_label[l]; transferred_pos[transferred_len] = end_pos[l]; transferred_len++; have_link = 1; } } if( have_link == 1 ) { /* fprintf(stderr," ..reverse TAIL.. untangling...\n"); */ lift_backward_tangled_tail(kai,newpath->stack[newpath->stack_len-1],path,transferred_label,transferred_pos,transferred_len); } /* pop off the top of this path */ pop_KmerAssemblyPath(path); free_KmerAssemblyPath(newpath); } /* fprintf(stderr,"Left input between %ld and %ld has depth %d\n",left_input->prev->number,left_input->next->number,left_input->sequence_label_len);*/ /* main loop around links; test whether starting link is empty */ if( left_input->sequence_label_len <= 0 ) { return TRUE; } /* currently we can't handle overbranching */ fprintf(stderr,"Currently we can't handle over-branching; returning FALSE...\n"); return FALSE; } return FALSE; } void lift_forward_tangled_tail(KmerAssemblyIndex * kai,KmerAssemblyPath * tail,long int * start_label,int label_len) { int i; int j; KmerAssemblyNode * prev; KmerAssemblyLink * link; KmerAssemblyNode * new_node; assert(kai != NULL); assert(tail != NULL); assert(start_label != NULL); assert(label_len > 0); prev = tail->stack[0]->prev; for(i=0;istack_len;i++) { if( i+1 != tail->stack_len ) { new_node = new_KmerAssemblyNode(tail->stack[i]->next->number); new_node->node_chain = tail->stack[i]->next->node_chain; tail->stack[i]->next->node_chain = new_node; } else { new_node = NULL; } link = new_KmerAssemblyLink(tail->stack[i]->base); add_next_KmerAssemblyNode(prev,link); if( new_node != NULL) { add_prev_KmerAssemblyNode(new_node,link); } link->prev = prev; link->next = new_node; for(j=0;jstack[i],start_label[j]+i); add_sequence_label_KmerAssemblyLink(link,start_label[j]+i); } if( tail->stack[i]->sequence_label_len == 0 ) { /* detach link */ remove_next_KmerAssemblyNode(tail->stack[i]->prev,tail->stack[i]); remove_prev_KmerAssemblyNode(tail->stack[i]->next,tail->stack[i]); } prev = new_node; } return; } void lift_backward_tangled_tail(KmerAssemblyIndex * kai,KmerAssemblyLink * new,KmerAssemblyPath * tail,int * start_label,SinglePosSequence ** positions,int label_len) { int i; int j; int k; assert(kai != NULL); assert(new != NULL); assert(tail != NULL); assert(start_label != NULL); assert(label_len > 0); i=0; k=0; while( 1) { /* check we have things to do */ for(j=0;j= positions[j]->start ) { break; } } if( j >= label_len ) { break; } /* lift out active sequences */ for(j=0;j= positions[j]->start ) { remove_sequence_label_KmerAssemblyLink(tail->stack[k],start_label[j]-i); add_sequence_label_KmerAssemblyLink(new,start_label[j]-i); } } /* remove link if needed */ if( tail->stack[k]->sequence_label_len == 0 ) { detach_KmerAssemblyLink(kai,tail->stack[k]); } /* advance links */ if( new->prev->prev_len > 1 ) { warn("VERY VERY BAD NEWS: in lifting a backward tail, new stream has more than one path"); } new = new->prev->prev[0]; k++; i++; if( new->prev->number != tail->stack[k]->prev->number ) { warn("IMPOSSIBLE: error! in lifting backward tail, old stream and new stream differ in numbers"); return; } } /* finished lift */ } KmerAssemblyPath * lift_forward_tangled_KmerAssemblyPath(KmerAssemblyIndex * kai,KmerAssemblyPath * kap,long int * start_label,int label_len) { int i,j; KmerAssemblyNode * new; KmerAssemblyNode * prev; KmerAssemblyLink * link; KmerAssemblyPath * out; char back[256]; char forw[256]; assert(kai != NULL); assert(kap != NULL); assert(start_label != NULL); assert(label_len > 0); out = new_KmerAssemblyPath(); prev = kap->stack[0]->prev; for(i=0;istack_len;i++) { reverse_map_dna_number(kap->stack[i]->prev->number,kai->kii->kmer_size,back); back[kai->kii->kmer_size] = '\0'; reverse_map_dna_number(kap->stack[i]->next->number,kai->kii->kmer_size,forw); forw[kai->kii->kmer_size] = '\0'; fprintf(stderr,"Moving stack position %d, depth %d, transfer %d, between %ld [%s] and %ld [%s]\n",i,kap->stack[i]->sequence_label_len,label_len,kap->stack[i]->prev->number,back,kap->stack[i]->next->number,forw); fprintf(stderr,"... Before transfer %d sequence labels and %d outgoing and %d incoming\n",kap->stack[i]->sequence_label_len,kap->stack[i]->prev->next_len,kap->stack[i]->next->prev_len); if( i+1 == kap->stack_len ) { /* last link --- has to be done differently as we attach it to the new place */ new = kap->stack[i]->next; } else { new = new_KmerAssemblyNode(kap->stack[i]->next->number); new->node_chain = kap->stack[i]->next->node_chain; kap->stack[i]->next->node_chain = new; } link = new_KmerAssemblyLink(kap->stack[i]->base); push_KmerAssemblyPath(out,link); add_next_KmerAssemblyNode(prev,link); add_prev_KmerAssemblyNode(new,link); link->prev = prev; link->next = new; for(j=0;jstack[i],start_label[j]+i); add_sequence_label_KmerAssemblyLink(link,start_label[j]+i); } if( kap->stack[i]->sequence_label_len == 0 ) { /* detach link */ remove_next_KmerAssemblyNode(kap->stack[i]->prev,kap->stack[i]); remove_prev_KmerAssemblyNode(kap->stack[i]->next,kap->stack[i]); fprintf(stderr,"...left with prev next_len %d and next prev_len %d\n",kap->stack[i]->prev->next_len,kap->stack[i]->next->prev_len); } else { fprintf(stderr,"...node is still live with %d sequence labels and %d outgoing and %d incoming\n",kap->stack[i]->sequence_label_len,kap->stack[i]->prev->next_len,kap->stack[i]->next->prev_len); } prev = new; } return out; } %} wise-2.4.1/src/dnaindex/kmer_assembly_contig.c0000644000175000001440000004765210670453716021025 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "kmer_assembly_contig.h" # line 34 "kmer_assembly_contig.dy" KmerAssemblyContig * find_strict_mirrored_KmerAssemblyContig(KmerAssemblyContigSet * kcs,KmerAssemblyContig * c) { int i; kmer_t start_rev; kmer_t end_rev; assert(kcs != NULL); assert(kcs->kai != NULL); assert(c != NULL); start_rev = reverse_complement_dna_number(c->start->number,kcs->kai->kii->kmer_size); end_rev = reverse_complement_dna_number(c->end->number,kcs->kai->kii->kmer_size); for(i=0;i < kcs->len;i++) { if( kcs->contig[i]->mirror != NULL || kcs->contig[i]->is_mirror == 1) { continue; } /* fprintf(stderr,"Looking at %ld,%ld vs %ld,%ld\n",kcs->contig[i]->start->number,start_rev,kcs->contig[i]->end->number,end_rev);*/ if( kcs->contig[i]->start->number == end_rev && kcs->contig[i]->end->number == start_rev ) { /* should check labels */ warn("Note to Ewan: Should check labels"); return kcs->contig[i]; } } return NULL; } # line 63 "kmer_assembly_contig.dy" KmerAssemblyContigSet * KmerAssemblyContigSet_from_KmerAssemblyIndex(KmerAssemblyIndex * kai) { KmerAssemblyContigSet * out; KmerAssemblyContigSet * final; kmer_t kmer; KmerAssemblyNode * node; KmerAssemblyContig * contig; boolean is_left_end; int i; assert(kai != NULL); assert(kai->kii != NULL ); assert(kai->kii->next_filled_kmer != NULL); out = KmerAssemblyContigSet_alloc_std(); out->kai = kai; kmer = -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); fprintf(stderr,"CONTIG BUILD\n"); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); for(;node != NULL; node = node->node_chain ) { if( node->next_len == 0 ) { continue; } /* test to see if it is start; no back link or all TANGLED links */ is_left_end = 0; if( node->prev_len == 0 ) { is_left_end = 1; /* this is the other main case, test before we do loop */ } else if( node->prev_len == 1 && !(node->prev[0]->state & KMER_ASSEMBLY_PREV_TANGLED) ) { is_left_end = 0; } else { for(i=0;iprev_len;i++) { fprintf(stderr,"Node position %d, state %d\n",i,node->prev[i]->state); if( !(node->prev[i]->state & KMER_ASSEMBLY_NEXT_TANGLED) ) { is_left_end = 0; break; } } if( i >= node->prev_len ) { is_left_end = 1; } } if( is_left_end == 0 && node->prev_len > 1 ) { fprintf(stderr,"Very weird: multi-prev but not left end, number is %d, state of 0 %d\n",node->prev_len,node->prev[0]->state); } if( is_left_end && node->next_len == 1) { contig = new_KmerAssemblyContig(node); add_KmerAssemblyContigSet(out,contig); } } } return out; } # line 130 "kmer_assembly_contig.dy" KmerAssemblyContig * new_KmerAssemblyContig(KmerAssemblyNode * node) { KmerAssemblyContig * out; KmerAssemblyLink * link; int len; assert(node != NULL); if( node->next_len != 1 ) { warn("Cannot build a KmerAssemblyContig from a node with %d out going links",node->next_len); } out = KmerAssemblyContig_alloc(); out->start = node; out->max_depth = 0; if( node->prev_len > 1 ) { out->clean_start = 0; } else { out->clean_start = 1; } len = 0; for(link = node->next[0];link != NULL && link->next->next_len == 1; link = link->next->next[0],len++) { if( link->state & KMER_ASSEMBLY_PREV_TANGLED ) { break; } if( link->prev->prev_len > 1 ) { fprintf(stderr,"Assembly is still tangled!"); break; /* bad end found */ } if( link->sequence_label_len > out->max_depth ) { out->max_depth = link->sequence_label_len; } } out->end = link->next; if( link->next->next_len != 0 ) { out->clean_end = 0; } else { out->clean_end = 1; } out->len = len; return out; } # line 183 "kmer_assembly_contig.dy" Assembly * Assembly_from_KmerAssemblyIndex(KmerAssemblyIndex * kai,KmerAssemblyContigPara * p) { Assembly * out; KmerAssemblyContigSet * kacs; KmerAssemblyContigSet * final; KmerAssemblyContig * mirror; int i; kacs = KmerAssemblyContigSet_from_KmerAssemblyIndex(kai); final = KmerAssemblyContigSet_alloc_std(); for(i=0;ilen;i++) { if( kacs->contig[i]->is_mirror == 1 ) { continue; } if( kacs->contig[i]->mirror == NULL ) { if( (mirror = find_strict_mirrored_KmerAssemblyContig(kacs,kacs->contig[i])) != NULL ) { kacs->contig[i]->mirror = hard_link_KmerAssemblyContig(mirror); mirror->is_mirror = 1; add_KmerAssemblyContigSet(final,hard_link_KmerAssemblyContig(kacs->contig[i])); } else { warn("Unable to mirror contig, adding anyway"); add_KmerAssemblyContigSet(final,hard_link_KmerAssemblyContig(kacs->contig[i])); } } } out = Assembly_from_KmerAssemblyContigSet(final,p); free_KmerAssemblyContigSet(kacs); free_KmerAssemblyContigSet(final); return out; } # line 221 "kmer_assembly_contig.dy" Assembly * Assembly_from_KmerAssemblyContigSet(KmerAssemblyContigSet * kacs,KmerAssemblyContigPara * p) { Assembly * out; AssemblyContig * ac; int i; assert(kacs != NULL); assert(p != NULL); out = Assembly_alloc_std(); for(i=0;ilen;i++) { if( kacs->contig[i]->len > p->minimum_len && kacs->contig[i]->max_depth >= p->minimum_depth ) { ac = AssemblyContig_from_KmerAssemblyContig(kacs->contig[i]); add_Assembly(out,ac); } } return out; } # line 242 "kmer_assembly_contig.dy" AssemblyContig * AssemblyContig_from_KmerAssemblyContig(KmerAssemblyContig * kac) { AssemblyContig * out; KmerAssemblyLink * link; Sequence * con; int i; char buffer[512]; con = Sequence_alloc(); con->seq = calloc(kac->len+1,sizeof(char)); con->len = kac->len; con->maxlen = con->len; sprintf(buffer,"contig_%ld",(long int)kac); con->name = stringalloc(buffer); out = AssemblyContig_alloc_std(); fprintf(stderr,"Starting contig fetching...\n"); for(i=0,link = kac->start->next[0] ;link != NULL && link->next->next_len == 1;link = link->next->next[0],i++) { con->seq[i] = link->base; /* NOT DEALING WITH READ PLACEMENT YET */ if( link->next == kac->end ) { break; } } out->clean_start = kac->clean_start; out->clean_end = kac->clean_end; out->max_depth = kac->max_depth; con->seq[i] = '\0'; con->len = strlen(con->seq); out->consensus = con; return out; } # line 263 "kmer_assembly_contig.c" /* Function: hard_link_KmerAssemblyContig(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerAssemblyContig *] * * Return [UNKN ] Undocumented return value [KmerAssemblyContig *] * */ KmerAssemblyContig * hard_link_KmerAssemblyContig(KmerAssemblyContig * obj) { if( obj == NULL ) { warn("Trying to hard link to a KmerAssemblyContig object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: KmerAssemblyContig_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerAssemblyContig *] * */ KmerAssemblyContig * KmerAssemblyContig_alloc(void) { KmerAssemblyContig * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(KmerAssemblyContig *) ckalloc (sizeof(KmerAssemblyContig))) == NULL) { warn("KmerAssemblyContig_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->len = 0; out->clean_start = FALSE; out->clean_end = FALSE; out->max_depth = 0; out->mirror = NULL; out->is_mirror = 0; return out; } /* Function: free_KmerAssemblyContig(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerAssemblyContig *] * * Return [UNKN ] Undocumented return value [KmerAssemblyContig *] * */ KmerAssemblyContig * free_KmerAssemblyContig(KmerAssemblyContig * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a KmerAssemblyContig obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->start is linked in */ /* obj->end is linked in */ if( obj->mirror != NULL) free_KmerAssemblyContig(obj->mirror); ckfree(obj); return NULL; } /* Function: swap_KmerAssemblyContigSet(list,i,j) * * Descrip: swap function: an internal for qsort_KmerAssemblyContigSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [KmerAssemblyContig **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_KmerAssemblyContigSet(KmerAssemblyContig ** list,int i,int j) { KmerAssemblyContig * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_KmerAssemblyContigSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_KmerAssemblyContigSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [KmerAssemblyContig **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_KmerAssemblyContigSet(KmerAssemblyContig ** list,int left,int right,int (*comp)(KmerAssemblyContig * ,KmerAssemblyContig * )) { int i,last; if( left >= right ) return; swap_KmerAssemblyContigSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_KmerAssemblyContigSet (list,++last,i); } swap_KmerAssemblyContigSet (list,left,last); qsort_KmerAssemblyContigSet(list,left,last-1,comp); qsort_KmerAssemblyContigSet(list,last+1,right,comp); } /* Function: sort_KmerAssemblyContigSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_KmerAssemblyContigSet * * * Arg: obj [UNKN ] Object containing list [KmerAssemblyContigSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_KmerAssemblyContigSet(KmerAssemblyContigSet * obj,int (*comp)(KmerAssemblyContig *, KmerAssemblyContig *)) { qsort_KmerAssemblyContigSet(obj->contig,0,obj->len-1,comp); return; } /* Function: expand_KmerAssemblyContigSet(obj,len) * * Descrip: Really an internal function for add_KmerAssemblyContigSet * * * Arg: obj [UNKN ] Object which contains the list [KmerAssemblyContigSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_KmerAssemblyContigSet(KmerAssemblyContigSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_KmerAssemblyContigSet called with no need"); return TRUE; } if( (obj->contig = (KmerAssemblyContig ** ) ckrealloc (obj->contig,sizeof(KmerAssemblyContig *)*len)) == NULL) { warn("ckrealloc failed for expand_KmerAssemblyContigSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_KmerAssemblyContigSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [KmerAssemblyContigSet *] * Arg: add [OWNER] Object to add to the list [KmerAssemblyContig *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_KmerAssemblyContigSet(KmerAssemblyContigSet * obj,KmerAssemblyContig * add) { if( obj->len >= obj->maxlen) { if( expand_KmerAssemblyContigSet(obj,obj->len + KmerAssemblyContigSetLISTLENGTH) == FALSE) return FALSE; } obj->contig[obj->len++]=add; return TRUE; } /* Function: flush_KmerAssemblyContigSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [KmerAssemblyContigSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_KmerAssemblyContigSet(KmerAssemblyContigSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->contig[i] != NULL) { free_KmerAssemblyContig(obj->contig[i]); obj->contig[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: KmerAssemblyContigSet_alloc_std(void) * * Descrip: Equivalent to KmerAssemblyContigSet_alloc_len(KmerAssemblyContigSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [KmerAssemblyContigSet *] * */ KmerAssemblyContigSet * KmerAssemblyContigSet_alloc_std(void) { return KmerAssemblyContigSet_alloc_len(KmerAssemblyContigSetLISTLENGTH); } /* Function: KmerAssemblyContigSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [KmerAssemblyContigSet *] * */ KmerAssemblyContigSet * KmerAssemblyContigSet_alloc_len(int len) { KmerAssemblyContigSet * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = KmerAssemblyContigSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->contig = (KmerAssemblyContig ** ) ckcalloc (len,sizeof(KmerAssemblyContig *))) == NULL) { warn("Warning, ckcalloc failed in KmerAssemblyContigSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_KmerAssemblyContigSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerAssemblyContigSet *] * * Return [UNKN ] Undocumented return value [KmerAssemblyContigSet *] * */ KmerAssemblyContigSet * hard_link_KmerAssemblyContigSet(KmerAssemblyContigSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a KmerAssemblyContigSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: KmerAssemblyContigSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerAssemblyContigSet *] * */ KmerAssemblyContigSet * KmerAssemblyContigSet_alloc(void) { KmerAssemblyContigSet * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(KmerAssemblyContigSet *) ckalloc (sizeof(KmerAssemblyContigSet))) == NULL) { warn("KmerAssemblyContigSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->contig = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_KmerAssemblyContigSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerAssemblyContigSet *] * * Return [UNKN ] Undocumented return value [KmerAssemblyContigSet *] * */ KmerAssemblyContigSet * free_KmerAssemblyContigSet(KmerAssemblyContigSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a KmerAssemblyContigSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->contig != NULL) { for(i=0;ilen;i++) { if( obj->contig[i] != NULL) free_KmerAssemblyContig(obj->contig[i]); } ckfree(obj->contig); } /* obj->kai is linked in */ ckfree(obj); return NULL; } /* Function: hard_link_KmerAssemblyContigPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerAssemblyContigPara *] * * Return [UNKN ] Undocumented return value [KmerAssemblyContigPara *] * */ KmerAssemblyContigPara * hard_link_KmerAssemblyContigPara(KmerAssemblyContigPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a KmerAssemblyContigPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: KmerAssemblyContigPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerAssemblyContigPara *] * */ KmerAssemblyContigPara * KmerAssemblyContigPara_alloc(void) { KmerAssemblyContigPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(KmerAssemblyContigPara *) ckalloc (sizeof(KmerAssemblyContigPara))) == NULL) { warn("KmerAssemblyContigPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->minimum_len = 50; out->minimum_depth = 1; return out; } /* Function: free_KmerAssemblyContigPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerAssemblyContigPara *] * * Return [UNKN ] Undocumented return value [KmerAssemblyContigPara *] * */ KmerAssemblyContigPara * free_KmerAssemblyContigPara(KmerAssemblyContigPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a KmerAssemblyContigPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/kmer_assembly_contig.h0000644000175000001440000002417210670453716021022 0ustar philippusers#ifndef DYNAMITEkmer_assembly_contigHEADERFILE #define DYNAMITEkmer_assembly_contigHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "kmer_assembly.h" #include "assembly.h" #define KmerAssemblyContigSetLISTLENGTH 256 #ifndef DYNAMITE_DEFINED_KmerAssemblyContig typedef struct Wise2_KmerAssemblyContig Wise2_KmerAssemblyContig; #define KmerAssemblyContig Wise2_KmerAssemblyContig #define DYNAMITE_DEFINED_KmerAssemblyContig #endif struct Wise2_KmerAssemblyContig { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif KmerAssemblyNode * start; KmerAssemblyNode * end; int len; boolean clean_start; boolean clean_end; int max_depth; KmerAssemblyContig * mirror; int is_mirror; } ; /* KmerAssemblyContig defined */ #ifndef DYNAMITE_DEFINED_KmerAssemblyContig typedef struct Wise2_KmerAssemblyContig Wise2_KmerAssemblyContig; #define KmerAssemblyContig Wise2_KmerAssemblyContig #define DYNAMITE_DEFINED_KmerAssemblyContig #endif struct Wise2_KmerAssemblyContigSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif KmerAssemblyContig ** contig; int len;/* len for above contig */ int maxlen; /* maxlen for above contig */ KmerAssemblyIndex * kai; } ; /* KmerAssemblyContigSet defined */ #ifndef DYNAMITE_DEFINED_KmerAssemblyContigSet typedef struct Wise2_KmerAssemblyContigSet Wise2_KmerAssemblyContigSet; #define KmerAssemblyContigSet Wise2_KmerAssemblyContigSet #define DYNAMITE_DEFINED_KmerAssemblyContigSet #endif struct Wise2_KmerAssemblyContigPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int minimum_len; int minimum_depth; } ; /* KmerAssemblyContigPara defined */ #ifndef DYNAMITE_DEFINED_KmerAssemblyContigPara typedef struct Wise2_KmerAssemblyContigPara Wise2_KmerAssemblyContigPara; #define KmerAssemblyContigPara Wise2_KmerAssemblyContigPara #define DYNAMITE_DEFINED_KmerAssemblyContigPara #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_KmerAssemblyContig(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerAssemblyContig *] * * Return [UNKN ] Undocumented return value [KmerAssemblyContig *] * */ KmerAssemblyContig * Wise2_hard_link_KmerAssemblyContig(KmerAssemblyContig * obj); #define hard_link_KmerAssemblyContig Wise2_hard_link_KmerAssemblyContig /* Function: KmerAssemblyContig_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerAssemblyContig *] * */ KmerAssemblyContig * Wise2_KmerAssemblyContig_alloc(void); #define KmerAssemblyContig_alloc Wise2_KmerAssemblyContig_alloc /* Function: free_KmerAssemblyContig(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerAssemblyContig *] * * Return [UNKN ] Undocumented return value [KmerAssemblyContig *] * */ KmerAssemblyContig * Wise2_free_KmerAssemblyContig(KmerAssemblyContig * obj); #define free_KmerAssemblyContig Wise2_free_KmerAssemblyContig /* Function: add_KmerAssemblyContigSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [KmerAssemblyContigSet *] * Arg: add [OWNER] Object to add to the list [KmerAssemblyContig *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_KmerAssemblyContigSet(KmerAssemblyContigSet * obj,KmerAssemblyContig * add); #define add_KmerAssemblyContigSet Wise2_add_KmerAssemblyContigSet /* Function: flush_KmerAssemblyContigSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [KmerAssemblyContigSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_KmerAssemblyContigSet(KmerAssemblyContigSet * obj); #define flush_KmerAssemblyContigSet Wise2_flush_KmerAssemblyContigSet /* Function: KmerAssemblyContigSet_alloc_std(void) * * Descrip: Equivalent to KmerAssemblyContigSet_alloc_len(KmerAssemblyContigSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [KmerAssemblyContigSet *] * */ KmerAssemblyContigSet * Wise2_KmerAssemblyContigSet_alloc_std(void); #define KmerAssemblyContigSet_alloc_std Wise2_KmerAssemblyContigSet_alloc_std /* Function: KmerAssemblyContigSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [KmerAssemblyContigSet *] * */ KmerAssemblyContigSet * Wise2_KmerAssemblyContigSet_alloc_len(int len); #define KmerAssemblyContigSet_alloc_len Wise2_KmerAssemblyContigSet_alloc_len /* Function: hard_link_KmerAssemblyContigSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerAssemblyContigSet *] * * Return [UNKN ] Undocumented return value [KmerAssemblyContigSet *] * */ KmerAssemblyContigSet * Wise2_hard_link_KmerAssemblyContigSet(KmerAssemblyContigSet * obj); #define hard_link_KmerAssemblyContigSet Wise2_hard_link_KmerAssemblyContigSet /* Function: KmerAssemblyContigSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerAssemblyContigSet *] * */ KmerAssemblyContigSet * Wise2_KmerAssemblyContigSet_alloc(void); #define KmerAssemblyContigSet_alloc Wise2_KmerAssemblyContigSet_alloc /* Function: free_KmerAssemblyContigSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerAssemblyContigSet *] * * Return [UNKN ] Undocumented return value [KmerAssemblyContigSet *] * */ KmerAssemblyContigSet * Wise2_free_KmerAssemblyContigSet(KmerAssemblyContigSet * obj); #define free_KmerAssemblyContigSet Wise2_free_KmerAssemblyContigSet /* Function: hard_link_KmerAssemblyContigPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerAssemblyContigPara *] * * Return [UNKN ] Undocumented return value [KmerAssemblyContigPara *] * */ KmerAssemblyContigPara * Wise2_hard_link_KmerAssemblyContigPara(KmerAssemblyContigPara * obj); #define hard_link_KmerAssemblyContigPara Wise2_hard_link_KmerAssemblyContigPara /* Function: KmerAssemblyContigPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerAssemblyContigPara *] * */ KmerAssemblyContigPara * Wise2_KmerAssemblyContigPara_alloc(void); #define KmerAssemblyContigPara_alloc Wise2_KmerAssemblyContigPara_alloc /* Function: free_KmerAssemblyContigPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerAssemblyContigPara *] * * Return [UNKN ] Undocumented return value [KmerAssemblyContigPara *] * */ KmerAssemblyContigPara * Wise2_free_KmerAssemblyContigPara(KmerAssemblyContigPara * obj); #define free_KmerAssemblyContigPara Wise2_free_KmerAssemblyContigPara /* Unplaced functions */ /* There has been no indication of the use of these functions */ KmerAssemblyContig * Wise2_find_strict_mirrored_KmerAssemblyContig(KmerAssemblyContigSet * kcs,KmerAssemblyContig * c); #define find_strict_mirrored_KmerAssemblyContig Wise2_find_strict_mirrored_KmerAssemblyContig KmerAssemblyContigSet * Wise2_KmerAssemblyContigSet_from_KmerAssemblyIndex(KmerAssemblyIndex * kai); #define KmerAssemblyContigSet_from_KmerAssemblyIndex Wise2_KmerAssemblyContigSet_from_KmerAssemblyIndex KmerAssemblyContig * Wise2_new_KmerAssemblyContig(KmerAssemblyNode * node); #define new_KmerAssemblyContig Wise2_new_KmerAssemblyContig Assembly * Wise2_Assembly_from_KmerAssemblyIndex(KmerAssemblyIndex * kai,KmerAssemblyContigPara * p); #define Assembly_from_KmerAssemblyIndex Wise2_Assembly_from_KmerAssemblyIndex Assembly * Wise2_Assembly_from_KmerAssemblyContigSet(KmerAssemblyContigSet * kacs,KmerAssemblyContigPara * p); #define Assembly_from_KmerAssemblyContigSet Wise2_Assembly_from_KmerAssemblyContigSet AssemblyContig * Wise2_AssemblyContig_from_KmerAssemblyContig(KmerAssemblyContig * kac); #define AssemblyContig_from_KmerAssemblyContig Wise2_AssemblyContig_from_KmerAssemblyContig /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_KmerAssemblyContigSet(KmerAssemblyContig ** list,int i,int j) ; #define swap_KmerAssemblyContigSet Wise2_swap_KmerAssemblyContigSet void Wise2_qsort_KmerAssemblyContigSet(KmerAssemblyContig ** list,int left,int right,int (*comp)(KmerAssemblyContig * ,KmerAssemblyContig * )); #define qsort_KmerAssemblyContigSet Wise2_qsort_KmerAssemblyContigSet void Wise2_sort_KmerAssemblyContigSet(KmerAssemblyContigSet * obj,int (*comp)(KmerAssemblyContig *, KmerAssemblyContig *)); #define sort_KmerAssemblyContigSet Wise2_sort_KmerAssemblyContigSet boolean Wise2_expand_KmerAssemblyContigSet(KmerAssemblyContigSet * obj,int len); #define expand_KmerAssemblyContigSet Wise2_expand_KmerAssemblyContigSet #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/kmer_assembly.dy0000644000175000001440000002774610011714154017637 0ustar philippusers %{ #include "kmer_index_interface.h" #include "singleseqspace.h" #include "assembly.h" #define KMER_ASSEMBLY_NEXT_TANGLED 2 #define KMER_ASSEMBLY_PREV_TANGLED 4 typedef struct KmerAssemblyLink { struct KmerAssemblyNode * prev; struct KmerAssemblyNode * next; char base; long * sequence_label; int sequence_label_len; int sequence_label_maxlen; char state; } KmerAssemblyLink; typedef struct KmerAssemblyNode { kmer_t number; struct KmerAssemblyLink ** prev; int prev_len; int prev_maxlen; struct KmerAssemblyLink ** next; int next_len; int next_maxlen; struct KmerAssemblyNode * node_chain; } KmerAssemblyNode; typedef struct KmerAssemblyIndex { KmerIndexInterface * kii; SinglePosSpace * sps; } KmerAssemblyIndex; #define KmerAssemblyNode_LINK_START 8 #define KmerAssemblyNode_LINK_LINEAR 64 #define KmerAssemblyLink_LABEL_START 2 #define KmerAssemblyLink_LABEL_LINEAR 8 %} %{ #include "kmer_assembly.h" void show_extensive_stats_KmerAssemblyIndex(KmerAssemblyIndex * kai,FILE * ofp) { int i; int j; int forward_splits [50]; int backward_splits [50]; kmer_t depth [50]; int link_2_lengths [50]; kmer_t total_numbers = 0; kmer_t total_links = 0; kmer_t kmer = -1; KmerAssemblyNode * node; KmerAssemblyLink * run; fprintf(stderr,"Intialising arrays...\n"); for(i=0;i<50;i++) { forward_splits[i] = backward_splits[i] = depth[i] = link_2_lengths[i] = 0; } kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { total_numbers++; node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); for(;node != NULL;node= node->node_chain ) { total_links += node->next_len; for(i=0;inext_len;i++) { if( node->next[i]->sequence_label_len > 45 ) { depth[45]++; } else { depth[node->next[i]->sequence_label_len]++; } } if( node->next_len > 1 ) { forward_splits[node->next_len]++; } if( node->prev_len > 1 ) { backward_splits[node->prev_len]++; } if( node->prev_len > 1 ) { if( node->next_len > 1 ) { link_2_lengths[0]++; } else { if( node->next_len == 1 ) { run = node->next[0]; for(j=1;run != NULL && j < 45 ;run = run->next->next[0],j++) { if( run->next->next_len > 1 ) { break; } if( run->next->next_len == 0 ) { break; } } link_2_lengths[j]++; } } } } } fprintf(ofp,"Coverage stats\n"); fprintf(ofp,"Depth %% of links at this depth\n"); for(i=0;i< 50;i++){ fprintf(ofp,"%3d %.2f%%\n",i,(100.0)*((double)depth[i]/(double)(total_links))); } fprintf(ofp,"\nSplits Forward Backward\n"); for(i=1; i < 50 ;i++) { fprintf(ofp,"%2d %4d %4d\n",i,forward_splits[i],backward_splits[i]); } fprintf(ofp,"\nDistribution of stream merge length\n"); fprintf(ofp,"Length Number\n"); for(i=0;i<50;i++) { fprintf(ofp,"%3d %4d\n",i,link_2_lengths[i]); } } void add_AssemblySequence_KmerAssemblyIndex(KmerAssemblyIndex * kai,AssemblySequence * aseq,int report) { kmer_t prev_number; kmer_t next_number; long int i; int j; char c; long start; char * seq_str; assert(kai != NULL); assert(aseq != NULL); assert(aseq->seq != NULL); start = add_Sequence_SinglePosSpace(kai->sps,aseq->seq->len,(void*)aseq); for(i=0;iseq->len-kai->kii->kmer_size;i++) { if( report != 0 && i % report == 0 && i != 0) { fprintf(stderr,"Loaded %ld positions in %s\n",i,aseq->seq->name); } for(j=0;jkii->kmer_size+1;j++) { c = toupper(aseq->seq->seq[i+j]); if( c != 'A' && c != 'T' && c != 'G' && c != 'C' ) { break; } } if( j < kai->kii->kmer_size+1 ) { continue; } seq_str = aseq->seq->seq; next_number = forward_dna_number_from_string(seq_str+i+1, kai->kii->kmer_size); prev_number = forward_dna_number_from_string(seq_str+i, kai->kii->kmer_size); /* fprintf(stderr,"Adding position %d %.*s...%ld,%ld\n",i,kai->kii->kmer_size+1,aseq->seq->seq+i,next_number,prev_number); */ store_KmerAssemblyLink_KmerAssemblyIndex(kai,prev_number,next_number,aseq->seq->seq[i+1],start+i+1); } return; } boolean store_KmerAssemblyLink_KmerAssemblyIndex(KmerAssemblyIndex * kai,kmer_t prev_number,kmer_t next_number,char base,long label) { int i; KmerAssemblyLink * link; KmerAssemblyNode * prev; KmerAssemblyNode * next; assert(kai != NULL); prev = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,prev_number); if( prev != NULL ) { for(i=0;inext_len;i++) { if( prev->next[i]->next->number == next_number ) { add_sequence_label_KmerAssemblyLink(prev->next[i],label); return TRUE; } } } /* nope - need new link */ next = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,next_number); if( prev == NULL ) { prev = new_KmerAssemblyNode(prev_number); assert(prev->number == prev_number); (*kai->kii->insert_by_kmer)(kai->kii->handle,prev_number,prev); } else { assert(prev->number >= 0); } if( next == NULL ) { next = new_KmerAssemblyNode(next_number); assert(next->number == next_number); (*kai->kii->insert_by_kmer)(kai->kii->handle,next_number,next); } else { assert(next->number >= 0); } assert(prev != NULL); assert(prev->number >= 0); assert(prev->prev != NULL); assert(prev->next != NULL); assert(next != NULL); assert(next->number >= 0); assert(next->prev != NULL); assert(next->next != NULL); link = new_KmerAssemblyLink(base); add_sequence_label_KmerAssemblyLink(link,label); link->prev = prev; link->next = next; /* fprintf(stderr,"Adding position to %ld : %ld with %d,%d\n",prev->number,next->number,prev->prev_len,next->next_len);*/ add_next_KmerAssemblyNode(prev,link); add_prev_KmerAssemblyNode(next,link); return TRUE; } void show_KmerAssemblyIndex(KmerAssemblyIndex * kai,FILE * ofp) { kmer_t kmer; KmerAssemblyNode * node; assert(kai != NULL); assert(kai->kii != NULL); assert(kai->kii->next_filled_kmer != NULL); kmer = -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); show_KmerAssemblyNode(node,kai->kii->kmer_size,0,ofp); } } void show_KmerAssemblyNode(KmerAssemblyNode * node,int kmer_size,int level,FILE * ofp) { int i; int k; char buffer[512]; assert(node != NULL); assert(ofp != NULL); reverse_map_dna_number(node->number,kmer_size,buffer); buffer[kmer_size] = '\0'; for(k=0;knumber,buffer); for(i=0;iprev_len;i++) { for(k=0;kprev[i]->base,node->prev[i]->sequence_label_len,node->prev[i]->prev->number); } for(i=0;inext_len;i++) { for(k=0;knext[i]->base,node->next[i]->sequence_label_len,node->next[i]->next->number); } if( node->node_chain != NULL) { fprintf(ofp,"Has chained node...\n"); show_KmerAssemblyNode(node->node_chain,kmer_size,level+1,ofp); } } KmerAssemblyIndex * new_KmerAssemblyIndex(KmerIndexInterface * kii,SinglePosSpace * sps) { KmerAssemblyIndex * out; assert(kii != NULL); assert(sps != NULL); out = (KmerAssemblyIndex*) malloc(sizeof(KmerAssemblyIndex)); out->kii = kii; out->sps = sps; return out; } KmerAssemblyLink * new_KmerAssemblyLink(char base) { KmerAssemblyLink * out; out = (KmerAssemblyLink*) malloc (sizeof(KmerAssemblyLink)); out->sequence_label = (long*) calloc(KmerAssemblyLink_LABEL_START,sizeof(long)); out->sequence_label_maxlen = KmerAssemblyLink_LABEL_START; out->sequence_label_len = 0; out->base = base; out->prev = NULL; out->next = NULL; out->state = 0; return out; } void remove_sequence_label_KmerAssemblyLink(KmerAssemblyLink * kal,long label) { int i; assert(kal != NULL); for(i=0;isequence_label_len;i++) { if( kal->sequence_label[i] == label ) { kal->sequence_label[i] = kal->sequence_label[--kal->sequence_label_len]; return; } } fprintf(stderr," ...unable to remove label %ld from link %ld (%d labels)\n",label,kal,kal->sequence_label_len); for(i=0;isequence_label_len;i++) { fprintf(stderr," [%ld] is %d label\n",kal->sequence_label[i]); } return; } void add_sequence_label_KmerAssemblyLink(KmerAssemblyLink * kal,long label) { assert(kal != NULL); if( kal->sequence_label_len >= kal->sequence_label_maxlen ) { if( kal->sequence_label_maxlen > KmerAssemblyLink_LABEL_LINEAR ) { kal->sequence_label_maxlen += KmerAssemblyLink_LABEL_LINEAR; } else { kal->sequence_label_maxlen *= 2; } kal->sequence_label = (long *) realloc (kal->sequence_label,sizeof(long)*kal->sequence_label_maxlen); } kal->sequence_label[kal->sequence_label_len++] = label; } void detach_KmerAssemblyLink(KmerAssemblyIndex * kai,KmerAssemblyLink * link) { assert(kai != NULL); assert(link != NULL); if( link->prev != NULL ) { remove_next_KmerAssemblyNode(link->prev,link); } if( link->next != NULL ) { remove_prev_KmerAssemblyNode(link->next,link); } } void remove_next_KmerAssemblyNode(KmerAssemblyNode * node,KmerAssemblyLink * next) { int i; assert(node != NULL); assert(next != NULL); for(i=0;inext_len;i++) { if( node->next[i] == next ) { node->next[i] = node->next[--node->next_len]; return; } } warn("In node %d, unable to remove %d as a next node, graph collapsing....",node,next); return; } void add_next_KmerAssemblyNode(KmerAssemblyNode * kan,KmerAssemblyLink * kal) { assert(kan != NULL); assert(kal != NULL); assert(kan->next != NULL); if( kan->next_len >= kan->next_maxlen ) { if( kan->next_maxlen > KmerAssemblyNode_LINK_LINEAR ){ kan->next = (KmerAssemblyLink **) realloc (kan->next,sizeof(KmerAssemblyLink*) * (kan->next_maxlen + KmerAssemblyNode_LINK_LINEAR)); kan->next_maxlen = kan->next_maxlen + KmerAssemblyNode_LINK_LINEAR; } else { kan->next = (KmerAssemblyLink **) realloc (kan->next,sizeof(KmerAssemblyLink*) * (kan->next_maxlen * 2)); kan->next_maxlen = kan->next_maxlen * 2; } } kan->next[kan->next_len++] = kal; } void remove_prev_KmerAssemblyNode(KmerAssemblyNode * node,KmerAssemblyLink * prev) { int i; assert(node != NULL); assert(prev != NULL); for(i=0;iprev_len;i++) { if( node->prev[i] == prev ) { node->prev[i] = node->prev[--node->prev_len]; return; } } warn("In node %d, unable to remove %d as a prev node",node,prev); return; } void add_prev_KmerAssemblyNode(KmerAssemblyNode * kan,KmerAssemblyLink * kal) { assert(kan != NULL); assert(kal != NULL); assert(kan->prev != NULL); if( kan->prev_len >= kan->prev_maxlen ) { if( kan->prev_maxlen > KmerAssemblyNode_LINK_LINEAR ){ kan->prev = (KmerAssemblyLink **) realloc (kan->prev,sizeof(KmerAssemblyLink*) * (kan->prev_maxlen + KmerAssemblyNode_LINK_LINEAR)); kan->prev_maxlen = kan->prev_maxlen + KmerAssemblyNode_LINK_LINEAR; } else { kan->prev = (KmerAssemblyLink **) realloc (kan->prev,sizeof(KmerAssemblyLink*) * (kan->prev_maxlen * 2)); kan->prev_maxlen = kan->prev_maxlen * 2; } } kan->prev[kan->prev_len++] = kal; } KmerAssemblyNode * new_KmerAssemblyNode(kmer_t number) { KmerAssemblyNode * out; out = (KmerAssemblyNode*) malloc( sizeof(KmerAssemblyNode)); assert(out != NULL); out->number = number; out->prev = (KmerAssemblyLink **) calloc (KmerAssemblyNode_LINK_START,sizeof(KmerAssemblyLink)); out->next = (KmerAssemblyLink **) calloc (KmerAssemblyNode_LINK_START,sizeof(KmerAssemblyLink)); out->prev_maxlen = out->next_maxlen = KmerAssemblyNode_LINK_START; out->prev_len = out->next_len = 0; out->node_chain = NULL; return out; } %} wise-2.4.1/src/dnaindex/assembly_stream_interface.dy0000644000175000001440000000221407736003505022206 0ustar philippusers %{ #include "assembly.h" %} struct AssemblySequenceStream AssemblySequence * (*next_AssemblySequence)(void *) !func void (*free_handle)(void *) !func void * handle !link %{ #include "assembly_stream_interface.h" %func provides specific deconstructor %% !deconstructor AssemblySequenceStream * free_AssemblySequenceStream(AssemblySequenceStream * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AssemblySequenceStream obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->handle != NULL ) { if( obj->free_handle == NULL ) { warn("In assembly stream constructor, no free function for handle. Probably will leak memory"); } else { (*obj->free_handle)(obj->handle); } } free(obj); return NULL; } %} wise-2.4.1/src/dnaindex/eulerindex.c0000644000175000001440000014143510670453716016763 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "eulerindex.h" # line 54 "eulerindex.dy" void dump_EulerGraph(EulerGraph * eg,FILE * ofp) { int i; int j; char dna_str[512]; assert(eg); assert(ofp); for(i=0;inode_len;i++) { if( eg->node[i] != NULL ) { reverse_map_dna_number(i,eg->kmer,dna_str); dna_str[eg->kmer] = '\0'; fprintf(ofp,"Node %d [%s]\n",i,dna_str); fprintf(ofp," Incoming Links:\n"); for(j=0;jnode[i]->back_len;j++) { fprintf(ofp," %d [%c] from %d\n",eg->node[i]->back[j]->depth,eg->node[i]->back[j]->base,eg->node[i]->back[j]->prev->number); } fprintf(ofp," Outgoing Links:\n"); for(j=0;jnode[i]->link_len;j++) { fprintf(ofp," %d [%c] to %d\n",eg->node[i]->link[j]->depth,eg->node[i]->link[j]->base,eg->node[i]->link[j]->next->number); } } } } # line 81 "eulerindex.dy" Sequence * read_Sequence_EulerNode(EulerNode * leftmost) { int i; Sequence * out; EulerLink * l; assert(leftmost); assert(leftmost->link_len == 1); i=0; l = leftmost->link[0]; while( 1 ) { i++; if( l->next->link_len == 1 ) { l = l->next->link[0]; continue; } if( l->next->link_len > 1 ) { warn("Untangled repeat sequence on node %d\n",l->next->number); break; } if( l->next->link_len == 0 ) { break; } } out = Sequence_alloc(); out->seq = calloc(i+1,sizeof(char)); i=0; l = leftmost->link[0]; while( 1 ) { out->seq[i] = l->base; i++; if( l->next->link_len == 1 ) { l = l->next->link[0]; continue; } if( l->next->link_len > 1 ) { break; } if( l->next->link_len == 0 ) { break; } } out->seq[i] = '\0'; out->name = stringalloc("EulerGraphSequence"); return out; } # line 138 "eulerindex.dy" boolean can_resolve_error_EulerGraph(EulerGraph *eg,EulerLink * leftmost) { EulerNode * node; EulerLink * path; int len = 1; int error_len; assert(eg); assert(leftmost); fprintf(stderr,"starting resolving\n"); error_len = eg->kmer; path = leftmost; while( len < error_len ) { if( path->depth != 1 ) { return FALSE; } if( path->next->link_len > 1 ) { return FALSE; } path = path->next->link[0]; if( path == NULL ) { return FALSE; } len++; } return TRUE; } # line 176 "eulerindex.dy" boolean resolve_error_EulerGraph(EulerGraph * eg,EulerLink * leftmost) { char * dna = "ATGC"; char dna_str[128]; int i; int test_number; EulerLink * walk; int w; assert(eg); assert(leftmost); reverse_map_dna_number(leftmost->next->number,eg->kmer,dna_str); for(i=0,walk = leftmost;ikmer;i++) { dna_str[eg->kmer+i] = walk->base; walk = walk->next->link[0]; } dna_str[eg->kmer+i] = '\0'; fprintf(stderr,"Have string of %s\n",dna_str); for(i=0;i<4;i++) { dna_str[eg->kmer-1] = dna[i]; fprintf(stderr,"Considering %c for fixing\n",dna[i]); test_number = forward_dna_number_from_string(dna_str,eg->kmer); if( eg->node[test_number] != NULL && eg->node[test_number]->link_len ==1 ) { fprintf(stderr,"Test number works, now walking...\n"); for(walk = eg->node[test_number]->back[0],w=0; walk != NULL && wkmer;w++) { /* fprintf(stderr,"Looking at %c vs %c\n",dna_str[eg->kmer+w],walk->base); */ if( dna_str[eg->kmer+w] != walk->base ) { break; } walk = walk->next->link[0]; } if( w >= eg->kmer ) { fix_error_EulerGraph(eg,leftmost,dna_str,eg->kmer); return TRUE; } } } return FALSE; } # line 225 "eulerindex.dy" void fix_error_EulerGraph(EulerGraph * eg, EulerLink * leftmost,char * dna_str,int len) { int i; int j; int number; int prev_number; EulerLink * walk; EulerLink * temp; EulerNode * prev; fprintf(stderr,"Fixing with %s length %d\n",dna_str,len); prev = leftmost->prev; prev_number = prev->number; walk = leftmost; for(i=0;ikmer); for(j=0;jnode[prev_number]->link_len;j++) { if( eg->node[prev_number]->link[j]->next->number == number ) { break; } } if( j >= eg->node[prev_number]->link_len ) { fprintf(stderr,"Problem here; fixed node doesn't have active numbers in link..."); return; } add_label_EulerLink(eg->node[prev_number]->link[j],walk->label[0]); prev_number = number; temp = walk; walk = walk->next->link[0]; remove_EulerLink_forward_EulerNode(temp->prev,temp); remove_EulerLink_backward_EulerNode(temp->next,temp); free_EulerLink(temp); } } # line 266 "eulerindex.dy" void build_new_node_path_EulerGraph(EulerGraph * eg,EulerLink * leftmost,EulerPath * path,int * starting_labels,int length) { int i; int l; int path_offset; EulerNode * new_node; EulerNode * prev_node; EulerLink * new_link; assert(eg); assert(leftmost); assert(starting_labels); assert(length > 0); fprintf(stderr,"Going to build new node path\n"); new_node = new_EulerNode(leftmost->next->number); add_dup_EulerGraph(eg,new_node); new_link = new_EulerLink(); new_link->prev = leftmost->prev; new_link->next = new_node; new_link->base = leftmost->base; new_link->depth = length; for(l=0;lprev,new_link); add_back_EulerNode(new_link->next,new_link); prev_node = new_node; for(i=path->current-1,path_offset = 1;i >= 0 ;i--,path_offset++) { new_link = new_EulerLink(); new_link->prev = prev_node; new_link->next = NULL; new_link->base = path->stack[i]->base; new_link->depth = length; for(l=0;lstack[i],starting_labels[i]+path_offset); add_label_EulerLink(new_link,starting_labels[l]+path_offset); } if( i > 0 ) { new_node = new_EulerNode(path->stack[i]->next->number); add_dup_EulerGraph(eg,new_node); new_link->next = new_node; } else { /* connect to the same path */ new_link->next = path->stack[0]->next; } add_link_EulerNode(new_link->prev,new_link); add_back_EulerNode(new_link->next,new_link); prev_node = new_node; } } # line 338 "eulerindex.dy" boolean attempt_untangle_EulerPath(EulerGraph *eg,EulerPath * path,EulerLink * leftmost) { int i; int j; SinglePosSequence * leftmost_sps[512]; SinglePosSequence * rightmost_sps[512]; int can_untangle_left[512]; int can_untangle_right[512]; int untangle_feasible = 0; int starting_label[512]; int total_labels = 0; int fully_left_untangled; int fully_right_untangled; assert(eg); assert(path); assert(leftmost); fprintf(stderr,"Considering untangle at position %d in path\n",path->current); for(i=0;ilabel_len && leftmost->label[i] != -1;i++) { leftmost_sps[i] = lookup_Sequence_SinglePosSpace(eg->sps,leftmost->label[i]); if( eg->kmer+leftmost->label[i]+3 > leftmost_sps[i]->end ) { can_untangle_left[i] = -2; fprintf(stderr,"Too close to end for resolving power, %s\n",leftmost_sps[i]->seq->name); } else { can_untangle_left[i] = -1; } } fprintf(stderr,"Going to look at rightmost\n"); for(i=0;istack[0]->label_len && path->stack[0]->label[i] != -1;i++) { rightmost_sps[i] = lookup_Sequence_SinglePosSpace(eg->sps,path->stack[0]->label[i]); if( path->stack[0]->label[i] - eg->kmer - 3 < rightmost_sps[i]->start ) { can_untangle_right[i] = -2; fprintf(stderr,"Too close to start for resolving power, %s\n",rightmost_sps[i]->seq->name); } else { can_untangle_right[i] = -1; } can_untangle_right[i] = -1; for(j=0;jlabel_len && leftmost->label[j] != -1;j++) { if( leftmost_sps[j]->seq == rightmost_sps[i]->seq && (path->current == (path->stack[0]->label[i] - leftmost->label[j])) ) { fprintf(stderr,"Able to untangle label %d with (%d) diff [left %d, right %d]\n",leftmost->label[j],path->stack[0]->label[i]-leftmost->label[j],j,i); can_untangle_left[j] = i; can_untangle_right[i] = j; untangle_feasible = 1; starting_label[total_labels++] = leftmost->label[j]; } } } if( untangle_feasible == 0 ) { fprintf(stderr,"No untangle feasible\n"); return 0; } fprintf(stderr,"Abotu to build new node path....\n"); build_new_node_path_EulerGraph(eg,leftmost,path,starting_label,total_labels); fully_left_untangled = 1; for(i=0;ilabel_len && leftmost->label[i] != -1 ;i++) { if( can_untangle_left[i] == -1 ) { fprintf(stderr,"Left: Label position %d not resolved (%s)\n",i,leftmost_sps[i]->seq->name); fully_left_untangled = 0; break; } } fully_right_untangled = 1; for(i=0;istack[0]->label_len && path->stack[0]->label[i] != -1;i++) { if( can_untangle_right[i] == -1 ) { fprintf(stderr,"Right: Label position %d not resolved (%s)\n",i,rightmost_sps[i]->seq->name); fully_right_untangled = 0; break; } } if( fully_left_untangled == 1) { fprintf(stderr,"Managed to fully left untangle path\n"); /* remove the link on leftmost */ remove_EulerLink_forward_EulerNode(leftmost->prev,leftmost); remove_EulerLink_backward_EulerNode(leftmost->next,leftmost); } if( fully_right_untangled == 1 ) { fprintf(stderr,"Managed to fully right untangle path\n"); /* remove the link on leftmost */ remove_EulerLink_forward_EulerNode(path->stack[0]->prev,path->stack[0]); remove_EulerLink_backward_EulerNode(path->stack[0]->next,path->stack[0]); } return fully_right_untangled; } # line 440 "eulerindex.dy" boolean untangle_from_split_EulerNode(EulerGraph * eg,EulerNode * split_outgoing,int max_backtrack) { EulerPath * ep; int i; int resolved = 0; EulerLink * split[512]; int len; assert(eg); assert(split_outgoing); assert(split_outgoing->link_len > 1); ep = new_EulerPath(); for(i=0;ilink_len;i++) { split[i] = split_outgoing->link[i]; } len = split_outgoing->link_len; for(i=0;ilink_len == 1 ) { fprintf(stderr,"No need to resolve this node at %d from %d\n",i,len); break; } ep->current = 0; resolved = 0; untangle_EulerLink_EulerPath(eg,ep,split[i],&resolved,0,max_backtrack); } free_EulerPath(ep); } # line 474 "eulerindex.dy" boolean untangle_EulerLink_EulerPath(EulerGraph * eg,EulerPath * current_path,EulerLink * current,int * resolved,int backtrack_len,int max_backtrack) { int i; int starting_path_point; assert(eg); assert(current_path); assert(current); fprintf(stderr,"Entering untangle at link between %d and %d, backtrack length of %d on path of %d\n",current->prev->number,current->next->number,backtrack_len,current_path->current); if( *resolved == 1 ) { return TRUE; } if( backtrack_len >= max_backtrack ) { return TRUE; } starting_path_point = current_path->current; while( 1 ) { /* push current into the path */ fprintf(stderr,"Pushing on to path link between %d and %d with back length of %d\n",current->prev->number,current->next->number,current->prev->back_len); push_EulerPath(current_path,current); backtrack_len++; if( current->prev->back_len == 0 ) { /* end of a stream! */ *resolved = 1; return TRUE; } if( current->prev->back_len > 1 ) { for(i=0;iprev->back_len;i++) { if( attempt_untangle_EulerPath(eg,current_path,current->prev->back[i]) == 1 ) { *resolved = 1; return TRUE; } } for(i=0;iprev->back_len;i++) { /* recurse into this branch */ untangle_EulerLink_EulerPath(eg,current_path,current->prev->back[i],resolved,backtrack_len,max_backtrack); } current_path->current = starting_path_point; /* at this point, gone down all paths, so return */ return TRUE; } else { /* continue in this routine steping back */ current = current->prev->back[0]; } } current_path->current = starting_path_point; return TRUE; } # line 537 "eulerindex.dy" boolean remove_EulerLink_forward_EulerNode(EulerNode * n,EulerLink *l) { int i; assert(n); assert(l); for(i=0;ilink_len;i++) { if( n->link[i] == l ) { for(++i;ilink_len;i++) { n->link[i-1] = n->link[i]; } n->link_len--; return TRUE; } } return FALSE; } # line 558 "eulerindex.dy" boolean remove_EulerLink_backward_EulerNode(EulerNode * n,EulerLink *l) { int i; assert(n); assert(l); for(i=0;iback_len;i++) { if( n->back[i] == l ) { for(++i;iback_len;i++) { n->back[i-1] = n->back[i]; } n->back_len--; return TRUE; } } fprintf(stderr,"...could not remove link\n"); return FALSE; } # line 581 "eulerindex.dy" boolean remove_label_EulerLink(EulerLink * el,int label) { int i; assert(el); for(i=0;ilabel_len;i++) { if( el->label[i] == label ) { break; } } if( i >= el->label_len ) { return FALSE; } for(i++;ilabel_len && el->label[i] != -1 ;i++) { el->label[i-1] = el->label[i]; } el->label[i] = -1; return TRUE; } # line 608 "eulerindex.dy" boolean store_Sequence_EulerGraph(EulerGraph * eg,Sequence * seq) { int i; int prev_number; int next_number; int pos_start; assert(eg); assert(seq); add_EulerGraph(eg,seq); pos_start = add_Sequence_SinglePosSpace(eg->sps,seq); for(i=0;ilen - eg->kmer ;i++) { prev_number = forward_dna_number_from_string(seq->seq+i,eg->kmer); next_number = forward_dna_number_from_string(seq->seq+i+1,eg->kmer); store_EulerLink_EulerGraph(eg,prev_number,next_number,seq->seq[i+eg->kmer],pos_start+i); } } # line 632 "eulerindex.dy" boolean store_EulerLink_EulerGraph(EulerGraph * eg,int prev_number,int next_number,char base,int label) { int i; EulerLink * link; assert(eg); if( eg->node[prev_number] != NULL ) { for(i=0;inode[prev_number]->link_len;i++) { if( eg->node[prev_number]->link[i]->next->number == next_number ) { eg->node[prev_number]->link[i]->depth++; add_label_EulerLink(eg->node[prev_number]->link[i],label); return TRUE; } } } /* else need new link */ if( eg->node[prev_number] == NULL ) { eg->node[prev_number] = new_EulerNode(prev_number); } if( eg->node[next_number] == NULL ) { eg->node[next_number] = new_EulerNode(next_number); } link = new_EulerLink(); link->depth = 1; link->base = base; add_label_EulerLink(link,label); link->prev = eg->node[prev_number]; link->next = eg->node[next_number]; eg->node[prev_number]->is_rightmost = 0; eg->node[next_number]->is_leftmost = 0; add_link_EulerNode(eg->node[prev_number],link); add_back_EulerNode(eg->node[next_number],link); return TRUE; } # line 678 "eulerindex.dy" EulerLink * new_EulerLink(void) { int i; EulerLink * out; out = EulerLink_alloc(); out->label = calloc(EulerLinkLabelLength,sizeof(int)); for(i=0;ilabel[i] = -1; } out->label_len = EulerLinkLabelLength; return out; } # line 693 "eulerindex.dy" boolean add_label_EulerLink(EulerLink * el,int label) { int i; int old_len; assert(el); for(i=0;ilabel_len;i++) { if( el->label[i] == -1 ) { el->label[i] = label; return TRUE; } } /* run out of space */ old_len = el->label_len; if( el->label_len > EulerLinkLabelLinear ) { el->label = realloc(el->label,el->label_len*2*sizeof(int)); el->label_len = el->label_len*2; } else { el->label = realloc(el->label,el->label_len*el->label_len*sizeof(int)); el->label_len = el->label_len * el->label_len; } /* put label at old_len, and then -1s */ el->label[old_len] = label; for(i=old_len+1;ilabel_len;i++) { el->label[i] = -1; } return TRUE; } # line 726 "eulerindex.dy" EulerNode * new_EulerNode(int number) { EulerNode * out; out = EulerNode_alloc_std(); out->number = number; out->is_leftmost = 1; out->is_rightmost = 1; return out; } # line 739 "eulerindex.dy" EulerGraph * new_EulerGraph(int kmer) { EulerGraph * out; int len = 1; int i; for(i=0;inode = calloc(len,sizeof(EulerNode*)); out->node_len = len; out->kmer = kmer; out->sps = new_SinglePosSpace(0,3000); return out; } # line 760 "eulerindex.dy" void * push_EulerPath(EulerPath * ep,EulerLink * el) { assert(ep); assert(el); if( ep->current+1 >= ep->max_stack_len ) extend_EulerPath_stack(ep); ep->stack[ep->current++] = el; return; } # line 774 "eulerindex.dy" EulerLink * pop_EulerPath(EulerPath * ep) { assert(ep); if( ep->current <= 0 ) { warn("Stack underflow on EulerPath"); return NULL; } return ep->stack[ep->current--]; } # line 786 "eulerindex.dy" void extend_EulerPath_stack(EulerPath * ep) { assert(ep); ep->stack = (EulerLink**) realloc(ep->stack,sizeof(EulerLink*) * ep->max_stack_len * 2); ep->max_stack_len = ep->max_stack_len * 2; return; } # line 796 "eulerindex.dy" EulerPath * new_EulerPath(void) { EulerPath * out; out = EulerPath_alloc(); out->stack = (EulerLink**) calloc(64,sizeof(EulerLink*)); out->max_stack_len = 64; out->current = 0; return out; } # line 782 "eulerindex.c" /* Function: hard_link_EulerLink(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EulerLink *] * * Return [UNKN ] Undocumented return value [EulerLink *] * */ EulerLink * hard_link_EulerLink(EulerLink * obj) { if( obj == NULL ) { warn("Trying to hard link to a EulerLink object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: EulerLink_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EulerLink *] * */ EulerLink * EulerLink_alloc(void) { EulerLink * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EulerLink *) ckalloc (sizeof(EulerLink))) == NULL) { warn("EulerLink_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->label = NULL; out->label_len = 0; out->depth = 0; out->base = 'u'; return out; } /* Function: free_EulerLink(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EulerLink *] * * Return [UNKN ] Undocumented return value [EulerLink *] * */ EulerLink * free_EulerLink(EulerLink * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EulerLink obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->prev is linked in */ /* obj->next is linked in */ if( obj->label != NULL) ckfree(obj->label); ckfree(obj); return NULL; } /* Function: hard_link_EulerPath(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EulerPath *] * * Return [UNKN ] Undocumented return value [EulerPath *] * */ EulerPath * hard_link_EulerPath(EulerPath * obj) { if( obj == NULL ) { warn("Trying to hard link to a EulerPath object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: EulerPath_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EulerPath *] * */ EulerPath * EulerPath_alloc(void) { EulerPath * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EulerPath *) ckalloc (sizeof(EulerPath))) == NULL) { warn("EulerPath_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->stack = NULL; out->max_stack_len = 0; out->current = 0; return out; } /* Function: free_EulerPath(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EulerPath *] * * Return [UNKN ] Undocumented return value [EulerPath *] * */ EulerPath * free_EulerPath(EulerPath * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EulerPath obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->stack != NULL) ckfree(obj->stack); ckfree(obj); return NULL; } /* Function: swap_link_EulerNode(list,i,j) * * Descrip: swap function: an internal for qsort_link_EulerNode * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [EulerLink **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_link_EulerNode(EulerLink ** list,int i,int j) { EulerLink * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_link_EulerNode(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_link_EulerNode which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [EulerLink **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_link_EulerNode(EulerLink ** list,int left,int right,int (*comp)(EulerLink * ,EulerLink * )) { int i,last; if( left >= right ) return; swap_link_EulerNode(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_link_EulerNode (list,++last,i); } swap_link_EulerNode (list,left,last); qsort_link_EulerNode(list,left,last-1,comp); qsort_link_EulerNode(list,last+1,right,comp); } /* Function: sort_link_EulerNode(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_link_EulerNode * * * Arg: obj [UNKN ] Object containing list [EulerNode *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_link_EulerNode(EulerNode * obj,int (*comp)(EulerLink *, EulerLink *)) { qsort_link_EulerNode(obj->link,0,obj->link_len-1,comp); return; } /* Function: expand_link_EulerNode(obj,len) * * Descrip: Really an internal function for add_link_EulerNode * * * Arg: obj [UNKN ] Object which contains the list [EulerNode *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_link_EulerNode(EulerNode * obj,int len) { if( obj->link_maxlen > obj->link_len ) { warn("expand_EulerNodelink_ called with no need"); return TRUE; } if( (obj->link = (EulerLink ** ) ckrealloc (obj->link,sizeof(EulerLink *)*len)) == NULL) { warn("ckrealloc failed for expand_EulerNode, returning FALSE"); return FALSE; } obj->link_maxlen = len; return TRUE; } /* Function: add_link_EulerNode(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [EulerNode *] * Arg: add [OWNER] Object to add to the list [EulerLink *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_link_EulerNode(EulerNode * obj,EulerLink * add) { if( obj->link_len >= obj->link_maxlen) { if( expand_link_EulerNode(obj,obj->link_len + EulerNodeLISTLENGTH) == FALSE) return FALSE; } obj->link[obj->link_len++]=add; return TRUE; } /* Function: flush_link_EulerNode(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [EulerNode *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_link_EulerNode(EulerNode * obj) { int i; for(i=0;ilink_len;i++) { /*for i over list length*/ if( obj->link[i] != NULL) { free_EulerLink(obj->link[i]); obj->link[i] = NULL; } } /* end of for i over list length */ obj->link_len = 0; return i; } /* Function: swap_back_EulerNode(list,i,j) * * Descrip: swap function: an internal for qsort_back_EulerNode * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [EulerLink **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_back_EulerNode(EulerLink ** list,int i,int j) { EulerLink * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_back_EulerNode(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_back_EulerNode which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [EulerLink **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_back_EulerNode(EulerLink ** list,int left,int right,int (*comp)(EulerLink * ,EulerLink * )) { int i,last; if( left >= right ) return; swap_back_EulerNode(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_back_EulerNode (list,++last,i); } swap_back_EulerNode (list,left,last); qsort_back_EulerNode(list,left,last-1,comp); qsort_back_EulerNode(list,last+1,right,comp); } /* Function: sort_back_EulerNode(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_back_EulerNode * * * Arg: obj [UNKN ] Object containing list [EulerNode *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_back_EulerNode(EulerNode * obj,int (*comp)(EulerLink *, EulerLink *)) { qsort_back_EulerNode(obj->back,0,obj->back_len-1,comp); return; } /* Function: expand_back_EulerNode(obj,len) * * Descrip: Really an internal function for add_back_EulerNode * * * Arg: obj [UNKN ] Object which contains the list [EulerNode *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_back_EulerNode(EulerNode * obj,int len) { if( obj->back_maxlen > obj->back_len ) { warn("expand_EulerNodeback_ called with no need"); return TRUE; } if( (obj->back = (EulerLink ** ) ckrealloc (obj->back,sizeof(EulerLink *)*len)) == NULL) { warn("ckrealloc failed for expand_EulerNode, returning FALSE"); return FALSE; } obj->back_maxlen = len; return TRUE; } /* Function: add_back_EulerNode(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [EulerNode *] * Arg: add [OWNER] Object to add to the list [EulerLink *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_back_EulerNode(EulerNode * obj,EulerLink * add) { if( obj->back_len >= obj->back_maxlen) { if( expand_back_EulerNode(obj,obj->back_len + EulerNodeLISTLENGTH) == FALSE) return FALSE; } obj->back[obj->back_len++]=add; return TRUE; } /* Function: flush_back_EulerNode(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [EulerNode *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_back_EulerNode(EulerNode * obj) { int i; for(i=0;iback_len;i++) { /*for i over list length*/ if( obj->back[i] != NULL) { free_EulerLink(obj->back[i]); obj->back[i] = NULL; } } /* end of for i over list length */ obj->back_len = 0; return i; } /* Function: EulerNode_alloc_std(void) * * Descrip: Equivalent to EulerNode_alloc_len(EulerNodeLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [EulerNode *] * */ EulerNode * EulerNode_alloc_std(void) { return EulerNode_alloc_len(EulerNodeLISTLENGTH); } /* Function: EulerNode_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [EulerNode *] * */ EulerNode * EulerNode_alloc_len(int len) { EulerNode * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = EulerNode_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->link = (EulerLink ** ) ckcalloc (len,sizeof(EulerLink *))) == NULL) { warn("Warning, ckcalloc failed in EulerNode_alloc_len"); return NULL; } out->link_len = 0; out->link_maxlen = len; if((out->back = (EulerLink ** ) ckcalloc (len,sizeof(EulerLink *))) == NULL) { warn("Warning, ckcalloc failed in EulerNode_alloc_len"); return NULL; } out->back_len = 0; out->back_maxlen = len; return out; } /* Function: hard_link_EulerNode(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EulerNode *] * * Return [UNKN ] Undocumented return value [EulerNode *] * */ EulerNode * hard_link_EulerNode(EulerNode * obj) { if( obj == NULL ) { warn("Trying to hard link to a EulerNode object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: EulerNode_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EulerNode *] * */ EulerNode * EulerNode_alloc(void) { EulerNode * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EulerNode *) ckalloc (sizeof(EulerNode))) == NULL) { warn("EulerNode_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->number = 0; out->link = NULL; out->link_len = out->link_maxlen = 0; out->back = NULL; out->back_len = out->back_maxlen = 0; out->is_leftmost = 'u'; out->is_rightmost = 'u'; return out; } /* Function: free_EulerNode(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EulerNode *] * * Return [UNKN ] Undocumented return value [EulerNode *] * */ EulerNode * free_EulerNode(EulerNode * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EulerNode obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->link != NULL) { for(i=0;ilink_len;i++) { if( obj->link[i] != NULL) free_EulerLink(obj->link[i]); } ckfree(obj->link); } if( obj->back != NULL) { for(i=0;iback_len;i++) { if( obj->back[i] != NULL) free_EulerLink(obj->back[i]); } ckfree(obj->back); } ckfree(obj); return NULL; } /* Function: swap_EulerGraph(list,i,j) * * Descrip: swap function: an internal for qsort_EulerGraph * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Sequence **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_EulerGraph(Sequence ** list,int i,int j) { Sequence * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_EulerGraph(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_EulerGraph which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Sequence **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_EulerGraph(Sequence ** list,int left,int right,int (*comp)(Sequence * ,Sequence * )) { int i,last; if( left >= right ) return; swap_EulerGraph(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_EulerGraph (list,++last,i); } swap_EulerGraph (list,left,last); qsort_EulerGraph(list,left,last-1,comp); qsort_EulerGraph(list,last+1,right,comp); } /* Function: sort_EulerGraph(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_EulerGraph * * * Arg: obj [UNKN ] Object containing list [EulerGraph *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_EulerGraph(EulerGraph * obj,int (*comp)(Sequence *, Sequence *)) { qsort_EulerGraph(obj->seq,0,obj->len-1,comp); return; } /* Function: expand_EulerGraph(obj,len) * * Descrip: Really an internal function for add_EulerGraph * * * Arg: obj [UNKN ] Object which contains the list [EulerGraph *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_EulerGraph(EulerGraph * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_EulerGraph called with no need"); return TRUE; } if( (obj->seq = (Sequence ** ) ckrealloc (obj->seq,sizeof(Sequence *)*len)) == NULL) { warn("ckrealloc failed for expand_EulerGraph, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_EulerGraph(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [EulerGraph *] * Arg: add [OWNER] Object to add to the list [Sequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_EulerGraph(EulerGraph * obj,Sequence * add) { if( obj->len >= obj->maxlen) { if( expand_EulerGraph(obj,obj->len + EulerGraphLISTLENGTH) == FALSE) return FALSE; } obj->seq[obj->len++]=add; return TRUE; } /* Function: flush_EulerGraph(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [EulerGraph *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_EulerGraph(EulerGraph * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->seq[i] != NULL) { free_Sequence(obj->seq[i]); obj->seq[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: swap_dup_EulerGraph(list,i,j) * * Descrip: swap function: an internal for qsort_dup_EulerGraph * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [EulerNode **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_dup_EulerGraph(EulerNode ** list,int i,int j) { EulerNode * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_dup_EulerGraph(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_dup_EulerGraph which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [EulerNode **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_dup_EulerGraph(EulerNode ** list,int left,int right,int (*comp)(EulerNode * ,EulerNode * )) { int i,last; if( left >= right ) return; swap_dup_EulerGraph(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_dup_EulerGraph (list,++last,i); } swap_dup_EulerGraph (list,left,last); qsort_dup_EulerGraph(list,left,last-1,comp); qsort_dup_EulerGraph(list,last+1,right,comp); } /* Function: sort_dup_EulerGraph(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_dup_EulerGraph * * * Arg: obj [UNKN ] Object containing list [EulerGraph *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_dup_EulerGraph(EulerGraph * obj,int (*comp)(EulerNode *, EulerNode *)) { qsort_dup_EulerGraph(obj->dup,0,obj->dup_len-1,comp); return; } /* Function: expand_dup_EulerGraph(obj,len) * * Descrip: Really an internal function for add_dup_EulerGraph * * * Arg: obj [UNKN ] Object which contains the list [EulerGraph *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_dup_EulerGraph(EulerGraph * obj,int len) { if( obj->dup_maxlen > obj->dup_len ) { warn("expand_EulerGraphdup_ called with no need"); return TRUE; } if( (obj->dup = (EulerNode ** ) ckrealloc (obj->dup,sizeof(EulerNode *)*len)) == NULL) { warn("ckrealloc failed for expand_EulerGraph, returning FALSE"); return FALSE; } obj->dup_maxlen = len; return TRUE; } /* Function: add_dup_EulerGraph(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [EulerGraph *] * Arg: add [OWNER] Object to add to the list [EulerNode *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_dup_EulerGraph(EulerGraph * obj,EulerNode * add) { if( obj->dup_len >= obj->dup_maxlen) { if( expand_dup_EulerGraph(obj,obj->dup_len + EulerGraphLISTLENGTH) == FALSE) return FALSE; } obj->dup[obj->dup_len++]=add; return TRUE; } /* Function: flush_dup_EulerGraph(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [EulerGraph *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_dup_EulerGraph(EulerGraph * obj) { int i; for(i=0;idup_len;i++) { /*for i over list length*/ if( obj->dup[i] != NULL) { free_EulerNode(obj->dup[i]); obj->dup[i] = NULL; } } /* end of for i over list length */ obj->dup_len = 0; return i; } /* Function: EulerGraph_alloc_std(void) * * Descrip: Equivalent to EulerGraph_alloc_len(EulerGraphLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [EulerGraph *] * */ EulerGraph * EulerGraph_alloc_std(void) { return EulerGraph_alloc_len(EulerGraphLISTLENGTH); } /* Function: EulerGraph_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [EulerGraph *] * */ EulerGraph * EulerGraph_alloc_len(int len) { EulerGraph * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = EulerGraph_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->seq = (Sequence ** ) ckcalloc (len,sizeof(Sequence *))) == NULL) { warn("Warning, ckcalloc failed in EulerGraph_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; if((out->dup = (EulerNode ** ) ckcalloc (len,sizeof(EulerNode *))) == NULL) { warn("Warning, ckcalloc failed in EulerGraph_alloc_len"); return NULL; } out->dup_len = 0; out->dup_maxlen = len; return out; } /* Function: hard_link_EulerGraph(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EulerGraph *] * * Return [UNKN ] Undocumented return value [EulerGraph *] * */ EulerGraph * hard_link_EulerGraph(EulerGraph * obj) { if( obj == NULL ) { warn("Trying to hard link to a EulerGraph object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: EulerGraph_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EulerGraph *] * */ EulerGraph * EulerGraph_alloc(void) { EulerGraph * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EulerGraph *) ckalloc (sizeof(EulerGraph))) == NULL) { warn("EulerGraph_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->node = NULL; out->node_len = 0; out->kmer = 0; out->seq = NULL; out->len = out->maxlen = 0; out->sps = NULL; out->dup = NULL; out->dup_len = out->dup_maxlen = 0; return out; } /* Function: free_EulerGraph(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EulerGraph *] * * Return [UNKN ] Undocumented return value [EulerGraph *] * */ EulerGraph * free_EulerGraph(EulerGraph * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EulerGraph obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->node != NULL) ckfree(obj->node); if( obj->seq != NULL) { for(i=0;ilen;i++) { if( obj->seq[i] != NULL) free_Sequence(obj->seq[i]); } ckfree(obj->seq); } if( obj->sps != NULL) free_SinglePosSpace(obj->sps); if( obj->dup != NULL) { for(i=0;idup_len;i++) { if( obj->dup[i] != NULL) free_EulerNode(obj->dup[i]); } ckfree(obj->dup); } ckfree(obj); return NULL; } /* Function: hard_link_EulerErrorPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EulerErrorPara *] * * Return [UNKN ] Undocumented return value [EulerErrorPara *] * */ EulerErrorPara * hard_link_EulerErrorPara(EulerErrorPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a EulerErrorPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: EulerErrorPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EulerErrorPara *] * */ EulerErrorPara * EulerErrorPara_alloc(void) { EulerErrorPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EulerErrorPara *) ckalloc (sizeof(EulerErrorPara))) == NULL) { warn("EulerErrorPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->error_size = 1; return out; } /* Function: free_EulerErrorPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EulerErrorPara *] * * Return [UNKN ] Undocumented return value [EulerErrorPara *] * */ EulerErrorPara * free_EulerErrorPara(EulerErrorPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EulerErrorPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/eulerindex.h0000644000175000001440000004570010670453716016766 0ustar philippusers#ifndef DYNAMITEeulerindexHEADERFILE #define DYNAMITEeulerindexHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #include "singleseqspace.h" #include "dnamapping.h" #define EulerNodeLISTLENGTH 4 #define EulerGraphLISTLENGTH 128 #define EulerLinkLabelLength 8 #define EulerLinkLabelLinear 128 #ifndef DYNAMITE_DEFINED_EulerNode typedef struct Wise2_EulerNode Wise2_EulerNode; #define EulerNode Wise2_EulerNode #define DYNAMITE_DEFINED_EulerNode #endif #ifndef DYNAMITE_DEFINED_EulerLink typedef struct Wise2_EulerLink Wise2_EulerLink; #define EulerLink Wise2_EulerLink #define DYNAMITE_DEFINED_EulerLink #endif struct Wise2_EulerLink { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif EulerNode * prev; EulerNode * next; int * label; int label_len; int depth; char base; } ; /* EulerLink defined */ #ifndef DYNAMITE_DEFINED_EulerLink typedef struct Wise2_EulerLink Wise2_EulerLink; #define EulerLink Wise2_EulerLink #define DYNAMITE_DEFINED_EulerLink #endif struct Wise2_EulerPath { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif EulerLink ** stack; int max_stack_len; int current; } ; /* EulerPath defined */ #ifndef DYNAMITE_DEFINED_EulerPath typedef struct Wise2_EulerPath Wise2_EulerPath; #define EulerPath Wise2_EulerPath #define DYNAMITE_DEFINED_EulerPath #endif struct Wise2_EulerNode { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int number; EulerLink ** link; int link_len; /* len for above link */ int link_maxlen;/* maxlen for above link */ EulerLink ** back; int back_len; /* len for above back */ int back_maxlen;/* maxlen for above back */ char is_leftmost; char is_rightmost; } ; /* EulerNode defined */ #ifndef DYNAMITE_DEFINED_EulerNode typedef struct Wise2_EulerNode Wise2_EulerNode; #define EulerNode Wise2_EulerNode #define DYNAMITE_DEFINED_EulerNode #endif struct Wise2_EulerGraph { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif EulerNode ** node; int node_len; int kmer; Sequence ** seq; int len;/* len for above seq */ int maxlen; /* maxlen for above seq */ SinglePosSpace * sps; EulerNode ** dup; int dup_len;/* len for above dup */ int dup_maxlen; /* maxlen for above dup */ } ; /* EulerGraph defined */ #ifndef DYNAMITE_DEFINED_EulerGraph typedef struct Wise2_EulerGraph Wise2_EulerGraph; #define EulerGraph Wise2_EulerGraph #define DYNAMITE_DEFINED_EulerGraph #endif struct Wise2_EulerErrorPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int error_size; } ; /* EulerErrorPara defined */ #ifndef DYNAMITE_DEFINED_EulerErrorPara typedef struct Wise2_EulerErrorPara Wise2_EulerErrorPara; #define EulerErrorPara Wise2_EulerErrorPara #define DYNAMITE_DEFINED_EulerErrorPara #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_EulerLink(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EulerLink *] * * Return [UNKN ] Undocumented return value [EulerLink *] * */ EulerLink * Wise2_hard_link_EulerLink(EulerLink * obj); #define hard_link_EulerLink Wise2_hard_link_EulerLink /* Function: EulerLink_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EulerLink *] * */ EulerLink * Wise2_EulerLink_alloc(void); #define EulerLink_alloc Wise2_EulerLink_alloc /* Function: free_EulerLink(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EulerLink *] * * Return [UNKN ] Undocumented return value [EulerLink *] * */ EulerLink * Wise2_free_EulerLink(EulerLink * obj); #define free_EulerLink Wise2_free_EulerLink /* Function: hard_link_EulerPath(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EulerPath *] * * Return [UNKN ] Undocumented return value [EulerPath *] * */ EulerPath * Wise2_hard_link_EulerPath(EulerPath * obj); #define hard_link_EulerPath Wise2_hard_link_EulerPath /* Function: EulerPath_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EulerPath *] * */ EulerPath * Wise2_EulerPath_alloc(void); #define EulerPath_alloc Wise2_EulerPath_alloc /* Function: free_EulerPath(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EulerPath *] * * Return [UNKN ] Undocumented return value [EulerPath *] * */ EulerPath * Wise2_free_EulerPath(EulerPath * obj); #define free_EulerPath Wise2_free_EulerPath /* Function: add_link_EulerNode(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [EulerNode *] * Arg: add [OWNER] Object to add to the list [EulerLink *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_link_EulerNode(EulerNode * obj,EulerLink * add); #define add_link_EulerNode Wise2_add_link_EulerNode /* Function: flush_link_EulerNode(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [EulerNode *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_link_EulerNode(EulerNode * obj); #define flush_link_EulerNode Wise2_flush_link_EulerNode /* Function: add_back_EulerNode(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [EulerNode *] * Arg: add [OWNER] Object to add to the list [EulerLink *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_back_EulerNode(EulerNode * obj,EulerLink * add); #define add_back_EulerNode Wise2_add_back_EulerNode /* Function: flush_back_EulerNode(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [EulerNode *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_back_EulerNode(EulerNode * obj); #define flush_back_EulerNode Wise2_flush_back_EulerNode /* Function: EulerNode_alloc_std(void) * * Descrip: Equivalent to EulerNode_alloc_len(EulerNodeLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [EulerNode *] * */ EulerNode * Wise2_EulerNode_alloc_std(void); #define EulerNode_alloc_std Wise2_EulerNode_alloc_std /* Function: EulerNode_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [EulerNode *] * */ EulerNode * Wise2_EulerNode_alloc_len(int len); #define EulerNode_alloc_len Wise2_EulerNode_alloc_len /* Function: hard_link_EulerNode(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EulerNode *] * * Return [UNKN ] Undocumented return value [EulerNode *] * */ EulerNode * Wise2_hard_link_EulerNode(EulerNode * obj); #define hard_link_EulerNode Wise2_hard_link_EulerNode /* Function: EulerNode_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EulerNode *] * */ EulerNode * Wise2_EulerNode_alloc(void); #define EulerNode_alloc Wise2_EulerNode_alloc /* Function: free_EulerNode(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EulerNode *] * * Return [UNKN ] Undocumented return value [EulerNode *] * */ EulerNode * Wise2_free_EulerNode(EulerNode * obj); #define free_EulerNode Wise2_free_EulerNode /* Function: add_EulerGraph(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [EulerGraph *] * Arg: add [OWNER] Object to add to the list [Sequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_EulerGraph(EulerGraph * obj,Sequence * add); #define add_EulerGraph Wise2_add_EulerGraph /* Function: flush_EulerGraph(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [EulerGraph *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_EulerGraph(EulerGraph * obj); #define flush_EulerGraph Wise2_flush_EulerGraph /* Function: add_dup_EulerGraph(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [EulerGraph *] * Arg: add [OWNER] Object to add to the list [EulerNode *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_dup_EulerGraph(EulerGraph * obj,EulerNode * add); #define add_dup_EulerGraph Wise2_add_dup_EulerGraph /* Function: flush_dup_EulerGraph(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [EulerGraph *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_dup_EulerGraph(EulerGraph * obj); #define flush_dup_EulerGraph Wise2_flush_dup_EulerGraph /* Function: EulerGraph_alloc_std(void) * * Descrip: Equivalent to EulerGraph_alloc_len(EulerGraphLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [EulerGraph *] * */ EulerGraph * Wise2_EulerGraph_alloc_std(void); #define EulerGraph_alloc_std Wise2_EulerGraph_alloc_std /* Function: EulerGraph_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [EulerGraph *] * */ EulerGraph * Wise2_EulerGraph_alloc_len(int len); #define EulerGraph_alloc_len Wise2_EulerGraph_alloc_len /* Function: hard_link_EulerGraph(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EulerGraph *] * * Return [UNKN ] Undocumented return value [EulerGraph *] * */ EulerGraph * Wise2_hard_link_EulerGraph(EulerGraph * obj); #define hard_link_EulerGraph Wise2_hard_link_EulerGraph /* Function: EulerGraph_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EulerGraph *] * */ EulerGraph * Wise2_EulerGraph_alloc(void); #define EulerGraph_alloc Wise2_EulerGraph_alloc /* Function: free_EulerGraph(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EulerGraph *] * * Return [UNKN ] Undocumented return value [EulerGraph *] * */ EulerGraph * Wise2_free_EulerGraph(EulerGraph * obj); #define free_EulerGraph Wise2_free_EulerGraph /* Function: hard_link_EulerErrorPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EulerErrorPara *] * * Return [UNKN ] Undocumented return value [EulerErrorPara *] * */ EulerErrorPara * Wise2_hard_link_EulerErrorPara(EulerErrorPara * obj); #define hard_link_EulerErrorPara Wise2_hard_link_EulerErrorPara /* Function: EulerErrorPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EulerErrorPara *] * */ EulerErrorPara * Wise2_EulerErrorPara_alloc(void); #define EulerErrorPara_alloc Wise2_EulerErrorPara_alloc /* Function: free_EulerErrorPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EulerErrorPara *] * * Return [UNKN ] Undocumented return value [EulerErrorPara *] * */ EulerErrorPara * Wise2_free_EulerErrorPara(EulerErrorPara * obj); #define free_EulerErrorPara Wise2_free_EulerErrorPara /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_dump_EulerGraph(EulerGraph * eg,FILE * ofp); #define dump_EulerGraph Wise2_dump_EulerGraph Sequence * Wise2_read_Sequence_EulerNode(EulerNode * leftmost); #define read_Sequence_EulerNode Wise2_read_Sequence_EulerNode boolean Wise2_can_resolve_error_EulerGraph(EulerGraph *eg,EulerLink * leftmost); #define can_resolve_error_EulerGraph Wise2_can_resolve_error_EulerGraph boolean Wise2_resolve_error_EulerGraph(EulerGraph * eg,EulerLink * leftmost); #define resolve_error_EulerGraph Wise2_resolve_error_EulerGraph void Wise2_fix_error_EulerGraph(EulerGraph * eg, EulerLink * leftmost,char * dna_str,int len); #define fix_error_EulerGraph Wise2_fix_error_EulerGraph void Wise2_build_new_node_path_EulerGraph(EulerGraph * eg,EulerLink * leftmost,EulerPath * path,int * starting_labels,int length); #define build_new_node_path_EulerGraph Wise2_build_new_node_path_EulerGraph boolean Wise2_attempt_untangle_EulerPath(EulerGraph *eg,EulerPath * path,EulerLink * leftmost); #define attempt_untangle_EulerPath Wise2_attempt_untangle_EulerPath boolean Wise2_untangle_from_split_EulerNode(EulerGraph * eg,EulerNode * split_outgoing,int max_backtrack); #define untangle_from_split_EulerNode Wise2_untangle_from_split_EulerNode boolean Wise2_untangle_EulerLink_EulerPath(EulerGraph * eg,EulerPath * current_path,EulerLink * current,int * resolved,int backtrack_len,int max_backtrack); #define untangle_EulerLink_EulerPath Wise2_untangle_EulerLink_EulerPath boolean Wise2_remove_EulerLink_forward_EulerNode(EulerNode * n,EulerLink *l); #define remove_EulerLink_forward_EulerNode Wise2_remove_EulerLink_forward_EulerNode boolean Wise2_remove_EulerLink_backward_EulerNode(EulerNode * n,EulerLink *l); #define remove_EulerLink_backward_EulerNode Wise2_remove_EulerLink_backward_EulerNode boolean Wise2_remove_label_EulerLink(EulerLink * el,int label); #define remove_label_EulerLink Wise2_remove_label_EulerLink boolean Wise2_store_Sequence_EulerGraph(EulerGraph * eg,Sequence * seq); #define store_Sequence_EulerGraph Wise2_store_Sequence_EulerGraph boolean Wise2_store_EulerLink_EulerGraph(EulerGraph * eg,int prev_number,int next_number,char base,int label); #define store_EulerLink_EulerGraph Wise2_store_EulerLink_EulerGraph EulerLink * Wise2_new_EulerLink(void); #define new_EulerLink Wise2_new_EulerLink boolean Wise2_add_label_EulerLink(EulerLink * el,int label); #define add_label_EulerLink Wise2_add_label_EulerLink EulerNode * Wise2_new_EulerNode(int number); #define new_EulerNode Wise2_new_EulerNode EulerGraph * Wise2_new_EulerGraph(int kmer); #define new_EulerGraph Wise2_new_EulerGraph void * Wise2_push_EulerPath(EulerPath * ep,EulerLink * el); #define push_EulerPath Wise2_push_EulerPath EulerLink * Wise2_pop_EulerPath(EulerPath * ep); #define pop_EulerPath Wise2_pop_EulerPath void Wise2_extend_EulerPath_stack(EulerPath * ep); #define extend_EulerPath_stack Wise2_extend_EulerPath_stack EulerPath * Wise2_new_EulerPath(void); #define new_EulerPath Wise2_new_EulerPath /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_link_EulerNode(EulerLink ** list,int i,int j) ; #define swap_link_EulerNode Wise2_swap_link_EulerNode void Wise2_qsort_link_EulerNode(EulerLink ** list,int left,int right,int (*comp)(EulerLink * ,EulerLink * )); #define qsort_link_EulerNode Wise2_qsort_link_EulerNode void Wise2_sort_link_EulerNode(EulerNode * obj,int (*comp)(EulerLink *, EulerLink *)); #define sort_link_EulerNode Wise2_sort_link_EulerNode boolean Wise2_expand_link_EulerNode(EulerNode * obj,int len); #define expand_link_EulerNode Wise2_expand_link_EulerNode void Wise2_swap_back_EulerNode(EulerLink ** list,int i,int j) ; #define swap_back_EulerNode Wise2_swap_back_EulerNode void Wise2_qsort_back_EulerNode(EulerLink ** list,int left,int right,int (*comp)(EulerLink * ,EulerLink * )); #define qsort_back_EulerNode Wise2_qsort_back_EulerNode void Wise2_sort_back_EulerNode(EulerNode * obj,int (*comp)(EulerLink *, EulerLink *)); #define sort_back_EulerNode Wise2_sort_back_EulerNode boolean Wise2_expand_back_EulerNode(EulerNode * obj,int len); #define expand_back_EulerNode Wise2_expand_back_EulerNode void Wise2_swap_EulerGraph(Sequence ** list,int i,int j) ; #define swap_EulerGraph Wise2_swap_EulerGraph void Wise2_qsort_EulerGraph(Sequence ** list,int left,int right,int (*comp)(Sequence * ,Sequence * )); #define qsort_EulerGraph Wise2_qsort_EulerGraph void Wise2_sort_EulerGraph(EulerGraph * obj,int (*comp)(Sequence *, Sequence *)); #define sort_EulerGraph Wise2_sort_EulerGraph boolean Wise2_expand_EulerGraph(EulerGraph * obj,int len); #define expand_EulerGraph Wise2_expand_EulerGraph void Wise2_swap_dup_EulerGraph(EulerNode ** list,int i,int j) ; #define swap_dup_EulerGraph Wise2_swap_dup_EulerGraph void Wise2_qsort_dup_EulerGraph(EulerNode ** list,int left,int right,int (*comp)(EulerNode * ,EulerNode * )); #define qsort_dup_EulerGraph Wise2_qsort_dup_EulerGraph void Wise2_sort_dup_EulerGraph(EulerGraph * obj,int (*comp)(EulerNode *, EulerNode *)); #define sort_dup_EulerGraph Wise2_sort_dup_EulerGraph boolean Wise2_expand_dup_EulerGraph(EulerGraph * obj,int len); #define expand_dup_EulerGraph Wise2_expand_dup_EulerGraph #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/vectorindex.dy0000644000175000001440000000451607723613712017340 0ustar philippusers %{ #include "dyna.h" #define KMER_VECTOR_LENGTH 4069 #define KMER_VECTOR_SIZE 6 typedef struct KmerVectorPosition { char kmer_vector[KMER_VECTOR_LENGTH]; long int position; } KmerVectorPosition; #define KmerVectorPositionSetLISTLENGTH 4096 %} struct KmerVectorPositionSet KmerVectorPosition ** vec !list %{ #include "vectorindex.h" double vector_KmerVectorPosition(KmerVectorPosition * a,KmerVectorPosition * b) { int i; double out = 0.0; for(i=0;ikmer_vector[i] * b->kmer_vector[i] / 256; } return out; } KmerVectorPosition * new_KmerVectorPosition(void) { KmerVectorPosition * out; out = malloc(sizeof(KmerVectorPosition)); bzero(out->kmer_vector,KMER_VECTOR_LENGTH); return out; } KmerVectorPositionSet * build_KmerVectorPositionSet(Sequence * input,long int start_pos,int step_size) { int i; int j; int k; int base[KMER_VECTOR_SIZE]; int temp; int is_forward; int curr; int forward; int backward; int vec; KmerVectorPosition * pos; KmerVectorPositionSet * out; assert(input != NULL); temp = 1; for(i=0;ilen / step_size)+2); for(i=0;i+step_sizelen;) { pos = new_KmerVectorPosition(); pos->position = start_pos + i; for(j=0;j<256 - KMER_VECTOR_SIZE;j++) { curr = i+j; /* first find lexical forward/backwardness */ is_forward = 1; /* palindromes read forward */ for(k=0;kseq[curr+k]); backward = complement_base(base_from_char(input->seq[curr+KMER_VECTOR_SIZE-k])); if( forward == backward ) { continue; } if( forward > backward ) { is_forward = 1; } else { is_forward = 0; } break; } vec = 0; for(k=0;kseq[curr+k]); } else { vec += base[k] * complement_base(base_from_char(input->seq[curr+KMER_VECTOR_SIZE-k])); } } assert(vec < KMER_VECTOR_LENGTH); pos->kmer_vector[vec]++; fatal("Ewan has not finished this yet! Idiot!"); } } return out; } KmerVectorPosition * free_KmerVectorPosition(KmerVectorPosition * vec) { free(vec); return NULL; } %} wise-2.4.1/src/dnaindex/compressed_protein_index.dy0000644000175000001440000001536210257314505022074 0ustar philippusers %{ #include "seqlookup.h" #include "kmer_index_interface.h" #include "kmer_direct.h" #include "singleseqspace.h" typedef struct CompressedProteinHead { int * positions; int maxlen; } CompressedProteinHead; #define COMPRESSED_INITIAL_SIZE 50 #define COMPRESSED_EXPAND 50 #define COMPRESSED_PROTEIN_CLIENT_INITIAL 16 %} struct CompressedProteinIndex KmerIndexInterface * kii SinglePosSpace * sps struct CompressedProteinClient SeqLookupResultStruct * res !link // actually we'll free this on demand int maxlen int current int point CompressedProteinIndex * index !link %{ #include "compressed_protein_index.h" SeqLookupResultStruct * get_next_CompressedProteinClient(void * data,SeqLookupResultStruct * prev) { CompressedProteinClient * cl = (CompressedProteinClient *)data; /* fprintf(stdout," entering with point %d max %d\n",cl->point,cl->current); */ if( prev == NULL ) { assert(cl->point == 0); } else { assert(&(cl->res[cl->point-1]) == prev); } if( cl->point == cl->current ) { return NULL; } else { return &cl->res[cl->point++]; } } boolean is_more_CompressedProteinClient(void * data) { CompressedProteinClient * cl = (CompressedProteinClient *)data; if( cl->point < cl->current ) { return TRUE; } else { return FALSE; } } void free_SeqLookupResultInterface_CompressedProteinClient(void * data) { /* no op*/ return; } SeqLookupResultInterface * lookup_CompressedProteinClient(void * data,int seq_number) { CompressedProteinClient * cl = (CompressedProteinClient *)data; int i; CompressedProteinHead * h; SeqLookupResultInterface * out; SinglePosSequence * pos; int len; out = SeqLookupResultInterface_alloc(); h = (CompressedProteinHead*)(*cl->index->kii->retrieve_by_kmer)(cl->index->kii->handle,(kmer_t)seq_number); if( h == NULL ) { cl->current = 0; cl->point = 0; } else { for(i=0;imaxlen;i++) { if( h->positions[i] == -1 ) { break; } } assert(i < h->maxlen); len = i; if( cl->maxlen < len ) { cl->maxlen = cl->maxlen * 2; cl->res = realloc(cl->res,sizeof(SeqLookupResultStruct)*cl->maxlen); } for(i=0;iindex->sps,h->positions[i]); cl->res[i].seq = (Sequence*)pos->data; cl->res[i].pos = (int)(h->positions[i] - pos->start); } cl->current = len; cl->point = 0; } out->data = cl; out->next = get_next_CompressedProteinClient; out->is_more = is_more_CompressedProteinClient; out->free_data = free_SeqLookupResultInterface_CompressedProteinClient; return out; } boolean is_populated_CompressedProteinClient(void * data,int seq_number) { CompressedProteinHead * h; CompressedProteinClient * cl = (CompressedProteinClient *)data; h = (CompressedProteinHead*)(*cl->index->kii->retrieve_by_kmer)(cl->index->kii->handle,(kmer_t)seq_number); if( h == NULL ) { return FALSE; } else { return TRUE; } } void free_Client_CompressedProteinClient(void * data) { CompressedProteinClient * cl = (CompressedProteinClient *)data; free(cl->res); free_CompressedProteinClient(cl); } SeqLookupInterface * new_direct_CompressedProteinLookup(void) { KmerIndexInterface * kii; kii = new_KmerDirectIndex(12); return new_CompressedProteinLookup(kii); } SeqLookupInterface * new_CompressedProteinLookup(KmerIndexInterface * kii) { CompressedProteinIndex * cpi; SeqLookupInterface * out; out = SeqLookupInterface_alloc_std(); cpi = CompressedProteinIndex_alloc(); cpi->kii = kii; cpi->sps = new_SinglePosSpace(1,1000); out->data = (void*)cpi; out->get_client = get_client_CompressedProteinIndex; out->add_seq = add_seq_CompressedProteinIndex; out->lookup_array_head = NULL; out->add_direct_number = add_direct_number_CompressedProteinIndex; out->free_data = free_data_CompressedProteinIndex; return out; } SeqLookupClientInterface * get_client_CompressedProteinIndex(void * data) { SeqLookupClientInterface * out; CompressedProteinClient * cl; cl = new_CompressedProteinClient(); out = SeqLookupClientInterface_alloc(); cl->index = (CompressedProteinIndex*)data; assert(cl->index != NULL); out->data = (void*)cl; out->lookup = lookup_CompressedProteinClient; out->is_populated = is_populated_CompressedProteinClient; out->free_data = free_Client_CompressedProteinClient; return out; } CompressedProteinClient * new_CompressedProteinClient(void) { CompressedProteinClient * out; out = CompressedProteinClient_alloc(); out->res = calloc(COMPRESSED_PROTEIN_CLIENT_INITIAL,sizeof(SeqLookupResultStruct)); out->current = 0; out->maxlen = COMPRESSED_PROTEIN_CLIENT_INITIAL; return out; } boolean add_direct_number_CompressedProteinIndex(void * data,int seq_number,Sequence * target, int pos) { fatal("For compressed protein indexes, impossible to add numbers directly"); return NULL; } ArraySeqHead * lookup_array_head_CompressedProteinIndex(void * data,int seq_number) { fatal("For compressed protein indexes, arrayseqhead lookup is not feasible"); return NULL; } boolean add_seq_CompressedProteinIndex(void * data,Sequence * seq,SeqLookupLoadPara * para) { long int offset; int no; int i; void * kmer_data; CompressedProteinHead * h; CompressedProteinIndex * cpi = (CompressedProteinIndex *) data; assert(cpi != NULL); assert(seq != NULL); offset = add_Sequence_SinglePosSpace(cpi->sps,(long int)seq->len,(void *) seq); for(i=0;ilen-5;) { no = seq_number_aa_5mer(seq->seq+i); if( (kmer_data = (*cpi->kii->retrieve_by_kmer)(cpi->kii->handle,(kmer_t)no)) == NULL ) { h = new_CompressedProteinHead(); (*cpi->kii->insert_by_kmer)(cpi->kii->handle,(kmer_t)no,(void*)h); } else { h = (CompressedProteinHead*) kmer_data; } add_pos_CompressedProteinHead(h,(int)offset+i); i += para->tile_freq; } return TRUE; } void free_data_CompressedProteinIndex(void * d) { CompressedProteinIndex * cpi = (CompressedProteinIndex *)d; assert(cpi != NULL); free_CompressedProteinIndex(cpi); } boolean add_pos_CompressedProteinHead(CompressedProteinHead * c,int pos) { int i; assert(c != NULL); for(i=0;imaxlen;i++) { if( c->positions[i] == -1 ) { break; } } assert(i < c->maxlen); if( i+2 == c->maxlen ) { c->maxlen += COMPRESSED_EXPAND; c->positions = realloc(c->positions,sizeof(int)*c->maxlen); } c->positions[i] = pos; c->positions[i+1] = -1; return TRUE; } CompressedProteinHead * new_CompressedProteinHead(void) { CompressedProteinHead * out; out = malloc(sizeof(CompressedProteinHead)); assert(out != NULL); out->maxlen = COMPRESSED_INITIAL_SIZE; out->positions = malloc(sizeof(int)*out->maxlen); out->positions[0] = -1; return out; } %} wise-2.4.1/src/dnaindex/kmer_assembly_error.c0000644000175000001440000004112710670453716020662 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "kmer_assembly_error.h" # line 14 "kmer_assembly_error.dy" boolean lift_indel_error_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyPath * real,KmerAssemblyPath * error,long int * start_labels,int label_len,int error_position,int error_len) { int i,j,k,true; for(i=0,true=0;istack_len && truestack_len;i++,true++) { if( i == error_position ) { if( error_len > 0 ) { for(j=0;jstack[i] == NULL ) { fprintf(stderr,"issue - error path is missing a link!"); } else { remove_sequence_label_KmerAssemblyLink(error->stack[i],start_labels[k]+i); } if( real->stack[true] == NULL ) { fprintf(stderr,"issue - true path is missing a link!"); } else { add_sequence_label_KmerAssemblyLink(real->stack[true],start_labels[k]+i); } if( error->stack[i] != NULL && error->stack[i]->sequence_label_len == 0 ) { detach_KmerAssemblyLink(kai,error->stack[i]); } } } return TRUE; } # line 57 "kmer_assembly_error.dy" boolean lift_forward_error_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyPath * real,KmerAssemblyPath * error,long int * start_labels,int label_len) { int i,k; for(i=0;istack_len;i++) { for(k=0;kstack[i],start_labels[k]+i); add_sequence_label_KmerAssemblyLink(real->stack[i],start_labels[k]+i); if( error->stack[i]->sequence_label_len == 0 ) { detach_KmerAssemblyLink(kai,error->stack[i]); } } } return TRUE; } # line 75 "kmer_assembly_error.dy" int mark_tangles_KmerAssembly(KmerAssemblyIndex * kai) { int i; kmer_t kmer; KmerAssemblyNode * node; char buffer[256]; int count = 0; kmer = -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); if( node->prev_len > 1 ) { reverse_map_dna_number(node->number,kai->kii->kmer_size,buffer); buffer[kai->kii->kmer_size] = '\0'; fprintf(stderr,"Marking node (%ld) [%s] as next tangled\n",node->number,buffer); count++; for(i=0;iprev_len;i++) { node->prev[i]->state |= KMER_ASSEMBLY_NEXT_TANGLED; } } if( node->next_len > 1 ) { reverse_map_dna_number(node->number,kai->kii->kmer_size,buffer); buffer[kai->kii->kmer_size] = '\0'; fprintf(stderr,"Marking node (%ld) [%s] as prev tangled\n",node->number,buffer); count++; for(i=0;inext_len;i++) { node->next[i]->state |= KMER_ASSEMBLY_PREV_TANGLED; } } } return count; } # line 116 "kmer_assembly_error.dy" int resolve_forward_errors_KmerAssembly(KmerAssemblyIndex * kai,int depth,int verbose,int max_path_enum) { int i; int total = 0; kmer_t kmer; KmerAssemblyNode * node; char buffer[128]; SinglePosSequence * sps; assert(kai != NULL); assert(kai->kii != NULL ); assert(kai->kii->next_filled_kmer != NULL); kmer = -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); assert(node != NULL); if( node->next_len < 2 ) { continue; } for(i=0;inext_len;i++) { if( node->next[i]->sequence_label_len <= depth ) { if( verbose ) { reverse_map_dna_number(node->next[i]->next->number,kai->kii->kmer_size,buffer); buffer[kai->kii->kmer_size] = '\0'; sps = lookup_Sequence_SinglePosSpace(kai->sps,node->next[i]->sequence_label[0]); fprintf(stderr,"Attempting to resolve error [%s] from sequence %s, depth %d\n",buffer,((AssemblySequence*)sps->data)->seq->name,node->next[i]->sequence_label_len); } total += attempt_resolve_forward_error_KmerAssembly(kai,node,depth,max_path_enum); break; } } } return total; } # line 163 "kmer_assembly_error.dy" void remove_errors_KmerAssemblyIndex(KmerAssemblyIndex * kai,int max_error_depth) { int i; kmer_t kmer; KmerAssemblyNode * node; assert(kai != NULL); assert(kai->kii != NULL); assert(kai->kii->next_filled_kmer != NULL); kmer = -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); assert(node); if( node->next_len > 1 ) { for(i=0;inext_len;i++) { if( node->next[i]->sequence_label_len <= max_error_depth ) { detach_KmerAssemblyLink(kai,node->next[i]); } } } if( node->prev_len > 1 ) { for(i=0;iprev_len;i++) { if( node->prev[i]->sequence_label_len <= max_error_depth ) { detach_KmerAssemblyLink(kai,node->prev[i]); } } } } } # line 200 "kmer_assembly_error.dy" int attempt_resolve_forward_error_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyNode * node,int depth,int max_path_enum) { int success; int i,j,k; KmerAssemblyPath * final_real; KmerAssemblyPath * final_error; char * alphabet = "ATGC"; char buffer[256]; char next[256]; char selfbase; kmer_t new_number; int no_success = 0; int no_failures = 0; assert(kai != NULL); assert(node != NULL); final_real = new_KmerAssemblyPath(); final_error = new_KmerAssemblyPath(); if( node->next_len == 0 ) { warn("No outgoing links, therefore no errors"); return TRUE; } if( node->next_len == 0 ) { warn("Only one outgoing link, so no error"); return TRUE; } /* look for links with depth outgoing */ for(i=0;inext_len;i++) { if( node->next[i]->sequence_label_len <= depth ) { /* see whether this is an error*/ success = 0; reverse_map_dna_number(node->next[i]->next->number,kai->kii->kmer_size,buffer); selfbase = buffer[kai->kii->kmer_size-1]; /* test each base */ for(j=0;j<4;j++) { if( alphabet[j] == selfbase ) { continue; } buffer[kai->kii->kmer_size-1] = alphabet[j]; new_number = forward_dna_number_from_string(buffer,kai->kii->kmer_size); for(k=0;knext_len;k++) { if( k == i ) { continue; } if( new_number == node->next[k]->next->number ) { /* potential fix */ final_error->stack_len = 0; final_real->stack_len = 0; fprintf(stderr,"Found potential fix of %c to %c in %.*s (real:%c (%d), error:%c (%d))\n",selfbase,alphabet[j],kai->kii->kmer_size,buffer,node->next[k]->base,k,node->next[i]->base,i); /* consider potential insertion of one base */ if( find_indel_path_KmerAssembly(node->next[k],node->next[i],-1,kai->kii->kmer_size-1,final_real,final_error,kai->kii->kmer_size+1,max_path_enum) == TRUE ) { fprintf(stderr,"SUCCESS in insertion modelling\n"); lift_indel_error_KmerAssembly(kai,final_real,final_error,node->next[i]->sequence_label,node->next[i]->sequence_label_len,kai->kii->kmer_size-1,-1); success = 1; break; } if( find_indel_path_KmerAssembly(node->next[k],node->next[i],1,kai->kii->kmer_size-1,final_real,final_error,kai->kii->kmer_size+1,max_path_enum) == TRUE ) { fprintf(stderr,"SUCCESS in deletion modelling\n"); lift_indel_error_KmerAssembly(kai,final_real,final_error,node->next[i]->sequence_label,node->next[i]->sequence_label_len,kai->kii->kmer_size-1,1); success = 1; break; } /* otherwise substitution is all we can really suggest... */ if( find_error_path_KmerAssembly(node->next[k],node->next[i],alphabet[j],kai->kii->kmer_size-1,final_real,final_error,kai->kii->kmer_size+1,max_path_enum) == TRUE ) { /* fix error */ /* fprintf(stderr,"Found Error: Real\n"); show_KmerAssemblyPath(final_real,stderr); fprintf(stderr," Error\n"); show_KmerAssemblyPath(final_error,stderr); fprintf(stderr,"\n"); */ fprintf(stderr,"SUCCESS in substitution modelling\n"); lift_forward_error_KmerAssembly(kai,final_real,final_error,node->next[i]->sequence_label,node->next[i]->sequence_label_len); success = 1; break; } } } } if( success == 0 ) { no_failures++; } else { no_success++; } } } free_KmerAssemblyPath(final_real); free_KmerAssemblyPath(final_error); return no_success; } # line 315 "kmer_assembly_error.dy" boolean find_indel_path_KmerAssembly(KmerAssemblyLink *real,KmerAssemblyLink * error,int delete_length,int proposed_position,KmerAssemblyPath * final_real,KmerAssemblyPath * final_error,int max_search,int max_path_enum) { int current_path = 1; return extend_indel_path_KmerAssembly(real,error,0,0,delete_length,proposed_position,final_real,final_error,max_search,¤t_path,max_path_enum); } # line 322 "kmer_assembly_error.dy" boolean extend_indel_path_KmerAssembly(KmerAssemblyLink* real,KmerAssemblyLink * error,int real_pos,int error_pos,int delete_length,int proposed_position,KmerAssemblyPath * final_real,KmerAssemblyPath * final_error,int max_search,int *current_path,int max_path_enum) { int real_start; int error_start; int k; int i,j; KmerAssemblyLink * temp_real[256]; KmerAssemblyLink * temp_error[256]; if( max_search > 256 ) { fatal("Madness. Max search greater than 256 - shouldn't happen!"); } if( max_path_enum < *current_path ) { fprintf(stderr,"Terminating due too many paths\n"); return FALSE; } real_start = real_pos; error_start = error_pos; /* fprintf(stderr,"Entering into extension code with real %d, error %d\n",real_pos,error_pos);*/ while( real != NULL && error != NULL ) { if( proposed_position != real_pos ) { if( real->base != error->base ) { fprintf(stderr,"in considering indel (%d, path %d), real (%c) and error (%c) do not agree at position %d,%d\n",delete_length,current_path,real->base,error->base,real_pos,error_pos); return FALSE; } } else { if( delete_length > 0 ) { /* we move along in the real positions by delete number */ for(k=0;knext->next[0]; if( real == NULL ) { return FALSE; } if( real->next->next_len > 1 ) { fprintf(stderr,"Cannot handle over branched cases in indel area\n"); return FALSE; } } } else { /* we move along in the error positions by the delete number */ delete_length = abs(delete_length); for(k=0;knext->next[0]; if( error == NULL ) { return FALSE; } if( error->next->next_len > 1 ) { fprintf(stderr,"Cannot handle over branched cases in indel area\n"); return FALSE; } } } } temp_real[real_pos++] = real; temp_error[error_pos++] = error; if( real_pos > max_search ) { /* will return TRUE after loop */ break; } if( real == error ) { /* same node, therefore the streams have successfully merged */ break; } if( real->next->next_len == 1 && error->next->next_len == 1 ) { real = real->next->next[0]; error = error->next->next[0]; continue; } /* this is a tail position */ if( error->next->next_len == 0 ) { /* will return TRUE after loop */ break; } /* recursively call for each possible path: if any return true, return TRUE */ /* fprintf(stderr,"paths are branching, real with %d, error with %d\n",real->next->next_len,error->next->next_len);*/ if( real->next->next_len > 1 || error->next->next_len > 1 ) { for(i=0;inext->next_len;i++) { for(j=0;jnext->next_len;j++) { (*current_path)++; if( extend_indel_path_KmerAssembly(real->next->next[i],error->next->next[j],real_pos,error_pos,delete_length,proposed_position,final_real,final_error,max_search,current_path,max_path_enum) == TRUE ) { break; } } } /* fprintf(stderr,"Recursively unable to find path\n");*/ /* unable to find a good path */ return FALSE; } fprintf(stderr,"should be impossible to reach here, all other options have been considered"); return FALSE; } /* have to put the right path into the path datastructures */ /* we might have to extend the path datastructures */ if( final_real->max_stack < real_pos || final_error->max_stack < error_pos ) { fatal("Have to extend path; should be easy, but not done yet"); } if( final_real->stack_len < real_pos ) { /* first return */ final_real->stack_len = real_pos; } if( final_error->stack_len < error_pos ) { /* first return */ final_error->stack_len = error_pos; } for(i=real_start;istack[i] = temp_real[i]; } for(i=error_start;istack[i] = temp_error[i]; } return TRUE; } # line 476 "kmer_assembly_error.dy" boolean find_error_path_KmerAssembly(KmerAssemblyLink * start_real,KmerAssemblyLink * start_error,char proposed_fix,int proposed_fix_position,KmerAssemblyPath * final_real,KmerAssemblyPath * final_error,int max_search,int max_path_enum) { int current_path = 1; return extend_error_path_KmerAssembly(start_real,start_error,0,proposed_fix,proposed_fix_position,final_real,final_error,max_search,¤t_path,max_path_enum); } # line 483 "kmer_assembly_error.dy" boolean extend_error_path_KmerAssembly(KmerAssemblyLink * real,KmerAssemblyLink * error,int current_pos,char proposed_fix,int proposed_fix_position,KmerAssemblyPath * final_real,KmerAssemblyPath * final_error,int max_search,int * current_path,int max_path_enum) { int i; int j; int temp_pos; int startpos = current_pos; KmerAssemblyLink * temp_real[256]; KmerAssemblyLink * temp_error[256]; if( max_search > 256 ) { fatal("Madness. Max search greater than 256 - shouldn't happen!"); } if( max_path_enum < *current_path ) { fprintf(stderr,"Terminating due too many paths\n"); return FALSE; } temp_pos = current_pos; /* fprintf(stderr,"Entering into extension code with %d temp_pos\n",temp_pos);*/ while( real != NULL && error != NULL ) { if( proposed_fix_position != temp_pos ) { if( real->base != error->base ) { /* fprintf(stderr,"real (%c) and error (%c) do not agree at position %d\n",real->base,error->base,temp_pos); */ return FALSE; } } else if ( real->base != proposed_fix ) { fprintf(stderr,"In fixed position real (%c) and proposed (%c) do not agree\n",real->base,proposed_fix); return FALSE; } temp_real[temp_pos] = real; temp_error[temp_pos] = error; temp_pos++; if( temp_pos > max_search ) { /* will return TRUE after loop */ break; } if( real->next->next_len == 1 && error->next->next_len == 1 ) { real = real->next->next[0]; error = error->next->next[0]; continue; } /* this is a tail position */ if( error->next->next_len == 0 ) { /* will return TRUE after loop */ break; } /* recursively call for each possible path: if any return true, return TRUE */ /* fprintf(stderr,"paths are branching, real with %d, error with %d\n",real->next->next_len,error->next->next_len);*/ if( real->next->next_len > 1 || error->next->next_len > 1 ) { for(i=0;inext->next_len;i++) { for(j=0;jnext->next_len;j++) { (*current_path)++; if( extend_error_path_KmerAssembly(real->next->next[i],error->next->next[j],temp_pos,proposed_fix,proposed_fix_position,final_real,final_error,max_search,current_path,max_path_enum) == TRUE ) { break; } } } /* fprintf(stderr,"Recursively unable to find path\n");*/ /* unable to find a good path */ return FALSE; } fprintf(stderr,"should be impossible to reach here, all other options have been considered"); return FALSE; } /* have to put the right path into the path datastructures */ /* we might have to extend the path datastructures */ if( final_real->max_stack < temp_pos || final_error->max_stack < temp_pos ) { fatal("Have to extend path; should be easy, but not done yet"); } if( final_real->stack_len < temp_pos ) { /* first return */ final_real->stack_len = temp_pos; final_error->stack_len = temp_pos; } for(i=startpos;istack[i] = temp_real[i]; final_error->stack[i] = temp_error[i]; } return TRUE; } # line 595 "kmer_assembly_error.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/kmer_assembly_error.h0000644000175000001440000000640310670453716020665 0ustar philippusers#ifndef DYNAMITEkmer_assembly_errorHEADERFILE #define DYNAMITEkmer_assembly_errorHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "kmer_assembly.h" #include "kmer_assembly_untangler.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Unplaced functions */ /* There has been no indication of the use of these functions */ boolean Wise2_lift_indel_error_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyPath * real,KmerAssemblyPath * error,long int * start_labels,int label_len,int error_position,int error_len); #define lift_indel_error_KmerAssembly Wise2_lift_indel_error_KmerAssembly boolean Wise2_lift_forward_error_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyPath * real,KmerAssemblyPath * error,long int * start_labels,int label_len); #define lift_forward_error_KmerAssembly Wise2_lift_forward_error_KmerAssembly int Wise2_mark_tangles_KmerAssembly(KmerAssemblyIndex * kai); #define mark_tangles_KmerAssembly Wise2_mark_tangles_KmerAssembly int Wise2_resolve_forward_errors_KmerAssembly(KmerAssemblyIndex * kai,int depth,int verbose,int max_path_enum); #define resolve_forward_errors_KmerAssembly Wise2_resolve_forward_errors_KmerAssembly void Wise2_remove_errors_KmerAssemblyIndex(KmerAssemblyIndex * kai,int max_error_depth); #define remove_errors_KmerAssemblyIndex Wise2_remove_errors_KmerAssemblyIndex int Wise2_attempt_resolve_forward_error_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyNode * node,int depth,int max_path_enum); #define attempt_resolve_forward_error_KmerAssembly Wise2_attempt_resolve_forward_error_KmerAssembly boolean Wise2_find_indel_path_KmerAssembly(KmerAssemblyLink *real,KmerAssemblyLink * error,int delete_length,int proposed_position,KmerAssemblyPath * final_real,KmerAssemblyPath * final_error,int max_search,int max_path_enum); #define find_indel_path_KmerAssembly Wise2_find_indel_path_KmerAssembly boolean Wise2_extend_indel_path_KmerAssembly(KmerAssemblyLink* real,KmerAssemblyLink * error,int real_pos,int error_pos,int delete_length,int proposed_position,KmerAssemblyPath * final_real,KmerAssemblyPath * final_error,int max_search,int *current_path,int max_path_enum); #define extend_indel_path_KmerAssembly Wise2_extend_indel_path_KmerAssembly boolean Wise2_find_error_path_KmerAssembly(KmerAssemblyLink * start_real,KmerAssemblyLink * start_error,char proposed_fix,int proposed_fix_position,KmerAssemblyPath * final_real,KmerAssemblyPath * final_error,int max_search,int max_path_enum); #define find_error_path_KmerAssembly Wise2_find_error_path_KmerAssembly boolean Wise2_extend_error_path_KmerAssembly(KmerAssemblyLink * real,KmerAssemblyLink * error,int current_pos,char proposed_fix,int proposed_fix_position,KmerAssemblyPath * final_real,KmerAssemblyPath * final_error,int max_search,int * current_path,int max_path_enum); #define extend_error_path_KmerAssembly Wise2_extend_error_path_KmerAssembly /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/kmer_glib_index.c0000644000175000001440000000527010670453716017735 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "kmer_glib_index.h" # line 28 "kmer_glib_index.dy" KmerIndexInterface * new_interface_KmerGlibIndex(int kmer_size) { KmerIndexInterface * out; KmerGlibIndex * kgi; assert(kmer_size < 16); kgi = new_KmerGlibIndex(); out = malloc(sizeof(KmerIndexInterface)); out->retrieve_by_kmer = retrieve_by_kmer_KmerGlibIndex; out->insert_by_kmer = insert_by_kmer_KmerGlibIndex; out->free_handle = free_KmerGlibIndex; out->next_filled_kmer = next_filled_kmer_KmerGlibIndex; out->handle = (void*) kgi; out->kmer_size = kmer_size; return out; } # line 53 "kmer_glib_index.dy" kmer_t next_filled_kmer_KmerGlibIndex(void * handle,kmer_t prev) { KmerGlibIndex * kgi = (KmerGlibIndex*) handle; if( prev == -1 ) { if( kgi->active_index == NULL ) { make_active_kmer_KmerGlibIndex(kgi); } kgi->kmer_pos = 0; } if( kgi->kmer_pos < kgi->active_index_length ) { return kgi->active_index[kgi->kmer_pos++]; } else { return -1; } } # line 73 "kmer_glib_index.dy" void * retrieve_by_kmer_KmerGlibIndex(void * handle,kmer_t kmer) { KmerGlibIndex * kgi = (KmerGlibIndex*) handle; return (void*) g_hash_table_lookup(kgi->hash,(gconstpointer)kmer); } # line 80 "kmer_glib_index.dy" boolean insert_by_kmer_KmerGlibIndex(void * handle,kmer_t kmer,void * poi) { KmerGlibIndex * kgi = (KmerGlibIndex*) handle; g_hash_table_insert(kgi->hash,(gpointer)kmer,poi); return TRUE; } # line 89 "kmer_glib_index.dy" void free_KmerGlibIndex(void * handle) { KmerGlibIndex * kgi = (KmerGlibIndex*) handle; assert(kgi); warn("Not freeing glib hash, so leaking memory here"); free(kgi); } # line 102 "kmer_glib_index.dy" boolean make_active_kmer_KmerGlibIndex(void * handle) { KmerGlibIndex * kgi = (KmerGlibIndex*) handle; int size; assert(kgi); size = g_hash_table_size(kgi->hash); kgi->active_index = calloc(size,sizeof(kmer_t)); kgi->active_index_length = size; kgi->kmer_pos = 0; g_hash_table_foreach(kgi->hash,retrieve_active_kmer_KmerGlibIndex,(gpointer)kgi); kgi->kmer_pos = 0; return TRUE; } # line 120 "kmer_glib_index.dy" void retrieve_active_kmer_KmerGlibIndex(gpointer key,gpointer value,gpointer user_data) { KmerGlibIndex * kgi = (KmerGlibIndex*) user_data; kgi->active_index[kgi->kmer_pos++] = (kmer_t) key; } # line 128 "kmer_glib_index.dy" KmerGlibIndex * new_KmerGlibIndex(void) { KmerGlibIndex * out; out = malloc(sizeof(KmerGlibIndex)); out->hash = g_hash_table_new(g_direct_hash,g_direct_equal); out->active_index = NULL; out->kmer_pos = 0; out->active_index_length = 0; return out; } # line 132 "kmer_glib_index.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/kmer_glib_index.h0000644000175000001440000000377310670453716017750 0ustar philippusers#ifndef DYNAMITEkmer_glib_indexHEADERFILE #define DYNAMITEkmer_glib_indexHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "kmer_index_interface.h" #include "glib.h" typedef struct KmerGlibIndex { GHashTable * hash; kmer_t index_length; kmer_t * active_index; int kmer_pos; int active_index_length; } KmerGlibIndex; /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Unplaced functions */ /* There has been no indication of the use of these functions */ KmerIndexInterface * Wise2_new_interface_KmerGlibIndex(int kmer_size); #define new_interface_KmerGlibIndex Wise2_new_interface_KmerGlibIndex kmer_t Wise2_next_filled_kmer_KmerGlibIndex(void * handle,kmer_t prev); #define next_filled_kmer_KmerGlibIndex Wise2_next_filled_kmer_KmerGlibIndex void * Wise2_retrieve_by_kmer_KmerGlibIndex(void * handle,kmer_t kmer); #define retrieve_by_kmer_KmerGlibIndex Wise2_retrieve_by_kmer_KmerGlibIndex boolean Wise2_insert_by_kmer_KmerGlibIndex(void * handle,kmer_t kmer,void * poi); #define insert_by_kmer_KmerGlibIndex Wise2_insert_by_kmer_KmerGlibIndex void Wise2_free_KmerGlibIndex(void * handle); #define free_KmerGlibIndex Wise2_free_KmerGlibIndex boolean Wise2_make_active_kmer_KmerGlibIndex(void * handle); #define make_active_kmer_KmerGlibIndex Wise2_make_active_kmer_KmerGlibIndex void Wise2_retrieve_active_kmer_KmerGlibIndex(gpointer key,gpointer value,gpointer user_data); #define retrieve_active_kmer_KmerGlibIndex Wise2_retrieve_active_kmer_KmerGlibIndex KmerGlibIndex * Wise2_new_KmerGlibIndex(void) ; #define new_KmerGlibIndex Wise2_new_KmerGlibIndex /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/assembly_sanger_project.c0000644000175000001440000001442610670453716021522 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "assembly_sanger_project.h" # line 23 "assembly_sanger_project.dy" AssemblySequence * next_AssemblySequence_sanger_impl(void * h) { char buffer[MAXLINE]; AssemblySequence * aseq; char * run; FILE * ifp; SangerProjectDirectory * s = (SangerProjectDirectory *) h; struct dirent * dirp; while( (dirp = readdir(s->dir)) != NULL ) { if( (run = strstr(dirp->d_name,s->extension)) != NULL ) { /* should check it is at the end */ if( strcmp(run,s->extension) != 0 ) { /* not at end */ continue; } sprintf(buffer,"%s/%s",s->directory,dirp->d_name); ifp = fopen(buffer,"r"); if( ifp == NULL ) { warn("This is crazy! name is in directory but cannot open file. Yikes"); return NULL; } aseq = read_clipped_sanger_AssemblySequence(ifp); fclose(ifp); return aseq; } } return NULL; } # line 61 "assembly_sanger_project.dy" AssemblySequence * read_clipped_sanger_AssemblySequence(FILE * ifp) { AssemblySequence * out; Sequence * in; char * seqstr; char * run; int maxlen; int curr_pos; int in_seq = 0; int clip_start = -1; int clip_end = -1; int temp; char buffer[512]; char name[60]; seqstr = malloc(sizeof(char)*1028); maxlen = 1028; curr_pos = 0; while( fgets(buffer,512,ifp) != NULL ) { if( strstartcmp(buffer,"ID") == 0 ) { sscanf(buffer,"ID %s",name); continue; } if( strstartcmp(buffer,"QL") == 0 ) { sscanf(buffer,"QL %d",&clip_start); continue; } if( strstartcmp(buffer,"SL") == 0 ) { sscanf(buffer,"SL %d",&temp); if( temp > clip_start ) { clip_start = temp; } continue; } if( strstartcmp(buffer,"QR") == 0 ) { sscanf(buffer,"QR %d",&clip_end); continue; } if( strstartcmp(buffer,"SQ") == 0 ) { in_seq = 1; continue; } if( strstartcmp(buffer,"//") == 0 ) { in_seq = 0; continue; } if( in_seq == 1 ) { for(run=buffer;*run;run++) { if( !isspace(*run) ) { if( *run == '-' ) { seqstr[curr_pos++] = 'N'; } else { seqstr[curr_pos++] = *run; } } if( curr_pos >= maxlen ) { maxlen *= 2; seqstr = realloc(seqstr,sizeof(char)*(maxlen)); } } } } seqstr[curr_pos] = '\0'; if( clip_start == -1 ) { warn("No start clipping point found"); clip_start = 1; } if( clip_end == -1 ) { warn("No end clipping point found"); clip_end = strlen(seqstr); } /* seq to C coords*/ clip_start--; seqstr[clip_end] = '\0'; in = Sequence_from_static_memory(name,seqstr+clip_start); in->type = SEQUENCE_DNA; out = AssemblySequence_alloc_std(); out->seq = in; return out; } # line 156 "assembly_sanger_project.dy" void free_handle_sanger_impl(void * h) { SangerProjectDirectory * s = (SangerProjectDirectory *) h; free_SangerProjectDirectory(s); } # line 163 "assembly_sanger_project.dy" AssemblySequenceStream * new_sanger_project_AssemblySequenceStream(char * dir_name,char * extension) { AssemblySequenceStream * out; SangerProjectDirectory * spd; spd = new_SangerProjectDirectory(dir_name,extension); out = AssemblySequenceStream_alloc(); out->handle = (void*) spd; out->next_AssemblySequence = next_AssemblySequence_sanger_impl; out->free_handle = free_handle_sanger_impl; return out; } # line 179 "assembly_sanger_project.dy" SangerProjectDirectory * new_SangerProjectDirectory(char * dir_name,char * extension) { DIR * d; SangerProjectDirectory * out; d = opendir(dir_name); if( d == NULL ) { warn("Could not open directory %s",dir_name); return NULL; } out = SangerProjectDirectory_alloc(); out->dir = d; out->extension = stringalloc(extension); out->directory = stringalloc(dir_name); return out; } /* Function: free_SangerProjectDirectory(obj) * * Descrip: deconstructor * * * Arg: obj [UNKN ] Undocumented argument [SangerProjectDirectory *] * * Return [UNKN ] Undocumented return value [SangerProjectDirectory *] * */ # line 203 "assembly_sanger_project.dy" SangerProjectDirectory * free_SangerProjectDirectory(SangerProjectDirectory * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Sanger Project obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; closedir(obj->dir); if( obj->extension != NULL ) { free(obj->extension); } free(obj); return NULL; } # line 232 "assembly_sanger_project.c" /* Function: hard_link_SangerProjectDirectory(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SangerProjectDirectory *] * * Return [UNKN ] Undocumented return value [SangerProjectDirectory *] * */ SangerProjectDirectory * hard_link_SangerProjectDirectory(SangerProjectDirectory * obj) { if( obj == NULL ) { warn("Trying to hard link to a SangerProjectDirectory object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SangerProjectDirectory_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SangerProjectDirectory *] * */ SangerProjectDirectory * SangerProjectDirectory_alloc(void) { SangerProjectDirectory * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SangerProjectDirectory *) ckalloc (sizeof(SangerProjectDirectory))) == NULL) { warn("SangerProjectDirectory_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->dir = NULL; out->extension = NULL; out->directory = NULL; return out; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/assembly_sanger_project.h0000644000175000001440000000645310670453716021530 0ustar philippusers#ifndef DYNAMITEassembly_sanger_projectHEADERFILE #define DYNAMITEassembly_sanger_projectHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "assembly_stream_interface.h" #include #include struct Wise2_SangerProjectDirectory { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DIR * dir; char * extension; char * directory; } ; /* SangerProjectDirectory defined */ #ifndef DYNAMITE_DEFINED_SangerProjectDirectory typedef struct Wise2_SangerProjectDirectory Wise2_SangerProjectDirectory; #define SangerProjectDirectory Wise2_SangerProjectDirectory #define DYNAMITE_DEFINED_SangerProjectDirectory #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: free_SangerProjectDirectory(obj) * * Descrip: deconstructor * * * Arg: obj [UNKN ] Undocumented argument [SangerProjectDirectory *] * * Return [UNKN ] Undocumented return value [SangerProjectDirectory *] * */ SangerProjectDirectory * Wise2_free_SangerProjectDirectory(SangerProjectDirectory * obj); #define free_SangerProjectDirectory Wise2_free_SangerProjectDirectory /* Function: hard_link_SangerProjectDirectory(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SangerProjectDirectory *] * * Return [UNKN ] Undocumented return value [SangerProjectDirectory *] * */ SangerProjectDirectory * Wise2_hard_link_SangerProjectDirectory(SangerProjectDirectory * obj); #define hard_link_SangerProjectDirectory Wise2_hard_link_SangerProjectDirectory /* Function: SangerProjectDirectory_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SangerProjectDirectory *] * */ SangerProjectDirectory * Wise2_SangerProjectDirectory_alloc(void); #define SangerProjectDirectory_alloc Wise2_SangerProjectDirectory_alloc /* Unplaced functions */ /* There has been no indication of the use of these functions */ AssemblySequence * Wise2_next_AssemblySequence_sanger_impl(void * h); #define next_AssemblySequence_sanger_impl Wise2_next_AssemblySequence_sanger_impl AssemblySequence * Wise2_read_clipped_sanger_AssemblySequence(FILE * ifp); #define read_clipped_sanger_AssemblySequence Wise2_read_clipped_sanger_AssemblySequence void Wise2_free_handle_sanger_impl(void * h); #define free_handle_sanger_impl Wise2_free_handle_sanger_impl AssemblySequenceStream * Wise2_new_sanger_project_AssemblySequenceStream(char * dir_name,char * extension); #define new_sanger_project_AssemblySequenceStream Wise2_new_sanger_project_AssemblySequenceStream SangerProjectDirectory * Wise2_new_SangerProjectDirectory(char * dir_name,char * extension); #define new_SangerProjectDirectory Wise2_new_SangerProjectDirectory /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/comparapath.c0000644000175000001440000010202610670453716017107 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "comparapath.h" # line 88 "comparapath.dy" ComparaLinkStart * free_ComparaLinkStart(ComparaLinkStart * cls) { free(cls); return NULL; } # line 95 "comparapath.dy" void show_SetofHSPset(SetofHSPset * set,FILE * ofp) { int i; for(i=0;ilen;i++) { show_HSPset(set->hspset[i],ofp); } } # line 106 "comparapath.dy" SetofHSPset * SetofHSPset_from_ComparaIndex(ComparaIndex * ci,ComparaLinkStartSet * clss,FILE * logfp) { int i; HSPset * hsp; SetofHSPset * out; assert(ci != NULL); assert(clss != NULL); out = SetofHSPset_alloc_std(); for(i=0;ilen;i++) { if( clss->cls[i]->start != NULL ) { fprintf(logfp,"Considering sequence %s\n",clss->cls[i]->seq->name); fflush(logfp); hsp = HSPset_from_ComparaIndex(ci,clss->cls[i],logfp); add_SetofHSPset(out,hsp); } } return out; } # line 130 "comparapath.dy" HSPset * HSPset_from_ComparaIndex(ComparaIndex * ci,ComparaLinkStart * cls,FILE * logfp) { HSPset * out; HSP * hsp; ComparaHead * current; long int target_pos; ComparaHead * current_head; ComparaHead * prev = NULL; SinglePosSequence * query = NULL; SinglePosSequence * target = NULL; long int start_pos; long int next_report_post; long int last_pos; long int unplaced = 0; out = HSPset_alloc_std(); query = lookup_Sequence_SinglePosSpace(ci->sps,cls->start->position[0]); start_pos = cls->start->position[0]; next_report_post = start_pos; for(current = cls->start;current != NULL;) { if( current->next_query == current ) { fprintf(logfp,"Impossible; loop in next_query list, causing massive problems. have to abort"); fflush(logfp); fatal("loop in next query, cannot contiue"); } last_pos = current->position[0]; current_head = current; if( current_head == prev || (prev != NULL && current_head->position[0] == prev->position[0]) ) { fprintf(logfp,"Dangerous case of unmoving loop; artificalling moving on from position %ld\n",current->position[0]); fflush(logfp); current = current->next_query; current_head = current; if( current == NULL ) { break; } } prev = current; if( current->position[0] >= next_report_post ) { fprintf(logfp,"Seen %ld unplaced vs %ld positions\n",unplaced,current->position[0] - start_pos); fprintf(logfp,"Considering positions %ld,%ld with size %d and spline %ld, (current %ld, prev %ld next %ld)\n",current->position[0],current->position[1],current->size,current->spline,current,prev,current->next_query); next_report_post += 10000000; } if( COMPARA_IS_JOINT_FORWARD(current_head) ) { /* fprintf(logfp,"Found forward, with state %d (len %d)\n",current_head->state,current_head->size); fflush(logfp); */ target_pos = current_head->position[1]; if( target == NULL || target->end > target_pos || target->start < target_pos ) { target = lookup_Sequence_SinglePosSpace(ci->sps,target_pos); } assert(target); assert(target->data); /* fprintf(logfp," ...forward is %s %ld\n",((Sequence*)target->data)->name,target_pos - target->start); fflush(logfp); */ hsp = new_dna_identical_HSP((Sequence*)query->data,(Sequence*)target->data,current->position[0] - query->start,target_pos - target->start,0); add_HSPset(out,hsp); for(;current != NULL && (current->position[0] - query->start) < hsp->query_start + hsp->length;current = current->next_query) ; } else if ( COMPARA_IS_JOINT_REVERSE(current_head) ) { /* fprintf(logfp,"Found reverse, with state %d (len %d)\n",current_head->state,current_head->size); fflush(logfp); */ target_pos = current_head->spline->position[0]; if( target == NULL || target->end > target_pos || target->start < target_pos ) { target = lookup_Sequence_SinglePosSpace(ci->sps,target_pos); } /* fprintf(logfp," ...reverse is %s %ld\n",((Sequence *)target->data)->name,target_pos - target->start); fflush(logfp); */ hsp = new_dna_identical_HSP((Sequence*)query->data,(Sequence*)target->data,current->position[0] - query->start,target_pos - target->start + ci->kii->kmer_size -1,1); add_HSPset(out,hsp); for(;current != NULL && (current->position[0] - query->start) < hsp->query_start + hsp->length;current = current->next_query) ; } else { unplaced++; current = current->next_query; } } fprintf(logfp,"PLACED %s %ld unplaced positions vs %ld considered\n",cls->seq->name,unplaced,last_pos - start_pos); fflush(logfp); return out; } # line 254 "comparapath.dy" boolean is_joint_forward(ComparaHead * h) { if( h->spline != NULL ) { return 0; } if( (h->state & COMPARA_QUERY_UNIQUE) && (h->state & COMPARA_TARGET_UNIQUE) ) { return 1; } return 0; } # line 266 "comparapath.dy" boolean is_joint_reverse(ComparaHead * h) { if( h->spline == NULL ) { return 0; } if( (h->state & COMPARA_QUERY_UNIQUE) && (h->spline->state & COMPARA_TARGET_UNIQUE) && !(h->spline->state & COMPARA_QUERY_UNIQUE) && !(h->spline->state & COMPARA_QUERY_MULTIPLE) ) { return 1; } /* if( (h->spline->state & COMPARA_QUERY_UNIQUE) && (h->state & COMPARA_TARGET_UNIQUE) && !(h->spline->state & COMPARA_TARGET_UNIQUE) && !(h->spline->state & COMPARA_TARGET_MULTIPLE) ) { return 1; } */ return 0; } # line 292 "comparapath.dy" void show_distrib_ComparaIndex(ComparaIndex * ci,ComparaLinkStart * cls,FILE * ofp) { long len = 0; int count[4]; int i; ComparaHead * current; ComparaHead * chead; for(i=0;i<4;i++) { count[i] =0; } for(current = cls->start;current != NULL;current = current->next_query) { chead = current; if( chead == NULL ) { continue; } count[(int)chead->size]++; len++; } fprintf(ofp,"Seen %ld links...\n",len); for(i=0;i<3;i++) { fprintf(ofp,"%5d %d\n",i,count[i]); } } # line 325 "comparapath.dy" void show_stats_ComparaIndex(ComparaIndex * ci,ComparaLinkStart * cls,FILE * ofp) { int i; int t_unique = 0; int q_unique = 0; int joint = 0; int rev_joint =0; int t_multiple = 0; int q_multiple = 0; ComparaHead *chead; ComparaHead * current; for(current = cls->start;current != NULL;current = current->next_query) { i = current->number; chead = current; if( chead == NULL ) { continue; } if( chead->state & COMPARA_TARGET_UNIQUE ) t_unique++; if( chead->state & COMPARA_QUERY_UNIQUE ) q_unique++; if( (chead->state & COMPARA_TARGET_UNIQUE) && (chead->state & COMPARA_QUERY_UNIQUE) ) joint++; if( chead->spline != NULL ) { /* currently only put in if spline is unique */ if( ((chead->state & COMPARA_TARGET_UNIQUE) && (chead->spline->state & COMPARA_QUERY_UNIQUE)) || ((chead->state & COMPARA_QUERY_UNIQUE) && (chead->spline->state & COMPARA_TARGET_UNIQUE)) ) rev_joint++; } if( chead->state & COMPARA_TARGET_MULTIPLE ) t_multiple++; if( chead->state & COMPARA_QUERY_MULTIPLE ) q_multiple++; } fprintf(ofp,"Target %d unique positions, %d (rev: %d) shared (%.2f %%)\n",t_unique,joint,rev_joint,((joint+rev_joint)*100.0)/(t_unique*1.0)); fprintf(ofp,"Query %d unique positions, %d (rev: %d) shared (%.2f %%)\n",q_unique,joint,rev_joint,((joint+rev_joint)*100.0)/(q_unique*1.0)); } # line 387 "comparapath.dy" long int insert_revcom_Splines_in_set(ComparaIndex * ci,ComparaLinkStartSet * clss,FILE * logfp) { int i; long int out = 0; for(i=0;ilen;i++) { if( clss->cls[i]->start != NULL ) { out += insert_revcom_Splines(ci,clss->cls[i],logfp); } } return out; } # line 402 "comparapath.dy" long int insert_revcom_Splines(ComparaIndex * ci,ComparaLinkStart * cls,FILE * logfp) { long int total = 0; kmer_t rev; ComparaHead *chead; ComparaHead * revhead; ComparaHead * current; long int count = 0; for(current = cls->start ; current != NULL ; current = current->next_query) { chead = current; if( chead == NULL ) { continue; } if( count % 1000000 == 0 ) { fprintf(logfp,"Splines for %s, considered %ld positions\n",cls->seq->name,count); fflush(logfp); } count++; rev = reverse_complement_dna_number(current->number,ci->kii->kmer_size); revhead = (ComparaHead*) (*ci->kii->retrieve_by_kmer)(ci->kii->handle,rev); if( revhead == NULL ) { continue; } /* reverse_map_dna_number(current->number,ci->kii->kmer_size,forward); reverse_map_dna_number(rev,ci->kii->kmer_size,reverse); forward[ci->kii->kmer_size] = reverse[ci->kii->kmer_size] = '\0'; fprintf(stderr,"Inserting spline at %ld with %s vs %s\n",current->position,forward,reverse); */ chead->spline = revhead; revhead->spline = chead; total++; } return total; } # line 453 "comparapath.dy" ComparaLinkStartSet * add_Sequence_stream_ComparaIndex(ComparaIndex * ci,FILE * ifp,boolean is_target,int lognumber,int test_rev,FILE * logfp,char * tag) { Sequence * input; ComparaLinkStartSet * clss; ComparaLinkStart * cls; char buffer[512]; /** 101001010100101010010 1001101 */ int skip_query[] = {1,0,1,0,0,1,0}; int skip_target[] = {1,0,0,1,1,0,1}; clss = ComparaLinkStartSet_alloc_std(); while( (input = read_large_dna_Sequence(ifp,lognumber,logfp)) != NULL ) { if( tag != NULL ) { sprintf(buffer,"%s_%s",tag,input->name); free(input->name); input->name = stringalloc(buffer); } if( is_target ) { cls = add_Sequence_ComparaIndex(ci,input,is_target,lognumber,0,7,skip_target,test_rev,logfp); } else { cls = add_Sequence_ComparaIndex(ci,input,is_target,lognumber,0,7,skip_query,test_rev,logfp); } add_ComparaLinkStartSet(clss,cls); } return clss; } # line 490 "comparapath.dy" ComparaLinkStart * add_Sequence_ComparaIndex(ComparaIndex * ci,Sequence * seq,boolean is_target,int lognumber,long truncate,int skipsize,int * skipflag,int test_rev,FILE * logfp) { int i; ComparaLinkStart * cls; long int pos_start; kmer_t number; ComparaHead * prev = NULL; ComparaHead *chead; int j; int s; char base; kmer_t rev_number; ComparaHead * revhead; char * base_numbers; long int base_nos[100]; int k; kmer_t skipped = 0; kmer_t repeated = 0; kmer_t seen_repeats = 0; assert(ci != NULL); assert(seq != NULL); assert(ci != NULL); assert(ci->kii != NULL); s = 1; for(i=0;ikii->kmer_size;i++) { base_nos[i] = s; s = s*4; } cls= new_ComparaLinkStart(seq); cls->start = NULL; pos_start = add_Sequence_SinglePosSpace(ci->sps,seq->len,(void*)seq); fprintf(logfp,"Loading position starting at %ld\n",pos_start); base_numbers = map_to_basepair_numbers(seq->seq,seq->len); for(i=0;ilen - ci->kii->kmer_size;) { for(s=0;slen - ci->kii->kmer_size;s++,i++) { if( lognumber != 0 && i % lognumber == 0 ) { fprintf(logfp,"Loading position %d (%ld skipped, %ld repeated, %ld repeats) from %s\n",i,skipped,repeated,seen_repeats,seq->name); fflush(logfp); } if( skipsize > 1 ) { if( skipflag[s] == 0 ) { continue; } } if( truncate != 0 && i > truncate ) { break; } for(j=0;jkii->kmer_size;j++) { /* if( seq->seq[i+j] == 'N' || islower(seq->seq[i+j]) ) {*/ base = base_from_char(toupper(seq->seq[i+j])); if( base >= 4 ) { break; } } if( j < ci->kii->kmer_size ) { skipped++; continue; } /* number = forward_dna_number_from_string(seq->seq+i,ci->kii->kmer_size); */ number = 0; for(k=0;kkii->kmer_size;k++) { number = number + (base_numbers[i+k]*base_nos[k]); } if( number < 0 ) { fprintf(logfp,"Yikes. Got bad number %ld at position %d, %.*s\n",number,i,ci->kii->kmer_size,seq->seq+i); } assert(number>= 0); chead = (ComparaHead*) (*ci->kii->retrieve_by_kmer)(ci->kii->handle,number); if( chead == NULL && is_target == 1 && test_rev == 1 ) { /* have to test reverse strand, otherwise pointless to put in */ rev_number = reverse_complement_dna_number(number,ci->kii->kmer_size); revhead = (ComparaHead*) (*ci->kii->retrieve_by_kmer)(ci->kii->handle,rev_number); if( revhead == NULL ) { continue; } } if( chead != NULL ) { if( is_target == 0 ) { seen_repeats++; chead->state |= COMPARA_IS_REPEATED; chead->state = chead->state | COMPARA_QUERY_MULTIPLE; continue; } if( (chead->state & COMPARA_IS_REPEATED) ) { seen_repeats++; continue; } if( chead->size >= 2 ) { chead->state |= COMPARA_IS_REPEATED; repeated++; continue; } } if( chead == NULL ) { chead = new_ComparaHead(ci->blockalloc); if( chead == NULL ) { warn("Unable to make new ComparaHead for position %lld\n",i); assert(chead); } chead->number = number; (*ci->kii->insert_by_kmer)(ci->kii->handle,number,chead); if( is_target ) { chead->state = COMPARA_TARGET_UNIQUE; } else { chead->state = COMPARA_QUERY_UNIQUE; } } else { /* must change state... */ if( is_target ) { if( (chead->state & COMPARA_TARGET_UNIQUE) ) { chead->state = chead->state & (~COMPARA_TARGET_UNIQUE); chead->state = chead->state | COMPARA_TARGET_MULTIPLE; } else if( !(chead->state & COMPARA_TARGET_MULTIPLE) ) { chead->state = chead->state | COMPARA_TARGET_UNIQUE; } } else { if( (chead->state & COMPARA_QUERY_UNIQUE) ) { chead->state = chead->state & (~COMPARA_QUERY_UNIQUE); chead->state = chead->state | COMPARA_QUERY_MULTIPLE; } else if ( !(chead->state & COMPARA_QUERY_MULTIPLE) ) { chead->state = chead->state | COMPARA_QUERY_UNIQUE; } } } new_position_in_ComparaHead(chead,pos_start+i); if( cls->start == NULL ) { if( chead == NULL ) { warn("Very weird; NULL chead at start assignment"); } else { cls->start = chead; } } if( is_target == 0 && prev != NULL ) { prev->next_query = chead; chead->next_query = NULL; } prev = chead; } } free(base_numbers); return cls; } # line 667 "comparapath.dy" ComparaIndex * new_ComparaIndex(KmerIndexInterface * kii) { ComparaIndex * out; assert(kii); out = malloc(sizeof(ComparaIndex)); out->kii = kii; out->linkstart = calloc(COMPARAINDEX_LINK_START,sizeof(ComparaLinkStart*)); out->current_link = 0; out->link_len = COMPARAINDEX_LINK_START; out->sps = new_SinglePosSpace(1,50000); out->blockalloc = new_ComparaHeadBlockAllocator(COMPARAHEAD_BA_BLOCK_LENGTH,COMPARAHEAD_BA_UNIT_LENGTH); return out; } # line 685 "comparapath.dy" ComparaLinkStart * new_ComparaLinkStart(Sequence * seq) { ComparaLinkStart * out; out = malloc(sizeof(ComparaLinkStart)); out->start = NULL; out->seq = seq; return out; } # line 697 "comparapath.dy" void add_ComparaLinkStart_to_ComparaIndex(ComparaIndex * ci,ComparaLinkStart * cls) { assert(ci); assert(cls); if( ci->current_link >= ci->link_len ) { if( ci->link_len > COMPARAINDEX_LINK_LINEAR ) { ci->linkstart = realloc(ci->linkstart,sizeof(ComparaLinkStart*)*(ci->link_len + COMPARAINDEX_LINK_LINEAR)); ci->link_len = ci->link_len + COMPARAINDEX_LINK_LINEAR; } else { ci->linkstart = realloc(ci->linkstart,sizeof(ComparaLinkStart*)*(ci->link_len*2)); ci->link_len = ci->link_len*2; } } ci->linkstart[ci->current_link++] = cls; } # line 718 "comparapath.dy" ComparaHead * new_ComparaHead(ComparaHeadBlockAllocator * ba) { ComparaHead * out; out = new_ComparaHead_from_ComparaHeadBlockAllocator(ba); assert(out != NULL); out->size = 0; out->position[0] = -1; out->position[1] = -1; out->state = COMPARA_NOTHING; out->spline = NULL; return out; } # line 734 "comparapath.dy" void new_position_in_ComparaHead(ComparaHead * h,long int position) { assert(h != NULL); if( h->size == 2 ) { h->state |= COMPARA_IS_REPEATED; return; } h->position[(int)h->size] = position; h->size++; return; } # line 748 "comparapath.dy" ComparaHeadBlockAllocator * new_ComparaHeadBlockAllocator(int block_length,int unit_length) { ComparaHeadBlockAllocator * out; out = (ComparaHeadBlockAllocator*) malloc(sizeof(ComparaHeadBlockAllocator)); out->current_block = 0; out->current_unit = 0; out->unit_length = unit_length; out->block_length = block_length; out->block = calloc(block_length,sizeof(ComparaHead*)); out->block[0] = calloc(unit_length,sizeof(ComparaHead)); return out; } # line 765 "comparapath.dy" ComparaHead * new_ComparaHead_from_ComparaHeadBlockAllocator(ComparaHeadBlockAllocator * chba) { ComparaHead * ret; assert(chba != NULL); if( chba->current_unit >= chba->unit_length ) { if( chba->current_block >= chba->block_length ) { chba->block = realloc(chba->block,sizeof(ComparaHead*)*(2*chba->block_length)); chba->block_length *= 2; } chba->current_block++; chba->block[chba->current_block] = calloc(chba->unit_length,sizeof(ComparaHead)); chba->current_unit = 0; } ret = chba->block[chba->current_block]+(chba->current_unit); chba->current_unit++; return ret; } # line 724 "comparapath.c" /* Function: swap_ComparaLinkStartSet(list,i,j) * * Descrip: swap function: an internal for qsort_ComparaLinkStartSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ComparaLinkStart **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ComparaLinkStartSet(ComparaLinkStart ** list,int i,int j) { ComparaLinkStart * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ComparaLinkStartSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ComparaLinkStartSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ComparaLinkStart **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ComparaLinkStartSet(ComparaLinkStart ** list,int left,int right,int (*comp)(ComparaLinkStart * ,ComparaLinkStart * )) { int i,last; if( left >= right ) return; swap_ComparaLinkStartSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ComparaLinkStartSet (list,++last,i); } swap_ComparaLinkStartSet (list,left,last); qsort_ComparaLinkStartSet(list,left,last-1,comp); qsort_ComparaLinkStartSet(list,last+1,right,comp); } /* Function: sort_ComparaLinkStartSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ComparaLinkStartSet * * * Arg: obj [UNKN ] Object containing list [ComparaLinkStartSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ComparaLinkStartSet(ComparaLinkStartSet * obj,int (*comp)(ComparaLinkStart *, ComparaLinkStart *)) { qsort_ComparaLinkStartSet(obj->cls,0,obj->len-1,comp); return; } /* Function: expand_ComparaLinkStartSet(obj,len) * * Descrip: Really an internal function for add_ComparaLinkStartSet * * * Arg: obj [UNKN ] Object which contains the list [ComparaLinkStartSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ComparaLinkStartSet(ComparaLinkStartSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_ComparaLinkStartSet called with no need"); return TRUE; } if( (obj->cls = (ComparaLinkStart ** ) ckrealloc (obj->cls,sizeof(ComparaLinkStart *)*len)) == NULL) { warn("ckrealloc failed for expand_ComparaLinkStartSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_ComparaLinkStartSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ComparaLinkStartSet *] * Arg: add [OWNER] Object to add to the list [ComparaLinkStart *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ComparaLinkStartSet(ComparaLinkStartSet * obj,ComparaLinkStart * add) { if( obj->len >= obj->maxlen) { if( expand_ComparaLinkStartSet(obj,obj->len + ComparaLinkStartSetLISTLENGTH) == FALSE) return FALSE; } obj->cls[obj->len++]=add; return TRUE; } /* Function: flush_ComparaLinkStartSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ComparaLinkStartSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ComparaLinkStartSet(ComparaLinkStartSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->cls[i] != NULL) { free_ComparaLinkStart(obj->cls[i]); obj->cls[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: ComparaLinkStartSet_alloc_std(void) * * Descrip: Equivalent to ComparaLinkStartSet_alloc_len(ComparaLinkStartSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ComparaLinkStartSet *] * */ ComparaLinkStartSet * ComparaLinkStartSet_alloc_std(void) { return ComparaLinkStartSet_alloc_len(ComparaLinkStartSetLISTLENGTH); } /* Function: ComparaLinkStartSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ComparaLinkStartSet *] * */ ComparaLinkStartSet * ComparaLinkStartSet_alloc_len(int len) { ComparaLinkStartSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = ComparaLinkStartSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->cls = (ComparaLinkStart ** ) ckcalloc (len,sizeof(ComparaLinkStart *))) == NULL) { warn("Warning, ckcalloc failed in ComparaLinkStartSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_ComparaLinkStartSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ComparaLinkStartSet *] * * Return [UNKN ] Undocumented return value [ComparaLinkStartSet *] * */ ComparaLinkStartSet * hard_link_ComparaLinkStartSet(ComparaLinkStartSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a ComparaLinkStartSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ComparaLinkStartSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ComparaLinkStartSet *] * */ ComparaLinkStartSet * ComparaLinkStartSet_alloc(void) { ComparaLinkStartSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ComparaLinkStartSet *) ckalloc (sizeof(ComparaLinkStartSet))) == NULL) { warn("ComparaLinkStartSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->cls = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_ComparaLinkStartSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ComparaLinkStartSet *] * * Return [UNKN ] Undocumented return value [ComparaLinkStartSet *] * */ ComparaLinkStartSet * free_ComparaLinkStartSet(ComparaLinkStartSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ComparaLinkStartSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->cls != NULL) { for(i=0;ilen;i++) { if( obj->cls[i] != NULL) free_ComparaLinkStart(obj->cls[i]); } ckfree(obj->cls); } ckfree(obj); return NULL; } /* Function: swap_SetofHSPset(list,i,j) * * Descrip: swap function: an internal for qsort_SetofHSPset * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [HSPset **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SetofHSPset(HSPset ** list,int i,int j) { HSPset * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SetofHSPset(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SetofHSPset which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [HSPset **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SetofHSPset(HSPset ** list,int left,int right,int (*comp)(HSPset * ,HSPset * )) { int i,last; if( left >= right ) return; swap_SetofHSPset(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SetofHSPset (list,++last,i); } swap_SetofHSPset (list,left,last); qsort_SetofHSPset(list,left,last-1,comp); qsort_SetofHSPset(list,last+1,right,comp); } /* Function: sort_SetofHSPset(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SetofHSPset * * * Arg: obj [UNKN ] Object containing list [SetofHSPset *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SetofHSPset(SetofHSPset * obj,int (*comp)(HSPset *, HSPset *)) { qsort_SetofHSPset(obj->hspset,0,obj->len-1,comp); return; } /* Function: expand_SetofHSPset(obj,len) * * Descrip: Really an internal function for add_SetofHSPset * * * Arg: obj [UNKN ] Object which contains the list [SetofHSPset *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SetofHSPset(SetofHSPset * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SetofHSPset called with no need"); return TRUE; } if( (obj->hspset = (HSPset ** ) ckrealloc (obj->hspset,sizeof(HSPset *)*len)) == NULL) { warn("ckrealloc failed for expand_SetofHSPset, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SetofHSPset(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SetofHSPset *] * Arg: add [OWNER] Object to add to the list [HSPset *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SetofHSPset(SetofHSPset * obj,HSPset * add) { if( obj->len >= obj->maxlen) { if( expand_SetofHSPset(obj,obj->len + SetofHSPsetLISTLENGTH) == FALSE) return FALSE; } obj->hspset[obj->len++]=add; return TRUE; } /* Function: flush_SetofHSPset(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SetofHSPset *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SetofHSPset(SetofHSPset * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->hspset[i] != NULL) { free_HSPset(obj->hspset[i]); obj->hspset[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SetofHSPset_alloc_std(void) * * Descrip: Equivalent to SetofHSPset_alloc_len(SetofHSPsetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SetofHSPset *] * */ SetofHSPset * SetofHSPset_alloc_std(void) { return SetofHSPset_alloc_len(SetofHSPsetLISTLENGTH); } /* Function: SetofHSPset_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SetofHSPset *] * */ SetofHSPset * SetofHSPset_alloc_len(int len) { SetofHSPset * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SetofHSPset_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->hspset = (HSPset ** ) ckcalloc (len,sizeof(HSPset *))) == NULL) { warn("Warning, ckcalloc failed in SetofHSPset_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SetofHSPset(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SetofHSPset *] * * Return [UNKN ] Undocumented return value [SetofHSPset *] * */ SetofHSPset * hard_link_SetofHSPset(SetofHSPset * obj) { if( obj == NULL ) { warn("Trying to hard link to a SetofHSPset object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SetofHSPset_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SetofHSPset *] * */ SetofHSPset * SetofHSPset_alloc(void) { SetofHSPset * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SetofHSPset *) ckalloc (sizeof(SetofHSPset))) == NULL) { warn("SetofHSPset_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->hspset = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_SetofHSPset(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SetofHSPset *] * * Return [UNKN ] Undocumented return value [SetofHSPset *] * */ SetofHSPset * free_SetofHSPset(SetofHSPset * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SetofHSPset obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->hspset != NULL) { for(i=0;ilen;i++) { if( obj->hspset[i] != NULL) free_HSPset(obj->hspset[i]); } ckfree(obj->hspset); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/comparapath.h0000644000175000001440000003224210670453716017116 0ustar philippusers#ifndef DYNAMITEcomparapathHEADERFILE #define DYNAMITEcomparapathHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #include "largeseqreader.h" #include "singleseqspace.h" #include "dnamapping.h" #include "kmer_index_interface.h" #include "kmer_direct.h" #include "hsp.h" #define COMPARALINK_START 8 #define COMPARALINK_LINEAR 256 #define COMPARA_NOTHING 0 #define COMPARA_QUERY_UNIQUE 1 #define COMPARA_QUERY_MULTIPLE 2 #define COMPARA_TARGET_UNIQUE 4 #define COMPARA_TARGET_MULTIPLE 8 #define COMPARA_SPLINE_FLIPPED 16 #define COMPARA_IS_REPEATED 32 #define COMPARA_IS_JOINT_FORWARD(a) is_joint_forward(a) #define COMPARA_IS_JOINT_REVERSE(a) is_joint_reverse(a) #define COMPARA_IS_JOINT_FORWARD_MACRO(a) (((a->state&COMPARA_QUERY_UNIQUE) && (a->state&COMPARA_TARGET_UNIQUE) && a->spline != NULL) ? 1 : 0) #define COMPARA_IS_JOINT_REVERSE_MACRO(a) (((a->spline != NULL) && (((a->spline->state & COMPARA_QUERY_UNIQUE) && (a->state & COMPARA_TARGET_UNIQUE)) || ((a->spline->state & COMPARA_TARGET_UNIQUE) && (a->state & COMPARA_QUERY_UNIQUE)))) ? 1 : 0) typedef struct ComparaHead { struct ComparaHead * next_query; long int position[2]; struct ComparaHead * spline; long int number; char size; char state; } ComparaHead; typedef struct ComparaLinkStart { ComparaHead * start; Sequence * seq; } ComparaLinkStart; typedef struct ComparaHeadBlockAllocator { ComparaHead ** block; int current_block; int current_unit; int unit_length; int block_length; } ComparaHeadBlockAllocator; #define COMPARAHEAD_BA_BLOCK_LENGTH 10000 #define COMPARAHEAD_BA_UNIT_LENGTH 10000 typedef struct ComparaIndex { KmerIndexInterface * kii; ComparaLinkStart ** linkstart; int current_link; int link_len; SinglePosSpace * sps; ComparaHeadBlockAllocator * blockalloc; } ComparaIndex; #define COMPARAINDEX_LINK_START 16 #define COMPARAINDEX_LINK_LINEAR 256 #define ComparaLinkStartSetLISTLENGTH 256 #define SetofHSPsetLISTLENGTH 256 struct Wise2_ComparaLinkStartSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ComparaLinkStart ** cls; int len;/* len for above cls */ int maxlen; /* maxlen for above cls */ } ; /* ComparaLinkStartSet defined */ #ifndef DYNAMITE_DEFINED_ComparaLinkStartSet typedef struct Wise2_ComparaLinkStartSet Wise2_ComparaLinkStartSet; #define ComparaLinkStartSet Wise2_ComparaLinkStartSet #define DYNAMITE_DEFINED_ComparaLinkStartSet #endif struct Wise2_SetofHSPset { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif HSPset ** hspset; int len;/* len for above hspset */ int maxlen; /* maxlen for above hspset */ } ; /* SetofHSPset defined */ #ifndef DYNAMITE_DEFINED_SetofHSPset typedef struct Wise2_SetofHSPset Wise2_SetofHSPset; #define SetofHSPset Wise2_SetofHSPset #define DYNAMITE_DEFINED_SetofHSPset #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: add_ComparaLinkStartSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ComparaLinkStartSet *] * Arg: add [OWNER] Object to add to the list [ComparaLinkStart *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_ComparaLinkStartSet(ComparaLinkStartSet * obj,ComparaLinkStart * add); #define add_ComparaLinkStartSet Wise2_add_ComparaLinkStartSet /* Function: flush_ComparaLinkStartSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ComparaLinkStartSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_ComparaLinkStartSet(ComparaLinkStartSet * obj); #define flush_ComparaLinkStartSet Wise2_flush_ComparaLinkStartSet /* Function: ComparaLinkStartSet_alloc_std(void) * * Descrip: Equivalent to ComparaLinkStartSet_alloc_len(ComparaLinkStartSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ComparaLinkStartSet *] * */ ComparaLinkStartSet * Wise2_ComparaLinkStartSet_alloc_std(void); #define ComparaLinkStartSet_alloc_std Wise2_ComparaLinkStartSet_alloc_std /* Function: ComparaLinkStartSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ComparaLinkStartSet *] * */ ComparaLinkStartSet * Wise2_ComparaLinkStartSet_alloc_len(int len); #define ComparaLinkStartSet_alloc_len Wise2_ComparaLinkStartSet_alloc_len /* Function: hard_link_ComparaLinkStartSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ComparaLinkStartSet *] * * Return [UNKN ] Undocumented return value [ComparaLinkStartSet *] * */ ComparaLinkStartSet * Wise2_hard_link_ComparaLinkStartSet(ComparaLinkStartSet * obj); #define hard_link_ComparaLinkStartSet Wise2_hard_link_ComparaLinkStartSet /* Function: ComparaLinkStartSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ComparaLinkStartSet *] * */ ComparaLinkStartSet * Wise2_ComparaLinkStartSet_alloc(void); #define ComparaLinkStartSet_alloc Wise2_ComparaLinkStartSet_alloc /* Function: free_ComparaLinkStartSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ComparaLinkStartSet *] * * Return [UNKN ] Undocumented return value [ComparaLinkStartSet *] * */ ComparaLinkStartSet * Wise2_free_ComparaLinkStartSet(ComparaLinkStartSet * obj); #define free_ComparaLinkStartSet Wise2_free_ComparaLinkStartSet /* Function: add_SetofHSPset(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SetofHSPset *] * Arg: add [OWNER] Object to add to the list [HSPset *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SetofHSPset(SetofHSPset * obj,HSPset * add); #define add_SetofHSPset Wise2_add_SetofHSPset /* Function: flush_SetofHSPset(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SetofHSPset *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SetofHSPset(SetofHSPset * obj); #define flush_SetofHSPset Wise2_flush_SetofHSPset /* Function: SetofHSPset_alloc_std(void) * * Descrip: Equivalent to SetofHSPset_alloc_len(SetofHSPsetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SetofHSPset *] * */ SetofHSPset * Wise2_SetofHSPset_alloc_std(void); #define SetofHSPset_alloc_std Wise2_SetofHSPset_alloc_std /* Function: SetofHSPset_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SetofHSPset *] * */ SetofHSPset * Wise2_SetofHSPset_alloc_len(int len); #define SetofHSPset_alloc_len Wise2_SetofHSPset_alloc_len /* Function: hard_link_SetofHSPset(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SetofHSPset *] * * Return [UNKN ] Undocumented return value [SetofHSPset *] * */ SetofHSPset * Wise2_hard_link_SetofHSPset(SetofHSPset * obj); #define hard_link_SetofHSPset Wise2_hard_link_SetofHSPset /* Function: SetofHSPset_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SetofHSPset *] * */ SetofHSPset * Wise2_SetofHSPset_alloc(void); #define SetofHSPset_alloc Wise2_SetofHSPset_alloc /* Function: free_SetofHSPset(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SetofHSPset *] * * Return [UNKN ] Undocumented return value [SetofHSPset *] * */ SetofHSPset * Wise2_free_SetofHSPset(SetofHSPset * obj); #define free_SetofHSPset Wise2_free_SetofHSPset /* Unplaced functions */ /* There has been no indication of the use of these functions */ ComparaLinkStart * Wise2_free_ComparaLinkStart(ComparaLinkStart * cls); #define free_ComparaLinkStart Wise2_free_ComparaLinkStart void Wise2_show_SetofHSPset(SetofHSPset * set,FILE * ofp); #define show_SetofHSPset Wise2_show_SetofHSPset SetofHSPset * Wise2_SetofHSPset_from_ComparaIndex(ComparaIndex * ci,ComparaLinkStartSet * clss,FILE * logfp); #define SetofHSPset_from_ComparaIndex Wise2_SetofHSPset_from_ComparaIndex HSPset * Wise2_HSPset_from_ComparaIndex(ComparaIndex * ci,ComparaLinkStart * cls,FILE * logfp); #define HSPset_from_ComparaIndex Wise2_HSPset_from_ComparaIndex boolean Wise2_is_joint_forward(ComparaHead * h); #define is_joint_forward Wise2_is_joint_forward boolean Wise2_is_joint_reverse(ComparaHead * h); #define is_joint_reverse Wise2_is_joint_reverse void Wise2_show_distrib_ComparaIndex(ComparaIndex * ci,ComparaLinkStart * cls,FILE * ofp); #define show_distrib_ComparaIndex Wise2_show_distrib_ComparaIndex void Wise2_show_stats_ComparaIndex(ComparaIndex * ci,ComparaLinkStart * cls,FILE * ofp); #define show_stats_ComparaIndex Wise2_show_stats_ComparaIndex long int Wise2_insert_revcom_Splines_in_set(ComparaIndex * ci,ComparaLinkStartSet * clss,FILE * logfp); #define insert_revcom_Splines_in_set Wise2_insert_revcom_Splines_in_set long int Wise2_insert_revcom_Splines(ComparaIndex * ci,ComparaLinkStart * cls,FILE * logfp); #define insert_revcom_Splines Wise2_insert_revcom_Splines ComparaLinkStartSet * Wise2_add_Sequence_stream_ComparaIndex(ComparaIndex * ci,FILE * ifp,boolean is_target,int lognumber,int test_rev,FILE * logfp,char * tag); #define add_Sequence_stream_ComparaIndex Wise2_add_Sequence_stream_ComparaIndex ComparaLinkStart * Wise2_add_Sequence_ComparaIndex(ComparaIndex * ci,Sequence * seq,boolean is_target,int lognumber,long truncate,int skipsize,int * skipflag,int test_rev,FILE * logfp); #define add_Sequence_ComparaIndex Wise2_add_Sequence_ComparaIndex ComparaIndex * Wise2_new_ComparaIndex(KmerIndexInterface * kii); #define new_ComparaIndex Wise2_new_ComparaIndex ComparaLinkStart * Wise2_new_ComparaLinkStart(Sequence * seq); #define new_ComparaLinkStart Wise2_new_ComparaLinkStart void Wise2_add_ComparaLinkStart_to_ComparaIndex(ComparaIndex * ci,ComparaLinkStart * cls); #define add_ComparaLinkStart_to_ComparaIndex Wise2_add_ComparaLinkStart_to_ComparaIndex ComparaHead * Wise2_new_ComparaHead(ComparaHeadBlockAllocator * ba); #define new_ComparaHead Wise2_new_ComparaHead void Wise2_new_position_in_ComparaHead(ComparaHead * h,long int position); #define new_position_in_ComparaHead Wise2_new_position_in_ComparaHead ComparaHeadBlockAllocator * Wise2_new_ComparaHeadBlockAllocator(int block_length,int unit_length); #define new_ComparaHeadBlockAllocator Wise2_new_ComparaHeadBlockAllocator ComparaHead * Wise2_new_ComparaHead_from_ComparaHeadBlockAllocator(ComparaHeadBlockAllocator * chba); #define new_ComparaHead_from_ComparaHeadBlockAllocator Wise2_new_ComparaHead_from_ComparaHeadBlockAllocator /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_ComparaLinkStartSet(ComparaLinkStart ** list,int i,int j) ; #define swap_ComparaLinkStartSet Wise2_swap_ComparaLinkStartSet void Wise2_qsort_ComparaLinkStartSet(ComparaLinkStart ** list,int left,int right,int (*comp)(ComparaLinkStart * ,ComparaLinkStart * )); #define qsort_ComparaLinkStartSet Wise2_qsort_ComparaLinkStartSet void Wise2_sort_ComparaLinkStartSet(ComparaLinkStartSet * obj,int (*comp)(ComparaLinkStart *, ComparaLinkStart *)); #define sort_ComparaLinkStartSet Wise2_sort_ComparaLinkStartSet boolean Wise2_expand_ComparaLinkStartSet(ComparaLinkStartSet * obj,int len); #define expand_ComparaLinkStartSet Wise2_expand_ComparaLinkStartSet void Wise2_swap_SetofHSPset(HSPset ** list,int i,int j) ; #define swap_SetofHSPset Wise2_swap_SetofHSPset void Wise2_qsort_SetofHSPset(HSPset ** list,int left,int right,int (*comp)(HSPset * ,HSPset * )); #define qsort_SetofHSPset Wise2_qsort_SetofHSPset void Wise2_sort_SetofHSPset(SetofHSPset * obj,int (*comp)(HSPset *, HSPset *)); #define sort_SetofHSPset Wise2_sort_SetofHSPset boolean Wise2_expand_SetofHSPset(SetofHSPset * obj,int len); #define expand_SetofHSPset Wise2_expand_SetofHSPset #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/kmer_assembly.c0000644000175000001440000002714110670453716017451 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "kmer_assembly.h" # line 56 "kmer_assembly.dy" void show_extensive_stats_KmerAssemblyIndex(KmerAssemblyIndex * kai,FILE * ofp) { int i; int j; int forward_splits [50]; int backward_splits [50]; kmer_t depth [50]; int link_2_lengths [50]; kmer_t total_numbers = 0; kmer_t total_links = 0; kmer_t kmer = -1; KmerAssemblyNode * node; KmerAssemblyLink * run; fprintf(stderr,"Intialising arrays...\n"); for(i=0;i<50;i++) { forward_splits[i] = backward_splits[i] = depth[i] = link_2_lengths[i] = 0; } kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { total_numbers++; node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); for(;node != NULL;node= node->node_chain ) { total_links += node->next_len; for(i=0;inext_len;i++) { if( node->next[i]->sequence_label_len > 45 ) { depth[45]++; } else { depth[node->next[i]->sequence_label_len]++; } } if( node->next_len > 1 ) { forward_splits[node->next_len]++; } if( node->prev_len > 1 ) { backward_splits[node->prev_len]++; } if( node->prev_len > 1 ) { if( node->next_len > 1 ) { link_2_lengths[0]++; } else { if( node->next_len == 1 ) { run = node->next[0]; for(j=1;run != NULL && j < 45 ;run = run->next->next[0],j++) { if( run->next->next_len > 1 ) { break; } if( run->next->next_len == 0 ) { break; } } link_2_lengths[j]++; } } } } } fprintf(ofp,"Coverage stats\n"); fprintf(ofp,"Depth %% of links at this depth\n"); for(i=0;i< 50;i++){ fprintf(ofp,"%3d %.2f%%\n",i,(100.0)*((double)depth[i]/(double)(total_links))); } fprintf(ofp,"\nSplits Forward Backward\n"); for(i=1; i < 50 ;i++) { fprintf(ofp,"%2d %4d %4d\n",i,forward_splits[i],backward_splits[i]); } fprintf(ofp,"\nDistribution of stream merge length\n"); fprintf(ofp,"Length Number\n"); for(i=0;i<50;i++) { fprintf(ofp,"%3d %4d\n",i,link_2_lengths[i]); } } # line 145 "kmer_assembly.dy" void add_AssemblySequence_KmerAssemblyIndex(KmerAssemblyIndex * kai,AssemblySequence * aseq,int report) { kmer_t prev_number; kmer_t next_number; long int i; int j; char c; long start; char * seq_str; assert(kai != NULL); assert(aseq != NULL); assert(aseq->seq != NULL); start = add_Sequence_SinglePosSpace(kai->sps,aseq->seq->len,(void*)aseq); for(i=0;iseq->len-kai->kii->kmer_size;i++) { if( report != 0 && i % report == 0 && i != 0) { fprintf(stderr,"Loaded %ld positions in %s\n",i,aseq->seq->name); } for(j=0;jkii->kmer_size+1;j++) { c = toupper(aseq->seq->seq[i+j]); if( c != 'A' && c != 'T' && c != 'G' && c != 'C' ) { break; } } if( j < kai->kii->kmer_size+1 ) { continue; } seq_str = aseq->seq->seq; next_number = forward_dna_number_from_string(seq_str+i+1, kai->kii->kmer_size); prev_number = forward_dna_number_from_string(seq_str+i, kai->kii->kmer_size); /* fprintf(stderr,"Adding position %d %.*s...%ld,%ld\n",i,kai->kii->kmer_size+1,aseq->seq->seq+i,next_number,prev_number); */ store_KmerAssemblyLink_KmerAssemblyIndex(kai,prev_number,next_number,aseq->seq->seq[i+1],start+i+1); } return; } # line 191 "kmer_assembly.dy" boolean store_KmerAssemblyLink_KmerAssemblyIndex(KmerAssemblyIndex * kai,kmer_t prev_number,kmer_t next_number,char base,long label) { int i; KmerAssemblyLink * link; KmerAssemblyNode * prev; KmerAssemblyNode * next; assert(kai != NULL); prev = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,prev_number); if( prev != NULL ) { for(i=0;inext_len;i++) { if( prev->next[i]->next->number == next_number ) { add_sequence_label_KmerAssemblyLink(prev->next[i],label); return TRUE; } } } /* nope - need new link */ next = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,next_number); if( prev == NULL ) { prev = new_KmerAssemblyNode(prev_number); assert(prev->number == prev_number); (*kai->kii->insert_by_kmer)(kai->kii->handle,prev_number,prev); } else { assert(prev->number >= 0); } if( next == NULL ) { next = new_KmerAssemblyNode(next_number); assert(next->number == next_number); (*kai->kii->insert_by_kmer)(kai->kii->handle,next_number,next); } else { assert(next->number >= 0); } assert(prev != NULL); assert(prev->number >= 0); assert(prev->prev != NULL); assert(prev->next != NULL); assert(next != NULL); assert(next->number >= 0); assert(next->prev != NULL); assert(next->next != NULL); link = new_KmerAssemblyLink(base); add_sequence_label_KmerAssemblyLink(link,label); link->prev = prev; link->next = next; /* fprintf(stderr,"Adding position to %ld : %ld with %d,%d\n",prev->number,next->number,prev->prev_len,next->next_len);*/ add_next_KmerAssemblyNode(prev,link); add_prev_KmerAssemblyNode(next,link); return TRUE; } # line 262 "kmer_assembly.dy" void show_KmerAssemblyIndex(KmerAssemblyIndex * kai,FILE * ofp) { kmer_t kmer; KmerAssemblyNode * node; assert(kai != NULL); assert(kai->kii != NULL); assert(kai->kii->next_filled_kmer != NULL); kmer = -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); show_KmerAssemblyNode(node,kai->kii->kmer_size,0,ofp); } } # line 280 "kmer_assembly.dy" void show_KmerAssemblyNode(KmerAssemblyNode * node,int kmer_size,int level,FILE * ofp) { int i; int k; char buffer[512]; assert(node != NULL); assert(ofp != NULL); reverse_map_dna_number(node->number,kmer_size,buffer); buffer[kmer_size] = '\0'; for(k=0;knumber,buffer); for(i=0;iprev_len;i++) { for(k=0;kprev[i]->base,node->prev[i]->sequence_label_len,node->prev[i]->prev->number); } for(i=0;inext_len;i++) { for(k=0;knext[i]->base,node->next[i]->sequence_label_len,node->next[i]->next->number); } if( node->node_chain != NULL) { fprintf(ofp,"Has chained node...\n"); show_KmerAssemblyNode(node->node_chain,kmer_size,level+1,ofp); } } # line 320 "kmer_assembly.dy" KmerAssemblyIndex * new_KmerAssemblyIndex(KmerIndexInterface * kii,SinglePosSpace * sps) { KmerAssemblyIndex * out; assert(kii != NULL); assert(sps != NULL); out = (KmerAssemblyIndex*) malloc(sizeof(KmerAssemblyIndex)); out->kii = kii; out->sps = sps; return out; } # line 335 "kmer_assembly.dy" KmerAssemblyLink * new_KmerAssemblyLink(char base) { KmerAssemblyLink * out; out = (KmerAssemblyLink*) malloc (sizeof(KmerAssemblyLink)); out->sequence_label = (long*) calloc(KmerAssemblyLink_LABEL_START,sizeof(long)); out->sequence_label_maxlen = KmerAssemblyLink_LABEL_START; out->sequence_label_len = 0; out->base = base; out->prev = NULL; out->next = NULL; out->state = 0; return out; } # line 353 "kmer_assembly.dy" void remove_sequence_label_KmerAssemblyLink(KmerAssemblyLink * kal,long label) { int i; assert(kal != NULL); for(i=0;isequence_label_len;i++) { if( kal->sequence_label[i] == label ) { kal->sequence_label[i] = kal->sequence_label[--kal->sequence_label_len]; return; } } fprintf(stderr," ...unable to remove label %ld from link %ld (%d labels)\n",label,kal,kal->sequence_label_len); for(i=0;isequence_label_len;i++) { fprintf(stderr," [%ld] is %d label\n",kal->sequence_label[i]); } return; } # line 373 "kmer_assembly.dy" void add_sequence_label_KmerAssemblyLink(KmerAssemblyLink * kal,long label) { assert(kal != NULL); if( kal->sequence_label_len >= kal->sequence_label_maxlen ) { if( kal->sequence_label_maxlen > KmerAssemblyLink_LABEL_LINEAR ) { kal->sequence_label_maxlen += KmerAssemblyLink_LABEL_LINEAR; } else { kal->sequence_label_maxlen *= 2; } kal->sequence_label = (long *) realloc (kal->sequence_label,sizeof(long)*kal->sequence_label_maxlen); } kal->sequence_label[kal->sequence_label_len++] = label; } # line 392 "kmer_assembly.dy" void detach_KmerAssemblyLink(KmerAssemblyIndex * kai,KmerAssemblyLink * link) { assert(kai != NULL); assert(link != NULL); if( link->prev != NULL ) { remove_next_KmerAssemblyNode(link->prev,link); } if( link->next != NULL ) { remove_prev_KmerAssemblyNode(link->next,link); } } # line 408 "kmer_assembly.dy" void remove_next_KmerAssemblyNode(KmerAssemblyNode * node,KmerAssemblyLink * next) { int i; assert(node != NULL); assert(next != NULL); for(i=0;inext_len;i++) { if( node->next[i] == next ) { node->next[i] = node->next[--node->next_len]; return; } } warn("In node %d, unable to remove %d as a next node, graph collapsing....",node,next); return; } # line 425 "kmer_assembly.dy" void add_next_KmerAssemblyNode(KmerAssemblyNode * kan,KmerAssemblyLink * kal) { assert(kan != NULL); assert(kal != NULL); assert(kan->next != NULL); if( kan->next_len >= kan->next_maxlen ) { if( kan->next_maxlen > KmerAssemblyNode_LINK_LINEAR ){ kan->next = (KmerAssemblyLink **) realloc (kan->next,sizeof(KmerAssemblyLink*) * (kan->next_maxlen + KmerAssemblyNode_LINK_LINEAR)); kan->next_maxlen = kan->next_maxlen + KmerAssemblyNode_LINK_LINEAR; } else { kan->next = (KmerAssemblyLink **) realloc (kan->next,sizeof(KmerAssemblyLink*) * (kan->next_maxlen * 2)); kan->next_maxlen = kan->next_maxlen * 2; } } kan->next[kan->next_len++] = kal; } # line 445 "kmer_assembly.dy" void remove_prev_KmerAssemblyNode(KmerAssemblyNode * node,KmerAssemblyLink * prev) { int i; assert(node != NULL); assert(prev != NULL); for(i=0;iprev_len;i++) { if( node->prev[i] == prev ) { node->prev[i] = node->prev[--node->prev_len]; return; } } warn("In node %d, unable to remove %d as a prev node",node,prev); return; } # line 464 "kmer_assembly.dy" void add_prev_KmerAssemblyNode(KmerAssemblyNode * kan,KmerAssemblyLink * kal) { assert(kan != NULL); assert(kal != NULL); assert(kan->prev != NULL); if( kan->prev_len >= kan->prev_maxlen ) { if( kan->prev_maxlen > KmerAssemblyNode_LINK_LINEAR ){ kan->prev = (KmerAssemblyLink **) realloc (kan->prev,sizeof(KmerAssemblyLink*) * (kan->prev_maxlen + KmerAssemblyNode_LINK_LINEAR)); kan->prev_maxlen = kan->prev_maxlen + KmerAssemblyNode_LINK_LINEAR; } else { kan->prev = (KmerAssemblyLink **) realloc (kan->prev,sizeof(KmerAssemblyLink*) * (kan->prev_maxlen * 2)); kan->prev_maxlen = kan->prev_maxlen * 2; } } kan->prev[kan->prev_len++] = kal; } # line 484 "kmer_assembly.dy" KmerAssemblyNode * new_KmerAssemblyNode(kmer_t number) { KmerAssemblyNode * out; out = (KmerAssemblyNode*) malloc( sizeof(KmerAssemblyNode)); assert(out != NULL); out->number = number; out->prev = (KmerAssemblyLink **) calloc (KmerAssemblyNode_LINK_START,sizeof(KmerAssemblyLink)); out->next = (KmerAssemblyLink **) calloc (KmerAssemblyNode_LINK_START,sizeof(KmerAssemblyLink)); out->prev_maxlen = out->next_maxlen = KmerAssemblyNode_LINK_START; out->prev_len = out->next_len = 0; out->node_chain = NULL; return out; } # line 471 "kmer_assembly.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/kmer_assembly.h0000644000175000001440000000771210670453716017460 0ustar philippusers#ifndef DYNAMITEkmer_assemblyHEADERFILE #define DYNAMITEkmer_assemblyHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "kmer_index_interface.h" #include "singleseqspace.h" #include "assembly.h" #define KMER_ASSEMBLY_NEXT_TANGLED 2 #define KMER_ASSEMBLY_PREV_TANGLED 4 typedef struct KmerAssemblyLink { struct KmerAssemblyNode * prev; struct KmerAssemblyNode * next; char base; long * sequence_label; int sequence_label_len; int sequence_label_maxlen; char state; } KmerAssemblyLink; typedef struct KmerAssemblyNode { kmer_t number; struct KmerAssemblyLink ** prev; int prev_len; int prev_maxlen; struct KmerAssemblyLink ** next; int next_len; int next_maxlen; struct KmerAssemblyNode * node_chain; } KmerAssemblyNode; typedef struct KmerAssemblyIndex { KmerIndexInterface * kii; SinglePosSpace * sps; } KmerAssemblyIndex; #define KmerAssemblyNode_LINK_START 8 #define KmerAssemblyNode_LINK_LINEAR 64 #define KmerAssemblyLink_LABEL_START 2 #define KmerAssemblyLink_LABEL_LINEAR 8 /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_show_extensive_stats_KmerAssemblyIndex(KmerAssemblyIndex * kai,FILE * ofp); #define show_extensive_stats_KmerAssemblyIndex Wise2_show_extensive_stats_KmerAssemblyIndex void Wise2_add_AssemblySequence_KmerAssemblyIndex(KmerAssemblyIndex * kai,AssemblySequence * aseq,int report); #define add_AssemblySequence_KmerAssemblyIndex Wise2_add_AssemblySequence_KmerAssemblyIndex boolean Wise2_store_KmerAssemblyLink_KmerAssemblyIndex(KmerAssemblyIndex * kai,kmer_t prev_number,kmer_t next_number,char base,long label); #define store_KmerAssemblyLink_KmerAssemblyIndex Wise2_store_KmerAssemblyLink_KmerAssemblyIndex void Wise2_show_KmerAssemblyIndex(KmerAssemblyIndex * kai,FILE * ofp); #define show_KmerAssemblyIndex Wise2_show_KmerAssemblyIndex void Wise2_show_KmerAssemblyNode(KmerAssemblyNode * node,int kmer_size,int level,FILE * ofp); #define show_KmerAssemblyNode Wise2_show_KmerAssemblyNode KmerAssemblyIndex * Wise2_new_KmerAssemblyIndex(KmerIndexInterface * kii,SinglePosSpace * sps); #define new_KmerAssemblyIndex Wise2_new_KmerAssemblyIndex KmerAssemblyLink * Wise2_new_KmerAssemblyLink(char base); #define new_KmerAssemblyLink Wise2_new_KmerAssemblyLink void Wise2_remove_sequence_label_KmerAssemblyLink(KmerAssemblyLink * kal,long label); #define remove_sequence_label_KmerAssemblyLink Wise2_remove_sequence_label_KmerAssemblyLink void Wise2_add_sequence_label_KmerAssemblyLink(KmerAssemblyLink * kal,long label); #define add_sequence_label_KmerAssemblyLink Wise2_add_sequence_label_KmerAssemblyLink void Wise2_detach_KmerAssemblyLink(KmerAssemblyIndex * kai,KmerAssemblyLink * link); #define detach_KmerAssemblyLink Wise2_detach_KmerAssemblyLink void Wise2_remove_next_KmerAssemblyNode(KmerAssemblyNode * node,KmerAssemblyLink * next); #define remove_next_KmerAssemblyNode Wise2_remove_next_KmerAssemblyNode void Wise2_add_next_KmerAssemblyNode(KmerAssemblyNode * kan,KmerAssemblyLink * kal); #define add_next_KmerAssemblyNode Wise2_add_next_KmerAssemblyNode void Wise2_remove_prev_KmerAssemblyNode(KmerAssemblyNode * node,KmerAssemblyLink * prev); #define remove_prev_KmerAssemblyNode Wise2_remove_prev_KmerAssemblyNode void Wise2_add_prev_KmerAssemblyNode(KmerAssemblyNode * kan,KmerAssemblyLink * kal); #define add_prev_KmerAssemblyNode Wise2_add_prev_KmerAssemblyNode KmerAssemblyNode * Wise2_new_KmerAssemblyNode(kmer_t number); #define new_KmerAssemblyNode Wise2_new_KmerAssemblyNode /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/linkindex.dy0000644000175000001440000003351707637404143016776 0ustar philippusers %{ #include "dnanumber.h" #define LinkNumberLISTLENGTH 32 #define LinkStreamLISTLENGTH 32 #define LinkNumberArrayLISTLENGTH 1024 %} friend LinkNumber friend LinkStream friend LinkEdge struct LinkEdge LinkStream * x !link LinkStream * y !link char twist struct LinkStream LinkEdge * a !link LinkEdge * b !link int number char depth char starting_flip char have_seen struct LinkNumber LinkStream ** stream !list int number struct LinkNumberArray LinkNumber ** array int array_len int nmer_size LinkEdge ** edge_set !list struct LinkNumberArrayDebug char placement_stream char add_stream char extraction FILE * ofp !link %{ #include "linkindex.h" %func Reverse builds a DNA sequence stream from LinkStream %% Sequence * extract_dna_LinkStream(LinkStream * ln,LinkNumberArrayDebug * lnad,int nmer_size) { LinkStream * runner; LinkStream * prev; LinkStream * next; int i = 0; Sequence * out; int flipped = 0; assert(ln); i++; if( lnad->extraction != 0 ) { fprintf(lnad->ofp,"Extracting DNA from linkstream %d\n",ln); } ln->have_seen = 1; if( ln->a == NULL ) { if( ln->b->x == ln ) { runner = ln->b->y; } else { runner = ln->b->x; } } else { if( ln->a->x == ln ) { runner = ln->a->y; } else { runner = ln->a->x; } } prev = ln; while( runner != NULL ) { /* to find the outgoing link from here, test neither a nor b is not NULL and figure out the right way to go from the fact that the link is back to ourselves */ if( runner->a == NULL || runner->b == NULL ) { /* other end of stream */ break; } runner->have_seen = 1; i++; if( lnad->extraction > 2 ) { fprintf(lnad->ofp,"Extracting DNA from linkstream %d, runner %d, position count %d\n",ln,runner,i); } if( runner->a->x == runner && runner->a->y != prev) { next = runner->a->y; } else if ( runner->a->y == runner && runner->a->x != prev ) { next = runner->a->x; } else if( runner->b->x == runner && runner->b->y != prev) { next = runner->b->y; } else if ( runner->b->y == runner && runner->b->x != prev ) { next = runner->b->x; } else { fatal("Unable to move off edge!"); } prev = runner; runner = next; } out = Sequence_alloc(); out->seq = calloc(i+1,sizeof(char)); i = 0; flipped = ln->starting_flip; if( ln->a == NULL ) { out->seq[0] = first_char_from_dnanumber(ln->number,nmer_size,flipped); } else { /* b is NULL, indicating a 3' end of a sequence, so flip the flip*/ out->seq[0] = first_char_from_dnanumber(ln->number,nmer_size,!flipped); } if( ln->a == NULL ) { if( ln->b->x == ln ) { runner = ln->b->y; } else { runner = ln->b->x; } if( ln->b->twist == 1 ) { flipped = !flipped; } } else { if( ln->a->x == ln ) { runner = ln->a->y; } else { runner = ln->a->x; } /* as b is always on the reverse strand, invert the flipped sense as we read down it*/ if( ln->a->twist == 0 ) { flipped = !flipped; } } prev = ln; i++; while( runner != NULL ) { /* to find the outgoing link from here, test neither a nor b is not NULL and figure out the right way to go from the fact that the link is back to ourselves */ if( runner->a == NULL || runner->b == NULL ) { /* other end of stream */ break; } out->seq[i] = first_char_from_dnanumber(runner->number,nmer_size,flipped); i++; if( runner->a->x == runner && runner->a->y != prev) { next = runner->a->y; if( runner->a->twist == 1 ) { flipped = !flipped; } } else if ( runner->a->y == runner && runner->a->x != prev ) { next = runner->a->x; if( runner->a->twist == 1 ) { flipped = !flipped; } } else if( runner->b->x == runner && runner->b->y != prev) { next = runner->b->y; if( runner->b->twist == 1 ) { flipped = !flipped; } } else if ( runner->b->y == runner && runner->b->x != prev ) { next = runner->b->x; if( runner->b->twist == 1 ) { flipped = !flipped; } } else { fatal("Unable to move off edge!"); } prev = runner; runner = next; } runner->have_seen = 1; return out; } %func Writes in read to existing streams %% boolean write_existing_LinkStream(LinkNumberArray * lna,LinkNumberArrayDebug * lnad,DnaNumberSequence * dns) { int i; int j; LinkStream * stream; LinkStream * prev = NULL; LinkEdge * edge = NULL; int is_new = 0; int is_old = 0; if( lnad->add_stream != 0 ) { fprintf(lnad->ofp,"Adding %s as an existing stream\n",dns->orig->name); } fprintf(stderr,"Adding... on existing...\n"); for(i=0;ilen;i++) { if( lna->array[dns->seq[i].number] == NULL ) { lna->array[dns->seq[i].number] = LinkNumber_alloc_std(); /* now add */ stream = LinkStream_alloc(); stream->number = dns->seq[i].number; stream->depth = 1; stream->have_seen = 0; stream->starting_flip = dns->seq[i].flipped; add_LinkNumber( lna->array[dns->seq[i].number],stream ); if( lnad->add_stream > 2 ) { fprintf(lnad->ofp,"Adding new position %s, on %d [%d,%c]\n",dns->orig->name,dns->seq[i].number,i,dns->orig->seq[i]); } is_new = 1; if( prev != NULL ) { edge = new_LinkEdge(lna); edge->x = prev; edge->y = stream; if( dns->seq[i].flipped == dns->seq[i-1].flipped ) { edge->twist = 0; } else { edge->twist = 1; } if( is_old != 1 ) { /* set up arbitary situation */ prev->b = edge; stream->a = edge; stream->b = NULL; /* terminating */ } else { if( prev->a == NULL ) { prev->a = edge; } else { prev->b = edge; } stream->a = edge; stream->b = NULL; /* terminating */ is_old = 0; } } else { /* first position, assign a to NULL */ stream->a = NULL; stream->b = NULL; } fprintf(stderr,"Leaving with position %d with %d on a and %d on b\n",dns->seq[i].number, lna->array[dns->seq[i].number]->stream[0]->a, lna->array[dns->seq[i].number]->stream[0]->b); prev = stream; continue; } else { /* as this number has a stream, and we are adding, one of the streams have to be right*/ /* if this is first, then we know this must be unambiguous */ if( i == 0 ) { if( lna->array[dns->seq[0].number]->len > 1 ) { fatal("Cannot deal with ambiguous first arrays"); } lna->array[dns->seq[0].number]->stream[0]->depth++; prev = lna->array[dns->seq[0].number]->stream[0]; continue; } /* otherwise, one of these streams should make sense, if not die! */ for(j=0;jarray[dns->seq[i].number]->len;j++) { auto LinkStream * stream = lna->array[dns->seq[i].number]->stream[j]; if( lnad->add_stream != 0 ) { fprintf(lnad->ofp,"Adding %s as an existing stream, testing %d [%d]\n",dns->orig->name,j,lna->array[dns->seq[i].number]); } if( stream->a == NULL || stream->b == NULL) { /* joining to existing stream from adding things in? Or leaving stream? */ stream->depth++; if( is_new == 1 ) { /* we are entering the existing stream here */ edge = new_LinkEdge(lna); edge->x = prev; edge->y = stream; if( dns->seq[i].flipped == dns->seq[i-1].flipped ) { edge->twist = 0; } else { edge->twist = 1; } /* assumptions that we make as we are entering here */ assert(prev); assert(prev->a != NULL); assert(prev->b == NULL); prev->b = edge; if( stream->a == NULL ) { stream->a = edge; } else { stream->b = edge; } is_new = 0; prev = stream; } else { /* we are leaving the existing stream here have to set up the situtation so that the next link works ok */ is_old = 1; prev = stream; } break; /* out of over all streams */ } if( is_linked_LinkStream(prev,lna->array[dns->seq[i].number]->stream[j],dns->seq[i-1].flipped == dns->seq[i].flipped? 0 : 1) != NULL ) { lna->array[dns->seq[i].number]->stream[j]->depth++; prev = lna->array[dns->seq[i].number]->stream[j]; break; } } /* this means we have no stream position that made sense */ if( j >= lna->array[dns->seq[i].number]->len ) { fatal("We have a problem. No valid stream, despite adding to existing stream"); } } /* end of else is filled */ } /* end of final position */ } %func Writes in read as a new stream %% boolean write_new_LinkStream(LinkNumberArray * lna,LinkNumberArrayDebug * lnad,DnaNumberSequence * dns) { LinkStream * stream; LinkStream * prev; LinkEdge * edge; int i; /* First position is odd */ if( lna->array[dns->seq[0].number] == NULL ) { lna->array[dns->seq[0].number] = LinkNumber_alloc_std(); } stream = LinkStream_alloc(); stream->number = dns->seq[0].number; stream->starting_flip = dns->seq[0].flipped; stream->depth = 1; add_LinkNumber( lna->array[dns->seq[0].number],stream ); if( lnad->add_stream > 2 ) { fprintf(lnad->ofp,"Adding %s, on %d\n",dns->orig->name,dns->seq[0].number); } stream->a = NULL; prev = stream; for(i=1;ilen;i++) { if( lna->array[dns->seq[i].number] == NULL ) { lna->array[dns->seq[i].number] = LinkNumber_alloc_std(); } stream = LinkStream_alloc(); stream->number = dns->seq[i].number; stream->starting_flip = dns->seq[i].flipped; stream->depth = 1; add_LinkNumber( lna->array[dns->seq[i].number],stream ); if( lnad->add_stream > 2 ) { fprintf(lnad->ofp,"Adding %s, on %d\n",dns->orig->name,dns->seq[i].number); } edge = new_LinkEdge(lna); edge->x = prev; edge->y = stream; if( dns->seq[i].flipped == dns->seq[i-1].flipped ) { edge->twist = 0; } else { edge->twist = 1; } prev->b = edge; stream->a = edge; prev = stream; } /* final guy, finish off */ prev->b = NULL; } %func Returns the right edge which potentially links these two link streams %% LinkEdge * is_linked_LinkStream(LinkStream * l_one,LinkStream * l_two,char twist) { if( l_one->a != NULL && l_one->b != NULL ) { fprintf(stderr,"Testing Link %d with Edges %d,%d and links %d,%d [%d] and %d,%d [%d] to %d [%d]\n",l_one,l_one->a,l_one->b,l_one->a->x,l_one->a->y,l_one->a->twist,l_one->b->x,l_one->b->y,l_one->b->twist,l_two,twist); } if( l_one->a != NULL && l_one->a->x == l_one && l_one->a->y == l_two && l_one->a->twist == twist ) { return l_one->a; } if( l_one->a != NULL && l_one->a->y == l_one && l_one->a->x == l_two && l_one->a->twist == twist ) { return l_one->a; } if( l_one->b != NULL && l_one->b->x == l_one && l_one->b->y == l_two && l_one->b->twist == twist ) { return l_one->b; } if( l_one->b != NULL && l_one->b->y == l_one && l_one->b->x == l_two && l_one->b->twist == twist ) { return l_one->b; } fprintf(stderr,"Going to return NULL\n"); return NULL; } %func Determines whether this DnaNumberSequence should be newly streamed or not %% boolean is_new_stream_LinkNumberArray(LinkNumberArray * lna,LinkNumberArrayDebug * lnad,DnaNumberSequence * dns) { int i,j,k; boolean seen_end = 0; LinkStream * prev; assert(lna); assert(dns); /* find starting position */ for(i=0;ilen;i++) { if( lnad->placement_stream > 2 ) { fprintf(lnad->ofp,"Read %s is unique testing position %d with %d [%d]\n",dns->orig->name,i,dns->seq[i].number,lna->array[dns->seq[i].number]); } if( lna->array[dns->seq[i].number] != NULL ) break; } if( i >= dns->len ) { /* virgin - return TRUE */ if( lnad->placement_stream != 0 ) { fprintf(lnad->ofp,"Read %s is unique, starting new stream\n",dns->orig->name); } return TRUE; } if( lna->array[dns->seq[i].number]->len > 1 ) { if( lnad->placement_stream != 0 ) { fprintf(lnad->ofp,"Read %s starts on ambiguous position, can't cope\n",dns->orig->name); } return TRUE; } prev = lna->array[dns->seq[i].number]->stream[0]; for(i++;ilen;i++) { if( lna->array[dns->seq[i].number] == NULL ) break; for(j=0;jarray[dns->seq[i].number]->len;j++) { auto LinkStream * stream = lna->array[dns->seq[i].number]->stream[j]; auto LinkEdge * edge = is_linked_LinkStream(stream,prev,dns->seq[i-1].flipped == dns->seq[i].flipped ? 0 : 1); if( edge == NULL ) { if( lnad->placement_stream != 0 ) { fprintf(lnad->ofp,"Read %s, edge failure at position %d\n",dns->orig->name,i); } return TRUE; } if( lnad->placement_stream > 2 ) { fprintf(lnad->ofp,"Read %s, successfully found stream for position %d\n",dns->orig->name,i); } prev = stream; } } if( i < dns->len ) { /* reached end, on a stream! return FALSE */ if( lnad->placement_stream != 0 ) { fprintf(lnad->ofp,"Read %s is streamable to end\n",dns->orig->name); } return FALSE; } /* still could be valid if NULL to end of seq */ for(;ilen;i++) { if( lna->array[dns->seq[i].number] == NULL ) { if( lnad->placement_stream != 0 ) { fprintf(lnad->ofp,"Read %s was streamable to end, but has a re-entry\n",dns->orig->name); } return TRUE; } } if( lnad->placement_stream != 0 ) { fprintf(lnad->ofp,"Read %s is streamable to end, but does have unique tail\n",dns->orig->name); } return FALSE; } %func Returns a LinkNumberArray with the appropiate array size for this size of Nmer %% LinkNumberArray * new_LinkNumberArray(int nmer_size) { int size = 1; int i; LinkNumberArray * out; for(i=0;iarray = calloc(size,sizeof(LinkNumber*)); out->nmer_size = nmer_size; out->array_len = size; return out; } %func makes a new link edge added into the memory management %% LinkEdge * new_LinkEdge(LinkNumberArray * lna) { LinkEdge * new; assert(lna); new = LinkEdge_alloc(); add_LinkNumberArray(lna,new); return new; } %} wise-2.4.1/src/dnaindex/compara2dotplot.pl0000644000175000001440000000430410117345736020111 0ustar philippusersuse strict; my $shift_x = 20; my $shift_y = 20; my $length_x = 500; my $length_y = 500; my $max_x = 200_000_000; my $max_y = 200_000_000; my $scale = 10_000_000; my $slice = 1; my $slice_x_start = 16_900_000; my $slice_y_start = 17_400_000; my $slice_x_end = 17_600_000; if( $slice == 1 ) { $max_x = ($slice_x_end - $slice_x_start); $max_y = $max_x; } print < /Helvetica findfont 12 scalefont setfont 0.25 setlinewidth /Helvetica findfont 8 scalefont setfont EOF #if( $rotate ) { # print "0 700 translate\n"; #} # grid lines. print "$shift_x $shift_y moveto\n"; print $shift_x + $length_x," $shift_y lineto stroke\n"; print "$shift_x $shift_y moveto\n"; print "$shift_x ",$shift_y+$length_y," lineto stroke\n"; my $i =0; if( $slice == 0 ) { while( $i < $max_x ) { my $xpos = $shift_x + ($i*$length_x / $max_x); print $xpos," $shift_y moveto\n"; print $xpos," ",$shift_y-2," lineto stroke\n"; print $xpos," ",$shift_y-10," moveto\n"; my $number = $i / 10_000_000; print "($number) show\n"; $i += $scale; } $i =0; while( $i < $max_y ) { my $ypos = $shift_y + ($i*$length_y / $max_y); print "$shift_x $ypos moveto\n"; print $shift_x-2," $ypos lineto stroke\n"; print $shift_x-13," $ypos moveto\n"; my $number = $i / 10_000_000; print "($number) show\n"; $i += $scale; } } while( <> ) { /chr/ || next; #1024 chr7 0 1024 chr7 171263 170239 - my ($len,$a,$startx,$endx,$b,$starty,$endy) = split; if( $len < 500 ) { next; } if( $slice ) { if( $startx > $slice_x_end || $endx < $slice_x_start ) { next; } $startx -= $slice_x_start; $endx -= $slice_x_start; $starty -= $slice_y_start; $endy -= $slice_y_start; } my $coord_x_start = $shift_x + ($startx * $length_x / $max_x); my $coord_x_end = $shift_x + ($endx * $length_x / $max_x); my $coord_y_start = $shift_x + ($starty * $length_y / $max_y); my $coord_y_end = $shift_y + ($endy * $length_y / $max_y); print "$coord_x_start $coord_y_start moveto\n"; print "$coord_x_end $coord_y_end lineto\n"; print "stroke\n"; } print "showpage\n"; wise-2.4.1/src/dnaindex/test_kmer.c0000644000175000001440000000224207736003505016600 0ustar philippusers#include "kmer_assembly.h" #include "kmer_direct.h" #include "largeseqreader.h" #include "kmer_assembly_untangler.h" #include "kmer_assembly_error.h" #include "kmer_assembly_contig.h" #include "assembly.h" int main(int argc,char ** argv) { KmerIndexInterface * kii; KmerAssemblyIndex * kai; SinglePosSpace * sps; AssemblySequence * aseq; AssemblySequence * mirror; Assembly * assembly; KmerAssemblyContigPara * p; p = KmerAssemblyContigPara_alloc(); p->minimum_len = 0; p->minimum_depth = 1; sps = new_SinglePosSpace(1,2000); kii = new_KmerDirectIndex(12); kai = new_KmerAssemblyIndex(kii,sps); while( (aseq = read_plain_fasta_AssemblySequence(stdin,1000000,stderr)) != NULL ) { add_AssemblySequence_KmerAssemblyIndex(kai,aseq,1000000); mirror = mirrored_AssemblySequence(aseq); add_AssemblySequence_KmerAssemblyIndex(kai,mirror,1000000); } resolve_forward_errors_KmerAssembly(kai,1); remove_errors_KmerAssemblyIndex(kai,1); untangle_KmerAssembly(kai); assembly = Assembly_from_KmerAssemblyIndex(kai,p); show_extensive_stats_KmerAssemblyIndex(kai,stdout); dump_contigs_as_fasta_Assembly(assembly,stdout); } wise-2.4.1/src/dnaindex/shotgun.c0000644000175000001440000000736010670453716016304 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "shotgun.h" /* Function: generate_shotgun_reads(shot,input,ofp) * * Descrip: Generates a file of Shotgun reads from a particular * sequence randomly * * * Arg: shot [UNKN ] Undocumented argument [ShotgunPara *] * Arg: input [UNKN ] Undocumented argument [Sequence *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 27 "shotgun.dy" void generate_shotgun_reads(ShotgunPara * shot,Sequence * input,FILE * ofp) { int i; int j; int pos; Sequence * rev; Sequence * out; char * seqstr; char buffer[MAXLINE]; init_random(); seqstr = calloc(shot->read_length+1,sizeof(char)); rev = reverse_complement_Sequence(input); for(i=0;inumber;i++) { pos = random_integer(input->len-shot->insert_size); fprintf(stderr,"position at %d\n",pos); for(j=0;jread_length;j++) { seqstr[j] = input->seq[pos+j]; } seqstr[j] = '\0'; sprintf(buffer,"Read.%d.f",i); out = new_Sequence_from_strings(buffer,seqstr); write_fasta_Sequence(out,ofp); if( shot->forward_only == 1 ) { continue; } for(j=0;jread_length;j++) { seqstr[j] = rev->seq[rev->len-(pos+shot->insert_size+j)]; } seqstr[j] = '\0'; sprintf(buffer,"Read.%d.r",i); out = new_Sequence_from_strings(buffer,seqstr); write_fasta_Sequence(out,ofp); } free_Sequence(rev); free(seqstr); } # line 75 "shotgun.c" /* Function: hard_link_ShotgunPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShotgunPara *] * * Return [UNKN ] Undocumented return value [ShotgunPara *] * */ ShotgunPara * hard_link_ShotgunPara(ShotgunPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a ShotgunPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ShotgunPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShotgunPara *] * */ ShotgunPara * ShotgunPara_alloc(void) { ShotgunPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ShotgunPara *) ckalloc (sizeof(ShotgunPara))) == NULL) { warn("ShotgunPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->read_length = 0; out->insert_size = 0; out->number = 0; out->forward_only = 0; return out; } /* Function: free_ShotgunPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShotgunPara *] * * Return [UNKN ] Undocumented return value [ShotgunPara *] * */ ShotgunPara * free_ShotgunPara(ShotgunPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ShotgunPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/shotgun.h0000644000175000001440000000534410670453716016311 0ustar philippusers#ifndef DYNAMITEshotgunHEADERFILE #define DYNAMITEshotgunHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" struct Wise2_ShotgunPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int read_length; int insert_size; int number; int forward_only; } ; /* ShotgunPara defined */ #ifndef DYNAMITE_DEFINED_ShotgunPara typedef struct Wise2_ShotgunPara Wise2_ShotgunPara; #define ShotgunPara Wise2_ShotgunPara #define DYNAMITE_DEFINED_ShotgunPara #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: generate_shotgun_reads(shot,input,ofp) * * Descrip: Generates a file of Shotgun reads from a particular * sequence randomly * * * Arg: shot [UNKN ] Undocumented argument [ShotgunPara *] * Arg: input [UNKN ] Undocumented argument [Sequence *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_generate_shotgun_reads(ShotgunPara * shot,Sequence * input,FILE * ofp); #define generate_shotgun_reads Wise2_generate_shotgun_reads /* Function: hard_link_ShotgunPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShotgunPara *] * * Return [UNKN ] Undocumented return value [ShotgunPara *] * */ ShotgunPara * Wise2_hard_link_ShotgunPara(ShotgunPara * obj); #define hard_link_ShotgunPara Wise2_hard_link_ShotgunPara /* Function: ShotgunPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShotgunPara *] * */ ShotgunPara * Wise2_ShotgunPara_alloc(void); #define ShotgunPara_alloc Wise2_ShotgunPara_alloc /* Function: free_ShotgunPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShotgunPara *] * * Return [UNKN ] Undocumented return value [ShotgunPara *] * */ ShotgunPara * Wise2_free_ShotgunPara(ShotgunPara * obj); #define free_ShotgunPara Wise2_free_ShotgunPara /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/eulerindex.dy0000644000175000001440000004252007706577312017155 0ustar philippusers %{ #include "dyna.h" #include "singleseqspace.h" #include "dnamapping.h" #define EulerNodeLISTLENGTH 4 #define EulerGraphLISTLENGTH 128 #define EulerLinkLabelLength 8 #define EulerLinkLabelLinear 128 %} friend EulerNode friend EulerLink struct EulerLink EulerNode * prev !link EulerNode * next !link int * label int label_len int depth char base struct EulerPath EulerLink ** stack int max_stack_len int current struct EulerNode int number EulerLink ** link !list !len="link_" EulerLink ** back !list !len="back_" char is_leftmost char is_rightmost struct EulerGraph EulerNode ** node int node_len int kmer Sequence ** seq !list SinglePosSpace * sps EulerNode ** dup !list !len="dup_" struct EulerErrorPara int error_size !def="1" %{ #include "eulerindex.h" void dump_EulerGraph(EulerGraph * eg,FILE * ofp) { int i; int j; char dna_str[512]; assert(eg); assert(ofp); for(i=0;inode_len;i++) { if( eg->node[i] != NULL ) { reverse_map_dna_number(i,eg->kmer,dna_str); dna_str[eg->kmer] = '\0'; fprintf(ofp,"Node %d [%s]\n",i,dna_str); fprintf(ofp," Incoming Links:\n"); for(j=0;jnode[i]->back_len;j++) { fprintf(ofp," %d [%c] from %d\n",eg->node[i]->back[j]->depth,eg->node[i]->back[j]->base,eg->node[i]->back[j]->prev->number); } fprintf(ofp," Outgoing Links:\n"); for(j=0;jnode[i]->link_len;j++) { fprintf(ofp," %d [%c] to %d\n",eg->node[i]->link[j]->depth,eg->node[i]->link[j]->base,eg->node[i]->link[j]->next->number); } } } } Sequence * read_Sequence_EulerNode(EulerNode * leftmost) { int i; Sequence * out; EulerLink * l; assert(leftmost); assert(leftmost->link_len == 1); i=0; l = leftmost->link[0]; while( 1 ) { i++; if( l->next->link_len == 1 ) { l = l->next->link[0]; continue; } if( l->next->link_len > 1 ) { warn("Untangled repeat sequence on node %d\n",l->next->number); break; } if( l->next->link_len == 0 ) { break; } } out = Sequence_alloc(); out->seq = calloc(i+1,sizeof(char)); i=0; l = leftmost->link[0]; while( 1 ) { out->seq[i] = l->base; i++; if( l->next->link_len == 1 ) { l = l->next->link[0]; continue; } if( l->next->link_len > 1 ) { break; } if( l->next->link_len == 0 ) { break; } } out->seq[i] = '\0'; out->name = stringalloc("EulerGraphSequence"); return out; } boolean can_resolve_error_EulerGraph(EulerGraph *eg,EulerLink * leftmost) { EulerNode * node; EulerLink * path; int len = 1; int error_len; assert(eg); assert(leftmost); fprintf(stderr,"starting resolving\n"); error_len = eg->kmer; path = leftmost; while( len < error_len ) { if( path->depth != 1 ) { return FALSE; } if( path->next->link_len > 1 ) { return FALSE; } path = path->next->link[0]; if( path == NULL ) { return FALSE; } len++; } return TRUE; } boolean resolve_error_EulerGraph(EulerGraph * eg,EulerLink * leftmost) { char * dna = "ATGC"; char dna_str[128]; int i; int test_number; EulerLink * walk; int w; assert(eg); assert(leftmost); reverse_map_dna_number(leftmost->next->number,eg->kmer,dna_str); for(i=0,walk = leftmost;ikmer;i++) { dna_str[eg->kmer+i] = walk->base; walk = walk->next->link[0]; } dna_str[eg->kmer+i] = '\0'; fprintf(stderr,"Have string of %s\n",dna_str); for(i=0;i<4;i++) { dna_str[eg->kmer-1] = dna[i]; fprintf(stderr,"Considering %c for fixing\n",dna[i]); test_number = forward_dna_number_from_string(dna_str,eg->kmer); if( eg->node[test_number] != NULL && eg->node[test_number]->link_len ==1 ) { fprintf(stderr,"Test number works, now walking...\n"); for(walk = eg->node[test_number]->back[0],w=0; walk != NULL && wkmer;w++) { /* fprintf(stderr,"Looking at %c vs %c\n",dna_str[eg->kmer+w],walk->base); */ if( dna_str[eg->kmer+w] != walk->base ) { break; } walk = walk->next->link[0]; } if( w >= eg->kmer ) { fix_error_EulerGraph(eg,leftmost,dna_str,eg->kmer); return TRUE; } } } return FALSE; } void fix_error_EulerGraph(EulerGraph * eg, EulerLink * leftmost,char * dna_str,int len) { int i; int j; int number; int prev_number; EulerLink * walk; EulerLink * temp; EulerNode * prev; fprintf(stderr,"Fixing with %s length %d\n",dna_str,len); prev = leftmost->prev; prev_number = prev->number; walk = leftmost; for(i=0;ikmer); for(j=0;jnode[prev_number]->link_len;j++) { if( eg->node[prev_number]->link[j]->next->number == number ) { break; } } if( j >= eg->node[prev_number]->link_len ) { fprintf(stderr,"Problem here; fixed node doesn't have active numbers in link..."); return; } add_label_EulerLink(eg->node[prev_number]->link[j],walk->label[0]); prev_number = number; temp = walk; walk = walk->next->link[0]; remove_EulerLink_forward_EulerNode(temp->prev,temp); remove_EulerLink_backward_EulerNode(temp->next,temp); free_EulerLink(temp); } } void build_new_node_path_EulerGraph(EulerGraph * eg,EulerLink * leftmost,EulerPath * path,int * starting_labels,int length) { int i; int l; int path_offset; EulerNode * new_node; EulerNode * prev_node; EulerLink * new_link; assert(eg); assert(leftmost); assert(starting_labels); assert(length > 0); fprintf(stderr,"Going to build new node path\n"); new_node = new_EulerNode(leftmost->next->number); add_dup_EulerGraph(eg,new_node); new_link = new_EulerLink(); new_link->prev = leftmost->prev; new_link->next = new_node; new_link->base = leftmost->base; new_link->depth = length; for(l=0;lprev,new_link); add_back_EulerNode(new_link->next,new_link); prev_node = new_node; for(i=path->current-1,path_offset = 1;i >= 0 ;i--,path_offset++) { new_link = new_EulerLink(); new_link->prev = prev_node; new_link->next = NULL; new_link->base = path->stack[i]->base; new_link->depth = length; for(l=0;lstack[i],starting_labels[i]+path_offset); add_label_EulerLink(new_link,starting_labels[l]+path_offset); } if( i > 0 ) { new_node = new_EulerNode(path->stack[i]->next->number); add_dup_EulerGraph(eg,new_node); new_link->next = new_node; } else { /* connect to the same path */ new_link->next = path->stack[0]->next; } add_link_EulerNode(new_link->prev,new_link); add_back_EulerNode(new_link->next,new_link); prev_node = new_node; } } boolean attempt_untangle_EulerPath(EulerGraph *eg,EulerPath * path,EulerLink * leftmost) { int i; int j; SinglePosSequence * leftmost_sps[512]; SinglePosSequence * rightmost_sps[512]; int can_untangle_left[512]; int can_untangle_right[512]; int untangle_feasible = 0; int starting_label[512]; int total_labels = 0; int fully_left_untangled; int fully_right_untangled; assert(eg); assert(path); assert(leftmost); fprintf(stderr,"Considering untangle at position %d in path\n",path->current); for(i=0;ilabel_len && leftmost->label[i] != -1;i++) { leftmost_sps[i] = lookup_Sequence_SinglePosSpace(eg->sps,leftmost->label[i]); if( eg->kmer+leftmost->label[i]+3 > leftmost_sps[i]->end ) { can_untangle_left[i] = -2; fprintf(stderr,"Too close to end for resolving power, %s\n",leftmost_sps[i]->seq->name); } else { can_untangle_left[i] = -1; } } fprintf(stderr,"Going to look at rightmost\n"); for(i=0;istack[0]->label_len && path->stack[0]->label[i] != -1;i++) { rightmost_sps[i] = lookup_Sequence_SinglePosSpace(eg->sps,path->stack[0]->label[i]); if( path->stack[0]->label[i] - eg->kmer - 3 < rightmost_sps[i]->start ) { can_untangle_right[i] = -2; fprintf(stderr,"Too close to start for resolving power, %s\n",rightmost_sps[i]->seq->name); } else { can_untangle_right[i] = -1; } can_untangle_right[i] = -1; for(j=0;jlabel_len && leftmost->label[j] != -1;j++) { if( leftmost_sps[j]->seq == rightmost_sps[i]->seq && (path->current == (path->stack[0]->label[i] - leftmost->label[j])) ) { fprintf(stderr,"Able to untangle label %d with (%d) diff [left %d, right %d]\n",leftmost->label[j],path->stack[0]->label[i]-leftmost->label[j],j,i); can_untangle_left[j] = i; can_untangle_right[i] = j; untangle_feasible = 1; starting_label[total_labels++] = leftmost->label[j]; } } } if( untangle_feasible == 0 ) { fprintf(stderr,"No untangle feasible\n"); return 0; } fprintf(stderr,"Abotu to build new node path....\n"); build_new_node_path_EulerGraph(eg,leftmost,path,starting_label,total_labels); fully_left_untangled = 1; for(i=0;ilabel_len && leftmost->label[i] != -1 ;i++) { if( can_untangle_left[i] == -1 ) { fprintf(stderr,"Left: Label position %d not resolved (%s)\n",i,leftmost_sps[i]->seq->name); fully_left_untangled = 0; break; } } fully_right_untangled = 1; for(i=0;istack[0]->label_len && path->stack[0]->label[i] != -1;i++) { if( can_untangle_right[i] == -1 ) { fprintf(stderr,"Right: Label position %d not resolved (%s)\n",i,rightmost_sps[i]->seq->name); fully_right_untangled = 0; break; } } if( fully_left_untangled == 1) { fprintf(stderr,"Managed to fully left untangle path\n"); /* remove the link on leftmost */ remove_EulerLink_forward_EulerNode(leftmost->prev,leftmost); remove_EulerLink_backward_EulerNode(leftmost->next,leftmost); } if( fully_right_untangled == 1 ) { fprintf(stderr,"Managed to fully right untangle path\n"); /* remove the link on leftmost */ remove_EulerLink_forward_EulerNode(path->stack[0]->prev,path->stack[0]); remove_EulerLink_backward_EulerNode(path->stack[0]->next,path->stack[0]); } return fully_right_untangled; } boolean untangle_from_split_EulerNode(EulerGraph * eg,EulerNode * split_outgoing,int max_backtrack) { EulerPath * ep; int i; int resolved = 0; EulerLink * split[512]; int len; assert(eg); assert(split_outgoing); assert(split_outgoing->link_len > 1); ep = new_EulerPath(); for(i=0;ilink_len;i++) { split[i] = split_outgoing->link[i]; } len = split_outgoing->link_len; for(i=0;ilink_len == 1 ) { fprintf(stderr,"No need to resolve this node at %d from %d\n",i,len); break; } ep->current = 0; resolved = 0; untangle_EulerLink_EulerPath(eg,ep,split[i],&resolved,0,max_backtrack); } free_EulerPath(ep); } boolean untangle_EulerLink_EulerPath(EulerGraph * eg,EulerPath * current_path,EulerLink * current,int * resolved,int backtrack_len,int max_backtrack) { int i; int starting_path_point; assert(eg); assert(current_path); assert(current); fprintf(stderr,"Entering untangle at link between %d and %d, backtrack length of %d on path of %d\n",current->prev->number,current->next->number,backtrack_len,current_path->current); if( *resolved == 1 ) { return TRUE; } if( backtrack_len >= max_backtrack ) { return TRUE; } starting_path_point = current_path->current; while( 1 ) { /* push current into the path */ fprintf(stderr,"Pushing on to path link between %d and %d with back length of %d\n",current->prev->number,current->next->number,current->prev->back_len); push_EulerPath(current_path,current); backtrack_len++; if( current->prev->back_len == 0 ) { /* end of a stream! */ *resolved = 1; return TRUE; } if( current->prev->back_len > 1 ) { for(i=0;iprev->back_len;i++) { if( attempt_untangle_EulerPath(eg,current_path,current->prev->back[i]) == 1 ) { *resolved = 1; return TRUE; } } for(i=0;iprev->back_len;i++) { /* recurse into this branch */ untangle_EulerLink_EulerPath(eg,current_path,current->prev->back[i],resolved,backtrack_len,max_backtrack); } current_path->current = starting_path_point; /* at this point, gone down all paths, so return */ return TRUE; } else { /* continue in this routine steping back */ current = current->prev->back[0]; } } current_path->current = starting_path_point; return TRUE; } boolean remove_EulerLink_forward_EulerNode(EulerNode * n,EulerLink *l) { int i; assert(n); assert(l); for(i=0;ilink_len;i++) { if( n->link[i] == l ) { for(++i;ilink_len;i++) { n->link[i-1] = n->link[i]; } n->link_len--; return TRUE; } } return FALSE; } boolean remove_EulerLink_backward_EulerNode(EulerNode * n,EulerLink *l) { int i; assert(n); assert(l); for(i=0;iback_len;i++) { if( n->back[i] == l ) { for(++i;iback_len;i++) { n->back[i-1] = n->back[i]; } n->back_len--; return TRUE; } } fprintf(stderr,"...could not remove link\n"); return FALSE; } boolean remove_label_EulerLink(EulerLink * el,int label) { int i; assert(el); for(i=0;ilabel_len;i++) { if( el->label[i] == label ) { break; } } if( i >= el->label_len ) { return FALSE; } for(i++;ilabel_len && el->label[i] != -1 ;i++) { el->label[i-1] = el->label[i]; } el->label[i] = -1; return TRUE; } boolean store_Sequence_EulerGraph(EulerGraph * eg,Sequence * seq) { int i; int prev_number; int next_number; int pos_start; assert(eg); assert(seq); add_EulerGraph(eg,seq); pos_start = add_Sequence_SinglePosSpace(eg->sps,seq); for(i=0;ilen - eg->kmer ;i++) { prev_number = forward_dna_number_from_string(seq->seq+i,eg->kmer); next_number = forward_dna_number_from_string(seq->seq+i+1,eg->kmer); store_EulerLink_EulerGraph(eg,prev_number,next_number,seq->seq[i+eg->kmer],pos_start+i); } } boolean store_EulerLink_EulerGraph(EulerGraph * eg,int prev_number,int next_number,char base,int label) { int i; EulerLink * link; assert(eg); if( eg->node[prev_number] != NULL ) { for(i=0;inode[prev_number]->link_len;i++) { if( eg->node[prev_number]->link[i]->next->number == next_number ) { eg->node[prev_number]->link[i]->depth++; add_label_EulerLink(eg->node[prev_number]->link[i],label); return TRUE; } } } /* else need new link */ if( eg->node[prev_number] == NULL ) { eg->node[prev_number] = new_EulerNode(prev_number); } if( eg->node[next_number] == NULL ) { eg->node[next_number] = new_EulerNode(next_number); } link = new_EulerLink(); link->depth = 1; link->base = base; add_label_EulerLink(link,label); link->prev = eg->node[prev_number]; link->next = eg->node[next_number]; eg->node[prev_number]->is_rightmost = 0; eg->node[next_number]->is_leftmost = 0; add_link_EulerNode(eg->node[prev_number],link); add_back_EulerNode(eg->node[next_number],link); return TRUE; } EulerLink * new_EulerLink(void) { int i; EulerLink * out; out = EulerLink_alloc(); out->label = calloc(EulerLinkLabelLength,sizeof(int)); for(i=0;ilabel[i] = -1; } out->label_len = EulerLinkLabelLength; return out; } boolean add_label_EulerLink(EulerLink * el,int label) { int i; int old_len; assert(el); for(i=0;ilabel_len;i++) { if( el->label[i] == -1 ) { el->label[i] = label; return TRUE; } } /* run out of space */ old_len = el->label_len; if( el->label_len > EulerLinkLabelLinear ) { el->label = realloc(el->label,el->label_len*2*sizeof(int)); el->label_len = el->label_len*2; } else { el->label = realloc(el->label,el->label_len*el->label_len*sizeof(int)); el->label_len = el->label_len * el->label_len; } /* put label at old_len, and then -1s */ el->label[old_len] = label; for(i=old_len+1;ilabel_len;i++) { el->label[i] = -1; } return TRUE; } EulerNode * new_EulerNode(int number) { EulerNode * out; out = EulerNode_alloc_std(); out->number = number; out->is_leftmost = 1; out->is_rightmost = 1; return out; } EulerGraph * new_EulerGraph(int kmer) { EulerGraph * out; int len = 1; int i; for(i=0;inode = calloc(len,sizeof(EulerNode*)); out->node_len = len; out->kmer = kmer; out->sps = new_SinglePosSpace(0,3000); return out; } void * push_EulerPath(EulerPath * ep,EulerLink * el) { assert(ep); assert(el); if( ep->current+1 >= ep->max_stack_len ) extend_EulerPath_stack(ep); ep->stack[ep->current++] = el; return; } EulerLink * pop_EulerPath(EulerPath * ep) { assert(ep); if( ep->current <= 0 ) { warn("Stack underflow on EulerPath"); return NULL; } return ep->stack[ep->current--]; } void extend_EulerPath_stack(EulerPath * ep) { assert(ep); ep->stack = (EulerLink**) realloc(ep->stack,sizeof(EulerLink*) * ep->max_stack_len * 2); ep->max_stack_len = ep->max_stack_len * 2; return; } EulerPath * new_EulerPath(void) { EulerPath * out; out = EulerPath_alloc(); out->stack = (EulerLink**) calloc(64,sizeof(EulerLink*)); out->max_stack_len = 64; out->current = 0; return out; } %} wise-2.4.1/src/dnaindex/assembly_stream_fasta.dy0000644000175000001440000000106107736003505021343 0ustar philippusers %{ #include "assembly_stream_interface.h" %} %{ #include "assembly_stream_fasta.h" AssemblySequenceStream * plain_fasta_AssemblySequenceStream(FILE * ifp) { AssemblySequenceStream * out; out = AssemblySequenceStream_alloc(); out->handle = (void*) ifp; out->next_AssemblySequence = next_AssemblySequence_fasta_impl; out->free_handle = NULL; /* it is a no-op */ return out; } AssemblySequence * next_AssemblySequence_fasta_impl(void * h) { FILE * ifp = (FILE *) h; return read_plain_fasta_AssemblySequence(ifp,0,NULL); } %} wise-2.4.1/src/dnaindex/assembly_stream_interface.c0000644000175000001440000000536510670453716022032 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "assembly_stream_interface.h" /* Function: free_AssemblySequenceStream(obj) * * Descrip: provides specific deconstructor * * * Arg: obj [UNKN ] Undocumented argument [AssemblySequenceStream *] * * Return [UNKN ] Undocumented return value [AssemblySequenceStream *] * */ # line 23 "assembly_stream_interface.dy" AssemblySequenceStream * free_AssemblySequenceStream(AssemblySequenceStream * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AssemblySequenceStream obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->handle != NULL ) { if( obj->free_handle == NULL ) { warn("In assembly stream constructor, no free function for handle. Probably will leak memory"); } else { (*obj->free_handle)(obj->handle); } } free(obj); return NULL; } # line 52 "assembly_stream_interface.c" /* Function: hard_link_AssemblySequenceStream(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblySequenceStream *] * * Return [UNKN ] Undocumented return value [AssemblySequenceStream *] * */ AssemblySequenceStream * hard_link_AssemblySequenceStream(AssemblySequenceStream * obj) { if( obj == NULL ) { warn("Trying to hard link to a AssemblySequenceStream object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AssemblySequenceStream_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblySequenceStream *] * */ AssemblySequenceStream * AssemblySequenceStream_alloc(void) { AssemblySequenceStream * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AssemblySequenceStream *) ckalloc (sizeof(AssemblySequenceStream))) == NULL) { warn("AssemblySequenceStream_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->next_AssemblySequence = NULL; out->free_handle = NULL; return out; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/assembly_stream_interface.h0000644000175000001440000000503410670453716022030 0ustar philippusers#ifndef DYNAMITEassembly_stream_interfaceHEADERFILE #define DYNAMITEassembly_stream_interfaceHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "assembly.h" struct Wise2_AssemblySequenceStream { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif AssemblySequence * (*next_AssemblySequence)(void *); void (*free_handle)(void *); void * handle; } ; /* AssemblySequenceStream defined */ #ifndef DYNAMITE_DEFINED_AssemblySequenceStream typedef struct Wise2_AssemblySequenceStream Wise2_AssemblySequenceStream; #define AssemblySequenceStream Wise2_AssemblySequenceStream #define DYNAMITE_DEFINED_AssemblySequenceStream #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: free_AssemblySequenceStream(obj) * * Descrip: provides specific deconstructor * * * Arg: obj [UNKN ] Undocumented argument [AssemblySequenceStream *] * * Return [UNKN ] Undocumented return value [AssemblySequenceStream *] * */ AssemblySequenceStream * Wise2_free_AssemblySequenceStream(AssemblySequenceStream * obj); #define free_AssemblySequenceStream Wise2_free_AssemblySequenceStream /* Function: hard_link_AssemblySequenceStream(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblySequenceStream *] * * Return [UNKN ] Undocumented return value [AssemblySequenceStream *] * */ AssemblySequenceStream * Wise2_hard_link_AssemblySequenceStream(AssemblySequenceStream * obj); #define hard_link_AssemblySequenceStream Wise2_hard_link_AssemblySequenceStream /* Function: AssemblySequenceStream_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblySequenceStream *] * */ AssemblySequenceStream * Wise2_AssemblySequenceStream_alloc(void); #define AssemblySequenceStream_alloc Wise2_AssemblySequenceStream_alloc /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/bigseqwise.c0000644000175000001440000000565507730362752016766 0ustar philippusers #include "comparapath.h" #include "../models/version.h" #include "kmer_direct.h" #include "kmer_hash.h" char * program_name = "bigseqwise"; void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EMBL and others\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney \n"); exit(63); } void show_help(FILE * ofp) { fprintf(ofp,"%s reference-assembly-as-fasta query-assembly-as-fasta\n",program_name); fprintf(ofp," -lognumber [1000000] number of base pairs for logging [0 for none]\n"); fprintf(ofp," -kmer [12] kmer size for kmer-graph\n"); fprintf(ofp," -[no]use_hash [default no] use 28bit hash for large kmer sizes\n"); fprintf(ofp," -restrict restrict reference to only active positions\n"); show_standard_options(ofp); } int main(int argc,char ** argv) { FILE * ref; FILE * q; FILE * logfp; SetofHSPset * hspset; ComparaLinkStartSet * reference; ComparaLinkStartSet * query; ComparaIndex * ci; KmerIndexInterface * kii; int kmer_size = 12; boolean use_28bithash = 0; boolean target_restrict = 0; int lognumber = 1000000; strip_out_integer_argument(&argc,argv,"lognumber",&lognumber); strip_out_integer_argument(&argc,argv,"kmer",&kmer_size); strip_out_boolean_def_argument(&argc,argv,"use_hash",&use_28bithash); strip_out_boolean_def_argument(&argc,argv,"restrict",&target_restrict); fprintf(stderr,"Hash used is %d\n",use_28bithash); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc != 4 ) { show_help(stdout); exit(12); } ref = openfile(argv[1],"r"); if( ref == NULL) { fatal("Unable to open file %s",argv[1]); } q = openfile(argv[2],"r"); if( ref == NULL) { fatal("Unable to open file %s",argv[2]); } if( strcmp(argv[3],"stderr") == 0 ) { logfp = stderr; } else { logfp = openfile(argv[3],"w"); if( logfp == NULL ) { fatal("unable to open %s as a logfile",argv[3]); } } fprintf(stderr,"Hash used is %d\n",use_28bithash); if( use_28bithash == FALSE) { kii = new_KmerDirectIndex(kmer_size); } else { fprintf(stderr,"Opening hash index...\n"); kii = new_KmerHashIndex(kmer_size); } ci = new_ComparaIndex(kii); query = add_Sequence_stream_ComparaIndex(ci,q,0,lognumber,0,logfp,"query"); reference = add_Sequence_stream_ComparaIndex(ci,ref,1,lognumber,target_restrict,logfp,"ref"); insert_revcom_Splines_in_set(ci,query,logfp); hspset = SetofHSPset_from_ComparaIndex(ci,query,logfp); show_SetofHSPset(hspset,stdout); return 0; } wise-2.4.1/src/dnaindex/tangle.fa0000644000175000001440000000041007716200047016212 0ustar philippusers>hs_est_a GAGAGGGCGAAGGTAGGCTGG GCCGCCGAAGAAGCATCGTTA CTCCTAAAGAGCCCGAACAGC >hs_est_b GAGAGATCCAAACACCAAGCG GCCGCCGAAGAAGCATCGTTA CAAAGAGAGCTGTCTCCAGAG >hs_est_c GAGAGATCCAAACACCAAGCG GCCGCCGAAGAAGCATCGTTA >hs_est_d GAGAGGGCGAAGGTAGGCTGG GCCGCCGAAGAAGCATCGTTA wise-2.4.1/src/dnaindex/kmer_count.dy0000644000175000001440000000145410064320541017135 0ustar philippusers %{ #include "dyna.h" #define KMER_COUNT_BLOCKSIZE 400 #define KmerCountAllocatorLISTLENGTH 128 %} struct KmerCount int long count struct KmerCountBlock KmerCount count[KMER_COUNT_BLOCKSIZE] struct KmerCountAllocator KmerCountBlock ** block !list int current_count %{ #include "kmer_count.h" KmerCount * new_KmerCount_KmerCountAllocator(KmerCountAllocator * kca) { if( kca->current_count >= KMER_COUNT_BLOCKSIZE ) { add_KmerCountAllocator(kca,KmerCountBlock_alloc()); kca->current_count = 0; } return &(kca->block[kca->len-1]->count[kca->current_count++]); } KmerCountAllocator * new_KmerCountAllocator(void) { KmerCountAllocator * out; out = KmerCountAllocator_alloc_std(); add_KmerCountAllocator(out,KmerCountBlock_alloc()); out->current_count = 0; return out; } %} wise-2.4.1/src/dnaindex/vectorindex.c0000644000175000001440000002516310670453716017150 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "vectorindex.h" # line 28 "vectorindex.dy" double vector_KmerVectorPosition(KmerVectorPosition * a,KmerVectorPosition * b) { int i; double out = 0.0; for(i=0;ikmer_vector[i] * b->kmer_vector[i] / 256; } return out; } # line 40 "vectorindex.dy" KmerVectorPosition * new_KmerVectorPosition(void) { KmerVectorPosition * out; out = malloc(sizeof(KmerVectorPosition)); bzero(out->kmer_vector,KMER_VECTOR_LENGTH); return out; } # line 52 "vectorindex.dy" KmerVectorPositionSet * build_KmerVectorPositionSet(Sequence * input,long int start_pos,int step_size) { int i; int j; int k; int base[KMER_VECTOR_SIZE]; int temp; int is_forward; int curr; int forward; int backward; int vec; KmerVectorPosition * pos; KmerVectorPositionSet * out; assert(input != NULL); temp = 1; for(i=0;ilen / step_size)+2); for(i=0;i+step_sizelen;) { pos = new_KmerVectorPosition(); pos->position = start_pos + i; for(j=0;j<256 - KMER_VECTOR_SIZE;j++) { curr = i+j; /* first find lexical forward/backwardness */ is_forward = 1; /* palindromes read forward */ for(k=0;kseq[curr+k]); backward = complement_base(base_from_char(input->seq[curr+KMER_VECTOR_SIZE-k])); if( forward == backward ) { continue; } if( forward > backward ) { is_forward = 1; } else { is_forward = 0; } break; } vec = 0; for(k=0;kseq[curr+k]); } else { vec += base[k] * complement_base(base_from_char(input->seq[curr+KMER_VECTOR_SIZE-k])); } } assert(vec < KMER_VECTOR_LENGTH); pos->kmer_vector[vec]++; fatal("Ewan has not finished this yet! Idiot!"); } } return out; } # line 125 "vectorindex.dy" KmerVectorPosition * free_KmerVectorPosition(KmerVectorPosition * vec) { free(vec); return NULL; } # line 114 "vectorindex.c" /* Function: swap_KmerVectorPositionSet(list,i,j) * * Descrip: swap function: an internal for qsort_KmerVectorPositionSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [KmerVectorPosition **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_KmerVectorPositionSet(KmerVectorPosition ** list,int i,int j) { KmerVectorPosition * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_KmerVectorPositionSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_KmerVectorPositionSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [KmerVectorPosition **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_KmerVectorPositionSet(KmerVectorPosition ** list,int left,int right,int (*comp)(KmerVectorPosition * ,KmerVectorPosition * )) { int i,last; if( left >= right ) return; swap_KmerVectorPositionSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_KmerVectorPositionSet (list,++last,i); } swap_KmerVectorPositionSet (list,left,last); qsort_KmerVectorPositionSet(list,left,last-1,comp); qsort_KmerVectorPositionSet(list,last+1,right,comp); } /* Function: sort_KmerVectorPositionSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_KmerVectorPositionSet * * * Arg: obj [UNKN ] Object containing list [KmerVectorPositionSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_KmerVectorPositionSet(KmerVectorPositionSet * obj,int (*comp)(KmerVectorPosition *, KmerVectorPosition *)) { qsort_KmerVectorPositionSet(obj->vec,0,obj->len-1,comp); return; } /* Function: expand_KmerVectorPositionSet(obj,len) * * Descrip: Really an internal function for add_KmerVectorPositionSet * * * Arg: obj [UNKN ] Object which contains the list [KmerVectorPositionSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_KmerVectorPositionSet(KmerVectorPositionSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_KmerVectorPositionSet called with no need"); return TRUE; } if( (obj->vec = (KmerVectorPosition ** ) ckrealloc (obj->vec,sizeof(KmerVectorPosition *)*len)) == NULL) { warn("ckrealloc failed for expand_KmerVectorPositionSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_KmerVectorPositionSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [KmerVectorPositionSet *] * Arg: add [OWNER] Object to add to the list [KmerVectorPosition *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_KmerVectorPositionSet(KmerVectorPositionSet * obj,KmerVectorPosition * add) { if( obj->len >= obj->maxlen) { if( expand_KmerVectorPositionSet(obj,obj->len + KmerVectorPositionSetLISTLENGTH) == FALSE) return FALSE; } obj->vec[obj->len++]=add; return TRUE; } /* Function: flush_KmerVectorPositionSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [KmerVectorPositionSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_KmerVectorPositionSet(KmerVectorPositionSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->vec[i] != NULL) { free_KmerVectorPosition(obj->vec[i]); obj->vec[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: KmerVectorPositionSet_alloc_std(void) * * Descrip: Equivalent to KmerVectorPositionSet_alloc_len(KmerVectorPositionSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [KmerVectorPositionSet *] * */ KmerVectorPositionSet * KmerVectorPositionSet_alloc_std(void) { return KmerVectorPositionSet_alloc_len(KmerVectorPositionSetLISTLENGTH); } /* Function: KmerVectorPositionSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [KmerVectorPositionSet *] * */ KmerVectorPositionSet * KmerVectorPositionSet_alloc_len(int len) { KmerVectorPositionSet * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = KmerVectorPositionSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->vec = (KmerVectorPosition ** ) ckcalloc (len,sizeof(KmerVectorPosition *))) == NULL) { warn("Warning, ckcalloc failed in KmerVectorPositionSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_KmerVectorPositionSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerVectorPositionSet *] * * Return [UNKN ] Undocumented return value [KmerVectorPositionSet *] * */ KmerVectorPositionSet * hard_link_KmerVectorPositionSet(KmerVectorPositionSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a KmerVectorPositionSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: KmerVectorPositionSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerVectorPositionSet *] * */ KmerVectorPositionSet * KmerVectorPositionSet_alloc(void) { KmerVectorPositionSet * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(KmerVectorPositionSet *) ckalloc (sizeof(KmerVectorPositionSet))) == NULL) { warn("KmerVectorPositionSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->vec = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_KmerVectorPositionSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerVectorPositionSet *] * * Return [UNKN ] Undocumented return value [KmerVectorPositionSet *] * */ KmerVectorPositionSet * free_KmerVectorPositionSet(KmerVectorPositionSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a KmerVectorPositionSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->vec != NULL) { for(i=0;ilen;i++) { if( obj->vec[i] != NULL) free_KmerVectorPosition(obj->vec[i]); } ckfree(obj->vec); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/vectorindex.h0000644000175000001440000001355010670453716017152 0ustar philippusers#ifndef DYNAMITEvectorindexHEADERFILE #define DYNAMITEvectorindexHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #define KMER_VECTOR_LENGTH 4069 #define KMER_VECTOR_SIZE 6 typedef struct KmerVectorPosition { char kmer_vector[KMER_VECTOR_LENGTH]; long int position; } KmerVectorPosition; #define KmerVectorPositionSetLISTLENGTH 4096 struct Wise2_KmerVectorPositionSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif KmerVectorPosition ** vec; int len;/* len for above vec */ int maxlen; /* maxlen for above vec */ } ; /* KmerVectorPositionSet defined */ #ifndef DYNAMITE_DEFINED_KmerVectorPositionSet typedef struct Wise2_KmerVectorPositionSet Wise2_KmerVectorPositionSet; #define KmerVectorPositionSet Wise2_KmerVectorPositionSet #define DYNAMITE_DEFINED_KmerVectorPositionSet #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: add_KmerVectorPositionSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [KmerVectorPositionSet *] * Arg: add [OWNER] Object to add to the list [KmerVectorPosition *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_KmerVectorPositionSet(KmerVectorPositionSet * obj,KmerVectorPosition * add); #define add_KmerVectorPositionSet Wise2_add_KmerVectorPositionSet /* Function: flush_KmerVectorPositionSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [KmerVectorPositionSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_KmerVectorPositionSet(KmerVectorPositionSet * obj); #define flush_KmerVectorPositionSet Wise2_flush_KmerVectorPositionSet /* Function: KmerVectorPositionSet_alloc_std(void) * * Descrip: Equivalent to KmerVectorPositionSet_alloc_len(KmerVectorPositionSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [KmerVectorPositionSet *] * */ KmerVectorPositionSet * Wise2_KmerVectorPositionSet_alloc_std(void); #define KmerVectorPositionSet_alloc_std Wise2_KmerVectorPositionSet_alloc_std /* Function: KmerVectorPositionSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [KmerVectorPositionSet *] * */ KmerVectorPositionSet * Wise2_KmerVectorPositionSet_alloc_len(int len); #define KmerVectorPositionSet_alloc_len Wise2_KmerVectorPositionSet_alloc_len /* Function: hard_link_KmerVectorPositionSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerVectorPositionSet *] * * Return [UNKN ] Undocumented return value [KmerVectorPositionSet *] * */ KmerVectorPositionSet * Wise2_hard_link_KmerVectorPositionSet(KmerVectorPositionSet * obj); #define hard_link_KmerVectorPositionSet Wise2_hard_link_KmerVectorPositionSet /* Function: KmerVectorPositionSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerVectorPositionSet *] * */ KmerVectorPositionSet * Wise2_KmerVectorPositionSet_alloc(void); #define KmerVectorPositionSet_alloc Wise2_KmerVectorPositionSet_alloc /* Function: free_KmerVectorPositionSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerVectorPositionSet *] * * Return [UNKN ] Undocumented return value [KmerVectorPositionSet *] * */ KmerVectorPositionSet * Wise2_free_KmerVectorPositionSet(KmerVectorPositionSet * obj); #define free_KmerVectorPositionSet Wise2_free_KmerVectorPositionSet /* Unplaced functions */ /* There has been no indication of the use of these functions */ double Wise2_vector_KmerVectorPosition(KmerVectorPosition * a,KmerVectorPosition * b); #define vector_KmerVectorPosition Wise2_vector_KmerVectorPosition KmerVectorPosition * Wise2_new_KmerVectorPosition(void); #define new_KmerVectorPosition Wise2_new_KmerVectorPosition KmerVectorPositionSet * Wise2_build_KmerVectorPositionSet(Sequence * input,long int start_pos,int step_size); #define build_KmerVectorPositionSet Wise2_build_KmerVectorPositionSet KmerVectorPosition * Wise2_free_KmerVectorPosition(KmerVectorPosition * vec); #define free_KmerVectorPosition Wise2_free_KmerVectorPosition /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_KmerVectorPositionSet(KmerVectorPosition ** list,int i,int j) ; #define swap_KmerVectorPositionSet Wise2_swap_KmerVectorPositionSet void Wise2_qsort_KmerVectorPositionSet(KmerVectorPosition ** list,int left,int right,int (*comp)(KmerVectorPosition * ,KmerVectorPosition * )); #define qsort_KmerVectorPositionSet Wise2_qsort_KmerVectorPositionSet void Wise2_sort_KmerVectorPositionSet(KmerVectorPositionSet * obj,int (*comp)(KmerVectorPosition *, KmerVectorPosition *)); #define sort_KmerVectorPositionSet Wise2_sort_KmerVectorPositionSet boolean Wise2_expand_KmerVectorPositionSet(KmerVectorPositionSet * obj,int len); #define expand_KmerVectorPositionSet Wise2_expand_KmerVectorPositionSet #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/kmer_count.c0000644000175000001440000003235110670453716016761 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "kmer_count.h" # line 24 "kmer_count.dy" KmerCount * new_KmerCount_KmerCountAllocator(KmerCountAllocator * kca) { if( kca->current_count >= KMER_COUNT_BLOCKSIZE ) { add_KmerCountAllocator(kca,KmerCountBlock_alloc()); kca->current_count = 0; } return &(kca->block[kca->len-1]->count[kca->current_count++]); } # line 36 "kmer_count.dy" KmerCountAllocator * new_KmerCountAllocator(void) { KmerCountAllocator * out; out = KmerCountAllocator_alloc_std(); add_KmerCountAllocator(out,KmerCountBlock_alloc()); out->current_count = 0; return out; } # line 32 "kmer_count.c" /* Function: hard_link_KmerCount(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerCount *] * * Return [UNKN ] Undocumented return value [KmerCount *] * */ KmerCount * hard_link_KmerCount(KmerCount * obj) { if( obj == NULL ) { warn("Trying to hard link to a KmerCount object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: KmerCount_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerCount *] * */ KmerCount * KmerCount_alloc(void) { KmerCount * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(KmerCount *) ckalloc (sizeof(KmerCount))) == NULL) { warn("KmerCount_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->count = 0; return out; } /* Function: free_KmerCount(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerCount *] * * Return [UNKN ] Undocumented return value [KmerCount *] * */ KmerCount * free_KmerCount(KmerCount * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a KmerCount obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_KmerCountBlock(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerCountBlock *] * * Return [UNKN ] Undocumented return value [KmerCountBlock *] * */ KmerCountBlock * hard_link_KmerCountBlock(KmerCountBlock * obj) { if( obj == NULL ) { warn("Trying to hard link to a KmerCountBlock object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: KmerCountBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerCountBlock *] * */ KmerCountBlock * KmerCountBlock_alloc(void) { KmerCountBlock * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(KmerCountBlock *) ckalloc (sizeof(KmerCountBlock))) == NULL) { warn("KmerCountBlock_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* count[KMER_COUNT_BLOCKSIZE] is an array: no default possible */ return out; } /* Function: free_KmerCountBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerCountBlock *] * * Return [UNKN ] Undocumented return value [KmerCountBlock *] * */ KmerCountBlock * free_KmerCountBlock(KmerCountBlock * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a KmerCountBlock obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_KmerCountAllocator(list,i,j) * * Descrip: swap function: an internal for qsort_KmerCountAllocator * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [KmerCountBlock **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_KmerCountAllocator(KmerCountBlock ** list,int i,int j) { KmerCountBlock * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_KmerCountAllocator(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_KmerCountAllocator which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [KmerCountBlock **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_KmerCountAllocator(KmerCountBlock ** list,int left,int right,int (*comp)(KmerCountBlock * ,KmerCountBlock * )) { int i,last; if( left >= right ) return; swap_KmerCountAllocator(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_KmerCountAllocator (list,++last,i); } swap_KmerCountAllocator (list,left,last); qsort_KmerCountAllocator(list,left,last-1,comp); qsort_KmerCountAllocator(list,last+1,right,comp); } /* Function: sort_KmerCountAllocator(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_KmerCountAllocator * * * Arg: obj [UNKN ] Object containing list [KmerCountAllocator *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_KmerCountAllocator(KmerCountAllocator * obj,int (*comp)(KmerCountBlock *, KmerCountBlock *)) { qsort_KmerCountAllocator(obj->block,0,obj->len-1,comp); return; } /* Function: expand_KmerCountAllocator(obj,len) * * Descrip: Really an internal function for add_KmerCountAllocator * * * Arg: obj [UNKN ] Object which contains the list [KmerCountAllocator *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_KmerCountAllocator(KmerCountAllocator * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_KmerCountAllocator called with no need"); return TRUE; } if( (obj->block = (KmerCountBlock ** ) ckrealloc (obj->block,sizeof(KmerCountBlock *)*len)) == NULL) { warn("ckrealloc failed for expand_KmerCountAllocator, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_KmerCountAllocator(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [KmerCountAllocator *] * Arg: add [OWNER] Object to add to the list [KmerCountBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_KmerCountAllocator(KmerCountAllocator * obj,KmerCountBlock * add) { if( obj->len >= obj->maxlen) { if( expand_KmerCountAllocator(obj,obj->len + KmerCountAllocatorLISTLENGTH) == FALSE) return FALSE; } obj->block[obj->len++]=add; return TRUE; } /* Function: flush_KmerCountAllocator(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [KmerCountAllocator *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_KmerCountAllocator(KmerCountAllocator * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->block[i] != NULL) { free_KmerCountBlock(obj->block[i]); obj->block[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: KmerCountAllocator_alloc_std(void) * * Descrip: Equivalent to KmerCountAllocator_alloc_len(KmerCountAllocatorLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [KmerCountAllocator *] * */ KmerCountAllocator * KmerCountAllocator_alloc_std(void) { return KmerCountAllocator_alloc_len(KmerCountAllocatorLISTLENGTH); } /* Function: KmerCountAllocator_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [KmerCountAllocator *] * */ KmerCountAllocator * KmerCountAllocator_alloc_len(int len) { KmerCountAllocator * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = KmerCountAllocator_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->block = (KmerCountBlock ** ) ckcalloc (len,sizeof(KmerCountBlock *))) == NULL) { warn("Warning, ckcalloc failed in KmerCountAllocator_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_KmerCountAllocator(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerCountAllocator *] * * Return [UNKN ] Undocumented return value [KmerCountAllocator *] * */ KmerCountAllocator * hard_link_KmerCountAllocator(KmerCountAllocator * obj) { if( obj == NULL ) { warn("Trying to hard link to a KmerCountAllocator object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: KmerCountAllocator_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerCountAllocator *] * */ KmerCountAllocator * KmerCountAllocator_alloc(void) { KmerCountAllocator * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(KmerCountAllocator *) ckalloc (sizeof(KmerCountAllocator))) == NULL) { warn("KmerCountAllocator_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->block = NULL; out->len = out->maxlen = 0; out->current_count = 0; return out; } /* Function: free_KmerCountAllocator(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerCountAllocator *] * * Return [UNKN ] Undocumented return value [KmerCountAllocator *] * */ KmerCountAllocator * free_KmerCountAllocator(KmerCountAllocator * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a KmerCountAllocator obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->block != NULL) { for(i=0;ilen;i++) { if( obj->block[i] != NULL) free_KmerCountBlock(obj->block[i]); } ckfree(obj->block); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/kmer_count.h0000644000175000001440000002017210670453716016764 0ustar philippusers#ifndef DYNAMITEkmer_countHEADERFILE #define DYNAMITEkmer_countHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #define KMER_COUNT_BLOCKSIZE 400 #define KmerCountAllocatorLISTLENGTH 128 struct Wise2_KmerCount { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int count; } ; /* KmerCount defined */ #ifndef DYNAMITE_DEFINED_KmerCount typedef struct Wise2_KmerCount Wise2_KmerCount; #define KmerCount Wise2_KmerCount #define DYNAMITE_DEFINED_KmerCount #endif struct Wise2_KmerCountBlock { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif KmerCount count[KMER_COUNT_BLOCKSIZE]; } ; /* KmerCountBlock defined */ #ifndef DYNAMITE_DEFINED_KmerCountBlock typedef struct Wise2_KmerCountBlock Wise2_KmerCountBlock; #define KmerCountBlock Wise2_KmerCountBlock #define DYNAMITE_DEFINED_KmerCountBlock #endif struct Wise2_KmerCountAllocator { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif KmerCountBlock ** block; int len;/* len for above block */ int maxlen; /* maxlen for above block */ int current_count; } ; /* KmerCountAllocator defined */ #ifndef DYNAMITE_DEFINED_KmerCountAllocator typedef struct Wise2_KmerCountAllocator Wise2_KmerCountAllocator; #define KmerCountAllocator Wise2_KmerCountAllocator #define DYNAMITE_DEFINED_KmerCountAllocator #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_KmerCount(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerCount *] * * Return [UNKN ] Undocumented return value [KmerCount *] * */ KmerCount * Wise2_hard_link_KmerCount(KmerCount * obj); #define hard_link_KmerCount Wise2_hard_link_KmerCount /* Function: KmerCount_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerCount *] * */ KmerCount * Wise2_KmerCount_alloc(void); #define KmerCount_alloc Wise2_KmerCount_alloc /* Function: free_KmerCount(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerCount *] * * Return [UNKN ] Undocumented return value [KmerCount *] * */ KmerCount * Wise2_free_KmerCount(KmerCount * obj); #define free_KmerCount Wise2_free_KmerCount /* Function: hard_link_KmerCountBlock(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerCountBlock *] * * Return [UNKN ] Undocumented return value [KmerCountBlock *] * */ KmerCountBlock * Wise2_hard_link_KmerCountBlock(KmerCountBlock * obj); #define hard_link_KmerCountBlock Wise2_hard_link_KmerCountBlock /* Function: KmerCountBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerCountBlock *] * */ KmerCountBlock * Wise2_KmerCountBlock_alloc(void); #define KmerCountBlock_alloc Wise2_KmerCountBlock_alloc /* Function: free_KmerCountBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerCountBlock *] * * Return [UNKN ] Undocumented return value [KmerCountBlock *] * */ KmerCountBlock * Wise2_free_KmerCountBlock(KmerCountBlock * obj); #define free_KmerCountBlock Wise2_free_KmerCountBlock /* Function: add_KmerCountAllocator(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [KmerCountAllocator *] * Arg: add [OWNER] Object to add to the list [KmerCountBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_KmerCountAllocator(KmerCountAllocator * obj,KmerCountBlock * add); #define add_KmerCountAllocator Wise2_add_KmerCountAllocator /* Function: flush_KmerCountAllocator(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [KmerCountAllocator *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_KmerCountAllocator(KmerCountAllocator * obj); #define flush_KmerCountAllocator Wise2_flush_KmerCountAllocator /* Function: KmerCountAllocator_alloc_std(void) * * Descrip: Equivalent to KmerCountAllocator_alloc_len(KmerCountAllocatorLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [KmerCountAllocator *] * */ KmerCountAllocator * Wise2_KmerCountAllocator_alloc_std(void); #define KmerCountAllocator_alloc_std Wise2_KmerCountAllocator_alloc_std /* Function: KmerCountAllocator_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [KmerCountAllocator *] * */ KmerCountAllocator * Wise2_KmerCountAllocator_alloc_len(int len); #define KmerCountAllocator_alloc_len Wise2_KmerCountAllocator_alloc_len /* Function: hard_link_KmerCountAllocator(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerCountAllocator *] * * Return [UNKN ] Undocumented return value [KmerCountAllocator *] * */ KmerCountAllocator * Wise2_hard_link_KmerCountAllocator(KmerCountAllocator * obj); #define hard_link_KmerCountAllocator Wise2_hard_link_KmerCountAllocator /* Function: KmerCountAllocator_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerCountAllocator *] * */ KmerCountAllocator * Wise2_KmerCountAllocator_alloc(void); #define KmerCountAllocator_alloc Wise2_KmerCountAllocator_alloc /* Function: free_KmerCountAllocator(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerCountAllocator *] * * Return [UNKN ] Undocumented return value [KmerCountAllocator *] * */ KmerCountAllocator * Wise2_free_KmerCountAllocator(KmerCountAllocator * obj); #define free_KmerCountAllocator Wise2_free_KmerCountAllocator /* Unplaced functions */ /* There has been no indication of the use of these functions */ KmerCount * Wise2_new_KmerCount_KmerCountAllocator(KmerCountAllocator * kca); #define new_KmerCount_KmerCountAllocator Wise2_new_KmerCount_KmerCountAllocator KmerCountAllocator * Wise2_new_KmerCountAllocator(void); #define new_KmerCountAllocator Wise2_new_KmerCountAllocator /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_KmerCountAllocator(KmerCountBlock ** list,int i,int j) ; #define swap_KmerCountAllocator Wise2_swap_KmerCountAllocator void Wise2_qsort_KmerCountAllocator(KmerCountBlock ** list,int left,int right,int (*comp)(KmerCountBlock * ,KmerCountBlock * )); #define qsort_KmerCountAllocator Wise2_qsort_KmerCountAllocator void Wise2_sort_KmerCountAllocator(KmerCountAllocator * obj,int (*comp)(KmerCountBlock *, KmerCountBlock *)); #define sort_KmerCountAllocator Wise2_sort_KmerCountAllocator boolean Wise2_expand_KmerCountAllocator(KmerCountAllocator * obj,int len); #define expand_KmerCountAllocator Wise2_expand_KmerCountAllocator #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/kmer_direct.dy0000644000175000001440000000340607715704035017273 0ustar philippusers %{ #include "kmer_index_interface.h" typedef struct KmerDirectIndex { void ** index; kmer_t index_length; } KmerDirectIndex; %} %{ #include "kmer_direct.h" KmerIndexInterface * new_KmerDirectIndex(int kmer_size) { KmerIndexInterface * out; KmerDirectIndex * kdi; kmer_t len = 1; int i; for(i=0;iindex = calloc(len,sizeof(void*)); if( kdi->index == NULL ) { warn("could not build index of size %lld pointers\n",len); return NULL; } kdi->index_length = len; out = malloc(sizeof(KmerIndexInterface)); out->retrieve_by_kmer = retrieve_by_kmer_KmerDirectIndex; out->insert_by_kmer = insert_by_kmer_KmerDirectIndex; out->free_handle = free_KmerDirectIndex; out->next_filled_kmer = next_filled_kmer_KmerDirectIndex; out->handle = (void*) kdi; out->kmer_size = kmer_size; return out; } kmer_t next_filled_kmer_KmerDirectIndex(void * handle,kmer_t kmer) { KmerDirectIndex * ind = (KmerDirectIndex*) handle; assert(ind); for(kmer++;kmer < ind->index_length;kmer++) { if( ind->index[kmer] != NULL ) { return kmer; } } return -1; } void * retrieve_by_kmer_KmerDirectIndex(void * handle,kmer_t kmer) { KmerDirectIndex * ind = (KmerDirectIndex*) handle; assert(ind != NULL); assert(kmer < ind->index_length); return ind->index[kmer]; } boolean insert_by_kmer_KmerDirectIndex(void * handle,kmer_t kmer,void * poi) { KmerDirectIndex * in = (KmerDirectIndex*) handle; assert(in != NULL); assert(kmer < in->index_length); in->index[kmer] = poi; return TRUE; } void free_KmerDirectIndex(void * handle) { KmerDirectIndex * in = (KmerDirectIndex*) handle; assert(in); free(in->index); free(in); return; } wise-2.4.1/src/dnaindex/test_linkindex.c0000644000175000001440000000176107637404143017637 0ustar philippusers#include "linkindex.h" int main(int argc,char ** argv) { char buffer[MAXLINE]; Sequence * in; DnaNumberSequence * dns; LinkNumberArray * lna; LinkNumberArrayDebug lnad; int i; lnad.placement_stream = 10; lnad.add_stream = 10; lnad.extraction = 10; lnad.ofp = stderr; lna = new_LinkNumberArray(11); while( (in = read_fasta_Sequence(stdin)) != NULL ) { dns = new_DnaNumberSequence(in,11); if( is_new_stream_LinkNumberArray(lna,&lnad,dns) == TRUE ) { write_new_LinkStream(lna,&lnad,dns); } else { write_existing_LinkStream(lna,&lnad,dns); } } for(i=0;iarray_len;i++) { if( lna->array[i] != NULL && (lna->array[i]->stream[0]->a == NULL || lna->array[i]->stream[0]->b == NULL) && lna->array[i]->stream[0]->have_seen == 0 ) { in = extract_dna_LinkStream(lna->array[i]->stream[0],&lnad,lna->nmer_size); sprintf(buffer,"Sequence_%d",i); in->name = stringalloc(buffer); write_fasta_Sequence(in,stdout); } } } wise-2.4.1/src/dnaindex/kmer_hash.c0000644000175000001440000001772510670453716016564 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "kmer_hash.h" static int crc_table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; # line 95 "kmer_hash.dy" int crc32(int crc, const char *buf, int len) { if (buf == NULL) return 0; crc = crc ^ 0xffffffff; while(len--){ crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); } return crc ^ 0xffffffff; } # line 108 "kmer_hash.dy" KmerIndexInterface * new_KmerHashIndex(int kmer_size) { KmerIndexInterface * out; KmerHashIndex * khi; khi = malloc(sizeof(KmerHashIndex)); khi->bucket = calloc(KMER_HASH_BUCKETS,sizeof(KmerHashBucket)); if( khi->bucket == NULL ) { warn("could not allocate hash table of size %ld\n",KMER_HASH_BUCKETS); return NULL; } khi->min_kmer = 0xffffffff; khi->max_kmer = 0x00000000; out = malloc(sizeof(KmerIndexInterface)); out->retrieve_by_kmer = retrieve_by_kmer_KmerHashIndex; out->insert_by_kmer = insert_by_kmer_KmerHashIndex; out->free_handle = free_KmerHashIndex; out->next_filled_kmer = next_filled_kmer_KmerHashIndex; out->handle = (void*) khi; out->kmer_size = kmer_size; return out; } # line 140 "kmer_hash.dy" kmer_t hash_kmer(kmer_t kmer) { kmer_t hash = kmer; /* kmer >>= 24; hash ^= kmer; */ /* kmer <<= 5; hash ^= kmer; kmer <<= 5; hash ^= kmer; kmer <<= 5; hash ^= kmer; kmer <<= 5; hash ^= kmer; kmer <<= 5; hash ^= kmer; */ /* kmer >>= 28; hash ^= kmer; */ hash = crc32(0, (char*)&kmer, sizeof(kmer_t)); hash &= KMER_HASH_MASK; return hash; } # line 174 "kmer_hash.dy" void * retrieve_by_kmer_KmerHashIndex(void * handle,kmer_t kmer) { kmer_t hashval = hash_kmer(kmer); KmerHashIndex *khi = (KmerHashIndex*) handle; KmerHashBucket *khb; int i; assert(khi); khb = &khi->bucket[hashval]; if(!khb->index) return NULL; for(i = 0; i < khb->length; ++i){ if(khb->kmer[i] == kmer){ return khb->index[i]; } } return NULL; } # line 196 "kmer_hash.dy" kmer_t next_filled_kmer_KmerHashIndex(void * handle,kmer_t kmer) { kmer_t hashval; KmerHashIndex *khi = (KmerHashIndex*) handle; KmerHashBucket *khb; int i; assert(khi); /* starting bucket */ if( kmer == -1 ) { for(i=0;ibucket[i].index != NULL ) { return khi->bucket[i].kmer[0]; } } } /* else we've got a real one */ hashval = hash_kmer(kmer); khb = &khi->bucket[hashval]; assert(khb != NULL); for(i=0;ilength;i++) { if( kmer == khb->kmer[i] ) { break; } } /* as we give out these numbers, they must be here! */ assert(i < khb->length); if( i+1 == khb->length ) { /* next hashval needed */ for(i=hashval+1;ibucket[i].index != NULL ) { return khi->bucket[i].kmer[0]; } } /* out of buckets - return -1 */ return -1; } else { /* return next position in this bucket */ return khb->kmer[i+1]; } } # line 247 "kmer_hash.dy" boolean insert_by_kmer_KmerHashIndex(void * handle,kmer_t kmer,void * poi) { kmer_t hashval = hash_kmer(kmer); KmerHashIndex *khi = (KmerHashIndex*) handle; KmerHashBucket *khb; int i; assert(khi); if(kmer > khi->max_kmer) khi->max_kmer = kmer; if(kmer < khi->min_kmer) khi->min_kmer = kmer; khb = &khi->bucket[hashval]; if(khb->index == NULL){ khb->index = (void**)malloc(sizeof(void*)*8); if(khb->index == NULL){ fprintf(stderr, "Out of memory\n"); exit(1); } khb->kmer = (kmer_t*)malloc(sizeof(kmer_t)*8); if(khb->kmer == NULL){ fprintf(stderr, "Out of memory\n"); exit(1); } khb->buflen = 8; } if(khb->length >= khb->buflen){ khb->index = (void**)realloc(khb->index, sizeof(void*)*(khb->buflen*2)); if(khb->index == NULL){ fprintf(stderr, "Out of memory\n"); exit(1); } khb->kmer = (kmer_t*)realloc(khb->kmer, sizeof(kmer_t)*(khb->buflen*2)); if(khb->kmer == NULL){ fprintf(stderr, "Out of memory\n"); exit(1); } khb->buflen *= 2; } khb->kmer[khb->length] = kmer; khb->index[khb->length] = poi; khb->length++; return TRUE; } # line 296 "kmer_hash.dy" void free_KmerHashIndex(void * handle) { int i; int lenhist[10]; KmerHashIndex *khi = (KmerHashIndex*) handle; KmerHashBucket *khb; assert(khi); for(i = 0; i < 10; ++i) lenhist[i] = 0; for(i = 0; i < KMER_HASH_BUCKETS; ++i){ khb = &khi->bucket[i]; if(khb->length >= 10){ lenhist[9]++; } else { lenhist[khb->length]++; } if(khb->index) free(khb->index); if(khb->kmer) free(khb->kmer); } free(khi->bucket); fprintf(stderr, "min_kmer: %016lx\n", khi->min_kmer); fprintf(stderr, "max_kmer: %016lx\n", khi->max_kmer); free(khi); for(i = 0; i < 9; ++i){ fprintf(stderr, "%2d:%8d\n", i, lenhist[i]); } fprintf(stderr, "9+:%8d\n", lenhist[9]); return; } # line 305 "kmer_hash.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/kmer_hash.h0000644000175000001440000000375510670453716016567 0ustar philippusers#ifndef DYNAMITEkmer_hashHEADERFILE #define DYNAMITEkmer_hashHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "kmer_index_interface.h" #define KMER_HASH_BITS 24 #define KMER_HASH_MASK 0x0000000000ffffffL #define KMER_HASH_BUCKETS 16777216 /* #define KMER_HASH_BITS 28 #define KMER_HASH_MASK 0x000000000fffffffL #define KMER_HASH_BUCKETS (16777216*16) */ typedef struct KmerHashBucket { void **index; kmer_t *kmer; int length; int buflen; } KmerHashBucket; typedef struct KmerHashIndex { KmerHashBucket *bucket; kmer_t min_kmer; kmer_t max_kmer; } KmerHashIndex; /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Unplaced functions */ /* There has been no indication of the use of these functions */ int Wise2_crc32(int crc, const char *buf, int len); #define crc32 Wise2_crc32 KmerIndexInterface * Wise2_new_KmerHashIndex(int kmer_size); #define new_KmerHashIndex Wise2_new_KmerHashIndex kmer_t Wise2_hash_kmer(kmer_t kmer); #define hash_kmer Wise2_hash_kmer void * Wise2_retrieve_by_kmer_KmerHashIndex(void * handle,kmer_t kmer); #define retrieve_by_kmer_KmerHashIndex Wise2_retrieve_by_kmer_KmerHashIndex kmer_t Wise2_next_filled_kmer_KmerHashIndex(void * handle,kmer_t kmer); #define next_filled_kmer_KmerHashIndex Wise2_next_filled_kmer_KmerHashIndex boolean Wise2_insert_by_kmer_KmerHashIndex(void * handle,kmer_t kmer,void * poi); #define insert_by_kmer_KmerHashIndex Wise2_insert_by_kmer_KmerHashIndex void Wise2_free_KmerHashIndex(void * handle); #define free_KmerHashIndex Wise2_free_KmerHashIndex /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/kmer_assembly_untangler.c0000644000175000001440000006301010670453716021523 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "kmer_assembly_untangler.h" # line 38 "kmer_assembly_untangler.dy" void show_KmerAssemblyPath(KmerAssemblyIndex * kai,KmerAssemblyPath * kap,FILE * ofp) { int i; char forw[512]; char back[512]; for(i=0;istack_len;i++) { reverse_map_dna_number(kap->stack[i]->prev->number,kai->kii->kmer_size,back); reverse_map_dna_number(kap->stack[i]->next->number,kai->kii->kmer_size,forw); back[kai->kii->kmer_size] ='\0'; forw[kai->kii->kmer_size] ='\0'; fprintf(ofp,"%3d memory %d, from [%s] to [%s], base %c\n",i,(int)kap->stack[i],back,forw,kap->stack[i]->base); } } # line 58 "kmer_assembly_untangler.dy" void push_KmerAssemblyPath(KmerAssemblyPath * kap,KmerAssemblyLink * kal) { assert(kap != NULL); assert(kal != NULL); if( kap->stack_len >= kap->max_stack) { fatal("Bugger it. Max stack over flow, could be made growable. Complain to Ewan... ;)"); } kap->stack[kap->stack_len++] = kal; } # line 71 "kmer_assembly_untangler.dy" KmerAssemblyLink * pop_KmerAssemblyPath(KmerAssemblyPath * kap) { assert(kap != NULL); if( kap->stack_len <= 0 ) { return NULL; } return kap->stack[kap->stack_len--]; } # line 81 "kmer_assembly_untangler.dy" KmerAssemblyPath * new_KmerAssemblyPath(void) { KmerAssemblyPath * out; out = KmerAssemblyPath_alloc(); out->stack = (KmerAssemblyLink**) calloc(KmerAssemblyPath_MAX_STACK,sizeof(KmerAssemblyLink*)); out->stack_len = 0; out->max_stack = KmerAssemblyPath_MAX_STACK; return out; } # line 95 "kmer_assembly_untangler.dy" int untangle_KmerAssembly(KmerAssemblyIndex * kai) { int total = 0; int i; kmer_t kmer; KmerAssemblyNode * node; KmerAssemblyLink * link_set[1024]; int node_len; char buffer[256]; int fully_untangled = 0; assert(kai != NULL); assert(kai->kii != NULL ); assert(kai->kii->next_filled_kmer != NULL); kmer = -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer); for(;kmer != -1; kmer = (*kai->kii->next_filled_kmer)(kai->kii->handle,kmer)) { node = (*kai->kii->retrieve_by_kmer)(kai->kii->handle,kmer); if( node->next_len > 1 || node->prev_len > 1 ) { reverse_map_dna_number(node->number,kai->kii->kmer_size,buffer); buffer[kai->kii->kmer_size] = '\0'; fprintf(stderr,"TANGLE: Node %ld, %s has forward %d and back %d links\n",node->number,buffer,node->next_len,node->prev_len); } if( node->prev_len < 2 ) { continue; } if( node->prev_len > 1024 ) { fatal("Insane - over 1024 possible back links, can't cope"); } /* we have to put this into temporary memory*/ for(i=0;iprev_len;i++) { link_set[i] = node->prev[i]; } node_len = node->prev_len; for(i=0;iprev[i]->prev->number,node->number); if( attempt_forward_untangle_KmerAssembly(kai,node->prev[i],500) == TRUE ) { total++; if( node->prev_len == 1 ) { fully_untangled = 1; /* fully untangled on left hand side. Assumme is ok on right side? * break this loop */ break; } } } reverse_map_dna_number(node->number,kai->kii->kmer_size,buffer); buffer[kai->kii->kmer_size] = '\0'; if( fully_untangled == 1 ) { fprintf(stderr,"RESOLVED: Node %ld [%s] Fully untangled now...\n",node->number,buffer); } else { fprintf(stderr,"UNRESOLVED: Node %ld [%s] still tangled...\n",node->number,buffer); } } return total; } # line 171 "kmer_assembly_untangler.dy" boolean recursive_untangle_KmerAssembly(KmerTangleResolver * res,KmerAssemblyIndex * kai,KmerAssemblyLink * current,KmerAssemblyPath * p,int current_pos) { KmerAssemblyLink * temp_link[500]; int start_pos = current_pos; int j; int i; while( 1 ) { if( current_pos > res->max_path ) { return FALSE; } /* belts and braces; should never reach here */ if( current == NULL || current->next == NULL ) { warn("Belt and braces test to ensure no path overrun"); return FALSE; } /* if the link is simple, just move along. We might want to check all labels are still valid in here to find right tails */ /* no matter what the next decision is, this position is on the valid path. push into the temporary array */ temp_link[current_pos] = current; current_pos++; if( current->next->next_len == 1 ) { /* check that this is not a buried tail */ if( no_longer_active_KmerTangleResolver(res,current,current_pos) == TRUE ) { p->right_tail = TRUE; break; } current = current->next->next[0]; continue; } /* if is the end of this path, must be false */ if( current->next->next_len == 0 ) { return FALSE; } fprintf(stderr,"Looking at split node with %d outgoing paths\n",current->next->next_len); /* for each possible link out */ for(j=0;jnext->next_len;j++) { assert(current->next->next[j] != NULL); if( is_righthand_link_KmerTangleResolver(res,current->next->next[j],current_pos-1) == TRUE ) { fprintf(stderr,"Is valid!\n"); temp_link[current_pos] = current->next->next[j]; current_pos++; break; } } /* if j < length, then we have a valid rightside */ if( j < current->next->next_len ) { break; } /* no links are possible; recurse down links */ for(j=0;jnext->next_len;j++) { assert(current->next->next[j] != NULL); if( recursive_untangle_KmerAssembly(res,kai,current->next->next[j],p,current_pos) == TRUE ) { break; } } if( j < current->next->next_len ) { break; } else { /* done all possible recursions, return FALSE */ return FALSE; } } /* path is true; fill up path and return */ if( p->max_stack < current_pos ) { fatal("Path overflow, just need to extend data here. Talk to Ewan"); } if( p->stack_len < current_pos ) { p->stack_len = current_pos; } /* this puts the temporary links into the path structure for final use */ for(i=start_pos;istack[i] = temp_link[i]; } return TRUE; } # line 272 "kmer_assembly_untangler.dy" KmerTangleResolver * new_KmerTangleResolver(KmerAssemblyIndex * kai,KmerAssemblyLink * leftmost,int max_path) { int i; KmerTangleResolver * out; if( leftmost->sequence_label_len > MAX_TANGLE_DEPTH ) { fatal("We need to move to dynamic memory for tangle resolver, have depth of %d\n",leftmost->sequence_label_len); } out = KmerTangleResolver_alloc(); out->max_end = 0; for(i=0;isequence_label_len;i++) { out->start_label[i] = leftmost->sequence_label[i]; out->start_pos[i] = lookup_Sequence_SinglePosSpace(kai->sps,leftmost->sequence_label[i]); out->distance_to_end[i] = ((Sequence*)out->start_pos[i]->data)->len - ((int)(out->start_label[i] - out->start_pos[i]->start)); if( out->distance_to_end[i] > out->max_end ) { out->max_end = out->distance_to_end[i]; } } out->label_len = leftmost->sequence_label_len; out->max_path = max_path; return out; } # line 301 "kmer_assembly_untangler.dy" boolean no_longer_active_KmerTangleResolver(KmerTangleResolver * res,KmerAssemblyLink * current,int pathlen) { int i; int j; for(i=0;ilabel_len;i++) { for(j=0;jsequence_label_len;j++) { fprintf(stderr,"Comparing %ld to %ld (%d)\n",res->start_label[i]+pathlen,current->sequence_label[j]+1,pathlen); if( res->start_label[i]+pathlen == current->sequence_label[j]+1 ) { fprintf(stderr,"...returning FALSE...\n"); return FALSE; } } } fprintf(stderr,"Inactive Resolver!\n"); return TRUE; } # line 321 "kmer_assembly_untangler.dy" boolean is_righthand_link_KmerTangleResolver(KmerTangleResolver * res,KmerAssemblyLink * rightside,int pathlen) { int i; int j; int start_label_ok[MAX_TANGLE_DEPTH]; assert(res->label_len < MAX_TANGLE_DEPTH); assert(rightside->sequence_label_len < MAX_TANGLE_DEPTH); /* have to find all transfered links */ for(i=0;ilabel_len;i++) { if( pathlen + res->start_label[i] >= res->start_pos[i]->start + ((Sequence*)(res->start_pos[i])->data)->len ) { start_label_ok[i] = 0; } else { start_label_ok[i] = -1; } } for(j=0;jsequence_label_len;j++) { for(i=0;ilabel_len;i++) { if( rightside->sequence_label[j] - res->start_label[i] == pathlen+1 ) { start_label_ok[i] = 1; break; } } } for(i=0;ilabel_len;i++) { if( start_label_ok[i] == -1 ) { return FALSE; } } return TRUE; } # line 360 "kmer_assembly_untangler.dy" boolean attempt_forward_untangle_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyLink * left_input,int max_search) { KmerAssemblyPath * path; KmerAssemblyPath * newpath; KmerTangleResolver * kres; boolean ret = FALSE; path = new_KmerAssemblyPath(); kres = new_KmerTangleResolver(kai,left_input,max_search); if( recursive_untangle_KmerAssembly(kres,kai,left_input,path,0) == TRUE ) { ret = TRUE; fprintf(stderr,"Successful untangling...\n"); show_KmerAssemblyPath(kai,path,stderr); if( path->right_tail == TRUE ) { lift_forward_tangled_tail(kai,path,kres->start_label,kres->label_len); } else { newpath = lift_forward_tangled_KmerAssemblyPath(kai,path,kres->start_label,kres->label_len); } } fprintf(stderr,"returning from attempt\n"); free_KmerAssemblyPath(path); free_KmerAssemblyPath(newpath); free_KmerTangleResolver(kres); return ret; } # line 392 "kmer_assembly_untangler.dy" boolean old_attempt_forward_untangle_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyLink * left_input,int max_search) { int i; int j; int k,l; int have_link; long int start_label[MAX_TANGLE_DEPTH]; long int end_label[MAX_TANGLE_DEPTH]; SinglePosSequence * start_pos[MAX_TANGLE_DEPTH]; SinglePosSequence * end_pos[MAX_TANGLE_DEPTH]; char buffer[128]; int start_len; int end_len; int pathlen = 0; long int transferred_label[MAX_TANGLE_DEPTH]; SinglePosSequence * transferred_pos[MAX_TANGLE_DEPTH]; int transferred_len; KmerAssemblyLink * current; KmerAssemblyPath * path; KmerAssemblyPath * newpath; assert(kai != NULL); assert(left_input != NULL); if( left_input->sequence_label_len > MAX_TANGLE_DEPTH ) { fatal("Ach, bugger it, overflow on fixed buffer length for forward untangle. Easily fixed; talk to Ewan"); } for(i=0;isequence_label_len;i++) { start_pos[i] = lookup_Sequence_SinglePosSpace(kai->sps,left_input->sequence_label[i]); start_label[i] = left_input->sequence_label[i]; } start_len = left_input->sequence_label_len; reverse_map_dna_number(left_input->next->number,kai->kii->kmer_size,buffer); buffer[kai->kii->kmer_size] = '\0'; fprintf(stderr,"Entering mapping code with %s depth %d\n",buffer,left_input->sequence_label_len); path = new_KmerAssemblyPath(); push_KmerAssemblyPath(path,left_input); for(pathlen=0,current = left_input;current != NULL && pathlen < max_search;) { fprintf(stderr,"looking at node %ld with path length %d, next length %d depth %d\n",current->next->number,pathlen,current->next->next_len,current->sequence_label_len); assert(current->next != NULL); if( current->next->next_len == 1 ) { pathlen++; current = current->next->next[0]; push_KmerAssemblyPath(path,current); continue; } if( current->next->next_len == 0 ) { return FALSE; } fprintf(stderr,"Looking at split out node %d, %d\n",current->next->next_len,pathlen); /* > 1, so should have our paths somewhere in here */ /* pull out exit sps... */ for(j=0;jnext->next_len;j++) { assert(current->next->next[j] != NULL); fprintf(stderr,"... paths are of size %d\n",pathlen); if( current->next->next[j]->sequence_label_len > MAX_TANGLE_DEPTH ) { warn("YIKES... unable to untangle, because over Max tangle depth, at %d\n",current->next->next[j]->sequence_label_len); return FALSE; } for(i=0;inext->next[j]->sequence_label_len;i++) { end_pos[i] = lookup_Sequence_SinglePosSpace(kai->sps,current->next->next[j]->sequence_label[i]); end_label[i] = current->next->next[j]->sequence_label[i]; } end_len = current->next->next[j]->sequence_label_len; transferred_len =0; have_link = 0; /* match pos to proposed, set labels to -1 when matched */ for(l=0;lnext->next[j]); newpath = lift_forward_tangled_KmerAssemblyPath(kai,path,transferred_label,transferred_len); /* we should check if we have any tails */ transferred_len = 0; have_link = 0; for(l=0;lkii->kmer_size,start_pos[l]->start,((Sequence*)start_pos[l]->data)->len); */ if( start_label[l] + pathlen + kai->kii->kmer_size > start_pos[l]->start + ((Sequence*)start_pos[l]->data)->len ) { /* yup, got a tail */ /* fprintf(stderr,"Got a tail label...\n"); */ transferred_label[transferred_len] = start_label[l]; transferred_pos[transferred_len] = start_pos[l]; transferred_len++; have_link = 1; } } if( have_link == 1 ) { /* fprintf(stderr," ..forward TAIL.. untangling...\n"); */ fatal("Duff function!"); } transferred_len = 0; have_link = 0; for(l=0;lstart ) { /* yup, got a tail */ transferred_label[transferred_len] = end_label[l]; transferred_pos[transferred_len] = end_pos[l]; transferred_len++; have_link = 1; } } if( have_link == 1 ) { /* fprintf(stderr," ..reverse TAIL.. untangling...\n"); */ lift_backward_tangled_tail(kai,newpath->stack[newpath->stack_len-1],path,transferred_label,transferred_pos,transferred_len); } /* pop off the top of this path */ pop_KmerAssemblyPath(path); free_KmerAssemblyPath(newpath); } /* fprintf(stderr,"Left input between %ld and %ld has depth %d\n",left_input->prev->number,left_input->next->number,left_input->sequence_label_len);*/ /* main loop around links; test whether starting link is empty */ if( left_input->sequence_label_len <= 0 ) { return TRUE; } /* currently we can't handle overbranching */ fprintf(stderr,"Currently we can't handle over-branching; returning FALSE...\n"); return FALSE; } return FALSE; } # line 599 "kmer_assembly_untangler.dy" void lift_forward_tangled_tail(KmerAssemblyIndex * kai,KmerAssemblyPath * tail,long int * start_label,int label_len) { int i; int j; KmerAssemblyNode * prev; KmerAssemblyLink * link; KmerAssemblyNode * new_node; assert(kai != NULL); assert(tail != NULL); assert(start_label != NULL); assert(label_len > 0); prev = tail->stack[0]->prev; for(i=0;istack_len;i++) { if( i+1 != tail->stack_len ) { new_node = new_KmerAssemblyNode(tail->stack[i]->next->number); new_node->node_chain = tail->stack[i]->next->node_chain; tail->stack[i]->next->node_chain = new_node; } else { new_node = NULL; } link = new_KmerAssemblyLink(tail->stack[i]->base); add_next_KmerAssemblyNode(prev,link); if( new_node != NULL) { add_prev_KmerAssemblyNode(new_node,link); } link->prev = prev; link->next = new_node; for(j=0;jstack[i],start_label[j]+i); add_sequence_label_KmerAssemblyLink(link,start_label[j]+i); } if( tail->stack[i]->sequence_label_len == 0 ) { /* detach link */ remove_next_KmerAssemblyNode(tail->stack[i]->prev,tail->stack[i]); remove_prev_KmerAssemblyNode(tail->stack[i]->next,tail->stack[i]); } prev = new_node; } return; } # line 660 "kmer_assembly_untangler.dy" void lift_backward_tangled_tail(KmerAssemblyIndex * kai,KmerAssemblyLink * new,KmerAssemblyPath * tail,int * start_label,SinglePosSequence ** positions,int label_len) { int i; int j; int k; assert(kai != NULL); assert(new != NULL); assert(tail != NULL); assert(start_label != NULL); assert(label_len > 0); i=0; k=0; while( 1) { /* check we have things to do */ for(j=0;j= positions[j]->start ) { break; } } if( j >= label_len ) { break; } /* lift out active sequences */ for(j=0;j= positions[j]->start ) { remove_sequence_label_KmerAssemblyLink(tail->stack[k],start_label[j]-i); add_sequence_label_KmerAssemblyLink(new,start_label[j]-i); } } /* remove link if needed */ if( tail->stack[k]->sequence_label_len == 0 ) { detach_KmerAssemblyLink(kai,tail->stack[k]); } /* advance links */ if( new->prev->prev_len > 1 ) { warn("VERY VERY BAD NEWS: in lifting a backward tail, new stream has more than one path"); } new = new->prev->prev[0]; k++; i++; if( new->prev->number != tail->stack[k]->prev->number ) { warn("IMPOSSIBLE: error! in lifting backward tail, old stream and new stream differ in numbers"); return; } } /* finished lift */ } # line 717 "kmer_assembly_untangler.dy" KmerAssemblyPath * lift_forward_tangled_KmerAssemblyPath(KmerAssemblyIndex * kai,KmerAssemblyPath * kap,long int * start_label,int label_len) { int i,j; KmerAssemblyNode * new; KmerAssemblyNode * prev; KmerAssemblyLink * link; KmerAssemblyPath * out; char back[256]; char forw[256]; assert(kai != NULL); assert(kap != NULL); assert(start_label != NULL); assert(label_len > 0); out = new_KmerAssemblyPath(); prev = kap->stack[0]->prev; for(i=0;istack_len;i++) { reverse_map_dna_number(kap->stack[i]->prev->number,kai->kii->kmer_size,back); back[kai->kii->kmer_size] = '\0'; reverse_map_dna_number(kap->stack[i]->next->number,kai->kii->kmer_size,forw); forw[kai->kii->kmer_size] = '\0'; fprintf(stderr,"Moving stack position %d, depth %d, transfer %d, between %ld [%s] and %ld [%s]\n",i,kap->stack[i]->sequence_label_len,label_len,kap->stack[i]->prev->number,back,kap->stack[i]->next->number,forw); fprintf(stderr,"... Before transfer %d sequence labels and %d outgoing and %d incoming\n",kap->stack[i]->sequence_label_len,kap->stack[i]->prev->next_len,kap->stack[i]->next->prev_len); if( i+1 == kap->stack_len ) { /* last link --- has to be done differently as we attach it to the new place */ new = kap->stack[i]->next; } else { new = new_KmerAssemblyNode(kap->stack[i]->next->number); new->node_chain = kap->stack[i]->next->node_chain; kap->stack[i]->next->node_chain = new; } link = new_KmerAssemblyLink(kap->stack[i]->base); push_KmerAssemblyPath(out,link); add_next_KmerAssemblyNode(prev,link); add_prev_KmerAssemblyNode(new,link); link->prev = prev; link->next = new; for(j=0;jstack[i],start_label[j]+i); add_sequence_label_KmerAssemblyLink(link,start_label[j]+i); } if( kap->stack[i]->sequence_label_len == 0 ) { /* detach link */ remove_next_KmerAssemblyNode(kap->stack[i]->prev,kap->stack[i]); remove_prev_KmerAssemblyNode(kap->stack[i]->next,kap->stack[i]); fprintf(stderr,"...left with prev next_len %d and next prev_len %d\n",kap->stack[i]->prev->next_len,kap->stack[i]->next->prev_len); } else { fprintf(stderr,"...node is still live with %d sequence labels and %d outgoing and %d incoming\n",kap->stack[i]->sequence_label_len,kap->stack[i]->prev->next_len,kap->stack[i]->next->prev_len); } prev = new; } return out; } # line 781 "kmer_assembly_untangler.c" /* Function: hard_link_KmerAssemblyPath(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerAssemblyPath *] * * Return [UNKN ] Undocumented return value [KmerAssemblyPath *] * */ KmerAssemblyPath * hard_link_KmerAssemblyPath(KmerAssemblyPath * obj) { if( obj == NULL ) { warn("Trying to hard link to a KmerAssemblyPath object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: KmerAssemblyPath_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerAssemblyPath *] * */ KmerAssemblyPath * KmerAssemblyPath_alloc(void) { KmerAssemblyPath * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(KmerAssemblyPath *) ckalloc (sizeof(KmerAssemblyPath))) == NULL) { warn("KmerAssemblyPath_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->stack = NULL; out->stack_len = 0; out->max_stack = 0; out->right_tail = FALSE; out->left_tail = FALSE; return out; } /* Function: free_KmerAssemblyPath(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerAssemblyPath *] * * Return [UNKN ] Undocumented return value [KmerAssemblyPath *] * */ KmerAssemblyPath * free_KmerAssemblyPath(KmerAssemblyPath * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a KmerAssemblyPath obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->stack != NULL) ckfree(obj->stack); ckfree(obj); return NULL; } /* Function: hard_link_KmerTangleResolver(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerTangleResolver *] * * Return [UNKN ] Undocumented return value [KmerTangleResolver *] * */ KmerTangleResolver * hard_link_KmerTangleResolver(KmerTangleResolver * obj) { if( obj == NULL ) { warn("Trying to hard link to a KmerTangleResolver object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: KmerTangleResolver_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerTangleResolver *] * */ KmerTangleResolver * KmerTangleResolver_alloc(void) { KmerTangleResolver * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(KmerTangleResolver *) ckalloc (sizeof(KmerTangleResolver))) == NULL) { warn("KmerTangleResolver_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* start_label[MAX_TANGLE_DEPTH] is an array: no default possible */ /* distance_to_end[MAX_TANGLE_DEPTH] is an array: no default possible */ out->max_end = 0; out->label_len = 0; out->max_path = 0; return out; } /* Function: free_KmerTangleResolver(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerTangleResolver *] * * Return [UNKN ] Undocumented return value [KmerTangleResolver *] * */ KmerTangleResolver * free_KmerTangleResolver(KmerTangleResolver * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a KmerTangleResolver obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->start_pos[MAX_TANGLE_DEPTH] is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/kmer_assembly_untangler.h0000644000175000001440000001557010670453716021540 0ustar philippusers#ifndef DYNAMITEkmer_assembly_untanglerHEADERFILE #define DYNAMITEkmer_assembly_untanglerHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "kmer_assembly.h" #define KmerAssemblyPath_MAX_STACK 1024 #define MAX_TANGLE_DEPTH 10000 struct Wise2_KmerAssemblyPath { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif KmerAssemblyLink ** stack; int stack_len; int max_stack; boolean right_tail; boolean left_tail; } ; /* KmerAssemblyPath defined */ #ifndef DYNAMITE_DEFINED_KmerAssemblyPath typedef struct Wise2_KmerAssemblyPath Wise2_KmerAssemblyPath; #define KmerAssemblyPath Wise2_KmerAssemblyPath #define DYNAMITE_DEFINED_KmerAssemblyPath #endif struct Wise2_KmerTangleResolver { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif long start_label[MAX_TANGLE_DEPTH]; SinglePosSequence * start_pos[MAX_TANGLE_DEPTH]; int distance_to_end[MAX_TANGLE_DEPTH]; int max_end; int label_len; int max_path; } ; /* KmerTangleResolver defined */ #ifndef DYNAMITE_DEFINED_KmerTangleResolver typedef struct Wise2_KmerTangleResolver Wise2_KmerTangleResolver; #define KmerTangleResolver Wise2_KmerTangleResolver #define DYNAMITE_DEFINED_KmerTangleResolver #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_KmerAssemblyPath(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerAssemblyPath *] * * Return [UNKN ] Undocumented return value [KmerAssemblyPath *] * */ KmerAssemblyPath * Wise2_hard_link_KmerAssemblyPath(KmerAssemblyPath * obj); #define hard_link_KmerAssemblyPath Wise2_hard_link_KmerAssemblyPath /* Function: KmerAssemblyPath_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerAssemblyPath *] * */ KmerAssemblyPath * Wise2_KmerAssemblyPath_alloc(void); #define KmerAssemblyPath_alloc Wise2_KmerAssemblyPath_alloc /* Function: free_KmerAssemblyPath(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerAssemblyPath *] * * Return [UNKN ] Undocumented return value [KmerAssemblyPath *] * */ KmerAssemblyPath * Wise2_free_KmerAssemblyPath(KmerAssemblyPath * obj); #define free_KmerAssemblyPath Wise2_free_KmerAssemblyPath /* Function: hard_link_KmerTangleResolver(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [KmerTangleResolver *] * * Return [UNKN ] Undocumented return value [KmerTangleResolver *] * */ KmerTangleResolver * Wise2_hard_link_KmerTangleResolver(KmerTangleResolver * obj); #define hard_link_KmerTangleResolver Wise2_hard_link_KmerTangleResolver /* Function: KmerTangleResolver_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [KmerTangleResolver *] * */ KmerTangleResolver * Wise2_KmerTangleResolver_alloc(void); #define KmerTangleResolver_alloc Wise2_KmerTangleResolver_alloc /* Function: free_KmerTangleResolver(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [KmerTangleResolver *] * * Return [UNKN ] Undocumented return value [KmerTangleResolver *] * */ KmerTangleResolver * Wise2_free_KmerTangleResolver(KmerTangleResolver * obj); #define free_KmerTangleResolver Wise2_free_KmerTangleResolver /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_show_KmerAssemblyPath(KmerAssemblyIndex * kai,KmerAssemblyPath * kap,FILE * ofp); #define show_KmerAssemblyPath Wise2_show_KmerAssemblyPath void Wise2_push_KmerAssemblyPath(KmerAssemblyPath * kap,KmerAssemblyLink * kal); #define push_KmerAssemblyPath Wise2_push_KmerAssemblyPath KmerAssemblyLink * Wise2_pop_KmerAssemblyPath(KmerAssemblyPath * kap); #define pop_KmerAssemblyPath Wise2_pop_KmerAssemblyPath KmerAssemblyPath * Wise2_new_KmerAssemblyPath(void); #define new_KmerAssemblyPath Wise2_new_KmerAssemblyPath int Wise2_untangle_KmerAssembly(KmerAssemblyIndex * kai); #define untangle_KmerAssembly Wise2_untangle_KmerAssembly boolean Wise2_recursive_untangle_KmerAssembly(KmerTangleResolver * res,KmerAssemblyIndex * kai,KmerAssemblyLink * current,KmerAssemblyPath * p,int current_pos); #define recursive_untangle_KmerAssembly Wise2_recursive_untangle_KmerAssembly KmerTangleResolver * Wise2_new_KmerTangleResolver(KmerAssemblyIndex * kai,KmerAssemblyLink * leftmost,int max_path); #define new_KmerTangleResolver Wise2_new_KmerTangleResolver boolean Wise2_no_longer_active_KmerTangleResolver(KmerTangleResolver * res,KmerAssemblyLink * current,int pathlen); #define no_longer_active_KmerTangleResolver Wise2_no_longer_active_KmerTangleResolver boolean Wise2_is_righthand_link_KmerTangleResolver(KmerTangleResolver * res,KmerAssemblyLink * rightside,int pathlen); #define is_righthand_link_KmerTangleResolver Wise2_is_righthand_link_KmerTangleResolver boolean Wise2_attempt_forward_untangle_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyLink * left_input,int max_search); #define attempt_forward_untangle_KmerAssembly Wise2_attempt_forward_untangle_KmerAssembly boolean Wise2_old_attempt_forward_untangle_KmerAssembly(KmerAssemblyIndex * kai,KmerAssemblyLink * left_input,int max_search); #define old_attempt_forward_untangle_KmerAssembly Wise2_old_attempt_forward_untangle_KmerAssembly void Wise2_lift_forward_tangled_tail(KmerAssemblyIndex * kai,KmerAssemblyPath * tail,long int * start_label,int label_len); #define lift_forward_tangled_tail Wise2_lift_forward_tangled_tail void Wise2_lift_backward_tangled_tail(KmerAssemblyIndex * kai,KmerAssemblyLink * new,KmerAssemblyPath * tail,int * start_label,SinglePosSequence ** positions,int label_len); #define lift_backward_tangled_tail Wise2_lift_backward_tangled_tail KmerAssemblyPath * Wise2_lift_forward_tangled_KmerAssemblyPath(KmerAssemblyIndex * kai,KmerAssemblyPath * kap,long int * start_label,int label_len); #define lift_forward_tangled_KmerAssemblyPath Wise2_lift_forward_tangled_KmerAssemblyPath /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/dnamapping.dy0000644000175000001440000000572210413710424017110 0ustar philippusers %{ #include "dyna.h" /*typedef long int kmer_t;*/ typedef long long kmer_t; struct lexical_kmer { kmer_t kmer; char lexical_forward; }; %} %{ #include "dnamapping.h" char * map_to_basepair_numbers(char * seq,long int len) { long int i; char * out; out = calloc(len,sizeof(char)); for(i=0;i= 0;i--) { base_number[i] = number / base; number -= base*base_number[i]; base = base / 4; } base = 1; total = 0; for(i=0;i= 0;i--) { no = number / base; buffer[i] = char_from_base(no); number -= base*no; base = base / 4; } return; } char lexical_last_base_from_kmer(kmer_t kmer,int kmer_size,int lexical_for) { int i; kmer_t base = 1; int last_base; if( lexical_for == 1) { for(i=0;i 0); for(i=0;i rev_buffer[i] ) { out.lexical_forward = 1; break; } if( for_buffer[i] < rev_buffer[i] ) { out.lexical_forward = 0; break; } } temp = 0; base = 1; if( out.lexical_forward == 1 ) { for(i=0;iextraction != 0 ) { fprintf(lnad->ofp,"Extracting DNA from linkstream %d\n",ln); } ln->have_seen = 1; if( ln->a == NULL ) { if( ln->b->x == ln ) { runner = ln->b->y; } else { runner = ln->b->x; } } else { if( ln->a->x == ln ) { runner = ln->a->y; } else { runner = ln->a->x; } } prev = ln; while( runner != NULL ) { /* to find the outgoing link from here, test neither a nor b is not NULL and figure out the right way to go from the fact that the link is back to ourselves */ if( runner->a == NULL || runner->b == NULL ) { /* other end of stream */ break; } runner->have_seen = 1; i++; if( lnad->extraction > 2 ) { fprintf(lnad->ofp,"Extracting DNA from linkstream %d, runner %d, position count %d\n",ln,runner,i); } if( runner->a->x == runner && runner->a->y != prev) { next = runner->a->y; } else if ( runner->a->y == runner && runner->a->x != prev ) { next = runner->a->x; } else if( runner->b->x == runner && runner->b->y != prev) { next = runner->b->y; } else if ( runner->b->y == runner && runner->b->x != prev ) { next = runner->b->x; } else { fatal("Unable to move off edge!"); } prev = runner; runner = next; } out = Sequence_alloc(); out->seq = calloc(i+1,sizeof(char)); i = 0; flipped = ln->starting_flip; if( ln->a == NULL ) { out->seq[0] = first_char_from_dnanumber(ln->number,nmer_size,flipped); } else { /* b is NULL, indicating a 3' end of a sequence, so flip the flip*/ out->seq[0] = first_char_from_dnanumber(ln->number,nmer_size,!flipped); } if( ln->a == NULL ) { if( ln->b->x == ln ) { runner = ln->b->y; } else { runner = ln->b->x; } if( ln->b->twist == 1 ) { flipped = !flipped; } } else { if( ln->a->x == ln ) { runner = ln->a->y; } else { runner = ln->a->x; } /* as b is always on the reverse strand, invert the flipped sense as we read down it*/ if( ln->a->twist == 0 ) { flipped = !flipped; } } prev = ln; i++; while( runner != NULL ) { /* to find the outgoing link from here, test neither a nor b is not NULL and figure out the right way to go from the fact that the link is back to ourselves */ if( runner->a == NULL || runner->b == NULL ) { /* other end of stream */ break; } out->seq[i] = first_char_from_dnanumber(runner->number,nmer_size,flipped); i++; if( runner->a->x == runner && runner->a->y != prev) { next = runner->a->y; if( runner->a->twist == 1 ) { flipped = !flipped; } } else if ( runner->a->y == runner && runner->a->x != prev ) { next = runner->a->x; if( runner->a->twist == 1 ) { flipped = !flipped; } } else if( runner->b->x == runner && runner->b->y != prev) { next = runner->b->y; if( runner->b->twist == 1 ) { flipped = !flipped; } } else if ( runner->b->y == runner && runner->b->x != prev ) { next = runner->b->x; if( runner->b->twist == 1 ) { flipped = !flipped; } } else { fatal("Unable to move off edge!"); } prev = runner; runner = next; } runner->have_seen = 1; return out; } /* Function: write_existing_LinkStream(lna,lnad,dns) * * Descrip: Writes in read to existing streams * * * Arg: lna [UNKN ] Undocumented argument [LinkNumberArray *] * Arg: lnad [UNKN ] Undocumented argument [LinkNumberArrayDebug *] * Arg: dns [UNKN ] Undocumented argument [DnaNumberSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 215 "linkindex.dy" boolean write_existing_LinkStream(LinkNumberArray * lna,LinkNumberArrayDebug * lnad,DnaNumberSequence * dns) { int i; int j; LinkStream * stream; LinkStream * prev = NULL; LinkEdge * edge = NULL; int is_new = 0; int is_old = 0; if( lnad->add_stream != 0 ) { fprintf(lnad->ofp,"Adding %s as an existing stream\n",dns->orig->name); } fprintf(stderr,"Adding... on existing...\n"); for(i=0;ilen;i++) { if( lna->array[dns->seq[i].number] == NULL ) { lna->array[dns->seq[i].number] = LinkNumber_alloc_std(); /* now add */ stream = LinkStream_alloc(); stream->number = dns->seq[i].number; stream->depth = 1; stream->have_seen = 0; stream->starting_flip = dns->seq[i].flipped; add_LinkNumber( lna->array[dns->seq[i].number],stream ); if( lnad->add_stream > 2 ) { fprintf(lnad->ofp,"Adding new position %s, on %d [%d,%c]\n",dns->orig->name,dns->seq[i].number,i,dns->orig->seq[i]); } is_new = 1; if( prev != NULL ) { edge = new_LinkEdge(lna); edge->x = prev; edge->y = stream; if( dns->seq[i].flipped == dns->seq[i-1].flipped ) { edge->twist = 0; } else { edge->twist = 1; } if( is_old != 1 ) { /* set up arbitary situation */ prev->b = edge; stream->a = edge; stream->b = NULL; /* terminating */ } else { if( prev->a == NULL ) { prev->a = edge; } else { prev->b = edge; } stream->a = edge; stream->b = NULL; /* terminating */ is_old = 0; } } else { /* first position, assign a to NULL */ stream->a = NULL; stream->b = NULL; } fprintf(stderr,"Leaving with position %d with %d on a and %d on b\n",dns->seq[i].number, lna->array[dns->seq[i].number]->stream[0]->a, lna->array[dns->seq[i].number]->stream[0]->b); prev = stream; continue; } else { /* as this number has a stream, and we are adding, one of the streams have to be right*/ /* if this is first, then we know this must be unambiguous */ if( i == 0 ) { if( lna->array[dns->seq[0].number]->len > 1 ) { fatal("Cannot deal with ambiguous first arrays"); } lna->array[dns->seq[0].number]->stream[0]->depth++; prev = lna->array[dns->seq[0].number]->stream[0]; continue; } /* otherwise, one of these streams should make sense, if not die! */ for(j=0;jarray[dns->seq[i].number]->len;j++) { auto LinkStream * stream = lna->array[dns->seq[i].number]->stream[j]; if( lnad->add_stream != 0 ) { fprintf(lnad->ofp,"Adding %s as an existing stream, testing %d [%d]\n",dns->orig->name,j,lna->array[dns->seq[i].number]); } if( stream->a == NULL || stream->b == NULL) { /* joining to existing stream from adding things in? Or leaving stream? */ stream->depth++; if( is_new == 1 ) { /* we are entering the existing stream here */ edge = new_LinkEdge(lna); edge->x = prev; edge->y = stream; if( dns->seq[i].flipped == dns->seq[i-1].flipped ) { edge->twist = 0; } else { edge->twist = 1; } /* assumptions that we make as we are entering here */ assert(prev); assert(prev->a != NULL); assert(prev->b == NULL); prev->b = edge; if( stream->a == NULL ) { stream->a = edge; } else { stream->b = edge; } is_new = 0; prev = stream; } else { /* we are leaving the existing stream here have to set up the situtation so that the next link works ok */ is_old = 1; prev = stream; } break; /* out of over all streams */ } if( is_linked_LinkStream(prev,lna->array[dns->seq[i].number]->stream[j],dns->seq[i-1].flipped == dns->seq[i].flipped? 0 : 1) != NULL ) { lna->array[dns->seq[i].number]->stream[j]->depth++; prev = lna->array[dns->seq[i].number]->stream[j]; break; } } /* this means we have no stream position that made sense */ if( j >= lna->array[dns->seq[i].number]->len ) { fatal("We have a problem. No valid stream, despite adding to existing stream"); } } /* end of else is filled */ } /* end of final position */ } /* Function: write_new_LinkStream(lna,lnad,dns) * * Descrip: Writes in read as a new stream * * * Arg: lna [UNKN ] Undocumented argument [LinkNumberArray *] * Arg: lnad [UNKN ] Undocumented argument [LinkNumberArrayDebug *] * Arg: dns [UNKN ] Undocumented argument [DnaNumberSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 369 "linkindex.dy" boolean write_new_LinkStream(LinkNumberArray * lna,LinkNumberArrayDebug * lnad,DnaNumberSequence * dns) { LinkStream * stream; LinkStream * prev; LinkEdge * edge; int i; /* First position is odd */ if( lna->array[dns->seq[0].number] == NULL ) { lna->array[dns->seq[0].number] = LinkNumber_alloc_std(); } stream = LinkStream_alloc(); stream->number = dns->seq[0].number; stream->starting_flip = dns->seq[0].flipped; stream->depth = 1; add_LinkNumber( lna->array[dns->seq[0].number],stream ); if( lnad->add_stream > 2 ) { fprintf(lnad->ofp,"Adding %s, on %d\n",dns->orig->name,dns->seq[0].number); } stream->a = NULL; prev = stream; for(i=1;ilen;i++) { if( lna->array[dns->seq[i].number] == NULL ) { lna->array[dns->seq[i].number] = LinkNumber_alloc_std(); } stream = LinkStream_alloc(); stream->number = dns->seq[i].number; stream->starting_flip = dns->seq[i].flipped; stream->depth = 1; add_LinkNumber( lna->array[dns->seq[i].number],stream ); if( lnad->add_stream > 2 ) { fprintf(lnad->ofp,"Adding %s, on %d\n",dns->orig->name,dns->seq[i].number); } edge = new_LinkEdge(lna); edge->x = prev; edge->y = stream; if( dns->seq[i].flipped == dns->seq[i-1].flipped ) { edge->twist = 0; } else { edge->twist = 1; } prev->b = edge; stream->a = edge; prev = stream; } /* final guy, finish off */ prev->b = NULL; } /* Function: is_linked_LinkStream(l_one,l_two,twist) * * Descrip: Returns the right edge which potentially links these two link streams * * * Arg: l_one [UNKN ] Undocumented argument [LinkStream *] * Arg: l_two [UNKN ] Undocumented argument [LinkStream *] * Arg: twist [UNKN ] Undocumented argument [char] * * Return [UNKN ] Undocumented return value [LinkEdge *] * */ # line 433 "linkindex.dy" LinkEdge * is_linked_LinkStream(LinkStream * l_one,LinkStream * l_two,char twist) { if( l_one->a != NULL && l_one->b != NULL ) { fprintf(stderr,"Testing Link %d with Edges %d,%d and links %d,%d [%d] and %d,%d [%d] to %d [%d]\n",l_one,l_one->a,l_one->b,l_one->a->x,l_one->a->y,l_one->a->twist,l_one->b->x,l_one->b->y,l_one->b->twist,l_two,twist); } if( l_one->a != NULL && l_one->a->x == l_one && l_one->a->y == l_two && l_one->a->twist == twist ) { return l_one->a; } if( l_one->a != NULL && l_one->a->y == l_one && l_one->a->x == l_two && l_one->a->twist == twist ) { return l_one->a; } if( l_one->b != NULL && l_one->b->x == l_one && l_one->b->y == l_two && l_one->b->twist == twist ) { return l_one->b; } if( l_one->b != NULL && l_one->b->y == l_one && l_one->b->x == l_two && l_one->b->twist == twist ) { return l_one->b; } fprintf(stderr,"Going to return NULL\n"); return NULL; } /* Function: is_new_stream_LinkNumberArray(lna,lnad,dns) * * Descrip: Determines whether this DnaNumberSequence should be newly * streamed or not * * * Arg: lna [UNKN ] Undocumented argument [LinkNumberArray *] * Arg: lnad [UNKN ] Undocumented argument [LinkNumberArrayDebug *] * Arg: dns [UNKN ] Undocumented argument [DnaNumberSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 464 "linkindex.dy" boolean is_new_stream_LinkNumberArray(LinkNumberArray * lna,LinkNumberArrayDebug * lnad,DnaNumberSequence * dns) { int i,j,k; boolean seen_end = 0; LinkStream * prev; assert(lna); assert(dns); /* find starting position */ for(i=0;ilen;i++) { if( lnad->placement_stream > 2 ) { fprintf(lnad->ofp,"Read %s is unique testing position %d with %d [%d]\n",dns->orig->name,i,dns->seq[i].number,lna->array[dns->seq[i].number]); } if( lna->array[dns->seq[i].number] != NULL ) break; } if( i >= dns->len ) { /* virgin - return TRUE */ if( lnad->placement_stream != 0 ) { fprintf(lnad->ofp,"Read %s is unique, starting new stream\n",dns->orig->name); } return TRUE; } if( lna->array[dns->seq[i].number]->len > 1 ) { if( lnad->placement_stream != 0 ) { fprintf(lnad->ofp,"Read %s starts on ambiguous position, can't cope\n",dns->orig->name); } return TRUE; } prev = lna->array[dns->seq[i].number]->stream[0]; for(i++;ilen;i++) { if( lna->array[dns->seq[i].number] == NULL ) break; for(j=0;jarray[dns->seq[i].number]->len;j++) { auto LinkStream * stream = lna->array[dns->seq[i].number]->stream[j]; auto LinkEdge * edge = is_linked_LinkStream(stream,prev,dns->seq[i-1].flipped == dns->seq[i].flipped ? 0 : 1); if( edge == NULL ) { if( lnad->placement_stream != 0 ) { fprintf(lnad->ofp,"Read %s, edge failure at position %d\n",dns->orig->name,i); } return TRUE; } if( lnad->placement_stream > 2 ) { fprintf(lnad->ofp,"Read %s, successfully found stream for position %d\n",dns->orig->name,i); } prev = stream; } } if( i < dns->len ) { /* reached end, on a stream! return FALSE */ if( lnad->placement_stream != 0 ) { fprintf(lnad->ofp,"Read %s is streamable to end\n",dns->orig->name); } return FALSE; } /* still could be valid if NULL to end of seq */ for(;ilen;i++) { if( lna->array[dns->seq[i].number] == NULL ) { if( lnad->placement_stream != 0 ) { fprintf(lnad->ofp,"Read %s was streamable to end, but has a re-entry\n",dns->orig->name); } return TRUE; } } if( lnad->placement_stream != 0 ) { fprintf(lnad->ofp,"Read %s is streamable to end, but does have unique tail\n",dns->orig->name); } return FALSE; } /* Function: new_LinkNumberArray(nmer_size) * * Descrip: Returns a LinkNumberArray with the appropiate * array size for this size of Nmer * * * Arg: nmer_size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [LinkNumberArray *] * */ # line 552 "linkindex.dy" LinkNumberArray * new_LinkNumberArray(int nmer_size) { int size = 1; int i; LinkNumberArray * out; for(i=0;iarray = calloc(size,sizeof(LinkNumber*)); out->nmer_size = nmer_size; out->array_len = size; return out; } /* Function: new_LinkEdge(lna) * * Descrip: makes a new link edge added into the memory management * * * Arg: lna [UNKN ] Undocumented argument [LinkNumberArray *] * * Return [UNKN ] Undocumented return value [LinkEdge *] * */ # line 576 "linkindex.dy" LinkEdge * new_LinkEdge(LinkNumberArray * lna) { LinkEdge * new; assert(lna); new = LinkEdge_alloc(); add_LinkNumberArray(lna,new); return new; } # line 593 "linkindex.c" /* Function: hard_link_LinkEdge(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkEdge *] * * Return [UNKN ] Undocumented return value [LinkEdge *] * */ LinkEdge * hard_link_LinkEdge(LinkEdge * obj) { if( obj == NULL ) { warn("Trying to hard link to a LinkEdge object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LinkEdge_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkEdge *] * */ LinkEdge * LinkEdge_alloc(void) { LinkEdge * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LinkEdge *) ckalloc (sizeof(LinkEdge))) == NULL) { warn("LinkEdge_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->twist = 'u'; return out; } /* Function: free_LinkEdge(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkEdge *] * * Return [UNKN ] Undocumented return value [LinkEdge *] * */ LinkEdge * free_LinkEdge(LinkEdge * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LinkEdge obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->x is linked in */ /* obj->y is linked in */ ckfree(obj); return NULL; } /* Function: hard_link_LinkStream(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkStream *] * * Return [UNKN ] Undocumented return value [LinkStream *] * */ LinkStream * hard_link_LinkStream(LinkStream * obj) { if( obj == NULL ) { warn("Trying to hard link to a LinkStream object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LinkStream_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkStream *] * */ LinkStream * LinkStream_alloc(void) { LinkStream * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LinkStream *) ckalloc (sizeof(LinkStream))) == NULL) { warn("LinkStream_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->number = 0; out->depth = 'u'; out->starting_flip = 'u'; out->have_seen = 'u'; return out; } /* Function: free_LinkStream(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkStream *] * * Return [UNKN ] Undocumented return value [LinkStream *] * */ LinkStream * free_LinkStream(LinkStream * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LinkStream obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->a is linked in */ /* obj->b is linked in */ ckfree(obj); return NULL; } /* Function: swap_LinkNumber(list,i,j) * * Descrip: swap function: an internal for qsort_LinkNumber * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [LinkStream **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_LinkNumber(LinkStream ** list,int i,int j) { LinkStream * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_LinkNumber(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_LinkNumber which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [LinkStream **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_LinkNumber(LinkStream ** list,int left,int right,int (*comp)(LinkStream * ,LinkStream * )) { int i,last; if( left >= right ) return; swap_LinkNumber(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_LinkNumber (list,++last,i); } swap_LinkNumber (list,left,last); qsort_LinkNumber(list,left,last-1,comp); qsort_LinkNumber(list,last+1,right,comp); } /* Function: sort_LinkNumber(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_LinkNumber * * * Arg: obj [UNKN ] Object containing list [LinkNumber *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_LinkNumber(LinkNumber * obj,int (*comp)(LinkStream *, LinkStream *)) { qsort_LinkNumber(obj->stream,0,obj->len-1,comp); return; } /* Function: expand_LinkNumber(obj,len) * * Descrip: Really an internal function for add_LinkNumber * * * Arg: obj [UNKN ] Object which contains the list [LinkNumber *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_LinkNumber(LinkNumber * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_LinkNumber called with no need"); return TRUE; } if( (obj->stream = (LinkStream ** ) ckrealloc (obj->stream,sizeof(LinkStream *)*len)) == NULL) { warn("ckrealloc failed for expand_LinkNumber, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_LinkNumber(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LinkNumber *] * Arg: add [OWNER] Object to add to the list [LinkStream *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_LinkNumber(LinkNumber * obj,LinkStream * add) { if( obj->len >= obj->maxlen) { if( expand_LinkNumber(obj,obj->len + LinkNumberLISTLENGTH) == FALSE) return FALSE; } obj->stream[obj->len++]=add; return TRUE; } /* Function: flush_LinkNumber(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LinkNumber *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_LinkNumber(LinkNumber * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->stream[i] != NULL) { free_LinkStream(obj->stream[i]); obj->stream[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: LinkNumber_alloc_std(void) * * Descrip: Equivalent to LinkNumber_alloc_len(LinkNumberLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [LinkNumber *] * */ LinkNumber * LinkNumber_alloc_std(void) { return LinkNumber_alloc_len(LinkNumberLISTLENGTH); } /* Function: LinkNumber_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [LinkNumber *] * */ LinkNumber * LinkNumber_alloc_len(int len) { LinkNumber * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = LinkNumber_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->stream = (LinkStream ** ) ckcalloc (len,sizeof(LinkStream *))) == NULL) { warn("Warning, ckcalloc failed in LinkNumber_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_LinkNumber(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkNumber *] * * Return [UNKN ] Undocumented return value [LinkNumber *] * */ LinkNumber * hard_link_LinkNumber(LinkNumber * obj) { if( obj == NULL ) { warn("Trying to hard link to a LinkNumber object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LinkNumber_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkNumber *] * */ LinkNumber * LinkNumber_alloc(void) { LinkNumber * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LinkNumber *) ckalloc (sizeof(LinkNumber))) == NULL) { warn("LinkNumber_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->stream = NULL; out->len = out->maxlen = 0; out->number = 0; return out; } /* Function: free_LinkNumber(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkNumber *] * * Return [UNKN ] Undocumented return value [LinkNumber *] * */ LinkNumber * free_LinkNumber(LinkNumber * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LinkNumber obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->stream != NULL) { for(i=0;ilen;i++) { if( obj->stream[i] != NULL) free_LinkStream(obj->stream[i]); } ckfree(obj->stream); } ckfree(obj); return NULL; } /* Function: swap_LinkNumberArray(list,i,j) * * Descrip: swap function: an internal for qsort_LinkNumberArray * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [LinkEdge **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_LinkNumberArray(LinkEdge ** list,int i,int j) { LinkEdge * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_LinkNumberArray(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_LinkNumberArray which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [LinkEdge **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_LinkNumberArray(LinkEdge ** list,int left,int right,int (*comp)(LinkEdge * ,LinkEdge * )) { int i,last; if( left >= right ) return; swap_LinkNumberArray(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_LinkNumberArray (list,++last,i); } swap_LinkNumberArray (list,left,last); qsort_LinkNumberArray(list,left,last-1,comp); qsort_LinkNumberArray(list,last+1,right,comp); } /* Function: sort_LinkNumberArray(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_LinkNumberArray * * * Arg: obj [UNKN ] Object containing list [LinkNumberArray *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_LinkNumberArray(LinkNumberArray * obj,int (*comp)(LinkEdge *, LinkEdge *)) { qsort_LinkNumberArray(obj->edge_set,0,obj->len-1,comp); return; } /* Function: expand_LinkNumberArray(obj,len) * * Descrip: Really an internal function for add_LinkNumberArray * * * Arg: obj [UNKN ] Object which contains the list [LinkNumberArray *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_LinkNumberArray(LinkNumberArray * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_LinkNumberArray called with no need"); return TRUE; } if( (obj->edge_set = (LinkEdge ** ) ckrealloc (obj->edge_set,sizeof(LinkEdge *)*len)) == NULL) { warn("ckrealloc failed for expand_LinkNumberArray, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_LinkNumberArray(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LinkNumberArray *] * Arg: add [OWNER] Object to add to the list [LinkEdge *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_LinkNumberArray(LinkNumberArray * obj,LinkEdge * add) { if( obj->len >= obj->maxlen) { if( expand_LinkNumberArray(obj,obj->len + LinkNumberArrayLISTLENGTH) == FALSE) return FALSE; } obj->edge_set[obj->len++]=add; return TRUE; } /* Function: flush_LinkNumberArray(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LinkNumberArray *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_LinkNumberArray(LinkNumberArray * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->edge_set[i] != NULL) { free_LinkEdge(obj->edge_set[i]); obj->edge_set[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: LinkNumberArray_alloc_std(void) * * Descrip: Equivalent to LinkNumberArray_alloc_len(LinkNumberArrayLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [LinkNumberArray *] * */ LinkNumberArray * LinkNumberArray_alloc_std(void) { return LinkNumberArray_alloc_len(LinkNumberArrayLISTLENGTH); } /* Function: LinkNumberArray_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [LinkNumberArray *] * */ LinkNumberArray * LinkNumberArray_alloc_len(int len) { LinkNumberArray * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = LinkNumberArray_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->edge_set = (LinkEdge ** ) ckcalloc (len,sizeof(LinkEdge *))) == NULL) { warn("Warning, ckcalloc failed in LinkNumberArray_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_LinkNumberArray(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkNumberArray *] * * Return [UNKN ] Undocumented return value [LinkNumberArray *] * */ LinkNumberArray * hard_link_LinkNumberArray(LinkNumberArray * obj) { if( obj == NULL ) { warn("Trying to hard link to a LinkNumberArray object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LinkNumberArray_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkNumberArray *] * */ LinkNumberArray * LinkNumberArray_alloc(void) { LinkNumberArray * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LinkNumberArray *) ckalloc (sizeof(LinkNumberArray))) == NULL) { warn("LinkNumberArray_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->array = NULL; out->array_len = 0; out->nmer_size = 0; out->edge_set = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_LinkNumberArray(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkNumberArray *] * * Return [UNKN ] Undocumented return value [LinkNumberArray *] * */ LinkNumberArray * free_LinkNumberArray(LinkNumberArray * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LinkNumberArray obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->array != NULL) ckfree(obj->array); if( obj->edge_set != NULL) { for(i=0;ilen;i++) { if( obj->edge_set[i] != NULL) free_LinkEdge(obj->edge_set[i]); } ckfree(obj->edge_set); } ckfree(obj); return NULL; } /* Function: hard_link_LinkNumberArrayDebug(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkNumberArrayDebug *] * * Return [UNKN ] Undocumented return value [LinkNumberArrayDebug *] * */ LinkNumberArrayDebug * hard_link_LinkNumberArrayDebug(LinkNumberArrayDebug * obj) { if( obj == NULL ) { warn("Trying to hard link to a LinkNumberArrayDebug object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LinkNumberArrayDebug_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkNumberArrayDebug *] * */ LinkNumberArrayDebug * LinkNumberArrayDebug_alloc(void) { LinkNumberArrayDebug * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LinkNumberArrayDebug *) ckalloc (sizeof(LinkNumberArrayDebug))) == NULL) { warn("LinkNumberArrayDebug_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->placement_stream = 'u'; out->add_stream = 'u'; out->extraction = 'u'; return out; } /* Function: free_LinkNumberArrayDebug(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkNumberArrayDebug *] * * Return [UNKN ] Undocumented return value [LinkNumberArrayDebug *] * */ LinkNumberArrayDebug * free_LinkNumberArrayDebug(LinkNumberArrayDebug * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LinkNumberArrayDebug obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->ofp is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/linkindex.h0000644000175000001440000004204610670453716016607 0ustar philippusers#ifndef DYNAMITElinkindexHEADERFILE #define DYNAMITElinkindexHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dnanumber.h" #define LinkNumberLISTLENGTH 32 #define LinkStreamLISTLENGTH 32 #define LinkNumberArrayLISTLENGTH 1024 #ifndef DYNAMITE_DEFINED_LinkNumber typedef struct Wise2_LinkNumber Wise2_LinkNumber; #define LinkNumber Wise2_LinkNumber #define DYNAMITE_DEFINED_LinkNumber #endif #ifndef DYNAMITE_DEFINED_LinkStream typedef struct Wise2_LinkStream Wise2_LinkStream; #define LinkStream Wise2_LinkStream #define DYNAMITE_DEFINED_LinkStream #endif #ifndef DYNAMITE_DEFINED_LinkEdge typedef struct Wise2_LinkEdge Wise2_LinkEdge; #define LinkEdge Wise2_LinkEdge #define DYNAMITE_DEFINED_LinkEdge #endif struct Wise2_LinkEdge { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif LinkStream * x; LinkStream * y; char twist; } ; /* LinkEdge defined */ #ifndef DYNAMITE_DEFINED_LinkEdge typedef struct Wise2_LinkEdge Wise2_LinkEdge; #define LinkEdge Wise2_LinkEdge #define DYNAMITE_DEFINED_LinkEdge #endif struct Wise2_LinkStream { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif LinkEdge * a; LinkEdge * b; int number; char depth; char starting_flip; char have_seen; } ; /* LinkStream defined */ #ifndef DYNAMITE_DEFINED_LinkStream typedef struct Wise2_LinkStream Wise2_LinkStream; #define LinkStream Wise2_LinkStream #define DYNAMITE_DEFINED_LinkStream #endif struct Wise2_LinkNumber { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif LinkStream ** stream; int len;/* len for above stream */ int maxlen; /* maxlen for above stream */ int number; } ; /* LinkNumber defined */ #ifndef DYNAMITE_DEFINED_LinkNumber typedef struct Wise2_LinkNumber Wise2_LinkNumber; #define LinkNumber Wise2_LinkNumber #define DYNAMITE_DEFINED_LinkNumber #endif struct Wise2_LinkNumberArray { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif LinkNumber ** array; int array_len; int nmer_size; LinkEdge ** edge_set; int len;/* len for above edge_set */ int maxlen; /* maxlen for above edge_set */ } ; /* LinkNumberArray defined */ #ifndef DYNAMITE_DEFINED_LinkNumberArray typedef struct Wise2_LinkNumberArray Wise2_LinkNumberArray; #define LinkNumberArray Wise2_LinkNumberArray #define DYNAMITE_DEFINED_LinkNumberArray #endif struct Wise2_LinkNumberArrayDebug { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char placement_stream; char add_stream; char extraction; FILE * ofp; } ; /* LinkNumberArrayDebug defined */ #ifndef DYNAMITE_DEFINED_LinkNumberArrayDebug typedef struct Wise2_LinkNumberArrayDebug Wise2_LinkNumberArrayDebug; #define LinkNumberArrayDebug Wise2_LinkNumberArrayDebug #define DYNAMITE_DEFINED_LinkNumberArrayDebug #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: extract_dna_LinkStream(ln,lnad,nmer_size) * * Descrip: Reverse builds a DNA sequence stream from LinkStream * * * Arg: ln [UNKN ] Undocumented argument [LinkStream *] * Arg: lnad [UNKN ] Undocumented argument [LinkNumberArrayDebug *] * Arg: nmer_size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_extract_dna_LinkStream(LinkStream * ln,LinkNumberArrayDebug * lnad,int nmer_size); #define extract_dna_LinkStream Wise2_extract_dna_LinkStream /* Function: write_existing_LinkStream(lna,lnad,dns) * * Descrip: Writes in read to existing streams * * * Arg: lna [UNKN ] Undocumented argument [LinkNumberArray *] * Arg: lnad [UNKN ] Undocumented argument [LinkNumberArrayDebug *] * Arg: dns [UNKN ] Undocumented argument [DnaNumberSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_write_existing_LinkStream(LinkNumberArray * lna,LinkNumberArrayDebug * lnad,DnaNumberSequence * dns); #define write_existing_LinkStream Wise2_write_existing_LinkStream /* Function: write_new_LinkStream(lna,lnad,dns) * * Descrip: Writes in read as a new stream * * * Arg: lna [UNKN ] Undocumented argument [LinkNumberArray *] * Arg: lnad [UNKN ] Undocumented argument [LinkNumberArrayDebug *] * Arg: dns [UNKN ] Undocumented argument [DnaNumberSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_write_new_LinkStream(LinkNumberArray * lna,LinkNumberArrayDebug * lnad,DnaNumberSequence * dns); #define write_new_LinkStream Wise2_write_new_LinkStream /* Function: is_linked_LinkStream(l_one,l_two,twist) * * Descrip: Returns the right edge which potentially links these two link streams * * * Arg: l_one [UNKN ] Undocumented argument [LinkStream *] * Arg: l_two [UNKN ] Undocumented argument [LinkStream *] * Arg: twist [UNKN ] Undocumented argument [char] * * Return [UNKN ] Undocumented return value [LinkEdge *] * */ LinkEdge * Wise2_is_linked_LinkStream(LinkStream * l_one,LinkStream * l_two,char twist); #define is_linked_LinkStream Wise2_is_linked_LinkStream /* Function: is_new_stream_LinkNumberArray(lna,lnad,dns) * * Descrip: Determines whether this DnaNumberSequence should be newly * streamed or not * * * Arg: lna [UNKN ] Undocumented argument [LinkNumberArray *] * Arg: lnad [UNKN ] Undocumented argument [LinkNumberArrayDebug *] * Arg: dns [UNKN ] Undocumented argument [DnaNumberSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_new_stream_LinkNumberArray(LinkNumberArray * lna,LinkNumberArrayDebug * lnad,DnaNumberSequence * dns); #define is_new_stream_LinkNumberArray Wise2_is_new_stream_LinkNumberArray /* Function: new_LinkNumberArray(nmer_size) * * Descrip: Returns a LinkNumberArray with the appropiate * array size for this size of Nmer * * * Arg: nmer_size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [LinkNumberArray *] * */ LinkNumberArray * Wise2_new_LinkNumberArray(int nmer_size); #define new_LinkNumberArray Wise2_new_LinkNumberArray /* Function: new_LinkEdge(lna) * * Descrip: makes a new link edge added into the memory management * * * Arg: lna [UNKN ] Undocumented argument [LinkNumberArray *] * * Return [UNKN ] Undocumented return value [LinkEdge *] * */ LinkEdge * Wise2_new_LinkEdge(LinkNumberArray * lna); #define new_LinkEdge Wise2_new_LinkEdge /* Function: hard_link_LinkEdge(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkEdge *] * * Return [UNKN ] Undocumented return value [LinkEdge *] * */ LinkEdge * Wise2_hard_link_LinkEdge(LinkEdge * obj); #define hard_link_LinkEdge Wise2_hard_link_LinkEdge /* Function: LinkEdge_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkEdge *] * */ LinkEdge * Wise2_LinkEdge_alloc(void); #define LinkEdge_alloc Wise2_LinkEdge_alloc /* Function: free_LinkEdge(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkEdge *] * * Return [UNKN ] Undocumented return value [LinkEdge *] * */ LinkEdge * Wise2_free_LinkEdge(LinkEdge * obj); #define free_LinkEdge Wise2_free_LinkEdge /* Function: hard_link_LinkStream(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkStream *] * * Return [UNKN ] Undocumented return value [LinkStream *] * */ LinkStream * Wise2_hard_link_LinkStream(LinkStream * obj); #define hard_link_LinkStream Wise2_hard_link_LinkStream /* Function: LinkStream_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkStream *] * */ LinkStream * Wise2_LinkStream_alloc(void); #define LinkStream_alloc Wise2_LinkStream_alloc /* Function: free_LinkStream(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkStream *] * * Return [UNKN ] Undocumented return value [LinkStream *] * */ LinkStream * Wise2_free_LinkStream(LinkStream * obj); #define free_LinkStream Wise2_free_LinkStream /* Function: add_LinkNumber(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LinkNumber *] * Arg: add [OWNER] Object to add to the list [LinkStream *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_LinkNumber(LinkNumber * obj,LinkStream * add); #define add_LinkNumber Wise2_add_LinkNumber /* Function: flush_LinkNumber(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LinkNumber *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_LinkNumber(LinkNumber * obj); #define flush_LinkNumber Wise2_flush_LinkNumber /* Function: LinkNumber_alloc_std(void) * * Descrip: Equivalent to LinkNumber_alloc_len(LinkNumberLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [LinkNumber *] * */ LinkNumber * Wise2_LinkNumber_alloc_std(void); #define LinkNumber_alloc_std Wise2_LinkNumber_alloc_std /* Function: LinkNumber_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [LinkNumber *] * */ LinkNumber * Wise2_LinkNumber_alloc_len(int len); #define LinkNumber_alloc_len Wise2_LinkNumber_alloc_len /* Function: hard_link_LinkNumber(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkNumber *] * * Return [UNKN ] Undocumented return value [LinkNumber *] * */ LinkNumber * Wise2_hard_link_LinkNumber(LinkNumber * obj); #define hard_link_LinkNumber Wise2_hard_link_LinkNumber /* Function: LinkNumber_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkNumber *] * */ LinkNumber * Wise2_LinkNumber_alloc(void); #define LinkNumber_alloc Wise2_LinkNumber_alloc /* Function: free_LinkNumber(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkNumber *] * * Return [UNKN ] Undocumented return value [LinkNumber *] * */ LinkNumber * Wise2_free_LinkNumber(LinkNumber * obj); #define free_LinkNumber Wise2_free_LinkNumber /* Function: add_LinkNumberArray(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LinkNumberArray *] * Arg: add [OWNER] Object to add to the list [LinkEdge *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_LinkNumberArray(LinkNumberArray * obj,LinkEdge * add); #define add_LinkNumberArray Wise2_add_LinkNumberArray /* Function: flush_LinkNumberArray(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LinkNumberArray *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_LinkNumberArray(LinkNumberArray * obj); #define flush_LinkNumberArray Wise2_flush_LinkNumberArray /* Function: LinkNumberArray_alloc_std(void) * * Descrip: Equivalent to LinkNumberArray_alloc_len(LinkNumberArrayLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [LinkNumberArray *] * */ LinkNumberArray * Wise2_LinkNumberArray_alloc_std(void); #define LinkNumberArray_alloc_std Wise2_LinkNumberArray_alloc_std /* Function: LinkNumberArray_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [LinkNumberArray *] * */ LinkNumberArray * Wise2_LinkNumberArray_alloc_len(int len); #define LinkNumberArray_alloc_len Wise2_LinkNumberArray_alloc_len /* Function: hard_link_LinkNumberArray(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkNumberArray *] * * Return [UNKN ] Undocumented return value [LinkNumberArray *] * */ LinkNumberArray * Wise2_hard_link_LinkNumberArray(LinkNumberArray * obj); #define hard_link_LinkNumberArray Wise2_hard_link_LinkNumberArray /* Function: LinkNumberArray_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkNumberArray *] * */ LinkNumberArray * Wise2_LinkNumberArray_alloc(void); #define LinkNumberArray_alloc Wise2_LinkNumberArray_alloc /* Function: free_LinkNumberArray(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkNumberArray *] * * Return [UNKN ] Undocumented return value [LinkNumberArray *] * */ LinkNumberArray * Wise2_free_LinkNumberArray(LinkNumberArray * obj); #define free_LinkNumberArray Wise2_free_LinkNumberArray /* Function: hard_link_LinkNumberArrayDebug(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinkNumberArrayDebug *] * * Return [UNKN ] Undocumented return value [LinkNumberArrayDebug *] * */ LinkNumberArrayDebug * Wise2_hard_link_LinkNumberArrayDebug(LinkNumberArrayDebug * obj); #define hard_link_LinkNumberArrayDebug Wise2_hard_link_LinkNumberArrayDebug /* Function: LinkNumberArrayDebug_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinkNumberArrayDebug *] * */ LinkNumberArrayDebug * Wise2_LinkNumberArrayDebug_alloc(void); #define LinkNumberArrayDebug_alloc Wise2_LinkNumberArrayDebug_alloc /* Function: free_LinkNumberArrayDebug(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinkNumberArrayDebug *] * * Return [UNKN ] Undocumented return value [LinkNumberArrayDebug *] * */ LinkNumberArrayDebug * Wise2_free_LinkNumberArrayDebug(LinkNumberArrayDebug * obj); #define free_LinkNumberArrayDebug Wise2_free_LinkNumberArrayDebug /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_LinkNumber(LinkStream ** list,int i,int j) ; #define swap_LinkNumber Wise2_swap_LinkNumber void Wise2_qsort_LinkNumber(LinkStream ** list,int left,int right,int (*comp)(LinkStream * ,LinkStream * )); #define qsort_LinkNumber Wise2_qsort_LinkNumber void Wise2_sort_LinkNumber(LinkNumber * obj,int (*comp)(LinkStream *, LinkStream *)); #define sort_LinkNumber Wise2_sort_LinkNumber boolean Wise2_expand_LinkNumber(LinkNumber * obj,int len); #define expand_LinkNumber Wise2_expand_LinkNumber void Wise2_swap_LinkNumberArray(LinkEdge ** list,int i,int j) ; #define swap_LinkNumberArray Wise2_swap_LinkNumberArray void Wise2_qsort_LinkNumberArray(LinkEdge ** list,int left,int right,int (*comp)(LinkEdge * ,LinkEdge * )); #define qsort_LinkNumberArray Wise2_qsort_LinkNumberArray void Wise2_sort_LinkNumberArray(LinkNumberArray * obj,int (*comp)(LinkEdge *, LinkEdge *)); #define sort_LinkNumberArray Wise2_sort_LinkNumberArray boolean Wise2_expand_LinkNumberArray(LinkNumberArray * obj,int len); #define expand_LinkNumberArray Wise2_expand_LinkNumberArray #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/dnanumber.dy0000644000175000001440000000446407637404143016763 0ustar philippusers %{ #include "wisebase.h" #include "codon.h" #include "sequence.h" typedef struct { int number; char flipped; } DnaNumber; %} struct DnaNumberSequence DnaNumber * seq int len; Sequence * orig %{ #include "dnanumber.h" DnaNumberSequence * new_DnaNumberSequence(Sequence * seq,int nmer_size) { int i; DnaNumberSequence * out; assert(seq); out = DnaNumberSequence_alloc(); out->seq = malloc(sizeof(DnaNumber)*seq->len); for(i=0;ilen;i++) out->seq[i] = dna_number_from_string(seq->seq+i,nmer_size); out->orig = hard_link_Sequence(seq); out->len = seq->len-nmer_size-1; return out; } char first_char_from_dnanumber(int dnanumber,int nmer_size,int flipped) { int base = 1; int basepair; int power; int i; if( flipped == 1 ) { /* first number is therefore lowest bit */ basepair = dnanumber % 4; /* fprintf(stderr,"Going to use %d as number\n",basepair);*/ basepair = complement_base(basepair); return char_from_base(basepair); } else { for(i=0;i backward ) { out.flipped = 0; break; } if( backward > forward ) { out.flipped = 1; break; } } assert(out.flipped != 2); if( out.flipped == 0 ) { for(i=0;i= 0;i--) { base_number[i] = number / base; number -= base*base_number[i]; base = base / 4; } base = 1; total = 0; for(i=0;i= 0;i--) { no = number / base; buffer[i] = char_from_base(no); number -= base*no; base = base / 4; } return; } # line 84 "dnamapping.dy" char lexical_last_base_from_kmer(kmer_t kmer,int kmer_size,int lexical_for) { int i; kmer_t base = 1; int last_base; if( lexical_for == 1) { for(i=0;i 0); for(i=0;i rev_buffer[i] ) { out.lexical_forward = 1; break; } if( for_buffer[i] < rev_buffer[i] ) { out.lexical_forward = 0; break; } } temp = 0; base = 1; if( out.lexical_forward == 1 ) { for(i=0;icurrent_end); assert(pos >= 0); if( space->is_static != 0 ) { /* can make explicit calculation for position */ index_pos = (int) (pos / space->average_len); if( space->sns[index_pos]->start == -1 ) { /* was a padding position */ for(index_pos--;index_pos >= 0 && space->sns[index_pos]->start == -1;index_pos--) { /*fprintf(stderr,"Regressed %d with %d [pos %d]\n",index_pos,space->sns[index_pos]->start,pos);*/ } assert(index_pos >= 0 ); } if( space->sns[index_pos] == NULL ) { fatal("Going to return %d for %d with %d - max %d\n",index_pos,pos,space->average_len,space->current_end); } return space->sns[index_pos]; } assert(pos < space->current_end); index_pos = find_position_SinglePosSpace(space,0,space->len-1,pos); return space->sns[index_pos]; } %func Recursive function for finding position %% int find_position_SinglePosSpace(SinglePosSpace * space,int lower,int higher,int position) { int mid; /* fprintf(stderr,"To find position %d Entering with.... %d to %d\n",position,lower,higher); */ if( lower+2 >= higher ) { if( position >= space->sns[lower]->start && position < space->sns[lower]->end ) return lower; if( position >= space->sns[higher]->start && position < space->sns[higher]->end ) return higher; } mid = (lower + (int)((higher-lower)/2)); if( position >= space->sns[mid]->start && position < space->sns[mid]->end ) return mid; if( position >= space->sns[mid]->end ) { /* top half */ return find_position_SinglePosSpace(space,mid,higher,position); } else { return find_position_SinglePosSpace(space,lower,mid,position); } } %func Adds a sequence to a single number space, giving out the start position for this sequence %% long int add_Sequence_SinglePosSpace(SinglePosSpace * space,long int length,void * data) { int seq_size = 1; int i; SinglePosSequence * a; SinglePosSequence * dummy; assert(space); assert(data); assert(length >= 0); a = SinglePosSequence_alloc(); a->start = space->current_end; if( space->is_static != 0 ) { if( length > space->max_length ) { seq_size = (length / space->max_length) +1; } else { seq_size = 1; } a->end = space->current_end + (space->max_length*seq_size); space->average_len = space->max_length; } else { a->end = space->current_end + length; space->average_len = a->end / length; } a->data = data; add_SinglePosSpace(space,a); /* pad for long sequences */ if( seq_size > 1 ) { for(i=1;istart = -1; dummy->end = -1; dummy->data = NULL; add_SinglePosSpace(space,dummy); } } space->current_end = a->end; return a->start; } %func Provides a new single number space %% SinglePosSpace * new_SinglePosSpace(int has_maxlen,int max_length) { SinglePosSpace * out; out = SinglePosSpace_alloc_std(); out->is_static = has_maxlen; out->max_length = max_length; return out; } wise-2.4.1/src/dnaindex/assembly_stream_cons.c0000644000175000001440000001260410670453716021026 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "assembly_stream_cons.h" # line 24 "assembly_stream_cons.dy" void show_help_AssemblyStreamConstructor(FILE * ofp) { fprintf(ofp,"Assembly Read Sequence input options\n"); fprintf(ofp," -astype [fasta/sanger] type of input\n"); fprintf(ofp," -asfile filename for fasta input\n"); fprintf(ofp," -asdir directory name for sanger project-style input\n"); fprintf(ofp," -asdirext [1c] extension for reads in sanger project style, defaul 1c\n"); } # line 33 "assembly_stream_cons.dy" AssemblySequenceStream * new_AssemblySequenceStream_from_AssemblyStreamConstructor(AssemblyStreamConstructor * asc) { FILE * ifp; /* a bit evil as we don't close this. Should fix */ switch(asc->type) { case AssemblyStreamTypeFasta : if( asc->file_name == NULL ) { warn("Fasta file type needs a filename with -asfile"); return NULL; } ifp = openfile(asc->file_name,"r"); if( ifp == NULL ) { warn("Unable to open file %s for fasta reading",asc->file_name); return NULL; } return plain_fasta_AssemblySequenceStream(ifp); break; case AssemblyStreamTypeSanger : if( asc->dir_name == NULL || asc->extension == NULL ) { warn("Sanger project type needs directory (-asdir) and extension (-asdirext) arguments"); return NULL; } return new_sanger_project_AssemblySequenceStream(asc->dir_name,asc->extension); break; default : warn("Unknown assembly stream type %d",asc->type); } fatal("impossible to get here"); return NULL; } # line 69 "assembly_stream_cons.dy" AssemblyStreamConstructor * new_AssemblyStreamConstructor_from_argv(int * argc,char ** argv) { char * temp; AssemblyStreamConstructor * out; out = AssemblyStreamConstructor_alloc(); out->type = AssemblyStreamTypeFasta; temp = strip_out_assigned_argument(argc,argv,"astype"); if( temp != NULL) { if( strcmp(temp,"fasta") == 0 ) { out->type = AssemblyStreamTypeFasta; } else if ( strcmp(temp,"sanger") == 0 ) { out->type = AssemblyStreamTypeSanger; } else { warn("Unable to decipher type %s as a type of assembly stream",temp); } } temp = strip_out_assigned_argument(argc,argv,"asdir"); if( temp != NULL) out->dir_name = stringalloc(temp); temp = strip_out_assigned_argument(argc,argv,"asdirext"); if( temp != NULL) out->extension = stringalloc(temp); else out->extension = stringalloc("1c"); temp = strip_out_assigned_argument(argc,argv,"asfile"); if( temp != NULL) out->file_name = stringalloc(temp); return out; } # line 90 "assembly_stream_cons.c" /* Function: hard_link_AssemblyStreamConstructor(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblyStreamConstructor *] * * Return [UNKN ] Undocumented return value [AssemblyStreamConstructor *] * */ AssemblyStreamConstructor * hard_link_AssemblyStreamConstructor(AssemblyStreamConstructor * obj) { if( obj == NULL ) { warn("Trying to hard link to a AssemblyStreamConstructor object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AssemblyStreamConstructor_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblyStreamConstructor *] * */ AssemblyStreamConstructor * AssemblyStreamConstructor_alloc(void) { AssemblyStreamConstructor * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AssemblyStreamConstructor *) ckalloc (sizeof(AssemblyStreamConstructor))) == NULL) { warn("AssemblyStreamConstructor_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = 0; out->file_name = NULL; out->dir_name = NULL; out->extension = NULL; return out; } /* Function: free_AssemblyStreamConstructor(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblyStreamConstructor *] * * Return [UNKN ] Undocumented return value [AssemblyStreamConstructor *] * */ AssemblyStreamConstructor * free_AssemblyStreamConstructor(AssemblyStreamConstructor * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AssemblyStreamConstructor obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->file_name != NULL) ckfree(obj->file_name); if( obj->dir_name != NULL) ckfree(obj->dir_name); if( obj->extension != NULL) ckfree(obj->extension); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dnaindex/assembly_stream_cons.h0000644000175000001440000000671210670453716021036 0ustar philippusers#ifndef DYNAMITEassembly_stream_consHEADERFILE #define DYNAMITEassembly_stream_consHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "assembly_stream_interface.h" #include "assembly_sanger_project.h" #include "assembly_stream_fasta.h" typedef enum assembly_stream_type { AssemblyStreamTypeFasta = 791, AssemblyStreamTypeSanger, } AssemblyStreamType; struct Wise2_AssemblyStreamConstructor { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; char * file_name; char * dir_name; char * extension; } ; /* AssemblyStreamConstructor defined */ #ifndef DYNAMITE_DEFINED_AssemblyStreamConstructor typedef struct Wise2_AssemblyStreamConstructor Wise2_AssemblyStreamConstructor; #define AssemblyStreamConstructor Wise2_AssemblyStreamConstructor #define DYNAMITE_DEFINED_AssemblyStreamConstructor #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_AssemblyStreamConstructor(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AssemblyStreamConstructor *] * * Return [UNKN ] Undocumented return value [AssemblyStreamConstructor *] * */ AssemblyStreamConstructor * Wise2_hard_link_AssemblyStreamConstructor(AssemblyStreamConstructor * obj); #define hard_link_AssemblyStreamConstructor Wise2_hard_link_AssemblyStreamConstructor /* Function: AssemblyStreamConstructor_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AssemblyStreamConstructor *] * */ AssemblyStreamConstructor * Wise2_AssemblyStreamConstructor_alloc(void); #define AssemblyStreamConstructor_alloc Wise2_AssemblyStreamConstructor_alloc /* Function: free_AssemblyStreamConstructor(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AssemblyStreamConstructor *] * * Return [UNKN ] Undocumented return value [AssemblyStreamConstructor *] * */ AssemblyStreamConstructor * Wise2_free_AssemblyStreamConstructor(AssemblyStreamConstructor * obj); #define free_AssemblyStreamConstructor Wise2_free_AssemblyStreamConstructor /* Unplaced functions */ /* There has been no indication of the use of these functions */ void Wise2_show_help_AssemblyStreamConstructor(FILE * ofp); #define show_help_AssemblyStreamConstructor Wise2_show_help_AssemblyStreamConstructor AssemblySequenceStream * Wise2_new_AssemblySequenceStream_from_AssemblyStreamConstructor(AssemblyStreamConstructor * asc); #define new_AssemblySequenceStream_from_AssemblyStreamConstructor Wise2_new_AssemblySequenceStream_from_AssemblyStreamConstructor AssemblyStreamConstructor * Wise2_new_AssemblyStreamConstructor_from_argv(int * argc,char ** argv); #define new_AssemblyStreamConstructor_from_argv Wise2_new_AssemblyStreamConstructor_from_argv /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dnaindex/kmer_stat.c0000644000175000001440000000102407715704035016574 0ustar philippusers#include "kmer_assembly.h" #include "kmer_direct.h" #include "largeseqreader.h" int main(int argc,char ** argv) { KmerIndexInterface * kii; KmerAssemblyIndex * kai; SinglePosSpace * sps; Sequence * seq; sps = new_SinglePosSpace(1,200000000); kii = new_KmerDirectIndex(16); kai = new_KmerAssemblyIndex(kii,sps); while( (seq = read_large_dna_Sequence(stdin,1000000)) != NULL ) { add_Sequence_KmerAssemblyIndex(kai,seq,1000000); } show_extensive_stats_KmerAssemblyIndex(kai,stdout); return 0; } wise-2.4.1/src/dnaindex/assembly/0000755000175000001440000000000010670453562016261 5ustar philippuserswise-2.4.1/src/dnaindex/assembly/assemblypath.dy0000644000175000001440000000426710207066416021316 0ustar philippusers %{ #include "assemblygraph.h" #define AssemblyPathLISTLENGTH 64 #define PathSeq_START_OF_TANGLE 1 #define PathSeq_END_OF_TANGLE 2 #define PathSeq_START_INTERNAL 4 #define PathSeq_END_INTERNAL 8 %} struct PathStep BaseLink * link !link struct PathSeq int state long start long base_zero int start_depth AssemblySequence * aseq !link friend AssemblyPath struct AssemblyPath PathStep ** path !list PathSeq ** seq !list !len="seq_" AssemblyPath ** branch !list !len="branch_" int buried_end !def=0 %{ #include "assemblypath.h" PathStep * new_PathStep(BaseLink * l ) { PathStep * out; out = PathStep_alloc(); out->link = l; return out; } boolean BaseLink_in_AssemblyPath(BaseLink * l,AssemblyPath * p) { int i; assert(l != NULL); assert(p != NULL); for(i=0;ilen;i++) { if( p->path[i]->link == l ) { return TRUE; } } for(i=0;ibranch_len;i++) { if( BaseLink_in_AssemblyPath(l,p->branch[i]) == TRUE ) { return TRUE; } } return FALSE; } PathSeq * new_PathSeq(long start,int start_depth,long base_zero,AssemblySequence * aseq) { PathSeq * out; out = PathSeq_alloc(); out->state = 0; out->start = start; out->aseq = aseq; out->base_zero = base_zero; out->start_depth = start_depth; return out; } void show_AssemblyPath(AssemblyPath * asp,int kmer_size,FILE * ofp) { int i; int lexical = 0; char base; BaseNode * next_node; BaseNode * prev_node; assert(asp != NULL); for(i=0;ilen-1;i++) { if( asp->path[i]->link->twist == 1 ) { if( lexical == 0 ) { lexical = 1; } else { lexical = 0; } } if( asp->path[i+1]->link->left == asp->path[i]->link->left || asp->path[i+1]->link->right == asp->path[i]->link->left ) { next_node = asp->path[i]->link->left; prev_node = asp->path[i]->link->right; } else { next_node = asp->path[i]->link->right; prev_node = asp->path[i]->link->left; } base = lexical_last_base_from_kmer(next_node->dna_number, kmer_size, lexical); fprintf(ofp,"%d %d from %d to %d, Base %c\n",i, asp->path[i]->link, (int)prev_node, (int)next_node, base); } } %} wise-2.4.1/src/dnaindex/assembly/test_graphtangle.c0000644000175000001440000000512610117345737021764 0ustar philippusers#include "assemblygraph.h" #include "assembly_stream_fasta.h" #include "kmer_glib_index.h" #include "kmer_hash.h" #include "assemblystats.h" #include "graphtangle.h" void test_basic_tangle(char * filename,int kmer,int use_hash) { char buffer[120]; AssemblyGraph * ag; AssemblySequenceStream * as; Assembly * assem; FILE * ifp; KmerIndexInterface * kii; long int load; AssemblyPath * path; BaseNode * bn; BaseLink * link; int no; ifp = openfile(filename,"r"); assert(ifp); as = plain_fasta_AssemblySequenceStream(ifp); if( use_hash == 0 ) { kii = new_interface_KmerGlibIndex(kmer); } else { kii = new_KmerHashIndex(kmer); } ag = new_AssemblyGraph(kii,500); load = load_AssemblyGraph(ag,as); assert(load > 0); bn = ag->bg->start; /* show_BaseGraph(ag->bg,stderr);*/ while( bn != NULL ) { if( bn->link_len == 1 && (bn->link[0]->state & BaseLink_TANGLE_TOUCH) != BaseLink_TANGLE_TOUCH ) { /* start here */ fprintf(stderr,"Got a unique link! %d state %d\n",bn,bn->link[0]->state); bn->link[0]->state |= BaseLink_TANGLE_TOUCH; link = bn->link[0]; if(link->left == bn ) { bn = link->right; } else { bn = link->left; } /* walk along until we hit a tangle */ while( bn != NULL ) { no =next_link_if_unique_BaseLink(link,bn,&link); if( no > 1 ) { reverse_map_dna_number(bn->dna_number,ag->bg->kii->kmer_size,buffer); buffer[ag->bg->kii->kmer_size] = '\0'; fprintf(stderr,"Investigating tangle around %d [%s] with %d links\n",bn,buffer,bn->link_len); path = find_sequence_label_tangle_path(ag,link,bn); if( path == NULL ) { /* can't handle this - move on! */ bn = bn->next_node; break; } show_AssemblyPath(path,ag->bg->kii->kmer_size,stderr); bn = lift_tangled_AssemblyPath(ag,path); fprintf(stderr,"Finished lifting\n"); /* need to find the new node now */ free_AssemblyPath(path); fprintf(stderr,"handled tangle, new node %d\n",bn); } else if( no == 0 ) { bn = bn->next_node; break; } else { if(link->left == bn ) { bn = link->right; } else { bn = link->left; } /* fprintf(stderr,"Progressing! with link %d %ld\n",link,link->sequence_label[0]); */ } } } else { bn = bn->next_node; } } assem = Assembly_from_AssemblyGraph(ag); dump_contigs_as_fasta_Assembly(assem,stdout); } int main(int argc,char ** argv) { if( argc < 2 || atoi(argv[2]) < 0 ) { fprintf(stderr,"Must have kmer size\n"); exit(0); } test_basic_tangle(argv[1],atoi(argv[2]),1); return 0; } wise-2.4.1/src/dnaindex/assembly/grapherror.dy0000644000175000001440000001354210207066416020771 0ustar philippusers %{ #include "basegraph.h" #include "assemblypath.h" #define ReadPatchLISTLENGTH 50 #define PathEndPointsLISTLENGTH 16 #define PathEndSetLISTLENGTH 16 %} struct NodeHolder BaseNode * node !link struct ReadPatch NodeHolder ** nodes !list struct PathEndPoints ReadPatch ** patches !list BaseLink * start !link struct PathEndSet PathEndPoints ** ends !list struct GraphErrorPara int search_depth !def=30 int patch_len !def=5 int min_real !def=2 int max_error !def=2 %{ #include "grapherror.h" GraphErrorPara * new_GraphErrorPara_from_argv(int * argc,char ** argv) { GraphErrorPara * out; assert(argc != NULL); assert(argv != NULL); out = GraphErrorPara_alloc(); assert(out != NULL); out->search_depth = 30; out->patch_len = 5; out->min_real = 2; out->max_error = 2; strip_out_integer_argument(argc,argv,"er_length",&out->search_depth); strip_out_integer_argument(argc,argv,"er_indel",&out->patch_len); strip_out_integer_argument(argc,argv,"er_real_depth",&out->min_real); strip_out_integer_argument(argc,argv,"er_error_depth",&out->max_error); return out; } void show_help_GraphErrorPara(FILE * ofp) { fprintf(ofp,"Sequencing Error model\n"); fprintf(ofp," -er_length [30] maximum sequence search for errors\n"); fprintf(ofp," -er_indel [5] maximum indel size\n"); fprintf(ofp," -er_real_depth [2] minimum depth for real coverage\n"); fprintf(ofp," -er_error_depth [2] maximum depth for error\n"); } boolean find_error_and_mark_BaseNode(BaseNode * bn,GraphErrorPara * gep) { int i,j; PathEndSet * pes; assert(bn != NULL); assert(gep != NULL); assert(bn->link_len > 2); pes = PathEndSet_from_BaseNode(bn,gep->search_depth,gep->patch_len); for(i=0;ilen;i++) { if( (pes->ends[i]->start->state & BaseLink_IS_ERROR) == BaseLink_IS_ERROR ) { continue; } if( pes->ends[i]->start->sequence_label_len > gep->min_real ) { for(j=0;jlen;j++) { if( j == i || ((pes->ends[j]->start->state & BaseLink_IS_ERROR) == BaseLink_IS_ERROR) || pes->ends[j]->start->sequence_label_len > gep->max_error ) { continue; } if( PathEndPoints_agree(pes->ends[i],pes->ends[j]) ) { pes->ends[j]->start->state |= BaseLink_IS_ERROR; } } } } return TRUE; } PathEndSet * PathEndSet_from_BaseNode(BaseNode * bn,int target_depth,int patch_len) { int i; PathEndSet * out; assert(bn != NULL); out = PathEndSet_alloc_std(); for(i=0;ilink_len;i++) { fprintf(stderr," ... making path around %d\n",bn->link[i]); add_PathEndSet(out,PathEndPoints_from_link(bn->link[i],bn,target_depth,patch_len)); } return out; } boolean PathEndPoints_agree(PathEndPoints * a,PathEndPoints * b) { int i; int j; int ii; int jj; for(i=0;ilen;i++) { for(j=0;jlen;j++) { for(ii=0; iipatches[i]->len ;ii++) { for(jj=0; jjpatches[j]->len ;jj++) { if( a->patches[i]->nodes[ii]->node == b->patches[j]->nodes[jj]->node ) { return TRUE; } } } } } return FALSE; } boolean extend_ReadPatch(PathEndPoints * out,int target_depth,int patch_len,int curr_depth,BaseLink * link,BaseNode * node,AssemblyPath * upstream,int recurse) { ReadPatch * rp; BaseNode * next_node; int no; int i; assert(link != NULL); if( BaseLink_in_AssemblyPath(link,upstream) == TRUE ) { return FALSE; } if( recurse > 3 ) { return FALSE; } /* fprintf(stderr,"Looking at potential error around link %d %d (%d)\n",(int)link,node,node->link_len); */ if( (link->state & BaseLink_IS_CYCLE) == BaseLink_IS_CYCLE ) { return FALSE; } add_AssemblyPath(upstream,new_PathStep(link)); while( curr_depth < target_depth ) { no = next_link_if_unique_BaseLink(link,node,&link); if( no == 1 ) { if( BaseLink_in_AssemblyPath(link,upstream) == TRUE ) { /* cannot work through loops at the moment */ return TRUE; } add_AssemblyPath(upstream,new_PathStep(link)); curr_depth++; if( link->left == node ) { node = link->right; } else { assert(link->right == node); node = link->left; } continue; } if( no == 0 ) { /* end of read before patch length */ return TRUE; } /* multiple links - recurse into all of these */ curr_depth++; for(i=0;ilink_len;i++) { if( link != node->link[i] ) { if( node->link[i]->left == node ) { next_node = node->link[i]->right; } else { assert(node->link[i]->right == node); next_node = node->link[i]->left; } /* fprintf(stderr," ..Recurse call\n");*/ extend_ReadPatch(out,target_depth,patch_len,curr_depth,node->link[i],next_node,upstream,++recurse); } } /* end of recursion in, so return */ return TRUE; } /* hit target depth - put in nodes */ rp = ReadPatch_alloc_std(); add_PathEndPoints(out,rp); while( curr_depth < target_depth+patch_len ) { no = next_link_if_unique_BaseLink(link,node,&link); if( no == 1 ) { curr_depth++; if( link->left == node ) { node = link->right; } else { assert(link->right == node); node = link->left; } add_ReadPatch(rp,new_NodeHolder(node)); continue; } else { return TRUE; } } return TRUE; } PathEndPoints * PathEndPoints_from_link(BaseLink * l,BaseNode * prev_node,int target_depth,int patch_len) { BaseNode * curr; PathEndPoints * out; AssemblyPath * p; out = PathEndPoints_alloc_std(); out->start = l; if( l->left == prev_node ) { curr = l->right; } else { assert(l->right == prev_node); curr = l->left; } p = AssemblyPath_alloc_std(); fprintf(stderr,"First call to extend\n"); extend_ReadPatch(out,target_depth,patch_len,0,l,curr,p,0); free_AssemblyPath(p); return out; } NodeHolder * new_NodeHolder(BaseNode * n) { NodeHolder * out; out = NodeHolder_alloc(); out->node = n; return out; } %} wise-2.4.1/src/dnaindex/assembly/graphtangle.dy0000644000175000001440000003740610207066416021117 0ustar philippusers %{ #include "assemblygraph.h" #include "assemblypath.h" #define MAX_TANGLE_LINK_SIZE 2048 typedef struct CycleBaseLink { int possible; BaseLink * next_link; BaseNode * prev_node; int new_depth; } CycleBaseLink; %} %{ #include "graphtangle.h" BaseNode * lift_tangled_AssemblyPath(AssemblyGraph * ag,AssemblyPath * ap) { int i,k,j; BaseNode * new_node; BaseNode * prev_node; BaseNode * old_prev; BaseNode * parent; BaseLink * new_link; BaseNode ** outgoing; BaseNode * ret; BaseNode * temp; BaseNode * temp_new; assert(ap != NULL); /* every tangled path must have two links - its first and last */ assert(ap->len > 1); assert(ag != NULL); /* first node we don't need to make a new link */ /* find the node going into the path */ if( ap->path[0]->link->left == ap->path[1]->link->left || ap->path[0]->link->left == ap->path[1]->link->right ) { parent = ap->path[0]->link->left; outgoing = &ap->path[0]->link->left; } else { assert((ap->path[0]->link->right == ap->path[1]->link->left || ap->path[0]->link->right == ap->path[1]->link->right)); parent = ap->path[0]->link->right; outgoing = &ap->path[0]->link->right; } new_node = new_BaseNode(&ag->bg->curr_end->next_node,parent->dna_number); assert(new_node != NULL); ag->bg->curr_end = new_node; parent->peer_node = new_node; ret = new_node; /* fprintf(stderr,"First node is %d new node %d\n",parent,new_node);*/ prev_node = new_node; old_prev = parent; add_BaseLink_BaseNode(new_node,ap->path[0]->link); /* we have to also remove the first link, but we need to delay it after the main loop; this is because to be able to determine the order of the links, we need to old_prev with the old link in it Set this to temp, and do it at the end. */ temp = parent; temp_new = new_node; for(i=1;ilen-1;i++) { /* figure out which one is the old prev node, and which one is the new node */ /* fprintf(stderr,"adjusting links for %d (%d) to %d (%d): old %d\n", ap->path[i]->link->left, ap->path[i]->link->left->link_len, ap->path[i]->link->right, ap->path[i]->link->right->link_len, old_prev ); */ if( ap->path[i]->link->left == old_prev ) { parent = ap->path[i]->link->right; } else { if( ap->path[i]->link->right != old_prev ) { fprintf(stderr,"Error in path link %d, old is %d\n",i,(int)old_prev); show_AssemblyPath(ap,ag->bg->kii->kmer_size,stderr); } assert(ap->path[i]->link->right == old_prev); parent = ap->path[i]->link->left; } /* duplicate parent node */ new_node = new_BaseNode(&ag->bg->curr_end->next_node,parent->dna_number); assert(new_node != NULL); ag->bg->curr_end = new_node; parent->peer_node = new_node; /* make new link these two nodes */ new_link = new_BaseLink(prev_node,new_node,ap->path[i]->link->twist); /* adjust prev */ prev_node = new_node; old_prev = parent; /* transfer sequence labels across */ for(k=0;kpath[i]->link->sequence_label_len;k++) { for(j=0;jseq_len;j++) { if( ap->path[i]->link->sequence_label[k] + (i - ap->seq[j]->start_depth) == ap->seq[j]->start || ap->path[i]->link->sequence_label[k] - (i - ap->seq[j]->start_depth) == ap->seq[j]->start ) { /* delete from current link, add to new link */ assert(remove_Sequence_BaseLink(ap->path[i]->link,ap->path[i]->link->sequence_label[k])); assert(add_Sequence_BaseLink(new_link,ap->path[i]->link->sequence_label[k])); } } } /* fprintf(stderr," ...left %d sequence labels\n",ap->path[i]->link->sequence_label_len); */ } /* fprintf(stderr,"Last node: adjusting links for %d (%d) to %d (%d) (old prev: %d)\n", ap->path[i]->link->left, ap->path[i]->link->left->link_len, ap->path[i]->link->right, ap->path[i]->link->right->link_len,old_prev ); */ /* last link, don't need to make new link, just attach it the right end of the link to the prev_node */ if( ap->buried_end == 0 ) { if( ap->path[i]->link->left == old_prev ) { /* fprintf(stderr,"At last tangle, removing %d and adding %d\n",ap->path[i]->link->left,prev_node); */ assert(remove_BaseLink_BaseNode(ap->path[i]->link->left,ap->path[i]->link)); ap->path[i]->link->left = prev_node; } else { /* fprintf(stderr,"At last tangle, removing %d and adding %d\n",ap->path[i]->link->right,prev_node); */ assert(remove_BaseLink_BaseNode(ap->path[i]->link->right,ap->path[i]->link)); ap->path[i]->link->right = prev_node; } } else { warn("EWAN HAS NOT DELT PROPERLEY WITH BURIED END LIFT"); /* leave the last node open */ } /* connect up the old/new cases */ add_BaseLink_BaseNode(prev_node,ap->path[i]->link); /* handle the first link */ /* fprintf(stderr,"handling %d as the first node\n",temp); */ remove_BaseLink_BaseNode(temp,ap->path[0]->link); *outgoing = temp_new; /*fprintf(stderr,"Last new node was %d with %d links\n",prev_node,prev_node->link_len);*/ return ret; } AssemblyPath * find_sequence_label_tangle_path(AssemblyGraph * ag,BaseLink * first,BaseNode * next) { BaseLink * link; SinglePosSequence * sps; AssemblyPath * out; PathSeq * s; int depth; int i,k; int non_error_cycle_link; CycleBaseLink cycle; assert(ag != NULL); assert(first != NULL); assert(next != NULL); assert(next->link_len > 2 ); /* Basic logic here is: We should have been passed a node with more than two links and one of them is an incoming link. We track the sequence labels of the incoming link. When we get to > 2 link positions, *all* the incoming links have to take one route. After a > 2 link position, if the resulting link only has are starting position labels and labels which originated during the tangle, then we have resolved the tangle */ /* store starting labels in AssemblyPath structure */ out = AssemblyPath_alloc_std(); for(i=0;isequence_label_len;i++) { sps = lookup_Sequence_SinglePosSpace(ag->sp,first->sequence_label[i]); assert(sps); s = new_PathSeq(first->sequence_label[i],0,sps->start,(AssemblySequence*)sps->data); /* fprintf(stderr,"For label %d in first link %d, sequence label is %ld vs %ld\n",i,first,s->start,first->sequence_label[i]); */ s->state |= PathSeq_START_OF_TANGLE; add_seq_AssemblyPath(out,s); } /* now look at next set of links, seeing whether all START of tangle labels make it into the next link */ depth = 1; link = first; while ( 1 ) { /* fprintf(stderr,"Looking into tangle, depth %d, link %d next %d\n",depth,link,next); show_BaseLink(ag->bg,link,stderr); */ add_AssemblyPath(out,new_PathStep(link)); non_error_cycle_link = non_error_link_BaseNode(next); /* fprintf(stderr,"Non error number next is %d\n",non_error_or_cycle_link_BaseNode(next));*/ if( non_error_cycle_link > 2 ) { if( 0 && (BaseNode_is_cyclical(ag->bg,next) == TRUE || (link->state & BaseLink_IS_DICYCLE)) ) { fprintf(stderr,"CYCLE!\n"); cycle = get_next_tangled_link_through_cycle(out,depth,next,link); if( cycle.possible == 0 && (link->state & BaseLink_IS_DICYCLE) ) { fprintf(stderr,"FLIP out DICYCLE\n"); if( link->left == next ) { cycle = get_next_tangled_link_through_cycle(out,depth,link->right,link); } else { assert(link->right == next); cycle = get_next_tangled_link_through_cycle(out,depth,link->left,link); } if( cycle.possible == 1 ) { /* we've found an exit on the other end of the dicycle link. Put in this link into the assembly path now */ add_AssemblyPath(out,new_PathStep(link)); } } if( cycle.possible == 0 ) { fprintf(stderr," ... cannot resolve tangle through cycle\n"); show_BaseNode(ag->bg,next,stderr); free_AssemblyPath(out); return NULL; } else { fprintf(stderr,"... is possible, cycle %d, link %d\n",cycle.possible,cycle.next_link); assert(cycle.next_link); assert(cycle.new_depth >= depth); depth = cycle.new_depth; link = cycle.next_link; } } else { /* fprintf(stderr,"Non cycle tangle!\n"); */ link = get_next_tangled_link(out,depth,next,link); if( link == NULL ) { warn("Bad problem: can't resolve tangle"); fprintf(stderr," ... cannot resolve tangle, no cycle\n"); show_BaseNode(ag->bg,next,stderr); free_AssemblyPath(out); return NULL; } } if( is_end_tangle_link(out,link,depth) ) { warn("EWAN HAS NOT DELT WITH FLAGGING THE CORRECT STARTING READS IN THE TANGLE"); add_AssemblyPath(out,new_PathStep(link)); fprintf(stderr," ... successful path\n"); return out; } else { /* move along */ if( link->left == next ) { next = link->right; } else { next = link->left; } depth++; continue; } } if( non_error_cycle_link < 2 ) { /* ending at the end of a contig */ out->buried_end = 1; return out; } assert( next_link_if_error_unique_BaseLink(link,next,&link) == 1); /* look for ends of sequences */ for(i=0;iseq_len;i++) { if( (out->seq[i]->start & PathSeq_START_OF_TANGLE) != PathSeq_START_OF_TANGLE ) { continue; } for(k=0;ksequence_label_len;k++) { if( out->seq[i]->start + depth == link->sequence_label[k] || out->seq[i]->start - depth == link->sequence_label[k] ) { break; } } if( k >= link->sequence_label_len ) { out->seq[i]->state |= PathSeq_END_INTERNAL; } } /* look for potential starts of sequences */ for(k=0;ksequence_label_len;k++) { sps = lookup_Sequence_SinglePosSpace(ag->sp,link->sequence_label[k]); if( link->sequence_label[k] == sps->start || (link->sequence_label[k] == sps->start + ((AssemblySequence*)sps->data)->seq->len) ) { /* potential internal start */ s = new_PathSeq(link->sequence_label[k],depth,sps->start,(AssemblySequence*)sps->data); s->state |= PathSeq_START_INTERNAL; add_seq_AssemblyPath(out,s); } } /* advance to next */ if( link->left == next ) { next = link->right; } else { next = link->left; } depth++; } return out; } boolean is_end_tangle_link(AssemblyPath * ap,BaseLink * link,int depth) { int i; int j; /* the question we are asking here is: Are all the labels of the link *either* from the start position or potentially created on route */ for(i=0;isequence_label_len;i++) { for(j=0;jseq_len;j++) { if( ap->seq[j]->start + (depth - ap->seq[j]->start_depth) == link->sequence_label[i] || ap->seq[j]->start - (depth - ap->seq[j]->start_depth) == link->sequence_label[i] ) { break; } } if( j >= ap->seq_len ) { /* there is a label here which did not either start before the tangle nor did it start in the tangle - therefore it is a bad label! */ return FALSE; } } return TRUE; } BaseLink * jump_move_tangle(AssemblyPath * ap,BaseLink * current,int jump) { int i; int j; int max_dis; /* * Find jump-move across graph by finding the sequence with * the longest remaining sequence, and then jump using this * into a new space */ for(i=0;iseq_len;i++) { } fatal("Ewan has not implemented jump moves!"); return NULL; } boolean BaseNode_is_cyclical(BaseGraph * bg,BaseNode * bn) { int i; assert(bn); char buffer_l[256]; char buffer_r[256]; for(i=0;ilink_len;i++) { reverse_map_dna_number(bn->link[i]->left->dna_number,bg->kii->kmer_size,buffer_l); reverse_map_dna_number(bn->link[i]->right->dna_number,bg->kii->kmer_size,buffer_r); buffer_l[bg->kii->kmer_size] = '\0'; buffer_r[bg->kii->kmer_size] = '\0'; /* fprintf(stderr,"Testing link %d state %d %d %s %s\n",i,bn->link[i]->state,bn->link[i],buffer_l,buffer_r); */ if( (bn->link[i]->state & BaseLink_IS_CYCLE) == BaseLink_IS_CYCLE ) { return TRUE; } } return FALSE; } CycleBaseLink get_next_tangled_link_through_cycle(AssemblyPath * ap,int depth,BaseNode * node,BaseLink * prev_link) { int i,j,k; CycleBaseLink out; int found_seq = 0; long int diff; assert(ap != NULL); assert(node != NULL); assert(prev_link != NULL); /* Links here will be cyclical. Basically we need to look at the links which fit the *sequences* that we have, not their sequence positions. Only 2 non-cyclical links should exist; one should be prev_link. We take the other one, and then adjust the depth to handle the number of cycles we've been through */ out.next_link = NULL; out.possible = 0; for(i=0;ilink_len;i++) { fprintf(stderr,"... cycle testing %d... %d %d\n",i,out.possible,out.next_link); if( (node->link[i]->state & BaseLink_IS_CYCLE) == BaseLink_IS_CYCLE ) { continue; } /* if( node->link[i] == prev_link ) { continue; } */ fprintf(stderr,"investigating\n"); found_seq = 0; for(j=0;jlink[i]->sequence_label_len;j++) { for(k=0;kseq_len;k++) { if( (ap->seq[k]->state & PathSeq_START_OF_TANGLE) != PathSeq_START_OF_TANGLE) { continue; } diff = (int)labs(node->link[i]->sequence_label[j] - ap->seq[k]->start); fprintf(stderr,"Looking at sequence %d, start %d, label %ld (%ld) vs %d Diff %d Depth %d\n", k, ap->seq[k]->start, node->link[i]->sequence_label[j], node->link[i]->sequence_label[j] - ap->seq[k]->base_zero, ap->seq[k]->aseq->seq->len, diff, depth); if( diff < depth + 100 && diff >= depth ) { if( out.next_link != NULL ) { fprintf(stderr,"Found a second link\n"); out.next_link = NULL; out.possible = 0; return out; } out.new_depth = (int)((labs(node->link[i]->sequence_label[j] - ap->seq[k]->start) - ap->seq[k]->start_depth)); out.next_link = node->link[i]; out.possible = 1; found_seq = 1; break; } } if( found_seq == 1 ) { break; } } } fprintf(stderr,"Going to return with %d %d\n",out.possible,out.next_link); return out; } BaseLink * get_next_tangled_link(AssemblyPath * ap,int depth,BaseNode * node,BaseLink * prev_link) { int i,k,j; BaseLink * ret = NULL; int link_no; assert(ap != NULL); assert(node != NULL); assert(prev_link != NULL); /* now look at each link, and see if one label goes into this position in the link. If so check we have not seen a link already - if we have, then return NULL (meaning there is no good path). */ fprintf(stderr," Attempting to untangle a node with %d links\n",node->link_len); for(i=0;ilink_len;i++) { /* start by setting to 0 */ if( node->link[i] == prev_link ) { continue; } for(k=0;klink[i]->sequence_label_len;k++) { for(j=0;jseq_len;j++) { if( (ap->seq[j]->state & PathSeq_START_OF_TANGLE) != PathSeq_START_OF_TANGLE) { continue; } /* fprintf(stderr,"For link %d -> %ld (%ld %ld), looking at label match %d,%d %ld vs %ld from %ld, depth %d\n",i, node->dna_number, node->link[i]->left->dna_number, node->link[i]->right->dna_number, k,j, node->link[i]->sequence_label[k], ap->seq[j]->start, node->link[i]->sequence_label[k]- ap->seq[j]->start,depth ); */ if( node->link[i]->sequence_label[k] + depth == ap->seq[j]->start || node->link[i]->sequence_label[k] - depth == ap->seq[j]->start ) { fprintf(stderr,"For link %d, got match on label %d %ld with depth %d vs %ld from %d\n",i,k, node->link[i]->sequence_label[k], depth, ap->seq[j]->start,j); if( ret != NULL ) { /* two outgoing links for the inputs */ fprintf(stderr,"Two links: old %d new %d\n",link_no,i); return NULL; } else { link_no = i; ret = node->link[i]; } break; } } if( j < ap->seq_len ) { break; /* no need to investigate more labels */ } } } /* fprintf(stderr,"all links have exhausted\n");*/ return ret; } %} wise-2.4.1/src/dnaindex/assembly/supertangle.dy0000644000175000001440000001363710123601042021137 0ustar philippusers %{ #include "basegraph.h" #include "assemblypath.h" #include "assemblygraph.h" #define SuperTangleLISTLENGTH 128 #define SuperTangleDistanceSetLISTLENGTH 256 %} struct SuperTangleUnique BaseNode * node !link BaseLink * link !link struct SuperTangle SuperTangleUnique ** stu !list struct SuperTangleDistance int dis; SuperTangleUnique * left !link SuperTangleUnique * right !link struct SuperTangleDistanceSet SuperTangleDistance ** std !list %{ #include "supertangle.h" SuperTangleDistance * new_SuperTangleDistance(AssemblyGraph * ag,SuperTangleUnique * a,SuperTangleUnique * b) { SuperTangleDistance * out = NULL; int i; int j; SinglePosSequence * sps_a; SinglePosSequence * sps_b; int min = 1000; long int dis = 0; int seen = 0; for(i=0;ilink->sequence_label_len;i++) { sps_a = lookup_Sequence_SinglePosSpace(ag->sp,a->link->sequence_label[i]); for(j=0;jlink->sequence_label_len;j++) { /* without getting out any sequences, we know long distances wont count */ dis = labs(a->link->sequence_label[i] - b->link->sequence_label[j]); if( dis > 1000 ) { continue; } sps_b = lookup_Sequence_SinglePosSpace(ag->sp,b->link->sequence_label[j]); if( sps_a != sps_b ) { continue; } assert(sps_a != NULL); seen = 1; if( dis < min && dis < 1000 ) { min = (int)dis; } } } if( seen == 1 ) { out = SuperTangleDistance_alloc(); out->dis = (int)min; out->left = a; out->right = b; } else { /* fprintf(stderr,"Not making a distance\n");*/ } return out; } int insert_conservative_jump_nodes_SuperTangleDistanceSet(SuperTangleDistanceSet * stds,int max_depth) { int count = 0; BaseLink * new; int i; int j; int pure; for(i=0;ilen;i++) { /* consider this as a jump-link. Don't put it it in until we have checked there is no other possible forward or backward cases */ pure = 1; for(j=0;jlen;j++) { if( stds->std[i]->left == stds->std[j]->left || stds->std[i]->left == stds->std[j]->right || stds->std[i]->right == stds->std[j]->left || stds->std[i]->right == stds->std[j]->right ) { pure = 0; break; } } fatal("Ewan has not implemented any more of this supertangle stuff!\n"); } return 0; } SuperTangleDistanceSet * new_SuperTangleDistanceSet(AssemblyGraph * ag,SuperTangle * st) { SuperTangleDistanceSet * out; int i; int j; SuperTangleDistance * std; out = SuperTangleDistanceSet_alloc_std(); for(i=0;ilen;i++) { for(j=i+1;jlen;j++) { std = new_SuperTangleDistance(ag,st->stu[i],st->stu[j]); if( std != NULL ) { add_SuperTangleDistanceSet(out,std); } } } return out; } int compare_SuperTangleDistance(SuperTangleDistance * a,SuperTangleDistance * b) { return (a->dis - b->dis); } void sort_dis_SuperTangleDistanceSet(SuperTangleDistanceSet * stds) { sort_SuperTangleDistanceSet(stds,compare_SuperTangleDistance); return; } void show_SuperTangleDistanceSet(SuperTangleDistanceSet * stds,FILE * ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp," %d Distance %d to %d %d\n",i,stds->std[i]->left,stds->std[i]->right,stds->std[i]->dis); } } SuperTangle * new_seeded_SuperTangle(BaseNode * bn,int max_depth) { SuperTangle * out; AssemblyPath * ap; BaseNode * next; int i; out = SuperTangle_alloc_std(); ap = AssemblyPath_alloc_std(); for(i=0;ilink_len;i++) { if( bn->link[i]->left == bn ) { next = bn->link[i]->right; } else { next = bn->link[i]->left; } recurse_into_SuperTangle(out,next,bn->link[i],ap,0,max_depth); } free_AssemblyPath(ap); return out; } SuperTangleUnique * new_SuperTangleUnique(BaseNode * bn,BaseLink * bl) { SuperTangleUnique * out; assert(bn != NULL); assert(bl != NULL); out = SuperTangleUnique_alloc(); out->node = bn; out->link = bl; return out; } boolean recurse_into_SuperTangle(SuperTangle * st,BaseNode * bn,BaseLink * bl,AssemblyPath * visited,int curr_depth,int max_depth) { int i; int bad_link = 0; BaseLink * unique = NULL; BaseNode * next; boolean ret = TRUE; assert(st != NULL); assert(bn != NULL); assert(bl != NULL); assert(visited != NULL); if( curr_depth >= max_depth ) { return FALSE; } if( BaseLink_in_AssemblyPath(bl,visited) == TRUE ) { return TRUE; } /* fprintf(stderr,"recursing in from %d\n",bl);*/ for(i=0;ilink_len;i++) { if( bn->link[i] == bl ) { continue; } if( BaseLink_in_AssemblyPath(bn->link[i],visited) ) { continue; } if( (bn->link[i]->state & (BaseLink_IS_CYCLE | BaseLink_IS_DICYCLE) ) ) { bad_link = 1; break; } else { /* a potentialy unique link */ if( unique != NULL) { /* two of them - recurse further */ bad_link = 1; break; } else { unique = bn->link[i]; } } } add_AssemblyPath(visited,new_PathStep(bl)); if( bad_link == 1 || unique == NULL ) { curr_depth++; for(i=0;ilink_len;i++) { if( bn->link[i] == bl ) { continue; } if( BaseLink_in_AssemblyPath(bn->link[i],visited) ) { continue; } bn->link[i]->state |= BaseLink_SUPERTANGLE; if( bn->link[i]->left == bn ) { next = bn->link[i]->right; } else { assert(bn->link[i]->right == bn); next = bn->link[i]->left; } if( recurse_into_SuperTangle(st,next,bn->link[i],visited,curr_depth,max_depth) == FALSE ) { ret = FALSE; } } } else { /* fprintf(stderr,"Adding unique %d\n",unique); */ add_AssemblyPath(visited,new_PathStep(unique)); add_SuperTangle(st,new_SuperTangleUnique(bn,unique)); } return ret; } void show_SuperTangle(BaseGraph * bg,SuperTangle * st,FILE * ofp) { int i; fprintf(stderr,"SuperTangle with %d unique ends\n",st->len); for(i=0;ilen;i++) { show_BaseLink(bg,st->stu[i]->link,ofp); } } %} wise-2.4.1/src/dnaindex/assembly/makefile0000644000175000001440000000542210207066416017756 0ustar philippusers .SUFFIXES : .dy test_basegraph : test_basegraph.o basegraph.o $(CC) -o test_basegraph test_basegraph.o basegraph.o ../dnamapping.o ../kmer_index_interface.o ../kmer_glib_index.o $(LFLAGS) -ldyna -lwisebase test_assemblygraph : test_assemblygraph.o assemblygraph.o assemblystats.o basegraph.o $(CC) -o test_assemblygraph test_assemblygraph.o assemblystats.o basegraph.o assemblygraph.o ../dnamapping.o ../kmer_index_interface.o ../kmer_glib_index.o ../kmer_hash.o ../assembly.o ../assembly_stream_fasta.o ../largeseqreader.o ../singleseqspace.o ../assembly_stream_interface.o $(LFLAGS) -ldyna -lwisebase test_graphtangle : test_graphtangle.o assemblygraph.o assemblystats.o basegraph.o graphtangle.o assemblypath.o $(CC) -o test_graphtangle test_graphtangle.o assemblystats.o basegraph.o assemblygraph.o graphtangle.o assemblypath.o ../dnamapping.o ../kmer_index_interface.o ../kmer_glib_index.o ../assembly.o ../assembly_stream_fasta.o ../largeseqreader.o ../singleseqspace.o ../assembly_stream_interface.o ../kmer_hash.o $(LFLAGS) -ldyna -lwisebase pathwise : pathwise.o supertangle.o assemblygraph.o assemblystats.o basegraph.o graphtangle.o assemblypath.o grapherror.o graphmanager.o depthmanager.o $(CC) -o pathwise pathwise.o supertangle.o depthmanager.o assemblystats.o basegraph.o assemblygraph.o ../dnamapping.o ../kmer_index_interface.o graphtangle.o assemblypath.o grapherror.o graphmanager.o ../kmer_glib_index.o ../kmer_hash.o ../assembly.o ../assembly_stream_fasta.o ../largeseqreader.o ../singleseqspace.o ../assembly_stream_interface.o ../assembly_sanger_project.o $(LFLAGS) -ldyna -lwisebase badkmer : badkmer.o assemblygraph.o assemblystats.o basegraph.o $(CC) -o badkmer badkmer.o assemblystats.o basegraph.o assemblygraph.o ../dnamapping.o ../kmer_index_interface.o ../kmer_glib_index.o ../kmer_hash.o ../assembly.o ../assembly_stream_fasta.o ../largeseqreader.o ../singleseqspace.o ../assembly_stream_interface.o $(LFLAGS) -ldyna -lwisebase arraymatcher : arraymatcher.o assemblygraph.o assemblystats.o basegraph.o $(CC) -o arraymatcher arraymatcher.o assemblystats.o basegraph.o assemblygraph.o ../dnamapping.o ../kmer_index_interface.o ../kmer_glib_index.o ../kmer_hash.o ../assembly.o ../assembly_stream_fasta.o ../largeseqreader.o ../singleseqspace.o ../assembly_stream_interface.o $(LFLAGS) -ldyna -lwisebase CC = cc CFLAGS = -Wall -pthread -c -DHAS_PTHREAD_SETSCOPE -g -DUNIX -I../../base/ -I../../dynlibsrc/ -I../ -I../../models/ `glib-config --cflags` LFLAGS = -g -L../../base/ -L../../dynlibsrc/ -lpthread `glib-config --libs` -lm .c.o : $(CC) $(CFLAGS) $(INCFLAGS) $? INCFLAGS = -I../base/ -I../dynlibsrc/ DFLAGS = -l -n Wise2_ -pthreads -dbtrace 5 -nocwarn .dy.c : dyc $(DFLAGS) $< .dy.o : dyc $(DFLAGS) $< $(CC) $(CFLAGS) $*.c init : dyc $(DFLAGS) *.dy wise-2.4.1/src/dnaindex/assembly/assemblystats.dy0000644000175000001440000000303610116325025021502 0ustar philippusers %{ #include "assemblygraph.h" %} struct AssemblyGraphStats long int node_count long int link_count long int node_link[256] long int link_depth[256] %{ #include "assemblystats.h" AssemblyGraphStats * new_AssemblyGraphStats(AssemblyGraph * ag) { BaseNode * bn; int i; AssemblyGraphStats * out; out = AssemblyGraphStats_alloc(); out->node_count = 0; out->link_count = 0; for(i=0;i < 256;i++) { out->node_link[i] = 0; out->link_depth[i] = 0; } bn = ag->bg->start; while( bn != NULL ) { out->node_count++; out->link_count += bn->link_len; if( bn->link_len < 255 ) { out->node_link[bn->link_len]++; } else { out->node_link[255]++; } for(i=0;ilink_len;i++) { if( bn->link[i]->sequence_label_len < 255 ) { out->link_depth[bn->link[i]->sequence_label_len]++; } else { out->link_depth[255]++; } } bn = bn->next_node; } return out; } void show_AssemblyGraphStats(AssemblyGraphStats * st,int node_report,int link_report,FILE * ofp) { int i; assert(st != NULL); assert(ofp != NULL); fprintf(ofp,"Nodes %ld Links %ld (%.2f)\n",st->node_count,st->link_count,(double)st->link_count/(double)st->node_count); for(i=0;inode_link[i],100.0*(double)st->node_link[i]/(double)st->node_count); } for(i=0;ilink_depth[i],100.0*(double)st->link_depth[i]/(double)st->link_count); } } %} wise-2.4.1/src/dnaindex/assembly/test_basegraph.c0000644000175000001440000000312510116325025021404 0ustar philippusers#include "basegraph.h" #include "kmer_glib_index.h" int test_basic_data(void) { int i; BaseLink * bl; BaseNode * bn_a; BaseNode * bn_b; BaseNode * st = NULL; bn_a = new_BaseNode(&st,456); bn_b = new_BaseNode(&bn_a->next_node,67); for(i=0;i<56;i++) { bl = new_BaseLink(bn_a,bn_b,1); } for(i=0;i<412;i++) { add_Sequence_BaseLink(bl,78); } assert(bn_a->next_node == bn_b); assert(bn_a->link_len == 56); assert(bn_b->link_len == 56); assert(bl->sequence_label_len == 412); assert(bl->sequence_label[77] == 78); fprintf(stdout,"basic data tests successful\n"); return 0; } int test_graph(void) { KmerIndexInterface * kii; BaseGraph * bg; BaseNode * bn; BaseLink * bl_1; BaseLink * bl_2; kii = new_interface_KmerGlibIndex(9); bg = new_BaseGraph(kii); insert_seqpos_BaseGraph(bg,1445,678,1,56); insert_seqpos_BaseGraph(bg,1445,678,1,57); insert_seqpos_BaseGraph(bg,678,43677,0,78); fprintf(stdout,"basic graph tests successful\n"); bn = retrieve_BaseNode(bg,1445); assert(bn->link_len == 1); assert(bn->link[0]->sequence_label_len == 2); assert(bn->link[0]->twist == 1); bn = retrieve_BaseNode(bg,678); assert(bn->link_len == 2); bl_1 = bn->link[0]; assert(next_link_if_unique_BaseLink(bl_1,bn,&bl_2) == 1); assert( (bl_1->sequence_label_len == 2 && bl_2->sequence_label_len == 1) || (bl_1->sequence_label_len == 1 && bl_2->sequence_label_len == 2) ); fprintf(stdout,"link following tests successful\n"); return 0; } int main(int argc,char ** argv) { test_basic_data(); test_graph(); return 0; } wise-2.4.1/src/dnaindex/assembly/graphmanager.dy0000644000175000001440000001105410207066416021246 0ustar philippusers %{ #include "graphtangle.h" #include "grapherror.h" #include "depthmanager.h" #include "supertangle.h" %} %{ #include "graphmanager.h" int find_di_cycles_AssemblyGraph(AssemblyGraph * ag) { BaseNode * bn; int i,j,k; int count = 0; int is_cyc = 0; assert(ag != NULL); for(bn=ag->bg->start;bn != NULL;bn = bn->next_node ) { for(i=0;ilink_len;i++) { is_cyc = 0; for(j=0;jlink[i]->sequence_label_len && is_cyc == 0;j++) { for(k=j+1;klink[i]->sequence_label_len && is_cyc == 0;k++) { if( abs(bn->link[i]->sequence_label[j] - bn->link[i]->sequence_label[k]) == 1 ) { bn->link[i]->state |= BaseLink_IS_DICYCLE; count++; is_cyc = 1; break; } } } } } return count; } int find_single_cycles_AssemblyGraph(AssemblyGraph * ag) { BaseNode * bn; int i; int count = 0; assert(ag != NULL); for(bn=ag->bg->start;bn != NULL;bn = bn->next_node ) { for(i=0;ilink_len;i++) { if( bn == bn->link[i]->left && bn == bn->link[i]->right ) { bn->link[i]->state |= BaseLink_IS_CYCLE; count++; } } } return count; } int find_and_jump_supertangles_AssemblyGraph(AssemblyGraph * ag) { SuperTangle * st; SuperTangleDistanceSet * stds; BaseNode * bn; int i; int count = 0; assert(ag != NULL); for(bn=ag->bg->start;bn != NULL;bn = bn->next_node ) { for(i=0;ilink_len;i++) { if( bn == bn->link[i]->left && (bn->link[i]->state & (BaseLink_IS_CYCLE | BaseLink_IS_DICYCLE)) && !(bn->link[i]->state & BaseLink_SUPERTANGLE) ) { fprintf(stderr,"Found potential supertangle %d\n",bn); st = new_seeded_SuperTangle(bn,50); show_SuperTangle(ag->bg,st,stderr); stds = new_SuperTangleDistanceSet(ag,st); sort_dis_SuperTangleDistanceSet(stds); show_SuperTangleDistanceSet(stds,stderr); count++; free_SuperTangle(st); } } } return count; } int find_and_resolve_tangles_AssemblyGraph(AssemblyGraph * ag) { return find_and_resolve_tangles_AssemblyGraph_Para(ag,NULL,0); } int find_and_resolve_tangles_AssemblyGraph_Para(AssemblyGraph * ag,DepthPara * dp,boolean use_depth) { BaseNode * bn; BaseLink * baselink; AssemblyPath * path; int no; int i; int count = 0; bn = ag->bg->start; while( bn != NULL ) { if( use_depth == FALSE && bn->link_len > 1 ) { bn = bn->next_node; continue; } if( use_depth == TRUE && bn->link_len == 2 ) { bn = bn->next_node; continue; } for(i=0;ilink_len;i++) { if( bn->link[i]->state & BaseLink_TANGLE_TOUCH ) { continue; } if( use_depth == TRUE && bn->link[i]->sequence_label_len > dp->max_depth ) { continue; } bn->link[i]->state |= BaseLink_TANGLE_TOUCH; baselink = bn->link[i]; if(baselink->left == bn ) { bn = baselink->right; } else { bn = baselink->left; } /* walk along until we hit a tangle */ while( bn != NULL ) { no = next_link_if_error_or_cycle_unique_BaseLink(baselink,bn,&baselink); if( no > 1 ) { /* reverse_map_dna_number(bn->dna_number,ag->bg->kii->kmer_size,buffer); buffer[ag->bg->kii->kmer_size] = '\0'; fprintf(stderr,"Investigating tangle around %d [%s] with %d baselinks\n",bn,buffer,bn->link_len); */ path = find_sequence_label_tangle_path(ag,baselink,bn); if( path == NULL ) { /* can't handle this - move on! */ fprintf(stderr,"Failure!\n"); break; } count++; /* fprintf(stderr," Handling a path %d from link %d\n",use_depth,baselink); show_AssemblyPath(path,ag->bg->kii->kmer_size,stderr); */ bn = lift_tangled_AssemblyPath(ag,path); fprintf(stderr,"Success!\n"); /* need to find the new node now */ free_AssemblyPath(path); fprintf(stderr,"handled tangle, new node %d\n",bn); } else if( no == 0 ) { break; } else { if(baselink->left == bn ) { bn = baselink->right; } else { bn = baselink->left; } /* fprintf(stderr,"Progressing! with link %d %ld\n",baselink,baselink->sequence_label[0]); */ } } } bn = bn->next_node; } return count; } boolean find_simple_errors_AssemblyGraph(AssemblyGraph * ag,GraphErrorPara * gep) { BaseNode * bn; int i; assert(ag != NULL); assert(gep != NULL); for(bn=ag->bg->start;bn != NULL;bn = bn->next_node ) { if( bn->link_len > 2 ) { for(i=0;ilink_len;i++) { if( bn->link[i]->sequence_label_len <= gep->max_error ) { fprintf(stderr,"Node %d has a potential error\n",bn); find_error_and_mark_BaseNode(bn,gep); break; } } } } return TRUE; } %} wise-2.4.1/src/dnaindex/assembly/depthmanager.dy0000644000175000001440000000126510123355112021243 0ustar philippusers %{ #include "basegraph.h" %} struct DepthPara int max_depth int depth_variation %{ #include "depthmanager.h" void show_help_DepthPara(FILE * ofp) { fprintf(ofp,"Read depth management\n"); fprintf(ofp," -depth_max [10] largest depth accepted for unique sequence\n"); fprintf(ofp," -depth_var [2] max variation in depth expected at nodes\n"); } DepthPara * new_DepthPara_from_argv(int * argc,char ** argv) { DepthPara * out; out = DepthPara_alloc(); out->max_depth = 10; out->depth_variation = 2; strip_out_integer_argument(argc,argv,"depth_max",&out->max_depth); strip_out_integer_argument(argc,argv,"depth_var",&out->depth_variation); return out; } %} wise-2.4.1/src/dnaindex/assembly/basegraph.dy0000644000175000001440000002246510123601042020541 0ustar philippusers %{ #include "../kmer_hash.h" typedef struct BaseNode { struct BaseNode * next_node; struct BaseNode * peer_node; struct BaseLink ** link; int link_len; int link_maxlen; kmer_t dna_number; } BaseNode; typedef struct BaseLink { struct BaseNode * left; struct BaseNode * right; char twist; long * sequence_label; int sequence_label_len; int sequence_label_maxlen; int state; } BaseLink; typedef struct BaseGraph { KmerIndexInterface * kii; struct BaseNode * start; struct BaseNode * curr_end; } BaseGraph; #define BaseNode_LinkLENGTH 16 #define BaseLink_SequenceLENGTH 16 #define BaseLink_USED 1 #define BaseLink_TANGLE_TOUCH 2 #define BaseLink_IS_ERROR 4 #define BaseLink_IS_CYCLE 8 #define BaseLink_IS_DICYCLE 16 #define BaseLink_SUPERTANGLE 32 #define BaseLink_JUMPLINK 64 %} %{ #include "basegraph.h" boolean insert_seqpos_BaseGraph(BaseGraph * bg,kmer_t dna_a,kmer_t dna_b,char twist,long seqno) { BaseLink * bl; if( (bl = existing_BaseLink(bg,dna_a,dna_b,twist)) == NULL ) { bl = new_BaseLink_dnanumber(bg,dna_a,dna_b,twist); assert(bl != NULL); } add_Sequence_BaseLink(bl,seqno); return TRUE; } BaseLink * existing_BaseLink(BaseGraph * bg,kmer_t dna_a,kmer_t dna_b,char twist) { int i; BaseNode * a; BaseNode * b; a = (BaseNode *) (*bg->kii->retrieve_by_kmer)(bg->kii->handle,dna_a); b = (BaseNode *) (*bg->kii->retrieve_by_kmer)(bg->kii->handle,dna_b); if( a == NULL || b == NULL ) { return NULL; } for(i=0;ilink_len;i++) { if( a->link[i]->left == a && a->link[i]->right == b && a->link[i]->twist == twist ) { return a->link[i]; } if( a->link[i]->right == a && a->link[i]->left == b && a->link[i]->twist == twist ) { return a->link[i]; } } return NULL; } int non_error_link_BaseNode(BaseNode * n) { return state_link_number_BaseNode(n,BaseLink_IS_ERROR); } int non_error_or_cycle_link_BaseNode(BaseNode * n) { return state_link_number_BaseNode(n,(BaseLink_IS_ERROR | BaseLink_IS_CYCLE)); } int state_link_number_BaseNode(BaseNode * n,int ignore_state) { int i; int count = 0; assert(n != NULL); for(i=0;ilink_len;i++) { if( (n->link[i]->state & (ignore_state)) ) continue; count++; } return count; } int next_link_if_error_unique_BaseLink(BaseLink * prev,BaseNode * curr,BaseLink ** next) { return next_state_unique_BaseLink(prev,curr,next,BaseLink_IS_ERROR); } int next_link_if_error_or_cycle_unique_BaseLink(BaseLink * prev,BaseNode * curr,BaseLink ** next) { return next_state_unique_BaseLink(prev,curr,next,(BaseLink_IS_ERROR | BaseLink_IS_CYCLE)); } int next_state_unique_BaseLink(BaseLink * prev,BaseNode * curr,BaseLink ** next,int ignore_state) { BaseLink * out; assert(prev != NULL); assert(curr != NULL); int i; int count = 0; assert(curr != NULL); assert(prev != NULL); for(i=0;ilink_len;i++) { /* fprintf(stderr,"Looking at link %d, count %d\n",i,count); */ if( (curr->link[i]->state & (ignore_state)) ) { continue; /* fprintf(stderr,"Got error or cycle\n"); */ } count++; if( curr->link[i] != prev ) { out = curr->link[i]; } } /* fprintf(stderr,"Count is %d at end\n",count); */ if( count == 2 ) { /* only two real links, therefore only one can be the next*/ *next = out; } count--; return count; } int next_link_if_unique_BaseLink(BaseLink * prev,BaseNode * curr,BaseLink ** next) { assert(prev != NULL); assert(curr != NULL); if( curr->link_len == 0 ) { fatal("Asking for next link in a node with no links!"); } if( curr->link_len == 1 ) { assert(curr->link[0] == prev); return 0; } if( curr->link_len == 2 ) { if( curr->link[0] == prev ) { *next = curr->link[1]; return 1; } else { assert(curr->link[1] == prev); *next = curr->link[0]; return 1; } } return curr->link_len; } BaseLink * new_BaseLink_dnanumber(BaseGraph * bg,kmer_t dna_a,kmer_t dna_b,char twist) { BaseNode * left; BaseNode * right; left = get_BaseNode_for_insert_create_if_needed(bg,dna_a); right = get_BaseNode_for_insert_create_if_needed(bg,dna_b); return new_BaseLink(left,right,twist); } BaseLink * new_BaseLink(BaseNode * left,BaseNode * right,char twist) { BaseLink * out; assert(left != NULL); assert(right != NULL); out = malloc(sizeof(struct BaseLink)); out->left = left; out->right = right; out->twist = twist; out->sequence_label = calloc(BaseLink_SequenceLENGTH,sizeof(long)); out->sequence_label_len = 0; out->sequence_label_maxlen = BaseLink_SequenceLENGTH; out->state = 0; add_BaseLink_BaseNode(left,out); add_BaseLink_BaseNode(right,out); return out; } boolean remove_BaseLink_BaseNode(BaseNode * node,BaseLink * link) { int i; assert(node != NULL); assert(link != NULL); fprintf(stderr,"Removing link %d from node %d\n",link,node); for(i=0;ilink_len;i++) { if( node->link[i] == link ) { for(i++;ilink_len;i++) { node->link[i-1] = node->link[i]; } node->link_len--; return TRUE; } } return FALSE; } boolean add_BaseLink_BaseNode(BaseNode * node,BaseLink * link) { int len; assert(node != NULL); assert(link != NULL); if( node->link_len >= node->link_maxlen) { len = 2 * node->link_maxlen; node->link = realloc(node->link,len*(sizeof(struct BaseLink *))); if( node->link == NULL ) { fatal("Failed to realloc a BaseNode link list to %d, %d",len,node->link_maxlen); } node->link_maxlen = len; } node->link[node->link_len++] = link; return TRUE; } boolean remove_Sequence_BaseLink(BaseLink * bl,long seqno) { int i; assert(bl != NULL); for(i=0;isequence_label_len;i++) { if( bl->sequence_label[i] == seqno ) { for(i++;isequence_label_len;i++) { bl->sequence_label[i-1] = bl->sequence_label[i]; } bl->sequence_label_len--; return TRUE; } } return FALSE; } boolean add_Sequence_BaseLink(BaseLink * bl,long seqno) { int len; assert(bl != NULL); if( bl->sequence_label_len >= bl->sequence_label_maxlen ) { len = 2* bl->sequence_label_maxlen; bl->sequence_label = realloc(bl->sequence_label,len*sizeof(long)); if( bl->sequence_label == NULL ) { fatal("Out of memory on reallocing %d labels on Link",len); } bl->sequence_label_maxlen = len; } bl->sequence_label[bl->sequence_label_len++] = seqno; return TRUE; } BaseGraph * new_BaseGraph(KmerIndexInterface * kii) { BaseGraph * out; assert(kii != NULL); out = malloc(sizeof(BaseGraph)); out->kii = kii; out->start = NULL; out->curr_end = NULL; return out; } BaseNode * retrieve_BaseNode(BaseGraph * bg,kmer_t dna_number) { BaseNode * out; assert(bg != NULL); out = (*bg->kii->retrieve_by_kmer)(bg->kii->handle,dna_number); return out; } BaseNode * get_BaseNode_for_insert_create_if_needed(BaseGraph * bg,kmer_t dna_number) { BaseNode * out; assert(bg != NULL); if( (out = (*bg->kii->retrieve_by_kmer)(bg->kii->handle,dna_number)) == NULL ) { if( bg->start == NULL ) { out = new_BaseNode(&bg->start,dna_number); } else { out = new_BaseNode(&bg->curr_end->next_node,dna_number); } assert(out != NULL); assert(out->dna_number == dna_number); bg->curr_end = out; if( (*bg->kii->insert_by_kmer)(bg->kii->handle,dna_number,out) == FALSE ) { fatal("Unable to insert BaseNode into graph"); } } return out; } BaseNode * new_BaseNode(BaseNode ** end_node,kmer_t dna_number) { BaseNode * out; assert(end_node != NULL); assert(*(end_node) == NULL); out = malloc(sizeof(struct BaseNode)); out->next_node = NULL; out->dna_number = dna_number; out->link = calloc(BaseNode_LinkLENGTH,sizeof(struct BaseLink *)); out->link_len = 0; out->link_maxlen = BaseNode_LinkLENGTH; out->peer_node = NULL; *(end_node) = out; return out; } BaseGraph * free_BaseGraph(BaseGraph * bg) { fprintf(stderr,"EWAN HAS NOT DELT WITH GRAPH DESTRUCTION."); return NULL; } void show_BaseLink(BaseGraph * bg,BaseLink * bl,FILE *ofp) { int i; char buffer_l[256]; char buffer_r[256]; assert(bg != NULL); assert(bl != NULL); assert(ofp != NULL); reverse_map_dna_number(bl->left->dna_number,bg->kii->kmer_size,buffer_l); reverse_map_dna_number(bl->right->dna_number,bg->kii->kmer_size,buffer_r); buffer_l[bg->kii->kmer_size] = '\0'; buffer_r[bg->kii->kmer_size] = '\0'; fprintf(ofp," Link %d state %d depth %d\n",(int)bl,bl->state,bl->sequence_label_len); fprintf(ofp," Left %d (%d) %s\n",(int)(bl->left),bl->left->link_len,buffer_l); fprintf(ofp," Right %d (%d) %s\n",(int)(bl->right),bl->right->link_len,buffer_r); for(i=0;isequence_label_len;i++) { fprintf(ofp," Label %ld\n",bl->sequence_label[i]); } } void show_BaseNode(BaseGraph * bg,BaseNode * bn,FILE * ofp) { int i; fprintf(ofp,"Node %d %d links\n",bn,bn->link_len); for(i=0;ilink_len;i++) { show_BaseLink(bg,bn->link[i],ofp); } } void show_BaseGraph(BaseGraph * bg,FILE *out) { int i; BaseNode * bn; bn = bg->start; while( bn != NULL ) { fprintf(out,"Node %d Links %d\n",bn,bn->link_len); for(i=0;ilink_len;i++) { fprintf(out," Link %d to %d labels %d\n", bn->link[i]->left, bn->link[i]->right, bn->link[i]->sequence_label_len); } bn = bn->next_node; } } %} wise-2.4.1/src/dnaindex/assembly/assemblygraph.dy0000644000175000001440000001302710207066416021455 0ustar philippusers %{ #include "assembly_stream_interface.h" #include "basegraph.h" #include "singleseqspace.h" #include "assembly.h" #include "depthmanager.h" %} struct AssemblyGraph BaseGraph * bg SinglePosSpace * sp %{ #include "assemblygraph.h" AssemblyGraph * new_AssemblyGraph(KmerIndexInterface * kii,int max_read_len) { AssemblyGraph * out; out = AssemblyGraph_alloc(); out->bg = new_BaseGraph(kii); out->sp = new_SinglePosSpace(1,max_read_len); return out; } long int load_AssemblyGraph(AssemblyGraph * ag,AssemblySequenceStream * ass,int readmax) { char buffer[256]; char c; int i; AssemblySequence * aseq; struct lexical_kmer l; struct lexical_kmer prev; char twist; int first; long seq_offset; long seq_load = 0; int warning_for_n = 0; int count = 0; while( (aseq = (*ass->next_AssemblySequence)(ass->handle)) != NULL ) { first = 0; if( readmax != 0 && readmax < count ) { break; } count++; if( count % 100 == 0 ) { fprintf(stderr,"Reading read %d\n",count); } seq_offset = add_Sequence_SinglePosSpace(ag->sp,aseq->seq->len,(void*)aseq); for(i=0;iseq->len - ag->bg->kii->kmer_size;i++) { l = lexical_dna_number_from_string(aseq->seq->seq+i,ag->bg->kii->kmer_size); if( l.lexical_forward == 3 ) { /* N at this position, have to skip */ if( warning_for_n == 0 ) { fprintf(stderr,"Ewan has not figured out how to handle N containing sequences\n"); warning_for_n = 1; } continue; } /* if this is the first kmer, store it as previous and continue */ if( first == 0 ) { prev = l; first = 1; continue; } if( prev.lexical_forward == l.lexical_forward ) { twist = 0; } else { twist = 1; } /* if( i > 1 && i < 12 ) { fprintf(stderr,"Inserting at position %d in sequence with %ld %ld to %ld\n",i,seq_offset+i,prev.kmer, l.kmer); reverse_map_dna_number(l.kmer,ag->bg->kii->kmer_size,buffer); c = lexical_last_base_from_kmer(l.kmer,ag->bg->kii->kmer_size,l.lexical_forward); buffer[ag->bg->kii->kmer_size] = '\0'; fprintf(stderr,"Kmer %s last %c %d\n",buffer,c,l.lexical_forward); } */ insert_seqpos_BaseGraph(ag->bg,prev.kmer,l.kmer,twist,seq_offset+i); prev = l; seq_load++; } } return seq_load; } Assembly * Assembly_from_AssemblyGraph(AssemblyGraph * ag,DepthPara * dp) { BaseNode * bn; Assembly * out; AssemblyContig * contig; int i; out = Assembly_alloc_std(); bn = ag->bg->start; while( bn != NULL ) { if( bn->link_len == 1 && ((bn->link[0]->state & BaseLink_USED) != BaseLink_USED) ) { /* edge node */ fprintf(stderr,"Using link %d with state %d\n",(int)bn->link,bn->link[0]->state); bn->link[0]->state |= BaseLink_USED; contig = AssemblyContig_from_start_link(ag,bn->link[0],bn); add_Assembly(out,contig); } else if ( bn->link_len > 2 ) { for(i=0;ilink_len;i++) { if( bn->link[i]->sequence_label_len < dp->max_depth && !(bn->link[i]->state & (BaseLink_USED | BaseLink_IS_ERROR | BaseLink_IS_CYCLE) ) ) { contig = AssemblyContig_from_start_link(ag,bn->link[i],bn); add_Assembly(out,contig); } } } bn = bn->next_node; } return out; } AssemblyContig * AssemblyContig_from_start_link(AssemblyGraph * ag,BaseLink * link,BaseNode * prev_node) { int no; char buffer[512]; AssemblyContig * out; BaseNode * next_node; int lexical = 0; char * seqstr; int seq_len; int curr_pos; int max_depth = 0; int clean_end = 0; int clean_start = 0; Sequence * seq; assert(link != NULL); assert(prev_node != NULL); seqstr = malloc(1024*sizeof(char)); curr_pos = 0; seq_len = 1024; out = AssemblyContig_alloc_std(); if( prev_node->link_len == 1 ) { clean_start = 1; } else { clean_start = 0; } sprintf(buffer,"Contig_%d",(int)link); while( 1 ) { if( link->sequence_label_len > max_depth ) { max_depth = link->sequence_label_len; } if( link->left == prev_node ) { next_node = link->right; } else { next_node = link->left; } /* fprintf(stdout,"Link at %d has next node %d with %d links\n",(int)link,(int) next_node,next_node->link_len); */ assert(next_node != NULL); /* use next node to give us the base */ if( curr_pos >= seq_len ) { seq_len = seq_len * 2; seqstr = realloc(seqstr,seq_len*sizeof(char)); if( seqstr == NULL ) { fatal("Out of memory in assembly contig reconstruction, trying to allocate string of %d",seq_len); } } if( link->twist == 1 ) { if( lexical == 0 ) { lexical = 1; } else { lexical = 0; } } seqstr[curr_pos++] = lexical_last_base_from_kmer(next_node->dna_number, ag->bg->kii->kmer_size, lexical); /* mark link as used */ link->state |= BaseLink_USED; /* fprintf(stdout,"Set link %d state to: %d\n",link,link->state); */ /* travel to next link */ no = next_link_if_error_or_cycle_unique_BaseLink(link,next_node,&link); if( no == 0 ) { /* no next link --> end */ break; } if( no > 1 ) { /* no unique link --> end */ break; } prev_node = next_node; /* return for next base */ } if( next_node->link_len > 1 ) { clean_end = 0; } else { clean_end = 1; } seqstr[curr_pos] = '\0'; seq = Sequence_from_static_memory(buffer,seqstr); out->consensus = seq; out->clean_start = clean_start; out->clean_end = clean_end; out->max_depth = max_depth; return out; } %} wise-2.4.1/src/dnaindex/assembly/badkmer.c0000644000175000001440000000546610121277500020030 0ustar philippusers#include "version.h" #include "assemblygraph.h" #include "assembly_stream_fasta.h" #include "kmer_glib_index.h" #include "kmer_hash.h" #include "assemblystats.h" char * program_name = "badkmer"; void show_help(FILE * ofp) { fprintf(ofp,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(ofp,"Output options\n"); fprintf(ofp," -depth [2] depth of link\n"); fprintf(ofp,"Kmer options\n"); fprintf(ofp," -kmer [15] kmer size (15 is max)\n"); fprintf(ofp," -[no]hash use optimised hash (true)\n"); show_standard_options(ofp); } void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EBI 2003\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney wrote the core code.\n"); exit(63); } int main(int argc,char ** argv) { boolean show_stats_before = 0; boolean use_hash = 1; BaseNode * bn; SinglePosSequence * sps; AssemblySequence * aseq; int i,j; int depth = 2; char buffer[256]; int kmer = 15; int load; AssemblyGraph * ag; AssemblyGraphStats * astat; AssemblySequenceStream * as; FILE * ifp; KmerIndexInterface * kii; strip_out_integer_argument(&argc,argv,"kmer",&kmer); strip_out_integer_argument(&argc,argv,"depth",&depth); strip_out_boolean_def_argument(&argc,argv,"hash",&use_hash); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc == 1 ) { show_help(stdout); exit(1); } ifp = openfile(argv[1],"r"); as = plain_fasta_AssemblySequenceStream(ifp); if( use_hash == 0 ) { kii = new_interface_KmerGlibIndex(kmer); } else { kii = new_KmerHashIndex(kmer); } ag = new_AssemblyGraph(kii,500); load = load_AssemblyGraph(ag,as); if( show_stats_before ) { astat = new_AssemblyGraphStats(ag); show_AssemblyGraphStats(astat,10,10,stdout); } for(bn=ag->bg->start;bn!= NULL;bn = bn->next_node ) { for(i=0;ilink_len;i++) { /* only show links attached to the left */ if( bn->link[i]->left == bn && bn->link[i]->sequence_label_len > depth ) { reverse_map_dna_number(bn->link[i]->right->dna_number,kmer,buffer); buffer[kmer] = '\0'; for(j=0;jlink[i]->sequence_label_len;j++) { sps = lookup_Sequence_SinglePosSpace(ag->sp,bn->link[i]->sequence_label[j]); aseq = (AssemblySequence*) sps->data; printf("%d %s %s %ld\n",bn->link[i]->sequence_label_len,buffer,aseq->seq->name,bn->link[i]->sequence_label[j] - sps->start); } } } } return 0; } wise-2.4.1/src/dnaindex/assembly/pathwise.c0000644000175000001440000001146710207066416020254 0ustar philippusers#include "version.h" #include "assemblygraph.h" #include "assembly_stream_fasta.h" #include "assembly_sanger_project.h" #include "kmer_glib_index.h" #include "kmer_hash.h" #include "assemblystats.h" #include "graphmanager.h" char * program_name = "pathwise"; void show_help(FILE * ofp) { fprintf(ofp,"%s (%s)\n",program_name,VERSION_NUMBER); fprintf(ofp,"Graph statistics display\n"); fprintf(ofp," -[no]stat_raw show stats just after sequence load\n"); fprintf(ofp," -[no]stat_error show stats just after error manip\n"); fprintf(ofp," -[no]stat_tangle show stats just after de-tangling\n"); fprintf(ofp,"Graph manipulation\n"); fprintf(ofp," -[no]error_free reads are error free. (off by default)\n"); fprintf(ofp,"Read input type\n"); fprintf(ofp," -readstream [fasta/sanger] Read input type (fasta by default)\n"); fprintf(ofp," -readmax [number] maximum reads to use (good for debugging)\n"); show_help_GraphErrorPara(ofp); show_help_DepthPara(ofp); show_help_AssemblyOutputPara(ofp); fprintf(ofp,"Kmer options\n"); fprintf(ofp," -kmer [15] kmer size (15 is max)\n"); fprintf(ofp," -[no]hash use optimised hash (true)\n"); show_standard_options(ofp); } void show_version(FILE * ofp) { fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE); fprintf(ofp,"\nThis program is freely distributed under a Gnu Public License\n"); fprintf(ofp,"The source code is copyright (c) EBI 2003\n"); fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n"); fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n"); fprintf(ofp,"Credits: Ewan Birney wrote the core code.\n"); exit(63); } int main(int argc,char ** argv) { boolean show_stats_before = 0; boolean show_stats_error = 0; boolean show_stats_tangle = 0; boolean show_fasta_contigs = 1; boolean use_hash = 1; boolean no_error = 0; int readmax = 0; int kmer = 15; int load; int cycle_count; GraphErrorPara * gep; DepthPara * dp; AssemblyGraph * ag; AssemblyGraphStats * astat; AssemblySequenceStream * as; AssemblyOutputPara * aop; Assembly * assem; FILE * ifp; KmerIndexInterface * kii; char * streamtype = NULL; gep = new_GraphErrorPara_from_argv(&argc,argv); dp = new_DepthPara_from_argv(&argc,argv); aop = new_AssemblyOutputPara_from_argv(&argc,argv); strip_out_integer_argument(&argc,argv,"kmer",&kmer); strip_out_boolean_def_argument(&argc,argv,"hash",&use_hash); strip_out_boolean_def_argument(&argc,argv,"error_free",&no_error); strip_out_boolean_def_argument(&argc,argv,"stat_raw",&show_stats_before); strip_out_boolean_def_argument(&argc,argv,"stat_error",&show_stats_error); strip_out_boolean_def_argument(&argc,argv,"stat_tangle",&show_stats_tangle); strip_out_integer_argument(&argc,argv,"readmax",&readmax); streamtype = strip_out_assigned_argument(&argc,argv,"readstream"); strip_out_standard_options(&argc,argv,show_help,show_version); if( argc == 1 ) { show_help(stdout); exit(1); } if( streamtype == NULL || strcmp(streamtype,"fasta") == 0 ) { ifp = openfile(argv[1],"r"); as = plain_fasta_AssemblySequenceStream(ifp); } else if( strcmp(streamtype,"sanger") == 0 ) { as = new_sanger_project_AssemblySequenceStream(argv[1],"1c"); } else { fatal("Bad stream type [%s]",streamtype); } if( use_hash == 0 ) { kii = new_interface_KmerGlibIndex(kmer); } else { kii = new_KmerHashIndex(kmer); } ag = new_AssemblyGraph(kii,500); load = load_AssemblyGraph(ag,as,readmax); if( show_stats_before ) { astat = new_AssemblyGraphStats(ag); show_AssemblyGraphStats(astat,10,10,stdout); free_AssemblyGraphStats(astat); } cycle_count = find_single_cycles_AssemblyGraph(ag); fprintf(stderr,"Found %d cycles\n",cycle_count); cycle_count = find_di_cycles_AssemblyGraph(ag); fprintf(stderr,"Found %d dicycles\n",cycle_count); /* handle errors */ if( no_error == 0 ) { find_simple_errors_AssemblyGraph(ag,gep); } if( show_stats_error ) { astat = new_AssemblyGraphStats(ag); show_AssemblyGraphStats(astat,10,10,stdout); free_AssemblyGraphStats(astat); } /* handle tangles */ find_and_resolve_tangles_AssemblyGraph(ag); /* now resolve internal tangles */ /* find_and_resolve_tangles_AssemblyGraph_Para(ag,dp,1);*/ if( show_stats_tangle ) { astat = new_AssemblyGraphStats(ag); show_AssemblyGraphStats(astat,10,10,stdout); free_AssemblyGraphStats(astat); } /* handle supertangles */ /* find_and_jump_supertangles_AssemblyGraph(ag);*/ if( show_fasta_contigs ) { assem = Assembly_from_AssemblyGraph(ag,dp); dump_contigs_as_fasta_Assembly(assem,aop,stdout); } return 0; } wise-2.4.1/src/dnaindex/assembly/test_assemblygraph.c0000644000175000001440000000172410117345737022331 0ustar philippusers#include "assemblygraph.h" #include "assembly_stream_fasta.h" #include "kmer_glib_index.h" #include "kmer_hash.h" #include "assemblystats.h" void test_basic_graph(char * filename,int kmer,int use_hash) { AssemblyGraph * ag; AssemblyGraphStats * astat; AssemblySequenceStream * as; Assembly * assem; FILE * ifp; KmerIndexInterface * kii; long int load; ifp = openfile(filename,"r"); assert(ifp); as = plain_fasta_AssemblySequenceStream(ifp); if( use_hash == 0 ) { kii = new_interface_KmerGlibIndex(kmer); } else { kii = new_KmerHashIndex(kmer); } ag = new_AssemblyGraph(kii,500); load = load_AssemblyGraph(ag,as); astat = new_AssemblyGraphStats(ag); show_AssemblyGraphStats(astat,10,10,stdout); assert(load > 0); /* assem = Assembly_from_AssemblyGraph(ag); dump_contigs_as_fasta_Assembly(assem,stdout); */ } int main(int argc,char ** argv) { test_basic_graph(argv[1],atoi(argv[2]),0); return 0; } wise-2.4.1/src/dnaindex/assembly_stream_cons.dy0000644000175000001440000000542707736003563021225 0ustar philippusers %{ #include "assembly_stream_interface.h" #include "assembly_sanger_project.h" #include "assembly_stream_fasta.h" typedef enum assembly_stream_type { AssemblyStreamTypeFasta = 791, AssemblyStreamTypeSanger, } AssemblyStreamType; %} struct AssemblyStreamConstructor int type char * file_name char * dir_name char * extension %{ #include "assembly_stream_cons.h" void show_help_AssemblyStreamConstructor(FILE * ofp) { fprintf(ofp,"Assembly Read Sequence input options\n"); fprintf(ofp," -astype [fasta/sanger] type of input\n"); fprintf(ofp," -asfile filename for fasta input\n"); fprintf(ofp," -asdir directory name for sanger project-style input\n"); fprintf(ofp," -asdirext [1c] extension for reads in sanger project style, defaul 1c\n"); } AssemblySequenceStream * new_AssemblySequenceStream_from_AssemblyStreamConstructor(AssemblyStreamConstructor * asc) { FILE * ifp; /* a bit evil as we don't close this. Should fix */ switch(asc->type) { case AssemblyStreamTypeFasta : if( asc->file_name == NULL ) { warn("Fasta file type needs a filename with -asfile"); return NULL; } ifp = openfile(asc->file_name,"r"); if( ifp == NULL ) { warn("Unable to open file %s for fasta reading",asc->file_name); return NULL; } return plain_fasta_AssemblySequenceStream(ifp); break; case AssemblyStreamTypeSanger : if( asc->dir_name == NULL || asc->extension == NULL ) { warn("Sanger project type needs directory (-asdir) and extension (-asdirext) arguments"); return NULL; } return new_sanger_project_AssemblySequenceStream(asc->dir_name,asc->extension); break; default : warn("Unknown assembly stream type %d",asc->type); } fatal("impossible to get here"); return NULL; } AssemblyStreamConstructor * new_AssemblyStreamConstructor_from_argv(int * argc,char ** argv) { char * temp; AssemblyStreamConstructor * out; out = AssemblyStreamConstructor_alloc(); out->type = AssemblyStreamTypeFasta; temp = strip_out_assigned_argument(argc,argv,"astype"); if( temp != NULL) { if( strcmp(temp,"fasta") == 0 ) { out->type = AssemblyStreamTypeFasta; } else if ( strcmp(temp,"sanger") == 0 ) { out->type = AssemblyStreamTypeSanger; } else { warn("Unable to decipher type %s as a type of assembly stream",temp); } } temp = strip_out_assigned_argument(argc,argv,"asdir"); if( temp != NULL) out->dir_name = stringalloc(temp); temp = strip_out_assigned_argument(argc,argv,"asdirext"); if( temp != NULL) out->extension = stringalloc(temp); else out->extension = stringalloc("1c"); temp = strip_out_assigned_argument(argc,argv,"asfile"); if( temp != NULL) out->file_name = stringalloc(temp); return out; } wise-2.4.1/src/welcome.csh0000755000175000001440000000077710345263435015015 0ustar philippusers#!/bin/tcsh -f echo "" echo "Welcome to Wise2.4" echo "" echo "The executable programs are in the ./bin directory" echo "" echo "You must set your WISECONFIGDIR to the config directory" echo "before using the programs" echo "" echo "ie, type setenv WISECONFIGDIR `pwd`/../wisecfg/" echo "" echo "to try an example, try cd example and then" echo "../bin/genewise road.pep human.genomic" echo "" echo "to build perl, type make perl and follow the instructions" echo "" echo "to test the package, type make test" wise-2.4.1/src/dynlibsrc/0000755000175000001440000000000010670453713014637 5ustar philippuserswise-2.4.1/src/dynlibsrc/probability.pod0000644000175000001440000000351210670453712017663 0ustar philippusers=head1 NAME probability module - part of the Wise2 package =head1 SYNOPSIS This module contains helper functions for the Wise2 package =head1 DESCRIPTION =over =item Probability_from_average_state_occupancy &Wise2::Probability_from_average_state_occupancy(length) for single state (exponetial decays) takes an average length and converts that to a probability that will produce that length (on average) for the state. NB... this *assumes* that you want a single state exp decay. Argument length [UNKN ] average length of state [double] Return [UNKN ] Undocumented return value [Probability] =item state_occupancy_from_Probability &Wise2::state_occupancy_from_Probability(p) If you have a single state then this will tak the probability for the state->state transition and give you back the average length in the state Argument p [UNKN ] probability of staying in the state [double] Return [UNKN ] Undocumented return value [double] =item Probability2Score &Wise2::Probability2Score(p) maps probabilities to scores. Deals sensibly with 0's. Argument p [UNKN ] Undocumented argument [Probability] Return [UNKN ] Undocumented return value [Score] =item Score2Probability &Wise2::Score2Probability(s) maps scores to probabilities Argument s [UNKN ] Undocumented argument [Score] Return [UNKN ] Undocumented return value [Probability] =item Score2Bits &Wise2::Score2Bits(s) maps scores to bits Argument s [UNKN ] Undocumented argument [Score] Return [UNKN ] Undocumented return value [Bits] =item halfbit2Probability &Wise2::halfbit2Probability(half_bit) maps halfbits (log2(prob*2) to probabilities Argument half_bit [UNKN ] Undocumented argument [double] Return [UNKN ] Undocumented return value [Probability] =back wise-2.4.1/src/dynlibsrc/probability.tex0000644000175000001440000000533710670453712017710 0ustar philippusers\section{probability} \label{module_probability} This module only contains factory methods \subsection{probability factory methods} \subsubsection{Probability_from_average_state_occupancy} \begin{description} \item[External C] {\tt Wise2_Probability_from_average_state_occupancy (length)} \item[Perl] {\tt &Wise2::Probability_from_average_state_occupancy (length)} \end{description} Arguments \begin{description} \item[length] [UNKN ] average length of state [double] \item[returns] [UNKN ] Undocumented return value [Probability] \end{description} for single state (exponetial decays) takes an average length and converts that to a probability that will produce that length (on average) for the state. NB... this *assumes* that you want a single state exp decay. \subsubsection{state_occupancy_from_Probability} \begin{description} \item[External C] {\tt Wise2_state_occupancy_from_Probability (p)} \item[Perl] {\tt &Wise2::state_occupancy_from_Probability (p)} \end{description} Arguments \begin{description} \item[p] [UNKN ] probability of staying in the state [double] \item[returns] [UNKN ] Undocumented return value [double] \end{description} If you have a single state then this will tak the probability for the state->state transition and give you back the average length in the state \subsubsection{Probability2Score} \begin{description} \item[External C] {\tt Wise2_Probability2Score (p)} \item[Perl] {\tt &Wise2::Probability2Score (p)} \end{description} Arguments \begin{description} \item[p] [UNKN ] Undocumented argument [Probability] \item[returns] [UNKN ] Undocumented return value [Score] \end{description} maps probabilities to scores. Deals sensibly with 0's. \subsubsection{Score2Probability} \begin{description} \item[External C] {\tt Wise2_Score2Probability (s)} \item[Perl] {\tt &Wise2::Score2Probability (s)} \end{description} Arguments \begin{description} \item[s] [UNKN ] Undocumented argument [Score] \item[returns] [UNKN ] Undocumented return value [Probability] \end{description} maps scores to probabilities \subsubsection{Score2Bits} \begin{description} \item[External C] {\tt Wise2_Score2Bits (s)} \item[Perl] {\tt &Wise2::Score2Bits (s)} \end{description} Arguments \begin{description} \item[s] [UNKN ] Undocumented argument [Score] \item[returns] [UNKN ] Undocumented return value [Bits] \end{description} maps scores to bits \subsubsection{halfbit2Probability} \begin{description} \item[External C] {\tt Wise2_halfbit2Probability (half_bit)} \item[Perl] {\tt &Wise2::halfbit2Probability (half_bit)} \end{description} Arguments \begin{description} \item[half_bit] [UNKN ] Undocumented argument [double] \item[returns] [UNKN ] Undocumented return value [Probability] \end{description} maps halfbits (log2(prob*2) to probabilities wise-2.4.1/src/dynlibsrc/dbsearchimpl.c0000644000175000001440000003615310670453712017447 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dbsearchimpl.h" /* Function: impl_string_DBSearchImpl(dbsi) * * Descrip: Gets a static text string out of the * search implementation * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * * Return [SOFT ] string of the search implementation [char *] * */ # line 89 "dbsearchimpl.dy" char * impl_string_DBSearchImpl(DBSearchImpl * dbsi) { switch(dbsi->type) { case DBSearchImpl_Serial : return "Single Threaded processor (serial)"; case DBSearchImpl_Pthreads : return "Pthreaded multiple processor"; case DBSearchImpl_MPI : return "MPI distributed memory multiple processor"; case DBSearchImpl_PVM : return "Parallel Virtual Machine implementation"; default : return "Unknown implementation"; } } /* Function: impl_string_routine_DBSearchImpl(dbsi) * * Descrip: Gets a static text string out of the * search routine implementation * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * * Return [SOFT ] string of the search implementation [char *] * */ # line 112 "dbsearchimpl.dy" char * impl_string_routine_DBSearchImpl(DBSearchImpl * dbsi) { switch(dbsi->search_routine) { case DBSearchImplRoutine_Exact : return "Exact calculation"; case DBSearchImplRoutine_Kbest : return "Kbest heuristic"; case DBSearchImplRoutine_Forward : return "Forward score"; default : return "Unknown routine implementation"; } } /* Function: number_of_threads_DBSearchImpl(dbsi) * * Descrip: This gets out the recommended number of * threads for a dbsi * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * * Return [UNKN ] Undocumented return value [int] * */ # line 130 "dbsearchimpl.dy" int number_of_threads_DBSearchImpl(DBSearchImpl * dbsi) { int num; if( dbsi->type != DBSearchImpl_Pthreads ) { warn("Asking a database implementation how many threads when it is not pthreads but [%s]",impl_string_DBSearchImpl(dbsi)); } if( dbsi->suggest_thread_no == -1) { num = DBSEARCH_NPROC; if (num == -1) num = 2; return num; } return dbsi->suggest_thread_no; } /* Function: new_MPI_DBSearchImpl(void) * * Descrip: Makes a new MPI DBSearchImpl * * For use mainly for api's who don't want * to initalize the object from the command * line * * * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ # line 157 "dbsearchimpl.dy" DBSearchImpl * new_MPI_DBSearchImpl(void) { DBSearchImpl * out; out = DBSearchImpl_alloc(); out->type = DBSearchImpl_MPI; return out; } /* Function: new_pthread_DBSearchImpl(void) * * Descrip: Makes a new pthreaded DBSearchImpl * * For use mainly for api's who don't want * to initalize the object from the command * line * * * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ # line 173 "dbsearchimpl.dy" DBSearchImpl * new_pthread_DBSearchImpl(void) { DBSearchImpl * out; out = DBSearchImpl_alloc(); out->type = DBSearchImpl_Pthreads; return out; } /* Function: new_serial_DBSearchImpl(void) * * Descrip: Makes a new serial DBSearchImpl * * For use mainly for api's who don't want * to initalize the object from the command * line * * * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ # line 189 "dbsearchimpl.dy" DBSearchImpl * new_serial_DBSearchImpl(void) { DBSearchImpl * out; out = DBSearchImpl_alloc(); out->type = DBSearchImpl_Serial; return out; } /* Function: show_help_DBSearchImpl(ofp) * * Descrip: This shows the help for the search implementation * system. * * It prints out lines like * -pthreads use pthreaded code * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 205 "dbsearchimpl.dy" void show_help_DBSearchImpl(FILE * ofp) { fprintf(ofp,"Database search implementation\n"); fprintf(ofp," -serial use serial code (single processor)\n"); fprintf(ofp," -pthread use pthread code (SMP box)\n"); fprintf(ofp," -pthr_no Number of threads to use\n"); fprintf(ofp," -mpi use MPI code (distributed memory system)\n"); fprintf(ofp," -pvm use parallel virtual machine search system\n"); fprintf(ofp," -dbtrace Trace level of the database code (for debugging only)\n"); fprintf(ofp," -sroutine Search type routine [exact/kbest/forward]\n"); } /* Function: new_DBSearchImpl_from_argv(argc,argv) * * Descrip: This process command line arguments to * make a new DBSearchImpl. This way the * search implementation is relatively * flexible from the program which calls it. * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ # line 224 "dbsearchimpl.dy" DBSearchImpl * new_DBSearchImpl_from_argv(int * argc,char ** argv) { DBSearchImpl * out; char * temp; out = DBSearchImpl_alloc(); out->trace_file = stderr; if( (strip_out_boolean_argument(argc,argv,"mpi")) == TRUE ) { out->type = DBSearchImpl_MPI; } if( (strip_out_boolean_argument(argc,argv,"pthread")) == TRUE ) { out->type = DBSearchImpl_Pthreads; } if( (strip_out_boolean_argument(argc,argv,"pvm")) == TRUE ) { out->type = DBSearchImpl_PVM; } if( (strip_out_boolean_argument(argc,argv,"serial")) == TRUE ) { out->type = DBSearchImpl_Serial; } if( (temp = strip_out_assigned_argument(argc,argv,"pthr_no")) != NULL ) { if( is_integer_string(temp,&out->suggest_thread_no) == FALSE ) { warn("String [%s] for pthr_no is not an integer!",temp); free_DBSearchImpl(out); return NULL; } } if( (temp = strip_out_assigned_argument(argc,argv,"dbtrace")) != NULL ) { if( is_integer_string(temp,&out->trace_level) == FALSE ) { warn("String [%s] for dbtrace is not an integer!",temp); free_DBSearchImpl(out); return NULL; } } if( (temp = strip_out_assigned_argument(argc,argv,"sroutine")) != NULL ) { if( strcmp(temp,"exact") == 0) { out->search_routine = DBSearchImplRoutine_Exact; } else if( strcmp(temp,"kbest") == 0 ) { out->search_routine = DBSearchImplRoutine_Kbest; } else if( strcmp(temp,"forward") == 0 ) { out->search_routine = DBSearchImplRoutine_Forward; } else { warn("String [%s] for search routine is not recognised",temp); free_DBSearchImpl(out); return NULL; } } return out; } # line 251 "dbsearchimpl.c" /* Function: hard_link_DBSearchImpl(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DBSearchImpl *] * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ DBSearchImpl * hard_link_DBSearchImpl(DBSearchImpl * obj) { if( obj == NULL ) { warn("Trying to hard link to a DBSearchImpl object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DBSearchImpl_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ DBSearchImpl * DBSearchImpl_alloc(void) { DBSearchImpl * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DBSearchImpl *) ckalloc (sizeof(DBSearchImpl))) == NULL) { warn("DBSearchImpl_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = DBSearchImpl_Serial; out->trace_level = 0; out->suggest_thread_no = (-1); out->search_routine = DBSearchImplRoutine_Exact; return out; } /* Function: free_DBSearchImpl(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DBSearchImpl *] * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ DBSearchImpl * free_DBSearchImpl(DBSearchImpl * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DBSearchImpl obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->trace_file is linked in */ ckfree(obj); return NULL; } /* Function: replace_type_DBSearchImpl(obj,type) * * Descrip: Replace member variable type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DBSearchImpl *] * Arg: type [OWNER] New value of the variable [int] * * Return [SOFT ] member variable type [boolean] * */ boolean replace_type_DBSearchImpl(DBSearchImpl * obj,int type) { if( obj == NULL) { warn("In replacement function type for object DBSearchImpl, got a NULL object"); return FALSE; } obj->type = type; return TRUE; } /* Function: access_type_DBSearchImpl(obj) * * Descrip: Access member variable type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DBSearchImpl *] * * Return [SOFT ] member variable type [int] * */ int access_type_DBSearchImpl(DBSearchImpl * obj) { if( obj == NULL) { warn("In accessor function type for object DBSearchImpl, got a NULL object"); return 0; } return obj->type; } /* Function: replace_trace_level_DBSearchImpl(obj,trace_level) * * Descrip: Replace member variable trace_level * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DBSearchImpl *] * Arg: trace_level [OWNER] New value of the variable [int] * * Return [SOFT ] member variable trace_level [boolean] * */ boolean replace_trace_level_DBSearchImpl(DBSearchImpl * obj,int trace_level) { if( obj == NULL) { warn("In replacement function trace_level for object DBSearchImpl, got a NULL object"); return FALSE; } obj->trace_level = trace_level; return TRUE; } /* Function: access_trace_level_DBSearchImpl(obj) * * Descrip: Access member variable trace_level * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DBSearchImpl *] * * Return [SOFT ] member variable trace_level [int] * */ int access_trace_level_DBSearchImpl(DBSearchImpl * obj) { if( obj == NULL) { warn("In accessor function trace_level for object DBSearchImpl, got a NULL object"); return 0; } return obj->trace_level; } /* Function: replace_trace_file_DBSearchImpl(obj,trace_file) * * Descrip: Replace member variable trace_file * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DBSearchImpl *] * Arg: trace_file [OWNER] New value of the variable [FILE *] * * Return [SOFT ] member variable trace_file [boolean] * */ boolean replace_trace_file_DBSearchImpl(DBSearchImpl * obj,FILE * trace_file) { if( obj == NULL) { warn("In replacement function trace_file for object DBSearchImpl, got a NULL object"); return FALSE; } obj->trace_file = trace_file; return TRUE; } /* Function: access_trace_file_DBSearchImpl(obj) * * Descrip: Access member variable trace_file * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DBSearchImpl *] * * Return [SOFT ] member variable trace_file [FILE *] * */ FILE * access_trace_file_DBSearchImpl(DBSearchImpl * obj) { if( obj == NULL) { warn("In accessor function trace_file for object DBSearchImpl, got a NULL object"); return NULL; } return obj->trace_file; } /* Function: replace_suggest_thread_no_DBSearchImpl(obj,suggest_thread_no) * * Descrip: Replace member variable suggest_thread_no * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DBSearchImpl *] * Arg: suggest_thread_no [OWNER] New value of the variable [int] * * Return [SOFT ] member variable suggest_thread_no [boolean] * */ boolean replace_suggest_thread_no_DBSearchImpl(DBSearchImpl * obj,int suggest_thread_no) { if( obj == NULL) { warn("In replacement function suggest_thread_no for object DBSearchImpl, got a NULL object"); return FALSE; } obj->suggest_thread_no = suggest_thread_no; return TRUE; } /* Function: access_suggest_thread_no_DBSearchImpl(obj) * * Descrip: Access member variable suggest_thread_no * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DBSearchImpl *] * * Return [SOFT ] member variable suggest_thread_no [int] * */ int access_suggest_thread_no_DBSearchImpl(DBSearchImpl * obj) { if( obj == NULL) { warn("In accessor function suggest_thread_no for object DBSearchImpl, got a NULL object"); return 0; } return obj->suggest_thread_no; } /* Function: replace_search_routine_DBSearchImpl(obj,search_routine) * * Descrip: Replace member variable search_routine * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DBSearchImpl *] * Arg: search_routine [OWNER] New value of the variable [int] * * Return [SOFT ] member variable search_routine [boolean] * */ boolean replace_search_routine_DBSearchImpl(DBSearchImpl * obj,int search_routine) { if( obj == NULL) { warn("In replacement function search_routine for object DBSearchImpl, got a NULL object"); return FALSE; } obj->search_routine = search_routine; return TRUE; } /* Function: access_search_routine_DBSearchImpl(obj) * * Descrip: Access member variable search_routine * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DBSearchImpl *] * * Return [SOFT ] member variable search_routine [int] * */ int access_search_routine_DBSearchImpl(DBSearchImpl * obj) { if( obj == NULL) { warn("In accessor function search_routine for object DBSearchImpl, got a NULL object"); return 0; } return obj->search_routine; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/dbsearchimpl.h0000644000175000001440000002064710670453712017455 0ustar philippusers#ifndef DYNAMITEdbsearchimplHEADERFILE #define DYNAMITEdbsearchimplHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" enum DBSearchImpl_Type { DBSearchImpl_Serial, DBSearchImpl_Pthreads, DBSearchImpl_MPI, DBSearchImpl_PVM }; /* lifted from HMMer2 for this sort of work. So thanks to * Sean Eddy and seems like warren gish as well */ /* Our problem here is that POSIX apparently doesn't specify * a standard for how to get sysconf() to report the number of * processors on-line. _SC_NPROCESSORS_ONLN is specified * by SVR4.0MP. Thanks to W. Gish for help here. */ #ifdef _SC_NPROCESSORS_ONLN /* Sun Solaris, Digital UNIX */ #define DBSEARCH_NPROC sysconf(_SC_NPROCESSORS_ONLN) #else #ifdef _SC_NPROC_ONLN /* Silicon Graphics IRIX */ #define DBSEARCH_NPROC sysconf(_SC_NPROC_ONLN) #else /* FreeBSD, Linux don't support getting ncpu via sysconf() */ #define DBSEARCH_NPROC -1 #endif #endif enum DBSearchImpl_Routine { DBSearchImplRoutine_Exact = 0, DBSearchImplRoutine_Kbest, DBSearchImplRoutine_Forward}; /* Object DBSearchImpl * * Descrip: No Description * */ struct Wise2_DBSearchImpl { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; int trace_level; /* how much debugging information to print */ FILE * trace_file; /* for writing out trace of db stuff */ int suggest_thread_no; /* default, -1, means the use a call to _SC_NPROC */ int search_routine; /* routine used for the calculation, exact/kbest */ } ; /* DBSearchImpl defined */ #ifndef DYNAMITE_DEFINED_DBSearchImpl typedef struct Wise2_DBSearchImpl Wise2_DBSearchImpl; #define DBSearchImpl Wise2_DBSearchImpl #define DYNAMITE_DEFINED_DBSearchImpl #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: impl_string_DBSearchImpl(dbsi) * * Descrip: Gets a static text string out of the * search implementation * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * * Return [SOFT ] string of the search implementation [char *] * */ char * Wise2_impl_string_DBSearchImpl(DBSearchImpl * dbsi); #define impl_string_DBSearchImpl Wise2_impl_string_DBSearchImpl /* Function: impl_string_routine_DBSearchImpl(dbsi) * * Descrip: Gets a static text string out of the * search routine implementation * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * * Return [SOFT ] string of the search implementation [char *] * */ char * Wise2_impl_string_routine_DBSearchImpl(DBSearchImpl * dbsi); #define impl_string_routine_DBSearchImpl Wise2_impl_string_routine_DBSearchImpl /* Function: number_of_threads_DBSearchImpl(dbsi) * * Descrip: This gets out the recommended number of * threads for a dbsi * * * Arg: dbsi [UNKN ] Undocumented argument [DBSearchImpl *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_number_of_threads_DBSearchImpl(DBSearchImpl * dbsi) ; #define number_of_threads_DBSearchImpl Wise2_number_of_threads_DBSearchImpl /* Function: new_MPI_DBSearchImpl(void) * * Descrip: Makes a new MPI DBSearchImpl * * For use mainly for api's who don't want * to initalize the object from the command * line * * * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ DBSearchImpl * Wise2_new_MPI_DBSearchImpl(void); #define new_MPI_DBSearchImpl Wise2_new_MPI_DBSearchImpl /* Function: new_pthread_DBSearchImpl(void) * * Descrip: Makes a new pthreaded DBSearchImpl * * For use mainly for api's who don't want * to initalize the object from the command * line * * * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ DBSearchImpl * Wise2_new_pthread_DBSearchImpl(void); #define new_pthread_DBSearchImpl Wise2_new_pthread_DBSearchImpl /* Function: new_serial_DBSearchImpl(void) * * Descrip: Makes a new serial DBSearchImpl * * For use mainly for api's who don't want * to initalize the object from the command * line * * * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ DBSearchImpl * Wise2_new_serial_DBSearchImpl(void); #define new_serial_DBSearchImpl Wise2_new_serial_DBSearchImpl /* Function: show_help_DBSearchImpl(ofp) * * Descrip: This shows the help for the search implementation * system. * * It prints out lines like * -pthreads use pthreaded code * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_help_DBSearchImpl(FILE * ofp); #define show_help_DBSearchImpl Wise2_show_help_DBSearchImpl /* Function: new_DBSearchImpl_from_argv(argc,argv) * * Descrip: This process command line arguments to * make a new DBSearchImpl. This way the * search implementation is relatively * flexible from the program which calls it. * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ DBSearchImpl * Wise2_new_DBSearchImpl_from_argv(int * argc,char ** argv); #define new_DBSearchImpl_from_argv Wise2_new_DBSearchImpl_from_argv /* Function: hard_link_DBSearchImpl(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DBSearchImpl *] * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ DBSearchImpl * Wise2_hard_link_DBSearchImpl(DBSearchImpl * obj); #define hard_link_DBSearchImpl Wise2_hard_link_DBSearchImpl /* Function: DBSearchImpl_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ DBSearchImpl * Wise2_DBSearchImpl_alloc(void); #define DBSearchImpl_alloc Wise2_DBSearchImpl_alloc /* Function: free_DBSearchImpl(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DBSearchImpl *] * * Return [UNKN ] Undocumented return value [DBSearchImpl *] * */ DBSearchImpl * Wise2_free_DBSearchImpl(DBSearchImpl * obj); #define free_DBSearchImpl Wise2_free_DBSearchImpl /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_trace_file_DBSearchImpl(DBSearchImpl * obj,FILE * trace_file); #define replace_trace_file_DBSearchImpl Wise2_replace_trace_file_DBSearchImpl FILE * Wise2_access_trace_file_DBSearchImpl(DBSearchImpl * obj); #define access_trace_file_DBSearchImpl Wise2_access_trace_file_DBSearchImpl int Wise2_access_type_DBSearchImpl(DBSearchImpl * obj); #define access_type_DBSearchImpl Wise2_access_type_DBSearchImpl boolean Wise2_replace_suggest_thread_no_DBSearchImpl(DBSearchImpl * obj,int suggest_thread_no); #define replace_suggest_thread_no_DBSearchImpl Wise2_replace_suggest_thread_no_DBSearchImpl int Wise2_access_trace_level_DBSearchImpl(DBSearchImpl * obj); #define access_trace_level_DBSearchImpl Wise2_access_trace_level_DBSearchImpl int Wise2_access_suggest_thread_no_DBSearchImpl(DBSearchImpl * obj); #define access_suggest_thread_no_DBSearchImpl Wise2_access_suggest_thread_no_DBSearchImpl boolean Wise2_replace_trace_level_DBSearchImpl(DBSearchImpl * obj,int trace_level); #define replace_trace_level_DBSearchImpl Wise2_replace_trace_level_DBSearchImpl boolean Wise2_replace_search_routine_DBSearchImpl(DBSearchImpl * obj,int search_routine); #define replace_search_routine_DBSearchImpl Wise2_replace_search_routine_DBSearchImpl boolean Wise2_replace_type_DBSearchImpl(DBSearchImpl * obj,int type); #define replace_type_DBSearchImpl Wise2_replace_type_DBSearchImpl int Wise2_access_search_routine_DBSearchImpl(DBSearchImpl * obj); #define access_search_routine_DBSearchImpl Wise2_access_search_routine_DBSearchImpl #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/dnaindexcons.dy0000644000175000001440000001126707713466714017672 0ustar philippusers %{ #include "subseqhash.h" #include "hsp.h" #include "hsphandler.h" #include "dnamatrix.h" typedef enum { DnaIndexConstructor_subseq = 438, } DnaIndexConstructorType; %} struct DnaIndexConstructor int type !def="DnaIndexConstructor_subseq" int index_word_length !def="7" Probability match_prob !def="0.8" int drop_off !def="30" struct DnaIndex int index_word_length SeqLookupInterface * sli CompMat * cm; int drop_off !def="30" %{ #include "dnaindexcons.h" %func Shows help for a DnaIndexConstructor %% void show_help_DnaIndexConstructor(FILE * ofp) { fprintf(ofp,"DnaIndex Constructor options\n"); fprintf(ofp," -dic_type [hash] type of DnaIndex\n"); fprintf(ofp," -dic_word [7] index word length\n"); fprintf(ofp," -dic_prob [0.85] match probabilty in extension\n"); fprintf(ofp," -dic_drop_off [30] drop off in HSP extension\n"); } %func Builds new DnaIndexConstructor off Command line %% DnaIndexConstructor * new_DnaIndexConstructor(int * argc,char ** argv) { DnaIndexConstructor * out; char * name; out = DnaIndexConstructor_alloc(); if( (name = strip_out_assigned_argument(argc,argv,"dic_type")) != NULL ) { if( strcmp(name,"hash") == 0 ) { out->type = DnaIndexConstructor_subseq; } else { fatal("Cannot recognise %s as a potential dna index type",name); } } strip_out_integer_argument(argc,argv,"dic_word",&out->index_word_length); strip_out_float_argument(argc,argv,"dic_prob",&out->match_prob); strip_out_integer_argument(argc,argv,"dic_drop_off",&out->drop_off); return out; } %func Makes a DnaIndex from a DnaIndexConstructore %% DnaIndex * DnaIndex_from_DnaIndexConstructor(DnaIndexConstructor * dic) { DnaIndex * out; DnaProbMatrix * dmp; DnaMatrix * dm; assert(dic); out = DnaIndex_alloc(); switch(dic->type) { case DnaIndexConstructor_subseq : out->sli = new_ghash_SeqLookupInterface(); break; default : warn("Unable to make DnaIndex from type %d",dic->type); return NULL; } out->index_word_length = dic->index_word_length; dmp = DnaProbMatrix_from_match(dic->match_prob,NMaskType_BANNED); assert(dmp); flat_null_DnaProbMatrix(dmp); dm = DnaMatrix_from_DnaProbMatrix(dmp); out->cm = new_CompMat_from_DnaMatrix_flat(dm); out->drop_off = dic->drop_off; free_DnaMatrix(dm); free_DnaProbMatrix(dmp); return out; } %func provides a LinearManager for a DNA sequence %% LinearHSPmanager * LinearHSPManager_scan_DnaIndex(DnaIndex * di,Sequence * query) { LinearHSPmanager * out; HSPmanager * hspm; hspm = HSPmanager_scan_DnaIndex(di,query); out = new_LinearHSPmanager_flat(hspm); free_HSPmanager(hspm); return out; } %func Provides a HSPmanager from a scan %% HSPmanager * HSPmanager_scan_DnaIndex(DnaIndex * di,Sequence * seq) { HSPmanager * out; SeqLookupClientInterface * slci; SeqLookupResultInterface * slri; SeqLookupResultStruct * res = NULL; int i; int no; assert(seq); assert(di); out = new_HSPmanager(seq,di->cm,di->drop_off); slci = (*di->sli->get_client)(di->sli->data); for(i=0;ilen-di->index_word_length;i++) { no = seq_number_dna_Nmer_noN(seq->seq+i,di->index_word_length); if( (*slci->is_populated)(slci->data,no) ) { slri = (*slci->lookup)(slci->data,no); for(;(*slri->is_more)(slri->data);) { res = (*slri->next)(slri->data,res); add_pair_HSPmanager(out,res->seq,i,res->pos); } free_SeqLookupResultInterface(slri); } } return out; } %func processes DNA based HSPs %% boolean process_dna_HSP(HSPset * set,Sequence * query,int query_pos,Sequence * tseq,SeqLookupResultStruct * res_struct,CompMat * mat) { int k; for(k=0;klen;k++) { if( on_HSP(set->hsp[k],query_pos,res_struct->pos) == TRUE ) { return FALSE; } } /* new HSP - extend and add */ add_HSPset(set,new_HSP(NULL,query,tseq,query_pos,res_struct->pos,mat,5*Probability2Score(0.8/0.25))); return TRUE; } %func Loads a sequence into a DnaIndex %% boolean load_Sequence_DnaIndex(DnaIndex * di,Sequence * seq,SeqLookupLoadPara * sllp) { int i; int no; assert(di); assert(seq); assert(di->sli); assert(sllp); for(i=0;ilen - di->index_word_length;i = i+sllp->tile_freq) { no = seq_number_dna_Nmer_noN(seq->seq+i,di->index_word_length); if( no != -1 ) { (*di->sli->add_direct_number)(di->sli->data,no,seq,i); } } return TRUE; } %func General DNA index number generation %% int seq_number_dna_Nmer_noN(char * seq,int index_length) { int i; int ret = 0; int base = 1; int no = 0; for(i=0;iseq[0]->len); for(i=0;ilen;i++) { if( sa->seq[i]->seq[pos] == '.' || sa->seq[i]->seq[pos] == '-' ) { return TRUE; } } return FALSE; } /* Function: trim_from_N_SeqAlign(sa) * * Descrip: trims sequence alignments to first and last * non N character (for DNA obviously) * * * Arg: sa [UNKN ] Undocumented argument [SeqAlign *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ # line 68 "seqalign.dy" SeqAlign * trim_from_N_SeqAlign(SeqAlign * sa) { int i; int j; int k; int left = 0; int right = 0; SeqAlign * out; Sequence * seq; char buffer[MAXLINE]; assert(sa); for(i=0;ilen;i++) { if( sa->seq[i]->len > left ) { left = sa->seq[i]->len; } } for(i=0;ilen;i++) { for(j=0;jseq[i]->len;j++) { if( sa->seq[i]->seq[j] != 'N' ) { break; } } if( left > j ) { left = j; } for(j=sa->seq[i]->len-1;j>=0;j--) { if( sa->seq[i]->seq[j] != 'N' ) { break; } } if ( right < j ) { right = j; } } right++; /* now we have left and right, make new sa */ out = SeqAlign_alloc_len(sa->len); for(i=0;ilen;i++) { seq = Sequence_alloc(); add_SeqAlign(out,seq); seq->name = stringalloc(sa->seq[i]->name); for(j=left,k=0;jseq[i]->len;j++,k++) { buffer[k] = sa->seq[i]->seq[j]; } for(;jseq = stringalloc(buffer); seq->len = k; seq->type = SEQUENCE_DNA; } return out; } /* Function: reweight_SeqAlign(sal) * * Descrip: Provides reweighting for a seqalign so all the weights * add up to 1.0 * * * Arg: sal [UNKN ] Undocumented argument [SeqAlign *] * */ # line 143 "seqalign.dy" void reweight_SeqAlign(SeqAlign * sal) { int i; double total =0.0; for(i=0;ilen;i++) { total += sal->seq[i]->weight; } for(i=0;ilen;i++) { sal->seq[i]->weight = sal->seq[i]->weight/ total; } } /* Function: ColumnCount_from_SeqAlign(sa,col) * * Descrip: Gives you a column count * * You are supposed to have enough sense to * cache this on the caller if you need it again * * * Arg: sa [UNKN ] Undocumented argument [SeqAlign *] * Arg: col [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ColumnCount *] * */ # line 165 "seqalign.dy" ColumnCount * ColumnCount_from_SeqAlign(SeqAlign * sa,int col) { ColumnCount * out; double count[27] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 , 0.0}; int i; if( sa == NULL || sa->seq[0]->len < col ) { warn("Cannot make column count at %d - out of range/seqalign null",col); return NULL; } for(i=0;ilen;i++) { if( sa->seq[i]->len < col ) { warn("For seqalign sequence %d (%s), although first seq ok, this doesn't extend to %d. Error.",i,sa->seq[i]->name,col); return NULL; } if ( isalpha(sa->seq[i]->seq[col]) ) { count[toupper(sa->seq[i]->seq[col]) - 'A']++; } else { count[26]++; } } out = ColumnCount_alloc(); for(i=0;i<27;i++) out->count[i] = count[i]; return out; } /* Function: write_selex_SeqAlign(sa,name_len,block_len,ofp) * * Descrip: Writes selex format * * * Arg: sa [UNKN ] Undocumented argument [const SeqAlign *] * Arg: name_len [UNKN ] Undocumented argument [int] * Arg: block_len [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 202 "seqalign.dy" boolean write_selex_SeqAlign(const SeqAlign * sa,int name_len,int block_len,FILE * ofp) { int col; int i; int j; int k; assert(sa); assert(ofp); assert(name_len > 1); assert(block_len > 1); for(col=0;colseq[0]->len;) { for(j=0;jlen;j++) { assert(sa->seq[j]->name); for(k=0;kseq[j]->name[k] != '\0';k++) { fputc(sa->seq[j]->name[k],ofp); } if( sa->seq[j]->name[k] == '\0' && k >= name_len ) { warn("In printing selex alignment, name %s is truncated at %d",sa->seq[j]->name,k); } /* put in the rest of k */ for(;kseq[j]->seq); for(i=col;(i - col) < block_len && i < sa->seq[j]->len ; i++) { fputc(sa->seq[j]->seq[i],ofp); } fputc('\n',ofp); } /* end over all sequences for this block */ col += block_len; fprintf(ofp,"\n\n"); } return TRUE; } /* Function: read_fasta_SeqAlign_file(filename) * * Descrip: Reads in fasta file opening the file * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ # line 253 "seqalign.dy" SeqAlign * read_fasta_SeqAlign_file(char * filename) { FILE * ifp; SeqAlign * out; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Cannot open file %s",filename); return NULL; } out = read_fasta_SeqAlign(ifp); fclose(ifp); return out; } /* Function: read_fasta_SeqAlign(ifp) * * Descrip: Reads in fasta file style alignments * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ # line 274 "seqalign.dy" SeqAlign * read_fasta_SeqAlign(FILE * ifp) { Sequence * seq; SeqAlign * out; out = SeqAlign_alloc_std(); while( (seq = read_fasta_Sequence(ifp)) != NULL ) { fprintf(stderr,"Adding sequence %s\n",seq->name); add_SeqAlign(out,seq); } /* in multi-fasta alignments, this indicates the end */ if( out->len == 0 ) { free_SeqAlign(out); return NULL; } return out; } /* Function: write_fasta_SeqAlign(sa,ofp) * * Descrip: writes out Fasta file * * * Arg: sa [UNKN ] Undocumented argument [SeqAlign *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 298 "seqalign.dy" void write_fasta_SeqAlign(SeqAlign * sa,FILE * ofp) { int i; for(i=0;ilen;i++) { write_fasta_Sequence(sa->seq[i],ofp); } } /* Function: read_selex_SeqAlign_file(filename) * * Descrip: Open files as well * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ # line 310 "seqalign.dy" SeqAlign * read_selex_SeqAlign_file(char * filename) { FILE * ifp; SeqAlign * out; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Cannot open file %s",filename); return NULL; } out = read_selex_SeqAlign(ifp); fclose(ifp); return out; } /* Function: read_selex_SeqAlign(ifp) * * Descrip: Reads in selex (Stockholm) alignment * * At the moment ignores all #= stuff on the * sequence * * Read HMMER documentation for a definition of * the format * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ # line 338 "seqalign.dy" SeqAlign * read_selex_SeqAlign(FILE * ifp) { char buffer[4096]; SeqAlign * out; Sequence * temp; int i; boolean isfirst; boolean isfseq; boolean isend; char * name; char * seq; char * strip; int pos; out = SeqAlign_alloc_std(); while( fgets(buffer,4096,ifp) != NULL ) { /*fprintf(stderr,"(selex) reading %s in selex alignment\n",buffer);*/ if( buffer[0] == '#' ) continue; /* skips over # */ if( buffer[0] == '/' && buffer[1] == '/' ) break; if( !isspace(buffer[0]) ) { /** in a block **/ i = 0; /* this is the first sequence */ if( out->len == 0 ) { isfirst = TRUE; isfseq = TRUE; } else { isfirst = FALSE; isfseq = FALSE; } for(;;) { /* strip trailing white space */ for(strip = buffer + strlen(buffer) - 1; strip > buffer && isspace(*strip);strip--) ; strip++; *strip = '\0'; for(name = seq = buffer;!isspace(*seq) && *seq; seq++) ; /** if '\0' - worry **/ if( !*seq ) { warn("For name %s in selex alignment, no sequence!",name); return out; } *seq = '\0'; if( isfirst == TRUE ) { temp = empty_Sequence_from_dynamic_memory(stringalloc(name)); add_SeqAlign(out,temp); } else { if ( i >= out->len ) { warn("For sequence %s, got over previous blocks size",name); return NULL; } temp = out->seq[i++]; } /* if is fseq, then find the next character */ if( isfseq == TRUE ) { for(seq++;*seq && isspace(*seq);seq++) ; if( *seq == '\0' ) { warn("In first sequence %s, got to end of line with no sequence!",name); return NULL; } isfseq = FALSE; pos = seq - buffer; } /* else pos is as normal */ /* map all non alnum chars to '-' */ for(seq = buffer+pos;*seq;seq++) { if( !isalnum(*seq) ) { *seq = '-'; } } /* add to sequence */ add_string_to_Sequence(temp,buffer+pos); /* get next line */ while( (seq = fgets(buffer,4096,ifp)) != NULL ) { /*fprintf(stderr,"(selex - 2nd loop) reading %s in selex alignment\n",buffer);*/ if( buffer[0] != '#' ) break; if( buffer[0] == '/' && buffer[1] == '/' ) break; } /*fprintf(stderr,"Broken from second loop\n");*/ if( seq == NULL ) { /*fprintf(stderr,"End of sequence?\n");*/ isend = TRUE; break; } if( buffer[0] == '/' && buffer[1] == '/' ) { /*fprintf(stderr,"double slash terminator?\n");*/ isend = TRUE; break; } /* if it is blank, break out of block */ if( !isalnum(buffer[0]) ) { /*fprintf(stderr,"Back to loop?\n");*/ break; } } if( isend == TRUE ) break; } /* end of was a non space line */ /* else - ignore it !*/ } return out; } # line 503 "seqalign.c" /* Function: swap_SeqAlign(list,i,j) * * Descrip: swap function: an internal for qsort_SeqAlign * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Sequence **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SeqAlign(Sequence ** list,int i,int j) { Sequence * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SeqAlign(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SeqAlign which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Sequence **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SeqAlign(Sequence ** list,int left,int right,int (*comp)(Sequence * ,Sequence * )) { int i,last; if( left >= right ) return; swap_SeqAlign(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SeqAlign (list,++last,i); } swap_SeqAlign (list,left,last); qsort_SeqAlign(list,left,last-1,comp); qsort_SeqAlign(list,last+1,right,comp); } /* Function: sort_SeqAlign(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SeqAlign * * * Arg: obj [UNKN ] Object containing list [SeqAlign *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SeqAlign(SeqAlign * obj,int (*comp)(Sequence *, Sequence *)) { qsort_SeqAlign(obj->seq,0,obj->len-1,comp); return; } /* Function: expand_SeqAlign(obj,len) * * Descrip: Really an internal function for add_SeqAlign * * * Arg: obj [UNKN ] Object which contains the list [SeqAlign *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SeqAlign(SeqAlign * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SeqAlign called with no need"); return TRUE; } if( (obj->seq = (Sequence ** ) ckrealloc (obj->seq,sizeof(Sequence *)*len)) == NULL) { warn("ckrealloc failed for expand_SeqAlign, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SeqAlign(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SeqAlign *] * Arg: add [OWNER] Object to add to the list [Sequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SeqAlign(SeqAlign * obj,Sequence * add) { if( obj->len >= obj->maxlen) { if( expand_SeqAlign(obj,obj->len + SeqAlignLISTLENGTH) == FALSE) return FALSE; } obj->seq[obj->len++]=add; return TRUE; } /* Function: flush_SeqAlign(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SeqAlign *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SeqAlign(SeqAlign * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->seq[i] != NULL) { free_Sequence(obj->seq[i]); obj->seq[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SeqAlign_alloc_std(void) * * Descrip: Equivalent to SeqAlign_alloc_len(SeqAlignLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * SeqAlign_alloc_std(void) { return SeqAlign_alloc_len(SeqAlignLISTLENGTH); } /* Function: SeqAlign_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * SeqAlign_alloc_len(int len) { SeqAlign * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SeqAlign_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->seq = (Sequence ** ) ckcalloc (len,sizeof(Sequence *))) == NULL) { warn("Warning, ckcalloc failed in SeqAlign_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SeqAlign(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqAlign *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * hard_link_SeqAlign(SeqAlign * obj) { if( obj == NULL ) { warn("Trying to hard link to a SeqAlign object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SeqAlign_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * SeqAlign_alloc(void) { SeqAlign * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SeqAlign *) ckalloc (sizeof(SeqAlign))) == NULL) { warn("SeqAlign_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->seq = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_SeqAlign(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeqAlign *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * free_SeqAlign(SeqAlign * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SeqAlign obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->seq != NULL) { for(i=0;ilen;i++) { if( obj->seq[i] != NULL) free_Sequence(obj->seq[i]); } ckfree(obj->seq); } ckfree(obj); return NULL; } /* Function: hard_link_ColumnCount(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ColumnCount *] * * Return [UNKN ] Undocumented return value [ColumnCount *] * */ ColumnCount * hard_link_ColumnCount(ColumnCount * obj) { if( obj == NULL ) { warn("Trying to hard link to a ColumnCount object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ColumnCount_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ColumnCount *] * */ ColumnCount * ColumnCount_alloc(void) { ColumnCount * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ColumnCount *) ckalloc (sizeof(ColumnCount))) == NULL) { warn("ColumnCount_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* count[27] is an array: no default possible */ return out; } /* Function: free_ColumnCount(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ColumnCount *] * * Return [UNKN ] Undocumented return value [ColumnCount *] * */ ColumnCount * free_ColumnCount(ColumnCount * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ColumnCount obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/seqalign.h0000644000175000001440000002465210670453712016623 0ustar philippusers#ifndef DYNAMITEseqalignHEADERFILE #define DYNAMITEseqalignHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #define SeqAlignLISTLENGTH 64 /* Object SeqAlign * * Descrip: The most stupid and bad representation * of a sequence alignment, being a list * of sequences with padding characters * in them * * Not very useful for anything but reformatting * and column frequencies. Dont use this * for complicated alignment manipulations. Use * the more hard core aln stuff * * For reading in this data structure, you can use * the wise2xhmmer2x bridge to Sean Eddy's reading * code. This copes inherently with automatically * detecting sequence alignment. * * Might bridge to his output stuff sometime as well... * * */ struct Wise2_SeqAlign { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; Sequence ** seq; int len;/* len for above seq */ int maxlen; /* maxlen for above seq */ } ; /* SeqAlign defined */ #ifndef DYNAMITE_DEFINED_SeqAlign typedef struct Wise2_SeqAlign Wise2_SeqAlign; #define SeqAlign Wise2_SeqAlign #define DYNAMITE_DEFINED_SeqAlign #endif /* Object ColumnCount * * Descrip: counts from a column of * an alignment * * */ struct Wise2_ColumnCount { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif double count[27]; } ; /* ColumnCount defined */ #ifndef DYNAMITE_DEFINED_ColumnCount typedef struct Wise2_ColumnCount Wise2_ColumnCount; #define ColumnCount Wise2_ColumnCount #define DYNAMITE_DEFINED_ColumnCount #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: is_gapped_SeqAlign(sa,pos) * * Descrip: Tells you whether either . or - characters occur at * a position. Uses C-style coordinates * * * Arg: sa [UNKN ] Undocumented argument [SeqAlign *] * Arg: pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_gapped_SeqAlign(SeqAlign * sa,int pos); #define is_gapped_SeqAlign Wise2_is_gapped_SeqAlign /* Function: trim_from_N_SeqAlign(sa) * * Descrip: trims sequence alignments to first and last * non N character (for DNA obviously) * * * Arg: sa [UNKN ] Undocumented argument [SeqAlign *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * Wise2_trim_from_N_SeqAlign(SeqAlign * sa); #define trim_from_N_SeqAlign Wise2_trim_from_N_SeqAlign /* Function: reweight_SeqAlign(sal) * * Descrip: Provides reweighting for a seqalign so all the weights * add up to 1.0 * * * Arg: sal [UNKN ] Undocumented argument [SeqAlign *] * */ void Wise2_reweight_SeqAlign(SeqAlign * sal); #define reweight_SeqAlign Wise2_reweight_SeqAlign /* Function: ColumnCount_from_SeqAlign(sa,col) * * Descrip: Gives you a column count * * You are supposed to have enough sense to * cache this on the caller if you need it again * * * Arg: sa [UNKN ] Undocumented argument [SeqAlign *] * Arg: col [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ColumnCount *] * */ ColumnCount * Wise2_ColumnCount_from_SeqAlign(SeqAlign * sa,int col); #define ColumnCount_from_SeqAlign Wise2_ColumnCount_from_SeqAlign /* Function: write_selex_SeqAlign(sa,name_len,block_len,ofp) * * Descrip: Writes selex format * * * Arg: sa [UNKN ] Undocumented argument [const SeqAlign *] * Arg: name_len [UNKN ] Undocumented argument [int] * Arg: block_len [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_write_selex_SeqAlign(const SeqAlign * sa,int name_len,int block_len,FILE * ofp); #define write_selex_SeqAlign Wise2_write_selex_SeqAlign /* Function: read_fasta_SeqAlign_file(filename) * * Descrip: Reads in fasta file opening the file * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * Wise2_read_fasta_SeqAlign_file(char * filename); #define read_fasta_SeqAlign_file Wise2_read_fasta_SeqAlign_file /* Function: read_fasta_SeqAlign(ifp) * * Descrip: Reads in fasta file style alignments * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * Wise2_read_fasta_SeqAlign(FILE * ifp); #define read_fasta_SeqAlign Wise2_read_fasta_SeqAlign /* Function: write_fasta_SeqAlign(sa,ofp) * * Descrip: writes out Fasta file * * * Arg: sa [UNKN ] Undocumented argument [SeqAlign *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_write_fasta_SeqAlign(SeqAlign * sa,FILE * ofp); #define write_fasta_SeqAlign Wise2_write_fasta_SeqAlign /* Function: read_selex_SeqAlign_file(filename) * * Descrip: Open files as well * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * Wise2_read_selex_SeqAlign_file(char * filename); #define read_selex_SeqAlign_file Wise2_read_selex_SeqAlign_file /* Function: read_selex_SeqAlign(ifp) * * Descrip: Reads in selex (Stockholm) alignment * * At the moment ignores all #= stuff on the * sequence * * Read HMMER documentation for a definition of * the format * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * Wise2_read_selex_SeqAlign(FILE * ifp); #define read_selex_SeqAlign Wise2_read_selex_SeqAlign /* Function: add_SeqAlign(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SeqAlign *] * Arg: add [OWNER] Object to add to the list [Sequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SeqAlign(SeqAlign * obj,Sequence * add); #define add_SeqAlign Wise2_add_SeqAlign /* Function: flush_SeqAlign(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SeqAlign *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SeqAlign(SeqAlign * obj); #define flush_SeqAlign Wise2_flush_SeqAlign /* Function: SeqAlign_alloc_std(void) * * Descrip: Equivalent to SeqAlign_alloc_len(SeqAlignLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * Wise2_SeqAlign_alloc_std(void); #define SeqAlign_alloc_std Wise2_SeqAlign_alloc_std /* Function: SeqAlign_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * Wise2_SeqAlign_alloc_len(int len); #define SeqAlign_alloc_len Wise2_SeqAlign_alloc_len /* Function: hard_link_SeqAlign(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqAlign *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * Wise2_hard_link_SeqAlign(SeqAlign * obj); #define hard_link_SeqAlign Wise2_hard_link_SeqAlign /* Function: SeqAlign_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * Wise2_SeqAlign_alloc(void); #define SeqAlign_alloc Wise2_SeqAlign_alloc /* Function: free_SeqAlign(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeqAlign *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * Wise2_free_SeqAlign(SeqAlign * obj); #define free_SeqAlign Wise2_free_SeqAlign /* Function: hard_link_ColumnCount(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ColumnCount *] * * Return [UNKN ] Undocumented return value [ColumnCount *] * */ ColumnCount * Wise2_hard_link_ColumnCount(ColumnCount * obj); #define hard_link_ColumnCount Wise2_hard_link_ColumnCount /* Function: ColumnCount_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ColumnCount *] * */ ColumnCount * Wise2_ColumnCount_alloc(void); #define ColumnCount_alloc Wise2_ColumnCount_alloc /* Function: free_ColumnCount(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ColumnCount *] * * Return [UNKN ] Undocumented return value [ColumnCount *] * */ ColumnCount * Wise2_free_ColumnCount(ColumnCount * obj); #define free_ColumnCount Wise2_free_ColumnCount /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_SeqAlign(Sequence ** list,int i,int j) ; #define swap_SeqAlign Wise2_swap_SeqAlign void Wise2_qsort_SeqAlign(Sequence ** list,int left,int right,int (*comp)(Sequence * ,Sequence * )); #define qsort_SeqAlign Wise2_qsort_SeqAlign void Wise2_sort_SeqAlign(SeqAlign * obj,int (*comp)(Sequence *, Sequence *)); #define sort_SeqAlign Wise2_sort_SeqAlign boolean Wise2_expand_SeqAlign(SeqAlign * obj,int len); #define expand_SeqAlign Wise2_expand_SeqAlign #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/sequence.pod0000644000175000001440000004034610670453712017161 0ustar philippusers=head1 NAME sequence module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item Sequence =item SequenceSet =back =head1 DESCRIPTION =head2 Object Sequence =over =item name Type [char *] Scalar name of the sequence =item seq Type [char *] Scalar actual sequence =item len Type [int] Scalar length of the sequence =item maxlen Type [int] Scalar internal counter, indicating how much space in seq there is =item offset Type [int] Scalar start (in bio-coords) of the sequence. Not called start due to weird legacy. =item end Type [int] Scalar end (in bio-coords == C coords) of the sequence =item type Type [char] Scalar guess of protein/dna type =item tax_id Type [int] Scalar taxonimic id of this =item weight Type [double] Scalar No documentation =item desc Type [char *] Scalar description - often this will be NULL =back This object is the basic sequence object, trying to hold little more than the name and sequence of the DNA/protein. The len/maxlen is the actual length of the sequence (strlen(obj->seq)) and amount of memory allocated in obj->seq mainly for parsing purposes. =head2 Member functions of Sequence =over =item uppercase &Wise2::Sequence::uppercase(seq) makes all the sequence uppercase Argument seq [RW ] Sequence to be uppercased [Sequence *] Return [UNKN ] Undocumented return value [void] =item force_to_dna &Wise2::Sequence::force_to_dna(seq,fraction,number_of_conver) This a) sees how many non ATGCN characters there are in Seq b) If the level is below fraction a) flips non ATGC chars to N b) writes number of conversions to number_of_conver c) returns TRUE c) else returns FALSE fraction of 0.0 means completely intolerant of errors fraction of 1.0 means completely tolerant of errors Argument seq [RW ] sequence object read and converted [Sequence *] Argument fraction [READ ] number 0..1 for tolerance of conversion [double] Return [READ ] TRUE for conversion to DNA, FALSE if not [boolean] =item is_reversed &Wise2::Sequence::is_reversed(seq) Currently the sequence object stores reversed sequences as start > end. This tests that and returns true if it is Argument seq [READ ] sequence to test [Sequence *] Return [UNKN ] Undocumented return value [boolean] =item translate &Wise2::Sequence::translate(dna,ct) This translates a DNA sequence to a protein. It assummes that it starts at first residue (use trunc_Sequence to chop a sequence up). Argument dna [READ ] DNA sequence to be translated [Sequence *] Argument ct [READ ] Codon table to do codon->aa mapping [CodonTable *] Return [OWNER] new protein sequence [Sequence *] =item revcomp &Wise2::Sequence::revcomp(seq) This both complements and reverses a sequence, - a common wish! The start/end are correct with respect to the start/end of the sequence (ie start = end, end = start). Argument seq [READ ] Sequence to that is used to reverse (makes a new Sequence) [Sequence *] Return [OWNER] new Sequence which is reversed [Sequence *] =item magic_trunc &Wise2::Sequence::magic_trunc(seq,start,end) Clever function for dna sequences. When start < end, truncates normally when start > end, truncates end,start and then reverse complements. ie. If you have a coordinate system where reverse sequences are labelled in reverse start/end way, then this routine produces the correct sequence. Argument seq [READ ] sequence that is the source to be truncated [Sequence *] Argument start [READ ] start point [int] Argument end [READ ] end point [int] Return [OWNER] new Sequence which is truncated/reversed [Sequence *] =item trunc &Wise2::Sequence::trunc(seq,start,end) truncates a sequence. It produces a new memory structure which is filled from sequence start to end. Please notice Truncation is in C coordinates. That is the first residue is 0 and end is the number of the residue after the cut-point. In otherwords to 2 - 3 would be a single residue truncation. So - if you want to work in more usual, 'inclusive' molecular biology numbers, which start at 1, then you need to say trunc_Sequence(seq,start-1,end); (NB, should be (end - 1 + 1) = end for the last coordinate). Truncation occurs against the *absolute* coordinate system of the Sequence, not the offset/end pair inside. So, this is a very bad error ** wrong code, and also leaks memory ** tru = trunc_Sequence(trunc_Sequence(seq,50,80),55,75); This the most portable way of doing this temp = trunc_Sequence(seq,50,80); tru = trunc_Sequence(temp,55-temp->offset,75-temp->offset); free_Sequence(temp); Argument seq [READ ] object holding the sequence to be truncated [Sequence *] Argument start [READ ] start point of truncation [int] Argument end [READ ] end point of truncation [int] Return [OWNER] newly allocated sequence structure [Sequence *] =item read_fasta_file_Sequence &Wise2::Sequence::read_fasta_file_Sequence(filename) Just a call a) open filename b) read sequence with /read_fasta_Sequence c) close file. Argument filename [READ ] filename to open [char *] Return [UNKN ] Undocumented return value [Sequence *] =item read_Sequence_EMBL_seq &Wise2::Sequence::read_Sequence_EMBL_seq(buffer,maxlen,ifp) reads the sequence part of an EMBL file. This function can either take a file which starts Argument buffer [RW ] buffer containing the first line. [char *] Argument maxlen [READ ] length of buffer [int] Argument ifp [READ ] input file to read from [FILE *] Return [UNKN ] Undocumented return value [Sequence *] =item read_fasta_Sequence &Wise2::Sequence::read_fasta_Sequence(ifp) reads a fasta file assumming pretty standard sanity for the file layout Argument ifp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [Sequence *] =item show_debug &Wise2::Sequence::show_debug(seq,start,end,ofp) shows a region of a sequence as 124 A 125 T etc from start to end. The numbers are in C coordinates (ie, 0 is the first letter). useful for debugging Argument seq [READ ] Sequence to show [Sequence *] Argument start [READ ] start of list [int] Argument end [READ ] end of list [int] Argument ofp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [void] =item write_fasta &Wise2::Sequence::write_fasta(seq,ofp) writes a fasta file of the form >name Sequence Argument seq [READ ] sequence to be written [Sequence *] Argument ofp [UNKN ] file to write to [FILE *] Return [UNKN ] Undocumented return value [void] =item validate &Wise2::Sequence::validate(seq) makes seq->len and seq->end match the seq->seq length number. It also checks the type of the sequence with /best_guess_type Argument seq [RW ] Sequence object [Sequence *] Return [UNKN ] Undocumented return value [void] =item hard_link_Sequence &Wise2::Sequence::hard_link_Sequence(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [Sequence *] Return [UNKN ] Undocumented return value [Sequence *] =item alloc &Wise2::Sequence::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [Sequence *] =item set_name &Wise2::Sequence::set_name(obj,name) Replace member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Argument name [OWNER] New value of the variable [char *] Return [SOFT ] member variable name [boolean] =item name &Wise2::Sequence::name(obj) Access member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Return [SOFT ] member variable name [char *] =item set_seq &Wise2::Sequence::set_seq(obj,seq) Replace member variable seq For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Argument seq [OWNER] New value of the variable [char *] Return [SOFT ] member variable seq [boolean] =item seq &Wise2::Sequence::seq(obj) Access member variable seq For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Return [SOFT ] member variable seq [char *] =item set_len &Wise2::Sequence::set_len(obj,len) Replace member variable len For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Argument len [OWNER] New value of the variable [int] Return [SOFT ] member variable len [boolean] =item len &Wise2::Sequence::len(obj) Access member variable len For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Return [SOFT ] member variable len [int] =item set_maxlen &Wise2::Sequence::set_maxlen(obj,maxlen) Replace member variable maxlen For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Argument maxlen [OWNER] New value of the variable [int] Return [SOFT ] member variable maxlen [boolean] =item maxlen &Wise2::Sequence::maxlen(obj) Access member variable maxlen For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Return [SOFT ] member variable maxlen [int] =item set_offset &Wise2::Sequence::set_offset(obj,offset) Replace member variable offset For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Argument offset [OWNER] New value of the variable [int] Return [SOFT ] member variable offset [boolean] =item offset &Wise2::Sequence::offset(obj) Access member variable offset For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Return [SOFT ] member variable offset [int] =item set_end &Wise2::Sequence::set_end(obj,end) Replace member variable end For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Argument end [OWNER] New value of the variable [int] Return [SOFT ] member variable end [boolean] =item end &Wise2::Sequence::end(obj) Access member variable end For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Return [SOFT ] member variable end [int] =item set_type &Wise2::Sequence::set_type(obj,type) Replace member variable type For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Argument type [OWNER] New value of the variable [char] Return [SOFT ] member variable type [boolean] =item type &Wise2::Sequence::type(obj) Access member variable type For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Return [SOFT ] member variable type [char] =item set_tax_id &Wise2::Sequence::set_tax_id(obj,tax_id) Replace member variable tax_id For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Argument tax_id [OWNER] New value of the variable [int] Return [SOFT ] member variable tax_id [boolean] =item tax_id &Wise2::Sequence::tax_id(obj) Access member variable tax_id For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Return [SOFT ] member variable tax_id [int] =item set_weight &Wise2::Sequence::set_weight(obj,weight) Replace member variable weight For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Argument weight [OWNER] New value of the variable [double] Return [SOFT ] member variable weight [boolean] =item weight &Wise2::Sequence::weight(obj) Access member variable weight For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Return [SOFT ] member variable weight [double] =item set_desc &Wise2::Sequence::set_desc(obj,desc) Replace member variable desc For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Argument desc [OWNER] New value of the variable [char *] Return [SOFT ] member variable desc [boolean] =item desc &Wise2::Sequence::desc(obj) Access member variable desc For use principly by API functions Argument obj [UNKN ] Object holding the variable [Sequence *] Return [SOFT ] member variable desc [char *] =back =head2 Object SequenceSet =over =item set Type [Sequence **] List No documentation =back A list of sequences. Not a database (you should use the db stuff for that!). But useful anyway =head2 Member functions of SequenceSet =over =item hard_link_SequenceSet &Wise2::SequenceSet::hard_link_SequenceSet(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [SequenceSet *] Return [UNKN ] Undocumented return value [SequenceSet *] =item SequenceSet_alloc_std &Wise2::SequenceSet::SequenceSet_alloc_std(void) Equivalent to SequenceSet_alloc_len(SequenceSetLISTLENGTH) Return [UNKN ] Undocumented return value [SequenceSet *] =item set &Wise2::SequenceSet::set(obj,i) Access members stored in the set list For use principly by API functions Argument obj [UNKN ] Object holding the list [SequenceSet *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [Sequence *] =item length_set &Wise2::SequenceSet::length_set(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [SequenceSet *] Return [UNKN ] length of the list [int] =item flush_set &Wise2::SequenceSet::flush_set(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [SequenceSet *] Return [UNKN ] Undocumented return value [int] =item add_set &Wise2::SequenceSet::add_set(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [SequenceSet *] Argument add [OWNER] Object to add to the list [Sequence *] Return [UNKN ] Undocumented return value [boolean] =back =over =item Sequence_type_to_string &Wise2::Sequence_type_to_string(type) Converts sequence type (SEQUENCE_*) to a string Argument type [UNKN ] type eg SEQUENCE_PROTEIN [int] Return [UNKN ] Undocumented return value [char *] =item new_Sequence_from_strings &Wise2::new_Sequence_from_strings(name,seq) Makes a new sequence from strings given. Separate memory will be allocated for them and them copied into it. They can be NULL, in which case o a dummy name SequenceName will be assigned o No sequence placed and length of zero. Though this is dangerous later on. The sequence type is calculated automatically using /best_guess_type. If you want a DNA sequence but are unsure of the content of, for example, IUPAC codes, please use /force_to_dna_Sequence before using the sequence. Most of the rest of dynamite relies on a five letter A,T,G,C,N alphabet, but this function will allow any sequence type to be stored, so please check if you want to save yourself alot of grief. In perl and other interfaces, this is a much safer constructor than the raw "new" type Argument name [READ ] name of sequence, memory is allocated for it. [char *] Argument seq [READ ] char * of sequence, memory is allocated for it. [char *] Return [UNKN ] Undocumented return value [Sequence *] =back wise-2.4.1/src/dynlibsrc/sequence.tex0000644000175000001440000003053310670453712017174 0ustar philippusers\section{sequence} \label{module_sequence} This module contains the following objects \begin{itemize} \item \ref{object_Sequence} Sequence \item \ref{object_SequenceSet} SequenceSet \item This module also contains some factory methods \end{itemize} \subsection{sequence factory methods} \subsubsection{Sequence_type_to_string} \begin{description} \item[External C] {\tt Wise2_Sequence_type_to_string (type)} \item[Perl] {\tt &Wise2::Sequence_type_to_string (type)} \end{description} Arguments \begin{description} \item[type] [UNKN ] type eg SEQUENCE_PROTEIN [int] \item[returns] [UNKN ] Undocumented return value [char *] \end{description} Converts sequence type (SEQUENCE_*) to a string \subsubsection{new_Sequence_from_strings} \begin{description} \item[External C] {\tt Wise2_new_Sequence_from_strings (name,seq)} \item[Perl] {\tt &Wise2::new_Sequence_from_strings (name,seq)} \end{description} Arguments \begin{description} \item[name] [READ ] name of sequence, memory is allocated for it. [char *] \item[seq] [READ ] char * of sequence, memory is allocated for it. [char *] \item[returns] [UNKN ] Undocumented return value [Sequence *] \end{description} Makes a new sequence from strings given. Separate memory will be allocated for them and them copied into it. They can be NULL, in which case o a dummy name SequenceName will be assigned o No sequence placed and length of zero. Though this is dangerous later on. The sequence type is calculated automatically using /best_guess_type. If you want a DNA sequence but are unsure of the content of, for example, IUPAC codes, please use /force_to_dna_Sequence before using the sequence. Most of the rest of dynamite relies on a five letter A,T,G,C,N alphabet, but this function will allow any sequence type to be stored, so please check if you want to save yourself alot of grief. In perl and other interfaces, this is a much safer constructor than the raw "new" type \subsection{Object Sequence} \label{object_Sequence} The Sequence object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{name} Type [char * : Scalar] name of the sequence \item{seq} Type [char * : Scalar] actual sequence \item{len} Type [int : Scalar] length of the sequence \item{maxlen} Type [int : Scalar] internal counter, indicating how much space in seq there is \item{offset} Type [int : Scalar] start (in bio-coords) of the sequence. Not called start due to weird legacy. \item{end} Type [int : Scalar] end (in bio-coords == C coords) of the sequence \item{type} Type [char : Scalar] guess of protein/dna type \item{tax_id} Type [int : Scalar] taxonimic id of this \item{weight} Type [double : Scalar] No documentation \item{desc} Type [char * : Scalar] description - often this will be NULL \end{description} This object is the basic sequence object, trying to hold little more than the name and sequence of the DNA/protein. The len/maxlen is the actual length of the sequence (strlen(obj->seq)) and amount of memory allocated in obj->seq mainly for parsing purposes. Member functions of Sequence \subsubsection{uppercase_Sequence} \begin{description} \item[External C] {\tt Wise2_uppercase_Sequence (seq)} \item[Perl] {\tt &Wise2::Sequence::uppercase (seq)} \item[Perl-OOP call] {\tt $obj->uppercase()} \end{description} Arguments \begin{description} \item[seq] [RW ] Sequence to be uppercased [Sequence *] \item[returns] Nothing - no return value \end{description} makes all the sequence uppercase \subsubsection{force_to_dna_Sequence} \begin{description} \item[External C] {\tt Wise2_force_to_dna_Sequence (seq,fraction,number_of_conver)} \item[Perl] {\tt &Wise2::Sequence::force_to_dna (seq,fraction)} \item[Perl-OOP call] {\tt $obj->force_to_dna(fraction)} \end{description} Arguments \begin{description} \item[seq] [RW ] sequence object read and converted [Sequence *] \item[fraction] [READ ] number 0..1 for tolerance of conversion [double] \item[number_of_conver] \em{only for C api} [WRITE] number of conversions actually made [int *] \item[returns] [READ ] TRUE for conversion to DNA, FALSE if not [boolean] \end{description} This \begin{verbatim} a) sees how many non ATGCN characters there are in Seq b) If the level is below fraction a) flips non ATGC chars to N b) writes number of conversions to number_of_conver c) returns TRUE c) else returns FALSE \end{verbatim} fraction of 0.0 means completely intolerant of errors fraction of 1.0 means completely tolerant of errors \subsubsection{is_reversed_Sequence} \begin{description} \item[External C] {\tt Wise2_is_reversed_Sequence (seq)} \item[Perl] {\tt &Wise2::Sequence::is_reversed (seq)} \item[Perl-OOP call] {\tt $obj->is_reversed()} \end{description} Arguments \begin{description} \item[seq] [READ ] sequence to test [Sequence *] \item[returns] [UNKN ] Undocumented return value [boolean] \end{description} Currently the sequence object stores reversed sequences as start > end. This tests that and returns true if it is \subsubsection{translate_Sequence} \begin{description} \item[External C] {\tt Wise2_translate_Sequence (dna,ct)} \item[Perl] {\tt &Wise2::Sequence::translate (dna,ct)} \item[Perl-OOP call] {\tt $obj->translate(ct)} \end{description} Arguments \begin{description} \item[dna] [READ ] DNA sequence to be translated [Sequence *] \item[ct] [READ ] Codon table to do codon->aa mapping [CodonTable *] \item[returns] [OWNER] new protein sequence [Sequence *] \end{description} This translates a DNA sequence to a protein. It assummes that it starts at first residue (use trunc_Sequence to chop a sequence up). \subsubsection{reverse_complement_Sequence} \begin{description} \item[External C] {\tt Wise2_reverse_complement_Sequence (seq)} \item[Perl] {\tt &Wise2::Sequence::revcomp (seq)} \item[Perl-OOP call] {\tt $obj->revcomp()} \end{description} Arguments \begin{description} \item[seq] [READ ] Sequence to that is used to reverse (makes a new Sequence) [Sequence *] \item[returns] [OWNER] new Sequence which is reversed [Sequence *] \end{description} This both complements and reverses a sequence, - a common wish! The start/end are correct with respect to the start/end of the sequence (ie start = end, end = start). \subsubsection{magic_trunc_Sequence} \begin{description} \item[External C] {\tt Wise2_magic_trunc_Sequence (seq,start,end)} \item[Perl] {\tt &Wise2::Sequence::magic_trunc (seq,start,end)} \item[Perl-OOP call] {\tt $obj->magic_trunc(start,end)} \end{description} Arguments \begin{description} \item[seq] [READ ] sequence that is the source to be truncated [Sequence *] \item[start] [READ ] start point [int] \item[end] [READ ] end point [int] \item[returns] [OWNER] new Sequence which is truncated/reversed [Sequence *] \end{description} Clever function for dna sequences. When start < end, truncates normally when start > end, truncates end,start and then reverse complements. ie. If you have a coordinate system where reverse sequences are labelled in reverse start/end way, then this routine produces the correct sequence. \subsubsection{trunc_Sequence} \begin{description} \item[External C] {\tt Wise2_trunc_Sequence (seq,start,end)} \item[Perl] {\tt &Wise2::Sequence::trunc (seq,start,end)} \item[Perl-OOP call] {\tt $obj->trunc(start,end)} \end{description} Arguments \begin{description} \item[seq] [READ ] object holding the sequence to be truncated [Sequence *] \item[start] [READ ] start point of truncation [int] \item[end] [READ ] end point of truncation [int] \item[returns] [OWNER] newly allocated sequence structure [Sequence *] \end{description} truncates a sequence. It produces a new memory structure which is filled from sequence start to end. Please notice \begin{verbatim} Truncation is in C coordinates. That is \end{verbatim} the first residue is 0 and end is the number of the residue after the cut-point. In otherwords to 2 - 3 would be a single residue truncation. So - if you want to work in more usual, 'inclusive' molecular biology numbers, which start at 1, then you need to say \begin{verbatim} trunc_Sequence(seq,start-1,end); \end{verbatim} (NB, should be (end - 1 + 1) = end for the last coordinate). \begin{verbatim} Truncation occurs against the *absolute* coordinate \end{verbatim} system of the Sequence, not the offset/end pair inside. So, this is a very bad error \begin{verbatim} ** wrong code, and also leaks memory ** tru = trunc_Sequence(trunc_Sequence(seq,50,80),55,75); \end{verbatim} This the most portable way of doing this \begin{verbatim} temp = trunc_Sequence(seq,50,80); tru = trunc_Sequence(temp,55-temp->offset,75-temp->offset); free_Sequence(temp); \end{verbatim} \subsubsection{read_fasta_file_Sequence} \begin{description} \item[External C] {\tt Wise2_read_fasta_file_Sequence (filename)} \item[Perl] {\tt &Wise2::Sequence::read_fasta_file_Sequence (filename)} \item[Perl-OOP call] {\tt $obj->read_fasta_file_Sequence()} \end{description} Arguments \begin{description} \item[filename] [READ ] filename to open [char *] \item[returns] [UNKN ] Undocumented return value [Sequence *] \end{description} Just a call \begin{verbatim} a) open filename b) read sequence with /read_fasta_Sequence c) close file. \end{verbatim} \subsubsection{read_Sequence_EMBL_seq} \begin{description} \item[External C] {\tt Wise2_read_Sequence_EMBL_seq (buffer,maxlen,ifp)} \item[Perl] {\tt &Wise2::Sequence::read_Sequence_EMBL_seq (buffer,maxlen,ifp)} \item[Perl-OOP call] {\tt $obj->read_Sequence_EMBL_seq(maxlen,ifp)} \end{description} Arguments \begin{description} \item[buffer] [RW ] buffer containing the first line. [char *] \item[maxlen] [READ ] length of buffer [int] \item[ifp] [READ ] input file to read from [FILE *] \item[returns] [UNKN ] Undocumented return value [Sequence *] \end{description} reads the sequence part of an EMBL file. This function can either take a file which starts \subsubsection{read_fasta_Sequence} \begin{description} \item[External C] {\tt Wise2_read_fasta_Sequence (ifp)} \item[Perl] {\tt &Wise2::Sequence::read_fasta_Sequence (ifp)} \item[Perl-OOP call] {\tt $obj->read_fasta_Sequence()} \end{description} Arguments \begin{description} \item[ifp] [UNKN ] Undocumented argument [FILE *] \item[returns] [UNKN ] Undocumented return value [Sequence *] \end{description} reads a fasta file assumming pretty standard sanity for the file layout \subsubsection{show_Sequence_residue_list} \begin{description} \item[External C] {\tt Wise2_show_Sequence_residue_list (seq,start,end,ofp)} \item[Perl] {\tt &Wise2::Sequence::show_debug (seq,start,end,ofp)} \item[Perl-OOP call] {\tt $obj->show_debug(start,end,ofp)} \end{description} Arguments \begin{description} \item[seq] [READ ] Sequence to show [Sequence *] \item[start] [READ ] start of list [int] \item[end] [READ ] end of list [int] \item[ofp] [UNKN ] Undocumented argument [FILE *] \item[returns] Nothing - no return value \end{description} shows a region of a sequence as \begin{verbatim} 124 A 125 T \end{verbatim} etc from start to end. The numbers are in C coordinates (ie, 0 is the first letter). useful for debugging \subsubsection{write_fasta_Sequence} \begin{description} \item[External C] {\tt Wise2_write_fasta_Sequence (seq,ofp)} \item[Perl] {\tt &Wise2::Sequence::write_fasta (seq,ofp)} \item[Perl-OOP call] {\tt $obj->write_fasta(ofp)} \end{description} Arguments \begin{description} \item[seq] [READ ] sequence to be written [Sequence *] \item[ofp] [UNKN ] file to write to [FILE *] \item[returns] Nothing - no return value \end{description} writes a fasta file of the form >name Sequence \subsubsection{make_len_type_Sequence} \begin{description} \item[External C] {\tt Wise2_make_len_type_Sequence (seq)} \item[Perl] {\tt &Wise2::Sequence::validate (seq)} \item[Perl-OOP call] {\tt $obj->validate()} \end{description} Arguments \begin{description} \item[seq] [RW ] Sequence object [Sequence *] \item[returns] Nothing - no return value \end{description} makes seq->len and seq->end match the seq->seq length number. It also checks the type of the sequence with /best_guess_type \subsection{Object SequenceSet} \label{object_SequenceSet} The SequenceSet object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{set} Type [Sequence ** : List] No documentation \end{description} A list of sequences. Not a database (you should use the db stuff for that!). But useful anyway Member functions of SequenceSet wise-2.4.1/src/dynlibsrc/sequencedb.c0000644000175000001440000010751110670453713017126 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "sequencedb.h" /* Function: get_Sequence_from_SequenceDB(sdb,de) * * Descrip: Quite a mindless function which retrieves sequences * via indexes * * Going to spend too much time in fopen if this is used * too much * * * Arg: sdb [UNKN ] Undocumented argument [SequenceDB *] * Arg: de [UNKN ] Undocumented argument [DataEntry *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 76 "sequencedb.dy" Sequence * get_Sequence_from_SequenceDB(SequenceDB * sdb,DataEntry * de) { FILE * ifp; Sequence * ret; if( de == NULL ) { warn("Cannot get sequence database entry with a null dataentry!"); return NULL; } if( sdb == NULL ) { warn("Cannot get sequence database entry with a null sequence db!"); return NULL; } if( de->filename == NULL ) { warn("Cannot get sequence database entry with no attached filename"); return NULL; } /* actually, all our info is in dataentry */ ifp = openfile(de->filename,"r"); if( ifp == NULL ) { warn("Bad error - could not open database file %s for reading indexed sequence",de->filename); return NULL; } fseek(ifp,de->byte_position,SEEK_SET); switch(de->data[1]) { case SEQ_DB_FASTA : ret = read_fasta_Sequence(ifp); break; default : warn("Unknown SequenceDB type [%d]",de->data[1]); ret = NULL; } fclose(ifp); return ret; } /* Function: add_SequenceDB_info_DataEntry(sdb,de) * * Descrip: A function which places data into dataentry so we can * be guarenteed to retrieve it sometime. * * It uses 0 and 1 points in the Data array. * * * Arg: sdb [UNKN ] Undocumented argument [SequenceDB *] * Arg: de [UNKN ] Undocumented argument [DataEntry *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 129 "sequencedb.dy" boolean add_SequenceDB_info_DataEntry(SequenceDB * sdb,DataEntry * de) { if( sdb == NULL || de == NULL ) { warn("Null objects being passed into add_SequenceDB_info_DataEntry. Can't be good!"); return FALSE; } de->filename = sdb->fs[sdb->current_source]->filename; /* if there... */ de->byte_position = sdb->byte_position; /* of this sequence */ de->data[1] = sdb->fs[sdb->current_source]->format; return TRUE; } /* Function: close_SequenceDB(last,sdb) * * Descrip: top level function that closes the SequenceDB * after the last sequence is read. * * * Arg: last [WRITE] Sequence object to be freed [Sequence *] * Arg: sdb [READ ] database to be closed [SequenceDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 151 "sequencedb.dy" boolean close_SequenceDB(Sequence * last,SequenceDB * sdb) { if( last != NULL ) free_Sequence(last); if( sdb->sequence_no == 1 && sdb->has_warned_single == 0) { info("Your sequence database has only sequence in it. It is quite likely there was a more efficient way to run this"); sdb->has_warned_single = 1; } /*** nothing else to do? ***/ sdb->current_source = (-1); return TRUE; } /* Function: init_SequenceDB(sdb,return_status) * * Descrip: top level function that starts a database read on * SequenceDB * * * * Arg: sdb [READ ] sequence database [SequenceDB *] * Arg: return_status [WRITE] returns the database status as found in database.h [int *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 175 "sequencedb.dy" Sequence * init_SequenceDB(SequenceDB * sdb,int * return_status) { Sequence * temp = NULL; int count; sdb->current_source = 0; sdb->sequence_no =0; load_next_fs_SequenceDB(sdb); if( sdb->seq_start != -1 && sdb->seq_end != -1 ) { for(count=0;count <= sdb->seq_start;count++) { temp = reload_SequenceDB(temp,sdb,return_status); } return temp; } return reload_SequenceDB(NULL,sdb,return_status); } /* Function: reload_SequenceDB(last,sdb,return_status) * * Descrip: top level function that reloads a sequence database * * * * Arg: last [WRITE] previous sequence to be used: will simply be freed at the moment [Sequence *] * Arg: sdb [UNKN ] sequence database [SequenceDB *] * Arg: return_status [WRITE] returns the database status as found in database.h [int *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 202 "sequencedb.dy" Sequence * reload_SequenceDB(Sequence * last,SequenceDB * sdb,int * return_status) { Sequence * out; int count = 0; /* * free last Sequence: if we did something clever with * memory, this is where we should do it */ if( last != NULL ) free_Sequence(last); /* if there is a seq_end, then see whether this is the end */ if( sdb->seq_end != -1 && sdb->sequence_no == sdb->seq_end ) { /* end */ sdb->current_source = -1; *return_status = DB_RETURN_END; return NULL; } /** see if we can read a Sequence now **/ if( (out = get_next_SequenceDB(sdb)) != NULL ) { *return_status = DB_RETURN_OK; sdb->sequence_no++; return out; } if( SequenceDB_at_end(sdb) == TRUE ) { if( close_last_fs_SequenceDB(sdb) == FALSE ) { warn("On file source [%d] [%s] could not close",sdb->current_source,sdb->fs[sdb->current_source]->filename); *return_status = DB_RETURN_ERROR; return NULL; } *return_status = DB_RETURN_END; return NULL; } /** ok, see if we can swap FileSources then **/ for(;;) { if( close_last_fs_SequenceDB(sdb) == FALSE ) { warn("On file source [%d] [%s] could not close",sdb->current_source,sdb->fs[sdb->current_source]->filename); *return_status = DB_RETURN_ERROR; return NULL; } if( load_next_fs_SequenceDB(sdb) == FALSE ) { warn("On file source [%d] [%s] could not open the file",sdb->current_source+1,sdb->fs[sdb->current_source+1]->filename); *return_status = DB_RETURN_ERROR; return NULL; } if( (out = get_next_SequenceDB(sdb)) != NULL ) { *return_status = DB_RETURN_OK; return out; } count++; warn("Ok, don't like this, just loaded the next Filesource, and got no sequence. Nope!"); if( SequenceDB_at_end(sdb) == TRUE ) { *return_status = DB_RETURN_END; return NULL; } if( count > 10 ) { /*** break out of infinite loop ***/ warn("Too many failed reloads of databases, going to fail"); *return_status = DB_RETURN_ERROR; return NULL; } } /** back for for(;;) **/ } /* Function: get_next_SequenceDB(sdb) * * Descrip: Main switch around formats * * * Arg: sdb [UNKN ] Undocumented argument [SequenceDB *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 290 "sequencedb.dy" Sequence * get_next_SequenceDB(SequenceDB * sdb) { /* remember the byte position now */ sdb->byte_position = ftell(sdb->current_file); switch (sdb->fs[sdb->current_source]->format) { case SEQ_DB_FASTA : return read_fasta_Sequence(sdb->current_file); default : warn("Unknown SequenceDB type [%d]",sdb->fs[sdb->current_source]->format); return NULL; } } /* Function: SequenceDB_at_end(sdb) * * Descrip: Tells you if the SequenceDB is actually ended * in terms of no more FileSources to eat through * * * Arg: sdb [UNKN ] Undocumented argument [SequenceDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 312 "sequencedb.dy" boolean SequenceDB_at_end(SequenceDB * sdb) { if( sdb->current_source == -1 ) { warn("Bad bug: asking when it has finished when you have not init'd seqdb %s",sdb->name); return TRUE; } if( sdb->current_source+1 < sdb->len ) { return FALSE; } return TRUE; } /* Function: load_next_fs_SequenceDB(sdb) * * Descrip: Opens or attaches next FileSource stream * * Does not close anything - use /close_last_fs_SequenceDB * * * Arg: sdb [UNKN ] Undocumented argument [SequenceDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 333 "sequencedb.dy" boolean load_next_fs_SequenceDB(SequenceDB * sdb) { FileSource * fs; if( sdb->current_source == -1 ) { warn("Bad bug: trying to close last source when you have not init'd seqdb %s",sdb->name); return FALSE; } if( sdb->current_source >= sdb->len ) { warn("Bad bug. Someone is trying to load the next fs file when there are none (has not tested with SequenceDB_at_end...). So. I will fail, but database is actually at the end"); return FALSE; } fs = sdb->fs[sdb->current_source]; if( fs->filename != NULL ) { if( (sdb->current_file = openfile(fs->filename,"r")) == NULL ) { warn("Could not open file [%s] for database [%s]",fs->filename,sdb->name); return FALSE; } } else { sdb->current_file = fs->input; } return TRUE; } /* Function: close_last_fs_SequenceDB(sdb) * * Descrip: closes the last FileSource: checks if it was a straight stream * (in which case does not close) * * * Arg: sdb [UNKN ] Undocumented argument [SequenceDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 367 "sequencedb.dy" boolean close_last_fs_SequenceDB(SequenceDB * sdb) { FileSource * fs; if( sdb->current_source == -1 ) { warn("Bad bug: trying to close last source when you have not init'd seqdb %s",sdb->name); return FALSE; } fs = sdb->fs[sdb->current_source]; if( fs->filename != NULL ) { fclose(sdb->current_file); } else if( fs->input != NULL ) { warn("Can't handle closes on streams yet. Not sure what to do!"); } sdb->current_source++; return TRUE; } /*** I/O ****/ /* Function: SequenceDB_from_FILE_and_format(input,format) * * Descrip: makes a SequencDB from a straight file stream. * * This means SequenceDB will *not* close it when * the SequenceDB is closed. * * * Arg: input [READ ] filestream [FILE *] * Arg: format [UNKN ] format as defined by /word_to_format [int] * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ # line 403 "sequencedb.dy" SequenceDB * SequenceDB_from_FILE_and_format(FILE * input,int format) { SequenceDB * out; FileSource * fs; out = SequenceDB_alloc_len(1); fs = FileSource_from_FILE_and_format(input,format); add_SequenceDB(out,fs); return out; } /* Function: FileSource_from_FILE_and_format(input,format) * * Descrip: Makes a file source from a straigth stream * * * Arg: input [UNKN ] Undocumented argument [FILE *] * Arg: format [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [FileSource *] * */ # line 422 "sequencedb.dy" FileSource * FileSource_from_FILE_and_format(FILE * input,int format) { FileSource * fs; fs = FileSource_alloc(); fs->input = input; fs->format = format; return fs; } /* Function: single_fasta_SequenceDB(filename) * * Descrip: pre-packed single fasta file db * * * * Arg: filename [UNKN ] name of fastadb [char *] * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ # line 440 "sequencedb.dy" SequenceDB * single_fasta_SequenceDB(char * filename) { SequenceDB * out; FileSource * fs; if( touchfile(filename) == FALSE) { warn("Cannot make SequenceDB from an unopenable fileanme [%s]",filename); return NULL; } fs = FileSource_alloc(); fs->filename = stringalloc(filename); fs->format = SEQ_DB_FASTA; out = SequenceDB_alloc_len(1); out->seq_start = -1; out->seq_end = -1; add_SequenceDB(out,fs); return out; } /* Function: read_SequenceDB_line(line,ifp) * * Descrip: Reads a SequenceDB definition from * * seqdb * * ... * endseqdb * * * * Arg: line [UNKN ] starting line (seqdb line) [char *] * Arg: ifp [UNKN ] file input [FILE *] * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ # line 476 "sequencedb.dy" SequenceDB * read_SequenceDB_line(char * line,FILE * ifp) { SequenceDB * out = NULL; FileSource * fs; char buffer[MAXLINE]; char * runner; if( strstartcmp(line,"seqdb") != 0 ) { warn("Attempting to read a sequence line without a seqdb start"); return NULL; } runner = strtok(line,spacestr); runner = strtok(line,spacestr); if( runner == NULL ) { out->name = stringalloc("UnNamedDatabase"); } else out->name = stringalloc(runner); out = SequenceDB_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ){ if( strstartcmp(buffer,"#") == 0 ) continue; if( strstartcmp(buffer,"end") == 0 ) break; fs = FileSource_from_line(buffer); if( fs != NULL ) add_SequenceDB(out,fs); } return out; } /* Function: word_to_format(word) * * Descrip: converts char * to format for SequenceDB FileSources * * * Arg: word [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 516 "sequencedb.dy" int word_to_format(char * word) { if( strcmp(word,"fasta") == 0 ) { return SEQ_DB_FASTA; } return SEQ_DB_UNKNOWN; } /* Function: FileSource_from_line(line) * * Descrip: Reads line * filename format type * * where format is determined by /word_to_format * and type is protein/dna * * * Arg: line [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [FileSource *] * */ # line 534 "sequencedb.dy" FileSource * FileSource_from_line(char * line) { FileSource * out; char * runner; char * run2; char * run3; runner = strtok(line,spacestr); run2 = strtok(line,spacestr); run3 = strtok(line,spacestr); if( runner == NULL || run2 == NULL || run3 == NULL ) { warn("You have not provided a database source line"); return NULL; } out = FileSource_alloc(); out->filename = stringalloc(runner); if( (out->format = word_to_format(run2)) == SEQ_DB_UNKNOWN) { warn("For filename %s, the format [%s] is unknown to me",runner,run2); } return out; } # line 579 "sequencedb.c" /* Function: hard_link_FileSource(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FileSource *] * * Return [UNKN ] Undocumented return value [FileSource *] * */ FileSource * hard_link_FileSource(FileSource * obj) { if( obj == NULL ) { warn("Trying to hard link to a FileSource object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: FileSource_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FileSource *] * */ FileSource * FileSource_alloc(void) { FileSource * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(FileSource *) ckalloc (sizeof(FileSource))) == NULL) { warn("FileSource_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->filename = NULL; out->format = 0; out->type = 0; return out; } /* Function: free_FileSource(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FileSource *] * * Return [UNKN ] Undocumented return value [FileSource *] * */ FileSource * free_FileSource(FileSource * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a FileSource obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->filename != NULL) ckfree(obj->filename); /* obj->input is linked in */ ckfree(obj); return NULL; } /* Function: swap_SequenceDB(list,i,j) * * Descrip: swap function: an internal for qsort_SequenceDB * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [FileSource **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SequenceDB(FileSource ** list,int i,int j) { FileSource * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SequenceDB(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SequenceDB which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [FileSource **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SequenceDB(FileSource ** list,int left,int right,int (*comp)(FileSource * ,FileSource * )) { int i,last; if( left >= right ) return; swap_SequenceDB(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SequenceDB (list,++last,i); } swap_SequenceDB (list,left,last); qsort_SequenceDB(list,left,last-1,comp); qsort_SequenceDB(list,last+1,right,comp); } /* Function: sort_SequenceDB(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SequenceDB * * * Arg: obj [UNKN ] Object containing list [SequenceDB *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SequenceDB(SequenceDB * obj,int (*comp)(FileSource *, FileSource *)) { qsort_SequenceDB(obj->fs,0,obj->len-1,comp); return; } /* Function: expand_SequenceDB(obj,len) * * Descrip: Really an internal function for add_SequenceDB * * * Arg: obj [UNKN ] Object which contains the list [SequenceDB *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SequenceDB(SequenceDB * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SequenceDB called with no need"); return TRUE; } if( (obj->fs = (FileSource ** ) ckrealloc (obj->fs,sizeof(FileSource *)*len)) == NULL) { warn("ckrealloc failed for expand_SequenceDB, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SequenceDB(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SequenceDB *] * Arg: add [OWNER] Object to add to the list [FileSource *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SequenceDB(SequenceDB * obj,FileSource * add) { if( obj->len >= obj->maxlen) { if( expand_SequenceDB(obj,obj->len + SequenceDBLISTLENGTH) == FALSE) return FALSE; } obj->fs[obj->len++]=add; return TRUE; } /* Function: flush_SequenceDB(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SequenceDB *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SequenceDB(SequenceDB * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->fs[i] != NULL) { free_FileSource(obj->fs[i]); obj->fs[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SequenceDB_alloc_std(void) * * Descrip: Equivalent to SequenceDB_alloc_len(SequenceDBLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ SequenceDB * SequenceDB_alloc_std(void) { return SequenceDB_alloc_len(SequenceDBLISTLENGTH); } /* Function: SequenceDB_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ SequenceDB * SequenceDB_alloc_len(int len) { SequenceDB * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SequenceDB_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->fs = (FileSource ** ) ckcalloc (len,sizeof(FileSource *))) == NULL) { warn("Warning, ckcalloc failed in SequenceDB_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SequenceDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SequenceDB *] * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ SequenceDB * hard_link_SequenceDB(SequenceDB * obj) { if( obj == NULL ) { warn("Trying to hard link to a SequenceDB object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SequenceDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ SequenceDB * SequenceDB_alloc(void) { SequenceDB * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SequenceDB *) ckalloc (sizeof(SequenceDB))) == NULL) { warn("SequenceDB_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->fs = NULL; out->len = out->maxlen = 0; out->current_source = -1; out->sequence_no = 0; out->byte_position = 0; out->has_warned_single = 0; out->seq_start = -1; out->seq_end = -1; return out; } /* Function: free_SequenceDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SequenceDB *] * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ SequenceDB * free_SequenceDB(SequenceDB * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SequenceDB obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->fs != NULL) { for(i=0;ilen;i++) { if( obj->fs[i] != NULL) free_FileSource(obj->fs[i]); } ckfree(obj->fs); } /* obj->current_file is linked in */ ckfree(obj); return NULL; } /* Function: replace_name_SequenceDB(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SequenceDB *] * Arg: name [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable name [boolean] * */ boolean replace_name_SequenceDB(SequenceDB * obj,char * name) { if( obj == NULL) { warn("In replacement function name for object SequenceDB, got a NULL object"); return FALSE; } obj->name = name; return TRUE; } /* Function: access_name_SequenceDB(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SequenceDB *] * * Return [SOFT ] member variable name [char *] * */ char * access_name_SequenceDB(SequenceDB * obj) { if( obj == NULL) { warn("In accessor function name for object SequenceDB, got a NULL object"); return NULL; } return obj->name; } /* Function: access_fs_SequenceDB(obj,i) * * Descrip: Access members stored in the fs list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [SequenceDB *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [FileSource *] * */ FileSource * access_fs_SequenceDB(SequenceDB * obj,int i) { if( obj == NULL) { warn("In accessor function fs for object SequenceDB, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function fs for object SequenceDB, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->fs[i]; } /* Function: length_fs_SequenceDB(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [SequenceDB *] * * Return [UNKN ] length of the list [int] * */ int length_fs_SequenceDB(SequenceDB * obj) { if( obj == NULL) { warn("In length function fs for object SequenceDB, got a NULL object"); return -1; } return obj->len; } /* Function: replace_current_source_SequenceDB(obj,current_source) * * Descrip: Replace member variable current_source * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SequenceDB *] * Arg: current_source [OWNER] New value of the variable [int] * * Return [SOFT ] member variable current_source [boolean] * */ boolean replace_current_source_SequenceDB(SequenceDB * obj,int current_source) { if( obj == NULL) { warn("In replacement function current_source for object SequenceDB, got a NULL object"); return FALSE; } obj->current_source = current_source; return TRUE; } /* Function: access_current_source_SequenceDB(obj) * * Descrip: Access member variable current_source * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SequenceDB *] * * Return [SOFT ] member variable current_source [int] * */ int access_current_source_SequenceDB(SequenceDB * obj) { if( obj == NULL) { warn("In accessor function current_source for object SequenceDB, got a NULL object"); return 0; } return obj->current_source; } /* Function: replace_current_file_SequenceDB(obj,current_file) * * Descrip: Replace member variable current_file * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SequenceDB *] * Arg: current_file [OWNER] New value of the variable [FILE *] * * Return [SOFT ] member variable current_file [boolean] * */ boolean replace_current_file_SequenceDB(SequenceDB * obj,FILE * current_file) { if( obj == NULL) { warn("In replacement function current_file for object SequenceDB, got a NULL object"); return FALSE; } obj->current_file = current_file; return TRUE; } /* Function: access_current_file_SequenceDB(obj) * * Descrip: Access member variable current_file * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SequenceDB *] * * Return [SOFT ] member variable current_file [FILE *] * */ FILE * access_current_file_SequenceDB(SequenceDB * obj) { if( obj == NULL) { warn("In accessor function current_file for object SequenceDB, got a NULL object"); return NULL; } return obj->current_file; } /* Function: replace_sequence_no_SequenceDB(obj,sequence_no) * * Descrip: Replace member variable sequence_no * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SequenceDB *] * Arg: sequence_no [OWNER] New value of the variable [int] * * Return [SOFT ] member variable sequence_no [boolean] * */ boolean replace_sequence_no_SequenceDB(SequenceDB * obj,int sequence_no) { if( obj == NULL) { warn("In replacement function sequence_no for object SequenceDB, got a NULL object"); return FALSE; } obj->sequence_no = sequence_no; return TRUE; } /* Function: access_sequence_no_SequenceDB(obj) * * Descrip: Access member variable sequence_no * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SequenceDB *] * * Return [SOFT ] member variable sequence_no [int] * */ int access_sequence_no_SequenceDB(SequenceDB * obj) { if( obj == NULL) { warn("In accessor function sequence_no for object SequenceDB, got a NULL object"); return 0; } return obj->sequence_no; } /* Function: replace_byte_position_SequenceDB(obj,byte_position) * * Descrip: Replace member variable byte_position * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SequenceDB *] * Arg: byte_position [OWNER] New value of the variable [int] * * Return [SOFT ] member variable byte_position [boolean] * */ boolean replace_byte_position_SequenceDB(SequenceDB * obj,int byte_position) { if( obj == NULL) { warn("In replacement function byte_position for object SequenceDB, got a NULL object"); return FALSE; } obj->byte_position = byte_position; return TRUE; } /* Function: access_byte_position_SequenceDB(obj) * * Descrip: Access member variable byte_position * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [SequenceDB *] * * Return [SOFT ] member variable byte_position [int] * */ int access_byte_position_SequenceDB(SequenceDB * obj) { if( obj == NULL) { warn("In accessor function byte_position for object SequenceDB, got a NULL object"); return 0; } return obj->byte_position; } /* Function: replace_filename_FileSource(obj,filename) * * Descrip: Replace member variable filename * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [FileSource *] * Arg: filename [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable filename [boolean] * */ boolean replace_filename_FileSource(FileSource * obj,char * filename) { if( obj == NULL) { warn("In replacement function filename for object FileSource, got a NULL object"); return FALSE; } obj->filename = filename; return TRUE; } /* Function: access_filename_FileSource(obj) * * Descrip: Access member variable filename * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [FileSource *] * * Return [SOFT ] member variable filename [char *] * */ char * access_filename_FileSource(FileSource * obj) { if( obj == NULL) { warn("In accessor function filename for object FileSource, got a NULL object"); return NULL; } return obj->filename; } /* Function: replace_input_FileSource(obj,input) * * Descrip: Replace member variable input * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [FileSource *] * Arg: input [OWNER] New value of the variable [FILE *] * * Return [SOFT ] member variable input [boolean] * */ boolean replace_input_FileSource(FileSource * obj,FILE * input) { if( obj == NULL) { warn("In replacement function input for object FileSource, got a NULL object"); return FALSE; } obj->input = input; return TRUE; } /* Function: access_input_FileSource(obj) * * Descrip: Access member variable input * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [FileSource *] * * Return [SOFT ] member variable input [FILE *] * */ FILE * access_input_FileSource(FileSource * obj) { if( obj == NULL) { warn("In accessor function input for object FileSource, got a NULL object"); return NULL; } return obj->input; } /* Function: replace_format_FileSource(obj,format) * * Descrip: Replace member variable format * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [FileSource *] * Arg: format [OWNER] New value of the variable [int] * * Return [SOFT ] member variable format [boolean] * */ boolean replace_format_FileSource(FileSource * obj,int format) { if( obj == NULL) { warn("In replacement function format for object FileSource, got a NULL object"); return FALSE; } obj->format = format; return TRUE; } /* Function: access_format_FileSource(obj) * * Descrip: Access member variable format * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [FileSource *] * * Return [SOFT ] member variable format [int] * */ int access_format_FileSource(FileSource * obj) { if( obj == NULL) { warn("In accessor function format for object FileSource, got a NULL object"); return 0; } return obj->format; } /* Function: replace_type_FileSource(obj,type) * * Descrip: Replace member variable type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [FileSource *] * Arg: type [OWNER] New value of the variable [int] * * Return [SOFT ] member variable type [boolean] * */ boolean replace_type_FileSource(FileSource * obj,int type) { if( obj == NULL) { warn("In replacement function type for object FileSource, got a NULL object"); return FALSE; } obj->type = type; return TRUE; } /* Function: access_type_FileSource(obj) * * Descrip: Access member variable type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [FileSource *] * * Return [SOFT ] member variable type [int] * */ int access_type_FileSource(FileSource * obj) { if( obj == NULL) { warn("In accessor function type for object FileSource, got a NULL object"); return 0; } return obj->type; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/sequencedb.h0000644000175000001440000003502710670453713017135 0ustar philippusers#ifndef DYNAMITEsequencedbHEADERFILE #define DYNAMITEsequencedbHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #include "database.h" #include "hscore.h" #define SequenceDBLISTLENGTH 128 enum SequenceDBFormat { SEQ_DB_UNKNOWN = 32, SEQ_DB_FASTA }; /* Object FileSource * * Descrip: This object represents a single * file source for a database. At * the moment only multiple fasta * files are catered for * * */ struct Wise2_FileSource { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * filename; FILE * input; /* could be stdin! */ int format; int type; } ; /* FileSource defined */ #ifndef DYNAMITE_DEFINED_FileSource typedef struct Wise2_FileSource Wise2_FileSource; #define FileSource Wise2_FileSource #define DYNAMITE_DEFINED_FileSource #endif /* Object SequenceDB * * Descrip: This is the basic Sequence database * wrapper - it handles all the formats * and the on-the-fly indexing. * * Generally it wont be directly used by * an algorithm, which will be using something * specific to the sequence type produce complex * sequence type objects: ie you will be using * proteindb or cdnadb which internally * will be using this object * * */ struct Wise2_SequenceDB { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; FileSource ** fs; int len;/* len for above fs */ int maxlen; /* maxlen for above fs */ int current_source; FILE * current_file; int sequence_no; int byte_position; int has_warned_single; int seq_start; int seq_end; } ; /* SequenceDB defined */ #ifndef DYNAMITE_DEFINED_SequenceDB typedef struct Wise2_SequenceDB Wise2_SequenceDB; #define SequenceDB Wise2_SequenceDB #define DYNAMITE_DEFINED_SequenceDB #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: get_Sequence_from_SequenceDB(sdb,de) * * Descrip: Quite a mindless function which retrieves sequences * via indexes * * Going to spend too much time in fopen if this is used * too much * * * Arg: sdb [UNKN ] Undocumented argument [SequenceDB *] * Arg: de [UNKN ] Undocumented argument [DataEntry *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_get_Sequence_from_SequenceDB(SequenceDB * sdb,DataEntry * de); #define get_Sequence_from_SequenceDB Wise2_get_Sequence_from_SequenceDB /* Function: add_SequenceDB_info_DataEntry(sdb,de) * * Descrip: A function which places data into dataentry so we can * be guarenteed to retrieve it sometime. * * It uses 0 and 1 points in the Data array. * * * Arg: sdb [UNKN ] Undocumented argument [SequenceDB *] * Arg: de [UNKN ] Undocumented argument [DataEntry *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SequenceDB_info_DataEntry(SequenceDB * sdb,DataEntry * de); #define add_SequenceDB_info_DataEntry Wise2_add_SequenceDB_info_DataEntry /* Function: close_SequenceDB(last,sdb) * * Descrip: top level function that closes the SequenceDB * after the last sequence is read. * * * Arg: last [WRITE] Sequence object to be freed [Sequence *] * Arg: sdb [READ ] database to be closed [SequenceDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_close_SequenceDB(Sequence * last,SequenceDB * sdb); #define close_SequenceDB Wise2_close_SequenceDB /* Function: init_SequenceDB(sdb,return_status) * * Descrip: top level function that starts a database read on * SequenceDB * * * * Arg: sdb [READ ] sequence database [SequenceDB *] * Arg: return_status [WRITE] returns the database status as found in database.h [int *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_init_SequenceDB(SequenceDB * sdb,int * return_status); #define init_SequenceDB Wise2_init_SequenceDB /* Function: reload_SequenceDB(last,sdb,return_status) * * Descrip: top level function that reloads a sequence database * * * * Arg: last [WRITE] previous sequence to be used: will simply be freed at the moment [Sequence *] * Arg: sdb [UNKN ] sequence database [SequenceDB *] * Arg: return_status [WRITE] returns the database status as found in database.h [int *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_reload_SequenceDB(Sequence * last,SequenceDB * sdb,int * return_status); #define reload_SequenceDB Wise2_reload_SequenceDB /* Function: SequenceDB_from_FILE_and_format(input,format) * * Descrip: makes a SequencDB from a straight file stream. * * This means SequenceDB will *not* close it when * the SequenceDB is closed. * * * Arg: input [READ ] filestream [FILE *] * Arg: format [UNKN ] format as defined by /word_to_format [int] * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ SequenceDB * Wise2_SequenceDB_from_FILE_and_format(FILE * input,int format); #define SequenceDB_from_FILE_and_format Wise2_SequenceDB_from_FILE_and_format /* Function: single_fasta_SequenceDB(filename) * * Descrip: pre-packed single fasta file db * * * * Arg: filename [UNKN ] name of fastadb [char *] * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ SequenceDB * Wise2_single_fasta_SequenceDB(char * filename); #define single_fasta_SequenceDB Wise2_single_fasta_SequenceDB /* Function: read_SequenceDB_line(line,ifp) * * Descrip: Reads a SequenceDB definition from * * seqdb * * ... * endseqdb * * * * Arg: line [UNKN ] starting line (seqdb line) [char *] * Arg: ifp [UNKN ] file input [FILE *] * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ SequenceDB * Wise2_read_SequenceDB_line(char * line,FILE * ifp); #define read_SequenceDB_line Wise2_read_SequenceDB_line /* Function: word_to_format(word) * * Descrip: converts char * to format for SequenceDB FileSources * * * Arg: word [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_word_to_format(char * word); #define word_to_format Wise2_word_to_format /* Function: hard_link_FileSource(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [FileSource *] * * Return [UNKN ] Undocumented return value [FileSource *] * */ FileSource * Wise2_hard_link_FileSource(FileSource * obj); #define hard_link_FileSource Wise2_hard_link_FileSource /* Function: FileSource_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [FileSource *] * */ FileSource * Wise2_FileSource_alloc(void); #define FileSource_alloc Wise2_FileSource_alloc /* Function: free_FileSource(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [FileSource *] * * Return [UNKN ] Undocumented return value [FileSource *] * */ FileSource * Wise2_free_FileSource(FileSource * obj); #define free_FileSource Wise2_free_FileSource /* Function: add_SequenceDB(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SequenceDB *] * Arg: add [OWNER] Object to add to the list [FileSource *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SequenceDB(SequenceDB * obj,FileSource * add); #define add_SequenceDB Wise2_add_SequenceDB /* Function: flush_SequenceDB(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SequenceDB *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SequenceDB(SequenceDB * obj); #define flush_SequenceDB Wise2_flush_SequenceDB /* Function: SequenceDB_alloc_std(void) * * Descrip: Equivalent to SequenceDB_alloc_len(SequenceDBLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ SequenceDB * Wise2_SequenceDB_alloc_std(void); #define SequenceDB_alloc_std Wise2_SequenceDB_alloc_std /* Function: SequenceDB_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ SequenceDB * Wise2_SequenceDB_alloc_len(int len); #define SequenceDB_alloc_len Wise2_SequenceDB_alloc_len /* Function: hard_link_SequenceDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SequenceDB *] * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ SequenceDB * Wise2_hard_link_SequenceDB(SequenceDB * obj); #define hard_link_SequenceDB Wise2_hard_link_SequenceDB /* Function: SequenceDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ SequenceDB * Wise2_SequenceDB_alloc(void); #define SequenceDB_alloc Wise2_SequenceDB_alloc /* Function: free_SequenceDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SequenceDB *] * * Return [UNKN ] Undocumented return value [SequenceDB *] * */ SequenceDB * Wise2_free_SequenceDB(SequenceDB * obj); #define free_SequenceDB Wise2_free_SequenceDB /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ FileSource * Wise2_access_fs_SequenceDB(SequenceDB * obj,int i); #define access_fs_SequenceDB Wise2_access_fs_SequenceDB int Wise2_access_current_source_SequenceDB(SequenceDB * obj); #define access_current_source_SequenceDB Wise2_access_current_source_SequenceDB boolean Wise2_replace_current_source_SequenceDB(SequenceDB * obj,int current_source); #define replace_current_source_SequenceDB Wise2_replace_current_source_SequenceDB boolean Wise2_replace_current_file_SequenceDB(SequenceDB * obj,FILE * current_file); #define replace_current_file_SequenceDB Wise2_replace_current_file_SequenceDB boolean Wise2_replace_sequence_no_SequenceDB(SequenceDB * obj,int sequence_no); #define replace_sequence_no_SequenceDB Wise2_replace_sequence_no_SequenceDB int Wise2_access_sequence_no_SequenceDB(SequenceDB * obj); #define access_sequence_no_SequenceDB Wise2_access_sequence_no_SequenceDB boolean Wise2_replace_name_SequenceDB(SequenceDB * obj,char * name); #define replace_name_SequenceDB Wise2_replace_name_SequenceDB int Wise2_access_format_FileSource(FileSource * obj); #define access_format_FileSource Wise2_access_format_FileSource boolean Wise2_replace_byte_position_SequenceDB(SequenceDB * obj,int byte_position); #define replace_byte_position_SequenceDB Wise2_replace_byte_position_SequenceDB int Wise2_length_fs_SequenceDB(SequenceDB * obj); #define length_fs_SequenceDB Wise2_length_fs_SequenceDB boolean Wise2_replace_format_FileSource(FileSource * obj,int format); #define replace_format_FileSource Wise2_replace_format_FileSource int Wise2_access_byte_position_SequenceDB(SequenceDB * obj); #define access_byte_position_SequenceDB Wise2_access_byte_position_SequenceDB FILE * Wise2_access_current_file_SequenceDB(SequenceDB * obj); #define access_current_file_SequenceDB Wise2_access_current_file_SequenceDB boolean Wise2_replace_filename_FileSource(FileSource * obj,char * filename); #define replace_filename_FileSource Wise2_replace_filename_FileSource char * Wise2_access_name_SequenceDB(SequenceDB * obj); #define access_name_SequenceDB Wise2_access_name_SequenceDB char * Wise2_access_filename_FileSource(FileSource * obj); #define access_filename_FileSource Wise2_access_filename_FileSource boolean Wise2_replace_type_FileSource(FileSource * obj,int type); #define replace_type_FileSource Wise2_replace_type_FileSource boolean Wise2_replace_input_FileSource(FileSource * obj,FILE * input); #define replace_input_FileSource Wise2_replace_input_FileSource int Wise2_access_type_FileSource(FileSource * obj); #define access_type_FileSource Wise2_access_type_FileSource FILE * Wise2_access_input_FileSource(FileSource * obj); #define access_input_FileSource Wise2_access_input_FileSource Sequence * Wise2_get_next_SequenceDB(SequenceDB * sdb); #define get_next_SequenceDB Wise2_get_next_SequenceDB boolean Wise2_SequenceDB_at_end(SequenceDB * sdb); #define SequenceDB_at_end Wise2_SequenceDB_at_end boolean Wise2_load_next_fs_SequenceDB(SequenceDB * sdb); #define load_next_fs_SequenceDB Wise2_load_next_fs_SequenceDB boolean Wise2_close_last_fs_SequenceDB(SequenceDB * sdb); #define close_last_fs_SequenceDB Wise2_close_last_fs_SequenceDB FileSource * Wise2_FileSource_from_FILE_and_format(FILE * input,int format); #define FileSource_from_FILE_and_format Wise2_FileSource_from_FILE_and_format FileSource * Wise2_FileSource_from_line(char * line); #define FileSource_from_line Wise2_FileSource_from_line void Wise2_swap_SequenceDB(FileSource ** list,int i,int j) ; #define swap_SequenceDB Wise2_swap_SequenceDB void Wise2_qsort_SequenceDB(FileSource ** list,int left,int right,int (*comp)(FileSource * ,FileSource * )); #define qsort_SequenceDB Wise2_qsort_SequenceDB void Wise2_sort_SequenceDB(SequenceDB * obj,int (*comp)(FileSource *, FileSource *)); #define sort_SequenceDB Wise2_sort_SequenceDB boolean Wise2_expand_SequenceDB(SequenceDB * obj,int len); #define expand_SequenceDB Wise2_expand_SequenceDB #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/dbsearchimpl.typemap0000644000175000001440000000040210670453712020670 0ustar philippusers TYPEMAP Wise2_DBSearchImpl * T_Wise2_DBSearchImpl INPUT T_Wise2_DBSearchImpl $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_DBSearchImpl *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_DBSearchImpl sv_setref_pv($arg, "Wise2::DBSearchImpl", (void*) $var); wise-2.4.1/src/dynlibsrc/genomic.typemap0000644000175000001440000000075410670453712017666 0ustar philippusers TYPEMAP Wise2_Genomic * T_Wise2_Genomic INPUT T_Wise2_Genomic $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_Genomic *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_Genomic sv_setref_pv($arg, "Wise2::Genomic", (void*) $var); TYPEMAP Wise2_GenomicRepeat * T_Wise2_GenomicRepeat INPUT T_Wise2_GenomicRepeat $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_GenomicRepeat *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_GenomicRepeat sv_setref_pv($arg, "Wise2::GenomicRepeat", (void*) $var); wise-2.4.1/src/dynlibsrc/asciibtcanvas.c0000644000175000001440000003260510670453712017622 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "asciibtcanvas.h" /* Function: ascii_btCanvas_usage(ofp) * * Descrip: prints out usage for * * ascii_btCanvas_from_commandline * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 34 "asciibtcanvas.dy" void ascii_btCanvas_usage(FILE * ofp) { fprintf(ofp,"Options for ascii canvas\n"); fprintf(ofp," -acleft [integer] size of left hand panel\n"); fprintf(ofp," -acmain [integer] size of main panel\n"); fprintf(ofp," -acright [integer] size of right hand panel\n"); } /* Function: ascii_btCanvas_from_commandline(argc,argv,default_left,default_main,default_right,ofp,height) * * Descrip: Makes a ascii btCanvas from the command line, * swallowing up options for * -acleft * -acright * -acmain * * If there are no options, builds with 15,50,5 * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * Arg: default_left [UNKN ] Undocumented argument [int] * Arg: default_main [UNKN ] Undocumented argument [int] * Arg: default_right [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * Arg: height [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [btCanvas *] * */ # line 51 "asciibtcanvas.dy" btCanvas * ascii_btCanvas_from_commandline(int * argc,char ** argv,int default_left,int default_main,int default_right,FILE * ofp,int height) { int left = default_left; int main_length = default_main; int right = default_right; strip_out_integer_argument(argc,argv,"acleft",&left); strip_out_integer_argument(argc,argv,"acright",&right); strip_out_integer_argument(argc,argv,"acmain",&main_length); return new_Ascii_btCanvas(ofp,left,main_length,right,height); } /* Function: new_Ascii_btCanvas(ofp,left,main,right,height) * * Descrip: The only function specifically for Ascii bt Canvases. * * Use this to make a new btCanvas. Then use functions like * /get_paste_area_btCanvas to actually use it. Everything * else is handled by data structures and pointer-to-functions * which are hidden to you (and be thankful for that!) * * The standard /free_btCanvas will free the hidden data structures * as well * * * Arg: ofp [UNKN ] FILE stream to write the ascii to [FILE *] * Arg: left [UNKN ] amount of text to reserve on the left [int] * Arg: main [UNKN ] Undocumented argument [int] * Arg: right [UNKN ] amount of text to reserve on the right [int] * Arg: height [UNKN ] height of block [int] * * Return [UNKN ] Undocumented return value [btCanvas *] * */ # line 81 "asciibtcanvas.dy" btCanvas * new_Ascii_btCanvas(FILE * ofp,int left,int main,int right,int height) { btCanvas * out; Ascii_btc_Data * d; out = btCanvas_alloc(); d = new_Ascii_btc_Data(ofp,left,main,right,height); out->canvas_data = (void *) d; out->decons = free_Ascii_btc; /* now need to put in correct pointers to functions for * canvas implementation */ out->can_get_paste_area = can_get_bt_Ascii; out->advance_line = ascii_next_line_btPasteArea; out->get_paste_area = next_Ascii_btpa; out->get_reserved_right = get_ascii_right_btPasteArea; out->get_reserved_left = get_ascii_left_btPasteArea; return out; } /* Function: next_Ascii_btpa(btc,length) * * Descrip: gets the next btPasteArea. Here we con * people by simply passing out the 'bpa' * held in canvas and never reallocating it * (see /free_Ascii_btpa which is already attached to * the bpa). * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * Arg: length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ # line 119 "asciibtcanvas.dy" btPasteArea * next_Ascii_btpa(btCanvas * btc,int length) { Ascii_btc_Data * abd = NULL; abd = (Ascii_btc_Data*) btc->canvas_data; if( abd->in_use == TRUE ) { warn("You are already using a btPasteArea on this canvas. Only one at a time! Probably you have not freed the btPasteArea before hand"); return NULL; } if( abd->current_x + length > abd->main + abd->res_left ) { warn("Asking for more block than I can give you. You have not tested with can_get_paste_area. Bad boy!"); return NULL; } abd->in_use = TRUE; abd->paint_x = abd->current_x; abd->current_x += length; abd->bpa->length = length; return abd->bpa; } /* Function: paste_char_bt_Ascii(bpa,x,y,c,format) * * Descrip: The paste function. Going to get at all the info * (obviously) through data * * * Arg: bpa [UNKN ] Undocumented argument [btPasteArea *] * Arg: x [UNKN ] Undocumented argument [int] * Arg: y [UNKN ] Undocumented argument [int] * Arg: c [UNKN ] Undocumented argument [char] * Arg: format [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 148 "asciibtcanvas.dy" boolean paste_char_bt_Ascii(btPasteArea * bpa,int x,int y,char c,int format) { Ascii_btc_Data * abd = NULL; abd = (Ascii_btc_Data*) bpa->canvas_data; /* fprintf(stderr,"Printing at %d %d %c\n",x,y,c); */ abd->scratch[y][abd->paint_x + x] = c; return TRUE; } /* Function: can_get_bt_Ascii(btc,length) * * Descrip: Can get function * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * Arg: length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 163 "asciibtcanvas.dy" boolean can_get_bt_Ascii(btCanvas * btc,int length) { Ascii_btc_Data * abd = NULL; abd = (Ascii_btc_Data*) btc->canvas_data; /* fprintf(stderr,"Current is %d to %d\n",abd->current_x,length); */ if( abd->current_x + length >= abd->main + abd->res_left ) return FALSE; /* fprintf(stderr,"Returning TRUE\n"); */ return TRUE; } /* Function: get_ascii_left_btPasteArea(btc) * * Descrip: The get left area function. * Again, con people into thinking that we are * passing a 'live' bpa * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ # line 186 "asciibtcanvas.dy" btPasteArea * get_ascii_left_btPasteArea(btCanvas * btc) { Ascii_btc_Data * abd = NULL; int length; abd = (Ascii_btc_Data*) btc->canvas_data; length = abd->res_left; if( abd->in_use == TRUE ) { warn("You are already using a btPasteArea on this canvas. Only one at a time! Probably you have not freed the btPasteArea before hand"); return NULL; } abd->in_use = TRUE; abd->paint_x = 0; abd->bpa->length = length; return abd->bpa; } /* Function: get_ascii_right_btPasteArea(btc) * * Descrip: The get right area function. * Again, con people into thinking that we are * passing a 'live' bpa * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ # line 212 "asciibtcanvas.dy" btPasteArea * get_ascii_right_btPasteArea(btCanvas * btc) { Ascii_btc_Data * abd = NULL; int length; abd = (Ascii_btc_Data*) btc->canvas_data; length = abd->res_left + abd->main; if( abd->in_use == TRUE ) { warn("You are already using a btPasteArea on this canvas. Only one at a time! Probably you have not freed the btPasteArea before hand"); return NULL; } abd->in_use = TRUE; abd->paint_x = length; abd->bpa->length = length; return abd->bpa; } /* Function: ascii_next_line_btPasteArea(btc) * * Descrip: Advancement function. * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 236 "asciibtcanvas.dy" boolean ascii_next_line_btPasteArea(btCanvas * btc) { Ascii_btc_Data * abd = NULL; int i,len; /* fprintf(stderr,"Going to advance\n"); */ abd = (Ascii_btc_Data*) btc->canvas_data; if( abd->in_use == TRUE ) { warn("You are already using a btPasteArea on this canvas, and now you are asking to advance a line. Ouch"); return FALSE; } len = abd->res_left + abd->main + abd->res_right; for(i=0;idepth_scratch;i++) { /* fprintf(stderr,"About to print %s\n",abd->scratch[i]);*/ fputs(abd->scratch[i],abd->ofp); } fputs("\n\n",abd->ofp); for(i=0;idepth_scratch;i++) { memset(abd->scratch[i],' ',len); } abd->current_x = abd->res_left; return TRUE; } /* Function: free_Ascii_btpa(obj) * * Descrip: Deconstructor for a btPasteArea we are * going to make. Will be attached on construction * * * Arg: obj [UNKN ] Undocumented argument [btPasteArea *] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ # line 272 "asciibtcanvas.dy" btPasteArea * free_Ascii_btpa(btPasteArea * obj) { Ascii_btc_Data * abd; /* all we have to do is set to FALSE the Ascii_btc_Data pointed to by canvas_data */ abd = (Ascii_btc_Data*) obj->canvas_data; abd->in_use = FALSE; return NULL; } /* Function: new_Ascii_btc_Data(ofp,left,main,right,height) * * Descrip: makes new ascii data. NB. Notice allocation of * 'dummy' btPasteArea and of the scratch pad. * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * Arg: left [UNKN ] Undocumented argument [int] * Arg: main [UNKN ] Undocumented argument [int] * Arg: right [UNKN ] Undocumented argument [int] * Arg: height [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Ascii_btc_Data *] * */ # line 294 "asciibtcanvas.dy" Ascii_btc_Data * new_Ascii_btc_Data(FILE * ofp,int left,int main,int right,int height) { Ascii_btc_Data * out; int tot; int i; tot = left + main + right +2; out = Ascii_btc_Data_alloc(); out->ofp = ofp; out->res_left = left; out->main = main; out->res_right = right; out->current_x= left; out->paint_x = left; out->scratch = (char **) ckcalloc(height,sizeof(char *)); for(i=0;iscratch[i] = (char *) ckcalloc(tot,sizeof(char)); memset(out->scratch[i],' ',tot-2); out->scratch[i][tot-1] = '\0'; out->scratch[i][tot-2] = '\n'; } out->depth_scratch = height; out->in_use = FALSE; out->bpa = btPasteArea_alloc(); out->bpa->height = height; out->bpa->canvas_data = (void *) out; out->bpa->decons = free_Ascii_btpa; out->bpa->paste_char = paste_char_bt_Ascii; return out; } /* Function: free_Ascii_btc(btc) * * Descrip: Deconstructor for the btcanvas we are going * to make. This function will be attached to * the btcanvas on construction * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [btCanvas *] * */ # line 340 "asciibtcanvas.dy" btCanvas * free_Ascii_btc(btCanvas * btc) { btc->canvas_data = (void *) free_Ascii_btc_Data((Ascii_btc_Data *)(btc->canvas_data)); ckfree(btc); return NULL; } /* Function: free_Ascii_btc_Data(obj) * * Descrip: Specialist deconstructor really for scratch pad * * * Arg: obj [WRITE] Ascii_btc_Data to be zapped [Ascii_btc_Data *] * * Return [UNKN ] Undocumented return value [Ascii_btc_Data *] * */ # line 355 "asciibtcanvas.dy" Ascii_btc_Data * free_Ascii_btc_Data(Ascii_btc_Data * obj) { int i; for(i=0;idepth_scratch;i++) { ckfree(obj->scratch[i]); } ckfree(obj->scratch); ckfree(obj->bpa); /* very subtle. bpa actually is a complete dummy obj * calling free_btPasteArea would be **really** bad */ ckfree(obj); return NULL; } # line 429 "asciibtcanvas.c" /* Function: hard_link_Ascii_btc_Data(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Ascii_btc_Data *] * * Return [UNKN ] Undocumented return value [Ascii_btc_Data *] * */ Ascii_btc_Data * hard_link_Ascii_btc_Data(Ascii_btc_Data * obj) { if( obj == NULL ) { warn("Trying to hard link to a Ascii_btc_Data object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Ascii_btc_Data_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Ascii_btc_Data *] * */ Ascii_btc_Data * Ascii_btc_Data_alloc(void) { Ascii_btc_Data * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Ascii_btc_Data *) ckalloc (sizeof(Ascii_btc_Data))) == NULL) { warn("Ascii_btc_Data_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->ofp = NULL; out->current_x = 0; out->paint_x = 0; out->res_left = 0; out->main = 0; out->res_right = 0; out->scratch = NULL; out->depth_scratch = 0; out->in_use = FALSE; out->bpa = NULL; return out; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/asciibtcanvas.h0000644000175000001440000001365010670453712017626 0ustar philippusers#ifndef DYNAMITEasciibtcanvasHEADERFILE #define DYNAMITEasciibtcanvasHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "btcanvas.h" struct Wise2_Ascii_btc_Data { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif FILE * ofp; /* file to write to */ int current_x; /* position in main line */ int paint_x; /* painting cursor on the line */ int res_left; /* amount reserved on left */ int main; /* main block amount */ int res_right; /* amount reserved on right */ char ** scratch; /* scratch pad lines */ int depth_scratch; /* depth of scratch pad for memory */ boolean in_use; btPasteArea * bpa; /* this is what we recycle.. */ } ; /* Ascii_btc_Data defined */ #ifndef DYNAMITE_DEFINED_Ascii_btc_Data typedef struct Wise2_Ascii_btc_Data Wise2_Ascii_btc_Data; #define Ascii_btc_Data Wise2_Ascii_btc_Data #define DYNAMITE_DEFINED_Ascii_btc_Data #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: ascii_btCanvas_usage(ofp) * * Descrip: prints out usage for * * ascii_btCanvas_from_commandline * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_ascii_btCanvas_usage(FILE * ofp); #define ascii_btCanvas_usage Wise2_ascii_btCanvas_usage /* Function: ascii_btCanvas_from_commandline(argc,argv,default_left,default_main,default_right,ofp,height) * * Descrip: Makes a ascii btCanvas from the command line, * swallowing up options for * -acleft * -acright * -acmain * * If there are no options, builds with 15,50,5 * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * Arg: default_left [UNKN ] Undocumented argument [int] * Arg: default_main [UNKN ] Undocumented argument [int] * Arg: default_right [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * Arg: height [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [btCanvas *] * */ btCanvas * Wise2_ascii_btCanvas_from_commandline(int * argc,char ** argv,int default_left,int default_main,int default_right,FILE * ofp,int height); #define ascii_btCanvas_from_commandline Wise2_ascii_btCanvas_from_commandline /* Function: new_Ascii_btCanvas(ofp,left,main,right,height) * * Descrip: The only function specifically for Ascii bt Canvases. * * Use this to make a new btCanvas. Then use functions like * /get_paste_area_btCanvas to actually use it. Everything * else is handled by data structures and pointer-to-functions * which are hidden to you (and be thankful for that!) * * The standard /free_btCanvas will free the hidden data structures * as well * * * Arg: ofp [UNKN ] FILE stream to write the ascii to [FILE *] * Arg: left [UNKN ] amount of text to reserve on the left [int] * Arg: main [UNKN ] Undocumented argument [int] * Arg: right [UNKN ] amount of text to reserve on the right [int] * Arg: height [UNKN ] height of block [int] * * Return [UNKN ] Undocumented return value [btCanvas *] * */ btCanvas * Wise2_new_Ascii_btCanvas(FILE * ofp,int left,int main,int right,int height); #define new_Ascii_btCanvas Wise2_new_Ascii_btCanvas /* Function: hard_link_Ascii_btc_Data(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Ascii_btc_Data *] * * Return [UNKN ] Undocumented return value [Ascii_btc_Data *] * */ Ascii_btc_Data * Wise2_hard_link_Ascii_btc_Data(Ascii_btc_Data * obj); #define hard_link_Ascii_btc_Data Wise2_hard_link_Ascii_btc_Data /* Function: Ascii_btc_Data_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Ascii_btc_Data *] * */ Ascii_btc_Data * Wise2_Ascii_btc_Data_alloc(void); #define Ascii_btc_Data_alloc Wise2_Ascii_btc_Data_alloc /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ btPasteArea * Wise2_next_Ascii_btpa(btCanvas * btc,int length); #define next_Ascii_btpa Wise2_next_Ascii_btpa boolean Wise2_paste_char_bt_Ascii(btPasteArea * bpa,int x,int y,char c,int format); #define paste_char_bt_Ascii Wise2_paste_char_bt_Ascii boolean Wise2_can_get_bt_Ascii(btCanvas * btc,int length); #define can_get_bt_Ascii Wise2_can_get_bt_Ascii btPasteArea * Wise2_get_ascii_left_btPasteArea(btCanvas * btc); #define get_ascii_left_btPasteArea Wise2_get_ascii_left_btPasteArea btPasteArea * Wise2_get_ascii_right_btPasteArea(btCanvas * btc); #define get_ascii_right_btPasteArea Wise2_get_ascii_right_btPasteArea boolean Wise2_ascii_next_line_btPasteArea(btCanvas * btc); #define ascii_next_line_btPasteArea Wise2_ascii_next_line_btPasteArea btPasteArea * Wise2_free_Ascii_btpa(btPasteArea * obj); #define free_Ascii_btpa Wise2_free_Ascii_btpa Ascii_btc_Data * Wise2_new_Ascii_btc_Data(FILE * ofp,int left,int main,int right,int height); #define new_Ascii_btc_Data Wise2_new_Ascii_btc_Data btCanvas * Wise2_free_Ascii_btc(btCanvas * btc); #define free_Ascii_btc Wise2_free_Ascii_btc Ascii_btc_Data * Wise2_free_Ascii_btc_Data(Ascii_btc_Data * obj); #define free_Ascii_btc_Data Wise2_free_Ascii_btc_Data #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/codon.c0000644000175000001440000004426110670453712016113 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "codon.h" /* Function: read_CodonTable_file(file) * * Descrip: Opens filename, reads it as if a Ewan style * codon table and closes. * * * Arg: file [READ ] filename to open [char *] * * Return [OWNER] A codon-table, NULL if error [CodonTable *] * */ # line 80 "codon.dy" CodonTable * read_CodonTable_file(char * file) { FILE * ifp; CodonTable * out; ifp = openfile(file,"r"); if( ifp == NULL) { warn("Could not open file %s as codon table file",file); return NULL; } out = read_CodonTable(ifp); fclose(ifp); return out; } /* Function: read_CodonTable(ifp) * * Descrip: reads a codon table from a filestream in Ewan * format. * * As Ewan format is really bad and has no start/stop * this will effectively read to the end of the file. * Ooops. * * * Arg: ifp [READ ] file input [FILE *] * * Return [UNKN ] Undocumented return value [CodonTable *] * */ # line 109 "codon.dy" CodonTable * read_CodonTable(FILE * ifp) { char buffer[MAXLINE]; CodonTable * out; codon c; char * runner; char * run2; out = CodonTable_alloc(); memset(out->codon_str,'x',125); while( fgets(buffer,MAXLINE,ifp) != NULL) { if( buffer[0] == '#' || buffer[0] == '!') continue; runner = strtok(buffer,spacestr); run2 = strtok(NULL,spacestr); if( runner == NULL || run2 == NULL ){ warn("Unable to read a line in codon table"); } c = codon_from_seq(runner); out->codon_str[c] = *run2; } return out; } /* Function: alloc_aminoacid_from_seq(ct,seq) * * Descrip: Not very useful function: allocates a single amino * acid (ie, buffer length one) so it can be freed later. * * * Arg: ct [READ ] codon table [CodonTable *] * Arg: seq [READ ] pointer to DNA Sequence chars [char *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 147 "codon.dy" char * alloc_aminoacid_from_seq(CodonTable * ct,char * seq) { char buf[2]; buf[1] = '\0'; buf[0] = aminoacid_from_codon(ct,codon_from_seq(seq)); return stringalloc(buf); } /* Function: aminoacid_from_seq(ct,seq) * * Descrip: Returns the amino acid for this position in the DNA sequence * Takes the pointer +1 and +2 points. * * No error checks implemented. Probably a mistake ;) * * * Arg: ct [READ ] codon table [CodonTable *] * Arg: seq [READ ] pointer to DNA chars [char *] * * Return [UNKN ] an amino acid char (A-Z) [aa] * */ # line 168 "codon.dy" aa aminoacid_from_seq(CodonTable * ct,char * seq) { return aminoacid_from_codon(ct,codon_from_seq(seq)); } /* Function: aminoacid_from_codon(ct,c) * * Descrip: returns amino acid for this codon number (NB codon numbers 0-125) * * * Arg: ct [READ ] codon table [CodonTable *] * Arg: c [READ ] codon number [codon] * * Return [READ ] aminoacid that is this codon (X for ambiguous, * for stop) [aa] * */ # line 180 "codon.dy" aa aminoacid_from_codon(CodonTable * ct,codon c) { return ct->codon_str[c]; } /* Function: aminoacid_no_from_codon(ct,c) * * Descrip: a sister function to aminoacid_from_codon: * returns amino acid number (0-26) for this codon number (0-125) * * * Arg: ct [READ ] codon table [CodonTable *] * Arg: c [READ ] codon number [codon] * * Return [READ ] aminoacid number [0-26] for this codon [int] * */ # line 193 "codon.dy" int aminoacid_no_from_codon(CodonTable * ct,codon c) { return (ct->codon_str[c] - 'A'); } /* Function: is_stop_codon(c,ct) * * Descrip: tells you whether this codon number is really a stop * in this translation table * * * Arg: c [READ ] codon number [codon] * Arg: ct [READ ] codon table [CodonTable *] * * Return [UNKN ] TRUE if is stop, FALSE otherwise [boolean] * */ # line 206 "codon.dy" boolean is_stop_codon(codon c,CodonTable * ct) { aa a; a = aminoacid_from_codon(ct,c); if( a == 'X' || a == '*') { return TRUE; } return FALSE; } /* Function: is_non_ambiguous_codon_seq(seq) * * Descrip: Tells you if this codon is a real codon * * * Arg: seq [READ ] pointer to DNA sequence [char *] * * Return [UNKN ] TRUE if real codon, FALSE if contains N's [boolean] * */ # line 225 "codon.dy" boolean is_non_ambiguous_codon_seq(char * seq) { if( *seq == '\0' || *(seq+1) == '\0' || *(seq+2) == '\0') { warn("Attempting to find a codon number is something less than 3 bases long!"); return FALSE; } if( base_from_char(*(seq++)) == BASE_N) return FALSE; if( base_from_char(*(seq++)) == BASE_N) return FALSE; if( base_from_char(*(seq)) == BASE_N) return FALSE; return TRUE; } /* Function: is_valid_aminoacid(ct,c) * * Descrip: Tells you if this letter (c) is recognised as a valid amino acid * in this codon table * * * Arg: ct [READ ] Codon Table [CodonTable *] * Arg: c [UNKN ] aminoacid [char] * * Return [UNKN ] TRUE if valid, FALSE if not. [boolean] * */ # line 250 "codon.dy" boolean is_valid_aminoacid(CodonTable * ct,char c) { if( strchr(ct->codon_str,c) != NULL ) return TRUE; else return FALSE; } /* Function: is_valid_base_char(c) * * Descrip: Tells you if the letter is A,T,C,G,N (NB, N is ok). * * * Arg: c [READ ] base [char] * * Return [UNKN ] TRUE if (ATGCN) FALSE otherwise [boolean] * */ # line 263 "codon.dy" boolean is_valid_base_char(char c) { if( c == 'A' || c == 'T' || c == 'G' || c == 'C' || c == 'N') return TRUE; return FALSE; } /* Function: codon_from_base4_codon(c) * * Descrip: maps a 0-63 codon to a 0-123 codon. Suprisingly useful. * * * Arg: c [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [codon] * */ # line 273 "codon.dy" codon codon_from_base4_codon(int c) { base one; base two; base three; one = c / 16; c -= one*16; two = c/4; c -= 4*two; three = c; return 25*one+5*two+three; } /* Function: base4_codon_from_codon(c) * * Descrip: maps a 0-125 codon to a 0-63 codon. * * If ambiguous then returns 64 having issued a warning. * * * Arg: c [READ ] codon 0-125 [codon] * * Return [UNKN ] base 4 codon (0-63) [int] * */ # line 297 "codon.dy" int base4_codon_from_codon(codon c) { base one; base two; base three; all_bases_from_codon(c,&one,&two,&three); if( one == BASE_N || two == BASE_N || three == BASE_N) { /* GSS 07:07:2000 DISABLED WARNING */ warn("Attempting to convert an ambiguous codon to base 64" " returning 64"); return 64; } return one*16 + two*4 + three; } /* Function: has_random_bases(c) * * Descrip: Tests to see if this codon number has any N's in it * * * Arg: c [READ ] codon number 0-124 [codon] * * Return [UNKN ] TRUE if has N's , FALSE otherwise [boolean] * */ # line 321 "codon.dy" boolean has_random_bases(codon c) { base o; base w; base t; o = base_from_codon(c,1); w = base_from_codon(c,2); t = base_from_codon(c,3); if( o == BASE_N || w == BASE_N || t == BASE_N) return TRUE; return FALSE; } /* Function: permute_possible_random_bases(c,one,two,three) * * Descrip: Bizarely useful function for calculating ambiguity scores. * * This takes the codon c, and for each possible base, * if it is N, replaces it with one, two or three. * * If the base is not N, it remains the same * * * Arg: c [READ ] codon number [codon] * Arg: one [READ ] base to replace first position if N [base] * Arg: two [READ ] base to replace second position if N [base] * Arg: three [READ ] base to replace third position if N [base] * * Return [UNKN ] codon number [codon] * */ # line 351 "codon.dy" codon permute_possible_random_bases(codon c,base one,base two,base three) { base o; base w; base t; o = base_from_codon(c,1); w = base_from_codon(c,2); t = base_from_codon(c,3); if( o == BASE_N ) o = one; if( w == BASE_N ) w = two; if( t == BASE_N ) t = three; return one*25+two*5+three; } /* Function: all_bases_from_codon(c,one,two,three) * * Descrip: Really an internal function, by useful enough to * encourage outside use. * * Takes codon c and breaks it into 3 base-numbers * * * Arg: c [UNKN ] Undocumented argument [codon] * Arg: one [UNKN ] Undocumented argument [base *] * Arg: two [UNKN ] Undocumented argument [base *] * Arg: three [UNKN ] Undocumented argument [base *] * */ # line 378 "codon.dy" void all_bases_from_codon(codon c,base * one,base * two,base * three) { base o; base t; base r; o = c/25; c -= o*25; t = c/5; c -= t*5; r = c; if( one != NULL ) *one = o; if( two != NULL ) *two = t; if( three != NULL ) *three = r; } /* Function: reverse_codon(c) * * Descrip: Reverses codon. Takes a forward codon number and * builds the inverted codon number * * * Arg: c [UNKN ] Undocumented argument [codon] * * Return [UNKN ] Undocumented return value [codon] * */ # line 405 "codon.dy" codon reverse_codon(codon c) { base one; base two; base three; all_bases_from_codon(c,&one,&two,&three); one = complement_base(one); two = complement_base(two); three = complement_base(three); return three*125 + two * 25 + one; } /* Function: base_from_codon(c,pos) * * Descrip: Probably not the best function to use for this, but * useful. Takes a codon and with pos being 1,2,3 gives * you the firt,second of third base * * * Arg: c [UNKN ] Undocumented argument [codon] * Arg: pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [base] * */ # line 426 "codon.dy" base base_from_codon(codon c,int pos) { base one; base two; base three; one = c/25; c -= one*25; two = c/5; c -= two*5; three = c; switch(pos) { case 1 : return one; case 2: return two; case 3: return three; default : warn("This is not good news: got a position asked which is not 1,2,3 [%d](BTW - first base is 1)",pos); return BASE_N; } } /* Function: codon_from_seq(seq) * * Descrip: takes an ASCII coded pointer to a 3 base pair * sequence (it could be the part of a sequence: it only * assummes that the seq points with 3 chars at pos 0,1,2 * in C coordinates from seq. No NULL is required). It * ives back the codon as made from standard mapping, ie, * 25*base_1+5*base_2 + base3 being a number from 0-124 inc. * * * Arg: seq [UNKN ] pointer to sequence of at least 3 chrs long. [char *] * * Return [UNKN ] Undocumented return value [codon] * */ # line 461 "codon.dy" codon codon_from_seq(char * seq) { base one; base two; base three; if( !is_base(*seq) || !is_base(*(seq+1)) || !is_base (*(seq+2)) ) { warn("Attempting to translate bad base %c%c%c",seq[0],seq[1],seq[2]); one = BASE_N; two = BASE_N; three = BASE_N; } else { one = base_from_char(*seq); two = base_from_char(*(seq+1)); three = base_from_char(*(seq+2)); } return one*25+two*5+three; } /* Function: base4_codon_from_seq(seq) * * Descrip: Sometimes it is more useful to work in base64, ie, * non N. this functions does the same thing as * /codon_from_seq but produces a seq being * 16*base1 + 4 *base2 + base3 * * * Arg: seq [UNKN ] pointer to sequence of at least 3 chrs long [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 489 "codon.dy" int base4_codon_from_seq(char * seq) { base one; base two; base three; one = base_from_char(*seq); two = base_from_char(*(seq+1)); three = base_from_char(*(seq+2)); if( one == BASE_N || two == BASE_N || three == BASE_N) return 64; else return one*16+two*4+three; } /* Function: char_from_base(b) * * Descrip: maps a base number (-04 inc) to A,T,G,C,N * * * Arg: b [UNKN ] Undocumented argument [base] * * Return [UNKN ] Undocumented return value [char] * */ # line 508 "codon.dy" char char_from_base(base b) { switch(b) { case BASE_A : return 'A'; case BASE_G : return 'G'; case BASE_C : return 'C'; case BASE_T : return 'T'; case BASE_N : return 'N'; default : return '?'; } } /* Function: base_from_char(c) * * Descrip: maps a char (atcgn) to number, * case insensitive, returns BASE_N * if not atcgn * * * Arg: c [UNKN ] Undocumented argument [char] * * Return [UNKN ] Undocumented return value [base] * */ # line 526 "codon.dy" base base_from_char(char c) { c = (char)toupper((int)c); switch(c) { case 'A' : return BASE_A; case 'T' : return BASE_T; case 'G' : return BASE_G; case 'C' : return BASE_C; case 'N' : return BASE_N; default : return BASE_N; } } /* Function: char_complement_base(c) * * Descrip: the char equivalent of /complement_base. * this gives the complement in char of a base * in char. Does not check for non ATGCN * * * Arg: c [UNKN ] Undocumented argument [char] * * Return [UNKN ] Undocumented return value [char] * */ # line 545 "codon.dy" char char_complement_base(char c) { if( c == '-' || c == '.' || c == '~' ) { return c; } return char_from_base(complement_base(base_from_char(c))); } /* Function: complement_base(b) * * Descrip: gives back the complement as a number * ofthe base (given as a number) * * * Arg: b [UNKN ] Undocumented argument [base] * * Return [UNKN ] Undocumented return value [base] * */ # line 558 "codon.dy" base complement_base(base b) { switch(b) { case BASE_A : return BASE_T; case BASE_G : return BASE_C; case BASE_C : return BASE_G; case BASE_T : return BASE_A; case BASE_N : return BASE_N; default : return BASE_N; } } /* Function: four_fold_sites_CodonTable(*ct,seq) * * Descrip: returns the number of four fold degenerate * sites in this codon * * * Arg: *ct [UNKN ] Undocumented argument [CodonTable] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 577 "codon.dy" int four_fold_sites_CodonTable(CodonTable *ct,char * seq) { int site_count; int i; int j; char codon[3]; char aa; assert(ct); codon[0] = seq[0]; codon[1] = seq[1]; codon[2] = seq[2]; aa = aminoacid_from_seq(ct,codon); site_count = 0; for(i=0;i<3;i++) { for( j=0;j<4;j++) { codon[i] = char_from_base(j); if( aa != aminoacid_from_seq(ct,codon) ) { break; } } if( j >= 4 ) { site_count++; } codon[i] = seq[i]; } return site_count; } # line 652 "codon.c" /* Function: hard_link_CodonTable(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CodonTable *] * * Return [UNKN ] Undocumented return value [CodonTable *] * */ CodonTable * hard_link_CodonTable(CodonTable * obj) { if( obj == NULL ) { warn("Trying to hard link to a CodonTable object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CodonTable_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CodonTable *] * */ CodonTable * CodonTable_alloc(void) { CodonTable * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CodonTable *) ckalloc (sizeof(CodonTable))) == NULL) { warn("CodonTable_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* codon_str[125] is an array: no default possible */ out->name = NULL; return out; } /* Function: free_CodonTable(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CodonTable *] * * Return [UNKN ] Undocumented return value [CodonTable *] * */ CodonTable * free_CodonTable(CodonTable * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CodonTable obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: replace_name_CodonTable(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [CodonTable *] * Arg: name [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable name [boolean] * */ boolean replace_name_CodonTable(CodonTable * obj,char * name) { if( obj == NULL) { warn("In replacement function name for object CodonTable, got a NULL object"); return FALSE; } obj->name = name; return TRUE; } /* Function: access_name_CodonTable(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [CodonTable *] * * Return [SOFT ] member variable name [char *] * */ char * access_name_CodonTable(CodonTable * obj) { if( obj == NULL) { warn("In accessor function name for object CodonTable, got a NULL object"); return NULL; } return obj->name; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/codon.h0000644000175000001440000003305710670453712016121 0ustar philippusers#ifndef DYNAMITEcodonHEADERFILE #define DYNAMITEcodonHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #define BASE_A 0 #define BASE_G 1 #define BASE_C 2 #define BASE_T 3 #define BASE_N 4 typedef short int base; typedef short int codon; typedef char aa; #define aminoacid_number(c) (c-'A') #define is_base(a) (a == 'A' || a == 'T' || a == 'C' || a == 'G' || a== 'N' || a == 'a' || a == 't' || a == 'c' || a == 'g' || a == 'n' ? 1 : 0) /* Object CodonTable * * Descrip: The codon table provides a mapping from the 64 codons to the 20 amino * acids. The rest of the modules provides assorted codon<->base<->amino * acid mappings. * * Probably the trickiest thing is that there are two different types of * representations of codons. One in base 5 (N being the 5th base), * providing 0-124 inclusive codon numbers. These numbers are the ones * going to be principly used in most calculations. * * However, it is often very useful to use 0-63 numbers, for example * in the precise definition of the codon table. * * */ struct Wise2_CodonTable { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif aa codon_str[125]; char * name; } ; /* CodonTable defined */ #ifndef DYNAMITE_DEFINED_CodonTable typedef struct Wise2_CodonTable Wise2_CodonTable; #define CodonTable Wise2_CodonTable #define DYNAMITE_DEFINED_CodonTable #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: read_CodonTable_file(file) * * Descrip: Opens filename, reads it as if a Ewan style * codon table and closes. * * * Arg: file [READ ] filename to open [char *] * * Return [OWNER] A codon-table, NULL if error [CodonTable *] * */ CodonTable * Wise2_read_CodonTable_file(char * file); #define read_CodonTable_file Wise2_read_CodonTable_file /* Function: read_CodonTable(ifp) * * Descrip: reads a codon table from a filestream in Ewan * format. * * As Ewan format is really bad and has no start/stop * this will effectively read to the end of the file. * Ooops. * * * Arg: ifp [READ ] file input [FILE *] * * Return [UNKN ] Undocumented return value [CodonTable *] * */ CodonTable * Wise2_read_CodonTable(FILE * ifp); #define read_CodonTable Wise2_read_CodonTable /* Function: aminoacid_from_seq(ct,seq) * * Descrip: Returns the amino acid for this position in the DNA sequence * Takes the pointer +1 and +2 points. * * No error checks implemented. Probably a mistake ;) * * * Arg: ct [READ ] codon table [CodonTable *] * Arg: seq [READ ] pointer to DNA chars [char *] * * Return [UNKN ] an amino acid char (A-Z) [aa] * */ aa Wise2_aminoacid_from_seq(CodonTable * ct,char * seq); #define aminoacid_from_seq Wise2_aminoacid_from_seq /* Function: aminoacid_from_codon(ct,c) * * Descrip: returns amino acid for this codon number (NB codon numbers 0-125) * * * Arg: ct [READ ] codon table [CodonTable *] * Arg: c [READ ] codon number [codon] * * Return [READ ] aminoacid that is this codon (X for ambiguous, * for stop) [aa] * */ aa Wise2_aminoacid_from_codon(CodonTable * ct,codon c); #define aminoacid_from_codon Wise2_aminoacid_from_codon /* Function: aminoacid_no_from_codon(ct,c) * * Descrip: a sister function to aminoacid_from_codon: * returns amino acid number (0-26) for this codon number (0-125) * * * Arg: ct [READ ] codon table [CodonTable *] * Arg: c [READ ] codon number [codon] * * Return [READ ] aminoacid number [0-26] for this codon [int] * */ int Wise2_aminoacid_no_from_codon(CodonTable * ct,codon c); #define aminoacid_no_from_codon Wise2_aminoacid_no_from_codon /* Function: is_stop_codon(c,ct) * * Descrip: tells you whether this codon number is really a stop * in this translation table * * * Arg: c [READ ] codon number [codon] * Arg: ct [READ ] codon table [CodonTable *] * * Return [UNKN ] TRUE if is stop, FALSE otherwise [boolean] * */ boolean Wise2_is_stop_codon(codon c,CodonTable * ct); #define is_stop_codon Wise2_is_stop_codon /* Function: is_non_ambiguous_codon_seq(seq) * * Descrip: Tells you if this codon is a real codon * * * Arg: seq [READ ] pointer to DNA sequence [char *] * * Return [UNKN ] TRUE if real codon, FALSE if contains N's [boolean] * */ boolean Wise2_is_non_ambiguous_codon_seq(char * seq); #define is_non_ambiguous_codon_seq Wise2_is_non_ambiguous_codon_seq /* Function: is_valid_aminoacid(ct,c) * * Descrip: Tells you if this letter (c) is recognised as a valid amino acid * in this codon table * * * Arg: ct [READ ] Codon Table [CodonTable *] * Arg: c [UNKN ] aminoacid [char] * * Return [UNKN ] TRUE if valid, FALSE if not. [boolean] * */ boolean Wise2_is_valid_aminoacid(CodonTable * ct,char c); #define is_valid_aminoacid Wise2_is_valid_aminoacid /* Function: is_valid_base_char(c) * * Descrip: Tells you if the letter is A,T,C,G,N (NB, N is ok). * * * Arg: c [READ ] base [char] * * Return [UNKN ] TRUE if (ATGCN) FALSE otherwise [boolean] * */ boolean Wise2_is_valid_base_char(char c); #define is_valid_base_char Wise2_is_valid_base_char /* Function: codon_from_base4_codon(c) * * Descrip: maps a 0-63 codon to a 0-123 codon. Suprisingly useful. * * * Arg: c [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [codon] * */ codon Wise2_codon_from_base4_codon(int c); #define codon_from_base4_codon Wise2_codon_from_base4_codon /* Function: base4_codon_from_codon(c) * * Descrip: maps a 0-125 codon to a 0-63 codon. * * If ambiguous then returns 64 having issued a warning. * * * Arg: c [READ ] codon 0-125 [codon] * * Return [UNKN ] base 4 codon (0-63) [int] * */ int Wise2_base4_codon_from_codon(codon c); #define base4_codon_from_codon Wise2_base4_codon_from_codon /* Function: has_random_bases(c) * * Descrip: Tests to see if this codon number has any N's in it * * * Arg: c [READ ] codon number 0-124 [codon] * * Return [UNKN ] TRUE if has N's , FALSE otherwise [boolean] * */ boolean Wise2_has_random_bases(codon c); #define has_random_bases Wise2_has_random_bases /* Function: permute_possible_random_bases(c,one,two,three) * * Descrip: Bizarely useful function for calculating ambiguity scores. * * This takes the codon c, and for each possible base, * if it is N, replaces it with one, two or three. * * If the base is not N, it remains the same * * * Arg: c [READ ] codon number [codon] * Arg: one [READ ] base to replace first position if N [base] * Arg: two [READ ] base to replace second position if N [base] * Arg: three [READ ] base to replace third position if N [base] * * Return [UNKN ] codon number [codon] * */ codon Wise2_permute_possible_random_bases(codon c,base one,base two,base three); #define permute_possible_random_bases Wise2_permute_possible_random_bases /* Function: all_bases_from_codon(c,one,two,three) * * Descrip: Really an internal function, by useful enough to * encourage outside use. * * Takes codon c and breaks it into 3 base-numbers * * * Arg: c [UNKN ] Undocumented argument [codon] * Arg: one [UNKN ] Undocumented argument [base *] * Arg: two [UNKN ] Undocumented argument [base *] * Arg: three [UNKN ] Undocumented argument [base *] * */ void Wise2_all_bases_from_codon(codon c,base * one,base * two,base * three); #define all_bases_from_codon Wise2_all_bases_from_codon /* Function: reverse_codon(c) * * Descrip: Reverses codon. Takes a forward codon number and * builds the inverted codon number * * * Arg: c [UNKN ] Undocumented argument [codon] * * Return [UNKN ] Undocumented return value [codon] * */ codon Wise2_reverse_codon(codon c); #define reverse_codon Wise2_reverse_codon /* Function: base_from_codon(c,pos) * * Descrip: Probably not the best function to use for this, but * useful. Takes a codon and with pos being 1,2,3 gives * you the firt,second of third base * * * Arg: c [UNKN ] Undocumented argument [codon] * Arg: pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [base] * */ base Wise2_base_from_codon(codon c,int pos); #define base_from_codon Wise2_base_from_codon /* Function: codon_from_seq(seq) * * Descrip: takes an ASCII coded pointer to a 3 base pair * sequence (it could be the part of a sequence: it only * assummes that the seq points with 3 chars at pos 0,1,2 * in C coordinates from seq. No NULL is required). It * ives back the codon as made from standard mapping, ie, * 25*base_1+5*base_2 + base3 being a number from 0-124 inc. * * * Arg: seq [UNKN ] pointer to sequence of at least 3 chrs long. [char *] * * Return [UNKN ] Undocumented return value [codon] * */ codon Wise2_codon_from_seq(char * seq); #define codon_from_seq Wise2_codon_from_seq /* Function: base4_codon_from_seq(seq) * * Descrip: Sometimes it is more useful to work in base64, ie, * non N. this functions does the same thing as * /codon_from_seq but produces a seq being * 16*base1 + 4 *base2 + base3 * * * Arg: seq [UNKN ] pointer to sequence of at least 3 chrs long [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_base4_codon_from_seq(char * seq); #define base4_codon_from_seq Wise2_base4_codon_from_seq /* Function: char_from_base(b) * * Descrip: maps a base number (-04 inc) to A,T,G,C,N * * * Arg: b [UNKN ] Undocumented argument [base] * * Return [UNKN ] Undocumented return value [char] * */ char Wise2_char_from_base(base b); #define char_from_base Wise2_char_from_base /* Function: base_from_char(c) * * Descrip: maps a char (atcgn) to number, * case insensitive, returns BASE_N * if not atcgn * * * Arg: c [UNKN ] Undocumented argument [char] * * Return [UNKN ] Undocumented return value [base] * */ base Wise2_base_from_char(char c); #define base_from_char Wise2_base_from_char /* Function: char_complement_base(c) * * Descrip: the char equivalent of /complement_base. * this gives the complement in char of a base * in char. Does not check for non ATGCN * * * Arg: c [UNKN ] Undocumented argument [char] * * Return [UNKN ] Undocumented return value [char] * */ char Wise2_char_complement_base(char c); #define char_complement_base Wise2_char_complement_base /* Function: complement_base(b) * * Descrip: gives back the complement as a number * ofthe base (given as a number) * * * Arg: b [UNKN ] Undocumented argument [base] * * Return [UNKN ] Undocumented return value [base] * */ base Wise2_complement_base(base b); #define complement_base Wise2_complement_base /* Function: four_fold_sites_CodonTable(*ct,seq) * * Descrip: returns the number of four fold degenerate * sites in this codon * * * Arg: *ct [UNKN ] Undocumented argument [CodonTable] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_four_fold_sites_CodonTable(CodonTable *ct,char * seq); #define four_fold_sites_CodonTable Wise2_four_fold_sites_CodonTable /* Function: hard_link_CodonTable(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CodonTable *] * * Return [UNKN ] Undocumented return value [CodonTable *] * */ CodonTable * Wise2_hard_link_CodonTable(CodonTable * obj); #define hard_link_CodonTable Wise2_hard_link_CodonTable /* Function: CodonTable_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CodonTable *] * */ CodonTable * Wise2_CodonTable_alloc(void); #define CodonTable_alloc Wise2_CodonTable_alloc /* Function: free_CodonTable(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CodonTable *] * * Return [UNKN ] Undocumented return value [CodonTable *] * */ CodonTable * Wise2_free_CodonTable(CodonTable * obj); #define free_CodonTable Wise2_free_CodonTable /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_name_CodonTable(CodonTable * obj,char * name); #define replace_name_CodonTable Wise2_replace_name_CodonTable char * Wise2_access_name_CodonTable(CodonTable * obj); #define access_name_CodonTable Wise2_access_name_CodonTable char * Wise2_alloc_aminoacid_from_seq(CodonTable * ct,char * seq); #define alloc_aminoacid_from_seq Wise2_alloc_aminoacid_from_seq #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/test_hsp.c0000644000175000001440000000112707523537015016636 0ustar philippusers#include "hsp.h" int main(int argc,char ** argv) { char * seq1s = "MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGLDYRTTDENLKAHRRKRRR"; char * seq2s = "MHKSEAPNEPEQLRKLFIGGLSFETTDESLREHFEQWGTLTDCVVMRDPNSKRSRGFGFV"; int query_coord = 33; int target_coord = 16; Sequence * seq1; Sequence * seq2; HSP * hsp; CompMat * mat; seq1 = new_Sequence_from_strings("seq1",seq1s); seq2 = new_Sequence_from_strings("seq2",seq2s); mat = read_Blast_file_CompMat("blosum62.bla"); hsp = new_HSP(seq1,seq2,query_coord,target_coord,mat,20); show_HSP(hsp,80,stdout); } wise-2.4.1/src/dynlibsrc/seqlookup.dy0000644000175000001440000001764510421421617017224 0ustar philippusers %{ #include "sequence.h" #include "sequencedb.h" #define SEQLOOKUP_5AA_SIZE (26*26*26*26*26) #define SEQLOOKUP_LOWCOMPLEXITY 1 #define ARRAYHEAD_IS_LOWCOMPLEXITY(head) (head->flags & SEQLOOKUP_LOWCOMPLEXITY) typedef struct SeqLookupResultStruct { Sequence * seq; int pos; } SeqLookupResultStruct; typedef struct Wise2_ArraySeqLookup_Unit { Sequence * seq; int pos; } ArraySeqLookupUnit; typedef struct Wise2_ArraySeqHead { ArraySeqLookupUnit * units; int current_pos; int max; char flags; } ArraySeqHead; typedef enum SeqLookupLoadType { SeqLookupLoad_Protein = 12, SeqLookupLoad_DNA } SeqLookupLoadType; #define SeqLookupInterfaceLISTLENGTH 4028 %} struct SeqLookupResultInterface SeqLookupResultStruct * (*next)(void * data,SeqLookupResultStruct * prev) !func boolean (*is_more)(void *data) !func void (*free_data)(void * data) !func void * data !link %info This is the final interface returned on finding an occuypied index (see below about how to get this). It basically represents an array of SeqLookupResultStruct. The interface can choose how to manage the memory - a client should call is_more function. If this function returns TRUE, then it can call next with the previous resultstruct passed in in the prev slot. For the first call it passes in a NULL pointer. The interface can decide whether to reuse the memory or not. Finally the client calls free_data to indicate that it does not want to use the information any more %% struct SeqLookupClientInterface SeqLookupResultInterface * (*lookup)(void * data,int seq_number) !func boolean (*is_populated)(void * data,int seq_number) !func void (*free_data)(void * data) !func void * data !link %info This is a per-client interface got from the central SeqLookup interface. A client must guarentee that only a single thread will interact with a single SeqLookupClientInterface so interfaces have a chance to sensible manage their memory %% struct SeqLookupLoadPara SeqLookupLoadType type !def="SeqLookupLoad_Protein" int tile_freq !def="1" int report_stagger !def="0" int truncate !def="0" int mark_low_complexity !def="1" int start_seq_load !def="-1" int end_seq_load !def="-1" struct SeqLookupInterface SeqLookupClientInterface * (*get_client)(void * data) !func boolean (*add_seq)(void * data,Sequence * seq,SeqLookupLoadPara * para) !func ArraySeqHead * (*lookup_array_head)(void * data,int seq_number) !func boolean (*add_direct_number)(void *data,int seq_number,Sequence * target,int pos) !func void (*free_data)(void * data) !func void * data !link Sequence ** seq_store !list %info This interface defines the basic SeqLookup possibilities. Its main role is to give out clientInterfaces, which must be one per thread (in contrast a client can call get_client by multiple threads, though it should do each call via single threaded). %% %{ #include "seqlookup.h" %func Frees SeqLookupInterface - overrides dynamite default %% !deconstructor SeqLookupInterface * free_SeqLookupInterface(SeqLookupInterface * sli) { int i; if( sli == NULL ) { return NULL; } for(i=0;ilen;i++) { free_Sequence(sli->seq_store[i]); } (*sli->free_data)(sli->data); ckfree(sli); return NULL; } %func Loads a SequenceDB into a hash on the basis of the SeqLookupLoadPara returns the number of sequences loaded %% int load_SequenceDB_SeqLookupLoadPara(SeqLookupLoadPara * p,SequenceDB * db,SeqLookupInterface * sli) { int ret; int c; int i; Sequence * seq; int base[5]; int start_base; int char_count = 0; for(i=0,start_base=1;i<5;i++) { base[i] = start_base; start_base = start_base * 26; } for(c=0,seq = init_SequenceDB(db,&ret); seq != NULL;seq = get_next_SequenceDB(db) ) { /* don't have to hardlink and then also free - just store here */ c++; if( p->start_seq_load >= 0 && c-1 < p->start_seq_load ) { continue; } if( p->end_seq_load >= 0 && c-1 >= p->end_seq_load ) { break; } add_SeqLookupInterface(sli,seq); if( p->report_stagger >= 1 && c % p->report_stagger == 0 ) { info("Loaded %d sequences (%d characters, %.2f)... at %s\n",c,char_count,(double)char_count/(double)p->report_stagger,seq->name); char_count = 0; } char_count += seq->len; (*sli->add_seq)(sli->data,seq,p); if( p->truncate != 0 && c == p->truncate ) { info("Asked to truncate load after %d sequences\n",p->truncate); break; } } return c; } %func Shows help associated with Sequence loading %% void show_help_SeqLookupLoadPara(FILE * ofp) { fprintf(ofp,"Sequence Index Loading parameters\n"); fprintf(ofp," -seqloadtile tiling skip of load (default 1)\n"); fprintf(ofp," -seqloadreport report (using info) at what stagger rating (default none)\n"); fprintf(ofp," -seqloadtrunc truncate load after this number of sequeneces (useful for debugging)\n"); fprintf(ofp," -seqloadstart start position in database for seq load\n"); fprintf(ofp," -seqloadend end position in database for seq load\n"); fprintf(ofp," -[no]seqloadlow mark low complexity words for use with low complexity numbing\n"); return; } %func Builds new SeqLookup load from a command line %% SeqLookupLoadPara * new_SeqLookupLoadPara_from_argv(int * argc,char ** argv) { SeqLookupLoadPara * out; out = SeqLookupLoadPara_alloc(); out->mark_low_complexity = 1; out->start_seq_load = -1; out->end_seq_load = -1; strip_out_integer_argument(argc,argv,"seqloadtile",&out->tile_freq); strip_out_integer_argument(argc,argv,"seqloadreport",&out->report_stagger); strip_out_integer_argument(argc,argv,"seqloadtrunc",&out->truncate); strip_out_integer_argument(argc,argv,"seqloadstart",&out->start_seq_load); strip_out_integer_argument(argc,argv,"seqloadend",&out->end_seq_load); strip_out_boolean_def_argument(argc,argv,"seqloadlow",&out->mark_low_complexity); return out; } %func Function for DNA sequence to number on 15mers, Ns get mapped to -1 %% int seq_number_dna_15mer_noN(char * seq) { int i; int ret = 0; int base = 1; int no = 0; for(i=0;i<15;i++) { no = base_from_char(seq[i]); if( no == BASE_N ) { return -1; } ret += base * no; base = base * 4; } return ret; } %func Function for DNA sequence to number on 15mers, Ns get mapped to -1 %% int seq_number_dna_7mer_noN(char * seq) { int i; int ret = 0; int base = 1; int no = 0; for(i=0;i<7;i++) { no = base_from_char(seq[i]); if( no == BASE_N ) { return -1; } ret += base * no; base = base * 4; } return ret; } %func Function for the amino acid to number on 5mers %% int seq_number_aa_5mer(char * seq) { int i; int ret = 0; int base = 1; int no = 0; for(i=0;i<5;i++) { no = toupper(seq[i])-'A'; if( no > 26 || no < 0 ) { no = 'X'-'A'; } ret += base * no; base = base * 26; } return ret; } %func returns simple lowcomplexity flag or not for this sequence %% char flags_from_5aa_sequence(char * seq) { int count = 0; if( seq[0] != seq[1] ) { count++; } if( seq[1] != seq[2] ) { count++; } if( seq[2] != seq[3] ) { count++; } if( seq[3] != seq[4] ) { count++; } if( seq[4] != seq[0] ) { count++; } if( count < 3 ) { return SEQLOOKUP_LOWCOMPLEXITY; } else { return 0; } } %func Frees SeqLookupClientInterface - overrides dynamite default %% !deconstructor SeqLookupClientInterface * free_SeqLookupClientInterface(SeqLookupClientInterface * sli) { if( sli == NULL ) { return NULL; } (*sli->free_data)(sli->data); ckfree(sli); return NULL; } %func Frees SeqLookupResultInterface - overrides dynamite default %% !deconstructor SeqLookupResultInterface * free_SeqLookupResultInterface(SeqLookupResultInterface * sli) { if( sli == NULL ) { return NULL; } /* fprintf(stderr,"Freeing results interface\n"); */ (*sli->free_data)(sli->data); return NULL; } %} wise-2.4.1/src/dynlibsrc/test_psi.c0000644000175000001440000000175507614546544016656 0ustar philippusers #include "proteinstreamedindex.h" int main(int argc,char ** argv) { Sequence * seq; ProteinStreamedIndex * psi; ProteinStreamedIndexResult * psir; Sequence * query; int i,j; query = read_fasta_file_Sequence(argv[1]); fprintf(stderr,"Read in file %s\n",query->name); assert(query); psi = new_ProteinStreamedIndex(5); while( (seq = read_fasta_Sequence(stdin)) != NULL ) { fprintf(stderr,"Read in %s... still got %s\n",seq->name,query->name); add_Sequence_ProteinStreamedIndex(psi,seq); } for(i=0;ilen;i++) { psir = lookup_ProteinStreamedIndex(psi,seq_number_aa_5mer(query->seq+i)); if( psir == NULL ) { continue; } for(j=0;jlen;j++) { fprintf(stdout,"\n----------\n"); fprintf(stdout,"Hit:%d - %d\n%.5s\n%.5s\n",i,psir->result[j].pos,query->seq+i,psir->result[j].seq->seq+psir->result[j].pos); } free_ProteinStreamedIndexResult(psir); } /* dump_ProteinStreamedIndex(psi,stdout); */ return 0; } wise-2.4.1/src/dynlibsrc/dbsearchimpl.dy0000644000175000001440000001610407502704706017635 0ustar philippusers %{ #include "wisebase.h" enum DBSearchImpl_Type { DBSearchImpl_Serial, DBSearchImpl_Pthreads, DBSearchImpl_MPI, DBSearchImpl_PVM }; /* lifted from HMMer2 for this sort of work. So thanks to * Sean Eddy and seems like warren gish as well */ /* Our problem here is that POSIX apparently doesn't specify * a standard for how to get sysconf() to report the number of * processors on-line. _SC_NPROCESSORS_ONLN is specified * by SVR4.0MP. Thanks to W. Gish for help here. */ #ifdef _SC_NPROCESSORS_ONLN /* Sun Solaris, Digital UNIX */ #define DBSEARCH_NPROC sysconf(_SC_NPROCESSORS_ONLN) #else #ifdef _SC_NPROC_ONLN /* Silicon Graphics IRIX */ #define DBSEARCH_NPROC sysconf(_SC_NPROC_ONLN) #else /* FreeBSD, Linux don't support getting ncpu via sysconf() */ #define DBSEARCH_NPROC -1 #endif #endif enum DBSearchImpl_Routine { DBSearchImplRoutine_Exact = 0, DBSearchImplRoutine_Kbest, DBSearchImplRoutine_Forward}; %} struct DBSearchImpl int type !def="DBSearchImpl_Serial" int trace_level !def="0" // how much debugging information to print FILE * trace_file !def="stderr" !link // for writing out trace of db stuff int suggest_thread_no !def="(-1)" // default, -1, means the use a call to _SC_NPROC int search_routine !def="DBSearchImplRoutine_Exact" // routine used for the calculation, exact/kbest %info DBSearchImpl contains the information about the database search implementation used in a dynamite call. This is the only object which needs to specify say threads vs serial code The construction of this object is from its own stripping of the command line. This way programs which do database searching need not know anything about the implementation that is being used by the dynamite compiler From the API you should be looking to make it from one of the handy constructors. For the threads code, if you leave the suggest_thread_no at (-1) - what it usually comes as for the constructors. The system then figures out the number of processors available on the machine and sets it to that. %% api object DBSearchImpl des free_DBSearchImpl func impl_string_DBSearchImpl endobject func new_pthread_DBSearchImpl func new_serial_DBSearchImpl endapi %{ #include "dbsearchimpl.h" %func Gets a static text string out of the search implementation %simple string %arg return s string of the search implementation %% char * impl_string_DBSearchImpl(DBSearchImpl * dbsi) { switch(dbsi->type) { case DBSearchImpl_Serial : return "Single Threaded processor (serial)"; case DBSearchImpl_Pthreads : return "Pthreaded multiple processor"; case DBSearchImpl_MPI : return "MPI distributed memory multiple processor"; case DBSearchImpl_PVM : return "Parallel Virtual Machine implementation"; default : return "Unknown implementation"; } } %func Gets a static text string out of the search routine implementation %simple routine %arg return s string of the search implementation %% char * impl_string_routine_DBSearchImpl(DBSearchImpl * dbsi) { switch(dbsi->search_routine) { case DBSearchImplRoutine_Exact : return "Exact calculation"; case DBSearchImplRoutine_Kbest : return "Kbest heuristic"; case DBSearchImplRoutine_Forward : return "Forward score"; default : return "Unknown routine implementation"; } } %func This gets out the recommended number of threads for a dbsi %% int number_of_threads_DBSearchImpl(DBSearchImpl * dbsi) { int num; if( dbsi->type != DBSearchImpl_Pthreads ) { warn("Asking a database implementation how many threads when it is not pthreads but [%s]",impl_string_DBSearchImpl(dbsi)); } if( dbsi->suggest_thread_no == -1) { num = DBSEARCH_NPROC; if (num == -1) num = 2; return num; } return dbsi->suggest_thread_no; } %func Makes a new MPI DBSearchImpl For use mainly for api's who don't want to initalize the object from the command line %% DBSearchImpl * new_MPI_DBSearchImpl(void) { DBSearchImpl * out; out = DBSearchImpl_alloc(); out->type = DBSearchImpl_MPI; return out; } %func Makes a new pthreaded DBSearchImpl For use mainly for api's who don't want to initalize the object from the command line %% DBSearchImpl * new_pthread_DBSearchImpl(void) { DBSearchImpl * out; out = DBSearchImpl_alloc(); out->type = DBSearchImpl_Pthreads; return out; } %func Makes a new serial DBSearchImpl For use mainly for api's who don't want to initalize the object from the command line %% DBSearchImpl * new_serial_DBSearchImpl(void) { DBSearchImpl * out; out = DBSearchImpl_alloc(); out->type = DBSearchImpl_Serial; return out; } %func This shows the help for the search implementation system. It prints out lines like -pthreads use pthreaded code %% void show_help_DBSearchImpl(FILE * ofp) { fprintf(ofp,"Database search implementation\n"); fprintf(ofp," -serial use serial code (single processor)\n"); fprintf(ofp," -pthread use pthread code (SMP box)\n"); fprintf(ofp," -pthr_no Number of threads to use\n"); fprintf(ofp," -mpi use MPI code (distributed memory system)\n"); fprintf(ofp," -pvm use parallel virtual machine search system\n"); fprintf(ofp," -dbtrace Trace level of the database code (for debugging only)\n"); fprintf(ofp," -sroutine Search type routine [exact/kbest/forward]\n"); } %func This process command line arguments to make a new DBSearchImpl. This way the search implementation is relatively flexible from the program which calls it. %% DBSearchImpl * new_DBSearchImpl_from_argv(int * argc,char ** argv) { DBSearchImpl * out; char * temp; out = DBSearchImpl_alloc(); out->trace_file = stderr; if( (strip_out_boolean_argument(argc,argv,"mpi")) == TRUE ) { out->type = DBSearchImpl_MPI; } if( (strip_out_boolean_argument(argc,argv,"pthread")) == TRUE ) { out->type = DBSearchImpl_Pthreads; } if( (strip_out_boolean_argument(argc,argv,"pvm")) == TRUE ) { out->type = DBSearchImpl_PVM; } if( (strip_out_boolean_argument(argc,argv,"serial")) == TRUE ) { out->type = DBSearchImpl_Serial; } if( (temp = strip_out_assigned_argument(argc,argv,"pthr_no")) != NULL ) { if( is_integer_string(temp,&out->suggest_thread_no) == FALSE ) { warn("String [%s] for pthr_no is not an integer!",temp); free_DBSearchImpl(out); return NULL; } } if( (temp = strip_out_assigned_argument(argc,argv,"dbtrace")) != NULL ) { if( is_integer_string(temp,&out->trace_level) == FALSE ) { warn("String [%s] for dbtrace is not an integer!",temp); free_DBSearchImpl(out); return NULL; } } if( (temp = strip_out_assigned_argument(argc,argv,"sroutine")) != NULL ) { if( strcmp(temp,"exact") == 0) { out->search_routine = DBSearchImplRoutine_Exact; } else if( strcmp(temp,"kbest") == 0 ) { out->search_routine = DBSearchImplRoutine_Kbest; } else if( strcmp(temp,"forward") == 0 ) { out->search_routine = DBSearchImplRoutine_Forward; } else { warn("String [%s] for search routine is not recognised",temp); free_DBSearchImpl(out); return NULL; } } return out; } wise-2.4.1/src/dynlibsrc/dbsearchimpl.xs0000644000175000001440000000477610670453712017665 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::DBSearchImpl char * string(dbsi) Wise2_DBSearchImpl * dbsi INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_impl_string_DBSearchImpl(dbsi)); RETVAL = temp; OUTPUT: RETVAL Wise2_DBSearchImpl * hard_link_DBSearchImpl(obj) Wise2_DBSearchImpl * obj CODE: RETVAL = Wise2_hard_link_DBSearchImpl(obj); OUTPUT: RETVAL Wise2_DBSearchImpl * alloc() CODE: RETVAL = Wise2_DBSearchImpl_alloc(); OUTPUT: RETVAL boolean set_type(obj,type) Wise2_DBSearchImpl * obj int type CODE: RETVAL = Wise2_replace_type_DBSearchImpl(obj,type); OUTPUT: RETVAL int type(obj) Wise2_DBSearchImpl * obj CODE: RETVAL = Wise2_access_type_DBSearchImpl(obj); OUTPUT: RETVAL boolean set_trace_level(obj,trace_level) Wise2_DBSearchImpl * obj int trace_level CODE: RETVAL = Wise2_replace_trace_level_DBSearchImpl(obj,trace_level); OUTPUT: RETVAL int trace_level(obj) Wise2_DBSearchImpl * obj CODE: RETVAL = Wise2_access_trace_level_DBSearchImpl(obj); OUTPUT: RETVAL boolean set_trace_file(obj,trace_file) Wise2_DBSearchImpl * obj FILE * trace_file CODE: RETVAL = Wise2_replace_trace_file_DBSearchImpl(obj,trace_file); OUTPUT: RETVAL FILE * trace_file(obj) Wise2_DBSearchImpl * obj CODE: RETVAL = Wise2_access_trace_file_DBSearchImpl(obj); OUTPUT: RETVAL boolean set_suggest_thread_no(obj,suggest_thread_no) Wise2_DBSearchImpl * obj int suggest_thread_no CODE: RETVAL = Wise2_replace_suggest_thread_no_DBSearchImpl(obj,suggest_thread_no); OUTPUT: RETVAL int suggest_thread_no(obj) Wise2_DBSearchImpl * obj CODE: RETVAL = Wise2_access_suggest_thread_no_DBSearchImpl(obj); OUTPUT: RETVAL boolean set_search_routine(obj,search_routine) Wise2_DBSearchImpl * obj int search_routine CODE: RETVAL = Wise2_replace_search_routine_DBSearchImpl(obj,search_routine); OUTPUT: RETVAL int search_routine(obj) Wise2_DBSearchImpl * obj CODE: RETVAL = Wise2_access_search_routine_DBSearchImpl(obj); OUTPUT: RETVAL Wise2_DBSearchImpl * new(class) char * class PPCODE: Wise2_DBSearchImpl * out; out = Wise2_DBSearchImpl_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_DBSearchImpl * obj CODE: Wise2_free_DBSearchImpl(obj); MODULE = Wise2 PACKAGE = Wise2 Wise2_DBSearchImpl * new_pthread_DBSearchImpl() CODE: RETVAL = Wise2_new_pthread_DBSearchImpl(); OUTPUT: RETVAL Wise2_DBSearchImpl * new_serial_DBSearchImpl() CODE: RETVAL = Wise2_new_serial_DBSearchImpl(); OUTPUT: RETVAL wise-2.4.1/src/dynlibsrc/proteinindexcons.c0000644000175000001440000001371710670453712020406 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "proteinindexcons.h" /* Function: new_SeqLookupInterface_from_ProteinIndexConstructor(pic) * * Descrip: Makes a new SeqLookupInterface from ProteinIndexConstructor * * * Arg: pic [UNKN ] Undocumented argument [ProteinIndexConstructor *] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ # line 34 "proteinindexcons.dy" SeqLookupInterface * new_SeqLookupInterface_from_ProteinIndexConstructor(ProteinIndexConstructor * pic) { switch(pic->type) { case ProteinIndexConstructor_Array : return new_ArraySeq_SeqLookupInterface(SEQLOOKUP_5AA_SIZE,1000); case ProteinIndexConstructor_Hash : return new_ghash_SeqLookupInterface(); case ProteinIndexConstructor_Stream : return new_ProteinStreamedIndex_SeqLookupInterface(pic->waypost); case ProteinIndexConstructor_Shadow : return new_ShadowSequenceIndex_SeqLookupInterface(pic->shadowlength,pic->has_maxlen,pic->max_seqlen,pic->shadow_error); default: fatal("Cannot process type %d as protein index constructor",pic->type); } return NULL; } /* Function: show_help_ProteinIndexConstructor(ofp) * * Descrip: provides help for protein index constructor * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 59 "proteinindexcons.dy" void show_help_ProteinIndexConstructor(FILE * ofp) { fprintf(ofp,"Protein Index construction options\n"); fprintf(ofp," -pitype [array/hash/stream/shadow] - default array\n"); fprintf(ofp," -piwaypost [number] - waypost for streamed cases, default 3\n"); fprintf(ofp," -pishadow [number] - shadow length for shadow cases, default 15\n"); fprintf(ofp," -pishadow_err [number] - errors per 100 identities tolerated, 3\n"); fprintf(ofp," -piseqmax - indexes can assumme maximum length of seq\n"); fprintf(ofp," -piseqmax_len [number] - assummed max sequnce length, default 1000\n"); return; } /* Function: new_ProteinIndexConstructor_from_argv(argc,argv) * * Descrip: Provides a ProteinIndexConstructor argument from argv * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [ProteinIndexConstructor *] * */ # line 76 "proteinindexcons.dy" ProteinIndexConstructor * new_ProteinIndexConstructor_from_argv(int * argc,char ** argv) { ProteinIndexConstructor * out; char * temp; out = ProteinIndexConstructor_alloc(); temp = strip_out_assigned_argument(argc,argv,"pitype"); if( temp != NULL ) { if( strcmp(temp,"array") == 0 ) { out->type = ProteinIndexConstructor_Array; } else if ( strcmp(temp,"hash") == 0 ) { out->type = ProteinIndexConstructor_Hash; } else if ( strcmp(temp,"stream") == 0 ) { out->type = ProteinIndexConstructor_Stream; } else if ( strcmp(temp,"shadow") == 0 ) { out->type = ProteinIndexConstructor_Shadow; } else { fatal("Could not interpret %s as a protein index type",temp); } } strip_out_integer_argument(argc,argv,"piwaypost",&out->waypost); strip_out_integer_argument(argc,argv,"pishadow",&out->shadowlength); strip_out_boolean_def_argument(argc,argv,"piseqmax",&out->waypost); strip_out_integer_argument(argc,argv,"piseqmax_len",&out->shadowlength); return out; } # line 100 "proteinindexcons.c" /* Function: hard_link_ProteinIndexConstructor(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ProteinIndexConstructor *] * * Return [UNKN ] Undocumented return value [ProteinIndexConstructor *] * */ ProteinIndexConstructor * hard_link_ProteinIndexConstructor(ProteinIndexConstructor * obj) { if( obj == NULL ) { warn("Trying to hard link to a ProteinIndexConstructor object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ProteinIndexConstructor_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ProteinIndexConstructor *] * */ ProteinIndexConstructor * ProteinIndexConstructor_alloc(void) { ProteinIndexConstructor * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ProteinIndexConstructor *) ckalloc (sizeof(ProteinIndexConstructor))) == NULL) { warn("ProteinIndexConstructor_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = ProteinIndexConstructor_Array; out->waypost = 3; out->shadowlength = 15; out->has_maxlen = 0; out->max_seqlen = 1000; out->shadow_error = 3; return out; } /* Function: free_ProteinIndexConstructor(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ProteinIndexConstructor *] * * Return [UNKN ] Undocumented return value [ProteinIndexConstructor *] * */ ProteinIndexConstructor * free_ProteinIndexConstructor(ProteinIndexConstructor * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ProteinIndexConstructor obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/proteinindexcons.h0000644000175000001440000001046610670453712020411 0ustar philippusers#ifndef DYNAMITEproteinindexconsHEADERFILE #define DYNAMITEproteinindexconsHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "arrayseqlookup.h" #include "subseqhash.h" #include "proteinstreamedindex.h" #include "shadowseqindex.h" typedef enum ProteinIndexConstructorType { ProteinIndexConstructor_Array = 78, ProteinIndexConstructor_Hash, ProteinIndexConstructor_Stream, ProteinIndexConstructor_Shadow } ProteinIndexConstructureType; struct Wise2_ProteinIndexConstructor { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; int waypost; int shadowlength; int has_maxlen; int max_seqlen; int shadow_error; } ; /* ProteinIndexConstructor defined */ #ifndef DYNAMITE_DEFINED_ProteinIndexConstructor typedef struct Wise2_ProteinIndexConstructor Wise2_ProteinIndexConstructor; #define ProteinIndexConstructor Wise2_ProteinIndexConstructor #define DYNAMITE_DEFINED_ProteinIndexConstructor #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_SeqLookupInterface_from_ProteinIndexConstructor(pic) * * Descrip: Makes a new SeqLookupInterface from ProteinIndexConstructor * * * Arg: pic [UNKN ] Undocumented argument [ProteinIndexConstructor *] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * Wise2_new_SeqLookupInterface_from_ProteinIndexConstructor(ProteinIndexConstructor * pic); #define new_SeqLookupInterface_from_ProteinIndexConstructor Wise2_new_SeqLookupInterface_from_ProteinIndexConstructor /* Function: show_help_ProteinIndexConstructor(ofp) * * Descrip: provides help for protein index constructor * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_help_ProteinIndexConstructor(FILE * ofp); #define show_help_ProteinIndexConstructor Wise2_show_help_ProteinIndexConstructor /* Function: new_ProteinIndexConstructor_from_argv(argc,argv) * * Descrip: Provides a ProteinIndexConstructor argument from argv * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [ProteinIndexConstructor *] * */ ProteinIndexConstructor * Wise2_new_ProteinIndexConstructor_from_argv(int * argc,char ** argv); #define new_ProteinIndexConstructor_from_argv Wise2_new_ProteinIndexConstructor_from_argv /* Function: hard_link_ProteinIndexConstructor(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ProteinIndexConstructor *] * * Return [UNKN ] Undocumented return value [ProteinIndexConstructor *] * */ ProteinIndexConstructor * Wise2_hard_link_ProteinIndexConstructor(ProteinIndexConstructor * obj); #define hard_link_ProteinIndexConstructor Wise2_hard_link_ProteinIndexConstructor /* Function: ProteinIndexConstructor_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ProteinIndexConstructor *] * */ ProteinIndexConstructor * Wise2_ProteinIndexConstructor_alloc(void); #define ProteinIndexConstructor_alloc Wise2_ProteinIndexConstructor_alloc /* Function: free_ProteinIndexConstructor(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ProteinIndexConstructor *] * * Return [UNKN ] Undocumented return value [ProteinIndexConstructor *] * */ ProteinIndexConstructor * Wise2_free_ProteinIndexConstructor(ProteinIndexConstructor * obj); #define free_ProteinIndexConstructor Wise2_free_ProteinIndexConstructor /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/translation.typemap0000644000175000001440000000037410670453713020602 0ustar philippusers TYPEMAP Wise2_Translation * T_Wise2_Translation INPUT T_Wise2_Translation $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_Translation *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_Translation sv_setref_pv($arg, "Wise2::Translation", (void*) $var); wise-2.4.1/src/dynlibsrc/proteinstreamedindex.c0000644000175000001440000003556410670453712021254 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "proteinstreamedindex.h" typedef struct ProteinStreamedClient_struct { GenericIndexResult result; SeqLookupResultInterface interface; ProteinStreamedIndex * index; } ProteinStreamedClient; static ProteinStreamedClient * ProteinStreamedClient_alloc(void) { ProteinStreamedClient * out; out = malloc(sizeof(ProteinStreamedClient)); return out; } /* Function: new_ProteinStreamedIndex_SeqLookupInterface(waypost) * * Descrip: Provides a SeqLookupInterface, the common runtime plug-in for indexers * using a ProteinStreamedIndex * * * Arg: waypost [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ # line 59 "proteinstreamedindex.dy" SeqLookupInterface * new_ProteinStreamedIndex_SeqLookupInterface(int waypost) { SeqLookupInterface * out; ProteinStreamedIndex * in; in = new_ProteinStreamedIndex(waypost); out = SeqLookupInterface_alloc_std(); out->get_client = get_client_interface_ProteinStreamedIndex; out->add_seq = add_seq_interface_ProteinStreamedIndex; out->free_data = free_interface_ProteinStreamedIndex; out->lookup_array_head = NULL; out->data = (void*) in; return out; } /* Function: get_client_interface_ProteinStreamedIndex(data) * * Descrip: gets client interface * * * Arg: data [UNKN ] Undocumented argument [void*] * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ # line 80 "proteinstreamedindex.dy" SeqLookupClientInterface * get_client_interface_ProteinStreamedIndex(void* data) { ProteinStreamedIndex * index = (ProteinStreamedIndex*) data; SeqLookupClientInterface * slci; ProteinStreamedClient * pcl; pcl = ProteinStreamedClient_alloc(); pcl->result.result = calloc(64,sizeof(SeqLookupResultStruct)); pcl->result.max_len = 64; pcl->result.len = 0; pcl->interface.next = next_interface_GenericIndexResult; pcl->interface.is_more = is_more_interface_GenericIndexResult; pcl->interface.free_data = free_noop_GenericIndexResult; pcl->interface.data = (void*) &(pcl->result); pcl->index = index; slci = SeqLookupClientInterface_alloc(); slci->lookup = lookup_interface_ProteinStreamedClient; slci->is_populated = is_populated_interface_ProteinStreamedClient; slci->free_data = free_interface_ProteinStreamedClient; slci->data = (void*) pcl; return slci; } /* Function: lookup_interface_ProteinStreamedClient(data,seq_number) * * Descrip: For lookup interface, provides a result * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ # line 112 "proteinstreamedindex.dy" SeqLookupResultInterface * lookup_interface_ProteinStreamedClient(void * data,int seq_number) { ProteinStreamedClient * cli= (ProteinStreamedClient*) data; ProteinStreamedIndex * in = cli->index; /* reset pointers */ cli->result.current_pos = 0; cli->result.len = 0; if( lookup_ProteinStreamedIndex(in,seq_number,&cli->result) == FALSE ) { return NULL; } return &cli->interface; } /* Function: is_populated_interface_ProteinStreamedClient(data,seq_number) * * Descrip: populated function for interface * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 131 "proteinstreamedindex.dy" boolean is_populated_interface_ProteinStreamedClient(void * data,int seq_number) { ProteinStreamedClient * client = (ProteinStreamedClient*) data; if( client->index->index[seq_number] != NULL ) { return TRUE; } else { return FALSE; } } /* Function: add_seq_interface_ProteinStreamedIndex(data,seq,para) * * Descrip: add function for interface * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 145 "proteinstreamedindex.dy" boolean add_seq_interface_ProteinStreamedIndex(void * data,Sequence * seq,SeqLookupLoadPara * para) { ProteinStreamedIndex * in = (ProteinStreamedIndex*) data; return add_Sequence_ProteinStreamedIndex(in,seq,para); } /* Function: free_interface_ProteinStreamedIndex(data) * * Descrip: for interface, frees index * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 155 "proteinstreamedindex.dy" void free_interface_ProteinStreamedIndex(void * data) { ProteinStreamedIndex * in = (ProteinStreamedIndex*) data; free_ProteinStreamedIndex(in); } /* Function: free_interface_ProteinStreamedClient(data) * * Descrip: Frees the client data * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 166 "proteinstreamedindex.dy" void free_interface_ProteinStreamedClient(void * data) { ProteinStreamedClient * cli = (ProteinStreamedClient *)data; free(cli->result.result); free(cli); } static int seq_number_aa_5mer_psi(char * seq) { int i; int ret = 0; int base = 1; int no = 0; for(i=0;i<5;i++) { no = toupper(seq[i])-'A'; if( no > 26 || no < 0 ) { no = 'X'-'A'; } ret += base * no; base = base * 26; } return ret; } /* Function: lookup_ProteinStreamedIndex(in,seqno,out) * * Descrip: Traverses index for a particular number to return hits * * * Arg: in [UNKN ] Undocumented argument [ProteinStreamedIndex *] * Arg: seqno [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [GenericIndexResult *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 200 "proteinstreamedindex.dy" boolean lookup_ProteinStreamedIndex(ProteinStreamedIndex * in,int seqno,GenericIndexResult * out) { /* look up this position, return NULL if nothing there */ if( in->index[seqno] == NULL ) { return FALSE; } /* yes, assign the number of counts in walk back up looking for wayposts */ /* start with self */ add_lookup_GenericIndexResult_from_Pos(in->index[seqno],out,0,in->waypost_depth); return TRUE; } /* Function: add_lookup_GenericIndexResult_from_Pos(p,psir,backtrace,waylength) * * Descrip: Adds additional sequences to index result from a particular position * * * Arg: p [UNKN ] Undocumented argument [ProteinStreamedIndexPos *] * Arg: psir [UNKN ] Undocumented argument [GenericIndexResult *] * Arg: backtrace [UNKN ] Undocumented argument [int] * Arg: waylength [UNKN ] Undocumented argument [int] * */ # line 222 "proteinstreamedindex.dy" void add_lookup_GenericIndexResult_from_Pos(ProteinStreamedIndexPos * p,GenericIndexResult * psir,int backtrace,int waylength) { int i; assert(p); assert(psir); /* printf("Entering add with backtrace %d count %d\n",backtrace,p->count);*/ while( p != NULL && backtrace < waylength ) { /* printf("Backtracing.... %d with count %d\n",backtrace,p->count); */ /* test whether this has any wayposts, add them with backtrace */ if( p->post_len > 0 ) { for(i=0;ipost_len;i++) { /* printf("....adding another index... %s, %d\n",p->post[i].seq->name,p->post[i].pos);*/ add_GenericIndexResult(psir,p->post[i].seq,p->post[i].pos+backtrace); } if( p->post_len == p->count ) { /* then we have the finished...*/ /* printf("... finished with %d\n",p->count); */ break; } } backtrace++; if( p->prev != NULL ) { /* have to recurse */ /* first go back up the main stream */ add_lookup_GenericIndexResult_from_Pos(p->first_prev,psir,backtrace,waylength); for(i=0;iprev_len;i++) { if( p->prev[i] == NULL ) { break; } add_lookup_GenericIndexResult_from_Pos(p->prev[i],psir,backtrace,waylength); } /* can assumme this is ok */ break; } else { p = p->first_prev; } } return; } /* Function: add_Sequence_ProteinStreamedIndex(in,seq,para) * * Descrip: Adds in a sequence into a ProteinStreamedIndex * * * Arg: in [UNKN ] Undocumented argument [ProteinStreamedIndex *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 274 "proteinstreamedindex.dy" boolean add_Sequence_ProteinStreamedIndex(ProteinStreamedIndex * in,Sequence * seq,SeqLookupLoadPara * para) { ProteinStreamedIndexPos * prev = NULL; int i; int j; int no; assert(in); assert(seq); if( para->tile_freq > 1 ) { fatal("Cannot have a streamed index with a tile_freq greater than 1. Misparameterisation"); } for(i=0;ilen-5;i++) { no = seq_number_aa_5mer_psi(seq->seq+i); if( in->index[no] == NULL ) { in->index[no] = new_ProteinStreamedIndexPos(); /* because this is a newly allocated index, we can put prev into first_prev now with impunity - the first one will have this as NULL and that is fine */ in->index[no]->first_prev = prev; } in->index[no]->count++; if( prev != NULL ) { /* check that reverse pointer is not present already */ j = 0; if( prev != in->index[no]->first_prev ) { for(j=0;jindex[no]->prev_len;j++) { if( prev == in->index[no]->prev[j] ) { break; } } if( j >= in->index[no]->prev_len ) { /* is not in there, add it */ /* potentially this could be first_prev if this came from the start of another sequence */ if( in->index[no]->first_prev == NULL ) { in->index[no]->first_prev = prev; } else { add_pos_ProteinStreamedIndexPos(in->index[no],prev); } } } } prev = in->index[no]; /* deal with waystations */ if( i == 0 || i % in->waypost_depth == 0 ) { add_waypost_ProteinStreamedIndexPos(in->index[no],seq,i); } } return TRUE; } /* Function: dump_ProteinStreamedIndex(in,ofp) * * Descrip: dumps in a silly format the ProteinStreamedIndex; for debugging * * * Arg: in [UNKN ] Undocumented argument [ProteinStreamedIndex *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 335 "proteinstreamedindex.dy" void dump_ProteinStreamedIndex(ProteinStreamedIndex * in,FILE * ofp) { int i,j; int size = 26 * 26 * 26 * 26 * 26; for(i=0;iindex[i] != NULL ) { fprintf(ofp,"Position %d occupied with %d previous\n WayStations ",i,in->index[i]->prev_len); for(j=0;jindex[i]->post_len;j++) { if( in->index[i] == NULL ) { break; } fprintf(ofp," %s [%d],",in->index[i]->post[j].seq->name, in->index[i]->post[j].pos); } fprintf(ofp,"\n"); } } } /* Function: new_ProteinStreamedIndex(waypost_depth) * * Descrip: Builds a new ProteinStreamedIndex * * * Arg: waypost_depth [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ProteinStreamedIndex *] * */ # line 360 "proteinstreamedindex.dy" ProteinStreamedIndex * new_ProteinStreamedIndex(int waypost_depth) { ProteinStreamedIndex * out; int size = 26 * 26 * 26 * 26 * 26; out = malloc(sizeof(ProteinStreamedIndex)); assert(out); out->index = calloc(size,sizeof(ProteinStreamedIndexPos*)); out->waypost_depth = waypost_depth; return out; } /* Function: free_ProteinStreamedIndex(in) * * Descrip: Release protein index * * * Arg: in [UNKN ] Undocumented argument [ProteinStreamedIndex *] * */ # line 376 "proteinstreamedindex.dy" void free_ProteinStreamedIndex(ProteinStreamedIndex * in) { int i; int size = 26 * 26 * 26 *26 * 26; assert(in); for(i=0;iindex[i] != NULL ) { free_ProteinStreamedIndexPos(in->index[i]); } } free(in->index); free(in); return; } /* Function: add_pos_ProteinStreamedIndexPos(pos,prev) * * Descrip: Adds a position, advancing array if needed * * * Arg: pos [UNKN ] Undocumented argument [ProteinStreamedIndexPos *] * Arg: prev [UNKN ] Undocumented argument [ProteinStreamedIndexPos *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 399 "proteinstreamedindex.dy" boolean add_pos_ProteinStreamedIndexPos(ProteinStreamedIndexPos * pos,ProteinStreamedIndexPos * prev) { int i; if( pos->prev == NULL ) { pos->prev = calloc(PROTEINSTREAMEDINDEX_PREV_START,sizeof(ProteinStreamedIndexPos*)); pos->prev[0] = NULL; pos->prev_len = PROTEINSTREAMEDINDEX_PREV_START; } if( pos->prev[pos->prev_len-1] != NULL ) { /* realloc */ pos->prev = realloc(pos->prev,(2*pos->prev_len)*sizeof(ProteinStreamedIndexPos*)); pos->prev_len = 2*pos->prev_len; } for(i=0;iprev_len;i++) { if( pos->prev[i] == NULL ) { pos->prev[i] = prev; pos->prev[i+1] = NULL; break; } } return TRUE; } /* Function: add_waypost_ProteinStreamedIndexPos(pos,seq,seqpos) * * Descrip: Adds a way post, advancing array if needed * * * Arg: pos [UNKN ] Undocumented argument [ProteinStreamedIndexPos *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: seqpos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 428 "proteinstreamedindex.dy" boolean add_waypost_ProteinStreamedIndexPos(ProteinStreamedIndexPos * pos,Sequence * seq,int seqpos) { if( pos->post == NULL ) { pos->post = calloc(PROTEINSTREAMEDINDEX_WAY_START,sizeof(ProteinStreamedIndexWayPost)); pos->post_len = 0; pos->post_maxlen = PROTEINSTREAMEDINDEX_WAY_START; } if( pos->post_len >= pos->post_maxlen ) { pos->post = realloc(pos->post,(2*pos->post_maxlen)*sizeof(ProteinStreamedIndexWayPost)); pos->post_maxlen = 2*pos->post_maxlen; } pos->post[pos->post_len].seq = seq; pos->post[pos->post_len].pos = seqpos; pos->post_len++; return TRUE; } /* Function: new_ProteinStreamedIndexPos(void) * * Descrip: Creates a new ProteinStreamedIndexPos * * * * Return [UNKN ] Undocumented return value [ProteinStreamedIndexPos *] * */ # line 452 "proteinstreamedindex.dy" ProteinStreamedIndexPos * new_ProteinStreamedIndexPos(void) { ProteinStreamedIndexPos * out; out = malloc(sizeof(ProteinStreamedIndexPos)); out->count = 0; out->prev = NULL; out->prev_len = 0; out->post = NULL; out->post_len = 0; out->post_maxlen = 0; return out; } /* Function: free_ProteinStreamedIndexPos(pos) * * Descrip: frees a ProteinStreamedIndexPos * * * Arg: pos [UNKN ] Undocumented argument [ProteinStreamedIndexPos *] * */ # line 469 "proteinstreamedindex.dy" void free_ProteinStreamedIndexPos(ProteinStreamedIndexPos * pos) { if( pos == NULL ) { return; } free(pos->prev); free(pos->post); free(pos); return; } # line 555 "proteinstreamedindex.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/proteinstreamedindex.h0000644000175000001440000002235310670453712021251 0ustar philippusers#ifndef DYNAMITEproteinstreamedindexHEADERFILE #define DYNAMITEproteinstreamedindexHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #include "seqlookup.h" #include "genericindexresult.h" typedef struct ProteinStreamedIndexWayPost { Sequence * seq; int pos; } ProteinStreamedIndexWayPost; typedef struct ProteinStreamedIndexPos { int count; struct ProteinStreamedIndexPos * first_prev; struct ProteinStreamedIndexPos ** prev; int prev_len; struct ProteinStreamedIndexWayPost * post; int post_len; int post_maxlen; } ProteinStreamedIndexPos; #define PROTEINSTREAMEDINDEX_PREV_START 4 #define PROTEINSTREAMEDINDEX_WAY_START 2 typedef struct ProteinStreamedIndex { ProteinStreamedIndexPos ** index; int len; int waypost_depth; } ProteinStreamedIndex; /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_ProteinStreamedIndex_SeqLookupInterface(waypost) * * Descrip: Provides a SeqLookupInterface, the common runtime plug-in for indexers * using a ProteinStreamedIndex * * * Arg: waypost [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * Wise2_new_ProteinStreamedIndex_SeqLookupInterface(int waypost); #define new_ProteinStreamedIndex_SeqLookupInterface Wise2_new_ProteinStreamedIndex_SeqLookupInterface /* Function: get_client_interface_ProteinStreamedIndex(data) * * Descrip: gets client interface * * * Arg: data [UNKN ] Undocumented argument [void*] * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ SeqLookupClientInterface * Wise2_get_client_interface_ProteinStreamedIndex(void* data); #define get_client_interface_ProteinStreamedIndex Wise2_get_client_interface_ProteinStreamedIndex /* Function: lookup_interface_ProteinStreamedClient(data,seq_number) * * Descrip: For lookup interface, provides a result * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ SeqLookupResultInterface * Wise2_lookup_interface_ProteinStreamedClient(void * data,int seq_number); #define lookup_interface_ProteinStreamedClient Wise2_lookup_interface_ProteinStreamedClient /* Function: is_populated_interface_ProteinStreamedClient(data,seq_number) * * Descrip: populated function for interface * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_populated_interface_ProteinStreamedClient(void * data,int seq_number); #define is_populated_interface_ProteinStreamedClient Wise2_is_populated_interface_ProteinStreamedClient /* Function: add_seq_interface_ProteinStreamedIndex(data,seq,para) * * Descrip: add function for interface * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_seq_interface_ProteinStreamedIndex(void * data,Sequence * seq,SeqLookupLoadPara * para); #define add_seq_interface_ProteinStreamedIndex Wise2_add_seq_interface_ProteinStreamedIndex /* Function: free_interface_ProteinStreamedIndex(data) * * Descrip: for interface, frees index * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_interface_ProteinStreamedIndex(void * data); #define free_interface_ProteinStreamedIndex Wise2_free_interface_ProteinStreamedIndex /* Function: free_interface_ProteinStreamedClient(data) * * Descrip: Frees the client data * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_interface_ProteinStreamedClient(void * data); #define free_interface_ProteinStreamedClient Wise2_free_interface_ProteinStreamedClient /* Function: lookup_ProteinStreamedIndex(in,seqno,out) * * Descrip: Traverses index for a particular number to return hits * * * Arg: in [UNKN ] Undocumented argument [ProteinStreamedIndex *] * Arg: seqno [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [GenericIndexResult *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_lookup_ProteinStreamedIndex(ProteinStreamedIndex * in,int seqno,GenericIndexResult * out); #define lookup_ProteinStreamedIndex Wise2_lookup_ProteinStreamedIndex /* Function: add_lookup_GenericIndexResult_from_Pos(p,psir,backtrace,waylength) * * Descrip: Adds additional sequences to index result from a particular position * * * Arg: p [UNKN ] Undocumented argument [ProteinStreamedIndexPos *] * Arg: psir [UNKN ] Undocumented argument [GenericIndexResult *] * Arg: backtrace [UNKN ] Undocumented argument [int] * Arg: waylength [UNKN ] Undocumented argument [int] * */ void Wise2_add_lookup_GenericIndexResult_from_Pos(ProteinStreamedIndexPos * p,GenericIndexResult * psir,int backtrace,int waylength); #define add_lookup_GenericIndexResult_from_Pos Wise2_add_lookup_GenericIndexResult_from_Pos /* Function: add_Sequence_ProteinStreamedIndex(in,seq,para) * * Descrip: Adds in a sequence into a ProteinStreamedIndex * * * Arg: in [UNKN ] Undocumented argument [ProteinStreamedIndex *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_Sequence_ProteinStreamedIndex(ProteinStreamedIndex * in,Sequence * seq,SeqLookupLoadPara * para); #define add_Sequence_ProteinStreamedIndex Wise2_add_Sequence_ProteinStreamedIndex /* Function: dump_ProteinStreamedIndex(in,ofp) * * Descrip: dumps in a silly format the ProteinStreamedIndex; for debugging * * * Arg: in [UNKN ] Undocumented argument [ProteinStreamedIndex *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_dump_ProteinStreamedIndex(ProteinStreamedIndex * in,FILE * ofp); #define dump_ProteinStreamedIndex Wise2_dump_ProteinStreamedIndex /* Function: new_ProteinStreamedIndex(waypost_depth) * * Descrip: Builds a new ProteinStreamedIndex * * * Arg: waypost_depth [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ProteinStreamedIndex *] * */ ProteinStreamedIndex * Wise2_new_ProteinStreamedIndex(int waypost_depth); #define new_ProteinStreamedIndex Wise2_new_ProteinStreamedIndex /* Function: free_ProteinStreamedIndex(in) * * Descrip: Release protein index * * * Arg: in [UNKN ] Undocumented argument [ProteinStreamedIndex *] * */ void Wise2_free_ProteinStreamedIndex(ProteinStreamedIndex * in); #define free_ProteinStreamedIndex Wise2_free_ProteinStreamedIndex /* Function: add_pos_ProteinStreamedIndexPos(pos,prev) * * Descrip: Adds a position, advancing array if needed * * * Arg: pos [UNKN ] Undocumented argument [ProteinStreamedIndexPos *] * Arg: prev [UNKN ] Undocumented argument [ProteinStreamedIndexPos *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_pos_ProteinStreamedIndexPos(ProteinStreamedIndexPos * pos,ProteinStreamedIndexPos * prev); #define add_pos_ProteinStreamedIndexPos Wise2_add_pos_ProteinStreamedIndexPos /* Function: add_waypost_ProteinStreamedIndexPos(pos,seq,seqpos) * * Descrip: Adds a way post, advancing array if needed * * * Arg: pos [UNKN ] Undocumented argument [ProteinStreamedIndexPos *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: seqpos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_waypost_ProteinStreamedIndexPos(ProteinStreamedIndexPos * pos,Sequence * seq,int seqpos); #define add_waypost_ProteinStreamedIndexPos Wise2_add_waypost_ProteinStreamedIndexPos /* Function: new_ProteinStreamedIndexPos(void) * * Descrip: Creates a new ProteinStreamedIndexPos * * * * Return [UNKN ] Undocumented return value [ProteinStreamedIndexPos *] * */ ProteinStreamedIndexPos * Wise2_new_ProteinStreamedIndexPos(void); #define new_ProteinStreamedIndexPos Wise2_new_ProteinStreamedIndexPos /* Function: free_ProteinStreamedIndexPos(pos) * * Descrip: frees a ProteinStreamedIndexPos * * * Arg: pos [UNKN ] Undocumented argument [ProteinStreamedIndexPos *] * */ void Wise2_free_ProteinStreamedIndexPos(ProteinStreamedIndexPos * pos); #define free_ProteinStreamedIndexPos Wise2_free_ProteinStreamedIndexPos /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/randomdb.c0000644000175000001440000004747010670453712016604 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "randomdb.h" /* Function: Sequence_from_RandomProteinDB(rndp) * * Descrip: Makes a new random sequence from a * RandomProteinDB * * * Arg: rndp [UNKN ] Undocumented argument [RandomProteinDB *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 44 "randomdb.dy" Sequence * Sequence_from_RandomProteinDB(RandomProteinDB * rndp) { int i; Sequence * out; char * name = "RandomSequence"; char buffer[512]; char * seq; if( rndp->use_flat_length == FALSE ) { warn("Ooops have not implemented gaussian lengths yet. Yikes!"); return NULL; } seq = ckcalloc(rndp->length+1,sizeof(char)); for(i=0;ilength+1;i++) { seq[i] = draw_random_aa_RandomModel(rndp->emission); } sprintf(buffer,"%s%d",name,rndp->num++); out = new_Sequence_from_strings(name,seq); ckfree(seq); return out; } /* Function: new_flat_RandomProteinDB(rm,length) * * Descrip: Makes a new flat RandomProteinDB * * * Arg: rm [SOFT ] RandomModel [RandomModel *] * Arg: length [UNKN ] length of protein to produce [int] * * Return [UNKN ] Undocumented return value [RandomProteinDB *] * */ # line 75 "randomdb.dy" RandomProteinDB * new_flat_RandomProteinDB(RandomModel * rm,int length) { RandomProteinDB * out; out = RandomProteinDB_alloc(); out->use_flat_length = TRUE; out->emission = hard_link_RandomModel(rm); out->length = length; return out; } /* Function: Sequence_from_RandomDNADB(rndp) * * Descrip: Makes a new random sequence from a * RandomDNADB * * * Arg: rndp [UNKN ] Undocumented argument [RandomDNADB *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 92 "randomdb.dy" Sequence * Sequence_from_RandomDNADB(RandomDNADB * rndp) { int i; Sequence * out; char * name = "RandomSequence"; char buffer[512]; char * seq; if( rndp->use_flat_length == FALSE ) { warn("Ooops have not implemented gaussian lengths yet. Yikes!"); return NULL; } seq = ckcalloc(rndp->length+1,sizeof(char)); for(i=0;ilength+1;i++) { seq[i] = draw_random_base_RandomModelDNA(rndp->emission); } sprintf(buffer,"%s%d",name,rndp->num++); out = new_Sequence_from_strings(buffer,seq); ckfree(seq); return out; } /* Function: new_flat_RandomDNADB(rm,length) * * Descrip: Makes a new flat RandomDNADB * * * Arg: rm [SOFT ] RandomModel emission [RandomModelDNA *] * Arg: length [UNKN ] length of DNA to produce [int] * * Return [UNKN ] Undocumented return value [RandomDNADB *] * */ # line 123 "randomdb.dy" RandomDNADB * new_flat_RandomDNADB(RandomModelDNA * rm,int length) { RandomDNADB * out; out = RandomDNADB_alloc(); out->use_flat_length = TRUE; out->emission = hard_link_RandomModelDNA(rm); out->length = length; out->num = 1; return out; } # line 121 "randomdb.c" /* Function: hard_link_RandomProteinDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomProteinDB *] * * Return [UNKN ] Undocumented return value [RandomProteinDB *] * */ RandomProteinDB * hard_link_RandomProteinDB(RandomProteinDB * obj) { if( obj == NULL ) { warn("Trying to hard link to a RandomProteinDB object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: RandomProteinDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomProteinDB *] * */ RandomProteinDB * RandomProteinDB_alloc(void) { RandomProteinDB * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(RandomProteinDB *) ckalloc (sizeof(RandomProteinDB))) == NULL) { warn("RandomProteinDB_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->use_flat_length = TRUE; out->length = 0; out->length_dist = NULL; out->emission = NULL; out->num = 0; return out; } /* Function: free_RandomProteinDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomProteinDB *] * * Return [UNKN ] Undocumented return value [RandomProteinDB *] * */ RandomProteinDB * free_RandomProteinDB(RandomProteinDB * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a RandomProteinDB obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->length_dist != NULL) free_Histogram(obj->length_dist); if( obj->emission != NULL) free_RandomModel(obj->emission); ckfree(obj); return NULL; } /* Function: hard_link_RandomDNADB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomDNADB *] * * Return [UNKN ] Undocumented return value [RandomDNADB *] * */ RandomDNADB * hard_link_RandomDNADB(RandomDNADB * obj) { if( obj == NULL ) { warn("Trying to hard link to a RandomDNADB object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: RandomDNADB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomDNADB *] * */ RandomDNADB * RandomDNADB_alloc(void) { RandomDNADB * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(RandomDNADB *) ckalloc (sizeof(RandomDNADB))) == NULL) { warn("RandomDNADB_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->use_flat_length = TRUE; out->length = 0; out->length_dist = NULL; out->emission = NULL; out->num = 0; return out; } /* Function: free_RandomDNADB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomDNADB *] * * Return [UNKN ] Undocumented return value [RandomDNADB *] * */ RandomDNADB * free_RandomDNADB(RandomDNADB * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a RandomDNADB obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->length_dist != NULL) free_Histogram(obj->length_dist); if( obj->emission != NULL) free_RandomModelDNA(obj->emission); ckfree(obj); return NULL; } /* Function: replace_use_flat_length_RandomProteinDB(obj,use_flat_length) * * Descrip: Replace member variable use_flat_length * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomProteinDB *] * Arg: use_flat_length [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable use_flat_length [boolean] * */ boolean replace_use_flat_length_RandomProteinDB(RandomProteinDB * obj,boolean use_flat_length) { if( obj == NULL) { warn("In replacement function use_flat_length for object RandomProteinDB, got a NULL object"); return FALSE; } obj->use_flat_length = use_flat_length; return TRUE; } /* Function: access_use_flat_length_RandomProteinDB(obj) * * Descrip: Access member variable use_flat_length * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomProteinDB *] * * Return [SOFT ] member variable use_flat_length [boolean] * */ boolean access_use_flat_length_RandomProteinDB(RandomProteinDB * obj) { if( obj == NULL) { warn("In accessor function use_flat_length for object RandomProteinDB, got a NULL object"); return FALSE; } return obj->use_flat_length; } /* Function: replace_length_RandomProteinDB(obj,length) * * Descrip: Replace member variable length * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomProteinDB *] * Arg: length [OWNER] New value of the variable [int] * * Return [SOFT ] member variable length [boolean] * */ boolean replace_length_RandomProteinDB(RandomProteinDB * obj,int length) { if( obj == NULL) { warn("In replacement function length for object RandomProteinDB, got a NULL object"); return FALSE; } obj->length = length; return TRUE; } /* Function: access_length_RandomProteinDB(obj) * * Descrip: Access member variable length * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomProteinDB *] * * Return [SOFT ] member variable length [int] * */ int access_length_RandomProteinDB(RandomProteinDB * obj) { if( obj == NULL) { warn("In accessor function length for object RandomProteinDB, got a NULL object"); return 0; } return obj->length; } /* Function: replace_length_dist_RandomProteinDB(obj,length_dist) * * Descrip: Replace member variable length_dist * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomProteinDB *] * Arg: length_dist [OWNER] New value of the variable [Histogram *] * * Return [SOFT ] member variable length_dist [boolean] * */ boolean replace_length_dist_RandomProteinDB(RandomProteinDB * obj,Histogram * length_dist) { if( obj == NULL) { warn("In replacement function length_dist for object RandomProteinDB, got a NULL object"); return FALSE; } obj->length_dist = length_dist; return TRUE; } /* Function: access_length_dist_RandomProteinDB(obj) * * Descrip: Access member variable length_dist * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomProteinDB *] * * Return [SOFT ] member variable length_dist [Histogram *] * */ Histogram * access_length_dist_RandomProteinDB(RandomProteinDB * obj) { if( obj == NULL) { warn("In accessor function length_dist for object RandomProteinDB, got a NULL object"); return NULL; } return obj->length_dist; } /* Function: replace_emission_RandomProteinDB(obj,emission) * * Descrip: Replace member variable emission * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomProteinDB *] * Arg: emission [OWNER] New value of the variable [RandomModel *] * * Return [SOFT ] member variable emission [boolean] * */ boolean replace_emission_RandomProteinDB(RandomProteinDB * obj,RandomModel * emission) { if( obj == NULL) { warn("In replacement function emission for object RandomProteinDB, got a NULL object"); return FALSE; } obj->emission = emission; return TRUE; } /* Function: access_emission_RandomProteinDB(obj) * * Descrip: Access member variable emission * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomProteinDB *] * * Return [SOFT ] member variable emission [RandomModel *] * */ RandomModel * access_emission_RandomProteinDB(RandomProteinDB * obj) { if( obj == NULL) { warn("In accessor function emission for object RandomProteinDB, got a NULL object"); return NULL; } return obj->emission; } /* Function: replace_num_RandomProteinDB(obj,num) * * Descrip: Replace member variable num * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomProteinDB *] * Arg: num [OWNER] New value of the variable [int] * * Return [SOFT ] member variable num [boolean] * */ boolean replace_num_RandomProteinDB(RandomProteinDB * obj,int num) { if( obj == NULL) { warn("In replacement function num for object RandomProteinDB, got a NULL object"); return FALSE; } obj->num = num; return TRUE; } /* Function: access_num_RandomProteinDB(obj) * * Descrip: Access member variable num * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomProteinDB *] * * Return [SOFT ] member variable num [int] * */ int access_num_RandomProteinDB(RandomProteinDB * obj) { if( obj == NULL) { warn("In accessor function num for object RandomProteinDB, got a NULL object"); return 0; } return obj->num; } /* Function: replace_use_flat_length_RandomDNADB(obj,use_flat_length) * * Descrip: Replace member variable use_flat_length * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomDNADB *] * Arg: use_flat_length [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable use_flat_length [boolean] * */ boolean replace_use_flat_length_RandomDNADB(RandomDNADB * obj,boolean use_flat_length) { if( obj == NULL) { warn("In replacement function use_flat_length for object RandomDNADB, got a NULL object"); return FALSE; } obj->use_flat_length = use_flat_length; return TRUE; } /* Function: access_use_flat_length_RandomDNADB(obj) * * Descrip: Access member variable use_flat_length * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomDNADB *] * * Return [SOFT ] member variable use_flat_length [boolean] * */ boolean access_use_flat_length_RandomDNADB(RandomDNADB * obj) { if( obj == NULL) { warn("In accessor function use_flat_length for object RandomDNADB, got a NULL object"); return FALSE; } return obj->use_flat_length; } /* Function: replace_length_RandomDNADB(obj,length) * * Descrip: Replace member variable length * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomDNADB *] * Arg: length [OWNER] New value of the variable [int] * * Return [SOFT ] member variable length [boolean] * */ boolean replace_length_RandomDNADB(RandomDNADB * obj,int length) { if( obj == NULL) { warn("In replacement function length for object RandomDNADB, got a NULL object"); return FALSE; } obj->length = length; return TRUE; } /* Function: access_length_RandomDNADB(obj) * * Descrip: Access member variable length * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomDNADB *] * * Return [SOFT ] member variable length [int] * */ int access_length_RandomDNADB(RandomDNADB * obj) { if( obj == NULL) { warn("In accessor function length for object RandomDNADB, got a NULL object"); return 0; } return obj->length; } /* Function: replace_length_dist_RandomDNADB(obj,length_dist) * * Descrip: Replace member variable length_dist * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomDNADB *] * Arg: length_dist [OWNER] New value of the variable [Histogram *] * * Return [SOFT ] member variable length_dist [boolean] * */ boolean replace_length_dist_RandomDNADB(RandomDNADB * obj,Histogram * length_dist) { if( obj == NULL) { warn("In replacement function length_dist for object RandomDNADB, got a NULL object"); return FALSE; } obj->length_dist = length_dist; return TRUE; } /* Function: access_length_dist_RandomDNADB(obj) * * Descrip: Access member variable length_dist * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomDNADB *] * * Return [SOFT ] member variable length_dist [Histogram *] * */ Histogram * access_length_dist_RandomDNADB(RandomDNADB * obj) { if( obj == NULL) { warn("In accessor function length_dist for object RandomDNADB, got a NULL object"); return NULL; } return obj->length_dist; } /* Function: replace_emission_RandomDNADB(obj,emission) * * Descrip: Replace member variable emission * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomDNADB *] * Arg: emission [OWNER] New value of the variable [RandomModelDNA *] * * Return [SOFT ] member variable emission [boolean] * */ boolean replace_emission_RandomDNADB(RandomDNADB * obj,RandomModelDNA * emission) { if( obj == NULL) { warn("In replacement function emission for object RandomDNADB, got a NULL object"); return FALSE; } obj->emission = emission; return TRUE; } /* Function: access_emission_RandomDNADB(obj) * * Descrip: Access member variable emission * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomDNADB *] * * Return [SOFT ] member variable emission [RandomModelDNA *] * */ RandomModelDNA * access_emission_RandomDNADB(RandomDNADB * obj) { if( obj == NULL) { warn("In accessor function emission for object RandomDNADB, got a NULL object"); return NULL; } return obj->emission; } /* Function: replace_num_RandomDNADB(obj,num) * * Descrip: Replace member variable num * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomDNADB *] * Arg: num [OWNER] New value of the variable [int] * * Return [SOFT ] member variable num [boolean] * */ boolean replace_num_RandomDNADB(RandomDNADB * obj,int num) { if( obj == NULL) { warn("In replacement function num for object RandomDNADB, got a NULL object"); return FALSE; } obj->num = num; return TRUE; } /* Function: access_num_RandomDNADB(obj) * * Descrip: Access member variable num * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomDNADB *] * * Return [SOFT ] member variable num [int] * */ int access_num_RandomDNADB(RandomDNADB * obj) { if( obj == NULL) { warn("In accessor function num for object RandomDNADB, got a NULL object"); return 0; } return obj->num; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/randomdb.h0000644000175000001440000002122110670453712016573 0ustar philippusers#ifndef DYNAMITErandomdbHEADERFILE #define DYNAMITErandomdbHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "histogram.h" #include "randommodel.h" struct Wise2_RandomProteinDB { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif boolean use_flat_length; int length; Histogram * length_dist; RandomModel * emission; int num; } ; /* RandomProteinDB defined */ #ifndef DYNAMITE_DEFINED_RandomProteinDB typedef struct Wise2_RandomProteinDB Wise2_RandomProteinDB; #define RandomProteinDB Wise2_RandomProteinDB #define DYNAMITE_DEFINED_RandomProteinDB #endif struct Wise2_RandomDNADB { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif boolean use_flat_length; int length; Histogram * length_dist; RandomModelDNA * emission; int num; } ; /* RandomDNADB defined */ #ifndef DYNAMITE_DEFINED_RandomDNADB typedef struct Wise2_RandomDNADB Wise2_RandomDNADB; #define RandomDNADB Wise2_RandomDNADB #define DYNAMITE_DEFINED_RandomDNADB #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: Sequence_from_RandomProteinDB(rndp) * * Descrip: Makes a new random sequence from a * RandomProteinDB * * * Arg: rndp [UNKN ] Undocumented argument [RandomProteinDB *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_Sequence_from_RandomProteinDB(RandomProteinDB * rndp); #define Sequence_from_RandomProteinDB Wise2_Sequence_from_RandomProteinDB /* Function: new_flat_RandomProteinDB(rm,length) * * Descrip: Makes a new flat RandomProteinDB * * * Arg: rm [SOFT ] RandomModel [RandomModel *] * Arg: length [UNKN ] length of protein to produce [int] * * Return [UNKN ] Undocumented return value [RandomProteinDB *] * */ RandomProteinDB * Wise2_new_flat_RandomProteinDB(RandomModel * rm,int length); #define new_flat_RandomProteinDB Wise2_new_flat_RandomProteinDB /* Function: Sequence_from_RandomDNADB(rndp) * * Descrip: Makes a new random sequence from a * RandomDNADB * * * Arg: rndp [UNKN ] Undocumented argument [RandomDNADB *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_Sequence_from_RandomDNADB(RandomDNADB * rndp); #define Sequence_from_RandomDNADB Wise2_Sequence_from_RandomDNADB /* Function: new_flat_RandomDNADB(rm,length) * * Descrip: Makes a new flat RandomDNADB * * * Arg: rm [SOFT ] RandomModel emission [RandomModelDNA *] * Arg: length [UNKN ] length of DNA to produce [int] * * Return [UNKN ] Undocumented return value [RandomDNADB *] * */ RandomDNADB * Wise2_new_flat_RandomDNADB(RandomModelDNA * rm,int length); #define new_flat_RandomDNADB Wise2_new_flat_RandomDNADB /* Function: hard_link_RandomProteinDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomProteinDB *] * * Return [UNKN ] Undocumented return value [RandomProteinDB *] * */ RandomProteinDB * Wise2_hard_link_RandomProteinDB(RandomProteinDB * obj); #define hard_link_RandomProteinDB Wise2_hard_link_RandomProteinDB /* Function: RandomProteinDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomProteinDB *] * */ RandomProteinDB * Wise2_RandomProteinDB_alloc(void); #define RandomProteinDB_alloc Wise2_RandomProteinDB_alloc /* Function: free_RandomProteinDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomProteinDB *] * * Return [UNKN ] Undocumented return value [RandomProteinDB *] * */ RandomProteinDB * Wise2_free_RandomProteinDB(RandomProteinDB * obj); #define free_RandomProteinDB Wise2_free_RandomProteinDB /* Function: hard_link_RandomDNADB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomDNADB *] * * Return [UNKN ] Undocumented return value [RandomDNADB *] * */ RandomDNADB * Wise2_hard_link_RandomDNADB(RandomDNADB * obj); #define hard_link_RandomDNADB Wise2_hard_link_RandomDNADB /* Function: RandomDNADB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomDNADB *] * */ RandomDNADB * Wise2_RandomDNADB_alloc(void); #define RandomDNADB_alloc Wise2_RandomDNADB_alloc /* Function: free_RandomDNADB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomDNADB *] * * Return [UNKN ] Undocumented return value [RandomDNADB *] * */ RandomDNADB * Wise2_free_RandomDNADB(RandomDNADB * obj); #define free_RandomDNADB Wise2_free_RandomDNADB /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_length_dist_RandomProteinDB(RandomProteinDB * obj,Histogram * length_dist); #define replace_length_dist_RandomProteinDB Wise2_replace_length_dist_RandomProteinDB boolean Wise2_replace_use_flat_length_RandomDNADB(RandomDNADB * obj,boolean use_flat_length); #define replace_use_flat_length_RandomDNADB Wise2_replace_use_flat_length_RandomDNADB boolean Wise2_access_use_flat_length_RandomProteinDB(RandomProteinDB * obj); #define access_use_flat_length_RandomProteinDB Wise2_access_use_flat_length_RandomProteinDB boolean Wise2_access_use_flat_length_RandomDNADB(RandomDNADB * obj); #define access_use_flat_length_RandomDNADB Wise2_access_use_flat_length_RandomDNADB int Wise2_access_length_RandomProteinDB(RandomProteinDB * obj); #define access_length_RandomProteinDB Wise2_access_length_RandomProteinDB boolean Wise2_replace_length_RandomDNADB(RandomDNADB * obj,int length); #define replace_length_RandomDNADB Wise2_replace_length_RandomDNADB Histogram * Wise2_access_length_dist_RandomProteinDB(RandomProteinDB * obj); #define access_length_dist_RandomProteinDB Wise2_access_length_dist_RandomProteinDB int Wise2_access_length_RandomDNADB(RandomDNADB * obj); #define access_length_RandomDNADB Wise2_access_length_RandomDNADB RandomModel * Wise2_access_emission_RandomProteinDB(RandomProteinDB * obj); #define access_emission_RandomProteinDB Wise2_access_emission_RandomProteinDB boolean Wise2_replace_length_dist_RandomDNADB(RandomDNADB * obj,Histogram * length_dist); #define replace_length_dist_RandomDNADB Wise2_replace_length_dist_RandomDNADB int Wise2_access_num_RandomProteinDB(RandomProteinDB * obj); #define access_num_RandomProteinDB Wise2_access_num_RandomProteinDB Histogram * Wise2_access_length_dist_RandomDNADB(RandomDNADB * obj); #define access_length_dist_RandomDNADB Wise2_access_length_dist_RandomDNADB boolean Wise2_replace_use_flat_length_RandomProteinDB(RandomProteinDB * obj,boolean use_flat_length); #define replace_use_flat_length_RandomProteinDB Wise2_replace_use_flat_length_RandomProteinDB boolean Wise2_replace_emission_RandomDNADB(RandomDNADB * obj,RandomModelDNA * emission); #define replace_emission_RandomDNADB Wise2_replace_emission_RandomDNADB boolean Wise2_replace_num_RandomProteinDB(RandomProteinDB * obj,int num); #define replace_num_RandomProteinDB Wise2_replace_num_RandomProteinDB RandomModelDNA * Wise2_access_emission_RandomDNADB(RandomDNADB * obj); #define access_emission_RandomDNADB Wise2_access_emission_RandomDNADB boolean Wise2_replace_emission_RandomProteinDB(RandomProteinDB * obj,RandomModel * emission); #define replace_emission_RandomProteinDB Wise2_replace_emission_RandomProteinDB boolean Wise2_replace_num_RandomDNADB(RandomDNADB * obj,int num); #define replace_num_RandomDNADB Wise2_replace_num_RandomDNADB boolean Wise2_replace_length_RandomProteinDB(RandomProteinDB * obj,int length); #define replace_length_RandomProteinDB Wise2_replace_length_RandomProteinDB int Wise2_access_num_RandomDNADB(RandomDNADB * obj); #define access_num_RandomDNADB Wise2_access_num_RandomDNADB #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/genomic.pod0000644000175000001440000002075710670453712016776 0ustar philippusers=head1 NAME genomic module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item Genomic =item GenomicRepeat =back =head1 DESCRIPTION =head2 Object Genomic =over =item baseseq Type [Sequence *] Scalar No documentation =item repeat Type [GenomicRepeat **] List No documentation =back No documentation for Genomic =head2 Member functions of Genomic =over =item truncate_Genomic &Wise2::Genomic::truncate_Genomic(gen,start,stop) Truncates a Genomic sequence. Basically uses the /magic_trunc_Sequence function (of course!) It does not alter gen, rather it returns a new sequence with that truncation Handles repeat information correctly. Argument gen [READ ] Genomic that is truncated [Genomic *] Argument start [UNKN ] Undocumented argument [int] Argument stop [UNKN ] Undocumented argument [int] Return [UNKN ] Undocumented return value [Genomic *] =item Genomic_name &Wise2::Genomic::Genomic_name(gen) Returns the name of the Genomic Argument gen [UNKN ] Undocumented argument [Genomic *] Return [UNKN ] Undocumented return value [char *] =item Genomic_length &Wise2::Genomic::Genomic_length(gen) Returns the length of the Genomic Argument gen [UNKN ] Undocumented argument [Genomic *] Return [UNKN ] Undocumented return value [int] =item Genomic_seqchar &Wise2::Genomic::Genomic_seqchar(gen,pos) Returns sequence character at this position. Argument gen [UNKN ] Genomic [Genomic *] Argument pos [UNKN ] position in Genomic to get char [int] Return [UNKN ] Undocumented return value [char] =item show &Wise2::Genomic::show(gen,ofp) For debugging Argument gen [UNKN ] Undocumented argument [Genomic *] Argument ofp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [void] =item hard_link_Genomic &Wise2::Genomic::hard_link_Genomic(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [Genomic *] Return [UNKN ] Undocumented return value [Genomic *] =item Genomic_alloc_std &Wise2::Genomic::Genomic_alloc_std(void) Equivalent to Genomic_alloc_len(GenomicLISTLENGTH) Return [UNKN ] Undocumented return value [Genomic *] =item set_baseseq &Wise2::Genomic::set_baseseq(obj,baseseq) Replace member variable baseseq For use principly by API functions Argument obj [UNKN ] Object holding the variable [Genomic *] Argument baseseq [OWNER] New value of the variable [Sequence *] Return [SOFT ] member variable baseseq [boolean] =item baseseq &Wise2::Genomic::baseseq(obj) Access member variable baseseq For use principly by API functions Argument obj [UNKN ] Object holding the variable [Genomic *] Return [SOFT ] member variable baseseq [Sequence *] =item repeat &Wise2::Genomic::repeat(obj,i) Access members stored in the repeat list For use principly by API functions Argument obj [UNKN ] Object holding the list [Genomic *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [GenomicRepeat *] =item length_repeat &Wise2::Genomic::length_repeat(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [Genomic *] Return [UNKN ] length of the list [int] =item flush_repeat &Wise2::Genomic::flush_repeat(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [Genomic *] Return [UNKN ] Undocumented return value [int] =item add_repeat &Wise2::Genomic::add_repeat(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [Genomic *] Argument add [OWNER] Object to add to the list [GenomicRepeat *] Return [UNKN ] Undocumented return value [boolean] =back =head2 Object GenomicRepeat =over =item start Type [int] Scalar No documentation =item end Type [int] Scalar No documentation =item type Type [char *] Scalar No documentation =back No documentation for GenomicRepeat =head2 Member functions of GenomicRepeat =over =item hard_link_GenomicRepeat &Wise2::GenomicRepeat::hard_link_GenomicRepeat(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [GenomicRepeat *] Return [UNKN ] Undocumented return value [GenomicRepeat *] =item alloc &Wise2::GenomicRepeat::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [GenomicRepeat *] =item set_start &Wise2::GenomicRepeat::set_start(obj,start) Replace member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicRepeat *] Argument start [OWNER] New value of the variable [int] Return [SOFT ] member variable start [boolean] =item start &Wise2::GenomicRepeat::start(obj) Access member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicRepeat *] Return [SOFT ] member variable start [int] =item set_end &Wise2::GenomicRepeat::set_end(obj,end) Replace member variable end For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicRepeat *] Argument end [OWNER] New value of the variable [int] Return [SOFT ] member variable end [boolean] =item end &Wise2::GenomicRepeat::end(obj) Access member variable end For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicRepeat *] Return [SOFT ] member variable end [int] =item set_type &Wise2::GenomicRepeat::set_type(obj,type) Replace member variable type For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicRepeat *] Argument type [OWNER] New value of the variable [char *] Return [SOFT ] member variable type [boolean] =item type &Wise2::GenomicRepeat::type(obj) Access member variable type For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicRepeat *] Return [SOFT ] member variable type [char *] =back =over =item read_fasta_file_Genomic &Wise2::read_fasta_file_Genomic(filename,length_of_N) Reads a fasta file assumming that it is Genomic. Will complain if it is not, and return NULL. Argument filename [UNKN ] filename to be opened and read [char *] Argument length_of_N [UNKN ] length of N to be considered repeat. -1 means none [int] Return [UNKN ] Undocumented return value [Genomic *] =item read_fasta_Genomic &Wise2::read_fasta_Genomic(ifp,length_of_N) Reads a fasta file assumming that it is Genomic. Will complain if it is not, and return NULL. Argument ifp [UNKN ] file point to be read from [FILE *] Argument length_of_N [UNKN ] length of N to be considered repeat. -1 means none [int] Return [UNKN ] Undocumented return value [Genomic *] =item Genomic_from_Sequence_Nheuristic &Wise2::Genomic_from_Sequence_Nheuristic(seq,length_of_N) makes a new genomic from a Sequence, but assummes that all the N runs greater than a certain level are actually repeats. Argument seq [UNKN ] Undocumented argument [Sequence *] Argument length_of_N [UNKN ] Undocumented argument [int] Return [UNKN ] Undocumented return value [Genomic *] =item Genomic_from_Sequence &Wise2::Genomic_from_Sequence(seq) makes a new genomic from a Sequence. It owns the Sequence memory, ie will attempt a /free_Sequence on the structure when /free_Genomic is called If you want to give this genomic this Sequence and forget about it, then just hand it this sequence and set seq to NULL (no need to free it). If you intend to use the sequence object elsewhere outside of the Genomic datastructure then use Genomic_from_Sequence(/hard_link_Sequence(seq)) This is part of a strict typing system, and therefore is going to convert all non ATGCNs to Ns. You will lose information here. Argument seq [OWNER] Sequence to make genomic from [Sequence *] Return [UNKN ] Undocumented return value [Genomic *] =back wise-2.4.1/src/dynlibsrc/genomic.tex0000644000175000001440000001414610670453712017007 0ustar philippusers\section{genomic} \label{module_genomic} This module contains the following objects \begin{itemize} \item \ref{object_Genomic} Genomic \item \ref{object_GenomicRepeat} GenomicRepeat \item This module also contains some factory methods \end{itemize} \subsection{genomic factory methods} \subsubsection{read_fasta_file_Genomic} \begin{description} \item[External C] {\tt Wise2_read_fasta_file_Genomic (filename,length_of_N)} \item[Perl] {\tt &Wise2::read_fasta_file_Genomic (filename,length_of_N)} \end{description} Arguments \begin{description} \item[filename] [UNKN ] filename to be opened and read [char *] \item[length_of_N] [UNKN ] length of N to be considered repeat. -1 means none [int] \item[returns] [UNKN ] Undocumented return value [Genomic *] \end{description} Reads a fasta file assumming that it is Genomic. Will complain if it is not, and return NULL. \subsubsection{read_fasta_Genomic} \begin{description} \item[External C] {\tt Wise2_read_fasta_Genomic (ifp,length_of_N)} \item[Perl] {\tt &Wise2::read_fasta_Genomic (ifp,length_of_N)} \end{description} Arguments \begin{description} \item[ifp] [UNKN ] file point to be read from [FILE *] \item[length_of_N] [UNKN ] length of N to be considered repeat. -1 means none [int] \item[returns] [UNKN ] Undocumented return value [Genomic *] \end{description} Reads a fasta file assumming that it is Genomic. Will complain if it is not, and return NULL. \subsubsection{Genomic_from_Sequence_Nheuristic} \begin{description} \item[External C] {\tt Wise2_Genomic_from_Sequence_Nheuristic (seq,length_of_N)} \item[Perl] {\tt &Wise2::Genomic_from_Sequence_Nheuristic (seq,length_of_N)} \end{description} Arguments \begin{description} \item[seq] [UNKN ] Undocumented argument [Sequence *] \item[length_of_N] [UNKN ] Undocumented argument [int] \item[returns] [UNKN ] Undocumented return value [Genomic *] \end{description} makes a new genomic from a Sequence, but assummes that all the N runs greater than a certain level are actually repeats. \subsubsection{Genomic_from_Sequence} \begin{description} \item[External C] {\tt Wise2_Genomic_from_Sequence (seq)} \item[Perl] {\tt &Wise2::Genomic_from_Sequence (seq)} \end{description} Arguments \begin{description} \item[seq] [OWNER] Sequence to make genomic from [Sequence *] \item[returns] [UNKN ] Undocumented return value [Genomic *] \end{description} makes a new genomic from a Sequence. It owns the Sequence memory, ie will attempt a /free_Sequence on the structure when /free_Genomic is called If you want to give this genomic this Sequence and forget about it, then just hand it this sequence and set seq to NULL (no need to free it). If you intend to use the sequence object elsewhere outside of the Genomic datastructure then use Genomic_from_Sequence(/hard_link_Sequence(seq)) This is part of a strict typing system, and therefore is going to convert all non ATGCNs to Ns. You will lose information here. \subsection{Object Genomic} \label{object_Genomic} The Genomic object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{baseseq} Type [Sequence * : Scalar] No documentation \item{repeat} Type [GenomicRepeat ** : List] No documentation \end{description} No documentation for Genomic Member functions of Genomic \subsubsection{truncate_Genomic} \begin{description} \item[External C] {\tt Wise2_truncate_Genomic (gen,start,stop)} \item[Perl] {\tt &Wise2::Genomic::truncate_Genomic (gen,start,stop)} \item[Perl-OOP call] {\tt $obj->truncate_Genomic(start,stop)} \end{description} Arguments \begin{description} \item[gen] [READ ] Genomic that is truncated [Genomic *] \item[start] [UNKN ] Undocumented argument [int] \item[stop] [UNKN ] Undocumented argument [int] \item[returns] [UNKN ] Undocumented return value [Genomic *] \end{description} Truncates a Genomic sequence. Basically uses the /magic_trunc_Sequence function (of course!) It does not alter gen, rather it returns a new sequence with that truncation Handles repeat information correctly. \subsubsection{Genomic_name} \begin{description} \item[External C] {\tt Wise2_Genomic_name (gen)} \item[Perl] {\tt &Wise2::Genomic::Genomic_name (gen)} \item[Perl-OOP call] {\tt $obj->Genomic_name()} \end{description} Arguments \begin{description} \item[gen] [UNKN ] Undocumented argument [Genomic *] \item[returns] [UNKN ] Undocumented return value [char *] \end{description} Returns the name of the Genomic \subsubsection{Genomic_length} \begin{description} \item[External C] {\tt Wise2_Genomic_length (gen)} \item[Perl] {\tt &Wise2::Genomic::Genomic_length (gen)} \item[Perl-OOP call] {\tt $obj->Genomic_length()} \end{description} Arguments \begin{description} \item[gen] [UNKN ] Undocumented argument [Genomic *] \item[returns] [UNKN ] Undocumented return value [int] \end{description} Returns the length of the Genomic \subsubsection{Genomic_seqchar} \begin{description} \item[External C] {\tt Wise2_Genomic_seqchar (gen,pos)} \item[Perl] {\tt &Wise2::Genomic::Genomic_seqchar (gen,pos)} \item[Perl-OOP call] {\tt $obj->Genomic_seqchar(pos)} \end{description} Arguments \begin{description} \item[gen] [UNKN ] Genomic [Genomic *] \item[pos] [UNKN ] position in Genomic to get char [int] \item[returns] [UNKN ] Undocumented return value [char] \end{description} Returns sequence character at this position. \subsubsection{show_Genomic} \begin{description} \item[External C] {\tt Wise2_show_Genomic (gen,ofp)} \item[Perl] {\tt &Wise2::Genomic::show (gen,ofp)} \item[Perl-OOP call] {\tt $obj->show(ofp)} \end{description} Arguments \begin{description} \item[gen] [UNKN ] Undocumented argument [Genomic *] \item[ofp] [UNKN ] Undocumented argument [FILE *] \item[returns] Nothing - no return value \end{description} For debugging \subsection{Object GenomicRepeat} \label{object_GenomicRepeat} The GenomicRepeat object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{start} Type [int : Scalar] No documentation \item{end} Type [int : Scalar] No documentation \item{type} Type [char * : Scalar] No documentation \end{description} No documentation for GenomicRepeat Member functions of GenomicRepeat wise-2.4.1/src/dynlibsrc/randomdb.typemap0000644000175000001440000000102010670453712020016 0ustar philippusers TYPEMAP Wise2_RandomProteinDB * T_Wise2_RandomProteinDB INPUT T_Wise2_RandomProteinDB $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_RandomProteinDB *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_RandomProteinDB sv_setref_pv($arg, "Wise2::RandomProteinDB", (void*) $var); TYPEMAP Wise2_RandomDNADB * T_Wise2_RandomDNADB INPUT T_Wise2_RandomDNADB $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_RandomDNADB *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_RandomDNADB sv_setref_pv($arg, "Wise2::RandomDNADB", (void*) $var); wise-2.4.1/src/dynlibsrc/hscore.dy0000644000175000001440000002637007313404541016463 0ustar philippusers %{ #include "wisebase.h" #include "histogram.h" #define HscoreLISTLENGTH 256 #define DATAENTRYSTDPOINTS 8 #define DATASCORESTORAGE_LENGTH 1024 typedef long BytePosition; %} struct DataEntry char * name // name of the entry int data[DATAENTRYSTDPOINTS] // space for algorithms to use boolean is_reversed !def="FALSE" // for sequences. handy BytePosition byte_position !hidden // useful for indexers - hopefully long enough! char * filename !hidden !link // useful for indexers etc. %info A lightweight structure to represent the information a db search algorithm will want to store and *nothing* more about a single entry This object will be stored twice (once for the target and once for the query) for each comparison: they probably will be on different databases and different objects. The data field is just a number (8 at the moment) of int's available for databases to store useful information (eg, length) of the object. A number of extra fields are provided for convience sake for indexers, including byte_position and filename. %% struct DataScore DataEntry * query DataEntry * target int score double evalue int is_stored !hidden %info The basic one entry vs one entry structure. Each of the DataEntry datastructures actually store the information about the indexing etc. %% struct DataScoreStorage DataScore score_array[DATASCORESTORAGE_LENGTH] DataEntry query_array[DATASCORESTORAGE_LENGTH] DataEntry target_array[DATASCORESTORAGE_LENGTH] int curr_pos !def="0" %info This object was needed because for very large searches the memory usage of allocation DataScore and DataEntry's on the heap was becoming prohibative. This datastructure holds pre-allocated DataScore and DataEntry objects read for use. A complicated constructor/deconstructor pair for DataScore objects ensures that these can be used cleanly. %% struct Hscore DataScore ** ds !list !hidden DataScoreStorage ** store !list !len="st_" !hidden Histogram * his double score_level // passed into should_store function boolean (*should_store)(int given_score,double internal_score_level) !func float (*score_to_his)(int given_score) !func int report_level // number of sequences to report on long total // total number of scores (duplicated info in histogram) %info Holds the information about a db search. Meant to be very lightweight The histogram is carried for on-the-fly histogram storage outside of the database. The idea is that the function should_store will tell whether the datascore structure should be stored (if it is NULL, it is always stored). The score_to_his function maps the score in datascore to the float in Histogram, allowing the scoring system of the search method to be on a different basis to the scoring system of the histogram. For most times, this is going to be Score2Bits To prevent too much dependency, the 'standard' way of making a histogram that has a bits cut off level is done using functions in the dynlibcross module (cross code), as it needs both Hscore and Probability. You should read dynlibcross module for the constructors for Hscore %% api object Hscore des free_Hscore func minimum_score_Hscore func maximum_score_Hscore func sort_Hscore_by_score func length_datascore_Hscore func get_datascore_Hscore func get_score_Hscore func get_evalue_Hscore func basic_show_Hscore endobject object DataScore des free_DataScore endobject object DataEntry des free_DataEntry endobject func std_score_Hscore endapi %{ #include "hscore.h" %func This gives you a standard Hscore module with a cutoff in score %% Hscore * std_score_Hscore(int cut_off,int report_stagger) { Hscore * out; out = Hscore_alloc_std(); out->his = new_Histogram(-1000,1000,100); out->score_level = cut_off; out->should_store = raw_should_store_Hscore; out->score_to_his = raw_score_to_his; out->report_level = report_stagger; return out; } %func This function is for the Hscore std constructor, %type internal %% boolean raw_should_store_Hscore(int score,double cutoff) { if( score > cutoff ) { return TRUE; } return FALSE; } %func This function is for the Hscore std constructor, %type internal %% float raw_score_to_his(int score) { return score; } %func Tells whether this score should be stored or not. Also updates Histogram if needed %% boolean should_store_Hscore(Hscore * hs,int score) { hs->total++; if( hs->report_level != -1 && (hs->total % hs->report_level == 0)) { if( hs->len > 0) { info("Done %d comparisons: last stored comparison was %s to %s",hs->total,hs->ds[hs->len-1]->query->name,hs->ds[hs->len-1]->target->name); } else { info("Done %d comparisons: No stored comparisons",hs->total); } } if( hs->his != NULL && hs->score_to_his != NULL ) { AddToHistogram(hs->his,(*hs->score_to_his)(score)); } if( hs->should_store == NULL ) { return TRUE; } return (*hs->should_store)(score,hs->score_level); } %func Returns the number of datascores in the hscore structure %simple length %arg obj r Hscore object %% int length_datascore_Hscore(Hscore * obj) { return obj->len; } %func Returns the specific datascore held at this position. This requires a considerable amount of memory duplication, so please dont process all your results by looping through this. %simple datascore %arg hs r Hscore object i position to be read return o New datascore object %% DataScore * get_datascore_Hscore(Hscore * hs,int i) { DataScore * out; out = new_DataScore(); copy_DataEntry(hs->ds[i]->query,out->query); copy_DataEntry(hs->ds[i]->target,out->target); out->score = hs->ds[i]->score; out->evalue = hs->ds[i]->evalue; return out; } %func Copies the info from one DataEntry to another %type internal %% void copy_DataEntry(DataEntry * from,DataEntry * to) { int i; to->name = stringalloc(from->name); for(i=0;idata[i] = from->data[i]; to->is_reversed = from->is_reversed; to->byte_position = from->byte_position; to->filename = from->filename; /* linked! */ } %func Returns the score of the specific datascore held at this position. %simple score %arg hs r Hscore object i position to be read return score %% int get_score_Hscore(Hscore * hs,int i) { return hs->ds[i]->score; } %func Returns the evalue of the specific datascore held at this position. %simple evalue %arg hs r Hscore object i position to be read return evalue %% double get_evalue_Hscore(Hscore * hs,int i) { return hs->ds[i]->evalue; } %func If a histogram is present, tries to fit the histogram and then gives evalues to all the scores in the Hscore model %% boolean fit_Hscore_to_EVD(Hscore * hs,float guess_of_outliers) { int i; if( hs->his == NULL ) { warn("Your Hscore has no histogram structure, and so no EVD can be fitted"); return FALSE; } if( ExtremeValueFitHistogram(hs->his,TRUE,guess_of_outliers) == 0 ) { warn("Extreme Value distribution is unable to be fitted. Sorry!"); return FALSE; } for(i=0;ilen;i++) { hs->ds[i]->evalue = ExtremeValueE((*hs->score_to_his)(hs->ds[i]->score),hs->his->param[EVD_MU],hs->his->param[EVD_LAMBDA],hs->his->total); } return TRUE; } %func gets the minimum score from Hscore %% int minimum_score_Hscore(Hscore * hs) { int i; int min; if( hs->len == 0) { warn("Can't get a minimum score with no entries"); return 0; } for(i=1,min=hs->ds[0]->score;ilen;i++) { if( min > hs->ds[i]->score ) { min = hs->ds[i]->score; } } return min; } %func gets the maximum score from Hscore %% int maximum_score_Hscore(Hscore * hs) { int i; int max; if( hs->len == 0) { warn("Can't get a minimum score with no entries"); return 0; } for(i=1,max=hs->ds[0]->score;ilen;i++) { if( max < hs->ds[i]->score ) { max = hs->ds[i]->score; } } return max; } %func The most baby-talk showing of Hscore %simple show %arg %% void basic_show_Hscore(Hscore * hs,FILE * ofp) { int i; if( hs == NULL ) { warn("parsing in a NULL Hscore object - cannot show!"); fprintf(ofp,"parsing in a NULL Hscore object - cannot show!"); } for(i=0;ilen;i++) { fprintf(ofp,"%3d Query: %12s Target: %12s Score %d\n",i, hs->ds[i]->query->name == NULL ? "NoName" : hs->ds[i]->query->name, hs->ds[i]->target->name == NULL ? "NoName" : hs->ds[i]->target->name, hs->ds[i]->score); } } %func As it says, sorts the high score by its score %arg hs Hscore to be sorted %% void sort_Hscore_by_score(Hscore * hs) { sort_Hscore(hs,compare_DataScore_by_score); } %func Used to compare two datascores for /sort_Hscore_by_score %type internal %arg %% int compare_DataScore_by_score(DataScore * one,DataScore * two) { if( one->score == two->score ) { if( one->query != NULL && one->query->name != NULL && two->query != NULL && two->query->name != NULL ) return strcmp(one->query->name,two->query->name); else return 1; } return two->score - one->score; } %func The best way to make a new DataScore. Allocates the query and target DataEntry structures as well as the DataScore structure. %type internal %arg %% DataScore * new_DataScore(void) { DataScore * ds; ds = DataScore_alloc(); ds->query = DataEntry_alloc(); ds->target = DataEntry_alloc(); return ds; } %func Gets a new DataScore from Storage %type internal %% DataScore * new_DataScore_from_storage(Hscore * hs) { DataScoreStorage * new; DataScoreStorage * curr; if( hs->st_len == 0 ) { new = new_DataScoreStorage(); if( new == NULL ) { warn("could not make inital data score storage!"); return NULL; } add_st_Hscore(hs,new); curr = new; } else { curr = hs->store[hs->st_len-1]; if( curr->curr_pos == DATASCORESTORAGE_LENGTH ) { new = new_DataScoreStorage(); if( new == NULL ) { warn("could not make data score storage block %d!",hs->st_len-1); return NULL; } add_st_Hscore(hs,new); curr = new; } } return &curr->score_array[curr->curr_pos++]; } %func Correctly handles destruction of a datascore %% !deconstructor DataScore * free_DataScore(DataScore * obj) { if( obj->is_stored == 1 ) { return NULL; /* don't free! */ } if( obj->dynamite_hard_link > 1 ) { obj->dynamite_hard_link--; return NULL; } if( obj->query != NULL ) free_DataEntry(obj->query); if( obj->target != NULL ) free_DataEntry(obj->target); return NULL; } %func Correctly handles destruction of DataScoreStorage, by freeing members in data storage %% !deconstructor DataScoreStorage * free_DataScoreStorage(DataScoreStorage * obj) { int i; for(i=0;icurr_pos;i++) { if( obj->query_array[i].name != NULL ) { ckfree(obj->query_array[i].name); } if( obj->target_array[i].name != NULL ) { ckfree(obj->target_array[i].name); } } ckfree(obj); return NULL; } %func Makes a new DataScoreStorage with all the pointers connected correctly %% DataScoreStorage * new_DataScoreStorage(void) { DataScoreStorage * out; int i; out = DataScoreStorage_alloc(); if( out == NULL ) { warn("Unable to make a new DataScoreStorage block with blocksize %d",DATASCORESTORAGE_LENGTH); return NULL; } for(i=0;iscore_array[i].query = &out->query_array[i]; out->score_array[i].target = &out->target_array[i]; out->score_array[i].is_stored = 1; } return out; } %} wise-2.4.1/src/dynlibsrc/hscore.xs0000644000175000001440000001074410670453712016503 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::Hscore int minimum_score_Hscore(hs) Wise2_Hscore * hs CODE: RETVAL = Wise2_minimum_score_Hscore(hs); OUTPUT: RETVAL int maximum_score_Hscore(hs) Wise2_Hscore * hs CODE: RETVAL = Wise2_maximum_score_Hscore(hs); OUTPUT: RETVAL void sort_Hscore_by_score(hs) Wise2_Hscore * hs CODE: Wise2_sort_Hscore_by_score(hs); int length(obj) Wise2_Hscore * obj CODE: RETVAL = Wise2_length_datascore_Hscore(obj); OUTPUT: RETVAL Wise2_DataScore * datascore(hs,i) Wise2_Hscore * hs int i CODE: RETVAL = Wise2_get_datascore_Hscore(hs,i); OUTPUT: RETVAL int score(hs,i) Wise2_Hscore * hs int i CODE: RETVAL = Wise2_get_score_Hscore(hs,i); OUTPUT: RETVAL double evalue(hs,i) Wise2_Hscore * hs int i CODE: RETVAL = Wise2_get_evalue_Hscore(hs,i); OUTPUT: RETVAL void show(hs,ofp) Wise2_Hscore * hs FILE * ofp CODE: Wise2_basic_show_Hscore(hs,ofp); Wise2_Hscore * hard_link_Hscore(obj) Wise2_Hscore * obj CODE: RETVAL = Wise2_hard_link_Hscore(obj); OUTPUT: RETVAL Wise2_Hscore * Hscore_alloc_std() CODE: RETVAL = Wise2_Hscore_alloc_std(); OUTPUT: RETVAL Wise2_Hscore * new(class) char * class PPCODE: Wise2_Hscore * out; out = Wise2_Hscore_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_Hscore * obj CODE: Wise2_free_Hscore(obj); MODULE = Wise2 PACKAGE = Wise2::DataScore Wise2_DataScore * hard_link_DataScore(obj) Wise2_DataScore * obj CODE: RETVAL = Wise2_hard_link_DataScore(obj); OUTPUT: RETVAL Wise2_DataScore * alloc() CODE: RETVAL = Wise2_DataScore_alloc(); OUTPUT: RETVAL boolean set_query(obj,query) Wise2_DataScore * obj Wise2_DataEntry * query CODE: RETVAL = Wise2_replace_query_DataScore(obj,Wise2_hard_link_DataEntry(query)); OUTPUT: RETVAL Wise2_DataEntry * query(obj) Wise2_DataScore * obj INIT: Wise2_DataEntry * temp; CODE: temp = Wise2_hard_link_DataEntry(Wise2_access_query_DataScore(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_target(obj,target) Wise2_DataScore * obj Wise2_DataEntry * target CODE: RETVAL = Wise2_replace_target_DataScore(obj,Wise2_hard_link_DataEntry(target)); OUTPUT: RETVAL Wise2_DataEntry * target(obj) Wise2_DataScore * obj INIT: Wise2_DataEntry * temp; CODE: temp = Wise2_hard_link_DataEntry(Wise2_access_target_DataScore(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_score(obj,score) Wise2_DataScore * obj int score CODE: RETVAL = Wise2_replace_score_DataScore(obj,score); OUTPUT: RETVAL int score(obj) Wise2_DataScore * obj CODE: RETVAL = Wise2_access_score_DataScore(obj); OUTPUT: RETVAL boolean set_evalue(obj,evalue) Wise2_DataScore * obj double evalue CODE: RETVAL = Wise2_replace_evalue_DataScore(obj,evalue); OUTPUT: RETVAL double evalue(obj) Wise2_DataScore * obj CODE: RETVAL = Wise2_access_evalue_DataScore(obj); OUTPUT: RETVAL Wise2_DataScore * new(class) char * class PPCODE: Wise2_DataScore * out; out = Wise2_DataScore_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_DataScore * obj CODE: Wise2_free_DataScore(obj); MODULE = Wise2 PACKAGE = Wise2::DataEntry Wise2_DataEntry * hard_link_DataEntry(obj) Wise2_DataEntry * obj CODE: RETVAL = Wise2_hard_link_DataEntry(obj); OUTPUT: RETVAL Wise2_DataEntry * alloc() CODE: RETVAL = Wise2_DataEntry_alloc(); OUTPUT: RETVAL boolean set_name(obj,name) Wise2_DataEntry * obj char * name CODE: RETVAL = Wise2_replace_name_DataEntry(obj,Wise2_stringalloc(name)); OUTPUT: RETVAL char * name(obj) Wise2_DataEntry * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_name_DataEntry(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_is_reversed(obj,is_reversed) Wise2_DataEntry * obj boolean is_reversed CODE: RETVAL = Wise2_replace_is_reversed_DataEntry(obj,is_reversed); OUTPUT: RETVAL boolean is_reversed(obj) Wise2_DataEntry * obj CODE: RETVAL = Wise2_access_is_reversed_DataEntry(obj); OUTPUT: RETVAL Wise2_DataEntry * new(class) char * class PPCODE: Wise2_DataEntry * out; out = Wise2_DataEntry_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_DataEntry * obj CODE: Wise2_free_DataEntry(obj); MODULE = Wise2 PACKAGE = Wise2 Wise2_Hscore * std_score_Hscore(cut_off,report_stagger) int cut_off int report_stagger CODE: RETVAL = Wise2_std_score_Hscore(cut_off,report_stagger); OUTPUT: RETVAL wise-2.4.1/src/dynlibsrc/randommodel.pod0000644000175000001440000000616110670453712017647 0ustar philippusers=head1 NAME randommodel module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item RandomModelDNA =item RandomModel =back =head1 DESCRIPTION =head2 Object RandomModelDNA =over =item base[5] Type [Probability] Scalar No documentation =item name Type [char *] Scalar No documentation =back No documentation for RandomModelDNA =head2 Member functions of RandomModelDNA =over =item hard_link_RandomModelDNA &Wise2::RandomModelDNA::hard_link_RandomModelDNA(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [RandomModelDNA *] Return [UNKN ] Undocumented return value [RandomModelDNA *] =item alloc &Wise2::RandomModelDNA::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [RandomModelDNA *] =item set_name &Wise2::RandomModelDNA::set_name(obj,name) Replace member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomModelDNA *] Argument name [OWNER] New value of the variable [char *] Return [SOFT ] member variable name [boolean] =item name &Wise2::RandomModelDNA::name(obj) Access member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomModelDNA *] Return [SOFT ] member variable name [char *] =back =head2 Object RandomModel =over =item aminoacid[26] Type [Probability] Scalar No documentation =item name Type [char *] Scalar No documentation =back No documentation for RandomModel =head2 Member functions of RandomModel =over =item hard_link_RandomModel &Wise2::RandomModel::hard_link_RandomModel(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [RandomModel *] Return [UNKN ] Undocumented return value [RandomModel *] =item alloc &Wise2::RandomModel::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [RandomModel *] =item set_name &Wise2::RandomModel::set_name(obj,name) Replace member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomModel *] Argument name [OWNER] New value of the variable [char *] Return [SOFT ] member variable name [boolean] =item name &Wise2::RandomModel::name(obj) Access member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomModel *] Return [SOFT ] member variable name [char *] =back =over =item RandomModelDNA_std &Wise2::RandomModelDNA_std(void) Returns a structure with 0.25 set in each place Return [UNKN ] Undocumented return value [RandomModelDNA *] =item default_RandomModel &Wise2::default_RandomModel(void) Gives a default random model numbers from swissprot34- via the HMMEr1 package Return [UNKN ] Undocumented return value [RandomModel *] =back wise-2.4.1/src/dynlibsrc/randommodel.tex0000644000175000001440000000344210670453712017664 0ustar philippusers\section{randommodel} \label{module_randommodel} This module contains the following objects \begin{itemize} \item \ref{object_RandomModelDNA} RandomModelDNA \item \ref{object_RandomModel} RandomModel \item This module also contains some factory methods \end{itemize} \subsection{randommodel factory methods} \subsubsection{RandomModelDNA_std} \begin{description} \item[External C] {\tt Wise2_RandomModelDNA_std (void)} \item[Perl] {\tt &Wise2::RandomModelDNA_std ()} \end{description} Arguments \begin{description} \item[returns] [UNKN ] Undocumented return value [RandomModelDNA *] \end{description} Returns a structure with 0.25 set in each place \subsubsection{default_RandomModel} \begin{description} \item[External C] {\tt Wise2_default_RandomModel (void)} \item[Perl] {\tt &Wise2::default_RandomModel ()} \end{description} Arguments \begin{description} \item[returns] [UNKN ] Undocumented return value [RandomModel *] \end{description} Gives a default random model numbers from swissprot34- via the HMMEr1 package \subsection{Object RandomModelDNA} \label{object_RandomModelDNA} The RandomModelDNA object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{base[5]} Type [Probability : Scalar] No documentation \item{name} Type [char * : Scalar] No documentation \end{description} No documentation for RandomModelDNA Member functions of RandomModelDNA \subsection{Object RandomModel} \label{object_RandomModel} The RandomModel object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{aminoacid[26]} Type [Probability : Scalar] No documentation \item{name} Type [char * : Scalar] No documentation \end{description} No documentation for RandomModel Member functions of RandomModel wise-2.4.1/src/dynlibsrc/shadowseq.c0000644000175000001440000003452710670453713017014 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "shadowseq.h" /* Function: dump_ShadowSequence(shadow,ofp) * * Descrip: Dumps shadow sequence out to file * * * Arg: shadow [UNKN ] Undocumented argument [ShadowSequence *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 31 "shadowseq.dy" void dump_ShadowSequence(ShadowSequence * shadow,FILE * ofp) { int i; assert(shadow); assert(ofp); fprintf(ofp,"Sequence %s %d\n",shadow->seq->name,shadow->seq->len); for(i=0;ilen;i++) { fprintf(ofp," Shadow %s %d,%d %d\n", shadow->region[i]->seq->name, shadow->region[i]->start_shadow, shadow->region[i]->start_seq, shadow->region[i]->len); } } /* Function: add_if_possible_ShadowSequence(shadow,seq,min_extension,start_shadow,start_seq,shadow_rate) * * Descrip: Looks as to whether there is a good extension to be made, if * so, does it and adds it to the ShadowSeq. Returns 0 if extension * fails, if succeeds returns end point * * * Arg: shadow [UNKN ] Undocumented argument [ShadowSequence *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: min_extension [UNKN ] Undocumented argument [int] * Arg: start_shadow [UNKN ] Undocumented argument [int] * Arg: start_seq [UNKN ] Undocumented argument [int] * Arg: shadow_rate [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ # line 54 "shadowseq.dy" int add_if_possible_ShadowSequence(ShadowSequence * shadow,Sequence * seq,int min_extension,int start_shadow,int start_seq,int shadow_rate) { int i; int j; int error = 0; assert(shadow); assert(seq); for(i=start_shadow,j=start_seq;iseq->len && jlen;i++,j++) { if( shadow->seq->seq[i] != seq->seq[j] ) { error++; if( i > start_shadow && error > (int)((shadow_rate*100)/(start_shadow-i)) ) break; } } if( i - start_shadow < min_extension ) { return 0; } /* we have a region */ add_region_ShadowSequence(shadow,seq,start_shadow,start_seq,i-start_shadow); return j; } /* Function: add_region_ShadowSequence(shadow,seq,start_shadow,start_seq,len) * * Descrip: Adds a region to a ShadowSequence, extending * the array if necessary * * * Arg: shadow [UNKN ] Undocumented argument [ShadowSequence *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: start_shadow [UNKN ] Undocumented argument [int] * Arg: start_seq [UNKN ] Undocumented argument [int] * Arg: len [UNKN ] Undocumented argument [int] * */ # line 87 "shadowseq.dy" void add_region_ShadowSequence(ShadowSequence * shadow,Sequence * seq,int start_shadow,int start_seq,int len) { ShadowSeqRegion * ssr; assert(shadow); assert(seq); ssr = ShadowSeqRegion_alloc(); ssr->seq = seq; ssr->start_shadow = start_shadow; ssr->start_seq = start_seq; ssr->len = len; if( shadow->region == NULL ) { if((shadow->region = (ShadowSeqRegion ** ) ckcalloc (ShadowSequenceLISTLENGTH,sizeof(ShadowSeqRegion *))) == NULL) { warn("Warning, ckcalloc failed in ShadowSequence_alloc_len"); return; } shadow->len = 0; shadow->maxlen = ShadowSequenceLISTLENGTH; } add_ShadowSequence(shadow,ssr); return; } /* Function: new_ShadowSequence(seq) * * Descrip: Builds a new ShadowSequence from a Sequence * doesnt hard link as memory should be handled * outside of the shadowsystem * * * Arg: seq [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [ShadowSequence *] * */ # line 123 "shadowseq.dy" ShadowSequence * new_ShadowSequence(Sequence * seq) { ShadowSequence * out; assert(seq); out = ShadowSequence_alloc(); assert(out); out->seq = seq; out->region = NULL; out->dirty = 0; return out; } # line 148 "shadowseq.c" /* Function: hard_link_ShadowSeqRegion(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShadowSeqRegion *] * * Return [UNKN ] Undocumented return value [ShadowSeqRegion *] * */ ShadowSeqRegion * hard_link_ShadowSeqRegion(ShadowSeqRegion * obj) { if( obj == NULL ) { warn("Trying to hard link to a ShadowSeqRegion object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ShadowSeqRegion_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShadowSeqRegion *] * */ ShadowSeqRegion * ShadowSeqRegion_alloc(void) { ShadowSeqRegion * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ShadowSeqRegion *) ckalloc (sizeof(ShadowSeqRegion))) == NULL) { warn("ShadowSeqRegion_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start_shadow = 0; out->start_seq = 0; out->len = 0; out->seq = NULL; return out; } /* Function: free_ShadowSeqRegion(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShadowSeqRegion *] * * Return [UNKN ] Undocumented return value [ShadowSeqRegion *] * */ ShadowSeqRegion * free_ShadowSeqRegion(ShadowSeqRegion * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ShadowSeqRegion obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->seq != NULL) free_Sequence(obj->seq); ckfree(obj); return NULL; } /* Function: swap_ShadowSequence(list,i,j) * * Descrip: swap function: an internal for qsort_ShadowSequence * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ShadowSeqRegion **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ShadowSequence(ShadowSeqRegion ** list,int i,int j) { ShadowSeqRegion * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ShadowSequence(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ShadowSequence which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ShadowSeqRegion **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ShadowSequence(ShadowSeqRegion ** list,int left,int right,int (*comp)(ShadowSeqRegion * ,ShadowSeqRegion * )) { int i,last; if( left >= right ) return; swap_ShadowSequence(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ShadowSequence (list,++last,i); } swap_ShadowSequence (list,left,last); qsort_ShadowSequence(list,left,last-1,comp); qsort_ShadowSequence(list,last+1,right,comp); } /* Function: sort_ShadowSequence(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ShadowSequence * * * Arg: obj [UNKN ] Object containing list [ShadowSequence *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ShadowSequence(ShadowSequence * obj,int (*comp)(ShadowSeqRegion *, ShadowSeqRegion *)) { qsort_ShadowSequence(obj->region,0,obj->len-1,comp); return; } /* Function: expand_ShadowSequence(obj,len) * * Descrip: Really an internal function for add_ShadowSequence * * * Arg: obj [UNKN ] Object which contains the list [ShadowSequence *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ShadowSequence(ShadowSequence * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_ShadowSequence called with no need"); return TRUE; } if( (obj->region = (ShadowSeqRegion ** ) ckrealloc (obj->region,sizeof(ShadowSeqRegion *)*len)) == NULL) { warn("ckrealloc failed for expand_ShadowSequence, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_ShadowSequence(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ShadowSequence *] * Arg: add [OWNER] Object to add to the list [ShadowSeqRegion *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ShadowSequence(ShadowSequence * obj,ShadowSeqRegion * add) { if( obj->len >= obj->maxlen) { if( expand_ShadowSequence(obj,obj->len + ShadowSequenceLISTLENGTH) == FALSE) return FALSE; } obj->region[obj->len++]=add; return TRUE; } /* Function: flush_ShadowSequence(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ShadowSequence *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ShadowSequence(ShadowSequence * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->region[i] != NULL) { free_ShadowSeqRegion(obj->region[i]); obj->region[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: ShadowSequence_alloc_std(void) * * Descrip: Equivalent to ShadowSequence_alloc_len(ShadowSequenceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ShadowSequence *] * */ ShadowSequence * ShadowSequence_alloc_std(void) { return ShadowSequence_alloc_len(ShadowSequenceLISTLENGTH); } /* Function: ShadowSequence_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ShadowSequence *] * */ ShadowSequence * ShadowSequence_alloc_len(int len) { ShadowSequence * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = ShadowSequence_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->region = (ShadowSeqRegion ** ) ckcalloc (len,sizeof(ShadowSeqRegion *))) == NULL) { warn("Warning, ckcalloc failed in ShadowSequence_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_ShadowSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShadowSequence *] * * Return [UNKN ] Undocumented return value [ShadowSequence *] * */ ShadowSequence * hard_link_ShadowSequence(ShadowSequence * obj) { if( obj == NULL ) { warn("Trying to hard link to a ShadowSequence object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ShadowSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShadowSequence *] * */ ShadowSequence * ShadowSequence_alloc(void) { ShadowSequence * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ShadowSequence *) ckalloc (sizeof(ShadowSequence))) == NULL) { warn("ShadowSequence_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->dirty = 'u'; out->region = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_ShadowSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShadowSequence *] * * Return [UNKN ] Undocumented return value [ShadowSequence *] * */ ShadowSequence * free_ShadowSequence(ShadowSequence * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ShadowSequence obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->seq is linked in */ if( obj->region != NULL) { for(i=0;ilen;i++) { if( obj->region[i] != NULL) free_ShadowSeqRegion(obj->region[i]); } ckfree(obj->region); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/shadowseq.h0000644000175000001440000002145610670453713017016 0ustar philippusers#ifndef DYNAMITEshadowseqHEADERFILE #define DYNAMITEshadowseqHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #define SHADOW_SEQUENCE_REGION_BASIC 4 #define ShadowSequenceLISTLENGTH 8 struct Wise2_ShadowSeqRegion { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start_shadow; int start_seq; int len; Sequence * seq; } ; /* ShadowSeqRegion defined */ #ifndef DYNAMITE_DEFINED_ShadowSeqRegion typedef struct Wise2_ShadowSeqRegion Wise2_ShadowSeqRegion; #define ShadowSeqRegion Wise2_ShadowSeqRegion #define DYNAMITE_DEFINED_ShadowSeqRegion #endif struct Wise2_ShadowSequence { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence * seq; char dirty; ShadowSeqRegion ** region; int len;/* len for above region */ int maxlen; /* maxlen for above region */ } ; /* ShadowSequence defined */ #ifndef DYNAMITE_DEFINED_ShadowSequence typedef struct Wise2_ShadowSequence Wise2_ShadowSequence; #define ShadowSequence Wise2_ShadowSequence #define DYNAMITE_DEFINED_ShadowSequence #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: dump_ShadowSequence(shadow,ofp) * * Descrip: Dumps shadow sequence out to file * * * Arg: shadow [UNKN ] Undocumented argument [ShadowSequence *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_dump_ShadowSequence(ShadowSequence * shadow,FILE * ofp); #define dump_ShadowSequence Wise2_dump_ShadowSequence /* Function: add_if_possible_ShadowSequence(shadow,seq,min_extension,start_shadow,start_seq,shadow_rate) * * Descrip: Looks as to whether there is a good extension to be made, if * so, does it and adds it to the ShadowSeq. Returns 0 if extension * fails, if succeeds returns end point * * * Arg: shadow [UNKN ] Undocumented argument [ShadowSequence *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: min_extension [UNKN ] Undocumented argument [int] * Arg: start_shadow [UNKN ] Undocumented argument [int] * Arg: start_seq [UNKN ] Undocumented argument [int] * Arg: shadow_rate [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_add_if_possible_ShadowSequence(ShadowSequence * shadow,Sequence * seq,int min_extension,int start_shadow,int start_seq,int shadow_rate); #define add_if_possible_ShadowSequence Wise2_add_if_possible_ShadowSequence /* Function: add_region_ShadowSequence(shadow,seq,start_shadow,start_seq,len) * * Descrip: Adds a region to a ShadowSequence, extending * the array if necessary * * * Arg: shadow [UNKN ] Undocumented argument [ShadowSequence *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: start_shadow [UNKN ] Undocumented argument [int] * Arg: start_seq [UNKN ] Undocumented argument [int] * Arg: len [UNKN ] Undocumented argument [int] * */ void Wise2_add_region_ShadowSequence(ShadowSequence * shadow,Sequence * seq,int start_shadow,int start_seq,int len); #define add_region_ShadowSequence Wise2_add_region_ShadowSequence /* Function: new_ShadowSequence(seq) * * Descrip: Builds a new ShadowSequence from a Sequence * doesnt hard link as memory should be handled * outside of the shadowsystem * * * Arg: seq [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [ShadowSequence *] * */ ShadowSequence * Wise2_new_ShadowSequence(Sequence * seq); #define new_ShadowSequence Wise2_new_ShadowSequence /* Function: hard_link_ShadowSeqRegion(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShadowSeqRegion *] * * Return [UNKN ] Undocumented return value [ShadowSeqRegion *] * */ ShadowSeqRegion * Wise2_hard_link_ShadowSeqRegion(ShadowSeqRegion * obj); #define hard_link_ShadowSeqRegion Wise2_hard_link_ShadowSeqRegion /* Function: ShadowSeqRegion_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShadowSeqRegion *] * */ ShadowSeqRegion * Wise2_ShadowSeqRegion_alloc(void); #define ShadowSeqRegion_alloc Wise2_ShadowSeqRegion_alloc /* Function: free_ShadowSeqRegion(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShadowSeqRegion *] * * Return [UNKN ] Undocumented return value [ShadowSeqRegion *] * */ ShadowSeqRegion * Wise2_free_ShadowSeqRegion(ShadowSeqRegion * obj); #define free_ShadowSeqRegion Wise2_free_ShadowSeqRegion /* Function: add_ShadowSequence(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ShadowSequence *] * Arg: add [OWNER] Object to add to the list [ShadowSeqRegion *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_ShadowSequence(ShadowSequence * obj,ShadowSeqRegion * add); #define add_ShadowSequence Wise2_add_ShadowSequence /* Function: flush_ShadowSequence(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ShadowSequence *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_ShadowSequence(ShadowSequence * obj); #define flush_ShadowSequence Wise2_flush_ShadowSequence /* Function: ShadowSequence_alloc_std(void) * * Descrip: Equivalent to ShadowSequence_alloc_len(ShadowSequenceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ShadowSequence *] * */ ShadowSequence * Wise2_ShadowSequence_alloc_std(void); #define ShadowSequence_alloc_std Wise2_ShadowSequence_alloc_std /* Function: ShadowSequence_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ShadowSequence *] * */ ShadowSequence * Wise2_ShadowSequence_alloc_len(int len); #define ShadowSequence_alloc_len Wise2_ShadowSequence_alloc_len /* Function: hard_link_ShadowSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShadowSequence *] * * Return [UNKN ] Undocumented return value [ShadowSequence *] * */ ShadowSequence * Wise2_hard_link_ShadowSequence(ShadowSequence * obj); #define hard_link_ShadowSequence Wise2_hard_link_ShadowSequence /* Function: ShadowSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShadowSequence *] * */ ShadowSequence * Wise2_ShadowSequence_alloc(void); #define ShadowSequence_alloc Wise2_ShadowSequence_alloc /* Function: free_ShadowSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShadowSequence *] * * Return [UNKN ] Undocumented return value [ShadowSequence *] * */ ShadowSequence * Wise2_free_ShadowSequence(ShadowSequence * obj); #define free_ShadowSequence Wise2_free_ShadowSequence /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_ShadowSequence(ShadowSeqRegion ** list,int i,int j) ; #define swap_ShadowSequence Wise2_swap_ShadowSequence void Wise2_qsort_ShadowSequence(ShadowSeqRegion ** list,int left,int right,int (*comp)(ShadowSeqRegion * ,ShadowSeqRegion * )); #define qsort_ShadowSequence Wise2_qsort_ShadowSequence void Wise2_sort_ShadowSequence(ShadowSequence * obj,int (*comp)(ShadowSeqRegion *, ShadowSeqRegion *)); #define sort_ShadowSequence Wise2_sort_ShadowSequence boolean Wise2_expand_ShadowSequence(ShadowSequence * obj,int len); #define expand_ShadowSequence Wise2_expand_ShadowSequence #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/genomicdb.c0000644000175000001440000005475610670453712016752 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genomicdb.h" /* Function: show_Hscore_GenomicDB(hs,ofp) * * Descrip: shows the Hscore by the GenomicDB information * * * * Arg: hs [UNKN ] High Score structure [Hscore *] * Arg: ofp [UNKN ] output file [FILE *] * */ # line 76 "genomicdb.dy" void show_Hscore_GenomicDB(Hscore * hs,FILE * ofp) { int i; for(i=0;ilen;i++) fprintf(ofp,"Query [%20s] Target [%20s] %d\n",hs->ds[i]->query->name,hs->ds[i]->target->name,hs->ds[i]->score); } /* Function: get_Genomic_from_GenomicDB(gendb,de) * * Descrip: Gets Genomic sequence out from * the GenomicDB using the information stored in * dataentry * * * Arg: gendb [UNKN ] Undocumented argument [GenomicDB *] * Arg: de [UNKN ] Undocumented argument [DataEntry *] * * Return [UNKN ] Undocumented return value [Genomic *] * */ # line 89 "genomicdb.dy" Genomic * get_Genomic_from_GenomicDB(GenomicDB * gendb,DataEntry * de) { Sequence * seq; Sequence * temp; /* we need to get out the Sequence from seqdb */ if( gendb == NULL || de == NULL ) { warn("Cannot get a genomic sequence from NULL objects. Ugh!"); return NULL; } if( gendb->is_single_seq) { if( de->is_reversed == TRUE ) return hard_link_Genomic(gendb->revsingle); else return hard_link_Genomic(gendb->single); } seq = get_Sequence_from_SequenceDB(gendb->sdb,de); if( seq == NULL ) { warn("Cannot get entry for %s from Genomic db",de->name); } /* check dna status. We assumme someone knows what he is doing when he makes a genomic db!*/ if( seq->type != SEQUENCE_DNA) { warn("Sequence from %s data entry doesn't look like DNA. Forcing it to",de->name); } force_to_dna_Sequence(seq,1.0,NULL); if( de->is_reversed == TRUE ) { temp = reverse_complement_Sequence(seq); free_Sequence(seq); seq = temp; } return Genomic_from_Sequence_Nheuristic(seq,gendb->length_of_N); } /* Function: dataentry_add_GenomicDB(de,cs,gendb) * * Descrip: adds information to dataentry from GenomicDB * * will eventually add file offset and format information * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: cs [UNKN ] Undocumented argument [ComplexSequence *] * Arg: gendb [UNKN ] Undocumented argument [GenomicDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 138 "genomicdb.dy" boolean dataentry_add_GenomicDB(DataEntry * de,ComplexSequence * cs,GenomicDB * gendb) { de->name = stringalloc(cs->seq->name); de->is_reversed = is_reversed_Sequence(cs->seq); if( gendb->is_single_seq ) { return TRUE; } add_SequenceDB_info_DataEntry(gendb->sdb,de); return TRUE; } /* Function: init_GenomicDB(gendb,return_status) * * Descrip: top level function which opens the Genomic database * * * Arg: gendb [UNKN ] protein database [GenomicDB *] * Arg: return_status [WRITE] the status of the open from database.h [int *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ # line 158 "genomicdb.dy" ComplexSequence * init_GenomicDB(GenomicDB * gendb,int * return_status) { ComplexSequence * cs; Sequence * seq; if( gendb->is_single_seq == TRUE) { *return_status = DB_RETURN_OK; gendb->done_forward = TRUE; return hard_link_ComplexSequence(gendb->forw); } /* is a seq db */ seq = init_SequenceDB(gendb->sdb,return_status); if( seq == NULL || *return_status == DB_RETURN_ERROR || *return_status == DB_RETURN_END ) { warn("On initiation of the genomicdb, immedaitely got an end scenario"); return NULL; } /* check dna status. We assumme someone knows what he is doing when he makes a genomic db!*/ if( seq->type != SEQUENCE_DNA) { warn("Sequence from %s data entry doesn't look like DNA. Forcing it to",seq->name); } force_to_dna_Sequence(seq,1.0,NULL); /* map to Genomic on length of N buiness */ gendb->current = Genomic_from_Sequence_Nheuristic(seq,gendb->length_of_N); gendb->done_forward = TRUE; cs = evaluate_ComplexSequence_Genomic(gendb->current,gendb->cses,0,gendb->repeat_in_cds_score); if( cs == NULL ) { warn("Cannot make initial ComplexSequence. Unable to error catch this. Failing!"); *return_status = DB_RETURN_ERROR; return NULL; } return cs; } /* Function: reload_GenomicDB(last,gendb,return_status) * * Descrip: function which reloads the database * * * Arg: last [UNKN ] previous complex sequence, will be freed [ComplexSequence *] * Arg: gendb [UNKN ] Undocumented argument [GenomicDB *] * Arg: return_status [WRITE] return_status of the load [int *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ # line 206 "genomicdb.dy" ComplexSequence * reload_GenomicDB(ComplexSequence * last,GenomicDB * gendb,int * return_status) { ComplexSequence * cs; Sequence * seq; Genomic *temp; Genomic * gen; /** NB - notice that we don't do silly things with free's. Maybe we should **/ if( gendb->is_single_seq == TRUE ) { if( gendb->done_forward == TRUE ) { *return_status = DB_RETURN_OK; gendb->done_forward = FALSE; return hard_link_ComplexSequence(gendb->rev); } else { *return_status = DB_RETURN_END; return NULL; } } /** standard database **/ /** free Complex Sequence **/ if ( last != NULL ) { free_ComplexSequence(last); } if( gendb->done_forward == TRUE ) { if( gendb->current == NULL ) { warn("A bad internal genomic db error - unable to find current sequence in db reload"); *return_status = DB_RETURN_ERROR; return NULL; } temp = reverse_complement_Genomic(gendb->current); if( temp == NULL ) { warn("A bad internal genomic db error - unable to reverse complements current"); *return_status = DB_RETURN_ERROR; return NULL; } cs = evaluate_ComplexSequence_Genomic(temp,gendb->cses,0,gendb->repeat_in_cds_score); if( cs == NULL ) { warn("A bad internal genomic db error - unable to make complex sequence in db reload"); *return_status = DB_RETURN_ERROR; return NULL; } free_Genomic(temp); gendb->done_forward = FALSE; return cs; } /* otherwise we have to get a new sequence */ seq = reload_SequenceDB(NULL,gendb->sdb,return_status); if( seq == NULL || *return_status == DB_RETURN_ERROR || *return_status == DB_RETURN_END ) { return NULL; /** error already reported **/ } uppercase_Sequence(seq); /* check dna status. We assumme someone knows what he is doing when he makes a genomic db!*/ if( seq->type != SEQUENCE_DNA) { warn("Sequence from %s data entry doesn't look like DNA. Forcing it to",seq->name); } force_to_dna_Sequence(seq,1.0,NULL); if( force_to_dna_Sequence(seq,0.1,NULL) == FALSE ) { if( gendb->error_handling == GENDB_READ_THROUGH ) { warn("Unable to map %s sequence to a genomic sequence, but ignoring that for the moment...",seq->name); free_Sequence(seq); return reload_GenomicDB(NULL,gendb,return_status); } else { warn("Unable to map %s sequence to a genomic sequence. Failing",seq->name); *return_status = DB_RETURN_ERROR; return NULL; } } gen = Genomic_from_Sequence_Nheuristic(seq,gendb->length_of_N); cs = evaluate_ComplexSequence_Genomic(gen,gendb->cses,0,gendb->repeat_in_cds_score); if( cs == NULL ) { if( gendb->error_handling == GENDB_READ_THROUGH ) { warn("Unable to map %s sequence to a genomic sequence, but ignoring that for the moment...",seq->name); free_Sequence(seq); return reload_GenomicDB(NULL,gendb,return_status); } else { warn("Unable to map %s sequence to a genomic sequence. Failing",seq->name); *return_status = DB_RETURN_ERROR; return NULL; } } gendb->current = free_Genomic(gendb->current); gendb->current = gen; gendb->done_forward= TRUE; return cs; } /* Function: close_GenomicDB(cs,gendb) * * Descrip: top level function which closes the genomic database * * * Arg: cs [UNKN ] last complex sequence [ComplexSequence *] * Arg: gendb [UNKN ] protein database [GenomicDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 325 "genomicdb.dy" boolean close_GenomicDB(ComplexSequence * cs,GenomicDB * gendb) { if( gendb->is_single_seq == TRUE ) { return TRUE; } if( cs != NULL) free_ComplexSequence(cs); if( gendb->current != NULL) gendb->current = free_Genomic(gendb->current); return close_SequenceDB(NULL,gendb->sdb); } /* Function: new_GenomicDB_from_single_seq(gen,cses,score_in_repeat_coding) * * Descrip: To make a new genomic database * from a single Genomic Sequence with a eval system * * * Arg: gen [UNKN ] sequence which as placed into GenomicDB structure. [Genomic *] * Arg: cses [UNKN ] Undocumented argument [ComplexSequenceEvalSet *] * Arg: score_in_repeat_coding [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [GenomicDB *] * */ # line 346 "genomicdb.dy" GenomicDB * new_GenomicDB_from_single_seq(Genomic * gen,ComplexSequenceEvalSet * cses,int score_in_repeat_coding) { ComplexSequence * cs,*cs_rev; GenomicDB * out; Genomic * temp; cs = evaluate_ComplexSequence_Genomic(gen,cses,0,score_in_repeat_coding); temp = reverse_complement_Genomic(gen); cs_rev = evaluate_ComplexSequence_Genomic(temp,cses,0,score_in_repeat_coding); out = new_GenomicDB_from_forrev_cseq(cs,cs_rev); out->single = hard_link_Genomic(gen); out->revsingle = temp; return out; } /* Function: new_GenomicDB_from_forrev_cseq(cs,cs_rev) * * Descrip: To make a new genomic database * from a single ComplexSequence * * * Arg: cs [UNKN ] complex sequence which is held. [ComplexSequence *] * Arg: cs_rev [UNKN ] Undocumented argument [ComplexSequence *] * * Return [UNKN ] Undocumented return value [GenomicDB *] * */ # line 370 "genomicdb.dy" GenomicDB * new_GenomicDB_from_forrev_cseq(ComplexSequence * cs,ComplexSequence * cs_rev) { GenomicDB * out; out = GenomicDB_alloc(); out->is_single_seq = TRUE; out->forw = cs; out->rev = cs_rev; return out; } /* Function: new_GenomicDB(seqdb,cses,length_of_N,repeat_in_cds_score) * * Descrip: To make a new genomic database * * * Arg: seqdb [UNKN ] sequence database [SequenceDB *] * Arg: cses [UNKN ] protein evaluation set [ComplexSequenceEvalSet *] * Arg: length_of_N [UNKN ] Undocumented argument [int] * Arg: repeat_in_cds_score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [GenomicDB *] * */ # line 391 "genomicdb.dy" GenomicDB * new_GenomicDB(SequenceDB * seqdb,ComplexSequenceEvalSet * cses,int length_of_N,int repeat_in_cds_score) { GenomicDB * out; if( seqdb == NULL || cses == NULL ) { warn("Attempting to make GenomicDB from some NULL objects."); return NULL; } /** should check sequence database **/ if( cses->type != SEQUENCE_GENOMIC ) { warn("You can't make a genomic database with a non SEQUENCE_GENOMIC cses type [%d]",cses->type); return NULL; } out = GenomicDB_alloc(); out->is_single_seq = FALSE; out->sdb = hard_link_SequenceDB(seqdb); out->cses = hard_link_ComplexSequenceEvalSet(cses); out->length_of_N = length_of_N; out->repeat_in_cds_score = repeat_in_cds_score; return out; } # line 404 "genomicdb.c" /* Function: hard_link_GenomicDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomicDB *] * * Return [UNKN ] Undocumented return value [GenomicDB *] * */ GenomicDB * hard_link_GenomicDB(GenomicDB * obj) { if( obj == NULL ) { warn("Trying to hard link to a GenomicDB object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GenomicDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomicDB *] * */ GenomicDB * GenomicDB_alloc(void) { GenomicDB * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenomicDB *) ckalloc (sizeof(GenomicDB))) == NULL) { warn("GenomicDB_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->is_single_seq = FALSE; out->done_forward = FALSE; out->forw = NULL; out->rev = NULL; out->sdb = NULL; out->current = NULL; out->cses = NULL; out->error_handling = GENDB_READ_THROUGH; out->single = NULL; out->revsingle = NULL; out->length_of_N = 10; out->repeat_in_cds_score = -1000000; return out; } /* Function: free_GenomicDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomicDB *] * * Return [UNKN ] Undocumented return value [GenomicDB *] * */ GenomicDB * free_GenomicDB(GenomicDB * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GenomicDB obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->forw != NULL) free_ComplexSequence(obj->forw); if( obj->rev != NULL) free_ComplexSequence(obj->rev); if( obj->sdb != NULL) free_SequenceDB(obj->sdb); if( obj->current != NULL) free_Genomic(obj->current); if( obj->cses != NULL) free_ComplexSequenceEvalSet(obj->cses); if( obj->single != NULL) free_Genomic(obj->single); if( obj->revsingle != NULL) free_Genomic(obj->revsingle); ckfree(obj); return NULL; } /* Function: replace_is_single_seq_GenomicDB(obj,is_single_seq) * * Descrip: Replace member variable is_single_seq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * Arg: is_single_seq [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable is_single_seq [boolean] * */ boolean replace_is_single_seq_GenomicDB(GenomicDB * obj,boolean is_single_seq) { if( obj == NULL) { warn("In replacement function is_single_seq for object GenomicDB, got a NULL object"); return FALSE; } obj->is_single_seq = is_single_seq; return TRUE; } /* Function: access_is_single_seq_GenomicDB(obj) * * Descrip: Access member variable is_single_seq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * * Return [SOFT ] member variable is_single_seq [boolean] * */ boolean access_is_single_seq_GenomicDB(GenomicDB * obj) { if( obj == NULL) { warn("In accessor function is_single_seq for object GenomicDB, got a NULL object"); return FALSE; } return obj->is_single_seq; } /* Function: replace_done_forward_GenomicDB(obj,done_forward) * * Descrip: Replace member variable done_forward * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * Arg: done_forward [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable done_forward [boolean] * */ boolean replace_done_forward_GenomicDB(GenomicDB * obj,boolean done_forward) { if( obj == NULL) { warn("In replacement function done_forward for object GenomicDB, got a NULL object"); return FALSE; } obj->done_forward = done_forward; return TRUE; } /* Function: access_done_forward_GenomicDB(obj) * * Descrip: Access member variable done_forward * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * * Return [SOFT ] member variable done_forward [boolean] * */ boolean access_done_forward_GenomicDB(GenomicDB * obj) { if( obj == NULL) { warn("In accessor function done_forward for object GenomicDB, got a NULL object"); return FALSE; } return obj->done_forward; } /* Function: replace_forw_GenomicDB(obj,forw) * * Descrip: Replace member variable forw * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * Arg: forw [OWNER] New value of the variable [ComplexSequence *] * * Return [SOFT ] member variable forw [boolean] * */ boolean replace_forw_GenomicDB(GenomicDB * obj,ComplexSequence * forw) { if( obj == NULL) { warn("In replacement function forw for object GenomicDB, got a NULL object"); return FALSE; } obj->forw = forw; return TRUE; } /* Function: access_forw_GenomicDB(obj) * * Descrip: Access member variable forw * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * * Return [SOFT ] member variable forw [ComplexSequence *] * */ ComplexSequence * access_forw_GenomicDB(GenomicDB * obj) { if( obj == NULL) { warn("In accessor function forw for object GenomicDB, got a NULL object"); return NULL; } return obj->forw; } /* Function: replace_rev_GenomicDB(obj,rev) * * Descrip: Replace member variable rev * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * Arg: rev [OWNER] New value of the variable [ComplexSequence *] * * Return [SOFT ] member variable rev [boolean] * */ boolean replace_rev_GenomicDB(GenomicDB * obj,ComplexSequence * rev) { if( obj == NULL) { warn("In replacement function rev for object GenomicDB, got a NULL object"); return FALSE; } obj->rev = rev; return TRUE; } /* Function: access_rev_GenomicDB(obj) * * Descrip: Access member variable rev * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * * Return [SOFT ] member variable rev [ComplexSequence *] * */ ComplexSequence * access_rev_GenomicDB(GenomicDB * obj) { if( obj == NULL) { warn("In accessor function rev for object GenomicDB, got a NULL object"); return NULL; } return obj->rev; } /* Function: replace_sdb_GenomicDB(obj,sdb) * * Descrip: Replace member variable sdb * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * Arg: sdb [OWNER] New value of the variable [SequenceDB *] * * Return [SOFT ] member variable sdb [boolean] * */ boolean replace_sdb_GenomicDB(GenomicDB * obj,SequenceDB * sdb) { if( obj == NULL) { warn("In replacement function sdb for object GenomicDB, got a NULL object"); return FALSE; } obj->sdb = sdb; return TRUE; } /* Function: access_sdb_GenomicDB(obj) * * Descrip: Access member variable sdb * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * * Return [SOFT ] member variable sdb [SequenceDB *] * */ SequenceDB * access_sdb_GenomicDB(GenomicDB * obj) { if( obj == NULL) { warn("In accessor function sdb for object GenomicDB, got a NULL object"); return NULL; } return obj->sdb; } /* Function: replace_current_GenomicDB(obj,current) * * Descrip: Replace member variable current * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * Arg: current [OWNER] New value of the variable [Genomic *] * * Return [SOFT ] member variable current [boolean] * */ boolean replace_current_GenomicDB(GenomicDB * obj,Genomic * current) { if( obj == NULL) { warn("In replacement function current for object GenomicDB, got a NULL object"); return FALSE; } obj->current = current; return TRUE; } /* Function: access_current_GenomicDB(obj) * * Descrip: Access member variable current * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * * Return [SOFT ] member variable current [Genomic *] * */ Genomic * access_current_GenomicDB(GenomicDB * obj) { if( obj == NULL) { warn("In accessor function current for object GenomicDB, got a NULL object"); return NULL; } return obj->current; } /* Function: replace_cses_GenomicDB(obj,cses) * * Descrip: Replace member variable cses * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * Arg: cses [OWNER] New value of the variable [ComplexSequenceEvalSet *] * * Return [SOFT ] member variable cses [boolean] * */ boolean replace_cses_GenomicDB(GenomicDB * obj,ComplexSequenceEvalSet * cses) { if( obj == NULL) { warn("In replacement function cses for object GenomicDB, got a NULL object"); return FALSE; } obj->cses = cses; return TRUE; } /* Function: access_cses_GenomicDB(obj) * * Descrip: Access member variable cses * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicDB *] * * Return [SOFT ] member variable cses [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * access_cses_GenomicDB(GenomicDB * obj) { if( obj == NULL) { warn("In accessor function cses for object GenomicDB, got a NULL object"); return NULL; } return obj->cses; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/genomicdb.h0000644000175000001440000002427310670453712016746 0ustar philippusers#ifndef DYNAMITEgenomicdbHEADERFILE #define DYNAMITEgenomicdbHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequencedb.h" #include "genomic.h" #include "hscore.h" #include "complexsequence.h" #include "complexevalset.h" typedef enum GenDBErrorType { GENDB_READ_THROUGH = 0, GENDB_FAIL_ON_ERROR = 1 } GenDBErrorType; /* Object GenomicDB * * Descrip: This object hold a database of * genomic sequences. * * You will probably use it in one of * two ways * * 1 A sequence formatted database, which * is provided by a /SequenceDB object * is used to provide the raw sequences * * 2 A single Genomic sequence is used. * * In each case this database provides * both the forward and reverse strands * into the system. * * Notice that what is exported are * /ComplexSequence objects, not genomic dna, * as this is what is generally needed. * These are things with splice sites calculated * etc. This is why for initialisation this needs * a /ComplexSequenceEvalSet of the correct type. * * */ struct Wise2_GenomicDB { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif boolean is_single_seq; boolean done_forward; ComplexSequence * forw; ComplexSequence * rev; SequenceDB * sdb; Genomic * current; ComplexSequenceEvalSet * cses; GenDBErrorType error_handling; Genomic * single; /* for single sequence cases, so we can 'index' on it */ Genomic * revsingle; int length_of_N; int repeat_in_cds_score; } ; /* GenomicDB defined */ #ifndef DYNAMITE_DEFINED_GenomicDB typedef struct Wise2_GenomicDB Wise2_GenomicDB; #define GenomicDB Wise2_GenomicDB #define DYNAMITE_DEFINED_GenomicDB #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: show_Hscore_GenomicDB(hs,ofp) * * Descrip: shows the Hscore by the GenomicDB information * * * * Arg: hs [UNKN ] High Score structure [Hscore *] * Arg: ofp [UNKN ] output file [FILE *] * */ void Wise2_show_Hscore_GenomicDB(Hscore * hs,FILE * ofp); #define show_Hscore_GenomicDB Wise2_show_Hscore_GenomicDB /* Function: get_Genomic_from_GenomicDB(gendb,de) * * Descrip: Gets Genomic sequence out from * the GenomicDB using the information stored in * dataentry * * * Arg: gendb [UNKN ] Undocumented argument [GenomicDB *] * Arg: de [UNKN ] Undocumented argument [DataEntry *] * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Wise2_get_Genomic_from_GenomicDB(GenomicDB * gendb,DataEntry * de); #define get_Genomic_from_GenomicDB Wise2_get_Genomic_from_GenomicDB /* Function: dataentry_add_GenomicDB(de,cs,gendb) * * Descrip: adds information to dataentry from GenomicDB * * will eventually add file offset and format information * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: cs [UNKN ] Undocumented argument [ComplexSequence *] * Arg: gendb [UNKN ] Undocumented argument [GenomicDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_dataentry_add_GenomicDB(DataEntry * de,ComplexSequence * cs,GenomicDB * gendb); #define dataentry_add_GenomicDB Wise2_dataentry_add_GenomicDB /* Function: init_GenomicDB(gendb,return_status) * * Descrip: top level function which opens the Genomic database * * * Arg: gendb [UNKN ] protein database [GenomicDB *] * Arg: return_status [WRITE] the status of the open from database.h [int *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * Wise2_init_GenomicDB(GenomicDB * gendb,int * return_status); #define init_GenomicDB Wise2_init_GenomicDB /* Function: reload_GenomicDB(last,gendb,return_status) * * Descrip: function which reloads the database * * * Arg: last [UNKN ] previous complex sequence, will be freed [ComplexSequence *] * Arg: gendb [UNKN ] Undocumented argument [GenomicDB *] * Arg: return_status [WRITE] return_status of the load [int *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * Wise2_reload_GenomicDB(ComplexSequence * last,GenomicDB * gendb,int * return_status); #define reload_GenomicDB Wise2_reload_GenomicDB /* Function: close_GenomicDB(cs,gendb) * * Descrip: top level function which closes the genomic database * * * Arg: cs [UNKN ] last complex sequence [ComplexSequence *] * Arg: gendb [UNKN ] protein database [GenomicDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_close_GenomicDB(ComplexSequence * cs,GenomicDB * gendb) ; #define close_GenomicDB Wise2_close_GenomicDB /* Function: new_GenomicDB_from_single_seq(gen,cses,score_in_repeat_coding) * * Descrip: To make a new genomic database * from a single Genomic Sequence with a eval system * * * Arg: gen [UNKN ] sequence which as placed into GenomicDB structure. [Genomic *] * Arg: cses [UNKN ] Undocumented argument [ComplexSequenceEvalSet *] * Arg: score_in_repeat_coding [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [GenomicDB *] * */ GenomicDB * Wise2_new_GenomicDB_from_single_seq(Genomic * gen,ComplexSequenceEvalSet * cses,int score_in_repeat_coding); #define new_GenomicDB_from_single_seq Wise2_new_GenomicDB_from_single_seq /* Function: new_GenomicDB_from_forrev_cseq(cs,cs_rev) * * Descrip: To make a new genomic database * from a single ComplexSequence * * * Arg: cs [UNKN ] complex sequence which is held. [ComplexSequence *] * Arg: cs_rev [UNKN ] Undocumented argument [ComplexSequence *] * * Return [UNKN ] Undocumented return value [GenomicDB *] * */ GenomicDB * Wise2_new_GenomicDB_from_forrev_cseq(ComplexSequence * cs,ComplexSequence * cs_rev); #define new_GenomicDB_from_forrev_cseq Wise2_new_GenomicDB_from_forrev_cseq /* Function: new_GenomicDB(seqdb,cses,length_of_N,repeat_in_cds_score) * * Descrip: To make a new genomic database * * * Arg: seqdb [UNKN ] sequence database [SequenceDB *] * Arg: cses [UNKN ] protein evaluation set [ComplexSequenceEvalSet *] * Arg: length_of_N [UNKN ] Undocumented argument [int] * Arg: repeat_in_cds_score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [GenomicDB *] * */ GenomicDB * Wise2_new_GenomicDB(SequenceDB * seqdb,ComplexSequenceEvalSet * cses,int length_of_N,int repeat_in_cds_score); #define new_GenomicDB Wise2_new_GenomicDB /* Function: hard_link_GenomicDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomicDB *] * * Return [UNKN ] Undocumented return value [GenomicDB *] * */ GenomicDB * Wise2_hard_link_GenomicDB(GenomicDB * obj); #define hard_link_GenomicDB Wise2_hard_link_GenomicDB /* Function: GenomicDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomicDB *] * */ GenomicDB * Wise2_GenomicDB_alloc(void); #define GenomicDB_alloc Wise2_GenomicDB_alloc /* Function: free_GenomicDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomicDB *] * * Return [UNKN ] Undocumented return value [GenomicDB *] * */ GenomicDB * Wise2_free_GenomicDB(GenomicDB * obj); #define free_GenomicDB Wise2_free_GenomicDB /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_is_single_seq_GenomicDB(GenomicDB * obj,boolean is_single_seq); #define replace_is_single_seq_GenomicDB Wise2_replace_is_single_seq_GenomicDB ComplexSequence * Wise2_access_rev_GenomicDB(GenomicDB * obj); #define access_rev_GenomicDB Wise2_access_rev_GenomicDB boolean Wise2_access_is_single_seq_GenomicDB(GenomicDB * obj); #define access_is_single_seq_GenomicDB Wise2_access_is_single_seq_GenomicDB boolean Wise2_replace_sdb_GenomicDB(GenomicDB * obj,SequenceDB * sdb); #define replace_sdb_GenomicDB Wise2_replace_sdb_GenomicDB boolean Wise2_access_done_forward_GenomicDB(GenomicDB * obj); #define access_done_forward_GenomicDB Wise2_access_done_forward_GenomicDB SequenceDB * Wise2_access_sdb_GenomicDB(GenomicDB * obj); #define access_sdb_GenomicDB Wise2_access_sdb_GenomicDB ComplexSequence * Wise2_access_forw_GenomicDB(GenomicDB * obj); #define access_forw_GenomicDB Wise2_access_forw_GenomicDB boolean Wise2_replace_current_GenomicDB(GenomicDB * obj,Genomic * current); #define replace_current_GenomicDB Wise2_replace_current_GenomicDB boolean Wise2_replace_done_forward_GenomicDB(GenomicDB * obj,boolean done_forward); #define replace_done_forward_GenomicDB Wise2_replace_done_forward_GenomicDB Genomic * Wise2_access_current_GenomicDB(GenomicDB * obj); #define access_current_GenomicDB Wise2_access_current_GenomicDB boolean Wise2_replace_rev_GenomicDB(GenomicDB * obj,ComplexSequence * rev); #define replace_rev_GenomicDB Wise2_replace_rev_GenomicDB boolean Wise2_replace_cses_GenomicDB(GenomicDB * obj,ComplexSequenceEvalSet * cses); #define replace_cses_GenomicDB Wise2_replace_cses_GenomicDB boolean Wise2_replace_forw_GenomicDB(GenomicDB * obj,ComplexSequence * forw); #define replace_forw_GenomicDB Wise2_replace_forw_GenomicDB ComplexSequenceEvalSet * Wise2_access_cses_GenomicDB(GenomicDB * obj); #define access_cses_GenomicDB Wise2_access_cses_GenomicDB #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/codonmapper.dy0000644000175000001440000002120307344153571017505 0ustar philippusers/* Last edited: Mar 14 14:01 1997 (birney) */ %{ #include "codon.h" %} api object CodonMapper des free_CodonMapper func sprinkle_errors_over_CodonMapper endobject func flat_CodonMapper endapi struct CodonMapper CodonTable * ct // hard-linked! double codon_map[125][26] %info CodonMapper holds a matrix of 125 by 26 to provide a mapping between a probabilities calculated on amino acids to triplet codon probabilities. This mapping takes into account 3 things 1) The CodonTable 2) The distribution of synonmous codons (codon bias) 3) substitution errors %% struct CodonFrequency double freq[64]; %info CodonFrequency is a very much internal object for CodonMapper. It provides the frequency of synomous codons, ie, an amino acid with only one codon will have 1.0 in the frequency table Rarely used outside of CodonMapper construction %% %{ #include "codonmapper.h" %func Builds a codon frequency from raw counts as just an array %% CodonFrequency * CodonFrequence_from_raw_counts(double * codon,CodonTable * ct) { double total[26]; CodonFrequency * cf; register int i; int c; register int j; for(i=0;i<26;i++) { total[i] = 0.0; for(j=0;j<64;j++) { c = codon_from_base4_codon(j); if( ct->codon_str[c] == ('A' + i) ) { total[i] += codon[j]; } } } cf = CodonFrequency_alloc(); for(i=0;i<64;i++) { c = codon_from_base4_codon(i); if( is_stop_codon(c,ct) ) continue; if( codon[i] < 0.0000000001) cf->freq[i] = 0.0; else { if( total[ct->codon_str[c] -'A'] < 0.00000001 ) { warn("For codon %d, amino acid %c, we have no frequency",i,ct->codon_str[i]); } else cf->freq[i] = codon[i] / total[ct->codon_str[c]-'A']; } } return cf; } %func Shows codon mapper in vaguely human form %arg %% void show_CodonMapper(CodonMapper * cm,FILE * ofp) { register int i; register int j; for(i=0;i<125;i++) { fprintf(ofp,"[%3d][%c] %.2f",i,aminoacid_from_codon(cm->ct,i),cm->codon_map[i][0]); for(j=1;j<26;j++) fprintf(ofp,",%.2f",cm->codon_map[i][j]); fprintf(ofp,"\n"); } } %func Shows codon frequency in vaguely human form %arg %% void show_CodonFrequency(CodonFrequency * cf,CodonTable * ct,FILE * ofp) { int i; for(i=0;i<64;i++) fprintf(ofp,"[%3d][%c] %.2f\n",i,aminoacid_from_codon(ct,codon_from_base4_codon(i)),cf->freq[i]); } %func Makes a CodonMapper with no codon bias or error possiblities from codon table %arg ct Codon Table giving codon->aa info %% CodonMapper * flat_CodonMapper(CodonTable * ct) { CodonFrequency * cf; CodonMapper * out; cf = flat_CodonFrequency(ct); out = new_CodonMapper(ct,cf); free_CodonFrequency(cf); return out; } %func Makes a no-biased codon Frequency. Probabaly most used in /flat_CodonMapper %arg %% CodonFrequency * flat_CodonFrequency(CodonTable * ct) { int number[26]; CodonFrequency * out; register int i; out = CodonFrequency_alloc(); for(i=0;i<26;i++) number[i] = 0; for(i=0;i<64;i++) out->freq[i]= 0.0; for(i=0;i<125;i++) if( has_random_bases(i) == FALSE && is_stop_codon(i,ct) == FALSE) number[aminoacid_no_from_codon(ct,i)]++; for(i=0;i<64;i++) { if( is_stop_codon(codon_from_base4_codon(i),ct) == FALSE && number[aminoacid_no_from_codon(ct,codon_from_base4_codon(i))] != 0) out->freq[i] = 1.0 / number[aminoacid_no_from_codon(ct,codon_from_base4_codon(i))]; } return out; } /*** ***/ %func Assummes number is an int * of length 26 Files up each position with the number of codons representing that aa %type internal %arg %% void construct_amino_number_array(int * number,CodonTable * ct) { register int i; register int j; for(i=0;i<26;i++) { number[i] = 0; for(j=0;j<64;j++) { if( ct->codon_str[j] == 'A' + i) number[i]++; } } } %func Now defunct. %type internal %arg %% void map_codon_array_CodonMapper(double * codon_array,double * protein_array,double stop,CodonMapper * cm) { register int i; for(i=0;i<125;i++) { if( is_stop_codon(i,cm->ct)== TRUE ) codon_array[i] = stop; else codon_array[i] = map_codon_CodonMapper(i,protein_array,cm); } } %func Takes an array of probabilities from 0-26 in protein array and writes into codon_array the adjusted probability from the codon mapper. Ie, maps a protein emission line to a codon emission line. This is the main use of CodonMapper. %arg codon_array w array (0-124) for the codon probabilities to be placed protein_array r array (0-25) for the protein probabilities to be read from cm Codon Mapper that provides the protein->codon mapping %% void true_map_codon_array_CodonMapper(double * codon_array,const double * protein_array,CodonMapper * cm) { int i; for(i=0;i<125;i++) { codon_array[i] = map_codon_CodonMapper(i,protein_array,cm); } } %func Does the mapping for a single codon from a protein_array %type internal %arg %% double map_codon_CodonMapper(int codon,const double * protein_array,CodonMapper * cm) { register int i; double out = 0.0; if( cm->codon_map[codon][0] < 0.0 ) { warn("Attempting to map a codon with below zero prob in map_codon_CodonMapper. This is bad news...."); return 0.0; } for(i=0;i<26;i++) { out += protein_array[i] * cm->codon_map[codon][i]; } return out; } %func Takes a codon mapper and assummes that the majority of errors are due to a single base change in the codon at probability error. Therefore, for each codon it adds error * prob(codon) * 0.25 to each other codon one base away, taking away therefore the result. %arg cm r CodonMapper to be sprinkled error substitution error rate %% void sprinkle_errors_over_CodonMapper(CodonMapper * cm,double error) { int i; int j; int k; base one; base two; base three; int new_codon; double scratch[125][26]; /* * put all the codons into scratch, but * subtracting 3*error which is the possibility * of an error. * * The self->self errors (eg, G to G) will be * added back later */ for(i=0;i<125;i++) for(j=0;j<26;j++) scratch[i][j] = cm->codon_map[i][j] * (1-(3*error)); /* * Now for each codon, find the single base change, * and add the probability for each amino acid onto it * factored by 0.25 * */ for(i=0;i<125;i++) { all_bases_from_codon(i,&one,&two,&three); if( one != BASE_N) { for(j=0;j<4;j++) { new_codon = j*25 + two * 5 + three; for(k=0;k<26;k++) scratch[i][k] += (cm->codon_map[new_codon][k] * error * 0.25); } } if( two != BASE_N) { for(j=0;j<4;j++) { new_codon = one*25 + j * 5 + three; for(k=0;k<26;k++) scratch[i][k] += (cm->codon_map[new_codon][k] * error * 0.25); } } if( three != BASE_N) { for(j=0;j<4;j++) { new_codon = one*25 + two * 5 + j; for(k=0;k<26;k++) scratch[i][k] += (cm->codon_map[new_codon][k] * error * 0.25); } } } /* * Now map back to original memory */ for(i=0;i<125;i++) for(j=0;j<26;j++) cm->codon_map[i][j] = scratch[i][j]; } %func The only way you should make a CodonMapper! Makes a codon mapper from CodonTable and frequency %arg %% CodonMapper * new_CodonMapper(CodonTable * ct,CodonFrequency * cf) { register int i; register int j; int k; base one; base two; base three; int base4; int oi,ti,ri; double total_freq; CodonMapper * out; out = CodonMapper_alloc(); out->ct = hard_link_CodonTable(ct); for(i=0;i<125;i++) { for(j=0;j<26;j++) out->codon_map[i][j] =0.0; if( has_random_bases(i) == FALSE ) { if( is_stop_codon(i,ct) == TRUE ) { for(k=0;k<26;k++) out->codon_map[i][k] = (0.0); } else { out->codon_map[i][aminoacid_no_from_codon(ct,i)] = cf->freq[base4_codon_from_codon(i)]; } } else { /*** is a random base ***/ /*** sneaky stuff. What we want to do is loop over all possible codons, adding up their frequencies for the amino acids they represent. This is done by looping over all possible bases for each position and then letting through ones which either have an N at this position or is the actual base. ***/ all_bases_from_codon(i,&one,&two,&three); total_freq = 0.0; for(oi=0;oi<4;oi++) for(ti=0;ti<4;ti++) for(ri=0;ri<4;ri++) { if( (one == BASE_N || one == oi) && (two == BASE_N || two == ti) && (three == BASE_N || three == ri) ) { base4 = codon_from_base4_codon(oi*16+ti*4+ri); if( !is_stop_codon(base4,ct) ) { out->codon_map[i][aminoacid_no_from_codon(ct,base4)] += cf->freq[base4_codon_from_codon(base4)]; } } /* end of if one == BASE_N || one == oi */ } /* end of for oi,ti,ri */ } /* end of else */ } return out; } %} wise-2.4.1/src/dynlibsrc/codonmapper.xs0000644000175000001440000000232610670453712017524 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::CodonMapper void sprinkle_errors_over_CodonMapper(cm,error) Wise2_CodonMapper * cm double error CODE: Wise2_sprinkle_errors_over_CodonMapper(cm,error); Wise2_CodonMapper * hard_link_CodonMapper(obj) Wise2_CodonMapper * obj CODE: RETVAL = Wise2_hard_link_CodonMapper(obj); OUTPUT: RETVAL Wise2_CodonMapper * alloc() CODE: RETVAL = Wise2_CodonMapper_alloc(); OUTPUT: RETVAL boolean set_ct(obj,ct) Wise2_CodonMapper * obj Wise2_CodonTable * ct CODE: RETVAL = Wise2_replace_ct_CodonMapper(obj,Wise2_hard_link_CodonTable(ct)); OUTPUT: RETVAL Wise2_CodonTable * ct(obj) Wise2_CodonMapper * obj INIT: Wise2_CodonTable * temp; CODE: temp = Wise2_hard_link_CodonTable(Wise2_access_ct_CodonMapper(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_CodonMapper * new(class) char * class PPCODE: Wise2_CodonMapper * out; out = Wise2_CodonMapper_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_CodonMapper * obj CODE: Wise2_free_CodonMapper(obj); MODULE = Wise2 PACKAGE = Wise2 Wise2_CodonMapper * flat_CodonMapper(ct) Wise2_CodonTable * ct CODE: RETVAL = Wise2_flat_CodonMapper(ct); OUTPUT: RETVAL wise-2.4.1/src/dynlibsrc/dnaindexcons.c0000644000175000001440000002702410670453712017464 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dnaindexcons.h" /* Function: show_help_DnaIndexConstructor(ofp) * * Descrip: Shows help for a DnaIndexConstructor * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 33 "dnaindexcons.dy" void show_help_DnaIndexConstructor(FILE * ofp) { fprintf(ofp,"DnaIndex Constructor options\n"); fprintf(ofp," -dic_type [hash] type of DnaIndex\n"); fprintf(ofp," -dic_word [7] index word length\n"); fprintf(ofp," -dic_prob [0.85] match probabilty in extension\n"); fprintf(ofp," -dic_drop_off [30] drop off in HSP extension\n"); } /* Function: new_DnaIndexConstructor(argc,argv) * * Descrip: Builds new DnaIndexConstructor off Command line * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [DnaIndexConstructor *] * */ # line 46 "dnaindexcons.dy" DnaIndexConstructor * new_DnaIndexConstructor(int * argc,char ** argv) { DnaIndexConstructor * out; char * name; out = DnaIndexConstructor_alloc(); if( (name = strip_out_assigned_argument(argc,argv,"dic_type")) != NULL ) { if( strcmp(name,"hash") == 0 ) { out->type = DnaIndexConstructor_subseq; } else { fatal("Cannot recognise %s as a potential dna index type",name); } } strip_out_integer_argument(argc,argv,"dic_word",&out->index_word_length); strip_out_float_argument(argc,argv,"dic_prob",&out->match_prob); strip_out_integer_argument(argc,argv,"dic_drop_off",&out->drop_off); return out; } /* Function: DnaIndex_from_DnaIndexConstructor(dic) * * Descrip: Makes a DnaIndex from a DnaIndexConstructore * * * Arg: dic [UNKN ] Undocumented argument [DnaIndexConstructor *] * * Return [UNKN ] Undocumented return value [DnaIndex *] * */ # line 73 "dnaindexcons.dy" DnaIndex * DnaIndex_from_DnaIndexConstructor(DnaIndexConstructor * dic) { DnaIndex * out; DnaProbMatrix * dmp; DnaMatrix * dm; assert(dic); out = DnaIndex_alloc(); switch(dic->type) { case DnaIndexConstructor_subseq : out->sli = new_ghash_SeqLookupInterface(); break; default : warn("Unable to make DnaIndex from type %d",dic->type); return NULL; } out->index_word_length = dic->index_word_length; dmp = DnaProbMatrix_from_match(dic->match_prob,NMaskType_BANNED); assert(dmp); flat_null_DnaProbMatrix(dmp); dm = DnaMatrix_from_DnaProbMatrix(dmp); out->cm = new_CompMat_from_DnaMatrix_flat(dm); out->drop_off = dic->drop_off; free_DnaMatrix(dm); free_DnaProbMatrix(dmp); return out; } /* Function: LinearHSPManager_scan_DnaIndex(di,query) * * Descrip: provides a LinearManager for a DNA sequence * * * Arg: di [UNKN ] Undocumented argument [DnaIndex *] * Arg: query [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 114 "dnaindexcons.dy" LinearHSPmanager * LinearHSPManager_scan_DnaIndex(DnaIndex * di,Sequence * query) { LinearHSPmanager * out; HSPmanager * hspm; hspm = HSPmanager_scan_DnaIndex(di,query); out = new_LinearHSPmanager_flat(hspm); free_HSPmanager(hspm); return out; } /* Function: HSPmanager_scan_DnaIndex(di,seq) * * Descrip: Provides a HSPmanager from a scan * * * Arg: di [UNKN ] Undocumented argument [DnaIndex *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [HSPmanager *] * */ # line 131 "dnaindexcons.dy" HSPmanager * HSPmanager_scan_DnaIndex(DnaIndex * di,Sequence * seq) { HSPmanager * out; SeqLookupClientInterface * slci; SeqLookupResultInterface * slri; SeqLookupResultStruct * res = NULL; int i; int no; assert(seq); assert(di); out = new_HSPmanager(seq,di->cm,di->drop_off); slci = (*di->sli->get_client)(di->sli->data); for(i=0;ilen-di->index_word_length;i++) { no = seq_number_dna_Nmer_noN(seq->seq+i,di->index_word_length); if( (*slci->is_populated)(slci->data,no) ) { slri = (*slci->lookup)(slci->data,no); for(;(*slri->is_more)(slri->data);) { res = (*slri->next)(slri->data,res); add_pair_HSPmanager(out,res->seq,i,res->pos); } free_SeqLookupResultInterface(slri); } } return out; } /* Function: process_dna_HSP(set,query,query_pos,tseq,res_struct,mat) * * Descrip: processes DNA based HSPs * * * Arg: set [UNKN ] Undocumented argument [HSPset *] * Arg: query [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: tseq [UNKN ] Undocumented argument [Sequence *] * Arg: res_struct [UNKN ] Undocumented argument [SeqLookupResultStruct *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 167 "dnaindexcons.dy" boolean process_dna_HSP(HSPset * set,Sequence * query,int query_pos,Sequence * tseq,SeqLookupResultStruct * res_struct,CompMat * mat) { int k; for(k=0;klen;k++) { if( on_HSP(set->hsp[k],query_pos,res_struct->pos) == TRUE ) { return FALSE; } } /* new HSP - extend and add */ add_HSPset(set,new_HSP(NULL,query,tseq,query_pos,res_struct->pos,mat,5*Probability2Score(0.8/0.25))); return TRUE; } /* Function: load_Sequence_DnaIndex(di,seq,sllp) * * Descrip: Loads a sequence into a DnaIndex * * * Arg: di [UNKN ] Undocumented argument [DnaIndex *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: sllp [UNKN ] Undocumented argument [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 188 "dnaindexcons.dy" boolean load_Sequence_DnaIndex(DnaIndex * di,Sequence * seq,SeqLookupLoadPara * sllp) { int i; int no; assert(di); assert(seq); assert(di->sli); assert(sllp); for(i=0;ilen - di->index_word_length;i = i+sllp->tile_freq) { no = seq_number_dna_Nmer_noN(seq->seq+i,di->index_word_length); if( no != -1 ) { (*di->sli->add_direct_number)(di->sli->data,no,seq,i); } } return TRUE; } /* Function: seq_number_dna_Nmer_noN(seq,index_length) * * Descrip: General DNA index number generation * * * Arg: seq [UNKN ] Undocumented argument [char *] * Arg: index_length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ # line 214 "dnaindexcons.dy" int seq_number_dna_Nmer_noN(char * seq,int index_length) { int i; int ret = 0; int base = 1; int no = 0; for(i=0;idynamite_hard_link++; return obj; } /* Function: DnaIndexConstructor_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaIndexConstructor *] * */ DnaIndexConstructor * DnaIndexConstructor_alloc(void) { DnaIndexConstructor * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaIndexConstructor *) ckalloc (sizeof(DnaIndexConstructor))) == NULL) { warn("DnaIndexConstructor_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = DnaIndexConstructor_subseq; out->index_word_length = 7; out->match_prob = 0.8; out->drop_off = 30; return out; } /* Function: free_DnaIndexConstructor(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaIndexConstructor *] * * Return [UNKN ] Undocumented return value [DnaIndexConstructor *] * */ DnaIndexConstructor * free_DnaIndexConstructor(DnaIndexConstructor * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaIndexConstructor obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_DnaIndex(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaIndex *] * * Return [UNKN ] Undocumented return value [DnaIndex *] * */ DnaIndex * hard_link_DnaIndex(DnaIndex * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaIndex object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaIndex_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaIndex *] * */ DnaIndex * DnaIndex_alloc(void) { DnaIndex * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaIndex *) ckalloc (sizeof(DnaIndex))) == NULL) { warn("DnaIndex_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->index_word_length = 0; out->sli = NULL; out->cm = NULL; out->drop_off = 30; return out; } /* Function: free_DnaIndex(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaIndex *] * * Return [UNKN ] Undocumented return value [DnaIndex *] * */ DnaIndex * free_DnaIndex(DnaIndex * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaIndex obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->sli != NULL) free_SeqLookupInterface(obj->sli); if( obj->cm != NULL) free_CompMat(obj->cm); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/dnaindexcons.h0000644000175000001440000001754110670453712017474 0ustar philippusers#ifndef DYNAMITEdnaindexconsHEADERFILE #define DYNAMITEdnaindexconsHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "subseqhash.h" #include "hsp.h" #include "hsphandler.h" #include "dnamatrix.h" typedef enum { DnaIndexConstructor_subseq = 438, } DnaIndexConstructorType; struct Wise2_DnaIndexConstructor { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; int index_word_length; Probability match_prob; int drop_off; } ; /* DnaIndexConstructor defined */ #ifndef DYNAMITE_DEFINED_DnaIndexConstructor typedef struct Wise2_DnaIndexConstructor Wise2_DnaIndexConstructor; #define DnaIndexConstructor Wise2_DnaIndexConstructor #define DYNAMITE_DEFINED_DnaIndexConstructor #endif struct Wise2_DnaIndex { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int index_word_length; SeqLookupInterface * sli; CompMat * cm; int drop_off; } ; /* DnaIndex defined */ #ifndef DYNAMITE_DEFINED_DnaIndex typedef struct Wise2_DnaIndex Wise2_DnaIndex; #define DnaIndex Wise2_DnaIndex #define DYNAMITE_DEFINED_DnaIndex #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: show_help_DnaIndexConstructor(ofp) * * Descrip: Shows help for a DnaIndexConstructor * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_help_DnaIndexConstructor(FILE * ofp); #define show_help_DnaIndexConstructor Wise2_show_help_DnaIndexConstructor /* Function: new_DnaIndexConstructor(argc,argv) * * Descrip: Builds new DnaIndexConstructor off Command line * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [DnaIndexConstructor *] * */ DnaIndexConstructor * Wise2_new_DnaIndexConstructor(int * argc,char ** argv); #define new_DnaIndexConstructor Wise2_new_DnaIndexConstructor /* Function: DnaIndex_from_DnaIndexConstructor(dic) * * Descrip: Makes a DnaIndex from a DnaIndexConstructore * * * Arg: dic [UNKN ] Undocumented argument [DnaIndexConstructor *] * * Return [UNKN ] Undocumented return value [DnaIndex *] * */ DnaIndex * Wise2_DnaIndex_from_DnaIndexConstructor(DnaIndexConstructor * dic); #define DnaIndex_from_DnaIndexConstructor Wise2_DnaIndex_from_DnaIndexConstructor /* Function: LinearHSPManager_scan_DnaIndex(di,query) * * Descrip: provides a LinearManager for a DNA sequence * * * Arg: di [UNKN ] Undocumented argument [DnaIndex *] * Arg: query [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_LinearHSPManager_scan_DnaIndex(DnaIndex * di,Sequence * query); #define LinearHSPManager_scan_DnaIndex Wise2_LinearHSPManager_scan_DnaIndex /* Function: HSPmanager_scan_DnaIndex(di,seq) * * Descrip: Provides a HSPmanager from a scan * * * Arg: di [UNKN ] Undocumented argument [DnaIndex *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [HSPmanager *] * */ HSPmanager * Wise2_HSPmanager_scan_DnaIndex(DnaIndex * di,Sequence * seq); #define HSPmanager_scan_DnaIndex Wise2_HSPmanager_scan_DnaIndex /* Function: process_dna_HSP(set,query,query_pos,tseq,res_struct,mat) * * Descrip: processes DNA based HSPs * * * Arg: set [UNKN ] Undocumented argument [HSPset *] * Arg: query [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: tseq [UNKN ] Undocumented argument [Sequence *] * Arg: res_struct [UNKN ] Undocumented argument [SeqLookupResultStruct *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_process_dna_HSP(HSPset * set,Sequence * query,int query_pos,Sequence * tseq,SeqLookupResultStruct * res_struct,CompMat * mat); #define process_dna_HSP Wise2_process_dna_HSP /* Function: load_Sequence_DnaIndex(di,seq,sllp) * * Descrip: Loads a sequence into a DnaIndex * * * Arg: di [UNKN ] Undocumented argument [DnaIndex *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: sllp [UNKN ] Undocumented argument [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_load_Sequence_DnaIndex(DnaIndex * di,Sequence * seq,SeqLookupLoadPara * sllp); #define load_Sequence_DnaIndex Wise2_load_Sequence_DnaIndex /* Function: seq_number_dna_Nmer_noN(seq,index_length) * * Descrip: General DNA index number generation * * * Arg: seq [UNKN ] Undocumented argument [char *] * Arg: index_length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_seq_number_dna_Nmer_noN(char * seq,int index_length); #define seq_number_dna_Nmer_noN Wise2_seq_number_dna_Nmer_noN /* Function: hard_link_DnaIndexConstructor(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaIndexConstructor *] * * Return [UNKN ] Undocumented return value [DnaIndexConstructor *] * */ DnaIndexConstructor * Wise2_hard_link_DnaIndexConstructor(DnaIndexConstructor * obj); #define hard_link_DnaIndexConstructor Wise2_hard_link_DnaIndexConstructor /* Function: DnaIndexConstructor_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaIndexConstructor *] * */ DnaIndexConstructor * Wise2_DnaIndexConstructor_alloc(void); #define DnaIndexConstructor_alloc Wise2_DnaIndexConstructor_alloc /* Function: free_DnaIndexConstructor(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaIndexConstructor *] * * Return [UNKN ] Undocumented return value [DnaIndexConstructor *] * */ DnaIndexConstructor * Wise2_free_DnaIndexConstructor(DnaIndexConstructor * obj); #define free_DnaIndexConstructor Wise2_free_DnaIndexConstructor /* Function: hard_link_DnaIndex(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaIndex *] * * Return [UNKN ] Undocumented return value [DnaIndex *] * */ DnaIndex * Wise2_hard_link_DnaIndex(DnaIndex * obj); #define hard_link_DnaIndex Wise2_hard_link_DnaIndex /* Function: DnaIndex_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaIndex *] * */ DnaIndex * Wise2_DnaIndex_alloc(void); #define DnaIndex_alloc Wise2_DnaIndex_alloc /* Function: free_DnaIndex(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaIndex *] * * Return [UNKN ] Undocumented return value [DnaIndex *] * */ DnaIndex * Wise2_free_DnaIndex(DnaIndex * obj); #define free_DnaIndex Wise2_free_DnaIndex /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/seqalign.dy0000644000175000001440000002110210076537056016777 0ustar philippusers %{ #include "sequence.h" #define SeqAlignLISTLENGTH 64 %} struct SeqAlign char * name Sequence ** seq !list %info The most stupid and bad representation of a sequence alignment, being a list of sequences with padding characters in them Not very useful for anything but reformatting and column frequencies. Dont use this for complicated alignment manipulations. Use the more hard core aln stuff For reading in this data structure, you can use the wise2xhmmer2x bridge to Sean Eddy's reading code. This copes inherently with automatically detecting sequence alignment. Might bridge to his output stuff sometime as well... %% struct ColumnCount double count[27] %info counts from a column of an alignment %% %{ #include "seqalign.h" %func Tells you whether either . or - characters occur at a position. Uses C-style coordinates %% boolean is_gapped_SeqAlign(SeqAlign * sa,int pos) { int i; assert(sa != NULL); assert(pos < sa->seq[0]->len); for(i=0;ilen;i++) { if( sa->seq[i]->seq[pos] == '.' || sa->seq[i]->seq[pos] == '-' ) { return TRUE; } } return FALSE; } %func trims sequence alignments to first and last non N character (for DNA obviously) %% SeqAlign * trim_from_N_SeqAlign(SeqAlign * sa) { int i; int j; int k; int left = 0; int right = 0; SeqAlign * out; Sequence * seq; char buffer[MAXLINE]; assert(sa); for(i=0;ilen;i++) { if( sa->seq[i]->len > left ) { left = sa->seq[i]->len; } } for(i=0;ilen;i++) { for(j=0;jseq[i]->len;j++) { if( sa->seq[i]->seq[j] != 'N' ) { break; } } if( left > j ) { left = j; } for(j=sa->seq[i]->len-1;j>=0;j--) { if( sa->seq[i]->seq[j] != 'N' ) { break; } } if ( right < j ) { right = j; } } right++; /* now we have left and right, make new sa */ out = SeqAlign_alloc_len(sa->len); for(i=0;ilen;i++) { seq = Sequence_alloc(); add_SeqAlign(out,seq); seq->name = stringalloc(sa->seq[i]->name); for(j=left,k=0;jseq[i]->len;j++,k++) { buffer[k] = sa->seq[i]->seq[j]; } for(;jseq = stringalloc(buffer); seq->len = k; seq->type = SEQUENCE_DNA; } return out; } %func Provides reweighting for a seqalign so all the weights add up to 1.0 %% void reweight_SeqAlign(SeqAlign * sal) { int i; double total =0.0; for(i=0;ilen;i++) { total += sal->seq[i]->weight; } for(i=0;ilen;i++) { sal->seq[i]->weight = sal->seq[i]->weight/ total; } } %func Gives you a column count You are supposed to have enough sense to cache this on the caller if you need it again %% ColumnCount * ColumnCount_from_SeqAlign(SeqAlign * sa,int col) { ColumnCount * out; double count[27] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 , 0.0}; int i; if( sa == NULL || sa->seq[0]->len < col ) { warn("Cannot make column count at %d - out of range/seqalign null",col); return NULL; } for(i=0;ilen;i++) { if( sa->seq[i]->len < col ) { warn("For seqalign sequence %d (%s), although first seq ok, this doesn't extend to %d. Error.",i,sa->seq[i]->name,col); return NULL; } if ( isalpha(sa->seq[i]->seq[col]) ) { count[toupper(sa->seq[i]->seq[col]) - 'A']++; } else { count[26]++; } } out = ColumnCount_alloc(); for(i=0;i<27;i++) out->count[i] = count[i]; return out; } %func Writes selex format %% boolean write_selex_SeqAlign(const SeqAlign * sa,int name_len,int block_len,FILE * ofp) { int col; int i; int j; int k; assert(sa); assert(ofp); assert(name_len > 1); assert(block_len > 1); for(col=0;colseq[0]->len;) { for(j=0;jlen;j++) { assert(sa->seq[j]->name); for(k=0;kseq[j]->name[k] != '\0';k++) { fputc(sa->seq[j]->name[k],ofp); } if( sa->seq[j]->name[k] == '\0' && k >= name_len ) { warn("In printing selex alignment, name %s is truncated at %d",sa->seq[j]->name,k); } /* put in the rest of k */ for(;kseq[j]->seq); for(i=col;(i - col) < block_len && i < sa->seq[j]->len ; i++) { fputc(sa->seq[j]->seq[i],ofp); } fputc('\n',ofp); } /* end over all sequences for this block */ col += block_len; fprintf(ofp,"\n\n"); } return TRUE; } %func Reads in fasta file opening the file %% SeqAlign * read_fasta_SeqAlign_file(char * filename) { FILE * ifp; SeqAlign * out; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Cannot open file %s",filename); return NULL; } out = read_fasta_SeqAlign(ifp); fclose(ifp); return out; } %func Reads in fasta file style alignments %% SeqAlign * read_fasta_SeqAlign(FILE * ifp) { Sequence * seq; SeqAlign * out; out = SeqAlign_alloc_std(); while( (seq = read_fasta_Sequence(ifp)) != NULL ) { fprintf(stderr,"Adding sequence %s\n",seq->name); add_SeqAlign(out,seq); } /* in multi-fasta alignments, this indicates the end */ if( out->len == 0 ) { free_SeqAlign(out); return NULL; } return out; } %func writes out Fasta file %% void write_fasta_SeqAlign(SeqAlign * sa,FILE * ofp) { int i; for(i=0;ilen;i++) { write_fasta_Sequence(sa->seq[i],ofp); } } %func Open files as well %% SeqAlign * read_selex_SeqAlign_file(char * filename) { FILE * ifp; SeqAlign * out; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Cannot open file %s",filename); return NULL; } out = read_selex_SeqAlign(ifp); fclose(ifp); return out; } %func Reads in selex (Stockholm) alignment At the moment ignores all #= stuff on the sequence Read HMMER documentation for a definition of the format %% SeqAlign * read_selex_SeqAlign(FILE * ifp) { char buffer[4096]; SeqAlign * out; Sequence * temp; int i; boolean isfirst; boolean isfseq; boolean isend; char * name; char * seq; char * strip; int pos; out = SeqAlign_alloc_std(); while( fgets(buffer,4096,ifp) != NULL ) { /*fprintf(stderr,"(selex) reading %s in selex alignment\n",buffer);*/ if( buffer[0] == '#' ) continue; /* skips over # */ if( buffer[0] == '/' && buffer[1] == '/' ) break; if( !isspace(buffer[0]) ) { /** in a block **/ i = 0; /* this is the first sequence */ if( out->len == 0 ) { isfirst = TRUE; isfseq = TRUE; } else { isfirst = FALSE; isfseq = FALSE; } for(;;) { /* strip trailing white space */ for(strip = buffer + strlen(buffer) - 1; strip > buffer && isspace(*strip);strip--) ; strip++; *strip = '\0'; for(name = seq = buffer;!isspace(*seq) && *seq; seq++) ; /** if '\0' - worry **/ if( !*seq ) { warn("For name %s in selex alignment, no sequence!",name); return out; } *seq = '\0'; if( isfirst == TRUE ) { temp = empty_Sequence_from_dynamic_memory(stringalloc(name)); add_SeqAlign(out,temp); } else { if ( i >= out->len ) { warn("For sequence %s, got over previous blocks size",name); return NULL; } temp = out->seq[i++]; } /* if is fseq, then find the next character */ if( isfseq == TRUE ) { for(seq++;*seq && isspace(*seq);seq++) ; if( *seq == '\0' ) { warn("In first sequence %s, got to end of line with no sequence!",name); return NULL; } isfseq = FALSE; pos = seq - buffer; } /* else pos is as normal */ /* map all non alnum chars to '-' */ for(seq = buffer+pos;*seq;seq++) { if( !isalnum(*seq) ) { *seq = '-'; } } /* add to sequence */ add_string_to_Sequence(temp,buffer+pos); /* get next line */ while( (seq = fgets(buffer,4096,ifp)) != NULL ) { /*fprintf(stderr,"(selex - 2nd loop) reading %s in selex alignment\n",buffer);*/ if( buffer[0] != '#' ) break; if( buffer[0] == '/' && buffer[1] == '/' ) break; } /*fprintf(stderr,"Broken from second loop\n");*/ if( seq == NULL ) { /*fprintf(stderr,"End of sequence?\n");*/ isend = TRUE; break; } if( buffer[0] == '/' && buffer[1] == '/' ) { /*fprintf(stderr,"double slash terminator?\n");*/ isend = TRUE; break; } /* if it is blank, break out of block */ if( !isalnum(buffer[0]) ) { /*fprintf(stderr,"Back to loop?\n");*/ break; } } if( isend == TRUE ) break; } /* end of was a non space line */ /* else - ignore it !*/ } return out; } wise-2.4.1/src/dynlibsrc/genomic.dy0000644000175000001440000001475607644512135016634 0ustar philippusers %{ #include "sequence.h" #define GenomicLISTLENGTH 128 %} api object Genomic des free_Genomic func truncate_Genomic func Genomic_name func Genomic_length func Genomic_seqchar func show_Genomic endobject object GenomicRepeat des free_GenomicRepeat endobject func read_fasta_file_Genomic func read_fasta_Genomic func Genomic_from_Sequence_Nheuristic func Genomic_from_Sequence endapi struct GenomicRepeat int start int end char * type struct Genomic Sequence * baseseq; GenomicRepeat ** repeat !list # SequenceErrorList * se // list of the sequence errors %{ #include "genomic.h" %func Truncates a Genomic sequence. Basically uses the /magic_trunc_Sequence function (of course!) It does not alter gen, rather it returns a new sequence with that truncation Handles repeat information correctly. %arg gen r Genomic that is truncated %% Genomic * truncate_Genomic(Genomic * gen,int start,int stop) { Genomic * out; GenomicRepeat * tempr; int tst,tend; int i; out = Genomic_from_Sequence(magic_trunc_Sequence(gen->baseseq,start,stop)); assert(out); for(i=0;ilen;i++) { if( start < stop ) { /* then we have to figure out if this repeat overlaps, and if so, put it in */ if( gen->repeat[i]->start > stop || gen->repeat[i]->end < start ) { continue; } /* overlaps in some way */ tst = gen->repeat[i]->start - start; tend = gen->repeat[i]->end - start; if( tst < 0 ) { tst =0; } if( tend > (stop-start) ) { tend = (stop-start); } } else { /* then we have to figure out if this repeat overlaps, and if so, put it in */ if( gen->repeat[i]->start > start || gen->repeat[i]->end < stop ) { continue; } /* overlaps in some way */ tend = start - gen->repeat[i]->start; tst = start - gen->repeat[i]->end; if( tst < 0 ) { tst =0; } if( tend > (start-stop) ) { tend = (start-stop); } } tempr = GenomicRepeat_alloc(); tempr->start = tst; tempr->end = tend; add_Genomic(out,tempr); } return out; } %func Reverse Complements s Genomic sequence. Handles repeat information correctly %arg gen r Genomic that is revomcp %% Genomic * reverse_complement_Genomic(Genomic * gen) { return truncate_Genomic(gen,gen->baseseq->len,0); } %func Reads a fasta file assumming that it is Genomic. Will complain if it is not, and return NULL. %arg filename filename to be opened and read length_of_N length of N to be considered repeat. -1 means none %% Genomic * read_fasta_file_Genomic(char * filename,int length_of_N) { Sequence * seq; seq = read_fasta_file_Sequence(filename); if( seq == NULL ) { warn("Unable to read sequence from %s [%d], so no genomic",filename,seq); return NULL; } if( length_of_N < 0 ) return Genomic_from_Sequence(seq); else return Genomic_from_Sequence_Nheuristic(seq,length_of_N); } %func Reads a fasta file assumming that it is Genomic. Will complain if it is not, and return NULL. %arg ifp file point to be read from length_of_N length of N to be considered repeat. -1 means none %% Genomic * read_fasta_Genomic(FILE * ifp,int length_of_N) { Sequence * seq; seq = read_fasta_Sequence(ifp); if( seq == NULL ) { return NULL; } if( length_of_N < 0 ) return Genomic_from_Sequence(seq); else return Genomic_from_Sequence_Nheuristic(seq,length_of_N); } %func Returns the name of the Genomic %arg %% char * Genomic_name(Genomic * gen) { return gen->baseseq->name; } %func Returns the length of the Genomic %arg %% int Genomic_length(Genomic * gen) { return gen->baseseq->len; } %func Returns sequence character at this position. %arg gen Genomic pos position in Genomic to get char %% char Genomic_seqchar(Genomic * gen,int pos) { return gen->baseseq->seq[pos]; } %func makes a new genomic from a Sequence, but assummes that all the N runs greater than a certain level are actually repeats. %% Genomic * Genomic_from_Sequence_Nheuristic(Sequence * seq,int length_of_N) { Genomic * out; GenomicRepeat * temp; char * run, *run2; out = Genomic_from_Sequence(seq); if( out == NULL ) { warn("Could not make a new Genomic Sequence from Sequence in Nheuristic"); return NULL; } for(run=strchr(seq->seq,'N');run != NULL;) { for(run2 = run; *run2 && *run2 == 'N';run2++) ; if( run2 - run > length_of_N) { temp = GenomicRepeat_alloc(); add_Genomic(out,temp); temp->start = run - seq->seq; temp->end = run2 - seq->seq; } run = strchr(run2,'N'); } return out; } %func makes a new genomic from a Sequence. It owns the Sequence memory, ie will attempt a /free_Sequence on the structure when /free_Genomic is called If you want to give this genomic this Sequence and forget about it, then just hand it this sequence and set seq to NULL (no need to free it). If you intend to use the sequence object elsewhere outside of the Genomic datastructure then use Genomic_from_Sequence(/hard_link_Sequence(seq)) This is part of a strict typing system, and therefore is going to convert all non ATGCNs to Ns. You will lose information here. %arg seq o Sequence to make genomic from %% Genomic * Genomic_from_Sequence(Sequence * seq) { Genomic * out; int conv; if( seq == NULL ) { warn("Cannot make a genomic sequence from a NULL sequence"); return NULL; } if( is_dna_Sequence(seq) == FALSE ) { warn("Trying to make a genomic sequence from a non genomic base sequence [%s] Type is %d.",seq->name,seq->type); return NULL; } uppercase_Sequence(seq); force_to_dna_Sequence(seq,1.0,&conv); if( conv != 0 ) { log_full_error(INFO,0,"In making %s a genomic sequence, converted %d bases (%2.1f%%) to N's from non ATGCN",seq->name,conv,(double)conv*100/(double)seq->len); } out = Genomic_alloc_std(); out->baseseq = seq; return out; } %func For debugging %simple show %% void show_Genomic(Genomic * gen,FILE * ofp) { int i; assert(gen); write_fasta_Sequence(gen->baseseq,ofp); fprintf(ofp,"%d repeats\n",gen->len); for(i=0;ilen;i++) { if( gen->baseseq->offset < gen->baseseq->end ) fprintf(ofp,"Repeat from %d - %d Biologically: %d - %d \n",gen->repeat[i]->start,gen->repeat[i]->end,gen->baseseq->offset+gen->repeat[i]->start,gen->baseseq->offset -1 + gen->repeat[i]->end); else fprintf(ofp,"Repeat from %d - %d Biologically: %d - %d \n",gen->repeat[i]->start,gen->repeat[i]->end,gen->baseseq->offset - gen->repeat[i]->start,gen->baseseq->offset - gen->repeat[i]->end +1); } } %} wise-2.4.1/src/dynlibsrc/genomic.xs0000644000175000001440000001104410670453712016633 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::Genomic Wise2_Genomic * truncate_Genomic(gen,start,stop) Wise2_Genomic * gen int start int stop CODE: RETVAL = Wise2_truncate_Genomic(gen,start,stop); OUTPUT: RETVAL char * Genomic_name(gen) Wise2_Genomic * gen CODE: RETVAL = Wise2_Genomic_name(gen); OUTPUT: RETVAL int Genomic_length(gen) Wise2_Genomic * gen CODE: RETVAL = Wise2_Genomic_length(gen); OUTPUT: RETVAL char Genomic_seqchar(gen,pos) Wise2_Genomic * gen int pos CODE: RETVAL = Wise2_Genomic_seqchar(gen,pos); OUTPUT: RETVAL void show(gen,ofp) Wise2_Genomic * gen FILE * ofp CODE: Wise2_show_Genomic(gen,ofp); Wise2_Genomic * hard_link_Genomic(obj) Wise2_Genomic * obj CODE: RETVAL = Wise2_hard_link_Genomic(obj); OUTPUT: RETVAL Wise2_Genomic * Genomic_alloc_std() CODE: RETVAL = Wise2_Genomic_alloc_std(); OUTPUT: RETVAL boolean set_baseseq(obj,baseseq) Wise2_Genomic * obj Wise2_Sequence * baseseq CODE: RETVAL = Wise2_replace_baseseq_Genomic(obj,Wise2_hard_link_Sequence(baseseq)); OUTPUT: RETVAL Wise2_Sequence * baseseq(obj) Wise2_Genomic * obj INIT: Wise2_Sequence * temp; CODE: temp = Wise2_hard_link_Sequence(Wise2_access_baseseq_Genomic(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_GenomicRepeat * repeat(obj,i) Wise2_Genomic * obj int i INIT: Wise2_GenomicRepeat * temp; CODE: temp = Wise2_hard_link_GenomicRepeat(Wise2_access_repeat_Genomic(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_repeat(obj) Wise2_Genomic * obj CODE: RETVAL = Wise2_length_repeat_Genomic(obj); OUTPUT: RETVAL int flush_repeat(obj) Wise2_Genomic * obj CODE: RETVAL = Wise2_flush_Genomic(obj); OUTPUT: RETVAL boolean add_repeat(obj,add) Wise2_Genomic * obj Wise2_GenomicRepeat * add CODE: RETVAL = Wise2_add_Genomic(obj,Wise2_hard_link_GenomicRepeat(add)); OUTPUT: RETVAL Wise2_Genomic * new(class) char * class PPCODE: Wise2_Genomic * out; out = Wise2_Genomic_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_Genomic * obj CODE: Wise2_free_Genomic(obj); void each_repeat(obj) Wise2_Genomic * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_repeat_Genomic(obj); for(i=0;idata = (void*) new_ArraySeqLookup(len,numb_level); out->get_client = get_client_arraylookup; out->add_seq = add_seq_arraylookup; out->free_data = free_data_arraylookup; out->lookup_array_head = arrayhead_direct_lookup; return out; } %func Prints out summary statistcis to a file %% void print_array_occuypancy_ArraySeq(ArraySeqLookup * asl,FILE * ofp) { int i; for(i=0;ilen;i++) { if( asl->array[i] == NULL ) { fprintf(ofp,"%d EMPTY\n",i); } else { fprintf(ofp,"%d full %d\n",i,asl->array[i]->current_pos); } } } %func Builds a new client from Array %% SeqLookupClientInterface * get_client_arraylookup(void *data) { ArraySeqLookup * array = (ArraySeqLookup *) data; ArraySeqClient * cli; SeqLookupClientInterface * slci; cli = ArraySeqClient_alloc(); cli->interface.next = next_arrayhead_search_results; cli->interface.is_more = is_more_arrayhead_search_results; cli->interface.free_data = free_arrayhead_results; cli->interface.data = (void *) &(cli->result); cli->result.ipos = 0; cli->array = array; slci = SeqLookupClientInterface_alloc(); slci->lookup = lookup_array_client; slci->is_populated = is_populated_array_client; slci->free_data = free_array_client; slci->data = (void*) cli; return slci; } %func Internal function for results interface %% SeqLookupResultStruct * next_arrayhead_search_results(void * data,SeqLookupResultStruct * prev) { ArraySeqHeadResults * a = (ArraySeqHeadResults *) data; if( a->ipos >= a->head->current_pos ) { fatal("Overran array!"); } a->str.seq = a->head->units[a->ipos].seq; a->str.pos = a->head->units[a->ipos].pos; a->ipos++; return &(a->str); } %func Internal function for results interface %% boolean is_more_arrayhead_search_results(void * data) { ArraySeqHeadResults * a = (ArraySeqHeadResults *) data; if( a->ipos >= a->head->current_pos ) { return FALSE; } return TRUE; } %func Internal function for results interface, which is a no-op %% void free_arrayhead_results(void * data) { return; } %func Internal function for client interface, which frees client specific memory %% void free_array_client(void * data) { ArraySeqClient * cli = (ArraySeqClient*) data; free(cli); } %func makes a new ArraySeqLookup taking up to len positions %% ArraySeqLookup * new_ArraySeqLookup(int len,long numb_level) { int i; ArraySeqLookup * out; out = ArraySeqLookup_alloc(); out->array = calloc(len,sizeof(ArraySeqHead*)); assert(out->array); for(i=0;iarray[i] = NULL; } out->len = len; out->numb_level = numb_level; return out; } %func tells whether this is populated or not %% boolean is_populated_array_client(void * data, int seq_number) { ArraySeqClient * cli = (ArraySeqClient *)data; if( cli->array->array[seq_number] == NULL ) { return FALSE; } else { return TRUE; } } %func Retrieves a SeqLookup position %% SeqLookupResultInterface * lookup_array_client(void * data, int seq_number) { ArraySeqClient * cli = (ArraySeqClient *)data; if( cli->array->array[seq_number] == NULL ) { return NULL; } cli->result.ipos = 0; cli->result.head = cli->array->array[seq_number]; return &(cli->interface); } %func For array optimised lookup hash, provides direct memory access %% ArraySeqHead * arrayhead_direct_lookup(void * data,int seq_number) { ArraySeqLookup * look = (ArraySeqLookup *)data; /* fprintf(stderr,"In arrayhead direct lookup with %d\n",seq_number);*/ return look->array[seq_number]; } %func Adds a sequence/pos pair to the hash %% boolean add_seq_arraylookup(void * data,Sequence * seq,SeqLookupLoadPara * para) { int i; ArraySeqLookup * look = (ArraySeqLookup *)data; int seq_number; assert(data != NULL); assert(seq != NULL); assert(para != NULL); for(i=0;ilen-5;i = i+para->tile_freq) { seq_number = seq_number_aa_5mer(seq->seq+i); if( look->array[seq_number] == NULL ) { look->array[seq_number] = new_ArraySeqHead(); if( para->mark_low_complexity ) { look->array[seq_number]->flags = flags_from_5aa_sequence(seq->seq+i); } } add_ArraySeqHead(look->array[seq_number],seq,i,look->numb_level); } return TRUE; } %func Frees data %% void free_data_arraylookup(void * data) { ArraySeqLookup * look = (ArraySeqLookup *)data; int i; for(i=0;ilen;i++) { if( look->array[i] == NULL ) { continue; } ckfree(look->array[i]->units); ckfree(look->array[i]); } free_ArraySeqLookup(look); } %func Adds a sequence/pos pair to an ArrayHead %% boolean add_ArraySeqHead(ArraySeqHead * h,Sequence * seq,int pos,long numb_level) { ArraySeqLookupUnit * temp; if( numb_level > 0 && h->current_pos > numb_level ) { return TRUE; } /* fprintf(stderr,"adding new sequence position with %d max pos %d\n",h->current_pos,h->max); */ if( h->current_pos >= h->max ) { temp = h->units; if( h->max < ARRAYSEQL_LINEAR ) { h->units = realloc(h->units,(h->max*2)*sizeof(ArraySeqLookupUnit)); h->max = h->max*2; } else { h->units = realloc(h->units,(h->max + ARRAYSEQL_LINEAR)*sizeof(ArraySeqLookupUnit)); h->max = h->max + ARRAYSEQL_LINEAR; } if( h->units == NULL ) { fatal("ArraySeqLookup realloc failed trying for %d positions\n",h->max); } /* fprintf(stderr,"... extended to %d\n",h->max); */ } h->units[h->current_pos].seq = seq; h->units[h->current_pos].pos = pos; h->current_pos++; return TRUE; } %func Builds a new ArraySeqHead structure %% ArraySeqHead * new_ArraySeqHead(void) { ArraySeqHead * out; out = malloc(sizeof(ArraySeqHead)); out->units = calloc(ARRAYSEQL_BASIC,sizeof(ArraySeqLookupUnit)); out->max = ARRAYSEQL_BASIC; out->current_pos = 0; return out; } wise-2.4.1/src/dynlibsrc/basematrix.typemap0000644000175000001440000000000010670453712020364 0ustar philippuserswise-2.4.1/src/dynlibsrc/hspscanruntime.c0000644000175000001440000001257210670453712020054 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "hspscanruntime.h" /* Function: new_runtime_HSPScanInterface(sli,mat,drop_off,score_cutoff,threadno) * * Descrip: Makes a new function which will at runtime switch between * implementation; vanilla, threaded and twohit * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * Arg: threadno [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ # line 26 "hspscanruntime.dy" HSPScanInterface * new_runtime_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff,int threadno) { HSPScanInterface * out; HSPScanRuntimeImpl * rt; out = HSPScanInterface_alloc(); rt = HSPScanRuntimeImpl_alloc(); rt->vanilla = new_one_off_HSPScanInterface(sli,mat,drop_off,score_cutoff); rt->threaded = new_threaded_HSPScanInterface(sli,mat,drop_off,score_cutoff,threadno); rt->twohit = new_twohit_one_off_HSPScanInterface(sli,mat,drop_off,score_cutoff); out->data = (void*) rt; out->free_data = free_runtime_hspscan; out->scan_query = scan_query_runtime_hspscan; return out; } /* Function: scan_query_runtime_hspscan(data,seq,para) * * Descrip: Handles runtime switching between methods for the scan query * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 48 "hspscanruntime.dy" LinearHSPmanager * scan_query_runtime_hspscan(void * data,Sequence * seq,HSPScanInterfacePara * para) { HSPScanRuntimeImpl * d; d = (HSPScanRuntimeImpl *) data; switch(para->implementation) { case HSPSCAN_IMPLEMENTATION_VANILLA : return (*d->vanilla->scan_query)(d->vanilla->data,seq,para); case HSPSCAN_IMPLEMENTATION_THREADED : return (*d->threaded->scan_query)(d->threaded->data,seq,para); case HSPSCAN_IMPLEMENTATION_TWOHIT : return (*d->twohit->scan_query)(d->twohit->data,seq,para); default : warn("No good implementation for %d as implementation",para->implementation); } return NULL; } /* Function: free_runtime_hspscan(data) * * Descrip: free function for runtime * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 72 "hspscanruntime.dy" void free_runtime_hspscan(void * data) { HSPScanRuntimeImpl * d; d = (HSPScanRuntimeImpl *) data; free_HSPScanRuntimeImpl(d); } # line 89 "hspscanruntime.c" /* Function: hard_link_HSPScanRuntimeImpl(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPScanRuntimeImpl *] * * Return [UNKN ] Undocumented return value [HSPScanRuntimeImpl *] * */ HSPScanRuntimeImpl * hard_link_HSPScanRuntimeImpl(HSPScanRuntimeImpl * obj) { if( obj == NULL ) { warn("Trying to hard link to a HSPScanRuntimeImpl object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HSPScanRuntimeImpl_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPScanRuntimeImpl *] * */ HSPScanRuntimeImpl * HSPScanRuntimeImpl_alloc(void) { HSPScanRuntimeImpl * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HSPScanRuntimeImpl *) ckalloc (sizeof(HSPScanRuntimeImpl))) == NULL) { warn("HSPScanRuntimeImpl_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->vanilla = NULL; out->threaded = NULL; out->twohit = NULL; return out; } /* Function: free_HSPScanRuntimeImpl(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPScanRuntimeImpl *] * * Return [UNKN ] Undocumented return value [HSPScanRuntimeImpl *] * */ HSPScanRuntimeImpl * free_HSPScanRuntimeImpl(HSPScanRuntimeImpl * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HSPScanRuntimeImpl obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->vanilla != NULL) free_HSPScanInterface(obj->vanilla); if( obj->threaded != NULL) free_HSPScanInterface(obj->threaded); if( obj->twohit != NULL) free_HSPScanInterface(obj->twohit); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/hspscanruntime.h0000644000175000001440000001030310670453712020047 0ustar philippusers#ifndef DYNAMITEhspscanruntimeHEADERFILE #define DYNAMITEhspscanruntimeHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "hsplookupscan.h" #include "hsplookupthreaded.h" #include "hsptwohitscan.h" struct Wise2_HSPScanRuntimeImpl { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif HSPScanInterface * vanilla; HSPScanInterface * threaded; HSPScanInterface * twohit; } ; /* HSPScanRuntimeImpl defined */ #ifndef DYNAMITE_DEFINED_HSPScanRuntimeImpl typedef struct Wise2_HSPScanRuntimeImpl Wise2_HSPScanRuntimeImpl; #define HSPScanRuntimeImpl Wise2_HSPScanRuntimeImpl #define DYNAMITE_DEFINED_HSPScanRuntimeImpl #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_runtime_HSPScanInterface(sli,mat,drop_off,score_cutoff,threadno) * * Descrip: Makes a new function which will at runtime switch between * implementation; vanilla, threaded and twohit * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * Arg: threadno [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ HSPScanInterface * Wise2_new_runtime_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff,int threadno); #define new_runtime_HSPScanInterface Wise2_new_runtime_HSPScanInterface /* Function: scan_query_runtime_hspscan(data,seq,para) * * Descrip: Handles runtime switching between methods for the scan query * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_scan_query_runtime_hspscan(void * data,Sequence * seq,HSPScanInterfacePara * para); #define scan_query_runtime_hspscan Wise2_scan_query_runtime_hspscan /* Function: free_runtime_hspscan(data) * * Descrip: free function for runtime * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_runtime_hspscan(void * data); #define free_runtime_hspscan Wise2_free_runtime_hspscan /* Function: hard_link_HSPScanRuntimeImpl(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPScanRuntimeImpl *] * * Return [UNKN ] Undocumented return value [HSPScanRuntimeImpl *] * */ HSPScanRuntimeImpl * Wise2_hard_link_HSPScanRuntimeImpl(HSPScanRuntimeImpl * obj); #define hard_link_HSPScanRuntimeImpl Wise2_hard_link_HSPScanRuntimeImpl /* Function: HSPScanRuntimeImpl_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPScanRuntimeImpl *] * */ HSPScanRuntimeImpl * Wise2_HSPScanRuntimeImpl_alloc(void); #define HSPScanRuntimeImpl_alloc Wise2_HSPScanRuntimeImpl_alloc /* Function: free_HSPScanRuntimeImpl(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPScanRuntimeImpl *] * * Return [UNKN ] Undocumented return value [HSPScanRuntimeImpl *] * */ HSPScanRuntimeImpl * Wise2_free_HSPScanRuntimeImpl(HSPScanRuntimeImpl * obj); #define free_HSPScanRuntimeImpl Wise2_free_HSPScanRuntimeImpl /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/histogram.c0000644000175000001440000013404510670453712017006 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "histogram.h" /* Function: Evalue_from_Histogram(his,score) * * Descrip: No Description * * Arg: his [UNKN ] Histogram object [Histogram *] * Arg: score [UNKN ] score you want the evalue for [double] * * Return [UNKN ] Undocumented return value [double] * */ # line 85 "histogram.dy" double Evalue_from_Histogram(Histogram * his,double score) { return ExtremeValueE(score,his->param[EVD_MU],his->param[EVD_LAMBDA],his->total); } /* Function: new_Histogram(min,max,lumpsize) * * Descrip: No Description * * Arg: min [UNKN ] minimum score (integer) [int] * Arg: max [UNKN ] maximum score (integer) [int] * Arg: lumpsize [UNKN ] when reallocating histogram, the reallocation amount [int] * * Return [UNKN ] Undocumented return value [Histogram *] * */ # line 113 "histogram.dy" Histogram * new_Histogram(int min, int max, int lumpsize) { Histogram *h; int newsize; int i; newsize = max - min + 1; h = Histogram_alloc(); /* ewan changed */ if( h == NULL ) { return NULL; } h->min = min; h->max = max; h->total = 0; h->lowscore = INT_MAX; h->highscore = INT_MIN; h->lumpsize = lumpsize; h->histogram = (int *) ckcalloc (newsize,sizeof(int)); /* ewan changed */ for (i = 0; i < newsize; i++) h->histogram[i] = 0; h->expect = NULL; h->fit_type = HISTFIT_NONE; h->param[EVD_WONKA] = 1.0; /* just in case, make sure this initializes */ return h; } /* Function: UnfitHistogram(h) * * Descrip: No Description * * Arg: h [UNKN ] Undocumented argument [Histogram *] * */ # line 156 "histogram.dy" void UnfitHistogram(Histogram * h) { if (h->expect != NULL) ckfree(h->expect); h->expect = NULL; h->fit_type = HISTFIT_NONE; } /* Function: AddToHistogram(h,sc) * * Descrip: No Description * * Arg: h [UNKN ] Undocumented argument [Histogram *] * Arg: sc [UNKN ] Undocumented argument [float] * */ # line 182 "histogram.dy" void AddToHistogram(Histogram * h, float sc) { int score; int moveby; int prevsize; int newsize; int i; /* Adding to a histogram conflicts with existing fit: * prohibit this. */ if (h->fit_type != HISTFIT_NONE) fatal("AddToHistogram(): Can't add to a fitted histogram\n"); /* histogram bins are defined as: score >= bin value, < bin+1 * -1.9 -> -2 -0.4 -> -1 1.9 -> 1 * -2.1 -> -3 0.4 -> 0 2.1 -> 2 */ score = (int) floor(sc); /* Check to see if we must reallocate the histogram. */ if (score < h->min) { prevsize = h->max - h->min + 1; moveby = (h->min - score) + h->lumpsize; newsize = prevsize + moveby; h->min -= moveby; h->histogram = (int *) ckrealloc(h->histogram, sizeof(int) * newsize); if( h->histogram == NULL ) { fatal("Unable to extend histogram... have to crash... sorry!"); } memmove(h->histogram+moveby, h->histogram, sizeof(int) * prevsize); for (i = 0; i < moveby; i++) h->histogram[i] = 0; } else if (score > h->max) { prevsize = h->max - h->min + 1; h->max = h->lumpsize + score; newsize = h->max - h->min + 1; h->histogram = (int *) ckrealloc(h->histogram, sizeof(int) * newsize); if( h->histogram == NULL ) { fatal("Cannot realloc histogram... going to die... sorry!"); } for (i = prevsize; i < newsize; i++) h->histogram[i] = 0; } /* Bump the correct bin. * The bin number is score - h->min */ h->histogram[score - h->min]++; h->total++; if (score < h->lowscore) h->lowscore = score; if (score > h->highscore) h->highscore = score; #if DEBUG fprintf(stderr, "AddToHistogram(): added %.1f; rounded to %d; in bin %d (%d-%d)\n", sc, score, score-h->min, h->min, h->max); #endif return; } /* Function: PrintASCIIHistogram(h,fp) * * Descrip: No Description * * Arg: h [UNKN ] histogram to print [Histogram *] * Arg: fp [UNKN ] open file to print to (stdout works) [FILE *] * */ # line 268 "histogram.dy" void PrintASCIIHistogram(Histogram * h,FILE * fp) { int units; int maxbar; int num; int i, idx; char buffer[81]; /* output line buffer */ int pos; /* position in output line buffer */ int lowbound, lowcount; /* cutoffs on the low side */ int highbound, highcount; /* cutoffs on the high side */ int emptybins = 3; /* Find out how we'll scale the histogram. * We have 59 characters to play with on a * standard 80-column terminal display: * leading "%5d %6d %6d|" occupies 20 chars. * Save the peak position, we'll use it later. */ maxbar = 0; for (i = h->lowscore - h->min; i <= h->highscore - h->min; i++) if (h->histogram[i] > maxbar) { maxbar = h->histogram[i]; /* max height */ lowbound = i + h->min; /* peak position */ } /* Truncate histogram display on both sides, ad hoc fashion. * Start from the peak; then move out until we see empty bins, * and stop. */ highbound = lowbound; /* start at peak position */ for (num = 0; lowbound > h->lowscore; lowbound--) { i = lowbound - h->min; if (h->histogram[i] > 0) { num = 0; continue; } /* reset */ if (++num == emptybins) { lowbound += emptybins; break; } /* stop */ } for (num = 0; highbound < h->highscore; highbound++) { i = highbound - h->min; if (h->histogram[i] > 0) { num = 0; continue; } /* reset */ if (++num == emptybins) { highbound -= emptybins; break; } /* stop */ } /* collect counts outside of bounds */ for (lowcount = 0, i = h->lowscore - h->min; i <= lowbound - h->min; i++) lowcount += h->histogram[i]; for (highcount = 0, i = h->highscore - h->min; i >= highbound - h->min; i--) highcount += h->histogram[i]; /* maxbar might need raised now; then set our units */ if (lowcount > maxbar) maxbar = lowcount; if (highcount > maxbar) maxbar = highcount; units = ((maxbar-1)/ 59) + 1; /* Print the histogram */ fprintf(fp, "%5s %6s %6s (one = represents %d sequences)\n", "score", "obs", "exp", units); fprintf(fp, "%5s %6s %6s\n", "-----", "---", "---"); buffer[80] = '\0'; buffer[79] = '\n'; for (i = h->lowscore; i <= h->highscore; i++) { memset(buffer, ' ', 79 * sizeof(char)); idx = i - h->min; /* Deal with special cases at edges */ if (i < lowbound) continue; else if (i > highbound) continue; else if (i == lowbound && i != h->lowscore) { sprintf(buffer, "<%4d %6d %6s|", i+1, lowcount, "-"); if (lowcount > 0) { num = 1+(lowcount-1) / units; if (num > 60) fatal("oops - more than 60 somethings in printing... "); for (pos = 20; num > 0; num--) buffer[pos++] = '='; } fputs(buffer, fp); continue; } else if (i == highbound && i != h->highscore) { sprintf(buffer, ">%4d %6d %6s|", i, highcount, "-"); if (highcount > 0) { num = 1+(highcount-1) / units; for (pos = 20; num > 0; num--) buffer[pos++] = '='; } fputs(buffer, fp); continue; } /* Deal with most cases */ if (h->fit_type != HISTFIT_NONE) sprintf(buffer, "%5d %6d %6d|", i, h->histogram[idx], (int) h->expect[idx]); else sprintf(buffer, "%5d %6d %6s|", i, h->histogram[idx], "-"); buffer[20] = ' '; /* sprintf writes a null char */ /* Mark the histogram bar for observed hits */ if (h->histogram[idx] > 0) { num = 1 + (h->histogram[idx]-1) / units; for (pos = 20; num > 0; num--) buffer[pos++] = '='; } /* Mark the theoretically expected value */ if (h->fit_type != HISTFIT_NONE && (int) h->expect[idx] > 0) { /* "corrected" line */ #ifdef SRE_REMOVED if (h->fit_type == HISTFIT_EVD) { pos = 20 + (int)(h->param[EVD_WONKA] * h->expect[idx] - 1) / units; if (pos >= 78) pos = 78; /* be careful of buffer bounds */ buffer[pos] = 'o'; } #endif /* true (uncorrected) line */ pos = 20 + (int)(h->expect[idx]-1) / units; if (pos >= 78) pos = 78; /* be careful of buffer bounds */ buffer[pos] = '*'; } /* Print the line */ fputs(buffer, fp); } /* Print details about the statistics */ switch (h->fit_type) { case HISTFIT_NONE: fprintf(fp, "\n\n%% No statistical fit available\n"); break; case HISTFIT_EVD: fprintf(fp, "\n\n%% Statistical details of theoretical EVD fit:\n"); fprintf(fp, " mu = %10.4f\n", h->param[EVD_MU]); fprintf(fp, " lambda = %10.4f\n", h->param[EVD_LAMBDA]); #ifdef SRE_REMOVED fprintf(fp, " fraction fit = %10.4f\n", h->param[EVD_WONKA]); #endif fprintf(fp, "chi-sq statistic = %10.4f\n", h->chisq); fprintf(fp, " P(chi-square) = %10.4g\n", h->chip); break; case HISTFIT_GAUSSIAN: fprintf(fp, "\n\n%% Statistical details of theoretical Gaussian fit:\n"); fprintf(fp, " mean = %10.4f\n", h->param[GAUSS_MEAN]); fprintf(fp, " sd = %10.4f\n", h->param[GAUSS_SD]); fprintf(fp, "chi-sq statistic = %10.4f\n", h->chisq); fprintf(fp, " P(chi-square) = %10.4g\n", h->chip); break; } return; } /* Function: EVDBasicFit(h) * * Descrip: No Description * * Arg: h [UNKN ] histogram to fit [Histogram *] * */ # line 456 "histogram.dy" void EVDBasicFit(Histogram * h) { float *d; /* distribution P(S < x) */ float *x; /* x-axis of P(Smin */ float slope, intercept; /* m,b fit from Linefit() */ float corr; /* correlation coeff of line fit, not used */ float lambda, mu; /* slope, intercept converted to EVD params */ /* Allocations for x, y axes * distribution d runs from min..max with indices 0..max-min * i.e. score - min = index into d, x, histogram, and expect */ hsize = h->highscore - h->lowscore + 1; d = (float *) ckalloc(sizeof(float) * hsize); x = (float *) ckalloc(sizeof(float) * hsize); for (idx = 0; idx < hsize; idx++) d[idx] = x[idx] = 0.; /* Calculate P(S < x) distribution from histogram. * note off-by-one of sc, because histogram bin contains scores between * x and x+1. */ sum = 0; for (sc = h->lowscore; sc <= h->highscore; sc++) { sum += h->histogram[sc - h->min]; d[sc - h->lowscore] = (float) sum / (float) h->total; x[sc - h->lowscore] = (float) (sc + 1); } /* Do a linear regression fit to the log[-log(P(Sx))] = -lambda * x + lambda * mu * so lambda = -m and mu = b/lambda */ /* convert y axis to log[-log(P(Slowscore; sc < h->highscore; sc++) d[sc - h->lowscore] = log(-1. * log(d[sc - h->lowscore])); /* do the linear regression */ Linefit(x, d, hsize-1, &intercept, &slope, &corr); /* calc mu, lambda */ lambda = -1. * slope; mu = intercept / lambda; /* Set the EVD parameters in the histogram; * pass 2 for additional lost degrees of freedom because we fit mu, lambda. */ ExtremeValueSetHistogram(h, mu, lambda, h->lowscore, h->highscore, 1.0, 2); free(x); free(d); return; } /* Function: ExtremeValueFitHistogram(h,censor,high_hint) * * Descrip: No Description * * Arg: h [UNKN ] histogram to fit [Histogram *] * Arg: censor [UNKN ] TRUE to censor data left of the peak [int] * Arg: high_hint [UNKN ] score cutoff; above this are real hits that arent fit [float] * * Return [UNKN ] if fit is judged to be valid else 0 if fit is invalid (too few seqs.) [int] * */ # line 540 "histogram.dy" int ExtremeValueFitHistogram(Histogram * h, int censor, float high_hint) { float *x; /* array of EVD samples to fit */ int *y; /* histogram counts */ int n; /* number of observed samples */ int z; /* number of censored samples */ int hsize; /* size of histogram */ float lambda, mu; /* new estimates of lambda, mu */ int sc; /* loop index for score */ int lowbound; /* lower bound of fitted region*/ int highbound; /* upper bound of fitted region*/ int new_highbound; int iteration; /* Determine lower bound on fitted region; * if we're censoring the data, choose the peak of the histogram. * if we're not, then we take the whole histogram. */ lowbound = h->lowscore; if (censor) { int max = -1; for (sc = h->lowscore; sc <= h->highscore; sc++) if (h->histogram[sc - h->min] > max) { max = h->histogram[sc - h->min]; lowbound = sc; } } /* Determine initial upper bound on fitted region. */ highbound = MIN(high_hint, h->highscore); /* Now, iteratively converge on our lambda, mu: */ for (iteration = 0; iteration < 100; iteration++) { /* Construct x, y vectors. */ x = NULL; y = NULL; hsize = highbound - lowbound + 1; if (hsize < 5) { warn("On iteration %d, got %d bins, which is not fitable",iteration,hsize); goto FITFAILED; /* require at least 5 bins or we don't fit */ } x = ckalloc(sizeof(float) * hsize); y = ckalloc(sizeof(int) * hsize); if( x == NULL || y == NULL ) { warn("Out of temporary memory for evd fitting... exiting with error, though I'd worry about this"); return 0; } n = 0; for (sc = lowbound; sc <= highbound; sc++) { x[sc-lowbound] = (float) sc + 0.5; /* crude, but tests OK */ y[sc-lowbound] = h->histogram[sc - h->min]; n += h->histogram[sc - h->min]; } if (n < 100) { warn("On iteration %d, got only %d points, which is not fitable",iteration,n); goto FITFAILED; /* require fitting to at least 100 points */ } /* If we're censoring, estimate z, the number of censored guys * left of the bound. Our initial estimate is crudely that we're * missing e^-1 of the total distribution (which would be exact * if we censored exactly at mu; but we censored at the observed peak). * Subsequent estimates are more exact based on our current estimate of mu. */ if (censor) { if (iteration == 0) z = MIN(h->total-n, (int) (0.58198 * (float) n)); else { double psx; psx = EVDDistribution((float) lowbound, mu, lambda); z = MIN(h->total-n, (int) ((double) n * psx / (1. - psx))); } } /* Do an ML fit */ if (censor) { if (! EVDCensoredFit(x, y, hsize, z, (float) lowbound, &mu, &lambda)) { warn("On iteration %d, unable to make maxlikehood evd fit with censor",iteration); goto FITFAILED; } } else { if (! EVDMaxLikelyFit(x, y, hsize, &mu, &lambda)) { warn("On iteration %d, unable to make maxlikehood evd fit without censor",iteration); goto FITFAILED; } } /* Find the Eval = 1 point as a new highbound; * the total number of samples estimated to "belong" to the EVD is n+z */ new_highbound = (int) (mu - (log (-1. * log((double) (n+z-1) / (double)(n+z))) / lambda)); free(x); free(y); if (new_highbound >= highbound) break; highbound = new_highbound; } /* Set the histogram parameters; * - the wonka factor is n+z / h->total : e.g. that's the fraction of the * hits that we expect to match the EVD, others are generally lower * - we fit from lowbound to highbound; thus we lose 2 degrees of freedom * for fitting mu, lambda, but we get 1 back because we're unnormalized * in this interval, hence we pass 2-1 = 1 as ndegrees. * * Mon Jan 19 06:18:14 1998: wonka = 1.0, temporarily disabled. */ ExtremeValueSetHistogram(h, mu, lambda, lowbound, highbound, 1.0, 1); return 1; FITFAILED: UnfitHistogram(h); if (x != NULL) free(x); if (y != NULL) free(y); return 0; } /* Function: ExtremeValueSetHistogram(h,mu,lambda,lowbound,highbound,wonka,ndegrees) * * Descrip: No Description * * Arg: h [UNKN ] the histogram to set [Histogram *] * Arg: mu [UNKN ] mu location parameter [float] * Arg: lambda [UNKN ] lambda scale parameter [float] * Arg: lowbound [UNKN ] low bound of the histogram that was fit [float] * Arg: highbound [UNKN ] high bound of histogram that was fit [float] * Arg: wonka [UNKN ] fudge factor; fraction of hits estimated to be "EVD-like" [float] * Arg: ndegrees [UNKN ] extra degrees of freedom to subtract in chi2 test: [int] * */ # line 702 "histogram.dy" void ExtremeValueSetHistogram(Histogram * h, float mu, float lambda, float lowbound, float highbound, float wonka, int ndegrees) { int sc; int hsize, idx; int nbins; float delta; UnfitHistogram(h); h->fit_type = HISTFIT_EVD; h->param[EVD_LAMBDA] = lambda; h->param[EVD_MU] = mu; h->param[EVD_WONKA] = wonka; hsize = h->max - h->min + 1; h->expect = (float *) ckalloc(sizeof(float) * hsize); if( h->expect == NULL ) { fatal("Cannot make memory for expect thing... "); } for (idx = 0; idx < hsize; idx++) h->expect[idx] = 0.; /* Calculate the expected values for the histogram. */ for (sc = h->min; sc <= h->max; sc++) h->expect[sc - h->min] = ExtremeValueE((float)(sc), h->param[EVD_MU], h->param[EVD_LAMBDA], h->total) - ExtremeValueE((float)(sc+1), h->param[EVD_MU], h->param[EVD_LAMBDA], h->total); /* Calculate the goodness-of-fit (within whole region) */ h->chisq = 0.; nbins = 0; for (sc = lowbound; sc <= highbound; sc++) if (h->expect[sc-h->min] >= 5. && h->histogram[sc-h->min] >= 5) { delta = (float) h->histogram[sc-h->min] - h->expect[sc-h->min]; h->chisq += delta * delta / h->expect[sc-h->min]; nbins++; } /* Since we fit the whole histogram, there is at least * one constraint on chi-square: the normalization to h->total. */ if (nbins > 1 + ndegrees) h->chip = (float) IncompleteGamma((double)(nbins-1-ndegrees)/2., (double) h->chisq/2.); else h->chip = 0.; } /* Function: GaussianFitHistogram(h,high_hint) * * Descrip: No Description * * Arg: h [UNKN ] histogram to fit [Histogram *] * Arg: high_hint [UNKN ] score cutoff; above this are `real' hits that aren't fit [float] * * Return [UNKN ] if fit is judged to be valid else 0 if fit is invalid (too few seqs.) [int] * */ # line 777 "histogram.dy" int GaussianFitHistogram(Histogram * h, float high_hint) { float sum; float sqsum; float delta; int sc; int nbins; int hsize, idx; /* Clear any previous fitting from the histogram. */ UnfitHistogram(h); /* Determine if we have enough hits to fit the histogram; * arbitrarily require 1000. */ if (h->total < 1000) { h->fit_type = HISTFIT_NONE; return 0; } /* Simplest algorithm for mean and sd; * no outlier detection yet (not even using high_hint) * * Magic 0.5 correction is because our histogram is for * scores between x and x+1; we estimate the expectation * (roughly) as x + 0.5. */ sum = sqsum = 0.; for (sc = h->lowscore; sc <= h->highscore; sc++) { delta = (float) sc + 0.5; sum += (float) h->histogram[sc-h->min] * delta; sqsum += (float) h->histogram[sc-h->min] * delta * delta; } h->fit_type = HISTFIT_GAUSSIAN; h->param[GAUSS_MEAN] = sum / (float) h->total; h->param[GAUSS_SD] = sqrt((sqsum - (sum*sum/(float)h->total)) / (float)(h->total-1)); /* Calculate the expected values for the histogram. * Note that the magic 0.5 correction appears again. * Calculating difference between distribution functions for Gaussian * would be correct but hard. */ hsize = h->max - h->min + 1; h->expect = (float *) ckalloc(sizeof(float) * hsize); if( h->expect == NULL ) { fatal("Unable to allocate expect space in histogram... sorry!"); } for (idx = 0; idx < hsize; idx++) h->expect[idx] = 0.; for (sc = h->min; sc <= h->max; sc++) { delta = (float) sc + 0.5 - h->param[GAUSS_MEAN]; h->expect[sc - h->min] = (float) h->total * ((1. / (h->param[GAUSS_SD] * sqrt(2.*3.14159))) * (exp(-1.* delta*delta / (2. * h->param[GAUSS_SD] * h->param[GAUSS_SD])))); } /* Calculate the goodness-of-fit (within region that was fitted) */ h->chisq = 0.; nbins = 0; for (sc = h->lowscore; sc <= h->highscore; sc++) if (h->expect[sc-h->min] >= 5. && h->histogram[sc-h->min] >= 5) { delta = (float) h->histogram[sc-h->min] - h->expect[sc-h->min]; h->chisq += delta * delta / h->expect[sc-h->min]; nbins++; } /* -1 d.f. for normalization; -2 d.f. for two free parameters */ if (nbins > 3) h->chip = (float) IncompleteGamma((double)(nbins-3)/2., (double) h->chisq/2.); else h->chip = 0.; return 1; } /* Function: GaussianSetHistogram(h,mean,sd) * * Descrip: No Description * * Arg: h [UNKN ] Undocumented argument [Histogram *] * Arg: mean [UNKN ] Undocumented argument [float] * Arg: sd [UNKN ] Undocumented argument [float] * */ # line 871 "histogram.dy" void GaussianSetHistogram(Histogram * h, float mean, float sd) { int sc; int hsize, idx; int nbins; float delta; UnfitHistogram(h); h->fit_type = HISTFIT_GAUSSIAN; h->param[GAUSS_MEAN] = mean; h->param[GAUSS_SD] = sd; /* Calculate the expected values for the histogram. */ hsize = h->max - h->min + 1; h->expect = (float *) ckalloc(sizeof(float) * hsize); if( h->expect == NULL ) { fatal("Unable to allocate expect size in expected histogram..."); } for (idx = 0; idx < hsize; idx++) h->expect[idx] = 0.; /* Note: ideally we'd use the Gaussian distribution function * to find the histogram occupancy in the window sc..sc+1. * However, the distribution function is hard to calculate. * Instead, estimate the histogram by taking the density at sc+0.5. */ for (sc = h->min; sc <= h->max; sc++) { delta = ((float)sc + 0.5) - h->param[GAUSS_MEAN]; h->expect[sc - h->min] = (float) h->total * ((1. / (h->param[GAUSS_SD] * sqrt(2.*3.14159))) * (exp(-1.*delta*delta / (2. * h->param[GAUSS_SD] * h->param[GAUSS_SD])))); } /* Calculate the goodness-of-fit (within whole region) */ h->chisq = 0.; nbins = 0; for (sc = h->lowscore; sc <= h->highscore; sc++) if (h->expect[sc-h->min] >= 5. && h->histogram[sc-h->min] >= 5) { delta = (float) h->histogram[sc-h->min] - h->expect[sc-h->min]; h->chisq += delta * delta / h->expect[sc-h->min]; nbins++; } /* -1 d.f. for normalization */ if (nbins > 1) h->chip = (float) IncompleteGamma((double)(nbins-1)/2., (double) h->chisq/2.); else h->chip = 0.; } /* Function: EVDDensity(x,mu,lambda) * * Descrip: No Description * * Arg: x [UNKN ] Undocumented argument [float] * Arg: mu [UNKN ] Undocumented argument [float] * Arg: lambda [UNKN ] Undocumented argument [float] * * Return [UNKN ] Undocumented return value [double] * */ # line 942 "histogram.dy" double EVDDensity(float x, float mu, float lambda) { return (lambda * exp(-1. * lambda * (x - mu) - exp(-1. * lambda * (x - mu)))); } /* Function: EVDDistribution(x,mu,lambda) * * Descrip: No Description * * Arg: x [UNKN ] Undocumented argument [float] * Arg: mu [UNKN ] Undocumented argument [float] * Arg: lambda [UNKN ] Undocumented argument [float] * * Return [UNKN ] Undocumented return value [double] * */ # line 962 "histogram.dy" double EVDDistribution(float x, float mu, float lambda) { return (exp(-1. * exp(-1. * lambda * (x - mu)))); } /* Function: ExtremeValueP(x,mu,lambda) * * Descrip: No Description * * Arg: x [UNKN ] score [float] * Arg: mu [UNKN ] characteristic value of extreme value distribution [float] * Arg: lambda [UNKN ] decay constant of extreme value distribution [float] * * Return [UNKN ] P(S>x) [double] * */ # line 988 "histogram.dy" double ExtremeValueP(float x, float mu, float lambda) { double y; /* a roundoff issue arises; use 1 - e^-x --> x for small x */ y = exp(-1. * lambda * (x - mu)); if (y < 1e-7) return y; else return (1.0 - exp(-1. * y)); } /* Function: ExtremeValueP2(x,mu,lambda,N) * * Descrip: No Description * * Arg: x [UNKN ] score [float] * Arg: mu [UNKN ] characteristic value of extreme value distribution [float] * Arg: lambda [UNKN ] decay constant of extreme value distribution [float] * Arg: N [UNKN ] number of trials (number of sequences) [int] * * Return [UNKN ] P(S>x) for database of size N [double] * */ # line 1018 "histogram.dy" double ExtremeValueP2(float x, float mu, float lambda, int N) { double y; y = N * ExtremeValueP(x,mu,lambda); if (y < 1e-7) return y; else return (1.0 - exp(-1. * y)); } /* Function: ExtremeValueE(x,mu,lambda,N) * * Descrip: No Description * * Arg: x [UNKN ] score [float] * Arg: mu [UNKN ] characteristic value of extreme value distribution [float] * Arg: lambda [UNKN ] decay constant of extreme value distribution [float] * Arg: N [UNKN ] number of trials (number of sequences) [int] * * Return [UNKN ] E(S>x) for database of size N [double] * */ # line 1046 "histogram.dy" double ExtremeValueE(float x, float mu, float lambda, int N) { return (double)N * ExtremeValueP(x,mu,lambda); } /* Function: EVDrandom(mu,lambda) * * Descrip: No Description * * Arg: mu [UNKN ] Undocumented argument [float] * Arg: lambda [UNKN ] Undocumented argument [float] * * Return [UNKN ] Undocumented return value [float] * */ # line 1068 "histogram.dy" float EVDrandom(float mu, float lambda) { float p = 0.0; /* Very unlikely, but possible, * that sre_random() would give us exactly 0 or 1 */ while (p == 0. || p == 1.) p = sre_random(); return mu - log(-1. * log(p)) / lambda; } /* Function: Lawless416(ret_f,ret_df,y,*x,x,*y,n,lambda,*ret_f,*ret_df) * * Descrip: No Description * * Arg: ret_f [WRITE] RETURN: 4.1.6 evaluated at lambda [NullString] * Arg: ret_df [WRITE] RETURN: first derivative of 4.1.6 evaluated at lambda [NullString] * Arg: y [UNKN ] NULL (or y-axis of a histogram) [NullString] * Arg: *x [UNKN ] Undocumented argument [float] * Arg: x [UNKN ] array of sample values (or x-axis of a histogram) [NullString] * Arg: *y [UNKN ] Undocumented argument [int] * Arg: n [UNKN ] number of samples (or number of histogram bins) [int] * Arg: lambda [UNKN ] a lambda to test [float] * Arg: *ret_f [UNKN ] Undocumented argument [float] * Arg: *ret_df [UNKN ] Undocumented argument [float] * */ # line 1107 "histogram.dy" void Lawless416(float *x, int *y, int n, float lambda, float *ret_f, float *ret_df) { double esum; /* \sum e^(-lambda xi) */ double xesum; /* \sum xi e^(-lambda xi) */ double xxesum; /* \sum xi^2 e^(-lambda xi) */ double xsum; /* \sum xi */ double mult; /* histogram count multiplier */ double total; /* total samples */ int i; esum = xesum = xsum = xxesum = total = 0.; for (i = 0; i < n; i++) { mult = (y == NULL) ? 1. : (double) y[i]; xsum += mult * x[i]; xesum += mult * x[i] * exp(-1. * lambda * x[i]); xxesum += mult * x[i] * x[i] * exp(-1. * lambda * x[i]); esum += mult * exp(-1. * lambda * x[i]); total += mult; } *ret_f = 1./lambda - xsum / total + xesum / esum; *ret_df = ((xesum / esum) * (xesum / esum)) - (xxesum / esum) - (1. / (lambda * lambda)); return; } /* Function: Lawless422(*x,ret_df,y,ret_f,x,*y,n,z,c,lambda,*ret_f,*ret_df) * * Descrip: No Description * * Arg: *x [UNKN ] Undocumented argument [float] * Arg: ret_df [WRITE] RETURN: first derivative of 4.2.2 evaluated at lambda [NullString] * Arg: y [UNKN ] NULL (or y axis of a histogram) [NullString] * Arg: ret_f [WRITE] RETURN: 4.2.2 evaluated at lambda [NullString] * Arg: x [UNKN ] array of sample values (or x axis of a histogram) [NullString] * Arg: *y [UNKN ] Undocumented argument [int] * Arg: n [UNKN ] number of observed samples (or number of histogram bins) [int] * Arg: z [UNKN ] number of censored samples [int] * Arg: c [UNKN ] censoring value; all observed x_i >= c [float] * Arg: lambda [UNKN ] a lambda to test [float] * Arg: *ret_f [UNKN ] Undocumented argument [float] * Arg: *ret_df [UNKN ] Undocumented argument [float] * */ # line 1170 "histogram.dy" void Lawless422(float *x, int *y, int n, int z, float c,float lambda, float *ret_f, float *ret_df) { double esum; /* \sum e^(-lambda xi) + z term */ double xesum; /* \sum xi e^(-lambda xi) + z term */ double xxesum; /* \sum xi^2 e^(-lambda xi) + z term */ double xsum; /* \sum xi (no z term) */ double mult; /* histogram count multiplier */ double total; /* total samples */ int i; esum = xesum = xsum = xxesum = total = 0.; for (i = 0; i < n; i++) { mult = (y == NULL) ? 1. : (double) y[i]; xsum += mult * x[i]; esum += mult * exp(-1. * lambda * x[i]); xesum += mult * x[i] * exp(-1. * lambda * x[i]); xxesum += mult * x[i] * x[i] * exp(-1. * lambda * x[i]); total += mult; } /* Add z terms for censored data */ esum += (double) z * exp(-1. * lambda * c); xesum += (double) z * c * exp(-1. * lambda * c); xxesum += (double) z * c * c * exp(-1. * lambda * c); *ret_f = 1./lambda - xsum / total + xesum / esum; *ret_df = ((xesum / esum) * (xesum / esum)) - (xxesum / esum) - (1. / (lambda * lambda)); return; } /* Function: EVDMaxLikelyFit(ret_lambda,x,*x,c,ret_mu,*c,n,*ret_mu,*ret_lambda) * * Descrip: No Description * * Arg: ret_lambda [WRITE] RETURN: ML estimate of lambda [NullString] * Arg: x [UNKN ] list of EVD distributed samples or x axis of histogram [NullString] * Arg: *x [UNKN ] Undocumented argument [float] * Arg: c [UNKN ] NULL, or y-axis of histogram [NullString] * Arg: ret_mu [WRITE] RETURN: ML estimate of mu [NullString] * Arg: *c [UNKN ] Undocumented argument [int] * Arg: n [UNKN ] number of samples, or number of histogram bins [int] * Arg: *ret_mu [UNKN ] Undocumented argument [float] * Arg: *ret_lambda [UNKN ] Undocumented argument [float] * * Return [UNKN ] on success; 0 on any failure [int] * */ # line 1238 "histogram.dy" int EVDMaxLikelyFit(float *x, int *c, int n, float *ret_mu, float *ret_lambda) { float lambda, mu; float fx; /* f(x) */ float dfx; /* f'(x) */ double esum; /* \sum e^(-lambda xi) */ double mult; double total; float tol = 1e-5; int i; /* 1. Find an initial guess at lambda: linear regression here? */ lambda = 0.2; /* 2. Use Newton/Raphson to solve Lawless 4.1.6 and find ML lambda */ for (i = 0; i < 100; i++) { Lawless416(x, c, n, lambda, &fx, &dfx); if (fabs(fx) < tol) break; /* success */ lambda = lambda - fx / dfx; /* Newton/Raphson is simple */ if (lambda <= 0.) lambda = 0.001; /* but be a little careful */ } /* 2.5: If we did 100 iterations but didn't converge, Newton/Raphson failed. * Resort to a bisection search. Worse convergence speed * but guaranteed to converge (unlike Newton/Raphson). * We assume (!?) that fx is a monotonically decreasing function of x; * i.e. fx > 0 if we are left of the root, fx < 0 if we * are right of the root. */ if (i == 100) { float left, right, mid; info("EVD maxlik fit - Newton/Raphson failed; switchover to bisection"); /* First we need to bracket the root */ lambda = right = left = 0.2; Lawless416(x, c, n, lambda, &fx, &dfx); if (fx < 0.) { /* fix right; search left. */ do { left -= 0.1; if (left < 0.) { info("failed to bracket root"); return 0; } Lawless416(x, c, n, left, &fx, &dfx); } while (fx < 0.); } else { /* fix left; search right. */ do { right += 0.1; Lawless416(x, c, n, right, &fx, &dfx); if (right > 100.) { info("failed to bracket root"); return 0; } } while (fx > 0.); } /* now we bisection search in left/right interval */ for (i = 0; i < 100; i++) { mid = (left + right) / 2.; Lawless416(x, c, n, mid, &fx, &dfx); if (fabs(fx) < tol) break; /* success */ if (fx > 0.) left = mid; else right = mid; } if (i == 100) { warn("even the bisection search failed"); return 0; } lambda = mid; } /* 3. Substitute into Lawless 4.1.5 to find mu */ esum = 0.; for (i = 0; i < n; i++) { mult = (c == NULL) ? 1. : (double) c[i]; esum += mult * exp(-1 * lambda * x[i]); total += mult; } mu = -1. * log(esum / total) / lambda; *ret_lambda = lambda; *ret_mu = mu; return 1; } /* Function: EVDCensoredFit(ret_mu,x,ret_lambda,y,*x,*y,n,z,c,*ret_mu,*ret_lambda) * * Descrip: No Description * * Arg: ret_mu [WRITE] RETURN: ML estimate of mu [NullString] * Arg: x [UNKN ] list of EVD distributed samples or x axis of histogram [NullString] * Arg: ret_lambda [WRITE] RETURN: ML estimate of lambda [NullString] * Arg: y [UNKN ] NULL, or y axis of histogram [NullString] * Arg: *x [UNKN ] Undocumented argument [float] * Arg: *y [UNKN ] Undocumented argument [int] * Arg: n [UNKN ] number of observed samples,or number of histogram bins [int] * Arg: z [UNKN ] number of censored samples [int] * Arg: c [UNKN ] censoring value (all x_i >= c) [float] * Arg: *ret_mu [UNKN ] Undocumented argument [float] * Arg: *ret_lambda [UNKN ] Undocumented argument [float] * * Return [UNKN ] Undocumented return value [int] * */ # line 1366 "histogram.dy" int EVDCensoredFit(float *x, int *y, int n, int z, float c,float *ret_mu, float *ret_lambda) { float lambda, mu; float fx; /* f(x) */ float dfx; /* f'(x) */ double esum; /* \sum e^(-lambda xi) */ double mult; double total; float tol = 1e-5; int i; /* 1. Find an initial guess at lambda: linear regression here? */ lambda = 0.2; /* 2. Use Newton/Raphson to solve Lawless 4.2.2 and find ML lambda */ for (i = 0; i < 100; i++) { Lawless422(x, y, n, z, c, lambda, &fx, &dfx); if (fabs(fx) < tol) break; /* success */ lambda = lambda - fx / dfx; /* Newton/Raphson is simple */ if (lambda <= 0.) lambda = 0.001; /* but be a little careful */ } /* 2.5: If we did 100 iterations but didn't converge, Newton/Raphson failed. * Resort to a bisection search. Worse convergence speed * but guaranteed to converge (unlike Newton/Raphson). * We assume (!?) that fx is a monotonically decreasing function of x; * i.e. fx > 0 if we are left of the root, fx < 0 if we * are right of the root. */ if (i == 100) { float left, right, mid; /* First we need to bracket the root */ info("EVDCensor fit: Newton/Raphson failed; switched to bisection"); lambda = right = left = 0.2; Lawless422(x, y, n, z, c, lambda, &fx, &dfx); if (fx < 0.) { /* fix right; search left. */ do { left -= 0.03; if (left < 0.) { info("failed to bracket root"); return 0; } Lawless422(x, y, n, z, c, left, &fx, &dfx); } while (fx < 0.); } else { /* fix left; search right. */ do { right += 0.1; Lawless422(x, y, n, z, c, left, &fx, &dfx); if (right > 100.) { info("failed to bracket root"); return 0; } } while (fx > 0.); } /* now we bisection search in left/right interval */ for (i = 0; i < 100; i++) { mid = (left + right) / 2.; Lawless422(x, y, n, z, c, left, &fx, &dfx); if (fabs(fx) < tol) break; /* success */ if (fx > 0.) left = mid; else right = mid; } if (i == 100) { info("even the bisection search failed"); return 0; } lambda = mid; } /* 3. Substitute into Lawless 4.2.3 to find mu */ esum = total = 0.; for (i = 0; i < n; i++) { mult = (y == NULL) ? 1. : (double) y[i]; esum += mult * exp(-1. * lambda * x[i]); total += mult; } esum += (double) z * exp(-1. * lambda * c); /* term from censored data */ mu = -1. * log(esum / total) / lambda; *ret_lambda = lambda; *ret_mu = mu; return 1; } /* Function: Linefit(ret_r,x,*x,ret_b,y,ret_a,*y,N,*ret_a,*ret_b,*ret_r) * * Descrip: No Description * * Arg: ret_r [WRITE] RETURN: correlation coefficient [NullString] * Arg: x [UNKN ] x values of data [NullString] * Arg: *x [UNKN ] Undocumented argument [float] * Arg: ret_b [WRITE] RETURN: slope [NullString] * Arg: y [UNKN ] y values of data [NullString] * Arg: ret_a [WRITE] RETURN: intercept [NullString] * Arg: *y [UNKN ] Undocumented argument [float] * Arg: N [UNKN ] number of data points [int] * Arg: *ret_a [UNKN ] Undocumented argument [float] * Arg: *ret_b [UNKN ] Undocumented argument [float] * Arg: *ret_r [UNKN ] Undocumented argument [float] * * Return [UNKN ] on success, 0 on failure. [int] * */ # line 1484 "histogram.dy" int Linefit(float *x, float *y, int N, float *ret_a, float *ret_b, float *ret_r) { float xavg, yavg; float sxx, syy, sxy; int i; /* Calculate averages, xavg and yavg */ xavg = yavg = 0.0; for (i = 0; i < N; i++) { xavg += x[i]; yavg += y[i]; } xavg /= (float) N; yavg /= (float) N; sxx = syy = sxy = 0.0; for (i = 0; i < N; i++) { sxx += (x[i] - xavg) * (x[i] - xavg); syy += (y[i] - yavg) * (y[i] - xavg); sxy += (x[i] - xavg) * (y[i] - yavg); } *ret_b = sxy / sxx; *ret_a = yavg - xavg*(*ret_b); *ret_r = sxy / (sqrt(sxx) * sqrt(syy)); return 1; } #define RANGE 268435456 /* 2^28 */ #define DIV 16384 /* sqrt(RANGE) */ #define MULT 72530821 /* my/Cathy's birthdays, x21, x even (Knuth)*/ static int sre_reseed = 0; /* TRUE to reinit sre_random() */ static int sre_randseed = 666; /* default seed for sre_random() */ /* Function: sre_random(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [float] * */ # line 1553 "histogram.dy" float sre_random(void) { static long rnd; static int firsttime = 1; long high1, low1; long high2, low2; if (sre_reseed || firsttime) { sre_reseed = firsttime = 0; if (sre_randseed <= 0) sre_randseed = 666; /* seeds of zero break me */ high1 = sre_randseed / DIV; low1 = sre_randseed % DIV; high2 = MULT / DIV; low2 = MULT % DIV; rnd = (((high2*low1 + high1*low2) % DIV)*DIV + low1*low2) % RANGE; } high1 = rnd / DIV; low1 = rnd % DIV; high2 = MULT / DIV; low2 = MULT % DIV; rnd = (((high2*low1 + high1*low2) % DIV)*DIV + low1*low2) % RANGE; return ((float) rnd / (float) RANGE); } #undef RANGE #undef DIV #undef MULT /* Function: IncompleteGamma(a,x) * * Descrip: No Description * * Arg: a [UNKN ] Undocumented argument [double] * Arg: x [UNKN ] Undocumented argument [double] * * Return [UNKN ] Undocumented return value [double] * */ # line 1609 "histogram.dy" double IncompleteGamma(double a, double x) { int iter; /* iteration counter */ if (a <= 0.) fatal("IncompleteGamma(): a must be > 0"); if (x < 0.) fatal("IncompleteGamma(): x must be >= 0"); /* For x > a + 1 the following gives rapid convergence; * calculate 1 - P(a,x) = \frac{\Gamma(a,x)}{\Gamma(a)}: * use a continued fraction development for \Gamma(a,x). */ if (x > a+1) { double oldp; /* previous value of p */ double nu0, nu1; /* numerators for continued fraction calc */ double de0, de1; /* denominators for continued fraction calc */ nu0 = 0.; /* A_0 = 0 */ de0 = 1.; /* B_0 = 1 */ nu1 = 1.; /* A_1 = 1 */ de1 = x; /* B_1 = x */ oldp = nu1; for (iter = 1; iter < 100; iter++) { /* Continued fraction development: * set A_j = b_j A_j-1 + a_j A_j-2 * B_j = b_j B_j-1 + a_j B_j-2 * We start with A_2, B_2. */ /* j = even: a_j = iter-a, b_j = 1 */ /* A,B_j-2 are in nu0, de0; A,B_j-1 are in nu1,de1 */ nu0 = nu1 + ((double)iter - a) * nu0; de0 = de1 + ((double)iter - a) * de0; /* j = odd: a_j = iter, b_j = x */ /* A,B_j-2 are in nu1, de1; A,B_j-1 in nu0,de0 */ nu1 = x * nu0 + (double) iter * nu1; de1 = x * de0 + (double) iter * de1; /* rescale */ if (de1) { nu0 /= de1; de0 /= de1; nu1 /= de1; de1 = 1.; } /* check for convergence */ if (fabs((nu1-oldp)/nu1) < 1.e-7) return nu1 * exp(a * log(x) - x - Gammln(a)); oldp = nu1; } fatal("IncompleteGamma(): failed to converge using continued fraction approx"); } else /* x <= a+1 */ { double p; /* current sum */ double val; /* current value used in sum */ /* For x <= a+1 we use a convergent series instead: * P(a,x) = \frac{\gamma(a,x)}{\Gamma(a)}, * where * \gamma(a,x) = e^{-x}x^a \sum_{n=0}{\infty} \frac{\Gamma{a}}{\Gamma{a+1+n}} x^n * which looks appalling but the sum is in fact rearrangeable to * a simple series without the \Gamma functions: * = \frac{1}{a} + \frac{x}{a(a+1)} + \frac{x^2}{a(a+1)(a+2)} ... * and it's obvious that this should converge nicely for x <= a+1. */ p = val = 1. / a; for (iter = 1; iter < 10000; iter++) { val *= x / (a+(double)iter); p += val; if (fabs(val/p) < 1.e-7) return 1. - p * exp(a * log(x) - x - Gammln(a)); } fatal("IncompleteGamma(): failed to converge using series approx"); } /*NOTREACHED*/ return 0.; } /* Function: Gammln(x) * * Descrip: No Description * * Arg: x [UNKN ] Undocumented argument [float] * * Return [UNKN ] Undocumented return value [float] * */ # line 1715 "histogram.dy" float Gammln(float x) { int i; double xx, tx; double tmp, value; static double cof[11] = { 4.694580336184385e+04, -1.560605207784446e+05, 2.065049568014106e+05, -1.388934775095388e+05, 5.031796415085709e+04, -9.601592329182778e+03, 8.785855930895250e+02, -3.155153906098611e+01, 2.908143421162229e-01, -2.319827630494973e-04, 1.251639670050933e-10 }; /* Protect against x=0. We see this in Dirichlet code, * for terms alpha = 0. This is a severe hack but it is effective * and safe. (due to GJM) */ if (x <= 0.0) return 999999.; xx = x - 1.0; tx = tmp = xx + 11.0; value = 1.0; for (i = 10; i >= 0; i--) /* sum least significant terms first */ { value += cof[i] / tmp; tmp -= 1.0; } value = log(value); tx += 0.5; value += 0.918938533 + (xx+0.5)*log(tx) - tx; return (float) value; } # line 1416 "histogram.c" /* Function: hard_link_Histogram(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Histogram *] * * Return [UNKN ] Undocumented return value [Histogram *] * */ Histogram * hard_link_Histogram(Histogram * obj) { if( obj == NULL ) { warn("Trying to hard link to a Histogram object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Histogram_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Histogram *] * */ Histogram * Histogram_alloc(void) { Histogram * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Histogram *) ckalloc (sizeof(Histogram))) == NULL) { warn("Histogram_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->histogram = NULL; out->min = 0; out->max = 0; out->highscore = 0; out->lowscore = 0; out->lumpsize = 0; out->total = 0; out->expect = NULL; out->fit_type = 0; /* param[3] is an array: no default possible */ out->chisq = 0; out->chip = 0; return out; } /* Function: free_Histogram(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Histogram *] * * Return [UNKN ] Undocumented return value [Histogram *] * */ Histogram * free_Histogram(Histogram * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Histogram obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->histogram != NULL) ckfree(obj->histogram); if( obj->expect != NULL) ckfree(obj->expect); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/histogram.h0000644000175000001440000004177110670453712017016 0ustar philippusers#ifndef DYNAMITEhistogramHEADERFILE #define DYNAMITEhistogramHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #define HISTFIT_NONE 0 /* no fit done yet */ #define HISTFIT_EVD 1 /* fit type = extreme value dist */ #define HISTFIT_GAUSSIAN 2 /* fit type = Gaussian */ #define EVD_MU 0 /* EVD fit parameter mu */ #define EVD_LAMBDA 1 /* EVD fit parameter lambda */ #define EVD_WONKA 2 /* EVD fit fudge factor */ #define GAUSS_MEAN 0 /* Gaussian parameter mean */ #define GAUSS_SD 1 /* Gaussian parameter std. dev. */ #ifndef MIN #define MIN(a,b) ((a)<(b) ? (a) : (b)) #endif /* Object Histogram * * Descrip: This Object came from Sean Eddy excellent histogram package. * He donated it free of all restrictions to allow it to be used * in the Wise2 package without complicated licensing terms. * He is a *very* nice man. * * It was made into a dynamite object so that * a) External ports to scripting languages would be trivial * b) cooperation with future versions of histogram.c would be possible. * * Here is the rest of the documentation from sean. * * Keep a score histogram. * * The main implementation issue here is that the range of * scores is unknown, and will go negative. histogram is * a 0..max-min array that represents the range min..max. * A given score is indexed in histogram array as score-min. * The AddToHistogram function deals with dynamically * resizing the histogram array when necessary. * * */ struct Wise2_Histogram { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int* histogram; /* counts of hits */ int min; /* elem 0 of histogram == min */ int max; /* last elem of histogram == max */ int highscore; /* highest active elem has this score */ int lowscore; /* lowest active elem has this score */ int lumpsize; /* when resizing, overalloc by this */ int total; /* total # of hits counted */ float* expect; /* expected counts of hits */ int fit_type; /* flag indicating distribution type */ float param[3]; /* parameters used for fits */ float chisq; /* chi-squared val for goodness of fit */ float chip; /* P value for chisquared */ } ; /* Histogram defined */ #ifndef DYNAMITE_DEFINED_Histogram typedef struct Wise2_Histogram Wise2_Histogram; #define Histogram Wise2_Histogram #define DYNAMITE_DEFINED_Histogram #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: Evalue_from_Histogram(his,score) * * Descrip: No Description * * Arg: his [UNKN ] Histogram object [Histogram *] * Arg: score [UNKN ] score you want the evalue for [double] * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_Evalue_from_Histogram(Histogram * his,double score); #define Evalue_from_Histogram Wise2_Evalue_from_Histogram /* Function: new_Histogram(min,max,lumpsize) * * Descrip: No Description * * Arg: min [UNKN ] minimum score (integer) [int] * Arg: max [UNKN ] maximum score (integer) [int] * Arg: lumpsize [UNKN ] when reallocating histogram, the reallocation amount [int] * * Return [UNKN ] Undocumented return value [Histogram *] * */ Histogram * Wise2_new_Histogram(int min, int max, int lumpsize); #define new_Histogram Wise2_new_Histogram /* Function: UnfitHistogram(h) * * Descrip: No Description * * Arg: h [UNKN ] Undocumented argument [Histogram *] * */ void Wise2_UnfitHistogram(Histogram * h); #define UnfitHistogram Wise2_UnfitHistogram /* Function: AddToHistogram(h,sc) * * Descrip: No Description * * Arg: h [UNKN ] Undocumented argument [Histogram *] * Arg: sc [UNKN ] Undocumented argument [float] * */ void Wise2_AddToHistogram(Histogram * h, float sc); #define AddToHistogram Wise2_AddToHistogram /* Function: PrintASCIIHistogram(h,fp) * * Descrip: No Description * * Arg: h [UNKN ] histogram to print [Histogram *] * Arg: fp [UNKN ] open file to print to (stdout works) [FILE *] * */ void Wise2_PrintASCIIHistogram(Histogram * h,FILE * fp); #define PrintASCIIHistogram Wise2_PrintASCIIHistogram /* Function: EVDBasicFit(h) * * Descrip: No Description * * Arg: h [UNKN ] histogram to fit [Histogram *] * */ void Wise2_EVDBasicFit(Histogram * h); #define EVDBasicFit Wise2_EVDBasicFit /* Function: ExtremeValueFitHistogram(h,censor,high_hint) * * Descrip: No Description * * Arg: h [UNKN ] histogram to fit [Histogram *] * Arg: censor [UNKN ] TRUE to censor data left of the peak [int] * Arg: high_hint [UNKN ] score cutoff; above this are real hits that arent fit [float] * * Return [UNKN ] if fit is judged to be valid else 0 if fit is invalid (too few seqs.) [int] * */ int Wise2_ExtremeValueFitHistogram(Histogram * h, int censor, float high_hint) ; #define ExtremeValueFitHistogram Wise2_ExtremeValueFitHistogram /* Function: ExtremeValueSetHistogram(h,mu,lambda,lowbound,highbound,wonka,ndegrees) * * Descrip: No Description * * Arg: h [UNKN ] the histogram to set [Histogram *] * Arg: mu [UNKN ] mu location parameter [float] * Arg: lambda [UNKN ] lambda scale parameter [float] * Arg: lowbound [UNKN ] low bound of the histogram that was fit [float] * Arg: highbound [UNKN ] high bound of histogram that was fit [float] * Arg: wonka [UNKN ] fudge factor; fraction of hits estimated to be "EVD-like" [float] * Arg: ndegrees [UNKN ] extra degrees of freedom to subtract in chi2 test: [int] * */ void Wise2_ExtremeValueSetHistogram(Histogram * h, float mu, float lambda, float lowbound, float highbound, float wonka, int ndegrees); #define ExtremeValueSetHistogram Wise2_ExtremeValueSetHistogram /* Function: GaussianFitHistogram(h,high_hint) * * Descrip: No Description * * Arg: h [UNKN ] histogram to fit [Histogram *] * Arg: high_hint [UNKN ] score cutoff; above this are `real' hits that aren't fit [float] * * Return [UNKN ] if fit is judged to be valid else 0 if fit is invalid (too few seqs.) [int] * */ int Wise2_GaussianFitHistogram(Histogram * h, float high_hint); #define GaussianFitHistogram Wise2_GaussianFitHistogram /* Function: GaussianSetHistogram(h,mean,sd) * * Descrip: No Description * * Arg: h [UNKN ] Undocumented argument [Histogram *] * Arg: mean [UNKN ] Undocumented argument [float] * Arg: sd [UNKN ] Undocumented argument [float] * */ void Wise2_GaussianSetHistogram(Histogram * h, float mean, float sd); #define GaussianSetHistogram Wise2_GaussianSetHistogram /* Function: EVDDensity(x,mu,lambda) * * Descrip: No Description * * Arg: x [UNKN ] Undocumented argument [float] * Arg: mu [UNKN ] Undocumented argument [float] * Arg: lambda [UNKN ] Undocumented argument [float] * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_EVDDensity(float x, float mu, float lambda); #define EVDDensity Wise2_EVDDensity /* Function: EVDDistribution(x,mu,lambda) * * Descrip: No Description * * Arg: x [UNKN ] Undocumented argument [float] * Arg: mu [UNKN ] Undocumented argument [float] * Arg: lambda [UNKN ] Undocumented argument [float] * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_EVDDistribution(float x, float mu, float lambda); #define EVDDistribution Wise2_EVDDistribution /* Function: ExtremeValueP(x,mu,lambda) * * Descrip: No Description * * Arg: x [UNKN ] score [float] * Arg: mu [UNKN ] characteristic value of extreme value distribution [float] * Arg: lambda [UNKN ] decay constant of extreme value distribution [float] * * Return [UNKN ] P(S>x) [double] * */ double Wise2_ExtremeValueP(float x, float mu, float lambda); #define ExtremeValueP Wise2_ExtremeValueP /* Function: ExtremeValueP2(x,mu,lambda,N) * * Descrip: No Description * * Arg: x [UNKN ] score [float] * Arg: mu [UNKN ] characteristic value of extreme value distribution [float] * Arg: lambda [UNKN ] decay constant of extreme value distribution [float] * Arg: N [UNKN ] number of trials (number of sequences) [int] * * Return [UNKN ] P(S>x) for database of size N [double] * */ double Wise2_ExtremeValueP2(float x, float mu, float lambda, int N); #define ExtremeValueP2 Wise2_ExtremeValueP2 /* Function: ExtremeValueE(x,mu,lambda,N) * * Descrip: No Description * * Arg: x [UNKN ] score [float] * Arg: mu [UNKN ] characteristic value of extreme value distribution [float] * Arg: lambda [UNKN ] decay constant of extreme value distribution [float] * Arg: N [UNKN ] number of trials (number of sequences) [int] * * Return [UNKN ] E(S>x) for database of size N [double] * */ double Wise2_ExtremeValueE(float x, float mu, float lambda, int N); #define ExtremeValueE Wise2_ExtremeValueE /* Function: EVDrandom(mu,lambda) * * Descrip: No Description * * Arg: mu [UNKN ] Undocumented argument [float] * Arg: lambda [UNKN ] Undocumented argument [float] * * Return [UNKN ] Undocumented return value [float] * */ float Wise2_EVDrandom(float mu, float lambda); #define EVDrandom Wise2_EVDrandom /* Function: Lawless416(ret_f,ret_df,y,*x,x,*y,n,lambda,*ret_f,*ret_df) * * Descrip: No Description * * Arg: ret_f [WRITE] RETURN: 4.1.6 evaluated at lambda [NullString] * Arg: ret_df [WRITE] RETURN: first derivative of 4.1.6 evaluated at lambda [NullString] * Arg: y [UNKN ] NULL (or y-axis of a histogram) [NullString] * Arg: *x [UNKN ] Undocumented argument [float] * Arg: x [UNKN ] array of sample values (or x-axis of a histogram) [NullString] * Arg: *y [UNKN ] Undocumented argument [int] * Arg: n [UNKN ] number of samples (or number of histogram bins) [int] * Arg: lambda [UNKN ] a lambda to test [float] * Arg: *ret_f [UNKN ] Undocumented argument [float] * Arg: *ret_df [UNKN ] Undocumented argument [float] * */ void Wise2_Lawless416(float *x, int *y, int n, float lambda, float *ret_f, float *ret_df); #define Lawless416 Wise2_Lawless416 /* Function: Lawless422(*x,ret_df,y,ret_f,x,*y,n,z,c,lambda,*ret_f,*ret_df) * * Descrip: No Description * * Arg: *x [UNKN ] Undocumented argument [float] * Arg: ret_df [WRITE] RETURN: first derivative of 4.2.2 evaluated at lambda [NullString] * Arg: y [UNKN ] NULL (or y axis of a histogram) [NullString] * Arg: ret_f [WRITE] RETURN: 4.2.2 evaluated at lambda [NullString] * Arg: x [UNKN ] array of sample values (or x axis of a histogram) [NullString] * Arg: *y [UNKN ] Undocumented argument [int] * Arg: n [UNKN ] number of observed samples (or number of histogram bins) [int] * Arg: z [UNKN ] number of censored samples [int] * Arg: c [UNKN ] censoring value; all observed x_i >= c [float] * Arg: lambda [UNKN ] a lambda to test [float] * Arg: *ret_f [UNKN ] Undocumented argument [float] * Arg: *ret_df [UNKN ] Undocumented argument [float] * */ void Wise2_Lawless422(float *x, int *y, int n, int z, float c,float lambda, float *ret_f, float *ret_df); #define Lawless422 Wise2_Lawless422 /* Function: EVDMaxLikelyFit(ret_lambda,x,*x,c,ret_mu,*c,n,*ret_mu,*ret_lambda) * * Descrip: No Description * * Arg: ret_lambda [WRITE] RETURN: ML estimate of lambda [NullString] * Arg: x [UNKN ] list of EVD distributed samples or x axis of histogram [NullString] * Arg: *x [UNKN ] Undocumented argument [float] * Arg: c [UNKN ] NULL, or y-axis of histogram [NullString] * Arg: ret_mu [WRITE] RETURN: ML estimate of mu [NullString] * Arg: *c [UNKN ] Undocumented argument [int] * Arg: n [UNKN ] number of samples, or number of histogram bins [int] * Arg: *ret_mu [UNKN ] Undocumented argument [float] * Arg: *ret_lambda [UNKN ] Undocumented argument [float] * * Return [UNKN ] on success; 0 on any failure [int] * */ int Wise2_EVDMaxLikelyFit(float *x, int *c, int n, float *ret_mu, float *ret_lambda); #define EVDMaxLikelyFit Wise2_EVDMaxLikelyFit /* Function: EVDCensoredFit(ret_mu,x,ret_lambda,y,*x,*y,n,z,c,*ret_mu,*ret_lambda) * * Descrip: No Description * * Arg: ret_mu [WRITE] RETURN: ML estimate of mu [NullString] * Arg: x [UNKN ] list of EVD distributed samples or x axis of histogram [NullString] * Arg: ret_lambda [WRITE] RETURN: ML estimate of lambda [NullString] * Arg: y [UNKN ] NULL, or y axis of histogram [NullString] * Arg: *x [UNKN ] Undocumented argument [float] * Arg: *y [UNKN ] Undocumented argument [int] * Arg: n [UNKN ] number of observed samples,or number of histogram bins [int] * Arg: z [UNKN ] number of censored samples [int] * Arg: c [UNKN ] censoring value (all x_i >= c) [float] * Arg: *ret_mu [UNKN ] Undocumented argument [float] * Arg: *ret_lambda [UNKN ] Undocumented argument [float] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_EVDCensoredFit(float *x, int *y, int n, int z, float c,float *ret_mu, float *ret_lambda); #define EVDCensoredFit Wise2_EVDCensoredFit /* Function: Linefit(ret_r,x,*x,ret_b,y,ret_a,*y,N,*ret_a,*ret_b,*ret_r) * * Descrip: No Description * * Arg: ret_r [WRITE] RETURN: correlation coefficient [NullString] * Arg: x [UNKN ] x values of data [NullString] * Arg: *x [UNKN ] Undocumented argument [float] * Arg: ret_b [WRITE] RETURN: slope [NullString] * Arg: y [UNKN ] y values of data [NullString] * Arg: ret_a [WRITE] RETURN: intercept [NullString] * Arg: *y [UNKN ] Undocumented argument [float] * Arg: N [UNKN ] number of data points [int] * Arg: *ret_a [UNKN ] Undocumented argument [float] * Arg: *ret_b [UNKN ] Undocumented argument [float] * Arg: *ret_r [UNKN ] Undocumented argument [float] * * Return [UNKN ] on success, 0 on failure. [int] * */ int Wise2_Linefit(float *x, float *y, int N, float *ret_a, float *ret_b, float *ret_r) ; #define Linefit Wise2_Linefit /* Function: sre_random(void) * * Descrip: No Description * * * Return [UNKN ] Undocumented return value [float] * */ float Wise2_sre_random(void); #define sre_random Wise2_sre_random /* Function: IncompleteGamma(a,x) * * Descrip: No Description * * Arg: a [UNKN ] Undocumented argument [double] * Arg: x [UNKN ] Undocumented argument [double] * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_IncompleteGamma(double a, double x); #define IncompleteGamma Wise2_IncompleteGamma /* Function: Gammln(x) * * Descrip: No Description * * Arg: x [UNKN ] Undocumented argument [float] * * Return [UNKN ] Undocumented return value [float] * */ float Wise2_Gammln(float x); #define Gammln Wise2_Gammln /* Function: hard_link_Histogram(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Histogram *] * * Return [UNKN ] Undocumented return value [Histogram *] * */ Histogram * Wise2_hard_link_Histogram(Histogram * obj); #define hard_link_Histogram Wise2_hard_link_Histogram /* Function: Histogram_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Histogram *] * */ Histogram * Wise2_Histogram_alloc(void); #define Histogram_alloc Wise2_Histogram_alloc /* Function: free_Histogram(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Histogram *] * * Return [UNKN ] Undocumented return value [Histogram *] * */ Histogram * Wise2_free_Histogram(Histogram * obj); #define free_Histogram Wise2_free_Histogram /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/protein.dy0000644000175000001440000000621407570660625016667 0ustar philippusers %{ #include "sequence.h" %} api object Protein des free_Protein func Protein_from_Sequence endobject endapi struct Protein Sequence * baseseq; %info The protein object is a typed example of a sequence object. It does nothing more than a sequence object but is typed %% # SequenceErrorList * se // list of the sequence errors %{ #include "protein.h" %func Truncates a protein sequence. Basically uses the /trunc_Sequence function (of course!) It does not alter pro, rather it returns a new sequence with that truncation %arg pro r Protein that is truncated %% Protein * truncate_Protein(Protein * pro,int start,int stop) { return Protein_from_Sequence(trunc_Sequence(pro->baseseq,start,stop)); } %func Reads a fasta file assumming that it is protein. Will complain if it is not, and return NULL. %arg filename filename to be opened and read %% Protein * read_fasta_file_Protein (char * filename) { Protein * out; Sequence * seq; seq = read_fasta_file_Sequence(filename); if( seq == NULL ) { return NULL; } out = Protein_from_Sequence(seq); return out; } %func Reads a fasta file assumming that it is protein. Will complain if it is not, and return NULL. %arg ifp file point to be read from %% Protein * read_fasta_Protein (FILE * ifp) { Sequence * seq; seq = read_fasta_Sequence(ifp); if( seq == NULL ) { return NULL; } return Protein_from_Sequence(seq); } %func Reads a efetch specified query Uses, of course /read_efetch_Sequence %arg estr r efetch string which is read %% Protein * read_efetch_Protein(char * estr) { return Protein_from_Sequence(read_efetch_Sequence(estr)); } %func Reads a SRS sequence using srs4 syntax. Uses, of course, /read_SRS_Sequence %arg srsquery r string query representing SRS name %% Protein * read_SRS_Protein(char * srsquery) { return Protein_from_Sequence(read_SRS_Sequence(srsquery)); } %func Returns the name of the protein %arg %% char * Protein_name (Protein * pr) { return pr->baseseq->name; } %func Returns the length of the protein %arg %% int Protein_length (Protein * pr) { return pr->baseseq->len; } %func Returns sequence character at this position. %arg pr Protein pos position in protein to get char %% char Protein_seqchar(Protein * pr,int pos) { return pr->baseseq->seq[pos]; } %func makes a new protein from a Sequence. It owns the Sequence memory, ie will attempt a /free_Sequence on the structure when /free_Protein is called If you want to give this protein this Sequence and forget about it, then just hand it this sequence and set seq to NULL (no need to free it). If you intend to use the sequecne object elsewhere outside of the Protein datastructure then use Protein_from_Sequence(/hard_link_Sequence(seq)) %arg seq o Sequence to make protein from %% Protein * Protein_from_Sequence(Sequence * seq) { Protein * out; if( seq == NULL ) { warn("Attempting to make a protein from a NULL sequence"); return NULL; } if( is_protein_Sequence(seq) == FALSE ) { warn("Trying to make a protein sequence from a non protein base sequence [%s].",seq->name); return NULL; } out = Protein_alloc(); out->baseseq = seq; return out; } %} wise-2.4.1/src/dynlibsrc/LICENSE0000644000175000001440000000404507313404537015647 0ustar philippusersAll of the documentation and software included in the dynlibsrc directory of the Wise2 package directory is copyrighted by Genome Research Limited (GRL) and other individuals where appropiate. This license is modelled after the 'BSD' style license and is appropiate for use by both academic and commerical sites, without placing any restriction on the distribution of source code from other sources with this software. Copyright 1998, 1999, GRL and others. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2.Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3.Neither the name GRL nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. It is considered polite to indicate where appropiate that software which is developed using this source code includes a statement that it was developed using the Wise2 soure code. This is not a requirement however. THIS SOFTWARE IS PROVIDED BY THE GRL AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GRL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. wise-2.4.1/src/dynlibsrc/protein.xs0000644000175000001440000000207510670453712016676 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::Protein Wise2_Protein * Protein_from_Sequence(seq) Wise2_Sequence * seq CODE: RETVAL = Wise2_Protein_from_Sequence(Wise2_hard_link_Sequence(seq)); OUTPUT: RETVAL Wise2_Protein * hard_link_Protein(obj) Wise2_Protein * obj CODE: RETVAL = Wise2_hard_link_Protein(obj); OUTPUT: RETVAL Wise2_Protein * alloc() CODE: RETVAL = Wise2_Protein_alloc(); OUTPUT: RETVAL boolean set_baseseq(obj,baseseq) Wise2_Protein * obj Wise2_Sequence * baseseq CODE: RETVAL = Wise2_replace_baseseq_Protein(obj,Wise2_hard_link_Sequence(baseseq)); OUTPUT: RETVAL Wise2_Sequence * baseseq(obj) Wise2_Protein * obj INIT: Wise2_Sequence * temp; CODE: temp = Wise2_hard_link_Sequence(Wise2_access_baseseq_Protein(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_Protein * new(class) char * class PPCODE: Wise2_Protein * out; out = Wise2_Protein_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_Protein * obj CODE: Wise2_free_Protein(obj); MODULE = Wise2 PACKAGE = Wise2 wise-2.4.1/src/dynlibsrc/aln.c0000644000175000001440000023433010670453712015561 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "aln.h" /* Function: collapsed_AlnBlock(alb,comp_row) * * Descrip: This function builds a new "collapsed" AlnBlock * on the similarity of one AlnSeq row * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: comp_row [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 111 "aln.dy" AlnBlock * collapsed_AlnBlock(AlnBlock * alb,int comp_row) { AlnBlock * out; AlnColumn * temp = NULL; AlnColumn * prev = NULL; AlnColumn * ori; int i; out = AlnBlock_alloc(); out->start = NULL; assert(alb); assert(comp_row >= 0); assert(out); for(ori=alb->start;ori != NULL;ori = ori->next) { if( temp != NULL && strcmp(temp->alu[comp_row]->text_label,ori->alu[comp_row]->text_label) == 0 ) { /* same column; eat it up */ for(i=0;ilen;i++) { temp->alu[i]->end = ori->alu[i]->end; temp->alu[i]->score[0] += ori->alu[i]->score[0]; } } else { /* new column */ prev = temp; temp = AlnColumn_alloc_len(ori->len); for(i=0;ilen;i++) { temp->alu[i]= AlnUnit_alloc(); temp->alu[i]->text_label = ori->alu[i]->text_label; temp->alu[i]->start = ori->alu[i]->start; temp->alu[i]->end = ori->alu[i]->end; temp->alu[i]->score[0] = ori->alu[i]->score[0]; } temp->len = ori->len; if( prev == NULL ) { out->start = temp; } else { prev->next = temp; } } } return out; } /* Function: add_to_anchored_AlnBlock(growing,add) * * Descrip: This function assummes that the first AlnSequence * in the current and the adding AlnBlock are the same, * and that you want to add the second AlnSequence of the * second alnblock to the first, anchored on the first * sequence. * * In other words, this builds up an anchored alignment, on * the first sequence * * This AlnBlock, like many others, consumes the sequence * in the second alnblock, unsetting things so that it is * valid. This makes for some pretty hairy coding. * * * Arg: growing [UNKN ] Undocumented argument [AlnBlock *] * Arg: add [UNKN ] Undocumented argument [AlnBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 173 "aln.dy" boolean add_to_anchored_AlnBlock(AlnBlock * growing,AlnBlock * add) { AlnColumn * anc; AlnColumn * new; AlnColumn * insert; AlnUnit * temp; AlnUnit ** prev; int i; assert(growing); assert(add); anc = growing->start; new = add->start; add_AlnBlock(growing,add->seq[1]); /* this should prevent freeing the sequence we are about to use */ add->len = 1; prev = &(add->seq[1]->start); /* wait until new is inside anc */ for(;new->alu[0]->start != anc->alu[0]->start;anc = anc->next) { /*fprintf(stderr,"Moving to %d-%d\n",anc->alu[0]->start,anc->alu[0]->end);*/ if( anc->alu[0]->start > new->alu[0]->start ) { warn("Somehow new has overrun anc, new %d-%d and anc %d-%d",new->alu[0]->start,new->alu[0]->end,anc->alu[0]->start,anc->alu[0]->end); return FALSE; } /* add a blank unit onto the anc */ temp = AlnUnit_alloc(); temp->score[0] = 0; temp->start = temp->end = 0; temp->text_label = "INSERT"; add_AlnColumn(anc,temp); *prev = temp; prev = &(temp->next); } /* ok - now we are at the start. We loop over for each 'matched' state */ *prev = new->alu[1]; for(;new->next != NULL;) { /* if the anchor state is actually an insert here, then * this is an insert not in the added sequence (if it were, * we would have added it last time through the loop) * * So - skip insert points */ if( anc->alu[0]->start == anc->alu[0]->end ) { temp = AlnUnit_alloc(); temp->score[0] = 0; temp->start = temp->end = new->alu[1]->end; temp->text_label = "INSERT"; *prev = temp; prev = &(temp->next); temp->next = new->alu[1]; add_AlnColumn(anc,temp); anc = anc->next; continue; } /* sanity check that we are at the same position on the two sequences */ if( anc->alu[0]->start != new->alu[0]->start || anc->alu[0]->end != new->alu[0]->end ) { warn("SANITY CHECK failed! new and anchor out of sync! anchor at %d-%d and new %d-%d",anc->alu[0]->start,anc->alu[0]->end,new->alu[0]->start,new->alu[0]->end); return FALSE; } add_AlnColumn(anc,new->alu[1]); /* see whether the next state is actually an insert */ prev = &(new->alu[1]->next); for(new = new->next;new != NULL && new->alu[0]->start == new->alu[0]->end;new = new->next) { /*fprintf(stderr,"Adding in insert states\n");*/ /* bail out if we have reached the end of anc */ if( anc->next == NULL ) { warn("HELP - run out of add positions!"); return FALSE; } /* does anc already have an insert state here? */ if( anc->next->alu[0]->start == anc->next->alu[0]->end ) { /* yes! - just add to the end */ anc = anc->next; add_AlnColumn(anc,new->alu[1]); } else { /* we have to drop in a new alncolumn */ insert = AlnColumn_alloc_std(); insert->next = anc->next; anc->next = insert; /*fprintf(stderr,"There are %d states to add to\n",anc->len);*/ for(i=0;ilen-1;i++) { temp = AlnUnit_alloc(); temp->score[0] = 0; temp->start = temp->end = anc->alu[i]->end; temp->text_label = "INSERT"; temp->next = anc->alu[i]->next; anc->alu[i]->next = temp; add_AlnColumn(insert,temp); } anc = anc->next; /* could be anc = insert */ /* add the new seq */ add_AlnColumn(insert,new->alu[1]); prev = &(new->alu[1]->next); } /* end of else add in an insert */ } /* end of looping over possible new inserts */ /*fprintf(stderr,"moving on one in anchor (new already moved!) %d-%d\n",anc->alu[0]->start,anc->alu[0]->end);*/ prev = &(new->alu[1]->next); anc = anc->next; } /* end of new alignment */ /*fprintf(stderr,"Left alignment at %d-%d\n",anc->alu[0]->start,anc->alu[0]->end);*/ /* now fill into the end of the anchored alignment */ for(;anc != NULL;anc = anc->next ) { /* add a blank unit onto the anc */ temp = AlnUnit_alloc(); temp->score[0] = 0; temp->start = temp->end = 0; temp->text_label = "INSERT"; add_AlnColumn(anc,temp); *prev = temp; prev = &(temp->next); } *prev = NULL; return TRUE; } /* Function: single_unit_AlnBlock(len,label) * * Descrip: This function makes a new AlnBlock of length len * and depth one, with each Block having the given * label and start = 0 end = start +1; * * It starts with a alu going from -1 to 0 * * * Arg: len [UNKN ] Undocumented argument [int] * Arg: label [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 324 "aln.dy" AlnBlock * single_unit_AlnBlock(int len,char * label) { AlnBlock * out; AlnSequence * als; AlnColumn * alc; AlnUnit * alu; AlnColumn ** prev; AlnUnit ** aprev; int i; out = AlnBlock_alloc_std(); als = AlnSequence_alloc(); add_AlnBlock(out,als); prev = &(out->start); aprev = &(als->start); for(i=-1;istart = i; alu->end = i+1; alu->text_label = label; add_AlnColumn(alc,alu); *aprev = alu; prev = &(alc->next); aprev = &(alu->next); } *prev = NULL; *aprev = NULL; return out; } /* Function: split_AlnBlock(alb,is_spacer_column) * * Descrip: This function splits an AlnBlock into * separate alignments (stored in the resulting AlnBlockList). * * The alb is split wherever there is a column that returns * true to the is_spacer_column function, discarding these * columns * * This function completely destroys the AlnBlock object that * is passed in, but to make sure that API functions dont * get confused, the alb that is passed in is simply stripped * of its AlnColumn information (so it is still a valid alb, * if empty). But - beware - all the alncolumns might or might * not be there, so dont pass in albs and hold on to anything * inside them! * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: is_spacer_column [UNKN ] Undocumented argument [NullString] * * Return [UNKN ] Undocumented return value [AlnBlockList *] * */ # line 378 "aln.dy" AlnBlockList * split_AlnBlock(AlnBlock * alb,boolean (*is_spacer_column)(const AlnColumn * alc)) { AlnBlockList * out; AlnBlock * temp; AlnColumn * alc; AlnColumn * prev; AlnSequence * als; int i; if( is_spacer_column == NULL ) { warn("You must pass in function for the spacer columns to split_AlnBlock"); } if( alb == NULL ) { warn("Unable to split a NULL alnblock!"); } out = AlnBlockList_alloc_std(); assert(out); for(alc=alb->start;alc != NULL;) { for(;alc != NULL && (*is_spacer_column)(alc) == TRUE;alc = alc->next) { if( alc == NULL) break; /* we need to detach this alncolumn from the entire alignment * as it will stop being valid. */ /* this is cheating, but it is still relevant to catch problems */ if( alc->dynamite_hard_link > 1 ) { warn("Detaching a alncolumn in split_AlnBlock that is being held somewhere else. This is very dangerous"); /* ok - give it a fighting chance of not crashing the client */ for(i=0;ilen;i++) { /* alnunits don't point to next */ alc->alu[i]->next = NULL; } alc->next = NULL; } /* now - free it. It *may* be being held onto by * someone else. Pity him... */ free_AlnColumn(alc); } /* alc is now the first alncolumn of a new alb */ if( alc == NULL) { if( out->len == 0 ) { warn("Unable to find any alignments in AlnBlock splitting!"); } break; /* will return */ } temp = AlnBlock_alloc_std(); add_AlnBlockList(out,temp); /* we need to make an exact copy of the AlnSequences */ for(i=0;ilen;i++) { assert(alc->alu[i]); als = AlnSequence_alloc(); add_AlnBlock(temp,als); als->data_type = alb->seq[i]->data_type; als->data = alb->seq[i]->data; als->bio_start = alb->seq[i]->bio_start; als->bio_end = alb->seq[i]->bio_end; /* unit is the unit in this column */ als->start = alc->alu[i]; } /* attach alc as the first column to temp */ temp->start = alc; /* keep walking along the list now until we hit * a random column. All the columns and units are * already correctly laid out in memory */ for(prev = alc;alc != NULL && (*is_spacer_column)(alc) == FALSE;) { prev = alc; alc = alc->next; } /* prev is the last column. detach it */ prev->next = NULL; for(i=0;ilen;i++) prev->alu[i]->next = NULL; /* return to eating empty columns */ } /* alb is now completely defunct. We need to make it * impotent with regard to the old stuff it used to have * * this basically makes alb complete empty */ alb->len =0; alb->start = NULL; return out; } /* Function: score_line_from_AlnBlock(alb,seqno) * * Descrip: gets the score out for a particular alb sequence * line * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: seqno [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ # line 496 "aln.dy" int score_line_from_AlnBlock(AlnBlock * alb,int seqno) { AlnUnit * alu; int score = 0; assert(alb); if( seqno > alb->len ) { warn("Asking for a score number of a sequence more than alb. giving back 0"); return 0; } for(alu = alb->seq[seqno]->start;alu != NULL;alu = alu->next) { score += alu->score[0]; } return score; } /* Function: at_end_AlnColumn(alc) * * Descrip: This tells you whether the AlnColumn is at the * end without passing NULL's around * * * * Arg: alc [READ ] AlnColumn [AlnColumn *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 522 "aln.dy" boolean at_end_AlnColumn(AlnColumn * alc) { if( alc->next == NULL ) return 1; return 0; } /* Function: bio_start_AlnUnit(alu) * * Descrip: Tells the bio-coordinate of the * start point of this alnunit * * * Arg: alu [UNKN ] Undocumented argument [AlnUnit *] * * Return [UNKN ] Undocumented return value [int] * */ # line 535 "aln.dy" int bio_start_AlnUnit(AlnUnit * alu) { if( alu->seq == NULL ) { warn("A mis-connected AlnUnit (no sequence!) - Returning a start as if start == 1"); return alu->start + 1 + 1; } return alu->start + alu->seq->bio_start + 1; } /* Function: bio_end_AlnUnit(alu) * * Descrip: Tells the bio-coordinate of the * end point of this alnunit * * * Arg: alu [UNKN ] Undocumented argument [AlnUnit *] * * Return [UNKN ] Undocumented return value [int] * */ # line 550 "aln.dy" int bio_end_AlnUnit(AlnUnit * alu) { if( alu->seq == NULL ) { warn("A mis-connected AlnUnit (no sequence!) - Returning a start as if start == 1"); return alu->end + 1; } return alu->end + alu->seq->bio_start; } /* Function: swallow_AlnColumn_multiple(master,eaten,comp_func) * * Descrip: This function will 'swallow' any number of AlnColumns as long * as the comparison function of the labels match (the basic * comp function would be something like strcmp(a,b) == 0 ? TRUE : FALSE) * The columns are 'swallowed' into master and come from eaten. (these * columns could be in the same linked list, though it only makes sense * if the master is before the eaten). * * It returns the first column that it could not swallow. * * you use this to collapse regions of the label alignment. * * * Arg: master [UNKN ] column which will eat other columns [AlnColumn *] * Arg: eaten [UNKN ] column which will be consumed [AlnColumn *] * Arg: comp_func [FUNCP] comparison function for label set [boolean (*comp_func] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ # line 578 "aln.dy" AlnColumn * swallow_AlnColumn_multiple(AlnColumn * master,AlnColumn * eaten,boolean (*comp_func)(char *,char *)) { register int i; for(i=0;eaten != NULL; eaten = eaten->next) { if( swallow_AlnColumn(master,eaten,comp_func) == FALSE ) break; } return eaten; } /* Function: swallow_AlnColumn_number(master,eaten,num,comp_func) * * Descrip: Basicaly the same as /swallow_AlnColumn_mulitple but there is a maximum number * of columns it will swallow * * * Arg: master [UNKN ] column which will eat other columns [AlnColumn *] * Arg: eaten [UNKN ] column which will be consumed [AlnColumn *] * Arg: num [UNKN ] max number of columns to eat [int] * Arg: comp_func [FUNCP] comparison function for label set [boolean (*comp_func] * * Return [UNKN ] number of columns eaten [int] * */ # line 602 "aln.dy" int swallow_AlnColumn_number(AlnColumn * master,AlnColumn * eaten,int num,boolean (*comp_func)(char *,char *)) { register int i; for(i=0;i < num && eaten != NULL; eaten = eaten->next) { if( swallow_AlnColumn(master,eaten,comp_func) == FALSE ) break; } return i; } /* Function: swallow_AlnColumn(master,eaten,comp_func) * * Descrip: This is the function that actually does the 'swallowing'. It will * try to swallow eaten into master. If comp_func does not give us an * ok (actually using /can_swallow_AlnColumn it returns FALSE. Otherwise * it moves on the end of AlnColumn in master to eaten and adds the * score of eaten to master. * * * Arg: master [UNKN ] column which will eat [AlnColumn *] * Arg: eaten [UNKN ] column which will dissappear into master if eatable [AlnColumn *] * Arg: comp_func [FUNCP] comparison function for labels [boolean (*comp_func] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 626 "aln.dy" boolean swallow_AlnColumn(AlnColumn * master,AlnColumn * eaten,boolean (*comp_func)(char *,char *)) { register int i; if( can_swallow_AlnColumn(master,eaten,comp_func) == FALSE ) { return FALSE; } for(i=0;ilen;i++) { master->alu[i]->end = eaten->alu[i]->end; /*** ok, for the moment, only add the 1st score, but eventually ***/ /*** we should add all of them... ***/ master->alu[i]->score[0] += eaten->alu[i]->score[0]; } return TRUE; } /* Function: can_swallow_AlnColumn(comp_func,master,eaten) * * Descrip: checks to see if two columns are mergable from comp_func. * First uses /identical_labels_in_AlnColumn to see if labels can be merged * Then checks that starts in master are greater than starts in eaten * * * Arg: comp_func [UNKN ] Undocumented argument [NullString] * Arg: master [UNKN ] Undocumented argument [AlnColumn *] * Arg: eaten [UNKN ] Undocumented argument [AlnColumn *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 654 "aln.dy" boolean can_swallow_AlnColumn(AlnColumn * master,AlnColumn * eaten,boolean (*comp_func)(char *,char *)) { register int i; if( identical_labels_in_AlnColumn(master,eaten,comp_func) == FALSE ) return FALSE; for(i=0;ilen;i++) if( master->alu[i]->start >= eaten->alu[i]->start) { warn("In trying to compare to AlnColumns, have some 'eatable' starts greater than master starts %d %d in row %d",master->alu[i]->start,eaten->alu[i]->start,i); return FALSE; } return TRUE; } /* Function: identical_labels_in_AlnColumn(comp_func,one,two) * * Descrip: checks to see if two AlnColumns has mergable labels by * comp_func. calls /identical_labels_in_AlnUnits for * the actual comparison. * * * Arg: comp_func [UNKN ] Undocumented argument [NullString] * Arg: one [UNKN ] Undocumented argument [AlnColumn *] * Arg: two [UNKN ] Undocumented argument [AlnColumn *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 677 "aln.dy" boolean identical_labels_in_AlnColumn(AlnColumn * one,AlnColumn * two,boolean (*comp_func)(char *,char *)) { register int i; if( one->len != two->len ) { warn("Attempting to see if two AlnColumns with *different numbers of units* %d,%d are identical...serious problem",one->len,two->len); return FALSE; } for(i=0;ilen;i++) { if( identical_labels_in_AlnUnits(one->alu[i],two->alu[i],comp_func) == FALSE ) return FALSE; } return TRUE; } /* Function: identical_labels_in_AlnUnits(comp_func,one,two) * * Descrip: actually calls the comp_func for the label compairson * * * Arg: comp_func [UNKN ] Undocumented argument [NullString] * Arg: one [UNKN ] Undocumented argument [AlnUnit *] * Arg: two [UNKN ] Undocumented argument [AlnUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 698 "aln.dy" boolean identical_labels_in_AlnUnits(AlnUnit * one,AlnUnit * two,boolean (*comp_func)(char *,char *)) { if( (*comp_func)(one->text_label,two->text_label) == TRUE ) return TRUE; else return FALSE; } /* Function: replace_and_free_AlnColumn_with_one(start,end,insert) * * Descrip: Linked list manipulation function * * Puts insert between start and end, and free's from start->next * onwards. *Beware* if start is linked to end before calling this * function thsi wil free end and everything chained to it. Think * before you call this! * * * Arg: start [UNKN ] Undocumented argument [AlnColumn *] * Arg: end [UNKN ] Undocumented argument [AlnColumn *] * Arg: insert [UNKN ] Undocumented argument [AlnColumn *] * */ # line 714 "aln.dy" void replace_and_free_AlnColumn_with_one(AlnColumn * start,AlnColumn * end,AlnColumn * insert) { replace_AlnColumn_with_one(start,end,insert); free_AlnColumn(start->next); } /* Function: replace_AlnColumn_with_one(start,end,insert) * * Descrip: Linked list manipulation function * * places insert between start and end. If start/end are not * continuous then it will loop out the start/end region * * * Arg: start [UNKN ] Undocumented argument [AlnColumn *] * Arg: end [UNKN ] Undocumented argument [AlnColumn *] * Arg: insert [UNKN ] Undocumented argument [AlnColumn *] * */ # line 729 "aln.dy" void replace_AlnColumn_with_one(AlnColumn * start,AlnColumn * end,AlnColumn * insert) { start->next = insert; insert->next = end->next; end->next = NULL; } /* Function: insert_AlnColumn(start,insert) * * Descrip: Linked list manipulation function * * places insert just after start: links insert * up to what start was linked to * * * Arg: start [UNKN ] Undocumented argument [AlnColumn *] * Arg: insert [UNKN ] Undocumented argument [AlnColumn *] * */ # line 744 "aln.dy" void insert_AlnColumn(AlnColumn * start,AlnColumn * insert) { insert->next = start->next; start->next = insert; } /* Function: go_back_n_AlnColumn(alb,start,n) * * Descrip: Linked list movement function * * A nasty function to reverse up a singly linked list by going to * the start and coming back until you are in the current position. yuk. * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: start [UNKN ] Undocumented argument [AlnColumn *] * Arg: n [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ # line 757 "aln.dy" AlnColumn * go_back_n_AlnColumn(AlnBlock * alb,AlnColumn * start,int n) { /*** really quite hacky ****/ AlnColumn * cursor; AlnColumn * back; register int i; for(i=0,cursor = alb->start;i < n && cursor != NULL && cursor != start;i++,cursor = cursor->next) ; if( i < n ) { return NULL; /** should I post an error? **/ } for(back = alb->start;cursor != NULL && cursor != start;cursor = cursor->next, back = back->next) ; if( cursor == NULL ) { warn("could not find you AlnColumn in AlnBlock at all... so could not get xxx positions back"); return NULL; } return back; } /*******************************/ /* show functions for aln block*/ /* */ /* these are really basic and */ /* should use alndisplay for */ /* ascii display */ /*******************************/ /* Function: dump_ascii_AlnBlock(alb,ofp) * * Descrip: Dumps the alignment in rereadable ascii form. * * Not really for human consumption * * * Arg: alb [UNKN ] AlnBlock to dump [AlnBlock *] * Arg: ofp [UNKN ] File stream to dump to [FILE *] * */ # line 800 "aln.dy" void dump_ascii_AlnBlock(AlnBlock * alb,FILE * ofp) { int i; AlnColumn * alc; for(alc=alb->start;alc != NULL;alc = alc->next) { fprintf(ofp,"[%d:%d \"%s\" %d]",alc->alu[0]->start,alc->alu[0]->end,alc->alu[0]->text_label,alc->alu[0]->score[0]); for(i=1;ilen;i++) { fprintf(ofp,",[%d:%d \"%s\" %d]",alc->alu[i]->start,alc->alu[i]->end,alc->alu[i]->text_label,alc->alu[i]->score[0]); } fprintf(ofp,"\n"); } fprintf(ofp,"\\\n"); } /* Function: mapped_ascii_AlnBlockList(alb,score_to_double,*al,ofp) * * Descrip: Shows a list of AlnBlocks with an arbitary mapping * of the score to some other system * * * Arg: alb [UNKN ] AlnBlock to dump [NullString] * Arg: score_to_double [UNKN ] Undocumented argument [NullString] * Arg: *al [UNKN ] Undocumented argument [AlnBlockList] * Arg: ofp [UNKN ] File stream to dump to [FILE *] * */ # line 826 "aln.dy" void mapped_ascii_AlnBlockList(AlnBlockList *al,double (*score_to_double)(int),FILE * ofp) { int i; assert(al); assert(ofp); assert(score_to_double); for(i=0;ilen;i++) { fprintf(ofp,"\n\nAlignment %d\n",i+1); mapped_ascii_AlnBlock(al->alb[i],score_to_double,0,ofp); } } /* Function: mapped_ascii_AlnBlock(alb,score_to_double,do_cumlative,ofp) * * Descrip: Shows AlnBlock with an arbitary mapping of * the score to some other system. * * * Arg: alb [UNKN ] AlnBlock to dump [AlnBlock *] * Arg: score_to_double [UNKN ] Undocumented argument [NullString] * Arg: do_cumlative [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] File stream to dump to [FILE *] * */ # line 845 "aln.dy" void mapped_ascii_AlnBlock(AlnBlock * alb,double (*score_to_double)(int),int do_cumlative,FILE * ofp) { int i; AlnColumn * alc; int cuml = 0; if( alb == NULL || score_to_double == NULL || ofp == NULL ) { warn("Passing in null objects to mapped_ascii_AlnBlock - unable to show!"); return; } for(alc=alb->start;alc != NULL;alc = alc->next) { cuml = cuml + alc->alu[0]->score[0]; fprintf(ofp,"%3.2f ",(double)(*score_to_double)(alc->alu[0]->score[0])); fprintf(ofp,"[%d:%d \"%s\" %d]",alc->alu[0]->start,alc->alu[0]->end,alc->alu[0]->text_label,alc->alu[0]->score[0]); for(i=1;ilen;i++) { fprintf(ofp,",[%d:%d \"%s\" %d]",alc->alu[i]->start,alc->alu[i]->end,alc->alu[i]->text_label,alc->alu[i]->score[0]); } if( do_cumlative == 1 ) { fprintf(ofp," {%3.2f} ",(double)(*score_to_double)(cuml),cuml); } fprintf(ofp,"\n"); } } /* Function: read_ascii_dump_AlnBlock(ifp) * * Descrip: Reads an ascii dumped alignment * * * Arg: ifp [UNKN ] File stream to read from [FILE *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 881 "aln.dy" AlnBlock * read_ascii_dump_AlnBlock(FILE * ifp) { char buffer[MAXLINE]; AlnBlock * out; AlnColumn ** attach; AlnColumn * new; out = AlnBlock_alloc_std(); attach = &out->start; while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"//") == 0 ) break; new = read_dumped_ascii_AlnColumn_line(buffer); if( new == NULL ){ warn("Unable to read entire AlnBlock. Returning no alignment"); free_AlnBlock(out); return NULL; } *attach = new; attach = &new->next; } return out; } /* Function: read_dumped_ascii_AlnColumn_line(line) * * Descrip: Reads one line of an ascii dumped alignment * * * Arg: line [UNKN ] line to be read [char *] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ # line 916 "aln.dy" AlnColumn * read_dumped_ascii_AlnColumn_line(char * line) { char ** base, **bstr; AlnUnit * alu; AlnColumn * out; int start; int end; int score; char buffer[128]; /* implies max label 128 characters. Worrying? */ out = AlnColumn_alloc_len(2); /** most times we are reading in pairwise alignments **/ /** split on comma, then sscanf each one **/ base = bstr = breakstring_protect(line,",","\""); for(;*bstr != NULL;bstr++) { sscanf(*bstr,"[%d,%d \"%s\" %d",&start,&end,buffer,&score); alu = AlnUnit_alloc(); alu->start = start; alu->end = end; alu->score[0] = score; alu->text_label = stringalloc(buffer); add_AlnColumn(out,alu); } return out; } /* Function: show_flat_AlnBlock(alb,ofp) * * Descrip: Shows the AlnBlock in vaguely human * readable form * * * Arg: alb [UNKN ] AlnBlock to show [AlnBlock *] * Arg: ofp [UNKN ] output [FILE *] * */ # line 957 "aln.dy" void show_flat_AlnBlock(AlnBlock * alb,FILE * ofp) { AlnColumn * alc; register int i; for(i=0,alc = alb->start;alc != NULL;alc = alc->next,i++) { fprintf(ofp,"Column %d:\n",i); show_flat_AlnColumn(alc,ofp); } } /* Function: show_flat_AlnColumn(alc,ofp) * * Descrip: sub for show_flat_AlnBlock * * * Arg: alc [UNKN ] Undocumented argument [AlnColumn *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 972 "aln.dy" void show_flat_AlnColumn(AlnColumn * alc,FILE * ofp) { register int i; for(i=0;ilen;i++) { fprintf(ofp,"Unit %2d- ",i); show_flat_AlnUnit(alc->alu[i],ofp); } fprintf(ofp,"\n"); } /* Function: show_flat_AlnUnit(alu,ofp) * * Descrip: sub for show_flat_AlnUnit * * * Arg: alu [UNKN ] Undocumented argument [AlnUnit *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 987 "aln.dy" void show_flat_AlnUnit(AlnUnit * alu,FILE * ofp) { fprintf(ofp,"[%4d-%4d] [%s]\n",alu->start,alu->end,alu->text_label == NULL ? "No Label" : alu->text_label); } /* Function: read_flat_AlnUnit_line(line,ret_pos) * * Descrip: Not used currently. To read in the flat output * format * * * Arg: line [UNKN ] Undocumented argument [char *] * Arg: ret_pos [UNKN ] Undocumented argument [int *] * * Return [UNKN ] Undocumented return value [AlnUnit *] * */ # line 998 "aln.dy" AlnUnit * read_flat_AlnUnit_line(char * line,int * ret_pos) { AlnUnit * out; char buffer[MAXLINE]; int start; int end; int pos; int num; sscanf(line,"Unit %d- Start: [%d], End: [%d] Label: number [%d] text [%s]",&pos,&start,&end,&num,buffer); out = AlnUnit_alloc(); if( out == NULL ) return NULL; out->start = start; out->end = end; out->label = num; out->text_label = stringalloc(buffer); if( ret_pos != NULL ) *ret_pos = pos; return out; } /***********************************/ /* movement functions around Aln's */ /***********************************/ /* Function: get_second_end_AlnColumn(alb) * * Descrip: Not sure if this is used! * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ # line 1031 "aln.dy" AlnColumn * get_second_end_AlnColumn(AlnBlock * alb) { AlnColumn * end = NULL; AlnColumn * prev = NULL; for(end = alb->start;end->next != NULL;prev = end,end = end->next) ; return prev; } /* Function: get_end_AlnColumn(alb) * * Descrip: To get to the last AlnColumn. If this was * a doubly linked list, life would be much easier * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ # line 1047 "aln.dy" AlnColumn * get_end_AlnColumn(AlnBlock * alb) { AlnColumn * end; for(end = alb->start;end->next != NULL;end = end->next) ; return end; } /* Function: link_AlnUnits_AlnBlock(alb) * * Descrip: Links up all AlnUnits to their parent * sequences * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 1061 "aln.dy" boolean link_AlnUnits_AlnBlock(AlnBlock * alb) { AlnSequence * aseq; AlnUnit * au; int i; for(i=0;ilen;i++) { aseq = alb->seq[i]; for(au = aseq->start;au != NULL;au++) { au->seq = aseq; } } return TRUE; } /************************************/ /* constructors/deconstructors to */ /* deal with linked list aspect of */ /* data */ /************************************/ /* Function: new_pairwise_AlnColumn(void) * * Descrip: Function as a constructor for the special * case of a pairwise alignment. Makes an * AlnColumn and puts in two AlnUnits all ready * to be linked in. * * * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ # line 1093 "aln.dy" AlnColumn * new_pairwise_AlnColumn(void) { AlnColumn * out; out = AlnColumn_alloc_len(2); add_AlnColumn(out,AlnUnit_alloc()); add_AlnColumn(out,AlnUnit_alloc()); return out; } /* Function: free_AlnColumn(obj) * * Descrip: Specilased deconstructor needed because * of linked list nature of the data structure * * * Arg: obj [UNKN ] Undocumented argument [AlnColumn *] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ # line 1109 "aln.dy" AlnColumn * free_AlnColumn(AlnColumn * obj) { if( obj == NULL ) { warn("passed a NULL object into free_AlnColumn!"); return NULL; } if( obj->dynamite_hard_link > 1 ) { obj->dynamite_hard_link--; return NULL; } if( obj->next != NULL ) free_AlnColumn(obj->next); if( obj->alu != NULL ) ckfree(obj->alu); /*** units free'd from linked list ***/ ckfree(obj); return NULL; } /* Function: free_AlnUnit(obj) * * Descrip: Specilased deconstructor needed because * of linked list nature of the data structure * * * Arg: obj [UNKN ] Undocumented argument [AlnUnit *] * * Return [UNKN ] Undocumented return value [AlnUnit *] * */ # line 1137 "aln.dy" AlnUnit * free_AlnUnit(AlnUnit * obj) { if( obj == NULL ) return NULL; if( obj->dynamite_hard_link > 1 ) { obj->dynamite_hard_link--; return NULL; } if( obj->next != NULL ) free_AlnUnit(obj->next); ckfree(obj); return NULL; } # line 1224 "aln.c" /* Function: hard_link_AlnUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnUnit *] * * Return [UNKN ] Undocumented return value [AlnUnit *] * */ AlnUnit * hard_link_AlnUnit(AlnUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlnUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlnUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnUnit *] * */ AlnUnit * AlnUnit_alloc(void) { AlnUnit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlnUnit *) ckalloc (sizeof(AlnUnit))) == NULL) { warn("AlnUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->end = 0; out->label = 0; /* score[AlnUnitSCORENUMBER] is an array: no default possible */ out->in_column = TRUE; return out; } /* Function: swap_AlnColumn(list,i,j) * * Descrip: swap function: an internal for qsort_AlnColumn * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [AlnUnit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_AlnColumn(AlnUnit ** list,int i,int j) { AlnUnit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_AlnColumn(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_AlnColumn which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [AlnUnit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_AlnColumn(AlnUnit ** list,int left,int right,int (*comp)(AlnUnit * ,AlnUnit * )) { int i,last; if( left >= right ) return; swap_AlnColumn(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_AlnColumn (list,++last,i); } swap_AlnColumn (list,left,last); qsort_AlnColumn(list,left,last-1,comp); qsort_AlnColumn(list,last+1,right,comp); } /* Function: sort_AlnColumn(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_AlnColumn * * * Arg: obj [UNKN ] Object containing list [AlnColumn *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_AlnColumn(AlnColumn * obj,int (*comp)(AlnUnit *, AlnUnit *)) { qsort_AlnColumn(obj->alu,0,obj->len-1,comp); return; } /* Function: expand_AlnColumn(obj,len) * * Descrip: Really an internal function for add_AlnColumn * * * Arg: obj [UNKN ] Object which contains the list [AlnColumn *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_AlnColumn(AlnColumn * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_AlnColumn called with no need"); return TRUE; } if( (obj->alu = (AlnUnit ** ) ckrealloc (obj->alu,sizeof(AlnUnit *)*len)) == NULL) { warn("ckrealloc failed for expand_AlnColumn, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_AlnColumn(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AlnColumn *] * Arg: add [OWNER] Object to add to the list [AlnUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_AlnColumn(AlnColumn * obj,AlnUnit * add) { if( obj->len >= obj->maxlen) { if( expand_AlnColumn(obj,obj->len + AlnColumnLISTLENGTH) == FALSE) return FALSE; } obj->alu[obj->len++]=add; return TRUE; } /* Function: flush_AlnColumn(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AlnColumn *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_AlnColumn(AlnColumn * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->alu[i] != NULL) { free_AlnUnit(obj->alu[i]); obj->alu[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: AlnColumn_alloc_std(void) * * Descrip: Equivalent to AlnColumn_alloc_len(AlnColumnLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * AlnColumn_alloc_std(void) { return AlnColumn_alloc_len(AlnColumnLISTLENGTH); } /* Function: AlnColumn_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * AlnColumn_alloc_len(int len) { AlnColumn * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = AlnColumn_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->alu = (AlnUnit ** ) ckcalloc (len,sizeof(AlnUnit *))) == NULL) { warn("Warning, ckcalloc failed in AlnColumn_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_AlnColumn(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnColumn *] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * hard_link_AlnColumn(AlnColumn * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlnColumn object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlnColumn_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * AlnColumn_alloc(void) { AlnColumn * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlnColumn *) ckalloc (sizeof(AlnColumn))) == NULL) { warn("AlnColumn_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->alu = NULL; out->len = out->maxlen = 0; return out; } /* Function: hard_link_AlnSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnSequence *] * * Return [UNKN ] Undocumented return value [AlnSequence *] * */ AlnSequence * hard_link_AlnSequence(AlnSequence * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlnSequence object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlnSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnSequence *] * */ AlnSequence * AlnSequence_alloc(void) { AlnSequence * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlnSequence *) ckalloc (sizeof(AlnSequence))) == NULL) { warn("AlnSequence_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = NULL; out->data_type = 0; out->bio_start = 1; out->bio_end = -1; return out; } /* Function: free_AlnSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnSequence *] * * Return [UNKN ] Undocumented return value [AlnSequence *] * */ AlnSequence * free_AlnSequence(AlnSequence * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AlnSequence obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->start != NULL) free_AlnUnit(obj->start); /* obj->data is linked in */ ckfree(obj); return NULL; } /* Function: swap_AlnBlock(list,i,j) * * Descrip: swap function: an internal for qsort_AlnBlock * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [AlnSequence **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_AlnBlock(AlnSequence ** list,int i,int j) { AlnSequence * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_AlnBlock(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_AlnBlock which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [AlnSequence **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_AlnBlock(AlnSequence ** list,int left,int right,int (*comp)(AlnSequence * ,AlnSequence * )) { int i,last; if( left >= right ) return; swap_AlnBlock(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_AlnBlock (list,++last,i); } swap_AlnBlock (list,left,last); qsort_AlnBlock(list,left,last-1,comp); qsort_AlnBlock(list,last+1,right,comp); } /* Function: sort_AlnBlock(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_AlnBlock * * * Arg: obj [UNKN ] Object containing list [AlnBlock *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_AlnBlock(AlnBlock * obj,int (*comp)(AlnSequence *, AlnSequence *)) { qsort_AlnBlock(obj->seq,0,obj->len-1,comp); return; } /* Function: expand_AlnBlock(obj,len) * * Descrip: Really an internal function for add_AlnBlock * * * Arg: obj [UNKN ] Object which contains the list [AlnBlock *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_AlnBlock(AlnBlock * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_AlnBlock called with no need"); return TRUE; } if( (obj->seq = (AlnSequence ** ) ckrealloc (obj->seq,sizeof(AlnSequence *)*len)) == NULL) { warn("ckrealloc failed for expand_AlnBlock, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_AlnBlock(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AlnBlock *] * Arg: add [OWNER] Object to add to the list [AlnSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_AlnBlock(AlnBlock * obj,AlnSequence * add) { if( obj->len >= obj->maxlen) { if( expand_AlnBlock(obj,obj->len + AlnBlockLISTLENGTH) == FALSE) return FALSE; } obj->seq[obj->len++]=add; return TRUE; } /* Function: flush_AlnBlock(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AlnBlock *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_AlnBlock(AlnBlock * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->seq[i] != NULL) { free_AlnSequence(obj->seq[i]); obj->seq[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: AlnBlock_alloc_std(void) * * Descrip: Equivalent to AlnBlock_alloc_len(AlnBlockLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * AlnBlock_alloc_std(void) { return AlnBlock_alloc_len(AlnBlockLISTLENGTH); } /* Function: AlnBlock_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * AlnBlock_alloc_len(int len) { AlnBlock * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = AlnBlock_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->seq = (AlnSequence ** ) ckcalloc (len,sizeof(AlnSequence *))) == NULL) { warn("Warning, ckcalloc failed in AlnBlock_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_AlnBlock(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnBlock *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * hard_link_AlnBlock(AlnBlock * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlnBlock object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlnBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * AlnBlock_alloc(void) { AlnBlock * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlnBlock *) ckalloc (sizeof(AlnBlock))) == NULL) { warn("AlnBlock_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = NULL; out->seq = NULL; out->len = out->maxlen = 0; out->length = 0; out->score = 0; return out; } /* Function: free_AlnBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnBlock *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * free_AlnBlock(AlnBlock * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AlnBlock obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->start != NULL) free_AlnColumn(obj->start); if( obj->seq != NULL) { for(i=0;ilen;i++) { if( obj->seq[i] != NULL) free_AlnSequence(obj->seq[i]); } ckfree(obj->seq); } ckfree(obj); return NULL; } /* Function: swap_AlnBlockList(list,i,j) * * Descrip: swap function: an internal for qsort_AlnBlockList * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [AlnBlock **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_AlnBlockList(AlnBlock ** list,int i,int j) { AlnBlock * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_AlnBlockList(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_AlnBlockList which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [AlnBlock **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_AlnBlockList(AlnBlock ** list,int left,int right,int (*comp)(AlnBlock * ,AlnBlock * )) { int i,last; if( left >= right ) return; swap_AlnBlockList(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_AlnBlockList (list,++last,i); } swap_AlnBlockList (list,left,last); qsort_AlnBlockList(list,left,last-1,comp); qsort_AlnBlockList(list,last+1,right,comp); } /* Function: sort_AlnBlockList(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_AlnBlockList * * * Arg: obj [UNKN ] Object containing list [AlnBlockList *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_AlnBlockList(AlnBlockList * obj,int (*comp)(AlnBlock *, AlnBlock *)) { qsort_AlnBlockList(obj->alb,0,obj->len-1,comp); return; } /* Function: expand_AlnBlockList(obj,len) * * Descrip: Really an internal function for add_AlnBlockList * * * Arg: obj [UNKN ] Object which contains the list [AlnBlockList *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_AlnBlockList(AlnBlockList * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_AlnBlockList called with no need"); return TRUE; } if( (obj->alb = (AlnBlock ** ) ckrealloc (obj->alb,sizeof(AlnBlock *)*len)) == NULL) { warn("ckrealloc failed for expand_AlnBlockList, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_AlnBlockList(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AlnBlockList *] * Arg: add [OWNER] Object to add to the list [AlnBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_AlnBlockList(AlnBlockList * obj,AlnBlock * add) { if( obj->len >= obj->maxlen) { if( expand_AlnBlockList(obj,obj->len + AlnBlockListLISTLENGTH) == FALSE) return FALSE; } obj->alb[obj->len++]=add; return TRUE; } /* Function: flush_AlnBlockList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AlnBlockList *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_AlnBlockList(AlnBlockList * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->alb[i] != NULL) { free_AlnBlock(obj->alb[i]); obj->alb[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: AlnBlockList_alloc_std(void) * * Descrip: Equivalent to AlnBlockList_alloc_len(AlnBlockListLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AlnBlockList *] * */ AlnBlockList * AlnBlockList_alloc_std(void) { return AlnBlockList_alloc_len(AlnBlockListLISTLENGTH); } /* Function: AlnBlockList_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AlnBlockList *] * */ AlnBlockList * AlnBlockList_alloc_len(int len) { AlnBlockList * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = AlnBlockList_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->alb = (AlnBlock ** ) ckcalloc (len,sizeof(AlnBlock *))) == NULL) { warn("Warning, ckcalloc failed in AlnBlockList_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_AlnBlockList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnBlockList *] * * Return [UNKN ] Undocumented return value [AlnBlockList *] * */ AlnBlockList * hard_link_AlnBlockList(AlnBlockList * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlnBlockList object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlnBlockList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnBlockList *] * */ AlnBlockList * AlnBlockList_alloc(void) { AlnBlockList * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlnBlockList *) ckalloc (sizeof(AlnBlockList))) == NULL) { warn("AlnBlockList_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->alb = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_AlnBlockList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnBlockList *] * * Return [UNKN ] Undocumented return value [AlnBlockList *] * */ AlnBlockList * free_AlnBlockList(AlnBlockList * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AlnBlockList obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->alb != NULL) { for(i=0;ilen;i++) { if( obj->alb[i] != NULL) free_AlnBlock(obj->alb[i]); } ckfree(obj->alb); } ckfree(obj); return NULL; } /* Function: replace_start_AlnBlock(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnBlock *] * Arg: start [OWNER] New value of the variable [AlnColumn *] * * Return [SOFT ] member variable start [boolean] * */ boolean replace_start_AlnBlock(AlnBlock * obj,AlnColumn * start) { if( obj == NULL) { warn("In replacement function start for object AlnBlock, got a NULL object"); return FALSE; } obj->start = start; return TRUE; } /* Function: access_start_AlnBlock(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnBlock *] * * Return [SOFT ] member variable start [AlnColumn *] * */ AlnColumn * access_start_AlnBlock(AlnBlock * obj) { if( obj == NULL) { warn("In accessor function start for object AlnBlock, got a NULL object"); return NULL; } return obj->start; } /* Function: access_seq_AlnBlock(obj,i) * * Descrip: Access members stored in the seq list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [AlnBlock *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [AlnSequence *] * */ AlnSequence * access_seq_AlnBlock(AlnBlock * obj,int i) { if( obj == NULL) { warn("In accessor function seq for object AlnBlock, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function seq for object AlnBlock, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->seq[i]; } /* Function: length_seq_AlnBlock(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [AlnBlock *] * * Return [UNKN ] length of the list [int] * */ int length_seq_AlnBlock(AlnBlock * obj) { if( obj == NULL) { warn("In length function seq for object AlnBlock, got a NULL object"); return -1; } return obj->len; } /* Function: replace_length_AlnBlock(obj,length) * * Descrip: Replace member variable length * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnBlock *] * Arg: length [OWNER] New value of the variable [int] * * Return [SOFT ] member variable length [boolean] * */ boolean replace_length_AlnBlock(AlnBlock * obj,int length) { if( obj == NULL) { warn("In replacement function length for object AlnBlock, got a NULL object"); return FALSE; } obj->length = length; return TRUE; } /* Function: access_length_AlnBlock(obj) * * Descrip: Access member variable length * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnBlock *] * * Return [SOFT ] member variable length [int] * */ int access_length_AlnBlock(AlnBlock * obj) { if( obj == NULL) { warn("In accessor function length for object AlnBlock, got a NULL object"); return 0; } return obj->length; } /* Function: replace_score_AlnBlock(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnBlock *] * Arg: score [OWNER] New value of the variable [int] * * Return [SOFT ] member variable score [boolean] * */ boolean replace_score_AlnBlock(AlnBlock * obj,int score) { if( obj == NULL) { warn("In replacement function score for object AlnBlock, got a NULL object"); return FALSE; } obj->score = score; return TRUE; } /* Function: access_score_AlnBlock(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnBlock *] * * Return [SOFT ] member variable score [int] * */ int access_score_AlnBlock(AlnBlock * obj) { if( obj == NULL) { warn("In accessor function score for object AlnBlock, got a NULL object"); return 0; } return obj->score; } /* Function: access_alu_AlnColumn(obj,i) * * Descrip: Access members stored in the alu list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [AlnColumn *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [AlnUnit *] * */ AlnUnit * access_alu_AlnColumn(AlnColumn * obj,int i) { if( obj == NULL) { warn("In accessor function alu for object AlnColumn, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function alu for object AlnColumn, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->alu[i]; } /* Function: length_alu_AlnColumn(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [AlnColumn *] * * Return [UNKN ] length of the list [int] * */ int length_alu_AlnColumn(AlnColumn * obj) { if( obj == NULL) { warn("In length function alu for object AlnColumn, got a NULL object"); return -1; } return obj->len; } /* Function: replace_next_AlnColumn(obj,next) * * Descrip: Replace member variable next * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnColumn *] * Arg: next [OWNER] New value of the variable [AlnColumn *] * * Return [SOFT ] member variable next [boolean] * */ boolean replace_next_AlnColumn(AlnColumn * obj,AlnColumn * next) { if( obj == NULL) { warn("In replacement function next for object AlnColumn, got a NULL object"); return FALSE; } obj->next = next; return TRUE; } /* Function: access_next_AlnColumn(obj) * * Descrip: Access member variable next * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnColumn *] * * Return [SOFT ] member variable next [AlnColumn *] * */ AlnColumn * access_next_AlnColumn(AlnColumn * obj) { if( obj == NULL) { warn("In accessor function next for object AlnColumn, got a NULL object"); return NULL; } return obj->next; } /* Function: replace_start_AlnUnit(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * Arg: start [OWNER] New value of the variable [int] * * Return [SOFT ] member variable start [boolean] * */ boolean replace_start_AlnUnit(AlnUnit * obj,int start) { if( obj == NULL) { warn("In replacement function start for object AlnUnit, got a NULL object"); return FALSE; } obj->start = start; return TRUE; } /* Function: access_start_AlnUnit(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * * Return [SOFT ] member variable start [int] * */ int access_start_AlnUnit(AlnUnit * obj) { if( obj == NULL) { warn("In accessor function start for object AlnUnit, got a NULL object"); return 0; } return obj->start; } /* Function: replace_end_AlnUnit(obj,end) * * Descrip: Replace member variable end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * Arg: end [OWNER] New value of the variable [int] * * Return [SOFT ] member variable end [boolean] * */ boolean replace_end_AlnUnit(AlnUnit * obj,int end) { if( obj == NULL) { warn("In replacement function end for object AlnUnit, got a NULL object"); return FALSE; } obj->end = end; return TRUE; } /* Function: access_end_AlnUnit(obj) * * Descrip: Access member variable end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * * Return [SOFT ] member variable end [int] * */ int access_end_AlnUnit(AlnUnit * obj) { if( obj == NULL) { warn("In accessor function end for object AlnUnit, got a NULL object"); return 0; } return obj->end; } /* Function: replace_label_AlnUnit(obj,label) * * Descrip: Replace member variable label * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * Arg: label [OWNER] New value of the variable [int] * * Return [SOFT ] member variable label [boolean] * */ boolean replace_label_AlnUnit(AlnUnit * obj,int label) { if( obj == NULL) { warn("In replacement function label for object AlnUnit, got a NULL object"); return FALSE; } obj->label = label; return TRUE; } /* Function: access_label_AlnUnit(obj) * * Descrip: Access member variable label * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * * Return [SOFT ] member variable label [int] * */ int access_label_AlnUnit(AlnUnit * obj) { if( obj == NULL) { warn("In accessor function label for object AlnUnit, got a NULL object"); return 0; } return obj->label; } /* Function: replace_text_label_AlnUnit(obj,text_label) * * Descrip: Replace member variable text_label * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * Arg: text_label [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable text_label [boolean] * */ boolean replace_text_label_AlnUnit(AlnUnit * obj,char * text_label) { if( obj == NULL) { warn("In replacement function text_label for object AlnUnit, got a NULL object"); return FALSE; } obj->text_label = text_label; return TRUE; } /* Function: access_text_label_AlnUnit(obj) * * Descrip: Access member variable text_label * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * * Return [SOFT ] member variable text_label [char *] * */ char * access_text_label_AlnUnit(AlnUnit * obj) { if( obj == NULL) { warn("In accessor function text_label for object AlnUnit, got a NULL object"); return NULL; } return obj->text_label; } /* Function: replace_next_AlnUnit(obj,next) * * Descrip: Replace member variable next * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * Arg: next [OWNER] New value of the variable [AlnUnit *] * * Return [SOFT ] member variable next [boolean] * */ boolean replace_next_AlnUnit(AlnUnit * obj,AlnUnit * next) { if( obj == NULL) { warn("In replacement function next for object AlnUnit, got a NULL object"); return FALSE; } obj->next = next; return TRUE; } /* Function: access_next_AlnUnit(obj) * * Descrip: Access member variable next * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * * Return [SOFT ] member variable next [AlnUnit *] * */ AlnUnit * access_next_AlnUnit(AlnUnit * obj) { if( obj == NULL) { warn("In accessor function next for object AlnUnit, got a NULL object"); return NULL; } return obj->next; } /* Function: replace_in_column_AlnUnit(obj,in_column) * * Descrip: Replace member variable in_column * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * Arg: in_column [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable in_column [boolean] * */ boolean replace_in_column_AlnUnit(AlnUnit * obj,boolean in_column) { if( obj == NULL) { warn("In replacement function in_column for object AlnUnit, got a NULL object"); return FALSE; } obj->in_column = in_column; return TRUE; } /* Function: access_in_column_AlnUnit(obj) * * Descrip: Access member variable in_column * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * * Return [SOFT ] member variable in_column [boolean] * */ boolean access_in_column_AlnUnit(AlnUnit * obj) { if( obj == NULL) { warn("In accessor function in_column for object AlnUnit, got a NULL object"); return FALSE; } return obj->in_column; } /* Function: replace_seq_AlnUnit(obj,seq) * * Descrip: Replace member variable seq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * Arg: seq [OWNER] New value of the variable [AlnSequence *] * * Return [SOFT ] member variable seq [boolean] * */ boolean replace_seq_AlnUnit(AlnUnit * obj,AlnSequence * seq) { if( obj == NULL) { warn("In replacement function seq for object AlnUnit, got a NULL object"); return FALSE; } obj->seq = seq; return TRUE; } /* Function: access_seq_AlnUnit(obj) * * Descrip: Access member variable seq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnUnit *] * * Return [SOFT ] member variable seq [AlnSequence *] * */ AlnSequence * access_seq_AlnUnit(AlnUnit * obj) { if( obj == NULL) { warn("In accessor function seq for object AlnUnit, got a NULL object"); return NULL; } return obj->seq; } /* Function: replace_start_AlnSequence(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnSequence *] * Arg: start [OWNER] New value of the variable [AlnUnit *] * * Return [SOFT ] member variable start [boolean] * */ boolean replace_start_AlnSequence(AlnSequence * obj,AlnUnit * start) { if( obj == NULL) { warn("In replacement function start for object AlnSequence, got a NULL object"); return FALSE; } obj->start = start; return TRUE; } /* Function: access_start_AlnSequence(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnSequence *] * * Return [SOFT ] member variable start [AlnUnit *] * */ AlnUnit * access_start_AlnSequence(AlnSequence * obj) { if( obj == NULL) { warn("In accessor function start for object AlnSequence, got a NULL object"); return NULL; } return obj->start; } /* Function: replace_data_type_AlnSequence(obj,data_type) * * Descrip: Replace member variable data_type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnSequence *] * Arg: data_type [OWNER] New value of the variable [int] * * Return [SOFT ] member variable data_type [boolean] * */ boolean replace_data_type_AlnSequence(AlnSequence * obj,int data_type) { if( obj == NULL) { warn("In replacement function data_type for object AlnSequence, got a NULL object"); return FALSE; } obj->data_type = data_type; return TRUE; } /* Function: access_data_type_AlnSequence(obj) * * Descrip: Access member variable data_type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnSequence *] * * Return [SOFT ] member variable data_type [int] * */ int access_data_type_AlnSequence(AlnSequence * obj) { if( obj == NULL) { warn("In accessor function data_type for object AlnSequence, got a NULL object"); return 0; } return obj->data_type; } /* Function: replace_data_AlnSequence(obj,data) * * Descrip: Replace member variable data * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnSequence *] * Arg: data [OWNER] New value of the variable [void *] * * Return [SOFT ] member variable data [boolean] * */ boolean replace_data_AlnSequence(AlnSequence * obj,void * data) { if( obj == NULL) { warn("In replacement function data for object AlnSequence, got a NULL object"); return FALSE; } obj->data = data; return TRUE; } /* Function: access_data_AlnSequence(obj) * * Descrip: Access member variable data * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnSequence *] * * Return [SOFT ] member variable data [void *] * */ void * access_data_AlnSequence(AlnSequence * obj) { if( obj == NULL) { warn("In accessor function data for object AlnSequence, got a NULL object"); return NULL; } return obj->data; } /* Function: replace_bio_start_AlnSequence(obj,bio_start) * * Descrip: Replace member variable bio_start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnSequence *] * Arg: bio_start [OWNER] New value of the variable [int] * * Return [SOFT ] member variable bio_start [boolean] * */ boolean replace_bio_start_AlnSequence(AlnSequence * obj,int bio_start) { if( obj == NULL) { warn("In replacement function bio_start for object AlnSequence, got a NULL object"); return FALSE; } obj->bio_start = bio_start; return TRUE; } /* Function: access_bio_start_AlnSequence(obj) * * Descrip: Access member variable bio_start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnSequence *] * * Return [SOFT ] member variable bio_start [int] * */ int access_bio_start_AlnSequence(AlnSequence * obj) { if( obj == NULL) { warn("In accessor function bio_start for object AlnSequence, got a NULL object"); return 0; } return obj->bio_start; } /* Function: replace_bio_end_AlnSequence(obj,bio_end) * * Descrip: Replace member variable bio_end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnSequence *] * Arg: bio_end [OWNER] New value of the variable [int] * * Return [SOFT ] member variable bio_end [boolean] * */ boolean replace_bio_end_AlnSequence(AlnSequence * obj,int bio_end) { if( obj == NULL) { warn("In replacement function bio_end for object AlnSequence, got a NULL object"); return FALSE; } obj->bio_end = bio_end; return TRUE; } /* Function: access_bio_end_AlnSequence(obj) * * Descrip: Access member variable bio_end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnSequence *] * * Return [SOFT ] member variable bio_end [int] * */ int access_bio_end_AlnSequence(AlnSequence * obj) { if( obj == NULL) { warn("In accessor function bio_end for object AlnSequence, got a NULL object"); return 0; } return obj->bio_end; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/aln.h0000644000175000001440000011006310670453712015562 0ustar philippusers#ifndef DYNAMITEalnHEADERFILE #define DYNAMITEalnHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #define AlnColumnLISTLENGTH 32 #define AlnBlockLISTLENGTH 32 #define AlnBlockListLISTLENGTH 32 #define AlnUnitSCORENUMBER 8 #ifndef DYNAMITE_DEFINED_AlnColumn typedef struct Wise2_AlnColumn Wise2_AlnColumn; #define AlnColumn Wise2_AlnColumn #define DYNAMITE_DEFINED_AlnColumn #endif #ifndef DYNAMITE_DEFINED_AlnUnit typedef struct Wise2_AlnUnit Wise2_AlnUnit; #define AlnUnit Wise2_AlnUnit #define DYNAMITE_DEFINED_AlnUnit #endif #ifndef DYNAMITE_DEFINED_AlnSequence typedef struct Wise2_AlnSequence Wise2_AlnSequence; #define AlnSequence Wise2_AlnSequence #define DYNAMITE_DEFINED_AlnSequence #endif /* Object AlnUnit * * Descrip: This is the basic unit of the label alignment. * It describes a single mark-up over one sequence: * being a start, an end and a text_label. * * */ struct Wise2_AlnUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start; /* start position in the sequence */ int end; /* end position in the sequence */ int label; /* not used */ char * text_label; /* text label of this position */ AlnUnit * next; /* next AlnUnit in this sequence */ int score[AlnUnitSCORENUMBER]; /* a series of scores for this position. */ boolean in_column; /* not used */ AlnSequence * seq; } ; /* AlnUnit defined */ #ifndef DYNAMITE_DEFINED_AlnUnit typedef struct Wise2_AlnUnit Wise2_AlnUnit; #define AlnUnit Wise2_AlnUnit #define DYNAMITE_DEFINED_AlnUnit #endif /* Object AlnColumn * * Descrip: This is a coupling of AlnUnits from different sequences. * Each AlnUnit is meant to represent *the equivalent* piece * of biological information in some sense (ie, they are * alignmed), even though quite possibly they are very * different types of information * * */ struct Wise2_AlnColumn { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif AlnUnit ** alu; /* list of the AlnUnits in this column */ int len;/* len for above alu */ int maxlen; /* maxlen for above alu */ AlnColumn * next; /* the next AlnColumn in this block */ } ; /* AlnColumn defined */ #ifndef DYNAMITE_DEFINED_AlnColumn typedef struct Wise2_AlnColumn Wise2_AlnColumn; #define AlnColumn Wise2_AlnColumn #define DYNAMITE_DEFINED_AlnColumn #endif /* Object AlnSequence * * Descrip: Each Sequence in an AlnBlock is represented by one of these, and * in many ways this is an orthogonal way of looking at the alignment * than the AlnColumns. If you look at the alignment from one * AlnSequence you will just see the individual labels on this * sequence * * */ struct Wise2_AlnSequence { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif AlnUnit * start; /* the first AlnUnit of this sequence */ int data_type; /* not used */ void * data; /* not used - don't use! */ int bio_start; /* start of this sequence in its 'bio' coordinates */ int bio_end; /* end of this sequence in its 'bio' coordinates */ } ; /* AlnSequence defined */ #ifndef DYNAMITE_DEFINED_AlnSequence typedef struct Wise2_AlnSequence Wise2_AlnSequence; #define AlnSequence Wise2_AlnSequence #define DYNAMITE_DEFINED_AlnSequence #endif /* Object AlnBlock * * Descrip: AlnBlock is the main representation of alignments from Dynamite. Each * AlnBlock represents any number of 'sequences', of any type, which share * things in common. The alignment is represented by a series of /AlnColumns * (linked list) in which each AlnColumn has a series of AlnUnits, each * Unit being a start/end/text_label triple. Alternatively, one can see * each sequence in isolation, and not ask what it is aligned to, but rather * what labels it has on it. * * */ struct Wise2_AlnBlock { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif AlnColumn * start; /* the first AlnColumn in the alignment */ AlnSequence ** seq; /* a list of AlnSequences in the alignment */ int len;/* len for above seq */ int maxlen; /* maxlen for above seq */ int length; /* not used */ int score; /* not used */ } ; /* AlnBlock defined */ #ifndef DYNAMITE_DEFINED_AlnBlock typedef struct Wise2_AlnBlock Wise2_AlnBlock; #define AlnBlock Wise2_AlnBlock #define DYNAMITE_DEFINED_AlnBlock #endif /* Object AlnBlockList * * Descrip: No Description * */ struct Wise2_AlnBlockList { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif AlnBlock ** alb; int len;/* len for above alb */ int maxlen; /* maxlen for above alb */ } ; /* AlnBlockList defined */ #ifndef DYNAMITE_DEFINED_AlnBlockList typedef struct Wise2_AlnBlockList Wise2_AlnBlockList; #define AlnBlockList Wise2_AlnBlockList #define DYNAMITE_DEFINED_AlnBlockList #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: collapsed_AlnBlock(alb,comp_row) * * Descrip: This function builds a new "collapsed" AlnBlock * on the similarity of one AlnSeq row * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: comp_row [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_collapsed_AlnBlock(AlnBlock * alb,int comp_row); #define collapsed_AlnBlock Wise2_collapsed_AlnBlock /* Function: add_to_anchored_AlnBlock(growing,add) * * Descrip: This function assummes that the first AlnSequence * in the current and the adding AlnBlock are the same, * and that you want to add the second AlnSequence of the * second alnblock to the first, anchored on the first * sequence. * * In other words, this builds up an anchored alignment, on * the first sequence * * This AlnBlock, like many others, consumes the sequence * in the second alnblock, unsetting things so that it is * valid. This makes for some pretty hairy coding. * * * Arg: growing [UNKN ] Undocumented argument [AlnBlock *] * Arg: add [UNKN ] Undocumented argument [AlnBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_to_anchored_AlnBlock(AlnBlock * growing,AlnBlock * add); #define add_to_anchored_AlnBlock Wise2_add_to_anchored_AlnBlock /* Function: single_unit_AlnBlock(len,label) * * Descrip: This function makes a new AlnBlock of length len * and depth one, with each Block having the given * label and start = 0 end = start +1; * * It starts with a alu going from -1 to 0 * * * Arg: len [UNKN ] Undocumented argument [int] * Arg: label [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_single_unit_AlnBlock(int len,char * label); #define single_unit_AlnBlock Wise2_single_unit_AlnBlock /* Function: split_AlnBlock(alb,is_spacer_column) * * Descrip: This function splits an AlnBlock into * separate alignments (stored in the resulting AlnBlockList). * * The alb is split wherever there is a column that returns * true to the is_spacer_column function, discarding these * columns * * This function completely destroys the AlnBlock object that * is passed in, but to make sure that API functions dont * get confused, the alb that is passed in is simply stripped * of its AlnColumn information (so it is still a valid alb, * if empty). But - beware - all the alncolumns might or might * not be there, so dont pass in albs and hold on to anything * inside them! * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: is_spacer_column [UNKN ] Undocumented argument [NullString] * * Return [UNKN ] Undocumented return value [AlnBlockList *] * */ AlnBlockList * Wise2_split_AlnBlock(AlnBlock * alb,boolean (*is_spacer_column)(const AlnColumn * alc)); #define split_AlnBlock Wise2_split_AlnBlock /* Function: score_line_from_AlnBlock(alb,seqno) * * Descrip: gets the score out for a particular alb sequence * line * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: seqno [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_score_line_from_AlnBlock(AlnBlock * alb,int seqno); #define score_line_from_AlnBlock Wise2_score_line_from_AlnBlock /* Function: at_end_AlnColumn(alc) * * Descrip: This tells you whether the AlnColumn is at the * end without passing NULL's around * * * * Arg: alc [READ ] AlnColumn [AlnColumn *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_at_end_AlnColumn(AlnColumn * alc); #define at_end_AlnColumn Wise2_at_end_AlnColumn /* Function: bio_start_AlnUnit(alu) * * Descrip: Tells the bio-coordinate of the * start point of this alnunit * * * Arg: alu [UNKN ] Undocumented argument [AlnUnit *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_bio_start_AlnUnit(AlnUnit * alu); #define bio_start_AlnUnit Wise2_bio_start_AlnUnit /* Function: bio_end_AlnUnit(alu) * * Descrip: Tells the bio-coordinate of the * end point of this alnunit * * * Arg: alu [UNKN ] Undocumented argument [AlnUnit *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_bio_end_AlnUnit(AlnUnit * alu); #define bio_end_AlnUnit Wise2_bio_end_AlnUnit /* Function: swallow_AlnColumn_multiple(master,eaten,comp_func) * * Descrip: This function will 'swallow' any number of AlnColumns as long * as the comparison function of the labels match (the basic * comp function would be something like strcmp(a,b) == 0 ? TRUE : FALSE) * The columns are 'swallowed' into master and come from eaten. (these * columns could be in the same linked list, though it only makes sense * if the master is before the eaten). * * It returns the first column that it could not swallow. * * you use this to collapse regions of the label alignment. * * * Arg: master [UNKN ] column which will eat other columns [AlnColumn *] * Arg: eaten [UNKN ] column which will be consumed [AlnColumn *] * Arg: comp_func [FUNCP] comparison function for label set [boolean (*comp_func] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * Wise2_swallow_AlnColumn_multiple(AlnColumn * master,AlnColumn * eaten,boolean (*comp_func)(char *,char *)); #define swallow_AlnColumn_multiple Wise2_swallow_AlnColumn_multiple /* Function: swallow_AlnColumn_number(master,eaten,num,comp_func) * * Descrip: Basicaly the same as /swallow_AlnColumn_mulitple but there is a maximum number * of columns it will swallow * * * Arg: master [UNKN ] column which will eat other columns [AlnColumn *] * Arg: eaten [UNKN ] column which will be consumed [AlnColumn *] * Arg: num [UNKN ] max number of columns to eat [int] * Arg: comp_func [FUNCP] comparison function for label set [boolean (*comp_func] * * Return [UNKN ] number of columns eaten [int] * */ int Wise2_swallow_AlnColumn_number(AlnColumn * master,AlnColumn * eaten,int num,boolean (*comp_func)(char *,char *)); #define swallow_AlnColumn_number Wise2_swallow_AlnColumn_number /* Function: swallow_AlnColumn(master,eaten,comp_func) * * Descrip: This is the function that actually does the 'swallowing'. It will * try to swallow eaten into master. If comp_func does not give us an * ok (actually using /can_swallow_AlnColumn it returns FALSE. Otherwise * it moves on the end of AlnColumn in master to eaten and adds the * score of eaten to master. * * * Arg: master [UNKN ] column which will eat [AlnColumn *] * Arg: eaten [UNKN ] column which will dissappear into master if eatable [AlnColumn *] * Arg: comp_func [FUNCP] comparison function for labels [boolean (*comp_func] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_swallow_AlnColumn(AlnColumn * master,AlnColumn * eaten,boolean (*comp_func)(char *,char *)); #define swallow_AlnColumn Wise2_swallow_AlnColumn /* Function: replace_and_free_AlnColumn_with_one(start,end,insert) * * Descrip: Linked list manipulation function * * Puts insert between start and end, and free's from start->next * onwards. *Beware* if start is linked to end before calling this * function thsi wil free end and everything chained to it. Think * before you call this! * * * Arg: start [UNKN ] Undocumented argument [AlnColumn *] * Arg: end [UNKN ] Undocumented argument [AlnColumn *] * Arg: insert [UNKN ] Undocumented argument [AlnColumn *] * */ void Wise2_replace_and_free_AlnColumn_with_one(AlnColumn * start,AlnColumn * end,AlnColumn * insert); #define replace_and_free_AlnColumn_with_one Wise2_replace_and_free_AlnColumn_with_one /* Function: replace_AlnColumn_with_one(start,end,insert) * * Descrip: Linked list manipulation function * * places insert between start and end. If start/end are not * continuous then it will loop out the start/end region * * * Arg: start [UNKN ] Undocumented argument [AlnColumn *] * Arg: end [UNKN ] Undocumented argument [AlnColumn *] * Arg: insert [UNKN ] Undocumented argument [AlnColumn *] * */ void Wise2_replace_AlnColumn_with_one(AlnColumn * start,AlnColumn * end,AlnColumn * insert); #define replace_AlnColumn_with_one Wise2_replace_AlnColumn_with_one /* Function: insert_AlnColumn(start,insert) * * Descrip: Linked list manipulation function * * places insert just after start: links insert * up to what start was linked to * * * Arg: start [UNKN ] Undocumented argument [AlnColumn *] * Arg: insert [UNKN ] Undocumented argument [AlnColumn *] * */ void Wise2_insert_AlnColumn(AlnColumn * start,AlnColumn * insert); #define insert_AlnColumn Wise2_insert_AlnColumn /* Function: go_back_n_AlnColumn(alb,start,n) * * Descrip: Linked list movement function * * A nasty function to reverse up a singly linked list by going to * the start and coming back until you are in the current position. yuk. * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: start [UNKN ] Undocumented argument [AlnColumn *] * Arg: n [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * Wise2_go_back_n_AlnColumn(AlnBlock * alb,AlnColumn * start,int n); #define go_back_n_AlnColumn Wise2_go_back_n_AlnColumn /* Function: dump_ascii_AlnBlock(alb,ofp) * * Descrip: Dumps the alignment in rereadable ascii form. * * Not really for human consumption * * * Arg: alb [UNKN ] AlnBlock to dump [AlnBlock *] * Arg: ofp [UNKN ] File stream to dump to [FILE *] * */ void Wise2_dump_ascii_AlnBlock(AlnBlock * alb,FILE * ofp); #define dump_ascii_AlnBlock Wise2_dump_ascii_AlnBlock /* Function: mapped_ascii_AlnBlockList(alb,score_to_double,*al,ofp) * * Descrip: Shows a list of AlnBlocks with an arbitary mapping * of the score to some other system * * * Arg: alb [UNKN ] AlnBlock to dump [NullString] * Arg: score_to_double [UNKN ] Undocumented argument [NullString] * Arg: *al [UNKN ] Undocumented argument [AlnBlockList] * Arg: ofp [UNKN ] File stream to dump to [FILE *] * */ void Wise2_mapped_ascii_AlnBlockList(AlnBlockList *al,double (*score_to_double)(int),FILE * ofp); #define mapped_ascii_AlnBlockList Wise2_mapped_ascii_AlnBlockList /* Function: mapped_ascii_AlnBlock(alb,score_to_double,do_cumlative,ofp) * * Descrip: Shows AlnBlock with an arbitary mapping of * the score to some other system. * * * Arg: alb [UNKN ] AlnBlock to dump [AlnBlock *] * Arg: score_to_double [UNKN ] Undocumented argument [NullString] * Arg: do_cumlative [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] File stream to dump to [FILE *] * */ void Wise2_mapped_ascii_AlnBlock(AlnBlock * alb,double (*score_to_double)(int),int do_cumlative,FILE * ofp); #define mapped_ascii_AlnBlock Wise2_mapped_ascii_AlnBlock /* Function: read_ascii_dump_AlnBlock(ifp) * * Descrip: Reads an ascii dumped alignment * * * Arg: ifp [UNKN ] File stream to read from [FILE *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_read_ascii_dump_AlnBlock(FILE * ifp); #define read_ascii_dump_AlnBlock Wise2_read_ascii_dump_AlnBlock /* Function: show_flat_AlnBlock(alb,ofp) * * Descrip: Shows the AlnBlock in vaguely human * readable form * * * Arg: alb [UNKN ] AlnBlock to show [AlnBlock *] * Arg: ofp [UNKN ] output [FILE *] * */ void Wise2_show_flat_AlnBlock(AlnBlock * alb,FILE * ofp); #define show_flat_AlnBlock Wise2_show_flat_AlnBlock /* Function: get_second_end_AlnColumn(alb) * * Descrip: Not sure if this is used! * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * Wise2_get_second_end_AlnColumn(AlnBlock * alb); #define get_second_end_AlnColumn Wise2_get_second_end_AlnColumn /* Function: get_end_AlnColumn(alb) * * Descrip: To get to the last AlnColumn. If this was * a doubly linked list, life would be much easier * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * Wise2_get_end_AlnColumn(AlnBlock * alb); #define get_end_AlnColumn Wise2_get_end_AlnColumn /* Function: link_AlnUnits_AlnBlock(alb) * * Descrip: Links up all AlnUnits to their parent * sequences * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_link_AlnUnits_AlnBlock(AlnBlock * alb); #define link_AlnUnits_AlnBlock Wise2_link_AlnUnits_AlnBlock /* Function: new_pairwise_AlnColumn(void) * * Descrip: Function as a constructor for the special * case of a pairwise alignment. Makes an * AlnColumn and puts in two AlnUnits all ready * to be linked in. * * * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * Wise2_new_pairwise_AlnColumn(void); #define new_pairwise_AlnColumn Wise2_new_pairwise_AlnColumn /* Function: free_AlnColumn(obj) * * Descrip: Specilased deconstructor needed because * of linked list nature of the data structure * * * Arg: obj [UNKN ] Undocumented argument [AlnColumn *] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * Wise2_free_AlnColumn(AlnColumn * obj); #define free_AlnColumn Wise2_free_AlnColumn /* Function: free_AlnUnit(obj) * * Descrip: Specilased deconstructor needed because * of linked list nature of the data structure * * * Arg: obj [UNKN ] Undocumented argument [AlnUnit *] * * Return [UNKN ] Undocumented return value [AlnUnit *] * */ AlnUnit * Wise2_free_AlnUnit(AlnUnit * obj); #define free_AlnUnit Wise2_free_AlnUnit /* Function: hard_link_AlnUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnUnit *] * * Return [UNKN ] Undocumented return value [AlnUnit *] * */ AlnUnit * Wise2_hard_link_AlnUnit(AlnUnit * obj); #define hard_link_AlnUnit Wise2_hard_link_AlnUnit /* Function: AlnUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnUnit *] * */ AlnUnit * Wise2_AlnUnit_alloc(void); #define AlnUnit_alloc Wise2_AlnUnit_alloc /* Function: add_AlnColumn(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AlnColumn *] * Arg: add [OWNER] Object to add to the list [AlnUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_AlnColumn(AlnColumn * obj,AlnUnit * add); #define add_AlnColumn Wise2_add_AlnColumn /* Function: flush_AlnColumn(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AlnColumn *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_AlnColumn(AlnColumn * obj); #define flush_AlnColumn Wise2_flush_AlnColumn /* Function: AlnColumn_alloc_std(void) * * Descrip: Equivalent to AlnColumn_alloc_len(AlnColumnLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * Wise2_AlnColumn_alloc_std(void); #define AlnColumn_alloc_std Wise2_AlnColumn_alloc_std /* Function: AlnColumn_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * Wise2_AlnColumn_alloc_len(int len); #define AlnColumn_alloc_len Wise2_AlnColumn_alloc_len /* Function: hard_link_AlnColumn(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnColumn *] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * Wise2_hard_link_AlnColumn(AlnColumn * obj); #define hard_link_AlnColumn Wise2_hard_link_AlnColumn /* Function: AlnColumn_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ AlnColumn * Wise2_AlnColumn_alloc(void); #define AlnColumn_alloc Wise2_AlnColumn_alloc /* Function: hard_link_AlnSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnSequence *] * * Return [UNKN ] Undocumented return value [AlnSequence *] * */ AlnSequence * Wise2_hard_link_AlnSequence(AlnSequence * obj); #define hard_link_AlnSequence Wise2_hard_link_AlnSequence /* Function: AlnSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnSequence *] * */ AlnSequence * Wise2_AlnSequence_alloc(void); #define AlnSequence_alloc Wise2_AlnSequence_alloc /* Function: free_AlnSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnSequence *] * * Return [UNKN ] Undocumented return value [AlnSequence *] * */ AlnSequence * Wise2_free_AlnSequence(AlnSequence * obj); #define free_AlnSequence Wise2_free_AlnSequence /* Function: add_AlnBlock(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AlnBlock *] * Arg: add [OWNER] Object to add to the list [AlnSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_AlnBlock(AlnBlock * obj,AlnSequence * add); #define add_AlnBlock Wise2_add_AlnBlock /* Function: flush_AlnBlock(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AlnBlock *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_AlnBlock(AlnBlock * obj); #define flush_AlnBlock Wise2_flush_AlnBlock /* Function: AlnBlock_alloc_std(void) * * Descrip: Equivalent to AlnBlock_alloc_len(AlnBlockLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_AlnBlock_alloc_std(void); #define AlnBlock_alloc_std Wise2_AlnBlock_alloc_std /* Function: AlnBlock_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_AlnBlock_alloc_len(int len); #define AlnBlock_alloc_len Wise2_AlnBlock_alloc_len /* Function: hard_link_AlnBlock(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnBlock *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_hard_link_AlnBlock(AlnBlock * obj); #define hard_link_AlnBlock Wise2_hard_link_AlnBlock /* Function: AlnBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_AlnBlock_alloc(void); #define AlnBlock_alloc Wise2_AlnBlock_alloc /* Function: free_AlnBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnBlock *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_free_AlnBlock(AlnBlock * obj); #define free_AlnBlock Wise2_free_AlnBlock /* Function: add_AlnBlockList(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AlnBlockList *] * Arg: add [OWNER] Object to add to the list [AlnBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_AlnBlockList(AlnBlockList * obj,AlnBlock * add); #define add_AlnBlockList Wise2_add_AlnBlockList /* Function: flush_AlnBlockList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AlnBlockList *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_AlnBlockList(AlnBlockList * obj); #define flush_AlnBlockList Wise2_flush_AlnBlockList /* Function: AlnBlockList_alloc_std(void) * * Descrip: Equivalent to AlnBlockList_alloc_len(AlnBlockListLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AlnBlockList *] * */ AlnBlockList * Wise2_AlnBlockList_alloc_std(void); #define AlnBlockList_alloc_std Wise2_AlnBlockList_alloc_std /* Function: AlnBlockList_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AlnBlockList *] * */ AlnBlockList * Wise2_AlnBlockList_alloc_len(int len); #define AlnBlockList_alloc_len Wise2_AlnBlockList_alloc_len /* Function: hard_link_AlnBlockList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnBlockList *] * * Return [UNKN ] Undocumented return value [AlnBlockList *] * */ AlnBlockList * Wise2_hard_link_AlnBlockList(AlnBlockList * obj); #define hard_link_AlnBlockList Wise2_hard_link_AlnBlockList /* Function: AlnBlockList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnBlockList *] * */ AlnBlockList * Wise2_AlnBlockList_alloc(void); #define AlnBlockList_alloc Wise2_AlnBlockList_alloc /* Function: free_AlnBlockList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnBlockList *] * * Return [UNKN ] Undocumented return value [AlnBlockList *] * */ AlnBlockList * Wise2_free_AlnBlockList(AlnBlockList * obj); #define free_AlnBlockList Wise2_free_AlnBlockList /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ AlnColumn * Wise2_access_start_AlnBlock(AlnBlock * obj); #define access_start_AlnBlock Wise2_access_start_AlnBlock AlnUnit * Wise2_access_alu_AlnColumn(AlnColumn * obj,int i); #define access_alu_AlnColumn Wise2_access_alu_AlnColumn int Wise2_length_alu_AlnColumn(AlnColumn * obj); #define length_alu_AlnColumn Wise2_length_alu_AlnColumn int Wise2_access_label_AlnUnit(AlnUnit * obj); #define access_label_AlnUnit Wise2_access_label_AlnUnit boolean Wise2_replace_text_label_AlnUnit(AlnUnit * obj,char * text_label); #define replace_text_label_AlnUnit Wise2_replace_text_label_AlnUnit boolean Wise2_replace_start_AlnBlock(AlnBlock * obj,AlnColumn * start); #define replace_start_AlnBlock Wise2_replace_start_AlnBlock boolean Wise2_replace_bio_end_AlnSequence(AlnSequence * obj,int bio_end); #define replace_bio_end_AlnSequence Wise2_replace_bio_end_AlnSequence char * Wise2_access_text_label_AlnUnit(AlnUnit * obj); #define access_text_label_AlnUnit Wise2_access_text_label_AlnUnit int Wise2_length_seq_AlnBlock(AlnBlock * obj); #define length_seq_AlnBlock Wise2_length_seq_AlnBlock boolean Wise2_replace_next_AlnUnit(AlnUnit * obj,AlnUnit * next); #define replace_next_AlnUnit Wise2_replace_next_AlnUnit int Wise2_access_length_AlnBlock(AlnBlock * obj); #define access_length_AlnBlock Wise2_access_length_AlnBlock AlnUnit * Wise2_access_next_AlnUnit(AlnUnit * obj); #define access_next_AlnUnit Wise2_access_next_AlnUnit int Wise2_access_score_AlnBlock(AlnBlock * obj); #define access_score_AlnBlock Wise2_access_score_AlnBlock boolean Wise2_replace_in_column_AlnUnit(AlnUnit * obj,boolean in_column); #define replace_in_column_AlnUnit Wise2_replace_in_column_AlnUnit AlnColumn * Wise2_access_next_AlnColumn(AlnColumn * obj); #define access_next_AlnColumn Wise2_access_next_AlnColumn boolean Wise2_access_in_column_AlnUnit(AlnUnit * obj); #define access_in_column_AlnUnit Wise2_access_in_column_AlnUnit int Wise2_access_start_AlnUnit(AlnUnit * obj); #define access_start_AlnUnit Wise2_access_start_AlnUnit boolean Wise2_replace_seq_AlnUnit(AlnUnit * obj,AlnSequence * seq); #define replace_seq_AlnUnit Wise2_replace_seq_AlnUnit int Wise2_access_end_AlnUnit(AlnUnit * obj); #define access_end_AlnUnit Wise2_access_end_AlnUnit AlnSequence * Wise2_access_seq_AlnUnit(AlnUnit * obj); #define access_seq_AlnUnit Wise2_access_seq_AlnUnit int Wise2_access_bio_end_AlnSequence(AlnSequence * obj); #define access_bio_end_AlnSequence Wise2_access_bio_end_AlnSequence boolean Wise2_replace_start_AlnSequence(AlnSequence * obj,AlnUnit * start); #define replace_start_AlnSequence Wise2_replace_start_AlnSequence boolean Wise2_replace_length_AlnBlock(AlnBlock * obj,int length); #define replace_length_AlnBlock Wise2_replace_length_AlnBlock AlnUnit * Wise2_access_start_AlnSequence(AlnSequence * obj); #define access_start_AlnSequence Wise2_access_start_AlnSequence boolean Wise2_replace_next_AlnColumn(AlnColumn * obj,AlnColumn * next); #define replace_next_AlnColumn Wise2_replace_next_AlnColumn boolean Wise2_replace_data_type_AlnSequence(AlnSequence * obj,int data_type); #define replace_data_type_AlnSequence Wise2_replace_data_type_AlnSequence boolean Wise2_replace_end_AlnUnit(AlnUnit * obj,int end); #define replace_end_AlnUnit Wise2_replace_end_AlnUnit int Wise2_access_data_type_AlnSequence(AlnSequence * obj); #define access_data_type_AlnSequence Wise2_access_data_type_AlnSequence AlnSequence * Wise2_access_seq_AlnBlock(AlnBlock * obj,int i); #define access_seq_AlnBlock Wise2_access_seq_AlnBlock boolean Wise2_replace_data_AlnSequence(AlnSequence * obj,void * data); #define replace_data_AlnSequence Wise2_replace_data_AlnSequence boolean Wise2_replace_start_AlnUnit(AlnUnit * obj,int start); #define replace_start_AlnUnit Wise2_replace_start_AlnUnit void * Wise2_access_data_AlnSequence(AlnSequence * obj); #define access_data_AlnSequence Wise2_access_data_AlnSequence boolean Wise2_replace_score_AlnBlock(AlnBlock * obj,int score); #define replace_score_AlnBlock Wise2_replace_score_AlnBlock boolean Wise2_replace_bio_start_AlnSequence(AlnSequence * obj,int bio_start); #define replace_bio_start_AlnSequence Wise2_replace_bio_start_AlnSequence boolean Wise2_replace_label_AlnUnit(AlnUnit * obj,int label); #define replace_label_AlnUnit Wise2_replace_label_AlnUnit int Wise2_access_bio_start_AlnSequence(AlnSequence * obj); #define access_bio_start_AlnSequence Wise2_access_bio_start_AlnSequence boolean Wise2_can_swallow_AlnColumn(AlnColumn * master,AlnColumn * eaten,boolean (*comp_func)(char *,char *)); #define can_swallow_AlnColumn Wise2_can_swallow_AlnColumn boolean Wise2_identical_labels_in_AlnColumn(AlnColumn * one,AlnColumn * two,boolean (*comp_func)(char *,char *)); #define identical_labels_in_AlnColumn Wise2_identical_labels_in_AlnColumn boolean Wise2_identical_labels_in_AlnUnits(AlnUnit * one,AlnUnit * two,boolean (*comp_func)(char *,char *)); #define identical_labels_in_AlnUnits Wise2_identical_labels_in_AlnUnits AlnColumn * Wise2_read_dumped_ascii_AlnColumn_line(char * line); #define read_dumped_ascii_AlnColumn_line Wise2_read_dumped_ascii_AlnColumn_line void Wise2_show_flat_AlnColumn(AlnColumn * alc,FILE * ofp); #define show_flat_AlnColumn Wise2_show_flat_AlnColumn void Wise2_show_flat_AlnUnit(AlnUnit * alu,FILE * ofp); #define show_flat_AlnUnit Wise2_show_flat_AlnUnit AlnUnit * Wise2_read_flat_AlnUnit_line(char * line,int * ret_pos); #define read_flat_AlnUnit_line Wise2_read_flat_AlnUnit_line void Wise2_swap_AlnColumn(AlnUnit ** list,int i,int j) ; #define swap_AlnColumn Wise2_swap_AlnColumn void Wise2_qsort_AlnColumn(AlnUnit ** list,int left,int right,int (*comp)(AlnUnit * ,AlnUnit * )); #define qsort_AlnColumn Wise2_qsort_AlnColumn void Wise2_sort_AlnColumn(AlnColumn * obj,int (*comp)(AlnUnit *, AlnUnit *)); #define sort_AlnColumn Wise2_sort_AlnColumn boolean Wise2_expand_AlnColumn(AlnColumn * obj,int len); #define expand_AlnColumn Wise2_expand_AlnColumn void Wise2_swap_AlnBlock(AlnSequence ** list,int i,int j) ; #define swap_AlnBlock Wise2_swap_AlnBlock void Wise2_qsort_AlnBlock(AlnSequence ** list,int left,int right,int (*comp)(AlnSequence * ,AlnSequence * )); #define qsort_AlnBlock Wise2_qsort_AlnBlock void Wise2_sort_AlnBlock(AlnBlock * obj,int (*comp)(AlnSequence *, AlnSequence *)); #define sort_AlnBlock Wise2_sort_AlnBlock boolean Wise2_expand_AlnBlock(AlnBlock * obj,int len); #define expand_AlnBlock Wise2_expand_AlnBlock void Wise2_swap_AlnBlockList(AlnBlock ** list,int i,int j) ; #define swap_AlnBlockList Wise2_swap_AlnBlockList void Wise2_qsort_AlnBlockList(AlnBlock ** list,int left,int right,int (*comp)(AlnBlock * ,AlnBlock * )); #define qsort_AlnBlockList Wise2_qsort_AlnBlockList void Wise2_sort_AlnBlockList(AlnBlockList * obj,int (*comp)(AlnBlock *, AlnBlock *)); #define sort_AlnBlockList Wise2_sort_AlnBlockList boolean Wise2_expand_AlnBlockList(AlnBlockList * obj,int len); #define expand_AlnBlockList Wise2_expand_AlnBlockList #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/dynlibcross.dy0000644000175000001440000000227307313404540017526 0ustar philippusers %{ #include "dyna.h" %} %{ #include "dynlibcross.h" %func shows Hscore as bits level %% void show_bits_Hscore(Hscore * out,FILE * ofp) { int i; assert(out); assert(ofp); for(i=0;ilen;i++) fprintf(ofp,"Query %s Target %s Bits %.2f\n",out->ds[i]->query->name, out->ds[i]->target->name,Score2Bits(out->ds[i]->score)); } %func This gives you a standard Hscore module with a cutoff in bits (assumming the score is being made from a standard Probability2Score type function). %% Hscore * std_bits_Hscore(double cut_off_level,int report_stagger) { Hscore * out; out = Hscore_alloc_std(); out->his = new_Histogram(-1000,1000,100); out->score_level = cut_off_level; out->should_store = std_should_store_Hscore; out->score_to_his = std_score_to_his; out->report_level = report_stagger; return out; } %func This function is for the Hscore std constructor, %type internal %% boolean std_should_store_Hscore(int score,double cutoff) { if( Score2Bits(score) > cutoff ) { return TRUE; } return FALSE; } %func This function is for the Hscore std constructor, %type internal %% float std_score_to_his(int score) { return Score2Bits(score); } wise-2.4.1/src/dynlibsrc/dna.c0000644000175000001440000001467110670453712015555 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dna.h" /* Function: truncate_DNA(dna,start,stop) * * Descrip: Truncates a DNA sequence. Basically uses * the /trunc_Sequence function (of course!) * * It does not alter dna, rather it returns a new * sequence with that truncation * * * Arg: dna [READ ] DNA that is truncated [DNA *] * Arg: start [UNKN ] Undocumented argument [int] * Arg: stop [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [DNA *] * */ # line 30 "dna.dy" DNA * truncate_DNA(DNA * dna,int start,int stop) { return DNA_from_Sequence(trunc_Sequence(dna->baseseq,start,stop)); } /* Function: read_fasta_file_DNA (filename) * * Descrip: Reads a fasta file assumming that it is DNA. * Will complain if it is not, and return NULL. * * * Arg: filename [UNKN ] filename to be opened and read [char *] * * Return [UNKN ] Undocumented return value [DNA *] * */ # line 41 "dna.dy" DNA * read_fasta_file_DNA (char * filename) { Sequence * seq; seq = read_fasta_file_Sequence(filename); if( seq == NULL ) { return NULL; } return DNA_from_Sequence(seq); } /* Function: read_fasta_DNA (ifp) * * Descrip: Reads a fasta file assumming that it is DNA. * Will complain if it is not, and return NULL. * * * Arg: ifp [UNKN ] file point to be read from [FILE *] * * Return [UNKN ] Undocumented return value [DNA *] * */ # line 60 "dna.dy" DNA * read_fasta_DNA (FILE * ifp) { Sequence * seq; seq = read_fasta_Sequence(ifp); if( seq == NULL ) { return NULL; } return DNA_from_Sequence(seq); } /* Function: read_efetch_DNA(estr) * * Descrip: Reads a efetch specified query * Uses, of course /read_efetch_Sequence * * * Arg: estr [READ ] efetch string which is read [char *] * * Return [UNKN ] Undocumented return value [DNA *] * */ # line 78 "dna.dy" DNA * read_efetch_DNA(char * estr) { return DNA_from_Sequence(read_efetch_Sequence(estr)); } /* Function: read_SRS_DNA(srsquery) * * Descrip: Reads a SRS sequence using srs4 syntax. * Uses, of course, /read_SRS_Sequence * * * * Arg: srsquery [READ ] string query representing SRS name [char *] * * Return [UNKN ] Undocumented return value [DNA *] * */ # line 90 "dna.dy" DNA * read_SRS_DNA(char * srsquery) { return DNA_from_Sequence(read_SRS_Sequence(srsquery)); } /* Function: DNA_name (dna) * * Descrip: Returns the name of the DNA * * * Arg: dna [UNKN ] Undocumented argument [DNA *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 100 "dna.dy" char * DNA_name (DNA * dna) { return dna->baseseq->name; } /* Function: DNA_length (dna) * * Descrip: Returns the length of the DNA * * * Arg: dna [UNKN ] Undocumented argument [DNA *] * * Return [UNKN ] Undocumented return value [int] * */ # line 109 "dna.dy" int DNA_length (DNA * dna) { return dna->baseseq->len; } /* Function: DNA_seqchar(dna,pos) * * Descrip: Returns sequence character at this position. * * * Arg: dna [UNKN ] DNA [DNA *] * Arg: pos [UNKN ] position in DNA to get char [int] * * Return [UNKN ] Undocumented return value [char] * */ # line 120 "dna.dy" char DNA_seqchar(DNA * dna,int pos) { return dna->baseseq->seq[pos]; } /* Function: DNA_from_Sequence(seq) * * Descrip: makes a new DNA from a Sequence. It * owns the Sequence memory, ie will attempt a /free_Sequence * on the structure when /free_DNA is called * * If you want to give this DNA this Sequence and * forget about it, then just hand it this sequence and set * seq to NULL (no need to free it). If you intend to use * the sequence object elsewhere outside of the DNA datastructure * then use DNA_from_Sequence(/hard_link_Sequence(seq)) * * * * Arg: seq [UNKN ] Sequence to make DNA from [Sequence *] * * Return [UNKN ] Undocumented return value [DNA *] * */ # line 140 "dna.dy" DNA * DNA_from_Sequence(Sequence * seq) { DNA * out; if( is_dna_Sequence(seq) == FALSE ) { warn("Trying to make a DNA sequence from a non DNA base sequence [%s].",seq->name); return NULL; } out = DNA_alloc(); out->baseseq = seq; return out; } # line 186 "dna.c" /* Function: hard_link_DNA(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DNA *] * * Return [UNKN ] Undocumented return value [DNA *] * */ DNA * hard_link_DNA(DNA * obj) { if( obj == NULL ) { warn("Trying to hard link to a DNA object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DNA_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DNA *] * */ DNA * DNA_alloc(void) { DNA * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DNA *) ckalloc (sizeof(DNA))) == NULL) { warn("DNA_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->baseseq = NULL; return out; } /* Function: free_DNA(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DNA *] * * Return [UNKN ] Undocumented return value [DNA *] * */ DNA * free_DNA(DNA * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DNA obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->baseseq != NULL) free_Sequence(obj->baseseq); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/dna.h0000644000175000001440000001330410670453712015552 0ustar philippusers#ifndef DYNAMITEdnaHEADERFILE #define DYNAMITEdnaHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" struct Wise2_DNA { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence * baseseq; } ; /* DNA defined */ #ifndef DYNAMITE_DEFINED_DNA typedef struct Wise2_DNA Wise2_DNA; #define DNA Wise2_DNA #define DYNAMITE_DEFINED_DNA #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: truncate_DNA(dna,start,stop) * * Descrip: Truncates a DNA sequence. Basically uses * the /trunc_Sequence function (of course!) * * It does not alter dna, rather it returns a new * sequence with that truncation * * * Arg: dna [READ ] DNA that is truncated [DNA *] * Arg: start [UNKN ] Undocumented argument [int] * Arg: stop [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [DNA *] * */ DNA * Wise2_truncate_DNA(DNA * dna,int start,int stop); #define truncate_DNA Wise2_truncate_DNA /* Function: read_fasta_file_DNA (filename) * * Descrip: Reads a fasta file assumming that it is DNA. * Will complain if it is not, and return NULL. * * * Arg: filename [UNKN ] filename to be opened and read [char *] * * Return [UNKN ] Undocumented return value [DNA *] * */ DNA * Wise2_read_fasta_file_DNA (char * filename); #define read_fasta_file_DNA Wise2_read_fasta_file_DNA /* Function: read_fasta_DNA (ifp) * * Descrip: Reads a fasta file assumming that it is DNA. * Will complain if it is not, and return NULL. * * * Arg: ifp [UNKN ] file point to be read from [FILE *] * * Return [UNKN ] Undocumented return value [DNA *] * */ DNA * Wise2_read_fasta_DNA (FILE * ifp); #define read_fasta_DNA Wise2_read_fasta_DNA /* Function: read_efetch_DNA(estr) * * Descrip: Reads a efetch specified query * Uses, of course /read_efetch_Sequence * * * Arg: estr [READ ] efetch string which is read [char *] * * Return [UNKN ] Undocumented return value [DNA *] * */ DNA * Wise2_read_efetch_DNA(char * estr); #define read_efetch_DNA Wise2_read_efetch_DNA /* Function: read_SRS_DNA(srsquery) * * Descrip: Reads a SRS sequence using srs4 syntax. * Uses, of course, /read_SRS_Sequence * * * * Arg: srsquery [READ ] string query representing SRS name [char *] * * Return [UNKN ] Undocumented return value [DNA *] * */ DNA * Wise2_read_SRS_DNA(char * srsquery); #define read_SRS_DNA Wise2_read_SRS_DNA /* Function: DNA_name (dna) * * Descrip: Returns the name of the DNA * * * Arg: dna [UNKN ] Undocumented argument [DNA *] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_DNA_name (DNA * dna); #define DNA_name Wise2_DNA_name /* Function: DNA_length (dna) * * Descrip: Returns the length of the DNA * * * Arg: dna [UNKN ] Undocumented argument [DNA *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_DNA_length (DNA * dna); #define DNA_length Wise2_DNA_length /* Function: DNA_seqchar(dna,pos) * * Descrip: Returns sequence character at this position. * * * Arg: dna [UNKN ] DNA [DNA *] * Arg: pos [UNKN ] position in DNA to get char [int] * * Return [UNKN ] Undocumented return value [char] * */ char Wise2_DNA_seqchar(DNA * dna,int pos); #define DNA_seqchar Wise2_DNA_seqchar /* Function: DNA_from_Sequence(seq) * * Descrip: makes a new DNA from a Sequence. It * owns the Sequence memory, ie will attempt a /free_Sequence * on the structure when /free_DNA is called * * If you want to give this DNA this Sequence and * forget about it, then just hand it this sequence and set * seq to NULL (no need to free it). If you intend to use * the sequence object elsewhere outside of the DNA datastructure * then use DNA_from_Sequence(/hard_link_Sequence(seq)) * * * * Arg: seq [UNKN ] Sequence to make DNA from [Sequence *] * * Return [UNKN ] Undocumented return value [DNA *] * */ DNA * Wise2_DNA_from_Sequence(Sequence * seq); #define DNA_from_Sequence Wise2_DNA_from_Sequence /* Function: hard_link_DNA(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DNA *] * * Return [UNKN ] Undocumented return value [DNA *] * */ DNA * Wise2_hard_link_DNA(DNA * obj); #define hard_link_DNA Wise2_hard_link_DNA /* Function: DNA_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DNA *] * */ DNA * Wise2_DNA_alloc(void); #define DNA_alloc Wise2_DNA_alloc /* Function: free_DNA(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DNA *] * * Return [UNKN ] Undocumented return value [DNA *] * */ DNA * Wise2_free_DNA(DNA * obj); #define free_DNA Wise2_free_DNA /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/basematrix.c0000644000175000001440000002246410670453712017151 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "basematrix.h" static int max_matrix_bytes = COMPILE_BASEMATRIX_MAX_KB; /* Function: change_max_BaseMatrix_kbytes(new_kilo_number) * * Descrip: This is to change, at run-time the maximum level of bytes basematrix *thinks* * it can use. This number is *not* used for any actual calls to basematrix * allocation: it is only used with /get_max_BaseMatrix_kbytes * * * Arg: new_kilo_number [UNKN ] max kilobytes allowed [int] * */ # line 130 "basematrix.dy" void change_max_BaseMatrix_kbytes(int new_kilo_number) { max_matrix_bytes = new_kilo_number; } /* Function: get_max_BaseMatrix_kbytes(void) * * Descrip: returns the max. number of kilobytes suggested as a limited * to BaseMatrix. * * * * Return [UNKN ] Undocumented return value [int] * */ # line 139 "basematrix.dy" int get_max_BaseMatrix_kbytes(void) { return max_matrix_bytes; } /* Function: can_make_explicit_matrix(leni,lenj,statesize) * * Descrip: Just checkes that leni*lenj*statesize/1024 < max_matrix_bytes. * returns TRUE if so, FALSE if not * * * Arg: leni [UNKN ] Undocumented argument [int] * Arg: lenj [UNKN ] Undocumented argument [int] * Arg: statesize [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 148 "basematrix.dy" boolean can_make_explicit_matrix(int leni,int lenj,int statesize) { if( leni*lenj*statesize/1024 > max_matrix_bytes) return FALSE; return TRUE; } /* Function: basematrix_type_to_string(type) * * Descrip: turns a int type to a char string of 'printable' * types. * * * Arg: type [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [char *] * */ # line 160 "basematrix.dy" char * basematrix_type_to_string(int type) { switch (type) { case BASEMATRIX_TYPE_UNKNOWN : return "Unknown"; case BASEMATRIX_TYPE_EXPLICIT : return "Explicit"; case BASEMATRIX_TYPE_LINEAR : return "Linear"; case BASEMATRIX_TYPE_SHADOW : return "Shadow"; default : return "Problem in converting type!"; } } /* Function: BaseMatrix_alloc_matrix_and_specials(len_spec_poin,len_point,len_array,len_spec_point,len_spec_array) * * Descrip: This function allocates the two bits of * matrix memory, of course returning a decent * NULL (with memory zapped) if it can't do it * * * Arg: len_spec_poin [UNKN ] length of pointers in special matrix [NullString] * Arg: len_point [UNKN ] length of pointers in main matrix [int] * Arg: len_array [UNKN ] length of array in main matrix [int] * Arg: len_spec_point [UNKN ] Undocumented argument [int] * Arg: len_spec_array [UNKN ] length of special array [int] * * Return [UNKN ] Undocumented return value [BaseMatrix *] * */ # line 182 "basematrix.dy" BaseMatrix * BaseMatrix_alloc_matrix_and_specials(int len_point,int len_array,int len_spec_point,int len_spec_array) { register int i; BaseMatrix * out; /* use dy matrix for main stuff */ if( (out = BaseMatrix_alloc_matrix(len_point,len_array)) == NULL ) { warn("Unable to allocate %d by %d [%d] int positions in basematrix main matrix",len_point,len_array,len_point*len_array); return NULL; } out->spec_len = 0; if( (out->specmatrix = (int **) ckcalloc(len_spec_point,sizeof(int *))) == NULL ) { warn("Unable to allocate %d special matrix pointers in basematrix",len_spec_point); free_BaseMatrix(out); return NULL; } if ((out->specmatrix[0] = (int *)ckcalloc(len_spec_point * len_spec_array, sizeof(int))) == NULL) return NULL; for(i = 1; i < len_spec_point; i++) out->specmatrix[i] = out->specmatrix[0] + (i * len_spec_array); out->spec_len = len_spec_point; return out; } /* Function: free_BaseMatrix(obj) * * Descrip: this is the override deconstructor for basematrix. It will * free both matrix and special memory * * * Arg: obj [UNKN ] Undocumented argument [BaseMatrix *] * * Return [UNKN ] Undocumented return value [BaseMatrix *] * */ # line 217 "basematrix.dy" BaseMatrix * free_BaseMatrix(BaseMatrix * obj) { int i; if( obj == NULL ) { warn("Trying to free NULL basematrix object. Should be trappable"); return NULL; } if( obj->dynamite_hard_link > 1 ) { obj->dynamite_hard_link--; return NULL; } if(obj->matrix != NULL ) { for(i=0;ileni;i++) if( obj->matrix[i] != NULL ) { ckfree(obj->matrix[i]); } free(obj->matrix); } if( obj->spec_len > 0 ) { if( obj->specmatrix == NULL ) { warn("Bad karma. you have a special matrix of length %d, but a NULL specmatrix pointer. I'm not going to free it!",obj->spec_len); } else { free(obj->specmatrix[0]); free(obj->specmatrix); } /* end of else */ } /* end of if specials */ if( obj->offsetmem != NULL ) ckfree(obj->offsetmem); if( obj->setmem != NULL ) ckfree(obj->setmem); ckfree(obj); return NULL; } # line 177 "basematrix.c" /* Function: BaseMatrix_alloc_matrix(leni,lenj) * * Descrip: Allocates structure and matrix * * * Arg: leni [UNKN ] Length of first dimension of matrix [int] * Arg: lenj [UNKN ] Length of second dimension of matrix [int] * * Return [UNKN ] Undocumented return value [BaseMatrix *] * */ BaseMatrix * BaseMatrix_alloc_matrix(int leni,int lenj) { BaseMatrix * out; /* out is exported */ register int i; /* for stepping down matrix */ register int j; /* for stepping across matrix */ /* Call alloc function, return NULL if NULL */ if((out = BaseMatrix_alloc()) == NULL) return NULL; /* Allocate memory for matrix */ if((out->matrix = (int **) ckcalloc (leni,sizeof(int *))) == NULL) { warn("Memory allocation problem in matrix for BaseMatrix matrix, first pointer set"); ckfree(out); return NULL; } /* Add NULL to all matrix pointers so free can be called */ for(i=0;imatrix[i] = NULL; /* Allocate each matrix row */ for(i=0;imatrix[i] = (int *) ckcalloc (lenj,sizeof(int )); if( out->matrix[i] == NULL) { warn("Failed alloc on %d, calling free and returning NULL",i); free_BaseMatrix(out); return NULL; } } for(i=0;imatrix[i][j] = 0; } out->leni=out->maxleni=leni; out->lenj=out->maxlenj=lenj; return out; } /* Function: expand_BaseMatrix(obj,leni,lenj) * * Descrip: Expands matrix. Rarely used * * * Arg: obj [UNKN ] Undocumented argument [BaseMatrix *] * Arg: leni [UNKN ] Undocumented argument [int] * Arg: lenj [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_BaseMatrix(BaseMatrix * obj,int leni,int lenj) { int i; int actualj; if( obj == NULL) { warn("Trying to expand a BaseMatrix but is NULL!"); return FALSE; } if( leni <= obj->maxleni && lenj <= obj->maxlenj) return TRUE; if( obj->maxleni < leni ) { if( (obj->matrix=(int **) ckrealloc (obj->matrix,sizeof(int *)*leni)) == NULL) return FALSE; obj->maxleni=obj->leni=leni; } if( lenj > obj->maxlenj ) actualj = lenj; else actualj = obj->maxlenj; for(i=0;ileni;i++) { if((obj->matrix[i] = (int *) realloc (obj->matrix[i],sizeof(int ) * actualj)) == NULL) return FALSE; } return TRUE; } /* Function: hard_link_BaseMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [BaseMatrix *] * * Return [UNKN ] Undocumented return value [BaseMatrix *] * */ BaseMatrix * hard_link_BaseMatrix(BaseMatrix * obj) { if( obj == NULL ) { warn("Trying to hard link to a BaseMatrix object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: BaseMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [BaseMatrix *] * */ BaseMatrix * BaseMatrix_alloc(void) { BaseMatrix * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(BaseMatrix *) ckalloc (sizeof(BaseMatrix))) == NULL) { warn("BaseMatrix_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = BASEMATRIX_TYPE_UNKNOWN; out->matrix = NULL; out->leni=out->maxleni=0; out->lenj=out->maxlenj=0; out->cellsize = 0; out->queryoffset = 0; out->targetoffset = 0; out->spec_len = 0; out->specmatrix = NULL; out->offsetmem = NULL; out->setmem = NULL; out->optimised_shadow = NULL; return out; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/basematrix.h0000644000175000001440000002110210670453712017142 0ustar philippusers#ifndef DYNAMITEbasematrixHEADERFILE #define DYNAMITEbasematrixHEADERFILE #ifdef _cplusplus extern "C" { #endif /********************************************************/ /* Wisetools version 3 file */ /* */ /* this file is copyright (c) Ewan Birney 1996 */ /* this file is part of the wisetools sequence analysis */ /* package */ /********************************************************/ /********************************************************/ /* BaseMatrix - structure to hold the memory of */ /* dynamite made matrices. */ /* A dynamite support library */ /* */ /********************************************************/ /***** RCS Info *****************************************/ /* $Id: basematrix.dy,v 1.3 2006/03/26 18:45:43 birney Exp $ $Log: basematrix.dy,v $ Revision 1.3 2006/03/26 18:45:43 birney new basematrix memory layout Revision 1.2 2006/02/27 09:32:23 birney start of folding in steves fixes into dynamite Revision 1.1.1.1 2001/06/18 13:59:59 birney moved wise2 to ensembl cvs repository Revision 1.2 1999/03/08 10:47:48 birney added in fixes for a variety of things Revision 1.1.1.1 1998/08/28 09:30:47 birney Wise2 * Revision 1.9 1997/11/12 13:20:18 birney * added documentation, cleaned up * * Revision 1.8 1997/07/24 15:34:45 birney * changed matrix size, and made 'IMPOSSIBLY_HIGH_SCORE' * * Revision 1.7 1997/02/11 20:42:48 birney * added max basematrix number and query size for it * * Revision 1.6 1997/02/03 16:04:48 birney * forgot to set spec_len in _and_special function. Ooops! * * Revision 1.5 1997/02/03 16:01:30 birney * added BaseMatrix_alloc_matrix_and_specials, but not tested. * * Revision 1.4 1996/11/12 16:41:54 birney * deconstructor was trying to free NULL'd pointers. (bad boy!) * * Revision 1.3 1996/11/11 22:17:22 birney * tweaked specials to allow clean linear memory. Hacky deconstructor * though now... * * Revision 1.2 1996/10/15 13:00:52 birney * changed memory behaviour for offsets: caught a memory leak * * Revision 1.1 1996/03/03 15:38:44 birney * Initial revision * */ /********************************************************/ #include "wisebase.h" enum basematrix_types { BASEMATRIX_TYPE_UNKNOWN = 67, BASEMATRIX_TYPE_EXPLICIT, BASEMATRIX_TYPE_LINEAR, BASEMATRIX_TYPE_SHADOW, BASEMATRIX_TYPE_VERYSMALL }; /* 20 MB assummed. Could break something? */ #define COMPILE_BASEMATRIX_MAX_KB 20000 #define IMPOSSIBLY_HIGH_SCORE 500000 struct Wise2_BaseMatrix { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; int ** matrix; /* NB i,j proper */ int leni; /* leni for above matrix */ int maxleni;/* max length for above pointer set */ int lenj; /* lenj for above matrix */ int maxlenj;/* max length for above pointer set */ int cellsize; int queryoffset; int targetoffset; int spec_len; int ** offsetmatrix; /* complex - this points to an internal matrix of correct offsets (!) */ int ** specmatrix; /* no longer linked: we have this memory specific... */ int ** offsetmem; int ** setmem; int * optimised_shadow; } ; /* BaseMatrix defined */ #ifndef DYNAMITE_DEFINED_BaseMatrix typedef struct Wise2_BaseMatrix Wise2_BaseMatrix; #define BaseMatrix Wise2_BaseMatrix #define DYNAMITE_DEFINED_BaseMatrix #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: change_max_BaseMatrix_kbytes(new_kilo_number) * * Descrip: This is to change, at run-time the maximum level of bytes basematrix *thinks* * it can use. This number is *not* used for any actual calls to basematrix * allocation: it is only used with /get_max_BaseMatrix_kbytes * * * Arg: new_kilo_number [UNKN ] max kilobytes allowed [int] * */ void Wise2_change_max_BaseMatrix_kbytes(int new_kilo_number); #define change_max_BaseMatrix_kbytes Wise2_change_max_BaseMatrix_kbytes /* Function: get_max_BaseMatrix_kbytes(void) * * Descrip: returns the max. number of kilobytes suggested as a limited * to BaseMatrix. * * * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_get_max_BaseMatrix_kbytes(void); #define get_max_BaseMatrix_kbytes Wise2_get_max_BaseMatrix_kbytes /* Function: can_make_explicit_matrix(leni,lenj,statesize) * * Descrip: Just checkes that leni*lenj*statesize/1024 < max_matrix_bytes. * returns TRUE if so, FALSE if not * * * Arg: leni [UNKN ] Undocumented argument [int] * Arg: lenj [UNKN ] Undocumented argument [int] * Arg: statesize [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_can_make_explicit_matrix(int leni,int lenj,int statesize); #define can_make_explicit_matrix Wise2_can_make_explicit_matrix /* Function: basematrix_type_to_string(type) * * Descrip: turns a int type to a char string of 'printable' * types. * * * Arg: type [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_basematrix_type_to_string(int type); #define basematrix_type_to_string Wise2_basematrix_type_to_string /* Function: BaseMatrix_alloc_matrix_and_specials(len_spec_poin,len_point,len_array,len_spec_point,len_spec_array) * * Descrip: This function allocates the two bits of * matrix memory, of course returning a decent * NULL (with memory zapped) if it can't do it * * * Arg: len_spec_poin [UNKN ] length of pointers in special matrix [NullString] * Arg: len_point [UNKN ] length of pointers in main matrix [int] * Arg: len_array [UNKN ] length of array in main matrix [int] * Arg: len_spec_point [UNKN ] Undocumented argument [int] * Arg: len_spec_array [UNKN ] length of special array [int] * * Return [UNKN ] Undocumented return value [BaseMatrix *] * */ BaseMatrix * Wise2_BaseMatrix_alloc_matrix_and_specials(int len_point,int len_array,int len_spec_point,int len_spec_array); #define BaseMatrix_alloc_matrix_and_specials Wise2_BaseMatrix_alloc_matrix_and_specials /* Function: free_BaseMatrix(obj) * * Descrip: this is the override deconstructor for basematrix. It will * free both matrix and special memory * * * Arg: obj [UNKN ] Undocumented argument [BaseMatrix *] * * Return [UNKN ] Undocumented return value [BaseMatrix *] * */ BaseMatrix * Wise2_free_BaseMatrix(BaseMatrix * obj); #define free_BaseMatrix Wise2_free_BaseMatrix /* Function: BaseMatrix_alloc_matrix(leni,lenj) * * Descrip: Allocates structure and matrix * * * Arg: leni [UNKN ] Length of first dimension of matrix [int] * Arg: lenj [UNKN ] Length of second dimension of matrix [int] * * Return [UNKN ] Undocumented return value [BaseMatrix *] * */ BaseMatrix * Wise2_BaseMatrix_alloc_matrix(int leni,int lenj); #define BaseMatrix_alloc_matrix Wise2_BaseMatrix_alloc_matrix /* Function: hard_link_BaseMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [BaseMatrix *] * * Return [UNKN ] Undocumented return value [BaseMatrix *] * */ BaseMatrix * Wise2_hard_link_BaseMatrix(BaseMatrix * obj); #define hard_link_BaseMatrix Wise2_hard_link_BaseMatrix /* Function: BaseMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [BaseMatrix *] * */ BaseMatrix * Wise2_BaseMatrix_alloc(void); #define BaseMatrix_alloc Wise2_BaseMatrix_alloc /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_expand_BaseMatrix(BaseMatrix * obj,int leni,int lenj); #define expand_BaseMatrix Wise2_expand_BaseMatrix #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/linkedlist_lookpos.c0000644000175000001440000001625310670453712020721 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "linkedlist_lookpos.h" /* Function: new_linkedl_SeqLookupResultInterface(head) * * Descrip: Makes a hash based SeqLookupResultsInterface thing * * * Arg: head [UNKN ] Undocumented argument [SeqLookupPos *] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ # line 27 "linkedlist_lookpos.dy" SeqLookupResultInterface * new_linkedl_SeqLookupResultInterface(SeqLookupPos * head) { SeqLookupResultInterface * out; SeqLookupPosResult * data; data = SeqLookupPosResult_alloc(); data->current = head; out = SeqLookupResultInterface_alloc(); out->next = next_linkedl_SeqLook; out->is_more = is_more_linkedl_SeqLook; out->free_data = free_linkedl_SeqLook; out->data = (void*)data; return out; } /* Function: free_linkedl_SeqLook(data) * * Descrip: Internal function returns data... * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 50 "linkedlist_lookpos.dy" void free_linkedl_SeqLook(void * data) { SeqLookupPosResult * posres = (SeqLookupPosResult *) data; free_SeqLookupPosResult(posres); } /* Function: is_more_linkedl_SeqLook(*data) * * Descrip: Internal function for returning whether there is more data * * * Arg: *data [UNKN ] Undocumented argument [void] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 62 "linkedlist_lookpos.dy" boolean is_more_linkedl_SeqLook(void *data) { SeqLookupPosResult * posres = (SeqLookupPosResult *) data; if( posres->current == NULL ) { return FALSE; } else { return TRUE; } } /* Function: next_linkedl_SeqLook(data,prev) * * Descrip: Internal function for returning the next position in the hash * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: prev [UNKN ] Undocumented argument [SeqLookupResultStruct *] * * Return [UNKN ] Undocumented return value [SeqLookupResultStruct *] * */ # line 78 "linkedlist_lookpos.dy" SeqLookupResultStruct * next_linkedl_SeqLook(void * data,SeqLookupResultStruct * prev) { SeqLookupPosResult * posres = (SeqLookupPosResult *) data; if( posres->current == NULL ) { fatal("Overrun virtual buffer"); } posres->result.seq = posres->current->seq; posres->result.pos = posres->current->pos; posres->current = posres->current->next; return &(posres->result); } # line 100 "linkedlist_lookpos.c" /* Function: hard_link_SeqLookupPos(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupPos *] * * Return [UNKN ] Undocumented return value [SeqLookupPos *] * */ SeqLookupPos * hard_link_SeqLookupPos(SeqLookupPos * obj) { if( obj == NULL ) { warn("Trying to hard link to a SeqLookupPos object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SeqLookupPos_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupPos *] * */ SeqLookupPos * SeqLookupPos_alloc(void) { SeqLookupPos * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SeqLookupPos *) ckalloc (sizeof(SeqLookupPos))) == NULL) { warn("SeqLookupPos_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->seq = NULL; out->pos = 0; out->next = NULL; return out; } /* Function: free_SeqLookupPos(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeqLookupPos *] * * Return [UNKN ] Undocumented return value [SeqLookupPos *] * */ SeqLookupPos * free_SeqLookupPos(SeqLookupPos * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SeqLookupPos obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->seq != NULL) free_Sequence(obj->seq); /* Unable to make free function for obj->next */ ckfree(obj); return NULL; } /* Function: hard_link_SeqLookupPosResult(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupPosResult *] * * Return [UNKN ] Undocumented return value [SeqLookupPosResult *] * */ SeqLookupPosResult * hard_link_SeqLookupPosResult(SeqLookupPosResult * obj) { if( obj == NULL ) { warn("Trying to hard link to a SeqLookupPosResult object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SeqLookupPosResult_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupPosResult *] * */ SeqLookupPosResult * SeqLookupPosResult_alloc(void) { SeqLookupPosResult * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SeqLookupPosResult *) ckalloc (sizeof(SeqLookupPosResult))) == NULL) { warn("SeqLookupPosResult_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->current = NULL; return out; } /* Function: free_SeqLookupPosResult(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeqLookupPosResult *] * * Return [UNKN ] Undocumented return value [SeqLookupPosResult *] * */ SeqLookupPosResult * free_SeqLookupPosResult(SeqLookupPosResult * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SeqLookupPosResult obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->current != NULL) free_SeqLookupPos(obj->current); /* obj->result is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/linkedlist_lookpos.h0000644000175000001440000001303010670453712020714 0ustar philippusers#ifndef DYNAMITElinkedlist_lookposHEADERFILE #define DYNAMITElinkedlist_lookposHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "seqlookup.h" struct Wise2_SeqLookupPos { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence * seq; int pos; struct Wise2_SeqLookupPos * next; } ; /* SeqLookupPos defined */ #ifndef DYNAMITE_DEFINED_SeqLookupPos typedef struct Wise2_SeqLookupPos Wise2_SeqLookupPos; #define SeqLookupPos Wise2_SeqLookupPos #define DYNAMITE_DEFINED_SeqLookupPos #endif struct Wise2_SeqLookupPosResult { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeqLookupPos * current; SeqLookupResultStruct result; } ; /* SeqLookupPosResult defined */ #ifndef DYNAMITE_DEFINED_SeqLookupPosResult typedef struct Wise2_SeqLookupPosResult Wise2_SeqLookupPosResult; #define SeqLookupPosResult Wise2_SeqLookupPosResult #define DYNAMITE_DEFINED_SeqLookupPosResult #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_linkedl_SeqLookupResultInterface(head) * * Descrip: Makes a hash based SeqLookupResultsInterface thing * * * Arg: head [UNKN ] Undocumented argument [SeqLookupPos *] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ SeqLookupResultInterface * Wise2_new_linkedl_SeqLookupResultInterface(SeqLookupPos * head); #define new_linkedl_SeqLookupResultInterface Wise2_new_linkedl_SeqLookupResultInterface /* Function: free_linkedl_SeqLook(data) * * Descrip: Internal function returns data... * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_linkedl_SeqLook(void * data); #define free_linkedl_SeqLook Wise2_free_linkedl_SeqLook /* Function: is_more_linkedl_SeqLook(*data) * * Descrip: Internal function for returning whether there is more data * * * Arg: *data [UNKN ] Undocumented argument [void] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_more_linkedl_SeqLook(void *data); #define is_more_linkedl_SeqLook Wise2_is_more_linkedl_SeqLook /* Function: next_linkedl_SeqLook(data,prev) * * Descrip: Internal function for returning the next position in the hash * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: prev [UNKN ] Undocumented argument [SeqLookupResultStruct *] * * Return [UNKN ] Undocumented return value [SeqLookupResultStruct *] * */ SeqLookupResultStruct * Wise2_next_linkedl_SeqLook(void * data,SeqLookupResultStruct * prev); #define next_linkedl_SeqLook Wise2_next_linkedl_SeqLook /* Function: hard_link_SeqLookupPos(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupPos *] * * Return [UNKN ] Undocumented return value [SeqLookupPos *] * */ SeqLookupPos * Wise2_hard_link_SeqLookupPos(SeqLookupPos * obj); #define hard_link_SeqLookupPos Wise2_hard_link_SeqLookupPos /* Function: SeqLookupPos_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupPos *] * */ SeqLookupPos * Wise2_SeqLookupPos_alloc(void); #define SeqLookupPos_alloc Wise2_SeqLookupPos_alloc /* Function: free_SeqLookupPos(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeqLookupPos *] * * Return [UNKN ] Undocumented return value [SeqLookupPos *] * */ SeqLookupPos * Wise2_free_SeqLookupPos(SeqLookupPos * obj); #define free_SeqLookupPos Wise2_free_SeqLookupPos /* Function: hard_link_SeqLookupPosResult(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupPosResult *] * * Return [UNKN ] Undocumented return value [SeqLookupPosResult *] * */ SeqLookupPosResult * Wise2_hard_link_SeqLookupPosResult(SeqLookupPosResult * obj); #define hard_link_SeqLookupPosResult Wise2_hard_link_SeqLookupPosResult /* Function: SeqLookupPosResult_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupPosResult *] * */ SeqLookupPosResult * Wise2_SeqLookupPosResult_alloc(void); #define SeqLookupPosResult_alloc Wise2_SeqLookupPosResult_alloc /* Function: free_SeqLookupPosResult(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeqLookupPosResult *] * * Return [UNKN ] Undocumented return value [SeqLookupPosResult *] * */ SeqLookupPosResult * Wise2_free_SeqLookupPosResult(SeqLookupPosResult * obj); #define free_SeqLookupPosResult Wise2_free_SeqLookupPosResult /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/hsplookupthreaded.c0000644000175000001440000005372410670453712020542 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "hsplookupthreaded.h" /* Function: new_threaded_HSPScanInterface(sli,mat,drop_off,score_cutoff,threadno) * * Descrip: Makes the wrapper structure for * threaded searches * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * Arg: threadno [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ # line 43 "hsplookupthreaded.dy" HSPScanInterface * new_threaded_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff,int threadno) { HSPScanInterface * out; HSPScanPara * p; assert(sli); assert(mat); out = HSPScanInterface_alloc(); p = HSPScanPara_alloc(); p->sli = hard_link_SeqLookupInterface(sli); p->mat = hard_link_CompMat(mat); p->drop_off = drop_off; p->score_cutoff = score_cutoff; p->threadno = threadno; out->data = (void*)p; out->free_data = simple_HSPScan_free; if( sli->lookup_array_head == NULL ) { fatal("Can't build threaded non array head structure"); } else { out->scan_query = one_off_threaded_HSPscan_scan_query_direct;; } return out; } /* Function: new_ordered_HSPScanInterface(sli,mat,drop_off,score_cutoff) * * Descrip: Makes the wrapper structure for ordered searches * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ # line 77 "hsplookupthreaded.dy" HSPScanInterface * new_ordered_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff) { HSPScanInterface * out; HSPScanPara * p; assert(sli); assert(mat); out = HSPScanInterface_alloc(); p = HSPScanPara_alloc(); p->sli = hard_link_SeqLookupInterface(sli); p->mat = hard_link_CompMat(mat); p->drop_off = drop_off; p->score_cutoff = score_cutoff; out->data = (void*)p; out->free_data = simple_HSPScan_free; if( sli->lookup_array_head == NULL ) { fatal("Can't build threaded non array head structure"); } else { out->scan_query = one_off_ordered_HSPscan_scan_query_direct; } return out; } /* Function: one_off_ordered_HSPscan_scan_query_direct(data,seq,para) * * Descrip: function which orders memory access pattern * more sensibly * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 113 "hsplookupthreaded.dy" LinearHSPmanager * one_off_ordered_HSPscan_scan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para) { LinearHSPmanager * out; LineariseHSPPara * hsp_para; HSPmanager * hspm; HSPScanPara * p = (HSPScanPara *)data; int * position; int * seqnumber; ArraySeqHead ** arrayseq; long int max_size = 0; long int current = 0; OrderedPosHolder * oph; long int current_oph = 0; long int max_oph = 0; OrderedPosHolder ** pos; int base[5]; int start_base; char * std_aa = "ACDEFGHIKLMNPQRSTVWY"; int score; int seqno[5]; int no; int aa; int used,skipped; int i,j,k; ArraySeqLookup * asl; #ifdef LINUX_TIMER struct timeval t1; struct timeval t2; struct timeval t3; struct timeval t4; struct timeval t5; struct timeval t6; struct timeval t7; #endif assert(p != NULL); assert(seq != NULL); assert(para->max_results > 0); #ifdef LINUX_TIMER gettimeofday(&t1,NULL); #endif /* we know how many positions we are going to fill */ /* each position will make 100 numbers */ max_size = seq->len * 100; position = calloc(max_size,sizeof(int)); seqnumber = calloc(max_size,sizeof(int)); arrayseq = calloc(max_size,sizeof(ArraySeqHead*)); current = 0; for(i=0,start_base=1;i<5;i++) { base[i] = start_base; start_base = start_base * 26; } for(i=0;ilen-5;i++) { position[current] = i; seqnumber[current] = seq_number_aa_5mer_client(seq->seq+i); current++; for(score=0,j=0;j<5;j++) { seqno[j] = base[j]*(toupper(seq->seq[i+j]-'A')); } for(j=0;j<5;j++) { for(aa=0;aa<20;aa++) { if( seq->seq[i+j] == std_aa[aa] ) { continue; } seqno[j] = base[j]*(std_aa[aa]-'A'); no= seqno[0]+seqno[1]+seqno[2]+seqno[3]+seqno[4]; position[current] = i; seqnumber[current] = no; current++; } } } #ifdef LINUX_TIMER gettimeofday(&t2,NULL); #endif /* start with max_size / 4 sequence positions */ max_oph = max_size /4; oph = calloc(max_oph,sizeof(OrderedPosHolder)); pos = calloc(max_oph,sizeof(OrderedPosHolder*)); current_oph = 0; qsort_seqnumber_array(position,seqnumber,0,current-1); #ifdef LINUX_TIMER gettimeofday(&t3,NULL); #endif /* now foreach position, fetch the right datastructure */ asl = (ArraySeqLookup*)p->sli->data; for(i=0;iarray[seqnumber[i]]; if( arrayseq[i] != NULL ) { for(k=0;kcurrent_pos;k++) { if( current_oph+1 >= max_oph ) { max_oph *= 2; oph = realloc(oph,max_oph*sizeof(OrderedPosHolder)); pos = realloc(pos,max_oph*sizeof(OrderedPosHolder*)); } pos[current_oph] = &(oph[current_oph]); oph[current_oph].seq = arrayseq[i]->units[k].seq; oph[current_oph].query_pos = position[i]; oph[current_oph].target_pos = arrayseq[i]->units[k].pos; oph[current_oph].diagonal = position[i] - arrayseq[i]->units[k].pos; current_oph++; } } } #ifdef LINUX_TIMER gettimeofday(&t4,NULL); #endif /* qsort_oph(oph,0,current_oph-1); */ fprintf(stderr,"About to sort oph pointers"); qsort_oph_pointer(pos,0,current_oph-1); fprintf(stderr,"retrieved array with %d elements\n",current_oph); #ifdef LINUX_TIMER gettimeofday(&t5,NULL); #endif hspm = new_HSPmanager(seq,p->mat,p->drop_off); /* we always add the first one */ used = 0; skipped = 0; add_pair_HSPmanager(hspm,oph[0].seq,oph[0].query_pos,oph[0].target_pos); for(i=1;iseq == pos[i]->seq || pos[i]->seq == pos[i+1]->seq) && (abs(pos[i-1]->diagonal - pos[i]->diagonal) < 5 || abs(pos[i]->diagonal - pos[i+1]->diagonal) < 5) ) { good_region = 1; } if( good_region == 0 || (pos[i-1]->seq == pos[i]->seq && pos[i-1]->diagonal == pos[i]->diagonal && abs(pos[i-1]->query_pos - pos[i]->query_pos) < 10) ) { skipped++; continue; } else { add_pair_HSPmanager(hspm,pos[i]->seq,pos[i]->query_pos,pos[i]->target_pos); used++; } } #ifdef LINUX_TIMER gettimeofday(&t6,NULL); #endif fprintf(stderr,"added %d HSPs skipped %d %f\n",used,skipped,(double)used/(double)(used+skipped)); /* make into a linear manager */ if( para->use_protein_heuristic == TRUE ) { out = new_LinearHSPmanager_heuristic_max(hspm,para->max_results); } else { out = new_LinearHSPmanager_flat(hspm); } free_HSPmanager(hspm); return out; } /* Function: qsort_oph_pointer(pos,left,right) * * Descrip: internal quicksort function on oph pointer arrays * * * Arg: pos [UNKN ] Undocumented argument [OrderedPosHolder **] * Arg: left [UNKN ] Undocumented argument [long int] * Arg: right [UNKN ] Undocumented argument [long int] * */ # line 326 "hsplookupthreaded.dy" void qsort_oph_pointer(OrderedPosHolder ** pos,long int left,long int right) { OrderedPosHolder * temp; long int i,last; if( left >= right ) return; /* fprintf(stderr,"Entering sort at %d,%d\n",left,right); */ temp = pos[left]; pos[left] = pos[(left+right)/2]; pos[(left+right)/2] = temp; last = left; for(i=left+1;i <= right;i++) { if( COMP_OPH_POINTER(((pos[i])),((pos[left]))) < 0 ) { last++; temp = pos[last]; pos[last] = pos[i]; pos[i] = temp; } } temp = pos[last]; pos[last] = pos[left]; pos[left] = temp; qsort_oph_pointer(pos,left,last-1); qsort_oph_pointer(pos,last+1,right); } /* Function: qsort_oph(oph,left,right) * * Descrip: internal quicksort function for ordered access * * * Arg: oph [UNKN ] Undocumented argument [OrderedPosHolder *] * Arg: left [UNKN ] Undocumented argument [int] * Arg: right [UNKN ] Undocumented argument [int] * */ # line 367 "hsplookupthreaded.dy" void qsort_oph(OrderedPosHolder * oph,int left,int right) { OrderedPosHolder temp; int i,last; if( left >= right ) return; temp = oph[left]; oph[left] = oph[(left+right)/2]; oph[(left+right)/2] = temp; last = left; for(i=left+1;i <= right;i++) { if( COMP_OPH(oph[i],oph[left]) < 0 ) { last++; temp = oph[last]; oph[last] = oph[i]; oph[i]= temp; } } temp = oph[last]; oph[last] = oph[left]; oph[left] = temp; qsort_oph(oph,left,last-1); qsort_oph(oph,last+1,right); } /* Function: qsort_seqnumber_array(position,seqnumber,left,right) * * Descrip: internal quicksort function for ordered access * * * Arg: position [UNKN ] Undocumented argument [int *] * Arg: seqnumber [UNKN ] Undocumented argument [int *] * Arg: left [UNKN ] Undocumented argument [int] * Arg: right [UNKN ] Undocumented argument [int] * */ # line 402 "hsplookupthreaded.dy" void qsort_seqnumber_array(int * position,int * seqnumber,int left,int right) { int i,last; int temp_pos; int temp_seqnumber; int t; if( left >= right ) return; temp_pos = position[left]; temp_seqnumber = seqnumber[left]; t = (left+right)/2; position[left] = position[t]; seqnumber[left] = seqnumber[t]; position[t] = temp_pos; seqnumber[t] = temp_seqnumber; last = left; for( i = left+1;i <= right;i++) { if( seqnumber[i] < seqnumber[left] ) { last++; temp_pos = position[last]; temp_seqnumber = seqnumber[last]; position[last] = position[i]; seqnumber[last] = seqnumber[i]; position[i] = temp_pos; seqnumber[i] = temp_seqnumber; } } /* swap final ones */ temp_pos = position[last]; temp_seqnumber = seqnumber[last]; position[last] = position[left]; seqnumber[last] = seqnumber[left]; position[left] = temp_pos; seqnumber[left] = temp_seqnumber; qsort_seqnumber_array(position,seqnumber,left,last-1); qsort_seqnumber_array(position,seqnumber,last+1,right); } /* Function: one_off_threaded_HSPscan_scan_query_direct(data,seq,para) * * Descrip: Main threaded function * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 455 "hsplookupthreaded.dy" LinearHSPmanager * one_off_threaded_HSPscan_scan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para) { LinearHSPmanager * out; LineariseHSPPara * hsp_para; HSPScanPara * p = (HSPScanPara *)data; int i; int block_size; int st; int err; HSPLookupThreadHolder thread_array[MAX_HSP_THREADS]; pthread_attr_t pat; pthread_t thread_pool[MAX_HSP_THREADS]; /* pre conditions */ assert(p != NULL); assert(seq != NULL); assert(para->max_results > 0); assert(p->threadno > 0); hsp_para = LineariseHSPPara_alloc(); hsp_para->verbosity = para->verbosity; hsp_para->max_size = para->max_results; hsp_para->min_score = para->min_hsp_score; hsp_para->width = para->hsp_link_width; hsp_para->tail = para->hsp_link_length; if( VERBOSITY_CHECK(1,para->verbosity) ) { info("processing sequence %s with threaded implementation",seq->name); } /* allocate common structures */ block_size = (int) seq->len / p->threadno; /* place into threads */ st = 0; for(i=0;ithreadno;i++) { thread_array[i].para = para; thread_array[i].p = p; thread_array[i].hspm = new_HSPmanager(seq,p->mat,p->drop_off); thread_array[i].start= st; st += block_size; thread_array[i].end = st; thread_array[i].seq = seq; } /* last thread ends at end */ thread_array[p->threadno-1].end = seq->len-5; /* launch threads with structure */ pthread_attr_init(&pat); #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(p->threadno+1); #endif /* set concurrency */ for(i=0;ithreadno;i++) { if( (err = pthread_create(&(thread_pool[i]),&pat,hsp_thread_worker,(void *)(&(thread_array[i])))) ) fatal("Unable to make thread %d %d",i,err); } for(i=0;ithreadno;i++) { if( pthread_join(thread_pool[i],NULL) != 0 ) fatal("Unable to join a thread"); } /* now merge hsp's into one case */ for(i=1;ithreadno;i++) { merge_HSPmanager(thread_array[0].hspm,thread_array[i].hspm); free_HSPmanager(thread_array[i].hspm); } /* make into a linear manager */ if( para->use_protein_heuristic == TRUE ) { out = new_LinearHSPmanager_simple_heuristic(thread_array[0].hspm,hsp_para); } else { out = new_LinearHSPmanager_flat(thread_array[0].hspm); } free_HSPmanager(thread_array[0].hspm); return out; } /* Function: merge_HSPmanager(from,to) * * Descrip: function to merge one HSPmanager into another * one * * * Arg: from [UNKN ] Undocumented argument [HSPmanager *] * Arg: to [UNKN ] Undocumented argument [HSPmanager *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 564 "hsplookupthreaded.dy" boolean merge_HSPmanager(HSPmanager * from,HSPmanager * to) { g_hash_table_foreach(from->target_hash,merge_HSPmanager_foreach,to); } /* Function: merge_HSPmanager_foreach(key,value,user_data) * * Descrip: internal function to merge HSPmanagers * * * Arg: key [UNKN ] Undocumented argument [gpointer] * Arg: value [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * */ # line 572 "hsplookupthreaded.dy" void merge_HSPmanager_foreach(gpointer key,gpointer value,gpointer user_data) { HSPmanager * hspm = (HSPmanager *) user_data; HSPset * s = (HSPset *) value; HSPset * master; int i,j; int seen; /* if there is no sequence, we can just add the set for this target */ if( (master = g_hash_table_lookup(hspm->target_hash,(gpointer)s->hsp[0]->target)) == NULL ) { g_hash_table_insert(hspm->target_hash,(gpointer)s->hsp[0]->target,hard_link_HSPset(s)); return; } /* this target is already in, must check each case */ for(i=0;ilen;i++) { seen = 0; for(j=0;j < master->len;j++) { if( s->hsp[i]->query_start == master->hsp[j]->query_start && s->hsp[i]->target_start == master->hsp[j]->target_start ) { seen = 1; break; } } if( seen == 0 ) { /* this HSP is new */ add_HSPset(master,hard_link_HSP(s->hsp[i])); } else { /* do nothing */ } } return; } /* Function: hsp_thread_worker(ptr) * * Descrip: thread worker * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ # line 618 "hsplookupthreaded.dy" void * hsp_thread_worker(void * ptr) { int i,j,k; int score; int aa; int jj; int aa2; int seqno[5]; int no; char newseq[5]; int base[5]; int start_base; int self_score[5]; int total_score; int current_score; HSPLookupThreadHolder * h = (HSPLookupThreadHolder*)ptr; char * std_aa = "ACDEFGHIKLMNPQRSTVWY"; HSPScanPara * p; HSPScanInterfacePara * para; Sequence * seq; ArraySeqHead * head; p = h->p; seq = h->seq; para = h->para; assert(p != NULL); assert(seq != NULL); assert(para != NULL); for(i=0,start_base=1;i<5;i++) { base[i] = start_base; start_base = start_base * 26; } for(i=h->start;iend;i++) { auto ArraySeqLookup * asl; asl = (ArraySeqLookup *)p->sli->data; if( VERBOSITY_CHECK(2,para->verbosity) && i%50 == 0 ) { info("Scanning (threaded) %s at position %d with %d hits",seq->name,i,h->hspm->hsp_count); } head = arrayhead_direct_lookup(p->sli->data,seq_number_aa_5mer_client(seq->seq+i)); if( VERBOSITY_CHECK(9,para->verbosity) ) { info("retrieved (threaded) %s at position %d with %d hits",seq->name,i,h->hspm->hsp_count); } if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { for(k=0;kcurrent_pos;k++) { if( add_pair_HSPmanager(h->hspm,head->units[k].seq,i,head->units[k].pos) == TRUE ) { ; } } } total_score = 0; for(score=0,j=0;j<5;j++) { seqno[j] = base[j]*(toupper(seq->seq[i+j])-'A'); self_score[j] = p->mat->comp[toupper(seq->seq[i+j])-'A'][toupper(seq->seq[i+j])-'A']; total_score += self_score[j]; } for(j=0;j<5;j++) { for(jj=1;jj<5;jj+=2) { for(aa=0;aa<20;aa++) { for(aa2=0;aa2<20;aa2++) { if( seq->seq[i+j] == std_aa[aa] ) { continue; } current_score = total_score; current_score -= (self_score[j] - p->mat->comp[toupper(seq->seq[i+j])-'A'][std_aa[aa]-'A']); current_score -= (self_score[jj] - p->mat->comp[toupper(seq->seq[i+jj])-'A'][std_aa[aa2]-'A']); if( current_score < para->min_word_score ) { continue; } else { /* fprintf(stderr,"Handling %d,%d amino acid %d,%d score %d\n",j,jj,aa,aa2,current_score); */ } seqno[j] = base[j]*(std_aa[aa]-'A'); seqno[jj] = base[jj]*(std_aa[aa2]-'A'); no= seqno[0]+seqno[1]+seqno[2]+seqno[3]+seqno[4]; head = (*p->sli->lookup_array_head)(p->sli->data,no); if( head != NULL ) { if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { if( VERBOSITY_CHECK(7,para->verbosity) ) { info("position %d hit direct over filled position, %d vs hard %d, low %d",i,head->current_pos,para->numb_level,para->low_numb); } continue; } for(k=0;kcurrent_pos;k++) { if( VERBOSITY_CHECK(9,para->verbosity) ) { info("one off... (threaded) %s at position %d with %d hits",seq->name,i,h->hspm->hsp_count); } add_pair_HSPmanager(h->hspm,head->units[k].seq,i,head->units[k].pos) ; } } seqno[j] = base[j]*(toupper(seq->seq[i+j]-'A')); seqno[jj] = base[jj]*(toupper(seq->seq[i+jj]-'A')); newseq[j] = seq->seq[i+j]; newseq[jj] = seq->seq[i+jj]; } /* each second aa */ } /* each first aa */ } /* each j position */ } /* each jj position */ } /* each i position */ return NULL; } # line 799 "hsplookupthreaded.c" /* Function: hard_link_HSPLookupThreadHolder(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPLookupThreadHolder *] * * Return [UNKN ] Undocumented return value [HSPLookupThreadHolder *] * */ HSPLookupThreadHolder * hard_link_HSPLookupThreadHolder(HSPLookupThreadHolder * obj) { if( obj == NULL ) { warn("Trying to hard link to a HSPLookupThreadHolder object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HSPLookupThreadHolder_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPLookupThreadHolder *] * */ HSPLookupThreadHolder * HSPLookupThreadHolder_alloc(void) { HSPLookupThreadHolder * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HSPLookupThreadHolder *) ckalloc (sizeof(HSPLookupThreadHolder))) == NULL) { warn("HSPLookupThreadHolder_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->end = 0; return out; } /* Function: free_HSPLookupThreadHolder(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPLookupThreadHolder *] * * Return [UNKN ] Undocumented return value [HSPLookupThreadHolder *] * */ HSPLookupThreadHolder * free_HSPLookupThreadHolder(HSPLookupThreadHolder * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HSPLookupThreadHolder obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->p is linked in */ /* obj->hspm is linked in */ /* obj->seq is linked in */ /* obj->para is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/hsplookupthreaded.h0000644000175000001440000002064010670453712020536 0ustar philippusers#ifndef DYNAMITEhsplookupthreadedHEADERFILE #define DYNAMITEhsplookupthreadedHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "hsplookupscan.h" #include "hsphandler.h" #include "arrayseqlookup.h" #define MAX_HSP_THREADS 64 typedef struct ordered_pos_holder { Sequence * seq; int target_pos; int query_pos; int diagonal; } OrderedPosHolder; #define COMP_OPH(a,b) ((a.seq - b.seq) == 0 ? (a.diagonal - b.diagonal) == 0 ? (a.query_pos - b.query_pos) : (a.diagonal - b. diagonal) : (a.seq - b.seq)) #define COMP_OPH_POINTER(a,b) ((a->seq - b->seq) == 0 ? ((a->diagonal - b->diagonal) == 0 ? (a->query_pos - b->query_pos) : (a->diagonal - b->diagonal)) : (a->seq - b->seq)) struct Wise2_HSPLookupThreadHolder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif HSPScanPara * p; HSPmanager * hspm; Sequence * seq; HSPScanInterfacePara * para; int start; int end; } ; /* HSPLookupThreadHolder defined */ #ifndef DYNAMITE_DEFINED_HSPLookupThreadHolder typedef struct Wise2_HSPLookupThreadHolder Wise2_HSPLookupThreadHolder; #define HSPLookupThreadHolder Wise2_HSPLookupThreadHolder #define DYNAMITE_DEFINED_HSPLookupThreadHolder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_threaded_HSPScanInterface(sli,mat,drop_off,score_cutoff,threadno) * * Descrip: Makes the wrapper structure for * threaded searches * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * Arg: threadno [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ HSPScanInterface * Wise2_new_threaded_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff,int threadno); #define new_threaded_HSPScanInterface Wise2_new_threaded_HSPScanInterface /* Function: new_ordered_HSPScanInterface(sli,mat,drop_off,score_cutoff) * * Descrip: Makes the wrapper structure for ordered searches * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ HSPScanInterface * Wise2_new_ordered_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff); #define new_ordered_HSPScanInterface Wise2_new_ordered_HSPScanInterface /* Function: one_off_ordered_HSPscan_scan_query_direct(data,seq,para) * * Descrip: function which orders memory access pattern * more sensibly * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_one_off_ordered_HSPscan_scan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para); #define one_off_ordered_HSPscan_scan_query_direct Wise2_one_off_ordered_HSPscan_scan_query_direct /* Function: qsort_oph_pointer(pos,left,right) * * Descrip: internal quicksort function on oph pointer arrays * * * Arg: pos [UNKN ] Undocumented argument [OrderedPosHolder **] * Arg: left [UNKN ] Undocumented argument [long int] * Arg: right [UNKN ] Undocumented argument [long int] * */ void Wise2_qsort_oph_pointer(OrderedPosHolder ** pos,long int left,long int right); #define qsort_oph_pointer Wise2_qsort_oph_pointer /* Function: qsort_oph(oph,left,right) * * Descrip: internal quicksort function for ordered access * * * Arg: oph [UNKN ] Undocumented argument [OrderedPosHolder *] * Arg: left [UNKN ] Undocumented argument [int] * Arg: right [UNKN ] Undocumented argument [int] * */ void Wise2_qsort_oph(OrderedPosHolder * oph,int left,int right); #define qsort_oph Wise2_qsort_oph /* Function: qsort_seqnumber_array(position,seqnumber,left,right) * * Descrip: internal quicksort function for ordered access * * * Arg: position [UNKN ] Undocumented argument [int *] * Arg: seqnumber [UNKN ] Undocumented argument [int *] * Arg: left [UNKN ] Undocumented argument [int] * Arg: right [UNKN ] Undocumented argument [int] * */ void Wise2_qsort_seqnumber_array(int * position,int * seqnumber,int left,int right); #define qsort_seqnumber_array Wise2_qsort_seqnumber_array /* Function: one_off_threaded_HSPscan_scan_query_direct(data,seq,para) * * Descrip: Main threaded function * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_one_off_threaded_HSPscan_scan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para); #define one_off_threaded_HSPscan_scan_query_direct Wise2_one_off_threaded_HSPscan_scan_query_direct /* Function: merge_HSPmanager(from,to) * * Descrip: function to merge one HSPmanager into another * one * * * Arg: from [UNKN ] Undocumented argument [HSPmanager *] * Arg: to [UNKN ] Undocumented argument [HSPmanager *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_merge_HSPmanager(HSPmanager * from,HSPmanager * to); #define merge_HSPmanager Wise2_merge_HSPmanager /* Function: merge_HSPmanager_foreach(key,value,user_data) * * Descrip: internal function to merge HSPmanagers * * * Arg: key [UNKN ] Undocumented argument [gpointer] * Arg: value [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * */ void Wise2_merge_HSPmanager_foreach(gpointer key,gpointer value,gpointer user_data); #define merge_HSPmanager_foreach Wise2_merge_HSPmanager_foreach /* Function: hsp_thread_worker(ptr) * * Descrip: thread worker * * * Arg: ptr [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * Wise2_hsp_thread_worker(void * ptr); #define hsp_thread_worker Wise2_hsp_thread_worker /* Function: hard_link_HSPLookupThreadHolder(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPLookupThreadHolder *] * * Return [UNKN ] Undocumented return value [HSPLookupThreadHolder *] * */ HSPLookupThreadHolder * Wise2_hard_link_HSPLookupThreadHolder(HSPLookupThreadHolder * obj); #define hard_link_HSPLookupThreadHolder Wise2_hard_link_HSPLookupThreadHolder /* Function: HSPLookupThreadHolder_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPLookupThreadHolder *] * */ HSPLookupThreadHolder * Wise2_HSPLookupThreadHolder_alloc(void); #define HSPLookupThreadHolder_alloc Wise2_HSPLookupThreadHolder_alloc /* Function: free_HSPLookupThreadHolder(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPLookupThreadHolder *] * * Return [UNKN ] Undocumented return value [HSPLookupThreadHolder *] * */ HSPLookupThreadHolder * Wise2_free_HSPLookupThreadHolder(HSPLookupThreadHolder * obj); #define free_HSPLookupThreadHolder Wise2_free_HSPLookupThreadHolder /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/translation_api.h0000644000175000001440000001211210670453713020174 0ustar philippusers /* Functions that create, manipulate or act on Translation * * Wise2_get_Protein_from_Translation * Wise2_hard_link_Translation * Wise2_Translation_alloc * Wise2_replace_start_Translation * Wise2_access_start_Translation * Wise2_replace_end_Translation * Wise2_access_end_Translation * Wise2_replace_parent_Translation * Wise2_access_parent_Translation * Wise2_replace_protein_Translation * Wise2_access_protein_Translation * Wise2_free_Translation [destructor] * */ /* API for object Translation */ /* Function: Wise2_get_Protein_from_Translation(ts,ct) * * Descrip: Gets the protein * * * Arg: ts translation [Wise2_Translation *] * Arg: ct codon table to use [Wise2_CodonTable *] * * Returns Protein sequence [Wise2_Protein *] * */ Wise2_Protein * Wise2_get_Protein_from_Translation( Wise2_Translation * ts,Wise2_CodonTable * ct); /* Function: Wise2_hard_link_Translation(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_Translation *] * * Returns Undocumented return value [Wise2_Translation *] * */ Wise2_Translation * Wise2_hard_link_Translation( Wise2_Translation * obj); /* Function: Wise2_Translation_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_Translation *] * */ Wise2_Translation * Wise2_Translation_alloc(); /* Function: Wise2_replace_start_Translation(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Translation *] * Arg: start New value of the variable [int] * * Returns member variable start [boolean] * */ boolean Wise2_replace_start_Translation( Wise2_Translation * obj,int start); /* Function: Wise2_access_start_Translation(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Translation *] * * Returns member variable start [int] * */ int Wise2_access_start_Translation( Wise2_Translation * obj); /* Function: Wise2_replace_end_Translation(obj,end) * * Descrip: Replace member variable end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Translation *] * Arg: end New value of the variable [int] * * Returns member variable end [boolean] * */ boolean Wise2_replace_end_Translation( Wise2_Translation * obj,int end); /* Function: Wise2_access_end_Translation(obj) * * Descrip: Access member variable end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Translation *] * * Returns member variable end [int] * */ int Wise2_access_end_Translation( Wise2_Translation * obj); /* Function: Wise2_replace_parent_Translation(obj,parent) * * Descrip: Replace member variable parent * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Translation *] * Arg: parent New value of the variable [Wise2_Transcript *] * * Returns member variable parent [boolean] * */ boolean Wise2_replace_parent_Translation( Wise2_Translation * obj,Wise2_Transcript * parent); /* Function: Wise2_access_parent_Translation(obj) * * Descrip: Access member variable parent * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Translation *] * * Returns member variable parent [Wise2_Transcript *] * */ Wise2_Transcript * Wise2_access_parent_Translation( Wise2_Translation * obj); /* Function: Wise2_replace_protein_Translation(obj,protein) * * Descrip: Replace member variable protein * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Translation *] * Arg: protein New value of the variable [Wise2_Protein *] * * Returns member variable protein [boolean] * */ boolean Wise2_replace_protein_Translation( Wise2_Translation * obj,Wise2_Protein * protein); /* Function: Wise2_access_protein_Translation(obj) * * Descrip: Access member variable protein * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Translation *] * * Returns member variable protein [Wise2_Protein *] * */ Wise2_Protein * Wise2_access_protein_Translation( Wise2_Translation * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_Translation(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_Translation *] * * Returns Undocumented return value [Wise2_Translation *] * */ Wise2_Translation * Wise2_free_Translation( Wise2_Translation * obj); wise-2.4.1/src/dynlibsrc/translation_api.t0000644000175000001440000000006510670453713020214 0ustar philippuserstypedef struct Wise2_Translation Wise2_Translation; wise-2.4.1/src/dynlibsrc/hsp.c0000644000175000001440000010624410670453712015603 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "hsp.h" /* Function: on_HSP(test,query_pos,target_pos) * * Descrip: tests whether this point is on this test HSP * * * Arg: test [UNKN ] Undocumented argument [HSP *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 64 "hsp.dy" boolean on_HSP(HSP * test,int query_pos,int target_pos) { if( (test->query_start - test->target_start) != query_pos - target_pos || query_pos < test->query_start || target_pos < test->target_start) { return FALSE; } if( query_pos - test->query_start > test->length ) { return FALSE; } return TRUE; } /* Function: compare_HSPset_score_qsort(a,b) * * Descrip: sorting linear HSPsets via qsort function * * * Arg: a [UNKN ] Undocumented argument [const void *] * Arg: b [UNKN ] Undocumented argument [const void *] * * Return [UNKN ] Undocumented return value [int] * */ # line 80 "hsp.dy" int compare_HSPset_score_qsort(const void * a,const void * b) { const HSPset * one; const HSPset * two; one = *((HSPset**)a); two = *((HSPset**)b); return two->score - one->score; } /* Function: compare_HSPset_score(one,two) * * Descrip: internal function for sort linear HSPsets * * * Arg: one [UNKN ] Undocumented argument [HSPset *] * Arg: two [UNKN ] Undocumented argument [HSPset *] * * Return [UNKN ] Undocumented return value [int] * */ # line 95 "hsp.dy" int compare_HSPset_score(HSPset * one,HSPset * two) { return two->score - one->score; } /* Function: sort_HSPset_by_score(*set) * * Descrip: Sorts by score * * * Arg: *set [UNKN ] Undocumented argument [HSPset] * */ # line 104 "hsp.dy" void sort_HSPset_by_score(HSPset *set) { sort_HSPset(set,compare_HSP_score); } /* Function: compare_HSP_score(one,two) * * Descrip: internal for sort by score * * * Arg: one [UNKN ] Undocumented argument [HSP *] * Arg: two [UNKN ] Undocumented argument [HSP *] * * Return [UNKN ] Undocumented return value [int] * */ # line 113 "hsp.dy" int compare_HSP_score(HSP * one,HSP * two) { return two->score - one->score; } /* Function: new_dna_identical_HSP(query,target,query_pos,target_pos,target_reverse) * * Descrip: builds a new HSP for these sequences breaking at first mismatch * * * Arg: query [UNKN ] Undocumented argument [Sequence *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * Arg: target_reverse [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSP *] * */ # line 121 "hsp.dy" HSP * new_dna_identical_HSP(Sequence * query,Sequence * target,int query_pos,int target_pos,int target_reverse) { int i,j; HSP * out; assert(query); assert(target); assert(query_pos >= 0 && query_pos < query->len); assert(target_pos >= 0 && target_pos < target->len); out = HSP_alloc(); out->query = hard_link_Sequence(query); out->target= hard_link_Sequence(target); i = query_pos; j = target_pos; /* upstream first */ while( i >= 0 && j >= 0 && j <= target->len ) { /* fprintf(stderr," in upstream loop, looking at %d (is revd %d)\n",i,target_reverse); */ if( target_reverse == 1 ) { if( toupper(query->seq[i]) != char_complement_base(toupper(target->seq[j])) ) { /* fprintf(stderr,"Breaking, reversed at %d,%d %c,%c\n",i,j,query->seq[i],char_complement_base(toupper(target->seq[j]))); */ break; } else { i--; j++; } } else { if( toupper(query->seq[i]) != toupper(target->seq[j]) ) { /* fprintf(stderr,"Breaking at %d,%d %c,%c\n",i,j,query->seq[i],target->seq[j]); */ break; } else{ i--; j--; } } } if( target_reverse == 1 ) { i++; j--; } else { i++; j++; } out->query_start = i; out->target_start = j; i = query_pos; j = target_pos; /* downstream next */ while( i < query->len && j >= 0 && j < target->len ) { if( target_reverse == 1 ) { if( toupper(query->seq[i]) != char_complement_base(toupper(target->seq[j])) ) { i--; j++; break; } else { i++; j--; } } else { if( toupper(query->seq[i]) != toupper(target->seq[j]) ) { i--; j--; break; } else{ i++; j++; } } } if( target_reverse == 1 ) { i++; j--; } else { i--; j--; } out->length = i - out->query_start; out->score = out->length; out->target_reverse = target_reverse; return out; } /* Function: new_HSP(cache,query,target,query_pos,target_pos,mat,drop_off) * * Descrip: builds a new HSP for these sequences * * * Arg: cache [UNKN ] Undocumented argument [HSPCache *] * Arg: query [UNKN ] Undocumented argument [Sequence *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSP *] * */ # line 221 "hsp.dy" HSP * new_HSP(HSPCache * cache,Sequence * query,Sequence * target,int query_pos,int target_pos,CompMat * mat,int drop_off) { int i,j; int pause_i,pause_j; int score = 0; int max_score= 0; HSP * out; if( cache != NULL ) { out = HSP_alloc_cache(cache); } else { out = HSP_alloc(); } assert(out != NULL); assert(query != NULL); assert(query->seq != NULL); assert(target != NULL); assert(target->seq != NULL); assert(mat != NULL); assert(drop_off > 0); assert(query->seq[query_pos] >= 'A' && query->seq[query_pos] <= 'Z'); assert(target->seq[target_pos] >= 'A' && target->seq[target_pos] <= 'Z'); /* fprintf(stdout,"got new hsp with drop_off of %d\n",drop_off);*/ out->query = hard_link_Sequence(query); out->target= hard_link_Sequence(target); out->score = -(mat->comp[query->seq[query_pos]-'A'][target->seq[target_pos]-'A']); pause_i = i = query_pos; pause_j = j = target_pos; /* go upstream first */ for(score = 0,max_score = 0;(max_score - score) < drop_off && i >= 0 && j >= 0;i--,j--) { score += mat->comp[query->seq[i]-'A'][target->seq[j]-'A']; /*fprintf(stderr,"Examining %c,%c - score %d max_score %d\n",query->seq[i],target->seq[j],score,max_score); */ if( score > max_score ) { pause_i = i; pause_j = j; max_score = score; } } out->query_start = pause_i; out->target_start = pause_j; out->score += max_score; /* now downstream */ for(score=0,max_score=0,pause_i=i=query_pos,pause_j=j=target_pos;(max_score - score) < drop_off && i < query->len && j < target->len;i++,j++) { score += mat->comp[query->seq[i]-'A'][target->seq[j]-'A']; if( score > max_score ) { pause_i = i; pause_j = j; max_score = score; } } out->length = pause_i - out->query_start+1; out->score += max_score; return out; } /* Function: HSP_alloc_cache(hspc) * * Descrip: Returns new HSP, using cache if needed * * * Arg: hspc [UNKN ] Undocumented argument [HSPCache *] * * Return [UNKN ] Undocumented return value [HSP *] * */ # line 297 "hsp.dy" HSP * HSP_alloc_cache(HSPCache * hspc) { assert(hspc); if( hspc->len > 0 ) { hspc->len--; return hspc->cache[hspc->len]; } return HSP_alloc(); } /* Function: free_HSP_cache(cache,hsp) * * Descrip: Places HSP back into cache, freeing if necessary * * * Arg: cache [UNKN ] Undocumented argument [HSPCache *] * Arg: hsp [UNKN ] Undocumented argument [HSP *] * * Return [UNKN ] Undocumented return value [HSP *] * */ # line 312 "hsp.dy" HSP * free_HSP_cache(HSPCache * cache,HSP * hsp) { int return_early = 0; assert(cache); assert(hsp); #ifdef PTHREAD assert(pthread_mutex_lock(&(hsp->dynamite_mutex)) == 0); #endif if( hsp->dynamite_hard_link > 1) { return_early = 1; hsp->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(hsp->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( cache->len > cache->max_cache ) { return free_HSP(hsp); } else { add_HSPCache(cache,hsp); return NULL; } } /* Function: new_HSPCache(maxsize) * * Descrip: Makes a new cache * * * Arg: maxsize [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPCache *] * */ # line 344 "hsp.dy" HSPCache * new_HSPCache(int maxsize) { HSPCache * out; out = HSPCache_alloc_std(); out->max_cache = maxsize; return out; } /* Function: show_HSPset(s,ofp) * * Descrip: Shows a HSP set * * * Arg: s [UNKN ] Undocumented argument [HSPset *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 357 "hsp.dy" void show_HSPset(HSPset * s,FILE * ofp) { int i; for(i=0;ilen;i++) { if( s->hsp[i]->target_reverse == 0 ) { fprintf(ofp,"%5d %s\t%d\t%d\t%s\t%d\t%d\t+\n",s->hsp[i]->length,s->hsp[i]->query->name,s->hsp[i]->query_start,s->hsp[i]->query_start+s->hsp[i]->length,s->hsp[i]->target->name,s->hsp[i]->target_start,s->hsp[i]->target_start + s->hsp[i]->length); } else { fprintf(ofp,"%5d %s\t%d\t%d\t%s\t%d\t%d\t-\n",s->hsp[i]->length,s->hsp[i]->query->name,s->hsp[i]->query_start,s->hsp[i]->query_start+s->hsp[i]->length,s->hsp[i]->target->name,s->hsp[i]->target_start,s->hsp[i]->target_start - s->hsp[i]->length); } } } /* Function: show_HSP(hsp,linelength,out) * * Descrip: Shows an HSP * * * Arg: hsp [UNKN ] Undocumented argument [HSP *] * Arg: linelength [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [FILE *] * */ # line 375 "hsp.dy" void show_HSP(HSP * hsp,int linelength,FILE * out) { int i,j; for(i=hsp->query_start,j=hsp->target_start;(i-hsp->query_start) < hsp->length;i++,j++) { fprintf(out,"%c %c\n",hsp->query->seq[i],hsp->target->seq[j]); } } # line 418 "hsp.c" /* Function: hard_link_HSP(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSP *] * * Return [UNKN ] Undocumented return value [HSP *] * */ HSP * hard_link_HSP(HSP * obj) { if( obj == NULL ) { warn("Trying to hard link to a HSP object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HSP_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSP *] * */ HSP * HSP_alloc(void) { HSP * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HSP *) ckalloc (sizeof(HSP))) == NULL) { warn("HSP_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->query = NULL; out->target = NULL; out->query_start = 0; out->target_start = 0; out->length = 0; out->score = 0; out->is_in_block = 0; out->target_reverse = 0; return out; } /* Function: free_HSP(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSP *] * * Return [UNKN ] Undocumented return value [HSP *] * */ HSP * free_HSP(HSP * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HSP obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->query != NULL) free_Sequence(obj->query); if( obj->target != NULL) free_Sequence(obj->target); ckfree(obj); return NULL; } /* Function: swap_HSPCache(list,i,j) * * Descrip: swap function: an internal for qsort_HSPCache * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [HSP **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_HSPCache(HSP ** list,int i,int j) { HSP * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_HSPCache(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_HSPCache which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [HSP **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_HSPCache(HSP ** list,int left,int right,int (*comp)(HSP * ,HSP * )) { int i,last; if( left >= right ) return; swap_HSPCache(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_HSPCache (list,++last,i); } swap_HSPCache (list,left,last); qsort_HSPCache(list,left,last-1,comp); qsort_HSPCache(list,last+1,right,comp); } /* Function: sort_HSPCache(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_HSPCache * * * Arg: obj [UNKN ] Object containing list [HSPCache *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_HSPCache(HSPCache * obj,int (*comp)(HSP *, HSP *)) { qsort_HSPCache(obj->cache,0,obj->len-1,comp); return; } /* Function: expand_HSPCache(obj,len) * * Descrip: Really an internal function for add_HSPCache * * * Arg: obj [UNKN ] Object which contains the list [HSPCache *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_HSPCache(HSPCache * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_HSPCache called with no need"); return TRUE; } if( (obj->cache = (HSP ** ) ckrealloc (obj->cache,sizeof(HSP *)*len)) == NULL) { warn("ckrealloc failed for expand_HSPCache, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_HSPCache(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [HSPCache *] * Arg: add [OWNER] Object to add to the list [HSP *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_HSPCache(HSPCache * obj,HSP * add) { if( obj->len >= obj->maxlen) { if( expand_HSPCache(obj,obj->len + HSPCacheLISTLENGTH) == FALSE) return FALSE; } obj->cache[obj->len++]=add; return TRUE; } /* Function: flush_HSPCache(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [HSPCache *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_HSPCache(HSPCache * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->cache[i] != NULL) { free_HSP(obj->cache[i]); obj->cache[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: HSPCache_alloc_std(void) * * Descrip: Equivalent to HSPCache_alloc_len(HSPCacheLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [HSPCache *] * */ HSPCache * HSPCache_alloc_std(void) { return HSPCache_alloc_len(HSPCacheLISTLENGTH); } /* Function: HSPCache_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [HSPCache *] * */ HSPCache * HSPCache_alloc_len(int len) { HSPCache * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = HSPCache_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->cache = (HSP ** ) ckcalloc (len,sizeof(HSP *))) == NULL) { warn("Warning, ckcalloc failed in HSPCache_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_HSPCache(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPCache *] * * Return [UNKN ] Undocumented return value [HSPCache *] * */ HSPCache * hard_link_HSPCache(HSPCache * obj) { if( obj == NULL ) { warn("Trying to hard link to a HSPCache object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HSPCache_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPCache *] * */ HSPCache * HSPCache_alloc(void) { HSPCache * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HSPCache *) ckalloc (sizeof(HSPCache))) == NULL) { warn("HSPCache_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->cache = NULL; out->len = out->maxlen = 0; out->max_cache = 0; return out; } /* Function: free_HSPCache(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPCache *] * * Return [UNKN ] Undocumented return value [HSPCache *] * */ HSPCache * free_HSPCache(HSPCache * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HSPCache obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->cache != NULL) { for(i=0;ilen;i++) { if( obj->cache[i] != NULL) free_HSP(obj->cache[i]); } ckfree(obj->cache); } ckfree(obj); return NULL; } /* Function: swap_HSPset(list,i,j) * * Descrip: swap function: an internal for qsort_HSPset * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [HSP **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_HSPset(HSP ** list,int i,int j) { HSP * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_HSPset(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_HSPset which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [HSP **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_HSPset(HSP ** list,int left,int right,int (*comp)(HSP * ,HSP * )) { int i,last; if( left >= right ) return; swap_HSPset(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_HSPset (list,++last,i); } swap_HSPset (list,left,last); qsort_HSPset(list,left,last-1,comp); qsort_HSPset(list,last+1,right,comp); } /* Function: sort_HSPset(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_HSPset * * * Arg: obj [UNKN ] Object containing list [HSPset *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_HSPset(HSPset * obj,int (*comp)(HSP *, HSP *)) { qsort_HSPset(obj->hsp,0,obj->len-1,comp); return; } /* Function: expand_HSPset(obj,len) * * Descrip: Really an internal function for add_HSPset * * * Arg: obj [UNKN ] Object which contains the list [HSPset *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_HSPset(HSPset * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_HSPset called with no need"); return TRUE; } if( (obj->hsp = (HSP ** ) ckrealloc (obj->hsp,sizeof(HSP *)*len)) == NULL) { warn("ckrealloc failed for expand_HSPset, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_HSPset(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [HSPset *] * Arg: add [OWNER] Object to add to the list [HSP *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_HSPset(HSPset * obj,HSP * add) { if( obj->len >= obj->maxlen) { if( expand_HSPset(obj,obj->len + HSPsetLISTLENGTH) == FALSE) return FALSE; } obj->hsp[obj->len++]=add; return TRUE; } /* Function: flush_HSPset(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [HSPset *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_HSPset(HSPset * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->hsp[i] != NULL) { free_HSP(obj->hsp[i]); obj->hsp[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: HSPset_alloc_std(void) * * Descrip: Equivalent to HSPset_alloc_len(HSPsetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [HSPset *] * */ HSPset * HSPset_alloc_std(void) { return HSPset_alloc_len(HSPsetLISTLENGTH); } /* Function: HSPset_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [HSPset *] * */ HSPset * HSPset_alloc_len(int len) { HSPset * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = HSPset_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->hsp = (HSP ** ) ckcalloc (len,sizeof(HSP *))) == NULL) { warn("Warning, ckcalloc failed in HSPset_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_HSPset(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPset *] * * Return [UNKN ] Undocumented return value [HSPset *] * */ HSPset * hard_link_HSPset(HSPset * obj) { if( obj == NULL ) { warn("Trying to hard link to a HSPset object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HSPset_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPset *] * */ HSPset * HSPset_alloc(void) { HSPset * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HSPset *) ckalloc (sizeof(HSPset))) == NULL) { warn("HSPset_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->hsp = NULL; out->len = out->maxlen = 0; out->score = 0; out->best_score = 0; out->last_accessed = -1; return out; } /* Function: free_HSPset(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPset *] * * Return [UNKN ] Undocumented return value [HSPset *] * */ HSPset * free_HSPset(HSPset * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HSPset obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->hsp != NULL) { for(i=0;ilen;i++) { if( obj->hsp[i] != NULL) free_HSP(obj->hsp[i]); } ckfree(obj->hsp); } ckfree(obj); return NULL; } /* Function: swap_LinearHSPmanager(list,i,j) * * Descrip: swap function: an internal for qsort_LinearHSPmanager * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [HSPset **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_LinearHSPmanager(HSPset ** list,int i,int j) { HSPset * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_LinearHSPmanager(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_LinearHSPmanager which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [HSPset **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_LinearHSPmanager(HSPset ** list,int left,int right,int (*comp)(HSPset * ,HSPset * )) { int i,last; if( left >= right ) return; swap_LinearHSPmanager(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_LinearHSPmanager (list,++last,i); } swap_LinearHSPmanager (list,left,last); qsort_LinearHSPmanager(list,left,last-1,comp); qsort_LinearHSPmanager(list,last+1,right,comp); } /* Function: sort_LinearHSPmanager(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_LinearHSPmanager * * * Arg: obj [UNKN ] Object containing list [LinearHSPmanager *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_LinearHSPmanager(LinearHSPmanager * obj,int (*comp)(HSPset *, HSPset *)) { qsort_LinearHSPmanager(obj->set,0,obj->len-1,comp); return; } /* Function: expand_LinearHSPmanager(obj,len) * * Descrip: Really an internal function for add_LinearHSPmanager * * * Arg: obj [UNKN ] Object which contains the list [LinearHSPmanager *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_LinearHSPmanager(LinearHSPmanager * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_LinearHSPmanager called with no need"); return TRUE; } if( (obj->set = (HSPset ** ) ckrealloc (obj->set,sizeof(HSPset *)*len)) == NULL) { warn("ckrealloc failed for expand_LinearHSPmanager, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_LinearHSPmanager(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LinearHSPmanager *] * Arg: add [OWNER] Object to add to the list [HSPset *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_LinearHSPmanager(LinearHSPmanager * obj,HSPset * add) { if( obj->len >= obj->maxlen) { if( expand_LinearHSPmanager(obj,obj->len + LinearHSPmanagerLISTLENGTH) == FALSE) return FALSE; } obj->set[obj->len++]=add; return TRUE; } /* Function: flush_LinearHSPmanager(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LinearHSPmanager *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_LinearHSPmanager(LinearHSPmanager * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->set[i] != NULL) { free_HSPset(obj->set[i]); obj->set[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: LinearHSPmanager_alloc_std(void) * * Descrip: Equivalent to LinearHSPmanager_alloc_len(LinearHSPmanagerLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * LinearHSPmanager_alloc_std(void) { return LinearHSPmanager_alloc_len(LinearHSPmanagerLISTLENGTH); } /* Function: LinearHSPmanager_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * LinearHSPmanager_alloc_len(int len) { LinearHSPmanager * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = LinearHSPmanager_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->set = (HSPset ** ) ckcalloc (len,sizeof(HSPset *))) == NULL) { warn("Warning, ckcalloc failed in LinearHSPmanager_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_LinearHSPmanager(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinearHSPmanager *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * hard_link_LinearHSPmanager(LinearHSPmanager * obj) { if( obj == NULL ) { warn("Trying to hard link to a LinearHSPmanager object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LinearHSPmanager_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * LinearHSPmanager_alloc(void) { LinearHSPmanager * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LinearHSPmanager *) ckalloc (sizeof(LinearHSPmanager))) == NULL) { warn("LinearHSPmanager_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->set = NULL; out->len = out->maxlen = 0; out->query = NULL; out->mat = NULL; out->min_score = 0; out->width = 0; out->tail = 0; out->worst_hsp_score = 0; return out; } /* Function: free_LinearHSPmanager(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinearHSPmanager *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * free_LinearHSPmanager(LinearHSPmanager * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LinearHSPmanager obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->set != NULL) { for(i=0;ilen;i++) { if( obj->set[i] != NULL) free_HSPset(obj->set[i]); } ckfree(obj->set); } if( obj->query != NULL) free_Sequence(obj->query); if( obj->mat != NULL) free_CompMat(obj->mat); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/hsp.h0000644000175000001440000004356410670453712015615 0ustar philippusers#ifndef DYNAMITEhspHEADERFILE #define DYNAMITEhspHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #include "compmat.h" #define HSPsetLISTLENGTH 20 #define HSP_BLOCK_SIZE 1024 #define HSPCacheLISTLENGTH 1024 #define LinearHSPmanagerLISTLENGTH 128 #define ON_HSP_MACRO(test,query_pos,target_pos) ( (((test->query_start-test->target_start)!=(query_pos-target_pos))||(query_posquery_start)||(target_postarget_start)||(query_pos-test->query_start>test->length)) ? FALSE : TRUE) struct Wise2_HSP { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence * query; Sequence * target; int query_start; int target_start; int length; int score; char is_in_block; char target_reverse; } ; /* HSP defined */ #ifndef DYNAMITE_DEFINED_HSP typedef struct Wise2_HSP Wise2_HSP; #define HSP Wise2_HSP #define DYNAMITE_DEFINED_HSP #endif struct Wise2_HSPCache { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif HSP ** cache; int len;/* len for above cache */ int maxlen; /* maxlen for above cache */ int max_cache; } ; /* HSPCache defined */ #ifndef DYNAMITE_DEFINED_HSPCache typedef struct Wise2_HSPCache Wise2_HSPCache; #define HSPCache Wise2_HSPCache #define DYNAMITE_DEFINED_HSPCache #endif struct Wise2_HSPset { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif HSP ** hsp; int len;/* len for above hsp */ int maxlen; /* maxlen for above hsp */ int score; int best_score; int last_accessed; } ; /* HSPset defined */ #ifndef DYNAMITE_DEFINED_HSPset typedef struct Wise2_HSPset Wise2_HSPset; #define HSPset Wise2_HSPset #define DYNAMITE_DEFINED_HSPset #endif struct Wise2_LinearHSPmanager { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif HSPset ** set; int len;/* len for above set */ int maxlen; /* maxlen for above set */ Sequence * query; CompMat * mat; int min_score; int width; int tail; int worst_hsp_score; } ; /* LinearHSPmanager defined */ #ifndef DYNAMITE_DEFINED_LinearHSPmanager typedef struct Wise2_LinearHSPmanager Wise2_LinearHSPmanager; #define LinearHSPmanager Wise2_LinearHSPmanager #define DYNAMITE_DEFINED_LinearHSPmanager #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: on_HSP(test,query_pos,target_pos) * * Descrip: tests whether this point is on this test HSP * * * Arg: test [UNKN ] Undocumented argument [HSP *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_on_HSP(HSP * test,int query_pos,int target_pos); #define on_HSP Wise2_on_HSP /* Function: compare_HSPset_score_qsort(a,b) * * Descrip: sorting linear HSPsets via qsort function * * * Arg: a [UNKN ] Undocumented argument [const void *] * Arg: b [UNKN ] Undocumented argument [const void *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_compare_HSPset_score_qsort(const void * a,const void * b); #define compare_HSPset_score_qsort Wise2_compare_HSPset_score_qsort /* Function: compare_HSPset_score(one,two) * * Descrip: internal function for sort linear HSPsets * * * Arg: one [UNKN ] Undocumented argument [HSPset *] * Arg: two [UNKN ] Undocumented argument [HSPset *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_compare_HSPset_score(HSPset * one,HSPset * two); #define compare_HSPset_score Wise2_compare_HSPset_score /* Function: sort_HSPset_by_score(*set) * * Descrip: Sorts by score * * * Arg: *set [UNKN ] Undocumented argument [HSPset] * */ void Wise2_sort_HSPset_by_score(HSPset *set); #define sort_HSPset_by_score Wise2_sort_HSPset_by_score /* Function: new_dna_identical_HSP(query,target,query_pos,target_pos,target_reverse) * * Descrip: builds a new HSP for these sequences breaking at first mismatch * * * Arg: query [UNKN ] Undocumented argument [Sequence *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * Arg: target_reverse [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSP *] * */ HSP * Wise2_new_dna_identical_HSP(Sequence * query,Sequence * target,int query_pos,int target_pos,int target_reverse); #define new_dna_identical_HSP Wise2_new_dna_identical_HSP /* Function: new_HSP(cache,query,target,query_pos,target_pos,mat,drop_off) * * Descrip: builds a new HSP for these sequences * * * Arg: cache [UNKN ] Undocumented argument [HSPCache *] * Arg: query [UNKN ] Undocumented argument [Sequence *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSP *] * */ HSP * Wise2_new_HSP(HSPCache * cache,Sequence * query,Sequence * target,int query_pos,int target_pos,CompMat * mat,int drop_off); #define new_HSP Wise2_new_HSP /* Function: HSP_alloc_cache(hspc) * * Descrip: Returns new HSP, using cache if needed * * * Arg: hspc [UNKN ] Undocumented argument [HSPCache *] * * Return [UNKN ] Undocumented return value [HSP *] * */ HSP * Wise2_HSP_alloc_cache(HSPCache * hspc); #define HSP_alloc_cache Wise2_HSP_alloc_cache /* Function: free_HSP_cache(cache,hsp) * * Descrip: Places HSP back into cache, freeing if necessary * * * Arg: cache [UNKN ] Undocumented argument [HSPCache *] * Arg: hsp [UNKN ] Undocumented argument [HSP *] * * Return [UNKN ] Undocumented return value [HSP *] * */ HSP * Wise2_free_HSP_cache(HSPCache * cache,HSP * hsp); #define free_HSP_cache Wise2_free_HSP_cache /* Function: new_HSPCache(maxsize) * * Descrip: Makes a new cache * * * Arg: maxsize [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPCache *] * */ HSPCache * Wise2_new_HSPCache(int maxsize); #define new_HSPCache Wise2_new_HSPCache /* Function: show_HSPset(s,ofp) * * Descrip: Shows a HSP set * * * Arg: s [UNKN ] Undocumented argument [HSPset *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_HSPset(HSPset * s,FILE * ofp); #define show_HSPset Wise2_show_HSPset /* Function: show_HSP(hsp,linelength,out) * * Descrip: Shows an HSP * * * Arg: hsp [UNKN ] Undocumented argument [HSP *] * Arg: linelength [UNKN ] Undocumented argument [int] * Arg: out [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_HSP(HSP * hsp,int linelength,FILE * out); #define show_HSP Wise2_show_HSP /* Function: hard_link_HSP(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSP *] * * Return [UNKN ] Undocumented return value [HSP *] * */ HSP * Wise2_hard_link_HSP(HSP * obj); #define hard_link_HSP Wise2_hard_link_HSP /* Function: HSP_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSP *] * */ HSP * Wise2_HSP_alloc(void); #define HSP_alloc Wise2_HSP_alloc /* Function: free_HSP(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSP *] * * Return [UNKN ] Undocumented return value [HSP *] * */ HSP * Wise2_free_HSP(HSP * obj); #define free_HSP Wise2_free_HSP /* Function: add_HSPCache(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [HSPCache *] * Arg: add [OWNER] Object to add to the list [HSP *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_HSPCache(HSPCache * obj,HSP * add); #define add_HSPCache Wise2_add_HSPCache /* Function: flush_HSPCache(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [HSPCache *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_HSPCache(HSPCache * obj); #define flush_HSPCache Wise2_flush_HSPCache /* Function: HSPCache_alloc_std(void) * * Descrip: Equivalent to HSPCache_alloc_len(HSPCacheLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [HSPCache *] * */ HSPCache * Wise2_HSPCache_alloc_std(void); #define HSPCache_alloc_std Wise2_HSPCache_alloc_std /* Function: HSPCache_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [HSPCache *] * */ HSPCache * Wise2_HSPCache_alloc_len(int len); #define HSPCache_alloc_len Wise2_HSPCache_alloc_len /* Function: hard_link_HSPCache(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPCache *] * * Return [UNKN ] Undocumented return value [HSPCache *] * */ HSPCache * Wise2_hard_link_HSPCache(HSPCache * obj); #define hard_link_HSPCache Wise2_hard_link_HSPCache /* Function: HSPCache_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPCache *] * */ HSPCache * Wise2_HSPCache_alloc(void); #define HSPCache_alloc Wise2_HSPCache_alloc /* Function: free_HSPCache(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPCache *] * * Return [UNKN ] Undocumented return value [HSPCache *] * */ HSPCache * Wise2_free_HSPCache(HSPCache * obj); #define free_HSPCache Wise2_free_HSPCache /* Function: add_HSPset(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [HSPset *] * Arg: add [OWNER] Object to add to the list [HSP *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_HSPset(HSPset * obj,HSP * add); #define add_HSPset Wise2_add_HSPset /* Function: flush_HSPset(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [HSPset *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_HSPset(HSPset * obj); #define flush_HSPset Wise2_flush_HSPset /* Function: HSPset_alloc_std(void) * * Descrip: Equivalent to HSPset_alloc_len(HSPsetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [HSPset *] * */ HSPset * Wise2_HSPset_alloc_std(void); #define HSPset_alloc_std Wise2_HSPset_alloc_std /* Function: HSPset_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [HSPset *] * */ HSPset * Wise2_HSPset_alloc_len(int len); #define HSPset_alloc_len Wise2_HSPset_alloc_len /* Function: hard_link_HSPset(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPset *] * * Return [UNKN ] Undocumented return value [HSPset *] * */ HSPset * Wise2_hard_link_HSPset(HSPset * obj); #define hard_link_HSPset Wise2_hard_link_HSPset /* Function: HSPset_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPset *] * */ HSPset * Wise2_HSPset_alloc(void); #define HSPset_alloc Wise2_HSPset_alloc /* Function: free_HSPset(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPset *] * * Return [UNKN ] Undocumented return value [HSPset *] * */ HSPset * Wise2_free_HSPset(HSPset * obj); #define free_HSPset Wise2_free_HSPset /* Function: add_LinearHSPmanager(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [LinearHSPmanager *] * Arg: add [OWNER] Object to add to the list [HSPset *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_LinearHSPmanager(LinearHSPmanager * obj,HSPset * add); #define add_LinearHSPmanager Wise2_add_LinearHSPmanager /* Function: flush_LinearHSPmanager(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [LinearHSPmanager *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_LinearHSPmanager(LinearHSPmanager * obj); #define flush_LinearHSPmanager Wise2_flush_LinearHSPmanager /* Function: LinearHSPmanager_alloc_std(void) * * Descrip: Equivalent to LinearHSPmanager_alloc_len(LinearHSPmanagerLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_LinearHSPmanager_alloc_std(void); #define LinearHSPmanager_alloc_std Wise2_LinearHSPmanager_alloc_std /* Function: LinearHSPmanager_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_LinearHSPmanager_alloc_len(int len); #define LinearHSPmanager_alloc_len Wise2_LinearHSPmanager_alloc_len /* Function: hard_link_LinearHSPmanager(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LinearHSPmanager *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_hard_link_LinearHSPmanager(LinearHSPmanager * obj); #define hard_link_LinearHSPmanager Wise2_hard_link_LinearHSPmanager /* Function: LinearHSPmanager_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_LinearHSPmanager_alloc(void); #define LinearHSPmanager_alloc Wise2_LinearHSPmanager_alloc /* Function: free_LinearHSPmanager(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LinearHSPmanager *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_free_LinearHSPmanager(LinearHSPmanager * obj); #define free_LinearHSPmanager Wise2_free_LinearHSPmanager /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_compare_HSP_score(HSP * one,HSP * two); #define compare_HSP_score Wise2_compare_HSP_score void Wise2_swap_HSPCache(HSP ** list,int i,int j) ; #define swap_HSPCache Wise2_swap_HSPCache void Wise2_qsort_HSPCache(HSP ** list,int left,int right,int (*comp)(HSP * ,HSP * )); #define qsort_HSPCache Wise2_qsort_HSPCache void Wise2_sort_HSPCache(HSPCache * obj,int (*comp)(HSP *, HSP *)); #define sort_HSPCache Wise2_sort_HSPCache boolean Wise2_expand_HSPCache(HSPCache * obj,int len); #define expand_HSPCache Wise2_expand_HSPCache void Wise2_swap_HSPset(HSP ** list,int i,int j) ; #define swap_HSPset Wise2_swap_HSPset void Wise2_qsort_HSPset(HSP ** list,int left,int right,int (*comp)(HSP * ,HSP * )); #define qsort_HSPset Wise2_qsort_HSPset void Wise2_sort_HSPset(HSPset * obj,int (*comp)(HSP *, HSP *)); #define sort_HSPset Wise2_sort_HSPset boolean Wise2_expand_HSPset(HSPset * obj,int len); #define expand_HSPset Wise2_expand_HSPset void Wise2_swap_LinearHSPmanager(HSPset ** list,int i,int j) ; #define swap_LinearHSPmanager Wise2_swap_LinearHSPmanager void Wise2_qsort_LinearHSPmanager(HSPset ** list,int left,int right,int (*comp)(HSPset * ,HSPset * )); #define qsort_LinearHSPmanager Wise2_qsort_LinearHSPmanager void Wise2_sort_LinearHSPmanager(LinearHSPmanager * obj,int (*comp)(HSPset *, HSPset *)); #define sort_LinearHSPmanager Wise2_sort_LinearHSPmanager boolean Wise2_expand_LinearHSPmanager(LinearHSPmanager * obj,int len); #define expand_LinearHSPmanager Wise2_expand_LinearHSPmanager #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/sequence_codon_api.h0000644000175000001440000000407010670453713020634 0ustar philippusers /* Helper functions in the module * * Wise2_reverse_complement_Sequence * Wise2_magic_trunc_Sequence * Wise2_translate_Sequence * /* These functions are not associated with an object */ /* Function: Wise2_reverse_complement_Sequence(seq) * * Descrip: This both complements and reverses a sequence, * - a common wish! * * The start/end are correct with respect to the start/end * of the sequence (ie start = end, end = start). * * * Arg: seq Sequence to that is used to reverse (makes a new Sequence) [Wise2_Sequence *] * * Returns new Sequence which is reversed [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_reverse_complement_Sequence( Wise2_Sequence * seq); /* Function: Wise2_magic_trunc_Sequence(seq,start,end) * * Descrip: Clever function for dna sequences. * * When start < end, truncates normally * * when start > end, truncates end,start and then * reverse complements. * * ie. If you have a coordinate system where reverse * sequences are labelled in reverse start/end way, * then this routine produces the correct sequence. * * * Arg: seq sequence that is the source to be truncated [Wise2_Sequence *] * Arg: start start point [int] * Arg: end end point [int] * * Returns new Sequence which is truncated/reversed [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_magic_trunc_Sequence( Wise2_Sequence * seq,int start,int end); /* Function: Wise2_translate_Sequence(dna,ct) * * Descrip: This translates a DNA sequence to a protein. * It assummes that it starts at first residue * (use trunc_Sequence to chop a sequence up). * * * Arg: dna DNA sequence to be translated [Wise2_Sequence *] * Arg: ct Codon table to do codon->aa mapping [Wise2_CodonTable *] * * Returns new protein sequence [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_translate_Sequence( Wise2_Sequence * dna,Wise2_CodonTable * ct); wise-2.4.1/src/dynlibsrc/sequence_codon_api.t0000644000175000001440000000000010670453713020635 0ustar philippuserswise-2.4.1/src/dynlibsrc/alnrange_api.h0000644000175000001440000002712410670453712017435 0ustar philippusers /* Functions that create, manipulate or act on AlnRange * * Wise2_hard_link_AlnRange * Wise2_AlnRange_alloc * Wise2_replace_starti_AlnRange * Wise2_access_starti_AlnRange * Wise2_replace_startj_AlnRange * Wise2_access_startj_AlnRange * Wise2_replace_startstate_AlnRange * Wise2_access_startstate_AlnRange * Wise2_replace_stopi_AlnRange * Wise2_access_stopi_AlnRange * Wise2_replace_stopj_AlnRange * Wise2_access_stopj_AlnRange * Wise2_replace_stopstate_AlnRange * Wise2_access_stopstate_AlnRange * Wise2_replace_startscore_AlnRange * Wise2_access_startscore_AlnRange * Wise2_replace_stopscore_AlnRange * Wise2_access_stopscore_AlnRange * Wise2_free_AlnRange [destructor] * */ /* Functions that create, manipulate or act on AlnRangeSet * * Wise2_hard_link_AlnRangeSet * Wise2_AlnRangeSet_alloc_std * Wise2_replace_score_AlnRangeSet * Wise2_access_score_AlnRangeSet * Wise2_access_alr_AlnRangeSet * Wise2_length_alr_AlnRangeSet * Wise2_flush_AlnRangeSet * Wise2_add_AlnRangeSet * Wise2_free_AlnRangeSet [destructor] * */ /* API for object AlnRange */ /* Function: Wise2_hard_link_AlnRange(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_AlnRange *] * * Returns Undocumented return value [Wise2_AlnRange *] * */ Wise2_AlnRange * Wise2_hard_link_AlnRange( Wise2_AlnRange * obj); /* Function: Wise2_AlnRange_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_AlnRange *] * */ Wise2_AlnRange * Wise2_AlnRange_alloc(); /* Function: Wise2_replace_starti_AlnRange(obj,starti) * * Descrip: Replace member variable starti * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * Arg: starti New value of the variable [int] * * Returns member variable starti [boolean] * */ boolean Wise2_replace_starti_AlnRange( Wise2_AlnRange * obj,int starti); /* Function: Wise2_access_starti_AlnRange(obj) * * Descrip: Access member variable starti * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * * Returns member variable starti [int] * */ int Wise2_access_starti_AlnRange( Wise2_AlnRange * obj); /* Function: Wise2_replace_startj_AlnRange(obj,startj) * * Descrip: Replace member variable startj * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * Arg: startj New value of the variable [int] * * Returns member variable startj [boolean] * */ boolean Wise2_replace_startj_AlnRange( Wise2_AlnRange * obj,int startj); /* Function: Wise2_access_startj_AlnRange(obj) * * Descrip: Access member variable startj * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * * Returns member variable startj [int] * */ int Wise2_access_startj_AlnRange( Wise2_AlnRange * obj); /* Function: Wise2_replace_startstate_AlnRange(obj,startstate) * * Descrip: Replace member variable startstate * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * Arg: startstate New value of the variable [int] * * Returns member variable startstate [boolean] * */ boolean Wise2_replace_startstate_AlnRange( Wise2_AlnRange * obj,int startstate); /* Function: Wise2_access_startstate_AlnRange(obj) * * Descrip: Access member variable startstate * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * * Returns member variable startstate [int] * */ int Wise2_access_startstate_AlnRange( Wise2_AlnRange * obj); /* Function: Wise2_replace_stopi_AlnRange(obj,stopi) * * Descrip: Replace member variable stopi * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * Arg: stopi New value of the variable [int] * * Returns member variable stopi [boolean] * */ boolean Wise2_replace_stopi_AlnRange( Wise2_AlnRange * obj,int stopi); /* Function: Wise2_access_stopi_AlnRange(obj) * * Descrip: Access member variable stopi * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * * Returns member variable stopi [int] * */ int Wise2_access_stopi_AlnRange( Wise2_AlnRange * obj); /* Function: Wise2_replace_stopj_AlnRange(obj,stopj) * * Descrip: Replace member variable stopj * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * Arg: stopj New value of the variable [int] * * Returns member variable stopj [boolean] * */ boolean Wise2_replace_stopj_AlnRange( Wise2_AlnRange * obj,int stopj); /* Function: Wise2_access_stopj_AlnRange(obj) * * Descrip: Access member variable stopj * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * * Returns member variable stopj [int] * */ int Wise2_access_stopj_AlnRange( Wise2_AlnRange * obj); /* Function: Wise2_replace_stopstate_AlnRange(obj,stopstate) * * Descrip: Replace member variable stopstate * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * Arg: stopstate New value of the variable [int] * * Returns member variable stopstate [boolean] * */ boolean Wise2_replace_stopstate_AlnRange( Wise2_AlnRange * obj,int stopstate); /* Function: Wise2_access_stopstate_AlnRange(obj) * * Descrip: Access member variable stopstate * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * * Returns member variable stopstate [int] * */ int Wise2_access_stopstate_AlnRange( Wise2_AlnRange * obj); /* Function: Wise2_replace_startscore_AlnRange(obj,startscore) * * Descrip: Replace member variable startscore * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * Arg: startscore New value of the variable [int] * * Returns member variable startscore [boolean] * */ boolean Wise2_replace_startscore_AlnRange( Wise2_AlnRange * obj,int startscore); /* Function: Wise2_access_startscore_AlnRange(obj) * * Descrip: Access member variable startscore * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * * Returns member variable startscore [int] * */ int Wise2_access_startscore_AlnRange( Wise2_AlnRange * obj); /* Function: Wise2_replace_stopscore_AlnRange(obj,stopscore) * * Descrip: Replace member variable stopscore * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * Arg: stopscore New value of the variable [int] * * Returns member variable stopscore [boolean] * */ boolean Wise2_replace_stopscore_AlnRange( Wise2_AlnRange * obj,int stopscore); /* Function: Wise2_access_stopscore_AlnRange(obj) * * Descrip: Access member variable stopscore * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRange *] * * Returns member variable stopscore [int] * */ int Wise2_access_stopscore_AlnRange( Wise2_AlnRange * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_AlnRange(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_AlnRange *] * * Returns Undocumented return value [Wise2_AlnRange *] * */ Wise2_AlnRange * Wise2_free_AlnRange( Wise2_AlnRange * obj); /* API for object AlnRangeSet */ /* Function: Wise2_hard_link_AlnRangeSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_AlnRangeSet *] * * Returns Undocumented return value [Wise2_AlnRangeSet *] * */ Wise2_AlnRangeSet * Wise2_hard_link_AlnRangeSet( Wise2_AlnRangeSet * obj); /* Function: Wise2_AlnRangeSet_alloc_std(void) * * Descrip: Equivalent to AlnRangeSet_alloc_len(AlnRangeSetLISTLENGTH) * * * * Returns Undocumented return value [Wise2_AlnRangeSet *] * */ Wise2_AlnRangeSet * Wise2_AlnRangeSet_alloc_std(); /* Function: Wise2_replace_score_AlnRangeSet(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRangeSet *] * Arg: score New value of the variable [int] * * Returns member variable score [boolean] * */ boolean Wise2_replace_score_AlnRangeSet( Wise2_AlnRangeSet * obj,int score); /* Function: Wise2_access_score_AlnRangeSet(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnRangeSet *] * * Returns member variable score [int] * */ int Wise2_access_score_AlnRangeSet( Wise2_AlnRangeSet * obj); /* Function: Wise2_access_alr_AlnRangeSet(obj,i) * * Descrip: Access members stored in the alr list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_AlnRangeSet *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_AlnRange *] * */ Wise2_AlnRange * Wise2_access_alr_AlnRangeSet( Wise2_AlnRangeSet * obj,int i); /* Function: Wise2_length_alr_AlnRangeSet(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_AlnRangeSet *] * * Returns length of the list [int] * */ int Wise2_length_alr_AlnRangeSet( Wise2_AlnRangeSet * obj); /* Function: Wise2_flush_AlnRangeSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_AlnRangeSet *] * * Returns Undocumented return value [int] * */ int Wise2_flush_AlnRangeSet( Wise2_AlnRangeSet * obj); /* Function: Wise2_add_AlnRangeSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_AlnRangeSet *] * Arg: add Object to add to the list [Wise2_AlnRange *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_AlnRangeSet( Wise2_AlnRangeSet * obj,Wise2_AlnRange * add); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_AlnRangeSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_AlnRangeSet *] * * Returns Undocumented return value [Wise2_AlnRangeSet *] * */ Wise2_AlnRangeSet * Wise2_free_AlnRangeSet( Wise2_AlnRangeSet * obj); wise-2.4.1/src/dynlibsrc/alnrange_api.t0000644000175000001440000000014410670453712017442 0ustar philippuserstypedef struct Wise2_AlnRange Wise2_AlnRange; typedef struct Wise2_AlnRangeSet Wise2_AlnRangeSet; wise-2.4.1/src/dynlibsrc/gene.typemap0000644000175000001440000000032210670453712017152 0ustar philippusers TYPEMAP Wise2_Gene * T_Wise2_Gene INPUT T_Wise2_Gene $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_Gene *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_Gene sv_setref_pv($arg, "Wise2::Gene", (void*) $var); wise-2.4.1/src/dynlibsrc/hsplookupscan.c0000644000175000001440000004257710670453712017712 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "hsplookupscan.h" #include #include /* Function: seq_number_aa_5mer_client(seq) * * Descrip: Function for the amino acid to number on 5mers * * * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 36 "hsplookupscan.dy" int seq_number_aa_5mer_client(char * seq) { int i; int ret = 0; int base = 1; int no = 0; for(i=0;i<5;i++) { no = toupper(seq[i])-'A'; if( no > 26 || no < 0 ) { no = 'X'-'A'; } ret += base * no; base = base * 26; } return ret; } /* Function: new_simple_HSPScanInterface(sli,mat,drop_off) * * Descrip: Builds a new simple scan interface. This * does not expand the query using a matrix but * rather simply scans down the query sequence * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ # line 62 "hsplookupscan.dy" HSPScanInterface * new_simple_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off) { HSPScanInterface * out; HSPScanPara * p; assert(sli); assert(mat); out = HSPScanInterface_alloc(); p = HSPScanPara_alloc(); p->sli = hard_link_SeqLookupInterface(sli); p->mat = hard_link_CompMat(mat); p->drop_off = drop_off; out->data = (void*)p; out->free_data = simple_HSPScan_free; out->scan_query = simple_HSPScan_scan_query; return out; } /* Function: new_one_off_HSPScanInterface(sli,mat,drop_off,score_cutoff) * * Descrip: Builds a new simple scan interface. This * does expands the query using a matrix but * just be considering off by one cases * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ # line 90 "hsplookupscan.dy" HSPScanInterface * new_one_off_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff) { HSPScanInterface * out; HSPScanPara * p; assert(sli); assert(mat); out = HSPScanInterface_alloc(); p = HSPScanPara_alloc(); p->sli = hard_link_SeqLookupInterface(sli); p->mat = hard_link_CompMat(mat); p->drop_off = drop_off; p->score_cutoff = score_cutoff; out->data = (void*)p; out->free_data = simple_HSPScan_free; if( sli->lookup_array_head == NULL ) { out->scan_query = one_off_HSPscan_scan_query; } else { out->scan_query = one_off_HSPscan_scan_query_direct; } return out; } /* Function: no_op_func(data,user_data,data2) * * Descrip: provide a no op func * * * Arg: data [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * Arg: data2 [UNKN ] Undocumented argument [gpointer] * * Return [UNKN ] Undocumented return value [int] * */ # line 122 "hsplookupscan.dy" int no_op_func(gpointer data,gpointer user_data,gpointer data2) { return 1; } /* Function: one_off_HSPscan_scan_query_direct(data,seq,para) * * Descrip: Simple word expansion for direct access * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 132 "hsplookupscan.dy" LinearHSPmanager * one_off_HSPscan_scan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para) { char * std_aa = "ACDEFGHIKLMNPQRSTVWY"; HSPmanager * hspm; LinearHSPmanager * out; HSPScanPara * p = (HSPScanPara *)data; LineariseHSPPara * hsp_para; int i; int j; int k; int aa; int score; char newseq[5]; int jj; int aa2; int has_seen; int seqno[5]; int base[5]; int start_base; int self_score[5]; int total_score; int current_score; ArraySeqHead * head; int no; #ifdef LINUX_TIMER static struct rusage use; struct timeval t1; struct timeval t2; struct timeval t3; #endif assert(seq); assert(p); assert(para); assert(para->max_results > 0); hsp_para = LineariseHSPPara_alloc(); hsp_para->verbosity = para->verbosity; hsp_para->max_size = para->max_results; hsp_para->min_score = para->min_hsp_score; hsp_para->width = para->hsp_link_width; hsp_para->tail = para->hsp_link_length; for(i=0,start_base=1;i<5;i++) { base[i] = start_base; start_base = start_base * 26; } if( VERBOSITY_CHECK(1,para->verbosity) ) { info("processing sequence %s with vanilla implementation",seq->name); } if( COMPILE_VERBOSITY_FLAG == 0 && para->verbosity > 0 ) { info("Verbosity information has not be enable in this compile. Ignoring verbosity request"); } hspm = new_HSPmanager(seq,p->mat,p->drop_off); #ifdef LINUX_TIMER if( VERBOSITY_CHECK(1,para->verbosity) ) { gettimeofday(&t1,NULL); } #endif for(i=0;ilen-5;i++) { if( VERBOSITY_CHECK(2,para->verbosity) && i%50 == 0 ) { info("Scanning %s at position %d with %d hits",seq->name,i,hspm->hsp_count); } head = (*p->sli->lookup_array_head)(p->sli->data,seq_number_aa_5mer_client(seq->seq+i)); if( head != NULL ) { if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { if( VERBOSITY_CHECK(7,para->verbosity) ) { info("position %d hit direct over filled position, %d vs hard %d, low %d",i,head->current_pos,para->numb_level,para->low_numb); } continue; } for(k=0;kcurrent_pos;k++) { if( add_pair_HSPmanager_score(hspm,head->units[k].seq,i,head->units[k].pos,para->min_hsp_score) == TRUE ) { ; } } /* if( p->use_msp_crunch == 1 && head != NULL && head->current_pos > p->msp_crunch_no ) { continue; } */ } total_score = 0; for(score=0,j=0;j<5;j++) { seqno[j] = base[j]*(toupper(seq->seq[i+j])-'A'); self_score[j] = p->mat->comp[toupper(seq->seq[i+j])-'A'][toupper(seq->seq[i+j])-'A']; total_score += self_score[j]; } has_seen = 0; for(j=0;j<5;j++) { for(aa=0;aa<20;aa++) { if( toupper(seq->seq[i+j]) == std_aa[aa] ) { continue; } seqno[j] = base[j]*(std_aa[aa]-'A'); no= seqno[0]+seqno[1]+seqno[2]+seqno[3]+seqno[4]; head = (*p->sli->lookup_array_head)(p->sli->data,no); if( head != NULL ) { if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { if( VERBOSITY_CHECK(7,para->verbosity) ) { info("position %d hit one-off over filled position, %d vs hard %d, low %d",i,head->current_pos,para->numb_level,para->low_numb); } continue; } has_seen = 1; for(k=0;kcurrent_pos;k++) { add_pair_HSPmanager(hspm,head->units[k].seq,i,head->units[k].pos) ; } } seqno[j] = base[j]*(toupper(seq->seq[i+j])-'A'); newseq[j] = seq->seq[i+j]; } /* really at this point we want to see if we have seen any really, really long HSPs, or rather enough long HSPs to remove the need for short HSPs. This is hard because good with two gaps in them will not have potentially three pretty short HSPs. Hmmmm. */ if( 1 || has_seen == 0 ) { /* latin square optimisation. The pattern of 1,1,0,1,0 of active swaps will cover all 2-off positions as the tile is progressed */ for(j=0;j<5;j++) { for(jj=1;jj<5;jj+=2) { for(aa=0;aa<20;aa++) { for(aa2=0;aa2<20;aa2++) { if( seq->seq[i+j] == std_aa[aa] || seq->seq[i+jj] == std_aa[aa2] ) { continue; } current_score = total_score; current_score -= (self_score[j] - p->mat->comp[toupper(seq->seq[i+j])-'A'][std_aa[aa]-'A']); current_score -= (self_score[jj] - p->mat->comp[toupper(seq->seq[i+jj])-'A'][std_aa[aa2]-'A']); if( current_score < para->min_word_score ) { continue; } else { /* fprintf(stderr,"Handling %d,%d amino acid %d,%d score %d\n",j,jj,aa,aa2,current_score); */ } seqno[j] = base[j]*(std_aa[aa]-'A'); seqno[jj] = base[jj]*(std_aa[aa2]-'A'); no= seqno[0]+seqno[1]+seqno[2]+seqno[3]+seqno[4]; head = (*p->sli->lookup_array_head)(p->sli->data,no); if( head != NULL ) { if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { if( VERBOSITY_CHECK(7,para->verbosity) ) { info("position %d hit direct over filled position, %d vs hard %d, low %d",i,head->current_pos,para->numb_level,para->low_numb); } continue; } has_seen = 1; for(k=0;kcurrent_pos;k++) { add_pair_HSPmanager_score(hspm,head->units[k].seq,i,head->units[k].pos,para->min_hsp_score) ; } } seqno[j] = base[j]*(toupper(seq->seq[i+j]-'A')); seqno[jj] = base[jj]*(toupper(seq->seq[i+jj]-'A')); newseq[j] = seq->seq[i+j]; newseq[jj] = seq->seq[i+jj]; } } } } } } } #ifdef LINUX_TIMER if( VERBOSITY_CHECK(1,para->verbosity) ) { getrusage(RUSAGE_SELF,&use); gettimeofday(&t2,NULL); } #endif if( para->use_protein_heuristic == TRUE ) { /* out = new_LinearHSPmanager_flat(hspm);*/ out = new_LinearHSPmanager_simple_heuristic(hspm,hsp_para); } else { out = new_LinearHSPmanager_flat(hspm); } fprintf(stderr,"Made linear manager with %d elements\n",out->len); #ifdef LINUX_TIMER if( VERBOSITY_CHECK(1,para->verbosity) ) { gettimeofday(&t3,NULL); getrusage(RUSAGE_SELF,&use); info("Sort clock point: Scan %f : Sort %f", t2.tv_sec - t1.tv_sec + ((t2.tv_usec - t1.tv_usec) * 1e-6), t3.tv_sec - t2.tv_sec + ((t2.tv_usec - t2.tv_usec) * 1e-6) ); } #endif /* free_HSPmanager(hspm);*/ return out; } /* Function: one_off_HSPscan_scan_query(data,seq,para) * * Descrip: Simple word expansion - one off score drop considered * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 398 "hsplookupscan.dy" LinearHSPmanager * one_off_HSPscan_scan_query(void * data,Sequence * seq,HSPScanInterfacePara * para) { HSPmanager * hspm; LinearHSPmanager * out; HSPScanPara * p = (HSPScanPara *)data; int i; int j; int aa; int score; int scorepos[5]; char newseq[5]; SeqLookupResultInterface * slri; SeqLookupClientInterface * slci; SeqLookupResultStruct * res = NULL; int trace = 0; assert(seq); assert(p); assert(para); assert(para->max_results > 0); slci = (*p->sli->get_client)(p->sli->data); hspm = new_HSPmanager(seq,p->mat,p->drop_off); for(i=0;ilen-5;i++) { if( trace ) fprintf(stderr,"Looking at %d %.5s (straight)\n",i,seq->seq+i); if( (*slci->is_populated)(slci->data,seq_number_aa_5mer(seq->seq+i)) ) { if( trace ) fprintf(stderr,".... is populated (straight) %d,%d\n",i,seq->seq[i]); slri = (*slci->lookup)(slci->data,seq_number_aa_5mer(seq->seq+i)); if( trace ) fprintf(stderr,".... have results (straight) %d,%d\n",i,seq->seq[i]); res = NULL; for(;(*slri->is_more)(slri->data);) { res = (*slri->next)(slri->data,res); add_pair_HSPmanager(hspm,res->seq,i,res->pos); if( trace ) fprintf(stderr,"...adding direct %.5s\n",res->seq->seq+res->pos); } free_SeqLookupResultInterface(slri); } if( trace ) { fprintf(stderr,"Expanding the sequence\n"); } for(score=0,j=0;j<5;j++) { newseq[j] = seq->seq[i+j]; scorepos[j] = p->mat->comp[seq->seq[i+j]-'A'][seq->seq[i+j]-'A']; score += p->mat->comp[seq->seq[i+j]-'A'][seq->seq[i+j]-'A']; } for(j=0;j<5;j++) { for(aa=0;aa<26;aa++) { if( score - scorepos[j] + p->mat->comp[seq->seq[i+j]-'A'][aa] > p->score_cutoff ) { newseq[j] = aa+'A'; if( trace ) { fprintf(stderr,"Seeing if is populated on expansion %d,%d\n",j,aa); } if( (*slci->is_populated)(slci->data,seq_number_aa_5mer(newseq)) ) { if( trace ) fprintf(stderr,"...is populated %.5s\n",res->seq->seq+res->pos); slri = (*slci->lookup)(slci->data,seq_number_aa_5mer(newseq)); res = NULL; for(;(*slri->is_more)(slri->data);) { res = (*slri->next)(slri->data,res); add_pair_HSPmanager(hspm,res->seq,i,res->pos); if( trace ) fprintf(stderr,"...adding one off %.5s\n",res->seq->seq+res->pos); } free_SeqLookupResultInterface(slri); } newseq[j] = seq->seq[i+j]; } } } } free_SeqLookupClientInterface(slci); if( para->use_protein_heuristic == TRUE ) { out = new_LinearHSPmanager_heuristic_max(hspm,para->max_results); } else { out = new_LinearHSPmanager_flat(hspm); } free_HSPmanager(hspm); return out; } /* Function: simple_HSPScan_scan_query(data,seq,para) * * Descrip: simple Scan function, no word expansions * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 515 "hsplookupscan.dy" LinearHSPmanager * simple_HSPScan_scan_query(void * data,Sequence * seq,HSPScanInterfacePara * para) { HSPmanager * hspm; LinearHSPmanager * out; HSPScanPara * p = (HSPScanPara *) data; int i; SeqLookupResultInterface * slri; SeqLookupClientInterface * slci; SeqLookupResultStruct * res = NULL; hspm = new_HSPmanager(seq,p->mat,p->drop_off); slci = (*p->sli->get_client)(p->sli->data); assert(slci); for(i=0;ilen-5;i++) { if( (*slci->is_populated)(slci->data,seq_number_aa_5mer(seq->seq+i)) ) { slri = (*slci->lookup)(slci->data,seq_number_aa_5mer(seq->seq+i)); for(;(*slri->is_more)(slri->data);) { res = (*slri->next)(slri->data,res); add_pair_HSPmanager(hspm,res->seq,i,res->pos); } free_SeqLookupResultInterface(slri); } } free_SeqLookupClientInterface(slci); out = new_LinearHSPmanager_heuristic_max(hspm,para->max_results); free_HSPmanager(hspm); return out; } /* Function: simple_HSPScan_free(data) * * Descrip: Free function for simple scans * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 557 "hsplookupscan.dy" void simple_HSPScan_free(void * data) { HSPScanPara * p = (HSPScanPara *) data; free_HSPScanPara(p); } # line 597 "hsplookupscan.c" /* Function: hard_link_HSPScanPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPScanPara *] * * Return [UNKN ] Undocumented return value [HSPScanPara *] * */ HSPScanPara * hard_link_HSPScanPara(HSPScanPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a HSPScanPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HSPScanPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPScanPara *] * */ HSPScanPara * HSPScanPara_alloc(void) { HSPScanPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HSPScanPara *) ckalloc (sizeof(HSPScanPara))) == NULL) { warn("HSPScanPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->sli = NULL; out->mat = NULL; out->drop_off = 0; out->score_cutoff = 0; out->use_msp_crunch = 1; out->msp_crunch_no = 10; out->seed_factor = 5; out->twohit_wobble = 5; out->threadno = 1; return out; } /* Function: free_HSPScanPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPScanPara *] * * Return [UNKN ] Undocumented return value [HSPScanPara *] * */ HSPScanPara * free_HSPScanPara(HSPScanPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HSPScanPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->sli != NULL) free_SeqLookupInterface(obj->sli); if( obj->mat != NULL) free_CompMat(obj->mat); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/hsplookupscan.h0000644000175000001440000001527010670453712017705 0ustar philippusers#ifndef DYNAMITEhsplookupscanHEADERFILE #define DYNAMITEhsplookupscanHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "hspscaninterface.h" #include "seqlookup.h" #include "hsphandler.h" #include "glib.h" struct Wise2_HSPScanPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeqLookupInterface * sli; CompMat * mat; int drop_off; int score_cutoff; int use_msp_crunch; int msp_crunch_no; int seed_factor; int twohit_wobble; int threadno; } ; /* HSPScanPara defined */ #ifndef DYNAMITE_DEFINED_HSPScanPara typedef struct Wise2_HSPScanPara Wise2_HSPScanPara; #define HSPScanPara Wise2_HSPScanPara #define DYNAMITE_DEFINED_HSPScanPara #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: seq_number_aa_5mer_client(seq) * * Descrip: Function for the amino acid to number on 5mers * * * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_seq_number_aa_5mer_client(char * seq); #define seq_number_aa_5mer_client Wise2_seq_number_aa_5mer_client /* Function: new_simple_HSPScanInterface(sli,mat,drop_off) * * Descrip: Builds a new simple scan interface. This * does not expand the query using a matrix but * rather simply scans down the query sequence * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ HSPScanInterface * Wise2_new_simple_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off); #define new_simple_HSPScanInterface Wise2_new_simple_HSPScanInterface /* Function: new_one_off_HSPScanInterface(sli,mat,drop_off,score_cutoff) * * Descrip: Builds a new simple scan interface. This * does expands the query using a matrix but * just be considering off by one cases * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ HSPScanInterface * Wise2_new_one_off_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff); #define new_one_off_HSPScanInterface Wise2_new_one_off_HSPScanInterface /* Function: no_op_func(data,user_data,data2) * * Descrip: provide a no op func * * * Arg: data [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * Arg: data2 [UNKN ] Undocumented argument [gpointer] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_no_op_func(gpointer data,gpointer user_data,gpointer data2); #define no_op_func Wise2_no_op_func /* Function: one_off_HSPscan_scan_query_direct(data,seq,para) * * Descrip: Simple word expansion for direct access * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_one_off_HSPscan_scan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para); #define one_off_HSPscan_scan_query_direct Wise2_one_off_HSPscan_scan_query_direct /* Function: one_off_HSPscan_scan_query(data,seq,para) * * Descrip: Simple word expansion - one off score drop considered * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_one_off_HSPscan_scan_query(void * data,Sequence * seq,HSPScanInterfacePara * para); #define one_off_HSPscan_scan_query Wise2_one_off_HSPscan_scan_query /* Function: simple_HSPScan_scan_query(data,seq,para) * * Descrip: simple Scan function, no word expansions * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_simple_HSPScan_scan_query(void * data,Sequence * seq,HSPScanInterfacePara * para); #define simple_HSPScan_scan_query Wise2_simple_HSPScan_scan_query /* Function: simple_HSPScan_free(data) * * Descrip: Free function for simple scans * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_simple_HSPScan_free(void * data); #define simple_HSPScan_free Wise2_simple_HSPScan_free /* Function: hard_link_HSPScanPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPScanPara *] * * Return [UNKN ] Undocumented return value [HSPScanPara *] * */ HSPScanPara * Wise2_hard_link_HSPScanPara(HSPScanPara * obj); #define hard_link_HSPScanPara Wise2_hard_link_HSPScanPara /* Function: HSPScanPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPScanPara *] * */ HSPScanPara * Wise2_HSPScanPara_alloc(void); #define HSPScanPara_alloc Wise2_HSPScanPara_alloc /* Function: free_HSPScanPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPScanPara *] * * Return [UNKN ] Undocumented return value [HSPScanPara *] * */ HSPScanPara * Wise2_free_HSPScanPara(HSPScanPara * obj); #define free_HSPScanPara Wise2_free_HSPScanPara /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/sequence_api.h0000644000175000001440000005432410670453712017460 0ustar philippusers /* Functions that create, manipulate or act on Sequence * * Wise2_uppercase_Sequence * Wise2_force_to_dna_Sequence * Wise2_is_reversed_Sequence * Wise2_translate_Sequence * Wise2_reverse_complement_Sequence * Wise2_magic_trunc_Sequence * Wise2_trunc_Sequence * Wise2_read_fasta_file_Sequence * Wise2_read_Sequence_EMBL_seq * Wise2_read_fasta_Sequence * Wise2_show_Sequence_residue_list * Wise2_write_fasta_Sequence * Wise2_make_len_type_Sequence * Wise2_hard_link_Sequence * Wise2_Sequence_alloc * Wise2_replace_name_Sequence * Wise2_access_name_Sequence * Wise2_replace_seq_Sequence * Wise2_access_seq_Sequence * Wise2_replace_len_Sequence * Wise2_access_len_Sequence * Wise2_replace_maxlen_Sequence * Wise2_access_maxlen_Sequence * Wise2_replace_offset_Sequence * Wise2_access_offset_Sequence * Wise2_replace_end_Sequence * Wise2_access_end_Sequence * Wise2_replace_type_Sequence * Wise2_access_type_Sequence * Wise2_replace_tax_id_Sequence * Wise2_access_tax_id_Sequence * Wise2_replace_weight_Sequence * Wise2_access_weight_Sequence * Wise2_replace_desc_Sequence * Wise2_access_desc_Sequence * Wise2_free_Sequence [destructor] * */ /* Functions that create, manipulate or act on SequenceSet * * Wise2_hard_link_SequenceSet * Wise2_SequenceSet_alloc_std * Wise2_access_set_SequenceSet * Wise2_length_set_SequenceSet * Wise2_flush_SequenceSet * Wise2_add_SequenceSet * Wise2_free_SequenceSet [destructor] * */ /* Helper functions in the module * * Wise2_Sequence_type_to_string * Wise2_new_Sequence_from_strings * /* API for object Sequence */ /* Function: Wise2_uppercase_Sequence(seq) * * Descrip: makes all the sequence uppercase * * * Arg: seq Sequence to be uppercased [Wise2_Sequence *] * * Returns Undocumented return value [void] * */ void Wise2_uppercase_Sequence( Wise2_Sequence * seq); /* Function: Wise2_force_to_dna_Sequence(seq,fraction,number_of_conver) * * Descrip: This * a) sees how many non ATGCN characters there are in Seq * b) If the level is below fraction * a) flips non ATGC chars to N * b) writes number of conversions to number_of_conver * c) returns TRUE * c) else returns FALSE * * fraction of 0.0 means completely intolerant of errors * fraction of 1.0 means completely tolerant of errors * * * * Arg: seq sequence object read and converted [Wise2_Sequence *] * Arg: fraction number 0..1 for tolerance of conversion [double] * Arg: number_of_conver number of conversions actually made [int *] * * Returns TRUE for conversion to DNA, FALSE if not [boolean] * */ boolean Wise2_force_to_dna_Sequence( Wise2_Sequence * seq,double fraction,int * number_of_conver); /* Function: Wise2_is_reversed_Sequence(seq) * * Descrip: Currently the sequence object stores * reversed sequences as start > end. * * This tests that and returns true if it is * * * Arg: seq sequence to test [Wise2_Sequence *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_is_reversed_Sequence( Wise2_Sequence * seq); /* Function: Wise2_translate_Sequence(dna,ct) * * Descrip: This translates a DNA sequence to a protein. * It assummes that it starts at first residue * (use trunc_Sequence to chop a sequence up). * * * Arg: dna DNA sequence to be translated [Wise2_Sequence *] * Arg: ct Codon table to do codon->aa mapping [Wise2_CodonTable *] * * Returns new protein sequence [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_translate_Sequence( Wise2_Sequence * dna,Wise2_CodonTable * ct); /* Function: Wise2_reverse_complement_Sequence(seq) * * Descrip: This both complements and reverses a sequence, * - a common wish! * * The start/end are correct with respect to the start/end * of the sequence (ie start = end, end = start). * * * Arg: seq Sequence to that is used to reverse (makes a new Sequence) [Wise2_Sequence *] * * Returns new Sequence which is reversed [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_reverse_complement_Sequence( Wise2_Sequence * seq); /* Function: Wise2_magic_trunc_Sequence(seq,start,end) * * Descrip: Clever function for dna sequences. * * When start < end, truncates normally * * when start > end, truncates end,start and then * reverse complements. * * ie. If you have a coordinate system where reverse * sequences are labelled in reverse start/end way, * then this routine produces the correct sequence. * * * Arg: seq sequence that is the source to be truncated [Wise2_Sequence *] * Arg: start start point [int] * Arg: end end point [int] * * Returns new Sequence which is truncated/reversed [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_magic_trunc_Sequence( Wise2_Sequence * seq,int start,int end); /* Function: Wise2_trunc_Sequence(seq,start,end) * * Descrip: truncates a sequence. It produces a new memory structure * which is filled from sequence start to end. * * Please notice * * Truncation is in C coordinates. That is * the first residue is 0 and end is the number of the * residue after the cut-point. In otherwords to * 2 - 3 would be a single residue truncation. So - if * you want to work in more usual, 'inclusive' molecular * biology numbers, which start at 1, then you need to say * * trunc_Sequence(seq,start-1,end); * * (NB, should be (end - 1 + 1) = end for the last coordinate). * * Truncation occurs against the *absolute* coordinate * system of the Sequence, not the offset/end pair inside. * So, this is a very bad error * * ** wrong code, and also leaks memory ** * * tru = trunc_Sequence(trunc_Sequence(seq,50,80),55,75); * * This the most portable way of doing this * * temp = trunc_Sequence(seq,50,80); * * tru = trunc_Sequence(temp,55-temp->offset,75-temp->offset); * * free_Sequence(temp); * * * * Arg: seq object holding the sequence to be truncated [Wise2_Sequence *] * Arg: start start point of truncation [int] * Arg: end end point of truncation [int] * * Returns newly allocated sequence structure [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_trunc_Sequence( Wise2_Sequence * seq,int start,int end); /* Function: Wise2_read_fasta_file_Sequence(filename) * * Descrip: Just a call * a) open filename * b) read sequence with /read_fasta_Sequence * c) close file. * * * Arg: filename filename to open [char *] * * Returns Undocumented return value [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_read_fasta_file_Sequence( char * filename); /* Function: Wise2_read_Sequence_EMBL_seq(buffer,maxlen,ifp) * * Descrip: reads the sequence part of an EMBL file. * * This function can either take a file which * starts * * * * Arg: buffer buffer containing the first line. [char *] * Arg: maxlen length of buffer [int] * Arg: ifp input file to read from [FILE *] * * Returns Undocumented return value [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_read_Sequence_EMBL_seq( char * buffer,int maxlen,FILE * ifp); /* Function: Wise2_read_fasta_Sequence(ifp) * * Descrip: reads a fasta file assumming pretty * standard sanity for the file layout * * * Arg: ifp Undocumented argument [FILE *] * * Returns Undocumented return value [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_read_fasta_Sequence( FILE * ifp); /* Function: Wise2_show_Sequence_residue_list(seq,start,end,ofp) * * Descrip: shows a region of a sequence as * 124 A * 125 T * * etc from start to end. The numbers * are in C coordinates (ie, 0 is the first * letter). * * useful for debugging * * * Arg: seq Sequence to show [Wise2_Sequence *] * Arg: start start of list [int] * Arg: end end of list [int] * Arg: ofp Undocumented argument [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_show_Sequence_residue_list( Wise2_Sequence * seq,int start,int end,FILE * ofp); /* Function: Wise2_write_fasta_Sequence(seq,ofp) * * Descrip: writes a fasta file of the form * >name * Sequence * * * Arg: seq sequence to be written [Wise2_Sequence *] * Arg: ofp file to write to [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_write_fasta_Sequence( Wise2_Sequence * seq,FILE * ofp); /* Function: Wise2_make_len_type_Sequence(seq) * * Descrip: makes seq->len and seq->end match the seq->seq * length number. * * It also checks the type of the sequence with * /best_guess_type * * * Arg: seq Sequence object [Wise2_Sequence *] * * Returns Undocumented return value [void] * */ void Wise2_make_len_type_Sequence( Wise2_Sequence * seq); /* Function: Wise2_hard_link_Sequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_Sequence *] * * Returns Undocumented return value [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_hard_link_Sequence( Wise2_Sequence * obj); /* Function: Wise2_Sequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_Sequence_alloc(); /* Function: Wise2_replace_name_Sequence(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * Arg: name New value of the variable [char *] * * Returns member variable name [boolean] * */ boolean Wise2_replace_name_Sequence( Wise2_Sequence * obj,char * name); /* Function: Wise2_access_name_Sequence(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * * Returns member variable name [char *] * */ char * Wise2_access_name_Sequence( Wise2_Sequence * obj); /* Function: Wise2_replace_seq_Sequence(obj,seq) * * Descrip: Replace member variable seq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * Arg: seq New value of the variable [char *] * * Returns member variable seq [boolean] * */ boolean Wise2_replace_seq_Sequence( Wise2_Sequence * obj,char * seq); /* Function: Wise2_access_seq_Sequence(obj) * * Descrip: Access member variable seq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * * Returns member variable seq [char *] * */ char * Wise2_access_seq_Sequence( Wise2_Sequence * obj); /* Function: Wise2_replace_len_Sequence(obj,len) * * Descrip: Replace member variable len * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * Arg: len New value of the variable [int] * * Returns member variable len [boolean] * */ boolean Wise2_replace_len_Sequence( Wise2_Sequence * obj,int len); /* Function: Wise2_access_len_Sequence(obj) * * Descrip: Access member variable len * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * * Returns member variable len [int] * */ int Wise2_access_len_Sequence( Wise2_Sequence * obj); /* Function: Wise2_replace_maxlen_Sequence(obj,maxlen) * * Descrip: Replace member variable maxlen * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * Arg: maxlen New value of the variable [int] * * Returns member variable maxlen [boolean] * */ boolean Wise2_replace_maxlen_Sequence( Wise2_Sequence * obj,int maxlen); /* Function: Wise2_access_maxlen_Sequence(obj) * * Descrip: Access member variable maxlen * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * * Returns member variable maxlen [int] * */ int Wise2_access_maxlen_Sequence( Wise2_Sequence * obj); /* Function: Wise2_replace_offset_Sequence(obj,offset) * * Descrip: Replace member variable offset * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * Arg: offset New value of the variable [int] * * Returns member variable offset [boolean] * */ boolean Wise2_replace_offset_Sequence( Wise2_Sequence * obj,int offset); /* Function: Wise2_access_offset_Sequence(obj) * * Descrip: Access member variable offset * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * * Returns member variable offset [int] * */ int Wise2_access_offset_Sequence( Wise2_Sequence * obj); /* Function: Wise2_replace_end_Sequence(obj,end) * * Descrip: Replace member variable end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * Arg: end New value of the variable [int] * * Returns member variable end [boolean] * */ boolean Wise2_replace_end_Sequence( Wise2_Sequence * obj,int end); /* Function: Wise2_access_end_Sequence(obj) * * Descrip: Access member variable end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * * Returns member variable end [int] * */ int Wise2_access_end_Sequence( Wise2_Sequence * obj); /* Function: Wise2_replace_type_Sequence(obj,type) * * Descrip: Replace member variable type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * Arg: type New value of the variable [char] * * Returns member variable type [boolean] * */ boolean Wise2_replace_type_Sequence( Wise2_Sequence * obj,char type); /* Function: Wise2_access_type_Sequence(obj) * * Descrip: Access member variable type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * * Returns member variable type [char] * */ char Wise2_access_type_Sequence( Wise2_Sequence * obj); /* Function: Wise2_replace_tax_id_Sequence(obj,tax_id) * * Descrip: Replace member variable tax_id * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * Arg: tax_id New value of the variable [int] * * Returns member variable tax_id [boolean] * */ boolean Wise2_replace_tax_id_Sequence( Wise2_Sequence * obj,int tax_id); /* Function: Wise2_access_tax_id_Sequence(obj) * * Descrip: Access member variable tax_id * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * * Returns member variable tax_id [int] * */ int Wise2_access_tax_id_Sequence( Wise2_Sequence * obj); /* Function: Wise2_replace_weight_Sequence(obj,weight) * * Descrip: Replace member variable weight * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * Arg: weight New value of the variable [double] * * Returns member variable weight [boolean] * */ boolean Wise2_replace_weight_Sequence( Wise2_Sequence * obj,double weight); /* Function: Wise2_access_weight_Sequence(obj) * * Descrip: Access member variable weight * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * * Returns member variable weight [double] * */ double Wise2_access_weight_Sequence( Wise2_Sequence * obj); /* Function: Wise2_replace_desc_Sequence(obj,desc) * * Descrip: Replace member variable desc * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * Arg: desc New value of the variable [char *] * * Returns member variable desc [boolean] * */ boolean Wise2_replace_desc_Sequence( Wise2_Sequence * obj,char * desc); /* Function: Wise2_access_desc_Sequence(obj) * * Descrip: Access member variable desc * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Sequence *] * * Returns member variable desc [char *] * */ char * Wise2_access_desc_Sequence( Wise2_Sequence * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_Sequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_Sequence *] * * Returns Undocumented return value [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_free_Sequence( Wise2_Sequence * obj); /* API for object SequenceSet */ /* Function: Wise2_hard_link_SequenceSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_SequenceSet *] * * Returns Undocumented return value [Wise2_SequenceSet *] * */ Wise2_SequenceSet * Wise2_hard_link_SequenceSet( Wise2_SequenceSet * obj); /* Function: Wise2_SequenceSet_alloc_std(void) * * Descrip: Equivalent to SequenceSet_alloc_len(SequenceSetLISTLENGTH) * * * * Returns Undocumented return value [Wise2_SequenceSet *] * */ Wise2_SequenceSet * Wise2_SequenceSet_alloc_std(); /* Function: Wise2_access_set_SequenceSet(obj,i) * * Descrip: Access members stored in the set list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_SequenceSet *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_access_set_SequenceSet( Wise2_SequenceSet * obj,int i); /* Function: Wise2_length_set_SequenceSet(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_SequenceSet *] * * Returns length of the list [int] * */ int Wise2_length_set_SequenceSet( Wise2_SequenceSet * obj); /* Function: Wise2_flush_SequenceSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_SequenceSet *] * * Returns Undocumented return value [int] * */ int Wise2_flush_SequenceSet( Wise2_SequenceSet * obj); /* Function: Wise2_add_SequenceSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_SequenceSet *] * Arg: add Object to add to the list [Wise2_Sequence *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_SequenceSet( Wise2_SequenceSet * obj,Wise2_Sequence * add); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_SequenceSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_SequenceSet *] * * Returns Undocumented return value [Wise2_SequenceSet *] * */ Wise2_SequenceSet * Wise2_free_SequenceSet( Wise2_SequenceSet * obj); /* These functions are not associated with an object */ /* Function: Wise2_Sequence_type_to_string(type) * * Descrip: Converts sequence type (SEQUENCE_*) to a string * * * Arg: type type eg SEQUENCE_PROTEIN [int] * * Returns Undocumented return value [char *] * */ char * Wise2_Sequence_type_to_string( int type); /* Function: Wise2_new_Sequence_from_strings(name,seq) * * Descrip: Makes a new sequence from strings given. * Separate memory will be allocated for them * and them copied into it. * * They can be NULL, in which case * o a dummy name SequenceName will be assigned * o No sequence placed and length of zero. * * Though this is dangerous later on. * * The sequence type is calculated automatically using * /best_guess_type. If you want a DNA sequence but are * unsure of the content of, for example, IUPAC codes, * please use /force_to_dna_Sequence before using the * sequence. Most of the rest of dynamite relies on a * five letter A,T,G,C,N alphabet, but this function * will allow any sequence type to be stored, so please * check if you want to save yourself alot of grief. * * In perl and other interfaces, this is a much safer * constructor than the raw "new" type * * * Arg: name name of sequence, memory is allocated for it. [char *] * Arg: seq char * of sequence, memory is allocated for it. [char *] * * Returns Undocumented return value [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_new_Sequence_from_strings( char * name,char * seq); wise-2.4.1/src/dynlibsrc/sequence_api.t0000644000175000001440000000014410670453712017463 0ustar philippuserstypedef struct Wise2_Sequence Wise2_Sequence; typedef struct Wise2_SequenceSet Wise2_SequenceSet; wise-2.4.1/src/dynlibsrc/genomic_api.h0000644000175000001440000003023210670453712017261 0ustar philippusers /* Functions that create, manipulate or act on Genomic * * Wise2_truncate_Genomic * Wise2_Genomic_name * Wise2_Genomic_length * Wise2_Genomic_seqchar * Wise2_show_Genomic * Wise2_hard_link_Genomic * Wise2_Genomic_alloc_std * Wise2_replace_baseseq_Genomic * Wise2_access_baseseq_Genomic * Wise2_access_repeat_Genomic * Wise2_length_repeat_Genomic * Wise2_flush_Genomic * Wise2_add_Genomic * Wise2_free_Genomic [destructor] * */ /* Functions that create, manipulate or act on GenomicRepeat * * Wise2_hard_link_GenomicRepeat * Wise2_GenomicRepeat_alloc * Wise2_replace_start_GenomicRepeat * Wise2_access_start_GenomicRepeat * Wise2_replace_end_GenomicRepeat * Wise2_access_end_GenomicRepeat * Wise2_replace_type_GenomicRepeat * Wise2_access_type_GenomicRepeat * Wise2_free_GenomicRepeat [destructor] * */ /* Helper functions in the module * * Wise2_read_fasta_file_Genomic * Wise2_read_fasta_Genomic * Wise2_Genomic_from_Sequence_Nheuristic * Wise2_Genomic_from_Sequence * /* API for object Genomic */ /* Function: Wise2_truncate_Genomic(gen,start,stop) * * Descrip: Truncates a Genomic sequence. Basically uses * the /magic_trunc_Sequence function (of course!) * * It does not alter gen, rather it returns a new * sequence with that truncation * * Handles repeat information correctly. * * * Arg: gen Genomic that is truncated [Wise2_Genomic *] * Arg: start Undocumented argument [int] * Arg: stop Undocumented argument [int] * * Returns Undocumented return value [Wise2_Genomic *] * */ Wise2_Genomic * Wise2_truncate_Genomic( Wise2_Genomic * gen,int start,int stop); /* Function: Wise2_Genomic_name(gen) * * Descrip: Returns the name of the Genomic * * * Arg: gen Undocumented argument [Wise2_Genomic *] * * Returns Undocumented return value [char *] * */ char * Wise2_Genomic_name( Wise2_Genomic * gen); /* Function: Wise2_Genomic_length(gen) * * Descrip: Returns the length of the Genomic * * * Arg: gen Undocumented argument [Wise2_Genomic *] * * Returns Undocumented return value [int] * */ int Wise2_Genomic_length( Wise2_Genomic * gen); /* Function: Wise2_Genomic_seqchar(gen,pos) * * Descrip: Returns sequence character at this position. * * * Arg: gen Genomic [Wise2_Genomic *] * Arg: pos position in Genomic to get char [int] * * Returns Undocumented return value [char] * */ char Wise2_Genomic_seqchar( Wise2_Genomic * gen,int pos); /* Function: Wise2_show_Genomic(gen,ofp) * * Descrip: For debugging * * * Arg: gen Undocumented argument [Wise2_Genomic *] * Arg: ofp Undocumented argument [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_show_Genomic( Wise2_Genomic * gen,FILE * ofp); /* Function: Wise2_hard_link_Genomic(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_Genomic *] * * Returns Undocumented return value [Wise2_Genomic *] * */ Wise2_Genomic * Wise2_hard_link_Genomic( Wise2_Genomic * obj); /* Function: Wise2_Genomic_alloc_std(void) * * Descrip: Equivalent to Genomic_alloc_len(GenomicLISTLENGTH) * * * * Returns Undocumented return value [Wise2_Genomic *] * */ Wise2_Genomic * Wise2_Genomic_alloc_std(); /* Function: Wise2_replace_baseseq_Genomic(obj,baseseq) * * Descrip: Replace member variable baseseq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Genomic *] * Arg: baseseq New value of the variable [Wise2_Sequence *] * * Returns member variable baseseq [boolean] * */ boolean Wise2_replace_baseseq_Genomic( Wise2_Genomic * obj,Wise2_Sequence * baseseq); /* Function: Wise2_access_baseseq_Genomic(obj) * * Descrip: Access member variable baseseq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Genomic *] * * Returns member variable baseseq [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_access_baseseq_Genomic( Wise2_Genomic * obj); /* Function: Wise2_access_repeat_Genomic(obj,i) * * Descrip: Access members stored in the repeat list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_Genomic *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_GenomicRepeat *] * */ Wise2_GenomicRepeat * Wise2_access_repeat_Genomic( Wise2_Genomic * obj,int i); /* Function: Wise2_length_repeat_Genomic(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_Genomic *] * * Returns length of the list [int] * */ int Wise2_length_repeat_Genomic( Wise2_Genomic * obj); /* Function: Wise2_flush_Genomic(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_Genomic *] * * Returns Undocumented return value [int] * */ int Wise2_flush_Genomic( Wise2_Genomic * obj); /* Function: Wise2_add_Genomic(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_Genomic *] * Arg: add Object to add to the list [Wise2_GenomicRepeat *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_Genomic( Wise2_Genomic * obj,Wise2_GenomicRepeat * add); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_Genomic(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_Genomic *] * * Returns Undocumented return value [Wise2_Genomic *] * */ Wise2_Genomic * Wise2_free_Genomic( Wise2_Genomic * obj); /* API for object GenomicRepeat */ /* Function: Wise2_hard_link_GenomicRepeat(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_GenomicRepeat *] * * Returns Undocumented return value [Wise2_GenomicRepeat *] * */ Wise2_GenomicRepeat * Wise2_hard_link_GenomicRepeat( Wise2_GenomicRepeat * obj); /* Function: Wise2_GenomicRepeat_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_GenomicRepeat *] * */ Wise2_GenomicRepeat * Wise2_GenomicRepeat_alloc(); /* Function: Wise2_replace_start_GenomicRepeat(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GenomicRepeat *] * Arg: start New value of the variable [int] * * Returns member variable start [boolean] * */ boolean Wise2_replace_start_GenomicRepeat( Wise2_GenomicRepeat * obj,int start); /* Function: Wise2_access_start_GenomicRepeat(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GenomicRepeat *] * * Returns member variable start [int] * */ int Wise2_access_start_GenomicRepeat( Wise2_GenomicRepeat * obj); /* Function: Wise2_replace_end_GenomicRepeat(obj,end) * * Descrip: Replace member variable end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GenomicRepeat *] * Arg: end New value of the variable [int] * * Returns member variable end [boolean] * */ boolean Wise2_replace_end_GenomicRepeat( Wise2_GenomicRepeat * obj,int end); /* Function: Wise2_access_end_GenomicRepeat(obj) * * Descrip: Access member variable end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GenomicRepeat *] * * Returns member variable end [int] * */ int Wise2_access_end_GenomicRepeat( Wise2_GenomicRepeat * obj); /* Function: Wise2_replace_type_GenomicRepeat(obj,type) * * Descrip: Replace member variable type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GenomicRepeat *] * Arg: type New value of the variable [char *] * * Returns member variable type [boolean] * */ boolean Wise2_replace_type_GenomicRepeat( Wise2_GenomicRepeat * obj,char * type); /* Function: Wise2_access_type_GenomicRepeat(obj) * * Descrip: Access member variable type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GenomicRepeat *] * * Returns member variable type [char *] * */ char * Wise2_access_type_GenomicRepeat( Wise2_GenomicRepeat * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_GenomicRepeat(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_GenomicRepeat *] * * Returns Undocumented return value [Wise2_GenomicRepeat *] * */ Wise2_GenomicRepeat * Wise2_free_GenomicRepeat( Wise2_GenomicRepeat * obj); /* These functions are not associated with an object */ /* Function: Wise2_read_fasta_file_Genomic(filename,length_of_N) * * Descrip: Reads a fasta file assumming that it is Genomic. * Will complain if it is not, and return NULL. * * * Arg: filename filename to be opened and read [char *] * Arg: length_of_N length of N to be considered repeat. -1 means none [int] * * Returns Undocumented return value [Wise2_Genomic *] * */ Wise2_Genomic * Wise2_read_fasta_file_Genomic( char * filename,int length_of_N); /* Function: Wise2_read_fasta_Genomic(ifp,length_of_N) * * Descrip: Reads a fasta file assumming that it is Genomic. * Will complain if it is not, and return NULL. * * * Arg: ifp file point to be read from [FILE *] * Arg: length_of_N length of N to be considered repeat. -1 means none [int] * * Returns Undocumented return value [Wise2_Genomic *] * */ Wise2_Genomic * Wise2_read_fasta_Genomic( FILE * ifp,int length_of_N); /* Function: Wise2_Genomic_from_Sequence_Nheuristic(seq,length_of_N) * * Descrip: makes a new genomic from a Sequence, but * assummes that all the N runs greater than * a certain level are actually repeats. * * * Arg: seq Undocumented argument [Wise2_Sequence *] * Arg: length_of_N Undocumented argument [int] * * Returns Undocumented return value [Wise2_Genomic *] * */ Wise2_Genomic * Wise2_Genomic_from_Sequence_Nheuristic( Wise2_Sequence * seq,int length_of_N); /* Function: Wise2_Genomic_from_Sequence(seq) * * Descrip: makes a new genomic from a Sequence. It * owns the Sequence memory, ie will attempt a /free_Sequence * on the structure when /free_Genomic is called * * If you want to give this genomic this Sequence and * forget about it, then just hand it this sequence and set * seq to NULL (no need to free it). If you intend to use * the sequence object elsewhere outside of the Genomic datastructure * then use Genomic_from_Sequence(/hard_link_Sequence(seq)) * * This is part of a strict typing system, and therefore * is going to convert all non ATGCNs to Ns. You will lose * information here. * * * Arg: seq Sequence to make genomic from [Wise2_Sequence *] * * Returns Undocumented return value [Wise2_Genomic *] * */ Wise2_Genomic * Wise2_Genomic_from_Sequence( Wise2_Sequence * seq); wise-2.4.1/src/dynlibsrc/genomic_api.t0000644000175000001440000000014610670453712017276 0ustar philippuserstypedef struct Wise2_Genomic Wise2_Genomic; typedef struct Wise2_GenomicRepeat Wise2_GenomicRepeat; wise-2.4.1/src/dynlibsrc/test_randomdb.c0000644000175000001440000000107207313404542017624 0ustar philippusers#include "randomdb.h" main() { int i; Sequence * out; RandomModel * rm; RandomProteinDB * rdp; RandomDNADB * rddp; RandomModelDNA * rmd; rm = default_RandomModel(); rmd = RandomModelDNA_std(); rdp = new_flat_RandomProteinDB(rm,50); for(i=0;i<5;i++) { out = Sequence_from_RandomProteinDB(rdp); write_fasta_Sequence(out,stdout); free_Sequence(out); } rddp = new_flat_RandomDNADB(rmd,50); for(i=0;i<5;i++) { out = Sequence_from_RandomDNADB(rddp); write_fasta_Sequence(out,stdout); free_Sequence(out); } } wise-2.4.1/src/dynlibsrc/pairbaseseq.dy0000644000175000001440000001435507502704706017505 0ustar philippusers %{ #include "pairbase.h" #include "seqalign.h" #include "complexsequence.h" #include "complexevalset.h" #define PAIRBASE_CS_CODON 0 #define PAIRBASE_CS_PAIRCODON 1 #define PAIRBASE_CS_PAIRBASE 2 #define PAIRBASE_CS_5SS 3 #define PAIRBASE_CS_3SS 4 #define PAIRBASE_RS_CODON 5 #define PAIRBASE_RS_PAIRCODON 6 #define PAIRBASE_RS_PAIRBASE 7 #define PAIRBASE_RS_5SS 8 #define PAIRBASE_RS_3SS 9 #define PAIRBASE_CS_LENGTH 10 #define CSEQ_PAIR_CODON(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_CS_CODON]) #define CSEQ_PAIR_PAIRCODON(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_CS_PAIRCODON]) #define CSEQ_PAIR_PAIRBASE(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_CS_PAIRBASE]) #define CSEQ_PAIR_5SS(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_CS_5SS]) #define CSEQ_PAIR_3SS(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_CS_3SS]) #define CSEQ_REV_PAIR_CODON(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_RS_CODON]) #define CSEQ_REV_PAIR_PAIRCODON(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_RS_PAIRCODON]) #define CSEQ_REV_PAIR_PAIRBASE(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_RS_PAIRBASE]) #define CSEQ_REV_PAIR_5SS(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_RS_5SS]) #define CSEQ_REV_PAIR_3SS(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_RS_3SS]) %} struct PairBaseSeq char * seq int len Sequence * anchor // may not always be here SeqAlign * sa // may not always be here %{ #include "pairbaseseq.h" %func Makes a ComplexSeq from a PairBaseSeq %% ComplexSequence * ComplexSequence_from_PairBaseSeq(PairBaseSeq * pbs,ComplexSequenceEval * splice5,ComplexSequenceEval * splice3) { int i; int * poi; ComplexSequence * out; Sequence * rev; pairbase_type a; pairbase_type g; pairbase_type t; assert(pbs); assert(pbs->anchor); assert(splice5); assert(splice3); a = MAKE_PAIRBASE(BASE_A,BASE_A); g = MAKE_PAIRBASE(BASE_G,BASE_G); t = MAKE_PAIRBASE(BASE_T,BASE_T); rev = reverse_complement_Sequence(pbs->anchor); out = ComplexSequence_alloc(); if( out == NULL ) return NULL; /* fprintf(stderr,"Got %s as anchor\n",pbs->anchor->seq); */ out->datastore = (int *) ckcalloc((pbs->anchor->len+10)*PAIRBASE_CS_LENGTH,sizeof(int)); out->data = out->datastore + (10 * PAIRBASE_CS_LENGTH); out->depth = PAIRBASE_CS_LENGTH; for(i=0;i<10;i++) { out->datastore[(i*PAIRBASE_CS_LENGTH)+0] = 4; } for(i=0,poi = out->data;ianchor->len;i++,poi = next_ComplexSequence_data(out,poi)) { /* 0 is codon */ poi[PAIRBASE_CS_CODON] = codon_number_func(0,NULL,pbs->anchor->seq+i); /* 1 is paircodon */ poi[PAIRBASE_CS_PAIRCODON] = pairbase_codon_from_seq(pbs->seq+i-2); /* 2 is a pairbase */ poi[PAIRBASE_CS_PAIRBASE] = pbs->seq[i]; /* 3 is 5' SS */ if( i < splice5->left_window || i+splice5->right_window > pbs->anchor->len || pbs->seq[i] != g || pbs->seq[i+1] != t) { poi[PAIRBASE_CS_5SS] = splice5->outside_score; } else { poi[PAIRBASE_CS_5SS] = splice5->eval_func(splice5->data_type,splice5->data,pbs->anchor->seq+i); poi[PAIRBASE_CS_5SS] += splice5->eval_func(splice5->data_type,splice5->data,pbs->sa->seq[1]->seq+i); } /* 4 is 3' SS */ if( i < splice3->left_window || i+splice3->right_window > pbs->anchor->len || pbs->seq[i] != g || pbs->seq[i-1] != a ) { poi[PAIRBASE_CS_3SS] = splice3->outside_score; } else { poi[PAIRBASE_CS_3SS] = splice3->eval_func(splice3->data_type,splice3->data,pbs->anchor->seq+i); poi[PAIRBASE_CS_3SS] += splice3->eval_func(splice3->data_type,splice3->data,pbs->sa->seq[1]->seq+i); } /* 5 is reverse codon */ poi[PAIRBASE_RS_CODON] = reverse_codon(codon_number_func(0,NULL,pbs->anchor->seq+i)); /* 6 is reverse paircodon */ poi[PAIRBASE_RS_PAIRCODON] = reverse_pairbase_codon(pairbase_codon_from_seq(pbs->seq+i-2)); /* 7 is reverse pairbase */ poi[PAIRBASE_RS_PAIRBASE] = complement_pairbase(pbs->seq[i]); /* 8 is reverse 5'SS */ if( i < splice5->left_window || i+splice5->right_window > pbs->anchor->len ) { poi[PAIRBASE_RS_5SS] = splice5->outside_score; } else { poi[PAIRBASE_RS_5SS] = splice5->eval_func(splice5->data_type,splice5->data,rev->seq+rev->len-1-i); } /* 9 is reverse 3'SS */ if( i < splice3->left_window || i+splice3->right_window > pbs->anchor->len ) { poi[PAIRBASE_RS_3SS] = splice3->outside_score; } else { poi[PAIRBASE_RS_3SS] = splice3->eval_func(splice3->data_type,splice3->data,rev->seq+rev->len-1-i); } /* fprintf(stdout,"Position %d got %d %d \n",i,poi[PAIRBASE_RS_5SS],poi[PAIRBASE_RS_3SS]); */ } out->length = pbs->anchor->len; out->seq = hard_link_Sequence(pbs->anchor); free_Sequence(rev); return out; } %func Makes a SeqAlign from a PairBaseSeq %% SeqAlign * SeqAlign_from_PairBaseSeq(PairBaseSeq * pbs) { SeqAlign * out; Sequence * a; Sequence * b; int i; assert(pbs); out = SeqAlign_alloc_len(2); a = Sequence_alloc_len(pbs->len); b = Sequence_alloc_len(pbs->len); add_SeqAlign(out,a); add_SeqAlign(out,b); for(i=0;ilen;i++) { a->seq[i] = char_from_base(anchor_base_from_pairbase(pbs->seq[i])); b->seq[i] = char_from_base(informant_base_from_pairbase(pbs->seq[i])); } a->seq[i] = b->seq[i] = '\0'; return out; } %func Makes a pairseq from a SeqAlign %% PairBaseSeq * new_PairBaseSeq_SeqAlign(SeqAlign * al) { PairBaseSeq * out; out = new_PairBaseSeq_strings(al->seq[0]->seq,al->seq[1]->seq); out->sa = hard_link_SeqAlign(al); return out; } %func Makes a pairseq from two strings %% PairBaseSeq * new_PairBaseSeq_strings(char * a,char * b) { int i; int l; PairBaseSeq * out; Sequence * anchor; assert(a); assert(b); if( strlen(a) != strlen(b) ) { warn("Cannot build PairBaseSeq with different length strings %d %d",strlen(a),strlen(b)); return NULL; } l = strlen(a); out = PairBaseSeq_alloc(); out->seq = (pairbase_type *) calloc(l,sizeof(pairbase_type)); for(i=0;iseq[i] = MAKE_PAIRBASE(base_from_char(a[i]),base_from_char(b[i])); } anchor = new_Sequence_from_strings("anchor",a); out->anchor = anchor; out->len = l; return out; } wise-2.4.1/src/dynlibsrc/complexevalset.dy0000644000175000001440000002250307346257031020233 0ustar philippusers/* Last edited: Apr 24 15:02 1997 (birney) */ %{ #include "complexsequence.h" #include "genomic.h" /*** ok, some types to works with ***/ #define AMINOACID CSEQ_PROTEIN_AMINOACID #define CSEQ_PROTEIN_AMINOACID(cseq,index) (cseq->data[index]) /*** for genomic ***/ #define CSEQ_G_LEN 6 #define CSEQ_GENOMIC_BASE(cseq,index) (cseq->data[(index)*CSEQ_G_LEN]) #define CSEQ_GENOMIC_CODON(cseq,index) (cseq->data[(index)*CSEQ_G_LEN +1]) #define CSEQ_GENOMIC_5SS(cseq,index) (cseq->data[(index)*CSEQ_G_LEN +2]) #define CSEQ_GENOMIC_3SS(cseq,index) (cseq->data[(index)*CSEQ_G_LEN +3]) #define CSEQ_GENOMIC_REPEAT(cseq,index) (cseq->data[(index)*CSEQ_G_LEN +4]) #define CSEQ_GENOMIC_CDSPOT(cseq,index) (cseq->data[(index)*CSEQ_G_LEN +5]) /*** for cDNA ***/ #define CSEQ_C_LEN 2 #define CSEQ_CDNA_BASE(cseq,index) (cseq->data[index*CSEQ_C_LEN]) #define CSEQ_CDNA_CODON(cseq,index) (cseq->data[index*CSEQ_C_LEN +1]) #define CSEQ_D_LEN 1 #define CSEQ_DNA_BASE(cseq,index) (cseq->data[index]) %} %{ #include "complexevalset.h" %func makes a new ComplexSequence from a Genomic sequence, using the repeat information to structure the positives and negatives. %% ComplexSequence * evaluate_ComplexSequence_Genomic(Genomic * gen,ComplexSequenceEvalSet * cses,int score_for_repeat,int score_for_cds_in_repeat) { int i,j; ComplexSequence * out; if( cses == NULL || cses->type != SEQUENCE_GENOMIC ) { warn("ComplexSequenceEvalSet is not valid for genomic!"); return NULL; } assert(gen); assert(gen->baseseq); assert(gen->baseseq->seq); out = new_ComplexSequence(gen->baseseq,cses); if( out == NULL ) { return NULL; } for(i=0;ilen;i++) { for(j=gen->repeat[i]->start;jrepeat[i]->end;j++) { if( j >= gen->baseseq->len ) { warn("Overran sequence - j position %d, sequence length %d on repeat %d",j,gen->baseseq->len,i); break; } CSEQ_GENOMIC_REPEAT(out,j) = score_for_repeat; CSEQ_GENOMIC_CDSPOT(out,j) = score_for_cds_in_repeat; } } /* for(i=0;ibaseseq->len;i++) fprintf(stderr,"At position %6d %d\n",CSEQ_GENOMIC_CDSPOT(out,j)); */ return out; } %func Makes a reasonably sensible genomic sequence eval set. Has base and codon numbers (what every good genomic sequence should do) and then /stupid_5SS and /stupid_3SS. Finally the repeat/EST regions modelled with the /flat_zero %arg %% ComplexSequenceEvalSet * default_genomic_ComplexSequenceEvalSet(void) { ComplexSequenceEvalSet * out; out = ComplexSequenceEvalSet_alloc_len(11); add_ComplexSequenceEvalSet(out,base_number_ComplexSequenceEval()); add_ComplexSequenceEvalSet(out,codon_number_ComplexSequenceEval()); add_ComplexSequenceEvalSet(out,stupid_5SS()); add_ComplexSequenceEvalSet(out,stupid_3SS()); add_ComplexSequenceEvalSet(out,flat_zero()); add_ComplexSequenceEvalSet(out,flat_zero()); out->type = SEQUENCE_GENOMIC; prepare_ComplexSequenceEvalSet(out); return out; } %func Makes a ComplexSequenceEval that puts NEGI everywhere %% ComplexSequenceEval * flat_negi(void) { ComplexSequenceEval * out; out= ComplexSequenceEval_alloc(); out->left_window = 0; out->right_window = 0; out->outside_score = NEGI; out->eval_func = flat_negi_eval; return out; } %func used by flat negi %type internal %% int flat_negi_eval(int type,void *data,char * seq) { return NEGI; } %func Makes a ComplexSequenceEval that puts 0 everywhere %arg %% ComplexSequenceEval * flat_zero(void) { ComplexSequenceEval * out; out= ComplexSequenceEval_alloc(); out->left_window = 0; out->right_window = 0; out->outside_score = NEGI; out->eval_func = flat_zero_eval; return out; } %func Used by /flat_zero as function actually called %type internal %arg %% int flat_zero_eval(int type,void *data,char * seq) { return 0; } %func Reasonably stupid 5'SS, of 0 at GT's and NEGI elsewhere. Pretends to have a longer footprint than it needs to satisify the lookbacks of more proper genomic models %arg %% ComplexSequenceEval * stupid_5SS(void) { ComplexSequenceEval * out; out= ComplexSequenceEval_alloc(); out->left_window = 3; out->right_window = 7; out->left_lookback = 8; out->outside_score = NEGI; out->eval_func = stupid_5SS_eval; return out; } %func Function which actually does the evaluation for 5'SS %type internal %arg %% int stupid_5SS_eval(int type,void *data,char * seq) { if( *(seq) == 'G' && *(seq+1) == 'T' ) return 0; else return NEGI; } %func Reasonably stupid 3'SS, of 0 at AG's and NEGI elsewhere. Pretends to have a longer footprint than it needs to satisify the lookbacks of more proper genomic models %arg %% ComplexSequenceEval * stupid_3SS(void) { ComplexSequenceEval * out; out= ComplexSequenceEval_alloc(); out->left_window = 3; out->right_window = 3; out->left_lookback = 5; out->outside_score = NEGI; out->eval_func = stupid_3SS_eval; return out; } %func Function which actually does the evaluation for 3'SS %type internal %arg %% int stupid_3SS_eval(int type,void *data,char * seq) { if( *(seq-1) == 'A' && *(seq) == 'G' ) return 0; else return NEGI; } /********************************/ /* cDNA and base stuff */ /********************************/ %func Makes a very sensible DNA sequence eval set. You shouldn't need your own %arg %% ComplexSequenceEvalSet * default_DNA_ComplexSequenceEvalSet(void) { ComplexSequenceEvalSet * out; out = ComplexSequenceEvalSet_alloc_len(1); add_ComplexSequenceEvalSet(out,base_number_ComplexSequenceEval()); out->type = SEQUENCE_DNA; prepare_ComplexSequenceEvalSet(out); return out; } %func Makes a very sensible cDNA sequence eval set. You shouldn't need your own %arg %% ComplexSequenceEvalSet * default_cDNA_ComplexSequenceEvalSet(void) { ComplexSequenceEvalSet * out; out = ComplexSequenceEvalSet_alloc_len(2); add_ComplexSequenceEvalSet(out,base_number_ComplexSequenceEval()); add_ComplexSequenceEvalSet(out,codon_number_ComplexSequenceEval()); out->type = SEQUENCE_CDNA; prepare_ComplexSequenceEvalSet(out); return out; } %func ComplexSequenceEval that puts a codon number in there (0-125 inc, 125 = impossible codon). %arg %% ComplexSequenceEval * codon_number_ComplexSequenceEval(void) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); if (out == NULL ) { return NULL; } out->left_window = 2; out->right_window = 0; out->outside_score = 125; out->eval_func = codon_number_func; return out; } %func Function which actually does the codon evaluation %type internal %arg %% int codon_number_func(int type,void * data,char * seq) { return codon_from_seq(seq-2); } %func Function which puts a 64 base codon... %% ComplexSequenceEval * codon64_number_ComplexSequenceEval(void) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); if (out == NULL ) { return NULL; } out->left_window = 2; out->right_window = 0; out->outside_score = 65; out->eval_func = codon64_number_func; return out; } %func Function which actually does the codon64 evaluation %type internal %arg %% int codon64_number_func(int type,void * data,char * seq) { int codon; if( !is_non_ambiguous_codon_seq(seq-2) ) { return 64; } codon = codon_from_seq(seq-2); return base4_codon_from_codon(codon); } %func ComplexSequenceEval that puts a base number (0-5 inc) %arg %% ComplexSequenceEval * base_number_ComplexSequenceEval(void) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); if (out == NULL ) { return NULL; } out->left_window = out->right_window = 0; out->eval_func = base_number_func; return out; } %func Function which actually does the evaluation bases %type internal %arg %% int base_number_func(int type,void * data,char * seq) { return base_from_char(*seq); } /***************************/ /* amino acid stuff */ /***************************/ %func Makes a very sensible protein sequence eval set. You shouldn't need your own %arg %% ComplexSequenceEvalSet * default_aminoacid_ComplexSequenceEvalSet(void) { ComplexSequenceEvalSet * out; out = ComplexSequenceEvalSet_alloc_len(1); add_ComplexSequenceEvalSet(out,aminoacid_number_ComplexSequenceEval()); out->type = SEQUENCE_PROTEIN; prepare_ComplexSequenceEvalSet(out); return out; } %func ComplexSequenceEval that puts a amino acid number in there (0-26) %arg %% ComplexSequenceEval * aminoacid_number_ComplexSequenceEval(void) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); if (out == NULL ) { return NULL; } out->left_window = out->right_window = 0; out->eval_func = aminoacid_number_func; return out; } %func Function which actually does the evaluation for aminoacids %type internal %arg %% int aminoacid_number_func(int type,void * data,char * seq) { return (int)(toupper((int)*seq)-'A'); } /***************************/ /* dna stuff */ /***************************/ %func Makes a very sensible dna sequence eval set. You shouldn't need your own %arg %% ComplexSequenceEvalSet * default_dna_ComplexSequenceEvalSet(void) { ComplexSequenceEvalSet * out; out = ComplexSequenceEvalSet_alloc_len(1); add_ComplexSequenceEvalSet(out,base_number_ComplexSequenceEval()); out->type = SEQUENCE_DNA; prepare_ComplexSequenceEvalSet(out); return out; } %} wise-2.4.1/src/dynlibsrc/sequence.dy0000644000175000001440000006551410345025225017010 0ustar philippusers %{ #include "wisebase.h" #include "codon.h" #ifdef LINUX #include "posix.h" #endif #define SEQUENCEBLOCK 8000 #define SEQUENCE_STARTSIZE 512 #define SEQUENCE_REALLOC_LINEAR (4096*4) enum SequenceType { SEQUENCE_UNKNOWN = 64, SEQUENCE_PROTEIN, SEQUENCE_DNA, SEQUENCE_CDNA, SEQUENCE_GENOMIC, SEQUENCE_EST, SEQUENCE_RNA }; #define is_dna_SequenceType(type) (type == SEQUENCE_DNA || type == SEQUENCE_CDNA || type == SEQUENCE_GENOMIC || type == SEQUENCE_EST ? TRUE : FALSE) #define is_rna_SequenceType(type) (type == SEQUENCE_RNA ? TRUE : FALSE) #define is_protein_SequenceType(type) (type == SEQUENCE_PROTEIN ? TRUE : FALSE ) #define is_dna_Sequence(seq) (is_dna_SequenceType(seq->type)) #define is_rna_Sequence(seq) (is_rna_SequenceType(seq->type)) #define is_protein_Sequence(seq) (is_protein_SequenceType(seq->type)) #define SequenceSetLISTLENGTH 64 %} struct Sequence char * name !def="NULL" // name of the sequence char * seq !def="NULL" // actual sequence int len; !def="0" // length of the sequence int maxlen; !def="0" // internal counter, indicating how much space in seq there is int offset; !def="1"; // start (in bio-coords) of the sequence. Not called start due to weird legacy. int end; !def="(-1)"; // end (in bio-coords == C coords) of the sequence char type; !def="SEQUENCE_UNKNOWN"; // guess of protein/dna type int tax_id !def="0" // taxonimic id of this double weight !def="1.0" char * desc !def="NULL" // description - often this will be NULL %info This object is the basic sequence object, trying to hold little more than the name and sequence of the DNA/protein. The len/maxlen is the actual length of the sequence (strlen(obj->seq)) and amount of memory allocated in obj->seq mainly for parsing purposes. %% struct SequenceSet Sequence ** set !list %info A list of sequences. Not a database (you should use the db stuff for that!). But useful anyway %% api object Sequence func uppercase_Sequence func force_to_dna_Sequence func is_reversed_Sequence func translate_Sequence func reverse_complement_Sequence func magic_trunc_Sequence func trunc_Sequence func read_fasta_file_Sequence func read_Sequence_EMBL_seq func read_fasta_Sequence func show_Sequence_residue_list func write_fasta_Sequence func make_len_type_Sequence des free_Sequence endobject object SequenceSet des free_SequenceSet endobject func Sequence_type_to_string func new_Sequence_from_strings endapi %{ #include "wisebase.h" #include "sequence.h" %func Makes a new sequence from strings given. Separate memory will be allocated for them and them copied into it. They can be NULL, in which case o a dummy name SequenceName will be assigned o No sequence placed and length of zero. Though this is dangerous later on. The sequence type is calculated automatically using /best_guess_type. If you want a DNA sequence but are unsure of the content of, for example, IUPAC codes, please use /force_to_dna_Sequence before using the sequence. Most of the rest of dynamite relies on a five letter A,T,G,C,N alphabet, but this function will allow any sequence type to be stored, so please check if you want to save yourself alot of grief. In perl and other interfaces, this is a much safer constructor than the raw "new" type %arg name r name of sequence, memory is allocated for it. seq r char * of sequence, memory is allocated for it. %% Sequence * new_Sequence_from_strings(char * name,char * seq) { Sequence * out; out = Sequence_alloc(); if( name == NULL) name = "SequenceName"; out->name = stringalloc(name); if( seq == NULL ) { out->seq = NULL; out->len = 0; return out; } out->seq = stringalloc(seq); out->len = strlen(out->seq); out->offset = 1; out->end = out->len; out->type = best_guess_type(out); return out; } %func Returns true if name looks like [A-Za-z]+[0-9]+ This should be an accession number %arg name r name to be tested %% boolean looks_like_accession(char * name) { char * run; for(run=name;*run && isalpha((int)*run);run++) ; if( *run == '\0') return FALSE; for(;*run && isalnum((int)*run) && !isalpha((int)*run);run++) ; if( *run == '\0') return TRUE; return FALSE; } %func makes seq->len and seq->end match the seq->seq length number. It also checks the type of the sequence with /best_guess_type %simple validate %arg seq rw Sequence object %% void make_len_type_Sequence(Sequence * seq) { seq->len = strlen(seq->seq); seq->end = seq->len + seq->offset -1; seq->type = best_guess_type(seq); } %func Guesses DNA or protein, by adding all the A,T,G,C up and if len < 300 && > 95% or len > 300 && > 75% then considers it to be DNA. NB - Ns now counted. %arg seq r Sequence to be guessed return o SEQUENCE_DNA or SEQUENCE_PROTEIN %% int best_guess_type(Sequence * seq) { register int i; int ch[26]; int no; int unplaced = 0; int total; for(i=0;i<26;i++) ch[i] = 0; for(i=0;ilen;i++) { /*fprintf(stderr,"character is %c and total is %d\n",seq->seq[i],unplaced);*/ if( (no=(int)( toupper(seq->seq[i])-'A')) > 26 || no < 0 ) unplaced++; else ch[no]++; } total = (ch['A' - 'A']+ch['T' - 'A'] + ch['G' - 'A'] + ch['C' - 'A'] + ch['N' - 'A']); if( seq->len < 300 ) { if( (double)total/(double)seq->len > 0.95 ) return SEQUENCE_DNA; else return SEQUENCE_PROTEIN; } else { if( (double)total/(double)seq->len > 0.75 ) return SEQUENCE_DNA; else return SEQUENCE_PROTEIN; } } %func Converts sequence type (SEQUENCE_*) to a string %arg type type eg SEQUENCE_PROTEIN %% char * Sequence_type_to_string(int type) { switch (type ) { case SEQUENCE_UNKNOWN : return "Unknown type"; case SEQUENCE_PROTEIN : return "Protein"; case SEQUENCE_DNA : return "Dna"; case SEQUENCE_CDNA : return "cDNA"; case SEQUENCE_GENOMIC : return "Genomic"; case SEQUENCE_EST : return "Est"; case SEQUENCE_RNA : return "RNA"; default : return "Undefined!"; } } %func makes all the sequence uppercase %simple uppercase %arg seq rw Sequence to be uppercased %% void uppercase_Sequence(Sequence * seq) { int i; for(i=0;ilen;i++) seq->seq[i] = toupper((int)seq->seq[i]); } %func This a) sees how many non ATGCN characters there are in Seq b) If the level is below fraction a) flips non ATGC chars to N b) writes number of conversions to number_of_conver c) returns TRUE c) else returns FALSE fraction of 0.0 means completely intolerant of errors fraction of 1.0 means completely tolerant of errors %simple force_to_dna %arg seq rw sequence object read and converted fraction r number 0..1 for tolerance of conversion number_of_conver wN number of conversions actually made return r TRUE for conversion to DNA, FALSE if not %% boolean force_to_dna_Sequence(Sequence * seq,double fraction,int * number_of_conver) { int count =0; int i; if( seq == NULL ) { warn("Attempting to force a sequence with no Sequence object!\n"); return FALSE; } if( seq->len <= 0 ) { warn("Trying to make a sequence with a length of %d. Bad news!",seq->len); return FALSE; } for(i=0;ilen;i++) { /* if it is lower case, uppercase it! */ seq->seq[i] = (char)toupper((int)seq->seq[i]); if( !is_valid_base_char(seq->seq[i]) ) { count++; } } if( ((double)count/(double)seq->len) < fraction ) { seq->type = SEQUENCE_DNA; if( count != 0 ) { for(i=0;ilen;i++) { if( !is_valid_base_char(seq->seq[i]) ) { seq->seq[i] = 'N'; } } } if( number_of_conver != NULL ) { *number_of_conver = count; } return TRUE; } else { if( number_of_conver != NULL ) { *number_of_conver = count; } return FALSE; } } %func Currently the sequence object stores reversed sequences as start > end. This tests that and returns true if it is %simple is_reversed %arg seq r sequence to test %% boolean is_reversed_Sequence(Sequence * seq) { if( seq->offset > seq->end) return TRUE; return FALSE; } %func This translates a DNA sequence to a protein. It assummes that it starts at first residue (use trunc_Sequence to chop a sequence up). %simple translate %arg dna r DNA sequence to be translated ct r Codon table to do codon->aa mapping return o new protein sequence %% Sequence * translate_Sequence(Sequence * dna,CodonTable * ct) { Sequence * out; int i; int j; int len; char * seq; char * name; char buffer[512]; if( is_dna_Sequence(dna) == FALSE) { warn("Trying to make a translation from a non DNA sequence... type is [%s]",Sequence_type_to_string(dna->type)); return NULL; } len = dna->len/3 + 1; seq = ckcalloc(len,sizeof(char)); sprintf(buffer,"%s.tr",dna->name == NULL ? "NoNameDNASeq" : dna->name); name = stringalloc(buffer); out = Sequence_from_dynamic_memory(name,seq); for(i=0,j=0;ilen-3;i+=3,j++) { out->seq[j] = aminoacid_from_seq(ct,dna->seq+i); } out->seq[j] = '\0'; out->type = SEQUENCE_PROTEIN; out->len = strlen(out->seq); return out; } %func This both complements and reverses a sequence, - a common wish! The start/end are correct with respect to the start/end of the sequence (ie start = end, end = start). %simple revcomp %arg seq r Sequence to that is used to reverse (makes a new Sequence) return o new Sequence which is reversed %% Sequence * reverse_complement_Sequence(Sequence * seq) { Sequence * out; int i; int j; if( is_dna_Sequence(seq) != TRUE ) { warn("Cannot reverse complement non-DNA sequence... type is %s",Sequence_type_to_string(seq->type)); return NULL; } out = Sequence_from_static_memory(seq->name,seq->seq); for(j=0,i=seq->len-1;i >= 0;i--,j++) { if( seq->seq[i] == '.' || seq->seq[i] == '-' ) { out->seq[j] = seq->seq[i]; } else { out->seq[j] = char_complement_base(seq->seq[i]); } /*fprintf(stderr,"In position %d placed %c from %c\n",j,out->seq[j],seq->seq[i]);*/ } out->len = strlen(seq->seq); out->offset = seq->end; out->end = seq->offset; out->type = seq->type; return out; } %func Clever function for dna sequences. When start < end, truncates normally when start > end, truncates end,start and then reverse complements. ie. If you have a coordinate system where reverse sequences are labelled in reverse start/end way, then this routine produces the correct sequence. %simple magic_trunc %arg seq r sequence that is the source to be truncated start r start point end r end point return o new Sequence which is truncated/reversed %% Sequence * magic_trunc_Sequence(Sequence * seq,int start,int end) { Sequence * temp; Sequence * out; if( is_dna_Sequence(seq) == FALSE) { warn("Cannot magic truncate on a non DNA sequence... type is %s",Sequence_type_to_string(seq->type)); return NULL; } if( start < 0 || end < 0 ) { warn("Attempting a magic truncation on indices which are less than zero [%d:%d]. Clearly impossible",start,end); return NULL; } if( start < end ) { return trunc_Sequence(seq,start,end); } else { temp = trunc_Sequence(seq,end,start); if( temp == NULL ) { warn("Unable to truncate sequence"); return NULL; } out = reverse_complement_Sequence(temp); free_Sequence(temp); return out; } } %func truncates a sequence. It produces a new memory structure which is filled from sequence start to end. Please notice Truncation is in C coordinates. That is the first residue is 0 and end is the number of the residue after the cut-point. In otherwords to 2 - 3 would be a single residue truncation. So - if you want to work in more usual, 'inclusive' molecular biology numbers, which start at 1, then you need to say trunc_Sequence(seq,start-1,end); (NB, should be (end - 1 + 1) = end for the last coordinate). Truncation occurs against the *absolute* coordinate system of the Sequence, not the offset/end pair inside. So, this is a very bad error ** wrong code, and also leaks memory ** tru = trunc_Sequence(trunc_Sequence(seq,50,80),55,75); This the most portable way of doing this temp = trunc_Sequence(seq,50,80); tru = trunc_Sequence(temp,55-temp->offset,75-temp->offset); free_Sequence(temp); %simple trunc %arg seq r object holding the sequence to be truncated start r start point of truncation end r end point of truncation return o newly allocated sequence structure %% Sequence * trunc_Sequence(Sequence * seq,int start,int end) { char * name; char * seqb; Sequence * out; if( start < 0 || end < 0 ) { warn("Attempting a truncation on indices which are less than zero [%d:%d]. Clearly impossible",start,end); return NULL; } if( end <= start ) { warn("Trying to truncate Sequence from %d - %d",start,end); return NULL; } if( end > seq->len ) { warn("Trying to truncate Sequecne %s from %d - %d when length is %d", seq->name,start,end,seq->len); return NULL; } name = stringalloc(seq->name); seqb = (char *) ckcalloc(end-start+1,sizeof(char)); memcpy(seqb,seq->seq+start,(end-start)); seqb[end-start] = '\0'; out = Sequence_from_dynamic_memory(name,seqb); out->len = strlen(out->seq); out->type = seq->type; out->offset = seq->offset+start; out->end = seq->offset + end-1; return out; } %func A function for you to easily specify the sequence name and the database separately. Just concatonates the two strings with : betwqeen them. Therefore you should use "swisprot-id" for example as your datastring. calls /read_SRS_Sequence %arg datastring r string representing the database (swissprot-id) srsstring r string for the name (eg, ROA1_HUMAN) %% Sequence * read_SRS_db_Sequence(char * datastring,char * srsstring) { char buffer[256]; sprintf(buffer,"%s:%s",datastring,srsstring); return read_SRS_Sequence(buffer); } %func reads SRS specified sequence. calls popoen with getz -f using srs4 syntax. Will only read the first sequence if there is more than one in the SRS spec, and does not warn you about additional sequences %arg srsstring r srs spec'd string swissprot-id:ROA1_HUMAN %% Sequence * read_SRS_Sequence(char * srsstring) { FILE * pipe; char buffer[MAXLINE]; Sequence * out; sprintf(buffer,"getz -d '[%s]' ",srsstring); pipe = popen(buffer,"r"); if ( pipe == NULL ) { warn("Could not open %s as an SRS database string - probably no getz",srsstring); return NULL; } out = read_fasta_Sequence(pipe); pclose(pipe); return out; } %func reads efetch specificed sequence. calls popen to efetch. A hack around accession numbers so that if the thing looks like WP:acc number, calls it with -a... otherwise assummes you have both database and name in the efetchstring %arg efetchstring r efetch valid string %% Sequence * read_efetch_Sequence(char * efetchstring) { FILE * pf; Sequence * out; char buffer[MAXLINE]; if( strstartcmp(efetchstring,"WP:") != 0 && looks_like_accession(efetchstring+3) == TRUE) { sprintf(buffer,"efetch -f -a %s",efetchstring); } else { sprintf(buffer,"efetch -f %s",efetchstring); } pf = popen(buffer,"r"); if( pf == NULL ) { warn("Could not open efetch pipe with [%s]",efetchstring); return NULL; } out = read_fasta_Sequence(pf); pclose(pf); return out; } %func Just a call a) open filename b) read sequence with /read_fasta_Sequence c) close file. %arg filename r filename to open %% Sequence * read_fasta_file_Sequence(char * filename) { Sequence * out; FILE * ifp; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Cannot open %s for read_fasta_file",filename); return NULL; } out = read_fasta_Sequence(ifp); fclose(ifp); return out; } %func reads the sequence part of an EMBL file. This function can either take a file which starts %arg ifp r input file to read from buffer rw buffer containing the first line. maxlen r length of buffer %% Sequence * read_Sequence_EMBL_seq(char * buffer,int maxlen,FILE * ifp) { Sequence * out; char seqbuffer[SEQUENCEBLOCK]; int i = 0; signed char c; if( !isalpha((int)*buffer) ) { warn("I don't like this - got a buffer of [%s] in reading an EMBL sequence section",buffer); } do { if( strstartcmp(buffer,"SQ") == 0 ) { break; } } while ( fgets(buffer,maxlen,ifp) != NULL); out = empty_Sequence_from_dynamic_memory(stringalloc("EMBLseq")); while( (c=fgetc(ifp)) != EOF ) { if( c == '/' && (c=fgetc(ifp)) == '/') break; /*** ugly perhaps. what about single / lines? ***/ if( isalpha(c) ) seqbuffer[i++] = c; if( i > SEQUENCEBLOCK-2) { seqbuffer[i] = '\0'; if( add_string_to_Sequence(out,seqbuffer) == FALSE ) { warn("Could not read full sequence of %s - returning\n",out->name); return out; } i = 0; } } /* ok have to now put away final buffer read! */ seqbuffer[i] = '\0'; add_string_to_Sequence(out,seqbuffer); /** add back > if need be **/ if( feof(ifp) || c != '/' ) { warn("In parsing an EMBL file got an poor ending of a sequence region"); } else { while( (c=fgetc(ifp)) != '\n' && c != EOF ) ; } make_len_type_Sequence(out); return out; } %func reads a fasta file assumming pretty standard sanity for the file layout %% Sequence * read_fasta_Sequence(FILE * ifp) { char buffer[MAXLINE]; char c; /* we need to do a nasty fgetc/ungetc to detect whether we have ended */ char seqbuffer[SEQUENCEBLOCK]; int i = 0; int j; int tax_id = -1; double weight = 1.0; boolean seen_weight = 0; char * temp; char * desc; char * name; Sequence * out; /* first line is '>' */ if( fgets(buffer,MAXLINE,ifp) == NULL ) { return NULL; } if( buffer[strlen(buffer)-1] != '\n' ) { /* excessive description line */ while( (c=fgetc(ifp)) != '\n' && c != EOF ) { ; } if( c == EOF ) { warn("In sequence file, overead line into end of file. Exiting"); return NULL; } } if( (temp = strstr(buffer,"tax_id=")) != NULL ) { tax_id = atoi(temp+strlen("tax_id=")); } if( (temp = strstr(buffer,"weight=")) != NULL ) { weight = atof(temp+strlen("weight=")); } if( buffer[0] == '/' && buffer[1] == '/' ) { /* silent exit as if EOF */ return NULL; } if( buffer[0] != '>' ) { warn("First character read not >, assumming is not fasta"); return NULL; } /* some annoying formats have >\s+\S+ ... Grrrr! */ for(i=1,name=buffer+1;*name && isspace(*name);name++,i++) ; /* now delimit this point */ for(;!isspace(buffer[i]);i++) ; buffer[i] = '\0'; /* now find description line if here */ for(i++;isspace(buffer[i]) && buffer[i] != '\0';i++) { ; } if( buffer[i] != '\0' ) { desc = buffer+i; for(i++;buffer[i] != '\0' && buffer[i] != '\n';i++) { ; } buffer[i] = '\0'; } else { desc = NULL; } out = empty_Sequence_from_dynamic_memory(stringalloc(name)); if( desc != NULL ){ out->desc = stringalloc(desc); } out->tax_id = tax_id; out->weight = weight; i =0; while( 1 ) { i =0; /* get/ungetc to see if we should read this line */ c = fgetc(ifp); if( c == EOF || c == '>' || c == '/') { break; } seqbuffer[i++] = c; /* get the rest of the line */ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Strangely truncated line in fasta file"); break; } /*fprintf(stderr,"Getting into while loop.. with [%s]\n",buffer); */ for(j=0;buffer[j] != '\0';j++) { if( isalpha(buffer[j]) || buffer[j] == '-' || buffer[j] == '.' || buffer[j] == '~' ) seqbuffer[i++] = buffer[j]; } seqbuffer[i] = '\0'; if( add_string_to_Sequence(out,seqbuffer) == FALSE ) { warn("Could not read full sequence of %s - returning\n",out->name); return out; } } /* ok have to now put away final buffer read! */ seqbuffer[i] = '\0'; add_string_to_Sequence(out,seqbuffer); /* end of file or '>' or '/' */ if( c == '>' || c == '/' ) ungetc(c,ifp); make_len_type_Sequence(out); return out; } %func reads the fasta file: format is >name sequence allocates a structure and puts in the sequence. Calls /make_len_type_Sequence to check type and length. It leaves the '>' on the next fasta sequence for multiple sequence reading %arg ifp r input file to read from return o new Sequence structure %% Sequence * read_old_fasta_Sequence(FILE * ifp) { Sequence * out; char seqbuffer[SEQUENCEBLOCK]; int i = 0; signed char c = EOF; if( feof(ifp) ) { /* fail silently */ return NULL; } while( (c=fgetc(ifp)) != EOF && isspace(c)) ; if( feof(ifp) ) return NULL; if( c != '>' ) { warn("First letter read is not '>' - assumming it is not a fasta stream"); return NULL; } if( c == EOF || feof(ifp) ) return NULL; /*** ok = got to > ****/ /*** read in name ****/ while( !isspace(c=fgetc(ifp)) && c != EOF) seqbuffer[i++]=c; if( c == EOF) return NULL; seqbuffer[i]='\0'; /*** name now in sequence buffer - make sequence ***/ out = empty_Sequence_from_dynamic_memory(stringalloc(seqbuffer)); if( out == NULL ) return NULL; /*** ok, suck in the rest of this line if necessary (ie something else on the 1st line) ***/ while( c != EOF && c != '\n' ) c=fgetc(ifp); /*** now read in sequence ***/ for(i=0; !feof(ifp) && (c=fgetc(ifp)) != '>' && c != EOF;) { if( isalpha(c) || c == '-' || c == '.' || c == '~' ) seqbuffer[i++] = c; if( i > SEQUENCEBLOCK-2) { seqbuffer[i] = '\0'; if( add_string_to_Sequence(out,seqbuffer) == FALSE ) { warn("Could not read full sequence of %s - returning\n",out->name); return out; } i = 0; } } /* ok have to now put away final buffer read! */ seqbuffer[i] = '\0'; add_string_to_Sequence(out,seqbuffer); /** add back > if need be **/ if( c == '>' ) ungetc(c,ifp); make_len_type_Sequence(out); return out; } %func shows a region of a sequence as 124 A 125 T etc from start to end. The numbers are in C coordinates (ie, 0 is the first letter). useful for debugging %simple show_debug %arg seq r Sequence to show start r start of list end r end of list %% void show_Sequence_residue_list(Sequence * seq,int start,int end,FILE * ofp) { int i; for(i=start;iseq[i]); } } %func New add_string_to_Sequence which should be much better at handling memory update %% boolean add_string_to_Sequence(Sequence * seq,char * more) { int strl; assert(seq); assert(more); assert(seq->maxlen > 0); strl = strlen(more); if( (seq->len + strl) > (seq->maxlen -2) ) { if( seq->maxlen < SEQUENCE_REALLOC_LINEAR ) { seq->seq = realloc( seq->seq,seq->maxlen*2); seq->maxlen = seq->maxlen *2; } else { seq->seq = realloc( seq->seq,seq->maxlen + SEQUENCE_REALLOC_LINEAR ); seq->maxlen = seq->maxlen + SEQUENCE_REALLOC_LINEAR; } } assert(seq->seq); strcat(seq->seq,more); seq->len = strlen(seq->seq); return TRUE; } %func Dodgy function. This is meant to add the more sequence to seq (into ->seq). Not sure how stable this is. In theory it reallocates memory on the basis of ->maxlen. %type internal %arg seq Sequence to add sequence to more pointer to sequence to add return TRUE if successful, FALSE if not %% boolean add_string_to_Sequence_old(Sequence * seq,char * more) { register int len; register int blocklen; void * temp; len = strlen(more)+1; if( len < seq->maxlen - seq->len ) { /*** ok can add to this block! ****/ strcat(seq->seq,more); seq->len = strlen(seq->seq); return TRUE; } /*** nope - need to realloc ****/ len -= (seq->maxlen - seq->len); /* amount that needs to be realloc'd */ blocklen = 1 + (int)(len / SEQUENCEBLOCK); /* number of blocks */ blocklen *= SEQUENCEBLOCK; /* make that into bytes */ blocklen += seq->maxlen; /* final size of string */ temp = ckrealloc ( seq->seq,blocklen); if( temp == NULL ) { warn("Sequence block error for sequence %s on blocklen %d\n",CKS(seq->name),blocklen); return FALSE; } seq->seq = (char *) temp; /* realloc moves the memory for us as well */ seq->maxlen = blocklen; /*** copy in string ****/ strcat(seq->seq,more); seq->len = strlen(seq->seq); return TRUE; } %func Only allocates sequence structure and name %% Sequence * empty_Sequence_from_dynamic_memory(char * name) { Sequence * out; out = Sequence_alloc(); if( out == NULL ) return NULL; if( name == NULL ) { warn("Attempting to make an empty sequence with no name: assigning dummy name"); name = stringalloc("DummyName"); } out->name = name; out->seq = (char *) ckcalloc (SEQUENCE_STARTSIZE,sizeof(char)); out->maxlen = SEQUENCE_STARTSIZE; out->len = 0; return out; } %func allocates sequence structure with enough length in char for len sequence. %arg len r length of blank sequene space %% Sequence * Sequence_alloc_len(int len) { Sequence * out; out = Sequence_alloc(); if( out == NULL) return NULL; out->seq = (char *) ckcalloc (len,sizeof(char)); out->maxlen = out->len = len; return out; } %func Allocates the sequence structure and memory for name and seq, copies them in. %type internal %% Sequence * Sequence_from_static_memory (char * name,char * seq) { return Sequence_from_dynamic_memory(stringalloc(name),stringalloc(seq)); } %func Allocates the sequence structure and simple attaches name and seq to the correct places %type internal %arg name name of sequence seq a char * to correct sequence %% Sequence * Sequence_from_dynamic_memory(char * name,char * seq) { Sequence * out; if( seq == NULL) { warn("Cannot make a sequence with no sequence!"); return NULL; } if( name == NULL ) { warn("You are attempting to make a sequence with no name - assigning dummy name"); name = stringalloc ("DummyName"); } out = Sequence_alloc(); if( out == NULL) return out; out->name = name; out->seq = seq; out->maxlen = out->len = strlen(seq); return out; } %func writes a fasta file of the form >name Sequence %simple write_fasta %arg seq r sequence to be written ofp file to write to %% void write_fasta_Sequence(Sequence * seq,FILE * ofp) { assert(seq); fprintf(ofp,">%s\n",seq->name == NULL ? "NoName_Null_string" : seq->name ); show_line(seq->seq,60,ofp); } %func reads a fasta file as a sequence set %% SequenceSet * read_fasta_SequenceSet(FILE * ifp) { SequenceSet * out; Sequence * in; out = SequenceSet_alloc_std(); while( (in = read_fasta_Sequence(ifp)) != NULL ) { add_SequenceSet(out,in); } return out; } %func opens file and reads in sequence set %% SequenceSet * read_fasta_SequenceSet_file(char * filename) { SequenceSet * out; FILE * ifp; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s as a file",filename); return NULL; } out = read_fasta_SequenceSet(ifp); fclose(ifp); return out; } %} wise-2.4.1/src/dynlibsrc/sequence.xs0000644000175000001440000001521210670453713017024 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::Sequence void uppercase(seq) Wise2_Sequence * seq CODE: Wise2_uppercase_Sequence(seq); boolean force_to_dna(seq,fraction) Wise2_Sequence * seq double fraction CODE: RETVAL = Wise2_force_to_dna_Sequence(seq,fraction,NULL); OUTPUT: RETVAL boolean is_reversed(seq) Wise2_Sequence * seq CODE: RETVAL = Wise2_is_reversed_Sequence(seq); OUTPUT: RETVAL Wise2_Sequence * translate(dna,ct) Wise2_Sequence * dna Wise2_CodonTable * ct CODE: RETVAL = Wise2_translate_Sequence(dna,ct); OUTPUT: RETVAL Wise2_Sequence * revcomp(seq) Wise2_Sequence * seq CODE: RETVAL = Wise2_reverse_complement_Sequence(seq); OUTPUT: RETVAL Wise2_Sequence * magic_trunc(seq,start,end) Wise2_Sequence * seq int start int end CODE: RETVAL = Wise2_magic_trunc_Sequence(seq,start,end); OUTPUT: RETVAL Wise2_Sequence * trunc(seq,start,end) Wise2_Sequence * seq int start int end CODE: RETVAL = Wise2_trunc_Sequence(seq,start,end); OUTPUT: RETVAL Wise2_Sequence * read_fasta_file_Sequence(filename) char * filename CODE: RETVAL = Wise2_read_fasta_file_Sequence(filename); OUTPUT: RETVAL Wise2_Sequence * read_Sequence_EMBL_seq(buffer,maxlen,ifp) char * buffer int maxlen FILE * ifp CODE: RETVAL = Wise2_read_Sequence_EMBL_seq(buffer,maxlen,ifp); OUTPUT: RETVAL Wise2_Sequence * read_fasta_Sequence(ifp) FILE * ifp CODE: RETVAL = Wise2_read_fasta_Sequence(ifp); OUTPUT: RETVAL void show_debug(seq,start,end,ofp) Wise2_Sequence * seq int start int end FILE * ofp CODE: Wise2_show_Sequence_residue_list(seq,start,end,ofp); void write_fasta(seq,ofp) Wise2_Sequence * seq FILE * ofp CODE: Wise2_write_fasta_Sequence(seq,ofp); void validate(seq) Wise2_Sequence * seq CODE: Wise2_make_len_type_Sequence(seq); Wise2_Sequence * hard_link_Sequence(obj) Wise2_Sequence * obj CODE: RETVAL = Wise2_hard_link_Sequence(obj); OUTPUT: RETVAL Wise2_Sequence * alloc() CODE: RETVAL = Wise2_Sequence_alloc(); OUTPUT: RETVAL boolean set_name(obj,name) Wise2_Sequence * obj char * name CODE: RETVAL = Wise2_replace_name_Sequence(obj,Wise2_stringalloc(name)); OUTPUT: RETVAL char * name(obj) Wise2_Sequence * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_name_Sequence(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_seq(obj,seq) Wise2_Sequence * obj char * seq CODE: RETVAL = Wise2_replace_seq_Sequence(obj,Wise2_stringalloc(seq)); OUTPUT: RETVAL char * seq(obj) Wise2_Sequence * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_seq_Sequence(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_len(obj,len) Wise2_Sequence * obj int len CODE: RETVAL = Wise2_replace_len_Sequence(obj,len); OUTPUT: RETVAL int len(obj) Wise2_Sequence * obj CODE: RETVAL = Wise2_access_len_Sequence(obj); OUTPUT: RETVAL boolean set_maxlen(obj,maxlen) Wise2_Sequence * obj int maxlen CODE: RETVAL = Wise2_replace_maxlen_Sequence(obj,maxlen); OUTPUT: RETVAL int maxlen(obj) Wise2_Sequence * obj CODE: RETVAL = Wise2_access_maxlen_Sequence(obj); OUTPUT: RETVAL boolean set_offset(obj,offset) Wise2_Sequence * obj int offset CODE: RETVAL = Wise2_replace_offset_Sequence(obj,offset); OUTPUT: RETVAL int offset(obj) Wise2_Sequence * obj CODE: RETVAL = Wise2_access_offset_Sequence(obj); OUTPUT: RETVAL boolean set_end(obj,end) Wise2_Sequence * obj int end CODE: RETVAL = Wise2_replace_end_Sequence(obj,end); OUTPUT: RETVAL int end(obj) Wise2_Sequence * obj CODE: RETVAL = Wise2_access_end_Sequence(obj); OUTPUT: RETVAL boolean set_type(obj,type) Wise2_Sequence * obj char type CODE: RETVAL = Wise2_replace_type_Sequence(obj,type); OUTPUT: RETVAL char type(obj) Wise2_Sequence * obj CODE: RETVAL = Wise2_access_type_Sequence(obj); OUTPUT: RETVAL boolean set_tax_id(obj,tax_id) Wise2_Sequence * obj int tax_id CODE: RETVAL = Wise2_replace_tax_id_Sequence(obj,tax_id); OUTPUT: RETVAL int tax_id(obj) Wise2_Sequence * obj CODE: RETVAL = Wise2_access_tax_id_Sequence(obj); OUTPUT: RETVAL boolean set_weight(obj,weight) Wise2_Sequence * obj double weight CODE: RETVAL = Wise2_replace_weight_Sequence(obj,weight); OUTPUT: RETVAL double weight(obj) Wise2_Sequence * obj CODE: RETVAL = Wise2_access_weight_Sequence(obj); OUTPUT: RETVAL boolean set_desc(obj,desc) Wise2_Sequence * obj char * desc CODE: RETVAL = Wise2_replace_desc_Sequence(obj,Wise2_stringalloc(desc)); OUTPUT: RETVAL char * desc(obj) Wise2_Sequence * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_desc_Sequence(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_Sequence * new(class) char * class PPCODE: Wise2_Sequence * out; out = Wise2_Sequence_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_Sequence * obj CODE: Wise2_free_Sequence(obj); MODULE = Wise2 PACKAGE = Wise2::SequenceSet Wise2_SequenceSet * hard_link_SequenceSet(obj) Wise2_SequenceSet * obj CODE: RETVAL = Wise2_hard_link_SequenceSet(obj); OUTPUT: RETVAL Wise2_SequenceSet * SequenceSet_alloc_std() CODE: RETVAL = Wise2_SequenceSet_alloc_std(); OUTPUT: RETVAL Wise2_Sequence * set(obj,i) Wise2_SequenceSet * obj int i INIT: Wise2_Sequence * temp; CODE: temp = Wise2_hard_link_Sequence(Wise2_access_set_SequenceSet(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_set(obj) Wise2_SequenceSet * obj CODE: RETVAL = Wise2_length_set_SequenceSet(obj); OUTPUT: RETVAL int flush_set(obj) Wise2_SequenceSet * obj CODE: RETVAL = Wise2_flush_SequenceSet(obj); OUTPUT: RETVAL boolean add_set(obj,add) Wise2_SequenceSet * obj Wise2_Sequence * add CODE: RETVAL = Wise2_add_SequenceSet(obj,Wise2_hard_link_Sequence(add)); OUTPUT: RETVAL Wise2_SequenceSet * new(class) char * class PPCODE: Wise2_SequenceSet * out; out = Wise2_SequenceSet_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_SequenceSet * obj CODE: Wise2_free_SequenceSet(obj); void each_set(obj) Wise2_SequenceSet * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_set_SequenceSet(obj); for(i=0;ilen;i++) { free_Sequence(sli->seq_store[i]); } (*sli->free_data)(sli->data); ckfree(sli); return NULL; } /* Function: load_SequenceDB_SeqLookupLoadPara(p,db,sli) * * Descrip: Loads a SequenceDB into a hash on the basis of the SeqLookupLoadPara * * returns the number of sequences loaded * * * Arg: p [UNKN ] Undocumented argument [SeqLookupLoadPara *] * Arg: db [UNKN ] Undocumented argument [SequenceDB *] * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * * Return [UNKN ] Undocumented return value [int] * */ # line 137 "seqlookup.dy" int load_SequenceDB_SeqLookupLoadPara(SeqLookupLoadPara * p,SequenceDB * db,SeqLookupInterface * sli) { int ret; int c; int i; Sequence * seq; int base[5]; int start_base; int char_count = 0; for(i=0,start_base=1;i<5;i++) { base[i] = start_base; start_base = start_base * 26; } for(c=0,seq = init_SequenceDB(db,&ret); seq != NULL;seq = get_next_SequenceDB(db) ) { /* don't have to hardlink and then also free - just store here */ c++; if( p->start_seq_load >= 0 && c-1 < p->start_seq_load ) { continue; } if( p->end_seq_load >= 0 && c-1 >= p->end_seq_load ) { break; } add_SeqLookupInterface(sli,seq); if( p->report_stagger >= 1 && c % p->report_stagger == 0 ) { info("Loaded %d sequences (%d characters, %.2f)... at %s\n",c,char_count,(double)char_count/(double)p->report_stagger,seq->name); char_count = 0; } char_count += seq->len; (*sli->add_seq)(sli->data,seq,p); if( p->truncate != 0 && c == p->truncate ) { info("Asked to truncate load after %d sequences\n",p->truncate); break; } } return c; } /* Function: show_help_SeqLookupLoadPara(ofp) * * Descrip: Shows help associated with Sequence loading * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 196 "seqlookup.dy" void show_help_SeqLookupLoadPara(FILE * ofp) { fprintf(ofp,"Sequence Index Loading parameters\n"); fprintf(ofp," -seqloadtile tiling skip of load (default 1)\n"); fprintf(ofp," -seqloadreport report (using info) at what stagger rating (default none)\n"); fprintf(ofp," -seqloadtrunc truncate load after this number of sequeneces (useful for debugging)\n"); fprintf(ofp," -seqloadstart start position in database for seq load\n"); fprintf(ofp," -seqloadend end position in database for seq load\n"); fprintf(ofp," -[no]seqloadlow mark low complexity words for use with low complexity numbing\n"); return; } /* Function: new_SeqLookupLoadPara_from_argv(argc,argv) * * Descrip: Builds new SeqLookup load from a command line * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [SeqLookupLoadPara *] * */ # line 212 "seqlookup.dy" SeqLookupLoadPara * new_SeqLookupLoadPara_from_argv(int * argc,char ** argv) { SeqLookupLoadPara * out; out = SeqLookupLoadPara_alloc(); out->mark_low_complexity = 1; out->start_seq_load = -1; out->end_seq_load = -1; strip_out_integer_argument(argc,argv,"seqloadtile",&out->tile_freq); strip_out_integer_argument(argc,argv,"seqloadreport",&out->report_stagger); strip_out_integer_argument(argc,argv,"seqloadtrunc",&out->truncate); strip_out_integer_argument(argc,argv,"seqloadstart",&out->start_seq_load); strip_out_integer_argument(argc,argv,"seqloadend",&out->end_seq_load); strip_out_boolean_def_argument(argc,argv,"seqloadlow",&out->mark_low_complexity); return out; } /* Function: seq_number_dna_15mer_noN(seq) * * Descrip: Function for DNA sequence to number on 15mers, * Ns get mapped to -1 * * * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 243 "seqlookup.dy" int seq_number_dna_15mer_noN(char * seq) { int i; int ret = 0; int base = 1; int no = 0; for(i=0;i<15;i++) { no = base_from_char(seq[i]); if( no == BASE_N ) { return -1; } ret += base * no; base = base * 4; } return ret; } /* Function: seq_number_dna_7mer_noN(seq) * * Descrip: Function for DNA sequence to number on 15mers, * Ns get mapped to -1 * * * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 269 "seqlookup.dy" int seq_number_dna_7mer_noN(char * seq) { int i; int ret = 0; int base = 1; int no = 0; for(i=0;i<7;i++) { no = base_from_char(seq[i]); if( no == BASE_N ) { return -1; } ret += base * no; base = base * 4; } return ret; } /* Function: seq_number_aa_5mer(seq) * * Descrip: Function for the amino acid to number on 5mers * * * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 294 "seqlookup.dy" int seq_number_aa_5mer(char * seq) { int i; int ret = 0; int base = 1; int no = 0; for(i=0;i<5;i++) { no = toupper(seq[i])-'A'; if( no > 26 || no < 0 ) { no = 'X'-'A'; } ret += base * no; base = base * 26; } return ret; } /* Function: flags_from_5aa_sequence(seq) * * Descrip: returns simple lowcomplexity flag or * not for this sequence * * * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char] * */ # line 317 "seqlookup.dy" char flags_from_5aa_sequence(char * seq) { int count = 0; if( seq[0] != seq[1] ) { count++; } if( seq[1] != seq[2] ) { count++; } if( seq[2] != seq[3] ) { count++; } if( seq[3] != seq[4] ) { count++; } if( seq[4] != seq[0] ) { count++; } if( count < 3 ) { return SEQLOOKUP_LOWCOMPLEXITY; } else { return 0; } } /* Function: free_SeqLookupClientInterface(sli) * * Descrip: Frees SeqLookupClientInterface - overrides dynamite default * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupClientInterface *] * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ # line 349 "seqlookup.dy" SeqLookupClientInterface * free_SeqLookupClientInterface(SeqLookupClientInterface * sli) { if( sli == NULL ) { return NULL; } (*sli->free_data)(sli->data); ckfree(sli); return NULL; } /* Function: free_SeqLookupResultInterface(sli) * * Descrip: Frees SeqLookupResultInterface - overrides dynamite default * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupResultInterface *] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ # line 366 "seqlookup.dy" SeqLookupResultInterface * free_SeqLookupResultInterface(SeqLookupResultInterface * sli) { if( sli == NULL ) { return NULL; } /* fprintf(stderr,"Freeing results interface\n"); */ (*sli->free_data)(sli->data); return NULL; } # line 340 "seqlookup.c" /* Function: hard_link_SeqLookupResultInterface(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupResultInterface *] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ SeqLookupResultInterface * hard_link_SeqLookupResultInterface(SeqLookupResultInterface * obj) { if( obj == NULL ) { warn("Trying to hard link to a SeqLookupResultInterface object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SeqLookupResultInterface_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ SeqLookupResultInterface * SeqLookupResultInterface_alloc(void) { SeqLookupResultInterface * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SeqLookupResultInterface *) ckalloc (sizeof(SeqLookupResultInterface))) == NULL) { warn("SeqLookupResultInterface_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->next = NULL; out->is_more = NULL; out->free_data = NULL; return out; } /* Function: hard_link_SeqLookupClientInterface(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupClientInterface *] * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ SeqLookupClientInterface * hard_link_SeqLookupClientInterface(SeqLookupClientInterface * obj) { if( obj == NULL ) { warn("Trying to hard link to a SeqLookupClientInterface object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SeqLookupClientInterface_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ SeqLookupClientInterface * SeqLookupClientInterface_alloc(void) { SeqLookupClientInterface * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SeqLookupClientInterface *) ckalloc (sizeof(SeqLookupClientInterface))) == NULL) { warn("SeqLookupClientInterface_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->lookup = NULL; out->is_populated = NULL; out->free_data = NULL; return out; } /* Function: hard_link_SeqLookupLoadPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [SeqLookupLoadPara *] * */ SeqLookupLoadPara * hard_link_SeqLookupLoadPara(SeqLookupLoadPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a SeqLookupLoadPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SeqLookupLoadPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupLoadPara *] * */ SeqLookupLoadPara * SeqLookupLoadPara_alloc(void) { SeqLookupLoadPara * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SeqLookupLoadPara *) ckalloc (sizeof(SeqLookupLoadPara))) == NULL) { warn("SeqLookupLoadPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = SeqLookupLoad_Protein; out->tile_freq = 1; out->report_stagger = 0; out->truncate = 0; out->mark_low_complexity = 1; out->start_seq_load = -1; out->end_seq_load = -1; return out; } /* Function: free_SeqLookupLoadPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [SeqLookupLoadPara *] * */ SeqLookupLoadPara * free_SeqLookupLoadPara(SeqLookupLoadPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SeqLookupLoadPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_SeqLookupInterface(list,i,j) * * Descrip: swap function: an internal for qsort_SeqLookupInterface * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Sequence **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SeqLookupInterface(Sequence ** list,int i,int j) { Sequence * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SeqLookupInterface(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SeqLookupInterface which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Sequence **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SeqLookupInterface(Sequence ** list,int left,int right,int (*comp)(Sequence * ,Sequence * )) { int i,last; if( left >= right ) return; swap_SeqLookupInterface(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SeqLookupInterface (list,++last,i); } swap_SeqLookupInterface (list,left,last); qsort_SeqLookupInterface(list,left,last-1,comp); qsort_SeqLookupInterface(list,last+1,right,comp); } /* Function: sort_SeqLookupInterface(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SeqLookupInterface * * * Arg: obj [UNKN ] Object containing list [SeqLookupInterface *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SeqLookupInterface(SeqLookupInterface * obj,int (*comp)(Sequence *, Sequence *)) { qsort_SeqLookupInterface(obj->seq_store,0,obj->len-1,comp); return; } /* Function: expand_SeqLookupInterface(obj,len) * * Descrip: Really an internal function for add_SeqLookupInterface * * * Arg: obj [UNKN ] Object which contains the list [SeqLookupInterface *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SeqLookupInterface(SeqLookupInterface * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SeqLookupInterface called with no need"); return TRUE; } if( (obj->seq_store = (Sequence ** ) ckrealloc (obj->seq_store,sizeof(Sequence *)*len)) == NULL) { warn("ckrealloc failed for expand_SeqLookupInterface, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SeqLookupInterface(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SeqLookupInterface *] * Arg: add [OWNER] Object to add to the list [Sequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SeqLookupInterface(SeqLookupInterface * obj,Sequence * add) { if( obj->len >= obj->maxlen) { if( expand_SeqLookupInterface(obj,obj->len + SeqLookupInterfaceLISTLENGTH) == FALSE) return FALSE; } obj->seq_store[obj->len++]=add; return TRUE; } /* Function: flush_SeqLookupInterface(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SeqLookupInterface *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SeqLookupInterface(SeqLookupInterface * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->seq_store[i] != NULL) { free_Sequence(obj->seq_store[i]); obj->seq_store[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SeqLookupInterface_alloc_std(void) * * Descrip: Equivalent to SeqLookupInterface_alloc_len(SeqLookupInterfaceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * SeqLookupInterface_alloc_std(void) { return SeqLookupInterface_alloc_len(SeqLookupInterfaceLISTLENGTH); } /* Function: SeqLookupInterface_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * SeqLookupInterface_alloc_len(int len) { SeqLookupInterface * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SeqLookupInterface_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->seq_store = (Sequence ** ) ckcalloc (len,sizeof(Sequence *))) == NULL) { warn("Warning, ckcalloc failed in SeqLookupInterface_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SeqLookupInterface(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupInterface *] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * hard_link_SeqLookupInterface(SeqLookupInterface * obj) { if( obj == NULL ) { warn("Trying to hard link to a SeqLookupInterface object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SeqLookupInterface_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * SeqLookupInterface_alloc(void) { SeqLookupInterface * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SeqLookupInterface *) ckalloc (sizeof(SeqLookupInterface))) == NULL) { warn("SeqLookupInterface_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->get_client = NULL; out->add_seq = NULL; out->lookup_array_head = NULL; out->add_direct_number = NULL; out->free_data = NULL; out->seq_store = NULL; out->len = out->maxlen = 0; return out; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/seqlookup.h0000644000175000001440000003715510670453712017044 0ustar philippusers#ifndef DYNAMITEseqlookupHEADERFILE #define DYNAMITEseqlookupHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #include "sequencedb.h" #define SEQLOOKUP_5AA_SIZE (26*26*26*26*26) #define SEQLOOKUP_LOWCOMPLEXITY 1 #define ARRAYHEAD_IS_LOWCOMPLEXITY(head) (head->flags & SEQLOOKUP_LOWCOMPLEXITY) typedef struct SeqLookupResultStruct { Sequence * seq; int pos; } SeqLookupResultStruct; typedef struct Wise2_ArraySeqLookup_Unit { Sequence * seq; int pos; } ArraySeqLookupUnit; typedef struct Wise2_ArraySeqHead { ArraySeqLookupUnit * units; int current_pos; int max; char flags; } ArraySeqHead; typedef enum SeqLookupLoadType { SeqLookupLoad_Protein = 12, SeqLookupLoad_DNA } SeqLookupLoadType; #define SeqLookupInterfaceLISTLENGTH 4028 /* Object SeqLookupResultInterface * * Descrip: This is the final interface returned on * finding an occuypied index (see below about * how to get this). It basically represents * an array of SeqLookupResultStruct. The * interface can choose how to manage the * memory - a client should call is_more function. * If this function returns TRUE, then it can call * next with the previous resultstruct passed in * in the prev slot. For the first call it passes * in a NULL pointer. The interface can decide whether * to reuse the memory or not. Finally the client * calls free_data to indicate that it does not want to * use the information any more * * */ struct Wise2_SeqLookupResultInterface { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeqLookupResultStruct * (*next)(void * data,SeqLookupResultStruct * prev); boolean (*is_more)(void *data); void (*free_data)(void * data); void * data; } ; /* SeqLookupResultInterface defined */ #ifndef DYNAMITE_DEFINED_SeqLookupResultInterface typedef struct Wise2_SeqLookupResultInterface Wise2_SeqLookupResultInterface; #define SeqLookupResultInterface Wise2_SeqLookupResultInterface #define DYNAMITE_DEFINED_SeqLookupResultInterface #endif /* Object SeqLookupClientInterface * * Descrip: This is a per-client interface got from the central SeqLookup * interface. A client must guarentee that only a single thread * will interact with a single SeqLookupClientInterface so * interfaces have a chance to sensible manage their memory * * */ struct Wise2_SeqLookupClientInterface { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeqLookupResultInterface * (*lookup)(void * data,int seq_number); boolean (*is_populated)(void * data,int seq_number); void (*free_data)(void * data); void * data; } ; /* SeqLookupClientInterface defined */ #ifndef DYNAMITE_DEFINED_SeqLookupClientInterface typedef struct Wise2_SeqLookupClientInterface Wise2_SeqLookupClientInterface; #define SeqLookupClientInterface Wise2_SeqLookupClientInterface #define DYNAMITE_DEFINED_SeqLookupClientInterface #endif struct Wise2_SeqLookupLoadPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeqLookupLoadType type; int tile_freq; int report_stagger; int truncate; int mark_low_complexity; int start_seq_load; int end_seq_load; } ; /* SeqLookupLoadPara defined */ #ifndef DYNAMITE_DEFINED_SeqLookupLoadPara typedef struct Wise2_SeqLookupLoadPara Wise2_SeqLookupLoadPara; #define SeqLookupLoadPara Wise2_SeqLookupLoadPara #define DYNAMITE_DEFINED_SeqLookupLoadPara #endif /* Object SeqLookupInterface * * Descrip: This interface defines the basic SeqLookup * possibilities. Its main role is to give out * clientInterfaces, which must be one per thread * (in contrast a client can call get_client by * multiple threads, though it should do each call via * single threaded). * * */ struct Wise2_SeqLookupInterface { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeqLookupClientInterface * (*get_client)(void * data); boolean (*add_seq)(void * data,Sequence * seq,SeqLookupLoadPara * para); ArraySeqHead * (*lookup_array_head)(void * data,int seq_number); boolean (*add_direct_number)(void *data,int seq_number,Sequence * target,int pos); void (*free_data)(void * data); void * data; Sequence ** seq_store; int len;/* len for above seq_store */ int maxlen; /* maxlen for above seq_store */ } ; /* SeqLookupInterface defined */ #ifndef DYNAMITE_DEFINED_SeqLookupInterface typedef struct Wise2_SeqLookupInterface Wise2_SeqLookupInterface; #define SeqLookupInterface Wise2_SeqLookupInterface #define DYNAMITE_DEFINED_SeqLookupInterface #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: free_SeqLookupInterface(sli) * * Descrip: Frees SeqLookupInterface - overrides dynamite default * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * Wise2_free_SeqLookupInterface(SeqLookupInterface * sli); #define free_SeqLookupInterface Wise2_free_SeqLookupInterface /* Function: load_SequenceDB_SeqLookupLoadPara(p,db,sli) * * Descrip: Loads a SequenceDB into a hash on the basis of the SeqLookupLoadPara * * returns the number of sequences loaded * * * Arg: p [UNKN ] Undocumented argument [SeqLookupLoadPara *] * Arg: db [UNKN ] Undocumented argument [SequenceDB *] * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_load_SequenceDB_SeqLookupLoadPara(SeqLookupLoadPara * p,SequenceDB * db,SeqLookupInterface * sli); #define load_SequenceDB_SeqLookupLoadPara Wise2_load_SequenceDB_SeqLookupLoadPara /* Function: show_help_SeqLookupLoadPara(ofp) * * Descrip: Shows help associated with Sequence loading * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_help_SeqLookupLoadPara(FILE * ofp); #define show_help_SeqLookupLoadPara Wise2_show_help_SeqLookupLoadPara /* Function: new_SeqLookupLoadPara_from_argv(argc,argv) * * Descrip: Builds new SeqLookup load from a command line * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [SeqLookupLoadPara *] * */ SeqLookupLoadPara * Wise2_new_SeqLookupLoadPara_from_argv(int * argc,char ** argv); #define new_SeqLookupLoadPara_from_argv Wise2_new_SeqLookupLoadPara_from_argv /* Function: seq_number_dna_15mer_noN(seq) * * Descrip: Function for DNA sequence to number on 15mers, * Ns get mapped to -1 * * * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_seq_number_dna_15mer_noN(char * seq); #define seq_number_dna_15mer_noN Wise2_seq_number_dna_15mer_noN /* Function: seq_number_dna_7mer_noN(seq) * * Descrip: Function for DNA sequence to number on 15mers, * Ns get mapped to -1 * * * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_seq_number_dna_7mer_noN(char * seq); #define seq_number_dna_7mer_noN Wise2_seq_number_dna_7mer_noN /* Function: seq_number_aa_5mer(seq) * * Descrip: Function for the amino acid to number on 5mers * * * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_seq_number_aa_5mer(char * seq); #define seq_number_aa_5mer Wise2_seq_number_aa_5mer /* Function: flags_from_5aa_sequence(seq) * * Descrip: returns simple lowcomplexity flag or * not for this sequence * * * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [char] * */ char Wise2_flags_from_5aa_sequence(char * seq); #define flags_from_5aa_sequence Wise2_flags_from_5aa_sequence /* Function: free_SeqLookupClientInterface(sli) * * Descrip: Frees SeqLookupClientInterface - overrides dynamite default * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupClientInterface *] * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ SeqLookupClientInterface * Wise2_free_SeqLookupClientInterface(SeqLookupClientInterface * sli); #define free_SeqLookupClientInterface Wise2_free_SeqLookupClientInterface /* Function: free_SeqLookupResultInterface(sli) * * Descrip: Frees SeqLookupResultInterface - overrides dynamite default * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupResultInterface *] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ SeqLookupResultInterface * Wise2_free_SeqLookupResultInterface(SeqLookupResultInterface * sli); #define free_SeqLookupResultInterface Wise2_free_SeqLookupResultInterface /* Function: hard_link_SeqLookupResultInterface(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupResultInterface *] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ SeqLookupResultInterface * Wise2_hard_link_SeqLookupResultInterface(SeqLookupResultInterface * obj); #define hard_link_SeqLookupResultInterface Wise2_hard_link_SeqLookupResultInterface /* Function: SeqLookupResultInterface_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ SeqLookupResultInterface * Wise2_SeqLookupResultInterface_alloc(void); #define SeqLookupResultInterface_alloc Wise2_SeqLookupResultInterface_alloc /* Function: hard_link_SeqLookupClientInterface(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupClientInterface *] * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ SeqLookupClientInterface * Wise2_hard_link_SeqLookupClientInterface(SeqLookupClientInterface * obj); #define hard_link_SeqLookupClientInterface Wise2_hard_link_SeqLookupClientInterface /* Function: SeqLookupClientInterface_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ SeqLookupClientInterface * Wise2_SeqLookupClientInterface_alloc(void); #define SeqLookupClientInterface_alloc Wise2_SeqLookupClientInterface_alloc /* Function: hard_link_SeqLookupLoadPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [SeqLookupLoadPara *] * */ SeqLookupLoadPara * Wise2_hard_link_SeqLookupLoadPara(SeqLookupLoadPara * obj); #define hard_link_SeqLookupLoadPara Wise2_hard_link_SeqLookupLoadPara /* Function: SeqLookupLoadPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupLoadPara *] * */ SeqLookupLoadPara * Wise2_SeqLookupLoadPara_alloc(void); #define SeqLookupLoadPara_alloc Wise2_SeqLookupLoadPara_alloc /* Function: free_SeqLookupLoadPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [SeqLookupLoadPara *] * */ SeqLookupLoadPara * Wise2_free_SeqLookupLoadPara(SeqLookupLoadPara * obj); #define free_SeqLookupLoadPara Wise2_free_SeqLookupLoadPara /* Function: add_SeqLookupInterface(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SeqLookupInterface *] * Arg: add [OWNER] Object to add to the list [Sequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SeqLookupInterface(SeqLookupInterface * obj,Sequence * add); #define add_SeqLookupInterface Wise2_add_SeqLookupInterface /* Function: flush_SeqLookupInterface(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SeqLookupInterface *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SeqLookupInterface(SeqLookupInterface * obj); #define flush_SeqLookupInterface Wise2_flush_SeqLookupInterface /* Function: SeqLookupInterface_alloc_std(void) * * Descrip: Equivalent to SeqLookupInterface_alloc_len(SeqLookupInterfaceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * Wise2_SeqLookupInterface_alloc_std(void); #define SeqLookupInterface_alloc_std Wise2_SeqLookupInterface_alloc_std /* Function: SeqLookupInterface_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * Wise2_SeqLookupInterface_alloc_len(int len); #define SeqLookupInterface_alloc_len Wise2_SeqLookupInterface_alloc_len /* Function: hard_link_SeqLookupInterface(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupInterface *] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * Wise2_hard_link_SeqLookupInterface(SeqLookupInterface * obj); #define hard_link_SeqLookupInterface Wise2_hard_link_SeqLookupInterface /* Function: SeqLookupInterface_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * Wise2_SeqLookupInterface_alloc(void); #define SeqLookupInterface_alloc Wise2_SeqLookupInterface_alloc /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_SeqLookupInterface(Sequence ** list,int i,int j) ; #define swap_SeqLookupInterface Wise2_swap_SeqLookupInterface void Wise2_qsort_SeqLookupInterface(Sequence ** list,int left,int right,int (*comp)(Sequence * ,Sequence * )); #define qsort_SeqLookupInterface Wise2_qsort_SeqLookupInterface void Wise2_sort_SeqLookupInterface(SeqLookupInterface * obj,int (*comp)(Sequence *, Sequence *)); #define sort_SeqLookupInterface Wise2_sort_SeqLookupInterface boolean Wise2_expand_SeqLookupInterface(SeqLookupInterface * obj,int len); #define expand_SeqLookupInterface Wise2_expand_SeqLookupInterface #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/codonmapper_api.h0000644000175000001440000000645610670453712020162 0ustar philippusers /* Functions that create, manipulate or act on CodonMapper * * Wise2_sprinkle_errors_over_CodonMapper * Wise2_hard_link_CodonMapper * Wise2_CodonMapper_alloc * Wise2_replace_ct_CodonMapper * Wise2_access_ct_CodonMapper * Wise2_free_CodonMapper [destructor] * */ /* Helper functions in the module * * Wise2_flat_CodonMapper * /* API for object CodonMapper */ /* Function: Wise2_sprinkle_errors_over_CodonMapper(cm,error) * * Descrip: Takes a codon mapper and assummes that the majority of errors * are due to a single base change in the codon at probability error. * Therefore, for each codon it adds error * prob(codon) * 0.25 to each * other codon one base away, taking away therefore the result. * * * * Arg: cm CodonMapper to be sprinkled [Wise2_CodonMapper *] * Arg: error substitution error rate [double] * * Returns Undocumented return value [void] * */ void Wise2_sprinkle_errors_over_CodonMapper( Wise2_CodonMapper * cm,double error); /* Function: Wise2_hard_link_CodonMapper(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_CodonMapper *] * * Returns Undocumented return value [Wise2_CodonMapper *] * */ Wise2_CodonMapper * Wise2_hard_link_CodonMapper( Wise2_CodonMapper * obj); /* Function: Wise2_CodonMapper_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_CodonMapper *] * */ Wise2_CodonMapper * Wise2_CodonMapper_alloc(); /* Function: Wise2_replace_ct_CodonMapper(obj,ct) * * Descrip: Replace member variable ct * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_CodonMapper *] * Arg: ct New value of the variable [Wise2_CodonTable *] * * Returns member variable ct [boolean] * */ boolean Wise2_replace_ct_CodonMapper( Wise2_CodonMapper * obj,Wise2_CodonTable * ct); /* Function: Wise2_access_ct_CodonMapper(obj) * * Descrip: Access member variable ct * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_CodonMapper *] * * Returns member variable ct [Wise2_CodonTable *] * */ Wise2_CodonTable * Wise2_access_ct_CodonMapper( Wise2_CodonMapper * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_CodonMapper(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_CodonMapper *] * * Returns Undocumented return value [Wise2_CodonMapper *] * */ Wise2_CodonMapper * Wise2_free_CodonMapper( Wise2_CodonMapper * obj); /* These functions are not associated with an object */ /* Function: Wise2_flat_CodonMapper(ct) * * Descrip: Makes a CodonMapper with no codon bias * or error possiblities from codon table * * * * Arg: ct Codon Table giving codon->aa info [Wise2_CodonTable *] * * Returns Undocumented return value [Wise2_CodonMapper *] * */ Wise2_CodonMapper * Wise2_flat_CodonMapper( Wise2_CodonTable * ct); wise-2.4.1/src/dynlibsrc/codonmapper_api.t0000644000175000001440000000006510670453712020164 0ustar philippuserstypedef struct Wise2_CodonMapper Wise2_CodonMapper; wise-2.4.1/src/dynlibsrc/hspscanruntime.dy0000644000175000001440000000352110417270545020240 0ustar philippusers %{ #include "hsplookupscan.h" #include "hsplookupthreaded.h" #include "hsptwohitscan.h" %} struct HSPScanRuntimeImpl HSPScanInterface * vanilla HSPScanInterface * threaded HSPScanInterface * twohit %{ #include "hspscanruntime.h" %func Makes a new function which will at runtime switch between implementation; vanilla, threaded and twohit %% HSPScanInterface * new_runtime_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff,int threadno) { HSPScanInterface * out; HSPScanRuntimeImpl * rt; out = HSPScanInterface_alloc(); rt = HSPScanRuntimeImpl_alloc(); rt->vanilla = new_one_off_HSPScanInterface(sli,mat,drop_off,score_cutoff); rt->threaded = new_threaded_HSPScanInterface(sli,mat,drop_off,score_cutoff,threadno); rt->twohit = new_twohit_one_off_HSPScanInterface(sli,mat,drop_off,score_cutoff); out->data = (void*) rt; out->free_data = free_runtime_hspscan; out->scan_query = scan_query_runtime_hspscan; return out; } %func Handles runtime switching between methods for the scan query %% LinearHSPmanager * scan_query_runtime_hspscan(void * data,Sequence * seq,HSPScanInterfacePara * para) { HSPScanRuntimeImpl * d; d = (HSPScanRuntimeImpl *) data; switch(para->implementation) { case HSPSCAN_IMPLEMENTATION_VANILLA : return (*d->vanilla->scan_query)(d->vanilla->data,seq,para); case HSPSCAN_IMPLEMENTATION_THREADED : return (*d->threaded->scan_query)(d->threaded->data,seq,para); case HSPSCAN_IMPLEMENTATION_TWOHIT : return (*d->twohit->scan_query)(d->twohit->data,seq,para); default : warn("No good implementation for %d as implementation",para->implementation); } return NULL; } %func free function for runtime %% void free_runtime_hspscan(void * data) { HSPScanRuntimeImpl * d; d = (HSPScanRuntimeImpl *) data; free_HSPScanRuntimeImpl(d); } wise-2.4.1/src/dynlibsrc/randommodel.typemap0000644000175000001440000000101210670453712020532 0ustar philippusers TYPEMAP Wise2_RandomModelDNA * T_Wise2_RandomModelDNA INPUT T_Wise2_RandomModelDNA $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_RandomModelDNA *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_RandomModelDNA sv_setref_pv($arg, "Wise2::RandomModelDNA", (void*) $var); TYPEMAP Wise2_RandomModel * T_Wise2_RandomModel INPUT T_Wise2_RandomModel $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_RandomModel *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_RandomModel sv_setref_pv($arg, "Wise2::RandomModel", (void*) $var); wise-2.4.1/src/dynlibsrc/dnamatrix_api.h0000644000175000001440000001042010670453712017624 0ustar philippusers /* Functions that create, manipulate or act on DnaMatrix * * Wise2_hard_link_DnaMatrix * Wise2_DnaMatrix_alloc * Wise2_free_DnaMatrix [destructor] * */ /* Functions that create, manipulate or act on DnaProbMatrix * * Wise2_flat_null_DnaProbMatrix * Wise2_hard_link_DnaProbMatrix * Wise2_DnaProbMatrix_alloc * Wise2_free_DnaProbMatrix [destructor] * */ /* Helper functions in the module * * Wise2_identity_DnaMatrix * Wise2_DnaProbMatrix_from_match * Wise2_DnaMatrix_from_DnaProbMatrix * /* API for object DnaMatrix */ /* Function: Wise2_hard_link_DnaMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_DnaMatrix *] * * Returns Undocumented return value [Wise2_DnaMatrix *] * */ Wise2_DnaMatrix * Wise2_hard_link_DnaMatrix( Wise2_DnaMatrix * obj); /* Function: Wise2_DnaMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_DnaMatrix *] * */ Wise2_DnaMatrix * Wise2_DnaMatrix_alloc(); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_DnaMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_DnaMatrix *] * * Returns Undocumented return value [Wise2_DnaMatrix *] * */ Wise2_DnaMatrix * Wise2_free_DnaMatrix( Wise2_DnaMatrix * obj); /* API for object DnaProbMatrix */ /* Function: Wise2_flat_null_DnaProbMatrix(dpm) * * Descrip: makes a odds of dpm via a 0.25 factor * into each base. * * * Arg: dpm Undocumented argument [Wise2_DnaProbMatrix *] * * Returns Undocumented return value [void] * */ void Wise2_flat_null_DnaProbMatrix( Wise2_DnaProbMatrix * dpm); /* Function: Wise2_hard_link_DnaProbMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_DnaProbMatrix *] * * Returns Undocumented return value [Wise2_DnaProbMatrix *] * */ Wise2_DnaProbMatrix * Wise2_hard_link_DnaProbMatrix( Wise2_DnaProbMatrix * obj); /* Function: Wise2_DnaProbMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_DnaProbMatrix *] * */ Wise2_DnaProbMatrix * Wise2_DnaProbMatrix_alloc(); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_DnaProbMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_DnaProbMatrix *] * * Returns Undocumented return value [Wise2_DnaProbMatrix *] * */ Wise2_DnaProbMatrix * Wise2_free_DnaProbMatrix( Wise2_DnaProbMatrix * obj); /* These functions are not associated with an object */ /* Function: Wise2_identity_DnaMatrix(id_score,mismatch) * * Descrip: makes an idenity matrix wth id_score on the leading * diagonal and mismatch elsewhere. * * * * Arg: id_score score of idenities [Score] * Arg: mismatch score of mistmatches [Score] * * Returns Undocumented return value [Wise2_DnaMatrix *] * */ Wise2_DnaMatrix * Wise2_identity_DnaMatrix( Score id_score,Score mismatch); /* Function: Wise2_DnaProbMatrix_from_match(match,nmask_type) * * Descrip: Makes a probability matrix from simple match/mismatch * probabilities. * * * * Arg: match Undocumented argument [Probability] * Arg: nmask_type Undocumented argument [int] * * Returns Undocumented return value [Wise2_DnaProbMatrix *] * */ Wise2_DnaProbMatrix * Wise2_DnaProbMatrix_from_match( Probability match,int nmask_type); /* Function: Wise2_DnaMatrix_from_DnaProbMatrix(dpm) * * Descrip: Maps probabilities to scores * * * Arg: dpm Undocumented argument [Wise2_DnaProbMatrix *] * * Returns Undocumented return value [Wise2_DnaMatrix *] * */ Wise2_DnaMatrix * Wise2_DnaMatrix_from_DnaProbMatrix( Wise2_DnaProbMatrix * dpm); wise-2.4.1/src/dynlibsrc/dnamatrix_api.t0000644000175000001440000000015210670453712017641 0ustar philippuserstypedef struct Wise2_DnaMatrix Wise2_DnaMatrix; typedef struct Wise2_DnaProbMatrix Wise2_DnaProbMatrix; wise-2.4.1/src/dynlibsrc/test_shadowindex.c0000644000175000001440000000075007626362477020376 0ustar philippusers#include "shadowseqindex.h" int main(int argc,char ** argv) { ShadowSequenceIndex * in; Sequence * seq; int i; in = new_ShadowSequenceIndex(26*26*26*26*26,15,0,5000,5); i = 0; while( (seq = read_fasta_Sequence(stdin)) != NULL ) { add_Sequence_ShadowSequenceIndex(in,seq,15); if( i % 500 == 0 ) { fprintf(stderr,"Loaded %d ...\n",i); } if( i > 10000 ) { break; } i++; } dump_stats_ShadowSequenceIndex(in,stdout); return 0; } wise-2.4.1/src/dynlibsrc/aln_api.h0000644000175000001440000005555610670453712016432 0ustar philippusers /* Functions that create, manipulate or act on AlnBlock * * Wise2_dump_ascii_AlnBlock * Wise2_hard_link_AlnBlock * Wise2_AlnBlock_alloc_std * Wise2_replace_start_AlnBlock * Wise2_access_start_AlnBlock * Wise2_access_seq_AlnBlock * Wise2_length_seq_AlnBlock * Wise2_flush_AlnBlock * Wise2_add_AlnBlock * Wise2_replace_length_AlnBlock * Wise2_access_length_AlnBlock * Wise2_replace_score_AlnBlock * Wise2_access_score_AlnBlock * Wise2_free_AlnBlock [destructor] * */ /* Functions that create, manipulate or act on AlnColumn * * Wise2_at_end_AlnColumn * Wise2_hard_link_AlnColumn * Wise2_AlnColumn_alloc_std * Wise2_access_alu_AlnColumn * Wise2_length_alu_AlnColumn * Wise2_flush_AlnColumn * Wise2_add_AlnColumn * Wise2_replace_next_AlnColumn * Wise2_access_next_AlnColumn * Wise2_free_AlnColumn [destructor] * */ /* Functions that create, manipulate or act on AlnUnit * * Wise2_bio_start_AlnUnit * Wise2_bio_end_AlnUnit * Wise2_hard_link_AlnUnit * Wise2_AlnUnit_alloc * Wise2_replace_start_AlnUnit * Wise2_access_start_AlnUnit * Wise2_replace_end_AlnUnit * Wise2_access_end_AlnUnit * Wise2_replace_label_AlnUnit * Wise2_access_label_AlnUnit * Wise2_replace_text_label_AlnUnit * Wise2_access_text_label_AlnUnit * Wise2_replace_next_AlnUnit * Wise2_access_next_AlnUnit * Wise2_replace_in_column_AlnUnit * Wise2_access_in_column_AlnUnit * Wise2_replace_seq_AlnUnit * Wise2_access_seq_AlnUnit * Wise2_free_AlnUnit [destructor] * */ /* Functions that create, manipulate or act on AlnSequence * * Wise2_hard_link_AlnSequence * Wise2_AlnSequence_alloc * Wise2_replace_start_AlnSequence * Wise2_access_start_AlnSequence * Wise2_replace_data_type_AlnSequence * Wise2_access_data_type_AlnSequence * Wise2_replace_data_AlnSequence * Wise2_access_data_AlnSequence * Wise2_replace_bio_start_AlnSequence * Wise2_access_bio_start_AlnSequence * Wise2_replace_bio_end_AlnSequence * Wise2_access_bio_end_AlnSequence * Wise2_free_AlnSequence [destructor] * */ /* API for object AlnBlock */ /* Function: Wise2_dump_ascii_AlnBlock(alb,ofp) * * Descrip: Dumps the alignment in rereadable ascii form. * * Not really for human consumption * * * Arg: alb AlnBlock to dump [Wise2_AlnBlock *] * Arg: ofp File stream to dump to [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_dump_ascii_AlnBlock( Wise2_AlnBlock * alb,FILE * ofp); /* Function: Wise2_hard_link_AlnBlock(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_AlnBlock *] * * Returns Undocumented return value [Wise2_AlnBlock *] * */ Wise2_AlnBlock * Wise2_hard_link_AlnBlock( Wise2_AlnBlock * obj); /* Function: Wise2_AlnBlock_alloc_std(void) * * Descrip: Equivalent to AlnBlock_alloc_len(AlnBlockLISTLENGTH) * * * * Returns Undocumented return value [Wise2_AlnBlock *] * */ Wise2_AlnBlock * Wise2_AlnBlock_alloc_std(); /* Function: Wise2_replace_start_AlnBlock(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnBlock *] * Arg: start New value of the variable [Wise2_AlnColumn *] * * Returns member variable start [boolean] * */ boolean Wise2_replace_start_AlnBlock( Wise2_AlnBlock * obj,Wise2_AlnColumn * start); /* Function: Wise2_access_start_AlnBlock(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnBlock *] * * Returns member variable start [Wise2_AlnColumn *] * */ Wise2_AlnColumn * Wise2_access_start_AlnBlock( Wise2_AlnBlock * obj); /* Function: Wise2_access_seq_AlnBlock(obj,i) * * Descrip: Access members stored in the seq list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_AlnBlock *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_AlnSequence *] * */ Wise2_AlnSequence * Wise2_access_seq_AlnBlock( Wise2_AlnBlock * obj,int i); /* Function: Wise2_length_seq_AlnBlock(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_AlnBlock *] * * Returns length of the list [int] * */ int Wise2_length_seq_AlnBlock( Wise2_AlnBlock * obj); /* Function: Wise2_flush_AlnBlock(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_AlnBlock *] * * Returns Undocumented return value [int] * */ int Wise2_flush_AlnBlock( Wise2_AlnBlock * obj); /* Function: Wise2_add_AlnBlock(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_AlnBlock *] * Arg: add Object to add to the list [Wise2_AlnSequence *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_AlnBlock( Wise2_AlnBlock * obj,Wise2_AlnSequence * add); /* Function: Wise2_replace_length_AlnBlock(obj,length) * * Descrip: Replace member variable length * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnBlock *] * Arg: length New value of the variable [int] * * Returns member variable length [boolean] * */ boolean Wise2_replace_length_AlnBlock( Wise2_AlnBlock * obj,int length); /* Function: Wise2_access_length_AlnBlock(obj) * * Descrip: Access member variable length * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnBlock *] * * Returns member variable length [int] * */ int Wise2_access_length_AlnBlock( Wise2_AlnBlock * obj); /* Function: Wise2_replace_score_AlnBlock(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnBlock *] * Arg: score New value of the variable [int] * * Returns member variable score [boolean] * */ boolean Wise2_replace_score_AlnBlock( Wise2_AlnBlock * obj,int score); /* Function: Wise2_access_score_AlnBlock(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnBlock *] * * Returns member variable score [int] * */ int Wise2_access_score_AlnBlock( Wise2_AlnBlock * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_AlnBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_AlnBlock *] * * Returns Undocumented return value [Wise2_AlnBlock *] * */ Wise2_AlnBlock * Wise2_free_AlnBlock( Wise2_AlnBlock * obj); /* API for object AlnColumn */ /* Function: Wise2_at_end_AlnColumn(alc) * * Descrip: This tells you whether the AlnColumn is at the * end without passing NULL's around * * * * Arg: alc AlnColumn [Wise2_AlnColumn *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_at_end_AlnColumn( Wise2_AlnColumn * alc); /* Function: Wise2_hard_link_AlnColumn(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_AlnColumn *] * * Returns Undocumented return value [Wise2_AlnColumn *] * */ Wise2_AlnColumn * Wise2_hard_link_AlnColumn( Wise2_AlnColumn * obj); /* Function: Wise2_AlnColumn_alloc_std(void) * * Descrip: Equivalent to AlnColumn_alloc_len(AlnColumnLISTLENGTH) * * * * Returns Undocumented return value [Wise2_AlnColumn *] * */ Wise2_AlnColumn * Wise2_AlnColumn_alloc_std(); /* Function: Wise2_access_alu_AlnColumn(obj,i) * * Descrip: Access members stored in the alu list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_AlnColumn *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_AlnUnit *] * */ Wise2_AlnUnit * Wise2_access_alu_AlnColumn( Wise2_AlnColumn * obj,int i); /* Function: Wise2_length_alu_AlnColumn(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_AlnColumn *] * * Returns length of the list [int] * */ int Wise2_length_alu_AlnColumn( Wise2_AlnColumn * obj); /* Function: Wise2_flush_AlnColumn(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_AlnColumn *] * * Returns Undocumented return value [int] * */ int Wise2_flush_AlnColumn( Wise2_AlnColumn * obj); /* Function: Wise2_add_AlnColumn(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_AlnColumn *] * Arg: add Object to add to the list [Wise2_AlnUnit *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_AlnColumn( Wise2_AlnColumn * obj,Wise2_AlnUnit * add); /* Function: Wise2_replace_next_AlnColumn(obj,next) * * Descrip: Replace member variable next * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnColumn *] * Arg: next New value of the variable [Wise2_AlnColumn *] * * Returns member variable next [boolean] * */ boolean Wise2_replace_next_AlnColumn( Wise2_AlnColumn * obj,Wise2_AlnColumn * next); /* Function: Wise2_access_next_AlnColumn(obj) * * Descrip: Access member variable next * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnColumn *] * * Returns member variable next [Wise2_AlnColumn *] * */ Wise2_AlnColumn * Wise2_access_next_AlnColumn( Wise2_AlnColumn * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_AlnColumn(obj) * * Descrip: Specilased deconstructor needed because * of linked list nature of the data structure * * * Arg: obj Undocumented argument [Wise2_AlnColumn *] * * Returns Undocumented return value [Wise2_AlnColumn *] * */ Wise2_AlnColumn * Wise2_free_AlnColumn( Wise2_AlnColumn * obj); /* API for object AlnUnit */ /* Function: Wise2_bio_start_AlnUnit(alu) * * Descrip: Tells the bio-coordinate of the * start point of this alnunit * * * Arg: alu Undocumented argument [Wise2_AlnUnit *] * * Returns Undocumented return value [int] * */ int Wise2_bio_start_AlnUnit( Wise2_AlnUnit * alu); /* Function: Wise2_bio_end_AlnUnit(alu) * * Descrip: Tells the bio-coordinate of the * end point of this alnunit * * * Arg: alu Undocumented argument [Wise2_AlnUnit *] * * Returns Undocumented return value [int] * */ int Wise2_bio_end_AlnUnit( Wise2_AlnUnit * alu); /* Function: Wise2_hard_link_AlnUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_AlnUnit *] * * Returns Undocumented return value [Wise2_AlnUnit *] * */ Wise2_AlnUnit * Wise2_hard_link_AlnUnit( Wise2_AlnUnit * obj); /* Function: Wise2_AlnUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_AlnUnit *] * */ Wise2_AlnUnit * Wise2_AlnUnit_alloc(); /* Function: Wise2_replace_start_AlnUnit(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * Arg: start New value of the variable [int] * * Returns member variable start [boolean] * */ boolean Wise2_replace_start_AlnUnit( Wise2_AlnUnit * obj,int start); /* Function: Wise2_access_start_AlnUnit(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * * Returns member variable start [int] * */ int Wise2_access_start_AlnUnit( Wise2_AlnUnit * obj); /* Function: Wise2_replace_end_AlnUnit(obj,end) * * Descrip: Replace member variable end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * Arg: end New value of the variable [int] * * Returns member variable end [boolean] * */ boolean Wise2_replace_end_AlnUnit( Wise2_AlnUnit * obj,int end); /* Function: Wise2_access_end_AlnUnit(obj) * * Descrip: Access member variable end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * * Returns member variable end [int] * */ int Wise2_access_end_AlnUnit( Wise2_AlnUnit * obj); /* Function: Wise2_replace_label_AlnUnit(obj,label) * * Descrip: Replace member variable label * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * Arg: label New value of the variable [int] * * Returns member variable label [boolean] * */ boolean Wise2_replace_label_AlnUnit( Wise2_AlnUnit * obj,int label); /* Function: Wise2_access_label_AlnUnit(obj) * * Descrip: Access member variable label * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * * Returns member variable label [int] * */ int Wise2_access_label_AlnUnit( Wise2_AlnUnit * obj); /* Function: Wise2_replace_text_label_AlnUnit(obj,text_label) * * Descrip: Replace member variable text_label * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * Arg: text_label New value of the variable [char *] * * Returns member variable text_label [boolean] * */ boolean Wise2_replace_text_label_AlnUnit( Wise2_AlnUnit * obj,char * text_label); /* Function: Wise2_access_text_label_AlnUnit(obj) * * Descrip: Access member variable text_label * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * * Returns member variable text_label [char *] * */ char * Wise2_access_text_label_AlnUnit( Wise2_AlnUnit * obj); /* Function: Wise2_replace_next_AlnUnit(obj,next) * * Descrip: Replace member variable next * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * Arg: next New value of the variable [Wise2_AlnUnit *] * * Returns member variable next [boolean] * */ boolean Wise2_replace_next_AlnUnit( Wise2_AlnUnit * obj,Wise2_AlnUnit * next); /* Function: Wise2_access_next_AlnUnit(obj) * * Descrip: Access member variable next * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * * Returns member variable next [Wise2_AlnUnit *] * */ Wise2_AlnUnit * Wise2_access_next_AlnUnit( Wise2_AlnUnit * obj); /* Function: Wise2_replace_in_column_AlnUnit(obj,in_column) * * Descrip: Replace member variable in_column * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * Arg: in_column New value of the variable [boolean] * * Returns member variable in_column [boolean] * */ boolean Wise2_replace_in_column_AlnUnit( Wise2_AlnUnit * obj,boolean in_column); /* Function: Wise2_access_in_column_AlnUnit(obj) * * Descrip: Access member variable in_column * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * * Returns member variable in_column [boolean] * */ boolean Wise2_access_in_column_AlnUnit( Wise2_AlnUnit * obj); /* Function: Wise2_replace_seq_AlnUnit(obj,seq) * * Descrip: Replace member variable seq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * Arg: seq New value of the variable [Wise2_AlnSequence *] * * Returns member variable seq [boolean] * */ boolean Wise2_replace_seq_AlnUnit( Wise2_AlnUnit * obj,Wise2_AlnSequence * seq); /* Function: Wise2_access_seq_AlnUnit(obj) * * Descrip: Access member variable seq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnUnit *] * * Returns member variable seq [Wise2_AlnSequence *] * */ Wise2_AlnSequence * Wise2_access_seq_AlnUnit( Wise2_AlnUnit * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_AlnUnit(obj) * * Descrip: Specilased deconstructor needed because * of linked list nature of the data structure * * * Arg: obj Undocumented argument [Wise2_AlnUnit *] * * Returns Undocumented return value [Wise2_AlnUnit *] * */ Wise2_AlnUnit * Wise2_free_AlnUnit( Wise2_AlnUnit * obj); /* API for object AlnSequence */ /* Function: Wise2_hard_link_AlnSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_AlnSequence *] * * Returns Undocumented return value [Wise2_AlnSequence *] * */ Wise2_AlnSequence * Wise2_hard_link_AlnSequence( Wise2_AlnSequence * obj); /* Function: Wise2_AlnSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_AlnSequence *] * */ Wise2_AlnSequence * Wise2_AlnSequence_alloc(); /* Function: Wise2_replace_start_AlnSequence(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnSequence *] * Arg: start New value of the variable [Wise2_AlnUnit *] * * Returns member variable start [boolean] * */ boolean Wise2_replace_start_AlnSequence( Wise2_AlnSequence * obj,Wise2_AlnUnit * start); /* Function: Wise2_access_start_AlnSequence(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnSequence *] * * Returns member variable start [Wise2_AlnUnit *] * */ Wise2_AlnUnit * Wise2_access_start_AlnSequence( Wise2_AlnSequence * obj); /* Function: Wise2_replace_data_type_AlnSequence(obj,data_type) * * Descrip: Replace member variable data_type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnSequence *] * Arg: data_type New value of the variable [int] * * Returns member variable data_type [boolean] * */ boolean Wise2_replace_data_type_AlnSequence( Wise2_AlnSequence * obj,int data_type); /* Function: Wise2_access_data_type_AlnSequence(obj) * * Descrip: Access member variable data_type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnSequence *] * * Returns member variable data_type [int] * */ int Wise2_access_data_type_AlnSequence( Wise2_AlnSequence * obj); /* Function: Wise2_replace_data_AlnSequence(obj,data) * * Descrip: Replace member variable data * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnSequence *] * Arg: data New value of the variable [void *] * * Returns member variable data [boolean] * */ boolean Wise2_replace_data_AlnSequence( Wise2_AlnSequence * obj,void * data); /* Function: Wise2_access_data_AlnSequence(obj) * * Descrip: Access member variable data * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnSequence *] * * Returns member variable data [void *] * */ void * Wise2_access_data_AlnSequence( Wise2_AlnSequence * obj); /* Function: Wise2_replace_bio_start_AlnSequence(obj,bio_start) * * Descrip: Replace member variable bio_start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnSequence *] * Arg: bio_start New value of the variable [int] * * Returns member variable bio_start [boolean] * */ boolean Wise2_replace_bio_start_AlnSequence( Wise2_AlnSequence * obj,int bio_start); /* Function: Wise2_access_bio_start_AlnSequence(obj) * * Descrip: Access member variable bio_start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnSequence *] * * Returns member variable bio_start [int] * */ int Wise2_access_bio_start_AlnSequence( Wise2_AlnSequence * obj); /* Function: Wise2_replace_bio_end_AlnSequence(obj,bio_end) * * Descrip: Replace member variable bio_end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnSequence *] * Arg: bio_end New value of the variable [int] * * Returns member variable bio_end [boolean] * */ boolean Wise2_replace_bio_end_AlnSequence( Wise2_AlnSequence * obj,int bio_end); /* Function: Wise2_access_bio_end_AlnSequence(obj) * * Descrip: Access member variable bio_end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_AlnSequence *] * * Returns member variable bio_end [int] * */ int Wise2_access_bio_end_AlnSequence( Wise2_AlnSequence * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_AlnSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_AlnSequence *] * * Returns Undocumented return value [Wise2_AlnSequence *] * */ Wise2_AlnSequence * Wise2_free_AlnSequence( Wise2_AlnSequence * obj); wise-2.4.1/src/dynlibsrc/aln_api.t0000644000175000001440000000030210670453712016421 0ustar philippuserstypedef struct Wise2_AlnBlock Wise2_AlnBlock; typedef struct Wise2_AlnColumn Wise2_AlnColumn; typedef struct Wise2_AlnUnit Wise2_AlnUnit; typedef struct Wise2_AlnSequence Wise2_AlnSequence; wise-2.4.1/src/dynlibsrc/dynlibcross.c0000644000175000001440000000434010670453712017336 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dynlibcross.h" /* Function: show_bits_Hscore(out,ofp) * * Descrip: shows Hscore as bits level * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 17 "dynlibcross.dy" void show_bits_Hscore(Hscore * out,FILE * ofp) { int i; assert(out); assert(ofp); for(i=0;ilen;i++) fprintf(ofp,"Query %s Target %s Bits %.2f\n",out->ds[i]->query->name, out->ds[i]->target->name,Score2Bits(out->ds[i]->score)); } /* Function: std_bits_Hscore(cut_off_level,report_stagger) * * Descrip: This gives you a standard Hscore * module with a cutoff in bits (assumming * the score is being made from a standard * Probability2Score type function). * * * Arg: cut_off_level [UNKN ] Undocumented argument [double] * Arg: report_stagger [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Hscore *] * */ # line 38 "dynlibcross.dy" Hscore * std_bits_Hscore(double cut_off_level,int report_stagger) { Hscore * out; out = Hscore_alloc_std(); out->his = new_Histogram(-1000,1000,100); out->score_level = cut_off_level; out->should_store = std_should_store_Hscore; out->score_to_his = std_score_to_his; out->report_level = report_stagger; return out; } /* Function: std_should_store_Hscore(score,cutoff) * * Descrip: This function is for the Hscore std constructor, * * * Arg: score [UNKN ] Undocumented argument [int] * Arg: cutoff [UNKN ] Undocumented argument [double] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 57 "dynlibcross.dy" boolean std_should_store_Hscore(int score,double cutoff) { if( Score2Bits(score) > cutoff ) { return TRUE; } return FALSE; } /* Function: std_score_to_his(score) * * Descrip: This function is for the Hscore std constructor, * * * Arg: score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [float] * */ # line 69 "dynlibcross.dy" float std_score_to_his(int score) { return Score2Bits(score); } # line 94 "dynlibcross.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/dynlibcross.h0000644000175000001440000000351610670453712017347 0ustar philippusers#ifndef DYNAMITEdynlibcrossHEADERFILE #define DYNAMITEdynlibcrossHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: show_bits_Hscore(out,ofp) * * Descrip: shows Hscore as bits level * * * Arg: out [UNKN ] Undocumented argument [Hscore *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_bits_Hscore(Hscore * out,FILE * ofp); #define show_bits_Hscore Wise2_show_bits_Hscore /* Function: std_bits_Hscore(cut_off_level,report_stagger) * * Descrip: This gives you a standard Hscore * module with a cutoff in bits (assumming * the score is being made from a standard * Probability2Score type function). * * * Arg: cut_off_level [UNKN ] Undocumented argument [double] * Arg: report_stagger [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * Wise2_std_bits_Hscore(double cut_off_level,int report_stagger); #define std_bits_Hscore Wise2_std_bits_Hscore /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_std_should_store_Hscore(int score,double cutoff); #define std_should_store_Hscore Wise2_std_should_store_Hscore float Wise2_std_score_to_his(int score); #define std_score_to_his Wise2_std_score_to_his #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/sequencedb.dy0000644000175000001440000002715107611245645017325 0ustar philippusers %{ #include "sequence.h" #include "database.h" #include "hscore.h" #define SequenceDBLISTLENGTH 128 enum SequenceDBFormat { SEQ_DB_UNKNOWN = 32, SEQ_DB_FASTA }; %} struct FileSource char * filename FILE * input !link // could be stdin! int format int type %info This object represents a single file source for a database. At the moment only multiple fasta files are catered for %% struct SequenceDB char * name FileSource ** fs !list int current_source !def="-1" FILE * current_file !def="NULL" !link int sequence_no; !def="0" int byte_position; int has_warned_single !def="0" !hidden int seq_start !def="-1" int seq_end !def="-1" %info This is the basic Sequence database wrapper - it handles all the formats and the on-the-fly indexing. Generally it wont be directly used by an algorithm, which will be using something specific to the sequence type produce complex sequence type objects: ie you will be using proteindb or cdnadb which internally will be using this object %% api object SequenceDB func close_SequenceDB des free_SequenceDB endobject object FileSource des free_FileSource endobject func single_fasta_SequenceDB endapi %{ #include "sequencedb.h" %func Quite a mindless function which retrieves sequences via indexes Going to spend too much time in fopen if this is used too much %% Sequence * get_Sequence_from_SequenceDB(SequenceDB * sdb,DataEntry * de) { FILE * ifp; Sequence * ret; if( de == NULL ) { warn("Cannot get sequence database entry with a null dataentry!"); return NULL; } if( sdb == NULL ) { warn("Cannot get sequence database entry with a null sequence db!"); return NULL; } if( de->filename == NULL ) { warn("Cannot get sequence database entry with no attached filename"); return NULL; } /* actually, all our info is in dataentry */ ifp = openfile(de->filename,"r"); if( ifp == NULL ) { warn("Bad error - could not open database file %s for reading indexed sequence",de->filename); return NULL; } fseek(ifp,de->byte_position,SEEK_SET); switch(de->data[1]) { case SEQ_DB_FASTA : ret = read_fasta_Sequence(ifp); break; default : warn("Unknown SequenceDB type [%d]",de->data[1]); ret = NULL; } fclose(ifp); return ret; } %func A function which places data into dataentry so we can be guarenteed to retrieve it sometime. It uses 0 and 1 points in the Data array. %% boolean add_SequenceDB_info_DataEntry(SequenceDB * sdb,DataEntry * de) { if( sdb == NULL || de == NULL ) { warn("Null objects being passed into add_SequenceDB_info_DataEntry. Can't be good!"); return FALSE; } de->filename = sdb->fs[sdb->current_source]->filename; /* if there... */ de->byte_position = sdb->byte_position; /* of this sequence */ de->data[1] = sdb->fs[sdb->current_source]->format; return TRUE; } %func top level function that closes the SequenceDB after the last sequence is read. %arg last w Sequence object to be freed sdb r database to be closed %% boolean close_SequenceDB(Sequence * last,SequenceDB * sdb) { if( last != NULL ) free_Sequence(last); if( sdb->sequence_no == 1 && sdb->has_warned_single == 0) { info("Your sequence database has only sequence in it. It is quite likely there was a more efficient way to run this"); sdb->has_warned_single = 1; } /*** nothing else to do? ***/ sdb->current_source = (-1); return TRUE; } %func top level function that starts a database read on SequenceDB %arg sdb r sequence database return_status w returns the database status as found in database.h %% Sequence * init_SequenceDB(SequenceDB * sdb,int * return_status) { Sequence * temp = NULL; int count; sdb->current_source = 0; sdb->sequence_no =0; load_next_fs_SequenceDB(sdb); if( sdb->seq_start != -1 && sdb->seq_end != -1 ) { for(count=0;count <= sdb->seq_start;count++) { temp = reload_SequenceDB(temp,sdb,return_status); } return temp; } return reload_SequenceDB(NULL,sdb,return_status); } %func top level function that reloads a sequence database %arg last w previous sequence to be used: will simply be freed at the moment sdb sequence database return_status w returns the database status as found in database.h %% Sequence * reload_SequenceDB(Sequence * last,SequenceDB * sdb,int * return_status) { Sequence * out; int count = 0; /* * free last Sequence: if we did something clever with * memory, this is where we should do it */ if( last != NULL ) free_Sequence(last); /* if there is a seq_end, then see whether this is the end */ if( sdb->seq_end != -1 && sdb->sequence_no == sdb->seq_end ) { /* end */ sdb->current_source = -1; *return_status = DB_RETURN_END; return NULL; } /** see if we can read a Sequence now **/ if( (out = get_next_SequenceDB(sdb)) != NULL ) { *return_status = DB_RETURN_OK; sdb->sequence_no++; return out; } if( SequenceDB_at_end(sdb) == TRUE ) { if( close_last_fs_SequenceDB(sdb) == FALSE ) { warn("On file source [%d] [%s] could not close",sdb->current_source,sdb->fs[sdb->current_source]->filename); *return_status = DB_RETURN_ERROR; return NULL; } *return_status = DB_RETURN_END; return NULL; } /** ok, see if we can swap FileSources then **/ for(;;) { if( close_last_fs_SequenceDB(sdb) == FALSE ) { warn("On file source [%d] [%s] could not close",sdb->current_source,sdb->fs[sdb->current_source]->filename); *return_status = DB_RETURN_ERROR; return NULL; } if( load_next_fs_SequenceDB(sdb) == FALSE ) { warn("On file source [%d] [%s] could not open the file",sdb->current_source+1,sdb->fs[sdb->current_source+1]->filename); *return_status = DB_RETURN_ERROR; return NULL; } if( (out = get_next_SequenceDB(sdb)) != NULL ) { *return_status = DB_RETURN_OK; return out; } count++; warn("Ok, don't like this, just loaded the next Filesource, and got no sequence. Nope!"); if( SequenceDB_at_end(sdb) == TRUE ) { *return_status = DB_RETURN_END; return NULL; } if( count > 10 ) { /*** break out of infinite loop ***/ warn("Too many failed reloads of databases, going to fail"); *return_status = DB_RETURN_ERROR; return NULL; } } /** back for for(;;) **/ } %func Main switch around formats %type internal %% Sequence * get_next_SequenceDB(SequenceDB * sdb) { /* remember the byte position now */ sdb->byte_position = ftell(sdb->current_file); switch (sdb->fs[sdb->current_source]->format) { case SEQ_DB_FASTA : return read_fasta_Sequence(sdb->current_file); default : warn("Unknown SequenceDB type [%d]",sdb->fs[sdb->current_source]->format); return NULL; } } %func Tells you if the SequenceDB is actually ended in terms of no more FileSources to eat through %type internal %% boolean SequenceDB_at_end(SequenceDB * sdb) { if( sdb->current_source == -1 ) { warn("Bad bug: asking when it has finished when you have not init'd seqdb %s",sdb->name); return TRUE; } if( sdb->current_source+1 < sdb->len ) { return FALSE; } return TRUE; } %func Opens or attaches next FileSource stream Does not close anything - use /close_last_fs_SequenceDB %type internal %% boolean load_next_fs_SequenceDB(SequenceDB * sdb) { FileSource * fs; if( sdb->current_source == -1 ) { warn("Bad bug: trying to close last source when you have not init'd seqdb %s",sdb->name); return FALSE; } if( sdb->current_source >= sdb->len ) { warn("Bad bug. Someone is trying to load the next fs file when there are none (has not tested with SequenceDB_at_end...). So. I will fail, but database is actually at the end"); return FALSE; } fs = sdb->fs[sdb->current_source]; if( fs->filename != NULL ) { if( (sdb->current_file = openfile(fs->filename,"r")) == NULL ) { warn("Could not open file [%s] for database [%s]",fs->filename,sdb->name); return FALSE; } } else { sdb->current_file = fs->input; } return TRUE; } %func closes the last FileSource: checks if it was a straight stream (in which case does not close) %type internal %% boolean close_last_fs_SequenceDB(SequenceDB * sdb) { FileSource * fs; if( sdb->current_source == -1 ) { warn("Bad bug: trying to close last source when you have not init'd seqdb %s",sdb->name); return FALSE; } fs = sdb->fs[sdb->current_source]; if( fs->filename != NULL ) { fclose(sdb->current_file); } else if( fs->input != NULL ) { warn("Can't handle closes on streams yet. Not sure what to do!"); } sdb->current_source++; return TRUE; } /*** I/O ****/ %func makes a SequencDB from a straight file stream. This means SequenceDB will *not* close it when the SequenceDB is closed. %arg input r filestream format format as defined by /word_to_format %% SequenceDB * SequenceDB_from_FILE_and_format(FILE * input,int format) { SequenceDB * out; FileSource * fs; out = SequenceDB_alloc_len(1); fs = FileSource_from_FILE_and_format(input,format); add_SequenceDB(out,fs); return out; } %func Makes a file source from a straigth stream %type internal %% FileSource * FileSource_from_FILE_and_format(FILE * input,int format) { FileSource * fs; fs = FileSource_alloc(); fs->input = input; fs->format = format; return fs; } %func pre-packed single fasta file db %arg filename name of fastadb %% SequenceDB * single_fasta_SequenceDB(char * filename) { SequenceDB * out; FileSource * fs; if( touchfile(filename) == FALSE) { warn("Cannot make SequenceDB from an unopenable fileanme [%s]",filename); return NULL; } fs = FileSource_alloc(); fs->filename = stringalloc(filename); fs->format = SEQ_DB_FASTA; out = SequenceDB_alloc_len(1); out->seq_start = -1; out->seq_end = -1; add_SequenceDB(out,fs); return out; } %func Reads a SequenceDB definition from seqdb ... endseqdb %arg line starting line (seqdb line) ifp file input %% SequenceDB * read_SequenceDB_line(char * line,FILE * ifp) { SequenceDB * out = NULL; FileSource * fs; char buffer[MAXLINE]; char * runner; if( strstartcmp(line,"seqdb") != 0 ) { warn("Attempting to read a sequence line without a seqdb start"); return NULL; } runner = strtok(line,spacestr); runner = strtok(line,spacestr); if( runner == NULL ) { out->name = stringalloc("UnNamedDatabase"); } else out->name = stringalloc(runner); out = SequenceDB_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ){ if( strstartcmp(buffer,"#") == 0 ) continue; if( strstartcmp(buffer,"end") == 0 ) break; fs = FileSource_from_line(buffer); if( fs != NULL ) add_SequenceDB(out,fs); } return out; } %func converts char * to format for SequenceDB FileSources %% int word_to_format(char * word) { if( strcmp(word,"fasta") == 0 ) { return SEQ_DB_FASTA; } return SEQ_DB_UNKNOWN; } %func Reads line filename format type where format is determined by /word_to_format and type is protein/dna %type internal %% FileSource * FileSource_from_line(char * line) { FileSource * out; char * runner; char * run2; char * run3; runner = strtok(line,spacestr); run2 = strtok(line,spacestr); run3 = strtok(line,spacestr); if( runner == NULL || run2 == NULL || run3 == NULL ) { warn("You have not provided a database source line"); return NULL; } out = FileSource_alloc(); out->filename = stringalloc(runner); if( (out->format = word_to_format(run2)) == SEQ_DB_UNKNOWN) { warn("For filename %s, the format [%s] is unknown to me",runner,run2); } return out; } %} wise-2.4.1/src/dynlibsrc/sequencedb.xs0000644000175000001440000001171210670453713017333 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::SequenceDB boolean close_SequenceDB(last,sdb) Wise2_Sequence * last Wise2_SequenceDB * sdb CODE: RETVAL = Wise2_close_SequenceDB(last,sdb); OUTPUT: RETVAL Wise2_SequenceDB * hard_link_SequenceDB(obj) Wise2_SequenceDB * obj CODE: RETVAL = Wise2_hard_link_SequenceDB(obj); OUTPUT: RETVAL Wise2_SequenceDB * SequenceDB_alloc_std() CODE: RETVAL = Wise2_SequenceDB_alloc_std(); OUTPUT: RETVAL boolean set_name(obj,name) Wise2_SequenceDB * obj char * name CODE: RETVAL = Wise2_replace_name_SequenceDB(obj,Wise2_stringalloc(name)); OUTPUT: RETVAL char * name(obj) Wise2_SequenceDB * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_name_SequenceDB(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_FileSource * fs(obj,i) Wise2_SequenceDB * obj int i INIT: Wise2_FileSource * temp; CODE: temp = Wise2_hard_link_FileSource(Wise2_access_fs_SequenceDB(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_fs(obj) Wise2_SequenceDB * obj CODE: RETVAL = Wise2_length_fs_SequenceDB(obj); OUTPUT: RETVAL int flush_fs(obj) Wise2_SequenceDB * obj CODE: RETVAL = Wise2_flush_SequenceDB(obj); OUTPUT: RETVAL boolean add_fs(obj,add) Wise2_SequenceDB * obj Wise2_FileSource * add CODE: RETVAL = Wise2_add_SequenceDB(obj,Wise2_hard_link_FileSource(add)); OUTPUT: RETVAL boolean set_current_source(obj,current_source) Wise2_SequenceDB * obj int current_source CODE: RETVAL = Wise2_replace_current_source_SequenceDB(obj,current_source); OUTPUT: RETVAL int current_source(obj) Wise2_SequenceDB * obj CODE: RETVAL = Wise2_access_current_source_SequenceDB(obj); OUTPUT: RETVAL boolean set_current_file(obj,current_file) Wise2_SequenceDB * obj FILE * current_file CODE: RETVAL = Wise2_replace_current_file_SequenceDB(obj,current_file); OUTPUT: RETVAL FILE * current_file(obj) Wise2_SequenceDB * obj CODE: RETVAL = Wise2_access_current_file_SequenceDB(obj); OUTPUT: RETVAL boolean set_sequence_no(obj,sequence_no) Wise2_SequenceDB * obj int sequence_no CODE: RETVAL = Wise2_replace_sequence_no_SequenceDB(obj,sequence_no); OUTPUT: RETVAL int sequence_no(obj) Wise2_SequenceDB * obj CODE: RETVAL = Wise2_access_sequence_no_SequenceDB(obj); OUTPUT: RETVAL boolean set_byte_position(obj,byte_position) Wise2_SequenceDB * obj int byte_position CODE: RETVAL = Wise2_replace_byte_position_SequenceDB(obj,byte_position); OUTPUT: RETVAL int byte_position(obj) Wise2_SequenceDB * obj CODE: RETVAL = Wise2_access_byte_position_SequenceDB(obj); OUTPUT: RETVAL Wise2_SequenceDB * new(class) char * class PPCODE: Wise2_SequenceDB * out; out = Wise2_SequenceDB_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_SequenceDB * obj CODE: Wise2_free_SequenceDB(obj); void each_fs(obj) Wise2_SequenceDB * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_fs_SequenceDB(obj); for(i=0;i end, truncates end,start and then reverse complements. ie. If you have a coordinate system where reverse sequences are labelled in reverse start/end way, then this routine produces the correct sequence. Argument seq [READ ] sequence that is the source to be truncated [Sequence *] Argument start [READ ] start point [int] Argument end [READ ] end point [int] Return [OWNER] new Sequence which is truncated/reversed [Sequence *] =item translate_Sequence &Wise2::translate(dna,ct) This translates a DNA sequence to a protein. It assummes that it starts at first residue (use trunc_Sequence to chop a sequence up). Argument dna [READ ] DNA sequence to be translated [Sequence *] Argument ct [READ ] Codon table to do codon->aa mapping [CodonTable *] Return [OWNER] new protein sequence [Sequence *] =back wise-2.4.1/src/dynlibsrc/sequence_codon.tex0000644000175000001440000000400610670453713020353 0ustar philippusers\section{sequence_codon} \label{module_sequence_codon} This module only contains factory methods \subsection{sequence_codon factory methods} \subsubsection{reverse_complement_Sequence} \begin{description} \item[External C] {\tt Wise2_reverse_complement_Sequence (seq)} \item[Perl] {\tt &Wise2::reverse_complement_Sequence (seq)} \end{description} Arguments \begin{description} \item[seq] [READ ] Sequence to that is used to reverse (makes a new Sequence) [Sequence *] \item[returns] [OWNER] new Sequence which is reversed [Sequence *] \end{description} This both complements and reverses a sequence, - a common wish! The start/end are correct with respect to the start/end of the sequence (ie start = end, end = start). \subsubsection{magic_trunc_Sequence} \begin{description} \item[External C] {\tt Wise2_magic_trunc_Sequence (seq,start,end)} \item[Perl] {\tt &Wise2::magic_trunc_Sequence (seq,start,end)} \end{description} Arguments \begin{description} \item[seq] [READ ] sequence that is the source to be truncated [Sequence *] \item[start] [READ ] start point [int] \item[end] [READ ] end point [int] \item[returns] [OWNER] new Sequence which is truncated/reversed [Sequence *] \end{description} Clever function for dna sequences. When start < end, truncates normally when start > end, truncates end,start and then reverse complements. ie. If you have a coordinate system where reverse sequences are labelled in reverse start/end way, then this routine produces the correct sequence. \subsubsection{translate_Sequence} \begin{description} \item[External C] {\tt Wise2_translate_Sequence (dna,ct)} \item[Perl] {\tt &Wise2::translate (dna,ct)} \end{description} Arguments \begin{description} \item[dna] [READ ] DNA sequence to be translated [Sequence *] \item[ct] [READ ] Codon table to do codon->aa mapping [CodonTable *] \item[returns] [OWNER] new protein sequence [Sequence *] \end{description} This translates a DNA sequence to a protein. It assummes that it starts at first residue (use trunc_Sequence to chop a sequence up). wise-2.4.1/src/dynlibsrc/randomdb.pod0000644000175000001440000001772510670453712017144 0ustar philippusers=head1 NAME randomdb module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item RandomProteinDB =item RandomDNADB =back =head1 DESCRIPTION =head2 Object RandomProteinDB =over =item use_flat_length Type [boolean] Scalar No documentation =item length Type [int] Scalar No documentation =item length_dist Type [Histogram *] Scalar No documentation =item emission Type [RandomModel *] Scalar No documentation =item num Type [int] Scalar No documentation =back No documentation for RandomProteinDB =head2 Member functions of RandomProteinDB =over =item hard_link_RandomProteinDB &Wise2::RandomProteinDB::hard_link_RandomProteinDB(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [RandomProteinDB *] Return [UNKN ] Undocumented return value [RandomProteinDB *] =item alloc &Wise2::RandomProteinDB::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [RandomProteinDB *] =item set_use_flat_length &Wise2::RandomProteinDB::set_use_flat_length(obj,use_flat_length) Replace member variable use_flat_length For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomProteinDB *] Argument use_flat_length [OWNER] New value of the variable [boolean] Return [SOFT ] member variable use_flat_length [boolean] =item use_flat_length &Wise2::RandomProteinDB::use_flat_length(obj) Access member variable use_flat_length For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomProteinDB *] Return [SOFT ] member variable use_flat_length [boolean] =item set_length &Wise2::RandomProteinDB::set_length(obj,length) Replace member variable length For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomProteinDB *] Argument length [OWNER] New value of the variable [int] Return [SOFT ] member variable length [boolean] =item length &Wise2::RandomProteinDB::length(obj) Access member variable length For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomProteinDB *] Return [SOFT ] member variable length [int] =item set_length_dist &Wise2::RandomProteinDB::set_length_dist(obj,length_dist) Replace member variable length_dist For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomProteinDB *] Argument length_dist [OWNER] New value of the variable [Histogram *] Return [SOFT ] member variable length_dist [boolean] =item length_dist &Wise2::RandomProteinDB::length_dist(obj) Access member variable length_dist For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomProteinDB *] Return [SOFT ] member variable length_dist [Histogram *] =item set_emission &Wise2::RandomProteinDB::set_emission(obj,emission) Replace member variable emission For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomProteinDB *] Argument emission [OWNER] New value of the variable [RandomModel *] Return [SOFT ] member variable emission [boolean] =item emission &Wise2::RandomProteinDB::emission(obj) Access member variable emission For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomProteinDB *] Return [SOFT ] member variable emission [RandomModel *] =item set_num &Wise2::RandomProteinDB::set_num(obj,num) Replace member variable num For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomProteinDB *] Argument num [OWNER] New value of the variable [int] Return [SOFT ] member variable num [boolean] =item num &Wise2::RandomProteinDB::num(obj) Access member variable num For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomProteinDB *] Return [SOFT ] member variable num [int] =back =head2 Object RandomDNADB =over =item use_flat_length Type [boolean] Scalar No documentation =item length Type [int] Scalar No documentation =item length_dist Type [Histogram *] Scalar No documentation =item emission Type [RandomModelDNA *] Scalar No documentation =item num Type [int] Scalar No documentation =back No documentation for RandomDNADB =head2 Member functions of RandomDNADB =over =item hard_link_RandomDNADB &Wise2::RandomDNADB::hard_link_RandomDNADB(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [RandomDNADB *] Return [UNKN ] Undocumented return value [RandomDNADB *] =item alloc &Wise2::RandomDNADB::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [RandomDNADB *] =item set_use_flat_length &Wise2::RandomDNADB::set_use_flat_length(obj,use_flat_length) Replace member variable use_flat_length For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomDNADB *] Argument use_flat_length [OWNER] New value of the variable [boolean] Return [SOFT ] member variable use_flat_length [boolean] =item use_flat_length &Wise2::RandomDNADB::use_flat_length(obj) Access member variable use_flat_length For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomDNADB *] Return [SOFT ] member variable use_flat_length [boolean] =item set_length &Wise2::RandomDNADB::set_length(obj,length) Replace member variable length For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomDNADB *] Argument length [OWNER] New value of the variable [int] Return [SOFT ] member variable length [boolean] =item length &Wise2::RandomDNADB::length(obj) Access member variable length For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomDNADB *] Return [SOFT ] member variable length [int] =item set_length_dist &Wise2::RandomDNADB::set_length_dist(obj,length_dist) Replace member variable length_dist For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomDNADB *] Argument length_dist [OWNER] New value of the variable [Histogram *] Return [SOFT ] member variable length_dist [boolean] =item length_dist &Wise2::RandomDNADB::length_dist(obj) Access member variable length_dist For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomDNADB *] Return [SOFT ] member variable length_dist [Histogram *] =item set_emission &Wise2::RandomDNADB::set_emission(obj,emission) Replace member variable emission For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomDNADB *] Argument emission [OWNER] New value of the variable [RandomModelDNA *] Return [SOFT ] member variable emission [boolean] =item emission &Wise2::RandomDNADB::emission(obj) Access member variable emission For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomDNADB *] Return [SOFT ] member variable emission [RandomModelDNA *] =item set_num &Wise2::RandomDNADB::set_num(obj,num) Replace member variable num For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomDNADB *] Argument num [OWNER] New value of the variable [int] Return [SOFT ] member variable num [boolean] =item num &Wise2::RandomDNADB::num(obj) Access member variable num For use principly by API functions Argument obj [UNKN ] Object holding the variable [RandomDNADB *] Return [SOFT ] member variable num [int] =back wise-2.4.1/src/dynlibsrc/randomdb.tex0000644000175000001440000000253410670453712017152 0ustar philippusers\section{randomdb} \label{module_randomdb} This module contains the following objects \begin{itemize} \item \ref{object_RandomProteinDB} RandomProteinDB \item \ref{object_RandomDNADB} RandomDNADB \end{itemize} \subsection{Object RandomProteinDB} \label{object_RandomProteinDB} The RandomProteinDB object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{use_flat_length} Type [boolean : Scalar] No documentation \item{length} Type [int : Scalar] No documentation \item{length_dist} Type [Histogram * : Scalar] No documentation \item{emission} Type [RandomModel * : Scalar] No documentation \item{num} Type [int : Scalar] No documentation \end{description} No documentation for RandomProteinDB Member functions of RandomProteinDB \subsection{Object RandomDNADB} \label{object_RandomDNADB} The RandomDNADB object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{use_flat_length} Type [boolean : Scalar] No documentation \item{length} Type [int : Scalar] No documentation \item{length_dist} Type [Histogram * : Scalar] No documentation \item{emission} Type [RandomModelDNA * : Scalar] No documentation \item{num} Type [int : Scalar] No documentation \end{description} No documentation for RandomDNADB Member functions of RandomDNADB wise-2.4.1/src/dynlibsrc/packaln.typemap0000644000175000001440000000074010670453712017651 0ustar philippusers TYPEMAP Wise2_PackAln * T_Wise2_PackAln INPUT T_Wise2_PackAln $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_PackAln *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_PackAln sv_setref_pv($arg, "Wise2::PackAln", (void*) $var); TYPEMAP Wise2_PackAlnUnit * T_Wise2_PackAlnUnit INPUT T_Wise2_PackAlnUnit $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_PackAlnUnit *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_PackAlnUnit sv_setref_pv($arg, "Wise2::PackAlnUnit", (void*) $var); wise-2.4.1/src/dynlibsrc/transcript.typemap0000644000175000001440000000071010670453713020427 0ustar philippusers TYPEMAP Wise2_Exon * T_Wise2_Exon INPUT T_Wise2_Exon $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_Exon *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_Exon sv_setref_pv($arg, "Wise2::Exon", (void*) $var); TYPEMAP Wise2_Transcript * T_Wise2_Transcript INPUT T_Wise2_Transcript $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_Transcript *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_Transcript sv_setref_pv($arg, "Wise2::Transcript", (void*) $var); wise-2.4.1/src/dynlibsrc/compmat.c0000644000175000001440000004630310670453712016450 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "compmat.h" /* Function: simple_CompProb(match,rnd) * * Descrip: Makes a simple CompProb matrix * * * Arg: match [UNKN ] Undocumented argument [Probability] * Arg: rnd [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [CompProb *] * */ # line 50 "compmat.dy" CompProb * simple_CompProb(Probability match,Probability rnd) { CompProb * p; Probability rem; int i,j; p = CompProb_alloc(); rem = (1.0-match)/20; for(i=0;i<26;i++) { for(j=i;j<26;j++) { if( i == j ) { p->comp[i][j] = match/rnd; } else { p->comp[i][j] = rem/rnd; p->comp[j][i] = rem/rnd; } } } return p; } /* Function: fold_column_RandomModel_CompProb(cp,rm) * * Descrip: Folds a random model in over the columns * * * Arg: cp [UNKN ] Undocumented argument [CompProb *] * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * */ # line 76 "compmat.dy" void fold_column_RandomModel_CompProb(CompProb * cp,RandomModel * rm) { int i,j; for(i=0;i<26;i++) { for(j=0;j<26;j++) { if( rm->aminoacid[j] < 0.00000000000001 ) { continue; } cp->comp[i][j] = cp->comp[i][j] / rm->aminoacid[j]; } } } /* Function: simple_aa_CompProb(match,set,rnd) * * Descrip: Makes a simple CompProb with simple aa rules * * * Arg: match [UNKN ] Undocumented argument [Probability] * Arg: set [UNKN ] Undocumented argument [Probability] * Arg: rnd [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [CompProb *] * */ # line 94 "compmat.dy" CompProb * simple_aa_CompProb(Probability match,Probability set,Probability rnd) { CompProb * p; Probability rem; int i,j,k; char * aa_set[] = { "FYW","LIV","RK","DE" }; p = CompProb_alloc(); rem = (1.0-match)/20; for(i=0;i<26;i++) { for(j=i;j<26;j++) { if( i == j ) { p->comp[i][j] = match/rnd; } else { for( k = 0;k<4;k++) { if( strchr(aa_set[k],'A'+i) != NULL && strchr(aa_set[k],'A'+j) != NULL ) { p->comp[i][j] = set/rnd; p->comp[j][i] = set/rnd; fprintf(stderr,"Setting %c,%c to %.2f\n",'A'+i,'A'+j,set/rnd); } else { p->comp[i][j] = rem/rnd; p->comp[j][i] = rem/rnd; } } } } } return p; } /* Function: CompMat_from_CompProb(cp) * * Descrip: Maps a CompProb to a CompMat going through * Probability2Score * * * Arg: cp [UNKN ] Undocumented argument [CompProb *] * * Return [UNKN ] Undocumented return value [CompMat *] * */ # line 130 "compmat.dy" CompMat * CompMat_from_CompProb(CompProb * cp) { int i,j; CompMat * cm; cm = CompMat_alloc(); for(i=0;i<26;i++) { for(j=0;j<26;j++) { cm->comp[i][j] = Probability2Score(cp->comp[i][j]); } } return cm; } /* Function: CompProb_from_halfbit(cm) * * Descrip: Maps a halfbit matrix to a prob matrix by rebasing * etc. * * *Really* not sensible! * * * Arg: cm [UNKN ] Undocumented argument [CompMat *] * * Return [UNKN ] Undocumented return value [CompProb *] * */ # line 153 "compmat.dy" CompProb * CompProb_from_halfbit(CompMat * cm) { CompProb * out; int i,j; out = CompProb_alloc(); for(i=0;i<26;i++) for(j=0;j<26;j++) out->comp[i][j] = halfbit2Probability(cm->comp[i][j]); return out; } /* Function: CompMat_from_halfbit(cm) * * Descrip: flips a halfbit based matrix (eg, blosum62) into a score * based matrix just by rebasing the log etc. * * Not a sensible function ... * * * * Arg: cm [UNKN ] Undocumented argument [CompMat *] * * Return [UNKN ] Undocumented return value [CompMat *] * */ # line 173 "compmat.dy" CompMat * CompMat_from_halfbit(CompMat * cm) { CompMat * out; int i,j; out = CompMat_alloc(); for(i=0;i<26;i++) for(j=0;j<26;j++) out->comp[i][j] = Probability2Score(halfbit2Probability(cm->comp[i][j])); return out; } /* Function: factor_CompMat(cm,factor) * * Descrip: multiples all the scores by the amount * * * Arg: cm [UNKN ] compmat object [CompMat *] * Arg: factor [UNKN ] amount to multiple by [int] * */ # line 193 "compmat.dy" void factor_CompMat(CompMat * cm,int factor) { int i,j; for(i=0;i<26;i++) for(j=0;j<26;j++) cm->comp[i][j] *= factor; } /* Function: fail_safe_CompMat_access(cm,aa1,aa2) * * Descrip: gives the fail form of the macro CompMat_AAMATCH which * checks that aa1 and a2 are sensible and that cm is not NULL. * * * Arg: cm [UNKN ] compmat object [CompMat *] * Arg: aa1 [UNKN ] first amino acid [int] * Arg: aa2 [UNKN ] second amino acid [int] * * Return [UNKN ] Undocumented return value [Score] * */ # line 212 "compmat.dy" Score fail_safe_CompMat_access(CompMat * cm,int aa1,int aa2) { if( cm == NULL) { warn("Attempting to access NULL CompMat."); return 0; } if( aa1 < 0 || aa1 >= 26 || aa2 < 0 || aa2 > 26) { warn("Attempting to access CompMat with aminoacid numbers %d:%d (they must be bound between 0:26, returning 0 here",aa1,aa2); return 0; } else return cm->comp[aa1][aa2]; } /* Function: write_Blast_CompMat(cm,ofp) * * Descrip: writes a protien CompMat with a standard * alphabet. * * * Arg: cm [UNKN ] CompMat object [CompMat *] * Arg: ofp [UNKN ] file to output [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 234 "compmat.dy" boolean write_Blast_CompMat(CompMat * cm,FILE * ofp) { return write_Blast_CompMat_alphabet(cm,"ARNDCQEGHILKMFPSTWYVBZX",ofp); } /* Function: bad_CompMat_alphabet(al) * * Descrip: checks that this string is ok for BLAST alphabet mappings. * * * Arg: al [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 243 "compmat.dy" boolean bad_CompMat_alphabet(char * al) { char * runner; for(runner=al;*runner;runner++) if( !isalpha((int)*runner) && toupper((int)*runner) != *runner ) { warn("Attempting to use [%s] as a CompMat alphabet: needs all upper case, no spaced letters",al); return TRUE; } return FALSE; } /* Function: write_Blast_CompMat_alphabet(cm,alphabet,ofp) * * Descrip: actualy writes out the Blast CFormat. The alphabet is * what order you want the amino acids. If you want the * standard format use /write_Blast_CompMat * * * Arg: cm [UNKN ] comp mat object [CompMat *] * Arg: alphabet [UNKN ] string for alphabet to be used [char *] * Arg: ofp [UNKN ] fileoutput [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 264 "compmat.dy" boolean write_Blast_CompMat_alphabet(CompMat * cm,char * alphabet,FILE * ofp) { char * runner; char * run2; int minnumbers[26]; int len; int i; int min; if( bad_CompMat_alphabet(alphabet) == TRUE ) return FALSE; /* warning already issued */ fprintf(ofp,"# File made by *Wise CompMat library module\n"); fprintf(ofp,"# Comparison matrix in BLAST format\n"); fprintf(ofp,"# Usually matrices are given in half-bit units\n"); fprintf(ofp,"# First line is alphabet, the * column is the lowest score\n"); fprintf(ofp,"# File Created [%s]\n",now_string()); fprintf(ofp,"# Matrix name [%s]\n",cm->name == NULL ? "No Name" : cm->name); /*** print out alphabet wit correct spacing ***/ fprintf(ofp," %c",alphabet[0]); for(runner=alphabet+1;*runner;runner++) fprintf(ofp," %c",*runner); fprintf(ofp," *\n"); /*** print out each row: remember the minimum number for printing later **/ for(runner=alphabet,len=0;*runner;runner++) { min = cm->comp[*runner-'A'][0]; fprintf(ofp,"%- d",cm->comp[*runner-'A'][0]); for(run2=alphabet+1;*run2;run2++) { fprintf(ofp," %- d",cm->comp[*runner-'A'][*run2-'A']); if( cm->comp[*runner-'A'][*run2-'A'] < min ) min = cm->comp[*runner-'A'][*run2-'A']; } minnumbers[len++] = min; fprintf(ofp," % d\n",min); } /*** final row... * ***/ fprintf(ofp,"% d",minnumbers[0]); for(i=1;iname = stringalloc(filename); } fclose(ifp); return out; } /* Function: read_Blast_CompMat(ifp) * * Descrip: reads a BLAST format matrix and * allocates a new ComMat structure. * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [CompMat *] * */ # line 350 "compmat.dy" CompMat * read_Blast_CompMat(FILE * ifp) { char buffer[MAXLINE]; int alphabet[MAXLINE]; char * runner; int len; int linenum; int row; CompMat * out; /*** Skip over # lines... read first line: is alphabet ie A R T G .... * ***/ while( fgets(buffer,MAXLINE,ifp) != NULL) if( buffer[0] != '#') break; /** loop over line, getting letters: warn if longer than one, or not a letter **/ for(len=0,runner=strtok(buffer,spacestr);runner != NULL;runner=strtok(NULL,spacestr)) { if( *runner == '*' ) break; /* end column */ if( !isalpha((int)*runner) || strlen(runner) > 1 ) { warn("In read Blast comp mat, probably an error: trying to interpret [%s] as an amino acid",runner); return NULL; } alphabet[len++] = toupper((int)*runner) -'A'; } out = blank_CompMat(); linenum = 0; /** get len lines, each line, get len numbers and put them away **/ while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( linenum >= len ) break; for(runner=strtok(buffer,spacestr),row = 0;runner != NULL && row < len;runner=strtok(NULL,spacestr),row++) { if( is_integer_string(runner,&out->comp[alphabet[linenum]][alphabet[row]]) == FALSE ) { warn("In read Blast comp mat, probably an error: trying to interpret [%s] as a number ... continuing",runner); } } linenum++; } return out; } /* Function: read_Blast_file_CompProb(filename) * * Descrip: Reads a BLAST format comp prob from file * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [CompProb *] * */ # line 413 "compmat.dy" CompProb * read_Blast_file_CompProb(char * filename) { FILE * ifp; CompProb * out; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s for compprob",filename); return NULL; } out = read_Blast_CompProb(ifp); fclose(ifp); return out; } /* Function: read_Blast_CompProb(ifp) * * Descrip: reads a BLAST format matrix and * allocates a new CompProb structure. * * * Arg: ifp [READ ] file input [FILE *] * * Return [UNKN ] newly allocated CompProb [CompProb *] * */ # line 440 "compmat.dy" CompProb * read_Blast_CompProb(FILE * ifp) { char buffer[MAXLINE]; int alphabet[MAXLINE]; char * runner; int len; int linenum; int row; CompProb * out; /*** Skip over # lines... read first line: is alphabet ie A R T G .... * ***/ while( fgets(buffer,MAXLINE,ifp) != NULL) if( buffer[0] != '#') break; /** loop over line, getting letters: warn if longer than one, or not a letter **/ for(len=0,runner=strtok(buffer,spacestr);runner != NULL;runner=strtok(NULL,spacestr)) { if( *runner == '*' ) break; /* end column */ if( !isalpha((int)*runner) || strlen(runner) > 1 ) { warn("In read Blast comp mat, probably an error: trying to interpret [%s] as an amino acid",runner); return NULL; } alphabet[len++] = toupper((int)*runner) -'A'; } out = blank_CompProb(); linenum = 0; /** get len lines, each line, get len numbers and put them away **/ while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"//") == 0 ) break; if( linenum >= len ) break; for(runner=strtok(buffer,spacestr),row = 0;runner != NULL && row < len;runner=strtok(NULL,spacestr),row++) { if( is_double_string(runner,&out->comp[alphabet[linenum]][alphabet[row]]) == FALSE ) { warn("In read Blast comp prob, probably an error: trying to interpret [%s] as a number ... continuing",runner); } } linenum++; } return out; } /* Function: blank_CompMat(void) * * Descrip: makes a 0,0 matrix * * * * Return [UNKN ] Undocumented return value [CompMat *] * */ # line 503 "compmat.dy" CompMat * blank_CompMat(void) { register int i; register int j; CompMat * out; out = CompMat_alloc(); if( out == NULL) return NULL; for(i=0;i<26;i++) for(j=0;j<26;j++) out->comp[i][j] = 0; return out; } /* Function: blank_CompProb(void) * * Descrip: makes a 1.0 prob matrix * * * * Return [UNKN ] Undocumented return value [CompProb *] * */ # line 524 "compmat.dy" CompProb * blank_CompProb(void) { register int i; register int j; CompProb * out; out = CompProb_alloc(); if( out == NULL) return NULL; for(i=0;i<26;i++) for(j=0;j<26;j++) out->comp[i][j] = 1.0; return out; } # line 594 "compmat.c" /* Function: hard_link_CompProb(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CompProb *] * * Return [UNKN ] Undocumented return value [CompProb *] * */ CompProb * hard_link_CompProb(CompProb * obj) { if( obj == NULL ) { warn("Trying to hard link to a CompProb object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CompProb_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CompProb *] * */ CompProb * CompProb_alloc(void) { CompProb * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CompProb *) ckalloc (sizeof(CompProb))) == NULL) { warn("CompProb_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* comp[26][26] is an array: no default possible */ out->name = NULL; return out; } /* Function: free_CompProb(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CompProb *] * * Return [UNKN ] Undocumented return value [CompProb *] * */ CompProb * free_CompProb(CompProb * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CompProb obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: hard_link_CompMat(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CompMat *] * * Return [UNKN ] Undocumented return value [CompMat *] * */ CompMat * hard_link_CompMat(CompMat * obj) { if( obj == NULL ) { warn("Trying to hard link to a CompMat object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CompMat_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CompMat *] * */ CompMat * CompMat_alloc(void) { CompMat * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CompMat *) ckalloc (sizeof(CompMat))) == NULL) { warn("CompMat_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* comp[26][26] is an array: no default possible */ out->name = NULL; return out; } /* Function: free_CompMat(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CompMat *] * * Return [UNKN ] Undocumented return value [CompMat *] * */ CompMat * free_CompMat(CompMat * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CompMat obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: replace_name_CompMat(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [CompMat *] * Arg: name [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable name [boolean] * */ boolean replace_name_CompMat(CompMat * obj,char * name) { if( obj == NULL) { warn("In replacement function name for object CompMat, got a NULL object"); return FALSE; } obj->name = name; return TRUE; } /* Function: access_name_CompMat(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [CompMat *] * * Return [SOFT ] member variable name [char *] * */ char * access_name_CompMat(CompMat * obj) { if( obj == NULL) { warn("In accessor function name for object CompMat, got a NULL object"); return NULL; } return obj->name; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/compmat.h0000644000175000001440000002543710670453712016462 0ustar philippusers#ifndef DYNAMITEcompmatHEADERFILE #define DYNAMITEcompmatHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "probability.h" #include "randommodel.h" #define CompMat_AAMATCH(comp_mat,aa1,aa2) (comp_mat->comp[aa1][aa2]) /* Object CompProb * * Descrip: The probabilistic form of CompMat * * */ struct Wise2_CompProb { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability comp[26][26]; char * name; } ; /* CompProb defined */ #ifndef DYNAMITE_DEFINED_CompProb typedef struct Wise2_CompProb Wise2_CompProb; #define CompProb Wise2_CompProb #define DYNAMITE_DEFINED_CompProb #endif /* Object CompMat * * Descrip: This object stores BLOSUM and PAM * comparison matrices. It stores them as * scores: NB - this means probabilistically * we are talking about some arbitary base of * log which is really annoying. * * */ struct Wise2_CompMat { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score comp[26][26]; char * name; /* if any, could be NULL */ } ; /* CompMat defined */ #ifndef DYNAMITE_DEFINED_CompMat typedef struct Wise2_CompMat Wise2_CompMat; #define CompMat Wise2_CompMat #define DYNAMITE_DEFINED_CompMat #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: simple_CompProb(match,rnd) * * Descrip: Makes a simple CompProb matrix * * * Arg: match [UNKN ] Undocumented argument [Probability] * Arg: rnd [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [CompProb *] * */ CompProb * Wise2_simple_CompProb(Probability match,Probability rnd); #define simple_CompProb Wise2_simple_CompProb /* Function: fold_column_RandomModel_CompProb(cp,rm) * * Descrip: Folds a random model in over the columns * * * Arg: cp [UNKN ] Undocumented argument [CompProb *] * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * */ void Wise2_fold_column_RandomModel_CompProb(CompProb * cp,RandomModel * rm); #define fold_column_RandomModel_CompProb Wise2_fold_column_RandomModel_CompProb /* Function: simple_aa_CompProb(match,set,rnd) * * Descrip: Makes a simple CompProb with simple aa rules * * * Arg: match [UNKN ] Undocumented argument [Probability] * Arg: set [UNKN ] Undocumented argument [Probability] * Arg: rnd [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [CompProb *] * */ CompProb * Wise2_simple_aa_CompProb(Probability match,Probability set,Probability rnd); #define simple_aa_CompProb Wise2_simple_aa_CompProb /* Function: CompMat_from_CompProb(cp) * * Descrip: Maps a CompProb to a CompMat going through * Probability2Score * * * Arg: cp [UNKN ] Undocumented argument [CompProb *] * * Return [UNKN ] Undocumented return value [CompMat *] * */ CompMat * Wise2_CompMat_from_CompProb(CompProb * cp); #define CompMat_from_CompProb Wise2_CompMat_from_CompProb /* Function: CompProb_from_halfbit(cm) * * Descrip: Maps a halfbit matrix to a prob matrix by rebasing * etc. * * *Really* not sensible! * * * Arg: cm [UNKN ] Undocumented argument [CompMat *] * * Return [UNKN ] Undocumented return value [CompProb *] * */ CompProb * Wise2_CompProb_from_halfbit(CompMat * cm); #define CompProb_from_halfbit Wise2_CompProb_from_halfbit /* Function: CompMat_from_halfbit(cm) * * Descrip: flips a halfbit based matrix (eg, blosum62) into a score * based matrix just by rebasing the log etc. * * Not a sensible function ... * * * * Arg: cm [UNKN ] Undocumented argument [CompMat *] * * Return [UNKN ] Undocumented return value [CompMat *] * */ CompMat * Wise2_CompMat_from_halfbit(CompMat * cm); #define CompMat_from_halfbit Wise2_CompMat_from_halfbit /* Function: factor_CompMat(cm,factor) * * Descrip: multiples all the scores by the amount * * * Arg: cm [UNKN ] compmat object [CompMat *] * Arg: factor [UNKN ] amount to multiple by [int] * */ void Wise2_factor_CompMat(CompMat * cm,int factor); #define factor_CompMat Wise2_factor_CompMat /* Function: fail_safe_CompMat_access(cm,aa1,aa2) * * Descrip: gives the fail form of the macro CompMat_AAMATCH which * checks that aa1 and a2 are sensible and that cm is not NULL. * * * Arg: cm [UNKN ] compmat object [CompMat *] * Arg: aa1 [UNKN ] first amino acid [int] * Arg: aa2 [UNKN ] second amino acid [int] * * Return [UNKN ] Undocumented return value [Score] * */ Score Wise2_fail_safe_CompMat_access(CompMat * cm,int aa1,int aa2); #define fail_safe_CompMat_access Wise2_fail_safe_CompMat_access /* Function: write_Blast_CompMat(cm,ofp) * * Descrip: writes a protien CompMat with a standard * alphabet. * * * Arg: cm [UNKN ] CompMat object [CompMat *] * Arg: ofp [UNKN ] file to output [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_write_Blast_CompMat(CompMat * cm,FILE * ofp); #define write_Blast_CompMat Wise2_write_Blast_CompMat /* Function: write_Blast_CompMat_alphabet(cm,alphabet,ofp) * * Descrip: actualy writes out the Blast CFormat. The alphabet is * what order you want the amino acids. If you want the * standard format use /write_Blast_CompMat * * * Arg: cm [UNKN ] comp mat object [CompMat *] * Arg: alphabet [UNKN ] string for alphabet to be used [char *] * Arg: ofp [UNKN ] fileoutput [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_write_Blast_CompMat_alphabet(CompMat * cm,char * alphabet,FILE * ofp); #define write_Blast_CompMat_alphabet Wise2_write_Blast_CompMat_alphabet /* Function: read_Blast_file_CompMat(filename) * * Descrip: Opens file, reads matrix, closes file. * calls /read_Blast_CompMat for the actual format * reading. Uses /openfile to open the file, * so will open from config files. * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [CompMat *] * */ CompMat * Wise2_read_Blast_file_CompMat(char * filename); #define read_Blast_file_CompMat Wise2_read_Blast_file_CompMat /* Function: read_Blast_CompMat(ifp) * * Descrip: reads a BLAST format matrix and * allocates a new ComMat structure. * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [CompMat *] * */ CompMat * Wise2_read_Blast_CompMat(FILE * ifp); #define read_Blast_CompMat Wise2_read_Blast_CompMat /* Function: read_Blast_file_CompProb(filename) * * Descrip: Reads a BLAST format comp prob from file * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [CompProb *] * */ CompProb * Wise2_read_Blast_file_CompProb(char * filename); #define read_Blast_file_CompProb Wise2_read_Blast_file_CompProb /* Function: read_Blast_CompProb(ifp) * * Descrip: reads a BLAST format matrix and * allocates a new CompProb structure. * * * Arg: ifp [READ ] file input [FILE *] * * Return [UNKN ] newly allocated CompProb [CompProb *] * */ CompProb * Wise2_read_Blast_CompProb(FILE * ifp); #define read_Blast_CompProb Wise2_read_Blast_CompProb /* Function: blank_CompMat(void) * * Descrip: makes a 0,0 matrix * * * * Return [UNKN ] Undocumented return value [CompMat *] * */ CompMat * Wise2_blank_CompMat(void); #define blank_CompMat Wise2_blank_CompMat /* Function: blank_CompProb(void) * * Descrip: makes a 1.0 prob matrix * * * * Return [UNKN ] Undocumented return value [CompProb *] * */ CompProb * Wise2_blank_CompProb(void); #define blank_CompProb Wise2_blank_CompProb /* Function: hard_link_CompProb(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CompProb *] * * Return [UNKN ] Undocumented return value [CompProb *] * */ CompProb * Wise2_hard_link_CompProb(CompProb * obj); #define hard_link_CompProb Wise2_hard_link_CompProb /* Function: CompProb_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CompProb *] * */ CompProb * Wise2_CompProb_alloc(void); #define CompProb_alloc Wise2_CompProb_alloc /* Function: free_CompProb(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CompProb *] * * Return [UNKN ] Undocumented return value [CompProb *] * */ CompProb * Wise2_free_CompProb(CompProb * obj); #define free_CompProb Wise2_free_CompProb /* Function: hard_link_CompMat(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CompMat *] * * Return [UNKN ] Undocumented return value [CompMat *] * */ CompMat * Wise2_hard_link_CompMat(CompMat * obj); #define hard_link_CompMat Wise2_hard_link_CompMat /* Function: CompMat_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CompMat *] * */ CompMat * Wise2_CompMat_alloc(void); #define CompMat_alloc Wise2_CompMat_alloc /* Function: free_CompMat(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CompMat *] * * Return [UNKN ] Undocumented return value [CompMat *] * */ CompMat * Wise2_free_CompMat(CompMat * obj); #define free_CompMat Wise2_free_CompMat /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_name_CompMat(CompMat * obj,char * name); #define replace_name_CompMat Wise2_replace_name_CompMat char * Wise2_access_name_CompMat(CompMat * obj); #define access_name_CompMat Wise2_access_name_CompMat boolean Wise2_bad_CompMat_alphabet(char * al); #define bad_CompMat_alphabet Wise2_bad_CompMat_alphabet #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/sequencedb.pod0000644000175000001440000002272610670453713017472 0ustar philippusers=head1 NAME sequencedb module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item SequenceDB =item FileSource =back =head1 DESCRIPTION =head2 Object SequenceDB =over =item name Type [char *] Scalar No documentation =item fs Type [FileSource **] List No documentation =item current_source Type [int] Scalar No documentation =item current_file Type [FILE *] Scalar No documentation =item sequence_no Type [int] Scalar No documentation =item byte_position Type [int] Scalar No documentation =item has_warned_single Type [int] Scalar No documentation =item seq_start Type [int] Scalar No documentation =item seq_end Type [int] Scalar No documentation =back This is the basic Sequence database wrapper - it handles all the formats and the on-the-fly indexing. Generally it wont be directly used by an algorithm, which will be using something specific to the sequence type produce complex sequence type objects: ie you will be using proteindb or cdnadb which internally will be using this object =head2 Member functions of SequenceDB =over =item close_SequenceDB &Wise2::SequenceDB::close_SequenceDB(last,sdb) top level function that closes the SequenceDB after the last sequence is read. Argument last [WRITE] Sequence object to be freed [Sequence *] Argument sdb [READ ] database to be closed [SequenceDB *] Return [UNKN ] Undocumented return value [boolean] =item hard_link_SequenceDB &Wise2::SequenceDB::hard_link_SequenceDB(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [SequenceDB *] Return [UNKN ] Undocumented return value [SequenceDB *] =item SequenceDB_alloc_std &Wise2::SequenceDB::SequenceDB_alloc_std(void) Equivalent to SequenceDB_alloc_len(SequenceDBLISTLENGTH) Return [UNKN ] Undocumented return value [SequenceDB *] =item set_name &Wise2::SequenceDB::set_name(obj,name) Replace member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [SequenceDB *] Argument name [OWNER] New value of the variable [char *] Return [SOFT ] member variable name [boolean] =item name &Wise2::SequenceDB::name(obj) Access member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [SequenceDB *] Return [SOFT ] member variable name [char *] =item fs &Wise2::SequenceDB::fs(obj,i) Access members stored in the fs list For use principly by API functions Argument obj [UNKN ] Object holding the list [SequenceDB *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [FileSource *] =item length_fs &Wise2::SequenceDB::length_fs(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [SequenceDB *] Return [UNKN ] length of the list [int] =item flush_fs &Wise2::SequenceDB::flush_fs(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [SequenceDB *] Return [UNKN ] Undocumented return value [int] =item add_fs &Wise2::SequenceDB::add_fs(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [SequenceDB *] Argument add [OWNER] Object to add to the list [FileSource *] Return [UNKN ] Undocumented return value [boolean] =item set_current_source &Wise2::SequenceDB::set_current_source(obj,current_source) Replace member variable current_source For use principly by API functions Argument obj [UNKN ] Object holding the variable [SequenceDB *] Argument current_source [OWNER] New value of the variable [int] Return [SOFT ] member variable current_source [boolean] =item current_source &Wise2::SequenceDB::current_source(obj) Access member variable current_source For use principly by API functions Argument obj [UNKN ] Object holding the variable [SequenceDB *] Return [SOFT ] member variable current_source [int] =item set_current_file &Wise2::SequenceDB::set_current_file(obj,current_file) Replace member variable current_file For use principly by API functions Argument obj [UNKN ] Object holding the variable [SequenceDB *] Argument current_file [OWNER] New value of the variable [FILE *] Return [SOFT ] member variable current_file [boolean] =item current_file &Wise2::SequenceDB::current_file(obj) Access member variable current_file For use principly by API functions Argument obj [UNKN ] Object holding the variable [SequenceDB *] Return [SOFT ] member variable current_file [FILE *] =item set_sequence_no &Wise2::SequenceDB::set_sequence_no(obj,sequence_no) Replace member variable sequence_no For use principly by API functions Argument obj [UNKN ] Object holding the variable [SequenceDB *] Argument sequence_no [OWNER] New value of the variable [int] Return [SOFT ] member variable sequence_no [boolean] =item sequence_no &Wise2::SequenceDB::sequence_no(obj) Access member variable sequence_no For use principly by API functions Argument obj [UNKN ] Object holding the variable [SequenceDB *] Return [SOFT ] member variable sequence_no [int] =item set_byte_position &Wise2::SequenceDB::set_byte_position(obj,byte_position) Replace member variable byte_position For use principly by API functions Argument obj [UNKN ] Object holding the variable [SequenceDB *] Argument byte_position [OWNER] New value of the variable [int] Return [SOFT ] member variable byte_position [boolean] =item byte_position &Wise2::SequenceDB::byte_position(obj) Access member variable byte_position For use principly by API functions Argument obj [UNKN ] Object holding the variable [SequenceDB *] Return [SOFT ] member variable byte_position [int] =back =head2 Object FileSource =over =item filename Type [char *] Scalar No documentation =item input Type [FILE *] Scalar could be stdin! =item format Type [int] Scalar No documentation =item type Type [int] Scalar No documentation =back This object represents a single file source for a database. At the moment only multiple fasta files are catered for =head2 Member functions of FileSource =over =item hard_link_FileSource &Wise2::FileSource::hard_link_FileSource(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [FileSource *] Return [UNKN ] Undocumented return value [FileSource *] =item alloc &Wise2::FileSource::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [FileSource *] =item set_filename &Wise2::FileSource::set_filename(obj,filename) Replace member variable filename For use principly by API functions Argument obj [UNKN ] Object holding the variable [FileSource *] Argument filename [OWNER] New value of the variable [char *] Return [SOFT ] member variable filename [boolean] =item filename &Wise2::FileSource::filename(obj) Access member variable filename For use principly by API functions Argument obj [UNKN ] Object holding the variable [FileSource *] Return [SOFT ] member variable filename [char *] =item set_input &Wise2::FileSource::set_input(obj,input) Replace member variable input For use principly by API functions Argument obj [UNKN ] Object holding the variable [FileSource *] Argument input [OWNER] New value of the variable [FILE *] Return [SOFT ] member variable input [boolean] =item input &Wise2::FileSource::input(obj) Access member variable input For use principly by API functions Argument obj [UNKN ] Object holding the variable [FileSource *] Return [SOFT ] member variable input [FILE *] =item set_format &Wise2::FileSource::set_format(obj,format) Replace member variable format For use principly by API functions Argument obj [UNKN ] Object holding the variable [FileSource *] Argument format [OWNER] New value of the variable [int] Return [SOFT ] member variable format [boolean] =item format &Wise2::FileSource::format(obj) Access member variable format For use principly by API functions Argument obj [UNKN ] Object holding the variable [FileSource *] Return [SOFT ] member variable format [int] =item set_type &Wise2::FileSource::set_type(obj,type) Replace member variable type For use principly by API functions Argument obj [UNKN ] Object holding the variable [FileSource *] Argument type [OWNER] New value of the variable [int] Return [SOFT ] member variable type [boolean] =item type &Wise2::FileSource::type(obj) Access member variable type For use principly by API functions Argument obj [UNKN ] Object holding the variable [FileSource *] Return [SOFT ] member variable type [int] =back =over =item single_fasta_SequenceDB &Wise2::single_fasta_SequenceDB(filename) pre-packed single fasta file db Argument filename [UNKN ] name of fastadb [char *] Return [UNKN ] Undocumented return value [SequenceDB *] =back wise-2.4.1/src/dynlibsrc/sequencedb.tex0000644000175000001440000000555610670453713017512 0ustar philippusers\section{sequencedb} \label{module_sequencedb} This module contains the following objects \begin{itemize} \item \ref{object_SequenceDB} SequenceDB \item \ref{object_FileSource} FileSource \item This module also contains some factory methods \end{itemize} \subsection{sequencedb factory methods} \subsubsection{single_fasta_SequenceDB} \begin{description} \item[External C] {\tt Wise2_single_fasta_SequenceDB (filename)} \item[Perl] {\tt &Wise2::single_fasta_SequenceDB (filename)} \end{description} Arguments \begin{description} \item[filename] [UNKN ] name of fastadb [char *] \item[returns] [UNKN ] Undocumented return value [SequenceDB *] \end{description} pre-packed single fasta file db \subsection{Object SequenceDB} \label{object_SequenceDB} The SequenceDB object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{name} Type [char * : Scalar] No documentation \item{fs} Type [FileSource ** : List] No documentation \item{current_source} Type [int : Scalar] No documentation \item{current_file} Type [FILE * : Scalar] No documentation \item{sequence_no} Type [int : Scalar] No documentation \item{byte_position} Type [int : Scalar] No documentation \item{has_warned_single} Type [int : Scalar] No documentation \item{seq_start} Type [int : Scalar] No documentation \item{seq_end} Type [int : Scalar] No documentation \end{description} This is the basic Sequence database wrapper - it handles all the formats and the on-the-fly indexing. Generally it wont be directly used by an algorithm, which will be using something specific to the sequence type produce complex sequence type objects: ie you will be using proteindb or cdnadb which internally will be using this object Member functions of SequenceDB \subsubsection{close_SequenceDB} \begin{description} \item[External C] {\tt Wise2_close_SequenceDB (last,sdb)} \item[Perl] {\tt &Wise2::SequenceDB::close_SequenceDB (last,sdb)} \item[Perl-OOP call] {\tt $obj->close_SequenceDB(sdb)} \end{description} Arguments \begin{description} \item[last] [WRITE] Sequence object to be freed [Sequence *] \item[sdb] [READ ] database to be closed [SequenceDB *] \item[returns] [UNKN ] Undocumented return value [boolean] \end{description} top level function that closes the SequenceDB after the last sequence is read. \subsection{Object FileSource} \label{object_FileSource} The FileSource object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{filename} Type [char * : Scalar] No documentation \item{input} Type [FILE * : Scalar] could be stdin! \item{format} Type [int : Scalar] No documentation \item{type} Type [int : Scalar] No documentation \end{description} This object represents a single file source for a database. At the moment only multiple fasta files are catered for Member functions of FileSource wise-2.4.1/src/dynlibsrc/complexconsensi.c0000644000175000001440000004206210670453712020217 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "complexconsensi.h" /* Function: show_ComplexConsensi(cc,*ofp) * * Descrip: shows complexconsensi in vaguely human form * * * Arg: cc [UNKN ] Undocumented argument [ComplexConsensi *] * Arg: *ofp [UNKN ] Undocumented argument [FILE] * */ # line 31 "complexconsensi.dy" void show_ComplexConsensi(ComplexConsensi * cc,FILE *ofp) { register int i; for(i=0;ilen;i++) show_ComplexConsensusWord(cc->ccw[i],ofp); } /* Function: show_ComplexConsensusWord(ccw,ofp) * * Descrip: shows an individual ccword * * * Arg: ccw [UNKN ] Undocumented argument [ComplexConsensusWord *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 45 "complexconsensi.dy" void show_ComplexConsensusWord(ComplexConsensusWord * ccw,FILE * ofp) { fprintf(ofp,"%s %4.4f %d\n",ccw->pattern,ccw->p,ccw->score); } /* Function: word_from_ComplexConsensi(word,cc) * * Descrip: Way of getting probabilities out of a consensus. * If it is in the Consensus, then gets prob, otherwise 0. * * * Arg: word [UNKN ] Undocumented argument [char *] * Arg: cc [UNKN ] Undocumented argument [ComplexConsensi *] * * Return [UNKN ] Undocumented return value [Probability] * */ # line 56 "complexconsensi.dy" Probability word_from_ComplexConsensi(char * word,ComplexConsensi * cc) { ComplexConsensusWord * ccw; ccw = best_ComplexConsensusWord(word,cc); if( ccw == NULL ) return 0.0; return ccw->p; } /* Function: score_from_ComplexConsensi(word,cc) * * Descrip: Way of getting scores out of a consensus. * If it is in the Consensus, then gets score, otherwise NEGI. * * * Arg: word [UNKN ] Undocumented argument [char *] * Arg: cc [UNKN ] Undocumented argument [ComplexConsensi *] * * Return [UNKN ] Undocumented return value [Score] * */ # line 73 "complexconsensi.dy" Score score_from_ComplexConsensi(char * word,ComplexConsensi * cc) { ComplexConsensusWord * ccw; ccw = best_ComplexConsensusWord(word,cc); if( ccw == NULL ) return NEGI; return ccw->score; } /* Function: best_ComplexConsensusWord(word,cc) * * Descrip: Finds the best (highest) match to this word * * * Arg: word [UNKN ] Undocumented argument [char *] * Arg: cc [UNKN ] Undocumented argument [ComplexConsensi *] * * Return [UNKN ] Undocumented return value [ComplexConsensusWord *] * */ # line 89 "complexconsensi.dy" ComplexConsensusWord * best_ComplexConsensusWord(char * word,ComplexConsensi * cc) { register int i; for(i=0;ilen;i++) { if( word_matches_ComplexConsensusWord(word,cc->ccw[i]) == TRUE) return cc->ccw[i]; } return NULL; } /* Function: word_matches_ComplexConsensusWord(word,ccw) * * Descrip: Core of the matching system. Checks that word matches * ComplexConsensusWord. This says that '-' matches anything. * Issues a warning if hits a '\0' in word * * * Arg: word [UNKN ] Undocumented argument [char *] * Arg: ccw [UNKN ] Undocumented argument [ComplexConsensusWord *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 108 "complexconsensi.dy" boolean word_matches_ComplexConsensusWord(char * word,ComplexConsensusWord * ccw) { return strcmp_with_dashes(word,ccw->pattern); } /* Function: strcmp_with_dashes(word,pattern) * * Descrip: The matching 'function' used by * /word_matches_ComplexConsensusWord * * * Arg: word [UNKN ] Undocumented argument [char *] * Arg: pattern [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 118 "complexconsensi.dy" boolean strcmp_with_dashes(char * word,char * pattern) { char * runner; char * base = word; for(runner = pattern;*runner && *word;word++,runner++) { if( *runner == '-') { continue; } if( *runner != *word ) { break; } } if( *word == '\0' && *runner != '\0') { warn("Tried to match a word [%s] which is shorter than the pattern [%s]",base,pattern); return FALSE; } if( *runner == '\0') { /* end of pattern */ return TRUE; } return FALSE; } /************************/ /* I/O */ /************************/ /* Function: read_ComplexConsensi_file(filename) * * Descrip: Reads a file containing the ComplexConsensi. * Not every useful, as most times these consensi * are in one file, with other things * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ # line 161 "complexconsensi.dy" ComplexConsensi * read_ComplexConsensi_file(char * filename) { FILE * ifp; ComplexConsensi * out; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open file %s for ComplexConsensi",filename); return NULL; } out = read_ComplexConsensi(ifp); fclose(ifp); return out; } /* Function: read_ComplexConsensi(ifp) * * Descrip: Reads on ComplexConsensi from the FILE ifp. * * * Arg: ifp [UNKN ] input filestream [FILE *] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ # line 185 "complexconsensi.dy" ComplexConsensi * read_ComplexConsensi(FILE * ifp) { ComplexConsensi * out; ComplexConsensusWord * temp; char buffer[MAXLINE]; out = ComplexConsensi_alloc_std(); if( out == NULL ) return NULL; while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '#' ) continue; temp = read_ComplexConsensusWord_line(buffer); if( temp != NULL ) add_ComplexConsensi(out,temp); } return out; } /* Function: read_ComplexConsensusWord_line(line) * * Descrip: Reads a single ccword from a line * * * Arg: line [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ComplexConsensusWord *] * */ # line 214 "complexconsensi.dy" ComplexConsensusWord * read_ComplexConsensusWord_line(char * line) { ComplexConsensusWord * out; char * pattern; char * score; pattern = strtok(line,spacestr); score = strtok(NULL,spacestr); if( pattern == NULL || score == NULL ) { warn("Could not read a ComplexConsenusWord... ooops"); return NULL; } out = ComplexConsensusWord_alloc(); if( out == NULL) return NULL; out->pattern = stringalloc(pattern); out->score = (double) atof(score); return out; } # line 270 "complexconsensi.c" /* Function: hard_link_ComplexConsensusWord(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ComplexConsensusWord *] * * Return [UNKN ] Undocumented return value [ComplexConsensusWord *] * */ ComplexConsensusWord * hard_link_ComplexConsensusWord(ComplexConsensusWord * obj) { if( obj == NULL ) { warn("Trying to hard link to a ComplexConsensusWord object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ComplexConsensusWord_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ComplexConsensusWord *] * */ ComplexConsensusWord * ComplexConsensusWord_alloc(void) { ComplexConsensusWord * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ComplexConsensusWord *) ckalloc (sizeof(ComplexConsensusWord))) == NULL) { warn("ComplexConsensusWord_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->pattern = NULL; out->score = 0; out->p = 0.0; return out; } /* Function: free_ComplexConsensusWord(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ComplexConsensusWord *] * * Return [UNKN ] Undocumented return value [ComplexConsensusWord *] * */ ComplexConsensusWord * free_ComplexConsensusWord(ComplexConsensusWord * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ComplexConsensusWord obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->pattern != NULL) ckfree(obj->pattern); ckfree(obj); return NULL; } /* Function: swap_ComplexConsensi(list,i,j) * * Descrip: swap function: an internal for qsort_ComplexConsensi * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ComplexConsensusWord **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ComplexConsensi(ComplexConsensusWord ** list,int i,int j) { ComplexConsensusWord * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ComplexConsensi(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ComplexConsensi which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ComplexConsensusWord **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ComplexConsensi(ComplexConsensusWord ** list,int left,int right,int (*comp)(ComplexConsensusWord * ,ComplexConsensusWord * )) { int i,last; if( left >= right ) return; swap_ComplexConsensi(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ComplexConsensi (list,++last,i); } swap_ComplexConsensi (list,left,last); qsort_ComplexConsensi(list,left,last-1,comp); qsort_ComplexConsensi(list,last+1,right,comp); } /* Function: sort_ComplexConsensi(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ComplexConsensi * * * Arg: obj [UNKN ] Object containing list [ComplexConsensi *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ComplexConsensi(ComplexConsensi * obj,int (*comp)(ComplexConsensusWord *, ComplexConsensusWord *)) { qsort_ComplexConsensi(obj->ccw,0,obj->len-1,comp); return; } /* Function: expand_ComplexConsensi(obj,len) * * Descrip: Really an internal function for add_ComplexConsensi * * * Arg: obj [UNKN ] Object which contains the list [ComplexConsensi *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ComplexConsensi(ComplexConsensi * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_ComplexConsensi called with no need"); return TRUE; } if( (obj->ccw = (ComplexConsensusWord ** ) ckrealloc (obj->ccw,sizeof(ComplexConsensusWord *)*len)) == NULL) { warn("ckrealloc failed for expand_ComplexConsensi, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_ComplexConsensi(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ComplexConsensi *] * Arg: add [OWNER] Object to add to the list [ComplexConsensusWord *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ComplexConsensi(ComplexConsensi * obj,ComplexConsensusWord * add) { if( obj->len >= obj->maxlen) { if( expand_ComplexConsensi(obj,obj->len + ComplexConsensiLISTLENGTH) == FALSE) return FALSE; } obj->ccw[obj->len++]=add; return TRUE; } /* Function: flush_ComplexConsensi(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ComplexConsensi *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ComplexConsensi(ComplexConsensi * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->ccw[i] != NULL) { free_ComplexConsensusWord(obj->ccw[i]); obj->ccw[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: ComplexConsensi_alloc_std(void) * * Descrip: Equivalent to ComplexConsensi_alloc_len(ComplexConsensiLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * ComplexConsensi_alloc_std(void) { return ComplexConsensi_alloc_len(ComplexConsensiLISTLENGTH); } /* Function: ComplexConsensi_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * ComplexConsensi_alloc_len(int len) { ComplexConsensi * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = ComplexConsensi_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->ccw = (ComplexConsensusWord ** ) ckcalloc (len,sizeof(ComplexConsensusWord *))) == NULL) { warn("Warning, ckcalloc failed in ComplexConsensi_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_ComplexConsensi(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ComplexConsensi *] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * hard_link_ComplexConsensi(ComplexConsensi * obj) { if( obj == NULL ) { warn("Trying to hard link to a ComplexConsensi object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ComplexConsensi_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * ComplexConsensi_alloc(void) { ComplexConsensi * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ComplexConsensi *) ckalloc (sizeof(ComplexConsensi))) == NULL) { warn("ComplexConsensi_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->ccw = NULL; out->len = out->maxlen = 0; out->name = NULL; return out; } /* Function: free_ComplexConsensi(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ComplexConsensi *] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * free_ComplexConsensi(ComplexConsensi * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ComplexConsensi obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->ccw != NULL) { for(i=0;ilen;i++) { if( obj->ccw[i] != NULL) free_ComplexConsensusWord(obj->ccw[i]); } ckfree(obj->ccw); } if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/complexconsensi.h0000644000175000001440000002436110670453712020226 0ustar philippusers#ifndef DYNAMITEcomplexconsensiHEADERFILE #define DYNAMITEcomplexconsensiHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "probability.h" #define ComplexConsensiLISTLENGTH 64 struct Wise2_ComplexConsensusWord { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * pattern; Score score; Probability p; } ; /* ComplexConsensusWord defined */ #ifndef DYNAMITE_DEFINED_ComplexConsensusWord typedef struct Wise2_ComplexConsensusWord Wise2_ComplexConsensusWord; #define ComplexConsensusWord Wise2_ComplexConsensusWord #define DYNAMITE_DEFINED_ComplexConsensusWord #endif struct Wise2_ComplexConsensi { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ComplexConsensusWord ** ccw; int len;/* len for above ccw */ int maxlen; /* maxlen for above ccw */ char * name; } ; /* ComplexConsensi defined */ #ifndef DYNAMITE_DEFINED_ComplexConsensi typedef struct Wise2_ComplexConsensi Wise2_ComplexConsensi; #define ComplexConsensi Wise2_ComplexConsensi #define DYNAMITE_DEFINED_ComplexConsensi #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: show_ComplexConsensi(cc,*ofp) * * Descrip: shows complexconsensi in vaguely human form * * * Arg: cc [UNKN ] Undocumented argument [ComplexConsensi *] * Arg: *ofp [UNKN ] Undocumented argument [FILE] * */ void Wise2_show_ComplexConsensi(ComplexConsensi * cc,FILE *ofp); #define show_ComplexConsensi Wise2_show_ComplexConsensi /* Function: word_from_ComplexConsensi(word,cc) * * Descrip: Way of getting probabilities out of a consensus. * If it is in the Consensus, then gets prob, otherwise 0. * * * Arg: word [UNKN ] Undocumented argument [char *] * Arg: cc [UNKN ] Undocumented argument [ComplexConsensi *] * * Return [UNKN ] Undocumented return value [Probability] * */ Probability Wise2_word_from_ComplexConsensi(char * word,ComplexConsensi * cc); #define word_from_ComplexConsensi Wise2_word_from_ComplexConsensi /* Function: score_from_ComplexConsensi(word,cc) * * Descrip: Way of getting scores out of a consensus. * If it is in the Consensus, then gets score, otherwise NEGI. * * * Arg: word [UNKN ] Undocumented argument [char *] * Arg: cc [UNKN ] Undocumented argument [ComplexConsensi *] * * Return [UNKN ] Undocumented return value [Score] * */ Score Wise2_score_from_ComplexConsensi(char * word,ComplexConsensi * cc); #define score_from_ComplexConsensi Wise2_score_from_ComplexConsensi /* Function: best_ComplexConsensusWord(word,cc) * * Descrip: Finds the best (highest) match to this word * * * Arg: word [UNKN ] Undocumented argument [char *] * Arg: cc [UNKN ] Undocumented argument [ComplexConsensi *] * * Return [UNKN ] Undocumented return value [ComplexConsensusWord *] * */ ComplexConsensusWord * Wise2_best_ComplexConsensusWord(char * word,ComplexConsensi * cc); #define best_ComplexConsensusWord Wise2_best_ComplexConsensusWord /* Function: word_matches_ComplexConsensusWord(word,ccw) * * Descrip: Core of the matching system. Checks that word matches * ComplexConsensusWord. This says that '-' matches anything. * Issues a warning if hits a '\0' in word * * * Arg: word [UNKN ] Undocumented argument [char *] * Arg: ccw [UNKN ] Undocumented argument [ComplexConsensusWord *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_word_matches_ComplexConsensusWord(char * word,ComplexConsensusWord * ccw); #define word_matches_ComplexConsensusWord Wise2_word_matches_ComplexConsensusWord /* Function: read_ComplexConsensi_file(filename) * * Descrip: Reads a file containing the ComplexConsensi. * Not every useful, as most times these consensi * are in one file, with other things * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * Wise2_read_ComplexConsensi_file(char * filename); #define read_ComplexConsensi_file Wise2_read_ComplexConsensi_file /* Function: read_ComplexConsensi(ifp) * * Descrip: Reads on ComplexConsensi from the FILE ifp. * * * Arg: ifp [UNKN ] input filestream [FILE *] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * Wise2_read_ComplexConsensi(FILE * ifp); #define read_ComplexConsensi Wise2_read_ComplexConsensi /* Function: hard_link_ComplexConsensusWord(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ComplexConsensusWord *] * * Return [UNKN ] Undocumented return value [ComplexConsensusWord *] * */ ComplexConsensusWord * Wise2_hard_link_ComplexConsensusWord(ComplexConsensusWord * obj); #define hard_link_ComplexConsensusWord Wise2_hard_link_ComplexConsensusWord /* Function: ComplexConsensusWord_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ComplexConsensusWord *] * */ ComplexConsensusWord * Wise2_ComplexConsensusWord_alloc(void); #define ComplexConsensusWord_alloc Wise2_ComplexConsensusWord_alloc /* Function: free_ComplexConsensusWord(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ComplexConsensusWord *] * * Return [UNKN ] Undocumented return value [ComplexConsensusWord *] * */ ComplexConsensusWord * Wise2_free_ComplexConsensusWord(ComplexConsensusWord * obj); #define free_ComplexConsensusWord Wise2_free_ComplexConsensusWord /* Function: add_ComplexConsensi(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ComplexConsensi *] * Arg: add [OWNER] Object to add to the list [ComplexConsensusWord *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_ComplexConsensi(ComplexConsensi * obj,ComplexConsensusWord * add); #define add_ComplexConsensi Wise2_add_ComplexConsensi /* Function: flush_ComplexConsensi(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ComplexConsensi *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_ComplexConsensi(ComplexConsensi * obj); #define flush_ComplexConsensi Wise2_flush_ComplexConsensi /* Function: ComplexConsensi_alloc_std(void) * * Descrip: Equivalent to ComplexConsensi_alloc_len(ComplexConsensiLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * Wise2_ComplexConsensi_alloc_std(void); #define ComplexConsensi_alloc_std Wise2_ComplexConsensi_alloc_std /* Function: ComplexConsensi_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * Wise2_ComplexConsensi_alloc_len(int len); #define ComplexConsensi_alloc_len Wise2_ComplexConsensi_alloc_len /* Function: hard_link_ComplexConsensi(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ComplexConsensi *] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * Wise2_hard_link_ComplexConsensi(ComplexConsensi * obj); #define hard_link_ComplexConsensi Wise2_hard_link_ComplexConsensi /* Function: ComplexConsensi_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * Wise2_ComplexConsensi_alloc(void); #define ComplexConsensi_alloc Wise2_ComplexConsensi_alloc /* Function: free_ComplexConsensi(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ComplexConsensi *] * * Return [UNKN ] Undocumented return value [ComplexConsensi *] * */ ComplexConsensi * Wise2_free_ComplexConsensi(ComplexConsensi * obj); #define free_ComplexConsensi Wise2_free_ComplexConsensi /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_show_ComplexConsensusWord(ComplexConsensusWord * ccw,FILE * ofp); #define show_ComplexConsensusWord Wise2_show_ComplexConsensusWord boolean Wise2_strcmp_with_dashes(char * word,char * pattern); #define strcmp_with_dashes Wise2_strcmp_with_dashes ComplexConsensusWord * Wise2_read_ComplexConsensusWord_line(char * line); #define read_ComplexConsensusWord_line Wise2_read_ComplexConsensusWord_line void Wise2_swap_ComplexConsensi(ComplexConsensusWord ** list,int i,int j) ; #define swap_ComplexConsensi Wise2_swap_ComplexConsensi void Wise2_qsort_ComplexConsensi(ComplexConsensusWord ** list,int left,int right,int (*comp)(ComplexConsensusWord * ,ComplexConsensusWord * )); #define qsort_ComplexConsensi Wise2_qsort_ComplexConsensi void Wise2_sort_ComplexConsensi(ComplexConsensi * obj,int (*comp)(ComplexConsensusWord *, ComplexConsensusWord *)); #define sort_ComplexConsensi Wise2_sort_ComplexConsensi boolean Wise2_expand_ComplexConsensi(ComplexConsensi * obj,int len); #define expand_ComplexConsensi Wise2_expand_ComplexConsensi #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/genomicdb.pod0000644000175000001440000001662410670453712017302 0ustar philippusers=head1 NAME genomicdb module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item GenomicDB =back =head1 DESCRIPTION =head2 Object GenomicDB =over =item is_single_seq Type [boolean] Scalar No documentation =item done_forward Type [boolean] Scalar No documentation =item forw Type [ComplexSequence *] Scalar No documentation =item rev Type [ComplexSequence *] Scalar No documentation =item sdb Type [SequenceDB *] Scalar No documentation =item current Type [Genomic *] Scalar No documentation =item cses Type [ComplexSequenceEvalSet *] Scalar No documentation =item error_handling Type [GenDBErrorType] Scalar No documentation =item single Type [Genomic *] Scalar for single sequence cases, so we can 'index' on it =item revsingle Type [Genomic *] Scalar No documentation =item length_of_N Type [int] Scalar No documentation =item repeat_in_cds_score Type [int] Scalar No documentation =back This object hold a database of genomic sequences. You will probably use it in one of two ways 1 A sequence formatted database, which is provided by a /SequenceDB object is used to provide the raw sequences 2 A single Genomic sequence is used. In each case this database provides both the forward and reverse strands into the system. Notice that what is exported are /ComplexSequence objects, not genomic dna, as this is what is generally needed. These are things with splice sites calculated etc. This is why for initialisation this needs a /ComplexSequenceEvalSet of the correct type. =head2 Member functions of GenomicDB =over =item get_Genomic_from_GenomicDB &Wise2::GenomicDB::get_Genomic_from_GenomicDB(gendb,de) Gets Genomic sequence out from the GenomicDB using the information stored in dataentry Argument gendb [UNKN ] Undocumented argument [GenomicDB *] Argument de [UNKN ] Undocumented argument [DataEntry *] Return [UNKN ] Undocumented return value [Genomic *] =item hard_link_GenomicDB &Wise2::GenomicDB::hard_link_GenomicDB(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [GenomicDB *] Return [UNKN ] Undocumented return value [GenomicDB *] =item alloc &Wise2::GenomicDB::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [GenomicDB *] =item set_is_single_seq &Wise2::GenomicDB::set_is_single_seq(obj,is_single_seq) Replace member variable is_single_seq For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Argument is_single_seq [OWNER] New value of the variable [boolean] Return [SOFT ] member variable is_single_seq [boolean] =item is_single_seq &Wise2::GenomicDB::is_single_seq(obj) Access member variable is_single_seq For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Return [SOFT ] member variable is_single_seq [boolean] =item set_done_forward &Wise2::GenomicDB::set_done_forward(obj,done_forward) Replace member variable done_forward For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Argument done_forward [OWNER] New value of the variable [boolean] Return [SOFT ] member variable done_forward [boolean] =item done_forward &Wise2::GenomicDB::done_forward(obj) Access member variable done_forward For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Return [SOFT ] member variable done_forward [boolean] =item set_forw &Wise2::GenomicDB::set_forw(obj,forw) Replace member variable forw For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Argument forw [OWNER] New value of the variable [ComplexSequence *] Return [SOFT ] member variable forw [boolean] =item forw &Wise2::GenomicDB::forw(obj) Access member variable forw For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Return [SOFT ] member variable forw [ComplexSequence *] =item set_rev &Wise2::GenomicDB::set_rev(obj,rev) Replace member variable rev For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Argument rev [OWNER] New value of the variable [ComplexSequence *] Return [SOFT ] member variable rev [boolean] =item rev &Wise2::GenomicDB::rev(obj) Access member variable rev For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Return [SOFT ] member variable rev [ComplexSequence *] =item set_sdb &Wise2::GenomicDB::set_sdb(obj,sdb) Replace member variable sdb For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Argument sdb [OWNER] New value of the variable [SequenceDB *] Return [SOFT ] member variable sdb [boolean] =item sdb &Wise2::GenomicDB::sdb(obj) Access member variable sdb For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Return [SOFT ] member variable sdb [SequenceDB *] =item set_current &Wise2::GenomicDB::set_current(obj,current) Replace member variable current For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Argument current [OWNER] New value of the variable [Genomic *] Return [SOFT ] member variable current [boolean] =item current &Wise2::GenomicDB::current(obj) Access member variable current For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Return [SOFT ] member variable current [Genomic *] =item set_cses &Wise2::GenomicDB::set_cses(obj,cses) Replace member variable cses For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Argument cses [OWNER] New value of the variable [ComplexSequenceEvalSet *] Return [SOFT ] member variable cses [boolean] =item cses &Wise2::GenomicDB::cses(obj) Access member variable cses For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicDB *] Return [SOFT ] member variable cses [ComplexSequenceEvalSet *] =back =over =item new_GenomicDB_from_single_seq &Wise2::new_GenomicDB_from_single_seq(gen,cses,score_in_repeat_coding) To make a new genomic database from a single Genomic Sequence with a eval system Argument gen [UNKN ] sequence which as placed into GenomicDB structure. [Genomic *] Argument cses [UNKN ] Undocumented argument [ComplexSequenceEvalSet *] Argument score_in_repeat_coding [UNKN ] Undocumented argument [int] Return [UNKN ] Undocumented return value [GenomicDB *] =item new_GenomicDB &Wise2::new_GenomicDB(seqdb,cses,length_of_N,repeat_in_cds_score) To make a new genomic database Argument seqdb [UNKN ] sequence database [SequenceDB *] Argument cses [UNKN ] protein evaluation set [ComplexSequenceEvalSet *] Argument length_of_N [UNKN ] Undocumented argument [int] Argument repeat_in_cds_score [UNKN ] Undocumented argument [int] Return [UNKN ] Undocumented return value [GenomicDB *] =back wise-2.4.1/src/dynlibsrc/genomicdb.tex0000644000175000001440000000730710670453712017316 0ustar philippusers\section{genomicdb} \label{module_genomicdb} This module contains the following objects \begin{itemize} \item \ref{object_GenomicDB} GenomicDB \item This module also contains some factory methods \end{itemize} \subsection{genomicdb factory methods} \subsubsection{new_GenomicDB_from_single_seq} \begin{description} \item[External C] {\tt Wise2_new_GenomicDB_from_single_seq (gen,cses,score_in_repeat_coding)} \item[Perl] {\tt &Wise2::new_GenomicDB_from_single_seq (gen,cses,score_in_repeat_coding)} \end{description} Arguments \begin{description} \item[gen] [UNKN ] sequence which as placed into GenomicDB structure. [Genomic *] \item[cses] [UNKN ] Undocumented argument [ComplexSequenceEvalSet *] \item[score_in_repeat_coding] [UNKN ] Undocumented argument [int] \item[returns] [UNKN ] Undocumented return value [GenomicDB *] \end{description} To make a new genomic database from a single Genomic Sequence with a eval system \subsubsection{new_GenomicDB} \begin{description} \item[External C] {\tt Wise2_new_GenomicDB (seqdb,cses,length_of_N,repeat_in_cds_score)} \item[Perl] {\tt &Wise2::new_GenomicDB (seqdb,cses,length_of_N,repeat_in_cds_score)} \end{description} Arguments \begin{description} \item[seqdb] [UNKN ] sequence database [SequenceDB *] \item[cses] [UNKN ] protein evaluation set [ComplexSequenceEvalSet *] \item[length_of_N] [UNKN ] Undocumented argument [int] \item[repeat_in_cds_score] [UNKN ] Undocumented argument [int] \item[returns] [UNKN ] Undocumented return value [GenomicDB *] \end{description} To make a new genomic database \subsection{Object GenomicDB} \label{object_GenomicDB} The GenomicDB object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{is_single_seq} Type [boolean : Scalar] No documentation \item{done_forward} Type [boolean : Scalar] No documentation \item{forw} Type [ComplexSequence * : Scalar] No documentation \item{rev} Type [ComplexSequence * : Scalar] No documentation \item{sdb} Type [SequenceDB * : Scalar] No documentation \item{current} Type [Genomic * : Scalar] No documentation \item{cses} Type [ComplexSequenceEvalSet * : Scalar] No documentation \item{error_handling} Type [GenDBErrorType : Scalar] No documentation \item{single} Type [Genomic * : Scalar] for single sequence cases, so we can 'index' on it \item{revsingle} Type [Genomic * : Scalar] No documentation \item{length_of_N} Type [int : Scalar] No documentation \item{repeat_in_cds_score} Type [int : Scalar] No documentation \end{description} This object hold a database of genomic sequences. You will probably use it in one of two ways 1 A sequence formatted database, which is provided by a /SequenceDB object is used to provide the raw sequences 2 A single Genomic sequence is used. In each case this database provides both the forward and reverse strands into the system. Notice that what is exported are /ComplexSequence objects, not genomic dna, as this is what is generally needed. These are things with splice sites calculated etc. This is why for initialisation this needs a /ComplexSequenceEvalSet of the correct type. Member functions of GenomicDB \subsubsection{get_Genomic_from_GenomicDB} \begin{description} \item[External C] {\tt Wise2_get_Genomic_from_GenomicDB (gendb,de)} \item[Perl] {\tt &Wise2::GenomicDB::get_Genomic_from_GenomicDB (gendb,de)} \item[Perl-OOP call] {\tt $obj->get_Genomic_from_GenomicDB(de)} \end{description} Arguments \begin{description} \item[gendb] [UNKN ] Undocumented argument [GenomicDB *] \item[de] [UNKN ] Undocumented argument [DataEntry *] \item[returns] [UNKN ] Undocumented return value [Genomic *] \end{description} Gets Genomic sequence out from the GenomicDB using the information stored in dataentry wise-2.4.1/src/dynlibsrc/sequencedb.typemap0000644000175000001440000000075410670453713020364 0ustar philippusers TYPEMAP Wise2_SequenceDB * T_Wise2_SequenceDB INPUT T_Wise2_SequenceDB $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_SequenceDB *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_SequenceDB sv_setref_pv($arg, "Wise2::SequenceDB", (void*) $var); TYPEMAP Wise2_FileSource * T_Wise2_FileSource INPUT T_Wise2_FileSource $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_FileSource *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_FileSource sv_setref_pv($arg, "Wise2::FileSource", (void*) $var); wise-2.4.1/src/dynlibsrc/basematrix.pod0000644000175000001440000000144610670453712017506 0ustar philippusers=head1 NAME basematrix module - part of the Wise2 package =head1 SYNOPSIS This module contains helper functions for the Wise2 package =head1 DESCRIPTION =over =item change_max_BaseMatrix_kbytes &Wise2::change_max_BaseMatrix_kbytes(new_kilo_number) This is to change, at run-time the maximum level of bytes basematrix *thinks* it can use. This number is *not* used for any actual calls to basematrix allocation: it is only used with /get_max_BaseMatrix_kbytes Argument new_kilo_number [UNKN ] max kilobytes allowed [int] Return [UNKN ] Undocumented return value [void] =item get_max_BaseMatrix_kbytes &Wise2::get_max_BaseMatrix_kbytes(void) returns the max. number of kilobytes suggested as a limited to BaseMatrix. Return [UNKN ] Undocumented return value [int] =back wise-2.4.1/src/dynlibsrc/basematrix.tex0000644000175000001440000000212310670453712017515 0ustar philippusers\section{basematrix} \label{module_basematrix} This module only contains factory methods \subsection{basematrix factory methods} \subsubsection{change_max_BaseMatrix_kbytes} \begin{description} \item[External C] {\tt Wise2_change_max_BaseMatrix_kbytes (new_kilo_number)} \item[Perl] {\tt &Wise2::change_max_BaseMatrix_kbytes (new_kilo_number)} \end{description} Arguments \begin{description} \item[new_kilo_number] [UNKN ] max kilobytes allowed [int] \item[returns] Nothing - no return value \end{description} This is to change, at run-time the maximum level of bytes basematrix *thinks* it can use. This number is *not* used for any actual calls to basematrix allocation: it is only used with /get_max_BaseMatrix_kbytes \subsubsection{get_max_BaseMatrix_kbytes} \begin{description} \item[External C] {\tt Wise2_get_max_BaseMatrix_kbytes (void)} \item[Perl] {\tt &Wise2::get_max_BaseMatrix_kbytes ()} \end{description} Arguments \begin{description} \item[returns] [UNKN ] Undocumented return value [int] \end{description} returns the max. number of kilobytes suggested as a limited to BaseMatrix. wise-2.4.1/src/dynlibsrc/searchstatinterface.dy0000644000175000001440000000075307627501726021232 0ustar philippusers %{ #include "wisebase.h" #include "sequence.h" %} struct SearchStatInterface double (*calc_evalue)(void *,Sequence*,Sequence*,int,int) !func double (*calc_bits)(void *,int,int,int) !func char* (*attribution)(void *) !func void (*free_data)(void *) !func void * data !link %info SearchStatInterface converts raw scores into both bit score and evalues. Both must be supplied. The function signatures are query_length,target_length,raw_score %% %{ #include "searchstatinterface.h" %}wise-2.4.1/src/dynlibsrc/subseqhash.c0000644000175000001440000001405310670453713017154 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "subseqhash.h" /* Function: new_ghash_SeqLookupInterface(void) * * Descrip: Makes a new Glib based SeqLookup system * * * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ # line 24 "subseqhash.dy" SeqLookupInterface * new_ghash_SeqLookupInterface(void) { SeqLookupInterface * out; out = SeqLookupInterface_alloc_std(); out->data = (void*) g_hash_table_new(g_direct_hash,g_direct_equal); out->get_client = get_client_subseqhash_ghash; out->add_seq = add_seq_subseqhash_ghash; out->add_direct_number = add_direct_number_subseqhash_ghash; out->free_data = free_subseqhash_ghash; return out; } /* Function: get_client_subseqhash_ghash(data) * * Descrip: provides the interface defiition for get_client * * * Arg: data [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ # line 42 "subseqhash.dy" SeqLookupClientInterface * get_client_subseqhash_ghash(void * data) { SeqLookupClientInterface * sci; GHashTable * t = (GHashTable*) data; sci = SeqLookupClientInterface_alloc(); sci->is_populated = is_populated_subseqhash_ghash; sci->lookup = lookup_subseqhash_ghash; sci->free_data = free_client_subseqhash_ghash; sci->data = t; return sci; } /* Function: free_client_subseqhash_ghash(data) * * Descrip: provides the interface definition for free_data on client, which is * actually a no-op in this case * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 63 "subseqhash.dy" void free_client_subseqhash_ghash(void * data) { return; } /* Function: free_subseqhash_ghash(data) * * Descrip: Internal function for freeing ghash * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 72 "subseqhash.dy" void free_subseqhash_ghash(void * data) { GHashTable * h; h = (GHashTable *) data; g_hash_table_foreach_remove(h,remove_subseq_SeqLookupPos,NULL); g_hash_table_destroy(h); } /* Function: remove_subseq_SeqLookupPos(key,value,user_data) * * Descrip: Sub call of free * * * Arg: key [UNKN ] Undocumented argument [gpointer] * Arg: value [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * * Return [UNKN ] Undocumented return value [gboolean] * */ # line 87 "subseqhash.dy" gboolean remove_subseq_SeqLookupPos(gpointer key,gpointer value,gpointer user_data) { SeqLookupPos * s; s = (SeqLookupPos *) user_data; if( s != NULL ) { free_SeqLookupPos(s); } return TRUE; } /* Function: is_populated_subseqhash_ghash(data,seq_number) * * Descrip: Tells whether a position is populated or not * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 103 "subseqhash.dy" boolean is_populated_subseqhash_ghash(void * data, int seq_number) { GHashTable * h; h = (GHashTable *) data; /* fprintf(stdout,"Looking up with %d\n",h);*/ if( g_hash_table_lookup(h,(gconstpointer)seq_number) == NULL ) { return FALSE; } else { return TRUE; } } /* Function: lookup_subseqhash_ghash(data,seq_number) * * Descrip: Retrieves a SeqLookupPos from the hash * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ # line 122 "subseqhash.dy" SeqLookupResultInterface * lookup_subseqhash_ghash(void * data,int seq_number) { GHashTable * h; h = (GHashTable *) data; return new_linkedl_SeqLookupResultInterface((SeqLookupPos *)g_hash_table_lookup(h,(gconstpointer)seq_number)); } /* Function: add_seq_subseqhash_ghash(data,seq,para) * * Descrip: Adds a sequence/pos pair to the hash with this * number * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 136 "subseqhash.dy" boolean add_seq_subseqhash_ghash(void * data,Sequence * seq,SeqLookupLoadPara * para) { GHashTable * h; SeqLookupPos * p; SeqLookupPos * ret; int i; int seq_number; h = (GHashTable *) data; assert(para->tile_freq > 0); if( para->tile_freq > 100 ) { info("Tile frequency load greater than 100. That's a little odd"); } for(i=0;ilen-5;i = i+para->tile_freq) { seq_number = seq_number_aa_5mer(seq->seq+i); p = SeqLookupPos_alloc(); p->seq = seq; p->pos = i; p->next = NULL; if((ret = (SeqLookupPos *) g_hash_table_lookup(h,(gconstpointer)seq_number)) == NULL ) { g_hash_table_insert(h,(gpointer)seq_number,p); } else { p->next = ret->next; ret->next = p; } } return TRUE; } /* Function: add_direct_number_subseqhash_ghash(data,seq_number,target,pos) * * Descrip: Adds a direct no/seq pair to the system * number * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 175 "subseqhash.dy" boolean add_direct_number_subseqhash_ghash(void * data,int seq_number,Sequence * target,int pos) { GHashTable * h; SeqLookupPos * p; SeqLookupPos * ret; h = (GHashTable *) data; p = SeqLookupPos_alloc(); p->seq = target; p->pos = pos; p->next = NULL; if((ret = (SeqLookupPos *) g_hash_table_lookup(h,(gconstpointer)seq_number)) == NULL ) { g_hash_table_insert(h,(gpointer)seq_number,p); } else { p->next = ret->next; ret->next = p; } return TRUE; } # line 244 "subseqhash.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/subseqhash.h0000644000175000001440000001152210670453713017157 0ustar philippusers#ifndef DYNAMITEsubseqhashHEADERFILE #define DYNAMITEsubseqhashHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #include "seqlookup.h" #include "linkedlist_lookpos.h" #include "glib.h" #include "wisebase.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_ghash_SeqLookupInterface(void) * * Descrip: Makes a new Glib based SeqLookup system * * * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * Wise2_new_ghash_SeqLookupInterface(void); #define new_ghash_SeqLookupInterface Wise2_new_ghash_SeqLookupInterface /* Function: get_client_subseqhash_ghash(data) * * Descrip: provides the interface defiition for get_client * * * Arg: data [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ SeqLookupClientInterface * Wise2_get_client_subseqhash_ghash(void * data); #define get_client_subseqhash_ghash Wise2_get_client_subseqhash_ghash /* Function: free_client_subseqhash_ghash(data) * * Descrip: provides the interface definition for free_data on client, which is * actually a no-op in this case * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_client_subseqhash_ghash(void * data); #define free_client_subseqhash_ghash Wise2_free_client_subseqhash_ghash /* Function: free_subseqhash_ghash(data) * * Descrip: Internal function for freeing ghash * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_subseqhash_ghash(void * data); #define free_subseqhash_ghash Wise2_free_subseqhash_ghash /* Function: remove_subseq_SeqLookupPos(key,value,user_data) * * Descrip: Sub call of free * * * Arg: key [UNKN ] Undocumented argument [gpointer] * Arg: value [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * * Return [UNKN ] Undocumented return value [gboolean] * */ gboolean Wise2_remove_subseq_SeqLookupPos(gpointer key,gpointer value,gpointer user_data); #define remove_subseq_SeqLookupPos Wise2_remove_subseq_SeqLookupPos /* Function: is_populated_subseqhash_ghash(data,seq_number) * * Descrip: Tells whether a position is populated or not * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_populated_subseqhash_ghash(void * data, int seq_number); #define is_populated_subseqhash_ghash Wise2_is_populated_subseqhash_ghash /* Function: lookup_subseqhash_ghash(data,seq_number) * * Descrip: Retrieves a SeqLookupPos from the hash * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ SeqLookupResultInterface * Wise2_lookup_subseqhash_ghash(void * data,int seq_number); #define lookup_subseqhash_ghash Wise2_lookup_subseqhash_ghash /* Function: add_seq_subseqhash_ghash(data,seq,para) * * Descrip: Adds a sequence/pos pair to the hash with this * number * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_seq_subseqhash_ghash(void * data,Sequence * seq,SeqLookupLoadPara * para); #define add_seq_subseqhash_ghash Wise2_add_seq_subseqhash_ghash /* Function: add_direct_number_subseqhash_ghash(data,seq_number,target,pos) * * Descrip: Adds a direct no/seq pair to the system * number * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_direct_number_subseqhash_ghash(void * data,int seq_number,Sequence * target,int pos); #define add_direct_number_subseqhash_ghash Wise2_add_direct_number_subseqhash_ghash /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/probability_api.h0000644000175000001440000000452510670453712020166 0ustar philippusers /* Helper functions in the module * * Wise2_Probability_from_average_state_occupancy * Wise2_state_occupancy_from_Probability * Wise2_Probability2Score * Wise2_Score2Probability * Wise2_Score2Bits * Wise2_halfbit2Probability * /* These functions are not associated with an object */ /* Function: Wise2_Probability_from_average_state_occupancy(length) * * Descrip: for single state (exponetial decays) takes an average length * and converts that to a probability that will produce that * length (on average) for the state. NB... this *assumes* that * you want a single state exp decay. * * * Arg: length average length of state [double] * * Returns Undocumented return value [Probability] * */ Probability Wise2_Probability_from_average_state_occupancy( double length); /* Function: Wise2_state_occupancy_from_Probability(p) * * Descrip: If you have a single state then this will tak * the probability for the state->state transition and * give you back the average length in the state * * * Arg: p probability of staying in the state [double] * * Returns Undocumented return value [double] * */ double Wise2_state_occupancy_from_Probability( double p); /* Function: Wise2_Probability2Score(p) * * Descrip: maps probabilities to scores. Deals * sensibly with 0's. * * * Arg: p Undocumented argument [Probability] * * Returns Undocumented return value [Score] * */ Score Wise2_Probability2Score( Probability p); /* Function: Wise2_Score2Probability(s) * * Descrip: maps scores to probabilities * * * Arg: s Undocumented argument [Score] * * Returns Undocumented return value [Probability] * */ Probability Wise2_Score2Probability( Score s); /* Function: Wise2_Score2Bits(s) * * Descrip: maps scores to bits * * * Arg: s Undocumented argument [Score] * * Returns Undocumented return value [Bits] * */ Bits Wise2_Score2Bits( Score s); /* Function: Wise2_halfbit2Probability(half_bit) * * Descrip: maps halfbits (log2(prob*2) to * probabilities * * * Arg: half_bit Undocumented argument [double] * * Returns Undocumented return value [Probability] * */ Probability Wise2_halfbit2Probability( double half_bit); wise-2.4.1/src/dynlibsrc/probability_api.t0000644000175000001440000000000010670453712020162 0ustar philippuserswise-2.4.1/src/dynlibsrc/proteindb.typemap0000644000175000001440000000036010670453712020224 0ustar philippusers TYPEMAP Wise2_ProteinDB * T_Wise2_ProteinDB INPUT T_Wise2_ProteinDB $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_ProteinDB *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_ProteinDB sv_setref_pv($arg, "Wise2::ProteinDB", (void*) $var); wise-2.4.1/src/dynlibsrc/packaln.pod0000644000175000001440000001512310670453712016755 0ustar philippusers=head1 NAME packaln module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item PackAln =item PackAlnUnit =back =head1 DESCRIPTION =head2 Object PackAln =over =item pau Type [PackAlnUnit **] List list of PackAlnUnits from start to end =item score Type [int] Scalar score over the entire alignment =back This is the lowest-level of representation of a DP alignment, being the list of (i,j,state) triples taken through the DP matrix. The score for the transition to this point is held as well. This object is very low level and often a much better choice for representation is in /AlnBlock objects =head2 Member functions of PackAln =over =item show_simple_PackAln &Wise2::PackAln::show_simple_PackAln(pal,ofp) shows packaln with a pretty verbose debugging format Argument pal [UNKN ] Undocumented argument [PackAln *] Argument ofp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [void] =item show_bits_and_cumlative_PackAln &Wise2::PackAln::show_bits_and_cumlative_PackAln(pal,ofp) Shows packaln as: i,j,state,score,bits,cumlative-score,cumlative-bits cumlative score and cumlative bits are useful sometimes Argument pal [UNKN ] Undocumented argument [PackAln *] Argument ofp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [void] =item hard_link_PackAln &Wise2::PackAln::hard_link_PackAln(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [PackAln *] Return [UNKN ] Undocumented return value [PackAln *] =item PackAln_alloc_std &Wise2::PackAln::PackAln_alloc_std(void) Equivalent to PackAln_alloc_len(PackAlnLISTLENGTH) Return [UNKN ] Undocumented return value [PackAln *] =item pau &Wise2::PackAln::pau(obj,i) Access members stored in the pau list For use principly by API functions Argument obj [UNKN ] Object holding the list [PackAln *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [PackAlnUnit *] =item length_pau &Wise2::PackAln::length_pau(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [PackAln *] Return [UNKN ] length of the list [int] =item flush_pau &Wise2::PackAln::flush_pau(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [PackAln *] Return [UNKN ] Undocumented return value [int] =item add_pau &Wise2::PackAln::add_pau(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [PackAln *] Argument add [OWNER] Object to add to the list [PackAlnUnit *] Return [UNKN ] Undocumented return value [boolean] =item set_score &Wise2::PackAln::set_score(obj,score) Replace member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [PackAln *] Argument score [OWNER] New value of the variable [int] Return [SOFT ] member variable score [boolean] =item score &Wise2::PackAln::score(obj) Access member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [PackAln *] Return [SOFT ] member variable score [int] =back =head2 Object PackAlnUnit =over =item i Type [int] Scalar position in query =item j Type [int] Scalar position in target =item state Type [int] Scalar state in FSM =item score Type [int] Scalar score of the transition that reached this state =back Internal object for /PackAln: A single position of an alignment as the (i,j,state) triple =head2 Member functions of PackAlnUnit =over =item hard_link_PackAlnUnit &Wise2::PackAlnUnit::hard_link_PackAlnUnit(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [PackAlnUnit *] Return [UNKN ] Undocumented return value [PackAlnUnit *] =item alloc &Wise2::PackAlnUnit::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [PackAlnUnit *] =item set_i &Wise2::PackAlnUnit::set_i(obj,i) Replace member variable i For use principly by API functions Argument obj [UNKN ] Object holding the variable [PackAlnUnit *] Argument i [OWNER] New value of the variable [int] Return [SOFT ] member variable i [boolean] =item i &Wise2::PackAlnUnit::i(obj) Access member variable i For use principly by API functions Argument obj [UNKN ] Object holding the variable [PackAlnUnit *] Return [SOFT ] member variable i [int] =item set_j &Wise2::PackAlnUnit::set_j(obj,j) Replace member variable j For use principly by API functions Argument obj [UNKN ] Object holding the variable [PackAlnUnit *] Argument j [OWNER] New value of the variable [int] Return [SOFT ] member variable j [boolean] =item j &Wise2::PackAlnUnit::j(obj) Access member variable j For use principly by API functions Argument obj [UNKN ] Object holding the variable [PackAlnUnit *] Return [SOFT ] member variable j [int] =item set_state &Wise2::PackAlnUnit::set_state(obj,state) Replace member variable state For use principly by API functions Argument obj [UNKN ] Object holding the variable [PackAlnUnit *] Argument state [OWNER] New value of the variable [int] Return [SOFT ] member variable state [boolean] =item state &Wise2::PackAlnUnit::state(obj) Access member variable state For use principly by API functions Argument obj [UNKN ] Object holding the variable [PackAlnUnit *] Return [SOFT ] member variable state [int] =item set_score &Wise2::PackAlnUnit::set_score(obj,score) Replace member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [PackAlnUnit *] Argument score [OWNER] New value of the variable [int] Return [SOFT ] member variable score [boolean] =item score &Wise2::PackAlnUnit::score(obj) Access member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [PackAlnUnit *] Return [SOFT ] member variable score [int] =back wise-2.4.1/src/dynlibsrc/packaln.tex0000644000175000001440000000501410670453712016771 0ustar philippusers\section{packaln} \label{module_packaln} This module contains the following objects \begin{itemize} \item \ref{object_PackAln} PackAln \item \ref{object_PackAlnUnit} PackAlnUnit \end{itemize} \subsection{Object PackAln} \label{object_PackAln} The PackAln object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{pau} Type [PackAlnUnit ** : List] list of PackAlnUnits from start to end \item{score} Type [int : Scalar] score over the entire alignment \end{description} This is the lowest-level of representation of a DP alignment, being the list of (i,j,state) triples taken through the DP matrix. The score for the transition to this point is held as well. This object is very low level and often a much better choice for representation is in /AlnBlock objects Member functions of PackAln \subsubsection{show_simple_PackAln} \begin{description} \item[External C] {\tt Wise2_show_simple_PackAln (pal,ofp)} \item[Perl] {\tt &Wise2::PackAln::show_simple_PackAln (pal,ofp)} \item[Perl-OOP call] {\tt $obj->show_simple_PackAln(ofp)} \end{description} Arguments \begin{description} \item[pal] [UNKN ] Undocumented argument [PackAln *] \item[ofp] [UNKN ] Undocumented argument [FILE *] \item[returns] Nothing - no return value \end{description} shows packaln with a pretty verbose debugging format \subsubsection{show_bits_and_cumlative_PackAln} \begin{description} \item[External C] {\tt Wise2_show_bits_and_cumlative_PackAln (pal,ofp)} \item[Perl] {\tt &Wise2::PackAln::show_bits_and_cumlative_PackAln (pal,ofp)} \item[Perl-OOP call] {\tt $obj->show_bits_and_cumlative_PackAln(ofp)} \end{description} Arguments \begin{description} \item[pal] [UNKN ] Undocumented argument [PackAln *] \item[ofp] [UNKN ] Undocumented argument [FILE *] \item[returns] Nothing - no return value \end{description} Shows packaln as: i,j,state,score,bits,cumlative-score,cumlative-bits cumlative score and cumlative bits are useful sometimes \subsection{Object PackAlnUnit} \label{object_PackAlnUnit} The PackAlnUnit object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{i} Type [int : Scalar] position in query \item{j} Type [int : Scalar] position in target \item{state} Type [int : Scalar] state in FSM \item{score} Type [int : Scalar] score of the transition that reached this state \end{description} Internal object for /PackAln: A single position of an alignment as the (i,j,state) triple Member functions of PackAlnUnit wise-2.4.1/src/dynlibsrc/hspstream.c0000644000175000001440000001270710670453712017017 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "hspstream.h" /* Function: untyped_LinearHSPmanager_to_Stream(lm,ws) * * Descrip: untyped linear hsp manager to stream * * * Arg: lm [UNKN ] Undocumented argument [void *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ # line 16 "hspstream.dy" void untyped_LinearHSPmanager_to_Stream(void * lm,Wise2WriteStreamInterface * ws) { return typed_LinearHSPmanager_to_Stream((void*)lm,ws); } /* Function: typed_LinearHSPmanager_to_Stream(lm,ws) * * Descrip: typed linear hsp manager to stream * * writes out sequneces first, with query as first * sequence and then each target in turn, and then all the * hsps in turn, only writing down the target name * * * Arg: lm [UNKN ] Undocumented argument [LinearHSPmanager *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ # line 28 "hspstream.dy" void typed_LinearHSPmanager_to_Stream(LinearHSPmanager * lm,Wise2WriteStreamInterface * ws) { int i,j; SequenceSet * out; char buffer[512]; /* assumme that each HSPset has only one target sequence */ out = SequenceSet_alloc_len(lm->len+1); /* query goes in first */ add_SequenceSet(out,hard_link_Sequence(lm->query)); for(i=0;ilen;i++) { if( lm->set[i]->len > 0 ) { if( lm->set[i]->hsp[0]->target == NULL) { warn("Unable to transport HSP at position %d, as no linked target sequence",i); } else { add_SequenceSet(out,hard_link_Sequence(lm->set[i]->hsp[0]->target)); } } } typed_write_SequenceSet_to_Stream(out,ws); free_SequenceSet(out); /* now write the hsps */ for(i=0;ilen;i++) { if( lm->set[i]->len > 0 && lm->set[i]->hsp[0]->target != NULL ) { for(j=0;jset[i]->len;j++) { sprintf(buffer,"%s %d %d %d %d %d\n", lm->set[i]->hsp[j]->target->name, lm->set[i]->hsp[j]->query_start, lm->set[i]->hsp[j]->target_start, lm->set[i]->hsp[j]->length, lm->set[i]->hsp[j]->score, lm->set[i]->hsp[j]->target_reverse); /* fprintf(stderr,"%s %d %d %d %d %d\n", lm->set[i]->hsp[j]->target->name, lm->set[i]->hsp[j]->query_start, lm->set[i]->hsp[j]->target_start, lm->set[i]->hsp[j]->length, lm->set[i]->hsp[j]->score, lm->set[i]->hsp[j]->target_reverse); */ WISE2_WRITE_STRING(buffer,ws); } } } WISE2_WRITE_STRING("//\n",ws); } /* Function: untyped_LinearHSPmanager_from_Stream(rs) * * Descrip: untyped read * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [void *] * */ # line 87 "hspstream.dy" void * untyped_LinearHSPmanager_from_Stream(Wise2ReadStreamInterface * rs) { return (void*) typed_LinearHSPmanager_from_Stream(rs); } /* Function: typed_LinearHSPmanager_from_Stream(rs) * * Descrip: typed linear hsp manager from stream * * assummes sequences coming in first, with query as first sequence * and then hsps one after the other * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 99 "hspstream.dy" LinearHSPmanager * typed_LinearHSPmanager_from_Stream(Wise2ReadStreamInterface * rs) { SequenceSet * set; LinearHSPmanager * lm; HSPset * curr; HSP * h; int seq_pos; int dummy; int i; char buffer[MAXLINE]; set = typed_SequenceSet_from_Stream(rs); /* for(i=0;ilen;i++) { fprintf(stderr,"Got %d, %s with %s\n",i,set->set[i]->name,set->set[i]->desc); } */ lm = LinearHSPmanager_alloc_std(); lm->query = hard_link_Sequence(set->set[0]); if( set->len == 1 ) { WISE2_READ_BUFFER(buffer,MAXLINE,rs); /* should check it is // */ return lm; } seq_pos = 1; curr = HSPset_alloc_std(); add_LinearHSPmanager(lm,curr); while( WISE2_READ_BUFFER(buffer,MAXLINE,rs) != NULL ) { auto int k; auto int temp_len = strlen(set->set[seq_pos]->name); if( strncmp(buffer,"//",2) == 0 ) { break; } /* is space is because we can have partial matching at the start of the of an identifier, in particular with uniprot alternative splice -X names */ for(k=0;k < MAXLINE;k++) { if( isspace(buffer[k]) ) { buffer[k] = '\0'; break; } } /*fprintf(stderr,"Comparing %s to %s with %d (%d) %d %d\n",buffer,set->set[seq_pos]->name,strncmp(buffer,set->set[seq_pos]->name,temp_len),temp_len,isspace(buffer[temp_len]),(int)(buffer[temp_len]) ); */ if( strcmp(buffer,set->set[seq_pos]->name) != 0 ) { seq_pos++; if( seq_pos >= set->len ) { warn("Overrun set sequences\n"); break; } curr = HSPset_alloc_std(); add_LinearHSPmanager(lm,curr); if( strncmp(buffer,set->set[seq_pos]->name,temp_len) != 0 ) { warn("Unable to match hsp name of [%s] to sequence name of %s, skipping\n",buffer,set->set[seq_pos]->name); continue; } } /* parse this hsp */ h = HSP_alloc(); h->query = hard_link_Sequence(set->set[0]); h->target = hard_link_Sequence(set->set[seq_pos]); sscanf(buffer+strlen(set->set[seq_pos]->name)+1,"%d %d %d %d %d",&h->query_start,&h->target_start,&h->length,&h->score,&dummy); if( dummy == 0 ) { h->target_reverse = 0; } else { h->target_reverse = 1; } add_HSPset(curr,h); } free_SequenceSet(set); return lm; } # line 218 "hspstream.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/hspstream.h0000644000175000001440000000542310670453712017021 0ustar philippusers#ifndef DYNAMITEhspstreamHEADERFILE #define DYNAMITEhspstreamHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "../dynlibsrc/hsp.h" #include "sequencestream.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: untyped_LinearHSPmanager_to_Stream(lm,ws) * * Descrip: untyped linear hsp manager to stream * * * Arg: lm [UNKN ] Undocumented argument [void *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ void Wise2_untyped_LinearHSPmanager_to_Stream(void * lm,Wise2WriteStreamInterface * ws); #define untyped_LinearHSPmanager_to_Stream Wise2_untyped_LinearHSPmanager_to_Stream /* Function: typed_LinearHSPmanager_to_Stream(lm,ws) * * Descrip: typed linear hsp manager to stream * * writes out sequneces first, with query as first * sequence and then each target in turn, and then all the * hsps in turn, only writing down the target name * * * Arg: lm [UNKN ] Undocumented argument [LinearHSPmanager *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ void Wise2_typed_LinearHSPmanager_to_Stream(LinearHSPmanager * lm,Wise2WriteStreamInterface * ws); #define typed_LinearHSPmanager_to_Stream Wise2_typed_LinearHSPmanager_to_Stream /* Function: untyped_LinearHSPmanager_from_Stream(rs) * * Descrip: untyped read * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [void *] * */ void * Wise2_untyped_LinearHSPmanager_from_Stream(Wise2ReadStreamInterface * rs); #define untyped_LinearHSPmanager_from_Stream Wise2_untyped_LinearHSPmanager_from_Stream /* Function: typed_LinearHSPmanager_from_Stream(rs) * * Descrip: typed linear hsp manager from stream * * assummes sequences coming in first, with query as first sequence * and then hsps one after the other * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_typed_LinearHSPmanager_from_Stream(Wise2ReadStreamInterface * rs); #define typed_LinearHSPmanager_from_Stream Wise2_typed_LinearHSPmanager_from_Stream /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/subseqlookup.c0000644000175000001440000004354410670453713017551 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "subseqlookup.h" /* Function: new_array_SeqLookupInterface(array_max_size) * * Descrip: Makes a new array Lookup system * * * Arg: array_max_size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ # line 32 "subseqlookup.dy" SeqLookupInterface * new_array_SeqLookupInterface(int array_max_size) { SeqLookupInterface * out; SubSeqLookup * a; int i; out = SeqLookupInterface_alloc_std(); a = SubSeqLookup_alloc(); a->array = calloc(array_max_size,sizeof(SeqLookupPos *)); for(i=0;iarray[i] = NULL; } a->array_max = array_max_size; a->block = new_SeqLookupPosBlockAllocator(); out->data = (void*) a; out->lookup = lookup_subseqlookup; out->add = add_subseqlookup; out->is_populated = is_populated_subseqlookup; out->free_data = free_subseqlookup; return out; } /* Function: free_subseqlookup(data) * * Descrip: free function for the hash * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 61 "subseqlookup.dy" void free_subseqlookup(void * data) { SubSeqLookup * look = (SubSeqLookup *)data; free_SubSeqLookup(look); } /* Function: is_populated_subseqlookup(data,seq_number) * * Descrip: tells whether this is populated or not * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 71 "subseqlookup.dy" boolean is_populated_subseqlookup(void * data, int seq_number) { SubSeqLookup * look = (SubSeqLookup *)data; if( look->array[seq_number] == NULL ) { return FALSE; } else { return TRUE; } } /* Function: lookup_subseqlookup(data,seq_number) * * Descrip: Retrieves a SeqLookup position * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ # line 86 "subseqlookup.dy" SeqLookupResultInterface * lookup_subseqlookup(void * data, int seq_number) { SubSeqLookup * look = (SubSeqLookup *)data; return new_linkedl_SeqLookupResultInterface(look->array[seq_number]); } /* Function: add_subseqlookup(data,seq_number,seq,pos) * * Descrip: Adds a sequence/pos pair to the hash * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 96 "subseqlookup.dy" boolean add_subseqlookup(void * data,int seq_number,Sequence * seq,int pos) { SubSeqLookup * look = (SubSeqLookup *)data; SeqLookupPos * p; p = new_SeqLookupPos_BlockAllocator(look->block); p->seq = seq; p->pos = pos; p->next = NULL; if( look->array[seq_number] == NULL ) { look->array[seq_number] = p; } else { p->next = look->array[seq_number]; look->array[seq_number] = p; } return TRUE; } /* Function: new_SeqLookupPosBlockAllocator(void) * * Descrip: Makes a new SeqPosLookup Block Allocator * * * * Return [UNKN ] Undocumented return value [SeqLookupPosBlockAllocator *] * */ # line 120 "subseqlookup.dy" SeqLookupPosBlockAllocator * new_SeqLookupPosBlockAllocator(void) { SeqLookupPosBlockAllocator * out; out = SeqLookupPosBlockAllocator_alloc_std(); add_SeqLookupPosBlockAllocator(out,SeqLookupPosBlock_alloc()); out->pos = 0; return out; } /* Function: new_SeqLookupPos_BlockAllocator(*bla) * * Descrip: Returns a new SeqPosLookup * * * Arg: *bla [UNKN ] Undocumented argument [SeqLookupPosBlockAllocator] * * Return [UNKN ] Undocumented return value [SeqLookupPos *] * */ # line 134 "subseqlookup.dy" SeqLookupPos * new_SeqLookupPos_BlockAllocator(SeqLookupPosBlockAllocator *bla) { if( bla->pos+1 > LOOKUP_BLOCK_SIZE ) { add_SeqLookupPosBlockAllocator(bla,SeqLookupPosBlock_alloc()); bla->pos = 0; fprintf(stderr,"Increasing block...\n"); } bla->block[bla->len-1]->block[bla->pos].dynamite_hard_link = 1; bla->pos++; return &(bla->block[bla->len-1]->block[bla->pos-1]); } # line 168 "subseqlookup.c" /* Function: hard_link_SeqLookupPosBlock(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupPosBlock *] * * Return [UNKN ] Undocumented return value [SeqLookupPosBlock *] * */ SeqLookupPosBlock * hard_link_SeqLookupPosBlock(SeqLookupPosBlock * obj) { if( obj == NULL ) { warn("Trying to hard link to a SeqLookupPosBlock object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SeqLookupPosBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupPosBlock *] * */ SeqLookupPosBlock * SeqLookupPosBlock_alloc(void) { SeqLookupPosBlock * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SeqLookupPosBlock *) ckalloc (sizeof(SeqLookupPosBlock))) == NULL) { warn("SeqLookupPosBlock_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* block[LOOKUP_BLOCK_SIZE] is an array: no default possible */ return out; } /* Function: free_SeqLookupPosBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeqLookupPosBlock *] * * Return [UNKN ] Undocumented return value [SeqLookupPosBlock *] * */ SeqLookupPosBlock * free_SeqLookupPosBlock(SeqLookupPosBlock * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SeqLookupPosBlock obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_SeqLookupPosBlockAllocator(list,i,j) * * Descrip: swap function: an internal for qsort_SeqLookupPosBlockAllocator * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [SeqLookupPosBlock **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SeqLookupPosBlockAllocator(SeqLookupPosBlock ** list,int i,int j) { SeqLookupPosBlock * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SeqLookupPosBlockAllocator(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SeqLookupPosBlockAllocator which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [SeqLookupPosBlock **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SeqLookupPosBlockAllocator(SeqLookupPosBlock ** list,int left,int right,int (*comp)(SeqLookupPosBlock * ,SeqLookupPosBlock * )) { int i,last; if( left >= right ) return; swap_SeqLookupPosBlockAllocator(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SeqLookupPosBlockAllocator (list,++last,i); } swap_SeqLookupPosBlockAllocator (list,left,last); qsort_SeqLookupPosBlockAllocator(list,left,last-1,comp); qsort_SeqLookupPosBlockAllocator(list,last+1,right,comp); } /* Function: sort_SeqLookupPosBlockAllocator(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SeqLookupPosBlockAllocator * * * Arg: obj [UNKN ] Object containing list [SeqLookupPosBlockAllocator *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SeqLookupPosBlockAllocator(SeqLookupPosBlockAllocator * obj,int (*comp)(SeqLookupPosBlock *, SeqLookupPosBlock *)) { qsort_SeqLookupPosBlockAllocator(obj->block,0,obj->len-1,comp); return; } /* Function: expand_SeqLookupPosBlockAllocator(obj,len) * * Descrip: Really an internal function for add_SeqLookupPosBlockAllocator * * * Arg: obj [UNKN ] Object which contains the list [SeqLookupPosBlockAllocator *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SeqLookupPosBlockAllocator(SeqLookupPosBlockAllocator * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SeqLookupPosBlockAllocator called with no need"); return TRUE; } if( (obj->block = (SeqLookupPosBlock ** ) ckrealloc (obj->block,sizeof(SeqLookupPosBlock *)*len)) == NULL) { warn("ckrealloc failed for expand_SeqLookupPosBlockAllocator, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SeqLookupPosBlockAllocator(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SeqLookupPosBlockAllocator *] * Arg: add [OWNER] Object to add to the list [SeqLookupPosBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SeqLookupPosBlockAllocator(SeqLookupPosBlockAllocator * obj,SeqLookupPosBlock * add) { if( obj->len >= obj->maxlen) { if( expand_SeqLookupPosBlockAllocator(obj,obj->len + SeqLookupPosBlockAllocatorLISTLENGTH) == FALSE) return FALSE; } obj->block[obj->len++]=add; return TRUE; } /* Function: flush_SeqLookupPosBlockAllocator(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SeqLookupPosBlockAllocator *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SeqLookupPosBlockAllocator(SeqLookupPosBlockAllocator * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->block[i] != NULL) { free_SeqLookupPosBlock(obj->block[i]); obj->block[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SeqLookupPosBlockAllocator_alloc_std(void) * * Descrip: Equivalent to SeqLookupPosBlockAllocator_alloc_len(SeqLookupPosBlockAllocatorLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SeqLookupPosBlockAllocator *] * */ SeqLookupPosBlockAllocator * SeqLookupPosBlockAllocator_alloc_std(void) { return SeqLookupPosBlockAllocator_alloc_len(SeqLookupPosBlockAllocatorLISTLENGTH); } /* Function: SeqLookupPosBlockAllocator_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SeqLookupPosBlockAllocator *] * */ SeqLookupPosBlockAllocator * SeqLookupPosBlockAllocator_alloc_len(int len) { SeqLookupPosBlockAllocator * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SeqLookupPosBlockAllocator_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->block = (SeqLookupPosBlock ** ) ckcalloc (len,sizeof(SeqLookupPosBlock *))) == NULL) { warn("Warning, ckcalloc failed in SeqLookupPosBlockAllocator_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SeqLookupPosBlockAllocator(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupPosBlockAllocator *] * * Return [UNKN ] Undocumented return value [SeqLookupPosBlockAllocator *] * */ SeqLookupPosBlockAllocator * hard_link_SeqLookupPosBlockAllocator(SeqLookupPosBlockAllocator * obj) { if( obj == NULL ) { warn("Trying to hard link to a SeqLookupPosBlockAllocator object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SeqLookupPosBlockAllocator_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupPosBlockAllocator *] * */ SeqLookupPosBlockAllocator * SeqLookupPosBlockAllocator_alloc(void) { SeqLookupPosBlockAllocator * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SeqLookupPosBlockAllocator *) ckalloc (sizeof(SeqLookupPosBlockAllocator))) == NULL) { warn("SeqLookupPosBlockAllocator_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->block = NULL; out->len = out->maxlen = 0; out->pos = 0; return out; } /* Function: free_SeqLookupPosBlockAllocator(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeqLookupPosBlockAllocator *] * * Return [UNKN ] Undocumented return value [SeqLookupPosBlockAllocator *] * */ SeqLookupPosBlockAllocator * free_SeqLookupPosBlockAllocator(SeqLookupPosBlockAllocator * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SeqLookupPosBlockAllocator obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->block != NULL) { for(i=0;ilen;i++) { if( obj->block[i] != NULL) free_SeqLookupPosBlock(obj->block[i]); } ckfree(obj->block); } ckfree(obj); return NULL; } /* Function: hard_link_SubSeqLookup(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SubSeqLookup *] * * Return [UNKN ] Undocumented return value [SubSeqLookup *] * */ SubSeqLookup * hard_link_SubSeqLookup(SubSeqLookup * obj) { if( obj == NULL ) { warn("Trying to hard link to a SubSeqLookup object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SubSeqLookup_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SubSeqLookup *] * */ SubSeqLookup * SubSeqLookup_alloc(void) { SubSeqLookup * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SubSeqLookup *) ckalloc (sizeof(SubSeqLookup))) == NULL) { warn("SubSeqLookup_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->array = NULL; out->array_max = 0; out->block = NULL; return out; } /* Function: free_SubSeqLookup(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SubSeqLookup *] * * Return [UNKN ] Undocumented return value [SubSeqLookup *] * */ SubSeqLookup * free_SubSeqLookup(SubSeqLookup * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SubSeqLookup obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->array != NULL) ckfree(obj->array); if( obj->block != NULL) free_SeqLookupPosBlockAllocator(obj->block); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/subseqlookup.h0000644000175000001440000002712410670453713017552 0ustar philippusers#ifndef DYNAMITEsubseqlookupHEADERFILE #define DYNAMITEsubseqlookupHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #include "seqlookup.h" #include "linkedlist_lookpos.h" #define LOOKUP_BLOCK_SIZE 1024*1024 #define SeqLookupPosBlockAllocatorLISTLENGTH 2048 struct Wise2_SeqLookupPosBlock { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeqLookupPos block[LOOKUP_BLOCK_SIZE]; } ; /* SeqLookupPosBlock defined */ #ifndef DYNAMITE_DEFINED_SeqLookupPosBlock typedef struct Wise2_SeqLookupPosBlock Wise2_SeqLookupPosBlock; #define SeqLookupPosBlock Wise2_SeqLookupPosBlock #define DYNAMITE_DEFINED_SeqLookupPosBlock #endif struct Wise2_SeqLookupPosBlockAllocator { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeqLookupPosBlock ** block; int len;/* len for above block */ int maxlen; /* maxlen for above block */ int pos; } ; /* SeqLookupPosBlockAllocator defined */ #ifndef DYNAMITE_DEFINED_SeqLookupPosBlockAllocator typedef struct Wise2_SeqLookupPosBlockAllocator Wise2_SeqLookupPosBlockAllocator; #define SeqLookupPosBlockAllocator Wise2_SeqLookupPosBlockAllocator #define DYNAMITE_DEFINED_SeqLookupPosBlockAllocator #endif struct Wise2_SubSeqLookup { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeqLookupPos ** array; int array_max; SeqLookupPosBlockAllocator * block; } ; /* SubSeqLookup defined */ #ifndef DYNAMITE_DEFINED_SubSeqLookup typedef struct Wise2_SubSeqLookup Wise2_SubSeqLookup; #define SubSeqLookup Wise2_SubSeqLookup #define DYNAMITE_DEFINED_SubSeqLookup #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_array_SeqLookupInterface(array_max_size) * * Descrip: Makes a new array Lookup system * * * Arg: array_max_size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * Wise2_new_array_SeqLookupInterface(int array_max_size); #define new_array_SeqLookupInterface Wise2_new_array_SeqLookupInterface /* Function: free_subseqlookup(data) * * Descrip: free function for the hash * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_subseqlookup(void * data); #define free_subseqlookup Wise2_free_subseqlookup /* Function: is_populated_subseqlookup(data,seq_number) * * Descrip: tells whether this is populated or not * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_populated_subseqlookup(void * data, int seq_number); #define is_populated_subseqlookup Wise2_is_populated_subseqlookup /* Function: lookup_subseqlookup(data,seq_number) * * Descrip: Retrieves a SeqLookup position * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ SeqLookupResultInterface * Wise2_lookup_subseqlookup(void * data, int seq_number); #define lookup_subseqlookup Wise2_lookup_subseqlookup /* Function: add_subseqlookup(data,seq_number,seq,pos) * * Descrip: Adds a sequence/pos pair to the hash * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_subseqlookup(void * data,int seq_number,Sequence * seq,int pos); #define add_subseqlookup Wise2_add_subseqlookup /* Function: new_SeqLookupPosBlockAllocator(void) * * Descrip: Makes a new SeqPosLookup Block Allocator * * * * Return [UNKN ] Undocumented return value [SeqLookupPosBlockAllocator *] * */ SeqLookupPosBlockAllocator * Wise2_new_SeqLookupPosBlockAllocator(void); #define new_SeqLookupPosBlockAllocator Wise2_new_SeqLookupPosBlockAllocator /* Function: new_SeqLookupPos_BlockAllocator(*bla) * * Descrip: Returns a new SeqPosLookup * * * Arg: *bla [UNKN ] Undocumented argument [SeqLookupPosBlockAllocator] * * Return [UNKN ] Undocumented return value [SeqLookupPos *] * */ SeqLookupPos * Wise2_new_SeqLookupPos_BlockAllocator(SeqLookupPosBlockAllocator *bla); #define new_SeqLookupPos_BlockAllocator Wise2_new_SeqLookupPos_BlockAllocator /* Function: hard_link_SeqLookupPosBlock(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupPosBlock *] * * Return [UNKN ] Undocumented return value [SeqLookupPosBlock *] * */ SeqLookupPosBlock * Wise2_hard_link_SeqLookupPosBlock(SeqLookupPosBlock * obj); #define hard_link_SeqLookupPosBlock Wise2_hard_link_SeqLookupPosBlock /* Function: SeqLookupPosBlock_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupPosBlock *] * */ SeqLookupPosBlock * Wise2_SeqLookupPosBlock_alloc(void); #define SeqLookupPosBlock_alloc Wise2_SeqLookupPosBlock_alloc /* Function: free_SeqLookupPosBlock(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeqLookupPosBlock *] * * Return [UNKN ] Undocumented return value [SeqLookupPosBlock *] * */ SeqLookupPosBlock * Wise2_free_SeqLookupPosBlock(SeqLookupPosBlock * obj); #define free_SeqLookupPosBlock Wise2_free_SeqLookupPosBlock /* Function: add_SeqLookupPosBlockAllocator(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SeqLookupPosBlockAllocator *] * Arg: add [OWNER] Object to add to the list [SeqLookupPosBlock *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SeqLookupPosBlockAllocator(SeqLookupPosBlockAllocator * obj,SeqLookupPosBlock * add); #define add_SeqLookupPosBlockAllocator Wise2_add_SeqLookupPosBlockAllocator /* Function: flush_SeqLookupPosBlockAllocator(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SeqLookupPosBlockAllocator *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SeqLookupPosBlockAllocator(SeqLookupPosBlockAllocator * obj); #define flush_SeqLookupPosBlockAllocator Wise2_flush_SeqLookupPosBlockAllocator /* Function: SeqLookupPosBlockAllocator_alloc_std(void) * * Descrip: Equivalent to SeqLookupPosBlockAllocator_alloc_len(SeqLookupPosBlockAllocatorLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SeqLookupPosBlockAllocator *] * */ SeqLookupPosBlockAllocator * Wise2_SeqLookupPosBlockAllocator_alloc_std(void); #define SeqLookupPosBlockAllocator_alloc_std Wise2_SeqLookupPosBlockAllocator_alloc_std /* Function: SeqLookupPosBlockAllocator_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SeqLookupPosBlockAllocator *] * */ SeqLookupPosBlockAllocator * Wise2_SeqLookupPosBlockAllocator_alloc_len(int len); #define SeqLookupPosBlockAllocator_alloc_len Wise2_SeqLookupPosBlockAllocator_alloc_len /* Function: hard_link_SeqLookupPosBlockAllocator(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeqLookupPosBlockAllocator *] * * Return [UNKN ] Undocumented return value [SeqLookupPosBlockAllocator *] * */ SeqLookupPosBlockAllocator * Wise2_hard_link_SeqLookupPosBlockAllocator(SeqLookupPosBlockAllocator * obj); #define hard_link_SeqLookupPosBlockAllocator Wise2_hard_link_SeqLookupPosBlockAllocator /* Function: SeqLookupPosBlockAllocator_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeqLookupPosBlockAllocator *] * */ SeqLookupPosBlockAllocator * Wise2_SeqLookupPosBlockAllocator_alloc(void); #define SeqLookupPosBlockAllocator_alloc Wise2_SeqLookupPosBlockAllocator_alloc /* Function: free_SeqLookupPosBlockAllocator(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeqLookupPosBlockAllocator *] * * Return [UNKN ] Undocumented return value [SeqLookupPosBlockAllocator *] * */ SeqLookupPosBlockAllocator * Wise2_free_SeqLookupPosBlockAllocator(SeqLookupPosBlockAllocator * obj); #define free_SeqLookupPosBlockAllocator Wise2_free_SeqLookupPosBlockAllocator /* Function: hard_link_SubSeqLookup(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SubSeqLookup *] * * Return [UNKN ] Undocumented return value [SubSeqLookup *] * */ SubSeqLookup * Wise2_hard_link_SubSeqLookup(SubSeqLookup * obj); #define hard_link_SubSeqLookup Wise2_hard_link_SubSeqLookup /* Function: SubSeqLookup_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SubSeqLookup *] * */ SubSeqLookup * Wise2_SubSeqLookup_alloc(void); #define SubSeqLookup_alloc Wise2_SubSeqLookup_alloc /* Function: free_SubSeqLookup(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SubSeqLookup *] * * Return [UNKN ] Undocumented return value [SubSeqLookup *] * */ SubSeqLookup * Wise2_free_SubSeqLookup(SubSeqLookup * obj); #define free_SubSeqLookup Wise2_free_SubSeqLookup /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_SeqLookupPosBlockAllocator(SeqLookupPosBlock ** list,int i,int j) ; #define swap_SeqLookupPosBlockAllocator Wise2_swap_SeqLookupPosBlockAllocator void Wise2_qsort_SeqLookupPosBlockAllocator(SeqLookupPosBlock ** list,int left,int right,int (*comp)(SeqLookupPosBlock * ,SeqLookupPosBlock * )); #define qsort_SeqLookupPosBlockAllocator Wise2_qsort_SeqLookupPosBlockAllocator void Wise2_sort_SeqLookupPosBlockAllocator(SeqLookupPosBlockAllocator * obj,int (*comp)(SeqLookupPosBlock *, SeqLookupPosBlock *)); #define sort_SeqLookupPosBlockAllocator Wise2_sort_SeqLookupPosBlockAllocator boolean Wise2_expand_SeqLookupPosBlockAllocator(SeqLookupPosBlockAllocator * obj,int len); #define expand_SeqLookupPosBlockAllocator Wise2_expand_SeqLookupPosBlockAllocator #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/hsp2hitscan.c0000644000175000001440000006713010670453712017237 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "hsp2hitscan.h" #include #include /* Function: new_SeedHit(posi,posj) * * Descrip: Makes a new SeedHit * * * Arg: posi [UNKN ] Undocumented argument [int] * Arg: posj [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeedHit *] * */ # line 40 "hsp2hitscan.dy" SeedHit * new_SeedHit(int posi,int posj) { SeedHit * out; out = SeedHit_alloc(); out->diagonal = posi - posj; out->posi = posi; out->posj = posj; out->used = 0; return out; } /* Function: add_SeedHit_SeedHitManager(shm,t,posi,posj,score) * * Descrip: Adds a new position to the manger, allocating any * new datastructures * * * Arg: shm [UNKN ] Undocumented argument [SeedHitManager *] * Arg: t [UNKN ] Undocumented argument [Sequence *] * Arg: posi [UNKN ] Undocumented argument [int] * Arg: posj [UNKN ] Undocumented argument [int] * Arg: score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 57 "hsp2hitscan.dy" boolean add_SeedHit_SeedHitManager(SeedHitManager * shm,Sequence * t,int posi,int posj,int score) { SeedHitSet * sh = NULL; if( (sh = g_hash_table_lookup(shm->hash,(gpointer)t)) == NULL ) { sh = SeedHitSet_alloc_std(); sh->target = t; g_hash_table_insert(shm->hash,(gpointer)t,sh); add_SeedHitManager(shm,sh); } sh->score += score; add_SeedHitSet(sh,new_SeedHit(posi,posj)); return TRUE; } /* Function: populate_HSP_from_SeedHitManager(query,shm,para,p) * * Descrip: Chooses which Seeds to use for HSPs. If there are more than factor x max_results * cases, restricted it to factor x max_results scored by seed hits. Then askes * for two diagonal seeds within a wobble factor to start the HSP process * * * Arg: query [UNKN ] Undocumented argument [Sequence *] * Arg: shm [UNKN ] Undocumented argument [SeedHitManager *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * Arg: p [UNKN ] Undocumented argument [HSPScanPara *] * * Return [UNKN ] Undocumented return value [HSPmanager *] * */ # line 82 "hsp2hitscan.dy" HSPmanager * populate_HSP_from_SeedHitManager(Sequence * query,SeedHitManager * shm,HSPScanInterfacePara * para,HSPScanPara * p) { HSPmanager * out; int max_depth; int i,j,k; assert(shm); out = new_HSPmanager(query,p->mat,p->drop_off); if( p->seed_factor * para->max_results > shm->len ) { max_depth = shm->len; } else { sort_SeedHitManager_by_score(shm); max_depth = p->seed_factor * para->max_results; } fprintf(stderr,"Looking at %d seend hits from %d\n",max_depth,shm->len); for(i=0;iset[i]); for(j=0;jset[i]->len;j++) { if( shm->set[i]->sh[j]->used == 1 ) { continue; } for(k=j+1;kset[i]->len;k++) { if( shm->set[i]->sh[j]->diagonal + p->twohit_wobble < shm->set[i]->sh[k]->diagonal ) { break; } /* else - we have two potential seeds */ if( shm->set[i]->sh[j]->used != 1 ) { add_pair_HSPmanager(out,shm->set[i]->target,shm->set[i]->sh[j]->posi,shm->set[i]->sh[j]->posj); } if( shm->set[i]->sh[k]->used != 1 ) { add_pair_HSPmanager(out,shm->set[i]->target,shm->set[i]->sh[k]->posi,shm->set[i]->sh[k]->posj); } shm->set[i]->sh[j]->used = 1; shm->set[i]->sh[k]->used = 1; } } } return out; } /* Function: new_twohit_HSPScanInterface(sli,mat,drop_off,score_cutoff) * * Descrip: Builds a 2 hit search model for protein searches * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ # line 137 "hsp2hitscan.dy" HSPScanInterface * new_twohit_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff) { HSPScanInterface * out; HSPScanPara * p; assert(sli); assert(mat); out = HSPScanInterface_alloc(); p = HSPScanPara_alloc(); p->sli = hard_link_SeqLookupInterface(sli); p->mat = hard_link_CompMat(mat); p->drop_off = drop_off; p->score_cutoff = score_cutoff; out->data = (void*)p; out->free_data = simple_HSPScan_free; out->scan_query = one_off_two_hit_HSPscan_query_direct; return out; } /* Function: one_off_two_hit_HSPscan_query_direct(data,seq,para) * * Descrip: two hit approach HSPscan * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 169 "hsp2hitscan.dy" LinearHSPmanager * one_off_two_hit_HSPscan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para) { HSPmanager * hspm; LinearHSPmanager * out; HSPScanPara * p = (HSPScanPara *)data; char * std_aa = "ACDEFGHIKLMNPQRSTVWY"; SeedHitManager * shm; char newseq[5]; int seqno[5]; int base[5]; int start_base; ArraySeqHead * head; int no; int aa; int score; SeqLookupResultInterface * slri; SeqLookupClientInterface * slci; SeqLookupResultStruct * res = NULL; static struct rusage use; int i,k,j; fprintf(stderr,"Got into two hit system!\n"); shm = new_SeedHitManager(); assert(seq != NULL); assert(p != NULL); assert(para != NULL); slci = (*p->sli->get_client)(p->sli->data); getrusage(RUSAGE_SELF,&use); fprintf(stderr,"START %d.%03du %d.%03ds \n", use.ru_utime.tv_sec, use.ru_utime.tv_sec/1000, use.ru_stime.tv_sec, use.ru_stime.tv_sec/1000 ); for(i=0;ilen-5;i++) { if( (*slci->is_populated)(slci->data,seq_number_aa_5mer(seq->seq+i)) ) { slri = (*slci->lookup)(slci->data,seq_number_aa_5mer(seq->seq+i)); res = NULL; for(;(*slri->is_more)(slri->data);) { res = (*slri->next)(slri->data,res); add_SeedHit_SeedHitManager(shm,res->seq,i,res->pos,5); } free_SeqLookupResultInterface(slri); } for(score=0,j=0;j<5;j++) { seqno[j] = base[j]*(toupper(seq->seq[i+j]-'A')); } for(j=0;j<5;j++) { for(aa=0;aa<20;aa++) { if( seq->seq[i+j] == std_aa[aa] ) { continue; } seqno[j] = base[j]*(std_aa[aa]-'A'); no= seqno[0]+seqno[1]+seqno[2]+seqno[3]+seqno[4]; if( (*slci->is_populated)(slci->data,seq_number_aa_5mer(newseq)) ) { slri = (*slci->lookup)(slci->data,seq_number_aa_5mer(newseq)); res = NULL; for(;(*slri->is_more)(slri->data);) { res = (*slri->next)(slri->data,res); add_SeedHit_SeedHitManager(shm,res->seq,i,res->pos,1); } free_SeqLookupResultInterface(slri); } seqno[j] = base[j]*(toupper(seq->seq[i+j]-'A')); newseq[j] = seq->seq[i+j]; } } } getrusage(RUSAGE_SELF,&use); fprintf(stderr,"END OF SEED %d.%03du %d.%03ds \n", use.ru_utime.tv_sec, use.ru_utime.tv_sec/1000, use.ru_stime.tv_sec, use.ru_stime.tv_sec/1000 ); hspm = populate_HSP_from_SeedHitManager(seq,shm,para,p); getrusage(RUSAGE_SELF,&use); fprintf(stderr,"POPULATION %d.%03du %d.%03ds \n", use.ru_utime.tv_sec, use.ru_utime.tv_sec/1000, use.ru_stime.tv_sec, use.ru_stime.tv_sec/1000 ); delete_SeedHitManager(shm); if( para->use_protein_heuristic == TRUE ) { out = new_LinearHSPmanager_heuristic_max(hspm,para->max_results); } else { out = new_LinearHSPmanager_flat(hspm); } fprintf(stdout,"LINEARISED %d.%03du %d.%03ds \n", use.ru_utime.tv_sec, use.ru_utime.tv_sec/1000, use.ru_stime.tv_sec, use.ru_stime.tv_sec/1000 ); return out; } /* Function: compare_SeedHitSet_score(one,two) * * Descrip: internal for score sorting * * * Arg: one [UNKN ] Undocumented argument [SeedHitSet *] * Arg: two [UNKN ] Undocumented argument [SeedHitSet *] * * Return [UNKN ] Undocumented return value [int] * */ # line 317 "hsp2hitscan.dy" int compare_SeedHitSet_score(SeedHitSet * one,SeedHitSet * two) { return two->score - one->score; } /* Function: compare_SeedHit_diagonal(one,two) * * Descrip: internal for diagonal sorting * * * Arg: one [UNKN ] Undocumented argument [SeedHit *] * Arg: two [UNKN ] Undocumented argument [SeedHit *] * * Return [UNKN ] Undocumented return value [int] * */ # line 325 "hsp2hitscan.dy" int compare_SeedHit_diagonal(SeedHit * one,SeedHit * two) { return one->diagonal - two->diagonal; } /* Function: sort_SeedHitManager_by_score(shm) * * Descrip: Sorts hit managers by score (highest first) * * * Arg: shm [UNKN ] Undocumented argument [SeedHitManager *] * */ # line 333 "hsp2hitscan.dy" void sort_SeedHitManager_by_score(SeedHitManager * shm) { sort_SeedHitManager(shm,compare_SeedHitSet_score); } /* Function: sort_SeedHitSet_by_diagonal(sh) * * Descrip: Sorts SeedHit by diagonal (lowest first) * * * Arg: sh [UNKN ] Undocumented argument [SeedHitSet *] * */ # line 341 "hsp2hitscan.dy" void sort_SeedHitSet_by_diagonal(SeedHitSet * sh) { sort_SeedHitSet(sh,compare_SeedHit_diagonal); } /* Function: new_SeedHitManager(void) * * Descrip: Makes an empty SeedHit Manager * * * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ # line 350 "hsp2hitscan.dy" SeedHitManager * new_SeedHitManager(void) { SeedHitManager * out; out = SeedHitManager_alloc_std(); out->hash = g_hash_table_new(g_direct_hash,g_direct_equal); return out; } /* Function: delete_SeedHitManager(shm) * * Descrip: Free SeedHitManager * * * * Arg: shm [UNKN ] Undocumented argument [SeedHitManager *] * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ # line 365 "hsp2hitscan.dy" SeedHitManager * delete_SeedHitManager(SeedHitManager * shm) { g_hash_table_destroy(shm->hash); return free_SeedHitManager(shm); } # line 419 "hsp2hitscan.c" /* Function: hard_link_SeedHit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeedHit *] * * Return [UNKN ] Undocumented return value [SeedHit *] * */ SeedHit * hard_link_SeedHit(SeedHit * obj) { if( obj == NULL ) { warn("Trying to hard link to a SeedHit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SeedHit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeedHit *] * */ SeedHit * SeedHit_alloc(void) { SeedHit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SeedHit *) ckalloc (sizeof(SeedHit))) == NULL) { warn("SeedHit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->diagonal = 0; out->posi = 0; out->posj = 0; out->used = 0; return out; } /* Function: free_SeedHit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeedHit *] * * Return [UNKN ] Undocumented return value [SeedHit *] * */ SeedHit * free_SeedHit(SeedHit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SeedHit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_SeedHitSet(list,i,j) * * Descrip: swap function: an internal for qsort_SeedHitSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [SeedHit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SeedHitSet(SeedHit ** list,int i,int j) { SeedHit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SeedHitSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SeedHitSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [SeedHit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SeedHitSet(SeedHit ** list,int left,int right,int (*comp)(SeedHit * ,SeedHit * )) { int i,last; if( left >= right ) return; swap_SeedHitSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SeedHitSet (list,++last,i); } swap_SeedHitSet (list,left,last); qsort_SeedHitSet(list,left,last-1,comp); qsort_SeedHitSet(list,last+1,right,comp); } /* Function: sort_SeedHitSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SeedHitSet * * * Arg: obj [UNKN ] Object containing list [SeedHitSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SeedHitSet(SeedHitSet * obj,int (*comp)(SeedHit *, SeedHit *)) { qsort_SeedHitSet(obj->sh,0,obj->len-1,comp); return; } /* Function: expand_SeedHitSet(obj,len) * * Descrip: Really an internal function for add_SeedHitSet * * * Arg: obj [UNKN ] Object which contains the list [SeedHitSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SeedHitSet(SeedHitSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SeedHitSet called with no need"); return TRUE; } if( (obj->sh = (SeedHit ** ) ckrealloc (obj->sh,sizeof(SeedHit *)*len)) == NULL) { warn("ckrealloc failed for expand_SeedHitSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SeedHitSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SeedHitSet *] * Arg: add [OWNER] Object to add to the list [SeedHit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SeedHitSet(SeedHitSet * obj,SeedHit * add) { if( obj->len >= obj->maxlen) { if( expand_SeedHitSet(obj,obj->len + SeedHitSetLISTLENGTH) == FALSE) return FALSE; } obj->sh[obj->len++]=add; return TRUE; } /* Function: flush_SeedHitSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SeedHitSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SeedHitSet(SeedHitSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->sh[i] != NULL) { free_SeedHit(obj->sh[i]); obj->sh[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SeedHitSet_alloc_std(void) * * Descrip: Equivalent to SeedHitSet_alloc_len(SeedHitSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SeedHitSet *] * */ SeedHitSet * SeedHitSet_alloc_std(void) { return SeedHitSet_alloc_len(SeedHitSetLISTLENGTH); } /* Function: SeedHitSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SeedHitSet *] * */ SeedHitSet * SeedHitSet_alloc_len(int len) { SeedHitSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SeedHitSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->sh = (SeedHit ** ) ckcalloc (len,sizeof(SeedHit *))) == NULL) { warn("Warning, ckcalloc failed in SeedHitSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SeedHitSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeedHitSet *] * * Return [UNKN ] Undocumented return value [SeedHitSet *] * */ SeedHitSet * hard_link_SeedHitSet(SeedHitSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a SeedHitSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SeedHitSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeedHitSet *] * */ SeedHitSet * SeedHitSet_alloc(void) { SeedHitSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SeedHitSet *) ckalloc (sizeof(SeedHitSet))) == NULL) { warn("SeedHitSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->sh = NULL; out->len = out->maxlen = 0; out->score = 0; return out; } /* Function: free_SeedHitSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeedHitSet *] * * Return [UNKN ] Undocumented return value [SeedHitSet *] * */ SeedHitSet * free_SeedHitSet(SeedHitSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SeedHitSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->sh != NULL) { for(i=0;ilen;i++) { if( obj->sh[i] != NULL) free_SeedHit(obj->sh[i]); } ckfree(obj->sh); } /* obj->target is linked in */ ckfree(obj); return NULL; } /* Function: swap_SeedHitManager(list,i,j) * * Descrip: swap function: an internal for qsort_SeedHitManager * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [SeedHitSet **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SeedHitManager(SeedHitSet ** list,int i,int j) { SeedHitSet * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SeedHitManager(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SeedHitManager which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [SeedHitSet **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SeedHitManager(SeedHitSet ** list,int left,int right,int (*comp)(SeedHitSet * ,SeedHitSet * )) { int i,last; if( left >= right ) return; swap_SeedHitManager(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SeedHitManager (list,++last,i); } swap_SeedHitManager (list,left,last); qsort_SeedHitManager(list,left,last-1,comp); qsort_SeedHitManager(list,last+1,right,comp); } /* Function: sort_SeedHitManager(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SeedHitManager * * * Arg: obj [UNKN ] Object containing list [SeedHitManager *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SeedHitManager(SeedHitManager * obj,int (*comp)(SeedHitSet *, SeedHitSet *)) { qsort_SeedHitManager(obj->set,0,obj->len-1,comp); return; } /* Function: expand_SeedHitManager(obj,len) * * Descrip: Really an internal function for add_SeedHitManager * * * Arg: obj [UNKN ] Object which contains the list [SeedHitManager *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SeedHitManager(SeedHitManager * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SeedHitManager called with no need"); return TRUE; } if( (obj->set = (SeedHitSet ** ) ckrealloc (obj->set,sizeof(SeedHitSet *)*len)) == NULL) { warn("ckrealloc failed for expand_SeedHitManager, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SeedHitManager(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SeedHitManager *] * Arg: add [OWNER] Object to add to the list [SeedHitSet *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SeedHitManager(SeedHitManager * obj,SeedHitSet * add) { if( obj->len >= obj->maxlen) { if( expand_SeedHitManager(obj,obj->len + SeedHitManagerLISTLENGTH) == FALSE) return FALSE; } obj->set[obj->len++]=add; return TRUE; } /* Function: flush_SeedHitManager(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SeedHitManager *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SeedHitManager(SeedHitManager * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->set[i] != NULL) { free_SeedHitSet(obj->set[i]); obj->set[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SeedHitManager_alloc_std(void) * * Descrip: Equivalent to SeedHitManager_alloc_len(SeedHitManagerLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ SeedHitManager * SeedHitManager_alloc_std(void) { return SeedHitManager_alloc_len(SeedHitManagerLISTLENGTH); } /* Function: SeedHitManager_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ SeedHitManager * SeedHitManager_alloc_len(int len) { SeedHitManager * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SeedHitManager_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->set = (SeedHitSet ** ) ckcalloc (len,sizeof(SeedHitSet *))) == NULL) { warn("Warning, ckcalloc failed in SeedHitManager_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SeedHitManager(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeedHitManager *] * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ SeedHitManager * hard_link_SeedHitManager(SeedHitManager * obj) { if( obj == NULL ) { warn("Trying to hard link to a SeedHitManager object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SeedHitManager_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ SeedHitManager * SeedHitManager_alloc(void) { SeedHitManager * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SeedHitManager *) ckalloc (sizeof(SeedHitManager))) == NULL) { warn("SeedHitManager_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->set = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_SeedHitManager(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeedHitManager *] * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ SeedHitManager * free_SeedHitManager(SeedHitManager * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SeedHitManager obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->hash is linked in */ if( obj->set != NULL) { for(i=0;ilen;i++) { if( obj->set[i] != NULL) free_SeedHitSet(obj->set[i]); } ckfree(obj->set); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/hsp2hitscan.h0000644000175000001440000003542010670453712017241 0ustar philippusers#ifndef DYNAMITEhsp2hitscanHEADERFILE #define DYNAMITEhsp2hitscanHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "hsplookupscan.h" #define SeedHitSetLISTLENGTH 200 #define SeedHitManagerLISTLENGTH 500 struct Wise2_SeedHit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int diagonal; int posi; int posj; int used; } ; /* SeedHit defined */ #ifndef DYNAMITE_DEFINED_SeedHit typedef struct Wise2_SeedHit Wise2_SeedHit; #define SeedHit Wise2_SeedHit #define DYNAMITE_DEFINED_SeedHit #endif struct Wise2_SeedHitSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeedHit ** sh; int len;/* len for above sh */ int maxlen; /* maxlen for above sh */ Sequence * target; int score; } ; /* SeedHitSet defined */ #ifndef DYNAMITE_DEFINED_SeedHitSet typedef struct Wise2_SeedHitSet Wise2_SeedHitSet; #define SeedHitSet Wise2_SeedHitSet #define DYNAMITE_DEFINED_SeedHitSet #endif struct Wise2_SeedHitManager { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GHashTable * hash; SeedHitSet ** set; int len;/* len for above set */ int maxlen; /* maxlen for above set */ } ; /* SeedHitManager defined */ #ifndef DYNAMITE_DEFINED_SeedHitManager typedef struct Wise2_SeedHitManager Wise2_SeedHitManager; #define SeedHitManager Wise2_SeedHitManager #define DYNAMITE_DEFINED_SeedHitManager #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_SeedHit(posi,posj) * * Descrip: Makes a new SeedHit * * * Arg: posi [UNKN ] Undocumented argument [int] * Arg: posj [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeedHit *] * */ SeedHit * Wise2_new_SeedHit(int posi,int posj); #define new_SeedHit Wise2_new_SeedHit /* Function: add_SeedHit_SeedHitManager(shm,t,posi,posj,score) * * Descrip: Adds a new position to the manger, allocating any * new datastructures * * * Arg: shm [UNKN ] Undocumented argument [SeedHitManager *] * Arg: t [UNKN ] Undocumented argument [Sequence *] * Arg: posi [UNKN ] Undocumented argument [int] * Arg: posj [UNKN ] Undocumented argument [int] * Arg: score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SeedHit_SeedHitManager(SeedHitManager * shm,Sequence * t,int posi,int posj,int score); #define add_SeedHit_SeedHitManager Wise2_add_SeedHit_SeedHitManager /* Function: populate_HSP_from_SeedHitManager(query,shm,para,p) * * Descrip: Chooses which Seeds to use for HSPs. If there are more than factor x max_results * cases, restricted it to factor x max_results scored by seed hits. Then askes * for two diagonal seeds within a wobble factor to start the HSP process * * * Arg: query [UNKN ] Undocumented argument [Sequence *] * Arg: shm [UNKN ] Undocumented argument [SeedHitManager *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * Arg: p [UNKN ] Undocumented argument [HSPScanPara *] * * Return [UNKN ] Undocumented return value [HSPmanager *] * */ HSPmanager * Wise2_populate_HSP_from_SeedHitManager(Sequence * query,SeedHitManager * shm,HSPScanInterfacePara * para,HSPScanPara * p); #define populate_HSP_from_SeedHitManager Wise2_populate_HSP_from_SeedHitManager /* Function: new_twohit_HSPScanInterface(sli,mat,drop_off,score_cutoff) * * Descrip: Builds a 2 hit search model for protein searches * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ HSPScanInterface * Wise2_new_twohit_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff); #define new_twohit_HSPScanInterface Wise2_new_twohit_HSPScanInterface /* Function: one_off_two_hit_HSPscan_query_direct(data,seq,para) * * Descrip: two hit approach HSPscan * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_one_off_two_hit_HSPscan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para); #define one_off_two_hit_HSPscan_query_direct Wise2_one_off_two_hit_HSPscan_query_direct /* Function: compare_SeedHitSet_score(one,two) * * Descrip: internal for score sorting * * * Arg: one [UNKN ] Undocumented argument [SeedHitSet *] * Arg: two [UNKN ] Undocumented argument [SeedHitSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_compare_SeedHitSet_score(SeedHitSet * one,SeedHitSet * two); #define compare_SeedHitSet_score Wise2_compare_SeedHitSet_score /* Function: compare_SeedHit_diagonal(one,two) * * Descrip: internal for diagonal sorting * * * Arg: one [UNKN ] Undocumented argument [SeedHit *] * Arg: two [UNKN ] Undocumented argument [SeedHit *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_compare_SeedHit_diagonal(SeedHit * one,SeedHit * two); #define compare_SeedHit_diagonal Wise2_compare_SeedHit_diagonal /* Function: sort_SeedHitManager_by_score(shm) * * Descrip: Sorts hit managers by score (highest first) * * * Arg: shm [UNKN ] Undocumented argument [SeedHitManager *] * */ void Wise2_sort_SeedHitManager_by_score(SeedHitManager * shm); #define sort_SeedHitManager_by_score Wise2_sort_SeedHitManager_by_score /* Function: sort_SeedHitSet_by_diagonal(sh) * * Descrip: Sorts SeedHit by diagonal (lowest first) * * * Arg: sh [UNKN ] Undocumented argument [SeedHitSet *] * */ void Wise2_sort_SeedHitSet_by_diagonal(SeedHitSet * sh); #define sort_SeedHitSet_by_diagonal Wise2_sort_SeedHitSet_by_diagonal /* Function: new_SeedHitManager(void) * * Descrip: Makes an empty SeedHit Manager * * * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ SeedHitManager * Wise2_new_SeedHitManager(void); #define new_SeedHitManager Wise2_new_SeedHitManager /* Function: delete_SeedHitManager(shm) * * Descrip: Free SeedHitManager * * * * Arg: shm [UNKN ] Undocumented argument [SeedHitManager *] * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ SeedHitManager * Wise2_delete_SeedHitManager(SeedHitManager * shm); #define delete_SeedHitManager Wise2_delete_SeedHitManager /* Function: hard_link_SeedHit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeedHit *] * * Return [UNKN ] Undocumented return value [SeedHit *] * */ SeedHit * Wise2_hard_link_SeedHit(SeedHit * obj); #define hard_link_SeedHit Wise2_hard_link_SeedHit /* Function: SeedHit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeedHit *] * */ SeedHit * Wise2_SeedHit_alloc(void); #define SeedHit_alloc Wise2_SeedHit_alloc /* Function: free_SeedHit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeedHit *] * * Return [UNKN ] Undocumented return value [SeedHit *] * */ SeedHit * Wise2_free_SeedHit(SeedHit * obj); #define free_SeedHit Wise2_free_SeedHit /* Function: add_SeedHitSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SeedHitSet *] * Arg: add [OWNER] Object to add to the list [SeedHit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SeedHitSet(SeedHitSet * obj,SeedHit * add); #define add_SeedHitSet Wise2_add_SeedHitSet /* Function: flush_SeedHitSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SeedHitSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SeedHitSet(SeedHitSet * obj); #define flush_SeedHitSet Wise2_flush_SeedHitSet /* Function: SeedHitSet_alloc_std(void) * * Descrip: Equivalent to SeedHitSet_alloc_len(SeedHitSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SeedHitSet *] * */ SeedHitSet * Wise2_SeedHitSet_alloc_std(void); #define SeedHitSet_alloc_std Wise2_SeedHitSet_alloc_std /* Function: SeedHitSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SeedHitSet *] * */ SeedHitSet * Wise2_SeedHitSet_alloc_len(int len); #define SeedHitSet_alloc_len Wise2_SeedHitSet_alloc_len /* Function: hard_link_SeedHitSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeedHitSet *] * * Return [UNKN ] Undocumented return value [SeedHitSet *] * */ SeedHitSet * Wise2_hard_link_SeedHitSet(SeedHitSet * obj); #define hard_link_SeedHitSet Wise2_hard_link_SeedHitSet /* Function: SeedHitSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeedHitSet *] * */ SeedHitSet * Wise2_SeedHitSet_alloc(void); #define SeedHitSet_alloc Wise2_SeedHitSet_alloc /* Function: free_SeedHitSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeedHitSet *] * * Return [UNKN ] Undocumented return value [SeedHitSet *] * */ SeedHitSet * Wise2_free_SeedHitSet(SeedHitSet * obj); #define free_SeedHitSet Wise2_free_SeedHitSet /* Function: add_SeedHitManager(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SeedHitManager *] * Arg: add [OWNER] Object to add to the list [SeedHitSet *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SeedHitManager(SeedHitManager * obj,SeedHitSet * add); #define add_SeedHitManager Wise2_add_SeedHitManager /* Function: flush_SeedHitManager(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SeedHitManager *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SeedHitManager(SeedHitManager * obj); #define flush_SeedHitManager Wise2_flush_SeedHitManager /* Function: SeedHitManager_alloc_std(void) * * Descrip: Equivalent to SeedHitManager_alloc_len(SeedHitManagerLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ SeedHitManager * Wise2_SeedHitManager_alloc_std(void); #define SeedHitManager_alloc_std Wise2_SeedHitManager_alloc_std /* Function: SeedHitManager_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ SeedHitManager * Wise2_SeedHitManager_alloc_len(int len); #define SeedHitManager_alloc_len Wise2_SeedHitManager_alloc_len /* Function: hard_link_SeedHitManager(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SeedHitManager *] * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ SeedHitManager * Wise2_hard_link_SeedHitManager(SeedHitManager * obj); #define hard_link_SeedHitManager Wise2_hard_link_SeedHitManager /* Function: SeedHitManager_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ SeedHitManager * Wise2_SeedHitManager_alloc(void); #define SeedHitManager_alloc Wise2_SeedHitManager_alloc /* Function: free_SeedHitManager(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SeedHitManager *] * * Return [UNKN ] Undocumented return value [SeedHitManager *] * */ SeedHitManager * Wise2_free_SeedHitManager(SeedHitManager * obj); #define free_SeedHitManager Wise2_free_SeedHitManager /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_SeedHitSet(SeedHit ** list,int i,int j) ; #define swap_SeedHitSet Wise2_swap_SeedHitSet void Wise2_qsort_SeedHitSet(SeedHit ** list,int left,int right,int (*comp)(SeedHit * ,SeedHit * )); #define qsort_SeedHitSet Wise2_qsort_SeedHitSet void Wise2_sort_SeedHitSet(SeedHitSet * obj,int (*comp)(SeedHit *, SeedHit *)); #define sort_SeedHitSet Wise2_sort_SeedHitSet boolean Wise2_expand_SeedHitSet(SeedHitSet * obj,int len); #define expand_SeedHitSet Wise2_expand_SeedHitSet void Wise2_swap_SeedHitManager(SeedHitSet ** list,int i,int j) ; #define swap_SeedHitManager Wise2_swap_SeedHitManager void Wise2_qsort_SeedHitManager(SeedHitSet ** list,int left,int right,int (*comp)(SeedHitSet * ,SeedHitSet * )); #define qsort_SeedHitManager Wise2_qsort_SeedHitManager void Wise2_sort_SeedHitManager(SeedHitManager * obj,int (*comp)(SeedHitSet *, SeedHitSet *)); #define sort_SeedHitManager Wise2_sort_SeedHitManager boolean Wise2_expand_SeedHitManager(SeedHitManager * obj,int len); #define expand_SeedHitManager Wise2_expand_SeedHitManager #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/sequencestream.c0000644000175000001440000001365210670453713020036 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "sequencestream.h" /* Function: untyped_SequenceSet_from_Stream(rs) * * Descrip: untyped version of reading from Wise2ReadStreamInterface * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [void *] * */ # line 17 "sequencestream.dy" void * untyped_SequenceSet_from_Stream(Wise2ReadStreamInterface * rs) { SequenceSet * set; set = typed_SequenceSet_from_Stream(rs); return (void*) set; } /* Function: typed_SequenceSet_from_Stream(rs) * * Descrip: Typed version of reading from Stream, making a SequenceSet * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ # line 29 "sequencestream.dy" SequenceSet * typed_SequenceSet_from_Stream(Wise2ReadStreamInterface * rs) { SequenceSet * out; char buffer[512]; Sequence * curr; char * pos; char * desc; out = SequenceSet_alloc_std(); curr = NULL; while( WISE2_READ_BUFFER(buffer,512,rs) != NULL ) { if( strncmp(buffer,"//",2) == 0 ) { /* fprintf(stderr,"In reading sequence set, have finally" " a sequence with length %d and first sequence %s\n", out->len,out->set[0]->seq); */ return out; } if( buffer[0] == '>' ) { /* make new sequence with this position */ /* delimit name after '>' */ for(pos=buffer+1;*pos;pos++) { if( isspace(*pos) ) { *pos = '\0'; break; } } /* find next string if there, will be description */ for(++pos;*pos && isspace(*pos);pos++) { ; } if( *pos != '\0' && !isspace(*pos) ) { desc = pos; /* could be '\n' delimited or '\0' delimited */ for(;*pos != '\0' && *pos != '\n';pos++) { ; } *pos = '\0'; } else { desc = NULL; } /* if there has been a previous sequence, it is in curr. Terminate the string at curr->len */ if( curr != NULL ) { curr->seq[curr->len] = '\0'; } curr = Sequence_alloc(); curr->name = stringalloc(buffer+1); curr->seq = calloc(512,sizeof(char)); curr->len = 0; curr->maxlen = 512; if( desc != NULL ) { curr->desc = stringalloc(desc); } add_SequenceSet(out,curr); /* fprintf(stderr, "SEQUENCE: %s\n", curr->name); */ continue; } /* this is a sequence line */ for(pos = buffer;*pos;pos++) { if( isalpha(*pos) ) { curr->seq[curr->len++] = *pos; } if( curr->len+1 >= curr->maxlen ) { void *tmpp; if( curr->maxlen >= 32768 ) { curr->maxlen += 32768; } else { curr->maxlen *= 2; } tmpp = realloc(curr->seq,sizeof(char)*curr->maxlen); if (tmpp == NULL) { fatal("Failed in realloc()"); } curr->seq = tmpp; } } } /* fprintf(stderr,"In reading sequence set, " "have finally a sequence with length %d and " "first sequence %s\n",out->len,out->set[0]->seq); */ return out; } /* Function: typed_write_SequenceSet_to_Stream(set,ws) * * Descrip: typed version of writing a sequence set to a stream * * * Arg: set [UNKN ] Undocumented argument [SequenceSet *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ # line 139 "sequencestream.dy" void typed_write_SequenceSet_to_Stream(SequenceSet * set,Wise2WriteStreamInterface * ws) { int i; for(i=0;ilen;i++) { typed_write_one_Sequence_to_Stream(set->set[i],ws); } WISE2_WRITE_STRING("//\n",ws); } /* Function: untyped_write_SequenceSet_to_Stream(s,ws) * * Descrip: untyped version for writing a sequence set to a stream * * * Arg: s [UNKN ] Undocumented argument [void *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ # line 154 "sequencestream.dy" void untyped_write_SequenceSet_to_Stream(void * s,Wise2WriteStreamInterface * ws) { typed_write_SequenceSet_to_Stream((SequenceSet*)s,ws); } /* Function: typed_write_one_Sequence_to_Stream(seq,ws) * * Descrip: internal function for writing out one sequence * * * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ # line 162 "sequencestream.dy" void typed_write_one_Sequence_to_Stream(Sequence * seq,Wise2WriteStreamInterface * ws) { char buffer[512]; int i; if( seq->desc != NULL) { sprintf(buffer,">%s %-80s\n",seq->name,seq->desc); } else { sprintf(buffer,">%s\n",seq->name); } WISE2_WRITE_STRING(buffer,ws); for(i=0;ilen;) { buffer[0] = '\0'; if( i+80 < seq->len ) { strncpy(buffer,seq->seq+i,80); i = i+80; buffer[80] = '\0'; } else { strcpy(buffer,seq->seq+i); i = seq->len; } strcat(buffer,"\n"); WISE2_WRITE_STRING(buffer,ws); } } /* Function: untyped_write_Sequence_to_Stream(seq,ws) * * Descrip: untyped write one sequence stream * * * Arg: seq [UNKN ] Undocumented argument [void *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ # line 196 "sequencestream.dy" void untyped_write_Sequence_to_Stream(void * seq,Wise2WriteStreamInterface * ws) { typed_write_one_Sequence_to_Stream((Sequence *)seq,ws); WISE2_WRITE_STRING("//\n",ws); } /* Function: untyped_read_Sequence_from_Stream(rs) * * Descrip: reading one sequence from stream * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [void *] * */ # line 205 "sequencestream.dy" void * untyped_read_Sequence_from_Stream(Wise2ReadStreamInterface * rs) { SequenceSet * out; Sequence * seq; out = typed_SequenceSet_from_Stream(rs); if( out == NULL || out->len == 0 ) { warn("In reading sequences, no sequences found"); return NULL; } seq = hard_link_Sequence(out->set[0]); free_SequenceSet(out); return (void*) seq; } # line 256 "sequencestream.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/sequencestream.h0000644000175000001440000000735710670453713020050 0ustar philippusers#ifndef DYNAMITEsequencestreamHEADERFILE #define DYNAMITEsequencestreamHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: untyped_SequenceSet_from_Stream(rs) * * Descrip: untyped version of reading from Wise2ReadStreamInterface * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [void *] * */ void * Wise2_untyped_SequenceSet_from_Stream(Wise2ReadStreamInterface * rs); #define untyped_SequenceSet_from_Stream Wise2_untyped_SequenceSet_from_Stream /* Function: typed_SequenceSet_from_Stream(rs) * * Descrip: Typed version of reading from Stream, making a SequenceSet * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ SequenceSet * Wise2_typed_SequenceSet_from_Stream(Wise2ReadStreamInterface * rs); #define typed_SequenceSet_from_Stream Wise2_typed_SequenceSet_from_Stream /* Function: typed_write_SequenceSet_to_Stream(set,ws) * * Descrip: typed version of writing a sequence set to a stream * * * Arg: set [UNKN ] Undocumented argument [SequenceSet *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ void Wise2_typed_write_SequenceSet_to_Stream(SequenceSet * set,Wise2WriteStreamInterface * ws); #define typed_write_SequenceSet_to_Stream Wise2_typed_write_SequenceSet_to_Stream /* Function: untyped_write_SequenceSet_to_Stream(s,ws) * * Descrip: untyped version for writing a sequence set to a stream * * * Arg: s [UNKN ] Undocumented argument [void *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ void Wise2_untyped_write_SequenceSet_to_Stream(void * s,Wise2WriteStreamInterface * ws); #define untyped_write_SequenceSet_to_Stream Wise2_untyped_write_SequenceSet_to_Stream /* Function: typed_write_one_Sequence_to_Stream(seq,ws) * * Descrip: internal function for writing out one sequence * * * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ void Wise2_typed_write_one_Sequence_to_Stream(Sequence * seq,Wise2WriteStreamInterface * ws); #define typed_write_one_Sequence_to_Stream Wise2_typed_write_one_Sequence_to_Stream /* Function: untyped_write_Sequence_to_Stream(seq,ws) * * Descrip: untyped write one sequence stream * * * Arg: seq [UNKN ] Undocumented argument [void *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ void Wise2_untyped_write_Sequence_to_Stream(void * seq,Wise2WriteStreamInterface * ws); #define untyped_write_Sequence_to_Stream Wise2_untyped_write_Sequence_to_Stream /* Function: untyped_read_Sequence_from_Stream(rs) * * Descrip: reading one sequence from stream * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [void *] * */ void * Wise2_untyped_read_Sequence_from_Stream(Wise2ReadStreamInterface * rs); #define untyped_read_Sequence_from_Stream Wise2_untyped_read_Sequence_from_Stream /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/protein.typemap0000644000175000001440000000034410670453712017720 0ustar philippusers TYPEMAP Wise2_Protein * T_Wise2_Protein INPUT T_Wise2_Protein $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_Protein *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_Protein sv_setref_pv($arg, "Wise2::Protein", (void*) $var); wise-2.4.1/src/dynlibsrc/cdnadb.typemap0000644000175000001440000000033610670453712017454 0ustar philippusers TYPEMAP Wise2_cDNADB * T_Wise2_cDNADB INPUT T_Wise2_cDNADB $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_cDNADB *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_cDNADB sv_setref_pv($arg, "Wise2::cDNADB", (void*) $var); wise-2.4.1/src/dynlibsrc/embl.dy0000644000175000001440000000135107313404540016106 0ustar philippusers %{ #include "wisebase.h" %} %{ #include "embl.h" %func internal function for reading EMBL feature tables. reads in line. If id 3 in, returns FALSE. Otherwise strips FT up to central tab region. %% boolean next_feature_tab_line(char * buffer,int maxlen,FILE * ifp) { char * runner; if( fgets(buffer,maxlen,ifp) == NULL ) { buffer[0]= '\0'; return FALSE; } if( strstartcmp(buffer,"FT") != 0) { return FALSE; } for(runner = buffer+2;*runner && isspace((int)*runner);runner++) ; if( *runner == '\0' ) { warn("A supposed EMBL feature line with nothing on it"); return FALSE; } if( runner - buffer > 3 ) { memmove(buffer,runner,strlen(runner)); return TRUE; } return FALSE; } %} wise-2.4.1/src/dynlibsrc/packaln_api.h0000644000175000001440000002201110670453712017245 0ustar philippusers /* Functions that create, manipulate or act on PackAln * * Wise2_show_simple_PackAln * Wise2_show_bits_and_cumlative_PackAln * Wise2_hard_link_PackAln * Wise2_PackAln_alloc_std * Wise2_access_pau_PackAln * Wise2_length_pau_PackAln * Wise2_flush_PackAln * Wise2_add_PackAln * Wise2_replace_score_PackAln * Wise2_access_score_PackAln * Wise2_free_PackAln [destructor] * */ /* Functions that create, manipulate or act on PackAlnUnit * * Wise2_hard_link_PackAlnUnit * Wise2_PackAlnUnit_alloc * Wise2_replace_i_PackAlnUnit * Wise2_access_i_PackAlnUnit * Wise2_replace_j_PackAlnUnit * Wise2_access_j_PackAlnUnit * Wise2_replace_state_PackAlnUnit * Wise2_access_state_PackAlnUnit * Wise2_replace_score_PackAlnUnit * Wise2_access_score_PackAlnUnit * Wise2_free_PackAlnUnit [destructor] * */ /* API for object PackAln */ /* Function: Wise2_show_simple_PackAln(pal,ofp) * * Descrip: shows packaln with a pretty verbose debugging * format * * * Arg: pal Undocumented argument [Wise2_PackAln *] * Arg: ofp Undocumented argument [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_show_simple_PackAln( Wise2_PackAln * pal,FILE * ofp); /* Function: Wise2_show_bits_and_cumlative_PackAln(pal,ofp) * * Descrip: Shows packaln as: * * i,j,state,score,bits,cumlative-score,cumlative-bits * * cumlative score and cumlative bits are useful sometimes * * * Arg: pal Undocumented argument [Wise2_PackAln *] * Arg: ofp Undocumented argument [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_show_bits_and_cumlative_PackAln( Wise2_PackAln * pal,FILE * ofp); /* Function: Wise2_hard_link_PackAln(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_PackAln *] * * Returns Undocumented return value [Wise2_PackAln *] * */ Wise2_PackAln * Wise2_hard_link_PackAln( Wise2_PackAln * obj); /* Function: Wise2_PackAln_alloc_std(void) * * Descrip: Equivalent to PackAln_alloc_len(PackAlnLISTLENGTH) * * * * Returns Undocumented return value [Wise2_PackAln *] * */ Wise2_PackAln * Wise2_PackAln_alloc_std(); /* Function: Wise2_access_pau_PackAln(obj,i) * * Descrip: Access members stored in the pau list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_PackAln *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_PackAlnUnit *] * */ Wise2_PackAlnUnit * Wise2_access_pau_PackAln( Wise2_PackAln * obj,int i); /* Function: Wise2_length_pau_PackAln(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_PackAln *] * * Returns length of the list [int] * */ int Wise2_length_pau_PackAln( Wise2_PackAln * obj); /* Function: Wise2_flush_PackAln(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_PackAln *] * * Returns Undocumented return value [int] * */ int Wise2_flush_PackAln( Wise2_PackAln * obj); /* Function: Wise2_add_PackAln(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_PackAln *] * Arg: add Object to add to the list [Wise2_PackAlnUnit *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_PackAln( Wise2_PackAln * obj,Wise2_PackAlnUnit * add); /* Function: Wise2_replace_score_PackAln(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PackAln *] * Arg: score New value of the variable [int] * * Returns member variable score [boolean] * */ boolean Wise2_replace_score_PackAln( Wise2_PackAln * obj,int score); /* Function: Wise2_access_score_PackAln(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PackAln *] * * Returns member variable score [int] * */ int Wise2_access_score_PackAln( Wise2_PackAln * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_PackAln(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_PackAln *] * * Returns Undocumented return value [Wise2_PackAln *] * */ Wise2_PackAln * Wise2_free_PackAln( Wise2_PackAln * obj); /* API for object PackAlnUnit */ /* Function: Wise2_hard_link_PackAlnUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_PackAlnUnit *] * * Returns Undocumented return value [Wise2_PackAlnUnit *] * */ Wise2_PackAlnUnit * Wise2_hard_link_PackAlnUnit( Wise2_PackAlnUnit * obj); /* Function: Wise2_PackAlnUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_PackAlnUnit *] * */ Wise2_PackAlnUnit * Wise2_PackAlnUnit_alloc(); /* Function: Wise2_replace_i_PackAlnUnit(obj,i) * * Descrip: Replace member variable i * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PackAlnUnit *] * Arg: i New value of the variable [int] * * Returns member variable i [boolean] * */ boolean Wise2_replace_i_PackAlnUnit( Wise2_PackAlnUnit * obj,int i); /* Function: Wise2_access_i_PackAlnUnit(obj) * * Descrip: Access member variable i * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PackAlnUnit *] * * Returns member variable i [int] * */ int Wise2_access_i_PackAlnUnit( Wise2_PackAlnUnit * obj); /* Function: Wise2_replace_j_PackAlnUnit(obj,j) * * Descrip: Replace member variable j * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PackAlnUnit *] * Arg: j New value of the variable [int] * * Returns member variable j [boolean] * */ boolean Wise2_replace_j_PackAlnUnit( Wise2_PackAlnUnit * obj,int j); /* Function: Wise2_access_j_PackAlnUnit(obj) * * Descrip: Access member variable j * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PackAlnUnit *] * * Returns member variable j [int] * */ int Wise2_access_j_PackAlnUnit( Wise2_PackAlnUnit * obj); /* Function: Wise2_replace_state_PackAlnUnit(obj,state) * * Descrip: Replace member variable state * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PackAlnUnit *] * Arg: state New value of the variable [int] * * Returns member variable state [boolean] * */ boolean Wise2_replace_state_PackAlnUnit( Wise2_PackAlnUnit * obj,int state); /* Function: Wise2_access_state_PackAlnUnit(obj) * * Descrip: Access member variable state * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PackAlnUnit *] * * Returns member variable state [int] * */ int Wise2_access_state_PackAlnUnit( Wise2_PackAlnUnit * obj); /* Function: Wise2_replace_score_PackAlnUnit(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PackAlnUnit *] * Arg: score New value of the variable [int] * * Returns member variable score [boolean] * */ boolean Wise2_replace_score_PackAlnUnit( Wise2_PackAlnUnit * obj,int score); /* Function: Wise2_access_score_PackAlnUnit(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_PackAlnUnit *] * * Returns member variable score [int] * */ int Wise2_access_score_PackAlnUnit( Wise2_PackAlnUnit * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_PackAlnUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_PackAlnUnit *] * * Returns Undocumented return value [Wise2_PackAlnUnit *] * */ Wise2_PackAlnUnit * Wise2_free_PackAlnUnit( Wise2_PackAlnUnit * obj); wise-2.4.1/src/dynlibsrc/packaln_api.t0000644000175000001440000000014210670453712017262 0ustar philippuserstypedef struct Wise2_PackAln Wise2_PackAln; typedef struct Wise2_PackAlnUnit Wise2_PackAlnUnit; wise-2.4.1/src/dynlibsrc/translation.dy0000644000175000001440000000606107534626465017551 0ustar philippusers %{ #include "dyna.h" %} api object Translation func get_Protein_from_Translation des free_Translation endobject endapi friend Transcript struct Translation int start int end Transcript * parent !link Protein * protein %info Translation represents a single translation from a cDNA. Although most cDNAs will have one translation, this does allow us to deal with alternative translation points etc. As with Transcript and Gene before it, the translation does not necessarily have any sequence in it. When sequence is asked for by get_Protein_from_Translation() the cache is checked, and if it is empty, then the transcript's DNA is called for, and the converted into the translation with appropiate start and stops. Of course, get_Protein_from_Translation can potentially trigger the construction of an entire gene upstairs, but that need not worry you here %% %{ #include "translation.h" %func Makes a complete clean copy of the translation %% Translation * copy_Translation(Translation * t) { Translation * out; out = Translation_alloc(); out->start = t->start; out->end = t->end; return out; } %func Gets the protein %arg ts translation ct codon table to use return s Protein sequence %% Protein * get_Protein_from_Translation(Translation * ts,CodonTable * ct) { cDNA * cd; int i,j; Sequence * seq; char buffer[64]; assert(ts); assert(ct); /* fprintf(stderr,"Codon table is %d\n",ct);*/ if( ts->protein != NULL) return ts->protein; if( ts->parent == NULL ) { warn("Cannot get Protein from translation as no parent!"); return NULL; } cd = get_cDNA_from_Transcript(ts->parent); if( cd == NULL ) { warn("Cannot make translation as can't get transcript!"); return NULL; } if( cd->baseseq == NULL ) { warn("A bad error - a non NULL cDNA with a null sequence object. No translation here!"); return NULL; } if( cd->baseseq->len == 0 ) { warn("Attempting to translate a zero length cDNA. Yikes!"); return NULL; } seq = Sequence_alloc(); sprintf(buffer,"%s.tr",cDNA_name(cd)); seq->name = stringalloc(buffer); seq->seq = ckcalloc((cd->baseseq->len/3) + 2,sizeof(char)); seq->type = SEQUENCE_PROTEIN; if( cd->baseseq->len%3 != 0 ) { warn("Problem in making translation, cDNA is not mod3! - length is %d - transcript id %s",cd->baseseq->len,seq->name); } for(i=0,j=0;ibaseseq->len;i+=3,j++) { if( is_stop_codon(codon_from_seq(cd->baseseq->seq+i),ct) == TRUE ) { if( i+3 >= cd->baseseq->len ) break; else { warn("Got a stop codon in the middle of a translation at postion [%d]. Yuk!",i); seq->seq[j] = '*'; } } else { seq->seq[j] = aminoacid_from_seq(ct,cd->baseseq->seq+i); } } seq->seq[j]='\0'; make_len_type_Sequence(seq); /*write_fasta_Sequence(seq,stdout);*/ seq->type = SEQUENCE_PROTEIN; ts->protein = Protein_from_Sequence(seq); return ts->protein; } %func shows a translation in vaguely human form %% void show_Translation(Translation *ts,FILE * ofp) { fprintf(ofp,"Translation %d - %d\n",ts->start,ts->end); } %} wise-2.4.1/src/dynlibsrc/translation.xs0000644000175000001440000000412610670453713017554 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::Translation Wise2_Protein * get_Protein_from_Translation(ts,ct) Wise2_Translation * ts Wise2_CodonTable * ct INIT: Wise2_Protein * temp; CODE: temp = Wise2_hard_link_Protein(Wise2_get_Protein_from_Translation(ts,ct)); RETVAL = temp; OUTPUT: RETVAL Wise2_Translation * hard_link_Translation(obj) Wise2_Translation * obj CODE: RETVAL = Wise2_hard_link_Translation(obj); OUTPUT: RETVAL Wise2_Translation * alloc() CODE: RETVAL = Wise2_Translation_alloc(); OUTPUT: RETVAL boolean set_start(obj,start) Wise2_Translation * obj int start CODE: RETVAL = Wise2_replace_start_Translation(obj,start); OUTPUT: RETVAL int start(obj) Wise2_Translation * obj CODE: RETVAL = Wise2_access_start_Translation(obj); OUTPUT: RETVAL boolean set_end(obj,end) Wise2_Translation * obj int end CODE: RETVAL = Wise2_replace_end_Translation(obj,end); OUTPUT: RETVAL int end(obj) Wise2_Translation * obj CODE: RETVAL = Wise2_access_end_Translation(obj); OUTPUT: RETVAL boolean set_parent(obj,parent) Wise2_Translation * obj Wise2_Transcript * parent CODE: RETVAL = Wise2_replace_parent_Translation(obj,Wise2_hard_link_Transcript(parent)); OUTPUT: RETVAL Wise2_Transcript * parent(obj) Wise2_Translation * obj INIT: Wise2_Transcript * temp; CODE: temp = Wise2_hard_link_Transcript(Wise2_access_parent_Translation(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_protein(obj,protein) Wise2_Translation * obj Wise2_Protein * protein CODE: RETVAL = Wise2_replace_protein_Translation(obj,Wise2_hard_link_Protein(protein)); OUTPUT: RETVAL Wise2_Protein * protein(obj) Wise2_Translation * obj INIT: Wise2_Protein * temp; CODE: temp = Wise2_hard_link_Protein(Wise2_access_protein_Translation(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_Translation * new(class) char * class PPCODE: Wise2_Translation * out; out = Wise2_Translation_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_Translation * obj CODE: Wise2_free_Translation(obj); MODULE = Wise2 PACKAGE = Wise2 wise-2.4.1/src/dynlibsrc/cdna_api.h0000644000175000001440000001121010670453712016540 0ustar philippusers /* Functions that create, manipulate or act on cDNA * * Wise2_truncate_cDNA * Wise2_read_fasta_file_cDNA * Wise2_cDNA_name * Wise2_cDNA_length * Wise2_cDNA_seqchar * Wise2_cDNA_from_Sequence * Wise2_hard_link_cDNA * Wise2_cDNA_alloc * Wise2_replace_baseseq_cDNA * Wise2_access_baseseq_cDNA * Wise2_free_cDNA [destructor] * */ /* API for object cDNA */ /* Function: Wise2_truncate_cDNA(cdna,start,stop) * * Descrip: Truncates a cDNA sequence. Basically uses * the /magic_trunc_Sequence function (of course!) * * It does not alter cdna, rather it returns a new * sequence with that truncation * * * Arg: cdna cDNA that is truncated [Wise2_cDNA *] * Arg: start Undocumented argument [int] * Arg: stop Undocumented argument [int] * * Returns Undocumented return value [Wise2_cDNA *] * */ Wise2_cDNA * Wise2_truncate_cDNA( Wise2_cDNA * cdna,int start,int stop); /* Function: Wise2_read_fasta_file_cDNA(filename) * * Descrip: Reads a fasta file assumming that it is cDNA. * Will complain if it is not, and return NULL. * * * Arg: filename filename to be opened and read [char *] * * Returns Undocumented return value [Wise2_cDNA *] * */ Wise2_cDNA * Wise2_read_fasta_file_cDNA( char * filename); /* Function: Wise2_cDNA_name(cdna) * * Descrip: Returns the name of the cDNA * * * Arg: cdna Undocumented argument [Wise2_cDNA *] * * Returns Undocumented return value [char *] * */ char * Wise2_cDNA_name( Wise2_cDNA * cdna); /* Function: Wise2_cDNA_length(cdna) * * Descrip: Returns the length of the cDNA * * * Arg: cdna Undocumented argument [Wise2_cDNA *] * * Returns Undocumented return value [int] * */ int Wise2_cDNA_length( Wise2_cDNA * cdna); /* Function: Wise2_cDNA_seqchar(cdna,pos) * * Descrip: Returns sequence character at this position. * * * Arg: cdna cDNA [Wise2_cDNA *] * Arg: pos position in cDNA to get char [int] * * Returns Undocumented return value [char] * */ char Wise2_cDNA_seqchar( Wise2_cDNA * cdna,int pos); /* Function: Wise2_cDNA_from_Sequence(seq) * * Descrip: makes a new cDNA from a Sequence. It * owns the Sequence memory, ie will attempt a /free_Sequence * on the structure when /free_cDNA is called * * If you want to give this cDNA this Sequence and * forget about it, then just hand it this sequence and set * seq to NULL (no need to free it). If you intend to use * the sequence object elsewhere outside of the cDNA datastructure * then use cDNA_from_Sequence(/hard_link_Sequence(seq)) * * * * Arg: seq Sequence to make cDNA from [Wise2_Sequence *] * * Returns Undocumented return value [Wise2_cDNA *] * */ Wise2_cDNA * Wise2_cDNA_from_Sequence( Wise2_Sequence * seq); /* Function: Wise2_hard_link_cDNA(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_cDNA *] * * Returns Undocumented return value [Wise2_cDNA *] * */ Wise2_cDNA * Wise2_hard_link_cDNA( Wise2_cDNA * obj); /* Function: Wise2_cDNA_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_cDNA *] * */ Wise2_cDNA * Wise2_cDNA_alloc(); /* Function: Wise2_replace_baseseq_cDNA(obj,baseseq) * * Descrip: Replace member variable baseseq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNA *] * Arg: baseseq New value of the variable [Wise2_Sequence *] * * Returns member variable baseseq [boolean] * */ boolean Wise2_replace_baseseq_cDNA( Wise2_cDNA * obj,Wise2_Sequence * baseseq); /* Function: Wise2_access_baseseq_cDNA(obj) * * Descrip: Access member variable baseseq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNA *] * * Returns member variable baseseq [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_access_baseseq_cDNA( Wise2_cDNA * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_cDNA(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_cDNA *] * * Returns Undocumented return value [Wise2_cDNA *] * */ Wise2_cDNA * Wise2_free_cDNA( Wise2_cDNA * obj); wise-2.4.1/src/dynlibsrc/cdna_api.t0000644000175000001440000000004710670453712016562 0ustar philippuserstypedef struct Wise2_cDNA Wise2_cDNA; wise-2.4.1/src/dynlibsrc/randomdb_api.h0000644000175000001440000002733410670453712017437 0ustar philippusers /* Functions that create, manipulate or act on RandomProteinDB * * Wise2_hard_link_RandomProteinDB * Wise2_RandomProteinDB_alloc * Wise2_replace_use_flat_length_RandomProteinDB * Wise2_access_use_flat_length_RandomProteinDB * Wise2_replace_length_RandomProteinDB * Wise2_access_length_RandomProteinDB * Wise2_replace_length_dist_RandomProteinDB * Wise2_access_length_dist_RandomProteinDB * Wise2_replace_emission_RandomProteinDB * Wise2_access_emission_RandomProteinDB * Wise2_replace_num_RandomProteinDB * Wise2_access_num_RandomProteinDB * Wise2_free_RandomProteinDB [destructor] * */ /* Functions that create, manipulate or act on RandomDNADB * * Wise2_hard_link_RandomDNADB * Wise2_RandomDNADB_alloc * Wise2_replace_use_flat_length_RandomDNADB * Wise2_access_use_flat_length_RandomDNADB * Wise2_replace_length_RandomDNADB * Wise2_access_length_RandomDNADB * Wise2_replace_length_dist_RandomDNADB * Wise2_access_length_dist_RandomDNADB * Wise2_replace_emission_RandomDNADB * Wise2_access_emission_RandomDNADB * Wise2_replace_num_RandomDNADB * Wise2_access_num_RandomDNADB * Wise2_free_RandomDNADB [destructor] * */ /* API for object RandomProteinDB */ /* Function: Wise2_hard_link_RandomProteinDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_RandomProteinDB *] * * Returns Undocumented return value [Wise2_RandomProteinDB *] * */ Wise2_RandomProteinDB * Wise2_hard_link_RandomProteinDB( Wise2_RandomProteinDB * obj); /* Function: Wise2_RandomProteinDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_RandomProteinDB *] * */ Wise2_RandomProteinDB * Wise2_RandomProteinDB_alloc(); /* Function: Wise2_replace_use_flat_length_RandomProteinDB(obj,use_flat_length) * * Descrip: Replace member variable use_flat_length * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomProteinDB *] * Arg: use_flat_length New value of the variable [boolean] * * Returns member variable use_flat_length [boolean] * */ boolean Wise2_replace_use_flat_length_RandomProteinDB( Wise2_RandomProteinDB * obj,boolean use_flat_length); /* Function: Wise2_access_use_flat_length_RandomProteinDB(obj) * * Descrip: Access member variable use_flat_length * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomProteinDB *] * * Returns member variable use_flat_length [boolean] * */ boolean Wise2_access_use_flat_length_RandomProteinDB( Wise2_RandomProteinDB * obj); /* Function: Wise2_replace_length_RandomProteinDB(obj,length) * * Descrip: Replace member variable length * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomProteinDB *] * Arg: length New value of the variable [int] * * Returns member variable length [boolean] * */ boolean Wise2_replace_length_RandomProteinDB( Wise2_RandomProteinDB * obj,int length); /* Function: Wise2_access_length_RandomProteinDB(obj) * * Descrip: Access member variable length * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomProteinDB *] * * Returns member variable length [int] * */ int Wise2_access_length_RandomProteinDB( Wise2_RandomProteinDB * obj); /* Function: Wise2_replace_length_dist_RandomProteinDB(obj,length_dist) * * Descrip: Replace member variable length_dist * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomProteinDB *] * Arg: length_dist New value of the variable [Wise2_Histogram *] * * Returns member variable length_dist [boolean] * */ boolean Wise2_replace_length_dist_RandomProteinDB( Wise2_RandomProteinDB * obj,Wise2_Histogram * length_dist); /* Function: Wise2_access_length_dist_RandomProteinDB(obj) * * Descrip: Access member variable length_dist * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomProteinDB *] * * Returns member variable length_dist [Wise2_Histogram *] * */ Wise2_Histogram * Wise2_access_length_dist_RandomProteinDB( Wise2_RandomProteinDB * obj); /* Function: Wise2_replace_emission_RandomProteinDB(obj,emission) * * Descrip: Replace member variable emission * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomProteinDB *] * Arg: emission New value of the variable [Wise2_RandomModel *] * * Returns member variable emission [boolean] * */ boolean Wise2_replace_emission_RandomProteinDB( Wise2_RandomProteinDB * obj,Wise2_RandomModel * emission); /* Function: Wise2_access_emission_RandomProteinDB(obj) * * Descrip: Access member variable emission * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomProteinDB *] * * Returns member variable emission [Wise2_RandomModel *] * */ Wise2_RandomModel * Wise2_access_emission_RandomProteinDB( Wise2_RandomProteinDB * obj); /* Function: Wise2_replace_num_RandomProteinDB(obj,num) * * Descrip: Replace member variable num * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomProteinDB *] * Arg: num New value of the variable [int] * * Returns member variable num [boolean] * */ boolean Wise2_replace_num_RandomProteinDB( Wise2_RandomProteinDB * obj,int num); /* Function: Wise2_access_num_RandomProteinDB(obj) * * Descrip: Access member variable num * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomProteinDB *] * * Returns member variable num [int] * */ int Wise2_access_num_RandomProteinDB( Wise2_RandomProteinDB * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_RandomProteinDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_RandomProteinDB *] * * Returns Undocumented return value [Wise2_RandomProteinDB *] * */ Wise2_RandomProteinDB * Wise2_free_RandomProteinDB( Wise2_RandomProteinDB * obj); /* API for object RandomDNADB */ /* Function: Wise2_hard_link_RandomDNADB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_RandomDNADB *] * * Returns Undocumented return value [Wise2_RandomDNADB *] * */ Wise2_RandomDNADB * Wise2_hard_link_RandomDNADB( Wise2_RandomDNADB * obj); /* Function: Wise2_RandomDNADB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_RandomDNADB *] * */ Wise2_RandomDNADB * Wise2_RandomDNADB_alloc(); /* Function: Wise2_replace_use_flat_length_RandomDNADB(obj,use_flat_length) * * Descrip: Replace member variable use_flat_length * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomDNADB *] * Arg: use_flat_length New value of the variable [boolean] * * Returns member variable use_flat_length [boolean] * */ boolean Wise2_replace_use_flat_length_RandomDNADB( Wise2_RandomDNADB * obj,boolean use_flat_length); /* Function: Wise2_access_use_flat_length_RandomDNADB(obj) * * Descrip: Access member variable use_flat_length * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomDNADB *] * * Returns member variable use_flat_length [boolean] * */ boolean Wise2_access_use_flat_length_RandomDNADB( Wise2_RandomDNADB * obj); /* Function: Wise2_replace_length_RandomDNADB(obj,length) * * Descrip: Replace member variable length * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomDNADB *] * Arg: length New value of the variable [int] * * Returns member variable length [boolean] * */ boolean Wise2_replace_length_RandomDNADB( Wise2_RandomDNADB * obj,int length); /* Function: Wise2_access_length_RandomDNADB(obj) * * Descrip: Access member variable length * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomDNADB *] * * Returns member variable length [int] * */ int Wise2_access_length_RandomDNADB( Wise2_RandomDNADB * obj); /* Function: Wise2_replace_length_dist_RandomDNADB(obj,length_dist) * * Descrip: Replace member variable length_dist * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomDNADB *] * Arg: length_dist New value of the variable [Wise2_Histogram *] * * Returns member variable length_dist [boolean] * */ boolean Wise2_replace_length_dist_RandomDNADB( Wise2_RandomDNADB * obj,Wise2_Histogram * length_dist); /* Function: Wise2_access_length_dist_RandomDNADB(obj) * * Descrip: Access member variable length_dist * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomDNADB *] * * Returns member variable length_dist [Wise2_Histogram *] * */ Wise2_Histogram * Wise2_access_length_dist_RandomDNADB( Wise2_RandomDNADB * obj); /* Function: Wise2_replace_emission_RandomDNADB(obj,emission) * * Descrip: Replace member variable emission * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomDNADB *] * Arg: emission New value of the variable [Wise2_RandomModelDNA *] * * Returns member variable emission [boolean] * */ boolean Wise2_replace_emission_RandomDNADB( Wise2_RandomDNADB * obj,Wise2_RandomModelDNA * emission); /* Function: Wise2_access_emission_RandomDNADB(obj) * * Descrip: Access member variable emission * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomDNADB *] * * Returns member variable emission [Wise2_RandomModelDNA *] * */ Wise2_RandomModelDNA * Wise2_access_emission_RandomDNADB( Wise2_RandomDNADB * obj); /* Function: Wise2_replace_num_RandomDNADB(obj,num) * * Descrip: Replace member variable num * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomDNADB *] * Arg: num New value of the variable [int] * * Returns member variable num [boolean] * */ boolean Wise2_replace_num_RandomDNADB( Wise2_RandomDNADB * obj,int num); /* Function: Wise2_access_num_RandomDNADB(obj) * * Descrip: Access member variable num * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomDNADB *] * * Returns member variable num [int] * */ int Wise2_access_num_RandomDNADB( Wise2_RandomDNADB * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_RandomDNADB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_RandomDNADB *] * * Returns Undocumented return value [Wise2_RandomDNADB *] * */ Wise2_RandomDNADB * Wise2_free_RandomDNADB( Wise2_RandomDNADB * obj); wise-2.4.1/src/dynlibsrc/randomdb_api.t0000644000175000001440000000016210670453712017441 0ustar philippuserstypedef struct Wise2_RandomProteinDB Wise2_RandomProteinDB; typedef struct Wise2_RandomDNADB Wise2_RandomDNADB; wise-2.4.1/src/dynlibsrc/dnamatrix.typemap0000644000175000001440000000077010670453712020232 0ustar philippusers TYPEMAP Wise2_DnaMatrix * T_Wise2_DnaMatrix INPUT T_Wise2_DnaMatrix $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_DnaMatrix *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_DnaMatrix sv_setref_pv($arg, "Wise2::DnaMatrix", (void*) $var); TYPEMAP Wise2_DnaProbMatrix * T_Wise2_DnaProbMatrix INPUT T_Wise2_DnaProbMatrix $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_DnaProbMatrix *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_DnaProbMatrix sv_setref_pv($arg, "Wise2::DnaProbMatrix", (void*) $var); wise-2.4.1/src/dynlibsrc/matrixdebug.c0000644000175000001440000010110610670453712017314 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "matrixdebug.h" /* Function: show_PackAln_Debug(de,pal,ofp) * * Descrip: Shows PackAln in debug context * * * Arg: de [UNKN ] Undocumented argument [DebugMatrix *] * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 63 "matrixdebug.dy" void show_PackAln_Debug(DebugMatrix * de,PackAln * pal,FILE * ofp) { int i; int j,k; int cum; PackAlnUnit * prev = pal->pau[0]; PackAlnUnit * c; DebugState * state; DebugTransition * trans; for(i=1;ilen;i++) { c= pal->pau[i]; /* have to find the correct state_num */ if( c->state >= de->len ) { /* special state - can't handle */ fprintf(ofp,"Special state\n"); prev = c; continue; } if( prev->state >= de->len ) { /* special state - can't handle */ fprintf(ofp,"From Special state\n"); prev = c; continue; } state = de->state[pal->pau[i]->state]; trans = NULL; for(k=0;klen;k++) { if( state->trans[k]->from_state_num == prev->state ) { trans = state->trans[k]; } } fprintf(ofp,"SCORE: %5d %5d %5d %s\n",c->score,c->i,c->j,state->statename); if( trans != NULL ) { (*trans->show_transition)(de->matrix,c->i,c->j,ofp); } prev = c; } } /* Function: show_DebugMatrix(de,buffer) * * Descrip: Show function cell state transition * * * Arg: de [UNKN ] Undocumented argument [DebugMatrix *] * Arg: buffer [UNKN ] Undocumented argument [char *] * */ # line 109 "matrixdebug.dy" void show_DebugMatrix(DebugMatrix * de,char * buffer) { char ** base; char ** brk; DebugState * ds; DebugTransition * tr; base = brk = breakstring(buffer,spacestr); brk++; if( *brk == NULL ) { (*de->show_cell)(de->matrix,de->currenti,de->currentj,de->out); } else { ds = find_DebugState(de,*brk); if( ds == NULL ) { fprintf(de->out,"No state called %s\n",*brk); } else { brk++; if( *brk != NULL ) { tr = find_DebugTransition(ds,*brk); if( tr == NULL ) { fprintf(de->out,"In state %s, no transition from %s\n",ds->statename,*brk); } else { (*tr->show_transition)(de->matrix,de->currenti,de->currentj,de->out); } } else { /* show state */ (*ds->show_state)(de->matrix,de->currenti,de->currentj,de->out); } } } ckfree(base); } /* Function: find_DebugState(de,name) * * Descrip: Finds a DebugState * * * Arg: de [UNKN ] Undocumented argument [DebugMatrix *] * Arg: name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [DebugState *] * */ # line 150 "matrixdebug.dy" DebugState * find_DebugState(DebugMatrix * de,char * name) { int i; for(i=0;ilen;i++) { if( strcmp(de->state[i]->statename,name) == 0 ) { return de->state[i]; } } return NULL; } /* Function: find_DebugTransition(state,name) * * Descrip: Finds a DebugTransition * * * Arg: state [UNKN ] Undocumented argument [DebugState *] * Arg: name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [DebugTransition *] * */ # line 166 "matrixdebug.dy" DebugTransition * find_DebugTransition(DebugState * state,char * name) { int i; for(i=0;ilen;i++) { if( strcmp(state->trans[i]->fromstate,name) == 0 ) { return state->trans[i]; } } return NULL; } /* Function: user_DebugMatrix(de) * * Descrip: Main function to talk to user * * * Arg: de [UNKN ] Undocumented argument [DebugMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 183 "matrixdebug.dy" boolean user_DebugMatrix(DebugMatrix * de) { char buffer[MAXLINE]; char ** base; char ** brk; FILE * in; FILE * out; DebugBreakPoint * bp; assert(de); assert(de->in); assert(de->out); in = de->in; out = de->out; /* set reset to FALSE */ de->reset = 0; fprintf(out,"Entering dynamite debugger. Type help for help\n"); while(1) { fprintf(out,"Dy %5d:%5d max: %d >",de->currenti,de->currentj,de->max_score); fgets(buffer,MAXLINE,in); if( strstartcmp(buffer,"quit") == 0 ) { exit(1); } if( strstartcmp(buffer,"show") == 0 ) { show_DebugMatrix(de,buffer); continue; } if( strstartcmp(buffer,"run") == 0 ) { /* return to calling function */ return 0; } if( strstartcmp(buffer,"break") == 0 ) { base = brk = breakstring(buffer,spacestr); brk++; if( *brk == NULL || *(brk+1) == NULL ) { fprintf(out,">>>> break must have i j positions\n"); continue; } else { bp = DebugBreakPoint_alloc(); bp->type = MDBP_Cursor; /* reset cursor positions */ if( is_integer_string(*brk,&bp->posi) == FALSE ) { fprintf(out,">>>> i position not an integer.\n"); } brk++; if( is_integer_string(*brk,&bp->posj) == FALSE ) { fprintf(out,">>>> j position not an integer.\n"); } fprintf(out,"Adding cursor break point %d,%d\n",bp->posi,bp->posj); add_bp_DebugMatrix(de,bp); } ckfree(base); continue; } if( strstartcmp(buffer,"set") == 0 ) { base = brk = breakstring(buffer,spacestr); brk++; if( *brk == NULL || *(brk+1) == NULL ) { fprintf(out,">>>> set must have i j positions\n"); } else { /* reset cursor positions */ if( is_integer_string(*brk,&de->currenti) == FALSE ) { fprintf(out,">>>> i position not an integer.\n"); } if( is_integer_string(*brk,&de->currenti) == FALSE ) { fprintf(out,">>>> j position not an integer.\n"); } } de->reset = 1; ckfree(base); continue; } } } /* Function: should_break_DebugMatrix(de) * * Descrip: Indicates whether we should break at this point. Assummes * the de datastructure has been updated correctly * * * Arg: de [UNKN ] Undocumented argument [DebugMatrix *] * * Return [UNKN ] Undocumented return value [MatrixDebugBreakPoint_type] * */ # line 277 "matrixdebug.dy" MatrixDebugBreakPoint_type should_break_DebugMatrix(DebugMatrix * de) { int i; for(i=0;ibp_len;i++) { auto DebugBreakPoint * p; p = de->point[i]; switch(p->type) { case MDBP_Cursor : if( de->currenti == p->posi && de->currentj == p->posj ) { return MDBP_Cursor; } break; case MDBP_Overflow : if( de->max_score > p->overflow ) { return MDBP_Overflow; } break; case MDBP_Underflow : if( de->min_score < p->overflow ) { return MDBP_Overflow; } break; default : warn("Weird break point type %d",p->type); } } return MDBP_NoBreakPoint; } /* Function: std_DebugMatrix(void) * * Descrip: Builds a "standard" Debug matrix * * * * Return [UNKN ] Undocumented return value [DebugMatrix *] * */ # line 315 "matrixdebug.dy" DebugMatrix * std_DebugMatrix(void) { DebugMatrix * out; DebugBreakPoint * bp; out = DebugMatrix_alloc_std(); bp = DebugBreakPoint_alloc(); bp->type = MDBP_Cursor; bp->posi = -1; bp->posj = -1; add_bp_DebugMatrix(out,bp); bp = DebugBreakPoint_alloc(); bp->type = MDBP_Overflow; bp->overflow = 1000000; add_bp_DebugMatrix(out,bp); out->in = stdin; out->out = stderr; return out; } # line 329 "matrixdebug.c" /* Function: hard_link_DebugTransition(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DebugTransition *] * * Return [UNKN ] Undocumented return value [DebugTransition *] * */ DebugTransition * hard_link_DebugTransition(DebugTransition * obj) { if( obj == NULL ) { warn("Trying to hard link to a DebugTransition object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DebugTransition_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DebugTransition *] * */ DebugTransition * DebugTransition_alloc(void) { DebugTransition * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DebugTransition *) ckalloc (sizeof(DebugTransition))) == NULL) { warn("DebugTransition_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->from_state_num = 0; out->show_transition = NULL; return out; } /* Function: free_DebugTransition(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DebugTransition *] * * Return [UNKN ] Undocumented return value [DebugTransition *] * */ DebugTransition * free_DebugTransition(DebugTransition * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DebugTransition obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->fromstate is linked in */ /* obj->show_transition is a function pointer */ ckfree(obj); return NULL; } /* Function: swap_DebugState(list,i,j) * * Descrip: swap function: an internal for qsort_DebugState * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [DebugTransition **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_DebugState(DebugTransition ** list,int i,int j) { DebugTransition * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_DebugState(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_DebugState which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [DebugTransition **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_DebugState(DebugTransition ** list,int left,int right,int (*comp)(DebugTransition * ,DebugTransition * )) { int i,last; if( left >= right ) return; swap_DebugState(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_DebugState (list,++last,i); } swap_DebugState (list,left,last); qsort_DebugState(list,left,last-1,comp); qsort_DebugState(list,last+1,right,comp); } /* Function: sort_DebugState(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_DebugState * * * Arg: obj [UNKN ] Object containing list [DebugState *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_DebugState(DebugState * obj,int (*comp)(DebugTransition *, DebugTransition *)) { qsort_DebugState(obj->trans,0,obj->len-1,comp); return; } /* Function: expand_DebugState(obj,len) * * Descrip: Really an internal function for add_DebugState * * * Arg: obj [UNKN ] Object which contains the list [DebugState *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_DebugState(DebugState * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_DebugState called with no need"); return TRUE; } if( (obj->trans = (DebugTransition ** ) ckrealloc (obj->trans,sizeof(DebugTransition *)*len)) == NULL) { warn("ckrealloc failed for expand_DebugState, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_DebugState(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DebugState *] * Arg: add [OWNER] Object to add to the list [DebugTransition *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_DebugState(DebugState * obj,DebugTransition * add) { if( obj->len >= obj->maxlen) { if( expand_DebugState(obj,obj->len + DebugStateLISTLENGTH) == FALSE) return FALSE; } obj->trans[obj->len++]=add; return TRUE; } /* Function: flush_DebugState(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DebugState *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_DebugState(DebugState * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->trans[i] != NULL) { free_DebugTransition(obj->trans[i]); obj->trans[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: DebugState_alloc_std(void) * * Descrip: Equivalent to DebugState_alloc_len(DebugStateLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DebugState *] * */ DebugState * DebugState_alloc_std(void) { return DebugState_alloc_len(DebugStateLISTLENGTH); } /* Function: DebugState_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DebugState *] * */ DebugState * DebugState_alloc_len(int len) { DebugState * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = DebugState_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->trans = (DebugTransition ** ) ckcalloc (len,sizeof(DebugTransition *))) == NULL) { warn("Warning, ckcalloc failed in DebugState_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_DebugState(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DebugState *] * * Return [UNKN ] Undocumented return value [DebugState *] * */ DebugState * hard_link_DebugState(DebugState * obj) { if( obj == NULL ) { warn("Trying to hard link to a DebugState object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DebugState_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DebugState *] * */ DebugState * DebugState_alloc(void) { DebugState * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DebugState *) ckalloc (sizeof(DebugState))) == NULL) { warn("DebugState_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->state_num = 0; out->trans = NULL; out->len = out->maxlen = 0; out->show_state = NULL; return out; } /* Function: free_DebugState(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DebugState *] * * Return [UNKN ] Undocumented return value [DebugState *] * */ DebugState * free_DebugState(DebugState * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DebugState obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->statename is linked in */ if( obj->trans != NULL) { for(i=0;ilen;i++) { if( obj->trans[i] != NULL) free_DebugTransition(obj->trans[i]); } ckfree(obj->trans); } /* obj->show_state is a function pointer */ ckfree(obj); return NULL; } /* Function: hard_link_DebugBreakPoint(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DebugBreakPoint *] * * Return [UNKN ] Undocumented return value [DebugBreakPoint *] * */ DebugBreakPoint * hard_link_DebugBreakPoint(DebugBreakPoint * obj) { if( obj == NULL ) { warn("Trying to hard link to a DebugBreakPoint object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DebugBreakPoint_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DebugBreakPoint *] * */ DebugBreakPoint * DebugBreakPoint_alloc(void) { DebugBreakPoint * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DebugBreakPoint *) ckalloc (sizeof(DebugBreakPoint))) == NULL) { warn("DebugBreakPoint_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = MDBP_Cursor; out->posi = 0; out->posj = 0; out->overflow = 0; out->underflow = 0; return out; } /* Function: free_DebugBreakPoint(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DebugBreakPoint *] * * Return [UNKN ] Undocumented return value [DebugBreakPoint *] * */ DebugBreakPoint * free_DebugBreakPoint(DebugBreakPoint * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DebugBreakPoint obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_DebugMatrix(list,i,j) * * Descrip: swap function: an internal for qsort_DebugMatrix * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [DebugState **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_DebugMatrix(DebugState ** list,int i,int j) { DebugState * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_DebugMatrix(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_DebugMatrix which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [DebugState **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_DebugMatrix(DebugState ** list,int left,int right,int (*comp)(DebugState * ,DebugState * )) { int i,last; if( left >= right ) return; swap_DebugMatrix(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_DebugMatrix (list,++last,i); } swap_DebugMatrix (list,left,last); qsort_DebugMatrix(list,left,last-1,comp); qsort_DebugMatrix(list,last+1,right,comp); } /* Function: sort_DebugMatrix(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_DebugMatrix * * * Arg: obj [UNKN ] Object containing list [DebugMatrix *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_DebugMatrix(DebugMatrix * obj,int (*comp)(DebugState *, DebugState *)) { qsort_DebugMatrix(obj->state,0,obj->len-1,comp); return; } /* Function: expand_DebugMatrix(obj,len) * * Descrip: Really an internal function for add_DebugMatrix * * * Arg: obj [UNKN ] Object which contains the list [DebugMatrix *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_DebugMatrix(DebugMatrix * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_DebugMatrix called with no need"); return TRUE; } if( (obj->state = (DebugState ** ) ckrealloc (obj->state,sizeof(DebugState *)*len)) == NULL) { warn("ckrealloc failed for expand_DebugMatrix, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_DebugMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DebugMatrix *] * Arg: add [OWNER] Object to add to the list [DebugState *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_DebugMatrix(DebugMatrix * obj,DebugState * add) { if( obj->len >= obj->maxlen) { if( expand_DebugMatrix(obj,obj->len + DebugMatrixLISTLENGTH) == FALSE) return FALSE; } obj->state[obj->len++]=add; return TRUE; } /* Function: flush_DebugMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DebugMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_DebugMatrix(DebugMatrix * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->state[i] != NULL) { free_DebugState(obj->state[i]); obj->state[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: swap_bp_DebugMatrix(list,i,j) * * Descrip: swap function: an internal for qsort_bp_DebugMatrix * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [DebugBreakPoint **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_bp_DebugMatrix(DebugBreakPoint ** list,int i,int j) { DebugBreakPoint * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_bp_DebugMatrix(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_bp_DebugMatrix which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [DebugBreakPoint **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_bp_DebugMatrix(DebugBreakPoint ** list,int left,int right,int (*comp)(DebugBreakPoint * ,DebugBreakPoint * )) { int i,last; if( left >= right ) return; swap_bp_DebugMatrix(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_bp_DebugMatrix (list,++last,i); } swap_bp_DebugMatrix (list,left,last); qsort_bp_DebugMatrix(list,left,last-1,comp); qsort_bp_DebugMatrix(list,last+1,right,comp); } /* Function: sort_bp_DebugMatrix(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_bp_DebugMatrix * * * Arg: obj [UNKN ] Object containing list [DebugMatrix *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_bp_DebugMatrix(DebugMatrix * obj,int (*comp)(DebugBreakPoint *, DebugBreakPoint *)) { qsort_bp_DebugMatrix(obj->point,0,obj->bp_len-1,comp); return; } /* Function: expand_bp_DebugMatrix(obj,len) * * Descrip: Really an internal function for add_bp_DebugMatrix * * * Arg: obj [UNKN ] Object which contains the list [DebugMatrix *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_bp_DebugMatrix(DebugMatrix * obj,int len) { if( obj->bp_maxlen > obj->bp_len ) { warn("expand_DebugMatrixbp_ called with no need"); return TRUE; } if( (obj->point = (DebugBreakPoint ** ) ckrealloc (obj->point,sizeof(DebugBreakPoint *)*len)) == NULL) { warn("ckrealloc failed for expand_DebugMatrix, returning FALSE"); return FALSE; } obj->bp_maxlen = len; return TRUE; } /* Function: add_bp_DebugMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DebugMatrix *] * Arg: add [OWNER] Object to add to the list [DebugBreakPoint *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_bp_DebugMatrix(DebugMatrix * obj,DebugBreakPoint * add) { if( obj->bp_len >= obj->bp_maxlen) { if( expand_bp_DebugMatrix(obj,obj->bp_len + DebugMatrixLISTLENGTH) == FALSE) return FALSE; } obj->point[obj->bp_len++]=add; return TRUE; } /* Function: flush_bp_DebugMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DebugMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_bp_DebugMatrix(DebugMatrix * obj) { int i; for(i=0;ibp_len;i++) { /*for i over list length*/ if( obj->point[i] != NULL) { free_DebugBreakPoint(obj->point[i]); obj->point[i] = NULL; } } /* end of for i over list length */ obj->bp_len = 0; return i; } /* Function: DebugMatrix_alloc_std(void) * * Descrip: Equivalent to DebugMatrix_alloc_len(DebugMatrixLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DebugMatrix *] * */ DebugMatrix * DebugMatrix_alloc_std(void) { return DebugMatrix_alloc_len(DebugMatrixLISTLENGTH); } /* Function: DebugMatrix_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DebugMatrix *] * */ DebugMatrix * DebugMatrix_alloc_len(int len) { DebugMatrix * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = DebugMatrix_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->state = (DebugState ** ) ckcalloc (len,sizeof(DebugState *))) == NULL) { warn("Warning, ckcalloc failed in DebugMatrix_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; if((out->point = (DebugBreakPoint ** ) ckcalloc (len,sizeof(DebugBreakPoint *))) == NULL) { warn("Warning, ckcalloc failed in DebugMatrix_alloc_len"); return NULL; } out->bp_len = 0; out->bp_maxlen = len; return out; } /* Function: hard_link_DebugMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DebugMatrix *] * * Return [UNKN ] Undocumented return value [DebugMatrix *] * */ DebugMatrix * hard_link_DebugMatrix(DebugMatrix * obj) { if( obj == NULL ) { warn("Trying to hard link to a DebugMatrix object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DebugMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DebugMatrix *] * */ DebugMatrix * DebugMatrix_alloc(void) { DebugMatrix * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DebugMatrix *) ckalloc (sizeof(DebugMatrix))) == NULL) { warn("DebugMatrix_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->currenti = -1; out->currentj = -1; out->max_score = 0; out->min_score = 100000; out->max_score_i = -1; out->max_score_j = -1; out->max_score_cell = 0; out->state = NULL; out->len = out->maxlen = 0; out->point = NULL; out->bp_len = out->bp_maxlen = 0; out->reset = FALSE; out->show_cell = NULL; return out; } /* Function: free_DebugMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DebugMatrix *] * * Return [UNKN ] Undocumented return value [DebugMatrix *] * */ DebugMatrix * free_DebugMatrix(DebugMatrix * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DebugMatrix obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->matrix is linked in */ if( obj->state != NULL) { for(i=0;ilen;i++) { if( obj->state[i] != NULL) free_DebugState(obj->state[i]); } ckfree(obj->state); } if( obj->point != NULL) { for(i=0;ibp_len;i++) { if( obj->point[i] != NULL) free_DebugBreakPoint(obj->point[i]); } ckfree(obj->point); } /* obj->in is linked in */ /* obj->out is linked in */ /* obj->show_cell is a function pointer */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/matrixdebug.h0000644000175000001440000004006210670453712017324 0ustar philippusers#ifndef DYNAMITEmatrixdebugHEADERFILE #define DYNAMITEmatrixdebugHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "basematrix.h" #include "packaln.h" #define DebugStateLISTLENGTH 40 #define DebugMatrixLISTLENGTH 40 typedef enum MatrixDebugBreakPoint { MDBP_Cursor = 321, MDBP_Overflow, MDBP_Underflow, MDBP_NoBreakPoint } MatrixDebugBreakPoint_type; struct Wise2_DebugTransition { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * fromstate; int from_state_num; void (*show_transition)(void * matrix,int i,int j,FILE * ofp); } ; /* DebugTransition defined */ #ifndef DYNAMITE_DEFINED_DebugTransition typedef struct Wise2_DebugTransition Wise2_DebugTransition; #define DebugTransition Wise2_DebugTransition #define DYNAMITE_DEFINED_DebugTransition #endif struct Wise2_DebugState { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * statename; int state_num; DebugTransition ** trans; int len;/* len for above trans */ int maxlen; /* maxlen for above trans */ void (*show_state)(void * matrix,int i,int j,FILE *ofp); } ; /* DebugState defined */ #ifndef DYNAMITE_DEFINED_DebugState typedef struct Wise2_DebugState Wise2_DebugState; #define DebugState Wise2_DebugState #define DYNAMITE_DEFINED_DebugState #endif struct Wise2_DebugBreakPoint { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif MatrixDebugBreakPoint_type type; int posi; int posj; int overflow; int underflow; } ; /* DebugBreakPoint defined */ #ifndef DYNAMITE_DEFINED_DebugBreakPoint typedef struct Wise2_DebugBreakPoint Wise2_DebugBreakPoint; #define DebugBreakPoint Wise2_DebugBreakPoint #define DYNAMITE_DEFINED_DebugBreakPoint #endif struct Wise2_DebugMatrix { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif void * matrix; int currenti; int currentj; int max_score; int min_score; int max_score_i; int max_score_j; int max_score_cell; DebugState ** state; int len;/* len for above state */ int maxlen; /* maxlen for above state */ DebugBreakPoint ** point; int bp_len; /* len for above point */ int bp_maxlen; /* maxlen for above point */ boolean reset; FILE * in; FILE * out; void (*show_cell)(void * matrix,int i,int j,FILE *ofp); } ; /* DebugMatrix defined */ #ifndef DYNAMITE_DEFINED_DebugMatrix typedef struct Wise2_DebugMatrix Wise2_DebugMatrix; #define DebugMatrix Wise2_DebugMatrix #define DYNAMITE_DEFINED_DebugMatrix #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: show_PackAln_Debug(de,pal,ofp) * * Descrip: Shows PackAln in debug context * * * Arg: de [UNKN ] Undocumented argument [DebugMatrix *] * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_PackAln_Debug(DebugMatrix * de,PackAln * pal,FILE * ofp); #define show_PackAln_Debug Wise2_show_PackAln_Debug /* Function: show_DebugMatrix(de,buffer) * * Descrip: Show function cell state transition * * * Arg: de [UNKN ] Undocumented argument [DebugMatrix *] * Arg: buffer [UNKN ] Undocumented argument [char *] * */ void Wise2_show_DebugMatrix(DebugMatrix * de,char * buffer); #define show_DebugMatrix Wise2_show_DebugMatrix /* Function: find_DebugState(de,name) * * Descrip: Finds a DebugState * * * Arg: de [UNKN ] Undocumented argument [DebugMatrix *] * Arg: name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [DebugState *] * */ DebugState * Wise2_find_DebugState(DebugMatrix * de,char * name); #define find_DebugState Wise2_find_DebugState /* Function: find_DebugTransition(state,name) * * Descrip: Finds a DebugTransition * * * Arg: state [UNKN ] Undocumented argument [DebugState *] * Arg: name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [DebugTransition *] * */ DebugTransition * Wise2_find_DebugTransition(DebugState * state,char * name); #define find_DebugTransition Wise2_find_DebugTransition /* Function: user_DebugMatrix(de) * * Descrip: Main function to talk to user * * * Arg: de [UNKN ] Undocumented argument [DebugMatrix *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_user_DebugMatrix(DebugMatrix * de); #define user_DebugMatrix Wise2_user_DebugMatrix /* Function: should_break_DebugMatrix(de) * * Descrip: Indicates whether we should break at this point. Assummes * the de datastructure has been updated correctly * * * Arg: de [UNKN ] Undocumented argument [DebugMatrix *] * * Return [UNKN ] Undocumented return value [MatrixDebugBreakPoint_type] * */ MatrixDebugBreakPoint_type Wise2_should_break_DebugMatrix(DebugMatrix * de); #define should_break_DebugMatrix Wise2_should_break_DebugMatrix /* Function: std_DebugMatrix(void) * * Descrip: Builds a "standard" Debug matrix * * * * Return [UNKN ] Undocumented return value [DebugMatrix *] * */ DebugMatrix * Wise2_std_DebugMatrix(void); #define std_DebugMatrix Wise2_std_DebugMatrix /* Function: hard_link_DebugTransition(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DebugTransition *] * * Return [UNKN ] Undocumented return value [DebugTransition *] * */ DebugTransition * Wise2_hard_link_DebugTransition(DebugTransition * obj); #define hard_link_DebugTransition Wise2_hard_link_DebugTransition /* Function: DebugTransition_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DebugTransition *] * */ DebugTransition * Wise2_DebugTransition_alloc(void); #define DebugTransition_alloc Wise2_DebugTransition_alloc /* Function: free_DebugTransition(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DebugTransition *] * * Return [UNKN ] Undocumented return value [DebugTransition *] * */ DebugTransition * Wise2_free_DebugTransition(DebugTransition * obj); #define free_DebugTransition Wise2_free_DebugTransition /* Function: add_DebugState(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DebugState *] * Arg: add [OWNER] Object to add to the list [DebugTransition *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_DebugState(DebugState * obj,DebugTransition * add); #define add_DebugState Wise2_add_DebugState /* Function: flush_DebugState(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DebugState *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_DebugState(DebugState * obj); #define flush_DebugState Wise2_flush_DebugState /* Function: DebugState_alloc_std(void) * * Descrip: Equivalent to DebugState_alloc_len(DebugStateLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DebugState *] * */ DebugState * Wise2_DebugState_alloc_std(void); #define DebugState_alloc_std Wise2_DebugState_alloc_std /* Function: DebugState_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DebugState *] * */ DebugState * Wise2_DebugState_alloc_len(int len); #define DebugState_alloc_len Wise2_DebugState_alloc_len /* Function: hard_link_DebugState(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DebugState *] * * Return [UNKN ] Undocumented return value [DebugState *] * */ DebugState * Wise2_hard_link_DebugState(DebugState * obj); #define hard_link_DebugState Wise2_hard_link_DebugState /* Function: DebugState_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DebugState *] * */ DebugState * Wise2_DebugState_alloc(void); #define DebugState_alloc Wise2_DebugState_alloc /* Function: free_DebugState(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DebugState *] * * Return [UNKN ] Undocumented return value [DebugState *] * */ DebugState * Wise2_free_DebugState(DebugState * obj); #define free_DebugState Wise2_free_DebugState /* Function: hard_link_DebugBreakPoint(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DebugBreakPoint *] * * Return [UNKN ] Undocumented return value [DebugBreakPoint *] * */ DebugBreakPoint * Wise2_hard_link_DebugBreakPoint(DebugBreakPoint * obj); #define hard_link_DebugBreakPoint Wise2_hard_link_DebugBreakPoint /* Function: DebugBreakPoint_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DebugBreakPoint *] * */ DebugBreakPoint * Wise2_DebugBreakPoint_alloc(void); #define DebugBreakPoint_alloc Wise2_DebugBreakPoint_alloc /* Function: free_DebugBreakPoint(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DebugBreakPoint *] * * Return [UNKN ] Undocumented return value [DebugBreakPoint *] * */ DebugBreakPoint * Wise2_free_DebugBreakPoint(DebugBreakPoint * obj); #define free_DebugBreakPoint Wise2_free_DebugBreakPoint /* Function: add_DebugMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DebugMatrix *] * Arg: add [OWNER] Object to add to the list [DebugState *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_DebugMatrix(DebugMatrix * obj,DebugState * add); #define add_DebugMatrix Wise2_add_DebugMatrix /* Function: flush_DebugMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DebugMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_DebugMatrix(DebugMatrix * obj); #define flush_DebugMatrix Wise2_flush_DebugMatrix /* Function: add_bp_DebugMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DebugMatrix *] * Arg: add [OWNER] Object to add to the list [DebugBreakPoint *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_bp_DebugMatrix(DebugMatrix * obj,DebugBreakPoint * add); #define add_bp_DebugMatrix Wise2_add_bp_DebugMatrix /* Function: flush_bp_DebugMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DebugMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_bp_DebugMatrix(DebugMatrix * obj); #define flush_bp_DebugMatrix Wise2_flush_bp_DebugMatrix /* Function: DebugMatrix_alloc_std(void) * * Descrip: Equivalent to DebugMatrix_alloc_len(DebugMatrixLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DebugMatrix *] * */ DebugMatrix * Wise2_DebugMatrix_alloc_std(void); #define DebugMatrix_alloc_std Wise2_DebugMatrix_alloc_std /* Function: DebugMatrix_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DebugMatrix *] * */ DebugMatrix * Wise2_DebugMatrix_alloc_len(int len); #define DebugMatrix_alloc_len Wise2_DebugMatrix_alloc_len /* Function: hard_link_DebugMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DebugMatrix *] * * Return [UNKN ] Undocumented return value [DebugMatrix *] * */ DebugMatrix * Wise2_hard_link_DebugMatrix(DebugMatrix * obj); #define hard_link_DebugMatrix Wise2_hard_link_DebugMatrix /* Function: DebugMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DebugMatrix *] * */ DebugMatrix * Wise2_DebugMatrix_alloc(void); #define DebugMatrix_alloc Wise2_DebugMatrix_alloc /* Function: free_DebugMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DebugMatrix *] * * Return [UNKN ] Undocumented return value [DebugMatrix *] * */ DebugMatrix * Wise2_free_DebugMatrix(DebugMatrix * obj); #define free_DebugMatrix Wise2_free_DebugMatrix /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_DebugState(DebugTransition ** list,int i,int j) ; #define swap_DebugState Wise2_swap_DebugState void Wise2_qsort_DebugState(DebugTransition ** list,int left,int right,int (*comp)(DebugTransition * ,DebugTransition * )); #define qsort_DebugState Wise2_qsort_DebugState void Wise2_sort_DebugState(DebugState * obj,int (*comp)(DebugTransition *, DebugTransition *)); #define sort_DebugState Wise2_sort_DebugState boolean Wise2_expand_DebugState(DebugState * obj,int len); #define expand_DebugState Wise2_expand_DebugState void Wise2_swap_DebugMatrix(DebugState ** list,int i,int j) ; #define swap_DebugMatrix Wise2_swap_DebugMatrix void Wise2_qsort_DebugMatrix(DebugState ** list,int left,int right,int (*comp)(DebugState * ,DebugState * )); #define qsort_DebugMatrix Wise2_qsort_DebugMatrix void Wise2_sort_DebugMatrix(DebugMatrix * obj,int (*comp)(DebugState *, DebugState *)); #define sort_DebugMatrix Wise2_sort_DebugMatrix boolean Wise2_expand_DebugMatrix(DebugMatrix * obj,int len); #define expand_DebugMatrix Wise2_expand_DebugMatrix void Wise2_swap_bp_DebugMatrix(DebugBreakPoint ** list,int i,int j) ; #define swap_bp_DebugMatrix Wise2_swap_bp_DebugMatrix void Wise2_qsort_bp_DebugMatrix(DebugBreakPoint ** list,int left,int right,int (*comp)(DebugBreakPoint * ,DebugBreakPoint * )); #define qsort_bp_DebugMatrix Wise2_qsort_bp_DebugMatrix void Wise2_sort_bp_DebugMatrix(DebugMatrix * obj,int (*comp)(DebugBreakPoint *, DebugBreakPoint *)); #define sort_bp_DebugMatrix Wise2_sort_bp_DebugMatrix boolean Wise2_expand_bp_DebugMatrix(DebugMatrix * obj,int len); #define expand_bp_DebugMatrix Wise2_expand_bp_DebugMatrix #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/staticseq.dy0000644000175000001440000000204707644504776017215 0ustar philippusers %{ #include "sequence.h" #include %} struct StaticSeqHolder GStringChunk * gstring_chunk %info Makes sequences with optimised static memory, but the sequences cannot be freed individually %% %{ #include "staticseq.h" %func makes a new StaticSeqHolder %% StaticSeqHolder * new_StaticSeqHolder(void) { StaticSeqHolder * out; out = StaticSeqHolder_alloc(); assert(out); out->gstring_chunk = g_string_chunk_new(1024*1024); return out; } %func for registering glib thingy for freeing %% GStringChunk * free_GStringChunk(GStringChunk * gs) { assert(gs); g_string_chunk_free(gs); return NULL; } %func Making a new sequence from a staticseq holder - consumes the sequence object (actually recycling the shell of it) %% Sequence * new_Sequence_StaticSeqHolder(StaticSeqHolder * ssh,Sequence * seq) { char * str; assert(seq); assert(ssh); assert(ssh->gstring_chunk); str = g_string_chunk_insert(ssh->gstring_chunk,seq->seq); ckfree(seq->seq); seq->seq = str; seq->dynamite_hard_link++; return seq; } %} %} wise-2.4.1/src/dynlibsrc/protein_api.h0000644000175000001440000000557110670453712017330 0ustar philippusers /* Functions that create, manipulate or act on Protein * * Wise2_Protein_from_Sequence * Wise2_hard_link_Protein * Wise2_Protein_alloc * Wise2_replace_baseseq_Protein * Wise2_access_baseseq_Protein * Wise2_free_Protein [destructor] * */ /* API for object Protein */ /* Function: Wise2_Protein_from_Sequence(seq) * * Descrip: makes a new protein from a Sequence. It * owns the Sequence memory, ie will attempt a /free_Sequence * on the structure when /free_Protein is called * * If you want to give this protein this Sequence and * forget about it, then just hand it this sequence and set * seq to NULL (no need to free it). If you intend to use * the sequecne object elsewhere outside of the Protein datastructure * then use Protein_from_Sequence(/hard_link_Sequence(seq)) * * * * Arg: seq Sequence to make protein from [Wise2_Sequence *] * * Returns Undocumented return value [Wise2_Protein *] * */ Wise2_Protein * Wise2_Protein_from_Sequence( Wise2_Sequence * seq); /* Function: Wise2_hard_link_Protein(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_Protein *] * * Returns Undocumented return value [Wise2_Protein *] * */ Wise2_Protein * Wise2_hard_link_Protein( Wise2_Protein * obj); /* Function: Wise2_Protein_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_Protein *] * */ Wise2_Protein * Wise2_Protein_alloc(); /* Function: Wise2_replace_baseseq_Protein(obj,baseseq) * * Descrip: Replace member variable baseseq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Protein *] * Arg: baseseq New value of the variable [Wise2_Sequence *] * * Returns member variable baseseq [boolean] * */ boolean Wise2_replace_baseseq_Protein( Wise2_Protein * obj,Wise2_Sequence * baseseq); /* Function: Wise2_access_baseseq_Protein(obj) * * Descrip: Access member variable baseseq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Protein *] * * Returns member variable baseseq [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_access_baseseq_Protein( Wise2_Protein * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_Protein(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_Protein *] * * Returns Undocumented return value [Wise2_Protein *] * */ Wise2_Protein * Wise2_free_Protein( Wise2_Protein * obj); wise-2.4.1/src/dynlibsrc/protein_api.t0000644000175000001440000000005510670453712017334 0ustar philippuserstypedef struct Wise2_Protein Wise2_Protein; wise-2.4.1/src/dynlibsrc/compmat.dy0000644000175000001440000002526407536706203016650 0ustar philippusers/* Last edited: Feb 11 10:32 1997 (birney) */ %{ #include "wisebase.h" #include "probability.h" #include "randommodel.h" #define CompMat_AAMATCH(comp_mat,aa1,aa2) (comp_mat->comp[aa1][aa2]) %} api object CompMat des free_CompMat func fail_safe_CompMat_access func write_Blast_CompMat func read_Blast_file_CompMat func read_Blast_CompMat endobject endapi struct CompProb Probability comp[26][26] char * name %info The probabilistic form of CompMat %% struct CompMat Score comp[26][26] char * name // if any, could be NULL %info This object stores BLOSUM and PAM comparison matrices. It stores them as scores: NB - this means probabilistically we are talking about some arbitary base of log which is really annoying. %% %{ #include "compmat.h" %func Makes a simple CompProb matrix %% CompProb * simple_CompProb(Probability match,Probability rnd) { CompProb * p; Probability rem; int i,j; p = CompProb_alloc(); rem = (1.0-match)/20; for(i=0;i<26;i++) { for(j=i;j<26;j++) { if( i == j ) { p->comp[i][j] = match/rnd; } else { p->comp[i][j] = rem/rnd; p->comp[j][i] = rem/rnd; } } } return p; } %func Folds a random model in over the columns %% void fold_column_RandomModel_CompProb(CompProb * cp,RandomModel * rm) { int i,j; for(i=0;i<26;i++) { for(j=0;j<26;j++) { if( rm->aminoacid[j] < 0.00000000000001 ) { continue; } cp->comp[i][j] = cp->comp[i][j] / rm->aminoacid[j]; } } } %func Makes a simple CompProb with simple aa rules %% CompProb * simple_aa_CompProb(Probability match,Probability set,Probability rnd) { CompProb * p; Probability rem; int i,j,k; char * aa_set[] = { "FYW","LIV","RK","DE" }; p = CompProb_alloc(); rem = (1.0-match)/20; for(i=0;i<26;i++) { for(j=i;j<26;j++) { if( i == j ) { p->comp[i][j] = match/rnd; } else { for( k = 0;k<4;k++) { if( strchr(aa_set[k],'A'+i) != NULL && strchr(aa_set[k],'A'+j) != NULL ) { p->comp[i][j] = set/rnd; p->comp[j][i] = set/rnd; fprintf(stderr,"Setting %c,%c to %.2f\n",'A'+i,'A'+j,set/rnd); } else { p->comp[i][j] = rem/rnd; p->comp[j][i] = rem/rnd; } } } } } return p; } %func Maps a CompProb to a CompMat going through Probability2Score %% CompMat * CompMat_from_CompProb(CompProb * cp) { int i,j; CompMat * cm; cm = CompMat_alloc(); for(i=0;i<26;i++) { for(j=0;j<26;j++) { cm->comp[i][j] = Probability2Score(cp->comp[i][j]); } } return cm; } %func Maps a halfbit matrix to a prob matrix by rebasing etc. *Really* not sensible! %% CompProb * CompProb_from_halfbit(CompMat * cm) { CompProb * out; int i,j; out = CompProb_alloc(); for(i=0;i<26;i++) for(j=0;j<26;j++) out->comp[i][j] = halfbit2Probability(cm->comp[i][j]); return out; } %func flips a halfbit based matrix (eg, blosum62) into a score based matrix just by rebasing the log etc. Not a sensible function ... %% CompMat * CompMat_from_halfbit(CompMat * cm) { CompMat * out; int i,j; out = CompMat_alloc(); for(i=0;i<26;i++) for(j=0;j<26;j++) out->comp[i][j] = Probability2Score(halfbit2Probability(cm->comp[i][j])); return out; } %func multiples all the scores by the amount %arg cm compmat object factor amount to multiple by %% void factor_CompMat(CompMat * cm,int factor) { int i,j; for(i=0;i<26;i++) for(j=0;j<26;j++) cm->comp[i][j] *= factor; } %func gives the fail form of the macro CompMat_AAMATCH which checks that aa1 and a2 are sensible and that cm is not NULL. %arg cm compmat object aa1 first amino acid aa2 second amino acid %% Score fail_safe_CompMat_access(CompMat * cm,int aa1,int aa2) { if( cm == NULL) { warn("Attempting to access NULL CompMat."); return 0; } if( aa1 < 0 || aa1 >= 26 || aa2 < 0 || aa2 > 26) { warn("Attempting to access CompMat with aminoacid numbers %d:%d (they must be bound between 0:26, returning 0 here",aa1,aa2); return 0; } else return cm->comp[aa1][aa2]; } %func writes a protien CompMat with a standard alphabet. %arg cm CompMat object ofp file to output %% boolean write_Blast_CompMat(CompMat * cm,FILE * ofp) { return write_Blast_CompMat_alphabet(cm,"ARNDCQEGHILKMFPSTWYVBZX",ofp); } %func checks that this string is ok for BLAST alphabet mappings. %type internal %% boolean bad_CompMat_alphabet(char * al) { char * runner; for(runner=al;*runner;runner++) if( !isalpha((int)*runner) && toupper((int)*runner) != *runner ) { warn("Attempting to use [%s] as a CompMat alphabet: needs all upper case, no spaced letters",al); return TRUE; } return FALSE; } %func actualy writes out the Blast CFormat. The alphabet is what order you want the amino acids. If you want the standard format use /write_Blast_CompMat %arg cm comp mat object alphabet string for alphabet to be used ofp fileoutput %% boolean write_Blast_CompMat_alphabet(CompMat * cm,char * alphabet,FILE * ofp) { char * runner; char * run2; int minnumbers[26]; int len; int i; int min; if( bad_CompMat_alphabet(alphabet) == TRUE ) return FALSE; /* warning already issued */ fprintf(ofp,"# File made by *Wise CompMat library module\n"); fprintf(ofp,"# Comparison matrix in BLAST format\n"); fprintf(ofp,"# Usually matrices are given in half-bit units\n"); fprintf(ofp,"# First line is alphabet, the * column is the lowest score\n"); fprintf(ofp,"# File Created [%s]\n",now_string()); fprintf(ofp,"# Matrix name [%s]\n",cm->name == NULL ? "No Name" : cm->name); /*** print out alphabet wit correct spacing ***/ fprintf(ofp," %c",alphabet[0]); for(runner=alphabet+1;*runner;runner++) fprintf(ofp," %c",*runner); fprintf(ofp," *\n"); /*** print out each row: remember the minimum number for printing later **/ for(runner=alphabet,len=0;*runner;runner++) { min = cm->comp[*runner-'A'][0]; fprintf(ofp,"%- d",cm->comp[*runner-'A'][0]); for(run2=alphabet+1;*run2;run2++) { fprintf(ofp," %- d",cm->comp[*runner-'A'][*run2-'A']); if( cm->comp[*runner-'A'][*run2-'A'] < min ) min = cm->comp[*runner-'A'][*run2-'A']; } minnumbers[len++] = min; fprintf(ofp," % d\n",min); } /*** final row... * ***/ fprintf(ofp,"% d",minnumbers[0]); for(i=1;iname = stringalloc(filename); } fclose(ifp); return out; } %func reads a BLAST format matrix and allocates a new ComMat structure. %% CompMat * read_Blast_CompMat(FILE * ifp) { char buffer[MAXLINE]; int alphabet[MAXLINE]; char * runner; int len; int linenum; int row; CompMat * out; /*** Skip over # lines... read first line: is alphabet ie A R T G .... * ***/ while( fgets(buffer,MAXLINE,ifp) != NULL) if( buffer[0] != '#') break; /** loop over line, getting letters: warn if longer than one, or not a letter **/ for(len=0,runner=strtok(buffer,spacestr);runner != NULL;runner=strtok(NULL,spacestr)) { if( *runner == '*' ) break; /* end column */ if( !isalpha((int)*runner) || strlen(runner) > 1 ) { warn("In read Blast comp mat, probably an error: trying to interpret [%s] as an amino acid",runner); return NULL; } alphabet[len++] = toupper((int)*runner) -'A'; } out = blank_CompMat(); linenum = 0; /** get len lines, each line, get len numbers and put them away **/ while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( linenum >= len ) break; for(runner=strtok(buffer,spacestr),row = 0;runner != NULL && row < len;runner=strtok(NULL,spacestr),row++) { if( is_integer_string(runner,&out->comp[alphabet[linenum]][alphabet[row]]) == FALSE ) { warn("In read Blast comp mat, probably an error: trying to interpret [%s] as a number ... continuing",runner); } } linenum++; } return out; } %func Reads a BLAST format comp prob from file %% CompProb * read_Blast_file_CompProb(char * filename) { FILE * ifp; CompProb * out; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s for compprob",filename); return NULL; } out = read_Blast_CompProb(ifp); fclose(ifp); return out; } %func reads a BLAST format matrix and allocates a new CompProb structure. %arg ifp r file input return newly allocated CompProb %% CompProb * read_Blast_CompProb(FILE * ifp) { char buffer[MAXLINE]; int alphabet[MAXLINE]; char * runner; int len; int linenum; int row; CompProb * out; /*** Skip over # lines... read first line: is alphabet ie A R T G .... * ***/ while( fgets(buffer,MAXLINE,ifp) != NULL) if( buffer[0] != '#') break; /** loop over line, getting letters: warn if longer than one, or not a letter **/ for(len=0,runner=strtok(buffer,spacestr);runner != NULL;runner=strtok(NULL,spacestr)) { if( *runner == '*' ) break; /* end column */ if( !isalpha((int)*runner) || strlen(runner) > 1 ) { warn("In read Blast comp mat, probably an error: trying to interpret [%s] as an amino acid",runner); return NULL; } alphabet[len++] = toupper((int)*runner) -'A'; } out = blank_CompProb(); linenum = 0; /** get len lines, each line, get len numbers and put them away **/ while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"//") == 0 ) break; if( linenum >= len ) break; for(runner=strtok(buffer,spacestr),row = 0;runner != NULL && row < len;runner=strtok(NULL,spacestr),row++) { if( is_double_string(runner,&out->comp[alphabet[linenum]][alphabet[row]]) == FALSE ) { warn("In read Blast comp prob, probably an error: trying to interpret [%s] as a number ... continuing",runner); } } linenum++; } return out; } %func makes a 0,0 matrix %% CompMat * blank_CompMat(void) { register int i; register int j; CompMat * out; out = CompMat_alloc(); if( out == NULL) return NULL; for(i=0;i<26;i++) for(j=0;j<26;j++) out->comp[i][j] = 0; return out; } %func makes a 1.0 prob matrix %% CompProb * blank_CompProb(void) { register int i; register int j; CompProb * out; out = CompProb_alloc(); if( out == NULL) return NULL; for(i=0;i<26;i++) for(j=0;j<26;j++) out->comp[i][j] = 1.0; return out; } wise-2.4.1/src/dynlibsrc/compmat.xs0000644000175000001440000000262210670453712016654 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::CompMat Score fail_safe_CompMat_access(cm,aa1,aa2) Wise2_CompMat * cm int aa1 int aa2 CODE: RETVAL = Wise2_fail_safe_CompMat_access(cm,aa1,aa2); OUTPUT: RETVAL boolean write_Blast_CompMat(cm,ofp) Wise2_CompMat * cm FILE * ofp CODE: RETVAL = Wise2_write_Blast_CompMat(cm,ofp); OUTPUT: RETVAL Wise2_CompMat * read_Blast_file_CompMat(filename) char * filename CODE: RETVAL = Wise2_read_Blast_file_CompMat(filename); OUTPUT: RETVAL Wise2_CompMat * read_Blast_CompMat(ifp) FILE * ifp CODE: RETVAL = Wise2_read_Blast_CompMat(ifp); OUTPUT: RETVAL Wise2_CompMat * hard_link_CompMat(obj) Wise2_CompMat * obj CODE: RETVAL = Wise2_hard_link_CompMat(obj); OUTPUT: RETVAL Wise2_CompMat * alloc() CODE: RETVAL = Wise2_CompMat_alloc(); OUTPUT: RETVAL boolean set_name(obj,name) Wise2_CompMat * obj char * name CODE: RETVAL = Wise2_replace_name_CompMat(obj,Wise2_stringalloc(name)); OUTPUT: RETVAL char * name(obj) Wise2_CompMat * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_name_CompMat(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_CompMat * new(class) char * class PPCODE: Wise2_CompMat * out; out = Wise2_CompMat_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_CompMat * obj CODE: Wise2_free_CompMat(obj); MODULE = Wise2 PACKAGE = Wise2 wise-2.4.1/src/dynlibsrc/testpairbase.c0000644000175000001440000000247707414067207017504 0ustar philippusers#include "pairbase.h" #include "pairbaseseq.h" #include "complexevalset.h" char * seq1 = "ATTGGGGGTGACCTGTTAGT"; char * seq2 = "AGGGTGGGGGACTTGATAGT"; int main(int argc,char ** argv) { PairBaseSeq * seq; ComplexSequence * cs; ComplexSequenceEval * splice5; ComplexSequenceEval * splice3; SeqAlign * sa; pairbase_type pb; pb = MAKE_PAIRBASE(BASE_A,BASE_T); if( anchor_base_from_pairbase(pb) != BASE_A ) { printf("not ok 1\n"); } else { printf("ok 1\n"); } if( informant_base_from_pairbase(pb) != BASE_T ) { printf("not ok 2\n"); } else { printf("ok 2\n"); } seq = new_PairBaseSeq_strings(seq1,seq2); if( seq == NULL ) { printf("not ok 3\n"); } else { printf("ok 3\n"); } sa = SeqAlign_from_PairBaseSeq(seq); if( sa == NULL ) { printf("not ok 4\n"); } else { printf("ok 4\n"); } if( strcmp(sa->seq[0]->seq,seq1) != 0 ) { printf("not ok 5\n"); printf("Got %s\n",sa->seq[0]->seq); } else { printf("ok 5\n"); } if( strcmp(sa->seq[1]->seq,seq2) != 0 ) { printf("not ok 6\n"); printf("Got %s\n",sa->seq[1]->seq); } else { printf("ok 6\n"); } splice5 = stupid_5SS(); splice3 = stupid_3SS(); cs = ComplexSequence_from_PairBaseSeq(seq,splice5,splice3); printf("ok 7\n"); show_ComplexSequence(cs,stdout); } wise-2.4.1/src/dynlibsrc/sequencedb_api.h0000644000175000001440000003147510670453713017771 0ustar philippusers /* Functions that create, manipulate or act on SequenceDB * * Wise2_close_SequenceDB * Wise2_hard_link_SequenceDB * Wise2_SequenceDB_alloc_std * Wise2_replace_name_SequenceDB * Wise2_access_name_SequenceDB * Wise2_access_fs_SequenceDB * Wise2_length_fs_SequenceDB * Wise2_flush_SequenceDB * Wise2_add_SequenceDB * Wise2_replace_current_source_SequenceDB * Wise2_access_current_source_SequenceDB * Wise2_replace_current_file_SequenceDB * Wise2_access_current_file_SequenceDB * Wise2_replace_sequence_no_SequenceDB * Wise2_access_sequence_no_SequenceDB * Wise2_replace_byte_position_SequenceDB * Wise2_access_byte_position_SequenceDB * Wise2_free_SequenceDB [destructor] * */ /* Functions that create, manipulate or act on FileSource * * Wise2_hard_link_FileSource * Wise2_FileSource_alloc * Wise2_replace_filename_FileSource * Wise2_access_filename_FileSource * Wise2_replace_input_FileSource * Wise2_access_input_FileSource * Wise2_replace_format_FileSource * Wise2_access_format_FileSource * Wise2_replace_type_FileSource * Wise2_access_type_FileSource * Wise2_free_FileSource [destructor] * */ /* Helper functions in the module * * Wise2_single_fasta_SequenceDB * /* API for object SequenceDB */ /* Function: Wise2_close_SequenceDB(last,sdb) * * Descrip: top level function that closes the SequenceDB * after the last sequence is read. * * * Arg: last Sequence object to be freed [Wise2_Sequence *] * Arg: sdb database to be closed [Wise2_SequenceDB *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_close_SequenceDB( Wise2_Sequence * last,Wise2_SequenceDB * sdb); /* Function: Wise2_hard_link_SequenceDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_SequenceDB *] * * Returns Undocumented return value [Wise2_SequenceDB *] * */ Wise2_SequenceDB * Wise2_hard_link_SequenceDB( Wise2_SequenceDB * obj); /* Function: Wise2_SequenceDB_alloc_std(void) * * Descrip: Equivalent to SequenceDB_alloc_len(SequenceDBLISTLENGTH) * * * * Returns Undocumented return value [Wise2_SequenceDB *] * */ Wise2_SequenceDB * Wise2_SequenceDB_alloc_std(); /* Function: Wise2_replace_name_SequenceDB(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SequenceDB *] * Arg: name New value of the variable [char *] * * Returns member variable name [boolean] * */ boolean Wise2_replace_name_SequenceDB( Wise2_SequenceDB * obj,char * name); /* Function: Wise2_access_name_SequenceDB(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SequenceDB *] * * Returns member variable name [char *] * */ char * Wise2_access_name_SequenceDB( Wise2_SequenceDB * obj); /* Function: Wise2_access_fs_SequenceDB(obj,i) * * Descrip: Access members stored in the fs list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_SequenceDB *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_FileSource *] * */ Wise2_FileSource * Wise2_access_fs_SequenceDB( Wise2_SequenceDB * obj,int i); /* Function: Wise2_length_fs_SequenceDB(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_SequenceDB *] * * Returns length of the list [int] * */ int Wise2_length_fs_SequenceDB( Wise2_SequenceDB * obj); /* Function: Wise2_flush_SequenceDB(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_SequenceDB *] * * Returns Undocumented return value [int] * */ int Wise2_flush_SequenceDB( Wise2_SequenceDB * obj); /* Function: Wise2_add_SequenceDB(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_SequenceDB *] * Arg: add Object to add to the list [Wise2_FileSource *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_SequenceDB( Wise2_SequenceDB * obj,Wise2_FileSource * add); /* Function: Wise2_replace_current_source_SequenceDB(obj,current_source) * * Descrip: Replace member variable current_source * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SequenceDB *] * Arg: current_source New value of the variable [int] * * Returns member variable current_source [boolean] * */ boolean Wise2_replace_current_source_SequenceDB( Wise2_SequenceDB * obj,int current_source); /* Function: Wise2_access_current_source_SequenceDB(obj) * * Descrip: Access member variable current_source * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SequenceDB *] * * Returns member variable current_source [int] * */ int Wise2_access_current_source_SequenceDB( Wise2_SequenceDB * obj); /* Function: Wise2_replace_current_file_SequenceDB(obj,current_file) * * Descrip: Replace member variable current_file * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SequenceDB *] * Arg: current_file New value of the variable [FILE *] * * Returns member variable current_file [boolean] * */ boolean Wise2_replace_current_file_SequenceDB( Wise2_SequenceDB * obj,FILE * current_file); /* Function: Wise2_access_current_file_SequenceDB(obj) * * Descrip: Access member variable current_file * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SequenceDB *] * * Returns member variable current_file [FILE *] * */ FILE * Wise2_access_current_file_SequenceDB( Wise2_SequenceDB * obj); /* Function: Wise2_replace_sequence_no_SequenceDB(obj,sequence_no) * * Descrip: Replace member variable sequence_no * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SequenceDB *] * Arg: sequence_no New value of the variable [int] * * Returns member variable sequence_no [boolean] * */ boolean Wise2_replace_sequence_no_SequenceDB( Wise2_SequenceDB * obj,int sequence_no); /* Function: Wise2_access_sequence_no_SequenceDB(obj) * * Descrip: Access member variable sequence_no * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SequenceDB *] * * Returns member variable sequence_no [int] * */ int Wise2_access_sequence_no_SequenceDB( Wise2_SequenceDB * obj); /* Function: Wise2_replace_byte_position_SequenceDB(obj,byte_position) * * Descrip: Replace member variable byte_position * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SequenceDB *] * Arg: byte_position New value of the variable [int] * * Returns member variable byte_position [boolean] * */ boolean Wise2_replace_byte_position_SequenceDB( Wise2_SequenceDB * obj,int byte_position); /* Function: Wise2_access_byte_position_SequenceDB(obj) * * Descrip: Access member variable byte_position * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_SequenceDB *] * * Returns member variable byte_position [int] * */ int Wise2_access_byte_position_SequenceDB( Wise2_SequenceDB * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_SequenceDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_SequenceDB *] * * Returns Undocumented return value [Wise2_SequenceDB *] * */ Wise2_SequenceDB * Wise2_free_SequenceDB( Wise2_SequenceDB * obj); /* API for object FileSource */ /* Function: Wise2_hard_link_FileSource(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_FileSource *] * * Returns Undocumented return value [Wise2_FileSource *] * */ Wise2_FileSource * Wise2_hard_link_FileSource( Wise2_FileSource * obj); /* Function: Wise2_FileSource_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_FileSource *] * */ Wise2_FileSource * Wise2_FileSource_alloc(); /* Function: Wise2_replace_filename_FileSource(obj,filename) * * Descrip: Replace member variable filename * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_FileSource *] * Arg: filename New value of the variable [char *] * * Returns member variable filename [boolean] * */ boolean Wise2_replace_filename_FileSource( Wise2_FileSource * obj,char * filename); /* Function: Wise2_access_filename_FileSource(obj) * * Descrip: Access member variable filename * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_FileSource *] * * Returns member variable filename [char *] * */ char * Wise2_access_filename_FileSource( Wise2_FileSource * obj); /* Function: Wise2_replace_input_FileSource(obj,input) * * Descrip: Replace member variable input * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_FileSource *] * Arg: input New value of the variable [FILE *] * * Returns member variable input [boolean] * */ boolean Wise2_replace_input_FileSource( Wise2_FileSource * obj,FILE * input); /* Function: Wise2_access_input_FileSource(obj) * * Descrip: Access member variable input * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_FileSource *] * * Returns member variable input [FILE *] * */ FILE * Wise2_access_input_FileSource( Wise2_FileSource * obj); /* Function: Wise2_replace_format_FileSource(obj,format) * * Descrip: Replace member variable format * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_FileSource *] * Arg: format New value of the variable [int] * * Returns member variable format [boolean] * */ boolean Wise2_replace_format_FileSource( Wise2_FileSource * obj,int format); /* Function: Wise2_access_format_FileSource(obj) * * Descrip: Access member variable format * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_FileSource *] * * Returns member variable format [int] * */ int Wise2_access_format_FileSource( Wise2_FileSource * obj); /* Function: Wise2_replace_type_FileSource(obj,type) * * Descrip: Replace member variable type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_FileSource *] * Arg: type New value of the variable [int] * * Returns member variable type [boolean] * */ boolean Wise2_replace_type_FileSource( Wise2_FileSource * obj,int type); /* Function: Wise2_access_type_FileSource(obj) * * Descrip: Access member variable type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_FileSource *] * * Returns member variable type [int] * */ int Wise2_access_type_FileSource( Wise2_FileSource * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_FileSource(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_FileSource *] * * Returns Undocumented return value [Wise2_FileSource *] * */ Wise2_FileSource * Wise2_free_FileSource( Wise2_FileSource * obj); /* These functions are not associated with an object */ /* Function: Wise2_single_fasta_SequenceDB(filename) * * Descrip: pre-packed single fasta file db * * * * Arg: filename name of fastadb [char *] * * Returns Undocumented return value [Wise2_SequenceDB *] * */ Wise2_SequenceDB * Wise2_single_fasta_SequenceDB( char * filename); wise-2.4.1/src/dynlibsrc/sequencedb_api.t0000644000175000001440000000014610670453713017774 0ustar philippuserstypedef struct Wise2_SequenceDB Wise2_SequenceDB; typedef struct Wise2_FileSource Wise2_FileSource; wise-2.4.1/src/dynlibsrc/cdnadb_api.h0000644000175000001440000002241610670453712017060 0ustar philippusers /* Functions that create, manipulate or act on cDNADB * * Wise2_get_cDNA_from_cDNADB * Wise2_hard_link_cDNADB * Wise2_cDNADB_alloc * Wise2_replace_is_single_seq_cDNADB * Wise2_access_is_single_seq_cDNADB * Wise2_replace_done_forward_cDNADB * Wise2_access_done_forward_cDNADB * Wise2_replace_forward_only_cDNADB * Wise2_access_forward_only_cDNADB * Wise2_replace_forw_cDNADB * Wise2_access_forw_cDNADB * Wise2_replace_rev_cDNADB * Wise2_access_rev_cDNADB * Wise2_replace_sdb_cDNADB * Wise2_access_sdb_cDNADB * Wise2_replace_current_cDNADB * Wise2_access_current_cDNADB * Wise2_replace_cses_cDNADB * Wise2_access_cses_cDNADB * Wise2_free_cDNADB [destructor] * */ /* Helper functions in the module * * Wise2_new_cDNADB_from_single_seq * Wise2_new_cDNADB * /* API for object cDNADB */ /* Function: Wise2_get_cDNA_from_cDNADB(cdnadb,de) * * Descrip: Gets cDNA sequence out from * the cDNADB using the information stored in * dataentry * * * Arg: cdnadb cDNA database [Wise2_cDNADB *] * Arg: de DataEntry information [Wise2_DataEntry *] * * Returns Undocumented return value [Wise2_cDNA *] * */ Wise2_cDNA * Wise2_get_cDNA_from_cDNADB( Wise2_cDNADB * cdnadb,Wise2_DataEntry * de); /* Function: Wise2_hard_link_cDNADB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_cDNADB *] * * Returns Undocumented return value [Wise2_cDNADB *] * */ Wise2_cDNADB * Wise2_hard_link_cDNADB( Wise2_cDNADB * obj); /* Function: Wise2_cDNADB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_cDNADB *] * */ Wise2_cDNADB * Wise2_cDNADB_alloc(); /* Function: Wise2_replace_is_single_seq_cDNADB(obj,is_single_seq) * * Descrip: Replace member variable is_single_seq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * Arg: is_single_seq New value of the variable [boolean] * * Returns member variable is_single_seq [boolean] * */ boolean Wise2_replace_is_single_seq_cDNADB( Wise2_cDNADB * obj,boolean is_single_seq); /* Function: Wise2_access_is_single_seq_cDNADB(obj) * * Descrip: Access member variable is_single_seq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * * Returns member variable is_single_seq [boolean] * */ boolean Wise2_access_is_single_seq_cDNADB( Wise2_cDNADB * obj); /* Function: Wise2_replace_done_forward_cDNADB(obj,done_forward) * * Descrip: Replace member variable done_forward * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * Arg: done_forward New value of the variable [boolean] * * Returns member variable done_forward [boolean] * */ boolean Wise2_replace_done_forward_cDNADB( Wise2_cDNADB * obj,boolean done_forward); /* Function: Wise2_access_done_forward_cDNADB(obj) * * Descrip: Access member variable done_forward * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * * Returns member variable done_forward [boolean] * */ boolean Wise2_access_done_forward_cDNADB( Wise2_cDNADB * obj); /* Function: Wise2_replace_forward_only_cDNADB(obj,forward_only) * * Descrip: Replace member variable forward_only * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * Arg: forward_only New value of the variable [boolean] * * Returns member variable forward_only [boolean] * */ boolean Wise2_replace_forward_only_cDNADB( Wise2_cDNADB * obj,boolean forward_only); /* Function: Wise2_access_forward_only_cDNADB(obj) * * Descrip: Access member variable forward_only * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * * Returns member variable forward_only [boolean] * */ boolean Wise2_access_forward_only_cDNADB( Wise2_cDNADB * obj); /* Function: Wise2_replace_forw_cDNADB(obj,forw) * * Descrip: Replace member variable forw * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * Arg: forw New value of the variable [Wise2_ComplexSequence *] * * Returns member variable forw [boolean] * */ boolean Wise2_replace_forw_cDNADB( Wise2_cDNADB * obj,Wise2_ComplexSequence * forw); /* Function: Wise2_access_forw_cDNADB(obj) * * Descrip: Access member variable forw * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * * Returns member variable forw [Wise2_ComplexSequence *] * */ Wise2_ComplexSequence * Wise2_access_forw_cDNADB( Wise2_cDNADB * obj); /* Function: Wise2_replace_rev_cDNADB(obj,rev) * * Descrip: Replace member variable rev * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * Arg: rev New value of the variable [Wise2_ComplexSequence *] * * Returns member variable rev [boolean] * */ boolean Wise2_replace_rev_cDNADB( Wise2_cDNADB * obj,Wise2_ComplexSequence * rev); /* Function: Wise2_access_rev_cDNADB(obj) * * Descrip: Access member variable rev * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * * Returns member variable rev [Wise2_ComplexSequence *] * */ Wise2_ComplexSequence * Wise2_access_rev_cDNADB( Wise2_cDNADB * obj); /* Function: Wise2_replace_sdb_cDNADB(obj,sdb) * * Descrip: Replace member variable sdb * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * Arg: sdb New value of the variable [Wise2_SequenceDB *] * * Returns member variable sdb [boolean] * */ boolean Wise2_replace_sdb_cDNADB( Wise2_cDNADB * obj,Wise2_SequenceDB * sdb); /* Function: Wise2_access_sdb_cDNADB(obj) * * Descrip: Access member variable sdb * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * * Returns member variable sdb [Wise2_SequenceDB *] * */ Wise2_SequenceDB * Wise2_access_sdb_cDNADB( Wise2_cDNADB * obj); /* Function: Wise2_replace_current_cDNADB(obj,current) * * Descrip: Replace member variable current * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * Arg: current New value of the variable [Wise2_Sequence *] * * Returns member variable current [boolean] * */ boolean Wise2_replace_current_cDNADB( Wise2_cDNADB * obj,Wise2_Sequence * current); /* Function: Wise2_access_current_cDNADB(obj) * * Descrip: Access member variable current * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * * Returns member variable current [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_access_current_cDNADB( Wise2_cDNADB * obj); /* Function: Wise2_replace_cses_cDNADB(obj,cses) * * Descrip: Replace member variable cses * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * Arg: cses New value of the variable [Wise2_ComplexSequenceEvalSet *] * * Returns member variable cses [boolean] * */ boolean Wise2_replace_cses_cDNADB( Wise2_cDNADB * obj,Wise2_ComplexSequenceEvalSet * cses); /* Function: Wise2_access_cses_cDNADB(obj) * * Descrip: Access member variable cses * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_cDNADB *] * * Returns member variable cses [Wise2_ComplexSequenceEvalSet *] * */ Wise2_ComplexSequenceEvalSet * Wise2_access_cses_cDNADB( Wise2_cDNADB * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_cDNADB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_cDNADB *] * * Returns Undocumented return value [Wise2_cDNADB *] * */ Wise2_cDNADB * Wise2_free_cDNADB( Wise2_cDNADB * obj); /* These functions are not associated with an object */ /* Function: Wise2_new_cDNADB_from_single_seq(seq) * * Descrip: To make a new cDNA database * from a single cDNA Sequence with a eval system * * * Arg: seq sequence which as placed into cDNADB structure. [Wise2_cDNA *] * * Returns Undocumented return value [Wise2_cDNADB *] * */ Wise2_cDNADB * Wise2_new_cDNADB_from_single_seq( Wise2_cDNA * seq); /* Function: Wise2_new_cDNADB(seqdb) * * Descrip: To make a new cDNA database * * * Arg: seqdb sequence database [Wise2_SequenceDB *] * * Returns Undocumented return value [Wise2_cDNADB *] * */ Wise2_cDNADB * Wise2_new_cDNADB( Wise2_SequenceDB * seqdb); wise-2.4.1/src/dynlibsrc/cdnadb_api.t0000644000175000001440000000005310670453712017065 0ustar philippuserstypedef struct Wise2_cDNADB Wise2_cDNADB; wise-2.4.1/src/dynlibsrc/complexconsensi.dy0000644000175000001440000001017007313404537020405 0ustar philippusers/* Last edited: Jan 10 17:23 1997 (birney) */ %{ #include "wisebase.h" #include "probability.h" #define ComplexConsensiLISTLENGTH 64 %} struct ComplexConsensusWord char * pattern Score score Probability p struct ComplexConsensi ComplexConsensusWord ** ccw !list char * name %{ #include "complexconsensi.h" %func shows complexconsensi in vaguely human form %arg %% void show_ComplexConsensi(ComplexConsensi * cc,FILE *ofp) { register int i; for(i=0;ilen;i++) show_ComplexConsensusWord(cc->ccw[i],ofp); } %func shows an individual ccword %type internal %arg %% void show_ComplexConsensusWord(ComplexConsensusWord * ccw,FILE * ofp) { fprintf(ofp,"%s %4.4f %d\n",ccw->pattern,ccw->p,ccw->score); } %func Way of getting probabilities out of a consensus. If it is in the Consensus, then gets prob, otherwise 0. %arg %% Probability word_from_ComplexConsensi(char * word,ComplexConsensi * cc) { ComplexConsensusWord * ccw; ccw = best_ComplexConsensusWord(word,cc); if( ccw == NULL ) return 0.0; return ccw->p; } %func Way of getting scores out of a consensus. If it is in the Consensus, then gets score, otherwise NEGI. %arg %% Score score_from_ComplexConsensi(char * word,ComplexConsensi * cc) { ComplexConsensusWord * ccw; ccw = best_ComplexConsensusWord(word,cc); if( ccw == NULL ) return NEGI; return ccw->score; } %func Finds the best (highest) match to this word %arg %% ComplexConsensusWord * best_ComplexConsensusWord(char * word,ComplexConsensi * cc) { register int i; for(i=0;ilen;i++) { if( word_matches_ComplexConsensusWord(word,cc->ccw[i]) == TRUE) return cc->ccw[i]; } return NULL; } %func Core of the matching system. Checks that word matches ComplexConsensusWord. This says that '-' matches anything. Issues a warning if hits a '\0' in word %arg %% boolean word_matches_ComplexConsensusWord(char * word,ComplexConsensusWord * ccw) { return strcmp_with_dashes(word,ccw->pattern); } %func The matching 'function' used by /word_matches_ComplexConsensusWord %type internal %% boolean strcmp_with_dashes(char * word,char * pattern) { char * runner; char * base = word; for(runner = pattern;*runner && *word;word++,runner++) { if( *runner == '-') { continue; } if( *runner != *word ) { break; } } if( *word == '\0' && *runner != '\0') { warn("Tried to match a word [%s] which is shorter than the pattern [%s]",base,pattern); return FALSE; } if( *runner == '\0') { /* end of pattern */ return TRUE; } return FALSE; } /************************/ /* I/O */ /************************/ %func Reads a file containing the ComplexConsensi. Not every useful, as most times these consensi are in one file, with other things %arg %% ComplexConsensi * read_ComplexConsensi_file(char * filename) { FILE * ifp; ComplexConsensi * out; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open file %s for ComplexConsensi",filename); return NULL; } out = read_ComplexConsensi(ifp); fclose(ifp); return out; } %func Reads on ComplexConsensi from the FILE ifp. %arg ifp input filestream %% ComplexConsensi * read_ComplexConsensi(FILE * ifp) { ComplexConsensi * out; ComplexConsensusWord * temp; char buffer[MAXLINE]; out = ComplexConsensi_alloc_std(); if( out == NULL ) return NULL; while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '#' ) continue; temp = read_ComplexConsensusWord_line(buffer); if( temp != NULL ) add_ComplexConsensi(out,temp); } return out; } %func Reads a single ccword from a line %type internal %arg %% ComplexConsensusWord * read_ComplexConsensusWord_line(char * line) { ComplexConsensusWord * out; char * pattern; char * score; pattern = strtok(line,spacestr); score = strtok(NULL,spacestr); if( pattern == NULL || score == NULL ) { warn("Could not read a ComplexConsenusWord... ooops"); return NULL; } out = ComplexConsensusWord_alloc(); if( out == NULL) return NULL; out->pattern = stringalloc(pattern); out->score = (double) atof(score); return out; } wise-2.4.1/src/dynlibsrc/asciibtcanvas.dy0000644000175000001440000002030207634046065020010 0ustar philippusers %{ #include "btcanvas.h" %} struct Ascii_btc_Data FILE * ofp // file to write to int current_x // position in main line int paint_x // painting cursor on the line int res_left // amount reserved on left int main // main block amount int res_right // amount reserved on right char ** scratch // scratch pad lines int depth_scratch // depth of scratch pad for memory boolean in_use !def="FALSE" btPasteArea * bpa // this is what we recycle.. %{ #include "asciibtcanvas.h" %func prints out usage for ascii_btCanvas_from_commandline %% void ascii_btCanvas_usage(FILE * ofp) { fprintf(ofp,"Options for ascii canvas\n"); fprintf(ofp," -acleft [integer] size of left hand panel\n"); fprintf(ofp," -acmain [integer] size of main panel\n"); fprintf(ofp," -acright [integer] size of right hand panel\n"); } %func Makes a ascii btCanvas from the command line, swallowing up options for -acleft -acright -acmain If there are no options, builds with 15,50,5 %% btCanvas * ascii_btCanvas_from_commandline(int * argc,char ** argv,int default_left,int default_main,int default_right,FILE * ofp,int height) { int left = default_left; int main_length = default_main; int right = default_right; strip_out_integer_argument(argc,argv,"acleft",&left); strip_out_integer_argument(argc,argv,"acright",&right); strip_out_integer_argument(argc,argv,"acmain",&main_length); return new_Ascii_btCanvas(ofp,left,main_length,right,height); } %func The only function specifically for Ascii bt Canvases. Use this to make a new btCanvas. Then use functions like /get_paste_area_btCanvas to actually use it. Everything else is handled by data structures and pointer-to-functions which are hidden to you (and be thankful for that!) The standard /free_btCanvas will free the hidden data structures as well %arg ofp FILE stream to write the ascii to left amount of text to reserve on the left right amount of text to reserve on the right height height of block %% btCanvas * new_Ascii_btCanvas(FILE * ofp,int left,int main,int right,int height) { btCanvas * out; Ascii_btc_Data * d; out = btCanvas_alloc(); d = new_Ascii_btc_Data(ofp,left,main,right,height); out->canvas_data = (void *) d; out->decons = free_Ascii_btc; /* now need to put in correct pointers to functions for * canvas implementation */ out->can_get_paste_area = can_get_bt_Ascii; out->advance_line = ascii_next_line_btPasteArea; out->get_paste_area = next_Ascii_btpa; out->get_reserved_right = get_ascii_right_btPasteArea; out->get_reserved_left = get_ascii_left_btPasteArea; return out; } %func gets the next btPasteArea. Here we con people by simply passing out the 'bpa' held in canvas and never reallocating it (see /free_Ascii_btpa which is already attached to the bpa). %type internal %% btPasteArea * next_Ascii_btpa(btCanvas * btc,int length) { Ascii_btc_Data * abd = NULL; abd = (Ascii_btc_Data*) btc->canvas_data; if( abd->in_use == TRUE ) { warn("You are already using a btPasteArea on this canvas. Only one at a time! Probably you have not freed the btPasteArea before hand"); return NULL; } if( abd->current_x + length > abd->main + abd->res_left ) { warn("Asking for more block than I can give you. You have not tested with can_get_paste_area. Bad boy!"); return NULL; } abd->in_use = TRUE; abd->paint_x = abd->current_x; abd->current_x += length; abd->bpa->length = length; return abd->bpa; } %func The paste function. Going to get at all the info (obviously) through data %type internal %% boolean paste_char_bt_Ascii(btPasteArea * bpa,int x,int y,char c,int format) { Ascii_btc_Data * abd = NULL; abd = (Ascii_btc_Data*) bpa->canvas_data; /* fprintf(stderr,"Printing at %d %d %c\n",x,y,c); */ abd->scratch[y][abd->paint_x + x] = c; return TRUE; } %func Can get function %type internal %% boolean can_get_bt_Ascii(btCanvas * btc,int length) { Ascii_btc_Data * abd = NULL; abd = (Ascii_btc_Data*) btc->canvas_data; /* fprintf(stderr,"Current is %d to %d\n",abd->current_x,length); */ if( abd->current_x + length >= abd->main + abd->res_left ) return FALSE; /* fprintf(stderr,"Returning TRUE\n"); */ return TRUE; } %func The get left area function. Again, con people into thinking that we are passing a 'live' bpa %type internal %% btPasteArea * get_ascii_left_btPasteArea(btCanvas * btc) { Ascii_btc_Data * abd = NULL; int length; abd = (Ascii_btc_Data*) btc->canvas_data; length = abd->res_left; if( abd->in_use == TRUE ) { warn("You are already using a btPasteArea on this canvas. Only one at a time! Probably you have not freed the btPasteArea before hand"); return NULL; } abd->in_use = TRUE; abd->paint_x = 0; abd->bpa->length = length; return abd->bpa; } %func The get right area function. Again, con people into thinking that we are passing a 'live' bpa %type internal %% btPasteArea * get_ascii_right_btPasteArea(btCanvas * btc) { Ascii_btc_Data * abd = NULL; int length; abd = (Ascii_btc_Data*) btc->canvas_data; length = abd->res_left + abd->main; if( abd->in_use == TRUE ) { warn("You are already using a btPasteArea on this canvas. Only one at a time! Probably you have not freed the btPasteArea before hand"); return NULL; } abd->in_use = TRUE; abd->paint_x = length; abd->bpa->length = length; return abd->bpa; } %func Advancement function. %type internal %% boolean ascii_next_line_btPasteArea(btCanvas * btc) { Ascii_btc_Data * abd = NULL; int i,len; /* fprintf(stderr,"Going to advance\n"); */ abd = (Ascii_btc_Data*) btc->canvas_data; if( abd->in_use == TRUE ) { warn("You are already using a btPasteArea on this canvas, and now you are asking to advance a line. Ouch"); return FALSE; } len = abd->res_left + abd->main + abd->res_right; for(i=0;idepth_scratch;i++) { /* fprintf(stderr,"About to print %s\n",abd->scratch[i]);*/ fputs(abd->scratch[i],abd->ofp); } fputs("\n\n",abd->ofp); for(i=0;idepth_scratch;i++) { memset(abd->scratch[i],' ',len); } abd->current_x = abd->res_left; return TRUE; } %func Deconstructor for a btPasteArea we are going to make. Will be attached on construction %type internal %% btPasteArea * free_Ascii_btpa(btPasteArea * obj) { Ascii_btc_Data * abd; /* all we have to do is set to FALSE the Ascii_btc_Data pointed to by canvas_data */ abd = (Ascii_btc_Data*) obj->canvas_data; abd->in_use = FALSE; return NULL; } %func makes new ascii data. NB. Notice allocation of 'dummy' btPasteArea and of the scratch pad. %type internal %% Ascii_btc_Data * new_Ascii_btc_Data(FILE * ofp,int left,int main,int right,int height) { Ascii_btc_Data * out; int tot; int i; tot = left + main + right +2; out = Ascii_btc_Data_alloc(); out->ofp = ofp; out->res_left = left; out->main = main; out->res_right = right; out->current_x= left; out->paint_x = left; out->scratch = (char **) ckcalloc(height,sizeof(char *)); for(i=0;iscratch[i] = (char *) ckcalloc(tot,sizeof(char)); memset(out->scratch[i],' ',tot-2); out->scratch[i][tot-1] = '\0'; out->scratch[i][tot-2] = '\n'; } out->depth_scratch = height; out->in_use = FALSE; out->bpa = btPasteArea_alloc(); out->bpa->height = height; out->bpa->canvas_data = (void *) out; out->bpa->decons = free_Ascii_btpa; out->bpa->paste_char = paste_char_bt_Ascii; return out; } %func Deconstructor for the btcanvas we are going to make. This function will be attached to the btcanvas on construction %type internal %% btCanvas * free_Ascii_btc(btCanvas * btc) { btc->canvas_data = (void *) free_Ascii_btc_Data((Ascii_btc_Data *)(btc->canvas_data)); ckfree(btc); return NULL; } %func Specialist deconstructor really for scratch pad %type internal %arg obj w Ascii_btc_Data to be zapped %% !deconstructor Ascii_btc_Data * free_Ascii_btc_Data(Ascii_btc_Data * obj) { int i; for(i=0;idepth_scratch;i++) { ckfree(obj->scratch[i]); } ckfree(obj->scratch); ckfree(obj->bpa); /* very subtle. bpa actually is a complete dummy obj * calling free_btPasteArea would be **really** bad */ ckfree(obj); return NULL; } %} wise-2.4.1/src/dynlibsrc/codon.dy0000644000175000001440000002665607657732677016342 0ustar philippusers/* Last edited: Mar 23 18:29 1997 (birney) */ %{ #include "wisebase.h" #define BASE_A 0 #define BASE_G 1 #define BASE_C 2 #define BASE_T 3 #define BASE_N 4 typedef short int base; typedef short int codon; typedef char aa; #define aminoacid_number(c) (c-'A') #define is_base(a) (a == 'A' || a == 'T' || a == 'C' || a == 'G' || a== 'N' || a == 'a' || a == 't' || a == 'c' || a == 'g' || a == 'n' ? 1 : 0) %} api object CodonTable des free_CodonTable func read_CodonTable_file func read_CodonTable func aminoacid_from_seq func aminoacid_from_codon func is_stop_codon func is_valid_aminoacid endobject func is_non_ambiguous_codon_seq func codon_from_base4_codon func base4_codon_from_codon func has_random_bases func permute_possible_random_bases func base_from_codon func codon_from_seq func base4_codon_from_seq func char_from_base func base_from_char func char_complement_base func complement_base endapi struct CodonTable aa codon_str[125]; char * name; %info The codon table provides a mapping from the 64 codons to the 20 amino acids. The rest of the modules provides assorted codon<->base<->amino acid mappings. Probably the trickiest thing is that there are two different types of representations of codons. One in base 5 (N being the 5th base), providing 0-124 inclusive codon numbers. These numbers are the ones going to be principly used in most calculations. However, it is often very useful to use 0-63 numbers, for example in the precise definition of the codon table. %% %{ #include "codon.h" %func Opens filename, reads it as if a Ewan style codon table and closes. %arg file r filename to open return o A codon-table, NULL if error %% CodonTable * read_CodonTable_file(char * file) { FILE * ifp; CodonTable * out; ifp = openfile(file,"r"); if( ifp == NULL) { warn("Could not open file %s as codon table file",file); return NULL; } out = read_CodonTable(ifp); fclose(ifp); return out; } %func reads a codon table from a filestream in Ewan format. As Ewan format is really bad and has no start/stop this will effectively read to the end of the file. Ooops. %arg ifp r file input %% CodonTable * read_CodonTable(FILE * ifp) { char buffer[MAXLINE]; CodonTable * out; codon c; char * runner; char * run2; out = CodonTable_alloc(); memset(out->codon_str,'x',125); while( fgets(buffer,MAXLINE,ifp) != NULL) { if( buffer[0] == '#' || buffer[0] == '!') continue; runner = strtok(buffer,spacestr); run2 = strtok(NULL,spacestr); if( runner == NULL || run2 == NULL ){ warn("Unable to read a line in codon table"); } c = codon_from_seq(runner); out->codon_str[c] = *run2; } return out; } %func Not very useful function: allocates a single amino acid (ie, buffer length one) so it can be freed later. %type internal %arg ct r codon table seq r pointer to DNA Sequence chars %% char * alloc_aminoacid_from_seq(CodonTable * ct,char * seq) { char buf[2]; buf[1] = '\0'; buf[0] = aminoacid_from_codon(ct,codon_from_seq(seq)); return stringalloc(buf); } %func Returns the amino acid for this position in the DNA sequence Takes the pointer +1 and +2 points. No error checks implemented. Probably a mistake ;) %arg ct r codon table seq r pointer to DNA chars return an amino acid char (A-Z) %% aa aminoacid_from_seq(CodonTable * ct,char * seq) { return aminoacid_from_codon(ct,codon_from_seq(seq)); } %func returns amino acid for this codon number (NB codon numbers 0-125) %arg ct r codon table c r codon number return r aminoacid that is this codon (X for ambiguous, * for stop) %% aa aminoacid_from_codon(CodonTable * ct,codon c) { return ct->codon_str[c]; } %func a sister function to aminoacid_from_codon: returns amino acid number (0-26) for this codon number (0-125) %arg ct r codon table c r codon number return r aminoacid number [0-26] for this codon %% int aminoacid_no_from_codon(CodonTable * ct,codon c) { return (ct->codon_str[c] - 'A'); } %func tells you whether this codon number is really a stop in this translation table %arg ct r codon table c r codon number return TRUE if is stop, FALSE otherwise %% boolean is_stop_codon(codon c,CodonTable * ct) { aa a; a = aminoacid_from_codon(ct,c); if( a == 'X' || a == '*') { return TRUE; } return FALSE; } %func Tells you if this codon is a real codon %arg seq r pointer to DNA sequence return TRUE if real codon, FALSE if contains N's %% boolean is_non_ambiguous_codon_seq(char * seq) { if( *seq == '\0' || *(seq+1) == '\0' || *(seq+2) == '\0') { warn("Attempting to find a codon number is something less than 3 bases long!"); return FALSE; } if( base_from_char(*(seq++)) == BASE_N) return FALSE; if( base_from_char(*(seq++)) == BASE_N) return FALSE; if( base_from_char(*(seq)) == BASE_N) return FALSE; return TRUE; } %func Tells you if this letter (c) is recognised as a valid amino acid in this codon table %arg ct r Codon Table c aminoacid return TRUE if valid, FALSE if not. %% boolean is_valid_aminoacid(CodonTable * ct,char c) { if( strchr(ct->codon_str,c) != NULL ) return TRUE; else return FALSE; } %func Tells you if the letter is A,T,C,G,N (NB, N is ok). %arg c r base return TRUE if (ATGCN) FALSE otherwise %% boolean is_valid_base_char(char c) { if( c == 'A' || c == 'T' || c == 'G' || c == 'C' || c == 'N') return TRUE; return FALSE; } %func maps a 0-63 codon to a 0-123 codon. Suprisingly useful. %% codon codon_from_base4_codon(int c) { base one; base two; base three; one = c / 16; c -= one*16; two = c/4; c -= 4*two; three = c; return 25*one+5*two+three; } %func maps a 0-125 codon to a 0-63 codon. If ambiguous then returns 64 having issued a warning. %arg c r codon 0-125 return base 4 codon (0-63) %% int base4_codon_from_codon(codon c) { base one; base two; base three; all_bases_from_codon(c,&one,&two,&three); if( one == BASE_N || two == BASE_N || three == BASE_N) { /* GSS 07:07:2000 DISABLED WARNING */ warn("Attempting to convert an ambiguous codon to base 64" " returning 64"); return 64; } return one*16 + two*4 + three; } %func Tests to see if this codon number has any N's in it %arg c r codon number 0-124 return TRUE if has N's , FALSE otherwise %% boolean has_random_bases(codon c) { base o; base w; base t; o = base_from_codon(c,1); w = base_from_codon(c,2); t = base_from_codon(c,3); if( o == BASE_N || w == BASE_N || t == BASE_N) return TRUE; return FALSE; } %func Bizarely useful function for calculating ambiguity scores. This takes the codon c, and for each possible base, if it is N, replaces it with one, two or three. If the base is not N, it remains the same %arg c r codon number one r base to replace first position if N two r base to replace second position if N three r base to replace third position if N return codon number %% codon permute_possible_random_bases(codon c,base one,base two,base three) { base o; base w; base t; o = base_from_codon(c,1); w = base_from_codon(c,2); t = base_from_codon(c,3); if( o == BASE_N ) o = one; if( w == BASE_N ) w = two; if( t == BASE_N ) t = three; return one*25+two*5+three; } %func Really an internal function, by useful enough to encourage outside use. Takes codon c and breaks it into 3 base-numbers %% void all_bases_from_codon(codon c,base * one,base * two,base * three) { base o; base t; base r; o = c/25; c -= o*25; t = c/5; c -= t*5; r = c; if( one != NULL ) *one = o; if( two != NULL ) *two = t; if( three != NULL ) *three = r; } %func Reverses codon. Takes a forward codon number and builds the inverted codon number %% codon reverse_codon(codon c) { base one; base two; base three; all_bases_from_codon(c,&one,&two,&three); one = complement_base(one); two = complement_base(two); three = complement_base(three); return three*125 + two * 25 + one; } %func Probably not the best function to use for this, but useful. Takes a codon and with pos being 1,2,3 gives you the firt,second of third base %% base base_from_codon(codon c,int pos) { base one; base two; base three; one = c/25; c -= one*25; two = c/5; c -= two*5; three = c; switch(pos) { case 1 : return one; case 2: return two; case 3: return three; default : warn("This is not good news: got a position asked which is not 1,2,3 [%d](BTW - first base is 1)",pos); return BASE_N; } } %func takes an ASCII coded pointer to a 3 base pair sequence (it could be the part of a sequence: it only assummes that the seq points with 3 chars at pos 0,1,2 in C coordinates from seq. No NULL is required). It ives back the codon as made from standard mapping, ie, 25*base_1+5*base_2 + base3 being a number from 0-124 inc. %arg seq pointer to sequence of at least 3 chrs long. %% codon codon_from_seq(char * seq) { base one; base two; base three; if( !is_base(*seq) || !is_base(*(seq+1)) || !is_base (*(seq+2)) ) { warn("Attempting to translate bad base %c%c%c",seq[0],seq[1],seq[2]); one = BASE_N; two = BASE_N; three = BASE_N; } else { one = base_from_char(*seq); two = base_from_char(*(seq+1)); three = base_from_char(*(seq+2)); } return one*25+two*5+three; } %func Sometimes it is more useful to work in base64, ie, non N. this functions does the same thing as /codon_from_seq but produces a seq being 16*base1 + 4 *base2 + base3 %arg seq pointer to sequence of at least 3 chrs long %% int base4_codon_from_seq(char * seq) { base one; base two; base three; one = base_from_char(*seq); two = base_from_char(*(seq+1)); three = base_from_char(*(seq+2)); if( one == BASE_N || two == BASE_N || three == BASE_N) return 64; else return one*16+two*4+three; } %func maps a base number (-04 inc) to A,T,G,C,N %% char char_from_base(base b) { switch(b) { case BASE_A : return 'A'; case BASE_G : return 'G'; case BASE_C : return 'C'; case BASE_T : return 'T'; case BASE_N : return 'N'; default : return '?'; } } %func maps a char (atcgn) to number, case insensitive, returns BASE_N if not atcgn %% base base_from_char(char c) { c = (char)toupper((int)c); switch(c) { case 'A' : return BASE_A; case 'T' : return BASE_T; case 'G' : return BASE_G; case 'C' : return BASE_C; case 'N' : return BASE_N; default : return BASE_N; } } %func the char equivalent of /complement_base. this gives the complement in char of a base in char. Does not check for non ATGCN %% char char_complement_base(char c) { if( c == '-' || c == '.' || c == '~' ) { return c; } return char_from_base(complement_base(base_from_char(c))); } %func gives back the complement as a number ofthe base (given as a number) %% base complement_base(base b) { switch(b) { case BASE_A : return BASE_T; case BASE_G : return BASE_C; case BASE_C : return BASE_G; case BASE_T : return BASE_A; case BASE_N : return BASE_N; default : return BASE_N; } } %func returns the number of four fold degenerate sites in this codon %% int four_fold_sites_CodonTable(CodonTable *ct,char * seq) { int site_count; int i; int j; char codon[3]; char aa; assert(ct); codon[0] = seq[0]; codon[1] = seq[1]; codon[2] = seq[2]; aa = aminoacid_from_seq(ct,codon); site_count = 0; for(i=0;i<3;i++) { for( j=0;j<4;j++) { codon[i] = char_from_base(j); if( aa != aminoacid_from_seq(ct,codon) ) { break; } } if( j >= 4 ) { site_count++; } codon[i] = seq[i]; } return site_count; } wise-2.4.1/src/dynlibsrc/codon.xs0000644000175000001440000000572110670453712016321 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::CodonTable Wise2_CodonTable * read_CodonTable_file(file) char * file CODE: RETVAL = Wise2_read_CodonTable_file(file); OUTPUT: RETVAL Wise2_CodonTable * read_CodonTable(ifp) FILE * ifp CODE: RETVAL = Wise2_read_CodonTable(ifp); OUTPUT: RETVAL aa aminoacid_from_seq(ct,seq) Wise2_CodonTable * ct char * seq CODE: RETVAL = Wise2_aminoacid_from_seq(ct,seq); OUTPUT: RETVAL aa aminoacid_from_codon(ct,c) Wise2_CodonTable * ct codon c CODE: RETVAL = Wise2_aminoacid_from_codon(ct,c); OUTPUT: RETVAL boolean is_stop_codon(c,ct) codon c Wise2_CodonTable * ct CODE: RETVAL = Wise2_is_stop_codon(c,ct); OUTPUT: RETVAL boolean is_valid_aminoacid(ct,c) Wise2_CodonTable * ct char c CODE: RETVAL = Wise2_is_valid_aminoacid(ct,c); OUTPUT: RETVAL Wise2_CodonTable * hard_link_CodonTable(obj) Wise2_CodonTable * obj CODE: RETVAL = Wise2_hard_link_CodonTable(obj); OUTPUT: RETVAL Wise2_CodonTable * alloc() CODE: RETVAL = Wise2_CodonTable_alloc(); OUTPUT: RETVAL boolean set_name(obj,name) Wise2_CodonTable * obj char * name CODE: RETVAL = Wise2_replace_name_CodonTable(obj,Wise2_stringalloc(name)); OUTPUT: RETVAL char * name(obj) Wise2_CodonTable * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_name_CodonTable(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_CodonTable * new(class) char * class PPCODE: Wise2_CodonTable * out; out = Wise2_CodonTable_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_CodonTable * obj CODE: Wise2_free_CodonTable(obj); MODULE = Wise2 PACKAGE = Wise2 boolean is_non_ambiguous_codon_seq(seq) char * seq CODE: RETVAL = Wise2_is_non_ambiguous_codon_seq(seq); OUTPUT: RETVAL codon codon_from_base4_codon(c) int c CODE: RETVAL = Wise2_codon_from_base4_codon(c); OUTPUT: RETVAL int base4_codon_from_codon(c) codon c CODE: RETVAL = Wise2_base4_codon_from_codon(c); OUTPUT: RETVAL boolean has_random_bases(c) codon c CODE: RETVAL = Wise2_has_random_bases(c); OUTPUT: RETVAL codon permute_possible_random_bases(c,one,two,three) codon c base one base two base three CODE: RETVAL = Wise2_permute_possible_random_bases(c,one,two,three); OUTPUT: RETVAL base base_from_codon(c,pos) codon c int pos CODE: RETVAL = Wise2_base_from_codon(c,pos); OUTPUT: RETVAL codon codon_from_seq(seq) char * seq CODE: RETVAL = Wise2_codon_from_seq(seq); OUTPUT: RETVAL int base4_codon_from_seq(seq) char * seq CODE: RETVAL = Wise2_base4_codon_from_seq(seq); OUTPUT: RETVAL char char_from_base(b) base b CODE: RETVAL = Wise2_char_from_base(b); OUTPUT: RETVAL base base_from_char(c) char c CODE: RETVAL = Wise2_base_from_char(c); OUTPUT: RETVAL char char_complement_base(c) char c CODE: RETVAL = Wise2_char_complement_base(c); OUTPUT: RETVAL base complement_base(b) base b CODE: RETVAL = Wise2_complement_base(b); OUTPUT: RETVAL wise-2.4.1/src/dynlibsrc/histogram.dy0000644000175000001440000014217007313404541017172 0ustar philippusers %{ #include "wisebase.h" #define HISTFIT_NONE 0 /* no fit done yet */ #define HISTFIT_EVD 1 /* fit type = extreme value dist */ #define HISTFIT_GAUSSIAN 2 /* fit type = Gaussian */ #define EVD_MU 0 /* EVD fit parameter mu */ #define EVD_LAMBDA 1 /* EVD fit parameter lambda */ #define EVD_WONKA 2 /* EVD fit fudge factor */ #define GAUSS_MEAN 0 /* Gaussian parameter mean */ #define GAUSS_SD 1 /* Gaussian parameter std. dev. */ #ifndef MIN #define MIN(a,b) ((a)<(b) ? (a) : (b)) #endif %} struct Histogram int* histogram; !hidden // counts of hits int min; // elem 0 of histogram == min int max; // last elem of histogram == max int highscore; // highest active elem has this score int lowscore; // lowest active elem has this score int lumpsize; // when resizing, overalloc by this int total; // total # of hits counted float* expect; !hidden // expected counts of hits int fit_type; // flag indicating distribution type float param[3]; // parameters used for fits float chisq; // chi-squared val for goodness of fit float chip; // P value for chisquared %info This Object came from Sean Eddy excellent histogram package. He donated it free of all restrictions to allow it to be used in the Wise2 package without complicated licensing terms. He is a *very* nice man. It was made into a dynamite object so that a) External ports to scripting languages would be trivial b) cooperation with future versions of histogram.c would be possible. Here is the rest of the documentation from sean. Keep a score histogram. The main implementation issue here is that the range of scores is unknown, and will go negative. histogram is a 0..max-min array that represents the range min..max. A given score is indexed in histogram array as score-min. The AddToHistogram function deals with dynamically resizing the histogram array when necessary. %% api object Histogram des free_Histogram func UnfitHistogram func AddToHistogram func PrintASCIIHistogram func EVDBasicFit func ExtremeValueFitHistogram func ExtremeValueSetHistogram func GaussianFitHistogram func GaussianSetHistogram func Evalue_from_Histogram endobject func new_Histogram endapi %{ #include "histogram.h" %func This is a convient short cut for calculating expected values from the histogram of results %simple evalue %arg his Histogram object score score you want the evalue for %% double Evalue_from_Histogram(Histogram * his,double score) { return ExtremeValueE(score,his->param[EVD_MU],his->param[EVD_LAMBDA],his->total); } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Allocate and return a histogram structure. min and max are your best guess. They need not be absolutely correct; the histogram will expand dynamically to accomodate scores that exceed these suggested bounds. The amount that the histogram grows by is set by "lumpsize" Was called AllocHistorgram new_Historgram is more wise2-ish %arg min minimum score (integer) max maximum score (integer) lumpsize when reallocating histogram, the reallocation amount %% Histogram * new_Histogram(int min, int max, int lumpsize) { Histogram *h; int newsize; int i; newsize = max - min + 1; h = Histogram_alloc(); /* ewan changed */ if( h == NULL ) { return NULL; } h->min = min; h->max = max; h->total = 0; h->lowscore = INT_MAX; h->highscore = INT_MIN; h->lumpsize = lumpsize; h->histogram = (int *) ckcalloc (newsize,sizeof(int)); /* ewan changed */ for (i = 0; i < newsize; i++) h->histogram[i] = 0; h->expect = NULL; h->fit_type = HISTFIT_NONE; h->param[EVD_WONKA] = 1.0; /* just in case, make sure this initializes */ return h; } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Free only the theoretical fit part of a histogram. %% void UnfitHistogram(Histogram * h) { if (h->expect != NULL) ckfree(h->expect); h->expect = NULL; h->fit_type = HISTFIT_NONE; } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Bump the appropriate counter in a histogram structure, given a score. The score is rounded off from float precision to the next lower integer. %simple add %% void AddToHistogram(Histogram * h, float sc) { int score; int moveby; int prevsize; int newsize; int i; /* Adding to a histogram conflicts with existing fit: * prohibit this. */ if (h->fit_type != HISTFIT_NONE) fatal("AddToHistogram(): Can't add to a fitted histogram\n"); /* histogram bins are defined as: score >= bin value, < bin+1 * -1.9 -> -2 -0.4 -> -1 1.9 -> 1 * -2.1 -> -3 0.4 -> 0 2.1 -> 2 */ score = (int) floor(sc); /* Check to see if we must reallocate the histogram. */ if (score < h->min) { prevsize = h->max - h->min + 1; moveby = (h->min - score) + h->lumpsize; newsize = prevsize + moveby; h->min -= moveby; h->histogram = (int *) ckrealloc(h->histogram, sizeof(int) * newsize); if( h->histogram == NULL ) { fatal("Unable to extend histogram... have to crash... sorry!"); } memmove(h->histogram+moveby, h->histogram, sizeof(int) * prevsize); for (i = 0; i < moveby; i++) h->histogram[i] = 0; } else if (score > h->max) { prevsize = h->max - h->min + 1; h->max = h->lumpsize + score; newsize = h->max - h->min + 1; h->histogram = (int *) ckrealloc(h->histogram, sizeof(int) * newsize); if( h->histogram == NULL ) { fatal("Cannot realloc histogram... going to die... sorry!"); } for (i = prevsize; i < newsize; i++) h->histogram[i] = 0; } /* Bump the correct bin. * The bin number is score - h->min */ h->histogram[score - h->min]++; h->total++; if (score < h->lowscore) h->lowscore = score; if (score > h->highscore) h->highscore = score; #if DEBUG fprintf(stderr, "AddToHistogram(): added %.1f; rounded to %d; in bin %d (%d-%d)\n", sc, score, score-h->min, h->min, h->max); #endif return; } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Print a "prettified" histogram to a file pointer. Deliberately a look-and-feel clone of Bill Pearson's excellent FASTA output. %simple show %arg fp - open file to print to (stdout works) h - histogram to print %% void PrintASCIIHistogram(Histogram * h,FILE * fp) { int units; int maxbar; int num; int i, idx; char buffer[81]; /* output line buffer */ int pos; /* position in output line buffer */ int lowbound, lowcount; /* cutoffs on the low side */ int highbound, highcount; /* cutoffs on the high side */ int emptybins = 3; /* Find out how we'll scale the histogram. * We have 59 characters to play with on a * standard 80-column terminal display: * leading "%5d %6d %6d|" occupies 20 chars. * Save the peak position, we'll use it later. */ maxbar = 0; for (i = h->lowscore - h->min; i <= h->highscore - h->min; i++) if (h->histogram[i] > maxbar) { maxbar = h->histogram[i]; /* max height */ lowbound = i + h->min; /* peak position */ } /* Truncate histogram display on both sides, ad hoc fashion. * Start from the peak; then move out until we see empty bins, * and stop. */ highbound = lowbound; /* start at peak position */ for (num = 0; lowbound > h->lowscore; lowbound--) { i = lowbound - h->min; if (h->histogram[i] > 0) { num = 0; continue; } /* reset */ if (++num == emptybins) { lowbound += emptybins; break; } /* stop */ } for (num = 0; highbound < h->highscore; highbound++) { i = highbound - h->min; if (h->histogram[i] > 0) { num = 0; continue; } /* reset */ if (++num == emptybins) { highbound -= emptybins; break; } /* stop */ } /* collect counts outside of bounds */ for (lowcount = 0, i = h->lowscore - h->min; i <= lowbound - h->min; i++) lowcount += h->histogram[i]; for (highcount = 0, i = h->highscore - h->min; i >= highbound - h->min; i--) highcount += h->histogram[i]; /* maxbar might need raised now; then set our units */ if (lowcount > maxbar) maxbar = lowcount; if (highcount > maxbar) maxbar = highcount; units = ((maxbar-1)/ 59) + 1; /* Print the histogram */ fprintf(fp, "%5s %6s %6s (one = represents %d sequences)\n", "score", "obs", "exp", units); fprintf(fp, "%5s %6s %6s\n", "-----", "---", "---"); buffer[80] = '\0'; buffer[79] = '\n'; for (i = h->lowscore; i <= h->highscore; i++) { memset(buffer, ' ', 79 * sizeof(char)); idx = i - h->min; /* Deal with special cases at edges */ if (i < lowbound) continue; else if (i > highbound) continue; else if (i == lowbound && i != h->lowscore) { sprintf(buffer, "<%4d %6d %6s|", i+1, lowcount, "-"); if (lowcount > 0) { num = 1+(lowcount-1) / units; if (num > 60) fatal("oops - more than 60 somethings in printing... "); for (pos = 20; num > 0; num--) buffer[pos++] = '='; } fputs(buffer, fp); continue; } else if (i == highbound && i != h->highscore) { sprintf(buffer, ">%4d %6d %6s|", i, highcount, "-"); if (highcount > 0) { num = 1+(highcount-1) / units; for (pos = 20; num > 0; num--) buffer[pos++] = '='; } fputs(buffer, fp); continue; } /* Deal with most cases */ if (h->fit_type != HISTFIT_NONE) sprintf(buffer, "%5d %6d %6d|", i, h->histogram[idx], (int) h->expect[idx]); else sprintf(buffer, "%5d %6d %6s|", i, h->histogram[idx], "-"); buffer[20] = ' '; /* sprintf writes a null char */ /* Mark the histogram bar for observed hits */ if (h->histogram[idx] > 0) { num = 1 + (h->histogram[idx]-1) / units; for (pos = 20; num > 0; num--) buffer[pos++] = '='; } /* Mark the theoretically expected value */ if (h->fit_type != HISTFIT_NONE && (int) h->expect[idx] > 0) { /* "corrected" line */ #ifdef SRE_REMOVED if (h->fit_type == HISTFIT_EVD) { pos = 20 + (int)(h->param[EVD_WONKA] * h->expect[idx] - 1) / units; if (pos >= 78) pos = 78; /* be careful of buffer bounds */ buffer[pos] = 'o'; } #endif /* true (uncorrected) line */ pos = 20 + (int)(h->expect[idx]-1) / units; if (pos >= 78) pos = 78; /* be careful of buffer bounds */ buffer[pos] = '*'; } /* Print the line */ fputs(buffer, fp); } /* Print details about the statistics */ switch (h->fit_type) { case HISTFIT_NONE: fprintf(fp, "\n\n%% No statistical fit available\n"); break; case HISTFIT_EVD: fprintf(fp, "\n\n%% Statistical details of theoretical EVD fit:\n"); fprintf(fp, " mu = %10.4f\n", h->param[EVD_MU]); fprintf(fp, " lambda = %10.4f\n", h->param[EVD_LAMBDA]); #ifdef SRE_REMOVED fprintf(fp, " fraction fit = %10.4f\n", h->param[EVD_WONKA]); #endif fprintf(fp, "chi-sq statistic = %10.4f\n", h->chisq); fprintf(fp, " P(chi-square) = %10.4g\n", h->chip); break; case HISTFIT_GAUSSIAN: fprintf(fp, "\n\n%% Statistical details of theoretical Gaussian fit:\n"); fprintf(fp, " mean = %10.4f\n", h->param[GAUSS_MEAN]); fprintf(fp, " sd = %10.4f\n", h->param[GAUSS_SD]); fprintf(fp, "chi-sq statistic = %10.4f\n", h->chisq); fprintf(fp, " P(chi-square) = %10.4g\n", h->chip); break; } return; } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Fit a score histogram to the extreme value distribution. Set the parameters lambda and mu in the histogram structure. Fill in the expected values in the histogram. Calculate a chi-square test as a measure of goodness of fit. This is the basic version of ExtremeValueFitHistogram(), in a nonrobust form: simple linear regression with no outlier pruning. Methods: Uses a linear regression fitting method [Collins88,Lawless82] %arg h histogram to fit %% void EVDBasicFit(Histogram * h) { float *d; /* distribution P(S < x) */ float *x; /* x-axis of P(Smin */ float slope, intercept; /* m,b fit from Linefit() */ float corr; /* correlation coeff of line fit, not used */ float lambda, mu; /* slope, intercept converted to EVD params */ /* Allocations for x, y axes * distribution d runs from min..max with indices 0..max-min * i.e. score - min = index into d, x, histogram, and expect */ hsize = h->highscore - h->lowscore + 1; d = (float *) ckalloc(sizeof(float) * hsize); x = (float *) ckalloc(sizeof(float) * hsize); for (idx = 0; idx < hsize; idx++) d[idx] = x[idx] = 0.; /* Calculate P(S < x) distribution from histogram. * note off-by-one of sc, because histogram bin contains scores between * x and x+1. */ sum = 0; for (sc = h->lowscore; sc <= h->highscore; sc++) { sum += h->histogram[sc - h->min]; d[sc - h->lowscore] = (float) sum / (float) h->total; x[sc - h->lowscore] = (float) (sc + 1); } /* Do a linear regression fit to the log[-log(P(Sx))] = -lambda * x + lambda * mu * so lambda = -m and mu = b/lambda */ /* convert y axis to log[-log(P(Slowscore; sc < h->highscore; sc++) d[sc - h->lowscore] = log(-1. * log(d[sc - h->lowscore])); /* do the linear regression */ Linefit(x, d, hsize-1, &intercept, &slope, &corr); /* calc mu, lambda */ lambda = -1. * slope; mu = intercept / lambda; /* Set the EVD parameters in the histogram; * pass 2 for additional lost degrees of freedom because we fit mu, lambda. */ ExtremeValueSetHistogram(h, mu, lambda, h->lowscore, h->highscore, 1.0, 2); free(x); free(d); return; } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Purpose: Fit a score histogram to the extreme value distribution. Set the parameters lambda and mu in the histogram structure. Calculate a chi-square test as a measure of goodness of fit. Methods: Uses a maximum likelihood method [Lawless82]. Lower outliers are removed by censoring the data below the peak. Upper outliers are removed iteratively using method described by [Mott92]. %simple fit_EVD %arg h histogram to fit censor TRUE to censor data left of the peak high_hint score cutoff; above this are real hits that arent fit return 1 if fit is judged to be valid else 0 if fit is invalid (too few seqs.) %% int ExtremeValueFitHistogram(Histogram * h, int censor, float high_hint) { float *x; /* array of EVD samples to fit */ int *y; /* histogram counts */ int n; /* number of observed samples */ int z; /* number of censored samples */ int hsize; /* size of histogram */ float lambda, mu; /* new estimates of lambda, mu */ int sc; /* loop index for score */ int lowbound; /* lower bound of fitted region*/ int highbound; /* upper bound of fitted region*/ int new_highbound; int iteration; /* Determine lower bound on fitted region; * if we're censoring the data, choose the peak of the histogram. * if we're not, then we take the whole histogram. */ lowbound = h->lowscore; if (censor) { int max = -1; for (sc = h->lowscore; sc <= h->highscore; sc++) if (h->histogram[sc - h->min] > max) { max = h->histogram[sc - h->min]; lowbound = sc; } } /* Determine initial upper bound on fitted region. */ highbound = MIN(high_hint, h->highscore); /* Now, iteratively converge on our lambda, mu: */ for (iteration = 0; iteration < 100; iteration++) { /* Construct x, y vectors. */ x = NULL; y = NULL; hsize = highbound - lowbound + 1; if (hsize < 5) { warn("On iteration %d, got %d bins, which is not fitable",iteration,hsize); goto FITFAILED; /* require at least 5 bins or we don't fit */ } x = ckalloc(sizeof(float) * hsize); y = ckalloc(sizeof(int) * hsize); if( x == NULL || y == NULL ) { warn("Out of temporary memory for evd fitting... exiting with error, though I'd worry about this"); return 0; } n = 0; for (sc = lowbound; sc <= highbound; sc++) { x[sc-lowbound] = (float) sc + 0.5; /* crude, but tests OK */ y[sc-lowbound] = h->histogram[sc - h->min]; n += h->histogram[sc - h->min]; } if (n < 100) { warn("On iteration %d, got only %d points, which is not fitable",iteration,n); goto FITFAILED; /* require fitting to at least 100 points */ } /* If we're censoring, estimate z, the number of censored guys * left of the bound. Our initial estimate is crudely that we're * missing e^-1 of the total distribution (which would be exact * if we censored exactly at mu; but we censored at the observed peak). * Subsequent estimates are more exact based on our current estimate of mu. */ if (censor) { if (iteration == 0) z = MIN(h->total-n, (int) (0.58198 * (float) n)); else { double psx; psx = EVDDistribution((float) lowbound, mu, lambda); z = MIN(h->total-n, (int) ((double) n * psx / (1. - psx))); } } /* Do an ML fit */ if (censor) { if (! EVDCensoredFit(x, y, hsize, z, (float) lowbound, &mu, &lambda)) { warn("On iteration %d, unable to make maxlikehood evd fit with censor",iteration); goto FITFAILED; } } else { if (! EVDMaxLikelyFit(x, y, hsize, &mu, &lambda)) { warn("On iteration %d, unable to make maxlikehood evd fit without censor",iteration); goto FITFAILED; } } /* Find the Eval = 1 point as a new highbound; * the total number of samples estimated to "belong" to the EVD is n+z */ new_highbound = (int) (mu - (log (-1. * log((double) (n+z-1) / (double)(n+z))) / lambda)); free(x); free(y); if (new_highbound >= highbound) break; highbound = new_highbound; } /* Set the histogram parameters; * - the wonka factor is n+z / h->total : e.g. that's the fraction of the * hits that we expect to match the EVD, others are generally lower * - we fit from lowbound to highbound; thus we lose 2 degrees of freedom * for fitting mu, lambda, but we get 1 back because we're unnormalized * in this interval, hence we pass 2-1 = 1 as ndegrees. * * Mon Jan 19 06:18:14 1998: wonka = 1.0, temporarily disabled. */ ExtremeValueSetHistogram(h, mu, lambda, lowbound, highbound, 1.0, 1); return 1; FITFAILED: UnfitHistogram(h); if (x != NULL) free(x); if (y != NULL) free(y); return 0; } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Instead of fitting the histogram to an EVD, simply set the EVD parameters from an external source. Note that the fudge factor "wonka" is used /only/ for prettification of expected/theoretical curves in PrintASCIIHistogram displays. %simple set_EVD %arg h the histogram to set mu mu location parameter lambda lambda scale parameter lowbound low bound of the histogram that was fit highbound high bound of histogram that was fit wonka fudge factor; fraction of hits estimated to be "EVD-like" ndegrees extra degrees of freedom to subtract in chi2 test: %% void ExtremeValueSetHistogram(Histogram * h, float mu, float lambda, float lowbound, float highbound, float wonka, int ndegrees) { int sc; int hsize, idx; int nbins; float delta; UnfitHistogram(h); h->fit_type = HISTFIT_EVD; h->param[EVD_LAMBDA] = lambda; h->param[EVD_MU] = mu; h->param[EVD_WONKA] = wonka; hsize = h->max - h->min + 1; h->expect = (float *) ckalloc(sizeof(float) * hsize); if( h->expect == NULL ) { fatal("Cannot make memory for expect thing... "); } for (idx = 0; idx < hsize; idx++) h->expect[idx] = 0.; /* Calculate the expected values for the histogram. */ for (sc = h->min; sc <= h->max; sc++) h->expect[sc - h->min] = ExtremeValueE((float)(sc), h->param[EVD_MU], h->param[EVD_LAMBDA], h->total) - ExtremeValueE((float)(sc+1), h->param[EVD_MU], h->param[EVD_LAMBDA], h->total); /* Calculate the goodness-of-fit (within whole region) */ h->chisq = 0.; nbins = 0; for (sc = lowbound; sc <= highbound; sc++) if (h->expect[sc-h->min] >= 5. && h->histogram[sc-h->min] >= 5) { delta = (float) h->histogram[sc-h->min] - h->expect[sc-h->min]; h->chisq += delta * delta / h->expect[sc-h->min]; nbins++; } /* Since we fit the whole histogram, there is at least * one constraint on chi-square: the normalization to h->total. */ if (nbins > 1 + ndegrees) h->chip = (float) IncompleteGamma((double)(nbins-1-ndegrees)/2., (double) h->chisq/2.); else h->chip = 0.; } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Fit a score histogram to a Gaussian distribution. Set the parameters mean and sd in the histogram structure, as well as a chi-squared test for goodness of fit. %simple fit_Gaussian %arg h histogram to fit high_hint score cutoff; above this are `real' hits that aren't fit return 1 if fit is judged to be valid else 0 if fit is invalid (too few seqs.) %% int GaussianFitHistogram(Histogram * h, float high_hint) { float sum; float sqsum; float delta; int sc; int nbins; int hsize, idx; /* Clear any previous fitting from the histogram. */ UnfitHistogram(h); /* Determine if we have enough hits to fit the histogram; * arbitrarily require 1000. */ if (h->total < 1000) { h->fit_type = HISTFIT_NONE; return 0; } /* Simplest algorithm for mean and sd; * no outlier detection yet (not even using high_hint) * * Magic 0.5 correction is because our histogram is for * scores between x and x+1; we estimate the expectation * (roughly) as x + 0.5. */ sum = sqsum = 0.; for (sc = h->lowscore; sc <= h->highscore; sc++) { delta = (float) sc + 0.5; sum += (float) h->histogram[sc-h->min] * delta; sqsum += (float) h->histogram[sc-h->min] * delta * delta; } h->fit_type = HISTFIT_GAUSSIAN; h->param[GAUSS_MEAN] = sum / (float) h->total; h->param[GAUSS_SD] = sqrt((sqsum - (sum*sum/(float)h->total)) / (float)(h->total-1)); /* Calculate the expected values for the histogram. * Note that the magic 0.5 correction appears again. * Calculating difference between distribution functions for Gaussian * would be correct but hard. */ hsize = h->max - h->min + 1; h->expect = (float *) ckalloc(sizeof(float) * hsize); if( h->expect == NULL ) { fatal("Unable to allocate expect space in histogram... sorry!"); } for (idx = 0; idx < hsize; idx++) h->expect[idx] = 0.; for (sc = h->min; sc <= h->max; sc++) { delta = (float) sc + 0.5 - h->param[GAUSS_MEAN]; h->expect[sc - h->min] = (float) h->total * ((1. / (h->param[GAUSS_SD] * sqrt(2.*3.14159))) * (exp(-1.* delta*delta / (2. * h->param[GAUSS_SD] * h->param[GAUSS_SD])))); } /* Calculate the goodness-of-fit (within region that was fitted) */ h->chisq = 0.; nbins = 0; for (sc = h->lowscore; sc <= h->highscore; sc++) if (h->expect[sc-h->min] >= 5. && h->histogram[sc-h->min] >= 5) { delta = (float) h->histogram[sc-h->min] - h->expect[sc-h->min]; h->chisq += delta * delta / h->expect[sc-h->min]; nbins++; } /* -1 d.f. for normalization; -2 d.f. for two free parameters */ if (nbins > 3) h->chip = (float) IncompleteGamma((double)(nbins-3)/2., (double) h->chisq/2.); else h->chip = 0.; return 1; } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Instead of fitting the histogram to a Gaussian, simply set the Gaussian parameters from an external source. %simple set_Gaussian %% void GaussianSetHistogram(Histogram * h, float mean, float sd) { int sc; int hsize, idx; int nbins; float delta; UnfitHistogram(h); h->fit_type = HISTFIT_GAUSSIAN; h->param[GAUSS_MEAN] = mean; h->param[GAUSS_SD] = sd; /* Calculate the expected values for the histogram. */ hsize = h->max - h->min + 1; h->expect = (float *) ckalloc(sizeof(float) * hsize); if( h->expect == NULL ) { fatal("Unable to allocate expect size in expected histogram..."); } for (idx = 0; idx < hsize; idx++) h->expect[idx] = 0.; /* Note: ideally we'd use the Gaussian distribution function * to find the histogram occupancy in the window sc..sc+1. * However, the distribution function is hard to calculate. * Instead, estimate the histogram by taking the density at sc+0.5. */ for (sc = h->min; sc <= h->max; sc++) { delta = ((float)sc + 0.5) - h->param[GAUSS_MEAN]; h->expect[sc - h->min] = (float) h->total * ((1. / (h->param[GAUSS_SD] * sqrt(2.*3.14159))) * (exp(-1.*delta*delta / (2. * h->param[GAUSS_SD] * h->param[GAUSS_SD])))); } /* Calculate the goodness-of-fit (within whole region) */ h->chisq = 0.; nbins = 0; for (sc = h->lowscore; sc <= h->highscore; sc++) if (h->expect[sc-h->min] >= 5. && h->histogram[sc-h->min] >= 5) { delta = (float) h->histogram[sc-h->min] - h->expect[sc-h->min]; h->chisq += delta * delta / h->expect[sc-h->min]; nbins++; } /* -1 d.f. for normalization */ if (nbins > 1) h->chip = (float) IncompleteGamma((double)(nbins-1)/2., (double) h->chisq/2.); else h->chip = 0.; } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Return the extreme value density P(S=x) at a given point x, for an EVD controlled by parameters mu and lambda. %% double EVDDensity(float x, float mu, float lambda) { return (lambda * exp(-1. * lambda * (x - mu) - exp(-1. * lambda * (x - mu)))); } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Returns the extreme value distribution P(S < x) evaluated at x, for an EVD controlled by parameters mu and lambda. %% double EVDDistribution(float x, float mu, float lambda) { return (exp(-1. * exp(-1. * lambda * (x - mu)))); } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Calculate P(S>x) according to an extreme value distribution, given x and the parameters of the distribution (characteristic value mu, decay constant lambda). %arg x score mu characteristic value of extreme value distribution lambda decay constant of extreme value distribution return P(S>x) %% double ExtremeValueP(float x, float mu, float lambda) { double y; /* a roundoff issue arises; use 1 - e^-x --> x for small x */ y = exp(-1. * lambda * (x - mu)); if (y < 1e-7) return y; else return (1.0 - exp(-1. * y)); } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Calculate P(S>x) in a database of size N, using P(S>x) for a single sequence, according to a Poisson distribution. %arg x score mu characteristic value of extreme value distribution lambda decay constant of extreme value distribution N number of trials (number of sequences) return P(S>x) for database of size N %% double ExtremeValueP2(float x, float mu, float lambda, int N) { double y; y = N * ExtremeValueP(x,mu,lambda); if (y < 1e-7) return y; else return (1.0 - exp(-1. * y)); } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Calculate E(S>x) in a database of size N, using P(S>x) for a single sequence: simply np. %arg x score mu characteristic value of extreme value distribution lambda decay constant of extreme value distribution N number of trials (number of sequences) return E(S>x) for database of size N %% double ExtremeValueE(float x, float mu, float lambda, int N) { return (double)N * ExtremeValueP(x,mu,lambda); } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Randomly sample an x from an EVD. Trivially done by the transformation method, since the distribution is analytical: x = mu - frac{log [ -log P(S= c lambda a lambda to test ret_f w RETURN: 4.2.2 evaluated at lambda ret_df w RETURN: first derivative of 4.2.2 evaluated at lambda %% void Lawless422(float *x, int *y, int n, int z, float c,float lambda, float *ret_f, float *ret_df) { double esum; /* \sum e^(-lambda xi) + z term */ double xesum; /* \sum xi e^(-lambda xi) + z term */ double xxesum; /* \sum xi^2 e^(-lambda xi) + z term */ double xsum; /* \sum xi (no z term) */ double mult; /* histogram count multiplier */ double total; /* total samples */ int i; esum = xesum = xsum = xxesum = total = 0.; for (i = 0; i < n; i++) { mult = (y == NULL) ? 1. : (double) y[i]; xsum += mult * x[i]; esum += mult * exp(-1. * lambda * x[i]); xesum += mult * x[i] * exp(-1. * lambda * x[i]); xxesum += mult * x[i] * x[i] * exp(-1. * lambda * x[i]); total += mult; } /* Add z terms for censored data */ esum += (double) z * exp(-1. * lambda * c); xesum += (double) z * c * exp(-1. * lambda * c); xxesum += (double) z * c * c * exp(-1. * lambda * c); *ret_f = 1./lambda - xsum / total + xesum / esum; *ret_df = ((xesum / esum) * (xesum / esum)) - (xxesum / esum) - (1. / (lambda * lambda)); return; } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Purpose: Given a list or a histogram of EVD-distributed samples, find maximum likelihood parameters lambda and mu. Algorithm: Uses approach described in [Lawless82]. Solves for lambda using Newton/Raphson iterations; then substitutes lambda into Lawless' equation 4.1.5 to get mu. Newton/Raphson algorithm developed from description in Numerical Recipes in C [Press88]. %arg x list of EVD distributed samples or x axis of histogram c NULL, or y-axis of histogram n number of samples, or number of histogram bins ret_mu w RETURN: ML estimate of mu ret_lambda w RETURN: ML estimate of lambda return 1 on success; 0 on any failure %% int EVDMaxLikelyFit(float *x, int *c, int n, float *ret_mu, float *ret_lambda) { float lambda, mu; float fx; /* f(x) */ float dfx; /* f'(x) */ double esum; /* \sum e^(-lambda xi) */ double mult; double total; float tol = 1e-5; int i; /* 1. Find an initial guess at lambda: linear regression here? */ lambda = 0.2; /* 2. Use Newton/Raphson to solve Lawless 4.1.6 and find ML lambda */ for (i = 0; i < 100; i++) { Lawless416(x, c, n, lambda, &fx, &dfx); if (fabs(fx) < tol) break; /* success */ lambda = lambda - fx / dfx; /* Newton/Raphson is simple */ if (lambda <= 0.) lambda = 0.001; /* but be a little careful */ } /* 2.5: If we did 100 iterations but didn't converge, Newton/Raphson failed. * Resort to a bisection search. Worse convergence speed * but guaranteed to converge (unlike Newton/Raphson). * We assume (!?) that fx is a monotonically decreasing function of x; * i.e. fx > 0 if we are left of the root, fx < 0 if we * are right of the root. */ if (i == 100) { float left, right, mid; info("EVD maxlik fit - Newton/Raphson failed; switchover to bisection"); /* First we need to bracket the root */ lambda = right = left = 0.2; Lawless416(x, c, n, lambda, &fx, &dfx); if (fx < 0.) { /* fix right; search left. */ do { left -= 0.1; if (left < 0.) { info("failed to bracket root"); return 0; } Lawless416(x, c, n, left, &fx, &dfx); } while (fx < 0.); } else { /* fix left; search right. */ do { right += 0.1; Lawless416(x, c, n, right, &fx, &dfx); if (right > 100.) { info("failed to bracket root"); return 0; } } while (fx > 0.); } /* now we bisection search in left/right interval */ for (i = 0; i < 100; i++) { mid = (left + right) / 2.; Lawless416(x, c, n, mid, &fx, &dfx); if (fabs(fx) < tol) break; /* success */ if (fx > 0.) left = mid; else right = mid; } if (i == 100) { warn("even the bisection search failed"); return 0; } lambda = mid; } /* 3. Substitute into Lawless 4.1.5 to find mu */ esum = 0.; for (i = 0; i < n; i++) { mult = (c == NULL) ? 1. : (double) c[i]; esum += mult * exp(-1 * lambda * x[i]); total += mult; } mu = -1. * log(esum / total) / lambda; *ret_lambda = lambda; *ret_mu = mu; return 1; } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Purpose: Given a /left-censored/ list or histogram of EVD-distributed samples, as well as the number of censored samples z and the censoring value c, find maximum likelihood parameters lambda and mu. Algorithm: Uses approach described in [Lawless82]. Solves for lambda using Newton/Raphson iterations; then substitutes lambda into Lawless' equation 4.2.3 to get mu. Newton/Raphson algorithm developed from description in Numerical Recipes in C [Press88]. %args x list of EVD distributed samples or x axis of histogram y NULL, or y axis of histogram n number of observed samples,or number of histogram bins z number of censored samples c censoring value (all x_i >= c) ret_mu w RETURN: ML estimate of mu ret_lambda w RETURN: ML estimate of lambda %% int EVDCensoredFit(float *x, int *y, int n, int z, float c,float *ret_mu, float *ret_lambda) { float lambda, mu; float fx; /* f(x) */ float dfx; /* f'(x) */ double esum; /* \sum e^(-lambda xi) */ double mult; double total; float tol = 1e-5; int i; /* 1. Find an initial guess at lambda: linear regression here? */ lambda = 0.2; /* 2. Use Newton/Raphson to solve Lawless 4.2.2 and find ML lambda */ for (i = 0; i < 100; i++) { Lawless422(x, y, n, z, c, lambda, &fx, &dfx); if (fabs(fx) < tol) break; /* success */ lambda = lambda - fx / dfx; /* Newton/Raphson is simple */ if (lambda <= 0.) lambda = 0.001; /* but be a little careful */ } /* 2.5: If we did 100 iterations but didn't converge, Newton/Raphson failed. * Resort to a bisection search. Worse convergence speed * but guaranteed to converge (unlike Newton/Raphson). * We assume (!?) that fx is a monotonically decreasing function of x; * i.e. fx > 0 if we are left of the root, fx < 0 if we * are right of the root. */ if (i == 100) { float left, right, mid; /* First we need to bracket the root */ info("EVDCensor fit: Newton/Raphson failed; switched to bisection"); lambda = right = left = 0.2; Lawless422(x, y, n, z, c, lambda, &fx, &dfx); if (fx < 0.) { /* fix right; search left. */ do { left -= 0.03; if (left < 0.) { info("failed to bracket root"); return 0; } Lawless422(x, y, n, z, c, left, &fx, &dfx); } while (fx < 0.); } else { /* fix left; search right. */ do { right += 0.1; Lawless422(x, y, n, z, c, left, &fx, &dfx); if (right > 100.) { info("failed to bracket root"); return 0; } } while (fx > 0.); } /* now we bisection search in left/right interval */ for (i = 0; i < 100; i++) { mid = (left + right) / 2.; Lawless422(x, y, n, z, c, left, &fx, &dfx); if (fabs(fx) < tol) break; /* success */ if (fx > 0.) left = mid; else right = mid; } if (i == 100) { info("even the bisection search failed"); return 0; } lambda = mid; } /* 3. Substitute into Lawless 4.2.3 to find mu */ esum = total = 0.; for (i = 0; i < n; i++) { mult = (y == NULL) ? 1. : (double) y[i]; esum += mult * exp(-1. * lambda * x[i]); total += mult; } esum += (double) z * exp(-1. * lambda * c); /* term from censored data */ mu = -1. * log(esum / total) / lambda; *ret_lambda = lambda; *ret_mu = mu; return 1; } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Given points x[0..N-1] and y[0..N-1], fit to a straight line y = a + bx. a, b, and the linear correlation coefficient r are filled in for return. %arg x x values of data y y values of data N number of data points ret_a w RETURN: intercept ret_b w RETURN: slope ret_r w RETURN: correlation coefficient return 1 on success, 0 on failure. %% int Linefit(float *x, float *y, int N, float *ret_a, float *ret_b, float *ret_r) { float xavg, yavg; float sxx, syy, sxy; int i; /* Calculate averages, xavg and yavg */ xavg = yavg = 0.0; for (i = 0; i < N; i++) { xavg += x[i]; yavg += y[i]; } xavg /= (float) N; yavg /= (float) N; sxx = syy = sxy = 0.0; for (i = 0; i < N; i++) { sxx += (x[i] - xavg) * (x[i] - xavg); syy += (y[i] - yavg) * (y[i] - xavg); sxy += (x[i] - xavg) * (y[i] - yavg); } *ret_b = sxy / sxx; *ret_a = yavg - xavg*(*ret_b); *ret_r = sxy / (sqrt(sxx) * sqrt(syy)); return 1; } #define RANGE 268435456 /* 2^28 */ #define DIV 16384 /* sqrt(RANGE) */ #define MULT 72530821 /* my/Cathy's birthdays, x21, x even (Knuth)*/ static int sre_reseed = 0; /* TRUE to reinit sre_random() */ static int sre_randseed = 666; /* default seed for sre_random() */ %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Purpose: Return a uniform deviate from 0.0 to 1.0. sre_randseed is a static variable, set by sre_srandom(). sre_reseed is a static flag raised by sre_srandom(), saying that we need to re-initialize. [0.0 <= x < 1.0] Uses a simple linear congruential generator with period 2^28. Based on discussion in Robert Sedgewick's _Algorithms in C_, Addison-Wesley, 1990. Requires that long int's have at least 32 bits. Reliable and portable, but slow. Benchmarks on wol, using IRIX cc and IRIX C library rand() and random(): sre_random(): 0.8 usec/call random(): 0.3 usec/call rand(): 0.3 usec/call %% float sre_random(void) { static long rnd; static int firsttime = 1; long high1, low1; long high2, low2; if (sre_reseed || firsttime) { sre_reseed = firsttime = 0; if (sre_randseed <= 0) sre_randseed = 666; /* seeds of zero break me */ high1 = sre_randseed / DIV; low1 = sre_randseed % DIV; high2 = MULT / DIV; low2 = MULT % DIV; rnd = (((high2*low1 + high1*low2) % DIV)*DIV + low1*low2) % RANGE; } high1 = rnd / DIV; low1 = rnd % DIV; high2 = MULT / DIV; low2 = MULT % DIV; rnd = (((high2*low1 + high1*low2) % DIV)*DIV + low1*low2) % RANGE; return ((float) rnd / (float) RANGE); } #undef RANGE #undef DIV #undef MULT %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Purpose: Returns 1 - P(a,x) where: P(a,x) = \frac{1}{\Gamma(a)} \int_{0}^{x} t^{a-1} e^{-t} dt = \frac{\gamma(a,x)}{\Gamma(a)} = 1 - \frac{\Gamma(a,x)}{\Gamma(a)} Used in a chi-squared test: for a X^2 statistic x with v degrees of freedom, call: p = IncompleteGamma(v/2., x/2.) to get the probability p that a chi-squared value greater than x could be obtained by chance even for a correct model. (i.e. p should be large, say 0.95 or more). Method: Based on ideas from Numerical Recipes in C, Press et al., Cambridge University Press, 1988. Args: a for instance, degrees of freedom / 2 [a > 0] x for instance, chi-squared statistic / 2 [x >= 0] return 1 - P(a,x). %% double IncompleteGamma(double a, double x) { int iter; /* iteration counter */ if (a <= 0.) fatal("IncompleteGamma(): a must be > 0"); if (x < 0.) fatal("IncompleteGamma(): x must be >= 0"); /* For x > a + 1 the following gives rapid convergence; * calculate 1 - P(a,x) = \frac{\Gamma(a,x)}{\Gamma(a)}: * use a continued fraction development for \Gamma(a,x). */ if (x > a+1) { double oldp; /* previous value of p */ double nu0, nu1; /* numerators for continued fraction calc */ double de0, de1; /* denominators for continued fraction calc */ nu0 = 0.; /* A_0 = 0 */ de0 = 1.; /* B_0 = 1 */ nu1 = 1.; /* A_1 = 1 */ de1 = x; /* B_1 = x */ oldp = nu1; for (iter = 1; iter < 100; iter++) { /* Continued fraction development: * set A_j = b_j A_j-1 + a_j A_j-2 * B_j = b_j B_j-1 + a_j B_j-2 * We start with A_2, B_2. */ /* j = even: a_j = iter-a, b_j = 1 */ /* A,B_j-2 are in nu0, de0; A,B_j-1 are in nu1,de1 */ nu0 = nu1 + ((double)iter - a) * nu0; de0 = de1 + ((double)iter - a) * de0; /* j = odd: a_j = iter, b_j = x */ /* A,B_j-2 are in nu1, de1; A,B_j-1 in nu0,de0 */ nu1 = x * nu0 + (double) iter * nu1; de1 = x * de0 + (double) iter * de1; /* rescale */ if (de1) { nu0 /= de1; de0 /= de1; nu1 /= de1; de1 = 1.; } /* check for convergence */ if (fabs((nu1-oldp)/nu1) < 1.e-7) return nu1 * exp(a * log(x) - x - Gammln(a)); oldp = nu1; } fatal("IncompleteGamma(): failed to converge using continued fraction approx"); } else /* x <= a+1 */ { double p; /* current sum */ double val; /* current value used in sum */ /* For x <= a+1 we use a convergent series instead: * P(a,x) = \frac{\gamma(a,x)}{\Gamma(a)}, * where * \gamma(a,x) = e^{-x}x^a \sum_{n=0}{\infty} \frac{\Gamma{a}}{\Gamma{a+1+n}} x^n * which looks appalling but the sum is in fact rearrangeable to * a simple series without the \Gamma functions: * = \frac{1}{a} + \frac{x}{a(a+1)} + \frac{x^2}{a(a+1)(a+2)} ... * and it's obvious that this should converge nicely for x <= a+1. */ p = val = 1. / a; for (iter = 1; iter < 10000; iter++) { val *= x / (a+(double)iter); p += val; if (fabs(val/p) < 1.e-7) return 1. - p * exp(a * log(x) - x - Gammln(a)); } fatal("IncompleteGamma(): failed to converge using series approx"); } /*NOTREACHED*/ return 0.; } %func This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Returns the natural log of the gamma function of x. x is > 0.0. Adapted from a public domain implementation in the NCBI core math library. Thanks to John Spouge and the NCBI. (According to the NCBI, that's Dr. John "Gammas Galore" Spouge to you, pal.) %% float Gammln(float x) { int i; double xx, tx; double tmp, value; static double cof[11] = { 4.694580336184385e+04, -1.560605207784446e+05, 2.065049568014106e+05, -1.388934775095388e+05, 5.031796415085709e+04, -9.601592329182778e+03, 8.785855930895250e+02, -3.155153906098611e+01, 2.908143421162229e-01, -2.319827630494973e-04, 1.251639670050933e-10 }; /* Protect against x=0. We see this in Dirichlet code, * for terms alpha = 0. This is a severe hack but it is effective * and safe. (due to GJM) */ if (x <= 0.0) return 999999.; xx = x - 1.0; tx = tmp = xx + 11.0; value = 1.0; for (i = 10; i >= 0; i--) /* sum least significant terms first */ { value += cof[i] / tmp; tmp -= 1.0; } value = log(value); tx += 0.5; value += 0.918938533 + (xx+0.5)*log(tx) - tx; return (float) value; } %} wise-2.4.1/src/dynlibsrc/histogram.xs0000644000175000001440000000354110670453712017212 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::Histogram void UnfitHistogram(h) Wise2_Histogram * h CODE: Wise2_UnfitHistogram(h); void add(h,sc) Wise2_Histogram * h float sc CODE: Wise2_AddToHistogram(h,sc); void show(h,fp) Wise2_Histogram * h FILE * fp CODE: Wise2_PrintASCIIHistogram(h,fp); void EVDBasicFit(h) Wise2_Histogram * h CODE: Wise2_EVDBasicFit(h); int fit_EVD(h,censor,high_hint) Wise2_Histogram * h int censor float high_hint CODE: RETVAL = Wise2_ExtremeValueFitHistogram(h,censor,high_hint); OUTPUT: RETVAL void set_EVD(h,mu,lambda,lowbound,highbound,wonka,ndegrees) Wise2_Histogram * h float mu float lambda float lowbound float highbound float wonka int ndegrees CODE: Wise2_ExtremeValueSetHistogram(h,mu,lambda,lowbound,highbound,wonka,ndegrees); int fit_Gaussian(h,high_hint) Wise2_Histogram * h float high_hint CODE: RETVAL = Wise2_GaussianFitHistogram(h,high_hint); OUTPUT: RETVAL void set_Gaussian(h,mean,sd) Wise2_Histogram * h float mean float sd CODE: Wise2_GaussianSetHistogram(h,mean,sd); double evalue(his,score) Wise2_Histogram * his double score CODE: RETVAL = Wise2_Evalue_from_Histogram(his,score); OUTPUT: RETVAL Wise2_Histogram * hard_link_Histogram(obj) Wise2_Histogram * obj CODE: RETVAL = Wise2_hard_link_Histogram(obj); OUTPUT: RETVAL Wise2_Histogram * alloc() CODE: RETVAL = Wise2_Histogram_alloc(); OUTPUT: RETVAL Wise2_Histogram * new(class) char * class PPCODE: Wise2_Histogram * out; out = Wise2_Histogram_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_Histogram * obj CODE: Wise2_free_Histogram(obj); MODULE = Wise2 PACKAGE = Wise2 Wise2_Histogram * new_Histogram(min,max,lumpsize) int min int max int lumpsize CODE: RETVAL = Wise2_new_Histogram(min,max,lumpsize); OUTPUT: RETVAL wise-2.4.1/src/dynlibsrc/testdb.c0000644000175000001440000000070407313404542016265 0ustar philippusers#include "sequencedb.h" int main(int argc,char ** argv) { SequenceDB * db; Sequence * seq; int i; int status; for(i=0;i<4;i++) { db = single_fasta_SequenceDB(argv[1]); for(seq = init_SequenceDB(db,&status);status != DB_RETURN_END;seq = reload_SequenceDB(seq,db,&status) ) fprintf(stdout,"Reload %d, Sequence %s\n",i,seq->name); close_SequenceDB(seq,db); fprintf(stdout,"Closed %d\n",i); } return 0; } wise-2.4.1/src/dynlibsrc/histogram_api.h0000644000175000001440000001311610670453712017637 0ustar philippusers /* Functions that create, manipulate or act on Histogram * * Wise2_UnfitHistogram * Wise2_AddToHistogram * Wise2_PrintASCIIHistogram * Wise2_EVDBasicFit * Wise2_ExtremeValueFitHistogram * Wise2_ExtremeValueSetHistogram * Wise2_GaussianFitHistogram * Wise2_GaussianSetHistogram * Wise2_Evalue_from_Histogram * Wise2_hard_link_Histogram * Wise2_Histogram_alloc * Wise2_free_Histogram [destructor] * */ /* Helper functions in the module * * Wise2_new_Histogram * /* API for object Histogram */ /* Function: Wise2_UnfitHistogram(h) * * Descrip: No Description * * Arg: h Undocumented argument [Wise2_Histogram *] * * Returns Undocumented return value [void] * */ void Wise2_UnfitHistogram( Wise2_Histogram * h); /* Function: Wise2_AddToHistogram(h,sc) * * Descrip: No Description * * Arg: h Undocumented argument [Wise2_Histogram *] * Arg: sc Undocumented argument [float] * * Returns Undocumented return value [void] * */ void Wise2_AddToHistogram( Wise2_Histogram * h,float sc); /* Function: Wise2_PrintASCIIHistogram(h,fp) * * Descrip: No Description * * Arg: h histogram to print [Wise2_Histogram *] * Arg: fp open file to print to (stdout works) [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_PrintASCIIHistogram( Wise2_Histogram * h,FILE * fp); /* Function: Wise2_EVDBasicFit(h) * * Descrip: No Description * * Arg: h histogram to fit [Wise2_Histogram *] * * Returns Undocumented return value [void] * */ void Wise2_EVDBasicFit( Wise2_Histogram * h); /* Function: Wise2_ExtremeValueFitHistogram(h,censor,high_hint) * * Descrip: No Description * * Arg: h histogram to fit [Wise2_Histogram *] * Arg: censor TRUE to censor data left of the peak [int] * Arg: high_hint score cutoff; above this are real hits that arent fit [float] * * Returns if fit is judged to be valid else 0 if fit is invalid (too few seqs.) [int] * */ int Wise2_ExtremeValueFitHistogram( Wise2_Histogram * h,int censor,float high_hint); /* Function: Wise2_ExtremeValueSetHistogram(h,mu,lambda,lowbound,highbound,wonka,ndegrees) * * Descrip: No Description * * Arg: h the histogram to set [Wise2_Histogram *] * Arg: mu mu location parameter [float] * Arg: lambda lambda scale parameter [float] * Arg: lowbound low bound of the histogram that was fit [float] * Arg: highbound high bound of histogram that was fit [float] * Arg: wonka fudge factor; fraction of hits estimated to be "EVD-like" [float] * Arg: ndegrees extra degrees of freedom to subtract in chi2 test: [int] * * Returns Undocumented return value [void] * */ void Wise2_ExtremeValueSetHistogram( Wise2_Histogram * h,float mu,float lambda,float lowbound,float highbound,float wonka,int ndegrees); /* Function: Wise2_GaussianFitHistogram(h,high_hint) * * Descrip: No Description * * Arg: h histogram to fit [Wise2_Histogram *] * Arg: high_hint score cutoff; above this are `real' hits that aren't fit [float] * * Returns if fit is judged to be valid else 0 if fit is invalid (too few seqs.) [int] * */ int Wise2_GaussianFitHistogram( Wise2_Histogram * h,float high_hint); /* Function: Wise2_GaussianSetHistogram(h,mean,sd) * * Descrip: No Description * * Arg: h Undocumented argument [Wise2_Histogram *] * Arg: mean Undocumented argument [float] * Arg: sd Undocumented argument [float] * * Returns Undocumented return value [void] * */ void Wise2_GaussianSetHistogram( Wise2_Histogram * h,float mean,float sd); /* Function: Wise2_Evalue_from_Histogram(his,score) * * Descrip: No Description * * Arg: his Histogram object [Wise2_Histogram *] * Arg: score score you want the evalue for [double] * * Returns Undocumented return value [double] * */ double Wise2_Evalue_from_Histogram( Wise2_Histogram * his,double score); /* Function: Wise2_hard_link_Histogram(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_Histogram *] * * Returns Undocumented return value [Wise2_Histogram *] * */ Wise2_Histogram * Wise2_hard_link_Histogram( Wise2_Histogram * obj); /* Function: Wise2_Histogram_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_Histogram *] * */ Wise2_Histogram * Wise2_Histogram_alloc(); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_Histogram(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_Histogram *] * * Returns Undocumented return value [Wise2_Histogram *] * */ Wise2_Histogram * Wise2_free_Histogram( Wise2_Histogram * obj); /* These functions are not associated with an object */ /* Function: Wise2_new_Histogram(min,max,lumpsize) * * Descrip: No Description * * Arg: min minimum score (integer) [int] * Arg: max maximum score (integer) [int] * Arg: lumpsize when reallocating histogram, the reallocation amount [int] * * Returns Undocumented return value [Wise2_Histogram *] * */ Wise2_Histogram * Wise2_new_Histogram( int min,int max,int lumpsize); wise-2.4.1/src/dynlibsrc/histogram_api.t0000644000175000001440000000006110670453712017646 0ustar philippuserstypedef struct Wise2_Histogram Wise2_Histogram; wise-2.4.1/src/dynlibsrc/cdnadb.pod0000644000175000001440000001634410670453712016565 0ustar philippusers=head1 NAME cdnadb module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item cDNADB =back =head1 DESCRIPTION =head2 Object cDNADB =over =item is_single_seq Type [boolean] Scalar No documentation =item done_forward Type [boolean] Scalar No documentation =item forward_only Type [boolean] Scalar No documentation =item forw Type [ComplexSequence *] Scalar No documentation =item rev Type [ComplexSequence *] Scalar No documentation =item sdb Type [SequenceDB *] Scalar No documentation =item current Type [Sequence *] Scalar No documentation =item cses Type [ComplexSequenceEvalSet *] Scalar No documentation =item error_handling Type [CdnaDBErrorType] Scalar No documentation =item error_tol Type [double] Scalar No documentation =back This object hold a database of cDNA sequences. You will probably use it in one of two ways 1 A sequence formatted database, which is provided by a /SequenceDB object is used to provide the raw sequences 2 A single cDNA sequence is used. In each case this database provides both the forward and reverse strands into the system. Notice that what is exported are /ComplexSequence objects, not cDNA dna, as this is what is generally needed. These are things with splice sites calculated etc. This is why for initialisation this needs a /ComplexSequenceEvalSet of the correct type. =head2 Member functions of cDNADB =over =item get_entry &Wise2::cDNADB::get_entry(cdnadb,de) Gets cDNA sequence out from the cDNADB using the information stored in dataentry Argument cdnadb [READ ] cDNA database [cDNADB *] Argument de [READ ] DataEntry information [DataEntry *] Return [UNKN ] Undocumented return value [cDNA *] =item hard_link_cDNADB &Wise2::cDNADB::hard_link_cDNADB(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [cDNADB *] Return [UNKN ] Undocumented return value [cDNADB *] =item alloc &Wise2::cDNADB::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [cDNADB *] =item set_is_single_seq &Wise2::cDNADB::set_is_single_seq(obj,is_single_seq) Replace member variable is_single_seq For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Argument is_single_seq [OWNER] New value of the variable [boolean] Return [SOFT ] member variable is_single_seq [boolean] =item is_single_seq &Wise2::cDNADB::is_single_seq(obj) Access member variable is_single_seq For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Return [SOFT ] member variable is_single_seq [boolean] =item set_done_forward &Wise2::cDNADB::set_done_forward(obj,done_forward) Replace member variable done_forward For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Argument done_forward [OWNER] New value of the variable [boolean] Return [SOFT ] member variable done_forward [boolean] =item done_forward &Wise2::cDNADB::done_forward(obj) Access member variable done_forward For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Return [SOFT ] member variable done_forward [boolean] =item set_forward_only &Wise2::cDNADB::set_forward_only(obj,forward_only) Replace member variable forward_only For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Argument forward_only [OWNER] New value of the variable [boolean] Return [SOFT ] member variable forward_only [boolean] =item forward_only &Wise2::cDNADB::forward_only(obj) Access member variable forward_only For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Return [SOFT ] member variable forward_only [boolean] =item set_forw &Wise2::cDNADB::set_forw(obj,forw) Replace member variable forw For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Argument forw [OWNER] New value of the variable [ComplexSequence *] Return [SOFT ] member variable forw [boolean] =item forw &Wise2::cDNADB::forw(obj) Access member variable forw For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Return [SOFT ] member variable forw [ComplexSequence *] =item set_rev &Wise2::cDNADB::set_rev(obj,rev) Replace member variable rev For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Argument rev [OWNER] New value of the variable [ComplexSequence *] Return [SOFT ] member variable rev [boolean] =item rev &Wise2::cDNADB::rev(obj) Access member variable rev For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Return [SOFT ] member variable rev [ComplexSequence *] =item set_sdb &Wise2::cDNADB::set_sdb(obj,sdb) Replace member variable sdb For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Argument sdb [OWNER] New value of the variable [SequenceDB *] Return [SOFT ] member variable sdb [boolean] =item sdb &Wise2::cDNADB::sdb(obj) Access member variable sdb For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Return [SOFT ] member variable sdb [SequenceDB *] =item set_current &Wise2::cDNADB::set_current(obj,current) Replace member variable current For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Argument current [OWNER] New value of the variable [Sequence *] Return [SOFT ] member variable current [boolean] =item current &Wise2::cDNADB::current(obj) Access member variable current For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Return [SOFT ] member variable current [Sequence *] =item set_cses &Wise2::cDNADB::set_cses(obj,cses) Replace member variable cses For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Argument cses [OWNER] New value of the variable [ComplexSequenceEvalSet *] Return [SOFT ] member variable cses [boolean] =item cses &Wise2::cDNADB::cses(obj) Access member variable cses For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNADB *] Return [SOFT ] member variable cses [ComplexSequenceEvalSet *] =back =over =item new_cDNADB_from_single_seq &Wise2::new_cDNADB_from_single_seq(seq) To make a new cDNA database from a single cDNA Sequence with a eval system Argument seq [UNKN ] sequence which as placed into cDNADB structure. [cDNA *] Return [UNKN ] Undocumented return value [cDNADB *] =item new_cDNADB &Wise2::new_cDNADB(seqdb) To make a new cDNA database Argument seqdb [READ ] sequence database [SequenceDB *] Return [UNKN ] Undocumented return value [cDNADB *] =back wise-2.4.1/src/dynlibsrc/cdnadb.tex0000644000175000001440000000573310670453712016603 0ustar philippusers\section{cdnadb} \label{module_cdnadb} This module contains the following objects \begin{itemize} \item \ref{object_cDNADB} cDNADB \item This module also contains some factory methods \end{itemize} \subsection{cdnadb factory methods} \subsubsection{new_cDNADB_from_single_seq} \begin{description} \item[External C] {\tt Wise2_new_cDNADB_from_single_seq (seq)} \item[Perl] {\tt &Wise2::new_cDNADB_from_single_seq (seq)} \end{description} Arguments \begin{description} \item[seq] [UNKN ] sequence which as placed into cDNADB structure. [cDNA *] \item[returns] [UNKN ] Undocumented return value [cDNADB *] \end{description} To make a new cDNA database from a single cDNA Sequence with a eval system \subsubsection{new_cDNADB} \begin{description} \item[External C] {\tt Wise2_new_cDNADB (seqdb)} \item[Perl] {\tt &Wise2::new_cDNADB (seqdb)} \end{description} Arguments \begin{description} \item[seqdb] [READ ] sequence database [SequenceDB *] \item[returns] [UNKN ] Undocumented return value [cDNADB *] \end{description} To make a new cDNA database \subsection{Object cDNADB} \label{object_cDNADB} The cDNADB object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{is_single_seq} Type [boolean : Scalar] No documentation \item{done_forward} Type [boolean : Scalar] No documentation \item{forward_only} Type [boolean : Scalar] No documentation \item{forw} Type [ComplexSequence * : Scalar] No documentation \item{rev} Type [ComplexSequence * : Scalar] No documentation \item{sdb} Type [SequenceDB * : Scalar] No documentation \item{current} Type [Sequence * : Scalar] No documentation \item{cses} Type [ComplexSequenceEvalSet * : Scalar] No documentation \item{error_handling} Type [CdnaDBErrorType : Scalar] No documentation \item{error_tol} Type [double : Scalar] No documentation \end{description} This object hold a database of cDNA sequences. You will probably use it in one of two ways 1 A sequence formatted database, which is provided by a /SequenceDB object is used to provide the raw sequences 2 A single cDNA sequence is used. In each case this database provides both the forward and reverse strands into the system. Notice that what is exported are /ComplexSequence objects, not cDNA dna, as this is what is generally needed. These are things with splice sites calculated etc. This is why for initialisation this needs a /ComplexSequenceEvalSet of the correct type. Member functions of cDNADB \subsubsection{get_cDNA_from_cDNADB} \begin{description} \item[External C] {\tt Wise2_get_cDNA_from_cDNADB (cdnadb,de)} \item[Perl] {\tt &Wise2::cDNADB::get_entry (cdnadb,de)} \item[Perl-OOP call] {\tt $obj->get_entry(de)} \end{description} Arguments \begin{description} \item[cdnadb] [READ ] cDNA database [cDNADB *] \item[de] [READ ] DataEntry information [DataEntry *] \item[returns] [UNKN ] Undocumented return value [cDNA *] \end{description} Gets cDNA sequence out from the cDNADB using the information stored in dataentry wise-2.4.1/src/dynlibsrc/makefile0000644000175000001440000001311010421421617016323 0ustar philippusers .SUFFIXES : .dy DYNGLIBOBJ = subseqhash.o \ intallocator.o \ proteinstreamedindex.o \ shadowseq.o \ shadowseqindex.o \ hsphandler.o \ hspscaninterface.o \ hsp2hitscan.o \ hsplookupscan.o \ hsplookupthreaded.o \ hspthreadeddb.o \ hspscanruntime.o \ hsptwohitscan.o \ proteinindexcons.o \ dnaindexcons.o \ staticseq.o DYNHELPEROBJ = packaln.o \ aln.o \ dnamatrix.o \ probability.o \ alnrange.o \ alnconvert.o \ basematrix.o \ shattermatrix.o \ matrixdebug.o \ dpenvelope.o \ dbsearchimpl.o \ dprunimpl.o \ complexsequence.o \ complexevalset.o \ complexconsensi.o \ sequence.o \ sequencestream.o \ seqalign.o \ hitlist.o \ hsp.o \ hspstream.o \ codon.o \ compmat.o \ codonmatrix.o \ codonmapper.o \ sequencedb.o \ hscore.o \ seqlookup.o \ arrayseqlookup.o \ genericindexresult.o \ linkedlist_lookpos.o \ singlenumberspace.o \ histogram.o \ searchstatinterface.o \ searchstatlookup.o \ proteindb.o \ protein.o \ pairbase.o \ pairbaseseq.o \ genomicdb.o \ randommodel.o \ randomdb.o \ genomic.o \ cdna.o \ cdnadb.o \ dna.o \ embl.o \ genomicregion.o \ gene.o \ transcript.o \ translation.o \ btcanvas.o \ asciibtcanvas.o \ dynlibcross.o CC = cc INCFLAGS = -I../base/ #CFLAGS = -Wall -g -pedantic -c -DUNIX -I../base/ CFLAGS = -Wall -pthread -g3 -DCOMPILE_VERBOSITY -DPTHREAD -O2 -c -DUNIX -I../base/ `glib-config --cflags` #CFLAGS = -Wall -g3 -pg -DPTHREAD -O2 -c -DUNIX -I../base/ `glib-config --cflags` #CFLAGS = -O2 -c -pthread -DUNIX -I../base/ `glib-config --cflags` #CFLAGS = -O -c -DUNIX -DNOERROR -I../base/ LFLAGS = -g -L../base/ -lm AR_OPTIONS = ru RANLIB_NEEDED = 0 # # Base library build - call wisebase # all : libdyna.a libdyna_glib.a libdyndb.a : $(DATABASEOBJ) ar $(AR_OPTIONS) libdyndb.a $? libdyna.a : $(DYNHELPEROBJ) ar $(AR_OPTIONS) libdyna.a $? -if test -x /bin/ranlib; then /bin/ranlib libdyna.a; else exit 0; fi -if test -x /usr/bin/ranlib; then /usr/bin/ranlib libdyna.a; else exit 0; fi libdyna_glib.a : $(DYNGLIBOBJ) ar $(AR_OPTIONS) libdyna_glib.a $(DYNGLIBOBJ) -if test -x /bin/ranlib; then /bin/ranlib libdyna_glib.a; else exit 0; fi -if test -x /usr/bin/ranlib; then /usr/bin/ranlib libdyna_glib.a; else exit 0; fi libline.a : $(INTER) ar $(AR_OPTIONS) libline.a $? # if ( $(RANLIB_NEEDED)) then ranlib libline.a; fi libprob.a : $(PROBOBJ) ar $(AR_OPTIONS) libprob.a $? init : dyc $(DFLAGS) *.dy # # # test_genomic : genomic.o test_genomic.o sequence.o codon.o $(CC) -o test_genomic test_genomic.o genomic.o sequence.o codon.o ../base/libwisebase.a -lm test_tree : tree.o test_tree.o $(CC) -o test_tree test_tree.o tree.o libdyna.a ../base/libwisebase.a -lm test_intallocator : intallocator.o test_intallocator.o $(CC) -o test_intallocator intallocator.o test_intallocator.o ../base/libwisebase.a -lm test_psi : test_psi.o proteinstreamedindex.o $(CC) -o test_psi test_psi.o proteinstreamedindex.o ./libdyna.a ../base/libwisebase.a -lm test_shadowindex : test_shadowindex.o shadowseqindex.o shadowseq.o libdyna.a $(CC) -g -o test_shadowindex test_shadowindex.o shadowseqindex.o shadowseq.o ./libdyna.a ../base/libwisebase.a -lm test_seqhash : test_seqhash.o subseqhash.o hsp.o hitlist.o hspscaninterface.o hsplookupscan.o libdyna.a $(CC) -g -o test_seqhash `glib-config --libs` test_seqhash.o subseqhash.o hsp.o hitlist.o hspscaninterface.o hsplookupscan.o libdyna.a ../base/libwisebase.a -lm test_hsp : test_hsp.o codon.o sequence.o hsp.o compmat.o probability.o $(CC) -g -o test_hsp test_hsp.o codon.o sequence.o hsp.o compmat.o probability.o ../base/libwisebase.a -lm `glib-config --libs` test_topscore : test_topscore.o codon.o sequence.o hsp.o compmat.o probability.o $(CC) -g -o test_topscore test_topscore.o codon.o sequence.o hsp.o compmat.o probability.o ../base/libwisebase.a -lm `glib-config --libs` testgendb : probability.o genomicdb.o genomic.o testgendb.o sequence.o codon.o sequencedb.o complexsequence.o complexevalset.o $(CC) -o testgendb probability.o genomicdb.o genomic.o testgendb.o sequence.o codon.o sequencedb.o complexsequence.o complexevalset.o ../base/libwisebase.a -lm testseqalign : seqalign.o testseqalign.o sequence.o codon.o $(CC) -o testseqalign testseqalign.o seqalign.o sequence.o codon.o ../base/libwisebase.a -lm testanc : libdyna.a $(CC) -o testanc ../models/testanc.o ../models/proteinsw.o ../models/abc.o ../models/pba.o ../models/sw_wrap.o libdyna.a ../base/libwisebase.a -lm testdb : testdb.o sequencedb.o sequence.o codon.o probability.o $(CC) -o testdb testdb.o sequencedb.o sequence.o codon.o probability.o ../base/libwisebase.a -lm testpdb : testpdb.o protein.o proteindb.o complexevalset.o complexsequence.o sequencedb.o sequence.o codon.o probability.o randomdb.o randommodel.o histogram.o $(CC) -o testpdb testpdb.o protein.o proteindb.o complexsequence.o sequencedb.o sequence.o codon.o probability.o randomdb.o randommodel.o complexevalset.o histogram.o ../base/libwisebase.a -lm testpb : testpairbase.o pairbase.o pairbaseseq.o sequence.o seqalign.o codon.o probability.o complexsequence.o complexevalset.o $(CC) -g -o testpb testpairbase.o pairbase.o pairbaseseq.o sequence.o codon.o seqalign.o probability.o complexsequence.o complexevalset.o ../base/libwisebase.a -lm .c.o : $(CC) $(CFLAGS) $(INCFLAGS) $? DFLAGS = -l -D -F -n Wise2_ -a _api.h -b _api.t -latex -perl .dy.c : dyc $(DFLAGS) $< .dy.o : dyc $(DFLAGS) $< $(CC) $(CFLAGS) $*.c # # pro2DNAmatrix.c pro2DNAmatrix.h : pro2DNAmatrix.dy # dy pro2DNAmatrix.dy test_randomdb : test_randomdb.o libdyna.a $(CC) -o test_randomdb test_randomdb.o libdyna.a -lwisebase -L../base -lm wise-2.4.1/src/dynlibsrc/pairbaseseq.c0000644000175000001440000002043210670453712017302 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "pairbaseseq.h" /* Function: ComplexSequence_from_PairBaseSeq(pbs,splice5,splice3) * * Descrip: Makes a ComplexSeq from a PairBaseSeq * * * Arg: pbs [UNKN ] Undocumented argument [PairBaseSeq *] * Arg: splice5 [UNKN ] Undocumented argument [ComplexSequenceEval *] * Arg: splice3 [UNKN ] Undocumented argument [ComplexSequenceEval *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ # line 54 "pairbaseseq.dy" ComplexSequence * ComplexSequence_from_PairBaseSeq(PairBaseSeq * pbs,ComplexSequenceEval * splice5,ComplexSequenceEval * splice3) { int i; int * poi; ComplexSequence * out; Sequence * rev; pairbase_type a; pairbase_type g; pairbase_type t; assert(pbs); assert(pbs->anchor); assert(splice5); assert(splice3); a = MAKE_PAIRBASE(BASE_A,BASE_A); g = MAKE_PAIRBASE(BASE_G,BASE_G); t = MAKE_PAIRBASE(BASE_T,BASE_T); rev = reverse_complement_Sequence(pbs->anchor); out = ComplexSequence_alloc(); if( out == NULL ) return NULL; /* fprintf(stderr,"Got %s as anchor\n",pbs->anchor->seq); */ out->datastore = (int *) ckcalloc((pbs->anchor->len+10)*PAIRBASE_CS_LENGTH,sizeof(int)); out->data = out->datastore + (10 * PAIRBASE_CS_LENGTH); out->depth = PAIRBASE_CS_LENGTH; for(i=0;i<10;i++) { out->datastore[(i*PAIRBASE_CS_LENGTH)+0] = 4; } for(i=0,poi = out->data;ianchor->len;i++,poi = next_ComplexSequence_data(out,poi)) { /* 0 is codon */ poi[PAIRBASE_CS_CODON] = codon_number_func(0,NULL,pbs->anchor->seq+i); /* 1 is paircodon */ poi[PAIRBASE_CS_PAIRCODON] = pairbase_codon_from_seq(pbs->seq+i-2); /* 2 is a pairbase */ poi[PAIRBASE_CS_PAIRBASE] = pbs->seq[i]; /* 3 is 5' SS */ if( i < splice5->left_window || i+splice5->right_window > pbs->anchor->len || pbs->seq[i] != g || pbs->seq[i+1] != t) { poi[PAIRBASE_CS_5SS] = splice5->outside_score; } else { poi[PAIRBASE_CS_5SS] = splice5->eval_func(splice5->data_type,splice5->data,pbs->anchor->seq+i); poi[PAIRBASE_CS_5SS] += splice5->eval_func(splice5->data_type,splice5->data,pbs->sa->seq[1]->seq+i); } /* 4 is 3' SS */ if( i < splice3->left_window || i+splice3->right_window > pbs->anchor->len || pbs->seq[i] != g || pbs->seq[i-1] != a ) { poi[PAIRBASE_CS_3SS] = splice3->outside_score; } else { poi[PAIRBASE_CS_3SS] = splice3->eval_func(splice3->data_type,splice3->data,pbs->anchor->seq+i); poi[PAIRBASE_CS_3SS] += splice3->eval_func(splice3->data_type,splice3->data,pbs->sa->seq[1]->seq+i); } /* 5 is reverse codon */ poi[PAIRBASE_RS_CODON] = reverse_codon(codon_number_func(0,NULL,pbs->anchor->seq+i)); /* 6 is reverse paircodon */ poi[PAIRBASE_RS_PAIRCODON] = reverse_pairbase_codon(pairbase_codon_from_seq(pbs->seq+i-2)); /* 7 is reverse pairbase */ poi[PAIRBASE_RS_PAIRBASE] = complement_pairbase(pbs->seq[i]); /* 8 is reverse 5'SS */ if( i < splice5->left_window || i+splice5->right_window > pbs->anchor->len ) { poi[PAIRBASE_RS_5SS] = splice5->outside_score; } else { poi[PAIRBASE_RS_5SS] = splice5->eval_func(splice5->data_type,splice5->data,rev->seq+rev->len-1-i); } /* 9 is reverse 3'SS */ if( i < splice3->left_window || i+splice3->right_window > pbs->anchor->len ) { poi[PAIRBASE_RS_3SS] = splice3->outside_score; } else { poi[PAIRBASE_RS_3SS] = splice3->eval_func(splice3->data_type,splice3->data,rev->seq+rev->len-1-i); } /* fprintf(stdout,"Position %d got %d %d \n",i,poi[PAIRBASE_RS_5SS],poi[PAIRBASE_RS_3SS]); */ } out->length = pbs->anchor->len; out->seq = hard_link_Sequence(pbs->anchor); free_Sequence(rev); return out; } /* Function: SeqAlign_from_PairBaseSeq(pbs) * * Descrip: Makes a SeqAlign from a PairBaseSeq * * * Arg: pbs [UNKN ] Undocumented argument [PairBaseSeq *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ # line 161 "pairbaseseq.dy" SeqAlign * SeqAlign_from_PairBaseSeq(PairBaseSeq * pbs) { SeqAlign * out; Sequence * a; Sequence * b; int i; assert(pbs); out = SeqAlign_alloc_len(2); a = Sequence_alloc_len(pbs->len); b = Sequence_alloc_len(pbs->len); add_SeqAlign(out,a); add_SeqAlign(out,b); for(i=0;ilen;i++) { a->seq[i] = char_from_base(anchor_base_from_pairbase(pbs->seq[i])); b->seq[i] = char_from_base(informant_base_from_pairbase(pbs->seq[i])); } a->seq[i] = b->seq[i] = '\0'; return out; } /* Function: new_PairBaseSeq_SeqAlign(al) * * Descrip: Makes a pairseq from a SeqAlign * * * Arg: al [UNKN ] Undocumented argument [SeqAlign *] * * Return [UNKN ] Undocumented return value [PairBaseSeq *] * */ # line 194 "pairbaseseq.dy" PairBaseSeq * new_PairBaseSeq_SeqAlign(SeqAlign * al) { PairBaseSeq * out; out = new_PairBaseSeq_strings(al->seq[0]->seq,al->seq[1]->seq); out->sa = hard_link_SeqAlign(al); return out; } /* Function: new_PairBaseSeq_strings(a,b) * * Descrip: Makes a pairseq from two strings * * * Arg: a [UNKN ] Undocumented argument [char *] * Arg: b [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [PairBaseSeq *] * */ # line 207 "pairbaseseq.dy" PairBaseSeq * new_PairBaseSeq_strings(char * a,char * b) { int i; int l; PairBaseSeq * out; Sequence * anchor; assert(a); assert(b); if( strlen(a) != strlen(b) ) { warn("Cannot build PairBaseSeq with different length strings %d %d",strlen(a),strlen(b)); return NULL; } l = strlen(a); out = PairBaseSeq_alloc(); out->seq = (pairbase_type *) calloc(l,sizeof(pairbase_type)); for(i=0;iseq[i] = MAKE_PAIRBASE(base_from_char(a[i]),base_from_char(b[i])); } anchor = new_Sequence_from_strings("anchor",a); out->anchor = anchor; out->len = l; return out; } # line 219 "pairbaseseq.c" /* Function: hard_link_PairBaseSeq(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PairBaseSeq *] * * Return [UNKN ] Undocumented return value [PairBaseSeq *] * */ PairBaseSeq * hard_link_PairBaseSeq(PairBaseSeq * obj) { if( obj == NULL ) { warn("Trying to hard link to a PairBaseSeq object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PairBaseSeq_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PairBaseSeq *] * */ PairBaseSeq * PairBaseSeq_alloc(void) { PairBaseSeq * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PairBaseSeq *) ckalloc (sizeof(PairBaseSeq))) == NULL) { warn("PairBaseSeq_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->seq = NULL; out->len = 0; out->anchor = NULL; out->sa = NULL; return out; } /* Function: free_PairBaseSeq(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PairBaseSeq *] * * Return [UNKN ] Undocumented return value [PairBaseSeq *] * */ PairBaseSeq * free_PairBaseSeq(PairBaseSeq * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PairBaseSeq obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->seq != NULL) ckfree(obj->seq); if( obj->anchor != NULL) free_Sequence(obj->anchor); if( obj->sa != NULL) free_SeqAlign(obj->sa); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/pairbaseseq.h0000644000175000001440000001262110670453712017310 0ustar philippusers#ifndef DYNAMITEpairbaseseqHEADERFILE #define DYNAMITEpairbaseseqHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "pairbase.h" #include "seqalign.h" #include "complexsequence.h" #include "complexevalset.h" #define PAIRBASE_CS_CODON 0 #define PAIRBASE_CS_PAIRCODON 1 #define PAIRBASE_CS_PAIRBASE 2 #define PAIRBASE_CS_5SS 3 #define PAIRBASE_CS_3SS 4 #define PAIRBASE_RS_CODON 5 #define PAIRBASE_RS_PAIRCODON 6 #define PAIRBASE_RS_PAIRBASE 7 #define PAIRBASE_RS_5SS 8 #define PAIRBASE_RS_3SS 9 #define PAIRBASE_CS_LENGTH 10 #define CSEQ_PAIR_CODON(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_CS_CODON]) #define CSEQ_PAIR_PAIRCODON(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_CS_PAIRCODON]) #define CSEQ_PAIR_PAIRBASE(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_CS_PAIRBASE]) #define CSEQ_PAIR_5SS(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_CS_5SS]) #define CSEQ_PAIR_3SS(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_CS_3SS]) #define CSEQ_REV_PAIR_CODON(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_RS_CODON]) #define CSEQ_REV_PAIR_PAIRCODON(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_RS_PAIRCODON]) #define CSEQ_REV_PAIR_PAIRBASE(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_RS_PAIRBASE]) #define CSEQ_REV_PAIR_5SS(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_RS_5SS]) #define CSEQ_REV_PAIR_3SS(cseq,index) (cseq->data[index*PAIRBASE_CS_LENGTH+PAIRBASE_RS_3SS]) struct Wise2_PairBaseSeq { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * seq; int len; Sequence * anchor; /* may not always be here */ SeqAlign * sa; /* may not always be here */ } ; /* PairBaseSeq defined */ #ifndef DYNAMITE_DEFINED_PairBaseSeq typedef struct Wise2_PairBaseSeq Wise2_PairBaseSeq; #define PairBaseSeq Wise2_PairBaseSeq #define DYNAMITE_DEFINED_PairBaseSeq #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: ComplexSequence_from_PairBaseSeq(pbs,splice5,splice3) * * Descrip: Makes a ComplexSeq from a PairBaseSeq * * * Arg: pbs [UNKN ] Undocumented argument [PairBaseSeq *] * Arg: splice5 [UNKN ] Undocumented argument [ComplexSequenceEval *] * Arg: splice3 [UNKN ] Undocumented argument [ComplexSequenceEval *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * Wise2_ComplexSequence_from_PairBaseSeq(PairBaseSeq * pbs,ComplexSequenceEval * splice5,ComplexSequenceEval * splice3); #define ComplexSequence_from_PairBaseSeq Wise2_ComplexSequence_from_PairBaseSeq /* Function: SeqAlign_from_PairBaseSeq(pbs) * * Descrip: Makes a SeqAlign from a PairBaseSeq * * * Arg: pbs [UNKN ] Undocumented argument [PairBaseSeq *] * * Return [UNKN ] Undocumented return value [SeqAlign *] * */ SeqAlign * Wise2_SeqAlign_from_PairBaseSeq(PairBaseSeq * pbs); #define SeqAlign_from_PairBaseSeq Wise2_SeqAlign_from_PairBaseSeq /* Function: new_PairBaseSeq_SeqAlign(al) * * Descrip: Makes a pairseq from a SeqAlign * * * Arg: al [UNKN ] Undocumented argument [SeqAlign *] * * Return [UNKN ] Undocumented return value [PairBaseSeq *] * */ PairBaseSeq * Wise2_new_PairBaseSeq_SeqAlign(SeqAlign * al); #define new_PairBaseSeq_SeqAlign Wise2_new_PairBaseSeq_SeqAlign /* Function: new_PairBaseSeq_strings(a,b) * * Descrip: Makes a pairseq from two strings * * * Arg: a [UNKN ] Undocumented argument [char *] * Arg: b [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [PairBaseSeq *] * */ PairBaseSeq * Wise2_new_PairBaseSeq_strings(char * a,char * b); #define new_PairBaseSeq_strings Wise2_new_PairBaseSeq_strings /* Function: hard_link_PairBaseSeq(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PairBaseSeq *] * * Return [UNKN ] Undocumented return value [PairBaseSeq *] * */ PairBaseSeq * Wise2_hard_link_PairBaseSeq(PairBaseSeq * obj); #define hard_link_PairBaseSeq Wise2_hard_link_PairBaseSeq /* Function: PairBaseSeq_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PairBaseSeq *] * */ PairBaseSeq * Wise2_PairBaseSeq_alloc(void); #define PairBaseSeq_alloc Wise2_PairBaseSeq_alloc /* Function: free_PairBaseSeq(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PairBaseSeq *] * * Return [UNKN ] Undocumented return value [PairBaseSeq *] * */ PairBaseSeq * Wise2_free_PairBaseSeq(PairBaseSeq * obj); #define free_PairBaseSeq Wise2_free_PairBaseSeq /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/proteindb.pod0000644000175000001440000001456510670453712017343 0ustar philippusers=head1 NAME proteindb module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item ProteinDB =back =head1 DESCRIPTION =head2 Object ProteinDB =over =item is_single_seq Type [boolean] Scalar No documentation =item is_random_db Type [boolean] Scalar No documentation =item single Type [ComplexSequence *] Scalar No documentation =item sdb Type [SequenceDB *] Scalar No documentation =item cses Type [ComplexSequenceEvalSet *] Scalar No documentation =item rnd Type [RandomProteinDB *] Scalar No documentation =item test_dna Type [boolean] Scalar No documentation =back A database of proteins. This takes either a single sequence or a sequence database and allows a method expecting protein complexsequences to loop over it. It also provides generic database indexing for this Horrible physical dependency in this generated by the random protein db requiring histogram and randommodel stuff. Yuk! =head2 Member functions of ProteinDB =over =item hard_link_ProteinDB &Wise2::ProteinDB::hard_link_ProteinDB(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [ProteinDB *] Return [UNKN ] Undocumented return value [ProteinDB *] =item alloc &Wise2::ProteinDB::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [ProteinDB *] =item set_is_single_seq &Wise2::ProteinDB::set_is_single_seq(obj,is_single_seq) Replace member variable is_single_seq For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Argument is_single_seq [OWNER] New value of the variable [boolean] Return [SOFT ] member variable is_single_seq [boolean] =item is_single_seq &Wise2::ProteinDB::is_single_seq(obj) Access member variable is_single_seq For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Return [SOFT ] member variable is_single_seq [boolean] =item set_is_random_db &Wise2::ProteinDB::set_is_random_db(obj,is_random_db) Replace member variable is_random_db For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Argument is_random_db [OWNER] New value of the variable [boolean] Return [SOFT ] member variable is_random_db [boolean] =item is_random_db &Wise2::ProteinDB::is_random_db(obj) Access member variable is_random_db For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Return [SOFT ] member variable is_random_db [boolean] =item set_single &Wise2::ProteinDB::set_single(obj,single) Replace member variable single For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Argument single [OWNER] New value of the variable [ComplexSequence *] Return [SOFT ] member variable single [boolean] =item single &Wise2::ProteinDB::single(obj) Access member variable single For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Return [SOFT ] member variable single [ComplexSequence *] =item set_sdb &Wise2::ProteinDB::set_sdb(obj,sdb) Replace member variable sdb For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Argument sdb [OWNER] New value of the variable [SequenceDB *] Return [SOFT ] member variable sdb [boolean] =item sdb &Wise2::ProteinDB::sdb(obj) Access member variable sdb For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Return [SOFT ] member variable sdb [SequenceDB *] =item set_cses &Wise2::ProteinDB::set_cses(obj,cses) Replace member variable cses For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Argument cses [OWNER] New value of the variable [ComplexSequenceEvalSet *] Return [SOFT ] member variable cses [boolean] =item cses &Wise2::ProteinDB::cses(obj) Access member variable cses For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Return [SOFT ] member variable cses [ComplexSequenceEvalSet *] =item set_rnd &Wise2::ProteinDB::set_rnd(obj,rnd) Replace member variable rnd For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Argument rnd [OWNER] New value of the variable [RandomProteinDB *] Return [SOFT ] member variable rnd [boolean] =item rnd &Wise2::ProteinDB::rnd(obj) Access member variable rnd For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Return [SOFT ] member variable rnd [RandomProteinDB *] =item set_test_dna &Wise2::ProteinDB::set_test_dna(obj,test_dna) Replace member variable test_dna For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Argument test_dna [OWNER] New value of the variable [boolean] Return [SOFT ] member variable test_dna [boolean] =item test_dna &Wise2::ProteinDB::test_dna(obj) Access member variable test_dna For use principly by API functions Argument obj [UNKN ] Object holding the variable [ProteinDB *] Return [SOFT ] member variable test_dna [boolean] =back =over =item new_ProteinDB_from_single_seq &Wise2::new_ProteinDB_from_single_seq(seq) To make a new protein database from a single Sequence with default amino acid mapping Argument seq [UNKN ] sequence which as placed into ProteinDB structure. [Sequence *] Return [UNKN ] Undocumented return value [ProteinDB *] =item single_fasta_ProteinDB &Wise2::single_fasta_ProteinDB(filename) pre-packed single fasta protein database Argument filename [UNKN ] name of fasta file [char *] Return [UNKN ] Undocumented return value [ProteinDB *] =item new_ProteinDB &Wise2::new_ProteinDB(seqdb,cses) To make a new protein database Argument seqdb [UNKN ] sequence database [SequenceDB *] Argument cses [UNKN ] protein evaluation set [ComplexSequenceEvalSet *] Return [UNKN ] Undocumented return value [ProteinDB *] =back wise-2.4.1/src/dynlibsrc/proteindb.tex0000644000175000001440000000506710670453712017356 0ustar philippusers\section{proteindb} \label{module_proteindb} This module contains the following objects \begin{itemize} \item \ref{object_ProteinDB} ProteinDB \item This module also contains some factory methods \end{itemize} \subsection{proteindb factory methods} \subsubsection{new_ProteinDB_from_single_seq} \begin{description} \item[External C] {\tt Wise2_new_ProteinDB_from_single_seq (seq)} \item[Perl] {\tt &Wise2::new_ProteinDB_from_single_seq (seq)} \end{description} Arguments \begin{description} \item[seq] [UNKN ] sequence which as placed into ProteinDB structure. [Sequence *] \item[returns] [UNKN ] Undocumented return value [ProteinDB *] \end{description} To make a new protein database from a single Sequence with default amino acid mapping \subsubsection{single_fasta_ProteinDB} \begin{description} \item[External C] {\tt Wise2_single_fasta_ProteinDB (filename)} \item[Perl] {\tt &Wise2::single_fasta_ProteinDB (filename)} \end{description} Arguments \begin{description} \item[filename] [UNKN ] name of fasta file [char *] \item[returns] [UNKN ] Undocumented return value [ProteinDB *] \end{description} pre-packed single fasta protein database \subsubsection{new_ProteinDB} \begin{description} \item[External C] {\tt Wise2_new_ProteinDB (seqdb,cses)} \item[Perl] {\tt &Wise2::new_ProteinDB (seqdb,cses)} \end{description} Arguments \begin{description} \item[seqdb] [UNKN ] sequence database [SequenceDB *] \item[cses] [UNKN ] protein evaluation set [ComplexSequenceEvalSet *] \item[returns] [UNKN ] Undocumented return value [ProteinDB *] \end{description} To make a new protein database \subsection{Object ProteinDB} \label{object_ProteinDB} The ProteinDB object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{is_single_seq} Type [boolean : Scalar] No documentation \item{is_random_db} Type [boolean : Scalar] No documentation \item{single} Type [ComplexSequence * : Scalar] No documentation \item{sdb} Type [SequenceDB * : Scalar] No documentation \item{cses} Type [ComplexSequenceEvalSet * : Scalar] No documentation \item{rnd} Type [RandomProteinDB * : Scalar] No documentation \item{test_dna} Type [boolean : Scalar] No documentation \end{description} A database of proteins. This takes either a single sequence or a sequence database and allows a method expecting protein complexsequences to loop over it. It also provides generic database indexing for this Horrible physical dependency in this generated by the random protein db requiring histogram and randommodel stuff. Yuk! Member functions of ProteinDB wise-2.4.1/src/dynlibsrc/searchstatinterface.c0000644000175000001440000000542110670453712021026 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "searchstatinterface.h" # line 6 "searchstatinterface.c" /* Function: hard_link_SearchStatInterface(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SearchStatInterface *] * * Return [UNKN ] Undocumented return value [SearchStatInterface *] * */ SearchStatInterface * hard_link_SearchStatInterface(SearchStatInterface * obj) { if( obj == NULL ) { warn("Trying to hard link to a SearchStatInterface object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SearchStatInterface_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SearchStatInterface *] * */ SearchStatInterface * SearchStatInterface_alloc(void) { SearchStatInterface * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SearchStatInterface *) ckalloc (sizeof(SearchStatInterface))) == NULL) { warn("SearchStatInterface_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->calc_evalue = NULL; out->calc_bits = NULL; out->attribution = NULL; out->free_data = NULL; return out; } /* Function: free_SearchStatInterface(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SearchStatInterface *] * * Return [UNKN ] Undocumented return value [SearchStatInterface *] * */ SearchStatInterface * free_SearchStatInterface(SearchStatInterface * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SearchStatInterface obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->calc_evalue is a function pointer */ /* obj->calc_bits is a function pointer */ /* obj->attribution is a function pointer */ /* obj->free_data is a function pointer */ /* obj->data is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/searchstatinterface.h0000644000175000001440000000554410670453712021041 0ustar philippusers#ifndef DYNAMITEsearchstatinterfaceHEADERFILE #define DYNAMITEsearchstatinterfaceHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "sequence.h" /* Object SearchStatInterface * * Descrip: SearchStatInterface converts raw scores into both * bit score and evalues. Both must be supplied. The * function signatures are query_length,target_length,raw_score * * */ struct Wise2_SearchStatInterface { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif double (*calc_evalue)(void *,Sequence*,Sequence*,int,int); double (*calc_bits)(void *,int,int,int); char* (*attribution)(void *); void (*free_data)(void *); void * data; } ; /* SearchStatInterface defined */ #ifndef DYNAMITE_DEFINED_SearchStatInterface typedef struct Wise2_SearchStatInterface Wise2_SearchStatInterface; #define SearchStatInterface Wise2_SearchStatInterface #define DYNAMITE_DEFINED_SearchStatInterface #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: hard_link_SearchStatInterface(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SearchStatInterface *] * * Return [UNKN ] Undocumented return value [SearchStatInterface *] * */ SearchStatInterface * Wise2_hard_link_SearchStatInterface(SearchStatInterface * obj); #define hard_link_SearchStatInterface Wise2_hard_link_SearchStatInterface /* Function: SearchStatInterface_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SearchStatInterface *] * */ SearchStatInterface * Wise2_SearchStatInterface_alloc(void); #define SearchStatInterface_alloc Wise2_SearchStatInterface_alloc /* Function: free_SearchStatInterface(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SearchStatInterface *] * * Return [UNKN ] Undocumented return value [SearchStatInterface *] * */ SearchStatInterface * Wise2_free_SearchStatInterface(SearchStatInterface * obj); #define free_SearchStatInterface Wise2_free_SearchStatInterface /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/complexsequence.pod0000644000175000001440000001605710670453712020553 0ustar philippusers=head1 NAME complexsequence module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item ComplexSequence =item ComplexSequenceEvalSet =back =head1 DESCRIPTION =head2 Object ComplexSequence =over =item type Type [int] Scalar No documentation =item seq Type [Sequence *] Scalar No documentation =item data Type [int *] Scalar No documentation =item datastore Type [int *] Scalar No documentation =item depth Type [int] Scalar No documentation =item length Type [int] Scalar No documentation =item creator Type [ComplexSequenceEvalSet *] Scalar what made it =back A ComplexSequence is an abstraction of a Sequence which can be handily made using ComplexSequenceEval functions and is efficiently laid out in memory. =head2 Member functions of ComplexSequence =over =item hard_link_ComplexSequence &Wise2::ComplexSequence::hard_link_ComplexSequence(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [ComplexSequence *] Return [UNKN ] Undocumented return value [ComplexSequence *] =item alloc &Wise2::ComplexSequence::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [ComplexSequence *] =item set_type &Wise2::ComplexSequence::set_type(obj,type) Replace member variable type For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequence *] Argument type [OWNER] New value of the variable [int] Return [SOFT ] member variable type [boolean] =item type &Wise2::ComplexSequence::type(obj) Access member variable type For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequence *] Return [SOFT ] member variable type [int] =item set_seq &Wise2::ComplexSequence::set_seq(obj,seq) Replace member variable seq For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequence *] Argument seq [OWNER] New value of the variable [Sequence *] Return [SOFT ] member variable seq [boolean] =item seq &Wise2::ComplexSequence::seq(obj) Access member variable seq For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequence *] Return [SOFT ] member variable seq [Sequence *] =back =head2 Object ComplexSequenceEvalSet =over =item type Type [int] Scalar No documentation =item has_been_prepared Type [boolean] Scalar No documentation =item left_window Type [int] Scalar overall sequence eval =item right_window Type [int] Scalar overall sequence eval =item left_lookback Type [int] Scalar overall sequence eval =item cse Type [ComplexSequenceEval **] List No documentation =back This object holds a collection of ComplexSequenceEvals. Its role is to define the sequence specific parts of a dynamic programming algorithm as computable functions. Ideally you should use pre-made ComplexSequenceEvalSets as it will save you alot of grief =head2 Member functions of ComplexSequenceEvalSet =over =item hard_link_ComplexSequenceEvalSet &Wise2::ComplexSequenceEvalSet::hard_link_ComplexSequenceEvalSet(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [ComplexSequenceEvalSet *] Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] =item ComplexSequenceEvalSet_alloc_std &Wise2::ComplexSequenceEvalSet::ComplexSequenceEvalSet_alloc_std(void) Equivalent to ComplexSequenceEvalSet_alloc_len(ComplexSequenceEvalSetLISTLENGTH) Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] =item set_type &Wise2::ComplexSequenceEvalSet::set_type(obj,type) Replace member variable type For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] Argument type [OWNER] New value of the variable [int] Return [SOFT ] member variable type [boolean] =item type &Wise2::ComplexSequenceEvalSet::type(obj) Access member variable type For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] Return [SOFT ] member variable type [int] =item set_has_been_prepared &Wise2::ComplexSequenceEvalSet::set_has_been_prepared(obj,has_been_prepared) Replace member variable has_been_prepared For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] Argument has_been_prepared [OWNER] New value of the variable [boolean] Return [SOFT ] member variable has_been_prepared [boolean] =item has_been_prepared &Wise2::ComplexSequenceEvalSet::has_been_prepared(obj) Access member variable has_been_prepared For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] Return [SOFT ] member variable has_been_prepared [boolean] =item set_left_window &Wise2::ComplexSequenceEvalSet::set_left_window(obj,left_window) Replace member variable left_window For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] Argument left_window [OWNER] New value of the variable [int] Return [SOFT ] member variable left_window [boolean] =item left_window &Wise2::ComplexSequenceEvalSet::left_window(obj) Access member variable left_window For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] Return [SOFT ] member variable left_window [int] =item set_right_window &Wise2::ComplexSequenceEvalSet::set_right_window(obj,right_window) Replace member variable right_window For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] Argument right_window [OWNER] New value of the variable [int] Return [SOFT ] member variable right_window [boolean] =item right_window &Wise2::ComplexSequenceEvalSet::right_window(obj) Access member variable right_window For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] Return [SOFT ] member variable right_window [int] =item set_left_lookback &Wise2::ComplexSequenceEvalSet::set_left_lookback(obj,left_lookback) Replace member variable left_lookback For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] Argument left_lookback [OWNER] New value of the variable [int] Return [SOFT ] member variable left_lookback [boolean] =item left_lookback &Wise2::ComplexSequenceEvalSet::left_lookback(obj) Access member variable left_lookback For use principly by API functions Argument obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] Return [SOFT ] member variable left_lookback [int] =back wise-2.4.1/src/dynlibsrc/complexsequence.tex0000644000175000001440000000366410670453712020571 0ustar philippusers\section{complexsequence} \label{module_complexsequence} This module contains the following objects \begin{itemize} \item \ref{object_ComplexSequence} ComplexSequence \item \ref{object_ComplexSequenceEvalSet} ComplexSequenceEvalSet \end{itemize} \subsection{Object ComplexSequence} \label{object_ComplexSequence} The ComplexSequence object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{type} Type [int : Scalar] No documentation \item{seq} Type [Sequence * : Scalar] No documentation \item{data} Type [int * : Scalar] No documentation \item{datastore} Type [int * : Scalar] No documentation \item{depth} Type [int : Scalar] No documentation \item{length} Type [int : Scalar] No documentation \item{creator} Type [ComplexSequenceEvalSet * : Scalar] what made it \end{description} A ComplexSequence is an abstraction of a Sequence which can be handily made using ComplexSequenceEval functions and is efficiently laid out in memory. Member functions of ComplexSequence \subsection{Object ComplexSequenceEvalSet} \label{object_ComplexSequenceEvalSet} The ComplexSequenceEvalSet object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{type} Type [int : Scalar] No documentation \item{has_been_prepared} Type [boolean : Scalar] No documentation \item{left_window} Type [int : Scalar] overall sequence eval \item{right_window} Type [int : Scalar] overall sequence eval \item{left_lookback} Type [int : Scalar] overall sequence eval \item{cse} Type [ComplexSequenceEval ** : List] No documentation \end{description} This object holds a collection of ComplexSequenceEvals. Its role is to define the sequence specific parts of a dynamic programming algorithm as computable functions. Ideally you should use pre-made ComplexSequenceEvalSets as it will save you alot of grief Member functions of ComplexSequenceEvalSet wise-2.4.1/src/dynlibsrc/translation.pod0000644000175000001440000001012110670453713017674 0ustar philippusers=head1 NAME translation module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item Translation =back =head1 DESCRIPTION =head2 Object Translation =over =item start Type [int] Scalar No documentation =item end Type [int] Scalar No documentation =item parent Type [Transcript *] Scalar No documentation =item protein Type [Protein *] Scalar No documentation =back Translation represents a single translation from a cDNA. Although most cDNAs will have one translation, this does allow us to deal with alternative translation points etc. As with Transcript and Gene before it, the translation does not necessarily have any sequence in it. When sequence is asked for by get_Protein_from_Translation() the cache is checked, and if it is empty, then the transcript's DNA is called for, and the converted into the translation with appropiate start and stops. Of course, get_Protein_from_Translation can potentially trigger the construction of an entire gene upstairs, but that need not worry you here =head2 Member functions of Translation =over =item get_Protein_from_Translation &Wise2::Translation::get_Protein_from_Translation(ts,ct) Gets the protein Argument ts [UNKN ] translation [Translation *] Argument ct [UNKN ] codon table to use [CodonTable *] Return [SOFT ] Protein sequence [Protein *] =item hard_link_Translation &Wise2::Translation::hard_link_Translation(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [Translation *] Return [UNKN ] Undocumented return value [Translation *] =item alloc &Wise2::Translation::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [Translation *] =item set_start &Wise2::Translation::set_start(obj,start) Replace member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [Translation *] Argument start [OWNER] New value of the variable [int] Return [SOFT ] member variable start [boolean] =item start &Wise2::Translation::start(obj) Access member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [Translation *] Return [SOFT ] member variable start [int] =item set_end &Wise2::Translation::set_end(obj,end) Replace member variable end For use principly by API functions Argument obj [UNKN ] Object holding the variable [Translation *] Argument end [OWNER] New value of the variable [int] Return [SOFT ] member variable end [boolean] =item end &Wise2::Translation::end(obj) Access member variable end For use principly by API functions Argument obj [UNKN ] Object holding the variable [Translation *] Return [SOFT ] member variable end [int] =item set_parent &Wise2::Translation::set_parent(obj,parent) Replace member variable parent For use principly by API functions Argument obj [UNKN ] Object holding the variable [Translation *] Argument parent [OWNER] New value of the variable [Transcript *] Return [SOFT ] member variable parent [boolean] =item parent &Wise2::Translation::parent(obj) Access member variable parent For use principly by API functions Argument obj [UNKN ] Object holding the variable [Translation *] Return [SOFT ] member variable parent [Transcript *] =item set_protein &Wise2::Translation::set_protein(obj,protein) Replace member variable protein For use principly by API functions Argument obj [UNKN ] Object holding the variable [Translation *] Argument protein [OWNER] New value of the variable [Protein *] Return [SOFT ] member variable protein [boolean] =item protein &Wise2::Translation::protein(obj) Access member variable protein For use principly by API functions Argument obj [UNKN ] Object holding the variable [Translation *] Return [SOFT ] member variable protein [Protein *] =back wise-2.4.1/src/dynlibsrc/translation.tex0000644000175000001440000000336610670453713017727 0ustar philippusers\section{translation} \label{module_translation} This module contains the following objects \begin{itemize} \item \ref{object_Translation} Translation \end{itemize} \subsection{Object Translation} \label{object_Translation} The Translation object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{start} Type [int : Scalar] No documentation \item{end} Type [int : Scalar] No documentation \item{parent} Type [Transcript * : Scalar] No documentation \item{protein} Type [Protein * : Scalar] No documentation \end{description} Translation represents a single translation from a cDNA. Although most cDNAs will have one translation, this does allow us to deal with alternative translation points etc. As with Transcript and Gene before it, the translation does not necessarily have any sequence in it. When sequence is asked for by get_Protein_from_Translation() the cache is checked, and if it is empty, then the transcript's DNA is called for, and the converted into the translation with appropiate start and stops. Of course, get_Protein_from_Translation can potentially trigger the construction of an entire gene upstairs, but that need not worry you here Member functions of Translation \subsubsection{get_Protein_from_Translation} \begin{description} \item[External C] {\tt Wise2_get_Protein_from_Translation (ts,ct)} \item[Perl] {\tt &Wise2::Translation::get_Protein_from_Translation (ts,ct)} \item[Perl-OOP call] {\tt $obj->get_Protein_from_Translation(ct)} \end{description} Arguments \begin{description} \item[ts] [UNKN ] translation [Translation *] \item[ct] [UNKN ] codon table to use [CodonTable *] \item[returns] [SOFT ] Protein sequence [Protein *] \end{description} Gets the protein wise-2.4.1/src/dynlibsrc/sequence_codon.typemap0000644000175000001440000000000010670453713021220 0ustar philippuserswise-2.4.1/src/dynlibsrc/protein.pod0000644000175000001440000000410410670453712017021 0ustar philippusers=head1 NAME protein module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item Protein =back =head1 DESCRIPTION =head2 Object Protein =over =item baseseq Type [Sequence *] Scalar No documentation =back The protein object is a typed example of a sequence object. It does nothing more than a sequence object but is typed =head2 Member functions of Protein =over =item Protein_from_Sequence &Wise2::Protein::Protein_from_Sequence(seq) makes a new protein from a Sequence. It owns the Sequence memory, ie will attempt a /free_Sequence on the structure when /free_Protein is called If you want to give this protein this Sequence and forget about it, then just hand it this sequence and set seq to NULL (no need to free it). If you intend to use the sequecne object elsewhere outside of the Protein datastructure then use Protein_from_Sequence(/hard_link_Sequence(seq)) Argument seq [OWNER] Sequence to make protein from [Sequence *] Return [UNKN ] Undocumented return value [Protein *] =item hard_link_Protein &Wise2::Protein::hard_link_Protein(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [Protein *] Return [UNKN ] Undocumented return value [Protein *] =item alloc &Wise2::Protein::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [Protein *] =item set_baseseq &Wise2::Protein::set_baseseq(obj,baseseq) Replace member variable baseseq For use principly by API functions Argument obj [UNKN ] Object holding the variable [Protein *] Argument baseseq [OWNER] New value of the variable [Sequence *] Return [SOFT ] member variable baseseq [boolean] =item baseseq &Wise2::Protein::baseseq(obj) Access member variable baseseq For use principly by API functions Argument obj [UNKN ] Object holding the variable [Protein *] Return [SOFT ] member variable baseseq [Sequence *] =back wise-2.4.1/src/dynlibsrc/protein.tex0000644000175000001440000000262110670453712017041 0ustar philippusers\section{protein} \label{module_protein} This module contains the following objects \begin{itemize} \item \ref{object_Protein} Protein \end{itemize} \subsection{Object Protein} \label{object_Protein} The Protein object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{baseseq} Type [Sequence * : Scalar] No documentation \end{description} The protein object is a typed example of a sequence object. It does nothing more than a sequence object but is typed Member functions of Protein \subsubsection{Protein_from_Sequence} \begin{description} \item[External C] {\tt Wise2_Protein_from_Sequence (seq)} \item[Perl] {\tt &Wise2::Protein::Protein_from_Sequence (seq)} \item[Perl-OOP call] {\tt $obj->Protein_from_Sequence()} \end{description} Arguments \begin{description} \item[seq] [OWNER] Sequence to make protein from [Sequence *] \item[returns] [UNKN ] Undocumented return value [Protein *] \end{description} makes a new protein from a Sequence. It owns the Sequence memory, ie will attempt a /free_Sequence on the structure when /free_Protein is called If you want to give this protein this Sequence and forget about it, then just hand it this sequence and set seq to NULL (no need to free it). If you intend to use the sequecne object elsewhere outside of the Protein datastructure then use Protein_from_Sequence(/hard_link_Sequence(seq)) wise-2.4.1/src/dynlibsrc/proteindb.dy0000644000175000001440000001423707313404541017165 0ustar philippusers %{ #include "sequencedb.h" #include "hscore.h" #include "complexsequence.h" #include "complexevalset.h" #include "randommodel.h" #include "randomdb.h" #include "protein.h" %} struct ProteinDB boolean is_single_seq !def="FALSE" boolean is_random_db !def="FALSE" ComplexSequence * single SequenceDB * sdb ComplexSequenceEvalSet * cses RandomProteinDB * rnd boolean test_dna !def="FALSE" %info A database of proteins. This takes either a single sequence or a sequence database and allows a method expecting protein complexsequences to loop over it. It also provides generic database indexing for this Horrible physical dependency in this generated by the random protein db requiring histogram and randommodel stuff. Yuk! %% api object ProteinDB des free_ProteinDB endobject func new_ProteinDB_from_single_seq func single_fasta_ProteinDB func new_ProteinDB endapi %{ #include "proteindb.h" %func shows the Hscore by the ProteinDB information %arg hs High Score structure ofp output file %% void show_Hscore_ProteinDB(Hscore * hs,FILE * ofp) { int i; for(i=0;ilen;i++) fprintf(ofp,"Query [%20s] Target [%20s] %d\n",hs->ds[i]->query->name,hs->ds[i]->target->name,hs->ds[i]->score); } %func Gets Protein sequence out from the proteindb using the information stored in dataentry %simple get_entry %arg prodb r ProteinDB database de r DataEntry information %% Protein * get_Protein_from_ProteinDB(ProteinDB * prodb,DataEntry * de) { Sequence * seq; if( prodb->is_single_seq == TRUE ) { return Protein_from_Sequence(hard_link_Sequence(prodb->single->seq)); } /* we need to get out the Sequence from seqdb */ seq = get_Sequence_from_SequenceDB(prodb->sdb,de); if( seq == NULL ) { warn("Cannot get entry for %s from Protein db",de->name); return NULL; } seq->type = SEQUENCE_PROTEIN; /* force to protein */ return Protein_from_Sequence(seq); } %func adds information to dataentry from ProteinDB This information is the necessary information for the proteindb to find this sequence later %% boolean dataentry_add_ProteinDB(DataEntry * de,ComplexSequence * cs,ProteinDB * prodb) { if( cs == NULL || cs->seq == NULL ){ warn("Adding a dataentry with a NULL complex sequence or null internal sequence. Nope!"); return FALSE; } if( prodb->is_single_seq == FALSE) add_SequenceDB_info_DataEntry(prodb->sdb,de); de->name = stringalloc(cs->seq->name); return TRUE; } %func top level function which opens the protein database %arg prodb protein database return_status w the status of the open from database.h %% ComplexSequence * init_ProteinDB(ProteinDB * prodb,int * return_status) { ComplexSequence * cs; Sequence * seq; if( prodb->is_single_seq == TRUE) { *return_status = DB_RETURN_OK; return prodb->single; } seq = init_SequenceDB(prodb->sdb,return_status); if( seq == NULL || *return_status == DB_RETURN_ERROR || *return_status == DB_RETURN_END ) { return NULL; /** error already reported **/ } if( prodb->test_dna == FALSE ) { seq->type = SEQUENCE_PROTEIN; } else { if( seq->type != SEQUENCE_PROTEIN ) { warn("For sequence %s, looks like a DNA sequence. Failing"); *return_status = DB_RETURN_ERROR; } } cs = new_ComplexSequence(seq,prodb->cses); free_Sequence(seq); return cs; } %func function which reloads the database %arg last previous complex sequence, will be freed return_status w return_status of the load %% ComplexSequence * reload_ProteinDB(ComplexSequence * last,ProteinDB * prodb,int * return_status) { ComplexSequence * cs; Sequence * seq; if( prodb->is_single_seq == TRUE ) { *return_status = DB_RETURN_END; return NULL; } /** free Complex Sequence **/ if( last != NULL ) { free_ComplexSequence(last); } seq = reload_SequenceDB(NULL,prodb->sdb,return_status); if( seq == NULL || *return_status == DB_RETURN_ERROR || *return_status == DB_RETURN_END ) { return NULL; /** error already reported **/ } if( prodb->test_dna == FALSE ) { seq->type = SEQUENCE_PROTEIN; } else { if( seq->type != SEQUENCE_PROTEIN ) { warn("For sequence %s, looks like a DNA sequence. Failing"); *return_status = DB_RETURN_ERROR; } } cs = new_ComplexSequence(seq,prodb->cses); free_Sequence(seq); return cs; } %func top level function which closes the protein database %arg cs last complex sequence prodb protein database %% boolean close_ProteinDB(ComplexSequence * cs,ProteinDB * prodb) { if( prodb->is_single_seq == TRUE ) { return TRUE; } if( cs != NULL) { free_ComplexSequence(cs); } return close_SequenceDB(NULL,prodb->sdb); } %func To make a new protein database from a single Sequence with default amino acid mapping %arg seq sequence which as placed into ProteinDB structure. %% ProteinDB * new_ProteinDB_from_single_seq(Sequence * seq) { ComplexSequenceEvalSet * cses; ComplexSequence * cs; cses = default_aminoacid_ComplexSequenceEvalSet(); cs = new_ComplexSequence(seq,cses); free_ComplexSequenceEvalSet(cses); return new_ProteinDB_from_single_cseq(cs); } %func To make a new protein database from a single ComplexSequence %arg cs complex sequence which is held. %% ProteinDB * new_ProteinDB_from_single_cseq(ComplexSequence * cs) { ProteinDB * out; out = ProteinDB_alloc(); out->is_single_seq = TRUE; out->single = cs; return out; } %func pre-packed single fasta protein database %arg filename name of fasta file %% ProteinDB * single_fasta_ProteinDB(char * filename) { return new_ProteinDB(single_fasta_SequenceDB(filename),default_aminoacid_ComplexSequenceEvalSet()); } %func To make a new protein database %arg seqdb sequence database cses protein evaluation set %% ProteinDB * new_ProteinDB(SequenceDB * seqdb,ComplexSequenceEvalSet * cses) { ProteinDB * out; /** should check sequence database **/ if( seqdb == NULL ) { warn("Cannot make ProteinDB from NULL SequenceDB object"); return NULL; } if( cses->type != SEQUENCE_PROTEIN ) { warn("You can't make a protein database with a non SEQUENCE_PROTEIN cses type [%d]",cses->type); return NULL; } out = ProteinDB_alloc(); out->sdb = seqdb; out->cses = cses; return out; } %} wise-2.4.1/src/dynlibsrc/proteindb.xs0000644000175000001440000000675710670453712017217 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::ProteinDB Wise2_ProteinDB * hard_link_ProteinDB(obj) Wise2_ProteinDB * obj CODE: RETVAL = Wise2_hard_link_ProteinDB(obj); OUTPUT: RETVAL Wise2_ProteinDB * alloc() CODE: RETVAL = Wise2_ProteinDB_alloc(); OUTPUT: RETVAL boolean set_is_single_seq(obj,is_single_seq) Wise2_ProteinDB * obj boolean is_single_seq CODE: RETVAL = Wise2_replace_is_single_seq_ProteinDB(obj,is_single_seq); OUTPUT: RETVAL boolean is_single_seq(obj) Wise2_ProteinDB * obj CODE: RETVAL = Wise2_access_is_single_seq_ProteinDB(obj); OUTPUT: RETVAL boolean set_is_random_db(obj,is_random_db) Wise2_ProteinDB * obj boolean is_random_db CODE: RETVAL = Wise2_replace_is_random_db_ProteinDB(obj,is_random_db); OUTPUT: RETVAL boolean is_random_db(obj) Wise2_ProteinDB * obj CODE: RETVAL = Wise2_access_is_random_db_ProteinDB(obj); OUTPUT: RETVAL boolean set_single(obj,single) Wise2_ProteinDB * obj Wise2_ComplexSequence * single CODE: RETVAL = Wise2_replace_single_ProteinDB(obj,Wise2_hard_link_ComplexSequence(single)); OUTPUT: RETVAL Wise2_ComplexSequence * single(obj) Wise2_ProteinDB * obj INIT: Wise2_ComplexSequence * temp; CODE: temp = Wise2_hard_link_ComplexSequence(Wise2_access_single_ProteinDB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_sdb(obj,sdb) Wise2_ProteinDB * obj Wise2_SequenceDB * sdb CODE: RETVAL = Wise2_replace_sdb_ProteinDB(obj,Wise2_hard_link_SequenceDB(sdb)); OUTPUT: RETVAL Wise2_SequenceDB * sdb(obj) Wise2_ProteinDB * obj INIT: Wise2_SequenceDB * temp; CODE: temp = Wise2_hard_link_SequenceDB(Wise2_access_sdb_ProteinDB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_cses(obj,cses) Wise2_ProteinDB * obj Wise2_ComplexSequenceEvalSet * cses CODE: RETVAL = Wise2_replace_cses_ProteinDB(obj,Wise2_hard_link_ComplexSequenceEvalSet(cses)); OUTPUT: RETVAL Wise2_ComplexSequenceEvalSet * cses(obj) Wise2_ProteinDB * obj INIT: Wise2_ComplexSequenceEvalSet * temp; CODE: temp = Wise2_hard_link_ComplexSequenceEvalSet(Wise2_access_cses_ProteinDB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_rnd(obj,rnd) Wise2_ProteinDB * obj Wise2_RandomProteinDB * rnd CODE: RETVAL = Wise2_replace_rnd_ProteinDB(obj,Wise2_hard_link_RandomProteinDB(rnd)); OUTPUT: RETVAL Wise2_RandomProteinDB * rnd(obj) Wise2_ProteinDB * obj INIT: Wise2_RandomProteinDB * temp; CODE: temp = Wise2_hard_link_RandomProteinDB(Wise2_access_rnd_ProteinDB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_test_dna(obj,test_dna) Wise2_ProteinDB * obj boolean test_dna CODE: RETVAL = Wise2_replace_test_dna_ProteinDB(obj,test_dna); OUTPUT: RETVAL boolean test_dna(obj) Wise2_ProteinDB * obj CODE: RETVAL = Wise2_access_test_dna_ProteinDB(obj); OUTPUT: RETVAL Wise2_ProteinDB * new(class) char * class PPCODE: Wise2_ProteinDB * out; out = Wise2_ProteinDB_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_ProteinDB * obj CODE: Wise2_free_ProteinDB(obj); MODULE = Wise2 PACKAGE = Wise2 Wise2_ProteinDB * new_ProteinDB_from_single_seq(seq) Wise2_Sequence * seq CODE: RETVAL = Wise2_new_ProteinDB_from_single_seq(seq); OUTPUT: RETVAL Wise2_ProteinDB * single_fasta_ProteinDB(filename) char * filename CODE: RETVAL = Wise2_single_fasta_ProteinDB(filename); OUTPUT: RETVAL Wise2_ProteinDB * new_ProteinDB(seqdb,cses) Wise2_SequenceDB * seqdb Wise2_ComplexSequenceEvalSet * cses CODE: RETVAL = Wise2_new_ProteinDB(seqdb,cses); OUTPUT: RETVAL wise-2.4.1/src/dynlibsrc/proteindb.c0000644000175000001440000004454510670453712017004 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "proteindb.h" /* Function: show_Hscore_ProteinDB(hs,ofp) * * Descrip: shows the Hscore by the ProteinDB information * * * * Arg: hs [UNKN ] High Score structure [Hscore *] * Arg: ofp [UNKN ] output file [FILE *] * */ # line 61 "proteindb.dy" void show_Hscore_ProteinDB(Hscore * hs,FILE * ofp) { int i; for(i=0;ilen;i++) fprintf(ofp,"Query [%20s] Target [%20s] %d\n",hs->ds[i]->query->name,hs->ds[i]->target->name,hs->ds[i]->score); } /* Function: get_Protein_from_ProteinDB(prodb,de) * * Descrip: Gets Protein sequence out from * the proteindb using the information stored in * dataentry * * * Arg: prodb [READ ] ProteinDB database [ProteinDB *] * Arg: de [READ ] DataEntry information [DataEntry *] * * Return [UNKN ] Undocumented return value [Protein *] * */ # line 78 "proteindb.dy" Protein * get_Protein_from_ProteinDB(ProteinDB * prodb,DataEntry * de) { Sequence * seq; if( prodb->is_single_seq == TRUE ) { return Protein_from_Sequence(hard_link_Sequence(prodb->single->seq)); } /* we need to get out the Sequence from seqdb */ seq = get_Sequence_from_SequenceDB(prodb->sdb,de); if( seq == NULL ) { warn("Cannot get entry for %s from Protein db",de->name); return NULL; } seq->type = SEQUENCE_PROTEIN; /* force to protein */ return Protein_from_Sequence(seq); } /* Function: dataentry_add_ProteinDB(de,cs,prodb) * * Descrip: adds information to dataentry from ProteinDB * * This information is the necessary information for * the proteindb to find this sequence later * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: cs [UNKN ] Undocumented argument [ComplexSequence *] * Arg: prodb [UNKN ] Undocumented argument [ProteinDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 106 "proteindb.dy" boolean dataentry_add_ProteinDB(DataEntry * de,ComplexSequence * cs,ProteinDB * prodb) { if( cs == NULL || cs->seq == NULL ){ warn("Adding a dataentry with a NULL complex sequence or null internal sequence. Nope!"); return FALSE; } if( prodb->is_single_seq == FALSE) add_SequenceDB_info_DataEntry(prodb->sdb,de); de->name = stringalloc(cs->seq->name); return TRUE; } /* Function: init_ProteinDB(prodb,return_status) * * Descrip: top level function which opens the protein database * * * Arg: prodb [UNKN ] protein database [ProteinDB *] * Arg: return_status [WRITE] the status of the open from database.h [int *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ # line 128 "proteindb.dy" ComplexSequence * init_ProteinDB(ProteinDB * prodb,int * return_status) { ComplexSequence * cs; Sequence * seq; if( prodb->is_single_seq == TRUE) { *return_status = DB_RETURN_OK; return prodb->single; } seq = init_SequenceDB(prodb->sdb,return_status); if( seq == NULL || *return_status == DB_RETURN_ERROR || *return_status == DB_RETURN_END ) { return NULL; /** error already reported **/ } if( prodb->test_dna == FALSE ) { seq->type = SEQUENCE_PROTEIN; } else { if( seq->type != SEQUENCE_PROTEIN ) { warn("For sequence %s, looks like a DNA sequence. Failing"); *return_status = DB_RETURN_ERROR; } } cs = new_ComplexSequence(seq,prodb->cses); free_Sequence(seq); return cs; } /* Function: reload_ProteinDB(last,prodb,return_status) * * Descrip: function which reloads the database * * * Arg: last [UNKN ] previous complex sequence, will be freed [ComplexSequence *] * Arg: prodb [UNKN ] Undocumented argument [ProteinDB *] * Arg: return_status [WRITE] return_status of the load [int *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ # line 166 "proteindb.dy" ComplexSequence * reload_ProteinDB(ComplexSequence * last,ProteinDB * prodb,int * return_status) { ComplexSequence * cs; Sequence * seq; if( prodb->is_single_seq == TRUE ) { *return_status = DB_RETURN_END; return NULL; } /** free Complex Sequence **/ if( last != NULL ) { free_ComplexSequence(last); } seq = reload_SequenceDB(NULL,prodb->sdb,return_status); if( seq == NULL || *return_status == DB_RETURN_ERROR || *return_status == DB_RETURN_END ) { return NULL; /** error already reported **/ } if( prodb->test_dna == FALSE ) { seq->type = SEQUENCE_PROTEIN; } else { if( seq->type != SEQUENCE_PROTEIN ) { warn("For sequence %s, looks like a DNA sequence. Failing"); *return_status = DB_RETURN_ERROR; } } cs = new_ComplexSequence(seq,prodb->cses); free_Sequence(seq); return cs; } /* Function: close_ProteinDB(cs,prodb) * * Descrip: top level function which closes the protein database * * * Arg: cs [UNKN ] last complex sequence [ComplexSequence *] * Arg: prodb [UNKN ] protein database [ProteinDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 210 "proteindb.dy" boolean close_ProteinDB(ComplexSequence * cs,ProteinDB * prodb) { if( prodb->is_single_seq == TRUE ) { return TRUE; } if( cs != NULL) { free_ComplexSequence(cs); } return close_SequenceDB(NULL,prodb->sdb); } /* Function: new_ProteinDB_from_single_seq(seq) * * Descrip: To make a new protein database * from a single Sequence with default amino acid mapping * * * Arg: seq [UNKN ] sequence which as placed into ProteinDB structure. [Sequence *] * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ # line 229 "proteindb.dy" ProteinDB * new_ProteinDB_from_single_seq(Sequence * seq) { ComplexSequenceEvalSet * cses; ComplexSequence * cs; cses = default_aminoacid_ComplexSequenceEvalSet(); cs = new_ComplexSequence(seq,cses); free_ComplexSequenceEvalSet(cses); return new_ProteinDB_from_single_cseq(cs); } /* Function: new_ProteinDB_from_single_cseq(cs) * * Descrip: To make a new protein database * from a single ComplexSequence * * * Arg: cs [UNKN ] complex sequence which is held. [ComplexSequence *] * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ # line 250 "proteindb.dy" ProteinDB * new_ProteinDB_from_single_cseq(ComplexSequence * cs) { ProteinDB * out; out = ProteinDB_alloc(); out->is_single_seq = TRUE; out->single = cs; return out; } /* Function: single_fasta_ProteinDB(filename) * * Descrip: pre-packed single fasta protein database * * * * Arg: filename [UNKN ] name of fasta file [char *] * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ # line 268 "proteindb.dy" ProteinDB * single_fasta_ProteinDB(char * filename) { return new_ProteinDB(single_fasta_SequenceDB(filename),default_aminoacid_ComplexSequenceEvalSet()); } /* Function: new_ProteinDB(seqdb,cses) * * Descrip: To make a new protein database * * * Arg: seqdb [UNKN ] sequence database [SequenceDB *] * Arg: cses [UNKN ] protein evaluation set [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ # line 280 "proteindb.dy" ProteinDB * new_ProteinDB(SequenceDB * seqdb,ComplexSequenceEvalSet * cses) { ProteinDB * out; /** should check sequence database **/ if( seqdb == NULL ) { warn("Cannot make ProteinDB from NULL SequenceDB object"); return NULL; } if( cses->type != SEQUENCE_PROTEIN ) { warn("You can't make a protein database with a non SEQUENCE_PROTEIN cses type [%d]",cses->type); return NULL; } out = ProteinDB_alloc(); out->sdb = seqdb; out->cses = cses; return out; } # line 300 "proteindb.c" /* Function: hard_link_ProteinDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ProteinDB *] * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ ProteinDB * hard_link_ProteinDB(ProteinDB * obj) { if( obj == NULL ) { warn("Trying to hard link to a ProteinDB object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ProteinDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ ProteinDB * ProteinDB_alloc(void) { ProteinDB * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ProteinDB *) ckalloc (sizeof(ProteinDB))) == NULL) { warn("ProteinDB_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->is_single_seq = FALSE; out->is_random_db = FALSE; out->single = NULL; out->sdb = NULL; out->cses = NULL; out->rnd = NULL; out->test_dna = FALSE; return out; } /* Function: free_ProteinDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ProteinDB *] * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ ProteinDB * free_ProteinDB(ProteinDB * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ProteinDB obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->single != NULL) free_ComplexSequence(obj->single); if( obj->sdb != NULL) free_SequenceDB(obj->sdb); if( obj->cses != NULL) free_ComplexSequenceEvalSet(obj->cses); if( obj->rnd != NULL) free_RandomProteinDB(obj->rnd); ckfree(obj); return NULL; } /* Function: replace_is_single_seq_ProteinDB(obj,is_single_seq) * * Descrip: Replace member variable is_single_seq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * Arg: is_single_seq [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable is_single_seq [boolean] * */ boolean replace_is_single_seq_ProteinDB(ProteinDB * obj,boolean is_single_seq) { if( obj == NULL) { warn("In replacement function is_single_seq for object ProteinDB, got a NULL object"); return FALSE; } obj->is_single_seq = is_single_seq; return TRUE; } /* Function: access_is_single_seq_ProteinDB(obj) * * Descrip: Access member variable is_single_seq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * * Return [SOFT ] member variable is_single_seq [boolean] * */ boolean access_is_single_seq_ProteinDB(ProteinDB * obj) { if( obj == NULL) { warn("In accessor function is_single_seq for object ProteinDB, got a NULL object"); return FALSE; } return obj->is_single_seq; } /* Function: replace_is_random_db_ProteinDB(obj,is_random_db) * * Descrip: Replace member variable is_random_db * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * Arg: is_random_db [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable is_random_db [boolean] * */ boolean replace_is_random_db_ProteinDB(ProteinDB * obj,boolean is_random_db) { if( obj == NULL) { warn("In replacement function is_random_db for object ProteinDB, got a NULL object"); return FALSE; } obj->is_random_db = is_random_db; return TRUE; } /* Function: access_is_random_db_ProteinDB(obj) * * Descrip: Access member variable is_random_db * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * * Return [SOFT ] member variable is_random_db [boolean] * */ boolean access_is_random_db_ProteinDB(ProteinDB * obj) { if( obj == NULL) { warn("In accessor function is_random_db for object ProteinDB, got a NULL object"); return FALSE; } return obj->is_random_db; } /* Function: replace_single_ProteinDB(obj,single) * * Descrip: Replace member variable single * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * Arg: single [OWNER] New value of the variable [ComplexSequence *] * * Return [SOFT ] member variable single [boolean] * */ boolean replace_single_ProteinDB(ProteinDB * obj,ComplexSequence * single) { if( obj == NULL) { warn("In replacement function single for object ProteinDB, got a NULL object"); return FALSE; } obj->single = single; return TRUE; } /* Function: access_single_ProteinDB(obj) * * Descrip: Access member variable single * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * * Return [SOFT ] member variable single [ComplexSequence *] * */ ComplexSequence * access_single_ProteinDB(ProteinDB * obj) { if( obj == NULL) { warn("In accessor function single for object ProteinDB, got a NULL object"); return NULL; } return obj->single; } /* Function: replace_sdb_ProteinDB(obj,sdb) * * Descrip: Replace member variable sdb * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * Arg: sdb [OWNER] New value of the variable [SequenceDB *] * * Return [SOFT ] member variable sdb [boolean] * */ boolean replace_sdb_ProteinDB(ProteinDB * obj,SequenceDB * sdb) { if( obj == NULL) { warn("In replacement function sdb for object ProteinDB, got a NULL object"); return FALSE; } obj->sdb = sdb; return TRUE; } /* Function: access_sdb_ProteinDB(obj) * * Descrip: Access member variable sdb * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * * Return [SOFT ] member variable sdb [SequenceDB *] * */ SequenceDB * access_sdb_ProteinDB(ProteinDB * obj) { if( obj == NULL) { warn("In accessor function sdb for object ProteinDB, got a NULL object"); return NULL; } return obj->sdb; } /* Function: replace_cses_ProteinDB(obj,cses) * * Descrip: Replace member variable cses * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * Arg: cses [OWNER] New value of the variable [ComplexSequenceEvalSet *] * * Return [SOFT ] member variable cses [boolean] * */ boolean replace_cses_ProteinDB(ProteinDB * obj,ComplexSequenceEvalSet * cses) { if( obj == NULL) { warn("In replacement function cses for object ProteinDB, got a NULL object"); return FALSE; } obj->cses = cses; return TRUE; } /* Function: access_cses_ProteinDB(obj) * * Descrip: Access member variable cses * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * * Return [SOFT ] member variable cses [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * access_cses_ProteinDB(ProteinDB * obj) { if( obj == NULL) { warn("In accessor function cses for object ProteinDB, got a NULL object"); return NULL; } return obj->cses; } /* Function: replace_rnd_ProteinDB(obj,rnd) * * Descrip: Replace member variable rnd * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * Arg: rnd [OWNER] New value of the variable [RandomProteinDB *] * * Return [SOFT ] member variable rnd [boolean] * */ boolean replace_rnd_ProteinDB(ProteinDB * obj,RandomProteinDB * rnd) { if( obj == NULL) { warn("In replacement function rnd for object ProteinDB, got a NULL object"); return FALSE; } obj->rnd = rnd; return TRUE; } /* Function: access_rnd_ProteinDB(obj) * * Descrip: Access member variable rnd * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * * Return [SOFT ] member variable rnd [RandomProteinDB *] * */ RandomProteinDB * access_rnd_ProteinDB(ProteinDB * obj) { if( obj == NULL) { warn("In accessor function rnd for object ProteinDB, got a NULL object"); return NULL; } return obj->rnd; } /* Function: replace_test_dna_ProteinDB(obj,test_dna) * * Descrip: Replace member variable test_dna * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * Arg: test_dna [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable test_dna [boolean] * */ boolean replace_test_dna_ProteinDB(ProteinDB * obj,boolean test_dna) { if( obj == NULL) { warn("In replacement function test_dna for object ProteinDB, got a NULL object"); return FALSE; } obj->test_dna = test_dna; return TRUE; } /* Function: access_test_dna_ProteinDB(obj) * * Descrip: Access member variable test_dna * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ProteinDB *] * * Return [SOFT ] member variable test_dna [boolean] * */ boolean access_test_dna_ProteinDB(ProteinDB * obj) { if( obj == NULL) { warn("In accessor function test_dna for object ProteinDB, got a NULL object"); return FALSE; } return obj->test_dna; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/proteindb.h0000644000175000001440000002266710670453712017012 0ustar philippusers#ifndef DYNAMITEproteindbHEADERFILE #define DYNAMITEproteindbHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequencedb.h" #include "hscore.h" #include "complexsequence.h" #include "complexevalset.h" #include "randommodel.h" #include "randomdb.h" #include "protein.h" /* Object ProteinDB * * Descrip: A database of proteins. This takes * either a single sequence or a * sequence database and allows a * method expecting protein complexsequences * to loop over it. * * It also provides generic database indexing * for this * * * Horrible physical dependency in this * generated by the random protein db * requiring histogram and randommodel * stuff. Yuk! * * */ struct Wise2_ProteinDB { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif boolean is_single_seq; boolean is_random_db; ComplexSequence * single; SequenceDB * sdb; ComplexSequenceEvalSet * cses; RandomProteinDB * rnd; boolean test_dna; } ; /* ProteinDB defined */ #ifndef DYNAMITE_DEFINED_ProteinDB typedef struct Wise2_ProteinDB Wise2_ProteinDB; #define ProteinDB Wise2_ProteinDB #define DYNAMITE_DEFINED_ProteinDB #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: show_Hscore_ProteinDB(hs,ofp) * * Descrip: shows the Hscore by the ProteinDB information * * * * Arg: hs [UNKN ] High Score structure [Hscore *] * Arg: ofp [UNKN ] output file [FILE *] * */ void Wise2_show_Hscore_ProteinDB(Hscore * hs,FILE * ofp); #define show_Hscore_ProteinDB Wise2_show_Hscore_ProteinDB /* Function: get_Protein_from_ProteinDB(prodb,de) * * Descrip: Gets Protein sequence out from * the proteindb using the information stored in * dataentry * * * Arg: prodb [READ ] ProteinDB database [ProteinDB *] * Arg: de [READ ] DataEntry information [DataEntry *] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Wise2_get_Protein_from_ProteinDB(ProteinDB * prodb,DataEntry * de); #define get_Protein_from_ProteinDB Wise2_get_Protein_from_ProteinDB /* Function: dataentry_add_ProteinDB(de,cs,prodb) * * Descrip: adds information to dataentry from ProteinDB * * This information is the necessary information for * the proteindb to find this sequence later * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: cs [UNKN ] Undocumented argument [ComplexSequence *] * Arg: prodb [UNKN ] Undocumented argument [ProteinDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_dataentry_add_ProteinDB(DataEntry * de,ComplexSequence * cs,ProteinDB * prodb); #define dataentry_add_ProteinDB Wise2_dataentry_add_ProteinDB /* Function: init_ProteinDB(prodb,return_status) * * Descrip: top level function which opens the protein database * * * Arg: prodb [UNKN ] protein database [ProteinDB *] * Arg: return_status [WRITE] the status of the open from database.h [int *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * Wise2_init_ProteinDB(ProteinDB * prodb,int * return_status); #define init_ProteinDB Wise2_init_ProteinDB /* Function: reload_ProteinDB(last,prodb,return_status) * * Descrip: function which reloads the database * * * Arg: last [UNKN ] previous complex sequence, will be freed [ComplexSequence *] * Arg: prodb [UNKN ] Undocumented argument [ProteinDB *] * Arg: return_status [WRITE] return_status of the load [int *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * Wise2_reload_ProteinDB(ComplexSequence * last,ProteinDB * prodb,int * return_status); #define reload_ProteinDB Wise2_reload_ProteinDB /* Function: close_ProteinDB(cs,prodb) * * Descrip: top level function which closes the protein database * * * Arg: cs [UNKN ] last complex sequence [ComplexSequence *] * Arg: prodb [UNKN ] protein database [ProteinDB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_close_ProteinDB(ComplexSequence * cs,ProteinDB * prodb) ; #define close_ProteinDB Wise2_close_ProteinDB /* Function: new_ProteinDB_from_single_seq(seq) * * Descrip: To make a new protein database * from a single Sequence with default amino acid mapping * * * Arg: seq [UNKN ] sequence which as placed into ProteinDB structure. [Sequence *] * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ ProteinDB * Wise2_new_ProteinDB_from_single_seq(Sequence * seq); #define new_ProteinDB_from_single_seq Wise2_new_ProteinDB_from_single_seq /* Function: new_ProteinDB_from_single_cseq(cs) * * Descrip: To make a new protein database * from a single ComplexSequence * * * Arg: cs [UNKN ] complex sequence which is held. [ComplexSequence *] * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ ProteinDB * Wise2_new_ProteinDB_from_single_cseq(ComplexSequence * cs); #define new_ProteinDB_from_single_cseq Wise2_new_ProteinDB_from_single_cseq /* Function: single_fasta_ProteinDB(filename) * * Descrip: pre-packed single fasta protein database * * * * Arg: filename [UNKN ] name of fasta file [char *] * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ ProteinDB * Wise2_single_fasta_ProteinDB(char * filename); #define single_fasta_ProteinDB Wise2_single_fasta_ProteinDB /* Function: new_ProteinDB(seqdb,cses) * * Descrip: To make a new protein database * * * Arg: seqdb [UNKN ] sequence database [SequenceDB *] * Arg: cses [UNKN ] protein evaluation set [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ ProteinDB * Wise2_new_ProteinDB(SequenceDB * seqdb,ComplexSequenceEvalSet * cses); #define new_ProteinDB Wise2_new_ProteinDB /* Function: hard_link_ProteinDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ProteinDB *] * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ ProteinDB * Wise2_hard_link_ProteinDB(ProteinDB * obj); #define hard_link_ProteinDB Wise2_hard_link_ProteinDB /* Function: ProteinDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ ProteinDB * Wise2_ProteinDB_alloc(void); #define ProteinDB_alloc Wise2_ProteinDB_alloc /* Function: free_ProteinDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ProteinDB *] * * Return [UNKN ] Undocumented return value [ProteinDB *] * */ ProteinDB * Wise2_free_ProteinDB(ProteinDB * obj); #define free_ProteinDB Wise2_free_ProteinDB /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_is_single_seq_ProteinDB(ProteinDB * obj,boolean is_single_seq); #define replace_is_single_seq_ProteinDB Wise2_replace_is_single_seq_ProteinDB SequenceDB * Wise2_access_sdb_ProteinDB(ProteinDB * obj); #define access_sdb_ProteinDB Wise2_access_sdb_ProteinDB boolean Wise2_access_is_single_seq_ProteinDB(ProteinDB * obj); #define access_is_single_seq_ProteinDB Wise2_access_is_single_seq_ProteinDB boolean Wise2_replace_cses_ProteinDB(ProteinDB * obj,ComplexSequenceEvalSet * cses); #define replace_cses_ProteinDB Wise2_replace_cses_ProteinDB boolean Wise2_access_is_random_db_ProteinDB(ProteinDB * obj); #define access_is_random_db_ProteinDB Wise2_access_is_random_db_ProteinDB ComplexSequenceEvalSet * Wise2_access_cses_ProteinDB(ProteinDB * obj); #define access_cses_ProteinDB Wise2_access_cses_ProteinDB ComplexSequence * Wise2_access_single_ProteinDB(ProteinDB * obj); #define access_single_ProteinDB Wise2_access_single_ProteinDB boolean Wise2_replace_rnd_ProteinDB(ProteinDB * obj,RandomProteinDB * rnd); #define replace_rnd_ProteinDB Wise2_replace_rnd_ProteinDB boolean Wise2_replace_is_random_db_ProteinDB(ProteinDB * obj,boolean is_random_db); #define replace_is_random_db_ProteinDB Wise2_replace_is_random_db_ProteinDB RandomProteinDB * Wise2_access_rnd_ProteinDB(ProteinDB * obj); #define access_rnd_ProteinDB Wise2_access_rnd_ProteinDB boolean Wise2_replace_sdb_ProteinDB(ProteinDB * obj,SequenceDB * sdb); #define replace_sdb_ProteinDB Wise2_replace_sdb_ProteinDB boolean Wise2_replace_test_dna_ProteinDB(ProteinDB * obj,boolean test_dna); #define replace_test_dna_ProteinDB Wise2_replace_test_dna_ProteinDB boolean Wise2_replace_single_ProteinDB(ProteinDB * obj,ComplexSequence * single); #define replace_single_ProteinDB Wise2_replace_single_ProteinDB boolean Wise2_access_test_dna_ProteinDB(ProteinDB * obj); #define access_test_dna_ProteinDB Wise2_access_test_dna_ProteinDB #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/genericindexresult.c0000644000175000001440000000775110670453712020717 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genericindexresult.h" /* Function: next_interface_GenericIndexResult(data,prev) * * Descrip: For interface, returns next position in SeqLookup Results * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: prev [UNKN ] Undocumented argument [SeqLookupResultStruct *] * * Return [UNKN ] Undocumented return value [SeqLookupResultStruct *] * */ # line 23 "genericindexresult.dy" SeqLookupResultStruct * next_interface_GenericIndexResult(void * data,SeqLookupResultStruct * prev) { GenericIndexResult * gir = (GenericIndexResult*)data; return &(gir->result[gir->current_pos++]); } /* Function: is_more_interface_GenericIndexResult(data) * * Descrip: For interface, indicates whether there is more stuff to find or not * * * Arg: data [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 33 "genericindexresult.dy" boolean is_more_interface_GenericIndexResult(void * data) { GenericIndexResult * gir = (GenericIndexResult*)data; if( gir->current_pos < gir->len ) { return TRUE; } return FALSE; } /* Function: free_noop_GenericIndexResult(data) * * Descrip: Frees the data * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 46 "genericindexresult.dy" void free_noop_GenericIndexResult(void * data) { return; } /* Function: add_GenericIndexResult(gir,seq,pos) * * Descrip: Adds another result to a IndexResult * * * Arg: gir [UNKN ] Undocumented argument [GenericIndexResult *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: pos [UNKN ] Undocumented argument [int] * */ # line 54 "genericindexresult.dy" void add_GenericIndexResult(GenericIndexResult * gir,Sequence * seq,int pos) { assert(gir); assert(seq); if( gir->len >= gir->max_len ) { gir->result = realloc(gir->result,2*gir->max_len*sizeof(SeqLookupResultStruct)); gir->max_len = 2* gir->max_len; } gir->result[gir->len].seq = seq; gir->result[gir->len].pos = pos; gir->len++; } /* Function: free_GenericIndexResult(p) * * Descrip: Frees GenericIndexResults - overrides dynamite default * * * Arg: p [UNKN ] Undocumented argument [GenericIndexResult *] * * Return [UNKN ] Undocumented return value [GenericIndexResult *] * */ # line 76 "genericindexresult.dy" GenericIndexResult * free_GenericIndexResult(GenericIndexResult * p) { assert(p); free(p->result); free(p); return NULL; } # line 101 "genericindexresult.c" /* Function: hard_link_GenericIndexResult(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenericIndexResult *] * * Return [UNKN ] Undocumented return value [GenericIndexResult *] * */ GenericIndexResult * hard_link_GenericIndexResult(GenericIndexResult * obj) { if( obj == NULL ) { warn("Trying to hard link to a GenericIndexResult object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GenericIndexResult_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenericIndexResult *] * */ GenericIndexResult * GenericIndexResult_alloc(void) { GenericIndexResult * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenericIndexResult *) ckalloc (sizeof(GenericIndexResult))) == NULL) { warn("GenericIndexResult_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->result = NULL; out->len = 0; out->max_len = 0; out->current_pos = 0; return out; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/genericindexresult.h0000644000175000001440000001011510670453712020710 0ustar philippusers#ifndef DYNAMITEgenericindexresultHEADERFILE #define DYNAMITEgenericindexresultHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "seqlookup.h" struct Wise2_GenericIndexResult { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif SeqLookupResultStruct * result; int len; int max_len; int current_pos; } ; /* GenericIndexResult defined */ #ifndef DYNAMITE_DEFINED_GenericIndexResult typedef struct Wise2_GenericIndexResult Wise2_GenericIndexResult; #define GenericIndexResult Wise2_GenericIndexResult #define DYNAMITE_DEFINED_GenericIndexResult #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: next_interface_GenericIndexResult(data,prev) * * Descrip: For interface, returns next position in SeqLookup Results * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: prev [UNKN ] Undocumented argument [SeqLookupResultStruct *] * * Return [UNKN ] Undocumented return value [SeqLookupResultStruct *] * */ SeqLookupResultStruct * Wise2_next_interface_GenericIndexResult(void * data,SeqLookupResultStruct * prev) ; #define next_interface_GenericIndexResult Wise2_next_interface_GenericIndexResult /* Function: is_more_interface_GenericIndexResult(data) * * Descrip: For interface, indicates whether there is more stuff to find or not * * * Arg: data [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_more_interface_GenericIndexResult(void * data); #define is_more_interface_GenericIndexResult Wise2_is_more_interface_GenericIndexResult /* Function: free_noop_GenericIndexResult(data) * * Descrip: Frees the data * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_noop_GenericIndexResult(void * data); #define free_noop_GenericIndexResult Wise2_free_noop_GenericIndexResult /* Function: add_GenericIndexResult(gir,seq,pos) * * Descrip: Adds another result to a IndexResult * * * Arg: gir [UNKN ] Undocumented argument [GenericIndexResult *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: pos [UNKN ] Undocumented argument [int] * */ void Wise2_add_GenericIndexResult(GenericIndexResult * gir,Sequence * seq,int pos); #define add_GenericIndexResult Wise2_add_GenericIndexResult /* Function: free_GenericIndexResult(p) * * Descrip: Frees GenericIndexResults - overrides dynamite default * * * Arg: p [UNKN ] Undocumented argument [GenericIndexResult *] * * Return [UNKN ] Undocumented return value [GenericIndexResult *] * */ GenericIndexResult * Wise2_free_GenericIndexResult(GenericIndexResult * p); #define free_GenericIndexResult Wise2_free_GenericIndexResult /* Function: hard_link_GenericIndexResult(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenericIndexResult *] * * Return [UNKN ] Undocumented return value [GenericIndexResult *] * */ GenericIndexResult * Wise2_hard_link_GenericIndexResult(GenericIndexResult * obj); #define hard_link_GenericIndexResult Wise2_hard_link_GenericIndexResult /* Function: GenericIndexResult_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenericIndexResult *] * */ GenericIndexResult * Wise2_GenericIndexResult_alloc(void); #define GenericIndexResult_alloc Wise2_GenericIndexResult_alloc /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/basematrix_api.h0000644000175000001440000000165610670453712020007 0ustar philippusers /* Helper functions in the module * * Wise2_change_max_BaseMatrix_kbytes * Wise2_get_max_BaseMatrix_kbytes * /* These functions are not associated with an object */ /* Function: Wise2_change_max_BaseMatrix_kbytes(new_kilo_number) * * Descrip: This is to change, at run-time the maximum level of bytes basematrix *thinks* * it can use. This number is *not* used for any actual calls to basematrix * allocation: it is only used with /get_max_BaseMatrix_kbytes * * * Arg: new_kilo_number max kilobytes allowed [int] * * Returns Undocumented return value [void] * */ void Wise2_change_max_BaseMatrix_kbytes( int new_kilo_number); /* Function: Wise2_get_max_BaseMatrix_kbytes(void) * * Descrip: returns the max. number of kilobytes suggested as a limited * to BaseMatrix. * * * * Returns Undocumented return value [int] * */ int Wise2_get_max_BaseMatrix_kbytes(); wise-2.4.1/src/dynlibsrc/basematrix_api.t0000644000175000001440000000000010670453712020001 0ustar philippuserswise-2.4.1/src/dynlibsrc/gene.pod0000644000175000001440000002035710670453712016267 0ustar philippusers=head1 NAME gene module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item Gene =back =head1 DESCRIPTION =head2 Object Gene =over =item start Type [int] Scalar No documentation =item end Type [int] Scalar No documentation =item parent Type [GenomicRegion *] Scalar may not be here =item genomic Type [Genomic *] Scalar may not be here! =item transcript Type [Transcript **] List No documentation =item name Type [char *] Scalar ugly . Need a better system =item bits Type [double] Scalar ditto... =item seqname Type [char *] Scalar very bad! this is for keeping track of what sequence was used to make the gene =item ispseudo Type [boolean] Scalar is a pseudogene or not =back Gene is the datastructure which represents a single gene. At the moment this is considered to be a series of transcripts (the first transcript being "canonical") which are made from a certain start/stop region in genomic DNA. The gene datastructure does not necessarily contain any DNA sequence. When someone askes for the gene sequence, via get_Genomic_from_Gene(), it first sees if there is anything in the Genomic * 'cache'. If this is null, it then looks at parent (the genomic region), and if that is null, complains and returns null. Otherwise it truncates its parent's dna in the correct way, places the data structure into the genomic * cache, and returns it. The name, bits and seqname have put into this datastructure for convience of carrying around this information into some of the gene prediction output formats. Probabaly o they should be in transcript, not gene o they shouldn't be here at all. =head2 Member functions of Gene =over =item get_Genomic_from_Gene &Wise2::Gene::get_Genomic_from_Gene(gene) Gives back a Genomic sequence type from a gene. Argument gene [READ ] gene to get Genomic from [Gene *] Return [SOFT ] Genomic DNA data structure [Genomic *] =item show_pretty_Gene &Wise2::Gene::show_pretty_Gene(ge,show_supporting,ofp) Shows a gene in the biologically accepted form Argument ge [UNKN ] Undocumented argument [Gene *] Argument show_supporting [UNKN ] Undocumented argument [boolean] Argument ofp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [void] =item hard_link_Gene &Wise2::Gene::hard_link_Gene(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [Gene *] Return [UNKN ] Undocumented return value [Gene *] =item Gene_alloc_std &Wise2::Gene::Gene_alloc_std(void) Equivalent to Gene_alloc_len(GeneLISTLENGTH) Return [UNKN ] Undocumented return value [Gene *] =item set_start &Wise2::Gene::set_start(obj,start) Replace member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Argument start [OWNER] New value of the variable [int] Return [SOFT ] member variable start [boolean] =item start &Wise2::Gene::start(obj) Access member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Return [SOFT ] member variable start [int] =item set_end &Wise2::Gene::set_end(obj,end) Replace member variable end For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Argument end [OWNER] New value of the variable [int] Return [SOFT ] member variable end [boolean] =item end &Wise2::Gene::end(obj) Access member variable end For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Return [SOFT ] member variable end [int] =item set_parent &Wise2::Gene::set_parent(obj,parent) Replace member variable parent For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Argument parent [OWNER] New value of the variable [GenomicRegion *] Return [SOFT ] member variable parent [boolean] =item parent &Wise2::Gene::parent(obj) Access member variable parent For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Return [SOFT ] member variable parent [GenomicRegion *] =item set_genomic &Wise2::Gene::set_genomic(obj,genomic) Replace member variable genomic For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Argument genomic [OWNER] New value of the variable [Genomic *] Return [SOFT ] member variable genomic [boolean] =item genomic &Wise2::Gene::genomic(obj) Access member variable genomic For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Return [SOFT ] member variable genomic [Genomic *] =item transcript &Wise2::Gene::transcript(obj,i) Access members stored in the transcript list For use principly by API functions Argument obj [UNKN ] Object holding the list [Gene *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [Transcript *] =item length_transcript &Wise2::Gene::length_transcript(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [Gene *] Return [UNKN ] length of the list [int] =item flush_transcript &Wise2::Gene::flush_transcript(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [Gene *] Return [UNKN ] Undocumented return value [int] =item add_transcript &Wise2::Gene::add_transcript(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [Gene *] Argument add [OWNER] Object to add to the list [Transcript *] Return [UNKN ] Undocumented return value [boolean] =item set_name &Wise2::Gene::set_name(obj,name) Replace member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Argument name [OWNER] New value of the variable [char *] Return [SOFT ] member variable name [boolean] =item name &Wise2::Gene::name(obj) Access member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Return [SOFT ] member variable name [char *] =item set_bits &Wise2::Gene::set_bits(obj,bits) Replace member variable bits For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Argument bits [OWNER] New value of the variable [double] Return [SOFT ] member variable bits [boolean] =item bits &Wise2::Gene::bits(obj) Access member variable bits For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Return [SOFT ] member variable bits [double] =item set_seqname &Wise2::Gene::set_seqname(obj,seqname) Replace member variable seqname For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Argument seqname [OWNER] New value of the variable [char *] Return [SOFT ] member variable seqname [boolean] =item seqname &Wise2::Gene::seqname(obj) Access member variable seqname For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Return [SOFT ] member variable seqname [char *] =item set_ispseudo &Wise2::Gene::set_ispseudo(obj,ispseudo) Replace member variable ispseudo For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Argument ispseudo [OWNER] New value of the variable [boolean] Return [SOFT ] member variable ispseudo [boolean] =item ispseudo &Wise2::Gene::ispseudo(obj) Access member variable ispseudo For use principly by API functions Argument obj [UNKN ] Object holding the variable [Gene *] Return [SOFT ] member variable ispseudo [boolean] =back wise-2.4.1/src/dynlibsrc/gene.tex0000644000175000001440000000561610670453712016306 0ustar philippusers\section{gene} \label{module_gene} This module contains the following objects \begin{itemize} \item \ref{object_Gene} Gene \end{itemize} \subsection{Object Gene} \label{object_Gene} The Gene object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{start} Type [int : Scalar] No documentation \item{end} Type [int : Scalar] No documentation \item{parent} Type [GenomicRegion * : Scalar] may not be here \item{genomic} Type [Genomic * : Scalar] may not be here! \item{transcript} Type [Transcript ** : List] No documentation \item{name} Type [char * : Scalar] ugly . Need a better system \item{bits} Type [double : Scalar] ditto... \item{seqname} Type [char * : Scalar] very bad! this is for keeping track of what sequence was used to make the gene \item{ispseudo} Type [boolean : Scalar] is a pseudogene or not \end{description} Gene is the datastructure which represents a single gene. At the moment this is considered to be a series of transcripts (the first transcript being "canonical") which are made from a certain start/stop region in genomic DNA. The gene datastructure does not necessarily contain any DNA sequence. When someone askes for the gene sequence, via get_Genomic_from_Gene(), it first sees if there is anything in the Genomic * 'cache'. If this is null, it then looks at parent (the genomic region), and if that is null, complains and returns null. Otherwise it truncates its parent's dna in the correct way, places the data structure into the genomic * cache, and returns it. The name, bits and seqname have put into this datastructure for convience of carrying around this information into some of the gene prediction output formats. Probabaly \begin{verbatim} o they should be in transcript, not gene o they shouldn't be here at all. \end{verbatim} Member functions of Gene \subsubsection{get_Genomic_from_Gene} \begin{description} \item[External C] {\tt Wise2_get_Genomic_from_Gene (gene)} \item[Perl] {\tt &Wise2::Gene::get_Genomic_from_Gene (gene)} \item[Perl-OOP call] {\tt $obj->get_Genomic_from_Gene()} \end{description} Arguments \begin{description} \item[gene] [READ ] gene to get Genomic from [Gene *] \item[returns] [SOFT ] Genomic DNA data structure [Genomic *] \end{description} Gives back a Genomic sequence type from a gene. \subsubsection{show_pretty_Gene} \begin{description} \item[External C] {\tt Wise2_show_pretty_Gene (ge,show_supporting,ofp)} \item[Perl] {\tt &Wise2::Gene::show_pretty_Gene (ge,show_supporting,ofp)} \item[Perl-OOP call] {\tt $obj->show_pretty_Gene(show_supporting,ofp)} \end{description} Arguments \begin{description} \item[ge] [UNKN ] Undocumented argument [Gene *] \item[show_supporting] [UNKN ] Undocumented argument [boolean] \item[ofp] [UNKN ] Undocumented argument [FILE *] \item[returns] Nothing - no return value \end{description} Shows a gene in the biologically accepted form wise-2.4.1/src/dynlibsrc/hsphandler.c0000644000175000001440000010761110670453712017140 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "hsphandler.h" /* Function: new_TopScoreManager(length) * * Descrip: Makes a new topscore manager of a specific length * * * Arg: length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [TopScoreManager *] * */ # line 57 "hsphandler.dy" TopScoreManager * new_TopScoreManager(int length) { TopScoreManager * tsm; tsm = TopScoreManager_alloc(); tsm->score = calloc(length,sizeof(int)); tsm->current_pos = 0; tsm->length = length; tsm->worst_score = 0; tsm->worst_position = -1; return tsm; } /* Function: add_score_TopScoreManager(tsm,score) * * Descrip: Adds a top score * * * Arg: tsm [UNKN ] Undocumented argument [TopScoreManager *] * Arg: score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 78 "hsphandler.dy" boolean add_score_TopScoreManager(TopScoreManager * tsm,int score) { int i; int temp_score; int temp_pos; /* fprintf(stderr,"Looking at %d\n",score);*/ if( tsm->current_pos < tsm->length ) { tsm->score[tsm->current_pos++] = score; return TRUE; } if( tsm->worst_position == -1 ) { /* fprintf(stderr,"Recalculating...\n"); */ /* need to recalculate top score */ for(i=1,temp_score = tsm->score[0],temp_pos = 0;ilength;i++) { if( temp_score > tsm->score[i] ) { temp_score = tsm->score[i]; temp_pos = i; } } tsm->worst_score = temp_score; tsm->worst_position = temp_pos; } if( score < tsm->worst_score ) { /* fprintf(stderr,"Ignoring... %d vs %d\n",score,tsm->worst_score); */ return FALSE; } /* fprintf(stderr,"Resetting...\n"); */ tsm->score[tsm->worst_position] = score; tsm->worst_position = -1; return TRUE; } /* Function: truncated_simple_LinearHSPmanager(lm,para) * * Descrip: A simpler truncation method, using diagonals * * * Arg: lm [UNKN ] Undocumented argument [LinearHSPmanager *] * Arg: para [UNKN ] Undocumented argument [LineariseHSPPara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 120 "hsphandler.dy" LinearHSPmanager * truncated_simple_LinearHSPmanager(LinearHSPmanager * lm,LineariseHSPPara * para) { LinearHSPmanager * out; int i; int j; int new_score; int diag_one; int diag_two; int query_position[500]; int k; int aa_count; int query_offset; /* struct timeval t1; struct timeval t2; struct timeval t3; */ /* gettimeofday(&t1,NULL);*/ if( VERBOSITY_CHECK(2,para->verbosity) ) { info("Input linear management of %d entries\n",lm->len); } for(i=0;ilen;i++) { /* rescore this set wrt to top diagonal */ sort_HSPset_by_score(lm->set[i]); new_score = lm->set[i]->hsp[0]->score; diag_one = lm->set[i]->hsp[0]->query_start - lm->set[i]->hsp[0]->target_start; if( VERBOSITY_CHECK(5,para->verbosity) ) { info("Looking at %s with starting hsp score of %d\n",lm->set[i]->hsp[0]->target->name,new_score); } query_offset = lm->set[i]->hsp[0]->query_start - 200; for(k=0;k<500;k++) { query_position[k] = 0; } for(k=0;kset[i]->hsp[0]->length && lm->set[i]->hsp[0]->query_start - query_offset+k < 500;k++) { query_position[lm->set[i]->hsp[0]->query_start - query_offset+k] = 1; } for(j=1;jset[i]->len;j++) { if( lm->set[i]->hsp[j]->score < para->min_score ) { if( VERBOSITY_CHECK(8,para->verbosity) ) { info(" ...not accepting hsp %d,%d due to min score",lm->set[i]->hsp[j]->query_start,lm->set[i]->hsp[j]->target_start); } break; } diag_two = lm->set[i]->hsp[j]->query_start - lm->set[i]->hsp[j]->target_start; if( abs(diag_one - diag_two) < para->width && abs(lm->set[i]->hsp[0]->query_start - lm->set[i]->hsp[j]->query_start) < para->tail) { /* this is now in the right area */ /* but we need to test for overlap on existing cases */ /* fprintf(stderr," .... looking at hsp overlap\n");*/ for(aa_count = 0,k=0;kset[i]->hsp[j]->length && lm->set[i]->hsp[j]->query_start - query_offset+k < 500;k++) { if( query_position[lm->set[i]->hsp[j]->query_start - query_offset+k] == 1 ) { aa_count++; } } /* if we have more than 15% of this hsp "accounted for" move on */ if(aa_count/(double)lm->set[i]->hsp[j]->length > 0.15 ) { continue; } /* fprintf(stderr," .... updating HSP overlap\n");*/ /* now set these positions as used */ for(aa_count = 0,k=0;kset[i]->hsp[j]->length && lm->set[i]->hsp[j]->query_start - query_offset+k < 500;k++) { query_position[lm->set[i]->hsp[j]->query_start - query_offset+k] = 1; } new_score += lm->set[i]->hsp[j]->score; if( VERBOSITY_CHECK(5,para->verbosity) ) { info(" ..accepting hsp on %s %d,%d new score %d",lm->set[i]->hsp[j]->target->name,lm->set[i]->hsp[j]->query_start,lm->set[i]->hsp[j]->target_start,new_score); } } else { if( VERBOSITY_CHECK(5,para->verbosity) ) { info(" ...not accepting hsp %d,%d due to diagonal width",lm->set[i]->hsp[j]->query_start,lm->set[i]->hsp[j]->target_start); } } } if( VERBOSITY_CHECK(3,para->verbosity) ) { info("Looking at %s with final score of %d",lm->set[i]->hsp[0]->target->name,new_score); } lm->set[i]->score = new_score; } /* gettimeofday(&t2,NULL); */ if( VERBOSITY_CHECK(2,para->verbosity) ) { info("sorting %d items",lm->len); } /*qsort(lm->set,lm->len,sizeof(HSPset*),compare_HSPset_score_qsort);*/ sort_LinearHSPmanager(lm,compare_HSPset_score); /* gettimeofday(&t3,NULL); info("truncation clock point: rescoring %f : sorting %f", t2.tv_sec - t1.tv_sec + ((t2.tv_usec - t1.tv_usec) * 1e-6), t3.tv_sec - t2.tv_sec + ((t2.tv_usec - t2.tv_usec) * 1e-6) ); */ out = LinearHSPmanager_alloc_std(); out->mat = hard_link_CompMat(lm->mat); for(i=0;ilen;i++) { if( VERBOSITY_CHECK(5,para->verbosity) ) { info("Accepting hit %s position %d with score %d",lm->set[i]->hsp[0]->target->name,i,lm->set[i]->score); } add_LinearHSPmanager(out,hard_link_HSPset(lm->set[i])); if( i > para->max_size ) { break; } } return out; } /* Function: truncated_LinearHSPmanager(lm,max_size,min_score,width,tail) * * Descrip: Makes a truncated linear set * * * Arg: lm [UNKN ] Undocumented argument [LinearHSPmanager *] * Arg: max_size [UNKN ] Undocumented argument [int] * Arg: min_score [UNKN ] Undocumented argument [int] * Arg: width [UNKN ] Undocumented argument [int] * Arg: tail [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 271 "hsphandler.dy" LinearHSPmanager * truncated_LinearHSPmanager(LinearHSPmanager * lm,int max_size,int min_score,int width,int tail) { LinearHSPmanager * out; int i,j; int worst_score = UNFEASIBLY_LARGE_SCORE; int worst_j = -1; HSPset ** worst; HSPset * trial; assert(max_size > 0); out = LinearHSPmanager_alloc_len(max_size+1); out->mat = hard_link_CompMat(lm->mat); sort_LinearHSPmanager(lm,compare_HSPset_score); for(i=0;ilen;i++) { /* we chew up into max_size positions */ if( out->len < max_size ) { trial = new_consistent_HSPset(lm->set[i],min_score,width,tail); if( trial->len == 0 ) { continue; } add_LinearHSPmanager(out,trial); } else { /* if have not found worst, scan to find worst */ if( worst_score == UNFEASIBLY_LARGE_SCORE ) { for(j=0;jlen;j++) { if( out->set[j]->score < worst_score ) { worst_score = out->set[j]->score; worst = out->set+j; worst_j = j; } } } /* worst_score is now the score */ if( lm->set[i]->score < worst_score ) { break; /* otta here - we don't need to look at any more! */ } trial = new_consistent_HSPset(lm->set[i],min_score,width,tail); if( trial->len == 0 ) { continue; } if( trial->score > worst_score ) { free_HSPset(out->set[worst_j]); out->set[worst_j] = trial; worst_score = UNFEASIBLY_LARGE_SCORE; } else { free_HSPset(trial); } } } return out; } /* Function: new_consistent_HSPset(set,min_score,width,tail) * * Descrip: Makes an HSP set via heuristics * to deal with low complexity regions * * * Arg: set [UNKN ] Undocumented argument [HSPset *] * Arg: min_score [UNKN ] Undocumented argument [int] * Arg: width [UNKN ] Undocumented argument [int] * Arg: tail [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPset *] * */ # line 336 "hsphandler.dy" HSPset * new_consistent_HSPset(HSPset * set,int min_score,int width,int tail) { HSPset * out; int i,j; int diag_a; int diag_b; int eaten; /* fprintf(stderr,"Entering consistency for %s with %d\n",set->hsp[0]->target->name,set->len); */ out = HSPset_alloc_std(); sort_HSPset_by_score(set); add_HSPset(out,hard_link_HSP(set->hsp[0])); out->score = set->hsp[0]->score; for(i=1;ilen;i++) { /* check against exisiting HSPs. If fits, add into big set */ eaten = 0; if( set->hsp[i]->score < min_score ) { continue; } for(j=0;jlen;j++) { diag_a = set->hsp[i]->query_start - set->hsp[i]->target_start; diag_b = out->hsp[j]->query_start - out->hsp[j]->target_start; if( abs(diag_a - diag_b) > 2 * width ) { continue; /* does not match */ } eaten = 1; add_HSPset(out,hard_link_HSP(set->hsp[i])); out->score += set->hsp[i]->score; break; } } return out; } /* Function: new_LinearHSPmanager_simple_heuristic(hspm,para) * * Descrip: New, simpler LinearHSPmanager with diagonal heuristics * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * Arg: para [UNKN ] Undocumented argument [LineariseHSPPara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 384 "hsphandler.dy" LinearHSPmanager * new_LinearHSPmanager_simple_heuristic(HSPmanager * hspm,LineariseHSPPara * para) { int i; int j; LinearHSPmanager * temp; LinearHSPmanager * out; #ifdef LINUX_TIMER struct timeval t1; struct timeval t2; struct timeval t3; if( VERBOSITY_CHECK(1,para->verbosity) ) { gettimeofday(&t1,NULL); } #endif temp = new_LinearHSPmanager_truncate_on_score(hspm); if( VERBOSITY_CHECK(2,para->verbosity) ) { info("Have got linear hsp manager with %d entries",temp->len); } #ifdef LINUX_TIMER if( VERBOSITY_CHECK(1,para->verbosity) ) { gettimeofday(&t2,NULL); } #endif out = truncated_simple_LinearHSPmanager(temp,para); if( VERBOSITY_CHECK(2,para->verbosity) ) { info("Now got linear hsp manager with %d entries",out->len); } #ifdef LINUX_TIMER if( VERBOSITY_CHECK(1,para->verbosity) ) { gettimeofday(&t3,NULL); info("Sort breakdown: Conversion %f : Truncation %f", t2.tv_sec - t1.tv_sec + ((t2.tv_usec - t1.tv_usec) * 1e-6), t3.tv_sec - t2.tv_sec + ((t2.tv_usec - t2.tv_usec) * 1e-6) ); } #endif /* for(i=0;ilen;i++) { fprintf(stderr,"%d, got score %d, top score %d %s\n",i,out->set[i]->score,out->set[i]->hsp[0]->score,out->set[i]->hsp[0]->target->name); for(j=0;jset[i]->len;j++) { fprintf(stderr," HSP %d,%d score %d\n",out->set[i]->hsp[j]->query_start, out->set[i]->hsp[j]->target_start, out->set[i]->hsp[j]->score); } } */ info("Currently not free'ing temporary list"); return out; } /* Function: new_LinearHSPmanager_heuristic_max(hspm,max_size) * * Descrip: Builds a new LinearHSPmanager from hash based with heuristics * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * Arg: max_size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 458 "hsphandler.dy" LinearHSPmanager * new_LinearHSPmanager_heuristic_max(HSPmanager * hspm,int max_size) { LinearHSPmanager * temp; LinearHSPmanager * out; assert(hspm); assert(max_size > 0); temp = new_LinearHSPmanager_truncate_on_score(hspm); out = truncated_LinearHSPmanager(temp,max_size,30,30,40); /* free_LinearHSPmanager(temp); */ return out; } /* Function: new_LinearHSPmanager_truncate_on_score(hspm) * * Descrip: Builds a LinearHSPmanager from a hash based HSP manager, using worst score truncation * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 478 "hsphandler.dy" LinearHSPmanager * new_LinearHSPmanager_truncate_on_score(HSPmanager * hspm) { LinearHSPmanager * out; out = LinearHSPmanager_alloc_std(); out->mat = hard_link_CompMat(hspm->mat); out->worst_hsp_score = hspm->tsm->worst_score; /* for(i=0;itsm->length;i++) { fprintf(stderr,"At position %d got score %d\n",i,hspm->tsm->score[i]); } */ /* fprintf(stderr,"Before management, we have %d, worst score is %d\n",g_hash_table_size(hspm->target_hash),out->worst_hsp_score); */ g_hash_table_foreach(hspm->target_hash,linearise_HSPset_truncate_on_score,out); /* sort_LinearHSPmanager(out,compare_HSPset_score); */ return out; } /* Function: new_LinearHSPmanager_flat(hspm) * * Descrip: Builds a LinearHSPmanager from a hash based HSP manager * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 512 "hsphandler.dy" LinearHSPmanager * new_LinearHSPmanager_flat(HSPmanager * hspm) { LinearHSPmanager * out; out = LinearHSPmanager_alloc_std(); out->mat = hard_link_CompMat(hspm->mat); g_hash_table_foreach(hspm->target_hash,linearise_HSPset_flat,out); sort_LinearHSPmanager(out,compare_HSPset_score); return out; } /* Function: linearise_HSPset_truncate_on_score(key,value,user_data) * * Descrip: internal function for remapping HSPs * * * Arg: key [UNKN ] Undocumented argument [gpointer] * Arg: value [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * */ # line 531 "hsphandler.dy" void linearise_HSPset_truncate_on_score(gpointer key,gpointer value,gpointer user_data) { LinearHSPmanager * l = (LinearHSPmanager *) user_data; HSPset * s = (HSPset *) value; if( s->len == 1 && s->score < l->worst_hsp_score ) { return; } else { add_LinearHSPmanager(l,hard_link_HSPset(s)); } } /* Function: linearise_HSPset_flat(key,value,user_data) * * Descrip: internal function for remapping HSPs with score cutoff * * * Arg: key [UNKN ] Undocumented argument [gpointer] * Arg: value [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * */ # line 547 "hsphandler.dy" void linearise_HSPset_flat(gpointer key,gpointer value,gpointer user_data) { LinearHSPmanager * l = (LinearHSPmanager *) user_data; HSPset * s = (HSPset *) value; int i; s->score = 0; s->best_score =0; for(i=0;ilen;i++) { s->score += s->hsp[i]->score; if( s->hsp[i]->score > s->best_score ) { s->best_score = s->hsp[i]->score; } } add_LinearHSPmanager(l,hard_link_HSPset(s)); } /* Function: linearise_HSPset_consistent(key,value,user_data) * * Descrip: internal function for remapping HSPs * * * Arg: key [UNKN ] Undocumented argument [gpointer] * Arg: value [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * */ # line 571 "hsphandler.dy" void linearise_HSPset_consistent(gpointer key,gpointer value,gpointer user_data) { LinearHSPmanager * l = (LinearHSPmanager *) user_data; HSPset * s = (HSPset *) value; HSPset * add; add = new_consistent_HSPset(s,l->min_score,l->width,l->tail); if( add->len > 0 ) { add_LinearHSPmanager(l,add); } else { free_HSPset(add); } } /* Function: new_HSPmanager(query,mat,score_drop_off) * * Descrip: Builds a new HSPmanager for a target system * * * Arg: query [UNKN ] Undocumented argument [Sequence *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: score_drop_off [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPmanager *] * */ # line 590 "hsphandler.dy" HSPmanager * new_HSPmanager(Sequence * query,CompMat * mat,int score_drop_off) { HSPmanager * out; out = HSPmanager_alloc(); out->query = hard_link_Sequence(query); if( mat == NULL ) { out->mat = NULL; } else { out->mat = hard_link_CompMat(mat); } out->qs = new_QuerySeqHSP(query,mat); /* out->qs = NULL; */ out->drop_off = score_drop_off; out->target_hash = g_hash_table_new(g_direct_hash,g_direct_equal); out->tsm = new_TopScoreManager(250); /* out->cache = new_HSPCache(2000);*/ out->cache = NULL; out->min_score = 25; out->hsp_count = 0; return out; } /* Function: add_pair_HSPmanager(hspm,target,query_pos,target_pos) * * Descrip: adds a new target pair, irregardless of score * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ # line 621 "hsphandler.dy" int add_pair_HSPmanager(HSPmanager * hspm,Sequence * target,int query_pos,int target_pos) { return add_pair_HSPmanager_score(hspm,target,query_pos,target_pos,-1); } /* Function: add_pair_HSPmanager_score(hspm,target,query_pos,target_pos,min_score) * * Descrip: Adds a new target pair to this HSPmanager for indexing, with a min score * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * Arg: min_score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ # line 629 "hsphandler.dy" int add_pair_HSPmanager_score(HSPmanager * hspm,Sequence * target,int query_pos,int target_pos,int min_score) { HSPset * set; int i; HSP * hsp; boolean has_set = 0; /* see if this target is loaded into the manager */ if( (set = g_hash_table_lookup(hspm->target_hash,(gpointer)target)) != NULL ) { has_set = 1; } /* set is now the HSPset. Ensure this position is not already accounted for in the set */ if( has_set == 1 ) { if( set->last_accessed != -1 && ON_HSP_MACRO(set->hsp[set->last_accessed],query_pos,target_pos) ) { return set->hsp[set->last_accessed]->score; } for(i=0;ilen;i++) { if( ON_HSP_MACRO(set->hsp[i],query_pos,target_pos) == TRUE ) { set->last_accessed = i; return set->hsp[set->last_accessed]->score; } } } if( hspm->qs != NULL ) { hsp = new_HSP_QuerySeqHSP(hspm->cache,hspm->qs,target,query_pos,target_pos,hspm->mat,hspm->drop_off,min_score); } else { hsp = new_HSP(hspm->cache,hspm->query,target,query_pos,target_pos,hspm->mat,hspm->drop_off); } if( hsp == NULL ) { /* internal min score optimisation */ return 0; } if( hsp->score < hspm->min_score ) { /* fprintf(stderr,"hsp being lost due to min score %d\n",hsp->score); */ free_HSP(hsp); return 0; } hspm->hsp_count++; if( has_set == 0 ) { set = HSPset_alloc_std(); g_hash_table_insert(hspm->target_hash,(gpointer)target,set); } set->score += hsp->score; if( hsp->score > set->best_score ) { set->best_score = hsp->score; add_score_TopScoreManager(hspm->tsm,set->best_score); } add_HSPset(set,hsp); set->last_accessed = set->len-1; return hsp->score; } /* Function: add_new_HSP_HSPmanager(hspm,target,query_start,target_start,length,score) * * Descrip: Adds a new HSP when all info is known * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_start [UNKN ] Undocumented argument [int] * Arg: target_start [UNKN ] Undocumented argument [int] * Arg: length [UNKN ] Undocumented argument [int] * Arg: score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 700 "hsphandler.dy" boolean add_new_HSP_HSPmanager(HSPmanager * hspm,Sequence * target,int query_start,int target_start,int length,int score) { HSPset * set; HSP * hsp; /* see if this target is loaded into the manager */ if( (set = g_hash_table_lookup(hspm->target_hash,(gpointer)target)) == NULL ) { set = HSPset_alloc_std(); g_hash_table_insert(hspm->target_hash,(gpointer)target,set); } if( hspm->cache != NULL ) { hsp = HSP_alloc_cache(hspm->cache); } else { hsp = HSP_alloc(); } hsp->query = hard_link_Sequence(hspm->query); hsp->target= hard_link_Sequence(target); hsp->score = score; hsp->target_start = target_start; hsp->query_start = query_start; hsp->length = length; add_HSPset(set,hsp); return TRUE; } /* Function: free_ghash_HSPsets(key,value,user_data) * * Descrip: Frees the HSPsets * * * Arg: key [UNKN ] Undocumented argument [gpointer] * Arg: value [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * */ # line 735 "hsphandler.dy" void free_ghash_HSPsets(gpointer key,gpointer value,gpointer user_data) { int i; HSPset * val = (HSPset *) value; HSPCache * cache = (HSPCache*) user_data; if( val->dynamite_hard_link > 1 ) { val->dynamite_hard_link--; return; } if( cache != NULL ) { for(i=0;ilen;i++) { free_HSP_cache(cache,val->hsp[i]); } val->len = 0; } free_HSPset(val); } /* Function: free_HSPmanager(h) * * Descrip: Frees the HSPmanager * * * Arg: h [UNKN ] Undocumented argument [HSPmanager *] * * Return [UNKN ] Undocumented return value [HSPmanager *] * */ # line 760 "hsphandler.dy" HSPmanager * free_HSPmanager(HSPmanager * h) { g_hash_table_foreach(h->target_hash,free_ghash_HSPsets,h->cache); g_hash_table_destroy(h->target_hash); free_CompMat(h->mat); if( h->tsm != NULL ) { free_TopScoreManager(h->tsm); } if( h->qs != NULL ) { free_QuerySeqHSP(h->qs); } ckfree(h); return NULL; } /* Function: new_HSP_QuerySeqHSP(cache,query,target,query_pos,target_pos,mat,score_drop_off,min_score) * * Descrip: builds a new HSP for these sequences * * * Arg: cache [UNKN ] Undocumented argument [HSPCache *] * Arg: query [UNKN ] Undocumented argument [QuerySeqHSP *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: score_drop_off [UNKN ] Undocumented argument [int] * Arg: min_score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSP *] * */ # line 780 "hsphandler.dy" HSP * new_HSP_QuerySeqHSP(HSPCache * cache,QuerySeqHSP * query,Sequence * target,int query_pos,int target_pos,CompMat * mat,int score_drop_off,int min_score) { int i,j; int ii,jj; int temp_score; int t; int pause_i,pause_j; int score = 0; HSP * out = NULL; const char * q_seq; const char * t_seq; const int * self_score; int overall_score; int query_start; int target_start; /* we count the start position twice */ overall_score = -(query->score[query_pos][target->seq[target_pos]-'A']); q_seq = query->query->seq; t_seq = target->seq; self_score = query->self_score; pause_i = i = query_pos; pause_j = j = target_pos; /* go upstream first */ for(score=0;i >= 0 && j >= 0;i--,j--) { /* optimise identical matches */ if( toupper(q_seq[i]) == toupper(t_seq[j]) ) { score += self_score[i]; continue; } t= query->score[i][target->seq[j]-'A']; if( t >= 0 ) { /* this is a positive score, we are on a high scoring run, so add and move on*/ score += t; } else { /* negative score. i+1,j+1 was our last best score */ for(temp_score = t,ii=i-1,jj=j-1;temp_score >= -score_drop_off && ii >= 0 && jj >= 0 && temp_score < 0;ii--,jj--) { temp_score += query->score[ii][target->seq[jj]-'A']; } if( temp_score >= 0 ) { /* new maximum reached */ i = ii; j = jj; score += temp_score; continue; /* back to main loop */ } else { /* either temp_score < -drop_off or something else */ break; } } } /* set start position */ query_start = i+1; target_start = j+1; overall_score += score; /* downstream */ for(score=0,i=query_pos,j=target_pos;i < query->len && j < target->len;i++,j++) { /* optimise identical matches */ if( toupper(q_seq[i]) == toupper(t_seq[j]) ) { score += self_score[i]; continue; } t= query->score[i][target->seq[j]-'A']; /* fprintf(stderr,"Doing %d %d, [%c,%c] off %d score %d\n",i,j,query->query->seq[i],target->seq[j],t,score); */ if( t >= 0 ) { /* this is a positive score, we are on a high scoring run, so add and move on*/ score += t; } else { /* negative score. i-1,j-1 was our last best score */ for(temp_score = t,ii=i+1,jj=j+1;temp_score >= -score_drop_off && ii < query->len && jj < target->len && temp_score < 0;ii++,jj++) { temp_score += query->score[ii][target->seq[jj]-'A']; /* fprintf(stderr,"Negative looping %d,%d temp %d [%c,%c]\n",ii,jj,temp_score,query->query->seq[ii],target->seq[jj]); */ } if( temp_score >= 0 ) { /* new good score reached */ i = ii; j = jj; score += temp_score; continue; /* back to main loop */ } else { /* either temp_score < -drop_off or something else */ break; } } } if( overall_score + score < min_score ) { return NULL; } /* we have a valid HSP. Ask for memory and return */ if( cache != NULL ) { out = HSP_alloc_cache(cache); } else { out = HSP_alloc(); } out->query_start = query_start; out->target_start = target_start; out->score = overall_score + score; out->query = hard_link_Sequence(query->query); out->target= hard_link_Sequence(target); /* set length and score */ out->length = i-1 - out->query_start +1; return out; } /* Function: new_QuerySeqHSP(seq,mat) * * Descrip: Builds a new QuerySeqHSP from Sequence and Matrix * * * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * * Return [UNKN ] Undocumented return value [QuerySeqHSP *] * */ # line 922 "hsphandler.dy" QuerySeqHSP * new_QuerySeqHSP(Sequence * seq,CompMat * mat) { QuerySeqHSP * out; int i; assert(seq); assert(mat); out = QuerySeqHSP_alloc(); out->query = hard_link_Sequence(seq); out->score = (int **)calloc(seq->len,sizeof(int*)); out->self_score = (int*) calloc(seq->len,sizeof(int)); out->len = seq->len; for(i=0;ilen;i++) { out->score[i] = mat->comp[toupper(seq->seq[i])-'A']; out->self_score[i] = mat->comp[toupper(seq->seq[i])-'A'][toupper(seq->seq[i])-'A']; } return out; } # line 1047 "hsphandler.c" /* Function: hard_link_TopScoreManager(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TopScoreManager *] * * Return [UNKN ] Undocumented return value [TopScoreManager *] * */ TopScoreManager * hard_link_TopScoreManager(TopScoreManager * obj) { if( obj == NULL ) { warn("Trying to hard link to a TopScoreManager object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TopScoreManager_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TopScoreManager *] * */ TopScoreManager * TopScoreManager_alloc(void) { TopScoreManager * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TopScoreManager *) ckalloc (sizeof(TopScoreManager))) == NULL) { warn("TopScoreManager_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->score = NULL; out->length = 0; out->current_pos = 0; out->worst_score = 0; out->worst_position = 0; return out; } /* Function: free_TopScoreManager(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TopScoreManager *] * * Return [UNKN ] Undocumented return value [TopScoreManager *] * */ TopScoreManager * free_TopScoreManager(TopScoreManager * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a TopScoreManager obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->score != NULL) ckfree(obj->score); ckfree(obj); return NULL; } /* Function: hard_link_QuerySeqHSP(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [QuerySeqHSP *] * * Return [UNKN ] Undocumented return value [QuerySeqHSP *] * */ QuerySeqHSP * hard_link_QuerySeqHSP(QuerySeqHSP * obj) { if( obj == NULL ) { warn("Trying to hard link to a QuerySeqHSP object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: QuerySeqHSP_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [QuerySeqHSP *] * */ QuerySeqHSP * QuerySeqHSP_alloc(void) { QuerySeqHSP * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(QuerySeqHSP *) ckalloc (sizeof(QuerySeqHSP))) == NULL) { warn("QuerySeqHSP_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->query = NULL; out->self_score = NULL; out->len = 0; return out; } /* Function: free_QuerySeqHSP(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [QuerySeqHSP *] * * Return [UNKN ] Undocumented return value [QuerySeqHSP *] * */ QuerySeqHSP * free_QuerySeqHSP(QuerySeqHSP * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a QuerySeqHSP obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->query != NULL) free_Sequence(obj->query); /* obj->score is linked in */ if( obj->self_score != NULL) ckfree(obj->self_score); ckfree(obj); return NULL; } /* Function: hard_link_HSPmanager(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPmanager *] * * Return [UNKN ] Undocumented return value [HSPmanager *] * */ HSPmanager * hard_link_HSPmanager(HSPmanager * obj) { if( obj == NULL ) { warn("Trying to hard link to a HSPmanager object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HSPmanager_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPmanager *] * */ HSPmanager * HSPmanager_alloc(void) { HSPmanager * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HSPmanager *) ckalloc (sizeof(HSPmanager))) == NULL) { warn("HSPmanager_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->query = NULL; out->mat = NULL; out->drop_off = 0; out->min_score = 0; out->tsm = NULL; out->qs = NULL; out->cache = NULL; out->hsp_count = 0; return out; } /* Function: hard_link_LineariseHSPPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LineariseHSPPara *] * * Return [UNKN ] Undocumented return value [LineariseHSPPara *] * */ LineariseHSPPara * hard_link_LineariseHSPPara(LineariseHSPPara * obj) { if( obj == NULL ) { warn("Trying to hard link to a LineariseHSPPara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: LineariseHSPPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LineariseHSPPara *] * */ LineariseHSPPara * LineariseHSPPara_alloc(void) { LineariseHSPPara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(LineariseHSPPara *) ckalloc (sizeof(LineariseHSPPara))) == NULL) { warn("LineariseHSPPara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->max_size = 0; out->min_score = 0; out->width = 0; out->tail = 0; out->verbosity = 0; return out; } /* Function: free_LineariseHSPPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LineariseHSPPara *] * * Return [UNKN ] Undocumented return value [LineariseHSPPara *] * */ LineariseHSPPara * free_LineariseHSPPara(LineariseHSPPara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a LineariseHSPPara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/hsphandler.h0000644000175000001440000004321310670453712017142 0ustar philippusers#ifndef DYNAMITEhsphandlerHEADERFILE #define DYNAMITEhsphandlerHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #include "compmat.h" #include "glib.h" #include "hsp.h" #define UNFEASIBLY_LARGE_SCORE 1000000 struct Wise2_TopScoreManager { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int * score; int length; int current_pos; int worst_score; int worst_position; } ; /* TopScoreManager defined */ #ifndef DYNAMITE_DEFINED_TopScoreManager typedef struct Wise2_TopScoreManager Wise2_TopScoreManager; #define TopScoreManager Wise2_TopScoreManager #define DYNAMITE_DEFINED_TopScoreManager #endif struct Wise2_QuerySeqHSP { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence * query; int ** score; int * self_score; int len; } ; /* QuerySeqHSP defined */ #ifndef DYNAMITE_DEFINED_QuerySeqHSP typedef struct Wise2_QuerySeqHSP Wise2_QuerySeqHSP; #define QuerySeqHSP Wise2_QuerySeqHSP #define DYNAMITE_DEFINED_QuerySeqHSP #endif struct Wise2_HSPmanager { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GHashTable * target_hash; Sequence * query; CompMat * mat; int drop_off; int min_score; TopScoreManager * tsm; QuerySeqHSP * qs; HSPCache * cache; int hsp_count; } ; /* HSPmanager defined */ #ifndef DYNAMITE_DEFINED_HSPmanager typedef struct Wise2_HSPmanager Wise2_HSPmanager; #define HSPmanager Wise2_HSPmanager #define DYNAMITE_DEFINED_HSPmanager #endif struct Wise2_LineariseHSPPara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int max_size; int min_score; int width; int tail; int verbosity; } ; /* LineariseHSPPara defined */ #ifndef DYNAMITE_DEFINED_LineariseHSPPara typedef struct Wise2_LineariseHSPPara Wise2_LineariseHSPPara; #define LineariseHSPPara Wise2_LineariseHSPPara #define DYNAMITE_DEFINED_LineariseHSPPara #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_TopScoreManager(length) * * Descrip: Makes a new topscore manager of a specific length * * * Arg: length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [TopScoreManager *] * */ TopScoreManager * Wise2_new_TopScoreManager(int length); #define new_TopScoreManager Wise2_new_TopScoreManager /* Function: add_score_TopScoreManager(tsm,score) * * Descrip: Adds a top score * * * Arg: tsm [UNKN ] Undocumented argument [TopScoreManager *] * Arg: score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_score_TopScoreManager(TopScoreManager * tsm,int score); #define add_score_TopScoreManager Wise2_add_score_TopScoreManager /* Function: truncated_simple_LinearHSPmanager(lm,para) * * Descrip: A simpler truncation method, using diagonals * * * Arg: lm [UNKN ] Undocumented argument [LinearHSPmanager *] * Arg: para [UNKN ] Undocumented argument [LineariseHSPPara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_truncated_simple_LinearHSPmanager(LinearHSPmanager * lm,LineariseHSPPara * para); #define truncated_simple_LinearHSPmanager Wise2_truncated_simple_LinearHSPmanager /* Function: truncated_LinearHSPmanager(lm,max_size,min_score,width,tail) * * Descrip: Makes a truncated linear set * * * Arg: lm [UNKN ] Undocumented argument [LinearHSPmanager *] * Arg: max_size [UNKN ] Undocumented argument [int] * Arg: min_score [UNKN ] Undocumented argument [int] * Arg: width [UNKN ] Undocumented argument [int] * Arg: tail [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_truncated_LinearHSPmanager(LinearHSPmanager * lm,int max_size,int min_score,int width,int tail); #define truncated_LinearHSPmanager Wise2_truncated_LinearHSPmanager /* Function: new_consistent_HSPset(set,min_score,width,tail) * * Descrip: Makes an HSP set via heuristics * to deal with low complexity regions * * * Arg: set [UNKN ] Undocumented argument [HSPset *] * Arg: min_score [UNKN ] Undocumented argument [int] * Arg: width [UNKN ] Undocumented argument [int] * Arg: tail [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPset *] * */ HSPset * Wise2_new_consistent_HSPset(HSPset * set,int min_score,int width,int tail); #define new_consistent_HSPset Wise2_new_consistent_HSPset /* Function: new_LinearHSPmanager_simple_heuristic(hspm,para) * * Descrip: New, simpler LinearHSPmanager with diagonal heuristics * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * Arg: para [UNKN ] Undocumented argument [LineariseHSPPara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_new_LinearHSPmanager_simple_heuristic(HSPmanager * hspm,LineariseHSPPara * para); #define new_LinearHSPmanager_simple_heuristic Wise2_new_LinearHSPmanager_simple_heuristic /* Function: new_LinearHSPmanager_heuristic_max(hspm,max_size) * * Descrip: Builds a new LinearHSPmanager from hash based with heuristics * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * Arg: max_size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_new_LinearHSPmanager_heuristic_max(HSPmanager * hspm,int max_size); #define new_LinearHSPmanager_heuristic_max Wise2_new_LinearHSPmanager_heuristic_max /* Function: new_LinearHSPmanager_truncate_on_score(hspm) * * Descrip: Builds a LinearHSPmanager from a hash based HSP manager, using worst score truncation * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_new_LinearHSPmanager_truncate_on_score(HSPmanager * hspm); #define new_LinearHSPmanager_truncate_on_score Wise2_new_LinearHSPmanager_truncate_on_score /* Function: new_LinearHSPmanager_flat(hspm) * * Descrip: Builds a LinearHSPmanager from a hash based HSP manager * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_new_LinearHSPmanager_flat(HSPmanager * hspm); #define new_LinearHSPmanager_flat Wise2_new_LinearHSPmanager_flat /* Function: linearise_HSPset_truncate_on_score(key,value,user_data) * * Descrip: internal function for remapping HSPs * * * Arg: key [UNKN ] Undocumented argument [gpointer] * Arg: value [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * */ void Wise2_linearise_HSPset_truncate_on_score(gpointer key,gpointer value,gpointer user_data); #define linearise_HSPset_truncate_on_score Wise2_linearise_HSPset_truncate_on_score /* Function: linearise_HSPset_flat(key,value,user_data) * * Descrip: internal function for remapping HSPs with score cutoff * * * Arg: key [UNKN ] Undocumented argument [gpointer] * Arg: value [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * */ void Wise2_linearise_HSPset_flat(gpointer key,gpointer value,gpointer user_data); #define linearise_HSPset_flat Wise2_linearise_HSPset_flat /* Function: linearise_HSPset_consistent(key,value,user_data) * * Descrip: internal function for remapping HSPs * * * Arg: key [UNKN ] Undocumented argument [gpointer] * Arg: value [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * */ void Wise2_linearise_HSPset_consistent(gpointer key,gpointer value,gpointer user_data); #define linearise_HSPset_consistent Wise2_linearise_HSPset_consistent /* Function: new_HSPmanager(query,mat,score_drop_off) * * Descrip: Builds a new HSPmanager for a target system * * * Arg: query [UNKN ] Undocumented argument [Sequence *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: score_drop_off [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPmanager *] * */ HSPmanager * Wise2_new_HSPmanager(Sequence * query,CompMat * mat,int score_drop_off); #define new_HSPmanager Wise2_new_HSPmanager /* Function: add_pair_HSPmanager(hspm,target,query_pos,target_pos) * * Descrip: adds a new target pair, irregardless of score * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_add_pair_HSPmanager(HSPmanager * hspm,Sequence * target,int query_pos,int target_pos); #define add_pair_HSPmanager Wise2_add_pair_HSPmanager /* Function: add_pair_HSPmanager_score(hspm,target,query_pos,target_pos,min_score) * * Descrip: Adds a new target pair to this HSPmanager for indexing, with a min score * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * Arg: min_score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_add_pair_HSPmanager_score(HSPmanager * hspm,Sequence * target,int query_pos,int target_pos,int min_score); #define add_pair_HSPmanager_score Wise2_add_pair_HSPmanager_score /* Function: add_new_HSP_HSPmanager(hspm,target,query_start,target_start,length,score) * * Descrip: Adds a new HSP when all info is known * * * Arg: hspm [UNKN ] Undocumented argument [HSPmanager *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_start [UNKN ] Undocumented argument [int] * Arg: target_start [UNKN ] Undocumented argument [int] * Arg: length [UNKN ] Undocumented argument [int] * Arg: score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_new_HSP_HSPmanager(HSPmanager * hspm,Sequence * target,int query_start,int target_start,int length,int score); #define add_new_HSP_HSPmanager Wise2_add_new_HSP_HSPmanager /* Function: free_ghash_HSPsets(key,value,user_data) * * Descrip: Frees the HSPsets * * * Arg: key [UNKN ] Undocumented argument [gpointer] * Arg: value [UNKN ] Undocumented argument [gpointer] * Arg: user_data [UNKN ] Undocumented argument [gpointer] * */ void Wise2_free_ghash_HSPsets(gpointer key,gpointer value,gpointer user_data); #define free_ghash_HSPsets Wise2_free_ghash_HSPsets /* Function: free_HSPmanager(h) * * Descrip: Frees the HSPmanager * * * Arg: h [UNKN ] Undocumented argument [HSPmanager *] * * Return [UNKN ] Undocumented return value [HSPmanager *] * */ HSPmanager * Wise2_free_HSPmanager(HSPmanager * h); #define free_HSPmanager Wise2_free_HSPmanager /* Function: new_HSP_QuerySeqHSP(cache,query,target,query_pos,target_pos,mat,score_drop_off,min_score) * * Descrip: builds a new HSP for these sequences * * * Arg: cache [UNKN ] Undocumented argument [HSPCache *] * Arg: query [UNKN ] Undocumented argument [QuerySeqHSP *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: score_drop_off [UNKN ] Undocumented argument [int] * Arg: min_score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSP *] * */ HSP * Wise2_new_HSP_QuerySeqHSP(HSPCache * cache,QuerySeqHSP * query,Sequence * target,int query_pos,int target_pos,CompMat * mat,int score_drop_off,int min_score); #define new_HSP_QuerySeqHSP Wise2_new_HSP_QuerySeqHSP /* Function: new_QuerySeqHSP(seq,mat) * * Descrip: Builds a new QuerySeqHSP from Sequence and Matrix * * * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * * Return [UNKN ] Undocumented return value [QuerySeqHSP *] * */ QuerySeqHSP * Wise2_new_QuerySeqHSP(Sequence * seq,CompMat * mat); #define new_QuerySeqHSP Wise2_new_QuerySeqHSP /* Function: hard_link_TopScoreManager(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TopScoreManager *] * * Return [UNKN ] Undocumented return value [TopScoreManager *] * */ TopScoreManager * Wise2_hard_link_TopScoreManager(TopScoreManager * obj); #define hard_link_TopScoreManager Wise2_hard_link_TopScoreManager /* Function: TopScoreManager_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TopScoreManager *] * */ TopScoreManager * Wise2_TopScoreManager_alloc(void); #define TopScoreManager_alloc Wise2_TopScoreManager_alloc /* Function: free_TopScoreManager(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [TopScoreManager *] * * Return [UNKN ] Undocumented return value [TopScoreManager *] * */ TopScoreManager * Wise2_free_TopScoreManager(TopScoreManager * obj); #define free_TopScoreManager Wise2_free_TopScoreManager /* Function: hard_link_QuerySeqHSP(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [QuerySeqHSP *] * * Return [UNKN ] Undocumented return value [QuerySeqHSP *] * */ QuerySeqHSP * Wise2_hard_link_QuerySeqHSP(QuerySeqHSP * obj); #define hard_link_QuerySeqHSP Wise2_hard_link_QuerySeqHSP /* Function: QuerySeqHSP_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [QuerySeqHSP *] * */ QuerySeqHSP * Wise2_QuerySeqHSP_alloc(void); #define QuerySeqHSP_alloc Wise2_QuerySeqHSP_alloc /* Function: free_QuerySeqHSP(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [QuerySeqHSP *] * * Return [UNKN ] Undocumented return value [QuerySeqHSP *] * */ QuerySeqHSP * Wise2_free_QuerySeqHSP(QuerySeqHSP * obj); #define free_QuerySeqHSP Wise2_free_QuerySeqHSP /* Function: hard_link_HSPmanager(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPmanager *] * * Return [UNKN ] Undocumented return value [HSPmanager *] * */ HSPmanager * Wise2_hard_link_HSPmanager(HSPmanager * obj); #define hard_link_HSPmanager Wise2_hard_link_HSPmanager /* Function: HSPmanager_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPmanager *] * */ HSPmanager * Wise2_HSPmanager_alloc(void); #define HSPmanager_alloc Wise2_HSPmanager_alloc /* Function: hard_link_LineariseHSPPara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [LineariseHSPPara *] * * Return [UNKN ] Undocumented return value [LineariseHSPPara *] * */ LineariseHSPPara * Wise2_hard_link_LineariseHSPPara(LineariseHSPPara * obj); #define hard_link_LineariseHSPPara Wise2_hard_link_LineariseHSPPara /* Function: LineariseHSPPara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [LineariseHSPPara *] * */ LineariseHSPPara * Wise2_LineariseHSPPara_alloc(void); #define LineariseHSPPara_alloc Wise2_LineariseHSPPara_alloc /* Function: free_LineariseHSPPara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [LineariseHSPPara *] * * Return [UNKN ] Undocumented return value [LineariseHSPPara *] * */ LineariseHSPPara * Wise2_free_LineariseHSPPara(LineariseHSPPara * obj); #define free_LineariseHSPPara Wise2_free_LineariseHSPPara /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/hspscaninterface.c0000644000175000001440000003103410670453712020323 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "hspscaninterface.h" /* Function: untyped_read_HSPScanInterfacePara_from_Stream(rs) * * Descrip: untyped version of read * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [void *] * */ # line 43 "hspscaninterface.dy" void * untyped_read_HSPScanInterfacePara_from_Stream(Wise2ReadStreamInterface * rs) { return (void*) typed_HSPScanInterfacePara_from_Stream(rs); } /* Function: typed_HSPScanInterfacePara_from_Stream(rs) * * Descrip: reads a HSPscan interface para from a stream * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [HSPScanInterfacePara *] * */ # line 51 "hspscaninterface.dy" HSPScanInterfacePara * typed_HSPScanInterfacePara_from_Stream(Wise2ReadStreamInterface * rs) { char buffer[MAXLINE]; HSPScanInterfacePara * out; out = HSPScanInterfacePara_std(); while( WISE2_READ_BUFFER(buffer,MAXLINE,rs) != NULL ) { if( buffer[0] == '/' && buffer[1] == '/' ) { break; } if( strstartcmp(buffer,"numb") == 0 ) { out->numb_level = strtol(buffer+5,NULL,0); } else if ( strstartcmp(buffer,"maxresults") == 0 ) { out->max_results = strtol(buffer+11,NULL,0); } else if ( strstartcmp(buffer,"worddepth") == 0 ) { out->word_depth = strtol(buffer+10,NULL,0); } else if ( strstartcmp(buffer,"minword") == 0 ) { out->min_word_score = strtol(buffer+8,NULL,0); } else if ( strstartcmp(buffer,"minhsp") == 0 ) { out->min_hsp_score = strtol(buffer+7,NULL,0); } else if ( strstartcmp(buffer,"impl") == 0 ) { out->implementation = strtol(buffer+5,NULL,0); } else if ( strstartcmp(buffer,"linkwidth") == 0 ) { out->hsp_link_width = strtol(buffer+10,NULL,0); } else if ( strstartcmp(buffer,"linklength") == 0 ) { out->hsp_link_length = strtol(buffer+11,NULL,0); } else if ( strstartcmp(buffer,"impl") == 0 ) { out->implementation = strtol(buffer+5,NULL,0); } else if ( strstartcmp(buffer,"verbose") == 0 ) { out->verbosity = strtol(buffer+8,NULL,0); } else if ( strstartcmp(buffer,"lownumb") == 0 ) { out->low_numb = strtol(buffer+8,NULL,0); } else if ( strstartcmp(buffer,"havgext") == 0 ) { out->hsp_avg_ext = strtol(buffer+8,NULL,0); } else { warn("In reading HspScanInterfacePara, unknown line %s",buffer); } } return out; } /* Function: untyped_HSPScanInterfacePara_to_Stream(p,ws) * * Descrip: writes out a standard HSPscan interface * * * Arg: p [UNKN ] Undocumented argument [void *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ # line 100 "hspscaninterface.dy" void untyped_HSPScanInterfacePara_to_Stream(void * p,Wise2WriteStreamInterface * ws) { HSPScanInterfacePara * h = (HSPScanInterfacePara *) p; char buffer[MAXLINE]; sprintf(buffer,"numb %d\n",h->numb_level); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"maxresults %d\n",h->max_results); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"worddepth %d\n",h->word_depth); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"minword %d\n",h->min_word_score); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"minhsp %d\n",h->min_hsp_score); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"linkwidth %d\n",h->hsp_link_width); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"linklength %d\n",h->hsp_link_length); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"impl %d\n",h->implementation); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"verbose %d\n",h->verbosity); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"lownumb %d\n",h->low_numb); WISE2_WRITE_STRING(buffer,ws); WISE2_WRITE_STRING("//\n",ws); } /* Function: untyped_HSPScanInterfacePara_free(p) * * Descrip: untyped free function for AnonymousObjects * * * Arg: p [UNKN ] Undocumented argument [void *] * */ # line 143 "hspscaninterface.dy" void untyped_HSPScanInterfacePara_free(void * p) { HSPScanInterfacePara * h; h = (HSPScanInterfacePara *) p; free_HSPScanInterfacePara(h); } /* Function: show_help_HSPScanInterfacePara(ofp) * * Descrip: help function for hspscan interface para * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 157 "hspscaninterface.dy" void show_help_HSPScanInterfacePara(FILE * ofp) { fprintf(ofp,"Parameters for word scan\n"); fprintf(ofp," -hspscan_impl [vanilla/threaded/twohit] implementation to use if compliled for runtime\n"); fprintf(ofp," -hspscan_maxres [100] maximum results returned by scan\n"); fprintf(ofp," -hspscan_numb [1000] word count to numb word (for low complexity)\n"); fprintf(ofp," -hspscan_worddepth [2] maximum offset from word - [0,1,2]\n"); fprintf(ofp," -hspscan_minword [14] minimum word score\n"); fprintf(ofp," -hspscan_minhsp [22] minimum hsp score\n"); fprintf(ofp," -hspscan_link_width [30] max width (gap) of scored HSP chain\n"); fprintf(ofp," -hspscan_link_length [150] max length of scored HSP chain\n"); fprintf(ofp," -hspscan_verbosity [0] verbosity level of server, if server is trace compiled\n"); fprintf(ofp," -hspscan_lownumb [0] low complexity numb level, 0 means no special low complexity scores\n"); fprintf(ofp," -hspscan_avgext [-6] average extension minimum in hsp extension\n"); } /* Function: new_HSPScanInterfacePara_from_argv(argc,argv) * * Descrip: makes a hspscan interface from the command line * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [HSPScanInterfacePara *] * */ # line 177 "hspscaninterface.dy" HSPScanInterfacePara * new_HSPScanInterfacePara_from_argv(int * argc,char ** argv) { char * temp; HSPScanInterfacePara * out; out = HSPScanInterfacePara_std(); if( (temp = strip_out_assigned_argument(argc,argv,"hspscan_impl")) != NULL ) { if( strcmp(temp,"vanilla") == 0 ) { out->implementation = HSPSCAN_IMPLEMENTATION_VANILLA; } else if ( strcmp(temp,"threaded") == 0 ) { out->implementation = HSPSCAN_IMPLEMENTATION_THREADED; } else if ( strcmp(temp,"twohit") == 0 ) { out->implementation = HSPSCAN_IMPLEMENTATION_TWOHIT; } else { fatal("Cannot parse %s as an implementation, exiting early before this gets snarled up",temp); } } strip_out_integer_argument(argc,argv,"hspscan_maxres",&out->max_results); strip_out_integer_argument(argc,argv,"hspscan_numb",&out->numb_level); strip_out_integer_argument(argc,argv,"hspscan_worddepth",&out->word_depth); strip_out_integer_argument(argc,argv,"hspscan_minword",&out->min_word_score); strip_out_integer_argument(argc,argv,"hspscan_minhsp",&out->min_hsp_score); strip_out_integer_argument(argc,argv,"hspscan_link_width",&out->hsp_link_width); strip_out_integer_argument(argc,argv,"hspscan_link_length",&out->hsp_link_length); strip_out_integer_argument(argc,argv,"hspscan_verbosity",&out->verbosity); strip_out_integer_argument(argc,argv,"hspscan_lownumb",&out->low_numb); strip_out_integer_argument(argc,argv,"hspscan_avgext",&out->hsp_avg_ext); return out; } /* Function: HSPScanInterfacePara_std(void) * * Descrip: makes a standard hsp scan interface para * * * * Return [UNKN ] Undocumented return value [HSPScanInterfacePara *] * */ # line 216 "hspscaninterface.dy" HSPScanInterfacePara * HSPScanInterfacePara_std(void) { HSPScanInterfacePara * out; out = HSPScanInterfacePara_alloc(); out->min_score = 20; out->max_results = 100; out->use_protein_heuristic = TRUE; out->numb_level = 1000; out->word_depth = 2; out->min_word_score = 14; out->min_hsp_score = 22; out->hsp_link_width = 30; out->hsp_link_length = 150; out->hsp_avg_ext = -6; out->implementation = HSPSCAN_IMPLEMENTATION_VANILLA; out->verbosity = 0; out->low_numb = 0; return out; } /* Function: free_HSPScanInterface(hsi) * * Descrip: Frees overrides dynamite default * * * Arg: hsi [UNKN ] Undocumented argument [HSPScanInterface *] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ # line 244 "hspscaninterface.dy" HSPScanInterface * free_HSPScanInterface(HSPScanInterface * hsi) { if( hsi == NULL ) { return NULL; } (*hsi->free_data)(hsi->data); ckfree(hsi); return NULL; } # line 267 "hspscaninterface.c" /* Function: hard_link_HSPScanInterfacePara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [HSPScanInterfacePara *] * */ HSPScanInterfacePara * hard_link_HSPScanInterfacePara(HSPScanInterfacePara * obj) { if( obj == NULL ) { warn("Trying to hard link to a HSPScanInterfacePara object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HSPScanInterfacePara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPScanInterfacePara *] * */ HSPScanInterfacePara * HSPScanInterfacePara_alloc(void) { HSPScanInterfacePara * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HSPScanInterfacePara *) ckalloc (sizeof(HSPScanInterfacePara))) == NULL) { warn("HSPScanInterfacePara_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->min_score = 0; out->max_results = 0; out->flags = 0; out->use_protein_heuristic = TRUE; out->numb_level = 1000; out->word_depth = 2; out->min_word_score = 14; out->min_hsp_score = 22; out->implementation = HSPSCAN_IMPLEMENTATION_VANILLA; out->hsp_link_width = 30; out->hsp_link_length = 150; out->verbosity = 0; out->low_numb = 0; out->hsp_avg_ext = -6; return out; } /* Function: free_HSPScanInterfacePara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [HSPScanInterfacePara *] * */ HSPScanInterfacePara * free_HSPScanInterfacePara(HSPScanInterfacePara * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HSPScanInterfacePara obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_HSPScanInterface(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPScanInterface *] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ HSPScanInterface * hard_link_HSPScanInterface(HSPScanInterface * obj) { if( obj == NULL ) { warn("Trying to hard link to a HSPScanInterface object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HSPScanInterface_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ HSPScanInterface * HSPScanInterface_alloc(void) { HSPScanInterface * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HSPScanInterface *) ckalloc (sizeof(HSPScanInterface))) == NULL) { warn("HSPScanInterface_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->scan_query = NULL; out->free_data = NULL; return out; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/hspscaninterface.h0000644000175000001440000001644210670453712020336 0ustar philippusers#ifndef DYNAMITEhspscaninterfaceHEADERFILE #define DYNAMITEhspscaninterfaceHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "hsp.h" #define HSPSCAN_IMPLEMENTATION_VANILLA 10 #define HSPSCAN_IMPLEMENTATION_THREADED 11 #define HSPSCAN_IMPLEMENTATION_TWOHIT 12 struct Wise2_HSPScanInterfacePara { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int min_score; int max_results; int flags; boolean use_protein_heuristic; int numb_level; int word_depth; int min_word_score; int min_hsp_score; int implementation; int hsp_link_width; int hsp_link_length; int verbosity; int low_numb; int hsp_avg_ext; } ; /* HSPScanInterfacePara defined */ #ifndef DYNAMITE_DEFINED_HSPScanInterfacePara typedef struct Wise2_HSPScanInterfacePara Wise2_HSPScanInterfacePara; #define HSPScanInterfacePara Wise2_HSPScanInterfacePara #define DYNAMITE_DEFINED_HSPScanInterfacePara #endif struct Wise2_HSPScanInterface { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif LinearHSPmanager * (*scan_query)(void *,Sequence *,HSPScanInterfacePara * para); void (*free_data)(void*); void * data; } ; /* HSPScanInterface defined */ #ifndef DYNAMITE_DEFINED_HSPScanInterface typedef struct Wise2_HSPScanInterface Wise2_HSPScanInterface; #define HSPScanInterface Wise2_HSPScanInterface #define DYNAMITE_DEFINED_HSPScanInterface #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: untyped_read_HSPScanInterfacePara_from_Stream(rs) * * Descrip: untyped version of read * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [void *] * */ void * Wise2_untyped_read_HSPScanInterfacePara_from_Stream(Wise2ReadStreamInterface * rs); #define untyped_read_HSPScanInterfacePara_from_Stream Wise2_untyped_read_HSPScanInterfacePara_from_Stream /* Function: typed_HSPScanInterfacePara_from_Stream(rs) * * Descrip: reads a HSPscan interface para from a stream * * * Arg: rs [UNKN ] Undocumented argument [Wise2ReadStreamInterface *] * * Return [UNKN ] Undocumented return value [HSPScanInterfacePara *] * */ HSPScanInterfacePara * Wise2_typed_HSPScanInterfacePara_from_Stream(Wise2ReadStreamInterface * rs); #define typed_HSPScanInterfacePara_from_Stream Wise2_typed_HSPScanInterfacePara_from_Stream /* Function: untyped_HSPScanInterfacePara_to_Stream(p,ws) * * Descrip: writes out a standard HSPscan interface * * * Arg: p [UNKN ] Undocumented argument [void *] * Arg: ws [UNKN ] Undocumented argument [Wise2WriteStreamInterface *] * */ void Wise2_untyped_HSPScanInterfacePara_to_Stream(void * p,Wise2WriteStreamInterface * ws); #define untyped_HSPScanInterfacePara_to_Stream Wise2_untyped_HSPScanInterfacePara_to_Stream /* Function: untyped_HSPScanInterfacePara_free(p) * * Descrip: untyped free function for AnonymousObjects * * * Arg: p [UNKN ] Undocumented argument [void *] * */ void Wise2_untyped_HSPScanInterfacePara_free(void * p); #define untyped_HSPScanInterfacePara_free Wise2_untyped_HSPScanInterfacePara_free /* Function: show_help_HSPScanInterfacePara(ofp) * * Descrip: help function for hspscan interface para * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_help_HSPScanInterfacePara(FILE * ofp); #define show_help_HSPScanInterfacePara Wise2_show_help_HSPScanInterfacePara /* Function: new_HSPScanInterfacePara_from_argv(argc,argv) * * Descrip: makes a hspscan interface from the command line * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [HSPScanInterfacePara *] * */ HSPScanInterfacePara * Wise2_new_HSPScanInterfacePara_from_argv(int * argc,char ** argv); #define new_HSPScanInterfacePara_from_argv Wise2_new_HSPScanInterfacePara_from_argv /* Function: HSPScanInterfacePara_std(void) * * Descrip: makes a standard hsp scan interface para * * * * Return [UNKN ] Undocumented return value [HSPScanInterfacePara *] * */ HSPScanInterfacePara * Wise2_HSPScanInterfacePara_std(void); #define HSPScanInterfacePara_std Wise2_HSPScanInterfacePara_std /* Function: free_HSPScanInterface(hsi) * * Descrip: Frees overrides dynamite default * * * Arg: hsi [UNKN ] Undocumented argument [HSPScanInterface *] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ HSPScanInterface * Wise2_free_HSPScanInterface(HSPScanInterface * hsi); #define free_HSPScanInterface Wise2_free_HSPScanInterface /* Function: hard_link_HSPScanInterfacePara(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [HSPScanInterfacePara *] * */ HSPScanInterfacePara * Wise2_hard_link_HSPScanInterfacePara(HSPScanInterfacePara * obj); #define hard_link_HSPScanInterfacePara Wise2_hard_link_HSPScanInterfacePara /* Function: HSPScanInterfacePara_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPScanInterfacePara *] * */ HSPScanInterfacePara * Wise2_HSPScanInterfacePara_alloc(void); #define HSPScanInterfacePara_alloc Wise2_HSPScanInterfacePara_alloc /* Function: free_HSPScanInterfacePara(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [HSPScanInterfacePara *] * */ HSPScanInterfacePara * Wise2_free_HSPScanInterfacePara(HSPScanInterfacePara * obj); #define free_HSPScanInterfacePara Wise2_free_HSPScanInterfacePara /* Function: hard_link_HSPScanInterface(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPScanInterface *] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ HSPScanInterface * Wise2_hard_link_HSPScanInterface(HSPScanInterface * obj); #define hard_link_HSPScanInterface Wise2_hard_link_HSPScanInterface /* Function: HSPScanInterface_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ HSPScanInterface * Wise2_HSPScanInterface_alloc(void); #define HSPScanInterface_alloc Wise2_HSPScanInterface_alloc /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/genericindexresult.dy0000644000175000001440000000262307621664104021103 0ustar philippusers %{ #include "seqlookup.h" %} struct GenericIndexResult SeqLookupResultStruct * result int len int max_len int current_pos %{ #include "genericindexresult.h" %func For interface, returns next position in SeqLookup Results %% SeqLookupResultStruct * next_interface_GenericIndexResult(void * data,SeqLookupResultStruct * prev) { GenericIndexResult * gir = (GenericIndexResult*)data; return &(gir->result[gir->current_pos++]); } %func For interface, indicates whether there is more stuff to find or not %% boolean is_more_interface_GenericIndexResult(void * data) { GenericIndexResult * gir = (GenericIndexResult*)data; if( gir->current_pos < gir->len ) { return TRUE; } return FALSE; } %func Frees the data %% void free_noop_GenericIndexResult(void * data) { return; } %func Adds another result to a IndexResult %% void add_GenericIndexResult(GenericIndexResult * gir,Sequence * seq,int pos) { assert(gir); assert(seq); if( gir->len >= gir->max_len ) { gir->result = realloc(gir->result,2*gir->max_len*sizeof(SeqLookupResultStruct)); gir->max_len = 2* gir->max_len; } gir->result[gir->len].seq = seq; gir->result[gir->len].pos = pos; gir->len++; } %func Frees GenericIndexResults - overrides dynamite default %% !deconstructor GenericIndexResult * free_GenericIndexResult(GenericIndexResult * p) { assert(p); free(p->result); free(p); return NULL; } %}wise-2.4.1/src/dynlibsrc/aln.dy0000644000175000001440000006624510057125537015763 0ustar philippusers/* Last edited: Mar 11 10:22 1997 (birney) */ %{ #include "wisebase.h" #define AlnColumnLISTLENGTH 32 #define AlnBlockLISTLENGTH 32 #define AlnBlockListLISTLENGTH 32 #define AlnUnitSCORENUMBER 8 %} api object AlnBlock des free_AlnBlock func dump_ascii_AlnBlock endobject object AlnColumn des free_AlnColumn func at_end_AlnColumn endobject object AlnUnit des free_AlnUnit func bio_start_AlnUnit func bio_end_AlnUnit endobject object AlnSequence des free_AlnSequence endobject endapi friend AlnColumn friend AlnUnit friend AlnSequence struct AlnUnit int start !def=(-1) // start position in the sequence int end !def=(-1) // end position in the sequence int label // not used char * text_label !def="NULL" !link // text label of this position AlnUnit * next; !link // next AlnUnit in this sequence int score[AlnUnitSCORENUMBER]; // a series of scores for this position. boolean in_column !def="TRUE" // not used AlnSequence * seq !link %info This is the basic unit of the label alignment. It describes a single mark-up over one sequence: being a start, an end and a text_label. %% struct AlnColumn AlnUnit ** alu !list // list of the AlnUnits in this column AlnColumn * next; !link // the next AlnColumn in this block %info This is a coupling of AlnUnits from different sequences. Each AlnUnit is meant to represent *the equivalent* piece of biological information in some sense (ie, they are alignmed), even though quite possibly they are very different types of information %% struct AlnSequence AlnUnit * start; // the first AlnUnit of this sequence int data_type; // not used void * data; !link // not used - don't use! int bio_start !def="1" // start of this sequence in its 'bio' coordinates int bio_end !def="-1" // end of this sequence in its 'bio' coordinates %info Each Sequence in an AlnBlock is represented by one of these, and in many ways this is an orthogonal way of looking at the alignment than the AlnColumns. If you look at the alignment from one AlnSequence you will just see the individual labels on this sequence %% struct AlnBlock AlnColumn * start; // the first AlnColumn in the alignment AlnSequence ** seq !list // a list of AlnSequences in the alignment int length; // not used int score; // not used %info AlnBlock is the main representation of alignments from Dynamite. Each AlnBlock represents any number of 'sequences', of any type, which share things in common. The alignment is represented by a series of /AlnColumns (linked list) in which each AlnColumn has a series of AlnUnits, each Unit being a start/end/text_label triple. Alternatively, one can see each sequence in isolation, and not ask what it is aligned to, but rather what labels it has on it. %% struct AlnBlockList AlnBlock ** alb !list %info Sometimes - you need a list of AlnBlocks! %% %{ #include "aln.h" %func This function builds a new "collapsed" AlnBlock on the similarity of one AlnSeq row %% AlnBlock * collapsed_AlnBlock(AlnBlock * alb,int comp_row) { AlnBlock * out; AlnColumn * temp = NULL; AlnColumn * prev = NULL; AlnColumn * ori; int i; out = AlnBlock_alloc(); out->start = NULL; assert(alb); assert(comp_row >= 0); assert(out); for(ori=alb->start;ori != NULL;ori = ori->next) { if( temp != NULL && strcmp(temp->alu[comp_row]->text_label,ori->alu[comp_row]->text_label) == 0 ) { /* same column; eat it up */ for(i=0;ilen;i++) { temp->alu[i]->end = ori->alu[i]->end; temp->alu[i]->score[0] += ori->alu[i]->score[0]; } } else { /* new column */ prev = temp; temp = AlnColumn_alloc_len(ori->len); for(i=0;ilen;i++) { temp->alu[i]= AlnUnit_alloc(); temp->alu[i]->text_label = ori->alu[i]->text_label; temp->alu[i]->start = ori->alu[i]->start; temp->alu[i]->end = ori->alu[i]->end; temp->alu[i]->score[0] = ori->alu[i]->score[0]; } temp->len = ori->len; if( prev == NULL ) { out->start = temp; } else { prev->next = temp; } } } return out; } %func This function assummes that the first AlnSequence in the current and the adding AlnBlock are the same, and that you want to add the second AlnSequence of the second alnblock to the first, anchored on the first sequence. In other words, this builds up an anchored alignment, on the first sequence This AlnBlock, like many others, consumes the sequence in the second alnblock, unsetting things so that it is valid. This makes for some pretty hairy coding. %% boolean add_to_anchored_AlnBlock(AlnBlock * growing,AlnBlock * add) { AlnColumn * anc; AlnColumn * new; AlnColumn * insert; AlnUnit * temp; AlnUnit ** prev; int i; assert(growing); assert(add); anc = growing->start; new = add->start; add_AlnBlock(growing,add->seq[1]); /* this should prevent freeing the sequence we are about to use */ add->len = 1; prev = &(add->seq[1]->start); /* wait until new is inside anc */ for(;new->alu[0]->start != anc->alu[0]->start;anc = anc->next) { /*fprintf(stderr,"Moving to %d-%d\n",anc->alu[0]->start,anc->alu[0]->end);*/ if( anc->alu[0]->start > new->alu[0]->start ) { warn("Somehow new has overrun anc, new %d-%d and anc %d-%d",new->alu[0]->start,new->alu[0]->end,anc->alu[0]->start,anc->alu[0]->end); return FALSE; } /* add a blank unit onto the anc */ temp = AlnUnit_alloc(); temp->score[0] = 0; temp->start = temp->end = 0; temp->text_label = "INSERT"; add_AlnColumn(anc,temp); *prev = temp; prev = &(temp->next); } /* ok - now we are at the start. We loop over for each 'matched' state */ *prev = new->alu[1]; for(;new->next != NULL;) { /* if the anchor state is actually an insert here, then * this is an insert not in the added sequence (if it were, * we would have added it last time through the loop) * * So - skip insert points */ if( anc->alu[0]->start == anc->alu[0]->end ) { temp = AlnUnit_alloc(); temp->score[0] = 0; temp->start = temp->end = new->alu[1]->end; temp->text_label = "INSERT"; *prev = temp; prev = &(temp->next); temp->next = new->alu[1]; add_AlnColumn(anc,temp); anc = anc->next; continue; } /* sanity check that we are at the same position on the two sequences */ if( anc->alu[0]->start != new->alu[0]->start || anc->alu[0]->end != new->alu[0]->end ) { warn("SANITY CHECK failed! new and anchor out of sync! anchor at %d-%d and new %d-%d",anc->alu[0]->start,anc->alu[0]->end,new->alu[0]->start,new->alu[0]->end); return FALSE; } add_AlnColumn(anc,new->alu[1]); /* see whether the next state is actually an insert */ prev = &(new->alu[1]->next); for(new = new->next;new != NULL && new->alu[0]->start == new->alu[0]->end;new = new->next) { /*fprintf(stderr,"Adding in insert states\n");*/ /* bail out if we have reached the end of anc */ if( anc->next == NULL ) { warn("HELP - run out of add positions!"); return FALSE; } /* does anc already have an insert state here? */ if( anc->next->alu[0]->start == anc->next->alu[0]->end ) { /* yes! - just add to the end */ anc = anc->next; add_AlnColumn(anc,new->alu[1]); } else { /* we have to drop in a new alncolumn */ insert = AlnColumn_alloc_std(); insert->next = anc->next; anc->next = insert; /*fprintf(stderr,"There are %d states to add to\n",anc->len);*/ for(i=0;ilen-1;i++) { temp = AlnUnit_alloc(); temp->score[0] = 0; temp->start = temp->end = anc->alu[i]->end; temp->text_label = "INSERT"; temp->next = anc->alu[i]->next; anc->alu[i]->next = temp; add_AlnColumn(insert,temp); } anc = anc->next; /* could be anc = insert */ /* add the new seq */ add_AlnColumn(insert,new->alu[1]); prev = &(new->alu[1]->next); } /* end of else add in an insert */ } /* end of looping over possible new inserts */ /*fprintf(stderr,"moving on one in anchor (new already moved!) %d-%d\n",anc->alu[0]->start,anc->alu[0]->end);*/ prev = &(new->alu[1]->next); anc = anc->next; } /* end of new alignment */ /*fprintf(stderr,"Left alignment at %d-%d\n",anc->alu[0]->start,anc->alu[0]->end);*/ /* now fill into the end of the anchored alignment */ for(;anc != NULL;anc = anc->next ) { /* add a blank unit onto the anc */ temp = AlnUnit_alloc(); temp->score[0] = 0; temp->start = temp->end = 0; temp->text_label = "INSERT"; add_AlnColumn(anc,temp); *prev = temp; prev = &(temp->next); } *prev = NULL; return TRUE; } %func This function makes a new AlnBlock of length len and depth one, with each Block having the given label and start = 0 end = start +1; It starts with a alu going from -1 to 0 %% AlnBlock * single_unit_AlnBlock(int len,char * label) { AlnBlock * out; AlnSequence * als; AlnColumn * alc; AlnUnit * alu; AlnColumn ** prev; AlnUnit ** aprev; int i; out = AlnBlock_alloc_std(); als = AlnSequence_alloc(); add_AlnBlock(out,als); prev = &(out->start); aprev = &(als->start); for(i=-1;istart = i; alu->end = i+1; alu->text_label = label; add_AlnColumn(alc,alu); *aprev = alu; prev = &(alc->next); aprev = &(alu->next); } *prev = NULL; *aprev = NULL; return out; } %func This function splits an AlnBlock into separate alignments (stored in the resulting AlnBlockList). The alb is split wherever there is a column that returns true to the is_spacer_column function, discarding these columns This function completely destroys the AlnBlock object that is passed in, but to make sure that API functions dont get confused, the alb that is passed in is simply stripped of its AlnColumn information (so it is still a valid alb, if empty). But - beware - all the alncolumns might or might not be there, so dont pass in albs and hold on to anything inside them! %% AlnBlockList * split_AlnBlock(AlnBlock * alb,boolean (*is_spacer_column)(const AlnColumn * alc)) { AlnBlockList * out; AlnBlock * temp; AlnColumn * alc; AlnColumn * prev; AlnSequence * als; int i; if( is_spacer_column == NULL ) { warn("You must pass in function for the spacer columns to split_AlnBlock"); } if( alb == NULL ) { warn("Unable to split a NULL alnblock!"); } out = AlnBlockList_alloc_std(); assert(out); for(alc=alb->start;alc != NULL;) { for(;alc != NULL && (*is_spacer_column)(alc) == TRUE;alc = alc->next) { if( alc == NULL) break; /* we need to detach this alncolumn from the entire alignment * as it will stop being valid. */ /* this is cheating, but it is still relevant to catch problems */ if( alc->dynamite_hard_link > 1 ) { warn("Detaching a alncolumn in split_AlnBlock that is being held somewhere else. This is very dangerous"); /* ok - give it a fighting chance of not crashing the client */ for(i=0;ilen;i++) { /* alnunits don't point to next */ alc->alu[i]->next = NULL; } alc->next = NULL; } /* now - free it. It *may* be being held onto by * someone else. Pity him... */ free_AlnColumn(alc); } /* alc is now the first alncolumn of a new alb */ if( alc == NULL) { if( out->len == 0 ) { warn("Unable to find any alignments in AlnBlock splitting!"); } break; /* will return */ } temp = AlnBlock_alloc_std(); add_AlnBlockList(out,temp); /* we need to make an exact copy of the AlnSequences */ for(i=0;ilen;i++) { assert(alc->alu[i]); als = AlnSequence_alloc(); add_AlnBlock(temp,als); als->data_type = alb->seq[i]->data_type; als->data = alb->seq[i]->data; als->bio_start = alb->seq[i]->bio_start; als->bio_end = alb->seq[i]->bio_end; /* unit is the unit in this column */ als->start = alc->alu[i]; } /* attach alc as the first column to temp */ temp->start = alc; /* keep walking along the list now until we hit * a random column. All the columns and units are * already correctly laid out in memory */ for(prev = alc;alc != NULL && (*is_spacer_column)(alc) == FALSE;) { prev = alc; alc = alc->next; } /* prev is the last column. detach it */ prev->next = NULL; for(i=0;ilen;i++) prev->alu[i]->next = NULL; /* return to eating empty columns */ } /* alb is now completely defunct. We need to make it * impotent with regard to the old stuff it used to have * * this basically makes alb complete empty */ alb->len =0; alb->start = NULL; return out; } %func gets the score out for a particular alb sequence line %% int score_line_from_AlnBlock(AlnBlock * alb,int seqno) { AlnUnit * alu; int score = 0; assert(alb); if( seqno > alb->len ) { warn("Asking for a score number of a sequence more than alb. giving back 0"); return 0; } for(alu = alb->seq[seqno]->start;alu != NULL;alu = alu->next) { score += alu->score[0]; } return score; } %func This tells you whether the AlnColumn is at the end without passing NULL's around %simple at_end %arg alc r AlnColumn %% boolean at_end_AlnColumn(AlnColumn * alc) { if( alc->next == NULL ) return 1; return 0; } %func Tells the bio-coordinate of the start point of this alnunit %simple bio_start %% int bio_start_AlnUnit(AlnUnit * alu) { if( alu->seq == NULL ) { warn("A mis-connected AlnUnit (no sequence!) - Returning a start as if start == 1"); return alu->start + 1 + 1; } return alu->start + alu->seq->bio_start + 1; } %func Tells the bio-coordinate of the end point of this alnunit %simple bio_end %% int bio_end_AlnUnit(AlnUnit * alu) { if( alu->seq == NULL ) { warn("A mis-connected AlnUnit (no sequence!) - Returning a start as if start == 1"); return alu->end + 1; } return alu->end + alu->seq->bio_start; } %func This function will 'swallow' any number of AlnColumns as long as the comparison function of the labels match (the basic comp function would be something like strcmp(a,b) == 0 ? TRUE : FALSE) The columns are 'swallowed' into master and come from eaten. (these columns could be in the same linked list, though it only makes sense if the master is before the eaten). It returns the first column that it could not swallow. you use this to collapse regions of the label alignment. %arg master column which will eat other columns eaten column which will be consumed comp_func comparison function for label set %% AlnColumn * swallow_AlnColumn_multiple(AlnColumn * master,AlnColumn * eaten,boolean (*comp_func)(char *,char *)) { register int i; for(i=0;eaten != NULL; eaten = eaten->next) { if( swallow_AlnColumn(master,eaten,comp_func) == FALSE ) break; } return eaten; } %func Basicaly the same as /swallow_AlnColumn_mulitple but there is a maximum number of columns it will swallow %arg master column which will eat other columns eaten column which will be consumed comp_func comparison function for label set num max number of columns to eat return number of columns eaten %% int swallow_AlnColumn_number(AlnColumn * master,AlnColumn * eaten,int num,boolean (*comp_func)(char *,char *)) { register int i; for(i=0;i < num && eaten != NULL; eaten = eaten->next) { if( swallow_AlnColumn(master,eaten,comp_func) == FALSE ) break; } return i; } %func This is the function that actually does the 'swallowing'. It will try to swallow eaten into master. If comp_func does not give us an ok (actually using /can_swallow_AlnColumn it returns FALSE. Otherwise it moves on the end of AlnColumn in master to eaten and adds the score of eaten to master. %arg master column which will eat eaten column which will dissappear into master if eatable comp_func comparison function for labels %% boolean swallow_AlnColumn(AlnColumn * master,AlnColumn * eaten,boolean (*comp_func)(char *,char *)) { register int i; if( can_swallow_AlnColumn(master,eaten,comp_func) == FALSE ) { return FALSE; } for(i=0;ilen;i++) { master->alu[i]->end = eaten->alu[i]->end; /*** ok, for the moment, only add the 1st score, but eventually ***/ /*** we should add all of them... ***/ master->alu[i]->score[0] += eaten->alu[i]->score[0]; } return TRUE; } %func checks to see if two columns are mergable from comp_func. First uses /identical_labels_in_AlnColumn to see if labels can be merged Then checks that starts in master are greater than starts in eaten %type internal %% boolean can_swallow_AlnColumn(AlnColumn * master,AlnColumn * eaten,boolean (*comp_func)(char *,char *)) { register int i; if( identical_labels_in_AlnColumn(master,eaten,comp_func) == FALSE ) return FALSE; for(i=0;ilen;i++) if( master->alu[i]->start >= eaten->alu[i]->start) { warn("In trying to compare to AlnColumns, have some 'eatable' starts greater than master starts %d %d in row %d",master->alu[i]->start,eaten->alu[i]->start,i); return FALSE; } return TRUE; } %func checks to see if two AlnColumns has mergable labels by comp_func. calls /identical_labels_in_AlnUnits for the actual comparison. %type internal %% boolean identical_labels_in_AlnColumn(AlnColumn * one,AlnColumn * two,boolean (*comp_func)(char *,char *)) { register int i; if( one->len != two->len ) { warn("Attempting to see if two AlnColumns with *different numbers of units* %d,%d are identical...serious problem",one->len,two->len); return FALSE; } for(i=0;ilen;i++) { if( identical_labels_in_AlnUnits(one->alu[i],two->alu[i],comp_func) == FALSE ) return FALSE; } return TRUE; } %func actually calls the comp_func for the label compairson %type internal %% boolean identical_labels_in_AlnUnits(AlnUnit * one,AlnUnit * two,boolean (*comp_func)(char *,char *)) { if( (*comp_func)(one->text_label,two->text_label) == TRUE ) return TRUE; else return FALSE; } %func Linked list manipulation function Puts insert between start and end, and free's from start->next onwards. *Beware* if start is linked to end before calling this function thsi wil free end and everything chained to it. Think before you call this! %% void replace_and_free_AlnColumn_with_one(AlnColumn * start,AlnColumn * end,AlnColumn * insert) { replace_AlnColumn_with_one(start,end,insert); free_AlnColumn(start->next); } %func Linked list manipulation function places insert between start and end. If start/end are not continuous then it will loop out the start/end region %% void replace_AlnColumn_with_one(AlnColumn * start,AlnColumn * end,AlnColumn * insert) { start->next = insert; insert->next = end->next; end->next = NULL; } %func Linked list manipulation function places insert just after start: links insert up to what start was linked to %% void insert_AlnColumn(AlnColumn * start,AlnColumn * insert) { insert->next = start->next; start->next = insert; } %func Linked list movement function A nasty function to reverse up a singly linked list by going to the start and coming back until you are in the current position. yuk. %% AlnColumn * go_back_n_AlnColumn(AlnBlock * alb,AlnColumn * start,int n) { /*** really quite hacky ****/ AlnColumn * cursor; AlnColumn * back; register int i; for(i=0,cursor = alb->start;i < n && cursor != NULL && cursor != start;i++,cursor = cursor->next) ; if( i < n ) { return NULL; /** should I post an error? **/ } for(back = alb->start;cursor != NULL && cursor != start;cursor = cursor->next, back = back->next) ; if( cursor == NULL ) { warn("could not find you AlnColumn in AlnBlock at all... so could not get xxx positions back"); return NULL; } return back; } /*******************************/ /* show functions for aln block*/ /* */ /* these are really basic and */ /* should use alndisplay for */ /* ascii display */ /*******************************/ %func Dumps the alignment in rereadable ascii form. Not really for human consumption %arg alb AlnBlock to dump ofp File stream to dump to %% void dump_ascii_AlnBlock(AlnBlock * alb,FILE * ofp) { int i; AlnColumn * alc; for(alc=alb->start;alc != NULL;alc = alc->next) { fprintf(ofp,"[%d:%d \"%s\" %d]",alc->alu[0]->start,alc->alu[0]->end,alc->alu[0]->text_label,alc->alu[0]->score[0]); for(i=1;ilen;i++) { fprintf(ofp,",[%d:%d \"%s\" %d]",alc->alu[i]->start,alc->alu[i]->end,alc->alu[i]->text_label,alc->alu[i]->score[0]); } fprintf(ofp,"\n"); } fprintf(ofp,"\\\n"); } %func Shows a list of AlnBlocks with an arbitary mapping of the score to some other system %arg alb AlnBlock to dump ofp File stream to dump to %% void mapped_ascii_AlnBlockList(AlnBlockList *al,double (*score_to_double)(int),FILE * ofp) { int i; assert(al); assert(ofp); assert(score_to_double); for(i=0;ilen;i++) { fprintf(ofp,"\n\nAlignment %d\n",i+1); mapped_ascii_AlnBlock(al->alb[i],score_to_double,0,ofp); } } %func Shows AlnBlock with an arbitary mapping of the score to some other system. %arg alb AlnBlock to dump ofp File stream to dump to %% void mapped_ascii_AlnBlock(AlnBlock * alb,double (*score_to_double)(int),int do_cumlative,FILE * ofp) { int i; AlnColumn * alc; int cuml = 0; if( alb == NULL || score_to_double == NULL || ofp == NULL ) { warn("Passing in null objects to mapped_ascii_AlnBlock - unable to show!"); return; } for(alc=alb->start;alc != NULL;alc = alc->next) { cuml = cuml + alc->alu[0]->score[0]; fprintf(ofp,"%3.2f ",(double)(*score_to_double)(alc->alu[0]->score[0])); fprintf(ofp,"[%d:%d \"%s\" %d]",alc->alu[0]->start,alc->alu[0]->end,alc->alu[0]->text_label,alc->alu[0]->score[0]); for(i=1;ilen;i++) { fprintf(ofp,",[%d:%d \"%s\" %d]",alc->alu[i]->start,alc->alu[i]->end,alc->alu[i]->text_label,alc->alu[i]->score[0]); } if( do_cumlative == 1 ) { fprintf(ofp," {%3.2f} ",(double)(*score_to_double)(cuml),cuml); } fprintf(ofp,"\n"); } } %func Reads an ascii dumped alignment %arg ifp File stream to read from %% AlnBlock * read_ascii_dump_AlnBlock(FILE * ifp) { char buffer[MAXLINE]; AlnBlock * out; AlnColumn ** attach; AlnColumn * new; out = AlnBlock_alloc_std(); attach = &out->start; while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"//") == 0 ) break; new = read_dumped_ascii_AlnColumn_line(buffer); if( new == NULL ){ warn("Unable to read entire AlnBlock. Returning no alignment"); free_AlnBlock(out); return NULL; } *attach = new; attach = &new->next; } return out; } %func Reads one line of an ascii dumped alignment %type internal %arg line line to be read %% AlnColumn * read_dumped_ascii_AlnColumn_line(char * line) { char ** base, **bstr; AlnUnit * alu; AlnColumn * out; int start; int end; int score; char buffer[128]; /* implies max label 128 characters. Worrying? */ out = AlnColumn_alloc_len(2); /** most times we are reading in pairwise alignments **/ /** split on comma, then sscanf each one **/ base = bstr = breakstring_protect(line,",","\""); for(;*bstr != NULL;bstr++) { sscanf(*bstr,"[%d,%d \"%s\" %d",&start,&end,buffer,&score); alu = AlnUnit_alloc(); alu->start = start; alu->end = end; alu->score[0] = score; alu->text_label = stringalloc(buffer); add_AlnColumn(out,alu); } return out; } %func Shows the AlnBlock in vaguely human readable form %simple show %arg alb AlnBlock to show ofp output %% void show_flat_AlnBlock(AlnBlock * alb,FILE * ofp) { AlnColumn * alc; register int i; for(i=0,alc = alb->start;alc != NULL;alc = alc->next,i++) { fprintf(ofp,"Column %d:\n",i); show_flat_AlnColumn(alc,ofp); } } %func sub for show_flat_AlnBlock %type internal %% void show_flat_AlnColumn(AlnColumn * alc,FILE * ofp) { register int i; for(i=0;ilen;i++) { fprintf(ofp,"Unit %2d- ",i); show_flat_AlnUnit(alc->alu[i],ofp); } fprintf(ofp,"\n"); } %func sub for show_flat_AlnUnit %type internal %% void show_flat_AlnUnit(AlnUnit * alu,FILE * ofp) { fprintf(ofp,"[%4d-%4d] [%s]\n",alu->start,alu->end,alu->text_label == NULL ? "No Label" : alu->text_label); } %func Not used currently. To read in the flat output format %type internal %% AlnUnit * read_flat_AlnUnit_line(char * line,int * ret_pos) { AlnUnit * out; char buffer[MAXLINE]; int start; int end; int pos; int num; sscanf(line,"Unit %d- Start: [%d], End: [%d] Label: number [%d] text [%s]",&pos,&start,&end,&num,buffer); out = AlnUnit_alloc(); if( out == NULL ) return NULL; out->start = start; out->end = end; out->label = num; out->text_label = stringalloc(buffer); if( ret_pos != NULL ) *ret_pos = pos; return out; } /***********************************/ /* movement functions around Aln's */ /***********************************/ %func Not sure if this is used! %% AlnColumn * get_second_end_AlnColumn(AlnBlock * alb) { AlnColumn * end = NULL; AlnColumn * prev = NULL; for(end = alb->start;end->next != NULL;prev = end,end = end->next) ; return prev; } %func To get to the last AlnColumn. If this was a doubly linked list, life would be much easier %% AlnColumn * get_end_AlnColumn(AlnBlock * alb) { AlnColumn * end; for(end = alb->start;end->next != NULL;end = end->next) ; return end; } %func Links up all AlnUnits to their parent sequences %% boolean link_AlnUnits_AlnBlock(AlnBlock * alb) { AlnSequence * aseq; AlnUnit * au; int i; for(i=0;ilen;i++) { aseq = alb->seq[i]; for(au = aseq->start;au != NULL;au++) { au->seq = aseq; } } return TRUE; } /************************************/ /* constructors/deconstructors to */ /* deal with linked list aspect of */ /* data */ /************************************/ %func Function as a constructor for the special case of a pairwise alignment. Makes an AlnColumn and puts in two AlnUnits all ready to be linked in. %% AlnColumn * new_pairwise_AlnColumn(void) { AlnColumn * out; out = AlnColumn_alloc_len(2); add_AlnColumn(out,AlnUnit_alloc()); add_AlnColumn(out,AlnUnit_alloc()); return out; } %func Specilased deconstructor needed because of linked list nature of the data structure %% !deconstructor AlnColumn * free_AlnColumn(AlnColumn * obj) { if( obj == NULL ) { warn("passed a NULL object into free_AlnColumn!"); return NULL; } if( obj->dynamite_hard_link > 1 ) { obj->dynamite_hard_link--; return NULL; } if( obj->next != NULL ) free_AlnColumn(obj->next); if( obj->alu != NULL ) ckfree(obj->alu); /*** units free'd from linked list ***/ ckfree(obj); return NULL; } %func Specilased deconstructor needed because of linked list nature of the data structure %% !deconstructor AlnUnit * free_AlnUnit(AlnUnit * obj) { if( obj == NULL ) return NULL; if( obj->dynamite_hard_link > 1 ) { obj->dynamite_hard_link--; return NULL; } if( obj->next != NULL ) free_AlnUnit(obj->next); ckfree(obj); return NULL; } %} wise-2.4.1/src/dynlibsrc/aln.xs0000644000175000001440000002204710670453712015771 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::AlnBlock void dump_ascii_AlnBlock(alb,ofp) Wise2_AlnBlock * alb FILE * ofp CODE: Wise2_dump_ascii_AlnBlock(alb,ofp); Wise2_AlnBlock * hard_link_AlnBlock(obj) Wise2_AlnBlock * obj CODE: RETVAL = Wise2_hard_link_AlnBlock(obj); OUTPUT: RETVAL Wise2_AlnBlock * AlnBlock_alloc_std() CODE: RETVAL = Wise2_AlnBlock_alloc_std(); OUTPUT: RETVAL boolean set_start(obj,start) Wise2_AlnBlock * obj Wise2_AlnColumn * start CODE: RETVAL = Wise2_replace_start_AlnBlock(obj,Wise2_hard_link_AlnColumn(start)); OUTPUT: RETVAL Wise2_AlnColumn * start(obj) Wise2_AlnBlock * obj INIT: Wise2_AlnColumn * temp; CODE: temp = Wise2_hard_link_AlnColumn(Wise2_access_start_AlnBlock(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_AlnSequence * seq(obj,i) Wise2_AlnBlock * obj int i INIT: Wise2_AlnSequence * temp; CODE: temp = Wise2_hard_link_AlnSequence(Wise2_access_seq_AlnBlock(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_seq(obj) Wise2_AlnBlock * obj CODE: RETVAL = Wise2_length_seq_AlnBlock(obj); OUTPUT: RETVAL int flush_seq(obj) Wise2_AlnBlock * obj CODE: RETVAL = Wise2_flush_AlnBlock(obj); OUTPUT: RETVAL boolean add_seq(obj,add) Wise2_AlnBlock * obj Wise2_AlnSequence * add CODE: RETVAL = Wise2_add_AlnBlock(obj,Wise2_hard_link_AlnSequence(add)); OUTPUT: RETVAL boolean set_length(obj,length) Wise2_AlnBlock * obj int length CODE: RETVAL = Wise2_replace_length_AlnBlock(obj,length); OUTPUT: RETVAL int length(obj) Wise2_AlnBlock * obj CODE: RETVAL = Wise2_access_length_AlnBlock(obj); OUTPUT: RETVAL boolean set_score(obj,score) Wise2_AlnBlock * obj int score CODE: RETVAL = Wise2_replace_score_AlnBlock(obj,score); OUTPUT: RETVAL int score(obj) Wise2_AlnBlock * obj CODE: RETVAL = Wise2_access_score_AlnBlock(obj); OUTPUT: RETVAL Wise2_AlnBlock * new(class) char * class PPCODE: Wise2_AlnBlock * out; out = Wise2_AlnBlock_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_AlnBlock * obj CODE: Wise2_free_AlnBlock(obj); void each_seq(obj) Wise2_AlnBlock * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_seq_AlnBlock(obj); for(i=0;iraw_score - one->raw_score; } /* Function: apply_SearchStat_to_HitList(hspm,ssi,database_size) * * Descrip: Applies statistics across a hitlist * * * Arg: hspm [UNKN ] Undocumented argument [HitList *] * Arg: ssi [UNKN ] Undocumented argument [SearchStatInterface *] * Arg: database_size [UNKN ] Undocumented argument [int] * */ # line 77 "hitlist.dy" void apply_SearchStat_to_HitList(HitList * hspm,SearchStatInterface * ssi,int database_size) { int i; int j; hspm->stat_attrib = stringalloc((*ssi->attribution)(ssi->data)); for(i=0;ilen;i++) { hspm->pair[i]->bit_score = (*ssi->calc_bits)(ssi->data,hspm->pair[i]->query->len,hspm->pair[i]->target->len,hspm->pair[i]->raw_score); hspm->pair[i]->evalue = (*ssi->calc_evalue)(ssi->data,hspm->pair[i]->query,hspm->pair[i]->target,hspm->pair[i]->raw_score,database_size); for(j=0;jpair[i]->len;j++ ) { hspm->pair[i]->aln[j]->bit_score = (*ssi->calc_bits)(ssi->data,hspm->pair[i]->query->len,hspm->pair[i]->target->len,hspm->pair[i]->aln[j]->raw_score); hspm->pair[i]->aln[j]->evalue = (*ssi->calc_evalue)(ssi->data,hspm->pair[i]->query,hspm->pair[i]->target,hspm->pair[i]->aln[j]->raw_score,database_size); } } } /* Function: HitList_from_LinearHSPmanager(lm) * * Descrip: Converts a LinearHSPmanager into a HitList * * * Arg: lm [UNKN ] Undocumented argument [LinearHSPmanager *] * * Return [UNKN ] Undocumented return value [HitList *] * */ # line 100 "hitlist.dy" HitList * HitList_from_LinearHSPmanager(LinearHSPmanager * lm) { HitList * out; HitPair * pair; int i; out = HitList_alloc_std(); if( lm->mat != NULL ) out->mat = hard_link_CompMat(lm->mat); for(i=0;ilen;i++) { pair = HitPair_from_HSPset(lm->set[i],lm->mat); add_HitList(out,pair); } return out; } /* Function: HitPair_from_HSPset(set,mat) * * Descrip: Builds a Hitpair from an HSP, not doing * alignment * * * Arg: set [UNKN ] Undocumented argument [HSPset *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * * Return [UNKN ] Undocumented return value [HitPair *] * */ # line 125 "hitlist.dy" HitPair * HitPair_from_HSPset(HSPset * set,CompMat * mat) { HitPair * out; HitAln * aln; int i; out = HitPair_alloc_std(); out->query = hard_link_Sequence(set->hsp[0]->query); out->target = hard_link_Sequence(set->hsp[0]->target); out->raw_score = 0.0; for(i=0;ilen;i++) { aln = HitAln_alloc(); aln->raw_score = set->hsp[i]->score; aln->bit_score = aln->raw_score/2.0; aln->alb = ungapped_AlnBlock_from_HSP(set->hsp[i],out->query,out->target,mat); add_HitPair(out,aln); out->raw_score += set->hsp[i]->score; } return out; } /* Function: ungapped_AlnBlock_from_HSP(hsp,q,t,mat) * * Descrip: Builds an expanded AlnBlock with one AlnColumn * per residue for an ungapped HSP * * * Arg: hsp [UNKN ] Undocumented argument [HSP *] * Arg: q [UNKN ] Undocumented argument [Sequence *] * Arg: t [UNKN ] Undocumented argument [Sequence *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 156 "hitlist.dy" AlnBlock * ungapped_AlnBlock_from_HSP(HSP * hsp,Sequence * q,Sequence * t,CompMat * mat) { AlnBlock * alb; AlnColumn * alc; AlnColumn * prev = NULL; int i; alb = AlnBlock_alloc_len(2); add_AlnBlock(alb,AlnSequence_alloc()); add_AlnBlock(alb,AlnSequence_alloc()); for(i=0;ilength && hsp->query_start+i < q->len && hsp->target_start+i < t->len;i++) { alc = new_pairwise_AlnColumn(); alc->alu[0]->start = hsp->query_start+i-1; alc->alu[0]->end = hsp->query_start+i; alc->alu[0]->text_label = "SEQUENCE"; alc->alu[1]->start = hsp->target_start+i-1; alc->alu[1]->end = hsp->target_start+i; alc->alu[1]->text_label = "SEQUENCE"; if( mat != NULL ) { alc->alu[0]->score[0] = alc->alu[1]->score[0] = mat->comp[toupper(q->seq[hsp->query_start+i])-'A'][toupper(t->seq[hsp->target_start+i])-'A']; } if( prev == NULL ) { alb->start = alc; prev = alc; } else { prev->next = alc; prev = alc; } } return alb; } /* Function: new_HitListOutputImpl_from_argv(argc,argv) * * Descrip: Builds a new HitListOutputFormat from commandline * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [HitListOutputImpl *] * */ # line 199 "hitlist.dy" HitListOutputImpl * new_HitListOutputImpl_from_argv(int * argc,char ** argv) { HitListOutputImpl * out; char * temp; out = HitListOutputImpl_alloc(); if( strip_out_boolean_argument(argc,argv,"hithelp") == TRUE ) { fprintf(stdout,"Hitlist help\npseudoblast gives a format similar to BLAST output\nTab gives a tab delimited format one line foreach ungapped block with columns\n \n"); fprintf(stdout,"aln gives cumlative score align label dumping, good for debugging\n"); exit(0); } if( (temp = strip_out_assigned_argument(argc,argv,"hitoutput")) != NULL ) { if( strcmp(temp,"pseudoblast") == 0 ) { out->type = HitListOutputFormatPseudoBlast; } if( strcmp(temp,"xml") == 0 ) { out->type = HitListOutputFormatXML; } if( strcmp(temp,"aln") == 0 ) { out->type = HitListAlnCumlative; } if( strcmp(temp,"tab") == 0 ) { out->type = HitListOutputFormatTab; } } return out; } /* Function: show_help_HitListOutputImpl(ofp) * * Descrip: Shows help for HitList output * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 232 "hitlist.dy" void show_help_HitListOutputImpl(FILE * ofp) { fprintf(ofp,"Hit list output options\n"); fprintf(ofp," -hitoutput [pseudoblast/xml/tab] pseudoblast by default\n"); fprintf(ofp," -hithelp more detailed help on hitlist formats\n"); } /* Function: show_HitList_HitListOutputImpl(hloi,hl,ofp) * * Descrip: Shows a hitlist wrt to output impl * * * Arg: hloi [UNKN ] Undocumented argument [HitListOutputImpl *] * Arg: hl [UNKN ] Undocumented argument [HitList *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 243 "hitlist.dy" void show_HitList_HitListOutputImpl(HitListOutputImpl * hloi,HitList * hl,FILE * ofp) { switch(hloi->type) { case HitListOutputFormatPseudoBlast : write_pseudoblast_HitList(hl,ofp); break; case HitListOutputFormatXML : write_XML_HitList(hl,ofp); break; case HitListOutputFormatTab : write_tab_HitList(hl,ofp); break; case HitListAlnCumlative : write_alb_HitList(hl,ofp); break; default : error("No valid HitListOutputFormat!"); } } /* Function: write_alb_HitList(hl,ofp) * * Descrip: Writes Alb output * * * Arg: hl [UNKN ] Undocumented argument [HitList *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 268 "hitlist.dy" void write_alb_HitList(HitList * hl,FILE * ofp) { int i,j; for(i=0;ilen;i++) { fprintf(stdout,"%s %s\n",hl->pair[i]->query->name,hl->pair[i]->target->name); for(j=0;jpair[i]->len;j++) { fprintf(ofp,"Alignment %d\n",j); if( hl->pair[i]->aln[j]->alb != NULL ) mapped_ascii_AlnBlock(hl->pair[i]->aln[j]->alb,Score2Bits,1,ofp); } } } /* Function: write_XML_HitList(hl,ofp) * * Descrip: Writes XML output * * * Arg: hl [UNKN ] Undocumented argument [HitList *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 286 "hitlist.dy" void write_XML_HitList(HitList * hl,FILE * ofp) { int i,j; btCanvas * btc; fprintf(ofp,"\n"); fprintf(ofp,"\n"); fprintf(ofp,"\n"); for(i=0;ilen;i++) { fprintf(ofp," \n"); fprintf(ofp," %d\n",i); fprintf(ofp," \n"); fprintf(ofp," %s\n",hl->pair[i]->target->name); if( hl->pair[i]->target->desc != NULL ) { fprintf(ofp," %s\n",hl->pair[i]->target->desc); } fprintf(ofp," %s\n",hl->pair[i]->target->seq); fprintf(ofp," \n"); fprintf(ofp," \n"); fprintf(ofp," %d\n",hl->pair[i]->raw_score); fprintf(ofp," %.2f\n",hl->pair[i]->bit_score); fprintf(ofp," %g\n",hl->pair[i]->evalue); fprintf(ofp," \n"); for(j=0;jpair[i]->len;j++) { auto HitAln * haln = hl->pair[i]->aln[j]; fprintf(ofp," \n"); fprintf(ofp," \n"); fprintf(ofp," %d\n",haln->raw_score); fprintf(ofp," %.2f\n",haln->bit_score); fprintf(ofp," %g\n",haln->evalue); fprintf(ofp," \n"); fprintf(ofp," \n"); btc = new_Ascii_btCanvas(stdout,20,50,7,3); write_pretty_str_blast_align_btc(hl->pair[i]->aln[j]->alb,"Query:",hl->pair[i]->query->seq,"Sbjct:",hl->pair[i]->target->seq,btc); free_btCanvas(btc); fprintf(ofp,"\n"); fprintf(ofp," \n"); fprintf(ofp," \n"); } fprintf(ofp,"\n"); } fprintf(ofp,"\n"); } /* Function: write_tab_HitList(hl,ofp) * * Descrip: Writes tab delimited tab like output * * * Arg: hl [UNKN ] Undocumented argument [HitList *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 338 "hitlist.dy" void write_tab_HitList(HitList * hl,FILE * ofp) { int i; int j; AlnColumn * alc; int qstart; int qend = 0; int tstart; int tend = 0; int strand; int tempt; for(i=0;ilen;i++) { for(j=0;jpair[i]->len;j++) { for(alc = hl->pair[i]->aln[j]->alb->start;alc != NULL && strcmp(alc->alu[1]->text_label,"END") != 0 ;) { /* start of a block - remember start coordinates */ qstart = alc->alu[0]->start+1+1; tstart = alc->alu[1]->start+1+1; /* progress any number of cases where the progression is the same */ for(;alc != NULL;alc = alc->next ) { if( (alc->alu[0]->end - alc->alu[0]->start) != (alc->alu[1]->end - alc->alu[1]->start) ) { break; } /* otherwise set end points */ qend = alc->alu[0]->end+1; tend = alc->alu[1]->end+1; } if( hl->pair[i]->target_reversed == 1 ) { strand = -1; tempt = tstart; tstart = hl->pair[i]->target->len - tend+1; tend = hl->pair[i]->target->len - tempt+1; } else { strand = 1; } /* end of a block. Print line */ fprintf(ofp,"%.2f\t%s\t%d\t%d\t%d\t%d\t%s\t%d\t%d\t%d\t%d\tgroup_%d_%d\n",hl->pair[i]->bit_score,hl->pair[i]->query->name,qstart,qend,1,hl->pair[i]->query->len,hl->pair[i]->target->name,tstart,tend,strand,hl->pair[i]->target->len,i,j); /* find start of next block */ for(;alc != NULL && strcmp(alc->alu[1]->text_label,"END") != 0;alc = alc->next ) { if( alc->alu[0]->end - alc->alu[0]->start == alc->alu[1]->end - alc->alu[1]->start ) { break; } } /* top loop will break at alc == NULL */ } } } } /* Function: write_pseudoblast_HitList(hl,ofp) * * Descrip: Writes pseudoblast output * * * Arg: hl [UNKN ] Undocumented argument [HitList *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 396 "hitlist.dy" void write_pseudoblast_HitList(HitList * hl,FILE * ofp) { int i,j; btCanvas * btc; char buffer[MAXLINE]; fprintf(ofp,"BLASTP 2.1.2\n"); fprintf(ofp,"\n\nReference: Wise2 Package, Ewan Birney\n"); fprintf(ofp,"BLAST like format to play well with existing parsers. Other options are available\nSee help on the program that generated this for other options\n"); if( hl->stat_attrib != NULL ) { fprintf(ofp," Statistics from : %s\n",hl->stat_attrib); } fprintf(ofp,"\n\n"); fprintf(ofp,"Query= Not specified\n"); fprintf(ofp,"\n\nSearch.................................done\n\n"); fprintf(ofp," Score E\n"); fprintf(ofp,"Sequences producing significant alignments: (bits) Value\n"); for(i=0;ilen;i++) { if( hl->pair[i]->target->desc != NULL ) { strcpy(buffer,hl->pair[i]->target->desc); } else { strcpy(buffer," "); } buffer[50] = '\0'; fprintf(ofp,"%15s %50s %-.2f %.2g\n",hl->pair[i]->target->name,buffer,hl->pair[i]->bit_score,hl->pair[i]->evalue); } fprintf(ofp,"\n"); for(i=0;ilen;i++) { fprintf(ofp,">%s %s\n Length = %d Reversed %d\n\n",hl->pair[i]->target->name,(hl->pair[i]->target->desc != NULL ? hl->pair[i]->target->desc : " "),hl->pair[i]->target->len,hl->pair[i]->target_reversed); for(j=0;jpair[i]->len;j++) { fprintf(ofp," Score = %.1f bits (%d), Expect = %g\n", hl->pair[i]->aln[j]->bit_score,hl->pair[i]->aln[j]->raw_score,hl->pair[i]->aln[j]->evalue); fprintf(ofp,"\n"); btc = new_Ascii_btCanvas(stdout,20,50,5,3); if( hl->write_btc_func == NULL ) { write_pretty_str_blast_align_btc(hl->pair[i]->aln[j]->alb,"Query:",hl->pair[i]->query->seq,"Sbjct:",hl->pair[i]->target->seq,btc); } else { (*hl->write_btc_func)(hl->pair[i]->aln[j]->alb,hl->pair[i]->query,hl->pair[i]->target,btc); } free_btCanvas(btc); fprintf(ofp,"\n"); } } } /* Function: write_pretty_Seq_blast_align_btc(alb,one,two,btc) * * Descrip: Chains up to char* level alignment writer * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: one [UNKN ] Undocumented argument [Sequence *] * Arg: two [UNKN ] Undocumented argument [Sequence *] * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 453 "hitlist.dy" boolean write_pretty_Seq_blast_align_btc(AlnBlock * alb,Sequence * one,Sequence * two,btCanvas * btc) { return write_pretty_str_blast_align_btc(alb,one->name,one->seq,two->name,two->seq,btc); } /* Function: write_pretty_str_blast_align_btc(alb,qname,query,tname,target,btc) * * Descrip: This function writes precisely * what you expect for a a simple alignment. * * We can reuse this routine all over the place because * we dont use any hard coded structure for the * query or the target sequence letters. ... but crap * type checking it has to be said! * * Also we use a generic btCanvas that could have * any implementation underneath (eg, ASCII, postscript etc). * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: qname [UNKN ] Undocumented argument [char *] * Arg: query [UNKN ] Undocumented argument [char *] * Arg: tname [UNKN ] Undocumented argument [char *] * Arg: target [UNKN ] Undocumented argument [char *] * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 470 "hitlist.dy" boolean write_pretty_str_blast_align_btc(AlnBlock * alb,char * qname,char * query,char * tname,char * target,btCanvas * btc) { int finished = 0; AlnColumn * alc; AlnColumn * prev = NULL; AlnUnit * q; AlnUnit * t; char buffer[14]; btPasteArea * btp; for(alc=alb->start;alc != NULL && finished == 0;) { /** put names in **/ btp = get_reserved_left_btCanvas(btc); paste_string_btPasteArea(btp,0,0,qname,BC_RIGHT,0); paste_string_btPasteArea(btp,0,2,tname,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[0]->start+1+1); paste_string_btPasteArea(btp,12,0,buffer,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[1]->start+1+1); paste_string_btPasteArea(btp,12,2,buffer,BC_RIGHT,0); free_btPasteArea(btp); /** now loop over this block **/ for(;finished == 0 && alc != NULL && can_get_paste_area_btCanvas(btc,1) == TRUE;prev=alc,alc=alc->next) { q = alc->alu[0]; t = alc->alu[1]; /* * at the end, break */ if( strcmp(q->text_label,"END") == 0 ) { finished = 1; break; } /* * Get the paste area, length 1, depth will be 3 */ btp = get_paste_area_btCanvas(btc,1); /* * Write in the query sequence * */ if( strcmp(q->text_label,"SEQUENCE") == 0 || strstr(q->text_label,"BOUND") != NULL ) { paste_char_btPasteArea(btp,0,0,toupper((int)query[q->start+1]),0); } else if( strcmp(q->text_label,"UNMATCHED_SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,0,tolower((int)query[q->start+1]),0); } else { /** is insert- we could check **/ if( strcmp(q->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",q->text_label); paste_char_btPasteArea(btp,0,0,'?',0); } else { paste_char_btPasteArea(btp,0,0,'-',0); } } /* * Write in the target sequence * */ if( strcmp(t->text_label,"SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,2,toupper((int)target[t->start+1]),0); } else if( strcmp(t->text_label,"UNMATCHED_SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,2,tolower((int)target[t->start+1]),0); } else { /** is insert- we could check **/ if( strcmp(t->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",t->text_label); paste_char_btPasteArea(btp,0,2,'?',0); } else { paste_char_btPasteArea(btp,0,2,'-',0); } } /* * Match line */ if( strcmp(q->text_label,"SEQUENCE") == 0 && strcmp(t->text_label,"SEQUENCE") == 0 ) { if( q->score[0] > 0 ) { if( query[q->start+1] == target[t->start+1] ) { paste_char_btPasteArea(btp,0,1,target[t->start+1],0); } else { paste_char_btPasteArea(btp,0,1,'+',0); } } } else paste_char_btPasteArea(btp,0,1,' ',0); free_btPasteArea(btp); } /* end of for this block */ if( prev != NULL ) { btp = get_reserved_right_btCanvas(btc); sprintf(buffer,"%d",prev->alu[0]->end+1); paste_string_btPasteArea(btp,0,0,buffer,BC_RIGHT,0); sprintf(buffer,"%d",prev->alu[1]->end+1); paste_string_btPasteArea(btp,0,2,buffer,BC_RIGHT,0); free_btPasteArea(btp); } advance_line_btCanvas(btc); if( alc->next != NULL && strcmp(alc->next->alu[1]->text_label,"END") == 0 ) { break; } } /* end of for the alignment */ return TRUE; /* we never returned false. Ooops! */ } # line 646 "hitlist.c" /* Function: hard_link_HitAln(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HitAln *] * * Return [UNKN ] Undocumented return value [HitAln *] * */ HitAln * hard_link_HitAln(HitAln * obj) { if( obj == NULL ) { warn("Trying to hard link to a HitAln object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HitAln_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HitAln *] * */ HitAln * HitAln_alloc(void) { HitAln * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HitAln *) ckalloc (sizeof(HitAln))) == NULL) { warn("HitAln_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->raw_score = 0; out->bit_score = 0; out->evalue = 0; out->alb = NULL; return out; } /* Function: free_HitAln(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HitAln *] * * Return [UNKN ] Undocumented return value [HitAln *] * */ HitAln * free_HitAln(HitAln * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HitAln obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->alb != NULL) free_AlnBlock(obj->alb); ckfree(obj); return NULL; } /* Function: swap_HitPair(list,i,j) * * Descrip: swap function: an internal for qsort_HitPair * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [HitAln **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_HitPair(HitAln ** list,int i,int j) { HitAln * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_HitPair(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_HitPair which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [HitAln **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_HitPair(HitAln ** list,int left,int right,int (*comp)(HitAln * ,HitAln * )) { int i,last; if( left >= right ) return; swap_HitPair(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_HitPair (list,++last,i); } swap_HitPair (list,left,last); qsort_HitPair(list,left,last-1,comp); qsort_HitPair(list,last+1,right,comp); } /* Function: sort_HitPair(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_HitPair * * * Arg: obj [UNKN ] Object containing list [HitPair *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_HitPair(HitPair * obj,int (*comp)(HitAln *, HitAln *)) { qsort_HitPair(obj->aln,0,obj->len-1,comp); return; } /* Function: expand_HitPair(obj,len) * * Descrip: Really an internal function for add_HitPair * * * Arg: obj [UNKN ] Object which contains the list [HitPair *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_HitPair(HitPair * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_HitPair called with no need"); return TRUE; } if( (obj->aln = (HitAln ** ) ckrealloc (obj->aln,sizeof(HitAln *)*len)) == NULL) { warn("ckrealloc failed for expand_HitPair, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_HitPair(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [HitPair *] * Arg: add [OWNER] Object to add to the list [HitAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_HitPair(HitPair * obj,HitAln * add) { if( obj->len >= obj->maxlen) { if( expand_HitPair(obj,obj->len + HitPairLISTLENGTH) == FALSE) return FALSE; } obj->aln[obj->len++]=add; return TRUE; } /* Function: flush_HitPair(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [HitPair *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_HitPair(HitPair * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->aln[i] != NULL) { free_HitAln(obj->aln[i]); obj->aln[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: HitPair_alloc_std(void) * * Descrip: Equivalent to HitPair_alloc_len(HitPairLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [HitPair *] * */ HitPair * HitPair_alloc_std(void) { return HitPair_alloc_len(HitPairLISTLENGTH); } /* Function: HitPair_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [HitPair *] * */ HitPair * HitPair_alloc_len(int len) { HitPair * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = HitPair_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->aln = (HitAln ** ) ckcalloc (len,sizeof(HitAln *))) == NULL) { warn("Warning, ckcalloc failed in HitPair_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_HitPair(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HitPair *] * * Return [UNKN ] Undocumented return value [HitPair *] * */ HitPair * hard_link_HitPair(HitPair * obj) { if( obj == NULL ) { warn("Trying to hard link to a HitPair object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HitPair_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HitPair *] * */ HitPair * HitPair_alloc(void) { HitPair * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HitPair *) ckalloc (sizeof(HitPair))) == NULL) { warn("HitPair_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->query = NULL; out->target = NULL; out->raw_score = 0; out->bit_score = 0; out->evalue = 0; out->aln = NULL; out->len = out->maxlen = 0; out->target_reversed = FALSE; return out; } /* Function: free_HitPair(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HitPair *] * * Return [UNKN ] Undocumented return value [HitPair *] * */ HitPair * free_HitPair(HitPair * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HitPair obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->query != NULL) free_Sequence(obj->query); if( obj->target != NULL) free_Sequence(obj->target); if( obj->aln != NULL) { for(i=0;ilen;i++) { if( obj->aln[i] != NULL) free_HitAln(obj->aln[i]); } ckfree(obj->aln); } ckfree(obj); return NULL; } /* Function: swap_HitList(list,i,j) * * Descrip: swap function: an internal for qsort_HitList * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [HitPair **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_HitList(HitPair ** list,int i,int j) { HitPair * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_HitList(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_HitList which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [HitPair **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_HitList(HitPair ** list,int left,int right,int (*comp)(HitPair * ,HitPair * )) { int i,last; if( left >= right ) return; swap_HitList(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_HitList (list,++last,i); } swap_HitList (list,left,last); qsort_HitList(list,left,last-1,comp); qsort_HitList(list,last+1,right,comp); } /* Function: sort_HitList(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_HitList * * * Arg: obj [UNKN ] Object containing list [HitList *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_HitList(HitList * obj,int (*comp)(HitPair *, HitPair *)) { qsort_HitList(obj->pair,0,obj->len-1,comp); return; } /* Function: expand_HitList(obj,len) * * Descrip: Really an internal function for add_HitList * * * Arg: obj [UNKN ] Object which contains the list [HitList *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_HitList(HitList * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_HitList called with no need"); return TRUE; } if( (obj->pair = (HitPair ** ) ckrealloc (obj->pair,sizeof(HitPair *)*len)) == NULL) { warn("ckrealloc failed for expand_HitList, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_HitList(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [HitList *] * Arg: add [OWNER] Object to add to the list [HitPair *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_HitList(HitList * obj,HitPair * add) { if( obj->len >= obj->maxlen) { if( expand_HitList(obj,obj->len + HitListLISTLENGTH) == FALSE) return FALSE; } obj->pair[obj->len++]=add; return TRUE; } /* Function: flush_HitList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [HitList *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_HitList(HitList * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->pair[i] != NULL) { free_HitPair(obj->pair[i]); obj->pair[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: HitList_alloc_std(void) * * Descrip: Equivalent to HitList_alloc_len(HitListLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [HitList *] * */ HitList * HitList_alloc_std(void) { return HitList_alloc_len(HitListLISTLENGTH); } /* Function: HitList_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [HitList *] * */ HitList * HitList_alloc_len(int len) { HitList * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = HitList_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->pair = (HitPair ** ) ckcalloc (len,sizeof(HitPair *))) == NULL) { warn("Warning, ckcalloc failed in HitList_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_HitList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HitList *] * * Return [UNKN ] Undocumented return value [HitList *] * */ HitList * hard_link_HitList(HitList * obj) { if( obj == NULL ) { warn("Trying to hard link to a HitList object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HitList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HitList *] * */ HitList * HitList_alloc(void) { HitList * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HitList *) ckalloc (sizeof(HitList))) == NULL) { warn("HitList_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->pair = NULL; out->len = out->maxlen = 0; out->mat = NULL; out->write_btc_func = NULL; out->stat_attrib = NULL; return out; } /* Function: free_HitList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HitList *] * * Return [UNKN ] Undocumented return value [HitList *] * */ HitList * free_HitList(HitList * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HitList obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->pair != NULL) { for(i=0;ilen;i++) { if( obj->pair[i] != NULL) free_HitPair(obj->pair[i]); } ckfree(obj->pair); } if( obj->mat != NULL) free_CompMat(obj->mat); /* obj->write_btc_func is a function pointer */ if( obj->stat_attrib != NULL) ckfree(obj->stat_attrib); ckfree(obj); return NULL; } /* Function: hard_link_HitListOutputImpl(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HitListOutputImpl *] * * Return [UNKN ] Undocumented return value [HitListOutputImpl *] * */ HitListOutputImpl * hard_link_HitListOutputImpl(HitListOutputImpl * obj) { if( obj == NULL ) { warn("Trying to hard link to a HitListOutputImpl object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HitListOutputImpl_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HitListOutputImpl *] * */ HitListOutputImpl * HitListOutputImpl_alloc(void) { HitListOutputImpl * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HitListOutputImpl *) ckalloc (sizeof(HitListOutputImpl))) == NULL) { warn("HitListOutputImpl_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = HitListOutputFormatPseudoBlast; return out; } /* Function: free_HitListOutputImpl(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HitListOutputImpl *] * * Return [UNKN ] Undocumented return value [HitListOutputImpl *] * */ HitListOutputImpl * free_HitListOutputImpl(HitListOutputImpl * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HitListOutputImpl obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/hitlist.h0000644000175000001440000004362610670453712016502 0ustar philippusers#ifndef DYNAMITEhitlistHEADERFILE #define DYNAMITEhitlistHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #include "hsp.h" #include "aln.h" #include "compmat.h" #include "btcanvas.h" #include "asciibtcanvas.h" #include "searchstatinterface.h" #define HitListLISTLENGTH 256 #define HitPairLISTLENGTH 16 typedef enum HitListOutputFormat { HitListOutputFormatPseudoBlast = 34, HitListOutputFormatXML, HitListOutputFormatTab, HitListAlnCumlative, HitListOutputFormatUnknown } HitListOutputFormat; struct Wise2_HitAln { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int raw_score; double bit_score; double evalue; AlnBlock * alb; } ; /* HitAln defined */ #ifndef DYNAMITE_DEFINED_HitAln typedef struct Wise2_HitAln Wise2_HitAln; #define HitAln Wise2_HitAln #define DYNAMITE_DEFINED_HitAln #endif struct Wise2_HitPair { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence * query; Sequence * target; int raw_score; double bit_score; double evalue; HitAln ** aln; int len;/* len for above aln */ int maxlen; /* maxlen for above aln */ boolean target_reversed; } ; /* HitPair defined */ #ifndef DYNAMITE_DEFINED_HitPair typedef struct Wise2_HitPair Wise2_HitPair; #define HitPair Wise2_HitPair #define DYNAMITE_DEFINED_HitPair #endif struct Wise2_HitList { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif HitPair ** pair; int len;/* len for above pair */ int maxlen; /* maxlen for above pair */ CompMat * mat; boolean (*write_btc_func)(AlnBlock *,Sequence *,Sequence *,btCanvas * btc); char * stat_attrib; } ; /* HitList defined */ #ifndef DYNAMITE_DEFINED_HitList typedef struct Wise2_HitList Wise2_HitList; #define HitList Wise2_HitList #define DYNAMITE_DEFINED_HitList #endif struct Wise2_HitListOutputImpl { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif HitListOutputFormat type; } ; /* HitListOutputImpl defined */ #ifndef DYNAMITE_DEFINED_HitListOutputImpl typedef struct Wise2_HitListOutputImpl Wise2_HitListOutputImpl; #define HitListOutputImpl Wise2_HitListOutputImpl #define DYNAMITE_DEFINED_HitListOutputImpl #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: sort_HitList_by_score(hl) * * Descrip: Sorts by score * * * Arg: hl [UNKN ] Undocumented argument [HitList *] * */ void Wise2_sort_HitList_by_score(HitList * hl); #define sort_HitList_by_score Wise2_sort_HitList_by_score /* Function: compare_HitPair_score(one,two) * * Descrip: internal function to sort by score * * * Arg: one [UNKN ] Undocumented argument [HitPair *] * Arg: two [UNKN ] Undocumented argument [HitPair *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_compare_HitPair_score(HitPair * one,HitPair * two) ; #define compare_HitPair_score Wise2_compare_HitPair_score /* Function: apply_SearchStat_to_HitList(hspm,ssi,database_size) * * Descrip: Applies statistics across a hitlist * * * Arg: hspm [UNKN ] Undocumented argument [HitList *] * Arg: ssi [UNKN ] Undocumented argument [SearchStatInterface *] * Arg: database_size [UNKN ] Undocumented argument [int] * */ void Wise2_apply_SearchStat_to_HitList(HitList * hspm,SearchStatInterface * ssi,int database_size); #define apply_SearchStat_to_HitList Wise2_apply_SearchStat_to_HitList /* Function: HitList_from_LinearHSPmanager(lm) * * Descrip: Converts a LinearHSPmanager into a HitList * * * Arg: lm [UNKN ] Undocumented argument [LinearHSPmanager *] * * Return [UNKN ] Undocumented return value [HitList *] * */ HitList * Wise2_HitList_from_LinearHSPmanager(LinearHSPmanager * lm); #define HitList_from_LinearHSPmanager Wise2_HitList_from_LinearHSPmanager /* Function: HitPair_from_HSPset(set,mat) * * Descrip: Builds a Hitpair from an HSP, not doing * alignment * * * Arg: set [UNKN ] Undocumented argument [HSPset *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * * Return [UNKN ] Undocumented return value [HitPair *] * */ HitPair * Wise2_HitPair_from_HSPset(HSPset * set,CompMat * mat); #define HitPair_from_HSPset Wise2_HitPair_from_HSPset /* Function: ungapped_AlnBlock_from_HSP(hsp,q,t,mat) * * Descrip: Builds an expanded AlnBlock with one AlnColumn * per residue for an ungapped HSP * * * Arg: hsp [UNKN ] Undocumented argument [HSP *] * Arg: q [UNKN ] Undocumented argument [Sequence *] * Arg: t [UNKN ] Undocumented argument [Sequence *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_ungapped_AlnBlock_from_HSP(HSP * hsp,Sequence * q,Sequence * t,CompMat * mat); #define ungapped_AlnBlock_from_HSP Wise2_ungapped_AlnBlock_from_HSP /* Function: new_HitListOutputImpl_from_argv(argc,argv) * * Descrip: Builds a new HitListOutputFormat from commandline * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [HitListOutputImpl *] * */ HitListOutputImpl * Wise2_new_HitListOutputImpl_from_argv(int * argc,char ** argv); #define new_HitListOutputImpl_from_argv Wise2_new_HitListOutputImpl_from_argv /* Function: show_help_HitListOutputImpl(ofp) * * Descrip: Shows help for HitList output * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_help_HitListOutputImpl(FILE * ofp); #define show_help_HitListOutputImpl Wise2_show_help_HitListOutputImpl /* Function: show_HitList_HitListOutputImpl(hloi,hl,ofp) * * Descrip: Shows a hitlist wrt to output impl * * * Arg: hloi [UNKN ] Undocumented argument [HitListOutputImpl *] * Arg: hl [UNKN ] Undocumented argument [HitList *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_HitList_HitListOutputImpl(HitListOutputImpl * hloi,HitList * hl,FILE * ofp); #define show_HitList_HitListOutputImpl Wise2_show_HitList_HitListOutputImpl /* Function: write_alb_HitList(hl,ofp) * * Descrip: Writes Alb output * * * Arg: hl [UNKN ] Undocumented argument [HitList *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_write_alb_HitList(HitList * hl,FILE * ofp); #define write_alb_HitList Wise2_write_alb_HitList /* Function: write_XML_HitList(hl,ofp) * * Descrip: Writes XML output * * * Arg: hl [UNKN ] Undocumented argument [HitList *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_write_XML_HitList(HitList * hl,FILE * ofp); #define write_XML_HitList Wise2_write_XML_HitList /* Function: write_tab_HitList(hl,ofp) * * Descrip: Writes tab delimited tab like output * * * Arg: hl [UNKN ] Undocumented argument [HitList *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_write_tab_HitList(HitList * hl,FILE * ofp); #define write_tab_HitList Wise2_write_tab_HitList /* Function: write_pseudoblast_HitList(hl,ofp) * * Descrip: Writes pseudoblast output * * * Arg: hl [UNKN ] Undocumented argument [HitList *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_write_pseudoblast_HitList(HitList * hl,FILE * ofp); #define write_pseudoblast_HitList Wise2_write_pseudoblast_HitList /* Function: write_pretty_Seq_blast_align_btc(alb,one,two,btc) * * Descrip: Chains up to char* level alignment writer * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: one [UNKN ] Undocumented argument [Sequence *] * Arg: two [UNKN ] Undocumented argument [Sequence *] * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_write_pretty_Seq_blast_align_btc(AlnBlock * alb,Sequence * one,Sequence * two,btCanvas * btc); #define write_pretty_Seq_blast_align_btc Wise2_write_pretty_Seq_blast_align_btc /* Function: write_pretty_str_blast_align_btc(alb,qname,query,tname,target,btc) * * Descrip: This function writes precisely * what you expect for a a simple alignment. * * We can reuse this routine all over the place because * we dont use any hard coded structure for the * query or the target sequence letters. ... but crap * type checking it has to be said! * * Also we use a generic btCanvas that could have * any implementation underneath (eg, ASCII, postscript etc). * * * Arg: alb [UNKN ] Undocumented argument [AlnBlock *] * Arg: qname [UNKN ] Undocumented argument [char *] * Arg: query [UNKN ] Undocumented argument [char *] * Arg: tname [UNKN ] Undocumented argument [char *] * Arg: target [UNKN ] Undocumented argument [char *] * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_write_pretty_str_blast_align_btc(AlnBlock * alb,char * qname,char * query,char * tname,char * target,btCanvas * btc); #define write_pretty_str_blast_align_btc Wise2_write_pretty_str_blast_align_btc /* Function: hard_link_HitAln(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HitAln *] * * Return [UNKN ] Undocumented return value [HitAln *] * */ HitAln * Wise2_hard_link_HitAln(HitAln * obj); #define hard_link_HitAln Wise2_hard_link_HitAln /* Function: HitAln_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HitAln *] * */ HitAln * Wise2_HitAln_alloc(void); #define HitAln_alloc Wise2_HitAln_alloc /* Function: free_HitAln(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HitAln *] * * Return [UNKN ] Undocumented return value [HitAln *] * */ HitAln * Wise2_free_HitAln(HitAln * obj); #define free_HitAln Wise2_free_HitAln /* Function: add_HitPair(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [HitPair *] * Arg: add [OWNER] Object to add to the list [HitAln *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_HitPair(HitPair * obj,HitAln * add); #define add_HitPair Wise2_add_HitPair /* Function: flush_HitPair(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [HitPair *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_HitPair(HitPair * obj); #define flush_HitPair Wise2_flush_HitPair /* Function: HitPair_alloc_std(void) * * Descrip: Equivalent to HitPair_alloc_len(HitPairLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [HitPair *] * */ HitPair * Wise2_HitPair_alloc_std(void); #define HitPair_alloc_std Wise2_HitPair_alloc_std /* Function: HitPair_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [HitPair *] * */ HitPair * Wise2_HitPair_alloc_len(int len); #define HitPair_alloc_len Wise2_HitPair_alloc_len /* Function: hard_link_HitPair(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HitPair *] * * Return [UNKN ] Undocumented return value [HitPair *] * */ HitPair * Wise2_hard_link_HitPair(HitPair * obj); #define hard_link_HitPair Wise2_hard_link_HitPair /* Function: HitPair_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HitPair *] * */ HitPair * Wise2_HitPair_alloc(void); #define HitPair_alloc Wise2_HitPair_alloc /* Function: free_HitPair(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HitPair *] * * Return [UNKN ] Undocumented return value [HitPair *] * */ HitPair * Wise2_free_HitPair(HitPair * obj); #define free_HitPair Wise2_free_HitPair /* Function: add_HitList(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [HitList *] * Arg: add [OWNER] Object to add to the list [HitPair *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_HitList(HitList * obj,HitPair * add); #define add_HitList Wise2_add_HitList /* Function: flush_HitList(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [HitList *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_HitList(HitList * obj); #define flush_HitList Wise2_flush_HitList /* Function: HitList_alloc_std(void) * * Descrip: Equivalent to HitList_alloc_len(HitListLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [HitList *] * */ HitList * Wise2_HitList_alloc_std(void); #define HitList_alloc_std Wise2_HitList_alloc_std /* Function: HitList_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [HitList *] * */ HitList * Wise2_HitList_alloc_len(int len); #define HitList_alloc_len Wise2_HitList_alloc_len /* Function: hard_link_HitList(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HitList *] * * Return [UNKN ] Undocumented return value [HitList *] * */ HitList * Wise2_hard_link_HitList(HitList * obj); #define hard_link_HitList Wise2_hard_link_HitList /* Function: HitList_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HitList *] * */ HitList * Wise2_HitList_alloc(void); #define HitList_alloc Wise2_HitList_alloc /* Function: free_HitList(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HitList *] * * Return [UNKN ] Undocumented return value [HitList *] * */ HitList * Wise2_free_HitList(HitList * obj); #define free_HitList Wise2_free_HitList /* Function: hard_link_HitListOutputImpl(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HitListOutputImpl *] * * Return [UNKN ] Undocumented return value [HitListOutputImpl *] * */ HitListOutputImpl * Wise2_hard_link_HitListOutputImpl(HitListOutputImpl * obj); #define hard_link_HitListOutputImpl Wise2_hard_link_HitListOutputImpl /* Function: HitListOutputImpl_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HitListOutputImpl *] * */ HitListOutputImpl * Wise2_HitListOutputImpl_alloc(void); #define HitListOutputImpl_alloc Wise2_HitListOutputImpl_alloc /* Function: free_HitListOutputImpl(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HitListOutputImpl *] * * Return [UNKN ] Undocumented return value [HitListOutputImpl *] * */ HitListOutputImpl * Wise2_free_HitListOutputImpl(HitListOutputImpl * obj); #define free_HitListOutputImpl Wise2_free_HitListOutputImpl /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_HitPair(HitAln ** list,int i,int j) ; #define swap_HitPair Wise2_swap_HitPair void Wise2_qsort_HitPair(HitAln ** list,int left,int right,int (*comp)(HitAln * ,HitAln * )); #define qsort_HitPair Wise2_qsort_HitPair void Wise2_sort_HitPair(HitPair * obj,int (*comp)(HitAln *, HitAln *)); #define sort_HitPair Wise2_sort_HitPair boolean Wise2_expand_HitPair(HitPair * obj,int len); #define expand_HitPair Wise2_expand_HitPair void Wise2_swap_HitList(HitPair ** list,int i,int j) ; #define swap_HitList Wise2_swap_HitList void Wise2_qsort_HitList(HitPair ** list,int left,int right,int (*comp)(HitPair * ,HitPair * )); #define qsort_HitList Wise2_qsort_HitList void Wise2_sort_HitList(HitList * obj,int (*comp)(HitPair *, HitPair *)); #define sort_HitList Wise2_sort_HitList boolean Wise2_expand_HitList(HitList * obj,int len); #define expand_HitList Wise2_expand_HitList #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/intallocator.c0000644000175000001440000003520410670453712017501 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "intallocator.h" /* Function: new_IntAllocatorSet(max_size) * * Descrip: Makes a new IntAllocatorSet up to a certain size * * * Arg: max_size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [IntAllocatorSet *] * */ # line 43 "intallocator.dy" IntAllocatorSet * new_IntAllocatorSet(int max_size) { IntAllocatorSet * out; out = IntAllocatorSet_alloc(); out->allocator_set = calloc(max_size,sizeof(IntAllocator*)); out->max_size = max_size; return out; } /* Function: realloc_intarray_IntAllocatorSet(ias,current,old_size,new_size) * * Descrip: reallocates a piece of memory * * * Arg: ias [UNKN ] Undocumented argument [IntAllocatorSet *] * Arg: current [UNKN ] Undocumented argument [int *] * Arg: old_size [UNKN ] Undocumented argument [int] * Arg: new_size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int *] * */ # line 60 "intallocator.dy" int * realloc_intarray_IntAllocatorSet(IntAllocatorSet * ias,int * current,int old_size,int new_size) { int i; int * new_a; assert(ias); assert(new_size > old_size); new_a = alloc_intarray_IntAllocatorSet(ias,new_size); assert(new_a); for(i=0;i ias->max_size ) { return free(array); } assert(ias->allocator_set[size]); return free_intarray_IntAllocator(ias->allocator_set[size],array); } /* Function: alloc_intarray_IntAllocatorSet(ias,size) * * Descrip: Allocates a new piece of memory in a IntAllocatorSet * * * Arg: ias [UNKN ] Undocumented argument [IntAllocatorSet *] * Arg: size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int *] * */ # line 101 "intallocator.dy" int * alloc_intarray_IntAllocatorSet(IntAllocatorSet * ias,int size) { assert(ias); if( size > ias->max_size ) { return (int*)calloc(size,sizeof(int)); } if( ias->allocator_set[size] == NULL ) { ias->allocator_set[size] = new_IntAllocator(size); } return alloc_intarray_IntAllocator(ias->allocator_set[size]); } /* Function: new_IntAllocator(size) * * Descrip: Makes a new int allocator * * * Arg: size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [IntAllocator *] * */ # line 120 "intallocator.dy" IntAllocator * new_IntAllocator(int size) { IntAllocator * out; #ifdef IntAllocator_PARANOIA warn("IntAllocator in paranoia mode. Will perform horrendously slowly due to cycle checking"); #endif out = IntAllocator_alloc(); out->size = size; out->start_of_free = NULL; out->allocated_blocks = NULL; out->max_allocated_blocks = 0; out->current_allocated_block = 0; return out; } #ifdef IntAllocator_PARANOIA /* Function: is_acyclic_IntAllocator(ia) * * Descrip: Detect cycle * * * Arg: ia [UNKN ] Undocumented argument [IntAllocator *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 143 "intallocator.dy" boolean is_acyclic_IntAllocator(IntAllocator * ia) { GHashTable * gh; IntAllocatorHeader * h; int count; int dummy; assert(ia); gh = g_hash_table_new(g_direct_hash,g_direct_equal); count = 0; for(h = ia->start_of_free;h != NULL;h = h->s.next) { if( g_hash_table_lookup(gh,(gconstpointer)h) != NULL ) { warn("Found cycle at memory position %d, count %d",h,count); return FALSE; } else { g_hash_table_insert(gh,(gpointer)h,&dummy); count++; } } g_hash_table_destroy(gh); return TRUE; } #endif /* Function: show_allocator_status_IntAllocatorSet(ias,ofp) * * Descrip: Show status of intallocator set * * * Arg: ias [UNKN ] Undocumented argument [IntAllocatorSet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 178 "intallocator.dy" void show_allocator_status_IntAllocatorSet(IntAllocatorSet * ias,FILE * ofp) { int i; int count; IntAllocatorHeader * h; IntAllocator * ia; int mem; long total = 0; for(i=0;imax_size;i++) { if( ias->allocator_set[i] == NULL ) { fprintf(ofp,"[%4d] No allocator\n",i); } else { ia = ias->allocator_set[i]; for(h = ia->start_of_free,count =0;h != NULL;h = h->s.next) { count++; } mem = ia->current_allocated_block * (sizeof(IntAllocatorHeader)+(sizeof(int)*ia->size)) * IntAllocator_BLOCKSIZE; total += mem; fprintf(ofp,"[%4d] %d allocated, %d free, total bytes %d\n",i,ia->current_allocated_block*IntAllocator_BLOCKSIZE,count,mem); } } fprintf(ofp,"In total, %ld bytes allocated\n",total); } /* Function: show_allocator_status_IntAllocator(ia,ofp) * * Descrip: Shows allocator status * * * Arg: ia [UNKN ] Undocumented argument [IntAllocator *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 211 "intallocator.dy" void show_allocator_status_IntAllocator(IntAllocator * ia,FILE * ofp) { int count = 0; IntAllocatorHeader * h; fprintf(ofp,"%d blocks allocated, using %ld bytes\n",ia->current_allocated_block,ia->current_allocated_block * (sizeof(IntAllocatorHeader)+(sizeof(int)*ia->size)) * IntAllocator_BLOCKSIZE); for(h = ia->start_of_free;h != NULL;h = h->s.next) { count++; } fprintf(ofp,"%d units free, %.2f %% occupancy\n",count,(count*100.0)/(ia->current_allocated_block * IntAllocator_BLOCKSIZE)); } /* Function: free_intarray_IntAllocator(ia,array) * * Descrip: returns an integer back to the pool. NOTE: * This integer * must have come from the pool otherwise * there is going to be a disaster... * * * Arg: ia [UNKN ] Undocumented argument [IntAllocator *] * Arg: array [UNKN ] Undocumented argument [int *] * */ # line 230 "intallocator.dy" void free_intarray_IntAllocator(IntAllocator * ia,int * array) { char * runner; IntAllocatorHeader * h; assert(ia); assert(array); runner = (char*) array; runner = runner - sizeof(IntAllocatorHeader); h = (IntAllocatorHeader*) runner; h->s.next = ia->start_of_free; ia->start_of_free = h; #ifdef IntAllocator_PARANOIA if( is_acyclic_IntAllocator(ia) == FALSE ) { fatal("cycle detected on freeing block for %d position",h); } #endif return; } /* Function: alloc_intarray_IntAllocator(ia) * * Descrip: returns an integer * from this allocator * * * Arg: ia [UNKN ] Undocumented argument [IntAllocator *] * * Return [UNKN ] Undocumented return value [int *] * */ # line 259 "intallocator.dy" int * alloc_intarray_IntAllocator(IntAllocator * ia) { IntAllocatorHeader * h; char * runner; assert(ia); if( ia->start_of_free == NULL ) { ia->start_of_free = allocate_new_block_IntAllocator(ia); } #ifdef IntAllocator_PARANOIA if( is_acyclic_IntAllocator(ia) == FALSE ) { fatal("cycle detected on allocating new block"); } #endif h = ia->start_of_free; ia->start_of_free = h->s.next; #ifdef IntAllocator_PARANOIA if( is_acyclic_IntAllocator(ia) == FALSE ) { fatal("cycle detected on returning new block"); } #endif runner = (char*) h; runner = runner + sizeof(IntAllocatorHeader); return (int*) runner; } /* Function: allocate_new_block_IntAllocator(ia) * * Descrip: internal function to allocate and segment * a block read for use, storing the memory * and segmenting it correctly. Returned pointer * is the first header block * * * Arg: ia [UNKN ] Undocumented argument [IntAllocator *] * * Return [UNKN ] Undocumented return value [IntAllocatorHeader *] * */ # line 298 "intallocator.dy" IntAllocatorHeader * allocate_new_block_IntAllocator(IntAllocator * ia) { int i; int step_size; char * new_block; IntAllocatorHeader * h; char * runner; assert(ia); step_size = sizeof(IntAllocatorHeader)+(sizeof(int)*ia->size); new_block = calloc(IntAllocator_BLOCKSIZE,step_size); add_new_block_to_memory_handlers_IA(ia,new_block); for(i=0;is.next = (IntAllocatorHeader*) runner; } else { /* last one */ h->s.next = NULL; } } return (IntAllocatorHeader*) new_block; } /* Function: add_new_block_to_memory_handlers_IA(ia,new_block) * * Descrip: internal function to ensure new block is added, with growth of block array * if needed * * * Arg: ia [UNKN ] Undocumented argument [IntAllocator *] * Arg: new_block [UNKN ] Undocumented argument [void *] * */ # line 334 "intallocator.dy" void add_new_block_to_memory_handlers_IA(IntAllocator * ia,void * new_block) { assert(ia); assert(new_block); if( ia->allocated_blocks == NULL ) { ia->allocated_blocks = calloc(IntAllocator_MEMORY_BLOCK_SIZE,sizeof(void*)); ia->max_allocated_blocks = IntAllocator_MEMORY_BLOCK_SIZE; ia->current_allocated_block = 0; } else if( ia->current_allocated_block >= ia->max_allocated_blocks ) { ia->allocated_blocks = realloc(ia->allocated_blocks,(ia->max_allocated_blocks+IntAllocator_MEMORY_BLOCK_SIZE)*sizeof(void*)); ia->max_allocated_blocks = (ia->max_allocated_blocks+IntAllocator_MEMORY_BLOCK_SIZE); } ia->allocated_blocks[ia->current_allocated_block++] = new_block; return; } # line 391 "intallocator.c" /* Function: hard_link_IntAllocator(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [IntAllocator *] * * Return [UNKN ] Undocumented return value [IntAllocator *] * */ IntAllocator * hard_link_IntAllocator(IntAllocator * obj) { if( obj == NULL ) { warn("Trying to hard link to a IntAllocator object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: IntAllocator_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [IntAllocator *] * */ IntAllocator * IntAllocator_alloc(void) { IntAllocator * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(IntAllocator *) ckalloc (sizeof(IntAllocator))) == NULL) { warn("IntAllocator_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->size = 0; out->max_allocated_blocks = 0; out->current_allocated_block = 0; return out; } /* Function: free_IntAllocator(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [IntAllocator *] * * Return [UNKN ] Undocumented return value [IntAllocator *] * */ IntAllocator * free_IntAllocator(IntAllocator * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a IntAllocator obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->start_of_free is linked in */ /* obj->allocated_blocks is linked in */ ckfree(obj); return NULL; } /* Function: hard_link_IntAllocatorSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [IntAllocatorSet *] * * Return [UNKN ] Undocumented return value [IntAllocatorSet *] * */ IntAllocatorSet * hard_link_IntAllocatorSet(IntAllocatorSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a IntAllocatorSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: IntAllocatorSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [IntAllocatorSet *] * */ IntAllocatorSet * IntAllocatorSet_alloc(void) { IntAllocatorSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(IntAllocatorSet *) ckalloc (sizeof(IntAllocatorSet))) == NULL) { warn("IntAllocatorSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->allocator_set = NULL; out->max_size = 0; return out; } /* Function: free_IntAllocatorSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [IntAllocatorSet *] * * Return [UNKN ] Undocumented return value [IntAllocatorSet *] * */ IntAllocatorSet * free_IntAllocatorSet(IntAllocatorSet * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a IntAllocatorSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->allocator_set != NULL) ckfree(obj->allocator_set); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/intallocator.h0000644000175000001440000002301410670453712017502 0ustar philippusers#ifndef DYNAMITEintallocatorHEADERFILE #define DYNAMITEintallocatorHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include typedef union int_allocator_header { struct { union int_allocator_header * next; /* when free */ }s ; int dummy; /* to ensure alignment */ } IntAllocatorHeader; #define IntAllocator_BLOCKSIZE 512 #define IntAllocator_MEMORY_BLOCK_SIZE 512 /* #define IntAllocator_PARANOIA 1 */ struct Wise2_IntAllocator { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int size; IntAllocatorHeader * start_of_free; void ** allocated_blocks; int max_allocated_blocks; int current_allocated_block; } ; /* IntAllocator defined */ #ifndef DYNAMITE_DEFINED_IntAllocator typedef struct Wise2_IntAllocator Wise2_IntAllocator; #define IntAllocator Wise2_IntAllocator #define DYNAMITE_DEFINED_IntAllocator #endif struct Wise2_IntAllocatorSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif IntAllocator ** allocator_set; int max_size; } ; /* IntAllocatorSet defined */ #ifndef DYNAMITE_DEFINED_IntAllocatorSet typedef struct Wise2_IntAllocatorSet Wise2_IntAllocatorSet; #define IntAllocatorSet Wise2_IntAllocatorSet #define DYNAMITE_DEFINED_IntAllocatorSet #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_IntAllocatorSet(max_size) * * Descrip: Makes a new IntAllocatorSet up to a certain size * * * Arg: max_size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [IntAllocatorSet *] * */ IntAllocatorSet * Wise2_new_IntAllocatorSet(int max_size); #define new_IntAllocatorSet Wise2_new_IntAllocatorSet /* Function: realloc_intarray_IntAllocatorSet(ias,current,old_size,new_size) * * Descrip: reallocates a piece of memory * * * Arg: ias [UNKN ] Undocumented argument [IntAllocatorSet *] * Arg: current [UNKN ] Undocumented argument [int *] * Arg: old_size [UNKN ] Undocumented argument [int] * Arg: new_size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int *] * */ int * Wise2_realloc_intarray_IntAllocatorSet(IntAllocatorSet * ias,int * current,int old_size,int new_size); #define realloc_intarray_IntAllocatorSet Wise2_realloc_intarray_IntAllocatorSet /* Function: free_intarray_IntAllocatorSet(ias,array,size) * * Descrip: Frees a piece of memory in a IntAllocatorSet * * * Arg: ias [UNKN ] Undocumented argument [IntAllocatorSet *] * Arg: array [UNKN ] Undocumented argument [int *] * Arg: size [UNKN ] Undocumented argument [int] * */ void Wise2_free_intarray_IntAllocatorSet(IntAllocatorSet * ias,int * array,int size); #define free_intarray_IntAllocatorSet Wise2_free_intarray_IntAllocatorSet /* Function: alloc_intarray_IntAllocatorSet(ias,size) * * Descrip: Allocates a new piece of memory in a IntAllocatorSet * * * Arg: ias [UNKN ] Undocumented argument [IntAllocatorSet *] * Arg: size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int *] * */ int * Wise2_alloc_intarray_IntAllocatorSet(IntAllocatorSet * ias,int size); #define alloc_intarray_IntAllocatorSet Wise2_alloc_intarray_IntAllocatorSet /* Function: new_IntAllocator(size) * * Descrip: Makes a new int allocator * * * Arg: size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [IntAllocator *] * */ IntAllocator * Wise2_new_IntAllocator(int size); #define new_IntAllocator Wise2_new_IntAllocator /* Function: is_acyclic_IntAllocator(ia) * * Descrip: Detect cycle * * * Arg: ia [UNKN ] Undocumented argument [IntAllocator *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_acyclic_IntAllocator(IntAllocator * ia); #define is_acyclic_IntAllocator Wise2_is_acyclic_IntAllocator /* Function: show_allocator_status_IntAllocatorSet(ias,ofp) * * Descrip: Show status of intallocator set * * * Arg: ias [UNKN ] Undocumented argument [IntAllocatorSet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_allocator_status_IntAllocatorSet(IntAllocatorSet * ias,FILE * ofp); #define show_allocator_status_IntAllocatorSet Wise2_show_allocator_status_IntAllocatorSet /* Function: show_allocator_status_IntAllocator(ia,ofp) * * Descrip: Shows allocator status * * * Arg: ia [UNKN ] Undocumented argument [IntAllocator *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_allocator_status_IntAllocator(IntAllocator * ia,FILE * ofp); #define show_allocator_status_IntAllocator Wise2_show_allocator_status_IntAllocator /* Function: free_intarray_IntAllocator(ia,array) * * Descrip: returns an integer back to the pool. NOTE: * This integer * must have come from the pool otherwise * there is going to be a disaster... * * * Arg: ia [UNKN ] Undocumented argument [IntAllocator *] * Arg: array [UNKN ] Undocumented argument [int *] * */ void Wise2_free_intarray_IntAllocator(IntAllocator * ia,int * array); #define free_intarray_IntAllocator Wise2_free_intarray_IntAllocator /* Function: alloc_intarray_IntAllocator(ia) * * Descrip: returns an integer * from this allocator * * * Arg: ia [UNKN ] Undocumented argument [IntAllocator *] * * Return [UNKN ] Undocumented return value [int *] * */ int * Wise2_alloc_intarray_IntAllocator(IntAllocator * ia); #define alloc_intarray_IntAllocator Wise2_alloc_intarray_IntAllocator /* Function: allocate_new_block_IntAllocator(ia) * * Descrip: internal function to allocate and segment * a block read for use, storing the memory * and segmenting it correctly. Returned pointer * is the first header block * * * Arg: ia [UNKN ] Undocumented argument [IntAllocator *] * * Return [UNKN ] Undocumented return value [IntAllocatorHeader *] * */ IntAllocatorHeader * Wise2_allocate_new_block_IntAllocator(IntAllocator * ia); #define allocate_new_block_IntAllocator Wise2_allocate_new_block_IntAllocator /* Function: add_new_block_to_memory_handlers_IA(ia,new_block) * * Descrip: internal function to ensure new block is added, with growth of block array * if needed * * * Arg: ia [UNKN ] Undocumented argument [IntAllocator *] * Arg: new_block [UNKN ] Undocumented argument [void *] * */ void Wise2_add_new_block_to_memory_handlers_IA(IntAllocator * ia,void * new_block); #define add_new_block_to_memory_handlers_IA Wise2_add_new_block_to_memory_handlers_IA /* Function: hard_link_IntAllocator(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [IntAllocator *] * * Return [UNKN ] Undocumented return value [IntAllocator *] * */ IntAllocator * Wise2_hard_link_IntAllocator(IntAllocator * obj); #define hard_link_IntAllocator Wise2_hard_link_IntAllocator /* Function: IntAllocator_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [IntAllocator *] * */ IntAllocator * Wise2_IntAllocator_alloc(void); #define IntAllocator_alloc Wise2_IntAllocator_alloc /* Function: free_IntAllocator(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [IntAllocator *] * * Return [UNKN ] Undocumented return value [IntAllocator *] * */ IntAllocator * Wise2_free_IntAllocator(IntAllocator * obj); #define free_IntAllocator Wise2_free_IntAllocator /* Function: hard_link_IntAllocatorSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [IntAllocatorSet *] * * Return [UNKN ] Undocumented return value [IntAllocatorSet *] * */ IntAllocatorSet * Wise2_hard_link_IntAllocatorSet(IntAllocatorSet * obj); #define hard_link_IntAllocatorSet Wise2_hard_link_IntAllocatorSet /* Function: IntAllocatorSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [IntAllocatorSet *] * */ IntAllocatorSet * Wise2_IntAllocatorSet_alloc(void); #define IntAllocatorSet_alloc Wise2_IntAllocatorSet_alloc /* Function: free_IntAllocatorSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [IntAllocatorSet *] * * Return [UNKN ] Undocumented return value [IntAllocatorSet *] * */ IntAllocatorSet * Wise2_free_IntAllocatorSet(IntAllocatorSet * obj); #define free_IntAllocatorSet Wise2_free_IntAllocatorSet /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/aln.typemap0000644000175000001440000000167210670453712017017 0ustar philippusers TYPEMAP Wise2_AlnBlock * T_Wise2_AlnBlock INPUT T_Wise2_AlnBlock $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_AlnBlock *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_AlnBlock sv_setref_pv($arg, "Wise2::AlnBlock", (void*) $var); TYPEMAP Wise2_AlnColumn * T_Wise2_AlnColumn INPUT T_Wise2_AlnColumn $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_AlnColumn *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_AlnColumn sv_setref_pv($arg, "Wise2::AlnColumn", (void*) $var); TYPEMAP Wise2_AlnUnit * T_Wise2_AlnUnit INPUT T_Wise2_AlnUnit $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_AlnUnit *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_AlnUnit sv_setref_pv($arg, "Wise2::AlnUnit", (void*) $var); TYPEMAP Wise2_AlnSequence * T_Wise2_AlnSequence INPUT T_Wise2_AlnSequence $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_AlnSequence *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_AlnSequence sv_setref_pv($arg, "Wise2::AlnSequence", (void*) $var); wise-2.4.1/src/dynlibsrc/cdna.c0000644000175000001440000002001410670453712015704 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "cdna.h" /* Function: truncate_cDNA(cdna,start,stop) * * Descrip: Truncates a cDNA sequence. Basically uses * the /magic_trunc_Sequence function (of course!) * * It does not alter cdna, rather it returns a new * sequence with that truncation * * * Arg: cdna [READ ] cDNA that is truncated [cDNA *] * Arg: start [UNKN ] Undocumented argument [int] * Arg: stop [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [cDNA *] * */ # line 45 "cdna.dy" cDNA * truncate_cDNA(cDNA * cdna,int start,int stop) { return cDNA_from_Sequence(magic_trunc_Sequence(cdna->baseseq,start,stop)); } /* Function: read_fasta_file_cDNA(filename) * * Descrip: Reads a fasta file assumming that it is cDNA. * Will complain if it is not, and return NULL. * * * Arg: filename [UNKN ] filename to be opened and read [char *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ # line 56 "cdna.dy" cDNA * read_fasta_file_cDNA(char * filename) { Sequence * seq; seq = read_fasta_file_Sequence(filename); if( seq == NULL ) { return NULL; } return cDNA_from_Sequence(seq); } /* Function: read_fasta_cDNA(ifp) * * Descrip: Reads a fasta file assumming that it is cDNA. * Will complain if it is not, and return NULL. * * * Arg: ifp [UNKN ] file point to be read from [FILE *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ # line 75 "cdna.dy" cDNA * read_fasta_cDNA(FILE * ifp) { Sequence * seq; seq = read_fasta_Sequence(ifp); if( seq == NULL ) { return NULL; } return cDNA_from_Sequence(seq); } /* Function: read_efetch_cDNA(estr) * * Descrip: Reads a efetch specified query * Uses, of course /read_efetch_Sequence * * * Arg: estr [READ ] efetch string which is read [char *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ # line 93 "cdna.dy" cDNA * read_efetch_cDNA(char * estr) { return cDNA_from_Sequence(read_efetch_Sequence(estr)); } /* Function: read_SRS_cDNA(srsquery) * * Descrip: Reads a SRS sequence using srs4 syntax. * Uses, of course, /read_SRS_Sequence * * * * Arg: srsquery [READ ] string query representing SRS name [char *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ # line 105 "cdna.dy" cDNA * read_SRS_cDNA(char * srsquery) { return cDNA_from_Sequence(read_SRS_Sequence(srsquery)); } /* Function: cDNA_name(cdna) * * Descrip: Returns the name of the cDNA * * * Arg: cdna [UNKN ] Undocumented argument [cDNA *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 115 "cdna.dy" char * cDNA_name(cDNA * cdna) { return cdna->baseseq->name; } /* Function: cDNA_length(cdna) * * Descrip: Returns the length of the cDNA * * * Arg: cdna [UNKN ] Undocumented argument [cDNA *] * * Return [UNKN ] Undocumented return value [int] * */ # line 124 "cdna.dy" int cDNA_length(cDNA * cdna) { return cdna->baseseq->len; } /* Function: cDNA_seqchar(cdna,pos) * * Descrip: Returns sequence character at this position. * * * Arg: cdna [UNKN ] cDNA [cDNA *] * Arg: pos [UNKN ] position in cDNA to get char [int] * * Return [UNKN ] Undocumented return value [char] * */ # line 135 "cdna.dy" char cDNA_seqchar(cDNA * cdna,int pos) { return cdna->baseseq->seq[pos]; } /* Function: cDNA_from_Sequence(seq) * * Descrip: makes a new cDNA from a Sequence. It * owns the Sequence memory, ie will attempt a /free_Sequence * on the structure when /free_cDNA is called * * If you want to give this cDNA this Sequence and * forget about it, then just hand it this sequence and set * seq to NULL (no need to free it). If you intend to use * the sequence object elsewhere outside of the cDNA datastructure * then use cDNA_from_Sequence(/hard_link_Sequence(seq)) * * * * Arg: seq [OWNER] Sequence to make cDNA from [Sequence *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ # line 155 "cdna.dy" cDNA * cDNA_from_Sequence(Sequence * seq) { cDNA * out; int conv; if( seq == NULL ) { warn("Trying to make a cdna sequence from a NULL baseseq."); return NULL; } if( is_dna_Sequence(seq) == FALSE ) { warn("Trying to make a cDNA sequence from a non cDNA base sequence [%s].",seq->name); return NULL; } uppercase_Sequence(seq); force_to_dna_Sequence(seq,1.0,&conv); if( conv != 0 ) { log_full_error(INFO,0,"In making %s a cdna sequence, converted %d bases (%2.1f%%) to N's from non ATGCN",seq->name,conv,(double)conv*100/(double)seq->len); } out = cDNA_alloc(); out->baseseq = seq; return out; } # line 199 "cdna.c" /* Function: hard_link_cDNA(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [cDNA *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ cDNA * hard_link_cDNA(cDNA * obj) { if( obj == NULL ) { warn("Trying to hard link to a cDNA object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: cDNA_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [cDNA *] * */ cDNA * cDNA_alloc(void) { cDNA * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(cDNA *) ckalloc (sizeof(cDNA))) == NULL) { warn("cDNA_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->baseseq = NULL; return out; } /* Function: free_cDNA(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [cDNA *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ cDNA * free_cDNA(cDNA * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a cDNA obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->baseseq != NULL) free_Sequence(obj->baseseq); ckfree(obj); return NULL; } /* Function: replace_baseseq_cDNA(obj,baseseq) * * Descrip: Replace member variable baseseq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNA *] * Arg: baseseq [OWNER] New value of the variable [Sequence *] * * Return [SOFT ] member variable baseseq [boolean] * */ boolean replace_baseseq_cDNA(cDNA * obj,Sequence * baseseq) { if( obj == NULL) { warn("In replacement function baseseq for object cDNA, got a NULL object"); return FALSE; } obj->baseseq = baseseq; return TRUE; } /* Function: access_baseseq_cDNA(obj) * * Descrip: Access member variable baseseq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNA *] * * Return [SOFT ] member variable baseseq [Sequence *] * */ Sequence * access_baseseq_cDNA(cDNA * obj) { if( obj == NULL) { warn("In accessor function baseseq for object cDNA, got a NULL object"); return NULL; } return obj->baseseq; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/cdna.h0000644000175000001440000001402010670453712015711 0ustar philippusers#ifndef DYNAMITEcdnaHEADERFILE #define DYNAMITEcdnaHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" struct Wise2_cDNA { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence * baseseq; } ; /* cDNA defined */ #ifndef DYNAMITE_DEFINED_cDNA typedef struct Wise2_cDNA Wise2_cDNA; #define cDNA Wise2_cDNA #define DYNAMITE_DEFINED_cDNA #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: truncate_cDNA(cdna,start,stop) * * Descrip: Truncates a cDNA sequence. Basically uses * the /magic_trunc_Sequence function (of course!) * * It does not alter cdna, rather it returns a new * sequence with that truncation * * * Arg: cdna [READ ] cDNA that is truncated [cDNA *] * Arg: start [UNKN ] Undocumented argument [int] * Arg: stop [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [cDNA *] * */ cDNA * Wise2_truncate_cDNA(cDNA * cdna,int start,int stop); #define truncate_cDNA Wise2_truncate_cDNA /* Function: read_fasta_file_cDNA(filename) * * Descrip: Reads a fasta file assumming that it is cDNA. * Will complain if it is not, and return NULL. * * * Arg: filename [UNKN ] filename to be opened and read [char *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ cDNA * Wise2_read_fasta_file_cDNA(char * filename); #define read_fasta_file_cDNA Wise2_read_fasta_file_cDNA /* Function: read_fasta_cDNA(ifp) * * Descrip: Reads a fasta file assumming that it is cDNA. * Will complain if it is not, and return NULL. * * * Arg: ifp [UNKN ] file point to be read from [FILE *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ cDNA * Wise2_read_fasta_cDNA(FILE * ifp); #define read_fasta_cDNA Wise2_read_fasta_cDNA /* Function: read_efetch_cDNA(estr) * * Descrip: Reads a efetch specified query * Uses, of course /read_efetch_Sequence * * * Arg: estr [READ ] efetch string which is read [char *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ cDNA * Wise2_read_efetch_cDNA(char * estr); #define read_efetch_cDNA Wise2_read_efetch_cDNA /* Function: read_SRS_cDNA(srsquery) * * Descrip: Reads a SRS sequence using srs4 syntax. * Uses, of course, /read_SRS_Sequence * * * * Arg: srsquery [READ ] string query representing SRS name [char *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ cDNA * Wise2_read_SRS_cDNA(char * srsquery); #define read_SRS_cDNA Wise2_read_SRS_cDNA /* Function: cDNA_name(cdna) * * Descrip: Returns the name of the cDNA * * * Arg: cdna [UNKN ] Undocumented argument [cDNA *] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_cDNA_name(cDNA * cdna); #define cDNA_name Wise2_cDNA_name /* Function: cDNA_length(cdna) * * Descrip: Returns the length of the cDNA * * * Arg: cdna [UNKN ] Undocumented argument [cDNA *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_cDNA_length(cDNA * cdna); #define cDNA_length Wise2_cDNA_length /* Function: cDNA_seqchar(cdna,pos) * * Descrip: Returns sequence character at this position. * * * Arg: cdna [UNKN ] cDNA [cDNA *] * Arg: pos [UNKN ] position in cDNA to get char [int] * * Return [UNKN ] Undocumented return value [char] * */ char Wise2_cDNA_seqchar(cDNA * cdna,int pos); #define cDNA_seqchar Wise2_cDNA_seqchar /* Function: cDNA_from_Sequence(seq) * * Descrip: makes a new cDNA from a Sequence. It * owns the Sequence memory, ie will attempt a /free_Sequence * on the structure when /free_cDNA is called * * If you want to give this cDNA this Sequence and * forget about it, then just hand it this sequence and set * seq to NULL (no need to free it). If you intend to use * the sequence object elsewhere outside of the cDNA datastructure * then use cDNA_from_Sequence(/hard_link_Sequence(seq)) * * * * Arg: seq [OWNER] Sequence to make cDNA from [Sequence *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ cDNA * Wise2_cDNA_from_Sequence(Sequence * seq); #define cDNA_from_Sequence Wise2_cDNA_from_Sequence /* Function: hard_link_cDNA(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [cDNA *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ cDNA * Wise2_hard_link_cDNA(cDNA * obj); #define hard_link_cDNA Wise2_hard_link_cDNA /* Function: cDNA_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [cDNA *] * */ cDNA * Wise2_cDNA_alloc(void); #define cDNA_alloc Wise2_cDNA_alloc /* Function: free_cDNA(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [cDNA *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ cDNA * Wise2_free_cDNA(cDNA * obj); #define free_cDNA Wise2_free_cDNA /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_baseseq_cDNA(cDNA * obj,Sequence * baseseq); #define replace_baseseq_cDNA Wise2_replace_baseseq_cDNA Sequence * Wise2_access_baseseq_cDNA(cDNA * obj); #define access_baseseq_cDNA Wise2_access_baseseq_cDNA #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/complexsequence_api.h0000644000175000001440000002322410670453712021043 0ustar philippusers /* Functions that create, manipulate or act on ComplexSequence * * Wise2_hard_link_ComplexSequence * Wise2_ComplexSequence_alloc * Wise2_replace_type_ComplexSequence * Wise2_access_type_ComplexSequence * Wise2_replace_seq_ComplexSequence * Wise2_access_seq_ComplexSequence * Wise2_free_ComplexSequence [destructor] * */ /* Functions that create, manipulate or act on ComplexSequenceEvalSet * * Wise2_hard_link_ComplexSequenceEvalSet * Wise2_ComplexSequenceEvalSet_alloc_std * Wise2_replace_type_ComplexSequenceEvalSet * Wise2_access_type_ComplexSequenceEvalSet * Wise2_replace_has_been_prepared_ComplexSequenceEvalSet * Wise2_access_has_been_prepared_ComplexSequenceEvalSet * Wise2_replace_left_window_ComplexSequenceEvalSet * Wise2_access_left_window_ComplexSequenceEvalSet * Wise2_replace_right_window_ComplexSequenceEvalSet * Wise2_access_right_window_ComplexSequenceEvalSet * Wise2_replace_left_lookback_ComplexSequenceEvalSet * Wise2_access_left_lookback_ComplexSequenceEvalSet * Wise2_free_ComplexSequenceEvalSet [destructor] * */ /* API for object ComplexSequence */ /* Function: Wise2_hard_link_ComplexSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_ComplexSequence *] * * Returns Undocumented return value [Wise2_ComplexSequence *] * */ Wise2_ComplexSequence * Wise2_hard_link_ComplexSequence( Wise2_ComplexSequence * obj); /* Function: Wise2_ComplexSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_ComplexSequence *] * */ Wise2_ComplexSequence * Wise2_ComplexSequence_alloc(); /* Function: Wise2_replace_type_ComplexSequence(obj,type) * * Descrip: Replace member variable type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequence *] * Arg: type New value of the variable [int] * * Returns member variable type [boolean] * */ boolean Wise2_replace_type_ComplexSequence( Wise2_ComplexSequence * obj,int type); /* Function: Wise2_access_type_ComplexSequence(obj) * * Descrip: Access member variable type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequence *] * * Returns member variable type [int] * */ int Wise2_access_type_ComplexSequence( Wise2_ComplexSequence * obj); /* Function: Wise2_replace_seq_ComplexSequence(obj,seq) * * Descrip: Replace member variable seq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequence *] * Arg: seq New value of the variable [Wise2_Sequence *] * * Returns member variable seq [boolean] * */ boolean Wise2_replace_seq_ComplexSequence( Wise2_ComplexSequence * obj,Wise2_Sequence * seq); /* Function: Wise2_access_seq_ComplexSequence(obj) * * Descrip: Access member variable seq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequence *] * * Returns member variable seq [Wise2_Sequence *] * */ Wise2_Sequence * Wise2_access_seq_ComplexSequence( Wise2_ComplexSequence * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_ComplexSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_ComplexSequence *] * * Returns Undocumented return value [Wise2_ComplexSequence *] * */ Wise2_ComplexSequence * Wise2_free_ComplexSequence( Wise2_ComplexSequence * obj); /* API for object ComplexSequenceEvalSet */ /* Function: Wise2_hard_link_ComplexSequenceEvalSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_ComplexSequenceEvalSet *] * * Returns Undocumented return value [Wise2_ComplexSequenceEvalSet *] * */ Wise2_ComplexSequenceEvalSet * Wise2_hard_link_ComplexSequenceEvalSet( Wise2_ComplexSequenceEvalSet * obj); /* Function: Wise2_ComplexSequenceEvalSet_alloc_std(void) * * Descrip: Equivalent to ComplexSequenceEvalSet_alloc_len(ComplexSequenceEvalSetLISTLENGTH) * * * * Returns Undocumented return value [Wise2_ComplexSequenceEvalSet *] * */ Wise2_ComplexSequenceEvalSet * Wise2_ComplexSequenceEvalSet_alloc_std(); /* Function: Wise2_replace_type_ComplexSequenceEvalSet(obj,type) * * Descrip: Replace member variable type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequenceEvalSet *] * Arg: type New value of the variable [int] * * Returns member variable type [boolean] * */ boolean Wise2_replace_type_ComplexSequenceEvalSet( Wise2_ComplexSequenceEvalSet * obj,int type); /* Function: Wise2_access_type_ComplexSequenceEvalSet(obj) * * Descrip: Access member variable type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequenceEvalSet *] * * Returns member variable type [int] * */ int Wise2_access_type_ComplexSequenceEvalSet( Wise2_ComplexSequenceEvalSet * obj); /* Function: Wise2_replace_has_been_prepared_ComplexSequenceEvalSet(obj,has_been_prepared) * * Descrip: Replace member variable has_been_prepared * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequenceEvalSet *] * Arg: has_been_prepared New value of the variable [boolean] * * Returns member variable has_been_prepared [boolean] * */ boolean Wise2_replace_has_been_prepared_ComplexSequenceEvalSet( Wise2_ComplexSequenceEvalSet * obj,boolean has_been_prepared); /* Function: Wise2_access_has_been_prepared_ComplexSequenceEvalSet(obj) * * Descrip: Access member variable has_been_prepared * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequenceEvalSet *] * * Returns member variable has_been_prepared [boolean] * */ boolean Wise2_access_has_been_prepared_ComplexSequenceEvalSet( Wise2_ComplexSequenceEvalSet * obj); /* Function: Wise2_replace_left_window_ComplexSequenceEvalSet(obj,left_window) * * Descrip: Replace member variable left_window * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequenceEvalSet *] * Arg: left_window New value of the variable [int] * * Returns member variable left_window [boolean] * */ boolean Wise2_replace_left_window_ComplexSequenceEvalSet( Wise2_ComplexSequenceEvalSet * obj,int left_window); /* Function: Wise2_access_left_window_ComplexSequenceEvalSet(obj) * * Descrip: Access member variable left_window * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequenceEvalSet *] * * Returns member variable left_window [int] * */ int Wise2_access_left_window_ComplexSequenceEvalSet( Wise2_ComplexSequenceEvalSet * obj); /* Function: Wise2_replace_right_window_ComplexSequenceEvalSet(obj,right_window) * * Descrip: Replace member variable right_window * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequenceEvalSet *] * Arg: right_window New value of the variable [int] * * Returns member variable right_window [boolean] * */ boolean Wise2_replace_right_window_ComplexSequenceEvalSet( Wise2_ComplexSequenceEvalSet * obj,int right_window); /* Function: Wise2_access_right_window_ComplexSequenceEvalSet(obj) * * Descrip: Access member variable right_window * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequenceEvalSet *] * * Returns member variable right_window [int] * */ int Wise2_access_right_window_ComplexSequenceEvalSet( Wise2_ComplexSequenceEvalSet * obj); /* Function: Wise2_replace_left_lookback_ComplexSequenceEvalSet(obj,left_lookback) * * Descrip: Replace member variable left_lookback * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequenceEvalSet *] * Arg: left_lookback New value of the variable [int] * * Returns member variable left_lookback [boolean] * */ boolean Wise2_replace_left_lookback_ComplexSequenceEvalSet( Wise2_ComplexSequenceEvalSet * obj,int left_lookback); /* Function: Wise2_access_left_lookback_ComplexSequenceEvalSet(obj) * * Descrip: Access member variable left_lookback * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ComplexSequenceEvalSet *] * * Returns member variable left_lookback [int] * */ int Wise2_access_left_lookback_ComplexSequenceEvalSet( Wise2_ComplexSequenceEvalSet * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_ComplexSequenceEvalSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_ComplexSequenceEvalSet *] * * Returns Undocumented return value [Wise2_ComplexSequenceEvalSet *] * */ Wise2_ComplexSequenceEvalSet * Wise2_free_ComplexSequenceEvalSet( Wise2_ComplexSequenceEvalSet * obj); wise-2.4.1/src/dynlibsrc/complexsequence_api.t0000644000175000001440000000021010670453712021045 0ustar philippuserstypedef struct Wise2_ComplexSequence Wise2_ComplexSequence; typedef struct Wise2_ComplexSequenceEvalSet Wise2_ComplexSequenceEvalSet; wise-2.4.1/src/dynlibsrc/pairbase.c0000644000175000001440000006723010670453712016600 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "pairbase.h" /* Function: diagonal_tweak_PairBaseCodonModel(m,ratio_on,ratio_off_positive,ratio_off_negative) * * Descrip: Tweaks a PairBaseCodonModel with on and off diagonal ratios * * * Arg: m [UNKN ] Undocumented argument [PairBaseCodonModel *] * Arg: ratio_on [UNKN ] Undocumented argument [double] * Arg: ratio_off_positive [UNKN ] Undocumented argument [double] * Arg: ratio_off_negative [UNKN ] Undocumented argument [double] * */ # line 43 "pairbase.dy" void diagonal_tweak_PairBaseCodonModel(PairBaseCodonModel * m,double ratio_on,double ratio_off_positive,double ratio_off_negative) { int a,b,c,x,y,z; int p; int codon_a; int codon_b; pairbase_type seq[3]; for(a=0;a<5;a++) { for(b=0;b<5;b++) { for(c=0;c<5;c++) { for(x=0;x<5;x++) { for(y=0;y<5;y++) { for(z=0;z<5;z++) { /* build the sequence */ seq[0] = MAKE_PAIRBASE(a,x); seq[1] = MAKE_PAIRBASE(b,y); seq[2] = MAKE_PAIRBASE(c,z); p = pairbase_codon_from_seq(seq); if( a == x && b == y && c == z ) { if( a == 4 && b == 4 && c== 4 ) { m->codon[p] *= 0.5; } else { m->codon[p] *= ratio_on; } } else if ( m->codon[p] > 1.0 ) { /* fprintf(stderr,"For %d %d,%d,%d vs %d,%d,%d\n",p,a,b,c,x,y,z); */ m->codon[p] *= ratio_off_positive; } else { m->codon[p] *= ratio_off_negative; } } } } } } } } /* Function: flatten_diagonal_PairBaseCodonModel(m,ct) * * Descrip: flattens out the diagonal signal * * * Arg: m [UNKN ] Undocumented argument [PairBaseCodonModel *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * */ # line 91 "pairbase.dy" void flatten_diagonal_PairBaseCodonModel(PairBaseCodonModel * m,CodonTable * ct) { int a,b,c; pairbase_type seq[3]; int codon_a; int p; for(a=0;a<5;a++) { for(b=0;b<5;b++) { for(c=0;c<5;c++) { if( a < 4 && b < 4 && c < 4 ) { codon_a = (25 * a) + (5 * b) + c; if( is_stop_codon(codon_a,ct) ) { m->codon[p] = 0.0; continue; } } /* build the sequence */ seq[0] = MAKE_PAIRBASE(a,a); seq[1] = MAKE_PAIRBASE(b,b); seq[2] = MAKE_PAIRBASE(c,c); p = pairbase_codon_from_seq(seq); if( a == 4 && b == 4 && c== 4 ) { m->codon[p] = 0.5; } else { m->codon[p] = 1.0; } } } } } /* Function: flatten_diagonal_PairBaseCodonModelScore(m,ct) * * Descrip: flattens out the diagonal signal - for scores! * * * Arg: m [UNKN ] Undocumented argument [PairBaseCodonModelScore *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * */ # line 133 "pairbase.dy" void flatten_diagonal_PairBaseCodonModelScore(PairBaseCodonModelScore * m,CodonTable * ct) { int a,b,c; pairbase_type seq[3]; int codon_a; int p; for(a=0;a<5;a++) { for(b=0;b<5;b++) { for(c=0;c<5;c++) { if( a < 4 && b < 4 && c < 4 ) { codon_a = (25 * a) + (5 * b) + c; if( is_stop_codon(codon_a,ct) ) { m->codon[p] = NEGI; continue; } } /* build the sequence */ seq[0] = MAKE_PAIRBASE(a,a); seq[1] = MAKE_PAIRBASE(b,b); seq[2] = MAKE_PAIRBASE(c,c); p = pairbase_codon_from_seq(seq); if( a == 4 && b == 4 && c== 4 ) { m->codon[p] = -2; } else { m->codon[p] = 0; } } } } } /* Function: zero_PairBaseModelScore(void) * * Descrip: a 0 pairbasemodel score * * * * Return [UNKN ] Undocumented return value [PairBaseModelScore *] * */ # line 178 "pairbase.dy" PairBaseModelScore * zero_PairBaseModelScore(void) { PairBaseModelScore * out; int i; out = PairBaseModelScore_alloc(); for(i=0;ibase[i] = 0; } return out; } /* Function: very_simple_PairBaseCodonModel(id,rnd,nonm,gap,ct) * * Descrip: Makes a PairBaseCodonModel from just a one parameter! Wow! * * * Arg: id [UNKN ] Undocumented argument [Probability] * Arg: rnd [UNKN ] Undocumented argument [Probability] * Arg: nonm [UNKN ] Undocumented argument [Probability] * Arg: gap [UNKN ] Undocumented argument [Probability] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ # line 197 "pairbase.dy" PairBaseCodonModel * very_simple_PairBaseCodonModel(Probability id,Probability rnd,Probability nonm,Probability gap,CodonTable * ct) { CompProb * p; PairBaseCodonModel * out; p = simple_aa_CompProb(id,id,rnd); out = make_flat_PairBaseCodonModel(p,nonm,gap,ct); free_CompProb(p); return out; } /* Function: make_flat_PairBaseCodonModel(cp,nonm,gap,ct) * * Descrip: Makes a PairBaseCodonModel from a protein matrix - assumming a flat * mapping to CodonMatrix * * * Arg: cp [UNKN ] Undocumented argument [CompProb *] * Arg: nonm [UNKN ] Undocumented argument [Probability] * Arg: gap [UNKN ] Undocumented argument [Probability] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ # line 216 "pairbase.dy" PairBaseCodonModel * make_flat_PairBaseCodonModel(CompProb * cp,Probability nonm,Probability gap,CodonTable * ct) { CodonMatrix * cm; PairBaseCodonModel * out; cm = naive_CodonMatrix(ct,cp); out = make_PairBaseCodonModel(cm,nonm,gap,ct); free_CodonMatrix(cm); return out; } /* Function: make_start_PairBaseCodonModelScore(ct) * * Descrip: Makes a PairBaseCodonModel score for start codon * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModelScore *] * */ # line 233 "pairbase.dy" PairBaseCodonModelScore * make_start_PairBaseCodonModelScore(CodonTable * ct) { PairBaseCodonModel * model; PairBaseCodonModelScore * out; model = make_conserved_PairBaseCodonModel(100.0,0.000000000001,'M',ct); out = new_PairBaseCodonModelScore(model); free_PairBaseCodonModel(model); return out; } /* Function: make_stop_PairBaseCodonModelScore(ct) * * Descrip: Makes a PairBaseCodonModel score for start codon * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModelScore *] * */ # line 251 "pairbase.dy" PairBaseCodonModelScore * make_stop_PairBaseCodonModelScore(CodonTable * ct) { PairBaseCodonModel * model; PairBaseCodonModelScore * out; model = make_conserved_PairBaseCodonModel(100.0,0.000000000001,'X',ct); out = new_PairBaseCodonModelScore(model); free_PairBaseCodonModel(model); return out; } /* Function: make_conserved_PairBaseCodonModel(cons,non_cons,aa_var,ct) * * Descrip: Makes a PairBaseCodonModel for a particular character in the CodonTable * * * Arg: cons [UNKN ] Undocumented argument [Probability] * Arg: non_cons [UNKN ] Undocumented argument [Probability] * Arg: aa_var [UNKN ] Undocumented argument [char] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ # line 270 "pairbase.dy" PairBaseCodonModel * make_conserved_PairBaseCodonModel(Probability cons,Probability non_cons,char aa_var,CodonTable * ct) { PairBaseCodonModel * out; int i; base base_a,base_b,base_c; pairbase_type seq[3]; int p; assert(ct); out = PairBaseCodonModel_alloc(); for(i=0;icodon[i] = non_cons; } for(i=0;i<125;i++) { if( ct->codon_str[i] == aa_var ) { fprintf(stderr,"Assinging %d with %c\n",i,aa_var); all_bases_from_codon(i,&base_a,&base_b,&base_c); seq[0] = MAKE_PAIRBASE(base_a,base_a); seq[1] = MAKE_PAIRBASE(base_b,base_b); seq[2] = MAKE_PAIRBASE(base_c,base_c); p = pairbase_codon_from_seq(seq); out->codon[p] = cons; } } return out; } /* Function: make_PairBaseCodonModel(codon_matrix,nonm,gap,ct) * * Descrip: Makes a PairBaseCodonModel from a CodonMatrix and parameters * * * Arg: codon_matrix [UNKN ] Undocumented argument [CodonMatrix *] * Arg: nonm [UNKN ] Undocumented argument [Probability] * Arg: gap [UNKN ] Undocumented argument [Probability] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ # line 306 "pairbase.dy" PairBaseCodonModel * make_PairBaseCodonModel(CodonMatrix * codon_matrix,Probability nonm,Probability gap,CodonTable * ct) { PairBaseCodonModel * out; int a,b,c,x,y,z; int i; int codon_a; int codon_b; int p; pairbase_type seq[3]; assert(codon_matrix); assert(ct); out = PairBaseCodonModel_alloc(); for(i=0;icodon[i] = 0.0; } for(a=0;a<5;a++) { for(b=0;b<5;b++) { for(c=0;c<5;c++) { for(x=0;x<5;x++) { for(y=0;y<5;y++) { for(z=0;z<5;z++) { /* build the sequence */ seq[0] = MAKE_PAIRBASE(a,x); seq[1] = MAKE_PAIRBASE(b,y); seq[2] = MAKE_PAIRBASE(c,z); p = pairbase_codon_from_seq(seq); codon_a = (a * 25) + (b * 5) + c; codon_b = (x * 25) + (y * 5) + z; if( is_stop_codon(codon_a,ct) || is_stop_codon(codon_b,ct) ) { out->codon[p] = 0.0; continue; } /* else */ out->codon[p] = codon_matrix->prob[codon_a][codon_b]; } } } } } } /* now to do blank and gap scores */ for(a=0;a<5;a++) { for(b=0;b<5;b++) { for(c=0;c<5;c++) { codon_a = (a * 25) + (b * 5) + c; seq[0] = MAKE_PAIRBASE(a,BASE_GAP); seq[1] = MAKE_PAIRBASE(b,BASE_GAP); seq[2] = MAKE_PAIRBASE(c,BASE_GAP); p = pairbase_codon_from_seq(seq); if( is_stop_codon(codon_a,ct) ) { out->codon[p] = 0.0; } else { out->codon[p] = gap; } seq[0] = MAKE_PAIRBASE(BASE_GAP,a); seq[1] = MAKE_PAIRBASE(BASE_GAP,b); seq[2] = MAKE_PAIRBASE(BASE_GAP,c); p = pairbase_codon_from_seq(seq); if( is_stop_codon(codon_a,ct) ) { out->codon[p] = 0.0; } else { out->codon[p] = gap; } seq[0] = MAKE_PAIRBASE(a,BASE_OPEN); seq[1] = MAKE_PAIRBASE(b,BASE_OPEN); seq[2] = MAKE_PAIRBASE(c,BASE_OPEN); p = pairbase_codon_from_seq(seq); if( is_stop_codon(codon_a,ct) ) { out->codon[p] = 0.0; } else { out->codon[p] = nonm; } seq[0] = MAKE_PAIRBASE(BASE_OPEN,a); seq[1] = MAKE_PAIRBASE(BASE_OPEN,b); seq[2] = MAKE_PAIRBASE(BASE_OPEN,c); p = pairbase_codon_from_seq(seq); if( is_stop_codon(codon_a,ct) ) { out->codon[p] = 0.0; } else { out->codon[p] = nonm; } } } } return out; } /* Function: simple_PairBaseModel(iden,other,gap) * * Descrip: Makes a pair base model from simple leading diagonal * * * Arg: iden [UNKN ] Undocumented argument [Probability] * Arg: other [UNKN ] Undocumented argument [Probability] * Arg: gap [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [PairBaseModel *] * */ # line 427 "pairbase.dy" PairBaseModel * simple_PairBaseModel(Probability iden,Probability other,Probability gap) { PairBaseModel * out; int i; int j; int base; out = PairBaseModel_alloc(); for(i=0;i<7;i++) { for(j=0;j<7;j++) { base = (i*7)+j; if( i == 5 || j == 5 ) { out->base[base]= gap/0.25; } else if( i == 6 || j == 6 ) { out->base[base]= 0.0; } else if( i == 4 || j == 4 ) { out->base[base]= 1.0; } else if( i == j ) { out->base[base]= iden / 0.25; } else { out->base[base]= other / 0.25; } } } return out; } /* Function: new_PairBaseCodonModelScore(pbcm) * * Descrip: Makes a codon score from a codon model * * * Arg: pbcm [UNKN ] Undocumented argument [PairBaseCodonModel *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModelScore *] * */ # line 462 "pairbase.dy" PairBaseCodonModelScore * new_PairBaseCodonModelScore(PairBaseCodonModel * pbcm) { PairBaseCodonModelScore * out; out = PairBaseCodonModelScore_alloc(); Probability2Score_move(pbcm->codon,out->codon,PAIRBASE_CODON_LENGTH); return out; } /* Function: new_PairBaseModelScore(pbm) * * Descrip: Makes a base score from a base model * * * Arg: pbm [UNKN ] Undocumented argument [PairBaseModel *] * * Return [UNKN ] Undocumented return value [PairBaseModelScore *] * */ # line 476 "pairbase.dy" PairBaseModelScore * new_PairBaseModelScore(PairBaseModel * pbm) { PairBaseModelScore * out; out = PairBaseModelScore_alloc(); Probability2Score_move(pbm->base,out->base,PAIRBASE_LENGTH); return out; } /* Function: show_PairBaseModelScore(sc,ofp) * * Descrip: Debugging * * * Arg: sc [UNKN ] Undocumented argument [PairBaseModelScore *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 490 "pairbase.dy" void show_PairBaseModelScore(PairBaseModelScore * sc,FILE * ofp) { int i; int anchor; int informant; for(i=0;ibase[i]); } } /* Function: show_PairBaseCodonModelScore(sc,ct,ofp) * * Descrip: Debugging * * * Arg: sc [UNKN ] Undocumented argument [PairBaseCodonModelScore *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 509 "pairbase.dy" void show_PairBaseCodonModelScore(PairBaseCodonModelScore * sc,CodonTable * ct,FILE * ofp) { int i; pairbase_type a; pairbase_type b; pairbase_type c; int anchor_a; int anchor_b; int anchor_c; int informant_a; int informant_b; int informant_c; char seq1[4]; char seq2[4]; seq1[3] = seq2[3] = '\0'; for(i=0;icodon[i]); } } /* Function: reverse_pairbase_codon(codon) * * Descrip: Inverts pairbase codon * * * Arg: codon [UNKN ] Undocumented argument [pairbase_codon_type] * * Return [UNKN ] Undocumented return value [pairbase_codon_type] * */ # line 558 "pairbase.dy" pairbase_codon_type reverse_pairbase_codon(pairbase_codon_type codon) { pairbase_type a; pairbase_type b; pairbase_type c; decompose_pairbase_codon(codon,&a,&b,&c); a = complement_pairbase(a); b = complement_pairbase(b); c = complement_pairbase(c); return (c*(PAIRBASE_LENGTH*PAIRBASE_LENGTH))+(b*PAIRBASE_LENGTH)+a; } /* Function: complement_pairbase(b) * * Descrip: complements a pairbase * * * Arg: b [UNKN ] Undocumented argument [pairbase_type] * * Return [UNKN ] Undocumented return value [pairbase_type] * */ # line 577 "pairbase.dy" pairbase_type complement_pairbase(pairbase_type b) { pairbase_type anchor; pairbase_type informant; anchor = anchor_base_from_pairbase(b); informant = informant_base_from_pairbase(b); /* we reverse completement anchor */ anchor = complement_base(anchor); if( informant != BASE_GAP && informant != BASE_OPEN ) { informant = complement_base(informant); } return MAKE_PAIRBASE(anchor,informant); } /* Function: pairbase_codon_from_seq(seq) * * Descrip: Makes a pairbase_codon from a pairbase_sequence * * * Arg: seq [UNKN ] Undocumented argument [pairbase_type *] * * Return [UNKN ] Undocumented return value [pairbase_codon_type] * */ # line 600 "pairbase.dy" pairbase_codon_type pairbase_codon_from_seq(pairbase_type * seq) { pairbase_type one; pairbase_type two; pairbase_type three; one = (*seq); two = (*(seq+1)); three = (*(seq+2)); return (one*(PAIRBASE_LENGTH*PAIRBASE_LENGTH))+(two*PAIRBASE_LENGTH)+three; } /* Function: decompose_pairbase_codon(t,a,b,c) * * Descrip: Decomposes a pairbase codon * * * Arg: t [UNKN ] Undocumented argument [pairbase_codon_type] * Arg: a [UNKN ] Undocumented argument [pairbase_type *] * Arg: b [UNKN ] Undocumented argument [pairbase_type *] * Arg: c [UNKN ] Undocumented argument [pairbase_type *] * */ # line 618 "pairbase.dy" void decompose_pairbase_codon(pairbase_codon_type t,pairbase_type * a,pairbase_type * b,pairbase_type * c) { assert(a); assert(b); assert(c); *a = t/(PAIRBASE_LENGTH*PAIRBASE_LENGTH); t -= (*a) * (PAIRBASE_LENGTH*PAIRBASE_LENGTH); *b = t/PAIRBASE_LENGTH; t -= (*b) * PAIRBASE_LENGTH; *c = t; } /* Function: anchor_base_from_pairbase(pairbase) * * Descrip: Finds the anchor base from a pair base * * * Arg: pairbase [UNKN ] Undocumented argument [pairbase_type] * * Return [UNKN ] Undocumented return value [base] * */ # line 638 "pairbase.dy" base anchor_base_from_pairbase(pairbase_type pairbase) { int top; top = (int)pairbase / 7; return top; } /* Function: informant_base_from_pairbase(pairbase) * * Descrip: Finds the informant base from a pair base * * * Arg: pairbase [UNKN ] Undocumented argument [pairbase_type] * * Return [UNKN ] Undocumented return value [base] * */ # line 650 "pairbase.dy" base informant_base_from_pairbase(pairbase_type pairbase) { int top; top = (int) pairbase /7; pairbase -= top*7; return pairbase; } /* Function: char_for_base(base) * * Descrip: gives back the character for the base * * * Arg: base [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [char] * */ # line 664 "pairbase.dy" char char_for_base(int base) { if( base < 5 ) { return char_from_base(base); } if( base == BASE_GAP ) { return '-'; } else { return ' '; } } # line 795 "pairbase.c" /* Function: hard_link_PairBaseModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PairBaseModel *] * * Return [UNKN ] Undocumented return value [PairBaseModel *] * */ PairBaseModel * hard_link_PairBaseModel(PairBaseModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a PairBaseModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PairBaseModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PairBaseModel *] * */ PairBaseModel * PairBaseModel_alloc(void) { PairBaseModel * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PairBaseModel *) ckalloc (sizeof(PairBaseModel))) == NULL) { warn("PairBaseModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* base[PAIRBASE_LENGTH] is an array: no default possible */ return out; } /* Function: free_PairBaseModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PairBaseModel *] * * Return [UNKN ] Undocumented return value [PairBaseModel *] * */ PairBaseModel * free_PairBaseModel(PairBaseModel * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PairBaseModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_PairBaseCodonModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PairBaseCodonModel *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ PairBaseCodonModel * hard_link_PairBaseCodonModel(PairBaseCodonModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a PairBaseCodonModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PairBaseCodonModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ PairBaseCodonModel * PairBaseCodonModel_alloc(void) { PairBaseCodonModel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PairBaseCodonModel *) ckalloc (sizeof(PairBaseCodonModel))) == NULL) { warn("PairBaseCodonModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* codon[PAIRBASE_CODON_LENGTH] is an array: no default possible */ return out; } /* Function: free_PairBaseCodonModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PairBaseCodonModel *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ PairBaseCodonModel * free_PairBaseCodonModel(PairBaseCodonModel * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PairBaseCodonModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_PairBaseModelScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PairBaseModelScore *] * * Return [UNKN ] Undocumented return value [PairBaseModelScore *] * */ PairBaseModelScore * hard_link_PairBaseModelScore(PairBaseModelScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a PairBaseModelScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PairBaseModelScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PairBaseModelScore *] * */ PairBaseModelScore * PairBaseModelScore_alloc(void) { PairBaseModelScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PairBaseModelScore *) ckalloc (sizeof(PairBaseModelScore))) == NULL) { warn("PairBaseModelScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* base[PAIRBASE_LENGTH] is an array: no default possible */ return out; } /* Function: free_PairBaseModelScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PairBaseModelScore *] * * Return [UNKN ] Undocumented return value [PairBaseModelScore *] * */ PairBaseModelScore * free_PairBaseModelScore(PairBaseModelScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PairBaseModelScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_PairBaseCodonModelScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PairBaseCodonModelScore *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModelScore *] * */ PairBaseCodonModelScore * hard_link_PairBaseCodonModelScore(PairBaseCodonModelScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a PairBaseCodonModelScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PairBaseCodonModelScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PairBaseCodonModelScore *] * */ PairBaseCodonModelScore * PairBaseCodonModelScore_alloc(void) { PairBaseCodonModelScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PairBaseCodonModelScore *) ckalloc (sizeof(PairBaseCodonModelScore))) == NULL) { warn("PairBaseCodonModelScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* codon[PAIRBASE_CODON_LENGTH] is an array: no default possible */ return out; } /* Function: free_PairBaseCodonModelScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PairBaseCodonModelScore *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModelScore *] * */ PairBaseCodonModelScore * free_PairBaseCodonModelScore(PairBaseCodonModelScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PairBaseCodonModelScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/pairbase.h0000644000175000001440000004424110670453712016602 0ustar philippusers#ifndef DYNAMITEpairbaseHEADERFILE #define DYNAMITEpairbaseHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "codon.h" #include "probability.h" #include "codonmatrix.h" #include typedef char pairbase_type; typedef int pairbase_codon_type; #define BASE_GAP 5 #define BASE_OPEN 6 #define IS_NOT_BASE(a) (a == BASE_GAP ? 1 : a == BASE_OPEN ? 1 : 0) #define MAKE_PAIRBASE(anchor,informant) (anchor*7+informant) #define PAIRBASE_LENGTH (7*7) #define PAIRBASE_CODON_LENGTH (PAIRBASE_LENGTH*PAIRBASE_LENGTH*PAIRBASE_LENGTH) struct Wise2_PairBaseModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability base[PAIRBASE_LENGTH]; } ; /* PairBaseModel defined */ #ifndef DYNAMITE_DEFINED_PairBaseModel typedef struct Wise2_PairBaseModel Wise2_PairBaseModel; #define PairBaseModel Wise2_PairBaseModel #define DYNAMITE_DEFINED_PairBaseModel #endif struct Wise2_PairBaseCodonModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability codon[PAIRBASE_CODON_LENGTH]; } ; /* PairBaseCodonModel defined */ #ifndef DYNAMITE_DEFINED_PairBaseCodonModel typedef struct Wise2_PairBaseCodonModel Wise2_PairBaseCodonModel; #define PairBaseCodonModel Wise2_PairBaseCodonModel #define DYNAMITE_DEFINED_PairBaseCodonModel #endif struct Wise2_PairBaseModelScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score base[PAIRBASE_LENGTH]; } ; /* PairBaseModelScore defined */ #ifndef DYNAMITE_DEFINED_PairBaseModelScore typedef struct Wise2_PairBaseModelScore Wise2_PairBaseModelScore; #define PairBaseModelScore Wise2_PairBaseModelScore #define DYNAMITE_DEFINED_PairBaseModelScore #endif struct Wise2_PairBaseCodonModelScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score codon[PAIRBASE_CODON_LENGTH]; } ; /* PairBaseCodonModelScore defined */ #ifndef DYNAMITE_DEFINED_PairBaseCodonModelScore typedef struct Wise2_PairBaseCodonModelScore Wise2_PairBaseCodonModelScore; #define PairBaseCodonModelScore Wise2_PairBaseCodonModelScore #define DYNAMITE_DEFINED_PairBaseCodonModelScore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: diagonal_tweak_PairBaseCodonModel(m,ratio_on,ratio_off_positive,ratio_off_negative) * * Descrip: Tweaks a PairBaseCodonModel with on and off diagonal ratios * * * Arg: m [UNKN ] Undocumented argument [PairBaseCodonModel *] * Arg: ratio_on [UNKN ] Undocumented argument [double] * Arg: ratio_off_positive [UNKN ] Undocumented argument [double] * Arg: ratio_off_negative [UNKN ] Undocumented argument [double] * */ void Wise2_diagonal_tweak_PairBaseCodonModel(PairBaseCodonModel * m,double ratio_on,double ratio_off_positive,double ratio_off_negative); #define diagonal_tweak_PairBaseCodonModel Wise2_diagonal_tweak_PairBaseCodonModel /* Function: flatten_diagonal_PairBaseCodonModel(m,ct) * * Descrip: flattens out the diagonal signal * * * Arg: m [UNKN ] Undocumented argument [PairBaseCodonModel *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * */ void Wise2_flatten_diagonal_PairBaseCodonModel(PairBaseCodonModel * m,CodonTable * ct); #define flatten_diagonal_PairBaseCodonModel Wise2_flatten_diagonal_PairBaseCodonModel /* Function: flatten_diagonal_PairBaseCodonModelScore(m,ct) * * Descrip: flattens out the diagonal signal - for scores! * * * Arg: m [UNKN ] Undocumented argument [PairBaseCodonModelScore *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * */ void Wise2_flatten_diagonal_PairBaseCodonModelScore(PairBaseCodonModelScore * m,CodonTable * ct); #define flatten_diagonal_PairBaseCodonModelScore Wise2_flatten_diagonal_PairBaseCodonModelScore /* Function: zero_PairBaseModelScore(void) * * Descrip: a 0 pairbasemodel score * * * * Return [UNKN ] Undocumented return value [PairBaseModelScore *] * */ PairBaseModelScore * Wise2_zero_PairBaseModelScore(void); #define zero_PairBaseModelScore Wise2_zero_PairBaseModelScore /* Function: very_simple_PairBaseCodonModel(id,rnd,nonm,gap,ct) * * Descrip: Makes a PairBaseCodonModel from just a one parameter! Wow! * * * Arg: id [UNKN ] Undocumented argument [Probability] * Arg: rnd [UNKN ] Undocumented argument [Probability] * Arg: nonm [UNKN ] Undocumented argument [Probability] * Arg: gap [UNKN ] Undocumented argument [Probability] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ PairBaseCodonModel * Wise2_very_simple_PairBaseCodonModel(Probability id,Probability rnd,Probability nonm,Probability gap,CodonTable * ct); #define very_simple_PairBaseCodonModel Wise2_very_simple_PairBaseCodonModel /* Function: make_flat_PairBaseCodonModel(cp,nonm,gap,ct) * * Descrip: Makes a PairBaseCodonModel from a protein matrix - assumming a flat * mapping to CodonMatrix * * * Arg: cp [UNKN ] Undocumented argument [CompProb *] * Arg: nonm [UNKN ] Undocumented argument [Probability] * Arg: gap [UNKN ] Undocumented argument [Probability] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ PairBaseCodonModel * Wise2_make_flat_PairBaseCodonModel(CompProb * cp,Probability nonm,Probability gap,CodonTable * ct); #define make_flat_PairBaseCodonModel Wise2_make_flat_PairBaseCodonModel /* Function: make_start_PairBaseCodonModelScore(ct) * * Descrip: Makes a PairBaseCodonModel score for start codon * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModelScore *] * */ PairBaseCodonModelScore * Wise2_make_start_PairBaseCodonModelScore(CodonTable * ct); #define make_start_PairBaseCodonModelScore Wise2_make_start_PairBaseCodonModelScore /* Function: make_stop_PairBaseCodonModelScore(ct) * * Descrip: Makes a PairBaseCodonModel score for start codon * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModelScore *] * */ PairBaseCodonModelScore * Wise2_make_stop_PairBaseCodonModelScore(CodonTable * ct); #define make_stop_PairBaseCodonModelScore Wise2_make_stop_PairBaseCodonModelScore /* Function: make_conserved_PairBaseCodonModel(cons,non_cons,aa_var,ct) * * Descrip: Makes a PairBaseCodonModel for a particular character in the CodonTable * * * Arg: cons [UNKN ] Undocumented argument [Probability] * Arg: non_cons [UNKN ] Undocumented argument [Probability] * Arg: aa_var [UNKN ] Undocumented argument [char] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ PairBaseCodonModel * Wise2_make_conserved_PairBaseCodonModel(Probability cons,Probability non_cons,char aa_var,CodonTable * ct); #define make_conserved_PairBaseCodonModel Wise2_make_conserved_PairBaseCodonModel /* Function: make_PairBaseCodonModel(codon_matrix,nonm,gap,ct) * * Descrip: Makes a PairBaseCodonModel from a CodonMatrix and parameters * * * Arg: codon_matrix [UNKN ] Undocumented argument [CodonMatrix *] * Arg: nonm [UNKN ] Undocumented argument [Probability] * Arg: gap [UNKN ] Undocumented argument [Probability] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ PairBaseCodonModel * Wise2_make_PairBaseCodonModel(CodonMatrix * codon_matrix,Probability nonm,Probability gap,CodonTable * ct); #define make_PairBaseCodonModel Wise2_make_PairBaseCodonModel /* Function: simple_PairBaseModel(iden,other,gap) * * Descrip: Makes a pair base model from simple leading diagonal * * * Arg: iden [UNKN ] Undocumented argument [Probability] * Arg: other [UNKN ] Undocumented argument [Probability] * Arg: gap [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [PairBaseModel *] * */ PairBaseModel * Wise2_simple_PairBaseModel(Probability iden,Probability other,Probability gap); #define simple_PairBaseModel Wise2_simple_PairBaseModel /* Function: new_PairBaseCodonModelScore(pbcm) * * Descrip: Makes a codon score from a codon model * * * Arg: pbcm [UNKN ] Undocumented argument [PairBaseCodonModel *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModelScore *] * */ PairBaseCodonModelScore * Wise2_new_PairBaseCodonModelScore(PairBaseCodonModel * pbcm); #define new_PairBaseCodonModelScore Wise2_new_PairBaseCodonModelScore /* Function: new_PairBaseModelScore(pbm) * * Descrip: Makes a base score from a base model * * * Arg: pbm [UNKN ] Undocumented argument [PairBaseModel *] * * Return [UNKN ] Undocumented return value [PairBaseModelScore *] * */ PairBaseModelScore * Wise2_new_PairBaseModelScore(PairBaseModel * pbm); #define new_PairBaseModelScore Wise2_new_PairBaseModelScore /* Function: show_PairBaseModelScore(sc,ofp) * * Descrip: Debugging * * * Arg: sc [UNKN ] Undocumented argument [PairBaseModelScore *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_PairBaseModelScore(PairBaseModelScore * sc,FILE * ofp); #define show_PairBaseModelScore Wise2_show_PairBaseModelScore /* Function: show_PairBaseCodonModelScore(sc,ct,ofp) * * Descrip: Debugging * * * Arg: sc [UNKN ] Undocumented argument [PairBaseCodonModelScore *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_PairBaseCodonModelScore(PairBaseCodonModelScore * sc,CodonTable * ct,FILE * ofp); #define show_PairBaseCodonModelScore Wise2_show_PairBaseCodonModelScore /* Function: reverse_pairbase_codon(codon) * * Descrip: Inverts pairbase codon * * * Arg: codon [UNKN ] Undocumented argument [pairbase_codon_type] * * Return [UNKN ] Undocumented return value [pairbase_codon_type] * */ pairbase_codon_type Wise2_reverse_pairbase_codon(pairbase_codon_type codon); #define reverse_pairbase_codon Wise2_reverse_pairbase_codon /* Function: complement_pairbase(b) * * Descrip: complements a pairbase * * * Arg: b [UNKN ] Undocumented argument [pairbase_type] * * Return [UNKN ] Undocumented return value [pairbase_type] * */ pairbase_type Wise2_complement_pairbase(pairbase_type b); #define complement_pairbase Wise2_complement_pairbase /* Function: pairbase_codon_from_seq(seq) * * Descrip: Makes a pairbase_codon from a pairbase_sequence * * * Arg: seq [UNKN ] Undocumented argument [pairbase_type *] * * Return [UNKN ] Undocumented return value [pairbase_codon_type] * */ pairbase_codon_type Wise2_pairbase_codon_from_seq(pairbase_type * seq); #define pairbase_codon_from_seq Wise2_pairbase_codon_from_seq /* Function: decompose_pairbase_codon(t,a,b,c) * * Descrip: Decomposes a pairbase codon * * * Arg: t [UNKN ] Undocumented argument [pairbase_codon_type] * Arg: a [UNKN ] Undocumented argument [pairbase_type *] * Arg: b [UNKN ] Undocumented argument [pairbase_type *] * Arg: c [UNKN ] Undocumented argument [pairbase_type *] * */ void Wise2_decompose_pairbase_codon(pairbase_codon_type t,pairbase_type * a,pairbase_type * b,pairbase_type * c); #define decompose_pairbase_codon Wise2_decompose_pairbase_codon /* Function: anchor_base_from_pairbase(pairbase) * * Descrip: Finds the anchor base from a pair base * * * Arg: pairbase [UNKN ] Undocumented argument [pairbase_type] * * Return [UNKN ] Undocumented return value [base] * */ base Wise2_anchor_base_from_pairbase(pairbase_type pairbase); #define anchor_base_from_pairbase Wise2_anchor_base_from_pairbase /* Function: informant_base_from_pairbase(pairbase) * * Descrip: Finds the informant base from a pair base * * * Arg: pairbase [UNKN ] Undocumented argument [pairbase_type] * * Return [UNKN ] Undocumented return value [base] * */ base Wise2_informant_base_from_pairbase(pairbase_type pairbase); #define informant_base_from_pairbase Wise2_informant_base_from_pairbase /* Function: char_for_base(base) * * Descrip: gives back the character for the base * * * Arg: base [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [char] * */ char Wise2_char_for_base(int base); #define char_for_base Wise2_char_for_base /* Function: hard_link_PairBaseModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PairBaseModel *] * * Return [UNKN ] Undocumented return value [PairBaseModel *] * */ PairBaseModel * Wise2_hard_link_PairBaseModel(PairBaseModel * obj); #define hard_link_PairBaseModel Wise2_hard_link_PairBaseModel /* Function: PairBaseModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PairBaseModel *] * */ PairBaseModel * Wise2_PairBaseModel_alloc(void); #define PairBaseModel_alloc Wise2_PairBaseModel_alloc /* Function: free_PairBaseModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PairBaseModel *] * * Return [UNKN ] Undocumented return value [PairBaseModel *] * */ PairBaseModel * Wise2_free_PairBaseModel(PairBaseModel * obj); #define free_PairBaseModel Wise2_free_PairBaseModel /* Function: hard_link_PairBaseCodonModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PairBaseCodonModel *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ PairBaseCodonModel * Wise2_hard_link_PairBaseCodonModel(PairBaseCodonModel * obj); #define hard_link_PairBaseCodonModel Wise2_hard_link_PairBaseCodonModel /* Function: PairBaseCodonModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ PairBaseCodonModel * Wise2_PairBaseCodonModel_alloc(void); #define PairBaseCodonModel_alloc Wise2_PairBaseCodonModel_alloc /* Function: free_PairBaseCodonModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PairBaseCodonModel *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModel *] * */ PairBaseCodonModel * Wise2_free_PairBaseCodonModel(PairBaseCodonModel * obj); #define free_PairBaseCodonModel Wise2_free_PairBaseCodonModel /* Function: hard_link_PairBaseModelScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PairBaseModelScore *] * * Return [UNKN ] Undocumented return value [PairBaseModelScore *] * */ PairBaseModelScore * Wise2_hard_link_PairBaseModelScore(PairBaseModelScore * obj); #define hard_link_PairBaseModelScore Wise2_hard_link_PairBaseModelScore /* Function: PairBaseModelScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PairBaseModelScore *] * */ PairBaseModelScore * Wise2_PairBaseModelScore_alloc(void); #define PairBaseModelScore_alloc Wise2_PairBaseModelScore_alloc /* Function: free_PairBaseModelScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PairBaseModelScore *] * * Return [UNKN ] Undocumented return value [PairBaseModelScore *] * */ PairBaseModelScore * Wise2_free_PairBaseModelScore(PairBaseModelScore * obj); #define free_PairBaseModelScore Wise2_free_PairBaseModelScore /* Function: hard_link_PairBaseCodonModelScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PairBaseCodonModelScore *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModelScore *] * */ PairBaseCodonModelScore * Wise2_hard_link_PairBaseCodonModelScore(PairBaseCodonModelScore * obj); #define hard_link_PairBaseCodonModelScore Wise2_hard_link_PairBaseCodonModelScore /* Function: PairBaseCodonModelScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PairBaseCodonModelScore *] * */ PairBaseCodonModelScore * Wise2_PairBaseCodonModelScore_alloc(void); #define PairBaseCodonModelScore_alloc Wise2_PairBaseCodonModelScore_alloc /* Function: free_PairBaseCodonModelScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PairBaseCodonModelScore *] * * Return [UNKN ] Undocumented return value [PairBaseCodonModelScore *] * */ PairBaseCodonModelScore * Wise2_free_PairBaseCodonModelScore(PairBaseCodonModelScore * obj); #define free_PairBaseCodonModelScore Wise2_free_PairBaseCodonModelScore /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/gene_api.h0000644000175000001440000002351410670453712016563 0ustar philippusers /* Functions that create, manipulate or act on Gene * * Wise2_get_Genomic_from_Gene * Wise2_show_pretty_Gene * Wise2_hard_link_Gene * Wise2_Gene_alloc_std * Wise2_replace_start_Gene * Wise2_access_start_Gene * Wise2_replace_end_Gene * Wise2_access_end_Gene * Wise2_replace_parent_Gene * Wise2_access_parent_Gene * Wise2_replace_genomic_Gene * Wise2_access_genomic_Gene * Wise2_access_transcript_Gene * Wise2_length_transcript_Gene * Wise2_flush_Gene * Wise2_add_Gene * Wise2_replace_name_Gene * Wise2_access_name_Gene * Wise2_replace_bits_Gene * Wise2_access_bits_Gene * Wise2_replace_seqname_Gene * Wise2_access_seqname_Gene * Wise2_replace_ispseudo_Gene * Wise2_access_ispseudo_Gene * Wise2_free_Gene [destructor] * */ /* API for object Gene */ /* Function: Wise2_get_Genomic_from_Gene(gene) * * Descrip: Gives back a Genomic sequence type * from a gene. * * * Arg: gene gene to get Genomic from [Wise2_Gene *] * * Returns Genomic DNA data structure [Wise2_Genomic *] * */ Wise2_Genomic * Wise2_get_Genomic_from_Gene( Wise2_Gene * gene); /* Function: Wise2_show_pretty_Gene(ge,show_supporting,ofp) * * Descrip: Shows a gene in the biologically accepted form * * * Arg: ge Undocumented argument [Wise2_Gene *] * Arg: show_supporting Undocumented argument [boolean] * Arg: ofp Undocumented argument [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_show_pretty_Gene( Wise2_Gene * ge,boolean show_supporting,FILE * ofp); /* Function: Wise2_hard_link_Gene(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_Gene *] * * Returns Undocumented return value [Wise2_Gene *] * */ Wise2_Gene * Wise2_hard_link_Gene( Wise2_Gene * obj); /* Function: Wise2_Gene_alloc_std(void) * * Descrip: Equivalent to Gene_alloc_len(GeneLISTLENGTH) * * * * Returns Undocumented return value [Wise2_Gene *] * */ Wise2_Gene * Wise2_Gene_alloc_std(); /* Function: Wise2_replace_start_Gene(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * Arg: start New value of the variable [int] * * Returns member variable start [boolean] * */ boolean Wise2_replace_start_Gene( Wise2_Gene * obj,int start); /* Function: Wise2_access_start_Gene(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * * Returns member variable start [int] * */ int Wise2_access_start_Gene( Wise2_Gene * obj); /* Function: Wise2_replace_end_Gene(obj,end) * * Descrip: Replace member variable end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * Arg: end New value of the variable [int] * * Returns member variable end [boolean] * */ boolean Wise2_replace_end_Gene( Wise2_Gene * obj,int end); /* Function: Wise2_access_end_Gene(obj) * * Descrip: Access member variable end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * * Returns member variable end [int] * */ int Wise2_access_end_Gene( Wise2_Gene * obj); /* Function: Wise2_replace_parent_Gene(obj,parent) * * Descrip: Replace member variable parent * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * Arg: parent New value of the variable [Wise2_GenomicRegion *] * * Returns member variable parent [boolean] * */ boolean Wise2_replace_parent_Gene( Wise2_Gene * obj,Wise2_GenomicRegion * parent); /* Function: Wise2_access_parent_Gene(obj) * * Descrip: Access member variable parent * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * * Returns member variable parent [Wise2_GenomicRegion *] * */ Wise2_GenomicRegion * Wise2_access_parent_Gene( Wise2_Gene * obj); /* Function: Wise2_replace_genomic_Gene(obj,genomic) * * Descrip: Replace member variable genomic * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * Arg: genomic New value of the variable [Wise2_Genomic *] * * Returns member variable genomic [boolean] * */ boolean Wise2_replace_genomic_Gene( Wise2_Gene * obj,Wise2_Genomic * genomic); /* Function: Wise2_access_genomic_Gene(obj) * * Descrip: Access member variable genomic * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * * Returns member variable genomic [Wise2_Genomic *] * */ Wise2_Genomic * Wise2_access_genomic_Gene( Wise2_Gene * obj); /* Function: Wise2_access_transcript_Gene(obj,i) * * Descrip: Access members stored in the transcript list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_Gene *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_Transcript *] * */ Wise2_Transcript * Wise2_access_transcript_Gene( Wise2_Gene * obj,int i); /* Function: Wise2_length_transcript_Gene(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_Gene *] * * Returns length of the list [int] * */ int Wise2_length_transcript_Gene( Wise2_Gene * obj); /* Function: Wise2_flush_Gene(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_Gene *] * * Returns Undocumented return value [int] * */ int Wise2_flush_Gene( Wise2_Gene * obj); /* Function: Wise2_add_Gene(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_Gene *] * Arg: add Object to add to the list [Wise2_Transcript *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_Gene( Wise2_Gene * obj,Wise2_Transcript * add); /* Function: Wise2_replace_name_Gene(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * Arg: name New value of the variable [char *] * * Returns member variable name [boolean] * */ boolean Wise2_replace_name_Gene( Wise2_Gene * obj,char * name); /* Function: Wise2_access_name_Gene(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * * Returns member variable name [char *] * */ char * Wise2_access_name_Gene( Wise2_Gene * obj); /* Function: Wise2_replace_bits_Gene(obj,bits) * * Descrip: Replace member variable bits * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * Arg: bits New value of the variable [double] * * Returns member variable bits [boolean] * */ boolean Wise2_replace_bits_Gene( Wise2_Gene * obj,double bits); /* Function: Wise2_access_bits_Gene(obj) * * Descrip: Access member variable bits * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * * Returns member variable bits [double] * */ double Wise2_access_bits_Gene( Wise2_Gene * obj); /* Function: Wise2_replace_seqname_Gene(obj,seqname) * * Descrip: Replace member variable seqname * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * Arg: seqname New value of the variable [char *] * * Returns member variable seqname [boolean] * */ boolean Wise2_replace_seqname_Gene( Wise2_Gene * obj,char * seqname); /* Function: Wise2_access_seqname_Gene(obj) * * Descrip: Access member variable seqname * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * * Returns member variable seqname [char *] * */ char * Wise2_access_seqname_Gene( Wise2_Gene * obj); /* Function: Wise2_replace_ispseudo_Gene(obj,ispseudo) * * Descrip: Replace member variable ispseudo * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * Arg: ispseudo New value of the variable [boolean] * * Returns member variable ispseudo [boolean] * */ boolean Wise2_replace_ispseudo_Gene( Wise2_Gene * obj,boolean ispseudo); /* Function: Wise2_access_ispseudo_Gene(obj) * * Descrip: Access member variable ispseudo * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Gene *] * * Returns member variable ispseudo [boolean] * */ boolean Wise2_access_ispseudo_Gene( Wise2_Gene * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_Gene(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_Gene *] * * Returns Undocumented return value [Wise2_Gene *] * */ Wise2_Gene * Wise2_free_Gene( Wise2_Gene * obj); wise-2.4.1/src/dynlibsrc/gene_api.t0000644000175000001440000000004710670453712016573 0ustar philippuserstypedef struct Wise2_Gene Wise2_Gene; wise-2.4.1/src/dynlibsrc/probability.dy0000644000175000001440000002111710062066211017503 0ustar philippusers/* Last edited: Apr 23 14:10 1997 (birney) */ %{ #include "wisebase.h" #define LOG_NEGATIVE_INFINITY (-100000000) #define NEGI LOG_NEGATIVE_INFINITY #define PROBABILITY_MINIMUM (0.0000000000000000001) #define INTEGER_FACTOR 500 typedef double Probability; typedef int Score; typedef double Bits; #define MINIMUM_ERROR (0.00000001) %} api func Probability_from_average_state_occupancy func state_occupancy_from_Probability func Probability2Score func Score2Probability func Score2Bits func halfbit2Probability endapi %{ #include "probability.h" %func for single state (exponetial decays) takes an average length and converts that to a probability that will produce that length (on average) for the state. NB... this *assumes* that you want a single state exp decay. %arg length average length of state %% Probability Probability_from_average_state_occupancy(double length) { return 1 - (1.0 / length); } %func If you have a single state then this will tak the probability for the state->state transition and give you back the average length in the state %arg p probability of staying in the state %% double state_occupancy_from_Probability(double p) { return 1 / (1-p); } %func gives back a score of the sum in probability space of the two scores. This is the function verison of this code, which is not efficient *at all* %% Score Probability_logsum(Score one,Score two) { return Probability2Score(Score2Probability(one) + Score2Probability(two)); } %func Gives back a Bits score for a probability %% Bits Probability2Bits(Probability p) { return Score2Bits(Probability2Score(p)); } %func shows a score array as score, score ,score ...' %arg s Score array len length of array ofp output filestream %% void show_Score_array(Score * s,int len,FILE * ofp) { register int i; fprintf(ofp,"\"%d",s[0]); for(i=1;i= len ) { return FALSE; } if( is_double_string(runner,&p[no]) == FALSE ) { return FALSE; } } return TRUE; } %func shows a proability array in %f notation. %arg p probability array len length of proability array ofp output filestream %% void show_Probability_array(Probability * p,int len,FILE * ofp) { register int i; fprintf(ofp,"\"%f",p[0]); for(i=1;ilen;i++) if( strcmp(acs->acu[i]->label1,label1) == 0 && strcmp(acs->acu[i]->label2,label2) == 0 ) acs->acu[i]->can_collapse = TRUE; } %func Takes a AlnConvertSet (acs) and a PackAln (pal) and blindly converts it to AlnBlock. This is really an internal for a dynamite produced dy function %% AlnBlock * AlnBlock_from_PackAln(AlnConvertSet * acs,PackAln *pal) { AlnBlock * alb; AlnColumn * prev; AlnColumn * new; boolean coll; int i; alb = AlnBlock_alloc_len(2); add_AlnBlock(alb,AlnSequence_alloc()); add_AlnBlock(alb,AlnSequence_alloc()); prev = NULL; alb->score = pal->score; for(i=1;ilen;i++) { coll = FALSE; new=AlnColumn_from_Pal_Convert(acs,pal->pau[i-1],pal->pau[i],prev,&coll); if( new == NULL ) { if( coll == FALSE ) { warn("Unrecoverable error in converting PackAln to AlnBlock... bugging out with partial alignment!"); return alb; } else { /** ok, was collapsed, just loop back **/ continue; } } else { /** got a new AlnColumn **/ if( prev == NULL ) { /** then first col **/ alb->start = new; alb->seq[0]->start = new->alu[0]; alb->seq[1]->start = new->alu[1]; prev = new; } else { prev->next = new; prev->alu[0]->next = new->alu[0]; prev->alu[1]->next = new->alu[1]; prev = new; } } } return alb; } %func the core of the conversion. %type internal %% AlnColumn * AlnColumn_from_Pal_Convert(AlnConvertSet * acs,PackAlnUnit * before,PackAlnUnit * after,AlnColumn * prev,boolean * was_collapsed) { AlnConvertUnit * acu; AlnColumn * alc; acu = AlnConvertUnit_from_state_and_offset(acs,before->state,after->state,after->i - before->i,after->j - before->j); if( acu == NULL) { warn("Between state [%d,%d,%d] and [%d,%d,%d] got no labels... labelling as UNKNOWN",before->i,before->j,before->state,after->i,after->j,after->state); alc = new_pairwise_AlnColumn(); alc->alu[0]->start = before->i; alc->alu[0]->end = after->i; alc->alu[1]->start = before->j; alc->alu[1]->end = after->j; alc->alu[0]->score[0] = alc->alu[1]->score[0] = after->score; alc->alu[1]->text_label = alc->alu[0]->text_label = unknown_label; return alc; } if( acu->can_collapse == TRUE && prev != NULL && strcmp(prev->alu[0]->text_label,acu->label1) == 0 && strcmp(prev->alu[1]->text_label,acu->label2) == 0 ) { /*** don't return something, just add into the next one ***/ prev->alu[0]->end = after->i; prev->alu[1]->end = after->j; prev->alu[0]->score[0] += after->score; prev->alu[1]->score[0] += after->score; if( was_collapsed != NULL ) { *was_collapsed = TRUE; } return NULL; } /*** else, put away this unit ***/ alc = new_pairwise_AlnColumn(); if( acu->is_from_special == TRUE ) { alc->alu[0]->start = after->i -1; alc->alu[0]->end = after->i; } else { alc->alu[0]->start = before->i; alc->alu[0]->end = after->i; } alc->alu[1]->start = before->j; alc->alu[1]->end = after->j; alc->alu[0]->score[0] = alc->alu[1]->score[0] = after->score; alc->alu[0]->text_label = acu->label1; alc->alu[1]->text_label = acu->label2; return alc; } %func Finds the correct AlnConvertUnit for this state,state,offi,offj quad %type internal %% AlnConvertUnit * AlnConvertUnit_from_state_and_offset(AlnConvertSet * acs,int state1,int state2,int offi,int offj) { register int i; for(i=0;ilen;i++) { if( acs->acu[i]->state1 == state1 && acs->acu[i]->state2 == state2 && (acs->acu[i]->offi == -1 || acs->acu[i]->offi == offi) && offj == acs->acu[i]->offj) return acs->acu[i]; } return NULL; } %} wise-2.4.1/src/dynlibsrc/dna.dy0000644000175000001440000000510607313404540015733 0ustar philippusers %{ #include "sequence.h" %} struct DNA Sequence * baseseq; %{ #include "dna.h" %func Truncates a DNA sequence. Basically uses the /trunc_Sequence function (of course!) It does not alter dna, rather it returns a new sequence with that truncation %arg dna r DNA that is truncated %% DNA * truncate_DNA(DNA * dna,int start,int stop) { return DNA_from_Sequence(trunc_Sequence(dna->baseseq,start,stop)); } %func Reads a fasta file assumming that it is DNA. Will complain if it is not, and return NULL. %arg filename filename to be opened and read %% DNA * read_fasta_file_DNA (char * filename) { Sequence * seq; seq = read_fasta_file_Sequence(filename); if( seq == NULL ) { return NULL; } return DNA_from_Sequence(seq); } %func Reads a fasta file assumming that it is DNA. Will complain if it is not, and return NULL. %arg ifp file point to be read from %% DNA * read_fasta_DNA (FILE * ifp) { Sequence * seq; seq = read_fasta_Sequence(ifp); if( seq == NULL ) { return NULL; } return DNA_from_Sequence(seq); } %func Reads a efetch specified query Uses, of course /read_efetch_Sequence %arg estr r efetch string which is read %% DNA * read_efetch_DNA(char * estr) { return DNA_from_Sequence(read_efetch_Sequence(estr)); } %func Reads a SRS sequence using srs4 syntax. Uses, of course, /read_SRS_Sequence %arg srsquery r string query representing SRS name %% DNA * read_SRS_DNA(char * srsquery) { return DNA_from_Sequence(read_SRS_Sequence(srsquery)); } %func Returns the name of the DNA %arg %% char * DNA_name (DNA * dna) { return dna->baseseq->name; } %func Returns the length of the DNA %arg %% int DNA_length (DNA * dna) { return dna->baseseq->len; } %func Returns sequence character at this position. %arg dna DNA pos position in DNA to get char %% char DNA_seqchar(DNA * dna,int pos) { return dna->baseseq->seq[pos]; } %func makes a new DNA from a Sequence. It owns the Sequence memory, ie will attempt a /free_Sequence on the structure when /free_DNA is called If you want to give this DNA this Sequence and forget about it, then just hand it this sequence and set seq to NULL (no need to free it). If you intend to use the sequence object elsewhere outside of the DNA datastructure then use DNA_from_Sequence(/hard_link_Sequence(seq)) %arg seq Sequence to make DNA from %% DNA * DNA_from_Sequence(Sequence * seq) { DNA * out; if( is_dna_Sequence(seq) == FALSE ) { warn("Trying to make a DNA sequence from a non DNA base sequence [%s].",seq->name); return NULL; } out = DNA_alloc(); out->baseseq = seq; return out; } %} wise-2.4.1/src/dynlibsrc/matrixdebug.dy0000644000175000001440000001522607415361074017517 0ustar philippusers %{ #include "basematrix.h" #include "packaln.h" #define DebugStateLISTLENGTH 40 #define DebugMatrixLISTLENGTH 40 typedef enum MatrixDebugBreakPoint { MDBP_Cursor = 321, MDBP_Overflow, MDBP_Underflow, MDBP_NoBreakPoint } MatrixDebugBreakPoint_type; %} struct DebugTransition char * fromstate !link int from_state_num; void (*show_transition)(void * matrix,int i,int j,FILE * ofp) !func struct DebugState char * statename !link int state_num DebugTransition ** trans !list void (*show_state)(void * matrix,int i,int j,FILE *ofp) !func struct DebugBreakPoint MatrixDebugBreakPoint_type type !def="MDBP_Cursor" int posi int posj int overflow int underflow struct DebugMatrix void * matrix !link int currenti !def="-1" int currentj !def="-1" int max_score !def="0" int min_score !def="100000" int max_score_i !def="-1" int max_score_j !def="-1" int max_score_cell DebugState ** state !list DebugBreakPoint ** point !list !len="bp_" boolean reset !def="FALSE"; FILE * in !link FILE * out !link void (*show_cell)(void * matrix,int i,int j,FILE *ofp) !func %{ #include "matrixdebug.h" %func Shows PackAln in debug context %% void show_PackAln_Debug(DebugMatrix * de,PackAln * pal,FILE * ofp) { int i; int j,k; int cum; PackAlnUnit * prev = pal->pau[0]; PackAlnUnit * c; DebugState * state; DebugTransition * trans; for(i=1;ilen;i++) { c= pal->pau[i]; /* have to find the correct state_num */ if( c->state >= de->len ) { /* special state - can't handle */ fprintf(ofp,"Special state\n"); prev = c; continue; } if( prev->state >= de->len ) { /* special state - can't handle */ fprintf(ofp,"From Special state\n"); prev = c; continue; } state = de->state[pal->pau[i]->state]; trans = NULL; for(k=0;klen;k++) { if( state->trans[k]->from_state_num == prev->state ) { trans = state->trans[k]; } } fprintf(ofp,"SCORE: %5d %5d %5d %s\n",c->score,c->i,c->j,state->statename); if( trans != NULL ) { (*trans->show_transition)(de->matrix,c->i,c->j,ofp); } prev = c; } } %func Show function cell state transition %% void show_DebugMatrix(DebugMatrix * de,char * buffer) { char ** base; char ** brk; DebugState * ds; DebugTransition * tr; base = brk = breakstring(buffer,spacestr); brk++; if( *brk == NULL ) { (*de->show_cell)(de->matrix,de->currenti,de->currentj,de->out); } else { ds = find_DebugState(de,*brk); if( ds == NULL ) { fprintf(de->out,"No state called %s\n",*brk); } else { brk++; if( *brk != NULL ) { tr = find_DebugTransition(ds,*brk); if( tr == NULL ) { fprintf(de->out,"In state %s, no transition from %s\n",ds->statename,*brk); } else { (*tr->show_transition)(de->matrix,de->currenti,de->currentj,de->out); } } else { /* show state */ (*ds->show_state)(de->matrix,de->currenti,de->currentj,de->out); } } } ckfree(base); } %func Finds a DebugState %% DebugState * find_DebugState(DebugMatrix * de,char * name) { int i; for(i=0;ilen;i++) { if( strcmp(de->state[i]->statename,name) == 0 ) { return de->state[i]; } } return NULL; } %func Finds a DebugTransition %% DebugTransition * find_DebugTransition(DebugState * state,char * name) { int i; for(i=0;ilen;i++) { if( strcmp(state->trans[i]->fromstate,name) == 0 ) { return state->trans[i]; } } return NULL; } %func Main function to talk to user %% boolean user_DebugMatrix(DebugMatrix * de) { char buffer[MAXLINE]; char ** base; char ** brk; FILE * in; FILE * out; DebugBreakPoint * bp; assert(de); assert(de->in); assert(de->out); in = de->in; out = de->out; /* set reset to FALSE */ de->reset = 0; fprintf(out,"Entering dynamite debugger. Type help for help\n"); while(1) { fprintf(out,"Dy %5d:%5d max: %d >",de->currenti,de->currentj,de->max_score); fgets(buffer,MAXLINE,in); if( strstartcmp(buffer,"quit") == 0 ) { exit(1); } if( strstartcmp(buffer,"show") == 0 ) { show_DebugMatrix(de,buffer); continue; } if( strstartcmp(buffer,"run") == 0 ) { /* return to calling function */ return 0; } if( strstartcmp(buffer,"break") == 0 ) { base = brk = breakstring(buffer,spacestr); brk++; if( *brk == NULL || *(brk+1) == NULL ) { fprintf(out,">>>> break must have i j positions\n"); continue; } else { bp = DebugBreakPoint_alloc(); bp->type = MDBP_Cursor; /* reset cursor positions */ if( is_integer_string(*brk,&bp->posi) == FALSE ) { fprintf(out,">>>> i position not an integer.\n"); } brk++; if( is_integer_string(*brk,&bp->posj) == FALSE ) { fprintf(out,">>>> j position not an integer.\n"); } fprintf(out,"Adding cursor break point %d,%d\n",bp->posi,bp->posj); add_bp_DebugMatrix(de,bp); } ckfree(base); continue; } if( strstartcmp(buffer,"set") == 0 ) { base = brk = breakstring(buffer,spacestr); brk++; if( *brk == NULL || *(brk+1) == NULL ) { fprintf(out,">>>> set must have i j positions\n"); } else { /* reset cursor positions */ if( is_integer_string(*brk,&de->currenti) == FALSE ) { fprintf(out,">>>> i position not an integer.\n"); } if( is_integer_string(*brk,&de->currenti) == FALSE ) { fprintf(out,">>>> j position not an integer.\n"); } } de->reset = 1; ckfree(base); continue; } } } %func Indicates whether we should break at this point. Assummes the de datastructure has been updated correctly %% MatrixDebugBreakPoint_type should_break_DebugMatrix(DebugMatrix * de) { int i; for(i=0;ibp_len;i++) { auto DebugBreakPoint * p; p = de->point[i]; switch(p->type) { case MDBP_Cursor : if( de->currenti == p->posi && de->currentj == p->posj ) { return MDBP_Cursor; } break; case MDBP_Overflow : if( de->max_score > p->overflow ) { return MDBP_Overflow; } break; case MDBP_Underflow : if( de->min_score < p->overflow ) { return MDBP_Overflow; } break; default : warn("Weird break point type %d",p->type); } } return MDBP_NoBreakPoint; } %func Builds a "standard" Debug matrix %% DebugMatrix * std_DebugMatrix(void) { DebugMatrix * out; DebugBreakPoint * bp; out = DebugMatrix_alloc_std(); bp = DebugBreakPoint_alloc(); bp->type = MDBP_Cursor; bp->posi = -1; bp->posj = -1; add_bp_DebugMatrix(out,bp); bp = DebugBreakPoint_alloc(); bp->type = MDBP_Overflow; bp->overflow = 1000000; add_bp_DebugMatrix(out,bp); out->in = stdin; out->out = stderr; return out; } %} wise-2.4.1/src/dynlibsrc/basematrix.dy0000644000175000001440000001517010411560527017333 0ustar philippusers/* Last edited: Feb 11 20:42 1997 (birney) */ %{ /********************************************************/ /* Wisetools version 3 file */ /* */ /* this file is copyright (c) Ewan Birney 1996 */ /* this file is part of the wisetools sequence analysis */ /* package */ /********************************************************/ /********************************************************/ /* BaseMatrix - structure to hold the memory of */ /* dynamite made matrices. */ /* A dynamite support library */ /* */ /********************************************************/ /***** RCS Info *****************************************/ /* $Id: basematrix.dy,v 1.3 2006/03/26 18:45:43 birney Exp $ $Log: basematrix.dy,v $ Revision 1.3 2006/03/26 18:45:43 birney new basematrix memory layout Revision 1.2 2006/02/27 09:32:23 birney start of folding in steves fixes into dynamite Revision 1.1.1.1 2001/06/18 13:59:59 birney moved wise2 to ensembl cvs repository Revision 1.2 1999/03/08 10:47:48 birney added in fixes for a variety of things Revision 1.1.1.1 1998/08/28 09:30:47 birney Wise2 * Revision 1.9 1997/11/12 13:20:18 birney * added documentation, cleaned up * * Revision 1.8 1997/07/24 15:34:45 birney * changed matrix size, and made 'IMPOSSIBLY_HIGH_SCORE' * * Revision 1.7 1997/02/11 20:42:48 birney * added max basematrix number and query size for it * * Revision 1.6 1997/02/03 16:04:48 birney * forgot to set spec_len in _and_special function. Ooops! * * Revision 1.5 1997/02/03 16:01:30 birney * added BaseMatrix_alloc_matrix_and_specials, but not tested. * * Revision 1.4 1996/11/12 16:41:54 birney * deconstructor was trying to free NULL'd pointers. (bad boy!) * * Revision 1.3 1996/11/11 22:17:22 birney * tweaked specials to allow clean linear memory. Hacky deconstructor * though now... * * Revision 1.2 1996/10/15 13:00:52 birney * changed memory behaviour for offsets: caught a memory leak * * Revision 1.1 1996/03/03 15:38:44 birney * Initial revision * */ /********************************************************/ #include "wisebase.h" enum basematrix_types { BASEMATRIX_TYPE_UNKNOWN = 67, BASEMATRIX_TYPE_EXPLICIT, BASEMATRIX_TYPE_LINEAR, BASEMATRIX_TYPE_SHADOW, BASEMATRIX_TYPE_VERYSMALL }; /* 20 MB assummed. Could break something? */ #define COMPILE_BASEMATRIX_MAX_KB 20000 #define IMPOSSIBLY_HIGH_SCORE 500000 %} struct BaseMatrix int type !def="BASEMATRIX_TYPE_UNKNOWN" int ** matrix !matrix !def="0" // NB i,j proper int cellsize; int queryoffset; int targetoffset; int spec_len !def="0" int ** offsetmatrix !link // complex - this points to an internal matrix of correct offsets (!) int ** specmatrix // no longer linked: we have this memory specific... int ** offsetmem int ** setmem int * optimised_shadow !def="NULL" api func change_max_BaseMatrix_kbytes func get_max_BaseMatrix_kbytes endapi %{ #include "basematrix.h" static int max_matrix_bytes = COMPILE_BASEMATRIX_MAX_KB; %func This is to change, at run-time the maximum level of bytes basematrix *thinks* it can use. This number is *not* used for any actual calls to basematrix allocation: it is only used with /get_max_BaseMatrix_kbytes %arg new_kilo_number max kilobytes allowed %% void change_max_BaseMatrix_kbytes(int new_kilo_number) { max_matrix_bytes = new_kilo_number; } %func returns the max. number of kilobytes suggested as a limited to BaseMatrix. %% int get_max_BaseMatrix_kbytes(void) { return max_matrix_bytes; } %func Just checkes that leni*lenj*statesize/1024 < max_matrix_bytes. returns TRUE if so, FALSE if not %% boolean can_make_explicit_matrix(int leni,int lenj,int statesize) { if( leni*lenj*statesize/1024 > max_matrix_bytes) return FALSE; return TRUE; } %func turns a int type to a char string of 'printable' types. %% char * basematrix_type_to_string(int type) { switch (type) { case BASEMATRIX_TYPE_UNKNOWN : return "Unknown"; case BASEMATRIX_TYPE_EXPLICIT : return "Explicit"; case BASEMATRIX_TYPE_LINEAR : return "Linear"; case BASEMATRIX_TYPE_SHADOW : return "Shadow"; default : return "Problem in converting type!"; } } %func This function allocates the two bits of matrix memory, of course returning a decent NULL (with memory zapped) if it can't do it %arg len_point length of pointers in main matrix len_array length of array in main matrix len_spec_poin length of pointers in special matrix len_spec_array length of special array %% BaseMatrix * BaseMatrix_alloc_matrix_and_specials(int len_point,int len_array,int len_spec_point,int len_spec_array) { register int i; BaseMatrix * out; /* use dy matrix for main stuff */ if( (out = BaseMatrix_alloc_matrix(len_point,len_array)) == NULL ) { warn("Unable to allocate %d by %d [%d] int positions in basematrix main matrix",len_point,len_array,len_point*len_array); return NULL; } out->spec_len = 0; if( (out->specmatrix = (int **) ckcalloc(len_spec_point,sizeof(int *))) == NULL ) { warn("Unable to allocate %d special matrix pointers in basematrix",len_spec_point); free_BaseMatrix(out); return NULL; } if ((out->specmatrix[0] = (int *)ckcalloc(len_spec_point * len_spec_array, sizeof(int))) == NULL) return NULL; for(i = 1; i < len_spec_point; i++) out->specmatrix[i] = out->specmatrix[0] + (i * len_spec_array); out->spec_len = len_spec_point; return out; } %func this is the override deconstructor for basematrix. It will free both matrix and special memory %% !deconstructor BaseMatrix * free_BaseMatrix(BaseMatrix * obj) { int i; if( obj == NULL ) { warn("Trying to free NULL basematrix object. Should be trappable"); return NULL; } if( obj->dynamite_hard_link > 1 ) { obj->dynamite_hard_link--; return NULL; } if(obj->matrix != NULL ) { for(i=0;ileni;i++) if( obj->matrix[i] != NULL ) { ckfree(obj->matrix[i]); } free(obj->matrix); } if( obj->spec_len > 0 ) { if( obj->specmatrix == NULL ) { warn("Bad karma. you have a special matrix of length %d, but a NULL specmatrix pointer. I'm not going to free it!",obj->spec_len); } else { free(obj->specmatrix[0]); free(obj->specmatrix); } /* end of else */ } /* end of if specials */ if( obj->offsetmem != NULL ) ckfree(obj->offsetmem); if( obj->setmem != NULL ) ckfree(obj->setmem); ckfree(obj); return NULL; } %} wise-2.4.1/src/dynlibsrc/basematrix.xs0000644000175000001440000000042210670453712017347 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2 void change_max_BaseMatrix_kbytes(new_kilo_number) int new_kilo_number CODE: Wise2_change_max_BaseMatrix_kbytes(new_kilo_number); int get_max_BaseMatrix_kbytes() CODE: RETVAL = Wise2_get_max_BaseMatrix_kbytes(); OUTPUT: RETVAL wise-2.4.1/src/dynlibsrc/embl.c0000644000175000001440000000222410670453712015721 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "embl.h" /* Function: next_feature_tab_line(buffer,maxlen,ifp) * * Descrip: internal function for reading EMBL feature * tables. * * reads in line. If id 3 in, returns FALSE. * Otherwise strips FT up to central tab region. * * * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: maxlen [UNKN ] Undocumented argument [int] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 20 "embl.dy" boolean next_feature_tab_line(char * buffer,int maxlen,FILE * ifp) { char * runner; if( fgets(buffer,maxlen,ifp) == NULL ) { buffer[0]= '\0'; return FALSE; } if( strstartcmp(buffer,"FT") != 0) { return FALSE; } for(runner = buffer+2;*runner && isspace((int)*runner);runner++) ; if( *runner == '\0' ) { warn("A supposed EMBL feature line with nothing on it"); return FALSE; } if( runner - buffer > 3 ) { memmove(buffer,runner,strlen(runner)); return TRUE; } return FALSE; } # line 50 "embl.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/embl.h0000644000175000001440000000253310670453712015731 0ustar philippusers#ifndef DYNAMITEemblHEADERFILE #define DYNAMITEemblHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: next_feature_tab_line(buffer,maxlen,ifp) * * Descrip: internal function for reading EMBL feature * tables. * * reads in line. If id 3 in, returns FALSE. * Otherwise strips FT up to central tab region. * * * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: maxlen [UNKN ] Undocumented argument [int] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_next_feature_tab_line(char * buffer,int maxlen,FILE * ifp); #define next_feature_tab_line Wise2_next_feature_tab_line /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/dyna.h0000644000175000001440000000242707614546544015761 0ustar philippusers/* Last edited: Mar 16 17:36 1997 (birney) */ #ifndef DYNAMITEHELPERHEADERFILE #define DYNAMITEHELPERHEADERFILE /*** this file includes all the correct files for libdyn linking ***/ #include "packaln.h" #include "basematrix.h" #include "shattermatrix.h" #include "dpenvelope.h" #include "dbsearchimpl.h" #include "dprunimpl.h" #include "matrixdebug.h" #include "shattermatrix.h" #include "sequence.h" #include "seqalign.h" #include "proteindb.h" #include "database.h" #include "hscore.h" #include "histogram.h" #include "searchstatinterface.h" #include "searchstatlookup.h" #include "aln.h" #include "linesubs.h" #include "complexsequence.h" #include "complexevalset.h" #include "complexconsensi.h" #include "codon.h" #include "codonmapper.h" #include "alnconvert.h" #include "alnrange.h" #include "compmat.h" #include "codonmatrix.h" #include "dnamatrix.h" #include "protein.h" #include "genomic.h" #include "genomicdb.h" #include "cdna.h" #include "cdnadb.h" #include "dna.h" #include "seqlookup.h" #include "arrayseqlookup.h" #include "proteinstreamedindex.h" #include "embl.h" #include "genomicregion.h" #include "gene.h" #include "transcript.h" #include "translation.h" #include "btcanvas.h" #include "asciibtcanvas.h" #include "dynlibcross.h" #include "matrixdebug.h" #endif wise-2.4.1/src/dynlibsrc/genomicregion.pod0000644000175000001440000001360510670453712020174 0ustar philippusers=head1 NAME genomicregion module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item GenomicRegion =back =head1 DESCRIPTION =head2 Object GenomicRegion =over =item gene Type [Gene **] List No documentation =item genomic Type [Genomic *] Scalar NB, may not be here. Be careful! =back GenomicRegion is structure which represents information on a region of genomic DNA. It *may not* have the actual DNA sequence in there, and it is important to realise that. The numbering scheme of many other things (eg, genes) are going to be represented in this guys coordinates =head2 Member functions of GenomicRegion =over =item new_GenomicRegion &Wise2::GenomicRegion::new_GenomicRegion(gen) makes a genomicregion from a genomic sequence Argument gen [UNKN ] Undocumented argument [Genomic *] Return [UNKN ] Undocumented return value [GenomicRegion *] =item read_EMBL_GenomicRegion_file &Wise2::GenomicRegion::read_EMBL_GenomicRegion_file(filename) Reads in both EMBL sequence and features Argument filename [UNKN ] Undocumented argument [char *] Return [UNKN ] Undocumented return value [GenomicRegion *] =item read_EMBL_GenomicRegion &Wise2::GenomicRegion::read_EMBL_GenomicRegion(ifp) Reads in both EMBL sequence and features Argument ifp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [GenomicRegion *] =item add_Gene_to_GenomicRegion &Wise2::GenomicRegion::add_Gene_to_GenomicRegion(gr,gene) adds a Gene to this GenomicRegion, making sure that it parent/son relationship is ok Argument gr [UNKN ] GenomicRegion to be added to [GenomicRegion *] Argument gene [UNKN ] Gene to be added [Gene *] Return [UNKN ] Undocumented return value [boolean] =item show_ace_GenomicRegion &Wise2::GenomicRegion::show_ace_GenomicRegion(gr,seq_name,ofp) shows ACeDB subsequence source. Assummes a only one transcript per gene b only cds exons are used Argument gr [UNKN ] Undocumented argument [GenomicRegion *] Argument seq_name [UNKN ] Undocumented argument [char *] Argument ofp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [void] =item show_pretty_GenomicRegion &Wise2::GenomicRegion::show_pretty_GenomicRegion(gr,show_supporting,ofp) shows 'pretty' bio type gene Argument gr [UNKN ] Undocumented argument [GenomicRegion *] Argument show_supporting [UNKN ] Undocumented argument [boolean] Argument ofp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [void] =item write_Diana_FT_GenomicRegion &Wise2::GenomicRegion::write_Diana_FT_GenomicRegion(gr,ofp) Writes Embl feature table for diana use. Does assumme that there is only one transcript per gene and only cds exons are used Output like FT misc_feature join(100..200) Argument gr [UNKN ] Undocumented argument [GenomicRegion *] Argument ofp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [void] =item write_Embl_FT_GenomicRegion &Wise2::GenomicRegion::write_Embl_FT_GenomicRegion(gr,ofp) Writes Embl feature table. Does assumme that there is only one transcript per gene and only cds exons are used Output like FT CDS join(100..200) Argument gr [UNKN ] Undocumented argument [GenomicRegion *] Argument ofp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [void] =item hard_link_GenomicRegion &Wise2::GenomicRegion::hard_link_GenomicRegion(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [GenomicRegion *] Return [UNKN ] Undocumented return value [GenomicRegion *] =item GenomicRegion_alloc_std &Wise2::GenomicRegion::GenomicRegion_alloc_std(void) Equivalent to GenomicRegion_alloc_len(GenomicRegionLISTLENGTH) Return [UNKN ] Undocumented return value [GenomicRegion *] =item gene &Wise2::GenomicRegion::gene(obj,i) Access members stored in the gene list For use principly by API functions Argument obj [UNKN ] Object holding the list [GenomicRegion *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [Gene *] =item length_gene &Wise2::GenomicRegion::length_gene(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [GenomicRegion *] Return [UNKN ] length of the list [int] =item flush_gene &Wise2::GenomicRegion::flush_gene(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [GenomicRegion *] Return [UNKN ] Undocumented return value [int] =item add_gene &Wise2::GenomicRegion::add_gene(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [GenomicRegion *] Argument add [OWNER] Object to add to the list [Gene *] Return [UNKN ] Undocumented return value [boolean] =item set_genomic &Wise2::GenomicRegion::set_genomic(obj,genomic) Replace member variable genomic For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicRegion *] Argument genomic [OWNER] New value of the variable [Genomic *] Return [SOFT ] member variable genomic [boolean] =item genomic &Wise2::GenomicRegion::genomic(obj) Access member variable genomic For use principly by API functions Argument obj [UNKN ] Object holding the variable [GenomicRegion *] Return [SOFT ] member variable genomic [Genomic *] =back wise-2.4.1/src/dynlibsrc/genomicregion.tex0000644000175000001440000001276110670453712020214 0ustar philippusers\section{genomicregion} \label{module_genomicregion} This module contains the following objects \begin{itemize} \item \ref{object_GenomicRegion} GenomicRegion \end{itemize} \subsection{Object GenomicRegion} \label{object_GenomicRegion} The GenomicRegion object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{gene} Type [Gene ** : List] No documentation \item{genomic} Type [Genomic * : Scalar] NB, may not be here. Be careful! \end{description} GenomicRegion is structure which represents information on a region of genomic DNA. It *may not* have the actual DNA sequence in there, and it is important to realise that. The numbering scheme of many other things (eg, genes) are going to be represented in this guys coordinates Member functions of GenomicRegion \subsubsection{new_GenomicRegion} \begin{description} \item[External C] {\tt Wise2_new_GenomicRegion (gen)} \item[Perl] {\tt &Wise2::GenomicRegion::new_GenomicRegion (gen)} \item[Perl-OOP call] {\tt $obj->new_GenomicRegion()} \end{description} Arguments \begin{description} \item[gen] [UNKN ] Undocumented argument [Genomic *] \item[returns] [UNKN ] Undocumented return value [GenomicRegion *] \end{description} makes a genomicregion from a genomic sequence \subsubsection{read_EMBL_GenomicRegion_file} \begin{description} \item[External C] {\tt Wise2_read_EMBL_GenomicRegion_file (filename)} \item[Perl] {\tt &Wise2::GenomicRegion::read_EMBL_GenomicRegion_file (filename)} \item[Perl-OOP call] {\tt $obj->read_EMBL_GenomicRegion_file()} \end{description} Arguments \begin{description} \item[filename] [UNKN ] Undocumented argument [char *] \item[returns] [UNKN ] Undocumented return value [GenomicRegion *] \end{description} Reads in both EMBL sequence and features \subsubsection{read_EMBL_GenomicRegion} \begin{description} \item[External C] {\tt Wise2_read_EMBL_GenomicRegion (ifp)} \item[Perl] {\tt &Wise2::GenomicRegion::read_EMBL_GenomicRegion (ifp)} \item[Perl-OOP call] {\tt $obj->read_EMBL_GenomicRegion()} \end{description} Arguments \begin{description} \item[ifp] [UNKN ] Undocumented argument [FILE *] \item[returns] [UNKN ] Undocumented return value [GenomicRegion *] \end{description} Reads in both EMBL sequence and features \subsubsection{add_Gene_to_GenomicRegion} \begin{description} \item[External C] {\tt Wise2_add_Gene_to_GenomicRegion (gr,gene)} \item[Perl] {\tt &Wise2::GenomicRegion::add_Gene_to_GenomicRegion (gr,gene)} \item[Perl-OOP call] {\tt $obj->add_Gene_to_GenomicRegion(gene)} \end{description} Arguments \begin{description} \item[gr] [UNKN ] GenomicRegion to be added to [GenomicRegion *] \item[gene] [UNKN ] Gene to be added [Gene *] \item[returns] [UNKN ] Undocumented return value [boolean] \end{description} adds a Gene to this GenomicRegion, making sure that it parent/son relationship is ok \subsubsection{show_ace_GenomicRegion} \begin{description} \item[External C] {\tt Wise2_show_ace_GenomicRegion (gr,seq_name,ofp)} \item[Perl] {\tt &Wise2::GenomicRegion::show_ace_GenomicRegion (gr,seq_name,ofp)} \item[Perl-OOP call] {\tt $obj->show_ace_GenomicRegion(seq_name,ofp)} \end{description} Arguments \begin{description} \item[gr] [UNKN ] Undocumented argument [GenomicRegion *] \item[seq_name] [UNKN ] Undocumented argument [char *] \item[ofp] [UNKN ] Undocumented argument [FILE *] \item[returns] Nothing - no return value \end{description} shows ACeDB subsequence source. Assummes \begin{verbatim} a only one transcript per gene b only cds exons are used \end{verbatim} \subsubsection{show_pretty_GenomicRegion} \begin{description} \item[External C] {\tt Wise2_show_pretty_GenomicRegion (gr,show_supporting,ofp)} \item[Perl] {\tt &Wise2::GenomicRegion::show_pretty_GenomicRegion (gr,show_supporting,ofp)} \item[Perl-OOP call] {\tt $obj->show_pretty_GenomicRegion(show_supporting,ofp)} \end{description} Arguments \begin{description} \item[gr] [UNKN ] Undocumented argument [GenomicRegion *] \item[show_supporting] [UNKN ] Undocumented argument [boolean] \item[ofp] [UNKN ] Undocumented argument [FILE *] \item[returns] Nothing - no return value \end{description} shows 'pretty' bio type gene \subsubsection{write_Diana_FT_GenomicRegion} \begin{description} \item[External C] {\tt Wise2_write_Diana_FT_GenomicRegion (gr,ofp)} \item[Perl] {\tt &Wise2::GenomicRegion::write_Diana_FT_GenomicRegion (gr,ofp)} \item[Perl-OOP call] {\tt $obj->write_Diana_FT_GenomicRegion(ofp)} \end{description} Arguments \begin{description} \item[gr] [UNKN ] Undocumented argument [GenomicRegion *] \item[ofp] [UNKN ] Undocumented argument [FILE *] \item[returns] Nothing - no return value \end{description} Writes Embl feature table for diana use. Does assumme that there is only one transcript per gene and only cds exons are used Output like \begin{verbatim} FT misc_feature join(100..200) \end{verbatim} \subsubsection{write_Embl_FT_GenomicRegion} \begin{description} \item[External C] {\tt Wise2_write_Embl_FT_GenomicRegion (gr,ofp)} \item[Perl] {\tt &Wise2::GenomicRegion::write_Embl_FT_GenomicRegion (gr,ofp)} \item[Perl-OOP call] {\tt $obj->write_Embl_FT_GenomicRegion(ofp)} \end{description} Arguments \begin{description} \item[gr] [UNKN ] Undocumented argument [GenomicRegion *] \item[ofp] [UNKN ] Undocumented argument [FILE *] \item[returns] Nothing - no return value \end{description} Writes Embl feature table. Does assumme that there is only one transcript per gene and only cds exons are used Output like \begin{verbatim} FT CDS join(100..200) \end{verbatim} wise-2.4.1/src/dynlibsrc/complexsequence.dy0000644000175000001440000002216007454520716020402 0ustar philippusers/* Last edited: Jan 3 15:57 1997 (birney) */ %{ #include "sequence.h" #include "probability.h" /* should move this to wisestring */ #define ComplexSequenceEvalSetLISTLENGTH 16 #define next_ComplexSequence_data(cs_struct,pointer) (pointer + cs_struct->depth) #define ComplexSequence_data(cs,position,number) (cs->data[cs->depth*position + number]) typedef enum CseScoreType { CseScoreType_Index = 673, CseScoreType_Bits } CseScoreType; %} struct ComplexSequenceEval int type int sequence_type int left_window int right_window int left_lookback int outside_score; void * data !link int data_type //optional, to be used by eval_func to check things if it wants to int (*eval_func)(int,void * ,char *); !func CseScoreType score_type !default="CseScoreType_Index" %info This object is best left alone (!) It represents a single way of mapping a sequence to some sort of number, eg amino acids to 0-25, bases to 0-4 or splice sites to log(Prob(splice)) This is handled by a reasonably scary pointer-to-function method You'll use collections of them in complexsequenceevalset's %% struct ComplexSequenceEvalSet int type; boolean has_been_prepared !def="FALSE" int left_window // overall sequence eval int right_window // overall sequence eval int left_lookback // overall sequence eval ComplexSequenceEval ** cse !list !hidden %info This object holds a collection of ComplexSequenceEvals. Its role is to define the sequence specific parts of a dynamic programming algorithm as computable functions. Ideally you should use pre-made ComplexSequenceEvalSets as it will save you alot of grief %% struct ComplexSequence int type; Sequence * seq int * data !link !hidden int * datastore !hidden int depth !hidden int length ComplexSequenceEvalSet * creator // what made it %info A ComplexSequence is an abstraction of a Sequence which can be handily made using ComplexSequenceEval functions and is efficiently laid out in memory. %% api object ComplexSequence des free_ComplexSequence endobject object ComplexSequenceEvalSet des free_ComplexSequenceEvalSet endobject endapi %{ #include "complexsequence.h" %func Builds a reversed complex sequence where position i has all the correct numbers for this position reading from the opposite strand %% ComplexSequence * reversed_ComplexSequence(Sequence * forward,ComplexSequenceEvalSet * cses) { ComplexSequence * out; register int i; register int j; register int * poi; Sequence * rev; int seqlen; if( forward == NULL ) { warn("Trying to make a complex sequence from a NULL sequence - impossible!"); return NULL; } if( can_evaluate_this_Sequence(cses,forward) == FALSE ) { warn("Could not evaluate these sequences Sequence type [%d][%s] Evaluation type [%d][%s]",forward->type,Sequence_type_to_string(forward->type),cses->type,Sequence_type_to_string(cses->type)); return NULL; } if( cses->has_been_prepared == FALSE) { warn("Trappable error: you have not prepared this ComplexSequenceEvalSet before using. Please do so in the future"); prepare_ComplexSequenceEvalSet(cses); } rev = reverse_complement_Sequence(forward); out = ComplexSequence_alloc(); if( out == NULL ) return NULL; out->creator = hard_link_ComplexSequenceEvalSet(cses); out->datastore = (int *) ckcalloc((forward->len+cses->left_lookback)*cses->len,sizeof(int)); if( out->datastore == NULL ) { warn("Could not allocate data pointer of length %d for ComplexSequence",forward->len*cses->len); free_ComplexSequence(out); return NULL; } out->data = out->datastore + (cses->left_lookback * cses->len); for(i=0;ileft_lookback;i++) { for(j=0;jlen;j++) out->datastore[(i*cses->len)+j] = cses->cse[j]->outside_score; } out->depth = cses->len; seqlen = forward->len; for(i=0,poi = out->data;ilen;i++,poi = next_ComplexSequence_data(out,poi)) { for(j=0;jlen;j++) { /* fprintf(stderr,"Calling with i at %d vs %d\n",i,cses->cse[j]->left_window); */ if( i < cses->cse[j]->right_window || (i + cses->cse[j]->left_window) >= seqlen) poi[j] = cses->cse[j]->outside_score; else poi[j] = (*cses->cse[j]->eval_func)(cses->cse[j]->data_type,cses->cse[j]->data,rev->seq+seqlen-i); } } return out; } %func The basic way to make a ComplexSequence. Requires that you have already built a ComplexSequenceEvalSet (such as /default_aminoacid_ComplexSequenceEvalSet). %arg seq Sequence that the ComplexSequence is based on cses EvalSet that defines the functions used on the sequence %% ComplexSequence * new_ComplexSequence(Sequence * seq,ComplexSequenceEvalSet * cses) { ComplexSequence * out; register int i; register int j; register int * poi; if( seq == NULL ) { warn("Trying to make a complex sequence from a NULL sequence - impossible!"); return NULL; } if( can_evaluate_this_Sequence(cses,seq) == FALSE ) { warn("Could not evaluate these sequences Sequence type [%d][%s] Evaluation type [%d][%s]",seq->type,Sequence_type_to_string(seq->type),cses->type,Sequence_type_to_string(cses->type)); return NULL; } if( cses->has_been_prepared == FALSE) { warn("Trappable error: you have not prepared this ComplexSequenceEvalSet before using. Please do so in the future"); prepare_ComplexSequenceEvalSet(cses); } out = ComplexSequence_alloc(); if( out == NULL ) return NULL; out->creator = hard_link_ComplexSequenceEvalSet(cses); out->datastore = (int *) ckcalloc((seq->len+cses->left_lookback)*cses->len,sizeof(int)); if( out->datastore == NULL ) { warn("Could not allocate data pointer of length %d for ComplexSequence",seq->len*cses->len); free_ComplexSequence(out); return NULL; } out->data = out->datastore + (cses->left_lookback * cses->len); for(i=0;ileft_lookback;i++) { for(j=0;jlen;j++) out->datastore[(i*cses->len)+j] = cses->cse[j]->outside_score; } out->depth = cses->len; for(i=0,poi = out->data;ilen;i++,poi = next_ComplexSequence_data(out,poi)) { for(j=0;jlen;j++) { /* fprintf(stderr,"Calling with i at %d vs %d\n",i,cses->cse[j]->left_window); */ if( i < cses->cse[j]->left_window || (i + cses->cse[j]->right_window) >= seq->len) poi[j] = cses->cse[j]->outside_score; else poi[j] = (*cses->cse[j]->eval_func)(cses->cse[j]->data_type,cses->cse[j]->data,seq->seq+i); } } out->seq = hard_link_Sequence(seq); out->length = seq->len; return out; } %func shows complex sequence in a vaguely human form %arg %% void show_ComplexSequence(ComplexSequence * cs,FILE * ofp) { register int i; assert(cs); assert(ofp); assert(cs->seq); fprintf(ofp,"ComplexSequence %s\n",cs->seq->name); for(i=0;ilength;i++) { show_one_position_ComplexSequence(cs,i,ofp); } } %func shows one position of a complex sequence %type internal %arg %% void show_one_position_ComplexSequence(ComplexSequence * cs,int pos,FILE * ofp) { int i; assert(cs); assert(ofp); fprintf(ofp,"%4d %c [",pos,cs->seq->seq[pos]); for(i=0;idepth;i++) { if( cs->creator != NULL ) { if( cs->creator->cse[i]->score_type == CseScoreType_Index ) { fprintf(ofp,"%4d%c",ComplexSequence_data(cs,pos,i),i == cs->depth-1 ? ']' : ','); } else { fprintf(ofp,"% 6d (%0+2.2f)%c",ComplexSequence_data(cs,pos,i),Score2Bits(ComplexSequence_data(cs,pos,i)), i == cs->depth-1 ? ']' : ','); } } else { fprintf(ofp,"%4d%c",ComplexSequence_data(cs,pos,i),i == cs->depth-1 ? ']' : ','); } } fprintf(ofp,"\n"); } /********************************/ /* Making complex sequences */ /********************************/ %func Calculates all the necessary offset for an EvalSet. This is necessary before using it in a /new_ComplexSequence place %arg %% boolean prepare_ComplexSequenceEvalSet(ComplexSequenceEvalSet * cses) { register int i; int left_window = 0; int right_window = 0; int left_lookback = 0; for(i=0;ilen;i++) { if( cses->cse[i]->right_window > right_window ) right_window = cses->cse[i]->right_window; if( cses->cse[i]->left_window > left_window ) left_window = cses->cse[i]->left_window; if( cses->cse[i]->left_lookback > left_lookback ) left_lookback = cses->cse[i]->left_lookback; } cses->right_window = right_window; cses->left_window = left_window; cses->left_lookback = left_lookback; cses->has_been_prepared = TRUE; return TRUE; } %func Checks that this ComplexSequenceEvalSet can be used with this Sequence. This is probably going to go defunct. %arg %% boolean can_evaluate_this_Sequence(ComplexSequenceEvalSet * cses,Sequence * s) { return can_evaluate_this_type(cses,s->type); } %func Pretty much an internal for /can_evaluate_this_Sequence %type internal %arg %% boolean can_evaluate_this_type(ComplexSequenceEvalSet * cses,int type) { switch (type) { case SEQUENCE_UNKNOWN : return FALSE; case SEQUENCE_DNA : if( cses->type == SEQUENCE_DNA || cses->type == SEQUENCE_CDNA || cses->type == SEQUENCE_EST || cses->type == SEQUENCE_GENOMIC) return TRUE; else return FALSE; default : if( cses->type == type) return TRUE; else return FALSE; } } %} wise-2.4.1/src/dynlibsrc/complexsequence.xs0000644000175000001440000000727010670453712020420 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::ComplexSequence Wise2_ComplexSequence * hard_link_ComplexSequence(obj) Wise2_ComplexSequence * obj CODE: RETVAL = Wise2_hard_link_ComplexSequence(obj); OUTPUT: RETVAL Wise2_ComplexSequence * alloc() CODE: RETVAL = Wise2_ComplexSequence_alloc(); OUTPUT: RETVAL boolean set_type(obj,type) Wise2_ComplexSequence * obj int type CODE: RETVAL = Wise2_replace_type_ComplexSequence(obj,type); OUTPUT: RETVAL int type(obj) Wise2_ComplexSequence * obj CODE: RETVAL = Wise2_access_type_ComplexSequence(obj); OUTPUT: RETVAL boolean set_seq(obj,seq) Wise2_ComplexSequence * obj Wise2_Sequence * seq CODE: RETVAL = Wise2_replace_seq_ComplexSequence(obj,Wise2_hard_link_Sequence(seq)); OUTPUT: RETVAL Wise2_Sequence * seq(obj) Wise2_ComplexSequence * obj INIT: Wise2_Sequence * temp; CODE: temp = Wise2_hard_link_Sequence(Wise2_access_seq_ComplexSequence(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_ComplexSequence * new(class) char * class PPCODE: Wise2_ComplexSequence * out; out = Wise2_ComplexSequence_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_ComplexSequence * obj CODE: Wise2_free_ComplexSequence(obj); MODULE = Wise2 PACKAGE = Wise2::ComplexSequenceEvalSet Wise2_ComplexSequenceEvalSet * hard_link_ComplexSequenceEvalSet(obj) Wise2_ComplexSequenceEvalSet * obj CODE: RETVAL = Wise2_hard_link_ComplexSequenceEvalSet(obj); OUTPUT: RETVAL Wise2_ComplexSequenceEvalSet * ComplexSequenceEvalSet_alloc_std() CODE: RETVAL = Wise2_ComplexSequenceEvalSet_alloc_std(); OUTPUT: RETVAL boolean set_type(obj,type) Wise2_ComplexSequenceEvalSet * obj int type CODE: RETVAL = Wise2_replace_type_ComplexSequenceEvalSet(obj,type); OUTPUT: RETVAL int type(obj) Wise2_ComplexSequenceEvalSet * obj CODE: RETVAL = Wise2_access_type_ComplexSequenceEvalSet(obj); OUTPUT: RETVAL boolean set_has_been_prepared(obj,has_been_prepared) Wise2_ComplexSequenceEvalSet * obj boolean has_been_prepared CODE: RETVAL = Wise2_replace_has_been_prepared_ComplexSequenceEvalSet(obj,has_been_prepared); OUTPUT: RETVAL boolean has_been_prepared(obj) Wise2_ComplexSequenceEvalSet * obj CODE: RETVAL = Wise2_access_has_been_prepared_ComplexSequenceEvalSet(obj); OUTPUT: RETVAL boolean set_left_window(obj,left_window) Wise2_ComplexSequenceEvalSet * obj int left_window CODE: RETVAL = Wise2_replace_left_window_ComplexSequenceEvalSet(obj,left_window); OUTPUT: RETVAL int left_window(obj) Wise2_ComplexSequenceEvalSet * obj CODE: RETVAL = Wise2_access_left_window_ComplexSequenceEvalSet(obj); OUTPUT: RETVAL boolean set_right_window(obj,right_window) Wise2_ComplexSequenceEvalSet * obj int right_window CODE: RETVAL = Wise2_replace_right_window_ComplexSequenceEvalSet(obj,right_window); OUTPUT: RETVAL int right_window(obj) Wise2_ComplexSequenceEvalSet * obj CODE: RETVAL = Wise2_access_right_window_ComplexSequenceEvalSet(obj); OUTPUT: RETVAL boolean set_left_lookback(obj,left_lookback) Wise2_ComplexSequenceEvalSet * obj int left_lookback CODE: RETVAL = Wise2_replace_left_lookback_ComplexSequenceEvalSet(obj,left_lookback); OUTPUT: RETVAL int left_lookback(obj) Wise2_ComplexSequenceEvalSet * obj CODE: RETVAL = Wise2_access_left_lookback_ComplexSequenceEvalSet(obj); OUTPUT: RETVAL Wise2_ComplexSequenceEvalSet * new(class) char * class PPCODE: Wise2_ComplexSequenceEvalSet * out; out = Wise2_ComplexSequenceEvalSet_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_ComplexSequenceEvalSet * obj CODE: Wise2_free_ComplexSequenceEvalSet(obj); MODULE = Wise2 PACKAGE = Wise2 wise-2.4.1/src/dynlibsrc/gene.dy0000644000175000001440000002666107345671711016133 0ustar philippusers %{ #include "dyna.h" #define GeneLISTLENGTH 16 %} api object Gene des free_Gene func get_Genomic_from_Gene func show_pretty_Gene endobject endapi friend GenomicRegion friend Transcript struct Gene int start int end GenomicRegion * parent !link // may not be here Genomic * genomic // may not be here! Transcript ** transcript !list char * name // ugly . Need a better system double bits // ditto... char * seqname // very bad! this is for keeping track of what sequence was used to make the gene boolean ispseudo !def="FALSE" // is a pseudogene or not %info Gene is the datastructure which represents a single gene. At the moment this is considered to be a series of transcripts (the first transcript being "canonical") which are made from a certain start/stop region in genomic DNA. The gene datastructure does not necessarily contain any DNA sequence. When someone askes for the gene sequence, via get_Genomic_from_Gene(), it first sees if there is anything in the Genomic * 'cache'. If this is null, it then looks at parent (the genomic region), and if that is null, complains and returns null. Otherwise it truncates its parent's dna in the correct way, places the data structure into the genomic * cache, and returns it. The name, bits and seqname have put into this datastructure for convience of carrying around this information into some of the gene prediction output formats. Probabaly o they should be in transcript, not gene o they shouldn't be here at all. %% %{ #include "gene.h" %func is this gene reversed? %simple reversed %% boolean reversed_Gene(Gene * g) { if( g->start < g->end ) return FALSE; return TRUE; } %func Makes a completely fresh copy of a gene %% Gene * copy_Gene(Gene * g) { int i; Gene * out; out = Gene_alloc(); for(i=0;ilen;i++) add_Gene(out,copy_Transcript(g->transcript[i])); return out; } %func Does this gene have a single transcript that transcript with translation start/end at the ends %% boolean is_simple_prediction_Gene(Gene * g) { if( g->len > 1 ) return FALSE; if( g->transcript[0]->len > 1 ) return FALSE; if( g->transcript[0]->translation[0]->start != 0 || g->transcript[0]->translation[0]->end != length_Transcript(g->transcript[0]) ) return FALSE; return TRUE; } %func Gives back a Genomic sequence type from a gene. %arg gene r gene to get Genomic from return s Genomic DNA data structure %% Genomic * get_Genomic_from_Gene(Gene * gene) { Genomic * gn; char buffer[64]; /* fprintf(stdout,"Getting genomic...\n"); */ if( gene->genomic != NULL ) return gene->genomic; if( gene->parent == NULL ) { warn("Cannot get Gene, as no parent genomic region!"); return NULL; } gn = get_Genomic_from_GenomicRegion(gene->parent); if( gn == NULL) { warn("Cannot get Gene, as no sequence in genomic region!"); return NULL; } if( gn->baseseq->offset < gn->baseseq->end) { if( gene->start > gene->end ) gene->genomic = truncate_Genomic(gn,gene->start-gn->baseseq->offset+2,gene->end-gn->baseseq->offset+2); else gene->genomic = truncate_Genomic(gn,gene->start-gn->baseseq->offset+1,gene->end-gn->baseseq->offset+1); } else { gene->genomic = truncate_Genomic(gn,gn->baseseq->offset-1 - gene->start,gn->baseseq->offset-1 - gene->end); } sprintf(buffer,"%s.[%d:%d]",Genomic_name(gn),gene->start+1,gene->end); ckfree(gene->genomic->baseseq->name); gene->genomic->baseseq->name = stringalloc(buffer); return gene->genomic; } #define MAX_EMBL_EXON_PARSE 128 %func Reads in an EMBL feature table. It expects to be passed a buffer with 'FT CDS'. or 'FT mRNA' in it. It will then use the buffer to read successive lines of the Feature table until it comes to the next 'meta' feature line (ie, 3 place point). It will use functions in /embl module for the reading. %arg buffer a string with FT CDS line in it maxlen length of the buffer ifp file stream with the rest of the feature table in it %% Gene * read_EMBL_feature_Gene(char * buffer,int maxlen,FILE * ifp) { Gene * gene; Transcript * tr; Translation * ts; Exon * exon; char * runner; char * base; char * next; int i; int exon_start[MAX_EMBL_EXON_PARSE]; int exon_end[MAX_EMBL_EXON_PARSE]; int number; int exon_no = 0; int isstart = 1; int is_complement = 0; int is_cds = 0; int break_at_end = 0; if( strstartcmp(buffer,"FT") != 0 ) { warn("passed in a bad line [%s] to be used for feature table parsing",buffer); return NULL; } if( (runner=strtok(buffer+2,spacestr)) == NULL ) { warn("Bad embl feature line [%s]",buffer); return NULL; } if( strcmp(runner,"CDS") != 0 && strcmp(runner,"mRNA") != 0 ) { warn("passed in a feature line to read_EMBL_feature_Gene with a %s tag. This only handles CDS and mRNA tags",runner); return NULL; } if( strcmp(runner,"CDS") == 0 ) { is_cds = TRUE; } runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("Bad embl feature line [%s]",buffer); return NULL; } if( strstartcmp(runner,"complement") == 0 ) { runner = strchr(runner,'('); if( runner == NULL) { warn("Could not find bracket on EMBL feature complement line"); return NULL; } is_complement = 1; runner++; } if( strstartcmp(runner,"join") == 0 ) { runner = strchr(runner,'('); runner++; } else if( isdigit((int)*runner) || *runner == '<' ) { /** ok - starts with the numbers. We'll cope!**/ } else { warn("Expecting a join statement, got a [%s]",runner); return NULL; } /*** ok, now the major number loop ***/ for(;;) { base= runner; for(;*runner && *runner != ')' && *runner != '.' && *runner != ',' && *runner != '>' && !isspace((int)*runner);runner++) ; /*fprintf(stderr,"Got a runner of %s\n ",runner); */ if( *runner == '\0' ) next = runner; else next = runner+1; if( *runner == ')' ) { break_at_end = TRUE; /* out of reading exons */ } *runner='\0'; if( strstartcmp(base,"complement(") == 0 ) { is_complement = TRUE; for(;*base != '(';base++) ; base++; break_at_end = FALSE; /* we found an bracket too early! */ } if( is_integer_string(base,&number) == FALSE ) { warn("Got a non integer [%s] in the middle of a join statement in EMBL parsing",runner); return NULL; } /** put this number away **/ if( isstart ) { exon_start[exon_no] = number; isstart = 0; } else { exon_end[exon_no++] = number; isstart = 1; } if( break_at_end == TRUE) break; for(runner=next;*runner && (*runner == '.' || isspace((int)*runner));runner++) ; if( *runner == '\0' ) { if( next_feature_tab_line(buffer,maxlen,ifp) == FALSE) { warn("In the middle of getting a join statement, got a [%s]. Yuk!",buffer); return NULL; } if( !isdigit((int)buffer[0]) && buffer[0] != '.' && buffer[0] != ',') { /*** ok - sometimes people very boring end things in here ***/ /* warn("In the middle of getting a join statement, got a [%s]. Ugh!",buffer); */ break; } runner = buffer; } } if( isstart == 0 ) { warn("I have read an uneven number of start-end points in the exon thing. Yuk!"); return NULL; } /** runner should now be on bracket **/ if( is_complement == 1 ) { /** ok . should be another bracket. Do we care? **/ } gene = Gene_alloc_len(1); tr = Transcript_alloc_len(exon_no); add_Gene(gene,tr); tr->parent = gene; if( is_complement == 1 ) { gene->start = exon_end[exon_no-1]-1; gene->end = exon_start[0] -1; for(i=exon_no -1;i >= 0;i--) { exon = Exon_alloc(); exon->start = (gene->start+1) - exon_end[i]; exon->end = (gene->start+1) - exon_start[i] +1; add_ex_Transcript(tr,exon); } } else { gene->start = exon_start[0] -1; gene->end = exon_end[exon_no-1] -1; for(i=0;istart = exon_start[i] - (gene->start+1); exon->end = exon_end[i] - (gene->start+1)+1; add_ex_Transcript(tr,exon); } } if( is_cds == TRUE ) { ts = Translation_alloc(); ts->start = 0; ts->end = length_Transcript(tr); ts->parent = tr; add_Transcript(tr,ts); } /*** read the rest of this feature ***/ while( next_feature_tab_line(buffer,maxlen,ifp) == TRUE) ; return gene; } %func shows a embl feature table part %% void write_Embl_FT_Gene(Gene * ge,char * key,FILE * ofp) { int i; Transcript * tr; int j; if( ge->start > ge->end ) { for(i=0;ilen;i++) { tr = ge->transcript[i]; if( tr->ex_len > 1 ) { fprintf(ofp,"FT %10s complement(join(",key); } else { fprintf(ofp,"FT %10s complement(",key); } for(j=0;jex_len;j++) { fprintf(ofp,"%d..%d%s",ge->start+1 - tr->exon[j]->start,ge->start - tr->exon[j]->end+2,j+1 == tr->ex_len ? "" : ","); if( j != 0 && j+1 != tr->ex_len && (j%3) == 0 ) { fprintf(ofp,"\nFT "); } } /* end of for over exons */ if( tr->ex_len > 1 ) { fprintf(ofp,"))\n"); } else { fprintf(ofp,")\n"); } } } else { for(i=0;ilen;i++) { tr = ge->transcript[i]; if( tr->ex_len > 1 ) { fprintf(ofp,"FT %10s join(",key); } else { fprintf(ofp,"FT %10s ",key); } for(j=0;jex_len;j++) { fprintf(ofp,"%d..%d%s",tr->exon[j]->start+ge->start+1,tr->exon[j]->end+ge->start,j+1 == tr->ex_len ? "" : ","); if( j != 0 && j+1 != tr->ex_len && (j%3) == 0 ) { fprintf(ofp,"\nFT "); } } } if( tr->ex_len > 1 ) { fprintf(ofp,")\n"); } else { fprintf(ofp,"\n"); } } } %func Shows a gene in the biologically accepted form %% void show_pretty_Gene(Gene * ge,boolean show_supporting,FILE * ofp) { int i; int j; int k; if( ge->start > ge->end ) { fprintf(ofp,"Gene %d %d%s\n",ge->start+1,ge->end+2,ge->ispseudo == TRUE ? " [pseudogene]" : ""); for(i=0;ilen;i++) { auto Transcript * tr; if( ge->len != 1 ) { fprintf(ofp," Transcript %d\n",i); } tr = ge->transcript[i]; for(j=0;jex_len;j++) { fprintf(ofp," Exon %d %d phase %d\n",ge->start+1 - tr->exon[j]->start,ge->start - tr->exon[j]->end+2,tr->exon[j]->phase); if( show_supporting ) { auto Exon * ex; ex = tr->exon[j]; for(k=0;kexon[j]->len;k++) { fprintf(ofp," Supporting %d %d %d %d\n",ge->start+1 - ex->sf[k]->start,ge->start - ex->sf[k]->end+2,ex->sf[k]->hstart+1,ex->sf[k]->hend); } } } } } else { fprintf(ofp,"Gene %d %d %s\n",ge->start+1,ge->end,ge->ispseudo == TRUE ? "[pseudogene]" : ""); for(i=0;ilen;i++) { auto Transcript * tr; if( ge->len != 1 ) { fprintf(ofp," Transcript %d\n",i); } tr = ge->transcript[i]; for(j=0;jex_len;j++) { fprintf(ofp," Exon %d %d phase %d\n",tr->exon[j]->start+ge->start+1, tr->exon[j]->end+ge->start,tr->exon[j]->phase); if( show_supporting ) { auto Exon * ex; ex = tr->exon[j]; for(k=0;kexon[j]->len;k++) { fprintf(ofp," Supporting %d %d %d %d\n",ge->start+1+ex->sf[k]->start,ge->start+ex->sf[k]->end,ex->sf[k]->hstart+1,ex->sf[k]->hend); } } } } } } %func shows a gene in a vaguely human readable form %% void show_Gene(Gene * ge,FILE * ofp) { int i; fprintf(ofp,"Gene %d - %d\n",ge->start,ge->end); for(i=0;ilen;i++) { fprintf(ofp,"Transcript %d\n",i); show_Transcript(ge->transcript[i],ofp); } } %} wise-2.4.1/src/dynlibsrc/gene.xs0000644000175000001440000001004410670453712016127 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::Gene Wise2_Genomic * get_Genomic_from_Gene(gene) Wise2_Gene * gene INIT: Wise2_Genomic * temp; CODE: temp = Wise2_hard_link_Genomic(Wise2_get_Genomic_from_Gene(gene)); RETVAL = temp; OUTPUT: RETVAL void show_pretty_Gene(ge,show_supporting,ofp) Wise2_Gene * ge boolean show_supporting FILE * ofp CODE: Wise2_show_pretty_Gene(ge,show_supporting,ofp); Wise2_Gene * hard_link_Gene(obj) Wise2_Gene * obj CODE: RETVAL = Wise2_hard_link_Gene(obj); OUTPUT: RETVAL Wise2_Gene * Gene_alloc_std() CODE: RETVAL = Wise2_Gene_alloc_std(); OUTPUT: RETVAL boolean set_start(obj,start) Wise2_Gene * obj int start CODE: RETVAL = Wise2_replace_start_Gene(obj,start); OUTPUT: RETVAL int start(obj) Wise2_Gene * obj CODE: RETVAL = Wise2_access_start_Gene(obj); OUTPUT: RETVAL boolean set_end(obj,end) Wise2_Gene * obj int end CODE: RETVAL = Wise2_replace_end_Gene(obj,end); OUTPUT: RETVAL int end(obj) Wise2_Gene * obj CODE: RETVAL = Wise2_access_end_Gene(obj); OUTPUT: RETVAL boolean set_parent(obj,parent) Wise2_Gene * obj Wise2_GenomicRegion * parent CODE: RETVAL = Wise2_replace_parent_Gene(obj,Wise2_hard_link_GenomicRegion(parent)); OUTPUT: RETVAL Wise2_GenomicRegion * parent(obj) Wise2_Gene * obj INIT: Wise2_GenomicRegion * temp; CODE: temp = Wise2_hard_link_GenomicRegion(Wise2_access_parent_Gene(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_genomic(obj,genomic) Wise2_Gene * obj Wise2_Genomic * genomic CODE: RETVAL = Wise2_replace_genomic_Gene(obj,Wise2_hard_link_Genomic(genomic)); OUTPUT: RETVAL Wise2_Genomic * genomic(obj) Wise2_Gene * obj INIT: Wise2_Genomic * temp; CODE: temp = Wise2_hard_link_Genomic(Wise2_access_genomic_Gene(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_Transcript * transcript(obj,i) Wise2_Gene * obj int i INIT: Wise2_Transcript * temp; CODE: temp = Wise2_hard_link_Transcript(Wise2_access_transcript_Gene(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_transcript(obj) Wise2_Gene * obj CODE: RETVAL = Wise2_length_transcript_Gene(obj); OUTPUT: RETVAL int flush_transcript(obj) Wise2_Gene * obj CODE: RETVAL = Wise2_flush_Gene(obj); OUTPUT: RETVAL boolean add_transcript(obj,add) Wise2_Gene * obj Wise2_Transcript * add CODE: RETVAL = Wise2_add_Gene(obj,Wise2_hard_link_Transcript(add)); OUTPUT: RETVAL boolean set_name(obj,name) Wise2_Gene * obj char * name CODE: RETVAL = Wise2_replace_name_Gene(obj,Wise2_stringalloc(name)); OUTPUT: RETVAL char * name(obj) Wise2_Gene * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_name_Gene(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_bits(obj,bits) Wise2_Gene * obj double bits CODE: RETVAL = Wise2_replace_bits_Gene(obj,bits); OUTPUT: RETVAL double bits(obj) Wise2_Gene * obj CODE: RETVAL = Wise2_access_bits_Gene(obj); OUTPUT: RETVAL boolean set_seqname(obj,seqname) Wise2_Gene * obj char * seqname CODE: RETVAL = Wise2_replace_seqname_Gene(obj,Wise2_stringalloc(seqname)); OUTPUT: RETVAL char * seqname(obj) Wise2_Gene * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_seqname_Gene(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_ispseudo(obj,ispseudo) Wise2_Gene * obj boolean ispseudo CODE: RETVAL = Wise2_replace_ispseudo_Gene(obj,ispseudo); OUTPUT: RETVAL boolean ispseudo(obj) Wise2_Gene * obj CODE: RETVAL = Wise2_access_ispseudo_Gene(obj); OUTPUT: RETVAL Wise2_Gene * new(class) char * class PPCODE: Wise2_Gene * out; out = Wise2_Gene_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_Gene * obj CODE: Wise2_free_Gene(obj); void each_transcript(obj) Wise2_Gene * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_transcript_Gene(obj); for(i=0;icurrent = head; out = SeqLookupResultInterface_alloc(); out->next = next_linkedl_SeqLook; out->is_more = is_more_linkedl_SeqLook; out->free_data = free_linkedl_SeqLook; out->data = (void*)data; return out; } %func Internal function returns data... %% void free_linkedl_SeqLook(void * data) { SeqLookupPosResult * posres = (SeqLookupPosResult *) data; free_SeqLookupPosResult(posres); } %func Internal function for returning whether there is more data %% boolean is_more_linkedl_SeqLook(void *data) { SeqLookupPosResult * posres = (SeqLookupPosResult *) data; if( posres->current == NULL ) { return FALSE; } else { return TRUE; } } %func Internal function for returning the next position in the hash %% SeqLookupResultStruct * next_linkedl_SeqLook(void * data,SeqLookupResultStruct * prev) { SeqLookupPosResult * posres = (SeqLookupPosResult *) data; if( posres->current == NULL ) { fatal("Overrun virtual buffer"); } posres->result.seq = posres->current->seq; posres->result.pos = posres->current->pos; posres->current = posres->current->next; return &(posres->result); } wise-2.4.1/src/dynlibsrc/gene.c0000644000175000001440000007211510670453712015726 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "gene.h" /* Function: reversed_Gene(g) * * Descrip: is this gene reversed? * * * Arg: g [UNKN ] Undocumented argument [Gene *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 67 "gene.dy" boolean reversed_Gene(Gene * g) { if( g->start < g->end ) return FALSE; return TRUE; } /* Function: copy_Gene(g) * * Descrip: Makes a completely fresh copy of a * gene * * * Arg: g [UNKN ] Undocumented argument [Gene *] * * Return [UNKN ] Undocumented return value [Gene *] * */ # line 78 "gene.dy" Gene * copy_Gene(Gene * g) { int i; Gene * out; out = Gene_alloc(); for(i=0;ilen;i++) add_Gene(out,copy_Transcript(g->transcript[i])); return out; } /* Function: is_simple_prediction_Gene(g) * * Descrip: Does this gene have * a single transcript * that transcript with translation start/end * at the ends * * * Arg: g [UNKN ] Undocumented argument [Gene *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 96 "gene.dy" boolean is_simple_prediction_Gene(Gene * g) { if( g->len > 1 ) return FALSE; if( g->transcript[0]->len > 1 ) return FALSE; if( g->transcript[0]->translation[0]->start != 0 || g->transcript[0]->translation[0]->end != length_Transcript(g->transcript[0]) ) return FALSE; return TRUE; } /* Function: get_Genomic_from_Gene(gene) * * Descrip: Gives back a Genomic sequence type * from a gene. * * * Arg: gene [READ ] gene to get Genomic from [Gene *] * * Return [SOFT ] Genomic DNA data structure [Genomic *] * */ # line 117 "gene.dy" Genomic * get_Genomic_from_Gene(Gene * gene) { Genomic * gn; char buffer[64]; /* fprintf(stdout,"Getting genomic...\n"); */ if( gene->genomic != NULL ) return gene->genomic; if( gene->parent == NULL ) { warn("Cannot get Gene, as no parent genomic region!"); return NULL; } gn = get_Genomic_from_GenomicRegion(gene->parent); if( gn == NULL) { warn("Cannot get Gene, as no sequence in genomic region!"); return NULL; } if( gn->baseseq->offset < gn->baseseq->end) { if( gene->start > gene->end ) gene->genomic = truncate_Genomic(gn,gene->start-gn->baseseq->offset+2,gene->end-gn->baseseq->offset+2); else gene->genomic = truncate_Genomic(gn,gene->start-gn->baseseq->offset+1,gene->end-gn->baseseq->offset+1); } else { gene->genomic = truncate_Genomic(gn,gn->baseseq->offset-1 - gene->start,gn->baseseq->offset-1 - gene->end); } sprintf(buffer,"%s.[%d:%d]",Genomic_name(gn),gene->start+1,gene->end); ckfree(gene->genomic->baseseq->name); gene->genomic->baseseq->name = stringalloc(buffer); return gene->genomic; } #define MAX_EMBL_EXON_PARSE 128 /* Function: read_EMBL_feature_Gene(buffer,maxlen,ifp) * * Descrip: Reads in an EMBL feature table. * * It expects to be passed a buffer with 'FT CDS'. * or 'FT mRNA' in it. It will then * use the buffer to read successive lines of the Feature table * until it comes to the next 'meta' feature line (ie, 3 place point). * * It will use functions in /embl module for the reading. * * * Arg: buffer [UNKN ] a string with FT CDS line in it [char *] * Arg: maxlen [UNKN ] length of the buffer [int] * Arg: ifp [UNKN ] file stream with the rest of the feature table in it [FILE *] * * Return [UNKN ] Undocumented return value [Gene *] * */ # line 172 "gene.dy" Gene * read_EMBL_feature_Gene(char * buffer,int maxlen,FILE * ifp) { Gene * gene; Transcript * tr; Translation * ts; Exon * exon; char * runner; char * base; char * next; int i; int exon_start[MAX_EMBL_EXON_PARSE]; int exon_end[MAX_EMBL_EXON_PARSE]; int number; int exon_no = 0; int isstart = 1; int is_complement = 0; int is_cds = 0; int break_at_end = 0; if( strstartcmp(buffer,"FT") != 0 ) { warn("passed in a bad line [%s] to be used for feature table parsing",buffer); return NULL; } if( (runner=strtok(buffer+2,spacestr)) == NULL ) { warn("Bad embl feature line [%s]",buffer); return NULL; } if( strcmp(runner,"CDS") != 0 && strcmp(runner,"mRNA") != 0 ) { warn("passed in a feature line to read_EMBL_feature_Gene with a %s tag. This only handles CDS and mRNA tags",runner); return NULL; } if( strcmp(runner,"CDS") == 0 ) { is_cds = TRUE; } runner = strtok(NULL,spacestr); if( runner == NULL ) { warn("Bad embl feature line [%s]",buffer); return NULL; } if( strstartcmp(runner,"complement") == 0 ) { runner = strchr(runner,'('); if( runner == NULL) { warn("Could not find bracket on EMBL feature complement line"); return NULL; } is_complement = 1; runner++; } if( strstartcmp(runner,"join") == 0 ) { runner = strchr(runner,'('); runner++; } else if( isdigit((int)*runner) || *runner == '<' ) { /** ok - starts with the numbers. We'll cope!**/ } else { warn("Expecting a join statement, got a [%s]",runner); return NULL; } /*** ok, now the major number loop ***/ for(;;) { base= runner; for(;*runner && *runner != ')' && *runner != '.' && *runner != ',' && *runner != '>' && !isspace((int)*runner);runner++) ; /*fprintf(stderr,"Got a runner of %s\n ",runner); */ if( *runner == '\0' ) next = runner; else next = runner+1; if( *runner == ')' ) { break_at_end = TRUE; /* out of reading exons */ } *runner='\0'; if( strstartcmp(base,"complement(") == 0 ) { is_complement = TRUE; for(;*base != '(';base++) ; base++; break_at_end = FALSE; /* we found an bracket too early! */ } if( is_integer_string(base,&number) == FALSE ) { warn("Got a non integer [%s] in the middle of a join statement in EMBL parsing",runner); return NULL; } /** put this number away **/ if( isstart ) { exon_start[exon_no] = number; isstart = 0; } else { exon_end[exon_no++] = number; isstart = 1; } if( break_at_end == TRUE) break; for(runner=next;*runner && (*runner == '.' || isspace((int)*runner));runner++) ; if( *runner == '\0' ) { if( next_feature_tab_line(buffer,maxlen,ifp) == FALSE) { warn("In the middle of getting a join statement, got a [%s]. Yuk!",buffer); return NULL; } if( !isdigit((int)buffer[0]) && buffer[0] != '.' && buffer[0] != ',') { /*** ok - sometimes people very boring end things in here ***/ /* warn("In the middle of getting a join statement, got a [%s]. Ugh!",buffer); */ break; } runner = buffer; } } if( isstart == 0 ) { warn("I have read an uneven number of start-end points in the exon thing. Yuk!"); return NULL; } /** runner should now be on bracket **/ if( is_complement == 1 ) { /** ok . should be another bracket. Do we care? **/ } gene = Gene_alloc_len(1); tr = Transcript_alloc_len(exon_no); add_Gene(gene,tr); tr->parent = gene; if( is_complement == 1 ) { gene->start = exon_end[exon_no-1]-1; gene->end = exon_start[0] -1; for(i=exon_no -1;i >= 0;i--) { exon = Exon_alloc(); exon->start = (gene->start+1) - exon_end[i]; exon->end = (gene->start+1) - exon_start[i] +1; add_ex_Transcript(tr,exon); } } else { gene->start = exon_start[0] -1; gene->end = exon_end[exon_no-1] -1; for(i=0;istart = exon_start[i] - (gene->start+1); exon->end = exon_end[i] - (gene->start+1)+1; add_ex_Transcript(tr,exon); } } if( is_cds == TRUE ) { ts = Translation_alloc(); ts->start = 0; ts->end = length_Transcript(tr); ts->parent = tr; add_Transcript(tr,ts); } /*** read the rest of this feature ***/ while( next_feature_tab_line(buffer,maxlen,ifp) == TRUE) ; return gene; } /* Function: write_Embl_FT_Gene(ge,key,ofp) * * Descrip: shows a embl feature table part * * * Arg: ge [UNKN ] Undocumented argument [Gene *] * Arg: key [UNKN ] Undocumented argument [char *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 361 "gene.dy" void write_Embl_FT_Gene(Gene * ge,char * key,FILE * ofp) { int i; Transcript * tr; int j; if( ge->start > ge->end ) { for(i=0;ilen;i++) { tr = ge->transcript[i]; if( tr->ex_len > 1 ) { fprintf(ofp,"FT %10s complement(join(",key); } else { fprintf(ofp,"FT %10s complement(",key); } for(j=0;jex_len;j++) { fprintf(ofp,"%d..%d%s",ge->start+1 - tr->exon[j]->start,ge->start - tr->exon[j]->end+2,j+1 == tr->ex_len ? "" : ","); if( j != 0 && j+1 != tr->ex_len && (j%3) == 0 ) { fprintf(ofp,"\nFT "); } } /* end of for over exons */ if( tr->ex_len > 1 ) { fprintf(ofp,"))\n"); } else { fprintf(ofp,")\n"); } } } else { for(i=0;ilen;i++) { tr = ge->transcript[i]; if( tr->ex_len > 1 ) { fprintf(ofp,"FT %10s join(",key); } else { fprintf(ofp,"FT %10s ",key); } for(j=0;jex_len;j++) { fprintf(ofp,"%d..%d%s",tr->exon[j]->start+ge->start+1,tr->exon[j]->end+ge->start,j+1 == tr->ex_len ? "" : ","); if( j != 0 && j+1 != tr->ex_len && (j%3) == 0 ) { fprintf(ofp,"\nFT "); } } } if( tr->ex_len > 1 ) { fprintf(ofp,")\n"); } else { fprintf(ofp,"\n"); } } } /* Function: show_pretty_Gene(ge,show_supporting,ofp) * * Descrip: Shows a gene in the biologically accepted form * * * Arg: ge [UNKN ] Undocumented argument [Gene *] * Arg: show_supporting [UNKN ] Undocumented argument [boolean] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 416 "gene.dy" void show_pretty_Gene(Gene * ge,boolean show_supporting,FILE * ofp) { int i; int j; int k; if( ge->start > ge->end ) { fprintf(ofp,"Gene %d %d%s\n",ge->start+1,ge->end+2,ge->ispseudo == TRUE ? " [pseudogene]" : ""); for(i=0;ilen;i++) { auto Transcript * tr; if( ge->len != 1 ) { fprintf(ofp," Transcript %d\n",i); } tr = ge->transcript[i]; for(j=0;jex_len;j++) { fprintf(ofp," Exon %d %d phase %d\n",ge->start+1 - tr->exon[j]->start,ge->start - tr->exon[j]->end+2,tr->exon[j]->phase); if( show_supporting ) { auto Exon * ex; ex = tr->exon[j]; for(k=0;kexon[j]->len;k++) { fprintf(ofp," Supporting %d %d %d %d\n",ge->start+1 - ex->sf[k]->start,ge->start - ex->sf[k]->end+2,ex->sf[k]->hstart+1,ex->sf[k]->hend); } } } } } else { fprintf(ofp,"Gene %d %d %s\n",ge->start+1,ge->end,ge->ispseudo == TRUE ? "[pseudogene]" : ""); for(i=0;ilen;i++) { auto Transcript * tr; if( ge->len != 1 ) { fprintf(ofp," Transcript %d\n",i); } tr = ge->transcript[i]; for(j=0;jex_len;j++) { fprintf(ofp," Exon %d %d phase %d\n",tr->exon[j]->start+ge->start+1, tr->exon[j]->end+ge->start,tr->exon[j]->phase); if( show_supporting ) { auto Exon * ex; ex = tr->exon[j]; for(k=0;kexon[j]->len;k++) { fprintf(ofp," Supporting %d %d %d %d\n",ge->start+1+ex->sf[k]->start,ge->start+ex->sf[k]->end,ex->sf[k]->hstart+1,ex->sf[k]->hend); } } } } } } /* Function: show_Gene(ge,ofp) * * Descrip: shows a gene in a vaguely human readable form * * * Arg: ge [UNKN ] Undocumented argument [Gene *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 469 "gene.dy" void show_Gene(Gene * ge,FILE * ofp) { int i; fprintf(ofp,"Gene %d - %d\n",ge->start,ge->end); for(i=0;ilen;i++) { fprintf(ofp,"Transcript %d\n",i); show_Transcript(ge->transcript[i],ofp); } } # line 465 "gene.c" /* Function: swap_Gene(list,i,j) * * Descrip: swap function: an internal for qsort_Gene * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Transcript **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Gene(Transcript ** list,int i,int j) { Transcript * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Gene(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Gene which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Transcript **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Gene(Transcript ** list,int left,int right,int (*comp)(Transcript * ,Transcript * )) { int i,last; if( left >= right ) return; swap_Gene(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Gene (list,++last,i); } swap_Gene (list,left,last); qsort_Gene(list,left,last-1,comp); qsort_Gene(list,last+1,right,comp); } /* Function: sort_Gene(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Gene * * * Arg: obj [UNKN ] Object containing list [Gene *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Gene(Gene * obj,int (*comp)(Transcript *, Transcript *)) { qsort_Gene(obj->transcript,0,obj->len-1,comp); return; } /* Function: expand_Gene(obj,len) * * Descrip: Really an internal function for add_Gene * * * Arg: obj [UNKN ] Object which contains the list [Gene *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Gene(Gene * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Gene called with no need"); return TRUE; } if( (obj->transcript = (Transcript ** ) ckrealloc (obj->transcript,sizeof(Transcript *)*len)) == NULL) { warn("ckrealloc failed for expand_Gene, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Gene(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Gene *] * Arg: add [OWNER] Object to add to the list [Transcript *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Gene(Gene * obj,Transcript * add) { if( obj->len >= obj->maxlen) { if( expand_Gene(obj,obj->len + GeneLISTLENGTH) == FALSE) return FALSE; } obj->transcript[obj->len++]=add; return TRUE; } /* Function: flush_Gene(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Gene *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Gene(Gene * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->transcript[i] != NULL) { free_Transcript(obj->transcript[i]); obj->transcript[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: Gene_alloc_std(void) * * Descrip: Equivalent to Gene_alloc_len(GeneLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * Gene_alloc_std(void) { return Gene_alloc_len(GeneLISTLENGTH); } /* Function: Gene_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * Gene_alloc_len(int len) { Gene * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Gene_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->transcript = (Transcript ** ) ckcalloc (len,sizeof(Transcript *))) == NULL) { warn("Warning, ckcalloc failed in Gene_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_Gene(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Gene *] * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * hard_link_Gene(Gene * obj) { if( obj == NULL ) { warn("Trying to hard link to a Gene object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Gene_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * Gene_alloc(void) { Gene * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Gene *) ckalloc (sizeof(Gene))) == NULL) { warn("Gene_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->end = 0; out->genomic = NULL; out->transcript = NULL; out->len = out->maxlen = 0; out->name = NULL; out->bits = 0; out->seqname = NULL; out->ispseudo = FALSE; return out; } /* Function: free_Gene(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Gene *] * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * free_Gene(Gene * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Gene obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->parent is linked in */ if( obj->genomic != NULL) free_Genomic(obj->genomic); if( obj->transcript != NULL) { for(i=0;ilen;i++) { if( obj->transcript[i] != NULL) free_Transcript(obj->transcript[i]); } ckfree(obj->transcript); } if( obj->name != NULL) ckfree(obj->name); if( obj->seqname != NULL) ckfree(obj->seqname); ckfree(obj); return NULL; } /* Function: replace_start_Gene(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * Arg: start [OWNER] New value of the variable [int] * * Return [SOFT ] member variable start [boolean] * */ boolean replace_start_Gene(Gene * obj,int start) { if( obj == NULL) { warn("In replacement function start for object Gene, got a NULL object"); return FALSE; } obj->start = start; return TRUE; } /* Function: access_start_Gene(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * * Return [SOFT ] member variable start [int] * */ int access_start_Gene(Gene * obj) { if( obj == NULL) { warn("In accessor function start for object Gene, got a NULL object"); return 0; } return obj->start; } /* Function: replace_end_Gene(obj,end) * * Descrip: Replace member variable end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * Arg: end [OWNER] New value of the variable [int] * * Return [SOFT ] member variable end [boolean] * */ boolean replace_end_Gene(Gene * obj,int end) { if( obj == NULL) { warn("In replacement function end for object Gene, got a NULL object"); return FALSE; } obj->end = end; return TRUE; } /* Function: access_end_Gene(obj) * * Descrip: Access member variable end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * * Return [SOFT ] member variable end [int] * */ int access_end_Gene(Gene * obj) { if( obj == NULL) { warn("In accessor function end for object Gene, got a NULL object"); return 0; } return obj->end; } /* Function: replace_parent_Gene(obj,parent) * * Descrip: Replace member variable parent * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * Arg: parent [OWNER] New value of the variable [GenomicRegion *] * * Return [SOFT ] member variable parent [boolean] * */ boolean replace_parent_Gene(Gene * obj,GenomicRegion * parent) { if( obj == NULL) { warn("In replacement function parent for object Gene, got a NULL object"); return FALSE; } obj->parent = parent; return TRUE; } /* Function: access_parent_Gene(obj) * * Descrip: Access member variable parent * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * * Return [SOFT ] member variable parent [GenomicRegion *] * */ GenomicRegion * access_parent_Gene(Gene * obj) { if( obj == NULL) { warn("In accessor function parent for object Gene, got a NULL object"); return NULL; } return obj->parent; } /* Function: replace_genomic_Gene(obj,genomic) * * Descrip: Replace member variable genomic * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * Arg: genomic [OWNER] New value of the variable [Genomic *] * * Return [SOFT ] member variable genomic [boolean] * */ boolean replace_genomic_Gene(Gene * obj,Genomic * genomic) { if( obj == NULL) { warn("In replacement function genomic for object Gene, got a NULL object"); return FALSE; } obj->genomic = genomic; return TRUE; } /* Function: access_genomic_Gene(obj) * * Descrip: Access member variable genomic * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * * Return [SOFT ] member variable genomic [Genomic *] * */ Genomic * access_genomic_Gene(Gene * obj) { if( obj == NULL) { warn("In accessor function genomic for object Gene, got a NULL object"); return NULL; } return obj->genomic; } /* Function: access_transcript_Gene(obj,i) * * Descrip: Access members stored in the transcript list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [Gene *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [Transcript *] * */ Transcript * access_transcript_Gene(Gene * obj,int i) { if( obj == NULL) { warn("In accessor function transcript for object Gene, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function transcript for object Gene, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->transcript[i]; } /* Function: length_transcript_Gene(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [Gene *] * * Return [UNKN ] length of the list [int] * */ int length_transcript_Gene(Gene * obj) { if( obj == NULL) { warn("In length function transcript for object Gene, got a NULL object"); return -1; } return obj->len; } /* Function: replace_name_Gene(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * Arg: name [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable name [boolean] * */ boolean replace_name_Gene(Gene * obj,char * name) { if( obj == NULL) { warn("In replacement function name for object Gene, got a NULL object"); return FALSE; } obj->name = name; return TRUE; } /* Function: access_name_Gene(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * * Return [SOFT ] member variable name [char *] * */ char * access_name_Gene(Gene * obj) { if( obj == NULL) { warn("In accessor function name for object Gene, got a NULL object"); return NULL; } return obj->name; } /* Function: replace_bits_Gene(obj,bits) * * Descrip: Replace member variable bits * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * Arg: bits [OWNER] New value of the variable [double] * * Return [SOFT ] member variable bits [boolean] * */ boolean replace_bits_Gene(Gene * obj,double bits) { if( obj == NULL) { warn("In replacement function bits for object Gene, got a NULL object"); return FALSE; } obj->bits = bits; return TRUE; } /* Function: access_bits_Gene(obj) * * Descrip: Access member variable bits * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * * Return [SOFT ] member variable bits [double] * */ double access_bits_Gene(Gene * obj) { if( obj == NULL) { warn("In accessor function bits for object Gene, got a NULL object"); return 0; } return obj->bits; } /* Function: replace_seqname_Gene(obj,seqname) * * Descrip: Replace member variable seqname * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * Arg: seqname [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable seqname [boolean] * */ boolean replace_seqname_Gene(Gene * obj,char * seqname) { if( obj == NULL) { warn("In replacement function seqname for object Gene, got a NULL object"); return FALSE; } obj->seqname = seqname; return TRUE; } /* Function: access_seqname_Gene(obj) * * Descrip: Access member variable seqname * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * * Return [SOFT ] member variable seqname [char *] * */ char * access_seqname_Gene(Gene * obj) { if( obj == NULL) { warn("In accessor function seqname for object Gene, got a NULL object"); return NULL; } return obj->seqname; } /* Function: replace_ispseudo_Gene(obj,ispseudo) * * Descrip: Replace member variable ispseudo * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * Arg: ispseudo [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable ispseudo [boolean] * */ boolean replace_ispseudo_Gene(Gene * obj,boolean ispseudo) { if( obj == NULL) { warn("In replacement function ispseudo for object Gene, got a NULL object"); return FALSE; } obj->ispseudo = ispseudo; return TRUE; } /* Function: access_ispseudo_Gene(obj) * * Descrip: Access member variable ispseudo * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Gene *] * * Return [SOFT ] member variable ispseudo [boolean] * */ boolean access_ispseudo_Gene(Gene * obj) { if( obj == NULL) { warn("In accessor function ispseudo for object Gene, got a NULL object"); return FALSE; } return obj->ispseudo; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/gene.h0000644000175000001440000002572010670453712015733 0ustar philippusers#ifndef DYNAMITEgeneHEADERFILE #define DYNAMITEgeneHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #define GeneLISTLENGTH 16 #ifndef DYNAMITE_DEFINED_GenomicRegion typedef struct Wise2_GenomicRegion Wise2_GenomicRegion; #define GenomicRegion Wise2_GenomicRegion #define DYNAMITE_DEFINED_GenomicRegion #endif #ifndef DYNAMITE_DEFINED_Transcript typedef struct Wise2_Transcript Wise2_Transcript; #define Transcript Wise2_Transcript #define DYNAMITE_DEFINED_Transcript #endif /* Object Gene * * Descrip: Gene is the datastructure which represents a single * gene. At the moment this is considered to be a series * of transcripts (the first transcript being "canonical") * which are made from a certain start/stop region in * genomic DNA. * * The gene datastructure does not necessarily contain * any DNA sequence. When someone askes for the gene sequence, * via get_Genomic_from_Gene(), it first sees if there * is anything in the Genomic * 'cache'. If this is null, * it then looks at parent (the genomic region), and if * that is null, complains and returns null. Otherwise it * truncates its parent's dna in the correct way, places * the data structure into the genomic * cache, and returns * it. * * The name, bits and seqname have put into this datastructure * for convience of carrying around this information into some * of the gene prediction output formats. Probabaly * o they should be in transcript, not gene * o they shouldn't be here at all. * * * * */ struct Wise2_Gene { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start; int end; GenomicRegion * parent; /* may not be here */ Genomic * genomic; /* may not be here! */ Transcript ** transcript; int len;/* len for above transcript */ int maxlen; /* maxlen for above transcript */ char * name; /* ugly . Need a better system */ double bits; /* ditto... */ char * seqname; /* very bad! this is for keeping track of what sequence was used to make the gene */ boolean ispseudo; /* is a pseudogene or not */ } ; /* Gene defined */ #ifndef DYNAMITE_DEFINED_Gene typedef struct Wise2_Gene Wise2_Gene; #define Gene Wise2_Gene #define DYNAMITE_DEFINED_Gene #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: reversed_Gene(g) * * Descrip: is this gene reversed? * * * Arg: g [UNKN ] Undocumented argument [Gene *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_reversed_Gene(Gene * g); #define reversed_Gene Wise2_reversed_Gene /* Function: copy_Gene(g) * * Descrip: Makes a completely fresh copy of a * gene * * * Arg: g [UNKN ] Undocumented argument [Gene *] * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * Wise2_copy_Gene(Gene * g); #define copy_Gene Wise2_copy_Gene /* Function: is_simple_prediction_Gene(g) * * Descrip: Does this gene have * a single transcript * that transcript with translation start/end * at the ends * * * Arg: g [UNKN ] Undocumented argument [Gene *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_simple_prediction_Gene(Gene * g); #define is_simple_prediction_Gene Wise2_is_simple_prediction_Gene /* Function: get_Genomic_from_Gene(gene) * * Descrip: Gives back a Genomic sequence type * from a gene. * * * Arg: gene [READ ] gene to get Genomic from [Gene *] * * Return [SOFT ] Genomic DNA data structure [Genomic *] * */ Genomic * Wise2_get_Genomic_from_Gene(Gene * gene); #define get_Genomic_from_Gene Wise2_get_Genomic_from_Gene /* Function: read_EMBL_feature_Gene(buffer,maxlen,ifp) * * Descrip: Reads in an EMBL feature table. * * It expects to be passed a buffer with 'FT CDS'. * or 'FT mRNA' in it. It will then * use the buffer to read successive lines of the Feature table * until it comes to the next 'meta' feature line (ie, 3 place point). * * It will use functions in /embl module for the reading. * * * Arg: buffer [UNKN ] a string with FT CDS line in it [char *] * Arg: maxlen [UNKN ] length of the buffer [int] * Arg: ifp [UNKN ] file stream with the rest of the feature table in it [FILE *] * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * Wise2_read_EMBL_feature_Gene(char * buffer,int maxlen,FILE * ifp); #define read_EMBL_feature_Gene Wise2_read_EMBL_feature_Gene /* Function: write_Embl_FT_Gene(ge,key,ofp) * * Descrip: shows a embl feature table part * * * Arg: ge [UNKN ] Undocumented argument [Gene *] * Arg: key [UNKN ] Undocumented argument [char *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_write_Embl_FT_Gene(Gene * ge,char * key,FILE * ofp); #define write_Embl_FT_Gene Wise2_write_Embl_FT_Gene /* Function: show_pretty_Gene(ge,show_supporting,ofp) * * Descrip: Shows a gene in the biologically accepted form * * * Arg: ge [UNKN ] Undocumented argument [Gene *] * Arg: show_supporting [UNKN ] Undocumented argument [boolean] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_pretty_Gene(Gene * ge,boolean show_supporting,FILE * ofp); #define show_pretty_Gene Wise2_show_pretty_Gene /* Function: show_Gene(ge,ofp) * * Descrip: shows a gene in a vaguely human readable form * * * Arg: ge [UNKN ] Undocumented argument [Gene *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_Gene(Gene * ge,FILE * ofp); #define show_Gene Wise2_show_Gene /* Function: add_Gene(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Gene *] * Arg: add [OWNER] Object to add to the list [Transcript *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_Gene(Gene * obj,Transcript * add); #define add_Gene Wise2_add_Gene /* Function: flush_Gene(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Gene *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_Gene(Gene * obj); #define flush_Gene Wise2_flush_Gene /* Function: Gene_alloc_std(void) * * Descrip: Equivalent to Gene_alloc_len(GeneLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * Wise2_Gene_alloc_std(void); #define Gene_alloc_std Wise2_Gene_alloc_std /* Function: Gene_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * Wise2_Gene_alloc_len(int len); #define Gene_alloc_len Wise2_Gene_alloc_len /* Function: hard_link_Gene(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Gene *] * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * Wise2_hard_link_Gene(Gene * obj); #define hard_link_Gene Wise2_hard_link_Gene /* Function: Gene_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * Wise2_Gene_alloc(void); #define Gene_alloc Wise2_Gene_alloc /* Function: free_Gene(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Gene *] * * Return [UNKN ] Undocumented return value [Gene *] * */ Gene * Wise2_free_Gene(Gene * obj); #define free_Gene Wise2_free_Gene /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_genomic_Gene(Gene * obj,Genomic * genomic); #define replace_genomic_Gene Wise2_replace_genomic_Gene Genomic * Wise2_access_genomic_Gene(Gene * obj); #define access_genomic_Gene Wise2_access_genomic_Gene Transcript * Wise2_access_transcript_Gene(Gene * obj,int i); #define access_transcript_Gene Wise2_access_transcript_Gene int Wise2_length_transcript_Gene(Gene * obj); #define length_transcript_Gene Wise2_length_transcript_Gene boolean Wise2_replace_start_Gene(Gene * obj,int start); #define replace_start_Gene Wise2_replace_start_Gene boolean Wise2_replace_name_Gene(Gene * obj,char * name); #define replace_name_Gene Wise2_replace_name_Gene boolean Wise2_replace_end_Gene(Gene * obj,int end); #define replace_end_Gene Wise2_replace_end_Gene char * Wise2_access_name_Gene(Gene * obj); #define access_name_Gene Wise2_access_name_Gene boolean Wise2_replace_parent_Gene(Gene * obj,GenomicRegion * parent); #define replace_parent_Gene Wise2_replace_parent_Gene boolean Wise2_replace_bits_Gene(Gene * obj,double bits); #define replace_bits_Gene Wise2_replace_bits_Gene boolean Wise2_access_ispseudo_Gene(Gene * obj); #define access_ispseudo_Gene Wise2_access_ispseudo_Gene double Wise2_access_bits_Gene(Gene * obj); #define access_bits_Gene Wise2_access_bits_Gene int Wise2_access_end_Gene(Gene * obj); #define access_end_Gene Wise2_access_end_Gene boolean Wise2_replace_seqname_Gene(Gene * obj,char * seqname); #define replace_seqname_Gene Wise2_replace_seqname_Gene int Wise2_access_start_Gene(Gene * obj); #define access_start_Gene Wise2_access_start_Gene char * Wise2_access_seqname_Gene(Gene * obj); #define access_seqname_Gene Wise2_access_seqname_Gene GenomicRegion * Wise2_access_parent_Gene(Gene * obj); #define access_parent_Gene Wise2_access_parent_Gene boolean Wise2_replace_ispseudo_Gene(Gene * obj,boolean ispseudo); #define replace_ispseudo_Gene Wise2_replace_ispseudo_Gene void Wise2_swap_Gene(Transcript ** list,int i,int j) ; #define swap_Gene Wise2_swap_Gene void Wise2_qsort_Gene(Transcript ** list,int left,int right,int (*comp)(Transcript * ,Transcript * )); #define qsort_Gene Wise2_qsort_Gene void Wise2_sort_Gene(Gene * obj,int (*comp)(Transcript *, Transcript *)); #define sort_Gene Wise2_sort_Gene boolean Wise2_expand_Gene(Gene * obj,int len); #define expand_Gene Wise2_expand_Gene #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/dnamatrix.dy0000644000175000001440000001102507536706203017165 0ustar philippusers %{ #include "dyna.h" typedef enum NMaskType { NMaskType_BASE, NMaskType_VARIABLE, NMaskType_EXCLUDED, NMaskType_BANNED } NMaskType; #define DnaMatrix_MATCH(mat,one,two) (mat->score[one][two]) %} struct DnaProbMatrix Probability prob[5][5] struct DnaMatrix Score score[5][5] api object DnaMatrix des free_DnaMatrix endobject object DnaProbMatrix des free_DnaProbMatrix func flat_null_DnaProbMatrix endobject func identity_DnaMatrix func DnaProbMatrix_from_match func DnaMatrix_from_DnaProbMatrix endapi %{ #include "dnamatrix.h" %func Builds a CompMat mapping of a DnaMatrix %% CompMat * new_CompMat_from_DnaMatrix_flat(DnaMatrix * dm) { int i,j; CompMat * mat; mat = CompMat_alloc(); for(i=0;i<26;i++) { for(j=0;j<26;j++) { mat->comp[i][j] = NEGI; } } for(i=0;i<5;i++) { for(j=0;j<5;j++) { mat->comp[char_from_base(i)-'A'][char_from_base(j)-'A'] = dm->score[i][j]; } } return mat; } %func Makes a probability matrix from simple match/mismatch probabilities. %% DnaProbMatrix * DnaProbMatrix_from_match(Probability match,int nmask_type) { int i,j; DnaProbMatrix * out; Probability factor; switch (nmask_type ) { case NMaskType_BASE : factor = ((1.0 - match)/4.0); break; case NMaskType_VARIABLE : case NMaskType_EXCLUDED : case NMaskType_BANNED : factor = ((1.0 - match)/3.0); break; default : warn("No valid mask type. Ugh!"); return NULL; } out = DnaProbMatrix_alloc(); for(i=0;i<4;i++) { for(j=0;j<4;j++) { if( i == j ) { out->prob[i][j] = match; } else { out->prob[i][j] = factor; } } } for(i=0;i<5;i++) { switch (nmask_type ) { case NMaskType_BASE : if( i == BASE_N ) { out->prob[i][i] = match; } else { out->prob[BASE_N][i] = out->prob[i][BASE_N] = factor; } break; case NMaskType_VARIABLE : if( i == BASE_N ) { out->prob[i][i] = 0.25; } else { out->prob[BASE_N][i] = out->prob[i][BASE_N] = 0.25; } break; case NMaskType_EXCLUDED : if( i == BASE_N ) { out->prob[i][i] = 1.0; } else { out->prob[BASE_N][i] = out->prob[i][BASE_N] = 0.0; } break; case NMaskType_BANNED : out->prob[BASE_N][i] = out->prob[i][BASE_N] = 0.0; break; default : warn("No valid mask type. Ugh! Shouldn't be here. A BAD BAD bug!!!"); } } return out; } %func makes a odds of dpm via a 0.25 factor into each base. %% void flat_null_DnaProbMatrix(DnaProbMatrix * dpm) { int i,j; for(i=0;i<4;i++) { for(j=0;j<4;j++) { dpm->prob[i][j] = dpm->prob[i][j]/0.25; } } return; } %func Maps probabilities to scores %% DnaMatrix * DnaMatrix_from_DnaProbMatrix(DnaProbMatrix * dpm) { int i,j; DnaMatrix * out; out = DnaMatrix_alloc(); for(i=0;i<5;i++) for(j=0;j<5;j++) out->score[i][j] = Probability2Score(dpm->prob[i][j]); return out; } %func Simple view of DnaMatrix %% void show_DnaMatrix(DnaMatrix * dcm,FILE * ofp) { int i,j; for(i=0;i<5;i++) { for(j=0;j<5;j++) { fprintf(ofp,"%c %c - %d\n",char_from_base(i),char_from_base(j),dcm->score[i][j]); } } } %func Simple view of DnaProbMatrix %% void show_DnaProbMatrix(DnaProbMatrix * dpm,FILE * ofp) { int i,j; for(i=0;i<5;i++) { for(j=0;j<5;j++) { fprintf(ofp,"%c %c - %g\n",char_from_base(i),char_from_base(j),dpm->prob[i][j]); } } } %func Run-time checked that one and two are ok to pass into dm as bases %arg dm DnaMatrix to get score from one base of one sequence two base of the other sequence %% Score fail_safe_DnaMatrix_access(DnaMatrix * dm,base one,base two) { if( dm == NULL) { warn("Passing in a NULL dna matrix into fail_safe_DnaMatrix_access, can't get a score therefore"); return 0; } if( one < 0 || one > 4 || two < 0 || two > 4 ) { warn("In fail safe DnaMatrix access, trying to access a position [%d][%d] where this is meant to be 0-4",one,two); return 0; } return dm->score[one][two]; } %func makes an idenity matrix wth id_score on the leading diagonal and mismatch elsewhere. %arg id_score score of idenities mismatch score of mistmatches %% DnaMatrix * identity_DnaMatrix(Score id_score,Score mismatch) { DnaMatrix * out; int i; int j; out = DnaMatrix_alloc(); for(i=0;i<4;i++) for(j=i;j<4;j++) { if( i == j ) out->score[i][j] = id_score; else out->score[i][j] = out->score[j][i] = mismatch; } for(i=0;i<4;i++) { out->score[i][4] = out->score[4][i] = 0; } out->score[4][4] = 0; return out; } %} wise-2.4.1/src/dynlibsrc/dnamatrix.xs0000644000175000001440000000335210670453712017204 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::DnaMatrix Wise2_DnaMatrix * hard_link_DnaMatrix(obj) Wise2_DnaMatrix * obj CODE: RETVAL = Wise2_hard_link_DnaMatrix(obj); OUTPUT: RETVAL Wise2_DnaMatrix * alloc() CODE: RETVAL = Wise2_DnaMatrix_alloc(); OUTPUT: RETVAL Wise2_DnaMatrix * new(class) char * class PPCODE: Wise2_DnaMatrix * out; out = Wise2_DnaMatrix_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_DnaMatrix * obj CODE: Wise2_free_DnaMatrix(obj); MODULE = Wise2 PACKAGE = Wise2::DnaProbMatrix void flat_null_DnaProbMatrix(dpm) Wise2_DnaProbMatrix * dpm CODE: Wise2_flat_null_DnaProbMatrix(dpm); Wise2_DnaProbMatrix * hard_link_DnaProbMatrix(obj) Wise2_DnaProbMatrix * obj CODE: RETVAL = Wise2_hard_link_DnaProbMatrix(obj); OUTPUT: RETVAL Wise2_DnaProbMatrix * alloc() CODE: RETVAL = Wise2_DnaProbMatrix_alloc(); OUTPUT: RETVAL Wise2_DnaProbMatrix * new(class) char * class PPCODE: Wise2_DnaProbMatrix * out; out = Wise2_DnaProbMatrix_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_DnaProbMatrix * obj CODE: Wise2_free_DnaProbMatrix(obj); MODULE = Wise2 PACKAGE = Wise2 Wise2_DnaMatrix * identity_DnaMatrix(id_score,mismatch) Score id_score Score mismatch CODE: RETVAL = Wise2_identity_DnaMatrix(id_score,mismatch); OUTPUT: RETVAL Wise2_DnaProbMatrix * DnaProbMatrix_from_match(match,nmask_type) Probability match int nmask_type CODE: RETVAL = Wise2_DnaProbMatrix_from_match(match,nmask_type); OUTPUT: RETVAL Wise2_DnaMatrix * DnaMatrix_from_DnaProbMatrix(dpm) Wise2_DnaProbMatrix * dpm CODE: RETVAL = Wise2_DnaMatrix_from_DnaProbMatrix(dpm); OUTPUT: RETVAL wise-2.4.1/src/dynlibsrc/hsplookupthreaded.dy0000644000175000001440000004104410421430032020704 0ustar philippusers %{ #include "hsplookupscan.h" #include "hsphandler.h" #include "arrayseqlookup.h" #define MAX_HSP_THREADS 64 typedef struct ordered_pos_holder { Sequence * seq; int target_pos; int query_pos; int diagonal; } OrderedPosHolder; #define COMP_OPH(a,b) ((a.seq - b.seq) == 0 ? (a.diagonal - b.diagonal) == 0 ? (a.query_pos - b.query_pos) : (a.diagonal - b. diagonal) : (a.seq - b.seq)) #define COMP_OPH_POINTER(a,b) ((a->seq - b->seq) == 0 ? ((a->diagonal - b->diagonal) == 0 ? (a->query_pos - b->query_pos) : (a->diagonal - b->diagonal)) : (a->seq - b->seq)) %} struct HSPLookupThreadHolder HSPScanPara * p !link HSPmanager * hspm !link Sequence * seq !link HSPScanInterfacePara * para !link int start; int end; %{ #include "hsplookupthreaded.h" %func Makes the wrapper structure for threaded searches %% HSPScanInterface * new_threaded_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff,int threadno) { HSPScanInterface * out; HSPScanPara * p; assert(sli); assert(mat); out = HSPScanInterface_alloc(); p = HSPScanPara_alloc(); p->sli = hard_link_SeqLookupInterface(sli); p->mat = hard_link_CompMat(mat); p->drop_off = drop_off; p->score_cutoff = score_cutoff; p->threadno = threadno; out->data = (void*)p; out->free_data = simple_HSPScan_free; if( sli->lookup_array_head == NULL ) { fatal("Can't build threaded non array head structure"); } else { out->scan_query = one_off_threaded_HSPscan_scan_query_direct;; } return out; } %func Makes the wrapper structure for ordered searches %% HSPScanInterface * new_ordered_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff) { HSPScanInterface * out; HSPScanPara * p; assert(sli); assert(mat); out = HSPScanInterface_alloc(); p = HSPScanPara_alloc(); p->sli = hard_link_SeqLookupInterface(sli); p->mat = hard_link_CompMat(mat); p->drop_off = drop_off; p->score_cutoff = score_cutoff; out->data = (void*)p; out->free_data = simple_HSPScan_free; if( sli->lookup_array_head == NULL ) { fatal("Can't build threaded non array head structure"); } else { out->scan_query = one_off_ordered_HSPscan_scan_query_direct; } return out; } %func function which orders memory access pattern more sensibly %% LinearHSPmanager * one_off_ordered_HSPscan_scan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para) { LinearHSPmanager * out; LineariseHSPPara * hsp_para; HSPmanager * hspm; HSPScanPara * p = (HSPScanPara *)data; int * position; int * seqnumber; ArraySeqHead ** arrayseq; long int max_size = 0; long int current = 0; OrderedPosHolder * oph; long int current_oph = 0; long int max_oph = 0; OrderedPosHolder ** pos; int base[5]; int start_base; char * std_aa = "ACDEFGHIKLMNPQRSTVWY"; int score; int seqno[5]; int no; int aa; int used,skipped; int i,j,k; ArraySeqLookup * asl; #ifdef LINUX_TIMER struct timeval t1; struct timeval t2; struct timeval t3; struct timeval t4; struct timeval t5; struct timeval t6; struct timeval t7; #endif assert(p != NULL); assert(seq != NULL); assert(para->max_results > 0); #ifdef LINUX_TIMER gettimeofday(&t1,NULL); #endif /* we know how many positions we are going to fill */ /* each position will make 100 numbers */ max_size = seq->len * 100; position = calloc(max_size,sizeof(int)); seqnumber = calloc(max_size,sizeof(int)); arrayseq = calloc(max_size,sizeof(ArraySeqHead*)); current = 0; for(i=0,start_base=1;i<5;i++) { base[i] = start_base; start_base = start_base * 26; } for(i=0;ilen-5;i++) { position[current] = i; seqnumber[current] = seq_number_aa_5mer_client(seq->seq+i); current++; for(score=0,j=0;j<5;j++) { seqno[j] = base[j]*(toupper(seq->seq[i+j]-'A')); } for(j=0;j<5;j++) { for(aa=0;aa<20;aa++) { if( seq->seq[i+j] == std_aa[aa] ) { continue; } seqno[j] = base[j]*(std_aa[aa]-'A'); no= seqno[0]+seqno[1]+seqno[2]+seqno[3]+seqno[4]; position[current] = i; seqnumber[current] = no; current++; } } } #ifdef LINUX_TIMER gettimeofday(&t2,NULL); #endif /* start with max_size / 4 sequence positions */ max_oph = max_size /4; oph = calloc(max_oph,sizeof(OrderedPosHolder)); pos = calloc(max_oph,sizeof(OrderedPosHolder*)); current_oph = 0; qsort_seqnumber_array(position,seqnumber,0,current-1); #ifdef LINUX_TIMER gettimeofday(&t3,NULL); #endif /* now foreach position, fetch the right datastructure */ asl = (ArraySeqLookup*)p->sli->data; for(i=0;iarray[seqnumber[i]]; if( arrayseq[i] != NULL ) { for(k=0;kcurrent_pos;k++) { if( current_oph+1 >= max_oph ) { max_oph *= 2; oph = realloc(oph,max_oph*sizeof(OrderedPosHolder)); pos = realloc(pos,max_oph*sizeof(OrderedPosHolder*)); } pos[current_oph] = &(oph[current_oph]); oph[current_oph].seq = arrayseq[i]->units[k].seq; oph[current_oph].query_pos = position[i]; oph[current_oph].target_pos = arrayseq[i]->units[k].pos; oph[current_oph].diagonal = position[i] - arrayseq[i]->units[k].pos; current_oph++; } } } #ifdef LINUX_TIMER gettimeofday(&t4,NULL); #endif /* qsort_oph(oph,0,current_oph-1); */ fprintf(stderr,"About to sort oph pointers"); qsort_oph_pointer(pos,0,current_oph-1); fprintf(stderr,"retrieved array with %d elements\n",current_oph); #ifdef LINUX_TIMER gettimeofday(&t5,NULL); #endif hspm = new_HSPmanager(seq,p->mat,p->drop_off); /* we always add the first one */ used = 0; skipped = 0; add_pair_HSPmanager(hspm,oph[0].seq,oph[0].query_pos,oph[0].target_pos); for(i=1;iseq == pos[i]->seq || pos[i]->seq == pos[i+1]->seq) && (abs(pos[i-1]->diagonal - pos[i]->diagonal) < 5 || abs(pos[i]->diagonal - pos[i+1]->diagonal) < 5) ) { good_region = 1; } if( good_region == 0 || (pos[i-1]->seq == pos[i]->seq && pos[i-1]->diagonal == pos[i]->diagonal && abs(pos[i-1]->query_pos - pos[i]->query_pos) < 10) ) { skipped++; continue; } else { add_pair_HSPmanager(hspm,pos[i]->seq,pos[i]->query_pos,pos[i]->target_pos); used++; } } #ifdef LINUX_TIMER gettimeofday(&t6,NULL); #endif fprintf(stderr,"added %d HSPs skipped %d %f\n",used,skipped,(double)used/(double)(used+skipped)); /* make into a linear manager */ if( para->use_protein_heuristic == TRUE ) { out = new_LinearHSPmanager_heuristic_max(hspm,para->max_results); } else { out = new_LinearHSPmanager_flat(hspm); } free_HSPmanager(hspm); return out; } %func internal quicksort function on oph pointer arrays %% void qsort_oph_pointer(OrderedPosHolder ** pos,long int left,long int right) { OrderedPosHolder * temp; long int i,last; if( left >= right ) return; /* fprintf(stderr,"Entering sort at %d,%d\n",left,right); */ temp = pos[left]; pos[left] = pos[(left+right)/2]; pos[(left+right)/2] = temp; last = left; for(i=left+1;i <= right;i++) { if( COMP_OPH_POINTER(((pos[i])),((pos[left]))) < 0 ) { last++; temp = pos[last]; pos[last] = pos[i]; pos[i] = temp; } } temp = pos[last]; pos[last] = pos[left]; pos[left] = temp; qsort_oph_pointer(pos,left,last-1); qsort_oph_pointer(pos,last+1,right); } %func internal quicksort function for ordered access %% void qsort_oph(OrderedPosHolder * oph,int left,int right) { OrderedPosHolder temp; int i,last; if( left >= right ) return; temp = oph[left]; oph[left] = oph[(left+right)/2]; oph[(left+right)/2] = temp; last = left; for(i=left+1;i <= right;i++) { if( COMP_OPH(oph[i],oph[left]) < 0 ) { last++; temp = oph[last]; oph[last] = oph[i]; oph[i]= temp; } } temp = oph[last]; oph[last] = oph[left]; oph[left] = temp; qsort_oph(oph,left,last-1); qsort_oph(oph,last+1,right); } %func internal quicksort function for ordered access %% void qsort_seqnumber_array(int * position,int * seqnumber,int left,int right) { int i,last; int temp_pos; int temp_seqnumber; int t; if( left >= right ) return; temp_pos = position[left]; temp_seqnumber = seqnumber[left]; t = (left+right)/2; position[left] = position[t]; seqnumber[left] = seqnumber[t]; position[t] = temp_pos; seqnumber[t] = temp_seqnumber; last = left; for( i = left+1;i <= right;i++) { if( seqnumber[i] < seqnumber[left] ) { last++; temp_pos = position[last]; temp_seqnumber = seqnumber[last]; position[last] = position[i]; seqnumber[last] = seqnumber[i]; position[i] = temp_pos; seqnumber[i] = temp_seqnumber; } } /* swap final ones */ temp_pos = position[last]; temp_seqnumber = seqnumber[last]; position[last] = position[left]; seqnumber[last] = seqnumber[left]; position[left] = temp_pos; seqnumber[left] = temp_seqnumber; qsort_seqnumber_array(position,seqnumber,left,last-1); qsort_seqnumber_array(position,seqnumber,last+1,right); } %func Main threaded function %% LinearHSPmanager * one_off_threaded_HSPscan_scan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para) { LinearHSPmanager * out; LineariseHSPPara * hsp_para; HSPScanPara * p = (HSPScanPara *)data; int i; int block_size; int st; int err; HSPLookupThreadHolder thread_array[MAX_HSP_THREADS]; pthread_attr_t pat; pthread_t thread_pool[MAX_HSP_THREADS]; /* pre conditions */ assert(p != NULL); assert(seq != NULL); assert(para->max_results > 0); assert(p->threadno > 0); hsp_para = LineariseHSPPara_alloc(); hsp_para->verbosity = para->verbosity; hsp_para->max_size = para->max_results; hsp_para->min_score = para->min_hsp_score; hsp_para->width = para->hsp_link_width; hsp_para->tail = para->hsp_link_length; if( VERBOSITY_CHECK(1,para->verbosity) ) { info("processing sequence %s with threaded implementation",seq->name); } /* allocate common structures */ block_size = (int) seq->len / p->threadno; /* place into threads */ st = 0; for(i=0;ithreadno;i++) { thread_array[i].para = para; thread_array[i].p = p; thread_array[i].hspm = new_HSPmanager(seq,p->mat,p->drop_off); thread_array[i].start= st; st += block_size; thread_array[i].end = st; thread_array[i].seq = seq; } /* last thread ends at end */ thread_array[p->threadno-1].end = seq->len-5; /* launch threads with structure */ pthread_attr_init(&pat); #ifndef __sgi /* SGI can't set system scope ... */ #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #endif /* sgi */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY pthread_setconcurrency(p->threadno+1); #endif /* set concurrency */ for(i=0;ithreadno;i++) { if( (err = pthread_create(&(thread_pool[i]),&pat,hsp_thread_worker,(void *)(&(thread_array[i])))) ) fatal("Unable to make thread %d %d",i,err); } for(i=0;ithreadno;i++) { if( pthread_join(thread_pool[i],NULL) != 0 ) fatal("Unable to join a thread"); } /* now merge hsp's into one case */ for(i=1;ithreadno;i++) { merge_HSPmanager(thread_array[0].hspm,thread_array[i].hspm); free_HSPmanager(thread_array[i].hspm); } /* make into a linear manager */ if( para->use_protein_heuristic == TRUE ) { out = new_LinearHSPmanager_simple_heuristic(thread_array[0].hspm,hsp_para); } else { out = new_LinearHSPmanager_flat(thread_array[0].hspm); } free_HSPmanager(thread_array[0].hspm); return out; } %func function to merge one HSPmanager into another one %% boolean merge_HSPmanager(HSPmanager * from,HSPmanager * to) { g_hash_table_foreach(from->target_hash,merge_HSPmanager_foreach,to); } %func internal function to merge HSPmanagers %% void merge_HSPmanager_foreach(gpointer key,gpointer value,gpointer user_data) { HSPmanager * hspm = (HSPmanager *) user_data; HSPset * s = (HSPset *) value; HSPset * master; int i,j; int seen; /* if there is no sequence, we can just add the set for this target */ if( (master = g_hash_table_lookup(hspm->target_hash,(gpointer)s->hsp[0]->target)) == NULL ) { g_hash_table_insert(hspm->target_hash,(gpointer)s->hsp[0]->target,hard_link_HSPset(s)); return; } /* this target is already in, must check each case */ for(i=0;ilen;i++) { seen = 0; for(j=0;j < master->len;j++) { if( s->hsp[i]->query_start == master->hsp[j]->query_start && s->hsp[i]->target_start == master->hsp[j]->target_start ) { seen = 1; break; } } if( seen == 0 ) { /* this HSP is new */ add_HSPset(master,hard_link_HSP(s->hsp[i])); } else { /* do nothing */ } } return; } %func thread worker %% void * hsp_thread_worker(void * ptr) { int i,j,k; int score; int aa; int jj; int aa2; int seqno[5]; int no; char newseq[5]; int base[5]; int start_base; int self_score[5]; int total_score; int current_score; HSPLookupThreadHolder * h = (HSPLookupThreadHolder*)ptr; char * std_aa = "ACDEFGHIKLMNPQRSTVWY"; HSPScanPara * p; HSPScanInterfacePara * para; Sequence * seq; ArraySeqHead * head; p = h->p; seq = h->seq; para = h->para; assert(p != NULL); assert(seq != NULL); assert(para != NULL); for(i=0,start_base=1;i<5;i++) { base[i] = start_base; start_base = start_base * 26; } for(i=h->start;iend;i++) { auto ArraySeqLookup * asl; asl = (ArraySeqLookup *)p->sli->data; if( VERBOSITY_CHECK(2,para->verbosity) && i%50 == 0 ) { info("Scanning (threaded) %s at position %d with %d hits",seq->name,i,h->hspm->hsp_count); } head = arrayhead_direct_lookup(p->sli->data,seq_number_aa_5mer_client(seq->seq+i)); if( VERBOSITY_CHECK(9,para->verbosity) ) { info("retrieved (threaded) %s at position %d with %d hits",seq->name,i,h->hspm->hsp_count); } if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { for(k=0;kcurrent_pos;k++) { if( add_pair_HSPmanager(h->hspm,head->units[k].seq,i,head->units[k].pos) == TRUE ) { ; } } } total_score = 0; for(score=0,j=0;j<5;j++) { seqno[j] = base[j]*(toupper(seq->seq[i+j])-'A'); self_score[j] = p->mat->comp[toupper(seq->seq[i+j])-'A'][toupper(seq->seq[i+j])-'A']; total_score += self_score[j]; } for(j=0;j<5;j++) { for(jj=1;jj<5;jj+=2) { for(aa=0;aa<20;aa++) { for(aa2=0;aa2<20;aa2++) { if( seq->seq[i+j] == std_aa[aa] ) { continue; } current_score = total_score; current_score -= (self_score[j] - p->mat->comp[toupper(seq->seq[i+j])-'A'][std_aa[aa]-'A']); current_score -= (self_score[jj] - p->mat->comp[toupper(seq->seq[i+jj])-'A'][std_aa[aa2]-'A']); if( current_score < para->min_word_score ) { continue; } else { /* fprintf(stderr,"Handling %d,%d amino acid %d,%d score %d\n",j,jj,aa,aa2,current_score); */ } seqno[j] = base[j]*(std_aa[aa]-'A'); seqno[jj] = base[jj]*(std_aa[aa2]-'A'); no= seqno[0]+seqno[1]+seqno[2]+seqno[3]+seqno[4]; head = (*p->sli->lookup_array_head)(p->sli->data,no); if( head != NULL ) { if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { if( VERBOSITY_CHECK(7,para->verbosity) ) { info("position %d hit direct over filled position, %d vs hard %d, low %d",i,head->current_pos,para->numb_level,para->low_numb); } continue; } for(k=0;kcurrent_pos;k++) { if( VERBOSITY_CHECK(9,para->verbosity) ) { info("one off... (threaded) %s at position %d with %d hits",seq->name,i,h->hspm->hsp_count); } add_pair_HSPmanager(h->hspm,head->units[k].seq,i,head->units[k].pos) ; } } seqno[j] = base[j]*(toupper(seq->seq[i+j]-'A')); seqno[jj] = base[jj]*(toupper(seq->seq[i+jj]-'A')); newseq[j] = seq->seq[i+j]; newseq[jj] = seq->seq[i+jj]; } /* each second aa */ } /* each first aa */ } /* each j position */ } /* each jj position */ } /* each i position */ return NULL; } %} wise-2.4.1/src/dynlibsrc/transcript.c0000644000175000001440000011056110670453713017200 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "transcript.h" /* Function: copy_Transcript(t) * * Descrip: Makes a completely new copy * of the transcript * * * Arg: t [UNKN ] Undocumented argument [Transcript *] * * Return [UNKN ] Undocumented return value [Transcript *] * */ # line 75 "transcript.dy" Transcript * copy_Transcript(Transcript * t) { Transcript * out; Exon * temp; int i; out = Transcript_alloc(); for(i=0;iex_len;i++) { temp = Exon_alloc(); temp->start = t->exon[i]->start; temp->end = t->exon[i]->end; add_ex_Transcript(out,temp); } for(i=0;ilen;i++) { add_Transcript(out,copy_Translation(t->translation[i])); } return out; } /* Function: get_cDNA_from_Transcript(trs) * * Descrip: gets the cDNA associated with this transcript, * if necessary, building it from the exon information * provided. * * returns a soft-linked object. If you want to ensure * that this cDNA object remains in memory use * /hard_link_cDNA on the object. * * * Arg: trs [READ ] transcript to get cDNA from [Transcript *] * * Return [SOFT ] cDNA of the transcript [cDNA *] * */ # line 109 "transcript.dy" cDNA * get_cDNA_from_Transcript(Transcript * trs) { Genomic * gn; Sequence * base; int i; char buffer[64]; if( trs->cDNA != NULL) return trs->cDNA; if( trs->parent == NULL ) { warn("Cannot get cDNA, as no parent Gene!"); return NULL; } if ( (gn = get_Genomic_from_Gene(trs->parent)) == NULL ) { warn("Cannot get cDNA, as cannot get Genomic sequence from Gene"); return NULL; } base = Sequence_alloc(); sprintf(buffer,"%s.sp",Genomic_name(gn)); base->name = stringalloc(buffer); base->seq = ckcalloc(length_Transcript(trs)+1,sizeof(char)); base->seq[0]='\0'; for(i=0;iex_len;i++) { strncat(base->seq,gn->baseseq->seq+trs->exon[i]->start,trs->exon[i]->end-trs->exon[i]->start); } make_len_type_Sequence(base); base->type = SEQUENCE_CDNA; trs->cDNA = cDNA_from_Sequence(base); return trs->cDNA; } /* Function: length_Transcript(tr) * * Descrip: returns the length by looking at the * exon lengths * * * Arg: tr [UNKN ] Undocumented argument [Transcript *] * * Return [UNKN ] Undocumented return value [int] * */ # line 151 "transcript.dy" int length_Transcript(Transcript * tr) { int len = 0; int i; for(i=0;iex_len;i++) { len += tr->exon[i]->end - tr->exon[i]->start; } return len; } /* Function: show_Transcript(tr,ofp) * * Descrip: shows a transcript in vaguely human form * * * Arg: tr [UNKN ] Undocumented argument [Transcript *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 166 "transcript.dy" void show_Transcript(Transcript * tr,FILE * ofp) { int i; int k; SupportingFeature * sf; for(i=0;iex_len;i++) { fprintf(ofp,"Exon %d-%d\n",tr->exon[i]->start,tr->exon[i]->end); /* for(k=0;kexon[i]->len;k++) { sf = tr->exon[i]->sf[k]; fprintf(ofp," SF %d %d %d %d\n",sf->start,sf->end,sf->hstart,sf->hend); } */ } for(i=0;ilen;i++) { show_Translation(tr->translation[i],ofp); } } # line 146 "transcript.c" /* Function: hard_link_SupportingFeature(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SupportingFeature *] * * Return [UNKN ] Undocumented return value [SupportingFeature *] * */ SupportingFeature * hard_link_SupportingFeature(SupportingFeature * obj) { if( obj == NULL ) { warn("Trying to hard link to a SupportingFeature object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SupportingFeature_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SupportingFeature *] * */ SupportingFeature * SupportingFeature_alloc(void) { SupportingFeature * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SupportingFeature *) ckalloc (sizeof(SupportingFeature))) == NULL) { warn("SupportingFeature_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->end = 0; out->hstart = 0; out->hend = 0; out->hstrand = 0; out->hid = NULL; return out; } /* Function: free_SupportingFeature(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SupportingFeature *] * * Return [UNKN ] Undocumented return value [SupportingFeature *] * */ SupportingFeature * free_SupportingFeature(SupportingFeature * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SupportingFeature obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->hid != NULL) ckfree(obj->hid); ckfree(obj); return NULL; } /* Function: swap_Exon(list,i,j) * * Descrip: swap function: an internal for qsort_Exon * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [SupportingFeature **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Exon(SupportingFeature ** list,int i,int j) { SupportingFeature * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Exon(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Exon which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [SupportingFeature **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Exon(SupportingFeature ** list,int left,int right,int (*comp)(SupportingFeature * ,SupportingFeature * )) { int i,last; if( left >= right ) return; swap_Exon(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Exon (list,++last,i); } swap_Exon (list,left,last); qsort_Exon(list,left,last-1,comp); qsort_Exon(list,last+1,right,comp); } /* Function: sort_Exon(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Exon * * * Arg: obj [UNKN ] Object containing list [Exon *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Exon(Exon * obj,int (*comp)(SupportingFeature *, SupportingFeature *)) { qsort_Exon(obj->sf,0,obj->len-1,comp); return; } /* Function: expand_Exon(obj,len) * * Descrip: Really an internal function for add_Exon * * * Arg: obj [UNKN ] Object which contains the list [Exon *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Exon(Exon * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Exon called with no need"); return TRUE; } if( (obj->sf = (SupportingFeature ** ) ckrealloc (obj->sf,sizeof(SupportingFeature *)*len)) == NULL) { warn("ckrealloc failed for expand_Exon, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Exon(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Exon *] * Arg: add [OWNER] Object to add to the list [SupportingFeature *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Exon(Exon * obj,SupportingFeature * add) { if( obj->len >= obj->maxlen) { if( expand_Exon(obj,obj->len + ExonLISTLENGTH) == FALSE) return FALSE; } obj->sf[obj->len++]=add; return TRUE; } /* Function: flush_Exon(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Exon *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Exon(Exon * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->sf[i] != NULL) { free_SupportingFeature(obj->sf[i]); obj->sf[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: Exon_alloc_std(void) * * Descrip: Equivalent to Exon_alloc_len(ExonLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Exon *] * */ Exon * Exon_alloc_std(void) { return Exon_alloc_len(ExonLISTLENGTH); } /* Function: Exon_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Exon *] * */ Exon * Exon_alloc_len(int len) { Exon * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Exon_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->sf = (SupportingFeature ** ) ckcalloc (len,sizeof(SupportingFeature *))) == NULL) { warn("Warning, ckcalloc failed in Exon_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_Exon(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Exon *] * * Return [UNKN ] Undocumented return value [Exon *] * */ Exon * hard_link_Exon(Exon * obj) { if( obj == NULL ) { warn("Trying to hard link to a Exon object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Exon_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Exon *] * */ Exon * Exon_alloc(void) { Exon * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Exon *) ckalloc (sizeof(Exon))) == NULL) { warn("Exon_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->end = 0; out->used = FALSE; out->score = 0; out->sf = NULL; out->len = out->maxlen = 0; out->phase = -1; return out; } /* Function: free_Exon(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Exon *] * * Return [UNKN ] Undocumented return value [Exon *] * */ Exon * free_Exon(Exon * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Exon obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->sf != NULL) { for(i=0;ilen;i++) { if( obj->sf[i] != NULL) free_SupportingFeature(obj->sf[i]); } ckfree(obj->sf); } ckfree(obj); return NULL; } /* Function: swap_ex_Transcript(list,i,j) * * Descrip: swap function: an internal for qsort_ex_Transcript * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Exon **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ex_Transcript(Exon ** list,int i,int j) { Exon * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ex_Transcript(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ex_Transcript which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Exon **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ex_Transcript(Exon ** list,int left,int right,int (*comp)(Exon * ,Exon * )) { int i,last; if( left >= right ) return; swap_ex_Transcript(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ex_Transcript (list,++last,i); } swap_ex_Transcript (list,left,last); qsort_ex_Transcript(list,left,last-1,comp); qsort_ex_Transcript(list,last+1,right,comp); } /* Function: sort_ex_Transcript(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ex_Transcript * * * Arg: obj [UNKN ] Object containing list [Transcript *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ex_Transcript(Transcript * obj,int (*comp)(Exon *, Exon *)) { qsort_ex_Transcript(obj->exon,0,obj->ex_len-1,comp); return; } /* Function: expand_ex_Transcript(obj,len) * * Descrip: Really an internal function for add_ex_Transcript * * * Arg: obj [UNKN ] Object which contains the list [Transcript *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ex_Transcript(Transcript * obj,int len) { if( obj->ex_maxlen > obj->ex_len ) { warn("expand_Transcriptex_ called with no need"); return TRUE; } if( (obj->exon = (Exon ** ) ckrealloc (obj->exon,sizeof(Exon *)*len)) == NULL) { warn("ckrealloc failed for expand_Transcript, returning FALSE"); return FALSE; } obj->ex_maxlen = len; return TRUE; } /* Function: add_ex_Transcript(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Transcript *] * Arg: add [OWNER] Object to add to the list [Exon *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ex_Transcript(Transcript * obj,Exon * add) { if( obj->ex_len >= obj->ex_maxlen) { if( expand_ex_Transcript(obj,obj->ex_len + TranscriptLISTLENGTH) == FALSE) return FALSE; } obj->exon[obj->ex_len++]=add; return TRUE; } /* Function: flush_ex_Transcript(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Transcript *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ex_Transcript(Transcript * obj) { int i; for(i=0;iex_len;i++) { /*for i over list length*/ if( obj->exon[i] != NULL) { free_Exon(obj->exon[i]); obj->exon[i] = NULL; } } /* end of for i over list length */ obj->ex_len = 0; return i; } /* Function: swap_Transcript(list,i,j) * * Descrip: swap function: an internal for qsort_Transcript * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Translation **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Transcript(Translation ** list,int i,int j) { Translation * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Transcript(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Transcript which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Translation **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Transcript(Translation ** list,int left,int right,int (*comp)(Translation * ,Translation * )) { int i,last; if( left >= right ) return; swap_Transcript(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Transcript (list,++last,i); } swap_Transcript (list,left,last); qsort_Transcript(list,left,last-1,comp); qsort_Transcript(list,last+1,right,comp); } /* Function: sort_Transcript(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Transcript * * * Arg: obj [UNKN ] Object containing list [Transcript *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Transcript(Transcript * obj,int (*comp)(Translation *, Translation *)) { qsort_Transcript(obj->translation,0,obj->len-1,comp); return; } /* Function: expand_Transcript(obj,len) * * Descrip: Really an internal function for add_Transcript * * * Arg: obj [UNKN ] Object which contains the list [Transcript *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Transcript(Transcript * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Transcript called with no need"); return TRUE; } if( (obj->translation = (Translation ** ) ckrealloc (obj->translation,sizeof(Translation *)*len)) == NULL) { warn("ckrealloc failed for expand_Transcript, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Transcript(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Transcript *] * Arg: add [OWNER] Object to add to the list [Translation *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Transcript(Transcript * obj,Translation * add) { if( obj->len >= obj->maxlen) { if( expand_Transcript(obj,obj->len + TranscriptLISTLENGTH) == FALSE) return FALSE; } obj->translation[obj->len++]=add; return TRUE; } /* Function: flush_Transcript(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Transcript *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Transcript(Transcript * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->translation[i] != NULL) { free_Translation(obj->translation[i]); obj->translation[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: Transcript_alloc_std(void) * * Descrip: Equivalent to Transcript_alloc_len(TranscriptLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Transcript *] * */ Transcript * Transcript_alloc_std(void) { return Transcript_alloc_len(TranscriptLISTLENGTH); } /* Function: Transcript_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Transcript *] * */ Transcript * Transcript_alloc_len(int len) { Transcript * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Transcript_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->exon = (Exon ** ) ckcalloc (len,sizeof(Exon *))) == NULL) { warn("Warning, ckcalloc failed in Transcript_alloc_len"); return NULL; } out->ex_len = 0; out->ex_maxlen = len; if((out->translation = (Translation ** ) ckcalloc (len,sizeof(Translation *))) == NULL) { warn("Warning, ckcalloc failed in Transcript_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_Transcript(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Transcript *] * * Return [UNKN ] Undocumented return value [Transcript *] * */ Transcript * hard_link_Transcript(Transcript * obj) { if( obj == NULL ) { warn("Trying to hard link to a Transcript object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Transcript_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Transcript *] * */ Transcript * Transcript_alloc(void) { Transcript * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Transcript *) ckalloc (sizeof(Transcript))) == NULL) { warn("Transcript_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->exon = NULL; out->ex_len = out->ex_maxlen = 0; out->translation = NULL; out->len = out->maxlen = 0; out->cDNA = NULL; return out; } /* Function: free_Transcript(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Transcript *] * * Return [UNKN ] Undocumented return value [Transcript *] * */ Transcript * free_Transcript(Transcript * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Transcript obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->exon != NULL) { for(i=0;iex_len;i++) { if( obj->exon[i] != NULL) free_Exon(obj->exon[i]); } ckfree(obj->exon); } /* obj->parent is linked in */ if( obj->translation != NULL) { for(i=0;ilen;i++) { if( obj->translation[i] != NULL) free_Translation(obj->translation[i]); } ckfree(obj->translation); } if( obj->cDNA != NULL) free_cDNA(obj->cDNA); ckfree(obj); return NULL; } /* Function: replace_start_Exon(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Exon *] * Arg: start [OWNER] New value of the variable [int] * * Return [SOFT ] member variable start [boolean] * */ boolean replace_start_Exon(Exon * obj,int start) { if( obj == NULL) { warn("In replacement function start for object Exon, got a NULL object"); return FALSE; } obj->start = start; return TRUE; } /* Function: access_start_Exon(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Exon *] * * Return [SOFT ] member variable start [int] * */ int access_start_Exon(Exon * obj) { if( obj == NULL) { warn("In accessor function start for object Exon, got a NULL object"); return 0; } return obj->start; } /* Function: replace_end_Exon(obj,end) * * Descrip: Replace member variable end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Exon *] * Arg: end [OWNER] New value of the variable [int] * * Return [SOFT ] member variable end [boolean] * */ boolean replace_end_Exon(Exon * obj,int end) { if( obj == NULL) { warn("In replacement function end for object Exon, got a NULL object"); return FALSE; } obj->end = end; return TRUE; } /* Function: access_end_Exon(obj) * * Descrip: Access member variable end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Exon *] * * Return [SOFT ] member variable end [int] * */ int access_end_Exon(Exon * obj) { if( obj == NULL) { warn("In accessor function end for object Exon, got a NULL object"); return 0; } return obj->end; } /* Function: replace_used_Exon(obj,used) * * Descrip: Replace member variable used * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Exon *] * Arg: used [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable used [boolean] * */ boolean replace_used_Exon(Exon * obj,boolean used) { if( obj == NULL) { warn("In replacement function used for object Exon, got a NULL object"); return FALSE; } obj->used = used; return TRUE; } /* Function: access_used_Exon(obj) * * Descrip: Access member variable used * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Exon *] * * Return [SOFT ] member variable used [boolean] * */ boolean access_used_Exon(Exon * obj) { if( obj == NULL) { warn("In accessor function used for object Exon, got a NULL object"); return FALSE; } return obj->used; } /* Function: replace_score_Exon(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Exon *] * Arg: score [OWNER] New value of the variable [double] * * Return [SOFT ] member variable score [boolean] * */ boolean replace_score_Exon(Exon * obj,double score) { if( obj == NULL) { warn("In replacement function score for object Exon, got a NULL object"); return FALSE; } obj->score = score; return TRUE; } /* Function: access_score_Exon(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Exon *] * * Return [SOFT ] member variable score [double] * */ double access_score_Exon(Exon * obj) { if( obj == NULL) { warn("In accessor function score for object Exon, got a NULL object"); return 0; } return obj->score; } /* Function: access_sf_Exon(obj,i) * * Descrip: Access members stored in the sf list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [Exon *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [SupportingFeature *] * */ SupportingFeature * access_sf_Exon(Exon * obj,int i) { if( obj == NULL) { warn("In accessor function sf for object Exon, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function sf for object Exon, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->sf[i]; } /* Function: length_sf_Exon(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [Exon *] * * Return [UNKN ] length of the list [int] * */ int length_sf_Exon(Exon * obj) { if( obj == NULL) { warn("In length function sf for object Exon, got a NULL object"); return -1; } return obj->len; } /* Function: replace_phase_Exon(obj,phase) * * Descrip: Replace member variable phase * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Exon *] * Arg: phase [OWNER] New value of the variable [int] * * Return [SOFT ] member variable phase [boolean] * */ boolean replace_phase_Exon(Exon * obj,int phase) { if( obj == NULL) { warn("In replacement function phase for object Exon, got a NULL object"); return FALSE; } obj->phase = phase; return TRUE; } /* Function: access_phase_Exon(obj) * * Descrip: Access member variable phase * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Exon *] * * Return [SOFT ] member variable phase [int] * */ int access_phase_Exon(Exon * obj) { if( obj == NULL) { warn("In accessor function phase for object Exon, got a NULL object"); return 0; } return obj->phase; } /* Function: access_exon_Transcript(obj,i) * * Descrip: Access members stored in the exon list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [Transcript *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [Exon *] * */ Exon * access_exon_Transcript(Transcript * obj,int i) { if( obj == NULL) { warn("In accessor function exon for object Transcript, got a NULL object"); return NULL; } if( obj->ex_len <= i ) { warn("In accessor function exon for object Transcript, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->exon[i]; } /* Function: length_exon_Transcript(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [Transcript *] * * Return [UNKN ] length of the list [int] * */ int length_exon_Transcript(Transcript * obj) { if( obj == NULL) { warn("In length function exon for object Transcript, got a NULL object"); return -1; } return obj->ex_len; } /* Function: replace_parent_Transcript(obj,parent) * * Descrip: Replace member variable parent * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Transcript *] * Arg: parent [OWNER] New value of the variable [Gene *] * * Return [SOFT ] member variable parent [boolean] * */ boolean replace_parent_Transcript(Transcript * obj,Gene * parent) { if( obj == NULL) { warn("In replacement function parent for object Transcript, got a NULL object"); return FALSE; } obj->parent = parent; return TRUE; } /* Function: access_parent_Transcript(obj) * * Descrip: Access member variable parent * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Transcript *] * * Return [SOFT ] member variable parent [Gene *] * */ Gene * access_parent_Transcript(Transcript * obj) { if( obj == NULL) { warn("In accessor function parent for object Transcript, got a NULL object"); return NULL; } return obj->parent; } /* Function: access_translation_Transcript(obj,i) * * Descrip: Access members stored in the translation list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [Transcript *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [Translation *] * */ Translation * access_translation_Transcript(Transcript * obj,int i) { if( obj == NULL) { warn("In accessor function translation for object Transcript, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function translation for object Transcript, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->translation[i]; } /* Function: length_translation_Transcript(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [Transcript *] * * Return [UNKN ] length of the list [int] * */ int length_translation_Transcript(Transcript * obj) { if( obj == NULL) { warn("In length function translation for object Transcript, got a NULL object"); return -1; } return obj->len; } /* Function: replace_cDNA_Transcript(obj,cDNA) * * Descrip: Replace member variable cDNA * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Transcript *] * Arg: cDNA [OWNER] New value of the variable [cDNA *] * * Return [SOFT ] member variable cDNA [boolean] * */ boolean replace_cDNA_Transcript(Transcript * obj,cDNA * cDNA) { if( obj == NULL) { warn("In replacement function cDNA for object Transcript, got a NULL object"); return FALSE; } obj->cDNA = cDNA; return TRUE; } /* Function: access_cDNA_Transcript(obj) * * Descrip: Access member variable cDNA * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Transcript *] * * Return [SOFT ] member variable cDNA [cDNA *] * */ cDNA * access_cDNA_Transcript(Transcript * obj) { if( obj == NULL) { warn("In accessor function cDNA for object Transcript, got a NULL object"); return NULL; } return obj->cDNA; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/transcript.h0000644000175000001440000003612510670453713017210 0ustar philippusers#ifndef DYNAMITEtranscriptHEADERFILE #define DYNAMITEtranscriptHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #define TranscriptLISTLENGTH 32 #define ExonLISTLENGTH 128 struct Wise2_SupportingFeature { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start; /* in exon coordinates */ int end; /* in exon coordinates */ int hstart; int hend; int hstrand; char* hid; } ; /* SupportingFeature defined */ #ifndef DYNAMITE_DEFINED_SupportingFeature typedef struct Wise2_SupportingFeature Wise2_SupportingFeature; #define SupportingFeature Wise2_SupportingFeature #define DYNAMITE_DEFINED_SupportingFeature #endif struct Wise2_Exon { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start; int end; boolean used; /* used by some prediction programs etc */ double score; SupportingFeature ** sf; int len;/* len for above sf */ int maxlen; /* maxlen for above sf */ int phase; } ; /* Exon defined */ #ifndef DYNAMITE_DEFINED_Exon typedef struct Wise2_Exon Wise2_Exon; #define Exon Wise2_Exon #define DYNAMITE_DEFINED_Exon #endif #ifndef DYNAMITE_DEFINED_Translation typedef struct Wise2_Translation Wise2_Translation; #define Translation Wise2_Translation #define DYNAMITE_DEFINED_Translation #endif #ifndef DYNAMITE_DEFINED_Gene typedef struct Wise2_Gene Wise2_Gene; #define Gene Wise2_Gene #define DYNAMITE_DEFINED_Gene #endif /* Object Transcript * * Descrip: No Description * */ struct Wise2_Transcript { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Exon ** exon; int ex_len; /* len for above exon */ int ex_maxlen; /* maxlen for above exon */ Gene * parent; Translation ** translation; int len;/* len for above translation */ int maxlen; /* maxlen for above translation */ cDNA * cDNA; /* may not be here! */ } ; /* Transcript defined */ #ifndef DYNAMITE_DEFINED_Transcript typedef struct Wise2_Transcript Wise2_Transcript; #define Transcript Wise2_Transcript #define DYNAMITE_DEFINED_Transcript #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: copy_Transcript(t) * * Descrip: Makes a completely new copy * of the transcript * * * Arg: t [UNKN ] Undocumented argument [Transcript *] * * Return [UNKN ] Undocumented return value [Transcript *] * */ Transcript * Wise2_copy_Transcript(Transcript * t); #define copy_Transcript Wise2_copy_Transcript /* Function: get_cDNA_from_Transcript(trs) * * Descrip: gets the cDNA associated with this transcript, * if necessary, building it from the exon information * provided. * * returns a soft-linked object. If you want to ensure * that this cDNA object remains in memory use * /hard_link_cDNA on the object. * * * Arg: trs [READ ] transcript to get cDNA from [Transcript *] * * Return [SOFT ] cDNA of the transcript [cDNA *] * */ cDNA * Wise2_get_cDNA_from_Transcript(Transcript * trs); #define get_cDNA_from_Transcript Wise2_get_cDNA_from_Transcript /* Function: length_Transcript(tr) * * Descrip: returns the length by looking at the * exon lengths * * * Arg: tr [UNKN ] Undocumented argument [Transcript *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_length_Transcript(Transcript * tr); #define length_Transcript Wise2_length_Transcript /* Function: show_Transcript(tr,ofp) * * Descrip: shows a transcript in vaguely human form * * * Arg: tr [UNKN ] Undocumented argument [Transcript *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_Transcript(Transcript * tr,FILE * ofp); #define show_Transcript Wise2_show_Transcript /* Function: hard_link_SupportingFeature(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SupportingFeature *] * * Return [UNKN ] Undocumented return value [SupportingFeature *] * */ SupportingFeature * Wise2_hard_link_SupportingFeature(SupportingFeature * obj); #define hard_link_SupportingFeature Wise2_hard_link_SupportingFeature /* Function: SupportingFeature_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SupportingFeature *] * */ SupportingFeature * Wise2_SupportingFeature_alloc(void); #define SupportingFeature_alloc Wise2_SupportingFeature_alloc /* Function: free_SupportingFeature(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SupportingFeature *] * * Return [UNKN ] Undocumented return value [SupportingFeature *] * */ SupportingFeature * Wise2_free_SupportingFeature(SupportingFeature * obj); #define free_SupportingFeature Wise2_free_SupportingFeature /* Function: add_Exon(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Exon *] * Arg: add [OWNER] Object to add to the list [SupportingFeature *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_Exon(Exon * obj,SupportingFeature * add); #define add_Exon Wise2_add_Exon /* Function: flush_Exon(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Exon *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_Exon(Exon * obj); #define flush_Exon Wise2_flush_Exon /* Function: Exon_alloc_std(void) * * Descrip: Equivalent to Exon_alloc_len(ExonLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Exon *] * */ Exon * Wise2_Exon_alloc_std(void); #define Exon_alloc_std Wise2_Exon_alloc_std /* Function: Exon_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Exon *] * */ Exon * Wise2_Exon_alloc_len(int len); #define Exon_alloc_len Wise2_Exon_alloc_len /* Function: hard_link_Exon(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Exon *] * * Return [UNKN ] Undocumented return value [Exon *] * */ Exon * Wise2_hard_link_Exon(Exon * obj); #define hard_link_Exon Wise2_hard_link_Exon /* Function: Exon_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Exon *] * */ Exon * Wise2_Exon_alloc(void); #define Exon_alloc Wise2_Exon_alloc /* Function: free_Exon(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Exon *] * * Return [UNKN ] Undocumented return value [Exon *] * */ Exon * Wise2_free_Exon(Exon * obj); #define free_Exon Wise2_free_Exon /* Function: add_ex_Transcript(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Transcript *] * Arg: add [OWNER] Object to add to the list [Exon *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_ex_Transcript(Transcript * obj,Exon * add); #define add_ex_Transcript Wise2_add_ex_Transcript /* Function: flush_ex_Transcript(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Transcript *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_ex_Transcript(Transcript * obj); #define flush_ex_Transcript Wise2_flush_ex_Transcript /* Function: add_Transcript(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Transcript *] * Arg: add [OWNER] Object to add to the list [Translation *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_Transcript(Transcript * obj,Translation * add); #define add_Transcript Wise2_add_Transcript /* Function: flush_Transcript(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Transcript *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_Transcript(Transcript * obj); #define flush_Transcript Wise2_flush_Transcript /* Function: Transcript_alloc_std(void) * * Descrip: Equivalent to Transcript_alloc_len(TranscriptLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Transcript *] * */ Transcript * Wise2_Transcript_alloc_std(void); #define Transcript_alloc_std Wise2_Transcript_alloc_std /* Function: Transcript_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Transcript *] * */ Transcript * Wise2_Transcript_alloc_len(int len); #define Transcript_alloc_len Wise2_Transcript_alloc_len /* Function: hard_link_Transcript(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Transcript *] * * Return [UNKN ] Undocumented return value [Transcript *] * */ Transcript * Wise2_hard_link_Transcript(Transcript * obj); #define hard_link_Transcript Wise2_hard_link_Transcript /* Function: Transcript_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Transcript *] * */ Transcript * Wise2_Transcript_alloc(void); #define Transcript_alloc Wise2_Transcript_alloc /* Function: free_Transcript(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Transcript *] * * Return [UNKN ] Undocumented return value [Transcript *] * */ Transcript * Wise2_free_Transcript(Transcript * obj); #define free_Transcript Wise2_free_Transcript /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ cDNA * Wise2_access_cDNA_Transcript(Transcript * obj); #define access_cDNA_Transcript Wise2_access_cDNA_Transcript int Wise2_access_end_Exon(Exon * obj); #define access_end_Exon Wise2_access_end_Exon boolean Wise2_replace_end_Exon(Exon * obj,int end); #define replace_end_Exon Wise2_replace_end_Exon boolean Wise2_replace_used_Exon(Exon * obj,boolean used); #define replace_used_Exon Wise2_replace_used_Exon boolean Wise2_replace_cDNA_Transcript(Transcript * obj,cDNA * cDNA); #define replace_cDNA_Transcript Wise2_replace_cDNA_Transcript boolean Wise2_access_used_Exon(Exon * obj); #define access_used_Exon Wise2_access_used_Exon double Wise2_access_score_Exon(Exon * obj); #define access_score_Exon Wise2_access_score_Exon SupportingFeature * Wise2_access_sf_Exon(Exon * obj,int i); #define access_sf_Exon Wise2_access_sf_Exon boolean Wise2_replace_start_Exon(Exon * obj,int start); #define replace_start_Exon Wise2_replace_start_Exon int Wise2_length_sf_Exon(Exon * obj); #define length_sf_Exon Wise2_length_sf_Exon int Wise2_access_start_Exon(Exon * obj); #define access_start_Exon Wise2_access_start_Exon boolean Wise2_replace_phase_Exon(Exon * obj,int phase); #define replace_phase_Exon Wise2_replace_phase_Exon boolean Wise2_replace_score_Exon(Exon * obj,double score); #define replace_score_Exon Wise2_replace_score_Exon int Wise2_access_phase_Exon(Exon * obj); #define access_phase_Exon Wise2_access_phase_Exon Gene * Wise2_access_parent_Transcript(Transcript * obj); #define access_parent_Transcript Wise2_access_parent_Transcript Exon * Wise2_access_exon_Transcript(Transcript * obj,int i); #define access_exon_Transcript Wise2_access_exon_Transcript Translation * Wise2_access_translation_Transcript(Transcript * obj,int i); #define access_translation_Transcript Wise2_access_translation_Transcript int Wise2_length_exon_Transcript(Transcript * obj); #define length_exon_Transcript Wise2_length_exon_Transcript int Wise2_length_translation_Transcript(Transcript * obj); #define length_translation_Transcript Wise2_length_translation_Transcript boolean Wise2_replace_parent_Transcript(Transcript * obj,Gene * parent); #define replace_parent_Transcript Wise2_replace_parent_Transcript void Wise2_swap_Exon(SupportingFeature ** list,int i,int j) ; #define swap_Exon Wise2_swap_Exon void Wise2_qsort_Exon(SupportingFeature ** list,int left,int right,int (*comp)(SupportingFeature * ,SupportingFeature * )); #define qsort_Exon Wise2_qsort_Exon void Wise2_sort_Exon(Exon * obj,int (*comp)(SupportingFeature *, SupportingFeature *)); #define sort_Exon Wise2_sort_Exon boolean Wise2_expand_Exon(Exon * obj,int len); #define expand_Exon Wise2_expand_Exon void Wise2_swap_ex_Transcript(Exon ** list,int i,int j) ; #define swap_ex_Transcript Wise2_swap_ex_Transcript void Wise2_qsort_ex_Transcript(Exon ** list,int left,int right,int (*comp)(Exon * ,Exon * )); #define qsort_ex_Transcript Wise2_qsort_ex_Transcript void Wise2_sort_ex_Transcript(Transcript * obj,int (*comp)(Exon *, Exon *)); #define sort_ex_Transcript Wise2_sort_ex_Transcript boolean Wise2_expand_ex_Transcript(Transcript * obj,int len); #define expand_ex_Transcript Wise2_expand_ex_Transcript void Wise2_swap_Transcript(Translation ** list,int i,int j) ; #define swap_Transcript Wise2_swap_Transcript void Wise2_qsort_Transcript(Translation ** list,int left,int right,int (*comp)(Translation * ,Translation * )); #define qsort_Transcript Wise2_qsort_Transcript void Wise2_sort_Transcript(Transcript * obj,int (*comp)(Translation *, Translation *)); #define sort_Transcript Wise2_sort_Transcript boolean Wise2_expand_Transcript(Transcript * obj,int len); #define expand_Transcript Wise2_expand_Transcript #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/transcript_api.h0000644000175000001440000003300710670453713020035 0ustar philippusers /* Functions that create, manipulate or act on Exon * * Wise2_hard_link_Exon * Wise2_Exon_alloc_std * Wise2_replace_start_Exon * Wise2_access_start_Exon * Wise2_replace_end_Exon * Wise2_access_end_Exon * Wise2_replace_used_Exon * Wise2_access_used_Exon * Wise2_replace_score_Exon * Wise2_access_score_Exon * Wise2_access_sf_Exon * Wise2_length_sf_Exon * Wise2_flush_Exon * Wise2_add_Exon * Wise2_replace_phase_Exon * Wise2_access_phase_Exon * Wise2_free_Exon [destructor] * */ /* Functions that create, manipulate or act on Transcript * * Wise2_get_cDNA_from_Transcript * Wise2_hard_link_Transcript * Wise2_Transcript_alloc_std * Wise2_access_exon_Transcript * Wise2_length_exon_Transcript * Wise2_flush_ex_Transcript * Wise2_add_ex_Transcript * Wise2_replace_parent_Transcript * Wise2_access_parent_Transcript * Wise2_access_translation_Transcript * Wise2_length_translation_Transcript * Wise2_flush_Transcript * Wise2_add_Transcript * Wise2_replace_cDNA_Transcript * Wise2_access_cDNA_Transcript * Wise2_free_Transcript [destructor] * */ /* API for object Exon */ /* Function: Wise2_hard_link_Exon(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_Exon *] * * Returns Undocumented return value [Wise2_Exon *] * */ Wise2_Exon * Wise2_hard_link_Exon( Wise2_Exon * obj); /* Function: Wise2_Exon_alloc_std(void) * * Descrip: Equivalent to Exon_alloc_len(ExonLISTLENGTH) * * * * Returns Undocumented return value [Wise2_Exon *] * */ Wise2_Exon * Wise2_Exon_alloc_std(); /* Function: Wise2_replace_start_Exon(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Exon *] * Arg: start New value of the variable [int] * * Returns member variable start [boolean] * */ boolean Wise2_replace_start_Exon( Wise2_Exon * obj,int start); /* Function: Wise2_access_start_Exon(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Exon *] * * Returns member variable start [int] * */ int Wise2_access_start_Exon( Wise2_Exon * obj); /* Function: Wise2_replace_end_Exon(obj,end) * * Descrip: Replace member variable end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Exon *] * Arg: end New value of the variable [int] * * Returns member variable end [boolean] * */ boolean Wise2_replace_end_Exon( Wise2_Exon * obj,int end); /* Function: Wise2_access_end_Exon(obj) * * Descrip: Access member variable end * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Exon *] * * Returns member variable end [int] * */ int Wise2_access_end_Exon( Wise2_Exon * obj); /* Function: Wise2_replace_used_Exon(obj,used) * * Descrip: Replace member variable used * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Exon *] * Arg: used New value of the variable [boolean] * * Returns member variable used [boolean] * */ boolean Wise2_replace_used_Exon( Wise2_Exon * obj,boolean used); /* Function: Wise2_access_used_Exon(obj) * * Descrip: Access member variable used * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Exon *] * * Returns member variable used [boolean] * */ boolean Wise2_access_used_Exon( Wise2_Exon * obj); /* Function: Wise2_replace_score_Exon(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Exon *] * Arg: score New value of the variable [double] * * Returns member variable score [boolean] * */ boolean Wise2_replace_score_Exon( Wise2_Exon * obj,double score); /* Function: Wise2_access_score_Exon(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Exon *] * * Returns member variable score [double] * */ double Wise2_access_score_Exon( Wise2_Exon * obj); /* Function: Wise2_access_sf_Exon(obj,i) * * Descrip: Access members stored in the sf list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_Exon *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_SupportingFeature *] * */ Wise2_SupportingFeature * Wise2_access_sf_Exon( Wise2_Exon * obj,int i); /* Function: Wise2_length_sf_Exon(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_Exon *] * * Returns length of the list [int] * */ int Wise2_length_sf_Exon( Wise2_Exon * obj); /* Function: Wise2_flush_Exon(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_Exon *] * * Returns Undocumented return value [int] * */ int Wise2_flush_Exon( Wise2_Exon * obj); /* Function: Wise2_add_Exon(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_Exon *] * Arg: add Object to add to the list [Wise2_SupportingFeature *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_Exon( Wise2_Exon * obj,Wise2_SupportingFeature * add); /* Function: Wise2_replace_phase_Exon(obj,phase) * * Descrip: Replace member variable phase * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Exon *] * Arg: phase New value of the variable [int] * * Returns member variable phase [boolean] * */ boolean Wise2_replace_phase_Exon( Wise2_Exon * obj,int phase); /* Function: Wise2_access_phase_Exon(obj) * * Descrip: Access member variable phase * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Exon *] * * Returns member variable phase [int] * */ int Wise2_access_phase_Exon( Wise2_Exon * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_Exon(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_Exon *] * * Returns Undocumented return value [Wise2_Exon *] * */ Wise2_Exon * Wise2_free_Exon( Wise2_Exon * obj); /* API for object Transcript */ /* Function: Wise2_get_cDNA_from_Transcript(trs) * * Descrip: gets the cDNA associated with this transcript, * if necessary, building it from the exon information * provided. * * returns a soft-linked object. If you want to ensure * that this cDNA object remains in memory use * /hard_link_cDNA on the object. * * * Arg: trs transcript to get cDNA from [Wise2_Transcript *] * * Returns cDNA of the transcript [Wise2_cDNA *] * */ Wise2_cDNA * Wise2_get_cDNA_from_Transcript( Wise2_Transcript * trs); /* Function: Wise2_hard_link_Transcript(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_Transcript *] * * Returns Undocumented return value [Wise2_Transcript *] * */ Wise2_Transcript * Wise2_hard_link_Transcript( Wise2_Transcript * obj); /* Function: Wise2_Transcript_alloc_std(void) * * Descrip: Equivalent to Transcript_alloc_len(TranscriptLISTLENGTH) * * * * Returns Undocumented return value [Wise2_Transcript *] * */ Wise2_Transcript * Wise2_Transcript_alloc_std(); /* Function: Wise2_access_exon_Transcript(obj,i) * * Descrip: Access members stored in the exon list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_Transcript *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_Exon *] * */ Wise2_Exon * Wise2_access_exon_Transcript( Wise2_Transcript * obj,int i); /* Function: Wise2_length_exon_Transcript(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_Transcript *] * * Returns length of the list [int] * */ int Wise2_length_exon_Transcript( Wise2_Transcript * obj); /* Function: Wise2_flush_ex_Transcript(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_Transcript *] * * Returns Undocumented return value [int] * */ int Wise2_flush_ex_Transcript( Wise2_Transcript * obj); /* Function: Wise2_add_ex_Transcript(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_Transcript *] * Arg: add Object to add to the list [Wise2_Exon *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_ex_Transcript( Wise2_Transcript * obj,Wise2_Exon * add); /* Function: Wise2_replace_parent_Transcript(obj,parent) * * Descrip: Replace member variable parent * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Transcript *] * Arg: parent New value of the variable [Wise2_Gene *] * * Returns member variable parent [boolean] * */ boolean Wise2_replace_parent_Transcript( Wise2_Transcript * obj,Wise2_Gene * parent); /* Function: Wise2_access_parent_Transcript(obj) * * Descrip: Access member variable parent * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Transcript *] * * Returns member variable parent [Wise2_Gene *] * */ Wise2_Gene * Wise2_access_parent_Transcript( Wise2_Transcript * obj); /* Function: Wise2_access_translation_Transcript(obj,i) * * Descrip: Access members stored in the translation list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_Transcript *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_Translation *] * */ Wise2_Translation * Wise2_access_translation_Transcript( Wise2_Transcript * obj,int i); /* Function: Wise2_length_translation_Transcript(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_Transcript *] * * Returns length of the list [int] * */ int Wise2_length_translation_Transcript( Wise2_Transcript * obj); /* Function: Wise2_flush_Transcript(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_Transcript *] * * Returns Undocumented return value [int] * */ int Wise2_flush_Transcript( Wise2_Transcript * obj); /* Function: Wise2_add_Transcript(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_Transcript *] * Arg: add Object to add to the list [Wise2_Translation *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_Transcript( Wise2_Transcript * obj,Wise2_Translation * add); /* Function: Wise2_replace_cDNA_Transcript(obj,cDNA) * * Descrip: Replace member variable cDNA * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Transcript *] * Arg: cDNA New value of the variable [Wise2_cDNA *] * * Returns member variable cDNA [boolean] * */ boolean Wise2_replace_cDNA_Transcript( Wise2_Transcript * obj,Wise2_cDNA * cDNA); /* Function: Wise2_access_cDNA_Transcript(obj) * * Descrip: Access member variable cDNA * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_Transcript *] * * Returns member variable cDNA [Wise2_cDNA *] * */ Wise2_cDNA * Wise2_access_cDNA_Transcript( Wise2_Transcript * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_Transcript(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_Transcript *] * * Returns Undocumented return value [Wise2_Transcript *] * */ Wise2_Transcript * Wise2_free_Transcript( Wise2_Transcript * obj); wise-2.4.1/src/dynlibsrc/transcript_api.t0000644000175000001440000000013210670453713020042 0ustar philippuserstypedef struct Wise2_Exon Wise2_Exon; typedef struct Wise2_Transcript Wise2_Transcript; wise-2.4.1/src/dynlibsrc/hsphandler.dy0000644000175000001440000005144110421463722017325 0ustar philippusers %{ #include "sequence.h" #include "compmat.h" #include "glib.h" #include "hsp.h" #define UNFEASIBLY_LARGE_SCORE 1000000 %} struct TopScoreManager int * score int length int current_pos int worst_score int worst_position struct QuerySeqHSP Sequence * query int ** score !link int * self_score int len struct HSPmanager GHashTable * target_hash !link Sequence * query CompMat * mat int drop_off int min_score !def=40 TopScoreManager * tsm; QuerySeqHSP * qs HSPCache * cache int hsp_count struct LineariseHSPPara int max_size int min_score int width int tail int verbosity %{ #include "hsphandler.h" %func Makes a new topscore manager of a specific length %% TopScoreManager * new_TopScoreManager(int length) { TopScoreManager * tsm; tsm = TopScoreManager_alloc(); tsm->score = calloc(length,sizeof(int)); tsm->current_pos = 0; tsm->length = length; tsm->worst_score = 0; tsm->worst_position = -1; return tsm; } %func Adds a top score %% boolean add_score_TopScoreManager(TopScoreManager * tsm,int score) { int i; int temp_score; int temp_pos; /* fprintf(stderr,"Looking at %d\n",score);*/ if( tsm->current_pos < tsm->length ) { tsm->score[tsm->current_pos++] = score; return TRUE; } if( tsm->worst_position == -1 ) { /* fprintf(stderr,"Recalculating...\n"); */ /* need to recalculate top score */ for(i=1,temp_score = tsm->score[0],temp_pos = 0;ilength;i++) { if( temp_score > tsm->score[i] ) { temp_score = tsm->score[i]; temp_pos = i; } } tsm->worst_score = temp_score; tsm->worst_position = temp_pos; } if( score < tsm->worst_score ) { /* fprintf(stderr,"Ignoring... %d vs %d\n",score,tsm->worst_score); */ return FALSE; } /* fprintf(stderr,"Resetting...\n"); */ tsm->score[tsm->worst_position] = score; tsm->worst_position = -1; return TRUE; } %func A simpler truncation method, using diagonals %% LinearHSPmanager * truncated_simple_LinearHSPmanager(LinearHSPmanager * lm,LineariseHSPPara * para) { LinearHSPmanager * out; int i; int j; int new_score; int diag_one; int diag_two; int query_position[500]; int k; int aa_count; int query_offset; /* struct timeval t1; struct timeval t2; struct timeval t3; */ /* gettimeofday(&t1,NULL);*/ if( VERBOSITY_CHECK(2,para->verbosity) ) { info("Input linear management of %d entries\n",lm->len); } for(i=0;ilen;i++) { /* rescore this set wrt to top diagonal */ sort_HSPset_by_score(lm->set[i]); new_score = lm->set[i]->hsp[0]->score; diag_one = lm->set[i]->hsp[0]->query_start - lm->set[i]->hsp[0]->target_start; if( VERBOSITY_CHECK(5,para->verbosity) ) { info("Looking at %s with starting hsp score of %d\n",lm->set[i]->hsp[0]->target->name,new_score); } query_offset = lm->set[i]->hsp[0]->query_start - 200; for(k=0;k<500;k++) { query_position[k] = 0; } for(k=0;kset[i]->hsp[0]->length && lm->set[i]->hsp[0]->query_start - query_offset+k < 500;k++) { query_position[lm->set[i]->hsp[0]->query_start - query_offset+k] = 1; } for(j=1;jset[i]->len;j++) { if( lm->set[i]->hsp[j]->score < para->min_score ) { if( VERBOSITY_CHECK(8,para->verbosity) ) { info(" ...not accepting hsp %d,%d due to min score",lm->set[i]->hsp[j]->query_start,lm->set[i]->hsp[j]->target_start); } break; } diag_two = lm->set[i]->hsp[j]->query_start - lm->set[i]->hsp[j]->target_start; if( abs(diag_one - diag_two) < para->width && abs(lm->set[i]->hsp[0]->query_start - lm->set[i]->hsp[j]->query_start) < para->tail) { /* this is now in the right area */ /* but we need to test for overlap on existing cases */ /* fprintf(stderr," .... looking at hsp overlap\n");*/ for(aa_count = 0,k=0;kset[i]->hsp[j]->length && lm->set[i]->hsp[j]->query_start - query_offset+k < 500;k++) { if( query_position[lm->set[i]->hsp[j]->query_start - query_offset+k] == 1 ) { aa_count++; } } /* if we have more than 15% of this hsp "accounted for" move on */ if(aa_count/(double)lm->set[i]->hsp[j]->length > 0.15 ) { continue; } /* fprintf(stderr," .... updating HSP overlap\n");*/ /* now set these positions as used */ for(aa_count = 0,k=0;kset[i]->hsp[j]->length && lm->set[i]->hsp[j]->query_start - query_offset+k < 500;k++) { query_position[lm->set[i]->hsp[j]->query_start - query_offset+k] = 1; } new_score += lm->set[i]->hsp[j]->score; if( VERBOSITY_CHECK(5,para->verbosity) ) { info(" ..accepting hsp on %s %d,%d new score %d",lm->set[i]->hsp[j]->target->name,lm->set[i]->hsp[j]->query_start,lm->set[i]->hsp[j]->target_start,new_score); } } else { if( VERBOSITY_CHECK(5,para->verbosity) ) { info(" ...not accepting hsp %d,%d due to diagonal width",lm->set[i]->hsp[j]->query_start,lm->set[i]->hsp[j]->target_start); } } } if( VERBOSITY_CHECK(3,para->verbosity) ) { info("Looking at %s with final score of %d",lm->set[i]->hsp[0]->target->name,new_score); } lm->set[i]->score = new_score; } /* gettimeofday(&t2,NULL); */ if( VERBOSITY_CHECK(2,para->verbosity) ) { info("sorting %d items",lm->len); } /*qsort(lm->set,lm->len,sizeof(HSPset*),compare_HSPset_score_qsort);*/ sort_LinearHSPmanager(lm,compare_HSPset_score); /* gettimeofday(&t3,NULL); info("truncation clock point: rescoring %f : sorting %f", t2.tv_sec - t1.tv_sec + ((t2.tv_usec - t1.tv_usec) * 1e-6), t3.tv_sec - t2.tv_sec + ((t2.tv_usec - t2.tv_usec) * 1e-6) ); */ out = LinearHSPmanager_alloc_std(); out->mat = hard_link_CompMat(lm->mat); for(i=0;ilen;i++) { if( VERBOSITY_CHECK(5,para->verbosity) ) { info("Accepting hit %s position %d with score %d",lm->set[i]->hsp[0]->target->name,i,lm->set[i]->score); } add_LinearHSPmanager(out,hard_link_HSPset(lm->set[i])); if( i > para->max_size ) { break; } } return out; } %func Makes a truncated linear set %% LinearHSPmanager * truncated_LinearHSPmanager(LinearHSPmanager * lm,int max_size,int min_score,int width,int tail) { LinearHSPmanager * out; int i,j; int worst_score = UNFEASIBLY_LARGE_SCORE; int worst_j = -1; HSPset ** worst; HSPset * trial; assert(max_size > 0); out = LinearHSPmanager_alloc_len(max_size+1); out->mat = hard_link_CompMat(lm->mat); sort_LinearHSPmanager(lm,compare_HSPset_score); for(i=0;ilen;i++) { /* we chew up into max_size positions */ if( out->len < max_size ) { trial = new_consistent_HSPset(lm->set[i],min_score,width,tail); if( trial->len == 0 ) { continue; } add_LinearHSPmanager(out,trial); } else { /* if have not found worst, scan to find worst */ if( worst_score == UNFEASIBLY_LARGE_SCORE ) { for(j=0;jlen;j++) { if( out->set[j]->score < worst_score ) { worst_score = out->set[j]->score; worst = out->set+j; worst_j = j; } } } /* worst_score is now the score */ if( lm->set[i]->score < worst_score ) { break; /* otta here - we don't need to look at any more! */ } trial = new_consistent_HSPset(lm->set[i],min_score,width,tail); if( trial->len == 0 ) { continue; } if( trial->score > worst_score ) { free_HSPset(out->set[worst_j]); out->set[worst_j] = trial; worst_score = UNFEASIBLY_LARGE_SCORE; } else { free_HSPset(trial); } } } return out; } %func Makes an HSP set via heuristics to deal with low complexity regions %% HSPset * new_consistent_HSPset(HSPset * set,int min_score,int width,int tail) { HSPset * out; int i,j; int diag_a; int diag_b; int eaten; /* fprintf(stderr,"Entering consistency for %s with %d\n",set->hsp[0]->target->name,set->len); */ out = HSPset_alloc_std(); sort_HSPset_by_score(set); add_HSPset(out,hard_link_HSP(set->hsp[0])); out->score = set->hsp[0]->score; for(i=1;ilen;i++) { /* check against exisiting HSPs. If fits, add into big set */ eaten = 0; if( set->hsp[i]->score < min_score ) { continue; } for(j=0;jlen;j++) { diag_a = set->hsp[i]->query_start - set->hsp[i]->target_start; diag_b = out->hsp[j]->query_start - out->hsp[j]->target_start; if( abs(diag_a - diag_b) > 2 * width ) { continue; /* does not match */ } eaten = 1; add_HSPset(out,hard_link_HSP(set->hsp[i])); out->score += set->hsp[i]->score; break; } } return out; } %func New, simpler LinearHSPmanager with diagonal heuristics %% LinearHSPmanager * new_LinearHSPmanager_simple_heuristic(HSPmanager * hspm,LineariseHSPPara * para) { int i; int j; LinearHSPmanager * temp; LinearHSPmanager * out; #ifdef LINUX_TIMER struct timeval t1; struct timeval t2; struct timeval t3; if( VERBOSITY_CHECK(1,para->verbosity) ) { gettimeofday(&t1,NULL); } #endif temp = new_LinearHSPmanager_truncate_on_score(hspm); if( VERBOSITY_CHECK(2,para->verbosity) ) { info("Have got linear hsp manager with %d entries",temp->len); } #ifdef LINUX_TIMER if( VERBOSITY_CHECK(1,para->verbosity) ) { gettimeofday(&t2,NULL); } #endif out = truncated_simple_LinearHSPmanager(temp,para); if( VERBOSITY_CHECK(2,para->verbosity) ) { info("Now got linear hsp manager with %d entries",out->len); } #ifdef LINUX_TIMER if( VERBOSITY_CHECK(1,para->verbosity) ) { gettimeofday(&t3,NULL); info("Sort breakdown: Conversion %f : Truncation %f", t2.tv_sec - t1.tv_sec + ((t2.tv_usec - t1.tv_usec) * 1e-6), t3.tv_sec - t2.tv_sec + ((t2.tv_usec - t2.tv_usec) * 1e-6) ); } #endif /* for(i=0;ilen;i++) { fprintf(stderr,"%d, got score %d, top score %d %s\n",i,out->set[i]->score,out->set[i]->hsp[0]->score,out->set[i]->hsp[0]->target->name); for(j=0;jset[i]->len;j++) { fprintf(stderr," HSP %d,%d score %d\n",out->set[i]->hsp[j]->query_start, out->set[i]->hsp[j]->target_start, out->set[i]->hsp[j]->score); } } */ info("Currently not free'ing temporary list"); return out; } %func Builds a new LinearHSPmanager from hash based with heuristics %% LinearHSPmanager * new_LinearHSPmanager_heuristic_max(HSPmanager * hspm,int max_size) { LinearHSPmanager * temp; LinearHSPmanager * out; assert(hspm); assert(max_size > 0); temp = new_LinearHSPmanager_truncate_on_score(hspm); out = truncated_LinearHSPmanager(temp,max_size,30,30,40); /* free_LinearHSPmanager(temp); */ return out; } %func Builds a LinearHSPmanager from a hash based HSP manager, using worst score truncation %% LinearHSPmanager * new_LinearHSPmanager_truncate_on_score(HSPmanager * hspm) { LinearHSPmanager * out; out = LinearHSPmanager_alloc_std(); out->mat = hard_link_CompMat(hspm->mat); out->worst_hsp_score = hspm->tsm->worst_score; /* for(i=0;itsm->length;i++) { fprintf(stderr,"At position %d got score %d\n",i,hspm->tsm->score[i]); } */ /* fprintf(stderr,"Before management, we have %d, worst score is %d\n",g_hash_table_size(hspm->target_hash),out->worst_hsp_score); */ g_hash_table_foreach(hspm->target_hash,linearise_HSPset_truncate_on_score,out); /* sort_LinearHSPmanager(out,compare_HSPset_score); */ return out; } %func Builds a LinearHSPmanager from a hash based HSP manager %% LinearHSPmanager * new_LinearHSPmanager_flat(HSPmanager * hspm) { LinearHSPmanager * out; out = LinearHSPmanager_alloc_std(); out->mat = hard_link_CompMat(hspm->mat); g_hash_table_foreach(hspm->target_hash,linearise_HSPset_flat,out); sort_LinearHSPmanager(out,compare_HSPset_score); return out; } %func internal function for remapping HSPs %% void linearise_HSPset_truncate_on_score(gpointer key,gpointer value,gpointer user_data) { LinearHSPmanager * l = (LinearHSPmanager *) user_data; HSPset * s = (HSPset *) value; if( s->len == 1 && s->score < l->worst_hsp_score ) { return; } else { add_LinearHSPmanager(l,hard_link_HSPset(s)); } } %func internal function for remapping HSPs with score cutoff %% void linearise_HSPset_flat(gpointer key,gpointer value,gpointer user_data) { LinearHSPmanager * l = (LinearHSPmanager *) user_data; HSPset * s = (HSPset *) value; int i; s->score = 0; s->best_score =0; for(i=0;ilen;i++) { s->score += s->hsp[i]->score; if( s->hsp[i]->score > s->best_score ) { s->best_score = s->hsp[i]->score; } } add_LinearHSPmanager(l,hard_link_HSPset(s)); } %func internal function for remapping HSPs %% void linearise_HSPset_consistent(gpointer key,gpointer value,gpointer user_data) { LinearHSPmanager * l = (LinearHSPmanager *) user_data; HSPset * s = (HSPset *) value; HSPset * add; add = new_consistent_HSPset(s,l->min_score,l->width,l->tail); if( add->len > 0 ) { add_LinearHSPmanager(l,add); } else { free_HSPset(add); } } %func Builds a new HSPmanager for a target system %% HSPmanager * new_HSPmanager(Sequence * query,CompMat * mat,int score_drop_off) { HSPmanager * out; out = HSPmanager_alloc(); out->query = hard_link_Sequence(query); if( mat == NULL ) { out->mat = NULL; } else { out->mat = hard_link_CompMat(mat); } out->qs = new_QuerySeqHSP(query,mat); /* out->qs = NULL; */ out->drop_off = score_drop_off; out->target_hash = g_hash_table_new(g_direct_hash,g_direct_equal); out->tsm = new_TopScoreManager(250); /* out->cache = new_HSPCache(2000);*/ out->cache = NULL; out->min_score = 25; out->hsp_count = 0; return out; } %func adds a new target pair, irregardless of score %% int add_pair_HSPmanager(HSPmanager * hspm,Sequence * target,int query_pos,int target_pos) { return add_pair_HSPmanager_score(hspm,target,query_pos,target_pos,-1); } %func Adds a new target pair to this HSPmanager for indexing, with a min score %% int add_pair_HSPmanager_score(HSPmanager * hspm,Sequence * target,int query_pos,int target_pos,int min_score) { HSPset * set; int i; HSP * hsp; boolean has_set = 0; /* see if this target is loaded into the manager */ if( (set = g_hash_table_lookup(hspm->target_hash,(gpointer)target)) != NULL ) { has_set = 1; } /* set is now the HSPset. Ensure this position is not already accounted for in the set */ if( has_set == 1 ) { if( set->last_accessed != -1 && ON_HSP_MACRO(set->hsp[set->last_accessed],query_pos,target_pos) ) { return set->hsp[set->last_accessed]->score; } for(i=0;ilen;i++) { if( ON_HSP_MACRO(set->hsp[i],query_pos,target_pos) == TRUE ) { set->last_accessed = i; return set->hsp[set->last_accessed]->score; } } } if( hspm->qs != NULL ) { hsp = new_HSP_QuerySeqHSP(hspm->cache,hspm->qs,target,query_pos,target_pos,hspm->mat,hspm->drop_off,min_score); } else { hsp = new_HSP(hspm->cache,hspm->query,target,query_pos,target_pos,hspm->mat,hspm->drop_off); } if( hsp == NULL ) { /* internal min score optimisation */ return 0; } if( hsp->score < hspm->min_score ) { /* fprintf(stderr,"hsp being lost due to min score %d\n",hsp->score); */ free_HSP(hsp); return 0; } hspm->hsp_count++; if( has_set == 0 ) { set = HSPset_alloc_std(); g_hash_table_insert(hspm->target_hash,(gpointer)target,set); } set->score += hsp->score; if( hsp->score > set->best_score ) { set->best_score = hsp->score; add_score_TopScoreManager(hspm->tsm,set->best_score); } add_HSPset(set,hsp); set->last_accessed = set->len-1; return hsp->score; } %func Adds a new HSP when all info is known %% boolean add_new_HSP_HSPmanager(HSPmanager * hspm,Sequence * target,int query_start,int target_start,int length,int score) { HSPset * set; HSP * hsp; /* see if this target is loaded into the manager */ if( (set = g_hash_table_lookup(hspm->target_hash,(gpointer)target)) == NULL ) { set = HSPset_alloc_std(); g_hash_table_insert(hspm->target_hash,(gpointer)target,set); } if( hspm->cache != NULL ) { hsp = HSP_alloc_cache(hspm->cache); } else { hsp = HSP_alloc(); } hsp->query = hard_link_Sequence(hspm->query); hsp->target= hard_link_Sequence(target); hsp->score = score; hsp->target_start = target_start; hsp->query_start = query_start; hsp->length = length; add_HSPset(set,hsp); return TRUE; } %func Frees the HSPsets %% void free_ghash_HSPsets(gpointer key,gpointer value,gpointer user_data) { int i; HSPset * val = (HSPset *) value; HSPCache * cache = (HSPCache*) user_data; if( val->dynamite_hard_link > 1 ) { val->dynamite_hard_link--; return; } if( cache != NULL ) { for(i=0;ilen;i++) { free_HSP_cache(cache,val->hsp[i]); } val->len = 0; } free_HSPset(val); } %func Frees the HSPmanager %% !deconstructor HSPmanager * free_HSPmanager(HSPmanager * h) { g_hash_table_foreach(h->target_hash,free_ghash_HSPsets,h->cache); g_hash_table_destroy(h->target_hash); free_CompMat(h->mat); if( h->tsm != NULL ) { free_TopScoreManager(h->tsm); } if( h->qs != NULL ) { free_QuerySeqHSP(h->qs); } ckfree(h); return NULL; } %func builds a new HSP for these sequences %% HSP * new_HSP_QuerySeqHSP(HSPCache * cache,QuerySeqHSP * query,Sequence * target,int query_pos,int target_pos,CompMat * mat,int score_drop_off,int min_score) { int i,j; int ii,jj; int temp_score; int t; int pause_i,pause_j; int score = 0; HSP * out = NULL; const char * q_seq; const char * t_seq; const int * self_score; int overall_score; int query_start; int target_start; /* we count the start position twice */ overall_score = -(query->score[query_pos][target->seq[target_pos]-'A']); q_seq = query->query->seq; t_seq = target->seq; self_score = query->self_score; pause_i = i = query_pos; pause_j = j = target_pos; /* go upstream first */ for(score=0;i >= 0 && j >= 0;i--,j--) { /* optimise identical matches */ if( toupper(q_seq[i]) == toupper(t_seq[j]) ) { score += self_score[i]; continue; } t= query->score[i][target->seq[j]-'A']; if( t >= 0 ) { /* this is a positive score, we are on a high scoring run, so add and move on*/ score += t; } else { /* negative score. i+1,j+1 was our last best score */ for(temp_score = t,ii=i-1,jj=j-1;temp_score >= -score_drop_off && ii >= 0 && jj >= 0 && temp_score < 0;ii--,jj--) { temp_score += query->score[ii][target->seq[jj]-'A']; } if( temp_score >= 0 ) { /* new maximum reached */ i = ii; j = jj; score += temp_score; continue; /* back to main loop */ } else { /* either temp_score < -drop_off or something else */ break; } } } /* set start position */ query_start = i+1; target_start = j+1; overall_score += score; /* downstream */ for(score=0,i=query_pos,j=target_pos;i < query->len && j < target->len;i++,j++) { /* optimise identical matches */ if( toupper(q_seq[i]) == toupper(t_seq[j]) ) { score += self_score[i]; continue; } t= query->score[i][target->seq[j]-'A']; /* fprintf(stderr,"Doing %d %d, [%c,%c] off %d score %d\n",i,j,query->query->seq[i],target->seq[j],t,score); */ if( t >= 0 ) { /* this is a positive score, we are on a high scoring run, so add and move on*/ score += t; } else { /* negative score. i-1,j-1 was our last best score */ for(temp_score = t,ii=i+1,jj=j+1;temp_score >= -score_drop_off && ii < query->len && jj < target->len && temp_score < 0;ii++,jj++) { temp_score += query->score[ii][target->seq[jj]-'A']; /* fprintf(stderr,"Negative looping %d,%d temp %d [%c,%c]\n",ii,jj,temp_score,query->query->seq[ii],target->seq[jj]); */ } if( temp_score >= 0 ) { /* new good score reached */ i = ii; j = jj; score += temp_score; continue; /* back to main loop */ } else { /* either temp_score < -drop_off or something else */ break; } } } if( overall_score + score < min_score ) { return NULL; } /* we have a valid HSP. Ask for memory and return */ if( cache != NULL ) { out = HSP_alloc_cache(cache); } else { out = HSP_alloc(); } out->query_start = query_start; out->target_start = target_start; out->score = overall_score + score; out->query = hard_link_Sequence(query->query); out->target= hard_link_Sequence(target); /* set length and score */ out->length = i-1 - out->query_start +1; return out; } %func Builds a new QuerySeqHSP from Sequence and Matrix %% QuerySeqHSP * new_QuerySeqHSP(Sequence * seq,CompMat * mat) { QuerySeqHSP * out; int i; assert(seq); assert(mat); out = QuerySeqHSP_alloc(); out->query = hard_link_Sequence(seq); out->score = (int **)calloc(seq->len,sizeof(int*)); out->self_score = (int*) calloc(seq->len,sizeof(int)); out->len = seq->len; for(i=0;ilen;i++) { out->score[i] = mat->comp[toupper(seq->seq[i])-'A']; out->self_score[i] = mat->comp[toupper(seq->seq[i])-'A'][toupper(seq->seq[i])-'A']; } return out; } wise-2.4.1/src/dynlibsrc/complexsequence.typemap0000644000175000001440000000112210670453712021433 0ustar philippusers TYPEMAP Wise2_ComplexSequence * T_Wise2_ComplexSequence INPUT T_Wise2_ComplexSequence $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_ComplexSequence *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_ComplexSequence sv_setref_pv($arg, "Wise2::ComplexSequence", (void*) $var); TYPEMAP Wise2_ComplexSequenceEvalSet * T_Wise2_ComplexSequenceEvalSet INPUT T_Wise2_ComplexSequenceEvalSet $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_ComplexSequenceEvalSet *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_ComplexSequenceEvalSet sv_setref_pv($arg, "Wise2::ComplexSequenceEvalSet", (void*) $var); wise-2.4.1/src/dynlibsrc/hsp.dy0000644000175000001440000001704510357235441015774 0ustar philippusers %{ #include "sequence.h" #include "compmat.h" #define HSPsetLISTLENGTH 20 #define HSP_BLOCK_SIZE 1024 #define HSPCacheLISTLENGTH 1024 #define LinearHSPmanagerLISTLENGTH 128 #define ON_HSP_MACRO(test,query_pos,target_pos) ( (((test->query_start-test->target_start)!=(query_pos-target_pos))||(query_posquery_start)||(target_postarget_start)||(query_pos-test->query_start>test->length)) ? FALSE : TRUE) %} struct HSP Sequence * query Sequence * target int query_start int target_start int length int score char is_in_block !def="0" char target_reverse !def="0" struct HSPCache HSP ** cache !list int max_cache struct HSPset HSP ** hsp !list int score int best_score int last_accessed !def="-1" struct LinearHSPmanager HSPset ** set !list Sequence * query CompMat * mat int min_score !def=80 int width !def=30 int tail !def=30 int worst_hsp_score %{ #include "hsp.h" %func tests whether this point is on this test HSP %% boolean on_HSP(HSP * test,int query_pos,int target_pos) { if( (test->query_start - test->target_start) != query_pos - target_pos || query_pos < test->query_start || target_pos < test->target_start) { return FALSE; } if( query_pos - test->query_start > test->length ) { return FALSE; } return TRUE; } %func sorting linear HSPsets via qsort function %% int compare_HSPset_score_qsort(const void * a,const void * b) { const HSPset * one; const HSPset * two; one = *((HSPset**)a); two = *((HSPset**)b); return two->score - one->score; } %func internal function for sort linear HSPsets %% int compare_HSPset_score(HSPset * one,HSPset * two) { return two->score - one->score; } %func Sorts by score %% void sort_HSPset_by_score(HSPset *set) { sort_HSPset(set,compare_HSP_score); } %func internal for sort by score %type internal %% int compare_HSP_score(HSP * one,HSP * two) { return two->score - one->score; } %func builds a new HSP for these sequences breaking at first mismatch %% HSP * new_dna_identical_HSP(Sequence * query,Sequence * target,int query_pos,int target_pos,int target_reverse) { int i,j; HSP * out; assert(query); assert(target); assert(query_pos >= 0 && query_pos < query->len); assert(target_pos >= 0 && target_pos < target->len); out = HSP_alloc(); out->query = hard_link_Sequence(query); out->target= hard_link_Sequence(target); i = query_pos; j = target_pos; /* upstream first */ while( i >= 0 && j >= 0 && j <= target->len ) { /* fprintf(stderr," in upstream loop, looking at %d (is revd %d)\n",i,target_reverse); */ if( target_reverse == 1 ) { if( toupper(query->seq[i]) != char_complement_base(toupper(target->seq[j])) ) { /* fprintf(stderr,"Breaking, reversed at %d,%d %c,%c\n",i,j,query->seq[i],char_complement_base(toupper(target->seq[j]))); */ break; } else { i--; j++; } } else { if( toupper(query->seq[i]) != toupper(target->seq[j]) ) { /* fprintf(stderr,"Breaking at %d,%d %c,%c\n",i,j,query->seq[i],target->seq[j]); */ break; } else{ i--; j--; } } } if( target_reverse == 1 ) { i++; j--; } else { i++; j++; } out->query_start = i; out->target_start = j; i = query_pos; j = target_pos; /* downstream next */ while( i < query->len && j >= 0 && j < target->len ) { if( target_reverse == 1 ) { if( toupper(query->seq[i]) != char_complement_base(toupper(target->seq[j])) ) { i--; j++; break; } else { i++; j--; } } else { if( toupper(query->seq[i]) != toupper(target->seq[j]) ) { i--; j--; break; } else{ i++; j++; } } } if( target_reverse == 1 ) { i++; j--; } else { i--; j--; } out->length = i - out->query_start; out->score = out->length; out->target_reverse = target_reverse; return out; } %func builds a new HSP for these sequences %% HSP * new_HSP(HSPCache * cache,Sequence * query,Sequence * target,int query_pos,int target_pos,CompMat * mat,int drop_off) { int i,j; int pause_i,pause_j; int score = 0; int max_score= 0; HSP * out; if( cache != NULL ) { out = HSP_alloc_cache(cache); } else { out = HSP_alloc(); } assert(out != NULL); assert(query != NULL); assert(query->seq != NULL); assert(target != NULL); assert(target->seq != NULL); assert(mat != NULL); assert(drop_off > 0); assert(query->seq[query_pos] >= 'A' && query->seq[query_pos] <= 'Z'); assert(target->seq[target_pos] >= 'A' && target->seq[target_pos] <= 'Z'); /* fprintf(stdout,"got new hsp with drop_off of %d\n",drop_off);*/ out->query = hard_link_Sequence(query); out->target= hard_link_Sequence(target); out->score = -(mat->comp[query->seq[query_pos]-'A'][target->seq[target_pos]-'A']); pause_i = i = query_pos; pause_j = j = target_pos; /* go upstream first */ for(score = 0,max_score = 0;(max_score - score) < drop_off && i >= 0 && j >= 0;i--,j--) { score += mat->comp[query->seq[i]-'A'][target->seq[j]-'A']; /*fprintf(stderr,"Examining %c,%c - score %d max_score %d\n",query->seq[i],target->seq[j],score,max_score); */ if( score > max_score ) { pause_i = i; pause_j = j; max_score = score; } } out->query_start = pause_i; out->target_start = pause_j; out->score += max_score; /* now downstream */ for(score=0,max_score=0,pause_i=i=query_pos,pause_j=j=target_pos;(max_score - score) < drop_off && i < query->len && j < target->len;i++,j++) { score += mat->comp[query->seq[i]-'A'][target->seq[j]-'A']; if( score > max_score ) { pause_i = i; pause_j = j; max_score = score; } } out->length = pause_i - out->query_start+1; out->score += max_score; return out; } %func Returns new HSP, using cache if needed %% HSP * HSP_alloc_cache(HSPCache * hspc) { assert(hspc); if( hspc->len > 0 ) { hspc->len--; return hspc->cache[hspc->len]; } return HSP_alloc(); } %func Places HSP back into cache, freeing if necessary %% HSP * free_HSP_cache(HSPCache * cache,HSP * hsp) { int return_early = 0; assert(cache); assert(hsp); #ifdef PTHREAD assert(pthread_mutex_lock(&(hsp->dynamite_mutex)) == 0); #endif if( hsp->dynamite_hard_link > 1) { return_early = 1; hsp->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(hsp->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( cache->len > cache->max_cache ) { return free_HSP(hsp); } else { add_HSPCache(cache,hsp); return NULL; } } %func Makes a new cache %% HSPCache * new_HSPCache(int maxsize) { HSPCache * out; out = HSPCache_alloc_std(); out->max_cache = maxsize; return out; } %func Shows a HSP set %% void show_HSPset(HSPset * s,FILE * ofp) { int i; for(i=0;ilen;i++) { if( s->hsp[i]->target_reverse == 0 ) { fprintf(ofp,"%5d %s\t%d\t%d\t%s\t%d\t%d\t+\n",s->hsp[i]->length,s->hsp[i]->query->name,s->hsp[i]->query_start,s->hsp[i]->query_start+s->hsp[i]->length,s->hsp[i]->target->name,s->hsp[i]->target_start,s->hsp[i]->target_start + s->hsp[i]->length); } else { fprintf(ofp,"%5d %s\t%d\t%d\t%s\t%d\t%d\t-\n",s->hsp[i]->length,s->hsp[i]->query->name,s->hsp[i]->query_start,s->hsp[i]->query_start+s->hsp[i]->length,s->hsp[i]->target->name,s->hsp[i]->target_start,s->hsp[i]->target_start - s->hsp[i]->length); } } } %func Shows an HSP %% void show_HSP(HSP * hsp,int linelength,FILE * out) { int i,j; for(i=hsp->query_start,j=hsp->target_start;(i-hsp->query_start) < hsp->length;i++,j++) { fprintf(out,"%c %c\n",hsp->query->seq[i],hsp->target->seq[j]); } } %} wise-2.4.1/src/dynlibsrc/hspscaninterface.dy0000644000175000001440000001646710417270545020532 0ustar philippusers %{ #include "hsp.h" #define HSPSCAN_IMPLEMENTATION_VANILLA 10 #define HSPSCAN_IMPLEMENTATION_THREADED 11 #define HSPSCAN_IMPLEMENTATION_TWOHIT 12 %} struct HSPScanInterfacePara int min_score int max_results int flags boolean use_protein_heuristic !def="TRUE" int numb_level !def="1000" int word_depth !def="2" int min_word_score !def="14" int min_hsp_score !def="22" int implementation !def="HSPSCAN_IMPLEMENTATION_VANILLA" int hsp_link_width !def="30" int hsp_link_length !def="150" int verbosity !def="0" int low_numb !def="0" int hsp_avg_ext !def="-6" struct HSPScanInterface LinearHSPmanager * (*scan_query)(void *,Sequence *,HSPScanInterfacePara * para) !func void (*free_data)(void*) !func void * data !link %{ #include "hspscaninterface.h" %func untyped version of read %% void * untyped_read_HSPScanInterfacePara_from_Stream(Wise2ReadStreamInterface * rs) { return (void*) typed_HSPScanInterfacePara_from_Stream(rs); } %func reads a HSPscan interface para from a stream %% HSPScanInterfacePara * typed_HSPScanInterfacePara_from_Stream(Wise2ReadStreamInterface * rs) { char buffer[MAXLINE]; HSPScanInterfacePara * out; out = HSPScanInterfacePara_std(); while( WISE2_READ_BUFFER(buffer,MAXLINE,rs) != NULL ) { if( buffer[0] == '/' && buffer[1] == '/' ) { break; } if( strstartcmp(buffer,"numb") == 0 ) { out->numb_level = strtol(buffer+5,NULL,0); } else if ( strstartcmp(buffer,"maxresults") == 0 ) { out->max_results = strtol(buffer+11,NULL,0); } else if ( strstartcmp(buffer,"worddepth") == 0 ) { out->word_depth = strtol(buffer+10,NULL,0); } else if ( strstartcmp(buffer,"minword") == 0 ) { out->min_word_score = strtol(buffer+8,NULL,0); } else if ( strstartcmp(buffer,"minhsp") == 0 ) { out->min_hsp_score = strtol(buffer+7,NULL,0); } else if ( strstartcmp(buffer,"impl") == 0 ) { out->implementation = strtol(buffer+5,NULL,0); } else if ( strstartcmp(buffer,"linkwidth") == 0 ) { out->hsp_link_width = strtol(buffer+10,NULL,0); } else if ( strstartcmp(buffer,"linklength") == 0 ) { out->hsp_link_length = strtol(buffer+11,NULL,0); } else if ( strstartcmp(buffer,"impl") == 0 ) { out->implementation = strtol(buffer+5,NULL,0); } else if ( strstartcmp(buffer,"verbose") == 0 ) { out->verbosity = strtol(buffer+8,NULL,0); } else if ( strstartcmp(buffer,"lownumb") == 0 ) { out->low_numb = strtol(buffer+8,NULL,0); } else if ( strstartcmp(buffer,"havgext") == 0 ) { out->hsp_avg_ext = strtol(buffer+8,NULL,0); } else { warn("In reading HspScanInterfacePara, unknown line %s",buffer); } } return out; } %func writes out a standard HSPscan interface %% void untyped_HSPScanInterfacePara_to_Stream(void * p,Wise2WriteStreamInterface * ws) { HSPScanInterfacePara * h = (HSPScanInterfacePara *) p; char buffer[MAXLINE]; sprintf(buffer,"numb %d\n",h->numb_level); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"maxresults %d\n",h->max_results); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"worddepth %d\n",h->word_depth); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"minword %d\n",h->min_word_score); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"minhsp %d\n",h->min_hsp_score); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"linkwidth %d\n",h->hsp_link_width); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"linklength %d\n",h->hsp_link_length); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"impl %d\n",h->implementation); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"verbose %d\n",h->verbosity); WISE2_WRITE_STRING(buffer,ws); sprintf(buffer,"lownumb %d\n",h->low_numb); WISE2_WRITE_STRING(buffer,ws); WISE2_WRITE_STRING("//\n",ws); } %func untyped free function for AnonymousObjects %% void untyped_HSPScanInterfacePara_free(void * p) { HSPScanInterfacePara * h; h = (HSPScanInterfacePara *) p; free_HSPScanInterfacePara(h); } %func help function for hspscan interface para %% void show_help_HSPScanInterfacePara(FILE * ofp) { fprintf(ofp,"Parameters for word scan\n"); fprintf(ofp," -hspscan_impl [vanilla/threaded/twohit] implementation to use if compliled for runtime\n"); fprintf(ofp," -hspscan_maxres [100] maximum results returned by scan\n"); fprintf(ofp," -hspscan_numb [1000] word count to numb word (for low complexity)\n"); fprintf(ofp," -hspscan_worddepth [2] maximum offset from word - [0,1,2]\n"); fprintf(ofp," -hspscan_minword [14] minimum word score\n"); fprintf(ofp," -hspscan_minhsp [22] minimum hsp score\n"); fprintf(ofp," -hspscan_link_width [30] max width (gap) of scored HSP chain\n"); fprintf(ofp," -hspscan_link_length [150] max length of scored HSP chain\n"); fprintf(ofp," -hspscan_verbosity [0] verbosity level of server, if server is trace compiled\n"); fprintf(ofp," -hspscan_lownumb [0] low complexity numb level, 0 means no special low complexity scores\n"); fprintf(ofp," -hspscan_avgext [-6] average extension minimum in hsp extension\n"); } %func makes a hspscan interface from the command line %% HSPScanInterfacePara * new_HSPScanInterfacePara_from_argv(int * argc,char ** argv) { char * temp; HSPScanInterfacePara * out; out = HSPScanInterfacePara_std(); if( (temp = strip_out_assigned_argument(argc,argv,"hspscan_impl")) != NULL ) { if( strcmp(temp,"vanilla") == 0 ) { out->implementation = HSPSCAN_IMPLEMENTATION_VANILLA; } else if ( strcmp(temp,"threaded") == 0 ) { out->implementation = HSPSCAN_IMPLEMENTATION_THREADED; } else if ( strcmp(temp,"twohit") == 0 ) { out->implementation = HSPSCAN_IMPLEMENTATION_TWOHIT; } else { fatal("Cannot parse %s as an implementation, exiting early before this gets snarled up",temp); } } strip_out_integer_argument(argc,argv,"hspscan_maxres",&out->max_results); strip_out_integer_argument(argc,argv,"hspscan_numb",&out->numb_level); strip_out_integer_argument(argc,argv,"hspscan_worddepth",&out->word_depth); strip_out_integer_argument(argc,argv,"hspscan_minword",&out->min_word_score); strip_out_integer_argument(argc,argv,"hspscan_minhsp",&out->min_hsp_score); strip_out_integer_argument(argc,argv,"hspscan_link_width",&out->hsp_link_width); strip_out_integer_argument(argc,argv,"hspscan_link_length",&out->hsp_link_length); strip_out_integer_argument(argc,argv,"hspscan_verbosity",&out->verbosity); strip_out_integer_argument(argc,argv,"hspscan_lownumb",&out->low_numb); strip_out_integer_argument(argc,argv,"hspscan_avgext",&out->hsp_avg_ext); return out; } %func makes a standard hsp scan interface para %% HSPScanInterfacePara * HSPScanInterfacePara_std(void) { HSPScanInterfacePara * out; out = HSPScanInterfacePara_alloc(); out->min_score = 20; out->max_results = 100; out->use_protein_heuristic = TRUE; out->numb_level = 1000; out->word_depth = 2; out->min_word_score = 14; out->min_hsp_score = 22; out->hsp_link_width = 30; out->hsp_link_length = 150; out->hsp_avg_ext = -6; out->implementation = HSPSCAN_IMPLEMENTATION_VANILLA; out->verbosity = 0; out->low_numb = 0; return out; } %func Frees overrides dynamite default %% !deconstructor HSPScanInterface * free_HSPScanInterface(HSPScanInterface * hsi) { if( hsi == NULL ) { return NULL; } (*hsi->free_data)(hsi->data); ckfree(hsi); return NULL; } %} wise-2.4.1/src/dynlibsrc/shattermatrix.c0000644000175000001440000003662610670453713017717 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "shattermatrix.h" /* Function: fetch_cell_value_ShatterMatrix(sm,ipos,jpos,state) * * Descrip: Gets the actual value from cell * * * Arg: sm [UNKN ] Undocumented argument [ShatterMatrix *] * Arg: ipos [UNKN ] Undocumented argument [int] * Arg: jpos [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ # line 32 "shattermatrix.dy" int fetch_cell_value_ShatterMatrix(ShatterMatrix * sm,int ipos,int jpos,int state) { int * ret; ret = fetch_cell_from_ShatterMatrix(sm,ipos,jpos); return ret[state]; } /* Function: fetch_cell_from_ShatterMatrix(sm,ipos,jpos) * * Descrip: gets int * pointer in the right place for this cell * * * Arg: sm [UNKN ] Undocumented argument [ShatterMatrix *] * Arg: ipos [UNKN ] Undocumented argument [int] * Arg: jpos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int *] * */ # line 44 "shattermatrix.dy" int * fetch_cell_from_ShatterMatrix(ShatterMatrix * sm,int ipos,int jpos) { int i; int offseti; int offsetj; assert(sm); for(i=0;ilen;i++) { if( ipos >= sm->smc[i]->starti && ipos < sm->smc[i]->endi && jpos >= sm->smc[i]->startj && jpos < sm->smc[i]->endj ) { /* great! */ /* offset into this */ offseti = ipos - sm->smc[i]->starti; offsetj = jpos - sm->smc[i]->startj; return sm->smc[i]->mat[offseti]+(offsetj*sm->cell_length); } } /* for(i=0;icell_length;i++) { if( sm->null_cell[i] != -100000 ) { fatal("At position %d,%d fetched null cell with %d\n",ipos,jpos,sm->null_cell[i]); } } fprintf(stderr," ...null cell %d,%d\n",ipos,jpos); */ return sm->null_cell; } /* Function: new_ShatterMatrix(dpenv,cell_length,jlength,special_length) * * Descrip: Makes a new shattermatrix - needs to know the cell length * and special length * * * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: cell_length [UNKN ] Undocumented argument [int] * Arg: jlength [UNKN ] Undocumented argument [int] * Arg: special_length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ShatterMatrix *] * */ # line 84 "shattermatrix.dy" ShatterMatrix * new_ShatterMatrix(DPEnvelope * dpenv,int cell_length,int jlength,int special_length) { int i; ShatterMatrix * out; out = ShatterMatrix_alloc_len(dpenv->len); out->cell_length = cell_length; out->null_cell = calloc(cell_length,sizeof(int)); for(i=0;inull_cell[i] = -100000; } for(i=0;ilen;i++) { auto DPUnit * dpu = dpenv->dpu[i]; if( dpu->type == DPENV_RECT ) { add_ShatterMatrix(out,new_ShatterMatrixComponent(dpu->starti,dpu->starti+dpu->height,dpu->startj,dpu->startj+dpu->length,cell_length)); } else if ( dpu->type == DPENV_DIAG ) { add_ShatterMatrix(out,new_ShatterMatrixComponent(dpu->starti-dpu->height,dpu->starti+dpu->height+dpu->length,dpu->startj-dpu->height,dpu->startj+dpu->height+dpu->length,cell_length)); } else { fatal("Do not understand type %d",dpu->type); } } out->special = calloc(special_length,sizeof(int*)); for(i=0;ispecial[i] = calloc(jlength,sizeof(int)); } return out; } /* Function: new_ShatterMatrixComponent(starti,endi,startj,endj,cell_length) * * Descrip: Makes a new ShatterMatrixComponent - needs to know the cell length and start/end * * * Arg: starti [UNKN ] Undocumented argument [int] * Arg: endi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: endj [UNKN ] Undocumented argument [int] * Arg: cell_length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ShatterMatrixComponent *] * */ # line 120 "shattermatrix.dy" ShatterMatrixComponent * new_ShatterMatrixComponent(int starti,int endi,int startj,int endj,int cell_length) { ShatterMatrixComponent * out; int i; int j; int leni; assert(starti < endi); assert(startj < endj); assert(cell_length > 0); out = ShatterMatrixComponent_alloc(); out->starti = starti; out->endi = endi; out->startj = startj; out->endj = endj; leni = endi - starti; /* fprintf(stderr,"Allocating area of %d,%d %d cells\n",leni,(endj-startj),leni*(endj-startj));*/ out->mat = calloc(leni,sizeof(int *)); for(i=0;imat[i] = calloc((endj-startj)*cell_length,sizeof(int)); } return out; } # line 160 "shattermatrix.c" /* Function: hard_link_ShatterMatrixComponent(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShatterMatrixComponent *] * * Return [UNKN ] Undocumented return value [ShatterMatrixComponent *] * */ ShatterMatrixComponent * hard_link_ShatterMatrixComponent(ShatterMatrixComponent * obj) { if( obj == NULL ) { warn("Trying to hard link to a ShatterMatrixComponent object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ShatterMatrixComponent_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShatterMatrixComponent *] * */ ShatterMatrixComponent * ShatterMatrixComponent_alloc(void) { ShatterMatrixComponent * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ShatterMatrixComponent *) ckalloc (sizeof(ShatterMatrixComponent))) == NULL) { warn("ShatterMatrixComponent_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->mat = NULL; out->starti = 0; out->startj = 0; out->endi = 0; out->endj = 0; return out; } /* Function: free_ShatterMatrixComponent(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShatterMatrixComponent *] * * Return [UNKN ] Undocumented return value [ShatterMatrixComponent *] * */ ShatterMatrixComponent * free_ShatterMatrixComponent(ShatterMatrixComponent * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ShatterMatrixComponent obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->mat != NULL) ckfree(obj->mat); ckfree(obj); return NULL; } /* Function: swap_ShatterMatrix(list,i,j) * * Descrip: swap function: an internal for qsort_ShatterMatrix * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ShatterMatrixComponent **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ShatterMatrix(ShatterMatrixComponent ** list,int i,int j) { ShatterMatrixComponent * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ShatterMatrix(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ShatterMatrix which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ShatterMatrixComponent **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ShatterMatrix(ShatterMatrixComponent ** list,int left,int right,int (*comp)(ShatterMatrixComponent * ,ShatterMatrixComponent * )) { int i,last; if( left >= right ) return; swap_ShatterMatrix(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ShatterMatrix (list,++last,i); } swap_ShatterMatrix (list,left,last); qsort_ShatterMatrix(list,left,last-1,comp); qsort_ShatterMatrix(list,last+1,right,comp); } /* Function: sort_ShatterMatrix(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ShatterMatrix * * * Arg: obj [UNKN ] Object containing list [ShatterMatrix *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ShatterMatrix(ShatterMatrix * obj,int (*comp)(ShatterMatrixComponent *, ShatterMatrixComponent *)) { qsort_ShatterMatrix(obj->smc,0,obj->len-1,comp); return; } /* Function: expand_ShatterMatrix(obj,len) * * Descrip: Really an internal function for add_ShatterMatrix * * * Arg: obj [UNKN ] Object which contains the list [ShatterMatrix *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ShatterMatrix(ShatterMatrix * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_ShatterMatrix called with no need"); return TRUE; } if( (obj->smc = (ShatterMatrixComponent ** ) ckrealloc (obj->smc,sizeof(ShatterMatrixComponent *)*len)) == NULL) { warn("ckrealloc failed for expand_ShatterMatrix, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_ShatterMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ShatterMatrix *] * Arg: add [OWNER] Object to add to the list [ShatterMatrixComponent *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ShatterMatrix(ShatterMatrix * obj,ShatterMatrixComponent * add) { if( obj->len >= obj->maxlen) { if( expand_ShatterMatrix(obj,obj->len + ShatterMatrixLISTLENGTH) == FALSE) return FALSE; } obj->smc[obj->len++]=add; return TRUE; } /* Function: flush_ShatterMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ShatterMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ShatterMatrix(ShatterMatrix * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->smc[i] != NULL) { free_ShatterMatrixComponent(obj->smc[i]); obj->smc[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: ShatterMatrix_alloc_std(void) * * Descrip: Equivalent to ShatterMatrix_alloc_len(ShatterMatrixLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ShatterMatrix *] * */ ShatterMatrix * ShatterMatrix_alloc_std(void) { return ShatterMatrix_alloc_len(ShatterMatrixLISTLENGTH); } /* Function: ShatterMatrix_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ShatterMatrix *] * */ ShatterMatrix * ShatterMatrix_alloc_len(int len) { ShatterMatrix * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = ShatterMatrix_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->smc = (ShatterMatrixComponent ** ) ckcalloc (len,sizeof(ShatterMatrixComponent *))) == NULL) { warn("Warning, ckcalloc failed in ShatterMatrix_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_ShatterMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShatterMatrix *] * * Return [UNKN ] Undocumented return value [ShatterMatrix *] * */ ShatterMatrix * hard_link_ShatterMatrix(ShatterMatrix * obj) { if( obj == NULL ) { warn("Trying to hard link to a ShatterMatrix object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ShatterMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShatterMatrix *] * */ ShatterMatrix * ShatterMatrix_alloc(void) { ShatterMatrix * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ShatterMatrix *) ckalloc (sizeof(ShatterMatrix))) == NULL) { warn("ShatterMatrix_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->smc = NULL; out->len = out->maxlen = 0; out->special = NULL; out->cell_length = 0; out->special_length = 0; out->null_cell = NULL; return out; } /* Function: free_ShatterMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShatterMatrix *] * * Return [UNKN ] Undocumented return value [ShatterMatrix *] * */ ShatterMatrix * free_ShatterMatrix(ShatterMatrix * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ShatterMatrix obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->smc != NULL) { for(i=0;ilen;i++) { if( obj->smc[i] != NULL) free_ShatterMatrixComponent(obj->smc[i]); } ckfree(obj->smc); } if( obj->special != NULL) ckfree(obj->special); if( obj->null_cell != NULL) ckfree(obj->null_cell); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/shattermatrix.h0000644000175000001440000002210210670453713017704 0ustar philippusers#ifndef DYNAMITEshattermatrixHEADERFILE #define DYNAMITEshattermatrixHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "dpenvelope.h" #define ShatterMatrixLISTLENGTH 1024 struct Wise2_ShatterMatrixComponent { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int ** mat; int starti; int startj; int endi; int endj; } ; /* ShatterMatrixComponent defined */ #ifndef DYNAMITE_DEFINED_ShatterMatrixComponent typedef struct Wise2_ShatterMatrixComponent Wise2_ShatterMatrixComponent; #define ShatterMatrixComponent Wise2_ShatterMatrixComponent #define DYNAMITE_DEFINED_ShatterMatrixComponent #endif struct Wise2_ShatterMatrix { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ShatterMatrixComponent ** smc; int len;/* len for above smc */ int maxlen; /* maxlen for above smc */ int ** special; int cell_length; int special_length; int * null_cell; } ; /* ShatterMatrix defined */ #ifndef DYNAMITE_DEFINED_ShatterMatrix typedef struct Wise2_ShatterMatrix Wise2_ShatterMatrix; #define ShatterMatrix Wise2_ShatterMatrix #define DYNAMITE_DEFINED_ShatterMatrix #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: fetch_cell_value_ShatterMatrix(sm,ipos,jpos,state) * * Descrip: Gets the actual value from cell * * * Arg: sm [UNKN ] Undocumented argument [ShatterMatrix *] * Arg: ipos [UNKN ] Undocumented argument [int] * Arg: jpos [UNKN ] Undocumented argument [int] * Arg: state [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_fetch_cell_value_ShatterMatrix(ShatterMatrix * sm,int ipos,int jpos,int state); #define fetch_cell_value_ShatterMatrix Wise2_fetch_cell_value_ShatterMatrix /* Function: fetch_cell_from_ShatterMatrix(sm,ipos,jpos) * * Descrip: gets int * pointer in the right place for this cell * * * Arg: sm [UNKN ] Undocumented argument [ShatterMatrix *] * Arg: ipos [UNKN ] Undocumented argument [int] * Arg: jpos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int *] * */ int * Wise2_fetch_cell_from_ShatterMatrix(ShatterMatrix * sm,int ipos,int jpos); #define fetch_cell_from_ShatterMatrix Wise2_fetch_cell_from_ShatterMatrix /* Function: new_ShatterMatrix(dpenv,cell_length,jlength,special_length) * * Descrip: Makes a new shattermatrix - needs to know the cell length * and special length * * * Arg: dpenv [UNKN ] Undocumented argument [DPEnvelope *] * Arg: cell_length [UNKN ] Undocumented argument [int] * Arg: jlength [UNKN ] Undocumented argument [int] * Arg: special_length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ShatterMatrix *] * */ ShatterMatrix * Wise2_new_ShatterMatrix(DPEnvelope * dpenv,int cell_length,int jlength,int special_length); #define new_ShatterMatrix Wise2_new_ShatterMatrix /* Function: new_ShatterMatrixComponent(starti,endi,startj,endj,cell_length) * * Descrip: Makes a new ShatterMatrixComponent - needs to know the cell length and start/end * * * Arg: starti [UNKN ] Undocumented argument [int] * Arg: endi [UNKN ] Undocumented argument [int] * Arg: startj [UNKN ] Undocumented argument [int] * Arg: endj [UNKN ] Undocumented argument [int] * Arg: cell_length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ShatterMatrixComponent *] * */ ShatterMatrixComponent * Wise2_new_ShatterMatrixComponent(int starti,int endi,int startj,int endj,int cell_length); #define new_ShatterMatrixComponent Wise2_new_ShatterMatrixComponent /* Function: hard_link_ShatterMatrixComponent(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShatterMatrixComponent *] * * Return [UNKN ] Undocumented return value [ShatterMatrixComponent *] * */ ShatterMatrixComponent * Wise2_hard_link_ShatterMatrixComponent(ShatterMatrixComponent * obj); #define hard_link_ShatterMatrixComponent Wise2_hard_link_ShatterMatrixComponent /* Function: ShatterMatrixComponent_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShatterMatrixComponent *] * */ ShatterMatrixComponent * Wise2_ShatterMatrixComponent_alloc(void); #define ShatterMatrixComponent_alloc Wise2_ShatterMatrixComponent_alloc /* Function: free_ShatterMatrixComponent(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShatterMatrixComponent *] * * Return [UNKN ] Undocumented return value [ShatterMatrixComponent *] * */ ShatterMatrixComponent * Wise2_free_ShatterMatrixComponent(ShatterMatrixComponent * obj); #define free_ShatterMatrixComponent Wise2_free_ShatterMatrixComponent /* Function: add_ShatterMatrix(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ShatterMatrix *] * Arg: add [OWNER] Object to add to the list [ShatterMatrixComponent *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_ShatterMatrix(ShatterMatrix * obj,ShatterMatrixComponent * add); #define add_ShatterMatrix Wise2_add_ShatterMatrix /* Function: flush_ShatterMatrix(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ShatterMatrix *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_ShatterMatrix(ShatterMatrix * obj); #define flush_ShatterMatrix Wise2_flush_ShatterMatrix /* Function: ShatterMatrix_alloc_std(void) * * Descrip: Equivalent to ShatterMatrix_alloc_len(ShatterMatrixLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ShatterMatrix *] * */ ShatterMatrix * Wise2_ShatterMatrix_alloc_std(void); #define ShatterMatrix_alloc_std Wise2_ShatterMatrix_alloc_std /* Function: ShatterMatrix_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ShatterMatrix *] * */ ShatterMatrix * Wise2_ShatterMatrix_alloc_len(int len); #define ShatterMatrix_alloc_len Wise2_ShatterMatrix_alloc_len /* Function: hard_link_ShatterMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShatterMatrix *] * * Return [UNKN ] Undocumented return value [ShatterMatrix *] * */ ShatterMatrix * Wise2_hard_link_ShatterMatrix(ShatterMatrix * obj); #define hard_link_ShatterMatrix Wise2_hard_link_ShatterMatrix /* Function: ShatterMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShatterMatrix *] * */ ShatterMatrix * Wise2_ShatterMatrix_alloc(void); #define ShatterMatrix_alloc Wise2_ShatterMatrix_alloc /* Function: free_ShatterMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShatterMatrix *] * * Return [UNKN ] Undocumented return value [ShatterMatrix *] * */ ShatterMatrix * Wise2_free_ShatterMatrix(ShatterMatrix * obj); #define free_ShatterMatrix Wise2_free_ShatterMatrix /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_ShatterMatrix(ShatterMatrixComponent ** list,int i,int j) ; #define swap_ShatterMatrix Wise2_swap_ShatterMatrix void Wise2_qsort_ShatterMatrix(ShatterMatrixComponent ** list,int left,int right,int (*comp)(ShatterMatrixComponent * ,ShatterMatrixComponent * )); #define qsort_ShatterMatrix Wise2_qsort_ShatterMatrix void Wise2_sort_ShatterMatrix(ShatterMatrix * obj,int (*comp)(ShatterMatrixComponent *, ShatterMatrixComponent *)); #define sort_ShatterMatrix Wise2_sort_ShatterMatrix boolean Wise2_expand_ShatterMatrix(ShatterMatrix * obj,int len); #define expand_ShatterMatrix Wise2_expand_ShatterMatrix #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/dnamatrix.pod0000644000175000001440000000526010670453712017334 0ustar philippusers=head1 NAME dnamatrix module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item DnaMatrix =item DnaProbMatrix =back =head1 DESCRIPTION =head2 Object DnaMatrix =over =item score[5][5] Type [Score] Scalar No documentation =back No documentation for DnaMatrix =head2 Member functions of DnaMatrix =over =item hard_link_DnaMatrix &Wise2::DnaMatrix::hard_link_DnaMatrix(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [DnaMatrix *] Return [UNKN ] Undocumented return value [DnaMatrix *] =item alloc &Wise2::DnaMatrix::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [DnaMatrix *] =back =head2 Object DnaProbMatrix =over =item prob[5][5] Type [Probability] Scalar No documentation =back No documentation for DnaProbMatrix =head2 Member functions of DnaProbMatrix =over =item flat_null_DnaProbMatrix &Wise2::DnaProbMatrix::flat_null_DnaProbMatrix(dpm) makes a odds of dpm via a 0.25 factor into each base. Argument dpm [UNKN ] Undocumented argument [DnaProbMatrix *] Return [UNKN ] Undocumented return value [void] =item hard_link_DnaProbMatrix &Wise2::DnaProbMatrix::hard_link_DnaProbMatrix(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [DnaProbMatrix *] Return [UNKN ] Undocumented return value [DnaProbMatrix *] =item alloc &Wise2::DnaProbMatrix::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [DnaProbMatrix *] =back =over =item identity_DnaMatrix &Wise2::identity_DnaMatrix(id_score,mismatch) makes an idenity matrix wth id_score on the leading diagonal and mismatch elsewhere. Argument id_score [UNKN ] score of idenities [Score] Argument mismatch [UNKN ] score of mistmatches [Score] Return [UNKN ] Undocumented return value [DnaMatrix *] =item DnaProbMatrix_from_match &Wise2::DnaProbMatrix_from_match(match,nmask_type) Makes a probability matrix from simple match/mismatch probabilities. Argument match [UNKN ] Undocumented argument [Probability] Argument nmask_type [UNKN ] Undocumented argument [int] Return [UNKN ] Undocumented return value [DnaProbMatrix *] =item DnaMatrix_from_DnaProbMatrix &Wise2::DnaMatrix_from_DnaProbMatrix(dpm) Maps probabilities to scores Argument dpm [UNKN ] Undocumented argument [DnaProbMatrix *] Return [UNKN ] Undocumented return value [DnaMatrix *] =back wise-2.4.1/src/dynlibsrc/dnamatrix.tex0000644000175000001440000000551510670453712017355 0ustar philippusers\section{dnamatrix} \label{module_dnamatrix} This module contains the following objects \begin{itemize} \item \ref{object_DnaMatrix} DnaMatrix \item \ref{object_DnaProbMatrix} DnaProbMatrix \item This module also contains some factory methods \end{itemize} \subsection{dnamatrix factory methods} \subsubsection{identity_DnaMatrix} \begin{description} \item[External C] {\tt Wise2_identity_DnaMatrix (id_score,mismatch)} \item[Perl] {\tt &Wise2::identity_DnaMatrix (id_score,mismatch)} \end{description} Arguments \begin{description} \item[id_score] [UNKN ] score of idenities [Score] \item[mismatch] [UNKN ] score of mistmatches [Score] \item[returns] [UNKN ] Undocumented return value [DnaMatrix *] \end{description} makes an idenity matrix wth id_score on the leading diagonal and mismatch elsewhere. \subsubsection{DnaProbMatrix_from_match} \begin{description} \item[External C] {\tt Wise2_DnaProbMatrix_from_match (match,nmask_type)} \item[Perl] {\tt &Wise2::DnaProbMatrix_from_match (match,nmask_type)} \end{description} Arguments \begin{description} \item[match] [UNKN ] Undocumented argument [Probability] \item[nmask_type] [UNKN ] Undocumented argument [int] \item[returns] [UNKN ] Undocumented return value [DnaProbMatrix *] \end{description} Makes a probability matrix from simple match/mismatch probabilities. \subsubsection{DnaMatrix_from_DnaProbMatrix} \begin{description} \item[External C] {\tt Wise2_DnaMatrix_from_DnaProbMatrix (dpm)} \item[Perl] {\tt &Wise2::DnaMatrix_from_DnaProbMatrix (dpm)} \end{description} Arguments \begin{description} \item[dpm] [UNKN ] Undocumented argument [DnaProbMatrix *] \item[returns] [UNKN ] Undocumented return value [DnaMatrix *] \end{description} Maps probabilities to scores \subsection{Object DnaMatrix} \label{object_DnaMatrix} The DnaMatrix object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{score[5][5]} Type [Score : Scalar] No documentation \end{description} No documentation for DnaMatrix Member functions of DnaMatrix \subsection{Object DnaProbMatrix} \label{object_DnaProbMatrix} The DnaProbMatrix object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{prob[5][5]} Type [Probability : Scalar] No documentation \end{description} No documentation for DnaProbMatrix Member functions of DnaProbMatrix \subsubsection{flat_null_DnaProbMatrix} \begin{description} \item[External C] {\tt Wise2_flat_null_DnaProbMatrix (dpm)} \item[Perl] {\tt &Wise2::DnaProbMatrix::flat_null_DnaProbMatrix (dpm)} \item[Perl-OOP call] {\tt $obj->flat_null_DnaProbMatrix()} \end{description} Arguments \begin{description} \item[dpm] [UNKN ] Undocumented argument [DnaProbMatrix *] \item[returns] Nothing - no return value \end{description} makes a odds of dpm via a 0.25 factor into each base. wise-2.4.1/src/dynlibsrc/genomicdb.typemap0000644000175000001440000000036010670453712020165 0ustar philippusers TYPEMAP Wise2_GenomicDB * T_Wise2_GenomicDB INPUT T_Wise2_GenomicDB $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_GenomicDB *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_GenomicDB sv_setref_pv($arg, "Wise2::GenomicDB", (void*) $var); wise-2.4.1/src/dynlibsrc/singlenumberspace.dy0000644000175000001440000000713707626362477020730 0ustar philippusers %{ #include "shadowseq.h" #define SingleNumberSpaceLISTLENGTH 1024 %} struct SingleNumberSequence int start int end ShadowSequence * seq !link struct SingleNumberSpace int current_end SingleNumberSequence ** sns !list SingleNumberSequence * last_accessed !link int average_len int is_static !def="0" int max_length !def="1000" %{ #include "singlenumberspace.h" %func New return using binary choping %% SingleNumberSequence * lookup_ShadowSequence_SingleNumberSpace(SingleNumberSpace * space,int pos) { int index_pos; assert(pos < space->current_end); if( space->is_static != 0 ) { /* can make explicit calculation for position */ index_pos = (int) (pos / space->average_len); if( space->sns[index_pos]->start == -1 ) { /* was a padding position */ for(index_pos--;index_pos >= 0 && space->sns[index_pos]->start == -1;index_pos--) { fprintf(stderr,"Regressed %d with %d [pos %d]\n",index_pos,space->sns[index_pos]->start,pos); } assert(index_pos >= 0 ); } if( space->sns[index_pos] == NULL ) { fatal("Going to return %d for %d with %d - max %d\n",index_pos,pos,space->average_len,space->current_end); } return space->sns[index_pos]; } assert(pos < space->current_end); index_pos = find_position_SingleNumberSpace(space,0,space->len-1,pos); return space->sns[index_pos]; } %func Recursive function for finding position %% int find_position_SingleNumberSpace(SingleNumberSpace * space,int lower,int higher,int position) { int mid; /* fprintf(stderr,"To find position %d Entering with.... %d to %d\n",position,lower,higher); */ if( lower+2 >= higher ) { if( position >= space->sns[lower]->start && position < space->sns[lower]->end ) return lower; if( position >= space->sns[higher]->start && position < space->sns[higher]->end ) return higher; } mid = (lower + (int)((higher-lower)/2)); if( position >= space->sns[mid]->start && position < space->sns[mid]->end ) return mid; if( position >= space->sns[mid]->end ) { /* top half */ return find_position_SingleNumberSpace(space,mid,higher,position); } else { return find_position_SingleNumberSpace(space,lower,mid,position); } } %func Adds a sequence to a single number space, giving out the start position for this sequence %% int add_ShadowSequence_SingleNumberSpace(SingleNumberSpace * space,ShadowSequence * seq) { int seq_size = 1; int i; SingleNumberSequence * a; SingleNumberSequence * dummy; assert(space); assert(seq); a = SingleNumberSequence_alloc(); a->start = space->current_end; if( space->is_static != 0 ) { if( seq->seq->len > space->max_length ) { seq_size = (seq->seq->len / space->max_length) +1; } else { seq_size = 1; } a->end = space->current_end + (space->max_length*seq_size); space->average_len = space->max_length; } else { a->end = space->current_end + seq->seq->len; space->average_len = a->end / space->len; } a->seq = seq; add_SingleNumberSpace(space,a); /* pad for long sequences */ if( seq_size > 1 ) { for(i=1;istart = -1; dummy->end = -1; dummy->seq = NULL; add_SingleNumberSpace(space,dummy); } } space->current_end = a->end; return a->start; } %func Provides a new single number space %% SingleNumberSpace * new_SingleNumberSpace(int has_maxlen,int max_length) { SingleNumberSpace * out; out = SingleNumberSpace_alloc_std(); out->is_static = has_maxlen; out->max_length = max_length; return out; } %} wise-2.4.1/src/dynlibsrc/hspthreadeddb.dy0000644000175000001440000001537110421463722020000 0ustar philippusers %{ #include "hsplookupscan.h" #include "arrayseqlookup.h" #define HSPThreadedDatabaseLISTLENGTH 32 #define DBTHREAD_MAX_SIZE 64 %} struct HSPDatabaseSegment HSPScanInterface * hspi SeqLookupInterface * sli Sequence * query !link // for running HSPScanInterfacePara * run_para !link // for running LinearHSPmanager * lm !link // for retrieving results SeqLookupLoadPara * load_para !link // for loading SequenceDB * loaddb !link // for loading pthread_mutex_t * dblock !link // for loading long int * count !link // for loading boolean * is_first !link // for loading struct HSPThreadedDatabase HSPDatabaseSegment ** seg !list %{ #include "hspthreadeddb.h" #define HAS_PTHREAD_SETSCOPE #define HAS_PTHREAD_SETCONCURRENCY %func Makes a HSPScanInterface from a loaded threaded database %% HSPScanInterface * new_HSPScanInterface_from_HSPThreadedDatabase(HSPThreadedDatabase * tdb) { HSPScanInterface * out; assert(tdb != NULL); assert(tdb->seg[0] != NULL); assert(tdb->seg[0]->sli != NULL); out = HSPScanInterface_alloc(); out->data = tdb; out->scan_query = scan_query_hspthreadeddb; out->free_data = free_data_hspthreadeddb; return out; } %func frees data %% void free_data_hspthreadeddb(void * d) { HSPThreadedDatabase * tdb = (HSPThreadedDatabase *) d; free_HSPThreadedDatabase(tdb); } %func Does the scan query for the HSPThreadedDatabase %% LinearHSPmanager * scan_query_hspthreadeddb(void * d,Sequence * query,HSPScanInterfacePara * para) { HSPThreadedDatabase * tdb; pthread_t thread_pool[DBTHREAD_MAX_SIZE]; pthread_attr_t pat; int i,j; int err; LinearHSPmanager * out; LinearHSPmanager * real_out; tdb = (HSPThreadedDatabase *) d; pthread_attr_init(&pat); #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY /* pthread_setconcurrency(tdb->len+1);*/ #endif /* set concurrency */ for(i=0;ilen;i++) { tdb->seg[i]->query = query; tdb->seg[i]->run_para = para; tdb->seg[i]->lm = NULL; if( (err = pthread_create(&(thread_pool[i]),&pat,threadeddb_scan_worker,(void*)tdb->seg[i])) != 0 ) { fatal("Unable to make thread %d with error %d",i,err); } } for(i=0;ilen;i++) { pthread_join(thread_pool[i],NULL); } fprintf(stderr,"All threads have run\n"); if( VERBOSITY_CHECK(4,para->verbosity) ) { info("All threads have run"); } out = LinearHSPmanager_alloc_std(); for(i=0;ilen;i++) { assert(tdb->seg[i]->lm != NULL); for(j=0;jseg[i]->lm->len;j++) { add_LinearHSPmanager(out,hard_link_HSPset(tdb->seg[i]->lm->set[j])); } } qsort(out->set,out->len,sizeof(HSPset*),compare_HSPset_score_qsort); /* this is a bit evil */ real_out = LinearHSPmanager_alloc_len(para->max_results); for(i=0;imax_results && ilen;i++) { add_LinearHSPmanager(real_out,out->set[i]); } /* out->len = para->max_results;*/ if( VERBOSITY_CHECK(4,para->verbosity) ) { info("Finish combine/sort with %d elements",real_out->len); } return out; } %func internal scan function %% void * threadeddb_scan_worker(void * d) { HSPDatabaseSegment * seg; seg = (HSPDatabaseSegment *) d; seg->lm = (*seg->hspi->scan_query)(seg->hspi->data,seg->query,seg->run_para); fprintf(stderr,"For segment %d, finished query with %d (%d) linear\n",seg,(int)seg->lm,seg->lm->len); return NULL; } %func Makes a new segmented database suitable for threading %% HSPThreadedDatabase * new_HSPThreadedDatabase(int segments,int array_numb_level) { HSPThreadedDatabase * out; int i; HSPDatabaseSegment * seg; out = HSPThreadedDatabase_alloc_len(segments); for(i=0;ihspi = NULL; seg->sli = new_ArraySeq_SeqLookupInterface(26*26*26*26*26,array_numb_level); add_HSPThreadedDatabase(out,seg); } return out; } %func Loades a segmented database %% void load_HSPThreadedDatabase(HSPThreadedDatabase * db,SequenceDB * sdb,SeqLookupLoadPara * para,CompMat * mat,int drop_off,int score_cutoff) { pthread_mutex_t dblock; pthread_t thread_pool[DBTHREAD_MAX_SIZE]; pthread_attr_t pat; int i; int err; long int count = 0; boolean is_first = 1; pthread_attr_init(&pat); #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #ifdef HAS_PTHREAD_SETCONCURRENCY /* needed to make sure one thread doesn't dominate the IO */ pthread_attr_setschedpolicy(&pat,SCHED_RR); #endif /* set concurrency */ if( pthread_mutex_init(&dblock,NULL) != 0 ) { fatal("Unable to make mutex for db lock"); } for(i=0;ilen;i++) { db->seg[i]->load_para = para; db->seg[i]->loaddb = sdb; db->seg[i]->dblock = &dblock; db->seg[i]->count = &count; db->seg[i]->is_first = &is_first; } for(i=0;ilen;i++) { if( (err = pthread_create(&(thread_pool[i]),&pat,threaddb_load_worker,(void*)db->seg[i])) != 0 ) { fatal("Unable to make thread %d with error %d",i,err); } } for(i=0;ilen;i++) { pthread_join(thread_pool[i],NULL); } /* attach scan interfaces to the databases */ for(i=0;ilen;i++) { db->seg[i]->hspi = new_one_off_HSPScanInterface(db->seg[i]->sli,mat,drop_off,score_cutoff); } return; } %func load threaddb %% void * threaddb_load_worker(void * d) { HSPDatabaseSegment * seg = (HSPDatabaseSegment *) d; Sequence * seq = NULL; long int temp_count; int ret; long load_count = 0; while( 1 ) { /* try to get lock */ if( pthread_mutex_lock(seg->dblock) != 0 ) { fatal("Unable to get mutex lock"); } /* try to get this sequence */ if( *seg->is_first == 1 ) { seq = init_SequenceDB(seg->loaddb,&ret); *seg->is_first = 0; } else { seq = get_next_SequenceDB(seg->loaddb); } /* if seq is NULL, or count > truncate end db */ if( seq == NULL || (seg->load_para->truncate> 0 && *seg->count > seg->load_para->truncate) ) { info("Thread loaded %d entries",load_count); pthread_mutex_unlock(seg->dblock); return NULL; } /* if not, up count, check if we need to report */ (*seg->count)++; temp_count = *seg->count; /* can now remove lock */ pthread_mutex_unlock(seg->dblock); if( seg->load_para->report_stagger > 0 && (temp_count % seg->load_para->report_stagger == 0) ) { info("Threaded db load %d sequences for sli %d at %s",temp_count,seg->sli,seq->name); } /* now we need to add this sequence */ add_SeqLookupInterface(seg->sli,seq); load_count++; (*seg->sli->add_seq)(seg->sli->data,seq,seg->load_para); } return NULL; } %} wise-2.4.1/src/dynlibsrc/test_genomic.c0000644000175000001440000000051307313404542017456 0ustar philippusers#include "genomic.h" main(int argc,char ** argv) { Genomic * gen; Genomic * gen2; Genomic * gen3; gen = read_fasta_file_Genomic(argv[1],10); show_Genomic(gen,stdout); gen2 = reverse_complement_Genomic(gen); show_Genomic(gen2,stdout); gen3 = truncate_Genomic(gen,1,50); show_Genomic(gen3,stdout); } wise-2.4.1/src/dynlibsrc/dpenvelope.dy0000644000175000001440000001242107611245645017342 0ustar philippusers %{ #include "wisebase.h" typedef enum dpenvelope_type { DPENV_RECT = 0, DPENV_DIAG } dpenv_type; #define DPEnvelopeLISTLENGTH 32 %} struct DPUnit int type !def="DPENV_RECT" int starti int startj int height // for diagonal units int length // for diagonal units struct DPEnvelope DPUnit ** dpu !list DPUnit * bbox int starti int startj int endi int endj %{ #include "dpenvelope.h" %func Helper function that checks whether things overlap or not %% boolean overlap_DPUnit(DPUnit * a,DPUnit * b) { int diag_a; int diag_b; if( a->type == DPENV_DIAG && b->type == DPENV_DIAG ) { diag_a = a->starti - a->startj; diag_b = b->starti - b->startj; if( diag_a - a->height > diag_b + b->height || diag_a + a->height < diag_b + b->height ) { return FALSE; } diag_a = a->starti + a->startj; diag_b = b->starti + b->startj; if( diag_a + a->length < diag_b || diag_a > diag_b + b->length ) { return FALSE; } return TRUE; } if( a->type == DPENV_RECT && b->type == DPENV_RECT ) { fatal("Not implemented rectangle overlap!"); } fatal("Not implemented rectangle - diag overlap!"); } %func Helper function that also opens the filename %% DPEnvelope * read_DPEnvelope_file(char * filename) { FILE * ifp; DPEnvelope * dpenv; ifp = openfile(filename,"r"); if( ifp == NULL ) { error("Could not open file with %s",filename); return NULL; } dpenv = read_DPEnvelope(ifp); fclose(ifp); return dpenv; } %func Reads a DPEnvelope from a file %% DPEnvelope * read_DPEnvelope(FILE * ifp) { char buffer[MAXLINE]; char ** base; char ** str; DPEnvelope * out; DPUnit * unit; out = DPEnvelope_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { base = str = breakstring(buffer,spacestr); unit = DPUnit_alloc(); add_DPEnvelope(out,unit); if( strcmp(*str,"rect") == 0 ) { unit->type = DPENV_RECT; } else if ( strcmp(*str,"diag") == 0 ) { unit->type = DPENV_DIAG; } else { error("Cannot parse DPEnv file"); continue; } str++; if( *str == NULL ) { error("Cannot parse DPEnv file"); continue; } unit->starti = atoi(*str); str++; if( *str == NULL ) { error("Cannot parse DPEnv file"); continue; } unit->startj = atoi(*str); str++; if( *str == NULL ) { error("Cannot parse DPEnv file"); continue; } unit->height = atoi(*str); str++; if( *str == NULL ) { error("Cannot parse DPEnv file"); continue; } unit->length = atoi(*str); } return out; } %func shows structure. useful for debugging %% void show_DPEnvelope(DPEnvelope * dpe,FILE * ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,"Unit %d [%s] Start %d-%d Height: %d Length: %d\n",i,dpe->dpu[i]->type == DPENV_RECT ? "rect" : "diag",dpe->dpu[i]->starti,dpe->dpu[i]->startj,dpe->dpu[i]->height,dpe->dpu[i]->length); } } %func Tests whether this i,j position is allowed in the DPEnvelope %% boolean is_in_DPEnvelope(DPEnvelope * dpe,int i,int j) { int k; for(k=0;klen;k++) { auto DPUnit * u; u = dpe->dpu[k]; switch (u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length) ) return TRUE; else break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) return TRUE; break; default : warn("Bad DPUnit type put in. Yuk. Bad error... %d",u->type); return FALSE; } } return FALSE; } %func Should run this before using the DPEnvelope %% boolean prepare_DPEnvelope(DPEnvelope * dpe) { int i; dpe->starti = 1000000; dpe->startj = 1000000; dpe->endi = 1; dpe->endj = 1; sort_DPEnvelope_by_startj(dpe); for(i=0;ilen;i++) { if( dpe->dpu[i]->type == DPENV_RECT ) { if( dpe->starti > dpe->dpu[i]->starti-1 ) { dpe->starti = dpe->dpu[i]->starti-1; } if( dpe->startj > dpe->dpu[i]->startj-1 ) { dpe->startj = dpe->dpu[i]->startj-1; } if( dpe->endi < dpe->dpu[i]->starti+ dpe->dpu[i]->height ) { dpe->endi = dpe->dpu[i]->starti+ dpe->dpu[i]->height; } if( dpe->endj < dpe->dpu[i]->startj + dpe->dpu[i]->length ) { dpe->endj = dpe->dpu[i]->startj + dpe->dpu[i]->length; } } else { /* DIAG */ if( dpe->starti > dpe->dpu[i]->starti-dpe->dpu[i]->height ) { dpe->starti = dpe->dpu[i]->starti-dpe->dpu[i]->height; } if( dpe->startj > dpe->dpu[i]->startj-dpe->dpu[i]->height ) { dpe->startj = dpe->dpu[i]->startj-dpe->dpu[i]->height; } if( dpe->endi < dpe->dpu[i]->starti+ dpe->dpu[i]->length+dpe->dpu[i]->height ) { dpe->endi = dpe->dpu[i]->starti+ dpe->dpu[i]->length + dpe->dpu[i]->height; } if( dpe->endj < dpe->dpu[i]->startj + dpe->dpu[i]->length + dpe->dpu[i]->height ) { dpe->endj = dpe->dpu[i]->startj + dpe->dpu[i]->length + dpe->dpu[i]->height; } } } return TRUE; } %func Sorts by startj %% void sort_DPEnvelope_by_startj(DPEnvelope * dpe) { sort_DPEnvelope(dpe,compare_DPUnit_startj); } %func internal for sort by startj %type internal %% int compare_DPUnit_startj(DPUnit * one,DPUnit * two) { return one->startj - two->startj; } wise-2.4.1/src/dynlibsrc/database.h0000644000175000001440000000062607313404540016552 0ustar philippusers #ifndef DATABASE_HEADER_FILE #define DATABASE_HEADER_FILE /* * Enum for database reload success/failure */ enum return_status { DB_RETURN_UNKNOWN = 143, DB_RETURN_OK, DB_RETURN_ERROR, DB_RETURN_END }; typedef int DB_Return_Type; /* * Enum for search success/failure */ enum search_return { SEARCH_UNKNOWN = 152, SEARCH_ERROR, SEARCH_OK }; typedef int Search_Return_Type; #endif wise-2.4.1/src/dynlibsrc/cdnadb.dy0000644000175000001440000002317007313404537016413 0ustar philippusers %{ #include "sequencedb.h" #include "cdna.h" #include "hscore.h" #include "complexsequence.h" #include "complexevalset.h" typedef enum CdnaDBErrorType { CDNADB_READ_THROUGH = 0, CDNADB_FAIL_ON_ERROR = 1 } CdnaDBErrorType; %} struct cDNADB boolean is_single_seq !def="FALSE" boolean done_forward !def="FALSE" boolean forward_only !def="FALSE" ComplexSequence * forw ComplexSequence * rev SequenceDB * sdb Sequence * current ComplexSequenceEvalSet * cses CdnaDBErrorType error_handling !def="CDNADB_READ_THROUGH" !hidden double error_tol !def="0.7" %info This object hold a database of cDNA sequences. You will probably use it in one of two ways 1 A sequence formatted database, which is provided by a /SequenceDB object is used to provide the raw sequences 2 A single cDNA sequence is used. In each case this database provides both the forward and reverse strands into the system. Notice that what is exported are /ComplexSequence objects, not cDNA dna, as this is what is generally needed. These are things with splice sites calculated etc. This is why for initialisation this needs a /ComplexSequenceEvalSet of the correct type. %% api object cDNADB des free_cDNADB func get_cDNA_from_cDNADB endobject func new_cDNADB_from_single_seq func new_cDNADB endapi %{ #include "cdnadb.h" %func shows the Hscore by the cDNADB information %arg hs High Score structure ofp output file %% void show_Hscore_cDNADB(Hscore * hs,FILE * ofp) { int i; for(i=0;ilen;i++) fprintf(ofp,"Query [%20s] Target [%20s] %d\n",hs->ds[i]->query->name,hs->ds[i]->target->name,hs->ds[i]->score); } %func Gets cDNA sequence out from the cDNADB using the information stored in dataentry %simple get_entry %arg cdnadb r cDNA database de r DataEntry information %% cDNA * get_cDNA_from_cDNADB(cDNADB * cdnadb,DataEntry * de) { Sequence * seq; Sequence * temp; if( cdnadb == NULL ) { warn("Cannot get entry from a null database"); return NULL; } if( de == NULL ) { warn("Cannot get entry with a null dataentry"); return NULL; } if( cdnadb->is_single_seq == TRUE ) { if( de->is_reversed == TRUE ) return cDNA_from_Sequence(hard_link_Sequence(cdnadb->rev->seq)); else return cDNA_from_Sequence(hard_link_Sequence(cdnadb->forw->seq)); } /* we need to get out the Sequence from seqdb */ seq = get_Sequence_from_SequenceDB(cdnadb->sdb,de); if( seq == NULL ) { warn("Cannot get entry for %s from cDNA db",de->name); return NULL; } if( seq->type != SEQUENCE_DNA) { warn("Sequence from %s data entry doesn't look like DNA. Forcing it to",de->name); } force_to_dna_Sequence(seq,1.0,NULL); if( de->is_reversed == TRUE ) { temp = reverse_complement_Sequence(seq); free_Sequence(seq); seq = temp; } return cDNA_from_Sequence(seq); } %func adds information to dataentry from cDNADB will eventually add file offset and format information, but this is handled by the SequenceDB mainly. %% boolean dataentry_add_cDNADB(DataEntry * de,ComplexSequence * cs,cDNADB * cdnadb) { if( cs == NULL || cs->seq == NULL ) { warn("Adding a dataentry with a NULL complex sequence or null internal sequence. Nope!"); return FALSE; } if( cdnadb->is_single_seq == FALSE) add_SequenceDB_info_DataEntry(cdnadb->sdb,de); de->name = stringalloc(cs->seq->name); de->is_reversed = is_reversed_Sequence(cs->seq); return TRUE; } %func top level function which opens the cDNA database %arg cdnadb protein database return_status w the status of the open from database.h %% ComplexSequence * init_cDNADB(cDNADB * cdnadb,int * return_status) { ComplexSequence * cs; Sequence * seq; if( cdnadb->is_single_seq == TRUE) { *return_status = DB_RETURN_OK; cdnadb->done_forward = TRUE; return hard_link_ComplexSequence(cdnadb->forw); } /* is a seq db */ seq = init_SequenceDB(cdnadb->sdb,return_status); if( seq == NULL || *return_status == DB_RETURN_ERROR || *return_status == DB_RETURN_END ) { return NULL; /** error already reported **/ } if( force_to_dna_Sequence(seq,cdnadb->error_tol,NULL) == FALSE ) { warn("first sequence below error level, have to fail at the moment. Ooops..."); free_Sequence(seq); *return_status = DB_RETURN_ERROR; return NULL; } cdnadb->current = seq; cdnadb->done_forward = TRUE; cs = new_ComplexSequence(seq,cdnadb->cses); if( cs == NULL ) { warn("Cannot make initial ComplexSequence. Unable to error catch this. Failing!"); *return_status = DB_RETURN_ERROR; return NULL; } return cs; } %func function which reloads the database %arg last previous complex sequence, will be freed return_status w return_status of the load return o a new ComplexSequence object %% ComplexSequence * reload_cDNADB(ComplexSequence * last,cDNADB * cdnadb,int * return_status) { ComplexSequence * cs; Sequence * seq,*temp; /** free Complex Sequence **/ if ( last != NULL ) { free_ComplexSequence(last); } if( cdnadb->forward_only == TRUE) { temp = reload_SequenceDB(NULL,cdnadb->sdb,return_status); if ( *return_status != DB_RETURN_OK ) { return NULL; } cs = new_ComplexSequence(temp,cdnadb->cses); return cs; } if( cdnadb->is_single_seq == TRUE ) { if( cdnadb->done_forward == TRUE ) { *return_status = DB_RETURN_OK; cdnadb->done_forward = FALSE; return hard_link_ComplexSequence(cdnadb->rev); } else { *return_status = DB_RETURN_END; return NULL; } } /** standard database **/ if( cdnadb->done_forward == TRUE ) { if( cdnadb->current == NULL ) { warn("A bad internal cDNA db error - unable to find current sequence in db reload"); *return_status = DB_RETURN_ERROR; return NULL; } temp = reverse_complement_Sequence(cdnadb->current); if( temp == NULL ) { warn("A bad internal cDNA db error - unable to reverse complements current"); *return_status = DB_RETURN_ERROR; return NULL; } cs = new_ComplexSequence(temp,cdnadb->cses); if( cs == NULL ) { warn("A bad internal cDNA db error - unable to make complex sequence in db reload"); *return_status = DB_RETURN_ERROR; return NULL; } free_Sequence(temp); cdnadb->done_forward = FALSE; return cs; } /* otherwise we have to get a new sequence */ seq = reload_SequenceDB(NULL,cdnadb->sdb,return_status); if( seq == NULL || *return_status == DB_RETURN_ERROR || *return_status == DB_RETURN_END ) { return NULL; /** error already reported **/ } uppercase_Sequence(seq); if( force_to_dna_Sequence(seq,cdnadb->error_tol,NULL) == FALSE ) { if( cdnadb->error_handling == CDNADB_READ_THROUGH ) { warn("Unable to map %s sequence to a cDNA sequence, but ignoring that for the moment...",seq->name); free_Sequence(seq); return reload_cDNADB(NULL,cdnadb,return_status); } else { warn("Unable to map %s sequence to a cDNA sequence. Failing",seq->name); *return_status = DB_RETURN_ERROR; return NULL; } } cs = new_ComplexSequence(seq,cdnadb->cses); if( cs == NULL ) { if( cdnadb->error_handling == CDNADB_READ_THROUGH ) { warn("Unable to map %s sequence to a cDNA sequence, but ignoring that for the moment...",seq->name); free_Sequence(seq); return reload_cDNADB(NULL,cdnadb,return_status); } else { warn("Unable to map %s sequence to a cDNA sequence. Failing",seq->name); *return_status = DB_RETURN_ERROR; return NULL; } } cdnadb->current = free_Sequence(cdnadb->current); cdnadb->current = seq; cdnadb->done_forward= TRUE; return cs; } %func top level function which closes the cDNA database %arg cs last complex sequence cdnadb protein database %% boolean close_cDNADB(ComplexSequence * cs,cDNADB * cdnadb) { if( cdnadb->is_single_seq == TRUE ) { return TRUE; } if( cs != NULL) free_ComplexSequence(cs); if( cdnadb->current != NULL) cdnadb->current = free_Sequence(cdnadb->current); return close_SequenceDB(NULL,cdnadb->sdb); } %func To make a new cDNA database from a single cDNA Sequence with a eval system %arg seq sequence which as placed into cDNADB structure. %% cDNADB * new_cDNADB_from_single_seq(cDNA * seq) { ComplexSequence * cs,*cs_rev; Sequence * temp; ComplexSequenceEvalSet * cses; cses = default_cDNA_ComplexSequenceEvalSet(); cs = new_ComplexSequence(seq->baseseq,cses); temp = reverse_complement_Sequence(seq->baseseq); cs_rev = new_ComplexSequence(temp,cses); free_Sequence(temp); free_ComplexSequenceEvalSet(cses); return new_cDNADB_from_forrev_cseq(cs,cs_rev); } %func To make a new cDNA database from a single ComplexSequence %type internal %arg cs o complex sequence which is held. cs_rev o complex sequence which is held. %% cDNADB * new_cDNADB_from_forrev_cseq(ComplexSequence * cs,ComplexSequence * cs_rev) { cDNADB * out; out = cDNADB_alloc(); out->is_single_seq = TRUE; out->forw = cs; out->rev = cs_rev; return out; } %func To make a new cDNA database %arg seqdb r sequence database %% cDNADB * new_cDNADB(SequenceDB * seqdb) { cDNADB * out; ComplexSequenceEvalSet * cses; if( seqdb == NULL ) { warn("No sequencedb - can't make a cDNADB!"); return NULL; } /** should check sequence database **/ cses = default_cDNA_ComplexSequenceEvalSet(); if( cses->type != SEQUENCE_CDNA ) { warn("You can't make a cDNA database with a non SEQUENCE_cDNA cses type [%d]",cses->type); return NULL; } out = cDNADB_alloc(); out->is_single_seq = FALSE; out->sdb = hard_link_SequenceDB(seqdb); out->cses = hard_link_ComplexSequenceEvalSet(cses); free_ComplexSequenceEvalSet(cses); return out; } %} wise-2.4.1/src/dynlibsrc/cdnadb.xs0000644000175000001440000000730210670453712016427 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::cDNADB Wise2_cDNA * get_entry(cdnadb,de) Wise2_cDNADB * cdnadb Wise2_DataEntry * de CODE: RETVAL = Wise2_get_cDNA_from_cDNADB(cdnadb,de); OUTPUT: RETVAL Wise2_cDNADB * hard_link_cDNADB(obj) Wise2_cDNADB * obj CODE: RETVAL = Wise2_hard_link_cDNADB(obj); OUTPUT: RETVAL Wise2_cDNADB * alloc() CODE: RETVAL = Wise2_cDNADB_alloc(); OUTPUT: RETVAL boolean set_is_single_seq(obj,is_single_seq) Wise2_cDNADB * obj boolean is_single_seq CODE: RETVAL = Wise2_replace_is_single_seq_cDNADB(obj,is_single_seq); OUTPUT: RETVAL boolean is_single_seq(obj) Wise2_cDNADB * obj CODE: RETVAL = Wise2_access_is_single_seq_cDNADB(obj); OUTPUT: RETVAL boolean set_done_forward(obj,done_forward) Wise2_cDNADB * obj boolean done_forward CODE: RETVAL = Wise2_replace_done_forward_cDNADB(obj,done_forward); OUTPUT: RETVAL boolean done_forward(obj) Wise2_cDNADB * obj CODE: RETVAL = Wise2_access_done_forward_cDNADB(obj); OUTPUT: RETVAL boolean set_forward_only(obj,forward_only) Wise2_cDNADB * obj boolean forward_only CODE: RETVAL = Wise2_replace_forward_only_cDNADB(obj,forward_only); OUTPUT: RETVAL boolean forward_only(obj) Wise2_cDNADB * obj CODE: RETVAL = Wise2_access_forward_only_cDNADB(obj); OUTPUT: RETVAL boolean set_forw(obj,forw) Wise2_cDNADB * obj Wise2_ComplexSequence * forw CODE: RETVAL = Wise2_replace_forw_cDNADB(obj,Wise2_hard_link_ComplexSequence(forw)); OUTPUT: RETVAL Wise2_ComplexSequence * forw(obj) Wise2_cDNADB * obj INIT: Wise2_ComplexSequence * temp; CODE: temp = Wise2_hard_link_ComplexSequence(Wise2_access_forw_cDNADB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_rev(obj,rev) Wise2_cDNADB * obj Wise2_ComplexSequence * rev CODE: RETVAL = Wise2_replace_rev_cDNADB(obj,Wise2_hard_link_ComplexSequence(rev)); OUTPUT: RETVAL Wise2_ComplexSequence * rev(obj) Wise2_cDNADB * obj INIT: Wise2_ComplexSequence * temp; CODE: temp = Wise2_hard_link_ComplexSequence(Wise2_access_rev_cDNADB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_sdb(obj,sdb) Wise2_cDNADB * obj Wise2_SequenceDB * sdb CODE: RETVAL = Wise2_replace_sdb_cDNADB(obj,Wise2_hard_link_SequenceDB(sdb)); OUTPUT: RETVAL Wise2_SequenceDB * sdb(obj) Wise2_cDNADB * obj INIT: Wise2_SequenceDB * temp; CODE: temp = Wise2_hard_link_SequenceDB(Wise2_access_sdb_cDNADB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_current(obj,current) Wise2_cDNADB * obj Wise2_Sequence * current CODE: RETVAL = Wise2_replace_current_cDNADB(obj,Wise2_hard_link_Sequence(current)); OUTPUT: RETVAL Wise2_Sequence * current(obj) Wise2_cDNADB * obj INIT: Wise2_Sequence * temp; CODE: temp = Wise2_hard_link_Sequence(Wise2_access_current_cDNADB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_cses(obj,cses) Wise2_cDNADB * obj Wise2_ComplexSequenceEvalSet * cses CODE: RETVAL = Wise2_replace_cses_cDNADB(obj,Wise2_hard_link_ComplexSequenceEvalSet(cses)); OUTPUT: RETVAL Wise2_ComplexSequenceEvalSet * cses(obj) Wise2_cDNADB * obj INIT: Wise2_ComplexSequenceEvalSet * temp; CODE: temp = Wise2_hard_link_ComplexSequenceEvalSet(Wise2_access_cses_cDNADB(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_cDNADB * new(class) char * class PPCODE: Wise2_cDNADB * out; out = Wise2_cDNADB_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_cDNADB * obj CODE: Wise2_free_cDNADB(obj); MODULE = Wise2 PACKAGE = Wise2 Wise2_cDNADB * new_cDNADB_from_single_seq(seq) Wise2_cDNA * seq CODE: RETVAL = Wise2_new_cDNADB_from_single_seq(seq); OUTPUT: RETVAL Wise2_cDNADB * new_cDNADB(seqdb) Wise2_SequenceDB * seqdb CODE: RETVAL = Wise2_new_cDNADB(seqdb); OUTPUT: RETVAL wise-2.4.1/src/dynlibsrc/compmat_api.h0000644000175000001440000000734610670453712017312 0ustar philippusers /* Functions that create, manipulate or act on CompMat * * Wise2_fail_safe_CompMat_access * Wise2_write_Blast_CompMat * Wise2_read_Blast_file_CompMat * Wise2_read_Blast_CompMat * Wise2_hard_link_CompMat * Wise2_CompMat_alloc * Wise2_replace_name_CompMat * Wise2_access_name_CompMat * Wise2_free_CompMat [destructor] * */ /* API for object CompMat */ /* Function: Wise2_fail_safe_CompMat_access(cm,aa1,aa2) * * Descrip: gives the fail form of the macro CompMat_AAMATCH which * checks that aa1 and a2 are sensible and that cm is not NULL. * * * Arg: cm compmat object [Wise2_CompMat *] * Arg: aa1 first amino acid [int] * Arg: aa2 second amino acid [int] * * Returns Undocumented return value [Score] * */ Score Wise2_fail_safe_CompMat_access( Wise2_CompMat * cm,int aa1,int aa2); /* Function: Wise2_write_Blast_CompMat(cm,ofp) * * Descrip: writes a protien CompMat with a standard * alphabet. * * * Arg: cm CompMat object [Wise2_CompMat *] * Arg: ofp file to output [FILE *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_write_Blast_CompMat( Wise2_CompMat * cm,FILE * ofp); /* Function: Wise2_read_Blast_file_CompMat(filename) * * Descrip: Opens file, reads matrix, closes file. * calls /read_Blast_CompMat for the actual format * reading. Uses /openfile to open the file, * so will open from config files. * * * Arg: filename Undocumented argument [char *] * * Returns Undocumented return value [Wise2_CompMat *] * */ Wise2_CompMat * Wise2_read_Blast_file_CompMat( char * filename); /* Function: Wise2_read_Blast_CompMat(ifp) * * Descrip: reads a BLAST format matrix and * allocates a new ComMat structure. * * * Arg: ifp Undocumented argument [FILE *] * * Returns Undocumented return value [Wise2_CompMat *] * */ Wise2_CompMat * Wise2_read_Blast_CompMat( FILE * ifp); /* Function: Wise2_hard_link_CompMat(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_CompMat *] * * Returns Undocumented return value [Wise2_CompMat *] * */ Wise2_CompMat * Wise2_hard_link_CompMat( Wise2_CompMat * obj); /* Function: Wise2_CompMat_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_CompMat *] * */ Wise2_CompMat * Wise2_CompMat_alloc(); /* Function: Wise2_replace_name_CompMat(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_CompMat *] * Arg: name New value of the variable [char *] * * Returns member variable name [boolean] * */ boolean Wise2_replace_name_CompMat( Wise2_CompMat * obj,char * name); /* Function: Wise2_access_name_CompMat(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_CompMat *] * * Returns member variable name [char *] * */ char * Wise2_access_name_CompMat( Wise2_CompMat * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_CompMat(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_CompMat *] * * Returns Undocumented return value [Wise2_CompMat *] * */ Wise2_CompMat * Wise2_free_CompMat( Wise2_CompMat * obj); wise-2.4.1/src/dynlibsrc/compmat_api.t0000644000175000001440000000005510670453712017314 0ustar philippuserstypedef struct Wise2_CompMat Wise2_CompMat; wise-2.4.1/src/dynlibsrc/hsptwohitscan.dy0000644000175000001440000003155310417270545020101 0ustar philippusers %{ #include "hsplookupscan.h" #define TwoHitBufferLISTLENGTH 4096 #define TwoHitSequenceLISTLENGTH 90 #define TWOHIT_FIRST_ENTRY 56 #define TWOHIT_FIRST_STORED 57 #define TWOHIT_HANDLED 58 typedef struct TwoHitStore { int hit_state; Sequence * target; int target_pos; int query_pos; int diagonal; } TwoHitStore; #define TWOHIT_BLOCK_SIZE 40000 #define TWOHIT_BLOCK_DEPTH 1000 typedef struct TwoHitStoreBlockAllocator { TwoHitStore ** block; int current_block; int current_pos; int block_len; } TwoHitStoreBlockAllocator; %} struct TwoHitSequence TwoHitStore ** word !list GHashTable * diagonal_hash !link struct TwoHitBuffer TwoHitSequence ** buffer !list GHashTable * target_hash !link TwoHitStoreBlockAllocator * thba %{ #include "hsptwohitscan.h" #include #include %func Builds a twohit scan interface. This does expands the query using a matrix but just be considering off by one cases %% HSPScanInterface * new_twohit_one_off_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff) { HSPScanInterface * out; HSPScanPara * p; assert(sli); assert(mat); out = HSPScanInterface_alloc(); p = HSPScanPara_alloc(); p->sli = hard_link_SeqLookupInterface(sli); p->mat = hard_link_CompMat(mat); p->drop_off = drop_off; p->score_cutoff = score_cutoff; out->data = (void*)p; out->free_data = simple_HSPScan_free; if( sli->lookup_array_head == NULL ) { fatal("Currently can only use direct lookup in twohit scans"); } else { out->scan_query = twohit_one_off_HSPscan_scan_query_direct; } return out; } %func Word expansion with two hit semantics %% LinearHSPmanager * twohit_one_off_HSPscan_scan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para) { char * std_aa = "ACDEFGHIKLMNPQRSTVWY"; HSPmanager * hspm; LinearHSPmanager * out; LineariseHSPPara * hsp_para; HSPScanPara * p = (HSPScanPara *)data; int i; int j; int k; int aa; int score; char newseq[5]; TwoHitBuffer * thb; TwoHitStore * s; int jj; int aa2; int has_seen; int seqno[5]; int base[5]; int start_base; int self_score[5]; int total_score; int current_score; ArraySeqHead * head; int no; #ifdef LINUX_TIMER struct timeval t1; struct timeval t2; struct timeval t3; #endif assert(seq); assert(p); assert(para); assert(para->max_results > 0); if( VERBOSITY_CHECK(1,para->verbosity) ) { info("processing sequence %s with twohit implementation",seq->name); } hsp_para = LineariseHSPPara_alloc(); hsp_para->verbosity = para->verbosity; hsp_para->max_size = para->max_results; hsp_para->min_score = para->min_hsp_score; hsp_para->width = para->hsp_link_width; hsp_para->tail = para->hsp_link_length; for(i=0,start_base=1;i<5;i++) { base[i] = start_base; start_base = start_base * 26; } hspm = new_HSPmanager(seq,p->mat,p->drop_off); thb = new_TwoHitBuffer(); #ifdef LINUX_TIMER gettimeofday(&t1,NULL); #endif /* * normal scan for 0 and 1 off. On identical and one off, simply put * things into the TwoHitBuffer and set the hit_state to TWOHIT_HANDLED - indicating * that this hit has already been delt with. * * For the two off cases - where most of the random cases will come * in, put in the TwoHitBuffer and only process the HSPs when you come * come back with a hit_state of TWOHIT_FIRST_ENTRY. This calling code * will then change this to TWOHIT_FIRST_STORED. If the hit_state is * TWOHIT_FIRST_STORED it will then process both the current hit and * the stored hit, and set the state to TWOHIT_HANDLED. If it is * in TWOHIT_HANDLED, it handles just the current hit. * * The end result of all of this is that a sequence will need two * two-off (or better) words to trigger HSP extension, which hopefully will * drastically cut down on random HSP extensions. * */ for(i=0;ilen-5;i++) { head = (*p->sli->lookup_array_head)(p->sli->data,seq_number_aa_5mer_client(seq->seq+i)); if( head != NULL ) { if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { if( VERBOSITY_CHECK(7,para->verbosity) ) { info("position %d hit direct over filled position, %d vs hard %d, low %d",i,head->current_pos,para->numb_level,para->low_numb); } continue; } for(k=0;kcurrent_pos;k++) { s = add_to_TwoHitBuffer(thb,head->units[k].seq,i,head->units[k].pos); s->hit_state = TWOHIT_HANDLED; if( add_pair_HSPmanager_score(hspm,head->units[k].seq,i,head->units[k].pos,para->min_hsp_score) == TRUE ) { ; } } } total_score = 0; for(score=0,j=0;j<5;j++) { seqno[j] = base[j]*(toupper(seq->seq[i+j])-'A'); self_score[j] = p->mat->comp[toupper(seq->seq[i+j])-'A'][toupper(seq->seq[i+j])-'A']; total_score += self_score[j]; } has_seen = 0; for(j=0;j<5;j++) { for(jj=1;jj<5;jj+=2) { for(aa=0;aa<20;aa++) { for(aa2=0;aa2<20;aa2++) { if( seq->seq[i+j] == std_aa[aa] ) { continue; } current_score = total_score; current_score -= (self_score[j] - p->mat->comp[toupper(seq->seq[i+j])-'A'][std_aa[aa]-'A']); current_score -= (self_score[jj] - p->mat->comp[toupper(seq->seq[i+jj])-'A'][std_aa[aa2]-'A']); if( current_score < para->min_word_score ) { continue; } else { /* fprintf(stderr,"Handling %d,%d amino acid %d,%d score %d\n",j,jj,aa,aa2,current_score); */ } seqno[j] = base[j]*(std_aa[aa]-'A'); seqno[jj] = base[jj]*(std_aa[aa2]-'A'); no= seqno[0]+seqno[1]+seqno[2]+seqno[3]+seqno[4]; head = (*p->sli->lookup_array_head)(p->sli->data,no); if( head != NULL ) { if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { if( VERBOSITY_CHECK(7,para->verbosity) ) { info("position %d hit direct over filled position, %d vs hard %d, low %d",i,head->current_pos,para->numb_level,para->low_numb); } continue; } has_seen = 1; for(k=0;kcurrent_pos;k++) { s = add_to_TwoHitBuffer(thb,head->units[k].seq,i,head->units[k].pos); /* if this is the first time we've used, this just store it */ if( s->hit_state == TWOHIT_FIRST_ENTRY ) { /* fprintf(stderr,"%d,%d %s, %d,%d added as first entry\n",j,aa,head->units[k].seq->name,i,head->units[k].pos); */ s->hit_state = TWOHIT_FIRST_STORED; continue; } /* if we get this back with TWOHIT_FIRST_STORED, * process the stored hit and then process the current * afterwards */ if( s->hit_state == TWOHIT_FIRST_STORED ) { /* fprintf(stderr,"%d,%d sequence %s, second hit, %d,%d vs %d,%d\n",j,aa,s->target->name,s->query_pos,s->target_pos,i,head->units[k].pos); */ s->hit_state = TWOHIT_HANDLED; /* stored hit */ add_pair_HSPmanager_score(hspm,s->target,s->query_pos,s->target_pos,para->min_hsp_score); } /* current hit - either stored or handled */ add_pair_HSPmanager(hspm,head->units[k].seq,i,head->units[k].pos) ; } } seqno[j] = base[j]*(toupper(seq->seq[i+j]-'A')); seqno[jj] = base[jj]*(toupper(seq->seq[i+jj]-'A')); newseq[j] = seq->seq[i+j]; newseq[jj] = seq->seq[i+jj]; } } } } } if( VERBOSITY_CHECK(4,para->verbosity) ) { for(i=0,jj=0,k=0;ilen;i++) { for(j=0;jbuffer[i]->len;j++ ) { if( thb->buffer[i]->word[j]->hit_state == TWOHIT_HANDLED ) { jj++; } k++; } } info("Two hit status: %d sequences, %d words %d handled",thb->len,k,jj); } #ifdef LINUX_TIMER if( VERBOSITY_CHECK(3,para->verbosity) ) { gettimeofday(&t2,NULL); } #endif if( para->use_protein_heuristic == TRUE ) { out = new_LinearHSPmanager_simple_heuristic(hspm,hsp_para); } else { out = new_LinearHSPmanager_flat(hspm); } #ifdef LINUX_TIMER if( VERBOSITY_CHECK(3,para->verbosity) ) { gettimeofday(&t3,NULL); info("Sort clock point: Scan %f : Sort %f", t2.tv_sec - t1.tv_sec + ((t2.tv_usec - t1.tv_usec) * 1e-6), t3.tv_sec - t2.tv_sec + ((t2.tv_usec - t2.tv_usec) * 1e-6) ); } #endif free_HSPmanager(hspm); return out; } %func adds a new potential hit to the TwoHitBuffer, returning the HitStore datastructure updated if hit is 1 then this is first entry if hit is more than 1 second %% TwoHitStore * add_to_TwoHitBuffer(TwoHitBuffer * thb,Sequence * target,int query_pos,int target_pos) { TwoHitSequence * seq; TwoHitStore * s; int diag; int i; int j; diag = query_pos - target_pos; if( (seq = g_hash_table_lookup(thb->target_hash,(gpointer)target)) != NULL ) { /* unrolling the first 2 positions */ if( seq->len ==2 || seq->len == 1) { if( seq->word[0]->diagonal == diag ) { return seq->word[0]; } } if( seq->len == 2 ) { if( seq->word[1]->diagonal == diag ) { return seq->word[1]; } } /* use the hash to test the other positions */ if( seq->len > 2 && (s = g_hash_table_lookup(seq->diagonal_hash,&diag)) != NULL ) { return s; } /* no position on this diagonal - make a new store */ s = new_TwoHitStore_from_Allocator(thb->thba); s->target = target; s->hit_state = TWOHIT_FIRST_ENTRY; s->target_pos = target_pos; s->query_pos = query_pos; s->diagonal = diag; add_TwoHitSequence(seq,s); g_hash_table_insert(seq->diagonal_hash,&(s->diagonal),s); return s; } /* else make a new seq and a new store, add it, pointer the hash to it */ seq = new_TwoHitSequence(); add_TwoHitBuffer(thb,seq); g_hash_table_insert(thb->target_hash,(gpointer)target,seq); s = new_TwoHitStore_from_Allocator(thb->thba); s->target = target; s->hit_state = TWOHIT_FIRST_ENTRY; s->target_pos = target_pos; s->query_pos = query_pos; s->diagonal = query_pos - target_pos; add_TwoHitSequence(seq,s); g_hash_table_insert(seq->diagonal_hash,&(s->diagonal),s); return s; } %func makes a new TwoHitBuffer ready for use %% TwoHitBuffer * new_TwoHitBuffer(void) { TwoHitBuffer * b; b = TwoHitBuffer_alloc_std(); b->target_hash = g_hash_table_new(g_direct_hash,g_direct_equal); b->thba = new_TwoHitStoreBlockAllocator(); return b; } %func make a new TwoHitSequence ready for use %% TwoHitSequence * new_TwoHitSequence(void) { TwoHitSequence * seq; seq = TwoHitSequence_alloc_std(); seq->diagonal_hash = g_hash_table_new(g_int_hash,g_int_equal); return seq; } %func Frees the TwoHitSequence %% !deconstructor TwoHitSequence * free_TwoHitSequence(TwoHitSequence * t) { g_hash_table_destroy(t->diagonal_hash); /* block allocator handles store memory */ ckfree(t->word); ckfree(t); return NULL; } %func Frees the TwoHitBuffer %% !deconstructor TwoHitBuffer * free_TwoHitBuffer(TwoHitBuffer * t) { int i; g_hash_table_destroy(t->target_hash); for(i=0;ilen;i++) { free_TwoHitSequence(t->buffer[i]); } ckfree(t->buffer); ckfree(t); return NULL; } %func allocator for twohitstore %% TwoHitStore * TwoHitStore_alloc(void) { TwoHitStore * out; out = (TwoHitStore *)malloc(sizeof(TwoHitStore)); return out; } %func free for twohitstore %% TwoHitStore * free_TwoHitStore(TwoHitStore * t) { if( t == NULL ) { return NULL; } free(t); return NULL; } %func gets a new store from a block allocator %% TwoHitStore * new_TwoHitStore_from_Allocator(TwoHitStoreBlockAllocator * a) { /* do short path first! */ if( a->current_pos < TWOHIT_BLOCK_SIZE ) { return &(a->block[a->current_block][a->current_pos++]); } /* else, we need a new block */ if( a->current_block >= a->block_len ) { /* we need to realloc the block ! */ a->block = realloc(a->block,sizeof(TwoHitStore *)*(2*a->block_len)); assert(a->block != NULL); a->block_len = (2*a->block_len); } a->current_block++; a->block[a->current_block] = calloc(TWOHIT_BLOCK_SIZE,sizeof(TwoHitStore)); assert(a->block[a->current_block] != NULL); a->current_pos = 0; return &(a->block[a->current_block][a->current_pos++]); } %func frees a block allocator %% TwoHitStoreBlockAllocator * free_TwoHitStoreBlockAllocator(TwoHitStoreBlockAllocator * a) { int i; assert(a != NULL); for(i=0;icurrent_block;i++) { free(a->block[i]); } free(a->block); free(a); return NULL; } %func makes a new block allocator %% TwoHitStoreBlockAllocator * new_TwoHitStoreBlockAllocator(void) { TwoHitStoreBlockAllocator * out; out = (TwoHitStoreBlockAllocator*) malloc(sizeof(TwoHitStoreBlockAllocator)); assert(out != NULL); out->block = (TwoHitStore **) calloc(TWOHIT_BLOCK_DEPTH,sizeof(TwoHitStore*)); out->block_len = TWOHIT_BLOCK_DEPTH; out->block[0] = (TwoHitStore*) calloc(TWOHIT_BLOCK_SIZE,sizeof(TwoHitStore)); out->current_block = 0; out->current_pos = 0; return out; } %} wise-2.4.1/src/dynlibsrc/alnrange.typemap0000644000175000001440000000074610670453712020035 0ustar philippusers TYPEMAP Wise2_AlnRange * T_Wise2_AlnRange INPUT T_Wise2_AlnRange $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_AlnRange *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_AlnRange sv_setref_pv($arg, "Wise2::AlnRange", (void*) $var); TYPEMAP Wise2_AlnRangeSet * T_Wise2_AlnRangeSet INPUT T_Wise2_AlnRangeSet $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_AlnRangeSet *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_AlnRangeSet sv_setref_pv($arg, "Wise2::AlnRangeSet", (void*) $var); wise-2.4.1/src/dynlibsrc/sequence_codon.c0000644000175000001440000001341510670453713020001 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "sequence_codon.h" /* Function: reverse_complement_Sequence(seq) * * Descrip: This both complements and reverses a sequence, * - a common wish! * * The start/end are correct with respect to the start/end * of the sequence (ie start = end, end = start). * * * Arg: seq [READ ] Sequence to that is used to reverse (makes a new Sequence) [Sequence *] * * Return [OWNER] new Sequence which is reversed [Sequence *] * */ # line 29 "sequence_codon.dy" Sequence * reverse_complement_Sequence(Sequence * seq) { Sequence * out; int i; int j; if( is_dna_Sequence(seq) != TRUE ) { warn("Cannot reverse complement non-DNA sequence... type is %s",Sequence_type_to_string(seq->type)); return NULL; } out = Sequence_from_static_memory(seq->name,seq->seq); for(j=0,i=seq->len-1;i >= 0;i--,j++) { out->seq[j] = char_complement_base(seq->seq[i]); /*fprintf(stderr,"In position %d placed %c from %c\n",j,out->seq[j],seq->seq[i]);*/ } out->len = strlen(seq->seq); out->offset = seq->end; out->end = seq->offset; out->type = seq->type; return out; } /* Function: magic_trunc_Sequence(seq,start,end) * * Descrip: Clever function for dna sequences. * * When start < end, truncates normally * * when start > end, truncates end,start and then * reverse complements. * * ie. If you have a coordinate system where reverse * sequences are labelled in reverse start/end way, * then this routine produces the correct sequence. * * * Arg: seq [READ ] sequence that is the source to be truncated [Sequence *] * Arg: start [READ ] start point [int] * Arg: end [READ ] end point [int] * * Return [OWNER] new Sequence which is truncated/reversed [Sequence *] * */ # line 74 "sequence_codon.dy" Sequence * magic_trunc_Sequence(Sequence * seq,int start,int end) { Sequence * temp; Sequence * out; if( is_dna_Sequence(seq) == FALSE) { warn("Cannot magic truncate on a non DNA sequence... type is %s",Sequence_type_to_string(seq->type)); return NULL; } if( start < 0 || end < 0 ) { warn("Attempting a magic truncation on indices which are less than zero [%d:%d]. Clearly impossible",start,end); return NULL; } if( start < end ) { return trunc_Sequence(seq,start,end); } else { temp = trunc_Sequence(seq,end,start); if( temp == NULL ) { warn("Unable to truncate sequence"); return NULL; } out = reverse_complement_Sequence(temp); free_Sequence(temp); return out; } } /* Function: translate_Sequence(dna,ct) * * Descrip: This translates a DNA sequence to a protein. * It assummes that it starts at first residue * (use trunc_Sequence to chop a sequence up). * * * Arg: dna [READ ] DNA sequence to be translated [Sequence *] * Arg: ct [READ ] Codon table to do codon->aa mapping [CodonTable *] * * Return [OWNER] new protein sequence [Sequence *] * */ # line 119 "sequence_codon.dy" Sequence * translate_Sequence(Sequence * dna,CodonTable * ct) { Sequence * out; int i; int j; int len; char * seq; char * name; char buffer[512]; if( is_dna_Sequence(dna) == FALSE) { warn("Trying to make a translation from a non DNA sequence... type is [%s]",Sequence_type_to_string(dna->type)); return NULL; } len = dna->len/3 + 1; seq = ckcalloc(len,sizeof(char)); sprintf(buffer,"%s.tr",dna->name == NULL ? "NoNameDNASeq" : dna->name); name = stringalloc(buffer); out = Sequence_from_dynamic_memory(name,seq); for(i=0,j=0;ilen-3;i+=3,j++) { out->seq[j] = aminoacid_from_seq(ct,dna->seq+i); } out->seq[j] = '\0'; out->type = SEQUENCE_PROTEIN; out->len = strlen(out->seq); return out; } /* Function: force_to_dna_Sequence(seq,fraction,number_of_conver) * * Descrip: This * a) sees how many non ATGCN characters there are in Seq * b) If the level is below fraction * a) flips non ATGC chars to N * b) writes number of conversions to number_of_conver * c) returns TRUE * c) else returns FALSE * * fraction of 0.0 means completely intolerant of errors * fraction of 1.0 means completely tolerant of errors * * * * Arg: seq [RW ] sequence object read and converted [Sequence *] * Arg: fraction [READ ] number 0..1 for tolerance of conversion [double] * Arg: number_of_conver [WRITE] number of conversions actually made [int *] * * Return [READ ] TRUE for conversion to DNA, FALSE if not [boolean] * */ # line 174 "sequence_codon.dy" boolean force_to_dna_Sequence(Sequence * seq,double fraction,int * number_of_conver) { int count =0; int i; if( seq == NULL ) { warn("Attempting to force a sequence with no Sequence object!\n"); return FALSE; } if( seq->len <= 0 ) { warn("Trying to make a sequence with a length of %d. Bad news!",seq->len); return FALSE; } for(i=0;ilen;i++) { /* if it is lower case, uppercase it! */ seq->seq[i] = (char)toupper((int)seq->seq[i]); if( !is_valid_base_char(seq->seq[i]) ) { count++; } } if( ((double)count/(double)seq->len) < fraction ) { seq->type = SEQUENCE_DNA; if( count != 0 ) { for(i=0;ilen;i++) { if( !is_valid_base_char(seq->seq[i]) ) { seq->seq[i] = 'N'; } } } if( number_of_conver != NULL ) { *number_of_conver = count; } return TRUE; } else { if( number_of_conver != NULL ) { *number_of_conver = count; } return FALSE; } } # line 216 "sequence_codon.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/sequence_codon.h0000644000175000001440000000735210670453713020011 0ustar philippusers#ifndef DYNAMITEsequence_codonHEADERFILE #define DYNAMITEsequence_codonHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #include "codon.h" /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: reverse_complement_Sequence(seq) * * Descrip: This both complements and reverses a sequence, * - a common wish! * * The start/end are correct with respect to the start/end * of the sequence (ie start = end, end = start). * * * Arg: seq [READ ] Sequence to that is used to reverse (makes a new Sequence) [Sequence *] * * Return [OWNER] new Sequence which is reversed [Sequence *] * */ Sequence * Wise2_reverse_complement_Sequence(Sequence * seq); #define reverse_complement_Sequence Wise2_reverse_complement_Sequence /* Function: magic_trunc_Sequence(seq,start,end) * * Descrip: Clever function for dna sequences. * * When start < end, truncates normally * * when start > end, truncates end,start and then * reverse complements. * * ie. If you have a coordinate system where reverse * sequences are labelled in reverse start/end way, * then this routine produces the correct sequence. * * * Arg: seq [READ ] sequence that is the source to be truncated [Sequence *] * Arg: start [READ ] start point [int] * Arg: end [READ ] end point [int] * * Return [OWNER] new Sequence which is truncated/reversed [Sequence *] * */ Sequence * Wise2_magic_trunc_Sequence(Sequence * seq,int start,int end); #define magic_trunc_Sequence Wise2_magic_trunc_Sequence /* Function: translate_Sequence(dna,ct) * * Descrip: This translates a DNA sequence to a protein. * It assummes that it starts at first residue * (use trunc_Sequence to chop a sequence up). * * * Arg: dna [READ ] DNA sequence to be translated [Sequence *] * Arg: ct [READ ] Codon table to do codon->aa mapping [CodonTable *] * * Return [OWNER] new protein sequence [Sequence *] * */ Sequence * Wise2_translate_Sequence(Sequence * dna,CodonTable * ct); #define translate_Sequence Wise2_translate_Sequence /* Function: force_to_dna_Sequence(seq,fraction,number_of_conver) * * Descrip: This * a) sees how many non ATGCN characters there are in Seq * b) If the level is below fraction * a) flips non ATGC chars to N * b) writes number of conversions to number_of_conver * c) returns TRUE * c) else returns FALSE * * fraction of 0.0 means completely intolerant of errors * fraction of 1.0 means completely tolerant of errors * * * * Arg: seq [RW ] sequence object read and converted [Sequence *] * Arg: fraction [READ ] number 0..1 for tolerance of conversion [double] * Arg: number_of_conver [WRITE] number of conversions actually made [int *] * * Return [READ ] TRUE for conversion to DNA, FALSE if not [boolean] * */ boolean Wise2_force_to_dna_Sequence(Sequence * seq,double fraction,int * number_of_conver); #define force_to_dna_Sequence Wise2_force_to_dna_Sequence /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/alnrange.dy0000644000175000001440000000234207313404537016765 0ustar philippusers/* Last edited: Apr 14 11:15 1997 (birney) */ %{ #include "dyna.h" #define AlnRangeSetLISTLENGTH 64 %} struct AlnRange int starti int startj int startstate int stopi int stopj int stopstate int startscore int stopscore struct AlnRangeSet int score // over complete alignment AlnRange ** alr !list api object AlnRange des free_AlnRange endobject object AlnRangeSet des free_AlnRangeSet endobject endapi %{ #include "alnrange.h" %func shows AlnRangeSet in vaguely human form %% void show_AlnRangeSet(AlnRangeSet * ars,FILE * ofp) { int i; for(i=0;ilen;i++) { show_AlnRange(ars->alr[i],ofp); } } %func shows AlnRange in vaguely human form %% void show_AlnRange(AlnRange * alr,FILE * ofp) { fprintf(ofp,"(%d,%d,%d)-(%d,%d,%d) [%d,%d]\n",alr->starti,alr->startj,alr->startstate, alr->stopi,alr->stopj,alr->stopstate,alr->startscore,alr->stopscore); } %func Sorts an AlnRangeSet by start of each AlnRange %% void sort_AlnRangeSet_by_start(AlnRangeSet * ars) { sort_AlnRangeSet(ars,compare_AlnRange_start); } %func compares to AlnRange for /sort_AlnRangeSet_by_start %type internal %% int compare_AlnRange_start(AlnRange * one,AlnRange * two) { if( one->startj > two->startj) return 1; else return -1; } %} wise-2.4.1/src/dynlibsrc/alnrange.xs0000644000175000001440000001053610670453712017006 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::AlnRange Wise2_AlnRange * hard_link_AlnRange(obj) Wise2_AlnRange * obj CODE: RETVAL = Wise2_hard_link_AlnRange(obj); OUTPUT: RETVAL Wise2_AlnRange * alloc() CODE: RETVAL = Wise2_AlnRange_alloc(); OUTPUT: RETVAL boolean set_starti(obj,starti) Wise2_AlnRange * obj int starti CODE: RETVAL = Wise2_replace_starti_AlnRange(obj,starti); OUTPUT: RETVAL int starti(obj) Wise2_AlnRange * obj CODE: RETVAL = Wise2_access_starti_AlnRange(obj); OUTPUT: RETVAL boolean set_startj(obj,startj) Wise2_AlnRange * obj int startj CODE: RETVAL = Wise2_replace_startj_AlnRange(obj,startj); OUTPUT: RETVAL int startj(obj) Wise2_AlnRange * obj CODE: RETVAL = Wise2_access_startj_AlnRange(obj); OUTPUT: RETVAL boolean set_startstate(obj,startstate) Wise2_AlnRange * obj int startstate CODE: RETVAL = Wise2_replace_startstate_AlnRange(obj,startstate); OUTPUT: RETVAL int startstate(obj) Wise2_AlnRange * obj CODE: RETVAL = Wise2_access_startstate_AlnRange(obj); OUTPUT: RETVAL boolean set_stopi(obj,stopi) Wise2_AlnRange * obj int stopi CODE: RETVAL = Wise2_replace_stopi_AlnRange(obj,stopi); OUTPUT: RETVAL int stopi(obj) Wise2_AlnRange * obj CODE: RETVAL = Wise2_access_stopi_AlnRange(obj); OUTPUT: RETVAL boolean set_stopj(obj,stopj) Wise2_AlnRange * obj int stopj CODE: RETVAL = Wise2_replace_stopj_AlnRange(obj,stopj); OUTPUT: RETVAL int stopj(obj) Wise2_AlnRange * obj CODE: RETVAL = Wise2_access_stopj_AlnRange(obj); OUTPUT: RETVAL boolean set_stopstate(obj,stopstate) Wise2_AlnRange * obj int stopstate CODE: RETVAL = Wise2_replace_stopstate_AlnRange(obj,stopstate); OUTPUT: RETVAL int stopstate(obj) Wise2_AlnRange * obj CODE: RETVAL = Wise2_access_stopstate_AlnRange(obj); OUTPUT: RETVAL boolean set_startscore(obj,startscore) Wise2_AlnRange * obj int startscore CODE: RETVAL = Wise2_replace_startscore_AlnRange(obj,startscore); OUTPUT: RETVAL int startscore(obj) Wise2_AlnRange * obj CODE: RETVAL = Wise2_access_startscore_AlnRange(obj); OUTPUT: RETVAL boolean set_stopscore(obj,stopscore) Wise2_AlnRange * obj int stopscore CODE: RETVAL = Wise2_replace_stopscore_AlnRange(obj,stopscore); OUTPUT: RETVAL int stopscore(obj) Wise2_AlnRange * obj CODE: RETVAL = Wise2_access_stopscore_AlnRange(obj); OUTPUT: RETVAL Wise2_AlnRange * new(class) char * class PPCODE: Wise2_AlnRange * out; out = Wise2_AlnRange_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_AlnRange * obj CODE: Wise2_free_AlnRange(obj); MODULE = Wise2 PACKAGE = Wise2::AlnRangeSet Wise2_AlnRangeSet * hard_link_AlnRangeSet(obj) Wise2_AlnRangeSet * obj CODE: RETVAL = Wise2_hard_link_AlnRangeSet(obj); OUTPUT: RETVAL Wise2_AlnRangeSet * AlnRangeSet_alloc_std() CODE: RETVAL = Wise2_AlnRangeSet_alloc_std(); OUTPUT: RETVAL boolean set_score(obj,score) Wise2_AlnRangeSet * obj int score CODE: RETVAL = Wise2_replace_score_AlnRangeSet(obj,score); OUTPUT: RETVAL int score(obj) Wise2_AlnRangeSet * obj CODE: RETVAL = Wise2_access_score_AlnRangeSet(obj); OUTPUT: RETVAL Wise2_AlnRange * alr(obj,i) Wise2_AlnRangeSet * obj int i INIT: Wise2_AlnRange * temp; CODE: temp = Wise2_hard_link_AlnRange(Wise2_access_alr_AlnRangeSet(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_alr(obj) Wise2_AlnRangeSet * obj CODE: RETVAL = Wise2_length_alr_AlnRangeSet(obj); OUTPUT: RETVAL int flush_alr(obj) Wise2_AlnRangeSet * obj CODE: RETVAL = Wise2_flush_AlnRangeSet(obj); OUTPUT: RETVAL boolean add_alr(obj,add) Wise2_AlnRangeSet * obj Wise2_AlnRange * add CODE: RETVAL = Wise2_add_AlnRangeSet(obj,Wise2_hard_link_AlnRange(add)); OUTPUT: RETVAL Wise2_AlnRangeSet * new(class) char * class PPCODE: Wise2_AlnRangeSet * out; out = Wise2_AlnRangeSet_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_AlnRangeSet * obj CODE: Wise2_free_AlnRangeSet(obj); void each_alr(obj) Wise2_AlnRangeSet * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_alr_AlnRangeSet(obj); for(i=0;imu,l->lambda); } /* Function: free_evdlookup_void (data) * * Descrip: Internal function for free... * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 42 "searchstatlookup.dy" void free_evdlookup_void (void * data) { EVDLookup * l = (EVDLookup *)data; free_EVDLookup(l); } /* Function: new_lookup_SearchStatInterface(mu,lambda) * * Descrip: Builds an external lookup statistics package * * * Arg: mu [UNKN ] Undocumented argument [double] * Arg: lambda [UNKN ] Undocumented argument [double] * * Return [UNKN ] Undocumented return value [SearchStatInterface *] * */ # line 51 "searchstatlookup.dy" SearchStatInterface * new_lookup_SearchStatInterface(double mu,double lambda) { SearchStatInterface * ssi; EVDLookup * el; ssi = SearchStatInterface_alloc(); el = EVDLookup_alloc(); el->mu = mu; el->lambda = lambda; ssi->data = (void *) el; ssi->calc_evalue = evalue_halfbit_lookup_ssi; ssi->calc_bits = bit_halfbit_lookup_ssi; ssi->free_data = free_evdlookup_void; return ssi; } # line 84 "searchstatlookup.c" /* Function: hard_link_EVDLookup(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EVDLookup *] * * Return [UNKN ] Undocumented return value [EVDLookup *] * */ EVDLookup * hard_link_EVDLookup(EVDLookup * obj) { if( obj == NULL ) { warn("Trying to hard link to a EVDLookup object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: EVDLookup_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EVDLookup *] * */ EVDLookup * EVDLookup_alloc(void) { EVDLookup * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(EVDLookup *) ckalloc (sizeof(EVDLookup))) == NULL) { warn("EVDLookup_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->mu = 0; out->lambda = 0; return out; } /* Function: free_EVDLookup(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EVDLookup *] * * Return [UNKN ] Undocumented return value [EVDLookup *] * */ EVDLookup * free_EVDLookup(EVDLookup * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a EVDLookup obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/searchstatlookup.h0000644000175000001440000001045310670453712020405 0ustar philippusers#ifndef DYNAMITEsearchstatlookupHEADERFILE #define DYNAMITEsearchstatlookupHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "searchstatinterface.h" #include "probability.h" #include "histogram.h" struct Wise2_EVDLookup { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif double mu; double lambda; } ; /* EVDLookup defined */ #ifndef DYNAMITE_DEFINED_EVDLookup typedef struct Wise2_EVDLookup Wise2_EVDLookup; #define EVDLookup Wise2_EVDLookup #define DYNAMITE_DEFINED_EVDLookup #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: bit_halfbit_lookup_ssi(data,query_len,target_len,raw_score) * * Descrip: Internal function for bit conversion * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: query_len [UNKN ] Undocumented argument [int] * Arg: target_len [UNKN ] Undocumented argument [int] * Arg: raw_score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_bit_halfbit_lookup_ssi(void * data,int query_len,int target_len,int raw_score); #define bit_halfbit_lookup_ssi Wise2_bit_halfbit_lookup_ssi /* Function: evalue_halfbit_lookup_ssi(data,a,b,raw_score,database_size) * * Descrip: Internal function for evalue conversion. uses externally * defined parameters for evd estimation * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: a [UNKN ] Undocumented argument [Sequence *] * Arg: b [UNKN ] Undocumented argument [Sequence *] * Arg: raw_score [UNKN ] Undocumented argument [int] * Arg: database_size [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_evalue_halfbit_lookup_ssi(void * data,Sequence * a,Sequence * b,int raw_score,int database_size); #define evalue_halfbit_lookup_ssi Wise2_evalue_halfbit_lookup_ssi /* Function: free_evdlookup_void (data) * * Descrip: Internal function for free... * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_evdlookup_void (void * data); #define free_evdlookup_void Wise2_free_evdlookup_void /* Function: new_lookup_SearchStatInterface(mu,lambda) * * Descrip: Builds an external lookup statistics package * * * Arg: mu [UNKN ] Undocumented argument [double] * Arg: lambda [UNKN ] Undocumented argument [double] * * Return [UNKN ] Undocumented return value [SearchStatInterface *] * */ SearchStatInterface * Wise2_new_lookup_SearchStatInterface(double mu,double lambda); #define new_lookup_SearchStatInterface Wise2_new_lookup_SearchStatInterface /* Function: hard_link_EVDLookup(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [EVDLookup *] * * Return [UNKN ] Undocumented return value [EVDLookup *] * */ EVDLookup * Wise2_hard_link_EVDLookup(EVDLookup * obj); #define hard_link_EVDLookup Wise2_hard_link_EVDLookup /* Function: EVDLookup_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [EVDLookup *] * */ EVDLookup * Wise2_EVDLookup_alloc(void); #define EVDLookup_alloc Wise2_EVDLookup_alloc /* Function: free_EVDLookup(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [EVDLookup *] * * Return [UNKN ] Undocumented return value [EVDLookup *] * */ EVDLookup * Wise2_free_EVDLookup(EVDLookup * obj); #define free_EVDLookup Wise2_free_EVDLookup /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/subseqhash.dy0000644000175000001440000000720607623143003017340 0ustar philippusers %{ #include "sequence.h" #include "seqlookup.h" #include "linkedlist_lookpos.h" #include "glib.h" #include "wisebase.h" %} %{ #include "subseqhash.h" %func Makes a new Glib based SeqLookup system %% SeqLookupInterface * new_ghash_SeqLookupInterface(void) { SeqLookupInterface * out; out = SeqLookupInterface_alloc_std(); out->data = (void*) g_hash_table_new(g_direct_hash,g_direct_equal); out->get_client = get_client_subseqhash_ghash; out->add_seq = add_seq_subseqhash_ghash; out->add_direct_number = add_direct_number_subseqhash_ghash; out->free_data = free_subseqhash_ghash; return out; } %func provides the interface defiition for get_client %% SeqLookupClientInterface * get_client_subseqhash_ghash(void * data) { SeqLookupClientInterface * sci; GHashTable * t = (GHashTable*) data; sci = SeqLookupClientInterface_alloc(); sci->is_populated = is_populated_subseqhash_ghash; sci->lookup = lookup_subseqhash_ghash; sci->free_data = free_client_subseqhash_ghash; sci->data = t; return sci; } %func provides the interface definition for free_data on client, which is actually a no-op in this case %% void free_client_subseqhash_ghash(void * data) { return; } %func Internal function for freeing ghash %% void free_subseqhash_ghash(void * data) { GHashTable * h; h = (GHashTable *) data; g_hash_table_foreach_remove(h,remove_subseq_SeqLookupPos,NULL); g_hash_table_destroy(h); } %func Sub call of free %% gboolean remove_subseq_SeqLookupPos(gpointer key,gpointer value,gpointer user_data) { SeqLookupPos * s; s = (SeqLookupPos *) user_data; if( s != NULL ) { free_SeqLookupPos(s); } return TRUE; } %func Tells whether a position is populated or not %% boolean is_populated_subseqhash_ghash(void * data, int seq_number) { GHashTable * h; h = (GHashTable *) data; /* fprintf(stdout,"Looking up with %d\n",h);*/ if( g_hash_table_lookup(h,(gconstpointer)seq_number) == NULL ) { return FALSE; } else { return TRUE; } } %func Retrieves a SeqLookupPos from the hash %% SeqLookupResultInterface * lookup_subseqhash_ghash(void * data,int seq_number) { GHashTable * h; h = (GHashTable *) data; return new_linkedl_SeqLookupResultInterface((SeqLookupPos *)g_hash_table_lookup(h,(gconstpointer)seq_number)); } %func Adds a sequence/pos pair to the hash with this number %% boolean add_seq_subseqhash_ghash(void * data,Sequence * seq,SeqLookupLoadPara * para) { GHashTable * h; SeqLookupPos * p; SeqLookupPos * ret; int i; int seq_number; h = (GHashTable *) data; assert(para->tile_freq > 0); if( para->tile_freq > 100 ) { info("Tile frequency load greater than 100. That's a little odd"); } for(i=0;ilen-5;i = i+para->tile_freq) { seq_number = seq_number_aa_5mer(seq->seq+i); p = SeqLookupPos_alloc(); p->seq = seq; p->pos = i; p->next = NULL; if((ret = (SeqLookupPos *) g_hash_table_lookup(h,(gconstpointer)seq_number)) == NULL ) { g_hash_table_insert(h,(gpointer)seq_number,p); } else { p->next = ret->next; ret->next = p; } } return TRUE; } %func Adds a direct no/seq pair to the system number %% boolean add_direct_number_subseqhash_ghash(void * data,int seq_number,Sequence * target,int pos) { GHashTable * h; SeqLookupPos * p; SeqLookupPos * ret; h = (GHashTable *) data; p = SeqLookupPos_alloc(); p->seq = target; p->pos = pos; p->next = NULL; if((ret = (SeqLookupPos *) g_hash_table_lookup(h,(gconstpointer)seq_number)) == NULL ) { g_hash_table_insert(h,(gpointer)seq_number,p); } else { p->next = ret->next; ret->next = p; } return TRUE; } %} wise-2.4.1/src/dynlibsrc/histogram.typemap0000644000175000001440000000036010670453712020233 0ustar philippusers TYPEMAP Wise2_Histogram * T_Wise2_Histogram INPUT T_Wise2_Histogram $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_Histogram *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_Histogram sv_setref_pv($arg, "Wise2::Histogram", (void*) $var); wise-2.4.1/src/dynlibsrc/randommodel_api.h0000644000175000001440000001164410670453712020147 0ustar philippusers /* Functions that create, manipulate or act on RandomModelDNA * * Wise2_hard_link_RandomModelDNA * Wise2_RandomModelDNA_alloc * Wise2_replace_name_RandomModelDNA * Wise2_access_name_RandomModelDNA * Wise2_free_RandomModelDNA [destructor] * */ /* Functions that create, manipulate or act on RandomModel * * Wise2_hard_link_RandomModel * Wise2_RandomModel_alloc * Wise2_replace_name_RandomModel * Wise2_access_name_RandomModel * Wise2_free_RandomModel [destructor] * */ /* Helper functions in the module * * Wise2_RandomModelDNA_std * Wise2_default_RandomModel * /* API for object RandomModelDNA */ /* Function: Wise2_hard_link_RandomModelDNA(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_RandomModelDNA *] * * Returns Undocumented return value [Wise2_RandomModelDNA *] * */ Wise2_RandomModelDNA * Wise2_hard_link_RandomModelDNA( Wise2_RandomModelDNA * obj); /* Function: Wise2_RandomModelDNA_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_RandomModelDNA *] * */ Wise2_RandomModelDNA * Wise2_RandomModelDNA_alloc(); /* Function: Wise2_replace_name_RandomModelDNA(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomModelDNA *] * Arg: name New value of the variable [char *] * * Returns member variable name [boolean] * */ boolean Wise2_replace_name_RandomModelDNA( Wise2_RandomModelDNA * obj,char * name); /* Function: Wise2_access_name_RandomModelDNA(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomModelDNA *] * * Returns member variable name [char *] * */ char * Wise2_access_name_RandomModelDNA( Wise2_RandomModelDNA * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_RandomModelDNA(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_RandomModelDNA *] * * Returns Undocumented return value [Wise2_RandomModelDNA *] * */ Wise2_RandomModelDNA * Wise2_free_RandomModelDNA( Wise2_RandomModelDNA * obj); /* API for object RandomModel */ /* Function: Wise2_hard_link_RandomModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_RandomModel *] * * Returns Undocumented return value [Wise2_RandomModel *] * */ Wise2_RandomModel * Wise2_hard_link_RandomModel( Wise2_RandomModel * obj); /* Function: Wise2_RandomModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_RandomModel *] * */ Wise2_RandomModel * Wise2_RandomModel_alloc(); /* Function: Wise2_replace_name_RandomModel(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomModel *] * Arg: name New value of the variable [char *] * * Returns member variable name [boolean] * */ boolean Wise2_replace_name_RandomModel( Wise2_RandomModel * obj,char * name); /* Function: Wise2_access_name_RandomModel(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_RandomModel *] * * Returns member variable name [char *] * */ char * Wise2_access_name_RandomModel( Wise2_RandomModel * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_RandomModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_RandomModel *] * * Returns Undocumented return value [Wise2_RandomModel *] * */ Wise2_RandomModel * Wise2_free_RandomModel( Wise2_RandomModel * obj); /* These functions are not associated with an object */ /* Function: Wise2_RandomModelDNA_std(void) * * Descrip: Returns a structure with 0.25 set in each place * * * * Returns Undocumented return value [Wise2_RandomModelDNA *] * */ Wise2_RandomModelDNA * Wise2_RandomModelDNA_std(); /* Function: Wise2_default_RandomModel(void) * * Descrip: Gives a default random model numbers from * swissprot34- via the HMMEr1 package * * * * Returns Undocumented return value [Wise2_RandomModel *] * */ Wise2_RandomModel * Wise2_default_RandomModel(); wise-2.4.1/src/dynlibsrc/randommodel_api.t0000644000175000001440000000016010670453712020152 0ustar philippuserstypedef struct Wise2_RandomModelDNA Wise2_RandomModelDNA; typedef struct Wise2_RandomModel Wise2_RandomModel; wise-2.4.1/src/dynlibsrc/test_intallocator.c0000644000175000001440000000205507636311132020533 0ustar philippusers #include "intallocator.h" double a_random_0_to_1(void) { double ret; long rnd; rnd = random(); ret = (double)rnd / (double)LONG_MAX; /* fprintf(stderr," got... %D %f\n",rnd,ret);*/ return ret; } int a_random_integer(int l) { double rand; rand = a_random_0_to_1(); return (int) (l*rand); } int main(int argc,char ** argv) { int * alloc_array[4024]; int i; int rnd; IntAllocator * inta; inta = new_IntAllocator(4); srandom(10); for(i=0;i<4024;i++) { alloc_array[i] = NULL; } for(i=0;i<7000;i++) { rnd = a_random_integer(4024); if( alloc_array[rnd] != NULL ) { fprintf(stderr,"Freeing position %d, (count %d)\n",rnd,i); free_intarray_IntAllocator(inta,alloc_array[rnd]); alloc_array[rnd] = NULL; } rnd = a_random_integer(4024); if( alloc_array[rnd] == NULL ) { fprintf(stderr,"allocating position %d, (count %d)\n",rnd,i); alloc_array[rnd] = alloc_intarray_IntAllocator(inta); } } show_allocator_status_IntAllocator(inta,stdout); return 0; } wise-2.4.1/src/dynlibsrc/transcript.dy0000644000175000001440000000757007345671711017404 0ustar philippusers %{ #include "dyna.h" #define TranscriptLISTLENGTH 32 #define ExonLISTLENGTH 128 %} api object Exon des free_Exon endobject object Transcript des free_Transcript func get_cDNA_from_Transcript endobject endapi struct SupportingFeature int start // in exon coordinates int end // in exon coordinates int hstart int hend int hstrand char* hid struct Exon int start int end boolean used; // used by some prediction programs etc double score SupportingFeature ** sf !list int phase !def="-1" friend Translation friend Gene struct Transcript Exon ** exon !list !len="ex_" Gene * parent; !link Translation ** translation !list cDNA * cDNA // may not be here! %info Transcript represents a single spliced product from a gene. The transcript is considered to be a series of exons and it contains, in addition a series of translations. Most genes will only have one translation. Like gene before it, transcript does not necessarily contain DNA. When some DNA is asked from it, via get_cDNA_from_Transcript (notice the change from Genomic typed sequence in Gene to cDNA typed sequence in Transcript) it first checkes the 'cache'. If it is not there, it asks for its parents genomic DNA, and then assemblies the cDNA using the exon coordinates. The exon coordinates are such that 0 means the start of the gene, not the start of the genomic region. (makes some outputs a pain). Supporting Features are added to exons, and, keeping in the spirit of this module, are relative to the exon start. The strand is inherieted from the exon %% %{ #include "transcript.h" %func Makes a completely new copy of the transcript %% Transcript * copy_Transcript(Transcript * t) { Transcript * out; Exon * temp; int i; out = Transcript_alloc(); for(i=0;iex_len;i++) { temp = Exon_alloc(); temp->start = t->exon[i]->start; temp->end = t->exon[i]->end; add_ex_Transcript(out,temp); } for(i=0;ilen;i++) { add_Transcript(out,copy_Translation(t->translation[i])); } return out; } %func gets the cDNA associated with this transcript, if necessary, building it from the exon information provided. returns a soft-linked object. If you want to ensure that this cDNA object remains in memory use /hard_link_cDNA on the object. %arg trs r transcript to get cDNA from return s cDNA of the transcript %% cDNA * get_cDNA_from_Transcript(Transcript * trs) { Genomic * gn; Sequence * base; int i; char buffer[64]; if( trs->cDNA != NULL) return trs->cDNA; if( trs->parent == NULL ) { warn("Cannot get cDNA, as no parent Gene!"); return NULL; } if ( (gn = get_Genomic_from_Gene(trs->parent)) == NULL ) { warn("Cannot get cDNA, as cannot get Genomic sequence from Gene"); return NULL; } base = Sequence_alloc(); sprintf(buffer,"%s.sp",Genomic_name(gn)); base->name = stringalloc(buffer); base->seq = ckcalloc(length_Transcript(trs)+1,sizeof(char)); base->seq[0]='\0'; for(i=0;iex_len;i++) { strncat(base->seq,gn->baseseq->seq+trs->exon[i]->start,trs->exon[i]->end-trs->exon[i]->start); } make_len_type_Sequence(base); base->type = SEQUENCE_CDNA; trs->cDNA = cDNA_from_Sequence(base); return trs->cDNA; } %func returns the length by looking at the exon lengths %% int length_Transcript(Transcript * tr) { int len = 0; int i; for(i=0;iex_len;i++) { len += tr->exon[i]->end - tr->exon[i]->start; } return len; } %func shows a transcript in vaguely human form %% void show_Transcript(Transcript * tr,FILE * ofp) { int i; int k; SupportingFeature * sf; for(i=0;iex_len;i++) { fprintf(ofp,"Exon %d-%d\n",tr->exon[i]->start,tr->exon[i]->end); /* for(k=0;kexon[i]->len;k++) { sf = tr->exon[i]->sf[k]; fprintf(ofp," SF %d %d %d %d\n",sf->start,sf->end,sf->hstart,sf->hend); } */ } for(i=0;ilen;i++) { show_Translation(tr->translation[i],ofp); } } %} wise-2.4.1/src/dynlibsrc/transcript.xs0000644000175000001440000001353110670453713017407 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::Exon Wise2_Exon * hard_link_Exon(obj) Wise2_Exon * obj CODE: RETVAL = Wise2_hard_link_Exon(obj); OUTPUT: RETVAL Wise2_Exon * Exon_alloc_std() CODE: RETVAL = Wise2_Exon_alloc_std(); OUTPUT: RETVAL boolean set_start(obj,start) Wise2_Exon * obj int start CODE: RETVAL = Wise2_replace_start_Exon(obj,start); OUTPUT: RETVAL int start(obj) Wise2_Exon * obj CODE: RETVAL = Wise2_access_start_Exon(obj); OUTPUT: RETVAL boolean set_end(obj,end) Wise2_Exon * obj int end CODE: RETVAL = Wise2_replace_end_Exon(obj,end); OUTPUT: RETVAL int end(obj) Wise2_Exon * obj CODE: RETVAL = Wise2_access_end_Exon(obj); OUTPUT: RETVAL boolean set_used(obj,used) Wise2_Exon * obj boolean used CODE: RETVAL = Wise2_replace_used_Exon(obj,used); OUTPUT: RETVAL boolean used(obj) Wise2_Exon * obj CODE: RETVAL = Wise2_access_used_Exon(obj); OUTPUT: RETVAL boolean set_score(obj,score) Wise2_Exon * obj double score CODE: RETVAL = Wise2_replace_score_Exon(obj,score); OUTPUT: RETVAL double score(obj) Wise2_Exon * obj CODE: RETVAL = Wise2_access_score_Exon(obj); OUTPUT: RETVAL Wise2_SupportingFeature * sf(obj,i) Wise2_Exon * obj int i INIT: Wise2_SupportingFeature * temp; CODE: temp = Wise2_hard_link_SupportingFeature(Wise2_access_sf_Exon(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_sf(obj) Wise2_Exon * obj CODE: RETVAL = Wise2_length_sf_Exon(obj); OUTPUT: RETVAL int flush_sf(obj) Wise2_Exon * obj CODE: RETVAL = Wise2_flush_Exon(obj); OUTPUT: RETVAL boolean add_sf(obj,add) Wise2_Exon * obj Wise2_SupportingFeature * add CODE: RETVAL = Wise2_add_Exon(obj,Wise2_hard_link_SupportingFeature(add)); OUTPUT: RETVAL boolean set_phase(obj,phase) Wise2_Exon * obj int phase CODE: RETVAL = Wise2_replace_phase_Exon(obj,phase); OUTPUT: RETVAL int phase(obj) Wise2_Exon * obj CODE: RETVAL = Wise2_access_phase_Exon(obj); OUTPUT: RETVAL Wise2_Exon * new(class) char * class PPCODE: Wise2_Exon * out; out = Wise2_Exon_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_Exon * obj CODE: Wise2_free_Exon(obj); void each_sf(obj) Wise2_Exon * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_sf_Exon(obj); for(i=0;i #include %func Function for the amino acid to number on 5mers %% int seq_number_aa_5mer_client(char * seq) { int i; int ret = 0; int base = 1; int no = 0; for(i=0;i<5;i++) { no = toupper(seq[i])-'A'; if( no > 26 || no < 0 ) { no = 'X'-'A'; } ret += base * no; base = base * 26; } return ret; } %func Builds a new simple scan interface. This does not expand the query using a matrix but rather simply scans down the query sequence %% HSPScanInterface * new_simple_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off) { HSPScanInterface * out; HSPScanPara * p; assert(sli); assert(mat); out = HSPScanInterface_alloc(); p = HSPScanPara_alloc(); p->sli = hard_link_SeqLookupInterface(sli); p->mat = hard_link_CompMat(mat); p->drop_off = drop_off; out->data = (void*)p; out->free_data = simple_HSPScan_free; out->scan_query = simple_HSPScan_scan_query; return out; } %func Builds a new simple scan interface. This does expands the query using a matrix but just be considering off by one cases %% HSPScanInterface * new_one_off_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff) { HSPScanInterface * out; HSPScanPara * p; assert(sli); assert(mat); out = HSPScanInterface_alloc(); p = HSPScanPara_alloc(); p->sli = hard_link_SeqLookupInterface(sli); p->mat = hard_link_CompMat(mat); p->drop_off = drop_off; p->score_cutoff = score_cutoff; out->data = (void*)p; out->free_data = simple_HSPScan_free; if( sli->lookup_array_head == NULL ) { out->scan_query = one_off_HSPscan_scan_query; } else { out->scan_query = one_off_HSPscan_scan_query_direct; } return out; } %func provide a no op func %% int no_op_func(gpointer data,gpointer user_data,gpointer data2) { return 1; } %func Simple word expansion for direct access %% LinearHSPmanager * one_off_HSPscan_scan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para) { char * std_aa = "ACDEFGHIKLMNPQRSTVWY"; HSPmanager * hspm; LinearHSPmanager * out; HSPScanPara * p = (HSPScanPara *)data; LineariseHSPPara * hsp_para; int i; int j; int k; int aa; int score; char newseq[5]; int jj; int aa2; int has_seen; int seqno[5]; int base[5]; int start_base; int self_score[5]; int total_score; int current_score; ArraySeqHead * head; int no; #ifdef LINUX_TIMER static struct rusage use; struct timeval t1; struct timeval t2; struct timeval t3; #endif assert(seq); assert(p); assert(para); assert(para->max_results > 0); hsp_para = LineariseHSPPara_alloc(); hsp_para->verbosity = para->verbosity; hsp_para->max_size = para->max_results; hsp_para->min_score = para->min_hsp_score; hsp_para->width = para->hsp_link_width; hsp_para->tail = para->hsp_link_length; for(i=0,start_base=1;i<5;i++) { base[i] = start_base; start_base = start_base * 26; } if( VERBOSITY_CHECK(1,para->verbosity) ) { info("processing sequence %s with vanilla implementation",seq->name); } if( COMPILE_VERBOSITY_FLAG == 0 && para->verbosity > 0 ) { info("Verbosity information has not be enable in this compile. Ignoring verbosity request"); } hspm = new_HSPmanager(seq,p->mat,p->drop_off); #ifdef LINUX_TIMER if( VERBOSITY_CHECK(1,para->verbosity) ) { gettimeofday(&t1,NULL); } #endif for(i=0;ilen-5;i++) { if( VERBOSITY_CHECK(2,para->verbosity) && i%50 == 0 ) { info("Scanning %s at position %d with %d hits",seq->name,i,hspm->hsp_count); } head = (*p->sli->lookup_array_head)(p->sli->data,seq_number_aa_5mer_client(seq->seq+i)); if( head != NULL ) { if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { if( VERBOSITY_CHECK(7,para->verbosity) ) { info("position %d hit direct over filled position, %d vs hard %d, low %d",i,head->current_pos,para->numb_level,para->low_numb); } continue; } for(k=0;kcurrent_pos;k++) { if( add_pair_HSPmanager_score(hspm,head->units[k].seq,i,head->units[k].pos,para->min_hsp_score) == TRUE ) { ; } } /* if( p->use_msp_crunch == 1 && head != NULL && head->current_pos > p->msp_crunch_no ) { continue; } */ } total_score = 0; for(score=0,j=0;j<5;j++) { seqno[j] = base[j]*(toupper(seq->seq[i+j])-'A'); self_score[j] = p->mat->comp[toupper(seq->seq[i+j])-'A'][toupper(seq->seq[i+j])-'A']; total_score += self_score[j]; } has_seen = 0; for(j=0;j<5;j++) { for(aa=0;aa<20;aa++) { if( toupper(seq->seq[i+j]) == std_aa[aa] ) { continue; } seqno[j] = base[j]*(std_aa[aa]-'A'); no= seqno[0]+seqno[1]+seqno[2]+seqno[3]+seqno[4]; head = (*p->sli->lookup_array_head)(p->sli->data,no); if( head != NULL ) { if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { if( VERBOSITY_CHECK(7,para->verbosity) ) { info("position %d hit one-off over filled position, %d vs hard %d, low %d",i,head->current_pos,para->numb_level,para->low_numb); } continue; } has_seen = 1; for(k=0;kcurrent_pos;k++) { add_pair_HSPmanager(hspm,head->units[k].seq,i,head->units[k].pos) ; } } seqno[j] = base[j]*(toupper(seq->seq[i+j])-'A'); newseq[j] = seq->seq[i+j]; } /* really at this point we want to see if we have seen any really, really long HSPs, or rather enough long HSPs to remove the need for short HSPs. This is hard because good with two gaps in them will not have potentially three pretty short HSPs. Hmmmm. */ if( 1 || has_seen == 0 ) { /* latin square optimisation. The pattern of 1,1,0,1,0 of active swaps will cover all 2-off positions as the tile is progressed */ for(j=0;j<5;j++) { for(jj=1;jj<5;jj+=2) { for(aa=0;aa<20;aa++) { for(aa2=0;aa2<20;aa2++) { if( seq->seq[i+j] == std_aa[aa] || seq->seq[i+jj] == std_aa[aa2] ) { continue; } current_score = total_score; current_score -= (self_score[j] - p->mat->comp[toupper(seq->seq[i+j])-'A'][std_aa[aa]-'A']); current_score -= (self_score[jj] - p->mat->comp[toupper(seq->seq[i+jj])-'A'][std_aa[aa2]-'A']); if( current_score < para->min_word_score ) { continue; } else { /* fprintf(stderr,"Handling %d,%d amino acid %d,%d score %d\n",j,jj,aa,aa2,current_score); */ } seqno[j] = base[j]*(std_aa[aa]-'A'); seqno[jj] = base[jj]*(std_aa[aa2]-'A'); no= seqno[0]+seqno[1]+seqno[2]+seqno[3]+seqno[4]; head = (*p->sli->lookup_array_head)(p->sli->data,no); if( head != NULL ) { if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { if( VERBOSITY_CHECK(7,para->verbosity) ) { info("position %d hit direct over filled position, %d vs hard %d, low %d",i,head->current_pos,para->numb_level,para->low_numb); } continue; } has_seen = 1; for(k=0;kcurrent_pos;k++) { add_pair_HSPmanager_score(hspm,head->units[k].seq,i,head->units[k].pos,para->min_hsp_score) ; } } seqno[j] = base[j]*(toupper(seq->seq[i+j]-'A')); seqno[jj] = base[jj]*(toupper(seq->seq[i+jj]-'A')); newseq[j] = seq->seq[i+j]; newseq[jj] = seq->seq[i+jj]; } } } } } } } #ifdef LINUX_TIMER if( VERBOSITY_CHECK(1,para->verbosity) ) { getrusage(RUSAGE_SELF,&use); gettimeofday(&t2,NULL); } #endif if( para->use_protein_heuristic == TRUE ) { /* out = new_LinearHSPmanager_flat(hspm);*/ out = new_LinearHSPmanager_simple_heuristic(hspm,hsp_para); } else { out = new_LinearHSPmanager_flat(hspm); } fprintf(stderr,"Made linear manager with %d elements\n",out->len); #ifdef LINUX_TIMER if( VERBOSITY_CHECK(1,para->verbosity) ) { gettimeofday(&t3,NULL); getrusage(RUSAGE_SELF,&use); info("Sort clock point: Scan %f : Sort %f", t2.tv_sec - t1.tv_sec + ((t2.tv_usec - t1.tv_usec) * 1e-6), t3.tv_sec - t2.tv_sec + ((t2.tv_usec - t2.tv_usec) * 1e-6) ); } #endif /* free_HSPmanager(hspm);*/ return out; } %func Simple word expansion - one off score drop considered %% LinearHSPmanager * one_off_HSPscan_scan_query(void * data,Sequence * seq,HSPScanInterfacePara * para) { HSPmanager * hspm; LinearHSPmanager * out; HSPScanPara * p = (HSPScanPara *)data; int i; int j; int aa; int score; int scorepos[5]; char newseq[5]; SeqLookupResultInterface * slri; SeqLookupClientInterface * slci; SeqLookupResultStruct * res = NULL; int trace = 0; assert(seq); assert(p); assert(para); assert(para->max_results > 0); slci = (*p->sli->get_client)(p->sli->data); hspm = new_HSPmanager(seq,p->mat,p->drop_off); for(i=0;ilen-5;i++) { if( trace ) fprintf(stderr,"Looking at %d %.5s (straight)\n",i,seq->seq+i); if( (*slci->is_populated)(slci->data,seq_number_aa_5mer(seq->seq+i)) ) { if( trace ) fprintf(stderr,".... is populated (straight) %d,%d\n",i,seq->seq[i]); slri = (*slci->lookup)(slci->data,seq_number_aa_5mer(seq->seq+i)); if( trace ) fprintf(stderr,".... have results (straight) %d,%d\n",i,seq->seq[i]); res = NULL; for(;(*slri->is_more)(slri->data);) { res = (*slri->next)(slri->data,res); add_pair_HSPmanager(hspm,res->seq,i,res->pos); if( trace ) fprintf(stderr,"...adding direct %.5s\n",res->seq->seq+res->pos); } free_SeqLookupResultInterface(slri); } if( trace ) { fprintf(stderr,"Expanding the sequence\n"); } for(score=0,j=0;j<5;j++) { newseq[j] = seq->seq[i+j]; scorepos[j] = p->mat->comp[seq->seq[i+j]-'A'][seq->seq[i+j]-'A']; score += p->mat->comp[seq->seq[i+j]-'A'][seq->seq[i+j]-'A']; } for(j=0;j<5;j++) { for(aa=0;aa<26;aa++) { if( score - scorepos[j] + p->mat->comp[seq->seq[i+j]-'A'][aa] > p->score_cutoff ) { newseq[j] = aa+'A'; if( trace ) { fprintf(stderr,"Seeing if is populated on expansion %d,%d\n",j,aa); } if( (*slci->is_populated)(slci->data,seq_number_aa_5mer(newseq)) ) { if( trace ) fprintf(stderr,"...is populated %.5s\n",res->seq->seq+res->pos); slri = (*slci->lookup)(slci->data,seq_number_aa_5mer(newseq)); res = NULL; for(;(*slri->is_more)(slri->data);) { res = (*slri->next)(slri->data,res); add_pair_HSPmanager(hspm,res->seq,i,res->pos); if( trace ) fprintf(stderr,"...adding one off %.5s\n",res->seq->seq+res->pos); } free_SeqLookupResultInterface(slri); } newseq[j] = seq->seq[i+j]; } } } } free_SeqLookupClientInterface(slci); if( para->use_protein_heuristic == TRUE ) { out = new_LinearHSPmanager_heuristic_max(hspm,para->max_results); } else { out = new_LinearHSPmanager_flat(hspm); } free_HSPmanager(hspm); return out; } %func simple Scan function, no word expansions %% LinearHSPmanager * simple_HSPScan_scan_query(void * data,Sequence * seq,HSPScanInterfacePara * para) { HSPmanager * hspm; LinearHSPmanager * out; HSPScanPara * p = (HSPScanPara *) data; int i; SeqLookupResultInterface * slri; SeqLookupClientInterface * slci; SeqLookupResultStruct * res = NULL; hspm = new_HSPmanager(seq,p->mat,p->drop_off); slci = (*p->sli->get_client)(p->sli->data); assert(slci); for(i=0;ilen-5;i++) { if( (*slci->is_populated)(slci->data,seq_number_aa_5mer(seq->seq+i)) ) { slri = (*slci->lookup)(slci->data,seq_number_aa_5mer(seq->seq+i)); for(;(*slri->is_more)(slri->data);) { res = (*slri->next)(slri->data,res); add_pair_HSPmanager(hspm,res->seq,i,res->pos); } free_SeqLookupResultInterface(slri); } } free_SeqLookupClientInterface(slci); out = new_LinearHSPmanager_heuristic_max(hspm,para->max_results); free_HSPmanager(hspm); return out; } %func Free function for simple scans %% void simple_HSPScan_free(void * data) { HSPScanPara * p = (HSPScanPara *) data; free_HSPScanPara(p); } wise-2.4.1/src/dynlibsrc/randommodel.dy0000644000175000001440000002244307533727703017512 0ustar philippusers/* Last edited: Apr 23 14:01 1997 (birney) */ %{ #include "wisebase.h" #include "probability.h" #include "codon.h" #include "sequence.h" %} struct RandomModel Probability aminoacid[26]; char * name struct RandomModelScoreaa Score aminoacid[26]; char * name struct RandomCodonScore Score codon[126]; char * name struct RandomCodon Probability codon[126]; char * name struct RandomModelDNA Probability base[5]; char * name; struct RandomModelDNAScore Score base[5] char * name; api object RandomModelDNA des free_RandomModelDNA endobject object RandomModel des free_RandomModel endobject func RandomModelDNA_std func default_RandomModel endapi %{ #include "randommodel.h" %func Draws an amino acid from the random distribution %% char draw_random_aa_RandomModel(RandomModel * rm) { double draw,tot; int i; draw = random_0_to_1(); for(tot=rm->aminoacid[0],i=0;draw > tot && i<26;tot += rm->aminoacid[++i]) ; if( i >= 26 ) { warn("Weird - got a draw %f which outside of random model total %f\n",draw,tot); return '?'; } return 'A'+i; } %func Draws a base from the random distribution %% char draw_random_base_RandomModelDNA(RandomModelDNA * rm) { double draw,tot; int i; draw = random_0_to_1(); for(tot=rm->base[0],i=0;draw > tot && i<4;tot += rm->base[++i]) ; if( i >= 26 ) { warn("Weird - got a draw %f which outside of random model total %f\n",draw,tot); return '?'; } return char_from_base(i); } %func Makes a score RandomCodon (log space) from a probability based random codon %% RandomCodonScore * RandomCodonScore_from_RandomCodon(RandomCodon * rc) { RandomCodonScore * out; out = RandomCodonScore_alloc(); Probability2Score_move(rc->codon,out->codon,126); if( rc-> name != NULL) out->name = stringalloc(rc->name); return out; } %func Sets all probabilities to 1.0 - ie, odds them to themselves. This is equivalent to saying that the randomcodon is being odd-ratioed to itself Also equivalent of saying all the scores (in log space) will be 0 %% void flatten_RandomCodon(RandomCodon * rc) { int i; for(i=0;i<125;i++) rc->codon[i] = 1.0; } %func Makes the randomcodon numbers become the odds ratio between their probabilitys and flat dna random model (0th order markov) %% void fold_in_RandomModelDNA_into_RandomCodon(RandomCodon * rc,RandomModelDNA * rmd) { register int one; register int two; register int three; if( rc == NULL || rmd == NULL ) { warn("Passed in NULL objects to fold_in_RandomModelDNA_into_RandomCodon"); } for(one=0;one < 5;one++) for(two =0;two<5;two ++) for(three=0;three<5;three++) rc->codon[(one*25)+(two*5)+(three)] /= (rmd->base[one]*rmd->base[two]*rmd->base[three]); } %func shows RandomCodonScore for debugging %% void show_RandomCodonScore(RandomCodonScore * rcs,FILE * ofp) { register int i; for(i=0;i<125;i++) { fprintf(ofp,"Score %3d is %d\n",i,rcs->codon[i]); } } %func shows RandomModelsDNAScore for debugging %% void show_RandomModelDNAScore(RandomModelDNAScore * rds,FILE * ofp) { register int i; for(i=0;i<5;i++) { fprintf(ofp,"Base %d[%c], Score %d [prob %.2f]\n",i,char_from_base(i),rds->base[i],Score2Probability(rds->base[i])); } } %func gives a odds ratio between two random models %% RandomModelDNAScore * folded_RandomModelDNAScore_from_2RMD(RandomModelDNA * dis,RandomModelDNA * rnd) { int i; RandomModelDNAScore * out; out = RandomModelDNAScore_alloc(); for(i=0;i<5;i++) out->base[i]= Probability2Score(dis->base[i]/rnd->base[i]); return out; } %func From raw counts (no adjustment to amino acids) of codons gives you a RandomCodon model No prior is used (? perhaps should have a flat prior) N's are handled correctly %% RandomCodon * RandomCodon_from_raw_CodonFrequency(double codon[64],CodonTable *ct) { RandomCodon * out; register int i; double total = 0.0; base one; base two; base three; int o,t,r; /** codon frequencies here *do* include protein amino acid freq... ie, they are raw frequencies, not adjusted for a codon table **/ /** the only thing is that we have to figure out how to deal with N'd codons, which will just be summed over... **/ out= RandomCodon_alloc(); for(i=0;i<64;i++) { total += codon[i]; } for(i=0;i<125;i++) { if( has_random_bases(i) == FALSE ) { out->codon[i] = codon[base4_codon_from_codon(i)]/total; } else { all_bases_from_codon(i,&one,&two,&three); if( one == BASE_N && two != BASE_N && three != BASE_N ) { for(o=0;o<4;o++) out->codon[i] += (codon[o*16+two*4+three]/total); } else if( one == BASE_N && two == BASE_N && three != BASE_N) { for(o=0;o<4;o++) for(t=0;t<4;t++) out->codon[i] += (codon[o*16+t*4+three]/total); } else if( one == BASE_N && two == BASE_N && three == BASE_N) { for(o=0;o<4;o++) for(t=0;t<4;t++) for(r=0;r<4;r++) out->codon[i] += (codon[o*16+t*4+r]/total); } else if( one != BASE_N && two == BASE_N && three != BASE_N) { for(t=0;t<4;t++) out->codon[i] += (codon[one*16+t*4+three]/total); } else if( one != BASE_N && two == BASE_N && three == BASE_N) { for(t=0;t<4;t++) for(r=0;r<4;r++) out->codon[i] += (codon[one*16+t*4+r]/total); } else if( one != BASE_N && two != BASE_N && three == BASE_N) { for(r=0;r<4;r++) out->codon[i] += (codon[one*16+two*4+r]/total); } } } out->codon[125] = 0.0; return out; } %func Makes a flat RandomCodon from CodonTable %% RandomCodon * flat_RandomCodon(CodonTable * ct) { int i; RandomCodon * rc; rc = RandomCodon_alloc(); for(i=0;i<125;i++) { if( is_stop_codon(i,ct) ) { rc->codon[i] = 0.0; } else { rc->codon[i] = 1.0 / 61.0; } } return rc; } %func Gives you a log space RandomModelDNAScore from a probability space one %% RandomModelDNAScore * RandomModelDNAScore_from_RandomModelDNA(RandomModelDNA * rmd) { RandomModelDNAScore * out; register int i; out = RandomModelDNAScore_alloc(); if( out == NULL ) return NULL; for(i=0;i<5;i++) { out->base[i] = Probability2Score(rmd->base[i]); } return out; } %func Returns a structure with 0.25 set in each place %% RandomModelDNA * RandomModelDNA_std(void) { register int i; RandomModelDNA * out; out = RandomModelDNA_alloc(); if( out == NULL ) return NULL; for(i=0;i<4;i++) out->base[i] = (1.0) / 4.0; out->base[4] = 1.0; return out; } %func Set human random model (slightly G/C) Not sure where I got the numbers now. Ooops %% RandomModelDNA * RandomModelDNA_std_human(void) { RandomModelDNA * out; out = RandomModelDNA_alloc(); if( out == NULL ) return NULL; out->base[BASE_A]= 0.245; out->base[BASE_G]= 0.251; out->base[BASE_C]= 0.253; out->base[BASE_T]= 0.248; out->base[BASE_N]= 1.0; return out; } %func Gives the score of a Sequence vs a random model %% Score Score_Sequence_is_random(Sequence * s,RandomModelScoreaa * rms) { register int i; Score sc = 0; for(i=0;ilen;i++) sc += rms->aminoacid[s->seq[i]-'A']; return sc; } %func Gives the probability of a Sequence vs a random model %% Probability Prob_Sequence_is_random(Sequence * s,RandomModel * rm) { register int i; Probability p = 1.0; for(i=0;ilen;i++) { p *= rm->aminoacid[s->seq[i]-'A']; } return p; } %func Gives a score based RandomModel from a probability based one %% RandomModelScoreaa * RandomModelScoreaa_from_RandomModel(RandomModel * rm) { register int i; RandomModelScoreaa * out; out = RandomModelScoreaa_alloc(); if( out == NULL ) return NULL; for(i=0;i<26;i++) out->aminoacid[i] = Probability2Score(rm->aminoacid[i]); return out; } %func Gives a default random model numbers from swissprot34- via the HMMEr1 package %% RandomModel * default_RandomModel(void) { RandomModel * out; int i; out = RandomModel_alloc(); for(i=0;i<26;i++) out->aminoacid[i] = 0.00000001; out->aminoacid['A' -'A'] = 0.08713; out->aminoacid['C' -'A'] = 0.03347; out->aminoacid['D' -'A'] = 0.04687; out->aminoacid['E' -'A'] = 0.04953; out->aminoacid['F' -'A'] = 0.03977; out->aminoacid['G' -'A'] = 0.08861; out->aminoacid['H' -'A'] = 0.03362; out->aminoacid['I' -'A'] = 0.03689; out->aminoacid['K' -'A'] = 0.08048; out->aminoacid['L' -'A'] = 0.08536; out->aminoacid['M' -'A'] = 0.01475; out->aminoacid['N' -'A'] = 0.04043; out->aminoacid['P' -'A'] = 0.05068; out->aminoacid['Q' -'A'] = 0.03826; out->aminoacid['R' -'A'] = 0.04090; out->aminoacid['S' -'A'] = 0.06958; out->aminoacid['T' -'A'] = 0.05854; out->aminoacid['V' -'A'] = 0.06472; out->aminoacid['W' -'A'] = 0.01049; out->aminoacid['Y' -'A'] = 0.02992; return out; } %func Reads a simplistic RandomModel file of C 0.0123 etc type of format %% RandomModel * read_RandomModel(FILE * ifp) { char buffer[MAXLINE]; char c; float f; RandomModel * out; register int i; out = RandomModel_alloc(); if( out == NULL ) return NULL; for(i=0;i<26;i++) out->aminoacid[i] = 0.000001; while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '!' ) continue; sscanf(buffer,"%c %f",&c,&f); c = toupper((int)c); if( c-'A' < 0 || c-'A' > 26 ) { warn("Have picked up an awfully dodgy character [%c] in reading random model",c); } out->aminoacid[c-'A'] = f; } return out; } %} wise-2.4.1/src/dynlibsrc/randommodel.xs0000644000175000001440000000403510670453712017515 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::RandomModelDNA Wise2_RandomModelDNA * hard_link_RandomModelDNA(obj) Wise2_RandomModelDNA * obj CODE: RETVAL = Wise2_hard_link_RandomModelDNA(obj); OUTPUT: RETVAL Wise2_RandomModelDNA * alloc() CODE: RETVAL = Wise2_RandomModelDNA_alloc(); OUTPUT: RETVAL boolean set_name(obj,name) Wise2_RandomModelDNA * obj char * name CODE: RETVAL = Wise2_replace_name_RandomModelDNA(obj,Wise2_stringalloc(name)); OUTPUT: RETVAL char * name(obj) Wise2_RandomModelDNA * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_name_RandomModelDNA(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_RandomModelDNA * new(class) char * class PPCODE: Wise2_RandomModelDNA * out; out = Wise2_RandomModelDNA_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_RandomModelDNA * obj CODE: Wise2_free_RandomModelDNA(obj); MODULE = Wise2 PACKAGE = Wise2::RandomModel Wise2_RandomModel * hard_link_RandomModel(obj) Wise2_RandomModel * obj CODE: RETVAL = Wise2_hard_link_RandomModel(obj); OUTPUT: RETVAL Wise2_RandomModel * alloc() CODE: RETVAL = Wise2_RandomModel_alloc(); OUTPUT: RETVAL boolean set_name(obj,name) Wise2_RandomModel * obj char * name CODE: RETVAL = Wise2_replace_name_RandomModel(obj,Wise2_stringalloc(name)); OUTPUT: RETVAL char * name(obj) Wise2_RandomModel * obj INIT: char * temp; CODE: temp = Wise2_stringalloc(Wise2_access_name_RandomModel(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_RandomModel * new(class) char * class PPCODE: Wise2_RandomModel * out; out = Wise2_RandomModel_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_RandomModel * obj CODE: Wise2_free_RandomModel(obj); MODULE = Wise2 PACKAGE = Wise2 Wise2_RandomModelDNA * RandomModelDNA_std() CODE: RETVAL = Wise2_RandomModelDNA_std(); OUTPUT: RETVAL Wise2_RandomModel * default_RandomModel() CODE: RETVAL = Wise2_default_RandomModel(); OUTPUT: RETVAL wise-2.4.1/src/dynlibsrc/genomic.c0000644000175000001440000005755210670453712016441 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "genomic.h" /* Function: truncate_Genomic(gen,start,stop) * * Descrip: Truncates a Genomic sequence. Basically uses * the /magic_trunc_Sequence function (of course!) * * It does not alter gen, rather it returns a new * sequence with that truncation * * Handles repeat information correctly. * * * Arg: gen [READ ] Genomic that is truncated [Genomic *] * Arg: start [UNKN ] Undocumented argument [int] * Arg: stop [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Genomic *] * */ # line 60 "genomic.dy" Genomic * truncate_Genomic(Genomic * gen,int start,int stop) { Genomic * out; GenomicRepeat * tempr; int tst,tend; int i; out = Genomic_from_Sequence(magic_trunc_Sequence(gen->baseseq,start,stop)); assert(out); for(i=0;ilen;i++) { if( start < stop ) { /* then we have to figure out if this repeat overlaps, and if so, put it in */ if( gen->repeat[i]->start > stop || gen->repeat[i]->end < start ) { continue; } /* overlaps in some way */ tst = gen->repeat[i]->start - start; tend = gen->repeat[i]->end - start; if( tst < 0 ) { tst =0; } if( tend > (stop-start) ) { tend = (stop-start); } } else { /* then we have to figure out if this repeat overlaps, and if so, put it in */ if( gen->repeat[i]->start > start || gen->repeat[i]->end < stop ) { continue; } /* overlaps in some way */ tend = start - gen->repeat[i]->start; tst = start - gen->repeat[i]->end; if( tst < 0 ) { tst =0; } if( tend > (start-stop) ) { tend = (start-stop); } } tempr = GenomicRepeat_alloc(); tempr->start = tst; tempr->end = tend; add_Genomic(out,tempr); } return out; } /* Function: reverse_complement_Genomic(gen) * * Descrip: Reverse Complements s Genomic sequence. * * Handles repeat information correctly * * * Arg: gen [READ ] Genomic that is revomcp [Genomic *] * * Return [UNKN ] Undocumented return value [Genomic *] * */ # line 125 "genomic.dy" Genomic * reverse_complement_Genomic(Genomic * gen) { return truncate_Genomic(gen,gen->baseseq->len,0); } /* Function: read_fasta_file_Genomic(filename,length_of_N) * * Descrip: Reads a fasta file assumming that it is Genomic. * Will complain if it is not, and return NULL. * * * Arg: filename [UNKN ] filename to be opened and read [char *] * Arg: length_of_N [UNKN ] length of N to be considered repeat. -1 means none [int] * * Return [UNKN ] Undocumented return value [Genomic *] * */ # line 138 "genomic.dy" Genomic * read_fasta_file_Genomic(char * filename,int length_of_N) { Sequence * seq; seq = read_fasta_file_Sequence(filename); if( seq == NULL ) { warn("Unable to read sequence from %s [%d], so no genomic",filename,seq); return NULL; } if( length_of_N < 0 ) return Genomic_from_Sequence(seq); else return Genomic_from_Sequence_Nheuristic(seq,length_of_N); } /* Function: read_fasta_Genomic(ifp,length_of_N) * * Descrip: Reads a fasta file assumming that it is Genomic. * Will complain if it is not, and return NULL. * * * Arg: ifp [UNKN ] file point to be read from [FILE *] * Arg: length_of_N [UNKN ] length of N to be considered repeat. -1 means none [int] * * Return [UNKN ] Undocumented return value [Genomic *] * */ # line 164 "genomic.dy" Genomic * read_fasta_Genomic(FILE * ifp,int length_of_N) { Sequence * seq; seq = read_fasta_Sequence(ifp); if( seq == NULL ) { return NULL; } if( length_of_N < 0 ) return Genomic_from_Sequence(seq); else return Genomic_from_Sequence_Nheuristic(seq,length_of_N); } /* Function: Genomic_name(gen) * * Descrip: Returns the name of the Genomic * * * Arg: gen [UNKN ] Undocumented argument [Genomic *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 185 "genomic.dy" char * Genomic_name(Genomic * gen) { return gen->baseseq->name; } /* Function: Genomic_length(gen) * * Descrip: Returns the length of the Genomic * * * Arg: gen [UNKN ] Undocumented argument [Genomic *] * * Return [UNKN ] Undocumented return value [int] * */ # line 194 "genomic.dy" int Genomic_length(Genomic * gen) { return gen->baseseq->len; } /* Function: Genomic_seqchar(gen,pos) * * Descrip: Returns sequence character at this position. * * * Arg: gen [UNKN ] Genomic [Genomic *] * Arg: pos [UNKN ] position in Genomic to get char [int] * * Return [UNKN ] Undocumented return value [char] * */ # line 205 "genomic.dy" char Genomic_seqchar(Genomic * gen,int pos) { return gen->baseseq->seq[pos]; } /* Function: Genomic_from_Sequence_Nheuristic(seq,length_of_N) * * Descrip: makes a new genomic from a Sequence, but * assummes that all the N runs greater than * a certain level are actually repeats. * * * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: length_of_N [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Genomic *] * */ # line 216 "genomic.dy" Genomic * Genomic_from_Sequence_Nheuristic(Sequence * seq,int length_of_N) { Genomic * out; GenomicRepeat * temp; char * run, *run2; out = Genomic_from_Sequence(seq); if( out == NULL ) { warn("Could not make a new Genomic Sequence from Sequence in Nheuristic"); return NULL; } for(run=strchr(seq->seq,'N');run != NULL;) { for(run2 = run; *run2 && *run2 == 'N';run2++) ; if( run2 - run > length_of_N) { temp = GenomicRepeat_alloc(); add_Genomic(out,temp); temp->start = run - seq->seq; temp->end = run2 - seq->seq; } run = strchr(run2,'N'); } return out; } /* Function: Genomic_from_Sequence(seq) * * Descrip: makes a new genomic from a Sequence. It * owns the Sequence memory, ie will attempt a /free_Sequence * on the structure when /free_Genomic is called * * If you want to give this genomic this Sequence and * forget about it, then just hand it this sequence and set * seq to NULL (no need to free it). If you intend to use * the sequence object elsewhere outside of the Genomic datastructure * then use Genomic_from_Sequence(/hard_link_Sequence(seq)) * * This is part of a strict typing system, and therefore * is going to convert all non ATGCNs to Ns. You will lose * information here. * * * Arg: seq [OWNER] Sequence to make genomic from [Sequence *] * * Return [UNKN ] Undocumented return value [Genomic *] * */ # line 261 "genomic.dy" Genomic * Genomic_from_Sequence(Sequence * seq) { Genomic * out; int conv; if( seq == NULL ) { warn("Cannot make a genomic sequence from a NULL sequence"); return NULL; } if( is_dna_Sequence(seq) == FALSE ) { warn("Trying to make a genomic sequence from a non genomic base sequence [%s] Type is %d.",seq->name,seq->type); return NULL; } uppercase_Sequence(seq); force_to_dna_Sequence(seq,1.0,&conv); if( conv != 0 ) { log_full_error(INFO,0,"In making %s a genomic sequence, converted %d bases (%2.1f%%) to N's from non ATGCN",seq->name,conv,(double)conv*100/(double)seq->len); } out = Genomic_alloc_std(); out->baseseq = seq; return out; } /* Function: show_Genomic(gen,ofp) * * Descrip: For debugging * * * Arg: gen [UNKN ] Undocumented argument [Genomic *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 297 "genomic.dy" void show_Genomic(Genomic * gen,FILE * ofp) { int i; assert(gen); write_fasta_Sequence(gen->baseseq,ofp); fprintf(ofp,"%d repeats\n",gen->len); for(i=0;ilen;i++) { if( gen->baseseq->offset < gen->baseseq->end ) fprintf(ofp,"Repeat from %d - %d Biologically: %d - %d \n",gen->repeat[i]->start,gen->repeat[i]->end,gen->baseseq->offset+gen->repeat[i]->start,gen->baseseq->offset -1 + gen->repeat[i]->end); else fprintf(ofp,"Repeat from %d - %d Biologically: %d - %d \n",gen->repeat[i]->start,gen->repeat[i]->end,gen->baseseq->offset - gen->repeat[i]->start,gen->baseseq->offset - gen->repeat[i]->end +1); } } # line 318 "genomic.c" /* Function: hard_link_GenomicRepeat(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomicRepeat *] * * Return [UNKN ] Undocumented return value [GenomicRepeat *] * */ GenomicRepeat * hard_link_GenomicRepeat(GenomicRepeat * obj) { if( obj == NULL ) { warn("Trying to hard link to a GenomicRepeat object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GenomicRepeat_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomicRepeat *] * */ GenomicRepeat * GenomicRepeat_alloc(void) { GenomicRepeat * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenomicRepeat *) ckalloc (sizeof(GenomicRepeat))) == NULL) { warn("GenomicRepeat_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->end = 0; out->type = NULL; return out; } /* Function: free_GenomicRepeat(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomicRepeat *] * * Return [UNKN ] Undocumented return value [GenomicRepeat *] * */ GenomicRepeat * free_GenomicRepeat(GenomicRepeat * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GenomicRepeat obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->type != NULL) ckfree(obj->type); ckfree(obj); return NULL; } /* Function: swap_Genomic(list,i,j) * * Descrip: swap function: an internal for qsort_Genomic * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [GenomicRepeat **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Genomic(GenomicRepeat ** list,int i,int j) { GenomicRepeat * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Genomic(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Genomic which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [GenomicRepeat **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Genomic(GenomicRepeat ** list,int left,int right,int (*comp)(GenomicRepeat * ,GenomicRepeat * )) { int i,last; if( left >= right ) return; swap_Genomic(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Genomic (list,++last,i); } swap_Genomic (list,left,last); qsort_Genomic(list,left,last-1,comp); qsort_Genomic(list,last+1,right,comp); } /* Function: sort_Genomic(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Genomic * * * Arg: obj [UNKN ] Object containing list [Genomic *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Genomic(Genomic * obj,int (*comp)(GenomicRepeat *, GenomicRepeat *)) { qsort_Genomic(obj->repeat,0,obj->len-1,comp); return; } /* Function: expand_Genomic(obj,len) * * Descrip: Really an internal function for add_Genomic * * * Arg: obj [UNKN ] Object which contains the list [Genomic *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Genomic(Genomic * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Genomic called with no need"); return TRUE; } if( (obj->repeat = (GenomicRepeat ** ) ckrealloc (obj->repeat,sizeof(GenomicRepeat *)*len)) == NULL) { warn("ckrealloc failed for expand_Genomic, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Genomic(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Genomic *] * Arg: add [OWNER] Object to add to the list [GenomicRepeat *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Genomic(Genomic * obj,GenomicRepeat * add) { if( obj->len >= obj->maxlen) { if( expand_Genomic(obj,obj->len + GenomicLISTLENGTH) == FALSE) return FALSE; } obj->repeat[obj->len++]=add; return TRUE; } /* Function: flush_Genomic(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Genomic *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Genomic(Genomic * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->repeat[i] != NULL) { free_GenomicRepeat(obj->repeat[i]); obj->repeat[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: Genomic_alloc_std(void) * * Descrip: Equivalent to Genomic_alloc_len(GenomicLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Genomic_alloc_std(void) { return Genomic_alloc_len(GenomicLISTLENGTH); } /* Function: Genomic_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Genomic_alloc_len(int len) { Genomic * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Genomic_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->repeat = (GenomicRepeat ** ) ckcalloc (len,sizeof(GenomicRepeat *))) == NULL) { warn("Warning, ckcalloc failed in Genomic_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_Genomic(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Genomic *] * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * hard_link_Genomic(Genomic * obj) { if( obj == NULL ) { warn("Trying to hard link to a Genomic object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Genomic_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Genomic_alloc(void) { Genomic * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Genomic *) ckalloc (sizeof(Genomic))) == NULL) { warn("Genomic_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->baseseq = NULL; out->repeat = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_Genomic(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Genomic *] * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * free_Genomic(Genomic * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Genomic obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->baseseq != NULL) free_Sequence(obj->baseseq); if( obj->repeat != NULL) { for(i=0;ilen;i++) { if( obj->repeat[i] != NULL) free_GenomicRepeat(obj->repeat[i]); } ckfree(obj->repeat); } ckfree(obj); return NULL; } /* Function: replace_baseseq_Genomic(obj,baseseq) * * Descrip: Replace member variable baseseq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Genomic *] * Arg: baseseq [OWNER] New value of the variable [Sequence *] * * Return [SOFT ] member variable baseseq [boolean] * */ boolean replace_baseseq_Genomic(Genomic * obj,Sequence * baseseq) { if( obj == NULL) { warn("In replacement function baseseq for object Genomic, got a NULL object"); return FALSE; } obj->baseseq = baseseq; return TRUE; } /* Function: access_baseseq_Genomic(obj) * * Descrip: Access member variable baseseq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Genomic *] * * Return [SOFT ] member variable baseseq [Sequence *] * */ Sequence * access_baseseq_Genomic(Genomic * obj) { if( obj == NULL) { warn("In accessor function baseseq for object Genomic, got a NULL object"); return NULL; } return obj->baseseq; } /* Function: access_repeat_Genomic(obj,i) * * Descrip: Access members stored in the repeat list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [Genomic *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [GenomicRepeat *] * */ GenomicRepeat * access_repeat_Genomic(Genomic * obj,int i) { if( obj == NULL) { warn("In accessor function repeat for object Genomic, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function repeat for object Genomic, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->repeat[i]; } /* Function: length_repeat_Genomic(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [Genomic *] * * Return [UNKN ] length of the list [int] * */ int length_repeat_Genomic(Genomic * obj) { if( obj == NULL) { warn("In length function repeat for object Genomic, got a NULL object"); return -1; } return obj->len; } /* Function: replace_start_GenomicRepeat(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicRepeat *] * Arg: start [OWNER] New value of the variable [int] * * Return [SOFT ] member variable start [boolean] * */ boolean replace_start_GenomicRepeat(GenomicRepeat * obj,int start) { if( obj == NULL) { warn("In replacement function start for object GenomicRepeat, got a NULL object"); return FALSE; } obj->start = start; return TRUE; } /* Function: access_start_GenomicRepeat(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicRepeat *] * * Return [SOFT ] member variable start [int] * */ int access_start_GenomicRepeat(GenomicRepeat * obj) { if( obj == NULL) { warn("In accessor function start for object GenomicRepeat, got a NULL object"); return 0; } return obj->start; } /* Function: replace_end_GenomicRepeat(obj,end) * * Descrip: Replace member variable end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicRepeat *] * Arg: end [OWNER] New value of the variable [int] * * Return [SOFT ] member variable end [boolean] * */ boolean replace_end_GenomicRepeat(GenomicRepeat * obj,int end) { if( obj == NULL) { warn("In replacement function end for object GenomicRepeat, got a NULL object"); return FALSE; } obj->end = end; return TRUE; } /* Function: access_end_GenomicRepeat(obj) * * Descrip: Access member variable end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicRepeat *] * * Return [SOFT ] member variable end [int] * */ int access_end_GenomicRepeat(GenomicRepeat * obj) { if( obj == NULL) { warn("In accessor function end for object GenomicRepeat, got a NULL object"); return 0; } return obj->end; } /* Function: replace_type_GenomicRepeat(obj,type) * * Descrip: Replace member variable type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicRepeat *] * Arg: type [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable type [boolean] * */ boolean replace_type_GenomicRepeat(GenomicRepeat * obj,char * type) { if( obj == NULL) { warn("In replacement function type for object GenomicRepeat, got a NULL object"); return FALSE; } obj->type = type; return TRUE; } /* Function: access_type_GenomicRepeat(obj) * * Descrip: Access member variable type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicRepeat *] * * Return [SOFT ] member variable type [char *] * */ char * access_type_GenomicRepeat(GenomicRepeat * obj) { if( obj == NULL) { warn("In accessor function type for object GenomicRepeat, got a NULL object"); return NULL; } return obj->type; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/genomic.h0000644000175000001440000002766010670453712016443 0ustar philippusers#ifndef DYNAMITEgenomicHEADERFILE #define DYNAMITEgenomicHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #define GenomicLISTLENGTH 128 struct Wise2_GenomicRepeat { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start; int end; char * type; } ; /* GenomicRepeat defined */ #ifndef DYNAMITE_DEFINED_GenomicRepeat typedef struct Wise2_GenomicRepeat Wise2_GenomicRepeat; #define GenomicRepeat Wise2_GenomicRepeat #define DYNAMITE_DEFINED_GenomicRepeat #endif struct Wise2_Genomic { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence * baseseq; GenomicRepeat ** repeat; int len;/* len for above repeat */ int maxlen; /* maxlen for above repeat */ } ; /* Genomic defined */ #ifndef DYNAMITE_DEFINED_Genomic typedef struct Wise2_Genomic Wise2_Genomic; #define Genomic Wise2_Genomic #define DYNAMITE_DEFINED_Genomic #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: truncate_Genomic(gen,start,stop) * * Descrip: Truncates a Genomic sequence. Basically uses * the /magic_trunc_Sequence function (of course!) * * It does not alter gen, rather it returns a new * sequence with that truncation * * Handles repeat information correctly. * * * Arg: gen [READ ] Genomic that is truncated [Genomic *] * Arg: start [UNKN ] Undocumented argument [int] * Arg: stop [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Wise2_truncate_Genomic(Genomic * gen,int start,int stop); #define truncate_Genomic Wise2_truncate_Genomic /* Function: reverse_complement_Genomic(gen) * * Descrip: Reverse Complements s Genomic sequence. * * Handles repeat information correctly * * * Arg: gen [READ ] Genomic that is revomcp [Genomic *] * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Wise2_reverse_complement_Genomic(Genomic * gen); #define reverse_complement_Genomic Wise2_reverse_complement_Genomic /* Function: read_fasta_file_Genomic(filename,length_of_N) * * Descrip: Reads a fasta file assumming that it is Genomic. * Will complain if it is not, and return NULL. * * * Arg: filename [UNKN ] filename to be opened and read [char *] * Arg: length_of_N [UNKN ] length of N to be considered repeat. -1 means none [int] * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Wise2_read_fasta_file_Genomic(char * filename,int length_of_N); #define read_fasta_file_Genomic Wise2_read_fasta_file_Genomic /* Function: read_fasta_Genomic(ifp,length_of_N) * * Descrip: Reads a fasta file assumming that it is Genomic. * Will complain if it is not, and return NULL. * * * Arg: ifp [UNKN ] file point to be read from [FILE *] * Arg: length_of_N [UNKN ] length of N to be considered repeat. -1 means none [int] * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Wise2_read_fasta_Genomic(FILE * ifp,int length_of_N); #define read_fasta_Genomic Wise2_read_fasta_Genomic /* Function: Genomic_name(gen) * * Descrip: Returns the name of the Genomic * * * Arg: gen [UNKN ] Undocumented argument [Genomic *] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_Genomic_name(Genomic * gen); #define Genomic_name Wise2_Genomic_name /* Function: Genomic_length(gen) * * Descrip: Returns the length of the Genomic * * * Arg: gen [UNKN ] Undocumented argument [Genomic *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_Genomic_length(Genomic * gen); #define Genomic_length Wise2_Genomic_length /* Function: Genomic_seqchar(gen,pos) * * Descrip: Returns sequence character at this position. * * * Arg: gen [UNKN ] Genomic [Genomic *] * Arg: pos [UNKN ] position in Genomic to get char [int] * * Return [UNKN ] Undocumented return value [char] * */ char Wise2_Genomic_seqchar(Genomic * gen,int pos); #define Genomic_seqchar Wise2_Genomic_seqchar /* Function: Genomic_from_Sequence_Nheuristic(seq,length_of_N) * * Descrip: makes a new genomic from a Sequence, but * assummes that all the N runs greater than * a certain level are actually repeats. * * * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: length_of_N [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Wise2_Genomic_from_Sequence_Nheuristic(Sequence * seq,int length_of_N); #define Genomic_from_Sequence_Nheuristic Wise2_Genomic_from_Sequence_Nheuristic /* Function: Genomic_from_Sequence(seq) * * Descrip: makes a new genomic from a Sequence. It * owns the Sequence memory, ie will attempt a /free_Sequence * on the structure when /free_Genomic is called * * If you want to give this genomic this Sequence and * forget about it, then just hand it this sequence and set * seq to NULL (no need to free it). If you intend to use * the sequence object elsewhere outside of the Genomic datastructure * then use Genomic_from_Sequence(/hard_link_Sequence(seq)) * * This is part of a strict typing system, and therefore * is going to convert all non ATGCNs to Ns. You will lose * information here. * * * Arg: seq [OWNER] Sequence to make genomic from [Sequence *] * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Wise2_Genomic_from_Sequence(Sequence * seq); #define Genomic_from_Sequence Wise2_Genomic_from_Sequence /* Function: show_Genomic(gen,ofp) * * Descrip: For debugging * * * Arg: gen [UNKN ] Undocumented argument [Genomic *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_Genomic(Genomic * gen,FILE * ofp); #define show_Genomic Wise2_show_Genomic /* Function: hard_link_GenomicRepeat(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomicRepeat *] * * Return [UNKN ] Undocumented return value [GenomicRepeat *] * */ GenomicRepeat * Wise2_hard_link_GenomicRepeat(GenomicRepeat * obj); #define hard_link_GenomicRepeat Wise2_hard_link_GenomicRepeat /* Function: GenomicRepeat_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomicRepeat *] * */ GenomicRepeat * Wise2_GenomicRepeat_alloc(void); #define GenomicRepeat_alloc Wise2_GenomicRepeat_alloc /* Function: free_GenomicRepeat(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomicRepeat *] * * Return [UNKN ] Undocumented return value [GenomicRepeat *] * */ GenomicRepeat * Wise2_free_GenomicRepeat(GenomicRepeat * obj); #define free_GenomicRepeat Wise2_free_GenomicRepeat /* Function: add_Genomic(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Genomic *] * Arg: add [OWNER] Object to add to the list [GenomicRepeat *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_Genomic(Genomic * obj,GenomicRepeat * add); #define add_Genomic Wise2_add_Genomic /* Function: flush_Genomic(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Genomic *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_Genomic(Genomic * obj); #define flush_Genomic Wise2_flush_Genomic /* Function: Genomic_alloc_std(void) * * Descrip: Equivalent to Genomic_alloc_len(GenomicLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Wise2_Genomic_alloc_std(void); #define Genomic_alloc_std Wise2_Genomic_alloc_std /* Function: Genomic_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Wise2_Genomic_alloc_len(int len); #define Genomic_alloc_len Wise2_Genomic_alloc_len /* Function: hard_link_Genomic(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Genomic *] * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Wise2_hard_link_Genomic(Genomic * obj); #define hard_link_Genomic Wise2_hard_link_Genomic /* Function: Genomic_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Wise2_Genomic_alloc(void); #define Genomic_alloc Wise2_Genomic_alloc /* Function: free_Genomic(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Genomic *] * * Return [UNKN ] Undocumented return value [Genomic *] * */ Genomic * Wise2_free_Genomic(Genomic * obj); #define free_Genomic Wise2_free_Genomic /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ char * Wise2_access_type_GenomicRepeat(GenomicRepeat * obj); #define access_type_GenomicRepeat Wise2_access_type_GenomicRepeat GenomicRepeat * Wise2_access_repeat_Genomic(Genomic * obj,int i); #define access_repeat_Genomic Wise2_access_repeat_Genomic int Wise2_length_repeat_Genomic(Genomic * obj); #define length_repeat_Genomic Wise2_length_repeat_Genomic boolean Wise2_replace_start_GenomicRepeat(GenomicRepeat * obj,int start); #define replace_start_GenomicRepeat Wise2_replace_start_GenomicRepeat boolean Wise2_replace_type_GenomicRepeat(GenomicRepeat * obj,char * type); #define replace_type_GenomicRepeat Wise2_replace_type_GenomicRepeat int Wise2_access_start_GenomicRepeat(GenomicRepeat * obj); #define access_start_GenomicRepeat Wise2_access_start_GenomicRepeat Sequence * Wise2_access_baseseq_Genomic(Genomic * obj); #define access_baseseq_Genomic Wise2_access_baseseq_Genomic boolean Wise2_replace_end_GenomicRepeat(GenomicRepeat * obj,int end); #define replace_end_GenomicRepeat Wise2_replace_end_GenomicRepeat boolean Wise2_replace_baseseq_Genomic(Genomic * obj,Sequence * baseseq); #define replace_baseseq_Genomic Wise2_replace_baseseq_Genomic int Wise2_access_end_GenomicRepeat(GenomicRepeat * obj); #define access_end_GenomicRepeat Wise2_access_end_GenomicRepeat void Wise2_swap_Genomic(GenomicRepeat ** list,int i,int j) ; #define swap_Genomic Wise2_swap_Genomic void Wise2_qsort_Genomic(GenomicRepeat ** list,int left,int right,int (*comp)(GenomicRepeat * ,GenomicRepeat * )); #define qsort_Genomic Wise2_qsort_Genomic void Wise2_sort_Genomic(Genomic * obj,int (*comp)(GenomicRepeat *, GenomicRepeat *)); #define sort_Genomic Wise2_sort_Genomic boolean Wise2_expand_Genomic(Genomic * obj,int len); #define expand_Genomic Wise2_expand_Genomic #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/arrayseqlookup.c0000644000175000001440000003573710670453712020102 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "arrayseqlookup.h" typedef struct ArraySeqClient_struct { ArraySeqHeadResults result; SeqLookupResultInterface interface; ArraySeqLookup * array; } ArraySeqClient; static ArraySeqClient * ArraySeqClient_alloc(void) { ArraySeqClient * out; out = malloc(sizeof(ArraySeqClient)); return out; } /* Function: new_ArraySeq_SeqLookupInterface(len,numb_level) * * Descrip: Exported function - makes a new seqlookupinterface in array mode * * * Arg: len [UNKN ] Undocumented argument [int] * Arg: numb_level [UNKN ] Undocumented argument [long] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ # line 49 "arrayseqlookup.dy" SeqLookupInterface * new_ArraySeq_SeqLookupInterface(int len,long numb_level) { SeqLookupInterface * out; out = SeqLookupInterface_alloc_std(); out->data = (void*) new_ArraySeqLookup(len,numb_level); out->get_client = get_client_arraylookup; out->add_seq = add_seq_arraylookup; out->free_data = free_data_arraylookup; out->lookup_array_head = arrayhead_direct_lookup; return out; } /* Function: print_array_occuypancy_ArraySeq(asl,ofp) * * Descrip: Prints out summary statistcis to a file * * * Arg: asl [UNKN ] Undocumented argument [ArraySeqLookup *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 70 "arrayseqlookup.dy" void print_array_occuypancy_ArraySeq(ArraySeqLookup * asl,FILE * ofp) { int i; for(i=0;ilen;i++) { if( asl->array[i] == NULL ) { fprintf(ofp,"%d EMPTY\n",i); } else { fprintf(ofp,"%d full %d\n",i,asl->array[i]->current_pos); } } } /* Function: get_client_arraylookup(*data) * * Descrip: Builds a new client from Array * * * Arg: *data [UNKN ] Undocumented argument [void] * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ # line 87 "arrayseqlookup.dy" SeqLookupClientInterface * get_client_arraylookup(void *data) { ArraySeqLookup * array = (ArraySeqLookup *) data; ArraySeqClient * cli; SeqLookupClientInterface * slci; cli = ArraySeqClient_alloc(); cli->interface.next = next_arrayhead_search_results; cli->interface.is_more = is_more_arrayhead_search_results; cli->interface.free_data = free_arrayhead_results; cli->interface.data = (void *) &(cli->result); cli->result.ipos = 0; cli->array = array; slci = SeqLookupClientInterface_alloc(); slci->lookup = lookup_array_client; slci->is_populated = is_populated_array_client; slci->free_data = free_array_client; slci->data = (void*) cli; return slci; } /* Function: next_arrayhead_search_results(data,prev) * * Descrip: Internal function for results interface * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: prev [UNKN ] Undocumented argument [SeqLookupResultStruct *] * * Return [UNKN ] Undocumented return value [SeqLookupResultStruct *] * */ # line 116 "arrayseqlookup.dy" SeqLookupResultStruct * next_arrayhead_search_results(void * data,SeqLookupResultStruct * prev) { ArraySeqHeadResults * a = (ArraySeqHeadResults *) data; if( a->ipos >= a->head->current_pos ) { fatal("Overran array!"); } a->str.seq = a->head->units[a->ipos].seq; a->str.pos = a->head->units[a->ipos].pos; a->ipos++; return &(a->str); } /* Function: is_more_arrayhead_search_results(data) * * Descrip: Internal function for results interface * * * Arg: data [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 136 "arrayseqlookup.dy" boolean is_more_arrayhead_search_results(void * data) { ArraySeqHeadResults * a = (ArraySeqHeadResults *) data; if( a->ipos >= a->head->current_pos ) { return FALSE; } return TRUE; } /* Function: free_arrayhead_results(data) * * Descrip: Internal function for results interface, which is a no-op * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 151 "arrayseqlookup.dy" void free_arrayhead_results(void * data) { return; } /* Function: free_array_client(data) * * Descrip: Internal function for client interface, which frees client specific memory * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 161 "arrayseqlookup.dy" void free_array_client(void * data) { ArraySeqClient * cli = (ArraySeqClient*) data; free(cli); } /* Function: new_ArraySeqLookup(len,numb_level) * * Descrip: makes a new ArraySeqLookup taking up * to len positions * * * Arg: len [UNKN ] Undocumented argument [int] * Arg: numb_level [UNKN ] Undocumented argument [long] * * Return [UNKN ] Undocumented return value [ArraySeqLookup *] * */ # line 173 "arrayseqlookup.dy" ArraySeqLookup * new_ArraySeqLookup(int len,long numb_level) { int i; ArraySeqLookup * out; out = ArraySeqLookup_alloc(); out->array = calloc(len,sizeof(ArraySeqHead*)); assert(out->array); for(i=0;iarray[i] = NULL; } out->len = len; out->numb_level = numb_level; return out; } /* Function: is_populated_array_client(data,seq_number) * * Descrip: tells whether this is populated or not * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 197 "arrayseqlookup.dy" boolean is_populated_array_client(void * data, int seq_number) { ArraySeqClient * cli = (ArraySeqClient *)data; if( cli->array->array[seq_number] == NULL ) { return FALSE; } else { return TRUE; } } /* Function: lookup_array_client(data,seq_number) * * Descrip: Retrieves a SeqLookup position * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ # line 212 "arrayseqlookup.dy" SeqLookupResultInterface * lookup_array_client(void * data, int seq_number) { ArraySeqClient * cli = (ArraySeqClient *)data; if( cli->array->array[seq_number] == NULL ) { return NULL; } cli->result.ipos = 0; cli->result.head = cli->array->array[seq_number]; return &(cli->interface); } /* Function: arrayhead_direct_lookup(data,seq_number) * * Descrip: For array optimised lookup hash, provides direct memory access * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ArraySeqHead *] * */ # line 229 "arrayseqlookup.dy" ArraySeqHead * arrayhead_direct_lookup(void * data,int seq_number) { ArraySeqLookup * look = (ArraySeqLookup *)data; /* fprintf(stderr,"In arrayhead direct lookup with %d\n",seq_number);*/ return look->array[seq_number]; } /* Function: add_seq_arraylookup(data,seq,para) * * Descrip: Adds a sequence/pos pair to the hash * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 242 "arrayseqlookup.dy" boolean add_seq_arraylookup(void * data,Sequence * seq,SeqLookupLoadPara * para) { int i; ArraySeqLookup * look = (ArraySeqLookup *)data; int seq_number; assert(data != NULL); assert(seq != NULL); assert(para != NULL); for(i=0;ilen-5;i = i+para->tile_freq) { seq_number = seq_number_aa_5mer(seq->seq+i); if( look->array[seq_number] == NULL ) { look->array[seq_number] = new_ArraySeqHead(); if( para->mark_low_complexity ) { look->array[seq_number]->flags = flags_from_5aa_sequence(seq->seq+i); } } add_ArraySeqHead(look->array[seq_number],seq,i,look->numb_level); } return TRUE; } /* Function: free_data_arraylookup(data) * * Descrip: Frees data * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 272 "arrayseqlookup.dy" void free_data_arraylookup(void * data) { ArraySeqLookup * look = (ArraySeqLookup *)data; int i; for(i=0;ilen;i++) { if( look->array[i] == NULL ) { continue; } ckfree(look->array[i]->units); ckfree(look->array[i]); } free_ArraySeqLookup(look); } /* Function: add_ArraySeqHead(h,seq,pos,numb_level) * * Descrip: Adds a sequence/pos pair to an ArrayHead * * * Arg: h [UNKN ] Undocumented argument [ArraySeqHead *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: pos [UNKN ] Undocumented argument [int] * Arg: numb_level [UNKN ] Undocumented argument [long] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 292 "arrayseqlookup.dy" boolean add_ArraySeqHead(ArraySeqHead * h,Sequence * seq,int pos,long numb_level) { ArraySeqLookupUnit * temp; if( numb_level > 0 && h->current_pos > numb_level ) { return TRUE; } /* fprintf(stderr,"adding new sequence position with %d max pos %d\n",h->current_pos,h->max); */ if( h->current_pos >= h->max ) { temp = h->units; if( h->max < ARRAYSEQL_LINEAR ) { h->units = realloc(h->units,(h->max*2)*sizeof(ArraySeqLookupUnit)); h->max = h->max*2; } else { h->units = realloc(h->units,(h->max + ARRAYSEQL_LINEAR)*sizeof(ArraySeqLookupUnit)); h->max = h->max + ARRAYSEQL_LINEAR; } if( h->units == NULL ) { fatal("ArraySeqLookup realloc failed trying for %d positions\n",h->max); } /* fprintf(stderr,"... extended to %d\n",h->max); */ } h->units[h->current_pos].seq = seq; h->units[h->current_pos].pos = pos; h->current_pos++; return TRUE; } /* Function: new_ArraySeqHead(void) * * Descrip: Builds a new ArraySeqHead structure * * * * Return [UNKN ] Undocumented return value [ArraySeqHead *] * */ # line 332 "arrayseqlookup.dy" ArraySeqHead * new_ArraySeqHead(void) { ArraySeqHead * out; out = malloc(sizeof(ArraySeqHead)); out->units = calloc(ARRAYSEQL_BASIC,sizeof(ArraySeqLookupUnit)); out->max = ARRAYSEQL_BASIC; out->current_pos = 0; return out; } # line 416 "arrayseqlookup.c" /* Function: hard_link_ArraySeqLookup(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ArraySeqLookup *] * * Return [UNKN ] Undocumented return value [ArraySeqLookup *] * */ ArraySeqLookup * hard_link_ArraySeqLookup(ArraySeqLookup * obj) { if( obj == NULL ) { warn("Trying to hard link to a ArraySeqLookup object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ArraySeqLookup_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ArraySeqLookup *] * */ ArraySeqLookup * ArraySeqLookup_alloc(void) { ArraySeqLookup * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ArraySeqLookup *) ckalloc (sizeof(ArraySeqLookup))) == NULL) { warn("ArraySeqLookup_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->array = NULL; out->len = 0; out->numb_level = 0; return out; } /* Function: free_ArraySeqLookup(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ArraySeqLookup *] * * Return [UNKN ] Undocumented return value [ArraySeqLookup *] * */ ArraySeqLookup * free_ArraySeqLookup(ArraySeqLookup * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ArraySeqLookup obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->array != NULL) ckfree(obj->array); ckfree(obj); return NULL; } /* Function: hard_link_ArraySeqHeadResults(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ArraySeqHeadResults *] * * Return [UNKN ] Undocumented return value [ArraySeqHeadResults *] * */ ArraySeqHeadResults * hard_link_ArraySeqHeadResults(ArraySeqHeadResults * obj) { if( obj == NULL ) { warn("Trying to hard link to a ArraySeqHeadResults object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ArraySeqHeadResults_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ArraySeqHeadResults *] * */ ArraySeqHeadResults * ArraySeqHeadResults_alloc(void) { ArraySeqHeadResults * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ArraySeqHeadResults *) ckalloc (sizeof(ArraySeqHeadResults))) == NULL) { warn("ArraySeqHeadResults_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->ipos = 0; return out; } /* Function: free_ArraySeqHeadResults(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ArraySeqHeadResults *] * * Return [UNKN ] Undocumented return value [ArraySeqHeadResults *] * */ ArraySeqHeadResults * free_ArraySeqHeadResults(ArraySeqHeadResults * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ArraySeqHeadResults obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->head is linked in */ /* obj->str is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/arrayseqlookup.h0000644000175000001440000002433710670453712020101 0ustar philippusers#ifndef DYNAMITEarrayseqlookupHEADERFILE #define DYNAMITEarrayseqlookupHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "seqlookup.h" #define ARRAYSEQL_BASIC 8 #define ARRAYSEQL_LINEAR 500 struct Wise2_ArraySeqLookup { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ArraySeqHead ** array; int len; long numb_level; } ; /* ArraySeqLookup defined */ #ifndef DYNAMITE_DEFINED_ArraySeqLookup typedef struct Wise2_ArraySeqLookup Wise2_ArraySeqLookup; #define ArraySeqLookup Wise2_ArraySeqLookup #define DYNAMITE_DEFINED_ArraySeqLookup #endif struct Wise2_ArraySeqHeadResults { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int ipos; ArraySeqHead * head; SeqLookupResultStruct str; } ; /* ArraySeqHeadResults defined */ #ifndef DYNAMITE_DEFINED_ArraySeqHeadResults typedef struct Wise2_ArraySeqHeadResults Wise2_ArraySeqHeadResults; #define ArraySeqHeadResults Wise2_ArraySeqHeadResults #define DYNAMITE_DEFINED_ArraySeqHeadResults #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_ArraySeq_SeqLookupInterface(len,numb_level) * * Descrip: Exported function - makes a new seqlookupinterface in array mode * * * Arg: len [UNKN ] Undocumented argument [int] * Arg: numb_level [UNKN ] Undocumented argument [long] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * Wise2_new_ArraySeq_SeqLookupInterface(int len,long numb_level); #define new_ArraySeq_SeqLookupInterface Wise2_new_ArraySeq_SeqLookupInterface /* Function: print_array_occuypancy_ArraySeq(asl,ofp) * * Descrip: Prints out summary statistcis to a file * * * Arg: asl [UNKN ] Undocumented argument [ArraySeqLookup *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_print_array_occuypancy_ArraySeq(ArraySeqLookup * asl,FILE * ofp); #define print_array_occuypancy_ArraySeq Wise2_print_array_occuypancy_ArraySeq /* Function: get_client_arraylookup(*data) * * Descrip: Builds a new client from Array * * * Arg: *data [UNKN ] Undocumented argument [void] * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ SeqLookupClientInterface * Wise2_get_client_arraylookup(void *data); #define get_client_arraylookup Wise2_get_client_arraylookup /* Function: next_arrayhead_search_results(data,prev) * * Descrip: Internal function for results interface * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: prev [UNKN ] Undocumented argument [SeqLookupResultStruct *] * * Return [UNKN ] Undocumented return value [SeqLookupResultStruct *] * */ SeqLookupResultStruct * Wise2_next_arrayhead_search_results(void * data,SeqLookupResultStruct * prev); #define next_arrayhead_search_results Wise2_next_arrayhead_search_results /* Function: is_more_arrayhead_search_results(data) * * Descrip: Internal function for results interface * * * Arg: data [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_more_arrayhead_search_results(void * data); #define is_more_arrayhead_search_results Wise2_is_more_arrayhead_search_results /* Function: free_arrayhead_results(data) * * Descrip: Internal function for results interface, which is a no-op * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_arrayhead_results(void * data); #define free_arrayhead_results Wise2_free_arrayhead_results /* Function: free_array_client(data) * * Descrip: Internal function for client interface, which frees client specific memory * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_array_client(void * data); #define free_array_client Wise2_free_array_client /* Function: new_ArraySeqLookup(len,numb_level) * * Descrip: makes a new ArraySeqLookup taking up * to len positions * * * Arg: len [UNKN ] Undocumented argument [int] * Arg: numb_level [UNKN ] Undocumented argument [long] * * Return [UNKN ] Undocumented return value [ArraySeqLookup *] * */ ArraySeqLookup * Wise2_new_ArraySeqLookup(int len,long numb_level); #define new_ArraySeqLookup Wise2_new_ArraySeqLookup /* Function: is_populated_array_client(data,seq_number) * * Descrip: tells whether this is populated or not * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_populated_array_client(void * data, int seq_number); #define is_populated_array_client Wise2_is_populated_array_client /* Function: lookup_array_client(data,seq_number) * * Descrip: Retrieves a SeqLookup position * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ SeqLookupResultInterface * Wise2_lookup_array_client(void * data, int seq_number); #define lookup_array_client Wise2_lookup_array_client /* Function: arrayhead_direct_lookup(data,seq_number) * * Descrip: For array optimised lookup hash, provides direct memory access * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ArraySeqHead *] * */ ArraySeqHead * Wise2_arrayhead_direct_lookup(void * data,int seq_number); #define arrayhead_direct_lookup Wise2_arrayhead_direct_lookup /* Function: add_seq_arraylookup(data,seq,para) * * Descrip: Adds a sequence/pos pair to the hash * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_seq_arraylookup(void * data,Sequence * seq,SeqLookupLoadPara * para); #define add_seq_arraylookup Wise2_add_seq_arraylookup /* Function: free_data_arraylookup(data) * * Descrip: Frees data * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_data_arraylookup(void * data); #define free_data_arraylookup Wise2_free_data_arraylookup /* Function: add_ArraySeqHead(h,seq,pos,numb_level) * * Descrip: Adds a sequence/pos pair to an ArrayHead * * * Arg: h [UNKN ] Undocumented argument [ArraySeqHead *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: pos [UNKN ] Undocumented argument [int] * Arg: numb_level [UNKN ] Undocumented argument [long] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_ArraySeqHead(ArraySeqHead * h,Sequence * seq,int pos,long numb_level); #define add_ArraySeqHead Wise2_add_ArraySeqHead /* Function: new_ArraySeqHead(void) * * Descrip: Builds a new ArraySeqHead structure * * * * Return [UNKN ] Undocumented return value [ArraySeqHead *] * */ ArraySeqHead * Wise2_new_ArraySeqHead(void); #define new_ArraySeqHead Wise2_new_ArraySeqHead /* Function: hard_link_ArraySeqLookup(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ArraySeqLookup *] * * Return [UNKN ] Undocumented return value [ArraySeqLookup *] * */ ArraySeqLookup * Wise2_hard_link_ArraySeqLookup(ArraySeqLookup * obj); #define hard_link_ArraySeqLookup Wise2_hard_link_ArraySeqLookup /* Function: ArraySeqLookup_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ArraySeqLookup *] * */ ArraySeqLookup * Wise2_ArraySeqLookup_alloc(void); #define ArraySeqLookup_alloc Wise2_ArraySeqLookup_alloc /* Function: free_ArraySeqLookup(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ArraySeqLookup *] * * Return [UNKN ] Undocumented return value [ArraySeqLookup *] * */ ArraySeqLookup * Wise2_free_ArraySeqLookup(ArraySeqLookup * obj); #define free_ArraySeqLookup Wise2_free_ArraySeqLookup /* Function: hard_link_ArraySeqHeadResults(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ArraySeqHeadResults *] * * Return [UNKN ] Undocumented return value [ArraySeqHeadResults *] * */ ArraySeqHeadResults * Wise2_hard_link_ArraySeqHeadResults(ArraySeqHeadResults * obj); #define hard_link_ArraySeqHeadResults Wise2_hard_link_ArraySeqHeadResults /* Function: ArraySeqHeadResults_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ArraySeqHeadResults *] * */ ArraySeqHeadResults * Wise2_ArraySeqHeadResults_alloc(void); #define ArraySeqHeadResults_alloc Wise2_ArraySeqHeadResults_alloc /* Function: free_ArraySeqHeadResults(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ArraySeqHeadResults *] * * Return [UNKN ] Undocumented return value [ArraySeqHeadResults *] * */ ArraySeqHeadResults * Wise2_free_ArraySeqHeadResults(ArraySeqHeadResults * obj); #define free_ArraySeqHeadResults Wise2_free_ArraySeqHeadResults /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/dbsearchimpl.pod0000644000175000001440000001317610670453712020007 0ustar philippusers=head1 NAME dbsearchimpl module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item DBSearchImpl =back =head1 DESCRIPTION =head2 Object DBSearchImpl =over =item type Type [int] Scalar No documentation =item trace_level Type [int] Scalar how much debugging information to print =item trace_file Type [FILE *] Scalar for writing out trace of db stuff =item suggest_thread_no Type [int] Scalar default, -1, means the use a call to _SC_NPROC =item search_routine Type [int] Scalar routine used for the calculation, exact/kbest =back DBSearchImpl contains the information about the database search implementation used in a dynamite call. This is the only object which needs to specify say threads vs serial code The construction of this object is from its own stripping of the command line. This way programs which do database searching need not know anything about the implementation that is being used by the dynamite compiler From the API you should be looking to make it from one of the handy constructors. For the threads code, if you leave the suggest_thread_no at (-1) - what it usually comes as for the constructors. The system then figures out the number of processors available on the machine and sets it to that. =head2 Member functions of DBSearchImpl =over =item string &Wise2::DBSearchImpl::string(dbsi) Gets a static text string out of the search implementation Argument dbsi [UNKN ] Undocumented argument [DBSearchImpl *] Return [SOFT ] string of the search implementation [char *] =item hard_link_DBSearchImpl &Wise2::DBSearchImpl::hard_link_DBSearchImpl(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [DBSearchImpl *] Return [UNKN ] Undocumented return value [DBSearchImpl *] =item alloc &Wise2::DBSearchImpl::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [DBSearchImpl *] =item set_type &Wise2::DBSearchImpl::set_type(obj,type) Replace member variable type For use principly by API functions Argument obj [UNKN ] Object holding the variable [DBSearchImpl *] Argument type [OWNER] New value of the variable [int] Return [SOFT ] member variable type [boolean] =item type &Wise2::DBSearchImpl::type(obj) Access member variable type For use principly by API functions Argument obj [UNKN ] Object holding the variable [DBSearchImpl *] Return [SOFT ] member variable type [int] =item set_trace_level &Wise2::DBSearchImpl::set_trace_level(obj,trace_level) Replace member variable trace_level For use principly by API functions Argument obj [UNKN ] Object holding the variable [DBSearchImpl *] Argument trace_level [OWNER] New value of the variable [int] Return [SOFT ] member variable trace_level [boolean] =item trace_level &Wise2::DBSearchImpl::trace_level(obj) Access member variable trace_level For use principly by API functions Argument obj [UNKN ] Object holding the variable [DBSearchImpl *] Return [SOFT ] member variable trace_level [int] =item set_trace_file &Wise2::DBSearchImpl::set_trace_file(obj,trace_file) Replace member variable trace_file For use principly by API functions Argument obj [UNKN ] Object holding the variable [DBSearchImpl *] Argument trace_file [OWNER] New value of the variable [FILE *] Return [SOFT ] member variable trace_file [boolean] =item trace_file &Wise2::DBSearchImpl::trace_file(obj) Access member variable trace_file For use principly by API functions Argument obj [UNKN ] Object holding the variable [DBSearchImpl *] Return [SOFT ] member variable trace_file [FILE *] =item set_suggest_thread_no &Wise2::DBSearchImpl::set_suggest_thread_no(obj,suggest_thread_no) Replace member variable suggest_thread_no For use principly by API functions Argument obj [UNKN ] Object holding the variable [DBSearchImpl *] Argument suggest_thread_no [OWNER] New value of the variable [int] Return [SOFT ] member variable suggest_thread_no [boolean] =item suggest_thread_no &Wise2::DBSearchImpl::suggest_thread_no(obj) Access member variable suggest_thread_no For use principly by API functions Argument obj [UNKN ] Object holding the variable [DBSearchImpl *] Return [SOFT ] member variable suggest_thread_no [int] =item set_search_routine &Wise2::DBSearchImpl::set_search_routine(obj,search_routine) Replace member variable search_routine For use principly by API functions Argument obj [UNKN ] Object holding the variable [DBSearchImpl *] Argument search_routine [OWNER] New value of the variable [int] Return [SOFT ] member variable search_routine [boolean] =item search_routine &Wise2::DBSearchImpl::search_routine(obj) Access member variable search_routine For use principly by API functions Argument obj [UNKN ] Object holding the variable [DBSearchImpl *] Return [SOFT ] member variable search_routine [int] =back =over =item new_pthread_DBSearchImpl &Wise2::new_pthread_DBSearchImpl(void) Makes a new pthreaded DBSearchImpl For use mainly for api's who don't want to initalize the object from the command line Return [UNKN ] Undocumented return value [DBSearchImpl *] =item new_serial_DBSearchImpl &Wise2::new_serial_DBSearchImpl(void) Makes a new serial DBSearchImpl For use mainly for api's who don't want to initalize the object from the command line Return [UNKN ] Undocumented return value [DBSearchImpl *] =back wise-2.4.1/src/dynlibsrc/dbsearchimpl.tex0000644000175000001440000000560310670453712020021 0ustar philippusers\section{dbsearchimpl} \label{module_dbsearchimpl} This module contains the following objects \begin{itemize} \item \ref{object_DBSearchImpl} DBSearchImpl \item This module also contains some factory methods \end{itemize} \subsection{dbsearchimpl factory methods} \subsubsection{new_pthread_DBSearchImpl} \begin{description} \item[External C] {\tt Wise2_new_pthread_DBSearchImpl (void)} \item[Perl] {\tt &Wise2::new_pthread_DBSearchImpl ()} \end{description} Arguments \begin{description} \item[returns] [UNKN ] Undocumented return value [DBSearchImpl *] \end{description} Makes a new pthreaded DBSearchImpl For use mainly for api's who don't want to initalize the object from the command line \subsubsection{new_serial_DBSearchImpl} \begin{description} \item[External C] {\tt Wise2_new_serial_DBSearchImpl (void)} \item[Perl] {\tt &Wise2::new_serial_DBSearchImpl ()} \end{description} Arguments \begin{description} \item[returns] [UNKN ] Undocumented return value [DBSearchImpl *] \end{description} Makes a new serial DBSearchImpl For use mainly for api's who don't want to initalize the object from the command line \subsection{Object DBSearchImpl} \label{object_DBSearchImpl} The DBSearchImpl object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{type} Type [int : Scalar] No documentation \item{trace_level} Type [int : Scalar] how much debugging information to print \item{trace_file} Type [FILE * : Scalar] for writing out trace of db stuff \item{suggest_thread_no} Type [int : Scalar] default, -1, means the use a call to _SC_NPROC \item{search_routine} Type [int : Scalar] routine used for the calculation, exact/kbest \end{description} DBSearchImpl contains the information about the database search implementation used in a dynamite call. This is the only object which needs to specify say threads vs serial code The construction of this object is from its own stripping of the command line. This way programs which do database searching need not know anything about the implementation that is being used by the dynamite compiler From the API you should be looking to make it from one of the handy constructors. For the threads code, if you leave the suggest_thread_no at (-1) - what it usually comes as for the constructors. The system then figures out the number of processors available on the machine and sets it to that. Member functions of DBSearchImpl \subsubsection{impl_string_DBSearchImpl} \begin{description} \item[External C] {\tt Wise2_impl_string_DBSearchImpl (dbsi)} \item[Perl] {\tt &Wise2::DBSearchImpl::string (dbsi)} \item[Perl-OOP call] {\tt $obj->string()} \end{description} Arguments \begin{description} \item[dbsi] [UNKN ] Undocumented argument [DBSearchImpl *] \item[returns] [SOFT ] string of the search implementation [char *] \end{description} Gets a static text string out of the search implementation wise-2.4.1/src/dynlibsrc/compmat.pod0000644000175000001440000000555010670453712017007 0ustar philippusers=head1 NAME compmat module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item CompMat =back =head1 DESCRIPTION =head2 Object CompMat =over =item comp[26][26] Type [Score] Scalar No documentation =item name Type [char *] Scalar if any, could be NULL =back This object stores BLOSUM and PAM comparison matrices. It stores them as scores: NB - this means probabilistically we are talking about some arbitary base of log which is really annoying. =head2 Member functions of CompMat =over =item fail_safe_CompMat_access &Wise2::CompMat::fail_safe_CompMat_access(cm,aa1,aa2) gives the fail form of the macro CompMat_AAMATCH which checks that aa1 and a2 are sensible and that cm is not NULL. Argument cm [UNKN ] compmat object [CompMat *] Argument aa1 [UNKN ] first amino acid [int] Argument aa2 [UNKN ] second amino acid [int] Return [UNKN ] Undocumented return value [Score] =item write_Blast_CompMat &Wise2::CompMat::write_Blast_CompMat(cm,ofp) writes a protien CompMat with a standard alphabet. Argument cm [UNKN ] CompMat object [CompMat *] Argument ofp [UNKN ] file to output [FILE *] Return [UNKN ] Undocumented return value [boolean] =item read_Blast_file_CompMat &Wise2::CompMat::read_Blast_file_CompMat(filename) Opens file, reads matrix, closes file. calls /read_Blast_CompMat for the actual format reading. Uses /openfile to open the file, so will open from config files. Argument filename [UNKN ] Undocumented argument [char *] Return [UNKN ] Undocumented return value [CompMat *] =item read_Blast_CompMat &Wise2::CompMat::read_Blast_CompMat(ifp) reads a BLAST format matrix and allocates a new ComMat structure. Argument ifp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [CompMat *] =item hard_link_CompMat &Wise2::CompMat::hard_link_CompMat(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [CompMat *] Return [UNKN ] Undocumented return value [CompMat *] =item alloc &Wise2::CompMat::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [CompMat *] =item set_name &Wise2::CompMat::set_name(obj,name) Replace member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [CompMat *] Argument name [OWNER] New value of the variable [char *] Return [SOFT ] member variable name [boolean] =item name &Wise2::CompMat::name(obj) Access member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [CompMat *] Return [SOFT ] member variable name [char *] =back wise-2.4.1/src/dynlibsrc/compmat.tex0000644000175000001440000000553610670453712017031 0ustar philippusers\section{compmat} \label{module_compmat} This module contains the following objects \begin{itemize} \item \ref{object_CompMat} CompMat \end{itemize} \subsection{Object CompMat} \label{object_CompMat} The CompMat object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{comp[26][26]} Type [Score : Scalar] No documentation \item{name} Type [char * : Scalar] if any, could be NULL \end{description} This object stores BLOSUM and PAM comparison matrices. It stores them as scores: NB - this means probabilistically we are talking about some arbitary base of log which is really annoying. Member functions of CompMat \subsubsection{fail_safe_CompMat_access} \begin{description} \item[External C] {\tt Wise2_fail_safe_CompMat_access (cm,aa1,aa2)} \item[Perl] {\tt &Wise2::CompMat::fail_safe_CompMat_access (cm,aa1,aa2)} \item[Perl-OOP call] {\tt $obj->fail_safe_CompMat_access(aa1,aa2)} \end{description} Arguments \begin{description} \item[cm] [UNKN ] compmat object [CompMat *] \item[aa1] [UNKN ] first amino acid [int] \item[aa2] [UNKN ] second amino acid [int] \item[returns] [UNKN ] Undocumented return value [Score] \end{description} gives the fail form of the macro CompMat_AAMATCH which checks that aa1 and a2 are sensible and that cm is not NULL. \subsubsection{write_Blast_CompMat} \begin{description} \item[External C] {\tt Wise2_write_Blast_CompMat (cm,ofp)} \item[Perl] {\tt &Wise2::CompMat::write_Blast_CompMat (cm,ofp)} \item[Perl-OOP call] {\tt $obj->write_Blast_CompMat(ofp)} \end{description} Arguments \begin{description} \item[cm] [UNKN ] CompMat object [CompMat *] \item[ofp] [UNKN ] file to output [FILE *] \item[returns] [UNKN ] Undocumented return value [boolean] \end{description} writes a protien CompMat with a standard alphabet. \subsubsection{read_Blast_file_CompMat} \begin{description} \item[External C] {\tt Wise2_read_Blast_file_CompMat (filename)} \item[Perl] {\tt &Wise2::CompMat::read_Blast_file_CompMat (filename)} \item[Perl-OOP call] {\tt $obj->read_Blast_file_CompMat()} \end{description} Arguments \begin{description} \item[filename] [UNKN ] Undocumented argument [char *] \item[returns] [UNKN ] Undocumented return value [CompMat *] \end{description} Opens file, reads matrix, closes file. calls /read_Blast_CompMat for the actual format reading. Uses /openfile to open the file, so will open from config files. \subsubsection{read_Blast_CompMat} \begin{description} \item[External C] {\tt Wise2_read_Blast_CompMat (ifp)} \item[Perl] {\tt &Wise2::CompMat::read_Blast_CompMat (ifp)} \item[Perl-OOP call] {\tt $obj->read_Blast_CompMat()} \end{description} Arguments \begin{description} \item[ifp] [UNKN ] Undocumented argument [FILE *] \item[returns] [UNKN ] Undocumented return value [CompMat *] \end{description} reads a BLAST format matrix and allocates a new ComMat structure. wise-2.4.1/src/dynlibsrc/translation.c0000644000175000001440000002321710670453713017346 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "translation.h" /* Function: copy_Translation(t) * * Descrip: Makes a complete clean copy of the translation * * * Arg: t [UNKN ] Undocumented argument [Translation *] * * Return [UNKN ] Undocumented return value [Translation *] * */ # line 50 "translation.dy" Translation * copy_Translation(Translation * t) { Translation * out; out = Translation_alloc(); out->start = t->start; out->end = t->end; return out; } /* Function: get_Protein_from_Translation(ts,ct) * * Descrip: Gets the protein * * * Arg: ts [UNKN ] translation [Translation *] * Arg: ct [UNKN ] codon table to use [CodonTable *] * * Return [SOFT ] Protein sequence [Protein *] * */ # line 68 "translation.dy" Protein * get_Protein_from_Translation(Translation * ts,CodonTable * ct) { cDNA * cd; int i,j; Sequence * seq; char buffer[64]; assert(ts); assert(ct); /* fprintf(stderr,"Codon table is %d\n",ct);*/ if( ts->protein != NULL) return ts->protein; if( ts->parent == NULL ) { warn("Cannot get Protein from translation as no parent!"); return NULL; } cd = get_cDNA_from_Transcript(ts->parent); if( cd == NULL ) { warn("Cannot make translation as can't get transcript!"); return NULL; } if( cd->baseseq == NULL ) { warn("A bad error - a non NULL cDNA with a null sequence object. No translation here!"); return NULL; } if( cd->baseseq->len == 0 ) { warn("Attempting to translate a zero length cDNA. Yikes!"); return NULL; } seq = Sequence_alloc(); sprintf(buffer,"%s.tr",cDNA_name(cd)); seq->name = stringalloc(buffer); seq->seq = ckcalloc((cd->baseseq->len/3) + 2,sizeof(char)); seq->type = SEQUENCE_PROTEIN; if( cd->baseseq->len%3 != 0 ) { warn("Problem in making translation, cDNA is not mod3! - length is %d - transcript id %s",cd->baseseq->len,seq->name); } for(i=0,j=0;ibaseseq->len;i+=3,j++) { if( is_stop_codon(codon_from_seq(cd->baseseq->seq+i),ct) == TRUE ) { if( i+3 >= cd->baseseq->len ) break; else { warn("Got a stop codon in the middle of a translation at postion [%d]. Yuk!",i); seq->seq[j] = '*'; } } else { seq->seq[j] = aminoacid_from_seq(ct,cd->baseseq->seq+i); } } seq->seq[j]='\0'; make_len_type_Sequence(seq); /*write_fasta_Sequence(seq,stdout);*/ seq->type = SEQUENCE_PROTEIN; ts->protein = Protein_from_Sequence(seq); return ts->protein; } /* Function: show_Translation(*ts,ofp) * * Descrip: shows a translation in vaguely human form * * * Arg: *ts [UNKN ] Undocumented argument [Translation] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 144 "translation.dy" void show_Translation(Translation *ts,FILE * ofp) { fprintf(ofp,"Translation %d - %d\n",ts->start,ts->end); } # line 122 "translation.c" /* Function: hard_link_Translation(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Translation *] * * Return [UNKN ] Undocumented return value [Translation *] * */ Translation * hard_link_Translation(Translation * obj) { if( obj == NULL ) { warn("Trying to hard link to a Translation object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Translation_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Translation *] * */ Translation * Translation_alloc(void) { Translation * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Translation *) ckalloc (sizeof(Translation))) == NULL) { warn("Translation_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->end = 0; out->protein = NULL; return out; } /* Function: free_Translation(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Translation *] * * Return [UNKN ] Undocumented return value [Translation *] * */ Translation * free_Translation(Translation * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Translation obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->parent is linked in */ if( obj->protein != NULL) free_Protein(obj->protein); ckfree(obj); return NULL; } /* Function: replace_start_Translation(obj,start) * * Descrip: Replace member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Translation *] * Arg: start [OWNER] New value of the variable [int] * * Return [SOFT ] member variable start [boolean] * */ boolean replace_start_Translation(Translation * obj,int start) { if( obj == NULL) { warn("In replacement function start for object Translation, got a NULL object"); return FALSE; } obj->start = start; return TRUE; } /* Function: access_start_Translation(obj) * * Descrip: Access member variable start * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Translation *] * * Return [SOFT ] member variable start [int] * */ int access_start_Translation(Translation * obj) { if( obj == NULL) { warn("In accessor function start for object Translation, got a NULL object"); return 0; } return obj->start; } /* Function: replace_end_Translation(obj,end) * * Descrip: Replace member variable end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Translation *] * Arg: end [OWNER] New value of the variable [int] * * Return [SOFT ] member variable end [boolean] * */ boolean replace_end_Translation(Translation * obj,int end) { if( obj == NULL) { warn("In replacement function end for object Translation, got a NULL object"); return FALSE; } obj->end = end; return TRUE; } /* Function: access_end_Translation(obj) * * Descrip: Access member variable end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Translation *] * * Return [SOFT ] member variable end [int] * */ int access_end_Translation(Translation * obj) { if( obj == NULL) { warn("In accessor function end for object Translation, got a NULL object"); return 0; } return obj->end; } /* Function: replace_parent_Translation(obj,parent) * * Descrip: Replace member variable parent * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Translation *] * Arg: parent [OWNER] New value of the variable [Transcript *] * * Return [SOFT ] member variable parent [boolean] * */ boolean replace_parent_Translation(Translation * obj,Transcript * parent) { if( obj == NULL) { warn("In replacement function parent for object Translation, got a NULL object"); return FALSE; } obj->parent = parent; return TRUE; } /* Function: access_parent_Translation(obj) * * Descrip: Access member variable parent * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Translation *] * * Return [SOFT ] member variable parent [Transcript *] * */ Transcript * access_parent_Translation(Translation * obj) { if( obj == NULL) { warn("In accessor function parent for object Translation, got a NULL object"); return NULL; } return obj->parent; } /* Function: replace_protein_Translation(obj,protein) * * Descrip: Replace member variable protein * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Translation *] * Arg: protein [OWNER] New value of the variable [Protein *] * * Return [SOFT ] member variable protein [boolean] * */ boolean replace_protein_Translation(Translation * obj,Protein * protein) { if( obj == NULL) { warn("In replacement function protein for object Translation, got a NULL object"); return FALSE; } obj->protein = protein; return TRUE; } /* Function: access_protein_Translation(obj) * * Descrip: Access member variable protein * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Translation *] * * Return [SOFT ] member variable protein [Protein *] * */ Protein * access_protein_Translation(Translation * obj) { if( obj == NULL) { warn("In accessor function protein for object Translation, got a NULL object"); return NULL; } return obj->protein; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/translation.h0000644000175000001440000001107210670453713017347 0ustar philippusers#ifndef DYNAMITEtranslationHEADERFILE #define DYNAMITEtranslationHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #ifndef DYNAMITE_DEFINED_Transcript typedef struct Wise2_Transcript Wise2_Transcript; #define Transcript Wise2_Transcript #define DYNAMITE_DEFINED_Transcript #endif /* Object Translation * * Descrip: No Description * */ struct Wise2_Translation { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start; int end; Transcript * parent; Protein * protein; } ; /* Translation defined */ #ifndef DYNAMITE_DEFINED_Translation typedef struct Wise2_Translation Wise2_Translation; #define Translation Wise2_Translation #define DYNAMITE_DEFINED_Translation #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: copy_Translation(t) * * Descrip: Makes a complete clean copy of the translation * * * Arg: t [UNKN ] Undocumented argument [Translation *] * * Return [UNKN ] Undocumented return value [Translation *] * */ Translation * Wise2_copy_Translation(Translation * t); #define copy_Translation Wise2_copy_Translation /* Function: get_Protein_from_Translation(ts,ct) * * Descrip: Gets the protein * * * Arg: ts [UNKN ] translation [Translation *] * Arg: ct [UNKN ] codon table to use [CodonTable *] * * Return [SOFT ] Protein sequence [Protein *] * */ Protein * Wise2_get_Protein_from_Translation(Translation * ts,CodonTable * ct); #define get_Protein_from_Translation Wise2_get_Protein_from_Translation /* Function: show_Translation(*ts,ofp) * * Descrip: shows a translation in vaguely human form * * * Arg: *ts [UNKN ] Undocumented argument [Translation] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_Translation(Translation *ts,FILE * ofp); #define show_Translation Wise2_show_Translation /* Function: hard_link_Translation(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Translation *] * * Return [UNKN ] Undocumented return value [Translation *] * */ Translation * Wise2_hard_link_Translation(Translation * obj); #define hard_link_Translation Wise2_hard_link_Translation /* Function: Translation_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Translation *] * */ Translation * Wise2_Translation_alloc(void); #define Translation_alloc Wise2_Translation_alloc /* Function: free_Translation(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Translation *] * * Return [UNKN ] Undocumented return value [Translation *] * */ Translation * Wise2_free_Translation(Translation * obj); #define free_Translation Wise2_free_Translation /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_start_Translation(Translation * obj,int start); #define replace_start_Translation Wise2_replace_start_Translation boolean Wise2_replace_parent_Translation(Translation * obj,Transcript * parent); #define replace_parent_Translation Wise2_replace_parent_Translation int Wise2_access_start_Translation(Translation * obj); #define access_start_Translation Wise2_access_start_Translation Transcript * Wise2_access_parent_Translation(Translation * obj); #define access_parent_Translation Wise2_access_parent_Translation int Wise2_access_end_Translation(Translation * obj); #define access_end_Translation Wise2_access_end_Translation boolean Wise2_replace_protein_Translation(Translation * obj,Protein * protein); #define replace_protein_Translation Wise2_replace_protein_Translation boolean Wise2_replace_end_Translation(Translation * obj,int end); #define replace_end_Translation Wise2_replace_end_Translation Protein * Wise2_access_protein_Translation(Translation * obj); #define access_protein_Translation Wise2_access_protein_Translation #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/staticseq.c0000644000175000001440000000763110670453713017012 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "staticseq.h" /* Function: new_StaticSeqHolder(void) * * Descrip: makes a new StaticSeqHolder * * * * Return [UNKN ] Undocumented return value [StaticSeqHolder *] * */ # line 25 "staticseq.dy" StaticSeqHolder * new_StaticSeqHolder(void) { StaticSeqHolder * out; out = StaticSeqHolder_alloc(); assert(out); out->gstring_chunk = g_string_chunk_new(1024*1024); return out; } /* Function: free_GStringChunk(gs) * * Descrip: for registering glib thingy for freeing * * * Arg: gs [UNKN ] Undocumented argument [GStringChunk *] * * Return [UNKN ] Undocumented return value [GStringChunk *] * */ # line 39 "staticseq.dy" GStringChunk * free_GStringChunk(GStringChunk * gs) { assert(gs); g_string_chunk_free(gs); return NULL; } /* Function: new_Sequence_StaticSeqHolder(ssh,seq) * * Descrip: Making a new sequence from a staticseq holder - consumes * the sequence object (actually recycling the shell of it) * * * Arg: ssh [UNKN ] Undocumented argument [StaticSeqHolder *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 51 "staticseq.dy" Sequence * new_Sequence_StaticSeqHolder(StaticSeqHolder * ssh,Sequence * seq) { char * str; assert(seq); assert(ssh); assert(ssh->gstring_chunk); str = g_string_chunk_insert(ssh->gstring_chunk,seq->seq); ckfree(seq->seq); seq->seq = str; seq->dynamite_hard_link++; return seq; } # line 70 "staticseq.c" /* Function: hard_link_StaticSeqHolder(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [StaticSeqHolder *] * * Return [UNKN ] Undocumented return value [StaticSeqHolder *] * */ StaticSeqHolder * hard_link_StaticSeqHolder(StaticSeqHolder * obj) { if( obj == NULL ) { warn("Trying to hard link to a StaticSeqHolder object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: StaticSeqHolder_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [StaticSeqHolder *] * */ StaticSeqHolder * StaticSeqHolder_alloc(void) { StaticSeqHolder * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(StaticSeqHolder *) ckalloc (sizeof(StaticSeqHolder))) == NULL) { warn("StaticSeqHolder_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->gstring_chunk = NULL; return out; } /* Function: free_StaticSeqHolder(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [StaticSeqHolder *] * * Return [UNKN ] Undocumented return value [StaticSeqHolder *] * */ StaticSeqHolder * free_StaticSeqHolder(StaticSeqHolder * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a StaticSeqHolder obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->gstring_chunk != NULL) free_GStringChunk(obj->gstring_chunk); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/staticseq.h0000644000175000001440000000720310670453713017012 0ustar philippusers#ifndef DYNAMITEstaticseqHEADERFILE #define DYNAMITEstaticseqHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #include /* Object StaticSeqHolder * * Descrip: Makes sequences with optimised * static memory, but the sequences * cannot be freed individually * * */ struct Wise2_StaticSeqHolder { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif GStringChunk * gstring_chunk; } ; /* StaticSeqHolder defined */ #ifndef DYNAMITE_DEFINED_StaticSeqHolder typedef struct Wise2_StaticSeqHolder Wise2_StaticSeqHolder; #define StaticSeqHolder Wise2_StaticSeqHolder #define DYNAMITE_DEFINED_StaticSeqHolder #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_StaticSeqHolder(void) * * Descrip: makes a new StaticSeqHolder * * * * Return [UNKN ] Undocumented return value [StaticSeqHolder *] * */ StaticSeqHolder * Wise2_new_StaticSeqHolder(void); #define new_StaticSeqHolder Wise2_new_StaticSeqHolder /* Function: free_GStringChunk(gs) * * Descrip: for registering glib thingy for freeing * * * Arg: gs [UNKN ] Undocumented argument [GStringChunk *] * * Return [UNKN ] Undocumented return value [GStringChunk *] * */ GStringChunk * Wise2_free_GStringChunk(GStringChunk * gs); #define free_GStringChunk Wise2_free_GStringChunk /* Function: new_Sequence_StaticSeqHolder(ssh,seq) * * Descrip: Making a new sequence from a staticseq holder - consumes * the sequence object (actually recycling the shell of it) * * * Arg: ssh [UNKN ] Undocumented argument [StaticSeqHolder *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_new_Sequence_StaticSeqHolder(StaticSeqHolder * ssh,Sequence * seq); #define new_Sequence_StaticSeqHolder Wise2_new_Sequence_StaticSeqHolder /* Function: hard_link_StaticSeqHolder(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [StaticSeqHolder *] * * Return [UNKN ] Undocumented return value [StaticSeqHolder *] * */ StaticSeqHolder * Wise2_hard_link_StaticSeqHolder(StaticSeqHolder * obj); #define hard_link_StaticSeqHolder Wise2_hard_link_StaticSeqHolder /* Function: StaticSeqHolder_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [StaticSeqHolder *] * */ StaticSeqHolder * Wise2_StaticSeqHolder_alloc(void); #define StaticSeqHolder_alloc Wise2_StaticSeqHolder_alloc /* Function: free_StaticSeqHolder(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [StaticSeqHolder *] * * Return [UNKN ] Undocumented return value [StaticSeqHolder *] * */ StaticSeqHolder * Wise2_free_StaticSeqHolder(StaticSeqHolder * obj); #define free_StaticSeqHolder Wise2_free_StaticSeqHolder /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/proteinindexcons.dy0000644000175000001440000000613510416534547020600 0ustar philippusers %{ #include "arrayseqlookup.h" #include "subseqhash.h" #include "proteinstreamedindex.h" #include "shadowseqindex.h" typedef enum ProteinIndexConstructorType { ProteinIndexConstructor_Array = 78, ProteinIndexConstructor_Hash, ProteinIndexConstructor_Stream, ProteinIndexConstructor_Shadow } ProteinIndexConstructureType; %} struct ProteinIndexConstructor int type !def="ProteinIndexConstructor_Array"; int waypost !def="3" int shadowlength !def="15" int has_maxlen !def="0" int max_seqlen !def="1000" int shadow_error !def="3" %{ #include "proteinindexcons.h" %func Makes a new SeqLookupInterface from ProteinIndexConstructor %% SeqLookupInterface * new_SeqLookupInterface_from_ProteinIndexConstructor(ProteinIndexConstructor * pic) { switch(pic->type) { case ProteinIndexConstructor_Array : return new_ArraySeq_SeqLookupInterface(SEQLOOKUP_5AA_SIZE,1000); case ProteinIndexConstructor_Hash : return new_ghash_SeqLookupInterface(); case ProteinIndexConstructor_Stream : return new_ProteinStreamedIndex_SeqLookupInterface(pic->waypost); case ProteinIndexConstructor_Shadow : return new_ShadowSequenceIndex_SeqLookupInterface(pic->shadowlength,pic->has_maxlen,pic->max_seqlen,pic->shadow_error); default: fatal("Cannot process type %d as protein index constructor",pic->type); } return NULL; } %func provides help for protein index constructor %% void show_help_ProteinIndexConstructor(FILE * ofp) { fprintf(ofp,"Protein Index construction options\n"); fprintf(ofp," -pitype [array/hash/stream/shadow] - default array\n"); fprintf(ofp," -piwaypost [number] - waypost for streamed cases, default 3\n"); fprintf(ofp," -pishadow [number] - shadow length for shadow cases, default 15\n"); fprintf(ofp," -pishadow_err [number] - errors per 100 identities tolerated, 3\n"); fprintf(ofp," -piseqmax - indexes can assumme maximum length of seq\n"); fprintf(ofp," -piseqmax_len [number] - assummed max sequnce length, default 1000\n"); return; } %func Provides a ProteinIndexConstructor argument from argv %% ProteinIndexConstructor * new_ProteinIndexConstructor_from_argv(int * argc,char ** argv) { ProteinIndexConstructor * out; char * temp; out = ProteinIndexConstructor_alloc(); temp = strip_out_assigned_argument(argc,argv,"pitype"); if( temp != NULL ) { if( strcmp(temp,"array") == 0 ) { out->type = ProteinIndexConstructor_Array; } else if ( strcmp(temp,"hash") == 0 ) { out->type = ProteinIndexConstructor_Hash; } else if ( strcmp(temp,"stream") == 0 ) { out->type = ProteinIndexConstructor_Stream; } else if ( strcmp(temp,"shadow") == 0 ) { out->type = ProteinIndexConstructor_Shadow; } else { fatal("Could not interpret %s as a protein index type",temp); } } strip_out_integer_argument(argc,argv,"piwaypost",&out->waypost); strip_out_integer_argument(argc,argv,"pishadow",&out->shadowlength); strip_out_boolean_def_argument(argc,argv,"piseqmax",&out->waypost); strip_out_integer_argument(argc,argv,"piseqmax_len",&out->shadowlength); return out; } wise-2.4.1/src/dynlibsrc/sequence.typemap0000644000175000001440000000074610670453713020057 0ustar philippusers TYPEMAP Wise2_Sequence * T_Wise2_Sequence INPUT T_Wise2_Sequence $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_Sequence *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_Sequence sv_setref_pv($arg, "Wise2::Sequence", (void*) $var); TYPEMAP Wise2_SequenceSet * T_Wise2_SequenceSet INPUT T_Wise2_SequenceSet $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_SequenceSet *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_SequenceSet sv_setref_pv($arg, "Wise2::SequenceSet", (void*) $var); wise-2.4.1/src/dynlibsrc/cdna.typemap0000644000175000001440000000032210670453712017141 0ustar philippusers TYPEMAP Wise2_cDNA * T_Wise2_cDNA INPUT T_Wise2_cDNA $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_cDNA *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_cDNA sv_setref_pv($arg, "Wise2::cDNA", (void*) $var); wise-2.4.1/src/dynlibsrc/genomicregion.dy0000644000175000001440000006211407657732677020052 0ustar philippusers %{ #include "dyna.h" #define GenomicRegionLISTLENGTH 16 #define GenomicOverlapResultsLISTLENGTH 16 %} api object GenomicRegion des free_GenomicRegion func new_GenomicRegion func read_EMBL_GenomicRegion_file func read_EMBL_GenomicRegion func add_Gene_to_GenomicRegion func show_ace_GenomicRegion func show_pretty_GenomicRegion func write_Diana_FT_GenomicRegion func write_Embl_FT_GenomicRegion endobject endapi friend Gene struct GenomicRegion Gene ** gene !list Genomic * genomic // NB, may not be here. Be careful! %info GenomicRegion is structure which represents information on a region of genomic DNA. It *may not* have the actual DNA sequence in there, and it is important to realise that. The numbering scheme of many other things (eg, genes) are going to be represented in this guys coordinates %% struct GenomicOverlapGene int exon_perfect !def="0" int exon_truncated !def="0" int exon_partial !def="0" int exon_missed_internal !def="0" int exon_missed_external !def="0" int exon_mispredicted !def="0" Gene * truth // NB hard-linked Gene * test struct GenomicOverlapResults int gene_overlap GenomicOverlapGene ** gog !list struct ShowGenomicRegionOptions boolean show_trans !def="0" boolean show_raw !def="0" boolean show_cdna !def="0" boolean show_ace !def="0" boolean show_ace_halfwise !def="0" boolean show_GFF !def="0" boolean show_gene_str !def="0" boolean show_gene_supp !def="0" %{ #include "genomicregion.h" %func Makes a new genomic region with genes greater than XXX length going through %% GenomicRegion * new_GenomicRegion_discard_short(GenomicRegion * gr,int multiexon,int singleexon) { GenomicRegion * out; int i; assert(gr); assert(gr->genomic); out = GenomicRegion_alloc_std(); assert(out); if( gr->genomic != NULL ) { out->genomic = hard_link_Genomic(gr->genomic); } for(i=0;ilen;i++) { if( gr->gene[i]->len == 0 ) { continue; } assert(gr->gene[i]->transcript[0]); if( gr->gene[i]->transcript[0]->ex_len > 1 ) { if( length_Transcript(gr->gene[i]->transcript[0]) > multiexon ) { add_GenomicRegion(out,hard_link_Gene(gr->gene[i])); } } else { if( length_Transcript(gr->gene[i]->transcript[0]) > singleexon ) { add_GenomicRegion(out,hard_link_Gene(gr->gene[i])); } } } return out; } %func Actually shows a genomic region wrt to the options %% void show_GenomicRegionOptions(ShowGenomicRegionOptions * sgro,GenomicRegion * gr,CodonTable * ct,char * dividestr,FILE * ofp) { if( sgro->show_raw == TRUE ) { show_GenomicRegion(gr,ofp); fprintf(ofp,"%s\n",dividestr); } if( sgro->show_trans == TRUE ) { dump_translations_GenomicRegion(gr,ct,ofp); fprintf(ofp,"%s\n",dividestr); } if( sgro->show_gene_str == TRUE ) { show_pretty_GenomicRegion(gr,0,ofp); fprintf(ofp,"%s\n",dividestr); } if( sgro->show_gene_supp == TRUE ) { show_pretty_GenomicRegion(gr,1,ofp); fprintf(ofp,"%s\n",dividestr); } } %func Help for ShowGenomicRegionOptions %% void show_help_ShowGenomicRegionOptions(FILE * ofp) { fprintf(ofp,"Gene Structure Output options\n"); fprintf(ofp," -trans show translation\n"); fprintf(ofp," -cdna show virtual cdna\n"); fprintf(ofp," -genes show gene structure\n"); fprintf(ofp," -genesf show gene structure with supporting evidence\n"); fprintf(ofp," -gener show raw (offset) gene structure\n"); fprintf(ofp," -ace show ace file\n"); } %func Makes a ShowGenomicRegionOptions from command line %% ShowGenomicRegionOptions * new_ShowGenomicRegionOptions_from_argv(int * argc,char ** argv) { ShowGenomicRegionOptions * out; out = ShowGenomicRegionOptions_alloc(); out->show_trans = strip_out_boolean_argument(argc,argv,"trans"); out->show_raw = strip_out_boolean_argument(argc,argv,"gener"); out->show_gene_str = strip_out_boolean_argument(argc,argv,"genes"); out->show_gene_supp = strip_out_boolean_argument(argc,argv,"genesf"); out->show_cdna = strip_out_boolean_argument(argc,argv,"cdna"); out->show_ace = strip_out_boolean_argument(argc,argv,"ace"); out->show_ace = strip_out_boolean_argument(argc,argv,"aceh"); return out; } %func read genes output %% GenomicRegion * read_genes_GenomicRegion(FILE * ifp) { char buffer[MAXLINE]; GenomicRegion * out; Gene * g; Transcript * t; Translation * ts; Exon * e; int is_start = 1; out = GenomicRegion_alloc_std(); while( fgets(buffer,MAXLINE,ifp) ) { if( strstartcmp(buffer,"//") == 0 ) { break; } if( strstartcmp(buffer,"Gene") == 0 ) { if( is_start == 1 ) { is_start =0; continue; /* next gene triggered */ } /* Line is Gene xxx yyy here */ g = Gene_alloc_std(); add_GenomicRegion(out,g); sscanf(buffer,"Gene %d %d",&g->start,&g->end); g->start = g->start -1; t = Transcript_alloc_std(); add_Gene(g,t); g->parent = out; while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"Gene") == 0 ) { break; } if( strstartcmp(buffer,"//") == 0 ) { break; } e = Exon_alloc_std(); add_ex_Transcript(t,e); sscanf(buffer," Exon %d %d",&e->start,&e->end); e->start = e->start - g->start -1; e->end = e->end - g->start; } ts = Translation_alloc(); ts->start = 0; ts->end = length_Transcript(t); ts->parent = t; add_Transcript(t,ts); t->parent = g; if( strstartcmp(buffer,"//") == 0 ) { break; } } } return out; } %func shows overlap resuls vaguely humanely %% void show_GenomicOverlapResults(GenomicOverlapResults * gor,FILE * ofp) { int i; fprintf(ofp,"%d genes overlapped\n",gor->gene_overlap); for(i=0;ilen;i++) show_GenomicOverlapGene(gor->gog[i],ofp); } %func shows overlap genes %type internal %% void show_GenomicOverlapGene(GenomicOverlapGene * gog,FILE * ofp) { fprintf(ofp,"Perfect exons %d\n",gog->exon_perfect); fprintf(ofp,"Truncated exons %d\n",gog->exon_truncated); fprintf(ofp,"Partial exons %d\n",gog->exon_partial); fprintf(ofp,"Mispredicted exons %d\n",gog->exon_mispredicted); fprintf(ofp,"Missed(int) exons %d\n",gog->exon_missed_internal); fprintf(ofp,"Missed(ext) exons %d\n",gog->exon_missed_external); } %func Gives the overlap of query in target. It is reported back in the GenomicOverlapResults structure %% GenomicOverlapResults * Genomic_overlap(GenomicRegion * query,GenomicRegion * truth) { GenomicOverlapResults * out; int i; int j; out = GenomicOverlapResults_alloc_std(); for(i=0;ilen;i++) { auto Gene * gene; gene = query->gene[i]; if( gene->start > gene->end ) { /* backward strand */ for(j=0;jlen;j++) { if( truth->gene[j]->start < truth->gene[j]->end ) continue; /* in forward strand - don't care */ if( (gene->start < truth->gene[j]->start && gene->start > truth->gene[j]->end) || (gene->end > truth->gene[j]->end && gene->end < truth->gene[j]->start) ) { out->gene_overlap++; add_GenomicOverlapResults(out,Gene_overlap_backward(gene,truth->gene[j])); } } } else { for(j=0;jlen;j++) { if( truth->gene[j]->start > truth->gene[j]->end ) continue; /* in backward strand - don't care */ if( (gene->start > truth->gene[j]->start && gene->start < truth->gene[j]->end) || (gene->end < truth->gene[j]->end && gene->end > truth->gene[j]->start) ) { out->gene_overlap++; add_GenomicOverlapResults(out,Gene_overlap_forward(gene,truth->gene[j])); } } } } return out; } %func Works out a gene overlap for two forward genes %% GenomicOverlapGene * Gene_overlap_forward(Gene * test,Gene * truth) { int i; int j; Transcript * tr; Transcript * te; int start_te; int end_te; int count; GenomicOverlapGene * out; out = GenomicOverlapGene_alloc(); out->test = hard_link_Gene(test); out->truth = hard_link_Gene(truth); tr = truth->transcript[0]; te = test->transcript[0]; for(i=0;iex_len;i++) te->exon[i]->used = FALSE; start_te = te->exon[0]->start + test->start; end_te = te->exon[te->ex_len-1]->end + test->start; for(i=0;iex_len;i++) { /** exon is to the left of start_te **/ if( tr->exon[i]->end + truth->start < start_te ) out->exon_missed_external++; else if( tr->exon[i]->start + truth->start > end_te) out->exon_missed_external++; else { for(j=0;jex_len;j++) { if( (tr->exon[i]->start + truth->start == te->exon[j]->start + test->start) ) { if( tr->exon[i]->end + truth->start == te->exon[j]->end + test->start) { out->exon_perfect++; te->exon[j]->used = TRUE; } else { out->exon_truncated++; te->exon[j]->used = TRUE; } break; } if( tr->exon[i]->end + truth->start == te->exon[j]->end + test->start ) { out->exon_truncated++; te->exon[j]->used = TRUE; break; } if( ((tr->exon[i]->start + truth->start) > te->exon[j]->start + test->start) && ((tr->exon[i]->start + truth->start) < te->exon[j]->end + test->start) ) { out->exon_partial++; te->exon[j]->used = TRUE; break; } if( ((tr->exon[i]->end + truth->start) > te->exon[j]->start + test->start) && ((tr->exon[i]->end + truth->start) < te->exon[j]->end + test->start) ) { out->exon_partial++; te->exon[j]->used = TRUE; break; } if( ((test->start + te->exon[j]->start) > (truth->start + tr->exon[i]->start)) && (test->start + te->exon[j]->end) < (truth->start + tr->exon[i]->end)) { if( j == 0 && j+1 == test->len ) { /* single exon prediction */ out->exon_truncated++; te->exon[j]->used = TRUE; } else out->exon_partial++; te->exon[j]->used = TRUE; break; } } if( j == te->ex_len ) { out->exon_missed_internal++; } } } for(i=0,count=0;iex_len;i++) { if( te->exon[i]->used != TRUE ) { count++; } } out->exon_mispredicted = count; return out; } %func Works out a gene overlap for two backward genes %% GenomicOverlapGene * Gene_overlap_backward(Gene * test,Gene * truth) { int i; int j; Transcript * tr; Transcript * te; int start_te; int end_te; int count; GenomicOverlapGene * out; out = GenomicOverlapGene_alloc(); out->test = hard_link_Gene(test); out->truth = hard_link_Gene(truth); tr = truth->transcript[0]; te = test->transcript[0]; for(i=0;iex_len;i++) te->exon[i]->used = FALSE; start_te = test->start - te->exon[0]->start; end_te = test->start - te->exon[te->ex_len-1]->end; for(i=0;iex_len;i++) { /** exon is to the left of start_te **/ if( truth->start - tr->exon[i]->end < start_te ) out->exon_missed_external++; else if( truth->start - tr->exon[i]->start > end_te) out->exon_missed_external++; else { for(j=0;jex_len;j++) { if( (truth->start - tr->exon[i]->start) == (test->start - te->exon[j]->start) ) { if( (truth->start - tr->exon[i]->end) == (test->start - te->exon[j]->end) ) { out->exon_perfect++; te->exon[j]->used = TRUE; } else { out->exon_truncated++; te->exon[j]->used = TRUE; } break; } if( (truth->start-tr->exon[i]->end) == (test->start - te->exon[j]->end)) { out->exon_truncated++; te->exon[j]->used = TRUE; break; } if( ((truth->start - tr->exon[i]->start) < test->start - te->exon[j]->start) && ((truth->start-tr->exon[i]->start) > test->start - te->exon[j]->end) ) { out->exon_partial++; te->exon[j]->used = TRUE; break; } if( ((truth->start - tr->exon[i]->end) < (test->start - te->exon[j]->start)) && ((truth->start - tr->exon[i]->end) > test->start - te->exon[j]->end) ) { out->exon_partial++; te->exon[j]->used = TRUE; break; } if( ((test->start - te->exon[j]->start) < (truth->start - tr->exon[i]->start)) && (test->start - te->exon[j]->end) > (truth->start - tr->exon[i]->end)) { if( j == 0 && j+1 == test->len ) { /* single exon prediction */ out->exon_truncated++; te->exon[j]->used = TRUE; } else out->exon_partial++; te->exon[j]->used = TRUE; break; } } if( j == te->ex_len ) { out->exon_missed_internal++; } } } for(i=0,count=0;iex_len;i++) { if( te->exon[i]->used != TRUE ) { count++; } } out->exon_mispredicted = count; return out; } %func Makes a new genomic region from the given genomic region, trying to merge close gene predictions that can be made by extending open reading frames %% GenomicRegion * simple_merged_GenomicRegion(GenomicRegion * gr,double bits_cutoff,int max_ext) { GenomicRegion * out; int i,j; Gene * gene; for(i=0;ilen;i++) { if( is_simple_prediction_Gene(gr->gene[i]) == FALSE ) { warn("Sorry - can only merge simple predictions of genes"); return FALSE; } } sort_GenomicRegion_absolute(gr); out = new_GenomicRegion(gr->genomic); /* start with a new gene from the same position as the first gene in the list */ for(i=0;ilen;i++) if( gr->gene[i]->bits > bits_cutoff ) break; if( i == gr->len ) return out; while( i < gr->len ) { /* copy this gene, and add it */ gene = copy_Gene(gr->gene[i]); add_GenomicRegion(out,gene); /* look at the next genes over the cutoff */ for(j=i+1;jlen;j++) { if( gr->gene[j]->bits < bits_cutoff ) continue; /* look at the next gene */ /* if it is on the other strand - we can forget it */ if( reversed_Gene(gene) != reversed_Gene(gr->gene[j]) ) break; /* ok - see if we can merge it */ } } return out; } %func sorts the genomicregion by absolute start points. %% void sort_GenomicRegion_absolute(GenomicRegion * gr) { sort_GenomicRegion(gr,compare_Gene_absolute); } %func internal sort function %% int compare_Gene_absolute(Gene * one,Gene * two) { int startone; int starttwo; if( reversed_Gene(one) == TRUE ) startone = one->end; else startone = one->start; if( reversed_Gene(two) == TRUE ) starttwo = two->end; else starttwo = two->start; return (startone-starttwo); } %func gives back genomic sequence from a genomic region. This is *soft linked* - ie, dont free it and use /hard_link_Genomic if you do want to... %arg gr genomic region input return s a Genomic sequence %% Genomic * get_Genomic_from_GenomicRegion(GenomicRegion * gr) { return gr->genomic; } %func Reads both feature table and sequence %% GenomicRegion * read_EMBL_GenomicRegion_efetch(char * efetch) { FILE * ifp; char buffer[MAXLINE]; GenomicRegion * out; sprintf(buffer,"efetch -a %s",efetch); ifp = popen(buffer,"r"); out = GenomicRegion_alloc_std(); read_EMBL_FT_into_GenomicRegion(buffer,MAXLINE,out,ifp); pclose(ifp); sprintf(buffer,"efetch -a -f %s",efetch); ifp = popen(buffer,"r"); out->genomic = read_fasta_Genomic(ifp,-1); pclose(ifp); return out; } %func Reads both feature table and sequence %% GenomicRegion * read_EMBL_GenomicRegion_SRS(char * srsquery) { FILE * ifp; char buffer[MAXLINE]; GenomicRegion * out; sprintf(buffer,"getz -td '[%s]'",srsquery); ifp = popen(buffer,"r"); out = GenomicRegion_alloc_std(); read_EMBL_FT_into_GenomicRegion(buffer,MAXLINE,out,ifp); out->genomic = read_fasta_Genomic(ifp,-1); pclose(ifp); return out; } %func Reads in both EMBL sequence and features %% GenomicRegion * read_EMBL_GenomicRegion_file(char * filename) { FILE * ifp; GenomicRegion * out; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s for EMBL reading",filename); return NULL; } out = read_EMBL_GenomicRegion(ifp); fclose(ifp); return out; } %func Reads in both EMBL sequence and features %% GenomicRegion * read_EMBL_GenomicRegion(FILE * ifp) { GenomicRegion * out; Sequence * seq; char buffer[MAXLINE]; char * name = NULL; char * runner; out = GenomicRegion_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"ID") == 0 ) { if( (runner=strtok(buffer+3,spacestr)) == NULL ) { warn("Very weird. Got an EMBL ID line with no name..."); } else { name = stringalloc(runner); } } else if ( strstartcmp(buffer,"FH") == 0 ) { break; } } if( read_EMBL_FT_into_GenomicRegion(buffer,MAXLINE,out,ifp) == FALSE ) { warn("Could not read EMBL feature table into GenomicRegion"); return free_GenomicRegion(out); } seq = read_Sequence_EMBL_seq(buffer,MAXLINE,ifp); if( name != NULL ) { ckfree(seq->name); seq->name = name; } if( seq == NULL ) { warn("In reading EMBL file %s, could not read sequence",name == NULL ? "Null" : name); return free_GenomicRegion(out); } if( (out->genomic = Genomic_from_Sequence(seq)) == NULL ) { warn("In reading EMBL file %s, sequence was not DNA",name == NULL ? "Null" : name); return free_GenomicRegion(out); } return out; } %func Reads in EMBL *features*, not sequence. %% boolean read_EMBL_FT_into_GenomicRegion(char * buffer,int maxlen,GenomicRegion * gr,FILE * ifp) { Gene * gene; fgets(buffer,maxlen,ifp); for(;;) { if( strstartcmp(buffer,"FT") == 0 && strstr(buffer," CDS ") ) { gene = read_EMBL_feature_Gene(buffer,maxlen,ifp); if( gene != NULL ) { gene->parent = gr; add_GenomicRegion(gr,gene); } } else if ( strstartcmp(buffer,"SQ") == 0 ) { break; } else { if( fgets(buffer,maxlen,ifp) == NULL ) { break; } } } return TRUE; } %func dumps genomic region in vaguely human form %% void show_GenomicRegion(GenomicRegion * gr,FILE * ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,"Gene %d\n",i); show_Gene(gr->gene[i],ofp); fprintf(ofp,"\n"); } } %func shows all the translations in this genomic region %% void dump_translations_GenomicRegion(GenomicRegion * gr,CodonTable * ct,FILE * ofp) { int i,j,k; Protein * trans; for(i=0;ilen;i++) for(j=0;jgene[i]->len;j++) for(k=0;kgene[i]->transcript[j]->len;k++) { trans = get_Protein_from_Translation(gr->gene[i]->transcript[j]->translation[k],ct); write_fasta_Sequence(trans->baseseq,ofp); } } %func shows all the transcripts in this genomic region %% void dump_transcripts_GenomicRegion(GenomicRegion * gr,FILE * ofp) { int i,j; cDNA * cd; for(i=0;ilen;i++) for(j=0;jgene[i]->len;j++) { cd = get_cDNA_from_Transcript(gr->gene[i]->transcript[j]); write_fasta_Sequence(cd->baseseq,ofp); } } %func makes a genomicregion from a genomic sequence %% GenomicRegion * new_GenomicRegion(Genomic * gen) { GenomicRegion * out; out = GenomicRegion_alloc_std(); out->genomic = hard_link_Genomic(gen); return out; } %func adds a Gene to this GenomicRegion, making sure that it parent/son relationship is ok %arg gr GenomicRegion to be added to gene Gene to be added %% boolean add_Gene_to_GenomicRegion(GenomicRegion * gr,Gene * gene) { gene->parent = gr; return add_GenomicRegion(gr,gene); } %func Writes Embl feature table. Does assumme that there is only one transcript per gene and only cds exons are used Output like FT CDS join(100..200) %% void write_Embl_FT_GenomicRegion(GenomicRegion * gr,FILE * ofp) { int i; for(i=0;ilen;i++) { write_Embl_FT_Gene(gr->gene[i],"CDS",ofp); if( gr->gene[i]->seqname == NULL) { fprintf(ofp,"FT /note=\"Wise2 gene object\"\n"); } else { fprintf(ofp,"FT /note=\"Match to %s\"\n",gr->gene[i]->seqname); } if( gr->gene[i]->ispseudo == TRUE ) { fprintf(ofp,"FT /note=Pseudogene\n"); } } } %func Writes Embl feature table for diana use. Does assumme that there is only one transcript per gene and only cds exons are used Output like FT misc_feature join(100..200) %% void write_Diana_FT_GenomicRegion(GenomicRegion * gr,FILE * ofp) { int i; for(i=0;ilen;i++) { write_Embl_FT_Gene(gr->gene[i],"misc_feature",ofp); if( gr->gene[i]->seqname == NULL) { fprintf(ofp,"FT /note=\"Wise2 gene object\"\n"); } else { fprintf(ofp,"FT /note=\"Match to %s Score %.2f\"\n",gr->gene[i]->seqname,gr->gene[i]->bits); } if( gr->gene[i]->ispseudo == TRUE ) { fprintf(ofp,"FT /note=Pseudogene\n"); } } } %func shows ACeDB subsequence source. Assummes a only one transcript per gene b only cds exons are used %% void show_ace_GenomicRegion(GenomicRegion * gr,char * seq_name,FILE * ofp) { int i,j; char buffer[64]; for(i=0;ilen;i++) { fprintf(ofp,"Sequence %s\n",seq_name); if ( gr->gene[i]->name != NULL ) { strcpy(buffer,gr->gene[i]->name); } else { sprintf(buffer,"%s.%d",seq_name,i+1); } if( gr->gene[i]->start < gr->gene[i]->end ) fprintf(ofp,"subsequence %s %d %d\n\n",buffer,gr->gene[i]->start+1,gr->gene[i]->end); else fprintf(ofp,"subsequence %s %d %d\n\n",buffer,gr->gene[i]->start+1,gr->gene[i]->end+2); fprintf(ofp,"Sequence %s\n",buffer); if( gr->gene[i]->ispseudo == FALSE ) fprintf(ofp,"CDS\n"); else fprintf(ofp,"Pseudogene\n"); fprintf(ofp,"Start_not_found\n"); fprintf(ofp,"End_not_found\n"); fprintf(ofp,"CDS_predicted_by genewise %.2f\n",gr->gene[i]->bits); for(j=0;jgene[i]->transcript[0]->ex_len;j++) fprintf(ofp,"source_Exons %d %d\n",gr->gene[i]->transcript[0]->exon[j]->start+1,gr->gene[i]->transcript[0]->exon[j]->end); fprintf(ofp,"\n"); } } %func shows ACeDB subsequence source for halfwise method. Assummes a only one transcript per gene b only cds exons are used %% void show_halfwise_GenomicRegion(GenomicRegion * gr,char * seq_name,char * method,char * db,boolean doweb,char * weblocation,FILE * ofp) { int i,j; char buffer[64]; for(i=0;ilen;i++) { fprintf(ofp,"Sequence %s\n",seq_name); sprintf(buffer,"%s.%s.%d",seq_name,gr->gene[i]->seqname,i+1); if( gr->gene[i]->start < gr->gene[i]->end ) fprintf(ofp,"subsequence %s %d %d\n\n",buffer,gr->gene[i]->start+1,gr->gene[i]->end); else fprintf(ofp,"subsequence %s %d %d\n\n",buffer,gr->gene[i]->start+1,gr->gene[i]->end+2); fprintf(ofp,"Sequence %s\n",buffer); fprintf(ofp,"Method %s\n",method); fprintf(ofp,"Database %s %s\n",db,gr->gene[i]->seqname); if( doweb) { fprintf(ofp,"Web_Location %s\n",weblocation); } if( gr->gene[i]->ispseudo == FALSE ) fprintf(ofp,"CDS\n"); else fprintf(ofp,"Pseudogene\n"); fprintf(ofp,"Start_not_found\n"); fprintf(ofp,"End_not_found\n"); fprintf(ofp,"CDS_predicted_by genewise %.2f\n",gr->gene[i]->bits); for(j=0;jgene[i]->transcript[0]->ex_len;j++) fprintf(ofp,"Source_Exons %d %d\n",gr->gene[i]->transcript[0]->exon[j]->start+1,gr->gene[i]->transcript[0]->exon[j]->end); fprintf(ofp,"\n"); } } %func shows GFF output Assummes a only cds exons are used %% void show_GFF_GenomicRegion(GenomicRegion * gr,char * seq_name,char * source,FILE * ofp) { int i,j,k,phase,len; char pname[64]; int count; if( seq_name == NULL ) { seq_name = "SEQ"; } if( source == NULL ) { source = "Wise-Generated"; } count=0; for(i=0;ilen;i++) { auto Gene * ge; count++; ge = gr->gene[i]; sprintf(pname,"%s-genewise-prediction-%d",seq_name == NULL ? "seq" : seq_name,count); if( ge->start < ge->end ) { fprintf(ofp,"%s\t%s\tmatch\t%d\t%d\t%.2f\t+\t.\t%s\n",seq_name,source,ge->start+1,ge->end,ge->bits,pname); } else { fprintf(ofp,"%s\t%s\tmatch\t%d\t%d\t%.2f\t-\t.\t%s\n",seq_name,source,ge->start+1,ge->end+2,ge->bits,pname); } for(j=0;jlen;j++) { auto Transcript * tr; phase = 0; len = 0; tr = ge->transcript[j]; if( ge->start < ge->end ) { for(k=0;kex_len;k++) { fprintf(ofp,"%s\t%s\tcds\t%d\t%d\t%.2f\t+\t%d\t%s\n",seq_name,source,ge->start+tr->exon[k]->start+1,ge->start+tr->exon[k]->end,tr->exon[k]->score,phase,pname); if( k < tr->ex_len-1 ) fprintf(ofp,"%s\t%s\tintron\t%d\t%d\t%.2f\t+\t.\t%s\n",seq_name,source,ge->start+tr->exon[k]->end+1,ge->start+tr->exon[k+1]->start,0.0,pname); len = len + (tr->exon[k]->end - tr->exon[k]->start); phase = len%3; if( phase == 2 ) phase = 1; else if( phase == 1 ) phase = 2; /* else 0 */ } } else { /* reverse strand */ for(k=0;kex_len;k++) { fprintf(ofp,"%s\t%s\tcds\t%d\t%d\t%.2f\t-\t%d\t%s\n",seq_name,source,(ge->start+1 - tr->exon[k]->start),ge->start - tr->exon[k]->end+2,tr->exon[k]->score,phase,pname); if( k < tr->ex_len-1 ) fprintf(ofp,"%s\t%s\tintron\t%d\t%d\t%.2f\t-\t.\t%s\n",seq_name,source,ge->start+1 - tr->exon[k]->end,(ge->start - tr->exon[k+1]->start)+2,0.0,pname); len += (tr->exon[k]->end - tr->exon[k]->start); phase = len%3; if( phase == 2 ) phase = 1; else if( phase == 1 ) phase = 2; /* else 0 */ } } /* end of else */ } /* end of over transcripts */ } } %func shows 'pretty' bio type gene %% void show_pretty_GenomicRegion(GenomicRegion * gr,boolean show_supporting,FILE * ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,"Gene %d\n",i+1); show_pretty_Gene(gr->gene[i],show_supporting,ofp); } } %} wise-2.4.1/src/dynlibsrc/genomicregion.xs0000644000175000001440000000615210670453712020043 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::GenomicRegion Wise2_GenomicRegion * new_GenomicRegion(gen) Wise2_Genomic * gen CODE: RETVAL = Wise2_new_GenomicRegion(gen); OUTPUT: RETVAL Wise2_GenomicRegion * read_EMBL_GenomicRegion_file(filename) char * filename CODE: RETVAL = Wise2_read_EMBL_GenomicRegion_file(filename); OUTPUT: RETVAL Wise2_GenomicRegion * read_EMBL_GenomicRegion(ifp) FILE * ifp CODE: RETVAL = Wise2_read_EMBL_GenomicRegion(ifp); OUTPUT: RETVAL boolean add_Gene_to_GenomicRegion(gr,gene) Wise2_GenomicRegion * gr Wise2_Gene * gene CODE: RETVAL = Wise2_add_Gene_to_GenomicRegion(gr,gene); OUTPUT: RETVAL void show_ace_GenomicRegion(gr,seq_name,ofp) Wise2_GenomicRegion * gr char * seq_name FILE * ofp CODE: Wise2_show_ace_GenomicRegion(gr,seq_name,ofp); void show_pretty_GenomicRegion(gr,show_supporting,ofp) Wise2_GenomicRegion * gr boolean show_supporting FILE * ofp CODE: Wise2_show_pretty_GenomicRegion(gr,show_supporting,ofp); void write_Diana_FT_GenomicRegion(gr,ofp) Wise2_GenomicRegion * gr FILE * ofp CODE: Wise2_write_Diana_FT_GenomicRegion(gr,ofp); void write_Embl_FT_GenomicRegion(gr,ofp) Wise2_GenomicRegion * gr FILE * ofp CODE: Wise2_write_Embl_FT_GenomicRegion(gr,ofp); Wise2_GenomicRegion * hard_link_GenomicRegion(obj) Wise2_GenomicRegion * obj CODE: RETVAL = Wise2_hard_link_GenomicRegion(obj); OUTPUT: RETVAL Wise2_GenomicRegion * GenomicRegion_alloc_std() CODE: RETVAL = Wise2_GenomicRegion_alloc_std(); OUTPUT: RETVAL Wise2_Gene * gene(obj,i) Wise2_GenomicRegion * obj int i INIT: Wise2_Gene * temp; CODE: temp = Wise2_hard_link_Gene(Wise2_access_gene_GenomicRegion(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_gene(obj) Wise2_GenomicRegion * obj CODE: RETVAL = Wise2_length_gene_GenomicRegion(obj); OUTPUT: RETVAL int flush_gene(obj) Wise2_GenomicRegion * obj CODE: RETVAL = Wise2_flush_GenomicRegion(obj); OUTPUT: RETVAL boolean add_gene(obj,add) Wise2_GenomicRegion * obj Wise2_Gene * add CODE: RETVAL = Wise2_add_GenomicRegion(obj,Wise2_hard_link_Gene(add)); OUTPUT: RETVAL boolean set_genomic(obj,genomic) Wise2_GenomicRegion * obj Wise2_Genomic * genomic CODE: RETVAL = Wise2_replace_genomic_GenomicRegion(obj,Wise2_hard_link_Genomic(genomic)); OUTPUT: RETVAL Wise2_Genomic * genomic(obj) Wise2_GenomicRegion * obj INIT: Wise2_Genomic * temp; CODE: temp = Wise2_hard_link_Genomic(Wise2_access_genomic_GenomicRegion(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_GenomicRegion * new(class) char * class PPCODE: Wise2_GenomicRegion * out; out = Wise2_GenomicRegion_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_GenomicRegion * obj CODE: Wise2_free_GenomicRegion(obj); void each_gene(obj) Wise2_GenomicRegion * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_gene_GenomicRegion(obj); for(i=0;igenomic); out = GenomicRegion_alloc_std(); assert(out); if( gr->genomic != NULL ) { out->genomic = hard_link_Genomic(gr->genomic); } for(i=0;ilen;i++) { if( gr->gene[i]->len == 0 ) { continue; } assert(gr->gene[i]->transcript[0]); if( gr->gene[i]->transcript[0]->ex_len > 1 ) { if( length_Transcript(gr->gene[i]->transcript[0]) > multiexon ) { add_GenomicRegion(out,hard_link_Gene(gr->gene[i])); } } else { if( length_Transcript(gr->gene[i]->transcript[0]) > singleexon ) { add_GenomicRegion(out,hard_link_Gene(gr->gene[i])); } } } return out; } /* Function: show_GenomicRegionOptions(sgro,gr,ct,dividestr,ofp) * * Descrip: Actually shows a genomic region wrt to the options * * * Arg: sgro [UNKN ] Undocumented argument [ShowGenomicRegionOptions *] * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: dividestr [UNKN ] Undocumented argument [char *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 116 "genomicregion.dy" void show_GenomicRegionOptions(ShowGenomicRegionOptions * sgro,GenomicRegion * gr,CodonTable * ct,char * dividestr,FILE * ofp) { if( sgro->show_raw == TRUE ) { show_GenomicRegion(gr,ofp); fprintf(ofp,"%s\n",dividestr); } if( sgro->show_trans == TRUE ) { dump_translations_GenomicRegion(gr,ct,ofp); fprintf(ofp,"%s\n",dividestr); } if( sgro->show_gene_str == TRUE ) { show_pretty_GenomicRegion(gr,0,ofp); fprintf(ofp,"%s\n",dividestr); } if( sgro->show_gene_supp == TRUE ) { show_pretty_GenomicRegion(gr,1,ofp); fprintf(ofp,"%s\n",dividestr); } } /* Function: show_help_ShowGenomicRegionOptions(ofp) * * Descrip: Help for ShowGenomicRegionOptions * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 143 "genomicregion.dy" void show_help_ShowGenomicRegionOptions(FILE * ofp) { fprintf(ofp,"Gene Structure Output options\n"); fprintf(ofp," -trans show translation\n"); fprintf(ofp," -cdna show virtual cdna\n"); fprintf(ofp," -genes show gene structure\n"); fprintf(ofp," -genesf show gene structure with supporting evidence\n"); fprintf(ofp," -gener show raw (offset) gene structure\n"); fprintf(ofp," -ace show ace file\n"); } /* Function: new_ShowGenomicRegionOptions_from_argv(argc,argv) * * Descrip: Makes a ShowGenomicRegionOptions from command line * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [ShowGenomicRegionOptions *] * */ # line 159 "genomicregion.dy" ShowGenomicRegionOptions * new_ShowGenomicRegionOptions_from_argv(int * argc,char ** argv) { ShowGenomicRegionOptions * out; out = ShowGenomicRegionOptions_alloc(); out->show_trans = strip_out_boolean_argument(argc,argv,"trans"); out->show_raw = strip_out_boolean_argument(argc,argv,"gener"); out->show_gene_str = strip_out_boolean_argument(argc,argv,"genes"); out->show_gene_supp = strip_out_boolean_argument(argc,argv,"genesf"); out->show_cdna = strip_out_boolean_argument(argc,argv,"cdna"); out->show_ace = strip_out_boolean_argument(argc,argv,"ace"); out->show_ace = strip_out_boolean_argument(argc,argv,"aceh"); return out; } /* Function: read_genes_GenomicRegion(ifp) * * Descrip: read genes output * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ # line 180 "genomicregion.dy" GenomicRegion * read_genes_GenomicRegion(FILE * ifp) { char buffer[MAXLINE]; GenomicRegion * out; Gene * g; Transcript * t; Translation * ts; Exon * e; int is_start = 1; out = GenomicRegion_alloc_std(); while( fgets(buffer,MAXLINE,ifp) ) { if( strstartcmp(buffer,"//") == 0 ) { break; } if( strstartcmp(buffer,"Gene") == 0 ) { if( is_start == 1 ) { is_start =0; continue; /* next gene triggered */ } /* Line is Gene xxx yyy here */ g = Gene_alloc_std(); add_GenomicRegion(out,g); sscanf(buffer,"Gene %d %d",&g->start,&g->end); g->start = g->start -1; t = Transcript_alloc_std(); add_Gene(g,t); g->parent = out; while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"Gene") == 0 ) { break; } if( strstartcmp(buffer,"//") == 0 ) { break; } e = Exon_alloc_std(); add_ex_Transcript(t,e); sscanf(buffer," Exon %d %d",&e->start,&e->end); e->start = e->start - g->start -1; e->end = e->end - g->start; } ts = Translation_alloc(); ts->start = 0; ts->end = length_Transcript(t); ts->parent = t; add_Transcript(t,ts); t->parent = g; if( strstartcmp(buffer,"//") == 0 ) { break; } } } return out; } /* Function: show_GenomicOverlapResults(gor,ofp) * * Descrip: shows overlap resuls vaguely humanely * * * Arg: gor [UNKN ] Undocumented argument [GenomicOverlapResults *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 253 "genomicregion.dy" void show_GenomicOverlapResults(GenomicOverlapResults * gor,FILE * ofp) { int i; fprintf(ofp,"%d genes overlapped\n",gor->gene_overlap); for(i=0;ilen;i++) show_GenomicOverlapGene(gor->gog[i],ofp); } /* Function: show_GenomicOverlapGene(gog,ofp) * * Descrip: shows overlap genes * * * Arg: gog [UNKN ] Undocumented argument [GenomicOverlapGene *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 266 "genomicregion.dy" void show_GenomicOverlapGene(GenomicOverlapGene * gog,FILE * ofp) { fprintf(ofp,"Perfect exons %d\n",gog->exon_perfect); fprintf(ofp,"Truncated exons %d\n",gog->exon_truncated); fprintf(ofp,"Partial exons %d\n",gog->exon_partial); fprintf(ofp,"Mispredicted exons %d\n",gog->exon_mispredicted); fprintf(ofp,"Missed(int) exons %d\n",gog->exon_missed_internal); fprintf(ofp,"Missed(ext) exons %d\n",gog->exon_missed_external); } /* Function: Genomic_overlap(query,truth) * * Descrip: Gives the overlap of query in target. It is reported * back in the GenomicOverlapResults structure * * * Arg: query [UNKN ] Undocumented argument [GenomicRegion *] * Arg: truth [UNKN ] Undocumented argument [GenomicRegion *] * * Return [UNKN ] Undocumented return value [GenomicOverlapResults *] * */ # line 280 "genomicregion.dy" GenomicOverlapResults * Genomic_overlap(GenomicRegion * query,GenomicRegion * truth) { GenomicOverlapResults * out; int i; int j; out = GenomicOverlapResults_alloc_std(); for(i=0;ilen;i++) { auto Gene * gene; gene = query->gene[i]; if( gene->start > gene->end ) { /* backward strand */ for(j=0;jlen;j++) { if( truth->gene[j]->start < truth->gene[j]->end ) continue; /* in forward strand - don't care */ if( (gene->start < truth->gene[j]->start && gene->start > truth->gene[j]->end) || (gene->end > truth->gene[j]->end && gene->end < truth->gene[j]->start) ) { out->gene_overlap++; add_GenomicOverlapResults(out,Gene_overlap_backward(gene,truth->gene[j])); } } } else { for(j=0;jlen;j++) { if( truth->gene[j]->start > truth->gene[j]->end ) continue; /* in backward strand - don't care */ if( (gene->start > truth->gene[j]->start && gene->start < truth->gene[j]->end) || (gene->end < truth->gene[j]->end && gene->end > truth->gene[j]->start) ) { out->gene_overlap++; add_GenomicOverlapResults(out,Gene_overlap_forward(gene,truth->gene[j])); } } } } return out; } /* Function: Gene_overlap_forward(test,truth) * * Descrip: Works out a gene overlap for two forward genes * * * Arg: test [UNKN ] Undocumented argument [Gene *] * Arg: truth [UNKN ] Undocumented argument [Gene *] * * Return [UNKN ] Undocumented return value [GenomicOverlapGene *] * */ # line 323 "genomicregion.dy" GenomicOverlapGene * Gene_overlap_forward(Gene * test,Gene * truth) { int i; int j; Transcript * tr; Transcript * te; int start_te; int end_te; int count; GenomicOverlapGene * out; out = GenomicOverlapGene_alloc(); out->test = hard_link_Gene(test); out->truth = hard_link_Gene(truth); tr = truth->transcript[0]; te = test->transcript[0]; for(i=0;iex_len;i++) te->exon[i]->used = FALSE; start_te = te->exon[0]->start + test->start; end_te = te->exon[te->ex_len-1]->end + test->start; for(i=0;iex_len;i++) { /** exon is to the left of start_te **/ if( tr->exon[i]->end + truth->start < start_te ) out->exon_missed_external++; else if( tr->exon[i]->start + truth->start > end_te) out->exon_missed_external++; else { for(j=0;jex_len;j++) { if( (tr->exon[i]->start + truth->start == te->exon[j]->start + test->start) ) { if( tr->exon[i]->end + truth->start == te->exon[j]->end + test->start) { out->exon_perfect++; te->exon[j]->used = TRUE; } else { out->exon_truncated++; te->exon[j]->used = TRUE; } break; } if( tr->exon[i]->end + truth->start == te->exon[j]->end + test->start ) { out->exon_truncated++; te->exon[j]->used = TRUE; break; } if( ((tr->exon[i]->start + truth->start) > te->exon[j]->start + test->start) && ((tr->exon[i]->start + truth->start) < te->exon[j]->end + test->start) ) { out->exon_partial++; te->exon[j]->used = TRUE; break; } if( ((tr->exon[i]->end + truth->start) > te->exon[j]->start + test->start) && ((tr->exon[i]->end + truth->start) < te->exon[j]->end + test->start) ) { out->exon_partial++; te->exon[j]->used = TRUE; break; } if( ((test->start + te->exon[j]->start) > (truth->start + tr->exon[i]->start)) && (test->start + te->exon[j]->end) < (truth->start + tr->exon[i]->end)) { if( j == 0 && j+1 == test->len ) { /* single exon prediction */ out->exon_truncated++; te->exon[j]->used = TRUE; } else out->exon_partial++; te->exon[j]->used = TRUE; break; } } if( j == te->ex_len ) { out->exon_missed_internal++; } } } for(i=0,count=0;iex_len;i++) { if( te->exon[i]->used != TRUE ) { count++; } } out->exon_mispredicted = count; return out; } /* Function: Gene_overlap_backward(test,truth) * * Descrip: Works out a gene overlap for two backward genes * * * Arg: test [UNKN ] Undocumented argument [Gene *] * Arg: truth [UNKN ] Undocumented argument [Gene *] * * Return [UNKN ] Undocumented return value [GenomicOverlapGene *] * */ # line 422 "genomicregion.dy" GenomicOverlapGene * Gene_overlap_backward(Gene * test,Gene * truth) { int i; int j; Transcript * tr; Transcript * te; int start_te; int end_te; int count; GenomicOverlapGene * out; out = GenomicOverlapGene_alloc(); out->test = hard_link_Gene(test); out->truth = hard_link_Gene(truth); tr = truth->transcript[0]; te = test->transcript[0]; for(i=0;iex_len;i++) te->exon[i]->used = FALSE; start_te = test->start - te->exon[0]->start; end_te = test->start - te->exon[te->ex_len-1]->end; for(i=0;iex_len;i++) { /** exon is to the left of start_te **/ if( truth->start - tr->exon[i]->end < start_te ) out->exon_missed_external++; else if( truth->start - tr->exon[i]->start > end_te) out->exon_missed_external++; else { for(j=0;jex_len;j++) { if( (truth->start - tr->exon[i]->start) == (test->start - te->exon[j]->start) ) { if( (truth->start - tr->exon[i]->end) == (test->start - te->exon[j]->end) ) { out->exon_perfect++; te->exon[j]->used = TRUE; } else { out->exon_truncated++; te->exon[j]->used = TRUE; } break; } if( (truth->start-tr->exon[i]->end) == (test->start - te->exon[j]->end)) { out->exon_truncated++; te->exon[j]->used = TRUE; break; } if( ((truth->start - tr->exon[i]->start) < test->start - te->exon[j]->start) && ((truth->start-tr->exon[i]->start) > test->start - te->exon[j]->end) ) { out->exon_partial++; te->exon[j]->used = TRUE; break; } if( ((truth->start - tr->exon[i]->end) < (test->start - te->exon[j]->start)) && ((truth->start - tr->exon[i]->end) > test->start - te->exon[j]->end) ) { out->exon_partial++; te->exon[j]->used = TRUE; break; } if( ((test->start - te->exon[j]->start) < (truth->start - tr->exon[i]->start)) && (test->start - te->exon[j]->end) > (truth->start - tr->exon[i]->end)) { if( j == 0 && j+1 == test->len ) { /* single exon prediction */ out->exon_truncated++; te->exon[j]->used = TRUE; } else out->exon_partial++; te->exon[j]->used = TRUE; break; } } if( j == te->ex_len ) { out->exon_missed_internal++; } } } for(i=0,count=0;iex_len;i++) { if( te->exon[i]->used != TRUE ) { count++; } } out->exon_mispredicted = count; return out; } /* Function: simple_merged_GenomicRegion(gr,bits_cutoff,max_ext) * * Descrip: Makes a new genomic region from the given * genomic region, trying to merge close * gene predictions that can be made by * extending open reading frames * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: bits_cutoff [UNKN ] Undocumented argument [double] * Arg: max_ext [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ # line 523 "genomicregion.dy" GenomicRegion * simple_merged_GenomicRegion(GenomicRegion * gr,double bits_cutoff,int max_ext) { GenomicRegion * out; int i,j; Gene * gene; for(i=0;ilen;i++) { if( is_simple_prediction_Gene(gr->gene[i]) == FALSE ) { warn("Sorry - can only merge simple predictions of genes"); return FALSE; } } sort_GenomicRegion_absolute(gr); out = new_GenomicRegion(gr->genomic); /* start with a new gene from the same position as the first gene in the list */ for(i=0;ilen;i++) if( gr->gene[i]->bits > bits_cutoff ) break; if( i == gr->len ) return out; while( i < gr->len ) { /* copy this gene, and add it */ gene = copy_Gene(gr->gene[i]); add_GenomicRegion(out,gene); /* look at the next genes over the cutoff */ for(j=i+1;jlen;j++) { if( gr->gene[j]->bits < bits_cutoff ) continue; /* look at the next gene */ /* if it is on the other strand - we can forget it */ if( reversed_Gene(gene) != reversed_Gene(gr->gene[j]) ) break; /* ok - see if we can merge it */ } } return out; } /* Function: sort_GenomicRegion_absolute(gr) * * Descrip: sorts the genomicregion by absolute start points. * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * */ # line 581 "genomicregion.dy" void sort_GenomicRegion_absolute(GenomicRegion * gr) { sort_GenomicRegion(gr,compare_Gene_absolute); } /* Function: compare_Gene_absolute(one,two) * * Descrip: internal sort function * * * Arg: one [UNKN ] Undocumented argument [Gene *] * Arg: two [UNKN ] Undocumented argument [Gene *] * * Return [UNKN ] Undocumented return value [int] * */ # line 589 "genomicregion.dy" int compare_Gene_absolute(Gene * one,Gene * two) { int startone; int starttwo; if( reversed_Gene(one) == TRUE ) startone = one->end; else startone = one->start; if( reversed_Gene(two) == TRUE ) starttwo = two->end; else starttwo = two->start; return (startone-starttwo); } /* Function: get_Genomic_from_GenomicRegion(gr) * * Descrip: gives back genomic sequence from a genomic region. This is *soft * linked* - ie, dont free it and use /hard_link_Genomic if you do want to... * * * Arg: gr [UNKN ] genomic region input [GenomicRegion *] * * Return [SOFT ] a Genomic sequence [Genomic *] * */ # line 616 "genomicregion.dy" Genomic * get_Genomic_from_GenomicRegion(GenomicRegion * gr) { return gr->genomic; } /* Function: read_EMBL_GenomicRegion_efetch(efetch) * * Descrip: Reads both feature table and sequence * * * Arg: efetch [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ # line 624 "genomicregion.dy" GenomicRegion * read_EMBL_GenomicRegion_efetch(char * efetch) { FILE * ifp; char buffer[MAXLINE]; GenomicRegion * out; sprintf(buffer,"efetch -a %s",efetch); ifp = popen(buffer,"r"); out = GenomicRegion_alloc_std(); read_EMBL_FT_into_GenomicRegion(buffer,MAXLINE,out,ifp); pclose(ifp); sprintf(buffer,"efetch -a -f %s",efetch); ifp = popen(buffer,"r"); out->genomic = read_fasta_Genomic(ifp,-1); pclose(ifp); return out; } /* Function: read_EMBL_GenomicRegion_SRS(srsquery) * * Descrip: Reads both feature table and sequence * * * Arg: srsquery [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ # line 655 "genomicregion.dy" GenomicRegion * read_EMBL_GenomicRegion_SRS(char * srsquery) { FILE * ifp; char buffer[MAXLINE]; GenomicRegion * out; sprintf(buffer,"getz -td '[%s]'",srsquery); ifp = popen(buffer,"r"); out = GenomicRegion_alloc_std(); read_EMBL_FT_into_GenomicRegion(buffer,MAXLINE,out,ifp); out->genomic = read_fasta_Genomic(ifp,-1); pclose(ifp); return out; } /* Function: read_EMBL_GenomicRegion_file(filename) * * Descrip: Reads in both EMBL sequence and features * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ # line 679 "genomicregion.dy" GenomicRegion * read_EMBL_GenomicRegion_file(char * filename) { FILE * ifp; GenomicRegion * out; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s for EMBL reading",filename); return NULL; } out = read_EMBL_GenomicRegion(ifp); fclose(ifp); return out; } /* Function: read_EMBL_GenomicRegion(ifp) * * Descrip: Reads in both EMBL sequence and features * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ # line 700 "genomicregion.dy" GenomicRegion * read_EMBL_GenomicRegion(FILE * ifp) { GenomicRegion * out; Sequence * seq; char buffer[MAXLINE]; char * name = NULL; char * runner; out = GenomicRegion_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"ID") == 0 ) { if( (runner=strtok(buffer+3,spacestr)) == NULL ) { warn("Very weird. Got an EMBL ID line with no name..."); } else { name = stringalloc(runner); } } else if ( strstartcmp(buffer,"FH") == 0 ) { break; } } if( read_EMBL_FT_into_GenomicRegion(buffer,MAXLINE,out,ifp) == FALSE ) { warn("Could not read EMBL feature table into GenomicRegion"); return free_GenomicRegion(out); } seq = read_Sequence_EMBL_seq(buffer,MAXLINE,ifp); if( name != NULL ) { ckfree(seq->name); seq->name = name; } if( seq == NULL ) { warn("In reading EMBL file %s, could not read sequence",name == NULL ? "Null" : name); return free_GenomicRegion(out); } if( (out->genomic = Genomic_from_Sequence(seq)) == NULL ) { warn("In reading EMBL file %s, sequence was not DNA",name == NULL ? "Null" : name); return free_GenomicRegion(out); } return out; } /* Function: read_EMBL_FT_into_GenomicRegion(buffer,maxlen,gr,ifp) * * Descrip: Reads in EMBL *features*, not sequence. * * * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: maxlen [UNKN ] Undocumented argument [int] * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 752 "genomicregion.dy" boolean read_EMBL_FT_into_GenomicRegion(char * buffer,int maxlen,GenomicRegion * gr,FILE * ifp) { Gene * gene; fgets(buffer,maxlen,ifp); for(;;) { if( strstartcmp(buffer,"FT") == 0 && strstr(buffer," CDS ") ) { gene = read_EMBL_feature_Gene(buffer,maxlen,ifp); if( gene != NULL ) { gene->parent = gr; add_GenomicRegion(gr,gene); } } else if ( strstartcmp(buffer,"SQ") == 0 ) { break; } else { if( fgets(buffer,maxlen,ifp) == NULL ) { break; } } } return TRUE; } /* Function: show_GenomicRegion(gr,ofp) * * Descrip: dumps genomic region in vaguely human form * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 779 "genomicregion.dy" void show_GenomicRegion(GenomicRegion * gr,FILE * ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,"Gene %d\n",i); show_Gene(gr->gene[i],ofp); fprintf(ofp,"\n"); } } /* Function: dump_translations_GenomicRegion(gr,ct,ofp) * * Descrip: shows all the translations in this genomic region * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 794 "genomicregion.dy" void dump_translations_GenomicRegion(GenomicRegion * gr,CodonTable * ct,FILE * ofp) { int i,j,k; Protein * trans; for(i=0;ilen;i++) for(j=0;jgene[i]->len;j++) for(k=0;kgene[i]->transcript[j]->len;k++) { trans = get_Protein_from_Translation(gr->gene[i]->transcript[j]->translation[k],ct); write_fasta_Sequence(trans->baseseq,ofp); } } /* Function: dump_transcripts_GenomicRegion(gr,ofp) * * Descrip: shows all the transcripts in this genomic region * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 810 "genomicregion.dy" void dump_transcripts_GenomicRegion(GenomicRegion * gr,FILE * ofp) { int i,j; cDNA * cd; for(i=0;ilen;i++) for(j=0;jgene[i]->len;j++) { cd = get_cDNA_from_Transcript(gr->gene[i]->transcript[j]); write_fasta_Sequence(cd->baseseq,ofp); } } /* Function: new_GenomicRegion(gen) * * Descrip: makes a genomicregion from a genomic sequence * * * Arg: gen [UNKN ] Undocumented argument [Genomic *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ # line 826 "genomicregion.dy" GenomicRegion * new_GenomicRegion(Genomic * gen) { GenomicRegion * out; out = GenomicRegion_alloc_std(); out->genomic = hard_link_Genomic(gen); return out; } /* Function: add_Gene_to_GenomicRegion(gr,gene) * * Descrip: adds a Gene to this GenomicRegion, making * sure that it parent/son relationship is ok * * * Arg: gr [UNKN ] GenomicRegion to be added to [GenomicRegion *] * Arg: gene [UNKN ] Gene to be added [Gene *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 843 "genomicregion.dy" boolean add_Gene_to_GenomicRegion(GenomicRegion * gr,Gene * gene) { gene->parent = gr; return add_GenomicRegion(gr,gene); } /* Function: write_Embl_FT_GenomicRegion(gr,ofp) * * Descrip: Writes Embl feature table. Does assumme that * there is only one transcript per gene and only * cds exons are used * * Output like * * FT CDS join(100..200) * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 858 "genomicregion.dy" void write_Embl_FT_GenomicRegion(GenomicRegion * gr,FILE * ofp) { int i; for(i=0;ilen;i++) { write_Embl_FT_Gene(gr->gene[i],"CDS",ofp); if( gr->gene[i]->seqname == NULL) { fprintf(ofp,"FT /note=\"Wise2 gene object\"\n"); } else { fprintf(ofp,"FT /note=\"Match to %s\"\n",gr->gene[i]->seqname); } if( gr->gene[i]->ispseudo == TRUE ) { fprintf(ofp,"FT /note=Pseudogene\n"); } } } /* Function: write_Diana_FT_GenomicRegion(gr,ofp) * * Descrip: Writes Embl feature table for diana use. Does assumme that * there is only one transcript per gene and only * cds exons are used * * Output like * * FT misc_feature join(100..200) * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 884 "genomicregion.dy" void write_Diana_FT_GenomicRegion(GenomicRegion * gr,FILE * ofp) { int i; for(i=0;ilen;i++) { write_Embl_FT_Gene(gr->gene[i],"misc_feature",ofp); if( gr->gene[i]->seqname == NULL) { fprintf(ofp,"FT /note=\"Wise2 gene object\"\n"); } else { fprintf(ofp,"FT /note=\"Match to %s Score %.2f\"\n",gr->gene[i]->seqname,gr->gene[i]->bits); } if( gr->gene[i]->ispseudo == TRUE ) { fprintf(ofp,"FT /note=Pseudogene\n"); } } } /* Function: show_ace_GenomicRegion(gr,seq_name,ofp) * * Descrip: shows ACeDB subsequence source. * * Assummes * a only one transcript per gene * b only cds exons are used * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: seq_name [UNKN ] Undocumented argument [char *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 910 "genomicregion.dy" void show_ace_GenomicRegion(GenomicRegion * gr,char * seq_name,FILE * ofp) { int i,j; char buffer[64]; for(i=0;ilen;i++) { fprintf(ofp,"Sequence %s\n",seq_name); if ( gr->gene[i]->name != NULL ) { strcpy(buffer,gr->gene[i]->name); } else { sprintf(buffer,"%s.%d",seq_name,i+1); } if( gr->gene[i]->start < gr->gene[i]->end ) fprintf(ofp,"subsequence %s %d %d\n\n",buffer,gr->gene[i]->start+1,gr->gene[i]->end); else fprintf(ofp,"subsequence %s %d %d\n\n",buffer,gr->gene[i]->start+1,gr->gene[i]->end+2); fprintf(ofp,"Sequence %s\n",buffer); if( gr->gene[i]->ispseudo == FALSE ) fprintf(ofp,"CDS\n"); else fprintf(ofp,"Pseudogene\n"); fprintf(ofp,"Start_not_found\n"); fprintf(ofp,"End_not_found\n"); fprintf(ofp,"CDS_predicted_by genewise %.2f\n",gr->gene[i]->bits); for(j=0;jgene[i]->transcript[0]->ex_len;j++) fprintf(ofp,"source_Exons %d %d\n",gr->gene[i]->transcript[0]->exon[j]->start+1,gr->gene[i]->transcript[0]->exon[j]->end); fprintf(ofp,"\n"); } } /* Function: show_halfwise_GenomicRegion(gr,seq_name,method,db,doweb,weblocation,ofp) * * Descrip: shows ACeDB subsequence source for halfwise * method. * * Assummes * a only one transcript per gene * b only cds exons are used * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: seq_name [UNKN ] Undocumented argument [char *] * Arg: method [UNKN ] Undocumented argument [char *] * Arg: db [UNKN ] Undocumented argument [char *] * Arg: doweb [UNKN ] Undocumented argument [boolean] * Arg: weblocation [UNKN ] Undocumented argument [char *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 951 "genomicregion.dy" void show_halfwise_GenomicRegion(GenomicRegion * gr,char * seq_name,char * method,char * db,boolean doweb,char * weblocation,FILE * ofp) { int i,j; char buffer[64]; for(i=0;ilen;i++) { fprintf(ofp,"Sequence %s\n",seq_name); sprintf(buffer,"%s.%s.%d",seq_name,gr->gene[i]->seqname,i+1); if( gr->gene[i]->start < gr->gene[i]->end ) fprintf(ofp,"subsequence %s %d %d\n\n",buffer,gr->gene[i]->start+1,gr->gene[i]->end); else fprintf(ofp,"subsequence %s %d %d\n\n",buffer,gr->gene[i]->start+1,gr->gene[i]->end+2); fprintf(ofp,"Sequence %s\n",buffer); fprintf(ofp,"Method %s\n",method); fprintf(ofp,"Database %s %s\n",db,gr->gene[i]->seqname); if( doweb) { fprintf(ofp,"Web_Location %s\n",weblocation); } if( gr->gene[i]->ispseudo == FALSE ) fprintf(ofp,"CDS\n"); else fprintf(ofp,"Pseudogene\n"); fprintf(ofp,"Start_not_found\n"); fprintf(ofp,"End_not_found\n"); fprintf(ofp,"CDS_predicted_by genewise %.2f\n",gr->gene[i]->bits); for(j=0;jgene[i]->transcript[0]->ex_len;j++) fprintf(ofp,"Source_Exons %d %d\n",gr->gene[i]->transcript[0]->exon[j]->start+1,gr->gene[i]->transcript[0]->exon[j]->end); fprintf(ofp,"\n"); } } /* Function: show_GFF_GenomicRegion(gr,seq_name,source,ofp) * * Descrip: shows GFF output * * Assummes * a only cds exons are used * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: seq_name [UNKN ] Undocumented argument [char *] * Arg: source [UNKN ] Undocumented argument [char *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 993 "genomicregion.dy" void show_GFF_GenomicRegion(GenomicRegion * gr,char * seq_name,char * source,FILE * ofp) { int i,j,k,phase,len; char pname[64]; int count; if( seq_name == NULL ) { seq_name = "SEQ"; } if( source == NULL ) { source = "Wise-Generated"; } count=0; for(i=0;ilen;i++) { auto Gene * ge; count++; ge = gr->gene[i]; sprintf(pname,"%s-genewise-prediction-%d",seq_name == NULL ? "seq" : seq_name,count); if( ge->start < ge->end ) { fprintf(ofp,"%s\t%s\tmatch\t%d\t%d\t%.2f\t+\t.\t%s\n",seq_name,source,ge->start+1,ge->end,ge->bits,pname); } else { fprintf(ofp,"%s\t%s\tmatch\t%d\t%d\t%.2f\t-\t.\t%s\n",seq_name,source,ge->start+1,ge->end+2,ge->bits,pname); } for(j=0;jlen;j++) { auto Transcript * tr; phase = 0; len = 0; tr = ge->transcript[j]; if( ge->start < ge->end ) { for(k=0;kex_len;k++) { fprintf(ofp,"%s\t%s\tcds\t%d\t%d\t%.2f\t+\t%d\t%s\n",seq_name,source,ge->start+tr->exon[k]->start+1,ge->start+tr->exon[k]->end,tr->exon[k]->score,phase,pname); if( k < tr->ex_len-1 ) fprintf(ofp,"%s\t%s\tintron\t%d\t%d\t%.2f\t+\t.\t%s\n",seq_name,source,ge->start+tr->exon[k]->end+1,ge->start+tr->exon[k+1]->start,0.0,pname); len = len + (tr->exon[k]->end - tr->exon[k]->start); phase = len%3; if( phase == 2 ) phase = 1; else if( phase == 1 ) phase = 2; /* else 0 */ } } else { /* reverse strand */ for(k=0;kex_len;k++) { fprintf(ofp,"%s\t%s\tcds\t%d\t%d\t%.2f\t-\t%d\t%s\n",seq_name,source,(ge->start+1 - tr->exon[k]->start),ge->start - tr->exon[k]->end+2,tr->exon[k]->score,phase,pname); if( k < tr->ex_len-1 ) fprintf(ofp,"%s\t%s\tintron\t%d\t%d\t%.2f\t-\t.\t%s\n",seq_name,source,ge->start+1 - tr->exon[k]->end,(ge->start - tr->exon[k+1]->start)+2,0.0,pname); len += (tr->exon[k]->end - tr->exon[k]->start); phase = len%3; if( phase == 2 ) phase = 1; else if( phase == 1 ) phase = 2; /* else 0 */ } } /* end of else */ } /* end of over transcripts */ } } /* Function: show_pretty_GenomicRegion(gr,show_supporting,ofp) * * Descrip: No Description * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: show_supporting [UNKN ] Undocumented argument [boolean] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 1069 "genomicregion.dy" void show_pretty_GenomicRegion(GenomicRegion * gr,boolean show_supporting,FILE * ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,"Gene %d\n",i+1); show_pretty_Gene(gr->gene[i],show_supporting,ofp); } } # line 1196 "genomicregion.c" /* Function: swap_GenomicRegion(list,i,j) * * Descrip: swap function: an internal for qsort_GenomicRegion * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Gene **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_GenomicRegion(Gene ** list,int i,int j) { Gene * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_GenomicRegion(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_GenomicRegion which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Gene **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_GenomicRegion(Gene ** list,int left,int right,int (*comp)(Gene * ,Gene * )) { int i,last; if( left >= right ) return; swap_GenomicRegion(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_GenomicRegion (list,++last,i); } swap_GenomicRegion (list,left,last); qsort_GenomicRegion(list,left,last-1,comp); qsort_GenomicRegion(list,last+1,right,comp); } /* Function: sort_GenomicRegion(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_GenomicRegion * * * Arg: obj [UNKN ] Object containing list [GenomicRegion *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_GenomicRegion(GenomicRegion * obj,int (*comp)(Gene *, Gene *)) { qsort_GenomicRegion(obj->gene,0,obj->len-1,comp); return; } /* Function: expand_GenomicRegion(obj,len) * * Descrip: Really an internal function for add_GenomicRegion * * * Arg: obj [UNKN ] Object which contains the list [GenomicRegion *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_GenomicRegion(GenomicRegion * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_GenomicRegion called with no need"); return TRUE; } if( (obj->gene = (Gene ** ) ckrealloc (obj->gene,sizeof(Gene *)*len)) == NULL) { warn("ckrealloc failed for expand_GenomicRegion, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_GenomicRegion(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenomicRegion *] * Arg: add [OWNER] Object to add to the list [Gene *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_GenomicRegion(GenomicRegion * obj,Gene * add) { if( obj->len >= obj->maxlen) { if( expand_GenomicRegion(obj,obj->len + GenomicRegionLISTLENGTH) == FALSE) return FALSE; } obj->gene[obj->len++]=add; return TRUE; } /* Function: flush_GenomicRegion(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenomicRegion *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GenomicRegion(GenomicRegion * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->gene[i] != NULL) { free_Gene(obj->gene[i]); obj->gene[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: GenomicRegion_alloc_std(void) * * Descrip: Equivalent to GenomicRegion_alloc_len(GenomicRegionLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * GenomicRegion_alloc_std(void) { return GenomicRegion_alloc_len(GenomicRegionLISTLENGTH); } /* Function: GenomicRegion_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * GenomicRegion_alloc_len(int len) { GenomicRegion * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = GenomicRegion_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->gene = (Gene ** ) ckcalloc (len,sizeof(Gene *))) == NULL) { warn("Warning, ckcalloc failed in GenomicRegion_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_GenomicRegion(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomicRegion *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * hard_link_GenomicRegion(GenomicRegion * obj) { if( obj == NULL ) { warn("Trying to hard link to a GenomicRegion object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GenomicRegion_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * GenomicRegion_alloc(void) { GenomicRegion * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenomicRegion *) ckalloc (sizeof(GenomicRegion))) == NULL) { warn("GenomicRegion_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->gene = NULL; out->len = out->maxlen = 0; out->genomic = NULL; return out; } /* Function: free_GenomicRegion(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomicRegion *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * free_GenomicRegion(GenomicRegion * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GenomicRegion obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->gene != NULL) { for(i=0;ilen;i++) { if( obj->gene[i] != NULL) free_Gene(obj->gene[i]); } ckfree(obj->gene); } if( obj->genomic != NULL) free_Genomic(obj->genomic); ckfree(obj); return NULL; } /* Function: hard_link_GenomicOverlapGene(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomicOverlapGene *] * * Return [UNKN ] Undocumented return value [GenomicOverlapGene *] * */ GenomicOverlapGene * hard_link_GenomicOverlapGene(GenomicOverlapGene * obj) { if( obj == NULL ) { warn("Trying to hard link to a GenomicOverlapGene object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GenomicOverlapGene_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomicOverlapGene *] * */ GenomicOverlapGene * GenomicOverlapGene_alloc(void) { GenomicOverlapGene * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenomicOverlapGene *) ckalloc (sizeof(GenomicOverlapGene))) == NULL) { warn("GenomicOverlapGene_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->exon_perfect = 0; out->exon_truncated = 0; out->exon_partial = 0; out->exon_missed_internal = 0; out->exon_missed_external = 0; out->exon_mispredicted = 0; out->truth = NULL; out->test = NULL; return out; } /* Function: free_GenomicOverlapGene(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomicOverlapGene *] * * Return [UNKN ] Undocumented return value [GenomicOverlapGene *] * */ GenomicOverlapGene * free_GenomicOverlapGene(GenomicOverlapGene * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GenomicOverlapGene obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->truth != NULL) free_Gene(obj->truth); if( obj->test != NULL) free_Gene(obj->test); ckfree(obj); return NULL; } /* Function: swap_GenomicOverlapResults(list,i,j) * * Descrip: swap function: an internal for qsort_GenomicOverlapResults * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [GenomicOverlapGene **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_GenomicOverlapResults(GenomicOverlapGene ** list,int i,int j) { GenomicOverlapGene * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_GenomicOverlapResults(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_GenomicOverlapResults which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [GenomicOverlapGene **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_GenomicOverlapResults(GenomicOverlapGene ** list,int left,int right,int (*comp)(GenomicOverlapGene * ,GenomicOverlapGene * )) { int i,last; if( left >= right ) return; swap_GenomicOverlapResults(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_GenomicOverlapResults (list,++last,i); } swap_GenomicOverlapResults (list,left,last); qsort_GenomicOverlapResults(list,left,last-1,comp); qsort_GenomicOverlapResults(list,last+1,right,comp); } /* Function: sort_GenomicOverlapResults(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_GenomicOverlapResults * * * Arg: obj [UNKN ] Object containing list [GenomicOverlapResults *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_GenomicOverlapResults(GenomicOverlapResults * obj,int (*comp)(GenomicOverlapGene *, GenomicOverlapGene *)) { qsort_GenomicOverlapResults(obj->gog,0,obj->len-1,comp); return; } /* Function: expand_GenomicOverlapResults(obj,len) * * Descrip: Really an internal function for add_GenomicOverlapResults * * * Arg: obj [UNKN ] Object which contains the list [GenomicOverlapResults *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_GenomicOverlapResults(GenomicOverlapResults * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_GenomicOverlapResults called with no need"); return TRUE; } if( (obj->gog = (GenomicOverlapGene ** ) ckrealloc (obj->gog,sizeof(GenomicOverlapGene *)*len)) == NULL) { warn("ckrealloc failed for expand_GenomicOverlapResults, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_GenomicOverlapResults(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenomicOverlapResults *] * Arg: add [OWNER] Object to add to the list [GenomicOverlapGene *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_GenomicOverlapResults(GenomicOverlapResults * obj,GenomicOverlapGene * add) { if( obj->len >= obj->maxlen) { if( expand_GenomicOverlapResults(obj,obj->len + GenomicOverlapResultsLISTLENGTH) == FALSE) return FALSE; } obj->gog[obj->len++]=add; return TRUE; } /* Function: flush_GenomicOverlapResults(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenomicOverlapResults *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_GenomicOverlapResults(GenomicOverlapResults * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->gog[i] != NULL) { free_GenomicOverlapGene(obj->gog[i]); obj->gog[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: GenomicOverlapResults_alloc_std(void) * * Descrip: Equivalent to GenomicOverlapResults_alloc_len(GenomicOverlapResultsLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GenomicOverlapResults *] * */ GenomicOverlapResults * GenomicOverlapResults_alloc_std(void) { return GenomicOverlapResults_alloc_len(GenomicOverlapResultsLISTLENGTH); } /* Function: GenomicOverlapResults_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GenomicOverlapResults *] * */ GenomicOverlapResults * GenomicOverlapResults_alloc_len(int len) { GenomicOverlapResults * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = GenomicOverlapResults_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->gog = (GenomicOverlapGene ** ) ckcalloc (len,sizeof(GenomicOverlapGene *))) == NULL) { warn("Warning, ckcalloc failed in GenomicOverlapResults_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_GenomicOverlapResults(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomicOverlapResults *] * * Return [UNKN ] Undocumented return value [GenomicOverlapResults *] * */ GenomicOverlapResults * hard_link_GenomicOverlapResults(GenomicOverlapResults * obj) { if( obj == NULL ) { warn("Trying to hard link to a GenomicOverlapResults object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: GenomicOverlapResults_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomicOverlapResults *] * */ GenomicOverlapResults * GenomicOverlapResults_alloc(void) { GenomicOverlapResults * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(GenomicOverlapResults *) ckalloc (sizeof(GenomicOverlapResults))) == NULL) { warn("GenomicOverlapResults_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->gene_overlap = 0; out->gog = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_GenomicOverlapResults(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomicOverlapResults *] * * Return [UNKN ] Undocumented return value [GenomicOverlapResults *] * */ GenomicOverlapResults * free_GenomicOverlapResults(GenomicOverlapResults * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a GenomicOverlapResults obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->gog != NULL) { for(i=0;ilen;i++) { if( obj->gog[i] != NULL) free_GenomicOverlapGene(obj->gog[i]); } ckfree(obj->gog); } ckfree(obj); return NULL; } /* Function: hard_link_ShowGenomicRegionOptions(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShowGenomicRegionOptions *] * * Return [UNKN ] Undocumented return value [ShowGenomicRegionOptions *] * */ ShowGenomicRegionOptions * hard_link_ShowGenomicRegionOptions(ShowGenomicRegionOptions * obj) { if( obj == NULL ) { warn("Trying to hard link to a ShowGenomicRegionOptions object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ShowGenomicRegionOptions_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShowGenomicRegionOptions *] * */ ShowGenomicRegionOptions * ShowGenomicRegionOptions_alloc(void) { ShowGenomicRegionOptions * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ShowGenomicRegionOptions *) ckalloc (sizeof(ShowGenomicRegionOptions))) == NULL) { warn("ShowGenomicRegionOptions_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->show_trans = 0; out->show_raw = 0; out->show_cdna = 0; out->show_ace = 0; out->show_ace_halfwise = 0; out->show_GFF = 0; out->show_gene_str = 0; out->show_gene_supp = 0; return out; } /* Function: free_ShowGenomicRegionOptions(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShowGenomicRegionOptions *] * * Return [UNKN ] Undocumented return value [ShowGenomicRegionOptions *] * */ ShowGenomicRegionOptions * free_ShowGenomicRegionOptions(ShowGenomicRegionOptions * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ShowGenomicRegionOptions obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: access_gene_GenomicRegion(obj,i) * * Descrip: Access members stored in the gene list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [GenomicRegion *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [Gene *] * */ Gene * access_gene_GenomicRegion(GenomicRegion * obj,int i) { if( obj == NULL) { warn("In accessor function gene for object GenomicRegion, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function gene for object GenomicRegion, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->gene[i]; } /* Function: length_gene_GenomicRegion(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [GenomicRegion *] * * Return [UNKN ] length of the list [int] * */ int length_gene_GenomicRegion(GenomicRegion * obj) { if( obj == NULL) { warn("In length function gene for object GenomicRegion, got a NULL object"); return -1; } return obj->len; } /* Function: replace_genomic_GenomicRegion(obj,genomic) * * Descrip: Replace member variable genomic * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicRegion *] * Arg: genomic [OWNER] New value of the variable [Genomic *] * * Return [SOFT ] member variable genomic [boolean] * */ boolean replace_genomic_GenomicRegion(GenomicRegion * obj,Genomic * genomic) { if( obj == NULL) { warn("In replacement function genomic for object GenomicRegion, got a NULL object"); return FALSE; } obj->genomic = genomic; return TRUE; } /* Function: access_genomic_GenomicRegion(obj) * * Descrip: Access member variable genomic * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [GenomicRegion *] * * Return [SOFT ] member variable genomic [Genomic *] * */ Genomic * access_genomic_GenomicRegion(GenomicRegion * obj) { if( obj == NULL) { warn("In accessor function genomic for object GenomicRegion, got a NULL object"); return NULL; } return obj->genomic; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/genomicregion.h0000644000175000001440000007010610670453712017640 0ustar philippusers#ifndef DYNAMITEgenomicregionHEADERFILE #define DYNAMITEgenomicregionHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #define GenomicRegionLISTLENGTH 16 #define GenomicOverlapResultsLISTLENGTH 16 #ifndef DYNAMITE_DEFINED_Gene typedef struct Wise2_Gene Wise2_Gene; #define Gene Wise2_Gene #define DYNAMITE_DEFINED_Gene #endif /* Object GenomicRegion * * Descrip: GenomicRegion is structure which represents * information on a region of genomic DNA. It * *may not* have the actual DNA sequence in there, * and it is important to realise that. * * The numbering scheme of many other things (eg, * genes) are going to be represented in this * guys coordinates * * */ struct Wise2_GenomicRegion { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Gene ** gene; int len;/* len for above gene */ int maxlen; /* maxlen for above gene */ Genomic * genomic; /* NB, may not be here. Be careful! */ } ; /* GenomicRegion defined */ #ifndef DYNAMITE_DEFINED_GenomicRegion typedef struct Wise2_GenomicRegion Wise2_GenomicRegion; #define GenomicRegion Wise2_GenomicRegion #define DYNAMITE_DEFINED_GenomicRegion #endif struct Wise2_GenomicOverlapGene { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int exon_perfect; int exon_truncated; int exon_partial; int exon_missed_internal; int exon_missed_external; int exon_mispredicted; Gene * truth; /* NB hard-linked */ Gene * test; } ; /* GenomicOverlapGene defined */ #ifndef DYNAMITE_DEFINED_GenomicOverlapGene typedef struct Wise2_GenomicOverlapGene Wise2_GenomicOverlapGene; #define GenomicOverlapGene Wise2_GenomicOverlapGene #define DYNAMITE_DEFINED_GenomicOverlapGene #endif struct Wise2_GenomicOverlapResults { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int gene_overlap; GenomicOverlapGene ** gog; int len;/* len for above gog */ int maxlen; /* maxlen for above gog */ } ; /* GenomicOverlapResults defined */ #ifndef DYNAMITE_DEFINED_GenomicOverlapResults typedef struct Wise2_GenomicOverlapResults Wise2_GenomicOverlapResults; #define GenomicOverlapResults Wise2_GenomicOverlapResults #define DYNAMITE_DEFINED_GenomicOverlapResults #endif struct Wise2_ShowGenomicRegionOptions { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif boolean show_trans; boolean show_raw; boolean show_cdna; boolean show_ace; boolean show_ace_halfwise; boolean show_GFF; boolean show_gene_str; boolean show_gene_supp; } ; /* ShowGenomicRegionOptions defined */ #ifndef DYNAMITE_DEFINED_ShowGenomicRegionOptions typedef struct Wise2_ShowGenomicRegionOptions Wise2_ShowGenomicRegionOptions; #define ShowGenomicRegionOptions Wise2_ShowGenomicRegionOptions #define DYNAMITE_DEFINED_ShowGenomicRegionOptions #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_GenomicRegion_discard_short(gr,multiexon,singleexon) * * Descrip: Makes a new genomic region with genes * greater than XXX length going through * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: multiexon [UNKN ] Undocumented argument [int] * Arg: singleexon [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * Wise2_new_GenomicRegion_discard_short(GenomicRegion * gr,int multiexon,int singleexon); #define new_GenomicRegion_discard_short Wise2_new_GenomicRegion_discard_short /* Function: show_GenomicRegionOptions(sgro,gr,ct,dividestr,ofp) * * Descrip: Actually shows a genomic region wrt to the options * * * Arg: sgro [UNKN ] Undocumented argument [ShowGenomicRegionOptions *] * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: dividestr [UNKN ] Undocumented argument [char *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_GenomicRegionOptions(ShowGenomicRegionOptions * sgro,GenomicRegion * gr,CodonTable * ct,char * dividestr,FILE * ofp); #define show_GenomicRegionOptions Wise2_show_GenomicRegionOptions /* Function: show_help_ShowGenomicRegionOptions(ofp) * * Descrip: Help for ShowGenomicRegionOptions * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_help_ShowGenomicRegionOptions(FILE * ofp); #define show_help_ShowGenomicRegionOptions Wise2_show_help_ShowGenomicRegionOptions /* Function: new_ShowGenomicRegionOptions_from_argv(argc,argv) * * Descrip: Makes a ShowGenomicRegionOptions from command line * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [ShowGenomicRegionOptions *] * */ ShowGenomicRegionOptions * Wise2_new_ShowGenomicRegionOptions_from_argv(int * argc,char ** argv); #define new_ShowGenomicRegionOptions_from_argv Wise2_new_ShowGenomicRegionOptions_from_argv /* Function: read_genes_GenomicRegion(ifp) * * Descrip: read genes output * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * Wise2_read_genes_GenomicRegion(FILE * ifp); #define read_genes_GenomicRegion Wise2_read_genes_GenomicRegion /* Function: show_GenomicOverlapResults(gor,ofp) * * Descrip: shows overlap resuls vaguely humanely * * * Arg: gor [UNKN ] Undocumented argument [GenomicOverlapResults *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_GenomicOverlapResults(GenomicOverlapResults * gor,FILE * ofp); #define show_GenomicOverlapResults Wise2_show_GenomicOverlapResults /* Function: Genomic_overlap(query,truth) * * Descrip: Gives the overlap of query in target. It is reported * back in the GenomicOverlapResults structure * * * Arg: query [UNKN ] Undocumented argument [GenomicRegion *] * Arg: truth [UNKN ] Undocumented argument [GenomicRegion *] * * Return [UNKN ] Undocumented return value [GenomicOverlapResults *] * */ GenomicOverlapResults * Wise2_Genomic_overlap(GenomicRegion * query,GenomicRegion * truth); #define Genomic_overlap Wise2_Genomic_overlap /* Function: Gene_overlap_forward(test,truth) * * Descrip: Works out a gene overlap for two forward genes * * * Arg: test [UNKN ] Undocumented argument [Gene *] * Arg: truth [UNKN ] Undocumented argument [Gene *] * * Return [UNKN ] Undocumented return value [GenomicOverlapGene *] * */ GenomicOverlapGene * Wise2_Gene_overlap_forward(Gene * test,Gene * truth); #define Gene_overlap_forward Wise2_Gene_overlap_forward /* Function: Gene_overlap_backward(test,truth) * * Descrip: Works out a gene overlap for two backward genes * * * Arg: test [UNKN ] Undocumented argument [Gene *] * Arg: truth [UNKN ] Undocumented argument [Gene *] * * Return [UNKN ] Undocumented return value [GenomicOverlapGene *] * */ GenomicOverlapGene * Wise2_Gene_overlap_backward(Gene * test,Gene * truth); #define Gene_overlap_backward Wise2_Gene_overlap_backward /* Function: simple_merged_GenomicRegion(gr,bits_cutoff,max_ext) * * Descrip: Makes a new genomic region from the given * genomic region, trying to merge close * gene predictions that can be made by * extending open reading frames * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: bits_cutoff [UNKN ] Undocumented argument [double] * Arg: max_ext [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * Wise2_simple_merged_GenomicRegion(GenomicRegion * gr,double bits_cutoff,int max_ext); #define simple_merged_GenomicRegion Wise2_simple_merged_GenomicRegion /* Function: sort_GenomicRegion_absolute(gr) * * Descrip: sorts the genomicregion by absolute start points. * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * */ void Wise2_sort_GenomicRegion_absolute(GenomicRegion * gr); #define sort_GenomicRegion_absolute Wise2_sort_GenomicRegion_absolute /* Function: compare_Gene_absolute(one,two) * * Descrip: internal sort function * * * Arg: one [UNKN ] Undocumented argument [Gene *] * Arg: two [UNKN ] Undocumented argument [Gene *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_compare_Gene_absolute(Gene * one,Gene * two); #define compare_Gene_absolute Wise2_compare_Gene_absolute /* Function: get_Genomic_from_GenomicRegion(gr) * * Descrip: gives back genomic sequence from a genomic region. This is *soft * linked* - ie, dont free it and use /hard_link_Genomic if you do want to... * * * Arg: gr [UNKN ] genomic region input [GenomicRegion *] * * Return [SOFT ] a Genomic sequence [Genomic *] * */ Genomic * Wise2_get_Genomic_from_GenomicRegion(GenomicRegion * gr); #define get_Genomic_from_GenomicRegion Wise2_get_Genomic_from_GenomicRegion /* Function: read_EMBL_GenomicRegion_efetch(efetch) * * Descrip: Reads both feature table and sequence * * * Arg: efetch [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * Wise2_read_EMBL_GenomicRegion_efetch(char * efetch) ; #define read_EMBL_GenomicRegion_efetch Wise2_read_EMBL_GenomicRegion_efetch /* Function: read_EMBL_GenomicRegion_SRS(srsquery) * * Descrip: Reads both feature table and sequence * * * Arg: srsquery [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * Wise2_read_EMBL_GenomicRegion_SRS(char * srsquery) ; #define read_EMBL_GenomicRegion_SRS Wise2_read_EMBL_GenomicRegion_SRS /* Function: read_EMBL_GenomicRegion_file(filename) * * Descrip: Reads in both EMBL sequence and features * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * Wise2_read_EMBL_GenomicRegion_file(char * filename); #define read_EMBL_GenomicRegion_file Wise2_read_EMBL_GenomicRegion_file /* Function: read_EMBL_GenomicRegion(ifp) * * Descrip: Reads in both EMBL sequence and features * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * Wise2_read_EMBL_GenomicRegion(FILE * ifp); #define read_EMBL_GenomicRegion Wise2_read_EMBL_GenomicRegion /* Function: read_EMBL_FT_into_GenomicRegion(buffer,maxlen,gr,ifp) * * Descrip: Reads in EMBL *features*, not sequence. * * * Arg: buffer [UNKN ] Undocumented argument [char *] * Arg: maxlen [UNKN ] Undocumented argument [int] * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_read_EMBL_FT_into_GenomicRegion(char * buffer,int maxlen,GenomicRegion * gr,FILE * ifp); #define read_EMBL_FT_into_GenomicRegion Wise2_read_EMBL_FT_into_GenomicRegion /* Function: show_GenomicRegion(gr,ofp) * * Descrip: dumps genomic region in vaguely human form * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_GenomicRegion(GenomicRegion * gr,FILE * ofp); #define show_GenomicRegion Wise2_show_GenomicRegion /* Function: dump_translations_GenomicRegion(gr,ct,ofp) * * Descrip: shows all the translations in this genomic region * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_dump_translations_GenomicRegion(GenomicRegion * gr,CodonTable * ct,FILE * ofp); #define dump_translations_GenomicRegion Wise2_dump_translations_GenomicRegion /* Function: dump_transcripts_GenomicRegion(gr,ofp) * * Descrip: shows all the transcripts in this genomic region * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_dump_transcripts_GenomicRegion(GenomicRegion * gr,FILE * ofp); #define dump_transcripts_GenomicRegion Wise2_dump_transcripts_GenomicRegion /* Function: new_GenomicRegion(gen) * * Descrip: makes a genomicregion from a genomic sequence * * * Arg: gen [UNKN ] Undocumented argument [Genomic *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * Wise2_new_GenomicRegion(Genomic * gen); #define new_GenomicRegion Wise2_new_GenomicRegion /* Function: add_Gene_to_GenomicRegion(gr,gene) * * Descrip: adds a Gene to this GenomicRegion, making * sure that it parent/son relationship is ok * * * Arg: gr [UNKN ] GenomicRegion to be added to [GenomicRegion *] * Arg: gene [UNKN ] Gene to be added [Gene *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_Gene_to_GenomicRegion(GenomicRegion * gr,Gene * gene); #define add_Gene_to_GenomicRegion Wise2_add_Gene_to_GenomicRegion /* Function: write_Embl_FT_GenomicRegion(gr,ofp) * * Descrip: Writes Embl feature table. Does assumme that * there is only one transcript per gene and only * cds exons are used * * Output like * * FT CDS join(100..200) * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_write_Embl_FT_GenomicRegion(GenomicRegion * gr,FILE * ofp); #define write_Embl_FT_GenomicRegion Wise2_write_Embl_FT_GenomicRegion /* Function: write_Diana_FT_GenomicRegion(gr,ofp) * * Descrip: Writes Embl feature table for diana use. Does assumme that * there is only one transcript per gene and only * cds exons are used * * Output like * * FT misc_feature join(100..200) * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_write_Diana_FT_GenomicRegion(GenomicRegion * gr,FILE * ofp); #define write_Diana_FT_GenomicRegion Wise2_write_Diana_FT_GenomicRegion /* Function: show_ace_GenomicRegion(gr,seq_name,ofp) * * Descrip: shows ACeDB subsequence source. * * Assummes * a only one transcript per gene * b only cds exons are used * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: seq_name [UNKN ] Undocumented argument [char *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_ace_GenomicRegion(GenomicRegion * gr,char * seq_name,FILE * ofp); #define show_ace_GenomicRegion Wise2_show_ace_GenomicRegion /* Function: show_halfwise_GenomicRegion(gr,seq_name,method,db,doweb,weblocation,ofp) * * Descrip: shows ACeDB subsequence source for halfwise * method. * * Assummes * a only one transcript per gene * b only cds exons are used * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: seq_name [UNKN ] Undocumented argument [char *] * Arg: method [UNKN ] Undocumented argument [char *] * Arg: db [UNKN ] Undocumented argument [char *] * Arg: doweb [UNKN ] Undocumented argument [boolean] * Arg: weblocation [UNKN ] Undocumented argument [char *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_halfwise_GenomicRegion(GenomicRegion * gr,char * seq_name,char * method,char * db,boolean doweb,char * weblocation,FILE * ofp); #define show_halfwise_GenomicRegion Wise2_show_halfwise_GenomicRegion /* Function: show_GFF_GenomicRegion(gr,seq_name,source,ofp) * * Descrip: shows GFF output * * Assummes * a only cds exons are used * * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: seq_name [UNKN ] Undocumented argument [char *] * Arg: source [UNKN ] Undocumented argument [char *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_GFF_GenomicRegion(GenomicRegion * gr,char * seq_name,char * source,FILE * ofp); #define show_GFF_GenomicRegion Wise2_show_GFF_GenomicRegion /* Function: show_pretty_GenomicRegion(gr,show_supporting,ofp) * * Descrip: No Description * * Arg: gr [UNKN ] Undocumented argument [GenomicRegion *] * Arg: show_supporting [UNKN ] Undocumented argument [boolean] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_pretty_GenomicRegion(GenomicRegion * gr,boolean show_supporting,FILE * ofp); #define show_pretty_GenomicRegion Wise2_show_pretty_GenomicRegion /* Function: add_GenomicRegion(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenomicRegion *] * Arg: add [OWNER] Object to add to the list [Gene *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_GenomicRegion(GenomicRegion * obj,Gene * add); #define add_GenomicRegion Wise2_add_GenomicRegion /* Function: flush_GenomicRegion(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenomicRegion *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_GenomicRegion(GenomicRegion * obj); #define flush_GenomicRegion Wise2_flush_GenomicRegion /* Function: GenomicRegion_alloc_std(void) * * Descrip: Equivalent to GenomicRegion_alloc_len(GenomicRegionLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * Wise2_GenomicRegion_alloc_std(void); #define GenomicRegion_alloc_std Wise2_GenomicRegion_alloc_std /* Function: GenomicRegion_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * Wise2_GenomicRegion_alloc_len(int len); #define GenomicRegion_alloc_len Wise2_GenomicRegion_alloc_len /* Function: hard_link_GenomicRegion(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomicRegion *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * Wise2_hard_link_GenomicRegion(GenomicRegion * obj); #define hard_link_GenomicRegion Wise2_hard_link_GenomicRegion /* Function: GenomicRegion_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * Wise2_GenomicRegion_alloc(void); #define GenomicRegion_alloc Wise2_GenomicRegion_alloc /* Function: free_GenomicRegion(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomicRegion *] * * Return [UNKN ] Undocumented return value [GenomicRegion *] * */ GenomicRegion * Wise2_free_GenomicRegion(GenomicRegion * obj); #define free_GenomicRegion Wise2_free_GenomicRegion /* Function: hard_link_GenomicOverlapGene(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomicOverlapGene *] * * Return [UNKN ] Undocumented return value [GenomicOverlapGene *] * */ GenomicOverlapGene * Wise2_hard_link_GenomicOverlapGene(GenomicOverlapGene * obj); #define hard_link_GenomicOverlapGene Wise2_hard_link_GenomicOverlapGene /* Function: GenomicOverlapGene_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomicOverlapGene *] * */ GenomicOverlapGene * Wise2_GenomicOverlapGene_alloc(void); #define GenomicOverlapGene_alloc Wise2_GenomicOverlapGene_alloc /* Function: free_GenomicOverlapGene(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomicOverlapGene *] * * Return [UNKN ] Undocumented return value [GenomicOverlapGene *] * */ GenomicOverlapGene * Wise2_free_GenomicOverlapGene(GenomicOverlapGene * obj); #define free_GenomicOverlapGene Wise2_free_GenomicOverlapGene /* Function: add_GenomicOverlapResults(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [GenomicOverlapResults *] * Arg: add [OWNER] Object to add to the list [GenomicOverlapGene *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_GenomicOverlapResults(GenomicOverlapResults * obj,GenomicOverlapGene * add); #define add_GenomicOverlapResults Wise2_add_GenomicOverlapResults /* Function: flush_GenomicOverlapResults(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [GenomicOverlapResults *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_GenomicOverlapResults(GenomicOverlapResults * obj); #define flush_GenomicOverlapResults Wise2_flush_GenomicOverlapResults /* Function: GenomicOverlapResults_alloc_std(void) * * Descrip: Equivalent to GenomicOverlapResults_alloc_len(GenomicOverlapResultsLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [GenomicOverlapResults *] * */ GenomicOverlapResults * Wise2_GenomicOverlapResults_alloc_std(void); #define GenomicOverlapResults_alloc_std Wise2_GenomicOverlapResults_alloc_std /* Function: GenomicOverlapResults_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [GenomicOverlapResults *] * */ GenomicOverlapResults * Wise2_GenomicOverlapResults_alloc_len(int len); #define GenomicOverlapResults_alloc_len Wise2_GenomicOverlapResults_alloc_len /* Function: hard_link_GenomicOverlapResults(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [GenomicOverlapResults *] * * Return [UNKN ] Undocumented return value [GenomicOverlapResults *] * */ GenomicOverlapResults * Wise2_hard_link_GenomicOverlapResults(GenomicOverlapResults * obj); #define hard_link_GenomicOverlapResults Wise2_hard_link_GenomicOverlapResults /* Function: GenomicOverlapResults_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [GenomicOverlapResults *] * */ GenomicOverlapResults * Wise2_GenomicOverlapResults_alloc(void); #define GenomicOverlapResults_alloc Wise2_GenomicOverlapResults_alloc /* Function: free_GenomicOverlapResults(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [GenomicOverlapResults *] * * Return [UNKN ] Undocumented return value [GenomicOverlapResults *] * */ GenomicOverlapResults * Wise2_free_GenomicOverlapResults(GenomicOverlapResults * obj); #define free_GenomicOverlapResults Wise2_free_GenomicOverlapResults /* Function: hard_link_ShowGenomicRegionOptions(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShowGenomicRegionOptions *] * * Return [UNKN ] Undocumented return value [ShowGenomicRegionOptions *] * */ ShowGenomicRegionOptions * Wise2_hard_link_ShowGenomicRegionOptions(ShowGenomicRegionOptions * obj); #define hard_link_ShowGenomicRegionOptions Wise2_hard_link_ShowGenomicRegionOptions /* Function: ShowGenomicRegionOptions_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShowGenomicRegionOptions *] * */ ShowGenomicRegionOptions * Wise2_ShowGenomicRegionOptions_alloc(void); #define ShowGenomicRegionOptions_alloc Wise2_ShowGenomicRegionOptions_alloc /* Function: free_ShowGenomicRegionOptions(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShowGenomicRegionOptions *] * * Return [UNKN ] Undocumented return value [ShowGenomicRegionOptions *] * */ ShowGenomicRegionOptions * Wise2_free_ShowGenomicRegionOptions(ShowGenomicRegionOptions * obj); #define free_ShowGenomicRegionOptions Wise2_free_ShowGenomicRegionOptions /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ Gene * Wise2_access_gene_GenomicRegion(GenomicRegion * obj,int i); #define access_gene_GenomicRegion Wise2_access_gene_GenomicRegion Genomic * Wise2_access_genomic_GenomicRegion(GenomicRegion * obj); #define access_genomic_GenomicRegion Wise2_access_genomic_GenomicRegion int Wise2_length_gene_GenomicRegion(GenomicRegion * obj); #define length_gene_GenomicRegion Wise2_length_gene_GenomicRegion boolean Wise2_replace_genomic_GenomicRegion(GenomicRegion * obj,Genomic * genomic); #define replace_genomic_GenomicRegion Wise2_replace_genomic_GenomicRegion void Wise2_show_GenomicOverlapGene(GenomicOverlapGene * gog,FILE * ofp); #define show_GenomicOverlapGene Wise2_show_GenomicOverlapGene void Wise2_swap_GenomicRegion(Gene ** list,int i,int j) ; #define swap_GenomicRegion Wise2_swap_GenomicRegion void Wise2_qsort_GenomicRegion(Gene ** list,int left,int right,int (*comp)(Gene * ,Gene * )); #define qsort_GenomicRegion Wise2_qsort_GenomicRegion void Wise2_sort_GenomicRegion(GenomicRegion * obj,int (*comp)(Gene *, Gene *)); #define sort_GenomicRegion Wise2_sort_GenomicRegion boolean Wise2_expand_GenomicRegion(GenomicRegion * obj,int len); #define expand_GenomicRegion Wise2_expand_GenomicRegion void Wise2_swap_GenomicOverlapResults(GenomicOverlapGene ** list,int i,int j) ; #define swap_GenomicOverlapResults Wise2_swap_GenomicOverlapResults void Wise2_qsort_GenomicOverlapResults(GenomicOverlapGene ** list,int left,int right,int (*comp)(GenomicOverlapGene * ,GenomicOverlapGene * )); #define qsort_GenomicOverlapResults Wise2_qsort_GenomicOverlapResults void Wise2_sort_GenomicOverlapResults(GenomicOverlapResults * obj,int (*comp)(GenomicOverlapGene *, GenomicOverlapGene *)); #define sort_GenomicOverlapResults Wise2_sort_GenomicOverlapResults boolean Wise2_expand_GenomicOverlapResults(GenomicOverlapResults * obj,int len); #define expand_GenomicOverlapResults Wise2_expand_GenomicOverlapResults #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/codonmatrix.dy0000644000175000001440000000476607346742773017556 0ustar philippusers %{ #include "dyna.h" %} struct CodonMatrix Probability prob[125][125] struct CodonMatrixScore Score score[125][125] %{ #include "codonmatrix.h" %func Combines CodonMatrixScore_from_CodonMatrix and naive_CodonMatrix %% CodonMatrixScore * naive_CodonMatrixScore_from_prob(CodonTable * ct,CompProb * cm) { CodonMatrixScore * out; CodonMatrix * com; com = naive_CodonMatrix(ct,cm); out = CodonMatrixScore_from_CodonMatrix(com); free_CodonMatrix(com); return out; } %func Makes a CodonMatrixScore from a CodonMatrix %% CodonMatrixScore * CodonMatrixScore_from_CodonMatrix(CodonMatrix * cm) { int i,j; CodonMatrixScore * out; out = CodonMatrixScore_alloc(); for(i=0;i<125;i++) for(j=0;j<125;j++) out->score[i][j] = Probability2Score(cm->prob[i][j]); return out; } %func Builds a probability matrix No codon bias No errors N codons score 1.0, stop codons probability 0.00001 %% CodonMatrix * naive_CodonMatrix(CodonTable * ct,CompProb * comp) { int i; int j; CodonMatrix * out; out = CodonMatrix_alloc(); for(i=0;i<125;i++) for(j=i;j<125;j++) { if( has_random_bases(i) == TRUE || has_random_bases(j) == TRUE ) { out->prob[i][j] = out->prob[j][i] = 1.0; } else if ( is_stop_codon(i,ct) == TRUE || is_stop_codon(j,ct) == TRUE ) { out->prob[i][j] = out->prob[j][i] = 0.00001; } else { out->prob[i][j] = out->prob[j][i] = comp->comp[aminoacid_no_from_codon(ct,i)][aminoacid_no_from_codon(ct,j)]; } } return out; } %func Builds a codon matrix from CompMat which assummes: No codon Bias No errors N codons score 0, stop codons score ?? %arg ct CodonTable for codon->aa mapping comp Comparison matrix for the score of the individual access %% CodonMatrixScore * naive_CodonMatrixScore(CodonTable * ct,CompMat * comp) { int i; int j; CodonMatrixScore * out; out = CodonMatrixScore_alloc(); for(i=0;i<125;i++) for(j=i;j<125;j++) { if( has_random_bases(i) == TRUE || has_random_bases(j) == TRUE ) out->score[i][j] = out->score[j][i] = 0; else out->score[i][j] = out->score[j][i] = fail_safe_CompMat_access(comp,aminoacid_no_from_codon(ct,i),aminoacid_no_from_codon(ct,j)); } return out; } %func Shows a codonmatrix %% void show_CodonMatrixScore(CodonMatrixScore * cms,CodonTable * ct,FILE * ofp) { int i; int j; for(i=0;i<125;i++) for(j=0;j<125;j++) { fprintf(ofp,"%5d %c :%5d %c Score %5d\n",i,aminoacid_from_codon(ct,i),j,aminoacid_from_codon(ct,j),cms->score[i][j]); } } wise-2.4.1/src/dynlibsrc/aln.pod0000644000175000001440000004173710670453712016130 0ustar philippusers=head1 NAME aln module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item AlnBlock =item AlnColumn =item AlnUnit =item AlnSequence =back =head1 DESCRIPTION =head2 Object AlnBlock =over =item start Type [AlnColumn *] Scalar the first AlnColumn in the alignment =item seq Type [AlnSequence **] List a list of AlnSequences in the alignment =item length Type [int] Scalar not used =item score Type [int] Scalar not used =back AlnBlock is the main representation of alignments from Dynamite. Each AlnBlock represents any number of 'sequences', of any type, which share things in common. The alignment is represented by a series of /AlnColumns (linked list) in which each AlnColumn has a series of AlnUnits, each Unit being a start/end/text_label triple. Alternatively, one can see each sequence in isolation, and not ask what it is aligned to, but rather what labels it has on it. =head2 Member functions of AlnBlock =over =item dump_ascii_AlnBlock &Wise2::AlnBlock::dump_ascii_AlnBlock(alb,ofp) Dumps the alignment in rereadable ascii form. Not really for human consumption Argument alb [UNKN ] AlnBlock to dump [AlnBlock *] Argument ofp [UNKN ] File stream to dump to [FILE *] Return [UNKN ] Undocumented return value [void] =item hard_link_AlnBlock &Wise2::AlnBlock::hard_link_AlnBlock(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [AlnBlock *] Return [UNKN ] Undocumented return value [AlnBlock *] =item AlnBlock_alloc_std &Wise2::AlnBlock::AlnBlock_alloc_std(void) Equivalent to AlnBlock_alloc_len(AlnBlockLISTLENGTH) Return [UNKN ] Undocumented return value [AlnBlock *] =item set_start &Wise2::AlnBlock::set_start(obj,start) Replace member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnBlock *] Argument start [OWNER] New value of the variable [AlnColumn *] Return [SOFT ] member variable start [boolean] =item start &Wise2::AlnBlock::start(obj) Access member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnBlock *] Return [SOFT ] member variable start [AlnColumn *] =item seq &Wise2::AlnBlock::seq(obj,i) Access members stored in the seq list For use principly by API functions Argument obj [UNKN ] Object holding the list [AlnBlock *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [AlnSequence *] =item length_seq &Wise2::AlnBlock::length_seq(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [AlnBlock *] Return [UNKN ] length of the list [int] =item flush_seq &Wise2::AlnBlock::flush_seq(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [AlnBlock *] Return [UNKN ] Undocumented return value [int] =item add_seq &Wise2::AlnBlock::add_seq(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [AlnBlock *] Argument add [OWNER] Object to add to the list [AlnSequence *] Return [UNKN ] Undocumented return value [boolean] =item set_length &Wise2::AlnBlock::set_length(obj,length) Replace member variable length For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnBlock *] Argument length [OWNER] New value of the variable [int] Return [SOFT ] member variable length [boolean] =item length &Wise2::AlnBlock::length(obj) Access member variable length For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnBlock *] Return [SOFT ] member variable length [int] =item set_score &Wise2::AlnBlock::set_score(obj,score) Replace member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnBlock *] Argument score [OWNER] New value of the variable [int] Return [SOFT ] member variable score [boolean] =item score &Wise2::AlnBlock::score(obj) Access member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnBlock *] Return [SOFT ] member variable score [int] =back =head2 Object AlnColumn =over =item alu Type [AlnUnit **] List list of the AlnUnits in this column =item next Type [AlnColumn *] Scalar the next AlnColumn in this block =back This is a coupling of AlnUnits from different sequences. Each AlnUnit is meant to represent *the equivalent* piece of biological information in some sense (ie, they are alignmed), even though quite possibly they are very different types of information =head2 Member functions of AlnColumn =over =item at_end &Wise2::AlnColumn::at_end(alc) This tells you whether the AlnColumn is at the end without passing NULL's around Argument alc [READ ] AlnColumn [AlnColumn *] Return [UNKN ] Undocumented return value [boolean] =item hard_link_AlnColumn &Wise2::AlnColumn::hard_link_AlnColumn(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [AlnColumn *] Return [UNKN ] Undocumented return value [AlnColumn *] =item AlnColumn_alloc_std &Wise2::AlnColumn::AlnColumn_alloc_std(void) Equivalent to AlnColumn_alloc_len(AlnColumnLISTLENGTH) Return [UNKN ] Undocumented return value [AlnColumn *] =item alu &Wise2::AlnColumn::alu(obj,i) Access members stored in the alu list For use principly by API functions Argument obj [UNKN ] Object holding the list [AlnColumn *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [AlnUnit *] =item length_alu &Wise2::AlnColumn::length_alu(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [AlnColumn *] Return [UNKN ] length of the list [int] =item flush_alu &Wise2::AlnColumn::flush_alu(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [AlnColumn *] Return [UNKN ] Undocumented return value [int] =item add_alu &Wise2::AlnColumn::add_alu(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [AlnColumn *] Argument add [OWNER] Object to add to the list [AlnUnit *] Return [UNKN ] Undocumented return value [boolean] =item set_next &Wise2::AlnColumn::set_next(obj,next) Replace member variable next For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnColumn *] Argument next [OWNER] New value of the variable [AlnColumn *] Return [SOFT ] member variable next [boolean] =item next &Wise2::AlnColumn::next(obj) Access member variable next For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnColumn *] Return [SOFT ] member variable next [AlnColumn *] =back =head2 Object AlnUnit =over =item start Type [int] Scalar start position in the sequence =item end Type [int] Scalar end position in the sequence =item label Type [int] Scalar not used =item text_label Type [char *] Scalar text label of this position =item next Type [AlnUnit *] Scalar next AlnUnit in this sequence =item score[AlnUnitSCORENUMBER] Type [int] Scalar a series of scores for this position. =item in_column Type [boolean] Scalar not used =item seq Type [AlnSequence *] Scalar No documentation =back This is the basic unit of the label alignment. It describes a single mark-up over one sequence: being a start, an end and a text_label. =head2 Member functions of AlnUnit =over =item bio_start &Wise2::AlnUnit::bio_start(alu) Tells the bio-coordinate of the start point of this alnunit Argument alu [UNKN ] Undocumented argument [AlnUnit *] Return [UNKN ] Undocumented return value [int] =item bio_end &Wise2::AlnUnit::bio_end(alu) Tells the bio-coordinate of the end point of this alnunit Argument alu [UNKN ] Undocumented argument [AlnUnit *] Return [UNKN ] Undocumented return value [int] =item hard_link_AlnUnit &Wise2::AlnUnit::hard_link_AlnUnit(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [AlnUnit *] Return [UNKN ] Undocumented return value [AlnUnit *] =item alloc &Wise2::AlnUnit::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [AlnUnit *] =item set_start &Wise2::AlnUnit::set_start(obj,start) Replace member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Argument start [OWNER] New value of the variable [int] Return [SOFT ] member variable start [boolean] =item start &Wise2::AlnUnit::start(obj) Access member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Return [SOFT ] member variable start [int] =item set_end &Wise2::AlnUnit::set_end(obj,end) Replace member variable end For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Argument end [OWNER] New value of the variable [int] Return [SOFT ] member variable end [boolean] =item end &Wise2::AlnUnit::end(obj) Access member variable end For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Return [SOFT ] member variable end [int] =item set_label &Wise2::AlnUnit::set_label(obj,label) Replace member variable label For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Argument label [OWNER] New value of the variable [int] Return [SOFT ] member variable label [boolean] =item label &Wise2::AlnUnit::label(obj) Access member variable label For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Return [SOFT ] member variable label [int] =item set_text_label &Wise2::AlnUnit::set_text_label(obj,text_label) Replace member variable text_label For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Argument text_label [OWNER] New value of the variable [char *] Return [SOFT ] member variable text_label [boolean] =item text_label &Wise2::AlnUnit::text_label(obj) Access member variable text_label For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Return [SOFT ] member variable text_label [char *] =item set_next &Wise2::AlnUnit::set_next(obj,next) Replace member variable next For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Argument next [OWNER] New value of the variable [AlnUnit *] Return [SOFT ] member variable next [boolean] =item next &Wise2::AlnUnit::next(obj) Access member variable next For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Return [SOFT ] member variable next [AlnUnit *] =item set_in_column &Wise2::AlnUnit::set_in_column(obj,in_column) Replace member variable in_column For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Argument in_column [OWNER] New value of the variable [boolean] Return [SOFT ] member variable in_column [boolean] =item in_column &Wise2::AlnUnit::in_column(obj) Access member variable in_column For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Return [SOFT ] member variable in_column [boolean] =item set_seq &Wise2::AlnUnit::set_seq(obj,seq) Replace member variable seq For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Argument seq [OWNER] New value of the variable [AlnSequence *] Return [SOFT ] member variable seq [boolean] =item seq &Wise2::AlnUnit::seq(obj) Access member variable seq For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnUnit *] Return [SOFT ] member variable seq [AlnSequence *] =back =head2 Object AlnSequence =over =item start Type [AlnUnit *] Scalar the first AlnUnit of this sequence =item data_type Type [int] Scalar not used =item data Type [void *] Scalar not used - don't use! =item bio_start Type [int] Scalar start of this sequence in its 'bio' coordinates =item bio_end Type [int] Scalar end of this sequence in its 'bio' coordinates =back Each Sequence in an AlnBlock is represented by one of these, and in many ways this is an orthogonal way of looking at the alignment than the AlnColumns. If you look at the alignment from one AlnSequence you will just see the individual labels on this sequence =head2 Member functions of AlnSequence =over =item hard_link_AlnSequence &Wise2::AlnSequence::hard_link_AlnSequence(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [AlnSequence *] Return [UNKN ] Undocumented return value [AlnSequence *] =item alloc &Wise2::AlnSequence::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [AlnSequence *] =item set_start &Wise2::AlnSequence::set_start(obj,start) Replace member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnSequence *] Argument start [OWNER] New value of the variable [AlnUnit *] Return [SOFT ] member variable start [boolean] =item start &Wise2::AlnSequence::start(obj) Access member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnSequence *] Return [SOFT ] member variable start [AlnUnit *] =item set_data_type &Wise2::AlnSequence::set_data_type(obj,data_type) Replace member variable data_type For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnSequence *] Argument data_type [OWNER] New value of the variable [int] Return [SOFT ] member variable data_type [boolean] =item data_type &Wise2::AlnSequence::data_type(obj) Access member variable data_type For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnSequence *] Return [SOFT ] member variable data_type [int] =item set_data &Wise2::AlnSequence::set_data(obj,data) Replace member variable data For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnSequence *] Argument data [OWNER] New value of the variable [void *] Return [SOFT ] member variable data [boolean] =item data &Wise2::AlnSequence::data(obj) Access member variable data For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnSequence *] Return [SOFT ] member variable data [void *] =item set_bio_start &Wise2::AlnSequence::set_bio_start(obj,bio_start) Replace member variable bio_start For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnSequence *] Argument bio_start [OWNER] New value of the variable [int] Return [SOFT ] member variable bio_start [boolean] =item bio_start &Wise2::AlnSequence::bio_start(obj) Access member variable bio_start For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnSequence *] Return [SOFT ] member variable bio_start [int] =item set_bio_end &Wise2::AlnSequence::set_bio_end(obj,bio_end) Replace member variable bio_end For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnSequence *] Argument bio_end [OWNER] New value of the variable [int] Return [SOFT ] member variable bio_end [boolean] =item bio_end &Wise2::AlnSequence::bio_end(obj) Access member variable bio_end For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnSequence *] Return [SOFT ] member variable bio_end [int] =back wise-2.4.1/src/dynlibsrc/aln.tex0000644000175000001440000001250410670453712016134 0ustar philippusers\section{aln} \label{module_aln} This module contains the following objects \begin{itemize} \item \ref{object_AlnBlock} AlnBlock \item \ref{object_AlnColumn} AlnColumn \item \ref{object_AlnUnit} AlnUnit \item \ref{object_AlnSequence} AlnSequence \end{itemize} \subsection{Object AlnBlock} \label{object_AlnBlock} The AlnBlock object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{start} Type [AlnColumn * : Scalar] the first AlnColumn in the alignment \item{seq} Type [AlnSequence ** : List] a list of AlnSequences in the alignment \item{length} Type [int : Scalar] not used \item{score} Type [int : Scalar] not used \end{description} AlnBlock is the main representation of alignments from Dynamite. Each AlnBlock represents any number of 'sequences', of any type, which share things in common. The alignment is represented by a series of /AlnColumns (linked list) in which each AlnColumn has a series of AlnUnits, each Unit being a start/end/text_label triple. Alternatively, one can see each sequence in isolation, and not ask what it is aligned to, but rather what labels it has on it. Member functions of AlnBlock \subsubsection{dump_ascii_AlnBlock} \begin{description} \item[External C] {\tt Wise2_dump_ascii_AlnBlock (alb,ofp)} \item[Perl] {\tt &Wise2::AlnBlock::dump_ascii_AlnBlock (alb,ofp)} \item[Perl-OOP call] {\tt $obj->dump_ascii_AlnBlock(ofp)} \end{description} Arguments \begin{description} \item[alb] [UNKN ] AlnBlock to dump [AlnBlock *] \item[ofp] [UNKN ] File stream to dump to [FILE *] \item[returns] Nothing - no return value \end{description} Dumps the alignment in rereadable ascii form. Not really for human consumption \subsection{Object AlnColumn} \label{object_AlnColumn} The AlnColumn object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{alu} Type [AlnUnit ** : List] list of the AlnUnits in this column \item{next} Type [AlnColumn * : Scalar] the next AlnColumn in this block \end{description} This is a coupling of AlnUnits from different sequences. Each AlnUnit is meant to represent *the equivalent* piece of biological information in some sense (ie, they are alignmed), even though quite possibly they are very different types of information Member functions of AlnColumn \subsubsection{at_end_AlnColumn} \begin{description} \item[External C] {\tt Wise2_at_end_AlnColumn (alc)} \item[Perl] {\tt &Wise2::AlnColumn::at_end (alc)} \item[Perl-OOP call] {\tt $obj->at_end()} \end{description} Arguments \begin{description} \item[alc] [READ ] AlnColumn [AlnColumn *] \item[returns] [UNKN ] Undocumented return value [boolean] \end{description} This tells you whether the AlnColumn is at the end without passing NULL's around \subsection{Object AlnUnit} \label{object_AlnUnit} The AlnUnit object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{start} Type [int : Scalar] start position in the sequence \item{end} Type [int : Scalar] end position in the sequence \item{label} Type [int : Scalar] not used \item{text_label} Type [char * : Scalar] text label of this position \item{next} Type [AlnUnit * : Scalar] next AlnUnit in this sequence \item{score[AlnUnitSCORENUMBER]} Type [int : Scalar] a series of scores for this position. \item{in_column} Type [boolean : Scalar] not used \item{seq} Type [AlnSequence * : Scalar] No documentation \end{description} This is the basic unit of the label alignment. It describes a single mark-up over one sequence: being a start, an end and a text_label. Member functions of AlnUnit \subsubsection{bio_start_AlnUnit} \begin{description} \item[External C] {\tt Wise2_bio_start_AlnUnit (alu)} \item[Perl] {\tt &Wise2::AlnUnit::bio_start (alu)} \item[Perl-OOP call] {\tt $obj->bio_start()} \end{description} Arguments \begin{description} \item[alu] [UNKN ] Undocumented argument [AlnUnit *] \item[returns] [UNKN ] Undocumented return value [int] \end{description} Tells the bio-coordinate of the start point of this alnunit \subsubsection{bio_end_AlnUnit} \begin{description} \item[External C] {\tt Wise2_bio_end_AlnUnit (alu)} \item[Perl] {\tt &Wise2::AlnUnit::bio_end (alu)} \item[Perl-OOP call] {\tt $obj->bio_end()} \end{description} Arguments \begin{description} \item[alu] [UNKN ] Undocumented argument [AlnUnit *] \item[returns] [UNKN ] Undocumented return value [int] \end{description} Tells the bio-coordinate of the end point of this alnunit \subsection{Object AlnSequence} \label{object_AlnSequence} The AlnSequence object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{start} Type [AlnUnit * : Scalar] the first AlnUnit of this sequence \item{data_type} Type [int : Scalar] not used \item{data} Type [void * : Scalar] not used - don't use! \item{bio_start} Type [int : Scalar] start of this sequence in its 'bio' coordinates \item{bio_end} Type [int : Scalar] end of this sequence in its 'bio' coordinates \end{description} Each Sequence in an AlnBlock is represented by one of these, and in many ways this is an orthogonal way of looking at the alignment than the AlnColumns. If you look at the alignment from one AlnSequence you will just see the individual labels on this sequence Member functions of AlnSequence wise-2.4.1/src/dynlibsrc/genomicregion_api.h0000644000175000001440000001743410670453712020476 0ustar philippusers /* Functions that create, manipulate or act on GenomicRegion * * Wise2_new_GenomicRegion * Wise2_read_EMBL_GenomicRegion_file * Wise2_read_EMBL_GenomicRegion * Wise2_add_Gene_to_GenomicRegion * Wise2_show_ace_GenomicRegion * Wise2_show_pretty_GenomicRegion * Wise2_write_Diana_FT_GenomicRegion * Wise2_write_Embl_FT_GenomicRegion * Wise2_hard_link_GenomicRegion * Wise2_GenomicRegion_alloc_std * Wise2_access_gene_GenomicRegion * Wise2_length_gene_GenomicRegion * Wise2_flush_GenomicRegion * Wise2_add_GenomicRegion * Wise2_replace_genomic_GenomicRegion * Wise2_access_genomic_GenomicRegion * Wise2_free_GenomicRegion [destructor] * */ /* API for object GenomicRegion */ /* Function: Wise2_new_GenomicRegion(gen) * * Descrip: makes a genomicregion from a genomic sequence * * * Arg: gen Undocumented argument [Wise2_Genomic *] * * Returns Undocumented return value [Wise2_GenomicRegion *] * */ Wise2_GenomicRegion * Wise2_new_GenomicRegion( Wise2_Genomic * gen); /* Function: Wise2_read_EMBL_GenomicRegion_file(filename) * * Descrip: Reads in both EMBL sequence and features * * * Arg: filename Undocumented argument [char *] * * Returns Undocumented return value [Wise2_GenomicRegion *] * */ Wise2_GenomicRegion * Wise2_read_EMBL_GenomicRegion_file( char * filename); /* Function: Wise2_read_EMBL_GenomicRegion(ifp) * * Descrip: Reads in both EMBL sequence and features * * * Arg: ifp Undocumented argument [FILE *] * * Returns Undocumented return value [Wise2_GenomicRegion *] * */ Wise2_GenomicRegion * Wise2_read_EMBL_GenomicRegion( FILE * ifp); /* Function: Wise2_add_Gene_to_GenomicRegion(gr,gene) * * Descrip: adds a Gene to this GenomicRegion, making * sure that it parent/son relationship is ok * * * Arg: gr GenomicRegion to be added to [Wise2_GenomicRegion *] * Arg: gene Gene to be added [Wise2_Gene *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_Gene_to_GenomicRegion( Wise2_GenomicRegion * gr,Wise2_Gene * gene); /* Function: Wise2_show_ace_GenomicRegion(gr,seq_name,ofp) * * Descrip: shows ACeDB subsequence source. * * Assummes * a only one transcript per gene * b only cds exons are used * * * Arg: gr Undocumented argument [Wise2_GenomicRegion *] * Arg: seq_name Undocumented argument [char *] * Arg: ofp Undocumented argument [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_show_ace_GenomicRegion( Wise2_GenomicRegion * gr,char * seq_name,FILE * ofp); /* Function: Wise2_show_pretty_GenomicRegion(gr,show_supporting,ofp) * * Descrip: No Description * * Arg: gr Undocumented argument [Wise2_GenomicRegion *] * Arg: show_supporting Undocumented argument [boolean] * Arg: ofp Undocumented argument [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_show_pretty_GenomicRegion( Wise2_GenomicRegion * gr,boolean show_supporting,FILE * ofp); /* Function: Wise2_write_Diana_FT_GenomicRegion(gr,ofp) * * Descrip: Writes Embl feature table for diana use. Does assumme that * there is only one transcript per gene and only * cds exons are used * * Output like * * FT misc_feature join(100..200) * * * Arg: gr Undocumented argument [Wise2_GenomicRegion *] * Arg: ofp Undocumented argument [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_write_Diana_FT_GenomicRegion( Wise2_GenomicRegion * gr,FILE * ofp); /* Function: Wise2_write_Embl_FT_GenomicRegion(gr,ofp) * * Descrip: Writes Embl feature table. Does assumme that * there is only one transcript per gene and only * cds exons are used * * Output like * * FT CDS join(100..200) * * * Arg: gr Undocumented argument [Wise2_GenomicRegion *] * Arg: ofp Undocumented argument [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_write_Embl_FT_GenomicRegion( Wise2_GenomicRegion * gr,FILE * ofp); /* Function: Wise2_hard_link_GenomicRegion(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_GenomicRegion *] * * Returns Undocumented return value [Wise2_GenomicRegion *] * */ Wise2_GenomicRegion * Wise2_hard_link_GenomicRegion( Wise2_GenomicRegion * obj); /* Function: Wise2_GenomicRegion_alloc_std(void) * * Descrip: Equivalent to GenomicRegion_alloc_len(GenomicRegionLISTLENGTH) * * * * Returns Undocumented return value [Wise2_GenomicRegion *] * */ Wise2_GenomicRegion * Wise2_GenomicRegion_alloc_std(); /* Function: Wise2_access_gene_GenomicRegion(obj,i) * * Descrip: Access members stored in the gene list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_GenomicRegion *] * Arg: i Position in the list [int] * * Returns Element of the list [Wise2_Gene *] * */ Wise2_Gene * Wise2_access_gene_GenomicRegion( Wise2_GenomicRegion * obj,int i); /* Function: Wise2_length_gene_GenomicRegion(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj Object holding the list [Wise2_GenomicRegion *] * * Returns length of the list [int] * */ int Wise2_length_gene_GenomicRegion( Wise2_GenomicRegion * obj); /* Function: Wise2_flush_GenomicRegion(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj Object which contains the list [Wise2_GenomicRegion *] * * Returns Undocumented return value [int] * */ int Wise2_flush_GenomicRegion( Wise2_GenomicRegion * obj); /* Function: Wise2_add_GenomicRegion(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj Object which contains the list [Wise2_GenomicRegion *] * Arg: add Object to add to the list [Wise2_Gene *] * * Returns Undocumented return value [boolean] * */ boolean Wise2_add_GenomicRegion( Wise2_GenomicRegion * obj,Wise2_Gene * add); /* Function: Wise2_replace_genomic_GenomicRegion(obj,genomic) * * Descrip: Replace member variable genomic * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GenomicRegion *] * Arg: genomic New value of the variable [Wise2_Genomic *] * * Returns member variable genomic [boolean] * */ boolean Wise2_replace_genomic_GenomicRegion( Wise2_GenomicRegion * obj,Wise2_Genomic * genomic); /* Function: Wise2_access_genomic_GenomicRegion(obj) * * Descrip: Access member variable genomic * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_GenomicRegion *] * * Returns member variable genomic [Wise2_Genomic *] * */ Wise2_Genomic * Wise2_access_genomic_GenomicRegion( Wise2_GenomicRegion * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_GenomicRegion(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_GenomicRegion *] * * Returns Undocumented return value [Wise2_GenomicRegion *] * */ Wise2_GenomicRegion * Wise2_free_GenomicRegion( Wise2_GenomicRegion * obj); wise-2.4.1/src/dynlibsrc/genomicregion_api.t0000644000175000001440000000007110670453712020477 0ustar philippuserstypedef struct Wise2_GenomicRegion Wise2_GenomicRegion; wise-2.4.1/src/dynlibsrc/probability.typemap0000644000175000001440000000000010670453712020545 0ustar philippuserswise-2.4.1/src/dynlibsrc/sequence_codon.dy0000644000175000001440000001146607313404542020173 0ustar philippusers %{ #include "sequence.h" #include "codon.h" %} api func reverse_complement_Sequence func magic_trunc_Sequence func translate_Sequence endapi %{ #include "sequence_codon.h" %func This both complements and reverses a sequence, - a common wish! The start/end are correct with respect to the start/end of the sequence (ie start = end, end = start). %arg seq r Sequence to that is used to reverse (makes a new Sequence) return o new Sequence which is reversed %% Sequence * reverse_complement_Sequence(Sequence * seq) { Sequence * out; int i; int j; if( is_dna_Sequence(seq) != TRUE ) { warn("Cannot reverse complement non-DNA sequence... type is %s",Sequence_type_to_string(seq->type)); return NULL; } out = Sequence_from_static_memory(seq->name,seq->seq); for(j=0,i=seq->len-1;i >= 0;i--,j++) { out->seq[j] = char_complement_base(seq->seq[i]); /*fprintf(stderr,"In position %d placed %c from %c\n",j,out->seq[j],seq->seq[i]);*/ } out->len = strlen(seq->seq); out->offset = seq->end; out->end = seq->offset; out->type = seq->type; return out; } %func Clever function for dna sequences. When start < end, truncates normally when start > end, truncates end,start and then reverse complements. ie. If you have a coordinate system where reverse sequences are labelled in reverse start/end way, then this routine produces the correct sequence. %arg seq r sequence that is the source to be truncated start r start point end r end point return o new Sequence which is truncated/reversed %% Sequence * magic_trunc_Sequence(Sequence * seq,int start,int end) { Sequence * temp; Sequence * out; if( is_dna_Sequence(seq) == FALSE) { warn("Cannot magic truncate on a non DNA sequence... type is %s",Sequence_type_to_string(seq->type)); return NULL; } if( start < 0 || end < 0 ) { warn("Attempting a magic truncation on indices which are less than zero [%d:%d]. Clearly impossible",start,end); return NULL; } if( start < end ) { return trunc_Sequence(seq,start,end); } else { temp = trunc_Sequence(seq,end,start); if( temp == NULL ) { warn("Unable to truncate sequence"); return NULL; } out = reverse_complement_Sequence(temp); free_Sequence(temp); return out; } } %func This translates a DNA sequence to a protein. It assummes that it starts at first residue (use trunc_Sequence to chop a sequence up). %simple translate %arg dna r DNA sequence to be translated ct r Codon table to do codon->aa mapping return o new protein sequence %% Sequence * translate_Sequence(Sequence * dna,CodonTable * ct) { Sequence * out; int i; int j; int len; char * seq; char * name; char buffer[512]; if( is_dna_Sequence(dna) == FALSE) { warn("Trying to make a translation from a non DNA sequence... type is [%s]",Sequence_type_to_string(dna->type)); return NULL; } len = dna->len/3 + 1; seq = ckcalloc(len,sizeof(char)); sprintf(buffer,"%s.tr",dna->name == NULL ? "NoNameDNASeq" : dna->name); name = stringalloc(buffer); out = Sequence_from_dynamic_memory(name,seq); for(i=0,j=0;ilen-3;i+=3,j++) { out->seq[j] = aminoacid_from_seq(ct,dna->seq+i); } out->seq[j] = '\0'; out->type = SEQUENCE_PROTEIN; out->len = strlen(out->seq); return out; } %func This a) sees how many non ATGCN characters there are in Seq b) If the level is below fraction a) flips non ATGC chars to N b) writes number of conversions to number_of_conver c) returns TRUE c) else returns FALSE fraction of 0.0 means completely intolerant of errors fraction of 1.0 means completely tolerant of errors %simple force_to_dna %arg seq rw sequence object read and converted fraction r number 0..1 for tolerance of conversion number_of_conver wN number of conversions actually made return r TRUE for conversion to DNA, FALSE if not %% boolean force_to_dna_Sequence(Sequence * seq,double fraction,int * number_of_conver) { int count =0; int i; if( seq == NULL ) { warn("Attempting to force a sequence with no Sequence object!\n"); return FALSE; } if( seq->len <= 0 ) { warn("Trying to make a sequence with a length of %d. Bad news!",seq->len); return FALSE; } for(i=0;ilen;i++) { /* if it is lower case, uppercase it! */ seq->seq[i] = (char)toupper((int)seq->seq[i]); if( !is_valid_base_char(seq->seq[i]) ) { count++; } } if( ((double)count/(double)seq->len) < fraction ) { seq->type = SEQUENCE_DNA; if( count != 0 ) { for(i=0;ilen;i++) { if( !is_valid_base_char(seq->seq[i]) ) { seq->seq[i] = 'N'; } } } if( number_of_conver != NULL ) { *number_of_conver = count; } return TRUE; } else { if( number_of_conver != NULL ) { *number_of_conver = count; } return FALSE; } } wise-2.4.1/src/dynlibsrc/sequence_codon.xs0000644000175000001440000000077510670453713020216 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2 Wise2_Sequence * reverse_complement_Sequence(seq) Wise2_Sequence * seq CODE: RETVAL = Wise2_reverse_complement_Sequence(seq); OUTPUT: RETVAL Wise2_Sequence * magic_trunc_Sequence(seq,start,end) Wise2_Sequence * seq int start int end CODE: RETVAL = Wise2_magic_trunc_Sequence(seq,start,end); OUTPUT: RETVAL Wise2_Sequence * translate(dna,ct) Wise2_Sequence * dna Wise2_CodonTable * ct CODE: RETVAL = Wise2_translate_Sequence(dna,ct); OUTPUT: RETVAL wise-2.4.1/src/dynlibsrc/shadowseqindex.dy0000644000175000001440000002331107644504776020240 0ustar philippusers %{ #include "seqlookup.h" #include "shadowseq.h" #include "genericindexresult.h" #include "singlenumberspace.h" #include "intallocator.h" #include "staticseq.h" #define SHADOW_ARRAYSEQL_BASIC 4 #define SHADOW_ARRAYSEQL_LINEAR 16 #define ShadowSequenceIndexLISTLENGTH 1024 #define SHADOW_TYPE int typedef struct Wise2_ShadowArraySeqHead { SHADOW_TYPE * seqdb_pos; int current_pos; int max; } ShadowArraySeqHead; %} struct ShadowSequenceIndex ShadowArraySeqHead ** array int array_len ShadowSequence ** shadow !list SingleNumberSpace * space int shadow_len int shadow_error IntAllocatorSet * ias StaticSeqHolder * ssh %{ #include "shadowseqindex.h" typedef struct ShadowSeqClient_struct { GenericIndexResult result; SeqLookupResultInterface interface; ShadowSequenceIndex * index; } ShadowSequenceClient; static ShadowSequenceClient * ShadowSequenceClient_alloc(void) { ShadowSequenceClient * out; out = malloc(sizeof(ShadowSequenceClient)); return out; } %func Provides a SeqLookupInterface, the common runtime plug-in for indexers using a ShadowSequenceIndex %% SeqLookupInterface * new_ShadowSequenceIndex_SeqLookupInterface(int shadow_len,int has_maxlen,int maxlen,int shadow_error) { SeqLookupInterface * out; ShadowSequenceIndex * in; in = new_ShadowSequenceIndex(26*26*26*26*26,shadow_len,has_maxlen,maxlen,shadow_error); out = SeqLookupInterface_alloc_std(); out->get_client = get_client_interface_ShadowSequenceIndex; out->add_seq = add_seq_interface_ShadowSequenceIndex; out->free_data = free_interface_ShadowSequenceIndex; out->lookup_array_head = NULL; out->data = (void*) in; return out; } %func gets client interface %% SeqLookupClientInterface * get_client_interface_ShadowSequenceIndex(void* data) { ShadowSequenceIndex * index = (ShadowSequenceIndex*) data; SeqLookupClientInterface * slci; ShadowSequenceClient * pcl; pcl = ShadowSequenceClient_alloc(); pcl->result.result = calloc(64,sizeof(SeqLookupResultStruct)); pcl->result.max_len = 64; pcl->result.len = 0; pcl->interface.next = next_interface_GenericIndexResult; pcl->interface.is_more = is_more_interface_GenericIndexResult; pcl->interface.free_data = free_noop_GenericIndexResult; pcl->interface.data = (void*) &(pcl->result); pcl->index = index; slci = SeqLookupClientInterface_alloc(); slci->lookup = lookup_interface_ShadowSequenceClient; slci->is_populated = is_populated_interface_ShadowSequenceClient; slci->free_data = free_interface_ShadowSequenceClient; slci->data = (void*) pcl; return slci; } %func For lookup interface, provides a result %% SeqLookupResultInterface * lookup_interface_ShadowSequenceClient(void * data,int seq_number) { ShadowSequenceClient * cli= (ShadowSequenceClient*) data; ShadowSequenceIndex * in = cli->index; /* reset pointers */ cli->result.current_pos = 0; cli->result.len = 0; if( lookup_result_ShadowSeq(&cli->result,in,seq_number) == FALSE ) { return NULL; } return &cli->interface; } %func populated function for interface %% boolean is_populated_interface_ShadowSequenceClient(void * data,int seq_number) { ShadowSequenceClient * client = (ShadowSequenceClient*) data; if( client->index->array[seq_number] != NULL ) { return TRUE; } else { return FALSE; } } %func add function for interface %% boolean add_seq_interface_ShadowSequenceIndex(void * data,Sequence * seq,SeqLookupLoadPara * para) { ShadowSequenceIndex * in = (ShadowSequenceIndex*) data; return add_Sequence_ShadowSequenceIndex(in,seq,in->shadow_len); } %func for interface, frees index %% void free_interface_ShadowSequenceIndex(void * data) { ShadowSequenceIndex * in = (ShadowSequenceIndex*) data; free_ShadowSequenceIndex(in); } %func Frees the client data %% void free_interface_ShadowSequenceClient(void * data) { ShadowSequenceClient * cli = (ShadowSequenceClient *)data; free(cli->result.result); free(cli); } %func handles the lookup and storage for a seq_no lookup %% boolean lookup_result_ShadowSeq(GenericIndexResult * res,ShadowSequenceIndex * in,int seq_no) { int i; SingleNumberSequence * sns; int pos; assert(res); assert(in); if( in->array[seq_no] == NULL ) { return FALSE; } for(i=0;iarray[seq_no]->current_pos;i++) { pos = in->array[seq_no]->seqdb_pos[i]; sns = lookup_ShadowSequence_SingleNumberSpace(in->space,pos); add_result_GenericIndexResult_ShadowSeq(res,sns->seq,pos-sns->start); } return TRUE; } %func adds a particular shadow sequence position, unrolling shadowed sequences into the result %% void add_result_GenericIndexResult_ShadowSeq(GenericIndexResult * res,ShadowSequence * seq,int pos) { int i; assert(res); assert(seq); add_GenericIndexResult(res,seq->seq,pos); for(i=0;ilen;i++) { if( pos >= seq->region[i]->start_seq && pos < seq->region[i]->start_seq + seq->region[i]->len ) { add_GenericIndexResult(res,seq->region[i]->seq,seq->region[i]->start_shadow + pos - seq->region[i]->start_seq); } } } %func Dumps information about shadows %% void dump_shadow_ShadowSequenceIndex(ShadowSequenceIndex * in,FILE * ofp) { int i; for(i=0;ilen;i++) { dump_ShadowSequence(in->shadow[i],ofp); } } %func Dumps useful information out of shadow sequence array %% void dump_stats_ShadowSequenceIndex(ShadowSequenceIndex * in,FILE * ofp) { int i; int j; int total_index = 0; int total_shadow = 0; int total_array = 0; int total_seq = 0; int total_head = 0; for(i=0;iarray_len;i++) { if( in->array[i] != NULL ) { total_index += in->array[i]->current_pos; total_array += in->array[i]->max; total_head++; } } for(i=0;ilen;i++) { total_seq += in->shadow[i]->seq->len; for(j=0;jshadow[i]->len;j++) { total_shadow += in->shadow[i]->region[j]->len; } } fprintf(ofp,"Arrayed %d, Shadowed %d (Compression ratio %.2f%%)\n", total_index, total_shadow, (double)(total_shadow)*100/(double)(total_shadow+total_index)); fprintf(ofp,"Occupied Array Memory %d [%.2f Mbytes]\n", total_index,((total_index/1000000.0)*sizeof(SHADOW_TYPE))); fprintf(ofp,"Allocated Array memory %d [%.2fMbytes] [%d %%]\n", total_array,((total_array/1000000.0)*sizeof(SHADOW_TYPE)), total_index*100/total_array); fprintf(ofp,"Head memory %d [%.2f Mbytes]\n",total_head,(total_head*sizeof(ShadowArraySeqHead))/100000); fprintf(ofp,"Sequence Memory %d [%.2f Mbytes]\n", total_seq,(total_seq/1000000.0)*sizeof(char)); show_allocator_status_IntAllocatorSet(in->ias,ofp); } %func Adds a Sequence to a ShadowIndex, placing shadowed regions correctly away %% boolean add_Sequence_ShadowSequenceIndex(ShadowSequenceIndex * in,Sequence * seq,int min_ext) { int i; int j; int no; int temp; ShadowSequence * shadow = NULL; int is_dirty = 0; int start_position; SingleNumberSequence * sns; assert(in); assert(seq); /* reap memory into the static system */ seq = new_Sequence_StaticSeqHolder(in->ssh,seq); shadow = new_ShadowSequence(seq); add_ShadowSequenceIndex(in,shadow); start_position = add_ShadowSequence_SingleNumberSpace(in->space,shadow); for(i=0;ilen-5;) { no = seq_number_aa_5mer(seq->seq+i); if( in->array[no] != NULL ) { temp = 0; for(j=0;jarray[no]->current_pos;j++) { sns = lookup_ShadowSequence_SingleNumberSpace(in->space,in->array[no]->seqdb_pos[j]); /* we can make a hard assumption that sns is not NULL, but just to catch errors a little more explicity... */ assert(sns); if( sns->seq->dirty == 0 && sns->seq != shadow && (temp = add_if_possible_ShadowSequence(sns->seq,seq,min_ext,in->array[no]->seqdb_pos[j]-sns->start,i,in->shadow_error)) != 0 ) { i = temp; break; } } if( temp != 0 ) { is_dirty = 1; continue; } } if( in->array[no] == NULL ) { in->array[no] = new_ShadowArraySeqHead(in->ias); } add_ShadowArraySeqHead(in->ias,in->array[no],start_position+i); i++; } shadow->dirty = is_dirty; return TRUE; } %func New ShadowSequenceIndex %% ShadowSequenceIndex * new_ShadowSequenceIndex(int len,int shadow_len,int has_maxlen,int maxlen,int shadow_error) { int i; ShadowSequenceIndex * out; out = ShadowSequenceIndex_alloc_std(); out->array = calloc(len,sizeof(ShadowArraySeqHead*)); assert(out->array); for(i=0;iarray[i] = NULL; } out->array_len = len; out->shadow_len = len; out->space = new_SingleNumberSpace(has_maxlen,maxlen); out->shadow_error = shadow_error; out->ias = new_IntAllocatorSet(65); out->ssh = new_StaticSeqHolder(); return out; } %func Adds a sequence/pos pair to an ArrayHead %% boolean add_ShadowArraySeqHead(IntAllocatorSet * ias,ShadowArraySeqHead * h,int seqdb_pos) { if( h->current_pos >= h->max ) { if( h->max < SHADOW_ARRAYSEQL_LINEAR ) { h->seqdb_pos = realloc_intarray_IntAllocatorSet(ias,h->seqdb_pos,h->max,(h->max*2)); h->max = h->max*2; } else { h->seqdb_pos = realloc_intarray_IntAllocatorSet(ias,h->seqdb_pos,h->max,h->max + SHADOW_ARRAYSEQL_LINEAR); h->max = h->max + SHADOW_ARRAYSEQL_LINEAR; } if( h->seqdb_pos == NULL ) { fatal("ArraySeqLookup realloc failed trying for %d positions\n",h->max); } /* fprintf(stderr,"... extended to %d\n",h->max); */ } h->seqdb_pos[h->current_pos] = seqdb_pos; h->current_pos++; return TRUE; } %func Builds a new ArraySeqHead structure %% ShadowArraySeqHead * new_ShadowArraySeqHead(IntAllocatorSet * ias) { ShadowArraySeqHead * out; out = malloc(sizeof(ShadowArraySeqHead)); out->seqdb_pos = alloc_intarray_IntAllocatorSet(ias,SHADOW_ARRAYSEQL_BASIC); out->max = SHADOW_ARRAYSEQL_BASIC; out->current_pos = 0; return out; } %} wise-2.4.1/src/dynlibsrc/genomicregion.typemap0000644000175000001440000000041010670453712021057 0ustar philippusers TYPEMAP Wise2_GenomicRegion * T_Wise2_GenomicRegion INPUT T_Wise2_GenomicRegion $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_GenomicRegion *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_GenomicRegion sv_setref_pv($arg, "Wise2::GenomicRegion", (void*) $var); wise-2.4.1/src/dynlibsrc/probability.c0000644000175000001440000003574510670453712017340 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "probability.h" /* Function: Probability_from_average_state_occupancy(length) * * Descrip: for single state (exponetial decays) takes an average length * and converts that to a probability that will produce that * length (on average) for the state. NB... this *assumes* that * you want a single state exp decay. * * * Arg: length [UNKN ] average length of state [double] * * Return [UNKN ] Undocumented return value [Probability] * */ # line 44 "probability.dy" Probability Probability_from_average_state_occupancy(double length) { return 1 - (1.0 / length); } /* Function: state_occupancy_from_Probability(p) * * Descrip: If you have a single state then this will tak * the probability for the state->state transition and * give you back the average length in the state * * * Arg: p [UNKN ] probability of staying in the state [double] * * Return [UNKN ] Undocumented return value [double] * */ # line 56 "probability.dy" double state_occupancy_from_Probability(double p) { return 1 / (1-p); } /* Function: Probability_logsum(one,two) * * Descrip: gives back a score of the sum in * probability space of the two scores. * * This is the function verison of this * code, which is not efficient *at all* * * * Arg: one [UNKN ] Undocumented argument [Score] * Arg: two [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Score] * */ # line 68 "probability.dy" Score Probability_logsum(Score one,Score two) { return Probability2Score(Score2Probability(one) + Score2Probability(two)); } /* Function: Probability2Bits(p) * * Descrip: Gives back a Bits score for a probability * * * Arg: p [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [Bits] * */ # line 76 "probability.dy" Bits Probability2Bits(Probability p) { return Score2Bits(Probability2Score(p)); } /* Function: show_Score_array(s,len,ofp) * * Descrip: shows a score array as score, score ,score ...' * * * Arg: s [UNKN ] Score array [Score *] * Arg: len [UNKN ] length of array [int] * Arg: ofp [UNKN ] output filestream [FILE *] * */ # line 88 "probability.dy" void show_Score_array(Score * s,int len,FILE * ofp) { register int i; fprintf(ofp,"\"%d",s[0]); for(i=1;i= len ) { return FALSE; } if( is_double_string(runner,&p[no]) == FALSE ) { return FALSE; } } return TRUE; } /* Function: show_Probability_array(p,len,ofp) * * Descrip: shows a proability array in %f notation. * * * * Arg: p [UNKN ] probability array [Probability *] * Arg: len [UNKN ] length of proability array [int] * Arg: ofp [UNKN ] output filestream [FILE *] * */ # line 151 "probability.dy" void show_Probability_array(Probability * p,int len,FILE * ofp) { register int i; fprintf(ofp,"\"%f",p[0]); for(i=1;istate transition and * give you back the average length in the state * * * Arg: p [UNKN ] probability of staying in the state [double] * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_state_occupancy_from_Probability(double p); #define state_occupancy_from_Probability Wise2_state_occupancy_from_Probability /* Function: Probability_logsum(one,two) * * Descrip: gives back a score of the sum in * probability space of the two scores. * * This is the function verison of this * code, which is not efficient *at all* * * * Arg: one [UNKN ] Undocumented argument [Score] * Arg: two [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Score] * */ Score Wise2_Probability_logsum(Score one,Score two); #define Probability_logsum Wise2_Probability_logsum /* Function: Probability2Bits(p) * * Descrip: Gives back a Bits score for a probability * * * Arg: p [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [Bits] * */ Bits Wise2_Probability2Bits(Probability p); #define Probability2Bits Wise2_Probability2Bits /* Function: show_Score_array(s,len,ofp) * * Descrip: shows a score array as score, score ,score ...' * * * Arg: s [UNKN ] Score array [Score *] * Arg: len [UNKN ] length of array [int] * Arg: ofp [UNKN ] output filestream [FILE *] * */ void Wise2_show_Score_array(Score * s,int len,FILE * ofp); #define show_Score_array Wise2_show_Score_array /* Function: show_Probability_array_exp(p,len,ofp) * * Descrip: shows a proability array in scientific notation. * * * * Arg: p [UNKN ] probability array [Probability *] * Arg: len [UNKN ] length of proability array [int] * Arg: ofp [UNKN ] output filestream [FILE *] * */ void Wise2_show_Probability_array_exp(Probability * p,int len,FILE * ofp); #define show_Probability_array_exp Wise2_show_Probability_array_exp /* Function: read_Probability_array(p,len,start_of_array) * * Descrip: reads in a probability array of comma separated numbers. * It calls /is_double_string to test whether the numbers are * probabilities. It tries ito read in len numbers: if it runs out of * commad separated guys it returns FALSE * * * Arg: p [UNKN ] Undocumented argument [Probability *] * Arg: len [UNKN ] Undocumented argument [int] * Arg: start_of_array [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_read_Probability_array(Probability * p,int len,char * start_of_array); #define read_Probability_array Wise2_read_Probability_array /* Function: show_Probability_array(p,len,ofp) * * Descrip: shows a proability array in %f notation. * * * * Arg: p [UNKN ] probability array [Probability *] * Arg: len [UNKN ] length of proability array [int] * Arg: ofp [UNKN ] output filestream [FILE *] * */ void Wise2_show_Probability_array(Probability * p,int len,FILE * ofp); #define show_Probability_array Wise2_show_Probability_array /* Function: sum_Probability_array(p,len) * * Descrip: adds up the probability array given * * * Arg: p [UNKN ] probability array [Probability *] * Arg: len [UNKN ] length of array [int] * * Return [UNKN ] Undocumented return value [Probability] * */ Probability Wise2_sum_Probability_array(Probability * p,int len); #define sum_Probability_array Wise2_sum_Probability_array /* Function: set_Probability_array(set,p,len) * * Descrip: Sets the probability array to p * * * Arg: set [UNKN ] probability array to set [Probability *] * Arg: p [UNKN ] probability to set it to [Probability] * Arg: len [UNKN ] length of probability array [int] * * Return [UNKN ] Undocumented return value [Probability *] * */ Probability * Wise2_set_Probability_array(Probability * set,Probability p,int len); #define set_Probability_array Wise2_set_Probability_array /* Function: Probability2Score_move(from,to,len) * * Descrip: moves the probability array from to the (same length) * score array to going through Probability2Score function * * * Arg: from [UNKN ] probability array to get the numbers [Probability *] * Arg: to [UNKN ] Score array to put the numbers [Score *] * Arg: len [UNKN ] length of arrays [int] * * Return [UNKN ] Undocumented return value [Score *] * */ Score * Wise2_Probability2Score_move(Probability * from,Score * to,int len); #define Probability2Score_move Wise2_Probability2Score_move /* Function: Probability_move(from,to,len) * * Descrip: moves from to to * * * Arg: from [UNKN ] probability array with the numbers [const Probability *] * Arg: to [UNKN ] probability array to be written into [Probability *] * Arg: len [UNKN ] length [int] * * Return [UNKN ] Undocumented return value [Probability *] * */ Probability * Wise2_Probability_move(const Probability * from,Probability * to,int len); #define Probability_move Wise2_Probability_move /* Function: Score_move(from,to,len) * * Descrip: moves from to to * * * Arg: from [UNKN ] Score array with the numbers [const Score *] * Arg: to [UNKN ] Score array to be written into [Score *] * Arg: len [UNKN ] length [int] * * Return [UNKN ] Undocumented return value [Score *] * */ Score * Wise2_Score_move(const Score * from,Score * to,int len); #define Score_move Wise2_Score_move /* Function: renormalise_Probability_array(array,len) * * Descrip: Reasonably stupid function. Sums up probability array * and then simply uses a linear renormalisation to get to the * array adding to 1.0 * * returns the difference between the original sum and 1,0 * * * Arg: array [UNKN ] array to renormalise [Probability *] * Arg: len [UNKN ] length of array [int] * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_renormalise_Probability_array(Probability * array,int len); #define renormalise_Probability_array Wise2_renormalise_Probability_array /* Function: Probability_array_divide(to,top,bottem,len) * * Descrip: divides one prob array by another pairwise * * * Arg: to [UNKN ] probability array to be written into [Probability *] * Arg: top [UNKN ] probability array to be divided [const Probability *] * Arg: bottem [UNKN ] probability array which divides [const Probability *] * Arg: len [UNKN ] length [int] * * Return [UNKN ] Undocumented return value [Probability *] * */ Probability * Wise2_Probability_array_divide(Probability * to,const Probability * top,const Probability * bottem,int len); #define Probability_array_divide Wise2_Probability_array_divide /* Function: Probability_array_multiply(to,top,bottem,len) * * Descrip: multiplies one prob array by another pairwise * * * Arg: to [UNKN ] probability array to be written into [Probability *] * Arg: top [UNKN ] probability array to be mulitpled [const Probability *] * Arg: bottem [UNKN ] probability array to be mulitpled [const Probability *] * Arg: len [UNKN ] length [int] * * Return [UNKN ] Undocumented return value [Probability *] * */ Probability * Wise2_Probability_array_multiply(Probability * to,const Probability * top,const Probability * bottem,int len); #define Probability_array_multiply Wise2_Probability_array_multiply /* Function: Probability_array_add(to,top,bottem,len) * * Descrip: sums one prob array with another pairwise * * * Arg: to [UNKN ] probability array to be written into [Probability *] * Arg: top [UNKN ] probability array to be summed [const Probability *] * Arg: bottem [UNKN ] probability array to be summed [const Probability *] * Arg: len [UNKN ] length [int] * * Return [UNKN ] Undocumented return value [Probability *] * */ Probability * Wise2_Probability_array_add(Probability * to,const Probability * top,const Probability * bottem,int len); #define Probability_array_add Wise2_Probability_array_add /* Function: Probability_array_subtract(to,top,bottem,len) * * Descrip: subtracts one prob array by another pairwise * * * Arg: to [UNKN ] probability array to be written into [Probability *] * Arg: top [UNKN ] probability array to be subtracted [const Probability *] * Arg: bottem [UNKN ] probability array that subtracts [const Probability *] * Arg: len [UNKN ] length [int] * * Return [UNKN ] Undocumented return value [Probability *] * */ Probability * Wise2_Probability_array_subtract(Probability * to,const Probability * top,const Probability * bottem,int len); #define Probability_array_subtract Wise2_Probability_array_subtract /* Function: Score_array_add(to,top,bottem,len) * * Descrip: sums one score array with another pairwise * * * Arg: to [UNKN ] score array to be written into [Score *] * Arg: top [UNKN ] score array to be summed [Score *] * Arg: bottem [UNKN ] score array to be summed [Score *] * Arg: len [UNKN ] length [int] * * Return [UNKN ] Undocumented return value [Score *] * */ Score * Wise2_Score_array_add(Score * to,Score * top,Score * bottem,int len); #define Score_array_add Wise2_Score_array_add /* Function: Score_array_subtract(to,top,bottem,len) * * Descrip: subtracts one score array by another pairwise * * * Arg: to [UNKN ] score array to be written into [Score *] * Arg: top [UNKN ] score array to be subtracted [const Score *] * Arg: bottem [UNKN ] score array that subtracts [const Score *] * Arg: len [UNKN ] length [int] * * Return [UNKN ] Undocumented return value [Score *] * */ Score * Wise2_Score_array_subtract(Score * to,const Score * top,const Score * bottem,int len); #define Score_array_subtract Wise2_Score_array_subtract /* Function: Score_Probability_sum(one,two) * * Descrip: Badly implemented sum in probability * space * * * Arg: one [UNKN ] Undocumented argument [Score] * Arg: two [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Score] * */ Score Wise2_Score_Probability_sum(Score one,Score two); #define Score_Probability_sum Wise2_Score_Probability_sum /* Function: Probability2Score(p) * * Descrip: maps probabilities to scores. Deals * sensibly with 0's. * * * Arg: p [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [Score] * */ Score Wise2_Probability2Score(Probability p); #define Probability2Score Wise2_Probability2Score /* Function: halfbit2Probability(half_bit) * * Descrip: maps halfbits (log2(prob*2) to * probabilities * * * Arg: half_bit [UNKN ] Undocumented argument [double] * * Return [UNKN ] Undocumented return value [Probability] * */ Probability Wise2_halfbit2Probability(double half_bit); #define halfbit2Probability Wise2_halfbit2Probability /* Function: Bits2Probability(bits) * * Descrip: maps halfbits (log2(prob*2) to * probabilities * * * Arg: bits [UNKN ] Undocumented argument [double] * * Return [UNKN ] Undocumented return value [Probability] * */ Probability Wise2_Bits2Probability(double bits); #define Bits2Probability Wise2_Bits2Probability /* Function: Probability2halfbit(p) * * Descrip: maps probabilities to halfbits. * Deals with 0's sensibly * * * Arg: p [UNKN ] Undocumented argument [Probability] * * Return [UNKN ] Undocumented return value [double] * */ double Wise2_Probability2halfbit(Probability p); #define Probability2halfbit Wise2_Probability2halfbit /* Function: Score2Probability(s) * * Descrip: maps scores to probabilities * * * Arg: s [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Probability] * */ Probability Wise2_Score2Probability(Score s); #define Score2Probability Wise2_Score2Probability /* Function: Score2Bits(s) * * Descrip: maps scores to bits * * * Arg: s [UNKN ] Undocumented argument [Score] * * Return [UNKN ] Undocumented return value [Bits] * */ Bits Wise2_Score2Bits(Score s); #define Score2Bits Wise2_Score2Bits /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/alnconvert.c0000644000175000001440000003750710670453712017171 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "alnconvert.h" static char * unknown_label = "UNKNOWN_LABEL"; /* Function: add_collapse_label_AlnConvertSet(acs,label1,label2) * * Descrip: Not a sensible function. Makes the convert with label1 and label2 * a collapsable label * * * Arg: acs [UNKN ] Undocumented argument [AlnConvertSet *] * Arg: label1 [UNKN ] Undocumented argument [char *] * Arg: label2 [UNKN ] Undocumented argument [char *] * */ # line 36 "alnconvert.dy" void add_collapse_label_AlnConvertSet(AlnConvertSet * acs,char * label1,char * label2) { int i; for(i=0;ilen;i++) if( strcmp(acs->acu[i]->label1,label1) == 0 && strcmp(acs->acu[i]->label2,label2) == 0 ) acs->acu[i]->can_collapse = TRUE; } /* Function: AlnBlock_from_PackAln(acs,*pal) * * Descrip: Takes a AlnConvertSet (acs) and a PackAln (pal) * and blindly converts it to AlnBlock. This is really * an internal for a dynamite produced dy function * * * Arg: acs [UNKN ] Undocumented argument [AlnConvertSet *] * Arg: *pal [UNKN ] Undocumented argument [PackAln] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ # line 51 "alnconvert.dy" AlnBlock * AlnBlock_from_PackAln(AlnConvertSet * acs,PackAln *pal) { AlnBlock * alb; AlnColumn * prev; AlnColumn * new; boolean coll; int i; alb = AlnBlock_alloc_len(2); add_AlnBlock(alb,AlnSequence_alloc()); add_AlnBlock(alb,AlnSequence_alloc()); prev = NULL; alb->score = pal->score; for(i=1;ilen;i++) { coll = FALSE; new=AlnColumn_from_Pal_Convert(acs,pal->pau[i-1],pal->pau[i],prev,&coll); if( new == NULL ) { if( coll == FALSE ) { warn("Unrecoverable error in converting PackAln to AlnBlock... bugging out with partial alignment!"); return alb; } else { /** ok, was collapsed, just loop back **/ continue; } } else { /** got a new AlnColumn **/ if( prev == NULL ) { /** then first col **/ alb->start = new; alb->seq[0]->start = new->alu[0]; alb->seq[1]->start = new->alu[1]; prev = new; } else { prev->next = new; prev->alu[0]->next = new->alu[0]; prev->alu[1]->next = new->alu[1]; prev = new; } } } return alb; } /* Function: AlnColumn_from_Pal_Convert(acs,before,after,prev,was_collapsed) * * Descrip: the core of the conversion. * * * Arg: acs [UNKN ] Undocumented argument [AlnConvertSet *] * Arg: before [UNKN ] Undocumented argument [PackAlnUnit *] * Arg: after [UNKN ] Undocumented argument [PackAlnUnit *] * Arg: prev [UNKN ] Undocumented argument [AlnColumn *] * Arg: was_collapsed [UNKN ] Undocumented argument [boolean *] * * Return [UNKN ] Undocumented return value [AlnColumn *] * */ # line 108 "alnconvert.dy" AlnColumn * AlnColumn_from_Pal_Convert(AlnConvertSet * acs,PackAlnUnit * before,PackAlnUnit * after,AlnColumn * prev,boolean * was_collapsed) { AlnConvertUnit * acu; AlnColumn * alc; acu = AlnConvertUnit_from_state_and_offset(acs,before->state,after->state,after->i - before->i,after->j - before->j); if( acu == NULL) { warn("Between state [%d,%d,%d] and [%d,%d,%d] got no labels... labelling as UNKNOWN",before->i,before->j,before->state,after->i,after->j,after->state); alc = new_pairwise_AlnColumn(); alc->alu[0]->start = before->i; alc->alu[0]->end = after->i; alc->alu[1]->start = before->j; alc->alu[1]->end = after->j; alc->alu[0]->score[0] = alc->alu[1]->score[0] = after->score; alc->alu[1]->text_label = alc->alu[0]->text_label = unknown_label; return alc; } if( acu->can_collapse == TRUE && prev != NULL && strcmp(prev->alu[0]->text_label,acu->label1) == 0 && strcmp(prev->alu[1]->text_label,acu->label2) == 0 ) { /*** don't return something, just add into the next one ***/ prev->alu[0]->end = after->i; prev->alu[1]->end = after->j; prev->alu[0]->score[0] += after->score; prev->alu[1]->score[0] += after->score; if( was_collapsed != NULL ) { *was_collapsed = TRUE; } return NULL; } /*** else, put away this unit ***/ alc = new_pairwise_AlnColumn(); if( acu->is_from_special == TRUE ) { alc->alu[0]->start = after->i -1; alc->alu[0]->end = after->i; } else { alc->alu[0]->start = before->i; alc->alu[0]->end = after->i; } alc->alu[1]->start = before->j; alc->alu[1]->end = after->j; alc->alu[0]->score[0] = alc->alu[1]->score[0] = after->score; alc->alu[0]->text_label = acu->label1; alc->alu[1]->text_label = acu->label2; return alc; } /* Function: AlnConvertUnit_from_state_and_offset(acs,state1,state2,offi,offj) * * Descrip: Finds the correct AlnConvertUnit for this state,state,offi,offj * quad * * * Arg: acs [UNKN ] Undocumented argument [AlnConvertSet *] * Arg: state1 [UNKN ] Undocumented argument [int] * Arg: state2 [UNKN ] Undocumented argument [int] * Arg: offi [UNKN ] Undocumented argument [int] * Arg: offj [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [AlnConvertUnit *] * */ # line 172 "alnconvert.dy" AlnConvertUnit * AlnConvertUnit_from_state_and_offset(AlnConvertSet * acs,int state1,int state2,int offi,int offj) { register int i; for(i=0;ilen;i++) { if( acs->acu[i]->state1 == state1 && acs->acu[i]->state2 == state2 && (acs->acu[i]->offi == -1 || acs->acu[i]->offi == offi) && offj == acs->acu[i]->offj) return acs->acu[i]; } return NULL; } # line 191 "alnconvert.c" /* Function: hard_link_AlnConvertUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnConvertUnit *] * * Return [UNKN ] Undocumented return value [AlnConvertUnit *] * */ AlnConvertUnit * hard_link_AlnConvertUnit(AlnConvertUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlnConvertUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlnConvertUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnConvertUnit *] * */ AlnConvertUnit * AlnConvertUnit_alloc(void) { AlnConvertUnit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlnConvertUnit *) ckalloc (sizeof(AlnConvertUnit))) == NULL) { warn("AlnConvertUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->state1 = 0; out->state2 = 0; out->offi = 0; out->offj = 0; out->can_collapse = FALSE; out->is_from_special = FALSE; return out; } /* Function: free_AlnConvertUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnConvertUnit *] * * Return [UNKN ] Undocumented return value [AlnConvertUnit *] * */ AlnConvertUnit * free_AlnConvertUnit(AlnConvertUnit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AlnConvertUnit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->label1 is linked in */ /* obj->label2 is linked in */ ckfree(obj); return NULL; } /* Function: swap_AlnConvertSet(list,i,j) * * Descrip: swap function: an internal for qsort_AlnConvertSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [AlnConvertUnit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_AlnConvertSet(AlnConvertUnit ** list,int i,int j) { AlnConvertUnit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_AlnConvertSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_AlnConvertSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [AlnConvertUnit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_AlnConvertSet(AlnConvertUnit ** list,int left,int right,int (*comp)(AlnConvertUnit * ,AlnConvertUnit * )) { int i,last; if( left >= right ) return; swap_AlnConvertSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_AlnConvertSet (list,++last,i); } swap_AlnConvertSet (list,left,last); qsort_AlnConvertSet(list,left,last-1,comp); qsort_AlnConvertSet(list,last+1,right,comp); } /* Function: sort_AlnConvertSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_AlnConvertSet * * * Arg: obj [UNKN ] Object containing list [AlnConvertSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_AlnConvertSet(AlnConvertSet * obj,int (*comp)(AlnConvertUnit *, AlnConvertUnit *)) { qsort_AlnConvertSet(obj->acu,0,obj->len-1,comp); return; } /* Function: expand_AlnConvertSet(obj,len) * * Descrip: Really an internal function for add_AlnConvertSet * * * Arg: obj [UNKN ] Object which contains the list [AlnConvertSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_AlnConvertSet(AlnConvertSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_AlnConvertSet called with no need"); return TRUE; } if( (obj->acu = (AlnConvertUnit ** ) ckrealloc (obj->acu,sizeof(AlnConvertUnit *)*len)) == NULL) { warn("ckrealloc failed for expand_AlnConvertSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_AlnConvertSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AlnConvertSet *] * Arg: add [OWNER] Object to add to the list [AlnConvertUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_AlnConvertSet(AlnConvertSet * obj,AlnConvertUnit * add) { if( obj->len >= obj->maxlen) { if( expand_AlnConvertSet(obj,obj->len + AlnConvertSetLISTLENGTH) == FALSE) return FALSE; } obj->acu[obj->len++]=add; return TRUE; } /* Function: flush_AlnConvertSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AlnConvertSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_AlnConvertSet(AlnConvertSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->acu[i] != NULL) { free_AlnConvertUnit(obj->acu[i]); obj->acu[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: AlnConvertSet_alloc_std(void) * * Descrip: Equivalent to AlnConvertSet_alloc_len(AlnConvertSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ AlnConvertSet * AlnConvertSet_alloc_std(void) { return AlnConvertSet_alloc_len(AlnConvertSetLISTLENGTH); } /* Function: AlnConvertSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ AlnConvertSet * AlnConvertSet_alloc_len(int len) { AlnConvertSet * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = AlnConvertSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->acu = (AlnConvertUnit ** ) ckcalloc (len,sizeof(AlnConvertUnit *))) == NULL) { warn("Warning, ckcalloc failed in AlnConvertSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_AlnConvertSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnConvertSet *] * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ AlnConvertSet * hard_link_AlnConvertSet(AlnConvertSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlnConvertSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlnConvertSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ AlnConvertSet * AlnConvertSet_alloc(void) { AlnConvertSet * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlnConvertSet *) ckalloc (sizeof(AlnConvertSet))) == NULL) { warn("AlnConvertSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->acu = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_AlnConvertSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnConvertSet *] * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ AlnConvertSet * free_AlnConvertSet(AlnConvertSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AlnConvertSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->acu != NULL) { for(i=0;ilen;i++) { if( obj->acu[i] != NULL) free_AlnConvertUnit(obj->acu[i]); } ckfree(obj->acu); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/alnconvert.h0000644000175000001440000001734610670453712017175 0ustar philippusers#ifndef DYNAMITEalnconvertHEADERFILE #define DYNAMITEalnconvertHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #define AlnConvertSetLISTLENGTH 64 struct Wise2_AlnConvertUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int state1; int state2; int offi; int offj; char * label1; char * label2; boolean can_collapse; boolean is_from_special; } ; /* AlnConvertUnit defined */ #ifndef DYNAMITE_DEFINED_AlnConvertUnit typedef struct Wise2_AlnConvertUnit Wise2_AlnConvertUnit; #define AlnConvertUnit Wise2_AlnConvertUnit #define DYNAMITE_DEFINED_AlnConvertUnit #endif struct Wise2_AlnConvertSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif AlnConvertUnit ** acu; int len;/* len for above acu */ int maxlen; /* maxlen for above acu */ } ; /* AlnConvertSet defined */ #ifndef DYNAMITE_DEFINED_AlnConvertSet typedef struct Wise2_AlnConvertSet Wise2_AlnConvertSet; #define AlnConvertSet Wise2_AlnConvertSet #define DYNAMITE_DEFINED_AlnConvertSet #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: add_collapse_label_AlnConvertSet(acs,label1,label2) * * Descrip: Not a sensible function. Makes the convert with label1 and label2 * a collapsable label * * * Arg: acs [UNKN ] Undocumented argument [AlnConvertSet *] * Arg: label1 [UNKN ] Undocumented argument [char *] * Arg: label2 [UNKN ] Undocumented argument [char *] * */ void Wise2_add_collapse_label_AlnConvertSet(AlnConvertSet * acs,char * label1,char * label2); #define add_collapse_label_AlnConvertSet Wise2_add_collapse_label_AlnConvertSet /* Function: AlnBlock_from_PackAln(acs,*pal) * * Descrip: Takes a AlnConvertSet (acs) and a PackAln (pal) * and blindly converts it to AlnBlock. This is really * an internal for a dynamite produced dy function * * * Arg: acs [UNKN ] Undocumented argument [AlnConvertSet *] * Arg: *pal [UNKN ] Undocumented argument [PackAln] * * Return [UNKN ] Undocumented return value [AlnBlock *] * */ AlnBlock * Wise2_AlnBlock_from_PackAln(AlnConvertSet * acs,PackAln *pal); #define AlnBlock_from_PackAln Wise2_AlnBlock_from_PackAln /* Function: hard_link_AlnConvertUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnConvertUnit *] * * Return [UNKN ] Undocumented return value [AlnConvertUnit *] * */ AlnConvertUnit * Wise2_hard_link_AlnConvertUnit(AlnConvertUnit * obj); #define hard_link_AlnConvertUnit Wise2_hard_link_AlnConvertUnit /* Function: AlnConvertUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnConvertUnit *] * */ AlnConvertUnit * Wise2_AlnConvertUnit_alloc(void); #define AlnConvertUnit_alloc Wise2_AlnConvertUnit_alloc /* Function: free_AlnConvertUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnConvertUnit *] * * Return [UNKN ] Undocumented return value [AlnConvertUnit *] * */ AlnConvertUnit * Wise2_free_AlnConvertUnit(AlnConvertUnit * obj); #define free_AlnConvertUnit Wise2_free_AlnConvertUnit /* Function: add_AlnConvertSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AlnConvertSet *] * Arg: add [OWNER] Object to add to the list [AlnConvertUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_AlnConvertSet(AlnConvertSet * obj,AlnConvertUnit * add); #define add_AlnConvertSet Wise2_add_AlnConvertSet /* Function: flush_AlnConvertSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AlnConvertSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_AlnConvertSet(AlnConvertSet * obj); #define flush_AlnConvertSet Wise2_flush_AlnConvertSet /* Function: AlnConvertSet_alloc_std(void) * * Descrip: Equivalent to AlnConvertSet_alloc_len(AlnConvertSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ AlnConvertSet * Wise2_AlnConvertSet_alloc_std(void); #define AlnConvertSet_alloc_std Wise2_AlnConvertSet_alloc_std /* Function: AlnConvertSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ AlnConvertSet * Wise2_AlnConvertSet_alloc_len(int len); #define AlnConvertSet_alloc_len Wise2_AlnConvertSet_alloc_len /* Function: hard_link_AlnConvertSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnConvertSet *] * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ AlnConvertSet * Wise2_hard_link_AlnConvertSet(AlnConvertSet * obj); #define hard_link_AlnConvertSet Wise2_hard_link_AlnConvertSet /* Function: AlnConvertSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ AlnConvertSet * Wise2_AlnConvertSet_alloc(void); #define AlnConvertSet_alloc Wise2_AlnConvertSet_alloc /* Function: free_AlnConvertSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnConvertSet *] * * Return [UNKN ] Undocumented return value [AlnConvertSet *] * */ AlnConvertSet * Wise2_free_AlnConvertSet(AlnConvertSet * obj); #define free_AlnConvertSet Wise2_free_AlnConvertSet /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ AlnColumn * Wise2_AlnColumn_from_Pal_Convert(AlnConvertSet * acs,PackAlnUnit * before,PackAlnUnit * after,AlnColumn * prev,boolean * was_collapsed); #define AlnColumn_from_Pal_Convert Wise2_AlnColumn_from_Pal_Convert AlnConvertUnit * Wise2_AlnConvertUnit_from_state_and_offset(AlnConvertSet * acs,int state1,int state2,int offi,int offj); #define AlnConvertUnit_from_state_and_offset Wise2_AlnConvertUnit_from_state_and_offset void Wise2_swap_AlnConvertSet(AlnConvertUnit ** list,int i,int j) ; #define swap_AlnConvertSet Wise2_swap_AlnConvertSet void Wise2_qsort_AlnConvertSet(AlnConvertUnit ** list,int left,int right,int (*comp)(AlnConvertUnit * ,AlnConvertUnit * )); #define qsort_AlnConvertSet Wise2_qsort_AlnConvertSet void Wise2_sort_AlnConvertSet(AlnConvertSet * obj,int (*comp)(AlnConvertUnit *, AlnConvertUnit *)); #define sort_AlnConvertSet Wise2_sort_AlnConvertSet boolean Wise2_expand_AlnConvertSet(AlnConvertSet * obj,int len); #define expand_AlnConvertSet Wise2_expand_AlnConvertSet #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/complexsequence.c0000644000175000001440000007723610670453712020221 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "complexsequence.h" /* Function: reversed_ComplexSequence(forward,cses) * * Descrip: No Description * * Arg: forward [UNKN ] Undocumented argument [Sequence *] * Arg: cses [UNKN ] Undocumented argument [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ # line 102 "complexsequence.dy" ComplexSequence * reversed_ComplexSequence(Sequence * forward,ComplexSequenceEvalSet * cses) { ComplexSequence * out; register int i; register int j; register int * poi; Sequence * rev; int seqlen; if( forward == NULL ) { warn("Trying to make a complex sequence from a NULL sequence - impossible!"); return NULL; } if( can_evaluate_this_Sequence(cses,forward) == FALSE ) { warn("Could not evaluate these sequences Sequence type [%d][%s] Evaluation type [%d][%s]",forward->type,Sequence_type_to_string(forward->type),cses->type,Sequence_type_to_string(cses->type)); return NULL; } if( cses->has_been_prepared == FALSE) { warn("Trappable error: you have not prepared this ComplexSequenceEvalSet before using. Please do so in the future"); prepare_ComplexSequenceEvalSet(cses); } rev = reverse_complement_Sequence(forward); out = ComplexSequence_alloc(); if( out == NULL ) return NULL; out->creator = hard_link_ComplexSequenceEvalSet(cses); out->datastore = (int *) ckcalloc((forward->len+cses->left_lookback)*cses->len,sizeof(int)); if( out->datastore == NULL ) { warn("Could not allocate data pointer of length %d for ComplexSequence",forward->len*cses->len); free_ComplexSequence(out); return NULL; } out->data = out->datastore + (cses->left_lookback * cses->len); for(i=0;ileft_lookback;i++) { for(j=0;jlen;j++) out->datastore[(i*cses->len)+j] = cses->cse[j]->outside_score; } out->depth = cses->len; seqlen = forward->len; for(i=0,poi = out->data;ilen;i++,poi = next_ComplexSequence_data(out,poi)) { for(j=0;jlen;j++) { /* fprintf(stderr,"Calling with i at %d vs %d\n",i,cses->cse[j]->left_window); */ if( i < cses->cse[j]->right_window || (i + cses->cse[j]->left_window) >= seqlen) poi[j] = cses->cse[j]->outside_score; else poi[j] = (*cses->cse[j]->eval_func)(cses->cse[j]->data_type,cses->cse[j]->data,rev->seq+seqlen-i); } } return out; } /* Function: new_ComplexSequence(seq,cses) * * Descrip: The basic way to make a ComplexSequence. Requires that * you have already built a ComplexSequenceEvalSet (such as * /default_aminoacid_ComplexSequenceEvalSet). * * * * Arg: seq [UNKN ] Sequence that the ComplexSequence is based on [Sequence *] * Arg: cses [UNKN ] EvalSet that defines the functions used on the sequence [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ # line 175 "complexsequence.dy" ComplexSequence * new_ComplexSequence(Sequence * seq,ComplexSequenceEvalSet * cses) { ComplexSequence * out; register int i; register int j; register int * poi; if( seq == NULL ) { warn("Trying to make a complex sequence from a NULL sequence - impossible!"); return NULL; } if( can_evaluate_this_Sequence(cses,seq) == FALSE ) { warn("Could not evaluate these sequences Sequence type [%d][%s] Evaluation type [%d][%s]",seq->type,Sequence_type_to_string(seq->type),cses->type,Sequence_type_to_string(cses->type)); return NULL; } if( cses->has_been_prepared == FALSE) { warn("Trappable error: you have not prepared this ComplexSequenceEvalSet before using. Please do so in the future"); prepare_ComplexSequenceEvalSet(cses); } out = ComplexSequence_alloc(); if( out == NULL ) return NULL; out->creator = hard_link_ComplexSequenceEvalSet(cses); out->datastore = (int *) ckcalloc((seq->len+cses->left_lookback)*cses->len,sizeof(int)); if( out->datastore == NULL ) { warn("Could not allocate data pointer of length %d for ComplexSequence",seq->len*cses->len); free_ComplexSequence(out); return NULL; } out->data = out->datastore + (cses->left_lookback * cses->len); for(i=0;ileft_lookback;i++) { for(j=0;jlen;j++) out->datastore[(i*cses->len)+j] = cses->cse[j]->outside_score; } out->depth = cses->len; for(i=0,poi = out->data;ilen;i++,poi = next_ComplexSequence_data(out,poi)) { for(j=0;jlen;j++) { /* fprintf(stderr,"Calling with i at %d vs %d\n",i,cses->cse[j]->left_window); */ if( i < cses->cse[j]->left_window || (i + cses->cse[j]->right_window) >= seq->len) poi[j] = cses->cse[j]->outside_score; else poi[j] = (*cses->cse[j]->eval_func)(cses->cse[j]->data_type,cses->cse[j]->data,seq->seq+i); } } out->seq = hard_link_Sequence(seq); out->length = seq->len; return out; } /* Function: show_ComplexSequence(cs,ofp) * * Descrip: shows complex sequence in a vaguely * human form * * * Arg: cs [UNKN ] Undocumented argument [ComplexSequence *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 243 "complexsequence.dy" void show_ComplexSequence(ComplexSequence * cs,FILE * ofp) { register int i; assert(cs); assert(ofp); assert(cs->seq); fprintf(ofp,"ComplexSequence %s\n",cs->seq->name); for(i=0;ilength;i++) { show_one_position_ComplexSequence(cs,i,ofp); } } /* Function: show_one_position_ComplexSequence(cs,pos,ofp) * * Descrip: shows one position of a complex sequence * * * Arg: cs [UNKN ] Undocumented argument [ComplexSequence *] * Arg: pos [UNKN ] Undocumented argument [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 262 "complexsequence.dy" void show_one_position_ComplexSequence(ComplexSequence * cs,int pos,FILE * ofp) { int i; assert(cs); assert(ofp); fprintf(ofp,"%4d %c [",pos,cs->seq->seq[pos]); for(i=0;idepth;i++) { if( cs->creator != NULL ) { if( cs->creator->cse[i]->score_type == CseScoreType_Index ) { fprintf(ofp,"%4d%c",ComplexSequence_data(cs,pos,i),i == cs->depth-1 ? ']' : ','); } else { fprintf(ofp,"% 6d (%0+2.2f)%c",ComplexSequence_data(cs,pos,i),Score2Bits(ComplexSequence_data(cs,pos,i)), i == cs->depth-1 ? ']' : ','); } } else { fprintf(ofp,"%4d%c",ComplexSequence_data(cs,pos,i),i == cs->depth-1 ? ']' : ','); } } fprintf(ofp,"\n"); } /********************************/ /* Making complex sequences */ /********************************/ /* Function: prepare_ComplexSequenceEvalSet(cses) * * Descrip: Calculates all the necessary offset for an EvalSet. * This is necessary before using it in a /new_ComplexSequence * place * * * Arg: cses [UNKN ] Undocumented argument [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 296 "complexsequence.dy" boolean prepare_ComplexSequenceEvalSet(ComplexSequenceEvalSet * cses) { register int i; int left_window = 0; int right_window = 0; int left_lookback = 0; for(i=0;ilen;i++) { if( cses->cse[i]->right_window > right_window ) right_window = cses->cse[i]->right_window; if( cses->cse[i]->left_window > left_window ) left_window = cses->cse[i]->left_window; if( cses->cse[i]->left_lookback > left_lookback ) left_lookback = cses->cse[i]->left_lookback; } cses->right_window = right_window; cses->left_window = left_window; cses->left_lookback = left_lookback; cses->has_been_prepared = TRUE; return TRUE; } /* Function: can_evaluate_this_Sequence(cses,s) * * Descrip: Checks that this ComplexSequenceEvalSet can be used with * this Sequence. This is probably going to go defunct. * * * * Arg: cses [UNKN ] Undocumented argument [ComplexSequenceEvalSet *] * Arg: s [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 327 "complexsequence.dy" boolean can_evaluate_this_Sequence(ComplexSequenceEvalSet * cses,Sequence * s) { return can_evaluate_this_type(cses,s->type); } /* Function: can_evaluate_this_type(cses,type) * * Descrip: Pretty much an internal for /can_evaluate_this_Sequence * * * Arg: cses [UNKN ] Undocumented argument [ComplexSequenceEvalSet *] * Arg: type [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 338 "complexsequence.dy" boolean can_evaluate_this_type(ComplexSequenceEvalSet * cses,int type) { switch (type) { case SEQUENCE_UNKNOWN : return FALSE; case SEQUENCE_DNA : if( cses->type == SEQUENCE_DNA || cses->type == SEQUENCE_CDNA || cses->type == SEQUENCE_EST || cses->type == SEQUENCE_GENOMIC) return TRUE; else return FALSE; default : if( cses->type == type) return TRUE; else return FALSE; } } # line 297 "complexsequence.c" /* Function: hard_link_ComplexSequenceEval(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ComplexSequenceEval *] * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * hard_link_ComplexSequenceEval(ComplexSequenceEval * obj) { if( obj == NULL ) { warn("Trying to hard link to a ComplexSequenceEval object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ComplexSequenceEval_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * ComplexSequenceEval_alloc(void) { ComplexSequenceEval * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ComplexSequenceEval *) ckalloc (sizeof(ComplexSequenceEval))) == NULL) { warn("ComplexSequenceEval_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = 0; out->sequence_type = 0; out->left_window = 0; out->right_window = 0; out->left_lookback = 0; out->outside_score = 0; out->data_type = 0; out->eval_func = NULL; out->score_type = CseScoreType_Index; return out; } /* Function: free_ComplexSequenceEval(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ComplexSequenceEval *] * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * free_ComplexSequenceEval(ComplexSequenceEval * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ComplexSequenceEval obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->data is linked in */ /* obj->eval_func is a function pointer */ ckfree(obj); return NULL; } /* Function: swap_ComplexSequenceEvalSet(list,i,j) * * Descrip: swap function: an internal for qsort_ComplexSequenceEvalSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ComplexSequenceEval **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ComplexSequenceEvalSet(ComplexSequenceEval ** list,int i,int j) { ComplexSequenceEval * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ComplexSequenceEvalSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ComplexSequenceEvalSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ComplexSequenceEval **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ComplexSequenceEvalSet(ComplexSequenceEval ** list,int left,int right,int (*comp)(ComplexSequenceEval * ,ComplexSequenceEval * )) { int i,last; if( left >= right ) return; swap_ComplexSequenceEvalSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ComplexSequenceEvalSet (list,++last,i); } swap_ComplexSequenceEvalSet (list,left,last); qsort_ComplexSequenceEvalSet(list,left,last-1,comp); qsort_ComplexSequenceEvalSet(list,last+1,right,comp); } /* Function: sort_ComplexSequenceEvalSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ComplexSequenceEvalSet * * * Arg: obj [UNKN ] Object containing list [ComplexSequenceEvalSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,int (*comp)(ComplexSequenceEval *, ComplexSequenceEval *)) { qsort_ComplexSequenceEvalSet(obj->cse,0,obj->len-1,comp); return; } /* Function: expand_ComplexSequenceEvalSet(obj,len) * * Descrip: Really an internal function for add_ComplexSequenceEvalSet * * * Arg: obj [UNKN ] Object which contains the list [ComplexSequenceEvalSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_ComplexSequenceEvalSet called with no need"); return TRUE; } if( (obj->cse = (ComplexSequenceEval ** ) ckrealloc (obj->cse,sizeof(ComplexSequenceEval *)*len)) == NULL) { warn("ckrealloc failed for expand_ComplexSequenceEvalSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_ComplexSequenceEvalSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ComplexSequenceEvalSet *] * Arg: add [OWNER] Object to add to the list [ComplexSequenceEval *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,ComplexSequenceEval * add) { if( obj->len >= obj->maxlen) { if( expand_ComplexSequenceEvalSet(obj,obj->len + ComplexSequenceEvalSetLISTLENGTH) == FALSE) return FALSE; } obj->cse[obj->len++]=add; return TRUE; } /* Function: flush_ComplexSequenceEvalSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->cse[i] != NULL) { free_ComplexSequenceEval(obj->cse[i]); obj->cse[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: ComplexSequenceEvalSet_alloc_std(void) * * Descrip: Equivalent to ComplexSequenceEvalSet_alloc_len(ComplexSequenceEvalSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * ComplexSequenceEvalSet_alloc_std(void) { return ComplexSequenceEvalSet_alloc_len(ComplexSequenceEvalSetLISTLENGTH); } /* Function: ComplexSequenceEvalSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * ComplexSequenceEvalSet_alloc_len(int len) { ComplexSequenceEvalSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = ComplexSequenceEvalSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->cse = (ComplexSequenceEval ** ) ckcalloc (len,sizeof(ComplexSequenceEval *))) == NULL) { warn("Warning, ckcalloc failed in ComplexSequenceEvalSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_ComplexSequenceEvalSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * hard_link_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a ComplexSequenceEvalSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ComplexSequenceEvalSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * ComplexSequenceEvalSet_alloc(void) { ComplexSequenceEvalSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ComplexSequenceEvalSet *) ckalloc (sizeof(ComplexSequenceEvalSet))) == NULL) { warn("ComplexSequenceEvalSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = 0; out->has_been_prepared = FALSE; out->left_window = 0; out->right_window = 0; out->left_lookback = 0; out->cse = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_ComplexSequenceEvalSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * free_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ComplexSequenceEvalSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->cse != NULL) { for(i=0;ilen;i++) { if( obj->cse[i] != NULL) free_ComplexSequenceEval(obj->cse[i]); } ckfree(obj->cse); } ckfree(obj); return NULL; } /* Function: hard_link_ComplexSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ComplexSequence *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * hard_link_ComplexSequence(ComplexSequence * obj) { if( obj == NULL ) { warn("Trying to hard link to a ComplexSequence object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ComplexSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * ComplexSequence_alloc(void) { ComplexSequence * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ComplexSequence *) ckalloc (sizeof(ComplexSequence))) == NULL) { warn("ComplexSequence_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = 0; out->seq = NULL; out->datastore = NULL; out->depth = 0; out->length = 0; out->creator = NULL; return out; } /* Function: free_ComplexSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ComplexSequence *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * free_ComplexSequence(ComplexSequence * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ComplexSequence obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->seq != NULL) free_Sequence(obj->seq); /* obj->data is linked in */ if( obj->datastore != NULL) ckfree(obj->datastore); if( obj->creator != NULL) free_ComplexSequenceEvalSet(obj->creator); ckfree(obj); return NULL; } /* Function: replace_type_ComplexSequence(obj,type) * * Descrip: Replace member variable type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequence *] * Arg: type [OWNER] New value of the variable [int] * * Return [SOFT ] member variable type [boolean] * */ boolean replace_type_ComplexSequence(ComplexSequence * obj,int type) { if( obj == NULL) { warn("In replacement function type for object ComplexSequence, got a NULL object"); return FALSE; } obj->type = type; return TRUE; } /* Function: access_type_ComplexSequence(obj) * * Descrip: Access member variable type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequence *] * * Return [SOFT ] member variable type [int] * */ int access_type_ComplexSequence(ComplexSequence * obj) { if( obj == NULL) { warn("In accessor function type for object ComplexSequence, got a NULL object"); return 0; } return obj->type; } /* Function: replace_seq_ComplexSequence(obj,seq) * * Descrip: Replace member variable seq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequence *] * Arg: seq [OWNER] New value of the variable [Sequence *] * * Return [SOFT ] member variable seq [boolean] * */ boolean replace_seq_ComplexSequence(ComplexSequence * obj,Sequence * seq) { if( obj == NULL) { warn("In replacement function seq for object ComplexSequence, got a NULL object"); return FALSE; } obj->seq = seq; return TRUE; } /* Function: access_seq_ComplexSequence(obj) * * Descrip: Access member variable seq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequence *] * * Return [SOFT ] member variable seq [Sequence *] * */ Sequence * access_seq_ComplexSequence(ComplexSequence * obj) { if( obj == NULL) { warn("In accessor function seq for object ComplexSequence, got a NULL object"); return NULL; } return obj->seq; } /* Function: replace_type_ComplexSequenceEvalSet(obj,type) * * Descrip: Replace member variable type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] * Arg: type [OWNER] New value of the variable [int] * * Return [SOFT ] member variable type [boolean] * */ boolean replace_type_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,int type) { if( obj == NULL) { warn("In replacement function type for object ComplexSequenceEvalSet, got a NULL object"); return FALSE; } obj->type = type; return TRUE; } /* Function: access_type_ComplexSequenceEvalSet(obj) * * Descrip: Access member variable type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] * * Return [SOFT ] member variable type [int] * */ int access_type_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj) { if( obj == NULL) { warn("In accessor function type for object ComplexSequenceEvalSet, got a NULL object"); return 0; } return obj->type; } /* Function: replace_has_been_prepared_ComplexSequenceEvalSet(obj,has_been_prepared) * * Descrip: Replace member variable has_been_prepared * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] * Arg: has_been_prepared [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable has_been_prepared [boolean] * */ boolean replace_has_been_prepared_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,boolean has_been_prepared) { if( obj == NULL) { warn("In replacement function has_been_prepared for object ComplexSequenceEvalSet, got a NULL object"); return FALSE; } obj->has_been_prepared = has_been_prepared; return TRUE; } /* Function: access_has_been_prepared_ComplexSequenceEvalSet(obj) * * Descrip: Access member variable has_been_prepared * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] * * Return [SOFT ] member variable has_been_prepared [boolean] * */ boolean access_has_been_prepared_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj) { if( obj == NULL) { warn("In accessor function has_been_prepared for object ComplexSequenceEvalSet, got a NULL object"); return FALSE; } return obj->has_been_prepared; } /* Function: replace_left_window_ComplexSequenceEvalSet(obj,left_window) * * Descrip: Replace member variable left_window * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] * Arg: left_window [OWNER] New value of the variable [int] * * Return [SOFT ] member variable left_window [boolean] * */ boolean replace_left_window_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,int left_window) { if( obj == NULL) { warn("In replacement function left_window for object ComplexSequenceEvalSet, got a NULL object"); return FALSE; } obj->left_window = left_window; return TRUE; } /* Function: access_left_window_ComplexSequenceEvalSet(obj) * * Descrip: Access member variable left_window * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] * * Return [SOFT ] member variable left_window [int] * */ int access_left_window_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj) { if( obj == NULL) { warn("In accessor function left_window for object ComplexSequenceEvalSet, got a NULL object"); return 0; } return obj->left_window; } /* Function: replace_right_window_ComplexSequenceEvalSet(obj,right_window) * * Descrip: Replace member variable right_window * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] * Arg: right_window [OWNER] New value of the variable [int] * * Return [SOFT ] member variable right_window [boolean] * */ boolean replace_right_window_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,int right_window) { if( obj == NULL) { warn("In replacement function right_window for object ComplexSequenceEvalSet, got a NULL object"); return FALSE; } obj->right_window = right_window; return TRUE; } /* Function: access_right_window_ComplexSequenceEvalSet(obj) * * Descrip: Access member variable right_window * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] * * Return [SOFT ] member variable right_window [int] * */ int access_right_window_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj) { if( obj == NULL) { warn("In accessor function right_window for object ComplexSequenceEvalSet, got a NULL object"); return 0; } return obj->right_window; } /* Function: replace_left_lookback_ComplexSequenceEvalSet(obj,left_lookback) * * Descrip: Replace member variable left_lookback * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] * Arg: left_lookback [OWNER] New value of the variable [int] * * Return [SOFT ] member variable left_lookback [boolean] * */ boolean replace_left_lookback_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,int left_lookback) { if( obj == NULL) { warn("In replacement function left_lookback for object ComplexSequenceEvalSet, got a NULL object"); return FALSE; } obj->left_lookback = left_lookback; return TRUE; } /* Function: access_left_lookback_ComplexSequenceEvalSet(obj) * * Descrip: Access member variable left_lookback * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [ComplexSequenceEvalSet *] * * Return [SOFT ] member variable left_lookback [int] * */ int access_left_lookback_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj) { if( obj == NULL) { warn("In accessor function left_lookback for object ComplexSequenceEvalSet, got a NULL object"); return 0; } return obj->left_lookback; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/complexsequence.h0000644000175000001440000003743110670453712020217 0ustar philippusers#ifndef DYNAMITEcomplexsequenceHEADERFILE #define DYNAMITEcomplexsequenceHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" #include "probability.h" /* should move this to wisestring */ #define ComplexSequenceEvalSetLISTLENGTH 16 #define next_ComplexSequence_data(cs_struct,pointer) (pointer + cs_struct->depth) #define ComplexSequence_data(cs,position,number) (cs->data[cs->depth*position + number]) typedef enum CseScoreType { CseScoreType_Index = 673, CseScoreType_Bits } CseScoreType; /* Object ComplexSequenceEval * * Descrip: This object is best left alone (!) * * It represents a single way of mapping * a sequence to some sort of number, eg * amino acids to 0-25, bases to 0-4 or * splice sites to log(Prob(splice)) * * This is handled by a reasonably scary * pointer-to-function method * * You'll use collections of them in * complexsequenceevalset's * * */ struct Wise2_ComplexSequenceEval { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; int sequence_type; int left_window; int right_window; int left_lookback; int outside_score; void * data; int data_type; /* optional, to be used by eval_func to check things if it wants to */ int (*eval_func)(int,void * ,char *); CseScoreType score_type; } ; /* ComplexSequenceEval defined */ #ifndef DYNAMITE_DEFINED_ComplexSequenceEval typedef struct Wise2_ComplexSequenceEval Wise2_ComplexSequenceEval; #define ComplexSequenceEval Wise2_ComplexSequenceEval #define DYNAMITE_DEFINED_ComplexSequenceEval #endif /* Object ComplexSequenceEvalSet * * Descrip: This object holds a collection of * ComplexSequenceEvals. Its role is to * define the sequence specific parts of a * dynamic programming algorithm as computable * functions. * * Ideally you should use pre-made ComplexSequenceEvalSets * as it will save you alot of grief * * */ struct Wise2_ComplexSequenceEvalSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; boolean has_been_prepared; int left_window; /* overall sequence eval */ int right_window; /* overall sequence eval */ int left_lookback; /* overall sequence eval */ ComplexSequenceEval ** cse; int len;/* len for above cse */ int maxlen; /* maxlen for above cse */ } ; /* ComplexSequenceEvalSet defined */ #ifndef DYNAMITE_DEFINED_ComplexSequenceEvalSet typedef struct Wise2_ComplexSequenceEvalSet Wise2_ComplexSequenceEvalSet; #define ComplexSequenceEvalSet Wise2_ComplexSequenceEvalSet #define DYNAMITE_DEFINED_ComplexSequenceEvalSet #endif /* Object ComplexSequence * * Descrip: A ComplexSequence is an abstraction of a * Sequence which can be handily made using * ComplexSequenceEval functions and is efficiently * laid out in memory. * * */ struct Wise2_ComplexSequence { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; Sequence * seq; int * data; int * datastore; int depth; int length; ComplexSequenceEvalSet * creator; /* what made it */ } ; /* ComplexSequence defined */ #ifndef DYNAMITE_DEFINED_ComplexSequence typedef struct Wise2_ComplexSequence Wise2_ComplexSequence; #define ComplexSequence Wise2_ComplexSequence #define DYNAMITE_DEFINED_ComplexSequence #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: reversed_ComplexSequence(forward,cses) * * Descrip: No Description * * Arg: forward [UNKN ] Undocumented argument [Sequence *] * Arg: cses [UNKN ] Undocumented argument [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * Wise2_reversed_ComplexSequence(Sequence * forward,ComplexSequenceEvalSet * cses) ; #define reversed_ComplexSequence Wise2_reversed_ComplexSequence /* Function: new_ComplexSequence(seq,cses) * * Descrip: The basic way to make a ComplexSequence. Requires that * you have already built a ComplexSequenceEvalSet (such as * /default_aminoacid_ComplexSequenceEvalSet). * * * * Arg: seq [UNKN ] Sequence that the ComplexSequence is based on [Sequence *] * Arg: cses [UNKN ] EvalSet that defines the functions used on the sequence [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * Wise2_new_ComplexSequence(Sequence * seq,ComplexSequenceEvalSet * cses); #define new_ComplexSequence Wise2_new_ComplexSequence /* Function: show_ComplexSequence(cs,ofp) * * Descrip: shows complex sequence in a vaguely * human form * * * Arg: cs [UNKN ] Undocumented argument [ComplexSequence *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_ComplexSequence(ComplexSequence * cs,FILE * ofp); #define show_ComplexSequence Wise2_show_ComplexSequence /* Function: prepare_ComplexSequenceEvalSet(cses) * * Descrip: Calculates all the necessary offset for an EvalSet. * This is necessary before using it in a /new_ComplexSequence * place * * * Arg: cses [UNKN ] Undocumented argument [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_prepare_ComplexSequenceEvalSet(ComplexSequenceEvalSet * cses); #define prepare_ComplexSequenceEvalSet Wise2_prepare_ComplexSequenceEvalSet /* Function: can_evaluate_this_Sequence(cses,s) * * Descrip: Checks that this ComplexSequenceEvalSet can be used with * this Sequence. This is probably going to go defunct. * * * * Arg: cses [UNKN ] Undocumented argument [ComplexSequenceEvalSet *] * Arg: s [UNKN ] Undocumented argument [Sequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_can_evaluate_this_Sequence(ComplexSequenceEvalSet * cses,Sequence * s); #define can_evaluate_this_Sequence Wise2_can_evaluate_this_Sequence /* Function: hard_link_ComplexSequenceEval(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ComplexSequenceEval *] * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * Wise2_hard_link_ComplexSequenceEval(ComplexSequenceEval * obj); #define hard_link_ComplexSequenceEval Wise2_hard_link_ComplexSequenceEval /* Function: ComplexSequenceEval_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * Wise2_ComplexSequenceEval_alloc(void); #define ComplexSequenceEval_alloc Wise2_ComplexSequenceEval_alloc /* Function: free_ComplexSequenceEval(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ComplexSequenceEval *] * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * Wise2_free_ComplexSequenceEval(ComplexSequenceEval * obj); #define free_ComplexSequenceEval Wise2_free_ComplexSequenceEval /* Function: add_ComplexSequenceEvalSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ComplexSequenceEvalSet *] * Arg: add [OWNER] Object to add to the list [ComplexSequenceEval *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,ComplexSequenceEval * add); #define add_ComplexSequenceEvalSet Wise2_add_ComplexSequenceEvalSet /* Function: flush_ComplexSequenceEvalSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj); #define flush_ComplexSequenceEvalSet Wise2_flush_ComplexSequenceEvalSet /* Function: ComplexSequenceEvalSet_alloc_std(void) * * Descrip: Equivalent to ComplexSequenceEvalSet_alloc_len(ComplexSequenceEvalSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * Wise2_ComplexSequenceEvalSet_alloc_std(void); #define ComplexSequenceEvalSet_alloc_std Wise2_ComplexSequenceEvalSet_alloc_std /* Function: ComplexSequenceEvalSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * Wise2_ComplexSequenceEvalSet_alloc_len(int len); #define ComplexSequenceEvalSet_alloc_len Wise2_ComplexSequenceEvalSet_alloc_len /* Function: hard_link_ComplexSequenceEvalSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * Wise2_hard_link_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj); #define hard_link_ComplexSequenceEvalSet Wise2_hard_link_ComplexSequenceEvalSet /* Function: ComplexSequenceEvalSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * Wise2_ComplexSequenceEvalSet_alloc(void); #define ComplexSequenceEvalSet_alloc Wise2_ComplexSequenceEvalSet_alloc /* Function: free_ComplexSequenceEvalSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ComplexSequenceEvalSet *] * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * Wise2_free_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj); #define free_ComplexSequenceEvalSet Wise2_free_ComplexSequenceEvalSet /* Function: hard_link_ComplexSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ComplexSequence *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * Wise2_hard_link_ComplexSequence(ComplexSequence * obj); #define hard_link_ComplexSequence Wise2_hard_link_ComplexSequence /* Function: ComplexSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * Wise2_ComplexSequence_alloc(void); #define ComplexSequence_alloc Wise2_ComplexSequence_alloc /* Function: free_ComplexSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ComplexSequence *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * Wise2_free_ComplexSequence(ComplexSequence * obj); #define free_ComplexSequence Wise2_free_ComplexSequence /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_access_type_ComplexSequence(ComplexSequence * obj); #define access_type_ComplexSequence Wise2_access_type_ComplexSequence boolean Wise2_replace_type_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,int type); #define replace_type_ComplexSequenceEvalSet Wise2_replace_type_ComplexSequenceEvalSet boolean Wise2_replace_has_been_prepared_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,boolean has_been_prepared); #define replace_has_been_prepared_ComplexSequenceEvalSet Wise2_replace_has_been_prepared_ComplexSequenceEvalSet int Wise2_access_left_lookback_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj); #define access_left_lookback_ComplexSequenceEvalSet Wise2_access_left_lookback_ComplexSequenceEvalSet boolean Wise2_access_has_been_prepared_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj); #define access_has_been_prepared_ComplexSequenceEvalSet Wise2_access_has_been_prepared_ComplexSequenceEvalSet boolean Wise2_replace_seq_ComplexSequence(ComplexSequence * obj,Sequence * seq); #define replace_seq_ComplexSequence Wise2_replace_seq_ComplexSequence boolean Wise2_replace_left_window_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,int left_window); #define replace_left_window_ComplexSequenceEvalSet Wise2_replace_left_window_ComplexSequenceEvalSet int Wise2_access_type_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj); #define access_type_ComplexSequenceEvalSet Wise2_access_type_ComplexSequenceEvalSet boolean Wise2_replace_left_lookback_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,int left_lookback); #define replace_left_lookback_ComplexSequenceEvalSet Wise2_replace_left_lookback_ComplexSequenceEvalSet int Wise2_access_left_window_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj); #define access_left_window_ComplexSequenceEvalSet Wise2_access_left_window_ComplexSequenceEvalSet Sequence * Wise2_access_seq_ComplexSequence(ComplexSequence * obj); #define access_seq_ComplexSequence Wise2_access_seq_ComplexSequence boolean Wise2_replace_right_window_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,int right_window); #define replace_right_window_ComplexSequenceEvalSet Wise2_replace_right_window_ComplexSequenceEvalSet boolean Wise2_replace_type_ComplexSequence(ComplexSequence * obj,int type); #define replace_type_ComplexSequence Wise2_replace_type_ComplexSequence int Wise2_access_right_window_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj); #define access_right_window_ComplexSequenceEvalSet Wise2_access_right_window_ComplexSequenceEvalSet void Wise2_show_one_position_ComplexSequence(ComplexSequence * cs,int pos,FILE * ofp); #define show_one_position_ComplexSequence Wise2_show_one_position_ComplexSequence boolean Wise2_can_evaluate_this_type(ComplexSequenceEvalSet * cses,int type); #define can_evaluate_this_type Wise2_can_evaluate_this_type void Wise2_swap_ComplexSequenceEvalSet(ComplexSequenceEval ** list,int i,int j) ; #define swap_ComplexSequenceEvalSet Wise2_swap_ComplexSequenceEvalSet void Wise2_qsort_ComplexSequenceEvalSet(ComplexSequenceEval ** list,int left,int right,int (*comp)(ComplexSequenceEval * ,ComplexSequenceEval * )); #define qsort_ComplexSequenceEvalSet Wise2_qsort_ComplexSequenceEvalSet void Wise2_sort_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,int (*comp)(ComplexSequenceEval *, ComplexSequenceEval *)); #define sort_ComplexSequenceEvalSet Wise2_sort_ComplexSequenceEvalSet boolean Wise2_expand_ComplexSequenceEvalSet(ComplexSequenceEvalSet * obj,int len); #define expand_ComplexSequenceEvalSet Wise2_expand_ComplexSequenceEvalSet #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/hspthreadeddb.c0000644000175000001440000004643510670453712017617 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "hspthreadeddb.h" #define HAS_PTHREAD_SETSCOPE #define HAS_PTHREAD_SETCONCURRENCY /* Function: new_HSPScanInterface_from_HSPThreadedDatabase(tdb) * * Descrip: Makes a HSPScanInterface from a loaded threaded database * * * Arg: tdb [UNKN ] Undocumented argument [HSPThreadedDatabase *] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ # line 39 "hspthreadeddb.dy" HSPScanInterface * new_HSPScanInterface_from_HSPThreadedDatabase(HSPThreadedDatabase * tdb) { HSPScanInterface * out; assert(tdb != NULL); assert(tdb->seg[0] != NULL); assert(tdb->seg[0]->sli != NULL); out = HSPScanInterface_alloc(); out->data = tdb; out->scan_query = scan_query_hspthreadeddb; out->free_data = free_data_hspthreadeddb; return out; } /* Function: free_data_hspthreadeddb(d) * * Descrip: frees data * * * Arg: d [UNKN ] Undocumented argument [void *] * */ # line 62 "hspthreadeddb.dy" void free_data_hspthreadeddb(void * d) { HSPThreadedDatabase * tdb = (HSPThreadedDatabase *) d; free_HSPThreadedDatabase(tdb); } /* Function: scan_query_hspthreadeddb(d,query,para) * * Descrip: Does the scan query for the HSPThreadedDatabase * * * Arg: d [UNKN ] Undocumented argument [void *] * Arg: query [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 74 "hspthreadeddb.dy" LinearHSPmanager * scan_query_hspthreadeddb(void * d,Sequence * query,HSPScanInterfacePara * para) { HSPThreadedDatabase * tdb; pthread_t thread_pool[DBTHREAD_MAX_SIZE]; pthread_attr_t pat; int i,j; int err; LinearHSPmanager * out; LinearHSPmanager * real_out; tdb = (HSPThreadedDatabase *) d; pthread_attr_init(&pat); #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ /* Give thread libraries a hint that there are num of threads to run */ #ifdef HAS_PTHREAD_SETCONCURRENCY /* pthread_setconcurrency(tdb->len+1);*/ #endif /* set concurrency */ for(i=0;ilen;i++) { tdb->seg[i]->query = query; tdb->seg[i]->run_para = para; tdb->seg[i]->lm = NULL; if( (err = pthread_create(&(thread_pool[i]),&pat,threadeddb_scan_worker,(void*)tdb->seg[i])) != 0 ) { fatal("Unable to make thread %d with error %d",i,err); } } for(i=0;ilen;i++) { pthread_join(thread_pool[i],NULL); } fprintf(stderr,"All threads have run\n"); if( VERBOSITY_CHECK(4,para->verbosity) ) { info("All threads have run"); } out = LinearHSPmanager_alloc_std(); for(i=0;ilen;i++) { assert(tdb->seg[i]->lm != NULL); for(j=0;jseg[i]->lm->len;j++) { add_LinearHSPmanager(out,hard_link_HSPset(tdb->seg[i]->lm->set[j])); } } qsort(out->set,out->len,sizeof(HSPset*),compare_HSPset_score_qsort); /* this is a bit evil */ real_out = LinearHSPmanager_alloc_len(para->max_results); for(i=0;imax_results && ilen;i++) { add_LinearHSPmanager(real_out,out->set[i]); } /* out->len = para->max_results;*/ if( VERBOSITY_CHECK(4,para->verbosity) ) { info("Finish combine/sort with %d elements",real_out->len); } return out; } /* Function: threadeddb_scan_worker(d) * * Descrip: internal scan function * * * Arg: d [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ # line 146 "hspthreadeddb.dy" void * threadeddb_scan_worker(void * d) { HSPDatabaseSegment * seg; seg = (HSPDatabaseSegment *) d; seg->lm = (*seg->hspi->scan_query)(seg->hspi->data,seg->query,seg->run_para); fprintf(stderr,"For segment %d, finished query with %d (%d) linear\n",seg,(int)seg->lm,seg->lm->len); return NULL; } /* Function: new_HSPThreadedDatabase(segments,array_numb_level) * * Descrip: Makes a new segmented database suitable for * threading * * * Arg: segments [UNKN ] Undocumented argument [int] * Arg: array_numb_level [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPThreadedDatabase *] * */ # line 164 "hspthreadeddb.dy" HSPThreadedDatabase * new_HSPThreadedDatabase(int segments,int array_numb_level) { HSPThreadedDatabase * out; int i; HSPDatabaseSegment * seg; out = HSPThreadedDatabase_alloc_len(segments); for(i=0;ihspi = NULL; seg->sli = new_ArraySeq_SeqLookupInterface(26*26*26*26*26,array_numb_level); add_HSPThreadedDatabase(out,seg); } return out; } /* Function: load_HSPThreadedDatabase(db,sdb,para,mat,drop_off,score_cutoff) * * Descrip: Loades a segmented database * * * Arg: db [UNKN ] Undocumented argument [HSPThreadedDatabase *] * Arg: sdb [UNKN ] Undocumented argument [SequenceDB *] * Arg: para [UNKN ] Undocumented argument [SeqLookupLoadPara *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * */ # line 187 "hspthreadeddb.dy" void load_HSPThreadedDatabase(HSPThreadedDatabase * db,SequenceDB * sdb,SeqLookupLoadPara * para,CompMat * mat,int drop_off,int score_cutoff) { pthread_mutex_t dblock; pthread_t thread_pool[DBTHREAD_MAX_SIZE]; pthread_attr_t pat; int i; int err; long int count = 0; boolean is_first = 1; pthread_attr_init(&pat); #ifdef HAS_PTHREAD_SETSCOPE pthread_attr_setscope(&pat, PTHREAD_SCOPE_SYSTEM); #endif /* set scope */ #ifdef HAS_PTHREAD_SETCONCURRENCY /* needed to make sure one thread doesn't dominate the IO */ pthread_attr_setschedpolicy(&pat,SCHED_RR); #endif /* set concurrency */ if( pthread_mutex_init(&dblock,NULL) != 0 ) { fatal("Unable to make mutex for db lock"); } for(i=0;ilen;i++) { db->seg[i]->load_para = para; db->seg[i]->loaddb = sdb; db->seg[i]->dblock = &dblock; db->seg[i]->count = &count; db->seg[i]->is_first = &is_first; } for(i=0;ilen;i++) { if( (err = pthread_create(&(thread_pool[i]),&pat,threaddb_load_worker,(void*)db->seg[i])) != 0 ) { fatal("Unable to make thread %d with error %d",i,err); } } for(i=0;ilen;i++) { pthread_join(thread_pool[i],NULL); } /* attach scan interfaces to the databases */ for(i=0;ilen;i++) { db->seg[i]->hspi = new_one_off_HSPScanInterface(db->seg[i]->sli,mat,drop_off,score_cutoff); } return; } /* Function: threaddb_load_worker(d) * * Descrip: load threaddb * * * Arg: d [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ # line 245 "hspthreadeddb.dy" void * threaddb_load_worker(void * d) { HSPDatabaseSegment * seg = (HSPDatabaseSegment *) d; Sequence * seq = NULL; long int temp_count; int ret; long load_count = 0; while( 1 ) { /* try to get lock */ if( pthread_mutex_lock(seg->dblock) != 0 ) { fatal("Unable to get mutex lock"); } /* try to get this sequence */ if( *seg->is_first == 1 ) { seq = init_SequenceDB(seg->loaddb,&ret); *seg->is_first = 0; } else { seq = get_next_SequenceDB(seg->loaddb); } /* if seq is NULL, or count > truncate end db */ if( seq == NULL || (seg->load_para->truncate> 0 && *seg->count > seg->load_para->truncate) ) { info("Thread loaded %d entries",load_count); pthread_mutex_unlock(seg->dblock); return NULL; } /* if not, up count, check if we need to report */ (*seg->count)++; temp_count = *seg->count; /* can now remove lock */ pthread_mutex_unlock(seg->dblock); if( seg->load_para->report_stagger > 0 && (temp_count % seg->load_para->report_stagger == 0) ) { info("Threaded db load %d sequences for sli %d at %s",temp_count,seg->sli,seq->name); } /* now we need to add this sequence */ add_SeqLookupInterface(seg->sli,seq); load_count++; (*seg->sli->add_seq)(seg->sli->data,seq,seg->load_para); } return NULL; } # line 326 "hspthreadeddb.c" /* Function: hard_link_HSPDatabaseSegment(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPDatabaseSegment *] * * Return [UNKN ] Undocumented return value [HSPDatabaseSegment *] * */ HSPDatabaseSegment * hard_link_HSPDatabaseSegment(HSPDatabaseSegment * obj) { if( obj == NULL ) { warn("Trying to hard link to a HSPDatabaseSegment object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HSPDatabaseSegment_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPDatabaseSegment *] * */ HSPDatabaseSegment * HSPDatabaseSegment_alloc(void) { HSPDatabaseSegment * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HSPDatabaseSegment *) ckalloc (sizeof(HSPDatabaseSegment))) == NULL) { warn("HSPDatabaseSegment_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->hspi = NULL; out->sli = NULL; return out; } /* Function: free_HSPDatabaseSegment(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPDatabaseSegment *] * * Return [UNKN ] Undocumented return value [HSPDatabaseSegment *] * */ HSPDatabaseSegment * free_HSPDatabaseSegment(HSPDatabaseSegment * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HSPDatabaseSegment obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->hspi != NULL) free_HSPScanInterface(obj->hspi); if( obj->sli != NULL) free_SeqLookupInterface(obj->sli); /* obj->query is linked in */ /* obj->run_para is linked in */ /* obj->lm is linked in */ /* obj->load_para is linked in */ /* obj->loaddb is linked in */ /* obj->dblock is linked in */ /* obj->count is linked in */ /* obj->is_first is linked in */ ckfree(obj); return NULL; } /* Function: swap_HSPThreadedDatabase(list,i,j) * * Descrip: swap function: an internal for qsort_HSPThreadedDatabase * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [HSPDatabaseSegment **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_HSPThreadedDatabase(HSPDatabaseSegment ** list,int i,int j) { HSPDatabaseSegment * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_HSPThreadedDatabase(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_HSPThreadedDatabase which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [HSPDatabaseSegment **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_HSPThreadedDatabase(HSPDatabaseSegment ** list,int left,int right,int (*comp)(HSPDatabaseSegment * ,HSPDatabaseSegment * )) { int i,last; if( left >= right ) return; swap_HSPThreadedDatabase(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_HSPThreadedDatabase (list,++last,i); } swap_HSPThreadedDatabase (list,left,last); qsort_HSPThreadedDatabase(list,left,last-1,comp); qsort_HSPThreadedDatabase(list,last+1,right,comp); } /* Function: sort_HSPThreadedDatabase(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_HSPThreadedDatabase * * * Arg: obj [UNKN ] Object containing list [HSPThreadedDatabase *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_HSPThreadedDatabase(HSPThreadedDatabase * obj,int (*comp)(HSPDatabaseSegment *, HSPDatabaseSegment *)) { qsort_HSPThreadedDatabase(obj->seg,0,obj->len-1,comp); return; } /* Function: expand_HSPThreadedDatabase(obj,len) * * Descrip: Really an internal function for add_HSPThreadedDatabase * * * Arg: obj [UNKN ] Object which contains the list [HSPThreadedDatabase *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_HSPThreadedDatabase(HSPThreadedDatabase * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_HSPThreadedDatabase called with no need"); return TRUE; } if( (obj->seg = (HSPDatabaseSegment ** ) ckrealloc (obj->seg,sizeof(HSPDatabaseSegment *)*len)) == NULL) { warn("ckrealloc failed for expand_HSPThreadedDatabase, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_HSPThreadedDatabase(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [HSPThreadedDatabase *] * Arg: add [OWNER] Object to add to the list [HSPDatabaseSegment *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_HSPThreadedDatabase(HSPThreadedDatabase * obj,HSPDatabaseSegment * add) { if( obj->len >= obj->maxlen) { if( expand_HSPThreadedDatabase(obj,obj->len + HSPThreadedDatabaseLISTLENGTH) == FALSE) return FALSE; } obj->seg[obj->len++]=add; return TRUE; } /* Function: flush_HSPThreadedDatabase(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [HSPThreadedDatabase *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_HSPThreadedDatabase(HSPThreadedDatabase * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->seg[i] != NULL) { free_HSPDatabaseSegment(obj->seg[i]); obj->seg[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: HSPThreadedDatabase_alloc_std(void) * * Descrip: Equivalent to HSPThreadedDatabase_alloc_len(HSPThreadedDatabaseLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [HSPThreadedDatabase *] * */ HSPThreadedDatabase * HSPThreadedDatabase_alloc_std(void) { return HSPThreadedDatabase_alloc_len(HSPThreadedDatabaseLISTLENGTH); } /* Function: HSPThreadedDatabase_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [HSPThreadedDatabase *] * */ HSPThreadedDatabase * HSPThreadedDatabase_alloc_len(int len) { HSPThreadedDatabase * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = HSPThreadedDatabase_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->seg = (HSPDatabaseSegment ** ) ckcalloc (len,sizeof(HSPDatabaseSegment *))) == NULL) { warn("Warning, ckcalloc failed in HSPThreadedDatabase_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_HSPThreadedDatabase(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPThreadedDatabase *] * * Return [UNKN ] Undocumented return value [HSPThreadedDatabase *] * */ HSPThreadedDatabase * hard_link_HSPThreadedDatabase(HSPThreadedDatabase * obj) { if( obj == NULL ) { warn("Trying to hard link to a HSPThreadedDatabase object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: HSPThreadedDatabase_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPThreadedDatabase *] * */ HSPThreadedDatabase * HSPThreadedDatabase_alloc(void) { HSPThreadedDatabase * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(HSPThreadedDatabase *) ckalloc (sizeof(HSPThreadedDatabase))) == NULL) { warn("HSPThreadedDatabase_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->seg = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_HSPThreadedDatabase(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPThreadedDatabase *] * * Return [UNKN ] Undocumented return value [HSPThreadedDatabase *] * */ HSPThreadedDatabase * free_HSPThreadedDatabase(HSPThreadedDatabase * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a HSPThreadedDatabase obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->seg != NULL) { for(i=0;ilen;i++) { if( obj->seg[i] != NULL) free_HSPDatabaseSegment(obj->seg[i]); } ckfree(obj->seg); } ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/hspthreadeddb.h0000644000175000001440000002445010670453712017615 0ustar philippusers#ifndef DYNAMITEhspthreadeddbHEADERFILE #define DYNAMITEhspthreadeddbHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "hsplookupscan.h" #include "arrayseqlookup.h" #define HSPThreadedDatabaseLISTLENGTH 32 #define DBTHREAD_MAX_SIZE 64 struct Wise2_HSPDatabaseSegment { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif HSPScanInterface * hspi; SeqLookupInterface * sli; Sequence * query; /* for running */ HSPScanInterfacePara * run_para; /* for running */ LinearHSPmanager * lm; /* for retrieving results */ SeqLookupLoadPara * load_para; /* for loading */ SequenceDB * loaddb; /* for loading */ pthread_mutex_t * dblock; /* for loading */ long int * count; /* for loading */ boolean * is_first; /* for loading */ } ; /* HSPDatabaseSegment defined */ #ifndef DYNAMITE_DEFINED_HSPDatabaseSegment typedef struct Wise2_HSPDatabaseSegment Wise2_HSPDatabaseSegment; #define HSPDatabaseSegment Wise2_HSPDatabaseSegment #define DYNAMITE_DEFINED_HSPDatabaseSegment #endif struct Wise2_HSPThreadedDatabase { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif HSPDatabaseSegment ** seg; int len;/* len for above seg */ int maxlen; /* maxlen for above seg */ } ; /* HSPThreadedDatabase defined */ #ifndef DYNAMITE_DEFINED_HSPThreadedDatabase typedef struct Wise2_HSPThreadedDatabase Wise2_HSPThreadedDatabase; #define HSPThreadedDatabase Wise2_HSPThreadedDatabase #define DYNAMITE_DEFINED_HSPThreadedDatabase #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_HSPScanInterface_from_HSPThreadedDatabase(tdb) * * Descrip: Makes a HSPScanInterface from a loaded threaded database * * * Arg: tdb [UNKN ] Undocumented argument [HSPThreadedDatabase *] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ HSPScanInterface * Wise2_new_HSPScanInterface_from_HSPThreadedDatabase(HSPThreadedDatabase * tdb); #define new_HSPScanInterface_from_HSPThreadedDatabase Wise2_new_HSPScanInterface_from_HSPThreadedDatabase /* Function: free_data_hspthreadeddb(d) * * Descrip: frees data * * * Arg: d [UNKN ] Undocumented argument [void *] * */ void Wise2_free_data_hspthreadeddb(void * d); #define free_data_hspthreadeddb Wise2_free_data_hspthreadeddb /* Function: scan_query_hspthreadeddb(d,query,para) * * Descrip: Does the scan query for the HSPThreadedDatabase * * * Arg: d [UNKN ] Undocumented argument [void *] * Arg: query [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_scan_query_hspthreadeddb(void * d,Sequence * query,HSPScanInterfacePara * para); #define scan_query_hspthreadeddb Wise2_scan_query_hspthreadeddb /* Function: threadeddb_scan_worker(d) * * Descrip: internal scan function * * * Arg: d [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * Wise2_threadeddb_scan_worker(void * d); #define threadeddb_scan_worker Wise2_threadeddb_scan_worker /* Function: new_HSPThreadedDatabase(segments,array_numb_level) * * Descrip: Makes a new segmented database suitable for * threading * * * Arg: segments [UNKN ] Undocumented argument [int] * Arg: array_numb_level [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPThreadedDatabase *] * */ HSPThreadedDatabase * Wise2_new_HSPThreadedDatabase(int segments,int array_numb_level); #define new_HSPThreadedDatabase Wise2_new_HSPThreadedDatabase /* Function: load_HSPThreadedDatabase(db,sdb,para,mat,drop_off,score_cutoff) * * Descrip: Loades a segmented database * * * Arg: db [UNKN ] Undocumented argument [HSPThreadedDatabase *] * Arg: sdb [UNKN ] Undocumented argument [SequenceDB *] * Arg: para [UNKN ] Undocumented argument [SeqLookupLoadPara *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * */ void Wise2_load_HSPThreadedDatabase(HSPThreadedDatabase * db,SequenceDB * sdb,SeqLookupLoadPara * para,CompMat * mat,int drop_off,int score_cutoff); #define load_HSPThreadedDatabase Wise2_load_HSPThreadedDatabase /* Function: threaddb_load_worker(d) * * Descrip: load threaddb * * * Arg: d [UNKN ] Undocumented argument [void *] * * Return [UNKN ] Undocumented return value [void *] * */ void * Wise2_threaddb_load_worker(void * d); #define threaddb_load_worker Wise2_threaddb_load_worker /* Function: hard_link_HSPDatabaseSegment(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPDatabaseSegment *] * * Return [UNKN ] Undocumented return value [HSPDatabaseSegment *] * */ HSPDatabaseSegment * Wise2_hard_link_HSPDatabaseSegment(HSPDatabaseSegment * obj); #define hard_link_HSPDatabaseSegment Wise2_hard_link_HSPDatabaseSegment /* Function: HSPDatabaseSegment_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPDatabaseSegment *] * */ HSPDatabaseSegment * Wise2_HSPDatabaseSegment_alloc(void); #define HSPDatabaseSegment_alloc Wise2_HSPDatabaseSegment_alloc /* Function: free_HSPDatabaseSegment(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPDatabaseSegment *] * * Return [UNKN ] Undocumented return value [HSPDatabaseSegment *] * */ HSPDatabaseSegment * Wise2_free_HSPDatabaseSegment(HSPDatabaseSegment * obj); #define free_HSPDatabaseSegment Wise2_free_HSPDatabaseSegment /* Function: add_HSPThreadedDatabase(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [HSPThreadedDatabase *] * Arg: add [OWNER] Object to add to the list [HSPDatabaseSegment *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_HSPThreadedDatabase(HSPThreadedDatabase * obj,HSPDatabaseSegment * add); #define add_HSPThreadedDatabase Wise2_add_HSPThreadedDatabase /* Function: flush_HSPThreadedDatabase(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [HSPThreadedDatabase *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_HSPThreadedDatabase(HSPThreadedDatabase * obj); #define flush_HSPThreadedDatabase Wise2_flush_HSPThreadedDatabase /* Function: HSPThreadedDatabase_alloc_std(void) * * Descrip: Equivalent to HSPThreadedDatabase_alloc_len(HSPThreadedDatabaseLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [HSPThreadedDatabase *] * */ HSPThreadedDatabase * Wise2_HSPThreadedDatabase_alloc_std(void); #define HSPThreadedDatabase_alloc_std Wise2_HSPThreadedDatabase_alloc_std /* Function: HSPThreadedDatabase_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [HSPThreadedDatabase *] * */ HSPThreadedDatabase * Wise2_HSPThreadedDatabase_alloc_len(int len); #define HSPThreadedDatabase_alloc_len Wise2_HSPThreadedDatabase_alloc_len /* Function: hard_link_HSPThreadedDatabase(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [HSPThreadedDatabase *] * * Return [UNKN ] Undocumented return value [HSPThreadedDatabase *] * */ HSPThreadedDatabase * Wise2_hard_link_HSPThreadedDatabase(HSPThreadedDatabase * obj); #define hard_link_HSPThreadedDatabase Wise2_hard_link_HSPThreadedDatabase /* Function: HSPThreadedDatabase_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [HSPThreadedDatabase *] * */ HSPThreadedDatabase * Wise2_HSPThreadedDatabase_alloc(void); #define HSPThreadedDatabase_alloc Wise2_HSPThreadedDatabase_alloc /* Function: free_HSPThreadedDatabase(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [HSPThreadedDatabase *] * * Return [UNKN ] Undocumented return value [HSPThreadedDatabase *] * */ HSPThreadedDatabase * Wise2_free_HSPThreadedDatabase(HSPThreadedDatabase * obj); #define free_HSPThreadedDatabase Wise2_free_HSPThreadedDatabase /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_HSPThreadedDatabase(HSPDatabaseSegment ** list,int i,int j) ; #define swap_HSPThreadedDatabase Wise2_swap_HSPThreadedDatabase void Wise2_qsort_HSPThreadedDatabase(HSPDatabaseSegment ** list,int left,int right,int (*comp)(HSPDatabaseSegment * ,HSPDatabaseSegment * )); #define qsort_HSPThreadedDatabase Wise2_qsort_HSPThreadedDatabase void Wise2_sort_HSPThreadedDatabase(HSPThreadedDatabase * obj,int (*comp)(HSPDatabaseSegment *, HSPDatabaseSegment *)); #define sort_HSPThreadedDatabase Wise2_sort_HSPThreadedDatabase boolean Wise2_expand_HSPThreadedDatabase(HSPThreadedDatabase * obj,int len); #define expand_HSPThreadedDatabase Wise2_expand_HSPThreadedDatabase #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/dpenvelope.c0000644000175000001440000004111010670453712017140 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dpenvelope.h" /* Function: overlap_DPUnit(a,b) * * Descrip: Helper function that checks whether things overlap or not * * * Arg: a [UNKN ] Undocumented argument [DPUnit *] * Arg: b [UNKN ] Undocumented argument [DPUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 37 "dpenvelope.dy" boolean overlap_DPUnit(DPUnit * a,DPUnit * b) { int diag_a; int diag_b; if( a->type == DPENV_DIAG && b->type == DPENV_DIAG ) { diag_a = a->starti - a->startj; diag_b = b->starti - b->startj; if( diag_a - a->height > diag_b + b->height || diag_a + a->height < diag_b + b->height ) { return FALSE; } diag_a = a->starti + a->startj; diag_b = b->starti + b->startj; if( diag_a + a->length < diag_b || diag_a > diag_b + b->length ) { return FALSE; } return TRUE; } if( a->type == DPENV_RECT && b->type == DPENV_RECT ) { fatal("Not implemented rectangle overlap!"); } fatal("Not implemented rectangle - diag overlap!"); } /* Function: read_DPEnvelope_file(filename) * * Descrip: Helper function that also opens the filename * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ # line 73 "dpenvelope.dy" DPEnvelope * read_DPEnvelope_file(char * filename) { FILE * ifp; DPEnvelope * dpenv; ifp = openfile(filename,"r"); if( ifp == NULL ) { error("Could not open file with %s",filename); return NULL; } dpenv = read_DPEnvelope(ifp); fclose(ifp); return dpenv; } /* Function: read_DPEnvelope(ifp) * * Descrip: Reads a DPEnvelope from a file * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ # line 95 "dpenvelope.dy" DPEnvelope * read_DPEnvelope(FILE * ifp) { char buffer[MAXLINE]; char ** base; char ** str; DPEnvelope * out; DPUnit * unit; out = DPEnvelope_alloc_std(); while( fgets(buffer,MAXLINE,ifp) != NULL ) { base = str = breakstring(buffer,spacestr); unit = DPUnit_alloc(); add_DPEnvelope(out,unit); if( strcmp(*str,"rect") == 0 ) { unit->type = DPENV_RECT; } else if ( strcmp(*str,"diag") == 0 ) { unit->type = DPENV_DIAG; } else { error("Cannot parse DPEnv file"); continue; } str++; if( *str == NULL ) { error("Cannot parse DPEnv file"); continue; } unit->starti = atoi(*str); str++; if( *str == NULL ) { error("Cannot parse DPEnv file"); continue; } unit->startj = atoi(*str); str++; if( *str == NULL ) { error("Cannot parse DPEnv file"); continue; } unit->height = atoi(*str); str++; if( *str == NULL ) { error("Cannot parse DPEnv file"); continue; } unit->length = atoi(*str); } return out; } /* Function: show_DPEnvelope(dpe,ofp) * * Descrip: shows structure. useful for debugging * * * Arg: dpe [UNKN ] Undocumented argument [DPEnvelope *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 157 "dpenvelope.dy" void show_DPEnvelope(DPEnvelope * dpe,FILE * ofp) { int i; for(i=0;ilen;i++) { fprintf(ofp,"Unit %d [%s] Start %d-%d Height: %d Length: %d\n",i,dpe->dpu[i]->type == DPENV_RECT ? "rect" : "diag",dpe->dpu[i]->starti,dpe->dpu[i]->startj,dpe->dpu[i]->height,dpe->dpu[i]->length); } } /* Function: is_in_DPEnvelope(dpe,i,j) * * Descrip: Tests whether this i,j position is allowed in the * DPEnvelope * * * Arg: dpe [UNKN ] Undocumented argument [DPEnvelope *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 171 "dpenvelope.dy" boolean is_in_DPEnvelope(DPEnvelope * dpe,int i,int j) { int k; for(k=0;klen;k++) { auto DPUnit * u; u = dpe->dpu[k]; switch (u->type) { case DPENV_RECT : if( i >= u->starti && j >= u->startj && i <= (u->starti+u->height) && j <= (u->startj+u->length) ) return TRUE; else break; case DPENV_DIAG : if( abs( (i-j) - (u->starti-u->startj)) <= u->height && i+j >= u->starti+u->startj && i+j+u->length >= u->starti+u->startj) return TRUE; break; default : warn("Bad DPUnit type put in. Yuk. Bad error... %d",u->type); return FALSE; } } return FALSE; } /* Function: prepare_DPEnvelope(dpe) * * Descrip: Should run this before using the DPEnvelope * * * Arg: dpe [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 205 "dpenvelope.dy" boolean prepare_DPEnvelope(DPEnvelope * dpe) { int i; dpe->starti = 1000000; dpe->startj = 1000000; dpe->endi = 1; dpe->endj = 1; sort_DPEnvelope_by_startj(dpe); for(i=0;ilen;i++) { if( dpe->dpu[i]->type == DPENV_RECT ) { if( dpe->starti > dpe->dpu[i]->starti-1 ) { dpe->starti = dpe->dpu[i]->starti-1; } if( dpe->startj > dpe->dpu[i]->startj-1 ) { dpe->startj = dpe->dpu[i]->startj-1; } if( dpe->endi < dpe->dpu[i]->starti+ dpe->dpu[i]->height ) { dpe->endi = dpe->dpu[i]->starti+ dpe->dpu[i]->height; } if( dpe->endj < dpe->dpu[i]->startj + dpe->dpu[i]->length ) { dpe->endj = dpe->dpu[i]->startj + dpe->dpu[i]->length; } } else { /* DIAG */ if( dpe->starti > dpe->dpu[i]->starti-dpe->dpu[i]->height ) { dpe->starti = dpe->dpu[i]->starti-dpe->dpu[i]->height; } if( dpe->startj > dpe->dpu[i]->startj-dpe->dpu[i]->height ) { dpe->startj = dpe->dpu[i]->startj-dpe->dpu[i]->height; } if( dpe->endi < dpe->dpu[i]->starti+ dpe->dpu[i]->length+dpe->dpu[i]->height ) { dpe->endi = dpe->dpu[i]->starti+ dpe->dpu[i]->length + dpe->dpu[i]->height; } if( dpe->endj < dpe->dpu[i]->startj + dpe->dpu[i]->length + dpe->dpu[i]->height ) { dpe->endj = dpe->dpu[i]->startj + dpe->dpu[i]->length + dpe->dpu[i]->height; } } } return TRUE; } /* Function: sort_DPEnvelope_by_startj(dpe) * * Descrip: Sorts by startj * * * Arg: dpe [UNKN ] Undocumented argument [DPEnvelope *] * */ # line 252 "dpenvelope.dy" void sort_DPEnvelope_by_startj(DPEnvelope * dpe) { sort_DPEnvelope(dpe,compare_DPUnit_startj); } /* Function: compare_DPUnit_startj(one,two) * * Descrip: internal for sort by startj * * * Arg: one [UNKN ] Undocumented argument [DPUnit *] * Arg: two [UNKN ] Undocumented argument [DPUnit *] * * Return [UNKN ] Undocumented return value [int] * */ # line 261 "dpenvelope.dy" int compare_DPUnit_startj(DPUnit * one,DPUnit * two) { return one->startj - two->startj; } # line 291 "dpenvelope.c" /* Function: hard_link_DPUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DPUnit *] * * Return [UNKN ] Undocumented return value [DPUnit *] * */ DPUnit * hard_link_DPUnit(DPUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a DPUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DPUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DPUnit *] * */ DPUnit * DPUnit_alloc(void) { DPUnit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DPUnit *) ckalloc (sizeof(DPUnit))) == NULL) { warn("DPUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = DPENV_RECT; out->starti = 0; out->startj = 0; out->height = 0; out->length = 0; return out; } /* Function: free_DPUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DPUnit *] * * Return [UNKN ] Undocumented return value [DPUnit *] * */ DPUnit * free_DPUnit(DPUnit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DPUnit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_DPEnvelope(list,i,j) * * Descrip: swap function: an internal for qsort_DPEnvelope * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [DPUnit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_DPEnvelope(DPUnit ** list,int i,int j) { DPUnit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_DPEnvelope(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_DPEnvelope which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [DPUnit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_DPEnvelope(DPUnit ** list,int left,int right,int (*comp)(DPUnit * ,DPUnit * )) { int i,last; if( left >= right ) return; swap_DPEnvelope(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_DPEnvelope (list,++last,i); } swap_DPEnvelope (list,left,last); qsort_DPEnvelope(list,left,last-1,comp); qsort_DPEnvelope(list,last+1,right,comp); } /* Function: sort_DPEnvelope(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_DPEnvelope * * * Arg: obj [UNKN ] Object containing list [DPEnvelope *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_DPEnvelope(DPEnvelope * obj,int (*comp)(DPUnit *, DPUnit *)) { qsort_DPEnvelope(obj->dpu,0,obj->len-1,comp); return; } /* Function: expand_DPEnvelope(obj,len) * * Descrip: Really an internal function for add_DPEnvelope * * * Arg: obj [UNKN ] Object which contains the list [DPEnvelope *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_DPEnvelope(DPEnvelope * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_DPEnvelope called with no need"); return TRUE; } if( (obj->dpu = (DPUnit ** ) ckrealloc (obj->dpu,sizeof(DPUnit *)*len)) == NULL) { warn("ckrealloc failed for expand_DPEnvelope, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_DPEnvelope(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DPEnvelope *] * Arg: add [OWNER] Object to add to the list [DPUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_DPEnvelope(DPEnvelope * obj,DPUnit * add) { if( obj->len >= obj->maxlen) { if( expand_DPEnvelope(obj,obj->len + DPEnvelopeLISTLENGTH) == FALSE) return FALSE; } obj->dpu[obj->len++]=add; return TRUE; } /* Function: flush_DPEnvelope(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DPEnvelope *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_DPEnvelope(DPEnvelope * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->dpu[i] != NULL) { free_DPUnit(obj->dpu[i]); obj->dpu[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: DPEnvelope_alloc_std(void) * * Descrip: Equivalent to DPEnvelope_alloc_len(DPEnvelopeLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ DPEnvelope * DPEnvelope_alloc_std(void) { return DPEnvelope_alloc_len(DPEnvelopeLISTLENGTH); } /* Function: DPEnvelope_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ DPEnvelope * DPEnvelope_alloc_len(int len) { DPEnvelope * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = DPEnvelope_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->dpu = (DPUnit ** ) ckcalloc (len,sizeof(DPUnit *))) == NULL) { warn("Warning, ckcalloc failed in DPEnvelope_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_DPEnvelope(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DPEnvelope *] * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ DPEnvelope * hard_link_DPEnvelope(DPEnvelope * obj) { if( obj == NULL ) { warn("Trying to hard link to a DPEnvelope object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DPEnvelope_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ DPEnvelope * DPEnvelope_alloc(void) { DPEnvelope * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DPEnvelope *) ckalloc (sizeof(DPEnvelope))) == NULL) { warn("DPEnvelope_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->dpu = NULL; out->len = out->maxlen = 0; out->bbox = NULL; out->starti = 0; out->startj = 0; out->endi = 0; out->endj = 0; return out; } /* Function: free_DPEnvelope(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DPEnvelope *] * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ DPEnvelope * free_DPEnvelope(DPEnvelope * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DPEnvelope obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->dpu != NULL) { for(i=0;ilen;i++) { if( obj->dpu[i] != NULL) free_DPUnit(obj->dpu[i]); } ckfree(obj->dpu); } if( obj->bbox != NULL) free_DPUnit(obj->bbox); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/dpenvelope.h0000644000175000001440000002061110670453712017150 0ustar philippusers#ifndef DYNAMITEdpenvelopeHEADERFILE #define DYNAMITEdpenvelopeHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" typedef enum dpenvelope_type { DPENV_RECT = 0, DPENV_DIAG } dpenv_type; #define DPEnvelopeLISTLENGTH 32 struct Wise2_DPUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; int starti; int startj; int height; /* for diagonal units */ int length; /* for diagonal units */ } ; /* DPUnit defined */ #ifndef DYNAMITE_DEFINED_DPUnit typedef struct Wise2_DPUnit Wise2_DPUnit; #define DPUnit Wise2_DPUnit #define DYNAMITE_DEFINED_DPUnit #endif struct Wise2_DPEnvelope { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DPUnit ** dpu; int len;/* len for above dpu */ int maxlen; /* maxlen for above dpu */ DPUnit * bbox; int starti; int startj; int endi; int endj; } ; /* DPEnvelope defined */ #ifndef DYNAMITE_DEFINED_DPEnvelope typedef struct Wise2_DPEnvelope Wise2_DPEnvelope; #define DPEnvelope Wise2_DPEnvelope #define DYNAMITE_DEFINED_DPEnvelope #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: overlap_DPUnit(a,b) * * Descrip: Helper function that checks whether things overlap or not * * * Arg: a [UNKN ] Undocumented argument [DPUnit *] * Arg: b [UNKN ] Undocumented argument [DPUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_overlap_DPUnit(DPUnit * a,DPUnit * b); #define overlap_DPUnit Wise2_overlap_DPUnit /* Function: read_DPEnvelope_file(filename) * * Descrip: Helper function that also opens the filename * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ DPEnvelope * Wise2_read_DPEnvelope_file(char * filename); #define read_DPEnvelope_file Wise2_read_DPEnvelope_file /* Function: read_DPEnvelope(ifp) * * Descrip: Reads a DPEnvelope from a file * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ DPEnvelope * Wise2_read_DPEnvelope(FILE * ifp); #define read_DPEnvelope Wise2_read_DPEnvelope /* Function: show_DPEnvelope(dpe,ofp) * * Descrip: shows structure. useful for debugging * * * Arg: dpe [UNKN ] Undocumented argument [DPEnvelope *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_DPEnvelope(DPEnvelope * dpe,FILE * ofp); #define show_DPEnvelope Wise2_show_DPEnvelope /* Function: is_in_DPEnvelope(dpe,i,j) * * Descrip: Tests whether this i,j position is allowed in the * DPEnvelope * * * Arg: dpe [UNKN ] Undocumented argument [DPEnvelope *] * Arg: i [UNKN ] Undocumented argument [int] * Arg: j [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_in_DPEnvelope(DPEnvelope * dpe,int i,int j); #define is_in_DPEnvelope Wise2_is_in_DPEnvelope /* Function: prepare_DPEnvelope(dpe) * * Descrip: Should run this before using the DPEnvelope * * * Arg: dpe [UNKN ] Undocumented argument [DPEnvelope *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_prepare_DPEnvelope(DPEnvelope * dpe); #define prepare_DPEnvelope Wise2_prepare_DPEnvelope /* Function: sort_DPEnvelope_by_startj(dpe) * * Descrip: Sorts by startj * * * Arg: dpe [UNKN ] Undocumented argument [DPEnvelope *] * */ void Wise2_sort_DPEnvelope_by_startj(DPEnvelope * dpe); #define sort_DPEnvelope_by_startj Wise2_sort_DPEnvelope_by_startj /* Function: hard_link_DPUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DPUnit *] * * Return [UNKN ] Undocumented return value [DPUnit *] * */ DPUnit * Wise2_hard_link_DPUnit(DPUnit * obj); #define hard_link_DPUnit Wise2_hard_link_DPUnit /* Function: DPUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DPUnit *] * */ DPUnit * Wise2_DPUnit_alloc(void); #define DPUnit_alloc Wise2_DPUnit_alloc /* Function: free_DPUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DPUnit *] * * Return [UNKN ] Undocumented return value [DPUnit *] * */ DPUnit * Wise2_free_DPUnit(DPUnit * obj); #define free_DPUnit Wise2_free_DPUnit /* Function: add_DPEnvelope(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [DPEnvelope *] * Arg: add [OWNER] Object to add to the list [DPUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_DPEnvelope(DPEnvelope * obj,DPUnit * add); #define add_DPEnvelope Wise2_add_DPEnvelope /* Function: flush_DPEnvelope(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [DPEnvelope *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_DPEnvelope(DPEnvelope * obj); #define flush_DPEnvelope Wise2_flush_DPEnvelope /* Function: DPEnvelope_alloc_std(void) * * Descrip: Equivalent to DPEnvelope_alloc_len(DPEnvelopeLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ DPEnvelope * Wise2_DPEnvelope_alloc_std(void); #define DPEnvelope_alloc_std Wise2_DPEnvelope_alloc_std /* Function: DPEnvelope_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ DPEnvelope * Wise2_DPEnvelope_alloc_len(int len); #define DPEnvelope_alloc_len Wise2_DPEnvelope_alloc_len /* Function: hard_link_DPEnvelope(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DPEnvelope *] * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ DPEnvelope * Wise2_hard_link_DPEnvelope(DPEnvelope * obj); #define hard_link_DPEnvelope Wise2_hard_link_DPEnvelope /* Function: DPEnvelope_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ DPEnvelope * Wise2_DPEnvelope_alloc(void); #define DPEnvelope_alloc Wise2_DPEnvelope_alloc /* Function: free_DPEnvelope(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DPEnvelope *] * * Return [UNKN ] Undocumented return value [DPEnvelope *] * */ DPEnvelope * Wise2_free_DPEnvelope(DPEnvelope * obj); #define free_DPEnvelope Wise2_free_DPEnvelope /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_compare_DPUnit_startj(DPUnit * one,DPUnit * two); #define compare_DPUnit_startj Wise2_compare_DPUnit_startj void Wise2_swap_DPEnvelope(DPUnit ** list,int i,int j) ; #define swap_DPEnvelope Wise2_swap_DPEnvelope void Wise2_qsort_DPEnvelope(DPUnit ** list,int left,int right,int (*comp)(DPUnit * ,DPUnit * )); #define qsort_DPEnvelope Wise2_qsort_DPEnvelope void Wise2_sort_DPEnvelope(DPEnvelope * obj,int (*comp)(DPUnit *, DPUnit *)); #define sort_DPEnvelope Wise2_sort_DPEnvelope boolean Wise2_expand_DPEnvelope(DPEnvelope * obj,int len); #define expand_DPEnvelope Wise2_expand_DPEnvelope #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/proteinstreamedindex.dy0000644000175000001440000002532107621664104021435 0ustar philippusers %{ #include "sequence.h" #include "seqlookup.h" #include "genericindexresult.h" typedef struct ProteinStreamedIndexWayPost { Sequence * seq; int pos; } ProteinStreamedIndexWayPost; typedef struct ProteinStreamedIndexPos { int count; struct ProteinStreamedIndexPos * first_prev; struct ProteinStreamedIndexPos ** prev; int prev_len; struct ProteinStreamedIndexWayPost * post; int post_len; int post_maxlen; } ProteinStreamedIndexPos; #define PROTEINSTREAMEDINDEX_PREV_START 4 #define PROTEINSTREAMEDINDEX_WAY_START 2 typedef struct ProteinStreamedIndex { ProteinStreamedIndexPos ** index; int len; int waypost_depth; } ProteinStreamedIndex; %} %{ #include "proteinstreamedindex.h" typedef struct ProteinStreamedClient_struct { GenericIndexResult result; SeqLookupResultInterface interface; ProteinStreamedIndex * index; } ProteinStreamedClient; static ProteinStreamedClient * ProteinStreamedClient_alloc(void) { ProteinStreamedClient * out; out = malloc(sizeof(ProteinStreamedClient)); return out; } %func Provides a SeqLookupInterface, the common runtime plug-in for indexers using a ProteinStreamedIndex %% SeqLookupInterface * new_ProteinStreamedIndex_SeqLookupInterface(int waypost) { SeqLookupInterface * out; ProteinStreamedIndex * in; in = new_ProteinStreamedIndex(waypost); out = SeqLookupInterface_alloc_std(); out->get_client = get_client_interface_ProteinStreamedIndex; out->add_seq = add_seq_interface_ProteinStreamedIndex; out->free_data = free_interface_ProteinStreamedIndex; out->lookup_array_head = NULL; out->data = (void*) in; return out; } %func gets client interface %% SeqLookupClientInterface * get_client_interface_ProteinStreamedIndex(void* data) { ProteinStreamedIndex * index = (ProteinStreamedIndex*) data; SeqLookupClientInterface * slci; ProteinStreamedClient * pcl; pcl = ProteinStreamedClient_alloc(); pcl->result.result = calloc(64,sizeof(SeqLookupResultStruct)); pcl->result.max_len = 64; pcl->result.len = 0; pcl->interface.next = next_interface_GenericIndexResult; pcl->interface.is_more = is_more_interface_GenericIndexResult; pcl->interface.free_data = free_noop_GenericIndexResult; pcl->interface.data = (void*) &(pcl->result); pcl->index = index; slci = SeqLookupClientInterface_alloc(); slci->lookup = lookup_interface_ProteinStreamedClient; slci->is_populated = is_populated_interface_ProteinStreamedClient; slci->free_data = free_interface_ProteinStreamedClient; slci->data = (void*) pcl; return slci; } %func For lookup interface, provides a result %% SeqLookupResultInterface * lookup_interface_ProteinStreamedClient(void * data,int seq_number) { ProteinStreamedClient * cli= (ProteinStreamedClient*) data; ProteinStreamedIndex * in = cli->index; /* reset pointers */ cli->result.current_pos = 0; cli->result.len = 0; if( lookup_ProteinStreamedIndex(in,seq_number,&cli->result) == FALSE ) { return NULL; } return &cli->interface; } %func populated function for interface %% boolean is_populated_interface_ProteinStreamedClient(void * data,int seq_number) { ProteinStreamedClient * client = (ProteinStreamedClient*) data; if( client->index->index[seq_number] != NULL ) { return TRUE; } else { return FALSE; } } %func add function for interface %% boolean add_seq_interface_ProteinStreamedIndex(void * data,Sequence * seq,SeqLookupLoadPara * para) { ProteinStreamedIndex * in = (ProteinStreamedIndex*) data; return add_Sequence_ProteinStreamedIndex(in,seq,para); } %func for interface, frees index %% void free_interface_ProteinStreamedIndex(void * data) { ProteinStreamedIndex * in = (ProteinStreamedIndex*) data; free_ProteinStreamedIndex(in); } %func Frees the client data %% void free_interface_ProteinStreamedClient(void * data) { ProteinStreamedClient * cli = (ProteinStreamedClient *)data; free(cli->result.result); free(cli); } static int seq_number_aa_5mer_psi(char * seq) { int i; int ret = 0; int base = 1; int no = 0; for(i=0;i<5;i++) { no = toupper(seq[i])-'A'; if( no > 26 || no < 0 ) { no = 'X'-'A'; } ret += base * no; base = base * 26; } return ret; } %func Traverses index for a particular number to return hits %% boolean lookup_ProteinStreamedIndex(ProteinStreamedIndex * in,int seqno,GenericIndexResult * out) { /* look up this position, return NULL if nothing there */ if( in->index[seqno] == NULL ) { return FALSE; } /* yes, assign the number of counts in walk back up looking for wayposts */ /* start with self */ add_lookup_GenericIndexResult_from_Pos(in->index[seqno],out,0,in->waypost_depth); return TRUE; } %func Adds additional sequences to index result from a particular position %% void add_lookup_GenericIndexResult_from_Pos(ProteinStreamedIndexPos * p,GenericIndexResult * psir,int backtrace,int waylength) { int i; assert(p); assert(psir); /* printf("Entering add with backtrace %d count %d\n",backtrace,p->count);*/ while( p != NULL && backtrace < waylength ) { /* printf("Backtracing.... %d with count %d\n",backtrace,p->count); */ /* test whether this has any wayposts, add them with backtrace */ if( p->post_len > 0 ) { for(i=0;ipost_len;i++) { /* printf("....adding another index... %s, %d\n",p->post[i].seq->name,p->post[i].pos);*/ add_GenericIndexResult(psir,p->post[i].seq,p->post[i].pos+backtrace); } if( p->post_len == p->count ) { /* then we have the finished...*/ /* printf("... finished with %d\n",p->count); */ break; } } backtrace++; if( p->prev != NULL ) { /* have to recurse */ /* first go back up the main stream */ add_lookup_GenericIndexResult_from_Pos(p->first_prev,psir,backtrace,waylength); for(i=0;iprev_len;i++) { if( p->prev[i] == NULL ) { break; } add_lookup_GenericIndexResult_from_Pos(p->prev[i],psir,backtrace,waylength); } /* can assumme this is ok */ break; } else { p = p->first_prev; } } return; } %func Adds in a sequence into a ProteinStreamedIndex %% boolean add_Sequence_ProteinStreamedIndex(ProteinStreamedIndex * in,Sequence * seq,SeqLookupLoadPara * para) { ProteinStreamedIndexPos * prev = NULL; int i; int j; int no; assert(in); assert(seq); if( para->tile_freq > 1 ) { fatal("Cannot have a streamed index with a tile_freq greater than 1. Misparameterisation"); } for(i=0;ilen-5;i++) { no = seq_number_aa_5mer_psi(seq->seq+i); if( in->index[no] == NULL ) { in->index[no] = new_ProteinStreamedIndexPos(); /* because this is a newly allocated index, we can put prev into first_prev now with impunity - the first one will have this as NULL and that is fine */ in->index[no]->first_prev = prev; } in->index[no]->count++; if( prev != NULL ) { /* check that reverse pointer is not present already */ j = 0; if( prev != in->index[no]->first_prev ) { for(j=0;jindex[no]->prev_len;j++) { if( prev == in->index[no]->prev[j] ) { break; } } if( j >= in->index[no]->prev_len ) { /* is not in there, add it */ /* potentially this could be first_prev if this came from the start of another sequence */ if( in->index[no]->first_prev == NULL ) { in->index[no]->first_prev = prev; } else { add_pos_ProteinStreamedIndexPos(in->index[no],prev); } } } } prev = in->index[no]; /* deal with waystations */ if( i == 0 || i % in->waypost_depth == 0 ) { add_waypost_ProteinStreamedIndexPos(in->index[no],seq,i); } } return TRUE; } %func dumps in a silly format the ProteinStreamedIndex; for debugging %% void dump_ProteinStreamedIndex(ProteinStreamedIndex * in,FILE * ofp) { int i,j; int size = 26 * 26 * 26 * 26 * 26; for(i=0;iindex[i] != NULL ) { fprintf(ofp,"Position %d occupied with %d previous\n WayStations ",i,in->index[i]->prev_len); for(j=0;jindex[i]->post_len;j++) { if( in->index[i] == NULL ) { break; } fprintf(ofp," %s [%d],",in->index[i]->post[j].seq->name, in->index[i]->post[j].pos); } fprintf(ofp,"\n"); } } } %func Builds a new ProteinStreamedIndex %% ProteinStreamedIndex * new_ProteinStreamedIndex(int waypost_depth) { ProteinStreamedIndex * out; int size = 26 * 26 * 26 * 26 * 26; out = malloc(sizeof(ProteinStreamedIndex)); assert(out); out->index = calloc(size,sizeof(ProteinStreamedIndexPos*)); out->waypost_depth = waypost_depth; return out; } %func Release protein index %% void free_ProteinStreamedIndex(ProteinStreamedIndex * in) { int i; int size = 26 * 26 * 26 *26 * 26; assert(in); for(i=0;iindex[i] != NULL ) { free_ProteinStreamedIndexPos(in->index[i]); } } free(in->index); free(in); return; } %func Adds a position, advancing array if needed %% boolean add_pos_ProteinStreamedIndexPos(ProteinStreamedIndexPos * pos,ProteinStreamedIndexPos * prev) { int i; if( pos->prev == NULL ) { pos->prev = calloc(PROTEINSTREAMEDINDEX_PREV_START,sizeof(ProteinStreamedIndexPos*)); pos->prev[0] = NULL; pos->prev_len = PROTEINSTREAMEDINDEX_PREV_START; } if( pos->prev[pos->prev_len-1] != NULL ) { /* realloc */ pos->prev = realloc(pos->prev,(2*pos->prev_len)*sizeof(ProteinStreamedIndexPos*)); pos->prev_len = 2*pos->prev_len; } for(i=0;iprev_len;i++) { if( pos->prev[i] == NULL ) { pos->prev[i] = prev; pos->prev[i+1] = NULL; break; } } return TRUE; } %func Adds a way post, advancing array if needed %% boolean add_waypost_ProteinStreamedIndexPos(ProteinStreamedIndexPos * pos,Sequence * seq,int seqpos) { if( pos->post == NULL ) { pos->post = calloc(PROTEINSTREAMEDINDEX_WAY_START,sizeof(ProteinStreamedIndexWayPost)); pos->post_len = 0; pos->post_maxlen = PROTEINSTREAMEDINDEX_WAY_START; } if( pos->post_len >= pos->post_maxlen ) { pos->post = realloc(pos->post,(2*pos->post_maxlen)*sizeof(ProteinStreamedIndexWayPost)); pos->post_maxlen = 2*pos->post_maxlen; } pos->post[pos->post_len].seq = seq; pos->post[pos->post_len].pos = seqpos; pos->post_len++; return TRUE; } %func Creates a new ProteinStreamedIndexPos %% ProteinStreamedIndexPos * new_ProteinStreamedIndexPos(void) { ProteinStreamedIndexPos * out; out = malloc(sizeof(ProteinStreamedIndexPos)); out->count = 0; out->prev = NULL; out->prev_len = 0; out->post = NULL; out->post_len = 0; out->post_maxlen = 0; return out; } %func frees a ProteinStreamedIndexPos %% void free_ProteinStreamedIndexPos(ProteinStreamedIndexPos * pos) { if( pos == NULL ) { return; } free(pos->prev); free(pos->post); free(pos); return; } %} wise-2.4.1/src/dynlibsrc/randommodel.c0000644000175000001440000007246410670453712017320 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "randommodel.h" /* Function: draw_random_aa_RandomModel(rm) * * Descrip: Draws an amino acid from the random distribution * * * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * * Return [UNKN ] Undocumented return value [char] * */ # line 56 "randommodel.dy" char draw_random_aa_RandomModel(RandomModel * rm) { double draw,tot; int i; draw = random_0_to_1(); for(tot=rm->aminoacid[0],i=0;draw > tot && i<26;tot += rm->aminoacid[++i]) ; if( i >= 26 ) { warn("Weird - got a draw %f which outside of random model total %f\n",draw,tot); return '?'; } return 'A'+i; } /* Function: draw_random_base_RandomModelDNA(rm) * * Descrip: Draws a base from the random distribution * * * Arg: rm [UNKN ] Undocumented argument [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [char] * */ # line 74 "randommodel.dy" char draw_random_base_RandomModelDNA(RandomModelDNA * rm) { double draw,tot; int i; draw = random_0_to_1(); for(tot=rm->base[0],i=0;draw > tot && i<4;tot += rm->base[++i]) ; if( i >= 26 ) { warn("Weird - got a draw %f which outside of random model total %f\n",draw,tot); return '?'; } return char_from_base(i); } /* Function: RandomCodonScore_from_RandomCodon(rc) * * Descrip: Makes a score RandomCodon (log space) * from a probability based random codon * * * Arg: rc [UNKN ] Undocumented argument [RandomCodon *] * * Return [UNKN ] Undocumented return value [RandomCodonScore *] * */ # line 94 "randommodel.dy" RandomCodonScore * RandomCodonScore_from_RandomCodon(RandomCodon * rc) { RandomCodonScore * out; out = RandomCodonScore_alloc(); Probability2Score_move(rc->codon,out->codon,126); if( rc-> name != NULL) out->name = stringalloc(rc->name); return out; } /* Function: flatten_RandomCodon(rc) * * Descrip: Sets all probabilities to 1.0 - ie, * odds them to themselves. * * This is equivalent to saying that the randomcodon * is being odd-ratioed to itself * * Also equivalent of saying all the scores (in log * space) will be 0 * * * Arg: rc [UNKN ] Undocumented argument [RandomCodon *] * */ # line 119 "randommodel.dy" void flatten_RandomCodon(RandomCodon * rc) { int i; for(i=0;i<125;i++) rc->codon[i] = 1.0; } /* Function: fold_in_RandomModelDNA_into_RandomCodon(rc,rmd) * * Descrip: Makes the randomcodon numbers become the odds ratio * between their probabilitys and flat dna random model * (0th order markov) * * * Arg: rc [UNKN ] Undocumented argument [RandomCodon *] * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * */ # line 133 "randommodel.dy" void fold_in_RandomModelDNA_into_RandomCodon(RandomCodon * rc,RandomModelDNA * rmd) { register int one; register int two; register int three; if( rc == NULL || rmd == NULL ) { warn("Passed in NULL objects to fold_in_RandomModelDNA_into_RandomCodon"); } for(one=0;one < 5;one++) for(two =0;two<5;two ++) for(three=0;three<5;three++) rc->codon[(one*25)+(two*5)+(three)] /= (rmd->base[one]*rmd->base[two]*rmd->base[three]); } /* Function: show_RandomCodonScore(rcs,ofp) * * Descrip: shows RandomCodonScore * * for debugging * * * Arg: rcs [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 156 "randommodel.dy" void show_RandomCodonScore(RandomCodonScore * rcs,FILE * ofp) { register int i; for(i=0;i<125;i++) { fprintf(ofp,"Score %3d is %d\n",i,rcs->codon[i]); } } /* Function: show_RandomModelDNAScore(rds,ofp) * * Descrip: shows RandomModelsDNAScore * * for debugging * * * Arg: rds [UNKN ] Undocumented argument [RandomModelDNAScore *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 171 "randommodel.dy" void show_RandomModelDNAScore(RandomModelDNAScore * rds,FILE * ofp) { register int i; for(i=0;i<5;i++) { fprintf(ofp,"Base %d[%c], Score %d [prob %.2f]\n",i,char_from_base(i),rds->base[i],Score2Probability(rds->base[i])); } } /* Function: folded_RandomModelDNAScore_from_2RMD(dis,rnd) * * Descrip: gives a odds ratio between two random models * * * Arg: dis [UNKN ] Undocumented argument [RandomModelDNA *] * Arg: rnd [UNKN ] Undocumented argument [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [RandomModelDNAScore *] * */ # line 183 "randommodel.dy" RandomModelDNAScore * folded_RandomModelDNAScore_from_2RMD(RandomModelDNA * dis,RandomModelDNA * rnd) { int i; RandomModelDNAScore * out; out = RandomModelDNAScore_alloc(); for(i=0;i<5;i++) out->base[i]= Probability2Score(dis->base[i]/rnd->base[i]); return out; } /* Function: RandomCodon_from_raw_CodonFrequency(codon[64],*ct) * * Descrip: From raw counts (no adjustment to amino acids) of codons * gives you a RandomCodon model * * No prior is used (? perhaps should have a flat prior) * * N's are handled correctly * * * Arg: codon[64] [UNKN ] Undocumented argument [double] * Arg: *ct [UNKN ] Undocumented argument [CodonTable] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ # line 206 "randommodel.dy" RandomCodon * RandomCodon_from_raw_CodonFrequency(double codon[64],CodonTable *ct) { RandomCodon * out; register int i; double total = 0.0; base one; base two; base three; int o,t,r; /** codon frequencies here *do* include protein amino acid freq... ie, they are raw frequencies, not adjusted for a codon table **/ /** the only thing is that we have to figure out how to deal with N'd codons, which will just be summed over... **/ out= RandomCodon_alloc(); for(i=0;i<64;i++) { total += codon[i]; } for(i=0;i<125;i++) { if( has_random_bases(i) == FALSE ) { out->codon[i] = codon[base4_codon_from_codon(i)]/total; } else { all_bases_from_codon(i,&one,&two,&three); if( one == BASE_N && two != BASE_N && three != BASE_N ) { for(o=0;o<4;o++) out->codon[i] += (codon[o*16+two*4+three]/total); } else if( one == BASE_N && two == BASE_N && three != BASE_N) { for(o=0;o<4;o++) for(t=0;t<4;t++) out->codon[i] += (codon[o*16+t*4+three]/total); } else if( one == BASE_N && two == BASE_N && three == BASE_N) { for(o=0;o<4;o++) for(t=0;t<4;t++) for(r=0;r<4;r++) out->codon[i] += (codon[o*16+t*4+r]/total); } else if( one != BASE_N && two == BASE_N && three != BASE_N) { for(t=0;t<4;t++) out->codon[i] += (codon[one*16+t*4+three]/total); } else if( one != BASE_N && two == BASE_N && three == BASE_N) { for(t=0;t<4;t++) for(r=0;r<4;r++) out->codon[i] += (codon[one*16+t*4+r]/total); } else if( one != BASE_N && two != BASE_N && three == BASE_N) { for(r=0;r<4;r++) out->codon[i] += (codon[one*16+two*4+r]/total); } } } out->codon[125] = 0.0; return out; } /* Function: flat_RandomCodon(ct) * * Descrip: Makes a flat RandomCodon from CodonTable * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ # line 285 "randommodel.dy" RandomCodon * flat_RandomCodon(CodonTable * ct) { int i; RandomCodon * rc; rc = RandomCodon_alloc(); for(i=0;i<125;i++) { if( is_stop_codon(i,ct) ) { rc->codon[i] = 0.0; } else { rc->codon[i] = 1.0 / 61.0; } } return rc; } /* Function: RandomModelDNAScore_from_RandomModelDNA(rmd) * * Descrip: Gives you a log space RandomModelDNAScore * from a probability space one * * * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [RandomModelDNAScore *] * */ # line 309 "randommodel.dy" RandomModelDNAScore * RandomModelDNAScore_from_RandomModelDNA(RandomModelDNA * rmd) { RandomModelDNAScore * out; register int i; out = RandomModelDNAScore_alloc(); if( out == NULL ) return NULL; for(i=0;i<5;i++) { out->base[i] = Probability2Score(rmd->base[i]); } return out; } /* Function: RandomModelDNA_std(void) * * Descrip: Returns a structure with 0.25 set in each place * * * * Return [UNKN ] Undocumented return value [RandomModelDNA *] * */ # line 329 "randommodel.dy" RandomModelDNA * RandomModelDNA_std(void) { register int i; RandomModelDNA * out; out = RandomModelDNA_alloc(); if( out == NULL ) return NULL; for(i=0;i<4;i++) out->base[i] = (1.0) / 4.0; out->base[4] = 1.0; return out; } /* Function: RandomModelDNA_std_human(void) * * Descrip: Set human random model (slightly G/C) * * Not sure where I got the numbers now. Ooops * * * * Return [UNKN ] Undocumented return value [RandomModelDNA *] * */ # line 351 "randommodel.dy" RandomModelDNA * RandomModelDNA_std_human(void) { RandomModelDNA * out; out = RandomModelDNA_alloc(); if( out == NULL ) return NULL; out->base[BASE_A]= 0.245; out->base[BASE_G]= 0.251; out->base[BASE_C]= 0.253; out->base[BASE_T]= 0.248; out->base[BASE_N]= 1.0; return out; } /* Function: Score_Sequence_is_random(s,rms) * * Descrip: Gives the score of a Sequence vs a random model * * * Arg: s [UNKN ] Undocumented argument [Sequence *] * Arg: rms [UNKN ] Undocumented argument [RandomModelScoreaa *] * * Return [UNKN ] Undocumented return value [Score] * */ # line 372 "randommodel.dy" Score Score_Sequence_is_random(Sequence * s,RandomModelScoreaa * rms) { register int i; Score sc = 0; for(i=0;ilen;i++) sc += rms->aminoacid[s->seq[i]-'A']; return sc; } /* Function: Prob_Sequence_is_random(s,rm) * * Descrip: Gives the probability of a Sequence vs a random model * * * Arg: s [UNKN ] Undocumented argument [Sequence *] * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * * Return [UNKN ] Undocumented return value [Probability] * */ # line 386 "randommodel.dy" Probability Prob_Sequence_is_random(Sequence * s,RandomModel * rm) { register int i; Probability p = 1.0; for(i=0;ilen;i++) { p *= rm->aminoacid[s->seq[i]-'A']; } return p; } /* Function: RandomModelScoreaa_from_RandomModel(rm) * * Descrip: Gives a score based RandomModel from a probability based one * * * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * * Return [UNKN ] Undocumented return value [RandomModelScoreaa *] * */ # line 403 "randommodel.dy" RandomModelScoreaa * RandomModelScoreaa_from_RandomModel(RandomModel * rm) { register int i; RandomModelScoreaa * out; out = RandomModelScoreaa_alloc(); if( out == NULL ) return NULL; for(i=0;i<26;i++) out->aminoacid[i] = Probability2Score(rm->aminoacid[i]); return out; } /* Function: default_RandomModel(void) * * Descrip: Gives a default random model numbers from * swissprot34- via the HMMEr1 package * * * * Return [UNKN ] Undocumented return value [RandomModel *] * */ # line 422 "randommodel.dy" RandomModel * default_RandomModel(void) { RandomModel * out; int i; out = RandomModel_alloc(); for(i=0;i<26;i++) out->aminoacid[i] = 0.00000001; out->aminoacid['A' -'A'] = 0.08713; out->aminoacid['C' -'A'] = 0.03347; out->aminoacid['D' -'A'] = 0.04687; out->aminoacid['E' -'A'] = 0.04953; out->aminoacid['F' -'A'] = 0.03977; out->aminoacid['G' -'A'] = 0.08861; out->aminoacid['H' -'A'] = 0.03362; out->aminoacid['I' -'A'] = 0.03689; out->aminoacid['K' -'A'] = 0.08048; out->aminoacid['L' -'A'] = 0.08536; out->aminoacid['M' -'A'] = 0.01475; out->aminoacid['N' -'A'] = 0.04043; out->aminoacid['P' -'A'] = 0.05068; out->aminoacid['Q' -'A'] = 0.03826; out->aminoacid['R' -'A'] = 0.04090; out->aminoacid['S' -'A'] = 0.06958; out->aminoacid['T' -'A'] = 0.05854; out->aminoacid['V' -'A'] = 0.06472; out->aminoacid['W' -'A'] = 0.01049; out->aminoacid['Y' -'A'] = 0.02992; return out; } /* Function: read_RandomModel(ifp) * * Descrip: Reads a simplistic RandomModel file of * * C 0.0123 * * etc type of format * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [RandomModel *] * */ # line 463 "randommodel.dy" RandomModel * read_RandomModel(FILE * ifp) { char buffer[MAXLINE]; char c; float f; RandomModel * out; register int i; out = RandomModel_alloc(); if( out == NULL ) return NULL; for(i=0;i<26;i++) out->aminoacid[i] = 0.000001; while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( buffer[0] == '!' ) continue; sscanf(buffer,"%c %f",&c,&f); c = toupper((int)c); if( c-'A' < 0 || c-'A' > 26 ) { warn("Have picked up an awfully dodgy character [%c] in reading random model",c); } out->aminoacid[c-'A'] = f; } return out; } # line 551 "randommodel.c" /* Function: hard_link_RandomModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomModel *] * * Return [UNKN ] Undocumented return value [RandomModel *] * */ RandomModel * hard_link_RandomModel(RandomModel * obj) { if( obj == NULL ) { warn("Trying to hard link to a RandomModel object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: RandomModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomModel *] * */ RandomModel * RandomModel_alloc(void) { RandomModel * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(RandomModel *) ckalloc (sizeof(RandomModel))) == NULL) { warn("RandomModel_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* aminoacid[26] is an array: no default possible */ out->name = NULL; return out; } /* Function: free_RandomModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomModel *] * * Return [UNKN ] Undocumented return value [RandomModel *] * */ RandomModel * free_RandomModel(RandomModel * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a RandomModel obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: hard_link_RandomModelScoreaa(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomModelScoreaa *] * * Return [UNKN ] Undocumented return value [RandomModelScoreaa *] * */ RandomModelScoreaa * hard_link_RandomModelScoreaa(RandomModelScoreaa * obj) { if( obj == NULL ) { warn("Trying to hard link to a RandomModelScoreaa object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: RandomModelScoreaa_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomModelScoreaa *] * */ RandomModelScoreaa * RandomModelScoreaa_alloc(void) { RandomModelScoreaa * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(RandomModelScoreaa *) ckalloc (sizeof(RandomModelScoreaa))) == NULL) { warn("RandomModelScoreaa_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* aminoacid[26] is an array: no default possible */ out->name = NULL; return out; } /* Function: free_RandomModelScoreaa(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomModelScoreaa *] * * Return [UNKN ] Undocumented return value [RandomModelScoreaa *] * */ RandomModelScoreaa * free_RandomModelScoreaa(RandomModelScoreaa * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a RandomModelScoreaa obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: hard_link_RandomCodonScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomCodonScore *] * * Return [UNKN ] Undocumented return value [RandomCodonScore *] * */ RandomCodonScore * hard_link_RandomCodonScore(RandomCodonScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a RandomCodonScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: RandomCodonScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomCodonScore *] * */ RandomCodonScore * RandomCodonScore_alloc(void) { RandomCodonScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(RandomCodonScore *) ckalloc (sizeof(RandomCodonScore))) == NULL) { warn("RandomCodonScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* codon[126] is an array: no default possible */ out->name = NULL; return out; } /* Function: free_RandomCodonScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomCodonScore *] * * Return [UNKN ] Undocumented return value [RandomCodonScore *] * */ RandomCodonScore * free_RandomCodonScore(RandomCodonScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a RandomCodonScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: hard_link_RandomCodon(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomCodon *] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ RandomCodon * hard_link_RandomCodon(RandomCodon * obj) { if( obj == NULL ) { warn("Trying to hard link to a RandomCodon object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: RandomCodon_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ RandomCodon * RandomCodon_alloc(void) { RandomCodon * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(RandomCodon *) ckalloc (sizeof(RandomCodon))) == NULL) { warn("RandomCodon_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* codon[126] is an array: no default possible */ out->name = NULL; return out; } /* Function: free_RandomCodon(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomCodon *] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ RandomCodon * free_RandomCodon(RandomCodon * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a RandomCodon obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: hard_link_RandomModelDNA(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [RandomModelDNA *] * */ RandomModelDNA * hard_link_RandomModelDNA(RandomModelDNA * obj) { if( obj == NULL ) { warn("Trying to hard link to a RandomModelDNA object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: RandomModelDNA_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomModelDNA *] * */ RandomModelDNA * RandomModelDNA_alloc(void) { RandomModelDNA * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(RandomModelDNA *) ckalloc (sizeof(RandomModelDNA))) == NULL) { warn("RandomModelDNA_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* base[5] is an array: no default possible */ out->name = NULL; return out; } /* Function: free_RandomModelDNA(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [RandomModelDNA *] * */ RandomModelDNA * free_RandomModelDNA(RandomModelDNA * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a RandomModelDNA obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: hard_link_RandomModelDNAScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [RandomModelDNAScore *] * */ RandomModelDNAScore * hard_link_RandomModelDNAScore(RandomModelDNAScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a RandomModelDNAScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: RandomModelDNAScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomModelDNAScore *] * */ RandomModelDNAScore * RandomModelDNAScore_alloc(void) { RandomModelDNAScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(RandomModelDNAScore *) ckalloc (sizeof(RandomModelDNAScore))) == NULL) { warn("RandomModelDNAScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* base[5] is an array: no default possible */ out->name = NULL; return out; } /* Function: free_RandomModelDNAScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [RandomModelDNAScore *] * */ RandomModelDNAScore * free_RandomModelDNAScore(RandomModelDNAScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a RandomModelDNAScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); ckfree(obj); return NULL; } /* Function: replace_name_RandomModelDNA(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomModelDNA *] * Arg: name [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable name [boolean] * */ boolean replace_name_RandomModelDNA(RandomModelDNA * obj,char * name) { if( obj == NULL) { warn("In replacement function name for object RandomModelDNA, got a NULL object"); return FALSE; } obj->name = name; return TRUE; } /* Function: access_name_RandomModelDNA(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomModelDNA *] * * Return [SOFT ] member variable name [char *] * */ char * access_name_RandomModelDNA(RandomModelDNA * obj) { if( obj == NULL) { warn("In accessor function name for object RandomModelDNA, got a NULL object"); return NULL; } return obj->name; } /* Function: replace_name_RandomModel(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomModel *] * Arg: name [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable name [boolean] * */ boolean replace_name_RandomModel(RandomModel * obj,char * name) { if( obj == NULL) { warn("In replacement function name for object RandomModel, got a NULL object"); return FALSE; } obj->name = name; return TRUE; } /* Function: access_name_RandomModel(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [RandomModel *] * * Return [SOFT ] member variable name [char *] * */ char * access_name_RandomModel(RandomModel * obj) { if( obj == NULL) { warn("In accessor function name for object RandomModel, got a NULL object"); return NULL; } return obj->name; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/randommodel.h0000644000175000001440000004507410670453712017322 0ustar philippusers#ifndef DYNAMITErandommodelHEADERFILE #define DYNAMITErandommodelHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "probability.h" #include "codon.h" #include "sequence.h" struct Wise2_RandomModel { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability aminoacid[26]; char * name; } ; /* RandomModel defined */ #ifndef DYNAMITE_DEFINED_RandomModel typedef struct Wise2_RandomModel Wise2_RandomModel; #define RandomModel Wise2_RandomModel #define DYNAMITE_DEFINED_RandomModel #endif struct Wise2_RandomModelScoreaa { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score aminoacid[26]; char * name; } ; /* RandomModelScoreaa defined */ #ifndef DYNAMITE_DEFINED_RandomModelScoreaa typedef struct Wise2_RandomModelScoreaa Wise2_RandomModelScoreaa; #define RandomModelScoreaa Wise2_RandomModelScoreaa #define DYNAMITE_DEFINED_RandomModelScoreaa #endif struct Wise2_RandomCodonScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score codon[126]; char * name; } ; /* RandomCodonScore defined */ #ifndef DYNAMITE_DEFINED_RandomCodonScore typedef struct Wise2_RandomCodonScore Wise2_RandomCodonScore; #define RandomCodonScore Wise2_RandomCodonScore #define DYNAMITE_DEFINED_RandomCodonScore #endif struct Wise2_RandomCodon { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability codon[126]; char * name; } ; /* RandomCodon defined */ #ifndef DYNAMITE_DEFINED_RandomCodon typedef struct Wise2_RandomCodon Wise2_RandomCodon; #define RandomCodon Wise2_RandomCodon #define DYNAMITE_DEFINED_RandomCodon #endif struct Wise2_RandomModelDNA { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability base[5]; char * name; } ; /* RandomModelDNA defined */ #ifndef DYNAMITE_DEFINED_RandomModelDNA typedef struct Wise2_RandomModelDNA Wise2_RandomModelDNA; #define RandomModelDNA Wise2_RandomModelDNA #define DYNAMITE_DEFINED_RandomModelDNA #endif struct Wise2_RandomModelDNAScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score base[5]; char * name; } ; /* RandomModelDNAScore defined */ #ifndef DYNAMITE_DEFINED_RandomModelDNAScore typedef struct Wise2_RandomModelDNAScore Wise2_RandomModelDNAScore; #define RandomModelDNAScore Wise2_RandomModelDNAScore #define DYNAMITE_DEFINED_RandomModelDNAScore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: draw_random_aa_RandomModel(rm) * * Descrip: Draws an amino acid from the random distribution * * * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * * Return [UNKN ] Undocumented return value [char] * */ char Wise2_draw_random_aa_RandomModel(RandomModel * rm); #define draw_random_aa_RandomModel Wise2_draw_random_aa_RandomModel /* Function: draw_random_base_RandomModelDNA(rm) * * Descrip: Draws a base from the random distribution * * * Arg: rm [UNKN ] Undocumented argument [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [char] * */ char Wise2_draw_random_base_RandomModelDNA(RandomModelDNA * rm); #define draw_random_base_RandomModelDNA Wise2_draw_random_base_RandomModelDNA /* Function: RandomCodonScore_from_RandomCodon(rc) * * Descrip: Makes a score RandomCodon (log space) * from a probability based random codon * * * Arg: rc [UNKN ] Undocumented argument [RandomCodon *] * * Return [UNKN ] Undocumented return value [RandomCodonScore *] * */ RandomCodonScore * Wise2_RandomCodonScore_from_RandomCodon(RandomCodon * rc); #define RandomCodonScore_from_RandomCodon Wise2_RandomCodonScore_from_RandomCodon /* Function: flatten_RandomCodon(rc) * * Descrip: Sets all probabilities to 1.0 - ie, * odds them to themselves. * * This is equivalent to saying that the randomcodon * is being odd-ratioed to itself * * Also equivalent of saying all the scores (in log * space) will be 0 * * * Arg: rc [UNKN ] Undocumented argument [RandomCodon *] * */ void Wise2_flatten_RandomCodon(RandomCodon * rc); #define flatten_RandomCodon Wise2_flatten_RandomCodon /* Function: fold_in_RandomModelDNA_into_RandomCodon(rc,rmd) * * Descrip: Makes the randomcodon numbers become the odds ratio * between their probabilitys and flat dna random model * (0th order markov) * * * Arg: rc [UNKN ] Undocumented argument [RandomCodon *] * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * */ void Wise2_fold_in_RandomModelDNA_into_RandomCodon(RandomCodon * rc,RandomModelDNA * rmd); #define fold_in_RandomModelDNA_into_RandomCodon Wise2_fold_in_RandomModelDNA_into_RandomCodon /* Function: show_RandomCodonScore(rcs,ofp) * * Descrip: shows RandomCodonScore * * for debugging * * * Arg: rcs [UNKN ] Undocumented argument [RandomCodonScore *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_RandomCodonScore(RandomCodonScore * rcs,FILE * ofp); #define show_RandomCodonScore Wise2_show_RandomCodonScore /* Function: show_RandomModelDNAScore(rds,ofp) * * Descrip: shows RandomModelsDNAScore * * for debugging * * * Arg: rds [UNKN ] Undocumented argument [RandomModelDNAScore *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_RandomModelDNAScore(RandomModelDNAScore * rds,FILE * ofp); #define show_RandomModelDNAScore Wise2_show_RandomModelDNAScore /* Function: folded_RandomModelDNAScore_from_2RMD(dis,rnd) * * Descrip: gives a odds ratio between two random models * * * Arg: dis [UNKN ] Undocumented argument [RandomModelDNA *] * Arg: rnd [UNKN ] Undocumented argument [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [RandomModelDNAScore *] * */ RandomModelDNAScore * Wise2_folded_RandomModelDNAScore_from_2RMD(RandomModelDNA * dis,RandomModelDNA * rnd); #define folded_RandomModelDNAScore_from_2RMD Wise2_folded_RandomModelDNAScore_from_2RMD /* Function: RandomCodon_from_raw_CodonFrequency(codon[64],*ct) * * Descrip: From raw counts (no adjustment to amino acids) of codons * gives you a RandomCodon model * * No prior is used (? perhaps should have a flat prior) * * N's are handled correctly * * * Arg: codon[64] [UNKN ] Undocumented argument [double] * Arg: *ct [UNKN ] Undocumented argument [CodonTable] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ RandomCodon * Wise2_RandomCodon_from_raw_CodonFrequency(double codon[64],CodonTable *ct); #define RandomCodon_from_raw_CodonFrequency Wise2_RandomCodon_from_raw_CodonFrequency /* Function: flat_RandomCodon(ct) * * Descrip: Makes a flat RandomCodon from CodonTable * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ RandomCodon * Wise2_flat_RandomCodon(CodonTable * ct); #define flat_RandomCodon Wise2_flat_RandomCodon /* Function: RandomModelDNAScore_from_RandomModelDNA(rmd) * * Descrip: Gives you a log space RandomModelDNAScore * from a probability space one * * * Arg: rmd [UNKN ] Undocumented argument [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [RandomModelDNAScore *] * */ RandomModelDNAScore * Wise2_RandomModelDNAScore_from_RandomModelDNA(RandomModelDNA * rmd); #define RandomModelDNAScore_from_RandomModelDNA Wise2_RandomModelDNAScore_from_RandomModelDNA /* Function: RandomModelDNA_std(void) * * Descrip: Returns a structure with 0.25 set in each place * * * * Return [UNKN ] Undocumented return value [RandomModelDNA *] * */ RandomModelDNA * Wise2_RandomModelDNA_std(void); #define RandomModelDNA_std Wise2_RandomModelDNA_std /* Function: RandomModelDNA_std_human(void) * * Descrip: Set human random model (slightly G/C) * * Not sure where I got the numbers now. Ooops * * * * Return [UNKN ] Undocumented return value [RandomModelDNA *] * */ RandomModelDNA * Wise2_RandomModelDNA_std_human(void); #define RandomModelDNA_std_human Wise2_RandomModelDNA_std_human /* Function: Score_Sequence_is_random(s,rms) * * Descrip: Gives the score of a Sequence vs a random model * * * Arg: s [UNKN ] Undocumented argument [Sequence *] * Arg: rms [UNKN ] Undocumented argument [RandomModelScoreaa *] * * Return [UNKN ] Undocumented return value [Score] * */ Score Wise2_Score_Sequence_is_random(Sequence * s,RandomModelScoreaa * rms); #define Score_Sequence_is_random Wise2_Score_Sequence_is_random /* Function: Prob_Sequence_is_random(s,rm) * * Descrip: Gives the probability of a Sequence vs a random model * * * Arg: s [UNKN ] Undocumented argument [Sequence *] * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * * Return [UNKN ] Undocumented return value [Probability] * */ Probability Wise2_Prob_Sequence_is_random(Sequence * s,RandomModel * rm); #define Prob_Sequence_is_random Wise2_Prob_Sequence_is_random /* Function: RandomModelScoreaa_from_RandomModel(rm) * * Descrip: Gives a score based RandomModel from a probability based one * * * Arg: rm [UNKN ] Undocumented argument [RandomModel *] * * Return [UNKN ] Undocumented return value [RandomModelScoreaa *] * */ RandomModelScoreaa * Wise2_RandomModelScoreaa_from_RandomModel(RandomModel * rm); #define RandomModelScoreaa_from_RandomModel Wise2_RandomModelScoreaa_from_RandomModel /* Function: default_RandomModel(void) * * Descrip: Gives a default random model numbers from * swissprot34- via the HMMEr1 package * * * * Return [UNKN ] Undocumented return value [RandomModel *] * */ RandomModel * Wise2_default_RandomModel(void); #define default_RandomModel Wise2_default_RandomModel /* Function: read_RandomModel(ifp) * * Descrip: Reads a simplistic RandomModel file of * * C 0.0123 * * etc type of format * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [RandomModel *] * */ RandomModel * Wise2_read_RandomModel(FILE * ifp); #define read_RandomModel Wise2_read_RandomModel /* Function: hard_link_RandomModel(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomModel *] * * Return [UNKN ] Undocumented return value [RandomModel *] * */ RandomModel * Wise2_hard_link_RandomModel(RandomModel * obj); #define hard_link_RandomModel Wise2_hard_link_RandomModel /* Function: RandomModel_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomModel *] * */ RandomModel * Wise2_RandomModel_alloc(void); #define RandomModel_alloc Wise2_RandomModel_alloc /* Function: free_RandomModel(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomModel *] * * Return [UNKN ] Undocumented return value [RandomModel *] * */ RandomModel * Wise2_free_RandomModel(RandomModel * obj); #define free_RandomModel Wise2_free_RandomModel /* Function: hard_link_RandomModelScoreaa(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomModelScoreaa *] * * Return [UNKN ] Undocumented return value [RandomModelScoreaa *] * */ RandomModelScoreaa * Wise2_hard_link_RandomModelScoreaa(RandomModelScoreaa * obj); #define hard_link_RandomModelScoreaa Wise2_hard_link_RandomModelScoreaa /* Function: RandomModelScoreaa_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomModelScoreaa *] * */ RandomModelScoreaa * Wise2_RandomModelScoreaa_alloc(void); #define RandomModelScoreaa_alloc Wise2_RandomModelScoreaa_alloc /* Function: free_RandomModelScoreaa(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomModelScoreaa *] * * Return [UNKN ] Undocumented return value [RandomModelScoreaa *] * */ RandomModelScoreaa * Wise2_free_RandomModelScoreaa(RandomModelScoreaa * obj); #define free_RandomModelScoreaa Wise2_free_RandomModelScoreaa /* Function: hard_link_RandomCodonScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomCodonScore *] * * Return [UNKN ] Undocumented return value [RandomCodonScore *] * */ RandomCodonScore * Wise2_hard_link_RandomCodonScore(RandomCodonScore * obj); #define hard_link_RandomCodonScore Wise2_hard_link_RandomCodonScore /* Function: RandomCodonScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomCodonScore *] * */ RandomCodonScore * Wise2_RandomCodonScore_alloc(void); #define RandomCodonScore_alloc Wise2_RandomCodonScore_alloc /* Function: free_RandomCodonScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomCodonScore *] * * Return [UNKN ] Undocumented return value [RandomCodonScore *] * */ RandomCodonScore * Wise2_free_RandomCodonScore(RandomCodonScore * obj); #define free_RandomCodonScore Wise2_free_RandomCodonScore /* Function: hard_link_RandomCodon(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomCodon *] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ RandomCodon * Wise2_hard_link_RandomCodon(RandomCodon * obj); #define hard_link_RandomCodon Wise2_hard_link_RandomCodon /* Function: RandomCodon_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ RandomCodon * Wise2_RandomCodon_alloc(void); #define RandomCodon_alloc Wise2_RandomCodon_alloc /* Function: free_RandomCodon(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomCodon *] * * Return [UNKN ] Undocumented return value [RandomCodon *] * */ RandomCodon * Wise2_free_RandomCodon(RandomCodon * obj); #define free_RandomCodon Wise2_free_RandomCodon /* Function: hard_link_RandomModelDNA(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [RandomModelDNA *] * */ RandomModelDNA * Wise2_hard_link_RandomModelDNA(RandomModelDNA * obj); #define hard_link_RandomModelDNA Wise2_hard_link_RandomModelDNA /* Function: RandomModelDNA_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomModelDNA *] * */ RandomModelDNA * Wise2_RandomModelDNA_alloc(void); #define RandomModelDNA_alloc Wise2_RandomModelDNA_alloc /* Function: free_RandomModelDNA(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomModelDNA *] * * Return [UNKN ] Undocumented return value [RandomModelDNA *] * */ RandomModelDNA * Wise2_free_RandomModelDNA(RandomModelDNA * obj); #define free_RandomModelDNA Wise2_free_RandomModelDNA /* Function: hard_link_RandomModelDNAScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [RandomModelDNAScore *] * */ RandomModelDNAScore * Wise2_hard_link_RandomModelDNAScore(RandomModelDNAScore * obj); #define hard_link_RandomModelDNAScore Wise2_hard_link_RandomModelDNAScore /* Function: RandomModelDNAScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [RandomModelDNAScore *] * */ RandomModelDNAScore * Wise2_RandomModelDNAScore_alloc(void); #define RandomModelDNAScore_alloc Wise2_RandomModelDNAScore_alloc /* Function: free_RandomModelDNAScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [RandomModelDNAScore *] * * Return [UNKN ] Undocumented return value [RandomModelDNAScore *] * */ RandomModelDNAScore * Wise2_free_RandomModelDNAScore(RandomModelDNAScore * obj); #define free_RandomModelDNAScore Wise2_free_RandomModelDNAScore /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ char * Wise2_access_name_RandomModelDNA(RandomModelDNA * obj); #define access_name_RandomModelDNA Wise2_access_name_RandomModelDNA boolean Wise2_replace_name_RandomModel(RandomModel * obj,char * name); #define replace_name_RandomModel Wise2_replace_name_RandomModel boolean Wise2_replace_name_RandomModelDNA(RandomModelDNA * obj,char * name); #define replace_name_RandomModelDNA Wise2_replace_name_RandomModelDNA char * Wise2_access_name_RandomModel(RandomModel * obj); #define access_name_RandomModel Wise2_access_name_RandomModel #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/hspstream.dy0000644000175000001440000001064010364126067017203 0ustar philippusers %{ #include "../dynlibsrc/hsp.h" #include "sequencestream.h" %} %{ #include "hspstream.h" %func untyped linear hsp manager to stream %% void untyped_LinearHSPmanager_to_Stream(void * lm,Wise2WriteStreamInterface * ws) { return typed_LinearHSPmanager_to_Stream((void*)lm,ws); } %func typed linear hsp manager to stream writes out sequneces first, with query as first sequence and then each target in turn, and then all the hsps in turn, only writing down the target name %% void typed_LinearHSPmanager_to_Stream(LinearHSPmanager * lm,Wise2WriteStreamInterface * ws) { int i,j; SequenceSet * out; char buffer[512]; /* assumme that each HSPset has only one target sequence */ out = SequenceSet_alloc_len(lm->len+1); /* query goes in first */ add_SequenceSet(out,hard_link_Sequence(lm->query)); for(i=0;ilen;i++) { if( lm->set[i]->len > 0 ) { if( lm->set[i]->hsp[0]->target == NULL) { warn("Unable to transport HSP at position %d, as no linked target sequence",i); } else { add_SequenceSet(out,hard_link_Sequence(lm->set[i]->hsp[0]->target)); } } } typed_write_SequenceSet_to_Stream(out,ws); free_SequenceSet(out); /* now write the hsps */ for(i=0;ilen;i++) { if( lm->set[i]->len > 0 && lm->set[i]->hsp[0]->target != NULL ) { for(j=0;jset[i]->len;j++) { sprintf(buffer,"%s %d %d %d %d %d\n", lm->set[i]->hsp[j]->target->name, lm->set[i]->hsp[j]->query_start, lm->set[i]->hsp[j]->target_start, lm->set[i]->hsp[j]->length, lm->set[i]->hsp[j]->score, lm->set[i]->hsp[j]->target_reverse); /* fprintf(stderr,"%s %d %d %d %d %d\n", lm->set[i]->hsp[j]->target->name, lm->set[i]->hsp[j]->query_start, lm->set[i]->hsp[j]->target_start, lm->set[i]->hsp[j]->length, lm->set[i]->hsp[j]->score, lm->set[i]->hsp[j]->target_reverse); */ WISE2_WRITE_STRING(buffer,ws); } } } WISE2_WRITE_STRING("//\n",ws); } %func untyped read %% void * untyped_LinearHSPmanager_from_Stream(Wise2ReadStreamInterface * rs) { return (void*) typed_LinearHSPmanager_from_Stream(rs); } %func typed linear hsp manager from stream assummes sequences coming in first, with query as first sequence and then hsps one after the other %% LinearHSPmanager * typed_LinearHSPmanager_from_Stream(Wise2ReadStreamInterface * rs) { SequenceSet * set; LinearHSPmanager * lm; HSPset * curr; HSP * h; int seq_pos; int dummy; int i; char buffer[MAXLINE]; set = typed_SequenceSet_from_Stream(rs); /* for(i=0;ilen;i++) { fprintf(stderr,"Got %d, %s with %s\n",i,set->set[i]->name,set->set[i]->desc); } */ lm = LinearHSPmanager_alloc_std(); lm->query = hard_link_Sequence(set->set[0]); if( set->len == 1 ) { WISE2_READ_BUFFER(buffer,MAXLINE,rs); /* should check it is // */ return lm; } seq_pos = 1; curr = HSPset_alloc_std(); add_LinearHSPmanager(lm,curr); while( WISE2_READ_BUFFER(buffer,MAXLINE,rs) != NULL ) { auto int k; auto int temp_len = strlen(set->set[seq_pos]->name); if( strncmp(buffer,"//",2) == 0 ) { break; } /* is space is because we can have partial matching at the start of the of an identifier, in particular with uniprot alternative splice -X names */ for(k=0;k < MAXLINE;k++) { if( isspace(buffer[k]) ) { buffer[k] = '\0'; break; } } /*fprintf(stderr,"Comparing %s to %s with %d (%d) %d %d\n",buffer,set->set[seq_pos]->name,strncmp(buffer,set->set[seq_pos]->name,temp_len),temp_len,isspace(buffer[temp_len]),(int)(buffer[temp_len]) ); */ if( strcmp(buffer,set->set[seq_pos]->name) != 0 ) { seq_pos++; if( seq_pos >= set->len ) { warn("Overrun set sequences\n"); break; } curr = HSPset_alloc_std(); add_LinearHSPmanager(lm,curr); if( strncmp(buffer,set->set[seq_pos]->name,temp_len) != 0 ) { warn("Unable to match hsp name of [%s] to sequence name of %s, skipping\n",buffer,set->set[seq_pos]->name); continue; } } /* parse this hsp */ h = HSP_alloc(); h->query = hard_link_Sequence(set->set[0]); h->target = hard_link_Sequence(set->set[seq_pos]); sscanf(buffer+strlen(set->set[seq_pos]->name)+1,"%d %d %d %d %d",&h->query_start,&h->target_start,&h->length,&h->score,&dummy); if( dummy == 0 ) { h->target_reverse = 0; } else { h->target_reverse = 1; } add_HSPset(curr,h); } free_SequenceSet(set); return lm; } %} wise-2.4.1/src/dynlibsrc/shadowseqindex.c0000644000175000001440000005507410670453713020044 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "shadowseqindex.h" typedef struct ShadowSeqClient_struct { GenericIndexResult result; SeqLookupResultInterface interface; ShadowSequenceIndex * index; } ShadowSequenceClient; static ShadowSequenceClient * ShadowSequenceClient_alloc(void) { ShadowSequenceClient * out; out = malloc(sizeof(ShadowSequenceClient)); return out; } /* Function: new_ShadowSequenceIndex_SeqLookupInterface(shadow_len,has_maxlen,maxlen,shadow_error) * * Descrip: Provides a SeqLookupInterface, the common runtime plug-in for indexers * using a ShadowSequenceIndex * * * Arg: shadow_len [UNKN ] Undocumented argument [int] * Arg: has_maxlen [UNKN ] Undocumented argument [int] * Arg: maxlen [UNKN ] Undocumented argument [int] * Arg: shadow_error [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ # line 61 "shadowseqindex.dy" SeqLookupInterface * new_ShadowSequenceIndex_SeqLookupInterface(int shadow_len,int has_maxlen,int maxlen,int shadow_error) { SeqLookupInterface * out; ShadowSequenceIndex * in; in = new_ShadowSequenceIndex(26*26*26*26*26,shadow_len,has_maxlen,maxlen,shadow_error); out = SeqLookupInterface_alloc_std(); out->get_client = get_client_interface_ShadowSequenceIndex; out->add_seq = add_seq_interface_ShadowSequenceIndex; out->free_data = free_interface_ShadowSequenceIndex; out->lookup_array_head = NULL; out->data = (void*) in; return out; } /* Function: get_client_interface_ShadowSequenceIndex(data) * * Descrip: gets client interface * * * Arg: data [UNKN ] Undocumented argument [void*] * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ # line 83 "shadowseqindex.dy" SeqLookupClientInterface * get_client_interface_ShadowSequenceIndex(void* data) { ShadowSequenceIndex * index = (ShadowSequenceIndex*) data; SeqLookupClientInterface * slci; ShadowSequenceClient * pcl; pcl = ShadowSequenceClient_alloc(); pcl->result.result = calloc(64,sizeof(SeqLookupResultStruct)); pcl->result.max_len = 64; pcl->result.len = 0; pcl->interface.next = next_interface_GenericIndexResult; pcl->interface.is_more = is_more_interface_GenericIndexResult; pcl->interface.free_data = free_noop_GenericIndexResult; pcl->interface.data = (void*) &(pcl->result); pcl->index = index; slci = SeqLookupClientInterface_alloc(); slci->lookup = lookup_interface_ShadowSequenceClient; slci->is_populated = is_populated_interface_ShadowSequenceClient; slci->free_data = free_interface_ShadowSequenceClient; slci->data = (void*) pcl; return slci; } /* Function: lookup_interface_ShadowSequenceClient(data,seq_number) * * Descrip: For lookup interface, provides a result * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ # line 116 "shadowseqindex.dy" SeqLookupResultInterface * lookup_interface_ShadowSequenceClient(void * data,int seq_number) { ShadowSequenceClient * cli= (ShadowSequenceClient*) data; ShadowSequenceIndex * in = cli->index; /* reset pointers */ cli->result.current_pos = 0; cli->result.len = 0; if( lookup_result_ShadowSeq(&cli->result,in,seq_number) == FALSE ) { return NULL; } return &cli->interface; } /* Function: is_populated_interface_ShadowSequenceClient(data,seq_number) * * Descrip: populated function for interface * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 137 "shadowseqindex.dy" boolean is_populated_interface_ShadowSequenceClient(void * data,int seq_number) { ShadowSequenceClient * client = (ShadowSequenceClient*) data; if( client->index->array[seq_number] != NULL ) { return TRUE; } else { return FALSE; } } /* Function: add_seq_interface_ShadowSequenceIndex(data,seq,para) * * Descrip: add function for interface * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 152 "shadowseqindex.dy" boolean add_seq_interface_ShadowSequenceIndex(void * data,Sequence * seq,SeqLookupLoadPara * para) { ShadowSequenceIndex * in = (ShadowSequenceIndex*) data; return add_Sequence_ShadowSequenceIndex(in,seq,in->shadow_len); } /* Function: free_interface_ShadowSequenceIndex(data) * * Descrip: for interface, frees index * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 162 "shadowseqindex.dy" void free_interface_ShadowSequenceIndex(void * data) { ShadowSequenceIndex * in = (ShadowSequenceIndex*) data; free_ShadowSequenceIndex(in); } /* Function: free_interface_ShadowSequenceClient(data) * * Descrip: Frees the client data * * * Arg: data [UNKN ] Undocumented argument [void *] * */ # line 173 "shadowseqindex.dy" void free_interface_ShadowSequenceClient(void * data) { ShadowSequenceClient * cli = (ShadowSequenceClient *)data; free(cli->result.result); free(cli); } /* Function: lookup_result_ShadowSeq(res,in,seq_no) * * Descrip: handles the lookup and storage for a seq_no * lookup * * * Arg: res [UNKN ] Undocumented argument [GenericIndexResult *] * Arg: in [UNKN ] Undocumented argument [ShadowSequenceIndex *] * Arg: seq_no [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 189 "shadowseqindex.dy" boolean lookup_result_ShadowSeq(GenericIndexResult * res,ShadowSequenceIndex * in,int seq_no) { int i; SingleNumberSequence * sns; int pos; assert(res); assert(in); if( in->array[seq_no] == NULL ) { return FALSE; } for(i=0;iarray[seq_no]->current_pos;i++) { pos = in->array[seq_no]->seqdb_pos[i]; sns = lookup_ShadowSequence_SingleNumberSpace(in->space,pos); add_result_GenericIndexResult_ShadowSeq(res,sns->seq,pos-sns->start); } return TRUE; } /* Function: add_result_GenericIndexResult_ShadowSeq(res,seq,pos) * * Descrip: adds a particular shadow sequence position, unrolling * shadowed sequences into the result * * * Arg: res [UNKN ] Undocumented argument [GenericIndexResult *] * Arg: seq [UNKN ] Undocumented argument [ShadowSequence *] * Arg: pos [UNKN ] Undocumented argument [int] * */ # line 215 "shadowseqindex.dy" void add_result_GenericIndexResult_ShadowSeq(GenericIndexResult * res,ShadowSequence * seq,int pos) { int i; assert(res); assert(seq); add_GenericIndexResult(res,seq->seq,pos); for(i=0;ilen;i++) { if( pos >= seq->region[i]->start_seq && pos < seq->region[i]->start_seq + seq->region[i]->len ) { add_GenericIndexResult(res,seq->region[i]->seq,seq->region[i]->start_shadow + pos - seq->region[i]->start_seq); } } } /* Function: dump_shadow_ShadowSequenceIndex(in,ofp) * * Descrip: Dumps information about shadows * * * Arg: in [UNKN ] Undocumented argument [ShadowSequenceIndex *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 237 "shadowseqindex.dy" void dump_shadow_ShadowSequenceIndex(ShadowSequenceIndex * in,FILE * ofp) { int i; for(i=0;ilen;i++) { dump_ShadowSequence(in->shadow[i],ofp); } } /* Function: dump_stats_ShadowSequenceIndex(in,ofp) * * Descrip: Dumps useful information out of shadow sequence array * * * Arg: in [UNKN ] Undocumented argument [ShadowSequenceIndex *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 250 "shadowseqindex.dy" void dump_stats_ShadowSequenceIndex(ShadowSequenceIndex * in,FILE * ofp) { int i; int j; int total_index = 0; int total_shadow = 0; int total_array = 0; int total_seq = 0; int total_head = 0; for(i=0;iarray_len;i++) { if( in->array[i] != NULL ) { total_index += in->array[i]->current_pos; total_array += in->array[i]->max; total_head++; } } for(i=0;ilen;i++) { total_seq += in->shadow[i]->seq->len; for(j=0;jshadow[i]->len;j++) { total_shadow += in->shadow[i]->region[j]->len; } } fprintf(ofp,"Arrayed %d, Shadowed %d (Compression ratio %.2f%%)\n", total_index, total_shadow, (double)(total_shadow)*100/(double)(total_shadow+total_index)); fprintf(ofp,"Occupied Array Memory %d [%.2f Mbytes]\n", total_index,((total_index/1000000.0)*sizeof(SHADOW_TYPE))); fprintf(ofp,"Allocated Array memory %d [%.2fMbytes] [%d %%]\n", total_array,((total_array/1000000.0)*sizeof(SHADOW_TYPE)), total_index*100/total_array); fprintf(ofp,"Head memory %d [%.2f Mbytes]\n",total_head,(total_head*sizeof(ShadowArraySeqHead))/100000); fprintf(ofp,"Sequence Memory %d [%.2f Mbytes]\n", total_seq,(total_seq/1000000.0)*sizeof(char)); show_allocator_status_IntAllocatorSet(in->ias,ofp); } /* Function: add_Sequence_ShadowSequenceIndex(in,seq,min_ext) * * Descrip: Adds a Sequence to a ShadowIndex, placing shadowed regions * correctly away * * * Arg: in [UNKN ] Undocumented argument [ShadowSequenceIndex *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: min_ext [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 298 "shadowseqindex.dy" boolean add_Sequence_ShadowSequenceIndex(ShadowSequenceIndex * in,Sequence * seq,int min_ext) { int i; int j; int no; int temp; ShadowSequence * shadow = NULL; int is_dirty = 0; int start_position; SingleNumberSequence * sns; assert(in); assert(seq); /* reap memory into the static system */ seq = new_Sequence_StaticSeqHolder(in->ssh,seq); shadow = new_ShadowSequence(seq); add_ShadowSequenceIndex(in,shadow); start_position = add_ShadowSequence_SingleNumberSpace(in->space,shadow); for(i=0;ilen-5;) { no = seq_number_aa_5mer(seq->seq+i); if( in->array[no] != NULL ) { temp = 0; for(j=0;jarray[no]->current_pos;j++) { sns = lookup_ShadowSequence_SingleNumberSpace(in->space,in->array[no]->seqdb_pos[j]); /* we can make a hard assumption that sns is not NULL, but just to catch errors a little more explicity... */ assert(sns); if( sns->seq->dirty == 0 && sns->seq != shadow && (temp = add_if_possible_ShadowSequence(sns->seq,seq,min_ext,in->array[no]->seqdb_pos[j]-sns->start,i,in->shadow_error)) != 0 ) { i = temp; break; } } if( temp != 0 ) { is_dirty = 1; continue; } } if( in->array[no] == NULL ) { in->array[no] = new_ShadowArraySeqHead(in->ias); } add_ShadowArraySeqHead(in->ias,in->array[no],start_position+i); i++; } shadow->dirty = is_dirty; return TRUE; } /* Function: new_ShadowSequenceIndex(len,shadow_len,has_maxlen,maxlen,shadow_error) * * Descrip: New ShadowSequenceIndex * * * Arg: len [UNKN ] Undocumented argument [int] * Arg: shadow_len [UNKN ] Undocumented argument [int] * Arg: has_maxlen [UNKN ] Undocumented argument [int] * Arg: maxlen [UNKN ] Undocumented argument [int] * Arg: shadow_error [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ShadowSequenceIndex *] * */ # line 370 "shadowseqindex.dy" ShadowSequenceIndex * new_ShadowSequenceIndex(int len,int shadow_len,int has_maxlen,int maxlen,int shadow_error) { int i; ShadowSequenceIndex * out; out = ShadowSequenceIndex_alloc_std(); out->array = calloc(len,sizeof(ShadowArraySeqHead*)); assert(out->array); for(i=0;iarray[i] = NULL; } out->array_len = len; out->shadow_len = len; out->space = new_SingleNumberSpace(has_maxlen,maxlen); out->shadow_error = shadow_error; out->ias = new_IntAllocatorSet(65); out->ssh = new_StaticSeqHolder(); return out; } /* Function: add_ShadowArraySeqHead(ias,h,seqdb_pos) * * Descrip: Adds a sequence/pos pair to an ArrayHead * * * Arg: ias [UNKN ] Undocumented argument [IntAllocatorSet *] * Arg: h [UNKN ] Undocumented argument [ShadowArraySeqHead *] * Arg: seqdb_pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 396 "shadowseqindex.dy" boolean add_ShadowArraySeqHead(IntAllocatorSet * ias,ShadowArraySeqHead * h,int seqdb_pos) { if( h->current_pos >= h->max ) { if( h->max < SHADOW_ARRAYSEQL_LINEAR ) { h->seqdb_pos = realloc_intarray_IntAllocatorSet(ias,h->seqdb_pos,h->max,(h->max*2)); h->max = h->max*2; } else { h->seqdb_pos = realloc_intarray_IntAllocatorSet(ias,h->seqdb_pos,h->max,h->max + SHADOW_ARRAYSEQL_LINEAR); h->max = h->max + SHADOW_ARRAYSEQL_LINEAR; } if( h->seqdb_pos == NULL ) { fatal("ArraySeqLookup realloc failed trying for %d positions\n",h->max); } /* fprintf(stderr,"... extended to %d\n",h->max); */ } h->seqdb_pos[h->current_pos] = seqdb_pos; h->current_pos++; return TRUE; } /* Function: new_ShadowArraySeqHead(ias) * * Descrip: Builds a new ArraySeqHead structure * * * Arg: ias [UNKN ] Undocumented argument [IntAllocatorSet *] * * Return [UNKN ] Undocumented return value [ShadowArraySeqHead *] * */ # line 425 "shadowseqindex.dy" ShadowArraySeqHead * new_ShadowArraySeqHead(IntAllocatorSet * ias) { ShadowArraySeqHead * out; out = malloc(sizeof(ShadowArraySeqHead)); out->seqdb_pos = alloc_intarray_IntAllocatorSet(ias,SHADOW_ARRAYSEQL_BASIC); out->max = SHADOW_ARRAYSEQL_BASIC; out->current_pos = 0; return out; } # line 507 "shadowseqindex.c" /* Function: swap_ShadowSequenceIndex(list,i,j) * * Descrip: swap function: an internal for qsort_ShadowSequenceIndex * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [ShadowSequence **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_ShadowSequenceIndex(ShadowSequence ** list,int i,int j) { ShadowSequence * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_ShadowSequenceIndex(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_ShadowSequenceIndex which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [ShadowSequence **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_ShadowSequenceIndex(ShadowSequence ** list,int left,int right,int (*comp)(ShadowSequence * ,ShadowSequence * )) { int i,last; if( left >= right ) return; swap_ShadowSequenceIndex(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_ShadowSequenceIndex (list,++last,i); } swap_ShadowSequenceIndex (list,left,last); qsort_ShadowSequenceIndex(list,left,last-1,comp); qsort_ShadowSequenceIndex(list,last+1,right,comp); } /* Function: sort_ShadowSequenceIndex(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_ShadowSequenceIndex * * * Arg: obj [UNKN ] Object containing list [ShadowSequenceIndex *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_ShadowSequenceIndex(ShadowSequenceIndex * obj,int (*comp)(ShadowSequence *, ShadowSequence *)) { qsort_ShadowSequenceIndex(obj->shadow,0,obj->len-1,comp); return; } /* Function: expand_ShadowSequenceIndex(obj,len) * * Descrip: Really an internal function for add_ShadowSequenceIndex * * * Arg: obj [UNKN ] Object which contains the list [ShadowSequenceIndex *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_ShadowSequenceIndex(ShadowSequenceIndex * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_ShadowSequenceIndex called with no need"); return TRUE; } if( (obj->shadow = (ShadowSequence ** ) ckrealloc (obj->shadow,sizeof(ShadowSequence *)*len)) == NULL) { warn("ckrealloc failed for expand_ShadowSequenceIndex, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_ShadowSequenceIndex(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ShadowSequenceIndex *] * Arg: add [OWNER] Object to add to the list [ShadowSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_ShadowSequenceIndex(ShadowSequenceIndex * obj,ShadowSequence * add) { if( obj->len >= obj->maxlen) { if( expand_ShadowSequenceIndex(obj,obj->len + ShadowSequenceIndexLISTLENGTH) == FALSE) return FALSE; } obj->shadow[obj->len++]=add; return TRUE; } /* Function: flush_ShadowSequenceIndex(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ShadowSequenceIndex *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_ShadowSequenceIndex(ShadowSequenceIndex * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->shadow[i] != NULL) { free_ShadowSequence(obj->shadow[i]); obj->shadow[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: ShadowSequenceIndex_alloc_std(void) * * Descrip: Equivalent to ShadowSequenceIndex_alloc_len(ShadowSequenceIndexLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ShadowSequenceIndex *] * */ ShadowSequenceIndex * ShadowSequenceIndex_alloc_std(void) { return ShadowSequenceIndex_alloc_len(ShadowSequenceIndexLISTLENGTH); } /* Function: ShadowSequenceIndex_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ShadowSequenceIndex *] * */ ShadowSequenceIndex * ShadowSequenceIndex_alloc_len(int len) { ShadowSequenceIndex * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = ShadowSequenceIndex_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->shadow = (ShadowSequence ** ) ckcalloc (len,sizeof(ShadowSequence *))) == NULL) { warn("Warning, ckcalloc failed in ShadowSequenceIndex_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_ShadowSequenceIndex(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShadowSequenceIndex *] * * Return [UNKN ] Undocumented return value [ShadowSequenceIndex *] * */ ShadowSequenceIndex * hard_link_ShadowSequenceIndex(ShadowSequenceIndex * obj) { if( obj == NULL ) { warn("Trying to hard link to a ShadowSequenceIndex object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: ShadowSequenceIndex_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShadowSequenceIndex *] * */ ShadowSequenceIndex * ShadowSequenceIndex_alloc(void) { ShadowSequenceIndex * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(ShadowSequenceIndex *) ckalloc (sizeof(ShadowSequenceIndex))) == NULL) { warn("ShadowSequenceIndex_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->array = NULL; out->array_len = 0; out->shadow = NULL; out->len = out->maxlen = 0; out->space = NULL; out->shadow_len = 0; out->shadow_error = 0; out->ias = NULL; out->ssh = NULL; return out; } /* Function: free_ShadowSequenceIndex(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShadowSequenceIndex *] * * Return [UNKN ] Undocumented return value [ShadowSequenceIndex *] * */ ShadowSequenceIndex * free_ShadowSequenceIndex(ShadowSequenceIndex * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a ShadowSequenceIndex obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->array != NULL) ckfree(obj->array); if( obj->shadow != NULL) { for(i=0;ilen;i++) { if( obj->shadow[i] != NULL) free_ShadowSequence(obj->shadow[i]); } ckfree(obj->shadow); } if( obj->space != NULL) free_SingleNumberSpace(obj->space); if( obj->ias != NULL) free_IntAllocatorSet(obj->ias); if( obj->ssh != NULL) free_StaticSeqHolder(obj->ssh); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/shadowseqindex.h0000644000175000001440000003215110670453713020040 0ustar philippusers#ifndef DYNAMITEshadowseqindexHEADERFILE #define DYNAMITEshadowseqindexHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "seqlookup.h" #include "shadowseq.h" #include "genericindexresult.h" #include "singlenumberspace.h" #include "intallocator.h" #include "staticseq.h" #define SHADOW_ARRAYSEQL_BASIC 4 #define SHADOW_ARRAYSEQL_LINEAR 16 #define ShadowSequenceIndexLISTLENGTH 1024 #define SHADOW_TYPE int typedef struct Wise2_ShadowArraySeqHead { SHADOW_TYPE * seqdb_pos; int current_pos; int max; } ShadowArraySeqHead; struct Wise2_ShadowSequenceIndex { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif ShadowArraySeqHead ** array; int array_len; ShadowSequence ** shadow; int len;/* len for above shadow */ int maxlen; /* maxlen for above shadow */ SingleNumberSpace * space; int shadow_len; int shadow_error; IntAllocatorSet * ias; StaticSeqHolder * ssh; } ; /* ShadowSequenceIndex defined */ #ifndef DYNAMITE_DEFINED_ShadowSequenceIndex typedef struct Wise2_ShadowSequenceIndex Wise2_ShadowSequenceIndex; #define ShadowSequenceIndex Wise2_ShadowSequenceIndex #define DYNAMITE_DEFINED_ShadowSequenceIndex #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_ShadowSequenceIndex_SeqLookupInterface(shadow_len,has_maxlen,maxlen,shadow_error) * * Descrip: Provides a SeqLookupInterface, the common runtime plug-in for indexers * using a ShadowSequenceIndex * * * Arg: shadow_len [UNKN ] Undocumented argument [int] * Arg: has_maxlen [UNKN ] Undocumented argument [int] * Arg: maxlen [UNKN ] Undocumented argument [int] * Arg: shadow_error [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupInterface *] * */ SeqLookupInterface * Wise2_new_ShadowSequenceIndex_SeqLookupInterface(int shadow_len,int has_maxlen,int maxlen,int shadow_error); #define new_ShadowSequenceIndex_SeqLookupInterface Wise2_new_ShadowSequenceIndex_SeqLookupInterface /* Function: get_client_interface_ShadowSequenceIndex(data) * * Descrip: gets client interface * * * Arg: data [UNKN ] Undocumented argument [void*] * * Return [UNKN ] Undocumented return value [SeqLookupClientInterface *] * */ SeqLookupClientInterface * Wise2_get_client_interface_ShadowSequenceIndex(void* data); #define get_client_interface_ShadowSequenceIndex Wise2_get_client_interface_ShadowSequenceIndex /* Function: lookup_interface_ShadowSequenceClient(data,seq_number) * * Descrip: For lookup interface, provides a result * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SeqLookupResultInterface *] * */ SeqLookupResultInterface * Wise2_lookup_interface_ShadowSequenceClient(void * data,int seq_number); #define lookup_interface_ShadowSequenceClient Wise2_lookup_interface_ShadowSequenceClient /* Function: is_populated_interface_ShadowSequenceClient(data,seq_number) * * Descrip: populated function for interface * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq_number [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_populated_interface_ShadowSequenceClient(void * data,int seq_number); #define is_populated_interface_ShadowSequenceClient Wise2_is_populated_interface_ShadowSequenceClient /* Function: add_seq_interface_ShadowSequenceIndex(data,seq,para) * * Descrip: add function for interface * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [SeqLookupLoadPara *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_seq_interface_ShadowSequenceIndex(void * data,Sequence * seq,SeqLookupLoadPara * para); #define add_seq_interface_ShadowSequenceIndex Wise2_add_seq_interface_ShadowSequenceIndex /* Function: free_interface_ShadowSequenceIndex(data) * * Descrip: for interface, frees index * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_interface_ShadowSequenceIndex(void * data); #define free_interface_ShadowSequenceIndex Wise2_free_interface_ShadowSequenceIndex /* Function: free_interface_ShadowSequenceClient(data) * * Descrip: Frees the client data * * * Arg: data [UNKN ] Undocumented argument [void *] * */ void Wise2_free_interface_ShadowSequenceClient(void * data); #define free_interface_ShadowSequenceClient Wise2_free_interface_ShadowSequenceClient /* Function: lookup_result_ShadowSeq(res,in,seq_no) * * Descrip: handles the lookup and storage for a seq_no * lookup * * * Arg: res [UNKN ] Undocumented argument [GenericIndexResult *] * Arg: in [UNKN ] Undocumented argument [ShadowSequenceIndex *] * Arg: seq_no [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_lookup_result_ShadowSeq(GenericIndexResult * res,ShadowSequenceIndex * in,int seq_no); #define lookup_result_ShadowSeq Wise2_lookup_result_ShadowSeq /* Function: add_result_GenericIndexResult_ShadowSeq(res,seq,pos) * * Descrip: adds a particular shadow sequence position, unrolling * shadowed sequences into the result * * * Arg: res [UNKN ] Undocumented argument [GenericIndexResult *] * Arg: seq [UNKN ] Undocumented argument [ShadowSequence *] * Arg: pos [UNKN ] Undocumented argument [int] * */ void Wise2_add_result_GenericIndexResult_ShadowSeq(GenericIndexResult * res,ShadowSequence * seq,int pos); #define add_result_GenericIndexResult_ShadowSeq Wise2_add_result_GenericIndexResult_ShadowSeq /* Function: dump_shadow_ShadowSequenceIndex(in,ofp) * * Descrip: Dumps information about shadows * * * Arg: in [UNKN ] Undocumented argument [ShadowSequenceIndex *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_dump_shadow_ShadowSequenceIndex(ShadowSequenceIndex * in,FILE * ofp); #define dump_shadow_ShadowSequenceIndex Wise2_dump_shadow_ShadowSequenceIndex /* Function: dump_stats_ShadowSequenceIndex(in,ofp) * * Descrip: Dumps useful information out of shadow sequence array * * * Arg: in [UNKN ] Undocumented argument [ShadowSequenceIndex *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_dump_stats_ShadowSequenceIndex(ShadowSequenceIndex * in,FILE * ofp); #define dump_stats_ShadowSequenceIndex Wise2_dump_stats_ShadowSequenceIndex /* Function: add_Sequence_ShadowSequenceIndex(in,seq,min_ext) * * Descrip: Adds a Sequence to a ShadowIndex, placing shadowed regions * correctly away * * * Arg: in [UNKN ] Undocumented argument [ShadowSequenceIndex *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: min_ext [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_Sequence_ShadowSequenceIndex(ShadowSequenceIndex * in,Sequence * seq,int min_ext); #define add_Sequence_ShadowSequenceIndex Wise2_add_Sequence_ShadowSequenceIndex /* Function: new_ShadowSequenceIndex(len,shadow_len,has_maxlen,maxlen,shadow_error) * * Descrip: New ShadowSequenceIndex * * * Arg: len [UNKN ] Undocumented argument [int] * Arg: shadow_len [UNKN ] Undocumented argument [int] * Arg: has_maxlen [UNKN ] Undocumented argument [int] * Arg: maxlen [UNKN ] Undocumented argument [int] * Arg: shadow_error [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ShadowSequenceIndex *] * */ ShadowSequenceIndex * Wise2_new_ShadowSequenceIndex(int len,int shadow_len,int has_maxlen,int maxlen,int shadow_error); #define new_ShadowSequenceIndex Wise2_new_ShadowSequenceIndex /* Function: add_ShadowArraySeqHead(ias,h,seqdb_pos) * * Descrip: Adds a sequence/pos pair to an ArrayHead * * * Arg: ias [UNKN ] Undocumented argument [IntAllocatorSet *] * Arg: h [UNKN ] Undocumented argument [ShadowArraySeqHead *] * Arg: seqdb_pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_ShadowArraySeqHead(IntAllocatorSet * ias,ShadowArraySeqHead * h,int seqdb_pos); #define add_ShadowArraySeqHead Wise2_add_ShadowArraySeqHead /* Function: new_ShadowArraySeqHead(ias) * * Descrip: Builds a new ArraySeqHead structure * * * Arg: ias [UNKN ] Undocumented argument [IntAllocatorSet *] * * Return [UNKN ] Undocumented return value [ShadowArraySeqHead *] * */ ShadowArraySeqHead * Wise2_new_ShadowArraySeqHead(IntAllocatorSet * ias); #define new_ShadowArraySeqHead Wise2_new_ShadowArraySeqHead /* Function: add_ShadowSequenceIndex(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [ShadowSequenceIndex *] * Arg: add [OWNER] Object to add to the list [ShadowSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_ShadowSequenceIndex(ShadowSequenceIndex * obj,ShadowSequence * add); #define add_ShadowSequenceIndex Wise2_add_ShadowSequenceIndex /* Function: flush_ShadowSequenceIndex(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [ShadowSequenceIndex *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_ShadowSequenceIndex(ShadowSequenceIndex * obj); #define flush_ShadowSequenceIndex Wise2_flush_ShadowSequenceIndex /* Function: ShadowSequenceIndex_alloc_std(void) * * Descrip: Equivalent to ShadowSequenceIndex_alloc_len(ShadowSequenceIndexLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [ShadowSequenceIndex *] * */ ShadowSequenceIndex * Wise2_ShadowSequenceIndex_alloc_std(void); #define ShadowSequenceIndex_alloc_std Wise2_ShadowSequenceIndex_alloc_std /* Function: ShadowSequenceIndex_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [ShadowSequenceIndex *] * */ ShadowSequenceIndex * Wise2_ShadowSequenceIndex_alloc_len(int len); #define ShadowSequenceIndex_alloc_len Wise2_ShadowSequenceIndex_alloc_len /* Function: hard_link_ShadowSequenceIndex(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [ShadowSequenceIndex *] * * Return [UNKN ] Undocumented return value [ShadowSequenceIndex *] * */ ShadowSequenceIndex * Wise2_hard_link_ShadowSequenceIndex(ShadowSequenceIndex * obj); #define hard_link_ShadowSequenceIndex Wise2_hard_link_ShadowSequenceIndex /* Function: ShadowSequenceIndex_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [ShadowSequenceIndex *] * */ ShadowSequenceIndex * Wise2_ShadowSequenceIndex_alloc(void); #define ShadowSequenceIndex_alloc Wise2_ShadowSequenceIndex_alloc /* Function: free_ShadowSequenceIndex(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [ShadowSequenceIndex *] * * Return [UNKN ] Undocumented return value [ShadowSequenceIndex *] * */ ShadowSequenceIndex * Wise2_free_ShadowSequenceIndex(ShadowSequenceIndex * obj); #define free_ShadowSequenceIndex Wise2_free_ShadowSequenceIndex /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_ShadowSequenceIndex(ShadowSequence ** list,int i,int j) ; #define swap_ShadowSequenceIndex Wise2_swap_ShadowSequenceIndex void Wise2_qsort_ShadowSequenceIndex(ShadowSequence ** list,int left,int right,int (*comp)(ShadowSequence * ,ShadowSequence * )); #define qsort_ShadowSequenceIndex Wise2_qsort_ShadowSequenceIndex void Wise2_sort_ShadowSequenceIndex(ShadowSequenceIndex * obj,int (*comp)(ShadowSequence *, ShadowSequence *)); #define sort_ShadowSequenceIndex Wise2_sort_ShadowSequenceIndex boolean Wise2_expand_ShadowSequenceIndex(ShadowSequenceIndex * obj,int len); #define expand_ShadowSequenceIndex Wise2_expand_ShadowSequenceIndex #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/packaln.c0000644000175000001440000005206410670453712016422 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "packaln.h" /* Function: read_simple_PackAln_file(file) * * Descrip: Reads in a PackAln from a file in show_simple_PackAln * * * Arg: file [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ # line 57 "packaln.dy" PackAln * read_simple_PackAln_file(char * file) { FILE * ifp; PackAln * out; if( (ifp=openfile(file,"r")) == NULL ) { warn("Could not open %s for PackAln file reading",file); } out = read_simple_PackAln(ifp); fclose(ifp); return out; } /* Function: read_simple_PackAln(ifp) * * Descrip: Reads in PackAln from file format in show_simple_PackAln * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ # line 77 "packaln.dy" PackAln * read_simple_PackAln(FILE * ifp) { PackAln * out; PackAlnUnit * unit; char buffer[MAXLINE]; assert(ifp); out = PackAln_alloc_std(); /* score line */ fgets(buffer,MAXLINE,ifp); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"//") == 0 ) { break; } unit = PackAlnUnit_alloc(); sscanf(buffer,"Position i:[%d] j:[%d] State:[%d] Score: %d",&unit->i,&unit->j,&unit->state,&unit->score); add_PackAln(out,unit); } return out; } /* Function: show_simple_PackAlnUnit(pau,ofp) * * Descrip: shows packalnunit very simply ;) * * * Arg: pau [UNKN ] Undocumented argument [PackAlnUnit *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 110 "packaln.dy" void show_simple_PackAlnUnit(PackAlnUnit * pau,FILE * ofp) { fprintf(ofp,"Position i:[%d] j:[%d] State:[%d] Score: %d\n",pau->i,pau->j,pau->state,pau->score); } /* Function: show_text_PackAlnUnit(state_to_char,pau,ofp) * * Descrip: shows packalnunit with the text mapping * * * Arg: state_to_char [UNKN ] Undocumented argument [NullString] * Arg: pau [UNKN ] Undocumented argument [PackAlnUnit *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 119 "packaln.dy" void show_text_PackAlnUnit(PackAlnUnit * pau,char * (*state_to_char)(int),FILE * ofp) { fprintf(ofp,"Position i:[%4d] j:[%4d] State:[%2d] Score:[%3d] [%s]\n",pau->i,pau->j,pau->state,pau->score,(*state_to_char)(pau->state)); } /* Function: show_bits_and_cumlative_PackAln(pal,ofp) * * Descrip: Shows packaln as: * * i,j,state,score,bits,cumlative-score,cumlative-bits * * cumlative score and cumlative bits are useful sometimes * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 131 "packaln.dy" void show_bits_and_cumlative_PackAln(PackAln * pal,FILE * ofp) { int i; int cs = 0; double cb = 0.0; fprintf(ofp,"Score %d\n",pal->score); for(i=0;ilen;i++) { auto PackAlnUnit * pau; pau = pal->pau[i]; cs += pal->pau[i]->score; cb += Score2Bits(pal->pau[i]->score); fprintf(ofp,"i [%4d] j [%4d] state [%2d] score [%4d] bits [%2.2f] Score-CF [%6d] Bits-CF[%4.2f]\n",pau->i,pau->j,pau->state,pau->score,Score2Bits(pau->score),cs,cb); } } /* Function: show_simple_PackAln(pal,ofp) * * Descrip: shows packaln with a pretty verbose debugging * format * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 155 "packaln.dy" void show_simple_PackAln(PackAln * pal,FILE * ofp) { register int i; fprintf(ofp,"Score %d\n",pal->score); for(i=0;ilen;i++) show_simple_PackAlnUnit(pal->pau[i],ofp); } /* Function: show_text_PackAln(state_to_char,pal,ofp) * * Descrip: shows packaln with a pretty verbose debugging * format, but with a conversion function from state number to * a string * * * Arg: state_to_char [UNKN ] Undocumented argument [NullString] * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 169 "packaln.dy" void show_text_PackAln(PackAln * pal,char * (*state_to_char)(int),FILE * ofp) { register int i; fprintf(ofp,"Score %d\n",pal->score); for(i=0;ilen;i++) show_text_PackAlnUnit(pal->pau[i],state_to_char,ofp); } /* Function: invert_PackAln(pal) * * Descrip: inverts the packaln so that the last unit is the first * etc. Because most alignments are read backwards this * is useful * * * Arg: pal [UNKN ] PackAln to be inverted [PackAln *] * */ # line 185 "packaln.dy" void invert_PackAln(PackAln * pal) { PackAlnUnit ** temp; register int i; /*** there are better ways to do this! ***/ temp = (PackAlnUnit **) ckcalloc(pal->len,sizeof(PackAlnUnit *)); for(i=0;ilen;i++) temp[i] = pal->pau[pal->len-1-i]; for(i=0;ilen;i++) pal->pau[i] = temp[i]; ckfree(temp); } # line 194 "packaln.c" /* Function: hard_link_PackAlnUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PackAlnUnit *] * * Return [UNKN ] Undocumented return value [PackAlnUnit *] * */ PackAlnUnit * hard_link_PackAlnUnit(PackAlnUnit * obj) { if( obj == NULL ) { warn("Trying to hard link to a PackAlnUnit object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PackAlnUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PackAlnUnit *] * */ PackAlnUnit * PackAlnUnit_alloc(void) { PackAlnUnit * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PackAlnUnit *) ckalloc (sizeof(PackAlnUnit))) == NULL) { warn("PackAlnUnit_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->i = 0; out->j = 0; out->state = 0; out->score = 0; return out; } /* Function: free_PackAlnUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PackAlnUnit *] * * Return [UNKN ] Undocumented return value [PackAlnUnit *] * */ PackAlnUnit * free_PackAlnUnit(PackAlnUnit * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PackAlnUnit obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_PackAln(list,i,j) * * Descrip: swap function: an internal for qsort_PackAln * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [PackAlnUnit **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_PackAln(PackAlnUnit ** list,int i,int j) { PackAlnUnit * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_PackAln(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_PackAln which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [PackAlnUnit **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_PackAln(PackAlnUnit ** list,int left,int right,int (*comp)(PackAlnUnit * ,PackAlnUnit * )) { int i,last; if( left >= right ) return; swap_PackAln(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_PackAln (list,++last,i); } swap_PackAln (list,left,last); qsort_PackAln(list,left,last-1,comp); qsort_PackAln(list,last+1,right,comp); } /* Function: sort_PackAln(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_PackAln * * * Arg: obj [UNKN ] Object containing list [PackAln *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_PackAln(PackAln * obj,int (*comp)(PackAlnUnit *, PackAlnUnit *)) { qsort_PackAln(obj->pau,0,obj->len-1,comp); return; } /* Function: expand_PackAln(obj,len) * * Descrip: Really an internal function for add_PackAln * * * Arg: obj [UNKN ] Object which contains the list [PackAln *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_PackAln(PackAln * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_PackAln called with no need"); return TRUE; } if( (obj->pau = (PackAlnUnit ** ) ckrealloc (obj->pau,sizeof(PackAlnUnit *)*len)) == NULL) { warn("ckrealloc failed for expand_PackAln, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_PackAln(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [PackAln *] * Arg: add [OWNER] Object to add to the list [PackAlnUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_PackAln(PackAln * obj,PackAlnUnit * add) { if( obj->len >= obj->maxlen) { if( expand_PackAln(obj,obj->len + PackAlnLISTLENGTH) == FALSE) return FALSE; } obj->pau[obj->len++]=add; return TRUE; } /* Function: flush_PackAln(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [PackAln *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_PackAln(PackAln * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->pau[i] != NULL) { free_PackAlnUnit(obj->pau[i]); obj->pau[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: PackAln_alloc_std(void) * * Descrip: Equivalent to PackAln_alloc_len(PackAlnLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_alloc_std(void) { return PackAln_alloc_len(PackAlnLISTLENGTH); } /* Function: PackAln_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_alloc_len(int len) { PackAln * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = PackAln_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->pau = (PackAlnUnit ** ) ckcalloc (len,sizeof(PackAlnUnit *))) == NULL) { warn("Warning, ckcalloc failed in PackAln_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_PackAln(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PackAln *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * hard_link_PackAln(PackAln * obj) { if( obj == NULL ) { warn("Trying to hard link to a PackAln object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PackAln_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * PackAln_alloc(void) { PackAln * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PackAln *) ckalloc (sizeof(PackAln))) == NULL) { warn("PackAln_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->pau = NULL; out->len = out->maxlen = 0; out->score = 0; return out; } /* Function: free_PackAln(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PackAln *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * free_PackAln(PackAln * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PackAln obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->pau != NULL) { for(i=0;ilen;i++) { if( obj->pau[i] != NULL) free_PackAlnUnit(obj->pau[i]); } ckfree(obj->pau); } ckfree(obj); return NULL; } /* Function: access_pau_PackAln(obj,i) * * Descrip: Access members stored in the pau list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [PackAln *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [PackAlnUnit *] * */ PackAlnUnit * access_pau_PackAln(PackAln * obj,int i) { if( obj == NULL) { warn("In accessor function pau for object PackAln, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function pau for object PackAln, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->pau[i]; } /* Function: length_pau_PackAln(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [PackAln *] * * Return [UNKN ] length of the list [int] * */ int length_pau_PackAln(PackAln * obj) { if( obj == NULL) { warn("In length function pau for object PackAln, got a NULL object"); return -1; } return obj->len; } /* Function: replace_score_PackAln(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PackAln *] * Arg: score [OWNER] New value of the variable [int] * * Return [SOFT ] member variable score [boolean] * */ boolean replace_score_PackAln(PackAln * obj,int score) { if( obj == NULL) { warn("In replacement function score for object PackAln, got a NULL object"); return FALSE; } obj->score = score; return TRUE; } /* Function: access_score_PackAln(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PackAln *] * * Return [SOFT ] member variable score [int] * */ int access_score_PackAln(PackAln * obj) { if( obj == NULL) { warn("In accessor function score for object PackAln, got a NULL object"); return 0; } return obj->score; } /* Function: replace_i_PackAlnUnit(obj,i) * * Descrip: Replace member variable i * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *] * Arg: i [OWNER] New value of the variable [int] * * Return [SOFT ] member variable i [boolean] * */ boolean replace_i_PackAlnUnit(PackAlnUnit * obj,int i) { if( obj == NULL) { warn("In replacement function i for object PackAlnUnit, got a NULL object"); return FALSE; } obj->i = i; return TRUE; } /* Function: access_i_PackAlnUnit(obj) * * Descrip: Access member variable i * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *] * * Return [SOFT ] member variable i [int] * */ int access_i_PackAlnUnit(PackAlnUnit * obj) { if( obj == NULL) { warn("In accessor function i for object PackAlnUnit, got a NULL object"); return 0; } return obj->i; } /* Function: replace_j_PackAlnUnit(obj,j) * * Descrip: Replace member variable j * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *] * Arg: j [OWNER] New value of the variable [int] * * Return [SOFT ] member variable j [boolean] * */ boolean replace_j_PackAlnUnit(PackAlnUnit * obj,int j) { if( obj == NULL) { warn("In replacement function j for object PackAlnUnit, got a NULL object"); return FALSE; } obj->j = j; return TRUE; } /* Function: access_j_PackAlnUnit(obj) * * Descrip: Access member variable j * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *] * * Return [SOFT ] member variable j [int] * */ int access_j_PackAlnUnit(PackAlnUnit * obj) { if( obj == NULL) { warn("In accessor function j for object PackAlnUnit, got a NULL object"); return 0; } return obj->j; } /* Function: replace_state_PackAlnUnit(obj,state) * * Descrip: Replace member variable state * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *] * Arg: state [OWNER] New value of the variable [int] * * Return [SOFT ] member variable state [boolean] * */ boolean replace_state_PackAlnUnit(PackAlnUnit * obj,int state) { if( obj == NULL) { warn("In replacement function state for object PackAlnUnit, got a NULL object"); return FALSE; } obj->state = state; return TRUE; } /* Function: access_state_PackAlnUnit(obj) * * Descrip: Access member variable state * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *] * * Return [SOFT ] member variable state [int] * */ int access_state_PackAlnUnit(PackAlnUnit * obj) { if( obj == NULL) { warn("In accessor function state for object PackAlnUnit, got a NULL object"); return 0; } return obj->state; } /* Function: replace_score_PackAlnUnit(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *] * Arg: score [OWNER] New value of the variable [int] * * Return [SOFT ] member variable score [boolean] * */ boolean replace_score_PackAlnUnit(PackAlnUnit * obj,int score) { if( obj == NULL) { warn("In replacement function score for object PackAlnUnit, got a NULL object"); return FALSE; } obj->score = score; return TRUE; } /* Function: access_score_PackAlnUnit(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [PackAlnUnit *] * * Return [SOFT ] member variable score [int] * */ int access_score_PackAlnUnit(PackAlnUnit * obj) { if( obj == NULL) { warn("In accessor function score for object PackAlnUnit, got a NULL object"); return 0; } return obj->score; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/packaln.h0000644000175000001440000002475010670453712016430 0ustar philippusers#ifndef DYNAMITEpackalnHEADERFILE #define DYNAMITEpackalnHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "probability.h" #define PackAlnLISTLENGTH 64 /* Object PackAlnUnit * * Descrip: Internal object for /PackAln: * A single position of an alignment * as the (i,j,state) triple * * */ struct Wise2_PackAlnUnit { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int i; /* position in query */ int j; /* position in target */ int state; /* state in FSM */ int score; /* score of the transition that reached this state */ } ; /* PackAlnUnit defined */ #ifndef DYNAMITE_DEFINED_PackAlnUnit typedef struct Wise2_PackAlnUnit Wise2_PackAlnUnit; #define PackAlnUnit Wise2_PackAlnUnit #define DYNAMITE_DEFINED_PackAlnUnit #endif /* Object PackAln * * Descrip: This is the lowest-level of representation * of a DP alignment, being the list of * (i,j,state) triples taken through the * DP matrix. The score for the transition to * this point is held as well. * * This object is very low level and often a * much better choice for representation is * in /AlnBlock objects * * */ struct Wise2_PackAln { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif PackAlnUnit ** pau; /* list of PackAlnUnits from start to end */ int len;/* len for above pau */ int maxlen; /* maxlen for above pau */ int score; /* score over the entire alignment */ } ; /* PackAln defined */ #ifndef DYNAMITE_DEFINED_PackAln typedef struct Wise2_PackAln Wise2_PackAln; #define PackAln Wise2_PackAln #define DYNAMITE_DEFINED_PackAln #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: read_simple_PackAln_file(file) * * Descrip: Reads in a PackAln from a file in show_simple_PackAln * * * Arg: file [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_read_simple_PackAln_file(char * file); #define read_simple_PackAln_file Wise2_read_simple_PackAln_file /* Function: read_simple_PackAln(ifp) * * Descrip: Reads in PackAln from file format in show_simple_PackAln * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_read_simple_PackAln(FILE * ifp); #define read_simple_PackAln Wise2_read_simple_PackAln /* Function: show_bits_and_cumlative_PackAln(pal,ofp) * * Descrip: Shows packaln as: * * i,j,state,score,bits,cumlative-score,cumlative-bits * * cumlative score and cumlative bits are useful sometimes * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_bits_and_cumlative_PackAln(PackAln * pal,FILE * ofp); #define show_bits_and_cumlative_PackAln Wise2_show_bits_and_cumlative_PackAln /* Function: show_simple_PackAln(pal,ofp) * * Descrip: shows packaln with a pretty verbose debugging * format * * * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_simple_PackAln(PackAln * pal,FILE * ofp); #define show_simple_PackAln Wise2_show_simple_PackAln /* Function: show_text_PackAln(state_to_char,pal,ofp) * * Descrip: shows packaln with a pretty verbose debugging * format, but with a conversion function from state number to * a string * * * Arg: state_to_char [UNKN ] Undocumented argument [NullString] * Arg: pal [UNKN ] Undocumented argument [PackAln *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_text_PackAln(PackAln * pal,char * (*state_to_char)(int),FILE * ofp); #define show_text_PackAln Wise2_show_text_PackAln /* Function: invert_PackAln(pal) * * Descrip: inverts the packaln so that the last unit is the first * etc. Because most alignments are read backwards this * is useful * * * Arg: pal [UNKN ] PackAln to be inverted [PackAln *] * */ void Wise2_invert_PackAln(PackAln * pal) ; #define invert_PackAln Wise2_invert_PackAln /* Function: hard_link_PackAlnUnit(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PackAlnUnit *] * * Return [UNKN ] Undocumented return value [PackAlnUnit *] * */ PackAlnUnit * Wise2_hard_link_PackAlnUnit(PackAlnUnit * obj); #define hard_link_PackAlnUnit Wise2_hard_link_PackAlnUnit /* Function: PackAlnUnit_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PackAlnUnit *] * */ PackAlnUnit * Wise2_PackAlnUnit_alloc(void); #define PackAlnUnit_alloc Wise2_PackAlnUnit_alloc /* Function: free_PackAlnUnit(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PackAlnUnit *] * * Return [UNKN ] Undocumented return value [PackAlnUnit *] * */ PackAlnUnit * Wise2_free_PackAlnUnit(PackAlnUnit * obj); #define free_PackAlnUnit Wise2_free_PackAlnUnit /* Function: add_PackAln(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [PackAln *] * Arg: add [OWNER] Object to add to the list [PackAlnUnit *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_PackAln(PackAln * obj,PackAlnUnit * add); #define add_PackAln Wise2_add_PackAln /* Function: flush_PackAln(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [PackAln *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_PackAln(PackAln * obj); #define flush_PackAln Wise2_flush_PackAln /* Function: PackAln_alloc_std(void) * * Descrip: Equivalent to PackAln_alloc_len(PackAlnLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_alloc_std(void); #define PackAln_alloc_std Wise2_PackAln_alloc_std /* Function: PackAln_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_alloc_len(int len); #define PackAln_alloc_len Wise2_PackAln_alloc_len /* Function: hard_link_PackAln(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PackAln *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_hard_link_PackAln(PackAln * obj); #define hard_link_PackAln Wise2_hard_link_PackAln /* Function: PackAln_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_PackAln_alloc(void); #define PackAln_alloc Wise2_PackAln_alloc /* Function: free_PackAln(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PackAln *] * * Return [UNKN ] Undocumented return value [PackAln *] * */ PackAln * Wise2_free_PackAln(PackAln * obj); #define free_PackAln Wise2_free_PackAln /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ PackAlnUnit * Wise2_access_pau_PackAln(PackAln * obj,int i); #define access_pau_PackAln Wise2_access_pau_PackAln int Wise2_access_score_PackAln(PackAln * obj); #define access_score_PackAln Wise2_access_score_PackAln boolean Wise2_replace_i_PackAlnUnit(PackAlnUnit * obj,int i); #define replace_i_PackAlnUnit Wise2_replace_i_PackAlnUnit int Wise2_access_score_PackAlnUnit(PackAlnUnit * obj); #define access_score_PackAlnUnit Wise2_access_score_PackAlnUnit int Wise2_access_i_PackAlnUnit(PackAlnUnit * obj); #define access_i_PackAlnUnit Wise2_access_i_PackAlnUnit boolean Wise2_replace_j_PackAlnUnit(PackAlnUnit * obj,int j); #define replace_j_PackAlnUnit Wise2_replace_j_PackAlnUnit boolean Wise2_replace_score_PackAlnUnit(PackAlnUnit * obj,int score); #define replace_score_PackAlnUnit Wise2_replace_score_PackAlnUnit int Wise2_access_j_PackAlnUnit(PackAlnUnit * obj); #define access_j_PackAlnUnit Wise2_access_j_PackAlnUnit boolean Wise2_replace_score_PackAln(PackAln * obj,int score); #define replace_score_PackAln Wise2_replace_score_PackAln boolean Wise2_replace_state_PackAlnUnit(PackAlnUnit * obj,int state); #define replace_state_PackAlnUnit Wise2_replace_state_PackAlnUnit int Wise2_length_pau_PackAln(PackAln * obj); #define length_pau_PackAln Wise2_length_pau_PackAln int Wise2_access_state_PackAlnUnit(PackAlnUnit * obj); #define access_state_PackAlnUnit Wise2_access_state_PackAlnUnit void Wise2_show_simple_PackAlnUnit(PackAlnUnit * pau,FILE * ofp); #define show_simple_PackAlnUnit Wise2_show_simple_PackAlnUnit void Wise2_show_text_PackAlnUnit(PackAlnUnit * pau,char * (*state_to_char)(int),FILE * ofp); #define show_text_PackAlnUnit Wise2_show_text_PackAlnUnit void Wise2_swap_PackAln(PackAlnUnit ** list,int i,int j) ; #define swap_PackAln Wise2_swap_PackAln void Wise2_qsort_PackAln(PackAlnUnit ** list,int left,int right,int (*comp)(PackAlnUnit * ,PackAlnUnit * )); #define qsort_PackAln Wise2_qsort_PackAln void Wise2_sort_PackAln(PackAln * obj,int (*comp)(PackAlnUnit *, PackAlnUnit *)); #define sort_PackAln Wise2_sort_PackAln boolean Wise2_expand_PackAln(PackAln * obj,int len); #define expand_PackAln Wise2_expand_PackAln #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/test_seqhash.c0000644000175000001440000000411107536706203017475 0ustar philippusers #include "seqlookup.h" #include "subseqhash.h" #include "sequencedb.h" #include "hsp.h" #include "hitlist.h" #include "hsplookupscan.h" void print_hsp(gpointer key,gpointer value,gpointer user_data) { Sequence * query; HSPset * set; btCanvas * btc; btPasteArea * btp; int i,j; char q,t; query = (Sequence *)user_data; set = (HSPset *) value; btc = new_Ascii_btCanvas(stdout,12,50,5,3); for(i=0;ilen;i++) { for(j=0;jhsp[i]->length;) { btp = get_reserved_left_btCanvas(btc); paste_string_btPasteArea(btp,0,0,query->name,BC_RIGHT,0); paste_string_btPasteArea(btp,0,2,set->hsp[i]->target->name,BC_RIGHT,0); free_btPasteArea(btp); for(;jhsp[i]->length && can_get_paste_area_btCanvas(btc,1) == TRUE;j++) { btp = get_paste_area_btCanvas(btc,1); q = query->seq[set->hsp[i]->query_start+j]; t = set->hsp[i]->target->seq[set->hsp[i]->target_start+j]; paste_char_btPasteArea(btp,0,0,q,0); paste_char_btPasteArea(btp,0,2,t,0); if( q == t ) { paste_char_btPasteArea(btp,0,1,t,0); } free_btPasteArea(btp); } advance_line_btCanvas(btc); } advance_line_btCanvas(btc); } free_btCanvas(btc); } int main(int argc,char ** argv) { SequenceDB * db; Sequence * seq; SeqLookupInterface * sli; SeqLookupPos * slp; HSPScanInterface * hsi; LinearHSPmanager * lm; HitList * hl; CompMat * mat; int ret; HSPScanInterfacePara p; p.min_score= 30; p.max_results = 200; db = single_fasta_SequenceDB(argv[1]); mat = read_Blast_file_CompMat("blosum62.bla"); sli = new_ghash_SeqLookupInterface(); for(seq = init_SequenceDB(db,&ret); seq != NULL;seq = get_next_SequenceDB(db) ) { load_aa_flat_Sequence_SeqLookupInterface(sli,hard_link_Sequence(seq)); } seq = read_fasta_file_Sequence(argv[2]); assert(seq); hsi = Wise2_new_one_off_HSPScanInterface(sli,mat,20,10); /* hspm = simple_HSPScan_scan_query((void*)hsi->data,seq); */ lm = (*hsi->scan_query)(hsi->data,seq,&p); hl = Wise2_HitList_from_LinearHSPmanager(lm); Wise2_write_pseudoblast_HitList(hl,stdout); } wise-2.4.1/src/dynlibsrc/alnrange.pod0000644000175000001440000002017310670453712017134 0ustar philippusers=head1 NAME alnrange module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item AlnRange =item AlnRangeSet =back =head1 DESCRIPTION =head2 Object AlnRange =over =item starti Type [int] Scalar No documentation =item startj Type [int] Scalar No documentation =item startstate Type [int] Scalar No documentation =item stopi Type [int] Scalar No documentation =item stopj Type [int] Scalar No documentation =item stopstate Type [int] Scalar No documentation =item startscore Type [int] Scalar No documentation =item stopscore Type [int] Scalar No documentation =back No documentation for AlnRange =head2 Member functions of AlnRange =over =item hard_link_AlnRange &Wise2::AlnRange::hard_link_AlnRange(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [AlnRange *] Return [UNKN ] Undocumented return value [AlnRange *] =item alloc &Wise2::AlnRange::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [AlnRange *] =item set_starti &Wise2::AlnRange::set_starti(obj,starti) Replace member variable starti For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Argument starti [OWNER] New value of the variable [int] Return [SOFT ] member variable starti [boolean] =item starti &Wise2::AlnRange::starti(obj) Access member variable starti For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Return [SOFT ] member variable starti [int] =item set_startj &Wise2::AlnRange::set_startj(obj,startj) Replace member variable startj For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Argument startj [OWNER] New value of the variable [int] Return [SOFT ] member variable startj [boolean] =item startj &Wise2::AlnRange::startj(obj) Access member variable startj For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Return [SOFT ] member variable startj [int] =item set_startstate &Wise2::AlnRange::set_startstate(obj,startstate) Replace member variable startstate For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Argument startstate [OWNER] New value of the variable [int] Return [SOFT ] member variable startstate [boolean] =item startstate &Wise2::AlnRange::startstate(obj) Access member variable startstate For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Return [SOFT ] member variable startstate [int] =item set_stopi &Wise2::AlnRange::set_stopi(obj,stopi) Replace member variable stopi For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Argument stopi [OWNER] New value of the variable [int] Return [SOFT ] member variable stopi [boolean] =item stopi &Wise2::AlnRange::stopi(obj) Access member variable stopi For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Return [SOFT ] member variable stopi [int] =item set_stopj &Wise2::AlnRange::set_stopj(obj,stopj) Replace member variable stopj For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Argument stopj [OWNER] New value of the variable [int] Return [SOFT ] member variable stopj [boolean] =item stopj &Wise2::AlnRange::stopj(obj) Access member variable stopj For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Return [SOFT ] member variable stopj [int] =item set_stopstate &Wise2::AlnRange::set_stopstate(obj,stopstate) Replace member variable stopstate For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Argument stopstate [OWNER] New value of the variable [int] Return [SOFT ] member variable stopstate [boolean] =item stopstate &Wise2::AlnRange::stopstate(obj) Access member variable stopstate For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Return [SOFT ] member variable stopstate [int] =item set_startscore &Wise2::AlnRange::set_startscore(obj,startscore) Replace member variable startscore For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Argument startscore [OWNER] New value of the variable [int] Return [SOFT ] member variable startscore [boolean] =item startscore &Wise2::AlnRange::startscore(obj) Access member variable startscore For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Return [SOFT ] member variable startscore [int] =item set_stopscore &Wise2::AlnRange::set_stopscore(obj,stopscore) Replace member variable stopscore For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Argument stopscore [OWNER] New value of the variable [int] Return [SOFT ] member variable stopscore [boolean] =item stopscore &Wise2::AlnRange::stopscore(obj) Access member variable stopscore For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRange *] Return [SOFT ] member variable stopscore [int] =back =head2 Object AlnRangeSet =over =item score Type [int] Scalar over complete alignment =item alr Type [AlnRange **] List No documentation =back No documentation for AlnRangeSet =head2 Member functions of AlnRangeSet =over =item hard_link_AlnRangeSet &Wise2::AlnRangeSet::hard_link_AlnRangeSet(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [AlnRangeSet *] Return [UNKN ] Undocumented return value [AlnRangeSet *] =item AlnRangeSet_alloc_std &Wise2::AlnRangeSet::AlnRangeSet_alloc_std(void) Equivalent to AlnRangeSet_alloc_len(AlnRangeSetLISTLENGTH) Return [UNKN ] Undocumented return value [AlnRangeSet *] =item set_score &Wise2::AlnRangeSet::set_score(obj,score) Replace member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRangeSet *] Argument score [OWNER] New value of the variable [int] Return [SOFT ] member variable score [boolean] =item score &Wise2::AlnRangeSet::score(obj) Access member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [AlnRangeSet *] Return [SOFT ] member variable score [int] =item alr &Wise2::AlnRangeSet::alr(obj,i) Access members stored in the alr list For use principly by API functions Argument obj [UNKN ] Object holding the list [AlnRangeSet *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [AlnRange *] =item length_alr &Wise2::AlnRangeSet::length_alr(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [AlnRangeSet *] Return [UNKN ] length of the list [int] =item flush_alr &Wise2::AlnRangeSet::flush_alr(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [AlnRangeSet *] Return [UNKN ] Undocumented return value [int] =item add_alr &Wise2::AlnRangeSet::add_alr(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [AlnRangeSet *] Argument add [OWNER] Object to add to the list [AlnRange *] Return [UNKN ] Undocumented return value [boolean] =back wise-2.4.1/src/dynlibsrc/alnrange.tex0000644000175000001440000000237010670453712017151 0ustar philippusers\section{alnrange} \label{module_alnrange} This module contains the following objects \begin{itemize} \item \ref{object_AlnRange} AlnRange \item \ref{object_AlnRangeSet} AlnRangeSet \end{itemize} \subsection{Object AlnRange} \label{object_AlnRange} The AlnRange object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{starti} Type [int : Scalar] No documentation \item{startj} Type [int : Scalar] No documentation \item{startstate} Type [int : Scalar] No documentation \item{stopi} Type [int : Scalar] No documentation \item{stopj} Type [int : Scalar] No documentation \item{stopstate} Type [int : Scalar] No documentation \item{startscore} Type [int : Scalar] No documentation \item{stopscore} Type [int : Scalar] No documentation \end{description} No documentation for AlnRange Member functions of AlnRange \subsection{Object AlnRangeSet} \label{object_AlnRangeSet} The AlnRangeSet object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{score} Type [int : Scalar] over complete alignment \item{alr} Type [AlnRange ** : List] No documentation \end{description} No documentation for AlnRangeSet Member functions of AlnRangeSet wise-2.4.1/src/dynlibsrc/codonmapper.c0000644000175000001440000004061210670453712017314 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "codonmapper.h" /* Function: CodonFrequence_from_raw_counts(codon,ct) * * Descrip: Builds a codon frequency from raw counts as just an array * * * Arg: codon [UNKN ] Undocumented argument [double *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [CodonFrequency *] * */ # line 56 "codonmapper.dy" CodonFrequency * CodonFrequence_from_raw_counts(double * codon,CodonTable * ct) { double total[26]; CodonFrequency * cf; register int i; int c; register int j; for(i=0;i<26;i++) { total[i] = 0.0; for(j=0;j<64;j++) { c = codon_from_base4_codon(j); if( ct->codon_str[c] == ('A' + i) ) { total[i] += codon[j]; } } } cf = CodonFrequency_alloc(); for(i=0;i<64;i++) { c = codon_from_base4_codon(i); if( is_stop_codon(c,ct) ) continue; if( codon[i] < 0.0000000001) cf->freq[i] = 0.0; else { if( total[ct->codon_str[c] -'A'] < 0.00000001 ) { warn("For codon %d, amino acid %c, we have no frequency",i,ct->codon_str[i]); } else cf->freq[i] = codon[i] / total[ct->codon_str[c]-'A']; } } return cf; } /* Function: show_CodonMapper(cm,ofp) * * Descrip: Shows codon mapper in vaguely human form * * * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 102 "codonmapper.dy" void show_CodonMapper(CodonMapper * cm,FILE * ofp) { register int i; register int j; for(i=0;i<125;i++) { fprintf(ofp,"[%3d][%c] %.2f",i,aminoacid_from_codon(cm->ct,i),cm->codon_map[i][0]); for(j=1;j<26;j++) fprintf(ofp,",%.2f",cm->codon_map[i][j]); fprintf(ofp,"\n"); } } /* Function: show_CodonFrequency(cf,ct,ofp) * * Descrip: Shows codon frequency in vaguely human form * * * Arg: cf [UNKN ] Undocumented argument [CodonFrequency *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 120 "codonmapper.dy" void show_CodonFrequency(CodonFrequency * cf,CodonTable * ct,FILE * ofp) { int i; for(i=0;i<64;i++) fprintf(ofp,"[%3d][%c] %.2f\n",i,aminoacid_from_codon(ct,codon_from_base4_codon(i)),cf->freq[i]); } /* Function: flat_CodonMapper(ct) * * Descrip: Makes a CodonMapper with no codon bias * or error possiblities from codon table * * * * Arg: ct [UNKN ] Codon Table giving codon->aa info [CodonTable *] * * Return [UNKN ] Undocumented return value [CodonMapper *] * */ # line 137 "codonmapper.dy" CodonMapper * flat_CodonMapper(CodonTable * ct) { CodonFrequency * cf; CodonMapper * out; cf = flat_CodonFrequency(ct); out = new_CodonMapper(ct,cf); free_CodonFrequency(cf); return out; } /* Function: flat_CodonFrequency(ct) * * Descrip: Makes a no-biased codon Frequency. * Probabaly most used in /flat_CodonMapper * * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [CodonFrequency *] * */ # line 158 "codonmapper.dy" CodonFrequency * flat_CodonFrequency(CodonTable * ct) { int number[26]; CodonFrequency * out; register int i; out = CodonFrequency_alloc(); for(i=0;i<26;i++) number[i] = 0; for(i=0;i<64;i++) out->freq[i]= 0.0; for(i=0;i<125;i++) if( has_random_bases(i) == FALSE && is_stop_codon(i,ct) == FALSE) number[aminoacid_no_from_codon(ct,i)]++; for(i=0;i<64;i++) { if( is_stop_codon(codon_from_base4_codon(i),ct) == FALSE && number[aminoacid_no_from_codon(ct,codon_from_base4_codon(i))] != 0) out->freq[i] = 1.0 / number[aminoacid_no_from_codon(ct,codon_from_base4_codon(i))]; } return out; } /*** ***/ /* Function: construct_amino_number_array(number,ct) * * Descrip: Assummes number is an int * of length 26 * * Files up each position with the number of codons representing that aa * * * * Arg: number [UNKN ] Undocumented argument [int *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * */ # line 197 "codonmapper.dy" void construct_amino_number_array(int * number,CodonTable * ct) { register int i; register int j; for(i=0;i<26;i++) { number[i] = 0; for(j=0;j<64;j++) { if( ct->codon_str[j] == 'A' + i) number[i]++; } } } /* Function: map_codon_array_CodonMapper(codon_array,protein_array,stop,cm) * * Descrip: Now defunct. * * * Arg: codon_array [UNKN ] Undocumented argument [double *] * Arg: protein_array [UNKN ] Undocumented argument [double *] * Arg: stop [UNKN ] Undocumented argument [double] * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * */ # line 218 "codonmapper.dy" void map_codon_array_CodonMapper(double * codon_array,double * protein_array,double stop,CodonMapper * cm) { register int i; for(i=0;i<125;i++) { if( is_stop_codon(i,cm->ct)== TRUE ) codon_array[i] = stop; else codon_array[i] = map_codon_CodonMapper(i,protein_array,cm); } } /* Function: true_map_codon_array_CodonMapper(codon_array,protein_array,cm) * * Descrip: Takes an array of probabilities from 0-26 in protein array * and writes into codon_array the adjusted probability from the * codon mapper. Ie, maps a protein emission line to a codon emission * line. This is the main use of CodonMapper. * * * * Arg: codon_array [WRITE] array (0-124) for the codon probabilities to be placed [double *] * Arg: protein_array [READ ] array (0-25) for the protein probabilities to be read from [const double *] * Arg: cm [UNKN ] Codon Mapper that provides the protein->codon mapping [CodonMapper *] * */ # line 241 "codonmapper.dy" void true_map_codon_array_CodonMapper(double * codon_array,const double * protein_array,CodonMapper * cm) { int i; for(i=0;i<125;i++) { codon_array[i] = map_codon_CodonMapper(i,protein_array,cm); } } /* Function: map_codon_CodonMapper(codon,protein_array,cm) * * Descrip: Does the mapping for a single codon from a protein_array * * * Arg: codon [UNKN ] Undocumented argument [int] * Arg: protein_array [UNKN ] Undocumented argument [const double *] * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * * Return [UNKN ] Undocumented return value [double] * */ # line 255 "codonmapper.dy" double map_codon_CodonMapper(int codon,const double * protein_array,CodonMapper * cm) { register int i; double out = 0.0; if( cm->codon_map[codon][0] < 0.0 ) { warn("Attempting to map a codon with below zero prob in map_codon_CodonMapper. This is bad news...."); return 0.0; } for(i=0;i<26;i++) { out += protein_array[i] * cm->codon_map[codon][i]; } return out; } /* Function: sprinkle_errors_over_CodonMapper(cm,error) * * Descrip: Takes a codon mapper and assummes that the majority of errors * are due to a single base change in the codon at probability error. * Therefore, for each codon it adds error * prob(codon) * 0.25 to each * other codon one base away, taking away therefore the result. * * * * Arg: cm [READ ] CodonMapper to be sprinkled [CodonMapper *] * Arg: error [UNKN ] substitution error rate [double] * */ # line 283 "codonmapper.dy" void sprinkle_errors_over_CodonMapper(CodonMapper * cm,double error) { int i; int j; int k; base one; base two; base three; int new_codon; double scratch[125][26]; /* * put all the codons into scratch, but * subtracting 3*error which is the possibility * of an error. * * The self->self errors (eg, G to G) will be * added back later */ for(i=0;i<125;i++) for(j=0;j<26;j++) scratch[i][j] = cm->codon_map[i][j] * (1-(3*error)); /* * Now for each codon, find the single base change, * and add the probability for each amino acid onto it * factored by 0.25 * */ for(i=0;i<125;i++) { all_bases_from_codon(i,&one,&two,&three); if( one != BASE_N) { for(j=0;j<4;j++) { new_codon = j*25 + two * 5 + three; for(k=0;k<26;k++) scratch[i][k] += (cm->codon_map[new_codon][k] * error * 0.25); } } if( two != BASE_N) { for(j=0;j<4;j++) { new_codon = one*25 + j * 5 + three; for(k=0;k<26;k++) scratch[i][k] += (cm->codon_map[new_codon][k] * error * 0.25); } } if( three != BASE_N) { for(j=0;j<4;j++) { new_codon = one*25 + two * 5 + j; for(k=0;k<26;k++) scratch[i][k] += (cm->codon_map[new_codon][k] * error * 0.25); } } } /* * Now map back to original memory */ for(i=0;i<125;i++) for(j=0;j<26;j++) cm->codon_map[i][j] = scratch[i][j]; } /* Function: new_CodonMapper(ct,cf) * * Descrip: The only way you should make a CodonMapper! * * Makes a codon mapper from CodonTable and frequency * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: cf [UNKN ] Undocumented argument [CodonFrequency *] * * Return [UNKN ] Undocumented return value [CodonMapper *] * */ # line 369 "codonmapper.dy" CodonMapper * new_CodonMapper(CodonTable * ct,CodonFrequency * cf) { register int i; register int j; int k; base one; base two; base three; int base4; int oi,ti,ri; double total_freq; CodonMapper * out; out = CodonMapper_alloc(); out->ct = hard_link_CodonTable(ct); for(i=0;i<125;i++) { for(j=0;j<26;j++) out->codon_map[i][j] =0.0; if( has_random_bases(i) == FALSE ) { if( is_stop_codon(i,ct) == TRUE ) { for(k=0;k<26;k++) out->codon_map[i][k] = (0.0); } else { out->codon_map[i][aminoacid_no_from_codon(ct,i)] = cf->freq[base4_codon_from_codon(i)]; } } else { /*** is a random base ***/ /*** sneaky stuff. What we want to do is loop over all possible codons, adding up their frequencies for the amino acids they represent. This is done by looping over all possible bases for each position and then letting through ones which either have an N at this position or is the actual base. ***/ all_bases_from_codon(i,&one,&two,&three); total_freq = 0.0; for(oi=0;oi<4;oi++) for(ti=0;ti<4;ti++) for(ri=0;ri<4;ri++) { if( (one == BASE_N || one == oi) && (two == BASE_N || two == ti) && (three == BASE_N || three == ri) ) { base4 = codon_from_base4_codon(oi*16+ti*4+ri); if( !is_stop_codon(base4,ct) ) { out->codon_map[i][aminoacid_no_from_codon(ct,base4)] += cf->freq[base4_codon_from_codon(base4)]; } } /* end of if one == BASE_N || one == oi */ } /* end of for oi,ti,ri */ } /* end of else */ } return out; } # line 443 "codonmapper.c" /* Function: hard_link_CodonMapper(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CodonMapper *] * * Return [UNKN ] Undocumented return value [CodonMapper *] * */ CodonMapper * hard_link_CodonMapper(CodonMapper * obj) { if( obj == NULL ) { warn("Trying to hard link to a CodonMapper object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CodonMapper_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CodonMapper *] * */ CodonMapper * CodonMapper_alloc(void) { CodonMapper * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CodonMapper *) ckalloc (sizeof(CodonMapper))) == NULL) { warn("CodonMapper_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->ct = NULL; /* codon_map[125][26] is an array: no default possible */ return out; } /* Function: free_CodonMapper(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CodonMapper *] * * Return [UNKN ] Undocumented return value [CodonMapper *] * */ CodonMapper * free_CodonMapper(CodonMapper * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CodonMapper obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->ct != NULL) free_CodonTable(obj->ct); ckfree(obj); return NULL; } /* Function: hard_link_CodonFrequency(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CodonFrequency *] * * Return [UNKN ] Undocumented return value [CodonFrequency *] * */ CodonFrequency * hard_link_CodonFrequency(CodonFrequency * obj) { if( obj == NULL ) { warn("Trying to hard link to a CodonFrequency object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CodonFrequency_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CodonFrequency *] * */ CodonFrequency * CodonFrequency_alloc(void) { CodonFrequency * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CodonFrequency *) ckalloc (sizeof(CodonFrequency))) == NULL) { warn("CodonFrequency_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* freq[64] is an array: no default possible */ return out; } /* Function: free_CodonFrequency(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CodonFrequency *] * * Return [UNKN ] Undocumented return value [CodonFrequency *] * */ CodonFrequency * free_CodonFrequency(CodonFrequency * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CodonFrequency obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: replace_ct_CodonMapper(obj,ct) * * Descrip: Replace member variable ct * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [CodonMapper *] * Arg: ct [OWNER] New value of the variable [CodonTable *] * * Return [SOFT ] member variable ct [boolean] * */ boolean replace_ct_CodonMapper(CodonMapper * obj,CodonTable * ct) { if( obj == NULL) { warn("In replacement function ct for object CodonMapper, got a NULL object"); return FALSE; } obj->ct = ct; return TRUE; } /* Function: access_ct_CodonMapper(obj) * * Descrip: Access member variable ct * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [CodonMapper *] * * Return [SOFT ] member variable ct [CodonTable *] * */ CodonTable * access_ct_CodonMapper(CodonMapper * obj) { if( obj == NULL) { warn("In accessor function ct for object CodonMapper, got a NULL object"); return NULL; } return obj->ct; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/codonmapper.h0000644000175000001440000002243310670453712017322 0ustar philippusers#ifndef DYNAMITEcodonmapperHEADERFILE #define DYNAMITEcodonmapperHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "codon.h" /* Object CodonMapper * * Descrip: CodonMapper holds a matrix of 125 by 26 * to provide a mapping between a probabilities * calculated on amino acids to triplet codon * probabilities. This mapping takes into account * 3 things * 1) The CodonTable * 2) The distribution of synonmous codons (codon bias) * 3) substitution errors * * */ struct Wise2_CodonMapper { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif CodonTable * ct; /* hard-linked! */ double codon_map[125][26]; } ; /* CodonMapper defined */ #ifndef DYNAMITE_DEFINED_CodonMapper typedef struct Wise2_CodonMapper Wise2_CodonMapper; #define CodonMapper Wise2_CodonMapper #define DYNAMITE_DEFINED_CodonMapper #endif /* Object CodonFrequency * * Descrip: CodonFrequency is a very much internal object for * CodonMapper. It provides the frequency of synomous * codons, ie, an amino acid with only one codon will * have 1.0 in the frequency table * * Rarely used outside of CodonMapper construction * * */ struct Wise2_CodonFrequency { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif double freq[64]; } ; /* CodonFrequency defined */ #ifndef DYNAMITE_DEFINED_CodonFrequency typedef struct Wise2_CodonFrequency Wise2_CodonFrequency; #define CodonFrequency Wise2_CodonFrequency #define DYNAMITE_DEFINED_CodonFrequency #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: CodonFrequence_from_raw_counts(codon,ct) * * Descrip: Builds a codon frequency from raw counts as just an array * * * Arg: codon [UNKN ] Undocumented argument [double *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [CodonFrequency *] * */ CodonFrequency * Wise2_CodonFrequence_from_raw_counts(double * codon,CodonTable * ct); #define CodonFrequence_from_raw_counts Wise2_CodonFrequence_from_raw_counts /* Function: show_CodonMapper(cm,ofp) * * Descrip: Shows codon mapper in vaguely human form * * * Arg: cm [UNKN ] Undocumented argument [CodonMapper *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_CodonMapper(CodonMapper * cm,FILE * ofp); #define show_CodonMapper Wise2_show_CodonMapper /* Function: show_CodonFrequency(cf,ct,ofp) * * Descrip: Shows codon frequency in vaguely human form * * * Arg: cf [UNKN ] Undocumented argument [CodonFrequency *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_CodonFrequency(CodonFrequency * cf,CodonTable * ct,FILE * ofp); #define show_CodonFrequency Wise2_show_CodonFrequency /* Function: flat_CodonMapper(ct) * * Descrip: Makes a CodonMapper with no codon bias * or error possiblities from codon table * * * * Arg: ct [UNKN ] Codon Table giving codon->aa info [CodonTable *] * * Return [UNKN ] Undocumented return value [CodonMapper *] * */ CodonMapper * Wise2_flat_CodonMapper(CodonTable * ct); #define flat_CodonMapper Wise2_flat_CodonMapper /* Function: flat_CodonFrequency(ct) * * Descrip: Makes a no-biased codon Frequency. * Probabaly most used in /flat_CodonMapper * * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * * Return [UNKN ] Undocumented return value [CodonFrequency *] * */ CodonFrequency * Wise2_flat_CodonFrequency(CodonTable * ct); #define flat_CodonFrequency Wise2_flat_CodonFrequency /* Function: true_map_codon_array_CodonMapper(codon_array,protein_array,cm) * * Descrip: Takes an array of probabilities from 0-26 in protein array * and writes into codon_array the adjusted probability from the * codon mapper. Ie, maps a protein emission line to a codon emission * line. This is the main use of CodonMapper. * * * * Arg: codon_array [WRITE] array (0-124) for the codon probabilities to be placed [double *] * Arg: protein_array [READ ] array (0-25) for the protein probabilities to be read from [const double *] * Arg: cm [UNKN ] Codon Mapper that provides the protein->codon mapping [CodonMapper *] * */ void Wise2_true_map_codon_array_CodonMapper(double * codon_array,const double * protein_array,CodonMapper * cm); #define true_map_codon_array_CodonMapper Wise2_true_map_codon_array_CodonMapper /* Function: sprinkle_errors_over_CodonMapper(cm,error) * * Descrip: Takes a codon mapper and assummes that the majority of errors * are due to a single base change in the codon at probability error. * Therefore, for each codon it adds error * prob(codon) * 0.25 to each * other codon one base away, taking away therefore the result. * * * * Arg: cm [READ ] CodonMapper to be sprinkled [CodonMapper *] * Arg: error [UNKN ] substitution error rate [double] * */ void Wise2_sprinkle_errors_over_CodonMapper(CodonMapper * cm,double error); #define sprinkle_errors_over_CodonMapper Wise2_sprinkle_errors_over_CodonMapper /* Function: new_CodonMapper(ct,cf) * * Descrip: The only way you should make a CodonMapper! * * Makes a codon mapper from CodonTable and frequency * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: cf [UNKN ] Undocumented argument [CodonFrequency *] * * Return [UNKN ] Undocumented return value [CodonMapper *] * */ CodonMapper * Wise2_new_CodonMapper(CodonTable * ct,CodonFrequency * cf); #define new_CodonMapper Wise2_new_CodonMapper /* Function: hard_link_CodonMapper(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CodonMapper *] * * Return [UNKN ] Undocumented return value [CodonMapper *] * */ CodonMapper * Wise2_hard_link_CodonMapper(CodonMapper * obj); #define hard_link_CodonMapper Wise2_hard_link_CodonMapper /* Function: CodonMapper_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CodonMapper *] * */ CodonMapper * Wise2_CodonMapper_alloc(void); #define CodonMapper_alloc Wise2_CodonMapper_alloc /* Function: free_CodonMapper(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CodonMapper *] * * Return [UNKN ] Undocumented return value [CodonMapper *] * */ CodonMapper * Wise2_free_CodonMapper(CodonMapper * obj); #define free_CodonMapper Wise2_free_CodonMapper /* Function: hard_link_CodonFrequency(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CodonFrequency *] * * Return [UNKN ] Undocumented return value [CodonFrequency *] * */ CodonFrequency * Wise2_hard_link_CodonFrequency(CodonFrequency * obj); #define hard_link_CodonFrequency Wise2_hard_link_CodonFrequency /* Function: CodonFrequency_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CodonFrequency *] * */ CodonFrequency * Wise2_CodonFrequency_alloc(void); #define CodonFrequency_alloc Wise2_CodonFrequency_alloc /* Function: free_CodonFrequency(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CodonFrequency *] * * Return [UNKN ] Undocumented return value [CodonFrequency *] * */ CodonFrequency * Wise2_free_CodonFrequency(CodonFrequency * obj); #define free_CodonFrequency Wise2_free_CodonFrequency /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ CodonTable * Wise2_access_ct_CodonMapper(CodonMapper * obj); #define access_ct_CodonMapper Wise2_access_ct_CodonMapper boolean Wise2_replace_ct_CodonMapper(CodonMapper * obj,CodonTable * ct); #define replace_ct_CodonMapper Wise2_replace_ct_CodonMapper void Wise2_construct_amino_number_array(int * number,CodonTable * ct); #define construct_amino_number_array Wise2_construct_amino_number_array void Wise2_map_codon_array_CodonMapper(double * codon_array,double * protein_array,double stop,CodonMapper * cm); #define map_codon_array_CodonMapper Wise2_map_codon_array_CodonMapper double Wise2_map_codon_CodonMapper(int codon,const double * protein_array,CodonMapper * cm); #define map_codon_CodonMapper Wise2_map_codon_CodonMapper #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/hitlist.dy0000644000175000001440000004000110414205303016632 0ustar philippusers %{ #include "sequence.h" #include "hsp.h" #include "aln.h" #include "compmat.h" #include "btcanvas.h" #include "asciibtcanvas.h" #include "searchstatinterface.h" #define HitListLISTLENGTH 256 #define HitPairLISTLENGTH 16 typedef enum HitListOutputFormat { HitListOutputFormatPseudoBlast = 34, HitListOutputFormatXML, HitListOutputFormatTab, HitListAlnCumlative, HitListOutputFormatUnknown } HitListOutputFormat; %} struct HitAln int raw_score double bit_score double evalue AlnBlock * alb struct HitPair Sequence * query Sequence * target int raw_score double bit_score double evalue HitAln ** aln !list boolean target_reversed !def="FALSE" struct HitList HitPair ** pair !list CompMat * mat boolean (*write_btc_func)(AlnBlock *,Sequence *,Sequence *,btCanvas * btc) !func char * stat_attrib struct HitListOutputImpl HitListOutputFormat type !def="HitListOutputFormatPseudoBlast" %{ #include "hitlist.h" %func Sorts by score %% void sort_HitList_by_score(HitList * hl) { sort_HitList(hl,compare_HitPair_score); } %func internal function to sort by score %% int compare_HitPair_score(HitPair * one,HitPair * two) { return two->raw_score - one->raw_score; } %func Applies statistics across a hitlist %% void apply_SearchStat_to_HitList(HitList * hspm,SearchStatInterface * ssi,int database_size) { int i; int j; hspm->stat_attrib = stringalloc((*ssi->attribution)(ssi->data)); for(i=0;ilen;i++) { hspm->pair[i]->bit_score = (*ssi->calc_bits)(ssi->data,hspm->pair[i]->query->len,hspm->pair[i]->target->len,hspm->pair[i]->raw_score); hspm->pair[i]->evalue = (*ssi->calc_evalue)(ssi->data,hspm->pair[i]->query,hspm->pair[i]->target,hspm->pair[i]->raw_score,database_size); for(j=0;jpair[i]->len;j++ ) { hspm->pair[i]->aln[j]->bit_score = (*ssi->calc_bits)(ssi->data,hspm->pair[i]->query->len,hspm->pair[i]->target->len,hspm->pair[i]->aln[j]->raw_score); hspm->pair[i]->aln[j]->evalue = (*ssi->calc_evalue)(ssi->data,hspm->pair[i]->query,hspm->pair[i]->target,hspm->pair[i]->aln[j]->raw_score,database_size); } } } %func Converts a LinearHSPmanager into a HitList %% HitList * HitList_from_LinearHSPmanager(LinearHSPmanager * lm) { HitList * out; HitPair * pair; int i; out = HitList_alloc_std(); if( lm->mat != NULL ) out->mat = hard_link_CompMat(lm->mat); for(i=0;ilen;i++) { pair = HitPair_from_HSPset(lm->set[i],lm->mat); add_HitList(out,pair); } return out; } %func Builds a Hitpair from an HSP, not doing alignment %% HitPair * HitPair_from_HSPset(HSPset * set,CompMat * mat) { HitPair * out; HitAln * aln; int i; out = HitPair_alloc_std(); out->query = hard_link_Sequence(set->hsp[0]->query); out->target = hard_link_Sequence(set->hsp[0]->target); out->raw_score = 0.0; for(i=0;ilen;i++) { aln = HitAln_alloc(); aln->raw_score = set->hsp[i]->score; aln->bit_score = aln->raw_score/2.0; aln->alb = ungapped_AlnBlock_from_HSP(set->hsp[i],out->query,out->target,mat); add_HitPair(out,aln); out->raw_score += set->hsp[i]->score; } return out; } %func Builds an expanded AlnBlock with one AlnColumn per residue for an ungapped HSP %% AlnBlock * ungapped_AlnBlock_from_HSP(HSP * hsp,Sequence * q,Sequence * t,CompMat * mat) { AlnBlock * alb; AlnColumn * alc; AlnColumn * prev = NULL; int i; alb = AlnBlock_alloc_len(2); add_AlnBlock(alb,AlnSequence_alloc()); add_AlnBlock(alb,AlnSequence_alloc()); for(i=0;ilength && hsp->query_start+i < q->len && hsp->target_start+i < t->len;i++) { alc = new_pairwise_AlnColumn(); alc->alu[0]->start = hsp->query_start+i-1; alc->alu[0]->end = hsp->query_start+i; alc->alu[0]->text_label = "SEQUENCE"; alc->alu[1]->start = hsp->target_start+i-1; alc->alu[1]->end = hsp->target_start+i; alc->alu[1]->text_label = "SEQUENCE"; if( mat != NULL ) { alc->alu[0]->score[0] = alc->alu[1]->score[0] = mat->comp[toupper(q->seq[hsp->query_start+i])-'A'][toupper(t->seq[hsp->target_start+i])-'A']; } if( prev == NULL ) { alb->start = alc; prev = alc; } else { prev->next = alc; prev = alc; } } return alb; } %func Builds a new HitListOutputFormat from commandline %% HitListOutputImpl * new_HitListOutputImpl_from_argv(int * argc,char ** argv) { HitListOutputImpl * out; char * temp; out = HitListOutputImpl_alloc(); if( strip_out_boolean_argument(argc,argv,"hithelp") == TRUE ) { fprintf(stdout,"Hitlist help\npseudoblast gives a format similar to BLAST output\nTab gives a tab delimited format one line foreach ungapped block with columns\n \n"); fprintf(stdout,"aln gives cumlative score align label dumping, good for debugging\n"); exit(0); } if( (temp = strip_out_assigned_argument(argc,argv,"hitoutput")) != NULL ) { if( strcmp(temp,"pseudoblast") == 0 ) { out->type = HitListOutputFormatPseudoBlast; } if( strcmp(temp,"xml") == 0 ) { out->type = HitListOutputFormatXML; } if( strcmp(temp,"aln") == 0 ) { out->type = HitListAlnCumlative; } if( strcmp(temp,"tab") == 0 ) { out->type = HitListOutputFormatTab; } } return out; } %func Shows help for HitList output %% void show_help_HitListOutputImpl(FILE * ofp) { fprintf(ofp,"Hit list output options\n"); fprintf(ofp," -hitoutput [pseudoblast/xml/tab] pseudoblast by default\n"); fprintf(ofp," -hithelp more detailed help on hitlist formats\n"); } %func Shows a hitlist wrt to output impl %% void show_HitList_HitListOutputImpl(HitListOutputImpl * hloi,HitList * hl,FILE * ofp) { switch(hloi->type) { case HitListOutputFormatPseudoBlast : write_pseudoblast_HitList(hl,ofp); break; case HitListOutputFormatXML : write_XML_HitList(hl,ofp); break; case HitListOutputFormatTab : write_tab_HitList(hl,ofp); break; case HitListAlnCumlative : write_alb_HitList(hl,ofp); break; default : error("No valid HitListOutputFormat!"); } } %func Writes Alb output %% void write_alb_HitList(HitList * hl,FILE * ofp) { int i,j; for(i=0;ilen;i++) { fprintf(stdout,"%s %s\n",hl->pair[i]->query->name,hl->pair[i]->target->name); for(j=0;jpair[i]->len;j++) { fprintf(ofp,"Alignment %d\n",j); if( hl->pair[i]->aln[j]->alb != NULL ) mapped_ascii_AlnBlock(hl->pair[i]->aln[j]->alb,Score2Bits,1,ofp); } } } %func Writes XML output %% void write_XML_HitList(HitList * hl,FILE * ofp) { int i,j; btCanvas * btc; fprintf(ofp,"\n"); fprintf(ofp,"\n"); fprintf(ofp,"\n"); for(i=0;ilen;i++) { fprintf(ofp," \n"); fprintf(ofp," %d\n",i); fprintf(ofp," \n"); fprintf(ofp," %s\n",hl->pair[i]->target->name); if( hl->pair[i]->target->desc != NULL ) { fprintf(ofp," %s\n",hl->pair[i]->target->desc); } fprintf(ofp," %s\n",hl->pair[i]->target->seq); fprintf(ofp," \n"); fprintf(ofp," \n"); fprintf(ofp," %d\n",hl->pair[i]->raw_score); fprintf(ofp," %.2f\n",hl->pair[i]->bit_score); fprintf(ofp," %g\n",hl->pair[i]->evalue); fprintf(ofp," \n"); for(j=0;jpair[i]->len;j++) { auto HitAln * haln = hl->pair[i]->aln[j]; fprintf(ofp," \n"); fprintf(ofp," \n"); fprintf(ofp," %d\n",haln->raw_score); fprintf(ofp," %.2f\n",haln->bit_score); fprintf(ofp," %g\n",haln->evalue); fprintf(ofp," \n"); fprintf(ofp," \n"); btc = new_Ascii_btCanvas(stdout,20,50,7,3); write_pretty_str_blast_align_btc(hl->pair[i]->aln[j]->alb,"Query:",hl->pair[i]->query->seq,"Sbjct:",hl->pair[i]->target->seq,btc); free_btCanvas(btc); fprintf(ofp,"\n"); fprintf(ofp," \n"); fprintf(ofp," \n"); } fprintf(ofp,"\n"); } fprintf(ofp,"\n"); } %func Writes tab delimited tab like output %% void write_tab_HitList(HitList * hl,FILE * ofp) { int i; int j; AlnColumn * alc; int qstart; int qend = 0; int tstart; int tend = 0; int strand; int tempt; for(i=0;ilen;i++) { for(j=0;jpair[i]->len;j++) { for(alc = hl->pair[i]->aln[j]->alb->start;alc != NULL && strcmp(alc->alu[1]->text_label,"END") != 0 ;) { /* start of a block - remember start coordinates */ qstart = alc->alu[0]->start+1+1; tstart = alc->alu[1]->start+1+1; /* progress any number of cases where the progression is the same */ for(;alc != NULL;alc = alc->next ) { if( (alc->alu[0]->end - alc->alu[0]->start) != (alc->alu[1]->end - alc->alu[1]->start) ) { break; } /* otherwise set end points */ qend = alc->alu[0]->end+1; tend = alc->alu[1]->end+1; } if( hl->pair[i]->target_reversed == 1 ) { strand = -1; tempt = tstart; tstart = hl->pair[i]->target->len - tend+1; tend = hl->pair[i]->target->len - tempt+1; } else { strand = 1; } /* end of a block. Print line */ fprintf(ofp,"%.2f\t%s\t%d\t%d\t%d\t%d\t%s\t%d\t%d\t%d\t%d\tgroup_%d_%d\n",hl->pair[i]->bit_score,hl->pair[i]->query->name,qstart,qend,1,hl->pair[i]->query->len,hl->pair[i]->target->name,tstart,tend,strand,hl->pair[i]->target->len,i,j); /* find start of next block */ for(;alc != NULL && strcmp(alc->alu[1]->text_label,"END") != 0;alc = alc->next ) { if( alc->alu[0]->end - alc->alu[0]->start == alc->alu[1]->end - alc->alu[1]->start ) { break; } } /* top loop will break at alc == NULL */ } } } } %func Writes pseudoblast output %% void write_pseudoblast_HitList(HitList * hl,FILE * ofp) { int i,j; btCanvas * btc; char buffer[MAXLINE]; fprintf(ofp,"BLASTP 2.1.2\n"); fprintf(ofp,"\n\nReference: Wise2 Package, Ewan Birney\n"); fprintf(ofp,"BLAST like format to play well with existing parsers. Other options are available\nSee help on the program that generated this for other options\n"); if( hl->stat_attrib != NULL ) { fprintf(ofp," Statistics from : %s\n",hl->stat_attrib); } fprintf(ofp,"\n\n"); fprintf(ofp,"Query= Not specified\n"); fprintf(ofp,"\n\nSearch.................................done\n\n"); fprintf(ofp," Score E\n"); fprintf(ofp,"Sequences producing significant alignments: (bits) Value\n"); for(i=0;ilen;i++) { if( hl->pair[i]->target->desc != NULL ) { strcpy(buffer,hl->pair[i]->target->desc); } else { strcpy(buffer," "); } buffer[50] = '\0'; fprintf(ofp,"%15s %50s %-.2f %.2g\n",hl->pair[i]->target->name,buffer,hl->pair[i]->bit_score,hl->pair[i]->evalue); } fprintf(ofp,"\n"); for(i=0;ilen;i++) { fprintf(ofp,">%s %s\n Length = %d Reversed %d\n\n",hl->pair[i]->target->name,(hl->pair[i]->target->desc != NULL ? hl->pair[i]->target->desc : " "),hl->pair[i]->target->len,hl->pair[i]->target_reversed); for(j=0;jpair[i]->len;j++) { fprintf(ofp," Score = %.1f bits (%d), Expect = %g\n", hl->pair[i]->aln[j]->bit_score,hl->pair[i]->aln[j]->raw_score,hl->pair[i]->aln[j]->evalue); fprintf(ofp,"\n"); btc = new_Ascii_btCanvas(stdout,20,50,5,3); if( hl->write_btc_func == NULL ) { write_pretty_str_blast_align_btc(hl->pair[i]->aln[j]->alb,"Query:",hl->pair[i]->query->seq,"Sbjct:",hl->pair[i]->target->seq,btc); } else { (*hl->write_btc_func)(hl->pair[i]->aln[j]->alb,hl->pair[i]->query,hl->pair[i]->target,btc); } free_btCanvas(btc); fprintf(ofp,"\n"); } } } %func Chains up to char* level alignment writer %% boolean write_pretty_Seq_blast_align_btc(AlnBlock * alb,Sequence * one,Sequence * two,btCanvas * btc) { return write_pretty_str_blast_align_btc(alb,one->name,one->seq,two->name,two->seq,btc); } %func This function writes precisely what you expect for a a simple alignment. We can reuse this routine all over the place because we dont use any hard coded structure for the query or the target sequence letters. ... but crap type checking it has to be said! Also we use a generic btCanvas that could have any implementation underneath (eg, ASCII, postscript etc). %% boolean write_pretty_str_blast_align_btc(AlnBlock * alb,char * qname,char * query,char * tname,char * target,btCanvas * btc) { int finished = 0; AlnColumn * alc; AlnColumn * prev = NULL; AlnUnit * q; AlnUnit * t; char buffer[14]; btPasteArea * btp; for(alc=alb->start;alc != NULL && finished == 0;) { /** put names in **/ btp = get_reserved_left_btCanvas(btc); paste_string_btPasteArea(btp,0,0,qname,BC_RIGHT,0); paste_string_btPasteArea(btp,0,2,tname,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[0]->start+1+1); paste_string_btPasteArea(btp,12,0,buffer,BC_RIGHT,0); sprintf(buffer,"%d",alc->alu[1]->start+1+1); paste_string_btPasteArea(btp,12,2,buffer,BC_RIGHT,0); free_btPasteArea(btp); /** now loop over this block **/ for(;finished == 0 && alc != NULL && can_get_paste_area_btCanvas(btc,1) == TRUE;prev=alc,alc=alc->next) { q = alc->alu[0]; t = alc->alu[1]; /* * at the end, break */ if( strcmp(q->text_label,"END") == 0 ) { finished = 1; break; } /* * Get the paste area, length 1, depth will be 3 */ btp = get_paste_area_btCanvas(btc,1); /* * Write in the query sequence * */ if( strcmp(q->text_label,"SEQUENCE") == 0 || strstr(q->text_label,"BOUND") != NULL ) { paste_char_btPasteArea(btp,0,0,toupper((int)query[q->start+1]),0); } else if( strcmp(q->text_label,"UNMATCHED_SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,0,tolower((int)query[q->start+1]),0); } else { /** is insert- we could check **/ if( strcmp(q->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",q->text_label); paste_char_btPasteArea(btp,0,0,'?',0); } else { paste_char_btPasteArea(btp,0,0,'-',0); } } /* * Write in the target sequence * */ if( strcmp(t->text_label,"SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,2,toupper((int)target[t->start+1]),0); } else if( strcmp(t->text_label,"UNMATCHED_SEQUENCE") == 0 ) { paste_char_btPasteArea(btp,0,2,tolower((int)target[t->start+1]),0); } else { /** is insert- we could check **/ if( strcmp(t->text_label,"INSERT") != 0 ) { warn("Got an uninterpretable label, %s",t->text_label); paste_char_btPasteArea(btp,0,2,'?',0); } else { paste_char_btPasteArea(btp,0,2,'-',0); } } /* * Match line */ if( strcmp(q->text_label,"SEQUENCE") == 0 && strcmp(t->text_label,"SEQUENCE") == 0 ) { if( q->score[0] > 0 ) { if( query[q->start+1] == target[t->start+1] ) { paste_char_btPasteArea(btp,0,1,target[t->start+1],0); } else { paste_char_btPasteArea(btp,0,1,'+',0); } } } else paste_char_btPasteArea(btp,0,1,' ',0); free_btPasteArea(btp); } /* end of for this block */ if( prev != NULL ) { btp = get_reserved_right_btCanvas(btc); sprintf(buffer,"%d",prev->alu[0]->end+1); paste_string_btPasteArea(btp,0,0,buffer,BC_RIGHT,0); sprintf(buffer,"%d",prev->alu[1]->end+1); paste_string_btPasteArea(btp,0,2,buffer,BC_RIGHT,0); free_btPasteArea(btp); } advance_line_btCanvas(btc); if( alc->next != NULL && strcmp(alc->next->alu[1]->text_label,"END") == 0 ) { break; } } /* end of for the alignment */ return TRUE; /* we never returned false. Ooops! */ } wise-2.4.1/src/dynlibsrc/complexevalset.c0000644000175000001440000003346410670453712020047 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "complexevalset.h" /* Function: evaluate_ComplexSequence_Genomic(gen,cses,score_for_repeat,score_for_cds_in_repeat) * * Descrip: makes a new ComplexSequence from a Genomic * sequence, using the repeat information to * structure the positives and negatives. * * * Arg: gen [UNKN ] Undocumented argument [Genomic *] * Arg: cses [UNKN ] Undocumented argument [ComplexSequenceEvalSet *] * Arg: score_for_repeat [UNKN ] Undocumented argument [int] * Arg: score_for_cds_in_repeat [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ # line 55 "complexevalset.dy" ComplexSequence * evaluate_ComplexSequence_Genomic(Genomic * gen,ComplexSequenceEvalSet * cses,int score_for_repeat,int score_for_cds_in_repeat) { int i,j; ComplexSequence * out; if( cses == NULL || cses->type != SEQUENCE_GENOMIC ) { warn("ComplexSequenceEvalSet is not valid for genomic!"); return NULL; } assert(gen); assert(gen->baseseq); assert(gen->baseseq->seq); out = new_ComplexSequence(gen->baseseq,cses); if( out == NULL ) { return NULL; } for(i=0;ilen;i++) { for(j=gen->repeat[i]->start;jrepeat[i]->end;j++) { if( j >= gen->baseseq->len ) { warn("Overran sequence - j position %d, sequence length %d on repeat %d",j,gen->baseseq->len,i); break; } CSEQ_GENOMIC_REPEAT(out,j) = score_for_repeat; CSEQ_GENOMIC_CDSPOT(out,j) = score_for_cds_in_repeat; } } /* for(i=0;ibaseseq->len;i++) fprintf(stderr,"At position %6d %d\n",CSEQ_GENOMIC_CDSPOT(out,j)); */ return out; } /* Function: default_genomic_ComplexSequenceEvalSet(void) * * Descrip: Makes a reasonably sensible genomic sequence * eval set. Has base and codon numbers (what * every good genomic sequence should do) and then * /stupid_5SS and /stupid_3SS. Finally the repeat/EST * regions modelled with the /flat_zero * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ # line 104 "complexevalset.dy" ComplexSequenceEvalSet * default_genomic_ComplexSequenceEvalSet(void) { ComplexSequenceEvalSet * out; out = ComplexSequenceEvalSet_alloc_len(11); add_ComplexSequenceEvalSet(out,base_number_ComplexSequenceEval()); add_ComplexSequenceEvalSet(out,codon_number_ComplexSequenceEval()); add_ComplexSequenceEvalSet(out,stupid_5SS()); add_ComplexSequenceEvalSet(out,stupid_3SS()); add_ComplexSequenceEvalSet(out,flat_zero()); add_ComplexSequenceEvalSet(out,flat_zero()); out->type = SEQUENCE_GENOMIC; prepare_ComplexSequenceEvalSet(out); return out; } /* Function: flat_negi(void) * * Descrip: Makes a ComplexSequenceEval that puts NEGI everywhere * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ # line 129 "complexevalset.dy" ComplexSequenceEval * flat_negi(void) { ComplexSequenceEval * out; out= ComplexSequenceEval_alloc(); out->left_window = 0; out->right_window = 0; out->outside_score = NEGI; out->eval_func = flat_negi_eval; return out; } /* Function: flat_negi_eval(type,*data,seq) * * Descrip: used by flat negi * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: *data [UNKN ] Undocumented argument [void] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 146 "complexevalset.dy" int flat_negi_eval(int type,void *data,char * seq) { return NEGI; } /* Function: flat_zero(void) * * Descrip: Makes a ComplexSequenceEval that puts 0 everywhere * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ # line 156 "complexevalset.dy" ComplexSequenceEval * flat_zero(void) { ComplexSequenceEval * out; out= ComplexSequenceEval_alloc(); out->left_window = 0; out->right_window = 0; out->outside_score = NEGI; out->eval_func = flat_zero_eval; return out; } /* Function: flat_zero_eval(type,*data,seq) * * Descrip: Used by /flat_zero as function actually called * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: *data [UNKN ] Undocumented argument [void] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 175 "complexevalset.dy" int flat_zero_eval(int type,void *data,char * seq) { return 0; } /* Function: stupid_5SS(void) * * Descrip: Reasonably stupid 5'SS, of 0 at GT's * and NEGI elsewhere. Pretends to have a longer * footprint than it needs to satisify the lookbacks * of more proper genomic models * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ # line 188 "complexevalset.dy" ComplexSequenceEval * stupid_5SS(void) { ComplexSequenceEval * out; out= ComplexSequenceEval_alloc(); out->left_window = 3; out->right_window = 7; out->left_lookback = 8; out->outside_score = NEGI; out->eval_func = stupid_5SS_eval; return out; } /* Function: stupid_5SS_eval(type,*data,seq) * * Descrip: Function which actually does the evaluation for * 5'SS * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: *data [UNKN ] Undocumented argument [void] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 209 "complexevalset.dy" int stupid_5SS_eval(int type,void *data,char * seq) { if( *(seq) == 'G' && *(seq+1) == 'T' ) return 0; else return NEGI; } /* Function: stupid_3SS(void) * * Descrip: Reasonably stupid 3'SS, of 0 at AG's * and NEGI elsewhere. Pretends to have a longer * footprint than it needs to satisify the lookbacks * of more proper genomic models * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ # line 224 "complexevalset.dy" ComplexSequenceEval * stupid_3SS(void) { ComplexSequenceEval * out; out= ComplexSequenceEval_alloc(); out->left_window = 3; out->right_window = 3; out->left_lookback = 5; out->outside_score = NEGI; out->eval_func = stupid_3SS_eval; return out; } /* Function: stupid_3SS_eval(type,*data,seq) * * Descrip: Function which actually does the evaluation for * 3'SS * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: *data [UNKN ] Undocumented argument [void] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 246 "complexevalset.dy" int stupid_3SS_eval(int type,void *data,char * seq) { if( *(seq-1) == 'A' && *(seq) == 'G' ) return 0; else return NEGI; } /********************************/ /* cDNA and base stuff */ /********************************/ /* Function: default_DNA_ComplexSequenceEvalSet(void) * * Descrip: Makes a very sensible DNA sequence * eval set. You shouldn't need your own * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ # line 264 "complexevalset.dy" ComplexSequenceEvalSet * default_DNA_ComplexSequenceEvalSet(void) { ComplexSequenceEvalSet * out; out = ComplexSequenceEvalSet_alloc_len(1); add_ComplexSequenceEvalSet(out,base_number_ComplexSequenceEval()); out->type = SEQUENCE_DNA; prepare_ComplexSequenceEvalSet(out); return out; } /* Function: default_cDNA_ComplexSequenceEvalSet(void) * * Descrip: Makes a very sensible cDNA sequence * eval set. You shouldn't need your own * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ # line 285 "complexevalset.dy" ComplexSequenceEvalSet * default_cDNA_ComplexSequenceEvalSet(void) { ComplexSequenceEvalSet * out; out = ComplexSequenceEvalSet_alloc_len(2); add_ComplexSequenceEvalSet(out,base_number_ComplexSequenceEval()); add_ComplexSequenceEvalSet(out,codon_number_ComplexSequenceEval()); out->type = SEQUENCE_CDNA; prepare_ComplexSequenceEvalSet(out); return out; } /* Function: codon_number_ComplexSequenceEval(void) * * Descrip: ComplexSequenceEval that puts a codon * number in there (0-125 inc, 125 = impossible codon). * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ # line 309 "complexevalset.dy" ComplexSequenceEval * codon_number_ComplexSequenceEval(void) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); if (out == NULL ) { return NULL; } out->left_window = 2; out->right_window = 0; out->outside_score = 125; out->eval_func = codon_number_func; return out; } /* Function: codon_number_func(type,data,seq) * * Descrip: Function which actually does the codon evaluation * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 334 "complexevalset.dy" int codon_number_func(int type,void * data,char * seq) { return codon_from_seq(seq-2); } /* Function: codon64_number_ComplexSequenceEval(void) * * Descrip: Function which puts a 64 base codon... * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ # line 343 "complexevalset.dy" ComplexSequenceEval * codon64_number_ComplexSequenceEval(void) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); if (out == NULL ) { return NULL; } out->left_window = 2; out->right_window = 0; out->outside_score = 65; out->eval_func = codon64_number_func; return out; } /* Function: codon64_number_func(type,data,seq) * * Descrip: Function which actually does the codon64 evaluation * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 368 "complexevalset.dy" int codon64_number_func(int type,void * data,char * seq) { int codon; if( !is_non_ambiguous_codon_seq(seq-2) ) { return 64; } codon = codon_from_seq(seq-2); return base4_codon_from_codon(codon); } /* Function: base_number_ComplexSequenceEval(void) * * Descrip: ComplexSequenceEval that puts a base * number (0-5 inc) * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ # line 387 "complexevalset.dy" ComplexSequenceEval * base_number_ComplexSequenceEval(void) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); if (out == NULL ) { return NULL; } out->left_window = out->right_window = 0; out->eval_func = base_number_func; return out; } /* Function: base_number_func(type,data,seq) * * Descrip: Function which actually does the evaluation bases * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 410 "complexevalset.dy" int base_number_func(int type,void * data,char * seq) { return base_from_char(*seq); } /***************************/ /* amino acid stuff */ /***************************/ /* Function: default_aminoacid_ComplexSequenceEvalSet(void) * * Descrip: Makes a very sensible protein sequence * eval set. You shouldn't need your own * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ # line 427 "complexevalset.dy" ComplexSequenceEvalSet * default_aminoacid_ComplexSequenceEvalSet(void) { ComplexSequenceEvalSet * out; out = ComplexSequenceEvalSet_alloc_len(1); add_ComplexSequenceEvalSet(out,aminoacid_number_ComplexSequenceEval()); out->type = SEQUENCE_PROTEIN; prepare_ComplexSequenceEvalSet(out); return out; } /* Function: aminoacid_number_ComplexSequenceEval(void) * * Descrip: ComplexSequenceEval that puts a amino acid * number in there (0-26) * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ # line 450 "complexevalset.dy" ComplexSequenceEval * aminoacid_number_ComplexSequenceEval(void) { ComplexSequenceEval * out; out = ComplexSequenceEval_alloc(); if (out == NULL ) { return NULL; } out->left_window = out->right_window = 0; out->eval_func = aminoacid_number_func; return out; } /* Function: aminoacid_number_func(type,data,seq) * * Descrip: Function which actually does the evaluation for aminoacids * * * Arg: type [UNKN ] Undocumented argument [int] * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [int] * */ # line 473 "complexevalset.dy" int aminoacid_number_func(int type,void * data,char * seq) { return (int)(toupper((int)*seq)-'A'); } /***************************/ /* dna stuff */ /***************************/ /* Function: default_dna_ComplexSequenceEvalSet(void) * * Descrip: Makes a very sensible dna sequence * eval set. You shouldn't need your own * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ # line 489 "complexevalset.dy" ComplexSequenceEvalSet * default_dna_ComplexSequenceEvalSet(void) { ComplexSequenceEvalSet * out; out = ComplexSequenceEvalSet_alloc_len(1); add_ComplexSequenceEvalSet(out,base_number_ComplexSequenceEval()); out->type = SEQUENCE_DNA; prepare_ComplexSequenceEvalSet(out); return out; } # line 572 "complexevalset.c" #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/complexevalset.h0000644000175000001440000002076610670453712020055 0ustar philippusers#ifndef DYNAMITEcomplexevalsetHEADERFILE #define DYNAMITEcomplexevalsetHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "complexsequence.h" #include "genomic.h" /*** ok, some types to works with ***/ #define AMINOACID CSEQ_PROTEIN_AMINOACID #define CSEQ_PROTEIN_AMINOACID(cseq,index) (cseq->data[index]) /*** for genomic ***/ #define CSEQ_G_LEN 6 #define CSEQ_GENOMIC_BASE(cseq,index) (cseq->data[(index)*CSEQ_G_LEN]) #define CSEQ_GENOMIC_CODON(cseq,index) (cseq->data[(index)*CSEQ_G_LEN +1]) #define CSEQ_GENOMIC_5SS(cseq,index) (cseq->data[(index)*CSEQ_G_LEN +2]) #define CSEQ_GENOMIC_3SS(cseq,index) (cseq->data[(index)*CSEQ_G_LEN +3]) #define CSEQ_GENOMIC_REPEAT(cseq,index) (cseq->data[(index)*CSEQ_G_LEN +4]) #define CSEQ_GENOMIC_CDSPOT(cseq,index) (cseq->data[(index)*CSEQ_G_LEN +5]) /*** for cDNA ***/ #define CSEQ_C_LEN 2 #define CSEQ_CDNA_BASE(cseq,index) (cseq->data[index*CSEQ_C_LEN]) #define CSEQ_CDNA_CODON(cseq,index) (cseq->data[index*CSEQ_C_LEN +1]) #define CSEQ_D_LEN 1 #define CSEQ_DNA_BASE(cseq,index) (cseq->data[index]) /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: evaluate_ComplexSequence_Genomic(gen,cses,score_for_repeat,score_for_cds_in_repeat) * * Descrip: makes a new ComplexSequence from a Genomic * sequence, using the repeat information to * structure the positives and negatives. * * * Arg: gen [UNKN ] Undocumented argument [Genomic *] * Arg: cses [UNKN ] Undocumented argument [ComplexSequenceEvalSet *] * Arg: score_for_repeat [UNKN ] Undocumented argument [int] * Arg: score_for_cds_in_repeat [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * Wise2_evaluate_ComplexSequence_Genomic(Genomic * gen,ComplexSequenceEvalSet * cses,int score_for_repeat,int score_for_cds_in_repeat); #define evaluate_ComplexSequence_Genomic Wise2_evaluate_ComplexSequence_Genomic /* Function: default_genomic_ComplexSequenceEvalSet(void) * * Descrip: Makes a reasonably sensible genomic sequence * eval set. Has base and codon numbers (what * every good genomic sequence should do) and then * /stupid_5SS and /stupid_3SS. Finally the repeat/EST * regions modelled with the /flat_zero * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * Wise2_default_genomic_ComplexSequenceEvalSet(void); #define default_genomic_ComplexSequenceEvalSet Wise2_default_genomic_ComplexSequenceEvalSet /* Function: flat_negi(void) * * Descrip: Makes a ComplexSequenceEval that puts NEGI everywhere * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * Wise2_flat_negi(void); #define flat_negi Wise2_flat_negi /* Function: flat_zero(void) * * Descrip: Makes a ComplexSequenceEval that puts 0 everywhere * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * Wise2_flat_zero(void); #define flat_zero Wise2_flat_zero /* Function: stupid_5SS(void) * * Descrip: Reasonably stupid 5'SS, of 0 at GT's * and NEGI elsewhere. Pretends to have a longer * footprint than it needs to satisify the lookbacks * of more proper genomic models * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * Wise2_stupid_5SS(void); #define stupid_5SS Wise2_stupid_5SS /* Function: stupid_3SS(void) * * Descrip: Reasonably stupid 3'SS, of 0 at AG's * and NEGI elsewhere. Pretends to have a longer * footprint than it needs to satisify the lookbacks * of more proper genomic models * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * Wise2_stupid_3SS(void); #define stupid_3SS Wise2_stupid_3SS /* Function: default_DNA_ComplexSequenceEvalSet(void) * * Descrip: Makes a very sensible DNA sequence * eval set. You shouldn't need your own * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * Wise2_default_DNA_ComplexSequenceEvalSet(void); #define default_DNA_ComplexSequenceEvalSet Wise2_default_DNA_ComplexSequenceEvalSet /* Function: default_cDNA_ComplexSequenceEvalSet(void) * * Descrip: Makes a very sensible cDNA sequence * eval set. You shouldn't need your own * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * Wise2_default_cDNA_ComplexSequenceEvalSet(void); #define default_cDNA_ComplexSequenceEvalSet Wise2_default_cDNA_ComplexSequenceEvalSet /* Function: codon_number_ComplexSequenceEval(void) * * Descrip: ComplexSequenceEval that puts a codon * number in there (0-125 inc, 125 = impossible codon). * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * Wise2_codon_number_ComplexSequenceEval(void); #define codon_number_ComplexSequenceEval Wise2_codon_number_ComplexSequenceEval /* Function: codon64_number_ComplexSequenceEval(void) * * Descrip: Function which puts a 64 base codon... * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * Wise2_codon64_number_ComplexSequenceEval(void); #define codon64_number_ComplexSequenceEval Wise2_codon64_number_ComplexSequenceEval /* Function: base_number_ComplexSequenceEval(void) * * Descrip: ComplexSequenceEval that puts a base * number (0-5 inc) * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * Wise2_base_number_ComplexSequenceEval(void); #define base_number_ComplexSequenceEval Wise2_base_number_ComplexSequenceEval /* Function: default_aminoacid_ComplexSequenceEvalSet(void) * * Descrip: Makes a very sensible protein sequence * eval set. You shouldn't need your own * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * Wise2_default_aminoacid_ComplexSequenceEvalSet(void); #define default_aminoacid_ComplexSequenceEvalSet Wise2_default_aminoacid_ComplexSequenceEvalSet /* Function: aminoacid_number_ComplexSequenceEval(void) * * Descrip: ComplexSequenceEval that puts a amino acid * number in there (0-26) * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEval *] * */ ComplexSequenceEval * Wise2_aminoacid_number_ComplexSequenceEval(void); #define aminoacid_number_ComplexSequenceEval Wise2_aminoacid_number_ComplexSequenceEval /* Function: default_dna_ComplexSequenceEvalSet(void) * * Descrip: Makes a very sensible dna sequence * eval set. You shouldn't need your own * * * * Return [UNKN ] Undocumented return value [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * Wise2_default_dna_ComplexSequenceEvalSet(void); #define default_dna_ComplexSequenceEvalSet Wise2_default_dna_ComplexSequenceEvalSet /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ int Wise2_flat_negi_eval(int type,void *data,char * seq); #define flat_negi_eval Wise2_flat_negi_eval int Wise2_flat_zero_eval(int type,void *data,char * seq); #define flat_zero_eval Wise2_flat_zero_eval int Wise2_stupid_5SS_eval(int type,void *data,char * seq); #define stupid_5SS_eval Wise2_stupid_5SS_eval int Wise2_stupid_3SS_eval(int type,void *data,char * seq); #define stupid_3SS_eval Wise2_stupid_3SS_eval int Wise2_codon_number_func(int type,void * data,char * seq); #define codon_number_func Wise2_codon_number_func int Wise2_codon64_number_func(int type,void * data,char * seq); #define codon64_number_func Wise2_codon64_number_func int Wise2_base_number_func(int type,void * data,char * seq); #define base_number_func Wise2_base_number_func int Wise2_aminoacid_number_func(int type,void * data,char * seq); #define aminoacid_number_func Wise2_aminoacid_number_func #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/sequence.c0000644000175000001440000015251010670453713016617 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "sequence.h" /* Function: new_Sequence_from_strings(name,seq) * * Descrip: Makes a new sequence from strings given. * Separate memory will be allocated for them * and them copied into it. * * They can be NULL, in which case * o a dummy name SequenceName will be assigned * o No sequence placed and length of zero. * * Though this is dangerous later on. * * The sequence type is calculated automatically using * /best_guess_type. If you want a DNA sequence but are * unsure of the content of, for example, IUPAC codes, * please use /force_to_dna_Sequence before using the * sequence. Most of the rest of dynamite relies on a * five letter A,T,G,C,N alphabet, but this function * will allow any sequence type to be stored, so please * check if you want to save yourself alot of grief. * * In perl and other interfaces, this is a much safer * constructor than the raw "new" type * * * Arg: name [READ ] name of sequence, memory is allocated for it. [char *] * Arg: seq [READ ] char * of sequence, memory is allocated for it. [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 124 "sequence.dy" Sequence * new_Sequence_from_strings(char * name,char * seq) { Sequence * out; out = Sequence_alloc(); if( name == NULL) name = "SequenceName"; out->name = stringalloc(name); if( seq == NULL ) { out->seq = NULL; out->len = 0; return out; } out->seq = stringalloc(seq); out->len = strlen(out->seq); out->offset = 1; out->end = out->len; out->type = best_guess_type(out); return out; } /* Function: looks_like_accession(name) * * Descrip: Returns true if name looks like [A-Za-z]+[0-9]+ * This should be an accession number * * * Arg: name [READ ] name to be tested [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 158 "sequence.dy" boolean looks_like_accession(char * name) { char * run; for(run=name;*run && isalpha((int)*run);run++) ; if( *run == '\0') return FALSE; for(;*run && isalnum((int)*run) && !isalpha((int)*run);run++) ; if( *run == '\0') return TRUE; return FALSE; } /* Function: make_len_type_Sequence(seq) * * Descrip: makes seq->len and seq->end match the seq->seq * length number. * * It also checks the type of the sequence with * /best_guess_type * * * Arg: seq [RW ] Sequence object [Sequence *] * */ # line 184 "sequence.dy" void make_len_type_Sequence(Sequence * seq) { seq->len = strlen(seq->seq); seq->end = seq->len + seq->offset -1; seq->type = best_guess_type(seq); } /* Function: best_guess_type(seq) * * Descrip: Guesses DNA or protein, by adding all * the A,T,G,C up and if len < 300 && > 95% or * len > 300 && > 75% then considers * it to be DNA. NB - Ns now counted. * * * Arg: seq [READ ] Sequence to be guessed [Sequence *] * * Return [OWNER] SEQUENCE_DNA or SEQUENCE_PROTEIN [int] * */ # line 202 "sequence.dy" int best_guess_type(Sequence * seq) { register int i; int ch[26]; int no; int unplaced = 0; int total; for(i=0;i<26;i++) ch[i] = 0; for(i=0;ilen;i++) { /*fprintf(stderr,"character is %c and total is %d\n",seq->seq[i],unplaced);*/ if( (no=(int)( toupper(seq->seq[i])-'A')) > 26 || no < 0 ) unplaced++; else ch[no]++; } total = (ch['A' - 'A']+ch['T' - 'A'] + ch['G' - 'A'] + ch['C' - 'A'] + ch['N' - 'A']); if( seq->len < 300 ) { if( (double)total/(double)seq->len > 0.95 ) return SEQUENCE_DNA; else return SEQUENCE_PROTEIN; } else { if( (double)total/(double)seq->len > 0.75 ) return SEQUENCE_DNA; else return SEQUENCE_PROTEIN; } } /* Function: Sequence_type_to_string(type) * * Descrip: Converts sequence type (SEQUENCE_*) to a string * * * Arg: type [UNKN ] type eg SEQUENCE_PROTEIN [int] * * Return [UNKN ] Undocumented return value [char *] * */ # line 239 "sequence.dy" char * Sequence_type_to_string(int type) { switch (type ) { case SEQUENCE_UNKNOWN : return "Unknown type"; case SEQUENCE_PROTEIN : return "Protein"; case SEQUENCE_DNA : return "Dna"; case SEQUENCE_CDNA : return "cDNA"; case SEQUENCE_GENOMIC : return "Genomic"; case SEQUENCE_EST : return "Est"; case SEQUENCE_RNA : return "RNA"; default : return "Undefined!"; } } /* Function: uppercase_Sequence(seq) * * Descrip: makes all the sequence uppercase * * * Arg: seq [RW ] Sequence to be uppercased [Sequence *] * */ # line 259 "sequence.dy" void uppercase_Sequence(Sequence * seq) { int i; for(i=0;ilen;i++) seq->seq[i] = toupper((int)seq->seq[i]); } /* Function: force_to_dna_Sequence(seq,fraction,number_of_conver) * * Descrip: This * a) sees how many non ATGCN characters there are in Seq * b) If the level is below fraction * a) flips non ATGC chars to N * b) writes number of conversions to number_of_conver * c) returns TRUE * c) else returns FALSE * * fraction of 0.0 means completely intolerant of errors * fraction of 1.0 means completely tolerant of errors * * * * Arg: seq [RW ] sequence object read and converted [Sequence *] * Arg: fraction [READ ] number 0..1 for tolerance of conversion [double] * Arg: number_of_conver [WRITE] number of conversions actually made [int *] * * Return [READ ] TRUE for conversion to DNA, FALSE if not [boolean] * */ # line 286 "sequence.dy" boolean force_to_dna_Sequence(Sequence * seq,double fraction,int * number_of_conver) { int count =0; int i; if( seq == NULL ) { warn("Attempting to force a sequence with no Sequence object!\n"); return FALSE; } if( seq->len <= 0 ) { warn("Trying to make a sequence with a length of %d. Bad news!",seq->len); return FALSE; } for(i=0;ilen;i++) { /* if it is lower case, uppercase it! */ seq->seq[i] = (char)toupper((int)seq->seq[i]); if( !is_valid_base_char(seq->seq[i]) ) { count++; } } if( ((double)count/(double)seq->len) < fraction ) { seq->type = SEQUENCE_DNA; if( count != 0 ) { for(i=0;ilen;i++) { if( !is_valid_base_char(seq->seq[i]) ) { seq->seq[i] = 'N'; } } } if( number_of_conver != NULL ) { *number_of_conver = count; } return TRUE; } else { if( number_of_conver != NULL ) { *number_of_conver = count; } return FALSE; } } /* Function: is_reversed_Sequence(seq) * * Descrip: Currently the sequence object stores * reversed sequences as start > end. * * This tests that and returns true if it is * * * Arg: seq [READ ] sequence to test [Sequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 342 "sequence.dy" boolean is_reversed_Sequence(Sequence * seq) { if( seq->offset > seq->end) return TRUE; return FALSE; } /* Function: translate_Sequence(dna,ct) * * Descrip: This translates a DNA sequence to a protein. * It assummes that it starts at first residue * (use trunc_Sequence to chop a sequence up). * * * Arg: dna [READ ] DNA sequence to be translated [Sequence *] * Arg: ct [READ ] Codon table to do codon->aa mapping [CodonTable *] * * Return [OWNER] new protein sequence [Sequence *] * */ # line 359 "sequence.dy" Sequence * translate_Sequence(Sequence * dna,CodonTable * ct) { Sequence * out; int i; int j; int len; char * seq; char * name; char buffer[512]; if( is_dna_Sequence(dna) == FALSE) { warn("Trying to make a translation from a non DNA sequence... type is [%s]",Sequence_type_to_string(dna->type)); return NULL; } len = dna->len/3 + 1; seq = ckcalloc(len,sizeof(char)); sprintf(buffer,"%s.tr",dna->name == NULL ? "NoNameDNASeq" : dna->name); name = stringalloc(buffer); out = Sequence_from_dynamic_memory(name,seq); for(i=0,j=0;ilen-3;i+=3,j++) { out->seq[j] = aminoacid_from_seq(ct,dna->seq+i); } out->seq[j] = '\0'; out->type = SEQUENCE_PROTEIN; out->len = strlen(out->seq); return out; } /* Function: reverse_complement_Sequence(seq) * * Descrip: This both complements and reverses a sequence, * - a common wish! * * The start/end are correct with respect to the start/end * of the sequence (ie start = end, end = start). * * * Arg: seq [READ ] Sequence to that is used to reverse (makes a new Sequence) [Sequence *] * * Return [OWNER] new Sequence which is reversed [Sequence *] * */ # line 406 "sequence.dy" Sequence * reverse_complement_Sequence(Sequence * seq) { Sequence * out; int i; int j; if( is_dna_Sequence(seq) != TRUE ) { warn("Cannot reverse complement non-DNA sequence... type is %s",Sequence_type_to_string(seq->type)); return NULL; } out = Sequence_from_static_memory(seq->name,seq->seq); for(j=0,i=seq->len-1;i >= 0;i--,j++) { if( seq->seq[i] == '.' || seq->seq[i] == '-' ) { out->seq[j] = seq->seq[i]; } else { out->seq[j] = char_complement_base(seq->seq[i]); } /*fprintf(stderr,"In position %d placed %c from %c\n",j,out->seq[j],seq->seq[i]);*/ } out->len = strlen(seq->seq); out->offset = seq->end; out->end = seq->offset; out->type = seq->type; return out; } /* Function: magic_trunc_Sequence(seq,start,end) * * Descrip: Clever function for dna sequences. * * When start < end, truncates normally * * when start > end, truncates end,start and then * reverse complements. * * ie. If you have a coordinate system where reverse * sequences are labelled in reverse start/end way, * then this routine produces the correct sequence. * * * Arg: seq [READ ] sequence that is the source to be truncated [Sequence *] * Arg: start [READ ] start point [int] * Arg: end [READ ] end point [int] * * Return [OWNER] new Sequence which is truncated/reversed [Sequence *] * */ # line 456 "sequence.dy" Sequence * magic_trunc_Sequence(Sequence * seq,int start,int end) { Sequence * temp; Sequence * out; if( is_dna_Sequence(seq) == FALSE) { warn("Cannot magic truncate on a non DNA sequence... type is %s",Sequence_type_to_string(seq->type)); return NULL; } if( start < 0 || end < 0 ) { warn("Attempting a magic truncation on indices which are less than zero [%d:%d]. Clearly impossible",start,end); return NULL; } if( start < end ) { return trunc_Sequence(seq,start,end); } else { temp = trunc_Sequence(seq,end,start); if( temp == NULL ) { warn("Unable to truncate sequence"); return NULL; } out = reverse_complement_Sequence(temp); free_Sequence(temp); return out; } } /* Function: trunc_Sequence(seq,start,end) * * Descrip: truncates a sequence. It produces a new memory structure * which is filled from sequence start to end. * * Please notice * * Truncation is in C coordinates. That is * the first residue is 0 and end is the number of the * residue after the cut-point. In otherwords to * 2 - 3 would be a single residue truncation. So - if * you want to work in more usual, 'inclusive' molecular * biology numbers, which start at 1, then you need to say * * trunc_Sequence(seq,start-1,end); * * (NB, should be (end - 1 + 1) = end for the last coordinate). * * Truncation occurs against the *absolute* coordinate * system of the Sequence, not the offset/end pair inside. * So, this is a very bad error * * ** wrong code, and also leaks memory ** * * tru = trunc_Sequence(trunc_Sequence(seq,50,80),55,75); * * This the most portable way of doing this * * temp = trunc_Sequence(seq,50,80); * * tru = trunc_Sequence(temp,55-temp->offset,75-temp->offset); * * free_Sequence(temp); * * * * Arg: seq [READ ] object holding the sequence to be truncated [Sequence *] * Arg: start [READ ] start point of truncation [int] * Arg: end [READ ] end point of truncation [int] * * Return [OWNER] newly allocated sequence structure [Sequence *] * */ # line 532 "sequence.dy" Sequence * trunc_Sequence(Sequence * seq,int start,int end) { char * name; char * seqb; Sequence * out; if( start < 0 || end < 0 ) { warn("Attempting a truncation on indices which are less than zero [%d:%d]. Clearly impossible",start,end); return NULL; } if( end <= start ) { warn("Trying to truncate Sequence from %d - %d",start,end); return NULL; } if( end > seq->len ) { warn("Trying to truncate Sequecne %s from %d - %d when length is %d", seq->name,start,end,seq->len); return NULL; } name = stringalloc(seq->name); seqb = (char *) ckcalloc(end-start+1,sizeof(char)); memcpy(seqb,seq->seq+start,(end-start)); seqb[end-start] = '\0'; out = Sequence_from_dynamic_memory(name,seqb); out->len = strlen(out->seq); out->type = seq->type; out->offset = seq->offset+start; out->end = seq->offset + end-1; return out; } /* Function: read_SRS_db_Sequence(datastring,srsstring) * * Descrip: A function for you to easily specify the sequence name * and the database separately. Just concatonates the two * strings with : betwqeen them. Therefore you should use * "swisprot-id" for example as your datastring. * * calls /read_SRS_Sequence * * * Arg: datastring [READ ] string representing the database (swissprot-id) [char *] * Arg: srsstring [READ ] string for the name (eg, ROA1_HUMAN) [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 582 "sequence.dy" Sequence * read_SRS_db_Sequence(char * datastring,char * srsstring) { char buffer[256]; sprintf(buffer,"%s:%s",datastring,srsstring); return read_SRS_Sequence(buffer); } /* Function: read_SRS_Sequence(srsstring) * * Descrip: reads SRS specified sequence. calls popoen * with getz -f using srs4 syntax. Will only read * the first sequence if there is more than one in the * SRS spec, and does not warn you about additional * sequences * * * Arg: srsstring [READ ] srs spec'd string swissprot-id:ROA1_HUMAN [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 600 "sequence.dy" Sequence * read_SRS_Sequence(char * srsstring) { FILE * pipe; char buffer[MAXLINE]; Sequence * out; sprintf(buffer,"getz -d '[%s]' ",srsstring); pipe = popen(buffer,"r"); if ( pipe == NULL ) { warn("Could not open %s as an SRS database string - probably no getz",srsstring); return NULL; } out = read_fasta_Sequence(pipe); pclose(pipe); return out; } /* Function: read_efetch_Sequence(efetchstring) * * Descrip: reads efetch specificed sequence. calls popen to * efetch. A hack around accession numbers so that if the * thing looks like WP:acc number, calls it with -a... * otherwise assummes you have both database and name in the * efetchstring * * * Arg: efetchstring [READ ] efetch valid string [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 632 "sequence.dy" Sequence * read_efetch_Sequence(char * efetchstring) { FILE * pf; Sequence * out; char buffer[MAXLINE]; if( strstartcmp(efetchstring,"WP:") != 0 && looks_like_accession(efetchstring+3) == TRUE) { sprintf(buffer,"efetch -f -a %s",efetchstring); } else { sprintf(buffer,"efetch -f %s",efetchstring); } pf = popen(buffer,"r"); if( pf == NULL ) { warn("Could not open efetch pipe with [%s]",efetchstring); return NULL; } out = read_fasta_Sequence(pf); pclose(pf); return out; } /* Function: read_fasta_file_Sequence(filename) * * Descrip: Just a call * a) open filename * b) read sequence with /read_fasta_Sequence * c) close file. * * * Arg: filename [READ ] filename to open [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 667 "sequence.dy" Sequence * read_fasta_file_Sequence(char * filename) { Sequence * out; FILE * ifp; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Cannot open %s for read_fasta_file",filename); return NULL; } out = read_fasta_Sequence(ifp); fclose(ifp); return out; } /* Function: read_Sequence_EMBL_seq(buffer,maxlen,ifp) * * Descrip: reads the sequence part of an EMBL file. * * This function can either take a file which * starts * * * * Arg: buffer [RW ] buffer containing the first line. [char *] * Arg: maxlen [READ ] length of buffer [int] * Arg: ifp [READ ] input file to read from [FILE *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 698 "sequence.dy" Sequence * read_Sequence_EMBL_seq(char * buffer,int maxlen,FILE * ifp) { Sequence * out; char seqbuffer[SEQUENCEBLOCK]; int i = 0; signed char c; if( !isalpha((int)*buffer) ) { warn("I don't like this - got a buffer of [%s] in reading an EMBL sequence section",buffer); } do { if( strstartcmp(buffer,"SQ") == 0 ) { break; } } while ( fgets(buffer,maxlen,ifp) != NULL); out = empty_Sequence_from_dynamic_memory(stringalloc("EMBLseq")); while( (c=fgetc(ifp)) != EOF ) { if( c == '/' && (c=fgetc(ifp)) == '/') break; /*** ugly perhaps. what about single / lines? ***/ if( isalpha(c) ) seqbuffer[i++] = c; if( i > SEQUENCEBLOCK-2) { seqbuffer[i] = '\0'; if( add_string_to_Sequence(out,seqbuffer) == FALSE ) { warn("Could not read full sequence of %s - returning\n",out->name); return out; } i = 0; } } /* ok have to now put away final buffer read! */ seqbuffer[i] = '\0'; add_string_to_Sequence(out,seqbuffer); /** add back > if need be **/ if( feof(ifp) || c != '/' ) { warn("In parsing an EMBL file got an poor ending of a sequence region"); } else { while( (c=fgetc(ifp)) != '\n' && c != EOF ) ; } make_len_type_Sequence(out); return out; } /* Function: read_fasta_Sequence(ifp) * * Descrip: reads a fasta file assumming pretty * standard sanity for the file layout * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 758 "sequence.dy" Sequence * read_fasta_Sequence(FILE * ifp) { char buffer[MAXLINE]; char c; /* we need to do a nasty fgetc/ungetc to detect whether we have ended */ char seqbuffer[SEQUENCEBLOCK]; int i = 0; int j; int tax_id = -1; double weight = 1.0; boolean seen_weight = 0; char * temp; char * desc; char * name; Sequence * out; /* first line is '>' */ if( fgets(buffer,MAXLINE,ifp) == NULL ) { return NULL; } if( buffer[strlen(buffer)-1] != '\n' ) { /* excessive description line */ while( (c=fgetc(ifp)) != '\n' && c != EOF ) { ; } if( c == EOF ) { warn("In sequence file, overead line into end of file. Exiting"); return NULL; } } if( (temp = strstr(buffer,"tax_id=")) != NULL ) { tax_id = atoi(temp+strlen("tax_id=")); } if( (temp = strstr(buffer,"weight=")) != NULL ) { weight = atof(temp+strlen("weight=")); } if( buffer[0] == '/' && buffer[1] == '/' ) { /* silent exit as if EOF */ return NULL; } if( buffer[0] != '>' ) { warn("First character read not >, assumming is not fasta"); return NULL; } /* some annoying formats have >\s+\S+ ... Grrrr! */ for(i=1,name=buffer+1;*name && isspace(*name);name++,i++) ; /* now delimit this point */ for(;!isspace(buffer[i]);i++) ; buffer[i] = '\0'; /* now find description line if here */ for(i++;isspace(buffer[i]) && buffer[i] != '\0';i++) { ; } if( buffer[i] != '\0' ) { desc = buffer+i; for(i++;buffer[i] != '\0' && buffer[i] != '\n';i++) { ; } buffer[i] = '\0'; } else { desc = NULL; } out = empty_Sequence_from_dynamic_memory(stringalloc(name)); if( desc != NULL ){ out->desc = stringalloc(desc); } out->tax_id = tax_id; out->weight = weight; i =0; while( 1 ) { i =0; /* get/ungetc to see if we should read this line */ c = fgetc(ifp); if( c == EOF || c == '>' || c == '/') { break; } seqbuffer[i++] = c; /* get the rest of the line */ if( fgets(buffer,MAXLINE,ifp) == NULL ) { warn("Strangely truncated line in fasta file"); break; } /*fprintf(stderr,"Getting into while loop.. with [%s]\n",buffer); */ for(j=0;buffer[j] != '\0';j++) { if( isalpha(buffer[j]) || buffer[j] == '-' || buffer[j] == '.' || buffer[j] == '~' ) seqbuffer[i++] = buffer[j]; } seqbuffer[i] = '\0'; if( add_string_to_Sequence(out,seqbuffer) == FALSE ) { warn("Could not read full sequence of %s - returning\n",out->name); return out; } } /* ok have to now put away final buffer read! */ seqbuffer[i] = '\0'; add_string_to_Sequence(out,seqbuffer); /* end of file or '>' or '/' */ if( c == '>' || c == '/' ) ungetc(c,ifp); make_len_type_Sequence(out); return out; } /* Function: read_old_fasta_Sequence(ifp) * * Descrip: reads the fasta file: format is * * >name * sequence * * allocates a structure and puts in the * sequence. Calls /make_len_type_Sequence to * check type and length. * * It leaves the '>' on the next fasta sequence * for multiple sequence reading * * * Arg: ifp [READ ] input file to read from [FILE *] * * Return [OWNER] new Sequence structure [Sequence *] * */ # line 911 "sequence.dy" Sequence * read_old_fasta_Sequence(FILE * ifp) { Sequence * out; char seqbuffer[SEQUENCEBLOCK]; int i = 0; signed char c = EOF; if( feof(ifp) ) { /* fail silently */ return NULL; } while( (c=fgetc(ifp)) != EOF && isspace(c)) ; if( feof(ifp) ) return NULL; if( c != '>' ) { warn("First letter read is not '>' - assumming it is not a fasta stream"); return NULL; } if( c == EOF || feof(ifp) ) return NULL; /*** ok = got to > ****/ /*** read in name ****/ while( !isspace(c=fgetc(ifp)) && c != EOF) seqbuffer[i++]=c; if( c == EOF) return NULL; seqbuffer[i]='\0'; /*** name now in sequence buffer - make sequence ***/ out = empty_Sequence_from_dynamic_memory(stringalloc(seqbuffer)); if( out == NULL ) return NULL; /*** ok, suck in the rest of this line if necessary (ie something else on the 1st line) ***/ while( c != EOF && c != '\n' ) c=fgetc(ifp); /*** now read in sequence ***/ for(i=0; !feof(ifp) && (c=fgetc(ifp)) != '>' && c != EOF;) { if( isalpha(c) || c == '-' || c == '.' || c == '~' ) seqbuffer[i++] = c; if( i > SEQUENCEBLOCK-2) { seqbuffer[i] = '\0'; if( add_string_to_Sequence(out,seqbuffer) == FALSE ) { warn("Could not read full sequence of %s - returning\n",out->name); return out; } i = 0; } } /* ok have to now put away final buffer read! */ seqbuffer[i] = '\0'; add_string_to_Sequence(out,seqbuffer); /** add back > if need be **/ if( c == '>' ) ungetc(c,ifp); make_len_type_Sequence(out); return out; } /* Function: show_Sequence_residue_list(seq,start,end,ofp) * * Descrip: shows a region of a sequence as * 124 A * 125 T * * etc from start to end. The numbers * are in C coordinates (ie, 0 is the first * letter). * * useful for debugging * * * Arg: seq [READ ] Sequence to show [Sequence *] * Arg: start [READ ] start of list [int] * Arg: end [READ ] end of list [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 1017 "sequence.dy" void show_Sequence_residue_list(Sequence * seq,int start,int end,FILE * ofp) { int i; for(i=start;iseq[i]); } } /* Function: add_string_to_Sequence(seq,more) * * Descrip: New add_string_to_Sequence which should be much better at * handling memory update * * * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: more [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 1030 "sequence.dy" boolean add_string_to_Sequence(Sequence * seq,char * more) { int strl; assert(seq); assert(more); assert(seq->maxlen > 0); strl = strlen(more); if( (seq->len + strl) > (seq->maxlen -2) ) { if( seq->maxlen < SEQUENCE_REALLOC_LINEAR ) { seq->seq = realloc( seq->seq,seq->maxlen*2); seq->maxlen = seq->maxlen *2; } else { seq->seq = realloc( seq->seq,seq->maxlen + SEQUENCE_REALLOC_LINEAR ); seq->maxlen = seq->maxlen + SEQUENCE_REALLOC_LINEAR; } } assert(seq->seq); strcat(seq->seq,more); seq->len = strlen(seq->seq); return TRUE; } /* Function: add_string_to_Sequence_old(seq,more) * * Descrip: Dodgy function. This is meant to add the more * sequence to seq (into ->seq). Not sure how stable * this is. In theory it reallocates memory on * the basis of ->maxlen. * * * Arg: seq [UNKN ] Sequence to add sequence to [Sequence *] * Arg: more [UNKN ] pointer to sequence to add [char *] * * Return [UNKN ] TRUE if successful, FALSE if not [boolean] * */ # line 1070 "sequence.dy" boolean add_string_to_Sequence_old(Sequence * seq,char * more) { register int len; register int blocklen; void * temp; len = strlen(more)+1; if( len < seq->maxlen - seq->len ) { /*** ok can add to this block! ****/ strcat(seq->seq,more); seq->len = strlen(seq->seq); return TRUE; } /*** nope - need to realloc ****/ len -= (seq->maxlen - seq->len); /* amount that needs to be realloc'd */ blocklen = 1 + (int)(len / SEQUENCEBLOCK); /* number of blocks */ blocklen *= SEQUENCEBLOCK; /* make that into bytes */ blocklen += seq->maxlen; /* final size of string */ temp = ckrealloc ( seq->seq,blocklen); if( temp == NULL ) { warn("Sequence block error for sequence %s on blocklen %d\n",CKS(seq->name),blocklen); return FALSE; } seq->seq = (char *) temp; /* realloc moves the memory for us as well */ seq->maxlen = blocklen; /*** copy in string ****/ strcat(seq->seq,more); seq->len = strlen(seq->seq); return TRUE; } /* Function: empty_Sequence_from_dynamic_memory(name) * * Descrip: Only allocates sequence structure and name * * * Arg: name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 1119 "sequence.dy" Sequence * empty_Sequence_from_dynamic_memory(char * name) { Sequence * out; out = Sequence_alloc(); if( out == NULL ) return NULL; if( name == NULL ) { warn("Attempting to make an empty sequence with no name: assigning dummy name"); name = stringalloc("DummyName"); } out->name = name; out->seq = (char *) ckcalloc (SEQUENCE_STARTSIZE,sizeof(char)); out->maxlen = SEQUENCE_STARTSIZE; out->len = 0; return out; } /* Function: Sequence_alloc_len(len) * * Descrip: allocates sequence structure with enough * length in char for len sequence. * * * Arg: len [READ ] length of blank sequene space [int] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 1148 "sequence.dy" Sequence * Sequence_alloc_len(int len) { Sequence * out; out = Sequence_alloc(); if( out == NULL) return NULL; out->seq = (char *) ckcalloc (len,sizeof(char)); out->maxlen = out->len = len; return out; } /* Function: Sequence_from_static_memory (name,seq) * * Descrip: Allocates the sequence structure and memory for * name and seq, copies them in. * * * Arg: name [UNKN ] Undocumented argument [char *] * Arg: seq [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 1167 "sequence.dy" Sequence * Sequence_from_static_memory (char * name,char * seq) { return Sequence_from_dynamic_memory(stringalloc(name),stringalloc(seq)); } /* Function: Sequence_from_dynamic_memory(name,seq) * * Descrip: Allocates the sequence structure and simple attaches * name and seq to the correct places * * * Arg: name [UNKN ] name of sequence [char *] * Arg: seq [UNKN ] a char * to correct sequence [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ # line 1180 "sequence.dy" Sequence * Sequence_from_dynamic_memory(char * name,char * seq) { Sequence * out; if( seq == NULL) { warn("Cannot make a sequence with no sequence!"); return NULL; } if( name == NULL ) { warn("You are attempting to make a sequence with no name - assigning dummy name"); name = stringalloc ("DummyName"); } out = Sequence_alloc(); if( out == NULL) return out; out->name = name; out->seq = seq; out->maxlen = out->len = strlen(seq); return out; } /* Function: write_fasta_Sequence(seq,ofp) * * Descrip: writes a fasta file of the form * >name * Sequence * * * Arg: seq [READ ] sequence to be written [Sequence *] * Arg: ofp [UNKN ] file to write to [FILE *] * */ # line 1217 "sequence.dy" void write_fasta_Sequence(Sequence * seq,FILE * ofp) { assert(seq); fprintf(ofp,">%s\n",seq->name == NULL ? "NoName_Null_string" : seq->name ); show_line(seq->seq,60,ofp); } /* Function: read_fasta_SequenceSet(ifp) * * Descrip: reads a fasta file as a sequence set * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ # line 1227 "sequence.dy" SequenceSet * read_fasta_SequenceSet(FILE * ifp) { SequenceSet * out; Sequence * in; out = SequenceSet_alloc_std(); while( (in = read_fasta_Sequence(ifp)) != NULL ) { add_SequenceSet(out,in); } return out; } /* Function: read_fasta_SequenceSet_file(filename) * * Descrip: opens file and reads in sequence set * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ # line 1244 "sequence.dy" SequenceSet * read_fasta_SequenceSet_file(char * filename) { SequenceSet * out; FILE * ifp; ifp = openfile(filename,"r"); if( ifp == NULL ) { warn("Could not open %s as a file",filename); return NULL; } out = read_fasta_SequenceSet(ifp); fclose(ifp); return out; } # line 1274 "sequence.c" /* Function: hard_link_Sequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Sequence *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * hard_link_Sequence(Sequence * obj) { if( obj == NULL ) { warn("Trying to hard link to a Sequence object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Sequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Sequence_alloc(void) { Sequence * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Sequence *) ckalloc (sizeof(Sequence))) == NULL) { warn("Sequence_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; out->seq = NULL; out->len = 0; out->maxlen = 0; out->offset = 1; out->end = (-1); out->type = SEQUENCE_UNKNOWN; out->tax_id = 0; out->weight = 1.0; out->desc = NULL; return out; } /* Function: free_Sequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Sequence *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * free_Sequence(Sequence * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Sequence obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); if( obj->seq != NULL) ckfree(obj->seq); if( obj->desc != NULL) ckfree(obj->desc); ckfree(obj); return NULL; } /* Function: swap_SequenceSet(list,i,j) * * Descrip: swap function: an internal for qsort_SequenceSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [Sequence **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SequenceSet(Sequence ** list,int i,int j) { Sequence * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SequenceSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SequenceSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [Sequence **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SequenceSet(Sequence ** list,int left,int right,int (*comp)(Sequence * ,Sequence * )) { int i,last; if( left >= right ) return; swap_SequenceSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SequenceSet (list,++last,i); } swap_SequenceSet (list,left,last); qsort_SequenceSet(list,left,last-1,comp); qsort_SequenceSet(list,last+1,right,comp); } /* Function: sort_SequenceSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SequenceSet * * * Arg: obj [UNKN ] Object containing list [SequenceSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SequenceSet(SequenceSet * obj,int (*comp)(Sequence *, Sequence *)) { qsort_SequenceSet(obj->set,0,obj->len-1,comp); return; } /* Function: expand_SequenceSet(obj,len) * * Descrip: Really an internal function for add_SequenceSet * * * Arg: obj [UNKN ] Object which contains the list [SequenceSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SequenceSet(SequenceSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SequenceSet called with no need"); return TRUE; } if( (obj->set = (Sequence ** ) ckrealloc (obj->set,sizeof(Sequence *)*len)) == NULL) { warn("ckrealloc failed for expand_SequenceSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SequenceSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SequenceSet *] * Arg: add [OWNER] Object to add to the list [Sequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SequenceSet(SequenceSet * obj,Sequence * add) { if( obj->len >= obj->maxlen) { if( expand_SequenceSet(obj,obj->len + SequenceSetLISTLENGTH) == FALSE) return FALSE; } obj->set[obj->len++]=add; return TRUE; } /* Function: flush_SequenceSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SequenceSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SequenceSet(SequenceSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->set[i] != NULL) { free_Sequence(obj->set[i]); obj->set[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SequenceSet_alloc_std(void) * * Descrip: Equivalent to SequenceSet_alloc_len(SequenceSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ SequenceSet * SequenceSet_alloc_std(void) { return SequenceSet_alloc_len(SequenceSetLISTLENGTH); } /* Function: SequenceSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ SequenceSet * SequenceSet_alloc_len(int len) { SequenceSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SequenceSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->set = (Sequence ** ) ckcalloc (len,sizeof(Sequence *))) == NULL) { warn("Warning, ckcalloc failed in SequenceSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SequenceSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SequenceSet *] * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ SequenceSet * hard_link_SequenceSet(SequenceSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a SequenceSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SequenceSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ SequenceSet * SequenceSet_alloc(void) { SequenceSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SequenceSet *) ckalloc (sizeof(SequenceSet))) == NULL) { warn("SequenceSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->set = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_SequenceSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SequenceSet *] * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ SequenceSet * free_SequenceSet(SequenceSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SequenceSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->set != NULL) { for(i=0;ilen;i++) { if( obj->set[i] != NULL) free_Sequence(obj->set[i]); } ckfree(obj->set); } ckfree(obj); return NULL; } /* Function: replace_name_Sequence(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * Arg: name [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable name [boolean] * */ boolean replace_name_Sequence(Sequence * obj,char * name) { if( obj == NULL) { warn("In replacement function name for object Sequence, got a NULL object"); return FALSE; } obj->name = name; return TRUE; } /* Function: access_name_Sequence(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * * Return [SOFT ] member variable name [char *] * */ char * access_name_Sequence(Sequence * obj) { if( obj == NULL) { warn("In accessor function name for object Sequence, got a NULL object"); return NULL; } return obj->name; } /* Function: replace_seq_Sequence(obj,seq) * * Descrip: Replace member variable seq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * Arg: seq [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable seq [boolean] * */ boolean replace_seq_Sequence(Sequence * obj,char * seq) { if( obj == NULL) { warn("In replacement function seq for object Sequence, got a NULL object"); return FALSE; } obj->seq = seq; return TRUE; } /* Function: access_seq_Sequence(obj) * * Descrip: Access member variable seq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * * Return [SOFT ] member variable seq [char *] * */ char * access_seq_Sequence(Sequence * obj) { if( obj == NULL) { warn("In accessor function seq for object Sequence, got a NULL object"); return NULL; } return obj->seq; } /* Function: replace_len_Sequence(obj,len) * * Descrip: Replace member variable len * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * Arg: len [OWNER] New value of the variable [int] * * Return [SOFT ] member variable len [boolean] * */ boolean replace_len_Sequence(Sequence * obj,int len) { if( obj == NULL) { warn("In replacement function len for object Sequence, got a NULL object"); return FALSE; } obj->len = len; return TRUE; } /* Function: access_len_Sequence(obj) * * Descrip: Access member variable len * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * * Return [SOFT ] member variable len [int] * */ int access_len_Sequence(Sequence * obj) { if( obj == NULL) { warn("In accessor function len for object Sequence, got a NULL object"); return 0; } return obj->len; } /* Function: replace_maxlen_Sequence(obj,maxlen) * * Descrip: Replace member variable maxlen * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * Arg: maxlen [OWNER] New value of the variable [int] * * Return [SOFT ] member variable maxlen [boolean] * */ boolean replace_maxlen_Sequence(Sequence * obj,int maxlen) { if( obj == NULL) { warn("In replacement function maxlen for object Sequence, got a NULL object"); return FALSE; } obj->maxlen = maxlen; return TRUE; } /* Function: access_maxlen_Sequence(obj) * * Descrip: Access member variable maxlen * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * * Return [SOFT ] member variable maxlen [int] * */ int access_maxlen_Sequence(Sequence * obj) { if( obj == NULL) { warn("In accessor function maxlen for object Sequence, got a NULL object"); return 0; } return obj->maxlen; } /* Function: replace_offset_Sequence(obj,offset) * * Descrip: Replace member variable offset * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * Arg: offset [OWNER] New value of the variable [int] * * Return [SOFT ] member variable offset [boolean] * */ boolean replace_offset_Sequence(Sequence * obj,int offset) { if( obj == NULL) { warn("In replacement function offset for object Sequence, got a NULL object"); return FALSE; } obj->offset = offset; return TRUE; } /* Function: access_offset_Sequence(obj) * * Descrip: Access member variable offset * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * * Return [SOFT ] member variable offset [int] * */ int access_offset_Sequence(Sequence * obj) { if( obj == NULL) { warn("In accessor function offset for object Sequence, got a NULL object"); return 0; } return obj->offset; } /* Function: replace_end_Sequence(obj,end) * * Descrip: Replace member variable end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * Arg: end [OWNER] New value of the variable [int] * * Return [SOFT ] member variable end [boolean] * */ boolean replace_end_Sequence(Sequence * obj,int end) { if( obj == NULL) { warn("In replacement function end for object Sequence, got a NULL object"); return FALSE; } obj->end = end; return TRUE; } /* Function: access_end_Sequence(obj) * * Descrip: Access member variable end * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * * Return [SOFT ] member variable end [int] * */ int access_end_Sequence(Sequence * obj) { if( obj == NULL) { warn("In accessor function end for object Sequence, got a NULL object"); return 0; } return obj->end; } /* Function: replace_type_Sequence(obj,type) * * Descrip: Replace member variable type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * Arg: type [OWNER] New value of the variable [char] * * Return [SOFT ] member variable type [boolean] * */ boolean replace_type_Sequence(Sequence * obj,char type) { if( obj == NULL) { warn("In replacement function type for object Sequence, got a NULL object"); return FALSE; } obj->type = type; return TRUE; } /* Function: access_type_Sequence(obj) * * Descrip: Access member variable type * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * * Return [SOFT ] member variable type [char] * */ char access_type_Sequence(Sequence * obj) { if( obj == NULL) { warn("In accessor function type for object Sequence, got a NULL object"); return 'u'; } return obj->type; } /* Function: replace_tax_id_Sequence(obj,tax_id) * * Descrip: Replace member variable tax_id * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * Arg: tax_id [OWNER] New value of the variable [int] * * Return [SOFT ] member variable tax_id [boolean] * */ boolean replace_tax_id_Sequence(Sequence * obj,int tax_id) { if( obj == NULL) { warn("In replacement function tax_id for object Sequence, got a NULL object"); return FALSE; } obj->tax_id = tax_id; return TRUE; } /* Function: access_tax_id_Sequence(obj) * * Descrip: Access member variable tax_id * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * * Return [SOFT ] member variable tax_id [int] * */ int access_tax_id_Sequence(Sequence * obj) { if( obj == NULL) { warn("In accessor function tax_id for object Sequence, got a NULL object"); return 0; } return obj->tax_id; } /* Function: replace_weight_Sequence(obj,weight) * * Descrip: Replace member variable weight * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * Arg: weight [OWNER] New value of the variable [double] * * Return [SOFT ] member variable weight [boolean] * */ boolean replace_weight_Sequence(Sequence * obj,double weight) { if( obj == NULL) { warn("In replacement function weight for object Sequence, got a NULL object"); return FALSE; } obj->weight = weight; return TRUE; } /* Function: access_weight_Sequence(obj) * * Descrip: Access member variable weight * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * * Return [SOFT ] member variable weight [double] * */ double access_weight_Sequence(Sequence * obj) { if( obj == NULL) { warn("In accessor function weight for object Sequence, got a NULL object"); return 0; } return obj->weight; } /* Function: replace_desc_Sequence(obj,desc) * * Descrip: Replace member variable desc * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * Arg: desc [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable desc [boolean] * */ boolean replace_desc_Sequence(Sequence * obj,char * desc) { if( obj == NULL) { warn("In replacement function desc for object Sequence, got a NULL object"); return FALSE; } obj->desc = desc; return TRUE; } /* Function: access_desc_Sequence(obj) * * Descrip: Access member variable desc * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Sequence *] * * Return [SOFT ] member variable desc [char *] * */ char * access_desc_Sequence(Sequence * obj) { if( obj == NULL) { warn("In accessor function desc for object Sequence, got a NULL object"); return NULL; } return obj->desc; } /* Function: access_set_SequenceSet(obj,i) * * Descrip: Access members stored in the set list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [SequenceSet *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [Sequence *] * */ Sequence * access_set_SequenceSet(SequenceSet * obj,int i) { if( obj == NULL) { warn("In accessor function set for object SequenceSet, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function set for object SequenceSet, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->set[i]; } /* Function: length_set_SequenceSet(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [SequenceSet *] * * Return [UNKN ] length of the list [int] * */ int length_set_SequenceSet(SequenceSet * obj) { if( obj == NULL) { warn("In length function set for object SequenceSet, got a NULL object"); return -1; } return obj->len; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/sequence.h0000644000175000001440000006343210670453713016630 0ustar philippusers#ifndef DYNAMITEsequenceHEADERFILE #define DYNAMITEsequenceHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "codon.h" #ifdef LINUX #include "posix.h" #endif #define SEQUENCEBLOCK 8000 #define SEQUENCE_STARTSIZE 512 #define SEQUENCE_REALLOC_LINEAR (4096*4) enum SequenceType { SEQUENCE_UNKNOWN = 64, SEQUENCE_PROTEIN, SEQUENCE_DNA, SEQUENCE_CDNA, SEQUENCE_GENOMIC, SEQUENCE_EST, SEQUENCE_RNA }; #define is_dna_SequenceType(type) (type == SEQUENCE_DNA || type == SEQUENCE_CDNA || type == SEQUENCE_GENOMIC || type == SEQUENCE_EST ? TRUE : FALSE) #define is_rna_SequenceType(type) (type == SEQUENCE_RNA ? TRUE : FALSE) #define is_protein_SequenceType(type) (type == SEQUENCE_PROTEIN ? TRUE : FALSE ) #define is_dna_Sequence(seq) (is_dna_SequenceType(seq->type)) #define is_rna_Sequence(seq) (is_rna_SequenceType(seq->type)) #define is_protein_Sequence(seq) (is_protein_SequenceType(seq->type)) #define SequenceSetLISTLENGTH 64 /* Object Sequence * * Descrip: This object is the basic sequence object, * trying to hold little more than the * name and sequence of the DNA/protein. * * The len/maxlen is the actual length * of the sequence (strlen(obj->seq)) and * amount of memory allocated in obj->seq * mainly for parsing purposes. * * * */ struct Wise2_Sequence { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; /* name of the sequence */ char * seq; /* actual sequence */ int len; /* length of the sequence */ int maxlen; /* internal counter, indicating how much space in seq there is */ int offset; /* start (in bio-coords) of the sequence. Not called start due to weird legacy. */ int end; /* end (in bio-coords == C coords) of the sequence */ char type; /* guess of protein/dna type */ int tax_id; /* taxonimic id of this */ double weight; char * desc; /* description - often this will be NULL */ } ; /* Sequence defined */ #ifndef DYNAMITE_DEFINED_Sequence typedef struct Wise2_Sequence Wise2_Sequence; #define Sequence Wise2_Sequence #define DYNAMITE_DEFINED_Sequence #endif /* Object SequenceSet * * Descrip: A list of sequences. Not a database (you should * use the db stuff for that!). But useful anyway * * */ struct Wise2_SequenceSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence ** set; int len;/* len for above set */ int maxlen; /* maxlen for above set */ } ; /* SequenceSet defined */ #ifndef DYNAMITE_DEFINED_SequenceSet typedef struct Wise2_SequenceSet Wise2_SequenceSet; #define SequenceSet Wise2_SequenceSet #define DYNAMITE_DEFINED_SequenceSet #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_Sequence_from_strings(name,seq) * * Descrip: Makes a new sequence from strings given. * Separate memory will be allocated for them * and them copied into it. * * They can be NULL, in which case * o a dummy name SequenceName will be assigned * o No sequence placed and length of zero. * * Though this is dangerous later on. * * The sequence type is calculated automatically using * /best_guess_type. If you want a DNA sequence but are * unsure of the content of, for example, IUPAC codes, * please use /force_to_dna_Sequence before using the * sequence. Most of the rest of dynamite relies on a * five letter A,T,G,C,N alphabet, but this function * will allow any sequence type to be stored, so please * check if you want to save yourself alot of grief. * * In perl and other interfaces, this is a much safer * constructor than the raw "new" type * * * Arg: name [READ ] name of sequence, memory is allocated for it. [char *] * Arg: seq [READ ] char * of sequence, memory is allocated for it. [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_new_Sequence_from_strings(char * name,char * seq); #define new_Sequence_from_strings Wise2_new_Sequence_from_strings /* Function: looks_like_accession(name) * * Descrip: Returns true if name looks like [A-Za-z]+[0-9]+ * This should be an accession number * * * Arg: name [READ ] name to be tested [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_looks_like_accession(char * name); #define looks_like_accession Wise2_looks_like_accession /* Function: make_len_type_Sequence(seq) * * Descrip: makes seq->len and seq->end match the seq->seq * length number. * * It also checks the type of the sequence with * /best_guess_type * * * Arg: seq [RW ] Sequence object [Sequence *] * */ void Wise2_make_len_type_Sequence(Sequence * seq); #define make_len_type_Sequence Wise2_make_len_type_Sequence /* Function: best_guess_type(seq) * * Descrip: Guesses DNA or protein, by adding all * the A,T,G,C up and if len < 300 && > 95% or * len > 300 && > 75% then considers * it to be DNA. NB - Ns now counted. * * * Arg: seq [READ ] Sequence to be guessed [Sequence *] * * Return [OWNER] SEQUENCE_DNA or SEQUENCE_PROTEIN [int] * */ int Wise2_best_guess_type(Sequence * seq); #define best_guess_type Wise2_best_guess_type /* Function: Sequence_type_to_string(type) * * Descrip: Converts sequence type (SEQUENCE_*) to a string * * * Arg: type [UNKN ] type eg SEQUENCE_PROTEIN [int] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_Sequence_type_to_string(int type); #define Sequence_type_to_string Wise2_Sequence_type_to_string /* Function: uppercase_Sequence(seq) * * Descrip: makes all the sequence uppercase * * * Arg: seq [RW ] Sequence to be uppercased [Sequence *] * */ void Wise2_uppercase_Sequence(Sequence * seq); #define uppercase_Sequence Wise2_uppercase_Sequence /* Function: force_to_dna_Sequence(seq,fraction,number_of_conver) * * Descrip: This * a) sees how many non ATGCN characters there are in Seq * b) If the level is below fraction * a) flips non ATGC chars to N * b) writes number of conversions to number_of_conver * c) returns TRUE * c) else returns FALSE * * fraction of 0.0 means completely intolerant of errors * fraction of 1.0 means completely tolerant of errors * * * * Arg: seq [RW ] sequence object read and converted [Sequence *] * Arg: fraction [READ ] number 0..1 for tolerance of conversion [double] * Arg: number_of_conver [WRITE] number of conversions actually made [int *] * * Return [READ ] TRUE for conversion to DNA, FALSE if not [boolean] * */ boolean Wise2_force_to_dna_Sequence(Sequence * seq,double fraction,int * number_of_conver); #define force_to_dna_Sequence Wise2_force_to_dna_Sequence /* Function: is_reversed_Sequence(seq) * * Descrip: Currently the sequence object stores * reversed sequences as start > end. * * This tests that and returns true if it is * * * Arg: seq [READ ] sequence to test [Sequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_is_reversed_Sequence(Sequence * seq); #define is_reversed_Sequence Wise2_is_reversed_Sequence /* Function: translate_Sequence(dna,ct) * * Descrip: This translates a DNA sequence to a protein. * It assummes that it starts at first residue * (use trunc_Sequence to chop a sequence up). * * * Arg: dna [READ ] DNA sequence to be translated [Sequence *] * Arg: ct [READ ] Codon table to do codon->aa mapping [CodonTable *] * * Return [OWNER] new protein sequence [Sequence *] * */ Sequence * Wise2_translate_Sequence(Sequence * dna,CodonTable * ct); #define translate_Sequence Wise2_translate_Sequence /* Function: reverse_complement_Sequence(seq) * * Descrip: This both complements and reverses a sequence, * - a common wish! * * The start/end are correct with respect to the start/end * of the sequence (ie start = end, end = start). * * * Arg: seq [READ ] Sequence to that is used to reverse (makes a new Sequence) [Sequence *] * * Return [OWNER] new Sequence which is reversed [Sequence *] * */ Sequence * Wise2_reverse_complement_Sequence(Sequence * seq); #define reverse_complement_Sequence Wise2_reverse_complement_Sequence /* Function: magic_trunc_Sequence(seq,start,end) * * Descrip: Clever function for dna sequences. * * When start < end, truncates normally * * when start > end, truncates end,start and then * reverse complements. * * ie. If you have a coordinate system where reverse * sequences are labelled in reverse start/end way, * then this routine produces the correct sequence. * * * Arg: seq [READ ] sequence that is the source to be truncated [Sequence *] * Arg: start [READ ] start point [int] * Arg: end [READ ] end point [int] * * Return [OWNER] new Sequence which is truncated/reversed [Sequence *] * */ Sequence * Wise2_magic_trunc_Sequence(Sequence * seq,int start,int end); #define magic_trunc_Sequence Wise2_magic_trunc_Sequence /* Function: trunc_Sequence(seq,start,end) * * Descrip: truncates a sequence. It produces a new memory structure * which is filled from sequence start to end. * * Please notice * * Truncation is in C coordinates. That is * the first residue is 0 and end is the number of the * residue after the cut-point. In otherwords to * 2 - 3 would be a single residue truncation. So - if * you want to work in more usual, 'inclusive' molecular * biology numbers, which start at 1, then you need to say * * trunc_Sequence(seq,start-1,end); * * (NB, should be (end - 1 + 1) = end for the last coordinate). * * Truncation occurs against the *absolute* coordinate * system of the Sequence, not the offset/end pair inside. * So, this is a very bad error * * ** wrong code, and also leaks memory ** * * tru = trunc_Sequence(trunc_Sequence(seq,50,80),55,75); * * This the most portable way of doing this * * temp = trunc_Sequence(seq,50,80); * * tru = trunc_Sequence(temp,55-temp->offset,75-temp->offset); * * free_Sequence(temp); * * * * Arg: seq [READ ] object holding the sequence to be truncated [Sequence *] * Arg: start [READ ] start point of truncation [int] * Arg: end [READ ] end point of truncation [int] * * Return [OWNER] newly allocated sequence structure [Sequence *] * */ Sequence * Wise2_trunc_Sequence(Sequence * seq,int start,int end); #define trunc_Sequence Wise2_trunc_Sequence /* Function: read_SRS_db_Sequence(datastring,srsstring) * * Descrip: A function for you to easily specify the sequence name * and the database separately. Just concatonates the two * strings with : betwqeen them. Therefore you should use * "swisprot-id" for example as your datastring. * * calls /read_SRS_Sequence * * * Arg: datastring [READ ] string representing the database (swissprot-id) [char *] * Arg: srsstring [READ ] string for the name (eg, ROA1_HUMAN) [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_read_SRS_db_Sequence(char * datastring,char * srsstring); #define read_SRS_db_Sequence Wise2_read_SRS_db_Sequence /* Function: read_SRS_Sequence(srsstring) * * Descrip: reads SRS specified sequence. calls popoen * with getz -f using srs4 syntax. Will only read * the first sequence if there is more than one in the * SRS spec, and does not warn you about additional * sequences * * * Arg: srsstring [READ ] srs spec'd string swissprot-id:ROA1_HUMAN [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_read_SRS_Sequence(char * srsstring); #define read_SRS_Sequence Wise2_read_SRS_Sequence /* Function: read_efetch_Sequence(efetchstring) * * Descrip: reads efetch specificed sequence. calls popen to * efetch. A hack around accession numbers so that if the * thing looks like WP:acc number, calls it with -a... * otherwise assummes you have both database and name in the * efetchstring * * * Arg: efetchstring [READ ] efetch valid string [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_read_efetch_Sequence(char * efetchstring); #define read_efetch_Sequence Wise2_read_efetch_Sequence /* Function: read_fasta_file_Sequence(filename) * * Descrip: Just a call * a) open filename * b) read sequence with /read_fasta_Sequence * c) close file. * * * Arg: filename [READ ] filename to open [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_read_fasta_file_Sequence(char * filename); #define read_fasta_file_Sequence Wise2_read_fasta_file_Sequence /* Function: read_Sequence_EMBL_seq(buffer,maxlen,ifp) * * Descrip: reads the sequence part of an EMBL file. * * This function can either take a file which * starts * * * * Arg: buffer [RW ] buffer containing the first line. [char *] * Arg: maxlen [READ ] length of buffer [int] * Arg: ifp [READ ] input file to read from [FILE *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_read_Sequence_EMBL_seq(char * buffer,int maxlen,FILE * ifp); #define read_Sequence_EMBL_seq Wise2_read_Sequence_EMBL_seq /* Function: read_fasta_Sequence(ifp) * * Descrip: reads a fasta file assumming pretty * standard sanity for the file layout * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_read_fasta_Sequence(FILE * ifp); #define read_fasta_Sequence Wise2_read_fasta_Sequence /* Function: read_old_fasta_Sequence(ifp) * * Descrip: reads the fasta file: format is * * >name * sequence * * allocates a structure and puts in the * sequence. Calls /make_len_type_Sequence to * check type and length. * * It leaves the '>' on the next fasta sequence * for multiple sequence reading * * * Arg: ifp [READ ] input file to read from [FILE *] * * Return [OWNER] new Sequence structure [Sequence *] * */ Sequence * Wise2_read_old_fasta_Sequence(FILE * ifp); #define read_old_fasta_Sequence Wise2_read_old_fasta_Sequence /* Function: show_Sequence_residue_list(seq,start,end,ofp) * * Descrip: shows a region of a sequence as * 124 A * 125 T * * etc from start to end. The numbers * are in C coordinates (ie, 0 is the first * letter). * * useful for debugging * * * Arg: seq [READ ] Sequence to show [Sequence *] * Arg: start [READ ] start of list [int] * Arg: end [READ ] end of list [int] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_Sequence_residue_list(Sequence * seq,int start,int end,FILE * ofp); #define show_Sequence_residue_list Wise2_show_Sequence_residue_list /* Function: add_string_to_Sequence(seq,more) * * Descrip: New add_string_to_Sequence which should be much better at * handling memory update * * * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: more [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_string_to_Sequence(Sequence * seq,char * more); #define add_string_to_Sequence Wise2_add_string_to_Sequence /* Function: empty_Sequence_from_dynamic_memory(name) * * Descrip: Only allocates sequence structure and name * * * Arg: name [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_empty_Sequence_from_dynamic_memory(char * name); #define empty_Sequence_from_dynamic_memory Wise2_empty_Sequence_from_dynamic_memory /* Function: Sequence_alloc_len(len) * * Descrip: allocates sequence structure with enough * length in char for len sequence. * * * Arg: len [READ ] length of blank sequene space [int] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_Sequence_alloc_len(int len); #define Sequence_alloc_len Wise2_Sequence_alloc_len /* Function: write_fasta_Sequence(seq,ofp) * * Descrip: writes a fasta file of the form * >name * Sequence * * * Arg: seq [READ ] sequence to be written [Sequence *] * Arg: ofp [UNKN ] file to write to [FILE *] * */ void Wise2_write_fasta_Sequence(Sequence * seq,FILE * ofp); #define write_fasta_Sequence Wise2_write_fasta_Sequence /* Function: read_fasta_SequenceSet(ifp) * * Descrip: reads a fasta file as a sequence set * * * Arg: ifp [UNKN ] Undocumented argument [FILE *] * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ SequenceSet * Wise2_read_fasta_SequenceSet(FILE * ifp); #define read_fasta_SequenceSet Wise2_read_fasta_SequenceSet /* Function: read_fasta_SequenceSet_file(filename) * * Descrip: opens file and reads in sequence set * * * Arg: filename [UNKN ] Undocumented argument [char *] * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ SequenceSet * Wise2_read_fasta_SequenceSet_file(char * filename); #define read_fasta_SequenceSet_file Wise2_read_fasta_SequenceSet_file /* Function: hard_link_Sequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Sequence *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_hard_link_Sequence(Sequence * obj); #define hard_link_Sequence Wise2_hard_link_Sequence /* Function: Sequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_Sequence_alloc(void); #define Sequence_alloc Wise2_Sequence_alloc /* Function: free_Sequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Sequence *] * * Return [UNKN ] Undocumented return value [Sequence *] * */ Sequence * Wise2_free_Sequence(Sequence * obj); #define free_Sequence Wise2_free_Sequence /* Function: add_SequenceSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SequenceSet *] * Arg: add [OWNER] Object to add to the list [Sequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SequenceSet(SequenceSet * obj,Sequence * add); #define add_SequenceSet Wise2_add_SequenceSet /* Function: flush_SequenceSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SequenceSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SequenceSet(SequenceSet * obj); #define flush_SequenceSet Wise2_flush_SequenceSet /* Function: SequenceSet_alloc_std(void) * * Descrip: Equivalent to SequenceSet_alloc_len(SequenceSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ SequenceSet * Wise2_SequenceSet_alloc_std(void); #define SequenceSet_alloc_std Wise2_SequenceSet_alloc_std /* Function: SequenceSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ SequenceSet * Wise2_SequenceSet_alloc_len(int len); #define SequenceSet_alloc_len Wise2_SequenceSet_alloc_len /* Function: hard_link_SequenceSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SequenceSet *] * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ SequenceSet * Wise2_hard_link_SequenceSet(SequenceSet * obj); #define hard_link_SequenceSet Wise2_hard_link_SequenceSet /* Function: SequenceSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ SequenceSet * Wise2_SequenceSet_alloc(void); #define SequenceSet_alloc Wise2_SequenceSet_alloc /* Function: free_SequenceSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SequenceSet *] * * Return [UNKN ] Undocumented return value [SequenceSet *] * */ SequenceSet * Wise2_free_SequenceSet(SequenceSet * obj); #define free_SequenceSet Wise2_free_SequenceSet /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_len_Sequence(Sequence * obj,int len); #define replace_len_Sequence Wise2_replace_len_Sequence boolean Wise2_replace_offset_Sequence(Sequence * obj,int offset); #define replace_offset_Sequence Wise2_replace_offset_Sequence int Wise2_access_offset_Sequence(Sequence * obj); #define access_offset_Sequence Wise2_access_offset_Sequence int Wise2_length_set_SequenceSet(SequenceSet * obj); #define length_set_SequenceSet Wise2_length_set_SequenceSet boolean Wise2_replace_end_Sequence(Sequence * obj,int end); #define replace_end_Sequence Wise2_replace_end_Sequence boolean Wise2_replace_name_Sequence(Sequence * obj,char * name); #define replace_name_Sequence Wise2_replace_name_Sequence int Wise2_access_end_Sequence(Sequence * obj); #define access_end_Sequence Wise2_access_end_Sequence boolean Wise2_replace_seq_Sequence(Sequence * obj,char * seq); #define replace_seq_Sequence Wise2_replace_seq_Sequence boolean Wise2_replace_type_Sequence(Sequence * obj,char type); #define replace_type_Sequence Wise2_replace_type_Sequence int Wise2_access_len_Sequence(Sequence * obj); #define access_len_Sequence Wise2_access_len_Sequence char Wise2_access_type_Sequence(Sequence * obj); #define access_type_Sequence Wise2_access_type_Sequence int Wise2_access_maxlen_Sequence(Sequence * obj); #define access_maxlen_Sequence Wise2_access_maxlen_Sequence boolean Wise2_replace_tax_id_Sequence(Sequence * obj,int tax_id); #define replace_tax_id_Sequence Wise2_replace_tax_id_Sequence Sequence * Wise2_access_set_SequenceSet(SequenceSet * obj,int i); #define access_set_SequenceSet Wise2_access_set_SequenceSet int Wise2_access_tax_id_Sequence(Sequence * obj); #define access_tax_id_Sequence Wise2_access_tax_id_Sequence char * Wise2_access_seq_Sequence(Sequence * obj); #define access_seq_Sequence Wise2_access_seq_Sequence boolean Wise2_replace_weight_Sequence(Sequence * obj,double weight); #define replace_weight_Sequence Wise2_replace_weight_Sequence char * Wise2_access_name_Sequence(Sequence * obj); #define access_name_Sequence Wise2_access_name_Sequence char * Wise2_access_desc_Sequence(Sequence * obj); #define access_desc_Sequence Wise2_access_desc_Sequence double Wise2_access_weight_Sequence(Sequence * obj); #define access_weight_Sequence Wise2_access_weight_Sequence boolean Wise2_replace_maxlen_Sequence(Sequence * obj,int maxlen); #define replace_maxlen_Sequence Wise2_replace_maxlen_Sequence boolean Wise2_replace_desc_Sequence(Sequence * obj,char * desc); #define replace_desc_Sequence Wise2_replace_desc_Sequence boolean Wise2_add_string_to_Sequence_old(Sequence * seq,char * more); #define add_string_to_Sequence_old Wise2_add_string_to_Sequence_old Sequence * Wise2_Sequence_from_static_memory (char * name,char * seq); #define Sequence_from_static_memory Wise2_Sequence_from_static_memory Sequence * Wise2_Sequence_from_dynamic_memory(char * name,char * seq); #define Sequence_from_dynamic_memory Wise2_Sequence_from_dynamic_memory void Wise2_swap_SequenceSet(Sequence ** list,int i,int j) ; #define swap_SequenceSet Wise2_swap_SequenceSet void Wise2_qsort_SequenceSet(Sequence ** list,int left,int right,int (*comp)(Sequence * ,Sequence * )); #define qsort_SequenceSet Wise2_qsort_SequenceSet void Wise2_sort_SequenceSet(SequenceSet * obj,int (*comp)(Sequence *, Sequence *)); #define sort_SequenceSet Wise2_sort_SequenceSet boolean Wise2_expand_SequenceSet(SequenceSet * obj,int len); #define expand_SequenceSet Wise2_expand_SequenceSet #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/randomdb.dy0000644000175000001440000000457707426023106016772 0ustar philippusers %{ #include "wisebase.h" #include "histogram.h" #include "randommodel.h" %} struct RandomProteinDB boolean use_flat_length !def="TRUE" int length Histogram * length_dist RandomModel * emission int num struct RandomDNADB boolean use_flat_length !def="TRUE" int length Histogram * length_dist RandomModelDNA * emission int num api object RandomProteinDB des free_RandomProteinDB endobject object RandomDNADB des free_RandomDNADB endobject endapi %{ #include "randomdb.h" %func Makes a new random sequence from a RandomProteinDB %% Sequence * Sequence_from_RandomProteinDB(RandomProteinDB * rndp) { int i; Sequence * out; char * name = "RandomSequence"; char buffer[512]; char * seq; if( rndp->use_flat_length == FALSE ) { warn("Ooops have not implemented gaussian lengths yet. Yikes!"); return NULL; } seq = ckcalloc(rndp->length+1,sizeof(char)); for(i=0;ilength+1;i++) { seq[i] = draw_random_aa_RandomModel(rndp->emission); } sprintf(buffer,"%s%d",name,rndp->num++); out = new_Sequence_from_strings(name,seq); ckfree(seq); return out; } %func Makes a new flat RandomProteinDB %arg rm s RandomModel length length of protein to produce %% RandomProteinDB * new_flat_RandomProteinDB(RandomModel * rm,int length) { RandomProteinDB * out; out = RandomProteinDB_alloc(); out->use_flat_length = TRUE; out->emission = hard_link_RandomModel(rm); out->length = length; return out; } %func Makes a new random sequence from a RandomDNADB %% Sequence * Sequence_from_RandomDNADB(RandomDNADB * rndp) { int i; Sequence * out; char * name = "RandomSequence"; char buffer[512]; char * seq; if( rndp->use_flat_length == FALSE ) { warn("Ooops have not implemented gaussian lengths yet. Yikes!"); return NULL; } seq = ckcalloc(rndp->length+1,sizeof(char)); for(i=0;ilength+1;i++) { seq[i] = draw_random_base_RandomModelDNA(rndp->emission); } sprintf(buffer,"%s%d",name,rndp->num++); out = new_Sequence_from_strings(buffer,seq); ckfree(seq); return out; } %func Makes a new flat RandomDNADB %arg rm s RandomModel emission length length of DNA to produce %% RandomDNADB * new_flat_RandomDNADB(RandomModelDNA * rm,int length) { RandomDNADB * out; out = RandomDNADB_alloc(); out->use_flat_length = TRUE; out->emission = hard_link_RandomModelDNA(rm); out->length = length; out->num = 1; return out; } %} wise-2.4.1/src/dynlibsrc/randomdb.xs0000644000175000001440000001111710670453712017001 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::RandomProteinDB Wise2_RandomProteinDB * hard_link_RandomProteinDB(obj) Wise2_RandomProteinDB * obj CODE: RETVAL = Wise2_hard_link_RandomProteinDB(obj); OUTPUT: RETVAL Wise2_RandomProteinDB * alloc() CODE: RETVAL = Wise2_RandomProteinDB_alloc(); OUTPUT: RETVAL boolean set_use_flat_length(obj,use_flat_length) Wise2_RandomProteinDB * obj boolean use_flat_length CODE: RETVAL = Wise2_replace_use_flat_length_RandomProteinDB(obj,use_flat_length); OUTPUT: RETVAL boolean use_flat_length(obj) Wise2_RandomProteinDB * obj CODE: RETVAL = Wise2_access_use_flat_length_RandomProteinDB(obj); OUTPUT: RETVAL boolean set_length(obj,length) Wise2_RandomProteinDB * obj int length CODE: RETVAL = Wise2_replace_length_RandomProteinDB(obj,length); OUTPUT: RETVAL int length(obj) Wise2_RandomProteinDB * obj CODE: RETVAL = Wise2_access_length_RandomProteinDB(obj); OUTPUT: RETVAL boolean set_length_dist(obj,length_dist) Wise2_RandomProteinDB * obj Wise2_Histogram * length_dist CODE: RETVAL = Wise2_replace_length_dist_RandomProteinDB(obj,Wise2_hard_link_Histogram(length_dist)); OUTPUT: RETVAL Wise2_Histogram * length_dist(obj) Wise2_RandomProteinDB * obj INIT: Wise2_Histogram * temp; CODE: temp = Wise2_hard_link_Histogram(Wise2_access_length_dist_RandomProteinDB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_emission(obj,emission) Wise2_RandomProteinDB * obj Wise2_RandomModel * emission CODE: RETVAL = Wise2_replace_emission_RandomProteinDB(obj,Wise2_hard_link_RandomModel(emission)); OUTPUT: RETVAL Wise2_RandomModel * emission(obj) Wise2_RandomProteinDB * obj INIT: Wise2_RandomModel * temp; CODE: temp = Wise2_hard_link_RandomModel(Wise2_access_emission_RandomProteinDB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_num(obj,num) Wise2_RandomProteinDB * obj int num CODE: RETVAL = Wise2_replace_num_RandomProteinDB(obj,num); OUTPUT: RETVAL int num(obj) Wise2_RandomProteinDB * obj CODE: RETVAL = Wise2_access_num_RandomProteinDB(obj); OUTPUT: RETVAL Wise2_RandomProteinDB * new(class) char * class PPCODE: Wise2_RandomProteinDB * out; out = Wise2_RandomProteinDB_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_RandomProteinDB * obj CODE: Wise2_free_RandomProteinDB(obj); MODULE = Wise2 PACKAGE = Wise2::RandomDNADB Wise2_RandomDNADB * hard_link_RandomDNADB(obj) Wise2_RandomDNADB * obj CODE: RETVAL = Wise2_hard_link_RandomDNADB(obj); OUTPUT: RETVAL Wise2_RandomDNADB * alloc() CODE: RETVAL = Wise2_RandomDNADB_alloc(); OUTPUT: RETVAL boolean set_use_flat_length(obj,use_flat_length) Wise2_RandomDNADB * obj boolean use_flat_length CODE: RETVAL = Wise2_replace_use_flat_length_RandomDNADB(obj,use_flat_length); OUTPUT: RETVAL boolean use_flat_length(obj) Wise2_RandomDNADB * obj CODE: RETVAL = Wise2_access_use_flat_length_RandomDNADB(obj); OUTPUT: RETVAL boolean set_length(obj,length) Wise2_RandomDNADB * obj int length CODE: RETVAL = Wise2_replace_length_RandomDNADB(obj,length); OUTPUT: RETVAL int length(obj) Wise2_RandomDNADB * obj CODE: RETVAL = Wise2_access_length_RandomDNADB(obj); OUTPUT: RETVAL boolean set_length_dist(obj,length_dist) Wise2_RandomDNADB * obj Wise2_Histogram * length_dist CODE: RETVAL = Wise2_replace_length_dist_RandomDNADB(obj,Wise2_hard_link_Histogram(length_dist)); OUTPUT: RETVAL Wise2_Histogram * length_dist(obj) Wise2_RandomDNADB * obj INIT: Wise2_Histogram * temp; CODE: temp = Wise2_hard_link_Histogram(Wise2_access_length_dist_RandomDNADB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_emission(obj,emission) Wise2_RandomDNADB * obj Wise2_RandomModelDNA * emission CODE: RETVAL = Wise2_replace_emission_RandomDNADB(obj,Wise2_hard_link_RandomModelDNA(emission)); OUTPUT: RETVAL Wise2_RandomModelDNA * emission(obj) Wise2_RandomDNADB * obj INIT: Wise2_RandomModelDNA * temp; CODE: temp = Wise2_hard_link_RandomModelDNA(Wise2_access_emission_RandomDNADB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_num(obj,num) Wise2_RandomDNADB * obj int num CODE: RETVAL = Wise2_replace_num_RandomDNADB(obj,num); OUTPUT: RETVAL int num(obj) Wise2_RandomDNADB * obj CODE: RETVAL = Wise2_access_num_RandomDNADB(obj); OUTPUT: RETVAL Wise2_RandomDNADB * new(class) char * class PPCODE: Wise2_RandomDNADB * out; out = Wise2_RandomDNADB_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_RandomDNADB * obj CODE: Wise2_free_RandomDNADB(obj); MODULE = Wise2 PACKAGE = Wise2 wise-2.4.1/src/dynlibsrc/packaln.dy0000644000175000001440000001011407646464215016613 0ustar philippusers/* Last edited: Dec 5 19:45 1996 (birney) */ %{ #include "wisebase.h" #include "probability.h" #define PackAlnLISTLENGTH 64 %} api object PackAln des free_PackAln func show_simple_PackAln func show_bits_and_cumlative_PackAln endobject object PackAlnUnit des free_PackAlnUnit endobject endapi struct PackAlnUnit int i // position in query int j // position in target int state // state in FSM int score !def="0" // score of the transition that reached this state %info Internal object for /PackAln: A single position of an alignment as the (i,j,state) triple %% struct PackAln PackAlnUnit ** pau !list // list of PackAlnUnits from start to end int score; // score over the entire alignment %info This is the lowest-level of representation of a DP alignment, being the list of (i,j,state) triples taken through the DP matrix. The score for the transition to this point is held as well. This object is very low level and often a much better choice for representation is in /AlnBlock objects %% %{ #include "packaln.h" %func Reads in a PackAln from a file in show_simple_PackAln %% PackAln * read_simple_PackAln_file(char * file) { FILE * ifp; PackAln * out; if( (ifp=openfile(file,"r")) == NULL ) { warn("Could not open %s for PackAln file reading",file); } out = read_simple_PackAln(ifp); fclose(ifp); return out; } %func Reads in PackAln from file format in show_simple_PackAln %% PackAln * read_simple_PackAln(FILE * ifp) { PackAln * out; PackAlnUnit * unit; char buffer[MAXLINE]; assert(ifp); out = PackAln_alloc_std(); /* score line */ fgets(buffer,MAXLINE,ifp); while( fgets(buffer,MAXLINE,ifp) != NULL ) { if( strstartcmp(buffer,"//") == 0 ) { break; } unit = PackAlnUnit_alloc(); sscanf(buffer,"Position i:[%d] j:[%d] State:[%d] Score: %d",&unit->i,&unit->j,&unit->state,&unit->score); add_PackAln(out,unit); } return out; } %func shows packalnunit very simply ;) %type internal %% void show_simple_PackAlnUnit(PackAlnUnit * pau,FILE * ofp) { fprintf(ofp,"Position i:[%d] j:[%d] State:[%d] Score: %d\n",pau->i,pau->j,pau->state,pau->score); } %func shows packalnunit with the text mapping %type internal %% void show_text_PackAlnUnit(PackAlnUnit * pau,char * (*state_to_char)(int),FILE * ofp) { fprintf(ofp,"Position i:[%4d] j:[%4d] State:[%2d] Score:[%3d] [%s]\n",pau->i,pau->j,pau->state,pau->score,(*state_to_char)(pau->state)); } %func Shows packaln as: i,j,state,score,bits,cumlative-score,cumlative-bits cumlative score and cumlative bits are useful sometimes %% void show_bits_and_cumlative_PackAln(PackAln * pal,FILE * ofp) { int i; int cs = 0; double cb = 0.0; fprintf(ofp,"Score %d\n",pal->score); for(i=0;ilen;i++) { auto PackAlnUnit * pau; pau = pal->pau[i]; cs += pal->pau[i]->score; cb += Score2Bits(pal->pau[i]->score); fprintf(ofp,"i [%4d] j [%4d] state [%2d] score [%4d] bits [%2.2f] Score-CF [%6d] Bits-CF[%4.2f]\n",pau->i,pau->j,pau->state,pau->score,Score2Bits(pau->score),cs,cb); } } %func shows packaln with a pretty verbose debugging format %% void show_simple_PackAln(PackAln * pal,FILE * ofp) { register int i; fprintf(ofp,"Score %d\n",pal->score); for(i=0;ilen;i++) show_simple_PackAlnUnit(pal->pau[i],ofp); } %func shows packaln with a pretty verbose debugging format, but with a conversion function from state number to a string %% void show_text_PackAln(PackAln * pal,char * (*state_to_char)(int),FILE * ofp) { register int i; fprintf(ofp,"Score %d\n",pal->score); for(i=0;ilen;i++) show_text_PackAlnUnit(pal->pau[i],state_to_char,ofp); } %func inverts the packaln so that the last unit is the first etc. Because most alignments are read backwards this is useful %arg pal PackAln to be inverted %% void invert_PackAln(PackAln * pal) { PackAlnUnit ** temp; register int i; /*** there are better ways to do this! ***/ temp = (PackAlnUnit **) ckcalloc(pal->len,sizeof(PackAlnUnit *)); for(i=0;ilen;i++) temp[i] = pal->pau[pal->len-1-i]; for(i=0;ilen;i++) pal->pau[i] = temp[i]; ckfree(temp); } %} wise-2.4.1/src/dynlibsrc/packaln.xs0000644000175000001440000000665710670453712016641 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::PackAln void show_simple_PackAln(pal,ofp) Wise2_PackAln * pal FILE * ofp CODE: Wise2_show_simple_PackAln(pal,ofp); void show_bits_and_cumlative_PackAln(pal,ofp) Wise2_PackAln * pal FILE * ofp CODE: Wise2_show_bits_and_cumlative_PackAln(pal,ofp); Wise2_PackAln * hard_link_PackAln(obj) Wise2_PackAln * obj CODE: RETVAL = Wise2_hard_link_PackAln(obj); OUTPUT: RETVAL Wise2_PackAln * PackAln_alloc_std() CODE: RETVAL = Wise2_PackAln_alloc_std(); OUTPUT: RETVAL Wise2_PackAlnUnit * pau(obj,i) Wise2_PackAln * obj int i INIT: Wise2_PackAlnUnit * temp; CODE: temp = Wise2_hard_link_PackAlnUnit(Wise2_access_pau_PackAln(obj,i)); RETVAL = temp; OUTPUT: RETVAL int length_pau(obj) Wise2_PackAln * obj CODE: RETVAL = Wise2_length_pau_PackAln(obj); OUTPUT: RETVAL int flush_pau(obj) Wise2_PackAln * obj CODE: RETVAL = Wise2_flush_PackAln(obj); OUTPUT: RETVAL boolean add_pau(obj,add) Wise2_PackAln * obj Wise2_PackAlnUnit * add CODE: RETVAL = Wise2_add_PackAln(obj,Wise2_hard_link_PackAlnUnit(add)); OUTPUT: RETVAL boolean set_score(obj,score) Wise2_PackAln * obj int score CODE: RETVAL = Wise2_replace_score_PackAln(obj,score); OUTPUT: RETVAL int score(obj) Wise2_PackAln * obj CODE: RETVAL = Wise2_access_score_PackAln(obj); OUTPUT: RETVAL Wise2_PackAln * new(class) char * class PPCODE: Wise2_PackAln * out; out = Wise2_PackAln_alloc_std(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_PackAln * obj CODE: Wise2_free_PackAln(obj); void each_pau(obj) Wise2_PackAln * obj PPCODE: int i=0; int len; SV* temp; len = Wise2_length_pau_PackAln(obj); for(i=0;iarray = calloc(array_max_size,sizeof(SeqLookupPos *)); for(i=0;iarray[i] = NULL; } a->array_max = array_max_size; a->block = new_SeqLookupPosBlockAllocator(); out->data = (void*) a; out->lookup = lookup_subseqlookup; out->add = add_subseqlookup; out->is_populated = is_populated_subseqlookup; out->free_data = free_subseqlookup; return out; } %func free function for the hash %% void free_subseqlookup(void * data) { SubSeqLookup * look = (SubSeqLookup *)data; free_SubSeqLookup(look); } %func tells whether this is populated or not %% boolean is_populated_subseqlookup(void * data, int seq_number) { SubSeqLookup * look = (SubSeqLookup *)data; if( look->array[seq_number] == NULL ) { return FALSE; } else { return TRUE; } } %func Retrieves a SeqLookup position %% SeqLookupResultInterface * lookup_subseqlookup(void * data, int seq_number) { SubSeqLookup * look = (SubSeqLookup *)data; return new_linkedl_SeqLookupResultInterface(look->array[seq_number]); } %func Adds a sequence/pos pair to the hash %% boolean add_subseqlookup(void * data,int seq_number,Sequence * seq,int pos) { SubSeqLookup * look = (SubSeqLookup *)data; SeqLookupPos * p; p = new_SeqLookupPos_BlockAllocator(look->block); p->seq = seq; p->pos = pos; p->next = NULL; if( look->array[seq_number] == NULL ) { look->array[seq_number] = p; } else { p->next = look->array[seq_number]; look->array[seq_number] = p; } return TRUE; } %func Makes a new SeqPosLookup Block Allocator %% SeqLookupPosBlockAllocator * new_SeqLookupPosBlockAllocator(void) { SeqLookupPosBlockAllocator * out; out = SeqLookupPosBlockAllocator_alloc_std(); add_SeqLookupPosBlockAllocator(out,SeqLookupPosBlock_alloc()); out->pos = 0; return out; } %func Returns a new SeqPosLookup %% SeqLookupPos * new_SeqLookupPos_BlockAllocator(SeqLookupPosBlockAllocator *bla) { if( bla->pos+1 > LOOKUP_BLOCK_SIZE ) { add_SeqLookupPosBlockAllocator(bla,SeqLookupPosBlock_alloc()); bla->pos = 0; fprintf(stderr,"Increasing block...\n"); } bla->block[bla->len-1]->block[bla->pos].dynamite_hard_link = 1; bla->pos++; return &(bla->block[bla->len-1]->block[bla->pos-1]); } wise-2.4.1/src/dynlibsrc/intallocator.dy0000644000175000001440000001653507636311132017676 0ustar philippusers %{ #include "wisebase.h" #include typedef union int_allocator_header { struct { union int_allocator_header * next; /* when free */ }s ; int dummy; /* to ensure alignment */ } IntAllocatorHeader; #define IntAllocator_BLOCKSIZE 512 #define IntAllocator_MEMORY_BLOCK_SIZE 512 /* #define IntAllocator_PARANOIA 1 */ %} struct IntAllocator int size IntAllocatorHeader * start_of_free !def="NULL" !link void ** allocated_blocks !link int max_allocated_blocks int current_allocated_block struct IntAllocatorSet IntAllocator ** allocator_set int max_size %{ #include "intallocator.h" %func Makes a new IntAllocatorSet up to a certain size %% IntAllocatorSet * new_IntAllocatorSet(int max_size) { IntAllocatorSet * out; out = IntAllocatorSet_alloc(); out->allocator_set = calloc(max_size,sizeof(IntAllocator*)); out->max_size = max_size; return out; } %func reallocates a piece of memory %% int * realloc_intarray_IntAllocatorSet(IntAllocatorSet * ias,int * current,int old_size,int new_size) { int i; int * new_a; assert(ias); assert(new_size > old_size); new_a = alloc_intarray_IntAllocatorSet(ias,new_size); assert(new_a); for(i=0;i ias->max_size ) { return free(array); } assert(ias->allocator_set[size]); return free_intarray_IntAllocator(ias->allocator_set[size],array); } %func Allocates a new piece of memory in a IntAllocatorSet %% int * alloc_intarray_IntAllocatorSet(IntAllocatorSet * ias,int size) { assert(ias); if( size > ias->max_size ) { return (int*)calloc(size,sizeof(int)); } if( ias->allocator_set[size] == NULL ) { ias->allocator_set[size] = new_IntAllocator(size); } return alloc_intarray_IntAllocator(ias->allocator_set[size]); } %func Makes a new int allocator %% IntAllocator * new_IntAllocator(int size) { IntAllocator * out; #ifdef IntAllocator_PARANOIA warn("IntAllocator in paranoia mode. Will perform horrendously slowly due to cycle checking"); #endif out = IntAllocator_alloc(); out->size = size; out->start_of_free = NULL; out->allocated_blocks = NULL; out->max_allocated_blocks = 0; out->current_allocated_block = 0; return out; } #ifdef IntAllocator_PARANOIA %func Detect cycle %% boolean is_acyclic_IntAllocator(IntAllocator * ia) { GHashTable * gh; IntAllocatorHeader * h; int count; int dummy; assert(ia); gh = g_hash_table_new(g_direct_hash,g_direct_equal); count = 0; for(h = ia->start_of_free;h != NULL;h = h->s.next) { if( g_hash_table_lookup(gh,(gconstpointer)h) != NULL ) { warn("Found cycle at memory position %d, count %d",h,count); return FALSE; } else { g_hash_table_insert(gh,(gpointer)h,&dummy); count++; } } g_hash_table_destroy(gh); return TRUE; } #endif %func Show status of intallocator set %% void show_allocator_status_IntAllocatorSet(IntAllocatorSet * ias,FILE * ofp) { int i; int count; IntAllocatorHeader * h; IntAllocator * ia; int mem; long total = 0; for(i=0;imax_size;i++) { if( ias->allocator_set[i] == NULL ) { fprintf(ofp,"[%4d] No allocator\n",i); } else { ia = ias->allocator_set[i]; for(h = ia->start_of_free,count =0;h != NULL;h = h->s.next) { count++; } mem = ia->current_allocated_block * (sizeof(IntAllocatorHeader)+(sizeof(int)*ia->size)) * IntAllocator_BLOCKSIZE; total += mem; fprintf(ofp,"[%4d] %d allocated, %d free, total bytes %d\n",i,ia->current_allocated_block*IntAllocator_BLOCKSIZE,count,mem); } } fprintf(ofp,"In total, %ld bytes allocated\n",total); } %func Shows allocator status %% void show_allocator_status_IntAllocator(IntAllocator * ia,FILE * ofp) { int count = 0; IntAllocatorHeader * h; fprintf(ofp,"%d blocks allocated, using %ld bytes\n",ia->current_allocated_block,ia->current_allocated_block * (sizeof(IntAllocatorHeader)+(sizeof(int)*ia->size)) * IntAllocator_BLOCKSIZE); for(h = ia->start_of_free;h != NULL;h = h->s.next) { count++; } fprintf(ofp,"%d units free, %.2f %% occupancy\n",count,(count*100.0)/(ia->current_allocated_block * IntAllocator_BLOCKSIZE)); } %func returns an integer back to the pool. NOTE: This integer * must have come from the pool otherwise there is going to be a disaster... %% void free_intarray_IntAllocator(IntAllocator * ia,int * array) { char * runner; IntAllocatorHeader * h; assert(ia); assert(array); runner = (char*) array; runner = runner - sizeof(IntAllocatorHeader); h = (IntAllocatorHeader*) runner; h->s.next = ia->start_of_free; ia->start_of_free = h; #ifdef IntAllocator_PARANOIA if( is_acyclic_IntAllocator(ia) == FALSE ) { fatal("cycle detected on freeing block for %d position",h); } #endif return; } %func returns an integer * from this allocator %% int * alloc_intarray_IntAllocator(IntAllocator * ia) { IntAllocatorHeader * h; char * runner; assert(ia); if( ia->start_of_free == NULL ) { ia->start_of_free = allocate_new_block_IntAllocator(ia); } #ifdef IntAllocator_PARANOIA if( is_acyclic_IntAllocator(ia) == FALSE ) { fatal("cycle detected on allocating new block"); } #endif h = ia->start_of_free; ia->start_of_free = h->s.next; #ifdef IntAllocator_PARANOIA if( is_acyclic_IntAllocator(ia) == FALSE ) { fatal("cycle detected on returning new block"); } #endif runner = (char*) h; runner = runner + sizeof(IntAllocatorHeader); return (int*) runner; } %func internal function to allocate and segment a block read for use, storing the memory and segmenting it correctly. Returned pointer is the first header block %% IntAllocatorHeader * allocate_new_block_IntAllocator(IntAllocator * ia) { int i; int step_size; char * new_block; IntAllocatorHeader * h; char * runner; assert(ia); step_size = sizeof(IntAllocatorHeader)+(sizeof(int)*ia->size); new_block = calloc(IntAllocator_BLOCKSIZE,step_size); add_new_block_to_memory_handlers_IA(ia,new_block); for(i=0;is.next = (IntAllocatorHeader*) runner; } else { /* last one */ h->s.next = NULL; } } return (IntAllocatorHeader*) new_block; } %func internal function to ensure new block is added, with growth of block array if needed %% void add_new_block_to_memory_handlers_IA(IntAllocator * ia,void * new_block) { assert(ia); assert(new_block); if( ia->allocated_blocks == NULL ) { ia->allocated_blocks = calloc(IntAllocator_MEMORY_BLOCK_SIZE,sizeof(void*)); ia->max_allocated_blocks = IntAllocator_MEMORY_BLOCK_SIZE; ia->current_allocated_block = 0; } else if( ia->current_allocated_block >= ia->max_allocated_blocks ) { ia->allocated_blocks = realloc(ia->allocated_blocks,(ia->max_allocated_blocks+IntAllocator_MEMORY_BLOCK_SIZE)*sizeof(void*)); ia->max_allocated_blocks = (ia->max_allocated_blocks+IntAllocator_MEMORY_BLOCK_SIZE); } ia->allocated_blocks[ia->current_allocated_block++] = new_block; return; } %} wise-2.4.1/src/dynlibsrc/searchstatlookup.dy0000644000175000001440000000236107640343144020571 0ustar philippusers %{ #include "searchstatinterface.h" #include "probability.h" #include "histogram.h" %} struct EVDLookup double mu double lambda %{ #include "searchstatlookup.h" %func Internal function for bit conversion %% double bit_halfbit_lookup_ssi(void * data,int query_len,int target_len,int raw_score) { return raw_score / 2.0; } %func Internal function for evalue conversion. uses externally defined parameters for evd estimation %% double evalue_halfbit_lookup_ssi(void * data,Sequence * a,Sequence * b,int raw_score,int database_size) { EVDLookup * l = (EVDLookup *)data; return database_size * ExtremeValueP((float)raw_score,l->mu,l->lambda); } %func Internal function for free... %% void free_evdlookup_void (void * data) { EVDLookup * l = (EVDLookup *)data; free_EVDLookup(l); } %func Builds an external lookup statistics package %% SearchStatInterface * new_lookup_SearchStatInterface(double mu,double lambda) { SearchStatInterface * ssi; EVDLookup * el; ssi = SearchStatInterface_alloc(); el = EVDLookup_alloc(); el->mu = mu; el->lambda = lambda; ssi->data = (void *) el; ssi->calc_evalue = evalue_halfbit_lookup_ssi; ssi->calc_bits = bit_halfbit_lookup_ssi; ssi->free_data = free_evdlookup_void; return ssi; } wise-2.4.1/src/dynlibsrc/hsp2hitscan.dy0000644000175000001440000001610310257313360017416 0ustar philippusers %{ #include "hsplookupscan.h" #define SeedHitSetLISTLENGTH 200 #define SeedHitManagerLISTLENGTH 500 %} struct SeedHit int diagonal int posi int posj int used !def="0" struct SeedHitSet SeedHit ** sh !list Sequence * target !link int score !def="0" struct SeedHitManager GHashTable * hash !link SeedHitSet ** set !list %{ #include "hsp2hitscan.h" #include #include %func Makes a new SeedHit %% SeedHit * new_SeedHit(int posi,int posj) { SeedHit * out; out = SeedHit_alloc(); out->diagonal = posi - posj; out->posi = posi; out->posj = posj; out->used = 0; return out; } %func Adds a new position to the manger, allocating any new datastructures %% boolean add_SeedHit_SeedHitManager(SeedHitManager * shm,Sequence * t,int posi,int posj,int score) { SeedHitSet * sh = NULL; if( (sh = g_hash_table_lookup(shm->hash,(gpointer)t)) == NULL ) { sh = SeedHitSet_alloc_std(); sh->target = t; g_hash_table_insert(shm->hash,(gpointer)t,sh); add_SeedHitManager(shm,sh); } sh->score += score; add_SeedHitSet(sh,new_SeedHit(posi,posj)); return TRUE; } %func Chooses which Seeds to use for HSPs. If there are more than factor x max_results cases, restricted it to factor x max_results scored by seed hits. Then askes for two diagonal seeds within a wobble factor to start the HSP process %% HSPmanager * populate_HSP_from_SeedHitManager(Sequence * query,SeedHitManager * shm,HSPScanInterfacePara * para,HSPScanPara * p) { HSPmanager * out; int max_depth; int i,j,k; assert(shm); out = new_HSPmanager(query,p->mat,p->drop_off); if( p->seed_factor * para->max_results > shm->len ) { max_depth = shm->len; } else { sort_SeedHitManager_by_score(shm); max_depth = p->seed_factor * para->max_results; } fprintf(stderr,"Looking at %d seend hits from %d\n",max_depth,shm->len); for(i=0;iset[i]); for(j=0;jset[i]->len;j++) { if( shm->set[i]->sh[j]->used == 1 ) { continue; } for(k=j+1;kset[i]->len;k++) { if( shm->set[i]->sh[j]->diagonal + p->twohit_wobble < shm->set[i]->sh[k]->diagonal ) { break; } /* else - we have two potential seeds */ if( shm->set[i]->sh[j]->used != 1 ) { add_pair_HSPmanager(out,shm->set[i]->target,shm->set[i]->sh[j]->posi,shm->set[i]->sh[j]->posj); } if( shm->set[i]->sh[k]->used != 1 ) { add_pair_HSPmanager(out,shm->set[i]->target,shm->set[i]->sh[k]->posi,shm->set[i]->sh[k]->posj); } shm->set[i]->sh[j]->used = 1; shm->set[i]->sh[k]->used = 1; } } } return out; } %func Builds a 2 hit search model for protein searches %% HSPScanInterface * new_twohit_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff) { HSPScanInterface * out; HSPScanPara * p; assert(sli); assert(mat); out = HSPScanInterface_alloc(); p = HSPScanPara_alloc(); p->sli = hard_link_SeqLookupInterface(sli); p->mat = hard_link_CompMat(mat); p->drop_off = drop_off; p->score_cutoff = score_cutoff; out->data = (void*)p; out->free_data = simple_HSPScan_free; out->scan_query = one_off_two_hit_HSPscan_query_direct; return out; } %func two hit approach HSPscan %% LinearHSPmanager * one_off_two_hit_HSPscan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para) { HSPmanager * hspm; LinearHSPmanager * out; HSPScanPara * p = (HSPScanPara *)data; char * std_aa = "ACDEFGHIKLMNPQRSTVWY"; SeedHitManager * shm; char newseq[5]; int seqno[5]; int base[5]; int start_base; ArraySeqHead * head; int no; int aa; int score; SeqLookupResultInterface * slri; SeqLookupClientInterface * slci; SeqLookupResultStruct * res = NULL; static struct rusage use; int i,k,j; fprintf(stderr,"Got into two hit system!\n"); shm = new_SeedHitManager(); assert(seq != NULL); assert(p != NULL); assert(para != NULL); slci = (*p->sli->get_client)(p->sli->data); getrusage(RUSAGE_SELF,&use); fprintf(stderr,"START %d.%03du %d.%03ds \n", use.ru_utime.tv_sec, use.ru_utime.tv_sec/1000, use.ru_stime.tv_sec, use.ru_stime.tv_sec/1000 ); for(i=0;ilen-5;i++) { if( (*slci->is_populated)(slci->data,seq_number_aa_5mer(seq->seq+i)) ) { slri = (*slci->lookup)(slci->data,seq_number_aa_5mer(seq->seq+i)); res = NULL; for(;(*slri->is_more)(slri->data);) { res = (*slri->next)(slri->data,res); add_SeedHit_SeedHitManager(shm,res->seq,i,res->pos,5); } free_SeqLookupResultInterface(slri); } for(score=0,j=0;j<5;j++) { seqno[j] = base[j]*(toupper(seq->seq[i+j]-'A')); } for(j=0;j<5;j++) { for(aa=0;aa<20;aa++) { if( seq->seq[i+j] == std_aa[aa] ) { continue; } seqno[j] = base[j]*(std_aa[aa]-'A'); no= seqno[0]+seqno[1]+seqno[2]+seqno[3]+seqno[4]; if( (*slci->is_populated)(slci->data,seq_number_aa_5mer(newseq)) ) { slri = (*slci->lookup)(slci->data,seq_number_aa_5mer(newseq)); res = NULL; for(;(*slri->is_more)(slri->data);) { res = (*slri->next)(slri->data,res); add_SeedHit_SeedHitManager(shm,res->seq,i,res->pos,1); } free_SeqLookupResultInterface(slri); } seqno[j] = base[j]*(toupper(seq->seq[i+j]-'A')); newseq[j] = seq->seq[i+j]; } } } getrusage(RUSAGE_SELF,&use); fprintf(stderr,"END OF SEED %d.%03du %d.%03ds \n", use.ru_utime.tv_sec, use.ru_utime.tv_sec/1000, use.ru_stime.tv_sec, use.ru_stime.tv_sec/1000 ); hspm = populate_HSP_from_SeedHitManager(seq,shm,para,p); getrusage(RUSAGE_SELF,&use); fprintf(stderr,"POPULATION %d.%03du %d.%03ds \n", use.ru_utime.tv_sec, use.ru_utime.tv_sec/1000, use.ru_stime.tv_sec, use.ru_stime.tv_sec/1000 ); delete_SeedHitManager(shm); if( para->use_protein_heuristic == TRUE ) { out = new_LinearHSPmanager_heuristic_max(hspm,para->max_results); } else { out = new_LinearHSPmanager_flat(hspm); } fprintf(stdout,"LINEARISED %d.%03du %d.%03ds \n", use.ru_utime.tv_sec, use.ru_utime.tv_sec/1000, use.ru_stime.tv_sec, use.ru_stime.tv_sec/1000 ); return out; } %func internal for score sorting %% int compare_SeedHitSet_score(SeedHitSet * one,SeedHitSet * two) { return two->score - one->score; } %func internal for diagonal sorting %% int compare_SeedHit_diagonal(SeedHit * one,SeedHit * two) { return one->diagonal - two->diagonal; } %func Sorts hit managers by score (highest first) %% void sort_SeedHitManager_by_score(SeedHitManager * shm) { sort_SeedHitManager(shm,compare_SeedHitSet_score); } %func Sorts SeedHit by diagonal (lowest first) %% void sort_SeedHitSet_by_diagonal(SeedHitSet * sh) { sort_SeedHitSet(sh,compare_SeedHit_diagonal); } %func Makes an empty SeedHit Manager %% SeedHitManager * new_SeedHitManager(void) { SeedHitManager * out; out = SeedHitManager_alloc_std(); out->hash = g_hash_table_new(g_direct_hash,g_direct_equal); return out; } %func Free SeedHitManager %% SeedHitManager * delete_SeedHitManager(SeedHitManager * shm) { g_hash_table_destroy(shm->hash); return free_SeedHitManager(shm); } wise-2.4.1/src/dynlibsrc/shattermatrix.dy0000644000175000001440000000631207644256202020077 0ustar philippusers %{ #include "wisebase.h" #include "dpenvelope.h" #define ShatterMatrixLISTLENGTH 1024 %} struct ShatterMatrixComponent int ** mat int starti int startj int endi int endj struct ShatterMatrix ShatterMatrixComponent ** smc !list int ** special int cell_length int special_length int * null_cell; %{ #include "shattermatrix.h" %func Gets the actual value from cell %% int fetch_cell_value_ShatterMatrix(ShatterMatrix * sm,int ipos,int jpos,int state) { int * ret; ret = fetch_cell_from_ShatterMatrix(sm,ipos,jpos); return ret[state]; } %func gets int * pointer in the right place for this cell %% int * fetch_cell_from_ShatterMatrix(ShatterMatrix * sm,int ipos,int jpos) { int i; int offseti; int offsetj; assert(sm); for(i=0;ilen;i++) { if( ipos >= sm->smc[i]->starti && ipos < sm->smc[i]->endi && jpos >= sm->smc[i]->startj && jpos < sm->smc[i]->endj ) { /* great! */ /* offset into this */ offseti = ipos - sm->smc[i]->starti; offsetj = jpos - sm->smc[i]->startj; return sm->smc[i]->mat[offseti]+(offsetj*sm->cell_length); } } /* for(i=0;icell_length;i++) { if( sm->null_cell[i] != -100000 ) { fatal("At position %d,%d fetched null cell with %d\n",ipos,jpos,sm->null_cell[i]); } } fprintf(stderr," ...null cell %d,%d\n",ipos,jpos); */ return sm->null_cell; } %func Makes a new shattermatrix - needs to know the cell length and special length %% ShatterMatrix * new_ShatterMatrix(DPEnvelope * dpenv,int cell_length,int jlength,int special_length) { int i; ShatterMatrix * out; out = ShatterMatrix_alloc_len(dpenv->len); out->cell_length = cell_length; out->null_cell = calloc(cell_length,sizeof(int)); for(i=0;inull_cell[i] = -100000; } for(i=0;ilen;i++) { auto DPUnit * dpu = dpenv->dpu[i]; if( dpu->type == DPENV_RECT ) { add_ShatterMatrix(out,new_ShatterMatrixComponent(dpu->starti,dpu->starti+dpu->height,dpu->startj,dpu->startj+dpu->length,cell_length)); } else if ( dpu->type == DPENV_DIAG ) { add_ShatterMatrix(out,new_ShatterMatrixComponent(dpu->starti-dpu->height,dpu->starti+dpu->height+dpu->length,dpu->startj-dpu->height,dpu->startj+dpu->height+dpu->length,cell_length)); } else { fatal("Do not understand type %d",dpu->type); } } out->special = calloc(special_length,sizeof(int*)); for(i=0;ispecial[i] = calloc(jlength,sizeof(int)); } return out; } %func Makes a new ShatterMatrixComponent - needs to know the cell length and start/end %% ShatterMatrixComponent * new_ShatterMatrixComponent(int starti,int endi,int startj,int endj,int cell_length) { ShatterMatrixComponent * out; int i; int j; int leni; assert(starti < endi); assert(startj < endj); assert(cell_length > 0); out = ShatterMatrixComponent_alloc(); out->starti = starti; out->endi = endi; out->startj = startj; out->endj = endj; leni = endi - starti; /* fprintf(stderr,"Allocating area of %d,%d %d cells\n",leni,(endj-startj),leni*(endj-startj));*/ out->mat = calloc(leni,sizeof(int *)); for(i=0;imat[i] = calloc((endj-startj)*cell_length,sizeof(int)); } return out; } wise-2.4.1/src/dynlibsrc/cdna.pod0000644000175000001440000000651510670453712016256 0ustar philippusers=head1 NAME cdna module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item cDNA =back =head1 DESCRIPTION =head2 Object cDNA =over =item baseseq Type [Sequence *] Scalar No documentation =back No documentation for cDNA =head2 Member functions of cDNA =over =item truncate_cDNA &Wise2::cDNA::truncate_cDNA(cdna,start,stop) Truncates a cDNA sequence. Basically uses the /magic_trunc_Sequence function (of course!) It does not alter cdna, rather it returns a new sequence with that truncation Argument cdna [READ ] cDNA that is truncated [cDNA *] Argument start [UNKN ] Undocumented argument [int] Argument stop [UNKN ] Undocumented argument [int] Return [UNKN ] Undocumented return value [cDNA *] =item read_fasta_file_cDNA &Wise2::cDNA::read_fasta_file_cDNA(filename) Reads a fasta file assumming that it is cDNA. Will complain if it is not, and return NULL. Argument filename [UNKN ] filename to be opened and read [char *] Return [UNKN ] Undocumented return value [cDNA *] =item cDNA_name &Wise2::cDNA::cDNA_name(cdna) Returns the name of the cDNA Argument cdna [UNKN ] Undocumented argument [cDNA *] Return [UNKN ] Undocumented return value [char *] =item cDNA_length &Wise2::cDNA::cDNA_length(cdna) Returns the length of the cDNA Argument cdna [UNKN ] Undocumented argument [cDNA *] Return [UNKN ] Undocumented return value [int] =item cDNA_seqchar &Wise2::cDNA::cDNA_seqchar(cdna,pos) Returns sequence character at this position. Argument cdna [UNKN ] cDNA [cDNA *] Argument pos [UNKN ] position in cDNA to get char [int] Return [UNKN ] Undocumented return value [char] =item cDNA_from_Sequence &Wise2::cDNA::cDNA_from_Sequence(seq) makes a new cDNA from a Sequence. It owns the Sequence memory, ie will attempt a /free_Sequence on the structure when /free_cDNA is called If you want to give this cDNA this Sequence and forget about it, then just hand it this sequence and set seq to NULL (no need to free it). If you intend to use the sequence object elsewhere outside of the cDNA datastructure then use cDNA_from_Sequence(/hard_link_Sequence(seq)) Argument seq [OWNER] Sequence to make cDNA from [Sequence *] Return [UNKN ] Undocumented return value [cDNA *] =item hard_link_cDNA &Wise2::cDNA::hard_link_cDNA(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [cDNA *] Return [UNKN ] Undocumented return value [cDNA *] =item alloc &Wise2::cDNA::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [cDNA *] =item set_baseseq &Wise2::cDNA::set_baseseq(obj,baseseq) Replace member variable baseseq For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNA *] Argument baseseq [OWNER] New value of the variable [Sequence *] Return [SOFT ] member variable baseseq [boolean] =item baseseq &Wise2::cDNA::baseseq(obj) Access member variable baseseq For use principly by API functions Argument obj [UNKN ] Object holding the variable [cDNA *] Return [SOFT ] member variable baseseq [Sequence *] =back wise-2.4.1/src/dynlibsrc/cdna.tex0000644000175000001440000000724110670453712016271 0ustar philippusers\section{cdna} \label{module_cdna} This module contains the following objects \begin{itemize} \item \ref{object_cDNA} cDNA \end{itemize} \subsection{Object cDNA} \label{object_cDNA} The cDNA object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{baseseq} Type [Sequence * : Scalar] No documentation \end{description} No documentation for cDNA Member functions of cDNA \subsubsection{truncate_cDNA} \begin{description} \item[External C] {\tt Wise2_truncate_cDNA (cdna,start,stop)} \item[Perl] {\tt &Wise2::cDNA::truncate_cDNA (cdna,start,stop)} \item[Perl-OOP call] {\tt $obj->truncate_cDNA(start,stop)} \end{description} Arguments \begin{description} \item[cdna] [READ ] cDNA that is truncated [cDNA *] \item[start] [UNKN ] Undocumented argument [int] \item[stop] [UNKN ] Undocumented argument [int] \item[returns] [UNKN ] Undocumented return value [cDNA *] \end{description} Truncates a cDNA sequence. Basically uses the /magic_trunc_Sequence function (of course!) It does not alter cdna, rather it returns a new sequence with that truncation \subsubsection{read_fasta_file_cDNA} \begin{description} \item[External C] {\tt Wise2_read_fasta_file_cDNA (filename)} \item[Perl] {\tt &Wise2::cDNA::read_fasta_file_cDNA (filename)} \item[Perl-OOP call] {\tt $obj->read_fasta_file_cDNA()} \end{description} Arguments \begin{description} \item[filename] [UNKN ] filename to be opened and read [char *] \item[returns] [UNKN ] Undocumented return value [cDNA *] \end{description} Reads a fasta file assumming that it is cDNA. Will complain if it is not, and return NULL. \subsubsection{cDNA_name} \begin{description} \item[External C] {\tt Wise2_cDNA_name (cdna)} \item[Perl] {\tt &Wise2::cDNA::cDNA_name (cdna)} \item[Perl-OOP call] {\tt $obj->cDNA_name()} \end{description} Arguments \begin{description} \item[cdna] [UNKN ] Undocumented argument [cDNA *] \item[returns] [UNKN ] Undocumented return value [char *] \end{description} Returns the name of the cDNA \subsubsection{cDNA_length} \begin{description} \item[External C] {\tt Wise2_cDNA_length (cdna)} \item[Perl] {\tt &Wise2::cDNA::cDNA_length (cdna)} \item[Perl-OOP call] {\tt $obj->cDNA_length()} \end{description} Arguments \begin{description} \item[cdna] [UNKN ] Undocumented argument [cDNA *] \item[returns] [UNKN ] Undocumented return value [int] \end{description} Returns the length of the cDNA \subsubsection{cDNA_seqchar} \begin{description} \item[External C] {\tt Wise2_cDNA_seqchar (cdna,pos)} \item[Perl] {\tt &Wise2::cDNA::cDNA_seqchar (cdna,pos)} \item[Perl-OOP call] {\tt $obj->cDNA_seqchar(pos)} \end{description} Arguments \begin{description} \item[cdna] [UNKN ] cDNA [cDNA *] \item[pos] [UNKN ] position in cDNA to get char [int] \item[returns] [UNKN ] Undocumented return value [char] \end{description} Returns sequence character at this position. \subsubsection{cDNA_from_Sequence} \begin{description} \item[External C] {\tt Wise2_cDNA_from_Sequence (seq)} \item[Perl] {\tt &Wise2::cDNA::cDNA_from_Sequence (seq)} \item[Perl-OOP call] {\tt $obj->cDNA_from_Sequence()} \end{description} Arguments \begin{description} \item[seq] [OWNER] Sequence to make cDNA from [Sequence *] \item[returns] [UNKN ] Undocumented return value [cDNA *] \end{description} makes a new cDNA from a Sequence. It owns the Sequence memory, ie will attempt a /free_Sequence on the structure when /free_cDNA is called If you want to give this cDNA this Sequence and forget about it, then just hand it this sequence and set seq to NULL (no need to free it). If you intend to use the sequence object elsewhere outside of the cDNA datastructure then use cDNA_from_Sequence(/hard_link_Sequence(seq)) wise-2.4.1/src/dynlibsrc/singlenumberspace.c0000644000175000001440000003670210670453713020521 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "singlenumberspace.h" /* Function: lookup_ShadowSequence_SingleNumberSpace(space,pos) * * Descrip: New return using binary choping * * * Arg: space [UNKN ] Undocumented argument [SingleNumberSpace *] * Arg: pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SingleNumberSequence *] * */ # line 34 "singlenumberspace.dy" SingleNumberSequence * lookup_ShadowSequence_SingleNumberSpace(SingleNumberSpace * space,int pos) { int index_pos; assert(pos < space->current_end); if( space->is_static != 0 ) { /* can make explicit calculation for position */ index_pos = (int) (pos / space->average_len); if( space->sns[index_pos]->start == -1 ) { /* was a padding position */ for(index_pos--;index_pos >= 0 && space->sns[index_pos]->start == -1;index_pos--) { fprintf(stderr,"Regressed %d with %d [pos %d]\n",index_pos,space->sns[index_pos]->start,pos); } assert(index_pos >= 0 ); } if( space->sns[index_pos] == NULL ) { fatal("Going to return %d for %d with %d - max %d\n",index_pos,pos,space->average_len,space->current_end); } return space->sns[index_pos]; } assert(pos < space->current_end); index_pos = find_position_SingleNumberSpace(space,0,space->len-1,pos); return space->sns[index_pos]; } /* Function: find_position_SingleNumberSpace(space,lower,higher,position) * * Descrip: Recursive function for finding position * * * Arg: space [UNKN ] Undocumented argument [SingleNumberSpace *] * Arg: lower [UNKN ] Undocumented argument [int] * Arg: higher [UNKN ] Undocumented argument [int] * Arg: position [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ # line 72 "singlenumberspace.dy" int find_position_SingleNumberSpace(SingleNumberSpace * space,int lower,int higher,int position) { int mid; /* fprintf(stderr,"To find position %d Entering with.... %d to %d\n",position,lower,higher); */ if( lower+2 >= higher ) { if( position >= space->sns[lower]->start && position < space->sns[lower]->end ) return lower; if( position >= space->sns[higher]->start && position < space->sns[higher]->end ) return higher; } mid = (lower + (int)((higher-lower)/2)); if( position >= space->sns[mid]->start && position < space->sns[mid]->end ) return mid; if( position >= space->sns[mid]->end ) { /* top half */ return find_position_SingleNumberSpace(space,mid,higher,position); } else { return find_position_SingleNumberSpace(space,lower,mid,position); } } /* Function: add_ShadowSequence_SingleNumberSpace(space,seq) * * Descrip: Adds a sequence to a single number space, giving out the start * position for this sequence * * * Arg: space [UNKN ] Undocumented argument [SingleNumberSpace *] * Arg: seq [UNKN ] Undocumented argument [ShadowSequence *] * * Return [UNKN ] Undocumented return value [int] * */ # line 106 "singlenumberspace.dy" int add_ShadowSequence_SingleNumberSpace(SingleNumberSpace * space,ShadowSequence * seq) { int seq_size = 1; int i; SingleNumberSequence * a; SingleNumberSequence * dummy; assert(space); assert(seq); a = SingleNumberSequence_alloc(); a->start = space->current_end; if( space->is_static != 0 ) { if( seq->seq->len > space->max_length ) { seq_size = (seq->seq->len / space->max_length) +1; } else { seq_size = 1; } a->end = space->current_end + (space->max_length*seq_size); space->average_len = space->max_length; } else { a->end = space->current_end + seq->seq->len; space->average_len = a->end / space->len; } a->seq = seq; add_SingleNumberSpace(space,a); /* pad for long sequences */ if( seq_size > 1 ) { for(i=1;istart = -1; dummy->end = -1; dummy->seq = NULL; add_SingleNumberSpace(space,dummy); } } space->current_end = a->end; return a->start; } /* Function: new_SingleNumberSpace(has_maxlen,max_length) * * Descrip: Provides a new single number space * * * Arg: has_maxlen [UNKN ] Undocumented argument [int] * Arg: max_length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SingleNumberSpace *] * */ # line 161 "singlenumberspace.dy" SingleNumberSpace * new_SingleNumberSpace(int has_maxlen,int max_length) { SingleNumberSpace * out; out = SingleNumberSpace_alloc_std(); out->is_static = has_maxlen; out->max_length = max_length; return out; } # line 183 "singlenumberspace.c" /* Function: hard_link_SingleNumberSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SingleNumberSequence *] * * Return [UNKN ] Undocumented return value [SingleNumberSequence *] * */ SingleNumberSequence * hard_link_SingleNumberSequence(SingleNumberSequence * obj) { if( obj == NULL ) { warn("Trying to hard link to a SingleNumberSequence object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SingleNumberSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SingleNumberSequence *] * */ SingleNumberSequence * SingleNumberSequence_alloc(void) { SingleNumberSequence * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SingleNumberSequence *) ckalloc (sizeof(SingleNumberSequence))) == NULL) { warn("SingleNumberSequence_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->start = 0; out->end = 0; return out; } /* Function: free_SingleNumberSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SingleNumberSequence *] * * Return [UNKN ] Undocumented return value [SingleNumberSequence *] * */ SingleNumberSequence * free_SingleNumberSequence(SingleNumberSequence * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SingleNumberSequence obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->seq is linked in */ ckfree(obj); return NULL; } /* Function: swap_SingleNumberSpace(list,i,j) * * Descrip: swap function: an internal for qsort_SingleNumberSpace * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [SingleNumberSequence **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_SingleNumberSpace(SingleNumberSequence ** list,int i,int j) { SingleNumberSequence * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_SingleNumberSpace(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_SingleNumberSpace which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [SingleNumberSequence **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_SingleNumberSpace(SingleNumberSequence ** list,int left,int right,int (*comp)(SingleNumberSequence * ,SingleNumberSequence * )) { int i,last; if( left >= right ) return; swap_SingleNumberSpace(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_SingleNumberSpace (list,++last,i); } swap_SingleNumberSpace (list,left,last); qsort_SingleNumberSpace(list,left,last-1,comp); qsort_SingleNumberSpace(list,last+1,right,comp); } /* Function: sort_SingleNumberSpace(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_SingleNumberSpace * * * Arg: obj [UNKN ] Object containing list [SingleNumberSpace *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_SingleNumberSpace(SingleNumberSpace * obj,int (*comp)(SingleNumberSequence *, SingleNumberSequence *)) { qsort_SingleNumberSpace(obj->sns,0,obj->len-1,comp); return; } /* Function: expand_SingleNumberSpace(obj,len) * * Descrip: Really an internal function for add_SingleNumberSpace * * * Arg: obj [UNKN ] Object which contains the list [SingleNumberSpace *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_SingleNumberSpace(SingleNumberSpace * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_SingleNumberSpace called with no need"); return TRUE; } if( (obj->sns = (SingleNumberSequence ** ) ckrealloc (obj->sns,sizeof(SingleNumberSequence *)*len)) == NULL) { warn("ckrealloc failed for expand_SingleNumberSpace, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_SingleNumberSpace(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SingleNumberSpace *] * Arg: add [OWNER] Object to add to the list [SingleNumberSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_SingleNumberSpace(SingleNumberSpace * obj,SingleNumberSequence * add) { if( obj->len >= obj->maxlen) { if( expand_SingleNumberSpace(obj,obj->len + SingleNumberSpaceLISTLENGTH) == FALSE) return FALSE; } obj->sns[obj->len++]=add; return TRUE; } /* Function: flush_SingleNumberSpace(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SingleNumberSpace *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_SingleNumberSpace(SingleNumberSpace * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->sns[i] != NULL) { free_SingleNumberSequence(obj->sns[i]); obj->sns[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: SingleNumberSpace_alloc_std(void) * * Descrip: Equivalent to SingleNumberSpace_alloc_len(SingleNumberSpaceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SingleNumberSpace *] * */ SingleNumberSpace * SingleNumberSpace_alloc_std(void) { return SingleNumberSpace_alloc_len(SingleNumberSpaceLISTLENGTH); } /* Function: SingleNumberSpace_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SingleNumberSpace *] * */ SingleNumberSpace * SingleNumberSpace_alloc_len(int len) { SingleNumberSpace * out;/* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = SingleNumberSpace_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->sns = (SingleNumberSequence ** ) ckcalloc (len,sizeof(SingleNumberSequence *))) == NULL) { warn("Warning, ckcalloc failed in SingleNumberSpace_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_SingleNumberSpace(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SingleNumberSpace *] * * Return [UNKN ] Undocumented return value [SingleNumberSpace *] * */ SingleNumberSpace * hard_link_SingleNumberSpace(SingleNumberSpace * obj) { if( obj == NULL ) { warn("Trying to hard link to a SingleNumberSpace object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: SingleNumberSpace_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SingleNumberSpace *] * */ SingleNumberSpace * SingleNumberSpace_alloc(void) { SingleNumberSpace * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(SingleNumberSpace *) ckalloc (sizeof(SingleNumberSpace))) == NULL) { warn("SingleNumberSpace_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->current_end = 0; out->sns = NULL; out->len = out->maxlen = 0; out->average_len = 0; out->is_static = 0; out->max_length = 1000; return out; } /* Function: free_SingleNumberSpace(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SingleNumberSpace *] * * Return [UNKN ] Undocumented return value [SingleNumberSpace *] * */ SingleNumberSpace * free_SingleNumberSpace(SingleNumberSpace * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a SingleNumberSpace obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->sns != NULL) { for(i=0;ilen;i++) { if( obj->sns[i] != NULL) free_SingleNumberSequence(obj->sns[i]); } ckfree(obj->sns); } /* obj->last_accessed is linked in */ ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/singlenumberspace.h0000644000175000001440000002163510670453713020525 0ustar philippusers#ifndef DYNAMITEsinglenumberspaceHEADERFILE #define DYNAMITEsinglenumberspaceHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "shadowseq.h" #define SingleNumberSpaceLISTLENGTH 1024 struct Wise2_SingleNumberSequence { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int start; int end; ShadowSequence * seq; } ; /* SingleNumberSequence defined */ #ifndef DYNAMITE_DEFINED_SingleNumberSequence typedef struct Wise2_SingleNumberSequence Wise2_SingleNumberSequence; #define SingleNumberSequence Wise2_SingleNumberSequence #define DYNAMITE_DEFINED_SingleNumberSequence #endif struct Wise2_SingleNumberSpace { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int current_end; SingleNumberSequence ** sns; int len;/* len for above sns */ int maxlen; /* maxlen for above sns */ SingleNumberSequence * last_accessed; int average_len; int is_static; int max_length; } ; /* SingleNumberSpace defined */ #ifndef DYNAMITE_DEFINED_SingleNumberSpace typedef struct Wise2_SingleNumberSpace Wise2_SingleNumberSpace; #define SingleNumberSpace Wise2_SingleNumberSpace #define DYNAMITE_DEFINED_SingleNumberSpace #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: lookup_ShadowSequence_SingleNumberSpace(space,pos) * * Descrip: New return using binary choping * * * Arg: space [UNKN ] Undocumented argument [SingleNumberSpace *] * Arg: pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SingleNumberSequence *] * */ SingleNumberSequence * Wise2_lookup_ShadowSequence_SingleNumberSpace(SingleNumberSpace * space,int pos); #define lookup_ShadowSequence_SingleNumberSpace Wise2_lookup_ShadowSequence_SingleNumberSpace /* Function: find_position_SingleNumberSpace(space,lower,higher,position) * * Descrip: Recursive function for finding position * * * Arg: space [UNKN ] Undocumented argument [SingleNumberSpace *] * Arg: lower [UNKN ] Undocumented argument [int] * Arg: higher [UNKN ] Undocumented argument [int] * Arg: position [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_find_position_SingleNumberSpace(SingleNumberSpace * space,int lower,int higher,int position); #define find_position_SingleNumberSpace Wise2_find_position_SingleNumberSpace /* Function: add_ShadowSequence_SingleNumberSpace(space,seq) * * Descrip: Adds a sequence to a single number space, giving out the start * position for this sequence * * * Arg: space [UNKN ] Undocumented argument [SingleNumberSpace *] * Arg: seq [UNKN ] Undocumented argument [ShadowSequence *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_add_ShadowSequence_SingleNumberSpace(SingleNumberSpace * space,ShadowSequence * seq); #define add_ShadowSequence_SingleNumberSpace Wise2_add_ShadowSequence_SingleNumberSpace /* Function: new_SingleNumberSpace(has_maxlen,max_length) * * Descrip: Provides a new single number space * * * Arg: has_maxlen [UNKN ] Undocumented argument [int] * Arg: max_length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [SingleNumberSpace *] * */ SingleNumberSpace * Wise2_new_SingleNumberSpace(int has_maxlen,int max_length); #define new_SingleNumberSpace Wise2_new_SingleNumberSpace /* Function: hard_link_SingleNumberSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SingleNumberSequence *] * * Return [UNKN ] Undocumented return value [SingleNumberSequence *] * */ SingleNumberSequence * Wise2_hard_link_SingleNumberSequence(SingleNumberSequence * obj); #define hard_link_SingleNumberSequence Wise2_hard_link_SingleNumberSequence /* Function: SingleNumberSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SingleNumberSequence *] * */ SingleNumberSequence * Wise2_SingleNumberSequence_alloc(void); #define SingleNumberSequence_alloc Wise2_SingleNumberSequence_alloc /* Function: free_SingleNumberSequence(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SingleNumberSequence *] * * Return [UNKN ] Undocumented return value [SingleNumberSequence *] * */ SingleNumberSequence * Wise2_free_SingleNumberSequence(SingleNumberSequence * obj); #define free_SingleNumberSequence Wise2_free_SingleNumberSequence /* Function: add_SingleNumberSpace(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [SingleNumberSpace *] * Arg: add [OWNER] Object to add to the list [SingleNumberSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_SingleNumberSpace(SingleNumberSpace * obj,SingleNumberSequence * add); #define add_SingleNumberSpace Wise2_add_SingleNumberSpace /* Function: flush_SingleNumberSpace(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [SingleNumberSpace *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_SingleNumberSpace(SingleNumberSpace * obj); #define flush_SingleNumberSpace Wise2_flush_SingleNumberSpace /* Function: SingleNumberSpace_alloc_std(void) * * Descrip: Equivalent to SingleNumberSpace_alloc_len(SingleNumberSpaceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [SingleNumberSpace *] * */ SingleNumberSpace * Wise2_SingleNumberSpace_alloc_std(void); #define SingleNumberSpace_alloc_std Wise2_SingleNumberSpace_alloc_std /* Function: SingleNumberSpace_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [SingleNumberSpace *] * */ SingleNumberSpace * Wise2_SingleNumberSpace_alloc_len(int len); #define SingleNumberSpace_alloc_len Wise2_SingleNumberSpace_alloc_len /* Function: hard_link_SingleNumberSpace(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [SingleNumberSpace *] * * Return [UNKN ] Undocumented return value [SingleNumberSpace *] * */ SingleNumberSpace * Wise2_hard_link_SingleNumberSpace(SingleNumberSpace * obj); #define hard_link_SingleNumberSpace Wise2_hard_link_SingleNumberSpace /* Function: SingleNumberSpace_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [SingleNumberSpace *] * */ SingleNumberSpace * Wise2_SingleNumberSpace_alloc(void); #define SingleNumberSpace_alloc Wise2_SingleNumberSpace_alloc /* Function: free_SingleNumberSpace(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [SingleNumberSpace *] * * Return [UNKN ] Undocumented return value [SingleNumberSpace *] * */ SingleNumberSpace * Wise2_free_SingleNumberSpace(SingleNumberSpace * obj); #define free_SingleNumberSpace Wise2_free_SingleNumberSpace /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_SingleNumberSpace(SingleNumberSequence ** list,int i,int j) ; #define swap_SingleNumberSpace Wise2_swap_SingleNumberSpace void Wise2_qsort_SingleNumberSpace(SingleNumberSequence ** list,int left,int right,int (*comp)(SingleNumberSequence * ,SingleNumberSequence * )); #define qsort_SingleNumberSpace Wise2_qsort_SingleNumberSpace void Wise2_sort_SingleNumberSpace(SingleNumberSpace * obj,int (*comp)(SingleNumberSequence *, SingleNumberSequence *)); #define sort_SingleNumberSpace Wise2_sort_SingleNumberSpace boolean Wise2_expand_SingleNumberSpace(SingleNumberSpace * obj,int len); #define expand_SingleNumberSpace Wise2_expand_SingleNumberSpace #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/cdnadb.c0000644000175000001440000005423610670453712016227 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "cdnadb.h" /* Function: show_Hscore_cDNADB(hs,ofp) * * Descrip: shows the Hscore by the cDNADB information * * * * Arg: hs [UNKN ] High Score structure [Hscore *] * Arg: ofp [UNKN ] output file [FILE *] * */ # line 75 "cdnadb.dy" void show_Hscore_cDNADB(Hscore * hs,FILE * ofp) { int i; for(i=0;ilen;i++) fprintf(ofp,"Query [%20s] Target [%20s] %d\n",hs->ds[i]->query->name,hs->ds[i]->target->name,hs->ds[i]->score); } /* Function: get_cDNA_from_cDNADB(cdnadb,de) * * Descrip: Gets cDNA sequence out from * the cDNADB using the information stored in * dataentry * * * Arg: cdnadb [READ ] cDNA database [cDNADB *] * Arg: de [READ ] DataEntry information [DataEntry *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ # line 92 "cdnadb.dy" cDNA * get_cDNA_from_cDNADB(cDNADB * cdnadb,DataEntry * de) { Sequence * seq; Sequence * temp; if( cdnadb == NULL ) { warn("Cannot get entry from a null database"); return NULL; } if( de == NULL ) { warn("Cannot get entry with a null dataentry"); return NULL; } if( cdnadb->is_single_seq == TRUE ) { if( de->is_reversed == TRUE ) return cDNA_from_Sequence(hard_link_Sequence(cdnadb->rev->seq)); else return cDNA_from_Sequence(hard_link_Sequence(cdnadb->forw->seq)); } /* we need to get out the Sequence from seqdb */ seq = get_Sequence_from_SequenceDB(cdnadb->sdb,de); if( seq == NULL ) { warn("Cannot get entry for %s from cDNA db",de->name); return NULL; } if( seq->type != SEQUENCE_DNA) { warn("Sequence from %s data entry doesn't look like DNA. Forcing it to",de->name); } force_to_dna_Sequence(seq,1.0,NULL); if( de->is_reversed == TRUE ) { temp = reverse_complement_Sequence(seq); free_Sequence(seq); seq = temp; } return cDNA_from_Sequence(seq); } /* Function: dataentry_add_cDNADB(de,cs,cdnadb) * * Descrip: adds information to dataentry from cDNADB * * will eventually add file offset and format information, * but this is handled by the SequenceDB mainly. * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: cs [UNKN ] Undocumented argument [ComplexSequence *] * Arg: cdnadb [UNKN ] Undocumented argument [cDNADB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 146 "cdnadb.dy" boolean dataentry_add_cDNADB(DataEntry * de,ComplexSequence * cs,cDNADB * cdnadb) { if( cs == NULL || cs->seq == NULL ) { warn("Adding a dataentry with a NULL complex sequence or null internal sequence. Nope!"); return FALSE; } if( cdnadb->is_single_seq == FALSE) add_SequenceDB_info_DataEntry(cdnadb->sdb,de); de->name = stringalloc(cs->seq->name); de->is_reversed = is_reversed_Sequence(cs->seq); return TRUE; } /* Function: init_cDNADB(cdnadb,return_status) * * Descrip: top level function which opens the cDNA database * * * Arg: cdnadb [UNKN ] protein database [cDNADB *] * Arg: return_status [WRITE] the status of the open from database.h [int *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ # line 167 "cdnadb.dy" ComplexSequence * init_cDNADB(cDNADB * cdnadb,int * return_status) { ComplexSequence * cs; Sequence * seq; if( cdnadb->is_single_seq == TRUE) { *return_status = DB_RETURN_OK; cdnadb->done_forward = TRUE; return hard_link_ComplexSequence(cdnadb->forw); } /* is a seq db */ seq = init_SequenceDB(cdnadb->sdb,return_status); if( seq == NULL || *return_status == DB_RETURN_ERROR || *return_status == DB_RETURN_END ) { return NULL; /** error already reported **/ } if( force_to_dna_Sequence(seq,cdnadb->error_tol,NULL) == FALSE ) { warn("first sequence below error level, have to fail at the moment. Ooops..."); free_Sequence(seq); *return_status = DB_RETURN_ERROR; return NULL; } cdnadb->current = seq; cdnadb->done_forward = TRUE; cs = new_ComplexSequence(seq,cdnadb->cses); if( cs == NULL ) { warn("Cannot make initial ComplexSequence. Unable to error catch this. Failing!"); *return_status = DB_RETURN_ERROR; return NULL; } return cs; } /* Function: reload_cDNADB(last,cdnadb,return_status) * * Descrip: function which reloads the database * * * Arg: last [UNKN ] previous complex sequence, will be freed [ComplexSequence *] * Arg: cdnadb [UNKN ] Undocumented argument [cDNADB *] * Arg: return_status [WRITE] return_status of the load [int *] * * Return [OWNER] a new ComplexSequence object [ComplexSequence *] * */ # line 215 "cdnadb.dy" ComplexSequence * reload_cDNADB(ComplexSequence * last,cDNADB * cdnadb,int * return_status) { ComplexSequence * cs; Sequence * seq,*temp; /** free Complex Sequence **/ if ( last != NULL ) { free_ComplexSequence(last); } if( cdnadb->forward_only == TRUE) { temp = reload_SequenceDB(NULL,cdnadb->sdb,return_status); if ( *return_status != DB_RETURN_OK ) { return NULL; } cs = new_ComplexSequence(temp,cdnadb->cses); return cs; } if( cdnadb->is_single_seq == TRUE ) { if( cdnadb->done_forward == TRUE ) { *return_status = DB_RETURN_OK; cdnadb->done_forward = FALSE; return hard_link_ComplexSequence(cdnadb->rev); } else { *return_status = DB_RETURN_END; return NULL; } } /** standard database **/ if( cdnadb->done_forward == TRUE ) { if( cdnadb->current == NULL ) { warn("A bad internal cDNA db error - unable to find current sequence in db reload"); *return_status = DB_RETURN_ERROR; return NULL; } temp = reverse_complement_Sequence(cdnadb->current); if( temp == NULL ) { warn("A bad internal cDNA db error - unable to reverse complements current"); *return_status = DB_RETURN_ERROR; return NULL; } cs = new_ComplexSequence(temp,cdnadb->cses); if( cs == NULL ) { warn("A bad internal cDNA db error - unable to make complex sequence in db reload"); *return_status = DB_RETURN_ERROR; return NULL; } free_Sequence(temp); cdnadb->done_forward = FALSE; return cs; } /* otherwise we have to get a new sequence */ seq = reload_SequenceDB(NULL,cdnadb->sdb,return_status); if( seq == NULL || *return_status == DB_RETURN_ERROR || *return_status == DB_RETURN_END ) { return NULL; /** error already reported **/ } uppercase_Sequence(seq); if( force_to_dna_Sequence(seq,cdnadb->error_tol,NULL) == FALSE ) { if( cdnadb->error_handling == CDNADB_READ_THROUGH ) { warn("Unable to map %s sequence to a cDNA sequence, but ignoring that for the moment...",seq->name); free_Sequence(seq); return reload_cDNADB(NULL,cdnadb,return_status); } else { warn("Unable to map %s sequence to a cDNA sequence. Failing",seq->name); *return_status = DB_RETURN_ERROR; return NULL; } } cs = new_ComplexSequence(seq,cdnadb->cses); if( cs == NULL ) { if( cdnadb->error_handling == CDNADB_READ_THROUGH ) { warn("Unable to map %s sequence to a cDNA sequence, but ignoring that for the moment...",seq->name); free_Sequence(seq); return reload_cDNADB(NULL,cdnadb,return_status); } else { warn("Unable to map %s sequence to a cDNA sequence. Failing",seq->name); *return_status = DB_RETURN_ERROR; return NULL; } } cdnadb->current = free_Sequence(cdnadb->current); cdnadb->current = seq; cdnadb->done_forward= TRUE; return cs; } /* Function: close_cDNADB(cs,cdnadb) * * Descrip: top level function which closes the cDNA database * * * Arg: cs [UNKN ] last complex sequence [ComplexSequence *] * Arg: cdnadb [UNKN ] protein database [cDNADB *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 332 "cdnadb.dy" boolean close_cDNADB(ComplexSequence * cs,cDNADB * cdnadb) { if( cdnadb->is_single_seq == TRUE ) { return TRUE; } if( cs != NULL) free_ComplexSequence(cs); if( cdnadb->current != NULL) cdnadb->current = free_Sequence(cdnadb->current); return close_SequenceDB(NULL,cdnadb->sdb); } /* Function: new_cDNADB_from_single_seq(seq) * * Descrip: To make a new cDNA database * from a single cDNA Sequence with a eval system * * * Arg: seq [UNKN ] sequence which as placed into cDNADB structure. [cDNA *] * * Return [UNKN ] Undocumented return value [cDNADB *] * */ # line 353 "cdnadb.dy" cDNADB * new_cDNADB_from_single_seq(cDNA * seq) { ComplexSequence * cs,*cs_rev; Sequence * temp; ComplexSequenceEvalSet * cses; cses = default_cDNA_ComplexSequenceEvalSet(); cs = new_ComplexSequence(seq->baseseq,cses); temp = reverse_complement_Sequence(seq->baseseq); cs_rev = new_ComplexSequence(temp,cses); free_Sequence(temp); free_ComplexSequenceEvalSet(cses); return new_cDNADB_from_forrev_cseq(cs,cs_rev); } /* Function: new_cDNADB_from_forrev_cseq(cs,cs_rev) * * Descrip: To make a new cDNA database * from a single ComplexSequence * * * Arg: cs [OWNER] complex sequence which is held. [ComplexSequence *] * Arg: cs_rev [OWNER] complex sequence which is held. [ComplexSequence *] * * Return [UNKN ] Undocumented return value [cDNADB *] * */ # line 379 "cdnadb.dy" cDNADB * new_cDNADB_from_forrev_cseq(ComplexSequence * cs,ComplexSequence * cs_rev) { cDNADB * out; out = cDNADB_alloc(); out->is_single_seq = TRUE; out->forw = cs; out->rev = cs_rev; return out; } /* Function: new_cDNADB(seqdb) * * Descrip: To make a new cDNA database * * * Arg: seqdb [READ ] sequence database [SequenceDB *] * * Return [UNKN ] Undocumented return value [cDNADB *] * */ # line 399 "cdnadb.dy" cDNADB * new_cDNADB(SequenceDB * seqdb) { cDNADB * out; ComplexSequenceEvalSet * cses; if( seqdb == NULL ) { warn("No sequencedb - can't make a cDNADB!"); return NULL; } /** should check sequence database **/ cses = default_cDNA_ComplexSequenceEvalSet(); if( cses->type != SEQUENCE_CDNA ) { warn("You can't make a cDNA database with a non SEQUENCE_cDNA cses type [%d]",cses->type); return NULL; } out = cDNADB_alloc(); out->is_single_seq = FALSE; out->sdb = hard_link_SequenceDB(seqdb); out->cses = hard_link_ComplexSequenceEvalSet(cses); free_ComplexSequenceEvalSet(cses); return out; } # line 404 "cdnadb.c" /* Function: hard_link_cDNADB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [cDNADB *] * * Return [UNKN ] Undocumented return value [cDNADB *] * */ cDNADB * hard_link_cDNADB(cDNADB * obj) { if( obj == NULL ) { warn("Trying to hard link to a cDNADB object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: cDNADB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [cDNADB *] * */ cDNADB * cDNADB_alloc(void) { cDNADB * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(cDNADB *) ckalloc (sizeof(cDNADB))) == NULL) { warn("cDNADB_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->is_single_seq = FALSE; out->done_forward = FALSE; out->forward_only = FALSE; out->forw = NULL; out->rev = NULL; out->sdb = NULL; out->current = NULL; out->cses = NULL; out->error_handling = CDNADB_READ_THROUGH; out->error_tol = 0.7; return out; } /* Function: free_cDNADB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [cDNADB *] * * Return [UNKN ] Undocumented return value [cDNADB *] * */ cDNADB * free_cDNADB(cDNADB * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a cDNADB obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->forw != NULL) free_ComplexSequence(obj->forw); if( obj->rev != NULL) free_ComplexSequence(obj->rev); if( obj->sdb != NULL) free_SequenceDB(obj->sdb); if( obj->current != NULL) free_Sequence(obj->current); if( obj->cses != NULL) free_ComplexSequenceEvalSet(obj->cses); ckfree(obj); return NULL; } /* Function: replace_is_single_seq_cDNADB(obj,is_single_seq) * * Descrip: Replace member variable is_single_seq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * Arg: is_single_seq [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable is_single_seq [boolean] * */ boolean replace_is_single_seq_cDNADB(cDNADB * obj,boolean is_single_seq) { if( obj == NULL) { warn("In replacement function is_single_seq for object cDNADB, got a NULL object"); return FALSE; } obj->is_single_seq = is_single_seq; return TRUE; } /* Function: access_is_single_seq_cDNADB(obj) * * Descrip: Access member variable is_single_seq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * * Return [SOFT ] member variable is_single_seq [boolean] * */ boolean access_is_single_seq_cDNADB(cDNADB * obj) { if( obj == NULL) { warn("In accessor function is_single_seq for object cDNADB, got a NULL object"); return FALSE; } return obj->is_single_seq; } /* Function: replace_done_forward_cDNADB(obj,done_forward) * * Descrip: Replace member variable done_forward * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * Arg: done_forward [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable done_forward [boolean] * */ boolean replace_done_forward_cDNADB(cDNADB * obj,boolean done_forward) { if( obj == NULL) { warn("In replacement function done_forward for object cDNADB, got a NULL object"); return FALSE; } obj->done_forward = done_forward; return TRUE; } /* Function: access_done_forward_cDNADB(obj) * * Descrip: Access member variable done_forward * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * * Return [SOFT ] member variable done_forward [boolean] * */ boolean access_done_forward_cDNADB(cDNADB * obj) { if( obj == NULL) { warn("In accessor function done_forward for object cDNADB, got a NULL object"); return FALSE; } return obj->done_forward; } /* Function: replace_forward_only_cDNADB(obj,forward_only) * * Descrip: Replace member variable forward_only * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * Arg: forward_only [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable forward_only [boolean] * */ boolean replace_forward_only_cDNADB(cDNADB * obj,boolean forward_only) { if( obj == NULL) { warn("In replacement function forward_only for object cDNADB, got a NULL object"); return FALSE; } obj->forward_only = forward_only; return TRUE; } /* Function: access_forward_only_cDNADB(obj) * * Descrip: Access member variable forward_only * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * * Return [SOFT ] member variable forward_only [boolean] * */ boolean access_forward_only_cDNADB(cDNADB * obj) { if( obj == NULL) { warn("In accessor function forward_only for object cDNADB, got a NULL object"); return FALSE; } return obj->forward_only; } /* Function: replace_forw_cDNADB(obj,forw) * * Descrip: Replace member variable forw * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * Arg: forw [OWNER] New value of the variable [ComplexSequence *] * * Return [SOFT ] member variable forw [boolean] * */ boolean replace_forw_cDNADB(cDNADB * obj,ComplexSequence * forw) { if( obj == NULL) { warn("In replacement function forw for object cDNADB, got a NULL object"); return FALSE; } obj->forw = forw; return TRUE; } /* Function: access_forw_cDNADB(obj) * * Descrip: Access member variable forw * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * * Return [SOFT ] member variable forw [ComplexSequence *] * */ ComplexSequence * access_forw_cDNADB(cDNADB * obj) { if( obj == NULL) { warn("In accessor function forw for object cDNADB, got a NULL object"); return NULL; } return obj->forw; } /* Function: replace_rev_cDNADB(obj,rev) * * Descrip: Replace member variable rev * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * Arg: rev [OWNER] New value of the variable [ComplexSequence *] * * Return [SOFT ] member variable rev [boolean] * */ boolean replace_rev_cDNADB(cDNADB * obj,ComplexSequence * rev) { if( obj == NULL) { warn("In replacement function rev for object cDNADB, got a NULL object"); return FALSE; } obj->rev = rev; return TRUE; } /* Function: access_rev_cDNADB(obj) * * Descrip: Access member variable rev * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * * Return [SOFT ] member variable rev [ComplexSequence *] * */ ComplexSequence * access_rev_cDNADB(cDNADB * obj) { if( obj == NULL) { warn("In accessor function rev for object cDNADB, got a NULL object"); return NULL; } return obj->rev; } /* Function: replace_sdb_cDNADB(obj,sdb) * * Descrip: Replace member variable sdb * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * Arg: sdb [OWNER] New value of the variable [SequenceDB *] * * Return [SOFT ] member variable sdb [boolean] * */ boolean replace_sdb_cDNADB(cDNADB * obj,SequenceDB * sdb) { if( obj == NULL) { warn("In replacement function sdb for object cDNADB, got a NULL object"); return FALSE; } obj->sdb = sdb; return TRUE; } /* Function: access_sdb_cDNADB(obj) * * Descrip: Access member variable sdb * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * * Return [SOFT ] member variable sdb [SequenceDB *] * */ SequenceDB * access_sdb_cDNADB(cDNADB * obj) { if( obj == NULL) { warn("In accessor function sdb for object cDNADB, got a NULL object"); return NULL; } return obj->sdb; } /* Function: replace_current_cDNADB(obj,current) * * Descrip: Replace member variable current * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * Arg: current [OWNER] New value of the variable [Sequence *] * * Return [SOFT ] member variable current [boolean] * */ boolean replace_current_cDNADB(cDNADB * obj,Sequence * current) { if( obj == NULL) { warn("In replacement function current for object cDNADB, got a NULL object"); return FALSE; } obj->current = current; return TRUE; } /* Function: access_current_cDNADB(obj) * * Descrip: Access member variable current * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * * Return [SOFT ] member variable current [Sequence *] * */ Sequence * access_current_cDNADB(cDNADB * obj) { if( obj == NULL) { warn("In accessor function current for object cDNADB, got a NULL object"); return NULL; } return obj->current; } /* Function: replace_cses_cDNADB(obj,cses) * * Descrip: Replace member variable cses * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * Arg: cses [OWNER] New value of the variable [ComplexSequenceEvalSet *] * * Return [SOFT ] member variable cses [boolean] * */ boolean replace_cses_cDNADB(cDNADB * obj,ComplexSequenceEvalSet * cses) { if( obj == NULL) { warn("In replacement function cses for object cDNADB, got a NULL object"); return FALSE; } obj->cses = cses; return TRUE; } /* Function: access_cses_cDNADB(obj) * * Descrip: Access member variable cses * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [cDNADB *] * * Return [SOFT ] member variable cses [ComplexSequenceEvalSet *] * */ ComplexSequenceEvalSet * access_cses_cDNADB(cDNADB * obj) { if( obj == NULL) { warn("In accessor function cses for object cDNADB, got a NULL object"); return NULL; } return obj->cses; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/cdnadb.h0000644000175000001440000002172110670453712016225 0ustar philippusers#ifndef DYNAMITEcdnadbHEADERFILE #define DYNAMITEcdnadbHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequencedb.h" #include "cdna.h" #include "hscore.h" #include "complexsequence.h" #include "complexevalset.h" typedef enum CdnaDBErrorType { CDNADB_READ_THROUGH = 0, CDNADB_FAIL_ON_ERROR = 1 } CdnaDBErrorType; /* Object cDNADB * * Descrip: This object hold a database of * cDNA sequences. * * You will probably use it in one of * two ways * * 1 A sequence formatted database, which * is provided by a /SequenceDB object * is used to provide the raw sequences * * 2 A single cDNA sequence is used. * * In each case this database provides * both the forward and reverse strands * into the system. * * Notice that what is exported are * /ComplexSequence objects, not cDNA dna, * as this is what is generally needed. * These are things with splice sites calculated * etc. This is why for initialisation this needs * a /ComplexSequenceEvalSet of the correct type. * * */ struct Wise2_cDNADB { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif boolean is_single_seq; boolean done_forward; boolean forward_only; ComplexSequence * forw; ComplexSequence * rev; SequenceDB * sdb; Sequence * current; ComplexSequenceEvalSet * cses; CdnaDBErrorType error_handling; double error_tol; } ; /* cDNADB defined */ #ifndef DYNAMITE_DEFINED_cDNADB typedef struct Wise2_cDNADB Wise2_cDNADB; #define cDNADB Wise2_cDNADB #define DYNAMITE_DEFINED_cDNADB #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: show_Hscore_cDNADB(hs,ofp) * * Descrip: shows the Hscore by the cDNADB information * * * * Arg: hs [UNKN ] High Score structure [Hscore *] * Arg: ofp [UNKN ] output file [FILE *] * */ void Wise2_show_Hscore_cDNADB(Hscore * hs,FILE * ofp); #define show_Hscore_cDNADB Wise2_show_Hscore_cDNADB /* Function: get_cDNA_from_cDNADB(cdnadb,de) * * Descrip: Gets cDNA sequence out from * the cDNADB using the information stored in * dataentry * * * Arg: cdnadb [READ ] cDNA database [cDNADB *] * Arg: de [READ ] DataEntry information [DataEntry *] * * Return [UNKN ] Undocumented return value [cDNA *] * */ cDNA * Wise2_get_cDNA_from_cDNADB(cDNADB * cdnadb,DataEntry * de); #define get_cDNA_from_cDNADB Wise2_get_cDNA_from_cDNADB /* Function: dataentry_add_cDNADB(de,cs,cdnadb) * * Descrip: adds information to dataentry from cDNADB * * will eventually add file offset and format information, * but this is handled by the SequenceDB mainly. * * * Arg: de [UNKN ] Undocumented argument [DataEntry *] * Arg: cs [UNKN ] Undocumented argument [ComplexSequence *] * Arg: cdnadb [UNKN ] Undocumented argument [cDNADB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_dataentry_add_cDNADB(DataEntry * de,ComplexSequence * cs,cDNADB * cdnadb); #define dataentry_add_cDNADB Wise2_dataentry_add_cDNADB /* Function: init_cDNADB(cdnadb,return_status) * * Descrip: top level function which opens the cDNA database * * * Arg: cdnadb [UNKN ] protein database [cDNADB *] * Arg: return_status [WRITE] the status of the open from database.h [int *] * * Return [UNKN ] Undocumented return value [ComplexSequence *] * */ ComplexSequence * Wise2_init_cDNADB(cDNADB * cdnadb,int * return_status); #define init_cDNADB Wise2_init_cDNADB /* Function: reload_cDNADB(last,cdnadb,return_status) * * Descrip: function which reloads the database * * * Arg: last [UNKN ] previous complex sequence, will be freed [ComplexSequence *] * Arg: cdnadb [UNKN ] Undocumented argument [cDNADB *] * Arg: return_status [WRITE] return_status of the load [int *] * * Return [OWNER] a new ComplexSequence object [ComplexSequence *] * */ ComplexSequence * Wise2_reload_cDNADB(ComplexSequence * last,cDNADB * cdnadb,int * return_status); #define reload_cDNADB Wise2_reload_cDNADB /* Function: close_cDNADB(cs,cdnadb) * * Descrip: top level function which closes the cDNA database * * * Arg: cs [UNKN ] last complex sequence [ComplexSequence *] * Arg: cdnadb [UNKN ] protein database [cDNADB *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_close_cDNADB(ComplexSequence * cs,cDNADB * cdnadb) ; #define close_cDNADB Wise2_close_cDNADB /* Function: new_cDNADB_from_single_seq(seq) * * Descrip: To make a new cDNA database * from a single cDNA Sequence with a eval system * * * Arg: seq [UNKN ] sequence which as placed into cDNADB structure. [cDNA *] * * Return [UNKN ] Undocumented return value [cDNADB *] * */ cDNADB * Wise2_new_cDNADB_from_single_seq(cDNA * seq); #define new_cDNADB_from_single_seq Wise2_new_cDNADB_from_single_seq /* Function: new_cDNADB(seqdb) * * Descrip: To make a new cDNA database * * * Arg: seqdb [READ ] sequence database [SequenceDB *] * * Return [UNKN ] Undocumented return value [cDNADB *] * */ cDNADB * Wise2_new_cDNADB(SequenceDB * seqdb); #define new_cDNADB Wise2_new_cDNADB /* Function: hard_link_cDNADB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [cDNADB *] * * Return [UNKN ] Undocumented return value [cDNADB *] * */ cDNADB * Wise2_hard_link_cDNADB(cDNADB * obj); #define hard_link_cDNADB Wise2_hard_link_cDNADB /* Function: cDNADB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [cDNADB *] * */ cDNADB * Wise2_cDNADB_alloc(void); #define cDNADB_alloc Wise2_cDNADB_alloc /* Function: free_cDNADB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [cDNADB *] * * Return [UNKN ] Undocumented return value [cDNADB *] * */ cDNADB * Wise2_free_cDNADB(cDNADB * obj); #define free_cDNADB Wise2_free_cDNADB /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_access_is_single_seq_cDNADB(cDNADB * obj); #define access_is_single_seq_cDNADB Wise2_access_is_single_seq_cDNADB ComplexSequence * Wise2_access_forw_cDNADB(cDNADB * obj); #define access_forw_cDNADB Wise2_access_forw_cDNADB boolean Wise2_replace_rev_cDNADB(cDNADB * obj,ComplexSequence * rev); #define replace_rev_cDNADB Wise2_replace_rev_cDNADB boolean Wise2_replace_done_forward_cDNADB(cDNADB * obj,boolean done_forward); #define replace_done_forward_cDNADB Wise2_replace_done_forward_cDNADB ComplexSequenceEvalSet * Wise2_access_cses_cDNADB(cDNADB * obj); #define access_cses_cDNADB Wise2_access_cses_cDNADB ComplexSequence * Wise2_access_rev_cDNADB(cDNADB * obj); #define access_rev_cDNADB Wise2_access_rev_cDNADB boolean Wise2_replace_forward_only_cDNADB(cDNADB * obj,boolean forward_only); #define replace_forward_only_cDNADB Wise2_replace_forward_only_cDNADB boolean Wise2_replace_sdb_cDNADB(cDNADB * obj,SequenceDB * sdb); #define replace_sdb_cDNADB Wise2_replace_sdb_cDNADB boolean Wise2_replace_forw_cDNADB(cDNADB * obj,ComplexSequence * forw); #define replace_forw_cDNADB Wise2_replace_forw_cDNADB SequenceDB * Wise2_access_sdb_cDNADB(cDNADB * obj); #define access_sdb_cDNADB Wise2_access_sdb_cDNADB boolean Wise2_access_done_forward_cDNADB(cDNADB * obj); #define access_done_forward_cDNADB Wise2_access_done_forward_cDNADB boolean Wise2_replace_current_cDNADB(cDNADB * obj,Sequence * current); #define replace_current_cDNADB Wise2_replace_current_cDNADB boolean Wise2_replace_is_single_seq_cDNADB(cDNADB * obj,boolean is_single_seq); #define replace_is_single_seq_cDNADB Wise2_replace_is_single_seq_cDNADB Sequence * Wise2_access_current_cDNADB(cDNADB * obj); #define access_current_cDNADB Wise2_access_current_cDNADB boolean Wise2_access_forward_only_cDNADB(cDNADB * obj); #define access_forward_only_cDNADB Wise2_access_forward_only_cDNADB boolean Wise2_replace_cses_cDNADB(cDNADB * obj,ComplexSequenceEvalSet * cses); #define replace_cses_cDNADB Wise2_replace_cses_cDNADB cDNADB * Wise2_new_cDNADB_from_forrev_cseq(ComplexSequence * cs,ComplexSequence * cs_rev); #define new_cDNADB_from_forrev_cseq Wise2_new_cDNADB_from_forrev_cseq #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/hsptwohitscan.c0000644000175000001440000007112410670453712017705 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "hsptwohitscan.h" #include #include /* Function: new_twohit_one_off_HSPScanInterface(sli,mat,drop_off,score_cutoff) * * Descrip: Builds a twohit scan interface. This * does expands the query using a matrix but * just be considering off by one cases * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ # line 61 "hsptwohitscan.dy" HSPScanInterface * new_twohit_one_off_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff) { HSPScanInterface * out; HSPScanPara * p; assert(sli); assert(mat); out = HSPScanInterface_alloc(); p = HSPScanPara_alloc(); p->sli = hard_link_SeqLookupInterface(sli); p->mat = hard_link_CompMat(mat); p->drop_off = drop_off; p->score_cutoff = score_cutoff; out->data = (void*)p; out->free_data = simple_HSPScan_free; if( sli->lookup_array_head == NULL ) { fatal("Currently can only use direct lookup in twohit scans"); } else { out->scan_query = twohit_one_off_HSPscan_scan_query_direct; } return out; } /* Function: twohit_one_off_HSPscan_scan_query_direct(data,seq,para) * * Descrip: Word expansion with two hit semantics * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ # line 93 "hsptwohitscan.dy" LinearHSPmanager * twohit_one_off_HSPscan_scan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para) { char * std_aa = "ACDEFGHIKLMNPQRSTVWY"; HSPmanager * hspm; LinearHSPmanager * out; LineariseHSPPara * hsp_para; HSPScanPara * p = (HSPScanPara *)data; int i; int j; int k; int aa; int score; char newseq[5]; TwoHitBuffer * thb; TwoHitStore * s; int jj; int aa2; int has_seen; int seqno[5]; int base[5]; int start_base; int self_score[5]; int total_score; int current_score; ArraySeqHead * head; int no; #ifdef LINUX_TIMER struct timeval t1; struct timeval t2; struct timeval t3; #endif assert(seq); assert(p); assert(para); assert(para->max_results > 0); if( VERBOSITY_CHECK(1,para->verbosity) ) { info("processing sequence %s with twohit implementation",seq->name); } hsp_para = LineariseHSPPara_alloc(); hsp_para->verbosity = para->verbosity; hsp_para->max_size = para->max_results; hsp_para->min_score = para->min_hsp_score; hsp_para->width = para->hsp_link_width; hsp_para->tail = para->hsp_link_length; for(i=0,start_base=1;i<5;i++) { base[i] = start_base; start_base = start_base * 26; } hspm = new_HSPmanager(seq,p->mat,p->drop_off); thb = new_TwoHitBuffer(); #ifdef LINUX_TIMER gettimeofday(&t1,NULL); #endif /* * normal scan for 0 and 1 off. On identical and one off, simply put * things into the TwoHitBuffer and set the hit_state to TWOHIT_HANDLED - indicating * that this hit has already been delt with. * * For the two off cases - where most of the random cases will come * in, put in the TwoHitBuffer and only process the HSPs when you come * come back with a hit_state of TWOHIT_FIRST_ENTRY. This calling code * will then change this to TWOHIT_FIRST_STORED. If the hit_state is * TWOHIT_FIRST_STORED it will then process both the current hit and * the stored hit, and set the state to TWOHIT_HANDLED. If it is * in TWOHIT_HANDLED, it handles just the current hit. * * The end result of all of this is that a sequence will need two * two-off (or better) words to trigger HSP extension, which hopefully will * drastically cut down on random HSP extensions. * */ for(i=0;ilen-5;i++) { head = (*p->sli->lookup_array_head)(p->sli->data,seq_number_aa_5mer_client(seq->seq+i)); if( head != NULL ) { if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { if( VERBOSITY_CHECK(7,para->verbosity) ) { info("position %d hit direct over filled position, %d vs hard %d, low %d",i,head->current_pos,para->numb_level,para->low_numb); } continue; } for(k=0;kcurrent_pos;k++) { s = add_to_TwoHitBuffer(thb,head->units[k].seq,i,head->units[k].pos); s->hit_state = TWOHIT_HANDLED; if( add_pair_HSPmanager_score(hspm,head->units[k].seq,i,head->units[k].pos,para->min_hsp_score) == TRUE ) { ; } } } total_score = 0; for(score=0,j=0;j<5;j++) { seqno[j] = base[j]*(toupper(seq->seq[i+j])-'A'); self_score[j] = p->mat->comp[toupper(seq->seq[i+j])-'A'][toupper(seq->seq[i+j])-'A']; total_score += self_score[j]; } has_seen = 0; for(j=0;j<5;j++) { for(jj=1;jj<5;jj+=2) { for(aa=0;aa<20;aa++) { for(aa2=0;aa2<20;aa2++) { if( seq->seq[i+j] == std_aa[aa] ) { continue; } current_score = total_score; current_score -= (self_score[j] - p->mat->comp[toupper(seq->seq[i+j])-'A'][std_aa[aa]-'A']); current_score -= (self_score[jj] - p->mat->comp[toupper(seq->seq[i+jj])-'A'][std_aa[aa2]-'A']); if( current_score < para->min_word_score ) { continue; } else { /* fprintf(stderr,"Handling %d,%d amino acid %d,%d score %d\n",j,jj,aa,aa2,current_score); */ } seqno[j] = base[j]*(std_aa[aa]-'A'); seqno[jj] = base[jj]*(std_aa[aa2]-'A'); no= seqno[0]+seqno[1]+seqno[2]+seqno[3]+seqno[4]; head = (*p->sli->lookup_array_head)(p->sli->data,no); if( head != NULL ) { if( para->numb_level < head->current_pos || (ARRAYHEAD_IS_LOWCOMPLEXITY(head) && para->low_numb > 0 && para->low_numb <= head->current_pos) ) { if( VERBOSITY_CHECK(7,para->verbosity) ) { info("position %d hit direct over filled position, %d vs hard %d, low %d",i,head->current_pos,para->numb_level,para->low_numb); } continue; } has_seen = 1; for(k=0;kcurrent_pos;k++) { s = add_to_TwoHitBuffer(thb,head->units[k].seq,i,head->units[k].pos); /* if this is the first time we've used, this just store it */ if( s->hit_state == TWOHIT_FIRST_ENTRY ) { /* fprintf(stderr,"%d,%d %s, %d,%d added as first entry\n",j,aa,head->units[k].seq->name,i,head->units[k].pos); */ s->hit_state = TWOHIT_FIRST_STORED; continue; } /* if we get this back with TWOHIT_FIRST_STORED, * process the stored hit and then process the current * afterwards */ if( s->hit_state == TWOHIT_FIRST_STORED ) { /* fprintf(stderr,"%d,%d sequence %s, second hit, %d,%d vs %d,%d\n",j,aa,s->target->name,s->query_pos,s->target_pos,i,head->units[k].pos); */ s->hit_state = TWOHIT_HANDLED; /* stored hit */ add_pair_HSPmanager_score(hspm,s->target,s->query_pos,s->target_pos,para->min_hsp_score); } /* current hit - either stored or handled */ add_pair_HSPmanager(hspm,head->units[k].seq,i,head->units[k].pos) ; } } seqno[j] = base[j]*(toupper(seq->seq[i+j]-'A')); seqno[jj] = base[jj]*(toupper(seq->seq[i+jj]-'A')); newseq[j] = seq->seq[i+j]; newseq[jj] = seq->seq[i+jj]; } } } } } if( VERBOSITY_CHECK(4,para->verbosity) ) { for(i=0,jj=0,k=0;ilen;i++) { for(j=0;jbuffer[i]->len;j++ ) { if( thb->buffer[i]->word[j]->hit_state == TWOHIT_HANDLED ) { jj++; } k++; } } info("Two hit status: %d sequences, %d words %d handled",thb->len,k,jj); } #ifdef LINUX_TIMER if( VERBOSITY_CHECK(3,para->verbosity) ) { gettimeofday(&t2,NULL); } #endif if( para->use_protein_heuristic == TRUE ) { out = new_LinearHSPmanager_simple_heuristic(hspm,hsp_para); } else { out = new_LinearHSPmanager_flat(hspm); } #ifdef LINUX_TIMER if( VERBOSITY_CHECK(3,para->verbosity) ) { gettimeofday(&t3,NULL); info("Sort clock point: Scan %f : Sort %f", t2.tv_sec - t1.tv_sec + ((t2.tv_usec - t1.tv_usec) * 1e-6), t3.tv_sec - t2.tv_sec + ((t2.tv_usec - t2.tv_usec) * 1e-6) ); } #endif free_HSPmanager(hspm); return out; } /* Function: add_to_TwoHitBuffer(thb,target,query_pos,target_pos) * * Descrip: adds a new potential hit to the TwoHitBuffer, * returning the HitStore datastructure updated * if hit is 1 then this is first entry * if hit is more than 1 second * * * Arg: thb [UNKN ] Undocumented argument [TwoHitBuffer *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [TwoHitStore *] * */ # line 347 "hsptwohitscan.dy" TwoHitStore * add_to_TwoHitBuffer(TwoHitBuffer * thb,Sequence * target,int query_pos,int target_pos) { TwoHitSequence * seq; TwoHitStore * s; int diag; int i; int j; diag = query_pos - target_pos; if( (seq = g_hash_table_lookup(thb->target_hash,(gpointer)target)) != NULL ) { /* unrolling the first 2 positions */ if( seq->len ==2 || seq->len == 1) { if( seq->word[0]->diagonal == diag ) { return seq->word[0]; } } if( seq->len == 2 ) { if( seq->word[1]->diagonal == diag ) { return seq->word[1]; } } /* use the hash to test the other positions */ if( seq->len > 2 && (s = g_hash_table_lookup(seq->diagonal_hash,&diag)) != NULL ) { return s; } /* no position on this diagonal - make a new store */ s = new_TwoHitStore_from_Allocator(thb->thba); s->target = target; s->hit_state = TWOHIT_FIRST_ENTRY; s->target_pos = target_pos; s->query_pos = query_pos; s->diagonal = diag; add_TwoHitSequence(seq,s); g_hash_table_insert(seq->diagonal_hash,&(s->diagonal),s); return s; } /* else make a new seq and a new store, add it, pointer the hash to it */ seq = new_TwoHitSequence(); add_TwoHitBuffer(thb,seq); g_hash_table_insert(thb->target_hash,(gpointer)target,seq); s = new_TwoHitStore_from_Allocator(thb->thba); s->target = target; s->hit_state = TWOHIT_FIRST_ENTRY; s->target_pos = target_pos; s->query_pos = query_pos; s->diagonal = query_pos - target_pos; add_TwoHitSequence(seq,s); g_hash_table_insert(seq->diagonal_hash,&(s->diagonal),s); return s; } /* Function: new_TwoHitBuffer(void) * * Descrip: makes a new TwoHitBuffer ready for use * * * * Return [UNKN ] Undocumented return value [TwoHitBuffer *] * */ # line 420 "hsptwohitscan.dy" TwoHitBuffer * new_TwoHitBuffer(void) { TwoHitBuffer * b; b = TwoHitBuffer_alloc_std(); b->target_hash = g_hash_table_new(g_direct_hash,g_direct_equal); b->thba = new_TwoHitStoreBlockAllocator(); return b; } /* Function: new_TwoHitSequence(void) * * Descrip: make a new TwoHitSequence ready for use * * * * Return [UNKN ] Undocumented return value [TwoHitSequence *] * */ # line 434 "hsptwohitscan.dy" TwoHitSequence * new_TwoHitSequence(void) { TwoHitSequence * seq; seq = TwoHitSequence_alloc_std(); seq->diagonal_hash = g_hash_table_new(g_int_hash,g_int_equal); return seq; } /* Function: free_TwoHitSequence(t) * * Descrip: Frees the TwoHitSequence * * * Arg: t [UNKN ] Undocumented argument [TwoHitSequence *] * * Return [UNKN ] Undocumented return value [TwoHitSequence *] * */ # line 449 "hsptwohitscan.dy" TwoHitSequence * free_TwoHitSequence(TwoHitSequence * t) { g_hash_table_destroy(t->diagonal_hash); /* block allocator handles store memory */ ckfree(t->word); ckfree(t); return NULL; } /* Function: free_TwoHitBuffer(t) * * Descrip: Frees the TwoHitBuffer * * * Arg: t [UNKN ] Undocumented argument [TwoHitBuffer *] * * Return [UNKN ] Undocumented return value [TwoHitBuffer *] * */ # line 470 "hsptwohitscan.dy" TwoHitBuffer * free_TwoHitBuffer(TwoHitBuffer * t) { int i; g_hash_table_destroy(t->target_hash); for(i=0;ilen;i++) { free_TwoHitSequence(t->buffer[i]); } ckfree(t->buffer); ckfree(t); return NULL; } /* Function: TwoHitStore_alloc(void) * * Descrip: allocator for twohitstore * * * * Return [UNKN ] Undocumented return value [TwoHitStore *] * */ # line 489 "hsptwohitscan.dy" TwoHitStore * TwoHitStore_alloc(void) { TwoHitStore * out; out = (TwoHitStore *)malloc(sizeof(TwoHitStore)); return out; } /* Function: free_TwoHitStore(t) * * Descrip: free for twohitstore * * * Arg: t [UNKN ] Undocumented argument [TwoHitStore *] * * Return [UNKN ] Undocumented return value [TwoHitStore *] * */ # line 501 "hsptwohitscan.dy" TwoHitStore * free_TwoHitStore(TwoHitStore * t) { if( t == NULL ) { return NULL; } free(t); return NULL; } /* Function: new_TwoHitStore_from_Allocator(a) * * Descrip: gets a new store from a block allocator * * * Arg: a [UNKN ] Undocumented argument [TwoHitStoreBlockAllocator *] * * Return [UNKN ] Undocumented return value [TwoHitStore *] * */ # line 513 "hsptwohitscan.dy" TwoHitStore * new_TwoHitStore_from_Allocator(TwoHitStoreBlockAllocator * a) { /* do short path first! */ if( a->current_pos < TWOHIT_BLOCK_SIZE ) { return &(a->block[a->current_block][a->current_pos++]); } /* else, we need a new block */ if( a->current_block >= a->block_len ) { /* we need to realloc the block ! */ a->block = realloc(a->block,sizeof(TwoHitStore *)*(2*a->block_len)); assert(a->block != NULL); a->block_len = (2*a->block_len); } a->current_block++; a->block[a->current_block] = calloc(TWOHIT_BLOCK_SIZE,sizeof(TwoHitStore)); assert(a->block[a->current_block] != NULL); a->current_pos = 0; return &(a->block[a->current_block][a->current_pos++]); } /* Function: free_TwoHitStoreBlockAllocator(a) * * Descrip: frees a block allocator * * * Arg: a [UNKN ] Undocumented argument [TwoHitStoreBlockAllocator *] * * Return [UNKN ] Undocumented return value [TwoHitStoreBlockAllocator *] * */ # line 543 "hsptwohitscan.dy" TwoHitStoreBlockAllocator * free_TwoHitStoreBlockAllocator(TwoHitStoreBlockAllocator * a) { int i; assert(a != NULL); for(i=0;icurrent_block;i++) { free(a->block[i]); } free(a->block); free(a); return NULL; } /* Function: new_TwoHitStoreBlockAllocator(void) * * Descrip: makes a new block allocator * * * * Return [UNKN ] Undocumented return value [TwoHitStoreBlockAllocator *] * */ # line 564 "hsptwohitscan.dy" TwoHitStoreBlockAllocator * new_TwoHitStoreBlockAllocator(void) { TwoHitStoreBlockAllocator * out; out = (TwoHitStoreBlockAllocator*) malloc(sizeof(TwoHitStoreBlockAllocator)); assert(out != NULL); out->block = (TwoHitStore **) calloc(TWOHIT_BLOCK_DEPTH,sizeof(TwoHitStore*)); out->block_len = TWOHIT_BLOCK_DEPTH; out->block[0] = (TwoHitStore*) calloc(TWOHIT_BLOCK_SIZE,sizeof(TwoHitStore)); out->current_block = 0; out->current_pos = 0; return out; } # line 611 "hsptwohitscan.c" /* Function: swap_TwoHitSequence(list,i,j) * * Descrip: swap function: an internal for qsort_TwoHitSequence * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [TwoHitStore **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_TwoHitSequence(TwoHitStore ** list,int i,int j) { TwoHitStore * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_TwoHitSequence(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_TwoHitSequence which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [TwoHitStore **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_TwoHitSequence(TwoHitStore ** list,int left,int right,int (*comp)(TwoHitStore * ,TwoHitStore * )) { int i,last; if( left >= right ) return; swap_TwoHitSequence(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_TwoHitSequence (list,++last,i); } swap_TwoHitSequence (list,left,last); qsort_TwoHitSequence(list,left,last-1,comp); qsort_TwoHitSequence(list,last+1,right,comp); } /* Function: sort_TwoHitSequence(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_TwoHitSequence * * * Arg: obj [UNKN ] Object containing list [TwoHitSequence *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_TwoHitSequence(TwoHitSequence * obj,int (*comp)(TwoHitStore *, TwoHitStore *)) { qsort_TwoHitSequence(obj->word,0,obj->len-1,comp); return; } /* Function: expand_TwoHitSequence(obj,len) * * Descrip: Really an internal function for add_TwoHitSequence * * * Arg: obj [UNKN ] Object which contains the list [TwoHitSequence *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_TwoHitSequence(TwoHitSequence * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_TwoHitSequence called with no need"); return TRUE; } if( (obj->word = (TwoHitStore ** ) ckrealloc (obj->word,sizeof(TwoHitStore *)*len)) == NULL) { warn("ckrealloc failed for expand_TwoHitSequence, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_TwoHitSequence(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TwoHitSequence *] * Arg: add [OWNER] Object to add to the list [TwoHitStore *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_TwoHitSequence(TwoHitSequence * obj,TwoHitStore * add) { if( obj->len >= obj->maxlen) { if( expand_TwoHitSequence(obj,obj->len + TwoHitSequenceLISTLENGTH) == FALSE) return FALSE; } obj->word[obj->len++]=add; return TRUE; } /* Function: flush_TwoHitSequence(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TwoHitSequence *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_TwoHitSequence(TwoHitSequence * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->word[i] != NULL) { free_TwoHitStore(obj->word[i]); obj->word[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: TwoHitSequence_alloc_std(void) * * Descrip: Equivalent to TwoHitSequence_alloc_len(TwoHitSequenceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TwoHitSequence *] * */ TwoHitSequence * TwoHitSequence_alloc_std(void) { return TwoHitSequence_alloc_len(TwoHitSequenceLISTLENGTH); } /* Function: TwoHitSequence_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TwoHitSequence *] * */ TwoHitSequence * TwoHitSequence_alloc_len(int len) { TwoHitSequence * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = TwoHitSequence_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->word = (TwoHitStore ** ) ckcalloc (len,sizeof(TwoHitStore *))) == NULL) { warn("Warning, ckcalloc failed in TwoHitSequence_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_TwoHitSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TwoHitSequence *] * * Return [UNKN ] Undocumented return value [TwoHitSequence *] * */ TwoHitSequence * hard_link_TwoHitSequence(TwoHitSequence * obj) { if( obj == NULL ) { warn("Trying to hard link to a TwoHitSequence object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TwoHitSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TwoHitSequence *] * */ TwoHitSequence * TwoHitSequence_alloc(void) { TwoHitSequence * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TwoHitSequence *) ckalloc (sizeof(TwoHitSequence))) == NULL) { warn("TwoHitSequence_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->word = NULL; out->len = out->maxlen = 0; return out; } /* Function: swap_TwoHitBuffer(list,i,j) * * Descrip: swap function: an internal for qsort_TwoHitBuffer * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [TwoHitSequence **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_TwoHitBuffer(TwoHitSequence ** list,int i,int j) { TwoHitSequence * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_TwoHitBuffer(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_TwoHitBuffer which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [TwoHitSequence **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_TwoHitBuffer(TwoHitSequence ** list,int left,int right,int (*comp)(TwoHitSequence * ,TwoHitSequence * )) { int i,last; if( left >= right ) return; swap_TwoHitBuffer(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_TwoHitBuffer (list,++last,i); } swap_TwoHitBuffer (list,left,last); qsort_TwoHitBuffer(list,left,last-1,comp); qsort_TwoHitBuffer(list,last+1,right,comp); } /* Function: sort_TwoHitBuffer(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_TwoHitBuffer * * * Arg: obj [UNKN ] Object containing list [TwoHitBuffer *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_TwoHitBuffer(TwoHitBuffer * obj,int (*comp)(TwoHitSequence *, TwoHitSequence *)) { qsort_TwoHitBuffer(obj->buffer,0,obj->len-1,comp); return; } /* Function: expand_TwoHitBuffer(obj,len) * * Descrip: Really an internal function for add_TwoHitBuffer * * * Arg: obj [UNKN ] Object which contains the list [TwoHitBuffer *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_TwoHitBuffer(TwoHitBuffer * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_TwoHitBuffer called with no need"); return TRUE; } if( (obj->buffer = (TwoHitSequence ** ) ckrealloc (obj->buffer,sizeof(TwoHitSequence *)*len)) == NULL) { warn("ckrealloc failed for expand_TwoHitBuffer, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_TwoHitBuffer(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TwoHitBuffer *] * Arg: add [OWNER] Object to add to the list [TwoHitSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_TwoHitBuffer(TwoHitBuffer * obj,TwoHitSequence * add) { if( obj->len >= obj->maxlen) { if( expand_TwoHitBuffer(obj,obj->len + TwoHitBufferLISTLENGTH) == FALSE) return FALSE; } obj->buffer[obj->len++]=add; return TRUE; } /* Function: flush_TwoHitBuffer(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TwoHitBuffer *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_TwoHitBuffer(TwoHitBuffer * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->buffer[i] != NULL) { free_TwoHitSequence(obj->buffer[i]); obj->buffer[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: TwoHitBuffer_alloc_std(void) * * Descrip: Equivalent to TwoHitBuffer_alloc_len(TwoHitBufferLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TwoHitBuffer *] * */ TwoHitBuffer * TwoHitBuffer_alloc_std(void) { return TwoHitBuffer_alloc_len(TwoHitBufferLISTLENGTH); } /* Function: TwoHitBuffer_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TwoHitBuffer *] * */ TwoHitBuffer * TwoHitBuffer_alloc_len(int len) { TwoHitBuffer * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = TwoHitBuffer_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->buffer = (TwoHitSequence ** ) ckcalloc (len,sizeof(TwoHitSequence *))) == NULL) { warn("Warning, ckcalloc failed in TwoHitBuffer_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_TwoHitBuffer(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TwoHitBuffer *] * * Return [UNKN ] Undocumented return value [TwoHitBuffer *] * */ TwoHitBuffer * hard_link_TwoHitBuffer(TwoHitBuffer * obj) { if( obj == NULL ) { warn("Trying to hard link to a TwoHitBuffer object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: TwoHitBuffer_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TwoHitBuffer *] * */ TwoHitBuffer * TwoHitBuffer_alloc(void) { TwoHitBuffer * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(TwoHitBuffer *) ckalloc (sizeof(TwoHitBuffer))) == NULL) { warn("TwoHitBuffer_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->buffer = NULL; out->len = out->maxlen = 0; out->thba = NULL; return out; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/hsptwohitscan.h0000644000175000001440000003217710670453712017717 0ustar philippusers#ifndef DYNAMITEhsptwohitscanHEADERFILE #define DYNAMITEhsptwohitscanHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "hsplookupscan.h" #define TwoHitBufferLISTLENGTH 4096 #define TwoHitSequenceLISTLENGTH 90 #define TWOHIT_FIRST_ENTRY 56 #define TWOHIT_FIRST_STORED 57 #define TWOHIT_HANDLED 58 typedef struct TwoHitStore { int hit_state; Sequence * target; int target_pos; int query_pos; int diagonal; } TwoHitStore; #define TWOHIT_BLOCK_SIZE 40000 #define TWOHIT_BLOCK_DEPTH 1000 typedef struct TwoHitStoreBlockAllocator { TwoHitStore ** block; int current_block; int current_pos; int block_len; } TwoHitStoreBlockAllocator; struct Wise2_TwoHitSequence { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif TwoHitStore ** word; int len;/* len for above word */ int maxlen; /* maxlen for above word */ GHashTable * diagonal_hash; } ; /* TwoHitSequence defined */ #ifndef DYNAMITE_DEFINED_TwoHitSequence typedef struct Wise2_TwoHitSequence Wise2_TwoHitSequence; #define TwoHitSequence Wise2_TwoHitSequence #define DYNAMITE_DEFINED_TwoHitSequence #endif struct Wise2_TwoHitBuffer { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif TwoHitSequence ** buffer; int len;/* len for above buffer */ int maxlen; /* maxlen for above buffer */ GHashTable * target_hash; TwoHitStoreBlockAllocator * thba; } ; /* TwoHitBuffer defined */ #ifndef DYNAMITE_DEFINED_TwoHitBuffer typedef struct Wise2_TwoHitBuffer Wise2_TwoHitBuffer; #define TwoHitBuffer Wise2_TwoHitBuffer #define DYNAMITE_DEFINED_TwoHitBuffer #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_twohit_one_off_HSPScanInterface(sli,mat,drop_off,score_cutoff) * * Descrip: Builds a twohit scan interface. This * does expands the query using a matrix but * just be considering off by one cases * * * Arg: sli [UNKN ] Undocumented argument [SeqLookupInterface *] * Arg: mat [UNKN ] Undocumented argument [CompMat *] * Arg: drop_off [UNKN ] Undocumented argument [int] * Arg: score_cutoff [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [HSPScanInterface *] * */ HSPScanInterface * Wise2_new_twohit_one_off_HSPScanInterface(SeqLookupInterface * sli,CompMat * mat,int drop_off,int score_cutoff); #define new_twohit_one_off_HSPScanInterface Wise2_new_twohit_one_off_HSPScanInterface /* Function: twohit_one_off_HSPscan_scan_query_direct(data,seq,para) * * Descrip: Word expansion with two hit semantics * * * Arg: data [UNKN ] Undocumented argument [void *] * Arg: seq [UNKN ] Undocumented argument [Sequence *] * Arg: para [UNKN ] Undocumented argument [HSPScanInterfacePara *] * * Return [UNKN ] Undocumented return value [LinearHSPmanager *] * */ LinearHSPmanager * Wise2_twohit_one_off_HSPscan_scan_query_direct(void * data,Sequence * seq,HSPScanInterfacePara * para); #define twohit_one_off_HSPscan_scan_query_direct Wise2_twohit_one_off_HSPscan_scan_query_direct /* Function: add_to_TwoHitBuffer(thb,target,query_pos,target_pos) * * Descrip: adds a new potential hit to the TwoHitBuffer, * returning the HitStore datastructure updated * if hit is 1 then this is first entry * if hit is more than 1 second * * * Arg: thb [UNKN ] Undocumented argument [TwoHitBuffer *] * Arg: target [UNKN ] Undocumented argument [Sequence *] * Arg: query_pos [UNKN ] Undocumented argument [int] * Arg: target_pos [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [TwoHitStore *] * */ TwoHitStore * Wise2_add_to_TwoHitBuffer(TwoHitBuffer * thb,Sequence * target,int query_pos,int target_pos); #define add_to_TwoHitBuffer Wise2_add_to_TwoHitBuffer /* Function: new_TwoHitBuffer(void) * * Descrip: makes a new TwoHitBuffer ready for use * * * * Return [UNKN ] Undocumented return value [TwoHitBuffer *] * */ TwoHitBuffer * Wise2_new_TwoHitBuffer(void); #define new_TwoHitBuffer Wise2_new_TwoHitBuffer /* Function: new_TwoHitSequence(void) * * Descrip: make a new TwoHitSequence ready for use * * * * Return [UNKN ] Undocumented return value [TwoHitSequence *] * */ TwoHitSequence * Wise2_new_TwoHitSequence(void); #define new_TwoHitSequence Wise2_new_TwoHitSequence /* Function: free_TwoHitSequence(t) * * Descrip: Frees the TwoHitSequence * * * Arg: t [UNKN ] Undocumented argument [TwoHitSequence *] * * Return [UNKN ] Undocumented return value [TwoHitSequence *] * */ TwoHitSequence * Wise2_free_TwoHitSequence(TwoHitSequence * t); #define free_TwoHitSequence Wise2_free_TwoHitSequence /* Function: free_TwoHitBuffer(t) * * Descrip: Frees the TwoHitBuffer * * * Arg: t [UNKN ] Undocumented argument [TwoHitBuffer *] * * Return [UNKN ] Undocumented return value [TwoHitBuffer *] * */ TwoHitBuffer * Wise2_free_TwoHitBuffer(TwoHitBuffer * t); #define free_TwoHitBuffer Wise2_free_TwoHitBuffer /* Function: TwoHitStore_alloc(void) * * Descrip: allocator for twohitstore * * * * Return [UNKN ] Undocumented return value [TwoHitStore *] * */ TwoHitStore * Wise2_TwoHitStore_alloc(void); #define TwoHitStore_alloc Wise2_TwoHitStore_alloc /* Function: free_TwoHitStore(t) * * Descrip: free for twohitstore * * * Arg: t [UNKN ] Undocumented argument [TwoHitStore *] * * Return [UNKN ] Undocumented return value [TwoHitStore *] * */ TwoHitStore * Wise2_free_TwoHitStore(TwoHitStore * t); #define free_TwoHitStore Wise2_free_TwoHitStore /* Function: new_TwoHitStore_from_Allocator(a) * * Descrip: gets a new store from a block allocator * * * Arg: a [UNKN ] Undocumented argument [TwoHitStoreBlockAllocator *] * * Return [UNKN ] Undocumented return value [TwoHitStore *] * */ TwoHitStore * Wise2_new_TwoHitStore_from_Allocator(TwoHitStoreBlockAllocator * a); #define new_TwoHitStore_from_Allocator Wise2_new_TwoHitStore_from_Allocator /* Function: free_TwoHitStoreBlockAllocator(a) * * Descrip: frees a block allocator * * * Arg: a [UNKN ] Undocumented argument [TwoHitStoreBlockAllocator *] * * Return [UNKN ] Undocumented return value [TwoHitStoreBlockAllocator *] * */ TwoHitStoreBlockAllocator * Wise2_free_TwoHitStoreBlockAllocator(TwoHitStoreBlockAllocator * a); #define free_TwoHitStoreBlockAllocator Wise2_free_TwoHitStoreBlockAllocator /* Function: new_TwoHitStoreBlockAllocator(void) * * Descrip: makes a new block allocator * * * * Return [UNKN ] Undocumented return value [TwoHitStoreBlockAllocator *] * */ TwoHitStoreBlockAllocator * Wise2_new_TwoHitStoreBlockAllocator(void); #define new_TwoHitStoreBlockAllocator Wise2_new_TwoHitStoreBlockAllocator /* Function: add_TwoHitSequence(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TwoHitSequence *] * Arg: add [OWNER] Object to add to the list [TwoHitStore *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_TwoHitSequence(TwoHitSequence * obj,TwoHitStore * add); #define add_TwoHitSequence Wise2_add_TwoHitSequence /* Function: flush_TwoHitSequence(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TwoHitSequence *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_TwoHitSequence(TwoHitSequence * obj); #define flush_TwoHitSequence Wise2_flush_TwoHitSequence /* Function: TwoHitSequence_alloc_std(void) * * Descrip: Equivalent to TwoHitSequence_alloc_len(TwoHitSequenceLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TwoHitSequence *] * */ TwoHitSequence * Wise2_TwoHitSequence_alloc_std(void); #define TwoHitSequence_alloc_std Wise2_TwoHitSequence_alloc_std /* Function: TwoHitSequence_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TwoHitSequence *] * */ TwoHitSequence * Wise2_TwoHitSequence_alloc_len(int len); #define TwoHitSequence_alloc_len Wise2_TwoHitSequence_alloc_len /* Function: hard_link_TwoHitSequence(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TwoHitSequence *] * * Return [UNKN ] Undocumented return value [TwoHitSequence *] * */ TwoHitSequence * Wise2_hard_link_TwoHitSequence(TwoHitSequence * obj); #define hard_link_TwoHitSequence Wise2_hard_link_TwoHitSequence /* Function: TwoHitSequence_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TwoHitSequence *] * */ TwoHitSequence * Wise2_TwoHitSequence_alloc(void); #define TwoHitSequence_alloc Wise2_TwoHitSequence_alloc /* Function: add_TwoHitBuffer(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [TwoHitBuffer *] * Arg: add [OWNER] Object to add to the list [TwoHitSequence *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_TwoHitBuffer(TwoHitBuffer * obj,TwoHitSequence * add); #define add_TwoHitBuffer Wise2_add_TwoHitBuffer /* Function: flush_TwoHitBuffer(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [TwoHitBuffer *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_TwoHitBuffer(TwoHitBuffer * obj); #define flush_TwoHitBuffer Wise2_flush_TwoHitBuffer /* Function: TwoHitBuffer_alloc_std(void) * * Descrip: Equivalent to TwoHitBuffer_alloc_len(TwoHitBufferLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [TwoHitBuffer *] * */ TwoHitBuffer * Wise2_TwoHitBuffer_alloc_std(void); #define TwoHitBuffer_alloc_std Wise2_TwoHitBuffer_alloc_std /* Function: TwoHitBuffer_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [TwoHitBuffer *] * */ TwoHitBuffer * Wise2_TwoHitBuffer_alloc_len(int len); #define TwoHitBuffer_alloc_len Wise2_TwoHitBuffer_alloc_len /* Function: hard_link_TwoHitBuffer(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [TwoHitBuffer *] * * Return [UNKN ] Undocumented return value [TwoHitBuffer *] * */ TwoHitBuffer * Wise2_hard_link_TwoHitBuffer(TwoHitBuffer * obj); #define hard_link_TwoHitBuffer Wise2_hard_link_TwoHitBuffer /* Function: TwoHitBuffer_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [TwoHitBuffer *] * */ TwoHitBuffer * Wise2_TwoHitBuffer_alloc(void); #define TwoHitBuffer_alloc Wise2_TwoHitBuffer_alloc /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ void Wise2_swap_TwoHitSequence(TwoHitStore ** list,int i,int j) ; #define swap_TwoHitSequence Wise2_swap_TwoHitSequence void Wise2_qsort_TwoHitSequence(TwoHitStore ** list,int left,int right,int (*comp)(TwoHitStore * ,TwoHitStore * )); #define qsort_TwoHitSequence Wise2_qsort_TwoHitSequence void Wise2_sort_TwoHitSequence(TwoHitSequence * obj,int (*comp)(TwoHitStore *, TwoHitStore *)); #define sort_TwoHitSequence Wise2_sort_TwoHitSequence boolean Wise2_expand_TwoHitSequence(TwoHitSequence * obj,int len); #define expand_TwoHitSequence Wise2_expand_TwoHitSequence void Wise2_swap_TwoHitBuffer(TwoHitSequence ** list,int i,int j) ; #define swap_TwoHitBuffer Wise2_swap_TwoHitBuffer void Wise2_qsort_TwoHitBuffer(TwoHitSequence ** list,int left,int right,int (*comp)(TwoHitSequence * ,TwoHitSequence * )); #define qsort_TwoHitBuffer Wise2_qsort_TwoHitBuffer void Wise2_sort_TwoHitBuffer(TwoHitBuffer * obj,int (*comp)(TwoHitSequence *, TwoHitSequence *)); #define sort_TwoHitBuffer Wise2_sort_TwoHitBuffer boolean Wise2_expand_TwoHitBuffer(TwoHitBuffer * obj,int len); #define expand_TwoHitBuffer Wise2_expand_TwoHitBuffer #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/dbsearchimpl_api.h0000644000175000001440000001612310670453712020300 0ustar philippusers /* Functions that create, manipulate or act on DBSearchImpl * * Wise2_impl_string_DBSearchImpl * Wise2_hard_link_DBSearchImpl * Wise2_DBSearchImpl_alloc * Wise2_replace_type_DBSearchImpl * Wise2_access_type_DBSearchImpl * Wise2_replace_trace_level_DBSearchImpl * Wise2_access_trace_level_DBSearchImpl * Wise2_replace_trace_file_DBSearchImpl * Wise2_access_trace_file_DBSearchImpl * Wise2_replace_suggest_thread_no_DBSearchImpl * Wise2_access_suggest_thread_no_DBSearchImpl * Wise2_replace_search_routine_DBSearchImpl * Wise2_access_search_routine_DBSearchImpl * Wise2_free_DBSearchImpl [destructor] * */ /* Helper functions in the module * * Wise2_new_pthread_DBSearchImpl * Wise2_new_serial_DBSearchImpl * /* API for object DBSearchImpl */ /* Function: Wise2_impl_string_DBSearchImpl(dbsi) * * Descrip: Gets a static text string out of the * search implementation * * * Arg: dbsi Undocumented argument [Wise2_DBSearchImpl *] * * Returns string of the search implementation [char *] * */ char * Wise2_impl_string_DBSearchImpl( Wise2_DBSearchImpl * dbsi); /* Function: Wise2_hard_link_DBSearchImpl(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_DBSearchImpl *] * * Returns Undocumented return value [Wise2_DBSearchImpl *] * */ Wise2_DBSearchImpl * Wise2_hard_link_DBSearchImpl( Wise2_DBSearchImpl * obj); /* Function: Wise2_DBSearchImpl_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_DBSearchImpl *] * */ Wise2_DBSearchImpl * Wise2_DBSearchImpl_alloc(); /* Function: Wise2_replace_type_DBSearchImpl(obj,type) * * Descrip: Replace member variable type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DBSearchImpl *] * Arg: type New value of the variable [int] * * Returns member variable type [boolean] * */ boolean Wise2_replace_type_DBSearchImpl( Wise2_DBSearchImpl * obj,int type); /* Function: Wise2_access_type_DBSearchImpl(obj) * * Descrip: Access member variable type * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DBSearchImpl *] * * Returns member variable type [int] * */ int Wise2_access_type_DBSearchImpl( Wise2_DBSearchImpl * obj); /* Function: Wise2_replace_trace_level_DBSearchImpl(obj,trace_level) * * Descrip: Replace member variable trace_level * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DBSearchImpl *] * Arg: trace_level New value of the variable [int] * * Returns member variable trace_level [boolean] * */ boolean Wise2_replace_trace_level_DBSearchImpl( Wise2_DBSearchImpl * obj,int trace_level); /* Function: Wise2_access_trace_level_DBSearchImpl(obj) * * Descrip: Access member variable trace_level * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DBSearchImpl *] * * Returns member variable trace_level [int] * */ int Wise2_access_trace_level_DBSearchImpl( Wise2_DBSearchImpl * obj); /* Function: Wise2_replace_trace_file_DBSearchImpl(obj,trace_file) * * Descrip: Replace member variable trace_file * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DBSearchImpl *] * Arg: trace_file New value of the variable [FILE *] * * Returns member variable trace_file [boolean] * */ boolean Wise2_replace_trace_file_DBSearchImpl( Wise2_DBSearchImpl * obj,FILE * trace_file); /* Function: Wise2_access_trace_file_DBSearchImpl(obj) * * Descrip: Access member variable trace_file * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DBSearchImpl *] * * Returns member variable trace_file [FILE *] * */ FILE * Wise2_access_trace_file_DBSearchImpl( Wise2_DBSearchImpl * obj); /* Function: Wise2_replace_suggest_thread_no_DBSearchImpl(obj,suggest_thread_no) * * Descrip: Replace member variable suggest_thread_no * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DBSearchImpl *] * Arg: suggest_thread_no New value of the variable [int] * * Returns member variable suggest_thread_no [boolean] * */ boolean Wise2_replace_suggest_thread_no_DBSearchImpl( Wise2_DBSearchImpl * obj,int suggest_thread_no); /* Function: Wise2_access_suggest_thread_no_DBSearchImpl(obj) * * Descrip: Access member variable suggest_thread_no * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DBSearchImpl *] * * Returns member variable suggest_thread_no [int] * */ int Wise2_access_suggest_thread_no_DBSearchImpl( Wise2_DBSearchImpl * obj); /* Function: Wise2_replace_search_routine_DBSearchImpl(obj,search_routine) * * Descrip: Replace member variable search_routine * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DBSearchImpl *] * Arg: search_routine New value of the variable [int] * * Returns member variable search_routine [boolean] * */ boolean Wise2_replace_search_routine_DBSearchImpl( Wise2_DBSearchImpl * obj,int search_routine); /* Function: Wise2_access_search_routine_DBSearchImpl(obj) * * Descrip: Access member variable search_routine * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DBSearchImpl *] * * Returns member variable search_routine [int] * */ int Wise2_access_search_routine_DBSearchImpl( Wise2_DBSearchImpl * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_DBSearchImpl(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_DBSearchImpl *] * * Returns Undocumented return value [Wise2_DBSearchImpl *] * */ Wise2_DBSearchImpl * Wise2_free_DBSearchImpl( Wise2_DBSearchImpl * obj); /* These functions are not associated with an object */ /* Function: Wise2_new_pthread_DBSearchImpl(void) * * Descrip: Makes a new pthreaded DBSearchImpl * * For use mainly for api's who don't want * to initalize the object from the command * line * * * * Returns Undocumented return value [Wise2_DBSearchImpl *] * */ Wise2_DBSearchImpl * Wise2_new_pthread_DBSearchImpl(); /* Function: Wise2_new_serial_DBSearchImpl(void) * * Descrip: Makes a new serial DBSearchImpl * * For use mainly for api's who don't want * to initalize the object from the command * line * * * * Returns Undocumented return value [Wise2_DBSearchImpl *] * */ Wise2_DBSearchImpl * Wise2_new_serial_DBSearchImpl(); wise-2.4.1/src/dynlibsrc/dbsearchimpl_api.t0000644000175000001440000000006710670453712020314 0ustar philippuserstypedef struct Wise2_DBSearchImpl Wise2_DBSearchImpl; wise-2.4.1/src/dynlibsrc/alnrange.c0000644000175000001440000005533110670453712016600 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "alnrange.h" /* Function: show_AlnRangeSet(ars,ofp) * * Descrip: shows AlnRangeSet in vaguely human form * * * Arg: ars [UNKN ] Undocumented argument [AlnRangeSet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 43 "alnrange.dy" void show_AlnRangeSet(AlnRangeSet * ars,FILE * ofp) { int i; for(i=0;ilen;i++) { show_AlnRange(ars->alr[i],ofp); } } /* Function: show_AlnRange(alr,ofp) * * Descrip: shows AlnRange in vaguely human form * * * Arg: alr [UNKN ] Undocumented argument [AlnRange *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 56 "alnrange.dy" void show_AlnRange(AlnRange * alr,FILE * ofp) { fprintf(ofp,"(%d,%d,%d)-(%d,%d,%d) [%d,%d]\n",alr->starti,alr->startj,alr->startstate, alr->stopi,alr->stopj,alr->stopstate,alr->startscore,alr->stopscore); } /* Function: sort_AlnRangeSet_by_start(ars) * * Descrip: Sorts an AlnRangeSet by start of each AlnRange * * * Arg: ars [UNKN ] Undocumented argument [AlnRangeSet *] * */ # line 65 "alnrange.dy" void sort_AlnRangeSet_by_start(AlnRangeSet * ars) { sort_AlnRangeSet(ars,compare_AlnRange_start); } /* Function: compare_AlnRange_start(one,two) * * Descrip: compares to AlnRange for /sort_AlnRangeSet_by_start * * * Arg: one [UNKN ] Undocumented argument [AlnRange *] * Arg: two [UNKN ] Undocumented argument [AlnRange *] * * Return [UNKN ] Undocumented return value [int] * */ # line 74 "alnrange.dy" int compare_AlnRange_start(AlnRange * one,AlnRange * two) { if( one->startj > two->startj) return 1; else return -1; } # line 69 "alnrange.c" /* Function: hard_link_AlnRange(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnRange *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * hard_link_AlnRange(AlnRange * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlnRange object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlnRange_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * AlnRange_alloc(void) { AlnRange * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlnRange *) ckalloc (sizeof(AlnRange))) == NULL) { warn("AlnRange_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->starti = 0; out->startj = 0; out->startstate = 0; out->stopi = 0; out->stopj = 0; out->stopstate = 0; out->startscore = 0; out->stopscore = 0; return out; } /* Function: free_AlnRange(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnRange *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * free_AlnRange(AlnRange * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AlnRange obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: swap_AlnRangeSet(list,i,j) * * Descrip: swap function: an internal for qsort_AlnRangeSet * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [AlnRange **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_AlnRangeSet(AlnRange ** list,int i,int j) { AlnRange * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_AlnRangeSet(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_AlnRangeSet which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [AlnRange **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_AlnRangeSet(AlnRange ** list,int left,int right,int (*comp)(AlnRange * ,AlnRange * )) { int i,last; if( left >= right ) return; swap_AlnRangeSet(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_AlnRangeSet (list,++last,i); } swap_AlnRangeSet (list,left,last); qsort_AlnRangeSet(list,left,last-1,comp); qsort_AlnRangeSet(list,last+1,right,comp); } /* Function: sort_AlnRangeSet(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_AlnRangeSet * * * Arg: obj [UNKN ] Object containing list [AlnRangeSet *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_AlnRangeSet(AlnRangeSet * obj,int (*comp)(AlnRange *, AlnRange *)) { qsort_AlnRangeSet(obj->alr,0,obj->len-1,comp); return; } /* Function: expand_AlnRangeSet(obj,len) * * Descrip: Really an internal function for add_AlnRangeSet * * * Arg: obj [UNKN ] Object which contains the list [AlnRangeSet *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_AlnRangeSet(AlnRangeSet * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_AlnRangeSet called with no need"); return TRUE; } if( (obj->alr = (AlnRange ** ) ckrealloc (obj->alr,sizeof(AlnRange *)*len)) == NULL) { warn("ckrealloc failed for expand_AlnRangeSet, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_AlnRangeSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AlnRangeSet *] * Arg: add [OWNER] Object to add to the list [AlnRange *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_AlnRangeSet(AlnRangeSet * obj,AlnRange * add) { if( obj->len >= obj->maxlen) { if( expand_AlnRangeSet(obj,obj->len + AlnRangeSetLISTLENGTH) == FALSE) return FALSE; } obj->alr[obj->len++]=add; return TRUE; } /* Function: flush_AlnRangeSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AlnRangeSet *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_AlnRangeSet(AlnRangeSet * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->alr[i] != NULL) { free_AlnRange(obj->alr[i]); obj->alr[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: AlnRangeSet_alloc_std(void) * * Descrip: Equivalent to AlnRangeSet_alloc_len(AlnRangeSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_alloc_std(void) { return AlnRangeSet_alloc_len(AlnRangeSetLISTLENGTH); } /* Function: AlnRangeSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_alloc_len(int len) { AlnRangeSet * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = AlnRangeSet_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->alr = (AlnRange ** ) ckcalloc (len,sizeof(AlnRange *))) == NULL) { warn("Warning, ckcalloc failed in AlnRangeSet_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; return out; } /* Function: hard_link_AlnRangeSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnRangeSet *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * hard_link_AlnRangeSet(AlnRangeSet * obj) { if( obj == NULL ) { warn("Trying to hard link to a AlnRangeSet object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: AlnRangeSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * AlnRangeSet_alloc(void) { AlnRangeSet * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(AlnRangeSet *) ckalloc (sizeof(AlnRangeSet))) == NULL) { warn("AlnRangeSet_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->score = 0; out->alr = NULL; out->len = out->maxlen = 0; return out; } /* Function: free_AlnRangeSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnRangeSet *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * free_AlnRangeSet(AlnRangeSet * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a AlnRangeSet obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->alr != NULL) { for(i=0;ilen;i++) { if( obj->alr[i] != NULL) free_AlnRange(obj->alr[i]); } ckfree(obj->alr); } ckfree(obj); return NULL; } /* Function: replace_starti_AlnRange(obj,starti) * * Descrip: Replace member variable starti * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * Arg: starti [OWNER] New value of the variable [int] * * Return [SOFT ] member variable starti [boolean] * */ boolean replace_starti_AlnRange(AlnRange * obj,int starti) { if( obj == NULL) { warn("In replacement function starti for object AlnRange, got a NULL object"); return FALSE; } obj->starti = starti; return TRUE; } /* Function: access_starti_AlnRange(obj) * * Descrip: Access member variable starti * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * * Return [SOFT ] member variable starti [int] * */ int access_starti_AlnRange(AlnRange * obj) { if( obj == NULL) { warn("In accessor function starti for object AlnRange, got a NULL object"); return 0; } return obj->starti; } /* Function: replace_startj_AlnRange(obj,startj) * * Descrip: Replace member variable startj * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * Arg: startj [OWNER] New value of the variable [int] * * Return [SOFT ] member variable startj [boolean] * */ boolean replace_startj_AlnRange(AlnRange * obj,int startj) { if( obj == NULL) { warn("In replacement function startj for object AlnRange, got a NULL object"); return FALSE; } obj->startj = startj; return TRUE; } /* Function: access_startj_AlnRange(obj) * * Descrip: Access member variable startj * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * * Return [SOFT ] member variable startj [int] * */ int access_startj_AlnRange(AlnRange * obj) { if( obj == NULL) { warn("In accessor function startj for object AlnRange, got a NULL object"); return 0; } return obj->startj; } /* Function: replace_startstate_AlnRange(obj,startstate) * * Descrip: Replace member variable startstate * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * Arg: startstate [OWNER] New value of the variable [int] * * Return [SOFT ] member variable startstate [boolean] * */ boolean replace_startstate_AlnRange(AlnRange * obj,int startstate) { if( obj == NULL) { warn("In replacement function startstate for object AlnRange, got a NULL object"); return FALSE; } obj->startstate = startstate; return TRUE; } /* Function: access_startstate_AlnRange(obj) * * Descrip: Access member variable startstate * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * * Return [SOFT ] member variable startstate [int] * */ int access_startstate_AlnRange(AlnRange * obj) { if( obj == NULL) { warn("In accessor function startstate for object AlnRange, got a NULL object"); return 0; } return obj->startstate; } /* Function: replace_stopi_AlnRange(obj,stopi) * * Descrip: Replace member variable stopi * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * Arg: stopi [OWNER] New value of the variable [int] * * Return [SOFT ] member variable stopi [boolean] * */ boolean replace_stopi_AlnRange(AlnRange * obj,int stopi) { if( obj == NULL) { warn("In replacement function stopi for object AlnRange, got a NULL object"); return FALSE; } obj->stopi = stopi; return TRUE; } /* Function: access_stopi_AlnRange(obj) * * Descrip: Access member variable stopi * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * * Return [SOFT ] member variable stopi [int] * */ int access_stopi_AlnRange(AlnRange * obj) { if( obj == NULL) { warn("In accessor function stopi for object AlnRange, got a NULL object"); return 0; } return obj->stopi; } /* Function: replace_stopj_AlnRange(obj,stopj) * * Descrip: Replace member variable stopj * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * Arg: stopj [OWNER] New value of the variable [int] * * Return [SOFT ] member variable stopj [boolean] * */ boolean replace_stopj_AlnRange(AlnRange * obj,int stopj) { if( obj == NULL) { warn("In replacement function stopj for object AlnRange, got a NULL object"); return FALSE; } obj->stopj = stopj; return TRUE; } /* Function: access_stopj_AlnRange(obj) * * Descrip: Access member variable stopj * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * * Return [SOFT ] member variable stopj [int] * */ int access_stopj_AlnRange(AlnRange * obj) { if( obj == NULL) { warn("In accessor function stopj for object AlnRange, got a NULL object"); return 0; } return obj->stopj; } /* Function: replace_stopstate_AlnRange(obj,stopstate) * * Descrip: Replace member variable stopstate * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * Arg: stopstate [OWNER] New value of the variable [int] * * Return [SOFT ] member variable stopstate [boolean] * */ boolean replace_stopstate_AlnRange(AlnRange * obj,int stopstate) { if( obj == NULL) { warn("In replacement function stopstate for object AlnRange, got a NULL object"); return FALSE; } obj->stopstate = stopstate; return TRUE; } /* Function: access_stopstate_AlnRange(obj) * * Descrip: Access member variable stopstate * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * * Return [SOFT ] member variable stopstate [int] * */ int access_stopstate_AlnRange(AlnRange * obj) { if( obj == NULL) { warn("In accessor function stopstate for object AlnRange, got a NULL object"); return 0; } return obj->stopstate; } /* Function: replace_startscore_AlnRange(obj,startscore) * * Descrip: Replace member variable startscore * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * Arg: startscore [OWNER] New value of the variable [int] * * Return [SOFT ] member variable startscore [boolean] * */ boolean replace_startscore_AlnRange(AlnRange * obj,int startscore) { if( obj == NULL) { warn("In replacement function startscore for object AlnRange, got a NULL object"); return FALSE; } obj->startscore = startscore; return TRUE; } /* Function: access_startscore_AlnRange(obj) * * Descrip: Access member variable startscore * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * * Return [SOFT ] member variable startscore [int] * */ int access_startscore_AlnRange(AlnRange * obj) { if( obj == NULL) { warn("In accessor function startscore for object AlnRange, got a NULL object"); return 0; } return obj->startscore; } /* Function: replace_stopscore_AlnRange(obj,stopscore) * * Descrip: Replace member variable stopscore * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * Arg: stopscore [OWNER] New value of the variable [int] * * Return [SOFT ] member variable stopscore [boolean] * */ boolean replace_stopscore_AlnRange(AlnRange * obj,int stopscore) { if( obj == NULL) { warn("In replacement function stopscore for object AlnRange, got a NULL object"); return FALSE; } obj->stopscore = stopscore; return TRUE; } /* Function: access_stopscore_AlnRange(obj) * * Descrip: Access member variable stopscore * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRange *] * * Return [SOFT ] member variable stopscore [int] * */ int access_stopscore_AlnRange(AlnRange * obj) { if( obj == NULL) { warn("In accessor function stopscore for object AlnRange, got a NULL object"); return 0; } return obj->stopscore; } /* Function: replace_score_AlnRangeSet(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRangeSet *] * Arg: score [OWNER] New value of the variable [int] * * Return [SOFT ] member variable score [boolean] * */ boolean replace_score_AlnRangeSet(AlnRangeSet * obj,int score) { if( obj == NULL) { warn("In replacement function score for object AlnRangeSet, got a NULL object"); return FALSE; } obj->score = score; return TRUE; } /* Function: access_score_AlnRangeSet(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [AlnRangeSet *] * * Return [SOFT ] member variable score [int] * */ int access_score_AlnRangeSet(AlnRangeSet * obj) { if( obj == NULL) { warn("In accessor function score for object AlnRangeSet, got a NULL object"); return 0; } return obj->score; } /* Function: access_alr_AlnRangeSet(obj,i) * * Descrip: Access members stored in the alr list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [AlnRangeSet *] * Arg: i [UNKN ] Position in the list [int] * * Return [SOFT ] Element of the list [AlnRange *] * */ AlnRange * access_alr_AlnRangeSet(AlnRangeSet * obj,int i) { if( obj == NULL) { warn("In accessor function alr for object AlnRangeSet, got a NULL object"); return NULL; } if( obj->len <= i ) { warn("In accessor function alr for object AlnRangeSet, index %%d is greater than list length %%d",i,obj->len); return NULL; } return obj->alr[i]; } /* Function: length_alr_AlnRangeSet(obj) * * Descrip: discover the length of the list * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the list [AlnRangeSet *] * * Return [UNKN ] length of the list [int] * */ int length_alr_AlnRangeSet(AlnRangeSet * obj) { if( obj == NULL) { warn("In length function alr for object AlnRangeSet, got a NULL object"); return -1; } return obj->len; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/alnrange.h0000644000175000001440000002254210670453712016603 0ustar philippusers#ifndef DYNAMITEalnrangeHEADERFILE #define DYNAMITEalnrangeHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" #define AlnRangeSetLISTLENGTH 64 struct Wise2_AlnRange { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int starti; int startj; int startstate; int stopi; int stopj; int stopstate; int startscore; int stopscore; } ; /* AlnRange defined */ #ifndef DYNAMITE_DEFINED_AlnRange typedef struct Wise2_AlnRange Wise2_AlnRange; #define AlnRange Wise2_AlnRange #define DYNAMITE_DEFINED_AlnRange #endif struct Wise2_AlnRangeSet { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int score; /* over complete alignment */ AlnRange ** alr; int len;/* len for above alr */ int maxlen; /* maxlen for above alr */ } ; /* AlnRangeSet defined */ #ifndef DYNAMITE_DEFINED_AlnRangeSet typedef struct Wise2_AlnRangeSet Wise2_AlnRangeSet; #define AlnRangeSet Wise2_AlnRangeSet #define DYNAMITE_DEFINED_AlnRangeSet #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: show_AlnRangeSet(ars,ofp) * * Descrip: shows AlnRangeSet in vaguely human form * * * Arg: ars [UNKN ] Undocumented argument [AlnRangeSet *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_AlnRangeSet(AlnRangeSet * ars,FILE * ofp); #define show_AlnRangeSet Wise2_show_AlnRangeSet /* Function: show_AlnRange(alr,ofp) * * Descrip: shows AlnRange in vaguely human form * * * Arg: alr [UNKN ] Undocumented argument [AlnRange *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_AlnRange(AlnRange * alr,FILE * ofp); #define show_AlnRange Wise2_show_AlnRange /* Function: sort_AlnRangeSet_by_start(ars) * * Descrip: Sorts an AlnRangeSet by start of each AlnRange * * * Arg: ars [UNKN ] Undocumented argument [AlnRangeSet *] * */ void Wise2_sort_AlnRangeSet_by_start(AlnRangeSet * ars); #define sort_AlnRangeSet_by_start Wise2_sort_AlnRangeSet_by_start /* Function: hard_link_AlnRange(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnRange *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * Wise2_hard_link_AlnRange(AlnRange * obj); #define hard_link_AlnRange Wise2_hard_link_AlnRange /* Function: AlnRange_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * Wise2_AlnRange_alloc(void); #define AlnRange_alloc Wise2_AlnRange_alloc /* Function: free_AlnRange(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnRange *] * * Return [UNKN ] Undocumented return value [AlnRange *] * */ AlnRange * Wise2_free_AlnRange(AlnRange * obj); #define free_AlnRange Wise2_free_AlnRange /* Function: add_AlnRangeSet(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [AlnRangeSet *] * Arg: add [OWNER] Object to add to the list [AlnRange *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_AlnRangeSet(AlnRangeSet * obj,AlnRange * add); #define add_AlnRangeSet Wise2_add_AlnRangeSet /* Function: flush_AlnRangeSet(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [AlnRangeSet *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_AlnRangeSet(AlnRangeSet * obj); #define flush_AlnRangeSet Wise2_flush_AlnRangeSet /* Function: AlnRangeSet_alloc_std(void) * * Descrip: Equivalent to AlnRangeSet_alloc_len(AlnRangeSetLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_alloc_std(void); #define AlnRangeSet_alloc_std Wise2_AlnRangeSet_alloc_std /* Function: AlnRangeSet_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_alloc_len(int len); #define AlnRangeSet_alloc_len Wise2_AlnRangeSet_alloc_len /* Function: hard_link_AlnRangeSet(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [AlnRangeSet *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_hard_link_AlnRangeSet(AlnRangeSet * obj); #define hard_link_AlnRangeSet Wise2_hard_link_AlnRangeSet /* Function: AlnRangeSet_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_AlnRangeSet_alloc(void); #define AlnRangeSet_alloc Wise2_AlnRangeSet_alloc /* Function: free_AlnRangeSet(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [AlnRangeSet *] * * Return [UNKN ] Undocumented return value [AlnRangeSet *] * */ AlnRangeSet * Wise2_free_AlnRangeSet(AlnRangeSet * obj); #define free_AlnRangeSet Wise2_free_AlnRangeSet /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_starti_AlnRange(AlnRange * obj,int starti); #define replace_starti_AlnRange Wise2_replace_starti_AlnRange int Wise2_access_stopi_AlnRange(AlnRange * obj); #define access_stopi_AlnRange Wise2_access_stopi_AlnRange boolean Wise2_replace_stopj_AlnRange(AlnRange * obj,int stopj); #define replace_stopj_AlnRange Wise2_replace_stopj_AlnRange int Wise2_access_stopj_AlnRange(AlnRange * obj); #define access_stopj_AlnRange Wise2_access_stopj_AlnRange AlnRange * Wise2_access_alr_AlnRangeSet(AlnRangeSet * obj,int i); #define access_alr_AlnRangeSet Wise2_access_alr_AlnRangeSet boolean Wise2_replace_stopstate_AlnRange(AlnRange * obj,int stopstate); #define replace_stopstate_AlnRange Wise2_replace_stopstate_AlnRange boolean Wise2_replace_startj_AlnRange(AlnRange * obj,int startj); #define replace_startj_AlnRange Wise2_replace_startj_AlnRange int Wise2_access_stopstate_AlnRange(AlnRange * obj); #define access_stopstate_AlnRange Wise2_access_stopstate_AlnRange boolean Wise2_replace_startstate_AlnRange(AlnRange * obj,int startstate); #define replace_startstate_AlnRange Wise2_replace_startstate_AlnRange boolean Wise2_replace_startscore_AlnRange(AlnRange * obj,int startscore); #define replace_startscore_AlnRange Wise2_replace_startscore_AlnRange boolean Wise2_replace_stopi_AlnRange(AlnRange * obj,int stopi); #define replace_stopi_AlnRange Wise2_replace_stopi_AlnRange int Wise2_access_startscore_AlnRange(AlnRange * obj); #define access_startscore_AlnRange Wise2_access_startscore_AlnRange int Wise2_access_starti_AlnRange(AlnRange * obj); #define access_starti_AlnRange Wise2_access_starti_AlnRange boolean Wise2_replace_stopscore_AlnRange(AlnRange * obj,int stopscore); #define replace_stopscore_AlnRange Wise2_replace_stopscore_AlnRange int Wise2_access_startstate_AlnRange(AlnRange * obj); #define access_startstate_AlnRange Wise2_access_startstate_AlnRange int Wise2_access_stopscore_AlnRange(AlnRange * obj); #define access_stopscore_AlnRange Wise2_access_stopscore_AlnRange int Wise2_access_startj_AlnRange(AlnRange * obj); #define access_startj_AlnRange Wise2_access_startj_AlnRange boolean Wise2_replace_score_AlnRangeSet(AlnRangeSet * obj,int score); #define replace_score_AlnRangeSet Wise2_replace_score_AlnRangeSet int Wise2_length_alr_AlnRangeSet(AlnRangeSet * obj); #define length_alr_AlnRangeSet Wise2_length_alr_AlnRangeSet int Wise2_access_score_AlnRangeSet(AlnRangeSet * obj); #define access_score_AlnRangeSet Wise2_access_score_AlnRangeSet int Wise2_compare_AlnRange_start(AlnRange * one,AlnRange * two); #define compare_AlnRange_start Wise2_compare_AlnRange_start void Wise2_swap_AlnRangeSet(AlnRange ** list,int i,int j) ; #define swap_AlnRangeSet Wise2_swap_AlnRangeSet void Wise2_qsort_AlnRangeSet(AlnRange ** list,int left,int right,int (*comp)(AlnRange * ,AlnRange * )); #define qsort_AlnRangeSet Wise2_qsort_AlnRangeSet void Wise2_sort_AlnRangeSet(AlnRangeSet * obj,int (*comp)(AlnRange *, AlnRange *)); #define sort_AlnRangeSet Wise2_sort_AlnRangeSet boolean Wise2_expand_AlnRangeSet(AlnRangeSet * obj,int len); #define expand_AlnRangeSet Wise2_expand_AlnRangeSet #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/codonmatrix.c0000644000175000001440000002051310670453712017332 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "codonmatrix.h" /* Function: naive_CodonMatrixScore_from_prob(ct,cm) * * Descrip: Combines CodonMatrixScore_from_CodonMatrix and naive_CodonMatrix * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: cm [UNKN ] Undocumented argument [CompProb *] * * Return [UNKN ] Undocumented return value [CodonMatrixScore *] * */ # line 23 "codonmatrix.dy" CodonMatrixScore * naive_CodonMatrixScore_from_prob(CodonTable * ct,CompProb * cm) { CodonMatrixScore * out; CodonMatrix * com; com = naive_CodonMatrix(ct,cm); out = CodonMatrixScore_from_CodonMatrix(com); free_CodonMatrix(com); return out; } /* Function: CodonMatrixScore_from_CodonMatrix(cm) * * Descrip: Makes a CodonMatrixScore from a CodonMatrix * * * Arg: cm [UNKN ] Undocumented argument [CodonMatrix *] * * Return [UNKN ] Undocumented return value [CodonMatrixScore *] * */ # line 41 "codonmatrix.dy" CodonMatrixScore * CodonMatrixScore_from_CodonMatrix(CodonMatrix * cm) { int i,j; CodonMatrixScore * out; out = CodonMatrixScore_alloc(); for(i=0;i<125;i++) for(j=0;j<125;j++) out->score[i][j] = Probability2Score(cm->prob[i][j]); return out; } /* Function: naive_CodonMatrix(ct,comp) * * Descrip: Builds a probability matrix * No codon bias * No errors * N codons score 1.0, stop codons probability 0.00001 * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: comp [UNKN ] Undocumented argument [CompProb *] * * Return [UNKN ] Undocumented return value [CodonMatrix *] * */ # line 61 "codonmatrix.dy" CodonMatrix * naive_CodonMatrix(CodonTable * ct,CompProb * comp) { int i; int j; CodonMatrix * out; out = CodonMatrix_alloc(); for(i=0;i<125;i++) for(j=i;j<125;j++) { if( has_random_bases(i) == TRUE || has_random_bases(j) == TRUE ) { out->prob[i][j] = out->prob[j][i] = 1.0; } else if ( is_stop_codon(i,ct) == TRUE || is_stop_codon(j,ct) == TRUE ) { out->prob[i][j] = out->prob[j][i] = 0.00001; } else { out->prob[i][j] = out->prob[j][i] = comp->comp[aminoacid_no_from_codon(ct,i)][aminoacid_no_from_codon(ct,j)]; } } return out; } /* Function: naive_CodonMatrixScore(ct,comp) * * Descrip: Builds a codon matrix from CompMat which assummes: * No codon Bias * No errors * N codons score 0, stop codons score ?? * * * Arg: ct [UNKN ] CodonTable for codon->aa mapping [CodonTable *] * Arg: comp [UNKN ] Comparison matrix for the score of the individual access [CompMat *] * * Return [UNKN ] Undocumented return value [CodonMatrixScore *] * */ # line 96 "codonmatrix.dy" CodonMatrixScore * naive_CodonMatrixScore(CodonTable * ct,CompMat * comp) { int i; int j; CodonMatrixScore * out; out = CodonMatrixScore_alloc(); for(i=0;i<125;i++) for(j=i;j<125;j++) { if( has_random_bases(i) == TRUE || has_random_bases(j) == TRUE ) out->score[i][j] = out->score[j][i] = 0; else out->score[i][j] = out->score[j][i] = fail_safe_CompMat_access(comp,aminoacid_no_from_codon(ct,i),aminoacid_no_from_codon(ct,j)); } return out; } /* Function: show_CodonMatrixScore(cms,ct,ofp) * * Descrip: Shows a codonmatrix * * * Arg: cms [UNKN ] Undocumented argument [CodonMatrixScore *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 120 "codonmatrix.dy" void show_CodonMatrixScore(CodonMatrixScore * cms,CodonTable * ct,FILE * ofp) { int i; int j; for(i=0;i<125;i++) for(j=0;j<125;j++) { fprintf(ofp,"%5d %c :%5d %c Score %5d\n",i,aminoacid_from_codon(ct,i),j,aminoacid_from_codon(ct,j),cms->score[i][j]); } } # line 150 "codonmatrix.c" /* Function: hard_link_CodonMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CodonMatrix *] * * Return [UNKN ] Undocumented return value [CodonMatrix *] * */ CodonMatrix * hard_link_CodonMatrix(CodonMatrix * obj) { if( obj == NULL ) { warn("Trying to hard link to a CodonMatrix object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CodonMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CodonMatrix *] * */ CodonMatrix * CodonMatrix_alloc(void) { CodonMatrix * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CodonMatrix *) ckalloc (sizeof(CodonMatrix))) == NULL) { warn("CodonMatrix_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* prob[125][125] is an array: no default possible */ return out; } /* Function: free_CodonMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CodonMatrix *] * * Return [UNKN ] Undocumented return value [CodonMatrix *] * */ CodonMatrix * free_CodonMatrix(CodonMatrix * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CodonMatrix obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_CodonMatrixScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CodonMatrixScore *] * * Return [UNKN ] Undocumented return value [CodonMatrixScore *] * */ CodonMatrixScore * hard_link_CodonMatrixScore(CodonMatrixScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a CodonMatrixScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: CodonMatrixScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CodonMatrixScore *] * */ CodonMatrixScore * CodonMatrixScore_alloc(void) { CodonMatrixScore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(CodonMatrixScore *) ckalloc (sizeof(CodonMatrixScore))) == NULL) { warn("CodonMatrixScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* score[125][125] is an array: no default possible */ return out; } /* Function: free_CodonMatrixScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CodonMatrixScore *] * * Return [UNKN ] Undocumented return value [CodonMatrixScore *] * */ CodonMatrixScore * free_CodonMatrixScore(CodonMatrixScore * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a CodonMatrixScore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/codonmatrix.h0000644000175000001440000001440010670453712017335 0ustar philippusers#ifndef DYNAMITEcodonmatrixHEADERFILE #define DYNAMITEcodonmatrixHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" struct Wise2_CodonMatrix { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability prob[125][125]; } ; /* CodonMatrix defined */ #ifndef DYNAMITE_DEFINED_CodonMatrix typedef struct Wise2_CodonMatrix Wise2_CodonMatrix; #define CodonMatrix Wise2_CodonMatrix #define DYNAMITE_DEFINED_CodonMatrix #endif struct Wise2_CodonMatrixScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score score[125][125]; } ; /* CodonMatrixScore defined */ #ifndef DYNAMITE_DEFINED_CodonMatrixScore typedef struct Wise2_CodonMatrixScore Wise2_CodonMatrixScore; #define CodonMatrixScore Wise2_CodonMatrixScore #define DYNAMITE_DEFINED_CodonMatrixScore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: naive_CodonMatrixScore_from_prob(ct,cm) * * Descrip: Combines CodonMatrixScore_from_CodonMatrix and naive_CodonMatrix * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: cm [UNKN ] Undocumented argument [CompProb *] * * Return [UNKN ] Undocumented return value [CodonMatrixScore *] * */ CodonMatrixScore * Wise2_naive_CodonMatrixScore_from_prob(CodonTable * ct,CompProb * cm); #define naive_CodonMatrixScore_from_prob Wise2_naive_CodonMatrixScore_from_prob /* Function: CodonMatrixScore_from_CodonMatrix(cm) * * Descrip: Makes a CodonMatrixScore from a CodonMatrix * * * Arg: cm [UNKN ] Undocumented argument [CodonMatrix *] * * Return [UNKN ] Undocumented return value [CodonMatrixScore *] * */ CodonMatrixScore * Wise2_CodonMatrixScore_from_CodonMatrix(CodonMatrix * cm); #define CodonMatrixScore_from_CodonMatrix Wise2_CodonMatrixScore_from_CodonMatrix /* Function: naive_CodonMatrix(ct,comp) * * Descrip: Builds a probability matrix * No codon bias * No errors * N codons score 1.0, stop codons probability 0.00001 * * * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: comp [UNKN ] Undocumented argument [CompProb *] * * Return [UNKN ] Undocumented return value [CodonMatrix *] * */ CodonMatrix * Wise2_naive_CodonMatrix(CodonTable * ct,CompProb * comp); #define naive_CodonMatrix Wise2_naive_CodonMatrix /* Function: naive_CodonMatrixScore(ct,comp) * * Descrip: Builds a codon matrix from CompMat which assummes: * No codon Bias * No errors * N codons score 0, stop codons score ?? * * * Arg: ct [UNKN ] CodonTable for codon->aa mapping [CodonTable *] * Arg: comp [UNKN ] Comparison matrix for the score of the individual access [CompMat *] * * Return [UNKN ] Undocumented return value [CodonMatrixScore *] * */ CodonMatrixScore * Wise2_naive_CodonMatrixScore(CodonTable * ct,CompMat * comp); #define naive_CodonMatrixScore Wise2_naive_CodonMatrixScore /* Function: show_CodonMatrixScore(cms,ct,ofp) * * Descrip: Shows a codonmatrix * * * Arg: cms [UNKN ] Undocumented argument [CodonMatrixScore *] * Arg: ct [UNKN ] Undocumented argument [CodonTable *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_CodonMatrixScore(CodonMatrixScore * cms,CodonTable * ct,FILE * ofp); #define show_CodonMatrixScore Wise2_show_CodonMatrixScore /* Function: hard_link_CodonMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CodonMatrix *] * * Return [UNKN ] Undocumented return value [CodonMatrix *] * */ CodonMatrix * Wise2_hard_link_CodonMatrix(CodonMatrix * obj); #define hard_link_CodonMatrix Wise2_hard_link_CodonMatrix /* Function: CodonMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CodonMatrix *] * */ CodonMatrix * Wise2_CodonMatrix_alloc(void); #define CodonMatrix_alloc Wise2_CodonMatrix_alloc /* Function: free_CodonMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CodonMatrix *] * * Return [UNKN ] Undocumented return value [CodonMatrix *] * */ CodonMatrix * Wise2_free_CodonMatrix(CodonMatrix * obj); #define free_CodonMatrix Wise2_free_CodonMatrix /* Function: hard_link_CodonMatrixScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [CodonMatrixScore *] * * Return [UNKN ] Undocumented return value [CodonMatrixScore *] * */ CodonMatrixScore * Wise2_hard_link_CodonMatrixScore(CodonMatrixScore * obj); #define hard_link_CodonMatrixScore Wise2_hard_link_CodonMatrixScore /* Function: CodonMatrixScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [CodonMatrixScore *] * */ CodonMatrixScore * Wise2_CodonMatrixScore_alloc(void); #define CodonMatrixScore_alloc Wise2_CodonMatrixScore_alloc /* Function: free_CodonMatrixScore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [CodonMatrixScore *] * * Return [UNKN ] Undocumented return value [CodonMatrixScore *] * */ CodonMatrixScore * Wise2_free_CodonMatrixScore(CodonMatrixScore * obj); #define free_CodonMatrixScore Wise2_free_CodonMatrixScore /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/compmat.typemap0000644000175000001440000000034410670453712017700 0ustar philippusers TYPEMAP Wise2_CompMat * T_Wise2_CompMat INPUT T_Wise2_CompMat $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_CompMat *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_CompMat sv_setref_pv($arg, "Wise2::CompMat", (void*) $var); wise-2.4.1/src/dynlibsrc/dprunimpl.dy0000644000175000001440000000473307553750750017225 0ustar philippusers %{ #include "wisebase.h" #include "basematrix.h" typedef enum DPRunImplMemory { DPIM_Default = 543, DPIM_Explicit, DPIM_Linear } DPRunImplMemory; %} struct DPRunImpl DPRunImplMemory memory !def="DPIM_Default" int kbyte_size !def="100000" boolean debug !def="FALSE" boolean paldebug !def="FALSE" boolean should_cache !def="TRUE" BaseMatrix * cache; %{ #include "dprunimpl.h" %func Clones a DPRunImpl - particularly sensible for cached cases %% DPRunImpl * clone_DPRunImpl(DPRunImpl * dpri) { DPRunImpl * out; out = DPRunImpl_alloc(); out->memory = dpri->memory; out->kbyte_size = dpri->kbyte_size; out->debug = dpri->debug; out->paldebug = dpri->paldebug; out->should_cache = dpri->should_cache; out->cache = NULL; return out; } %func Shows help functions for DPRunImpl %% void show_help_DPRunImpl(FILE * ofp) { fprintf(ofp,"Dynamic programming matrix implementation\n"); fprintf(ofp," -dymem memory style [default/linear/explicit]\n"); fprintf(ofp," -kbyte memory amount to use [4000]\n"); fprintf(ofp," -[no]dycache implicitly cache dy matrix usage (default yes)\n"); fprintf(ofp," -dydebug drop into dynamite dp matrix debugger\n"); fprintf(ofp," -paldebug print PackAln after debugger run if used\n"); } %func Makes a DPRunImpl object from stripping from a command line %% DPRunImpl * new_DPRunImpl_from_argv(int * argc,char ** argv) { DPRunImpl * out; char * temp; out = DPRunImpl_alloc(); if( (temp = strip_out_assigned_argument(argc,argv,"dymem")) != NULL ) { if( strcmp(temp,"explicit") == 0) { out->memory = DPIM_Explicit; } else if( strcmp(temp,"linear") == 0 ) { out->memory = DPIM_Linear; } else if( strcmp(temp,"default") == 0 ) { out->memory = DPIM_Default; } else { warn("String [%s] for dynamic memory layout is not recognised",temp); free_DPRunImpl(out); return NULL; } } if( (temp = strip_out_assigned_argument(argc,argv,"kbyte")) != NULL ) { if( is_integer_string(temp,&out->kbyte_size) == FALSE ) { warn("String [%s] for dynamic memory size is not recognised",temp); free_DPRunImpl(out); return NULL; } } strip_out_boolean_def_argument(argc,argv,"dycache",&out->should_cache); if(strip_out_boolean_argument(argc,argv,"dydebug") == TRUE ) { out->debug = 1; out->memory = DPIM_Explicit; } if(strip_out_boolean_argument(argc,argv,"paldebug") == TRUE ) { out->paldebug = 1; } return out; } %} wise-2.4.1/src/dynlibsrc/hscore.pod0000644000175000001440000002441410670453712016632 0ustar philippusers=head1 NAME hscore module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item Hscore =item DataScore =item DataEntry =back =head1 DESCRIPTION =head2 Object Hscore =over =item ds Type [DataScore **] List No documentation =item store Type [DataScoreStorage **] List No documentation =item his Type [Histogram *] Scalar No documentation =item score_level Type [double] Scalar passed into should_store function =item should_store Type [boolean (*should_store)(int given_score,double internal_score_level)] Scalar No documentation =item score_to_his Type [float (*score_to_his)(int given_score)] Scalar No documentation =item report_level Type [int] Scalar number of sequences to report on =item total Type [long] Scalar total number of scores (duplicated info in histogram) =back Holds the information about a db search. Meant to be very lightweight The histogram is carried for on-the-fly histogram storage outside of the database. The idea is that the function should_store will tell whether the datascore structure should be stored (if it is NULL, it is always stored). The score_to_his function maps the score in datascore to the float in Histogram, allowing the scoring system of the search method to be on a different basis to the scoring system of the histogram. For most times, this is going to be Score2Bits To prevent too much dependency, the 'standard' way of making a histogram that has a bits cut off level is done using functions in the dynlibcross module (cross code), as it needs both Hscore and Probability. You should read dynlibcross module for the constructors for Hscore =head2 Member functions of Hscore =over =item minimum_score_Hscore &Wise2::Hscore::minimum_score_Hscore(hs) gets the minimum score from Hscore Argument hs [UNKN ] Undocumented argument [Hscore *] Return [UNKN ] Undocumented return value [int] =item maximum_score_Hscore &Wise2::Hscore::maximum_score_Hscore(hs) gets the maximum score from Hscore Argument hs [UNKN ] Undocumented argument [Hscore *] Return [UNKN ] Undocumented return value [int] =item sort_Hscore_by_score &Wise2::Hscore::sort_Hscore_by_score(hs) As it says, sorts the high score by its score Argument hs [UNKN ] Hscore to be sorted [Hscore *] Return [UNKN ] Undocumented return value [void] =item length &Wise2::Hscore::length(obj) Returns the number of datascores in the hscore structure Argument obj [READ ] Hscore object [Hscore *] Return [UNKN ] Undocumented return value [int] =item datascore &Wise2::Hscore::datascore(hs,i) Returns the specific datascore held at this position. This requires a considerable amount of memory duplication, so please dont process all your results by looping through this. Argument hs [READ ] Hscore object [Hscore *] Argument i [UNKN ] position to be read [int] Return [OWNER] New datascore object [DataScore *] =item score &Wise2::Hscore::score(hs,i) Returns the score of the specific datascore held at this position. Argument hs [READ ] Hscore object [Hscore *] Argument i [UNKN ] position to be read [int] Return [UNKN ] score [int] =item evalue &Wise2::Hscore::evalue(hs,i) Returns the evalue of the specific datascore held at this position. Argument hs [READ ] Hscore object [Hscore *] Argument i [UNKN ] position to be read [int] Return [UNKN ] evalue [double] =item show &Wise2::Hscore::show(hs,ofp) The most baby-talk showing of Hscore Argument hs [UNKN ] Undocumented argument [Hscore *] Argument ofp [UNKN ] Undocumented argument [FILE *] Return [UNKN ] Undocumented return value [void] =item hard_link_Hscore &Wise2::Hscore::hard_link_Hscore(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [Hscore *] Return [UNKN ] Undocumented return value [Hscore *] =item Hscore_alloc_std &Wise2::Hscore::Hscore_alloc_std(void) Equivalent to Hscore_alloc_len(HscoreLISTLENGTH) Return [UNKN ] Undocumented return value [Hscore *] =back =head2 Object DataScore =over =item query Type [DataEntry *] Scalar No documentation =item target Type [DataEntry *] Scalar No documentation =item score Type [int] Scalar No documentation =item evalue Type [double] Scalar No documentation =item is_stored Type [int] Scalar No documentation =back The basic one entry vs one entry structure. Each of the DataEntry datastructures actually store the information about the indexing etc. =head2 Member functions of DataScore =over =item hard_link_DataScore &Wise2::DataScore::hard_link_DataScore(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [DataScore *] Return [UNKN ] Undocumented return value [DataScore *] =item alloc &Wise2::DataScore::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [DataScore *] =item set_query &Wise2::DataScore::set_query(obj,query) Replace member variable query For use principly by API functions Argument obj [UNKN ] Object holding the variable [DataScore *] Argument query [OWNER] New value of the variable [DataEntry *] Return [SOFT ] member variable query [boolean] =item query &Wise2::DataScore::query(obj) Access member variable query For use principly by API functions Argument obj [UNKN ] Object holding the variable [DataScore *] Return [SOFT ] member variable query [DataEntry *] =item set_target &Wise2::DataScore::set_target(obj,target) Replace member variable target For use principly by API functions Argument obj [UNKN ] Object holding the variable [DataScore *] Argument target [OWNER] New value of the variable [DataEntry *] Return [SOFT ] member variable target [boolean] =item target &Wise2::DataScore::target(obj) Access member variable target For use principly by API functions Argument obj [UNKN ] Object holding the variable [DataScore *] Return [SOFT ] member variable target [DataEntry *] =item set_score &Wise2::DataScore::set_score(obj,score) Replace member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [DataScore *] Argument score [OWNER] New value of the variable [int] Return [SOFT ] member variable score [boolean] =item score &Wise2::DataScore::score(obj) Access member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [DataScore *] Return [SOFT ] member variable score [int] =item set_evalue &Wise2::DataScore::set_evalue(obj,evalue) Replace member variable evalue For use principly by API functions Argument obj [UNKN ] Object holding the variable [DataScore *] Argument evalue [OWNER] New value of the variable [double] Return [SOFT ] member variable evalue [boolean] =item evalue &Wise2::DataScore::evalue(obj) Access member variable evalue For use principly by API functions Argument obj [UNKN ] Object holding the variable [DataScore *] Return [SOFT ] member variable evalue [double] =back =head2 Object DataEntry =over =item name Type [char *] Scalar name of the entry =item data[DATAENTRYSTDPOINTS] Type [int] Scalar space for algorithms to use =item is_reversed Type [boolean] Scalar for sequences. handy =item byte_position Type [BytePosition] Scalar useful for indexers - hopefully long enough! =item filename Type [char *] Scalar useful for indexers etc. =back A lightweight structure to represent the information a db search algorithm will want to store and *nothing* more about a single entry This object will be stored twice (once for the target and once for the query) for each comparison: they probably will be on different databases and different objects. The data field is just a number (8 at the moment) of int's available for databases to store useful information (eg, length) of the object. A number of extra fields are provided for convience sake for indexers, including byte_position and filename. =head2 Member functions of DataEntry =over =item hard_link_DataEntry &Wise2::DataEntry::hard_link_DataEntry(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [DataEntry *] Return [UNKN ] Undocumented return value [DataEntry *] =item alloc &Wise2::DataEntry::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [DataEntry *] =item set_name &Wise2::DataEntry::set_name(obj,name) Replace member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [DataEntry *] Argument name [OWNER] New value of the variable [char *] Return [SOFT ] member variable name [boolean] =item name &Wise2::DataEntry::name(obj) Access member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [DataEntry *] Return [SOFT ] member variable name [char *] =item set_is_reversed &Wise2::DataEntry::set_is_reversed(obj,is_reversed) Replace member variable is_reversed For use principly by API functions Argument obj [UNKN ] Object holding the variable [DataEntry *] Argument is_reversed [OWNER] New value of the variable [boolean] Return [SOFT ] member variable is_reversed [boolean] =item is_reversed &Wise2::DataEntry::is_reversed(obj) Access member variable is_reversed For use principly by API functions Argument obj [UNKN ] Object holding the variable [DataEntry *] Return [SOFT ] member variable is_reversed [boolean] =back =over =item std_score_Hscore &Wise2::std_score_Hscore(cut_off,report_stagger) This gives you a standard Hscore module with a cutoff in score Argument cut_off [UNKN ] Undocumented argument [int] Argument report_stagger [UNKN ] Undocumented argument [int] Return [UNKN ] Undocumented return value [Hscore *] =back wise-2.4.1/src/dynlibsrc/hscore.tex0000644000175000001440000001755210670453712016655 0ustar philippusers\section{hscore} \label{module_hscore} This module contains the following objects \begin{itemize} \item \ref{object_Hscore} Hscore \item \ref{object_DataScore} DataScore \item \ref{object_DataEntry} DataEntry \item This module also contains some factory methods \end{itemize} \subsection{hscore factory methods} \subsubsection{std_score_Hscore} \begin{description} \item[External C] {\tt Wise2_std_score_Hscore (cut_off,report_stagger)} \item[Perl] {\tt &Wise2::std_score_Hscore (cut_off,report_stagger)} \end{description} Arguments \begin{description} \item[cut_off] [UNKN ] Undocumented argument [int] \item[report_stagger] [UNKN ] Undocumented argument [int] \item[returns] [UNKN ] Undocumented return value [Hscore *] \end{description} This gives you a standard Hscore module with a cutoff in score \subsection{Object Hscore} \label{object_Hscore} The Hscore object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{ds} Type [DataScore ** : List] No documentation \item{store} Type [DataScoreStorage ** : List] No documentation \item{his} Type [Histogram * : Scalar] No documentation \item{score_level} Type [double : Scalar] passed into should_store function \item{should_store} Type [boolean (*should_store)(int given_score,double internal_score_level) : Scalar] No documentation \item{score_to_his} Type [float (*score_to_his)(int given_score) : Scalar] No documentation \item{report_level} Type [int : Scalar] number of sequences to report on \item{total} Type [long : Scalar] total number of scores (duplicated info in histogram) \end{description} Holds the information about a db search. Meant to be very lightweight The histogram is carried for on-the-fly histogram storage outside of the database. The idea is that the function should_store will tell whether the datascore structure should be stored (if it is NULL, it is always stored). The score_to_his function maps the score in datascore to the float in Histogram, allowing the scoring system of the search method to be on a different basis to the scoring system of the histogram. For most times, this is going to be Score2Bits To prevent too much dependency, the 'standard' way of making a histogram that has a bits cut off level is done using functions in the dynlibcross module (cross code), as it needs both Hscore and Probability. You should read dynlibcross module for the constructors for Hscore Member functions of Hscore \subsubsection{minimum_score_Hscore} \begin{description} \item[External C] {\tt Wise2_minimum_score_Hscore (hs)} \item[Perl] {\tt &Wise2::Hscore::minimum_score_Hscore (hs)} \item[Perl-OOP call] {\tt $obj->minimum_score_Hscore()} \end{description} Arguments \begin{description} \item[hs] [UNKN ] Undocumented argument [Hscore *] \item[returns] [UNKN ] Undocumented return value [int] \end{description} gets the minimum score from Hscore \subsubsection{maximum_score_Hscore} \begin{description} \item[External C] {\tt Wise2_maximum_score_Hscore (hs)} \item[Perl] {\tt &Wise2::Hscore::maximum_score_Hscore (hs)} \item[Perl-OOP call] {\tt $obj->maximum_score_Hscore()} \end{description} Arguments \begin{description} \item[hs] [UNKN ] Undocumented argument [Hscore *] \item[returns] [UNKN ] Undocumented return value [int] \end{description} gets the maximum score from Hscore \subsubsection{sort_Hscore_by_score} \begin{description} \item[External C] {\tt Wise2_sort_Hscore_by_score (hs)} \item[Perl] {\tt &Wise2::Hscore::sort_Hscore_by_score (hs)} \item[Perl-OOP call] {\tt $obj->sort_Hscore_by_score()} \end{description} Arguments \begin{description} \item[hs] [UNKN ] Hscore to be sorted [Hscore *] \item[returns] Nothing - no return value \end{description} As it says, sorts the high score by its score \subsubsection{length_datascore_Hscore} \begin{description} \item[External C] {\tt Wise2_length_datascore_Hscore (obj)} \item[Perl] {\tt &Wise2::Hscore::length (obj)} \item[Perl-OOP call] {\tt $obj->length()} \end{description} Arguments \begin{description} \item[obj] [READ ] Hscore object [Hscore *] \item[returns] [UNKN ] Undocumented return value [int] \end{description} Returns the number of datascores in the hscore structure \subsubsection{get_datascore_Hscore} \begin{description} \item[External C] {\tt Wise2_get_datascore_Hscore (hs,i)} \item[Perl] {\tt &Wise2::Hscore::datascore (hs,i)} \item[Perl-OOP call] {\tt $obj->datascore(i)} \end{description} Arguments \begin{description} \item[hs] [READ ] Hscore object [Hscore *] \item[i] [UNKN ] position to be read [int] \item[returns] [OWNER] New datascore object [DataScore *] \end{description} Returns the specific datascore held at this position. This requires a considerable amount of memory duplication, so please dont process all your results by looping through this. \subsubsection{get_score_Hscore} \begin{description} \item[External C] {\tt Wise2_get_score_Hscore (hs,i)} \item[Perl] {\tt &Wise2::Hscore::score (hs,i)} \item[Perl-OOP call] {\tt $obj->score(i)} \end{description} Arguments \begin{description} \item[hs] [READ ] Hscore object [Hscore *] \item[i] [UNKN ] position to be read [int] \item[returns] [UNKN ] score [int] \end{description} Returns the score of the specific datascore held at this position. \subsubsection{get_evalue_Hscore} \begin{description} \item[External C] {\tt Wise2_get_evalue_Hscore (hs,i)} \item[Perl] {\tt &Wise2::Hscore::evalue (hs,i)} \item[Perl-OOP call] {\tt $obj->evalue(i)} \end{description} Arguments \begin{description} \item[hs] [READ ] Hscore object [Hscore *] \item[i] [UNKN ] position to be read [int] \item[returns] [UNKN ] evalue [double] \end{description} Returns the evalue of the specific datascore held at this position. \subsubsection{basic_show_Hscore} \begin{description} \item[External C] {\tt Wise2_basic_show_Hscore (hs,ofp)} \item[Perl] {\tt &Wise2::Hscore::show (hs,ofp)} \item[Perl-OOP call] {\tt $obj->show(ofp)} \end{description} Arguments \begin{description} \item[hs] [UNKN ] Undocumented argument [Hscore *] \item[ofp] [UNKN ] Undocumented argument [FILE *] \item[returns] Nothing - no return value \end{description} The most baby-talk showing of Hscore \subsection{Object DataScore} \label{object_DataScore} The DataScore object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{query} Type [DataEntry * : Scalar] No documentation \item{target} Type [DataEntry * : Scalar] No documentation \item{score} Type [int : Scalar] No documentation \item{evalue} Type [double : Scalar] No documentation \item{is_stored} Type [int : Scalar] No documentation \end{description} The basic one entry vs one entry structure. Each of the DataEntry datastructures actually store the information about the indexing etc. Member functions of DataScore \subsection{Object DataEntry} \label{object_DataEntry} The DataEntry object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{name} Type [char * : Scalar] name of the entry \item{data[DATAENTRYSTDPOINTS]} Type [int : Scalar] space for algorithms to use \item{is_reversed} Type [boolean : Scalar] for sequences. handy \item{byte_position} Type [BytePosition : Scalar] useful for indexers - hopefully long enough! \item{filename} Type [char * : Scalar] useful for indexers etc. \end{description} A lightweight structure to represent the information a db search algorithm will want to store and *nothing* more about a single entry This object will be stored twice (once for the target and once for the query) for each comparison: they probably will be on different databases and different objects. The data field is just a number (8 at the moment) of int's available for databases to store useful information (eg, length) of the object. A number of extra fields are provided for convience sake for indexers, including byte_position and filename. Member functions of DataEntry wise-2.4.1/src/dynlibsrc/codon.pod0000644000175000001440000001725610670453712016457 0ustar philippusers=head1 NAME codon module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item CodonTable =back =head1 DESCRIPTION =head2 Object CodonTable =over =item codon_str[125] Type [aa] Scalar No documentation =item name Type [char *] Scalar No documentation =back The codon table provides a mapping from the 64 codons to the 20 amino acids. The rest of the modules provides assorted codon<->base<->amino acid mappings. Probably the trickiest thing is that there are two different types of representations of codons. One in base 5 (N being the 5th base), providing 0-124 inclusive codon numbers. These numbers are the ones going to be principly used in most calculations. However, it is often very useful to use 0-63 numbers, for example in the precise definition of the codon table. =head2 Member functions of CodonTable =over =item read_CodonTable_file &Wise2::CodonTable::read_CodonTable_file(file) Opens filename, reads it as if a Ewan style codon table and closes. Argument file [READ ] filename to open [char *] Return [OWNER] A codon-table, NULL if error [CodonTable *] =item read_CodonTable &Wise2::CodonTable::read_CodonTable(ifp) reads a codon table from a filestream in Ewan format. As Ewan format is really bad and has no start/stop this will effectively read to the end of the file. Ooops. Argument ifp [READ ] file input [FILE *] Return [UNKN ] Undocumented return value [CodonTable *] =item aminoacid_from_seq &Wise2::CodonTable::aminoacid_from_seq(ct,seq) Returns the amino acid for this position in the DNA sequence Takes the pointer +1 and +2 points. No error checks implemented. Probably a mistake ;) Argument ct [READ ] codon table [CodonTable *] Argument seq [READ ] pointer to DNA chars [char *] Return [UNKN ] an amino acid char (A-Z) [aa] =item aminoacid_from_codon &Wise2::CodonTable::aminoacid_from_codon(ct,c) returns amino acid for this codon number (NB codon numbers 0-125) Argument ct [READ ] codon table [CodonTable *] Argument c [READ ] codon number [codon] Return [READ ] aminoacid that is this codon (X for ambiguous, * for stop) [aa] =item is_stop_codon &Wise2::CodonTable::is_stop_codon(c,ct) tells you whether this codon number is really a stop in this translation table Argument c [READ ] codon number [codon] Argument ct [READ ] codon table [CodonTable *] Return [UNKN ] TRUE if is stop, FALSE otherwise [boolean] =item is_valid_aminoacid &Wise2::CodonTable::is_valid_aminoacid(ct,c) Tells you if this letter (c) is recognised as a valid amino acid in this codon table Argument ct [READ ] Codon Table [CodonTable *] Argument c [UNKN ] aminoacid [char] Return [UNKN ] TRUE if valid, FALSE if not. [boolean] =item hard_link_CodonTable &Wise2::CodonTable::hard_link_CodonTable(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [CodonTable *] Return [UNKN ] Undocumented return value [CodonTable *] =item alloc &Wise2::CodonTable::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [CodonTable *] =item set_name &Wise2::CodonTable::set_name(obj,name) Replace member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [CodonTable *] Argument name [OWNER] New value of the variable [char *] Return [SOFT ] member variable name [boolean] =item name &Wise2::CodonTable::name(obj) Access member variable name For use principly by API functions Argument obj [UNKN ] Object holding the variable [CodonTable *] Return [SOFT ] member variable name [char *] =back =over =item is_non_ambiguous_codon_seq &Wise2::is_non_ambiguous_codon_seq(seq) Tells you if this codon is a real codon Argument seq [READ ] pointer to DNA sequence [char *] Return [UNKN ] TRUE if real codon, FALSE if contains N's [boolean] =item codon_from_base4_codon &Wise2::codon_from_base4_codon(c) maps a 0-63 codon to a 0-123 codon. Suprisingly useful. Argument c [UNKN ] Undocumented argument [int] Return [UNKN ] Undocumented return value [codon] =item base4_codon_from_codon &Wise2::base4_codon_from_codon(c) maps a 0-125 codon to a 0-63 codon. If ambiguous then returns 64 having issued a warning. Argument c [READ ] codon 0-125 [codon] Return [UNKN ] base 4 codon (0-63) [int] =item has_random_bases &Wise2::has_random_bases(c) Tests to see if this codon number has any N's in it Argument c [READ ] codon number 0-124 [codon] Return [UNKN ] TRUE if has N's , FALSE otherwise [boolean] =item permute_possible_random_bases &Wise2::permute_possible_random_bases(c,one,two,three) Bizarely useful function for calculating ambiguity scores. This takes the codon c, and for each possible base, if it is N, replaces it with one, two or three. If the base is not N, it remains the same Argument c [READ ] codon number [codon] Argument one [READ ] base to replace first position if N [base] Argument two [READ ] base to replace second position if N [base] Argument three [READ ] base to replace third position if N [base] Return [UNKN ] codon number [codon] =item base_from_codon &Wise2::base_from_codon(c,pos) Probably not the best function to use for this, but useful. Takes a codon and with pos being 1,2,3 gives you the firt,second of third base Argument c [UNKN ] Undocumented argument [codon] Argument pos [UNKN ] Undocumented argument [int] Return [UNKN ] Undocumented return value [base] =item codon_from_seq &Wise2::codon_from_seq(seq) takes an ASCII coded pointer to a 3 base pair sequence (it could be the part of a sequence: it only assummes that the seq points with 3 chars at pos 0,1,2 in C coordinates from seq. No NULL is required). It ives back the codon as made from standard mapping, ie, 25*base_1+5*base_2 + base3 being a number from 0-124 inc. Argument seq [UNKN ] pointer to sequence of at least 3 chrs long. [char *] Return [UNKN ] Undocumented return value [codon] =item base4_codon_from_seq &Wise2::base4_codon_from_seq(seq) Sometimes it is more useful to work in base64, ie, non N. this functions does the same thing as /codon_from_seq but produces a seq being 16*base1 + 4 *base2 + base3 Argument seq [UNKN ] pointer to sequence of at least 3 chrs long [char *] Return [UNKN ] Undocumented return value [int] =item char_from_base &Wise2::char_from_base(b) maps a base number (-04 inc) to A,T,G,C,N Argument b [UNKN ] Undocumented argument [base] Return [UNKN ] Undocumented return value [char] =item base_from_char &Wise2::base_from_char(c) maps a char (atcgn) to number, case insensitive, returns BASE_N if not atcgn Argument c [UNKN ] Undocumented argument [char] Return [UNKN ] Undocumented return value [base] =item char_complement_base &Wise2::char_complement_base(c) the char equivalent of /complement_base. this gives the complement in char of a base in char. Does not check for non ATGCN Argument c [UNKN ] Undocumented argument [char] Return [UNKN ] Undocumented return value [char] =item complement_base &Wise2::complement_base(b) gives back the complement as a number ofthe base (given as a number) Argument b [UNKN ] Undocumented argument [base] Return [UNKN ] Undocumented return value [base] =back wise-2.4.1/src/dynlibsrc/codon.tex0000644000175000001440000002347210670453712016472 0ustar philippusers\section{codon} \label{module_codon} This module contains the following objects \begin{itemize} \item \ref{object_CodonTable} CodonTable \item This module also contains some factory methods \end{itemize} \subsection{codon factory methods} \subsubsection{is_non_ambiguous_codon_seq} \begin{description} \item[External C] {\tt Wise2_is_non_ambiguous_codon_seq (seq)} \item[Perl] {\tt &Wise2::is_non_ambiguous_codon_seq (seq)} \end{description} Arguments \begin{description} \item[seq] [READ ] pointer to DNA sequence [char *] \item[returns] [UNKN ] TRUE if real codon, FALSE if contains N's [boolean] \end{description} Tells you if this codon is a real codon \subsubsection{codon_from_base4_codon} \begin{description} \item[External C] {\tt Wise2_codon_from_base4_codon (c)} \item[Perl] {\tt &Wise2::codon_from_base4_codon (c)} \end{description} Arguments \begin{description} \item[c] [UNKN ] Undocumented argument [int] \item[returns] [UNKN ] Undocumented return value [codon] \end{description} maps a 0-63 codon to a 0-123 codon. Suprisingly useful. \subsubsection{base4_codon_from_codon} \begin{description} \item[External C] {\tt Wise2_base4_codon_from_codon (c)} \item[Perl] {\tt &Wise2::base4_codon_from_codon (c)} \end{description} Arguments \begin{description} \item[c] [READ ] codon 0-125 [codon] \item[returns] [UNKN ] base 4 codon (0-63) [int] \end{description} maps a 0-125 codon to a 0-63 codon. If ambiguous then returns 64 having issued a warning. \subsubsection{has_random_bases} \begin{description} \item[External C] {\tt Wise2_has_random_bases (c)} \item[Perl] {\tt &Wise2::has_random_bases (c)} \end{description} Arguments \begin{description} \item[c] [READ ] codon number 0-124 [codon] \item[returns] [UNKN ] TRUE if has N's , FALSE otherwise [boolean] \end{description} Tests to see if this codon number has any N's in it \subsubsection{permute_possible_random_bases} \begin{description} \item[External C] {\tt Wise2_permute_possible_random_bases (c,one,two,three)} \item[Perl] {\tt &Wise2::permute_possible_random_bases (c,one,two,three)} \end{description} Arguments \begin{description} \item[c] [READ ] codon number [codon] \item[one] [READ ] base to replace first position if N [base] \item[two] [READ ] base to replace second position if N [base] \item[three] [READ ] base to replace third position if N [base] \item[returns] [UNKN ] codon number [codon] \end{description} Bizarely useful function for calculating ambiguity scores. This takes the codon c, and for each possible base, if it is N, replaces it with one, two or three. If the base is not N, it remains the same \subsubsection{base_from_codon} \begin{description} \item[External C] {\tt Wise2_base_from_codon (c,pos)} \item[Perl] {\tt &Wise2::base_from_codon (c,pos)} \end{description} Arguments \begin{description} \item[c] [UNKN ] Undocumented argument [codon] \item[pos] [UNKN ] Undocumented argument [int] \item[returns] [UNKN ] Undocumented return value [base] \end{description} Probably not the best function to use for this, but useful. Takes a codon and with pos being 1,2,3 gives you the firt,second of third base \subsubsection{codon_from_seq} \begin{description} \item[External C] {\tt Wise2_codon_from_seq (seq)} \item[Perl] {\tt &Wise2::codon_from_seq (seq)} \end{description} Arguments \begin{description} \item[seq] [UNKN ] pointer to sequence of at least 3 chrs long. [char *] \item[returns] [UNKN ] Undocumented return value [codon] \end{description} takes an ASCII coded pointer to a 3 base pair sequence (it could be the part of a sequence: it only assummes that the seq points with 3 chars at pos 0,1,2 in C coordinates from seq. No NULL is required). It ives back the codon as made from standard mapping, ie, 25*base_1+5*base_2 + base3 being a number from 0-124 inc. \subsubsection{base4_codon_from_seq} \begin{description} \item[External C] {\tt Wise2_base4_codon_from_seq (seq)} \item[Perl] {\tt &Wise2::base4_codon_from_seq (seq)} \end{description} Arguments \begin{description} \item[seq] [UNKN ] pointer to sequence of at least 3 chrs long [char *] \item[returns] [UNKN ] Undocumented return value [int] \end{description} Sometimes it is more useful to work in base64, ie, non N. this functions does the same thing as /codon_from_seq but produces a seq being 16*base1 + 4 *base2 + base3 \subsubsection{char_from_base} \begin{description} \item[External C] {\tt Wise2_char_from_base (b)} \item[Perl] {\tt &Wise2::char_from_base (b)} \end{description} Arguments \begin{description} \item[b] [UNKN ] Undocumented argument [base] \item[returns] [UNKN ] Undocumented return value [char] \end{description} maps a base number (-04 inc) to A,T,G,C,N \subsubsection{base_from_char} \begin{description} \item[External C] {\tt Wise2_base_from_char (c)} \item[Perl] {\tt &Wise2::base_from_char (c)} \end{description} Arguments \begin{description} \item[c] [UNKN ] Undocumented argument [char] \item[returns] [UNKN ] Undocumented return value [base] \end{description} maps a char (atcgn) to number, case insensitive, returns BASE_N if not atcgn \subsubsection{char_complement_base} \begin{description} \item[External C] {\tt Wise2_char_complement_base (c)} \item[Perl] {\tt &Wise2::char_complement_base (c)} \end{description} Arguments \begin{description} \item[c] [UNKN ] Undocumented argument [char] \item[returns] [UNKN ] Undocumented return value [char] \end{description} the char equivalent of /complement_base. this gives the complement in char of a base in char. Does not check for non ATGCN \subsubsection{complement_base} \begin{description} \item[External C] {\tt Wise2_complement_base (b)} \item[Perl] {\tt &Wise2::complement_base (b)} \end{description} Arguments \begin{description} \item[b] [UNKN ] Undocumented argument [base] \item[returns] [UNKN ] Undocumented return value [base] \end{description} gives back the complement as a number ofthe base (given as a number) \subsection{Object CodonTable} \label{object_CodonTable} The CodonTable object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{codon_str[125]} Type [aa : Scalar] No documentation \item{name} Type [char * : Scalar] No documentation \end{description} The codon table provides a mapping from the 64 codons to the 20 amino acids. The rest of the modules provides assorted codon<->base<->amino acid mappings. Probably the trickiest thing is that there are two different types of representations of codons. One in base 5 (N being the 5th base), providing 0-124 inclusive codon numbers. These numbers are the ones going to be principly used in most calculations. However, it is often very useful to use 0-63 numbers, for example in the precise definition of the codon table. Member functions of CodonTable \subsubsection{read_CodonTable_file} \begin{description} \item[External C] {\tt Wise2_read_CodonTable_file (file)} \item[Perl] {\tt &Wise2::CodonTable::read_CodonTable_file (file)} \item[Perl-OOP call] {\tt $obj->read_CodonTable_file()} \end{description} Arguments \begin{description} \item[file] [READ ] filename to open [char *] \item[returns] [OWNER] A codon-table, NULL if error [CodonTable *] \end{description} Opens filename, reads it as if a Ewan style codon table and closes. \subsubsection{read_CodonTable} \begin{description} \item[External C] {\tt Wise2_read_CodonTable (ifp)} \item[Perl] {\tt &Wise2::CodonTable::read_CodonTable (ifp)} \item[Perl-OOP call] {\tt $obj->read_CodonTable()} \end{description} Arguments \begin{description} \item[ifp] [READ ] file input [FILE *] \item[returns] [UNKN ] Undocumented return value [CodonTable *] \end{description} reads a codon table from a filestream in Ewan format. As Ewan format is really bad and has no start/stop this will effectively read to the end of the file. Ooops. \subsubsection{aminoacid_from_seq} \begin{description} \item[External C] {\tt Wise2_aminoacid_from_seq (ct,seq)} \item[Perl] {\tt &Wise2::CodonTable::aminoacid_from_seq (ct,seq)} \item[Perl-OOP call] {\tt $obj->aminoacid_from_seq(seq)} \end{description} Arguments \begin{description} \item[ct] [READ ] codon table [CodonTable *] \item[seq] [READ ] pointer to DNA chars [char *] \item[returns] [UNKN ] an amino acid char (A-Z) [aa] \end{description} Returns the amino acid for this position in the DNA sequence Takes the pointer +1 and +2 points. No error checks implemented. Probably a mistake ;) \subsubsection{aminoacid_from_codon} \begin{description} \item[External C] {\tt Wise2_aminoacid_from_codon (ct,c)} \item[Perl] {\tt &Wise2::CodonTable::aminoacid_from_codon (ct,c)} \item[Perl-OOP call] {\tt $obj->aminoacid_from_codon(c)} \end{description} Arguments \begin{description} \item[ct] [READ ] codon table [CodonTable *] \item[c] [READ ] codon number [codon] \item[returns] [READ ] aminoacid that is this codon (X for ambiguous, * for stop) [aa] \end{description} returns amino acid for this codon number (NB codon numbers 0-125) \subsubsection{is_stop_codon} \begin{description} \item[External C] {\tt Wise2_is_stop_codon (c,ct)} \item[Perl] {\tt &Wise2::CodonTable::is_stop_codon (c,ct)} \item[Perl-OOP call] {\tt $obj->is_stop_codon(ct)} \end{description} Arguments \begin{description} \item[c] [READ ] codon number [codon] \item[ct] [READ ] codon table [CodonTable *] \item[returns] [UNKN ] TRUE if is stop, FALSE otherwise [boolean] \end{description} tells you whether this codon number is really a stop in this translation table \subsubsection{is_valid_aminoacid} \begin{description} \item[External C] {\tt Wise2_is_valid_aminoacid (ct,c)} \item[Perl] {\tt &Wise2::CodonTable::is_valid_aminoacid (ct,c)} \item[Perl-OOP call] {\tt $obj->is_valid_aminoacid(c)} \end{description} Arguments \begin{description} \item[ct] [READ ] Codon Table [CodonTable *] \item[c] [UNKN ] aminoacid [char] \item[returns] [UNKN ] TRUE if valid, FALSE if not. [boolean] \end{description} Tells you if this letter (c) is recognised as a valid amino acid in this codon table wise-2.4.1/src/dynlibsrc/histogram.pod0000644000175000001440000002251610670453712017345 0ustar philippusers=head1 NAME histogram module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item Histogram =back =head1 DESCRIPTION =head2 Object Histogram =over =item histogram Type [int* ] Scalar counts of hits =item min Type [int] Scalar elem 0 of histogram == min =item max Type [int] Scalar last elem of histogram == max =item highscore Type [int] Scalar highest active elem has this score =item lowscore Type [int] Scalar lowest active elem has this score =item lumpsize Type [int] Scalar when resizing, overalloc by this =item total Type [int] Scalar total # of hits counted =item expect Type [float*] Scalar expected counts of hits =item fit_type Type [int] Scalar flag indicating distribution type =item param[3] Type [float] Scalar parameters used for fits =item chisq Type [float] Scalar chi-squared val for goodness of fit =item chip Type [float] Scalar P value for chisquared =back This Object came from Sean Eddy excellent histogram package. He donated it free of all restrictions to allow it to be used in the Wise2 package without complicated licensing terms. He is a *very* nice man. It was made into a dynamite object so that a) External ports to scripting languages would be trivial b) cooperation with future versions of histogram.c would be possible. Here is the rest of the documentation from sean. Keep a score histogram. The main implementation issue here is that the range of scores is unknown, and will go negative. histogram is a 0..max-min array that represents the range min..max. A given score is indexed in histogram array as score-min. The AddToHistogram function deals with dynamically resizing the histogram array when necessary. =head2 Member functions of Histogram =over =item UnfitHistogram &Wise2::Histogram::UnfitHistogram(h) This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Free only the theoretical fit part of a histogram. Argument h [UNKN ] Undocumented argument [Histogram *] Return [UNKN ] Undocumented return value [void] =item add &Wise2::Histogram::add(h,sc) This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Bump the appropriate counter in a histogram structure, given a score. The score is rounded off from float precision to the next lower integer. Argument h [UNKN ] Undocumented argument [Histogram *] Argument sc [UNKN ] Undocumented argument [float] Return [UNKN ] Undocumented return value [void] =item show &Wise2::Histogram::show(h,fp) This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Print a "prettified" histogram to a file pointer. Deliberately a look-and-feel clone of Bill Pearson's excellent FASTA output. Argument h [UNKN ] histogram to print [Histogram *] Argument fp [UNKN ] open file to print to (stdout works) [FILE *] Return [UNKN ] Undocumented return value [void] =item EVDBasicFit &Wise2::Histogram::EVDBasicFit(h) This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Fit a score histogram to the extreme value distribution. Set the parameters lambda and mu in the histogram structure. Fill in the expected values in the histogram. Calculate a chi-square test as a measure of goodness of fit. This is the basic version of ExtremeValueFitHistogram(), in a nonrobust form: simple linear regression with no outlier pruning. Methods: Uses a linear regression fitting method [Collins88,Lawless82] Argument h [UNKN ] histogram to fit [Histogram *] Return [UNKN ] Undocumented return value [void] =item fit_EVD &Wise2::Histogram::fit_EVD(h,censor,high_hint) This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Purpose: Fit a score histogram to the extreme value distribution. Set the parameters lambda and mu in the histogram structure. Calculate a chi-square test as a measure of goodness of fit. Methods: Uses a maximum likelihood method [Lawless82]. Lower outliers are removed by censoring the data below the peak. Upper outliers are removed iteratively using method described by [Mott92]. Argument h [UNKN ] histogram to fit [Histogram *] Argument censor [UNKN ] TRUE to censor data left of the peak [int] Argument high_hint [UNKN ] score cutoff; above this are real hits that arent fit [float] Return [UNKN ] if fit is judged to be valid else 0 if fit is invalid (too few seqs.) [int] =item set_EVD &Wise2::Histogram::set_EVD(h,mu,lambda,lowbound,highbound,wonka,ndegrees) This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Instead of fitting the histogram to an EVD, simply set the EVD parameters from an external source. Note that the fudge factor "wonka" is used /only/ for prettification of expected/theoretical curves in PrintASCIIHistogram displays. Argument h [UNKN ] the histogram to set [Histogram *] Argument mu [UNKN ] mu location parameter [float] Argument lambda [UNKN ] lambda scale parameter [float] Argument lowbound [UNKN ] low bound of the histogram that was fit [float] Argument highbound [UNKN ] high bound of histogram that was fit [float] Argument wonka [UNKN ] fudge factor; fraction of hits estimated to be "EVD-like" [float] Argument ndegrees [UNKN ] extra degrees of freedom to subtract in chi2 test: [int] Return [UNKN ] Undocumented return value [void] =item fit_Gaussian &Wise2::Histogram::fit_Gaussian(h,high_hint) This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Fit a score histogram to a Gaussian distribution. Set the parameters mean and sd in the histogram structure, as well as a chi-squared test for goodness of fit. Argument h [UNKN ] histogram to fit [Histogram *] Argument high_hint [UNKN ] score cutoff; above this are `real' hits that aren't fit [float] Return [UNKN ] if fit is judged to be valid else 0 if fit is invalid (too few seqs.) [int] =item set_Gaussian &Wise2::Histogram::set_Gaussian(h,mean,sd) This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Instead of fitting the histogram to a Gaussian, simply set the Gaussian parameters from an external source. Argument h [UNKN ] Undocumented argument [Histogram *] Argument mean [UNKN ] Undocumented argument [float] Argument sd [UNKN ] Undocumented argument [float] Return [UNKN ] Undocumented return value [void] =item evalue &Wise2::Histogram::evalue(his,score) This is a convient short cut for calculating expected values from the histogram of results Argument his [UNKN ] Histogram object [Histogram *] Argument score [UNKN ] score you want the evalue for [double] Return [UNKN ] Undocumented return value [double] =item hard_link_Histogram &Wise2::Histogram::hard_link_Histogram(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [Histogram *] Return [UNKN ] Undocumented return value [Histogram *] =item alloc &Wise2::Histogram::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [Histogram *] =back =over =item new_Histogram &Wise2::new_Histogram(min,max,lumpsize) This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Allocate and return a histogram structure. min and max are your best guess. They need not be absolutely correct; the histogram will expand dynamically to accomodate scores that exceed these suggested bounds. The amount that the histogram grows by is set by "lumpsize" Was called AllocHistorgram new_Historgram is more wise2-ish Argument min [UNKN ] minimum score (integer) [int] Argument max [UNKN ] maximum score (integer) [int] Argument lumpsize [UNKN ] when reallocating histogram, the reallocation amount [int] Return [UNKN ] Undocumented return value [Histogram *] =back wise-2.4.1/src/dynlibsrc/histogram.tex0000644000175000001440000002571410670453712017366 0ustar philippusers\section{histogram} \label{module_histogram} This module contains the following objects \begin{itemize} \item \ref{object_Histogram} Histogram \item This module also contains some factory methods \end{itemize} \subsection{histogram factory methods} \subsubsection{new_Histogram} \begin{description} \item[External C] {\tt Wise2_new_Histogram (min,max,lumpsize)} \item[Perl] {\tt &Wise2::new_Histogram (min,max,lumpsize)} \end{description} Arguments \begin{description} \item[min] [UNKN ] minimum score (integer) [int] \item[max] [UNKN ] maximum score (integer) [int] \item[lumpsize] [UNKN ] when reallocating histogram, the reallocation amount [int] \item[returns] [UNKN ] Undocumented return value [Histogram *] \end{description} This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Allocate and return a histogram structure. min and max are your best guess. They need not be absolutely correct; the histogram will expand dynamically to accomodate scores that exceed these suggested bounds. The amount that the histogram grows by is set by "lumpsize" Was called AllocHistorgram new_Historgram is more wise2-ish \subsection{Object Histogram} \label{object_Histogram} The Histogram object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{histogram} Type [int* : Scalar] counts of hits \item{min} Type [int : Scalar] elem 0 of histogram == min \item{max} Type [int : Scalar] last elem of histogram == max \item{highscore} Type [int : Scalar] highest active elem has this score \item{lowscore} Type [int : Scalar] lowest active elem has this score \item{lumpsize} Type [int : Scalar] when resizing, overalloc by this \item{total} Type [int : Scalar] total # of hits counted \item{expect} Type [float* : Scalar] expected counts of hits \item{fit_type} Type [int : Scalar] flag indicating distribution type \item{param[3]} Type [float : Scalar] parameters used for fits \item{chisq} Type [float : Scalar] chi-squared val for goodness of fit \item{chip} Type [float : Scalar] P value for chisquared \end{description} This Object came from Sean Eddy excellent histogram package. He donated it free of all restrictions to allow it to be used in the Wise2 package without complicated licensing terms. He is a *very* nice man. It was made into a dynamite object so that \begin{verbatim} a) External ports to scripting languages would be trivial b) cooperation with future versions of histogram.c would be possible. \end{verbatim} Here is the rest of the documentation from sean. Keep a score histogram. The main implementation issue here is that the range of scores is unknown, and will go negative. histogram is a 0..max-min array that represents the range min..max. A given score is indexed in histogram array as score-min. The AddToHistogram function deals with dynamically resizing the histogram array when necessary. Member functions of Histogram \subsubsection{UnfitHistogram} \begin{description} \item[External C] {\tt Wise2_UnfitHistogram (h)} \item[Perl] {\tt &Wise2::Histogram::UnfitHistogram (h)} \item[Perl-OOP call] {\tt $obj->UnfitHistogram()} \end{description} Arguments \begin{description} \item[h] [UNKN ] Undocumented argument [Histogram *] \item[returns] Nothing - no return value \end{description} This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Free only the theoretical fit part of a histogram. \subsubsection{AddToHistogram} \begin{description} \item[External C] {\tt Wise2_AddToHistogram (h,sc)} \item[Perl] {\tt &Wise2::Histogram::add (h,sc)} \item[Perl-OOP call] {\tt $obj->add(sc)} \end{description} Arguments \begin{description} \item[h] [UNKN ] Undocumented argument [Histogram *] \item[sc] [UNKN ] Undocumented argument [float] \item[returns] Nothing - no return value \end{description} This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Bump the appropriate counter in a histogram structure, given a score. The score is rounded off from float precision to the next lower integer. \subsubsection{PrintASCIIHistogram} \begin{description} \item[External C] {\tt Wise2_PrintASCIIHistogram (h,fp)} \item[Perl] {\tt &Wise2::Histogram::show (h,fp)} \item[Perl-OOP call] {\tt $obj->show(fp)} \end{description} Arguments \begin{description} \item[h] [UNKN ] histogram to print [Histogram *] \item[fp] [UNKN ] open file to print to (stdout works) [FILE *] \item[returns] Nothing - no return value \end{description} This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Print a "prettified" histogram to a file pointer. Deliberately a look-and-feel clone of Bill Pearson's excellent FASTA output. \subsubsection{EVDBasicFit} \begin{description} \item[External C] {\tt Wise2_EVDBasicFit (h)} \item[Perl] {\tt &Wise2::Histogram::EVDBasicFit (h)} \item[Perl-OOP call] {\tt $obj->EVDBasicFit()} \end{description} Arguments \begin{description} \item[h] [UNKN ] histogram to fit [Histogram *] \item[returns] Nothing - no return value \end{description} This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Fit a score histogram to the extreme value distribution. Set the parameters lambda and mu in the histogram structure. Fill in the expected values in the histogram. Calculate a chi-square test as a measure of goodness of fit. This is the basic version of ExtremeValueFitHistogram(), in a nonrobust form: simple linear regression with no outlier pruning. Methods: Uses a linear regression fitting method [Collins88,Lawless82] \subsubsection{ExtremeValueFitHistogram} \begin{description} \item[External C] {\tt Wise2_ExtremeValueFitHistogram (h,censor,high_hint)} \item[Perl] {\tt &Wise2::Histogram::fit_EVD (h,censor,high_hint)} \item[Perl-OOP call] {\tt $obj->fit_EVD(censor,high_hint)} \end{description} Arguments \begin{description} \item[h] [UNKN ] histogram to fit [Histogram *] \item[censor] [UNKN ] TRUE to censor data left of the peak [int] \item[high_hint] [UNKN ] score cutoff; above this are real hits that arent fit [float] \item[returns] [UNKN ] if fit is judged to be valid else 0 if fit is invalid (too few seqs.) [int] \end{description} This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Purpose: Fit a score histogram to the extreme value distribution. Set the parameters lambda and mu in the histogram structure. Calculate a chi-square test as a measure of goodness of fit. Methods: Uses a maximum likelihood method [Lawless82]. Lower outliers are removed by censoring the data below the peak. Upper outliers are removed iteratively using method described by [Mott92]. \subsubsection{ExtremeValueSetHistogram} \begin{description} \item[External C] {\tt Wise2_ExtremeValueSetHistogram (h,mu,lambda,lowbound,highbound,wonka,ndegrees)} \item[Perl] {\tt &Wise2::Histogram::set_EVD (h,mu,lambda,lowbound,highbound,wonka,ndegrees)} \item[Perl-OOP call] {\tt $obj->set_EVD(mu,lambda,lowbound,highbound,wonka,ndegrees)} \end{description} Arguments \begin{description} \item[h] [UNKN ] the histogram to set [Histogram *] \item[mu] [UNKN ] mu location parameter [float] \item[lambda] [UNKN ] lambda scale parameter [float] \item[lowbound] [UNKN ] low bound of the histogram that was fit [float] \item[highbound] [UNKN ] high bound of histogram that was fit [float] \item[wonka] [UNKN ] fudge factor; fraction of hits estimated to be "EVD-like" [float] \item[ndegrees] [UNKN ] extra degrees of freedom to subtract in chi2 test: [int] \item[returns] Nothing - no return value \end{description} This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Instead of fitting the histogram to an EVD, simply set the EVD parameters from an external source. Note that the fudge factor "wonka" is used /only/ for prettification of expected/theoretical curves in PrintASCIIHistogram displays. \subsubsection{GaussianFitHistogram} \begin{description} \item[External C] {\tt Wise2_GaussianFitHistogram (h,high_hint)} \item[Perl] {\tt &Wise2::Histogram::fit_Gaussian (h,high_hint)} \item[Perl-OOP call] {\tt $obj->fit_Gaussian(high_hint)} \end{description} Arguments \begin{description} \item[h] [UNKN ] histogram to fit [Histogram *] \item[high_hint] [UNKN ] score cutoff; above this are `real' hits that aren't fit [float] \item[returns] [UNKN ] if fit is judged to be valid else 0 if fit is invalid (too few seqs.) [int] \end{description} This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Fit a score histogram to a Gaussian distribution. Set the parameters mean and sd in the histogram structure, as well as a chi-squared test for goodness of fit. \subsubsection{GaussianSetHistogram} \begin{description} \item[External C] {\tt Wise2_GaussianSetHistogram (h,mean,sd)} \item[Perl] {\tt &Wise2::Histogram::set_Gaussian (h,mean,sd)} \item[Perl-OOP call] {\tt $obj->set_Gaussian(mean,sd)} \end{description} Arguments \begin{description} \item[h] [UNKN ] Undocumented argument [Histogram *] \item[mean] [UNKN ] Undocumented argument [float] \item[sd] [UNKN ] Undocumented argument [float] \item[returns] Nothing - no return value \end{description} This function was written by Sean Eddy as part of his HMMer2 histogram.c module Converted by Ewan Birney to Dynamite source June 98. Copyright is LGPL. For more info read READMEs Documentation: Instead of fitting the histogram to a Gaussian, simply set the Gaussian parameters from an external source. \subsubsection{Evalue_from_Histogram} \begin{description} \item[External C] {\tt Wise2_Evalue_from_Histogram (his,score)} \item[Perl] {\tt &Wise2::Histogram::evalue (his,score)} \item[Perl-OOP call] {\tt $obj->evalue(score)} \end{description} Arguments \begin{description} \item[his] [UNKN ] Histogram object [Histogram *] \item[score] [UNKN ] score you want the evalue for [double] \item[returns] [UNKN ] Undocumented return value [double] \end{description} This is a convient short cut for calculating expected values from the histogram of results wise-2.4.1/src/dynlibsrc/cdna.dy0000644000175000001440000000633607313404537016112 0ustar philippusers %{ #include "sequence.h" %} api object cDNA des free_cDNA func truncate_cDNA func read_fasta_file_cDNA func cDNA_name func cDNA_length func cDNA_seqchar func cDNA_from_Sequence endobject endapi struct cDNA Sequence * baseseq; #SequenceErrorList * se // list of the sequence errors %{ #include "cdna.h" %func Truncates a cDNA sequence. Basically uses the /magic_trunc_Sequence function (of course!) It does not alter cdna, rather it returns a new sequence with that truncation %arg cdna r cDNA that is truncated %% cDNA * truncate_cDNA(cDNA * cdna,int start,int stop) { return cDNA_from_Sequence(magic_trunc_Sequence(cdna->baseseq,start,stop)); } %func Reads a fasta file assumming that it is cDNA. Will complain if it is not, and return NULL. %arg filename filename to be opened and read %% cDNA * read_fasta_file_cDNA(char * filename) { Sequence * seq; seq = read_fasta_file_Sequence(filename); if( seq == NULL ) { return NULL; } return cDNA_from_Sequence(seq); } %func Reads a fasta file assumming that it is cDNA. Will complain if it is not, and return NULL. %arg ifp file point to be read from %% cDNA * read_fasta_cDNA(FILE * ifp) { Sequence * seq; seq = read_fasta_Sequence(ifp); if( seq == NULL ) { return NULL; } return cDNA_from_Sequence(seq); } %func Reads a efetch specified query Uses, of course /read_efetch_Sequence %arg estr r efetch string which is read %% cDNA * read_efetch_cDNA(char * estr) { return cDNA_from_Sequence(read_efetch_Sequence(estr)); } %func Reads a SRS sequence using srs4 syntax. Uses, of course, /read_SRS_Sequence %arg srsquery r string query representing SRS name %% cDNA * read_SRS_cDNA(char * srsquery) { return cDNA_from_Sequence(read_SRS_Sequence(srsquery)); } %func Returns the name of the cDNA %arg %% char * cDNA_name(cDNA * cdna) { return cdna->baseseq->name; } %func Returns the length of the cDNA %arg %% int cDNA_length(cDNA * cdna) { return cdna->baseseq->len; } %func Returns sequence character at this position. %arg cdna cDNA pos position in cDNA to get char %% char cDNA_seqchar(cDNA * cdna,int pos) { return cdna->baseseq->seq[pos]; } %func makes a new cDNA from a Sequence. It owns the Sequence memory, ie will attempt a /free_Sequence on the structure when /free_cDNA is called If you want to give this cDNA this Sequence and forget about it, then just hand it this sequence and set seq to NULL (no need to free it). If you intend to use the sequence object elsewhere outside of the cDNA datastructure then use cDNA_from_Sequence(/hard_link_Sequence(seq)) %arg seq o Sequence to make cDNA from %% cDNA * cDNA_from_Sequence(Sequence * seq) { cDNA * out; int conv; if( seq == NULL ) { warn("Trying to make a cdna sequence from a NULL baseseq."); return NULL; } if( is_dna_Sequence(seq) == FALSE ) { warn("Trying to make a cDNA sequence from a non cDNA base sequence [%s].",seq->name); return NULL; } uppercase_Sequence(seq); force_to_dna_Sequence(seq,1.0,&conv); if( conv != 0 ) { log_full_error(INFO,0,"In making %s a cdna sequence, converted %d bases (%2.1f%%) to N's from non ATGCN",seq->name,conv,(double)conv*100/(double)seq->len); } out = cDNA_alloc(); out->baseseq = seq; return out; } %} wise-2.4.1/src/dynlibsrc/cdna.xs0000644000175000001440000000316310670453712016122 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::cDNA Wise2_cDNA * truncate_cDNA(cdna,start,stop) Wise2_cDNA * cdna int start int stop CODE: RETVAL = Wise2_truncate_cDNA(cdna,start,stop); OUTPUT: RETVAL Wise2_cDNA * read_fasta_file_cDNA(filename) char * filename CODE: RETVAL = Wise2_read_fasta_file_cDNA(filename); OUTPUT: RETVAL char * cDNA_name(cdna) Wise2_cDNA * cdna CODE: RETVAL = Wise2_cDNA_name(cdna); OUTPUT: RETVAL int cDNA_length(cdna) Wise2_cDNA * cdna CODE: RETVAL = Wise2_cDNA_length(cdna); OUTPUT: RETVAL char cDNA_seqchar(cdna,pos) Wise2_cDNA * cdna int pos CODE: RETVAL = Wise2_cDNA_seqchar(cdna,pos); OUTPUT: RETVAL Wise2_cDNA * cDNA_from_Sequence(seq) Wise2_Sequence * seq CODE: RETVAL = Wise2_cDNA_from_Sequence(Wise2_hard_link_Sequence(seq)); OUTPUT: RETVAL Wise2_cDNA * hard_link_cDNA(obj) Wise2_cDNA * obj CODE: RETVAL = Wise2_hard_link_cDNA(obj); OUTPUT: RETVAL Wise2_cDNA * alloc() CODE: RETVAL = Wise2_cDNA_alloc(); OUTPUT: RETVAL boolean set_baseseq(obj,baseseq) Wise2_cDNA * obj Wise2_Sequence * baseseq CODE: RETVAL = Wise2_replace_baseseq_cDNA(obj,Wise2_hard_link_Sequence(baseseq)); OUTPUT: RETVAL Wise2_Sequence * baseseq(obj) Wise2_cDNA * obj INIT: Wise2_Sequence * temp; CODE: temp = Wise2_hard_link_Sequence(Wise2_access_baseseq_cDNA(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_cDNA * new(class) char * class PPCODE: Wise2_cDNA * out; out = Wise2_cDNA_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_cDNA * obj CODE: Wise2_free_cDNA(obj); MODULE = Wise2 PACKAGE = Wise2 wise-2.4.1/src/dynlibsrc/dprunimpl.c0000644000175000001440000001224210670453712017015 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dprunimpl.h" /* Function: clone_DPRunImpl(dpri) * * Descrip: Clones a DPRunImpl - particularly sensible * for cached cases * * * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [DPRunImpl *] * */ # line 33 "dprunimpl.dy" DPRunImpl * clone_DPRunImpl(DPRunImpl * dpri) { DPRunImpl * out; out = DPRunImpl_alloc(); out->memory = dpri->memory; out->kbyte_size = dpri->kbyte_size; out->debug = dpri->debug; out->paldebug = dpri->paldebug; out->should_cache = dpri->should_cache; out->cache = NULL; return out; } /* Function: show_help_DPRunImpl(ofp) * * Descrip: Shows help functions for DPRunImpl * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 52 "dprunimpl.dy" void show_help_DPRunImpl(FILE * ofp) { fprintf(ofp,"Dynamic programming matrix implementation\n"); fprintf(ofp," -dymem memory style [default/linear/explicit]\n"); fprintf(ofp," -kbyte memory amount to use [4000]\n"); fprintf(ofp," -[no]dycache implicitly cache dy matrix usage (default yes)\n"); fprintf(ofp," -dydebug drop into dynamite dp matrix debugger\n"); fprintf(ofp," -paldebug print PackAln after debugger run if used\n"); } /* Function: new_DPRunImpl_from_argv(argc,argv) * * Descrip: Makes a DPRunImpl object from stripping from * a command line * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [DPRunImpl *] * */ # line 66 "dprunimpl.dy" DPRunImpl * new_DPRunImpl_from_argv(int * argc,char ** argv) { DPRunImpl * out; char * temp; out = DPRunImpl_alloc(); if( (temp = strip_out_assigned_argument(argc,argv,"dymem")) != NULL ) { if( strcmp(temp,"explicit") == 0) { out->memory = DPIM_Explicit; } else if( strcmp(temp,"linear") == 0 ) { out->memory = DPIM_Linear; } else if( strcmp(temp,"default") == 0 ) { out->memory = DPIM_Default; } else { warn("String [%s] for dynamic memory layout is not recognised",temp); free_DPRunImpl(out); return NULL; } } if( (temp = strip_out_assigned_argument(argc,argv,"kbyte")) != NULL ) { if( is_integer_string(temp,&out->kbyte_size) == FALSE ) { warn("String [%s] for dynamic memory size is not recognised",temp); free_DPRunImpl(out); return NULL; } } strip_out_boolean_def_argument(argc,argv,"dycache",&out->should_cache); if(strip_out_boolean_argument(argc,argv,"dydebug") == TRUE ) { out->debug = 1; out->memory = DPIM_Explicit; } if(strip_out_boolean_argument(argc,argv,"paldebug") == TRUE ) { out->paldebug = 1; } return out; } # line 107 "dprunimpl.c" /* Function: hard_link_DPRunImpl(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DPRunImpl *] * * Return [UNKN ] Undocumented return value [DPRunImpl *] * */ DPRunImpl * hard_link_DPRunImpl(DPRunImpl * obj) { if( obj == NULL ) { warn("Trying to hard link to a DPRunImpl object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DPRunImpl_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DPRunImpl *] * */ DPRunImpl * DPRunImpl_alloc(void) { DPRunImpl * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DPRunImpl *) ckalloc (sizeof(DPRunImpl))) == NULL) { warn("DPRunImpl_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->memory = DPIM_Default; out->kbyte_size = 100000; out->debug = FALSE; out->paldebug = FALSE; out->should_cache = TRUE; out->cache = NULL; return out; } /* Function: free_DPRunImpl(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DPRunImpl *] * * Return [UNKN ] Undocumented return value [DPRunImpl *] * */ DPRunImpl * free_DPRunImpl(DPRunImpl * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DPRunImpl obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->cache != NULL) free_BaseMatrix(obj->cache); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/dprunimpl.h0000644000175000001440000000667410670453712017036 0ustar philippusers#ifndef DYNAMITEdprunimplHEADERFILE #define DYNAMITEdprunimplHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "basematrix.h" typedef enum DPRunImplMemory { DPIM_Default = 543, DPIM_Explicit, DPIM_Linear } DPRunImplMemory; struct Wise2_DPRunImpl { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DPRunImplMemory memory; int kbyte_size; boolean debug; boolean paldebug; boolean should_cache; BaseMatrix * cache; } ; /* DPRunImpl defined */ #ifndef DYNAMITE_DEFINED_DPRunImpl typedef struct Wise2_DPRunImpl Wise2_DPRunImpl; #define DPRunImpl Wise2_DPRunImpl #define DYNAMITE_DEFINED_DPRunImpl #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: clone_DPRunImpl(dpri) * * Descrip: Clones a DPRunImpl - particularly sensible * for cached cases * * * Arg: dpri [UNKN ] Undocumented argument [DPRunImpl *] * * Return [UNKN ] Undocumented return value [DPRunImpl *] * */ DPRunImpl * Wise2_clone_DPRunImpl(DPRunImpl * dpri); #define clone_DPRunImpl Wise2_clone_DPRunImpl /* Function: show_help_DPRunImpl(ofp) * * Descrip: Shows help functions for DPRunImpl * * * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_help_DPRunImpl(FILE * ofp); #define show_help_DPRunImpl Wise2_show_help_DPRunImpl /* Function: new_DPRunImpl_from_argv(argc,argv) * * Descrip: Makes a DPRunImpl object from stripping from * a command line * * * Arg: argc [UNKN ] Undocumented argument [int *] * Arg: argv [UNKN ] Undocumented argument [char **] * * Return [UNKN ] Undocumented return value [DPRunImpl *] * */ DPRunImpl * Wise2_new_DPRunImpl_from_argv(int * argc,char ** argv); #define new_DPRunImpl_from_argv Wise2_new_DPRunImpl_from_argv /* Function: hard_link_DPRunImpl(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DPRunImpl *] * * Return [UNKN ] Undocumented return value [DPRunImpl *] * */ DPRunImpl * Wise2_hard_link_DPRunImpl(DPRunImpl * obj); #define hard_link_DPRunImpl Wise2_hard_link_DPRunImpl /* Function: DPRunImpl_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DPRunImpl *] * */ DPRunImpl * Wise2_DPRunImpl_alloc(void); #define DPRunImpl_alloc Wise2_DPRunImpl_alloc /* Function: free_DPRunImpl(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DPRunImpl *] * * Return [UNKN ] Undocumented return value [DPRunImpl *] * */ DPRunImpl * Wise2_free_DPRunImpl(DPRunImpl * obj); #define free_DPRunImpl Wise2_free_DPRunImpl /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/btcanvas.c0000644000175000001440000002341310670453712016606 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "btcanvas.h" /* Function: can_get_paste_area_btCanvas(btc,length) * * Descrip: This returns whether there is room for length * of chars in this line. If not, advance a line * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * Arg: length [UNKN ] length of block wanted [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 70 "btcanvas.dy" boolean can_get_paste_area_btCanvas(btCanvas * btc,int length) { return ((*btc->can_get_paste_area)(btc,length)); } /* Function: advance_line_btCanvas(btc) * * Descrip: Advances the canvas to the next line * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 81 "btcanvas.dy" boolean advance_line_btCanvas(btCanvas * btc) { return ((*btc->advance_line)(btc)); } /* Function: get_reserved_left_btCanvas(btc) * * Descrip: This gets a paste-able area at the left hand * side of block * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ # line 92 "btcanvas.dy" btPasteArea * get_reserved_left_btCanvas(btCanvas * btc) { return ((*btc->get_reserved_left)(btc)); } /* Function: get_reserved_right_btCanvas(btc) * * Descrip: This gets a paste-able area at the right hand * side of block * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ # line 102 "btcanvas.dy" btPasteArea * get_reserved_right_btCanvas(btCanvas * btc) { return ((*btc->get_reserved_right)(btc)); } /* Function: get_paste_area_btCanvas(btc,length) * * Descrip: This gets a paste-able area of a certain length from * the current cursor. NULL on error * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * Arg: length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ # line 113 "btcanvas.dy" btPasteArea * get_paste_area_btCanvas(btCanvas * btc,int length) { return ((*btc->get_paste_area)(btc,length)); } /* Function: paste_substr_btPasteArea(bta,x,y,str,len,map_func,dir,format) * * Descrip: This will paste the substr of length len (obviously this could * not be a \0 terminated string) starting from str[0] into btCanvas * If map_func is non NULL, it converts each of the characters * using the map_func first. This is surprisingly useful. * * map_func can be NULL, in which case the characters are just * used as seen * * Length has to be less than 64 chars * * * Arg: bta [UNKN ] PasteArea to be used [btPasteArea *] * Arg: x [UNKN ] x position of start of string [int] * Arg: y [UNKN ] y position of start of string [int] * Arg: str [READ ] string to get the substr from to be pasted [const char *] * Arg: len [READ ] length of the substr [int] * Arg: map_func [FUNCP] Function to specifiy the mapping of chars from str to display [char (*map_func] * Arg: dir [UNKN ] direction (BC_UP, BC_DOWN, BC_RIGHT, BC_LEFT) [btCanvasDirection] * Arg: format [UNKN ] format (if recognised by the cnavas) [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 138 "btcanvas.dy" boolean paste_substr_btPasteArea(btPasteArea * bta,int x,int y,const char * str,int len,char (*map_func)(char),btCanvasDirection dir,int format) { char buf[64]; const char *run; int i; for(run=str,i=0;i bta->length || y > bta->height ) { warn("Trying to paste a character into an unpasteable position [%d,%d] into [%d,%d]",x,y,bta->length,bta->height); return FALSE; } return ((*bta->paste_char))(bta,x,y,c,format); } /* Function: free_btPasteArea(obj) * * Descrip: Specialised deconstructor. Ensures the * data structures are freed * * * Arg: obj [WRITE] btPasteArea obj to be destroyed [btPasteArea *] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ # line 216 "btcanvas.dy" btPasteArea * free_btPasteArea(btPasteArea * obj) { return ((*obj->decons))(obj); } /* Function: free_btCanvas(obj) * * Descrip: Specialised deconstructor. Ensures the * data structures are freed * * * Arg: obj [WRITE] btCanvas obj to be destroyed [btCanvas *] * * Return [UNKN ] Undocumented return value [btCanvas *] * */ # line 228 "btcanvas.dy" btCanvas * free_btCanvas(btCanvas * obj) { return ((*obj->decons))(obj); } # line 223 "btcanvas.c" /* Function: hard_link_btPasteArea(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [btPasteArea *] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ btPasteArea * hard_link_btPasteArea(btPasteArea * obj) { if( obj == NULL ) { warn("Trying to hard link to a btPasteArea object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: btPasteArea_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ btPasteArea * btPasteArea_alloc(void) { btPasteArea * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(btPasteArea *) ckalloc (sizeof(btPasteArea))) == NULL) { warn("btPasteArea_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = 0; out->height = 0; out->length = 0; out->paste_char = NULL; out->canvas_data = NULL; out->decons = NULL; return out; } /* Function: hard_link_btCanvas(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [btCanvas *] * * Return [UNKN ] Undocumented return value [btCanvas *] * */ btCanvas * hard_link_btCanvas(btCanvas * obj) { if( obj == NULL ) { warn("Trying to hard link to a btCanvas object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: btCanvas_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [btCanvas *] * */ btCanvas * btCanvas_alloc(void) { btCanvas * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(btCanvas *) ckalloc (sizeof(btCanvas))) == NULL) { warn("btCanvas_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->type = 0; out->height = 0; out->res_right = 0; out->res_left = 0; out->can_get_paste_area = NULL; out->advance_line = NULL; out->get_paste_area = NULL; out->get_reserved_right = NULL; out->get_reserved_left = NULL; out->canvas_data = NULL; out->decons = NULL; return out; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/btcanvas.h0000644000175000001440000002404510670453712016615 0ustar philippusers#ifndef DYNAMITEbtcanvasHEADERFILE #define DYNAMITEbtcanvasHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" typedef enum btCanvasDirection { BC_UP, BC_DOWN, BC_RIGHT, BC_LEFT } btCanvasDirection ; /* * Icky... icky.. icky * * Would you believe, some C compilers will not allow typdef's * inside function to pointer definitions in structures... * * Hence - hard coded package names!!!! Yuk!!! * */ #ifndef DYNAMITE_DEFINED_btPastArea typedef struct Wise2_btPastArea Wise2_btPastArea; #define btPastArea Wise2_btPastArea #define DYNAMITE_DEFINED_btPastArea #endif #ifndef DYNAMITE_DEFINED_btCanvas typedef struct Wise2_btCanvas Wise2_btCanvas; #define btCanvas Wise2_btCanvas #define DYNAMITE_DEFINED_btCanvas #endif struct Wise2_btPasteArea { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; int height; int length; boolean (*paste_char)(struct Wise2_btPasteArea *,int,int,char,int); void * canvas_data; struct Wise2_btPasteArea * (*decons)(struct Wise2_btPasteArea * bt); } ; /* btPasteArea defined */ #ifndef DYNAMITE_DEFINED_btPasteArea typedef struct Wise2_btPasteArea Wise2_btPasteArea; #define btPasteArea Wise2_btPasteArea #define DYNAMITE_DEFINED_btPasteArea #endif /* Object btCanvas * * Descrip: No Description * */ struct Wise2_btCanvas { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int type; int height; int res_right; int res_left; boolean (*can_get_paste_area)(struct Wise2_btCanvas *,int); boolean (*advance_line)(struct Wise2_btCanvas *); struct Wise2_btPasteArea * (*get_paste_area)(struct Wise2_btCanvas *,int); struct Wise2_btPasteArea * (*get_reserved_right)(struct Wise2_btCanvas *); struct Wise2_btPasteArea * (*get_reserved_left)(struct Wise2_btCanvas *); void * canvas_data; struct Wise2_btCanvas * (*decons)(struct Wise2_btCanvas * btc); } ; /* btCanvas defined */ #ifndef DYNAMITE_DEFINED_btCanvas typedef struct Wise2_btCanvas Wise2_btCanvas; #define btCanvas Wise2_btCanvas #define DYNAMITE_DEFINED_btCanvas #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: can_get_paste_area_btCanvas(btc,length) * * Descrip: This returns whether there is room for length * of chars in this line. If not, advance a line * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * Arg: length [UNKN ] length of block wanted [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_can_get_paste_area_btCanvas(btCanvas * btc,int length); #define can_get_paste_area_btCanvas Wise2_can_get_paste_area_btCanvas /* Function: advance_line_btCanvas(btc) * * Descrip: Advances the canvas to the next line * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_advance_line_btCanvas(btCanvas * btc); #define advance_line_btCanvas Wise2_advance_line_btCanvas /* Function: get_reserved_left_btCanvas(btc) * * Descrip: This gets a paste-able area at the left hand * side of block * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ btPasteArea * Wise2_get_reserved_left_btCanvas(btCanvas * btc); #define get_reserved_left_btCanvas Wise2_get_reserved_left_btCanvas /* Function: get_reserved_right_btCanvas(btc) * * Descrip: This gets a paste-able area at the right hand * side of block * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ btPasteArea * Wise2_get_reserved_right_btCanvas(btCanvas * btc); #define get_reserved_right_btCanvas Wise2_get_reserved_right_btCanvas /* Function: get_paste_area_btCanvas(btc,length) * * Descrip: This gets a paste-able area of a certain length from * the current cursor. NULL on error * * * Arg: btc [UNKN ] Undocumented argument [btCanvas *] * Arg: length [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ btPasteArea * Wise2_get_paste_area_btCanvas(btCanvas * btc,int length); #define get_paste_area_btCanvas Wise2_get_paste_area_btCanvas /* Function: paste_substr_btPasteArea(bta,x,y,str,len,map_func,dir,format) * * Descrip: This will paste the substr of length len (obviously this could * not be a \0 terminated string) starting from str[0] into btCanvas * If map_func is non NULL, it converts each of the characters * using the map_func first. This is surprisingly useful. * * map_func can be NULL, in which case the characters are just * used as seen * * Length has to be less than 64 chars * * * Arg: bta [UNKN ] PasteArea to be used [btPasteArea *] * Arg: x [UNKN ] x position of start of string [int] * Arg: y [UNKN ] y position of start of string [int] * Arg: str [READ ] string to get the substr from to be pasted [const char *] * Arg: len [READ ] length of the substr [int] * Arg: map_func [FUNCP] Function to specifiy the mapping of chars from str to display [char (*map_func] * Arg: dir [UNKN ] direction (BC_UP, BC_DOWN, BC_RIGHT, BC_LEFT) [btCanvasDirection] * Arg: format [UNKN ] format (if recognised by the cnavas) [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_paste_substr_btPasteArea(btPasteArea * bta,int x,int y,const char * str,int len,char (*map_func)(char),btCanvasDirection dir,int format); #define paste_substr_btPasteArea Wise2_paste_substr_btPasteArea /* Function: paste_string_btPasteArea(bta,x,y,str,dir,format) * * Descrip: This will paste the '\0' terminated string into x,y in the direction * specified (up, down, left or right) * * * Arg: bta [UNKN ] PasteArea to be used [btPasteArea *] * Arg: x [UNKN ] x position of start of string [int] * Arg: y [UNKN ] y position of start of string [int] * Arg: str [READ ] string to be pasted [const char *] * Arg: dir [UNKN ] direction (BC_UP, BC_DOWN, BC_RIGHT, BC_LEFT) [btCanvasDirection] * Arg: format [UNKN ] format (if recognised by the cnavas) [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_paste_string_btPasteArea(btPasteArea * bta,int x,int y,const char * str,btCanvasDirection dir,int format); #define paste_string_btPasteArea Wise2_paste_string_btPasteArea /* Function: paste_char_btPasteArea(bta,x,y,c,format) * * Descrip: This will paste one character at x,y into the paste area. * If the canvas understands the format style, it will take * notice of it. * * * Arg: bta [UNKN ] Undocumented argument [btPasteArea *] * Arg: x [UNKN ] Undocumented argument [int] * Arg: y [UNKN ] Undocumented argument [int] * Arg: c [UNKN ] Undocumented argument [char] * Arg: format [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_paste_char_btPasteArea(btPasteArea * bta,int x,int y,char c,int format) ; #define paste_char_btPasteArea Wise2_paste_char_btPasteArea /* Function: free_btPasteArea(obj) * * Descrip: Specialised deconstructor. Ensures the * data structures are freed * * * Arg: obj [WRITE] btPasteArea obj to be destroyed [btPasteArea *] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ btPasteArea * Wise2_free_btPasteArea(btPasteArea * obj); #define free_btPasteArea Wise2_free_btPasteArea /* Function: free_btCanvas(obj) * * Descrip: Specialised deconstructor. Ensures the * data structures are freed * * * Arg: obj [WRITE] btCanvas obj to be destroyed [btCanvas *] * * Return [UNKN ] Undocumented return value [btCanvas *] * */ btCanvas * Wise2_free_btCanvas(btCanvas * obj); #define free_btCanvas Wise2_free_btCanvas /* Function: hard_link_btPasteArea(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [btPasteArea *] * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ btPasteArea * Wise2_hard_link_btPasteArea(btPasteArea * obj); #define hard_link_btPasteArea Wise2_hard_link_btPasteArea /* Function: btPasteArea_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [btPasteArea *] * */ btPasteArea * Wise2_btPasteArea_alloc(void); #define btPasteArea_alloc Wise2_btPasteArea_alloc /* Function: hard_link_btCanvas(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [btCanvas *] * * Return [UNKN ] Undocumented return value [btCanvas *] * */ btCanvas * Wise2_hard_link_btCanvas(btCanvas * obj); #define hard_link_btCanvas Wise2_hard_link_btCanvas /* Function: btCanvas_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [btCanvas *] * */ btCanvas * Wise2_btCanvas_alloc(void); #define btCanvas_alloc Wise2_btCanvas_alloc /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/pthreadpool.c0000644000175000001440000001452610670453712017333 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "pthreadpool.h" /* Function: new_PThreadPool(no_threads) * * Descrip: Makes a new Thread pool * * * Arg: no_threads [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [PThreadPool *] * */ # line 51 "pthreadpool.dy" PThreadPool * new_PThreadPool(int no_threads) { PThreadPool * out; out = PThreadPool_alloc(); out->number_of_threads = no_threads; out->max_work_size = max_work; out->cur_queue_size = 0; out->head = NULL; out->tail = NULL; out->queue_closed = 0; out->shutdown = 0; out->lock = (pthread_mutex_t *) ckalloc (sizeof(pthread_mutex_t)); out->work_to_do = (pthread_cond_t *) ckalloc (sizeof(pthread_cond_t)); out->queue_not_full = (pthread_cond_t *) ckalloc (sizeof(pthread_cond_t)); out->queue_empty = (pthread_cond_t *) ckalloc (sizeof(pthread_cond_t)); if( pthread_mutex_init(out->lock,NULL) != 0 ) { warn("Unable to initialise lock mutex"); return NULL; } return out; } # line 44 "pthreadpool.c" /* Function: hard_link_PTP_Work(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PTP_Work *] * * Return [UNKN ] Undocumented return value [PTP_Work *] * */ PTP_Work * hard_link_PTP_Work(PTP_Work * obj) { if( obj == NULL ) { warn("Trying to hard link to a PTP_Work object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PTP_Work_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PTP_Work *] * */ PTP_Work * PTP_Work_alloc(void) { PTP_Work * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PTP_Work *) ckalloc (sizeof(PTP_Work))) == NULL) { warn("PTP_Work_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->work_routine = NULL; out->data = NULL; out->next = NULL; return out; } /* Function: free_PTP_Work(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PTP_Work *] * * Return [UNKN ] Undocumented return value [PTP_Work *] * */ PTP_Work * free_PTP_Work(PTP_Work * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PTP_Work obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; /* obj->work_routine is a function pointer */ if( obj->data != NULL) free_void(obj->data); if( obj->next != NULL) free_PTP_Work(obj->next); ckfree(obj); return NULL; } /* Function: hard_link_PThreadPool(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PThreadPool *] * * Return [UNKN ] Undocumented return value [PThreadPool *] * */ PThreadPool * hard_link_PThreadPool(PThreadPool * obj) { if( obj == NULL ) { warn("Trying to hard link to a PThreadPool object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: PThreadPool_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PThreadPool *] * */ PThreadPool * PThreadPool_alloc(void) { PThreadPool * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(PThreadPool *) ckalloc (sizeof(PThreadPool))) == NULL) { warn("PThreadPool_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->number_of_threads = 0; /* threads[MAX_THREAD_NUMBER] is an array: no default possible */ out->max_work_size = 0; out->current_work_size = 0; out->head = NULL; out->tail = NULL; out->lock = NULL; out->work_to_do = NULL; out->queue_not_full = NULL; out->queue_empty = NULL; out->queue_closed = 0; out->shutdown = 0; return out; } /* Function: free_PThreadPool(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PThreadPool *] * * Return [UNKN ] Undocumented return value [PThreadPool *] * */ PThreadPool * free_PThreadPool(PThreadPool * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a PThreadPool obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->head != NULL) free_PTP_Work(obj->head); if( obj->tail != NULL) free_PTP_Work(obj->tail); if( obj->lock != NULL) free_pthread_mutex_t(obj->lock); if( obj->work_to_do != NULL) free_pthread_cond_t(obj->work_to_do); if( obj->queue_not_full != NULL) free_pthread_cond_t(obj->queue_not_full); if( obj->queue_empty != NULL) free_pthread_cond_t(obj->queue_empty); ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/pthreadpool.h0000644000175000001440000001166110670453712017335 0ustar philippusers#ifndef DYNAMITEpthreadpoolHEADERFILE #define DYNAMITEpthreadpoolHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include #define MAX_THREAD_NUMBER 100 #ifndef DYNAMITE_DEFINED_PThreadPool typedef struct Wise2_PThreadPool Wise2_PThreadPool; #define PThreadPool Wise2_PThreadPool #define DYNAMITE_DEFINED_PThreadPool #endif #ifndef DYNAMITE_DEFINED_PTP_Work typedef struct Wise2_PTP_Work Wise2_PTP_Work; #define PTP_Work Wise2_PTP_Work #define DYNAMITE_DEFINED_PTP_Work #endif /* Object PTP_Work * * Descrip: This data structure holds an individual job to be * executed by the PThreadPool. * * */ struct Wise2_PTP_Work { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif void (*work_routine)(void * data); void * data; PTP_Work * next; } ; /* PTP_Work defined */ #ifndef DYNAMITE_DEFINED_PTP_Work typedef struct Wise2_PTP_Work Wise2_PTP_Work; #define PTP_Work Wise2_PTP_Work #define DYNAMITE_DEFINED_PTP_Work #endif /* Object PThreadPool * * Descrip: This datastructure is to hold a thread pool. * Work can be added via * * This is work in progress. Dont use! * * */ struct Wise2_PThreadPool { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif int number_of_threads; pthread_t threads[MAX_THREAD_NUMBER]; int max_work_size; int current_work_size; PTP_Work * head; PTP_Work * tail; pthread_mutex_t * lock; pthread_cond_t * work_to_do; pthread_cond_t * queue_not_full; pthread_cond_t * queue_empty; int queue_closed; int shutdown; } ; /* PThreadPool defined */ #ifndef DYNAMITE_DEFINED_PThreadPool typedef struct Wise2_PThreadPool Wise2_PThreadPool; #define PThreadPool Wise2_PThreadPool #define DYNAMITE_DEFINED_PThreadPool #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_PThreadPool(no_threads) * * Descrip: Makes a new Thread pool * * * Arg: no_threads [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [PThreadPool *] * */ PThreadPool * Wise2_new_PThreadPool(int no_threads); #define new_PThreadPool Wise2_new_PThreadPool /* Function: hard_link_PTP_Work(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PTP_Work *] * * Return [UNKN ] Undocumented return value [PTP_Work *] * */ PTP_Work * Wise2_hard_link_PTP_Work(PTP_Work * obj); #define hard_link_PTP_Work Wise2_hard_link_PTP_Work /* Function: PTP_Work_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PTP_Work *] * */ PTP_Work * Wise2_PTP_Work_alloc(void); #define PTP_Work_alloc Wise2_PTP_Work_alloc /* Function: free_PTP_Work(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PTP_Work *] * * Return [UNKN ] Undocumented return value [PTP_Work *] * */ PTP_Work * Wise2_free_PTP_Work(PTP_Work * obj); #define free_PTP_Work Wise2_free_PTP_Work /* Function: hard_link_PThreadPool(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [PThreadPool *] * * Return [UNKN ] Undocumented return value [PThreadPool *] * */ PThreadPool * Wise2_hard_link_PThreadPool(PThreadPool * obj); #define hard_link_PThreadPool Wise2_hard_link_PThreadPool /* Function: PThreadPool_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [PThreadPool *] * */ PThreadPool * Wise2_PThreadPool_alloc(void); #define PThreadPool_alloc Wise2_PThreadPool_alloc /* Function: free_PThreadPool(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [PThreadPool *] * * Return [UNKN ] Undocumented return value [PThreadPool *] * */ PThreadPool * Wise2_free_PThreadPool(PThreadPool * obj); #define free_PThreadPool Wise2_free_PThreadPool /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/shadowseq.dy0000644000175000001440000000516207626362477017214 0ustar philippusers %{ #include "sequence.h" #define SHADOW_SEQUENCE_REGION_BASIC 4 #define ShadowSequenceLISTLENGTH 8 %} struct ShadowSeqRegion int start_shadow int start_seq int len Sequence * seq struct ShadowSequence Sequence * seq !link char dirty ShadowSeqRegion ** region !list %{ #include "shadowseq.h" %func Dumps shadow sequence out to file %% void dump_ShadowSequence(ShadowSequence * shadow,FILE * ofp) { int i; assert(shadow); assert(ofp); fprintf(ofp,"Sequence %s %d\n",shadow->seq->name,shadow->seq->len); for(i=0;ilen;i++) { fprintf(ofp," Shadow %s %d,%d %d\n", shadow->region[i]->seq->name, shadow->region[i]->start_shadow, shadow->region[i]->start_seq, shadow->region[i]->len); } } %func Looks as to whether there is a good extension to be made, if so, does it and adds it to the ShadowSeq. Returns 0 if extension fails, if succeeds returns end point %% int add_if_possible_ShadowSequence(ShadowSequence * shadow,Sequence * seq,int min_extension,int start_shadow,int start_seq,int shadow_rate) { int i; int j; int error = 0; assert(shadow); assert(seq); for(i=start_shadow,j=start_seq;iseq->len && jlen;i++,j++) { if( shadow->seq->seq[i] != seq->seq[j] ) { error++; if( i > start_shadow && error > (int)((shadow_rate*100)/(start_shadow-i)) ) break; } } if( i - start_shadow < min_extension ) { return 0; } /* we have a region */ add_region_ShadowSequence(shadow,seq,start_shadow,start_seq,i-start_shadow); return j; } %func Adds a region to a ShadowSequence, extending the array if necessary %% void add_region_ShadowSequence(ShadowSequence * shadow,Sequence * seq,int start_shadow,int start_seq,int len) { ShadowSeqRegion * ssr; assert(shadow); assert(seq); ssr = ShadowSeqRegion_alloc(); ssr->seq = seq; ssr->start_shadow = start_shadow; ssr->start_seq = start_seq; ssr->len = len; if( shadow->region == NULL ) { if((shadow->region = (ShadowSeqRegion ** ) ckcalloc (ShadowSequenceLISTLENGTH,sizeof(ShadowSeqRegion *))) == NULL) { warn("Warning, ckcalloc failed in ShadowSequence_alloc_len"); return; } shadow->len = 0; shadow->maxlen = ShadowSequenceLISTLENGTH; } add_ShadowSequence(shadow,ssr); return; } %func Builds a new ShadowSequence from a Sequence doesnt hard link as memory should be handled outside of the shadowsystem %% ShadowSequence * new_ShadowSequence(Sequence * seq) { ShadowSequence * out; assert(seq); out = ShadowSequence_alloc(); assert(out); out->seq = seq; out->region = NULL; out->dirty = 0; return out; } %} wise-2.4.1/src/dynlibsrc/btcanvas.dy0000644000175000001440000001256407313404537017006 0ustar philippusers %{ #include "wisebase.h" typedef enum btCanvasDirection { BC_UP, BC_DOWN, BC_RIGHT, BC_LEFT } btCanvasDirection ; /* * Icky... icky.. icky * * Would you believe, some C compilers will not allow typdef's * inside function to pointer definitions in structures... * * Hence - hard coded package names!!!! Yuk!!! * */ %} friend btPastArea friend btCanvas struct btPasteArea int type int height int length boolean (*paste_char)(struct Wise2_btPasteArea *,int,int,char,int) !func void * canvas_data struct Wise2_btPasteArea * (*decons)(struct Wise2_btPasteArea * bt) !func struct btCanvas int type int height int res_right int res_left boolean (*can_get_paste_area)(struct Wise2_btCanvas *,int) !func boolean (*advance_line)(struct Wise2_btCanvas *) !func struct Wise2_btPasteArea * (*get_paste_area)(struct Wise2_btCanvas *,int) !func struct Wise2_btPasteArea * (*get_reserved_right)(struct Wise2_btCanvas *) !func struct Wise2_btPasteArea * (*get_reserved_left)(struct Wise2_btCanvas *) !func void * canvas_data struct Wise2_btCanvas * (*decons)(struct Wise2_btCanvas * btc) !func %info This structure would be much cleaner written in C++ It is basically a virtual object which will be made by other (concrete) implmentations, such as asciibtcanvas A btcanvas is an abstraction of the block text type alignment output common for many algorithms. It allows you to ask for regions in one of these alignment 'outputs' and for you to paste characters into it %% %{ #include "btcanvas.h" %func This returns whether there is room for length of chars in this line. If not, advance a line %arg length length of block wanted %% boolean can_get_paste_area_btCanvas(btCanvas * btc,int length) { return ((*btc->can_get_paste_area)(btc,length)); } %func Advances the canvas to the next line %arg %% boolean advance_line_btCanvas(btCanvas * btc) { return ((*btc->advance_line)(btc)); } %func This gets a paste-able area at the left hand side of block %arg %% btPasteArea * get_reserved_left_btCanvas(btCanvas * btc) { return ((*btc->get_reserved_left)(btc)); } %func This gets a paste-able area at the right hand side of block %arg %% btPasteArea * get_reserved_right_btCanvas(btCanvas * btc) { return ((*btc->get_reserved_right)(btc)); } %func This gets a paste-able area of a certain length from the current cursor. NULL on error %arg %% btPasteArea * get_paste_area_btCanvas(btCanvas * btc,int length) { return ((*btc->get_paste_area)(btc,length)); } %func This will paste the substr of length len (obviously this could not be a \0 terminated string) starting from str[0] into btCanvas If map_func is non NULL, it converts each of the characters using the map_func first. This is surprisingly useful. map_func can be NULL, in which case the characters are just used as seen Length has to be less than 64 chars %arg bta PasteArea to be used x x position of start of string y y position of start of string str r string to get the substr from to be pasted len r length of the substr map_func Function to specifiy the mapping of chars from str to display dir direction (BC_UP, BC_DOWN, BC_RIGHT, BC_LEFT) format format (if recognised by the cnavas) %% boolean paste_substr_btPasteArea(btPasteArea * bta,int x,int y,const char * str,int len,char (*map_func)(char),btCanvasDirection dir,int format) { char buf[64]; const char *run; int i; for(run=str,i=0;i bta->length || y > bta->height ) { warn("Trying to paste a character into an unpasteable position [%d,%d] into [%d,%d]",x,y,bta->length,bta->height); return FALSE; } return ((*bta->paste_char))(bta,x,y,c,format); } %func Specialised deconstructor. Ensures the data structures are freed %arg obj w btPasteArea obj to be destroyed %% !deconstructor btPasteArea * free_btPasteArea(btPasteArea * obj) { return ((*obj->decons))(obj); } %func Specialised deconstructor. Ensures the data structures are freed %arg obj w btCanvas obj to be destroyed %% !deconstructor btCanvas * free_btCanvas(btCanvas * obj) { return ((*obj->decons))(obj); } %} wise-2.4.1/src/dynlibsrc/hscore.c0000644000175000001440000010764710670453712016304 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "hscore.h" /* Function: std_score_Hscore(cut_off,report_stagger) * * Descrip: This gives you a standard Hscore * module with a cutoff in score * * * Arg: cut_off [UNKN ] Undocumented argument [int] * Arg: report_stagger [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Hscore *] * */ # line 125 "hscore.dy" Hscore * std_score_Hscore(int cut_off,int report_stagger) { Hscore * out; out = Hscore_alloc_std(); out->his = new_Histogram(-1000,1000,100); out->score_level = cut_off; out->should_store = raw_should_store_Hscore; out->score_to_his = raw_score_to_his; out->report_level = report_stagger; return out; } /* Function: raw_should_store_Hscore(score,cutoff) * * Descrip: This function is for the Hscore std constructor, * * * Arg: score [UNKN ] Undocumented argument [int] * Arg: cutoff [UNKN ] Undocumented argument [double] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 143 "hscore.dy" boolean raw_should_store_Hscore(int score,double cutoff) { if( score > cutoff ) { return TRUE; } return FALSE; } /* Function: raw_score_to_his(score) * * Descrip: This function is for the Hscore std constructor, * * * Arg: score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [float] * */ # line 155 "hscore.dy" float raw_score_to_his(int score) { return score; } /* Function: should_store_Hscore(hs,score) * * Descrip: Tells whether this score should be stored * or not. Also updates Histogram if needed * * * Arg: hs [UNKN ] Undocumented argument [Hscore *] * Arg: score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 165 "hscore.dy" boolean should_store_Hscore(Hscore * hs,int score) { hs->total++; if( hs->report_level != -1 && (hs->total % hs->report_level == 0)) { if( hs->len > 0) { info("Done %d comparisons: last stored comparison was %s to %s",hs->total,hs->ds[hs->len-1]->query->name,hs->ds[hs->len-1]->target->name); } else { info("Done %d comparisons: No stored comparisons",hs->total); } } if( hs->his != NULL && hs->score_to_his != NULL ) { AddToHistogram(hs->his,(*hs->score_to_his)(score)); } if( hs->should_store == NULL ) { return TRUE; } return (*hs->should_store)(score,hs->score_level); } /* Function: length_datascore_Hscore(obj) * * Descrip: Returns the number of datascores in the hscore * structure * * * Arg: obj [READ ] Hscore object [Hscore *] * * Return [UNKN ] Undocumented return value [int] * */ # line 194 "hscore.dy" int length_datascore_Hscore(Hscore * obj) { return obj->len; } /* Function: get_datascore_Hscore(hs,i) * * Descrip: Returns the specific datascore held at this * position. * * This requires a considerable amount of memory * duplication, so please dont process all your * results by looping through this. * * * Arg: hs [READ ] Hscore object [Hscore *] * Arg: i [UNKN ] position to be read [int] * * Return [OWNER] New datascore object [DataScore *] * */ # line 213 "hscore.dy" DataScore * get_datascore_Hscore(Hscore * hs,int i) { DataScore * out; out = new_DataScore(); copy_DataEntry(hs->ds[i]->query,out->query); copy_DataEntry(hs->ds[i]->target,out->target); out->score = hs->ds[i]->score; out->evalue = hs->ds[i]->evalue; return out; } /* Function: copy_DataEntry(from,to) * * Descrip: Copies the info from one DataEntry to another * * * Arg: from [UNKN ] Undocumented argument [DataEntry *] * Arg: to [UNKN ] Undocumented argument [DataEntry *] * */ # line 229 "hscore.dy" void copy_DataEntry(DataEntry * from,DataEntry * to) { int i; to->name = stringalloc(from->name); for(i=0;idata[i] = from->data[i]; to->is_reversed = from->is_reversed; to->byte_position = from->byte_position; to->filename = from->filename; /* linked! */ } /* Function: get_score_Hscore(hs,i) * * Descrip: No Description * * Arg: hs [READ ] Hscore object [Hscore *] * Arg: i [UNKN ] position to be read [int] * * Return [UNKN ] score [int] * */ # line 251 "hscore.dy" int get_score_Hscore(Hscore * hs,int i) { return hs->ds[i]->score; } /* Function: get_evalue_Hscore(hs,i) * * Descrip: Returns the evalue of the specific datascore held at this position. * * * * Arg: hs [READ ] Hscore object [Hscore *] * Arg: i [UNKN ] position to be read [int] * * Return [UNKN ] evalue [double] * */ # line 266 "hscore.dy" double get_evalue_Hscore(Hscore * hs,int i) { return hs->ds[i]->evalue; } /* Function: fit_Hscore_to_EVD(hs,guess_of_outliers) * * Descrip: If a histogram is present, tries to fit the histogram and * then gives evalues to all the scores in the Hscore model * * * Arg: hs [UNKN ] Undocumented argument [Hscore *] * Arg: guess_of_outliers [UNKN ] Undocumented argument [float] * * Return [UNKN ] Undocumented return value [boolean] * */ # line 275 "hscore.dy" boolean fit_Hscore_to_EVD(Hscore * hs,float guess_of_outliers) { int i; if( hs->his == NULL ) { warn("Your Hscore has no histogram structure, and so no EVD can be fitted"); return FALSE; } if( ExtremeValueFitHistogram(hs->his,TRUE,guess_of_outliers) == 0 ) { warn("Extreme Value distribution is unable to be fitted. Sorry!"); return FALSE; } for(i=0;ilen;i++) { hs->ds[i]->evalue = ExtremeValueE((*hs->score_to_his)(hs->ds[i]->score),hs->his->param[EVD_MU],hs->his->param[EVD_LAMBDA],hs->his->total); } return TRUE; } /* Function: minimum_score_Hscore(hs) * * Descrip: gets the minimum score from Hscore * * * Arg: hs [UNKN ] Undocumented argument [Hscore *] * * Return [UNKN ] Undocumented return value [int] * */ # line 302 "hscore.dy" int minimum_score_Hscore(Hscore * hs) { int i; int min; if( hs->len == 0) { warn("Can't get a minimum score with no entries"); return 0; } for(i=1,min=hs->ds[0]->score;ilen;i++) { if( min > hs->ds[i]->score ) { min = hs->ds[i]->score; } } return min; } /* Function: maximum_score_Hscore(hs) * * Descrip: gets the maximum score from Hscore * * * Arg: hs [UNKN ] Undocumented argument [Hscore *] * * Return [UNKN ] Undocumented return value [int] * */ # line 324 "hscore.dy" int maximum_score_Hscore(Hscore * hs) { int i; int max; if( hs->len == 0) { warn("Can't get a minimum score with no entries"); return 0; } for(i=1,max=hs->ds[0]->score;ilen;i++) { if( max < hs->ds[i]->score ) { max = hs->ds[i]->score; } } return max; } /* Function: basic_show_Hscore(hs,ofp) * * Descrip: The most baby-talk showing of Hscore * * * Arg: hs [UNKN ] Undocumented argument [Hscore *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 349 "hscore.dy" void basic_show_Hscore(Hscore * hs,FILE * ofp) { int i; if( hs == NULL ) { warn("parsing in a NULL Hscore object - cannot show!"); fprintf(ofp,"parsing in a NULL Hscore object - cannot show!"); } for(i=0;ilen;i++) { fprintf(ofp,"%3d Query: %12s Target: %12s Score %d\n",i, hs->ds[i]->query->name == NULL ? "NoName" : hs->ds[i]->query->name, hs->ds[i]->target->name == NULL ? "NoName" : hs->ds[i]->target->name, hs->ds[i]->score); } } /* Function: sort_Hscore_by_score(hs) * * Descrip: As it says, sorts the high score by its score * * * Arg: hs [UNKN ] Hscore to be sorted [Hscore *] * */ # line 371 "hscore.dy" void sort_Hscore_by_score(Hscore * hs) { sort_Hscore(hs,compare_DataScore_by_score); } /* Function: compare_DataScore_by_score(one,two) * * Descrip: Used to compare two datascores for * /sort_Hscore_by_score * * * Arg: one [UNKN ] Undocumented argument [DataScore *] * Arg: two [UNKN ] Undocumented argument [DataScore *] * * Return [UNKN ] Undocumented return value [int] * */ # line 383 "hscore.dy" int compare_DataScore_by_score(DataScore * one,DataScore * two) { if( one->score == two->score ) { if( one->query != NULL && one->query->name != NULL && two->query != NULL && two->query->name != NULL ) return strcmp(one->query->name,two->query->name); else return 1; } return two->score - one->score; } /* Function: new_DataScore(void) * * Descrip: The best way to make a new DataScore. * Allocates the query and target DataEntry structures * as well as the DataScore structure. * * * * Return [UNKN ] Undocumented return value [DataScore *] * */ # line 402 "hscore.dy" DataScore * new_DataScore(void) { DataScore * ds; ds = DataScore_alloc(); ds->query = DataEntry_alloc(); ds->target = DataEntry_alloc(); return ds; } /* Function: new_DataScore_from_storage(hs) * * Descrip: Gets a new DataScore from Storage * * * Arg: hs [UNKN ] Undocumented argument [Hscore *] * * Return [UNKN ] Undocumented return value [DataScore *] * */ # line 417 "hscore.dy" DataScore * new_DataScore_from_storage(Hscore * hs) { DataScoreStorage * new; DataScoreStorage * curr; if( hs->st_len == 0 ) { new = new_DataScoreStorage(); if( new == NULL ) { warn("could not make inital data score storage!"); return NULL; } add_st_Hscore(hs,new); curr = new; } else { curr = hs->store[hs->st_len-1]; if( curr->curr_pos == DATASCORESTORAGE_LENGTH ) { new = new_DataScoreStorage(); if( new == NULL ) { warn("could not make data score storage block %d!",hs->st_len-1); return NULL; } add_st_Hscore(hs,new); curr = new; } } return &curr->score_array[curr->curr_pos++]; } /* Function: free_DataScore(obj) * * Descrip: Correctly handles destruction of a datascore * * * Arg: obj [UNKN ] Undocumented argument [DataScore *] * * Return [UNKN ] Undocumented return value [DataScore *] * */ # line 452 "hscore.dy" DataScore * free_DataScore(DataScore * obj) { if( obj->is_stored == 1 ) { return NULL; /* don't free! */ } if( obj->dynamite_hard_link > 1 ) { obj->dynamite_hard_link--; return NULL; } if( obj->query != NULL ) free_DataEntry(obj->query); if( obj->target != NULL ) free_DataEntry(obj->target); return NULL; } /* Function: free_DataScoreStorage(obj) * * Descrip: Correctly handles destruction of DataScoreStorage, by * freeing members in data storage * * * Arg: obj [UNKN ] Undocumented argument [DataScoreStorage *] * * Return [UNKN ] Undocumented return value [DataScoreStorage *] * */ # line 476 "hscore.dy" DataScoreStorage * free_DataScoreStorage(DataScoreStorage * obj) { int i; for(i=0;icurr_pos;i++) { if( obj->query_array[i].name != NULL ) { ckfree(obj->query_array[i].name); } if( obj->target_array[i].name != NULL ) { ckfree(obj->target_array[i].name); } } ckfree(obj); return NULL; } /* Function: new_DataScoreStorage(void) * * Descrip: Makes a new DataScoreStorage with all the pointers connected correctly * * * * Return [UNKN ] Undocumented return value [DataScoreStorage *] * */ # line 499 "hscore.dy" DataScoreStorage * new_DataScoreStorage(void) { DataScoreStorage * out; int i; out = DataScoreStorage_alloc(); if( out == NULL ) { warn("Unable to make a new DataScoreStorage block with blocksize %d",DATASCORESTORAGE_LENGTH); return NULL; } for(i=0;iscore_array[i].query = &out->query_array[i]; out->score_array[i].target = &out->target_array[i]; out->score_array[i].is_stored = 1; } return out; } # line 490 "hscore.c" /* Function: hard_link_DataEntry(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DataEntry *] * * Return [UNKN ] Undocumented return value [DataEntry *] * */ DataEntry * hard_link_DataEntry(DataEntry * obj) { if( obj == NULL ) { warn("Trying to hard link to a DataEntry object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DataEntry_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DataEntry *] * */ DataEntry * DataEntry_alloc(void) { DataEntry * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DataEntry *) ckalloc (sizeof(DataEntry))) == NULL) { warn("DataEntry_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->name = NULL; /* data[DATAENTRYSTDPOINTS] is an array: no default possible */ out->is_reversed = FALSE; out->byte_position = 0; return out; } /* Function: free_DataEntry(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DataEntry *] * * Return [UNKN ] Undocumented return value [DataEntry *] * */ DataEntry * free_DataEntry(DataEntry * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DataEntry obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->name != NULL) ckfree(obj->name); /* obj->filename is linked in */ ckfree(obj); return NULL; } /* Function: hard_link_DataScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DataScore *] * * Return [UNKN ] Undocumented return value [DataScore *] * */ DataScore * hard_link_DataScore(DataScore * obj) { if( obj == NULL ) { warn("Trying to hard link to a DataScore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DataScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DataScore *] * */ DataScore * DataScore_alloc(void) { DataScore * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DataScore *) ckalloc (sizeof(DataScore))) == NULL) { warn("DataScore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->query = NULL; out->target = NULL; out->score = 0; out->evalue = 0; out->is_stored = 0; return out; } /* Function: hard_link_DataScoreStorage(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DataScoreStorage *] * * Return [UNKN ] Undocumented return value [DataScoreStorage *] * */ DataScoreStorage * hard_link_DataScoreStorage(DataScoreStorage * obj) { if( obj == NULL ) { warn("Trying to hard link to a DataScoreStorage object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DataScoreStorage_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DataScoreStorage *] * */ DataScoreStorage * DataScoreStorage_alloc(void) { DataScoreStorage * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DataScoreStorage *) ckalloc (sizeof(DataScoreStorage))) == NULL) { warn("DataScoreStorage_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* score_array[DATASCORESTORAGE_LENGTH] is an array: no default possible */ /* query_array[DATASCORESTORAGE_LENGTH] is an array: no default possible */ /* target_array[DATASCORESTORAGE_LENGTH] is an array: no default possible */ out->curr_pos = 0; return out; } /* Function: swap_Hscore(list,i,j) * * Descrip: swap function: an internal for qsort_Hscore * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [DataScore **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_Hscore(DataScore ** list,int i,int j) { DataScore * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_Hscore(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_Hscore which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [DataScore **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_Hscore(DataScore ** list,int left,int right,int (*comp)(DataScore * ,DataScore * )) { int i,last; if( left >= right ) return; swap_Hscore(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_Hscore (list,++last,i); } swap_Hscore (list,left,last); qsort_Hscore(list,left,last-1,comp); qsort_Hscore(list,last+1,right,comp); } /* Function: sort_Hscore(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_Hscore * * * Arg: obj [UNKN ] Object containing list [Hscore *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_Hscore(Hscore * obj,int (*comp)(DataScore *, DataScore *)) { qsort_Hscore(obj->ds,0,obj->len-1,comp); return; } /* Function: expand_Hscore(obj,len) * * Descrip: Really an internal function for add_Hscore * * * Arg: obj [UNKN ] Object which contains the list [Hscore *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_Hscore(Hscore * obj,int len) { if( obj->maxlen > obj->len ) { warn("expand_Hscore called with no need"); return TRUE; } if( (obj->ds = (DataScore ** ) ckrealloc (obj->ds,sizeof(DataScore *)*len)) == NULL) { warn("ckrealloc failed for expand_Hscore, returning FALSE"); return FALSE; } obj->maxlen = len; return TRUE; } /* Function: add_Hscore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Hscore *] * Arg: add [OWNER] Object to add to the list [DataScore *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_Hscore(Hscore * obj,DataScore * add) { if( obj->len >= obj->maxlen) { if( expand_Hscore(obj,obj->len + HscoreLISTLENGTH) == FALSE) return FALSE; } obj->ds[obj->len++]=add; return TRUE; } /* Function: flush_Hscore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Hscore *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_Hscore(Hscore * obj) { int i; for(i=0;ilen;i++) { /*for i over list length*/ if( obj->ds[i] != NULL) { free_DataScore(obj->ds[i]); obj->ds[i] = NULL; } } /* end of for i over list length */ obj->len = 0; return i; } /* Function: swap_st_Hscore(list,i,j) * * Descrip: swap function: an internal for qsort_st_Hscore * swaps two positions in the array * * * Arg: list [UNKN ] List of structures to swap in [DataScoreStorage **] * Arg: i [UNKN ] swap position [int] * Arg: j [UNKN ] swap position [int] * */ /* swap function for qsort function */ void swap_st_Hscore(DataScoreStorage ** list,int i,int j) { DataScoreStorage * temp; temp=list[i]; list[i]=list[j]; list[j]=temp; } /* Function: qsort_st_Hscore(list,left,right,comp) * * Descrip: qsort - lifted from K&R * sorts the array using quicksort * Probably much better to call sort_st_Hscore which sorts from start to end * * * Arg: list [UNKN ] List of structures to swap in [DataScoreStorage **] * Arg: left [UNKN ] left position [int] * Arg: right [UNKN ] right position [int] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void qsort_st_Hscore(DataScoreStorage ** list,int left,int right,int (*comp)(DataScoreStorage * ,DataScoreStorage * )) { int i,last; if( left >= right ) return; swap_st_Hscore(list,left,(left+right)/2); last = left; for ( i=left+1; i <= right;i++) { if( (*comp)(list[i],list[left]) < 0) swap_st_Hscore (list,++last,i); } swap_st_Hscore (list,left,last); qsort_st_Hscore(list,left,last-1,comp); qsort_st_Hscore(list,last+1,right,comp); } /* Function: sort_st_Hscore(obj,comp) * * Descrip: sorts from start to end using comp * sorts the array using quicksort by calling qsort_st_Hscore * * * Arg: obj [UNKN ] Object containing list [Hscore *] * Arg: comp [FUNCP] Function which returns -1 or 1 to sort on [int (*comp] * */ void sort_st_Hscore(Hscore * obj,int (*comp)(DataScoreStorage *, DataScoreStorage *)) { qsort_st_Hscore(obj->store,0,obj->st_len-1,comp); return; } /* Function: expand_st_Hscore(obj,len) * * Descrip: Really an internal function for add_st_Hscore * * * Arg: obj [UNKN ] Object which contains the list [Hscore *] * Arg: len [UNKN ] Length to add one [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean expand_st_Hscore(Hscore * obj,int len) { if( obj->st_maxlen > obj->st_len ) { warn("expand_Hscorest_ called with no need"); return TRUE; } if( (obj->store = (DataScoreStorage ** ) ckrealloc (obj->store,sizeof(DataScoreStorage *)*len)) == NULL) { warn("ckrealloc failed for expand_Hscore, returning FALSE"); return FALSE; } obj->st_maxlen = len; return TRUE; } /* Function: add_st_Hscore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Hscore *] * Arg: add [OWNER] Object to add to the list [DataScoreStorage *] * * Return [UNKN ] Undocumented return value [boolean] * */ /* will expand function if necessary */ boolean add_st_Hscore(Hscore * obj,DataScoreStorage * add) { if( obj->st_len >= obj->st_maxlen) { if( expand_st_Hscore(obj,obj->st_len + HscoreLISTLENGTH) == FALSE) return FALSE; } obj->store[obj->st_len++]=add; return TRUE; } /* Function: flush_st_Hscore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Hscore *] * * Return [UNKN ] Undocumented return value [int] * */ int flush_st_Hscore(Hscore * obj) { int i; for(i=0;ist_len;i++) { /*for i over list length*/ if( obj->store[i] != NULL) { free_DataScoreStorage(obj->store[i]); obj->store[i] = NULL; } } /* end of for i over list length */ obj->st_len = 0; return i; } /* Function: Hscore_alloc_std(void) * * Descrip: Equivalent to Hscore_alloc_len(HscoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * Hscore_alloc_std(void) { return Hscore_alloc_len(HscoreLISTLENGTH); } /* Function: Hscore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * Hscore_alloc_len(int len) { Hscore * out; /* out is exported at the end of function */ /* Call alloc function: return NULL if NULL */ /* Warning message alread in alloc function */ if((out = Hscore_alloc()) == NULL) return NULL; /* Calling ckcalloc for list elements */ if((out->ds = (DataScore ** ) ckcalloc (len,sizeof(DataScore *))) == NULL) { warn("Warning, ckcalloc failed in Hscore_alloc_len"); return NULL; } out->len = 0; out->maxlen = len; if((out->store = (DataScoreStorage ** ) ckcalloc (len,sizeof(DataScoreStorage *))) == NULL) { warn("Warning, ckcalloc failed in Hscore_alloc_len"); return NULL; } out->st_len = 0; out->st_maxlen = len; return out; } /* Function: hard_link_Hscore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Hscore *] * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * hard_link_Hscore(Hscore * obj) { if( obj == NULL ) { warn("Trying to hard link to a Hscore object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Hscore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * Hscore_alloc(void) { Hscore * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Hscore *) ckalloc (sizeof(Hscore))) == NULL) { warn("Hscore_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->ds = NULL; out->len = out->maxlen = 0; out->store = NULL; out->st_len = out->st_maxlen = 0; out->his = NULL; out->score_level = 0; out->should_store = NULL; out->score_to_his = NULL; out->report_level = 0; out->total = 0; return out; } /* Function: free_Hscore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Hscore *] * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * free_Hscore(Hscore * obj) { int return_early = 0; int i; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Hscore obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->ds != NULL) { for(i=0;ilen;i++) { if( obj->ds[i] != NULL) free_DataScore(obj->ds[i]); } ckfree(obj->ds); } if( obj->store != NULL) { for(i=0;ist_len;i++) { if( obj->store[i] != NULL) free_DataScoreStorage(obj->store[i]); } ckfree(obj->store); } if( obj->his != NULL) free_Histogram(obj->his); /* obj->should_store is a function pointer */ /* obj->score_to_his is a function pointer */ ckfree(obj); return NULL; } /* Function: replace_query_DataScore(obj,query) * * Descrip: Replace member variable query * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DataScore *] * Arg: query [OWNER] New value of the variable [DataEntry *] * * Return [SOFT ] member variable query [boolean] * */ boolean replace_query_DataScore(DataScore * obj,DataEntry * query) { if( obj == NULL) { warn("In replacement function query for object DataScore, got a NULL object"); return FALSE; } obj->query = query; return TRUE; } /* Function: access_query_DataScore(obj) * * Descrip: Access member variable query * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DataScore *] * * Return [SOFT ] member variable query [DataEntry *] * */ DataEntry * access_query_DataScore(DataScore * obj) { if( obj == NULL) { warn("In accessor function query for object DataScore, got a NULL object"); return NULL; } return obj->query; } /* Function: replace_target_DataScore(obj,target) * * Descrip: Replace member variable target * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DataScore *] * Arg: target [OWNER] New value of the variable [DataEntry *] * * Return [SOFT ] member variable target [boolean] * */ boolean replace_target_DataScore(DataScore * obj,DataEntry * target) { if( obj == NULL) { warn("In replacement function target for object DataScore, got a NULL object"); return FALSE; } obj->target = target; return TRUE; } /* Function: access_target_DataScore(obj) * * Descrip: Access member variable target * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DataScore *] * * Return [SOFT ] member variable target [DataEntry *] * */ DataEntry * access_target_DataScore(DataScore * obj) { if( obj == NULL) { warn("In accessor function target for object DataScore, got a NULL object"); return NULL; } return obj->target; } /* Function: replace_score_DataScore(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DataScore *] * Arg: score [OWNER] New value of the variable [int] * * Return [SOFT ] member variable score [boolean] * */ boolean replace_score_DataScore(DataScore * obj,int score) { if( obj == NULL) { warn("In replacement function score for object DataScore, got a NULL object"); return FALSE; } obj->score = score; return TRUE; } /* Function: access_score_DataScore(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DataScore *] * * Return [SOFT ] member variable score [int] * */ int access_score_DataScore(DataScore * obj) { if( obj == NULL) { warn("In accessor function score for object DataScore, got a NULL object"); return 0; } return obj->score; } /* Function: replace_evalue_DataScore(obj,evalue) * * Descrip: Replace member variable evalue * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DataScore *] * Arg: evalue [OWNER] New value of the variable [double] * * Return [SOFT ] member variable evalue [boolean] * */ boolean replace_evalue_DataScore(DataScore * obj,double evalue) { if( obj == NULL) { warn("In replacement function evalue for object DataScore, got a NULL object"); return FALSE; } obj->evalue = evalue; return TRUE; } /* Function: access_evalue_DataScore(obj) * * Descrip: Access member variable evalue * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DataScore *] * * Return [SOFT ] member variable evalue [double] * */ double access_evalue_DataScore(DataScore * obj) { if( obj == NULL) { warn("In accessor function evalue for object DataScore, got a NULL object"); return 0; } return obj->evalue; } /* Function: replace_name_DataEntry(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DataEntry *] * Arg: name [OWNER] New value of the variable [char *] * * Return [SOFT ] member variable name [boolean] * */ boolean replace_name_DataEntry(DataEntry * obj,char * name) { if( obj == NULL) { warn("In replacement function name for object DataEntry, got a NULL object"); return FALSE; } obj->name = name; return TRUE; } /* Function: access_name_DataEntry(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DataEntry *] * * Return [SOFT ] member variable name [char *] * */ char * access_name_DataEntry(DataEntry * obj) { if( obj == NULL) { warn("In accessor function name for object DataEntry, got a NULL object"); return NULL; } return obj->name; } /* Function: replace_is_reversed_DataEntry(obj,is_reversed) * * Descrip: Replace member variable is_reversed * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DataEntry *] * Arg: is_reversed [OWNER] New value of the variable [boolean] * * Return [SOFT ] member variable is_reversed [boolean] * */ boolean replace_is_reversed_DataEntry(DataEntry * obj,boolean is_reversed) { if( obj == NULL) { warn("In replacement function is_reversed for object DataEntry, got a NULL object"); return FALSE; } obj->is_reversed = is_reversed; return TRUE; } /* Function: access_is_reversed_DataEntry(obj) * * Descrip: Access member variable is_reversed * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [DataEntry *] * * Return [SOFT ] member variable is_reversed [boolean] * */ boolean access_is_reversed_DataEntry(DataEntry * obj) { if( obj == NULL) { warn("In accessor function is_reversed for object DataEntry, got a NULL object"); return FALSE; } return obj->is_reversed; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/hscore.h0000644000175000001440000004752510670453712016307 0ustar philippusers#ifndef DYNAMITEhscoreHEADERFILE #define DYNAMITEhscoreHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "wisebase.h" #include "histogram.h" #define HscoreLISTLENGTH 256 #define DATAENTRYSTDPOINTS 8 #define DATASCORESTORAGE_LENGTH 1024 typedef long BytePosition; /* Object DataEntry * * Descrip: A lightweight structure to represent the information * a db search algorithm will want to store and *nothing* * more about a single entry * * This object will be stored twice (once for the target * and once for the query) for each comparison: they probably * will be on different databases and different objects. * * The data field is just a number (8 at the moment) of int's available * for databases to store useful information (eg, length) of the * object. * * A number of extra fields are provided for convience sake for indexers, * including byte_position and filename. * * */ struct Wise2_DataEntry { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif char * name; /* name of the entry */ int data[DATAENTRYSTDPOINTS]; /* space for algorithms to use */ boolean is_reversed; /* for sequences. handy */ BytePosition byte_position; /* useful for indexers - hopefully long enough! */ char * filename; /* useful for indexers etc. */ } ; /* DataEntry defined */ #ifndef DYNAMITE_DEFINED_DataEntry typedef struct Wise2_DataEntry Wise2_DataEntry; #define DataEntry Wise2_DataEntry #define DYNAMITE_DEFINED_DataEntry #endif /* Object DataScore * * Descrip: The basic one entry vs one entry structure. Each * of the DataEntry datastructures actually store the * information about the indexing etc. * * */ struct Wise2_DataScore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DataEntry * query; DataEntry * target; int score; double evalue; int is_stored; } ; /* DataScore defined */ #ifndef DYNAMITE_DEFINED_DataScore typedef struct Wise2_DataScore Wise2_DataScore; #define DataScore Wise2_DataScore #define DYNAMITE_DEFINED_DataScore #endif /* Object DataScoreStorage * * Descrip: This object was needed because for very large searches * the memory usage of allocation DataScore and DataEntry's * on the heap was becoming prohibative. * * This datastructure holds pre-allocated DataScore and DataEntry * objects read for use. A complicated constructor/deconstructor * pair for DataScore objects ensures that these can be used * cleanly. * * */ struct Wise2_DataScoreStorage { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DataScore score_array[DATASCORESTORAGE_LENGTH]; DataEntry query_array[DATASCORESTORAGE_LENGTH]; DataEntry target_array[DATASCORESTORAGE_LENGTH]; int curr_pos; } ; /* DataScoreStorage defined */ #ifndef DYNAMITE_DEFINED_DataScoreStorage typedef struct Wise2_DataScoreStorage Wise2_DataScoreStorage; #define DataScoreStorage Wise2_DataScoreStorage #define DYNAMITE_DEFINED_DataScoreStorage #endif /* Object Hscore * * Descrip: Holds the information about a db search. * Meant to be very lightweight * * The histogram is carried for on-the-fly histogram storage outside * of the database. The idea is that the function should_store will * tell whether the datascore structure should be stored (if it is * NULL, it is always stored). The score_to_his function maps the * score in datascore to the float in Histogram, allowing the scoring * system of the search method to be on a different basis to the * scoring system of the histogram. For most times, this is going to * be Score2Bits * * To prevent too much dependency, the 'standard' way of making a * histogram that has a bits cut off level is done using functions * in the dynlibcross module (cross code), as it needs both Hscore and * Probability. You should read dynlibcross module for the constructors * for Hscore * * */ struct Wise2_Hscore { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif DataScore ** ds; int len;/* len for above ds */ int maxlen; /* maxlen for above ds */ DataScoreStorage ** store; int st_len; /* len for above store */ int st_maxlen; /* maxlen for above store */ Histogram * his; double score_level; /* passed into should_store function */ boolean (*should_store)(int given_score,double internal_score_level); float (*score_to_his)(int given_score); int report_level; /* number of sequences to report on */ long total; /* total number of scores (duplicated info in histogram) */ } ; /* Hscore defined */ #ifndef DYNAMITE_DEFINED_Hscore typedef struct Wise2_Hscore Wise2_Hscore; #define Hscore Wise2_Hscore #define DYNAMITE_DEFINED_Hscore #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: std_score_Hscore(cut_off,report_stagger) * * Descrip: This gives you a standard Hscore * module with a cutoff in score * * * Arg: cut_off [UNKN ] Undocumented argument [int] * Arg: report_stagger [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * Wise2_std_score_Hscore(int cut_off,int report_stagger); #define std_score_Hscore Wise2_std_score_Hscore /* Function: should_store_Hscore(hs,score) * * Descrip: Tells whether this score should be stored * or not. Also updates Histogram if needed * * * Arg: hs [UNKN ] Undocumented argument [Hscore *] * Arg: score [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_should_store_Hscore(Hscore * hs,int score); #define should_store_Hscore Wise2_should_store_Hscore /* Function: length_datascore_Hscore(obj) * * Descrip: Returns the number of datascores in the hscore * structure * * * Arg: obj [READ ] Hscore object [Hscore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_length_datascore_Hscore(Hscore * obj); #define length_datascore_Hscore Wise2_length_datascore_Hscore /* Function: get_datascore_Hscore(hs,i) * * Descrip: Returns the specific datascore held at this * position. * * This requires a considerable amount of memory * duplication, so please dont process all your * results by looping through this. * * * Arg: hs [READ ] Hscore object [Hscore *] * Arg: i [UNKN ] position to be read [int] * * Return [OWNER] New datascore object [DataScore *] * */ DataScore * Wise2_get_datascore_Hscore(Hscore * hs,int i); #define get_datascore_Hscore Wise2_get_datascore_Hscore /* Function: get_score_Hscore(hs,i) * * Descrip: No Description * * Arg: hs [READ ] Hscore object [Hscore *] * Arg: i [UNKN ] position to be read [int] * * Return [UNKN ] score [int] * */ int Wise2_get_score_Hscore(Hscore * hs,int i); #define get_score_Hscore Wise2_get_score_Hscore /* Function: get_evalue_Hscore(hs,i) * * Descrip: Returns the evalue of the specific datascore held at this position. * * * * Arg: hs [READ ] Hscore object [Hscore *] * Arg: i [UNKN ] position to be read [int] * * Return [UNKN ] evalue [double] * */ double Wise2_get_evalue_Hscore(Hscore * hs,int i); #define get_evalue_Hscore Wise2_get_evalue_Hscore /* Function: fit_Hscore_to_EVD(hs,guess_of_outliers) * * Descrip: If a histogram is present, tries to fit the histogram and * then gives evalues to all the scores in the Hscore model * * * Arg: hs [UNKN ] Undocumented argument [Hscore *] * Arg: guess_of_outliers [UNKN ] Undocumented argument [float] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_fit_Hscore_to_EVD(Hscore * hs,float guess_of_outliers); #define fit_Hscore_to_EVD Wise2_fit_Hscore_to_EVD /* Function: minimum_score_Hscore(hs) * * Descrip: gets the minimum score from Hscore * * * Arg: hs [UNKN ] Undocumented argument [Hscore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_minimum_score_Hscore(Hscore * hs); #define minimum_score_Hscore Wise2_minimum_score_Hscore /* Function: maximum_score_Hscore(hs) * * Descrip: gets the maximum score from Hscore * * * Arg: hs [UNKN ] Undocumented argument [Hscore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_maximum_score_Hscore(Hscore * hs); #define maximum_score_Hscore Wise2_maximum_score_Hscore /* Function: basic_show_Hscore(hs,ofp) * * Descrip: The most baby-talk showing of Hscore * * * Arg: hs [UNKN ] Undocumented argument [Hscore *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_basic_show_Hscore(Hscore * hs,FILE * ofp); #define basic_show_Hscore Wise2_basic_show_Hscore /* Function: sort_Hscore_by_score(hs) * * Descrip: As it says, sorts the high score by its score * * * Arg: hs [UNKN ] Hscore to be sorted [Hscore *] * */ void Wise2_sort_Hscore_by_score(Hscore * hs); #define sort_Hscore_by_score Wise2_sort_Hscore_by_score /* Function: free_DataScore(obj) * * Descrip: Correctly handles destruction of a datascore * * * Arg: obj [UNKN ] Undocumented argument [DataScore *] * * Return [UNKN ] Undocumented return value [DataScore *] * */ DataScore * Wise2_free_DataScore(DataScore * obj); #define free_DataScore Wise2_free_DataScore /* Function: free_DataScoreStorage(obj) * * Descrip: Correctly handles destruction of DataScoreStorage, by * freeing members in data storage * * * Arg: obj [UNKN ] Undocumented argument [DataScoreStorage *] * * Return [UNKN ] Undocumented return value [DataScoreStorage *] * */ DataScoreStorage * Wise2_free_DataScoreStorage(DataScoreStorage * obj); #define free_DataScoreStorage Wise2_free_DataScoreStorage /* Function: new_DataScoreStorage(void) * * Descrip: Makes a new DataScoreStorage with all the pointers connected correctly * * * * Return [UNKN ] Undocumented return value [DataScoreStorage *] * */ DataScoreStorage * Wise2_new_DataScoreStorage(void); #define new_DataScoreStorage Wise2_new_DataScoreStorage /* Function: hard_link_DataEntry(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DataEntry *] * * Return [UNKN ] Undocumented return value [DataEntry *] * */ DataEntry * Wise2_hard_link_DataEntry(DataEntry * obj); #define hard_link_DataEntry Wise2_hard_link_DataEntry /* Function: DataEntry_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DataEntry *] * */ DataEntry * Wise2_DataEntry_alloc(void); #define DataEntry_alloc Wise2_DataEntry_alloc /* Function: free_DataEntry(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DataEntry *] * * Return [UNKN ] Undocumented return value [DataEntry *] * */ DataEntry * Wise2_free_DataEntry(DataEntry * obj); #define free_DataEntry Wise2_free_DataEntry /* Function: hard_link_DataScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DataScore *] * * Return [UNKN ] Undocumented return value [DataScore *] * */ DataScore * Wise2_hard_link_DataScore(DataScore * obj); #define hard_link_DataScore Wise2_hard_link_DataScore /* Function: DataScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DataScore *] * */ DataScore * Wise2_DataScore_alloc(void); #define DataScore_alloc Wise2_DataScore_alloc /* Function: hard_link_DataScoreStorage(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DataScoreStorage *] * * Return [UNKN ] Undocumented return value [DataScoreStorage *] * */ DataScoreStorage * Wise2_hard_link_DataScoreStorage(DataScoreStorage * obj); #define hard_link_DataScoreStorage Wise2_hard_link_DataScoreStorage /* Function: DataScoreStorage_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DataScoreStorage *] * */ DataScoreStorage * Wise2_DataScoreStorage_alloc(void); #define DataScoreStorage_alloc Wise2_DataScoreStorage_alloc /* Function: add_Hscore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Hscore *] * Arg: add [OWNER] Object to add to the list [DataScore *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_Hscore(Hscore * obj,DataScore * add); #define add_Hscore Wise2_add_Hscore /* Function: flush_Hscore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Hscore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_Hscore(Hscore * obj); #define flush_Hscore Wise2_flush_Hscore /* Function: add_st_Hscore(obj,add) * * Descrip: Adds another object to the list. It will expand the list if necessary * * * Arg: obj [UNKN ] Object which contains the list [Hscore *] * Arg: add [OWNER] Object to add to the list [DataScoreStorage *] * * Return [UNKN ] Undocumented return value [boolean] * */ boolean Wise2_add_st_Hscore(Hscore * obj,DataScoreStorage * add); #define add_st_Hscore Wise2_add_st_Hscore /* Function: flush_st_Hscore(obj) * * Descrip: Frees the list elements, sets length to 0 * If you want to save some elements, use hard_link_xxx * to protect them from being actually destroyed in the free * * * Arg: obj [UNKN ] Object which contains the list [Hscore *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_flush_st_Hscore(Hscore * obj); #define flush_st_Hscore Wise2_flush_st_Hscore /* Function: Hscore_alloc_std(void) * * Descrip: Equivalent to Hscore_alloc_len(HscoreLISTLENGTH) * * * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * Wise2_Hscore_alloc_std(void); #define Hscore_alloc_std Wise2_Hscore_alloc_std /* Function: Hscore_alloc_len(len) * * Descrip: Allocates len length to all lists * * * Arg: len [UNKN ] Length of lists to allocate [int] * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * Wise2_Hscore_alloc_len(int len); #define Hscore_alloc_len Wise2_Hscore_alloc_len /* Function: hard_link_Hscore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Hscore *] * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * Wise2_hard_link_Hscore(Hscore * obj); #define hard_link_Hscore Wise2_hard_link_Hscore /* Function: Hscore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * Wise2_Hscore_alloc(void); #define Hscore_alloc Wise2_Hscore_alloc /* Function: free_Hscore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Hscore *] * * Return [UNKN ] Undocumented return value [Hscore *] * */ Hscore * Wise2_free_Hscore(Hscore * obj); #define free_Hscore Wise2_free_Hscore /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ DataEntry * Wise2_access_query_DataScore(DataScore * obj); #define access_query_DataScore Wise2_access_query_DataScore boolean Wise2_replace_target_DataScore(DataScore * obj,DataEntry * target); #define replace_target_DataScore Wise2_replace_target_DataScore DataEntry * Wise2_access_target_DataScore(DataScore * obj); #define access_target_DataScore Wise2_access_target_DataScore boolean Wise2_replace_is_reversed_DataEntry(DataEntry * obj,boolean is_reversed); #define replace_is_reversed_DataEntry Wise2_replace_is_reversed_DataEntry boolean Wise2_replace_score_DataScore(DataScore * obj,int score); #define replace_score_DataScore Wise2_replace_score_DataScore boolean Wise2_access_is_reversed_DataEntry(DataEntry * obj); #define access_is_reversed_DataEntry Wise2_access_is_reversed_DataEntry int Wise2_access_score_DataScore(DataScore * obj); #define access_score_DataScore Wise2_access_score_DataScore boolean Wise2_replace_query_DataScore(DataScore * obj,DataEntry * query); #define replace_query_DataScore Wise2_replace_query_DataScore boolean Wise2_replace_evalue_DataScore(DataScore * obj,double evalue); #define replace_evalue_DataScore Wise2_replace_evalue_DataScore char * Wise2_access_name_DataEntry(DataEntry * obj); #define access_name_DataEntry Wise2_access_name_DataEntry boolean Wise2_replace_name_DataEntry(DataEntry * obj,char * name); #define replace_name_DataEntry Wise2_replace_name_DataEntry double Wise2_access_evalue_DataScore(DataScore * obj); #define access_evalue_DataScore Wise2_access_evalue_DataScore boolean Wise2_raw_should_store_Hscore(int score,double cutoff); #define raw_should_store_Hscore Wise2_raw_should_store_Hscore float Wise2_raw_score_to_his(int score); #define raw_score_to_his Wise2_raw_score_to_his void Wise2_copy_DataEntry(DataEntry * from,DataEntry * to); #define copy_DataEntry Wise2_copy_DataEntry int Wise2_compare_DataScore_by_score(DataScore * one,DataScore * two); #define compare_DataScore_by_score Wise2_compare_DataScore_by_score DataScore * Wise2_new_DataScore(void); #define new_DataScore Wise2_new_DataScore DataScore * Wise2_new_DataScore_from_storage(Hscore * hs); #define new_DataScore_from_storage Wise2_new_DataScore_from_storage void Wise2_swap_Hscore(DataScore ** list,int i,int j) ; #define swap_Hscore Wise2_swap_Hscore void Wise2_qsort_Hscore(DataScore ** list,int left,int right,int (*comp)(DataScore * ,DataScore * )); #define qsort_Hscore Wise2_qsort_Hscore void Wise2_sort_Hscore(Hscore * obj,int (*comp)(DataScore *, DataScore *)); #define sort_Hscore Wise2_sort_Hscore boolean Wise2_expand_Hscore(Hscore * obj,int len); #define expand_Hscore Wise2_expand_Hscore void Wise2_swap_st_Hscore(DataScoreStorage ** list,int i,int j) ; #define swap_st_Hscore Wise2_swap_st_Hscore void Wise2_qsort_st_Hscore(DataScoreStorage ** list,int left,int right,int (*comp)(DataScoreStorage * ,DataScoreStorage * )); #define qsort_st_Hscore Wise2_qsort_st_Hscore void Wise2_sort_st_Hscore(Hscore * obj,int (*comp)(DataScoreStorage *, DataScoreStorage *)); #define sort_st_Hscore Wise2_sort_st_Hscore boolean Wise2_expand_st_Hscore(Hscore * obj,int len); #define expand_st_Hscore Wise2_expand_st_Hscore #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/protein.c0000644000175000001440000002007010670453712016461 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "protein.h" /* Function: truncate_Protein(pro,start,stop) * * Descrip: Truncates a protein sequence. Basically uses * the /trunc_Sequence function (of course!) * * It does not alter pro, rather it returns a new * sequence with that truncation * * * Arg: pro [READ ] Protein that is truncated [Protein *] * Arg: start [UNKN ] Undocumented argument [int] * Arg: stop [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Protein *] * */ # line 45 "protein.dy" Protein * truncate_Protein(Protein * pro,int start,int stop) { return Protein_from_Sequence(trunc_Sequence(pro->baseseq,start,stop)); } /* Function: read_fasta_file_Protein (filename) * * Descrip: Reads a fasta file assumming that it is protein. * Will complain if it is not, and return NULL. * * * Arg: filename [UNKN ] filename to be opened and read [char *] * * Return [UNKN ] Undocumented return value [Protein *] * */ # line 56 "protein.dy" Protein * read_fasta_file_Protein (char * filename) { Protein * out; Sequence * seq; seq = read_fasta_file_Sequence(filename); if( seq == NULL ) { return NULL; } out = Protein_from_Sequence(seq); return out; } /* Function: read_fasta_Protein (ifp) * * Descrip: Reads a fasta file assumming that it is protein. * Will complain if it is not, and return NULL. * * * Arg: ifp [UNKN ] file point to be read from [FILE *] * * Return [UNKN ] Undocumented return value [Protein *] * */ # line 78 "protein.dy" Protein * read_fasta_Protein (FILE * ifp) { Sequence * seq; seq = read_fasta_Sequence(ifp); if( seq == NULL ) { return NULL; } return Protein_from_Sequence(seq); } /* Function: read_efetch_Protein(estr) * * Descrip: Reads a efetch specified query * Uses, of course /read_efetch_Sequence * * * Arg: estr [READ ] efetch string which is read [char *] * * Return [UNKN ] Undocumented return value [Protein *] * */ # line 96 "protein.dy" Protein * read_efetch_Protein(char * estr) { return Protein_from_Sequence(read_efetch_Sequence(estr)); } /* Function: read_SRS_Protein(srsquery) * * Descrip: Reads a SRS sequence using srs4 syntax. * Uses, of course, /read_SRS_Sequence * * * * Arg: srsquery [READ ] string query representing SRS name [char *] * * Return [UNKN ] Undocumented return value [Protein *] * */ # line 108 "protein.dy" Protein * read_SRS_Protein(char * srsquery) { return Protein_from_Sequence(read_SRS_Sequence(srsquery)); } /* Function: Protein_name (pr) * * Descrip: Returns the name of the protein * * * Arg: pr [UNKN ] Undocumented argument [Protein *] * * Return [UNKN ] Undocumented return value [char *] * */ # line 118 "protein.dy" char * Protein_name (Protein * pr) { return pr->baseseq->name; } /* Function: Protein_length (pr) * * Descrip: Returns the length of the protein * * * Arg: pr [UNKN ] Undocumented argument [Protein *] * * Return [UNKN ] Undocumented return value [int] * */ # line 127 "protein.dy" int Protein_length (Protein * pr) { return pr->baseseq->len; } /* Function: Protein_seqchar(pr,pos) * * Descrip: Returns sequence character at this position. * * * Arg: pr [UNKN ] Protein [Protein *] * Arg: pos [UNKN ] position in protein to get char [int] * * Return [UNKN ] Undocumented return value [char] * */ # line 138 "protein.dy" char Protein_seqchar(Protein * pr,int pos) { return pr->baseseq->seq[pos]; } /* Function: Protein_from_Sequence(seq) * * Descrip: makes a new protein from a Sequence. It * owns the Sequence memory, ie will attempt a /free_Sequence * on the structure when /free_Protein is called * * If you want to give this protein this Sequence and * forget about it, then just hand it this sequence and set * seq to NULL (no need to free it). If you intend to use * the sequecne object elsewhere outside of the Protein datastructure * then use Protein_from_Sequence(/hard_link_Sequence(seq)) * * * * Arg: seq [OWNER] Sequence to make protein from [Sequence *] * * Return [UNKN ] Undocumented return value [Protein *] * */ # line 158 "protein.dy" Protein * Protein_from_Sequence(Sequence * seq) { Protein * out; if( seq == NULL ) { warn("Attempting to make a protein from a NULL sequence"); return NULL; } if( is_protein_Sequence(seq) == FALSE ) { warn("Trying to make a protein sequence from a non protein base sequence [%s].",seq->name); return NULL; } out = Protein_alloc(); out->baseseq = seq; return out; } # line 194 "protein.c" /* Function: hard_link_Protein(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Protein *] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * hard_link_Protein(Protein * obj) { if( obj == NULL ) { warn("Trying to hard link to a Protein object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: Protein_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Protein_alloc(void) { Protein * out; /* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(Protein *) ckalloc (sizeof(Protein))) == NULL) { warn("Protein_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif out->baseseq = NULL; return out; } /* Function: free_Protein(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Protein *] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * free_Protein(Protein * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a Protein obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; if( obj->baseseq != NULL) free_Sequence(obj->baseseq); ckfree(obj); return NULL; } /* Function: replace_baseseq_Protein(obj,baseseq) * * Descrip: Replace member variable baseseq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Protein *] * Arg: baseseq [OWNER] New value of the variable [Sequence *] * * Return [SOFT ] member variable baseseq [boolean] * */ boolean replace_baseseq_Protein(Protein * obj,Sequence * baseseq) { if( obj == NULL) { warn("In replacement function baseseq for object Protein, got a NULL object"); return FALSE; } obj->baseseq = baseseq; return TRUE; } /* Function: access_baseseq_Protein(obj) * * Descrip: Access member variable baseseq * For use principly by API functions * * * Arg: obj [UNKN ] Object holding the variable [Protein *] * * Return [SOFT ] member variable baseseq [Sequence *] * */ Sequence * access_baseseq_Protein(Protein * obj) { if( obj == NULL) { warn("In accessor function baseseq for object Protein, got a NULL object"); return NULL; } return obj->baseseq; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/protein.h0000644000175000001440000001502010670453712016465 0ustar philippusers#ifndef DYNAMITEproteinHEADERFILE #define DYNAMITEproteinHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "sequence.h" /* Object Protein * * Descrip: The protein object is a typed * example of a sequence object. * * It does nothing more than a sequence * object but is typed * * */ struct Wise2_Protein { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Sequence * baseseq; } ; /* Protein defined */ #ifndef DYNAMITE_DEFINED_Protein typedef struct Wise2_Protein Wise2_Protein; #define Protein Wise2_Protein #define DYNAMITE_DEFINED_Protein #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: truncate_Protein(pro,start,stop) * * Descrip: Truncates a protein sequence. Basically uses * the /trunc_Sequence function (of course!) * * It does not alter pro, rather it returns a new * sequence with that truncation * * * Arg: pro [READ ] Protein that is truncated [Protein *] * Arg: start [UNKN ] Undocumented argument [int] * Arg: stop [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Wise2_truncate_Protein(Protein * pro,int start,int stop); #define truncate_Protein Wise2_truncate_Protein /* Function: read_fasta_file_Protein (filename) * * Descrip: Reads a fasta file assumming that it is protein. * Will complain if it is not, and return NULL. * * * Arg: filename [UNKN ] filename to be opened and read [char *] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Wise2_read_fasta_file_Protein (char * filename); #define read_fasta_file_Protein Wise2_read_fasta_file_Protein /* Function: read_fasta_Protein (ifp) * * Descrip: Reads a fasta file assumming that it is protein. * Will complain if it is not, and return NULL. * * * Arg: ifp [UNKN ] file point to be read from [FILE *] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Wise2_read_fasta_Protein (FILE * ifp); #define read_fasta_Protein Wise2_read_fasta_Protein /* Function: read_efetch_Protein(estr) * * Descrip: Reads a efetch specified query * Uses, of course /read_efetch_Sequence * * * Arg: estr [READ ] efetch string which is read [char *] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Wise2_read_efetch_Protein(char * estr); #define read_efetch_Protein Wise2_read_efetch_Protein /* Function: read_SRS_Protein(srsquery) * * Descrip: Reads a SRS sequence using srs4 syntax. * Uses, of course, /read_SRS_Sequence * * * * Arg: srsquery [READ ] string query representing SRS name [char *] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Wise2_read_SRS_Protein(char * srsquery); #define read_SRS_Protein Wise2_read_SRS_Protein /* Function: Protein_name (pr) * * Descrip: Returns the name of the protein * * * Arg: pr [UNKN ] Undocumented argument [Protein *] * * Return [UNKN ] Undocumented return value [char *] * */ char * Wise2_Protein_name (Protein * pr); #define Protein_name Wise2_Protein_name /* Function: Protein_length (pr) * * Descrip: Returns the length of the protein * * * Arg: pr [UNKN ] Undocumented argument [Protein *] * * Return [UNKN ] Undocumented return value [int] * */ int Wise2_Protein_length (Protein * pr); #define Protein_length Wise2_Protein_length /* Function: Protein_seqchar(pr,pos) * * Descrip: Returns sequence character at this position. * * * Arg: pr [UNKN ] Protein [Protein *] * Arg: pos [UNKN ] position in protein to get char [int] * * Return [UNKN ] Undocumented return value [char] * */ char Wise2_Protein_seqchar(Protein * pr,int pos); #define Protein_seqchar Wise2_Protein_seqchar /* Function: Protein_from_Sequence(seq) * * Descrip: makes a new protein from a Sequence. It * owns the Sequence memory, ie will attempt a /free_Sequence * on the structure when /free_Protein is called * * If you want to give this protein this Sequence and * forget about it, then just hand it this sequence and set * seq to NULL (no need to free it). If you intend to use * the sequecne object elsewhere outside of the Protein datastructure * then use Protein_from_Sequence(/hard_link_Sequence(seq)) * * * * Arg: seq [OWNER] Sequence to make protein from [Sequence *] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Wise2_Protein_from_Sequence(Sequence * seq); #define Protein_from_Sequence Wise2_Protein_from_Sequence /* Function: hard_link_Protein(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [Protein *] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Wise2_hard_link_Protein(Protein * obj); #define hard_link_Protein Wise2_hard_link_Protein /* Function: Protein_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Wise2_Protein_alloc(void); #define Protein_alloc Wise2_Protein_alloc /* Function: free_Protein(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [Protein *] * * Return [UNKN ] Undocumented return value [Protein *] * */ Protein * Wise2_free_Protein(Protein * obj); #define free_Protein Wise2_free_Protein /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ boolean Wise2_replace_baseseq_Protein(Protein * obj,Sequence * baseseq); #define replace_baseseq_Protein Wise2_replace_baseseq_Protein Sequence * Wise2_access_baseseq_Protein(Protein * obj); #define access_baseseq_Protein Wise2_access_baseseq_Protein #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/pthreadpool.dy0000644000175000001440000000272107313404541017513 0ustar philippusers %{ #include "wisebase.h" #include #define MAX_THREAD_NUMBER 100 %} friend PThreadPool friend PTP_Work struct PTP_Work void (*work_routine)(void * data) !func void * data PTP_Work * next; %info This data structure holds an individual job to be executed by the PThreadPool. %% struct PThreadPool int number_of_threads pthread_t threads[MAX_THREAD_NUMBER] int max_work_size int current_work_size PTP_Work * head PTP_Work * tail pthread_mutex_t * lock; pthread_cond_t * work_to_do pthread_cond_t * queue_not_full pthread_cond_t * queue_empty int queue_closed int shutdown %info This datastructure is to hold a thread pool. Work can be added via This is work in progress. Dont use! %% %{ #include "pthreadpool.h" %func Makes a new Thread pool %% PThreadPool * new_PThreadPool(int no_threads) { PThreadPool * out; out = PThreadPool_alloc(); out->number_of_threads = no_threads; out->max_work_size = max_work; out->cur_queue_size = 0; out->head = NULL; out->tail = NULL; out->queue_closed = 0; out->shutdown = 0; out->lock = (pthread_mutex_t *) ckalloc (sizeof(pthread_mutex_t)); out->work_to_do = (pthread_cond_t *) ckalloc (sizeof(pthread_cond_t)); out->queue_not_full = (pthread_cond_t *) ckalloc (sizeof(pthread_cond_t)); out->queue_empty = (pthread_cond_t *) ckalloc (sizeof(pthread_cond_t)); if( pthread_mutex_init(out->lock,NULL) != 0 ) { warn("Unable to initialise lock mutex"); return NULL; } return out; } %} wise-2.4.1/src/dynlibsrc/testgendb0000755000175000001440000062000107313404542016537 0ustar philippusersƒ®ø_7àP0   €`v  @`@ÿÿÿÿÿÿÿÿàÊ@.dynamicð ð °ð .liblist    0 .rel.dynÐ Ð  Ѐ.dynstrð ð  (ð.dynsym/ / à(/@.hashðW ðW àðW.text`s `s €í`s .inità` à` @à`€.fini a  a @ a.gotðJ@ðJ@ÐðÊ.data@@p>€@.xdatap>@p>@ p¾@.pdataPh Ph  Phb€.rconstÐf Ðf €Ðf .sdatapH@pH@€pÈà.sbssÀR@ÀR@ à.bssàR@àR@€.comment °p p&pâ pøp³ ppðW ð /  ( ðJ@p´p pÐ p p   à`  a pÁ-¨4b ›ò ª-¨4›_•^libm.soosf.1libc.soosf.1.rconst.pdata.text.init.fini.data.rdata.xdata.sdata.lit4.lit8.sbss.bss__start_mcounteprol__eprolWise2_Probability_from_average_state_occupancyWise2_state_occupancy_from_ProbabilityWise2_Probability_logsumWise2_show_Probability_array_expWise2_read_Probability_arrayWise2_show_Probability_arrayWise2_set_Probability_arrayWise2_Probability2Score_moveWise2_Probability_moveWise2_Score_moveWise2_renormalise_Probability_arrayWise2_Probability_array_divideWise2_Probability_array_multiplyWise2_Probability_array_addWise2_Probability_array_subtractWise2_Score_array_addWise2_Score_array_subtractWise2_Score_Probability_sumWise2_halfbit2ProbabilityWise2_Bits2ProbabilityWise2_Probability2halfbitWise2_Score2BitsWise2_show_Hscore_GenomicDBWise2_get_Genomic_from_GenomicDBWise2_dataentry_add_GenomicDBWise2_new_GenomicDBWise2_hard_link_GenomicDBWise2_free_GenomicDBWise2_replace_is_single_seq_GenomicDBWise2_access_is_single_seq_GenomicDBWise2_replace_done_forward_GenomicDBWise2_access_done_forward_GenomicDBWise2_replace_forw_GenomicDBWise2_access_forw_GenomicDBWise2_replace_rev_GenomicDBWise2_access_rev_GenomicDBWise2_replace_sdb_GenomicDBWise2_access_sdb_GenomicDBWise2_replace_current_GenomicDBWise2_access_current_GenomicDBWise2_replace_cses_GenomicDBWise2_access_cses_GenomicDBWise2_read_fasta_file_GenomicWise2_read_fasta_GenomicWise2_Genomic_nameWise2_Genomic_lengthWise2_Genomic_seqcharWise2_show_GenomicWise2_hard_link_GenomicRepeatWise2_sort_GenomicWise2_flush_GenomicWise2_replace_baseseq_GenomicWise2_access_baseseq_GenomicWise2_access_repeat_GenomicWise2_length_repeat_GenomicWise2_replace_start_GenomicRepeatWise2_access_start_GenomicRepeatWise2_replace_end_GenomicRepeatWise2_access_end_GenomicRepeatWise2_replace_type_GenomicRepeatWise2_access_type_GenomicRepeatWise2_translate_SequenceWise2_read_SRS_db_SequenceWise2_read_efetch_SequenceWise2_read_Sequence_EMBL_seqWise2_show_Sequence_residue_listWise2_Sequence_alloc_lenWise2_sort_SequenceSetWise2_add_SequenceSetWise2_flush_SequenceSetWise2_SequenceSet_alloc_stdWise2_hard_link_SequenceSetWise2_free_SequenceSetWise2_replace_name_SequenceWise2_access_name_SequenceWise2_replace_seq_SequenceWise2_access_seq_SequenceWise2_replace_len_SequenceWise2_access_len_SequenceWise2_replace_maxlen_SequenceWise2_access_maxlen_SequenceWise2_replace_offset_SequenceWise2_access_offset_SequenceWise2_replace_end_SequenceWise2_access_end_SequenceWise2_replace_type_SequenceWise2_access_type_SequenceWise2_access_set_SequenceSetWise2_length_set_SequenceSetWise2_read_CodonTable_fileWise2_alloc_aminoacid_from_seqWise2_aminoacid_no_from_codonWise2_is_stop_codonWise2_is_non_ambiguous_codon_seqWise2_is_valid_aminoacidWise2_codon_from_base4_codonWise2_base4_codon_from_codonWise2_has_random_basesWise2_permute_possible_random_basesWise2_base4_codon_from_seqWise2_hard_link_CodonTableWise2_free_CodonTableWise2_replace_name_CodonTableWise2_access_name_CodonTableWise2_SequenceDB_from_FILE_and_formatWise2_single_fasta_SequenceDBWise2_read_SequenceDB_lineWise2_hard_link_FileSourceWise2_sort_SequenceDBWise2_flush_SequenceDBWise2_replace_name_SequenceDBWise2_access_name_SequenceDBWise2_access_fs_SequenceDBWise2_length_fs_SequenceDBWise2_replace_current_source_SequenceDBWise2_access_current_source_SequenceDBWise2_replace_current_file_SequenceDBWise2_access_current_file_SequenceDBWise2_replace_sequence_no_SequenceDBWise2_access_sequence_no_SequenceDBWise2_replace_byte_position_SequenceDBWise2_access_byte_position_SequenceDBWise2_replace_filename_FileSourceWise2_access_filename_FileSourceWise2_replace_input_FileSourceWise2_access_input_FileSourceWise2_replace_format_FileSourceWise2_access_format_FileSourceWise2_replace_type_FileSourceWise2_access_type_FileSourceWise2_show_ComplexSequenceWise2_hard_link_ComplexSequenceEvalWise2_sort_ComplexSequenceEvalSetWise2_flush_ComplexSequenceEvalSetWise2_ComplexSequenceEvalSet_alloc_stdWise2_replace_type_ComplexSequenceWise2_access_type_ComplexSequenceWise2_replace_seq_ComplexSequenceWise2_access_seq_ComplexSequenceWise2_replace_type_ComplexSequenceEvalSetWise2_access_type_ComplexSequenceEvalSetWise2_replace_has_been_prepared_ComplexSequenceEvalSetWise2_access_has_been_prepared_ComplexSequenceEvalSetWise2_replace_left_window_ComplexSequenceEvalSetWise2_access_left_window_ComplexSequenceEvalSetWise2_replace_right_window_ComplexSequenceEvalSetWise2_access_right_window_ComplexSequenceEvalSetWise2_replace_left_lookback_ComplexSequenceEvalSetWise2_access_left_lookback_ComplexSequenceEvalSetWise2_flat_negiWise2_default_DNA_ComplexSequenceEvalSetWise2_default_cDNA_ComplexSequenceEvalSetWise2_default_aminoacid_ComplexSequenceEvalSetWise2_get_number_from_slashed_stringWise2_is_integer_stringWise2_compress_space_around_puncWise2_striptoprintWise2_stringalloc_next_quoted_stringWise2_strwhitestartcmpWise2_strwordcmpWise2_print_numbered_lineWise2_print_lineWise2_only_whitespaceWise2_chop_newlineWise2_good_datastring_fromendWise2_looks_like_vmsWise2_looks_like_unixWise2_estrcasecmpWise2_strendWise2_string_before_equalityWise2_number_from_quoted_equalityWise2_number_from_equalityWise2_sub_stringWise2_string_from_quoted_equalityWise2_breakstringWise2_strip_quote_charsWise2_padstringWise2_second_word_allocWise2_stringallocfWise2_push_errormsg_stackWise2_push_errormsg_stack_callWise2_pop_errormsg_stackWise2_add_log_filenameWise2_error_offWise2_error_onWise2_catch_errorsWise2_stop_catching_errorsWise2_fatalWise2_start_reportingWise2_stop_reportingWise2_set_config_dirWise2_myfcloseWise2_remove_fileWise2_move_fileWise2_envopenfile_call_add_pc_range_table_call_remove_pc_range_table_call_add_gp_range_call_remove_gp_rangeetext__ldr_data__main_routine_edata_fbssedataend_end_ebss__lc_ctype__environ_ioberrno_fpdata_size_fpdataexit_ftextWise2_show_Score_arrayWise2_sum_Probability_arrayWise2_Probability2ScoreWise2_Score2ProbabilityWise2_init_GenomicDBWise2_reload_GenomicDBWise2_close_GenomicDBWise2_new_GenomicDB_from_single_seqWise2_new_GenomicDB_from_forrev_cseqWise2_GenomicDB_allocWise2_truncate_GenomicWise2_reverse_complement_GenomicWise2_Genomic_from_Sequence_NheuristicWise2_Genomic_from_SequenceWise2_GenomicRepeat_allocWise2_free_GenomicRepeatWise2_swap_GenomicWise2_qsort_GenomicWise2_expand_GenomicWise2_add_GenomicWise2_Genomic_alloc_stdWise2_Genomic_alloc_lenWise2_hard_link_GenomicWise2_Genomic_allocWise2_free_GenomicWise2_new_Sequence_from_stringsWise2_looks_like_accessionWise2_make_len_type_SequenceWise2_best_guess_typeWise2_Sequence_type_to_stringWise2_uppercase_SequenceWise2_force_to_dna_SequenceWise2_is_reversed_SequenceWise2_reverse_complement_SequenceWise2_magic_trunc_SequenceWise2_trunc_SequenceWise2_read_SRS_SequenceWise2_read_fasta_file_SequenceWise2_read_fasta_SequenceWise2_add_string_to_SequenceWise2_empty_Sequence_from_dynamic_memoryWise2_Sequence_from_static_memoryWise2_Sequence_from_dynamic_memoryWise2_write_fasta_SequenceWise2_hard_link_SequenceWise2_Sequence_allocWise2_free_SequenceWise2_swap_SequenceSetWise2_qsort_SequenceSetWise2_expand_SequenceSetWise2_SequenceSet_alloc_lenWise2_SequenceSet_allocWise2_read_CodonTableWise2_aminoacid_from_seqWise2_aminoacid_from_codonWise2_is_valid_base_charWise2_all_bases_from_codonWise2_base_from_codonWise2_codon_from_seqWise2_char_from_baseWise2_base_from_charWise2_char_complement_baseWise2_complement_baseWise2_CodonTable_allocWise2_get_Sequence_from_SequenceDBWise2_add_SequenceDB_info_DataEntryWise2_close_SequenceDBWise2_init_SequenceDBWise2_reload_SequenceDBWise2_get_next_SequenceDBWise2_SequenceDB_at_endWise2_load_next_fs_SequenceDBWise2_close_last_fs_SequenceDBWise2_FileSource_from_FILE_and_formatWise2_word_to_formatWise2_FileSource_from_lineWise2_FileSource_allocWise2_free_FileSourceWise2_swap_SequenceDBWise2_qsort_SequenceDBWise2_expand_SequenceDBWise2_add_SequenceDBWise2_SequenceDB_alloc_stdWise2_SequenceDB_alloc_lenWise2_hard_link_SequenceDBWise2_SequenceDB_allocWise2_free_SequenceDBWise2_new_ComplexSequenceWise2_show_one_position_ComplexSequenceWise2_prepare_ComplexSequenceEvalSetWise2_can_evaluate_this_SequenceWise2_can_evaluate_this_typeWise2_ComplexSequenceEval_allocWise2_free_ComplexSequenceEvalWise2_swap_ComplexSequenceEvalSetWise2_qsort_ComplexSequenceEvalSetWise2_expand_ComplexSequenceEvalSetWise2_add_ComplexSequenceEvalSetWise2_ComplexSequenceEvalSet_alloc_lenWise2_hard_link_ComplexSequenceEvalSetWise2_ComplexSequenceEvalSet_allocWise2_free_ComplexSequenceEvalSetWise2_hard_link_ComplexSequenceWise2_ComplexSequence_allocWise2_free_ComplexSequenceWise2_evaluate_ComplexSequence_GenomicWise2_default_genomic_ComplexSequenceEvalSetWise2_flat_negi_evalWise2_flat_zeroWise2_flat_zero_evalWise2_stupid_5SSWise2_stupid_5SS_evalWise2_stupid_3SSWise2_stupid_3SS_evalWise2_codon_number_ComplexSequenceEvalWise2_codon_number_funcWise2_base_number_ComplexSequenceEvalWise2_base_number_funcWise2_aminoacid_number_ComplexSequenceEvalWise2_aminoacid_number_funcWise2_is_double_stringWise2_strstartcmpWise2_string_from_charred_equalityWise2_breakstring_protectWise2_capitaliseWise2_show_lineWise2_show_textWise2_stringallocWise2_ckallocWise2_ckcallocWise2_ckreallocWise2_ckfreeWise2_show_message_stackWise2_add_log_fileWise2_error_flag_onWise2_error_flag_offWise2_push_error_callWise2_pop_error_callWise2_type_to_errorWise2_infoWise2_warnWise2_log_full_errorWise2_show_errorWise2_try_to_loadWise2_append_file_to_pathWise2_touchfileWise2_openfileWise2_start_overlayWise2_stop_overlayWise2_print_overlay__istart_etext_fdata_gpinfo__Argc__Argv_auxv_ldr_present_gpstrcmpftellfseek__exc_remove_pc_range_tablefprintfstrtokexplog__exc_add_gp_range_OtsRemainder32callocremoverenamefopengetenvstrncpyrealloc__exc_add_pc_range_tablefputs__assertstrchrstrstrstrcpyfflushfreestrtolstrtodstrcatstrlenatoifputcvsprintfmemcpy__exc_remove_gp_rangememsetpopenpcloseungetcfgetsfgetcsprintffclosemainÐf ÿ%Ph ÿ,v ÿ2à` ÿ8 a ÿ>@ÿDp>@ÿKp>@ÿRpH@ÿYpH@ÿ_pH@ÿeÀR@ÿkàR@ÿpv ÿxàv ÿ€ðv "ÿ†ðv ÿŽw ÿ½ w ÿä@w ÿýx ÿPy ÿ; z ÿXp{ ÿtà{ ÿ‘p| ÿ¨} ÿ¹°} ÿÝ~ ÿüp ÿP€ ÿ90 ÿZ‚ ÿpð‚ ÿ‹Ѓ ÿ§°„ ÿÁ0… ÿØ … ÿò€† ÿà† ÿ‡ ÿ@ ‰ ÿ^P ÿrp‘ ÿŒp’ ÿ¡°“ ÿÇ” ÿì`” ÿÀ” ÿ5• ÿRp• ÿnÀ• ÿŠ – ÿ¥p– ÿÁЖ ÿÜ — ÿü€— ÿЗ ÿ80˜ ÿT@š ÿrðš ÿ‹€› ÿž› ÿ³ › ÿÉž ÿÜ  ÿú£ ÿ °¤ ÿ!¨ ÿ?`¨ ÿ\°¨ ÿx@© ÿ”© ÿ¶ð© ÿ×@ª ÿ÷ ª ÿðª ÿ7P« ÿW µ ÿp`¼ ÿ‹½ ÿ¦€¿ ÿÃpÆ ÿäPÉ ÿý Ï ÿ0Ð ÿ*ÀÐ ÿBPÑ ÿ^0Ò ÿzÓ ÿ‘ðÓ ÿ­PÔ ÿÈ Ô ÿãÕ ÿýPÕ ÿ °Õ ÿ2 Ö ÿP `Ö ÿm °Ö ÿ‹ × ÿ¨ `× ÿà À× ÿÝ Ø ÿù pØ ÿ ÀØ ÿ1 PÙ ÿN  Ù ÿi  Û ÿˆ Ü ÿ¦ ÀÜ ÿº Ý ÿÛ Þ ÿô Þ ÿ ðÞ ÿ. °ß ÿE `à ÿi  ã ÿ„ pæ ÿŸ @ç ÿµ ðç ÿÓ Pè ÿð Ðð ÿ ñ ÿ4 pò ÿO €õ ÿj ø ÿ€ 0ú ÿ— ý ÿµ ðý ÿÒ @þ ÿí Ðþ ÿ ÿ ÿ0 €ÿ ÿW Ðÿ ÿ} 0 ÿ¢ € ÿÇ à ÿë 0 ÿ ÿ8à ÿZ@ ÿ{ ÿšð ÿ¸@ ÿØ  ÿ÷ð ÿP ÿ2@ ÿM   ÿq°  ÿ“P ÿ¶à ÿÝP ÿ° ÿ" ÿD` ÿe° ÿ ÿ¸` ÿïÀ ÿ% ÿVp ÿ†À ÿ¸  ÿép ÿÐ ÿNÀ ÿ^À ÿ‡P ÿ±0! ÿà " ÿ`# ÿÐ$ ÿ> & ÿQ ' ÿvà( ÿP* ÿžp+ ÿ¸0, ÿÉ , ÿß0- ÿò- ÿ€. ÿ%À. ÿ;/ ÿMÐ/ ÿZ@0 ÿw°1 ÿ™p3 ÿ´5 ÿÅp7 ÿçÐ8 ÿùÀ; ÿð< ÿ!PA ÿ9àB ÿLðE ÿfG ÿ… G ÿžðH ÿµpI ÿŰI ÿÔ°K ÿçÀL ÿ€O ÿ Q ÿ$`R ÿ9°T ÿNU ÿ]àV ÿoW ÿ\ ÿ‘à^ ÿª _ ÿÆP_ ÿÙ ` ÿï`a ÿõ@ÿ@ÿÀR@ÿÀR@ÿÀR@ÿ"àV@ÿ&àV@ÿ+àV@ÿ1<òÿFKòÿQbñÿ^Ph ÿf`s k`s ÿr°w ÿ‰ðz ÿ¥@„ ÿ½† ÿÕ°‰ ÿê‹ ÿ Ž ÿ0 ÿ; ÿ`Б ÿv€˜ ÿš ÿ®Л ÿÕ@ ÿñ`  ÿ Р ÿ$€¡ ÿ7°¡ ÿKP£ ÿ` ¤ ÿr@¥ ÿŠp¥ ÿ¢ ¦ ÿº€¦ ÿΧ ÿá­ ÿà­ ÿ ¯ ÿ9° ÿOб ÿm`² ÿ†P³ ÿ¢µ ÿ½À· ÿß0¹ ÿú°º ÿÀ¼ ÿ'о ÿF€Â ÿ`0Ç ÿ}€È ÿ¦àÉ ÿÈ@Ê ÿë Ë ÿÐË ÿ0Ì ÿ4ÀÌ ÿHÍ ÿ_ÀÍ ÿw`Ï ÿ€Ñ ÿ¬Ò ÿÄPÚ ÿÚ Ü ÿópÜ ÿPÞ ÿ'á ÿBðá ÿXàâ ÿm€ä ÿ‚àä ÿ—°å ÿ²æ ÿÈÐæ ÿß è ÿ@ê ÿ&Ðê ÿ=Pë ÿS°ë ÿkàí ÿ…€î ÿàî ÿ»ð ÿÚ@ñ ÿô ÿ@ô ÿ0àõ ÿGPö ÿ]÷ ÿs0÷ ÿŠÐø ÿ¢ ù ÿ·Àú ÿÒðú ÿí û ÿ ü ÿ ü ÿ5   ÿO à ÿw    ÿœ   ÿ½ @  ÿÚ  ÿú  ÿ!  ÿ;!P  ÿ^!ð  ÿ‚!À ÿ£! ÿÊ!À ÿñ!  ÿ"° ÿ6"  ÿV" ÿr"€ ÿ"  ÿ´"p ÿá" ÿö"  ÿ#p ÿ#€ ÿ,#à ÿB#  ÿS#€ ÿi#  ÿ#`  ÿ¨#  ÿÎ#ð  ÿå#À! ÿ$ " ÿ,$ $ ÿC$ð* ÿU$ 7 ÿx$9 ÿ’$ > ÿ£$à> ÿ³$Ð? ÿÃ$pC ÿÕ$PD ÿã$°D ÿò$ðD ÿ%€E ÿ%H ÿ(%ÐH ÿ;%ðI ÿO%ÐJ ÿd%€M ÿz% M ÿ%ÀM ÿ£% N ÿ®%ÐN ÿ¹%`P ÿÎ% R ÿß%pU ÿñ%@W ÿ &@X ÿ&ÐX ÿ*&P] ÿ>&p] ÿQ&À] ÿe&à` ÿn&`a ÿu&@ÿ|&@H@ÿ„&ÀR@ÿ‹&ÈR@ÿ’&ÐR@ÿ˜&ØR@ÿ¥&àÊ@ñÿ©&°&¶&¼&Ø&à&ç&ë&ï&''' '''-'4'<'D']'c'l's'z''ˆ''”'›'¢'©'®'´'½'Ä'Ú'á'ç'î'õ'û'( (( « ÿ´ïaT˜sãu,=&’v8Ίn+ÃqÂ$¹'¡ÓÇ[l(j—uc3B~Yÿ. ¨ rÊoÌ—>WL$ƒ<!^ ½#*§®Q¸Gƒž·Œ#ç{pdGV]»Ek…U2ö›†¯§Åq!'ê•Ró0P%]IO )¥Žb±*C¦{¬åñ-­Z ÄdŽ0c?=)6U|ëHz«m4t[+9 Y‘nrVJg¾‹ò/DùÒÏT5XN\±ư€KÈ/Ë hͳMè ܪ ÝS^ŸØ”¼xX"˜Ií3A&:ˆ-;’1~9,‡67;.@‰…NbzîsLF_øii W¶Caw™‡<žÙ£v_`ef ´÷}–¤"ÚºýEy𤂓w„†@xŠ‹2Ðäðœ(Ñæ|×g³Ÿ¢µÛ²£JßMO¨©}KþÀjˆÕìÔB4Á‰€¿õÉ\ô 5âÖ¡éÞá‚àpH >ûF%ú«ü? m7A”Se:–o1šD8tylªPfQ`hR›Zk™¢¦Œ„“•­‘œ¥¯©¬®²°@(#)$RCSfile: testgendb,v $ $Revision: 1.1.1.1 $ (DEC) $Date: 2001/06/18 14:00:02 $úC@Æ?€?•dyáý¥=ûÿÿÿÿ‡ÃÀ€?š™™™™™¹?ÈB€?çÿß(çÿß4çÿß@çÿßLçÿßXçÿßdçÿß@?ffffffî?«ªªª`àhàpàxà€àÐàØàààèàðà€àÀà°àÀàÀàÀà àÀàÀàÀàÀàÀàÀàÀàÀàÀàÀàÀàÀààÍÌÌÌÌÌÌÌ ×£p= ×£ð­Ûº­ À Öÿ °ÐðÖÿ`Öÿ@ÖÿÖÿÐÖÿ  ôÕÿ À`äÕÿ@ àÀ €´Õÿð´Õÿ`´Õÿà´ÕÿP´ÕÿÀ´Õÿ0´Õÿ´Õÿ@´ÕÿÐ ´Õÿ`!´ÕÿÀ"´ÕÿP&´Õÿà&´Õÿ°'´Õÿ(´Õÿ )´Õÿ€)´Õÿ *´Õÿ`+´ÕÿÀ+´Õÿ,´Õÿp,´ÕÿÀ,´Õÿ -´Õÿp-´ÕÿÐ-´Õÿ .´Õÿ€.´ÕÿÐ.´Õÿ0/´Õÿ€/´Õÿà/´Õÿ00´Õÿ°1´Õÿð1´Õÿ 2´Õÿ03@3P3€3œÕÿð4œÕÿ@6œÕÿ°7œÕÿ8œÕÿ€8œÕÿ09`9”ÕÿÀ:”Õÿ;”ÕÿÐ;”Õÿ`<”Õÿð<”Õÿ =”ÕÿÐ=”Õÿ0>”Õÿ°>”Õÿ°?”Õÿ@”Õÿ`@”Õÿð@”Õÿ@A”Õÿ A”ÕÿðA”ÕÿPB”Õÿ B”ÕÿC”ÕÿPC”Õÿ°DœÕÿEœÕÿPGœÕÿÀGœÕÿ€IJ”ÕÿK”Õÿ@MPMŒÕÿpOŒÕÿàPŒÕÿ`RŒÕÿTŒÕÿpTŒÕÿ@UŒÕÿ€VŒÕÿ0WŒÕÿ0ZŒÕÿ ^ŒÕÿà^ŒÕÿ0`ŒÕÿaŒÕÿaŒÕÿðaŒÕÿÐbŒÕÿ€cŒÕÿàcŒÕÿpdŒÕÿ@epe„ÕÿÐf„Õÿg„Õÿàg„Õÿph„Õÿi„Õÿ0i„Õÿài„Õÿ@j„Õÿ°j„Õÿ k„Õÿl„ÕÿPl„Õÿ°l„Õÿm„Õÿ`m„Õÿ°m„Õÿn„Õÿ`n„ÕÿÀn„Õÿo„Õÿpo„ÕÿÀo„Õÿ p„Õÿpp„Õÿq„ÕÿPq„Õÿr„ÕÿPs„ÕÿÐs„Õÿ t@tpttÕÿÀttÕÿÀutÕÿv@v vdÕÿ`wdÕÿxdÕÿÀx y\Õÿz\ÕÿP{\Õÿ0||TÕÿ`}TÕÿÀ} ~LÕÿ€~LÕÿð~LÕÿ LÕÿ€LÕÿP€LÕÿðLÕÿ€‚LÕÿƒLÕÿ`ƒLÕÿ…LÕÿ0†LÕÿ†LÕÿÀ‡LÕÿ€ˆLÕÿðˆLÕÿ@‰LÕÿ ŠLÕÿ°‹LÕÿð‹LÕÿ0LÕÿLÕÿŽLÕÿ°ŽàŽDÕÿ@DÕÿ€DÕÿP‘DÕÿà‘DÕÿp’DÕÿ ’DÕÿP“DÕÿ°“DÕÿ@”DÕÿ@•DÕÿ •DÕÿð•DÕÿ€–DÕÿЖDÕÿ0—DÕÿ€—DÕÿà—DÕÿ0˜DÕÿ˜DÕÿà˜DÕÿ@™DÕÿ™DÕÿð™DÕÿ@šDÕÿ šDÕÿðšDÕÿP›DÕÿ ›DÕÿœDÕÿPœDÕÿðŸDÕÿ DÕÿP¡À¡<Õÿð¡P¢4Õÿ°¢4Õÿ@£4ÕÿУ¤,Õÿ`¥,Õÿ ¥,Õÿp¦,Õÿ§,Õÿ§,ÕÿÀ§,Õÿp¨,ÕÿШ,Õÿ`©,ÕÿPª,Õÿ°ª,Õÿ0«,Õÿ¬,Õÿ`¬,Õÿ°¬,Õÿ­,Õÿ`­,ÕÿÀ­,Õÿ®,Õÿp®,ÕÿÀ®,Õÿ ¯,Õÿp¯,ÕÿЯ,Õÿ °,Õÿ€°,Õÿа,Õÿ ³,Õÿp´,ÕÿÀ´Ð´$Õÿ µ0µÕÿµÐµÕÿ0¶p¶ Õÿ· Õÿ°· Õÿ¸ Õÿ@¸ Õÿ ¸ ÕÿภÕÿp¹ Õÿй ÕÿPºÕÿ»ÕÿлÕÿ€¼ÕÿP¾ÕÿP¿ÕÿÀÕÿÂÕÿ Â à Õÿàà ÕÿPÄ ÕÿàÄ Õÿ@Å Õÿ0Æ ÕÿpÆ Õÿ°Æ Õÿ€Ç ÕÿðÇ Õÿ`É Õÿ Ë ÕÿÀÌ Õÿ Ï ÕÿPÏ Õÿ€Ð ÕÿÀÐ ÕÿpÓ Õÿ ÔÐÕÕÿÖÕÿ€×ÕÿÙÕÿÚÕÿ ÛÕÿÜÕÿ`ÜÕÿ ÜÕÿ0ÝÕÿ ÝÕÿ°ÞÕÿPßÕÿÀßÕÿ€à àüÔÿ áüÔÿ`áüÔÿ áüÔÿ€âüÔÿ`ãüÔÿpäüÔÿ0åPåpåÐåäÔÿ€æäÔÿ0çäÔÿèäÔÿPéäÔÿêäÔÿPêäÔÿ`ìäÔÿÀìäÔÿ íäÔÿîäÔÿÀîäÔÿðîäÔÿðïäÔÿ€ðäÔÿ°óäÔÿõ õäÔÿpõäÔÿöäÔÿÐöäÔÿ÷äÔÿÐ÷äÔÿø€}§èŸ#œ'{k€}§‰Ÿ#œ'{k€}§ŠŸ#œ'{k€}§‹Ÿ#œ'{k€}§ŒŸ#œ'{k€}§Ÿ#œ'{k€}§ŽŸ#œ'{k€}§Ÿ#œ'{k€}§Ÿ#œ'{k€}§‘Ÿ#œ'{k€}§’Ÿ#œ'{k€}§“Ÿ#œ'{k€}§”Ÿ#œ'{k€}§•Ÿ#œ'{k€}§–Ÿ#œ'{k€}§—Ÿ#œ'{k€}§˜Ÿ#œ'{k€}§™Ÿ#œ'{k€}§šŸ#œ'{k€}§›Ÿ#œ'{k€}§œŸ#œ'{k€}§Ÿ#œ'{k€}§žŸ#œ'{k€}§ŸŸ#œ'{k€}§ Ÿ#œ'{k€}§¡Ÿ#œ'{k€}§¢Ÿ#œ'{k€}§£Ÿ#œ'{k€}§¤Ÿ#œ'{k€}§¥Ÿ#œ'{k€}§¦Ÿ#œ'{k€}§§Ÿ#œ'{k€}§¨Ÿ#œ'{k€}§©Ÿ#œ'{k€}§ªŸ#œ'{k€}§«Ÿ#œ'{k€}§¬Ÿ#œ'{k€}§­Ÿ#œ'{k€}§®Ÿ#œ'{k€}§¯Ÿ#œ'{k€}§°Ÿ#œ'{k€}§±Ÿ#œ'{k€}§²Ÿ#œ'{kðÿÞ#þ· À¢>" ¡'RBABÄT½#RF3¤aBýÿ?ôP†§0†}§²X†§<¶H§\¶`†§|¶`ç@[k º'pT½#X§ÿÿ}'`†}¦X†=¦P†¦ü³H]¦(5{§s¦¢1¦R¦@[k º'4T½#h†=¤!  ôp}§D!^[kÞ#àkÿGþ/€ükÿGþ/ÿGÿGþ/ÿGþ/ »'àS½#à'\œˆpX X€úkÿG »'ÀS½#à'\œˆ0X`X€úkÿG »' S½#ñCþ/àÿÞ#ðC^·>²­@Ó º'¢|S½#ÿGœ§@Ó º'dS½#>ŒÿG X-@Ó º'^§LS½# Þ#€úkÿGÿG »'0S½#ÀÿÞ#^·>µ^µ~µ žµ(¾µ òG0¶òG ñC 4àGÿÿ}%0^¦˜†}§R¢}k!ëG»A[k º' =@AÜR½#ô0>¤¡!þ/M¢˜†}§+"éG¯A[k 0€A º'  ŠA¬R½#­!õÿô˜†}§+"éG¥A[k º'^§>¥^¥~¥ ž¥(¾¥„R½#@Þ#€úkÿGÿGÿG »'PR½#ÀÿÞ#^·>µðG^µ~µ žµ(¾µ ñC0¶ òGòG 4àGAŽÿÿ}%˜†}§¨}k!ëGƒA[k º' =@AüQ½#ô0>¤¡!þ/MŽ˜†}§+"éGwA[k 0€A º'  ŠAÌQ½#­!õÿô^§>¥^¥~¥ ž¥(¾¥@Þ#€úkÿG »'Q½#ÐÿÞ#^·>µ^µ~µ žµ ðG ñCòG ÿGÿÿ% †}§¸}Œ!ìGD[k º'àGLQ½#ä¡ KA ôÿGQiA 0`A›*@Ó º'$Q½#ä †}§,"ÿG~D[k º'àGQ½#ïÿô4àGþ/^§>¥^¥~¥ ž¥0Þ#€úkþ/ÿGöÿÿÃÿGôÿÿà »'ÀP½#ÀÿÞ#^·>µðG^µ~µ žµ(¾µ ñC0¶ òGòG 4àGAŽ €}¥˜†}§ëG A[k º' =@ApP½# ô0>¤¡!MŽ˜†}§+"éGA[k 0€A º'  ŠADP½#­!õÿô˜†}§+"éG A[k º'^§>¥^¥~¥ ž¥(¾¥P½#@Þ#€úkÿGñCÿ_ÿG î!q B¢ 1@@ä ì ð£0ŒP@X0Œ£ @ "¢ @ XøÿPX Xòÿô@äþ/0Œ0@£ @"Xúÿô€úkÿGòCðG@î"q@B¤ R@ÿGðG €ä @ì @#ž¦ "@#ž c ðÿ#ž§ 2@øÿ#ž÷ÿßôàäþ/0 @#ž± 2@c ûÿ?ö€úkÿGÿG »'O½#ÐÿÞ#^·>µ^µ~µ žµ òC(>¶ í ÿG ðG ñG ŽÿG 0@Ak!@Ó º'¢ IA´N½# °Œ!õÿ_ô^§>¥^¥~¥ ž¥(¤0Þ#€úkÿGÿGÿGòCñG!@î"q@B£ R@ÿGñG`ä@ì%0Bô£@¥×§@ ôŒ€ð£ @œ¨ "@0ŒP " „ øÿp³ 2@èÿ$œðÿDøÿdñÿõ`æ0 @¶ 2@"„„ ùÿßö€úkÿGÿGÿGòCñG!@î"q@B£ R@ÿGñG`ä@ì%0Bô¡@¥×£@ ôð @ð£¡ä° @¢ °¢¶ "@±„²"„ · 2@üÿ¤²ñÿßöàæ0£0 @± 2@"$³„ ùÿ?ö€úkÿGÿGÿG »'0M½#àÿÞ#þ/^·>µ ñC¶éGFÿ_Ó º'!q AM½#! í£ )@^¤ÿG`ä ìþ/€â£"Œ@ B a X¥ @¦ @àÿ"œèÿBðÿbj@Yøÿ‚k`YèÿBl€Yðÿbøÿ‚îÿ¿ôÀäþ/¢0@¨ @B m Yøÿ¢ùÿõà'\œÜ‰^§>¥ ÀY Þ#€úkÿGÿGóCðG3`î"q`B£ S@ÿGðG$`ä#@ì%Bô£@&B¥×§@ ôôÃ@¦×Ç@ÀôŒ2Œ`ñ£`X`ò£Qr‘² @ 1"µ "@ R" „ ¶ 3@jKYàÿœlYèÿDðÿ„øÿÑøÿònÏYøÿÄçÿ¿ö Àæþ/Ž2Ž0 @1"pZ» 3@R"„ øÿžöÿ÷€úkÿGóCðG3`î"q`B£ S@ÿGðG$`ä#@ì%Bô£@&B¥×§@ ôôÃ@¦×Ç@ÀôŒ2ŒQr`ñ£@X`ò£JKY @ 1"µ "@œ R" „ ¶ 3@èÿDðÿ‘ðÿ²øÿÑøÿòLYNÏYðÿ„øÿÄçÿ¿ö Àæþ/Ž2Ž0 @1"PZ» 3@R"„ øÿžöÿ÷€úkÿGóCðG3`î"q`B£ S@ÿGðG$`ä#@ì%Bô£@&B¥×§@ ôôÃ@¦×Ç@ÀôŒ2Œ`ñ£`ò£X @µ "@ 1" R" „ ¶ 3@àÿœèÿQèÿrðÿ‘ðÿ²øÿÑ KYøÿò YÏYèÿDðÿ„øÿÄçÿ¿ö Àæþ/Ž2Ž0 @1"Z» 3@R"„ øÿžöÿ÷€úkÿGóCðG3`î"q`B£ S@ÿGðG$`ä#@ì%Bô£@&B¥×§@ ôôÃ@¦×Ç@Àô`ñ£`ò£Œ2ŒQr‘²Ñ X*KYò,Y @œ.ÏYµ "@ 1"D„ R" „ ¶ 3@øÿÄçÿ¿ö Àæþ/Ž2Ž0 @1"0Z» 3@R"„ øÿžöÿ÷€úkÿGóCðG3`î"q`B£ S@ÿGðG$`ä#@ì%Bô¡@&B¥×£@ ôôÁ@¦×Ã@Àô0ñ£0ò£‘¢²¢Ñ¢ò¢£2£ q£•B @ ¢×BC„²pC¥ "@IJ1"³R" ²„ èÿ¿ô¦ 3@ Àäþ/ñ¢2£0 @1"ùB» 3@ä²R"„ öÿ÷€úkÿGóCðG3`î"q`B£ S@ÿGðG$`ä#@ì%Bô¡@&B¥×£@ ôôÁ@¦×Ã@Àô0ñ£0ò£‘¢²¢Ñ¢ò¢£4•B2£ @6×B„²8C ¢ r ¥ "@IJ#B³1"R" d°„ èÿ¿ô¦ 3@ Àäþ/‘¢2£0 @1"4™B¸ 3@„²R"„ öÿ÷€úkÿG »'G½#ñCþ/àÿÞ#ðC^·>²‰@Ó º'¢ìF½#ÿGœƒ@Ó º'ÔF½#>ŒÿG X @Ó º'^§¼F½# Þ#€úkÿGÿG »' F½#ðÿÞ#à'^·ðØ `œŒÀZÄÞ#€úk°†}§sG[k º'^§lF½#à'Pœ<ˆ@Xàà[œþ/ßG Þ#€úkÿGÿG »'0F½#ðÿÞ#à'^·hœŒžàZÄÿ_Þ#€úk°†}§°ÿ[UG[k>Œ º'ôE½#@ Xà'¨†}§Xœ\‰P XÜh[k º'^§ÐE½#Þ#€úkÿGÿGÿG »'°E½#ðÿÞ#à'^·TœˆžàZÄÿ_Þ#€úk°†}§°ÿ[5G[k º'tE½#>Œ¨†}§P X¿h[k º'^§\E½#Þ#€úkÿGÿG »'@E½#ðÿÞ#à'^·`œŒÀZÄà'TœˆÞ#€úk°†}§G[kX º'E½#°ÿ[°†}§œG[k>Œ º'^§` XìD½#Þ#€úk »'ÐD½#ðCÿ_' ðÿÞ#^·øÞ#€úk¶þ/ßG>Œà'¨†}§Áá[Pœ\‰p*Xˆh[k º'^§€D½#Þ#€úkÿGÿGÿG »'`D½#ðC°ÿ[àÿÞ#°†}§¶þ/ßGŒ^·Àà[œâF[k º'^(D½#^§à'Pœ<ˆ@X`@Y Þ#€úk »'D½#P ÐÿÞ#^·>µ^µ~µ žµ(¾µ@ì ðG ñG ÿGÿÿ½% ÿG05­!‰¤˜†}§êGíG 0`AŒ@ A„¤„¢Ĥä¤F¦g¦å}[k   º'„C½#  `Aíÿô^§>¥^¥~¥ ž¥(¾¥0Þ#€úk »'PC½#àÿÞ#^·>µ^µ~µæ ðG ñG öÿÿ&þ/P5"Ã1@Ó º'C½#ÿGIàÃþ/I ÿG@ä0J¡ª5@A@åH ¦Š@Ó º'àB½#=àÃþ/@ ¦ÿGƒ@Ó º'ÄB½#6àà ¦ÿGêG@Ó º' àG¨B½#ô*¦ÿÿ&þ/ˆ5"Ÿ1@Ó º'„B½#(  ÿÿ&þ/À6" U@ô*¦•1@Ó º'\B½#ëGà'þ/ÿGpœ<Š­ @Ó0J¡ º'¥^¥~¥ Þ#€úkÿGÿG »'ÀA½#Q¤ÿGàÿÞ#^·>µ ðG>¶¦^¶Š.@Ó º'^¤A½# ´¦ÿG @Ó^¤0 ° º'b tA½#éGþ/`ô ¦-@Ó º'LA½#^§>¥4àG Þ#€úk »'0A½#P àÿÞ#^·òG>µ4àG^µ~µ ðG ñG¢5@@@äÿGq°¦‰°+"@Ó º'ä@½#:àà ¦ÿGêGP@Ó º' àGÈ@½#1äJ ÿÿ&þ/7"£5R@+`ô¢UR@)@ô(  ¥U¨@ ô ¦1@Ó º'„@½#ëGà'þ/ÿGpœ<Š7 @ÓP)¢ º'ëGd@½#þ/Q@Ó0)¦ º'L@½#þ/4àG( ´àG)°ÿGTi¢š#@Ó º' 4òG @½#ôÿÿ&þ/P7"þ0@Ó º'*±@½#ÿG^§>¥^¥~¥ Þ#€úkÿGÿG »'Ð?½# ÐÿÞ#^·>µ^µ~µ ñG òG 5@ä1¢ÿGòG±5 B æJ²é³ ¦Ñ!@Ó º'|?½#àà TòG*±ÿGþ/^§>¥^¥~¥0Þ#€úkæÿGù!@Ó º'½#ôÿÿ&þ/ 4òGð7"³0@Ó º'Ô>½#×ÿÿÃ0)¦Ti¢þ/ëGÿG>#@Ó º' ´°>½#ô 4òGÿÿ&þ/88"¡0@Ó º'Œ>½#ÅÿÿÃþ/ëG§@Ó º'é³t>½# ¤Àÿÿà )¦ÿGÿGêGÉ@Ó º' àGL>½#µÿäJ àG£5R@±ÿô¢UR@¯ÿ_ôÿGi @Ó(+  º'>½#ÿÿ&þ/ˆ8"¡U(@ ô+¦{0@Ó º'ô=½#ëGà'þ/ÿGpœ<Š“ @Ó º'Ô=½#ëGà'þ/ÿGxœ<Ž‹ @Ó º'´=½#ô8) ÿÿ&þ/Ð8" ô+¦a0@Ó º'ëGŒ=½#ÿGØ@Ó º'ÿGx=½#éGþ/êGeÿ_Ó º'\=½#|ÿÿÃ+¦ÿÿ&þ/ 4òG°5"L0@Ó º'8=½#pÿÿÃP)¢þ/ëG…@ÓTi¢0)¦ º'=½# ´þ/àGÿGÐ"@Ó º'(´ø<½#ô8i ÿÿ&þ/(9"`ô+¦10@Ó º'ëGÌ<½#ÿG¨@Ó º'ÿG¸<½#éGþ/êG5ÿ_Ó º'œ<½#LÿÿÃ+¦ÿÿ&þ/ 4òGð5"0@Ó º'x<½#@ÿÿÃ( ¦ÿG"@Ó ^¥4àG º'(Iµ °`<½#(¤8ÿÿà »'@<½#Q ðÿÞ#^·4àG>µ ñG¢5@@@ä>¥Þ#€úkæÿG*!@Ó º'<½#( ¦ÿGæ@Ó º'( ´è;½# )¦ÿGþ/ñ@Ó º'^§>¥Ì;½#Þ#€úkÿG »'°;½#òCþ/ÀÿÞ#òC^·>µ^µ ðG ^²ÿG>¶p"@Ó º'(´x;½#éGÿG¢@Ó º'>¦`;½# ~¢þ/àG0´ÿGa"@Ó º'(¦<;½#þ/àG@Ó º'$;½# àGþ/éG•@Ó0>¤ º'^§@ ´êGH*´ ;½#>¥^¥@Þ#€úk »'à:½#àÿÞ#þ/^·¶>¶n@Ó~¤ž¤ º'^§4àGÀ:½# °`´€´ Þ#€úkÿG »':½#òCóCÐÿÞ#^·>µ^µ¶ ñG ^²$~²æ öÿÿ&þ/06"/@Ó º'^§>¥^¥H:½#ÿG0Þ#€úk)¢ÿÿ&þ/€9"¢•(B @ô/@Ó º'^§>¥^¥ :½#ÿG0Þ#€úkÿG7@Ó º'ä9½#¦þ/ àG೤@Ó º' ´È9½#éGÿGæ@Ó > $^  º'^§0 ´êGP*°°9½#TJ°>¥^¥0Þ#€úkÿGÿGÿG »'p9½#ðÿÞ#^·ðG öÿÿ&þ/h6"P/@Ó º'^§H9½#ÿGÞ#€úk@ ^§0@@@°Þ#€úkÿGÿG »'9½#ðÿÞ#þ/^·ëG›,@Ó º'ô8½# ôÿÿ&þ/¨6"4/@Ó º'^§Ø8½#ÿGÞ#€úk4àGñÿŸ$ °TáGà³À½„ à³à·à· à·(à·0à·8à³@à·Hà·P`°T€°^§Þ#€úk »'p8½#ðÿÞ#^·>µ ðG öÿÿ&þ/Ð9"/@Ó º'^§>¥D8½#ÿGÞ#€úkI ^§ÿG£=@@`ô"1@@I°>¥Þ#€úk ¦ÿGæ& @Ó º'ð7½# ¦ÿGæ @Ó º'Ø7½# ¦ÿGæ^@Ó º'À7½#( ¦ÿGæô@Ó º'¨7½#0 ¦ÿGæš@Ó º'7½#@ ¦ÿGæè@Ó º'x7½#H ¦ÿGæâ@Ó º'`7½#éGþ/},@Ó º'^§>¥L7½#ÿGÞ#€úk »'07½#ðÿÞ#^·ñC öÿÿ&þ/ :"À.@Ó º'^§7½#ÿGÞ#€úk^§4àG0²Þ#€úkÿGÿGÿG »'Ð6½#ðÿÞ#^· öÿÿ&þ/p:"©.@Ó º'^§¬6½#ÿGÞ#€úkþ/ ^§Þ#€úk »'€6½#ðÿÞ#^·ñC öÿÿ&þ/À:"”.@Ó º'^§X6½#ÿGÞ#€úk^§4àG0²Þ#€úkÿGÿGÿG »' 6½#ðÿÞ#^· öÿÿ&þ/;"}.@Ó º'^§ü5½#ÿGÞ#€úkþ/ ^§Þ#€úk »'Ð5½#ðÿÞ#^· öÿÿ&þ/`;"i.@Ó º'^§¬5½#ÿGÞ#€úkþ/^§4àG0¶Þ#€úkÿGÿGÿG »'p5½#ðÿÞ#^· öÿÿ&þ/¨;"Q.@Ó º'^§L5½#ÿGÞ#€úkþ/¤^§Þ#€úk »' 5½#ðÿÞ#^· öÿÿ&þ/ð;"=.@Ó º'^§ü4½#ÿGÞ#€úkþ/^§4àG0¶Þ#€úkÿGÿGÿG »'À4½#ðÿÞ#^· öÿÿ&þ/8<"%.@Ó º'^§œ4½#ÿGÞ#€úkþ/¤^§Þ#€úk »'p4½#ðÿÞ#^· öÿÿ&þ/€<".@Ó º'^§L4½#ÿGÞ#€úkþ/^§4àG 0¶Þ#€úkÿGÿGÿG »'4½#ðÿÞ#^· öÿÿ&þ/È<"ù-@Ó º'^§ì3½#ÿGÞ#€úkþ/ ¤^§Þ#€úk »'À3½#ðÿÞ#^· öÿÿ&þ/="å-@Ó º'^§œ3½#ÿGÞ#€úkþ/^§4àG(0¶Þ#€úkÿGÿGÿG »'`3½#ðÿÞ#^· öÿÿ&þ/X="Í-@Ó º'^§<3½#ÿGÞ#€úkþ/(¤^§Þ#€úk »'3½#ðÿÞ#^· öÿÿ&þ/ ="¹-@Ó º'^§ì2½#ÿGÞ#€úkþ/^§4àG00¶Þ#€úkÿGÿGÿG »'°2½#ðÿÞ#^· öÿG8€¦¢-@Ó º'^§2½#ÿGÞ#€úk0¤^§Þ#€úk »'`2½#°ÿÞ#þ/^·>µ^µ~µ žµ(¾µ0Þµ8þµ ñC òC ðGêG¦ëG@Ó º'2½#àGþ/ ÿGÿG@ÓI  º'ø1½#@´6@ìþ/£ KA`䉤0jAŽ@„¤Ä § fA'àô¤ &Ê@†ÀD æG¨ ª@!õ%ª@± °@…0FåGàÃI¦7KANBR¦’¢µ TA ör¢4TA¶ kBÀö¸ —B”G,SAŒ€EôGÿG´@Ó º'€±H1½#@¦àGà±ÿGœ@Ó º'(1½#‰¡ 0 AÁA¬ ¬AËÿŸõ^§>¥^¥~¥ ž¥(¾¥0Þ¥8þ¥@¤PÞ#€úk »'à0½#0¤ÿGðÿÞ#ÿG^·!¢™ÿ_Ó º'^§¼0½#Þ#€úkÿGÿG »' 0½#àÿÞ#þ/^·¶>² @Ó º'àG€0½# ôÿÿ&þ/>¦0>"-@Ó º'^§\0½#ÿG Þ#€úkþ/> ÿG ø¦@Ó º'^§00½# Þ#€úkÿG>¢B@Ó º'^§0½# Þ#€úkÿGÿGÿG »'ð/½#ðÿÞ#þ/^·>²ß @Ó º'Ô/½#àGô^§ÿGÞ#€úkþ/> ÿG ø‚@Ó º'^§ /½#Þ#€úkÿG>¢@Ó º'^§€/½#Þ#€úkÿGÿGÿG¦¤€úkÿG¦ €úkÿG¦ñC¦B0,"@0H€H€úkÿGÿGÿG »'/½#ÀÿÞ#þ/^·>µ^µ~µ žµ(¾µ0Þµ ðG ñCP@Ó º' àGØ.½#ôÿÿ&þ/`@"¬,@Ó º'ÿG¸.½#7àà ¦‡}§ÔéG†l[k º' àG˜.½#.ä,, ìGÁ,H äm,ÃmH£Õi@ `ä­,­!Å­H ä¥Õ©@ äí,­!ÇíHòÿÿô0¬Aþ/° PAæí@Ó º'àG,.½#þ/ëGàGÖ@Ó)¤ º'.½#!A.° ¤  A°‡}§íGÔéGXl[k º' àGà-½#ÒÿôëG^§>¥^¥~¥ ž¥(¾¥0Þ¥@Þ#€úkÿGÿG »' -½#àÿÞ#^·>µ ðG öÿÿ&þ/`>"[,@Ó º'^§>¥t-½#ÿG Þ#€úk(I¢ÿÿ&þ/¨@"¢UHB@ô£uHB`ô¤•HB €ô¥µHB  ô)¦F,@Ó º'^§>¥ -½#ÿG Þ#€úkþ/þ/éG@Ó º'ô,½#éGà'þ/^"„œ<ŠS@Ó  º'ˆÔ,½#äI‰i¦à_à'ÿÿ]&þ/ž¢áGÁà[ÿGAR" ê_Ëê[€œ\‰A*Xu+X,@Ó º'|,½#þ/µ@Ó º'^§ µ>¥l,½# Þ#€úk »'P,½#ÀÿÞ#ðC^·'_">µ^µ~µ žµ(¾µ0Þµ ðG ñG ôÿÿ=&‡}§X€¦˜>1"„j[k º',½# ¦ÿGêG ÿG @ÓI¢ º'êGä+½# ÿGÿÿ}%˜†}§˜>k!+"ów[k)  º'¼+½#' ìi¤˜†}§ +"êG$ƒ  ᤠÄA €ä©¤­@¥¤e¢E¢ÓAÒA51à@Þw[k º'h+½#àà ¤˜†}§P+"êG @¤`¢@¢4ÒA.ÓA0ÀAÏw[k º',+½#É¡ 0€A ¡A® ŽAÙÿßõ^§>¥^¥~¥ ž¥(¾¥0Þ¥@Þ#€úkÿGÿGÿG »'à*½#ðÿÞ#^·ðG öÿÿ&þ/XA"¬+@Ó º'^§¸*½#ÿGÞ#€úk@ ^§0@@@°Þ#€úkÿGÿG »'€*½#ðÿÞ#þ/^·ãG÷(@Ó º'd*½# ôÿÿ&þ/?"+@Ó º'^§H*½#ÿGÞ#€úk4àG^§ °à³à³à·Þ#€úk »'*½#ðÿÞ#^·>µ ðG öÿÿ&þ/ A"w+@Ó º'^§>¥ä)½#ÿGÞ#€úkI ^§ÿG£=@@`ô"1@@I°>¥Þ#€úk ¦ÿGæ)@Ó º')½#éGþ/ )@Ó º'^§>¥|)½#ÿGÞ#€úkòCñCRPBP0B¤0¦´2¶€úkÿGÿGÿG »'0)½#°ÿÞ#^·>µ^µ~µ žµ(¾µ0Þµ8þµ ñC òC@~¶  ‹A;ô ðG2B³Bþ/BëG’7JéGÛÿ_Ó 0`A º'  ¬AÌ(½#ëGäO©AJiA¦*¦@~§@[k º'éGœ(½#øÿG0ÀAíGîGÆÿ_Ó º'x(½# 0 Aï!  ¬Aíÿôþ/éGëGîG»ÿ_Ó º'@~¦L(½#þ/21ÀAéGëGÁÿ_Ó º'@~¦,(½#þ/0ÀAéGìG¹ÿ_Ó º' (½#^§>¥^¥~¥ ž¥(¾¥0Þ¥8þ¥PÞ#€úkÿGÿGÿG »'Ð'½#P ¦þ/ðÿÞ#ñG^·ÿG21@@Ÿÿ_Ó º'^§¤'½#Þ#€úk »''½# P ñCàÿÞ#^·>µ ðG>²  @ äÿÿ&þ/8?"Ò*@Ó º'^§>¥P'½#4àG Þ#€úkþ/ ¦^ þ/Q_@M(@Ó º' ´'½# ôÿÿ&þ/`?"½*@Ó º'^§>¥ü&½#ÿG Þ#€úk> ^§4àG)°>¥ Þ#€úkÿG »'À&½#P  àÿÞ#þ/^·>µ ðG>¶  @ äP@Àÿ_Ó º'^§ˆ&½#ô>¥ÿG Þ#€úkI i¤¾¤^§4àG0@@BC@‰°>¥¢´ Þ#€úkÿGÿG »'0&½#P àÿÞ#^·>µ^µ~µ ðG ÿG@ì ÿG‰¤ÿG‹@¦æøþ_Ó ¤ º'è%½# @à· 0@A)  aA¡ AAðÿ?ô^§êGé³>¥^¥~¥ Þ#€úk »' %½#ðÿÞ#þ/^·ðG@Ó º'^§„%½#Þ#€úk »'p%½#àÿÞ#þ/^·>µ²>@Ó º' àGP%½#ô^§>¥ÿG Þ#€úkÿG¢áG½'@Ó º' ´%½# ôÿÿ&þ/˜?"=*@Ó º'^§>¥ü$½#ÿG Þ#€úk^ ^§é³éGI°>¥ Þ#€úk »'À$½#ðÿÞ#^·ðG öÿÿ&þ/È?"$*@Ó º'^§˜$½#ÿGÞ#€úk@ ^§0@@@°Þ#€úkÿGÿG »'`$½#ðÿÞ#þ/^·äGo'@Ó º'D$½# ôÿÿ&þ/@"*@Ó º'^§($½#ÿGÞ#€úk4àG^§ °à·à·à³à³Þ#€úkÿGÿGÿG »'à#½#àÿÞ#^·>µ^µ~µ ðGöÿÿ&þ/ðA"é)@Ó º'¬#½#)àÃI £=@@`ô"1@@I°#àà ¦ÿGæX @Ó º'x#½#)¤ ÿG ÿG äI  @쉤ÿG‹@¦æNþ_Ó º'@#½#   0@A aA  @Aóÿô ¦ÿGp'@Ó º'#½#þ/éGk'@Ó º'#½#^§>¥^¥~¥ÿG Þ#€úk »'à"½#ðÿÞ#^· öÿÿ&þ/8B"­)@Ó º'^§¼"½#ÿGÞ#€úkþ/^§4àG0¶Þ#€úkÿGÿGÿG »'€"½#ðÿÞ#^· öÿÿ&þ/€B"•)@Ó º'^§\"½#ÿGÞ#€úkþ/¤^§Þ#€úk »'0"½#ðÿÞ#^·ñC öÿÿ&þ/ÈB"€)@Ó º'^§"½#ÿGÞ#€úkP¢ÿG¢ QB @äÿÿ&C"s)@Ó º'^§Ô!½#ÿGÞ#€úk¦^§P0B¤Þ#€úkÿG »' !½#ðÿÞ#^· öÿÿ&þ/ @"])@Ó º'^§|!½#ÿÿ Þ#€úkþ/ ^§Þ#€úk »'P!½#ðÿÞ#^·ñC öÿÿ&þ/pC"H)@Ó º'^§(!½#ÿGÞ#€úk^§4àG0²Þ#€úkÿGÿGÿG »'ð ½#ðÿÞ#^· öÿÿ&þ/ÀC"1)@Ó º'^§Ì ½#ÿGÞ#€úkþ/ ^§Þ#€úk »'  ½#ðÿÞ#^·ñC öÿÿ&þ/D")@Ó º'^§x ½#ÿGÞ#€úk^§4àG0²Þ#€úkÿGÿGÿG »'@ ½#ðÿÞ#^· öÿÿ&þ/PD")@Ó º'^§ ½#ÿGÞ#€úkþ/ ^§Þ#€úk »'ð½#ðÿÞ#^· öÿÿ&þ/˜D"ñ(@Ó º'^§Ì½#ÿGÞ#€úkþ/^§4àG0¶Þ#€úkÿGÿGÿG »'½#ðÿÞ#^· öÿGP€¦Ú(@Ó º'^§p½#ÿGÞ#€úk¤^§Þ#€úk »'@½#°ÿÞ#^·>µ^µ~µH²@>¶H> áCH>°p€¦ÿÿ=&ø}1"þ/I@Ó º'ü½#0´TèG0~¤(C°0¦ÿGPü_Ó º'ؽ#(´ÿG×@Ó º'Ľ#8´(¦8>¦ÿGþ/¿ø_Ó º'¤½# àG ÿG¡y A$ äëG >"þ/U÷_Ó º'|½# àGàÃP]¤p"j¤C¦h€=¦˜†}§˜t[k º'P½#êGëG ^"þ/›÷_Ó º'4½# àG > ¡2@ìÿ?ôêGëGþ/uø_Ó º' ½# 0 AÚÿÿÃÿG^§>¥^¥~¥PÞ#€úk »'à½#àÿÞ#þ/^·>µ^µ ðG>¶Ä@Ó º' àG¸½#ÿÿ=$þ/@E! ‰!EéG‹%@Ó>¤ º' ´”½# ôê·ê³àÃþ/ÿG¦%@Ó º'd½#àGX‡}§ ´—c[k º'4àGL½#þ/êG ° *°$ °˜@Ó º'( °(½#^§êG>¥^¥ Þ#€úkÿG »'½#àÿÞ#^·>µ^µ ðG0,@]¥Á0H äþ/J¦I 0r§ `÷h¤ .BJ‚GH@@@ 0D ô àÃ), "4àGP0HJ@[k º'„½#ä),)!Á)Hæÿ?ôi,@]¥ÃiH?`äJ¦é ^§0r§`÷h²¤i,FgH†ÇHÃiH `@EÅ@¥ P D  ô>¥^¥ Þ#€úk - "TàGPIJ@[k º'ô½#äJ¦i 0r§ `÷h2¤I,BCH‚GHAA@! 0 D ô àÃþ/‰,© 4àGP…HJ@[k º'˜½#ô),)!Á)HÉÿ?ôi,^§^¥ÃiH>¥ `@ Þ#€úk^§>¥^¥ÿG Þ#€úkÿG »'@½#ðÿÞ#X‡}§^·>µ ðG¦ c[k I  º'½#þ/éG °@"1@@$I° @Ó º'^§ô½#( °>¥Þ#€úkÿGÿG »'н#`ÿÞ#^·>µÿG^µ8^ ~µ  žµ ðG @â³£ù"@â³â³B üÿâ³øÿôB 0 @£@@üÿâ³ûÿô‰  ÿG@}¥#€ì+¦q§ `÷X¤)¤*@A,! AAH'H@ @  àÃi¤j@.c PJJ@[k º' ½#,1@¡]ƒA ä€é8^ B‚Ab 0`@b°‰  0@A¤ DAÝÿŸô)¡8¾ „Þ Pþ @¡l¢¦@à'§@4èG¨@TèG°@¸œ\Ôþ)" ú(¾´0>µ(Œ0>ŒÀà[Áá[`Xà XÔTèGàÃþ/(¾´4èG0>µ(~0žà'Ëë[Ìì[°œ¼‰klYëmY`ÕTèG^§>¥^¥~¥ ž¥ Þ#€úk »'½#ðC0B ×B䈀§\Bœ£Cükÿÿ]$PE €úkÿÿ=$~ €úkÿÿ&~ €úkÿÿ]$~ €úkÿÿ=$~ €úkÿÿ& ~ €úkÿÿ]$(~ €úkÿÿ=$`E €úkÿG »'€½#P ÀÿÞ#^·>µ^µ~µ žµ(¾µ0Þµ$@ì ðG ÿG ÿG@¥‰¤,¦q§ ‹@í `÷X±¤Í,FÇH†ÇHEÅ@¥ åGàà -M"PIJ@[k º'ô½#àG-,bÍI 0@A 4`AA-H"D-<i £ CAàÿô^§>¥^¥~¥ ž¥(¾¥0Þ¥@Þ#€úkÿGÿGÿG »'½# ÿÞ#^·>µ^µ~µ žµ(¾µ0Þµ8þµ ðG@>ž ÿGH^¶öÿÿ&þ/pE"Î&@Ó º'@½#nàÃþ/I ÿÿ&þ/°E"@üâGÃ&@Ó º'½#càÃ/@ì@Ý¥ ÿG ÿGi¤.¦q§m@Ï `÷X‘¤¯,E¦H…§HD¤@„  äGàÃï,!PèHJ@[k º' àG¬½#/,bOIþ/ 0€AA/H"D/<0`A‰¤@ 4 A¤,„ P¤HJt @ÓI¡ º'`½#‹Dª ŠAÔÿ_õI @^P~µTèGßGPŒÿGÀà[ ÿGX^´ßGX>ŒÁá[`XÀ X Ä(©°`å@ìé¤þ/ ÔéGê@-ç PIJR @Ó º'ؽ#ô‰¥ ŠA,,b¬IA,H"D,<i 0àA 4@A£ ãAèÿôH¾¤ äe±4àGàÃHþ¤àäg±ÿG^§>¥^¥~¥ ž¥(¾¥0Þ¥8þ¥`Þ#€úk P $0   "@€úk »'@½#°ýÞ#^·>µ^µ~µ žµ(¾µ0Þµ8þµ ðG ñG(¢þ/¢UB@ô£uB`ô¤•B€ô¥µB  ôöþ_Ó º'àGà½#ÿÿ&þ/K"/&@Ó º'Ľ#ÿGXàÃþ/I à'þ/4àGÀœœ¤#âCÃBDdLƒ6dH%ãCÅCD0 @•#@ÓI¤ º'|½#@´ÿÿ}$ðEC"@ôàÃâGÿÿ=&¸‡}§H"0~1"Un[k º'D½#H"þ/ ÿG ÿGÿG/#@Ó º'$½#@>¦þ/àGÿGÜ@ÓI  º'½#@´"q@@@ì@~¤ÿGêG p€Ac¤©¤ 0 A n@¯@D @ÓK,c H º'tàABKHȽ#CD4ÀAK<‰ $q€@¤ „AéÿŸô@¾¤X‡}§4èGŤÍ@-HI=¦(%²a[k@~¥ º'h½# °ëG^§>¥^¥~¥ ž¥(¾¥0Þ¥8þ¥PÞ#€úkÿGÿGÿG »' ½#ÀÿÞ#^·>µ^µ~µ žµ(¾µ0Þµ ðG(¢ UBô uBô •Bô µBþ/ 5@ ôoþ_Ó º'Ľ#àGÿÿ&þ/F"¨%@Ó º'ÿG¨½#.àà ¦)¦þ/ ÿGc@ÓI  º' àG„½#+1@@`é ëGi¤Фþ/+1`Am@Œ@£,c -5 A 4€AP£HJC @ÓN,cH º'BNH4½#CDN<ëÿù ¦X‡}§Æ`[k ° º'$‰¡½#êG б ©¡$ª±(i¡(j±^§>¥^¥~¥ ž¥(¾¥0Þ¥@Þ#€úkÿGÿGÿG »'°½#(0 àÿÞ#^·ñC>µòC£U(@`ô¤u(@€ô¥•(@ ô¦µ(@Àôþ/áGþ_Ó º'd½#àGÿÿ&þ/@F"P%@Ó º'^§>¥H½#ÿG Þ#€úkRD øÿÿ&þ/âGPK"B%@Ó º'^§>¥½#ÿG Þ#€úkþ/¡ R@ äþ/âG-@Ó º'^§>¥Ü½# Þ#€úkþ/þ/òGâG"@Ó º' àG°½# ôÿÿ&þ/€F""%@Ó º'^§>¥½#ÿG Þ#€úkþ/þ/éGSÿ_Ó º'd½#´þ/éG@Ó º'^§>¥¤L½# Þ#€úk »'0½#ÀÿÞ#^·>µ^µ~µ žµ(¾µ ñC òC ðGKE øÿÿ&þ/êGëG°K"ö$@Ó º'ÿGà½#Kàá jA äÿÿ&þ/êGëG F"ê$@Ó º'ÿG°½#?àÉ¢ÿÿ&þ/êGÐF"ëG¢ ‹B@ä)¦Ü$@Ó º'ÿGx½#1àà ¦ÿG,jAü!@Ó º'0´X½#0€A4àGþ/E"@ÓI¤ º'<½#x‡}§ àGàGìG ¬AJ@Qb[k º',,½#þ/íGA,H,<0¦–@Ó¦ º'ð½# àGX‡}§ú_[k ° º'(I Ø½#ìG(L° i j@ l° ) +@!1 @$,°^§>¥^¥~¥ ž¥(¾¥@Þ#€úkÿG »'€½#ñGÿÿ=&¸‡}§ðþÞ#ðG^·"8~1"Ùl[k º'T½#"ÿG @Ó º'^§@½#Þ#€úkÿGÿGÿG »' ½#àýÞ#ÿÿ=&¸‡}§ðG^·G1"¶">µÀl[k º'"ð ½#ÿÿ=&‡}§@~1"y[[k º'Ô ½# àG ôÿÿ=$ÿG>¦G! "i$@Ó º'^§>¥¬ ½#ÿG Þ#€úkþ/éGK@Ó º'„ ½#´˜‡}§éG÷t[k º'^§>¥¤l ½# Þ#€úk »'P ½#àýÞ#ÿÿ=&ÿG^·H~1">µ^µ ðGM@Ó º'$ ½#äþ/ "ü_Ó º' 5@ ½# äÿÿ=&¸‡}§"`G1"éG}l[k º'ä ½#àÃÿÿ=&¸‡}§"éGpG1"tl[k º'À ½#"ÿÿ$‡}§H~  ",[[k º' àG  ½# ôÿÿ&þ/éG€G"$@Ó º'^§>¥^¥| ½#ÿG Þ#€úkÿGêGþ@Ó º' àGP ½#êG˜‡}§ªt[k º'^§éG>¥^¥8 ½# Þ#€úkÿGÿG »' ½#àÿÞ#ÿÿ=&ÿG^·X~1">µ¶x&@Ó º' àGè ½# ôÿÿ&þ/>¦¨G"ï#@Ó º'^§>¥Ä ½#ÿG Þ#€úkþ/éGÑ@Ó º'´œ ½#éGÀ‡}§éh[k º'^§>¥¤„ ½# Þ#€úkÿGÿG »'` ½#@ÿÞ#^·>µp ^µ~µ žµ(¾µ0Þµ òG ðG ñC ÿG@}¥K¦0r§ `÷h2¤P,BCH‚GHAA@! 0 D ô àÉ,© 4àGP…HJ@[k º'Ø ½#ôÿÿ&þ/éGL"¬#@Ó º'¸ ½#ÿÿÝ%`~Î!þ/éGîGª@Ó º'éG˜ ½#䨇}§ìGêGöj[k º'x ½#ñÿôÿÿ&þ/h~"½ @Ó º'àG\ ½#ÿGü@Ó º' àGH ½#°‡}§êG¼r[kðD º'¡õßA0 ½# àG; ô®õÅA Àå°‡}§êG±r[kðD º'®õÅA ½# àG0ÀõK¦"‡I0r§‚GH`÷h2¤AA@! 0 D ôàÃ#‡I4àGgH@[k º'° ½#äÍC8.,bŽI 0 AA.H"D8.<£Ý¯AÑÿôÍCéG8¤,ÿG8>" ÿGE¤H8¤"KnI ðŸE8n=X@Ój¥ º' ½#¬õ…AË’`I bE `õ €å°‡}§êGgr[kðD º'­U@ õ@ܽ# EöÿäàÃÿÿ&þ/H")#@Ó º'¬½#éGÿGXû_Ó º'˜½#^§éG>¥^¥~¥ ž¥(¾¥0Þ¥ÀÞ#€úkÿGÿG »'`½#@ÿÞ#^·>µ^µ~µ žµ(¾µ0Þµ ðG ÿGP¤°‡}§Â’@HBD2@ô6r[kðD º'¡õ?@½# àG ô@¥L¦#gIƒgH0r§Ÿ `÷hR¤Bb@B DD@ôàÃ%gI?"§H@[k º'¼½# ä°‡}§éGr[kðD º'¡õ?@¤½# àGäÿ?äi¤ ðEÿÿ&¤ÕgAþ/XL"Ã’`HbD£ãC`ô €ôÕ"@Ó º'\½#ÿG^§>¥^¥~¥ ž¥(¾¥0Þ¥ÀÞ#€úk«õAôÿõóÿô@¥,¤°‡}§éG0a¥`õh¡¥ðq[k!H_ 'H º'A-@½#! àG"D ôàÃþ/°‡}§éGáq[kL¦-H º'§IĽ#àG?"ëG@Kk º' ½# ô ðßE­õ¿A õ ÊC 0@A8+,bËIA+H"D8+<Óÿÿà ðßEÊC£õ¿AÁÿô8¤,ÿG8"ªõ¿AE¤H­U¡A8¤<´@Ó º'àG8½# MEÿGò@Ó º' àG ½#¯ÿä @õ°‡}§éG°q[k ðD º'ªõ¿A­U¡A ME½#öÿ_åàG ÿG)¤°‡}§éGÁ’ H"D9 ô q[kL¦#HƒgH ðD º'¡ÕGAÀ½#àG/ ôªõ_A-@õ0r§`÷hR¤Bb@B 0@D @ôàÃþ/$ÇI4àG‡H@[k º'`½#ä ÍC8*,bÊI 0 AA*H"D8*<£Ý¯AÕÿôÍCëG8¤,ÿG8>"E¤H8¤"JLI8L=F@Ó ðßE.ÇIÇI º'ªÕGAÀ½#@å ‡}§éG*\[k º'˜½#þ/ëGSú_Ó º'„½#ëGIÿÿÃÿG »'p½#ÀÿÞ#^·>µ^µ~µ žµ(¾µ0Þµ òC ñC¡ «A äÿÿÝ% ðG óG íGp~Î!þ/I¤˜†}§êGîGìG 0€AM@ 4 Ab,B SbH“gJÿm[k º'  ‹Aì½#ïÿô^§>¥^¥~¥ ž¥(¾¥0Þ¥@Þ#€úkÿGÿG »'°½#àÿÞ#X‡}§^·>µ^µ~µ ðG ñGñG$][ki I 0@ º'€½#êGP‡}§#C@¥ ƒ@  ä ¦Lp[k ¦ º'P½#X‡}§][k º'<½#)àà ¦#ƒ@ðo@þ/ÁcD÷ H!÷ HA@ 0@ëGG@Ó º'½#àGô)¥ÿÿ&pH"80" õàÃéGþ/ëG±!@Ó º'ÿG̽#àÃP‡}§êG ¶i±"p[k ¦ º'¨½#X‡}§é\[k º'”½# °4àG^§>¥^¥~¥ Þ#€úkÿGÿGÿG »'`½#àÿÞ#þ/^·>µ^µ ðGå@Ó º' àG<½#ô^§>¥^¥ÿG Þ#€úkþ/ õÿÿ=%þ/ L)!éG|!@Ó º'ü "ø½#þ/Ÿ@Ó º'ä½# àGþ/ðG*µ4àGç@Ó º'^§ðG ´êG*°Ä½#ê³>¥^¥ Þ#€úkÿG »'½#àÿÞ#þ/^·>µ^µ ðC±@Ó º' àGl½#ô^§>¥^¥ÿG Þ#€úkþ/þ/éG4àGÂ@Ó º'^§ ´êG*±0½#*±>¥^¥ Þ#€úkÿG »'½#àÿÞ#þ/^·>¶_@Ó º'ä½#¦ÿG´Y@Ó º'¦Ì½#þ/àG@Ó º'^§´½# Þ#€úk »' ½#àÿÞ#^·>µ^µ~µ ðG ñG öÿÿ&þ/ÈH"!@Ó º'ÿGh½#àà õÿÿ=%þ/èL)!éG!@Ó º'ü "@½#þ/1@Ó º' àG,½#ÿG\@Ó º' àG½# äX‡}§êG µ@µA\[k º' °ôÿ½# °ëG^§>¥^¥~¥ Þ#€úkÿGÿG »'Àÿ½#àÿÞ#ðC^·_">µ ðG>¶ ôÿÿ=&‡}§€€¦I1"e_[k º'„ÿ½#)¤€€]¤ÿÿ}$""IC" ôàÃáG˜†}§¦Øl[k ¦ º'Pÿ½#^¦þ/”çGÏ@Ó º'^§>¥4ÿ½# Þ#€úkÿGÿGÿG »'ÿ½#ðÿÞ#^·ðG öÿÿ&þ/0I"¸ @Ó º'^§èþ½#ÿGÞ#€úk@ ^§0@@@°Þ#€úkÿGÿG »'°þ½#ðÿÞ#þ/^·æG@Ó º'”þ½# ôÿÿ&þ/pI"œ @Ó º'^§xþ½#ÿGÞ#€úk4àGà·^§ÿÿ @°èGà·à³à³ @°$`°(€°Þ#€úkÿGÿG »' þ½#ðÿÞ#^·>µ ðG öÿÿ&þ/8M"{ @Ó º'^§>¥ôý½#ÿGÞ#€úkI ^§ÿG£=@@`ô"1@@I°>¥Þ#€úk ¦ÿGæ@Ó º' ý½# ¦ÿGæ @Ó º'ˆý½#þ/éG@Ó º'^§>¥tý½#ÿGÞ#€úkÿGÿGòCñCRPBP0B¤0¦´2¶€úkÿGÿGÿG »' ý½#°ÿÞ#^·>µ^µ~µ žµ(¾µ0Þµ8þµ ñC òC@~¶  ‹A;ô ðG2B³Bþ/BëG’7JéGÛÿ_Ó 0`A º'  ¬A¼ü½#ëGäO©AJiA¦*¦@~§@[k º'éGŒü½#øÿG0ÀAíGîGÆÿ_Ó º'hü½# 0 Aï!  ¬Aíÿôþ/éGëGîG»ÿ_Ó º'@~¦<ü½#þ/21ÀAéGëGÁÿ_Ó º'@~¦ü½#þ/0ÀAéGìG¹ÿ_Ó º'üû½#^§>¥^¥~¥ ž¥(¾¥0Þ¥8þ¥PÞ#€úkÿGÿGÿG »'Àû½#P ¦þ/ðÿÞ#ñG^·ÿG21@@Ÿÿ_Ó º'^§”û½#Þ#€úk »'€û½# P ñCàÿÞ#^·>µ ðG>²  @ äÿÿ&þ/ˆI"Î@Ó º'^§>¥@û½#4àG Þ#€úkþ/ ¦^ þ/Q_@I@Ó º' ´ û½# ôÿÿ&þ/°I"¹@Ó º'^§>¥ìú½#ÿG Þ#€úk> ^§4àG)°>¥ Þ#€úkÿG »'°ú½#P p àÿÞ#þ/^·>µ ðG>¶£ b@ `äH@Àÿ_Ó º'^§xú½#ô>¥ÿG Þ#€úkI i¤¾¤^§4àG0@@BC@‰°>¥¢´ Þ#€úkÿGÿG »' ú½#P àÿÞ#^·>µ^µ~µ ðG ÿG@ì ÿG‰¤ÿG‹@¦æðþ_Ó ¤ º'Øù½# @à· 0@A)  aA¡ AAðÿ?ô^§êGé³>¥^¥~¥ Þ#€úk »'ù½#ðÿÞ#þ/^·èG@Ó º'^§tù½#Þ#€úk »'`ù½#àÿÞ#þ/^·>µ²>@Ó º' àG@ù½#ô^§>¥ÿG Þ#€úkÿG¢áG¹@Ó º' ´ ù½# ôÿÿ&þ/ðI"9@Ó º'^§>¥ìø½#ÿG Þ#€úk^ ^§é³éGI°>¥ Þ#€úk »'°ø½#ðÿÞ#^·ðG öÿÿ&þ/ˆM" @Ó º'^§ˆø½#ÿGÞ#€úk@ ^§0@@@°Þ#€úkÿGÿG »'Pø½#ðÿÞ#þ/^·ãGk@Ó º'4ø½# ôÿÿ&þ/(J"@Ó º'^§ø½#ÿGÞ#€úk4àG^§ °à·à³à³Þ#€úk »'à÷½#àÿÞ#^·>µ^µ~µ ðGöÿÿ&þ/ÐM"é@Ó º'¬÷½##àÃI £=@@`ô"1@@I°àɤ ÿG ÿG€ä©   ìé¤ÿGë@¦æPþ_Ó º'X÷½#   0@A aA  @Aóÿô ¦ÿGv@Ó º'0÷½#éGþ/q@Ó º'÷½#^§>¥^¥~¥ÿG Þ#€úkÿGÿG »'ðö½#ðÿÞ#^· öÿÿ&þ/ N"±@Ó º'^§Ìö½#ÿGÞ#€úkþ/^§4àG0¶Þ#€úkÿGÿGÿG »'ö½#ðÿÞ#^· öÿÿ&þ/hN"™@Ó º'^§lö½#ÿGÞ#€úkþ/¤^§Þ#€úk »'@ö½#ðÿÞ#^· öÿÿ&þ/°N"…@Ó º'^§ö½#ÿGÞ#€úkþ/^§4àG0¶Þ#€úkÿGÿGÿG »'àõ½#ðÿÞ#^· öÿÿ&þ/HJ"m@Ó º'^§¼õ½#ÿGÞ#€úkþ/¤^§Þ#€úk »'õ½#ðÿÞ#^·ñC öÿÿ&þ/øN"X@Ó º'^§hõ½#ÿGÞ#€úk^§4àG0²Þ#€úkÿGÿGÿG »'0õ½#ðÿÞ#^· öÿÿ&þ/ˆJ"A@Ó º'^§ õ½#ÿGÞ#€úkþ/ ^§Þ#€úk »'àô½#ðÿÞ#^·ñC öÿÿ&þ/@O",@Ó º'^§¸ô½#ÿGÞ#€úk^§4àG0²Þ#€úkÿGÿGÿG »'€ô½#ðÿÞ#^· öÿÿ&þ/ˆO"@Ó º'^§\ô½#ÿGÞ#€úkþ/ ^§Þ#€úk »'0ô½#ðÿÞ#^·ñC öÿÿ&þ/ÐO"@Ó º'^§ô½#ÿGÞ#€úk^§4àG 0²Þ#€úkÿGÿGÿG »'Ðó½#ðÿÞ#^· öÿÿ&þ/P"é@Ó º'^§¬ó½#ÿGÞ#€úkþ/  ^§Þ#€úk »'€ó½#ðÿÞ#^·ñC öÿÿ&þ/`P"Ô@Ó º'^§Xó½#ÿGÞ#€úk^§4àG$0²Þ#€úkÿGÿGÿG »' ó½#ðÿÞ#^· öÿÿ&þ/ÈJ"½@Ó º'^§üò½#ÿGÞ#€úkþ/$ ^§Þ#€úk »'Ðò½#ðÿÞ#^·ñC öÿÿ&þ/¨P"¨@Ó º'^§¨ò½#ÿGÞ#€úk^§4àG(0²Þ#€úkÿGÿGÿG »'pò½#ðÿÞ#^· öÿÿ&þ/ðP"‘@Ó º'^§Lò½#ÿGÞ#€úkþ/( ^§Þ#€úk »' ò½#ðÿÞ#^·ñC öÿÿ&þ/8Q"|@Ó º'^§øñ½#ÿGÞ#€úkP¢ÿG¢ QB @äÿÿ&€Q"o@Ó º'^§Äñ½#ÿGÞ#€úk¦^§P0B¤Þ#€úkÿG »'ñ½#ðÿÞ#^· öÿGx€¦Z@Ó º'^§pñ½#ÿÿ Þ#€úk ^§Þ#€úk »'@ñ½#àÿÞ#ÿÿ=&ÿG^·~1">µ¶Ä@Ó º' àGñ½# ôÿÿ&þ/>¦0R";@Ó º'^§>¥ôð½#ÿG Þ#€úkþ/éG@Ó º'´Ìð½#éGÀ‡}§5b[k º'^§>¥¤´ð½# Þ#€úkÿGÿG »'ð½#ÐýÞ#þ/^·>µ^µ~µ žµ ðG@Ó º'dð½# àGˆ‡}§"ïG´ïG5[[k º'Dð½#¨‡}§("?"éGbd[k º'(>¤(ð½#,äð?D("£uD@óÿôð?D¢5D@ðÿ_ô¨€}¥ †}§ëG7l[k º' àGìï½# †}§+"ÿG0l[k º' àGÐï½#€åôÿÿ&þ/`R"é@Ó º'¬ï½#ìGÿGè@Ó‹-@A@, Ë‹I º'caI˜ï½#BAHCD@<ËÿÿÃ^§êG>¥^¥~¥ ž¥0Þ#€úkÿGÿG »'@ï½#èÿ> ÿG!¶?HàÿÞ#¶ñG^·>°Ç@Ó º'ï½#¦þ/àG#@Ó>  º'üî½#ðDñ?Dþ/D°"Û@Ó º'^§Ôî½# Þ#€úk »'Àî½#ðÿÞ#þ/¶ñG^·ª@Ó º'¦ î½#àGÿG@Ó º'^§ˆî½#Þ#€úkÿG1&J‘&JB,"@H€H€úk1&J‘&JB0,"A0H'H 5(@€úkÿGÿGÿG »' î½#0JÿGJðÿÞ#ñG^·áGâÿ_Ó º'^§¡ @ U@øí½# DÞ#€úkÿGÿG »'Ðí½#ðÿÞ#^·ð, Ð !ÁðHÿG+ äp,GèHP ÃdH&`ä°,‡çHçGŦH! ä^´ß@Ó º' •@tí½#!ô~¤ÿG#,C c P"HJ~´Ò@Ó º' •@@í½#ô^¤ÿG",B P"HJÇ@Ó º'^§ •@í½#8DÞ#€úkÿÿ&þ/¨R"8@Ó º'èì½#^§ÿGÞ#€úk »'Ðì½#1'J‡}§‘'JðÿÞ#^·" \[k º'^§¬ì½# àCÞ#€úkÿGðF¡Õ B ô¢uB@ô£õB`ô¤5B°• BD€úkþ/4àG€úkÿGÿGðCðBÁF— H"&He!@‚FHA¡@"—@H"Bp@@ÃBDƒW`H$fHCc@„†HDŸ@#@"D@"@!&H€&H€úkÿG »'ðë½#0JÿGJàÿÞ#^·>"^"~"@Ó¤ º'~¤!vHÄë½#¡• @ ô^¤%v`H#fH¥• @$v@H^§"FH¤•€@‚FH…D€ôƒfH H"—@H€HBb@@ Þ#€úkÿÿ&þ/ðR"Ñ@Ó º'^§Lë½#èG Þ#€úkÿG »'0ë½#0JÿGàÿÞ#4àG^·>µ‰JéG‡@Ó º'ë½#´þ/éGTàG€@Ó º'´èê½#éGtàGþ/y@Ó º' •@Ìê½# ô>¥>¤^§©• A¡• @!E>¥ Þ#€úk^§>¥4àG Þ#€úkÿG »'€ê½#0JÿGÐÿÞ#^·>µ^µ‰J ñG~¶éG ^¶4àGW@Ó º'Dê½#éGþ/TàGQ@Ó º'éG,ê½#þ/tàGiJAJ@Ó ¤>¤I*A º'@@^§ A>¥@^¥ Hê½#€H0Þ#€úkÿG »'Ðé½# J¸€§€H!àC\¤ÁD"L– H"áCÂDcB@Cb@#B¦ fH€H!àCÁD0LV H0áCÐDQ FDB#d@P F#fHƒfH æ¡ fDHE¤H¦D¡°@æQ@FP@F eJD‚H…D°`æQ`FP`F1 b`HA H"D1°€úkÿGÿGÿG »'ðè½# J¸€§€HñC!àC\¤ÁDðÿÞ#^·"LÿG– H"áCÂDcB@Cb@#B¦ fH€H!àCÁD0LV H0áCÐD¡5 B ôDB#d@#fH¤U B €ô€fH£u B`ôÿÿ&8S"@Ó º'^§Lè½#”àGÞ#€úkþ/^§0J€JÞ#€úk"FH€FH^§Þ#€úkÿGÿG »'è½#àÿÞ#^·>µP ^µ ðG)!0,ÿGP"HJt@Ó º'þÿ),Èç½#ÿÿI ÿGP"HJ àGk@Ó º'´¤ç½#ÿÿ),ÿGP)HiJAJb@Ó>¤I*A º'^§A!@^¥!A>¥ @€ç½# H€H Þ#€úkÿGÿG »'@ç½#àÿÞ#^·>µP ðG)!0,ÿGP"HJE@Ó º'´þÿ), ç½#ÿÿI ÿGP"HJ<@Ó º'´ÿÿ),èæ½#ÿGP)HJ4@Ó º'©•@Èæ½# õ>¤~¤^§>¥¢• @!— H¤•`@Aa@DD@ô@ Þ#€úkþ/^§>¥èG Þ#€úkÿGÿGÿG »'`æ½#0JJ öJ°€§ @ä\Bœ£Cük4èG€úkôèG€úktèG€úk”êG€úkÔéG€úkôçG€úk »'æ½# J@=¤€HðÿÞ#!¦^·q§`÷XQ¤@@ àÃ0JJ@[k º'¼å½#àC!'H°€§'H!5(@"ö!H\<@¢}B@°@ä(œ£Cük^§ÿGÞ#€úk^§tàGÞ#€úk^§4àGÞ#€úk^§TàGÞ#€úk^§”àGÞ#€úk »'0å½#0JÿGJðÿÞ#^·Æÿ_Ó º'àGå½#þ/ @Ó º'àGüä½#ÿG¤ÿ_Ó º'^§èä½#Þ#€úkÿG »'Ðä½#0JJ öJ°€§ @ ä\Bœ£CüktàG€úkTàG€úk4àG€úkÿG€úk”àG€úkÿGÿG »'pä½#ðÿÞ#^·ðG öÿÿ&þ/˜S"@Ó º'^§Hä½#ÿGÞ#€úk@ ^§0@@@°Þ#€úkÿGÿG »'ä½#ðÿÞ#þ/^·òG[@Ó º'ôã½# ôÿÿ&þ/ˆR"ô@Ó º'^§Øã½#ÿGÞ#€úk^§4àG °ˆà·Þ#€úkÿGÿG »' ã½#ðÿÞ#^·>µ ðG öÿÿ&þ/àS"Û@Ó º'^§>¥tã½#ÿGÞ#€úkI ^§ÿG£=@@`ô"1@@I°>¥Þ#€úkˆ ¦ÿGær@Ó º' ã½#éGþ/m@Ó º'^§>¥ ã½#ÿGÞ#€úk »'ðâ½#ðÿÞ#^· öÿÿ&þ/0T"±@Ó º'^§Ìâ½#ÿGÞ#€úkþ/^§4àGˆ0¶Þ#€úkÿGÿGÿG »'â½#ðÿÞ#^· öÿG €¦š@Ó º'^§pâ½#ÿGÞ#€úkˆ¤^§Þ#€úk »'@â½#àÿÞ#^·>µ^µ ñG öÿÿ&þ/ÀT"‚@Ó º'^§>¥^¥â½#ÿG Þ#€úk öÿÿ&þ/U"u@Ó º'^§>¥^¥Üá½#ÿG Þ#€úk@ ¦ÿG öÿÿ&@U"g@Ó º'^§>¥^¥¤á½#ÿG Þ#€úkþ/ÿÿ=&þ/°~1"Ú@Ó º' àGpá½# ô@)¦ÿÿ&þ/Y"Q@Ó º'^§>¥^¥Lá½#ÿG Þ#€úk8)¦ˆ†}§êGÿGšm[k)¢ º'á½#êGþ/ 5$Bä(ö_Ó º' àGøà½#àÃÿÿ&þ/ ÿG€U"3@Ó º'Ôà½#êGÀ‡}§8^[k º'^§éG>¥^¥Àà½# Þ#€úk »' à½#ðÿÞ#^·æ öÿÿ&þ/XY"@Ó º'^§xà½#ÿGÞ#€úkP¤ p ^§4àGBb@B¤B¤@Q´4° 8±´Ф 0 A&@!¤! 1°Þ#€úkÿGÿG »'à½#ðÿÞ#^·>µ ñGæÿGuø_Ó º'ìß½#0) ÿÿ&þ/¨Y"¡5 @ ä8I @ôÂ@Ó º'4àGÀß½#8 °^§ÿÿ_ I°4àG>¥Þ#€úkÿG »'ß½#àÿÞ#þ/^·>µ ðG ð³>¶0ð³Û@Ó º'dß½#^¦þ/ÿGéG@Ó º'^§>¥Hß½# Þ#€úk »'0ß½#àÿÞ#^·>µ^µ~µ ñG òG ÿGæÿG9ø_Ó º'üÞ½#éGÿG|@Ó º'òGèÞ½#ä*°0i 0`@0i°jàÃþ/þ/éG—@Ó º' 5@´Þ½#äÿGéGô@Ó º'˜Þ½# ô )¢)¥ÿÿ&þ/ U"I)B)¥I¦˜@Ó º'hÞ½#Màà TòG*±LàÃþ/éG 0`AÞ@Ó º'éG@Þ½#äÿGŒ@Ó º'éG(Þ½#"äÿGF@Ó º'Þ½#*ôÿÿ&þ/Z"{@Ó º'ôݽ#éGÿGb@Ó º' 5@àݽ# ô¡]aAÞÿ?ô!àÃþ/ )¢I¤ÿÿ&þ/ÐU"B"BB¤B¦e@Ó º'œÝ½#àà I )¤ÿÿ&þ/V"AA@0@@!¤A¦X@Ó º'hݽ# àà òG*± àÃTòG*° àÃþ/ÿÿ&þ/8V"J@Ó º'0ݽ# 4òGj±ÿG^§>¥^¥~¥ Þ#€úkÿG »'ݽ#ðÿÞ#€†}§^·>µ ðG(¦Sv[k i I¤4 ° º'Üܽ#þ/Bb@B¤"¢¤5$B€ä( ¦õ_Ó º'^§>¥¨Ü½#Þ#€úkÿÿ&þ/pV"@Ó º'^§>¥€Ü½#ÿGÞ#€úkÿG »'`ܽ# P ðÿÞ#^·ÿG4@@ ô0¦ÿÿ&pZ" @Ó º'^§0ܽ#4àGÞ#€úk¢^§0@@  BÞ#€úk »'ܽ# P àÿÞ#^·>µ^µ ðG4@@þ/ ô0¦ÿÿ&¸Z"ï@Ó º'^§>¥^¥ÄÛ½#ÿG Þ#€úkþ/i ÿÿ&þ/["£ b@ `äß@Ó º'^§>¥^¥„Û½#ÿG Þ#€úkþ/i¤ÿÿ=&þ/¸~1"BC@B¥ ¦æM@Ó º'( ´<Û½#ôI¦*¦ÿÿ&þ/V"Ã@Ó º'^§>¥^¥Û½#ÿG Þ#€úkJ¥(Iµ4àG^§>¥^¥ Þ#€úkÿG »'ÐÚ½# P ðÿÞ#^·>µ ðG4@@ ô0¦ÿÿ&þ/°["¤@Ó º'^§>¥˜Ú½#ÿGÞ#€úki¤À‡}§BC@B¤¢¤ ä( ¦Ÿ\[k º'\Ú½#àÃB¤ÿÿ&þ/ÀV"@äŒ@Ó º'8Ú½# ) ^§4àG0 @ )°>¥Þ#€úk »'Ú½#àÿÞ#þ/¶4àG^·>²@Ó º'¦ìÙ½#ÿG>¢´@Ó º'¦ÐÙ½#àGÿG @Ó º'^§¤¸Ù½# Þ#€úk »' Ù½#ñCþ/àÿÞ#^·¶>²!@Ó>¤~  º'^§|Ù½# ´`° Þ#€úkÿGÿG »'PÙ½#àÿÞ#þ/^·>µ^µ ðG¥@Ó º'éG,Ù½# ôÿÿ&þ/W"A@Ó º'^§>¥^¥ Ù½#ÿG Þ#€úkÿGû@Ó º'䨽# àGþ/éGY@Ó º'4äGÌØ½#þ/4àG ´*°1@Ó º' àG¬Ø½#þ/àGêGÖ@Ó º'^§éG>¥^¥Ø½# Þ#€úk »'pؽ#àýÞ#^·>µ^µ~µ ñG ðGÿÿ}%þ/À~k!ëG@Ó º'8ؽ#äÿÿ&þ/8W"@Ó º'ÿGؽ#Dàà†}§+"éG;f[k º'+"ü×½# †}§éG5f[k º'ä×½#àGôÿÿ&þ/xW"@Ó º'Ä×½#àÃÿG@Ó º'°×½#´ÿGá@Ó º' àGœ×½#¨‡}§ "?"êG7^[k º'+"|×½#äÿG "Ü @Ó º' +"`×½#ðÿäþ/ "Õ @Ó º'D×½#äþ/ "%@Ó º'àG,×½#ãÿäÿGéGv@Ó º'×½#ÝÿÿÃþ/éG^§>¥^¥~¥ Þ#€úkÿG »'àÖ½#ðÿÞ#x†}§È€=¦^·áS[k4äGÁD º'^§ÄÖ½#áGÞ#€úkÿG »' Ö½#àÿÞ#ÿÿ=& †}§^·ð~1">µ^µ~µ ðGØe[k º' àGpÖ½#éGÿÿ=$ †}§ð~! !"Ïe[k º' àGLÖ½#ÿÿ=$ †}§éGð~! !"Æe[k º'(Ö½#äÿG@å`åE@Ó º' àG Ö½#þ/êG£@Ó º'ôÕ½# ´þ/ëGÁÿ_Ó º' ° @ÜÕ½#äÿÿ&þ/êGëG¸W"j@Ó º'°Õ½#éGàÃÿÿ&þ/ˆW"b@Ó º'ÿGÕ½#^§>¥^¥~¥ Þ#€úkÿGÿGÿG »'`Õ½#ðÿÞ#^·ðG öÿÿ&þ/ø["L@Ó º'^§8Õ½#ÿGÞ#€úk@ ^§0@@@°Þ#€úkÿGÿG »'Õ½#ðÿÞ#þ/^·äG—@Ó º'äÔ½# ôÿÿ&þ/ðW"0@Ó º'^§ÈÔ½#ÿGÞ#€úk4àG^§ °à·à³à³Þ#€úk »'Ô½#ðÿÞ#^·>µ ðG öÿÿ&þ/@\"@Ó º'^§>¥dÔ½#ÿGÞ#€úkI ^§ÿG£=@@`ô"1@@I°>¥Þ#€úk ¦ÿGæ®@Ó º'Ô½#éGþ/©@Ó º'^§>¥üÓ½#ÿGÞ#€úkòCñCRPBP0B¤0¦´2¶€úkÿGÿGÿG »'°Ó½#°ÿÞ#^·>µ^µ~µ žµ(¾µ0Þµ8þµ ñC òC@~¶  ‹A;ô ðG2B³Bþ/BëG’7JéGÛÿ_Ó 0`A º'  ¬ALÓ½#ëGäO©AJiA¦*¦@~§@[k º'éGÓ½#øÿG0ÀAíGîGÆÿ_Ó º'øÒ½# 0 Aï!  ¬Aíÿôþ/éGëGîG»ÿ_Ó º'@~¦ÌÒ½#þ/21ÀAéGëGÁÿ_Ó º'@~¦¬Ò½#þ/0ÀAéGìG¹ÿ_Ó º'ŒÒ½#^§>¥^¥~¥ ž¥(¾¥0Þ¥8þ¥PÞ#€úkÿGÿGÿG »'PÒ½#P ¦þ/ðÿÞ#ñG^·ÿG21@@Ÿÿ_Ó º'^§$Ò½#Þ#€úk »'Ò½# P ñCàÿÞ#^·>µ ðG>²  @ äÿÿ&þ/X"r@Ó º'^§>¥Ðѽ#4àG Þ#€úkþ/ ¦^ þ/Q_@í@Ó º' ´œÑ½# ôÿÿ&þ/8X"]@Ó º'^§>¥|ѽ#ÿG Þ#€úk> ^§4àG)°>¥ Þ#€úkÿG »'@ѽ#P  àÿÞ#þ/^·>µ ðG>¶  @ äP@Àÿ_Ó º'^§ѽ#ô>¥ÿG Þ#€úkI i¤¾¤^§4àG0@@BC@‰°>¥¢´ Þ#€úkÿGÿG »'°Ð½#P àÿÞ#^·>µ^µ~µ ðG ÿG@ì ÿG‰¤ÿG‹@¦æøþ_Ó ¤ º'hн# @à· 0@A)  aA¡ AAðÿ?ô^§êGé³>¥^¥~¥ Þ#€úk »' н#ðÿÞ#þ/^·ðG@Ó º'^§н#Þ#€úk »'ðϽ#àÿÞ#þ/^·>µ²>@Ó º' àGÐϽ#ô^§>¥ÿG Þ#€úkÿG¢áG]@Ó º' ´œÏ½# ôÿÿ&þ/pX"Ý@Ó º'^§>¥|Ͻ#ÿG Þ#€úk^ ^§é³éGI°>¥ Þ#€úk »'@Ͻ#ðÿÞ#^·ðG öÿÿ&þ/\"Ä@Ó º'^§Ͻ#ÿGÞ#€úk@ ^§0@@@°Þ#€úkÿGÿG »'àν#ðÿÞ#þ/^·èG@Ó º'Äν# ôÿÿ&þ/¨X"¨@Ó º'^§¨Î½#ÿGÞ#€úk4àGÿÿ °à·à·à³à³ `°0à³4à³8à³^§Þ#€úkÿGÿG »'Pν#àÿÞ#^·>µ^µ~µ ðGöÿÿ&þ/Ø\"…@Ó º'ν#)àÃI £=@@`ô"1@@I°#àà ¦ÿGæ$@Ó º'èͽ#)¤ ÿG ÿG äI  @쉤ÿG‹@¦æJþ_Ó º'°Í½#   0@A aA  @Aóÿô ¦ÿG @Ó º'ˆÍ½#þ/éG@Ó º'tͽ#^§>¥^¥~¥ÿG Þ#€úk »'Pͽ#ðÿÞ#^· öÿÿ&þ/(]"I@Ó º'^§,ͽ#ÿGÞ#€úkþ/^§4àG0¶Þ#€úkÿGÿGÿG »'ð̽#ðÿÞ#^· öÿÿ&þ/p]"1@Ó º'^§Ì̽#ÿGÞ#€úkþ/¤^§Þ#€úk »' Ì½#ðÿÞ#^·ñC öÿÿ&þ/¸]"@Ó º'^§x̽#ÿGÞ#€úkP¢ÿG¢ QB @äÿÿ&^"@Ó º'^§D̽#ÿGÞ#€úk¦^§P0B¤Þ#€úkÿG »'̽#ðÿÞ#^· öÿÿ&þ/ÈX"ù@Ó º'^§ì˽#ÿÿ Þ#€úkþ/ ^§Þ#€úk »'À˽#ðÿÞ#^·ñC öÿÿ&þ/`^"ä@Ó º'^§˜Ë½#ÿGÞ#€úk^§4àG 0²Þ#€úkÿGÿGÿG »'`˽#ðÿÞ#^· öÿÿ&þ/°^"Í@Ó º'^§<˽#ÿGÞ#€úkþ/  ^§Þ#€úk »'˽#ðÿÞ#^· öÿÿ&þ/_"¹@Ó º'^§ìʽ#ÿGÞ#€úkþ/^§4àG(0¶Þ#€úkÿGÿGÿG »'°Ê½#ðÿÞ#^· öÿÿ&þ/P_"¡@Ó º'^§ŒÊ½#ÿGÞ#€úkþ/(¤^§Þ#€úk »'`ʽ#ðÿÞ#^·ñC öÿÿ&þ/ _"Œ@Ó º'^§8ʽ#ÿGÞ#€úk^§4àG00²Þ#€úkÿGÿGÿG »'ʽ#ðÿÞ#^· öÿÿ&þ/ð_"u@Ó º'^§Üɽ#ÿGÞ#€úkþ/0 ^§Þ#€úk »'°É½#ðÿÞ#^·ñC öÿÿ&þ/@`"`@Ó º'^§ˆÉ½#ÿGÞ#€úk^§4àG40²Þ#€úkÿGÿGÿG »'Pɽ#ðÿÞ#^· öÿÿ&þ/`"I@Ó º'^§,ɽ#ÿGÞ#€úkþ/4 ^§Þ#€úk »'ɽ#ðÿÞ#^· öÿÿ&þ/à`"5@Ó º'^§ÜȽ#ÿGÞ#€úkþ/^§4àG0¶Þ#€úkÿGÿGÿG »' È½#ðÿÞ#^· öÿÿ&þ/0a"@Ó º'^§|Ƚ#ÿGÞ#€úkþ/¤^§Þ#€úk »'PȽ#ðÿÞ#^· öÿÿ&þ/xa" @Ó º'^§,Ƚ#ÿGÞ#€úkþ/^§4àG0¶Þ#€úkÿGÿGÿG »'ðǽ#ðÿÞ#^· öÿÿ&þ/Àa"ñ@Ó º'^§Ìǽ#ÿGÞ#€úkþ/¤^§Þ#€úk »' Ç½#ðÿÞ#^·ñC öÿÿ&þ/b"Ü@Ó º'^§xǽ#ÿGÞ#€úk^§4àG0²Þ#€úkÿGÿGÿG »'@ǽ#ðÿÞ#^· öÿÿ&þ/Pb"Å@Ó º'^§ǽ#ÿGÞ#€úkþ/ ^§Þ#€úk »'ðƽ#ðÿÞ#^·ñC öÿÿ&þ/˜b"°@Ó º'^§Èƽ#ÿGÞ#€úk^§4àG0²Þ#€úkÿGÿGÿG »'ƽ#ðÿÞ#^· öÿGÀ€¦š@Ó º'^§pƽ#ÿGÞ#€úk ^§Þ#€úk »'@ƽ#°ÿÞ#^·>µ^µ~µ žµ(¾µ0Þµ8þµ ñG@¶ ö ðGÿÿ&þ/@d"{@Ó º'ôŽ#ÿGÄàÃþ/ÿG@>¦êGB@Ó º'@>¥ÐŽ#ô()¡ÿGéG*ë_ÓJ¡ º'°Å½#H´þ/êG#ë_Ó º'”Ž#H^¦ÿÿ&þ/àGéGˆd"êGY@Ó º'ÿGlŽ#¢àÃJ ÿÿ&þ/àd"@ôO@Ó º'DŽ#êGÿGü@Ó º'0Ž#ÿGR@Ó º'H´ Ž#ô àGÿGŒàÃþ/Š  ª @>¤ÿG”àGA D@EL­@ÓH>¤ º'ÜĽ#´ô J¡@>¥)¡ÿÿ&þ/Pe"*M(@Ó º'H¦¨Ä½#þ/O@Ó º'”Ľ#ÿGlàÃþ/J  j Hž¤ÿGCL@@@´ª % ì ê ÿGÿGàìJ¦ *¢d¦ÑLPBR¦B(B0AR¢Q3BQ² Š¢µ AÔL  æʦ䦈BÐB0AÖ¦T—BBÖ¢Ô² £¸ Aãÿ÷*£0À@¹ Ù@Ûÿ?÷ J£„¥@~§ ÿG D³{ +`ì  ÿGÿGìê¤@¾¦IÌAï@g¥ +¢± ±A öK¢õ¢²A² òB @ö0k§ +¦µ¦( ¢­B@[k º' °Pý#àÃk¡AÌAa±0ÀA J áA¢ ÂAáÿ_ôH~¤@ž¤ 0 A c „ Ll@¤ ¤AÕÿŸôÿG@¦ûð_ÓH>¥@~¥ º' ´ô½#k¡éG$i±^§>¥^¥~¥ ž¥(¾¥0Þ¥8þ¥PÞ#€úkÿGÿGÿG »' Â½#P¤àÿÞ#^·>µ^µ~µ ðG ñGB¦ñGÿÿ=&˜†}§ ÿG0c1"›][k$)  º'\½# ìÿGéGëGêG@Ó$   0`A º'8½#  `Aõÿô^§>¥^¥~¥ Þ#€úkÿGÿG »'½#àÿÞ#^·>µ^µ~µ ðG ñC òG¦ÿÿ=&˜†}§Hc1"¦ BP."SPJêG“gJëGm][k ¤ )¢ º'¤Á½#êGÿG +NP`A–Û_Ó º'êG€Á½#˜†}§Ø€=¦^][k º'^§>¥^¥~¥hÁ½# Þ#€úkÿGÿG p ÿGÿGÿG4àGÿG`ìð¤'¦0 @ç q¢´ @À“F ‘¢Q¢³ 4@ÁtF´ £@³ ’@ÄrFòÿŸö°4àG 0°°а€úk »'ÐÀ½#(1¢ÿGðÿÞ#^·@Ó º'^§´À½#Þ#€úkñC (Bô¡U(B 䢠UBô¡uB ô µBô •B€úk4àG€úk¢ B€úkþ/ÿG€úkÿGÿG »'@À½#ðÿÞ#^·ðG öÿÿ&þ/˜e"@Ó º'^§À½#ÿGÞ#€úk@ ^§0@@@°Þ#€úkÿGÿG »'࿽#ðÿÞ#þ/^·çGO@Ó º'Ä¿½# ôÿÿ&þ/Xc"è@Ó º'^§¨¿½#ÿGÞ#€úk4àG^§ °à³à³ à³à³à³à³(à³0à·Þ#€úkÿGÿGÿG »'P¿½#ðÿÞ#^· öÿÿ&þ/èe"É@Ó º'^§,¿½#ÿGÞ#€úkþ/P ^§ÿG£=@@`ô"1@@P°Þ#€úkÿGc@Ó º'^§ä¾½#ÿGÞ#€úkÿGÿGÿGòCñCRPBP0B¤0¦´2¶€úkÿGÿGÿG »'¾½#°ÿÞ#^·>µ^µ~µ žµ(¾µ0Þµ8þµ ñC òC@~¶  ‹A;ô ðG2B³Bþ/BëG’7JéGÛÿ_Ó 0`A º'  ¬A,¾½#ëGäO©AJiA¦*¦@~§@[k º'éGü½½#øÿG0ÀAíGîGÆÿ_Ó º'ؽ½# 0 Aï!  ¬Aíÿôþ/éGëGîG»ÿ_Ó º'@~¦¬½½#þ/21ÀAéGëGÁÿ_Ó º'@~¦Œ½½#þ/0ÀAéGìG¹ÿ_Ó º'l½½#^§>¥^¥~¥ ž¥(¾¥0Þ¥8þ¥PÞ#€úkÿGÿGÿG »'0½½# P ¦þ/ðÿÞ#ñG^·ÿG21@@Ÿÿ_Ó º'^§½½#Þ#€úk »'ð¼½#  $P ñCàÿÞ#^·>µ ðG>²  @ äÿÿ&þ/€c"*@Ó º'^§>¥°¼½#4àG Þ#€úkþ/ ¦^ þ/Q_@¥ @Ó º' ´|¼½# ôÿÿ&þ/@f"@Ó º'^§>¥\¼½#ÿG Þ#€úk> ^§4àG$)°>¥ Þ#€úkÿG »' ¼½# P $p àÿÞ#þ/^·>µ ðG>¶£ b@ `äB@Àÿ_Ó º'^§è»½#ô>¥ÿG Þ#€úk I i¤¾¤^§4àG0@@BC@ ‰°>¥¢´ Þ#€úkÿGÿG »'»½# P àÿÞ#^·>µ^µ~µ ðG ÿG@ì ÿG‰¤ÿG‹@¦æÿ_Ó ¤ º'H»½# @à· 0@A )  aA¡ AAðÿ?ô^§êG é³>¥^¥~¥ Þ#€úk »'»½#ðÿÞ#þ/^·âG@Ó º'^§äº½#Þ#€úk »'к½#àÿÞ#þ/^·>µ²>@Ó º' àG°º½#ô^§>¥ÿG Þ#€úkÿG¢áG @Ó º' ´|º½# ôÿÿ&þ/¸c"•@Ó º'^§>¥\º½#ÿG Þ#€úk^ ^§ é³éG$I°>¥ Þ#€úk »' º½#ðÿÞ#^·ðG öÿÿ&þ/ˆf"|@Ó º'^§ø¹½#ÿGÞ#€úk@ ^§0@@@°Þ#€úkÿGÿG »'À¹½#ðÿÞ#þ/^·åGÇ @Ó º'¤¹½# ôÿÿ&þ/øc"`@Ó º'^§ˆ¹½#ÿGÞ#€úk4àG^§ °à³à³ à³à³à³à·$à³ à³Þ#€úkÿGÿGÿG »'0¹½#àÿÞ#^·>µ^µ~µ ðGöÿÿ&þ/Øf"=@Ó º'ü¸½##àÃI £=@@`ô"1@@I°àɤ ÿG ÿG€ä ©   ìé¤ÿGë@¦æXþ_Ó º'¨¸½#   0@A aA  @Aóÿô ¦ÿGÊ @Ó º'€¸½#éGþ/Å @Ó º'l¸½#^§>¥^¥~¥ÿG Þ#€úkÿGÿG »'@¸½#ðÿÞ#^·ðG öÿÿ&þ/0g"@Ó º'^§¸½#ÿGÞ#€úk@ ^§0@@@°Þ#€úkÿGÿG »'à·½#ðÿÞ#þ/^·åGO @Ó º'Ä·½# ôÿÿ&þ/ d"è@Ó º'^§¨·½#ÿGÞ#€úk4àG^§ °à³à·à· à³$à³Þ#€úkÿGÿG »'`·½#ðÿÞ#^·>µ ðG öÿÿ&þ/xg"Ë@Ó º'^§>¥4·½#ÿGÞ#€úkI ^§ÿG£=@@`ô"1@@I°>¥Þ#€úk ¦ÿGæ2î_Ó º'à¶½# ¦ÿGæ\ @Ó º'ȶ½#þ/éGW @Ó º'^§>¥´¶½#ÿGÞ#€úkÿGÿG »'¶½#ðÿÞ#^·ñC öÿÿ&þ/Èg"˜@Ó º'^§h¶½#ÿGÞ#€úk^§4àG0²Þ#€úkÿGÿGÿG »'0¶½#ðÿÞ#^· öÿÿ&þ/h"@Ó º'^§ ¶½#ÿGÞ#€úkþ/ ^§Þ#€úk »'ൽ#ðÿÞ#^· öÿÿ&þ/`h"m@Ó º'^§¼µ½#ÿGÞ#€úkþ/^§4àG0¶Þ#€úkÿGÿGÿG »'€µ½#ðÿÞ#^· öÿÿ&þ/°h"U@Ó º'^§\µ½#ÿGÞ#€úkþ/¤^§Þ#€úk »'0µ½#ðÿÞ#^·ñC öÿÿ&þ/øh"@@Ó º'^§µ½#ÿGÞ#€úk^§4àG0²Þ#€úkÿGÿGÿG »'д½#ðÿÞ#^· öÿÿ&þ/Pi")@Ó º'^§¬´½#ÿGÞ#€úkþ/ ^§Þ#€úk »'€´½#ðÿÞ#^·ñC öÿÿ&þ/ i"@Ó º'^§X´½#ÿGÞ#€úk^§4àG0²Þ#€úkÿGÿGÿG »' ´½#ðÿÞ#^· öÿÿ&þ/j"ý @Ó º'^§ü³½#ÿGÞ#€úkþ/ ^§Þ#€úk »'г½#ðÿÞ#^·ñC öÿÿ&þ/`j"è @Ó º'^§¨³½#ÿGÞ#€úk^§4àG 0²Þ#€úkÿGÿGÿG »'p³½#ðÿÞ#^· öÿÿ&þ/Àj"Ñ @Ó º'^§L³½#ÿGÞ#€úkþ/  ^§Þ#€úk »' ³½#ðÿÞ#^·ñC öÿÿ&þ/k"¼ @Ó º'^§ø²½#ÿGÞ#€úk^§4àG0²Þ#€úkÿGÿGÿG »'À²½#ðÿÞ#^· öÿÿ&þ/xk"¥ @Ó º'^§œ²½#ÿGÞ#€úkþ/ ^§Þ#€úk »'p²½#ðÿÞ#^·ñC öÿÿ&þ/Ðk" @Ó º'^§H²½#ÿGÞ#€úk^§4àG0²Þ#€úkÿGÿGÿG »'²½#ðÿÞ#^· öÿGЀ¦z @Ó º'^§ð±½#ÿGÞ#€úk ^§Þ#€úk »'À±½#ÀÿÞ#^·>µðC^µ~µ žµ(¾µ0Þµu æ ðG ñG òC óC1 ‡}§à€=¦è€¦4èG¡•(@j ä@ôÛK[k º'\±½#) ÿÿ&‡}§TèGàl"0" ôÑK[k º'4±½#)¤ÿÿ&‡}§tèGm"0"!  ôÆK[k º'±½# ¦ÿGêG ÿG­ú_Ó º' àGì°½#NäI ÿGC@쉤Ž@„¤¤ $¢¥ %B7 äþ/ɤ1Bgç@Gÿ@â@”â@Æ ¦ Ñ@$Àô ¦0 B1BvÖBVßBÂB”ÂBBp±j¦gB‡±‰¦ŽB”¦”¢´ 4B€æ©¦µ¢µ ±B öê¦0 BøBw± ¥Aˆ±)§.C9§9£¹ 9BÔÿ?÷ àÃI§ÿÿ&þ/8m"íGZ¢ö @Ó º'௽#   0 AÁA   A½ÿôêGàÃÿÿ&þ/l"é @Ó º'¬¯½#ÿG^§>¥^¥~¥ ž¥(¾¥0Þ¥@Þ#€úkÿGÿGÿG »'p¯½#ðÿÞ#þ/^·táG>µ"ý_Ó º' àGP¯½#þ/=@Ó º'àG<¯½#þ/éGÃü_Ó º'$¯½#þ/@Ó º'¯½#àGþ/éG¹ü_Ó º'ü®½#þ/e@Ó º'àG쮽#þ/éG¯ü_Ó º'Ô®½#þ/ƒ@Ó º'Ä®½#àGþ/éG¥ü_Ó º'¬®½#þ/9@Ó º'àGœ®½#þ/éG›ü_Ó º'„®½#þ//@Ó º't®½#àGþ/éG‘ü_Ó º'”èG\®½#þ/éG °@û_Ó º'^§éG>¥@®½#Þ#€úkÿG »' ®½#ðÿÞ#þ/^·Œû_Ó º'^§®½#ðØ_ à}$ à³0Rc à³@°0`´Þ#€úkÿGÿGðØ €úkÿGÿG »'À­½#ðÿÞ#þ/^·tû_Ó º'^§¨­½#ðØ_ à}$ à³Rc à³@°0`´Þ#€úkÿGÿGÿG€úkÿGÿG »'`­½#ðÿÞ#þ/^·\û_Ó º'tàGH­½#ôàGàÝ$^§áGðØ¿ °SÆ `°€° °0À´Þ#€úkÿGÿG2,ðØŸ ÿGÁ2H¡õ(@ är,R"ÃrH£•j@€dD€úkðØ €úkÿGÿG »'À¬½#ðÿÞ#þ/^·4û_Ó º'tàG¨¬½#^§à½$´àGðØŸ ° S¥  °`°€°0 ´Þ#€úkÿGÿGÿGÿÿ2,ÿÿR ðØŸ ÿGÁ"H¡5(@ är,ÃrH£õh@€dD€úkðØ €úkÿGÿG »' ¬½#ðÿÞ#þ/^·4àG>µNü_Ó º' àG¬½#þ/i@Ó º'àG쫽#þ/éGïû_Ó º'Ô«½#TèGþ/éG °žú_Ó º'^§éG>¥¸«½#Þ#€úkÿGÿGÿG »'«½#ðÿÞ#þ/^·TàG>µ*ü_Ó º' àGp«½#þ/E@Ó º'àG\«½#þ/éGËû_Ó º'D«½#þ/@Ó º'4«½#àGþ/éGÁû_Ó º'tèG«½#þ/éG °pú_Ó º'^§éG>¥«½#Þ#€úkÿG »'ઽ#ðÿÞ#þ/^·¼ú_Ó º'^§Èª½#ôÿGÞ#€úkà$TàG^§´ïG€U„ °à³`°0€´Þ#€úk »'€ª½#ðÿÞ#þ/^·þÿ"›ð_Ó º'^§dª½#Þ#€úk »'Pª½#ðÿÞ#þ/^·˜ú_Ó º'^§8ª½#ôÿGÞ#€úkà]$^§à³VB à³0@´Þ#€úkÿGÿGÿG »'ð©½#ðÿÞ#^·2,R"ÿGP2HJôð_Ó º'^§È©½#Þ#€úkÿG »'°©½#ðÿÞ#þ/^·4àG>µ²û_Ó º' àG©½#þ/@Ó º'àG|©½#þ/éGSû_Ó º'd©½#4èGþ/éG °ú_Ó º'^§éG>¥H©½#Þ#€úkÿGÿGÿG »' ©½#ðÿÞ#þ/^·Lú_Ó º'^§©½#ôÿGÞ#€úkà]$^§à³@WB à³0@´Þ#€úkÿGÿGÿG »'À¨½#ðÿÞ#@=¤^·’ !¦q§ `÷XQ¤r,CdHƒgHBb@B ^° 1H@Þ#€úkþ/²,R"P²HJ@[k º'^§°\¨½# 1@Þ#€úk »'@¨½#ðG ‡}§ðÿÞ#ñG>¶áG^·æG[k º'^§¨½#ôÿÿ Þ#€úk>¤ÿGA,ÂAH@ä¥ @ äÁ,-0€@ÆÁH! ¦õÅ@ÈIÄÑD å² @@æ.! 0€@ÔJ¨õAÄEìÿŸö^§äGÞ#€úkÿGÿG »'€§½#àÿÞ#@‡}§>¶>"^·TáG‡M[k^¤ º'\§½#@äàC°@}¤C¦¾¤^§0r§¥ `÷h’¤ÿÿÅ,EÅH…§HD¤@„ 0€D Ÿ@ Þ#€úkþ¤4àG-ç PIJ@[k º'^§ä¦½# @ Þ#€úkÿGÿGÿG »'À¦½#àÿÞ#H‡}§>¶>"^·(i[k>¤ º' ¦½# äœ@]¤ž¤B¦„ ^§0r§ `÷hr¤ÿÿ¤,D¤H„‡HCƒ@c 0`D @ Þ#€úkÞ¤4àGæ,Æ PæHJ@[k º'^§,¦½# @ Þ#€úkÿG »'¦½#ÐÿÞ#^·>µ^µ~µ žµ(¾µ ðG ñG òG ðG àÃl,Œ ‡}§êGQdH‘'JOJ[k º'¼¥½#ôŒ!,,Á,Hòÿ?ô,,ÿÿ¬!£-AÁ,HH ä `ä,­ ‡}§ëGQ…H‘'J;J[k º'l¥½#äÿÿ­!¡-Aóÿ?ô¢©A @ô­!£¬A`ä(‡}§íGìG íG;K[k º',¥½# ,À HäL,l ‡}§êGQCH‘'JJ[k º'ü¤½#ä¬-Œ!Á¬Iòÿ?ôL, ìGÂLH@ä@äŒ,¬ ‡}§Q…HëG‘'J J[k º'°¤½#ä,,Œ!Á,Hòÿ?ô£¬A`ô(‡}§íGìGK[k º'|¤½# íG°ÿÿÃ^§>¥^¥~¥ ž¥(¾¥0Þ#€úkÿGÿGÿG »'@¤½#ÐÿÞ#^·>µÿG^µ~µ ðGö.àÃþ/), éG >µÁ)H$ ä@}¥K¦© 0r§ `÷hr¤‰,D…H„‡HCƒ@c pD `ôàÃþ/É,é ðGPÇHJ@[k º'¨£½#ä),Š,Á)He*HDŠHJ!…DÿÿŠ<)!É,ÆÉHÝÿßô .P J > ¤^§>¥^¥~¥0Þ#€úkÿG »'@£½#àÿÞ#^·>µ0,Á0H äp,ÃpH£Ud@ `ô°,"ŰH ä¥U¤@ ôð,"ÇðHòÿÿô0.^§Ñ0J>¥ öÿG Þ#€úkp." ðGÓpJ`æ©.Õ©JµU¤B  öé.)!×éJàæ·UäBàö)/)!Ù)Kòÿ?÷i/^§ÿGÛiK`÷>¥ Þ#€úk),ÿGÁ)H>´i,CiHi<µ@Ó^¤i, º'dIH<¢½#CiHdDi<^§>¥ Þ#€úkÿGÿGÿG »'¢½#àÿÞ#^·>µP ^µ~µ ñG ðG òG0,‡}§òGQ"H‘'JOI[k º'¼¡½# ä),I ‡}§ëGQ"H)!‘'JDI[k º'¡½#õÿô),Á)H, äj,ÃjH¡#@ ä©,Å©H äê,ÇêHàä .J.)!J!Ð JÒJJ´B €æ æ@æ©.ê.)!J!Õ©J×êJµ·Bèÿ¿ö*/ÿGÙ*K ÷àÃþ/i/j-)!J!IiKJjI‰'IŠGI *AàÃJ,J!BJH‚GH âC^§>¥^¥~¥ Þ#€úkÿGÿGÿG »' ½#ðÿÞ#^·0,Á0H äq,ÃqH `ä°,ŰH££@`äð,"1"ÇðHôÿÿôq."‡}§ÑqJ öÿÿ.QJòG‘'JçH[k º'^§ ½# @Þ#€úkþ/^§4àGÞ#€úk0,Á0H äþ/q,Ð !"ÃqH`äÿÿ°,ñ,E¦H1"GèH…§H‡çH² å@ @ö¥ §@  ôp.ÓpJìÿö±.ѱJ ñC€úk4àG€úkÿÿ €úk »'pŸ½#àÿÞ#^·>µ^µ ðC ñGñGêGÿÿ=&˜†}§01"ÒT[kðØ* üJ €˜ D£™LAªYAA º'€x@D8Ÿ½#ÀT`DÀ4@E¤™@ €ä àGþ/h‡}§ôëGéG 0@A‹I[k º' ™HAìž½#÷ÿôh‡}§TáGéGƒI[k º'^§>¥^¥Ìž½# Þ#€úk »'°ž½#àÿÞ#^·>µ^µ ðG ÿGh‡}§ôëGéG 0@AoI[k º' ÙHA|ž½#÷ÿôh‡}§TáGéGgI[k º'^§>¥^¥\ž½# Þ#€úk »'@ž½#àÿÞ#^·>µ^µ ðG ñG0,Á0H äþ/i,‰ ‡}§êGQdH‘'J]H[k º'ô½#ä),)!Á)Hòÿ?ôi,^§ÃiH>¥^¥ @ Þ#€úkÿGÿG »'°½#ðÿÞ#X‡}§^·¶©C[k>¤ º' @”½#ÿÿ@,ÿÿ Â@H¢UA@@ä€,D€H€<^§Þ#€úkÿGÿG »'P½#àÿÞ#X‡}§^·>µ^µ~µ ðG ðGC[k Aÿÿ ! º'¡IA$½#! ä@}¥K¦‰ 0r§ `÷hR¤i,CdHƒgHBb@B P@D@ô àÃþ/©,É TàGP¦HJ@[k º'¸œ½#ô),Á)H£õ+@`ô¡Õ%@ äÿÿ)!¤IAàÿŸô¥*A ôI!^§êG>¥^¥~¥ Þ#€úk »'`œ½#ðÿÞ#‡}§^·TçGñG[k º'^§Dœ½# àCÞ#€úkÿGÿGÿG »' œ½#ðÿÞ#‡}§^·ôåGáG[k º'^§œ½# àCÞ#€úkÿGÿGÿG »'à›½#àÿÞ#þ/^·>µ^µ>¶@Ó º'¦¼›½#þ/ àG@Ó º'¤›½# àGþ/éGµ@Ó º'êGŒ›½#ÿG°@Ó º'éGx›½#êGx†}§E[k º'°`›½#éG8‡}§âD[k º'êGH›½#8‡}§ÝD[k º'^§>¥^¥ 4›½# Þ#€úkÿG »'›½#àÿÞ# ‡}§^·>µ>¶œD[k º' àGðš½#ô^§>¥ÿG Þ#€úkX‡}§¦ôB[k º'^§ A>¥Àš½# Þ#€úkÿG »' š½#àÿÞ#þ/^·>µ^µ~µÅ@Ó@, º'|š½#Â@H àGàG@ä,ÄH¤µ‡@ €ôÁ,! ÆÁHÀ䦵Ç@Àô-! ÈIòÿõ!.8‡}§Ñ!JéG ö”D[k º'ÿGš½#,àÃ@}¥ÿÿA!K¦Š ¿ 0r§ `÷hR¤j,CdHƒgHBb@B ED @ô àÃÊ,ê ?"PÇHJ@[k º'¨™½#äÿÿJ!çÿÿÃþ/J,* þ/éGBAHJ<ƒ@Ó º't™½# àG8‡}§éGgD[k º'ëG\™½#^§>¥^¥~¥ Þ#€úkÿGÿG »'0™½#àÿÞ#^·>µ^µ~µ ðG0,Á0H äi,ÃiH£µg@ `ô©,)!Å©H ä¥µ§@ ôé,)!ÇéHòÿÿô).@]¥Ñ)J±ñCJ æJ¦©"ß"0r§ `÷hr¦‰.T•J”‡JS“Bs¢vF `ö àÃé. #?"PøJJ@[k º'h˜½#ä),)!Á)Håÿ?ôi, éG@}¥ÃiH`äK¦é 0r§ `÷h²¤É,FÇH†ÇHEÅ@¥ P D  ôàÃþ/ - "TàGPIJ@[k º'è—½#ä),)!Á)Håÿ?ô©,`‡}§êGË©HE©H©< Q[k),biI º'A)H"D°—½#)<àÃÿG^§>¥^¥~¥ Þ#€úkÿG »'p—½#àÿÞ#^·>µ^µ ðG0,Á0H äi,ÃiH£µg@ `ô©,)!Å©H ä¥µ§@ ôé,)!ÇéHòÿÿô).^§^¥ÿGÑ)J ö>¥ Þ#€úk@]¥J¦©"ß"0r§`÷hr¦‰.T•J”‡JS“Bs¢vF`ö>µJ¦© ß 0r§`÷hr¤‰,D…H„‡HCƒ@c fD`ôàÃé. #?"PøJJ@[k º'`–½#èÿä),Á)Håÿ?ä)!ÖÿÿÃé, !?"PèHJ@[k º'(–½#ôi,ÁiH äCiH)!ÿÿi<ÔÿÿÃ`‡}§¦±P[k º'^§>¥^¥ô•½# Þ#€úkÿGÿG »'Е½#ÐýÞ# ‡}§^·>µ^µ~µ žµ ðG ñG òG(ž!FC[k º'˜•½#\ä¡ A= ôýÿ` ¤`@.€ä¥#A, äÉ, .i"Œ"ÆÉH #qÌH,#P J‰ F¬ >)!ýÿI.þ/ ŸE¬.ÒSJvTJU´J¨#A¶FŒ!ýÿ¬>° Aþÿé.þ/ ŸEþÿL/×øJ{ùJZYK[GþÿL?ÿÿ),ÿÿì,Á$Hf%HGåHæDÿÿì<Õÿõ ö).Œ.Ñ)J)!u,J¶ ATŒJŒ!•FÿÿŒ>õÿßæ ŸE /P‡}§("ëGX K ?•T[k º't”½#("X‡}§\A[k º'(ž!`”½# €AX‡}§êGUA[k º'D”½#  A ‡}§éGêGêB[k º'(”½#¤ÿô),Á)H äi,Ì,ÃiH)!glHFÌHŒ!ÇDÿÿÌ< -È I)! åL.s IRLJSFŒ!ÿÿL>‰.Ô‰JêÿŸöì.ÿGWìJ("ì>@Ó º'^§>¥^¥~¥ ž¥ “½#0Þ#€úkÿGÿGÿG »'p“½#ðÿÞ#þ/^·TäG@Ó º'^§T“½#Þ#€úk »'@“½#ðÿÞ#^·0,Á0H ä,ÀH µ@ ô0,"Á0H 䡵'@ ôP,"ÁPHòÿ?ô,ð?FÀH/ä0,Á0H¡"@ ô,"ÀHä @ôp,"ÀpHòÿô0, ð?FÁ0H äp,äGÂdH@ä$,Á$H¡1@ ôd,„ ÃdH`ä£q@`ô$,„ À$HòÿôD,ÿGBDHD<³@Ó º'^§4’½#Þ#€úk^§ÿGÞ#€úk »'’½#ðÿÞ#ÿÿ]&ÿG^·8R" @Ó º'^§ð‘½#Þ#€úkÿGÿGÿG »'Б½#ÀÿÞ#þ/^·>µ^µ~µ žµ(¾µ0Þµ ðG ñG òGðGáGÙ@Ó º'),Œ‘½#I ‡}§Q"H àG‘'JêG9E[k º' 4àGd‘½# äþ/),I ‡}§êGQ"H)!‘'J,E[k º'0‘½#õÿô-µI,ÂIHb@äþ/‰,© ‡}§ëGQ…HÉ!‘'JE[k º'i ð½#"äI,‡}§ëGQCH‘'JE[k º'Ƚ#ô.,N ‡}§Á.HëG ä¡•+@Î"Dn,Ž Î!QdH‘'JE[k º'„½#ïÿä.,.!Á.HC ä..Ñ)JÓÿ?ö3àÃi,‰ ‡}§êGQdH‘'JïD[k º'<½#%äÉ-ÁÉI äþ/I,i ‡}§êGQCH‘'JáD[k º'½#ä),A)H)<)! ?EI,ÂIHîÿ_ô‰,ÿÿ© ĉHFA€äÿÿ - 0€AéGHIÿÿ =&µ).Ñ)J¤ÿ?öàÃ).)!Ñ)JŸÿ?öLA^§íGì·>¥^¥~¥ ž¥(¾¥0Þ¥@Þ#€úkÿÿ]&þ/SAs¦TàGÿGÐmR"1@Ó º'LA<½# ¬AèÿÿÃÿGÿG »' ½#àÿÞ#^·>µ ðG>¶I ñG),‡}§>µQ"H)!‘'J˜D[k º'àŽ½#ä),Á)H äi,ÿÿÉ,ÿÿ© )"ÃiH)!geHFÅHÇDþÿÉ< ?E -È I åÿÿI.sI)!RQJSFþÿI> ?E‰.Ô‰JèÿŸöÿÿé.ÿÿÉ"WöJÿÿé>X‡}§¦×[k>¥ º'L޽# A‡}§ÿÿ",¦ÿÿ"!Q"H‘'JhD[k º' ޽#äI,BIHI<^§>¥ Þ#€úkÿGÿG1,òCÁ1H äE@îq,Ð,21@BÃqH1"gpHFÐHÇD"ÿÿÐ<-ÈI1" åvI5@î°.21@BU°J¶F"ÿÿ°>ñ.×ñJæÿÿö+@î¹}@B ÷P,äGapKBPH fdKADP<ð Fp,sgK!2‘@BCdHvhKfDp<´}@BF°,"E§H³Dþÿ°<Fÿÿ°.U¨J¶Fÿÿ°>áÿŸæ @îð.äGyKWðJ21@BùF"ÿÿð>÷ÿ_þ€úkÿG »'ÀŒ½#àÿÞ#^·>µ^µ~µ ðG0,@]¥Á0H ä*¦I q§`÷X¤ .BJ‚GH@@@ àÃþ/), "P0HJ@[k º'LŒ½#I,c HBIH)!CDÿÿI<þ/ ?E‰,ĉHâÿŸô^§>¥^¥~¥ Þ#€úk »'Œ½#ÐÿÞ#^·>µ^µ~µ žµ òG ñC ÿG ðG0,Á0H äþ/À†}§ëGêGˆV[k º'TáG°‹½#ô`åh‡}§éG´D[k º'‹½# ,, h‡}§PHJéG«D[k ,Œ! º'À Hl‹½# 0`Aäÿôh‡}§TáGéG D[k º'^§>¥^¥~¥ ž¥@‹½#0Þ#€úkÿGÿGÿG »'‹½#ÐÿÞ#^·>µðG^µðG~µ žµ(¾µ òG ñCø€}¥¢,$A@§ Š@Å¢Hàä" ä âGb.B ÓbJµdBôÿ¿öóÿæÂ.B ÖÂJ¸ÄBîÿ÷ôÿßöìÿÿàäl/éGëGÍlKáG[lKl?˜†}§œO[kL,c¬I º', BLH`н#CDL<áGØÿÿÃ"A@˜†}§¢ J@@äèÿ+"éGáGŠO[k º'н#àà ,˜†}§ðÿ+"Í HéG@ HáG <~O[k ,a¬I º'L"@ H艽#˜†}§D <øÿ+"éGrO[k º'¸‰½#^§>¥^¥~¥ ž¥(¾¥0Þ#€úk »'‰½#àÿÞ#^·>µ^µ ðG ñG0,Á0H äþ/i,‰ ‡}§êGQdH‘'J1C[k º'D‰½#ô),)!Á)Hòÿ?ôi,ÿÿ&ÃiHÿG `ôn"éG@@Ó º'^§>¥^¥‰½#ÿG Þ#€úk),)!Á)H äi,‰ ‡}§êGQdH‘'JC[k º'¼ˆ½#ä),)!Á)Hòÿ?ôi,>µÃiH`ä©,É ‡}§êGQ¦H‘'JýB[k º'tˆ½#ô),)!Á)Hòÿ?ô©,ÿGÊ©HE©H©<¦5@ÓI,cII º'BIH<ˆ½#CDI<^§>¥^¥ Þ#€úkÿGÿGÿG »'ˆ½#áGp‡}§Ðÿž €ûÞ#X>¶ðG>°P¶"`^¶h~¶P^"ž´ ž(>ž0^ž8~ž@žžH¾žpž¶x¾¶^·~¦æ\[k º'"˜‡½#þ/@Ó º'^§„‡½#€Þ#€úk »'p‡½#àÿÞ#^·>µ^µ ðG öÿGð€¦Ï@Ó º'^§>¥^¥D‡½#ÿG Þ#€úkþ/X‡}§éG ~[k º'‡½#0@ÿG@Ó º' àG‡½# ôÿÿ&þ/¨m"¶@Ó º'^§>¥^¥à†½#ÿG Þ#€úk(‡}§êGéGœC[k º'^§êG>¥^¥°†½# Þ#€úk »'†½#ðÿÞ#Ȇ}§^·4àG¶ôB[k º'>¦p†½#ôÿÿ&þ/`n"’@Ó º'ÿGP†½#^§Þ#€úkÿGÿG »'0†½#ðCNþ/ðÿÞ#^·âÿ_Ó º'^§†½#Þ#€úkÿGÿGÿG »'ð…½#ðÿÞ#^·>¶ öÿÿ&þ/ˆn"p@Ó º'^§È…½#ÿGÞ#€úkø†}§>¦¹G[k º'¤…½#ôÿÿ&þ/>¦°n"_@Ó º'„…½#ÿG^§Þ#€úkÿGÿGÿG »'`…½#ðÿÞ#^·>µ ðG öÿG¦L@Ó º'^§éG>¥8…½#Þ#€úk8‡}§éGT[k º'^§>¥…½#ÿGÞ#€úk »'ð„½#Ðÿ^ p‡}§áG€ûÞ#X>¶ðG^´P¶ "`^¶h~¶P^"^·ž° ž(>ž0^ž8~ž@žžH¾žpž¶x¾¶>µ~¦!\[k º'„„½# >"=¥ÿÿ&ÿG  o"¡@ ô@Ó   º'^§X„½#0@ °>¥ÿG€Þ#€úkÿGþ/ "Š= B@A@0@>´â· °'ÿ_Ó>¥ º'^§þ ´„½#>¥4àG€Þ#€úk »'àƒ½#ðÿÞ#^·>µ=¥ÿG) ¢(@@ôÿÿ&Ho"é@Ó   º'^§0@¬ƒ½# °ÿG>¥Þ#€úkþ/ÿG^§0 @4àGŠ} I°D#@A#@¶>¥þá·Þ#€úkÿGÿGÿG »'@ƒ½#ðÿÞ#ÿÿ=$^·œA ˆ#£H@¤@@bA@dD`à‚Cþ/¦æiÿ_Ó º'ü‚½#¤   ì!1 @ °^§Þ#€úkÿG »'Ђ½#ÐÿÞ#^·>µ^µ~µ žµ ðG ÿG]¥ÿG* ˆ! ìl§ `ç@[k º'àGˆ‚½#4èGþ/éGÙý_Ó º'l‚½#àà ¦ÿG4èGéGÑý_Ó º'L‚½#   0`AŒ!  `Açÿô^§>¥^¥~¥ ž¥0Þ#€úkÿG »'‚½#ÿÿ=$`¶€úkÿGÿGÿG »'ð½#ðÿÞ#ÿÿ=&ÿG^·p1"¶ñ@Ó º'àG̽# ôÿÿ&ÿG>¦ˆo"h@Ó º'^§¨½#ÿGÞ#€úkÿGàÿ_Ó º'^§ˆ½#4àGÞ#€úk »'p½#ðÿÞ#þ/^·ðC4àGR@Ó º'^§P½#Þ#€úkÿGÿGÿG »'0½#ðÿÞ#þ/^·ðC4àG @Ó º'^§½#Þ#€úkÿGÿGÿG »'ð€½#ðC 5`BðÿÞ#ñC^·(ô°U`Bö aBô°bBæÿÿ$” ¢F²Þ#€úkÿÿ]&þ/TàGÿG°oR"ƒ@Ó º'^§„€½#Þ#€úkÿÿ$^§  1D °Þ#€úkÿÿ]$^§ŒB b qDb°Þ#€úkÿÿ$^§ˆ„ ¤ ±D¤°Þ#€úk »'€½#ðC 5`BðÿÞ#ñC^·(ô°U`Bö aBô°bBæÿÿ$” ¢F²Þ#€úkÿÿ]&þ/TàGÿGðoR"K@Óÿº'^§¤½#Þ#€úkÿÿ$^§  1D °Þ#€úkÿÿ]$^§ŒB b qDb°Þ#€úkÿÿ$^§ˆ„ ¤ ±D¤°Þ#€úkÿ»'0½#ðÿÞ#þ/¶áG^·4àG‰ÿ_Óÿº'TàG ½#þ/4àGƒÿ_Óÿº'ô~½#4àGþ/4àG}ÿ_Óÿº'áGÜ~½#þ/TàG¯ÿ_Óÿº'Ä~½#TàGþ/TàG©ÿ_Óÿº'4àG¬~½#þ/TàG£ÿ_Óÿº'”~½#áGþ/áGeÿ_Óÿº'TàG|~½#þ/áG_ÿ_Óÿº'd~½#4àGþ/áGYÿ_Óÿº'¦L~½#ÿG8@Óÿº'^§8~½#4àGÞ#€úkÿ»' ~½#ðÿÞ#þ/^·áGTàGFÿ_Óÿº'TàG~½#TàGÿG@ÿ_Óÿº'4àGè}½#TàGÿG:ÿ_Óÿº'áGÐ}½#áGÿGlÿ_Óÿº'TàG¸}½#áGÿGfÿ_Óÿº'4àG }½#áGÿG`ÿ_Óÿº'ˆ}½#ÿG@Óÿº'^§x}½#4àGÞ#€úkÿ»'`}½#ÿÿ=$h¶€úkÿGÿGÿGÿ»'@}½#ÿÿ=$há·€úkÿGÿGÿGÿ»' }½#ðC 5B ô¡UB ô°Bæÿÿ$Pp €úkÿÿ=$`p €úkÿÿ&@p €úkÿÿ=$0p €úkÿGÿGÿGÿ»'À|½#Ðÿ^ p‡}§áG€ûÞ#X>¶ðG^´P¶"`^¶h~¶P^"ž° ž(>ž0^ž8~ž@žžH¾žpž¶x¾¶^·~¦Z[kÿº'>"X|½#áGÿÿ$þ/˜  øÿ¢0 @ °ü@Óÿº'^§(|½#€Þ#€úkÿGÿ»'|½#€ûÞ#p‡}§X>¶ðGP¶P^ áG^´`^¶P^"h~¶²" ž(>ž0^ž8~ž@žžH¾žpž¶x¾¶^·~¦êY[kÿº'>"¨{½#TàGÿÿ$þ/˜  ôÿ¢0 @ °Ð@Óÿº'^§x{½#€Þ#€úkÿGÿ»'`{½#Ðÿ^ p‡}§áG€ûÞ#X>¶ðG^´P¶"`^¶h~¶P^"ž° ž(>ž0^ž8~ž@žžH¾žpž¶x¾¶^·~¦¾Y[kÿº'>"øz½#4àGÿÿ$þ/˜  ðÿ¢0 @ °¤@Óÿº'TáGÈz½#P¤h‡}§p "{@[kÿº'TàG¬z½#p}§Âg[kÿº'^§˜z½#€Þ#€úkÿGÿ»'€z½#Ðÿ p‡}§ãGpûÞ#^·>µh>¶òG^µ ðC´`¶("p^¶x~¶`^" ^°0ž8>ž@^žH~žPžžX¾ž€ž¶ˆ¾¶ ~¦ƒY[kÿº'¡5 A z½#ÿÿ]%þ/(>"4àG˜J!  ðÿ ¢0@ ° äg@Óÿº'Ôy½#TáGP¤h‡}§p ">@[kÿº'TàG¸y½#p}§…g[kÿº'¤y½#øÿ  üÿ* ¢!Aôÿj ¤U A€ADðÿ ¢þ/¥5 Aƒ€D(>"éG£DK@Óÿº'^§>¥^¥dy½#Þ#€úkÿGÿGÿ»'@y½#€ûÞ#ÿÿ=$ žP~ ”! p‡}§(>žáG0^ž8~ž@žžH¾žP¶X>¶`^¶ðGh~¶P^"pž¶"x¾¶^· à~´¾°~¦3Y[kÿº'"Ìx½#P¤‡}§p ">¶³I[kÿº'¦¬x½#ÿGÄ@Óÿº'˜x½#^§€Þ#€úkÿGÿ»'€x½#ðÿÞ#ÿÿ=$^·”! ÿG à½@Óÿº'\x½#^§Þ#€úkÿGÿGÿ»'@x½#ÐÿÞ#^·>µ^µ~µ žµsâ òC bA ñG ðCäþ/ñG¹@Óÿº'üw½#hàÃP@E2äþ/ëG±þ_Óÿº'àGÜw½#P=¤‡}§p!ìGwI[kÿº'TáG¼w½#h‡}§ìG¹[kÿº'¤w½#ìGÿÿ$þ/œ   ì/ý_Óÿº'„w½#ìGÿÿ$‡}§x"bI[kÿº' 5`Ahw½#ä‡}§éGìGZI[kÿº'Hw½#àÃÿGéGÔèGìGû_Óÿº'(w½#@E¥( äÿGÄÿ ¤ëG$äzþ_ÓÄÿ,¦ÿº'w½#àG‡}§BI[kÿº'TáGèv½#P¤h‡}§p "ƒ[kÄÿ ¦  ÿº'Ìv½#þ/ìúü_Óÿº'°v½#Äÿ,¦‡}§äÿ ".I[kÄÿL¦ÿº'˜v½#éGþ/ÔèGÝú_Óÿº'|v½#Ìÿl§ AE@åéGëG`ç@[kÿº'Xv½#^§>¥^¥~¥ ž¥0Þ#€úkÿ»'0v½#ðÿÞ#ÿÿ=$¶ ! ^·¦ÿGæ+ü_Óÿº'v½#¦ÿG¢û_Óÿº'^§ðu½#ÿÿ=$ ! ´Þ#€úkÿ»'Ðu½#ðÿÞ#ÿÿ=&P=¤˜†}§¶ðG^·p"€p1"lJ[kÿº'¦ u½#À‡}§kC[kÿº'^§Œu½#4àGÞ#€úkÿGÿ»'pu½#àþÞ#^·>µ”àG^µÿGÿÿ=%ÿÿ]&þ/ì)!) pR"¡5 @ ä­þ_Óÿº',u½#ÿÿ$è†}§p "ô~[kÿº' àGu½#äX‡}§àGy[k@Aÿÿ ,ÿÿ ÿº'êGÀ Hôt½# õ@äÿGXû_Óÿº'Èt½# àø‡}§Ìÿ)""êGnF[kÿº'"¨t½#þ/Kû_Óÿº'”t½#´ÿ ´ÿÿ]%è†}§pJ!0 "Í~[kÿº'tt½#äþ/àG=û_Óÿº'¼ÿ ´\t½#Ôÿ "è†}§Á~[kÿº'Dt½#äþ/àG1û_Óÿº'Äÿ ´,t½# 4àG^§I±>¥^¥ Þ#€úkÿGÿ»'t½#ðÿÞ#І}§^·öT[kÿº'^§ès½# @Þ#€úkÿ»'Ðs½#ðÿÞ#؆}§^·vX[kÿº'^§¸s½# @Þ#€úkÿ»' s½#ÐÿÞ#X‡}§ñC^·>µ^µ~µ ðG òG óG >²òGy[kÿº'ds½#(°X‡}§ëGy[k(>  ^ ÿº' @Ls½#0@ÿÿ&  @@ äþ/Ðp"ëGêGÃý_Óÿº's½#ÿGàÃþ/(‡}§éGëG¬~[kÿº'éGðr½#X‡}§ûx[kÿº'éGÜr½#P‡}§êG)L[kÿº'Är½#4àG^§>¥^¥~¥0Þ#€úkÿ»' r½#ðÿÞ#^· öÿÿ&þ/q"ý_Óÿº'^§|r½#ÿGÞ#€úkþ/ÿÿ=&þ/È1"@Óÿº'àGPr½#ô^§ÿGÞ#€úkÀ‡}§’B[kÿº'^§(r½#4àGÞ#€úkÿ»'r½#ÀûÞ#ð†}§^·”áG>µ^µ ~µ ðG("Ø{[k( ÿº' ÿGàq½#ðDñD¡U*@ äP@ 4àG(°þ/ßG(~ ðDñD¤õŠ@€äðn@ 4àG(~° õŸ@åÿÿ&þ/(q"/ý_Óÿº'tq½#˜àÃÿÿ}%x†}§éGÐk!ëG„z[kÿº'(> Pq½# ôð?DP]¤¡U.@ ä ‰àÃP}¤8 †àÃà†}§éG(>"#[kÿº'ªêC q½#~ôÿÿ&@åÿGXq"éG8p"(^" ý_Óÿº'Üp½#  ÿGô×þ_Óÿº'Äp½#  àÿk¦©  5@#ô"`æI,þ/I"ÂIH8"¢ÕO@@ä‰,?"Ä…H¤õ…@€ä6ÿ_Óÿº'8"pp½#äà†}§(>"õ~[kÿº'Tp½#Qô @åÿÿ&þ/éG0r"(^"xÿ"8~"Ûü_Óÿº'$p½#("‡}§ôîGã|[kÿº'Øÿk¦ p½#=ôÿG`æ8"?"éGÿ_Óÿº'äo½#äà†}§8"(>"Ò~[kÿº'Èo½#.ôÿÿ]& @åÿG€rR"ÿG@ÿ"éG¶áG(ž"8¾"Eý_Óÿº'Œo½#Ðÿk¦þ/8" `æ?"éGôþ_Óÿº'8"ho½#äà†}§(>"³~[kÿº'Lo½#ô @åÿÿ]&þ/ÿGØrR"éGÿ"(ž"¶áG8¾"&ý_Óÿº'o½#ÿG^§>¥^¥ ~¥@Þ#€úkÿGÿGÿGÿ»'àn½#àýÞ#^·>µ^µ ðG åñG öÿG ¦©ü_Óÿº'^§>¥^¥¬n½#ÿG Þ#€úkè†}§Q}[kÿº'„n½# àGô^§>¥^¥ÿG Þ#€úkX‡}§éGØw[kÿº'°Pn½#êGX‡}§Òw[k> ÿº'8n½#éG @ÿÿ&þ þ/ øðq"êG€ü_Óÿº'^§>¥^¥n½#ÿG Þ#€úk¸‡}§(=¦ "éGêG¸D[kÿº' "Ðm½#ÿÿ=%à†}§à)"M~[kÿº'^§>¥^¥´m½# Þ#€úkÿ»'m½#4àGÿÿ=$ð! ¶a°€úkÿ»'pm½#ðÿÞ#^·>µÿÿ=%˜†}§ð)! ¦)"UH[kÿº'^§Dm½#é·é³é³>¥Þ#€úkÿ»' m½#pýÞ#^·>µáG^µ`¾ 0ž ÿG8>ž@^žH~žPžžX¾ž`¶h>¶p^¶x~¶€ž¶ˆ¾¶€=!) ‰ ' ä ^°¾´ €ìh‡}§èÿ)¦áG 0@A÷|[k  ÿº'œl½#  @Aöÿôp‡}§^¦ ~¦`>¦("V[kÿº'("pl½#X‡}§[w[kÿº'èÿ ¦\l½#˜†}§øÿ)" °(^"H[kÿº'èÿ ¦¥^¥Þ#€úkÿ»'l½#ðÿÞ#`¤‡}§h¦ ^·àCvd[kÿº'^§Øk½#Þ#€úkÿGÿ»'Àk½#ðÿÞ#†}§h¦^· c[kÿº'^§¤k½#Þ#€úkÿ»'k½#àÿÞ#à'H†=¤x¤`|¤8†½¤A¤p†Ý¤^·"¢C@>µ^µ¥ ~µ@ô1°@F"¸†}§6^[kÿº'8k½#àäx]¤@†}¥4@!!äB!‰¤©¤)¦¸†}§)!Š@«@$^[k ¤ÿº'ðj½#4@óÿô^§>¥^¥~¥ Þ#€úkÿGÿ»'Àj½#àÿÞ#à'H†=¤x¤`|¤€‡}§A¤"^·¢C@>µ^µ @ô n[kÿº'^§>¥^¥€j½# Þ#€úkþ/¤x]¤!!4@ äB!‰¤€‡}§)!Š@n[k ¤ÿº'4j½#4@öÿô^§>¥^¥ Þ#€úkðÿÞ#~·^·~§{'pþ{#@[k~§{'þ{#@[k^§Þ#€úkðÿÞ#~·^·~§{'þ{#@[k~§{'ÿ{#@[k^§Þ#€úk « Query [%20s] Target [%20s] %d Cannot get a genomic sequence from NULL objects. Ugh!Cannot get entry for %s from Genomic dbUnable to map %s sequence to a genomic sequence. FailingUnable to map %s sequence to a genomic sequence. FailingAttempting to make GenomicDB from some NULL objects.Trying to hard link to a GenomicDB object: passed a NULL objectGenomicDB_alloc failed Sequence from %s data entry doesn't look like DNA. Forcing it toSequence from %s data entry doesn't look like DNA. Forcing it toCannot make initial ComplexSequence. Unable to error catch this. Failing!A bad internal genomic db error - unable to find current sequence in db reloadA bad internal genomic db error - unable to reverse complements currentA bad internal genomic db error - unable to make complex sequence in db reloadSequence from %s data entry doesn't look like DNA. Forcing it toUnable to map %s sequence to a genomic sequence, but ignoring that for the moment...Unable to map %s sequence to a genomic sequence, but ignoring that for the moment...You can't make a genomic database with a non SEQUENCE_GENOMIC cses type [%d]Attempting to free a NULL pointer to a GenomicDB obj. Should be trappableIn replacement function is_single_seq for object GenomicDB, got a NULL objectIn accessor function is_single_seq for object GenomicDB, got a NULL objectIn replacement function done_forward for object GenomicDB, got a NULL objectIn accessor function done_forward for object GenomicDB, got a NULL objectIn replacement function forw for object GenomicDB, got a NULL objectIn accessor function forw for object GenomicDB, got a NULL objectIn replacement function rev for object GenomicDB, got a NULL objectIn accessor function rev for object GenomicDB, got a NULL objectIn replacement function sdb for object GenomicDB, got a NULL objectIn accessor function sdb for object GenomicDB, got a NULL objectIn replacement function current for object GenomicDB, got a NULL objectIn accessor function current for object GenomicDB, got a NULL objectIn replacement function cses for object GenomicDB, got a NULL objectIn accessor function cses for object GenomicDB, got a NULL objectUnable to read sequence from %s, so no genomicCannot make a genomic sequence from a NULL sequencegenomic.dy%d repeats Repeat from %d - %d Biologically: %d - %d Repeat from %d - %d Biologically: %d - %d GenomicRepeat_alloc failed expand_Genomic called with no needckrealloc failed for expand_Genomic, returning FALSEWarning, ckcalloc failed in Genomic_alloc_lenTrying to hard link to a Genomic object: passed a NULL objectGenomic_alloc failed In length function repeat for object Genomic, got a NULL objectCould not make a new Genomic Sequence from Sequence in NheuristicTrying to make a genomic sequence from a non genomic base sequence [%s] Type is %d.In making %s a genomic sequence, converted %d bases (%2.1f%%) to N's from non ATGCNTrying to hard link to a GenomicRepeat object: passed a NULL objectAttempting to free a NULL pointer to a GenomicRepeat obj. Should be trappableAttempting to free a NULL pointer to a Genomic obj. Should be trappableIn replacement function baseseq for object Genomic, got a NULL objectIn accessor function baseseq for object Genomic, got a NULL objectIn accessor function repeat for object Genomic, got a NULL objectIn accessor function repeat for object Genomic, index %%d is greater than list length %%dIn replacement function start for object GenomicRepeat, got a NULL objectIn accessor function start for object GenomicRepeat, got a NULL objectIn replacement function end for object GenomicRepeat, got a NULL objectIn accessor function end for object GenomicRepeat, got a NULL objectIn replacement function type for object GenomicRepeat, got a NULL objectIn accessor function type for object GenomicRepeat, got a NULL objectsequence %s SequenceNameUnknown typeUndefined!Attempting to force a sequence with no Sequence object! Trying to make a sequence with a length of %d. Bad news!NoNameDNASeqCannot reverse complement non-DNA sequence... type is %sCannot magic truncate on a non DNA sequence... type is %sUnable to truncate sequenceTrying to truncate Sequence from %d - %dTrying to truncate Sequecne %s from %d - %d when length is %dgetz -d '[%s]' Could not open %s as an SRS database string - probably no getzefetch -f -a %sefetch -f %sCould not open efetch pipe with [%s]Cannot open %s for read_fasta_fileCould not read full sequence of %s - returning In parsing an EMBL file got an poor ending of a sequence regionCould not read full sequence of %s - returning Sequence block error for sequence %s on blocklen %d NullStringDummyNameCannot make a sequence with no sequence!DummyNamesequence.dyNoName_Null_stringTrying to hard link to a Sequence object: passed a NULL objectSequence_alloc failed expand_SequenceSet called with no needckrealloc failed for expand_SequenceSet, returning FALSEWarning, ckcalloc failed in SequenceSet_alloc_lenSequenceSet_alloc failed In accessor function seq for object Sequence, got a NULL objectIn accessor function len for object Sequence, got a NULL objectIn accessor function end for object Sequence, got a NULL objectTrying to make a translation from a non DNA sequence... type is [%s]Attempting a magic truncation on indices which are less than zero [%d:%d]. Clearly impossibleAttempting a truncation on indices which are less than zero [%d:%d]. Clearly impossibleI don't like this - got a buffer of [%s] in reading an EMBL sequence sectionFirst letter read is not '>' - assumming it is not a fasta streamAttempting to make an empty sequence with no name: assigning dummy nameYou are attempting to make a sequence with no name - assigning dummy nameAttempting to free a NULL pointer to a Sequence obj. Should be trappableTrying to hard link to a SequenceSet object: passed a NULL objectAttempting to free a NULL pointer to a SequenceSet obj. Should be trappableIn replacement function name for object Sequence, got a NULL objectIn accessor function name for object Sequence, got a NULL objectIn replacement function seq for object Sequence, got a NULL objectIn replacement function len for object Sequence, got a NULL objectIn replacement function maxlen for object Sequence, got a NULL objectIn accessor function maxlen for object Sequence, got a NULL objectIn replacement function offset for object Sequence, got a NULL objectIn accessor function offset for object Sequence, got a NULL objectIn replacement function end for object Sequence, got a NULL objectIn replacement function type for object Sequence, got a NULL objectIn accessor function type for object Sequence, got a NULL objectIn accessor function set for object SequenceSet, got a NULL objectIn accessor function set for object SequenceSet, index %%d is greater than list length %%dIn length function set for object SequenceSet, got a NULL objectCould not open file %s as codon table fileUnable to read a line in codon tableCodonTable_alloc failed Attempting to find a codon number is something less than 3 bases long!Attempting to convert an ambiguous codon to base 64... returning 64This is not good news: got a position asked which is not 1,2,3 [%d](BTW - first base is 1)Trying to hard link to a CodonTable object: passed a NULL objectAttempting to free a NULL pointer to a CodonTable obj. Should be trappableIn replacement function name for object CodonTable, got a NULL objectIn accessor function name for object CodonTable, got a NULL objectCannot get sequence database entry with a null dataentry!Cannot get sequence database entry with a null sequence db!Cannot get sequence database entry with no attached filenameUnknown SequenceDB type [%d]On file source [%d] [%s] could not closeOn file source [%d] [%s] could not closeOn file source [%d] [%s] could not open the fileToo many failed reloads of databases, going to failUnknown SequenceDB type [%d]Could not open file [%s] for database [%s]Can't handle closes on streams yet. Not sure what to do!Cannot make SequenceDB from an unopenable fileanme [%s]Attempting to read a sequence line without a seqdb startUnNamedDatabaseYou have not provided a database source lineFor filename %s, the format [%s] is unknown to meFileSource_alloc failed expand_SequenceDB called with no needckrealloc failed for expand_SequenceDB, returning FALSEWarning, ckcalloc failed in SequenceDB_alloc_lenSequenceDB_alloc failed In length function fs for object SequenceDB, got a NULL objectBad error - could not open database file %s for reading indexed sequenceNull objects being passed into add_SequenceDB_info_DataEntry. Can't be good!Your sequence database has only sequence in it. It is quite likely there was a more efficient way to run thisOk, don't like this, just loaded the next Filesource, and got no sequence. Nope!Bad bug: asking when it has finished when you have not init'd seqdb %sBad bug: trying to close last source when you have not init'd seqdb %sBad bug. Someone is trying to load the next fs file when there are none (has not tested with SequenceDB_at_end...). So. I will fail, but database is actually at the endBad bug: trying to close last source when you have not init'd seqdb %sTrying to hard link to a FileSource object: passed a NULL objectAttempting to free a NULL pointer to a FileSource obj. Should be trappableTrying to hard link to a SequenceDB object: passed a NULL objectAttempting to free a NULL pointer to a SequenceDB obj. Should be trappableIn replacement function name for object SequenceDB, got a NULL objectIn accessor function name for object SequenceDB, got a NULL objectIn accessor function fs for object SequenceDB, got a NULL objectIn accessor function fs for object SequenceDB, index %%d is greater than list length %%dIn replacement function current_source for object SequenceDB, got a NULL objectIn accessor function current_source for object SequenceDB, got a NULL objectIn replacement function current_file for object SequenceDB, got a NULL objectIn accessor function current_file for object SequenceDB, got a NULL objectIn replacement function sequence_no for object SequenceDB, got a NULL objectIn accessor function sequence_no for object SequenceDB, got a NULL objectIn replacement function byte_position for object SequenceDB, got a NULL objectIn accessor function byte_position for object SequenceDB, got a NULL objectIn replacement function filename for object FileSource, got a NULL objectIn accessor function filename for object FileSource, got a NULL objectIn replacement function input for object FileSource, got a NULL objectIn accessor function input for object FileSource, got a NULL objectIn replacement function format for object FileSource, got a NULL objectIn accessor function format for object FileSource, got a NULL objectIn replacement function type for object FileSource, got a NULL objectIn accessor function type for object FileSource, got a NULL objectComplexSequence %s %4d %c [ComplexSequenceEval_alloc failed expand_ComplexSequenceEvalSet called with no needWarning, ckcalloc failed in ComplexSequenceEvalSet_alloc_lenComplexSequenceEvalSet_alloc failed ComplexSequence_alloc failed Trying to make a complex sequence from a NULL sequence - impossible!Could not evaluate these sequences Sequence type [%d][%s] Evaluation type [%d][%s]Trappable error: you have not prepared this ComplexSequenceEvalSet before using. Please do so in the futureCould not allocate data pointer of length %d for ComplexSequenceTrying to hard link to a ComplexSequenceEval object: passed a NULL objectAttempting to free a NULL pointer to a ComplexSequenceEval obj. Should be trappableckrealloc failed for expand_ComplexSequenceEvalSet, returning FALSETrying to hard link to a ComplexSequenceEvalSet object: passed a NULL objectAttempting to free a NULL pointer to a ComplexSequenceEvalSet obj. Should be trappableTrying to hard link to a ComplexSequence object: passed a NULL objectAttempting to free a NULL pointer to a ComplexSequence obj. Should be trappableIn replacement function type for object ComplexSequence, got a NULL objectIn accessor function type for object ComplexSequence, got a NULL objectIn replacement function seq for object ComplexSequence, got a NULL objectIn accessor function seq for object ComplexSequence, got a NULL objectIn replacement function type for object ComplexSequenceEvalSet, got a NULL objectIn accessor function type for object ComplexSequenceEvalSet, got a NULL objectIn replacement function has_been_prepared for object ComplexSequenceEvalSet, got a NULL objectIn accessor function has_been_prepared for object ComplexSequenceEvalSet, got a NULL objectIn replacement function left_window for object ComplexSequenceEvalSet, got a NULL objectIn accessor function left_window for object ComplexSequenceEvalSet, got a NULL objectIn replacement function right_window for object ComplexSequenceEvalSet, got a NULL objectIn accessor function right_window for object ComplexSequenceEvalSet, got a NULL objectIn replacement function left_lookback for object ComplexSequenceEvalSet, got a NULL objectIn accessor function left_lookback for object ComplexSequenceEvalSet, got a NULL objectComplexSequenceEvalSet is not valid for genomic!complexevalset.dygen->baseseqcomplexevalset.dygen->baseseq->seqcomplexevalset.dyOverran sequence - j position %d, sequence length %d on repeat %dPassed stringalloc a NULL pointerstringalloc unable to allocate memoryIn breakstring_protect, reached endofline in protected string [%s]Can only find one word in [%s] - certainly can't alloc the secondOut of memory, on asking for %d bytes Bad call to ckrealloc, NULL pointer Out of memory, trying to realloc %d bytes Bad call to ckfree - NULL pointer Too many messages held on stack, [%s] discarded Too many messages held on stack, Error message call discarded Could not open %s as a log filenameIn error system, tried to change flag %d which doesn't exist!In error system, tried to change flag %d which doesn't exist!Fatal ErrorWarning ErrorInformationStrange error type???Closing %d Trying to reload configdirsWISECONFIGDIRWISEPERSONALDIRUnable to expand %s with %s due to lack of buffer spaceTried to touch a NULL filenameOpen for file failed due to NULL filenameDirect open for [%s,%s] failed: Error message is %sNo error availableNo error availableNo error availableNo error availableReally long filename/enviroment variables [%s] [%s] Can't cope!Expanded tilda open for[%s,%s], expanded to %s failed: Error message is %sExpanded personal direcotry open for[%s,%s], expanded to %s failed: Error message is %sExpanded system directory open for[%s,%s], expanded to %s failed: Error message is %sPassed a NULL filename or enviroment name into Envfile. Should trap this elsewhere> > >  >   þ  ~ ~ þ    ~ þ  þJ ~ > "D D ~ ~ ~ þ  F   D þ  þ  þ  ~  > F ~ > ’  $ ˆ DRð­Ûº­ €íàÊÿÿÿÿÿÿÿÿ"%d,%d"%4.4g,%4.4g, , "%f,%f"genmyseqATTGGGCProteinDnacDNAGenomicEstRNA%s.tr%s:%srWP:rrSQEMBLseq%d %c seq>%s r rrseqdb #endfasta ] gen_%d"%s %s %s %s w %s/HOMEr-%s/%sr %s@¨H@0g @g È@Pg Xg È@ÀH@`g @ÐH@À@XI@pg g ˜g X@xI@°g (h À-@ÈI@7@ðI@¨7@J@`8@8J@À9@0;@|J@àR@>@¸J@èJ@@h xîÀÿÀêÀÿ ÀÿP( ÀÿbPh Pï €ÿ`s °w ðz @„ † °‰ ‹  Ž 0  Б €˜ š Л @ `  Р €¡ °¡ P£  ¤ @¥ p¥  ¦ €¦ § ­ à­  ¯ ° б `² P³ µ À· 0¹ °º À¼ о €Â 0Ç €È àÉ @Ê  Ë ÐË 0Ì ÀÌ Í ÀÍ `Ï €Ñ Ò PÚ  Ü pÜ PÞ á ðá àâ €ä àä °å æ Ðæ  è @ê Ðê Pë °ë àí €î àî ð @ñ ô @ô àõ Pö ÷ 0÷ Ðø  ù Àú ðú  û ü ü   à      @        P  ð  À  À   °    €   p    p € à   €   `    ð  À!  "  $ ð*  7 9  > à> Ð? pC PD °D ðD €E H ÐH ðI ÐJ €M  M ÀM  N ÐN `P  R pU @W @X ÐX P] p] À] à` `a @@H@ÀR@ÈR@ÐR@ØR@àÊ@ C €ÿPÇ€ÿ0 €ÿpë €ÿð~ €ÿЋ€ÿ€(€ÿ@¢€ÿ€Ø €ÿP™€ÿ@P €ÿЪ€ÿ¹€ÿ`V €ÿ Q €ÿ`H €ÿ d €ÿàð €ÿy €ÿðH€ÿ`N €ÿ`B €ÿ R €ÿ€… €ÿ C €ÿ Y€ÿàÈ€ÿÀˆ €ÿð; €ÿ°w €ÿ R€ÿà¶€ÿE €ÿà€ÿpG €ÿð*€ÿP‘€ÿð6€ÿ@l €ÿ ‹ €ÿðo €ÿc €ÿ « ’ XaBáøø'*è³àÐ8ðlt€l™hÁ(ÑÈÜv  ÿÿÿÿøÿÿÿÿÿÿÿP»àv ÿÿÿÿÿÿÿÿ½Ñðv ÿÿÿÿÿÿÿÿÓØw ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ,/ w ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ8;@w ÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ DG°w ÿÿÿÿÿÿÿÿêÿÿÿÿ>Àÿÿÿÿÿÿÿ@P[x ÿÿÿÿÿÿÿÿÿÿÿÿ>Àÿÿÿÿÿÿÿ@enPy ÿÿÿÿÿÿÿÿÿÿÿÿÐÿÿÿÿÿÿÿ0v„ z ÿÿÿÿÿÿÿÿÿÿÿÿ>Àÿÿÿÿÿÿÿ@šðz ÿÿÿÿÿÿÿÿëÿÿÿÿÿÿÿÿ¢«p{ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ´¼à{ ÿÿÿÿÿÿÿÿÿÿÿÿÐÿÿÿÿÿÿÿ0ÆÎp| ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ×ß} ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèð°} ÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ ý~ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿp ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ&.P€ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ8@0 ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿKS‚ ÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿ^fð‚ ÿÿÿÿÿÿÿÿ!ÿÿÿÿÿÿÿÿqyЃ ÿÿÿÿÿÿÿÿ"ÿÿÿÿàÿÿÿÿÿÿÿ ‚@„ ÿÿÿÿÿÿÿÿìÿÿÿÿðÿÿÿÿÿÿÿˆŽ°„ ÿÿÿÿÿÿÿÿ#ÿÿÿÿðÿÿÿÿÿÿÿ”œ0… ÿÿÿÿÿÿÿÿ$ÿÿÿÿðÿÿÿÿÿÿÿ¢ª … ÿÿÿÿÿÿÿÿ%ÿÿÿÿðÿÿÿÿÿÿÿ°µ† ÿÿÿÿÿÿÿÿíÿÿÿÿðÿÿÿÿÿÿÿ»À€† ÿÿÿÿÿÿÿÿ&ÿÿÿÿàÿÿÿÿÿÿÿ ÅÈà† ÿÿÿÿÿÿÿÿ'ÿÿÿÿ>Ðÿÿÿÿÿÿÿ0LR‡ ÿÿÿÿÿÿÿÿ(ÿÿÿÿàÿÿÿÿÿÿÿ Y ‰ ÿÿÿÿÿÿÿÿ)ÿÿÿÿàÿÿÿÿÿÿÿ Š•°‰ ÿÿÿÿÿÿÿÿîÿÿÿÿàÿÿÿÿÿÿÿ žÅ‹ ÿÿÿÿÿÿÿÿïÿÿÿÿÐÿÿÿÿÿÿÿ0Í: Ž ÿÿÿÿÿÿÿÿðÿÿÿÿðÿÿÿÿÿÿÿDQ0 ÿÿÿÿÿÿÿÿñÿÿÿÿÀÿÿÿÿÿÿÿ@Yh ÿÿÿÿÿÿÿÿòÿÿÿÿàÿÿÿÿÿÿÿ q|P ÿÿÿÿÿÿÿÿ*ÿÿÿÿÐÿÿÿÿÿÿÿ0† p‘ ÿÿÿÿÿÿÿÿ+ÿÿÿÿðÿÿÿÿÿÿÿž¦Б ÿÿÿÿÿÿÿÿóÿÿÿÿðÿÿÿÿÿÿÿ²Ìp’ ÿÿÿÿÿÿÿÿ,ÿÿÿÿðÿÿÿÿÿÿÿÚú°“ ÿÿÿÿÿÿÿÿ-ÿÿÿÿðÿÿÿÿÿÿÿ ” ÿÿÿÿÿÿÿÿ.ÿÿÿÿðÿÿÿÿÿÿÿ&`” ÿÿÿÿÿÿÿÿ/ÿÿÿÿðÿÿÿÿÿÿÿ5=À” ÿÿÿÿÿÿÿÿ0ÿÿÿÿðÿÿÿÿÿÿÿKR• ÿÿÿÿÿÿÿÿ1ÿÿÿÿðÿÿÿÿÿÿÿaip• ÿÿÿÿÿÿÿÿ2ÿÿÿÿðÿÿÿÿÿÿÿw~À• ÿÿÿÿÿÿÿÿ3ÿÿÿÿðÿÿÿÿÿÿÿ• – ÿÿÿÿÿÿÿÿ4ÿÿÿÿðÿÿÿÿÿÿÿ£ªp– ÿÿÿÿÿÿÿÿ5ÿÿÿÿðÿÿÿÿÿÿÿ¹ÁЖ ÿÿÿÿÿÿÿÿ6ÿÿÿÿðÿÿÿÿÿÿÿÏÖ — ÿÿÿÿÿÿÿÿ7ÿÿÿÿðÿÿÿÿÿÿÿå퀗 ÿÿÿÿÿÿÿÿ8ÿÿÿÿðÿÿÿÿÿÿÿûЗ ÿÿÿÿÿÿÿÿ9ÿÿÿÿðÿÿÿÿÿÿÿ0˜ ÿÿÿÿÿÿÿÿ:ÿÿÿÿðÿÿÿÿÿÿÿ'.€˜ ÿÿÿÿÿÿÿÿôÿÿÿÿþ°ÿÿÿÿÿÿÿP<pš ÿÿÿÿÿÿÿÿõÿÿÿÿðÿÿÿÿÿÿÿz}@š ÿÿÿÿÿÿÿÿ;ÿÿÿÿàÿÿÿÿÿÿÿ ‡•ðš ÿÿÿÿÿÿÿÿ<ÿÿÿÿðÿÿÿÿÿÿÿŸ­€› ÿÿÿÿÿÿÿÿ=ÿÿÿÿÿÿÿÿ´·› ÿÿÿÿÿÿÿÿ>ÿÿÿÿÿÿÿÿ½À › ÿÿÿÿÿÿÿÿ?ÿÿÿÿÿÿÿÿÈËЛ ÿÿÿÿÿÿÿÿöÿÿÿÿ~Àÿÿÿÿÿÿÿ@Óì@ ÿÿÿÿÿÿÿÿ÷ÿÿÿÿàÿÿÿÿÿÿÿ ž ÿÿÿÿÿÿÿÿ@ÿÿÿÿ~Àÿÿÿÿÿÿÿ@$2  ÿÿÿÿÿÿÿÿAÿÿÿÿðÿÿÿÿÿÿÿDL`  ÿÿÿÿÿÿÿÿøÿÿÿÿðÿÿÿÿÿÿÿXiР ÿÿÿÿÿÿÿÿùÿÿÿÿðÿÿÿÿÿÿÿw‹€¡ ÿÿÿÿÿÿÿÿúÿÿÿÿÿÿÿÿš °¡ ÿÿÿÿÿÿÿÿûÿÿÿÿþ°ÿÿÿÿÿÿÿP°À£ ÿÿÿÿÿÿÿÿBÿÿÿÿðÿÿÿÿÿÿÿÍÑP£ ÿÿÿÿÿÿÿÿüÿÿÿÿàÿÿÿÿÿÿÿ ßï ¤ ÿÿÿÿÿÿÿÿýÿÿÿÿàÿÿÿÿÿÿÿ þ°¤ ÿÿÿÿÿÿÿÿCÿÿÿÿàÿÿÿÿÿÿÿ &@¥ ÿÿÿÿÿÿÿÿþÿÿÿÿðÿÿÿÿÿÿÿ25p¥ ÿÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ BW ¦ ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿem€¦ ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿyЧ ÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ ˜´¨ ÿÿÿÿÿÿÿÿDÿÿÿÿðÿÿÿÿÿÿÿÃË`¨ ÿÿÿÿÿÿÿÿEÿÿÿÿðÿÿÿÿÿÿÿÙà°¨ ÿÿÿÿÿÿÿÿFÿÿÿÿðÿÿÿÿÿÿÿïú@© ÿÿÿÿÿÿÿÿGÿÿÿÿðÿÿÿÿÿÿÿ© ÿÿÿÿÿÿÿÿHÿÿÿÿðÿÿÿÿÿÿÿ&ð© ÿÿÿÿÿÿÿÿIÿÿÿÿðÿÿÿÿÿÿÿ4;@ª ÿÿÿÿÿÿÿÿJÿÿÿÿðÿÿÿÿÿÿÿJR ª ÿÿÿÿÿÿÿÿKÿÿÿÿðÿÿÿÿÿÿÿ`gðª ÿÿÿÿÿÿÿÿLÿÿÿÿðÿÿÿÿÿÿÿv~P« ÿÿÿÿÿÿÿÿMÿÿÿÿðÿÿÿÿÿÿÿŒ“ « °ÿÿÿÿÿÿÿP#­ ÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ ˜à­ ÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ ¡® ¯ ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿ»Â° ÿÿÿÿÿÿÿÿÿÿÿÿ`ÿÿÿÿÿÿÿ Íëб ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿòþ`² ÿÿÿÿÿÿÿÿÿÿÿÿ~Àÿÿÿÿÿÿÿ@ P³ ÿÿÿÿÿÿÿÿ ÿÿÿÿþ ÿÿÿÿÿÿÿ`!Nµ ÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿY^ µ ÿÿÿÿÿÿÿÿNÿÿÿÿþ°ýÿÿÿÿÿÿPjŒÀ· ÿÿÿÿÿÿÿÿ ÿÿÿÿ~Àÿÿÿÿÿÿÿ@™´0¹ ÿÿÿÿÿÿÿÿ ÿÿÿÿàÿÿÿÿÿÿÿ Çè°º ÿÿÿÿÿÿÿÿ ÿÿÿÿ>Àÿÿÿÿÿÿÿ@8`¼ ÿÿÿÿÿÿÿÿOÿÿÿÿðþÿÿÿÿÿÿELÀ¼ ÿÿÿÿÿÿÿÿÿÿÿÿàýÿÿÿÿÿÿ Wl½ ÿÿÿÿÿÿÿÿPÿÿÿÿàýÿÿÿÿÿÿ wо ÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ š«€¿ ÿÿÿÿÿÿÿÿQÿÿÿÿ~@ÿÿÿÿÿÿÿÀ¸î€Â ÿÿÿÿÿÿÿÿÿÿÿÿ~@ÿÿÿÿÿÿÿÀ]pÆ ÿÿÿÿÿÿÿÿRÿÿÿÿ~Àÿÿÿÿÿÿÿ@ov0Ç ÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ „°€È ÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ µÊPÉ ÿÿÿÿÿÿÿÿSÿÿÿÿàÿÿÿÿÿÿÿ ÒÞàÉ ÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ åè@Ê ÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ ò  Ë ÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ ÐË ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿ"0Ì ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿ.CÀÌ ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿQgÍ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿv|ÀÍ ÿÿÿÿÿÿÿÿÿÿÿÿþ°ÿÿÿÿÿÿÿPŒœ Ï ÿÿÿÿÿÿÿÿTÿÿÿÿðÿÿÿÿÿÿÿ©­`Ï ÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ »Ë0Ð ÿÿÿÿÿÿÿÿUÿÿÿÿàÿÿÿÿÿÿÿ ÚäÀÐ ÿÿÿÿÿÿÿÿVÿÿÿÿàÿÿÿÿÿÿÿ óPÑ ÿÿÿÿÿÿÿÿWÿÿÿÿðÿÿÿÿÿÿÿ€Ñ ÿÿÿÿÿÿÿÿÿÿÿÿàÿÿÿÿÿÿÿ 30Ò ÿÿÿÿÿÿÿÿXÿÿÿÿðÿÿÿÿÿÿÿAIÒ ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿUeÓ ÿÿÿÿÿÿÿÿYÿÿÿÿàÿÿÿÿÿÿÿ sðÓ ÿÿÿÿÿÿÿÿZÿÿÿÿðÿÿÿÿÿÿÿœ¤PÔ ÿÿÿÿÿÿÿÿ[ÿÿÿÿðÿÿÿÿÿÿÿ²¹ Ô ÿÿÿÿÿÿÿÿ\ÿÿÿÿðÿÿÿÿÿÿÿÈÐÕ ÿÿÿÿÿÿÿÿ]ÿÿÿÿðÿÿÿÿÿÿÿÞåPÕ ÿÿÿÿÿÿÿÿ^ÿÿÿÿðÿÿÿÿÿÿÿôü°Õ ÿÿÿÿÿÿÿÿ_ÿÿÿÿðÿÿÿÿÿÿÿ Ö ÿÿÿÿÿÿÿÿ`ÿÿÿÿðÿÿÿÿÿÿÿ (`Ö ÿÿÿÿÿÿÿÿaÿÿÿÿðÿÿÿÿÿÿÿ6=°Ö ÿÿÿÿÿÿÿÿbÿÿÿÿðÿÿÿÿÿÿÿLT× ÿÿÿÿÿÿÿÿcÿÿÿÿðÿÿÿÿÿÿÿbi`× ÿÿÿÿÿÿÿÿdÿÿÿÿðÿÿÿÿÿÿÿx€À× ÿÿÿÿÿÿÿÿeÿÿÿÿðÿÿÿÿÿÿÿŽ•Ø ÿÿÿÿÿÿÿÿfÿÿÿÿðÿÿÿÿÿÿÿ¤¬pØ ÿÿÿÿÿÿÿÿgÿÿÿÿðÿÿÿÿÿÿÿºÁÀØ ÿÿÿÿÿÿÿÿhÿÿÿÿðÿÿÿÿÿÿÿÐÛPÙ ÿÿÿÿÿÿÿÿiÿÿÿÿðÿÿÿÿÿÿÿéð Ù ÿÿÿÿÿÿÿÿjÿÿÿÿàÿÿÿÿÿÿÿ M^PÚ ÿÿÿÿÿÿÿÿÿÿÿÿÐýÿÿÿÿÿÿ0j… Û ÿÿÿÿÿÿÿÿkÿÿÿÿàÿÿÿÿÿÿÿ ™ Ü ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿ¥¨pÜ ÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿ±´Ü ÿÿÿÿÿÿÿÿlÿÿÿÿÿÿÿÿ¾ÁÀÜ ÿÿÿÿÿÿÿÿmÿÿÿÿðÿÿÿÿÿÿÿËÖÝ ÿÿÿÿÿÿÿÿnÿÿÿÿðÿÿÿÿÿÿÿÞíÞ ÿÿÿÿÿÿÿÿoÿÿÿÿðÿÿÿÿÿÿÿ÷üPÞ ÿÿÿÿÿÿÿÿ!ÿÿÿÿÿÿÿÿ Þ ÿÿÿÿÿÿÿÿpÿÿÿÿÿÿÿÿðÞ ÿÿÿÿÿÿÿÿqÿÿÿÿàÿÿÿÿÿÿÿ &4°ß ÿÿÿÿÿÿÿÿrÿÿÿÿàÿÿÿÿÿÿÿ <J`à ÿÿÿÿÿÿÿÿsÿÿÿÿÐÿÿÿÿÿÿÿ0Zlá ÿÿÿÿÿÿÿÿ"ÿÿÿÿÿÿÿÿuŠðá ÿÿÿÿÿÿÿÿ#ÿÿÿÿðÿÿÿÿÿÿÿ’©àâ ÿÿÿÿÿÿÿÿ$ÿÿÿÿàÿÿÿÿÿÿÿ µÀ ã ÿÿÿÿÿÿÿÿtÿÿÿÿàÿÿÿÿÿÿÿ ÊØ€ä ÿÿÿÿÿÿÿÿ%ÿÿÿÿÿÿÿÿÝèàä ÿÿÿÿÿÿÿÿ&ÿÿÿÿðÿÿÿÿÿÿÿïû°å ÿÿÿÿÿÿÿÿ'ÿÿÿÿðÿÿÿÿÿÿÿæ ÿÿÿÿÿÿÿÿ(ÿÿÿÿÿÿÿÿ pæ ÿÿÿÿÿÿÿÿuÿÿÿÿðÿÿÿÿÿÿÿAIÐæ ÿÿÿÿÿÿÿÿ)ÿÿÿÿðÿÿÿÿÿÿÿUe@ç ÿÿÿÿÿÿÿÿvÿÿÿÿðÿÿÿÿÿÿÿs‡ðç ÿÿÿÿÿÿÿÿwÿÿÿÿðÿÿÿÿÿÿÿ–žPè ÿÿÿÿÿÿÿÿxÿÿÿÿðÿÿÿÿÿÿÿ¬³ è ÿÿÿÿÿÿÿÿ*ÿÿÿÿàÿÿÿÿÿÿÿ Ju@ê ÿÿÿÿÿÿÿÿ+ÿÿÿÿðÿÿÿÿÿÿÿ‹Ðê ÿÿÿÿÿÿÿÿ,ÿÿÿÿðÿÿÿÿÿÿÿ•¢Pë ÿÿÿÿÿÿÿÿ-ÿÿÿÿàÿÿÿÿÿÿÿ ­µ°ë ÿÿÿÿÿÿÿÿ.ÿÿÿÿàÿÿÿÿÿÿÿ ¿àí ÿÿÿÿÿÿÿÿ/ÿÿÿÿðÿÿÿÿÿÿÿ €î ÿÿÿÿÿÿÿÿ0ÿÿÿÿðÿÿÿÿÿÿÿ#/àî ÿÿÿÿÿÿÿÿ1ÿÿÿÿàÿÿÿÿÿÿÿ 8Sð ÿÿÿÿÿÿÿÿ2ÿÿÿÿðÿÿÿÿÿÿÿZpÐð ÿÿÿÿÿÿÿÿyÿÿÿÿàÿÿÿÿÿÿÿ ~‹@ñ ÿÿÿÿÿÿÿÿ3ÿÿÿÿàÿÿÿÿÿÿÿ ‘›ñ ÿÿÿÿÿÿÿÿzÿÿÿÿàÿÿÿÿÿÿÿ £¶pò ÿÿÿÿÿÿÿÿ{ÿÿÿÿàýÿÿÿÿÿÿ Æéô ÿÿÿÿÿÿÿÿ4ÿÿÿÿðÿÿÿÿÿÿÿîõ@ô ÿÿÿÿÿÿÿÿ5ÿÿÿÿàÿÿÿÿÿÿÿ €õ ÿÿÿÿÿÿÿÿ|ÿÿÿÿðÿÿÿÿÿÿÿ:Bàõ ÿÿÿÿÿÿÿÿ6ÿÿÿÿðÿÿÿÿÿÿÿN_Pö ÿÿÿÿÿÿÿÿ7ÿÿÿÿðÿÿÿÿÿÿÿm‚÷ ÿÿÿÿÿÿÿÿ8ÿÿÿÿÿÿÿÿ‘—0÷ ÿÿÿÿÿÿÿÿ9ÿÿÿÿþ°ÿÿÿÿÿÿÿP§·ø ÿÿÿÿÿÿÿÿ}ÿÿÿÿðÿÿÿÿÿÿÿÄÈÐø ÿÿÿÿÿÿÿÿ:ÿÿÿÿàÿÿÿÿÿÿÿ Öæ ù ÿÿÿÿÿÿÿÿ;ÿÿÿÿàÿÿÿÿÿÿÿ õÿ0ú ÿÿÿÿÿÿÿÿ~ÿÿÿÿàÿÿÿÿÿÿÿ Àú ÿÿÿÿÿÿÿÿ<ÿÿÿÿðÿÿÿÿÿÿÿ),ðú ÿÿÿÿÿÿÿÿ=ÿÿÿÿàÿÿÿÿÿÿÿ 9N û ÿÿÿÿÿÿÿÿ>ÿÿÿÿðÿÿÿÿÿÿÿ\dü ÿÿÿÿÿÿÿÿ?ÿÿÿÿðÿÿÿÿÿÿÿp…ü ÿÿÿÿÿÿÿÿ@ÿÿÿÿàÿÿÿÿÿÿÿ “°ý ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿ¿Çðý ÿÿÿÿÿÿÿÿ€ÿÿÿÿðÿÿÿÿÿÿÿÕÜ@þ ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿëöÐþ ÿÿÿÿÿÿÿÿ‚ÿÿÿÿðÿÿÿÿÿÿÿ  ÿ ÿÿÿÿÿÿÿÿƒÿÿÿÿðÿÿÿÿÿÿÿ"€ÿ ÿÿÿÿÿÿÿÿ„ÿÿÿÿðÿÿÿÿÿÿÿ07Ðÿ ÿÿÿÿÿÿÿÿ…ÿÿÿÿðÿÿÿÿÿÿÿFN0 ÿÿÿÿÿÿÿÿ†ÿÿÿÿðÿÿÿÿÿÿÿ\c€ ÿÿÿÿÿÿÿÿ‡ÿÿÿÿðÿÿÿÿÿÿÿrzà ÿÿÿÿÿÿÿÿˆÿÿÿÿðÿÿÿÿÿÿÿˆ0 ÿÿÿÿÿÿÿÿ‰ÿÿÿÿðÿÿÿÿÿÿÿž¦ ÿÿÿÿÿÿÿÿŠÿÿÿÿðÿÿÿÿÿÿÿ´»à ÿÿÿÿÿÿÿÿ‹ÿÿÿÿðÿÿÿÿÿÿÿÊÒ@ ÿÿÿÿÿÿÿÿŒÿÿÿÿðÿÿÿÿÿÿÿàç ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿöþð ÿÿÿÿÿÿÿÿŽÿÿÿÿðÿÿÿÿÿÿÿ @ ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿ"*  ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿ8?ð ÿÿÿÿÿÿÿÿ‘ÿÿÿÿðÿÿÿÿÿÿÿNVP ÿÿÿÿÿÿÿÿ’ÿÿÿÿðÿÿÿÿÿÿÿdk  ÿÿÿÿÿÿÿÿAÿÿÿÿþ°ÿÿÿÿÿÿÿPf¡@ ÿÿÿÿÿÿÿÿ“ÿÿÿÿàÿÿÿÿÿÿÿ ¨±à ÿÿÿÿÿÿÿÿBÿÿÿÿàÿÿÿÿÿÿÿ ¸½   ÿÿÿÿÿÿÿÿCÿÿÿÿÿÿÿÿÊà  ÿÿÿÿÿÿÿÿDÿÿÿÿðÿÿÿÿÿÿÿéì@  ÿÿÿÿÿÿÿÿEÿÿÿÿÿÿÿÿô   ÿÿÿÿÿÿÿÿ”ÿÿÿÿðÿÿÿÿÿÿÿØà  ÿÿÿÿÿÿÿÿFÿÿÿÿðÿÿÿÿÿÿÿì  ÿÿÿÿÿÿÿÿGÿÿÿÿðÿÿÿÿÿÿÿ$  ÿÿÿÿÿÿÿÿHÿÿÿÿÿÿÿÿ39P  ÿÿÿÿÿÿÿÿIÿÿÿÿþ°ÿÿÿÿÿÿÿPIY°  ÿÿÿÿÿÿÿÿ•ÿÿÿÿðÿÿÿÿÿÿÿfjð  ÿÿÿÿÿÿÿÿJÿÿÿÿàÿÿÿÿÿÿÿ xˆÀ ÿÿÿÿÿÿÿÿKÿÿÿÿàÿÿÿÿÿÿÿ —¡P ÿÿÿÿÿÿÿÿ–ÿÿÿÿàÿÿÿÿÿÿÿ °¿à ÿÿÿÿÿÿÿÿ—ÿÿÿÿðÿÿÿÿÿÿÿËÎ ÿÿÿÿÿÿÿÿLÿÿÿÿàÿÿÿÿÿÿÿ ÛðÀ ÿÿÿÿÿÿÿÿMÿÿÿÿðÿÿÿÿÿÿÿþ  ÿÿÿÿÿÿÿÿNÿÿÿÿðÿÿÿÿÿÿÿ'° ÿÿÿÿÿÿÿÿOÿÿÿÿàÿÿÿÿÿÿÿ 5O  ÿÿÿÿÿÿÿÿPÿÿÿÿðÿÿÿÿÿÿÿ]e ÿÿÿÿÿÿÿÿQÿÿÿÿðÿÿÿÿÿÿÿq„€ ÿÿÿÿÿÿÿÿRÿÿÿÿðÿÿÿÿÿÿÿ’©P ÿÿÿÿÿÿÿÿ˜ÿÿÿÿðÿÿÿÿÿÿÿ¸À° ÿÿÿÿÿÿÿÿ™ÿÿÿÿðÿÿÿÿÿÿÿÎÕ ÿÿÿÿÿÿÿÿšÿÿÿÿðÿÿÿÿÿÿÿäì` ÿÿÿÿÿÿÿÿ›ÿÿÿÿðÿÿÿÿÿÿÿú° ÿÿÿÿÿÿÿÿœÿÿÿÿðÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿ&-` ÿÿÿÿÿÿÿÿžÿÿÿÿðÿÿÿÿÿÿÿ<DÀ ÿÿÿÿÿÿÿÿŸÿÿÿÿðÿÿÿÿÿÿÿRY ÿÿÿÿÿÿÿÿ ÿÿÿÿðÿÿÿÿÿÿÿhpp ÿÿÿÿÿÿÿÿ¡ÿÿÿÿðÿÿÿÿÿÿÿ~…À ÿÿÿÿÿÿÿÿ¢ÿÿÿÿðÿÿÿÿÿÿÿ”œ  ÿÿÿÿÿÿÿÿ£ÿÿÿÿðÿÿÿÿÿÿÿª±p ÿÿÿÿÿÿÿÿ¤ÿÿÿÿðÿÿÿÿÿÿÿÀÈÐ ÿÿÿÿÿÿÿÿ¥ÿÿÿÿðÿÿÿÿÿÿÿÖÝ  ÿÿÿÿÿÿÿÿSÿÿÿÿ~Àÿÿÿÿÿÿÿ@7[p ÿÿÿÿÿÿÿÿTÿÿÿÿðÿÿÿÿÿÿÿfzÀ ÿÿÿÿÿÿÿÿ¦ÿÿÿÿðÿÿÿÿÿÿÿŠ ÿÿÿÿÿÿÿÿUÿÿÿÿÿÿÿÿ“  ÿÿÿÿÿÿÿÿVÿÿÿÿðÿÿÿÿÿÿÿš¦p ÿÿÿÿÿÿÿÿWÿÿÿÿÿÿÿÿ­°€ ÿÿÿÿÿÿÿÿXÿÿÿÿðÿÿÿÿÿÿÿºÇà ÿÿÿÿÿÿÿÿYÿÿÿÿÿÿÿÿÏÔ  ÿÿÿÿÿÿÿÿZÿÿÿÿðÿÿÿÿÿÿÿÞë€ ÿÿÿÿÿÿÿÿ[ÿÿÿÿÿÿÿÿôùÀ ÿÿÿÿÿÿÿÿ§ÿÿÿÿðÿÿÿÿÿÿÿP ÿÿÿÿÿÿÿÿ¨ÿÿÿÿðÿÿÿÿÿÿÿ)  ÿÿÿÿÿÿÿÿ\ÿÿÿÿðÿÿÿÿÿÿÿ3E`  ÿÿÿÿÿÿÿÿ]ÿÿÿÿðÿÿÿÿÿÿÿMP  ÿÿÿÿÿÿÿÿ^ÿÿÿÿðÿÿÿÿÿÿÿZið  ÿÿÿÿÿÿÿÿ_ÿÿÿÿðÿÿÿÿÿÿÿqt0! ÿÿÿÿÿÿÿÿ©ÿÿÿÿðÿÿÿÿÿÿÿ‚À! ÿÿÿÿÿÿÿÿ`ÿÿÿÿðÿÿÿÿÿÿÿ™¨ " ÿÿÿÿÿÿÿÿaÿÿÿÿðÿÿÿÿÿÿÿ°³ " ÿÿÿÿÿÿÿÿªÿÿÿÿðÿÿÿÿÿÿÿ)<`# ÿÿÿÿÿÿÿÿ«ÿÿÿÿàÿÿÿÿÿÿÿ GU $ ÿÿÿÿÿÿÿÿbÿÿÿÿàÿÿÿÿÿÿÿ _mÐ$ ÿÿÿÿÿÿÿÿ¬ÿÿÿÿ>Ðÿÿÿÿÿÿÿ0v£ & ÿÿÿÿÿÿÿÿ­ÿÿÿÿÐÿÿÿÿÿÿÿ0«¼ ' ÿÿÿÿÿÿÿÿ®ÿÿÿÿàÿÿÿÿÿÿÿ ÃÚà( ÿÿÿÿÿÿÿÿ¯ÿÿÿÿàÿÿÿÿÿÿÿ âñP* ÿÿÿÿÿÿÿÿ°ÿÿÿÿðÿÿÿÿÿÿÿûð* ÿÿÿÿÿÿÿÿcÿÿÿÿÿÿÿÿ p+ ÿÿÿÿÿÿÿÿ±ÿÿÿÿàÿÿÿÿÿÿÿ 10, ÿÿÿÿÿÿÿÿ²ÿÿÿÿàÿÿÿÿÿÿÿ 6= , ÿÿÿÿÿÿÿÿ³ÿÿÿÿàÿÿÿÿÿÿÿ EL0- ÿÿÿÿÿÿÿÿ´ÿÿÿÿðÿÿÿÿÿÿÿQW- ÿÿÿÿÿÿÿÿµÿÿÿÿàÿÿÿÿÿÿÿ `i€. ÿÿÿÿÿÿÿÿ¶ÿÿÿÿðÿÿÿÿÿÿÿotÀ. ÿÿÿÿÿÿÿÿ·ÿÿÿÿðÿÿÿÿÿÿÿz/ ÿÿÿÿÿÿÿÿ¸ÿÿÿÿàÿÿÿÿÿÿÿ …—Ð/ ÿÿÿÿÿÿÿÿ¹ÿÿÿÿàÿÿÿÿÿÿÿ ¨@0 ÿÿÿÿÿÿÿÿºÿÿÿÿàÿÿÿÿÿÿÿ ¯Ç°1 ÿÿÿÿÿÿÿÿ»ÿÿÿÿàÿÿÿÿÿÿÿ Íæp3 ÿÿÿÿÿÿÿÿ¼ÿÿÿÿàÿÿÿÿÿÿÿ í5 ÿÿÿÿÿÿÿÿ½ÿÿÿÿÐýÿÿÿÿÿÿ0p7 ÿÿÿÿÿÿÿÿ¾ÿÿÿÿðÿÿÿÿÿÿÿ"% 7 ÿÿÿÿÿÿÿÿdÿÿÿÿðÿÿÿÿÿÿÿ,EÐ8 ÿÿÿÿÿÿÿÿ¿ÿÿÿÿðÿÿÿÿÿÿÿJM9 ÿÿÿÿÿÿÿÿeÿÿÿÿ~Àÿÿÿÿÿÿÿ@g™À; ÿÿÿÿÿÿÿÿÀÿÿÿÿàÿÿÿÿÿÿÿ ž¯ð< ÿÿÿÿÿÿÿÿÁÿÿÿÿÿÿÿÿµ¾ > ÿÿÿÿÿÿÿÿfÿÿÿÿàÿÿÿÿÿÿÿ ÃÇà> ÿÿÿÿÿÿÿÿgÿÿÿÿÐÿÿÿÿÿÿÿ0ÏÜÐ? ÿÿÿÿÿÿÿÿhÿÿÿÿ>Ðÿÿÿÿÿÿÿ0â PA ÿÿÿÿÿÿÿÿÂÿÿÿÿàÿÿÿÿÿÿÿ .àB ÿÿÿÿÿÿÿÿÃÿÿÿÿ€ûÿÿÿÿÿÿ€5ApC ÿÿÿÿÿÿÿÿiÿÿÿÿàÿÿÿÿÿÿÿ H\PD ÿÿÿÿÿÿÿÿjÿÿÿÿðÿÿÿÿÿÿÿ~“°D ÿÿÿÿÿÿÿÿkÿÿÿÿðÿÿÿÿÿÿÿ˜›ðD ÿÿÿÿÿÿÿÿlÿÿÿÿðÿÿÿÿÿÿÿ ¯€E ÿÿÿÿÿÿÿÿmÿÿÿÿðÿÿÿÿÿÿÿ´ÃðE ÿÿÿÿÿÿÿÿÄÿÿÿÿ€ûÿÿÿÿÿÿ€TgG ÿÿÿÿÿÿÿÿÅÿÿÿÿðÿÿÿÿÿÿÿq} G ÿÿÿÿÿÿÿÿÆÿÿÿÿðÿÿÿÿÿÿÿ‚ˆH ÿÿÿÿÿÿÿÿnÿÿÿÿÐÿÿÿÿÿÿÿ0œÐH ÿÿÿÿÿÿÿÿoÿÿÿÿÿÿÿÿ¤©ðH ÿÿÿÿÿÿÿÿÇÿÿÿÿðÿÿÿÿÿÿÿ¯¹pI ÿÿÿÿÿÿÿÿÈÿÿÿÿðÿÿÿÿÿÿÿ¿Â°I ÿÿÿÿÿÿÿÿÉÿÿÿÿðÿÿÿÿÿÿÿÈËðI ÿÿÿÿÿÿÿÿpÿÿÿÿðÿÿÿÿÿÿÿÒÜÐJ ÿÿÿÿÿÿÿÿqÿÿÿÿðÿÿÿÿÿÿÿâë°K ÿÿÿÿÿÿÿÿÊÿÿÿÿðÿÿÿÿÿÿÿø ÀL ÿÿÿÿÿÿÿÿËÿÿÿÿðÿÿÿÿÿÿÿ€M ÿÿÿÿÿÿÿÿrÿÿÿÿÿÿÿÿ$' M ÿÿÿÿÿÿÿÿsÿÿÿÿÿÿÿÿ,/ÀM ÿÿÿÿÿÿÿÿtÿÿÿÿÿÿÿÿ5= N ÿÿÿÿÿÿÿÿuÿÿÿÿ€ûÿÿÿÿÿÿ€BPÐN ÿÿÿÿÿÿÿÿvÿÿÿÿ€ûÿÿÿÿÿÿ€Uc€O ÿÿÿÿÿÿÿÿÌÿÿÿÿ€ûÿÿÿÿÿÿ€hx`P ÿÿÿÿÿÿÿÿwÿÿÿÿpûÿÿÿÿÿÿ’ Q ÿÿÿÿÿÿÿÿÍÿÿÿÿ€ûÿÿÿÿÿÿ€—¤`R ÿÿÿÿÿÿÿÿÎÿÿÿÿðÿÿÿÿÿÿÿ©¯ R ÿÿÿÿÿÿÿÿxÿÿÿÿÐÿÿÿÿÿÿÿ0µÜ°T ÿÿÿÿÿÿÿÿÏÿÿÿÿðÿÿÿÿÿÿÿ8>U ÿÿÿÿÿÿÿÿÐÿÿÿÿðÿÿÿÿÿÿÿDJpU ÿÿÿÿÿÿÿÿyÿÿÿÿàþÿÿÿÿÿÿ QmàV ÿÿÿÿÿÿÿÿÑÿÿÿÿðÿÿÿÿÿÿÿsxW ÿÿÿÿÿÿÿÿÒÿÿÿÿðÿÿÿÿÿÿÿ~ƒ@W ÿÿÿÿÿÿÿÿzÿÿÿÿÐÿÿÿÿÿÿÿ0‰Ÿ@X ÿÿÿÿÿÿÿÿ{ÿÿÿÿðÿÿÿÿÿÿÿ¤¹ÐX ÿÿÿÿÿÿÿÿ|ÿÿÿÿÈûÿÿÿÿÿÿ@Ë#\ ÿÿÿÿÿÿÿÿÓÿÿÿÿàýÿÿÿÿÿÿ 2HP] ÿÿÿÿÿÿÿÿ}ÿÿÿÿÿÿÿÿp] ÿÿÿÿÿÿÿÿ~ÿÿÿÿðÿÿÿÿÿÿÿ &À] ÿÿÿÿÿÿÿÿÿÿÿÿpýÿÿÿÿÿÿ0Jà^ ÿÿÿÿÿÿÿÿÔÿÿÿÿðÿÿÿÿÿÿÿ@D _ ÿÿÿÿÿÿÿÿÕÿÿÿÿðÿÿÿÿÿÿÿFJP_ ÿÿÿÿÿÿÿÿÖÿÿÿÿàÿÿÿÿÿÿÿ Lb ` ÿÿÿÿÿÿÿÿ×ÿÿÿÿàÿÿÿÿÿÿÿ dtKð «  F°(C1 C0GÐ Ñ èÿÿÿÿÿÿÿ#DAàÿÿÿÿÿÿÿ(DqØÿÿÿÿÿÿÿ,D¡ 01Ðÿÿÿÿÿÿÿ2D1HH@` HHKp ÇRÉR/ÉR È Ê"XCÇRSÉ‚ fÉ’@tÉ’€É’À†É’ŠÉÂ@ŽÉò€–É"À›ÉbªÉò@±Éò€»É‚ ÇÉ‚CÈbCÊRHK°ÇR ÉR!.ÉRÈ ;ÇÂLÉÂ@_ÉÒ€hÉbÀnÉÂàuÉÂ;ÈR;Ê’@zÇ’LÉÂ@‹ÉÒ€ÉÀ“ÉÂà—ÉžÉÂ@­Éb€ºÉ ÆÉÂÀÔÉÂzÈÒzÊBHKРǢ@ÉRA*ÉRB;ÉRCHÉRDVÉREgÉRFtÉR È0ÇBÉ’@£É¢€¨É¢À¬É’à°É’·É’ ¾É’@ÂÉ’È¢ÊbÇDzÉ’@ÙÉ‬ɒ °É’ÇÈRÇÊHK@Ê"Ê"HK HKÊ"Êb8$Çò%ÉÒ *Éâ@1Éò€6ÉòÀ<ÉÒàDÉðJÉPÉ@ZÉ"€`Éò$È2iÊ¢HKpÇRÉ"@ÉbÈ%Ê2HK` Ê"$Êb,Êb5ÊÒ5ÊÒ<ÊÒDÊ"LÊ¢TÊâ]ÊbdÊRlÊ’uÊÒʇÊRÇ2‘É’È“Ê"PÇr¥É‚ÈBÊâ©ÊÒ±ÊҹʢÁÊâÉÊ¢ÐÊ"ÖÊ‚ÜÊÒâÊÒéÊ"ïÊRöÊÒþÊòÊÒ Ê"Ê"Ê"Ê¢%ÊÒ+Ê 2Êb;ÊbEÊbNÊbUÊR°^ÇroÉ"@wÉ¢€~ÉRÀ„É’ ^ÈÊò €žÇÂoÉ"@„ÉR žÈ‚´ʲ pÈÇoÉ"@„É ÈÈÒÝÊr ˆðDzüÉ¢@É¢€ÉâÉ¢˜%É¢ 1É¢¨<ÉÒ ¸HÉ¢ÀRÉR]É2 €iÉ¢ÀwÉ¢„É¢@”É¢€£É¢À±ÉR¾É’ @ËÉR€×Éb ãÉbÀïÉbàþÉÒ É¢ðÈ"ÊÒ $Ê¢ 01ÇrCÉb oÉb@wÉ¢€~Éb JÉbÀRÉRRÉR@ZÉ¢1ÈÒbÊ’(rǃÉb oÉb@wÉ¢€~ÉbÀRÉRZÉ¢rÈ‚‹Ê"šÊbX¨ÇbƒÉ"@„É‚¨È"¹ÊâÈÊ"ÐÊrÖÊâÛÊbæÊ"îÊ"öÊ"ýÊ"ʲ ÊòÊ"ÊbÊR$ʲ+Êò3Ê"9Êb@Ê¢HÊâQÊ"XÊb`Çò¥ÉB`ÈÂfÊ¢kÊ"sÊR{Ê¢‡Êb‘ÊâHK@&Ê"2Ê"HK Ê"Ê"#Çb*É’#È2#Ê3Ç’3ÈrHKÀÇRÉR "ÉRÈÊ"&Ç¢ÉÂ@"ÉÂ&Èb&Ê’HK0 ¨Ç‚,Ér@1É¢€;É"ÀIÉ"WÉ2ÈÊB˜iÇò,ÉÀxÉ¢ˆÉ¢@˜É¢€ªÉ¢À¼É¢ÉÉ¢@×É¢€åÉBˆõÉBÉB˜ÉB ÉB¨,ÉB°;ÉB¸GÉBÀSÉ¢^É¢@jÉ¢€{É¢iÈ’iÊâHÇb,É€›É¢À©É¢·É‚ÈÊ’XÀÇâ,ÉRÀËÉ¢ÓÉ¢@ÚÉ¢€áÉ¢ÀÈrÀÊ"èçÇ2,É@òÉ¢€øÉ¢Àþɢɢ@ɲɲÀÉÀ !ÉÀ %Ér@ +É2€ /É¢À 8É¢BÉ¢@MÉ¢€XÉ¢À`É¢lÉ¢çÈòçÊÒ¸vÇB,ÉB€„É2ˆŒÉ2”É2ÀŸÉr§Ér ±Ér@»Ér`ÅÉr€ÐÉrÀÛÉ‚åÉ2@îɲ€öÉâvÈBvʘþÇb,ÉB@ Ér`Ér€Ér "ÉrÀ,ÉÒ3ÉÒ@:ÉÒ€@ÉÒÀFÉ‚KÉr WÉ2@`Éâ€iÉr rÉrþÈRþÊ`}ÇB,É ÀŠÉ¢€’ÉÀ›É2¦Éb@±É’€ºÉÂÀÆÉòÑÉ"@ÙÉR€áÉ‚}Èr}ÊâêÇ’ëÉ¢ íÉÒÈRïÊr êÇâüÉ¢@ÉrêÈ¢ Ê êÇ2Ér@Éb êÈò(Ê’ 8ÊBFÊ¢êÇ¢XÉâ ÉR êÈbdʲ xÊò êÇ ‰Ér Ér@‘ÉÒêÈ•ÊR ªÊ‚ 0êÇÒ ¼Ér ÉÉr@ÔÉr`ãÉr€ðÉâ ÀûÉ ÉB @Ér êÈ2 ÊÒ êÇ É2êÈâ $ÊB0êÇb 7É =ÉÈ" CÊ¢êÇ PÉr@WÉ¢€^É¢êÈr eÊêÇ pÉ¢@uÉrêÈÒ zÊbHKpÇÂ+ÉR3ÉR>ÉRJÉRTÉR`ÉRlÉRyÉR ‚ÉRÈÊ"‹ÇBŒÉb ”É’0šÉ’@¡ÉÒ€©ÉÒ‹ÈҮʢˆ‹Çb»ÉâÀ¿ÉËÉ"@ÒÉ2€ÛÉ"ÀâÉ2ëÉ"@ñÉ"€úÉ"ÀÉ" É"@É"€É"À*Éb/É‹ÈR4Ê’H‹Ç»ÉâÀGÉPÉ@YÉ2€`É"À*Éb/É‹ÈriÊ’p‹Çò»ÉâÀzÉ"‚É2@ŠÉ"€’É2ÀšÉ"¢É"@ªÉ2€³É"À»Éò*É@/É‹ÈÃÊ28ÖÇÒÙÉ àÉÂ@çÉÂ`ïÉ€÷É þÉÂÀÉÂàÉÂÉÂ@ÉÒ€)ÉâÖÈH‹Çb»ÉâÀ¿É1É2@:É€CÉ2À*Éò/É‹ÈÒLÊ"8‹Çâ»ÉâÀ¿É\É‚@*ɲ€/É‹ÈrdÊâ0‹ÇR»ÉâÀ¿É*ÉB@/É‹ÈòxÊr8‹ÇÒ»ÉâÀ¿É‹É"@*ÉÒ€/É‹Èb“Ê8‹ÇR»ÉâÀ¿É£Éb@*É’€/É‹Èâ®ÊÂHK€hÇrÉR@+ÉR€9ÉRÀBÉRRÉR@bÉR€tÉRÀ†ÉR“ÉR@¡ÉR€¯Ébˆ¿ÉbËÉb˜ÙÉb èÉb¨öÉb°Éb¸ÉbÀÉR.ÉRÈHK(Ç‚ÉR@$Éb€)ÉrÀ.Ér3ÉrÈHKpÊ" %Çb0É’€<É’%È"HK°Çb(ÉR@.É‚€7É’È?Ê"GDzNÉ‚XÉ"ÈrbÊòkÇzÉò@‡É‚`”É‚kÈ¢Êb@³Çb¼É’€ÌÉò³È"0ÖÇ¢×É"ÞÉ‚ÈbÖÇâêɲ@ÉÂÖÈ¢ÊÂ%Ç2.ÉR@5É‚%Èò=Ê" HÇ¢OÉÂ@WÉ€_ÉÀfÉHÈBHK0Ê"HK° Ê"Ê"Ê’Ç’(É‚ ;ÉÒ@EÉ’ÈBÊRHKð ÇrÉR,ÉR‘9ÉR’IÉR ÈWÊbfÇÒ˜tÉR™ƒÉRšÉRfÈ‚šÊbHKÐ Ê"HÇ¢'Éò@:É€?Éb€DÉÀPÉ2^ÉÈ"ÊÂ0gÇ2'Éò@wÉr€}ÉrÀ„ÉòŠÉÒ@‘ÉògȲgÊ¢›Ç²'Éò@²É@¾É’@ÊÉ’@×Éò›ÈB›ÊXàDz'Éò@íÉr€ðÉò ôÉòÀûÉ¢Éò Éò@ÉÒ€ÉÒÀ"É/É2@<Éò€IÉ"àÈÂàÊBHK H ÇÉâ@0É"€:Éâ >ÉâÀBÉâàLÉâUÉâ ^Éâ@dÉ2€kÉâ tÉRzÉB €ÉB È ʲHK ÇrÉ" 2É"@8É"€<É2 È ÊB AÇòÉ"@OÉ¢€WÉÒÀ^É"àbÉ"AÈ‚AÊHKP8ÇÒ-Ér @Ér@EÉr`SÉr€_Ér lÉrÀzÉrˆÉ"@Ér€—É2ÈÊB(¡Ç’-Ér @Ér@¾É`SÉr€_Ér lÉrÀÐɲÔÉr ØÉr¡Èâ¡Êâ(ßÇ2-Ér @Ér@õÉ¢€ˆÉÒÀùÉÒÉr  ÉrßÈ¢ßÊrHKPÊ"Êb!Ê"HK Hüÿÿÿÿ<ÿÿÿ/<ÿO ÿ/ 1ÿ/<ÿ_<ÿ?<ÿŸ<ÿO<ÿÿü Ó¥[8ÿ<ÿ_<ÿ?<ÿŸ<ÿÿ<ÿŸ0ÿo<ÿ/<ÿ_ü M1Þ8ÿ<ÿÿ0ÿ_<ÿÏ<ÿÏ0ÿß<ÿŸü€Kv×8ÿ0ÿ¯<ÿO<ÿO0ÿ_<ÿ¿ü¡ë^ó<ÿ<ÿ/üÿÿÿÿ<ÿÿÿ/üKÓ |<ÿx<ÿ/0ÿ? h<ÿÿü4»±Z0ÿ<ÿ_üÇê?Âx<ÿ<ÿ/<ÿ?<ÿO<ÿ_<ÿo<ÿ <ÿ<ÿŸ<ÿ¯|<ÿ¿ <ÿÏ<ÿß<ÿï|<ÿÿxÿ/@0ÿ0ÿ<ÿ?xÿ/ @0ÿO<ÿ<ÿ<ÿŸ<ÿ¯x<ÿ¿<ÿÏ<ÿß<ÿï<ÿÿ<ÿ<ÿ<ÿ/<ÿ?<ÿO<ÿ_<ÿo<ÿ<ÿh<ÿŸ<ÿ¯ÿ/ <ÿ¿<ÿÏ<ÿß<ÿï<ÿÿ<ÿ|ÿ/@0ÿ<ÿ|ÿ/@0ÿ<ÿÏ|ÿ/ @0ÿß<ÿ ÿ/|ÿ/@h0ÿ/0ÿ/<ÿ¿<ÿÏ0ÿß0ÿß<ÿ0ÿ0ÿ<ÿ<ÿ0ÿ/0ÿ/<ÿo<ÿh<ÿ<ÿŸ<ÿ¯<ÿ¿<ÿÏ<ÿß<ÿï<ÿÿ<ÿ<ÿ<ÿ/<ÿ?<ÿO<ÿ_<ÿo<ÿ<ÿ<ÿŸ<ÿ¯<ÿ¿ÿ/ 0ÿÏ<ÿÿ<ÿ <ÿ <ÿ/ <ÿ? <ÿO ü& <…|<ÿ <ÿ/ ü& `<ÿ <ÿ/ <ÿ/ ÿ/ 0ÿ? <ÿo 0ÿ üå oC0ÿ <ÿ_ 0ÿo x<ÿ¯ üä“ѯ| 0ÿ <ÿo <ÿ 0ÿŸ <ÿï <ÿÿ 0ÿ <ÿ_ <ÿo 0ÿ <ÿß <ÿï 1ÿ/@1ÿ/ @1ÿ/@0ÿÿ <ÿo <ÿ? <ÿo <ÿÏ <ÿ 0ÿO <ÿÿ <ÿŸ <ÿO <ÿ 0ÿ_ <ÿ <ÿo 1ÿ/6@0ÿ<ÿ <ÿO <ÿo <ÿÿ <ÿo <ÿï <ÿ? 1ÿ/@0ÿ <ÿ_ <ÿO 4ÿ_ ÿ/ 0ÿ¯ <ÿï <ÿï 0ÿÿ <ÿ? <ÿO <ÿ_ ÿ/ 0ÿo <ÿ¯ <ÿ¿ 0ÿÏ <ÿ <ÿ/ <ÿO <ÿ¿ <ÿ/ 1ÿ/@0ÿ? <ÿß 0ÿï <ÿ 4ÿ/ <ÿo 0ÿ <ÿÏ 0ÿß <ÿ üž€Ã8ÿ <ÿÏ 0ÿß |<ÿO !<ÿ0!ÿ 0ÿ_ h<ÿo <ÿÿ<ÿ?0!ÿ_ 0ÿ <ÿ h0!ÿO 0ÿ <ÿÿ 0ÿ x0!ÿÿ 0ÿß <ÿo <ÿ0!ÿŸ 0ÿ <ÿï 0!ÿ 0ÿÿ <ÿ_ 0!ÿ 0ÿo <ÿß 0!ÿ0!ÿ 0ÿï <ÿ_ ü>›7í0ÿüܳ 0ÿ,üëtÇ’<ÿ0ÿ/0ÿÿüCÊyD0ÿ<ÿ¯<ÿ<ÿo4ÿh<ÿ¿0ÿÏ<ÿ0ÿ/4ÿoÿ/ 0ÿ¯h<ÿ<ÿï0ÿÿ<ÿ_x<ÿ?0ÿO|üeß“B<ÿüÄ ä^<ÿ<ÿ/<ÿ?<ÿ?ÿ/|0ÿO<ÿŸüÒšt8ÿ<ÿ8ÿ<ÿßü}òüx<ÿÿ/ 0ÿ/<ÿ/<ÿ¯<ÿ¯0ÿ¿,<ÿ?<ÿ?ÿ/ÿ€<ÿ¯ÿ/ÿ@0ÿO<ÿ¿<ÿ?<ÿ¿<ÿ<ÿ/(0ÿÏ<ÿ¿üNdžÌ(((ÿ/ 0ÿ<ÿüÑ膕0ÿ<ÿ<ÿO<ÿ0ÿ<ÿÿüP’ úh0ÿ<ÿß<ÿß0ÿï<ÿ/<ÿŸ0ÿ¯<ÿO<ÿ?üQ06*,<ÿ<ÿ/<ÿ?ü ?Íútestgendb.cmainargcargvgdbcscsesseqgenireloadgenomicdb.hGenDBErrorTypeGENDB_READ_THROUGHGENDB_FAIL_ON_ERRORWise2_GenomicDBdynamite_hard_linkis_single_seqdone_forwardforwrevsdbcurrentcseserror_handlingsinglerevsinglelength_of_Nrepeat_in_cds_scoresequencedb.hSequenceDBFormatSEQ_DB_UNKNOWNSEQ_DB_FASTAWise2_FileSourcedynamite_hard_linkfilenameinputformattypeWise2_SequenceDBnamefslenmaxlencurrent_sourcecurrent_filesequence_nobyte_positionhas_warned_singlesequence.hSequenceTypeSEQUENCE_UNKNOWNSEQUENCE_PROTEINSEQUENCE_DNASEQUENCE_CDNASEQUENCE_GENOMICSEQUENCE_ESTSEQUENCE_RNAWise2_Sequencedynamite_hard_linknameseqlenmaxlenoffsetendtypeWise2_SequenceSetset../base//wisebase.hboolean/usr/include/stdio.h/usr/include/stdio.hsize_tfpos_t_cnt_flag2_ptr_base_bufsiz_flag_file__newbase_lock_bufendpFILE/usr/include/va_list.h_a0_offsetva_list/usr/include/sys/types.hptrdiff_twchar_twctype_ttime_tclock_tssize_tuchar_tushort_tuint_tulong_tvuchar_tvushort_tvuint_tvulong_trphysadr_tlabel_tvallevel_tdaddr_tcaddr_tqaddr_taddr_tino_tcnt_tdev_tchan_toff_trlim_tpaddr_tnlink_tkey_tmode_tuid_tgid_tmid_tpid_tslab_tshmatt_tmsgqnum_tmsglen_twint_tsigset_t__pthread_attr_t__valid__name__arg__reservedpthread_attr_t__pthread_mutexattr_tpthread_mutexattr_t__pthread_condattr_tpthread_condattr_t__pthread_t__reserved1__reserved2__size__version__reserved3__external__reserved4__creator__sequence__reserved5__per_kt_area__stack_base__stack_reserve__stack_yellow__stack_guard__stack_size__tsd_values__tsd_count__reserved6__reserved7__thread_flags__thd_errno__stack_hiwaterpthread_tpthreadTeb_t__pthread_mutex_t__lock__depth__owner__blockpthread_mutex_t__pthread_cond_t__statepthread_cond_tpthread_key_t__pthread_once_tpthread_once_ttimer_tsig_tid_tuseconds_tmajor_tminor_tdevs_tunit_tucharushortuintulongphysadru_charu_shortu_intu_longvu_charvu_shortvu_intvu_long_quadquadswblk_tfixpt_tsa_family_tin_addr_tin_port_t/usr/include/mach/machine/vm_types.hvm_offset_tvm_size_t/usr/include/sys/select.hfd_maskfd_setfds_bitstimeval/usr/include/stdlib.hdiv_tquotremldiv_t/usr/include/sys/localedef.h_LC_charmap_tcorecm_csnamecm_mb_cur_maxcm_mb_cur_mincm_max_disp_width_LC_monetary_tint_curr_symbolcurrency_symbolmon_decimal_pointmon_thousands_sepmon_groupingpositive_signnegative_signint_frac_digitsfrac_digitsp_cs_precedesp_sep_by_spacen_cs_precedesn_sep_by_spacep_sign_posnn_sign_posndebit_signcredit_signleft_parenthesisright_parenthesis_LC_numeric_tdecimal_pointthousands_sepgrouping_LC_resp_tyesexprnoexpryesstrnostr_LC_time_td_fmtt_fmtd_t_fmtt_fmt_ampmabdaydayabmonmonam_pmeraera_yearera_d_fmtalt_digitsm_d_recentm_d_oldera_d_t_fmtera_t_fmt_LC_collate_tco_nordversionce_definedco_sortco_wc_minco_wc_maxco_hboundco_col_minco_col_maxco_coltblco_nsubsco_subsmethods_LC_ctype_tmin_wcmax_wcmax_uppermax_lower_upper_lower_maskqmaskqidxqidx_hboundnclassesclassnmsnum_rowsnum_qmasks_LC_locale_tnl_infonl_lconvlc_charmaplc_collatelc_ctypelc_monetarylc_numericlc_resplc_timenl_info2np_LC_weight_tce_symce_wgt_LC_collel_tct_wgtct_collel_LC_coltbl_v1_t_LC_strpool_t_LC_strpool_ptr_tstrpool_idx_LC_collel_tbl_v2_t_LC_collel_tbl_tminmaxtbl_LC_collel_qidx_v2_t_LC_collel_qidx_tce_tbl_bsizece_tbl_cntce_strpool_cntversion_maskce_strpoolce_tblce_qidx_LC_coltbl_v2_tgetcolval_LC_coll_methods_tct_v1ct_v2_LC_coltbl_tss_actss_srcss_tgt_LC_subs_tnamemask_LC_classnm_t/usr/include/sys/lc_core.h__lc_type_id_t_LC_CAR_LC_LOCALE_LC_CHARMAP_LC_CTYPE_LC_COLLATE_LC_NUMERIC_LC_MONETARY_LC_TIME_LC_RESPtype_idmagicformatversionsize_LC_object_thdrnl_langinfombtowcmbstowcswctombwcstombsmblenwcswidthwcwidth__mbtopc__mbstopcs__pctomb__pcstombsinitdata_LC_core_charmap_ttowuppertowlowerwctypeiswctype_LC_core_ctype_tstrcollstrxfrmwcscollwcsxfrmfnmatchregcompregerrorregexecregfree_LC_core_collate_ttmtm_sectm_mintm_hourtm_mdaytm_montm_yeartm_wdaytm_ydaytm_isdsttm_gmtofftm_zonestrftimestrptimewcsftime_LC_core_time_tstrfmon_LC_core_monetary_t_LC_core_numeric_trpmatch_LC_core_resp_tlocaleconv_LC_core_locale_t/usr/include/locale.hlconvdecimal_pointthousands_sepgroupingint_curr_symbolcurrency_symbolmon_decimal_pointmon_thousands_sepmon_groupingpositive_signnegative_signint_frac_digitsfrac_digitsp_cs_precedesp_sep_by_spacen_cs_precedesn_sep_by_spacep_sign_posnn_sign_posnleft_parenthesisright_parenthesis/usr/include/math.hexceptiontypenamearg1arg2retval/usr/include/sys/timers.hclockid_titimerspecit_intervalit_value/usr/include/sys/sysmisc.hsigaltstackss_spss_flagsss_sizestack_tsigvalsival_intsival_ptrsigval_tsigevent_event_sigev_value_sigev_signo_sigev_notifysigevent_event_tsigevent_sigev_sigevent_sigev_un_sigev_sigev_un_s_sigev_notify_function_sigev_notify_attributessigevent_ttimespectv_sectv_nsectimespec_tuuprofpr_basepr_sizepr_offpr_scale../base//wiseerror.hFlagcodon.hbasecodonaaWise2_CodonTabledynamite_hard_linkcodon_strnamedatabase.hreturn_statusDB_RETURN_UNKNOWNDB_RETURN_OKDB_RETURN_ERRORDB_RETURN_ENDDB_Return_Typesearch_returnSEARCH_UNKNOWNSEARCH_ERRORSEARCH_OKSearch_Return_Typehscore.hBytePositionWise2_DataEntrydynamite_hard_linknamedatais_reversedbyte_positionfilenameWise2_DataScorequerytargetscoreevalueis_storedWise2_DataScoreStoragescore_arrayquery_arraytarget_arraycurr_posWise2_Hscoredslenmaxlenstorest_lenst_maxlenhisscore_levelshould_storescore_to_hisreport_leveltotalhistogram.hWise2_Histogramdynamite_hard_linkhistogramminmaxhighscorelowscorelumpsizetotalexpectfit_typeparamchisqchipgenomic.hWise2_GenomicRepeatdynamite_hard_linkstartendtypeWise2_Genomicbaseseqrepeatlenmaxlencomplexsequence.hWise2_ComplexSequenceEvaldynamite_hard_linktypesequence_typeleft_windowright_windowleft_lookbackoutside_scoredatadata_typeeval_funcWise2_ComplexSequenceEvalSethas_been_preparedcselenmaxlenWise2_ComplexSequenceseqdatastoredepthlengthprobability.hProbabilityScoreBitscomplexevalset.h.text.init.fini.data.sdata.rdata.sbss.bss.lit8.lit4.rconst__environ__Argc__Argv_auxv_ldr_presenterrno__ldr_data__main_routinemain__start__istartexit_mcount__eproleprol_fpdatafprintfstrtokexplogWise2_is_double_stringWise2_Probability_from_average_state_occupancyWise2_state_occupancy_from_ProbabilityWise2_Probability_logsumWise2_show_Score_arrayWise2_show_Probability_array_expWise2_read_Probability_arrayWise2_show_Probability_arrayWise2_sum_Probability_arrayWise2_set_Probability_arrayWise2_Probability2Score_moveWise2_Probability_moveWise2_Score_moveWise2_renormalise_Probability_arrayWise2_Probability_array_divideWise2_Probability_array_multiplyWise2_Probability_array_addWise2_Probability_array_subtractWise2_Score_array_addWise2_Score_array_subtractWise2_Score_Probability_sumWise2_Probability2ScoreWise2_halfbit2ProbabilityWise2_Bits2ProbabilityWise2_Probability2halfbitWise2_Score2ProbabilityWise2_Score2BitsWise2_stringallocWise2_ckallocWise2_ckfreeWise2_warnWise2_uppercase_SequenceWise2_force_to_dna_SequenceWise2_is_reversed_SequenceWise2_reverse_complement_SequenceWise2_free_SequenceWise2_get_Sequence_from_SequenceDBWise2_add_SequenceDB_info_DataEntryWise2_close_SequenceDBWise2_init_SequenceDBWise2_reload_SequenceDBWise2_hard_link_SequenceDBWise2_free_SequenceDBWise2_reverse_complement_GenomicWise2_Genomic_from_Sequence_NheuristicWise2_hard_link_GenomicWise2_free_GenomicWise2_hard_link_ComplexSequenceEvalSetWise2_free_ComplexSequenceEvalSetWise2_hard_link_ComplexSequenceWise2_free_ComplexSequenceWise2_evaluate_ComplexSequence_GenomicWise2_show_Hscore_GenomicDBWise2_get_Genomic_from_GenomicDBWise2_dataentry_add_GenomicDBWise2_init_GenomicDBWise2_reload_GenomicDBWise2_close_GenomicDBWise2_new_GenomicDB_from_single_seqWise2_new_GenomicDB_from_forrev_cseqWise2_new_GenomicDBWise2_hard_link_GenomicDBWise2_GenomicDB_allocWise2_free_GenomicDBWise2_replace_is_single_seq_GenomicDBWise2_access_rev_GenomicDBWise2_access_is_single_seq_GenomicDBWise2_replace_sdb_GenomicDBWise2_access_done_forward_GenomicDBWise2_access_sdb_GenomicDBWise2_access_forw_GenomicDBWise2_replace_current_GenomicDBWise2_replace_done_forward_GenomicDBWise2_access_current_GenomicDBWise2_replace_rev_GenomicDBWise2_replace_cses_GenomicDBWise2_replace_forw_GenomicDBWise2_access_cses_GenomicDBstrchr__assertWise2_ckcallocWise2_ckreallocWise2_log_full_errorWise2_magic_trunc_SequenceWise2_read_fasta_file_SequenceWise2_read_fasta_SequenceWise2_write_fasta_SequenceWise2_truncate_GenomicWise2_read_fasta_file_GenomicWise2_read_fasta_GenomicWise2_Genomic_nameWise2_Genomic_lengthWise2_Genomic_seqcharWise2_Genomic_from_SequenceWise2_show_GenomicWise2_hard_link_GenomicRepeatWise2_GenomicRepeat_allocWise2_free_GenomicRepeatWise2_add_GenomicWise2_flush_GenomicWise2_Genomic_alloc_stdWise2_Genomic_alloc_lenWise2_Genomic_allocWise2_access_type_GenomicRepeatWise2_access_repeat_GenomicWise2_length_repeat_GenomicWise2_replace_start_GenomicRepeatWise2_replace_type_GenomicRepeatWise2_access_start_GenomicRepeatWise2_access_baseseq_GenomicWise2_replace_end_GenomicRepeatWise2_replace_baseseq_GenomicWise2_access_end_GenomicRepeatWise2_swap_GenomicWise2_qsort_GenomicWise2_sort_GenomicWise2_expand_Genomic_iobWise2_new_Sequence_from_stringsWise2_default_genomic_ComplexSequenceEvalSetfclosesprintffgetcfgetsungetcpclosepopenmemcpystrlenstrcat__lc_ctypeWise2_strstartcmpWise2_show_lineWise2_openfileWise2_aminoacid_from_seqWise2_is_valid_base_charWise2_char_complement_baseWise2_looks_like_accessionWise2_make_len_type_SequenceWise2_best_guess_typeWise2_Sequence_type_to_stringWise2_translate_SequenceWise2_trunc_SequenceWise2_read_SRS_db_SequenceWise2_read_SRS_SequenceWise2_read_efetch_SequenceWise2_read_Sequence_EMBL_seqWise2_show_Sequence_residue_listWise2_empty_Sequence_from_dynamic_memoryWise2_Sequence_alloc_lenWise2_hard_link_SequenceWise2_Sequence_allocWise2_add_SequenceSetWise2_flush_SequenceSetWise2_SequenceSet_alloc_stdWise2_SequenceSet_alloc_lenWise2_hard_link_SequenceSetWise2_SequenceSet_allocWise2_free_SequenceSetWise2_replace_name_SequenceWise2_replace_len_SequenceWise2_access_len_SequenceWise2_replace_maxlen_SequenceWise2_access_maxlen_SequenceWise2_length_set_SequenceSetWise2_access_set_SequenceSetWise2_access_name_SequenceWise2_replace_offset_SequenceWise2_access_seq_SequenceWise2_access_offset_SequenceWise2_access_type_SequenceWise2_replace_end_SequenceWise2_replace_seq_SequenceWise2_replace_type_SequenceWise2_access_end_SequenceWise2_add_string_to_SequenceWise2_Sequence_from_static_memoryWise2_Sequence_from_dynamic_memoryWise2_swap_SequenceSetWise2_qsort_SequenceSetWise2_sort_SequenceSetWise2_expand_SequenceSetmemsetWise2_read_CodonTable_fileWise2_read_CodonTableWise2_aminoacid_from_codonWise2_aminoacid_no_from_codonWise2_is_stop_codonWise2_is_non_ambiguous_codon_seqWise2_is_valid_aminoacidWise2_codon_from_base4_codonWise2_base4_codon_from_codonWise2_has_random_basesWise2_permute_possible_random_basesWise2_all_bases_from_codonWise2_base_from_codonWise2_codon_from_seqWise2_base4_codon_from_seqWise2_char_from_baseWise2_base_from_charWise2_complement_baseWise2_hard_link_CodonTableWise2_CodonTable_allocWise2_free_CodonTableWise2_replace_name_CodonTableWise2_access_name_CodonTableWise2_alloc_aminoacid_from_seqfseekftellstrcmpWise2_touchfileWise2_infoWise2_SequenceDB_from_FILE_and_formatWise2_single_fasta_SequenceDBWise2_read_SequenceDB_lineWise2_word_to_formatWise2_hard_link_FileSourceWise2_FileSource_allocWise2_free_FileSourceWise2_add_SequenceDBWise2_flush_SequenceDBWise2_SequenceDB_alloc_stdWise2_SequenceDB_alloc_lenWise2_SequenceDB_allocWise2_access_fs_SequenceDBWise2_access_current_source_SequenceDBWise2_replace_current_source_SequenceDBWise2_replace_current_file_SequenceDBWise2_replace_sequence_no_SequenceDBWise2_access_sequence_no_SequenceDBWise2_replace_name_SequenceDBWise2_access_format_FileSourceWise2_replace_byte_position_SequenceDBWise2_length_fs_SequenceDBWise2_replace_format_FileSourceWise2_access_byte_position_SequenceDBWise2_access_current_file_SequenceDBWise2_replace_filename_FileSourceWise2_access_name_SequenceDBWise2_access_filename_FileSourceWise2_replace_type_FileSourceWise2_replace_input_FileSourceWise2_access_type_FileSourceWise2_access_input_FileSourceWise2_get_next_SequenceDBWise2_SequenceDB_at_endWise2_load_next_fs_SequenceDBWise2_close_last_fs_SequenceDBWise2_FileSource_from_FILE_and_formatWise2_FileSource_from_lineWise2_swap_SequenceDBWise2_qsort_SequenceDBWise2_sort_SequenceDBWise2_expand_SequenceDBWise2_new_ComplexSequenceWise2_show_ComplexSequenceWise2_prepare_ComplexSequenceEvalSetWise2_can_evaluate_this_SequenceWise2_hard_link_ComplexSequenceEvalWise2_ComplexSequenceEval_allocWise2_free_ComplexSequenceEvalWise2_add_ComplexSequenceEvalSetWise2_flush_ComplexSequenceEvalSetWise2_ComplexSequenceEvalSet_alloc_stdWise2_ComplexSequenceEvalSet_alloc_lenWise2_ComplexSequenceEvalSet_allocWise2_ComplexSequence_allocWise2_access_type_ComplexSequenceWise2_replace_type_ComplexSequenceEvalSetWise2_access_type_ComplexSequenceEvalSetWise2_replace_has_been_prepared_ComplexSequenceEvalSetWise2_replace_type_ComplexSequenceWise2_access_has_been_prepared_ComplexSequenceEvalSetWise2_access_seq_ComplexSequenceWise2_replace_left_window_ComplexSequenceEvalSetWise2_replace_left_lookback_ComplexSequenceEvalSetWise2_access_left_window_ComplexSequenceEvalSetWise2_access_left_lookback_ComplexSequenceEvalSetWise2_replace_right_window_ComplexSequenceEvalSetWise2_replace_seq_ComplexSequenceWise2_access_right_window_ComplexSequenceEvalSetWise2_show_one_position_ComplexSequenceWise2_can_evaluate_this_typeWise2_swap_ComplexSequenceEvalSetWise2_qsort_ComplexSequenceEvalSetWise2_sort_ComplexSequenceEvalSetWise2_expand_ComplexSequenceEvalSetWise2_flat_negiWise2_flat_zeroWise2_stupid_5SSWise2_stupid_3SSWise2_default_DNA_ComplexSequenceEvalSetWise2_default_cDNA_ComplexSequenceEvalSetWise2_codon_number_ComplexSequenceEvalWise2_base_number_ComplexSequenceEvalWise2_default_aminoacid_ComplexSequenceEvalSetWise2_aminoacid_number_ComplexSequenceEvalWise2_flat_negi_evalWise2_flat_zero_evalWise2_stupid_5SS_evalWise2_stupid_3SS_evalWise2_codon_number_funcWise2_base_number_funcWise2_aminoacid_number_func__exc_add_pc_range_table__exc_add_gp_range__exc_remove_pc_range_table__exc_remove_gp_rangevsprintffputcatoistrtodstrtolfreestrcpystrstrWise2_get_number_from_slashed_stringWise2_is_integer_stringWise2_compress_space_around_puncWise2_striptoprintWise2_stringalloc_next_quoted_stringWise2_strwhitestartcmpWise2_strwordcmpWise2_print_numbered_lineWise2_print_lineWise2_chop_newlineWise2_good_datastring_fromendWise2_estrcasecmpWise2_number_from_quoted_equalityWise2_number_from_equalityWise2_string_from_quoted_equalityWise2_string_from_charred_equalityWise2_breakstringWise2_breakstring_protectWise2_strip_quote_charsWise2_padstringWise2_capitaliseWise2_show_textWise2_second_word_allocWise2_stringallocfWise2_only_whitespaceWise2_looks_like_vmsWise2_looks_like_unixWise2_strendWise2_string_before_equalityWise2_sub_string_OtsRemainder32callocreallocfputsWise2_start_overlayWise2_stop_overlayWise2_print_overlayWise2_push_errormsg_stack_callWise2_pop_errormsg_stackWise2_add_log_filenameWise2_error_offWise2_error_onWise2_error_flag_onWise2_error_flag_offWise2_catch_errorsWise2_stop_catching_errorsWise2_push_error_callWise2_pop_error_callWise2_type_to_errorWise2_fatalWise2_start_reportingWise2_stop_reportingWise2_push_errormsg_stackWise2_show_message_stackWise2_add_log_fileWise2_show_errorremoverenamefopengetenvstrncpyWise2_set_config_dirWise2_myfcloseWise2_remove_fileWise2_move_fileWise2_envopenfileWise2_try_to_loadWise2_append_file_to_pathfflush_call_add_pc_range_table_call_add_gp_range_call_remove_pc_range_table_call_remove_gp_range_fpdata_size_gpinfo_gp_fdata_ftext_etext.xdata.pdata_edata_ebss_endetextedataend_fbssv ÿÿÿÿH¢ ÿÿÿÿÑ ÿÿÿÿøá ÿÿÿÿ7"p 9XY-@ « Û9-` « æ&L:` « ÝúAfU` « ×^} p`P ôb† ‹@ « n d¦` « -xu¦ Á` « ›¥|–°_Ü` « <@ ÷` « ;| ` « -·  2-` « ˆä,³BüH` « Àlßw>rc` « @,V°~` « :ln ·™` « E¦w¿ ´` « oë~+ËAÏ` « Z© ê` « Ju¬ ` « ­¿·/ ` « OlÆ-?J;` « …»ó‰V` « i@›q` « ©%±!Œ` « &¹;Ò §` « ß@ßÂ`(C ÿÿÿÿZ7ÝØ ÿÿÿÿ‘Þ8] ÿÿÿÿ¬1ߘR ÿÿÿÿÝ%à8@ ÿÿÿÿáøt ÿÿÿÿ"âXN ÿÿÿÿ7ã¸} ÿÿÿÿ;äØy ÿÿÿÿQ åhe ÿÿÿÿZæ¸i ÿÿÿÿ]ç                            !"#$%&'()Ðf =ÄöÿÿÿÿÿÿPh É'Döÿÿÿÿÿÿv Dðÿÿÿÿÿÿà` „õÿÿÿÿÿÿ a  „öÿÿÿÿÿÿ@„ðÿÿÿÿÿÿp>@Äóÿÿÿÿÿÿp>@Â'öÿÿÿÿÿÿpH@DóÿÿÿÿÿÿpH@7DóÿÿÿÿÿÿpH@1DóÿÿÿÿÿÿÀR@&„óÿÿÿÿÿÿàR@,Äðÿÿÿÿÿÿv •Fðÿÿàv «Fðÿÿðv »Fðÿÿðv ³Fðÿÿw ÷Fðÿÿ w &Fðÿÿ@w MFðÿÿx }FðÿÿPy žFðÿÿ z »Fðÿÿp{ ôFðÿÿà{ Fðÿÿp| -Fðÿÿ} DFðÿÿ°} UFðÿÿ~ yFðÿÿp ˜FðÿÿP€ ¹Fðÿÿ0 ÕFðÿÿ‚ öFðÿÿð‚  FðÿÿЃ 'Fðÿÿ°„ [Fðÿÿ0… uFðÿÿ … ŒFðÿÿ€† ¾Fðÿÿà† hFðÿÿ‡ „Fðÿÿ ‰ ¥FðÿÿP NFðÿÿp‘ bFðÿÿp’ ’Fðÿÿ°“ §Fðÿÿ” èFðÿÿ`” ¤FðÿÿÀ” )Fðÿÿ• ! Fðÿÿp• hFðÿÿÀ• èFðÿÿ – ÍFðÿÿp–  FðÿÿЖ MFðÿÿ — „Fðÿÿ€— ÉFðÿÿЗ  Fðÿÿ0˜ > Fðÿÿ@š $ Fðÿÿðš B Fðÿÿ€› [ Fðÿÿ› n Fðÿÿ › ƒ Fðÿÿž µ Fðÿÿ  È Fðÿÿ£ à Fðÿÿ°¤ + Fðÿÿ¨ | Fðÿÿ`¨ ? Fðÿÿ°¨ £ Fðÿÿ@© ¿ Fðÿÿ© Û Fðÿÿð©  Fðÿÿ@ª \ Fðÿÿ ª š Fðÿÿðª ý FðÿÿP« ƒ Fðÿÿ µ “Fðÿÿ`¼ ÁFðÿÿ½ ôFðÿÿ€¿ FðÿÿpÆ ,FðÿÿPÉ vFðÿÿ Ï ¼Fðÿÿ0Ð ½FðÿÿÀÐ ÓFðÿÿPÑ ëFðÿÿ0Ò #FðÿÿÓ WFðÿÿðÓ nFðÿÿPÔ 4Fðÿÿ Ô ÚFðÿÿÕ mFðÿÿPÕ ŠFðÿÿ°Õ ¥FðÿÿÖ ¿Fðÿÿ`Ö ÝFðÿÿ°Ö OFðÿÿ× ‡Fðÿÿ`× ¿FðÿÿÀ× FðÿÿØ õFðÿÿpØ ¤FðÿÿÀØ FðÿÿPÙ úFðÿÿ Ù óFðÿÿ  Û DFðÿÿ Ü ?Fðÿÿ ÀÜ ]Fðÿÿ Ý qFðÿÿ Þ ’Fðÿÿ Þ «Fðÿÿ ðÞ ÈFðÿÿ °ß åFðÿÿ `à üFðÿÿ  ã fFðÿÿ pæ ÁFðÿÿ @ç óFðÿÿ ðç  Fðÿÿ Pè 'Fðÿÿ Ðð ‘Fðÿÿ!ñ ·Fðÿÿ!pò ÕFðÿÿ!€õ Fðÿÿ!ø >Fðÿÿ!0ú bFðÿÿ!ý ŸFðÿÿ!ðý «Fðÿÿ!@þ ÆFðÿÿ!Ðþ Fðÿÿ! ÿ Fðÿÿ!€ÿ áFðÿÿ!Ðÿ 0Fðÿÿ!0 dFðÿÿ!€ VFðÿÿ!à {Fðÿÿ!0 ÜFðÿÿ! >Fðÿÿ!à ‰Fðÿÿ!@ ÈFðÿÿ! Fðÿÿ!ð CFðÿÿ!@ Fðÿÿ!  ½Fðÿÿ!ð éFðÿÿ!P &Fðÿÿ!@ †Fðÿÿ"   çFðÿÿ"°  Fðÿÿ"P kFðÿÿ"à ŽFðÿÿ"P ÇFðÿÿ"° Fðÿÿ" 9Fðÿÿ"`  Fðÿÿ"° =Fðÿÿ" gFðÿÿ"` Fðÿÿ"À êFðÿÿ" AFðÿÿ"p ¥Fðÿÿ"À Fðÿÿ"  [Fðÿÿ"p rFðÿÿ"Ð ÕFðÿÿ"À \Fðÿÿ#À žFðÿÿ#P ÇFðÿÿ#0! > Fðÿÿ# " Ì!Fðÿÿ$`# ñ!Fðÿÿ$Ð$  "Fðÿÿ$ & *"Fðÿÿ$ ' ="Fðÿÿ$à( b"Fðÿÿ$P* y"Fðÿÿ$p+ Š"Fðÿÿ$0, ¤"Fðÿÿ$ , $Fðÿÿ$0- µ"Fðÿÿ$- È"Fðÿÿ$€. 0$Fðÿÿ$À. E$Fðÿÿ$/ æ"Fðÿÿ$Ð/ [$Fðÿÿ$@0 h$Fðÿÿ$°1 ø"Fðÿÿ$p3 #Fðÿÿ$5 …$Fðÿÿ$p7 5#Fðÿÿ$Ð8 z#Fðÿÿ$À; ¦#Fðÿÿ$ð< ¾#Fðÿÿ$PA ï#Fðÿÿ$àB $Fðÿÿ$ðE 1&Fðÿÿ&G ö$Fðÿÿ& G %Fðÿÿ&ðH .%Fðÿÿ&pI E%Fðÿÿ&°I U%Fðÿÿ&°K %Fðÿÿ&ÀL  %Fðÿÿ&€O ú%Fðÿÿ& Q &Fðÿÿ&`R &Fðÿÿ&°T «&Fðÿÿ'U À&Fðÿÿ'àV Ï&Fðÿÿ'W á&Fðÿÿ'\ ñ&Fðÿÿ'à^ 6'Fðÿÿÿÿÿÿ _ b'FðÿÿÿÿÿÿP_ O'Fðÿÿÿÿÿÿ ` ~'Fðÿÿÿÿÿÿ`a â'Eðÿÿÿÿÿÿ@vðÿÿ@ðÿÿÀR@Ð'…ðÿÿÿÿÿÿÀR@ò'…óÿÿÿÿÿÿÀR@è'…ðÿÿÿÿÿÿàV@î'ÅðÿÿÿÿÿÿàV@Ý'ÅðÿÿÿÿÿÿàV@×'Åðÿÿÿÿÿÿ « Fž ñÿÿEAôÿÿ ! pAôÿÿb”'Eñÿÿ)Ph ÁEöÿÿ`s ¦†ñÿÿ`s ´'Eðÿÿ)°w fFðÿÿðz ØFðÿÿ@„ CFðÿÿ† ¦Fðÿÿ°‰ ÃFðÿÿ‹ ØFðÿÿ Ž ïFðÿÿ0 Fðÿÿ )FðÿÿБ |Fðÿÿ€˜  Fðÿÿš JFðÿÿЛ kFðÿÿ@ ™ Fðÿÿ`  æ FðÿÿР  Fðÿÿ€¡ ¹ Fðÿÿ°¡ Ì FðÿÿP£ ó Fðÿÿ ¤  Fðÿÿ@¥ ? Fðÿÿp¥ W Fðÿÿ ¦ ’Fðÿÿ€¦ o Fðÿÿ§ ªFðÿÿ­  Fðÿÿà­ 'Fðÿÿ ¯ BFðÿÿ° _Fðÿÿб uFðÿÿ`² FðÿÿP³  Fðÿÿµ <FðÿÿÀ· WFðÿÿ0¹ ž Fðÿÿ°º ¬FðÿÿÀ¼ ÜFðÿÿо ¹ Fðÿÿ€Â Ø Fðÿÿ0Ç +Fðÿÿ€È MFðÿÿàÉ HFðÿÿ@Ê jFðÿÿ Ë ò FðÿÿÐË Fðÿÿ0Ì ¨FðÿÿÀÌ yFðÿÿÍ FðÿÿÀÍ ¤Fðÿÿ`Ï ÓFðÿÿ€Ñ FðÿÿÒ ?FðÿÿPÚ Fðÿÿ Ü Ú FðÿÿpÜ $Fðÿÿ PÞ ó Fðÿÿá  Fðÿÿ ðá ;Fðÿÿ àâ QFðÿÿ €ä Fðÿÿ àä –Fðÿÿ °å  Fðÿÿæ «Fðÿÿ Ðæ ÜFðÿÿ  è Fðÿÿ@ê °FðÿÿÐê ÔFðÿÿPë ëFðÿÿ°ë Fðÿÿàí aFðÿÿ!€î {Fðÿÿ!àî “Fðÿÿ!ð ±Fðÿÿ!@ñ ÐFðÿÿ!ô ðFðÿÿ!@ô öFðÿÿ!àõ  Fðÿÿ!Pö 7Fðÿÿ!÷ Fðÿÿ!0÷ 'Fðÿÿ!Ðø TFðÿÿ! ù MFðÿÿ!Àú yFðÿÿ!ðú ”Fðÿÿ! û Fðÿÿü ¯Fðÿÿ!ü 4Fðÿÿ  lFðÿÿ"à ŒFðÿÿ"   ¡Fðÿÿ"  ÆFðÿÿ"@  ´Fðÿÿ"   Fðÿÿ"  +Fðÿÿ"  ÑFðÿÿ"P  óFðÿÿ"ð  8Fðÿÿ"À JFðÿÿ" µFðÿÿ"À ½Fðÿÿ  ÜFðÿÿ"° äFðÿÿ  Fðÿÿ ÿFðÿÿ"€ &Fðÿÿ  AFðÿÿp - Fðÿÿ ˜ Fðÿÿ#  lFðÿÿ#p ­ Fðÿÿ#€ |Fðÿÿ#à  Fðÿÿ#  Fðÿÿ#€ Ø Fðÿÿ#  ñFðÿÿ#`  î Fðÿÿ#   Fðÿÿ#ð  !Fðÿÿ#À! m Fðÿÿ# " !Fðÿÿ# $ àFðÿÿð* © Fðÿÿ 7 W#Fðÿÿ$9 Œ#Fðÿÿ$ > Î#Fðÿÿ$à> » FðÿÿÐ? ß#Fðÿÿ$pC ÏFðÿÿPD áFðÿÿ°D j FðÿÿðD y Fðÿÿ€E ïFðÿÿH K&Fðÿÿ&ÐH d&Fðÿÿ&ðI d%Fðÿÿ&ÐJ x%Fðÿÿ&€M »%Fðÿÿ& M Ñ%Fðÿÿ&ÀM æ%Fðÿÿ& N †Fðÿÿ!ÐN üFðÿÿ`P ‰ Fðÿÿ R w&Fðÿÿ&pU 'Fðÿÿ'@W 'Fðÿÿ'@X vFðÿÿ!ÐX Ë FðÿÿP] »$Fðÿÿ&p] Ï$Fðÿÿ&À] â$Fðÿÿ&à` Žõÿÿ`a »'Eðÿÿ)@­'…ðÿÿ)@H@¡'öÿÿ)ÀR@OóÿÿÈR@VóÿÿÐR@]óÿÿØR@cóÿÿàÊ@©'Eñÿÿ)o†ñÿÿ!i†ñÿÿ!c†ñÿÿ!e!†ñÿÿÿÿÿÿɆñÿÿцñÿÿ؆ñÿÿ܆ñÿÿR!†ñÿÿÿÿÿÿ–$†ñÿÿ$¦$†ñÿÿ%ˆ&†ñÿÿ'&†ñÿÿ'–&†ñÿÿ'œ&†ñÿÿ'£&†ñÿÿ'­$†ñÿÿ%9!†ñÿÿÿÿÿÿµ$†ñÿÿ&a †ñÿÿZ †ñÿÿÅ!†ñÿÿ$¾!†ñÿÿ$/'†ñÿÿ(¹!†ñÿÿ$²!†ñÿÿ$«!†ñÿÿ$— †ñÿÿ †ñÿÿ¦!†ñÿÿ$ !†ñÿÿ$—!†ñÿÿ$‰ †ñÿÿ!†ñÿÿÿÿÿÿì†ñÿÿ ƒ †ñÿÿ| †ñÿÿu †ñÿÿo †ñÿÿi †ñÿÿa †ñÿÿZ †ñÿÿ‡ %$'"(êE°p6ð0Hˆ€à.xdata.dynsym.got.data .text Ø à jh `"$â $" â(""üädä¼UÄ|mp䈩K©¬è©Kð©¬HªK\ª¬èªKøª¬Ô¬K䬬d­Kp­¬”®K ®¬àÃÄ@ÌÄ`s !`s "HH@D@à` !`s "PH@D@¨R@¸wise-2.4.1/src/dynlibsrc/genomicdb.dy0000644000175000001440000002414507611245645017136 0ustar philippusers %{ #include "sequencedb.h" #include "genomic.h" #include "hscore.h" #include "complexsequence.h" #include "complexevalset.h" typedef enum GenDBErrorType { GENDB_READ_THROUGH = 0, GENDB_FAIL_ON_ERROR = 1 } GenDBErrorType; %} struct GenomicDB boolean is_single_seq !def="FALSE" boolean done_forward !def="FALSE" ComplexSequence * forw ComplexSequence * rev SequenceDB * sdb Genomic * current ComplexSequenceEvalSet * cses GenDBErrorType error_handling !def="GENDB_READ_THROUGH" !hidden Genomic * single // for single sequence cases, so we can 'index' on it Genomic * revsingle int length_of_N !def="10" int repeat_in_cds_score !def="-1000000" %info This object hold a database of genomic sequences. You will probably use it in one of two ways 1 A sequence formatted database, which is provided by a /SequenceDB object is used to provide the raw sequences 2 A single Genomic sequence is used. In each case this database provides both the forward and reverse strands into the system. Notice that what is exported are /ComplexSequence objects, not genomic dna, as this is what is generally needed. These are things with splice sites calculated etc. This is why for initialisation this needs a /ComplexSequenceEvalSet of the correct type. %% api object GenomicDB des free_GenomicDB func get_Genomic_from_GenomicDB endobject func new_GenomicDB_from_single_seq func new_GenomicDB endapi %{ #include "genomicdb.h" %func shows the Hscore by the GenomicDB information %arg hs High Score structure ofp output file %% void show_Hscore_GenomicDB(Hscore * hs,FILE * ofp) { int i; for(i=0;ilen;i++) fprintf(ofp,"Query [%20s] Target [%20s] %d\n",hs->ds[i]->query->name,hs->ds[i]->target->name,hs->ds[i]->score); } %func Gets Genomic sequence out from the GenomicDB using the information stored in dataentry %% Genomic * get_Genomic_from_GenomicDB(GenomicDB * gendb,DataEntry * de) { Sequence * seq; Sequence * temp; /* we need to get out the Sequence from seqdb */ if( gendb == NULL || de == NULL ) { warn("Cannot get a genomic sequence from NULL objects. Ugh!"); return NULL; } if( gendb->is_single_seq) { if( de->is_reversed == TRUE ) return hard_link_Genomic(gendb->revsingle); else return hard_link_Genomic(gendb->single); } seq = get_Sequence_from_SequenceDB(gendb->sdb,de); if( seq == NULL ) { warn("Cannot get entry for %s from Genomic db",de->name); } /* check dna status. We assumme someone knows what he is doing when he makes a genomic db!*/ if( seq->type != SEQUENCE_DNA) { warn("Sequence from %s data entry doesn't look like DNA. Forcing it to",de->name); } force_to_dna_Sequence(seq,1.0,NULL); if( de->is_reversed == TRUE ) { temp = reverse_complement_Sequence(seq); free_Sequence(seq); seq = temp; } return Genomic_from_Sequence_Nheuristic(seq,gendb->length_of_N); } %func adds information to dataentry from GenomicDB will eventually add file offset and format information %% boolean dataentry_add_GenomicDB(DataEntry * de,ComplexSequence * cs,GenomicDB * gendb) { de->name = stringalloc(cs->seq->name); de->is_reversed = is_reversed_Sequence(cs->seq); if( gendb->is_single_seq ) { return TRUE; } add_SequenceDB_info_DataEntry(gendb->sdb,de); return TRUE; } %func top level function which opens the Genomic database %arg gendb protein database return_status w the status of the open from database.h %% ComplexSequence * init_GenomicDB(GenomicDB * gendb,int * return_status) { ComplexSequence * cs; Sequence * seq; if( gendb->is_single_seq == TRUE) { *return_status = DB_RETURN_OK; gendb->done_forward = TRUE; return hard_link_ComplexSequence(gendb->forw); } /* is a seq db */ seq = init_SequenceDB(gendb->sdb,return_status); if( seq == NULL || *return_status == DB_RETURN_ERROR || *return_status == DB_RETURN_END ) { warn("On initiation of the genomicdb, immedaitely got an end scenario"); return NULL; } /* check dna status. We assumme someone knows what he is doing when he makes a genomic db!*/ if( seq->type != SEQUENCE_DNA) { warn("Sequence from %s data entry doesn't look like DNA. Forcing it to",seq->name); } force_to_dna_Sequence(seq,1.0,NULL); /* map to Genomic on length of N buiness */ gendb->current = Genomic_from_Sequence_Nheuristic(seq,gendb->length_of_N); gendb->done_forward = TRUE; cs = evaluate_ComplexSequence_Genomic(gendb->current,gendb->cses,0,gendb->repeat_in_cds_score); if( cs == NULL ) { warn("Cannot make initial ComplexSequence. Unable to error catch this. Failing!"); *return_status = DB_RETURN_ERROR; return NULL; } return cs; } %func function which reloads the database %arg last previous complex sequence, will be freed return_status w return_status of the load %% ComplexSequence * reload_GenomicDB(ComplexSequence * last,GenomicDB * gendb,int * return_status) { ComplexSequence * cs; Sequence * seq; Genomic *temp; Genomic * gen; /** NB - notice that we don't do silly things with free's. Maybe we should **/ if( gendb->is_single_seq == TRUE ) { if( gendb->done_forward == TRUE ) { *return_status = DB_RETURN_OK; gendb->done_forward = FALSE; return hard_link_ComplexSequence(gendb->rev); } else { *return_status = DB_RETURN_END; return NULL; } } /** standard database **/ /** free Complex Sequence **/ if ( last != NULL ) { free_ComplexSequence(last); } if( gendb->done_forward == TRUE ) { if( gendb->current == NULL ) { warn("A bad internal genomic db error - unable to find current sequence in db reload"); *return_status = DB_RETURN_ERROR; return NULL; } temp = reverse_complement_Genomic(gendb->current); if( temp == NULL ) { warn("A bad internal genomic db error - unable to reverse complements current"); *return_status = DB_RETURN_ERROR; return NULL; } cs = evaluate_ComplexSequence_Genomic(temp,gendb->cses,0,gendb->repeat_in_cds_score); if( cs == NULL ) { warn("A bad internal genomic db error - unable to make complex sequence in db reload"); *return_status = DB_RETURN_ERROR; return NULL; } free_Genomic(temp); gendb->done_forward = FALSE; return cs; } /* otherwise we have to get a new sequence */ seq = reload_SequenceDB(NULL,gendb->sdb,return_status); if( seq == NULL || *return_status == DB_RETURN_ERROR || *return_status == DB_RETURN_END ) { return NULL; /** error already reported **/ } uppercase_Sequence(seq); /* check dna status. We assumme someone knows what he is doing when he makes a genomic db!*/ if( seq->type != SEQUENCE_DNA) { warn("Sequence from %s data entry doesn't look like DNA. Forcing it to",seq->name); } force_to_dna_Sequence(seq,1.0,NULL); if( force_to_dna_Sequence(seq,0.1,NULL) == FALSE ) { if( gendb->error_handling == GENDB_READ_THROUGH ) { warn("Unable to map %s sequence to a genomic sequence, but ignoring that for the moment...",seq->name); free_Sequence(seq); return reload_GenomicDB(NULL,gendb,return_status); } else { warn("Unable to map %s sequence to a genomic sequence. Failing",seq->name); *return_status = DB_RETURN_ERROR; return NULL; } } gen = Genomic_from_Sequence_Nheuristic(seq,gendb->length_of_N); cs = evaluate_ComplexSequence_Genomic(gen,gendb->cses,0,gendb->repeat_in_cds_score); if( cs == NULL ) { if( gendb->error_handling == GENDB_READ_THROUGH ) { warn("Unable to map %s sequence to a genomic sequence, but ignoring that for the moment...",seq->name); free_Sequence(seq); return reload_GenomicDB(NULL,gendb,return_status); } else { warn("Unable to map %s sequence to a genomic sequence. Failing",seq->name); *return_status = DB_RETURN_ERROR; return NULL; } } gendb->current = free_Genomic(gendb->current); gendb->current = gen; gendb->done_forward= TRUE; return cs; } %func top level function which closes the genomic database %arg cs last complex sequence gendb protein database %% boolean close_GenomicDB(ComplexSequence * cs,GenomicDB * gendb) { if( gendb->is_single_seq == TRUE ) { return TRUE; } if( cs != NULL) free_ComplexSequence(cs); if( gendb->current != NULL) gendb->current = free_Genomic(gendb->current); return close_SequenceDB(NULL,gendb->sdb); } %func To make a new genomic database from a single Genomic Sequence with a eval system %arg gen sequence which as placed into GenomicDB structure. %% GenomicDB * new_GenomicDB_from_single_seq(Genomic * gen,ComplexSequenceEvalSet * cses,int score_in_repeat_coding) { ComplexSequence * cs,*cs_rev; GenomicDB * out; Genomic * temp; cs = evaluate_ComplexSequence_Genomic(gen,cses,0,score_in_repeat_coding); temp = reverse_complement_Genomic(gen); cs_rev = evaluate_ComplexSequence_Genomic(temp,cses,0,score_in_repeat_coding); out = new_GenomicDB_from_forrev_cseq(cs,cs_rev); out->single = hard_link_Genomic(gen); out->revsingle = temp; return out; } %func To make a new genomic database from a single ComplexSequence %arg cs complex sequence which is held. %% GenomicDB * new_GenomicDB_from_forrev_cseq(ComplexSequence * cs,ComplexSequence * cs_rev) { GenomicDB * out; out = GenomicDB_alloc(); out->is_single_seq = TRUE; out->forw = cs; out->rev = cs_rev; return out; } %func To make a new genomic database %arg seqdb sequence database cses protein evaluation set %% GenomicDB * new_GenomicDB(SequenceDB * seqdb,ComplexSequenceEvalSet * cses,int length_of_N,int repeat_in_cds_score) { GenomicDB * out; if( seqdb == NULL || cses == NULL ) { warn("Attempting to make GenomicDB from some NULL objects."); return NULL; } /** should check sequence database **/ if( cses->type != SEQUENCE_GENOMIC ) { warn("You can't make a genomic database with a non SEQUENCE_GENOMIC cses type [%d]",cses->type); return NULL; } out = GenomicDB_alloc(); out->is_single_seq = FALSE; out->sdb = hard_link_SequenceDB(seqdb); out->cses = hard_link_ComplexSequenceEvalSet(cses); out->length_of_N = length_of_N; out->repeat_in_cds_score = repeat_in_cds_score; return out; } %} wise-2.4.1/src/dynlibsrc/genomicdb.xs0000644000175000001440000000751510670453712017151 0ustar philippusers MODULE = Wise2 PACKAGE = Wise2::GenomicDB Wise2_Genomic * get_Genomic_from_GenomicDB(gendb,de) Wise2_GenomicDB * gendb Wise2_DataEntry * de CODE: RETVAL = Wise2_get_Genomic_from_GenomicDB(gendb,de); OUTPUT: RETVAL Wise2_GenomicDB * hard_link_GenomicDB(obj) Wise2_GenomicDB * obj CODE: RETVAL = Wise2_hard_link_GenomicDB(obj); OUTPUT: RETVAL Wise2_GenomicDB * alloc() CODE: RETVAL = Wise2_GenomicDB_alloc(); OUTPUT: RETVAL boolean set_is_single_seq(obj,is_single_seq) Wise2_GenomicDB * obj boolean is_single_seq CODE: RETVAL = Wise2_replace_is_single_seq_GenomicDB(obj,is_single_seq); OUTPUT: RETVAL boolean is_single_seq(obj) Wise2_GenomicDB * obj CODE: RETVAL = Wise2_access_is_single_seq_GenomicDB(obj); OUTPUT: RETVAL boolean set_done_forward(obj,done_forward) Wise2_GenomicDB * obj boolean done_forward CODE: RETVAL = Wise2_replace_done_forward_GenomicDB(obj,done_forward); OUTPUT: RETVAL boolean done_forward(obj) Wise2_GenomicDB * obj CODE: RETVAL = Wise2_access_done_forward_GenomicDB(obj); OUTPUT: RETVAL boolean set_forw(obj,forw) Wise2_GenomicDB * obj Wise2_ComplexSequence * forw CODE: RETVAL = Wise2_replace_forw_GenomicDB(obj,Wise2_hard_link_ComplexSequence(forw)); OUTPUT: RETVAL Wise2_ComplexSequence * forw(obj) Wise2_GenomicDB * obj INIT: Wise2_ComplexSequence * temp; CODE: temp = Wise2_hard_link_ComplexSequence(Wise2_access_forw_GenomicDB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_rev(obj,rev) Wise2_GenomicDB * obj Wise2_ComplexSequence * rev CODE: RETVAL = Wise2_replace_rev_GenomicDB(obj,Wise2_hard_link_ComplexSequence(rev)); OUTPUT: RETVAL Wise2_ComplexSequence * rev(obj) Wise2_GenomicDB * obj INIT: Wise2_ComplexSequence * temp; CODE: temp = Wise2_hard_link_ComplexSequence(Wise2_access_rev_GenomicDB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_sdb(obj,sdb) Wise2_GenomicDB * obj Wise2_SequenceDB * sdb CODE: RETVAL = Wise2_replace_sdb_GenomicDB(obj,Wise2_hard_link_SequenceDB(sdb)); OUTPUT: RETVAL Wise2_SequenceDB * sdb(obj) Wise2_GenomicDB * obj INIT: Wise2_SequenceDB * temp; CODE: temp = Wise2_hard_link_SequenceDB(Wise2_access_sdb_GenomicDB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_current(obj,current) Wise2_GenomicDB * obj Wise2_Genomic * current CODE: RETVAL = Wise2_replace_current_GenomicDB(obj,Wise2_hard_link_Genomic(current)); OUTPUT: RETVAL Wise2_Genomic * current(obj) Wise2_GenomicDB * obj INIT: Wise2_Genomic * temp; CODE: temp = Wise2_hard_link_Genomic(Wise2_access_current_GenomicDB(obj)); RETVAL = temp; OUTPUT: RETVAL boolean set_cses(obj,cses) Wise2_GenomicDB * obj Wise2_ComplexSequenceEvalSet * cses CODE: RETVAL = Wise2_replace_cses_GenomicDB(obj,Wise2_hard_link_ComplexSequenceEvalSet(cses)); OUTPUT: RETVAL Wise2_ComplexSequenceEvalSet * cses(obj) Wise2_GenomicDB * obj INIT: Wise2_ComplexSequenceEvalSet * temp; CODE: temp = Wise2_hard_link_ComplexSequenceEvalSet(Wise2_access_cses_GenomicDB(obj)); RETVAL = temp; OUTPUT: RETVAL Wise2_GenomicDB * new(class) char * class PPCODE: Wise2_GenomicDB * out; out = Wise2_GenomicDB_alloc(); ST(0) = sv_newmortal(); sv_setref_pv(ST(0),class,(void*)out); XSRETURN(1); void DESTROY(obj) Wise2_GenomicDB * obj CODE: Wise2_free_GenomicDB(obj); MODULE = Wise2 PACKAGE = Wise2 Wise2_GenomicDB * new_GenomicDB_from_single_seq(gen,cses,score_in_repeat_coding) Wise2_Genomic * gen Wise2_ComplexSequenceEvalSet * cses int score_in_repeat_coding CODE: RETVAL = Wise2_new_GenomicDB_from_single_seq(gen,cses,score_in_repeat_coding); OUTPUT: RETVAL Wise2_GenomicDB * new_GenomicDB(seqdb,cses,length_of_N,repeat_in_cds_score) Wise2_SequenceDB * seqdb Wise2_ComplexSequenceEvalSet * cses int length_of_N int repeat_in_cds_score CODE: RETVAL = Wise2_new_GenomicDB(seqdb,cses,length_of_N,repeat_in_cds_score); OUTPUT: RETVAL wise-2.4.1/src/dynlibsrc/codonmapper.typemap0000644000175000001440000000037410670453712020552 0ustar philippusers TYPEMAP Wise2_CodonMapper * T_Wise2_CodonMapper INPUT T_Wise2_CodonMapper $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_CodonMapper *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_CodonMapper sv_setref_pv($arg, "Wise2::CodonMapper", (void*) $var); wise-2.4.1/src/dynlibsrc/transcript.pod0000644000175000001440000002474310670453713017546 0ustar philippusers=head1 NAME transcript module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item Exon =item Transcript =back =head1 DESCRIPTION =head2 Object Exon =over =item start Type [int] Scalar No documentation =item end Type [int] Scalar No documentation =item used Type [boolean] Scalar used by some prediction programs etc =item score Type [double] Scalar No documentation =item sf Type [SupportingFeature **] List No documentation =item phase Type [int] Scalar No documentation =back No documentation for Exon =head2 Member functions of Exon =over =item hard_link_Exon &Wise2::Exon::hard_link_Exon(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [Exon *] Return [UNKN ] Undocumented return value [Exon *] =item Exon_alloc_std &Wise2::Exon::Exon_alloc_std(void) Equivalent to Exon_alloc_len(ExonLISTLENGTH) Return [UNKN ] Undocumented return value [Exon *] =item set_start &Wise2::Exon::set_start(obj,start) Replace member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [Exon *] Argument start [OWNER] New value of the variable [int] Return [SOFT ] member variable start [boolean] =item start &Wise2::Exon::start(obj) Access member variable start For use principly by API functions Argument obj [UNKN ] Object holding the variable [Exon *] Return [SOFT ] member variable start [int] =item set_end &Wise2::Exon::set_end(obj,end) Replace member variable end For use principly by API functions Argument obj [UNKN ] Object holding the variable [Exon *] Argument end [OWNER] New value of the variable [int] Return [SOFT ] member variable end [boolean] =item end &Wise2::Exon::end(obj) Access member variable end For use principly by API functions Argument obj [UNKN ] Object holding the variable [Exon *] Return [SOFT ] member variable end [int] =item set_used &Wise2::Exon::set_used(obj,used) Replace member variable used For use principly by API functions Argument obj [UNKN ] Object holding the variable [Exon *] Argument used [OWNER] New value of the variable [boolean] Return [SOFT ] member variable used [boolean] =item used &Wise2::Exon::used(obj) Access member variable used For use principly by API functions Argument obj [UNKN ] Object holding the variable [Exon *] Return [SOFT ] member variable used [boolean] =item set_score &Wise2::Exon::set_score(obj,score) Replace member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [Exon *] Argument score [OWNER] New value of the variable [double] Return [SOFT ] member variable score [boolean] =item score &Wise2::Exon::score(obj) Access member variable score For use principly by API functions Argument obj [UNKN ] Object holding the variable [Exon *] Return [SOFT ] member variable score [double] =item sf &Wise2::Exon::sf(obj,i) Access members stored in the sf list For use principly by API functions Argument obj [UNKN ] Object holding the list [Exon *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [SupportingFeature *] =item length_sf &Wise2::Exon::length_sf(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [Exon *] Return [UNKN ] length of the list [int] =item flush_sf &Wise2::Exon::flush_sf(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [Exon *] Return [UNKN ] Undocumented return value [int] =item add_sf &Wise2::Exon::add_sf(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [Exon *] Argument add [OWNER] Object to add to the list [SupportingFeature *] Return [UNKN ] Undocumented return value [boolean] =item set_phase &Wise2::Exon::set_phase(obj,phase) Replace member variable phase For use principly by API functions Argument obj [UNKN ] Object holding the variable [Exon *] Argument phase [OWNER] New value of the variable [int] Return [SOFT ] member variable phase [boolean] =item phase &Wise2::Exon::phase(obj) Access member variable phase For use principly by API functions Argument obj [UNKN ] Object holding the variable [Exon *] Return [SOFT ] member variable phase [int] =back =head2 Object Transcript =over =item exon Type [Exon **] List No documentation =item parent Type [Gene *] Scalar No documentation =item translation Type [Translation **] List No documentation =item cDNA Type [cDNA *] Scalar may not be here! =back Transcript represents a single spliced product from a gene. The transcript is considered to be a series of exons and it contains, in addition a series of translations. Most genes will only have one translation. Like gene before it, transcript does not necessarily contain DNA. When some DNA is asked from it, via get_cDNA_from_Transcript (notice the change from Genomic typed sequence in Gene to cDNA typed sequence in Transcript) it first checkes the 'cache'. If it is not there, it asks for its parents genomic DNA, and then assemblies the cDNA using the exon coordinates. The exon coordinates are such that 0 means the start of the gene, not the start of the genomic region. (makes some outputs a pain). Supporting Features are added to exons, and, keeping in the spirit of this module, are relative to the exon start. The strand is inherieted from the exon =head2 Member functions of Transcript =over =item get_cDNA_from_Transcript &Wise2::Transcript::get_cDNA_from_Transcript(trs) gets the cDNA associated with this transcript, if necessary, building it from the exon information provided. returns a soft-linked object. If you want to ensure that this cDNA object remains in memory use /hard_link_cDNA on the object. Argument trs [READ ] transcript to get cDNA from [Transcript *] Return [SOFT ] cDNA of the transcript [cDNA *] =item hard_link_Transcript &Wise2::Transcript::hard_link_Transcript(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [Transcript *] Return [UNKN ] Undocumented return value [Transcript *] =item Transcript_alloc_std &Wise2::Transcript::Transcript_alloc_std(void) Equivalent to Transcript_alloc_len(TranscriptLISTLENGTH) Return [UNKN ] Undocumented return value [Transcript *] =item exon &Wise2::Transcript::exon(obj,i) Access members stored in the exon list For use principly by API functions Argument obj [UNKN ] Object holding the list [Transcript *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [Exon *] =item length_exon &Wise2::Transcript::length_exon(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [Transcript *] Return [UNKN ] length of the list [int] =item flush_exon &Wise2::Transcript::flush_exon(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [Transcript *] Return [UNKN ] Undocumented return value [int] =item add_exon &Wise2::Transcript::add_exon(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [Transcript *] Argument add [OWNER] Object to add to the list [Exon *] Return [UNKN ] Undocumented return value [boolean] =item set_parent &Wise2::Transcript::set_parent(obj,parent) Replace member variable parent For use principly by API functions Argument obj [UNKN ] Object holding the variable [Transcript *] Argument parent [OWNER] New value of the variable [Gene *] Return [SOFT ] member variable parent [boolean] =item parent &Wise2::Transcript::parent(obj) Access member variable parent For use principly by API functions Argument obj [UNKN ] Object holding the variable [Transcript *] Return [SOFT ] member variable parent [Gene *] =item translation &Wise2::Transcript::translation(obj,i) Access members stored in the translation list For use principly by API functions Argument obj [UNKN ] Object holding the list [Transcript *] Argument i [UNKN ] Position in the list [int] Return [SOFT ] Element of the list [Translation *] =item length_translation &Wise2::Transcript::length_translation(obj) discover the length of the list For use principly by API functions Argument obj [UNKN ] Object holding the list [Transcript *] Return [UNKN ] length of the list [int] =item flush_translation &Wise2::Transcript::flush_translation(obj) Frees the list elements, sets length to 0 If you want to save some elements, use hard_link_xxx to protect them from being actually destroyed in the free Argument obj [UNKN ] Object which contains the list [Transcript *] Return [UNKN ] Undocumented return value [int] =item add_translation &Wise2::Transcript::add_translation(obj,add) Adds another object to the list. It will expand the list if necessary Argument obj [UNKN ] Object which contains the list [Transcript *] Argument add [OWNER] Object to add to the list [Translation *] Return [UNKN ] Undocumented return value [boolean] =item set_cDNA &Wise2::Transcript::set_cDNA(obj,cDNA) Replace member variable cDNA For use principly by API functions Argument obj [UNKN ] Object holding the variable [Transcript *] Argument cDNA [OWNER] New value of the variable [cDNA *] Return [SOFT ] member variable cDNA [boolean] =item cDNA &Wise2::Transcript::cDNA(obj) Access member variable cDNA For use principly by API functions Argument obj [UNKN ] Object holding the variable [Transcript *] Return [SOFT ] member variable cDNA [cDNA *] =back wise-2.4.1/src/dynlibsrc/transcript.tex0000644000175000001440000000534310670453713017557 0ustar philippusers\section{transcript} \label{module_transcript} This module contains the following objects \begin{itemize} \item \ref{object_Exon} Exon \item \ref{object_Transcript} Transcript \end{itemize} \subsection{Object Exon} \label{object_Exon} The Exon object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{start} Type [int : Scalar] No documentation \item{end} Type [int : Scalar] No documentation \item{used} Type [boolean : Scalar] used by some prediction programs etc \item{score} Type [double : Scalar] No documentation \item{sf} Type [SupportingFeature ** : List] No documentation \item{phase} Type [int : Scalar] No documentation \end{description} No documentation for Exon Member functions of Exon \subsection{Object Transcript} \label{object_Transcript} The Transcript object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{exon} Type [Exon ** : List] No documentation \item{parent} Type [Gene * : Scalar] No documentation \item{translation} Type [Translation ** : List] No documentation \item{cDNA} Type [cDNA * : Scalar] may not be here! \end{description} Transcript represents a single spliced product from a gene. The transcript is considered to be a series of exons and it contains, in addition a series of translations. Most genes will only have one translation. Like gene before it, transcript does not necessarily contain DNA. When some DNA is asked from it, via get_cDNA_from_Transcript (notice the change from Genomic typed sequence in Gene to cDNA typed sequence in Transcript) it first checkes the 'cache'. If it is not there, it asks for its parents genomic DNA, and then assemblies the cDNA using the exon coordinates. The exon coordinates are such that 0 means the start of the gene, not the start of the genomic region. (makes some outputs a pain). Supporting Features are added to exons, and, keeping in the spirit of this module, are relative to the exon start. The strand is inherieted from the exon Member functions of Transcript \subsubsection{get_cDNA_from_Transcript} \begin{description} \item[External C] {\tt Wise2_get_cDNA_from_Transcript (trs)} \item[Perl] {\tt &Wise2::Transcript::get_cDNA_from_Transcript (trs)} \item[Perl-OOP call] {\tt $obj->get_cDNA_from_Transcript()} \end{description} Arguments \begin{description} \item[trs] [READ ] transcript to get cDNA from [Transcript *] \item[returns] [SOFT ] cDNA of the transcript [cDNA *] \end{description} gets the cDNA associated with this transcript, if necessary, building it from the exon information provided. returns a soft-linked object. If you want to ensure that this cDNA object remains in memory use /hard_link_cDNA on the object. wise-2.4.1/src/dynlibsrc/proteindb_api.h0000644000175000001440000002127610670453712017636 0ustar philippusers /* Functions that create, manipulate or act on ProteinDB * * Wise2_hard_link_ProteinDB * Wise2_ProteinDB_alloc * Wise2_replace_is_single_seq_ProteinDB * Wise2_access_is_single_seq_ProteinDB * Wise2_replace_is_random_db_ProteinDB * Wise2_access_is_random_db_ProteinDB * Wise2_replace_single_ProteinDB * Wise2_access_single_ProteinDB * Wise2_replace_sdb_ProteinDB * Wise2_access_sdb_ProteinDB * Wise2_replace_cses_ProteinDB * Wise2_access_cses_ProteinDB * Wise2_replace_rnd_ProteinDB * Wise2_access_rnd_ProteinDB * Wise2_replace_test_dna_ProteinDB * Wise2_access_test_dna_ProteinDB * Wise2_free_ProteinDB [destructor] * */ /* Helper functions in the module * * Wise2_new_ProteinDB_from_single_seq * Wise2_single_fasta_ProteinDB * Wise2_new_ProteinDB * /* API for object ProteinDB */ /* Function: Wise2_hard_link_ProteinDB(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_ProteinDB *] * * Returns Undocumented return value [Wise2_ProteinDB *] * */ Wise2_ProteinDB * Wise2_hard_link_ProteinDB( Wise2_ProteinDB * obj); /* Function: Wise2_ProteinDB_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_ProteinDB *] * */ Wise2_ProteinDB * Wise2_ProteinDB_alloc(); /* Function: Wise2_replace_is_single_seq_ProteinDB(obj,is_single_seq) * * Descrip: Replace member variable is_single_seq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * Arg: is_single_seq New value of the variable [boolean] * * Returns member variable is_single_seq [boolean] * */ boolean Wise2_replace_is_single_seq_ProteinDB( Wise2_ProteinDB * obj,boolean is_single_seq); /* Function: Wise2_access_is_single_seq_ProteinDB(obj) * * Descrip: Access member variable is_single_seq * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * * Returns member variable is_single_seq [boolean] * */ boolean Wise2_access_is_single_seq_ProteinDB( Wise2_ProteinDB * obj); /* Function: Wise2_replace_is_random_db_ProteinDB(obj,is_random_db) * * Descrip: Replace member variable is_random_db * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * Arg: is_random_db New value of the variable [boolean] * * Returns member variable is_random_db [boolean] * */ boolean Wise2_replace_is_random_db_ProteinDB( Wise2_ProteinDB * obj,boolean is_random_db); /* Function: Wise2_access_is_random_db_ProteinDB(obj) * * Descrip: Access member variable is_random_db * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * * Returns member variable is_random_db [boolean] * */ boolean Wise2_access_is_random_db_ProteinDB( Wise2_ProteinDB * obj); /* Function: Wise2_replace_single_ProteinDB(obj,single) * * Descrip: Replace member variable single * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * Arg: single New value of the variable [Wise2_ComplexSequence *] * * Returns member variable single [boolean] * */ boolean Wise2_replace_single_ProteinDB( Wise2_ProteinDB * obj,Wise2_ComplexSequence * single); /* Function: Wise2_access_single_ProteinDB(obj) * * Descrip: Access member variable single * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * * Returns member variable single [Wise2_ComplexSequence *] * */ Wise2_ComplexSequence * Wise2_access_single_ProteinDB( Wise2_ProteinDB * obj); /* Function: Wise2_replace_sdb_ProteinDB(obj,sdb) * * Descrip: Replace member variable sdb * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * Arg: sdb New value of the variable [Wise2_SequenceDB *] * * Returns member variable sdb [boolean] * */ boolean Wise2_replace_sdb_ProteinDB( Wise2_ProteinDB * obj,Wise2_SequenceDB * sdb); /* Function: Wise2_access_sdb_ProteinDB(obj) * * Descrip: Access member variable sdb * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * * Returns member variable sdb [Wise2_SequenceDB *] * */ Wise2_SequenceDB * Wise2_access_sdb_ProteinDB( Wise2_ProteinDB * obj); /* Function: Wise2_replace_cses_ProteinDB(obj,cses) * * Descrip: Replace member variable cses * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * Arg: cses New value of the variable [Wise2_ComplexSequenceEvalSet *] * * Returns member variable cses [boolean] * */ boolean Wise2_replace_cses_ProteinDB( Wise2_ProteinDB * obj,Wise2_ComplexSequenceEvalSet * cses); /* Function: Wise2_access_cses_ProteinDB(obj) * * Descrip: Access member variable cses * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * * Returns member variable cses [Wise2_ComplexSequenceEvalSet *] * */ Wise2_ComplexSequenceEvalSet * Wise2_access_cses_ProteinDB( Wise2_ProteinDB * obj); /* Function: Wise2_replace_rnd_ProteinDB(obj,rnd) * * Descrip: Replace member variable rnd * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * Arg: rnd New value of the variable [Wise2_RandomProteinDB *] * * Returns member variable rnd [boolean] * */ boolean Wise2_replace_rnd_ProteinDB( Wise2_ProteinDB * obj,Wise2_RandomProteinDB * rnd); /* Function: Wise2_access_rnd_ProteinDB(obj) * * Descrip: Access member variable rnd * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * * Returns member variable rnd [Wise2_RandomProteinDB *] * */ Wise2_RandomProteinDB * Wise2_access_rnd_ProteinDB( Wise2_ProteinDB * obj); /* Function: Wise2_replace_test_dna_ProteinDB(obj,test_dna) * * Descrip: Replace member variable test_dna * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * Arg: test_dna New value of the variable [boolean] * * Returns member variable test_dna [boolean] * */ boolean Wise2_replace_test_dna_ProteinDB( Wise2_ProteinDB * obj,boolean test_dna); /* Function: Wise2_access_test_dna_ProteinDB(obj) * * Descrip: Access member variable test_dna * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_ProteinDB *] * * Returns member variable test_dna [boolean] * */ boolean Wise2_access_test_dna_ProteinDB( Wise2_ProteinDB * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_ProteinDB(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_ProteinDB *] * * Returns Undocumented return value [Wise2_ProteinDB *] * */ Wise2_ProteinDB * Wise2_free_ProteinDB( Wise2_ProteinDB * obj); /* These functions are not associated with an object */ /* Function: Wise2_new_ProteinDB_from_single_seq(seq) * * Descrip: To make a new protein database * from a single Sequence with default amino acid mapping * * * Arg: seq sequence which as placed into ProteinDB structure. [Wise2_Sequence *] * * Returns Undocumented return value [Wise2_ProteinDB *] * */ Wise2_ProteinDB * Wise2_new_ProteinDB_from_single_seq( Wise2_Sequence * seq); /* Function: Wise2_single_fasta_ProteinDB(filename) * * Descrip: pre-packed single fasta protein database * * * * Arg: filename name of fasta file [char *] * * Returns Undocumented return value [Wise2_ProteinDB *] * */ Wise2_ProteinDB * Wise2_single_fasta_ProteinDB( char * filename); /* Function: Wise2_new_ProteinDB(seqdb,cses) * * Descrip: To make a new protein database * * * Arg: seqdb sequence database [Wise2_SequenceDB *] * Arg: cses protein evaluation set [Wise2_ComplexSequenceEvalSet *] * * Returns Undocumented return value [Wise2_ProteinDB *] * */ Wise2_ProteinDB * Wise2_new_ProteinDB( Wise2_SequenceDB * seqdb,Wise2_ComplexSequenceEvalSet * cses); wise-2.4.1/src/dynlibsrc/proteindb_api.t0000644000175000001440000000006110670453712017637 0ustar philippuserstypedef struct Wise2_ProteinDB Wise2_ProteinDB; wise-2.4.1/src/dynlibsrc/testpdb.c0000644000175000001440000000102707313404542016444 0ustar philippusers#include "proteindb.h" int main(int argc,char ** argv) { ProteinDB * db; ComplexSequence * seq; int i; int status; for(i=0;i<1;i++) { db = single_fasta_ProteinDB(argv[1]); for(seq = init_ProteinDB(db,&status);status != DB_RETURN_END;seq = reload_ProteinDB(seq,db,&status) ) fprintf(stdout,"Reload %d, Sequence %s\n",i,seq->seq->name); close_ProteinDB(seq,db); fprintf(stdout,"Closed %d\n",i); free_ProteinDB(db); /*display_allocated_memory("-->",stdout);*/ } return 0; } wise-2.4.1/src/dynlibsrc/hscore_api.h0000644000175000001440000002772610670453712017141 0ustar philippusers /* Functions that create, manipulate or act on Hscore * * Wise2_minimum_score_Hscore * Wise2_maximum_score_Hscore * Wise2_sort_Hscore_by_score * Wise2_length_datascore_Hscore * Wise2_get_datascore_Hscore * Wise2_get_score_Hscore * Wise2_get_evalue_Hscore * Wise2_basic_show_Hscore * Wise2_hard_link_Hscore * Wise2_Hscore_alloc_std * Wise2_free_Hscore [destructor] * */ /* Functions that create, manipulate or act on DataScore * * Wise2_hard_link_DataScore * Wise2_DataScore_alloc * Wise2_replace_query_DataScore * Wise2_access_query_DataScore * Wise2_replace_target_DataScore * Wise2_access_target_DataScore * Wise2_replace_score_DataScore * Wise2_access_score_DataScore * Wise2_replace_evalue_DataScore * Wise2_access_evalue_DataScore * Wise2_free_DataScore [destructor] * */ /* Functions that create, manipulate or act on DataEntry * * Wise2_hard_link_DataEntry * Wise2_DataEntry_alloc * Wise2_replace_name_DataEntry * Wise2_access_name_DataEntry * Wise2_replace_is_reversed_DataEntry * Wise2_access_is_reversed_DataEntry * Wise2_free_DataEntry [destructor] * */ /* Helper functions in the module * * Wise2_std_score_Hscore * /* API for object Hscore */ /* Function: Wise2_minimum_score_Hscore(hs) * * Descrip: gets the minimum score from Hscore * * * Arg: hs Undocumented argument [Wise2_Hscore *] * * Returns Undocumented return value [int] * */ int Wise2_minimum_score_Hscore( Wise2_Hscore * hs); /* Function: Wise2_maximum_score_Hscore(hs) * * Descrip: gets the maximum score from Hscore * * * Arg: hs Undocumented argument [Wise2_Hscore *] * * Returns Undocumented return value [int] * */ int Wise2_maximum_score_Hscore( Wise2_Hscore * hs); /* Function: Wise2_sort_Hscore_by_score(hs) * * Descrip: As it says, sorts the high score by its score * * * Arg: hs Hscore to be sorted [Wise2_Hscore *] * * Returns Undocumented return value [void] * */ void Wise2_sort_Hscore_by_score( Wise2_Hscore * hs); /* Function: Wise2_length_datascore_Hscore(obj) * * Descrip: Returns the number of datascores in the hscore * structure * * * Arg: obj Hscore object [Wise2_Hscore *] * * Returns Undocumented return value [int] * */ int Wise2_length_datascore_Hscore( Wise2_Hscore * obj); /* Function: Wise2_get_datascore_Hscore(hs,i) * * Descrip: Returns the specific datascore held at this * position. * * This requires a considerable amount of memory * duplication, so please dont process all your * results by looping through this. * * * Arg: hs Hscore object [Wise2_Hscore *] * Arg: i position to be read [int] * * Returns New datascore object [Wise2_DataScore *] * */ Wise2_DataScore * Wise2_get_datascore_Hscore( Wise2_Hscore * hs,int i); /* Function: Wise2_get_score_Hscore(hs,i) * * Descrip: No Description * * Arg: hs Hscore object [Wise2_Hscore *] * Arg: i position to be read [int] * * Returns score [int] * */ int Wise2_get_score_Hscore( Wise2_Hscore * hs,int i); /* Function: Wise2_get_evalue_Hscore(hs,i) * * Descrip: Returns the evalue of the specific datascore held at this position. * * * * Arg: hs Hscore object [Wise2_Hscore *] * Arg: i position to be read [int] * * Returns evalue [double] * */ double Wise2_get_evalue_Hscore( Wise2_Hscore * hs,int i); /* Function: Wise2_basic_show_Hscore(hs,ofp) * * Descrip: The most baby-talk showing of Hscore * * * Arg: hs Undocumented argument [Wise2_Hscore *] * Arg: ofp Undocumented argument [FILE *] * * Returns Undocumented return value [void] * */ void Wise2_basic_show_Hscore( Wise2_Hscore * hs,FILE * ofp); /* Function: Wise2_hard_link_Hscore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_Hscore *] * * Returns Undocumented return value [Wise2_Hscore *] * */ Wise2_Hscore * Wise2_hard_link_Hscore( Wise2_Hscore * obj); /* Function: Wise2_Hscore_alloc_std(void) * * Descrip: Equivalent to Hscore_alloc_len(HscoreLISTLENGTH) * * * * Returns Undocumented return value [Wise2_Hscore *] * */ Wise2_Hscore * Wise2_Hscore_alloc_std(); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_Hscore(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_Hscore *] * * Returns Undocumented return value [Wise2_Hscore *] * */ Wise2_Hscore * Wise2_free_Hscore( Wise2_Hscore * obj); /* API for object DataScore */ /* Function: Wise2_hard_link_DataScore(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_DataScore *] * * Returns Undocumented return value [Wise2_DataScore *] * */ Wise2_DataScore * Wise2_hard_link_DataScore( Wise2_DataScore * obj); /* Function: Wise2_DataScore_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_DataScore *] * */ Wise2_DataScore * Wise2_DataScore_alloc(); /* Function: Wise2_replace_query_DataScore(obj,query) * * Descrip: Replace member variable query * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DataScore *] * Arg: query New value of the variable [Wise2_DataEntry *] * * Returns member variable query [boolean] * */ boolean Wise2_replace_query_DataScore( Wise2_DataScore * obj,Wise2_DataEntry * query); /* Function: Wise2_access_query_DataScore(obj) * * Descrip: Access member variable query * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DataScore *] * * Returns member variable query [Wise2_DataEntry *] * */ Wise2_DataEntry * Wise2_access_query_DataScore( Wise2_DataScore * obj); /* Function: Wise2_replace_target_DataScore(obj,target) * * Descrip: Replace member variable target * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DataScore *] * Arg: target New value of the variable [Wise2_DataEntry *] * * Returns member variable target [boolean] * */ boolean Wise2_replace_target_DataScore( Wise2_DataScore * obj,Wise2_DataEntry * target); /* Function: Wise2_access_target_DataScore(obj) * * Descrip: Access member variable target * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DataScore *] * * Returns member variable target [Wise2_DataEntry *] * */ Wise2_DataEntry * Wise2_access_target_DataScore( Wise2_DataScore * obj); /* Function: Wise2_replace_score_DataScore(obj,score) * * Descrip: Replace member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DataScore *] * Arg: score New value of the variable [int] * * Returns member variable score [boolean] * */ boolean Wise2_replace_score_DataScore( Wise2_DataScore * obj,int score); /* Function: Wise2_access_score_DataScore(obj) * * Descrip: Access member variable score * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DataScore *] * * Returns member variable score [int] * */ int Wise2_access_score_DataScore( Wise2_DataScore * obj); /* Function: Wise2_replace_evalue_DataScore(obj,evalue) * * Descrip: Replace member variable evalue * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DataScore *] * Arg: evalue New value of the variable [double] * * Returns member variable evalue [boolean] * */ boolean Wise2_replace_evalue_DataScore( Wise2_DataScore * obj,double evalue); /* Function: Wise2_access_evalue_DataScore(obj) * * Descrip: Access member variable evalue * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DataScore *] * * Returns member variable evalue [double] * */ double Wise2_access_evalue_DataScore( Wise2_DataScore * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_DataScore(obj) * * Descrip: Correctly handles destruction of a datascore * * * Arg: obj Undocumented argument [Wise2_DataScore *] * * Returns Undocumented return value [Wise2_DataScore *] * */ Wise2_DataScore * Wise2_free_DataScore( Wise2_DataScore * obj); /* API for object DataEntry */ /* Function: Wise2_hard_link_DataEntry(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_DataEntry *] * * Returns Undocumented return value [Wise2_DataEntry *] * */ Wise2_DataEntry * Wise2_hard_link_DataEntry( Wise2_DataEntry * obj); /* Function: Wise2_DataEntry_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_DataEntry *] * */ Wise2_DataEntry * Wise2_DataEntry_alloc(); /* Function: Wise2_replace_name_DataEntry(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DataEntry *] * Arg: name New value of the variable [char *] * * Returns member variable name [boolean] * */ boolean Wise2_replace_name_DataEntry( Wise2_DataEntry * obj,char * name); /* Function: Wise2_access_name_DataEntry(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DataEntry *] * * Returns member variable name [char *] * */ char * Wise2_access_name_DataEntry( Wise2_DataEntry * obj); /* Function: Wise2_replace_is_reversed_DataEntry(obj,is_reversed) * * Descrip: Replace member variable is_reversed * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DataEntry *] * Arg: is_reversed New value of the variable [boolean] * * Returns member variable is_reversed [boolean] * */ boolean Wise2_replace_is_reversed_DataEntry( Wise2_DataEntry * obj,boolean is_reversed); /* Function: Wise2_access_is_reversed_DataEntry(obj) * * Descrip: Access member variable is_reversed * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_DataEntry *] * * Returns member variable is_reversed [boolean] * */ boolean Wise2_access_is_reversed_DataEntry( Wise2_DataEntry * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_DataEntry(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_DataEntry *] * * Returns Undocumented return value [Wise2_DataEntry *] * */ Wise2_DataEntry * Wise2_free_DataEntry( Wise2_DataEntry * obj); /* These functions are not associated with an object */ /* Function: Wise2_std_score_Hscore(cut_off,report_stagger) * * Descrip: This gives you a standard Hscore * module with a cutoff in score * * * Arg: cut_off Undocumented argument [int] * Arg: report_stagger Undocumented argument [int] * * Returns Undocumented return value [Wise2_Hscore *] * */ Wise2_Hscore * Wise2_std_score_Hscore( int cut_off,int report_stagger); wise-2.4.1/src/dynlibsrc/hscore_api.t0000644000175000001440000000021510670453712017135 0ustar philippuserstypedef struct Wise2_Hscore Wise2_Hscore; typedef struct Wise2_DataScore Wise2_DataScore; typedef struct Wise2_DataEntry Wise2_DataEntry; wise-2.4.1/src/dynlibsrc/pairbase.dy0000644000175000001440000003105207467001131016755 0ustar philippusers %{ #include "codon.h" #include "probability.h" #include "codonmatrix.h" #include typedef char pairbase_type; typedef int pairbase_codon_type; #define BASE_GAP 5 #define BASE_OPEN 6 #define IS_NOT_BASE(a) (a == BASE_GAP ? 1 : a == BASE_OPEN ? 1 : 0) #define MAKE_PAIRBASE(anchor,informant) (anchor*7+informant) #define PAIRBASE_LENGTH (7*7) #define PAIRBASE_CODON_LENGTH (PAIRBASE_LENGTH*PAIRBASE_LENGTH*PAIRBASE_LENGTH) %} struct PairBaseModel Probability base[PAIRBASE_LENGTH] struct PairBaseCodonModel Probability codon[PAIRBASE_CODON_LENGTH] struct PairBaseModelScore Score base[PAIRBASE_LENGTH] struct PairBaseCodonModelScore Score codon[PAIRBASE_CODON_LENGTH] %{ #include "pairbase.h" %func Tweaks a PairBaseCodonModel with on and off diagonal ratios %% void diagonal_tweak_PairBaseCodonModel(PairBaseCodonModel * m,double ratio_on,double ratio_off_positive,double ratio_off_negative) { int a,b,c,x,y,z; int p; int codon_a; int codon_b; pairbase_type seq[3]; for(a=0;a<5;a++) { for(b=0;b<5;b++) { for(c=0;c<5;c++) { for(x=0;x<5;x++) { for(y=0;y<5;y++) { for(z=0;z<5;z++) { /* build the sequence */ seq[0] = MAKE_PAIRBASE(a,x); seq[1] = MAKE_PAIRBASE(b,y); seq[2] = MAKE_PAIRBASE(c,z); p = pairbase_codon_from_seq(seq); if( a == x && b == y && c == z ) { if( a == 4 && b == 4 && c== 4 ) { m->codon[p] *= 0.5; } else { m->codon[p] *= ratio_on; } } else if ( m->codon[p] > 1.0 ) { /* fprintf(stderr,"For %d %d,%d,%d vs %d,%d,%d\n",p,a,b,c,x,y,z); */ m->codon[p] *= ratio_off_positive; } else { m->codon[p] *= ratio_off_negative; } } } } } } } } %func flattens out the diagonal signal %% void flatten_diagonal_PairBaseCodonModel(PairBaseCodonModel * m,CodonTable * ct) { int a,b,c; pairbase_type seq[3]; int codon_a; int p; for(a=0;a<5;a++) { for(b=0;b<5;b++) { for(c=0;c<5;c++) { if( a < 4 && b < 4 && c < 4 ) { codon_a = (25 * a) + (5 * b) + c; if( is_stop_codon(codon_a,ct) ) { m->codon[p] = 0.0; continue; } } /* build the sequence */ seq[0] = MAKE_PAIRBASE(a,a); seq[1] = MAKE_PAIRBASE(b,b); seq[2] = MAKE_PAIRBASE(c,c); p = pairbase_codon_from_seq(seq); if( a == 4 && b == 4 && c== 4 ) { m->codon[p] = 0.5; } else { m->codon[p] = 1.0; } } } } } %func flattens out the diagonal signal - for scores! %% void flatten_diagonal_PairBaseCodonModelScore(PairBaseCodonModelScore * m,CodonTable * ct) { int a,b,c; pairbase_type seq[3]; int codon_a; int p; for(a=0;a<5;a++) { for(b=0;b<5;b++) { for(c=0;c<5;c++) { if( a < 4 && b < 4 && c < 4 ) { codon_a = (25 * a) + (5 * b) + c; if( is_stop_codon(codon_a,ct) ) { m->codon[p] = NEGI; continue; } } /* build the sequence */ seq[0] = MAKE_PAIRBASE(a,a); seq[1] = MAKE_PAIRBASE(b,b); seq[2] = MAKE_PAIRBASE(c,c); p = pairbase_codon_from_seq(seq); if( a == 4 && b == 4 && c== 4 ) { m->codon[p] = -2; } else { m->codon[p] = 0; } } } } } %func a 0 pairbasemodel score %% PairBaseModelScore * zero_PairBaseModelScore(void) { PairBaseModelScore * out; int i; out = PairBaseModelScore_alloc(); for(i=0;ibase[i] = 0; } return out; } %func Makes a PairBaseCodonModel from just a one parameter! Wow! %% PairBaseCodonModel * very_simple_PairBaseCodonModel(Probability id,Probability rnd,Probability nonm,Probability gap,CodonTable * ct) { CompProb * p; PairBaseCodonModel * out; p = simple_aa_CompProb(id,id,rnd); out = make_flat_PairBaseCodonModel(p,nonm,gap,ct); free_CompProb(p); return out; } %func Makes a PairBaseCodonModel from a protein matrix - assumming a flat mapping to CodonMatrix %% PairBaseCodonModel * make_flat_PairBaseCodonModel(CompProb * cp,Probability nonm,Probability gap,CodonTable * ct) { CodonMatrix * cm; PairBaseCodonModel * out; cm = naive_CodonMatrix(ct,cp); out = make_PairBaseCodonModel(cm,nonm,gap,ct); free_CodonMatrix(cm); return out; } %func Makes a PairBaseCodonModel score for start codon %% PairBaseCodonModelScore * make_start_PairBaseCodonModelScore(CodonTable * ct) { PairBaseCodonModel * model; PairBaseCodonModelScore * out; model = make_conserved_PairBaseCodonModel(100.0,0.000000000001,'M',ct); out = new_PairBaseCodonModelScore(model); free_PairBaseCodonModel(model); return out; } %func Makes a PairBaseCodonModel score for start codon %% PairBaseCodonModelScore * make_stop_PairBaseCodonModelScore(CodonTable * ct) { PairBaseCodonModel * model; PairBaseCodonModelScore * out; model = make_conserved_PairBaseCodonModel(100.0,0.000000000001,'X',ct); out = new_PairBaseCodonModelScore(model); free_PairBaseCodonModel(model); return out; } %func Makes a PairBaseCodonModel for a particular character in the CodonTable %% PairBaseCodonModel * make_conserved_PairBaseCodonModel(Probability cons,Probability non_cons,char aa_var,CodonTable * ct) { PairBaseCodonModel * out; int i; base base_a,base_b,base_c; pairbase_type seq[3]; int p; assert(ct); out = PairBaseCodonModel_alloc(); for(i=0;icodon[i] = non_cons; } for(i=0;i<125;i++) { if( ct->codon_str[i] == aa_var ) { fprintf(stderr,"Assinging %d with %c\n",i,aa_var); all_bases_from_codon(i,&base_a,&base_b,&base_c); seq[0] = MAKE_PAIRBASE(base_a,base_a); seq[1] = MAKE_PAIRBASE(base_b,base_b); seq[2] = MAKE_PAIRBASE(base_c,base_c); p = pairbase_codon_from_seq(seq); out->codon[p] = cons; } } return out; } %func Makes a PairBaseCodonModel from a CodonMatrix and parameters %% PairBaseCodonModel * make_PairBaseCodonModel(CodonMatrix * codon_matrix,Probability nonm,Probability gap,CodonTable * ct) { PairBaseCodonModel * out; int a,b,c,x,y,z; int i; int codon_a; int codon_b; int p; pairbase_type seq[3]; assert(codon_matrix); assert(ct); out = PairBaseCodonModel_alloc(); for(i=0;icodon[i] = 0.0; } for(a=0;a<5;a++) { for(b=0;b<5;b++) { for(c=0;c<5;c++) { for(x=0;x<5;x++) { for(y=0;y<5;y++) { for(z=0;z<5;z++) { /* build the sequence */ seq[0] = MAKE_PAIRBASE(a,x); seq[1] = MAKE_PAIRBASE(b,y); seq[2] = MAKE_PAIRBASE(c,z); p = pairbase_codon_from_seq(seq); codon_a = (a * 25) + (b * 5) + c; codon_b = (x * 25) + (y * 5) + z; if( is_stop_codon(codon_a,ct) || is_stop_codon(codon_b,ct) ) { out->codon[p] = 0.0; continue; } /* else */ out->codon[p] = codon_matrix->prob[codon_a][codon_b]; } } } } } } /* now to do blank and gap scores */ for(a=0;a<5;a++) { for(b=0;b<5;b++) { for(c=0;c<5;c++) { codon_a = (a * 25) + (b * 5) + c; seq[0] = MAKE_PAIRBASE(a,BASE_GAP); seq[1] = MAKE_PAIRBASE(b,BASE_GAP); seq[2] = MAKE_PAIRBASE(c,BASE_GAP); p = pairbase_codon_from_seq(seq); if( is_stop_codon(codon_a,ct) ) { out->codon[p] = 0.0; } else { out->codon[p] = gap; } seq[0] = MAKE_PAIRBASE(BASE_GAP,a); seq[1] = MAKE_PAIRBASE(BASE_GAP,b); seq[2] = MAKE_PAIRBASE(BASE_GAP,c); p = pairbase_codon_from_seq(seq); if( is_stop_codon(codon_a,ct) ) { out->codon[p] = 0.0; } else { out->codon[p] = gap; } seq[0] = MAKE_PAIRBASE(a,BASE_OPEN); seq[1] = MAKE_PAIRBASE(b,BASE_OPEN); seq[2] = MAKE_PAIRBASE(c,BASE_OPEN); p = pairbase_codon_from_seq(seq); if( is_stop_codon(codon_a,ct) ) { out->codon[p] = 0.0; } else { out->codon[p] = nonm; } seq[0] = MAKE_PAIRBASE(BASE_OPEN,a); seq[1] = MAKE_PAIRBASE(BASE_OPEN,b); seq[2] = MAKE_PAIRBASE(BASE_OPEN,c); p = pairbase_codon_from_seq(seq); if( is_stop_codon(codon_a,ct) ) { out->codon[p] = 0.0; } else { out->codon[p] = nonm; } } } } return out; } %func Makes a pair base model from simple leading diagonal %% PairBaseModel * simple_PairBaseModel(Probability iden,Probability other,Probability gap) { PairBaseModel * out; int i; int j; int base; out = PairBaseModel_alloc(); for(i=0;i<7;i++) { for(j=0;j<7;j++) { base = (i*7)+j; if( i == 5 || j == 5 ) { out->base[base]= gap/0.25; } else if( i == 6 || j == 6 ) { out->base[base]= 0.0; } else if( i == 4 || j == 4 ) { out->base[base]= 1.0; } else if( i == j ) { out->base[base]= iden / 0.25; } else { out->base[base]= other / 0.25; } } } return out; } %func Makes a codon score from a codon model %% PairBaseCodonModelScore * new_PairBaseCodonModelScore(PairBaseCodonModel * pbcm) { PairBaseCodonModelScore * out; out = PairBaseCodonModelScore_alloc(); Probability2Score_move(pbcm->codon,out->codon,PAIRBASE_CODON_LENGTH); return out; } %func Makes a base score from a base model %% PairBaseModelScore * new_PairBaseModelScore(PairBaseModel * pbm) { PairBaseModelScore * out; out = PairBaseModelScore_alloc(); Probability2Score_move(pbm->base,out->base,PAIRBASE_LENGTH); return out; } %func Debugging %% void show_PairBaseModelScore(PairBaseModelScore * sc,FILE * ofp) { int i; int anchor; int informant; for(i=0;ibase[i]); } } %func Debugging %% void show_PairBaseCodonModelScore(PairBaseCodonModelScore * sc,CodonTable * ct,FILE * ofp) { int i; pairbase_type a; pairbase_type b; pairbase_type c; int anchor_a; int anchor_b; int anchor_c; int informant_a; int informant_b; int informant_c; char seq1[4]; char seq2[4]; seq1[3] = seq2[3] = '\0'; for(i=0;icodon[i]); } } %func Inverts pairbase codon %% pairbase_codon_type reverse_pairbase_codon(pairbase_codon_type codon) { pairbase_type a; pairbase_type b; pairbase_type c; decompose_pairbase_codon(codon,&a,&b,&c); a = complement_pairbase(a); b = complement_pairbase(b); c = complement_pairbase(c); return (c*(PAIRBASE_LENGTH*PAIRBASE_LENGTH))+(b*PAIRBASE_LENGTH)+a; } %func complements a pairbase %% pairbase_type complement_pairbase(pairbase_type b) { pairbase_type anchor; pairbase_type informant; anchor = anchor_base_from_pairbase(b); informant = informant_base_from_pairbase(b); /* we reverse completement anchor */ anchor = complement_base(anchor); if( informant != BASE_GAP && informant != BASE_OPEN ) { informant = complement_base(informant); } return MAKE_PAIRBASE(anchor,informant); } %func Makes a pairbase_codon from a pairbase_sequence %% pairbase_codon_type pairbase_codon_from_seq(pairbase_type * seq) { pairbase_type one; pairbase_type two; pairbase_type three; one = (*seq); two = (*(seq+1)); three = (*(seq+2)); return (one*(PAIRBASE_LENGTH*PAIRBASE_LENGTH))+(two*PAIRBASE_LENGTH)+three; } %func Decomposes a pairbase codon %% void decompose_pairbase_codon(pairbase_codon_type t,pairbase_type * a,pairbase_type * b,pairbase_type * c) { assert(a); assert(b); assert(c); *a = t/(PAIRBASE_LENGTH*PAIRBASE_LENGTH); t -= (*a) * (PAIRBASE_LENGTH*PAIRBASE_LENGTH); *b = t/PAIRBASE_LENGTH; t -= (*b) * PAIRBASE_LENGTH; *c = t; } %func Finds the anchor base from a pair base %% base anchor_base_from_pairbase(pairbase_type pairbase) { int top; top = (int)pairbase / 7; return top; } %func Finds the informant base from a pair base %% base informant_base_from_pairbase(pairbase_type pairbase) { int top; top = (int) pairbase /7; pairbase -= top*7; return pairbase; } %func gives back the character for the base %% char char_for_base(int base) { if( base < 5 ) { return char_from_base(base); } if( base == BASE_GAP ) { return '-'; } else { return ' '; } } wise-2.4.1/src/dynlibsrc/codon_api.h0000644000175000001440000002325710670453712016753 0ustar philippusers /* Functions that create, manipulate or act on CodonTable * * Wise2_read_CodonTable_file * Wise2_read_CodonTable * Wise2_aminoacid_from_seq * Wise2_aminoacid_from_codon * Wise2_is_stop_codon * Wise2_is_valid_aminoacid * Wise2_hard_link_CodonTable * Wise2_CodonTable_alloc * Wise2_replace_name_CodonTable * Wise2_access_name_CodonTable * Wise2_free_CodonTable [destructor] * */ /* Helper functions in the module * * Wise2_is_non_ambiguous_codon_seq * Wise2_codon_from_base4_codon * Wise2_base4_codon_from_codon * Wise2_has_random_bases * Wise2_permute_possible_random_bases * Wise2_base_from_codon * Wise2_codon_from_seq * Wise2_base4_codon_from_seq * Wise2_char_from_base * Wise2_base_from_char * Wise2_char_complement_base * Wise2_complement_base * /* API for object CodonTable */ /* Function: Wise2_read_CodonTable_file(file) * * Descrip: Opens filename, reads it as if a Ewan style * codon table and closes. * * * Arg: file filename to open [char *] * * Returns A codon-table, NULL if error [Wise2_CodonTable *] * */ Wise2_CodonTable * Wise2_read_CodonTable_file( char * file); /* Function: Wise2_read_CodonTable(ifp) * * Descrip: reads a codon table from a filestream in Ewan * format. * * As Ewan format is really bad and has no start/stop * this will effectively read to the end of the file. * Ooops. * * * Arg: ifp file input [FILE *] * * Returns Undocumented return value [Wise2_CodonTable *] * */ Wise2_CodonTable * Wise2_read_CodonTable( FILE * ifp); /* Function: Wise2_aminoacid_from_seq(ct,seq) * * Descrip: Returns the amino acid for this position in the DNA sequence * Takes the pointer +1 and +2 points. * * No error checks implemented. Probably a mistake ;) * * * Arg: ct codon table [Wise2_CodonTable *] * Arg: seq pointer to DNA chars [char *] * * Returns an amino acid char (A-Z) [aa] * */ aa Wise2_aminoacid_from_seq( Wise2_CodonTable * ct,char * seq); /* Function: Wise2_aminoacid_from_codon(ct,c) * * Descrip: returns amino acid for this codon number (NB codon numbers 0-125) * * * Arg: ct codon table [Wise2_CodonTable *] * Arg: c codon number [codon] * * Returns aminoacid that is this codon (X for ambiguous, * for stop) [aa] * */ aa Wise2_aminoacid_from_codon( Wise2_CodonTable * ct,codon c); /* Function: Wise2_is_stop_codon(c,ct) * * Descrip: tells you whether this codon number is really a stop * in this translation table * * * Arg: c codon number [codon] * Arg: ct codon table [Wise2_CodonTable *] * * Returns TRUE if is stop, FALSE otherwise [boolean] * */ boolean Wise2_is_stop_codon( codon c,Wise2_CodonTable * ct); /* Function: Wise2_is_valid_aminoacid(ct,c) * * Descrip: Tells you if this letter (c) is recognised as a valid amino acid * in this codon table * * * Arg: ct Codon Table [Wise2_CodonTable *] * Arg: c aminoacid [char] * * Returns TRUE if valid, FALSE if not. [boolean] * */ boolean Wise2_is_valid_aminoacid( Wise2_CodonTable * ct,char c); /* Function: Wise2_hard_link_CodonTable(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj Object to be hard linked [Wise2_CodonTable *] * * Returns Undocumented return value [Wise2_CodonTable *] * */ Wise2_CodonTable * Wise2_hard_link_CodonTable( Wise2_CodonTable * obj); /* Function: Wise2_CodonTable_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Returns Undocumented return value [Wise2_CodonTable *] * */ Wise2_CodonTable * Wise2_CodonTable_alloc(); /* Function: Wise2_replace_name_CodonTable(obj,name) * * Descrip: Replace member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_CodonTable *] * Arg: name New value of the variable [char *] * * Returns member variable name [boolean] * */ boolean Wise2_replace_name_CodonTable( Wise2_CodonTable * obj,char * name); /* Function: Wise2_access_name_CodonTable(obj) * * Descrip: Access member variable name * For use principly by API functions * * * Arg: obj Object holding the variable [Wise2_CodonTable *] * * Returns member variable name [char *] * */ char * Wise2_access_name_CodonTable( Wise2_CodonTable * obj); /* This is the destructor function, ie, call this to free object*/ /* Function: Wise2_free_CodonTable(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj Object that is free'd [Wise2_CodonTable *] * * Returns Undocumented return value [Wise2_CodonTable *] * */ Wise2_CodonTable * Wise2_free_CodonTable( Wise2_CodonTable * obj); /* These functions are not associated with an object */ /* Function: Wise2_is_non_ambiguous_codon_seq(seq) * * Descrip: Tells you if this codon is a real codon * * * Arg: seq pointer to DNA sequence [char *] * * Returns TRUE if real codon, FALSE if contains N's [boolean] * */ boolean Wise2_is_non_ambiguous_codon_seq( char * seq); /* Function: Wise2_codon_from_base4_codon(c) * * Descrip: maps a 0-63 codon to a 0-123 codon. Suprisingly useful. * * * Arg: c Undocumented argument [int] * * Returns Undocumented return value [codon] * */ codon Wise2_codon_from_base4_codon( int c); /* Function: Wise2_base4_codon_from_codon(c) * * Descrip: maps a 0-125 codon to a 0-63 codon. * * If ambiguous then returns 64 having issued a warning. * * * Arg: c codon 0-125 [codon] * * Returns base 4 codon (0-63) [int] * */ int Wise2_base4_codon_from_codon( codon c); /* Function: Wise2_has_random_bases(c) * * Descrip: Tests to see if this codon number has any N's in it * * * Arg: c codon number 0-124 [codon] * * Returns TRUE if has N's , FALSE otherwise [boolean] * */ boolean Wise2_has_random_bases( codon c); /* Function: Wise2_permute_possible_random_bases(c,one,two,three) * * Descrip: Bizarely useful function for calculating ambiguity scores. * * This takes the codon c, and for each possible base, * if it is N, replaces it with one, two or three. * * If the base is not N, it remains the same * * * Arg: c codon number [codon] * Arg: one base to replace first position if N [base] * Arg: two base to replace second position if N [base] * Arg: three base to replace third position if N [base] * * Returns codon number [codon] * */ codon Wise2_permute_possible_random_bases( codon c,base one,base two,base three); /* Function: Wise2_base_from_codon(c,pos) * * Descrip: Probably not the best function to use for this, but * useful. Takes a codon and with pos being 1,2,3 gives * you the firt,second of third base * * * Arg: c Undocumented argument [codon] * Arg: pos Undocumented argument [int] * * Returns Undocumented return value [base] * */ base Wise2_base_from_codon( codon c,int pos); /* Function: Wise2_codon_from_seq(seq) * * Descrip: takes an ASCII coded pointer to a 3 base pair * sequence (it could be the part of a sequence: it only * assummes that the seq points with 3 chars at pos 0,1,2 * in C coordinates from seq. No NULL is required). It * ives back the codon as made from standard mapping, ie, * 25*base_1+5*base_2 + base3 being a number from 0-124 inc. * * * Arg: seq pointer to sequence of at least 3 chrs long. [char *] * * Returns Undocumented return value [codon] * */ codon Wise2_codon_from_seq( char * seq); /* Function: Wise2_base4_codon_from_seq(seq) * * Descrip: Sometimes it is more useful to work in base64, ie, * non N. this functions does the same thing as * /codon_from_seq but produces a seq being * 16*base1 + 4 *base2 + base3 * * * Arg: seq pointer to sequence of at least 3 chrs long [char *] * * Returns Undocumented return value [int] * */ int Wise2_base4_codon_from_seq( char * seq); /* Function: Wise2_char_from_base(b) * * Descrip: maps a base number (-04 inc) to A,T,G,C,N * * * Arg: b Undocumented argument [base] * * Returns Undocumented return value [char] * */ char Wise2_char_from_base( base b); /* Function: Wise2_base_from_char(c) * * Descrip: maps a char (atcgn) to number, * case insensitive, returns BASE_N * if not atcgn * * * Arg: c Undocumented argument [char] * * Returns Undocumented return value [base] * */ base Wise2_base_from_char( char c); /* Function: Wise2_char_complement_base(c) * * Descrip: the char equivalent of /complement_base. * this gives the complement in char of a base * in char. Does not check for non ATGCN * * * Arg: c Undocumented argument [char] * * Returns Undocumented return value [char] * */ char Wise2_char_complement_base( char c); /* Function: Wise2_complement_base(b) * * Descrip: gives back the complement as a number * ofthe base (given as a number) * * * Arg: b Undocumented argument [base] * * Returns Undocumented return value [base] * */ base Wise2_complement_base( base b); wise-2.4.1/src/dynlibsrc/codon_api.t0000644000175000001440000000006310670453712016755 0ustar philippuserstypedef struct Wise2_CodonTable Wise2_CodonTable; wise-2.4.1/src/dynlibsrc/dnamatrix.c0000644000175000001440000002441510670453712016777 0ustar philippusers#ifdef _cplusplus extern "C" { #endif #include "dnamatrix.h" /* Function: new_CompMat_from_DnaMatrix_flat(dm) * * Descrip: Builds a CompMat mapping of a DnaMatrix * * * Arg: dm [UNKN ] Undocumented argument [DnaMatrix *] * * Return [UNKN ] Undocumented return value [CompMat *] * */ # line 44 "dnamatrix.dy" CompMat * new_CompMat_from_DnaMatrix_flat(DnaMatrix * dm) { int i,j; CompMat * mat; mat = CompMat_alloc(); for(i=0;i<26;i++) { for(j=0;j<26;j++) { mat->comp[i][j] = NEGI; } } for(i=0;i<5;i++) { for(j=0;j<5;j++) { mat->comp[char_from_base(i)-'A'][char_from_base(j)-'A'] = dm->score[i][j]; } } return mat; } /* Function: DnaProbMatrix_from_match(match,nmask_type) * * Descrip: Makes a probability matrix from simple match/mismatch * probabilities. * * * * Arg: match [UNKN ] Undocumented argument [Probability] * Arg: nmask_type [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [DnaProbMatrix *] * */ # line 73 "dnamatrix.dy" DnaProbMatrix * DnaProbMatrix_from_match(Probability match,int nmask_type) { int i,j; DnaProbMatrix * out; Probability factor; switch (nmask_type ) { case NMaskType_BASE : factor = ((1.0 - match)/4.0); break; case NMaskType_VARIABLE : case NMaskType_EXCLUDED : case NMaskType_BANNED : factor = ((1.0 - match)/3.0); break; default : warn("No valid mask type. Ugh!"); return NULL; } out = DnaProbMatrix_alloc(); for(i=0;i<4;i++) { for(j=0;j<4;j++) { if( i == j ) { out->prob[i][j] = match; } else { out->prob[i][j] = factor; } } } for(i=0;i<5;i++) { switch (nmask_type ) { case NMaskType_BASE : if( i == BASE_N ) { out->prob[i][i] = match; } else { out->prob[BASE_N][i] = out->prob[i][BASE_N] = factor; } break; case NMaskType_VARIABLE : if( i == BASE_N ) { out->prob[i][i] = 0.25; } else { out->prob[BASE_N][i] = out->prob[i][BASE_N] = 0.25; } break; case NMaskType_EXCLUDED : if( i == BASE_N ) { out->prob[i][i] = 1.0; } else { out->prob[BASE_N][i] = out->prob[i][BASE_N] = 0.0; } break; case NMaskType_BANNED : out->prob[BASE_N][i] = out->prob[i][BASE_N] = 0.0; break; default : warn("No valid mask type. Ugh! Shouldn't be here. A BAD BAD bug!!!"); } } return out; } /* Function: flat_null_DnaProbMatrix(dpm) * * Descrip: makes a odds of dpm via a 0.25 factor * into each base. * * * Arg: dpm [UNKN ] Undocumented argument [DnaProbMatrix *] * */ # line 148 "dnamatrix.dy" void flat_null_DnaProbMatrix(DnaProbMatrix * dpm) { int i,j; for(i=0;i<4;i++) { for(j=0;j<4;j++) { dpm->prob[i][j] = dpm->prob[i][j]/0.25; } } return; } /* Function: DnaMatrix_from_DnaProbMatrix(dpm) * * Descrip: Maps probabilities to scores * * * Arg: dpm [UNKN ] Undocumented argument [DnaProbMatrix *] * * Return [UNKN ] Undocumented return value [DnaMatrix *] * */ # line 165 "dnamatrix.dy" DnaMatrix * DnaMatrix_from_DnaProbMatrix(DnaProbMatrix * dpm) { int i,j; DnaMatrix * out; out = DnaMatrix_alloc(); for(i=0;i<5;i++) for(j=0;j<5;j++) out->score[i][j] = Probability2Score(dpm->prob[i][j]); return out; } /* Function: show_DnaMatrix(dcm,ofp) * * Descrip: Simple view of DnaMatrix * * * Arg: dcm [UNKN ] Undocumented argument [DnaMatrix *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 181 "dnamatrix.dy" void show_DnaMatrix(DnaMatrix * dcm,FILE * ofp) { int i,j; for(i=0;i<5;i++) { for(j=0;j<5;j++) { fprintf(ofp,"%c %c - %d\n",char_from_base(i),char_from_base(j),dcm->score[i][j]); } } } /* Function: show_DnaProbMatrix(dpm,ofp) * * Descrip: Simple view of DnaProbMatrix * * * Arg: dpm [UNKN ] Undocumented argument [DnaProbMatrix *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ # line 195 "dnamatrix.dy" void show_DnaProbMatrix(DnaProbMatrix * dpm,FILE * ofp) { int i,j; for(i=0;i<5;i++) { for(j=0;j<5;j++) { fprintf(ofp,"%c %c - %g\n",char_from_base(i),char_from_base(j),dpm->prob[i][j]); } } } /* Function: fail_safe_DnaMatrix_access(dm,one,two) * * Descrip: Run-time checked that one and two are ok to pass * into dm as bases * * * * Arg: dm [UNKN ] DnaMatrix to get score from [DnaMatrix *] * Arg: one [UNKN ] base of one sequence [base] * Arg: two [UNKN ] base of the other sequence [base] * * Return [UNKN ] Undocumented return value [Score] * */ # line 216 "dnamatrix.dy" Score fail_safe_DnaMatrix_access(DnaMatrix * dm,base one,base two) { if( dm == NULL) { warn("Passing in a NULL dna matrix into fail_safe_DnaMatrix_access, can't get a score therefore"); return 0; } if( one < 0 || one > 4 || two < 0 || two > 4 ) { warn("In fail safe DnaMatrix access, trying to access a position [%d][%d] where this is meant to be 0-4",one,two); return 0; } return dm->score[one][two]; } /* Function: identity_DnaMatrix(id_score,mismatch) * * Descrip: makes an idenity matrix wth id_score on the leading * diagonal and mismatch elsewhere. * * * * Arg: id_score [UNKN ] score of idenities [Score] * Arg: mismatch [UNKN ] score of mistmatches [Score] * * Return [UNKN ] Undocumented return value [DnaMatrix *] * */ # line 239 "dnamatrix.dy" DnaMatrix * identity_DnaMatrix(Score id_score,Score mismatch) { DnaMatrix * out; int i; int j; out = DnaMatrix_alloc(); for(i=0;i<4;i++) for(j=i;j<4;j++) { if( i == j ) out->score[i][j] = id_score; else out->score[i][j] = out->score[j][i] = mismatch; } for(i=0;i<4;i++) { out->score[i][4] = out->score[4][i] = 0; } out->score[4][4] = 0; return out; } # line 270 "dnamatrix.c" /* Function: hard_link_DnaProbMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProbMatrix *] * * Return [UNKN ] Undocumented return value [DnaProbMatrix *] * */ DnaProbMatrix * hard_link_DnaProbMatrix(DnaProbMatrix * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaProbMatrix object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaProbMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProbMatrix *] * */ DnaProbMatrix * DnaProbMatrix_alloc(void) { DnaProbMatrix * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaProbMatrix *) ckalloc (sizeof(DnaProbMatrix))) == NULL) { warn("DnaProbMatrix_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* prob[5][5] is an array: no default possible */ return out; } /* Function: free_DnaProbMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProbMatrix *] * * Return [UNKN ] Undocumented return value [DnaProbMatrix *] * */ DnaProbMatrix * free_DnaProbMatrix(DnaProbMatrix * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaProbMatrix obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } /* Function: hard_link_DnaMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaMatrix *] * * Return [UNKN ] Undocumented return value [DnaMatrix *] * */ DnaMatrix * hard_link_DnaMatrix(DnaMatrix * obj) { if( obj == NULL ) { warn("Trying to hard link to a DnaMatrix object: passed a NULL object"); return NULL; } obj->dynamite_hard_link++; return obj; } /* Function: DnaMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaMatrix *] * */ DnaMatrix * DnaMatrix_alloc(void) { DnaMatrix * out;/* out is exported at end of function */ /* call ckalloc and see if NULL */ if((out=(DnaMatrix *) ckalloc (sizeof(DnaMatrix))) == NULL) { warn("DnaMatrix_alloc failed "); return NULL; /* calling function should respond! */ } out->dynamite_hard_link = 1; #ifdef PTHREAD pthread_mutex_init(&(out->dynamite_mutex),NULL); #endif /* score[5][5] is an array: no default possible */ return out; } /* Function: free_DnaMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaMatrix *] * * Return [UNKN ] Undocumented return value [DnaMatrix *] * */ DnaMatrix * free_DnaMatrix(DnaMatrix * obj) { int return_early = 0; if( obj == NULL) { warn("Attempting to free a NULL pointer to a DnaMatrix obj. Should be trappable"); return NULL; } #ifdef PTHREAD assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); #endif if( obj->dynamite_hard_link > 1) { return_early = 1; obj->dynamite_hard_link--; } #ifdef PTHREAD assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0); #endif if( return_early == 1) return NULL; ckfree(obj); return NULL; } #ifdef _cplusplus } #endif wise-2.4.1/src/dynlibsrc/dnamatrix.h0000644000175000001440000001604510670453712017004 0ustar philippusers#ifndef DYNAMITEdnamatrixHEADERFILE #define DYNAMITEdnamatrixHEADERFILE #ifdef _cplusplus extern "C" { #endif #include "dyna.h" typedef enum NMaskType { NMaskType_BASE, NMaskType_VARIABLE, NMaskType_EXCLUDED, NMaskType_BANNED } NMaskType; #define DnaMatrix_MATCH(mat,one,two) (mat->score[one][two]) struct Wise2_DnaProbMatrix { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Probability prob[5][5]; } ; /* DnaProbMatrix defined */ #ifndef DYNAMITE_DEFINED_DnaProbMatrix typedef struct Wise2_DnaProbMatrix Wise2_DnaProbMatrix; #define DnaProbMatrix Wise2_DnaProbMatrix #define DYNAMITE_DEFINED_DnaProbMatrix #endif struct Wise2_DnaMatrix { int dynamite_hard_link; #ifdef PTHREAD pthread_mutex_t dynamite_mutex; #endif Score score[5][5]; } ; /* DnaMatrix defined */ #ifndef DYNAMITE_DEFINED_DnaMatrix typedef struct Wise2_DnaMatrix Wise2_DnaMatrix; #define DnaMatrix Wise2_DnaMatrix #define DYNAMITE_DEFINED_DnaMatrix #endif /***************************************************/ /* Callable functions */ /* These are the functions you are expected to use */ /***************************************************/ /* Function: new_CompMat_from_DnaMatrix_flat(dm) * * Descrip: Builds a CompMat mapping of a DnaMatrix * * * Arg: dm [UNKN ] Undocumented argument [DnaMatrix *] * * Return [UNKN ] Undocumented return value [CompMat *] * */ CompMat * Wise2_new_CompMat_from_DnaMatrix_flat(DnaMatrix * dm); #define new_CompMat_from_DnaMatrix_flat Wise2_new_CompMat_from_DnaMatrix_flat /* Function: DnaProbMatrix_from_match(match,nmask_type) * * Descrip: Makes a probability matrix from simple match/mismatch * probabilities. * * * * Arg: match [UNKN ] Undocumented argument [Probability] * Arg: nmask_type [UNKN ] Undocumented argument [int] * * Return [UNKN ] Undocumented return value [DnaProbMatrix *] * */ DnaProbMatrix * Wise2_DnaProbMatrix_from_match(Probability match,int nmask_type); #define DnaProbMatrix_from_match Wise2_DnaProbMatrix_from_match /* Function: flat_null_DnaProbMatrix(dpm) * * Descrip: makes a odds of dpm via a 0.25 factor * into each base. * * * Arg: dpm [UNKN ] Undocumented argument [DnaProbMatrix *] * */ void Wise2_flat_null_DnaProbMatrix(DnaProbMatrix * dpm); #define flat_null_DnaProbMatrix Wise2_flat_null_DnaProbMatrix /* Function: DnaMatrix_from_DnaProbMatrix(dpm) * * Descrip: Maps probabilities to scores * * * Arg: dpm [UNKN ] Undocumented argument [DnaProbMatrix *] * * Return [UNKN ] Undocumented return value [DnaMatrix *] * */ DnaMatrix * Wise2_DnaMatrix_from_DnaProbMatrix(DnaProbMatrix * dpm); #define DnaMatrix_from_DnaProbMatrix Wise2_DnaMatrix_from_DnaProbMatrix /* Function: show_DnaMatrix(dcm,ofp) * * Descrip: Simple view of DnaMatrix * * * Arg: dcm [UNKN ] Undocumented argument [DnaMatrix *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_DnaMatrix(DnaMatrix * dcm,FILE * ofp); #define show_DnaMatrix Wise2_show_DnaMatrix /* Function: show_DnaProbMatrix(dpm,ofp) * * Descrip: Simple view of DnaProbMatrix * * * Arg: dpm [UNKN ] Undocumented argument [DnaProbMatrix *] * Arg: ofp [UNKN ] Undocumented argument [FILE *] * */ void Wise2_show_DnaProbMatrix(DnaProbMatrix * dpm,FILE * ofp); #define show_DnaProbMatrix Wise2_show_DnaProbMatrix /* Function: fail_safe_DnaMatrix_access(dm,one,two) * * Descrip: Run-time checked that one and two are ok to pass * into dm as bases * * * * Arg: dm [UNKN ] DnaMatrix to get score from [DnaMatrix *] * Arg: one [UNKN ] base of one sequence [base] * Arg: two [UNKN ] base of the other sequence [base] * * Return [UNKN ] Undocumented return value [Score] * */ Score Wise2_fail_safe_DnaMatrix_access(DnaMatrix * dm,base one,base two); #define fail_safe_DnaMatrix_access Wise2_fail_safe_DnaMatrix_access /* Function: identity_DnaMatrix(id_score,mismatch) * * Descrip: makes an idenity matrix wth id_score on the leading * diagonal and mismatch elsewhere. * * * * Arg: id_score [UNKN ] score of idenities [Score] * Arg: mismatch [UNKN ] score of mistmatches [Score] * * Return [UNKN ] Undocumented return value [DnaMatrix *] * */ DnaMatrix * Wise2_identity_DnaMatrix(Score id_score,Score mismatch); #define identity_DnaMatrix Wise2_identity_DnaMatrix /* Function: hard_link_DnaProbMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaProbMatrix *] * * Return [UNKN ] Undocumented return value [DnaProbMatrix *] * */ DnaProbMatrix * Wise2_hard_link_DnaProbMatrix(DnaProbMatrix * obj); #define hard_link_DnaProbMatrix Wise2_hard_link_DnaProbMatrix /* Function: DnaProbMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaProbMatrix *] * */ DnaProbMatrix * Wise2_DnaProbMatrix_alloc(void); #define DnaProbMatrix_alloc Wise2_DnaProbMatrix_alloc /* Function: free_DnaProbMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaProbMatrix *] * * Return [UNKN ] Undocumented return value [DnaProbMatrix *] * */ DnaProbMatrix * Wise2_free_DnaProbMatrix(DnaProbMatrix * obj); #define free_DnaProbMatrix Wise2_free_DnaProbMatrix /* Function: hard_link_DnaMatrix(obj) * * Descrip: Bumps up the reference count of the object * Meaning that multiple pointers can 'own' it * * * Arg: obj [UNKN ] Object to be hard linked [DnaMatrix *] * * Return [UNKN ] Undocumented return value [DnaMatrix *] * */ DnaMatrix * Wise2_hard_link_DnaMatrix(DnaMatrix * obj); #define hard_link_DnaMatrix Wise2_hard_link_DnaMatrix /* Function: DnaMatrix_alloc(void) * * Descrip: Allocates structure: assigns defaults if given * * * * Return [UNKN ] Undocumented return value [DnaMatrix *] * */ DnaMatrix * Wise2_DnaMatrix_alloc(void); #define DnaMatrix_alloc Wise2_DnaMatrix_alloc /* Function: free_DnaMatrix(obj) * * Descrip: Free Function: removes the memory held by obj * Will chain up to owned members and clear all lists * * * Arg: obj [UNKN ] Object that is free'd [DnaMatrix *] * * Return [UNKN ] Undocumented return value [DnaMatrix *] * */ DnaMatrix * Wise2_free_DnaMatrix(DnaMatrix * obj); #define free_DnaMatrix Wise2_free_DnaMatrix /* Unplaced functions */ /* There has been no indication of the use of these functions */ /***************************************************/ /* Internal functions */ /* you are not expected to have to call these */ /***************************************************/ #ifdef _cplusplus } #endif #endif wise-2.4.1/src/dynlibsrc/hscore.typemap0000644000175000001440000000127610670453712017530 0ustar philippusers TYPEMAP Wise2_Hscore * T_Wise2_Hscore INPUT T_Wise2_Hscore $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_Hscore *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_Hscore sv_setref_pv($arg, "Wise2::Hscore", (void*) $var); TYPEMAP Wise2_DataScore * T_Wise2_DataScore INPUT T_Wise2_DataScore $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_DataScore *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_DataScore sv_setref_pv($arg, "Wise2::DataScore", (void*) $var); TYPEMAP Wise2_DataEntry * T_Wise2_DataEntry INPUT T_Wise2_DataEntry $var = ($type) (SvROK($arg) == 0 ? NULL : (Wise2_DataEntry *) SvIV((SV*)SvRV($arg))) OUTPUT T_Wise2_DataEntry sv_setref_pv($arg, "Wise2::DataEntry", (void*) $var); wise-2.4.1/src/dynlibsrc/codonmapper.pod0000644000175000001440000000500610670453712017652 0ustar philippusers=head1 NAME codonmapper module - part of the Wise2 package =head1 SYNOPSIS This module contains the following objects =over =item CodonMapper =back =head1 DESCRIPTION =head2 Object CodonMapper =over =item ct Type [CodonTable *] Scalar hard-linked! =item codon_map[125][26] Type [double] Scalar No documentation =back CodonMapper holds a matrix of 125 by 26 to provide a mapping between a probabilities calculated on amino acids to triplet codon probabilities. This mapping takes into account 3 things 1) The CodonTable 2) The distribution of synonmous codons (codon bias) 3) substitution errors =head2 Member functions of CodonMapper =over =item sprinkle_errors_over_CodonMapper &Wise2::CodonMapper::sprinkle_errors_over_CodonMapper(cm,error) Takes a codon mapper and assummes that the majority of errors are due to a single base change in the codon at probability error. Therefore, for each codon it adds error * prob(codon) * 0.25 to each other codon one base away, taking away therefore the result. Argument cm [READ ] CodonMapper to be sprinkled [CodonMapper *] Argument error [UNKN ] substitution error rate [double] Return [UNKN ] Undocumented return value [void] =item hard_link_CodonMapper &Wise2::CodonMapper::hard_link_CodonMapper(obj) Bumps up the reference count of the object Meaning that multiple pointers can 'own' it Argument obj [UNKN ] Object to be hard linked [CodonMapper *] Return [UNKN ] Undocumented return value [CodonMapper *] =item alloc &Wise2::CodonMapper::alloc(void) Allocates structure: assigns defaults if given Return [UNKN ] Undocumented return value [CodonMapper *] =item set_ct &Wise2::CodonMapper::set_ct(obj,ct) Replace member variable ct For use principly by API functions Argument obj [UNKN ] Object holding the variable [CodonMapper *] Argument ct [OWNER] New value of the variable [CodonTable *] Return [SOFT ] member variable ct [boolean] =item ct &Wise2::CodonMapper::ct(obj) Access member variable ct For use principly by API functions Argument obj [UNKN ] Object holding the variable [CodonMapper *] Return [SOFT ] member variable ct [CodonTable *] =back =over =item flat_CodonMapper &Wise2::flat_CodonMapper(ct) Makes a CodonMapper with no codon bias or error possiblities from codon table Argument ct [UNKN ] Codon Table giving codon->aa info [CodonTable *] Return [UNKN ] Undocumented return value [CodonMapper *] =back wise-2.4.1/src/dynlibsrc/codonmapper.tex0000644000175000001440000000416610670453712017676 0ustar philippusers\section{codonmapper} \label{module_codonmapper} This module contains the following objects \begin{itemize} \item \ref{object_CodonMapper} CodonMapper \item This module also contains some factory methods \end{itemize} \subsection{codonmapper factory methods} \subsubsection{flat_CodonMapper} \begin{description} \item[External C] {\tt Wise2_flat_CodonMapper (ct)} \item[Perl] {\tt &Wise2::flat_CodonMapper (ct)} \end{description} Arguments \begin{description} \item[ct] [UNKN ] Codon Table giving codon->aa info [CodonTable *] \item[returns] [UNKN ] Undocumented return value [CodonMapper *] \end{description} Makes a CodonMapper with no codon bias or error possiblities from codon table \subsection{Object CodonMapper} \label{object_CodonMapper} The CodonMapper object has the following fields. To see how to access them refer to \ref{accessing_fields} \begin{description} \item{ct} Type [CodonTable * : Scalar] hard-linked! \item{codon_map[125][26]} Type [double : Scalar] No documentation \end{description} CodonMapper holds a matrix of 125 by 26 to provide a mapping between a probabilities calculated on amino acids to triplet codon probabilities. This mapping takes into account 3 things \begin{verbatim} 1) The CodonTable 2) The distribution of synonmous codons (codon bias) 3) substitution errors \end{verbatim} Member functions of CodonMapper \subsubsection{sprinkle_errors_over_CodonMapper} \begin{description} \item[External C] {\tt Wise2_sprinkle_errors_over_CodonMapper (cm,error)} \item[Perl] {\tt &Wise2::CodonMapper::sprinkle_errors_over_CodonMapper (cm,error)} \item[Perl-OOP call] {\tt $obj->sprinkle_errors_over_CodonMapper(error)} \end{description} Arguments \begin{description} \item[cm] [READ ] CodonMapper to be sprinkled [CodonMapper *] \item[error] [UNKN ] substitution error rate [double] \item[returns] Nothing - no return value \end{description} Takes a codon mapper and assummes that the majority of errors are due to a single base change in the codon at probability error. Therefore, for each codon it adds error * prob(codon) * 0.25 to each other codon one base away, taking away therefore the result. wise-2.4.1/src/dynlibsrc/sequencestream.dy0000644000175000001440000001030610345352771020222 0ustar philippusers %{ #include "sequence.h" %} %{ #include "sequencestream.h" %func untyped version of reading from Wise2ReadStreamInterface %% void * untyped_SequenceSet_from_Stream(Wise2ReadStreamInterface * rs) { SequenceSet * set; set = typed_SequenceSet_from_Stream(rs); return (void*) set; } %func Typed version of reading from Stream, making a SequenceSet %% SequenceSet * typed_SequenceSet_from_Stream(Wise2ReadStreamInterface * rs) { SequenceSet * out; char buffer[512]; Sequence * curr; char * pos; char * desc; out = SequenceSet_alloc_std(); curr = NULL; while( WISE2_READ_BUFFER(buffer,512,rs) != NULL ) { if( strncmp(buffer,"//",2) == 0 ) { /* fprintf(stderr,"In reading sequence set, have finally" " a sequence with length %d and first sequence %s\n", out->len,out->set[0]->seq); */ return out; } if( buffer[0] == '>' ) { /* make new sequence with this position */ /* delimit name after '>' */ for(pos=buffer+1;*pos;pos++) { if( isspace(*pos) ) { *pos = '\0'; break; } } /* find next string if there, will be description */ for(++pos;*pos && isspace(*pos);pos++) { ; } if( *pos != '\0' && !isspace(*pos) ) { desc = pos; /* could be '\n' delimited or '\0' delimited */ for(;*pos != '\0' && *pos != '\n';pos++) { ; } *pos = '\0'; } else { desc = NULL; } /* if there has been a previous sequence, it is in curr. Terminate the string at curr->len */ if( curr != NULL ) { curr->seq[curr->len] = '\0'; } curr = Sequence_alloc(); curr->name = stringalloc(buffer+1); curr->seq = calloc(512,sizeof(char)); curr->len = 0; curr->maxlen = 512; if( desc != NULL ) { curr->desc = stringalloc(desc); } add_SequenceSet(out,curr); /* fprintf(stderr, "SEQUENCE: %s\n", curr->name); */ continue; } /* this is a sequence line */ for(pos = buffer;*pos;pos++) { if( isalpha(*pos) ) { curr->seq[curr->len++] = *pos; } if( curr->len+1 >= curr->maxlen ) { void *tmpp; if( curr->maxlen >= 32768 ) { curr->maxlen += 32768; } else { curr->maxlen *= 2; } tmpp = realloc(curr->seq,sizeof(char)*curr->maxlen); if (tmpp == NULL) { fatal("Failed in realloc()"); } curr->seq = tmpp; } } } /* fprintf(stderr,"In reading sequence set, " "have finally a sequence with length %d and " "first sequence %s\n",out->len,out->set[0]->seq); */ return out; } %func typed version of writing a sequence set to a stream %% void typed_write_SequenceSet_to_Stream(SequenceSet * set,Wise2WriteStreamInterface * ws) { int i; for(i=0;ilen;i++) { typed_write_one_Sequence_to_Stream(set->set[i],ws); } WISE2_WRITE_STRING("//\n",ws); } %func untyped version for writing a sequence set to a stream %% void untyped_write_SequenceSet_to_Stream(void * s,Wise2WriteStreamInterface * ws) { typed_write_SequenceSet_to_Stream((SequenceSet*)s,ws); } %func internal function for writing out one sequence %% void typed_write_one_Sequence_to_Stream(Sequence * seq,Wise2WriteStreamInterface * ws) { char buffer[512]; int i; if( seq->desc != NULL) { sprintf(buffer,">%s %-80s\n",seq->name,seq->desc); } else { sprintf(buffer,">%s\n",seq->name); } WISE2_WRITE_STRING(buffer,ws); for(i=0;ilen;) { buffer[0] = '\0'; if( i+80 < seq->len ) { strncpy(buffer,seq->seq+i,80); i = i+80; buffer[80] = '\0'; } else { strcpy(buffer,seq->seq+i); i = seq->len; } strcat(buffer,"\n"); WISE2_WRITE_STRING(buffer,ws); } } %func untyped write one sequence stream %% void untyped_write_Sequence_to_Stream(void * seq,Wise2WriteStreamInterface * ws) { typed_write_one_Sequence_to_Stream((Sequence *)seq,ws); WISE2_WRITE_STRING("//\n",ws); } %func reading one sequence from stream %% void * untyped_read_Sequence_from_Stream(Wise2ReadStreamInterface * rs) { SequenceSet * out; Sequence * seq; out = typed_SequenceSet_from_Stream(rs); if( out == NULL || out->len == 0 ) { warn("In reading sequences, no sequences found"); return NULL; } seq = hard_link_Sequence(out->set[0]); free_SequenceSet(out); return (void*) seq; } %} wise-2.4.1/docs/0000755000175000001440000000000010670453536013012 5ustar philippuserswise-2.4.1/docs/appendix.tex0000644000175000001440000005204607313404521015341 0ustar philippusers\makeatletter \documentstyle[11pt,fleqn]{article} %\input amssym.def %\input amssym.tex \setlength{\evensidemargin}{0in} \setlength{\oddsidemargin}{0in} \setlength{\textwidth}{6.25in} \setlength{\textheight}{8.5in} \setlength{\topmargin}{0in} \setlength{\headheight}{0in} \setlength{\headsep}{0in} \setlength{\itemsep}{-\parsep} \renewcommand{\topfraction}{.9} \renewcommand{\textfraction}{.1} \newcommand{\ol}{\setlength{\itemsep}{0pt.}\begin{enumerate}} \newcommand{\eol}{\end{enumerate}\setlength{\itemsep}{-\parsep}} \newcommand{\ignore}[1]{} \setlength{\parskip}{0pt} %{\medskipamount} \parindent 1em % \sup will be used for superscript. %\def\sup{^} %right arrow \newcommand{\rarrow}{\rightarrow} %left arrow \newcommand{\larrow}{\leftarrow} \overfullrule=0pt \def\setof#1{\lbrace #1 \rbrace} % SIDE MARGINS: \oddsidemargin 0pt % Left margin on odd-numbered pages. \evensidemargin 0pt % Left margin on even-numbered pages. \marginparwidth 40pt % Width of marginal notes. \marginparsep 10pt % Horizontal space between outer margin and % marginal note % VERTICAL SPACING: \topmargin 0pt % Nominal distance from top of page to top of % box containing running head. \headsep 10pt % Space between running head and text. % DIMENSION OF TEXT: \textheight 8.4in % Height of text (including footnotes and figures, % excluding running head and foot). \textwidth 6.5in % Width of text line. \newtheorem{theo}{Theorem} \newtheorem{prop}[theo]{Proposition} \newtheorem{conj}{Conjecture} \newtheorem{prob}[conj]{Problem} \renewcommand{\baselinestretch}{1.6} \title{GeneWise - Probability Appendix} \author{Ewan Birney, Mor Amitai} \begin{document} \maketitle \section{Intron Probabilities} \subsection{Definitions and Preamble} This document describes the derivation of probabilities for the case of an intron of a known phase occuring between two match states. Precisely the same process can be used for the other phase introns and the introns occuring between two insert states or insert to match or match to insert. The way we will model the introns is as 5 regions, two of fixed length, which can then be modeled as 3 states in the resulting HMM. Because we allow overlaps in the 'emission' of characters from different states there are conditional probabilities which require carefully handling; for this reason we explicitly expand the probability calculations and then collect relevant terms to construct the HMM. The final HMM is slightly incorrect in that the correction terms needed to be multipled on the non-intron, coding sequence path cannot take into account the more complicated intron modeling we have provided here. However because these probabilities for introns are small, with the corresponding correction term being 1-($\sum$ intron probabilites) this effect is likely to be small. We will use the following notations: \begin{description} \item intron = intron$V$ = intron of phase $V$. \item $C^s = c^s_1,...,c^s_l$ - l bases before the intron. \item $C^e = c^e_1,...,c^e_t$ - t bases after the intron. \item $X = x_1,x_2,...,x_m$ - the first $m$ bases of the intron. \item $A = a_1,a_2,...,a_n$ - the central $n$ bases of the intron. \item $Y = y_1,y_2,...,y_p$ - the $p$ bases of the pyrimidine tract. \item $B = b_1,b_2,...,b_q$ - the $b$ bases between the pyrimidine tract and the 3' splice site. \item $Z = z_1,z_2,...,z_r$ - the last $r$ bases of the intron. \end{description} $C^sX$ is the 5' splice site information, $Y$ the pyrimidine tract information and $ZC^e$ is the 3' splice site information. $A$ and $B$ are spacers between the 5'SS and the pyrimidine tract and the pyrimidine tract and the 3'SS which will mainly provide length information. \subsection{Overview of the probabilities} We want to calculate Prob(sequence , alignment $|$ model). In most Hidden Markov Models, this probability can be calculated in two parts: \begin{enumerate} \item Prob(alignment $|$ model) - The transition probabilities \item Prob(sequence $|$ model,alignment) - The emission probabilities \end{enumerate} In calculating the intron probability there are terms equivalent to the alignment path and terms equivalent to the sequence emitted, but because the same sequence is 'emitted' by two separate processes (for example, the bases before the 5'SS must be evaluted both as part of the protein sequence and as part of the splice site consensus), the probability calculation is not a mechanical decomposition of path and emissions. So, starting from the complete probability of a intron of phase $V$ between match states $i$ and $i+1$, we will first decompse the probabilities into a product in which each term can be calculated using some biological assumptions. Following this, the different terms of the product can be placed at appropiate transitions or emissions in the expanded HMM for the best path to be calculated by standard dynamic programming methods. \subsection{Biological assumptions} The biological assumptions which we make are as follows \begin{enumerate} \item Amino acids, or in this case, codons are independent. This assumption is made in standard HMM models of protein sequence. \item The different regions of the intron are independent and so the probability of an intron is simply the product of the different regions. This assumption is often used in current gene parsing methods. \item The intron can be adaquately modelled as a having 5 regions: 5'SS, central region, pyrimidine tract, spacer, 3'SS. \item The length distributions of the separate regions are independant of any other features of the introns. \item The length distributions of the different regions can be adquately modeled by an exponential decay or fixed lengths. This assumption can be changed at the cost of greater computional complexity. \item That there is no exon of less than $l+t+2$ bases. $l$ and $t$ are the splice site information which overlap the coding sequence, and are currently fixed at 3. \item That the number of phase 1 or 2 introns in a gene are small such that ignoring the information in the split codons in these introns (which will be necessary for calculating the probability of an intron) does not significantly change the overall probability. \end{enumerate} Some assumptions which we have kept however in the model are \begin{enumerate} \item The 5'SS is $dependent$ on the previous coding sequence bases \item The 3'SS is $dependent$ on the following coding sequence bases \end{enumerate} \subsection{Probability} In the following formula the terms such as $Y_{j+m+n,p}$ encorporates three separate parts of the probability: firstly that the length of the region is $p$, secondly that the bases $y_1$ ... $y_p$, come from the $Y$ region, ie the pyrimidine tract, and finally that the Y region starts at position $j+m+n$. Thus these terms represent both alignment and emission components. We are interested in the probability of an intron of a defined path between positions $j$ and $h$ in the DNA sequence and between match state $i$ and match state $i+1$ in the Hidden Markov model. \begin{equation}\label{overall} Prob(C^s_{j-l,l},C^e_{h,t},X_{j,m},A_{j+m,n},Y_{j+m+n,p},B_{j+m+n+p,q},Z_{j+m+n+p+q,r} \; |\; model) \end{equation} Notice that $$ h = j+m+n+p+q+r $$ As everything is dependant on the model, we can omit explicit $P( \cdot\; | \; model)$ terms. $$ Prob(C^s_{j-l,l},C^e_{h,t},X_{j,m},A_{j+m,n},Y_{j+m+n,p},B_{j+m+n+p,q},Z_{j+m+n+p+q,r} \;) $$ Using $$ P(\alpha, \beta \; |\; \gamma) = P(\alpha \; |\; \gamma) \times P(\beta \; |\; \alpha, \gamma) $$ iteratively we can decompose this probability into a product \begin{equation}\label{eq1} P(C^s_{j-l,l},C^e_{h,t}\;) \times \end{equation} \begin{equation}\label{eq2} P(X_{j,m}\; |\; C^s_{j-l,l},C^e_{h,t}) \times \end{equation} \begin{equation}\label{eq3} P(A_{j+m,n}\; |\; C^s_{j-l,l},C^e_{h,t},X_{j,m}) \times \end{equation} \begin{equation}\label{eq4} P(Y_{j+m+n,p}\; |\; C^s_{j-l,l},C^e_{h,t},X_{j,m},A_{j+m,n}) \times \end{equation} \begin{equation}\label{eq5} P(B_{j+m+n+p,q}\; |\; C^s_{j-l,l},C^e_{h,t},X_{j,m},A_{j+m,n},Y_{j+m+n,p}) \times \end{equation} \begin{equation}\label{eq6} P(Z_{j+m+n+p+q,r}\; |\; C^s_{j-l,l},C^e_{h,t},X_{j,m},A_{j+m,n},Y_{j+m+n,p},B_{j+m+n+p,q}) \end{equation} Now, we will treat each of these equations in turn, and, by using the biological assumptions stated above, decompose them into measurably quanities. For the terms 2-6 generally we will have three components \begin{enumerate} \item the probability of entering this region from the previous region \item the probability of the length of this region \item the probability of the bases in this region \end{enumerate} \subsection{equation 2} $$ P(C^s_{j-l,l},C^e_{h,t}\; |\; model) = $$ $$ P(c^s_1,...,c^s_{l-V}\; |\; model) \times P(c^{split}_{l-V+1},c^{split}_{l-V+2},c^{split}_{l-V+3}) \times P(c^e_{4-V},...,c^e_{t} \; |\; model) (\ref{eq1}) $$ The first and last terms (for appropiates choice of $l$ and $t$), and the middle $c^{split}$ term for $V = 0$ are emission probabilities (whether match or insert) from the model, and are calculated in the standard manner. For $V = 1 \mbox{ or } 2$ The term $c^{split}_{index}$ indicates the split codon made from the end of $C^s$ and the beginning of $C^e$, depending on $V$. This codon cannot be calculated correctly without a large increased in computational complexity, and so we ignore the information in this codon. \subsection{equation 3} $$ P(X_{j,m}\; |\; C^s_{j-l,l},C^e_{h,t}) = $$ \begin{equation}\label{eq2.1} P(5'SS_j,3'SS_h \; |\; C^s_{j-l,l},C^e_{h,t})\times \end{equation} \begin{equation}\label{eq2.2} P(length(X)=m \; |\; C^s_{j-l,l},C^e_{h,t},5'SS_j,3'SS_h) \end{equation} \begin{equation}\label{eq2.3} P(X_{j,m} \; |\; C^s_{j-l,l},C^e_{h,t},5'SS_j,3'SS_h,length(X)=m) \end{equation} The term $P(5'SS_j,3'SS_h | \cdot)$ indicates that the intron starts at position $j$ and ends at position $h$. $h$ is defined to be the end of the intron, and we assume that all introns have an end. And so $P(5'SS_j| \cdot) = P(3'SS_h| \cdot) = P(5'SS_j,3'SS_h\; |\;\cdot)$. $$ (\ref{eq2.1}) \;\;\; P(5'SS_j,3'SS_h \; |\; C^s_{j-l,l},C^e_{h,t}) = \frac{P(C^s_{j-l,l},C^e_{h,t} \; |\; 5'SS_j,3'SS_h ) \times P( 5'SS_j,3'SS_h)}{ P(C^s_{j-l,l},C^e_{h,t})} $$ $$ = \frac{P(C^s_{j-l,l} \; |\; 5'SS_j,3'SS_h ) \times P(C^e_{h,t}\; |\; 5'SS_j,3'SS_h )\times P( 5'SS_j,3'SS_h)} { P(C^s_{j-l,l})\times P(C^e_{h,t})} $$ $$ = \frac{P(C^s_{j-l,l} \; |\; 5'SS_j ) \times P( 5'SS_j,3'SS_h)} {P(C^s_{j-l,l})} \times \frac{ P(C^e_{h,t}\; |\; 3'SS_h )\times P(5'SS_j,3'SS_h)}{P(C^e_{h,t})} \times \frac{1}{ P(5'SS_j,3'SS_h)} $$ Notice that $P(5'SS_j,3'SS_h \; |\; C^s_{j-l,l}) = P(5'SS_j \; |\; C^s_{j-l,l})$ and similarly for $3'SS$. $$ = P( 5'SS_j \; |\; C^s_{j-l,l}) \times P(3'SS_h \; |\; C^e_{h,t}) \times \frac{1}{ P(5'SS_j,3'SS_h)} $$ $$ = \frac{no(C^s \mbox{ in 5' SS})}{no(\mbox{ $C^s$ in CDS})} \times \frac{no(C^e \mbox{ in 3' SS})}{no(\mbox{ $C^e$ in CDS})} \times \frac{1}{\frac{no(\mbox{intron of phase $V$})} {no(\mbox{CDS bases})\times \frac{1}{3}}} $$ \begin{equation}\label{intron_existance_term} = \frac { no(C^s \mbox{ in 5' SS})\times no(C^e \mbox{ in 3' SS})\times no(\mbox{CDS bases}) } { no(\mbox{$C^s$ in CDS})\times no(\mbox{$C^e$ in CDS})\times no(\mbox{intron of phase $V$})\times 3 } \end{equation} $ (\ref{eq2.2}) \;\;\; P(length(X) = m | C^s_{j-l,l},C^e_{h,t},5'SS_j,3'SS_h) = 1 $ We have fixed m to be a set length (7 for the current human model), and thus this ``transition'' probability is one. \begin{equation}\label{5'SS_consensus} (\ref{eq2.3}) \;\;\; P(X_{j,m} \; |\; C^s_{j-l,l},C^e_{h,t},5'SS_j,3'SS_h) = P(X_{j,m} \; |\; C^s_{j-l,l},5'SS_j) = \frac{no(\mbox{$C^sX$ in 5' SS})}{no(\mbox{$C^s$ in 5' SS} )} \end{equation} \subsection{equation 4} $$ P(A_{j+m,n} \; |\; C^s_{j-l,l},C^e_{h,t},X_{j,m}) = P(A_{j+m,n} \; |\; X_{j,m}) $$ \begin{equation}\label{eq3.1} P(A \mbox{ region } \; |\; X_{j,m})\times \end{equation} \begin{equation}\label{eq3.2} P( \mbox{ length of $A$ region is }n \; |\; \mbox{ region $A$} ) \times \end{equation} \begin{equation}\label{eq3.3} P( A = a_1,a_2,...,a_n \; |\; \mbox{ region $A$ of length $n$ } ) \end{equation} $(\ref{eq3.1})$ is 1 because we always have a central region following a 5'SS.\\ $(\ref{eq3.2})$ assuming an exponetial decay distribution with parameter $\alpha$ \begin{equation}\label{central_length} P( \mbox{ $A$ region of length }n\; | \; \mbox{ region $A$} ) = (1- \alpha) \alpha^{n-1} \end{equation} $(\ref{eq3.3})$ is \begin{equation}\label{central_emission} \prod_{i=1}^n P(a_i \; |\; \mbox{ central region }) \end{equation} \subsection{equation 5} $$ P(Y_{j+m+n,p}\; |\; C^s_{j-l,l},C^e_{h,t},X_{j,m},A_{j+m,n}) = P(Y_{j+m+n,p}\; |\; A_{j+m,n}) = $$ \begin{equation}\label{eq4.1} P(Y \mbox{ region } \; |\; A_{j+m,n})\times \end{equation} \begin{equation}\label{eq4.2} P( \mbox{ length of $Y$ region is }p\; | \; \mbox{ region $Y$ }) \times \end{equation} \begin{equation}\label{eq4.3} P( Y = y_1,y_2,...,y_p \; |\; \mbox{ region $Y$ of length $p$ } ) \end{equation} As the previous region, the first term ($\ref{eq4.1}$) is one, whereas the other two terms are as before, \begin{equation}\label{py_length} (\ref{eq4.2}) P( \mbox{ $Y$ region of length }p \; | \; \mbox{ region $Y$ }) = (1- \beta) \beta^{p-1} \end{equation} \begin{equation}\label{py_emission} (\ref{eq4.3}) = \prod_{i=1}^p P(y_i \; |\; \mbox{ pyrimidine region }) \end{equation} \subsection{equation 6} $$ P(B_{j+m+n}\; |\; C^s_{j-l,l},C^e_{h,t},X_{j,m},A_{j+m,n},Y_{j+m+n,p}) = P(B_{j+m+n+p,q}\; |\; Y_{j+m+n,p}) = $$ \begin{equation}\label{eq5.1} P(B \mbox{ region } \; |\; Y_{j+m+n,p})\times \end{equation} \begin{equation}\label{eq5.2} P( \mbox{ length of $B$ region is }q \; | \; \mbox{ region $B$ } ) \times \end{equation} \begin{equation}\label{eq5.3} P( B = b_1,b_2,...,b_q \; |\; \mbox{ region $B$ of length $q$ } ) \end{equation} As the previous two regions, the first term ($\ref{eq5.1}$) is one, whereas the other two terms are as before, \begin{equation}\label{spacer_length} (\ref{eq5.2}) P( \mbox{ $B$ region of length }q\; | \; \mbox{ region $Y$} ) = (1- \gamma) \gamma^{q-1} \end{equation} \begin{equation}\label{spacer_emission} (\ref{eq5.3}) = \prod_{i=1}^q P(b_i \; |\; \mbox{ pyrimidine to 3'SS spacer region }) \end{equation} \subsection{equation 7} $$ P( Z_{j+m+n+p+q,r}\; | \; C^s_{j-l,l},C^e_{h,t},X_{j,m},A_{j+m,n},Y_{j+m+n,p},B_{j+m+n+p,q}) $$ $$ = P( Z_{j+m+n+p+q,r} | C^e_{h,t}, B_{j+m+n+p,q}) $$ \begin{equation}\label{eq6.1} P(Z \mbox{ region } \; |\; C^e_{h,t}, B_{j+m+n+p,q} ) \times \end{equation} \begin{equation}\label{eq6.2} P( \mbox{ length of $Z$ region is }r \; | \; \mbox{ region $Z$} ) \times \end{equation} \begin{equation}\label{eq6.3} P( Z = z_1,...,z_r \; |\; C^e_{h,t}, \mbox{ length of $Z$ region is }r) \end{equation} $(\ref{eq6.1})$ is one $(\ref{eq6.2})$ is also one because we have a fixed length of $r$ (3 for the current human model) and \begin{equation}\label{3'SS_consensus} (\ref{eq6.3}) = \frac{ no(ZC^e \mbox{ in 3'SS } )}{ no(C^e \mbox{ in 3'SS })} \end{equation} \section{Applying Probabilities to the expanded HMM} The above probabilities, although now measurable cannot be placed on the HMM architecture. We need to mulitple the terms $\ref{eq1}-\ref{eq6}$ and then redistribute the resulting product over the HMM. In fact the central,pyrimidine tract and spacer regions ($A$,$Y$ and $B$) behave exactly as one expects in a standard HMM. However the $X$ and $Z$ regions are not calculable in the HMM as the stand at must be multiplied out first So, the equations which need to be multiplied together are: \begin{equation}\label{multiply} \mbox{Final Probabilty } = (\ref{intron_existance_term}) \times (\ref{5'SS_consensus}) \times (\ref{central_length}) \times (\ref{central_emission}) \times (\ref{py_length}) \times (\ref{py_emission}) \times (\ref{spacer_length}) \times (\ref{spacer_emission}) \times (\ref{3'SS_consensus}) \end{equation} $$ (\ref{multiply}) = \frac { no(C^s \mbox{ in 5'SS})\times no(C^e \mbox{ in 3' SS})\times no(\mbox{CDS bases}) } { no(\mbox{$C^s$ in CDS})\times no(\mbox{$C^e$ in CDS})\times no(\mbox{intron of phase $V$})\times 3 } \times $$ $$ \frac{no(\mbox{$C^sX$ in 5' SS})}{no(\mbox{$C^s$ in 5' SS} )} \times \frac{ no(ZC^e \mbox{ in 3'SS } )}{ no(C^e \mbox{ in 3'SS })} \times $$ $$ \times (\ref{central_length}) \times (\ref{central_emission}) \times (\ref{py_length}) \times (\ref{py_emission}) \times (\ref{spacer_length}) \times (\ref{spacer_emission}) $$ Cancelling the $no(C^s \mbox{ in 5'SS})$ and $no(C^e \mbox{ in 3'SS})$ terms, and rearranging the terms involving $C^s$ and $C^e$ together we arrive at \begin{equation}\label{5'SS_term} \frac { no(C^sX \mbox{ in 5'SS})}{ no(C^s \mbox{ in CDS}) } \times \end{equation} \begin{equation}\label{3'SS_term} \frac { no(ZC^e \mbox{ in 3'SS})}{ no(C^e \mbox{ in CDS}) } \times \end{equation} \begin{equation}\label{intron_correction_term} \frac { no(\mbox{CDS bases})}{ no(\mbox{introns of phase $V$}) \times 3} \times \end{equation} $$ \times (\ref{central_length}) \times (\ref{central_emission}) \times (\ref{py_length}) \times (\ref{py_emission}) \times (\ref{spacer_length}) \times (\ref{spacer_emission}) $$ \subsection{HMM transition probabilities} Despite having 5 regions in the intron, two of them, the 5'SS and the 3'SS are of fixed length. This means that these regions can be precisely modeled in the transition of states leading into them or leading from them with appropiate transition emission lengths (notice that these HMMs must 'emit' on the transitions as the probability depends on the sequence emitted). Thus the five regions of the intron can be represented by three states in the HMM, called CENTRAL, PY and SPACER We have some freedom as where to place the term ($\ref{intron_correction_term}$), which must be multipled once during the parse of the intron, but could go at any non-looping transition. We will place it at the 3'SS. [NB, this term, which will be greater than one is a 'correction' term for the fact that we have to incorporate the probability of having an intron twice, once in the 5'SS calculations and once in the 3'SS calculations]. In addition some probabilities will be the same for all positions in the protein model and depends only on the DNA sequence, for example ($\ref{5'SS_term}$) which indicates the consensus information at the 5'SS. These probabilities can be preprocessed on the sequence before the final dynamic programming method. \subsubsection{Transitions from MATCH to CENTRAL} From state MATCH to CENTRAL \begin{enumerate} \item sequence dependant: $(\ref{5'SS_term})$ \item sequence dependant: $P(a_1 \; | \; \mbox{ Central region})$ [the first term in$~(\ref{central_emission})$] partial match information: See note \end{enumerate} \subsubsection{Transitions from CENTRAL} From CENTRAL to CENTRAL \begin{enumerate} \item constant: $\alpha$ \item sequence dependant: $P(a_i \; | \; \mbox{ Central region})$ [the $i^{th}$ term in$~(\ref{central_emission})$] \end{enumerate} From CENTRAL to PY \begin{enumerate} \item constant: $1-\alpha$ \item sequence dependant: $P(y_1 \; | \; \mbox{ pyrimidine region})$ [the first term in$~(\ref{py_emission})$] \end{enumerate} \subsubsection{Transitions from PY} From PY to PY \begin{enumerate} \item constant: $\beta$ \item sequence dependant: $P(y_i \; | \; \mbox{ pyrimidine region})$ [the $i^{th}$ term in$~(\ref{py_emission})$] \end{enumerate} From PY to SPACER \begin{enumerate} \item constant: $1-\beta$ \item sequence dependant: $P(b_1 \; | \; \mbox{ spacer region})$ [the first term in$~(\ref{spacer_emission})$] \end{enumerate} \subsubsection{Transitions from SPACER} From SPACER to SPACER \begin{enumerate} \item constant: $\gamma$ \item sequence dependant: $P(b_i \; | \; \mbox{ spacer region})$ [the $i^{th}$ term in$~(\ref{spacer_emission})$] \end{enumerate} From SPACER to MATCH \begin{enumerate} \item constant: $1-\gamma$ \item constant: $\ref{intron_correction_term}$ \item sequence dependant: $\ref{3'SS_term}$ \item artifical match information: See note \end{enumerate} \subsection{Partial Match information} The Match information in phase 1 and 2 must be split but the split bases can still be evaluated as cases in which only one or two bases of the codon are known. Thus some of the information in the protein HMM is retained. \subsection{Tranistion from MATCH to MATCH (in coding sequence)} The protein MATCH to MATCH transition has now become four transitions, MATCH to MATCH, and MATCH to phase 0,1,2 introns. The sum of these four probabilities must sum to the original MATCH to MATCH probability. This can be achieved by the MATCH to MATCH (and MATCH to INSERT) taking a sequence dependant multipler to its probability Defining the term $S$ to mean the sequence around the codon ending at $j$. $$ S = s_{j-l},...,s_{j+m} $$ Notice that $l$ and $m$ are fixed for a particular model. $$ Prob(\mbox{ MATCH}\rightarrow \mbox{ MATCH in DNA }) = $$ $$ Prob(\mbox{ MATCH}\rightarrow \mbox{ MATCH in protein}) (1 - P(\mbox{ Intron phase 0}\;|\;S) - P(\mbox{Intron phase 1}\;|\;S) - P(\mbox{Intron phase 2}\;|\;S)) $$ The latter half of this product can be preprocessed on the sequence outside of the dynamic programming routine. \end{document} wise-2.4.1/docs/README0000644000175000001440000000011707313404521013657 0ustar philippusers This directory contains the documentation for the Wise2 and Dynamite packages wise-2.4.1/docs/wise2api.tex0000644000175000001440000004004307313404521015246 0ustar philippusers\documentstyle{article} \begin{document} \newcommand{\programtext}[1]{{\tt #1}} \title{Wise2 API (version 2.1.19b)} \author{Ewan Birney\\ Sanger Centre\\ Wellcome Trust Genome Campus\\ Hinxton, Cambridge CB10 1SA,\\ England.\\ Email: birney@sanger.ac.uk} \maketitle \newpage \tableofcontents \newpage \section{Overview} This document describes the API of the Wise2 system. The API (application programming interface) allows other programmers use the functionality in the Wise2 package directly, rather than treating the executables as a black box through which you get ASCII output. If you want to learn more about the Wise2 package itself, the algorithms in it or what it is used for, look for the Wise2 documentation (available as postscript), probably in the same place that you found this documentation! The API is accessible in 3 different ways: As a C function calls made inside the Wise2 package namespace - this is the way the current executables (eg, genewise) access the API, as C function calls made from outside the Wise2 package namespace - this is for people writing C programs with their own set of functions who do not want name clashes of things like ``Sequence'' (in this API the name is exported as ``Wise2\_Sequence''), and finally as a Perl API, using the XS extension code where C function calls which are dynamic loaded into the Perl interpretter can be executed as if they were standard Perl commands. Probably the most usable is the Perl API. Perl is a very forgiving language, and it is easier to learn for novice programmers - in particular memory management is handled for you. For people who want to use the Wise2 api from inside their own C program, I would use the external api. For people who want to extend wise2 programs to do other things, the internal api. \section{WARNING - still in alpha} After playing around with the API for a while, I have realised that a number of things are not clean enough in the interface. I am not currently considering the API to the 2.1.x series stable. An aim for the 2.2 series is to make a stable and useful API, that is well documented. However, this API does work, and there is this documentation for it, so it maybe worth people who like this sort of thing to play around with it. Anyone who uses the API gets huge guru points from me... \section{API generation} The API is not manually generated but rather is generated by the Dynamite compiler. Dynamite is a language which I wrote specifically for the Wise2 project: it is a cranky but useful language based heavily on C (it converts its source code to C), with a portion dedicated to dynamic programming code (a common algorithm in bioinformatics). It also has a lightweight object model that supports scalars and lists of types. Because the API is generated through Dynamite, you can expect consistent documentation and memory handling of all the functions and objects. \section{Getting Started for the impatient} Here is 3 different ways of using the Wise2 API to reverse complement a sequence. Once in perl, once using the name space protected API, and once using the internal API. These three programs all make the same output, using the same code. It is only how the programming is presented to the user (once in perl, twice in C) which changes. \subsection{Perl reverse complement} \begin{verbatim} #!/usr/local/bin/perl use Wise2; # loads in Wise2 api $file = shift; # first argument if( !defined $file ) { print "You must give a file to revcom for a reverse to work!"; exit(1); } $seq = &Wise2::Sequence::read_fasta_file_Sequence($file); $rev = $seq->revcomp(); print "Original sequence\n\n"; $seq->write_fasta(STDOUT); print "Reversed sequence\n\n"; $rev->write_fasta(STDOUT); \end{verbatim} \subsection{Wise2 external API calls} \begin{verbatim} #include "dyna_api.h" int main(int argc,char ** argv) { Wise2_Sequence * seq; Wise2_Sequence * rev; if( argc != 2 ) { fprintf(stderr,"have to give an argument for a file"); exit(1); } seq = Wise2_read_fasta_file_Sequence(argv[1]); if( seq == NULL ) { fprintf(stderr,"Unable to read fasta file in %s\n",argv[1]); exit(1); } rev = Wise2_reverse_complement_Sequence(seq); printf("Original sequence\n\n"); Wise2_write_fasta_Sequence(seq,stdout); printf("Revcomp sequence\n\n"); Wise2_write_fasta_Sequence(rev,stdout); Wise2_free_Sequence(seq); Wise2_free_Sequence(rev); } \end{verbatim} \subsection{Wise2 internal API calls} \begin{verbatim} #include "dyna.h" int main(int argc,char ** argv) { Sequence * seq; Sequence * rev; if( argc != 2 ) { fprintf(stderr,"have to give an argument for a file"); exit(1); } seq = read_fasta_file_Sequence(argv[1]); if( seq == NULL ) { fprintf(stderr,"Unable to read fasta file in %s\n",argv[1]); exit(1); } rev = reverse_complement_Sequence(seq); printf("Original sequence\n\n"); write_fasta_Sequence(seq,stdout); printf("Revcomp sequence\n\n"); write_fasta_Sequence(rev,stdout); free_Sequence(seq); free_Sequence(rev); } \end{verbatim} \section{Navigating the source code} The Wise2 api has a bewildering number of objects and functions, and the biggest problem in using the API is knowing which objects can be made from what. This next section walks you through at an object level how to do some common tasks. This list is in no way complete, but it is better than just browsing around the index. A very good place to start is to read the scripts in the perl/scripts area (halfwise.pl does not use the Wise2 API but all the others do). \subsection{Making a translation of a DNA sequence} \begin{itemize} \item Build a codon table object from a file (\ref{object_CodonTable}) \item Build a sequence object, from a file or strings (\ref{object_Sequence}) \item Use the translate function on the Sequence object \end{itemize} \subsection{Comparing two sequences using smith waterman} \begin{itemize} \item Build a Comparison matrix object from a file (\ref{object_CompMat}) \item Build two Sequence objects, from a file or strings (\ref{object_Sequence}) \item Optionally convert the Sequence objects into Protein objects (\ref{object_Protein}). This ensures you have proteins \item Read in the comparison matrix using CompMat (\ref{object_CompMat}) \item Use one of the algorithm calls in sw_wrap module (\ref{module_sw_wrap}) \item Show the alignment using a call in the seqaligndisaply module (\ref{module_seqaligndisplay}) \end{itemize} \subsection{Running a smith waterman search of single protein sequence vs a db} \begin{itemize} \item Read in a sequence object and convert it to a protein object (\ref{object_Protein},\ref{object_Sequence}) \item Make a protein database from the single protein object (\ref{object_ProteinDB}) \item Make a protein database from a single fasta file (\ref{object_ProteinDB}) \item Using one of the calls to the sw_wrap module, make a Hscore object (\ref{module_sw_wrap}) \item Show the Hscore object using a show function (\ref{object_Hscore}) \item Retrieve individual protein objects from the database by taking out the DataEntry objects (\ref{object_DataEntry}) and passing them into the ProteinDB object (\ref{object_ProteinDB}), giving you a protein object \item optionally align them as in the above section \end{itemize} \subsection{Running a genewise on a single protein vs a single DNA sequence} See the script genewise.pl in the distribution \begin{itemize} \item Make a Sequence object from a strings or a file (\ref{object_Sequence}) \item Make that a protein object (\ref{object_Protein}) \item Make a Sequence object from a string or a file (\ref{object_Sequence}) \item Make that a Genomic object (\ref{object_Genomic}) \item Add any additional repeat areas from external information to the genomic object \item Read in a gene frequency counts (\ref{object_GeneFrequency}) \item Read in a codon table (\ref{object_CodonTable}) \item Make a random DNA model (\ref{object_RandomModelDNA}) \item Make an algorithm type (\ref{module_gwrap}) \item Build an entire parameter set for genewise using Wise2::GeneParameter21_wrap (\ref{module_gwrap}) \item Run the actual algorithm (\ref{module_gwrap}) \item show the alignment using genedisplay (\ref{module_gwrap}) \end{itemize} \section{Concepts and overview of the API} The API is organised in the following way. There are 4 main areas of source code in the wise2 package \begin{itemize} \item wisebase - base memory, string and error handling libraries \item dynlibsrc - generic bioinformatics objects \item models - specific Wise2 objects \item HMMer2 - HMMER 2 (Sean Eddy's HMM package) \end{itemize} The API is mainly derived from the dynlibsrc and models directories. There is no distinction in the API of one directory from another \section{The reference section} The reference section is built automatically from the Dynamite source. This means that the function names, argument lists and in nearly all cases the documentation should be completely up to date with whatever version you got this documentation from. The code is divided up into modules: each module having potentially a number of objects in it and a number of free standing functions (factory functions). The documentation lists each object and the fields in the object which are accessible by the Perl API and the external API (more fields maybe accessible by the internal API, but generally these are not fields that you are expected to use). Fields can either be scalar or list types. In either case the scalar or list can either be a basic type or another object type. The following access methods are available for scalar types \subsection{Accessing fields in objects} \label{accessing_fields} In both the external API and the Perl API you can access all the fields via function calls. In Perl these function calls have the correct names space system to be called using the OOP syntax of Perl. \subsubsection{Perl scalar accessors} \begin{itemize} \item \$obj\->\emph{fieldname}() gets the value of this field \item \$obj\->set\_\emph{fieldname}(\emph{new value}) sets the value of this field \end{itemize} For example \begin{verbatim} $name = $seq->name(); # get the name of a sequence $seq->set_name('NewName'); # set the name of a sequence \end{verbatim} \subsubsection{External C scalar accessors} \begin{itemize} \item Wise2\_access\_\emph{fieldname}\_\emph{ObjectName}(obj) gets the value of this field \item Wise2\_replace\_\emph{fieldname}\_\emph{ObjectName}(obj,\emph{new value}) sets the value of this field \end{itemize} For example \begin{verbatim} char * name; Wise2_Sequence * seq; /* ... get a sequence object somehow ... */ name = Wise2_access_name_Sequence(seq); Wise2_replace_name_Sequence(seq,"NewName"); \end{verbatim} \subsubsection{Perl List accessors} \begin{itemize} \item \$obj\->each\_\emph{fieldname}() Gives a Perl array of all the items in a list \item \$obj\->length\_\emph{fieldname} Length of the list \item \$obj\->\emph{fieldname}(\$i) The ith member of the list \item \$obj\->add\_\emph{fieldname}(\$another\_obj) Adds another object to the list \item \$obj\->flush\_\emph{fieldname}() Destroys all the items in a list, sets list size to zero \end{itemize} \subsubsection{External API List accessors} \begin{itemize} \item Wise2\_access\_\emph{fieldname}\_\emph{ObjectName}(obj,i) access the ith position in the list \item Wise2\_flush\_\emph{fieldname}\_\emph{ObjectName}(obj) Flushes the list \item Wise2\_add\_\emph{fieldname}\_\emph{ObjectName}(obj,added\_object) Adds an object onto the end of the list \end{itemize} \subsection{Object Construction and handling} The good news is that in the Perl API \emph{all} the memory handling is managed between the Perl memory handling method and the Wise2 handling method. Bascially you can completely forget about these things and code normally in Perl and all the memory is handled for you. In the C external API, as in any C program, the programmer is responsible for the memory, and you need to read the documentation as to whether the objects you recieve from function calls need explict frees or not. \subsubsection{Low level Object Constructing} In both Perl and in C you have the possibility of making a new object from scratch. \begin{itemize} \item In Perl it is \$obj = new Wise2::\emph{ObjectName}; \item in C it is obj = \emph{ObjectName}\_alloc for objects with no lists, and obj = \emph{ObjectName}\_alloc\_std for objects with lists (this is a mistake in the API I know). \end{itemize} However I would read carefully the documentation for an object first, as in some cases the objects have to made through specific functions. These are likely to be things like new\_\emph{ObjectName} or such like. They are likely to be ``factory'' functions, that is functions not attached to any object. \subsubsection{Object deconstructors} In Perl you don't have to worry about this (heaven). In the C API you have two functions to handle the memory of objects. The objects have a reference counted memory: when the free function is called it decrements the object reference count and if this count hits 0 then the object itself is free'd. To up the reference count you call the hard\_link\_\emph{ObjectName} function. \begin{itemize} \item free\_\emph{ObjectName}(obj) Releases this pointer on this object \item obj = hard\_link\_\emph{ObjectName}() Adds this pointer to object, increasing the reference count \end{itemize} \section{Wise2 Specific Modules} There are a number of modules which are specific to Wise2 algorithms. These should be the starting point for how to use Wise2 algorithms: try to find a function in these modules which provide the functionality that you want. Then figure out how to make the appropiate objects to use this functionality. \begin{description} \item[gwrap] \ref{module_gwrap} The gwrap module has the main entry points for the genewise algorithm and how to build parameters for it \item[estwrap] \ref{module_estwrap} The estwrap module has the main entry points for the estwise algorithm \item[sw\_wrap] \ref{module_sw_wrap} The sw\_wrap has the main entry points for the smith waterman algorithm \item[genedisplay] \ref{module_genedisplay} The pretty ascii output used for genewise and estwise output \item[seqaligndisplay] \ref{module_seqaligndisplay} The pretty ascii output used for smith waterman alignments \item[threestatemodel] \ref{module_threestatemodel} profile-HMM support \item[threestatedb] \ref{module_threestatedb} profile-HMM database support \item[genefrequency] \ref{module_genefrequency} Raw counts for the genewise model \item[geneparameter] \ref{module_geneparameter} probabilities for the genewise model \item[cdparser] \ref{module_cdparser} probabilities for the estwise model \end{description} \section{Dynamite library modules} \subsection{Sequence modules} \begin{description} \item[sequence] \ref{module_sequence} Basic sequences \item[sequencedb] \ref{module_sequencedb} Basic sequence database \item[protein] \ref{module_protein} Protein specific type \item[proteindb] \ref{module_proteindb} Protein database \item[genomic] \ref{module_genomic} Genomic specific type \item[genomicdb] \ref{module_genomicdb} Genomic database \item[cdna] \ref{module_cdna} Cdna specific type \item[cdnadb] \ref{module_cdnadb} Cdna database \end{description} \subsection{Generic probabilistic modelling support} \begin{description} \item[probability] \ref{module_probability} Probability to log space conversions \item[codon] \ref{module_codon} Codon Table support \item[compmat] \ref{module_compmat} Protein Comparison matrix support \item[codonmat] \ref{module_codonmat} Codon Matrix comparison matrix \item[codonmapper] \ref{module_codonmapper} Codon bias/substitution errors support \end{description} \subsection{Generic Database Searching} \begin{description} \item[hscore] \ref{module_hscore} High Score list \item[histogram] \ref{module_histogram} Extreme Value distribution fitting \item[dbimpl] \ref{module_dbimpl} Database Implementation \end{description} \subsection{Generic Dynamite algorithm support} \begin{description} \item[aln] \ref{module_aln} Label alignments \item[packaln] \ref{module_packaln} Raw (low level) alignments \item[basematrix] \ref{module_basematrix} Memory management for DP implementations \end{description} wise-2.4.1/docs/makefile0000644000175000001440000000042407313404521014500 0ustar philippusers .SUFFIXES : .tex .dvi .ps dynamite : dynamite.ps dynamite.ps : dynamite.dvi dvips dynamite.dvi -o api : cat ../models/*.tex ../dynlibsrc/*.tex | perl gettex.pl > temp.tex cat wise2api.tex temp.tex apiend.tex > api.tex latex api.tex latex api.tex dvips api.dvi -o wise-2.4.1/docs/dynamite.tex0000644000175000001440000026336107313404521015347 0ustar philippusers\documentstyle{article} \begin{document} \newcommand{\programtext}[1]{{\tt #1}} \title{Dynamite Documentation, for version 1.5a} \author{Ewan Birney\\ Sanger Centre\\ Wellcome Trust Genome Campus\\ Hinxton, Cambridge CB10 1SA,\\ England.\\ Email: birney@sanger.ac.uk} \maketitle \newpage \tableofcontents \newpage \section{Introduction} Dynamite is a code generating language whose main purpose is to produce efficient code for dynamic programming. Dynamic programming is used throughout sequence analysis in a variety of different guises (sequence alignment, gene prediction etc). Dynamite is used extensively by myself (Ewan Birney), in particular for the Wise2 package. Dynamite itself is probably of interest to a small number of people, who are quite skilled programmers that want to make new algorithms. However the programs developed by Dynamite are potentially useful for many different people. The production of Dynamite has necessitated two other developments \begin{itemize} \item Firstly Dynamite has an internal ``object'' concept it uses. Dynamite is not a full OOP language, but rather can be classified as an Object based language. This is very useful for me internally, and may be useful for other people. In particular one development in this object model is to provide glue into Perl of the Dynamite objects. \item Secondly Dynamite requires a run-time library to link to. This run time library is designed inside Dynamite's object model, which provides a consistent way of handling objects. The run-time library does contain things which are very dynamite specific but alot of the code is generic sequence handling, codon handling etc. \end{itemize} \subsection{Thanks} Dynamite would not be possible without the help of a number of people. Richard Durbin, my supervisor has encouraged me and helped in the design of Dynamite. Ian Holmes has been a constant teacher of the theory behind this and a great help in many aspects of Dynamite. He also wrote the technical section at the end of this document. Lars Averstead helped by being an early tester and added some new functionality to the compiler. Finally I am very appreciative of the people who are currently struggling with Dynamite, such as Lisa Davies, Ramu Chenna and David Kulp. \subsection{How to read this documentation} Dynamite has quite a steep learning curve. This is due to three things \begin{itemize} \item Dynamite was written by a biochemist picking up Computer Science. The syntax is a little weird \item Dynamite provides a very flexible approach to dynamic programming. If you are not use to this class of algorithm then you will have to pick up some concepts on the way \item Dynamite is designed for library orientated C generation. You have to program ontop of the routines generated by Dynamite to provide an actual application. For people who aren't used to C, there is the C learning curve, which is not as shallow as, say, Perl \end{itemize} This means the people who are most at ease with Dynamite are those who know C and dynamic programming. Unfortunately these are the people with the least need for Dynamite! Here is some help for reading this documentation \subsubsection{Good C programmer, new to dynamic programming} Read the first example, and then the ``Use your own types'' section, (\ref{own_objects}), \subsubsection{new to C, familiar with dynamic programing/sequence alignment} Make sure your C set up is correct, by compiling (and running) a ``Hello World'' program. Read the examples, trying to compile and run them each time. \subsubsection{new to C, new to dynamic programming} The curve is particularly steep for you. You need to make sure your C set up is good (find someone who compiles C on your system to help you) and then try to read around the topic, partly using this documentation and other dynamic programming references. I learnt dynamic programming from ``Dynamic programming algorithms for biological sequence comparison.'', in Methods Enzymol 1992;210:575-601. I would highly recommend ``Biological sequence analysis'' by Messers Durbin, Eddy, Krogh and Mitchison. \section{An introduction to specific readers} Dynamite lies firmly between three different disciplines. The language has been specifically designed for bioinformatics problems, and therefore Dynamite could be of interest to people with a biochemical or molecular biology background. The algorithm basis however is the well known dynamic programming used in many aspects of computer science. In this case dynamite produces algorithms which are probably most similar to certain types of speech-recognition Hidden Markov Models, and in general considering these algorithms as probablistic finite state machines provides a neat theoretical way of setting parameters. Computer scientists may well be interested in Dynamite from this aspect. Finally Dynamite is interested in providing efficient, stable and extensible code, and there are aspects of Dynamite which are involved solely in programming issues. \subsection{Biological readers.} Dynamite is interested in making sequence alignment and database searching algorithms. It could be directly used, for example, to make an equivalent of SSEARCH in Bill Pearson's FASTA package. The BLAST algorithms can be considered as an approximation to such algorithm types: In the more recent BLAST2 and WU-BLAST packages, a deliberate 'gapped alignment' stage has been added which uses dynamic programming. A good introduction to Dynamic programming was written by Pearson and Miller in Methods in enzymology However there are a number of possible dynamic programming algorithms to represent different types of biology. If one accepts certain restrictions (in particular, each position in a sequence must be treated independantly of any distant other location in a sequence), then one can model quite complicated biological concepts inside the database search. For example, one can use the fact that alpha helices have different residue biases than beta strands inside the comparison of two proteins. \subsection{Computer science readers.} Dynamic programming is used in so many different areas it is hard to know how best to describe dynamite's role. The basic sequence alignment problem can be considered a shortest string edit problem, with somewhat arbitary costs for each edit coming from emperical estimates of biological mutations. Another rich vein of similarity is with Hidden Markov Modeling of speech. In this case a word may be represented by a series of states that emit speech waveform at certain probabilities and transitions between states have defined probabilities. The dynamic programming algorithm is an efficient form of calculating probabilities of observing a given waveform given that it came from this word. This can be done over all possible paths (summed in probability space) or be used to find the most likely path through the state network (Viterbi algorithm). In molecular biology, the waveform is protein or DNA sequence, and the word is a model of a protein structure. An excellent package for this is the HMMer package by Sean Eddy. The summed matrix is very useful for determining parameters of such a model simply from data: the viterbi form of DP is often used for determining whether a new sequence does or does not contain this protein structure. The final theoretical approach taken by many people has been a grammar based linguist approach to biological sequence analysis. This has many desirable features, in particular the heirarchy of phoneme, word, phrase, sentance etc seems very similar to the many biological heirarchies eg, base pair, exon, transcript, gene (to take one of many examples). Although the algorithms can be written as grammars, with classical grammar production rules, the traditional approach for parsing grammars, a depth first parse tree is rarely taken in biosequence analysis. Rather dynamic programming is employed which can be considered a breadth first approach. This is principly because in biosequence analysis there is no basic deterministic transitions, and all possible parses of a grammar are usually valid. Therefore depth first or complicated breadth first parsing does not help you in restricting the paths (or parses) that a ``sequence'' can take. In addition, it is likely that the memory is laid out arbitarily making implementations slow for unimportant reasons. However, parse trees often allow much greater flexibility in adding new components in particular in heirarchies. In many ways, dynamite is an attempt to provide the same sort of flexibility in being able to change the grammar without scarificing the implmentation speed. Searls and Murphy published a similar package to Dynamite focusing on some of the more theoretical aspects of Finite State Machines. Dynamite is more focused on practical aspects of the problem. \subsection{Programmers} I started out as a biologist. (I am not sure what I am now). Dynamite has really suffered from having to cope with some tough programming concepts in an pretty naive mind. Dynamite acts as a C-generating machine. You could think of it as a poorly written Cfront, or a program rather like yacc or a complex function template in C++. Because Dynamite has to produce reasonably efficient code it produces probably far too much C where I have by and large trusted the C optimiser to do a good job on it. The dynamic programming algorithm has been implemented in many different ways. In perhaps its cleanest view, it can represented as an directed acyclic graph with different weights on each arc. The 'best' (depending on your definition of best, max or min) path needs to be found (this is the viterbi algorithm). This view however takes away a level of granularity of the DP problem as presented in biology. In essence there is one sub graph which is used to produce the entire graph, just that each sub graph is reparameterised on the basis of its position in the full graph. The inner loop of the algorithm therefore is usually written with the sub-graph explicitly laid out in the code, allowing for very good optimisation of memory look ups and also potential for micro-parallelisation (if the sub-graph allows it). The dynamite definition is precisely this sub-graph. At a coarser level, the algorithms are used in a ``embarrasingly parallel'' fashion of it simply being repeated for a series of objects for a database search. There is no link between each object in terms of which ones need to be done first. Therefore very simple parallelisation strategies can be used. So, in terms of implementation, there are many avenues to improve efficiency. These range from specialised hardware implementations which are flexible enough to take a sub-set of biologically sensible dynamic programming algorithms to simple pthreaded code for SMP boxees The hope is that dynamite can hide the implementation development from the algorithm development, allowing people to focus on one or the other without having to worry that they will not be able to take advantage of the best algorithms or machines respectively. \section{I'm here to help} I am well aware that the learning curve to Dynamite is quite steep. Dynamite is my own language and suffers from the fact that it has been developed with only really one user. At the moment I am trying very hard to make it more useful to other people. (This documentation is a start). If you do find something confusing, please email me (birney@sanger.ac.uk) and I'll get a reply as soon as I can, usually within a day. \section{Overview of Dynamite (for programmers)} Programmers may appreciate a quick top-level overview of Dynamite. You can separate dynamite into 3 areas: the dynamite compiler which produces the C code, (acting much like yacc), the dynamite support libraries which are required for this code to run, ie hold some generic matrix and alignment structures, and the dynamite run-time library which provides predefined biologically relevant types. The run-time library and the dynamite compiler can communicate certain concepts through a file called 'methods' which is bit like a dynamite compiler headerfile. When you are starting with Dynamite is probably not worth using this system, but if you want to get into the database searching aspects of dynamite, it is a necessity. This communication allows a stronger form of typing than offered by the C implementation: in particular macros can be typed using this method. In addition the communication is on a biologically 'logical' level so theoretically one can drop out the dynamite run-time library, replace it with one's own specific biological typed library (the ncbi toolkit for example) and recompile with a new 'methods' file. This has to assumme that certain biological concepts are represented in a particular way (for example, Base A is represented by 0, Base C 1 etc), but does allow the underlying data structures complete freedom. If that's all gibberish, then wait until I get around to writing an example of swapping dynamite run-time libraries. \section{Installation} The installation is a pretty straight forward on UNIX machines. Pick up the distribution from 'ftp://ftp.sanger.ac.uk/pub/birney/dynamite/dyn.x.tar.Z' (where x is the latest release). Then uncompress and untar, cd into the directory made (something like dyn1.0a) and type make ie: \begin{verbatim} %zcat dyn1.0a.tar.Z | tar -xvf - %cd dyn1.0a %make %cd examples \end{verbatim} I have not tested dynamite out at all on non UNIX systems. To make on linux systems go \begin{verbatim} %cd dyc %make linux \end{verbatim} \section{Example1 (psw)} Enough waffle! Lets see a real life example of a piece of code. This can be found in the examples directory For our first example we'll take the well known case of smith waterman protein alignment. This aligns to proteins using a comparison matrix and gap penalties \subsection{proteinsw.dy} proteinsw.dy is the actual dynamite source file to describe smith waterman. \begin{verbatim} %{ #include "dyna.h" %} matrix ProteinSW query type="PROTEIN" name="query" target type="PROTEIN" name="target" resource type="COMPMAT" name="comp" resource type="int" name="gap" resource type="int" name="ext" state MATCH offi="1" offj="1" calc="AAMATCH(comp,AMINOACID(query,i),AMINOACID(target,j))" source MATCH calc="0" endsource source INSERT calc="0" endsource source DELETE calc="0" endsource source START calc="0" endsource query_label SEQUENCE target_label SEQUENCE endstate state INSERT offi="0" offj="1" source MATCH calc="gap" endsource source INSERT calc="ext" endsource query_label INSERT target_label SEQUENCE endstate state DELETE offi="1" offj="0" source MATCH calc="gap" endsource source DELETE calc="ext" endsource query_label SEQUENCE target_label INSERT endstate state START !special !start query_label START target_label START endstate state END !special !end source MATCH calc="0" endsource query_label END target_label END endstate endmatrix \end{verbatim} This file provides a single Dynamite defintion. Lets ignore the precise definitions and concentrate on how to use this file to make a workable application. At the moment there is no option for the dynamite compiler to build all the necessary C code including the main function and 'pretty' output displays. To make the actual dynamite code one needs to compile the file proteinsw.dy with dyc (the dynamite compiler). This makes a .c and a .h file of ANSI C code \begin{verbatim} %pwd /nfs/disk21/birney/prog/dyn_release/dyn1.0a/examples %../bin/dyc proteinsw.dy %more proteinsw.c #ifdef _cplusplus extern "C" { #endif #include "proteinsw.h" # line 5 "proteinsw.c" /***************** C functions ****************/ /* Written using dynamite */ /* Wed Jan 21 15:04:45 1998 */ /* email birney@sanger.ac.uk */ /* http://www.sanger.ac.uk/Software/Dynamite */ /*************************************************/ \end{verbatim} Then this file can be compiled to a .o file and linked to an appropiate ``driver'' main C file. In this example it is in psw.c \subsection{psw.c (driver file)} psw.c contains the main function which is going to actually use the function code produced from proteinsw.dy \begin{verbatim} /* * include proteinsw.h - will include the dynamite * produced declarations provided */ #include "proteinsw.h" /* * seqaligndisplay - fancy display * */ #include "seqaligndisplay.h" void show_help(FILE * ofp) { fprintf(ofp,"\npsw seq1 seq2\nBoth sequences in fasta format\n" "\tOPTIONS\n" "\t-g gap penalty (default 12)\n" "\t-e ext penatly (default 2)\n" "\t-m comp matrix (default blosum62.bla)\n" "\t-r show raw output\n" "\t-l show label output\n" "\t-f show fancy output\n" "\t (default, -f, all outputs can be shown together\n" ); } int main(int argc,char ** argv) { Sequence * query; Sequence * target; ComplexSequence * query_cs; ComplexSequence * target_cs; ComplexSequenceEvalSet * evalfunc; CompMat * comp; char * comp_file; int gap = (12); int ext = (2); boolean show_raw_output = FALSE; boolean show_label_output = FALSE; boolean show_fancy_output = FALSE; boolean has_outputted = FALSE; PackAln * pal; AlnBlock * alb; /* * Process command line options * -h or -help gives us help * -g for gap value (an int) - rely on commandline error processing * -e for ext value (an int) - rely on commandline error processing * -m for matrix (a char) * -r - raw matrix output * -l - label output * -f - fancy output * * * Use calls to commandline.h functions * */ if( strip_out_boolean_argument(&argc,argv,"h") == TRUE || strip_out_boolean_argument(&argc,argv,"-help") == TRUE) { show_help(stdout); exit(1); } show_raw_output = strip_out_boolean_argument(&argc,argv,"r"); show_label_output = strip_out_boolean_argument(&argc,argv,"l"); show_fancy_output = strip_out_boolean_argument(&argc,argv,"f"); /** if all FALSE, set fancy to TRUE **/ if( show_raw_output == FALSE && show_label_output == FALSE ) show_fancy_output = TRUE; (void) strip_out_integer_argument(&argc,argv,"g",&gap); (void) strip_out_integer_argument(&argc,argv,"e",&ext); comp_file = strip_out_assigned_argument(&argc,argv,"m"); if( comp_file == NULL) comp_file = "blosum62.bla"; if( argc != 3 ) { warn("Must have two arguments for sequence 1 and sequence 2 %d",argc); show_help(stdout); exit(1); } /* * Read in two sequences */ if( (query=read_fasta_file_Sequence(argv[1])) == NULL ) { fatal("Unable to read the sequence in file %s",argv[1]); } if( (target=read_fasta_file_Sequence(argv[2])) == NULL ) { fatal("Unable to read the sequence in file %s",argv[2]); } /* * Open a blosum matrix. This will be opened from WISECONFIGDIR * or WISEPERSONALDIR if it is not present in the current directory. */ comp = read_Blast_file_CompMat(comp_file); if( comp == NULL ) { fatal("unable to read file %s",comp_file); } /* * Convert sequences to ComplexSequences: * To do this we need an protein ComplexSequenceEvalSet * */ evalfunc = default_aminoacid_ComplexSequenceEvalSet(); query_cs = new_ComplexSequence(query,evalfunc); if( query_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",query->name); } target_cs = new_ComplexSequence(target,evalfunc); if( target_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",target->name); } /* * Make an alignment. I don't care about the implementation: * If the sequences are small enough then it should use explicit memory. * Long sequences should use divide and conquor methods. * * Calling PackAln_bestmemory_ProteinSW is the answer * This function decides on the best method considering the * memory and changes accordingly. It frees the matrix memory * at the end as well. * */ pal = PackAln_bestmemory_ProteinSW(query_cs,target_cs,comp,-gap,-ext,NULL); if( pal == NULL ) { fatal("Unable to make an alignment from %s and %s",query->name,target->name); } /* * ok, make other alignment forms, and be ready to show */ alb = convert_PackAln_to_AlnBlock_ProteinSW(pal); /* * show output. If multiple outputs, divide using // */ if( show_raw_output == TRUE ) { show_simple_PackAln(pal,stdout); puts("//\n"); } if( show_label_output == TRUE ) { show_flat_AlnBlock(alb,stdout); } if( show_fancy_output == TRUE ) { write_pretty_seq_align(alb,query,target,15,50,stdout); puts("//\n"); } /* * Destroy the memory. */ free_Sequence(query); free_Sequence(target); free_CompMat(comp); free_ComplexSequence(query_cs); free_ComplexSequence(target_cs); free_PackAln(pal); free_AlnBlock(alb); return 0; } \end{verbatim} This seems to have alot of code to do a simple thing. However, if you notice, most of the code in interested in I/O. The core algorithm is in this section \begin{verbatim} /* * Convert sequences to ComplexSequences: * To do this we need an protein ComplexSequenceEvalSet * */ evalfunc = default_aminoacid_ComplexSequenceEvalSet(); query_cs = new_ComplexSequence(query,evalfunc); if( query_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",query->name); } target_cs = new_ComplexSequence(target,evalfunc); if( target_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",target->name); } /* * Make an alignment. I don't care about the implementation: * If the sequences are small enough then it should use explicit memory. * Long sequences should use divide and conquor methods. * * Calling PackAln_bestmemory_ProteinSW is the answer * This function decides on the best method considering the * memory and changes accordingly. It frees the matrix memory * at the end as well. * */ pal = PackAln_bestmemory_ProteinSW(query_cs,target_cs,comp,-gap,-ext,NULL); if( pal == NULL ) { fatal("Unable to make an alignment from %s and %s",query->name,target->name); } \end{verbatim} There are two things going on here. The call \begin{verbatim} pal = PackAln_bestmemory_ProteinSW(query_cs,target_cs,comp,-gap,-ext); \end{verbatim} is there the actual call to the dynamite produced algorithm. It is only one function - dynamite has done all the decision making about what implementation of the algorithm to use, and also the algorithm itself and free'd all memory usage. Before that there was the rather counter intuitive production of 'ComplexSequence' objects in lines like \begin{verbatim} query_cs = new_ComplexSequence(query,evalfunc); if( query_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",query->name); } \end{verbatim} Why do this? Well the answer is that Dynamite really needs a slightly more extended concept of a 'sequence' to allow to cope with things like splice sites or repeats (to give two obvious example) which somehow exsist in DNA sequence without being easily derivable from the sequence. (A deeper answer is that the dynamite configuration setup which has been shipped with the dynamite compiler has provided this need for ComplexSequences. In fact this configuration can change, allowing dynamite to produce code for nearly any type of data layout that can be got at via C syntax. But that's beyond the scope of this level of explanation) The only thing at the moment you need to realise is that \begin{itemize} \item Each 'type' of biological sequence is going to represented by a specific ComplexSequenceEvalSet. This ComplexSequenceEvalSet maps a sequence to the correct data layout for the algorithm \item The dynamite run-time libary contains default ComplexSequenceEvalSet's for protein, cdna and genomic types \end{itemize} \subsection{Running the example} Lets make and run the example \begin{verbatim} %make psw %psw Warning Error Must have two arguments for sequence 1 and sequence 2 1 psw seq1 seq2 Both sequences in fasta format OPTIONS -g gap penalty (default 12) -e ext penatly (default 2) -m comp matrix (default blosum62.bla) -r show raw output -l show label output -f show fancy output (default, -f, all outputs can be shown together %psw roac.pep roah.pep Q22037 EPENLRKIFVGGLTSNTTDDLMREFYSQFGEITDIIVMRDPTTKRSRGF EPE LRK+F+GGL+ TTD+ +R + Q+G +TD +VMRDP TKRSRGF ROA1_HUMAN EPEQLRKLFIGGLSFETTDESLRSHFEQWGTLTDCVVMRDPNTKRSRGF Q22037 GFVTFSGKTEVDAAMKQRPHIIDGKTVDPKRAVPRDDKNRSESNVSTKR GFVT++ EVDAAM RPH +DG+ V+PKRAV R+D R ++++ K+ ROA1_HUMAN GFVTYATVEEVDAAMNARPHKVDGRVVEPKRAVSREDSQRPGAHLTVKK Q22037 LYVSGVREDHTEDMLTEYFTKYGTVTKSEIILDKATQKPRGFGFVTFDD ++V G++ED E L +YF +YG + EI+ D+ + K RGF FVTFDD ROA1_HUMAN IFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAFVTFDD Q22037 HDSVDQCVLQKSHMVNGHRCDVRKGLSKDEMSKAQMNRDRETRGGRSRD HDSVD+ V+QK H VNGH C+VRK LSK EM+ A ++ GRS ROA1_HUMAN HDSVDKIVIQKYHTVNGHNCEVRKALSKQEMASAS-----SSQRGRSGS Q22037 GQRGGYNGGG-GGGGGWGGPAQRGGPGAYGGP-GGGGQGGYGGDYGG-- G GG GGG GG +G G G +GG GGGG GG G Y G ROA1_HUMAN GNFGGGRGGGFGGNDNFGRGGNFSGRGGFGGSRGGGGYGGSGDGYNGFG Q22037 GWGQQGGGGQGGWGGPQQQQGGG-GWGQQGGGGQGGWGGPQQQQQGGWG G GGGG G GG + GG G+G QG G GG G GG ROA1_HUMAN NDGGYGGGGPGYSGGSRGYGSGGQGYGNQGSG-YGGSGSYDSYNNGGGR Q22037 GPQQGGGGGGWGGQGQQQGGWGGQSGAQQWAHAQGGN G GG G +GG G + + + +GGN ROA1_HUMAN G-FGGGSGSNFGGGGSYNDFGNYNNQSSNFGPMKGGN // \end{verbatim} This gives back what you expect: the smith waterman alignment of the two proteins \section{Explaining proteinsw.dy} Lets go back to proteinsw.dy to find out how this file represents the smith waterman algorithm. To calculate the algorithm one needs 5 pieecs of data \begin{itemize} \item Two sequences \item A comparison matrix of 20x20 amino acids for the match of each amino acid \item Gap open penalty \item Gap extension penalty \end{itemize} To calculate the alignment one would take a mathematical recursion something like \begin{verbatim} (Pseudo-code) N = length of sequence 1 M = length of sequence 2 best = -infinity Match[N][M] = -infinity Insert[N][M] = -infinity Delete[N][M] = -infinity for( i goes 0 to N-1) for( j goes 0 to M-1) Match(i,j) = max { 0, Match(i-1,j-1), Insert(i-1,j-1), Delete(i-1,j-1) } + MatchScore(seq[i],seq[j]) Insert(i,j) = max { Match(i-1,j) - gap_open, Insert(i-1,j) - gap_ext } Delete(i,j) = max { Match(i,j-1) - gap_open, Delete(i,j-1) - gap_ext } best = max(best,Match(i,j)) return best \end{verbatim} The alignment is the set of (i,j,) triples, where state is one of (Match,Insert,Delete) which provided the best score. Sometimes this algorithm is written in a different way with a concept of a 'cell'. There is absolutely no difference of this form compared to the upper form. \begin{verbatim} for( i goes 0 to N-1) for( j goes 0 to M-1) Cell(i,j).Match = max { 0, Match(i-1,j-1), Insert(i-1,j-1), Delete(i-1,j-1) } + MatchScore(seq[i],seq[j]) Cell(i,j).Insert= max { Match(i-1,j) - gap_open, Insert(i-1,j) - gap_ext } Cell(i,j).Delete= max { Match(i,j-1) - gap_open, Delete(i,j-1) - gap_ext } best = max(best,Cell(i,j).Match) \end{verbatim} Now lets look at the Dynamite definition file: The dynamite definition is started by a idenitifer for this code and finished with an endmatrix line \begin{verbatim} matrix ProteinSW endmatrix \end{verbatim} The 5 pieces of data are passed in at the top of the file \begin{verbatim} query type="PROTEIN" name="query" target type="PROTEIN" name="target" resource type="COMPMAT" name="comp" resource type="int" name="gap" resource type="int" name="ext" \end{verbatim} The two sequences are given special 'resource' types called query and target, meaning this are the two datatypes which are laid along the axis of the matrix. This is not so important for the calculation of a single matrix, but is important for the database searching modes. The rest of the dynamite definition is interested in the actual recursion defintions. You can see the similarity of the recursion and the state defintions: Each 'cell unit' or matrix (like Match, Insert or Delete) are provided with a state ... endstate set of lines. Inside each state lines are the 'source' lines which indicate the calculations done to define each number. Most times these calculations are done inside the max line of the different possible ways of making the numbers, but some of these calculations (for example, MatchScore(seq1[i],seq2[j]) ) can occur outside of the max system. \begin{verbatim} state MATCH offi="1" offj="1" calc="AAMATCH(comp,AMINOACID(query,i),AMINOACID(target,j))" source MATCH calc="0" endsource source INSERT calc="0" endsource source DELETE calc="0" endsource source START calc="0" endsource query_label SEQUENCE target_label SEQUENCE endstate state INSERT offi="0" offj="1" source MATCH calc="gap" endsource source INSERT calc="ext" endsource query_label INSERT target_label SEQUENCE endstate state DELETE offi="1" offj="0" source MATCH calc="gap" endsource source DELETE calc="ext" endsource query_label SEQUENCE target_label INSERT endstate \end{verbatim} As this is the core of the dynamite defintion, lets review some of the needs of state and source lines \begin{itemize} \item Each state name must be unique \item Each source name must reference a state \item Each source must have a valid offi (offset in i) and offj (offset in j) line. These lines can be defined as defaults for the entire states. \item Each source must have a calc line, even if that is calc="0" \item Each source must have a query and target label. These can be defined as state defaults. (We'll see more about labels /{labels} later/) \item Each state can have an optional calc line which is notionally 'added' to each source's calc line. (the implementation does make efficient use of this, and adds it after the max calculation if you are interested). \end{itemize} Because of the use of the state defaults issue, this means I could have written the MATCH state as follows: \begin{verbatim} state MATCH source MATCH offi="1" offj="1" calc="AAMATCH(comp,AMINOACID(query,i),AMINOACID(target,j))" query_label SEQUENCE target_label SEQUENCE endsource source INSERT offi="1" offj="1" calc="AAMATCH(comp,AMINOACID(query,i),AMINOACID(target,j))" query_label SEQUENCE target_label SEQUENCE endsource source DELETE offi="1" offj="1" calc="AAMATCH(comp,AMINOACID(query,i),AMINOACID(target,j))" query_label SEQUENCE target_label SEQUENCE endsource source START offi="1" offj="1" calc="AAMATCH(comp,AMINOACID(query,i),AMINOACID(target,j))" query_label SEQUENCE target_label SEQUENCE endsource endstate \end{verbatim} But as you can see this is a much longer definition, and if you want to change something then you have to edit quite a few lines. In addition the dynamite compiler is not yet clever enough to figure out that the calc lines are identical and therefore can be optimised. (your C optimiser may however manage this!). The final point of the dynamite defintion is to define start and end points. In smith waterman you 'start at any point' and 'end at any point' (actually not true. You can start in any match, and end in any match in one interpretation). This is represented in Dynamite as two states, both are *special* states, which are used in a broader context later, and one has the identifier !start, and one !end. I tend to actually call the states START and END, but this is not required \begin{verbatim} state START !special !start query_label START target_label START endstate state END !special !end source MATCH calc="0" endsource query_label END target_label END endstate \end{verbatim} The end state here is updated for all MATCH states, and provides the best score over the alignment. Just to review the start/end initiation of the matrix, these are the definitions which are requires \begin{itemize} \item Each matrix must have one start state, called anything, with !start and !special defined \item Each matrix must have one end state, called anything, with !end and !special defined \end{itemize} The start state is the only state which is initialised to zero. This means that all alignments must start in the start state. The end of alignment is considered to be the end state with the highest score. As you might see, dynamite can code for many other algorithms than just smith waterman. Lets see another example, est2gen \section{Example2 (est2gen)} est2gen compares an est sequence to genomic sequence. In this case, assuming that the est sequence came from the same gene we have two different processes occuring: \begin{itemize} \item There are sequencing errors in the est sequence (? and maybe the genomic sequence) \item There are introns in the genomic sequence which are not present in the est sequence \end{itemize} The intron is going to look like a 'long gap' in the est sequence. We are going to have 'short gaps' as well in the est sequence compared to the genomic sequence because of sequencing error. In addition introns are going to be started with GT (perhaps a better description would be good) and finish with AG. The solution is to write a dynamite definition file which has two types of gaps in the genomic direction, indicated by the different state, GENOMIC\_INSERT and GENOMIC\_INTRON. Notice how the source lines to and from GENOMIC\_INSERT and GENOMIC\_INTRON are different \begin{verbatim} %{ #include "dyna.h" #define DnaMatrix_Score(dnamat,base1,base2) (dnamat->score[base1][base2]) %} type DNAMAT real DnaMatrix* endtype method DNA_MAT_SCORE map DnaMatrix_Score arg DNAMAT arg base arg base return int endmethod matrix cDNA2Gen query type="CDNA" name="query" target type="GENOMIC" name="target" resource type="DNAMAT" name="dm" resource type="Score" name="cdna_open" resource type="Score" name="cdna_ext" resource type="Score" name="gen_open" resource type="Score" name="gen_ext" resource type="Score" name="intron_open" state MATCH offi="1" offj="1" calc="DNA_MAT_SCORE(dm,CDNA_BASE(query,i),GENOMIC_BASE(target,j))" source MATCH calc="0" endsource source CDNA_INSERT calc="0" endsource source START calc="0" endsource source GENOMIC_INSERT calc="0" endsource source GENOMIC_INTRON calc="GENOMIC_3SS(target,j-1)" target_label 3SS endsource query_label SEQUENCE target_label SEQUENCE endstate state CDNA_INSERT offi="1" offj="0" source MATCH calc="cdna_open" endsource source CDNA_INSERT calc="cdna_ext" endsource query_label SEQUENCE target_label INSERT endstate state GENOMIC_INSERT offi="0" offj="1" source MATCH calc="gen_open" endsource source GENOMIC_INSERT calc="gen_ext" endsource query_label INSERT target_label SEQUENCE endstate state GENOMIC_INTRON offi="0" offj="1" source MATCH offj="1" calc="GENOMIC_5SS(target,j) + intron_open" target_label 5SS endsource source GENOMIC_INTRON calc="0" endsource query_label INSERT target_label CENTRAL_INTRON endstate state START !special !start endstate state END !special !end source MATCH calc="0" endsource query_label END target_label END endstate collapse INSERT CENTRAL_INTRON endmatrix \end{verbatim} Now, this file shows two different features of dynamite: \begin{itemize} \item Using different states (GENOMIC\_INTRON and GENOMIC\_INSERT) to represent different gapping types \item Using different types in dynamite \end{itemize} Let's just look at the driver C file first, to see how we will run the program \begin{verbatim} /* * include cdna2genomic.h - will include the dynamite * produced declarations provided */ #include "cdna2genomic.h" /* * fancy display */ #include "estgendisplay.h" void show_help(FILE * ofp) { fprintf(ofp,"\nest2gen est-seq genomic-seq\nBoth sequences in fasta format\n" "\tOPTIONS\n" "\t-g gap penalty (default 2)\n" "\t-e ext penatly (default 1)\n" "\t-m match score (default 4)\n" "\t-n mismatch score (default -3)\n" "\t-r show raw output\n" "\t-l show label output\n" "\t-f show fancy output\n" "\t (default, -f, all outputs can be shown together\n)" ); } int main(int argc,char ** argv) { Sequence * query; Sequence * target; ComplexSequence * query_cs; ComplexSequence * target_cs; int gap = (2); int ext = (1); int match = (4); int mismatch = (-3); Score cdna_open,cdna_ext,gen_open,gen_ext,intron_open; DnaMatrix * dm; ComplexSequenceEvalSet * cses_g; ComplexSequenceEvalSet * cses_c; boolean show_raw_output = FALSE; boolean show_label_output = FALSE; boolean show_fancy_output = FALSE; boolean has_outputted = FALSE; PackAln * pal; AlnBlock * alb; /* * Process command line options * * Use calls to commandline.h functions * */ if( strip_out_boolean_argument(&argc,argv,"h") == TRUE || strip_out_boolean_argument(&argc,argv,"-help") == TRUE) { show_help(stdout); exit(1); } show_raw_output = strip_out_boolean_argument(&argc,argv,"r"); show_label_output = strip_out_boolean_argument(&argc,argv,"l"); show_fancy_output = strip_out_boolean_argument(&argc,argv,"f"); /** if all FALSE, set fancy to TRUE **/ if( show_raw_output == FALSE && show_label_output == FALSE ) show_fancy_output = TRUE; (void) strip_out_integer_argument(&argc,argv,"g",&gap); (void) strip_out_integer_argument(&argc,argv,"e",&ext); (void) strip_out_integer_argument(&argc,argv,"m",&match); (void) strip_out_integer_argument(&argc,argv,"n",&mismatch); if( argc != 3 ) { warn("Must have two arguments for sequence 1 and sequence 2 %d",argc); show_help(stdout); exit(1); } /* * Read in two sequences */ if( (query=read_fasta_file_Sequence(argv[1])) == NULL ) { fatal("Unable to read the sequence in file %s",argv[1]); } if( (target=read_fasta_file_Sequence(argv[2])) == NULL ) { fatal("Unable to read the sequence in file %s",argv[2]); } /* * build dna matrix */ dm = identity_DnaMatrix(match,mismatch); /* * Convert sequences to ComplexSequences: * To do this we need a cdna ComplexSequenceEvalSet and a genomic one * * Really our genomic model should be alot more complex. The 'default' one * has 0 at GT----AG for 5' and 3' splice sites, and NEGI (= -infinity) * elsewhere. * * We could build up something much better, using complexconsensi and * other machinery, but not for now . See the genewise code if you * want to get scared. */ cses_g = default_genomic_ComplexSequenceEvalSet(); cses_c = default_cDNA_ComplexSequenceEvalSet(); query_cs = new_ComplexSequence(query,cses_c); if( query_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",query->name); } target_cs = new_ComplexSequence(target,cses_g); if( target_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",target->name); } free_ComplexSequenceEvalSet(cses_g); free_ComplexSequenceEvalSet(cses_c); /* * Make an alignment using best memory * * cDNA2Gen has alot more parameter space than the parameters to this * program. Firstly we are treating errors similarly on each side of the * sequences (? correct). * * Secondly there is a rather complex interaction between the gap/extension * of what is thought to be sequencing error and the introns. Here we have * one more parameter, and intron open penalty, which can be set, to prevent * the more permissive use of introns to 'cheat' gaps. * * One good way to parameterise all this would be to have a probabilistic * model of the processes, derive probabilities and then map them to ints * (probability.h has got these mappings, such as Probability2Score). * * but this is not done here... */ pal = PackAln_bestmemory_cDNA2Gen(query_cs,target_cs,dm,gap,-ext,-gap,-ext,0,NULL); if( pal == NULL ) { fatal("Unable to make an alignment from %s and %s",query->name,target->name); } /* * ok, make other alignment forms, and be ready to show */ alb = convert_PackAln_to_AlnBlock_cDNA2Gen(pal); /* * show output. If multiple outputs, divide using // */ if( show_raw_output == TRUE ) { show_simple_PackAln(pal,stdout); puts("//\n"); } if( show_label_output == TRUE ) { show_flat_AlnBlock(alb,stdout); puts("//\n"); } if( show_fancy_output == TRUE ) { write_pretty_estgen_seq_align(alb,query,target,15,50,stdout); puts("//\n"); } /* * Destroy the memory. */ free_Sequence(query); free_Sequence(target); free_DnaMatrix(dm); free_ComplexSequence(query_cs); free_ComplexSequence(target_cs); free_PackAln(pal); free_AlnBlock(alb); return 0; } \end{verbatim} Basically this looks the same as the previous example program. The line \begin{verbatim} pal = PackAln_bestmemory_cDNA2Gen(query_cs,target_cs,dm,gap,-ext,-gap,-ext,0); \end{verbatim} is the major algorithm call. Notice the rather different 'ComplexSequence' building. Here we need two different complexsequence builds, one for the genomic dna and one for the cdna. \begin{verbatim} /* * Convert sequences to ComplexSequences: * To do this we need a cdna ComplexSequenceEvalSet and a genomic one * * Really our genomic model should be alot more complex. The 'default' one * has 0 at GT----AG for 5' and 3' splice sites, and NEGI (= -infinity) * elsewhere. * * We could build up something much better, using complexconsensi and * other machinery, but not for now . See the genewise code if you * want to get scared. */ cses_g = default_genomic_ComplexSequenceEvalSet(); cses_c = default_cDNA_ComplexSequenceEvalSet(); query_cs = new_ComplexSequence(query,cses_c); if( query_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",query->name); } target_cs = new_ComplexSequence(target,cses_g); if( target_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",target->name); } free_ComplexSequenceEvalSet(cses_g); free_ComplexSequenceEvalSet(cses_c); \end{verbatim} This example can be made and tested by \begin{verbatim} %make est2gen %est2gen hn.est hn.gen HSHNCPA1 1 GGTGGCATTAAAGAAGACACTGAAGAACATCACCTAAGAGATGGT-TAT GGTGGCATTAAAGAAGACACTGAAGAACATCACCTAAGAGAT T T T HSHNRNPA 2132 GGTGGCATTAAAGAAGACACTGAAGAACATCACCTAAGAGAT--TAT-T HSHNCPA1 49 TTGAACAGTATGGAAAAATTGAAGTGATTGAAATCATGACTGACCGAGG TTGAACAGTATGGAAAAATTGAAGTGATTGAAATCATGACTGACCGAGG HSHNRNPA 2178 TTGAACAGTATGGAAAAATTGAAGTGATTGAAATCATGACTGACCGAGG HSHNCPA1 98 CAGTGGCAAGAAAAGGGGCTTTGCCT-TAGTAACCTTTGACGACCATGA CAGTGGCAAGAAAAGGGGCTTTGCCT T GTAACCTTTGACGACCATGA HSHNRNPA 2227 CAGTGGCAAGAAAAGGGGCTTTGCCTTT-GTAACCTTTGACGACCATGA HSHNCPA1 146 CTCCGTGGATAAGATTGTCA TTCAGAAATACCATAC CTCCGTGGATAAGATTGTCA TTCAGAAATACCATAC HSHNRNPA 2275 CTCCGTGGATAAGATTGTCA<-2295:2387->TTCAGAAATACCATAC HSHNCPA1 182 TGTGAATGGCCACAACTGTGAAGTTAGAAAAGCCCTGTCAAAGCAAGAG TGTGAATGGCCACAACTGTGAAGTTAGAAAAGCCCTGTCAAAGCAAGAG HSHNRNPA 2404 TGTGAATGGCCACAACTGTGAAGTTAGAAAAGCCCTGTCAAAGCAAGAG HSHNCPA1 231 ATGGCTAGTGCTTCATCCAGCCAAAGAG GTCGAAGT ATGGCTAGTGCTTCATCCAGCCAAAGAG GTCGAAGT HSHNRNPA 2453 ATGGCTAGTGCTTCATCCAGCCAAAGAG<-2481:2566->GTCGAAGT HSHNCPA1 267 GGTTCTGGAAACTTTGGTGGTGGTCGTGGAGGTGGTTTCGGTGGGAATG GGTTCTGGAAACTTTGGTGGTGGTCGTGGAGGTGGTTTCGGTGGGAATG HSHNRNPA 2575 GGTTCTGGAAACTTTGGTGGTGGTCGTGGAGGTGGTTTCGGTGGGAATG HSHNCPA1 316 ACAACTTCGGTCGTGGAGGAAACTTCAGTGGTCGTG ACAACTTCGGTCGTGGAGGAAACTTCAGTGGTCGTG HSHNRNPA 2624 ACAACTTCGGTCGTGGAGGAAACTTCAGTGGTCGTG<-2660:2793-> HSHNCPA1 352 GTNG-CTTTGGTGGCAGCCGTGGTGGTGGTGGATATGGTGGCAGTGGGG GT G CTTTGGTGGCAGCCGTGGTGGTGGTGGATATGGTGGCAGTGGGG HSHNRNPA 2794 GT-GGCTTTGGTGGCAGCCGTGGTGGTGGTGGATATGGTGGCAGTGGGG HSHNCPA1 400 ATGGCTATAATGGATTTGGCAATGATG GAAGCAATT ATGGCTATAATGGATTTGGCAATGATG GAAGCAATT HSHNRNPA 2842 ATGGCTATAATGGATTTGGCAATGATG<-2869:3805->GAAGCAATT HSHNCPA1 436 TTGGAGGTGGTGGAAGCTACAATGATTTTGGG--tttatgcA-CAATCA TTGGAGGTGGTGGAAGCTACAATGATTTTGGG ++ + +A CAATCA HSHNRNPA 3815 TTGGAGGTGGTGGAAGCTACAATGATTTTGGGAATT-A--CAACAATCA HSHNCPA1 482 GTCTTCAAATTTTGGACCCATGAAGGGAGGAAATTTTGGAGGCAGAAGC GTCTTCAAATTTTGGACCCATGAAGGGAGGAAATTTTGGAGGCAGAAGC HSHNRNPA 3861 GTCTTCAAATTTTGGACCCATGAAGGGAGGAAATTTTGGAGGCAGAAGC HSHNCPA1 531 TCTGGCCCCTATGGCGGTGGAGGCCAATACTTTGCAAAACCACGAAACC TCTGGCCCCTATGGCGGTGGAGGCCAATACTTTGCAAAACCACGAAACC HSHNRNPA 3910 TCTGGCCCCTATGGCGGTGGAGGCCAATACTTTGCAAAACCACGAAACC HSHNCPA1 580 AAG GTGGCTATGGCGGTTCCAGCAGCAGCAGTAGCT AAG GTGGCTATGGCGGTTCCAGCAGCAGCAGTAGCT HSHNRNPA 3959 AAG<-3962:4251->GTGGCTATGGCGGTTCCAGCAGCAGCAGTAGCT HSHNCPA1 616 ATGGCAGTGGCAGAAGATTT ATGGCAGTGGCAGAAGATTT HSHNRNPA 4285 ATGGCAGTGGCAGAAGATTT // \end{verbatim} \section{Example 3 - using your own Sequence objects} \label{own_objects} If you are a seasoned programmer, you might want to use Dynamite's dynamic programming engine, in particular the divide-and-conquor (linear memory) code. In this case, you have your own Sequence structures and your own comparison matrix code: you just want to use Dynamites dynamic programming engine. First off, Dynamite is \emph{very} flexible, which was one of the design goals of the program. For the basic class of dynamic programming (compare two iterated objects using a regular grammar) you can write most types in Dynamite. I have seen Dynamite be used for aspects as diverse as biological sequences, musical copyright databases and financial data. For the first example, let's recode smith waterman using our own sequence objects. The objects will be of the following type \begin{verbatim} struct MySequence { char * seq; int length_of_sequence; } and struct MyComparisonMatrix { int comp[26][26]; } and the following macro /* macro gets out the sequence at i as 0-26 number */ #define SEQ_POS(obj,i) (toupper(obj->seq[i])-'A') \end{verbatim} How do we use these objects in Dynamite? Quite simply in fact. Dynamite can take raw C types and the calc lines are parsed as a strict subset of C. This means we can provide any calculation function in the middle of the dynamic programming loop. Here is smith waterman written with these objects \begin{verbatim} %{ #include "dyna.h" %} matrix MyProteinSW query type="MySequence*" name="query" field:len="length_of_sequence" target type="MySequence*" name="target" field:len="length_of_sequence" resource type="MyComparisonMatrix" name="mat" resource type="int" name="gap" resource type="int" name="ext" state MATCH offi="1" offj="1" calc="mat.comp[SEQ_POS(query,i)][SEQ_POS(target,j)]" source MATCH calc="0" endsource source INSERT calc="0" endsource source DELETE calc="0" endsource source START calc="0" endsource query_label SEQUENCE target_label SEQUENCE endstate state INSERT offi="0" offj="1" source MATCH calc="gap" endsource source INSERT calc="ext" endsource query_label INSERT target_label SEQUENCE endstate state DELETE offi="1" offj="0" source MATCH calc="gap" endsource source DELETE calc="ext" endsource query_label SEQUENCE target_label INSERT endstate state START !special !start query_label START target_label START endstate state END !special !end source MATCH calc="0" endsource query_label END target_label END endstate endmatrix \end{verbatim} When the current dynamite compiles this code, it will generate alot of warnings that things are 'out of scope' or untypeable. Ignore these and/or pass the -nocwarn flag to dyc to cut some of them out. I need to configure the dynamite better with respect to warnings. Notice how the calc line \begin{verbatim} calc="mat.comp[SEQ_POS(query,i)][SEQ_POS(target,j)]" \end{verbatim} is precisely what you would write in normal C to get the score of the ith amino acid from the query sequence matched to the jth amino acid from the target sequence. The dynamite compiler expands this expression to be scoped properely (so that mat, query and target are held in the 'matrix' scope and can be refered between different parts of the dynamite generated code sensibly). Notice we passed in the Sequence objects as pointers and the Matrix object as a struct. In theory you should be able to pass in objects any way you wish, except I made a mistake and hard coded the concept of the length being from a pointer construct. In other words the line \begin{verbatim} query type="MySequence*" name="query" field:len="length_of_sequence" \end{verbatim} means dynamite generates the following code \begin{verbatim} /* to get out the length of the query dimension */ out->leni = query->length_of_sequence; \end{verbatim} In other words, dynamite can only cope with query and target objects being pointers to structs with a field being their length. I consider this a bug which I should remove, with the length being a more general calc like function (ie, it could be any piece of valid C in the correct scope). Apologies. To use this piece of Dynamite you would only have call \begin{verbatim} PackAln * pal; PackAlnUnit * unit; /* do your own IO for your objects */ pal = PackAln_bestmemory_MyProteinSW(seqone,seqtwo,mat,-12,-2,NULL); /* to investigate PackAln, loop over it */ for(i=0;ilen;i++) { unit = pal->pau[i]; if( unit->state == 0 ) { fprintf(stdout,"%d,%d are matched with score %d\n",unit->i+1,unit->j+1,unit->score); } } \end{verbatim} The i,j numbers in PackAln are the C type numbers, starting at 0, however they are best thought of as occuring \emph{between} the letters of the actual sequence, starting at -1 for each sequence (so the number 0 sits between the first and second resiudes of the sequence). For single amino acid sequences this is usually what you expect, but for multi residue matches (eg, codons), you need to be a little careful of what is going on. The state number starts at 0 as the first state of the Dynamite file, and increasing down the file. When I get around to writing the documentation about the AlnBlock structure sensibly I will explain how to use that sensibly. Lets look at extending the dynamite model for raising the gap penalty in secondary structure regions of the protein. Say our structure was now \begin{verbatim} struct MySequence { char * seq; int length_of_sequence; char * ss; /* string of H,E or C */ } #define IS_ALPHA_SEQ(obj,i) (obj->ss[i] == 'H' ? 1 : 0) \end{verbatim} Now we could write the Dynamite model like this \begin{verbatim} %{ #include "dyna.h" %} matrix MyProteinSW2 query type="MySequence*" name="query" field:len="length_of_sequence" target type="MySequence*" name="target" field:len="length_of_sequence" resource type="MyComparisonMatrix" name="mat" resource type="int" name="gap" resource type="int" name="gap_alpha" resource type="int" name="ext" state MATCH offi="1" offj="1" calc="mat.comp[SEQ_POS(query,i)][SEQ_POS(target,j)]" source MATCH calc="0" endsource source INSERT calc="0" endsource source DELETE calc="0" endsource source START calc="0" endsource query_label SEQUENCE target_label SEQUENCE endstate state INSERT offi="0" offj="1" source MATCH calc="(IS_ALPHA_SEQ(target,j) == 1 ? gap_alpha : gap)" endsource source INSERT calc="ext" endsource query_label INSERT target_label SEQUENCE endstate state DELETE offi="1" offj="0" source MATCH calc="(IS_ALPHA_SEQ(query,i) == 1 ? gap_alpha : gap)" endsource source DELETE calc="ext" endsource query_label SEQUENCE target_label INSERT endstate state START !special !start query_label START target_label START endstate state END !special !end source MATCH calc="0" endsource query_label END target_label END endstate endmatrix \end{verbatim} Notice that we are editing the calc lines for MATCH to INSERT and MATCH to DELETE. These edits are linked to the correct sequence (INSERT extends in the j direction, and so we look up on the j line). This is cute but it actually one can do much better, by having a separate model of evolution, including comparison matrix and gap penalties in the model. In this case we will partion the sequences only into Alpha regions and non alpha regions \begin{verbatim} %{ #include "dyna.h" #define ALPHA_SEQ_SCORE(obj,pos) (obj->ss[pos] == 'H' ? 0 : NEGI) %} matrix MyProteinAlphaSW query type="MySequence*" name="query" field:len="length_of_sequence" target type="MySequence*" name="target" field:len="length_of_sequence" resource type="MyComparisonMatrix" name="mat_alpha" resource type="int" name="gap_alpha" resource type="int" name="ext_alpha" resource type="MyComparisonMatrix" name="mat" resource type="int" name="gap" resource type="int" name="ext" state MATCH offi="1" offj="1" calc="mat.comp[SEQ_POS(query,i)][SEQ_POS(target,j)]" source MATCH calc="0" endsource source MATCH_ALPHA calc="0" endsource source INSERT calc="0" endsource source DELETE calc="0" endsource source START calc="0" endsource query_label SEQUENCE target_label SEQUENCE endstate state INSERT offi="0" offj="1" source MATCH calc="gap" endsource source INSERT calc="ext" endsource query_label INSERT target_label SEQUENCE endstate state DELETE offi="1" offj="0" source MATCH calc="ext" endsource source DELETE calc="ext" endsource query_label SEQUENCE target_label INSERT endstate state MATCH_ALPHA offi="1" offj="1" calc="ALPHA_SEQ_SCORE(query,i) + ALPHA_SEQ_SCORE(target,j) + mat_alpha.comp[SEQ_POS(query,i)][SEQ_POS(target,j)]" source MATCH calc="0" endsource source MATCH_ALPHA calc="0" endsource source INSERT_ALPHA calc="0" endsource source DELETE_ALPHA calc="0" endsource source START calc="0" endsource query_label SEQUENCE target_label SEQUENCE endstate state INSERT_ALPHA offi="0" offj="1" calc="ALPHA_SEQ_SCORE(target,j)" source MATCH_ALPHA calc="gap_alpha" endsource source INSERT_ALPHA calc="ext_alpha" endsource query_label INSERT target_label SEQUENCE endstate state DELETE_ALPHA offi="1" offj="0" calc="ALPHA_SEQ_SCORE(query,i)" source MATCH_ALPHA calc="ext_alpha" endsource source DELETE_ALPHA calc="ext_alpha" endsource query_label SEQUENCE target_label INSERT endstate state START !special !start query_label START target_label START endstate state END !special !end source MATCH calc="0" endsource query_label END target_label END endstate endmatrix \end{verbatim} This model has a number of consequences \begin{itemize} \item Both the query and target sequences must be predicted alpha for the model to enter the \_ALPHA states, and no non alpha regions are tolerated in the \_ALPHA states \item The model is only allowed to switch from alpha to non alpha states and visa versa at matched positions. If a switch from alpha to non alpha or visa versa occurs ``naturally'' at a gap position, the algorithm will be forced to make a match \end{itemize} It is possible to get around both these problems, but that is left as an exercise for the reader. \section{Extending the Dynamite types} The previous example showed how to use your own C types in the Dynamite generated code. These types can be connected up to the Dynamite typing system. This gives a number of benefits \begin{itemize} \item The algorithms can be written without knowing too much about the libraries they are linking to provide the actual C types \item You can type-safe macros. The macros provide efficient decoding of your data structures but don't provide good type saftey. By using dynamite types, the type safety can be enforced by the Dynamite compiler \end{itemize} Because of the way I wrote this documentation, this section has been written to refer to the est2gen example. The est2gen example showed how the Dynamite types can be extended to accommodate your own C structures. The region in the dynamite blueprint area does the extension \begin{verbatim} type DNAMAT real DnaMatrix* endtype method DNA_MAT_SCORE map DnaMatrix_Score arg DNAMAT arg base arg base return int endmethod \end{verbatim} This snippet does two things \begin{itemize} \item Defines DNAMAT as a dynamite type \item Defines DNA\_MAT\_SCORE as 'method'. \end{itemize} The actual C-implementations are defined as being \begin{itemize} \item DnaMatrix* as the type (from the real definition). DnaMatrix can be found in the dnamatrix module in the library section. \item The macro DnaMatrix\_Score which is defined at the top of the cdna2genomic.dy file \end{itemize} This illustrates two nice features in using the Dynamite types and methods \begin{itemize} \item You can use (in the C-implementation) a macro but still have it typechecked \item The types are far extended from the C-implementation. For example, 'bases', 'codons' and 'amino-acids' are all implemented as integers with appropiate ranges. Most C-compilers have to allow conversions between typedefs. The dynamite compiler however treats each type independently. \end{itemize} This means that if we had inadvertently written: \begin{verbatim} calc="DNA_MAT_SCORE(dm,CDNA_BASE(query,i),GENOMIC_CODON(target,j))" \end{verbatim} The dynamite compiler produces the following warning: \begin{verbatim} %dyc cdna2genomic.dy Warning Error ->In preparing matrix cDNA2Gen -->In parsing calc line for state [MATCH] (source ind.) Mis-type in argument 3 of DNA\_MAT\_SCORE: wanted [base] got [codon] Warning Error ->In preparing matrix cDNA2Gen Failed to parse calc lines The following parser errors were considered fatal: Mistyped arguments \end{verbatim} In addition to this type-checking, Dynamite can check some of the semantics in the calc-line usage. In particular the index i should only refer to the query dimension, whereas the index j should only refer to the target dimension. Thus the code \begin{verbatim} calc="DNA_MAT_SCORE(dm,CDNA_BASE(query,j),GENOMIC_BASE(target,j))" \end{verbatim} Generates this warning: \begin{verbatim} %dyc cdna2genomic.dy Warning Error ->In preparing matrix cDNA2Gen -->In parsing calc line for state [MATCH] (source ind.) For function CDNA\_BASE, you have arguments j and query, which do not expect to paired directly in a function. This is just a warning that you can ignore \end{verbatim} \section{Replacing Dynamite types} The Dynamite typing system really comes into its own when you want to use someone else's libraries to provide the basic 'sequence' objects to use. All the dynamite types go through the same typing system as outlined above. The dynamite compiler picks up the file methods from either the current directory or \$WISEPERSONALDIR or \$WISECONFIGDIR. These provide the methods associated with the dynamite run-time library which is distributed with the dynamite compiler. Say in proteinsw.dy you wanted to use your own implementation of the scoring matrix, which was a more generic system, able to cope with completely arbitary alphabets. The C code you had was: \begin{verbatim} typedef struct { int ** score; /* a len-by-len array */ char * alphabet; /* the alphabet of the matrix */ int len; /* the length of the matrix */ } CompMatrix; int score_CompMatrix(CompMatrix * mat,char one,char two) { int a,b; char * pos; if( (pos = strchr(mat->alphabet,one)) == NULL ) { throw_warning("Letter %c does not exist in comparison matrix",one); return 0; } a = pos - mat->alphabet; if( (pos = strchr(mat->alphabet,two)) == NULL ) { throw_warning("Letter %c does not exist in comparison matrix",two); return 0; } b = pos - mat->alphabet; return mat->score[a][b]; } \end{verbatim} How can we adapt this so that proteinsw.dy could use it. Well, the answer is a very simple change in the methods. We need to write one piece of C - like \begin{verbatim} /* this could be a macro */ int map_aa_number_CompMatrix(CompMatrix * mat,int a,int b) { return score_CompMatrix(mat,(char)('A'+a),(char)('A'+b)); } \end{verbatim} and then the methods file rather than looking like: \begin{verbatim} type COMPMAT real CompMat* endtype method AAMATCH map CompMat_AAMATCH arg COMPMAT arg aa arg aa return int endmethod \end{verbatim} would look like \begin{verbatim} type COMPMAT real CompMatrix* endtype method AAMATCH map map_aa_number_CompMatrix arg COMPMAT arg aa arg aa return int endmethod \end{verbatim} \section{Database Searching code} Database searching code is probably one of the first things you would like to do with the Dynamite generated code. Dynamite builds code for a number of different database implementations - at the time of writing, single threaded and multi threaded implementations are provided for. Dynamite will build a single database searching function which will compare (potentially) a database of query objects to a database of target objects. In each case, to be able to build the code, Dynamite must have a specification of the type as a logical type with additional attributes indicating how to initialise, reload and close a database associated with a type. For most uses this means sticking to provided types in the methods file (ie things like PROTEIN or GENOMIC\_DNA). To provide a pthreads port yet more information is required. However, it is possible to write your own database objects and provide the necessary information in the methods file to indicate how dynamite should loop over the database. For the moment you should contact Ewan about writing your own database objects. For many cases you will be using a database-to-database search. The more common, single object vs a database of objects is provided by ways of making a database object which simply has a single entry. These generally are cache'd sensible so it is efficient (whereas a normal database object will free the memory of each entry object once it has been used). The implementation of the database search is provided in the \emph{DBSeachImpl} object. This object can be constructed from the command line, allowing the driving program to be somewhat immune to additional implementations being provided by the dynamite compiler. Each implementation is only guarenteed to provide a single score for each pair of comparisons. For most cases as well it will provide some sort of on-the-fly indexing of the database and ways to retrieve the sequences. At the moment, you need to manually write the alignment code if you want it. Below a simple example of a database search of protein smith waterman, comparing one sequence vs a database a protein sequences. It is dbsearch.c in the examples directory \begin{verbatim} #include "proteinsw.h" void show_help (void) { fprintf(stdout,"dbsearch [options] \n"); fprintf(stdout,"Valid options are\n"); /** add more options here sometime, eg comp matrix and gap penalty*/ /** print out dbsearch options. We don't know here what implementations are either possible or how they are specified. Of course, there is the problem that we could clash our options with the dbsearchimpl options, but that is not too likely, and this makes this program future proof wrt to new implementations */ show_help_DBSearchImpl(stdout); } int main ( int argc, char ** argv) { Hscore * out; DBSearchImpl * dbsi; Protein * temp; Sequence * query; ProteinDB * querydb; ProteinDB * prodb; CompMat * mat; ComplexSequence * query_cs; ComplexSequence * target_cs; ComplexSequenceEvalSet * evalfunc; PackAln * pal; AlnBlock * alb; int i; /* * processes the command line, removing options * that it wants to in order to make the new DBSearchImpl * * The great thing about this is that this programs does not * care about which implementation is used, and does not know either (!) * */ dbsi = new_DBSearchImpl_from_argv(&argc,argv); if( argc != 3 ) { show_help(); exit(1); } /* * first argument is a single sequence. Read it in and make it * into a database */ query = read_fasta_file_Sequence(argv[1]); if( query == NULL ) fatal("Cannot read sequence in %s\n",argv[1]); querydb = new_ProteinDB_from_single_seq(query); /* * Second argument is a real database. This call is * a nice short cut for doing this. */ prodb = single_fasta_ProteinDB(argv[2]); if( prodb == NULL ) fatal("Cannot read protein database in %s\n",argv[2]); /* * This is where all the results are stored. It also * on-the-fly stores distribution information ready * to be fitted by a extreme value distribution */ /* 10 means a score cutoff of 10, -1 means don't report on stderr search progress */ out = std_score_Hscore(10,-1); mat = read_Blast_file_CompMat("blosum62.bla"); if( search_ProteinSW(dbsi,out,querydb,prodb,mat,-12,-2) != SEARCH_OK ) fatal("Some sort of error in the database search. Dieing ungracefully"); sort_Hscore_by_score(out); evalfunc = default_aminoacid_ComplexSequenceEvalSet(); query_cs = new_ComplexSequence(query,evalfunc); if( query_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",query->name); } for(i=0;i<10 && i < out->len;i++) { fprintf(stdout,"Comparison to %s was %d score\n",out->ds[i]->target->name,out->ds[i]->score); /* * Retrieve the protein from the database */ temp = get_Protein_from_ProteinDB(prodb,out->ds[i]->target); /* * Make a complex sequence of it - see psw for info on this */ target_cs = new_ComplexSequence(temp->baseseq,evalfunc); if( target_cs == NULL ) { fatal("Unable to make a protein complex sequence from %s",temp->baseseq->name); } /* * Actually align it */ pal = PackAln_bestmemory_ProteinSW(query_cs,target_cs,mat,-12,-2,NULL); if( pal == NULL ) { fatal("Unable to make an alignment from %s and %s",query->name,temp->baseseq->name); } alb = convert_PackAln_to_AlnBlock_ProteinSW(pal); write_pretty_seq_align(alb,query,temp->baseseq,15,50,stdout); puts("//\n"); free_Protein(temp); free_ComplexSequence(target_cs); } return 0; } \end{verbatim} The main database searching call is at \begin{verbatim} if( search_ProteinSW(dbsi,out,querydb,prodb,mat,-12,-2) != SEARCH_OK ) fatal("Some sort of error in the database search. Dieing ungracefully"); \end{verbatim} It takes the two database objects (querydb and prodb) instead of the normal query and target sequences, and the resources required for this comparison. The dbsi variable is an instance of the DBSearchImpl object made from the command line with the function call \begin{verbatim} dbsi = new_DBSearchImpl_from_argv(&argc,argv); \end{verbatim} The out variable is an instance of the Hscore object. You can find out more about this object by reading the hscore.h file in the dynlibsrc section, with additional functionality in the dynlibcross.dy section. It is made in this case by \begin{verbatim} out = std_score_Hscore(10,-1); \end{verbatim} This indicates that it should store every score greater than 10 (not that sensible) and not report at all about progress during the search. Later on in the program it goes back to pull the sequences out of the database, using the call \begin{verbatim} temp = get_Protein_from_ProteinDB(prodb,out->ds[i]->target); \end{verbatim} This call is not an inherent part of Dynamite, but is provided for convience in the proteindb database. The protein object is then used to actually align the sequences. \subsection{Compiling with pthreads} As it stands the dynamite compiler is not compiling with pthread support. To do so you need to pass the -pthreads switch to the dyc compiler. \begin{verbatim} ../dyc/dyc -pthreads proteinsw.dy \end{verbatim} This generates the pthreading code in the corresponding .c file, but guards it with preprocessor defines so it need not be compiled if so wished. To compile the C program you need to provide the PTHREAD symbol in the preprocessor. \begin{verbatim} cc -c -O -I../dynlibsrc/ -I../base -DPTHREAD proteinsw.c \end{verbatim} Finally in the link phase you must also specify the threads library as in \begin{verbatim} cc -o dbsearch dbsearch.o proteinsw.o seqaligndisplay.o -L../dynlibsrc/ -L../base/ -ldyna -lwisebase -lm -lpthread \end{verbatim} For convience in the examples directory these steps are put in the makefile for target dbthread. so {\tt make dbthread} should produce a pthreaded piece of code. To actually run the exectuable with threads you need to pass in the -pthread switch to dbsearch \newpage \section{Dynamite language definition} \subsection{Overview} Dynamite files consist of three sections. The first two of these are mandatory, the last is optional. The first section is a yacc-like prefix block enclosed by {\tt \%\{ } and {\tt \%\}} delimiters. This block is copied directly to the output and will typically contain \#include statements and other header information. The second section contains of a series of \emph{blueprint} definitions written in the Dynamite language. These include type and access information for objects such as query and target sequences, as well as the main recursion information for the eventual generated DP code. This section is interpreted by the Dynamite parser. The third (optional) section is also delimited by {\tt \%\{} and {\tt \%\}} and contains "marked-up" C. This is currently undocumented. \subsection{Elements of the dynamite language} The following language elements are defined within the second, blueprints section. \subsubsection{Comments} Lines starting with \# are treated as comments. \subsubsection{Single-line statements} Single-line statements are identified by a single keyword at the start of the line whose scope extends to the end of that line. Following this keyword will typically be additional information pertaining to the keyword. The following single-line keywords are reserved: \begin{itemize} \item query \item target \item resource \item extern \item collapse \item calcfunc \item query\_label \item target\_label \item arg \item real \item dbtype \item init \item reload \item close \item addentry \item name \item map \item return \item func \item des \end{itemize} Here is an example of a single-line statement: \begin{verbatim} resource type="COMPMAT" name="comp" \end{verbatim} Many of these single-line keywords are only valid within certain scopes. The scoping rules for individual keywords are described within the relevant sections below. \subsubsection{Multi-line statements} Multi-line statement blocks are delimited by pairs of keywords of the form {\tt tag} and {\tt endtag}. Within the block delimited by these keywords will typically be additional information and constructs pertaining to that keyword. The following multi-line keywords are reserved: \begin{itemize} \item matrix...endmatrix \item state...endstate \item source...endsource \item method...endmethod \item type...endtype \item struct...endstruct \item api...endapi \item object...endobject \end{itemize} Here is an example of a multi-line statement: \begin{verbatim} source MATCH calc="0" endsource \end{verbatim} Many of these multi-line delimiter keywords are only valid within certain scopes. The scoping rules for individual keywords are described within the relevant sections below. \subsubsection{Name-value pairs} Name-value pairs can occur within both single-line and multi-line statement blocks and are used to specify parameters in a flexible way. They take the form of a name, followed by an "=" sign, followed by a quotation-mark-enclosed value. There must be no whitespace between the name and the "=" sign, or between the "=" sign and the value. The following name keywords are reserved: \begin{itemize} \item offi \item offj \item calc \end{itemize} The examples of single-line and multi-line statement blocks in the preceding sections also contain name-value pairs. Here is another example: \begin{verbatim} offi="3" \end{verbatim} \subsection{Definition of the file layout} We now move to a more detailed description of the Dynamite file layout. \subsubsection{Section 1 - C header} \begin{verbatim} %{ #include "dyna.h" #include "my_file.h" %} \end{verbatim} These lines are exported into the .h file verbatim. All files using the standard dynamite run-time libraries should use \#include "dyna.h" The {\tt \%\{} and {\tt \%\}} delimiters must occur in the file. If a second set of lines delimited by {\tt \%\{} and {\tt \%\}} are found, these are exported into the .c file as ``marked-up'' C. This is only really used by myself (ewan). \subsubsection{Section 2 - Dynamite blueprint definitions} Dynamite has a series of 'blueprints' which are sort of the top level block which the dynamite compiler acts on. For example, each DP matrix definition is a single blueprint. Following the first {\tt \%\{} {\tt \%\}} block can be any number of dynamite blueprint definitions. These are multi-line statement blocks as described above. A complete list of allowed blueprints follows: \begin{itemize} \item matrix...endmatrix - describes the central dynamic programming recursion routines \item type...endtype - describes typing information for objects used by the generated code \item method...endmethod - describes data-access methods for objects used by the generated code \item struct...endstruct - describes the Dynamite object model (undocumented) \item api...endapi - describes the Dynamite API model (undocumented) \end{itemize} The most commonly used blueprint is "matrix...endmatrix". \subsection{Definition of the matrix blueprint} We now consider the matrix blueprint in more detail. Essentially the Dynamite compiler needs to know two things: (1) what kinds of sequence-like objects are to be compared, and (2) what recursion relations are to comprise the main loop of the dynamic programming routines. The Dynamite code must therefore specify (1) type and access information for the sequence objects, (2) information about the transitions between the states of the alignment automaton, and (3) how to calculate the scores of these transitions. Requirements (1) and (3) are essentially "data" requirements and we consider these first, in the section entitled "Data objects". Requirement (2) is to do with the model definition and is considered in the section entitled "Model definition". \subsubsection{Data objects} The following single-line statements are used to specify resources. These resources will be visible to the single-line "calc" statements that specify how to calculate the scores of transitions between states (see "Model definition", below). \begin{itemize} \item query - describes the query sequence object. Only one of these is allowed. \item target - describes the target sequence object. Only one of these is allowed. \item resource - describes resource objects such as substitution matrices and other scoring parameters. \item extern - describes resource objects with external linkage (i.e. linkage to \#define properties in C code). \end{itemize} In all of these lines, both of the following name-value pairs are MANDATORY: \begin{itemize} \item {\tt name="name"} name of the object \item {\tt type="type"} type of the object, either a C-type or a logical dynamite type \end{itemize} \subsubsection{Model definition} The main recursion is defined in terms of a finite-state automaton. Each state is described by a "state...endstate" multi-line block. Within each "state...endstate" block, one or more "source...endsource" blocks describe the various possible transitions into that state. States do not need to be declared in any particular order. Each "state...endstate" block has the following format \begin{verbatim} state NAME endstate \end{verbatim} where NAME is the name of the state. Each "state...endstate" block must contain at least one "source...endsource" block. A state can also be declared "special" as follows: \begin{verbatim} state NAME !special endstate \end{verbatim} DP calculations for special states occur "outside" the dynamic programming matrix, in that only one cell score for special states is maintained for each residue of the target sequence. The following name-value pairs can be used within the "state...endstate" block (outside the scope of any enclosed "source...endsource" blocks): \begin{itemize} \item {\tt offi=""} - to specify the default i-offset (i.e. query sequence offset) for transitions \item {\tt offj=""} - to specify the default j-offset (i.e. target sequence offset) for transitions \item {\tt calc=""} - to specify a transition-independent expression to be added to all transition scores \end{itemize} The following single-line statements can be used within the "state...endstate" block (outside the scope of any enclosed "source...endsource" blocks): \begin{itemize} \item query\_label - to specify the default transition label for the query sequence \item target\_label - to specify the default transition label for the target sequence \end{itemize} \subsubsection{Transition definitions} Each "source...endsource" block must have the form \begin{verbatim} source NAME endsource \end{verbatim} where the NAME is the name of the source state for this transition. Within each "source...endsource" block, the following name-value pairs may override the defaults specified in the "state...endstate" block: \begin{itemize} \item {\tt offi="int"} - offset in i for this transition \item {\tt offj="int"} - offset in j for this transition \end{itemize} These attributes must be specified somewhere, so if no default is specified in the "state...endstate" block, then they must be specified here. Within each "source...endsource" block, the following single-line statements may override the defaults specified in the "state...endstate" block: \begin{itemize} \item query\_label LABEL - label for query \item target\_label LABEL - label for target \end{itemize} These attributes must be specified somewhere, so if no default is specified in the "state...endstate" block, then they must be specified here. Each "source...endsource" block muys Each "source...endsource" block must contain a single calc definition. The format for these is described in the following section. \subsubsection{Calc lines} Calc lines describe how to calculate the scores of transitions between states. They provide the major interface between Dynamite-generated code and your own C routines. The calc lines can use the following C expression syntax: \begin{itemize} \item {\tt \+,\-,\*,\\} (N.B. floating point calculations are not recommended in calc lines) \item {\tt \*} (pointer deference), . (struct deference), and -> (pointer + struct dereference) \item {\tt \[\]} (array access) \item standard function calls, including method calls to Dynamite objects \item variables declared in query, target, resource and extern blocks \end{itemize} Dynamite will automatically type-check method calls to pre-defined Dynamite objects. This type safety is stronger than that offered by the C compiler and is recommended. Where C functions unknown to Dynamite are invoked, Dynamite will issue a warning that it cannot type-check the function call. \subsection{Definition of the run-time set up.} The Dynamite runtime set up is found in a file called methods, picked up from .,\$WISEPERSONALDIR or \$WISECONFIGDIR. This file is shipped to be compatible with the dynamite run-time libraries which come with the system. The following types are defined "logical" types \begin{itemize} \item PROTEIN \item CDNA \item GENOMIC \item COMPMAT \item aa \item codon \item base \end{itemize} \subsubsection{PROTEIN} This represents a protein sequence. valid methods are \begin{itemize} \item aa AMINOACID(PROTEIN,int) - returns amino acid at this position \end{itemize} \subsubsection{CDNA} This represents a cDNA sequence. valid methods are \begin{itemize} \item base CDNA\_BASE(CDNA,int) - returns the base at this position \item codon CDNA\_CODON(CDNA,int) - returns the codon at this position \end{itemize} \subsubsection{GENOMIC} This represents a Genomic sequence. valid methods are \begin{itemize} \item base GENOMIC\_BASE(GENOMIC,int) - returns the base at this position \item codon GENOMIC\_CODON(GENOMIC,int) - returns the codon at this position \item int GENOMIC\_5SS(GENOMIC,int) - returns the 5' splice potential for this position \item int GENOMIC\_3SS(GENOMIC,int) - returns the 3' splice potential for this position \item int GENOMIC\_REPEAT(GENOMIC,int) - returns non-cds potential (ie, definitely not a coding sequence) for this position \item int GENOMIC\_CDSPOT(GENOMIC,int) - returns cds potential (ie, definitely a coding sequence) for this position \end{itemize} \subsubsection{COMPMAT} This represents a comparison matrix for protein amino acids \begin{itemize} \item int AAMATCH(COMPMAT,aa,aa) returns the score for these two amino acids \end{itemize} \subsubsection{aa} No functions associated with this. It is a number from 0-25 inclusive, where 'A' (alanine) is 0 etc... This means we have more numbers than amino acids, but that is fine. \subsubsection{codon} No functions associated with this. It is a number from 0-125 inclusive, where this is calculated as \mbox{(base1*25)+(base2*5)+base3} (base defined below) of a codon, at 125 means no possible codon at this position. \subsubsection{base} No functions associated with this. It is a number from 0-4 inclusive where A = 0, G = 1, C = 2, T = 3 and N = 4 \section{Errors Reported by the Dynamite Compiler} A number of different errors can be reported by the Dynamite compiler. Some of them are warnings but the dynamite compiler still generates valid code whereas others cause the dynamite compiler to stop. The errors can be divided into three types \begin{itemize} \item Syntactic errors, due to writing the wrong commands in the dynamite file \item Semantic errors in the Dynamite definition \item Syntactic and semantic errors in the calc lines of the dynamite file \end{itemize} Syntatic errors in the blueprint file will sometime cause a run-away set of parsing errors. These are terminated with a fatal call to prevent your stderr filling up with boring messages. Otherwise dynamite tries to gather as many errors as possible before exiting. At the moment the dynamite compiler does not remove the .c file when it encounters an error (it should do!). This means that if an error is encountered you may well have to remove the .c file yourself for the makefile to remake it etc... \subsection{Syntax errors in the matrix blueprint parsing} Generally the syntax errors in the matrix blueprint parsing are quite informative. They come with a line indicating where they lie in the file. This line is the currently read line in the parser, and so might be not be precisely where the error is. The hardest error to understand is the run-away parsing error in which a ``endsource'' or similar multi line ending section is not closed. Below details some of the more common errors found in parsing. \subsubsection{[Dynamite Level] Did not understand line [ source MATCH]. Probably a run-away parsing error, so failing now} This error indicates that the parser has left the GenericMatrix parsing and returned to the top level dynamite level. It is usually preceded by the next error \subsubsection{Unable to read GenericMatrix} The syntax error when the matrix blueprint reading fails. The precise error should have been posted beforehand \subsubsection{Got the line [state INSERT offi="0" offj="1"], a state start line inside a state. Expect you forgot an endstate} The error message says it all. This is when you have forgotten to close a multi-line brace, like state...endstate or source...endsource \subsubsection{got an end tag [endxxx] but expecting a [endyyy]} xxx might be matrix whereas yyy might be source. This means that you haven't balanced your state...endstate or source...endsource blocks correctly. You have probably missed out a endsource or a endstate line somewhere \subsubsection{You have specified a modifier [name] to XXX but it has either no '=' sign or no quoted argument. The '=' character should be flush to both the tag and the quoted (using \") argument} The dynamite parser is particularly bad about the modifer lines. They have to be of the form {\tt modifer="something"} with no whitespace. This is an extremely bad thing I know. \subsubsection{Could not understand line in YYY parse} YYY might be ``matrix'' or ``state'' or ``source''. This means that the parser got a line it couldn't handle. It is quite likely that you have missed out a ``endxxxx'' line \subsection{Semantic errors} Semantic errors are not reported with a line number. This is because the Dynamite compiler does not associate a line number with the parts of the datastructure which is carries around (it should do). However semantic errors are labeled by where (logically) they come in the Dynamite file: for example the following error was made by mistyping ``MATCH'' in a source line, and therefore making a source line that had no state. The first error is quite descriptive about what is going on. \begin{verbatim} adnah:[/wise2/dyc]<369>: dyc proteinsw.dy Warning Error In preparing matrix ProteinSW In matrix ProteinSW - State MATCH asks for source MATCH2 but there is no State of that name Warning Error In preparing matrix ProteinSW Unable to cross reference state and source Warning Error In preparing matrix ProteinSW Failing simple cross-checks, aborting before calc-line parsing Fatal Error A Dynamite blueprint fails semantic checks. Please refer to previous errors for the precise problem \end{verbatim} \subsubsection{A Dynamite blueprint fails semantic checks. Please refer to previous errors for the precise problem} This error indicates that a the top level a semantic problem was found, even though the syntax was parsed ok. \subsubsection{Failing simple cross-checks, aborting before calc-line parsing} This is the error message likely to be got just before the last error. This means that the semantics of the matrix blueprint failed, and the Dynamite parser did not attempt to parse the calc lines. \subsubsection{Start/End points are faulty} This indicates that the start or end points where not there or not special states. There is individual error messages for each of those. \subsubsection{You have not got a !start special, but you do have a START special state. Presuming that you wanted to make that the START ;)} This is warning. You haven't used the proper dynamite syntax of !start to indicate the start state. You do however have a special state called START and there is all likelhood that this is what you want as the start. There is a similar error message for end \subsubsection{Unable to prepare labels} This means that you have missed out a ``query\_label'' or a ``target\_label'' definition for one source line. Even if you don't use label alignments, the labels are still required. Remember that you can place them as defaults for a particular state. \subsubsection{Unable to resolve all the cell offset refs into correct offsets} This means that you have probably forgotten an offi and or an offj modifier for a source line. Remember that you can set them as defaults at the state line if you so wish. It is probably preceeded by the next error \subsubsection{In state INSERT (source MATCH), both offi and offj are zero: dynamite cannot currently handle cell internal references} The most likely explanation for this is that you have not specified the offsets for this source at all. If you have specified them as 0,0 this is illegal in Dynamite. In needs at least one offset to be non zero. \subsection{Syntax and Semantics of calc line parsing} Once all the semantics of the Dynamite blueprint is ok, the compiler then turns its attention to the calc lines. This is like a mini-parser operating inside the dynamite parser, but unlike the dynamite parser, this once was written in yacc/lex and is a more vanilla parser enviroment. \subsubsection{Parser Syntax error on calc line} This is the error which indicates that the yacc parser cannot get through the calc line. Above it should be precisely which calc line gives the error and where on it the parser halted. For example \begin{verbatim} adnah:[/wise2/dyc]<377>: dyc proteinsw.dy Warning Error In preparing matrix ProteinSW In parsing calc line for state [MATCH] source [START] Calc line parser error: [syntax error] Occured at: 0 += 2 ---^ Warning Error In preparing matrix ProteinSW Failed to parse calc lines The following parser errors were considered fatal: Parser Syntax error on calc line Fatal Error A Dynamite blueprint fails semantic checks. Please refer to previous errors for the precise problem \end{verbatim} This will cause a fatal error which you will need to solve before proceeding. A number of other errors can be generated by the parsing of calc lines, but most of them do not cause a fatal error at the end of the day. \end{document} wise-2.4.1/docs/apiend.tex0000644000175000001440000000002007313404504014753 0ustar philippusers \end{document} wise-2.4.1/docs/gettex.pl0000644000175000001440000000052107313404521014633 0ustar philippusers#!/usr/local/bin/perl while(<>) { s/module_/!!MODULE/g; s/object_/!!OBJECT/g; s/accessing_/!!ACCESS/g; s/\_/\\\_/g; s/\&/\\\&/g; s/\$/\\\$/g; s/\'/\\\'/g; s/\#/\\\#/g; s/!!OBJECT/object_/g; s/!!ACCESS/accessing_/g; s/!!MODULE/module_/g; s/module_sw\\_wrap/module_sw_wrap/g; print; } wise-2.4.1/docs/papers/0000755000175000001440000000000010670453540014277 5ustar philippuserswise-2.4.1/docs/papers/alignment.bib0000644000175000001440000037351007725360453016753 0ustar philippusers@string{AHG = "Annals of Human Genetics"} @string{AJHG = "American Journal of Human Genetics"} @string{ARB = "Annual Review of Biochemistry"} @string{ARCB = "Annual Review of Cell Biology"} @string{BI = "Bioinformatics"} @string{BIOGEN = "Biochemical Genetics"} @string{BJLS = "Biological Journal of the Linnean Society"} @string{BMB = "Bulletin of Mathematical Biology"} @string{CABIOS = "Computer Applications in the Biosciences"} @string{CACM = "Communications of the ACM"} @string{COCB = "Current Opinion in Cell Biology"} @string{COSB = "Current Opinion in Structural Biology"} @string{CSHSQB = "Cold Spring Harbor Symposia Quantitative Biology"} @string{ComputChem = "Computers and Chemistry"} @string{EMBO = "EMBO Journal"} @string{EVO = "Evolution"} @string{GEN = "Genetics"} @string{JBSD = "Journal of Biomolecular Structure and Dynamics"} @string{JComputBiol = "Journal of Computational Biology"} @string{JCB = JComputBiol} @string{JMB = "Journal of Molecular Biology"} @string{JME = "Journal of Molecular Evolution"} @string{JRSS = "Journal of the Royal Statistical Society, B"} @string{JTB = "Journal of Theoretical Biology"} @string{MBE = "Molecular Biology and Evolution"} @string{MBIO = "Mathematical Biosciences"} @string{ME = "Methods in Enzymology"} @string{MPE = "Molecular Phylogenetics and Evolution"} @string{NAR = "Nucleic Acids Research"} @string{NC = "Neural Computation"} @string{NNB = "Nature New Biology"} @string{Nature = "Nature"} @string{PE = "Protein Engineering"} @string{PNAS = "Proceedings of the National Academy of Sciences of the USA"} @string{PROT = "Proteins"} @string{PROTSCI = "Protein Science"} @string{SIAM = "SIAM Journal of Applied Mathematics"} @string{SYSB = "Systematic Biology"} @string{SZ = "Systematic Zoology"} @string{Science = "Science"} @string{S = Science} @string{TIBTECH= "Trends in Biotechnology"} @string{TIGS = "Trends in Genetics"} @string{TIBS = "Trends in Biochemistry"} @string{UKSB = "University of Kansas Scientific Bulletin"} @Article{Abrahams90, author = {J. P. Abrahams and M. van den Berg and E. van Batenburg and C. Pleij}, title = {Prediction of {RNA} Secondary Structure, Including Pseudoknotting, by Computer Simulation}, journal = NAR, year = 1990, volume = 18, pages = {3035-3044} } @inproceedings{AllisonEtal92a, author = "L. Allison and C. S. Wallace and C. N. Yee", title = "Minimum message length encoding, evolutionary trees and multiple alignment", booktitle = "Hawaii International Conference on System Sciences", year = "1992", volume = "1", pages = "663-674" } @article{AllisonEtal92b, author = "L. Allison and C. S. Wallace and C. N. Yee", title = "Finite-state models in the alignment of macromolecules.", journal = JME, year = "1992", volume = "35", pages = "77-89" } @techreport{AllisonWallace93, author = "L. Allison and C. S. Wallace", title = "The posterior probability distribution of alignments and its application to parameter estimation of evolutionary trees and to optimisation of muliple alignments", institution = "Monash University Computer Science", year = 1993, number = "TR 93/188" } @article{Altschul89, author = "S. F. Altschul", title = "Gap costs for multiple sequence alignment", journal = JTB, volume = 138, pages = "297-309", year = 1989 } @Article{Altschul90, author = "S. F. Altschul and W. Gish and W. Miller and E. W. Myers and D. J. Lipman", title = "Basic Local Alignment Search Tool", journal = JMB, year = 1990, volume = 215, pages = "403-410" } @Article{Altschul91, author = "S. F. Altschul", title = "Amino Acid Substitution Matrices from an Information Theoretic Perspective", journal = JMB, year = 1991, volume = 219, pages = "555-565" } @article{AltschulErickson86, author = "S. F. Altschul and B. W. Erickson", title = "Optimal sequence alignment using affine gap costs", journal = BMB, volume = 48, pages = "603-616", year = 1986 } @article{AltschulEtal89, author = "S. F. Altschul and and R. J. Carroll and D. J. Lipman", title = "Weights for Data Related by a Tree", journal = JMB, volume = 207, pages = "647-653", year = 1989 } @article{SlonimEtal97, author = "D. Slonim and L. Kruglyak and L. Stein and E. Lander", title = "Building human genome maps with radiation hybrids", journal = JCB, pages = "487-504", volume = 4, year = 1997, } @article{ThorneEtal96, author = "J. L. Thorne and N. Goldman and D. T. Jones", title = "Combining protein evolution and secondary structure.", journal = MBE, volume = 13, pages = "666-673", year = 1996, } @article{GoldmanEtal96, author = "N. Goldman and J. L. Thorne and D. T. Jones", title = "Using evolutionary trees in protein secondary structure prediction and other comparative sequence analyses.", journal = JMB, volume = 263, pages = "196-208", year = 1996, } @article{LioEtal99, author = "P. Lio and J. L. Thorne and N. Goldman and D. T. Jones", title = "PASSML: combining evolutionary inference and protein secondary structure prediction.", pages = "726-733", journal = BI, volume = 14, year = 1999, } @article{AltschulGish96, author = {S. F. Altschul and W. Gish}, title = {Local alignment statistics}, journal = ME, volume = 266, pages = "460-480", year = 1996 } @Article{Altschul97, author = {S. F. Altschul and T. L. Madden and A. A. Schaffer and J. Zhang and Z. Zhang and W. Miller and D. J. Lipman}, title = {Gapped {BLAST} and {PSI-BLAST}: a New Generation of Protein Database Search Programs}, journal = NAR, year = 1997, volume = 25, pages = {3389-3402} } @Article{AltschulLipman89, author = {S. F. Altschul and D. J. Lipman}, title = {Trees, Stars, and Multiple Biological Sequence Alignment}, journal = SIAM, year = 1989, volume = 49, pages = {197-209} } @article{AsaiEtal93, author = "K. Asai and S. Hayamizu and K. Handa", title = "Prediction of protein secondary structure by the hidden {M}arkov model", journal = CABIOS, year = "1993", volume = "9", number = "2", pages = "141-146" } @book{Asmussen87, author = "S. Asmussen", title = "Applied Probability and Queues", publisher = "Wiley", address = "Chichester, UK", year = 1987 } @incollection{Atteson97, author = "K. Atteson", title = "The performance of the neighbor-joining method of phylogeny reconstruction", booktitle = "Mathematical Hierarchies and Biology", pages = "133-148", editor = "B. Mirkin and F. Mc{M}orris and F. Roberts and A. Rzhetsky", publisher = "American Mathematical Society", address = "Providence, RI", year = 1997 } @Article{Attwood94, author = {T. K. Attwood and M. E. Beck}, title = {{PRINTS} -- A Protein Motif Fingerprint Database}, journal = PE, year = 1994, volume = 7, pages = {841-848} } @inproceedings{BaileyElkan94, author = "T. L. Bailey and C. Elkan", title = "Fitting a Mixture Model by Expectation Maximization to Discover Motifs in Biopolymers", crossref = "ismb94", pages = "28--36" } @inproceedings{BaileyElkan95, author = "T. L. Bailey and C. Elkan", title = "The value of prior knowledge in discovering motifs with {MEME}", pages = "21-29", crossref = "ismb95" } @inproceedings{BaileyGribskov96, author = "T. L. Bailey and M. Gribskov", title = "The megaprior heuristic for discovering protein sequence patterns.", pages = "15-24", crossref = "ismb96", } @inproceedings{BahlEtAl86, author = "L. R. Bahl and P. F. Brown and P. V. de Souza and R. L. Mercer", title = "Maximum Mutual Information Estimation of Hidden {M}arkov Model Parameters for Speech Recognition", booktitle = "Proceedings of ICASSP '86", pages = "49-52", year = "1986", myref = "HMM25" } @Article{Bairoch97b, author = {A. Bairoch and P. Bucher and K. Hofmann}, title = {The {\sc PROSITE} Database, Its Status in 1997}, journal = NAR, year = 1997, volume = 25, pages = {217-221} } % RD says: % this is the correct latest swissprot reference to replace % BairochApweiler96 in your list - I updated the only \cite{BA96} % in the book, in profhmm. @Article{Bairoch97, author = {A. Bairoch and R. Apweiler}, title = {The {\sc SWISS-PROT} Protein Sequence Data Bank and Its Supplement {TrEMBL}}, journal = NAR, year = 1997, volume = 25, pages = {31-36} } @book{BaldiBrunak98, author = "P. Baldi and S. Brunak", title = "Bioinformatics -- The Machine Learning Approach", publisher = "MIT Press", address = "Cambridge, MA", year = 1998 } @article{BaldiChauvin94, author = "P. Baldi and Y. Chauvin ", title = "Smooth on-line learning algorithms for hidden {M}arkov models", journal = NC, year = 1994, number = 2, volume = 6, pages = "307-318" } @article{bhattacharya99, author = "S. K. Bhattacharya and S. Ramchandani and N. Cervoni and M. Szyf", title = "A mammalian protein with specific demethylase activity for m{C}p{G} {DNA}", journal = Nature, pages = {579-583}, volume = 397, year = 1999 } @inproceedings{BaldiChauvin95, author = "P. Baldi and Y. Chauvin", title = "Protein modeling with hybrid Hidden {M}arkov Model/neural network architectures", year = "1995", pages = "39-47", crossref = "ismb95" } @article{BaldiEtal94, author = "P. Baldi and Y. Chauvin and T. Hunkapiller and M. A. Mc{C}lure", title = "Hidden {M}arkov models of biological primary sequence information", journal = PNAS, year = "1994", volume = "91", number = "3", pages = "1059-1063" } @article{BaldiEtal96b, author = {P. Baldi and S. Brunak and Y. Chauvin and A. Krogh}, title = {Naturally Occurring Nucleosome Positioning Signals in Human Exons}, journal = JMB, volume = 263, pages = "503-510", year = 1996 } @article{BandeltDress92, author = "H.-J. Bandelt and A. W. M. Dress", title = "Split decomposition: a new and useful approach to phylogenetic analysis of distance data", journal = MPE, volume = 1, pages = "242-252", year = 1992 } @article{BartonSternberg87, author = "G. J. Barton and M. J. E. Sternberg", title = "A Strategy for the Rapid Multiple Alignment of Protein Sequences", journal = JMB, volume = 198, year = 1987, pages = "327-337" } @article{Barton93, author = "G. J. Barton", title = "An efficient algorithm to locate all locally optimal alignments between two sequences allowing for gaps", journal = CABIOS, volume = 9, number = 6, year = 1993, pages = "729-734" } @article{barton90, author = "G. J. Barton and M. J. Sternberg", title = "Flexible protein sequence patterns. A sensitive method to detect weak structural similarities.", journal = JMB, volume = 212, pages = "389-402", year = 1990, } @InCollection{Baserga93, author = "S. J. Baserga and J. A. Steitz", title = "The Diverse World of Small Ribonucleoproteins", booktitle = "The {RNA} World", publisher = "Cold Spring Harbor Press", year = 1993, editor = "R. F. Gesteland and J. F. Atkins", pages = "359-381", address = "New York" } @article{BashfordEtal87, author = "D. Bashford and C. Chothia and A. M. Lesk", title = "Determinants of a protein fold: unique features of the globin amino acid sequence", journal = JMB, volume = 196, pages = "199-216", year = 1987 } @article{Baum72, author = {L. E. Baum}, title = {An Equality and Associated Maximization Technique in Statistical Estimation for Probabilistic Functions of {M}arkov Processes}, journal = {Inequalities}, year = 1972, volume = 3, pages = {1-8} } @article{BengioEtal92, author = "Y. Bengio and R. De Mori and G. Flammia and R. Kompe", title = "Global optimization of a neural network--hidden {M}arkov model hybrid", journal = "IEEE Transactions on Neural Networks", year = 1992, number = 2, volume = 3, pages = "252-259" } @book{Berger85, author= "J. O. Berger", title= "Statistical Decision Theory and {B}ayesian Analysis", publisher= "Springer-Verlag", address= "New York", year= 1985 } @article{BergerMunson91, author = "M. P. Berger and P. J. Munson", title = "A novel randomized iterative strategy for aligning multiple protein sequences", journal = CABIOS, volume = 7, pages = "479-484", year = 1991 } @Article{Bird87, author = {A. Bird}, title = {{CpG} islands as gene markers in the vertebrate nucleus}, journal = TIGS, year = 1987, volume = 3, pages = {342-347} } @Article{Birney93, author = {E Birney and S. Kumar and A. R. Krainer}, title = {Analysis of the {RNA}-recognition motif and {RS} and {RGG} domains: conservation in metazoan pre-m{RNA} splicing factors}, journal = NAR, year = 1993, pages = {5803-5816} } @Article{Birney94, author = {T. J. Gibson and M. Hyvonen and A. Musacchio and M. Saraste and E. Birney}, title = {{PH} domain: the first anniversary}, journal = TIBS, year = 1994, volume = 19, pages = {349-353} } @Article{Birney96, author = {E. Birney and J. D. Thompson and T. J. Gibson}, title = {Pairwise and Searchwise: comparison of a protein profile to all three translation frames simultaneously}, journal = NAR, year = 1996, volume = 24, pages = {2730-2739} } @inproceedings{BirneyDurbin97, author = "E. Birney and R. Durbin", title = {Dynamite: a flexible code generating language for dynamic programming methods used in sequence comparison}, crossref = "ismb97", year = 1997, pages = "56-64" } @article{BishopThompson86, author = {M. J. Bishop and E. A. Thompson}, title = {Maximum Likelihood alignment of {DNA} Sequences}, journal = JMB, year = 1986, volume = 190, pages = {159-165} } @article{BorodovskyEtal86a, author = "M. Yu. Borodovsky and Yu. A. Sprizhitsky and E. I. Golovanov and A. A. Alexandrov", title = "Statistical Patterns in the Primary Structure of the Functional Regions of the {Escherichia} Coli Genome. {I}. {F}requency Characteristics", journal = "Molecularnaya Biologia", note = "(English translation)", year = 1986, volume = 20, pages = "826--833" } @article{BorodovskyEtal86b, author = "M. Yu. Borodovsky and Yu. A. Sprizhitsky and E. I. Golovanov and A. A. Alexandrov", title = "Statistical Patterns in the Primary Structure of the Functional Regions of the {Escherichia Coli} Genome. {II}. {N}onuniform {M}arkov Models", journal = "Molecularnaya Biologia", note = "(English translation)", year = 1986, volume = 20, pages = "833--840" } @article{BorodovskyEtal86c, author = "M. Yu. Borodovsky and Yu. A. Sprizhitsky and E. I. Golovanov and A. A. Alexandrov", title = "Statistical Patterns in the Primary Structure of the Functional Regions of the {Escherichia Coli} Genome. {III}. {C}omputer Recognition of Coding Regions", journal = "Molecularnaya Biologia", note = "(English translation)", year = 1986, volume = 20, pages = "1144--1150" } @article{BorodovskyMcIninch93, author = "M. Borodovsky and J. Mc{I}ninch", title = "{\sc GENMARK}: parallel Gene Recognition for Both {DNA} strands", journal = ComputChem, year = "1993", volume = 17, number = 2, pages = "123--133", myref = "BIO105" } @article{BowieEtal91, author = "J. U. Bowie and R. Luthy and D. Eisenberg", title = "A method to identify protein sequences that fold into a known three-dimensional structure", journal = Science, year = 1991, volume = 253, pages = "164-170" } @Book{BoxTiao92, author = {G. E. P. Box and G. C. Tiao}, title = {Bayesian Inference in Statistical Analysis}, publisher = {Wiley-Interscience}, year = 1992 } @Book{Branden91, author = {C. Branden and J. Tooze}, title = {Introduction to Protein Structure}, publisher = {Garland}, year = 1991, address = {New York} } @Article{Brendel86, author = {V. Brendel and J. S. Beckmann and E. N. Trifonov}, title = {Linguistics of Nucleotide Sequences: morphology and Comparison of Vocabularies}, journal = JBSD, year = 1986, volume = 4, pages = {11-20}, filed = {Trifonov} } @book{Brooksetal91, author = "D. R. Brooks and D. A. Mc{L}ennan", title = "Phylogeny, Ecology and Behaviour", publisher = "University of Chicago Press", address = "Chicago", year = 1991 } @inproceedings{BrownEtal93, author={M. Brown and R. Hughey and A. Krogh and I. S. Mian and K. Sj{\"o}lander and D. Haussler}, title="Using {D}irichlet Mixture Priors to Derive Hidden {M}arkov Models for Protein Families", pages= "47-55", crossref = "ismb93" } @Unpublished{BrownWilson95, author = {M. Brown and C. Wilson}, title = {{RNA} Pseudoknot Modeling Using Intersections of Stochastic Context-Free Grammars with Applications to Database Search}, note = {Unpublished manuscript available from http://www.cse.ucsc.edu/research/compbio/pseudoknot.html}, year = 1995 } @article{BrunakEtal91, author = "S. Brunak and J. Engelbrecht and S. Knudsen", title = "Prediction of human {mRNA} donor and acceptor sites from the {DNA} sequence", journal = JMB, year = "1991", volume = "220", number = "1", pages = "49--65" } @article{BrunakEtal90, author = "S. Brunak and J. Engelbrecht and S. Knudsen", title = "Iden" } @article{BucherEtal96, author = "P. Bucher and K. Karplus and N. Moeri and K. Hofmann", title = "A Flexible Motif Search Technique Based on Generalized Profiles", journal = ComputChem, volume = 20, pages = "3-24", year = 1996 } @InProceedings{BucherHofmann96, author = {P. Bucher and K. Hofmann}, title = {A Sequence Similarity Search Algorithm Based on a Probabilistic Interpretation of an Alignment Scoring System}, crossref = "ismb96", pages = {44-51} } @incollection{Buneman71, author = "P. Buneman", title = "The recovery of trees from measures of dissimilarity", booktitle = "Mathematics in the Archaeological and Historical Sciences", pages = "387-395", editor = "F. R. Hodson and D. G. Kendall and P. Tautu", publisher = "Edinburgh University Press", address = "Edinburgh", year = 1971 } @article{BurgeKarlin97, author = "C. Burge and S. Karlin", title = "Prediction of Complete Gene Structures in Human Genomic {DNA}", journal = JMB, volume = 268, year = 1997, pages = "78-94" } @article{CaminSokal65, author = "J. H. Camin and R. R. Sokal", title = "A method for deducing branching sequences in phylogeny", journal = EVO, volume = 19, pages = "311-327", year = 1965 } @article{CardonStormo92, author = "L. R. Cardon and G. D. Stormo", title = "Expectation maximization algorithm for identifying protein-binding sites with variable lengths from unaligned {DNA} fragments", journal = JMB, year = 1992, volume = 223, number = 1, pages = "159--170" } @article{CarrilloLipman88, author = "H. Carrillo and D. Lipman", title = "The Multiple Sequence Alignment Problem in Biology", journal = SIAM, volume = 48, pages = "1073-1082", year = "1988" } @InProceedings{CaryStormo95, author = {R. B. Cary and G. D. Stormo}, title = {Graph-Theoretic Approach to {RNA} Modeling Using Comparative Data}, pages = {75-80}, crossref = "ismb95" } @book{CasellaBerger90, author= "G. Casella and R. L. Berger", title= "Statistical Inference", publisher= "Duxbury Press", address= "Belmont, CA", year= 1990 } @article{Cavender78, author = "J. A. Cavender", title = "Taxonomy with confidence", journal = MBIO, volume = 40, pages = "271-280", year = 1978 } @article {Cech86, author = "T. R. Cech and B. L. Bass", title = "Biological Catalysis by {RNA}", journal = ARB, volume = 55, pages = "599-629", year = 1986 } @article{Chan92, author = {S. C. Chan and A. K. C. Wong and D. K. Y. Chiu}, title = {A survey of multiple sequence comparison methods}, journal = BMB, volume = 54, pages = "563-598", year = 1992 } @inproceedings{ChangLawler90, author = {W. I. Chang and E. L. Lawler}, title = "Approximate string matching in sublinear expected time", booktitle = "Proceedings of the 31st Annual IEEE Symposium on Foundations Computer Science", address = "St Louis, MO", publisher = "IEEE", year = 1990, pages = {116-124} } @Article{Chao92, author = {K. M. Chao and W. R. Pearson and W. Miller}, title = {Aligning Two Sequences Within a Specified Diagonal Band}, journal = CABIOS, year = 1992, volume = 8, pages = {481-487} } @Article{Chao94, author = {K. M. Chao and R. C. Hardison and W. Miller}, title = {Recent Developments in Linear-Space Alignment Methods: a Survey}, journal = JComputBiol, year = 1994, volume = 1, pages = {271-291} } @Article{Chiu91, author = "D. K. Y. Chiu and T. Kolodziejczak", title = "Inferring Consensus Structure from Nucleic Acid Sequences", journal = CABIOS, year = 1991, volume = 7, pages = "347-352" } @Article{Chomsky56, author = "N. Chomsky", title = "Three Models for the Description of Language", journal = "IRE Transactions Information Theory", year = 1956, volume = 2, pages = "113-124" } @Article{Chomsky59, author = "N. Chomsky", title = "On Certain Formal Properties of Grammars", journal = "Information and Control", year = 1959, volume = 2, pages = "137-167" } @Article{Chothia86, author = "C. Chothia and A. M. Lesk", title = "The Relation Between the Divergence of Sequence and Structure in Proteins", journal = EMBO, year = 1986, volume = 5, pages = "823-826" } @Article{Churchill89, author = {G. A. Churchill}, title = {Stochastic Models for Heterogeneous {DNA} Sequences}, journal = BMB, year = 1989, volume = 51, pages = {79--94} } @article{Churchill92, author = "G. A. Churchill", title = "Hidden Markov chains and the analysis of genome structure", journal = "Computers and Chemistry", volume = 16, number = 2, pages = "107-115", year = 1992, abstract = { Statistical methods based on a hidden Markov chain model are used to study the structure of some small complete genomes and a human genome segment. A variety of discrete compositional domains are discovered and their correlations with genome function are explored.} } @article{Claverie94, author = "J.-M. Claverie", title = "Some useful statistical properties of position-weight matrices", journal = ComputChem, year = 1994, volume = 18, pages = "287-294" } @Article{Collado-Vides89, author = {J. Collado-Vides}, title = {A Transformational-Grammar Approach to the Study of the Regulation of Gene Expression}, journal = JTB, year = 1989, volume = 136, pages = {403-425} } @Article{Collado-Vides91, author = {J. Collado-Vides}, title = {A Syntactic Representation of Units of Genetic Information -- A Syntax of Units of Genetic Information}, journal = JTB, year = 1991, volume = 148, pages = {401-429} } @Article{Corpet94, author = "F. Corpet and B. Michot", title = "{RNAlign} Program: alignment of {RNA} Sequences Using Both Primary and Secondary Structures", journal = CABIOS, year = 1994, volume = 10, pages = "389-399" } @book{CoverThomas91, author = "T. M. Cover and J. A. Thomas", title = "Elements of Information Theory", year = 1991, publisher = "John Wiley \& Sons, Inc.", address = "New York" } @article{Cox62, author = "D. R. Cox", title = "Further results on tests of separate families of hypotheses", journal = JRSS, volume = 24, pages = "406-424", year = 1962 } @book{CoxMiller65, author= "D. R. Cox and H. D. Miller", title= "The Theory of Stochastic Processes", publisher= "Chapman \& Hall", address= "London", year= 1965 } @Article{Dandekar95, author = "T. Dandekar and M. W. Hentze", title = "Finding the Hairpin in the Haystack: searching for {RNA} Motifs", journal = TIGS, year = 1995, volume = 11, pages = "45-50" } @incollection{DayhoffEtal72, author = "M. O. Dayhoff and R. V. Eck and C. M. Park", booktitle= "Atlas of Protein Sequence and Structure", editor = "M. O. Dayhoff", publisher="National Biomedical Research Foundation", address = "Washington, DC", year= "1972", volume = 5, pages = "89-99" } @incollection{DayhoffEtal78, author= "M. O. Dayhoff and R. M. Schwartz and B. C. Orcutt", title= "A Model of Evolutionary Change in Proteins", booktitle= "Atlas of Protein Sequence and Structure", editor = "M. O. Dayhoff", publisher="National Biomedical Research Foundation", address = "Washington, DC", year= 1978, volume = "5, supplement 3", pages = "345-352" } @article{DemboKarlin91, author = {A. Dembo and S. Karlin}, title = {Strong limit theorems of empirical functionals for large exceedances of partial sums of i.i.d.\ variables}, journal = {Annals of Probability}, volume = 19, pages = {1737-1755}, year = 1991 } @article{DempsterEtal77, author = {A. P Dempster and N. M. Laird and D. B. Rubin}, title = {Maximum Likelihood From Incomplete Data via the {EM} Algorithm}, journal = {Journal of the Royal Statistical Society}, year = 1977, volume = "B 39", pages = {1-38} } @Article{Dijkstra, author = {E. W. Dijkstra}, title = {A note on two problems in connection with graphs}, journal = {Numerische Mathematics}, year = 1959, volume = 1, pages = {269-271} } @Article{Dong94, author = {S. Dong and D. B. Searls}, title = {Gene Structure Prediction by Linguistic Methods}, journal = {Genomics}, year = 1994, volume = 23, pages = {540--551} } @article{DoolittleEtal96, author = "R. F. Doolittle and D.-F. Feng and S. Tsang and G. Cho and E. Little", title = "Determining divergence times of the major kingdoms of living organisms with a protein clock", journal = S, volume = 271, pages = "470-477", year = 1996 } @book{EckDayhoff66, author = {R. V. Eck and M. O. Dayhoff }, title = "Atlas of Protein Sequence and Structure", publisher = "National Biomedical Research Foundation", address = "Silver Spring, MD", year = 1966 } @Article{Eddy94, author = "S. R. Eddy and R. Durbin", title = "{RNA} Sequence Analysis Using Covariance Models", journal = NAR, year = 1994, volume = 22, pages = "2079-2088" } @Article{Eddy95, author = "S. R. Eddy and G. J. Mitchison and R. Durbin", title = "Maximum Discrimination Hidden {M}arkov Models of Sequence Consensus", journal = JComputBiol, year = 1995, pages = "9-23" } @Article{Eddy98, author = "S. R. Eddy", title = "profile-hidden {M}arkov models", journal = BI, year = 1998, volume = 14, pages = "755-763", } @InProceedings{Eddy95b, author = "S. R. Eddy", title = "Multiple Alignment Using Hidden {M}arkov Models", pages = "114-120", crossref = "ismb95" } @Article{Eddy96, author = {S. R. Eddy}, title = {Hidden {M}arkov Models}, journal = COSB, year = 1996, volume = 6, pages = {361--365} } @article{EddyEtal95, author = "S. R. Eddy and G. J. Mitchison and R. Durbin", title = "Maximum discrimination hidden {M}arkov models of sequence consensus", journal = JComputBiol, year = 1995, volume = 2, number = 1, pages = "9-23" } @article{Edwards63, author = "A. W. F. Edwards and L. Cavalli-Sforza", title = "The reconstruction of evolution", journal = AHG, volume = 27, pages = "105", year = 1963 } @incollection{Edwards64, author = {A. W. F. Edwards and L. Cavalli-Sforza}, title = "Reconstruction of evolutionary trees", booktitle = "Phenetic and Phylogenetic Classification", pages = "67-76", editor = "V. H. Heywood and J. Mc{N}eill", publisher = "Systematics Association Publication No. 6", address = "London", year = 1964 } @article{Edwards70, author = "A. W. F. Edwards", title = "Estimation of the branch points of a branching diffusion process", journal = JRSS, volume = 32, pages = "155-174", year = 1970 } @book{Edwards92, author = "A. W. F. Edwards", title = "Likelihood", publisher = "Johns Hopkins Universty Press", address = "Baltimore, London", year = 1992 } @article{Edwards96, author = "A. W. F. Edwards", title = "The origin and early development of the method of minimum evolution for the reconstruction of phylogenetic trees", journal = SYSB, volume = 45, pages = "179-191", year = 1996 } @book{EfronTibshirani93, author = "B. Efron and R. J. Tibshirani", title = "An Introduction to the Bootstrap", publisher = "Chapman and Hall", address = "London", year = 1993 } @article{EfronEtal96, author = "B. Efron and E. Halloran and S. Holmes", title = "Bootstrap confidence levels for phylogenetic trees", journal = PNAS, volume = 93, pages = "13429-13434", year = 1996 } @book{Feller71, author = "W. Feller", title = "An Introduction to Probability Theory and its Applications, Vol II.", publisher = "John Wiley and Sons", address = "New York", year = 1971 } @article{Felsenstein73, author = "J. Felsenstein", title = "Maximum-likelihood estimation of evolutionary trees from continuous characters", journal = AJHG, volume = 25, pages = "471-492", year = 1973 } @article{Felsenstein78, author = "J. Felsenstein", title = "The number of evolutionary trees", journal = SZ, volume = 27, pages = "27-33", year = 1978 } @article{Felsenstein78b, author = "J. Felsenstein", title = "Cases in which parsimony or compatibility methods will be positively misleading", journal = SZ, volume = 27, pages = "401-410", year = 1978 } @Article{Felsenstein81, author = "J. Felsenstein", title = "Evolutionary Trees from {DNA} Sequences: a Maximum Likelihood Approach", journal = JME, year = 1981, volume = 17, pages = "368-376" } @article{Felsenstein81b, author = "J. Felsenstein", title = "A likelihood approach to character weighting and what it tells us about parsimony and compatibility", journal = BJLS, volume = 16, pages = "183-196", year = 1981 } @article{Felsenstein85, author = "J. Felsenstein", title = "Confidence limits on phylogenies: an approach using the bootstrap", journal = EVO, volume = 39, pages = "783-791", year = 1985 } @article{Felsenstein96, author = "J. Felsenstein", title = "Inferring phylogenies from protein sequences by parsimony, distance, and likelihood methods", journal = ME, volume = 266, pages = "418-427", year = 1996 } @article{FelsensteinChurchill96, author = "J. Felsenstein and G. A. Churchill", title = "A hidden {M}arkov model approach to variation among sites in rate of evolution", journal = MBE, volume = 13, pages = "93-104", year = 1996 } @article{FengDoolittle87, author = "D.-F. Feng and R. F. Doolittle", title = "Progressive Sequence Alignment as a Prerequisite to Correct Phylogenetic Trees", journal = JME, volume = 25, pages = "351-360", year = 1987 } @article{FengDoolittle96, author = "D.-F. Feng and R. F. Doolittle", title = "Progressive Alignment of Amino Acid Sequences and Construction of Phylogenetic Trees from Them", journal = ME, volume = 266, pages = "368-382", year = 1996 } @Article{Fichant91, author = "G. A. Fichant and C. Burks", title = "Identifying Potential {tRNA} Genes in Genomic {DNA} Sequences", journal = JMB, year = 1991, volume = 220, pages = "659-671" } @Article{FieldsGutell96, author = {D. S. Fields and R. R. Gutell}, title = {An Analysis of Large {rRNA} Sequences Folded by a Thermodynamic Method}, journal = {Folding and Design}, year = 1996, volume = 1, pages = {419-430} } @article{Fitch71, author = "W. M. Fitch", title = "Toward defining the course of evolution: minimum change for a specifed tree topology", journal = SZ, volume = 20, pages = "406-416", year = 1971 } @article{FitchMargoliash67, author = "W. M. Fitch and E. Margoliash", title = "Construction of phylogenetic trees", journal = Science, volume = 155, pages = "279-284", year = 1967 } @article{FitchMargoliash67b, author = "W. M. Fitch and E. Margoliash", title = "A method for estimating the number of invariant amino acid coding positions in a gene using cytochrome c as a model case", journal = BIOGEN, volume = 1, pages = "65-71", year = 1967 } @inproceedings{FrasconiBengio94, author = "P. Frasconi and Y. Bengio", title = "An {EM} approach to grammatical inference: input/output {HMM}s", year = "1994", volume = "2", booktitle = "Proceedings of the 12th IAPR International Conference on Pattern Recognition", publisher = "IEEE Computer Society Press", address = "Los Alamitos, CA", pages = "289-294" } @article{Freier86, author = "S. M. Freier and R. Kierzek and J. A. Jaeger and N. Sugimoto and M. H. Caruthers and T. Neilson and D. H. Turner", title = "Improved Free-Energy Parameters for Predictions of {RNA} Duplex Stability", journal = PNAS, volume = "83", year = 1986, pages = "9373-9377" } @inproceedings{FujiwaraEtal94, author = "Y. Fujiwara and M. Asogawa and A. Konagaya", title = "Stochastic Motif Extraction Using Hidden {M}arkov Model", pages = "121--129", crossref = "ismb94" } @Article{Gautheret90, author = "D. Gautheret and F. Major and R. Cedergren", title = "Pattern Searching/Alignment with {RNA} Primary and Secondary Structures: an Effective Descriptor for {tRNA}", journal = CABIOS, year = 1990, volume = 6, pages = "325-331" } @article{Gelfand96, author = "M. S. Gelfand and A. A. Mironov and P. A. Pevzner", title = "Gene recognition via spliced sequence alignment", journal = PNAS, year = 1996, volume = 93, pages = "9061-9066", } @article{GersteinEtal94, author = "M. Gerstein and E. L. L. Sonnhammer and C. Chothia", title = "Volume changes in protein evolution", journal = JMB, volume = 236, pages = "1067-1078", year = 1994 } @InProceedings{GersteinLevittISMB96, author = {M. Gerstein and M. Levitt}, title = {Using Iterative Dynamic Programming to Obtain Accurate Pairwise and Multiple Alignments of Protein Structures}, pages = {59-67}, crossref = "ismb96" } @Book{Gersting93, author = "J. L. Gersting", title = "Mathematical Structures for Computer Science", publisher = {W. H. Freeman}, year = 1993 } @Book{Gesteland93, title = "The {RNA} World", publisher = "Cold Spring Harbor Laboratory Press", year = 1993, editor = "R. F. Gesteland and J. F. Atkins", address = "New York" } @Article{Gilbert86, author = "W. Gilbert", title = "The {RNA} World", journal = Nature, year = 1986, volume = 319, pages = 618 } @Article{Gold95, author = "L. Gold and B. Polisky and O. Uhlenbeck and M. Yarus", title = "Diversity of Oligonucleotide Functions", journal = ARB, year = 1995, volume = 64, pages = "763-797" } @article{Goldman93, author = "N. Goldman", title = "Statistical tests of models of {DNA} substitution", journal = JME, volume = 36, pages = "182-198", year = 1993 } @article{GoldmanYang94, author = "N. Goldman and Z. Yang", title = "A codon-based model of nucleotide substitution for protein-coding {DNA} sequences", journal = MBE, volume = 11, pages = "725-735", year = 1994 } @article{GonnetEtal92, author = "G. H. Gonnet and M. A. Cohen and S. A. Benner", title = "Exhaustive matching of the entire protein sequence database", journal = Science, year = 1992, volume = 256, number = 5062, pages = "1443-1445" } @article{Gotoh82, author = {O. Gotoh}, title = {An improved algorithm for matching biological sequences}, journal = JMB, year = 1982, volume = 162, pages = {705-708} } @article{Gotoh93, myref = "BIO220", author = "O. Gotoh", title = "Optimal alignment between groups of sequences and its application to multiple sequence alignment", year = 1993, journal = CABIOS, pages = "361-370", number = 3, volume = 9 } @article{Gotoh96, author = "O. Gotoh", title = "Significant Improvement in Accuracy of Multiple Protein Alignments by Iterative Refinement as Assessed by Reference to Structural Alignments", year = 1996, journal = JMB, volume = "264", pages = "823-838" } @InProceedings{Grate95, author = {L. Grate}, title = {Automatic {RNA} Secondary Structure Determination with Stochastic Context-Free Grammars}, pages = {136-144}, crossref = "ismb95" } @article{GribskovEtal87, author = "M. Gribskov and A. D. Mc{L}achlan and D. Eisenberg", title = "Profile Analysis: detection of Distantly Related Proteins", journal = PNAS, year = 1987, volume = 84, pages = "4355-4358" } @article{GribskovEtal90, author = {M. Gribskov and R. L{\"u}thy and D. Eisenberg}, title = "Profile analysis", journal = ME, volume = 183, pages = "146-159", year = 1990, } @article{GribskovVeretnik96, author = "M. Gribskov and S. Veretnik", title = "Identification of Sequence Patterns with Profile Analysis", journal = ME, year = 1996, volume = 266, pages = "198-212" } @article{Grundy96, title = "Meta-MEME: motif-based hidden Markov models of protein families.", author = "W. N. Grundy and T. L. Bailey and C. P. Elkan and M. E. Baker", pages = "397-406", year = "1997", journal = CABIOS, } @article{ParkEtal96, title = "Sequence comparisons using multiple sequences detect three times as many remote homologues as pairwise methods.", journal = JMB, volume = 284, author = "J. Park and K. Karplus and C. Barrett and R. Hughey and D. Haussler and T. Hubbard and C. Chothia", pages = "1201-1210", year = 1996, } @Article{Gultyaev91, author = {A. P. Gultyaev}, title = {The Computer Simulation of {RNA} Folding Involving Pseudoknot Formation}, journal = NAR, year = 1991, volume = 19, pages = {2489-2494} } @book{Gumbel58, author = "E. J. Gumbel", title = "Statistics of Extremes", publisher = "Columbia University Press", address = "New York", year = 1958 } @Article{Gupta95, author = {S. K. Gupta and J. D. Kececioglu and A. A. Schaffer}, title = {Improving the Practical Space and Time Efficiency of the Shortest-Paths Approach to Sum-of-Pairs Multiple Sequence Alignment}, journal = JComputBiol, year = 1995, volume = 2, pages = {459-472} } @Article{Gutell92, author = "R. R. Gutell and A. Power and G. Z. Hertz and E. J. Putz and G. D. Stormo", title = "Identifying Constraints on the Higher-Order Structure of {RNA}: continued Development and Application of Comparative Sequence Analysis Methods", journal = NAR, year = 1992, volume = 20, pages = "5785-5795" } @Article{Gutell93, author = {R. R. Gutell}, title = {Collection of Small Subunit ({16S} and {16S}-like) Ribosomal {RNA} Structures}, journal = NAR, year = 1993, volume = 21, pages = {3051-3054} } @Article{HHS-89a, author = "G. Z. Hertz and G. W. Hartzell {III} and G. D. Stormo", title = "Identification of consensus patterns in unaligned {DNA} sequences known to be functionally related", journal = CABIOS, year = 1990, volume = 6, pages = "81-92" } @book{HKP:Binder88, author = "K. Binder and D. W. Heerman", title = "Monte {C}arlo Simulation in Statistical Mechanics", publisher = "Springer-Verlag", address = "Berlin", year = 1988 } @article{HannenhalliEtal95, author = "S. Hannenhalli and C. Chappey and E. V. Koonin and P. A. Pevsner", title = "Genome sequence comparison and scenarios for gene rearrangements: a test case", journal = {Genomics}, volume = 30, pages = "299-311", year = 1995 } @Article{Harpaz94, author = "Y. Harpaz and C. Chothia", title = "Many of the Immunoglobulin Superfamily Domains in Cell Adhesion Molecules and Surface Receptors Belong to a New Structural Set Which is Close to That Containing Variable Domains", journal = JMB, year = 1994, volume = 238, pages = "528-539" } @Book{Harrison78, author = {M. A. Harrison}, title = {Introduction to Formal Language Theory}, publisher = {Addison-Wesley}, year = 1978 } @article{HasegawaEtal85, author = "M. Hasegawa and H. Kishino and T. Yano ", title = "Dating the human-ape splitting by a molecular clock of mitochondrial {DNA}", journal = JME, volume = 22, pages = "160-174", year = 1985 } @inproceedings{HausslerEtal93, author= {D. Haussler and A. Krogh and I. S. Mian and K. Sj{\"o}lander}, title= "Protein Modeling using Hidden {M}arkov Models: analysis of Globins", booktitle= "Proceedings of the Twenty-Sixth Annual Hawaii International Conference on System Sciences", editor={T. N. Mudge and V. Milutinovic and L. Hunter}, volume={1}, pages={792--802}, publisher = "IEEE Computer Society Press", address="Los Alamitos, CA", year= "1993" } @article{HebsgaardEtal96, author = "S. M. Hebsgaard and P. G. Korning and N. Tolstrup and J. Engelbrecht and P. Rouz\'e and S. Brunak", title = "Splice site prediction in {A}rabidopsis thaliana pre-m{RNA} by combining local and global sequence information", journal = NAR, volume = 24, year = 1996, pages = "3439-3452" } @article{Hein89a, author = "J. Hein", title = "A new method that simultaneously aligns and reconstructs ancestral sequences for any number of homologous sequences, when the phylogeny is given.", journal = MBE, year = "1989", volume = "6", number = "6", pages = "649-668" } @article{Hein89b, author = "J. Hein", title = "A tree reconstruction method that is economical in the number of pairwise comparisons used.", journal = MBE, year = "1989", volume = "6", number = "6", pages = "669-684" } @article{Hein93, author = "J. J. Hein", title = "A heuristic method to reconstruct the history of sequences subject to recombination", journal = JME, volume = 36, year = 1993, pages = "396-405" } @article{Hein94, author = "J. Hein", title = "An algorithm combining DNA and protein alignment.", journal = JTB, volume = 167, pages = {169-174}, year = 1994, } Hein J, Stovlbaek J @article{HendersonEtal96, author = "J. Henderson and S. Salzberg and K. H. Fasman", title = "Finding Genes in {DNA} with a Hidden {M}arkov Model", journal = JCB, volume = 4, number = 2, pages = "127-141", year = 1997 } @article{HendyEtal89, author = "M. D. Hendy and D. Penny ", title = "A framework for the quantitative study of evolutionary trees", journal = SZ, volume = 38, pages = "297-309", year = 1989 } @Article{Henikoff91, author = {S. Henikoff and J. G. Henikoff}, title = {Automated Assembly of Protein Blocks for Database Searching}, journal = NAR, year = 1991, volume = 19, pages = {6565-6572} } @article{HenikoffEtal92, author = "S. Henikoff and J. G. Henikoff ", title = "Amino acid substitution matrices from protein blocks", journal = PNAS, volume = 89, pages = "10915-10919", year = 1992 } @article{HenikoffHenikoff94, author = "S. Henikoff and J. G. Henikoff", title = "Position-based sequence weights", journal = JMB, year = 1994, volume = 243, number = 4, pages = "574-578" } @article{HenikoffHenikoff96, author = "J. G. Henikoff and S. Henikoff ", title = "Using substitution probabilities to improve position-specific scoring matrices", journal = CABIOS, year = 1996, volume = 12, pages = "135-143" } @article{HigginsEtal92, author = "D. G. Higgins and A. J. Bleasby and R. Fuchs", title = "{CLUSTAL V:} improved software for multiple sequence alignment.", journal = CABIOS, year = 1992, volume = 8, number = 2, pages = "189-191" } @article{HigginsSharp89, author = "D. G. Higgins and P. M. Sharp ", title = "Fast and Sensitive Multiple Sequence Alignments on a Microcomputer", journal = CABIOS, year = 1989, volume = 5, pages = "151-153" } @article{HillisBull93, author = "D. M. Hillis and J. J. Bull ", title = "An empirical test of bootstrapping as a method for assessing confidence in phylogenetic analysis", journal = SYSB, volume = 42, pages = "182-192", year = 1993 } @article{HillisEtal92, author = "D. M. Hillis and J. J. Bull and M. E. White and M. R. Badgett and I. J. Molineux", title = "Experimental phylogenetics: generation of a known phylogeny", journal = S, volume = 255, pages = "589-592", year = 1992 } @article{HirosawaEtal93, author = "M. Hirosawa and M. Hoshida and M. Ishikawa and T. Toya", title = "{MASCOT}: multiple alignment system for protein sequences based on three-way dynamic programming", journal = CABIOS, year = 1993, volume = 9, number = 2, pages = "161-167" } @Article{Hirschberg75, author = {D. S. Hirschberg}, title = {A Linear Space Algorithm for Computing Maximal Common Subsequences}, journal = CACM, year = 1975, volume = 18, pages = {341-343} } @article{HogewegHesper84, author = "P. Hogeweg and B. Hesper", title = "The alignment of sets of sequences and the construction of phyletic trees: an integrated method", journal = JME, volume = 20, pages = "175-186", year = 1984 } @Article{HolmSander93, author = {L. Holm and C. Sander}, title = {Protein Structure Comparison by Alignment of Distance Matrices}, journal = JMB, year = 1993, volume = 233, pages = {123-138} } @Book{HopcroftUllman79, author = "J. E. Hopcroft and J. D. Ullman", title = "Introduction to Automata Theory, Languages, and Computation", publisher = "Addison-Wesley", year = 1979 } @Book{KilShin, author = "D. H. Kil and F. B. Shin", title = "Pattern recognition and prediction with applications to signal characterization", publisher = "AIP Press", year = 1996, } @Article{HuangZhang96, author = {X. Huang and J. Zhang}, title = {Methods for Comparing a {DNA} Sequence with a Protein Sequence}, journal = CABIOS, year = 1996, volume = 12, pages = {497-506} } @article{Hubbard99, author = "T. J. P. Hubbard", title = "{RMS}/Coverage graphs: A qualitative method for comparing three-dimensional protein structure predictions", journal = PROT, volume = 3, pages = "15-21", year = 1999, } @article{HuelsenbeckRannala97, author = "J. P. Huelsenbeck and B. Rannala ", title = "Phylogenetic methods come of age: testing hypotheses in an evolutionary context", journal = Science, volume = 276, pages = "227-232", year = 1997 } @incollection{Hudson90, author = "R. R. Hudson ", title = "Gene genealogies and the coalescent process", booktitle = "Gene Genealogies and the Coalescent Process", pages = "1-44", editor = "D. Futuyma and J. Antonovics", publisher = "Oxford University Press", address = "Oxford, UK", year = 1990 } @article{HugheyKrogh96, author = {R. Hughey and A. Krogh}, title = {Hidden {M}arkov models for sequence analysis: extension and analysis of the basic method}, journal = CABIOS, year = 1996, volume = 12, pages = {95-107} } @Article{Jacob77, author = {F. Jacob}, title = {Evolution and tinkering}, journal = Science, year = 1977, volume = 196, pages = {1161-1166} } @Article{Jefferys92, author = {W. H. Jefferys and J. O. Berger}, title = {Ockham's Razor and {B}ayesian Analysis}, journal = {American Scientist}, year = 1992, volume = 80, pages = {64-72} } @article{JuangRabiner91, author = "B. H. Juang and L. R. Rabiner ", title = "Hidden {M}arkov models for speech recognition", journal = "Technometrics", year = "1991", number = 3, volume = 33, pages = "251-272" } @incollection{JukesCantor69, author = "T. H. Jukes and C. Cantor ", title = "Evolution of protein molecules", booktitle = "Mammalian Protein Metabolism", pages = "21-132", publisher = "Academic Press", address = "New York", year = 1969 } @Article{Karlin90, author = "S. Karlin and S. F. Altschul", title = "Methods for Assessing the Statistical Significance of Molecular Sequence Features by Using General Scoring Schemes", journal = PNAS, year = 1990, volume = 87, pages = "2264-2268" } @Article{KarlinAltschul93, author = "S. Karlin and S. F. Altschul", title = "Applications and statistics for multiple high-scoring segments in molecular sequences", journal = PNAS, year = 1993, volume = 90, pages = "5873-5877" } @InProceedings{Karplus95, author = {K. Karplus}, title = {Evaluating Regularizers for Estimating Distributions of Amino Acids}, pages = {188--196}, crossref = "ismb95" } @book{Keeping95, author = "E. S. Keeping ", title = "Introduction to Statistical Inference", publisher = "Dover Publications", address = "New York", year = 1995 } @article{KimEtal94, author = "J. Kim and S. Pramanik and M. J. Chung", title = "Multiple sequence alignment using simulated annealing", journal = CABIOS, volume = 10, pages = "419-426", year = 1994 } @inproceedings{KimPramanik94, author = "J. Kim and S. Pramanik", title = "An Efficient Method for Multiple Sequence Alignment", pages = "212--218", crossref = "ismb94" } @article{Kimura80, author = "M. Kimura", title = "A simple method for estimating evolutionary rates of base substitutions through comparative studies of nucleotide sequences", journal = JME, volume = 16, pages = "111-120", year = 1980 } @book{Kimura83, author = "M. Kimura", title = "The Neutral Theory of Molecular Evolution", publisher = "Cambridge University Press", address = "Cambridge, UK", year = 1983 } @article{Kingman82a, author = "J. F. C. Kingman ", title = "The coalescent", journal = "Stochastic Processes and their Applications", volume = 13, pages = "235-248", year = 1982 } @article{Kingman82b, author = "J. F. C. Kingman ", title = "On the genealogy of large populations", journal = "Journal of Applied Probability", volume = "19A", pages = "27-43", year = 1982 } @article{Kirkpatrick83, author = "S. Kirkpatrick and C. D. Gelatt Jr. and M. P. Vecchi", title = "Optimization by Simulated Annealing", journal = Science, volume = 220, year = 1983, pages = "671-680" } @article{KishinoEtal90, author = "H. Kishino and T. Miyata and M. Hasegawa ", title = "Maximum likelihood inference of protein phylogeny and the origin of chloroplasts", journal = JME, volume = 31, pages = "151-160", year = 1990 } @Article{Konings89, author = "D. A. M. Konings and P. Hogeweg", title = "Pattern Analysis of {RNA} Secondary Structure: similarity and Consensus of Minimal-Energy Folding", journal = JMB, year = 1989, volume = 207, pages = "597-614" } @Article{KoningsGutell95, author = {D. A. M. Konings and R. R. Gutell}, title = {A Comparison of Thermodynamic Foldings with Comparatively Derived Structures of {16S} and {16S}-Like {rRNAs}}, journal = {RNA}, year = 1995, volume = 1, pages = {559-574} } @Article{ChurchillLazareva99, author = "G. A. Churchill and B. Lazareva", title = "Bayesian restoration of a hidden Markov chain with applications to DNA sequencing.", journal = JCB, pages = "261-277", year = 1999, } @Article{Krogh94a, author = "A. Krogh and I. S. Mian IS and D. Haussler", title = "A hidden Markov model that finds genes in E. coli DNA.", journal = NAR, pages = {4768-4778}, year = 1994, } @inproceedings{Krogh94, author = {A. Krogh}, title = {Hidden {M}arkov Models for Labeled Sequences}, booktitle="Proceedings of the 12th IAPR International Conference on Pattern Recognition", publisher="IEEE Computer Society Press", address="Los Alamitos, CA", pages= "140--144", year = 1994 } @inproceedings{Krogh97a, author = "A. Krogh", title = "Two methods for improving performance of a {HMM} and their application for gene finding", crossref = "ismb97", year = 1997, pages = "179-186" } @incollection{Krogh97b, author = "A. Krogh", title = "An Introduction to Hidden {M}arkov Models for Biological Sequences", booktitle = "Computational Biology: Pattern Analysis and Machine Learning Methods", publisher = "Elsevier", address = "Amsterdam", editor = "S. Salzberg and D. Searls and S. Kasif", chapter = 4, year = 1998, note = "In press" } @incollection{Krogh97c, author = "A. Krogh", title = "Gene finding: putting the parts together", booktitle = "Guide to Human Genome Computing", editor = "M. Bishop", edition = "2nd", year = 1997, publisher = "Academic Press", note = "To appear" } @article{KroghEtal94a, author = {A. Krogh and M. Brown and I. S. Mian and K. Sj{\"o}lander and D. Haussler}, title = "Hidden {M}arkov models in computational biology: applications to protein modeling", journal = JMB, volume = 235, pages = "1501-1531", month= "Feb.", year = "1994" } @article{KroghEtal94b, author= "A. Krogh and I. S. Mian and D. Haussler", title="A Hidden {M}arkov Model that finds genes in {E}. coli {DNA}", journal = NAR, volume = 22, pages = "4768--4778", year = 1994 } @inproceedings{KroghMitchison95, author = {A. Krogh and G. J. Mitchison}, title = {Maximum Entropy Weighting of Aligned Sequences of Proteins or {DNA}}, pages = "215-221", crossref = "ismb95" } @article{KuhnerEtal95, author = "M. K. Kuhner and J. Yamato and J. Felsenstein ", title = "Estimating effective population size and mutation rate from sequence data using {M}etropolis--{H}astings sampling", journal = GEN, volume = 140, pages = "1421-1430", year = 1995 } @inproceedings{KulpEtal96, author = "D. Kulp and D. Haussler and M. G. Reese and F. H. Eeckman", title = "A Generalized Hidden {M}arkov Model for the Recognition of Human Genes in {DNA}", pages = "134-142", crossref = "ismb96" } @article{LangleyFitch74, author = "C. H. Langley and W. M. Fitch ", title = "An examination of the constancy of the rate of molecular evolution", journal = JME, volume = 3, pages = "161-177", year = 1974 } @Article{Lari90, author = "K. Lari and S. J. Young", title = "The Estimation of Stochastic Context-Free Grammars Using the Inside--Outside Algorithm", journal = "Computer Speech and Language", year = 1990, volume = 4, pages = "35-56" } @Article{Lari91, author = "K. Lari and S. J. Young", title = "Applications of Stochastic Context-Free Grammars Using the Inside--Outside Algorithm", journal = "Computer Speech and Language", year = 1991, volume = 5, pages = "237-257" } @Article{Larsen93, author = "N. Larsen and C. Zwieb", title = "The Signal Recognition Particle Database {(SRPDB)}", journal = NAR, year = 1993, volume = 21, pages = "3019-3020" } @book{LawKelton91, author = "A. M. Law and W. D. Kelton ", title = "Simulation Modelling and Analysis", publisher = "McGraw-Hill", address = "New York, London", year = 1991 } @article{LawrenceEtal93, author = "C. E. Lawrence and S. F. Altschul and M. S. Boguski and J. S. Liu and A. F. Neuwald and J. C. Wootton", title = "Detecting subtle sequence signals: a {G}ibbs sampling strategy for multiple alignment", journal = Science, year = 1993, volume = 262, number = 5131, pages = "208-214" } @article{LawrenceReilly90, author = "C. E. Lawrence and A. A. Reilly", title = "An expectation maximization {(EM)} algorithm for the identification and characterization of common sites in unaligned biopolymer sequences", journal = PROT, year = 1990, volume = 7, number = 1, pages = "41-51" } @InProceedings{Lefebvre95, author = {F. Lefebvre}, title = {An Optimized Parsing Algorithm Well Suited to {RNA} Folding}, pages = {222-230}, crossref = "ismb95" } @InProceedings{Lefebvre96, author = {F. Lefebvre}, title = {A Grammar-Based Unification of Several Alignment and Folding Algorithms}, pages = {143-154}, crossref = "ismb96" } @Article{Lindenmayer68, author = {A. Lindenmayer}, title = {Mathematical Models for Cellular Interactions in Development {I.} Filaments with One-Sided Inputs}, journal = JTB, year = 1968, volume = 18, pages = {280-299} } @article{LipmanEtal89, author = "D. J. Lipman and S. F. Altschul and J. D. Kececioglu", title = "A tool for multiple sequence alignment", journal = PNAS, volume = 86, pages = "4412-4415", year = 1989 } @Article{Lisacek94, author = "F. Lisacek and Y. Diaz and F. Michel", title = "Automatic Identification of Group {I} Intron Cores in Genomic {DNA} Sequences", journal = JMB, year = 1994, volume = 235, pages = "1206-1217" } @Article{LoweEddy97, author = {T. M. Lowe and S. R. Eddy}, title = {{tRNAscan-SE}: a Program for Improved Detection of Transfer {RNA} Genes in Genomic Sequence}, journal = NAR, year = 1997, volume = 25, pages = {955-964} } @article{LukashinEtal92, author = "A. V. Lukashin and J. Engelbrecht and S. Brunak", title = "Multiple alignment using simulated annealing: branch point definition in human m{RNA} splicing", journal = NAR, volume = 20, pages = "2511-2516", year = 1992 } @article{LuthyEtal91, author = "R. Luthy and A. D. Mc{L}achlan and D. Eisenberg", title = "Secondary structure-based profiles: use of structure-conserving scoring tables in searching protein sequence databases for structural similarities", journal = "Proteins", year = 1991, volume = 10, number = 3, pages = "229-239" } @article{LuthyEtal94, author = "R. Luthy and I. Xenarios and P. Bucher", title = "Improving the sensitivity of the sequence profile method", journal = PROTSCI, year = 1994, volume = 3, number = 1, pages = "139-146" } @article{MacKay92, author= "D. J. C. Mac{K}ay", title= "Bayesian Interpolation", journal = NC, volume = "4", pages = "415-447", year = 1992 } @article{MacKayPeto95, author = "D. J. C. Mac{K}ay and L. Peto", title = "A Hierarchical {D}irichlet Language Model", year = 1995, journal = "Natural Language Engineering", volume=1, number=3, pages="1-19" } @Article{Margalit89, author = {H. Margalit and B. A. Shapiro and A. B. Oppenheim and J. V. Maizel}, title = {Detection of Common Motifs in {RNA} Secondary Structures}, journal = NAR, year = 1989, volume = 17, pages = {4829-4845} } @book{MathewsWalker70, author = "J. Mathews and R. L. Walker ", title = "Mathematical Methods of Physics", publisher = "W. A. Benjamin", address = "New York", year = 1970 } @techreport{MauEtal96, author = "B. Mau and M. A. Newton and B. Larget ", title = "Bayesian phylogenetic inference via {M}arkov chain {M}onte {C}arlo methods", institution = "Statistics Department, University of Wisconsin-Madison", number = 961, year = 1996 } @Article{Maxwell95, author = "E. S. Maxwell and M. J. Fournier", title = "The Small Nucleolar {RNAs}", journal = ARB, year = 1995, volume = 64, pages = "897-934" } @article{McCaskill90, author = "J. S. Mc{C}askill", title = "The Equilibrium Partition Function and Base Pair Binding Probabilities for {RNA} Secondary Structure", journal = "Biopolymers", volume = "29", year = 1990, pages = "1105-1119" } @Article{McClure94, author = {M. A. Mc{C}lure and T. K. Vasi and W. M. Fitch}, title = {Comparative Analysis of Multiple Protein-Sequence Alignment Methods}, journal = JME, year = 1994, volume = 11, pages = {571--592} } @Article{McKeown92, author = "M. Mc{K}eown", title = "Alternative {mRNA} Splicing", journal = ARCB, year = 1992, volume = 8, pages = "133-155" } @Article{Melefors93, author = "O. Melefors and M. W. Hentze", title = "Translational Regulation by m{RNA}/Protein Interactions in Eukaryotic Cells: ferritin and Beyond", journal = BIOESS, year = 1993, volume = 15, pages = "85-90" } @article{MengRubin92, author = "X.-L. Meng and D. B. Rubin", title = "Recent Extensions to the {EM} Algorithm", journal = "Bayesian Statistics", volume = "4", pages = "307--320", year = "1992", myref = "HMM6" } @article{MevissenVingron96, author = "H. T. Mevissen and M. Vingron ", title = "Quantifying the local reliability of a sequence alignment", journal = PE, year = 1996, volume = 9, number = 2, pages = "127-132" } @article{Mitchison98, author = "G. J. Mitchison ", title = "Probabilistic modelling of phylogeny and alignment", journal = MBE, pages = "submitted", year = 1998 } @article{MitchisonDurbin95, author = "G. J. Mitchison and R. Durbin", title = "Tree-Based Maximal Likelihood Substitution Matrices and Hidden {M}arkov Models", journal = JME, volume = 41, pages = "1139-1151", year = 1995 } @article{Miyazawa94, author = {S. Miyazawa}, title = {A Reliable Sequence Alignment Method Based on Probabilities of Residue Correspondence}, journal = PE, year = 1994, volume = 8, pages = {999-1009} } @Book{Monod71, author = {J. Monod}, title = {Chance and Necessity: An Essay on the Natural Philosophy of Modern Biology}, publisher = {Knopf}, year = 1971, mynote = {Olin QH331 M55313} } @article{Mott92, author = {R. Mott}, title = {Maximum likelihood estimation of the statistical distribution of {S}mith--{W}aterman local sequence similarity scores}, journal = BMB, volume = 54, pages = {59-75}, year = 1992 } @article{Mott97, author = {R. Mott}, title = {Trace alignment and some of its applications}, journal = BI, volume = 14, pages = {92-97}, year = 1997 } @article{Myers94, author = {E. W. Myers}, title = {A sublinear algorithm for approximate keyword searching}, journal = {Algorithmica}, year = 1994, volume = 12, pages = {345-374} } @Article{Myers95, author = {E. W. Myers}, title = {Approximately Matching Context-Free Languages}, journal = {Information Processing Letters}, year = 1995, volume = 54, pages = {85-92} } @Article{MurzinBateman97, author = {A. G. Murzin and A. Bateman}, title = {Distant Homology Recognition using structual classification of proteins}, journal = PROT, year = 1997, volume = 1, pages = {105-112} } @article{MyersMiller88, author = {W. Miller and E. W. Myers}, title = {Sequence comparison with concave weighting functions}, journal = BMB, year = 1988, volume = 50, pages = {97-120} } @Article{MyM-88a, author = "E. W. Myers and W. Miller", title = "Optimal alignments in linear space", journal = CABIOS, year = 1988, volume = 4, number = 1, pages = "11-17" } @book{Neal96, author = "R. M. Neal ", title = "Bayesian Learning in Neural Networks.", publisher = "Springer (Lecture Notes in Statistics)", address = "New York, Berlin", year = 1996 } @unpublished{NealHinton93, author = "R. M. Neal and G. E. Hinton", title = "A New View of the {EM} Algorithm that Justifies Incremental and Other Variants", note = {Preprint, Dept.\ of Computer Science, Univ.\ of Toronto, available from ftp://archive.cis.ohio-state.edu/pub/neuroprose/neal.em.ps.Z}, year = "1993" } @incollection{Neyman71, author = "J. Neyman ", booktitle = "Statistical Decision Theory and Related Topics", editor = "S. S. Gupta and J. Yackel", publisher = "Academic Press", address = "New York", year = 1971 } @Article{Needleman70, author = "S. B. Needleman and C. D. Wunsch", title = "A General Method Applicable to the Search for Similarities in the Amino Acid Sequence of Two Proteins", journal = JMB, year = 1970, volume = 48, pages = "443-453" } @Article{Noller92, author = {H. F. Noller and V. Hoffarth and L. Zimniak}, title = {Unusual Resistance of Peptidyl Transferase to Protein Extraction Procedures}, journal = Science, year = 1992, volume = 256, pages = {1416-1419} } @inproceedings{NormandinMorgera91, author = "Y. Normandin and S. D. Morgera", title = "An Improved {MMIE} Training Algorithm for Speaker-Independent, Small Vocabulary, Continuous Speech Recognition", booktitle = "Proceedings of ICASSP '91", pages = "537--540", year = "1991", myref = "HMM15" } @Article{Nussinov78, author = "R. Nussinov and G. Pieczenik and J. R. Griggs and D. J. Kleitman", title = "Algorithms for Loop Matchings", journal = SIAM, year = 1978, volume = 35, pages = "68-82" } @Article{Pavesi94, author = {A. Pavesi and F. Conterlo and A. Bolchi and G. Dieci and S. Ottonello}, title = {Identification of New Eukaryotic {tRNA} Genes in Genomic {DNA} Databases by a Multistep Weight Matrix Analysis of Transcriptional Control Regions}, journal = NAR, year = 1994, volume = 22, pages = {1247--1256} } @Article{Peltz92, author = "S. W. Peltz and A. Jacobson", title = "{mRNA} Stability: in Trans-it", journal = COCB, year = 1992, volume = 4, pages = "979-983" } @Article{Nagai90, author = "K. Nagai and C. Oubridge and T. H. Jessen and J. Li and P. R. Evans", title = "Crystal structure of the {RNA-binding} domain of the {U1} small nuclear ribonucleoprotein {A}", year = 1990, journal = Nature, volume = 348, pages = {515-520} } @Article{Handa99, title = "Structural basis for recognition of the \emph{tra} {mRNA} precursor by the Sex-lethal protein", author = "N. Handa and O. Nureki and K. Kurimoto and I. Kim and H. Sakamoto and Y. Shimura and Y. Muto Y and S. Yokoyama", journal = Nature, year = 1999, volume = 398, pages = {579-585} } @Article{Oubridge94, author = "C. Oubridge and N. Ito and P. R. Evans PR and C. H. Teo and K. Nagai", title = "Crystal structure at 1.92 {\AA} resolution of the {RNA-binding} domain of the {U1A} spliceosomal protein complexed with an {RNA} hairpin", year = 1994, journal = Nature, volume = 372, pages = {432-438} } @Article{Ouzounis94, author = "C.A. Ouzounis and N. C. Kyrpides", title = "On the evolution of arginases and related enzymes", journal = JME, year = 1994, volume = 1, pages = {101-104} } @article{Pearson96, author = {W. R. Pearson}, title = {Effective Protein Sequence Comparison}, journal = ME, volume = 266, pages = "227-258", year = 1996 } @article{Pearson95, author = {W. R. Pearson}, title = {Comparison of methods for searching protein sequence databases}, journal = {Protein Science}, volume = 4, pages = "1145-1160", year = 1995 } @article{PearsonLipman88, author = {W. R. Pearson and D. J. Lipman}, title = {Improved tools for biological sequence comparison}, journal = PNAS, volume = 4, pages = "2444-2448", year = 1988 } @Article{PearsonMiller92, author = {W. R. Pearson and W. Miller}, title = {Dynamic Programming Algorithms for Biological Sequence Comparison}, journal = ME, year = 1992, volume = 210, pages = {575-601} } @inproceedings{PedersenEtal96, author = "A. G. Pedersen and P. Baldi and S. Brunak and Y. Chauvin ", title = "Characterization of prokaryotic and eukaryotic promoters using hidden {M}arkov models", pages = "182-191", crossref = "ismb96" } @Article{Pesole94, author = "G. Pesole and M. Attimonelli and C. Saccone", title = "Linguistic Approaches to the Analysis of Sequence Information", journal = TIBTECH, year = 1994, volume = 12, pages = "401-408" } @Article{Pietrokovski90, author = {S. Pietrokovski and J. Hirshon and E. N. Trifonov}, title = {Linguistic Measure of Taxonomic and Functional Relatedness of Nucleotide Sequences}, journal = JBSD, year = 1990, volume = 7, pages = {1251-1268} } @book{PreparataShamos85, author = "F. P. Preparata and M. I. Shamos", title = "Computational Geometry", publisher = "Springer-Verlag", address = "New York, Berlin, Heidelberg, Tokyo", year = 1985 } @book{PressEtal92, author = "W. H. Press and S. A. Teukolsky and W. Vetterling T. and B. P. Flannery", title = "Numerical Recipes in {C}", publisher = "Cambridge University Press", address = "Cambridge, UK", year = 1992 } @article{RabinerJuang86, author= "L. R. Rabiner and B. H. Juang", title= "An Introduction to Hidden {M}arkov Models", journal= "IEEE ASSP Magazine", year= 1986, volume= 3, number= 1, pages= "4-16" } @book{RabinerJuang93, author = "L. R. Rabiner and B. H. Juang", title = "Fundamentals of Speech Recognition", publisher= "Prentice-Hall", address= "Englewood Cliffs, NJ", year= 1993 } @article{Rabiner89, author = "L. R. Rabiner", title = "A Tutorial on Hidden {M}arkov Models and Selected Applications in Speech Recognition", journal = "Proceedings of the IEEE", year = 1989, volume = 77, pages = "257-286" } @article{RannalaYang96, author = "B. Rannala and Z. Yang ", title = "Probability distribution of molecular evolutionary trees: a new method of phylogenetic inference", journal = JME, volume = 43, pages = "304-311", year = 1996 } @article{ReeseEtal96, author = "M. G. Reese and F. H. Eeckman and D. Kulp and D. Haussler", title = "Improved Splice Site Detection in {G}enie", journal = JCB, volume = 4, number = 3, pages = "311-323", year = 1997 } @article{RenalsEtal94, author = "S. Renals and N. Morgan and H. Bourlard and M. Cohen and H. Franco", title = "Connectionist probability estimators in HMM speech recognition.", journal = "IEEE Transactions on Speech and Audio Processing", year = 1994, volume = 2, pages = "161-174" } @article{Rivas99, author = "Eleanor Rivas and Sean Eddy", title = "A dynamic programming algorithm for RNA structure prediction including pseudoknots", journal = JMB, year = 1999, volume = 285, pages = "2053-2068", } @inproceedings{RiisKrogh97, author = {S. K. Riis and A. Krogh }, title = {Hidden Neural Networks: a Framework for {HMM/NN} Hybrids}, booktitle = "Proceedings of ICASSP '97", year = "1997", publisher = "IEEE", address = "New York", vol = 4, pages = "3233-3236" } @book{Ripley96, author= "B. D. Ripley", title= "Pattern Recognition and Neural Networks", publisher= "Cambridge University Press", address= "Cambridge, UK", year= 1996 } @Article{Rosenblueth96, author = {D. A. Rosenblueth and D. Thieffry and A. M. Huerta and H. Salgado and J. Collado-Vides}, title = {Syntactic Recognition of Regulatory Regions in {E}scherichia coli}, journal = CABIOS, year = 1996, volume = 12, pages = {415-422} } @Article{RussellBarton92, author = {R. B. Russell and G. J. Barton}, title = {Multiple Protein Sequence Alignment from Tertiary Structure Comparison: assignment of Global and Residue Confidence Levels}, journal = PROT, year = 1992, volume = 14, pages = {309-323} } @article{Saitou96, author = "N. Saitou ", title = "Reconstruction of gene trees from sequence data", journal = ME, volume = 266, pages = "427-448", year = 1996 } @article{SaitouNei87, author = "N. Saitou and M. Nei ", title = "The neighbor-joining method: a new method for reconstructing phylogenetic trees.", journal = MBE, volume = 4, pages = "406-425", year = 1987 } @Article{Sakakibara94c, author = "Y. Sakakibara and M. Brown and R. Hughey and I. Saira Mian and Kimmen Sj{\"o}lander and R. C. Underwood and D. Haussler", title = "Stochastic Context-Free Grammars for {tRNA} Modeling", journal = NAR, year = 1994, volume = 22, pages = "5112-5120" } @article{Sankoff75, author = "D. Sankoff ", title = "Minimal mutation trees of sequences.", journal = SIAM, volume = 28, pages = "35-42", year = 1975 } @Book{Sankoff83, author = {D. Sankoff and J. B. Kruskal}, title = {Time Warps, String Edits, and Macromolecules: The Theory and Practice of Sequence Comparison}, publisher = {Addison-Wesley}, year = 1983, address = {London} } @incollection{SankoffCedergren83, author = "D. Sankoff and R. J. Cedergren", title = "Simultaneous Comparison of Three or More Sequences Related by a Tree", booktitle = "Time Warps, String Edits, and Macromolecules: the Theory and Practice of Sequence Comparison", chapter = 9, pages = "253-264", editor = "D. Sankoff and J. B. Kruskal", publisher = "Addison-Wesley", address = "Reading, MA", year = 1983 } @article{SankoffEtal73, author = "D. Sankoff and C. Morel and R. J. Cedergren", title = "Evolution of {5S} {RNA} and the nonrandomness of base replacement.", journal = NNB, year = "1973", volume = "245", pages = "232-234" } @article{SchneiderStephens90, author = "T. D. Schneider and R. M. Stephens", title = "Sequence logos: a new way to display consensus sequences", journal = NAR, year = 1990, volume = 18, pages = "6097-6100" } } @Article{Schuster94, author = {P. Schuster and W. Fontana and P. F. Stadler and I. L. Hofacker}, title = {From Sequences to Shapes and Back: a Case Study in {RNA} Secondary Structures}, journal = {Proceedings of the Royal Society: Biological Sciences, Series B}, year = 1994, volume = 255, pages = {279-284} } @Article{Schuster95, author = {P. Schuster}, title = {How to Search for {RNA} Structures. {T}heoretical Concepts in Evolutionary Biotechnology}, journal = {Journal of Biotechnology}, year = 1995, volume = 41, pages = {239-257} } @inproceedings{SchwartzChow90, author = "R. Schwartz and Y.-L. Chow", title = "The {N}-best algorithm: an efficient and exact procedure for finding the N most likely hypotheses", year = "1990", booktitle = "Proceedings of ICASSP'90", pages = "81-84", } @Article{Searls92, author = "D. B. Searls", title = "The Linguistics of {DNA}", journal = "American Scientist", year = 1992, volume = 80, pages = "579-591" } @inproceedings{Searls95, author = "D. B. Searls and K. P. Murphy ", title = "Automata-theoretic models of mutation and alignment", pages = "341-349", crossref = "ismb95" } @Article{Shapiro90, author = "B. A. Shapiro and K. Zhang", title = "Comparing Multiple {RNA} Secondary STructures Using Tree Comparisons", journal = CABIOS, year = 1990, volume = 6, pages = "309-318" } @Article{ShapiroWu96, author = {B. A. Shapiro and J. C. Wu}, title = {An Annealing Mutation Operator in the Genetic Algorithms for {RNA} Folding}, journal = CABIOS, year = 1996, volume = 12, pages = {171-180} } @article{ShimamuraEtal97, author = "M. Shimamura and H. Yasue and K. Ohshima and H. Abe and H. Kato and T. Kishiro and M. Goto and I. Munechika and N. Okada", title = "Molecular evidence from retroposons that whales form a clade within even-toed ungulates", journal = Nature, volume = 388, pages = "666-670", year = 1997 } @Article{Shpaer96, author = {E. G. Shpaer and M. Robinson and D. Yee and J. D. Candlin and R. Mines and T. Hunkapiller}, title = {Sensitivity and Selectivity in Protein Similarity Searches: a Comparison of {Smith--Waterman} in Hardware to {\sc BLAST} and {\sc FASTA}}, journal = {Genomics}, year = 1996, volume = 38, pages = {179-191} } @article{SibbaldArgos90, author = "P. R. Sibbald and P. Argos ", title = "Weighting aligned protein or nucleic acid sequences to correct for unequal representation", journal = JMB, volume = 216, pages = "813-818", year = 1990 } @article{SjolanderEtal96, author={K. Sj{\"o}lander and K. Karplus and M. Brown and R. Hughey and A. Krogh and I. S. Mian and D. Haussler}, title = {Dirichlet Mixtures: a Method for Improved Detection of Weak but Significant Protein Sequence Homology}, journal = CABIOS, year = 1996, volume = 12, number = 4, pages = "327-345" } @article{Smith81, author = "T. F. Smith and M. S. Waterman", title = "Identification of Common Molecular Subsequences", journal = JMB, year = 1981, volume = 147, pages = "195-197", } @article{SokalMichener58, author = "R. R. Sokal and C. D. Michener ", title = "A statistical method for evaluating systematic relationships", journal = UKSB, volume = 28, pages = "1409-1438", year = 1958 } @inproceedings{KroghSonn, author = "E. L. Sonnhammer, G. von Heijne and A. Krogh", title = "A hidden Markov model for predicting transmembrane helices in protein sequences.", pages = "175-182", crossref = "ismb98" } @inproceedings{SolSalLaw95, author = "V. V. Solovyev, A. A. Salamov and C. B. Lawrence", title = "Identification of human gene structure using linear discriminant functions and dynamic programming", pages = "367-375", crossref = "ismb95" } @inproceedings{SolSal97, author = "V. V. Solovyev, A. A. Salamov", title = "The {G}ene-{F}inder computer tools for analysis of human and model organisms genome sequences", pages = "294-302", crossref = "ismb97" } @article{SonnhammerEtal97, author = {E. L. L. Sonnhammer and S. R. Eddy and R. Durbin}, title = {{P}fam: a Comprehensive Database of Protein Domain Families Based on Seed Alignments}, journal = PROT, year = 1997, volume = 28, pages = "405-420" } @article{Staden84, author = "R. Staden", title = "Measurements of the effects that coding for a protein has on a {DNA} sequence and their use for finding genes.", journal = NAR, volume = 12, pages = "551-567", year = 1984, } @Article{Sta-88a, author = "R. Staden", title = "Methods to define and locate patterns of motifs in sequences", journal = CABIOS, year = 1988, volume = 4, number = 1, pages = "53-60" } @Article{Steinberg93, author = "S. Steinberg and A. Misch and M. Sprinzl", title = "Compilation of {tRNA} Sequences and Sequences of {tRNA} Genes", journal = NAR, year = 1993, volume = 21, pages = "3011-3015" } @InProceedings{StolckeOmohundro93, author = "A. Stolcke and S. M. Omohundro", title = "Hidden {M}arkov Model Induction by {B}ayesian Model Merging", editor = "S. J. Hanson and J. D. Cowan and C. L. Giles", volume = 5, pages = "11-18", booktitle = "Advances in Neural Information Processing Systems 5", year = 1993, publisher = "Morgan Kaufmann Publishers, Inc.", address = "San Mateo, CA" } @article{Stormo90, author = {G. D. Stormo}, title = {Consensus patterns in {DNA}}, journal = ME, volume = 183, pages = {211-221}, year = 1990 } @Article{StormoHartzell89, author = "G. D. Stormo and G. W. Hartzell {III}", title = "Identifying Protein--Binding Sites From Unaligned {DNA} Fragments", journal = PNAS, year = 1989, volume = 86, pages = "1183-1187" } @inproceedings{StormoHaussler94, author = "G. D. Stormo and D. Haussler", title = "Optimally Parsing a Sequence into Different Classes Based on Multiple Types of Evidence", pages = "369--375", crossref = "ismb96" } @article{StudierKeppler88, author = "J. A. Studier and K. J. Keppler ", title = "A note on the neighbour-joining algorithm of {S}aitou and {N}ei", journal = MBE, volume = 5, pages = "729-731", year = 1988 } @article{StultzEtal93, author = "C. M. Stultz and J. V. White and T. F. Smith", title = "Structural analysis based on state-space modeling", journal = "Protein Science", year = 1993, volume = 2, pages = "305-314" } @incollection{SwoffordOlsen96, author = {D. L. Swofford and G. J. Olsen }, title = "Phylogeny reconstruction", booktitle = "Molecular Systematics", pages = "407-511", editor = " D. M. Hillis and C. Moritz", publisher = "Sinauer Associates", address = "Sunderland, MA", year = 1996 } @Article{TatusovEtal94, author = {R. L. Tatusov and S. F. Altschul and E. V. Koonin}, title = {Detection of Conserved Segments in Proteins: iterative Scanning of Sequence Databases with Alignment Blocks}, journal = PNAS, year = 1994, volume = 91, pages = {12091--12095} } @article{Taylor87, author = "W. R. Taylor", title = "Multiple sequence alignment by a pairwise algorithm", journal = CABIOS, volume = 3, pages = "81-87", year = 1987 } @Article{Thompson94, author = "J. D. Thompson and D. G. Higgins and T. J. Gibson", title = "Improved Sensitivity of Profile Searches Through the Use of Sequence Weights and Gap Excision", journal = CABIOS, year = 1994, volume = 10, pages = "19-29" } @article{ThompsonEtal94a, author = "J. D. Thompson and D. G. Higgins and T. J. Gibson ", title = "{\sc CLUSTAL W}: improving the Sensitivity of Progressive Multiple Sequence Alignment Through Sequence Weighting, Position Specific Gap Penalties and Weight Matrix Choice", journal = NAR, volume = 22, pages = "4673-4680", year = 1994 } @book{Thompson75, author = "E. A. Thompson", title = "Human Evolutionary Trees", year = 1975, publisher = "Cambridge University Press", address = "Cambridge, UK" } @article{ThorneEtal91, author = {J. L. Thorne and H. Kishino and J. Felsenstein }, title = {An Evolutionary Model for Maximum Likelihood Alignment of {DNA} Sequences}, journal = JME, year = 1991, volume = 33, pages = {114-124} } @article{ThorneEtal92, author = "J. L. Thorne and H. Kishino and J. Felsenstein", title = "Inching Toward Reality: an Improved Likelihood Model of Sequence Evolution", journal = ME, year = 1992, volume = 34, pages = "3-16" } @Article{TolstrupEtal97, author = "N. Tolstrup and P. Rouz\'{e} and S. Brunak ", title = "A branch point consensus from {A}rabidopsis found by non-circular analysis allows for better prediction of acceptor sites", journal = NAR, year = 1997, volume = 25, pages = "3159-3164 " } @Article{Tuerk92c, author = "C. Tuerk and S. Mac{D}ougal and L. Gold", title = "{RNA} Pseudoknots That Inhibit Human Immunodeficiency Virus Type 1 Reverse Transcriptase", journal = PNAS, year = 1992, volume = 89, pages = "6988-6992" } @article{Turner87, author = "D. H. Turner and N. Sugimoto and J. A. Jaeger and C. E. Longfellow and S. M. Freier and R. Kierzek", title = "Improved Parameters for Prediction of {RNA} Structure", journal = CSHSQB, volume = "52", year = 1987, pages = "123-133" } @Article{Vingron96, author = {M. Vingron}, title = {Near-Optimal Sequence Alignment}, journal = COSB, year = 1996, volume = 6, pages = {346-352} } @article{VingronWaterman94, author = {M. Vingron and M. S. Waterman}, title = {Sequence alignment and penalty choice: review of concepts, case studies and implications}, journal = JMB, year = 1994, volume = 235, pages = {1-12} } @book{Waterman95, author = "M. S. Waterman", title = "Introduction to Computational Biology", publisher = "Chapman \& Hall", address = "London", year = 1995 } @article{WatermanEggert87, author = {M. S. Waterman and M. Eggert}, title = {A new algorithm for best subsequence alignments with application to t{RNA}--r{RNA} comparisons}, journal = JMB, year = 1987, volume = 197, pages = {723-725} } @article{WatermanPerlwitz84, author="M. S. Waterman and M. D. Perlwitz", title = "Line Geometries for Sequence Comparisons", journal = BMB, year = "1984", volume = 46, pages = "567-577" } @Article{Watson53, author = {J. D. Watson and F. H. C. Crick}, title = {A Structure for Deoxyribose Nucleic Acid}, journal = Nature, year = 1953, volume = 171, pages = {737-738} } @Book{Watson87, author = "J. D. Watson and N. H. Hopkins and J. W. Roberts and J. A. Steitz and A. M. Weiner", title = "Molecular Biology of the Gene", publisher = "Benjamin/Cummings", year = 1987, address = "Menlo Park, CA" } @article{WhiteEtal91, author="J. V. White and C. M. Stultz and T. F. Smith", title = "Protein classification by stochastic modeling and optimal filtering of amino-acid sequences", journal = "Mathematical Biosciences", year = 1994, volume = 119, pages = "35-75" } @article{WilmannsEisenberg93, author = "M. Wilmanns and D. Eisenberg", title = "Three-dimensional profiles from residue-pair preferences: identification of sequences with beta/alpha-barrel fold", journal = PNAS, year = 1993, volume = 90, number = 4, pages = "1379-1383" } @Article{Witherell91, author = "G. W. Witherell and J. M. Gott and O. C. Uhlenbeck", title = "Specific Interaction Between {RNA} Phage Coat Proteins and {RNA}", journal = "Progress in Nucleic Acid Research and Molecular Biology", year = 1991, volume = 40, pages = "185-220" } @incollection{Woese93, author = "C. R. Woese and N. R. Pace", title = "Probing {RNA} Structure, Function, and History by Comparative Analysis", booktitle = "The {RNA} World", publisher = "Cold Spring Harbor Laboratory Press", year = 1993, pages = "91-117", editor = "R. F. Gesteland and J. F. Atkins", address = "New York" } @article{WrayEtal96, author = "G. A. Wray and J. S. Levinto and L. H. Shapiro ", title = "Molecular evidence for deep precambrian divergences among metazoan phyla", journal = S, volume = 274, pages = "568-573", year = 1996 } @article{WuManber92, author = {S. Wu and U. Manber}, title = {Fast text searching allowing errors}, journal = CACM, year = 1992, volume = 35, pages = {83-90} } @Article{YadaEtal97, author = "T. Yada and T. Sazuka and M. Hirosawa ", title = "Analysis of sequence patterns surrounding the translation initiation sites on {C}yanobacterium genome using the hidden {M}arkov model", journal = "DNA Research", year = 1997, volume = 4, number = 1, pages = "1-7" } @Article{YadaHirosawa96, author = "T. Yada and M. Hirosawa ", title = "Detection of short protein coding regions within the {C}yanobacterium genome: application of the hidden {M}arkov model", journal = "DNA Research", year = 1996, volume = 3, number = 6, pages = "355-361" } @article{Yang93, author = "Z. Yang ", title = "Maximum-likelihood estimation of phylogeny from {DNA} sequences when substitution rates differ over sites", journal = MBE, volume = 10, pages = "1396-1401", year = 1993 } @article{Yang94, author = "Z. Yang ", title = "Maximum likelihood phylogenetic estimation from {DNA} sequences with variable rates over sites: approximate methods", journal = JME, volume = 39, pages = "306-314", year = 1994 } @article{Yule24, author = "G. U. Yule ", title = "A mathematical theory of evolution, based on the conclusions of {Dr J.C. Willis, FRS}", journal = "Phil. Trans. Roy. Soc. London, B", volume = 213, pages = "21-87", year = 1924 } @incollection{ZuckerkandelEtal62, author = {E. Zuckerkandel and L. Pauling }, title = "Molecular disease, evolution and genetic heterogeneity", booktitle = "Horizons in Biochemistry", pages = "189-225", editor = "M. Marsha and B. Pullman", publisher = "Academic Press", address = "New York", year = 1962 } @Article{Zuker81, author = "M. Zuker and P. Stiegler", title = "Optimal Computer Folding of Large {RNA} Sequences Using Thermodynamics and Auxiliary Information", journal = NAR, year = 1981, volume = 9, pages = "133-148" } @Article{Zuker89, author = "M. Zuker", title = "On Finding All Suboptimal Foldings of an {RNA} Molecule", journal = Science, year = 1989, volume = 244, pages = "48-52" } @Article{Zuker89b, author = "M. Zuker", title = "Computer prediction of {RNA} Structure.", journal = ME, volume = "180", year = 1989, pages = "262-288" } @Article{Zuker91, author = {M. Zuker}, title = {Suboptimal Sequence Alignment in Molecular Biology: alignment with Error Analysis}, journal = JMB, year = 1991, volume = 221, pages = {403-420} } @Article{vanBatenburg95, author = {F. H. D. van Batenburg and A. P. Gultyaev and C. W. A. Pleij}, title = {An {APL}-programmed Genetic Algorithm for the Prediction of {RNA} Secondary Structure}, journal = JTB, year = 1995, volume = 174, pages = {269--280} } @article{Notredame96, author = {C. Notredame and D. G. Higgins}, title = {{SAGA}: sequence alignment by genetic algorithm}, journal = NAR, year = {1996}, volume = 24, number = 8, pages = {1515-1524} } @article{Hwa96, author = {T. Hwa and M. L{\"a}ssig}, title = {Similarity-detection and localization}, journal = "Physical Review Letters", year = 1996, volume = 76, pages = {2591} } @InCollection{Hwa96a, author = "T. Hwa", title = "From Flux Pinning to {DNA} Sequence Alignment", booktitle = "Quantum Coherence and Decoherence", publisher = "Elsevier", year = 1996, editor = "K. Fujikawa and Y. A. Ono", pages = "109-114" } @InProceedings{Hwa98, author = "T. Hwa and M. L{\"a}ssig", title = "Optimal detection of sequence similarity by local alignment", booktitle = "Proceedings of the Second Annual International Conference on Computational Molecular Biology", editor = "S. Istrail and P. Pevzner and M. S. Waterman", pages = "109-116", publisher = "{ACM} press", address = "New York", year = 1998, } @unpublished{DrasdoEtal97a, year = 1997, author = "D. Drasdo and T. Hwa and M. L{\"a}ssig", title = "{DNA} sequence alignment and critical phenomena", note = {Available from http://matisse.ucsd.edu/\~{}hwa/pub.html} } @unpublished{DrasdoEtal97, year = 1997, author = "D. Drasdo and T. Hwa and M. L{\"a}ssig", title = "Scaling Laws and Similarity Detection in Sequence Alignment with Gaps", note = {Preprint, available from http://matisse.ucsd.edu/\~{}hwa/pub.html} } @book{Durbin98, author = "R. Durbin and S. Eddy and A. Krogh and G. Mitchison", title = "Biological Sequence Analysis: Probabilistic Models of Proteins and Nucleic Acids", publisher = "Cambridge University Press", address = "Cambridge, UK", year = 1998 } @inproceedings{Zhu97, author = "J. Zhu and J. Liu and C. Lawrence", title = "Bayesian adaptive alignment and inference", crossref = "ismb97", pages = {358-368} } @article{Holmes98, author = "I. Holmes and R. Durbin", title = "Dynamic programming alignment accuracy", journal = JCB, year = 1998, volume = 5, number = 3, pages = {493-504} } @phdthesis{Holmes98b, author = "I. Holmes", title = "Studies in probabilistic sequence alignment and evolution", school = "The Sanger Centre", year = 1998 } @phdthesis{Sonnhammer96, author = "E. Sonnhammer", title = "Classification of protein domain families for genomic sequence analysis", school = "The Sanger Centre", year = 1996 } @techreport{Cline98, title = "On alignment shift and its measures", author = "M. Cline and K. Karplus", institution = "University of California Santa Cruz", year = "1998", note = "Available from http://www.cse.ucsc.edu/\~{}cline/shiftscore.html" } @article{SonnEddyDurbin97, author = "E. L. L. Sonnhammer and S. R. Eddy and R. Durbin", title = "Pfam: a comprehensive database of protein domain families based on seed alignments.", journal = PROT, volume = 28, year = 1997, pages = {405-420} } @article{SonnhammerEtal98, title = "Pfam: multiple sequence alignments and {HMM}-profiles of protein domains", author = "E. Sonnhammer and S. Eddy and E. Birney and A. Bateman and R. Durbin", journal = NAR, volume = 26, number = 1, pages = {320-322}, year = 1998 } @article{BatemanEtal2000, title = "The Pfam Protein Families Database.", author = "A. Bateman and E. Birney and R. Durbin and S. R. Eddy and K. L. Howe and E. L. L. Sonnhammer", pages = "263-266", journal = NAR, volume = 28, year = 2000, } @article{SchultzEtal2000, title = "SMART: a web-based tool for the study of genetically mobile domains.", author = "J. Schultz and R. R. Copley and T. Doerks and C. P. Ponting and P. Bork", journal = NAR, pages = "231-234", year = 2000, } @article{Hoffmann99, title = "The PROSITE database, its status in 1999.", author = "K. Hofmann and P. Bucher and L. Falquet and A. Bairoch", journal = NAR, pages = "215-219", year = 1999, volume = 27 } @article{SonnhammerEtal94, title = "A workbench for large-scale sequence homology analysis", author = "E. Sonnhammer and R. Durbin", journal = CABIOS, volume = 10, number = 3, pages = {301-307}, year = 1994 } @string{ISMBstr = " International Conference on Intelligent Systems for Molecular Biology"} @proceedings{ismb93, booktitle= "Proceedings of the First" # ISMBstr, title= "Proceedings of the First" # ISMBstr, editor="L. Hunter and D. B. Searls and J. Shavlik", publisher="AAAI Press", address= "Menlo Park, CA", year = 1993 } @proceedings{ismb94, booktitle= "Proceedings of the Second" # ISMBstr, title= "Proceedings of the Second" # ISMBstr, editor="R. Altman and D. Brutlag and P. Karp and R. Lathrop and D. Searls", publisher="AAAI Press", address= "Menlo Park, CA", year = 1994 } @proceedings{ismb95, booktitle= "Proceedings of the Third" # ISMBstr, title= "Proceedings of the Third" # ISMBstr, editor="C. Rawlings and D. Clark and R. Altman and L. Hunter and T. Lengauer and S. Wodak", publisher="AAAI Press", address= "Menlo Park, CA", year = 1995 } @proceedings{ismb96, booktitle = "Proceedings of the Fourth" # ISMBstr, title = "Proceedings of the Fourth" # ISMBstr, editor = "D. J. States and P. Agarwal and T. Gaasterland and L. Hunter and R. F. Smith", publisher="AAAI Press", address= "Menlo Park, CA", year = 1996 } @proceedings{ismb97, booktitle = "Proceedings of the Fifth" # ISMBstr, title = "Proceedings of the Fifth" # ISMBstr, editor = "T. Gaasterland and P. Karp and K. Karplus and C. Ouzounis and C. Sander and A. Valencia", publisher="AAAI Press", address= "Menlo Park, CA", year = 1997 } @proceedings{ismb98, booktitle = "Proceedings of the Sixth" # ISMBstr, title = "Proceedings of the Sixth" # ISMBstr, editor = "T. Gaasterland and P. Karp and K. Karplus and C. Ouzounis and C. Sander and A. Valencia", publisher="AAAI Press", address= "Menlo Park, CA", year = 1998 } @unpublished{Jaakkola98, author = "T. S. Jaakkola and D. Haussler", title = "Exploiting generative models in discriminative classifiers", year = 1998, note = {Preprint, Dept.\ of Computer Science, Univ.\ of California, available from http://www.cse.ucsc.edu/\~{}haussler/pubs.html} } @Article{Bulmer86, author = "M. Bulmer", title = "Neighbouring base effects on substitution rates in pseudogenes", journal = MBE, year = 1986, volume = 3, pages = "322-329" } @misc{GFF98, key = {GFF}, title = "{GFF}: an exchange format for gene-finding features", note = {Webpage at http://www.sanger.ac.uk/Software/GFF/} } @misc{Dust98, author = "R. Tatusov", note = {Personal communication} } @misc{Guigo2000pc, author = "R. Guigo and P. Agarwal", note = {manuscript in preparation} } @article{DingEtal99, title = "Crystal structure of the two-{RRM} domain of {hnRNP} {A1} ({UP1}) complexed with single-stranded telomeric {DNA}.", author = "J. Ding and M. K. Hayashi and Y. Zhang and L. Manche and A. R. Krainer and R. M. Xu", journal = "Genes and Development", year = 1999, pages = "1102-1115", } @article{CaceresEtal97, title = "Role of the modular domains of SR proteins in subnuclear localization and alternative splicing specificity.", author = "J. F. Caceres and T. Misteli and G. R. Screaton and D. L. Spector and A. R. Krainer", journal = JCB, pages = "225-238", year = 1997, } @article{BorkEtal96, title = "Structure and distribution of modules in extracellular proteins.", author = "P. Bork and A. K. Downing and B. Kieffer and I. D. Campbell", journal = "Quarterly Review Biophysics", volume = 92, pages = "119-167", year = 1996, } @article{ClarkeBerg98, author = "N. D. Clarke and J. M. Berg", title = "Zinc fingers in Caenorhabditis elegans: finding families and probing pathways.", year = 1998, journal = SCIENCE, pages = "2018-2022", } @article{Robertson98, author = "H. Robertson", title = "Two large families of chemoreceptor genes in the nematodes Caenorhabditis elegans and Caenorhabditis briggsae reveal extensive gene duplication, diversification, movement, and intron loss.", year = 1998, journal = "Genome Research", pages = "449-463", } @article{PearsonEtal97, author = "W. R. Pearson and T. Wood and Z. Zhang and W. Miller", title = "Comparison of DNA sequences with protein sequences.", pages = "24-36", year = 1997, journal = "Genomics", volume = 46, } @article{Huang97, author = "X. Huang and M. D. Adams and H. Zhou and A. R. Kerlavage", title = "A tool for analyzing and annotating genomic sequences.", journal = "Genomics", volume = 46, pages = "37-46", year = 1997, } @article{ScherlyEtal90, title = "Major determinants of the specificity of interaction between small nuclear ribonucleoproteins U1A and U2B'' and their cognate RNAs.", author = "D. Scherly and W. Boelens and N. A. Dathan and W. J. van Venrooij and I. W. Mattaj", journal = NATURE, volume = 345, pages = "502-506", year = 1990, } @article{TeichmannEtal97, title = "Structural assignments to the Mycoplasma genitalium proteins show extensive gene duplications and domain rearrangements.", author = "S. A. Teichmann and J. Park and C. Chothia", journal = PNAS, pages = "14658-14663", volume = 95, year = 1997, } @unpublished{Haussler98, author = "D. Haussler", title = "Computational Genefinding", year = 1998, note = {Preprint; available from http://www.cse.ucsc.edu/research/compbio/research.html} } @phdthesis{Mackay92a, author = "D. J. C. Mac{K}ay", title = "Bayesian Methods for Adaptive Models", school = "California Institute of Technology", year = 1992 } @misc{GPL, title = "The {GNU} {P}ublic {L}icense", key = "GPL", note = {Available in full from http://www.fsf.org/copyleft/gpl.html} } @article{Viterbi67, author = "A. Viterbi", title = "Error bounds for convolutional codes and an asymptotically optimum decoding algorithm", journal = "IEEE Transactions on Information Theory", year = 1967, pages = "260-269" } @article{GriceEtal97, author = "J. A. Grice and R. Hughey and D. Speck", title = "Reduced space sequence alignment.", journal = CABIOS, pages = "45-53", year = 1997, volume = 13, } @article{JonesEtal94, author = "D. T. Jones and W. R. Taylor and J. M. Thornton", title = "A mutation data matrix for transmembrane proteins.", journal = "FEBBs Letters", pages = "269-275", volume = 339, year = 1994, } @book{Bishop95, author = "C. M. Bishop", title = "Neural Networks for Pattern Recognition", publisher = "Oxford University Press", address = "Oxford, UK", year = 1995 } @unpublished{Neal98, author = "R. M. Neal", title = "Annealed importance sampling", note = {Technical report no. 9805, Dept.\ of Statistics, Univ.\ of Toronto, available from http://www.cs.utoronto.ca/\~{}radford/}, year = "1998" } @Misc{Neal98pc, author = {R. M. Neal}, note = {Personal communication} } @book{KarlinTaylor75, author = "S. Karlin and H. Taylor", title = "A First Course in Stochastic Processes", publisher = "Academic Press", address = "San Diego, CA", year = 1975 } @article{Neuwald97, author = "A. F. Neuwald and J. S. Liu and D. J. Lipman and C. E. Lawrence", title = "Extracting protein alignment models from the sequence database", journal = NAR, year = 1997, pages = "1665-1677" } @article{BursetGuigo96, author = "M. Burset and R. Guigo", title = "Evaluation of gene structure prediction programs.", journal = "Genomics", pages = "353-367", year = 1996, volume = 34, } @unpublished{Burges98, author = "C. J. C. Burges", title = "A tutorial on support vector machines for pattern recognition", note = {Available from http://svm.research.bell-labs.com/SVMdoc.html}, year = "1998" } @unpublished{Mackay97, author = "D. J. C. Mac{K}ay", title = "Introduction to {Gaussian} processes", note = {Available from http://wol.ra.phy.cam.ac.uk/mackay/}, year = "1997" } @incollection{Mackay96, author = {D. J. C. Mac{K}ay}, title = "Density networks and their application to protein modelling", booktitle = "Maximum Entropy and Bayesian Methods", pages = "259-268", publisher = "Kluwer Academic Publishers", address = "Netherlands", year = 1996 } @unpublished{Povinelli98, author = "M. Povinelli", title = "Density Networks with Application to Protein Modelling", note = {{M.Phil} thesis, Univ.\ of Cambridge, UK. Available from http://www.mit.edu/\~{}mpovinel/pub.html}, year = "1998" } @article{Chothia92, author = "C. Chothia", title = "One thousand families for the molecular biologist", journal = Nature, year = 1992, volume = 357, pages = "543-544" } @article{DeRisi97, author = "J. L. DeRisi and V. R. Iyer and P. O. Brown", title = "Exploring the Metabolic and Genetic Control of Gene Expression on a Genomic Scale", journal = Science, year = 1997, volume = 278, pages = "680-686" } @Unpublished{Brazma98, author = {A. Brazma and I. Jonassen and J. Vilo and E. Ukkonen}, title = {Predicting Gene Regulatory Elements in Silico on a Genomic Scale}, note = {Preprint, to appear in Genome Research}, year = 1998 } @article{Celegans98, author = {The {C}. elegans sequencing consortium}, title = {Genome sequence of the Nematode {C}. elegans: A platform for investigating biology}, journal = {Science}, year = 1998, pages = "2012-2018" } @article{Martinelli97, author = "S. D. Martinelli and C. G. Brown and R. Durbin", title = "Gene expression and development databases for {C}.elegans", journal = "Seminars in Cell and Developmental Biology", year = 1997, volume = 8, pages = "459-467" } @article{PontingRussel95, author = "C. P. Ponting and R. B. Russell", title = "Swaposins: circular permutations within genes encoding saposin homologues", journal = TIBS, year = 1995, pages = "179-180", volume = 20, } @article{Agarwal98, author = "P. Agarwal and D. J. States", title = "Comparative accuracy of methods for protein sequence similarity search", journal = BI, year = 1998, volume = 14, pages = "40-47" } @article{Zhu98, author = "J. Zhu and J. S. Liu and C. E. Lawrence", title = "Bayesian adaptive sequence alignment algorithms", journal = BI, year = 1998, volume = 14, pages = "25-39" } @book{Stryer88, author = "L. Stryer", title = "Biochemistry", publisher = "W.H.Freeman and Company", address = "New York", year = 1988 } @article{Waterston98, author = "R. Waterston and J. E. Sulston", title = "The {H}uman {G}enome {P}roject: reaching the finish line", journal = Science, year = 1998, volume = 282, pages = "53-54" } @article{Waterston95, author = "R. Waterston and J. Sulston", title = "The genome of {C}aenorhabditis elegans", journal = PNAS, year = 1995, volume = 92, pages = "10836-10840" } @article{Fleischmann95, author = "R. D. Fleischmann and M. D. Adams and O. White and R. A. Clayton and E. F. Kirkness and A. R. Kerlavage and C. J. Bult and J. F. Tomb and B. A. Dougherty and J. M. Merrick and others", title = "Whole-genome random sequencing and assembly of {H}aemophilus influenzae {R}d", journal = Science, year = 1995, volume = 269, pages = "496-512" } @article{Kass97, author = "S. U. Kass and D. Pruss and A. P. Wolffe", title = "How does {DNA} methylation repress transcription?", journal = TIGS, year = 1997, volume = 13, pages = "444-449" } @article{Lamond98, author = "A. I. Lamond and W. C. Earnshaw", title = "Structure and function in the nucleus", journal = Science, year = 1998, volume = 280, pages = "547-553" } @article{Brooks98, author = "C. L. Brooks", title = "Simulations of protein folding and unfolding", journal = COSB, year = 1998, volume = 8, pages = "222-226" } @article{Shakhnovich97, author = "E. I. Shakhnovich", title = "Theoretical studies of protein folding thermodynamics and kinetics", journal = COSB, year = 1997, volume = 7, pages = "29-40" } @misc{PDB, note={http://www.pdb.bnl.gov/} } @unpublished{Goldman98, author = "N. Goldman", title = "Phylogeny with alignment uncertainty", year = 1998, note = {Preprint, Isaac Newton Institute for the Mathematical Sciences, Univ.\ of Cambridge, UK} } @article{MacKay94:BC, author = "D. J. C. Mac{K}ay", title = "Equivalence of {B}oltzmann Chains and Hidden {M}arkov Models", journal = "Neural Computation", year = 1996, volume=8, number=1, pages="178-181", ANNOTE ="Date submitted: Nov 1994; modified 31 March 1995; Date accepted: April 10 1995; Collaborating institutes: none" } @article{Uberbacher91, author = "E. C. Uberbacher and R. J. Mural", title = "Locating protein-coding regions in human DNA sequences by a multiple sensor-neural network approach.", journal = PNAS, pages = "11261-11265", volume = 88, year = 1991, } @Article{VincensEtal98, author = "P. Vincens and L. Buffat and C. Andre and J. P. Chevrolat and J. F. Boisvieux and S. Hazout", title = "A strategy for finding regions of similarity in complete genome sequences", journal = BI, year = 1998, volume = 14, pages = "715-725" } @Article{Wootton94, author = "J. C. Wootton", title = "Non-globular domains in protein sequences: automated segmentation using complexity measures", journal = "Computational Chemistry", year = 1994, volume = 18, pages = "269-85" } @Book{LandauLifshitz80:StatPhys1, author = "L. D. Landau and E. M. Lifshitz", title = "Statistical Physics Part {I}", publisher = "Pergamon Press", year = 1980, volume = 5, series = "Course of Theoretical Physics", address = "Oxford, UK" } @book{LandauLifshitz, author = "L. Stryer", title = "Biochemistry", publisher = "W.H.Freeman and Company", address = "New York", year = 1988 } @Article{Attwood94a, author = "T. K. Attwood and J. B. Findlay", title = "Fingerprinting {G}-protein-coupled receptors", journal = PE, year = 1994, volume = 7, pages = "195-203" } @Misc{Mott98pc, author = "R. Mott", note = {Personal communication} } @Misc{Bruskiewichpc, author = "R. Bruskiewich", note = {Personal communication} } @article{Mott97b, author = "R. Mott", title = "{EST\_GENOME}: a program to align spliced DNA sequences to unspliced genomic DNA.", year = 1997, journal = CABIOS, pages = "477-478" } @incollection{Jaynes86, author = "E. T. Jaynes", title = "Bayesian methods: general background", booktitle = "Maximum Entropy and {B}ayesian Methods in Applied Statistics", publisher = "Cambridge University Press", year = 1986, pages = "1-25", editor = "J. H. Justice", address = "Cambridge, UK" } @Article{Butler98, author = "B. A. Butler", title = "Sequence analysis using {GCG}", journal = "Methods of Biochemical Analysis", year = 1998, volume = 39, pages = "74-97" } @unpublished{Clamp98, author = "M. Clamp", title = "Jalview", year = 1998, note = {In press} } @article{TackeManley98, author = "R. Tacke and J. L. Manley", title = "Determinants of SR protein specificity.", journal = "Current Opinion in Cell Biology", year = 1998, pages = "358-362", volume = 11, } @article{LuiEtal98, author = "H. X. Liu and M. Zhang and A. R. Krainer", title = "Identification of functional exonic splicing enhancer motifs recognized by individual SR proteins.", journal = "Genes and Development", pages = "1998-2012", volume = "12", year = 1998 } @article{BurgeEtal98, author = "C. B. Burge and R. A. Padgett and P. A. Sharp", title = "Evolutionary fates and origins of U12-type introns.", journal = "Molecular Cell", pages = "773-785", year = 1998, volume = 2 } @article{Burtis93, author = "K. C. Burtis", title = "The regulation of sex determination and sexually dimorphic differentiation in Drosophila.", journal = "Current Opinion in Cell Biology", pages = "1006-1014", volume = 5, year = 1993, } @article{KrecicSwanson98, author = "A. M. Krecic and M. S. Swanson", title = "hnRNP complexes: composition, structure, and function.", journal = "Current Opinion in Cell Biology", pages = "363-371", volume = 11, year = 1998, } @article{MayedaKrainer99, author = "A. Mayeda and A. R. Krainer", title = "Mammalian in vitro splicing assays.", journal = "Methods in Molecular Biology", pages = "315-321", year = 1999, volume = 118, } @article{HorowitzKrainer94, author = "D. S. Horowitz and A. R. Krainer", title = "Mechanisms for selecting 5' splice sites in mammalian pre-mRNA splicing.", pages = "100-106", year = 1994, journal = TIGS, volume = 10, } @Article{Mouse2002, Author="Waterston, Robert. H. and Lindblad-Toh, Kerstin. and Birney, Ewan. and Rogers, Jane. and Abril, Josep. F. and Agarwal, Pankaj. and Agarwala, Richa. and Ainscough, Rachel. and Alexandersson, Marina. and An, Peter. and Antonarakis, Stylianos. E. and Attwood, John. and Baertsch, Robert. and Bailey, Jonathon. and Barlow, Karen. and Beck, Stephan. and Berry, Eric. and Birren, Bruce. and Bloom, Toby. and Bork, Peer. and Botcherby, Marc. and Bray, Nicolas. and Brent, Michael. R. and Brown, Daniel. G. and Brown, Stephen. D. and Bult, Carol. and Burton, John. and Butler, Jonathan. and Campbell, Robert. D. and Carninci, Piero. and Cawley, Simon. and Chiaromonte, Francesca. and Chinwalla, Asif. T. and Church, Deanna. M. and Clamp, Michele. and Clee, Christopher. and Collins, Francis. S. and Cook, Lisa. L. and Copley, Richard. R. and Coulson, Alan. and Couronne, Olivier. and Cuff, James. and Curwen, Val. and Cutts, Tim. and Daly, Mark. and David, Robert. and Davies, Joy. and Delehaunty, Kimberly. D. and Deri, Justin. and Dermitzakis, Emmanouil. T. and Dewey, Colin. and Dickens, Nicholas. J. and Diekhans, Mark. and Dodge, Sheila. and Dubchak, Inna. and Dunn, Diane. M. and Eddy, Sean. R. and Elnitski, Laura. and Emes, Richard. D. and Eswara, Pallavi. and Eyras, Eduardo. and Felsenfeld, Adam. and Fewell, Ginger. A. and Flicek, Paul. and Foley, Karen. and Frankel, Wayne. N. and Fulton, Lucinda. A. and Fulton, Robert. S. and Furey, Terrence. S. and Gage, Diane. and Gibbs, Richard. A. and Glusman, Gustavo. and Gnerre, Sante. and Goldman, Nick. and Goodstadt, Leo. and Grafham, Darren. and Graves, Tina. A. and Green, Eric. D. and Gregory, Simon. and Guigo, Roderic. and Guyer, Mark. and Hardison, Ross. C. and Haussler, David. and Hayashizaki, Yoshihide. and Hillier, LaDeana. W. and Hinrichs, Angela. and Hlavina, Wratko. and Holzer, Timothy. and Hsu, Fan. and Hua, Axin. and Hubbard, Tim. and Hunt, Adrienne. and Jackson, Ian. and Jaffe, David. B. and Johnson, L. Steven. and Jones, Matthew. and Jones, Thomas. A. and Joy, Ann. and Kamal, Michael. and Karlsson, Elinor. K. and Karolchik, Donna. and Kasprzyk, Arkadiusz. and Kawai, Jun. and Keibler, Evan. and Kells, Cristyn. and Kent, W. James. and Kirby, Andrew. and Kolbe, Diana. L. and Korf, Ian. and Kucherlapati, Raju. S. and Kulbokas, Edward. J. and Kulp, David. and Landers, Tom. and Leger, J. P. and Leonard, Steven. and Letunic, Ivica. and Levine, Rosie. and Li, Jia. and Li, Ming. and Lloyd, Christine. and Lucas, Susan. and Ma, Bin. and Maglott, Donna. R. and Mardis, Elaine. R. and Matthews, Lucy. and Mauceli, Evan. and Mayer, John. H. and McCarthy, Megan. and McCombie, W. Richard. and McLaren, Stuart. and McLay, Kirsten. and McPherson, John. D. and Meldrim, Jim. and Meredith, Beverley. and Mesirov, Jill. P. and Miller, Webb. and Miner, Tracie. L. and Mongin, Emmanuel. and Montgomery, Kate. T. and Morgan, Michael. and Mott, Richard. and Mullikin, James. C. and Muzny, Donna. M. and Nash, William. E. and Nelson, Joanne. O. and Nhan, Michael. N. and Nicol, Robert. and Ning, Zemin. and Nusbaum, Chad. and O'Connor, Michael. J. and Okazaki, Yasushi. and Oliver, Karen. and Overton-Larty, Emma. and Pachter, Lior. and Parra, Genis. and Pepin, Kymberlie. H. and Peterson, Jane. and Pevzner, Pavel. and Plumb, Robert. and Pohl, Craig. S. and Poliakov, Alex. and Ponce, Tracy. C. and Ponting, Chris. P. and Potter, Simon. and Quail, Michael. and Reymond, Alexandre. and Roe, Bruce. A. and Roskin, Krishna. M. and Rubin, Edward. M. and Rust, Alistair. G. and Santos, Ralph. and Sapojnikov, Victor. and Schultz, Brian. and Schultz, Jorg. and Schwartz, Matthias. S. and Schwartz, Scott. and Scott, Carol. and Seaman, Steven. and Searle, Steve. and Sharpe, Ted. and Sheridan, Andrew. and Shownkeen, Ratna. and Sims, Sarah. and Singer, Jonathan. B. and Slater, Guy. and Smit, Arian. and Smith, Douglas. R. and Spencer, Brian. and Stabenau, Arne. and Stange-Thomann, Nicole. and Sugnet, Charles. and Suyama, Mikita. and Tesler, Glenn. and Thompson, Johanna. and Torrents, David. and Trevaskis, Evanne. and Tromp, John. and Ucla, Catherine. and Ureta-Vidal, Abel. and Vinson, Jade. P. and Von Niederhausern., Andrew. C. and Wade, Claire. M. and Wall, Melanie. and Weber, Ryan. J. and Weiss, Robert. B. and Wendl, Michael. C. and West, Anthony. P. and Wetterstrand, Kris. and Wheeler, Raymond. and Whelan, Simon. and Wierzbowski, Jamey. and Willey, David. and Williams, Sophie. and Wilson, Richard. K. and Winter, Eitan. and Worley, Kim. C. and Wyman, Dudley. and Yang, Shan. and Yang, Shiaw.-Pyng and Zdobnov, Evgeny. M. and Zody, Michael. C. and Lander, Eric. S.", Title="{Initial sequencing and comparative analysis of the mouse genome}", Journal="Nature", Year="2002", Volume="420", Number="6915", Pages="520-562", Month="Dec" } @Article{Human2001, Author="Lander, E. S. and Linton, L. M. and Birren, B. and Nusbaum, C. and Zody, M. C. and Baldwin, J. and Devon, K. and Dewar, K. and Doyle, M. and FitzHugh, W. and Funke, R. and Gage, D. and Harris, K. and Heaford, A. and Howland, J. and Kann, L. and Lehoczky, J. and LeVine, R. and McEwan, P. and McKernan, K. and Meldrim, J. and Mesirov, J. P. and Miranda, C. and Morris, W. and Naylor, J. and Raymond, C. and Rosetti, M. and Santos, R. and Sheridan, A. and Sougnez, C. and Stange-Thomann, N. and Stojanovic, N. and Subramanian, A. and Wyman, D. and Rogers, J. and Sulston, J. and Ainscough, R. and Beck, S. and Bentley, D. and Burton, J. and Clee, C. and Carter, N. and Coulson, A. and Deadman, R. and Deloukas, P. and Dunham, A. and Dunham, I. and Durbin, R. and French, L. and Grafham, D. and Gregory, S. and Hubbard, T. and Humphray, S. and Hunt, A. and Jones, M. and Lloyd, C. and McMurray, A. and Matthews, L. and Mercer, S. and Milne, S. and Mullikin, J. C. and Mungall, A. and Plumb, R. and Ross, M. and Shownkeen, R. and Sims, S. and Waterston, R. H. and Wilson, R. K. and Hillier, L. W. and McPherson, J. D. and Marra, M. A. and Mardis, E. R. and Fulton, L. A. and Chinwalla, A. T. and Pepin, K. H. and Gish, W. R. and Chissoe, S. L. and Wendl, M. C. and Delehaunty, K. D. and Miner, T. L. and Delehaunty, A. and Kramer, J. B. and Cook, L. L. and Fulton, R. S. and Johnson, D. L. and Minx, P. J. and Clifton, S. W. and Hawkins, T. and Branscomb, E. and Predki, P. and Richardson, P. and Wenning, S. and Slezak, T. and Doggett, N. and Cheng, J. F. and Olsen, A. and Lucas, S. and Elkin, C. and Uberbacher, E. and Frazier, M. and Gibbs, R. A. and Muzny, D. M. and Scherer, S. E. and Bouck, J. B. and Sodergren, E. J. and Worley, K. C. and Rives, C. M. and Gorrell, J. H. and Metzker, M. L. and Naylor, S. L. and Kucherlapati, R. S. and Nelson, D. L. and Weinstock, G. M. and Sakaki, Y. and Fujiyama, A. and Hattori, M. and Yada, T. and Toyoda, A. and Itoh, T. and Kawagoe, C. and Watanabe, H. and Totoki, Y. and Taylor, T. and Weissenbach, J. and Heilig, R. and Saurin, W. and Artiguenave, F. and Brottier, P. and Bruls, T. and Pelletier, E. and Robert, C. and Wincker, P. and Smith, D. R. and Doucette-Stamm, L. and Rubenfield, M. and Weinstock, K. and Lee, H. M. and Dubois, J. and Rosenthal, A. and Platzer, M. and Nyakatura, G. and Taudien, S. and Rump, A. and Yang, H. and Yu, J. and Wang, J. and Huang, G. and Gu, J. and Hood, L. and Rowen, L. and Madan, A. and Qin, S. and Davis, R. W. and Federspiel, N. A. and Abola, A. P. and Proctor, M. J. and Myers, R. M. and Schmutz, J. and Dickson, M. and Grimwood, J. and Cox, D. R. and Olson, M. V. and Kaul, R. and Raymond, C. and Shimizu, N. and Kawasaki, K. and Minoshima, S. and Evans, G. A. and Athanasiou, M. and Schultz, R. and Roe, B. A. and Chen, F. and Pan, H. and Ramser, J. and Lehrach, H. and Reinhardt, R. and McCombie, W. R. and de la. Bastide., M. and Dedhia, N. and Blocker, H. and Hornischer, K. and Nordsiek, G. and Agarwala, R. and Aravind, L. and Bailey, J. A. and Bateman, A. and Batzoglou, S. and Birney, E. and Bork, P. and Brown, D. G. and Burge, C. B. and Cerutti, L. and Chen, H. C. and Church, D. and Clamp, M. and Copley, R. R. and Doerks, T. and Eddy, S. R. and Eichler, E. E. and Furey, T. S. and Galagan, J. and Gilbert, J. G. and Harmon, C. and Hayashizaki, Y. and Haussler, D. and Hermjakob, H. and Hokamp, K. and Jang, W. and Johnson, L. S. and Jones, T. A. and Kasif, S. and Kaspryzk, A. and Kennedy, S. and Kent, W. J. and Kitts, P. and Koonin, E. V. and Korf, I. and Kulp, D. and Lancet, D. and Lowe, T. M. and McLysaght, A. and Mikkelsen, T. and Moran, J. V. and Mulder, N. and Pollara, V. J. and Ponting, C. P. and Schuler, G. and Schultz, J. and Slater, G. and Smit, A. F. and Stupka, E. and Szustakowski, J. and Thierry-Mieg, D. and Thierry-Mieg, J. and Wagner, L. and Wallis, J. and Wheeler, R. and Williams, A. and Wolf, Y. I. and Wolfe, K. H. and Yang, S. P. and Yeh, R. F. and Collins, F. and Guyer, M. S. and Peterson, J. and Felsenfeld, A. and Wetterstrand, K. A. and Patrinos, A. and Morgan, M. J. and Szustakowki, J. and de Jong., P. and Catanese, J. J. and Osoegawa, K. and Shizuya, H. and Choi, S. and Chen, Y. J.", Title="{Initial sequencing and analysis of the human genome}", Journal="Nature", Year="2001", Volume="409", Number="6822", Pages="860-921", Month="Feb" } % 9518021 (JID) 20243856 (UI) @Article{BirneyDurbin2000, Author="Birney, E. and Durbin, R.", Title="{Using GeneWise in the Drosophila annotation experiment}", Journal="Genome Res", Year="2000", Volume="10", Number="4", Pages="547-548", Month="Apr" } @Article{ Fugu2002, Author="Aparicio, Samuel. and Chapman, Jarrod. and Stupka, Elia. and Putnam, Nik. and Chia, Jer.-Ming and Dehal, Paramvir. and Christoffels, Alan. and Rash, Sam. and Hoon, Shawn. and Smit, Arian. and Gelpke, Maarten. D. Sollewijn. and Roach, Jared. and Oh, Tania. and Ho, Isaac. Y. and Wong, Marie. and Detter, Chris. and Verhoef, Frans. and Predki, Paul. and Tay, Alice. and Lucas, Susan. and Richardson, Paul. and Smith, Sarah. F. and Clark, Melody. S. and Edwards, Yvonne. J. K. and Doggett, Norman. and Zharkikh, Andrey. and Tavtigian, Sean. V. and Pruss, Dmitry. and Barnstead, Mary. and Evans, Cheryl. and Baden, Holly. and Powell, Justin. and Glusman, Gustavo. and Rowen, Lee. and Hood, Leroy. and Tan, Y. H. and Elgar, Greg. and Hawkins, Trevor. and Venkatesh, Byrappa. and Rokhsar, Daniel. and Brenner, Sydney.", Title="{Whole-genome shotgun assembly and analysis of the genome of Fugu rubripes}", Journal="Science", Year="2002", Volume="297", Number="5585", Pages="1301-1310", Month="Aug" } % 9518021 (JID) 21235191 (UI) @Article{BurgeGenomescan, Author="Yeh, R. F. and Lim, L. P. and Burge, C. B.", Title="{Computational inference of homologous gene structures in the human genome}", Journal="Genome Res", Year="2001", Volume="11", Number="5", Pages="803-816", Month="May" } % 9518021 (JID) 22202135 (UI) @Article{HoweDurbin, Author="Howe, Kevin. L. and Chothia, Tom. and Durbin, Richard.", Title="{GAZE: a generic framework for the integration of gene-prediction data by dynamic programming}", Journal="Genome Res", Year="2002", Volume="12", Number="9", Pages="1418-1427", Month="Sep" } % 9808944 (JID) 22263282 (UI) @Article{MeyerDurbin, Author="Meyer, Irmtraud. M. and Durbin, Richard.", Title="{Comparative ab initio prediction of gene structures using pair HMMs}", Journal="Bioinformatics", Year="2002", Volume="18", Number="10", Pages="1309-1318", Month="Oct", Note="Evaluation Studies" } % 0404511 (JID) 22369169 (UI) @Article{Ciona2002, Author="Dehal, Paramvir. and Satou, Yutaka. and Campbell, Robert. K. and Chapman, Jarrod. and Degnan, Bernard. and De Tomaso., Anthony. and Davidson, Brad. and Di Gregorio., Anna. and Gelpke, Maarten. and Goodstein, David. M. and Harafuji, Naoe. and Hastings, Kenneth. E. M. and Ho, Isaac. and Hotta, Kohji. and Huang, Wayne. and Kawashima, Takeshi. and Lemaire, Patrick. and Martinez, Diego. and Meinertzhagen, Ian. A. and Necula, Simona. and Nonaka, Masaru. and Putnam, Nik. and Rash, Sam. and Saiga, Hidetoshi. and Satake, Masanobu. and Terry, Astrid. and Yamada, Lixy. and Wang, Hong.-Gang and Awazu, Satoko. and Azumi, Kaoru. and Boore, Jeffrey. and Branno, Margherita. and Chin-Bow, Stephen. and DeSantis, Rosaria. and Doyle, Sharon. and Francino, Pilar. and Keys, David. N. and Haga, Shinobu. and Hayashi, Hiroko. and Hino, Kyosuke. and Imai, Kaoru. S. and Inaba, Kazuo. and Kano, Shungo. and Kobayashi, Kenji. and Kobayashi, Mari. and Lee, Byung.-In and Makabe, Kazuhiro. W. and Manohar, Chitra. and Matassi, Giorgio. and Medina, Monica. and Mochizuki, Yasuaki. and Mount, Steve. and Morishita, Tomomi. and Miura, Sachiko. and Nakayama, Akie. and Nishizaka, Satoko. and Nomoto, Hisayo. and Ohta, Fumiko. and Oishi, Kazuko. and Rigoutsos, Isidore. and Sano, Masako. and Sasaki, Akane. and Sasakura, Yasunori. and Shoguchi, Eiichi. and Shin-i, Tadasu. and Spagnuolo, Antoinetta. and Stainier, Didier. and Suzuki, Miho. M. and Tassy, Olivier. and Takatori, Naohito. and Tokuoka, Miki. and Yagi, Kasumi. and Yoshizaki, Fumiko. and Wada, Shuichi. and Zhang, Cindy. and Hyatt, P. Douglas. and Larimer, Frank. and Detter, Chris. and Doggett, Norman. and Glavina, Tijana. and Hawkins, Trevor. and Richardson, Paul. and Lucas, Susan. and Kohara, Yuji. and Levine, Michael. and Satoh, Nori. and Rokhsar, Daniel. S.", Title="{The draft genome of Ciona intestinalis: insights into chordate and vertebrate origins}", Journal="Science", Year="2002", Volume="298", Number="5601", Pages="2157-2167", Month="Dec" } % 9518021 (JID) 20243852 (UI) @Article{Krogh2000, Author="Krogh, A.", Title="{Using database matches with for HMMGene for automated gene detection in Drosophila}", Journal="Genome Res", Year="2000", Volume="10", Number="4", Pages="523-528", Month="Apr" } % 100962779 (JID) 22199598 (UI) @Article{Zhang2003, Author="Zhang, Michael. Q.", Title="{Computational prediction of eukaryotic protein-coding genes}", Journal="Nat Rev Genet", Year="2002", Volume="3", Number="9", Pages="698-709", Month="Sep" } % 9518021 (JID) 22417281 (UI) @Article{SGP2, Author="Parra, Genis. and Agarwal, Pankaj. and Abril, Josep. F. and Wiehe, Thomas. and Fickett, James. W. and Guigo, Roderic.", Title="{Comparative gene prediction in human and mouse}", Journal="Genome Res", Year="2003", Volume="13", Number="1", Pages="108-117", Month="Jan" } % 9518021 (JID) 22417273 (UI) @Article{Twinscan2003, Author="Flicek, Paul. and Keibler, Evan. and Hu, Ping. and Korf, Ian. and Brent, Michael. R.", Title="{Leveraging the mouse genome for gene prediction in human: from whole-genome shotgun reads to a global synteny map}", Journal="Genome Res", Year="2003", Volume="13", Number="1", Pages="46-54", Month="Jan" } % 9808944 (JID) 22425588 (UI) @Article{Pedersen2003, Author="Pedersen, Jakob. Skou. and Hein, Jotun.", Title="{Gene finding with a hidden Markov model of genome structure and evolution}", Journal="Bioinformatics", Year="2003", Volume="19", Number="2", Pages="219-227", Month="Jan" } % 9518021 (JID) 22505432 (UI) @Article{Pachter2003, Author="Alexandersson, Marina. and Cawley, Simon. and Pachter, Lior.", Title="{SLAM: cross-species gene finding and alignment with a generalized pair hidden Markov model}", Journal="Genome Res", Year="2003", Volume="13", Number="3", Pages="496-502", Month="Mar" } % 0410462 (JID) 22598136 (UI) @Article{Neurospora2003, Author="Galagan, James. E. and Calvo, Sarah. E. and Borkovich, Katherine. A. and Selker, Eric. U. and Read, Nick. D. and Jaffe, David. and FitzHugh, William. and Ma, Li.-Jun and Smirnov, Serge. and Purcell, Seth. and Rehman, Bushra. and Elkins, Timothy. and Engels, Reinhard. and Wang, Shunguang. and Nielsen, Cydney. B. and Butler, Jonathan. and Endrizzi, Matthew. and Qui, Dayong. and Ianakiev, Peter. and Bell-Pedersen, Deborah. and Nelson, Mary. Anne. and Werner-Washburne, Margaret. and Selitrennikoff, Claude. P. and Kinsey, John. A. and Braun, Edward. L. and Zelter, Alex. and Schulte, Ulrich. and Kothe, Gregory. O. and Jedd, Gregory. and Mewes, Werner. and Staben, Chuck. and Marcotte, Edward. and Greenberg, David. and Roy, Alice. and Foley, Karen. and Naylor, Jerome. and Stange-Thomann, Nicole. and Barrett, Robert. and Gnerre, Sante. and Kamal, Michael. and Kamvysselis, Manolis. and Mauceli, Evan. and Bielke, Cord. and Rudd, Stephen. and Frishman, Dmitrij. and Krystofova, Svetlana. and Rasmussen, Carolyn. and Metzenberg, Robert. L. and Perkins, David. D. and Kroken, Scott. and Cogoni, Carlo. and Macino, Giuseppe. and Catcheside, David. and Li, Weixi. and Pratt, Robert. J. and Osmani, Stephen. A. and DeSouza, Colin. P. C. and Glass, Louise. and Orbach, Marc. J. and Berglund, J. Andrew. and Voelker, Rodger. and Yarden, Oded. and Plamann, Michael. and Seiler, Stephan. and Dunlap, Jay. and Radford, Alan. and Aramayo, Rodolfo. and Natvig, Donald. O. and Alex, Lisa. A. and Mannhaupt, Gertrud. and Ebbole, Daniel. J. and Freitag, Michael. and Paulsen, Ian. and Sachs, Matthew. S. and Lander, Eric. S. and Nusbaum, Chad. and Birren, Bruce.", Title="{The genome sequence of the filamentous fungus Neurospora crassa}", Journal="Nature", Year="2003", Volume="422", Number="6934", Pages="859-868", Month="Apr" } % 9518021 (JID) 20499375 (UI) @Article{Guigo2000, Author="Guigo, R. and Agarwal, P. and Abril, J. F. and Burset, M. and Fickett, J. W.", Title="{An assessment of gene prediction accuracy in large DNA sequences}", Journal="Genome Res", Year="2000", Volume="10", Number="10", Pages="1631-1642", Month="Oct" } wise-2.4.1/docs/papers/promoterwise.tex0000644000175000001440000002051707725360453017574 0ustar philippusers\documentclass{article} \usepackage{a4} \usepackage{epsfig} \usepackage{float} \usepackage{chicago} \bibliographystyle{chicago} %\bibliographystyle{plain} \renewcommand{\baselinestretch}{2} %\setcounter{secnumdepth}{0} % this is the preamble \title{Promoterwise: flexible alignment of promoters and its application to Mammalian vs Telost comparisons} \author{L. Ettwiller, B. Paten and E. Birney} \begin{document} \maketitle \section{Abstract} ..to be written.. \section{Introduction} The alignment of DNA sequences is one of the earliest applications of bioinformatics \shortcite{gotoh,smithwaterman,needleman} and remains a core features of sequence analysis. The original alignment methods have focused principally on the alignment of coding sequences, either at the DNA level or at the protein level, mainly because the vast majority of available sequences were involved with protein coding genes. More recently there has been an interest in aligning non coding DNA driven by the availability of large genomes with considerable non coding extents, for example, 95\% of bases for mammalian species are thought to be non coding. A considerable amount of the complexity of large metozoan genomes is thought to be encoded in non-coding DNA. This currently poorly understood additional code in the genome should be revealed by the action of both negative and positive selection on specific sequences, giving rise in each case to specific patterns of alignments which deviate from an underlying supposed neutral model of base pair evolution (for a review, see \shortcite{UretaVidal}). Given such a widespread interest in non coding alignments, a number of groups have applied standard methods to the alignment of genome sequences \shortcite{?}, developed new methods to align genome sequences \shortcite{Jareborg}, or both \shortcite{blastz}. In many cases the alignment of non coding sequences is considered in the broader context of aligning two genome sequences, such as those detailed in the analysis of the mouse genome sequence \shortcite{Waterston} and much of the novel machinery has been focused on the pragmatic problems posed mainly by the length of the genome sequences. Given such activity, we have been surprised by the apparent disinterest in the specific underlying model of current alignment programs. We expect that when two protein structures have a common ancestor, there are a series of co-linear ``alignable'' residues, which are presumed to be homologous bases in each extant sequences with a smooth process of substitution explaining the differences which maintain the structure or function of the protein sequence. These alignable residues are separated by unalignable gaps in each sequence. If they do not share a common ancestor then there are no homologous base pairs and so no biologically valid alignment. In non coding alignments many of these assumptions are not true. Firstly there is ample evidence in non coding regions that either translocations and inversions both occur naturally and also often do not perturb the function of the sequence. This observation means that resulting alignments of homologous base pairs may not be colinear. Secondly, rather than the relatively large colinear stretches of sequence of protein domains being the indivisible unit of protein sequences, far smaller motifs, being the binding site for particular DNA or RNA recognising factors are the indivisible units, which are often well modelled by small stretches of sequence with few if any gaps. Finally the combination of the small size of motifs and the functional tolerance of relative position and orientation allows for de-novo creation and removal of motifs to support a broader functional region. Effectively this process of de novo creation of functional regions is never considered in protein alignments, and has intriguing consequences for the alignment of sequences where equivalent functional sequences, which are still related by a smooth process of subsitution and selection across a small region of sequence are not necessarily a subset of the orthologous base pairs. Evidence of such birth-death process of motifs have been found in careful experimentally verified studies \shortcite{Manolis} Standard alignment programs therefore try find the maximal co-linear set of aligned residues under some scoring scheme which usually optimises for a mixture of small to mid-sized gaps. This is likely to be completely inappropiate for certain types non coding DNA. Such alignment programs cannot direct tolerate inversions or translocations, and it is only after post-processing the local processes (which may be optimised to an entirely inappropiate model) of finding long co-linear regions that such inversions or translocations are potentially visible. This prevents any observations of more interesting, potentially real cases of alignment that break co-linearity or score poorly under a mid-sized gap model. Previous studies have explored scoring schemes for non coding DNA \shortcite{Jareborg,Hardison}. This work reuses the DBA pair-HMM method presented in \shortcite{Jareborg} which has also been used in a number of other studies \shortcite{OtherDBAUsingPapers}. In this work we examine relaxing the need for strict co-linearity of the aligned regions, designing a new program, \emph{Promoterwise}. We show by simulation that this program can reliably find inverted and translocated sequences. We apply this to a number of genome-wide alignments of promoters and confirm the longstanding view that transcription factors are under tight transcriptional regulation; in particular in the vertebrate clade, many transcription factors have large portions of their promoters conserved between mammalia and telosts. In contrast other gene classes, including some well understood promoters do not seem to have such preserved alignable regions and we propose some explanations for this apparent divergence. \subsection{Methods} The alignment of two sequences allow both inversions and translocations is NP-complete \shortcite{Sankoff}. Therefore we took a greedy approach of proposing a large number of believable sub alignments and then reconciled them by accepting the higher scoring alignments and rejecting alignments with significant overlap. An outline of the method is given in pseudocode below: \begin{verbatim} foreach stand in sequence-a hsp-list = Generate-All-HSPs (sequencea,sequenceb) Find all 6 out 7 base pair matches, extend to HSPs using a +5,-4 scoring scheme. Reject HSPs with a score < H sub-alignment-list = align-HSPs (hsp-list) sort HSPs by score foreach remaining hsp initialise with top scoring HSP descend the list of unaccount HSPs, and merge if they are consistent with current region within expansion parameter E once no more HSPs are mergable, align the region with the DBA style pair HMM sort all subalignments (both strands) by score accept the first alignment foreach remaining alignment reject if alignment overlaps any already accepted alignment in either sequence \end{verbatim} Although any potential alignment model can be used instead of the DBA pair HMM, an important feature of the DBA model is that it is conservatively parameterised, such that random sequence is rarely aligned. This ensures that the greedy-style rejection of alignments on the basis of overlap is unlikely to be due to a small additional extension of an alignment due to random matches. In contrast, more standard smith-waterman alignments can have extensive random extensions, in particular on the edges of real alignments. \subsection{Results} Ben's stuff - simulate evolution with allowing translocations and flips; score smith-waterman, DBA and promoterwise on these cases, produce sensitivity vs specificity style plots. Laurence's stuff Human/Fugu, Human/Zebra, Zebra/Fugu comparisons, Tables of interpro obs vs expected chi2, also GO (with experimental evidence codes) in human. How many times do we see non-colinear arrangements in these cases? Any time? (probably not!) \subsection{Discussion} Wax lyrical about inversions and translocations speculate wildly about the need for transcription factors to have transcription regulation. \section{Acknowledgements} L.E, B.P and E.B. are funded by EMBL. We used spare compute resource from the Ensembl project, funded by the Wellcome Trust. \bibliography{alignment} \end{document} wise-2.4.1/docs/genewise21.eps0000644000175000001440000010203407313404521015462 0ustar philippusers%!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 0 0 575 753 %%Pages: 0 %%Creator: Sun Microsystems, Inc. %%Title: none %%CreationDate: none %%LanguageLevel: 2 %%EndComments %%BeginProlog %%BeginResource: SDRes /b4_inc_state save def /dict_count countdictstack def /op_count count 1 sub def userdict begin 0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit[] 0 setdash newpath /languagelevel where {pop languagelevel 1 ne {false setstrokeadjust false setoverprint} if} if /bdef {bind def} bind def /c {setrgbcolor} bdef /l {neg lineto} bdef /rl {neg rlineto} bdef /cl {currentlinewidth currentdash currentlinecap 2 setlinecap} bdef /lc {setlinecap} bdef /lw {setlinewidth} bdef /ld {setdash} bdef /m {neg moveto} bdef /r {rotate} bdef /t {translate} bdef /gs {gsave} bdef /gr {grestore} bdef /f {findfont dup length dict begin {1 index /FID ne {def} {pop pop} ifelse} forall /Encoding ISOLatin1Encoding def currentdict end /NFont exch definefont pop /NFont findfont} bdef /s {show} bdef /p {closepath} bdef /sf {scalefont setfont} bdef /pf {closepath fill}bdef /pc {closepath stroke}bdef /ps {stroke}bdef /pum {matrix currentmatrix}bdef /pom {setmatrix}bdef /bs {/aString exch def /nXOfs exch def /nWidth exch def currentpoint nXOfs 0 rmoveto pum nWidth aString stringwidth pop div 1 scale aString show pom moveto} bdef %%EndResource %%EndProlog %%BeginSetup %%EndSetup %%Page: 1 1 %%BeginPageSetup %%EndPageSetup pum 0.28339 0.2836 scale 0 2655.1 t gs 0 0 m 2028.9 0 l 2028.9 2655 l 0 2655 l 0 0 l eoclip newpath 0.003 0.003 0.003 c 998.2 649.4 m 997.9 640.3 l 997.2 631.2 l 995.9 622.2 l 994.1 613.2 l 991.8 604.3 l 989 595.5 l 985.8 586.9 l 982 578.5 l 977.8 570.2 l 973.1 562.1 l 967.9 554.2 l 962.4 546.6 l 956.4 539.3 l 950 532.2 l 943.2 525.5 l 936 519 l 928.5 512.89999 l 920.6 507.1 l 912.5 501.7 l 904 496.7 l 895.3 492.1 l 886.3 487.9 l 877.1 484.1 l 867.7 480.7 l 858.1 477.8 l 848.3 475.2 l 838.5 473.2 l 828.5 471.6 l 818.4 470.4 l 808.3 469.7 l 798.2 469.5 l 798.2 469.5 l 788.1 469.7 l 778 470.4 l 767.9 471.6 l 757.9 473.2 l 748.1 475.2 l 738.3 477.8 l 728.7 480.7 l 719.3 484.1 l 710.1 487.9 l 701.1 492.1 l 692.4 496.7 l 683.9 501.7 l 675.8 507.1 l 667.9 512.89999 l 660.4 519 l 653.2 525.5 l 646.4 532.2 l 640 539.3 l 634 546.6 l 628.5 554.2 l 623.3 562.1 l 618.6 570.2 l 614.4 578.5 l 610.6 586.9 l 607.4 595.5 l 604.6 604.3 l 602.3 613.2 l 600.5 622.2 l 599.2 631.2 l 598.5 640.3 l 598.2 649.4 l 598.2 649.4 l 598.5 658.5 l 599.2 667.6 l 600.5 676.6 l 602.3 685.6 l 604.6 694.5 l 607.4 703.3 l 610.6 711.9 l 614.4 720.3 l 618.6 728.6 l 623.3 736.7 l 628.5 744.6 l 634 752.2 l 640 759.5 l 646.4 766.6 l 653.2 773.3 l 660.4 779.8 l 667.9 785.9 l 675.8 791.7 l 683.9 797.1 l 692.4 802.1 l 701.1 806.7 l 710.1 810.9 l 719.3 814.7 l 728.7 818.1 l 738.3 821 l 748.1 823.6 l 757.9 825.6 l 767.9 827.2 l 778 828.4 l 788.1 829.1 l 798.2 829.3 l 798.2 829.3 l 808.3 829.1 l 818.4 828.4 l 828.5 827.2 l 838.5 825.6 l 848.3 823.6 l 858.1 821 l 867.7 818.1 l 877.1 814.7 l 886.3 810.9 l 895.3 806.7 l 904 802.1 l 912.5 797.1 l 920.6 791.7 l 928.5 785.9 l 936 779.8 l 943.2 773.3 l 950 766.6 l 956.4 759.5 l 962.4 752.2 l 967.9 744.6 l 973.1 736.7 l 977.8 728.6 l 982 720.3 l 985.8 711.9 l 989 703.3 l 991.8 694.5 l 994.1 685.6 l 995.9 676.6 l 997.2 667.6 l 997.9 658.5 l 998.2 649.4 l pc 1508.1 1476.2 m 1507.8 1467.1 l 1507.1 1458 l 1505.8 1449 l 1504 1440 l 1501.7 1431.1 l 1498.9 1422.3 l 1495.6 1413.7 l 1491.9 1405.3 l 1487.7 1397 l 1483 1388.9 l 1477.8 1381 l 1472.2 1373.4 l 1466.2 1366.1 l 1459.8 1359 l 1453 1352.3 l 1445.9 1345.8 l 1438.3 1339.7 l 1430.5 1333.9 l 1422.3 1328.5 l 1413.8 1323.5 l 1405.1 1318.9 l 1396.1 1314.7 l 1386.9 1310.9 l 1377.5 1307.5 l 1367.9 1304.6 l 1358.2 1302 l 1348.3 1300 l 1338.3 1298.4 l 1328.2 1297.2 l 1318.1 1296.5 l 1308 1296.3 l 1308 1296.3 l 1297.9 1296.5 l 1287.8 1297.2 l 1277.7 1298.4 l 1267.7 1300 l 1257.8 1302 l 1248.1 1304.6 l 1238.5 1307.5 l 1229.1 1310.9 l 1219.9 1314.7 l 1210.9 1318.9 l 1202.2 1323.5 l 1193.7 1328.5 l 1185.5 1333.9 l 1177.7 1339.7 l 1170.1 1345.8 l 1163 1352.3 l 1156.2 1359 l 1149.79999 1366.1 l 1143.79999 1373.4 l 1138.2 1381 l 1133 1388.9 l 1128.29999 1397 l 1124.1 1405.3 l 1120.4 1413.7 l 1117.1 1422.3 l 1114.29999 1431.1 l 1112 1440 l 1110.2 1449 l 1108.9 1458 l 1108.2 1467.1 l 1107.9 1476.2 l 1107.9 1476.2 l 1108.2 1485.3 l 1108.9 1494.4 l 1110.2 1503.4 l 1112 1512.4 l 1114.29999 1521.3 l 1117.1 1530.1 l 1120.4 1538.7 l 1124.1 1547.1 l 1128.29999 1555.4 l 1133 1563.5 l 1138.2 1571.4 l 1143.79999 1579 l 1149.79999 1586.3 l 1156.2 1593.4 l 1163 1600.1 l 1170.1 1606.6 l 1177.7 1612.7 l 1185.5 1618.5 l 1193.7 1623.9 l 1202.2 1628.9 l 1210.9 1633.5 l 1219.9 1637.7 l 1229.1 1641.5 l 1238.5 1644.9 l 1248.1 1647.8 l 1257.8 1650.4 l 1267.7 1652.4 l 1277.7 1654 l 1287.8 1655.2 l 1297.9 1655.9 l 1308 1656.1 l 1308 1656.1 l 1318.1 1655.9 l 1328.2 1655.2 l 1338.3 1654 l 1348.3 1652.4 l 1358.2 1650.4 l 1367.9 1647.8 l 1377.5 1644.9 l 1386.9 1641.5 l 1396.1 1637.7 l 1405.1 1633.5 l 1413.8 1628.9 l 1422.3 1623.9 l 1430.5 1618.5 l 1438.3 1612.7 l 1445.9 1606.6 l 1453 1600.1 l 1459.8 1593.4 l 1466.2 1586.3 l 1472.2 1579 l 1477.8 1571.4 l 1483 1563.5 l 1487.7 1555.4 l 1491.9 1547.1 l 1495.6 1538.7 l 1498.9 1530.1 l 1501.7 1521.3 l 1504 1512.4 l 1505.8 1503.4 l 1507.1 1494.4 l 1507.8 1485.3 l 1508.1 1476.2 l pc 468.4 1490.3 m 468.1 1481.2 l 467.4 1472.1 l 466.1 1463.1 l 464.3 1454.1 l 462 1445.2 l 459.2 1436.4 l 455.9 1427.8 l 452.2 1419.4 l 448 1411.1 l 443.3 1403 l 438.1 1395.1 l 432.5 1387.5 l 426.5 1380.2 l 420.1 1373.1 l 413.3 1366.4 l 406.2 1359.9 l 398.6 1353.8 l 390.8 1348 l 382.6 1342.6 l 374.1 1337.6 l 365.4 1333 l 356.4 1328.8 l 347.2 1325 l 337.8 1321.6 l 328.2 1318.7 l 318.5 1316.1 l 308.6 1314.1 l 298.6 1312.5 l 288.5 1311.3 l 278.4 1310.6 l 268.3 1310.4 l 268.3 1310.4 l 258.2 1310.6 l 248.1 1311.3 l 238 1312.5 l 228 1314.1 l 218.1 1316.1 l 208.4 1318.7 l 198.8 1321.6 l 189.4 1325 l 180.2 1328.8 l 171.2 1333 l 162.5 1337.6 l 154 1342.6 l 145.8 1348 l 138 1353.8 l 130.4 1359.9 l 123.3 1366.4 l 116.5 1373.1 l 110.1 1380.2 l 104.1 1387.5 l 98.5 1395.1 l 93.3 1403 l 88.6 1411.1 l 84.4 1419.4 l 80.7 1427.8 l 77.4 1436.4 l 74.6 1445.2 l 72.3 1454.1 l 70.5 1463.1 l 69.2 1472.1 l 68.5 1481.2 l 68.2 1490.3 l 68.2 1490.3 l 68.5 1499.4 l 69.2 1508.5 l 70.5 1517.5 l 72.3 1526.5 l 74.6 1535.4 l 77.4 1544.2 l 80.7 1552.8 l 84.4 1561.2 l 88.6 1569.5 l 93.3 1577.6 l 98.5 1585.5 l 104.1 1593.1 l 110.1 1600.4 l 116.5 1607.5 l 123.3 1614.2 l 130.4 1620.7 l 138 1626.8 l 145.8 1632.6 l 154 1638 l 162.5 1643 l 171.2 1647.6 l 180.2 1651.8 l 189.4 1655.6 l 198.8 1659 l 208.4 1661.9 l 218.1 1664.5 l 228 1666.5 l 238 1668.1 l 248.1 1669.3 l 258.2 1670 l 268.3 1670.2 l 268.3 1670.2 l 278.4 1670 l 288.5 1669.3 l 298.6 1668.1 l 308.6 1666.5 l 318.5 1664.5 l 328.2 1661.9 l 337.8 1659 l 347.2 1655.6 l 356.4 1651.8 l 365.4 1647.6 l 374.1 1643 l 382.6 1638 l 390.8 1632.6 l 398.6 1626.8 l 406.2 1620.7 l 413.3 1614.2 l 420.1 1607.5 l 426.5 1600.4 l 432.5 1593.1 l 438.1 1585.5 l 443.3 1577.6 l 448 1569.5 l 452.2 1561.2 l 455.9 1552.8 l 459.2 1544.2 l 462 1535.4 l 464.3 1526.5 l 466.1 1517.5 l 467.4 1508.5 l 468.1 1499.4 l 468.4 1490.3 l pc 668.2 792 m 343.1 1296.4 l ps 343.1 1296.4 m 346.1 1268.6 l 367.2 1282.2 l 343.1 1296.4 l pf 403.2 1329.1 m 708.1 834 l ps 708.1 834 m 705.6 861.8 l 684.3 848.7 l 708.1 834 l pf 948.2 792 m 1247.9 1282.3 l ps 1247.9 1282.3 m 1224.2 1267.5 l 1245.5 1254.5 l 1247.9 1282.3 l pf 1203.1 1310.5 m 913.3 824.5 l ps 913.3 824.5 m 936.8 839.6 l 915.4 852.4 l 913.3 824.5 l pf 483.3 1450.5 m 1083.2 1450.5 l ps 1083.2 1450.5 m 1058.2 1463 l 1058.2 1438 l 1083.2 1450.5 l pf 1093.1 1511.4 m 483.3 1511.4 l ps 483.3 1511.4 m 508.3 1498.9 l 508.3 1523.9 l 483.3 1511.4 l pf gs 677.3 605.9 m 904.9 605.9 l 904.9 701.1 l 677.3 701.1 l 677.3 605.9 l eoclip newpath /Times f 84.6 sf 677.3 685.3 m 79.4 0 (M) bs 37 79.6 (a) bs 23.8 117.7 (t) bs 37 143.09999 (c) bs 47.6 179.5 (h) bs gr gs /Times f 84.6 sf 1206.5 1484.3 m 29.1 0 (I) bs 47.6 28.8 (n) bs 31.8 76.2 (s) bs 39.7 108.4 (e) bs 29.1 148.2 (r) bs 23.8 177 (t) bs gr gs 140.2 1420.8 m 373.1 1420.8 l 373.1 1516.1 l 140.2 1516.1 l 140.2 1420.8 l eoclip newpath /Times f 84.6 sf 140.2 1500.2 m 66.1 0 (D) bs 39.7 66.9 (e) bs 21.2 106.7 (l) bs 39.7 128.7 (e) bs 23.8 168.5 (t) bs 39.7 193.9 (e) bs gr 0.003 1.000 0.003 c 1365.2 155.9 m 1592.8 155.9 l 1592.8 288.2 l 1365.2 288.2 l 1365.2 155.9 l pc gs 0.003 0.003 0.003 c /Times f 84.6 sf 1455.2 254 m (0) s 1455.2 254 m (0) s gr 1365.3 304.1 m 1598.2 304.1 l 1598.2 436.4 l 1365.3 436.4 l 1365.3 304.1 l pc gs 1460.5 322.8 m 1500.2 322.8 l 1500.2 418 l 1460.5 418 l 1460.5 322.8 l eoclip newpath 0.003 0.003 0.003 c /Times f 84.6 sf 1460.5 402.2 m (1) s 1460.5 402.2 m (1) s gr 1365.4 452.4 m 1598.3 452.4 l 1598.3 584.7 l 1365.4 584.7 l 1365.4 452.4 l pc gs 0.003 0.003 0.003 c /Times f 84.6 sf 1460.5 550.4 m (2) s 1460.5 550.4 m (2) s gr 1254.1 375.4 m 1254.1 373.7 l 1253.9 371.9 l 1253.7 370.2 l 1253.3 368.5 l 1252.9 366.8 l 1252.4 365.1 l 1251.8 363.5 l 1251.1 361.8 l 1250.3 360.3 l 1249.4 358.7 l 1248.5 357.2 l 1247.5 355.7 l 1246.3 354.3 l 1245.1 353 l 1243.9 351.7 l 1242.6 350.5 l 1241.2 349.3 l 1239.7 348.2 l 1238.2 347.2 l 1236.6 346.2 l 1235 345.3 l 1233.3 344.5 l 1231.6 343.8 l 1229.9 343.1 l 1228.1 342.6 l 1226.3 342.1 l 1224.5 341.7 l 1222.6 341.4 l 1220.8 341.2 l 1218.9 341 l 1217 341 l 1217 341 l 1215.1 341 l 1213.2 341.2 l 1211.4 341.4 l 1209.5 341.7 l 1207.7 342.1 l 1205.9 342.6 l 1204.1 343.1 l 1202.4 343.8 l 1200.7 344.5 l 1199 345.3 l 1197.4 346.2 l 1195.8 347.2 l 1194.3 348.2 l 1192.8 349.3 l 1191.4 350.5 l 1190.1 351.7 l 1188.9 353 l 1187.7 354.3 l 1186.5 355.7 l 1185.5 357.2 l 1184.6 358.7 l 1183.7 360.3 l 1182.9 361.8 l 1182.2 363.5 l 1181.6 365.1 l 1181.1 366.8 l 1180.7 368.5 l 1180.3 370.2 l 1180.1 371.9 l 1179.9 373.7 l 1179.9 375.4 l 1179.9 375.4 l 1179.9 377.1 l 1180.1 378.9 l 1180.3 380.6 l 1180.7 382.3 l 1181.1 384 l 1181.6 385.7 l 1182.2 387.3 l 1182.9 389 l 1183.7 390.5 l 1184.6 392.1 l 1185.5 393.6 l 1186.5 395.1 l 1187.7 396.5 l 1188.9 397.8 l 1190.1 399.1 l 1191.4 400.3 l 1192.8 401.5 l 1194.3 402.6 l 1195.8 403.6 l 1197.4 404.6 l 1199 405.5 l 1200.7 406.3 l 1202.4 407 l 1204.1 407.7 l 1205.9 408.2 l 1207.7 408.7 l 1209.5 409.1 l 1211.4 409.4 l 1213.2 409.6 l 1215.1 409.8 l 1217 409.8 l 1217 409.8 l 1218.9 409.8 l 1220.8 409.6 l 1222.6 409.4 l 1224.5 409.1 l 1226.3 408.7 l 1228.1 408.2 l 1229.9 407.7 l 1231.6 407 l 1233.3 406.3 l 1235 405.5 l 1236.6 404.6 l 1238.2 403.6 l 1239.7 402.6 l 1241.2 401.5 l 1242.6 400.3 l 1243.9 399.1 l 1245.1 397.8 l 1246.3 396.5 l 1247.5 395.1 l 1248.5 393.6 l 1249.4 392.1 l 1250.3 390.5 l 1251.1 389 l 1251.8 387.3 l 1252.4 385.7 l 1252.9 384 l 1253.3 382.3 l 1253.7 380.6 l 1253.9 378.9 l 1254.1 377.1 l 1254.1 375.4 l pc 1365.2 222 m 1309.7 222 l 1309.7 375.4 l 1254.1 375.4 l ps 1365.3 370.2 m 1309.7 370.2 l 1309.7 375.4 l 1254.1 375.4 l ps 1365.4 518.5 m 1309.8 518.5 l 1309.8 375.4 l 1254.1 375.4 l ps 1365.3 155.9 m 1592.9 155.9 l 1592.9 288.2 l 1365.3 288.2 l 1365.3 155.9 l pc gs 1455.2 174.6 m 1494.9 174.6 l 1494.9 269.9 l 1455.2 269.9 l 1455.2 174.6 l eoclip newpath 0.003 0.003 0.003 c /Times f 84.6 sf 1455.2 254 m (0) s 1455.2 254 m (0) s gr 1365.4 304.1 m 1598.3 304.1 l 1598.3 436.4 l 1365.4 436.4 l 1365.4 304.1 l pc gs 0.003 0.003 0.003 c /Times f 84.6 sf 1460.5 402.2 m (1) s 1460.5 402.2 m (1) s gr 1365.5 452.4 m 1598.4 452.4 l 1598.4 584.7 l 1365.5 584.7 l 1365.5 452.4 l pc gs 1463.1 471 m 1502.8 471 l 1502.8 566.2 l 1463.1 566.2 l 1463.1 471 l eoclip newpath 0.003 0.003 0.003 c /Times f 84.6 sf 1463.1 550.4 m (2) s 1463.1 550.4 m (2) s gr 1254.2 375.4 m 1254.2 373.7 l 1254 371.9 l 1253.8 370.2 l 1253.4 368.5 l 1253 366.8 l 1252.5 365.1 l 1251.9 363.5 l 1251.2 361.8 l 1250.4 360.3 l 1249.5 358.7 l 1248.6 357.2 l 1247.6 355.7 l 1246.4 354.3 l 1245.2 353 l 1244 351.7 l 1242.7 350.5 l 1241.3 349.3 l 1239.8 348.2 l 1238.3 347.2 l 1236.7 346.2 l 1235.1 345.3 l 1233.4 344.5 l 1231.7 343.8 l 1230 343.1 l 1228.2 342.6 l 1226.4 342.1 l 1224.6 341.7 l 1222.7 341.4 l 1220.9 341.2 l 1219 341 l 1217.1 341 l 1217.1 341 l 1215.2 341 l 1213.3 341.2 l 1211.5 341.4 l 1209.6 341.7 l 1207.8 342.1 l 1206 342.6 l 1204.2 343.1 l 1202.5 343.8 l 1200.8 344.5 l 1199.1 345.3 l 1197.5 346.2 l 1195.9 347.2 l 1194.4 348.2 l 1192.9 349.3 l 1191.5 350.5 l 1190.2 351.7 l 1189 353 l 1187.8 354.3 l 1186.6 355.7 l 1185.6 357.2 l 1184.7 358.7 l 1183.8 360.3 l 1183 361.8 l 1182.3 363.5 l 1181.7 365.1 l 1181.2 366.8 l 1180.8 368.5 l 1180.4 370.2 l 1180.2 371.9 l 1180 373.7 l 1180 375.4 l 1180 375.4 l 1180 377.1 l 1180.2 378.9 l 1180.4 380.6 l 1180.8 382.3 l 1181.2 384 l 1181.7 385.7 l 1182.3 387.3 l 1183 389 l 1183.8 390.5 l 1184.7 392.1 l 1185.6 393.6 l 1186.6 395.1 l 1187.8 396.5 l 1189 397.8 l 1190.2 399.1 l 1191.5 400.3 l 1192.9 401.5 l 1194.4 402.6 l 1195.9 403.6 l 1197.5 404.6 l 1199.1 405.5 l 1200.8 406.3 l 1202.5 407 l 1204.2 407.7 l 1206 408.2 l 1207.8 408.7 l 1209.6 409.1 l 1211.5 409.4 l 1213.3 409.6 l 1215.2 409.8 l 1217.1 409.8 l 1217.1 409.8 l 1219 409.8 l 1220.9 409.6 l 1222.7 409.4 l 1224.6 409.1 l 1226.4 408.7 l 1228.2 408.2 l 1230 407.7 l 1231.7 407 l 1233.4 406.3 l 1235.1 405.5 l 1236.7 404.6 l 1238.3 403.6 l 1239.8 402.6 l 1241.3 401.5 l 1242.7 400.3 l 1244 399.1 l 1245.2 397.8 l 1246.4 396.5 l 1247.6 395.1 l 1248.6 393.6 l 1249.5 392.1 l 1250.4 390.5 l 1251.2 389 l 1251.9 387.3 l 1252.5 385.7 l 1253 384 l 1253.4 382.3 l 1253.8 380.6 l 1254 378.9 l 1254.2 377.1 l 1254.2 375.4 l pc 1365.3 222 m 1309.8 222 l 1309.8 375.4 l 1254.2 375.4 l ps 1365.4 370.2 m 1309.8 370.2 l 1309.8 375.4 l 1254.2 375.4 l ps 1365.5 518.5 m 1309.9 518.5 l 1309.9 375.4 l 1254.2 375.4 l ps 1666.8 833.3 m 1894.4 833.3 l 1894.4 965.6 l 1666.8 965.6 l 1666.8 833.3 l pc gs 0.003 0.003 0.003 c /Times f 84.6 sf 1756.8 931.4 m (0) s 1756.8 931.4 m (0) s gr 1666.9 981.5 m 1899.8 981.5 l 1899.8 1113.79999 l 1666.9 1113.79999 l 1666.9 981.5 l pc gs 1762.1 1000.1 m 1801.8 1000.1 l 1801.8 1095.4 l 1762.1 1095.4 l 1762.1 1000.1 l eoclip newpath 0.003 0.003 0.003 c /Times f 84.6 sf 1762.1 1079.5 m (1) s 1762.1 1079.5 m (1) s gr 1667 1129.79999 m 1899.9 1129.79999 l 1899.9 1262.1 l 1667 1262.1 l 1667 1129.79999 l pc gs 0.003 0.003 0.003 c /Times f 84.6 sf 1762.1 1227.7 m (2) s 1762.1 1227.7 m (2) s gr 1555.7 1052.79999 m 1555.7 1051.1 l 1555.5 1049.29999 l 1555.3 1047.6 l 1554.9 1045.9 l 1554.5 1044.2 l 1554 1042.5 l 1553.4 1040.9 l 1552.7 1039.2 l 1551.9 1037.7 l 1551 1036.1 l 1550.1 1034.6 l 1549.1 1033.1 l 1547.9 1031.7 l 1546.7 1030.4 l 1545.5 1029.1 l 1544.2 1027.9 l 1542.8 1026.7 l 1541.3 1025.6 l 1539.8 1024.6 l 1538.2 1023.6 l 1536.6 1022.7 l 1534.9 1021.9 l 1533.2 1021.2 l 1531.5 1020.5 l 1529.7 1020 l 1527.9 1019.5 l 1526.1 1019.1 l 1524.2 1018.8 l 1522.4 1018.6 l 1520.5 1018.4 l 1518.6 1018.4 l 1518.6 1018.4 l 1516.7 1018.4 l 1514.8 1018.6 l 1513 1018.8 l 1511.1 1019.1 l 1509.3 1019.5 l 1507.5 1020 l 1505.7 1020.5 l 1504 1021.2 l 1502.3 1021.9 l 1500.6 1022.7 l 1499 1023.6 l 1497.4 1024.6 l 1495.9 1025.6 l 1494.4 1026.7 l 1493 1027.9 l 1491.7 1029.1 l 1490.5 1030.4 l 1489.3 1031.7 l 1488.1 1033.1 l 1487.1 1034.6 l 1486.2 1036.1 l 1485.3 1037.7 l 1484.5 1039.2 l 1483.8 1040.9 l 1483.2 1042.5 l 1482.7 1044.2 l 1482.3 1045.9 l 1481.9 1047.6 l 1481.7 1049.29999 l 1481.5 1051.1 l 1481.5 1052.79999 l 1481.5 1052.79999 l 1481.5 1054.5 l 1481.7 1056.29999 l 1481.9 1058 l 1482.3 1059.7 l 1482.7 1061.4 l 1483.2 1063.1 l 1483.8 1064.7 l 1484.5 1066.4 l 1485.3 1067.9 l 1486.2 1069.5 l 1487.1 1071 l 1488.1 1072.5 l 1489.3 1073.9 l 1490.5 1075.2 l 1491.7 1076.5 l 1493 1077.7 l 1494.4 1078.9 l 1495.9 1080 l 1497.4 1081 l 1499 1082 l 1500.6 1082.9 l 1502.3 1083.7 l 1504 1084.4 l 1505.7 1085.1 l 1507.5 1085.6 l 1509.3 1086.1 l 1511.1 1086.5 l 1513 1086.79999 l 1514.8 1087 l 1516.7 1087.2 l 1518.6 1087.2 l 1518.6 1087.2 l 1520.5 1087.2 l 1522.4 1087 l 1524.2 1086.79999 l 1526.1 1086.5 l 1527.9 1086.1 l 1529.7 1085.6 l 1531.5 1085.1 l 1533.2 1084.4 l 1534.9 1083.7 l 1536.6 1082.9 l 1538.2 1082 l 1539.8 1081 l 1541.3 1080 l 1542.8 1078.9 l 1544.2 1077.7 l 1545.5 1076.5 l 1546.7 1075.2 l 1547.9 1073.9 l 1549.1 1072.5 l 1550.1 1071 l 1551 1069.5 l 1551.9 1067.9 l 1552.7 1066.4 l 1553.4 1064.7 l 1554 1063.1 l 1554.5 1061.4 l 1554.9 1059.7 l 1555.3 1058 l 1555.5 1056.29999 l 1555.7 1054.5 l 1555.7 1052.79999 l pc 1666.8 899.4 m 1611.3 899.4 l 1611.3 1052.79999 l 1555.7 1052.79999 l ps 1666.9 1047.6 m 1611.3 1047.6 l 1611.3 1052.79999 l 1555.7 1052.79999 l ps 1667 1195.9 m 1611.4 1195.9 l 1611.4 1052.79999 l 1555.7 1052.79999 l ps 1666.9 833.3 m 1894.5 833.3 l 1894.5 965.6 l 1666.9 965.6 l 1666.9 833.3 l pc gs 1756.8 852 m 1796.5 852 l 1796.5 947.2 l 1756.8 947.2 l 1756.8 852 l eoclip newpath 0.003 0.003 0.003 c /Times f 84.6 sf 1756.8 931.4 m (0) s 1756.8 931.4 m (0) s gr 1667 981.5 m 1899.9 981.5 l 1899.9 1113.79999 l 1667 1113.79999 l 1667 981.5 l pc gs 0.003 0.003 0.003 c /Times f 84.6 sf 1762.1 1079.5 m (1) s 1762.1 1079.5 m (1) s gr 1667.1 1129.79999 m 1900 1129.79999 l 1900 1262.1 l 1667.1 1262.1 l 1667.1 1129.79999 l pc gs 1764.8 1148.29999 m 1804.5 1148.29999 l 1804.5 1243.5 l 1764.8 1243.5 l 1764.8 1148.29999 l eoclip newpath 0.003 0.003 0.003 c /Times f 84.6 sf 1764.8 1227.7 m (2) s 1764.8 1227.7 m (2) s gr 1555.8 1052.79999 m 1555.8 1051.1 l 1555.6 1049.29999 l 1555.4 1047.6 l 1555 1045.9 l 1554.6 1044.2 l 1554.1 1042.5 l 1553.5 1040.9 l 1552.8 1039.2 l 1552 1037.7 l 1551.1 1036.1 l 1550.2 1034.6 l 1549.2 1033.1 l 1548 1031.7 l 1546.8 1030.4 l 1545.6 1029.1 l 1544.3 1027.9 l 1542.9 1026.7 l 1541.4 1025.6 l 1539.9 1024.6 l 1538.3 1023.6 l 1536.7 1022.7 l 1535 1021.9 l 1533.3 1021.2 l 1531.6 1020.5 l 1529.8 1020 l 1528 1019.5 l 1526.2 1019.1 l 1524.3 1018.8 l 1522.5 1018.6 l 1520.6 1018.4 l 1518.7 1018.4 l 1518.7 1018.4 l 1516.8 1018.4 l 1514.9 1018.6 l 1513.1 1018.8 l 1511.2 1019.1 l 1509.4 1019.5 l 1507.6 1020 l 1505.8 1020.5 l 1504.1 1021.2 l 1502.4 1021.9 l 1500.7 1022.7 l 1499.1 1023.6 l 1497.5 1024.6 l 1496 1025.6 l 1494.5 1026.7 l 1493.1 1027.9 l 1491.8 1029.1 l 1490.6 1030.4 l 1489.4 1031.7 l 1488.2 1033.1 l 1487.2 1034.6 l 1486.3 1036.1 l 1485.4 1037.7 l 1484.6 1039.2 l 1483.9 1040.9 l 1483.3 1042.5 l 1482.8 1044.2 l 1482.4 1045.9 l 1482 1047.6 l 1481.8 1049.29999 l 1481.6 1051.1 l 1481.6 1052.79999 l 1481.6 1052.79999 l 1481.6 1054.5 l 1481.8 1056.29999 l 1482 1058 l 1482.4 1059.7 l 1482.8 1061.4 l 1483.3 1063.1 l 1483.9 1064.7 l 1484.6 1066.4 l 1485.4 1067.9 l 1486.3 1069.5 l 1487.2 1071 l 1488.2 1072.5 l 1489.4 1073.9 l 1490.6 1075.2 l 1491.8 1076.5 l 1493.1 1077.7 l 1494.5 1078.9 l 1496 1080 l 1497.5 1081 l 1499.1 1082 l 1500.7 1082.9 l 1502.4 1083.7 l 1504.1 1084.4 l 1505.8 1085.1 l 1507.6 1085.6 l 1509.4 1086.1 l 1511.2 1086.5 l 1513.1 1086.79999 l 1514.9 1087 l 1516.8 1087.2 l 1518.7 1087.2 l 1518.7 1087.2 l 1520.6 1087.2 l 1522.5 1087 l 1524.3 1086.79999 l 1526.2 1086.5 l 1528 1086.1 l 1529.8 1085.6 l 1531.6 1085.1 l 1533.3 1084.4 l 1535 1083.7 l 1536.7 1082.9 l 1538.3 1082 l 1539.9 1081 l 1541.4 1080 l 1542.9 1078.9 l 1544.3 1077.7 l 1545.6 1076.5 l 1546.8 1075.2 l 1548 1073.9 l 1549.2 1072.5 l 1550.2 1071 l 1551.1 1069.5 l 1552 1067.9 l 1552.8 1066.4 l 1553.5 1064.7 l 1554.1 1063.1 l 1554.6 1061.4 l 1555 1059.7 l 1555.4 1058 l 1555.6 1056.29999 l 1555.8 1054.5 l 1555.8 1052.79999 l pc 1666.9 899.4 m 1611.4 899.4 l 1611.4 1052.79999 l 1555.8 1052.79999 l ps 1667 1047.6 m 1611.4 1047.6 l 1611.4 1052.79999 l 1555.8 1052.79999 l ps 1667.1 1195.9 m 1611.5 1195.9 l 1611.5 1052.79999 l 1555.8 1052.79999 l ps 0.003 0.003 0.003 c 968.4 542.1 m 1185.3 409.8 l ps 1185.3 409.8 m 1170.5 433.5 l 1157.4 412.1 l 1185.3 409.8 l pf 1180 372.8 m 931.3 520.89999 l ps 931.3 520.89999 m 946.4 497.4 l 959.2 518.8 l 931.3 520.89999 l pf 1381.1 1309.4 m 1508.1 1087.1 l ps 1508.1 1087.1 m 1506.6 1115 l 1484.8 1102.6 l 1508.1 1087.1 l pf 1481.6 1065.9 m 1344.1 1288.2 l ps 1344.1 1288.2 m 1346.6 1260.4 l 1367.9 1273.5 l 1344.1 1288.2 l pf 1005.4 647.9 m 1486.9 1023.6 l ps 1486.9 1023.6 m 1459.5 1018.1 l 1474.9 998.4 l 1486.9 1023.6 l pf 1307 1293.5 m 1217.1 420.4 l ps 1217.1 420.4 m 1232.1 444 l 1207.2 446.5 l 1217.1 420.4 l pf 0.503 0.003 0.003 c 976.1 756.3 m 1296.4 1304.1 l ps 1296.4 1304.1 m 1273 1288.8 l 1294.6 1276.2 l 1296.4 1304.1 l pf 1169.4 1346.4 m 867.8 822.5 l ps 867.8 822.5 m 891.1 837.9 l 869.4 850.4 l 867.8 822.5 l pf 455.1 1409.9 m 1116.5 1409.9 l ps 1116.5 1409.9 m 1091.5 1422.4 l 1091.5 1397.4 l 1116.5 1409.9 l pf 449.8 1362.3 m 756.7 838.4 l ps 756.7 838.4 m 754.8 866.3 l 733.3 853.7 l 756.7 838.4 l pf 1.000 1.000 1.000 c 1309.5 1733.8 m 1539.6 1733.8 l 1539.6 1927.9 l 1079.4 1927.9 l 1079.4 1733.8 l 1309.5 1733.8 l pf 1309.5 1733.8 m 1539.6 1733.8 l 1539.6 1927.9 l 1079.4 1927.9 l 1079.4 1733.8 l 1309.5 1733.8 l pc 514.5 193.1 m 974.7 193.1 l 974.7 387.2 l 514.5 387.2 l 514.5 193.1 l pf 514.5 193.1 m 974.7 193.1 l 974.7 387.2 l 514.5 387.2 l 514.5 193.1 l pc 0.003 1.000 0.003 c 619.1 2375.59999 m 618.9 2369.3 l 618.3 2363 l 617.4 2356.8 l 616.1 2350.59999 l 614.4 2344.4 l 612.3 2338.4 l 609.9 2332.4 l 607.1 2326.5 l 604 2320.8 l 600.5 2315.2 l 596.7 2309.8 l 592.5 2304.5 l 588.1 2299.5 l 583.3 2294.59999 l 578.3 2289.9 l 573 2285.4 l 567.4 2281.2 l 561.6 2277.2 l 555.6 2273.5 l 549.3 2270 l 542.8 2266.8 l 536.2 2263.9 l 529.3 2261.3 l 522.39999 2258.9 l 515.3 2256.9 l 508 2255.2 l 500.7 2253.7 l 493.3 2252.59999 l 485.9 2251.8 l 478.4 2251.4 l 470.9 2251.2 l 470.9 2251.2 l 463.4 2251.4 l 455.9 2251.8 l 448.5 2252.59999 l 441.1 2253.7 l 433.8 2255.2 l 426.5 2256.9 l 419.4 2258.9 l 412.5 2261.3 l 405.6 2263.9 l 399 2266.8 l 392.5 2270 l 386.2 2273.5 l 380.2 2277.2 l 374.4 2281.2 l 368.8 2285.4 l 363.5 2289.9 l 358.5 2294.59999 l 353.7 2299.5 l 349.3 2304.5 l 345.1 2309.8 l 341.3 2315.2 l 337.8 2320.8 l 334.7 2326.5 l 331.9 2332.4 l 329.5 2338.4 l 327.4 2344.4 l 325.7 2350.59999 l 324.4 2356.8 l 323.5 2363 l 322.9 2369.3 l 322.7 2375.59999 l 322.7 2375.59999 l 322.9 2381.9 l 323.5 2388.2 l 324.4 2394.4 l 325.7 2400.6 l 327.4 2406.8 l 329.5 2412.8 l 331.9 2418.8 l 334.7 2424.7 l 337.8 2430.4 l 341.3 2436 l 345.1 2441.4 l 349.3 2446.7 l 353.7 2451.7 l 358.5 2456.6 l 363.5 2461.3 l 368.8 2465.8 l 374.4 2470 l 380.2 2474 l 386.2 2477.7 l 392.5 2481.2 l 399 2484.4 l 405.6 2487.3 l 412.5 2489.9 l 419.4 2492.3 l 426.5 2494.3 l 433.8 2496 l 441.1 2497.5 l 448.5 2498.6 l 455.9 2499.4 l 463.4 2499.8 l 470.9 2500 l 470.9 2500 l 478.4 2499.8 l 485.9 2499.4 l 493.3 2498.6 l 500.7 2497.5 l 508 2496 l 515.3 2494.3 l 522.39999 2492.3 l 529.3 2489.9 l 536.2 2487.3 l 542.8 2484.4 l 549.3 2481.2 l 555.6 2477.7 l 561.6 2474 l 567.4 2470 l 573 2465.8 l 578.3 2461.3 l 583.3 2456.6 l 588.1 2451.7 l 592.5 2446.7 l 596.7 2441.4 l 600.5 2436 l 604 2430.4 l 607.1 2424.7 l 609.9 2418.8 l 612.3 2412.8 l 614.4 2406.8 l 616.1 2400.6 l 617.4 2394.4 l 618.3 2388.2 l 618.9 2381.9 l 619.1 2375.59999 l pc 1090.1 2370.5 m 1089.9 2364.2 l 1089.29999 2357.9 l 1088.4 2351.7 l 1087.1 2345.5 l 1085.4 2339.3 l 1083.29999 2333.3 l 1080.9 2327.3 l 1078.1 2321.4 l 1075 2315.7 l 1071.5 2310.09999 l 1067.7 2304.7 l 1063.5 2299.4 l 1059.1 2294.4 l 1054.29999 2289.5 l 1049.29999 2284.8 l 1044 2280.3 l 1038.4 2276.09999 l 1032.6 2272.09999 l 1026.6 2268.4 l 1020.3 2264.9 l 1013.8 2261.7 l 1007.2 2258.8 l 1000.3 2256.2 l 993.4 2253.8 l 986.3 2251.8 l 979 2250.09999 l 971.7 2248.59999 l 964.3 2247.5 l 956.9 2246.7 l 949.4 2246.3 l 941.9 2246.09999 l 941.9 2246.09999 l 934.4 2246.3 l 926.9 2246.7 l 919.5 2247.5 l 912.1 2248.59999 l 904.8 2250.09999 l 897.5 2251.8 l 890.4 2253.8 l 883.5 2256.2 l 876.6 2258.8 l 870 2261.7 l 863.5 2264.9 l 857.2 2268.4 l 851.2 2272.09999 l 845.4 2276.09999 l 839.8 2280.3 l 834.5 2284.8 l 829.5 2289.5 l 824.7 2294.4 l 820.3 2299.4 l 816.1 2304.7 l 812.3 2310.09999 l 808.8 2315.7 l 805.7 2321.4 l 802.9 2327.3 l 800.5 2333.3 l 798.4 2339.3 l 796.7 2345.5 l 795.4 2351.7 l 794.5 2357.9 l 793.9 2364.2 l 793.7 2370.5 l 793.7 2370.5 l 793.9 2376.8 l 794.5 2383.09999 l 795.4 2389.3 l 796.7 2395.5 l 798.4 2401.7 l 800.5 2407.7 l 802.9 2413.7 l 805.7 2419.6 l 808.8 2425.3 l 812.3 2430.9 l 816.1 2436.3 l 820.3 2441.6 l 824.7 2446.6 l 829.5 2451.5 l 834.5 2456.2 l 839.8 2460.7 l 845.4 2464.9 l 851.2 2468.9 l 857.2 2472.6 l 863.5 2476.1 l 870 2479.3 l 876.6 2482.2 l 883.5 2484.8 l 890.4 2487.2 l 897.5 2489.2 l 904.8 2490.9 l 912.1 2492.4 l 919.5 2493.5 l 926.9 2494.3 l 934.4 2494.7 l 941.9 2494.9 l 941.9 2494.9 l 949.4 2494.7 l 956.9 2494.3 l 964.3 2493.5 l 971.7 2492.4 l 979 2490.9 l 986.3 2489.2 l 993.4 2487.2 l 1000.3 2484.8 l 1007.2 2482.2 l 1013.8 2479.3 l 1020.3 2476.1 l 1026.6 2472.6 l 1032.6 2468.9 l 1038.4 2464.9 l 1044 2460.7 l 1049.29999 2456.2 l 1054.29999 2451.5 l 1059.1 2446.6 l 1063.5 2441.6 l 1067.7 2436.3 l 1071.5 2430.9 l 1075 2425.3 l 1078.1 2419.6 l 1080.9 2413.7 l 1083.29999 2407.7 l 1085.4 2401.7 l 1087.1 2395.5 l 1088.4 2389.3 l 1089.29999 2383.09999 l 1089.9 2376.8 l 1090.1 2370.5 l pc 1608.7 2370.59999 m 1608.5 2364.3 l 1607.9 2358 l 1607 2351.8 l 1605.7 2345.59999 l 1604 2339.4 l 1601.9 2333.4 l 1599.5 2327.4 l 1596.7 2321.5 l 1593.6 2315.8 l 1590.1 2310.2 l 1586.3 2304.8 l 1582.1 2299.5 l 1577.7 2294.5 l 1572.9 2289.59999 l 1567.9 2284.9 l 1562.6 2280.4 l 1557 2276.2 l 1551.2 2272.2 l 1545.2 2268.5 l 1538.9 2265 l 1532.4 2261.8 l 1525.8 2258.9 l 1518.9 2256.3 l 1512 2253.9 l 1504.9 2251.9 l 1497.6 2250.2 l 1490.3 2248.7 l 1482.9 2247.59999 l 1475.5 2246.8 l 1468 2246.4 l 1460.5 2246.2 l 1460.5 2246.2 l 1453 2246.4 l 1445.5 2246.8 l 1438.1 2247.59999 l 1430.7 2248.7 l 1423.4 2250.2 l 1416.1 2251.9 l 1409 2253.9 l 1402.1 2256.3 l 1395.2 2258.9 l 1388.6 2261.8 l 1382.1 2265 l 1375.8 2268.5 l 1369.8 2272.2 l 1364 2276.2 l 1358.4 2280.4 l 1353.1 2284.9 l 1348.1 2289.59999 l 1343.3 2294.5 l 1338.9 2299.5 l 1334.7 2304.8 l 1330.9 2310.2 l 1327.4 2315.8 l 1324.3 2321.5 l 1321.5 2327.4 l 1319.1 2333.4 l 1317 2339.4 l 1315.3 2345.59999 l 1314 2351.8 l 1313.1 2358 l 1312.5 2364.3 l 1312.3 2370.59999 l 1312.3 2370.59999 l 1312.5 2376.9 l 1313.1 2383.2 l 1314 2389.4 l 1315.3 2395.6 l 1317 2401.8 l 1319.1 2407.8 l 1321.5 2413.8 l 1324.3 2419.7 l 1327.4 2425.4 l 1330.9 2431 l 1334.7 2436.4 l 1338.9 2441.7 l 1343.3 2446.7 l 1348.1 2451.6 l 1353.1 2456.3 l 1358.4 2460.8 l 1364 2465 l 1369.8 2469 l 1375.8 2472.7 l 1382.1 2476.2 l 1388.6 2479.4 l 1395.2 2482.3 l 1402.1 2484.9 l 1409 2487.3 l 1416.1 2489.3 l 1423.4 2491 l 1430.7 2492.5 l 1438.1 2493.6 l 1445.5 2494.4 l 1453 2494.8 l 1460.5 2495 l 1460.5 2495 l 1468 2494.8 l 1475.5 2494.4 l 1482.9 2493.6 l 1490.3 2492.5 l 1497.6 2491 l 1504.9 2489.3 l 1512 2487.3 l 1518.9 2484.9 l 1525.8 2482.3 l 1532.4 2479.4 l 1538.9 2476.2 l 1545.2 2472.7 l 1551.2 2469 l 1557 2465 l 1562.6 2460.8 l 1567.9 2456.3 l 1572.9 2451.6 l 1577.7 2446.7 l 1582.1 2441.7 l 1586.3 2436.4 l 1590.1 2431 l 1593.6 2425.4 l 1596.7 2419.7 l 1599.5 2413.8 l 1601.9 2407.8 l 1604 2401.8 l 1605.7 2395.6 l 1607 2389.4 l 1607.9 2383.2 l 1608.5 2376.9 l 1608.7 2370.59999 l pc 158.7 2367.7 m 322.8 2367.7 l ps 322.8 2367.7 m 297.8 2380.2 l 297.8 2355.2 l 322.8 2367.7 l pf 624.4 2373 m 793.7 2373 l ps 793.7 2373 m 768.7 2385.5 l 768.7 2360.5 l 793.7 2373 l pf 1102.1 2369.09999 m 1301.7 2367.7 l ps 1301.7 2367.7 m 1276.8 2380.4 l 1276.6 2355.4 l 1301.7 2367.7 l pf 1610.1 2369 m 1779.4 2369 l ps 1779.4 2369 m 1754.4 2381.5 l 1754.4 2356.5 l 1779.4 2369 l pf 1.000 1.000 1.000 c 464.7 2536.5 m 586.6 2536.5 l 586.6 2595.5 l 342.8 2595.5 l 342.8 2536.5 l 464.7 2536.5 l pf 464.7 2536.5 m 586.6 2536.5 l 586.6 2595.5 l 342.8 2595.5 l 342.8 2536.5 l 464.7 2536.5 l pc 946.3 2536.5 m 1068.2 2536.5 l 1068.2 2595.5 l 824.4 2595.5 l 824.4 2536.5 l 946.3 2536.5 l pf 946.3 2536.5 m 1068.2 2536.5 l 1068.2 2595.5 l 824.4 2595.5 l 824.4 2536.5 l 946.3 2536.5 l pc 1476.8 2536.5 m 1598.7 2536.5 l 1598.7 2595.5 l 1354.9 2595.5 l 1354.9 2536.5 l 1476.8 2536.5 l pf 1476.8 2536.5 m 1598.7 2536.5 l 1598.7 2595.5 l 1354.9 2595.5 l 1354.9 2536.5 l 1476.8 2536.5 l pc gs 0.003 0.003 0.003 c /Times f 84.6 sf 349.3 2405.1 m 29.1 0 (I) bs 47.6 28.8 (n) bs 23.8 76.2 (t) bs 29.1 101.6 (r) bs 45 130.4 (o) bs 47.6 175.3 (n) bs gr gs 899.6 2325.7 m 989.5 2325.7 l 989.5 2420.9 l 899.6 2420.9 l 899.6 2325.7 l eoclip newpath 0.003 0.003 0.003 c /Times f 84.6 sf 899.6 2405.1 m 47.6 0 (P) bs 39.7 49.1 (y) bs gr gs 0.003 0.003 0.003 c /Times f 84.6 sf 1344.1 2405.1 m 47.6 0 (S) bs 42.3 47.4 (p) bs 37 90.6 (a) bs 37 128.7 (c) bs 39.7 165.1 (e) bs 29.1 204.9 (r) bs gr 0.003 1.000 0.003 c 137.6 2198.4 m 1830.9 2198.4 l 1830.9 2611.1 l 137.6 2611.1 l 137.6 2198.4 l pc gs 190.5 2389.2 m 251.4 2389.2 l 251.4 2484.4 l 190.5 2484.4 l 190.5 2389.2 l eoclip newpath 0.003 0.003 0.003 c /Times f 84.6 sf 190.5 2468.6 m 39.7 0 (5) bs 21.2 39.8 (') bs gr gs 0.003 0.003 0.003 c /Times f 84.6 sf 1645.7 2473.9 m 39.7 0 (3) bs 21.2 39.8 (') bs gr 0.003 0.003 0.003 c 691.6 483.3 m 678.9 464.9 l 669.4 444.6 l 663.4 422.5 l 661.4 399.2 l 666.1 364 l 679.4 332.4 l 700.1 305.6 l 726.9 284.9 l 758.5 271.6 l 793.7 266.9 l 828.8 271.6 l 860.4 284.9 l 887.2 305.6 l 907.9 332.4 l 921.2 364 l 926 399.2 l 923.4 425 l 916.1 449.2 l 904.5 471.2 l 889.2 490.5 l 870.7 506.7 l ps 691.6 483.3 m 678.4 437.7 l 653.7 454.8 l pf 1401.3 1649.4 m 1419.8 1665.5 l 1435.1 1684.8 l 1446.6 1706.8 l 1453.8 1730.9 l 1456.4 1756.8 l 1451.6 1791.9 l 1438.3 1823.5 l 1417.6 1850.3 l 1390.8 1871 l 1359.2 1884.3 l 1324.1 1889.1 l 1288.9 1884.3 l 1257.3 1871 l 1230.5 1850.3 l 1209.8 1823.5 l 1196.5 1791.9 l 1191.8 1756.8 l 1193.8 1733.3 l 1199.9 1711.2 l 1209.5 1690.8 l 1222.3 1672.5 l ps 1401.3 1649.4 m 1425.4 1690.3 l 1445.1 1667.6 l pf 344.3 1645.6 m 362.8 1661.7 l 378.1 1681 l 389.6 1703 l 396.8 1727.1 l 399.4 1753 l 394.6 1788.1 l 381.3 1819.7 l 360.6 1846.5 l 333.8 1867.2 l 302.2 1880.5 l 267.1 1885.3 l 231.9 1880.5 l 200.3 1867.2 l 173.5 1846.5 l 152.8 1819.7 l 139.5 1788.1 l 134.8 1753 l 136.8 1729.5 l 142.9 1707.4 l 152.5 1687 l 165.3 1668.7 l ps 344.3 1645.6 m 368.4 1686.5 l 388.1 1663.8 l pf 0.503 0.003 0.003 c 1440.5 1625.9 m 1461.2 1648.7 l 1479 1675.4 l 1493.5 1705.5 l 1504.3 1738.5 l 1511.1 1773.9 l 1513.5 1811.3 l 1508.8 1863.6 l 1495.6 1911.7 l 1474.9 1954.1 l 1447.7 1989.5 l 1415.2 2016.4 l 1378.2 2033.6 l 1338.1 2039.7 l 1297.9 2033.6 l 1260.9 2016.4 l 1228.4 1989.5 l 1201.2 1954.1 l 1180.5 1911.7 l 1167.3 1863.6 l 1162.7 1811.3 l 1164.4 1778.7 l 1169.6 1747.5 l 1177.9 1718 l 1189.2 1690.7 l 1203.1 1665.7 l ps 1440.5 1625.9 m 1459.6 1669.3 l 1481.9 1649.1 l pf 658.9 476.8 m 645 451.8 l 633.9 424.4 l 625.6 395.1 l 620.5 364 l 618.8 331.5 l 623.4 279.1 l 636.6 231 l 657.3 188.6 l 684.5 153.2 l 717 126.3 l 754 109.1 l 794.2 103.1 l 834.3 109.1 l 871.3 126.3 l 903.8 153.2 l 931 188.6 l 951.7 231 l 964.9 279.1 l 969.6 331.5 l 967.2 368.8 l 960.4 404.2 l 949.6 437.2 l 935 467.3 l 917.2 494 l 896.5 516.89999 l ps 658.9 476.8 m 650.1 430.2 l 623.9 444.8 l pf 0.003 0.503 0.003 c 395.4 2247.2 m 380.6 2231.4 l 369.4 2212.8 l 362.2 2191.9 l 359.8 2169.3 l 365 2136.7 l 379.7 2108.3 l 402 2086 l 430.4 2071.3 l 463 2066.09999 l 495.5 2071.3 l 523.89999 2086 l 546.2 2108.3 l 560.9 2136.7 l 566.2 2169.3 l 564.2 2189 l 558.8 2207.5 l 550.1 2224.5 l 538.6 2239.4 l 524.6 2252 l ps 395.4 2247.2 m 375.6 2204.09999 l 353.7 2224.59999 l pf 878.2 2254 m 863.4 2238.2 l 852.2 2219.59999 l 845 2198.7 l 842.6 2176.09999 l 847.8 2143.5 l 862.5 2115.09999 l 884.8 2092.8 l 913.2 2078.09999 l 945.8 2072.9 l 978.3 2078.09999 l 1006.7 2092.8 l 1029 2115.09999 l 1043.7 2143.5 l 1049 2176.09999 l 1047 2195.8 l 1041.6 2214.3 l 1032.9 2231.3 l 1021.4 2246.2 l 1007.4 2258.8 l ps 878.2 2254 m 858.4 2210.9 l 836.5 2231.4 l pf 1387.5 2260.7 m 1372.7 2244.9 l 1361.5 2226.3 l 1354.3 2205.4 l 1351.9 2182.8 l 1357.1 2150.2 l 1371.8 2121.8 l 1394.1 2099.5 l 1422.5 2084.8 l 1455.1 2079.59999 l 1487.6 2084.8 l 1516 2099.5 l 1538.3 2121.8 l 1553 2150.2 l 1558.3 2182.8 l 1556.3 2202.5 l 1550.9 2221 l 1542.2 2238 l 1530.7 2252.9 l 1516.7 2265.5 l ps 1387.5 2260.7 m 1367.7 2217.59999 l 1345.8 2238.09999 l pf gr 0 -2655.1 t pom %%PageTrailer %%Trailer count op_count sub {pop} repeat countdictstack dict_count sub {end} repeat b4_inc_state restore %%EOF wise-2.4.1/docs/wise2.tex0000644000175000001440000023662407640311474014577 0ustar philippusers \documentclass{article} \usepackage{epsfig} \begin{document} \newcommand{\programtext}[1]{{\tt #1}} \title{Wise2 Documentation (version 2.2 series)} \author{Ewan Birney\\ EBI\\ Wellcome Trust Genome Campus\\ Hinxton, Cambridge CB10 1SD,\\ England.\\ Email: birney@ebi.ac.uk} \maketitle \newpage \tableofcontents \newpage \section{Overview} Wise2 is a package focused on comparisons of biopolymers, commonly DNA sequence and protein sequence. There are many other packages which do this, probably the best known being BLAST package (from NCBI) and the Fasta package (from Bill Pearson). There are other packages, such as the HMMER package (Sean Eddy) or SAM package (UC Santa Cruz) focused on hidden Markov models (HMMs) of biopolymers. Wise2's is now a collection of algorithms which generally differ from the usualy, ``standard'' bioinformatics comparison methods. Probably the most used algorithm in Wise2 is \emph{genewise}, which is the comparison of DNA sequence at the level of its protein translation. This comparison allows the simultaneous prediction of say gene structure with homology based alignment. However Wise2 has a number of other methods which I hope will also appeal to users - \emph{promoterwise} for comparing upstream regions, \emph{genomewise} as a ``protein gene finisher'' tool for combining disparate evidence strands and \emph{scanwisep} as a fast but sensitive search method. Wise2, although implemented in C makes heavy use of the Dynamite code generating language. Dynamite was written for this project, by myself (Ewan Birney). There is a separate documentation for Dynamite found in the same place as this file; to be honest noone except me can be expected to use Dynamite; it is a cranky, stupid, badly written code generating language with about two thirds of its code base dedicated to dynamic programming, and the remaining third a rather bad primitive object based system. It does however fit me like a glove, and makes my own personal code efficiency impressive. Wise2 has had a varied life. It started off as a rewrite of my old pairwise and searchwise package (called WiseTools), hence the name Wise2. For a while it looked as if it was going to be pensioned off and live its life out as a rather solid code base for genewise and estwise, but mid 2002 I came back to it for long and complex reasons not worth putting into documentation. This lead to the new methods such as promoterwise and scanwisep which I have high hopes for, though the real test is with real data used by real users... \subsection{Authors} The Wise2 package was principly written by Ewan Birney, who wrote the main genewise and estwise programs. The protein comparison database search program was written by Richard Copley using the underlying Wise2 libraries. Wise2 also uses code from Sean Eddy for reading HMMs and for Extreme value distribution fitting. However the authorship of Wise2 should be more fairly distributed between the main authors and the wonderful alpha testers I have had over the years. In particular Michele Clamp stands out as my longest running collaborator and tester, and indeed in effect all my successful algorithms have been best used and developed with Michele. Other mentions go to Gos Micklem and Niclas Jareborg and for their work at testing and their patience in my coding over the last couple of years. Other notables are (in no apparent order) - Enoch Huang, Erik Sonnhammer, Doug Rusch, Steve Jones, Ian Korf, Iftach Nachman, George Hartzell and Lars Arvestead. I believe that program writing is a 50-50 partnership between the coders and the testers or developers, and these people have actively helped me make a much better package. \newpage \section{Introduction for the impatient} It may well be that you want to understand Wise2's functionality now, without bothering with the concepts or the installation instructions. This section is designed for you. Wise2 has four main executable programs using sequence inputs which are designed to provide access to the main algorithms sensibly. The algorithms you are interested in is \emph{genewise} - compare protein information to genomic DNA and \emph{estwise} - compare protein information to EST/cDNA DNA. Other algorithms in Wise2 have their own single executables. In particular you might be interested in \emph{promoterwise} These are the programs which you might use for this. \begin{description} \item[genewise] a single protein vs a single genomic dna sequence \item[genewisedb] a database of proteins vs a database of genomic dna sequences. Read section \ref{genewise_large} before you use this in anger though. \item[estwise] a single protein vs a single EST/cDNA sequence. \item[estwisedb] a database of proteins vs a database of EST/cDNA sequences. Read section \ref{estwise_large} before you use this in anger though. \end{description} If you see error messages like \begin{verbatim} Warning Error Could not open human.gf as a genefrequency file Warning Error Could not read a GeneFrequency file in human.gf ... \end{verbatim} This means that the enviroment variable WISECONFIGDIR has not been set up correctly. You need to find where the distribution was downloaded to (a directory called something like wise2.1.16b) and inside that directory should be the configuration directory wisecfg. You need to setenv WISECONFIGDIR to that directory. In each of the programs the protein can either be a protein sequence or a protein profile HMM, as made by the HMMER package (both version 1 and version 2 HMMs can be read). Any of the databases can have one entry (in which case more efficient routines are used), and databases of profile HMMs, such as those provided by Pfam, can be used. The simple running of a protein sequence (drosophila) vs a human genomic sequence, using genewise is given below. The output comes on stdout, which in normal unix notation can be redirected to a file. \begin{verbatim} adnah:[/birney/search]<98>: genewise road.pep hngen.fa genewise (unreleased release) This program is freely distributed under a GPL. See source directory Copyright (c) GRL limited: portions of the code are from separate copyright Query protein: roa1_drome Comp Matrix: blosum62.bla Gap open: 12 Gap extension: 2 Start/End local Target Sequence HSHNRNPA Strand: forward Gene Paras: human.gf Codon Table: codon.table Subs error: 1e-05 Indel error: 1e-05 Model splice? model Model codon bias? flat Model intron bias? tied Null model syn Algorithm 623 Find start end points: [25,1387][346,3962] Score 87719 Recovering alignment: Alignment recoveredExplicit read offone 94% genewise output Score 253.10 bits over entire alignment Scores as bits over a synchronous coding model Warning: The bits scores is not probablistically correct for single seqs See WWW help for more info roa1_drome 88 AQKSRPHKIDGRVVEPKRAVPRQ DID A +RPHK+DGRVVEPKRAV R+ D AMNARPHKVDGRVVEPKRAVSRE DSQ HSHNRNPA 1867 gaagaccagggagggcaaggtagGTGAGTG Intron 2 TAGgtc ctacgcaataggttacagctcga<0-----[1936 : 2083]-0>aca tgtagacggtaatgaagatccaa tta roa1_drome 114 SPNAGATVKKLFVGALKDDHDEQSIRDYFQHFGNIVDINIVIDKETGKK P A TVKK+FVG +K+D +E +RDYF+ +G I I I+ D+ +GKK RPGAHLTVKKIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKK HSHNRNPA 2093 acggctagaaatgggaaggaggcccagttgctgaaggagaaagcgagaa gcgcatctaatttggtaaacaaaatgaataaagatattattcaggggaa aatccatgagatttctaactaatcaatttagtaatagtacgtcactcga roa1_drome 163 RGFAFVEFDDYDPVDKVV QKQHQ RGFAFV FDD+D VDK+V QK H RGFAFVTFDDHDSVDKIV L:I[att] QKYHT HSHNRNPA 2240 agtgtgatggcgtggaagAGTAAGTA Intron 3 TAGTTcatca ggtcttctaaaactaatt <1-----[2295 : 2387]-1> aaaac gctctactcctccgtgtc gactt roa1_drome 187 LNGKMVDVKKALPKQNDQQGGGGGR +NG +V+KAL KQ R VNGHNCEVRKALSKQEMASASSSQR G:G[ggt] HSHNRNPA 2405 gagcatggaagctacgagagttacaGGTATGCT Intron 4 tagaagatgactcaaatcgcccgag <1-----[2481 : 2793] gtccctataacgagaggtttaccaa ...truncated \end{verbatim} The output is as follows \begin{itemize} \item Parameters of the comparison used (it used default parameters) \item The alignment of a combined homology + gene prediction alignment \end{itemize} The pretty alignment shows the protein sequence on the first line, followed by a line indicating the similarity level of the match followed by 4 lines representing the DNA sequence. The DNA sequence in the exons descending in triplets, each triplet being a codon. The translation of each codon is shown above it. Between the two protein sequences a line indicating the similarity of the match is printed. In introns the DNA sequence is not shown but for the first 7 bases (making the 5' splice site) and the last 3 bases of the 3' splice site. The intervening sequence is indicated in the square brackets. Above each intron, for phase 1 and 2 introns (ones that split a codon) the implied protein to conceptual gene match is displayed, with the codon in square brackets. Generally the defaults of the options are reasonably sensible, and for the main part you should trust them until you become familar with the package. The following commands show how to run the other programs in a variety of different modes \subsection{Common running modes} \label{sec:commonmode} Running modes for genewise (genomic to protein comparisons). NB, the order of the -options are not important, but the protein file must be before the dna file \begin{itemize} \item \hbox{\tt{genewise protein.pep cosmid.dna}} compares a protein sequence to a DNA sequence (same as the example above) \item \hbox{\tt{genewise -hmmer pkinase.hmm cosmid.dna}} compares a protein profile HMM to a DNA sequence \item \hbox{\tt{genewisedb protein.pep human.fa}} compares a single protein sequence to a database of DNA sequences \item \hbox{\tt{genewisedb -hmmer pkinase.hmm human.fa}} compares a single protein profile HMM to a database of DNA sequences \item \hbox{\tt{genewisedb -prodb protein.pep -dnas cosmid.dna}} compares a database of protein sequences to a single dna sequence \item \hbox{\tt{genewisedb -pfam Pfam -dnas cosmid.dna}} compares a database of protein profile HMMs to a single dna sequence \item \hbox{\tt{genewisedb -prodb protein.pep human.fa}} compares a database of protein sequences to a database dna sequences - beware, this will take a while! \item \hbox{\tt{genewisedb -pfam Pfam human.fa}} compares a database of protein profile HMMs to a database of single sequences - beware, this will take a while \end{itemize} The estwise (protein to est/cDNA comparisons) have precisely the same running modes. Listed for completeness below \begin{itemize} \item \hbox{\tt{estwise protein.pep singleest.fa}} compares a protein sequence to a DNA sequence (same as the example above) \item \hbox{\tt{estwise -hmmer pkinase.hmm singleest.fa}} compares a protein profile HMM to a DNA sequence \item \hbox{\tt{estwisedb protein.pep est.fa}} compares a single protein sequence to a database of DNA sequences \item \hbox{\tt{estwisedb -hmmer pkinase.hmm est.fa}} compares a single protein profile HMM to a database of DNA sequences \item \hbox{\tt{estwisedb -prodb protein.pep -dnas singleest.fa}} compares a database of protein sequences to a single dna sequence \item \hbox{\tt{estwisedb -pfam Pfam -dnas singleest.fa}} compares a database of protein profile HMMs to a single dna sequence \item \hbox{\tt{estwisedb -prodb protein.pep est.fa}} compares a database of protein sequences to a database dna sequences - beware, this will take a while! \item \hbox{\tt{estwisedb -pfam Pfam est.fa}} compares a database of protein profile HMMs to a database of single sequences - beware, this will take a while \end{itemize} \subsection{Common options to change} There are a number of common options that can be used. Options can be issued anywhere on the command line. \begin{description} \item[-help] help on options \item[-version] show version and build date (useful for bug reporting) \item[-quiet] remove update line on stderr and informational messages \item[-silent] suppress all messages to stderr \item[-report] \emph{number} for database searching, issue a report on stderr every \emph{number} of comparisons (useful to ensure it is actually running) \item[-trev] genewise and estwise - use the reverse strand of the DNA \item[-both] genewise and estwise - use both strands of the DNA \item[-u position] The start point in the DNA sequence for the comparison \item[-v position] The end point in the DNA sequence for the comparison \item[-init] [default/global/local/wing] (see section \ref{sec:start_end}) For protein sequences the default is to be local (like smith waterman). For protein profile HMMs, the default is read from the HMM - the HMM carries this information internally. The global mode is equivalent to to the ls building option (the default in the HMMer2 package). The local mode is equivalent to to the fs building option (-f) in the HMMer2 package. The wing model is local on the edges and global in the middle. \item[-gene file] change gene model parameters. Currently we have either human (human.gf) or worm (worm.gf) \item[-genes] Output option for genewise algorithms - show an easy to read gene structure report \item[-trans] Output option for genewise algorithms - provide an automatic translation of the predicted gene as a fasta format \item[-cdna] Output option for genewise algorithms - provide an automatic construction of the spliced dna sequence as a fasta format \item[-ace] Output option for genewise algorithms - provide an ACeDB subsequence model output \end{description} \subsection{Common gripes, Cookbook and FAQ} \subsubsection{It hasn't given me a complete gene prediction} The genewise algorithm does not attempt to predict an entire gene, from Met to STOP. It tries to predict regions which are justified with the protein homology and no more. This does mean you can be confident of the predictions that genewise makes \subsubsection{How can I get rid of the annoying messages on stderr?} Some people like them. use -quiet \subsubsection{It goes far too slow} Well... I have always had the philosophy that if it took you over a month to sequence a gene, then 4 hours in a computer is not an issue. However, in particular for times when people are using genewise simply to confirm that the a gene prediction is correct with respect to a protein sequence (sometimes the notional translation!) it is taking too long. In many cases you will know the rough region to compare the sequence to - if so use the -u and -v options to truncate your DNA at the correct points (the output will remain in the coordinates of the full length sequence). For database searching there is the option of using SMP boxes efficiently with the pthreads port. There are also a number of heurisitcs that use the BLAST program to provide the speed. These heuristics are found in the perl/scripts directory, called halfwise and blastwise and notes on how to use them are a later section (\ref{half_and_blast}). The scripts have extensive installation instructions, and I completely expect people to edit them for their system. There is functionality for providing a heurisitic bound to the space the algorithm explores in the alignment. This is done via the potential gene option in genewise. It is not well tested out. \subsubsection{I have a new cosmid. What do I do?} One thing to do is to use the halfwise script available in the perl/scripts package. Another is to use the blastwise script. \subsubsection{Can I modify or use the Wise2 source code?} Of course you can - it is Open Source code, licensed under the Gnu Public Licensed (GPL'd), like emacs or gcc. For more information on this License read the GNULICENSE file in the distribution. As well as using the source code, you can if you like contribute directly back into the Wise2 source code. Get in contact with me if you would like to do this. \subsubsection{Making a single gene prediction on the basis of a close homolog} This is perhaps the easiest use of genewise. The basic formulation is \begin{verbatim} %genewise protein.fasta dna.fasta \end{verbatim} To get out computer parsable formats of the gene prediction try -genes or -gff or -ace. To get out the protein translation in one go use -trans \subsubsection{Using non human/worm/fly genomic DNA} At the moment, genewise only has gene frequency files for human and worm sequences. The production of these files are based around somewhat annoying and non portable script. In any case, making a dataset requires alot of effort as it needs to be clean The consequence of all this is that the species that you are comparing against (eg, hamster) may not have a gene frequency (.gf) file. In which case you basically have two options \begin{itemize} \item Use a close species - ie, for hamster, use human or rat \item Use -splice flat -intron tied which switches the splice model to ``start at GT, finish at AG'' with no other information \end{itemize} \subsubsection{Working with non spliced (bacterial) genomic DNA} Use genewise with the -alg 333 or -alg 333L options. This has all the outputs of genewise but does not consider introns. The -gene option and -intron, -splice options are all pointless. The only options to worry about is the -subs and -indel for substitution and insertion and deletion errors respectively. \subsubsection{Working with ESTs} Use the estwise/estwisedb programs \subsubsection{Getting out the protein translation} You have three approaches for getting out protein translations \begin{itemize} \item -pep available on all programs, provides the translations moving over frameshifts and introns \item -trans available on genewise/genewisedb provides the translations across introns but breaks on frameshift errors. This means that the translations can be correctly placed on the genomic DNA provided \item -mul available only on estwisedb when a HMM is used, provides a protein multiple alignment of all the DNA hits derived against the HMM match \end{itemize} \subsubsection{Using Pfam} Pfam can be used with the genewisedb or the estwisedb program with the -pfam flag. Usually you want to also use the -dnas (single DNA sequence flag) as well. An example run would be \begin{verbatim} genewisedb -pfam Pfam -dnas myseq.fa \end{verbatim} If you have set up the HMMER package to work with Pfam using the enviroment variable HMMERDB, Wise2 will also pick that up as well. \subsubsection{Optimising alignment speed} Wise2 assummes you have a rather small amount of memory (20 MBytes). When it is making an alignment, if it cannot make the explicit matrix in that size (being length of query $\times$ length of target $\times$ state number) it has to move to linear memory (length of query $\times$ state number). The linear memory is much slower (it is the one that starts with ``Find start end points''). If you have more memory than 20 Mbytes, then it is really sensible to up the number, using the -kbyte option. For a machine with say 64Mbytes physical memory I would suggest putting an upper limit of 50Mbytes with -kbyte. This does assumme you are not using it for anything else. You can change the compile time default in basematrix.h if you can't be bothered to remember to change it every time \subsubsection{Optimising search speed} See sections \ref{genewise_large} and \ref{estwise_large} for use of these programs in large scale throughput environments. Make sure you have compiled with optimisation. If you are using the make all from the top level you have. If you are using gcc, make sure you are using -O2 optimisation, and probably crank it all the way up. If you have a large SMP box, you can compile with pthread support. The searches work on SGI/Compaq alpha/Suns. There are some issues about some architecture ports, which I need to expand somewhere in the docs, but first off, just try compiling with pthreads (\ref{compile_pthread}) and using pthreads in the search. For real, order-of-magnitude speed ups, you are going to have to use a heuristic stage before the actual database search - in other words, using BLAST. I dislike this, but it is fact of life, and there are two scripts in perl/scripts, halfwise and blastwise (\ref{half_and_blast}), which help you do this. Both scripts use Steve Chervitz excellent perl Blast parser, which is available in bioperl. (Make sure you have a 0.05 release or later of bioperl, as the Blast parser in the 0.05 release is much better). \begin{itemize} \item halfwise is for the Pfam search. You need to pick up the halfwise database (done for a specific release of Pfam) from the ftp site. \item blastwise is for post processing blast results. It uses the Wise2 perl port to do this, so you have to go make perl at the top level \end{itemize} halfwise is a pretty sensible, self contained script. blastwise I expect people to modify heavily to get to work as wished on their systems. Please read it, and add in your own heuristics (eg, figuring out start/end points). I am very interested in better heuristics in this area. \subsubsection{segmentation fault = bottle of champagne} You've found a bug? I am really keen to hear from you. I want to hear about the problems you've got. Each year I award my best tester with a prize. This year (1998/99) it will be a bottle of champagne. Send a mail to birney@sanger.ac.uk for your prize! \subsection{Using GeneWise in a large scale throughput manner} \label{genewise_large} If you are analysing genomic DNA in a large scale manner, you might wonder what is the best way to use genewise. Genewise is \emph{very CPU expensive} compared to other programs. Part of this is because I have concentrated much more on correctness of the algorithm, not its speed (it is probably about 2 fold slower than it could be optimally), but mainly this is because the algorithm is complicated and DNA sequence is generally very large. I do not believe that optimising genewise in the code will solve people's CPU problems. For these reasons, I do not advise the serious use of genewisedb as a single executable for comparing DNA sequence to either Pfam or protein databases. For these cases I suggest using the halfwise and blastwise scripts. See the section on Halfwise and Blastwise (\ref{half_and_blast} \begin{itemize} \item halfwise compares a DNA sequence to Pfam using a Blast speed up \item blastwise uses a Blastx result to provide the database search and provides sequence alignments ontop of that \end{itemize} Another option is to get in contact with Paracel, Compugen or TimeLogic, all of whom may be able to sell you specialised hardware. Paracel has successfully ported genewise to their hardware with only a few minor changes to the method. \subsection{Using EstWise in a large scale throughput manner} \label{estwise_large} Estwise in a large scale manner is a more troubling issue than genewise. Generally the DNA databases are as large, but the algorithm is smaller and often people are equally interested in sensitivity and alignment quality. Therefore it makes more sense to use estwise directly as the database search. Estwise is still pretty slow, so here is a check list of things to do \begin{itemize} \item Run estwise on a \emph{clustered} EST database, not raw reads \item Make sure you are using the 3:12 algorithm on estwise (-alg 312) for the database search. Try using the 3:12 quick (-alg 312Q). \item Use the pthread port if you have a large SGI/Sun/Dec multiprocessor \item For the final tuning, make sure you have switched on all the compiler options. egcs is a good thing to try. This will give you a 10-15% speed up at most \end{itemize} I am thinking about improvements to the estwise running time. I would very much like to collaborate with someone on estwise in terms of understanding its sensitivity and improving all aspects of the algorithm. Please get in contact with me. The hardware solutions from Compugen, Paracel and Time Logic are all very good in this area, and worth investigating if you have money to spend. \newpage \section{Installation} Installation is quite easy as long as you are au fait with standard UNIX utilities. You should ftp to ftp.sanger.ac.uk, log in as anonymous and move to pub/birney/wise2. You can then pick up the release - I would pick up the latest numbered in that directory. (NB, if you want to be working in the development release, go to the pub/birney/wise2/alpha directory, but be sure to read the html help at http://www.sanger.ac.uk/Software/Wise2/Programming). \subsection{Building the executables} The release is distributed as a gzipped, tar file. To unzip and untar in a single command you can type \begin{verbatim} %zcat wise2.1.12b.tar.gz | tar -xvf - \end{verbatim} This will untar into a directory called 'wise2.1.12b' (of course, your version of Wise2 might be different). Once you have made the tar file, it should build completely cleanly as long as you have an ANSI C compiler. If in doubt, just assumme that it is, but in particular sun users might want to use gcc (gnu cc) as the sun cc compiler installed by default is often non-ANSI. To change the cc compiler you only need to edit the line in the top level makefile called CC = cc to CC = gcc. To build the package type \begin{verbatim} %cd wise2.1.12b %make all %make bin \end{verbatim} The executable files will now be in wise2.1.12b/bin I am interested in all compiler errors, and consider most of them to be bugs (which means if you report them you could be on the champagne list!) \subsection{Environment set up} The Wise2 package needs to know where a number of files are (eg, the gene predicition statistics). These files are in the directory called wisecfg/. You will need to setenv WISECONFIGDIR to this directory (you can of course move the directory elsewhere, and set WISECONFIGDIR to it). \subsection{Building with thread support (for SMP machines)} \label{compile_pthread} To build with pthread support you must switch on some extra compile time options before you type make all. These are found at the top of the makefile in the top directory, and it is pretty clear from the makefile what to do. See the section \ref{running_pthread} for information on how to run pthreaded code. In some cases the pthreads do not schedule correctly, preventing multiple threads working on different processors at the same time. If you have this problem, trying compiling with -D HAS\_PTHREAD\_SETSCOPE on the CFLAGS line. The pthreaded code has been reported to be 97% efficient with 8 threads, and there have been reports of up to 100 multiple threads running fine. \subsection{Building Perl port} \label{perl_port} To build with Perl support you need to go \begin{verbatim} make perl \end{verbatim} at the top level. This should build everything correctly. The only problem is if you have a Solaris or *BSD box. If so you need to compile with -fpic or -fPIC depending on your compiler. This needs to go into the top level CFLAGS line. In addition, in the out-of-the box perl distribution for solaris they built it with a different compiler to the one it comes with (idiots!), so the perl generated makefile has the wrong -fpic option. You need to edit that by hand. \newpage \section{Concepts and conventions} The algorithms used in Wise2 have a strong theoretical justification, which is useful, though not necessary to understand. For example to understand what most of the options do in the gene model part of genewise you need to understand the algorithm. \subsection{Technical Approach} You can miss this section which describes some of the theoretical background of the work. The algorithms are based around a 'Bayesian' formalism that has been established in Bioinformatics by such people as David Haussler, Gary Churchill, Anders Krogh, Richard Durbin, Sean Eddy and Graeme Mitchinson, as well as many others. In this formalism there is assumed to be a generative model of the process that you are observing, which has probabilities to generate a number of different observations. Deciding whether this model fits a previously unseen piece of data or not is the first decision to make. Given that the data fits, a second question is what actual processes were the most likely to produce the observed data. Both these questions fit naturally into a Bayesian framework where the result is a posterior probability having seen the data. For people coming from a bioinformatics/biology background where the last paragraph may seem very confusing, it is only because this a different (and well established) field with their own terminology to describe the algorithms. In fact the methods a very close to standard techniques presented in bioinformatics. The generative models that we use are the models that are implied by the standard bioinformatics tools. For example, the Smith-Waterman algorithm implies a process of evolution with certain probabilities for seeing say an Leucine to Valine substitution and certain probabilities for creating and extending a insertion (gap). As you can see you can almost replace the word 'probability' with 'score' to return to the standard method, and mathematically it is almost that easy: the score is related to the log of the probability. Perhaps a better known example is the relationship between the old profile technology, as developped by Gribskov and Gibson along with others, and its probabilistic partner, profile Hidden Markov Models (profile HMMs). In terms of the actual algorithm these two methods are very similar: it is simply that the profile HMM has a strong probabilistic model underlying it, allowing well established techniques to be used in its generation. \subsection{Introduction to Models in Wise2} Wise2 contains a number of algorithms, each of which are based around one of two biological models. \begin{description} \item[genewise] comparison of a related protein to genomic DNA \item[estwise] comparison of a related protein to cDNA (or ESTs) \end{description} This models themselves are built up from two component models, one for how protein residues are matched, and one for the gene prediction process. For the model of protein residues I have taken the established models of profile HMMs. The model of splicing and translation we developed with an eye to biology. It has many of the features of the GenScan model [chris Burge]. The model of translation (for estwise) is simple. \subsection{Model} The main model to understand is the genewise model (called genewise 21:93 for reasons discussed below). It is this model which the other models are based on - for the estwise models, by removing the intron generating part of the models, and for the other genewise algorithms by making approximations to genewise21:93. A diagramatic representation of genewise21:93 is shown in Figure \ref{Figure:genewise21} \begin{figure} \begin{center} \leavevmode \epsfxsize 300pt \epsfbox{genewise21.eps} \newline \caption{GeneWise21:93 Algorithm. The dark circles represent states, and the arrows between them transitions. Black transitions are standard protein transitions, red transitions are frameshifting transitions and green transitions are intronic transitions. Introns are each built of three states, listed at the bottem of the figure} \label{Figure:genewise2193} \end{center} \end{figure} The central part of the model is the Match-Insert-Delete trio common to both profile HMMs (such as HMMER models) and the smith waterman model. This trio of states is one model 'position' in the profile HMMs, where each model position contains a Match, Insert and Delete states. This means to interpret the figure of the model in the way the profile HMM models are usually displayed, you have to imagine a series of these states concatonated together. I imagine the model growing as stack of pages out from the figure, each new page being a new position in the profile HMM. The first addition to the model are the frameshifting transitions, shown in with x4 boxes above them. These occur whenever there is a transition which produces a codon: in effect all transitions that terminate at either match or insert states. There are four frameshifting transitions in each Notice that there are frameshifting transitions from Delete to Match, which is equivalent to saying that a frameshift occurs on the codon just after a run of deletions in the model. It is these sorts of frameshifts that are not well modelled by other algorithms. The second addition involves the intron emitting states found in the green boxes. Each intron is modelled by having 5 regions, two of which are fixed length. The five regions are \begin{itemize} \item 5'SS The splice site consensus region at the 5' end of the intron. Fixed length \item The central part of the intron that constitutes the major part of the intron \item The polypyrimidine tract (a region of C/T bias upstream of the 3'SS) \item an optional joining region between the poly-py tract and the 3'SS \item 3'SS The splice site consensus region at the 3' end of the intron. Fixed length \end{itemize} Notice that there is no branch site, because we could not produce a good enough statistical model for it. This model can be modelled using 3 states, with the fixed length regions being accommodated using transitions which emitted the appropiate length of sequence. Each of the intron models must be duplicated 3 times to account for the 3 different phases of introns (each phase being a different placement of the intron relative to the codon), so we need to duplicated these 3 states at least 3 times. In addition, if this intron lies in an insert state, ie, the surrounding protein sequence in the exons are being produced by an insert state in the underlying protein profile HMM, so we have to maintain that information across the intron. This means that we need to duplicate the intron states 6 times in total: 3 times for the different phases and twice on top of that for the different protein states this intron could lie in. \subsubsection{Parameterisation of the model} The model presented above seems biological sensible, but how on earth are we going to parameterise it? Are we honestly going to let a user try to juggle the forty odd parameters inherent to this model? Clearly not. The approach we have taken to this is to provide set statistics derived from a maximum likelhood approach from known genes - this requires virtually no training - and then give switches to the user to turn on and off a variety of different parts of the algorithm. The model is parameterised as probabilities, but actually calculated in log space. If you look in the code you would find that there is alot of switching between the two spaces: these are provided by the functions Probability2Score and Score2Probability (notice that the 'Score' here is very specific to the Wise2 package - you can't put any old score into Score2Probability to get a probability out as it depends on how that Score was converted into Log space). \subsubsection{The protein model} For the emissions of the actually underlying amino acids when we have a profile HMM, we are lucky - we can take the probabilies defined in the HMMer2 models. This is completely natural and means I don't have to worry about deriving probabilities for the profile HMMs In the case where we have a protein sequence, I somehow have to get to a profile HMM type representation. Thankfully the smith waterman algorithm in terms of architecture is very close to a profile HMM, and so the only problem is mapping the usual scores used in the smith waterman algorithm to probabilites. This is quite hard to do correctly, but I've hacked it by knowing that the blosum62 matrix is given in half bits, in other words using a 2*log2 mapping from probability space to the give scores in the matrix. By reversing this process one can get pretty good emission probability for the amino acids. I now assumme that the gap penalities are \emph{as if} they were written in half bits. A certain amount of normalisation is required to make sure things add to one, and eh voila - one profile HMM from a single sequence. \subsubsection{Start End points} \label{sec:start_end} One interesting issue about the protein model is how the start end points work. For proteins it is obvious that for distant homology, it needs to be local - ie can start or finish anywhere in the sequence. For protein HMMs it is less clear. If a HMM really represents a single domain then global start end points are correct. However, many times local start end points are useful. The HMMer2 models internally carry whether this HMM is has global or local (or indeed any type) of start end policy. However, the genewise algorithm is quite dependent on the models being global to effectively predict introns in domains, when the looping algorithm (multiple copies of the domain) is present. This is because nearly always in a local HMM, an intron can be better modelled as the end of the domain half way through and the start of a new domain half way through, further down the sequence, thus not predicting the intron. To get clean intron prediction, one needs to go to global mode. However, using global mode forces the start and end point of the model to be really correct, and in some cases (in particular some Pfam models) this makes very incorrect results on the edges of the domain. To combat this another type of start end policy is introduced - wing. This has a local start mode for the first 15 model positions and end mode for the last 15 model positions, but global in the central part of the model. In the programs one can set four types of start end policy \begin{itemize} \item default local for protein, and the HMM default for HMMs \item local local \item global global \item wing local on the edges, global in the middle \end{itemize} \subsubsection{The gene model} For the emissions of the gene model we had to do more work. What we did was to make a database of known genes, with annotated gene structure. These genes then provided a raw set of counts for particular parts of the gene structure. It is these raw counts which are stored in the .gf files. (we store the raw counts because one might want to do something clever for deriving the probabilities of certain things using these counts. Counts are the basis for the probability derivations, not frequencies). The only issue here is what to do with the splice sites. We were well aware that the information in the splice sites is considerably more than just the simple position matrix. We chose to use a single branching (biased) decision tree, in which each branch either carried along the main trunk of the tree or ended in a leaf, each leaf representing a consensus build from A,T,G,C or N for any character. This decision tree could be easily constructed by chosing the most common consensus (where N is allowed where a position is better represented by N than any specific residue), and then removing that consensus from the list of observed consensi, and then repeating the process. This also gave us the same basis (counts) for each consensus used in the splice sites. One additional twist came about in the splice site development. The splice sites overlap between their consensi and the coding sequence region. These overlaps need to be treated correctly: the problem is that probabilistically we have two processes wanting to account for the same DNA bases. This was solved by assumming conditional independence between the two processes. A more formal mathematicall approach can be found in the documented called 'probappendix'. \subsubsection{The NULL model} The probability of the model has to compared to an alternative model (in fact to all alternative models which are possible) to allow proper Bayesian inference. This causes considerable difficulty in these algorithms because from a algorithmical point of view we would probably like to use an alternative model which is a single state, like the random model in profile-HMMs, where we can simply 'log-odd' the scored model, whereas from a biological point of view we probably want to use a full gene predicting alternative model. In addition we need to account for the fact that the protein HMM or protein homolog probably does not extend over all the gene sequence, nor in fact does the gene have to be the only gene in the DNA sequence. This means that there are very good splice sites/poly-pyrimidine tracts outside of the 'matched' alignment can severely de-rail the alignment. Basically we are in trouble with the random model parts of this problem. The solutions is different in the genewise21:93 compared to the genewise 6:23 algorithms. Genewise 6:23 is shown in figure \ref{Figure:genewise623} \begin{figure} \begin{center} \leavevmode \epsfxsize 300pt \epsfbox{genewise6.eps} \newline \caption{GeneWise6:23} \label{Figure:genewise623} \end{center} \end{figure} \begin{itemize} \item In 6:23 we force the external match portions of the homology model to be identical to the alternative model, thus cancelling each other out. This is a pretty gross approximation and is sort of equivalent to the intron tie'ing. It makes things algorithmically easier... However this means a) 6:23 is nowhere near a probabilistic model and b) you really have to used a tied intron model in 6:23 otherwise very bad edge effects (final introns being ridiculously long) occur. \item In 21:93 we have a full probabilistic model on each side of the homology segment. This is not reported in the -pretty output but you can see it in the -alb output if you like. Do not trust the gene model outside of the homology segment however. By having these external gene model parts we can use all the gene model features safe in the knowledge that if the homology segments do not justify the match then the external part of the model will soak up the additional intron/py-tract/splice site biases. \end{itemize} However this still does not solve the problem about what to compare it to. There are two approaches to the comparison \begin{description} \item[flat] The homology model is scored against a single state 0.25 emission model. This is effectively 'how likely is this DNA segement has any genes some with this homologous protein/HMM in it' for 21:93. It is, unsurprisingly, a massive 'yes' for nearly all biological DNA, and though a valid number in terms in bayesian inference pretty biologically uninteresing. There is also no decent interpretation of partial scores (ie, scores per domain). \item[syn] For synchronous model pretends that there is an alternative model of a complete gene which is dragged into the coding part of the gene when the homology model is in the coding part. This is not probabilistically valid, but gives better results and interpretable scores for partial regions, ie domain by domain. (in fact, very similar scores to protein sequences). However I'm worried about what I am doing It would be much better to get some mathematically justification for this. \end{description} \subsection{Algorithms} \label{sec:alg} The algorithms are then based around this central model, but have a variety of features removed from it progressively, either due to biological constraints (bacterial sequences have no introns, so there is no need to model them) or to speed up the the algorithm. Algorithms are named in two parts, \emph{descriptive-word} \emph{state-number:transition-number}. The descriptive word indicates the \emph{biological} model. At the moment there are 2 such biological models in the package \begin{description} \item[genewise] comparisons of protein information to genomic DNA \item[estwise] comparisons of protein information to cDNA/bacterial DNA (no introns) \end{description} There are many other models being worked on in development \begin{description} \item[sywise] comparisons of genomic DNA to genomic DNA \item[parawise] comparions of cDNA to cDNA \end{description} The \emph{state-number:transition-number} is the number of states in the model followed by the number of transitions. GeneWise 21:93 is the most complicated model, with 21 states and 93 transitions. The number of states is directly proportional to the memory usage of the program. The number of transitions is roughly proportional to the CPU time of the algorithm. For comparison the standard smithwaterman algorithm is a 3:7 algorithm (3 states, 7 transitions). These numbers are per compared residue - so as genomic DNA is some 1,000 fold longer than protein sequences on average, there is an additional massive CPU load. Finally the algorithms can be looping or not. A Looping algorithm is one in which the protein information can be repeated in the DNA target sequence. This could either be due to mutliple copies of the gene in the DNA sequence or multiple copies of a domain in a single gene. Looping algorithms are given a 'L' tag. By default, when you use profile-HMMs you use a looping model For the genewise family the following algorithms are available. \begin{description} \item[genewise 21:93] The largest genewise algorithm which also contains a complex flanking model to prevent inappropiate gene predictions \item[genewise 21:93L] The same algorithm with a looping mode. This allows a protein HMM (nearly always a HMM) to match multiple times a DNA sequence. This could be due to multiple domains in a single gene or multiple genes in a DNA sequence with the domain. The algorithm doesn't distinguish between these possibilities. \item[genewise 6:23] This is a smaller, (and so faster) algorithm. The approximations made compared to genewise 21:93 are that there is no poly-pyrimidine tract in the intron, and that introns from match states are not distinct from introns in insert states. A side effect of these approximations is that 6:23 is much more robust with respect to unmasked repeats and strange composition effects found in the DNA sequences. \item[genewise 6:23L] The same algorithm as 6:23 but in looping mode \item[genewise 4:21] The smallest algorithm in the genewise family, with an additional approximation of not distinguishing between introns of different phases. This has been compiled for short protein sequences only - effectively only profile-HMMs. \end{description} For the estwise family the following algorithms are available \begin{description} \item[estwise 3:33] The largest estwise algorithm, modelling potential insertion or deletions throughout the alignment of the protein information to the DNA sequence. \item[estwise 3:33L] The same algorithm but in looping mode. \item[estwise 3:12] A slimmer algorithm designed for faster db searching. The algorithm models enough insertions or deletions of DNA bases to 'ride through' a indel region without too much penalty, even if it doesn't model the most correct one. \end{description} \subsection{Scores} The scoring system for the algorithms, as eluded to earlier is a Bayesian score. This score is related to the probability that model provided in the algorithm exists in the sequence (often called the posterior). Rather than expressing this probability directly I report a log-odds ratio of the likelhoods of the model compared to a random model of DNA sequence. This ratio (often called \emph{bits score} because the log is base 2) should be such that a score of 0 means that the two alternatives \emph{it has this homology} and \emph{it is a random DNA sequence} are equally likely. However there are two features of the scoring scheme that are not worked into the score that means that some extra calculations are required \begin{itemize} \item The score is reported as a likelhood of the models, and to convert this to a posterior probability you need to factor in the ratio of the prior probabilities for a match. Because you expect a far greater number of sequences to be random than not, this probability of your prior knowledge needs to be worked in. Offhand sensible priors would in the order of probability that there is a match being roughly proportional to the database size. \item The posterior probability should not merely be in favour of the homology model over the random model but also be confident in it. In other words you would want probabilities in the 0.95 or 0.99 range before being confident that this match was correct. \end{itemize} These two features mean that the reported bits score needs to be above some threshold which combines the effect of the prior probabilities and the need to have confidence in the posterior probability. In this field people do not tend to work the threshold out rigorously using the above technique, as in fact, deficiencies in the model mean that you end up choosing some arbitary number for a cutoff. In my experience, the following things hold true: bit scores above 35 nearly always mean that there is something there, bit scores between 25-35 generally are true, and bit scores between 18-25 in some families are true but in other families definitely noise. I don't trust anything with a bit score less than 15 bits for these DNA based searches. For protein-HMM to protein there are a number of cases where very negative bit scores are still 'real' (this is best shown by a classical statistical method, usually given as evalues, which is available from the HMMer2 package), but this doesn't seem to occur in the DNA searches. I have been thinking about using a classical statistic method on top of the bit score, assumming the distribution is an extreme value distribution (EVD), but for DNA it becomes difficult to know what to do with the problem of different lengths of DNA. As these can be wildly different, it is hard to know precisely how to handle it. Currently a single HMM compared to a DNA database can produce evalues using Sean Eddy's EVD fitting code but, I am not completely confident that I am doing the correct thing. Please use it, but keep in mind that it is an experimental feature. \newpage \section{Halfwise and Blastwise} \label{half_and_blast} The use of genewise in large scale analysis is beyond most people's CPU abilities. To counter this I have written two scripts which allow people to use genewise more sensibly. \begin{itemize} \item Halfwise - a Perl script that compares a DNA sequence to Pfam sensibly, using BLAST to speed up the process. \item Blastwise - a Perl script that compares a DNA sequence to a protein database, using BLASTX and then calls genewise on a carefully selected set of proteins \end{itemize} To run halfwise you will need \begin{itemize} \item The Wise2 package, compiled to provide the genewisedb executable at least \item One of the blastx type programs, either blast 1 series, blast 2 series from ncbi or wublast from warren gish (bioperl automatically detects the different flavours of blast and adjusts). \item The bioperl distribution, preferably the 0.05 series \item The halfwise protein database, found at ftp://ftp.sanger.ac.uk/pub/birney/wise2/halfwise \item The halfwise Pfam database, at the same ftp site \item The HMMER package, version 2.1 series \end{itemize} The halfwise database is made from the Pfam FULL alignments, made non redundant to 75%. This gives a good coverage of the protein sequences represented by Pfam whilst being quite a small database. To install halfwise you need to \begin{itemize} \item place the halfwise protein database in the directory pointed by BLASTDB and either pressdb or setdb depending on which version of blast you are going to use. (If you don't have the BLASTDB directory set up, make a directory called blastdb and set the environment variable BLASTDB to point to that) \item install bioperl, best by following the instructions in the README \item install Wise2 \item install the latest HMMER \item place the HMM library in BLASTDB and run hmmindex (from the HMMER package) on it \item edit the information at the top of the halfwise.pl to point to the correct executables, if need be \end{itemize} To run halfwise go \begin{verbatim} halfwise dna.seq > dna.seq.hlf \end{verbatim} halfwise by itself gives you help about it. To run blastwise you will need \begin{itemize} \item a blastable protein database \item one of the blastx type programs, as above \item The Wise2 package, having made the perl port. This is done by going ``make perl'' in the root directory \item Bioperl version 0.05 or above \item a way of fetching fasta formatted sequences from teh protein database, eg SRS \end{itemize} Install bioperl and blast as before, install the Wise2 perl port. Edit the blastwise.pl script, making sure you change protein database and the GETZ line lower down to represent the way of getting sequences. To run blastwise go \begin{verbatim} blastwise.pl dna.seq > dna.seq.blw \end{verbatim} The blastwise script is designed to be adjusted to fit your site. There are a number of us world wide concentrating on extending and improving blastwise. Please get in touch if you want to help. \section{Principle Programs} The main programs are genewise, genewisedb, estwise, estwisedb. These all have basically the same running mode \begin{verbatim} %genewise protein-file dna-file \end{verbatim} A number of options are common to these programs from the point of view of how they run \begin{description} \item[-help] verbose help of all options \item[-version] show version and compile info \item[-silent] No messages on stderr, whether reports or warnings \item[-quiet] No reports or information messages on stderr \item[-erroroffstd] No warning messages to stderr, but reports are still issued \item[-errorlog] [file] Log warning messages to file (useful for sending to me) \end{description} You will probably want to read the \ref{sec:commonmode} common modes of usage section as well \subsection{genewise} Genewise compares a protein sequence or a protein profile HMM to a dna sequence \subsubsection{genewise - options: dna/protein} \begin{description} \item[-u] start position in dna \item[-v] end position in dna \item[-trev] Compare on the reverse strand \item[-tfor] (default) Compare on the forward strand \item[-both] Both strands \item[-tabs] Report positions as absolute to truncated/reverse sequence \item[-s] start position in protein - has no meaning for HMMs \item[-t] end position in protein - has no meaning for HMMs \item[-gap] [no] default [12] gap penalty to use for protein comparisons. This is used to estimate a probability per gap \item[-ext] [no] default [2] extension penalty to use for protein comparisons. This is used to estimate a probability for an extension of a gap \item[-matrix] default [blosum62.bla] Comparison matrix. Must be in half-bit units (blosum62 is in half bits). This is used to estimate a probability of amino acid comparisons \item[-hmmer] Protein file is HMMer 2 HMM \item[-hname] Use this as the name of the HMM. \item[-init] [default/global/local/wing] (see section \ref{sec:start_end}) For protein sequences the default is to be local (like smith waterman). For protein profile HMMs, the default is read from the HMM - the HMM carries this information internally. The global mode is equivalent to to the ls building option (the default in the HMMer2 package). The local mode is equivalent to to the fs building option (-f) in the HMMer2 package. The wing model is local on the edges and global in the middle. \end{description} \subsubsection{genewise - options: gene model} \begin{description} \item[-codon] [codon.table] Codon file. The default is for the universal code, but you can supply your own \item[-gene] [human.gf] Gene parameter file. Provide statistics for different gene models. Current human.gf and worm.gf are provided. The statistics are basically too complicated to explain here. \item[-subs] [1e-05] Substitution error rate, ie the assummed probability of base substitutions in the sequencing reaction/assembly that provided the DNA sequence. The substituion error is what dominates the penalty for stop codons - a higher error rate implies a smaller penalty for stop codons \item[-indel] [1e-05] Insertion/deletion error rate, ie the assummed probability of indel events in the sequencing reaction/assembly that provided the DNA sequence. The indel rate is what provides the penalty for frameshift errors. A higher error rate implies a smaller penalty for indels. \item[-cfreq] [model/flat] Using codon bias or not? [default flat] - a reasonably pointless option now, as it only applies when using -syn flat. If codon bias is modelled, then common codons score more than uncommons one for the same amino acid. \item[-splice] [model/flat] Using splice model or GT/AG? [default model] - use the full blown model for splice sites, or a simplistic GT/AG. Generally if you are using a DNA sequence which is from human or worm, then leave this on. If you are using a very different (eg plant) species, switch it off. \item[-intron] [model/tied] Use tied model for introns [default tied] - whether intron base distribution effects the parse. Because varying GC content and/or repeats can seriously drag the algorithm away from correct parses when intron base distribution is used, this is usually switched off. \item[-null] [syn/flat] Random Model as synchronous or flat [default syn] - whether to use a null model which is a simple base distribution (called flat), or imagine that the viterbi path is being compared to a gene based null model that is making all the same gene exon/intron boundaries (synchronous). The latter is basically a hack which demphaises the gene prediction machinery and tries to trust the homology machinery. (not ideal!) \item[-pg] [file] Potential Gene file (heurestic for speeding alignments). The potential gene file should look like \begin{verbatim} pgene # stands for potential gene ptrans # stands for potential transcript pexon pexon ... endptrans endpgene \end{verbatim} When this file is read in, it provides a series of start/end in dna and protein sequences around which is drawn an envelope of possibly alignment area. The alignment is then calculated only in this area This feature has not been well tested yet. any potential bugs reported in are very useful. \item[-alg] [623/623L/2193/2193L/6LITE] Algorithm used [default 623/623L] You should read the section on algorithms (\ref{sec:alg}). Basically 623 and 623L are cheaper computationally and more robust with respect to repeats etc. 2193 and 2193L are much more expensive, more sensitive to changes in parameters but potentially more accurate. \item[-kbyte] [ 2000] Max number of kilobytes used in main calculation. Indicates how much memory can be used for the dynamic programming calculation. \end{description} \subsubsection{genewise - options: output} All output options can be used at the same time. They are separated by the value to -divide option \begin{description} \item[-pretty] show pretty ascii output, as see in Section 2 \item[-pseudo] For genes with frameshifts, mark them as pseudo genes \item[-genes] show gene structure - as \begin{verbatim} Gene 1 Gene 1386 3963 Exon 1386 1493 Exon 1789 1935 Exon 2084 2294 Exon 2388 2480 Exon 2794 2868 Exon 3073 3228 Exon 3806 3963 // \end{verbatim} \item[-para] show parameters \item[-sum] show summary output. Shows output as \begin{verbatim} Bits Query start end Target start end idels introns 230.57 roa1_drome 26 347 HSHNRNPA 1386 3963 0 6 \end{verbatim} This is useful for parsing, but probably if you want to do something like that you want to get hold of the API directly. \item[-cdna] show cDNA Show a fasta format of the predicted cDNA sequence \item[-trans] show protein translation Show a fasta format of the predicted protein sequence. Breaks on frameshifts \item[-pep] show predicted peptide. Shows predicted peptide, including frameshifts, which are X's in the proteins \item[-ace] ace file gene structure - ACeDB subsequence model \begin{verbatim} Sequence HSHNRNPA subsequence HSHNRNPA.1 1386 3963 Sequence HSHNRNPA.1 CDS CDS_predicted_by genewise 0.00 source_Exons 1 108 source_Exons 404 550 source_Exons 699 909 source_Exons 1003 1095 source_Exons 1409 1483 source_Exons 1688 1843 source_Exons 2421 257 \end{verbatim} \item[-gff] Gene Feature Format file - useful for programs which also support GFF \begin{verbatim} HSHNRNPA GeneWise cds_exon 1386 1494 0.00 + 0 HSHNRNPA GeneWise cds_exon 1789 1936 0.00 + 0 HSHNRNPA GeneWise cds_exon 2084 2295 0.00 + 0 \end{verbatim} \item[-gener] raw gene structure - a debugging output \item[-alb] show logical AlnBlock alignment - a debugging output \item[-pal] show raw matrix alignment - a debugging output \item[-block] [50] Length of main block in pretty output \item[-divide] [//] divide string for multiple outputs \end{description} \subsection{genewisedb} genewisedb is the database searching version of genewise. It takes a database of proteins and compares it to a database of dna sequences \subsubsection{genewisedb - search modes} \begin{description} \item[-protein] [default] single protein. Protein is a single protein sequence in fasta format \item[-prodb] protein fasta format db. Protein is a database of protein sequences in fasta format \item[-pfam] pfam hmm library. Protein is a database of HMMer2 models as a single file \item[-pfam2] pfam old style model directory (2.1). Protein is a directory of HMMs with a file called HMMs in it indicating which HMMs there. This is how Pfam databases 2.1 and lower were distributed \item[-hmmer] single hmmer HMM (version 2 compatible). Protein is a single HMM \item[-dnadb] [default] dna fasta database. The DNA sequence is a fasta format file with multiple sequences \item[-dnas] a single dna fasta sequence. The DNA sequence is a single sequence in fasta format \end{description} \subsubsection{genewisedb - protein comparison options} \begin{description} \item[-gap] [ 12] gap penalty - see genewise option \item[-ext] [ 2] extension penalty - see genewise option \item[-matrix] [blosum62.bla] Comparison matrix - see genewise option \item[-hname] For single hmms, use this as the name, not filename \end{description} \subsubsection{genewisedb - gene model options} Many of these options are identical to the genewise options listed above \begin{description} \item[-init] [default/global/local/wing] (see section \ref{sec:start_end}) For protein sequences the default is to be local (like smith waterman). For protein profile HMMs, the default is read from the HMM - the HMM carries this information internally. The global mode is equivalent to to the ls building option (the default in the HMMer2 package). The local mode is equivalent to to the fs building option (-f) in the HMMer2 package. The wing model is local on the edges and global in the middle. \item[-codon] [codon.table] Codon file -see genewise option \item[-gene] [human.gf] Gene parameter file - see genewise option \item[-subs] [1e-05] Substitution error rate - see genewise option \item[-indel] [1e-05] Insertion/deletion error rate - see genewise option \item[-cfreq] [model/flat] Using codon bias or not? [default flat] - see genewise option \item[-splice] [model/flat] Using splice model or GT/AG? [default model] - see genewise option \item[-intron] [model/tied] Use tied model for introns [default tied] - see genewise option \item[-null] [syn/flat] Random Model as synchronous or flat [default syn] - see genewise option \item[-alg] [421/623/2193/] Algorithm used for searching [default 623] The is the algorithm to use for the database search part of the process. 421 is the cheapest algorithm but can only be used with HMMs or small proteins as it has been compiled for a limited size of query. Looping algorithms (623L and 2193L) are not permitted as it is hard to interpret the results \item[-aalg] [623/623L/2193/2193L] Algorithm used for alignment [default 623/623L] This is the algorithm used for the alignment of the matches. The default for proteins is 623, whereas for HMMs it is the looping model 623L. \item[-kbyte] [ 2000] Max number of kilobytes used in alignments calculation. Maximum amount of memory allowed in the alignment process. \item[-cut] [20.00] Bits cutoff for reporting in search algorithm. Comparisons scoring greater than this cutoff are aligned. \item[-ecut] [n/a] Evalue cutoff only for searches which can calculate evalues \item[-aln] [50] Max number of alignments (even if above cut). A cutoff for the number of alignments, whatever their bits score. \item[-nohis] Don't show histogram on single protein/hmm vs DNA search. On a single protein (or hmm) vs DNA database search an on-the-fly evalue score is calculated. This disables the production of a histogram \item[-report] [0] Issue a report every x comparisons (default 0 comparisons). Mainly for debugging \end{description} \subsubsection{genewisedb output - for each comparison} For each alignment made by genewisedb you can output it as a number of different options \begin{description} \item[-pretty] show pretty ascii output, as in genewise \item[-pseudo] For genes with frameshifts, mark them as pseudo genes \item[-genes] show gene structure, as in genewise \item[-para] show parameters, as in genewise \item[-sum] show summary output, as in genewise \item[-cdna] show cDNA, as in genewise \item[-trans] show protein translation, as in genewise \item[-ace] ace file gene structure, as in genewise \item[-gff] Gene Feature Format file, as in genewise \item[-gener] raw gene structure, as in genewise \item[-alb] show logical AlnBlock alignment, as in genewise \item[-pal] show raw matrix alignment, as in genewise \item[-block] [50] Length of main block in pretty output, as in genewise \item[-divide] [//] divide string for multiple outputs, as in genewise \end{description} \subsubsection{genewisedb output - complete analysis} Each alignment produces a notional gene prediction. At the end of the output, these gene predictions can be displayed together. This only works for -pfam or -prodb and -dnas options, ie a database of protein information vs a single dna sequence In the future it is hoped that additional options (such as merging consistent gene predictions) will operate before these outptus are made \begin{description} \item[-ctrans] provide all translations \item[-ccdna] provide all cdna \item[-cgene] provide all gene structures \item[-cace] provide all gene structures in ace format \end{description} \subsection{estwise} Estwise runs very much like genewise with basically a subset of options. For completeness they are all listed below \subsubsection{estwise - options: dna/protein} \begin{description} \item[-u] start position in dna \item[-v] end position in dna \item[-trev] reverse complement dna \item[-tfor] use forward strands only \item[-both] [default] do both strands \item[-tabs] Positions reported as absolute to DNA \item[-s] start position in protein \item[-t] end position in protein \item[-gap] [ 12] gap penalty \item[-ext] [ 2] extension penalty \item[-matrix] [blosum62.bla] Comparison matrix \item[-hmmer] Protein file is HMMer 1.x file \item[-hname] Name of HMM rather than using the filename \end{description} \subsubsection{estwise - options: model} \begin{description} \item[-init] [default/global/local/wing] (see section \ref{sec:start_end}) For protein sequences the default is to be local (like smith waterman). For protein profile HMMs, the default is read from the HMM - the HMM carries this information internally. The global mode is equivalent to to the ls building option (the default in the HMMer2 package). The local mode is equivalent to to the fs building option (-f) in the HMMer2 package. The wing model is local on the edges and global in the middle. \item[-codon] [codon.table] Codon file. The default is for the universal code, but you can supply your own \item[-subs] [0.01] Substitution error rate, ie the assummed probability of base substitutions in the sequencing reaction/assembly that provided the DNA sequence. The substituion error is what dominates the penalty for stop codons - a higher error rate implies a smaller penalty for stop codons \item[-indel] [0.01] Insertion/deletion error rate, ie the assummed probability of indel events in the sequencing reaction/assembly that provided the DNA sequence. The indel rate is what provides the penalty for frameshift errors. A higher error rate implies a smaller penalty for indels. \item[-null] [syn/flat] Random Model as synchronous or flat [default syn] whether to use a null model which is a simple base distribution (called flat), or imagine that the viterbi path is being compared to a gene based null model that is making all the same gene exon/intron boundaries (synchronous). The latter is basically a hack which demphaises the placement of frameshifts and tries to trust the homology machinery. (not ideal!) \item[-alg] [333,333L,333F] Algorithm used. 333 is the normal algorithm. 333L is the looping algorithm \item[-kbyte] [ 2000] Max number of kilobytes used in main calculation \item[-pretty] show pretty ascii output as in genewise \item[-para] show parameters \item[-sum] show summary information as in genewise \item[-alb] show logical AlnBlock alignment, debugging output \item[-pal] show raw matrix alignment, debugging output \item[-block] [50] Length of main block in pretty output - the length of the main text in the pretty output \item[-divide] [//] divide string for multiple outputs, the string used to separate multiple outputs \end{description} \subsection{estwisedb} estwisedb is the database searching version of the estwise program. Like estwise, it has the same sort of running modes as genewisedb, but with more limited options. \subsubsection{estwisedb - options: running modes} \begin{description} \item[-protein] [default] single protein \item[-prodb] protein fasta format db \item[-pfam] pfam hmm library \item[-pfam2] pfam style model directory (2.1) \item[-hmmer] single hmmer 1.x HMM \item[-dnadb] [default] dna fasta database \item[-dnas] a single dna fasta sequence \end{description} \subsubsection{estwisedb - options: model} \begin{description} \item[-gap] [ 12] gap penalty \item[-ext] [ 2] extension penalty \item[-matrix] [blosum62.bla] Comparison matrix \item[-hname] For single hmms, use this as the name, not filename \item[-codon] [codon.table] Codon file \item[-subs] [0.01] Substitution error rate \item[-indel] [0.01] Insertion/deletion error rate \item[-null] [syn/flat] Random Model as synchronous or flat [default syn] \item[-alg] [333/312/312Q] Algorithm used for searching [default 312] \item[-aalg] [333/333L] Algorithm used for alignment [default 623] \item[-kbyte] [ 2000] Max number of kilobytes used in alignments calculation \item[-cut] [20.00] Bits cutoff for reporting in search algorithm \item[-ecut] [n/a] Evalue cutoff only for searches which can calculate evalues \item[-aln] [50] Max number of alignments (even if above cut) \item[-nohis] Don't show histogram on single protein/hmm vs DNA search \item[-report] [0] Issue a report every x comparisons (default 0 comparisons) \end{description} \subsubsection{estwisedb - options: output} \begin{description} \item[-pretty] show pretty ascii output \item[-para] show parameters \item[-sum] show summary output \item[-alb] show logical AlnBlock alignment \item[-pal] show raw matrix alignment \item[-mul] produce complete protein multiple alignment from a HMM to DNA db search as a mul format M/A. \item[-pep] show predicted peptide. Shows predicted peptide, including frameshifts, which are X's in the proteins \item[-block] [50] Length of main block in pretty output \item[-divide] [//] divide string for multiple outputs \item[-help] help \item[-version] show version and compile info \item[-silent] No messages on stderr \item[-quiet] No report on stderr \item[-erroroffstd] No warning messages to stderr \item[-errorlog] [file] Log warning messages to file \end{description} \subsection{Running with pthreads} \label{running_pthread} The two database searching programs, genewisedb and estwisedb can be run with pthread support on SMP boxes. To do so you need to compile the source code with pthread support (it is very easy, see section \ref{compile_pthread}). Then the programs need to be run with the additional option {\tt -pthread}. On most machines the executable will pick up the number of available processors automatically and run that number of threads. If you want to override this use the {\tt -pthr\_no} option. \newpage \section{Other Programs} There are other programs in the wise2 package which are sometimes pretty well worked out (eg promoterwise) and sometimes just a little standard program (eg, psw). \subsection{promoterwise} promoterwise is a sort of next generation DBA (see next section). It is designed for comparisons between two promoter sequences or realistically any two orthologous regulatory regions (or homologous for that matter, but in theory it should work better for orthologous regulatory regions, depending on how much active change you expect paralogous regulatory regions to have). Promoterwise reports alignments between these two sequences assumming that alignments cannot overlap in both sequences, but *not* assumming that the alignments have to be co linear or on the same strand. Promoterwise works by taking the two sequences and then finds all common exact 7mers between them, in both the forward and reverse strands. These are then merged such that close HSPs (whoes centers are within the window size of each other) are considered one region. These regions then have a local version of the DBA algorithm run over them, which has a model of DNA similarity of small regions of similarity, potentially with small gaps separated by large pieces of unknown DNA. The resulting set of alignments are then sorted by score, and a simple greedy algorithm is used to discard ``bad'' subsequent alignments. By default this is to discard alignments which overlap on the query coordinate with alignments of a higher score (this can be changed). The alignments are then outputted with bits score. In my hands I think a bit score of over 20bits looks good. Of course there are many options to change here. \subsubsection{promoterwise - options} \begin{description} \item[-s] query start position restriction \item[-t] query end position restriction \item[-u] target start position restriction \item[-v] target end position restriction \item[-lhwindow] sequence window given to alignment, default 50 \item[-lhseed] seed score cutoff in bits, defualt 10.0 \item[-lhaln] aln score cutoff, default 8.0 bits \item[-lhscore] sort final list by score (default by position) \item[-lhreject] [none/query/both] - overlap rejection criteria in greedy assembly [query] \item[-lhmax] maximum number of processed hits - default 20000 \item[-hitoutput] [pseudoblast/xml/tab] pseudoblast by default \item[-hithelp] more detailed help on hitlist formats \item[-dymem] memory style [default/linear/explicit] \item[-kbyte] memory amount to use [4000] \item[-\[no\]dycache] implicitly cache dy matrix usage (default yes) \item[-dydebug] drop into dynamite dp matrix debugger \item[-paldebug] print PackAln after debugger run if used \item[-help] show help options \item[-version] show version and compile info \item[-silent] No messages on stderr \item[-quiet] No report on stderr \item[-erroroffstd] No warning messages to stderr \item[-errorlog] [file] Log warning messages to file \end{description} \subsection{dba - Dna Block Aligner} \label{sec:dba} dba - standing for Dna Block Aligner, was developped by Niclas Jareborg, Richard Durbin and Ewan Birney for characterising shared regulatory regions of genomic DNA, either in upstream regions or introns of genes The idea was that in these regions there would a series of shared motifs, perhaps with one or two insertions or deletions but between motifs there would be any length of sequence. The subsquent model was a 3 state model which was log-odd'd ratio to a null model of their being no examples of a motif in the two sequences. \subsubsection{dba - options} \begin{description} \item[-match] [0.8] match probability \item[-gap] [0.05] gap probability \item[-blockopen] [0.01] block open probability \item[-umatch] [0.99] unmatched gap probability \item[-nomatchn] do not match N to any base \item[-align] show alignment \item[-params] print parameters \item[-help] print this message \end{description} \subsection{psw - Protein Smith-Waterman and other comparisons} \label{sec:psw} psw is a short and sweet program for calculating smith waterman alginments quickly. It was mainly written as C driver to test the underlying code which is more useful in things like the Perl port. More recently I added in the generalised gap penalty model of Stephen Altschul, that is known as the \emph{abc} model in Wise2. The abc model is detailed in Proteins 1998 Jul 1, 32 pages 88-96. \subsubsection{psw - options} \begin{description} \item[-g] gap penalty (default 12) - gap penalty used for smith waterman \item[-e] ext penatly (default 2) - ext penalty used for smith waterman \item[-m] comp matrix (default blosum62.bla) - comparison matrix used for both smith waterman and the abc model \item[-abc] use the abc model: use Stephen Altschul's 'generalised gap penalty' model (called the abc model in Wise2) \item[-a] a penalty for above (default 120) gap opening penalty in the abc model \item[-b] b penalty for above (default 10) gap extension penalty in the abc model \item[-c] c penalty for above (default 3) unmatched 'gap' region penalty in the abc model \item[-r] show raw output - raw matrix output \item[-l] show label output - label based output \item[-f] show fancy output - pretty output \end{description} \subsection{pswdb} pswdb - protein smith waterman database searching was written by Richard Copley using the underlying Wise2 libraries \subsubsection{psw - options} \begin{description} \item[-g] gap penalty (default 12) - gap penalty used for smith waterman \item[-e] ext penatly (default 2) - ext penalty used for smith waterman \item[-m] comp matrix (default blosum62.bla) - comparison matrix used for both smith waterman and the abc model \item[-abc] use the abc model: use Stephen Altschul's 'generalised gap penalty' model (called the abc model in Wise2) \item[-a] a penalty for above (default 120) gap opening penalty in the abc model \item[-b] b penalty for above (default 10) gap extension penalty in the abc model \item[-c] c penalty for above (default 3) unmatched 'gap' region penalty in the abc model \item[-max\_desc] Maximum number of description lines \item[-max\_aln] Maximum number of alignments \item[-ids] in alignments, show sequence names, not probe/target \item[-r] show raw output - raw matrix output \item[-l] show label output - label based output \item[-f] show fancy output - pretty output \end{description} \section{API} There used to be a direct Perl binding API. No longer. Frankly why I thought this was a good idea is now beyond me (the excitment of youth. The thrill of binding C directly to Perl. The head thumping complexity of XS). Wise2 programs are best run on the command line or shell'd out from scripts and then parsed in. \end{document} wise-2.4.1/docs/wise3arch.tex0000644000175000001440000001515107313404521015415 0ustar philippusers\documentstyle{article} \begin{document} \newcommand{\programtext}[1]{{\tt #1}} \title{Wise3 Open Architecture} \author{Ewan Birney, Guy Slater Sanger Centre\\ Wellcome Trust Genome Campus\\ Hinxton, Cambridge CB10 1SA,\\ England.\\ Email: birney@sanger.ac.uk,gslater@hgmp.mrc.ac.uk} \maketitle \newpage \tableofcontents \newpage \section{Introduction} The aim of this paper is to lay out some architecture goals for the next generation of the Wise package, Wise3. In addition we would like to lay out some of the changes to the software of Wise. The architecture is designed to be open and provide additional code to work seemlessly with the Wise package. There are two main groups of people this open architecture is aimed at. FIXME: the document should be more focused at general wise3 issues. \begin{itemize} \item Large sites with databases which are not kept in simple fasta databases. \item Hardware manufacturers, including specialised hardware, who would like to improve on the speed or sensitivity aspects of the database search. \end{itemize} The aim is also to encourage people to work on a consistent framework for using genewise and genewise type algorithms sensibly by encouraging people to conform to standards whenever it is sensible. The main goal is to prevent the annoying habit of hardware manufactures being asked to ``implement genewise'' without a clear definition of what that means, and in addition, being forced not merely to implement genewise, but also the entire supporting framework, such as alignments and post processing. This is a huge additional strain on the hardware manufactures which does not help anyone. For consumers of hardware or database systems, this provides a single document which you can point to to indicate what you want from the system. It should clear up a considerable amount of confusion for providing compliant systems. \subsection{Committment to open source, freely available code} The Wise2 package has been licensed under the Gnu Public License since its inception. In addition, parts of the package has even less restrictive Licenses. I have a strong committment to keep Wise a freely available, open source package. The aim of the open architecture is to allow Wise to be compiled with additional extensions provided by third party sources: As the users will be compiling in the additional extensions, this will not require the 3rd parties to License their code under GPL. They will be free to license their code under any license they see fit, including keep their source code closed and charging for it. \subsection{Potential conflict of interests} I have been a consultant to Compugen (a company which builds specialised hardware) and am currently a consultant to Paracel (again, a specialised hardware company) and I have been a consultant to a number of bioinformatics and pharmaceutical companies worldwide. I do \emph{not believe} that my involvement with these companies prejuidices the open source nature of the Wise package, nor has this architecture been written to favour one particular company over another. I'd like to point out both that my committment to the scientific endeavour involved in the Wise package is far greater than any committment to any company, and that if I wanted to make money out of the Wise package in a serious manner I would have gone private \emph{myself} some time ago. I am sympathetic to people who are concerned about any potential conflict of interests that I have: I would welcome people to email their concerns and we can discuss it. I am very happy to allow the involvement of independent researchers who can verify the open nature Wise - all suggestions welcome. \subsection{A collaborative approach} This document is the first stab at a definition of an open architecture. I would very much welcome feedback from both manufactures, corporate users and academic users as to what would help them make better use of Wise in a large scale software environment. Please feel free to make your own suggestions and corrections. \section{Overview of the architecture} The architecture will define 3 main interfaces \begin{itemize} \item A C based interface of opening, iterating over and closing a database of sequences. \item A CORBA based interface of opening, iterating over and closing a database of sequences: this reuses the BioSource idl from bioperl for greater code reuse between packages. \item A C based interface of running a database search of a particular algorithm type, of a single query structure against a database of sequences as give by the above, C interface \end{itemize} In addition there needs to be additional rules for propagating command line arguments into the intialisation of the database and search routines, and also conventions for how to find and link against libaries containing this information, regardless of where they came from. Although at first the expected mode of action will be that the Wise source code will be compiled and then linked to the additional functionalities provided as C libraries, eventually dynamic loading routines might be considered. It was also tempting to focus on a CORBA only based interface of the code: however, even with free, lightweight effective ORBs such as ORBit, the technology is both an overkill for what is effectively a series of very simple interfaces and ties the portability of the code to the portability of the ORBs. In addition, people may be concerned that performance issues would come into play, even though ORBit will do direct function calls for in process object requests. A CORBA defintion has been provided for the database layer, but will always sit behind the pure C interface (ORBit will be our ORB of choice to do the mapping). The C interfaces will be designed with the following features in mind \begin{itemize} \item All the definitions will focus on passing opaque pointers to functions \item When functions return status values, they will return an integer, with 0 being success and non zero indicating an error of some sort \end{itemize} \section{Database Access, C definition} \begin{verbatim} typedef struct WOpenSeq WOpenSeq; typedef struct WOpenSeqStream WOpenSeqStream; typedef struct WOpenSeqDB WOpenSeqDB; typedef int WOpenStatus; char * WOpenSeq_seq(WOpenSeq * seq); char * WOpenSeq_subseq(WOpenSeq * seq,long start,long end); long WOpenSeq_length(WOpenSeq * seq); char * WOpenSeq_desc(WOpenSeq * seq); char * WOpenSeq_identifier(WOpenSeq * seq); WOpenStatus WOpenSeqStream_open(WOpenSeqStream * stream); \end{verbatim} \section{Error Libraries} The idea is that we ditch the error handling libraries of Wise2 (the /base stuff) and switch over to using glib routines \end{document} wise-2.4.1/docs/genewise6.eps0000644000175000001440000005141607313404521015414 0ustar philippusers%!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 0 0 473 722 %%Pages: 0 %%Creator: Sun Microsystems, Inc. %%Title: none %%CreationDate: none %%LanguageLevel: 2 %%EndComments %%BeginProlog %%BeginResource: SDRes /b4_inc_state save def /dict_count countdictstack def /op_count count 1 sub def userdict begin 0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit[] 0 setdash newpath /languagelevel where {pop languagelevel 1 ne {false setstrokeadjust false setoverprint} if} if /bdef {bind def} bind def /c {setrgbcolor} bdef /l {neg lineto} bdef /rl {neg rlineto} bdef /cl {currentlinewidth currentdash currentlinecap 2 setlinecap} bdef /lc {setlinecap} bdef /lw {setlinewidth} bdef /ld {setdash} bdef /m {neg moveto} bdef /r {rotate} bdef /t {translate} bdef /gs {gsave} bdef /gr {grestore} bdef /f {findfont dup length dict begin {1 index /FID ne {def} {pop pop} ifelse} forall /Encoding ISOLatin1Encoding def currentdict end /NFont exch definefont pop /NFont findfont} bdef /s {show} bdef /p {closepath} bdef /sf {scalefont setfont} bdef /pf {closepath fill}bdef /pc {closepath stroke}bdef /ps {stroke}bdef /pum {matrix currentmatrix}bdef /pom {setmatrix}bdef /bs {/aString exch def /nXOfs exch def /nWidth exch def currentpoint nXOfs 0 rmoveto pum nWidth aString stringwidth pop div 1 scale aString show pom moveto} bdef %%EndResource %%EndProlog %%BeginSetup %%EndSetup %%Page: 1 1 %%BeginPageSetup %%EndPageSetup pum 0.28362 0.2834 scale 0 2547.6 t 0.003 0.003 0.003 c 929.9 585.8 m 929.6 576.7 l 928.9 567.6 l 927.6 558.6 l 925.8 549.6 l 923.5 540.7 l 920.7 531.9 l 917.5 523.3 l 913.7 514.9 l 909.5 506.6 l 904.8 498.5 l 899.6 490.6 l 894.1 483 l 888.1 475.7 l 881.7 468.6 l 874.9 461.9 l 867.7 455.4 l 860.2 449.3 l 852.3 443.5 l 844.2 438.1 l 835.7 433.1 l 827 428.5 l 818 424.3 l 808.8 420.5 l 799.4 417.1 l 789.8 414.2 l 780 411.6 l 770.2 409.6 l 760.2 408 l 750.1 406.8 l 740 406.1 l 729.9 405.9 l 729.9 405.9 l 719.8 406.1 l 709.7 406.8 l 699.6 408 l 689.6 409.6 l 679.8 411.6 l 670 414.2 l 660.39999 417.1 l 651 420.5 l 641.8 424.3 l 632.8 428.5 l 624.1 433.1 l 615.6 438.1 l 607.5 443.5 l 599.6 449.3 l 592.1 455.4 l 584.89999 461.9 l 578.1 468.6 l 571.7 475.7 l 565.7 483 l 560.2 490.6 l 555 498.5 l 550.3 506.6 l 546.1 514.9 l 542.3 523.3 l 539.1 531.9 l 536.3 540.7 l 534 549.6 l 532.2 558.6 l 530.89999 567.6 l 530.2 576.7 l 529.89999 585.8 l 529.89999 585.8 l 530.2 594.9 l 530.89999 604 l 532.2 613 l 534 622 l 536.3 630.9 l 539.1 639.7 l 542.3 648.3 l 546.1 656.7 l 550.3 665 l 555 673.1 l 560.2 681 l 565.7 688.6 l 571.7 695.9 l 578.1 703 l 584.89999 709.7 l 592.1 716.2 l 599.6 722.3 l 607.5 728.1 l 615.6 733.5 l 624.1 738.5 l 632.8 743.1 l 641.8 747.3 l 651 751.1 l 660.39999 754.5 l 670 757.4 l 679.8 760 l 689.6 762 l 699.6 763.6 l 709.7 764.8 l 719.8 765.5 l 729.9 765.7 l 729.9 765.7 l 740 765.5 l 750.1 764.8 l 760.2 763.6 l 770.2 762 l 780 760 l 789.8 757.4 l 799.4 754.5 l 808.8 751.1 l 818 747.3 l 827 743.1 l 835.7 738.5 l 844.2 733.5 l 852.3 728.1 l 860.2 722.3 l 867.7 716.2 l 874.9 709.7 l 881.7 703 l 888.1 695.9 l 894.1 688.6 l 899.6 681 l 904.8 673.1 l 909.5 665 l 913.7 656.7 l 917.5 648.3 l 920.7 639.7 l 923.5 630.9 l 925.8 622 l 927.6 613 l 928.9 604 l 929.6 594.9 l 929.9 585.8 l pc 1439.8 1412.6 m 1439.5 1403.5 l 1438.8 1394.4 l 1437.5 1385.4 l 1435.7 1376.4 l 1433.4 1367.5 l 1430.6 1358.7 l 1427.3 1350.1 l 1423.6 1341.7 l 1419.4 1333.4 l 1414.7 1325.3 l 1409.5 1317.4 l 1403.9 1309.8 l 1397.9 1302.5 l 1391.5 1295.4 l 1384.7 1288.7 l 1377.6 1282.2 l 1370 1276.1 l 1362.2 1270.3 l 1354 1264.9 l 1345.5 1259.9 l 1336.8 1255.3 l 1327.8 1251.1 l 1318.6 1247.3 l 1309.2 1243.9 l 1299.6 1241 l 1289.9 1238.4 l 1280 1236.4 l 1270 1234.8 l 1259.9 1233.6 l 1249.79999 1232.9 l 1239.7 1232.7 l 1239.7 1232.7 l 1229.6 1232.9 l 1219.5 1233.6 l 1209.4 1234.8 l 1199.4 1236.4 l 1189.5 1238.4 l 1179.79999 1241 l 1170.2 1243.9 l 1160.79999 1247.3 l 1151.6 1251.1 l 1142.6 1255.3 l 1133.9 1259.9 l 1125.4 1264.9 l 1117.2 1270.3 l 1109.4 1276.1 l 1101.79999 1282.2 l 1094.7 1288.7 l 1087.9 1295.4 l 1081.5 1302.5 l 1075.5 1309.8 l 1069.9 1317.4 l 1064.7 1325.3 l 1060 1333.4 l 1055.79999 1341.7 l 1052.1 1350.1 l 1048.79999 1358.7 l 1046 1367.5 l 1043.7 1376.4 l 1041.9 1385.4 l 1040.6 1394.4 l 1039.9 1403.5 l 1039.6 1412.6 l 1039.6 1412.6 l 1039.9 1421.7 l 1040.6 1430.8 l 1041.9 1439.8 l 1043.7 1448.8 l 1046 1457.7 l 1048.79999 1466.5 l 1052.1 1475.1 l 1055.79999 1483.5 l 1060 1491.8 l 1064.7 1499.9 l 1069.9 1507.8 l 1075.5 1515.4 l 1081.5 1522.7 l 1087.9 1529.8 l 1094.7 1536.5 l 1101.79999 1543 l 1109.4 1549.1 l 1117.2 1554.9 l 1125.4 1560.3 l 1133.9 1565.3 l 1142.6 1569.9 l 1151.6 1574.1 l 1160.79999 1577.9 l 1170.2 1581.3 l 1179.79999 1584.2 l 1189.5 1586.8 l 1199.4 1588.8 l 1209.4 1590.4 l 1219.5 1591.6 l 1229.6 1592.3 l 1239.7 1592.5 l 1239.7 1592.5 l 1249.79999 1592.3 l 1259.9 1591.6 l 1270 1590.4 l 1280 1588.8 l 1289.9 1586.8 l 1299.6 1584.2 l 1309.2 1581.3 l 1318.6 1577.9 l 1327.8 1574.1 l 1336.8 1569.9 l 1345.5 1565.3 l 1354 1560.3 l 1362.2 1554.9 l 1370 1549.1 l 1377.6 1543 l 1384.7 1536.5 l 1391.5 1529.8 l 1397.9 1522.7 l 1403.9 1515.4 l 1409.5 1507.8 l 1414.7 1499.9 l 1419.4 1491.8 l 1423.6 1483.5 l 1427.3 1475.1 l 1430.6 1466.5 l 1433.4 1457.7 l 1435.7 1448.8 l 1437.5 1439.8 l 1438.8 1430.8 l 1439.5 1421.7 l 1439.8 1412.6 l pc 400.1 1426.7 m 399.8 1417.6 l 399.1 1408.5 l 397.8 1399.5 l 396 1390.5 l 393.7 1381.6 l 390.9 1372.8 l 387.6 1364.2 l 383.9 1355.8 l 379.69999 1347.5 l 375 1339.4 l 369.8 1331.5 l 364.19999 1323.9 l 358.19999 1316.6 l 351.8 1309.5 l 345 1302.8 l 337.9 1296.3 l 330.3 1290.2 l 322.5 1284.4 l 314.3 1279 l 305.8 1274 l 297.1 1269.4 l 288.1 1265.2 l 278.9 1261.4 l 269.5 1258 l 259.9 1255.1 l 250.2 1252.5 l 240.3 1250.5 l 230.3 1248.9 l 220.2 1247.7 l 210.09999 1247 l 200 1246.8 l 200 1246.8 l 189.9 1247 l 179.8 1247.7 l 169.7 1248.9 l 159.7 1250.5 l 149.8 1252.5 l 140.09999 1255.1 l 130.5 1258 l 121.1 1261.4 l 111.9 1265.2 l 102.9 1269.4 l 94.2 1274 l 85.7 1279 l 77.5 1284.4 l 69.7 1290.2 l 62.1 1296.3 l 55 1302.8 l 48.19999 1309.5 l 41.79999 1316.6 l 35.79999 1323.9 l 30.19999 1331.5 l 24.99999 1339.4 l 20.29999 1347.5 l 16.09999 1355.8 l 12.39999 1364.2 l 9.09999 1372.8 l 6.29999 1381.6 l 3.99999 1390.5 l 2.19999 1399.5 l 0.89999 1408.5 l 0.19999 1417.6 l -0.1 1426.7 l -0.1 1426.7 l 0.19999 1435.8 l 0.89999 1444.9 l 2.19999 1453.9 l 3.99999 1462.9 l 6.29999 1471.8 l 9.09999 1480.6 l 12.39999 1489.2 l 16.09999 1497.6 l 20.29999 1505.9 l 24.99999 1514 l 30.19999 1521.9 l 35.79999 1529.5 l 41.79999 1536.8 l 48.19999 1543.9 l 55 1550.6 l 62.1 1557.1 l 69.7 1563.2 l 77.5 1569 l 85.7 1574.4 l 94.2 1579.4 l 102.9 1584 l 111.9 1588.2 l 121.1 1592 l 130.5 1595.4 l 140.09999 1598.3 l 149.8 1600.9 l 159.7 1602.9 l 169.7 1604.5 l 179.8 1605.7 l 189.9 1606.4 l 200 1606.6 l 200 1606.6 l 210.09999 1606.4 l 220.2 1605.7 l 230.3 1604.5 l 240.3 1602.9 l 250.2 1600.9 l 259.9 1598.3 l 269.5 1595.4 l 278.9 1592 l 288.1 1588.2 l 297.1 1584 l 305.8 1579.4 l 314.3 1574.4 l 322.5 1569 l 330.3 1563.2 l 337.9 1557.1 l 345 1550.6 l 351.8 1543.9 l 358.19999 1536.8 l 364.19999 1529.5 l 369.8 1521.9 l 375 1514 l 379.69999 1505.9 l 383.9 1497.6 l 387.6 1489.2 l 390.9 1480.6 l 393.7 1471.8 l 396 1462.9 l 397.8 1453.9 l 399.1 1444.9 l 399.8 1435.8 l 400.1 1426.7 l pc 599.89999 728.4 m 274.8 1232.8 l ps 274.8 1232.8 m 277.8 1205 l 298.9 1218.6 l 274.8 1232.8 l pf 334.9 1265.5 m 639.8 770.4 l ps 639.8 770.4 m 637.3 798.2 l 616 785.1 l 639.8 770.4 l pf 879.9 728.4 m 1179.6 1218.7 l ps 1179.6 1218.7 m 1155.9 1203.9 l 1177.2 1190.9 l 1179.6 1218.7 l pf 1134.79999 1246.9 m 845 760.9 l ps 845 760.9 m 868.5 776 l 847.1 788.8 l 845 760.9 l pf 415 1386.9 m 1014.9 1386.9 l ps 1014.9 1386.9 m 989.9 1399.4 l 989.9 1374.4 l 1014.9 1386.9 l pf 1024.79999 1447.8 m 415 1447.8 l ps 415 1447.8 m 440 1435.3 l 440 1460.3 l 415 1447.8 l pf gs 611.2 542.4 m 836.1 542.4 l 836.1 637.6 l 611.2 637.6 l 611.2 542.4 l eoclip newpath /Times f 84.6 sf 611.2 621.8 m 79.4 0 (M) bs 37 79.6 (a) bs 23.8 117.7 (t) bs 37 143.09999 (c) bs 47.6 179.5 (h) bs gr gs /Times f 84.6 sf 1137.7 1420.8 m 29.1 0 (I) bs 47.6 28.8 (n) bs 31.8 76.2 (s) bs 39.7 108.4 (e) bs 29.1 148.2 (r) bs 23.8 177 (t) bs gr gs 71.4 1357.3 m 304.3 1357.3 l 304.3 1452.6 l 71.4 1452.6 l 71.4 1357.3 l eoclip newpath /Times f 84.6 sf 71.4 1436.7 m 66.1 0 (D) bs 39.7 66.9 (e) bs 21.2 106.7 (l) bs 39.7 128.7 (e) bs 23.8 168.5 (t) bs 39.7 193.9 (e) bs gr 0.003 1.000 0.003 c 1434.4 388.7 m 1662 388.7 l 1662 521 l 1434.4 521 l 1434.4 388.7 l pc gs 0.003 0.003 0.003 c /Times f 84.6 sf 1526.6 486.9 m (0) s gr 1434.5 536.9 m 1667.4 536.9 l 1667.4 669.2 l 1434.5 669.2 l 1434.5 536.9 l pc gs 1531.9 555.6 m 1571.6 555.6 l 1571.6 650.9 l 1531.9 650.9 l 1531.9 555.6 l eoclip newpath 0.003 0.003 0.003 c /Times f 84.6 sf 1531.9 635 m (1) s gr 1434.6 685.2 m 1667.5 685.2 l 1667.5 817.5 l 1434.6 817.5 l 1434.6 685.2 l pc gs 0.003 0.003 0.003 c /Times f 84.6 sf 1531.9 783.2 m (2) s gr 1323.3 608.2 m 1323.3 606.5 l 1323.1 604.7 l 1322.9 603 l 1322.5 601.3 l 1322.1 599.6 l 1321.6 597.9 l 1321 596.3 l 1320.3 594.6 l 1319.5 593.1 l 1318.6 591.5 l 1317.7 590 l 1316.7 588.5 l 1315.5 587.1 l 1314.3 585.8 l 1313.1 584.5 l 1311.8 583.3 l 1310.4 582.1 l 1308.9 581 l 1307.4 580 l 1305.8 579 l 1304.2 578.1 l 1302.5 577.3 l 1300.8 576.6 l 1299.1 575.9 l 1297.29999 575.4 l 1295.5 574.9 l 1293.7 574.5 l 1291.79999 574.2 l 1290 574 l 1288.1 573.8 l 1286.2 573.8 l 1286.2 573.8 l 1284.29999 573.8 l 1282.4 574 l 1280.6 574.2 l 1278.7 574.5 l 1276.9 574.9 l 1275.1 575.4 l 1273.29999 575.9 l 1271.6 576.6 l 1269.9 577.3 l 1268.2 578.1 l 1266.6 579 l 1265 580 l 1263.5 581 l 1262 582.1 l 1260.6 583.3 l 1259.29999 584.5 l 1258.1 585.8 l 1256.9 587.1 l 1255.7 588.5 l 1254.7 590 l 1253.79999 591.5 l 1252.9 593.1 l 1252.1 594.6 l 1251.4 596.3 l 1250.79999 597.9 l 1250.29999 599.6 l 1249.9 601.3 l 1249.5 603 l 1249.29999 604.7 l 1249.1 606.5 l 1249.1 608.2 l 1249.1 608.2 l 1249.1 609.9 l 1249.29999 611.7 l 1249.5 613.4 l 1249.9 615.1 l 1250.29999 616.8 l 1250.79999 618.5 l 1251.4 620.1 l 1252.1 621.8 l 1252.9 623.3 l 1253.79999 624.9 l 1254.7 626.4 l 1255.7 627.9 l 1256.9 629.3 l 1258.1 630.6 l 1259.29999 631.9 l 1260.6 633.1 l 1262 634.3 l 1263.5 635.4 l 1265 636.4 l 1266.6 637.4 l 1268.2 638.3 l 1269.9 639.1 l 1271.6 639.8 l 1273.29999 640.5 l 1275.1 641 l 1276.9 641.5 l 1278.7 641.9 l 1280.6 642.2 l 1282.4 642.4 l 1284.29999 642.6 l 1286.2 642.6 l 1286.2 642.6 l 1288.1 642.6 l 1290 642.4 l 1291.79999 642.2 l 1293.7 641.9 l 1295.5 641.5 l 1297.29999 641 l 1299.1 640.5 l 1300.8 639.8 l 1302.5 639.1 l 1304.2 638.3 l 1305.8 637.4 l 1307.4 636.4 l 1308.9 635.4 l 1310.4 634.3 l 1311.8 633.1 l 1313.1 631.9 l 1314.3 630.6 l 1315.5 629.3 l 1316.7 627.9 l 1317.7 626.4 l 1318.6 624.9 l 1319.5 623.3 l 1320.3 621.8 l 1321 620.1 l 1321.6 618.5 l 1322.1 616.8 l 1322.5 615.1 l 1322.9 613.4 l 1323.1 611.7 l 1323.3 609.9 l 1323.3 608.2 l pc 1434.4 454.8 m 1378.9 454.8 l 1378.9 608.2 l 1323.3 608.2 l ps 1434.5 603 m 1378.9 603 l 1378.9 608.2 l 1323.3 608.2 l ps 1434.6 751.3 m 1379 751.3 l 1379 608.2 l 1323.3 608.2 l ps 1434.5 388.7 m 1662.1 388.7 l 1662.1 521 l 1434.5 521 l 1434.5 388.7 l pc gs 1526.6 407.5 m 1566.3 407.5 l 1566.3 502.7 l 1526.6 502.7 l 1526.6 407.5 l eoclip newpath 0.003 0.003 0.003 c /Times f 84.6 sf 1526.6 486.9 m (0) s gr 1434.6 536.9 m 1667.5 536.9 l 1667.5 669.2 l 1434.6 669.2 l 1434.6 536.9 l pc gs 0.003 0.003 0.003 c /Times f 84.6 sf 1531.9 635 m (1) s gr 1434.7 685.2 m 1667.6 685.2 l 1667.6 817.5 l 1434.7 817.5 l 1434.7 685.2 l pc gs 1531.9 703.8 m 1571.6 703.8 l 1571.6 799 l 1531.9 799 l 1531.9 703.8 l eoclip newpath 0.003 0.003 0.003 c /Times f 84.6 sf 1531.9 783.2 m (2) s gr 1323.4 608.2 m 1323.4 606.5 l 1323.2 604.7 l 1323 603 l 1322.6 601.3 l 1322.2 599.6 l 1321.7 597.9 l 1321.1 596.3 l 1320.4 594.6 l 1319.6 593.1 l 1318.7 591.5 l 1317.8 590 l 1316.8 588.5 l 1315.6 587.1 l 1314.4 585.8 l 1313.2 584.5 l 1311.9 583.3 l 1310.5 582.1 l 1309 581 l 1307.5 580 l 1305.9 579 l 1304.3 578.1 l 1302.6 577.3 l 1300.9 576.6 l 1299.2 575.9 l 1297.4 575.4 l 1295.6 574.9 l 1293.79999 574.5 l 1291.9 574.2 l 1290.1 574 l 1288.2 573.8 l 1286.29999 573.8 l 1286.29999 573.8 l 1284.4 573.8 l 1282.5 574 l 1280.7 574.2 l 1278.79999 574.5 l 1277 574.9 l 1275.2 575.4 l 1273.4 575.9 l 1271.7 576.6 l 1270 577.3 l 1268.29999 578.1 l 1266.7 579 l 1265.1 580 l 1263.6 581 l 1262.1 582.1 l 1260.7 583.3 l 1259.4 584.5 l 1258.2 585.8 l 1257 587.1 l 1255.79999 588.5 l 1254.79999 590 l 1253.9 591.5 l 1253 593.1 l 1252.2 594.6 l 1251.5 596.3 l 1250.9 597.9 l 1250.4 599.6 l 1250 601.3 l 1249.6 603 l 1249.4 604.7 l 1249.2 606.5 l 1249.2 608.2 l 1249.2 608.2 l 1249.2 609.9 l 1249.4 611.7 l 1249.6 613.4 l 1250 615.1 l 1250.4 616.8 l 1250.9 618.5 l 1251.5 620.1 l 1252.2 621.8 l 1253 623.3 l 1253.9 624.9 l 1254.79999 626.4 l 1255.79999 627.9 l 1257 629.3 l 1258.2 630.6 l 1259.4 631.9 l 1260.7 633.1 l 1262.1 634.3 l 1263.6 635.4 l 1265.1 636.4 l 1266.7 637.4 l 1268.29999 638.3 l 1270 639.1 l 1271.7 639.8 l 1273.4 640.5 l 1275.2 641 l 1277 641.5 l 1278.79999 641.9 l 1280.7 642.2 l 1282.5 642.4 l 1284.4 642.6 l 1286.29999 642.6 l 1286.29999 642.6 l 1288.2 642.6 l 1290.1 642.4 l 1291.9 642.2 l 1293.79999 641.9 l 1295.6 641.5 l 1297.4 641 l 1299.2 640.5 l 1300.9 639.8 l 1302.6 639.1 l 1304.3 638.3 l 1305.9 637.4 l 1307.5 636.4 l 1309 635.4 l 1310.5 634.3 l 1311.9 633.1 l 1313.2 631.9 l 1314.4 630.6 l 1315.6 629.3 l 1316.8 627.9 l 1317.8 626.4 l 1318.7 624.9 l 1319.6 623.3 l 1320.4 621.8 l 1321.1 620.1 l 1321.7 618.5 l 1322.2 616.8 l 1322.6 615.1 l 1323 613.4 l 1323.2 611.7 l 1323.4 609.9 l 1323.4 608.2 l pc 1434.5 454.8 m 1379 454.8 l 1379 608.2 l 1323.4 608.2 l ps 1434.6 603 m 1379 603 l 1379 608.2 l 1323.4 608.2 l ps 1434.7 751.3 m 1379.1 751.3 l 1379.1 608.2 l 1323.4 608.2 l ps 0.003 0.003 0.003 c 894.8 478.5 m 1249.29999 594.9 l ps 1249.29999 594.9 m 1221.6 599 l 1229.4 575.2 l 1249.29999 594.9 l pf 1265.2 573.7 m 852.4 430.9 l ps 852.4 430.9 m 880.1 427.3 l 871.9 450.9 l 852.4 430.9 l pf 1312.8 1245.8 m 1286.29999 642.5 l ps 1286.29999 642.5 m 1299.9 666.9 l 1274.9 668 l 1286.29999 642.5 l pf 1259.9 642.5 m 1275.79999 1224.6 l ps 1275.79999 1224.6 m 1262.6 1200 l 1287.6 1199.3 l 1275.79999 1224.6 l pf 1.000 1.000 1.000 c 504.4 129.5 m 964.6 129.5 l 964.6 323.6 l 504.4 323.6 l 504.4 129.5 l pf 504.4 129.5 m 964.6 129.5 l 964.6 323.6 l 504.4 323.6 l 504.4 129.5 l pc 0.003 1.000 0.003 c 550.8 2312 m 550.6 2305.7 l 550 2299.4 l 549.1 2293.2 l 547.8 2287 l 546.1 2280.8 l 544 2274.8 l 541.6 2268.8 l 538.8 2262.9 l 535.7 2257.2 l 532.2 2251.6 l 528.39999 2246.2 l 524.2 2240.9 l 519.8 2235.9 l 515 2231 l 510 2226.3 l 504.7 2221.8 l 499.1 2217.59999 l 493.3 2213.59999 l 487.3 2209.9 l 481 2206.4 l 474.5 2203.2 l 467.9 2200.3 l 461 2197.7 l 454.1 2195.3 l 447 2193.3 l 439.7 2191.59999 l 432.4 2190.09999 l 425 2189 l 417.6 2188.2 l 410.1 2187.8 l 402.6 2187.59999 l 402.6 2187.59999 l 395.1 2187.8 l 387.6 2188.2 l 380.2 2189 l 372.8 2190.09999 l 365.5 2191.59999 l 358.19999 2193.3 l 351.1 2195.3 l 344.19999 2197.7 l 337.3 2200.3 l 330.69999 2203.2 l 324.19999 2206.4 l 317.9 2209.9 l 311.9 2213.59999 l 306.1 2217.59999 l 300.5 2221.8 l 295.19999 2226.3 l 290.19999 2231 l 285.4 2235.9 l 281 2240.9 l 276.8 2246.2 l 273 2251.6 l 269.5 2257.2 l 266.4 2262.9 l 263.6 2268.8 l 261.19999 2274.8 l 259.1 2280.8 l 257.4 2287 l 256.1 2293.2 l 255.2 2299.4 l 254.6 2305.7 l 254.4 2312 l 254.4 2312 l 254.6 2318.3 l 255.2 2324.6 l 256.1 2330.8 l 257.4 2337 l 259.1 2343.2 l 261.19999 2349.2 l 263.6 2355.2 l 266.4 2361.1 l 269.5 2366.8 l 273 2372.4 l 276.8 2377.8 l 281 2383.1 l 285.4 2388.1 l 290.19999 2393 l 295.19999 2397.7 l 300.5 2402.2 l 306.1 2406.4 l 311.9 2410.4 l 317.9 2414.1 l 324.19999 2417.6 l 330.69999 2420.8 l 337.3 2423.7 l 344.19999 2426.3 l 351.1 2428.7 l 358.19999 2430.7 l 365.5 2432.4 l 372.8 2433.9 l 380.2 2435 l 387.6 2435.8 l 395.1 2436.2 l 402.6 2436.4 l 402.6 2436.4 l 410.1 2436.2 l 417.6 2435.8 l 425 2435 l 432.4 2433.9 l 439.7 2432.4 l 447 2430.7 l 454.1 2428.7 l 461 2426.3 l 467.9 2423.7 l 474.5 2420.8 l 481 2417.6 l 487.3 2414.1 l 493.3 2410.4 l 499.1 2406.4 l 504.7 2402.2 l 510 2397.7 l 515 2393 l 519.8 2388.1 l 524.2 2383.1 l 528.39999 2377.8 l 532.2 2372.4 l 535.7 2366.8 l 538.8 2361.1 l 541.6 2355.2 l 544 2349.2 l 546.1 2343.2 l 547.8 2337 l 549.1 2330.8 l 550 2324.6 l 550.6 2318.3 l 550.8 2312 l pc 90.4 2304.1 m 254.5 2304.1 l ps 254.5 2304.1 m 229.5 2316.6 l 229.5 2291.6 l 254.5 2304.1 l pf 1.000 1.000 1.000 c 396.4 2472.9 m 518.3 2472.9 l 518.3 2531.9 l 274.5 2531.9 l 274.5 2472.9 l 396.4 2472.9 l pf 396.4 2472.9 m 518.3 2472.9 l 518.3 2531.9 l 274.5 2531.9 l 274.5 2472.9 l 396.4 2472.9 l pc 1408.5 2472.9 m 1530.4 2472.9 l 1530.4 2531.9 l 1286.6 2531.9 l 1286.6 2472.9 l 1408.5 2472.9 l pf 1408.5 2472.9 m 1530.4 2472.9 l 1530.4 2531.9 l 1286.6 2531.9 l 1286.6 2472.9 l 1408.5 2472.9 l pc gs 0.003 0.003 0.003 c /Times f 84.6 sf 280.5 2341.6 m 29.1 0 (I) bs 47.6 28.8 (n) bs 23.8 76.2 (t) bs 29.1 101.6 (r) bs 45 130.4 (o) bs 47.6 175.3 (n) bs gr 0.003 1.000 0.003 c 69.29999 2134.8 m 799.5 2134.8 l 799.5 2547.5 l 69.29999 2547.5 l 69.29999 2134.8 l pc gs 121.7 2325.7 m 182.59999 2325.7 l 182.59999 2420.9 l 121.7 2420.9 l 121.7 2325.7 l eoclip newpath 0.003 0.003 0.003 c /Times f 84.6 sf 121.7 2405.1 m 39.7 0 (5) bs 21.2 39.8 (') bs gr 557.5 2316 m 726.8 2316 l ps 726.8 2316 m 701.8 2328.5 l 701.8 2303.5 l 726.8 2316 l pf gs 0.003 0.003 0.003 c /Times f 84.6 sf 592.7 2421 m 39.7 0 (3) bs 21.2 39.8 (') bs gr 0.003 0.003 0.003 c 1323.5 1573.8 m 1337.8 1591.7 l 1349.5 1612.9 l 1358.4 1636.8 l 1363.9 1662.9 l 1365.9 1690.8 l 1362 1730 l 1351 1765.3 l 1334 1795.2 l 1312 1818.3 l 1286.1 1833.2 l 1257.29999 1838.5 l 1228.4 1833.2 l 1202.5 1818.3 l 1180.5 1795.2 l 1163.5 1765.3 l 1152.5 1730 l 1148.7 1690.8 l 1149.6 1671.3 l 1152.29999 1652.6 l 1156.79999 1634.9 l 1162.7 1618.2 l 1170.2 1602.8 l ps 1323.5 1573.8 m 1339.9 1618.3 l 1363.3 1599.6 l pf 282.4 1586 m 296.69999 1603.9 l 308.4 1625.1 l 317.3 1649 l 322.8 1675.1 l 324.8 1703 l 320.9 1742.2 l 309.9 1777.5 l 292.9 1807.4 l 270.9 1830.5 l 245 1845.4 l 216.2 1850.7 l 187.3 1845.4 l 161.4 1830.5 l 139.4 1807.4 l 122.4 1777.5 l 111.4 1742.2 l 107.6 1703 l 108.5 1683.5 l 111.2 1664.8 l 115.7 1647.1 l 121.6 1630.4 l 129.09999 1615 l ps 282.4 1586 m 298.8 1630.5 l 322.19999 1611.8 l pf 0.503 0.003 0.003 c 1369.9 1529.2 m 1388.2 1553.2 l 1404 1580.9 l 1416.8 1611.8 l 1426.3 1645.6 l 1432.3 1681.7 l 1434.4 1719.7 l 1431 1768.1 l 1421.3 1813.2 l 1406.1 1854 l 1385.9 1889.6 l 1361.4 1919 l 1333.4 1941.1 l 1302.3 1955.2 l 1269.1 1960.1 l 1235.79999 1955.2 l 1204.7 1941.1 l 1176.7 1919 l 1152.2 1889.6 l 1132 1854 l 1116.79999 1813.2 l 1107.1 1768.1 l 1103.79999 1719.7 l 1105.2 1688 l 1109.4 1657.6 l 1116.1 1628.7 l 1125.1 1601.6 l 1136.4 1576.5 l ps 1369.9 1529.2 m 1385.3 1574.1 l 1409.1 1555.9 l pf 603 405.8 m 591.7 380.7 l 582.7 353.6 l 576.1 324.7 l 572 294.4 l 570.6 262.9 l 573.89999 214.4 l 583.6 169.3 l 598.8 128.5 l 619 92.9 l 643.5 63.5 l 671.5 41.4 l 702.6 27.3 l 735.9 22.5 l 769.1 27.3 l 800.2 41.4 l 828.2 63.5 l 852.7 92.9 l 872.9 128.5 l 888.1 169.3 l 897.8 214.4 l 901.2 262.9 l 899.1 300.9 l 893.1 337.1 l 883.5 370.9 l 870.6 401.9 l 854.8 429.6 l 836.4 453.6 l ps 603 405.8 m 598.2 358.6 l 570.8 370.9 l pf 0.003 0.003 0.003 c 647.3 403.1 m 639.89999 387.6 l 634 371 l 629.6 353.2 l 626.89999 334.6 l 626 315.3 l 629.8 276 l 640.8 240.7 l 657.8 210.8 l 679.8 187.7 l 705.7 172.8 l 734.6 167.6 l 763.4 172.8 l 789.3 187.7 l 811.3 210.8 l 828.3 240.7 l 839.3 276 l 843.2 315.3 l 841.2 343.2 l 835.6 369.3 l 826.7 393.2 l 814.9 414.4 l 800.6 432.5 l ps 647.3 403.1 m 641.39999 356 l 614.39999 369 l pf 0.003 0.503 0.003 c 332.4 2209 m 316.8 2195.4 l 304 2179.2 l 294.4 2160.8 l 288.4 2140.59999 l 286.3 2119 l 291.9 2083.9 l 307.69999 2053.4 l 331.8 2029.3 l 362.3 2013.5 l 397.4 2007.9 l 432.4 2013.5 l 462.9 2029.3 l 487 2053.4 l 502.8 2083.9 l 508.5 2119 l 506 2142.2 l 499 2163.8 l 487.9 2183.2 l 473.3 2199.9 l 455.7 2213.5 l ps 332.4 2209 m 308.3 2168.09999 l 288.6 2190.7 l pf 0 -2547.6 t pom %%PageTrailer %%Trailer count op_count sub {pop} repeat countdictstack dict_count sub {end} repeat b4_inc_state restore %%EOF wise-2.4.1/LICENSE0000644000175000001440000000451610345263435013071 0ustar philippusers The Wise2 package is entirely open source licensed for use by both commerical and academic sites. This means that anyone can modify and redistribute the source code without restriction. However, the use of the source code as part of a larger, and potentially proprietory package depends on which portions of the source code you wish to use. Each directory has a seperate LICENSE or GNULICENSE file which you should read, but the gist is given below. The base (base libaries), dynlibsrc (underlying bioinformatics libaries) and dyc (dynamite compiler) are distributed under a BSD style license. This means that there is no restriction transfered to other source code when these pieces of source code are linked with other (potentially closed source) software libraries or code. These portions therefore are freely redistributable and freely useable: only an acknowledgement of the authorship needs to be declared. The HMMer2 libaries (Sean Eddy's HMM package) and the models directory (The algorithms for the Wise2 package, and final executable programs) are both distributed under a Gnu General Public License (GPL). This means that the entire package as it is distributed with these portions in is also licensed under GPL, due to the 'infectious' nature of the GPL. If people wish to use one of the BSD styled licensed pieces of code, the best route is to contact me directly so that I can make a clean distribution with no GPL'd code. The aim for this rather complicated licensing scheme is to provide people with the freedom to use the underlying libraries and technology as they see fit with very little restrictions, but to ensure that the scientific work that I (and in case of HMMER, Sean Eddy) provide is not explioted by someone else. By having the important algorithmical parts of the package protected under GPL, we ensure that any additional modifications or packages built on top of our work have to be freely redistributed. However, I must emphasise that the underlying bioinformatics libaries (base, dynlibsrc) and the dynamite compiler can be used in any manner at all, as long as authorship is acknowledged. For more information, please contact Ewan Birney but I don't like getting into protracted legal arguments. I believe that this file and Licenses should be enough for any organisation to figure out how they can use the software. wise-2.4.1/README0000644000175000001440000000366510642011253012735 0ustar philippusers README for Wise2/Dynamite development Wise2/Dynamite is written and maintained by Ewan Birney . The paper for Genewise is: GeneWise and Genomewise. Birney E, Clamp M, Durbin R. Genome Res. 2004 May;14(5):988-95. The paper for Dynamite is: Dynamite: a flexible code generating language for dynamic programming methods used in sequence comparison. Birney E, Durbin R. Proc Int Conf Intell Syst Mol Biol. 1997;5:56-64. If you are using Genewise, almost certainly you want to be also using Exonerate is protein2genome mode - for reasonably close genomes (ie, inter-mammalian, or human/chicken), this is as accurate as genewise and about 1,000 times faster. Exonerate was written by Guy Slater and is available at: http://www.ebi.ac.uk/~guy/exonerate/ INSTALLATION ------------- cd into src and type make all possibly followed by make test there is not a make install. binaries are in src/bin after make. The pthreads port no longer cleanly compiles. There was never really that much point in using the pthreads port as (a) you could trivially split databases and recombine the results for the same effect, and this was more sensible as it would work on farm configurations and (b) it was excessively long computation in anycase and probably you are better off with Exonerate. Development Notes: ------------------ Wise2 package is having a bit of a renaissance as my own (ie, Ewan's) coding development package. You will see alot more experimental code in these distributions and programs in development. The old war-horse, genewise is being gently tweaked. There is far more flexible splice site model. However currently this does not give better results that plain old gt-ag for all cases. Because of that the default is to use the gt-ag rule. Other interesting programs that will come out from this include promoterwise - a small region aligner designed for promoters and scanwise - a new protein searching engine. wise-2.4.1/INSTALL0000644000175000001440000000265607523540627013125 0ustar philippusers This README tells you how to install the wise2 on your own system. You have picked up the source distribution all you need to do cd into src and type 'make all'. This should only fail if a) You don't have a ANSI C compiler installed as cc. In which case see if you have gcc installated, and if so, edit the makefile in this directory to say CC = gcc rather than CC = cc b) You don't have a make program that allows recursion into directories (some old Sun systems did this). Install gnu make. c) If your copy of wise2 was downloaded via CVS, all the models are written in dynamite and need to be compiled. To do that you need to make dyc from an existing dynamite compiled system (ie, a tar ball from the ftp site) In the existing tar ball go: -make all in src directory -cd into dyc go make dyc -on linux this will fail. Then go make linux Now go: -copy dyc somewhere on your path; setenv WISECONFIGDIR to $wise-cvs-home/wisecfg/ -cd into src in cvs sources -go "make init" -now you can go make all. -------------------------------------------------------------- Installing with Pthreads support To install with Pthreads, you need to edit the top of the makefile in this directory. Basically you need to comment out the areas it says (by adding a # at the start of hte line) and uncomment the areas it says to uncomment. Then 'make all' should make it fine. -------------------------------------------------------------- wise-2.4.1/wisecfg/0000755000175000001440000000000010670453646013513 5ustar philippuserswise-2.4.1/wisecfg/gon200.bla0000644000175000001440000000572107313404522015172 0ustar philippusers A R N D C Q E G H I L K M F P S T W Y V B Z X * 3.5 -1.1 -0.7 -0.6 0.4 -0.4 -0.2 0.4 -1.3 -1.2 -1.6 -0.7 -0.9 -3.0 0.1 1.4 0.6 -4.5 -2.9 0.1 0.0 0.0 0.0 -6.4 -1.1 6.0 0.0 -0.9 -2.8 1.7 0.2 -1.5 0.5 -3.2 -2.8 3.2 -2.2 -4.2 -1.5 -0.5 -0.5 -2.0 -2.3 -2.6 0.0 0.0 0.0 -6.4 -0.7 0.0 5.2 2.4 -2.4 0.6 0.8 0.1 1.4 -3.6 -3.9 0.8 -2.8 -3.8 -1.5 1.0 0.5 -4.5 -1.8 -3.0 0.0 0.0 0.0 -6.4 -0.6 -0.9 2.4 5.9 -4.2 0.8 3.1 -0.3 0.2 -5.0 -5.2 0.3 -3.9 -5.7 -1.2 0.3 -0.3 -6.4 -3.5 -3.9 0.0 0.0 0.0 -6.4 0.4 -2.8 -2.4 -4.2 12.6 -3.3 -4.0 -2.6 -1.8 -1.8 -2.1 -3.7 -1.4 -1.2 -4.1 0.0 -0.9 -1.5 -0.8 -0.3 0.0 0.0 0.0 -6.4 -0.4 1.7 0.6 0.8 -3.3 4.1 2.1 -1.5 1.5 -2.5 -2.0 1.8 -1.1 -3.3 -0.5 0.0 -0.1 -3.3 -2.3 -2.1 0.0 0.0 0.0 -6.4 -0.2 0.2 0.8 3.1 -4.0 2.1 4.8 -1.4 0.2 -3.4 -3.6 1.3 -2.5 -5.0 -0.9 0.0 -0.4 -5.3 -3.5 -2.4 0.0 0.0 0.0 -6.4 0.4 -1.5 0.1 -0.3 -2.6 -1.5 -1.4 7.5 -2.0 -5.7 -5.5 -1.7 -4.3 -6.3 -2.2 0.2 -1.7 -4.8 -5.0 -4.2 0.0 0.0 0.0 -6.4 -1.3 0.5 1.4 0.2 -1.8 1.5 0.2 -2.0 7.8 -2.9 -2.5 0.5 -1.7 -0.3 -1.6 -0.4 -0.5 -1.3 2.5 -2.7 0.0 0.0 0.0 -6.4 -1.2 -3.2 -3.6 -5.0 -1.8 -2.5 -3.4 -5.7 -2.9 5.0 3.0 -2.8 2.8 0.7 -3.4 -2.5 -0.8 -2.6 -1.3 3.6 0.0 0.0 0.0 -6.4 -1.6 -2.8 -3.9 -5.2 -2.1 -2.0 -3.6 -5.5 -2.5 3.0 4.9 -2.7 3.2 2.0 -2.9 -2.8 -1.8 -1.3 -0.5 1.8 0.0 0.0 0.0 -6.4 -0.7 3.2 0.8 0.3 -3.7 1.8 1.3 -1.7 0.5 -2.8 -2.7 4.4 -1.8 -4.2 -1.0 -0.1 0.0 -4.4 -2.8 -2.3 0.0 0.0 0.0 -6.4 -0.9 -2.2 -2.8 -3.9 -1.4 -1.1 -2.5 -4.3 -1.7 2.8 3.2 -1.8 5.9 1.5 -3.3 -1.8 -0.8 -1.6 -0.7 1.6 0.0 0.0 0.0 -6.4 -3.0 -4.2 -3.8 -5.7 -1.2 -3.3 -5.0 -6.3 -0.3 0.7 2.0 -4.2 1.5 8.1 -4.8 -3.6 -2.9 3.5 5.4 -0.3 0.0 0.0 0.0 -6.4 0.1 -1.5 -1.5 -1.2 -4.1 -0.5 -0.9 -2.2 -1.6 -3.4 -2.9 -1.0 -3.3 -4.8 8.7 0.2 -0.1 -6.1 -3.9 -2.5 0.0 0.0 0.0 -6.4 1.4 -0.5 1.0 0.3 0.0 0.0 0.0 0.2 -0.4 -2.5 -2.8 -0.1 -1.8 -3.6 0.2 3.3 1.9 -4.0 -2.3 -1.5 0.0 0.0 0.0 -6.4 0.6 -0.5 0.5 -0.3 -0.9 -0.1 -0.4 -1.7 -0.5 -0.8 -1.8 0.0 -0.8 -2.9 -0.1 1.9 3.7 -4.4 -2.5 0.0 0.0 0.0 0.0 -6.4 -4.5 -2.0 -4.5 -6.4 -1.5 -3.3 -5.3 -4.8 -1.3 -2.6 -1.3 -4.4 -1.6 3.5 -6.1 -4.0 -4.4 15.1 4.0 -3.5 0.0 0.0 0.0 -6.4 -2.9 -2.3 -1.8 -3.5 -0.8 -2.3 -3.5 -5.0 2.5 -1.3 -0.5 -2.8 -0.7 5.4 -3.9 -2.3 -2.5 4.0 9.0 -1.7 0.0 0.0 0.0 -6.4 0.1 -2.6 -3.0 -3.9 -0.3 -2.1 -2.4 -4.2 -2.7 3.6 1.8 -2.3 1.6 -0.3 -2.5 -1.5 0.0 -3.5 -1.7 4.3 0.0 0.0 0.0 -6.4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -6.4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -6.4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 -6.4 1.0 wise-2.4.1/wisecfg/gon250.bla0000644000175000001440000000474507313404522015204 0ustar philippusers# benner-gonnet matrix # pam := 250 # print (DayhoffM (NewLogPAM1, pam)); # DayMatrix(Peptide, pam=250, Simil: max=14.152, min=-5.161, max offdiag=5.080, # del=-19.814-1.396*(k-1)) A R N D C Q E G H I L K M F P S T W Y V * 2.4 -0.6 -0.3 -0.3 0.5 -0.2 0.0 0.5 -0.8 -0.8 -1.2 -0.4 -0.7 -2.3 0.3 1.1 0.6 -3.6 -2.2 0.1 -5.2 -0.6 4.7 0.3 -0.3 -2.2 1.5 0.4 -1.0 0.6 -2.4 -2.2 2.7 -1.7 -3.2 -0.9 -0.2 -0.2 -1.6 -1.8 -2.0 -5.2 -0.3 0.3 3.8 2.2 -1.8 0.7 0.9 0.4 1.2 -2.8 -3.0 0.8 -2.2 -3.1 -0.9 0.9 0.5 -3.6 -1.4 -2.2 -5.2 -0.3 -0.3 2.2 4.7 -3.2 0.9 2.7 0.1 0.4 -3.8 -4.0 0.5 -3.0 -4.5 -0.7 0.5 0.0 -5.2 -2.8 -2.9 -5.2 0.5 -2.2 -1.8 -3.2 11.5 -2.4 -3.0 -2.0 -1.3 -1.1 -1.5 -2.8 -0.9 -0.8 -3.1 0.1 -0.5 -1.0 -0.5 0.0 -5.2 -0.2 1.5 0.7 0.9 -2.4 2.7 1.7 -1.0 1.2 -1.9 -1.6 1.5 -1.0 -2.6 -0.2 0.2 0.0 -2.7 -1.7 -1.5 -5.2 0.0 0.4 0.9 2.7 -3.0 1.7 3.6 -0.8 0.4 -2.7 -2.8 1.2 -2.0 -3.9 -0.5 0.2 -0.1 -4.3 -2.7 -1.9 -5.2 0.5 -1.0 0.4 0.1 -2.0 -1.0 -0.8 6.6 -1.4 -4.5 -4.4 -1.1 -3.5 -5.2 -1.6 0.4 -1.1 -4.0 -4.0 -3.3 -5.2 -0.8 0.6 1.2 0.4 -1.3 1.2 0.4 -1.4 6.0 -2.2 -1.9 0.6 -1.3 -0.1 -1.1 -0.2 -0.3 -0.8 2.2 -2.0 -5.2 -0.8 -2.4 -2.8 -3.8 -1.1 -1.9 -2.7 -4.5 -2.2 4.0 2.8 -2.1 2.5 1.0 -2.6 -1.8 -0.6 -1.8 -0.7 3.1 -5.2 -1.2 -2.2 -3.0 -4.0 -1.5 -1.6 -2.8 -4.4 -1.9 2.8 4.0 -2.1 2.8 2.0 -2.3 -2.1 -1.3 -0.7 0.0 1.8 -5.2 -0.4 2.7 0.8 0.5 -2.8 1.5 1.2 -1.1 0.6 -2.1 -2.1 3.2 -1.4 -3.3 -0.6 0.1 0.1 -3.5 -2.1 -1.7 -5.2 -0.7 -1.7 -2.2 -3.0 -0.9 -1.0 -2.0 -3.5 -1.3 2.5 2.8 -1.4 4.3 1.6 -2.4 -1.4 -0.6 -1.0 -0.2 1.6 -5.2 -2.3 -3.2 -3.1 -4.5 -0.8 -2.6 -3.9 -5.2 -0.1 1.0 2.0 -3.3 1.6 7.0 -3.8 -2.8 -2.2 3.6 5.1 0.1 -5.2 0.3 -0.9 -0.9 -0.7 -3.1 -0.2 -0.5 -1.6 -1.1 -2.6 -2.3 -0.6 -2.4 -3.8 7.6 0.4 0.1 -5.0 -3.1 -1.8 -5.2 1.1 -0.2 0.9 0.5 0.1 0.2 0.2 0.4 -0.2 -1.8 -2.1 0.1 -1.4 -2.8 0.4 2.2 1.5 -3.3 -1.9 -1.0 -5.2 0.6 -0.2 0.5 0.0 -0.5 0.0 -0.1 -1.1 -0.3 -0.6 -1.3 0.1 -0.6 -2.2 0.1 1.5 2.5 -3.5 -1.9 0.0 -5.2 -3.6 -1.6 -3.6 -5.2 -1.0 -2.7 -4.3 -4.0 -0.8 -1.8 -0.7 -3.5 -1.0 3.6 -5.0 -3.3 -3.5 14.2 4.1 -2.6 -5.2 -2.2 -1.8 -1.4 -2.8 -0.5 -1.7 -2.7 -4.0 2.2 -0.7 0.0 -2.1 -0.2 5.1 -3.1 -1.9 -1.9 4.1 7.8 -1.1 -5.2 0.1 -2.0 -2.2 -2.9 0.0 -1.5 -1.9 -3.3 -2.0 3.1 1.8 -1.7 1.6 0.1 -1.8 -1.0 0.0 -2.6 -1.1 3.4 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 -5.2 1 wise-2.4.1/wisecfg/pb.gf0000644000175000001440000001274407313404523014430 0ustar philippusers# Splice sites and intron regions information for GeneWise-21 May 1500 # Created by Mor Amitai (mor@compugen.co.il) # dataset : ~/ftp/pub/PomBase/temp/cds_cdna ~/ftp/pub/PomBase/temp/cds_ex # Consensi are read from top down. The value, for a sequence, # is the number in the line of the first consensus that # matches the sequence. # Note: the set of sequences that are represented by a consensus # are all the sequences that match this consensus and none of the # previous consensi # # the numbers in types 5SS, 3SS, CDS, and the emissions are the number of # occurrences of each sequence in the database. # In case of a consensus this is the number of occurrences of sequences # that are represented by the consensus in the database divided by the # number of sequences that are represented by the consensus. # *stay_prob is the probability of the transition from the state to itself. # No_Spacer_Prob is the probability of transition from Pyrimidine directly # to 3SS (no spacer). type 5SS center 3 phase all begin consensus ---GTA-GT- 8.69141 ---GT----- 0.0821553 end consensus type 5SS center 3 phase 0 begin consensus ---GTA-GT- 3.71094 ---GT----- 0.0356523 end consensus type 5SS center 3 phase 1 begin consensus ---GTA-GT- 2.92969 ---GT----- 0.0294519 end consensus type 5SS center 3 phase 2 begin consensus ---GT----- 0.0488281 end consensus type 3SS center 3 phase all begin consensus TAG--- 1.64062 -AG--- 22.9167 end consensus type 3SS center 3 phase 0 begin consensus TAG--- 0.765625 -AG--- 9.375 end consensus type 3SS center 3 phase 1 begin consensus TAG--- 0.515625 -AG--- 8.85417 end consensus type 3SS center 3 phase 2 begin consensus -AG--- 12.5 end consensus type CDS phase all begin consensus AAA 238.6335 AAC 105.316 AAG 156.4912 AAT 168.6987 ACA 98.7639 ACC 64.5552 ACG 58.8997 ACT 105.1091 AGA 126.4206 AGC 83.1769 AGG 72.7625 AGT 86.5564 ATA 99.3847 ATC 104.0746 ATG 139.4558 ATT 185.1134 CAA 149.8701 CAC 57.5203 CAG 70.8314 CAT 95.1086 CCA 79.5215 CCC 49.1751 CCG 45.5887 CCT 83.2459 CGA 70.6935 CGC 36.8985 CGG 35.4502 CGT 74.1419 CTA 83.6597 CTC 86.1426 CTG 91.798 CTT 143.6629 GAA 168.216 GAC 64.1414 GAG 82.3493 GAT 125.593 GCA 79.3146 GCC 51.589 GCG 36.4847 GCT 96.488 GGA 94.6258 GGC 47.037 GGG 35.2433 GGT 84.6942 GTA 73.7281 GTC 68.8313 GTG 72.4867 GTT 127.5931 TAA 113.0406 TAC 99.9364 TAG 59.1066 TAT 138.5592 TCA 115.9373 TCC 92.1429 TCG 76.4179 TCT 120.5582 TGA 148.7666 TGC 96.7638 TGG 118.0064 TGT 96.6949 TTA 153.8704 TTC 145.5251 TTG 156.6981 TTT 212.8391 end consensus type CDS phase 0 begin consensus AAA 248.8005 AAC 103.9424 AAG 172.7552 AAT 217.5971 ACA 87.4108 ACC 69.0194 ACG 38.6426 ACT 163.0428 AGA 70.2593 AGC 51.4546 AGG 27.6904 AGT 88.0307 ATA 74.1855 ATC 72.1191 ATG 126.4667 ATT 251.6935 CAA 170.2754 CAC 39.4692 CAG 70.2593 CAT 104.5623 CCA 77.4918 CCC 56.6207 CCG 25.8306 CCT 144.4448 CGA 48.1483 CGC 42.1556 CGG 17.1515 CGT 131.8395 CTA 50.628 CTC 47.735 CTG 34.3031 CTT 165.7292 GAA 288.4763 GAC 103.9424 GAG 150.4375 GAT 257.6862 GCA 100.4294 GCC 74.5988 GCG 29.1369 GCT 190.5266 GGA 104.9756 GGC 59.927 GGG 26.4506 GGT 158.29 GTA 76.252 GTC 75.0121 GTG 49.5948 GTT 200.6522 TAA 0 TAC 77.0786 TAG 0 TAT 147.7511 TCA 102.4959 TCC 77.2852 TCG 41.5356 TCT 182.6741 TGA 0 TGC 32.2366 TGG 58.8938 TGT 48.5616 TTA 163.0428 TTC 90.7171 TTG 145.0647 TTT 196.5193 end consensus type CDS phase 1 begin consensus AAA 234.9249 AAC 117.7724 AAG 221.908 AAT 133.0621 ACA 116.7393 ACC 50.4148 ACG 81.6142 ACT 75.6223 AGA 108.6812 AGC 97.937 AGG 113.4334 AGT 73.5561 ATA 169.427 ATC 136.5747 ATG 253.9338 ATT 167.5674 CAA 120.0452 CAC 66.7377 CAG 102.8959 CAT 78.1017 CCA 99.7966 CCC 45.6626 CCG 72.7296 CCT 59.5061 CGA 43.5964 CGC 22.728 CGG 37.8111 CGT 30.9927 CTA 166.1211 CTC 141.3269 CTG 215.7094 CTT 157.6497 GAA 86.573 GAC 38.431 GAG 54.5472 GAT 44.0097 GCA 61.5722 GCC 35.5383 GCG 47.5222 GCT 41.117 GGA 40.7038 GGC 24.5876 GGG 33.4722 GGT 31.406 GTA 107.6481 GTC 79.1348 GTG 150.4181 GTT 89.4657 TAA 114.0533 TAC 76.862 TAG 96.4907 TAT 76.6554 TCA 89.6723 TCC 59.5061 TCG 76.0355 TCT 60.3325 TGA 103.7224 TGC 66.5311 TGG 120.8717 TGT 64.0517 TTA 199.3866 TTC 168.6005 TTG 265.2978 TTT 181.2042 end consensus type CDS phase 2 begin consensus AAA 231.6265 AAC 94.221 AAG 74.5916 AAT 155.1753 ACA 92.1547 ACC 74.385 ACG 56.6152 ACT 76.6578 AGA 200.2195 AGC 100.2131 AGG 77.2777 AGT 98.1468 ATA 54.549 ATC 103.5191 ATG 37.8124 ATT 135.7526 CAA 159.1012 CAC 66.5332 CAG 39.4654 CAT 102.6926 CCA 61.3676 CCC 45.4575 CCG 38.4322 CCT 45.8707 CGA 120.4623 CGC 46.0774 CGG 51.6562 CGT 59.7146 CTA 34.2997 CTC 69.426 CTG 25.4149 CTT 107.445 GAA 129.3472 GAC 50.2099 GAG 42.1515 GAT 75.0048 GCA 76.038 GCC 44.8376 GCG 33.06 GCT 57.855 GGA 138.2321 GGC 56.8219 GGG 46.0774 GGT 64.467 GTA 37.3991 GTC 52.4827 GTG 17.5631 GTT 92.568 TAA 224.8079 TAC 145.8772 TAG 80.7903 TAT 191.128 TCA 155.5886 TCC 139.6784 TCG 111.7841 TCT 118.6027 TGA 342.1709 TGC 191.5413 TGG 174.1848 TGT 177.4908 TTA 98.9733 TTC 177.0775 TTG 59.508 TTT 260.3474 end consensus type Intron_Corr_Term phase all 225.12 type Intron_Corr_Term phase 0 524.049 type Intron_Corr_Term phase 1 652.388 type Intron_Corr_Term phase 2 998.969 type Intron_emission begin consensus A 123.3115 C 59.5593 G 67.0399 T 150.0893 end consensus type Pyrimidine_emission begin consensus A 26.1549 C 86.9936 G 12.7932 T 274.0583 end consensus type Spacer_emission begin consensus A 149.5231 C 60.7484 G 51.3573 T 138.3712 end consensus type Intron_Stay_Prob 0.988929 type Central_Intron_Stay_Prob 0.983466 type Pyrimidine_Stay_Prob 0.904578 type No_Spacer_Prob 0.0743243 type Spacer_Stay_Prob 0.952081 wise-2.4.1/wisecfg/wag550000644000175000001440000001013207472455567014375 0ustar philippusers# # WAG matrix from Wheelan and Goldman at 85% id # Rows sum to 1 A R N D C Q E G H I L K M F P S T W Y V 0.50493 0.015148 0.015792 0.024503 0.010041 0.017396 0.0389 0.05571 0.0058002 0.013239 0.021759 0.029039 0.0083419 0.0059471 0.031166 0.083925 0.05561 0.001593 0.0060437 0.05512 0.029843 0.54463 0.017754 0.010729 0.0054799 0.045411 0.022624 0.027142 0.022965 0.0075331 0.023396 0.12395 0.0070529 0.0041592 0.017473 0.038508 0.022449 0.0078979 0.0083105 0.01269 0.034998 0.019972 0.40695 0.10638 0.0037826 0.026112 0.038214 0.045904 0.034561 0.012107 0.010891 0.067707 0.0037022 0.0048246 0.01024 0.090799 0.051509 0.0014578 0.017444 0.012446 0.037209 0.00827 0.072893 0.55042 0.0013337 0.019638 0.12725 0.03965 0.012883 0.0037402 0.0069276 0.026109 0.0021679 0.0024262 0.012582 0.038901 0.019211 0.00138 0.0074016 0.0096052 0.04505 0.01248 0.007658 0.0039405 0.72917 0.0040415 0.0042908 0.017343 0.0041197 0.0093249 0.020646 0.0066132 0.0047968 0.0095511 0.0054864 0.043863 0.020147 0.0057833 0.0109 0.03479 0.041032 0.054368 0.027791 0.030501 0.0021246 0.42387 0.10495 0.01982 0.037678 0.0076057 0.033709 0.090907 0.011617 0.0043616 0.02155 0.035287 0.028174 0.0022265 0.007026 0.015399 0.058041 0.017134 0.025728 0.12503 0.0014269 0.066391 0.47478 0.028843 0.010272 0.0066042 0.011738 0.064341 0.0043877 0.0029658 0.017569 0.030583 0.026869 0.001576 0.0051377 0.020587 0.057969 0.014336 0.021554 0.027169 0.0040222 0.0087439 0.020115 0.7295 0.0046701 0.0029386 0.0056471 0.016112 0.0024277 0.0020788 0.0088248 0.043894 0.01382 0.0028292 0.0033001 0.010046 0.020566 0.041333 0.055297 0.03008 0.0032558 0.056642 0.024411 0.015914 0.53116 0.0064392 0.023685 0.034558 0.005008 0.016643 0.017077 0.030068 0.019155 0.0031166 0.056853 0.0087402 0.023664 0.0068346 0.0097645 0.0044022 0.0037148 0.0057637 0.0079114 0.0050478 0.003246 0.48061 0.11951 0.012562 0.031956 0.021791 0.0054216 0.015706 0.038725 0.0025437 0.0093217 0.19151 0.021865 0.011934 0.0049384 0.0045841 0.0046241 0.014361 0.0079049 0.0054534 0.0067123 0.067186 0.64186 0.011635 0.037042 0.038371 0.010741 0.014607 0.015262 0.0053783 0.0106 0.064945 0.040555 0.08787 0.042668 0.024011 0.0020585 0.053827 0.060223 0.021625 0.013611 0.0098157 0.01617 0.50337 0.0082684 0.0033302 0.015555 0.036775 0.03841 0.0018961 0.0048277 0.015131 0.037053 0.015902 0.0074204 0.0063409 0.0047489 0.021877 0.013062 0.010363 0.0062736 0.079413 0.16374 0.026298 0.4314 0.024041 0.0074007 0.021025 0.038544 0.0042612 0.0097354 0.071096 0.013405 0.0047588 0.0049071 0.0036013 0.0047984 0.0041682 0.0044804 0.0045031 0.01058 0.02748 0.086072 0.0053749 0.0122 0.64009 0.0055669 0.018706 0.0093194 0.012122 0.099842 0.028021 0.058996 0.016789 0.0087469 0.015684 0.0023148 0.017295 0.02229 0.016054 0.0091167 0.0057418 0.020234 0.021084 0.0031539 0.0046751 0.67813 0.050059 0.027707 0.0015359 0.0053827 0.015012 0.10458 0.024358 0.051056 0.031922 0.012182 0.018643 0.025542 0.052565 0.010567 0.01095 0.018114 0.032813 0.0058983 0.010341 0.032953 0.43084 0.091781 0.0037916 0.013291 0.017809 0.078957 0.016179 0.033 0.017962 0.0063757 0.01696 0.025568 0.018857 0.0076703 0.030761 0.021565 0.039049 0.012321 0.0058703 0.020782 0.10457 0.48975 0.0015808 0.0071713 0.045043 0.0095924 0.024141 0.0039613 0.0054722 0.0077619 0.0056845 0.0063604 0.016372 0.0052929 0.0085696 0.03223 0.0081754 0.0057769 0.032383 0.004886 0.018322 0.0067045 0.73897 0.043982 0.015364 0.014842 0.01036 0.01933 0.01197 0.0059663 0.0073156 0.0084562 0.0077886 0.039377 0.012808 0.025905 0.0084893 0.0053826 0.10878 0.0069833 0.026194 0.012404 0.017937 0.63467 0.015043 0.067351 0.007871 0.006862 0.0077286 0.0094749 0.0079775 0.016859 0.011797 0.003012 0.13092 0.078973 0.013238 0.019558 0.01519 0.0096904 0.017462 0.038764 0.0031175 0.0074845 0.52667 wise-2.4.1/wisecfg/wag650000644000175000001440000001022307472455567014377 0ustar philippusers# # WAG matrix from Wheelan and Goldman at 85% id # Rows sum to 1 A R N D C Q E G H I L K M F P S T W Y V 0.61284 0.01101 0.011113 0.018135 0.0076918 0.01323 0.031183 0.043464 0.0040281 0.00862 0.015678 0.022082 0.006454 0.0041318 0.024322 0.070737 0.044673 0.0010472 0.0042329 0.045322 0.021691 0.64901 0.012706 0.0067382 0.0041108 0.036989 0.015556 0.020172 0.018302 0.0051074 0.017491 0.10366 0.0053343 0.0026903 0.012995 0.030247 0.016163 0.0061619 0.0060195 0.008855 0.024628 0.014293 0.52621 0.09085 0.0026427 0.02048 0.027729 0.035389 0.02918 0.0094183 0.0071914 0.056719 0.0024884 0.003075 0.0066909 0.078313 0.041691 0.00091157 0.013728 0.0083726 0.027539 0.005194 0.062254 0.65123 0.00077564 0.013705 0.10781 0.029681 0.0096221 0.0022285 0.0044909 0.018009 0.0013906 0.0014899 0.0090049 0.029642 0.013233 0.00094803 0.0053242 0.0064261 0.034511 0.0093619 0.0053502 0.0022916 0.80091 0.0025905 0.0024444 0.012286 0.0029079 0.0060737 0.014901 0.0041022 0.0034541 0.0068995 0.0035349 0.03465 0.014559 0.0043035 0.0080724 0.026792 0.031205 0.044284 0.021797 0.021286 0.0013618 0.54235 0.090622 0.013874 0.031798 0.0048444 0.026527 0.075721 0.0095482 0.0028 0.016475 0.027128 0.021249 0.0015545 0.0047758 0.010802 0.046527 0.011782 0.018669 0.10593 0.0008129 0.057328 0.58494 0.021005 0.0072789 0.0043089 0.007892 0.052484 0.0031062 0.0019243 0.013062 0.022343 0.020224 0.0010968 0.0035426 0.01575 0.045226 0.010654 0.016616 0.020338 0.0028494 0.0061208 0.014649 0.79996 0.0032217 0.0017221 0.0035965 0.011378 0.0016863 0.0013182 0.0060443 0.034236 0.0091845 0.0020776 0.0021874 0.006932 0.014283 0.032941 0.046687 0.022467 0.0022981 0.047803 0.017298 0.010978 0.6395 0.004241 0.017662 0.025373 0.0036178 0.012062 0.012839 0.022324 0.013738 0.0021235 0.046116 0.005648 0.015407 0.0046338 0.0075961 0.002623 0.0024196 0.0036711 0.0051618 0.0029582 0.0021378 0.58878 0.095396 0.0090453 0.026406 0.016424 0.0034465 0.011041 0.030843 0.0017276 0.0067122 0.16357 0.015754 0.0089215 0.0032607 0.0029716 0.0033374 0.011302 0.005315 0.0034732 0.0050053 0.053631 0.72803 0.0081397 0.03054 0.029976 0.0079469 0.010567 0.010616 0.0039945 0.0073711 0.049848 0.03084 0.073488 0.035743 0.016562 0.0012769 0.044835 0.049125 0.015272 0.0099936 0.0070675 0.011313 0.6114 0.0064959 0.0021553 0.011332 0.027757 0.030253 0.0012565 0.0031579 0.010681 0.028668 0.012027 0.0049876 0.0040674 0.0034196 0.017981 0.0092471 0.0071985 0.004532 0.065621 0.135 0.02066 0.55159 0.018241 0.0049241 0.015383 0.031037 0.0031415 0.0069738 0.055307 0.0093134 0.0030781 0.0031277 0.0022115 0.0034662 0.0026759 0.002907 0.0028554 0.007668 0.020712 0.06724 0.0034786 0.0092564 0.72826 0.0038323 0.014304 0.0062551 0.0090792 0.079831 0.020451 0.04604 0.012486 0.0057152 0.011225 0.0014914 0.013222 0.016572 0.010996 0.0068544 0.00365 0.014971 0.015359 0.0020985 0.0032184 0.7604 0.039619 0.020609 0.001052 0.0037667 0.010655 0.088147 0.019132 0.044035 0.024324 0.0096237 0.014332 0.01866 0.040999 0.0078454 0.0076973 0.013104 0.024767 0.0043154 0.007908 0.026081 0.54554 0.078424 0.0028852 0.01029 0.011895 0.063429 0.011648 0.026711 0.012373 0.0046073 0.012791 0.019245 0.012532 0.0055009 0.024501 0.015001 0.030757 0.0099211 0.0039401 0.015458 0.089356 0.60069 0.0010352 0.0050633 0.035439 0.006306 0.018835 0.0024769 0.0037593 0.0057759 0.0039687 0.0044264 0.012023 0.0036064 0.0058202 0.023937 0.0054177 0.0042588 0.024255 0.0033466 0.013942 0.0043905 0.80847 0.033799 0.011189 0.010395 0.0075037 0.015212 0.0086102 0.0044185 0.0049726 0.0058308 0.0051625 0.03194 0.0092224 0.018015 0.005553 0.0038557 0.086977 0.0048867 0.02028 0.0087578 0.013784 0.72398 0.010637 0.055379 0.0054922 0.0046164 0.0051707 0.0072966 0.0055961 0.012898 0.0081402 0.0019464 0.11182 0.060615 0.0093453 0.015214 0.011086 0.0068776 0.011663 0.030499 0.0022704 0.0052925 0.62878 wise-2.4.1/wisecfg/wag750000644000175000001440000001034007472455567014400 0ustar philippusers# # WAG matrix from Wheelan and Goldman at 75% id # Rows sum to 1 A R N D C Q E G H I L K M F P S T W Y V 0.72236 0.0073771 0.0071265 0.012353 0.005409 0.0092423 0.022865 0.031067 0.0025878 0.0050247 0.010451 0.015446 0.0045932 0.0026633 0.017379 0.054031 0.032687 0.00063635 0.0027487 0.033949 0.014533 0.75146 0.0083091 0.0038833 0.002847 0.027403 0.0097449 0.013849 0.013311 0.0032075 0.012073 0.078448 0.0037115 0.0016088 0.0089121 0.021815 0.010699 0.0044056 0.004036 0.0057424 0.015793 0.009347 0.65362 0.070111 0.0017058 0.014719 0.018296 0.025064 0.022302 0.0067838 0.0043877 0.043176 0.0015307 0.0017853 0.0039821 0.061057 0.030735 0.00052026 0.0098958 0.0051914 0.018759 0.0029934 0.048043 0.75144 0.00040822 0.0086638 0.082561 0.020461 0.0065982 0.0012043 0.0027231 0.011312 0.00082613 0.00084592 0.0059694 0.020713 0.0083499 0.00060834 0.0035396 0.0039798 0.024268 0.0064837 0.0034534 0.0012061 0.86472 0.0015329 0.0012387 0.0080626 0.001907 0.0036146 0.0099665 0.0023257 0.0023046 0.0046145 0.0021004 0.025067 0.0096929 0.0029529 0.00552 0.018972 0.021799 0.032807 0.015665 0.013456 0.00080585 0.66716 0.070592 0.0089885 0.024281 0.0027972 0.019166 0.057177 0.0071595 0.0016545 0.011586 0.019175 0.014732 0.0010072 0.0029829 0.0070043 0.034116 0.0073805 0.012318 0.08112 0.00041192 0.044656 0.69939 0.014131 0.0047218 0.0025822 0.0049031 0.038998 0.0020243 0.001167 0.0089559 0.014995 0.014024 0.00071256 0.0022736 0.011122 0.032327 0.0073149 0.011769 0.01402 0.0018699 0.0039654 0.0098549 0.86336 0.002059 0.00091967 0.0021334 0.0074332 0.0010913 0.00077926 0.0038354 0.024485 0.0055889 0.0014113 0.0013472 0.0044391 0.0091756 0.023957 0.035683 0.015406 0.0015071 0.036503 0.011221 0.0070161 0.74536 0.0025842 0.012166 0.01705 0.0024134 0.0080479 0.0089 0.015212 0.0090823 0.0013372 0.034003 0.0033795 0.008981 0.0029101 0.0054713 0.0014174 0.00144 0.0021197 0.0030933 0.0015798 0.0013027 0.70162 0.069476 0.006042 0.019824 0.011394 0.002017 0.0071815 0.022472 0.0010856 0.0044796 0.1261 0.010502 0.006158 0.0019895 0.0018019 0.0022322 0.0081653 0.0033021 0.0020602 0.0034477 0.039059 0.80988 0.0052661 0.022848 0.021434 0.0054391 0.0070962 0.0068056 0.0027385 0.0047342 0.035039 0.021572 0.055612 0.027208 0.010403 0.00072393 0.033856 0.036502 0.0099764 0.0067156 0.0047209 0.007319 0.72111 0.0046839 0.0013012 0.0076238 0.019202 0.021824 0.00076789 0.0019032 0.0069729 0.020402 0.0083682 0.0030679 0.0024164 0.0022816 0.013483 0.0060262 0.0046586 0.0030232 0.049263 0.101 0.014897 0.6761 0.012716 0.0030197 0.010361 0.022846 0.0021417 0.0046291 0.039299 0.0060033 0.0018407 0.0018159 0.0012556 0.0023183 0.0015812 0.0017629 0.001688 0.0051161 0.014369 0.04808 0.0021001 0.0064527 0.81102 0.0024539 0.010102 0.0038793 0.0062582 0.058128 0.013774 0.032899 0.0085633 0.0034013 0.007441 0.00088619 0.0092988 0.011362 0.0069773 0.0047514 0.0021361 0.010246 0.010333 0.0012869 0.0020608 0.83544 0.028695 0.014098 0.0006709 0.002448 0.0070067 0.067329 0.013799 0.034332 0.016997 0.0069621 0.010131 0.012523 0.029322 0.005346 0.0050067 0.0088 0.017134 0.0029068 0.0055846 0.01889 0.66786 0.060527 0.0020277 0.0073253 0.0072011 0.04641 0.0077111 0.019691 0.0078069 0.0030674 0.0088684 0.013345 0.007626 0.0036368 0.017851 0.0096161 0.022187 0.0073026 0.0024436 0.010575 0.068964 0.71344 0.00062704 0.003306 0.025521 0.0038319 0.013466 0.0014137 0.0024123 0.0039632 0.0025714 0.0028758 0.0081675 0.0022709 0.0036574 0.016411 0.003311 0.0029034 0.016719 0.0021342 0.0097988 0.0026594 0.87005 0.023821 0.0075625 0.0067505 0.0050312 0.010966 0.0057243 0.0030214 0.0031058 0.0037421 0.0031797 0.023551 0.0061549 0.01157 0.0033466 0.0025594 0.063331 0.0031759 0.014437 0.0057183 0.0097149 0.80794 0.0069843 0.041483 0.0035616 0.0028624 0.0032023 0.0051669 0.0036287 0.0091084 0.0052128 0.0011646 0.086203 0.042607 0.0061008 0.010811 0.007467 0.0045228 0.0070611 0.021963 0.0015346 0.0034751 0.73286 wise-2.4.1/wisecfg/wag850000644000175000001440000001050207472455567014401 0ustar philippusers# # WAG matrix from Wheelan and Goldman at 85% id # Rows sum to 1 A R N D C Q E G H I L K M F P S T W Y V 0.83293 0.0041645 0.0038065 0.0070817 0.0031949 0.005425 0.014039 0.018624 0.0014046 0.0023729 0.0058862 0.009089 0.002749 0.0014531 0.010411 0.034325 0.019973 0.0003257 0.0015102 0.021229 0.0082043 0.85212 0.004542 0.0018713 0.0016627 0.016937 0.0050784 0.0080232 0.0080967 0.0017023 0.0070279 0.049349 0.0021723 0.00081022 0.0051512 0.013213 0.0059548 0.0026422 0.0022872 0.0031578 0.0084359 0.0051093 0.78787 0.044915 0.00092857 0.0088737 0.01005 0.014918 0.014168 0.0041245 0.0022547 0.027383 0.00078554 0.00085711 0.0019643 0.039506 0.018919 0.0002458 0.0059807 0.0027074 0.010754 0.0014425 0.030777 0.85117 0.00017472 0.0045329 0.052507 0.011877 0.0038013 0.00053175 0.0014075 0.0059092 0.00041447 0.0004036 0.0033468 0.012148 0.0044085 0.00033219 0.0019862 0.0020807 0.014334 0.0037866 0.0018799 0.00051621 0.92239 0.00076252 0.00049435 0.0044744 0.00106 0.0017891 0.0056385 0.0010934 0.0013006 0.0026087 0.0010483 0.015202 0.0054344 0.0017076 0.003184 0.011296 0.012796 0.020277 0.0094442 0.0070404 0.00040085 0.79715 0.045587 0.0049208 0.015408 0.0013275 0.011624 0.035931 0.0044846 0.00081909 0.0068539 0.011398 0.0085883 0.00055252 0.0015623 0.0038337 0.020947 0.0038462 0.0067665 0.05159 0.0001644 0.028838 0.81741 0.0080237 0.0025644 0.0012946 0.0025667 0.024196 0.0011092 0.0006026 0.005175 0.0084574 0.0081911 0.0003938 0.0012389 0.0066205 0.01938 0.0042377 0.0070045 0.008138 0.0010377 0.0021709 0.0055956 0.92124 0.0011125 0.00040396 0.0010729 0.0041019 0.00059985 0.00039086 0.0020575 0.014695 0.0028392 0.00080976 0.00070272 0.0024066 0.0049803 0.014573 0.022669 0.0088757 0.0008377 0.023163 0.006094 0.0037909 0.84885 0.001328 0.0070691 0.0096004 0.001358 0.0045206 0.0051982 0.0087034 0.0050592 0.00071033 0.020912 0.0017064 0.0042413 0.0015444 0.0033266 0.00062587 0.00071275 0.001006 0.0015508 0.0006939 0.00066943 0.81844 0.042314 0.0034167 0.012404 0.0066536 0.00098916 0.003948 0.013712 0.00057586 0.0025293 0.080648 0.0059148 0.0035847 0.0010223 0.00093134 0.0012628 0.0049525 0.0017286 0.0010361 0.0020034 0.023789 0.88815 0.0028763 0.014238 0.012847 0.003144 0.0040368 0.0036724 0.0015833 0.002565 0.020657 0.012694 0.034983 0.017256 0.0054344 0.00034035 0.021275 0.022648 0.0055053 0.0037813 0.0026696 0.0039976 0.83204 0.0028349 0.00066777 0.0043283 0.011144 0.013198 0.00039457 0.00096307 0.0038436 0.012211 0.0048977 0.0015745 0.0012123 0.0012876 0.0084456 0.0033019 0.0025606 0.0017012 0.030824 0.062936 0.0090163 0.80387 0.0074514 0.0015566 0.0058729 0.014073 0.001233 0.0025995 0.023374 0.0032754 0.00092702 0.00087177 0.00059908 0.0013106 0.00078278 0.00091035 0.00084668 0.0028738 0.0083907 0.028818 0.0010778 0.0037813 0.88935 0.0013326 0.0060149 0.0020276 0.0036307 0.035355 0.0078247 0.019708 0.0049496 0.0016778 0.0041718 0.00044228 0.0055007 0.0065655 0.003743 0.0027751 0.0010476 0.0059228 0.0058666 0.00066336 0.0011191 0.90471 0.017414 0.0081129 0.00036312 0.0013479 0.0038973 0.042773 0.0083579 0.022214 0.0099681 0.0042221 0.0060218 0.0070633 0.017598 0.0030587 0.0027525 0.005006 0.0099433 0.0016476 0.0033252 0.011463 0.79664 0.038765 0.0012019 0.0043835 0.003597 0.028359 0.0042916 0.012121 0.0041219 0.0017197 0.0051699 0.0077946 0.0038741 0.0020258 0.010892 0.0051889 0.013418 0.0044985 0.0012772 0.0060851 0.044169 0.82745 0.00032009 0.0018226 0.015403 0.0019613 0.008076 0.00066789 0.0013172 0.0022918 0.0014106 0.0015893 0.0046861 0.0012063 0.0019401 0.0094883 0.0017013 0.0016716 0.0096994 0.0011551 0.0058078 0.0013575 0.92555 0.014094 0.004328 0.0037087 0.0028512 0.0066275 0.0032121 0.0017428 0.0016267 0.0020392 0.0016585 0.014484 0.0034752 0.0062688 0.0016935 0.0014373 0.03852 0.0017487 0.008639 0.0031526 0.0057481 0.88748 0.0038853 0.02594 0.0019586 0.0014928 0.0016742 0.0030765 0.0019861 0.0054217 0.0028261 0.00058805 0.055133 0.025119 0.0033628 0.0064299 0.0042417 0.0025157 0.0035271 0.013255 0.00087822 0.0019331 0.83864 wise-2.4.1/wisecfg/idenity.bla0000644000175000001440000000550307313404523015631 0ustar philippusers# made by ewan's routine...blast like format A B C D E F G H I J K L M N O P Q R S T U V W X Y Z * 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 wise-2.4.1/wisecfg/gon350.bla0000644000175000001440000000472107313404522015177 0ustar philippusers# benner-gonnet matrix # ppam := 350 # print (DayhoffM (NewLogPAM1, pam)); # DayMatrix(Peptide, pam=350, Simil: max=12.362, min=-3.511, max offdiag=4.155, # del=-18.727-1.396*(k-1)) A R N D C Q E G H I L K M F P S T W Y V * 1.0 -0.2 0.0 0.0 0.4 0.0 0.1 0.5 -0.4 -0.4 -0.7 -0.1 -0.4 -1.4 0.3 0.6 0.4 -2.4 -1.4 0.0 -3.5 -0.2 2.8 0.4 0.2 -1.3 1.0 0.6 -0.4 0.6 -1.5 -1.4 1.8 -1.1 -2.0 -0.4 0.1 0.0 -1.2 -1.2 -1.2 -3.5 0.0 0.4 2.0 1.5 -1.1 0.6 0.9 0.5 0.8 -1.8 -1.9 0.7 -1.4 -2.0 -0.3 0.6 0.4 -2.4 -1.0 -1.3 -3.5 0.0 0.2 1.5 2.9 -1.9 0.8 1.9 0.4 0.5 -2.4 -2.5 0.6 -1.9 -3.0 -0.2 0.5 0.2 -3.5 -1.8 -1.8 -3.5 0.4 -1.3 -1.1 -1.9 9.3 -1.4 -1.7 -1.2 -0.8 -0.5 -0.7 -1.6 -0.4 -0.3 -1.8 0.1 -0.2 -0.4 -0.1 0.2 -3.5 0.0 1.0 0.6 0.8 -1.4 1.2 1.1 -0.4 0.7 -1.1 -1.1 1.0 -0.7 -1.6 0.0 0.2 0.1 -1.9 -1.1 -0.9 -3.5 0.1 0.6 0.9 1.9 -1.7 1.1 2.0 -0.2 0.4 -1.7 -1.8 0.9 -1.3 -2.5 0.0 0.3 0.1 -2.9 -1.7 -1.2 -3.5 0.5 -0.4 0.5 0.4 -1.2 -0.4 -0.2 5.1 -0.7 -2.9 -3.0 -0.4 -2.3 -3.5 -0.7 0.5 -0.5 -3.0 -2.7 -2.1 -3.5 -0.4 0.6 0.8 0.5 -0.8 0.7 0.4 -0.7 3.3 -1.3 -1.1 0.5 -0.8 0.1 -0.5 0.0 -0.1 -0.3 1.5 -1.1 -3.5 -0.4 -1.5 -1.8 -2.4 -0.5 -1.1 -1.7 -2.9 -1.3 2.7 2.2 -1.3 1.9 1.1 -1.6 -1.1 -0.3 -0.9 -0.1 2.2 -3.5 -0.7 -1.4 -1.9 -2.5 -0.7 -1.1 -1.8 -3.0 -1.1 2.2 2.8 -1.4 2.1 1.8 -1.5 -1.3 -0.7 -0.1 0.5 1.6 -3.5 -0.1 1.8 0.7 0.6 -1.6 1.0 0.9 -0.4 0.5 -1.3 -1.4 1.8 -0.9 -2.1 -0.2 0.2 0.2 -2.3 -1.4 -1.0 -3.5 -0.4 -1.1 -1.4 -1.9 -0.4 -0.7 -1.3 -2.3 -0.8 1.9 2.1 -0.9 2.3 1.4 -1.4 -0.9 -0.4 -0.3 0.2 1.4 -3.5 -1.4 -2.0 -2.0 -3.0 -0.3 -1.6 -2.5 -3.5 0.1 1.1 1.8 -2.1 1.4 5.1 -2.5 -1.8 -1.3 3.5 4.2 0.5 -3.5 0.3 -0.4 -0.3 -0.2 -1.8 0.0 0.0 -0.7 -0.5 -1.6 -1.5 -0.2 -1.4 -2.5 5.6 0.4 0.2 -3.4 -2.0 -1.1 -3.5 0.6 0.1 0.6 0.5 0.1 0.2 0.3 0.5 0.0 -1.1 -1.3 0.2 -0.9 -1.8 0.4 1.0 0.8 -2.2 -1.2 -0.6 -3.5 0.4 0.0 0.4 0.2 -0.2 0.1 0.1 -0.5 -0.1 -0.3 -0.7 0.2 -0.4 -1.3 0.2 0.8 1.1 -2.3 -1.2 0.0 -3.5 -2.4 -1.2 -2.4 -3.5 -0.4 -1.9 -2.9 -3.0 -0.3 -0.9 -0.1 -2.3 -0.3 3.5 -3.4 -2.2 -2.3 12.4 3.9 -1.4 -3.5 -1.4 -1.2 -1.0 -1.8 -0.1 -1.1 -1.7 -2.7 1.5 -0.1 0.5 -1.4 0.2 4.2 -2.0 -1.2 -1.2 3.9 5.7 -0.4 -3.5 0.0 -1.2 -1.3 -1.8 0.2 -0.9 -1.2 -2.1 -1.1 2.2 1.6 -1.0 1.4 0.5 -1.1 -0.6 0.0 -1.4 -0.4 2.1 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 -3.5 1 wise-2.4.1/wisecfg/pombe.gf0000644000175000001440000005227207313404523015131 0ustar philippusers# Splice sites and intron regions information for GeneWise-21 # Fri May 15 13:20:38 IDT 1998 # Created by Mor Amitai (mor@compugen.co.il) # dataset : ~/ftp/pub/PomBase/temp/cds_cdna ~/ftp/pub/PomBase/temp/cds_ex # Consensi are read from top down. The value, for a sequence, # is the number in the line of the first consensus that # matches the sequence. # Note: the set of sequences that are represented by a consensus # are all the sequences that match this consensus and none of the # previous consensi # # the numbers in types 5SS, 3SS, CDS, and the emissions are the number of # occurrences of each sequence in the database. # In case of a consensus this is the number of occurrences of sequences # that are represented by the consensus in the database divided by the # number of sequences that are represented by the consensus. # *stay_prob is the probability of the transition from the state to itself. # No_Spacer_Prob is the probability of transition from Pyrimidine directly # to 3SS (no spacer). type 5SS center 3 phase all begin consensus ---GTA-GT- 0.0869141 ---GT----- 0.000821553 end consensus type 5SS center 3 phase 0 begin consensus ---GTA-GT- 0.0371094 ---GT----- 0.000356523 end consensus type 5SS center 3 phase 1 begin consensus ---GTA-GT- 0.0292969 ---GT----- 0.000294519 end consensus type 5SS center 3 phase 2 begin consensus ---GT----- 0.000488281 end consensus type 5SS_codon phase all begin consensus AAA 1.864078 AAC 0.621359 AAG 6.524272 AAT 1.864078 AAN 2.71845 ACA 0.932039 ACC 0.310680 ACG 1.553398 ACT 0.932039 ACN 0.932039 AGA 1.553398 AGC 0.310680 AGG 1.553398 AGT 1.864078 AGN 1.32039 ATA 0.932039 ATC 0.621359 ATG 2.796117 ATT 1.553398 ATN 1.47573 ANA 1.32039 ANC 0.46602 ANG 3.1068 ANT 1.5534 ANN 1.61165 CAA 1.242718 CAC 0.310680 CAG 3.417476 CAT 0.621359 CAN 1.39806 CCA 0.310680 CCC 0.310680 CCG 0.621359 CCT 0.310680 CCN 0.38835 CGA 0.621359 CGC 0.310680 CGG 1.242718 CGT 0.310680 CGN 0.621359 CTA 0.310680 CTC 0.310680 CTG 1.864078 CTT 0.621359 CTN 0.776699 CNA 0.621359 CNC 0.31068 CNG 1.78641 CNT 0.46602 CNN 0.796117 GAA 0.310680 GAC 0.621359 GAG 3.106796 GAT 1.242718 GAN 1.32039 GCA 0.621359 GCC 0.621359 GCG 0.310680 GCT 0.621359 GCN 0.543689 GGA 0.310680 GGC 0.310680 GGG 0.310680 GGT 0.310680 GGN 0.31068 GTA 0.310680 GTC 0.310680 GTG 0.932039 GTT 0.310680 GTN 0.46602 GNA 0.38835 GNC 0.46602 GNG 1.16505 GNT 0.621359 GNN 0.660194 TAA 0.621359 TAC 0.932039 TAG 0.932039 TAT 0.621359 TAN 0.776699 TCA 0.621359 TCC 0.310680 TCG 0.621359 TCT 0.932039 TCN 0.621359 TGA 0.621359 TGC 0.621359 TGG 1.242718 TGT 0.621359 TGN 0.776699 TTA 0.621359 TTC 0.621359 TTG 3.106796 TTT 1.864078 TTN 1.5534 TNA 0.621359 TNC 0.621359 TNG 1.47573 TNT 1.00971 TNN 0.932039 NAA 1.00971 NAC 0.621359 NAG 3.49515 NAT 1.08738 NAN 1.5534 NCA 0.621359 NCC 0.38835 NCG 0.776699 NCT 0.699029 NCN 0.621359 NGA 0.776699 NGC 0.38835 NGG 1.08738 NGT 0.776699 NGN 0.757282 NTA 0.543689 NTC 0.46602 NTG 2.17476 NTT 1.08738 NTN 1.06796 NNA 0.737864 NNC 0.46602 NNG 1.8835 NNT 0.912621 NNN 1 end consensus type 5SS_codon phase 0 begin consensus AAA 0.512000 AAC 0.512000 AAG 6.144000 AAT 1.536000 AAN 2.176 ACA 1.024000 ACC 0.512000 ACG 0.512000 ACT 0.512000 ACN 0.64 AGA 0.512000 AGC 0.512000 AGG 1.536000 AGT 1.024000 AGN 0.896 ATA 0.512000 ATC 0.512000 ATG 2.048000 ATT 1.536000 ATN 1.152 ANA 0.64 ANC 0.512 ANG 2.56 ANT 1.152 ANN 1.216 CAA 1.024000 CAC 0.512000 CAG 4.608000 CAT 1.024000 CAN 1.792 CCA 0.512000 CCC 0.512000 CCG 1.024000 CCT 0.512000 CCN 0.64 CGA 0.512000 CGC 0.512000 CGG 1.024000 CGT 0.512000 CGN 0.64 CTA 0.512000 CTC 0.512000 CTG 1.536000 CTT 1.024000 CTN 0.896 CNA 0.64 CNC 0.512 CNG 2.048 CNT 0.768 CNN 0.992 GAA 0.512000 GAC 0.512000 GAG 4.096000 GAT 1.536000 GAN 1.664 GCA 1.024000 GCC 1.024000 GCG 0.512000 GCT 1.024000 GCN 0.896 GGA 0.512000 GGC 0.512000 GGG 0.512000 GGT 0.512000 GGN 0.512 GTA 0.512000 GTC 0.512000 GTG 1.536000 GTT 0.512000 GTN 0.768 GNA 0.64 GNC 0.64 GNG 1.664 GNT 0.896 GNN 0.96 TAA 0.512000 TAC 1.536000 TAG 0.512000 TAT 0.512000 TAN 0.768 TCA 0.512000 TCC 0.512000 TCG 0.512000 TCT 1.536000 TCN 0.768 TGA 0.512000 TGC 0.512000 TGG 0.512000 TGT 0.512000 TGN 0.512 TTA 1.024000 TTC 0.512000 TTG 2.048000 TTT 1.536000 TTN 1.28 TNA 0.64 TNC 0.768 TNG 0.896 TNT 1.024 TNN 0.832 NAA 0.64 NAC 0.768 NAG 3.84 NAT 1.152 NAN 1.6 NCA 0.768 NCC 0.64 NCG 0.64 NCT 0.896 NCN 0.736 NGA 0.512 NGC 0.512 NGG 0.896 NGT 0.64 NGN 0.64 NTA 0.64 NTC 0.512 NTG 1.792 NTT 1.152 NTN 1.024 NNA 0.64 NNC 0.608 NNG 1.792 NNT 0.96 NNN 1 end consensus type 5SS_codon phase 1 begin consensus AAA 1.699115 AAC 0.566372 AAG 3.964602 AAT 1.132743 AAN 1.84071 ACA 1.132743 ACC 0.566372 ACG 2.265487 ACT 1.699115 ACN 1.41593 AGA 1.132743 AGC 0.566372 AGG 1.699115 AGT 1.132743 AGN 1.13274 ATA 1.699115 ATC 1.132743 ATG 2.831858 ATT 1.699115 ATN 1.84071 ANA 1.41593 ANC 0.707965 ANG 2.69027 ANT 1.41593 ANN 1.55752 CAA 1.132743 CAC 0.566372 CAG 1.132743 CAT 0.566372 CAN 0.849557 CCA 0.566372 CCC 0.566372 CCG 0.566372 CCT 0.566372 CCN 0.566372 CGA 0.566372 CGC 0.566372 CGG 1.699115 CGT 0.566372 CGN 0.849558 CTA 0.566372 CTC 0.566372 CTG 2.265487 CTT 0.566372 CTN 0.991151 CNA 0.707965 CNC 0.566372 CNG 1.41593 CNT 0.566372 CNN 0.814159 GAA 0.566372 GAC 1.132743 GAG 1.699115 GAT 0.566372 GAN 0.99115 GCA 0.566372 GCC 0.566372 GCG 0.566372 GCT 0.566372 GCN 0.566372 GGA 0.566372 GGC 0.566372 GGG 0.566372 GGT 0.566372 GGN 0.566372 GTA 0.566372 GTC 0.566372 GTG 0.566372 GTT 0.566372 GTN 0.566372 GNA 0.566372 GNC 0.707965 GNG 0.849558 GNT 0.566372 GNN 0.672567 TAA 0.566372 TAC 0.566372 TAG 0.566372 TAT 1.132743 TAN 0.707965 TCA 0.566372 TCC 0.566372 TCG 0.566372 TCT 0.566372 TCN 0.566372 TGA 0.566372 TGC 0.566372 TGG 1.699115 TGT 0.566372 TGN 0.849558 TTA 0.566372 TTC 0.566372 TTG 3.964602 TTT 1.699115 TTN 1.69912 TNA 0.566372 TNC 0.566372 TNG 1.69912 TNT 0.99115 TNN 0.955752 NAA 0.99115 NAC 0.707965 NAG 1.84071 NAT 0.849557 NAN 1.09735 NCA 0.707965 NCC 0.566372 NCG 0.991151 NCT 0.849558 NCN 0.778761 NGA 0.707965 NGC 0.566372 NGG 1.41593 NGT 0.707965 NGN 0.849558 NTA 0.849558 NTC 0.707965 NTG 2.40708 NTT 1.13274 NTN 1.27434 NNA 0.814159 NNC 0.637168 NNG 1.66372 NNT 0.884956 NNN 1 end consensus type 5SS_codon phase 2 begin consensus AAA 2.666667 AAC 1.333333 AAG 2.666667 AAT 2.000000 AAN 2.16667 ACA 0.666667 ACC 0.666667 ACG 1.333333 ACT 0.666667 ACN 0.833334 AGA 2.666667 AGC 0.666667 AGG 0.666667 AGT 2.666667 AGN 1.66667 ATA 0.666667 ATC 0.666667 ATG 1.333333 ATT 0.666667 ATN 0.833334 ANA 1.66667 ANC 0.833333 ANG 1.5 ANT 1.5 ANN 1.375 CAA 1.333333 CAC 0.666667 CAG 1.333333 CAT 0.666667 CAN 1 CCA 0.666667 CCC 0.666667 CCG 0.666667 CCT 0.666667 CCN 0.666667 CGA 1.333333 CGC 0.666667 CGG 0.666667 CGT 0.666667 CGN 0.833333 CTA 0.666667 CTC 0.666667 CTG 0.666667 CTT 0.666667 CTN 0.666667 CNA 1 CNC 0.666667 CNG 0.833333 CNT 0.666667 CNN 0.791667 GAA 0.666667 GAC 0.666667 GAG 0.666667 GAT 1.333333 GAN 0.833334 GCA 0.666667 GCC 0.666667 GCG 0.666667 GCT 0.666667 GCN 0.666667 GGA 0.666667 GGC 0.666667 GGG 0.666667 GGT 0.666667 GGN 0.666667 GTA 0.666667 GTC 0.666667 GTG 0.666667 GTT 0.666667 GTN 0.666667 GNA 0.666667 GNC 0.666667 GNG 0.666667 GNT 0.833333 GNN 0.708334 TAA 1.333333 TAC 0.666667 TAG 2.000000 TAT 0.666667 TAN 1.16667 TCA 1.333333 TCC 0.666667 TCG 1.333333 TCT 0.666667 TCN 1 TGA 1.333333 TGC 1.333333 TGG 1.333333 TGT 1.333333 TGN 1.33333 TTA 0.666667 TTC 1.333333 TTG 0.666667 TTT 1.333333 TTN 1 TNA 1.16667 TNC 1 TNG 1.33333 TNT 1 TNN 1.125 NAA 1.5 NAC 0.833333 NAG 1.66667 NAT 1.16667 NAN 1.29167 NCA 0.833334 NCC 0.666667 NCG 1 NCT 0.666667 NCN 0.791667 NGA 1.5 NGC 0.833334 NGG 0.833334 NGT 1.33333 NGN 1.125 NTA 0.666667 NTC 0.833334 NTG 0.833333 NTT 0.833334 NTN 0.791667 NNA 1.125 NNC 0.791667 NNG 1.08333 NNT 1 NNN 1 end consensus type 3SS center 3 phase all begin consensus TAG--- 1.64062 -AG--- 0.229167 end consensus type 3SS center 3 phase 0 begin consensus TAG--- 0.765625 -AG--- 0.09375 end consensus type 3SS center 3 phase 1 begin consensus TAG--- 0.515625 -AG--- 0.0885417 end consensus type 3SS center 3 phase 2 begin consensus -AG--- 0.125 end consensus type 3SS_codon phase all begin consensus AAA 1.802817 AAC 1.502347 AAG 0.300469 AAT 1.802817 AAN 1.35211 ACA 0.300469 ACC 1.802817 ACG 0.300469 ACT 0.901408 ACN 0.826291 AGA 0.600939 AGC 0.300469 AGG 0.600939 AGT 1.502347 AGN 0.751173 ATA 1.502347 ATC 2.103286 ATG 1.502347 ATT 2.103286 ATN 1.80282 ANA 1.05164 ANC 1.42723 ANG 0.676056 ANT 1.57746 ANN 1.1831 CAA 2.103286 CAC 0.300469 CAG 0.300469 CAT 1.201878 CAN 0.976526 CCA 0.600939 CCC 0.600939 CCG 0.901408 CCT 0.600939 CCN 0.676056 CGA 0.300469 CGC 0.300469 CGG 0.300469 CGT 0.901408 CGN 0.450704 CTA 0.901408 CTC 0.600939 CTG 1.201878 CTT 1.201878 CTN 0.976526 CNA 0.976526 CNC 0.450704 CNG 0.676056 CNT 0.976526 CNN 0.769953 GAA 1.802817 GAC 0.300469 GAG 1.201878 GAT 2.403756 GAN 1.42723 GCA 0.901408 GCC 0.300469 GCG 1.201878 GCT 1.502347 GCN 0.976526 GGA 0.901408 GGC 0.600939 GGG 0.600939 GGT 1.201878 GGN 0.826291 GTA 1.201878 GTC 1.502347 GTG 0.600939 GTT 1.502347 GTN 1.20188 GNA 1.20188 GNC 0.676056 GNG 0.901408 GNT 1.65258 GNN 1.10798 TAA 0.600939 TAC 0.300469 TAG 0.300469 TAT 1.502347 TAN 0.676056 TCA 1.201878 TCC 0.901408 TCG 0.901408 TCT 1.201878 TCN 1.05164 TGA 0.300469 TGC 0.300469 TGG 0.901408 TGT 1.502347 TGN 0.751173 TTA 0.600939 TTC 0.600939 TTG 1.201878 TTT 2.704225 TTN 1.277 TNA 0.676056 TNC 0.525821 TNG 0.826291 TNT 1.7277 TNN 0.938967 NAA 1.57746 NAC 0.600939 NAG 0.525821 NAT 1.7277 NAN 1.10798 NCA 0.751173 NCC 0.901408 NCG 0.826291 NCT 1.05164 NCN 0.882629 NGA 0.525821 NGC 0.375587 NGG 0.600939 NGT 1.277 NGN 0.694835 NTA 1.05164 NTC 1.20188 NTG 1.12676 NTT 1.87793 NTN 1.31455 NNA 0.976526 NNC 0.769953 NNG 0.769953 NNT 1.48357 NNN 1 end consensus type 3SS_codon phase 0 begin consensus AAA 1.465649 AAC 1.465649 AAG 0.488550 AAT 1.954198 AAN 1.34351 ACA 0.488550 ACC 1.954198 ACG 0.488550 ACT 0.977099 ACN 0.977099 AGA 0.488550 AGC 0.488550 AGG 0.488550 AGT 1.954198 AGN 0.854962 ATA 1.465649 ATC 0.488550 ATG 0.977099 ATT 1.465649 ATN 1.09924 ANA 0.9771 ANC 1.09924 ANG 0.610687 ANT 1.58779 ANN 1.0687 CAA 2.931298 CAC 0.488550 CAG 0.488550 CAT 0.977099 CAN 1.22137 CCA 0.977099 CCC 0.488550 CCG 0.488550 CCT 0.977099 CCN 0.732824 CGA 0.488550 CGC 0.488550 CGG 0.488550 CGT 0.488550 CGN 0.48855 CTA 1.465649 CTC 0.977099 CTG 0.488550 CTT 0.977099 CTN 0.977099 CNA 1.46565 CNC 0.610687 CNG 0.48855 CNT 0.854962 CNN 0.854962 GAA 1.954198 GAC 0.488550 GAG 0.977099 GAT 2.931298 GAN 1.58779 GCA 0.977099 GCC 0.488550 GCG 0.977099 GCT 0.488550 GCN 0.732824 GGA 0.488550 GGC 0.977099 GGG 0.977099 GGT 1.465649 GGN 0.977099 GTA 1.465649 GTC 0.977099 GTG 0.488550 GTT 1.465649 GTN 1.09924 GNA 1.22137 GNC 0.732824 GNG 0.854962 GNT 1.58779 GNN 1.09924 TAA 0.488550 TAC 0.488550 TAG 0.488550 TAT 0.977099 TAN 0.610687 TCA 1.465649 TCC 1.465649 TCG 0.977099 TCT 1.954198 TCN 1.46565 TGA 0.488550 TGC 0.488550 TGG 0.977099 TGT 0.488550 TGN 0.610687 TTA 0.977099 TTC 0.488550 TTG 0.488550 TTT 2.931298 TTN 1.22137 TNA 0.854962 TNC 0.732825 TNG 0.732824 TNT 1.58779 TNN 0.977099 NAA 1.70992 NAC 0.732825 NAG 0.610687 NAT 1.70992 NAN 1.19084 NCA 0.977099 NCC 1.09924 NCG 0.732824 NCT 1.09924 NCN 0.977099 NGA 0.48855 NGC 0.610687 NGG 0.732824 NGT 1.09924 NGN 0.732825 NTA 1.34351 NTC 0.732824 NTG 0.610687 NTT 1.70992 NTN 1.09924 NNA 1.12977 NNC 0.793893 NNG 0.671756 NNT 1.40458 NNN 1 end consensus type 3SS_codon phase 1 begin consensus AAA 1.684211 AAC 1.122807 AAG 0.561404 AAT 1.684211 AAN 1.26316 ACA 0.561404 ACC 1.684211 ACG 0.561404 ACT 0.561404 ACN 0.842106 AGA 1.122807 AGC 0.561404 AGG 1.122807 AGT 0.561404 AGN 0.842106 ATA 1.122807 ATC 2.245614 ATG 2.245614 ATT 1.684211 ATN 1.82456 ANA 1.12281 ANC 1.40351 ANG 1.12281 ANT 1.12281 ANN 1.19298 CAA 0.561404 CAC 0.561404 CAG 0.561404 CAT 1.122807 CAN 0.701755 CCA 0.561404 CCC 0.561404 CCG 1.122807 CCT 0.561404 CCN 0.701755 CGA 0.561404 CGC 0.561404 CGG 0.561404 CGT 1.684211 CGN 0.842106 CTA 0.561404 CTC 0.561404 CTG 2.245614 CTT 1.684211 CTN 1.26316 CNA 0.561404 CNC 0.561404 CNG 1.12281 CNT 1.26316 CNN 0.877193 GAA 1.684211 GAC 0.561404 GAG 1.684211 GAT 1.122807 GAN 1.26316 GCA 1.122807 GCC 0.561404 GCG 0.561404 GCT 1.122807 GCN 0.842105 GGA 1.122807 GGC 0.561404 GGG 0.561404 GGT 1.122807 GGN 0.842105 GTA 1.122807 GTC 1.684211 GTG 1.122807 GTT 1.122807 GTN 1.26316 GNA 1.26316 GNC 0.842106 GNG 0.982457 GNT 1.12281 GNN 1.05263 TAA 0.561404 TAC 0.561404 TAG 0.561404 TAT 0.561404 TAN 0.561404 TCA 0.561404 TCC 0.561404 TCG 0.561404 TCT 0.561404 TCN 0.561404 TGA 0.561404 TGC 0.561404 TGG 1.122807 TGT 1.122807 TGN 0.842105 TTA 0.561404 TTC 1.122807 TTG 2.245614 TTT 2.245614 TTN 1.54386 TNA 0.561404 TNC 0.701755 TNG 1.12281 TNT 1.12281 TNN 0.877193 NAA 1.12281 NAC 0.701755 NAG 0.842106 NAT 1.12281 NAN 0.947369 NCA 0.701755 NCC 0.842106 NCG 0.701755 NCT 0.701755 NCN 0.736842 NGA 0.842106 NGC 0.561404 NGG 0.842105 NGT 1.12281 NGN 0.842106 NTA 0.842106 NTC 1.40351 NTG 1.96491 NTT 1.68421 NTN 1.47368 NNA 0.877193 NNC 0.877193 NNG 1.08772 NNT 1.15789 NNN 1 end consensus type 3SS_codon phase 2 begin consensus AAA 1.333333 AAC 1.333333 AAG 0.666667 AAT 0.666667 AAN 1 ACA 0.666667 ACC 0.666667 ACG 0.666667 ACT 1.333333 ACN 0.833334 AGA 0.666667 AGC 0.666667 AGG 0.666667 AGT 1.333333 AGN 0.833334 ATA 1.333333 ATC 2.666667 ATG 0.666667 ATT 2.000000 ATN 1.66667 ANA 1 ANC 1.33333 ANG 0.666667 ANT 1.33333 ANN 1.08333 CAA 1.333333 CAC 0.666667 CAG 0.666667 CAT 1.333333 CAN 1 CCA 0.666667 CCC 1.333333 CCG 1.333333 CCT 0.666667 CCN 1 CGA 0.666667 CGC 0.666667 CGG 0.666667 CGT 0.666667 CGN 0.666667 CTA 0.666667 CTC 0.666667 CTG 0.666667 CTT 0.666667 CTN 0.666667 CNA 0.833333 CNC 0.833333 CNG 0.833333 CNT 0.833333 CNN 0.833334 GAA 0.666667 GAC 0.666667 GAG 0.666667 GAT 1.333333 GAN 0.833334 GCA 0.666667 GCC 0.666667 GCG 2.000000 GCT 2.666667 GCN 1.5 GGA 1.333333 GGC 0.666667 GGG 0.666667 GGT 0.666667 GGN 0.833333 GTA 0.666667 GTC 1.333333 GTG 0.666667 GTT 1.333333 GTN 1 GNA 0.833334 GNC 0.833334 GNG 1 GNT 1.5 GNN 1.04167 TAA 1.333333 TAC 0.666667 TAG 0.666667 TAT 2.666667 TAN 1.33333 TCA 1.333333 TCC 0.666667 TCG 1.333333 TCT 0.666667 TCN 1 TGA 0.666667 TGC 0.666667 TGG 0.666667 TGT 2.666667 TGN 1.16667 TTA 0.666667 TTC 0.666667 TTG 0.666667 TTT 0.666667 TTN 0.666667 TNA 1 TNC 0.666667 TNG 0.833333 TNT 1.66667 TNN 1.04167 NAA 1.16667 NAC 0.833333 NAG 0.666667 NAT 1.5 NAN 1.04167 NCA 0.833334 NCC 0.833333 NCG 1.33333 NCT 1.33333 NCN 1.08333 NGA 0.833334 NGC 0.666667 NGG 0.666667 NGT 1.33333 NGN 0.875 NTA 0.833333 NTC 1.33333 NTG 0.666667 NTT 1.16667 NTN 1 NNA 0.916667 NNC 0.916667 NNG 0.833334 NNT 1.33333 NNN 1 end consensus type CDS phase all begin consensus AAA 2.386335 AAC 1.053160 AAG 1.564912 AAT 1.686987 AAN 1.67285 ACA 0.987639 ACC 0.645552 ACG 0.588997 ACT 1.051091 ACN 0.81832 AGA 1.264206 AGC 0.831769 AGG 0.727625 AGT 0.865564 AGN 0.922291 ATA 0.993847 ATC 1.040746 ATG 1.394558 ATT 1.851134 ATN 1.32007 ANA 1.40801 ANC 0.892807 ANG 1.06902 ANT 1.36369 ANN 1.18338 CAA 1.498701 CAC 0.575203 CAG 0.708314 CAT 0.951086 CAN 0.933326 CCA 0.795215 CCC 0.491751 CCG 0.455887 CCT 0.832459 CCN 0.643828 CGA 0.706935 CGC 0.368985 CGG 0.354502 CGT 0.741419 CGN 0.54296 CTA 0.836597 CTC 0.861426 CTG 0.917980 CTT 1.436629 CTN 1.01316 CNA 0.959362 CNC 0.574341 CNG 0.609171 CNT 0.990398 CNN 0.783318 GAA 1.682160 GAC 0.641414 GAG 0.823493 GAT 1.255930 GAN 1.10075 GCA 0.793146 GCC 0.515890 GCG 0.364847 GCT 0.964880 GCN 0.659691 GGA 0.946258 GGC 0.470370 GGG 0.352433 GGT 0.846942 GGN 0.654001 GTA 0.737281 GTC 0.688313 GTG 0.724867 GTT 1.275931 GTN 0.856598 GNA 1.03971 GNC 0.578997 GNG 0.56641 GNT 1.08592 GNN 0.81776 TAA 1.130406 TAC 0.999364 TAG 0.591066 TAT 1.385592 TAN 1.02661 TCA 1.159373 TCC 0.921429 TCG 0.764179 TCT 1.205582 TCN 1.01264 TGA 1.487666 TGC 0.967638 TGG 1.180064 TGT 0.966949 TGN 1.15058 TTA 1.538704 TTC 1.455251 TTG 1.566981 TTT 2.128391 TTN 1.67233 TNA 1.32904 TNC 1.08592 TNG 1.02557 TNT 1.42163 TNN 1.21554 NAA 1.6744 NAC 0.817285 NAG 0.921946 NAT 1.3199 NAN 1.18338 NCA 0.933843 NCC 0.643655 NCG 0.543477 NCT 1.0135 NCN 0.78362 NGA 1.10127 NGC 0.65969 NGG 0.653656 NGT 0.855218 NGN 0.817458 NTA 1.02661 NTC 1.01143 NTG 1.1511 NTT 1.67302 NTN 1.21554 NNA 1.18403 NNC 0.783016 NNG 0.817544 NNT 1.21541 NNN 1 end consensus type CDS phase 0 begin consensus AAA 2.488005 AAC 1.039424 AAG 1.727552 AAT 2.175971 AAN 1.85774 ACA 0.874108 ACC 0.690194 ACG 0.386426 ACT 1.630428 ACN 0.895289 AGA 0.702593 AGC 0.514546 AGG 0.276904 AGT 0.880307 AGN 0.593587 ATA 0.741855 ATC 0.721191 ATG 1.264667 ATT 2.516935 ATN 1.31116 ANA 1.20164 ANC 0.741339 ANG 0.913887 ANT 1.80091 ANN 1.16444 CAA 1.702754 CAC 0.394692 CAG 0.702593 CAT 1.045623 CAN 0.961415 CCA 0.774918 CCC 0.566207 CCG 0.258306 CCT 1.444448 CCN 0.76097 CGA 0.481483 CGC 0.421556 CGG 0.171515 CGT 1.318395 CGN 0.598237 CTA 0.506280 CTC 0.477350 CTG 0.343031 CTT 1.657292 CTN 0.745988 CNA 0.866359 CNC 0.464951 CNG 0.368861 CNT 1.36644 CNN 0.766653 GAA 2.884763 GAC 1.039424 GAG 1.504375 GAT 2.576862 GAN 2.00136 GCA 1.004294 GCC 0.745988 GCG 0.291369 GCT 1.905266 GCN 0.986729 GGA 1.049756 GGC 0.599270 GGG 0.264506 GGT 1.582900 GGN 0.874108 GTA 0.762520 GTC 0.750121 GTG 0.495948 GTT 2.006522 GTN 1.00378 GNA 1.42533 GNC 0.783701 GNG 0.639049 GNT 2.01789 GNN 1.21649 TAA 0.000000 TAC 0.770786 TAG 0.000000 TAT 1.477511 TAN 0.562074 TCA 1.024959 TCC 0.772852 TCG 0.415356 TCT 1.826741 TCN 1.00998 TGA 0.000000 TGC 0.322366 TGG 0.588938 TGT 0.485616 TGN 0.34923 TTA 1.630428 TTC 0.907171 TTG 1.450647 TTT 1.965193 TTN 1.48836 TNA 0.663847 TNC 0.693294 TNG 0.613735 TNT 1.43877 TNN 0.85241 NAA 1.76888 NAC 0.811082 NAG 0.98363 NAT 1.81899 NAN 1.34565 NCA 0.91957 NCC 0.69381 NCG 0.337864 NCT 1.70172 NCN 0.913241 NGA 0.558458 NGC 0.464434 NGG 0.325466 NGT 1.0668 NGN 0.603791 NTA 0.910271 NTC 0.713958 NTG 0.888573 NTT 2.03649 NTN 1.13732 NNA 1.03929 NNC 0.670821 NNG 0.633883 NNT 1.656 NNN 1 end consensus type CDS phase 1 begin consensus AAA 2.349249 AAC 1.177724 AAG 2.219080 AAT 1.330621 AAN 1.76917 ACA 1.167393 ACC 0.504148 ACG 0.816142 ACT 0.756223 ACN 0.810976 AGA 1.086812 AGC 0.979370 AGG 1.134334 AGT 0.735561 AGN 0.984019 ATA 1.694270 ATC 1.365747 ATG 2.539338 ATT 1.675674 ATN 1.81876 ANA 1.57443 ANC 1.00675 ANG 1.67722 ANT 1.12452 ANN 1.34573 CAA 1.200452 CAC 0.667377 CAG 1.028959 CAT 0.781017 CAN 0.919451 CCA 0.997966 CCC 0.456626 CCG 0.727296 CCT 0.595061 CCN 0.694237 CGA 0.435964 CGC 0.227280 CGG 0.378111 CGT 0.309927 CGN 0.337821 CTA 1.661211 CTC 1.413269 CTG 2.157094 CTT 1.576497 CTN 1.70202 CNA 1.0739 CNC 0.691138 CNG 1.07286 CNT 0.815626 CNN 0.913382 GAA 0.865730 GAC 0.384310 GAG 0.545472 GAT 0.440097 GAN 0.558902 GCA 0.615722 GCC 0.355383 GCG 0.475222 GCT 0.411170 GCN 0.464374 GGA 0.407038 GGC 0.245876 GGG 0.334722 GGT 0.314060 GGN 0.325424 GTA 1.076481 GTC 0.791348 GTG 1.504181 GTT 0.894657 GTN 1.06667 GNA 0.741243 GNC 0.444229 GNG 0.714899 GNT 0.514996 GNN 0.603842 TAA 1.140533 TAC 0.768620 TAG 0.964907 TAT 0.766554 TAN 0.910154 TCA 0.896723 TCC 0.595061 TCG 0.760355 TCT 0.603325 TCN 0.713866 TGA 1.037224 TGC 0.665311 TGG 1.208717 TGT 0.640517 TGN 0.887942 TTA 1.993866 TTC 1.686005 TTG 2.652978 TTT 1.812042 TTN 2.03622 TNA 1.26709 TNC 0.928749 TNG 1.39674 TNT 0.95561 TNN 1.13705 NAA 1.38899 NAC 0.749508 NAG 1.1896 NAT 0.829572 NAN 1.03942 NCA 0.919451 NCC 0.477804 NCG 0.694754 NCT 0.591445 NCN 0.670863 NGA 0.741759 NGC 0.529459 NGG 0.763971 NGT 0.500016 NGN 0.633801 NTA 1.60646 NTC 1.31409 NTG 2.2134 NTT 1.48972 NTN 1.65592 NNA 1.16416 NNC 0.767716 NNG 1.21543 NNT 0.852688 NNN 1 end consensus type CDS phase 2 begin consensus AAA 2.316265 AAC 0.942210 AAG 0.745916 AAT 1.551753 AAN 1.38904 ACA 0.921547 ACC 0.743850 ACG 0.566152 ACT 0.766578 ACN 0.749532 AGA 2.002195 AGC 1.002131 AGG 0.772777 AGT 0.981468 AGN 1.18964 ATA 0.545490 ATC 1.035191 ATG 0.378124 ATT 1.357526 ATN 0.829083 ANA 1.44637 ANC 0.930845 ANG 0.615742 ANT 1.16433 ANN 1.03932 CAA 1.591012 CAC 0.665332 CAG 0.394654 CAT 1.026926 CAN 0.919481 CCA 0.613676 CCC 0.454575 CCG 0.384322 CCT 0.458707 CCN 0.47782 CGA 1.204623 CGC 0.460774 CGG 0.516562 CGT 0.597146 CGN 0.694776 CTA 0.342997 CTC 0.694260 CTG 0.254149 CTT 1.074450 CTN 0.591464 CNA 0.938077 CNC 0.568735 CNG 0.387422 CNT 0.789307 CNN 0.670885 GAA 1.293472 GAC 0.502099 GAG 0.421515 GAT 0.750048 GAN 0.741783 GCA 0.760380 GCC 0.448376 GCG 0.330600 GCT 0.578550 GCN 0.529477 GGA 1.382321 GGC 0.568219 GGG 0.460774 GGT 0.644670 GGN 0.763996 GTA 0.373991 GTC 0.524827 GTG 0.175631 GTT 0.925680 GTN 0.500032 GNA 0.952541 GNC 0.51088 GNG 0.34713 GNT 0.724737 GNN 0.633822 TAA 2.248079 TAC 1.458772 TAG 0.807903 TAT 1.911280 TAN 1.60651 TCA 1.555886 TCC 1.396784 TCG 1.117841 TCT 1.186027 TCN 1.31413 TGA 3.421709 TGC 1.915413 TGG 1.741848 TGT 1.774908 TGN 2.21347 TTA 0.989733 TTC 1.770775 TTG 0.595080 TTT 2.603474 TTN 1.48977 TNA 2.05385 TNC 1.63544 TNG 1.06567 TNT 1.86892 TNN 1.65597 NAA 1.86221 NAC 0.892103 NAG 0.592497 NAT 1.31 NAN 1.1642 NCA 0.962872 NCC 0.760896 NCG 0.599729 NCT 0.747465 NCN 0.767741 NGA 2.00271 NGC 0.986634 NGG 0.87299 NGT 0.999548 NGN 1.21547 NTA 0.563053 NTC 1.00626 NTG 0.350746 NTT 1.49028 NTN 0.852586 NNA 1.34771 NNC 0.911474 NNG 0.603991 NNT 1.13682 NNN 1 end consensus type Intron_Corr_Term phase all 225.12 type Intron_Corr_Term phase 0 524.049 type Intron_Corr_Term phase 1 652.388 type Intron_Corr_Term phase 2 998.969 type Intron_emission begin consensus A 1.233115 C 0.595593 G 0.670399 T 1.500893 end consensus type Pyrimidine_emission begin consensus A 0.261549 C 0.869936 G 0.127932 T 2.740583 end consensus type Spacer_emission begin consensus A 1.495231 C 0.607484 G 0.513573 T 1.383712 end consensus type Intron_Stay_Prob 0.988929 type Central_Intron_Stay_Prob 0.983466 type Pyrimidine_Stay_Prob 0.904578 type No_Spacer_Prob 0.0743243 type Spacer_Stay_Prob 0.952081 wise-2.4.1/wisecfg/human.gf0000644000175000001440000002154107313404522015131 0ustar philippusers# Splice sites and intron regions information for GeneWise-21 # Wed Jan 1 13:42:23 IST 1997 # Created by Mor Amitai (mor@compugen.co.il) # dataset : hum1 and hum2 from embl48 # Consensi are read from top down. The value, for a sequence, # is the number in the line of the first consensus that # matches the sequence. # Note: the set of sequences that are represented by a consensus # are all the sequences that match this consensus and none of the # previous consensi # # the numbers in types 5SS, 3SS, CDS, and the emissions are the number of # occurrences of each sequence in the database. # In case of a consensus this is the number of occurrences of sequences # that are represented by the consensus in the database divided by the # number of sequences that are represented by the consensus. # *stay_prob is the probability of the transition from the state to itself. # No_Spacer_Prob is the probability of transition from Pyrimidine directly # to 3SS (no spacer). type 5SS center 3 phase all begin consensus C-GGTGAGTG 15.75 --GGTGAGTG 8.83333 CAGGTGAG-- 7.6 AAGGTGAG-- 6.86667 CAGGTAAG-- 4.3125 GAGGTGAG-- 4.26667 AAGGTAAG-- 4.1875 --GGTGAGT- 1.71795 ---GTGAGTG 1.66667 --GGTGAG-C 1.51282 -A-GTAAGT- 1.41071 -AGGTG-GT- 1.39583 -TGGTAAG-- 1.39062 CAGGTA-G-- 1.35417 AAGGTA-G-- 1.04167 -GGGTAAG-- 1 --GGTGAG-- 0.91453 -C-GTAAGT- 0.828125 ---GTGAGT- 0.729167 -AGGTAA--- 0.578704 -AGGTG-G-- 0.506944 CAGGTA---- 0.381944 --GGTA-GT- 0.339286 -AGGTGA--- 0.265625 --GGTCAG-- 0.207031 ---GTAAG-- 0.155556 -AGGTA---- 0.134921 -AGGT--G-- 0.111607 --GGT--G-- 0.0369898 -AGGT----- 0.0250947 --GGTA---- 0.0234375 --AGT--G-- 0.0132415 ---GT----- 0.00148067 end consensus type 5SS center 3 phase 0 begin consensus A-GGTGAGTG 8.25 C-GGTGAGTG 7.75 AAGGTGAG-- 3.86667 CAGGTGAG-- 3.46667 AAGGTAAG-- 2.5 GAGGTGAG-- 2.4375 --GGTGAGT- 1.19565 -AGGTAAG-- 1.02083 -A-GTGAGT- 0.916667 -AGGT--GTG 0.785714 AAGGT-GG-- 0.716667 -C-GTGAGT- 0.666667 ---GTAAGTG 0.566667 --GGTGAG-- 0.423077 --GGTAAG-- 0.355556 CAGGT--G-- 0.3 ---GTAAGT- 0.284722 -AGGTAA--- 0.265625 --GGTA-GT- 0.196429 -AGGTAC--- 0.157895 AAGGTG---- 0.13964 -AGGTG---- 0.048048 -AGGT----- 0.0181818 --GGT--G-- 0.0129717 ---GTA---- 0.00291667 ---GT----- 0.000915751 end consensus type 5SS center 3 phase 1 begin consensus --GGTGAGTG 4.375 CAGGTGAG-- 2.8 AAGGTGAG-- 2.26667 -AGGTAAG-- 1.01562 -TGGTAAG-- 0.8125 -TGGTGAG-- 0.7 G-GGTGAG-- 0.755556 CAGGT-GG-- 0.546875 --GGTGAG-- 0.428571 ---GTGAGTG 0.625 ---GTAAGT- 0.223214 AAGGT--G-- 0.200893 -AGGTAA--- 0.1875 --GGTA-G-G 0.175 CAGGT----- 0.0733945 ---GTGAG-- 0.0527778 --GGT--GT- 0.0512129 A-GGTA---- 0.046398 -AGGT----- 0.0137104 ---G-AAG-- 0.00972447 ---GT----- 0.00111909 end consensus type 5SS center 3 phase 2 begin consensus -AGGTGAG-- 0.703125 C--GTGAGT- 0.516667 -AGGTAAG-- 0.5 ---GTAAGT- 0.241667 --GGTGAG-- 0.227778 CAGGTA---- 0.133333 ---GTGAG-- 0.0569444 -AGGT--G-- 0.0483491 ---GTAAG-- 0.0444444 --GGTA---- 0.00896991 ---GT----- 0.000797367 end consensus type 3SS center 3 phase all begin consensus CAGGTG 143 CAGGGT 120 CAGGGC 88 CAGGGA 82 CAGGCT 77 CAGGAG 73 CAGGGG 66 CAGGTA 60 CAGGCC 58 CAGGAA 54 CAGATC 50 CAGCTG 50 CAGG-C 43.5 CAGG-T 38.5 CAGA-C 35.6667 CAGAT- 29.3333 CAGA-A 27.3333 CAG-TC 25.5 TAGG-G 21.75 CAG-CA 21.6667 TAGGA- 21.3333 TAGGG- 20.6667 CAGA-G 19.3333 CAGTG- 18.75 CAGA-- 18 TAGG-- 13.8333 CAG-C- 11.8571 CAG-T- 10.4 CAG-A- 7.375 TAGA-- 6.0625 TAGC-- 3.3125 AAGG-- 3.125 -AGT-- 1.08333 -AG--- 0.714286 end consensus type 3SS center 3 phase 0 begin consensus CAGGGT 88 CAGGTG 64 CAGGAG 43 CAGGG- 40.3333 CAGATC 32 CAGG-C 25 CAGG-A 19 CAGG-T 17.3333 CAGA-C 14.6667 CAG-TG 13 CAGAA- 13 CAGA-T 11.3333 CAGC-C 10.25 TAGG-- 9.8125 CAG--A 4.09091 CAGT-- 4.45455 TAG-T- 3.33333 TAG--- 1.36111 -AGG-- 1.06061 -AG--- 0.342857 end consensus type 3SS center 3 phase 1 begin consensus CAGGTG 71 CAGGCT 36 CAGGG- 24.75 CAG-CC 17.5 CAG-TG 16.6667 CAGAG- 15.75 CAGG-- 14.5556 CAGA-A 13.3333 CAGTG- 10.75 CAG-TC 10.3333 TAGG-G 9.5 CAGA-- 6.16667 TAGG-- 5 CAGC-- 3.69231 TAG--- 1.66667 -AG--- 0.328467 end consensus type 3SS center 3 phase 2 begin consensus CAGG-A 19.25 CAGG-T 14.75 CAG-G- 4.57143 CAG--T 4.66667 TAGG-- 3 CAG--- 2.87879 TAG--- 0.645833 AAG--- 0.25 end consensus type CDS phase all begin consensus AAA 5290.000000 AAC 4795.000000 AAG 8178.000000 AAT 3305.000000 ACA 6240.000000 ACC 7728.000000 ACG 3347.000000 ACT 4930.000000 AGA 8491.000000 AGC 8639.000000 AGG 8997.000000 AGT 4417.000000 ATA 1975.000000 ATC 4973.000000 ATG 6474.000000 ATT 3083.000000 CAA 7057.000000 CAC 6815.000000 CAG 11041.000000 CAT 5779.000000 CCA 10537.000000 CCC 10307.000000 CCG 5621.000000 CCT 10134.000000 CGA 3377.000000 CGC 5146.000000 CGG 5375.000000 CGT 2765.000000 CTA 3502.000000 CTC 7465.000000 CTG 13780.000000 CTT 5453.000000 GAA 7461.000000 GAC 6937.000000 GAG 9975.000000 GAT 4949.000000 GCA 7747.000000 GCC 10890.000000 GCG 4828.000000 GCT 9371.000000 GGA 10143.000000 GGC 10400.000000 GGG 8869.000000 GGT 5567.000000 GTA 2143.000000 GTC 4593.000000 GTG 8189.000000 GTT 3021.000000 TAA 1775.000000 TAC 3687.000000 TAG 1333.000000 TAT 2477.000000 TCA 6180.000000 TCC 7668.000000 TCG 2875.000000 TCT 5767.000000 TGA 7315.000000 TGC 8625.000000 TGG 11718.000000 TGT 5197.000000 TTA 1664.000000 TTC 5462.000000 TTG 4420.000000 TTT 3453.000000 end consensus type CDS phase 0 begin consensus AAA 2167.000000 AAC 2839.000000 AAG 4830.000000 AAT 1616.000000 ACA 1543.000000 ACC 3187.000000 ACG 983.000000 ACT 1484.000000 AGA 995.000000 AGC 2722.000000 AGG 1326.000000 AGT 1093.000000 ATA 585.000000 ATC 3281.000000 ATG 2538.000000 ATT 1584.000000 CAA 1141.000000 CAC 1981.000000 CAG 4796.000000 CAT 1016.000000 CCA 2021.000000 CCC 3183.000000 CCG 1104.000000 CCT 2289.000000 CGA 770.000000 CGC 2011.000000 CGG 1762.000000 CGT 687.000000 CTA 745.000000 CTC 2964.000000 CTG 6980.000000 CTT 1200.000000 GAA 2729.000000 GAC 3946.000000 GAG 6121.000000 GAT 2318.000000 GCA 1767.000000 GCC 4902.000000 GCG 1288.000000 GCT 2556.000000 GGA 2322.000000 GGC 4338.000000 GGG 2688.000000 GGT 1903.000000 GTA 690.000000 GTC 2172.000000 GTG 4546.000000 GTT 1020.000000 TAA 0.000000 TAC 2405.000000 TAG 0.000000 TAT 1323.000000 TCA 990.000000 TCC 2579.000000 TCG 684.000000 TCT 1522.000000 TGA 0.000000 TGC 1747.000000 TGG 1766.000000 TGT 931.000000 TTA 397.000000 TTC 3156.000000 TTG 1313.000000 TTT 1697.000000 end consensus type CDS phase 1 begin consensus AAA 1534.000000 AAC 1140.000000 AAG 2597.000000 AAT 767.000000 ACA 3632.000000 ACC 3429.000000 ACG 1849.000000 ACT 2262.000000 AGA 4427.000000 AGC 4014.000000 AGG 5377.000000 AGT 1927.000000 ATA 953.000000 ATC 1055.000000 ATG 3488.000000 ATT 777.000000 CAA 998.000000 CAC 1332.000000 CAG 3260.000000 CAT 731.000000 CCA 4701.000000 CCC 3908.000000 CCG 2252.000000 CCT 2992.000000 CGA 471.000000 CGC 1361.000000 CGG 1785.000000 CGT 443.000000 CTA 825.000000 CTC 1766.000000 CTG 4378.000000 CTT 882.000000 GAA 924.000000 GAC 843.000000 GAG 1897.000000 GAT 424.000000 GCA 3140.000000 GCC 3275.000000 GCG 1806.000000 GCT 2595.000000 GGA 1911.000000 GGC 2034.000000 GGG 2835.000000 GGT 762.000000 GTA 577.000000 GTC 968.000000 GTG 2506.000000 GTT 563.000000 TAA 622.000000 TAC 561.000000 TAG 912.000000 TAT 322.000000 TCA 3963.000000 TCC 3535.000000 TCG 1466.000000 TCT 2607.000000 TGA 3311.000000 TGC 4099.000000 TGG 6194.000000 TGT 1772.000000 TTA 773.000000 TTC 1353.000000 TTG 2662.000000 TTT 713.000000 end consensus type CDS phase 2 begin consensus AAA 1589.000000 AAC 816.000000 AAG 751.000000 AAT 922.000000 ACA 1065.000000 ACC 1112.000000 ACG 515.000000 ACT 1184.000000 AGA 3069.000000 AGC 1903.000000 AGG 2294.000000 AGT 1397.000000 ATA 437.000000 ATC 637.000000 ATG 448.000000 ATT 722.000000 CAA 4918.000000 CAC 3502.000000 CAG 2985.000000 CAT 4032.000000 CCA 3815.000000 CCC 3216.000000 CCG 2265.000000 CCT 4853.000000 CGA 2136.000000 CGC 1774.000000 CGG 1828.000000 CGT 1635.000000 CTA 1932.000000 CTC 2735.000000 CTG 2422.000000 CTT 3371.000000 GAA 3808.000000 GAC 2148.000000 GAG 1957.000000 GAT 2207.000000 GCA 2840.000000 GCC 2713.000000 GCG 1734.000000 GCT 4220.000000 GGA 5910.000000 GGC 4028.000000 GGG 3346.000000 GGT 2902.000000 GTA 876.000000 GTC 1453.000000 GTG 1137.000000 GTT 1438.000000 TAA 1153.000000 TAC 721.000000 TAG 421.000000 TAT 832.000000 TCA 1227.000000 TCC 1554.000000 TCG 725.000000 TCT 1638.000000 TGA 4004.000000 TGC 2779.000000 TGG 3758.000000 TGT 2494.000000 TTA 494.000000 TTC 953.000000 TTG 445.000000 TTT 1043.000000 end consensus type Intron_Corr_Term phase all 65.6094 type Intron_Corr_Term phase 0 141.429 type Intron_Corr_Term phase 1 172.738 type Intron_Corr_Term phase 2 371.127 type Intron_emission begin consensus A 399845.000000 C 371259.000000 G 393779.000000 T 425926.000000 end consensus type Pyrimidine_emission begin consensus A 2299.000000 C 18610.000000 G 2345.000000 T 17132.000000 end consensus type Spacer_emission begin consensus A 3020.000000 C 3834.000000 G 3644.000000 T 4224.000000 end consensus type Central_Intron_Stay_Prob 0.99853 type Pyrimidine_Stay_Prob 0.944485 type No_Spacer_Prob 0.331508 type Spacer_Stay_Prob 0.902704 wise-2.4.1/wisecfg/human.gp0000644000175000001440000002154307313404522015145 0ustar philippusers# Splice sites and intron regions information for GeneWise-21 # Wed Jan 1 13:42:23 IST 1997 # Created by Mor Amitai (mor@compugen.co.il) # dataset : hum1 and hum2 from embl48 # Consensi are read from top down. The value, for a sequence, # is the number in the line of the first consensus that # matches the sequence. # Note: the set of sequences that are represented by a consensus # are all the sequences that match this consensus and none of the # previous consensi # # the numbers in types 5SS, 3SS, CDS, and the emissions are the number of # occurrences of each sequence in the database. # In case of a consensus this is the number of occurrences of sequences # that are represented by the consensus in the database divided by the # number of sequences that are represented by the consensus. # *stay_prob is the probability of the transition from the state to itself. # No_Spacer_Prob is the probability of transition from Pyrimidine directly # to 3SS (no spacer). type 5SS center 3 phase all begin consensus C-GGTGAGTG 15.75 --GGTGAGTG 8.83333 CAGGTGAG-- 7.6 AAGGTGAG-- 6.86667 CAGGTAAG-- 4.3125 GAGGTGAG-- 4.26667 AAGGTAAG-- 4.1875 --GGTGAGT- 1.71795 ---GTGAGTG 1.66667 --GGTGAG-C 1.51282 -A-GTAAGT- 1.41071 -AGGTG-GT- 1.39583 -TGGTAAG-- 1.39062 CAGGTA-G-- 1.35417 AAGGTA-G-- 1.04167 -GGGTAAG-- 1 --GGTGAG-- 0.91453 -C-GTAAGT- 0.828125 ---GTGAGT- 0.729167 -AGGTAA--- 0.578704 -AGGTG-G-- 0.506944 CAGGTA---- 0.381944 --GGTA-GT- 0.339286 -AGGTGA--- 0.265625 --GGTCAG-- 0.207031 ---GTAAG-- 0.155556 -AGGTA---- 0.134921 -AGGT--G-- 0.111607 --GGT--G-- 0.0369898 -AGGT----- 0.0250947 --GGTA---- 0.0234375 --AGT--G-- 0.0132415 ---GT----- 0.00148067 end consensus type 5SS center 3 phase 0 begin consensus A-GGTGAGTG 8.25 C-GGTGAGTG 7.75 AAGGTGAG-- 3.86667 CAGGTGAG-- 3.46667 AAGGTAAG-- 2.5 GAGGTGAG-- 2.4375 --GGTGAGT- 1.19565 -AGGTAAG-- 1.02083 -A-GTGAGT- 0.916667 -AGGT--GTG 0.785714 AAGGT-GG-- 0.716667 -C-GTGAGT- 0.666667 ---GTAAGTG 0.566667 --GGTGAG-- 0.423077 --GGTAAG-- 0.355556 CAGGT--G-- 0.3 ---GTAAGT- 0.284722 -AGGTAA--- 0.265625 --GGTA-GT- 0.196429 -AGGTAC--- 0.157895 AAGGTG---- 0.13964 -AGGTG---- 0.048048 -AGGT----- 0.0181818 --GGT--G-- 0.0129717 ---GTA---- 0.00291667 ---GT----- 0.000915751 end consensus type 5SS center 3 phase 1 begin consensus --GGTGAGTG 4.375 CAGGTGAG-- 2.8 AAGGTGAG-- 2.26667 -AGGTAAG-- 1.01562 -TGGTAAG-- 0.8125 -TGGTGAG-- 0.7 G-GGTGAG-- 0.755556 CAGGT-GG-- 0.546875 --GGTGAG-- 0.428571 ---GTGAGTG 0.625 ---GTAAGT- 0.223214 AAGGT--G-- 0.200893 -AGGTAA--- 0.1875 --GGTA-G-G 0.175 CAGGT----- 0.0733945 ---GTGAG-- 0.0527778 --GGT--GT- 0.0512129 A-GGTA---- 0.046398 -AGGT----- 0.0137104 ---G-AAG-- 0.00972447 ---GT----- 0.00111909 end consensus type 5SS center 3 phase 2 begin consensus -AGGTGAG-- 0.703125 C--GTGAGT- 0.516667 -AGGTAAG-- 0.5 ---GTAAGT- 0.241667 --GGTGAG-- 0.227778 CAGGTA---- 0.133333 ---GTGAG-- 0.0569444 -AGGT--G-- 0.0483491 ---GTAAG-- 0.0444444 --GGTA---- 0.00896991 ---GT----- 0.000797367 end consensus type 3SS center 3 phase all begin consensus CAGGTG 143 CAGGGT 120 CAGGGC 88 CAGGGA 82 CAGGCT 77 CAGGAG 73 CAGGGG 66 CAGGTA 60 CAGGCC 58 CAGGAA 54 CAGATC 50 CAGCTG 50 CAGG-C 43.5 CAGG-T 38.5 CAGA-C 35.6667 CAGAT- 29.3333 CAGA-A 27.3333 CAG-TC 25.5 TAGG-G 21.75 CAG-CA 21.6667 TAGGA- 21.3333 TAGGG- 20.6667 CAGA-G 19.3333 CAGTG- 18.75 CAGA-- 18 TAGG-- 13.8333 CAG-C- 11.8571 CAG-T- 10.4 CAG-A- 7.375 TAGA-- 6.0625 TAGC-- 3.3125 AAGG-- 3.125 -AGT-- 1.08333 -AG--- 0.714286 end consensus type 3SS center 3 phase 0 begin consensus CAGGGT 88 CAGGTG 64 CAGGAG 43 CAGGG- 40.3333 CAGATC 32 CAGG-C 25 CAGG-A 19 CAGG-T 17.3333 CAGA-C 14.6667 CAG-TG 13 CAGAA- 13 CAGA-T 11.3333 CAGC-C 10.25 TAGG-- 9.8125 CAG--A 4.09091 CAGT-- 4.45455 TAG-T- 3.33333 TAG--- 1.36111 -AGG-- 1.06061 -AG--- 0.342857 end consensus type 3SS center 3 phase 1 begin consensus CAGGTG 71 CAGGCT 36 CAGGG- 24.75 CAG-CC 17.5 CAG-TG 16.6667 CAGAG- 15.75 CAGG-- 14.5556 CAGA-A 13.3333 CAGTG- 10.75 CAG-TC 10.3333 TAGG-G 9.5 CAGA-- 6.16667 TAGG-- 5 CAGC-- 3.69231 TAG--- 1.66667 -AG--- 0.328467 end consensus type 3SS center 3 phase 2 begin consensus CAGG-A 19.25 CAGG-T 14.75 CAG-G- 4.57143 CAG--T 4.66667 TAGG-- 3 CAG--- 2.87879 TAG--- 0.645833 AAG--- 0.25 end consensus type CDS phase all begin consensus AAA 5290.000000 AAC 4795.000000 AAG 8178.000000 AAT 3305.000000 ACA 6240.000000 ACC 7728.000000 ACG 3347.000000 ACT 4930.000000 AGA 8491.000000 AGC 8639.000000 AGG 8997.000000 AGT 4417.000000 ATA 1975.000000 ATC 4973.000000 ATG 6474.000000 ATT 3083.000000 CAA 7057.000000 CAC 6815.000000 CAG 11041.000000 CAT 5779.000000 CCA 10537.000000 CCC 10307.000000 CCG 5621.000000 CCT 10134.000000 CGA 3377.000000 CGC 5146.000000 CGG 5375.000000 CGT 2765.000000 CTA 3502.000000 CTC 7465.000000 CTG 13780.000000 CTT 5453.000000 GAA 7461.000000 GAC 6937.000000 GAG 9975.000000 GAT 4949.000000 GCA 7747.000000 GCC 10890.000000 GCG 4828.000000 GCT 9371.000000 GGA 10143.000000 GGC 10400.000000 GGG 8869.000000 GGT 5567.000000 GTA 2143.000000 GTC 4593.000000 GTG 8189.000000 GTT 3021.000000 TAA 1775.000000 TAC 3687.000000 TAG 1333.000000 TAT 2477.000000 TCA 6180.000000 TCC 7668.000000 TCG 2875.000000 TCT 5767.000000 TGA 7315.000000 TGC 8625.000000 TGG 11718.000000 TGT 5197.000000 TTA 1664.000000 TTC 5462.000000 TTG 4420.000000 TTT 3453.000000 end consensus type CDS phase 0 begin consensus AAA 2167.000000 AAC 2839.000000 AAG 4830.000000 AAT 1616.000000 ACA 1543.000000 ACC 3187.000000 ACG 983.000000 ACT 1484.000000 AGA 995.000000 AGC 2722.000000 AGG 1326.000000 AGT 1093.000000 ATA 585.000000 ATC 3281.000000 ATG 2538.000000 ATT 1584.000000 CAA 1141.000000 CAC 1981.000000 CAG 4796.000000 CAT 1016.000000 CCA 2021.000000 CCC 3183.000000 CCG 1104.000000 CCT 2289.000000 CGA 770.000000 CGC 2011.000000 CGG 1762.000000 CGT 687.000000 CTA 745.000000 CTC 2964.000000 CTG 6980.000000 CTT 1200.000000 GAA 2729.000000 GAC 3946.000000 GAG 6121.000000 GAT 2318.000000 GCA 1767.000000 GCC 4902.000000 GCG 1288.000000 GCT 2556.000000 GGA 2322.000000 GGC 4338.000000 GGG 2688.000000 GGT 1903.000000 GTA 690.000000 GTC 2172.000000 GTG 4546.000000 GTT 1020.000000 TAA 0.000000 TAC 2405.000000 TAG 0.000000 TAT 1323.000000 TCA 990.000000 TCC 2579.000000 TCG 684.000000 TCT 1522.000000 TGA 0.000000 TGC 1747.000000 TGG 1766.000000 TGT 931.000000 TTA 397.000000 TTC 3156.000000 TTG 1313.000000 TTT 1697.000000 end consensus type CDS phase 1 begin consensus AAA 1534.000000 AAC 1140.000000 AAG 2597.000000 AAT 767.000000 ACA 3632.000000 ACC 3429.000000 ACG 1849.000000 ACT 2262.000000 AGA 4427.000000 AGC 4014.000000 AGG 5377.000000 AGT 1927.000000 ATA 953.000000 ATC 1055.000000 ATG 3488.000000 ATT 777.000000 CAA 998.000000 CAC 1332.000000 CAG 3260.000000 CAT 731.000000 CCA 4701.000000 CCC 3908.000000 CCG 2252.000000 CCT 2992.000000 CGA 471.000000 CGC 1361.000000 CGG 1785.000000 CGT 443.000000 CTA 825.000000 CTC 1766.000000 CTG 4378.000000 CTT 882.000000 GAA 924.000000 GAC 843.000000 GAG 1897.000000 GAT 424.000000 GCA 3140.000000 GCC 3275.000000 GCG 1806.000000 GCT 2595.000000 GGA 1911.000000 GGC 2034.000000 GGG 2835.000000 GGT 762.000000 GTA 577.000000 GTC 968.000000 GTG 2506.000000 GTT 563.000000 TAA 622.000000 TAC 561.000000 TAG 912.000000 TAT 322.000000 TCA 3963.000000 TCC 3535.000000 TCG 1466.000000 TCT 2607.000000 TGA 3311.000000 TGC 4099.000000 TGG 6194.000000 TGT 1772.000000 TTA 773.000000 TTC 1353.000000 TTG 2662.000000 TTT 713.000000 end consensus type CDS phase 2 begin consensus AAA 1589.000000 AAC 816.000000 AAG 751.000000 AAT 922.000000 ACA 1065.000000 ACC 1112.000000 ACG 515.000000 ACT 1184.000000 AGA 3069.000000 AGC 1903.000000 AGG 2294.000000 AGT 1397.000000 ATA 437.000000 ATC 637.000000 ATG 448.000000 ATT 722.000000 CAA 4918.000000 CAC 3502.000000 CAG 2985.000000 CAT 4032.000000 CCA 3815.000000 CCC 3216.000000 CCG 2265.000000 CCT 4853.000000 CGA 2136.000000 CGC 1774.000000 CGG 1828.000000 CGT 1635.000000 CTA 1932.000000 CTC 2735.000000 CTG 2422.000000 CTT 3371.000000 GAA 3808.000000 GAC 2148.000000 GAG 1957.000000 GAT 2207.000000 GCA 2840.000000 GCC 2713.000000 GCG 1734.000000 GCT 4220.000000 GGA 5910.000000 GGC 4028.000000 GGG 3346.000000 GGT 2902.000000 GTA 876.000000 GTC 1453.000000 GTG 1137.000000 GTT 1438.000000 TAA 1153.000000 TAC 721.000000 TAG 421.000000 TAT 832.000000 TCA 1227.000000 TCC 1554.000000 TCG 725.000000 TCT 1638.000000 TGA 4004.000000 TGC 2779.000000 TGG 3758.000000 TGT 2494.000000 TTA 494.000000 TTC 953.000000 TTG 445.000000 TTT 1043.000000 end consensus type Intron_Corr_Term phase all 65.6094 type Intron_Corr_Term phase 0 141.429 type Intron_Corr_Term phase 1 172.738 type Intron_Corr_Term phase 2 371.127 type Intron_emission begin consensus A 399845.000000 C 371259.000000 G 393779.000000 T 425926.000000 end consensus type Pyrimidine_emission begin consensus A 2299.000000 C 18610.000000 G 2345.000000 T 17132.000000 end consensus type Spacer_emission begin consensus A 3020.000000 C 3834.000000 G 3644.000000 T 4224.000000 end consensus type Central_Intron_Stay_Prob 0.99853 type Pyrimidine_Stay_Prob 0.944485 type No_Spacer_Prob 0.331508 type Spacer_Stay_Prob 0.902704 wise-2.4.1/wisecfg/codon.table0000644000175000001440000000064207313404522015615 0ustar philippusers! this is a codon table ! by ewan TTT F TTC F TTA L TTG L TCT S TCC S TCA S TCG S TAT Y TAC Y TAA X TAG X TGT C TGC C TGA X TGG W CTT L CTC L CTA L CTG L CCT P CCC P CCA P CCG P CAT H CAC H CAA Q CAG Q CGT R CGC R CGA R CGG R ATT I ATC I ATA I ATG M ACT T ACC T ACA T ACG T AAT N AAC N AAA K AAG K AGT S AGC S AGA R AGG R GTT V GTC V GTA V GTG V GCT A GCC A GCA A GCG A GAT D GAC D GAA E GAG E GGT G GGC G GGA G GGG G wise-2.4.1/wisecfg/human.stats0000644000175000001440000000522707627665627015725 0ustar philippusers# # # new genestats file # intron_emission 0.25 0.25 0.25 0.25 0.1 // rnd_emission 0.25 0.25 0.25 0.25 0.1 // splice3 10 ENSE00000673410 TCCCACATAGATCA ENSE00000673409 TATCCTGCAGTATG ENSE00000673408 TTTGCTATAGATTA ENSE00000673407 GGTTTTTCAGTTGC ENSE00000401072 CTCCCATTAGGGTT ENSE00000868868 TTATTTCTAGCTGA ENSE00000401061 CTTTGGTTAGGCAG ENSE00000673400 GTTCTCCCAGGCCT ENSE00000673402 TGTTTTATAGGGAT ENSE00000673403 CTTCTTTCAGAATG ENSE00000868865 ATTATCTTAGTTTC ENSE00000662824 ATTTTTTTAGTGGA ENSE00000662823 TCATTTTTAGGAAC ENSE00000662822 CAAATTTCAGCCAA ENSE00000662821 TATTCTACAGGAAG ENSE00000662820 TATTTGGCAGCCGT ENSE00000662819 TTTCTTACAGATTA ENSE00000814444 ATTTTTAAAGCATT ENSE00000814445 TTTTTTCCAGGGAC ENSE00000814446 CTCTGTCTAGTTTC ENSE00000814447 CTGCTTTTAGTCTC ENSE00000814448 TGGATTTCAGTTTC ENSE00000789672 TGGCATTTAGAAAT ENSE00000789671 TTGTCCTCAGATTT ENSE00000814451 TTTCGGGTAGATCA ENSE00000814452 TTGCTCCTAGGTTT ENSE00000789668 TTCCCTACAGGCGA ENSE00000789652 TTCTTTGCAGTTAT ENSE00000789653 ATTCATTTAGGCAG ENSE00000789654 TTTGGATCAGGATA ENSE00000789655 TTTATTTTAGGAAT ENSE00000789656 CCCTTCCCAGCAAG ENSE00000789657 TACATGTAAGACCT ENSE00000789658 TTCCCTGCAGGATA ENSE00000789659 TTTTGATTAGGATG ENSE00000789660 TATATTGCAGATAT ENSE00000789661 CTTTTTCCAGATAA ENSE00000789662 TTTATTTCAGCTGG ENSE00000450960 TGTCCTTCAGAACA ENSE00000789663 TGTTTCTTAGGTAG ENSE00000789664 ACCTCTGTAGGCAG ENSE00000789665 GTTCTTTTAGGACA ENSE00000789666 TTTTTAATAGGGAA ENSE00000450963 TCCCTGGCAGACTG ENSE00000813771 AACTTTTCAGCTCT ENSE00000813770 TATTACACAGGATT // splice5 5 ENSE00000673410 ACTGGTGAGTCCTT ENSE00000673409 TGAGGTAAGCCTGA ENSE00000673408 TACGGTAAGTGGTA ENSE00000673407 TGAAGTAAGGTGCC ENSE00000401072 CCAAGTAAGTTTTT ENSE00000868868 TAAGGTGCGTTCAT ENSE00000401061 AAAAGTAAGTAAAT ENSE00000673400 AAACGTAAGTTGGA ENSE00000673402 TGAGGTATGTAAGA ENSE00000673403 TCAGGTATGACATT ENSE00000868865 CTATGTGAGTTATG ENSE00000662824 GTAAGTTATAAGAA ENSE00000662823 CCATGTAAGTGGTA ENSE00000662822 TTAGGTAGGTACTA ENSE00000662821 TCAGGTAGGTACAT ENSE00000662820 TCAGGTACAGTGAA ENSE00000662819 CGAGGTATGCAACT ENSE00000814444 CAGAGTAAGTAACC ENSE00000814445 AGAGGTAAGCCAGG ENSE00000814446 GATGGTAAGATGAT ENSE00000814447 CAGGGTGAGTTGGA ENSE00000814448 TCAGGTGAGGGCAT ENSE00000789672 TTAAGTAAGTTCAG ENSE00000789671 AAAGGTGAATGCTT ENSE00000814451 ACAGGTCAGAGGCC ENSE00000814452 GAAGGTAAGAATTA ENSE00000789668 TGAGGTGAGTACTT ENSE00000789652 TTAAGTAAGTTTGT ENSE00000789653 ACAGGTAAAATTTG ENSE00000789654 TAAGGTAAGGCTTT ENSE00000789655 ACAGGTAAGAAGAA ENSE00000789656 TTAGGTAAGCTTCA // wise-2.4.1/wisecfg/codon.martian0000644000175000001440000000064207575675612016205 0ustar philippusers! this is a codon table ! by ewan TTT * TTC * TTA * TTG * TCT * TCC * TCA * TCG * TAT * TAC * TAA * TAG * TGT * TGC * TGA * TGG * CTT * CTC * CTA * CTG * CCT * CCC * CCA * CCG * CAT * CAC * CAA * CAG * CGT * CGC * CGA * CGG * ATT * ATC * ATA * ATG M ACT * ACC * ACA * ACG * AAT * AAC * AAA * AAG * AGT * AGC * AGA * AGG * GTT * GTC * GTA * GTG * GCT * GCC * GCA * GCG * GAT * GAC * GAA * GAG * GGT * GGC * GGA * GGG * wise-2.4.1/wisecfg/methods0000644000175000001440000000562007313411702015067 0ustar philippusers type aa real int endtype type codon real int endtype # # Stuff for PROTEIN # type PROTEIN real ComplexSequence* dbtype ProteinDB* init init_ProteinDB reload reload_ProteinDB close close_ProteinDB addentry dataentry_add_ProteinDB name get_allocd_name_ComplexSequence hardlink hard_link_ComplexSequence free free_ComplexSequence threadsafe endtype method AMINOACID map CSEQ_PROTEIN_AMINOACID arg PROTEIN arg int return aa endmethod # # End of protein type and methods # type COMPMAT real CompMat* endtype method AAMATCH map CompMat_AAMATCH arg COMPMAT arg aa arg aa return int endmethod type DNACOMPMAT real DnaMatrix* endtype method DNABASEMATCH map DnaMatrix_MATCH arg DNACOMPMAT arg base arg base return int endmethod type CODONMATRIX real CodonMatrixScore* endtype method CODON_MATCH map CodonMatrix_MATCH arg CODONMATRIX arg codon arg codon return int endmethod # # Genomic types and methods # type GENOMIC real ComplexSequence* dbtype GenomicDB* init init_GenomicDB reload reload_GenomicDB close close_GenomicDB addentry dataentry_add_GenomicDB name get_allocd_name_ComplexSequence hardlink hard_link_ComplexSequence free free_ComplexSequence threadsafe endtype method GENOMIC_CODON map CSEQ_GENOMIC_CODON arg GENOMIC arg int return codon endmethod method GENOMIC_BASE map CSEQ_GENOMIC_BASE arg GENOMIC arg int return base endmethod method GENOMIC_5SS map CSEQ_GENOMIC_5SS arg GENOMIC arg int return int endmethod method GENOMIC_3SS map CSEQ_GENOMIC_3SS arg GENOMIC arg int return int endmethod method GENOMIC_REPEAT map CSEQ_GENOMIC_REPEAT arg GENOMIC arg int return int endmethod method GENOMIC_CDS_POT map CSEQ_GENOMIC_CDSPOT arg GENOMIC arg int return int endmethod # # Cdna Methods # type CDNA real ComplexSequence* dbtype cDNADB* init init_cDNADB reload reload_cDNADB close close_cDNADB addentry dataentry_add_cDNADB hardlink hard_link_ComplexSequence free free_ComplexSequence threadsafe endtype method CDNA_CODON map CSEQ_CDNA_CODON arg CDNA arg int return codon endmethod method CDNA_BASE map CSEQ_CDNA_BASE arg CDNA arg int return base endmethod method CDNA_SEQ_POS map CSEQ_SEQ arg CDNA arg int return char* endmethod # # Dna mehtods # type DNA real ComplexSequence* endtype method DNA_BASE map CSEQ_DNA_BASE arg DNA arg int return base endmethod type DNAMAT real DnaMatrix* endtype method DNAMATCH map DnaMatrix_MATCH arg DNAMAT arg base arg base return int endmethod # genewise models type CDNA_HMM real GeneWiseScore* dbtype GeneWiseDB* init init_GeneWiseDB reload reload_GeneWiseDB close close_GeneWiseDB addentry dataentry_add_GeneWiseDB hardlink hard_link_GeneWiseScore free free_GeneWiseScore threadsafe endtype type GENEWISEMODEL real GeneWiseScore* dbtype GeneWiseDB* init init_GeneWiseDB reload reload_GeneWiseDB close close_GeneWiseDB addentry dataentry_add_GeneWiseDB hardlink hard_link_GeneWiseScore free free_GeneWiseScore threadsafe endtype wise-2.4.1/wisecfg/aa.rnd0000644000175000001440000000036707313404522014574 0ustar philippusers! ! AMINO_ALPHABET "ACDEFGHIKLMNPQRSTVWY" ! ! A 0.08713 C 0.03347 D 0.04687 E 0.04953 F 0.03977 G 0.08861 H 0.03362 I 0.03689 K 0.08048 L 0.08536 M 0.01475 N 0.04043 P 0.05068 Q 0.03826 R 0.04090 S 0.06958 T 0.05854 V 0.06472 W 0.01049 Y 0.02992 wise-2.4.1/wisecfg/cb.tmf0000644000175000001440000002414107313404522014576 0ustar philippusers tmfreq paired internal -:- 5836 -:A 906 -:B 0.00 -:C 0.00 -:D 107 -:E 84 -:F 1 -:G 330 -:H 4 -:I 6 -:J 0.00 -:K 879 -:L 178 -:M 234 -:N 288 -:O 0.00 -:P 629 -:Q 67 -:R 423 -:S 692 -:T 377 -:U 0.00 -:V 475 -:W 50 -:X 0.00 -:Y 148 -:Z 0.00 A:A 8356 A:B 0.00 A:C 0.00 A:D 11 A:E 237 A:F 0.00 A:G 872 A:H 5 A:I 19 A:J 0.00 A:K 412 A:L 16 A:M 12 A:N 112 A:O 0.00 A:P 698 A:Q 71 A:R 61 A:S 1072 A:T 875 A:U 0.00 A:V 902 A:W 7 A:X 0.00 A:Y 0.00 A:Z 0.00 B:B 0.00 B:C 0.00 B:D 0.00 B:E 0.00 B:F 0.00 B:G 0.00 B:H 0.00 B:I 0.00 B:J 0.00 B:K 0.00 B:L 0.00 B:M 0.00 B:N 0.00 B:O 0.00 B:P 0.00 B:Q 0.00 B:R 0.00 B:S 0.00 B:T 0.00 B:U 0.00 B:V 0.00 B:W 0.00 B:X 0.00 B:Y 0.00 B:Z 0.00 C:C 1 C:D 0.00 C:E 0.00 C:F 96 C:G 50 C:H 0.00 C:I 0.00 C:J 0.00 C:K 0.00 C:L 2 C:M 0.00 C:N 0.00 C:O 0.00 C:P 0.00 C:Q 0.00 C:R 0.00 C:S 0.00 C:T 0.00 C:U 0.00 C:V 0.00 C:W 0.00 C:X 0.00 C:Y 0.00 C:Z 0.00 D:D 9289 D:E 957 D:F 0.00 D:G 180 D:H 0.00 D:I 3 D:J 0.00 D:K 0.00 D:L 0.00 D:M 0.00 D:N 55 D:O 0.00 D:P 37 D:Q 36 D:R 99 D:S 117 D:T 125 D:U 0.00 D:V 45 D:W 0.00 D:X 0.00 D:Y 50 D:Z 0.00 E:E 9911 E:F 0.00 E:G 667 E:H 49 E:I 34 E:J 0.00 E:K 147 E:L 50 E:M 0.00 E:N 14 E:O 0.00 E:P 218 E:Q 461 E:R 1 E:S 157 E:T 129 E:U 0.00 E:V 173 E:W 0.00 E:X 0.00 E:Y 0.00 E:Z 0.00 F:F 5946 F:G 0.00 F:H 0.00 F:I 0.00 F:J 0.00 F:K 0.00 F:L 365 F:M 0.00 F:N 0.00 F:O 0.00 F:P 0.00 F:Q 0.00 F:R 0.00 F:S 1 F:T 0.00 F:U 0.00 F:V 2 F:W 52 F:X 0.00 F:Y 141 F:Z 0.00 G:G 15636 G:H 0.00 G:I 14 G:J 0.00 G:K 35 G:L 52 G:M 4 G:N 82 G:O 0.00 G:P 243 G:Q 179 G:R 9 G:S 355 G:T 150 G:U 0.00 G:V 456 G:W 0.00 G:X 0.00 G:Y 0.00 G:Z 0.00 H:H 0.00 H:I 0.00 H:J 0.00 H:K 2 H:L 0.00 H:M 0.00 H:N 0.00 H:O 0.00 H:P 49 H:Q 0.00 H:R 0.00 H:S 3 H:T 38 H:U 0.00 H:V 0.00 H:W 0.00 H:X 0.00 H:Y 0.00 H:Z 0.00 I:I 781 I:J 0.00 I:K 0.00 I:L 1113 I:M 0.00 I:N 6 I:O 0.00 I:P 433 I:Q 0.00 I:R 0.00 I:S 155 I:T 91 I:U 0.00 I:V 112 I:W 2 I:X 0.00 I:Y 0.00 I:Z 0.00 J:J 0.00 J:K 0.00 J:L 0.00 J:M 0.00 J:N 0.00 J:O 0.00 J:P 0.00 J:Q 0.00 J:R 0.00 J:S 0.00 J:T 0.00 J:U 0.00 J:V 0.00 J:W 0.00 J:X 0.00 J:Y 0.00 J:Z 0.00 K:K 6931 K:L 412 K:M 49 K:N 8 K:O 0.00 K:P 268 K:Q 6 K:R 870 K:S 404 K:T 324 K:U 0.00 K:V 22 K:W 0.00 K:X 0.00 K:Y 0.00 K:Z 0.00 L:L 10639 L:M 9 L:N 26 L:O 0.00 L:P 242 L:Q 0.00 L:R 47 L:S 7 L:T 128 L:U 0.00 L:V 525 L:W 0.00 L:X 0.00 L:Y 50 L:Z 0.00 M:M 1035 M:N 1 M:O 0.00 M:P 1 M:Q 0.00 M:R 1 M:S 6 M:T 13 M:U 0.00 M:V 0.00 M:W 0.00 M:X 0.00 M:Y 0.00 M:Z 0.00 N:N 1186 N:O 0.00 N:P 5 N:Q 16 N:R 8 N:S 89 N:T 228 N:U 0.00 N:V 42 N:W 0.00 N:X 0.00 N:Y 98 N:Z 0.00 O:O 0.00 O:P 0.00 O:Q 0.00 O:R 0.00 O:S 0.00 O:T 0.00 O:U 0.00 O:V 0.00 O:W 0.00 O:X 0.00 O:Y 0.00 O:Z 0.00 P:P 12009 P:Q 34 P:R 52 P:S 1012 P:T 399 P:U 0.00 P:V 547 P:W 15 P:X 0.00 P:Y 0.00 P:Z 0.00 Q:Q 61 Q:R 1 Q:S 152 Q:T 23 Q:U 0.00 Q:V 32 Q:W 0.00 Q:X 0.00 Q:Y 0.00 Q:Z 0.00 R:R 3652 R:S 41 R:T 33 R:U 0.00 R:V 0.00 R:W 0.00 R:X 0.00 R:Y 0.00 R:Z 0.00 S:S 6355 S:T 541 S:U 0.00 S:V 73 S:W 63 S:X 0.00 S:Y 0.00 S:Z 0.00 T:T 4355 T:U 0.00 T:V 304 T:W 12 T:X 0.00 T:Y 50 T:Z 0.00 U:U 0.00 U:V 0.00 U:W 0.00 U:X 0.00 U:Y 0.00 U:Z 0.00 V:V 3145 V:W 0.00 V:X 0.00 V:Y 0.00 V:Z 0.00 W:W 2401 W:X 0.00 W:Y 47 W:Z 0.00 X:X 0.00 X:Y 0.00 X:Z 0.00 Y:Y 6033 Y:Z 0.00 Z:Z 0.00 endpaired unpaired internal - 351 A 460 B 0.00 C 3 D 408 E 464 F 251 G 699 H 3 I 71 J 0.00 K 354 L 490 M 48 N 69 O 0.00 P 578 Q 24 R 179 S 353 T 251 U 0.00 V 200 W 101 X 0.00 Y 253 Z 0.00 endunpaired paired external -:- 2260 -:A 2 -:B 0.00 -:C 0.00 -:D 0.00 -:E 0.00 -:F 0.00 -:G 0.00 -:H 0.00 -:I 0.00 -:J 0.00 -:K 92 -:L 0.00 -:M 0.00 -:N 45 -:O 0.00 -:P 0.00 -:Q 46 -:R 50 -:S 1 -:T 46 -:U 0.00 -:V 48 -:W 0.00 -:X 0.00 -:Y 0.00 -:Z 0.00 A:A 7600 A:B 0.00 A:C 1 A:D 86 A:E 66 A:F 161 A:G 139 A:H 0.00 A:I 1 A:J 0.00 A:K 138 A:L 123 A:M 0.00 A:N 644 A:O 0.00 A:P 186 A:Q 35 A:R 0.00 A:S 1605 A:T 141 A:U 0.00 A:V 327 A:W 0.00 A:X 0.00 A:Y 145 A:Z 0.00 B:B 0.00 B:C 0.00 B:D 0.00 B:E 0.00 B:F 0.00 B:G 0.00 B:H 0.00 B:I 0.00 B:J 0.00 B:K 0.00 B:L 0.00 B:M 0.00 B:N 0.00 B:O 0.00 B:P 0.00 B:Q 0.00 B:R 0.00 B:S 0.00 B:T 0.00 B:U 0.00 B:V 0.00 B:W 0.00 B:X 0.00 B:Y 0.00 B:Z 0.00 C:C 0.00 C:D 0.00 C:E 0.00 C:F 0.00 C:G 0.00 C:H 0.00 C:I 0.00 C:J 0.00 C:K 0.00 C:L 0.00 C:M 0.00 C:N 0.00 C:O 0.00 C:P 1 C:Q 0.00 C:R 0.00 C:S 0.00 C:T 3 C:U 0.00 C:V 45 C:W 0.00 C:X 0.00 C:Y 0.00 C:Z 0.00 D:D 3495 D:E 320 D:F 0.00 D:G 100 D:H 0.00 D:I 0.00 D:J 0.00 D:K 44 D:L 0.00 D:M 0.00 D:N 147 D:O 0.00 D:P 0.00 D:Q 58 D:R 0.00 D:S 50 D:T 6 D:U 0.00 D:V 2 D:W 47 D:X 0.00 D:Y 0.00 D:Z 0.00 E:E 3347 E:F 0.00 E:G 2 E:H 0.00 E:I 0.00 E:J 0.00 E:K 44 E:L 0.00 E:M 0.00 E:N 1 E:O 0.00 E:P 0.00 E:Q 190 E:R 0.00 E:S 30 E:T 2 E:U 0.00 E:V 0.00 E:W 1 E:X 0.00 E:Y 0.00 E:Z 0.00 F:F 5036 F:G 0.00 F:H 0.00 F:I 13 F:J 0.00 F:K 0.00 F:L 105 F:M 0.00 F:N 17 F:O 0.00 F:P 0.00 F:Q 0.00 F:R 0.00 F:S 74 F:T 4 F:U 0.00 F:V 4 F:W 96 F:X 0.00 F:Y 454 F:Z 0.00 G:G 9902 G:H 0.00 G:I 0.00 G:J 0.00 G:K 193 G:L 0.00 G:M 0.00 G:N 2 G:O 0.00 G:P 4 G:Q 2 G:R 49 G:S 51 G:T 5 G:U 0.00 G:V 98 G:W 1 G:X 0.00 G:Y 0.00 G:Z 0.00 H:H 1275 H:I 0.00 H:J 0.00 H:K 0.00 H:L 0.00 H:M 0.00 H:N 0.00 H:O 0.00 H:P 0.00 H:Q 0.00 H:R 0.00 H:S 0.00 H:T 0.00 H:U 0.00 H:V 0.00 H:W 0.00 H:X 0.00 H:Y 50 H:Z 0.00 I:I 1426 I:J 0.00 I:K 0.00 I:L 808 I:M 0.00 I:N 1 I:O 0.00 I:P 0.00 I:Q 1 I:R 0.00 I:S 1 I:T 0.00 I:U 0.00 I:V 89 I:W 0.00 I:X 0.00 I:Y 34 I:Z 0.00 J:J 0.00 J:K 0.00 J:L 0.00 J:M 0.00 J:N 0.00 J:O 0.00 J:P 0.00 J:Q 0.00 J:R 0.00 J:S 0.00 J:T 0.00 J:U 0.00 J:V 0.00 J:W 0.00 J:X 0.00 J:Y 0.00 J:Z 0.00 K:K 3191 K:L 0.00 K:M 11 K:N 361 K:O 0.00 K:P 0.00 K:Q 133 K:R 385 K:S 90 K:T 138 K:U 0.00 K:V 45 K:W 22 K:X 0.00 K:Y 22 K:Z 0.00 L:L 5074 L:M 0.00 L:N 2 L:O 0.00 L:P 49 L:Q 1 L:R 0.00 L:S 14 L:T 1 L:U 0.00 L:V 248 L:W 48 L:X 0.00 L:Y 3 L:Z 0.00 M:M 0.00 M:N 0.00 M:O 0.00 M:P 0.00 M:Q 0.00 M:R 35 M:S 0.00 M:T 0.00 M:U 0.00 M:V 0.00 M:W 2 M:X 0.00 M:Y 2 M:Z 0.00 N:N 7464 N:O 0.00 N:P 0.00 N:Q 3 N:R 0.00 N:S 207 N:T 86 N:U 0.00 N:V 168 N:W 1 N:X 0.00 N:Y 37 N:Z 0.00 O:O 0.00 O:P 0.00 O:Q 0.00 O:R 0.00 O:S 0.00 O:T 0.00 O:U 0.00 O:V 0.00 O:W 0.00 O:X 0.00 O:Y 0.00 O:Z 0.00 P:P 3731 P:Q 0.00 P:R 50 P:S 0.00 P:T 103 P:U 0.00 P:V 45 P:W 0.00 P:X 0.00 P:Y 0.00 P:Z 0.00 Q:Q 1279 Q:R 0.00 Q:S 17 Q:T 6 Q:U 0.00 Q:V 50 Q:W 0.00 Q:X 0.00 Q:Y 0.00 Q:Z 0.00 R:R 595 R:S 1 R:T 0.00 R:U 0.00 R:V 0.00 R:W 70 R:X 0.00 R:Y 70 R:Z 0.00 S:S 2017 S:T 6 S:U 0.00 S:V 76 S:W 0.00 S:X 0.00 S:Y 43 S:Z 0.00 T:T 1230 T:U 0.00 T:V 190 T:W 0.00 T:X 0.00 T:Y 3 T:Z 0.00 U:U 0.00 U:V 0.00 U:W 0.00 U:X 0.00 U:Y 0.00 U:Z 0.00 V:V 4431 V:W 0.00 V:X 0.00 V:Y 3 V:Z 0.00 W:W 2404 W:X 0.00 W:Y 4 W:Z 0.00 X:X 0.00 X:Y 0.00 X:Z 0.00 Y:Y 1790 Y:Z 0.00 Z:Z 0.00 endpaired unpaired external - 97 A 380 B 0.00 C 1 D 157 E 147 F 220 G 409 H 52 I 76 J 0.00 K 162 L 231 M 1 N 333 O 0.00 P 158 Q 62 R 38 S 126 T 64 U 0.00 V 206 W 102 X 0.00 Y 89 Z 0.00 endunpaired paired hydrophobic -:- 0.00 -:A 0.00 -:B 0.00 -:C 0.00 -:D 0.00 -:E 0.00 -:F 0.00 -:G 0.00 -:H 0.00 -:I 0.00 -:J 0.00 -:K 0.00 -:L 0.00 -:M 0.00 -:N 0.00 -:O 0.00 -:P 0.00 -:Q 0.00 -:R 0.00 -:S 0.00 -:T 0.00 -:U 0.00 -:V 0.00 -:W 0.00 -:X 0.00 -:Y 0.00 -:Z 0.00 A:A 9335 A:B 0.00 A:C 108 A:D 0.00 A:E 0.00 A:F 230 A:G 302 A:H 0.00 A:I 26 A:J 0.00 A:K 0.00 A:L 315 A:M 0.00 A:N 11 A:O 0.00 A:P 0.00 A:Q 2 A:R 0.00 A:S 97 A:T 109 A:U 0.00 A:V 80 A:W 0.00 A:X 0.00 A:Y 0.00 A:Z 0.00 B:B 0.00 B:C 0.00 B:D 0.00 B:E 0.00 B:F 0.00 B:G 0.00 B:H 0.00 B:I 0.00 B:J 0.00 B:K 0.00 B:L 0.00 B:M 0.00 B:N 0.00 B:O 0.00 B:P 0.00 B:Q 0.00 B:R 0.00 B:S 0.00 B:T 0.00 B:U 0.00 B:V 0.00 B:W 0.00 B:X 0.00 B:Y 0.00 B:Z 0.00 C:C 1937 C:D 0.00 C:E 0.00 C:F 60 C:G 78 C:H 0.00 C:I 98 C:J 0.00 C:K 0.00 C:L 0.00 C:M 98 C:N 0.00 C:O 0.00 C:P 0.00 C:Q 0.00 C:R 0.00 C:S 554 C:T 330 C:U 0.00 C:V 150 C:W 50 C:X 0.00 C:Y 0.00 C:Z 0.00 D:D 0.00 D:E 0.00 D:F 0.00 D:G 0.00 D:H 0.00 D:I 0.00 D:J 0.00 D:K 0.00 D:L 0.00 D:M 0.00 D:N 0.00 D:O 0.00 D:P 0.00 D:Q 0.00 D:R 0.00 D:S 0.00 D:T 0.00 D:U 0.00 D:V 0.00 D:W 0.00 D:X 0.00 D:Y 0.00 D:Z 0.00 E:E 2550 E:F 0.00 E:G 0.00 E:H 0.00 E:I 0.00 E:J 0.00 E:K 0.00 E:L 0.00 E:M 0.00 E:N 0.00 E:O 0.00 E:P 49 E:Q 1 E:R 0.00 E:S 0.00 E:T 0.00 E:U 0.00 E:V 0.00 E:W 0.00 E:X 0.00 E:Y 0.00 E:Z 0.00 F:F 6104 F:G 0.00 F:H 0.00 F:I 0.00 F:J 0.00 F:K 0.00 F:L 330 F:M 0.00 F:N 0.00 F:O 0.00 F:P 0.00 F:Q 0.00 F:R 0.00 F:S 4 F:T 210 F:U 0.00 F:V 10 F:W 0.00 F:X 0.00 F:Y 98 F:Z 0.00 G:G 8731 G:H 0.00 G:I 0.00 G:J 0.00 G:K 0.00 G:L 0.00 G:M 0.00 G:N 0.00 G:O 0.00 G:P 0.00 G:Q 0.00 G:R 50 G:S 57 G:T 2 G:U 0.00 G:V 49 G:W 0.00 G:X 0.00 G:Y 0.00 G:Z 0.00 H:H 2550 H:I 0.00 H:J 0.00 H:K 0.00 H:L 0.00 H:M 0.00 H:N 0.00 H:O 0.00 H:P 0.00 H:Q 0.00 H:R 50 H:S 0.00 H:T 0.00 H:U 0.00 H:V 0.00 H:W 0.00 H:X 0.00 H:Y 0.00 H:Z 0.00 I:I 5218 I:J 0.00 I:K 0.00 I:L 448 I:M 48 I:N 0.00 I:O 0.00 I:P 0.00 I:Q 0.00 I:R 0.00 I:S 0.00 I:T 95 I:U 0.00 I:V 2349 I:W 0.00 I:X 0.00 I:Y 0.00 I:Z 0.00 J:J 0.00 J:K 0.00 J:L 0.00 J:M 0.00 J:N 0.00 J:O 0.00 J:P 0.00 J:Q 0.00 J:R 0.00 J:S 0.00 J:T 0.00 J:U 0.00 J:V 0.00 J:W 0.00 J:X 0.00 J:Y 0.00 J:Z 0.00 K:K 1275 K:L 0.00 K:M 0.00 K:N 50 K:O 0.00 K:P 0.00 K:Q 50 K:R 0.00 K:S 0.00 K:T 0.00 K:U 0.00 K:V 0.00 K:W 0.00 K:X 0.00 K:Y 0.00 K:Z 0.00 L:L 9469 L:M 96 L:N 0.00 L:O 0.00 L:P 0.00 L:Q 0.00 L:R 0.00 L:S 49 L:T 3 L:U 0.00 L:V 433 L:W 188 L:X 0.00 L:Y 0.00 L:Z 0.00 M:M 4854 M:N 0.00 M:O 0.00 M:P 0.00 M:Q 0.00 M:R 0.00 M:S 0.00 M:T 0.00 M:U 0.00 M:V 0.00 M:W 0.00 M:X 0.00 M:Y 0.00 M:Z 0.00 N:N 1280 N:O 0.00 N:P 0.00 N:Q 22 N:R 0.00 N:S 457 N:T 0.00 N:U 0.00 N:V 0.00 N:W 0.00 N:X 0.00 N:Y 0.00 N:Z 0.00 O:O 0.00 O:P 0.00 O:Q 0.00 O:R 0.00 O:S 0.00 O:T 0.00 O:U 0.00 O:V 0.00 O:W 0.00 O:X 0.00 O:Y 0.00 O:Z 0.00 P:P 2451 P:Q 49 P:R 0.00 P:S 0.00 P:T 0.00 P:U 0.00 P:V 0.00 P:W 0.00 P:X 0.00 P:Y 0.00 P:Z 0.00 Q:Q 3776 Q:R 0.00 Q:S 74 Q:T 0.00 Q:U 0.00 Q:V 0.00 Q:W 0.00 Q:X 0.00 Q:Y 0.00 Q:Z 0.00 R:R 3775 R:S 0.00 R:T 0.00 R:U 0.00 R:V 0.00 R:W 0.00 R:X 0.00 R:Y 0.00 R:Z 0.00 S:S 3338 S:T 72 S:U 0.00 S:V 10 S:W 0.00 S:X 0.00 S:Y 0.00 S:Z 0.00 T:T 1287 T:U 0.00 T:V 105 T:W 0.00 T:X 0.00 T:Y 0.00 T:Z 0.00 U:U 0.00 U:V 0.00 U:W 0.00 U:X 0.00 U:Y 0.00 U:Z 0.00 V:V 8357 V:W 0.00 V:X 0.00 V:Y 0.00 V:Z 0.00 W:W 2306 W:X 0.00 W:Y 0.00 W:Z 0.00 X:X 0.00 X:Y 0.00 X:Z 0.00 Y:Y 1176 Y:Z 0.00 Z:Z 0.00 endpaired unpaired hydrophobic - 0.00 A 399 B 0.00 C 108 D 0.00 E 103 F 263 G 360 H 103 I 270 J 0.00 K 53 L 416 M 199 N 62 O 0.00 P 100 Q 155 R 153 S 161 T 70 U 0.00 V 398 W 97 X 0.00 Y 49 Z 0.00 endunpaired endtmfreq wise-2.4.1/wisecfg/gene.stat0000644000175000001440000000736507463470413015336 0ustar philippusers# # new genestats file # splice3 10 ENSE00000673410 TCCCACATAGATCA ENSE00000673409 TATCCTGCAGTATG ENSE00000673408 TTTGCTATAGATTA ENSE00000673407 GGTTTTTCAGTTGC ENSE00000401072 CTCCCATTAGGGTT ENSE00000868868 TTATTTCTAGCTGA ENSE00000401061 CTTTGGTTAGGCAG ENSE00000673400 GTTCTCCCAGGCCT ENSE00000673402 TGTTTTATAGGGAT ENSE00000673403 CTTCTTTCAGAATG ENSE00000868865 ATTATCTTAGTTTC ENSE00000662824 ATTTTTTTAGTGGA ENSE00000662823 TCATTTTTAGGAAC ENSE00000662822 CAAATTTCAGCCAA ENSE00000662821 TATTCTACAGGAAG ENSE00000662820 TATTTGGCAGCCGT ENSE00000662819 TTTCTTACAGATTA ENSE00000814444 ATTTTTAAAGCATT ENSE00000814445 TTTTTTCCAGGGAC ENSE00000814446 CTCTGTCTAGTTTC ENSE00000814447 CTGCTTTTAGTCTC ENSE00000814448 TGGATTTCAGTTTC ENSE00000789672 TGGCATTTAGAAAT ENSE00000789671 TTGTCCTCAGATTT ENSE00000814451 TTTCGGGTAGATCA ENSE00000814452 TTGCTCCTAGGTTT ENSE00000789668 TTCCCTACAGGCGA ENSE00000789652 TTCTTTGCAGTTAT ENSE00000789653 ATTCATTTAGGCAG ENSE00000789654 TTTGGATCAGGATA ENSE00000789655 TTTATTTTAGGAAT ENSE00000789656 CCCTTCCCAGCAAG ENSE00000789657 TACATGTAAGACCT ENSE00000789658 TTCCCTGCAGGATA ENSE00000789659 TTTTGATTAGGATG ENSE00000789660 TATATTGCAGATAT ENSE00000789661 CTTTTTCCAGATAA ENSE00000789662 TTTATTTCAGCTGG ENSE00000450960 TGTCCTTCAGAACA ENSE00000789663 TGTTTCTTAGGTAG ENSE00000789664 ACCTCTGTAGGCAG ENSE00000789665 GTTCTTTTAGGACA ENSE00000789666 TTTTTAATAGGGAA ENSE00000450963 TCCCTGGCAGACTG ENSE00000813771 AACTTTTCAGCTCT ENSE00000813770 TATTACACAGGATT // splice5 5 ENSE00000673410 ACTGGTGAGTCCTT ENSE00000673409 TGAGGTAAGCCTGA ENSE00000673408 TACGGTAAGTGGTA ENSE00000673407 TGAAGTAAGGTGCC ENSE00000401072 CCAAGTAAGTTTTT ENSE00000868868 TAAGGTGCGTTCAT ENSE00000401061 AAAAGTAAGTAAAT ENSE00000673400 AAACGTAAGTTGGA ENSE00000673402 TGAGGTATGTAAGA ENSE00000673403 TCAGGTATGACATT ENSE00000868865 CTATGTGAGTTATG ENSE00000662824 GTAAGTTATAAGAA ENSE00000662823 CCATGTAAGTGGTA ENSE00000662822 TTAGGTAGGTACTA ENSE00000662821 TCAGGTAGGTACAT ENSE00000662820 TCAGGTACAGTGAA ENSE00000662819 CGAGGTATGCAACT ENSE00000814444 CAGAGTAAGTAACC ENSE00000814445 AGAGGTAAGCCAGG ENSE00000814446 GATGGTAAGATGAT ENSE00000814447 CAGGGTGAGTTGGA ENSE00000814448 TCAGGTGAGGGCAT ENSE00000789672 TTAAGTAAGTTCAG ENSE00000789671 AAAGGTGAATGCTT ENSE00000814451 ACAGGTCAGAGGCC ENSE00000814452 GAAGGTAAGAATTA ENSE00000789668 TGAGGTGAGTACTT ENSE00000789652 TTAAGTAAGTTTGT ENSE00000789653 ACAGGTAAAATTTG ENSE00000789654 TAAGGTAAGGCTTT ENSE00000789655 ACAGGTAAGAAGAA ENSE00000789656 TTAGGTAAGCTTCA // # A G C T N intron_emission 0.25 0.25 0.25 0.25 0.25 // polyp_emission 0.2 0.2 0.3 0.3 0.25 // rnd_emission 0.25 0.25 0.25 0.25 0.25 1.0 // rndcodon AAA 5290.000000 AAC 4795.000000 AAG 8178.000000 AAT 3305.000000 ACA 6240.000000 ACC 7728.000000 ACG 3347.000000 ACT 4930.000000 AGA 8491.000000 AGC 8639.000000 AGG 8997.000000 AGT 4417.000000 ATA 1975.000000 ATC 4973.000000 ATG 6474.000000 ATT 3083.000000 CAA 7057.000000 CAC 6815.000000 CAG 11041.000000 CAT 5779.000000 CCA 10537.000000 CCC 10307.000000 CCG 5621.000000 CCT 10134.000000 CGA 3377.000000 CGC 5146.000000 CGG 5375.000000 CGT 2765.000000 CTA 3502.000000 CTC 7465.000000 CTG 13780.000000 CTT 5453.000000 GAA 7461.000000 GAC 6937.000000 GAG 9975.000000 GAT 4949.000000 GCA 7747.000000 GCC 10890.000000 GCG 4828.000000 GCT 9371.000000 GGA 10143.000000 GGC 10400.000000 GGG 8869.000000 GGT 5567.000000 GTA 2143.000000 GTC 4593.000000 GTG 8189.000000 GTT 3021.000000 TAA 1775.000000 TAC 3687.000000 TAG 1333.000000 TAT 2477.000000 TCA 6180.000000 TCC 7668.000000 TCG 2875.000000 TCT 5767.000000 TGA 7315.000000 TGC 8625.000000 TGG 11718.000000 TGT 5197.000000 TTA 1664.000000 TTC 5462.000000 TTG 4420.000000 TTT 3453.000000 // wise-2.4.1/wisecfg/BLOSUM30.bla0000644000175000001440000000403007313404521015320 0ustar philippusers# Matrix made by matblas from blosum30.iij # * column uses minimum score # BLOSUM Clustered Scoring Matrix in 1/5 Bit Units # Blocks Database = /data/blocks_5.0/blocks.dat # Cluster Percentage: >= 30 # Entropy = 0.1424, Expected = -0.1074 A R N D C Q E G H I L K M F P S T W Y V B Z X * 4 -1 0 0 -3 1 0 0 -2 0 -1 0 1 -2 -1 1 1 -5 -4 1 0 0 0 -7 -1 8 -2 -1 -2 3 -1 -2 -1 -3 -2 1 0 -1 -1 -1 -3 0 0 -1 -2 0 -1 -7 0 -2 8 1 -1 -1 -1 0 -1 0 -2 0 0 -1 -3 0 1 -7 -4 -2 4 -1 0 -7 0 -1 1 9 -3 -1 1 -1 -2 -4 -1 0 -3 -5 -1 0 -1 -4 -1 -2 5 0 -1 -7 -3 -2 -1 -3 17 -2 1 -4 -5 -2 0 -3 -2 -3 -3 -2 -2 -2 -6 -2 -2 0 -2 -7 1 3 -1 -1 -2 8 2 -2 0 -2 -2 0 -1 -3 0 -1 0 -1 -1 -3 -1 4 0 -7 0 -1 -1 1 1 2 6 -2 0 -3 -1 2 -1 -4 1 0 -2 -1 -2 -3 0 5 -1 -7 0 -2 0 -1 -4 -2 -2 8 -3 -1 -2 -1 -2 -3 -1 0 -2 1 -3 -3 0 -2 -1 -7 -2 -1 -1 -2 -5 0 0 -3 14 -2 -1 -2 2 -3 1 -1 -2 -5 0 -3 -2 0 -1 -7 0 -3 0 -4 -2 -2 -3 -1 -2 6 2 -2 1 0 -3 -1 0 -3 -1 4 -2 -3 0 -7 -1 -2 -2 -1 0 -2 -1 -2 -1 2 4 -2 2 2 -3 -2 0 -2 3 1 -1 -1 0 -7 0 1 0 0 -3 0 2 -1 -2 -2 -2 4 2 -1 1 0 -1 -2 -1 -2 0 1 0 -7 1 0 0 -3 -2 -1 -1 -2 2 1 2 2 6 -2 -4 -2 0 -3 -1 0 -2 -1 0 -7 -2 -1 -1 -5 -3 -3 -4 -3 -3 0 2 -1 -2 10 -4 -1 -2 1 3 1 -3 -4 -1 -7 -1 -1 -3 -1 -3 0 1 -1 1 -3 -3 1 -4 -4 11 -1 0 -3 -2 -4 -2 0 -1 -7 1 -1 0 0 -2 -1 0 0 -1 -1 -2 0 -2 -1 -1 4 2 -3 -2 -1 0 -1 0 -7 1 -3 1 -1 -2 0 -2 -2 -2 0 0 -1 0 -2 0 2 5 -5 -1 1 0 -1 0 -7 -5 0 -7 -4 -2 -1 -1 1 -5 -3 -2 -2 -3 1 -3 -3 -5 20 5 -3 -5 -1 -2 -7 -4 0 -4 -1 -6 -1 -2 -3 0 -1 3 -1 -1 3 -2 -2 -1 5 9 1 -3 -2 -1 -7 1 -1 -2 -2 -2 -3 -3 -3 -3 4 1 -2 0 1 -4 -1 1 -3 1 5 -2 -3 0 -7 0 -2 4 5 -2 -1 0 0 -2 -2 -1 0 -2 -3 -2 0 0 -5 -3 -2 5 0 -1 -7 0 0 -1 0 0 4 5 -2 0 -3 -1 1 -1 -4 0 -1 -1 -1 -2 -3 0 4 0 -7 0 -1 0 -1 -2 0 -1 -1 -1 0 0 0 0 -1 -1 0 0 -2 -1 0 -1 0 -1 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 -7 1 wise-2.4.1/wisecfg/BLOSUM45.bla0000644000175000001440000000316707313404522015341 0ustar philippusers# Matrix made by matblas from blosum45.iij # * column uses minimum score # BLOSUM Clustered Scoring Matrix in 1/3 Bit Units # Blocks Database = /data/blocks_5.0/blocks.dat # Cluster Percentage: >= 45 # Entropy = 0.3795, Expected = -0.2789 A R N D C Q E G H I L K M F P S T W Y V * 5 -2 -1 -2 -1 -1 -1 0 -2 -1 -1 -1 -1 -2 -1 1 0 -2 -2 0 -5 -2 7 0 -1 -3 1 0 -2 0 -3 -2 3 -1 -2 -2 -1 -1 -2 -1 -2 -5 -1 0 6 2 -2 0 0 0 1 -2 -3 0 -2 -2 -2 1 0 -4 -2 -3 -5 -2 -1 2 7 -3 0 2 -1 0 -4 -3 0 -3 -4 -1 0 -1 -4 -2 -3 -5 -1 -3 -2 -3 12 -3 -3 -3 -3 -3 -2 -3 -2 -2 -4 -1 -1 -5 -3 -1 -5 -1 1 0 0 -3 6 2 -2 1 -2 -2 1 0 -4 -1 0 -1 -2 -1 -3 -5 -1 0 0 2 -3 2 6 -2 0 -3 -2 1 -2 -3 0 0 -1 -3 -2 -3 -5 0 -2 0 -1 -3 -2 -2 7 -2 -4 -3 -2 -2 -3 -2 0 -2 -2 -3 -3 -5 -2 0 1 0 -3 1 0 -2 10 -3 -2 -1 0 -2 -2 -1 -2 -3 2 -3 -5 -1 -3 -2 -4 -3 -2 -3 -4 -3 5 2 -3 2 0 -2 -2 -1 -2 0 3 -5 -1 -2 -3 -3 -2 -2 -2 -3 -2 2 5 -3 2 1 -3 -3 -1 -2 0 1 -5 -1 3 0 0 -3 1 1 -2 -1 -3 -3 5 -1 -3 -1 -1 -1 -2 -1 -2 -5 -1 -1 -2 -3 -2 0 -2 -2 0 2 2 -1 6 0 -2 -2 -1 -2 0 1 -5 -2 -2 -2 -4 -2 -4 -3 -3 -2 0 1 -3 0 8 -3 -2 -1 1 3 0 -5 -1 -2 -2 -1 -4 -1 0 -2 -2 -2 -3 -1 -2 -3 9 -1 -1 -3 -3 -3 -5 1 -1 1 0 -1 0 0 0 -1 -2 -3 -1 -2 -2 -1 4 2 -4 -2 -1 -5 0 -1 0 -1 -1 -1 -1 -2 -2 -1 -1 -1 -1 -1 -1 2 5 -3 -1 0 -5 -2 -2 -4 -4 -5 -2 -3 -2 -3 -2 -2 -2 -2 1 -3 -4 -3 15 3 -3 -5 -2 -1 -2 -2 -3 -1 -2 -3 2 0 0 -1 0 3 -3 -2 -1 3 8 -1 -5 0 -2 -3 -3 -1 -3 -3 -3 -3 3 1 -2 1 0 -3 -1 0 -3 -1 5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 1 wise-2.4.1/wisecfg/BLOSUM62.bla0000644000175000001440000000316707313404522015340 0ustar philippusers# Matrix made by matblas from blosum62.iij # * column uses minimum score # BLOSUM Clustered Scoring Matrix in 1/2 Bit Units # Blocks Database = /data/blocks_5.0/blocks.dat # Cluster Percentage: >= 62 # Entropy = 0.6979, Expected = -0.5209 A R N D C Q E G H I L K M F P S T W Y V * 4 -1 -2 -2 0 -1 -1 0 -2 -1 -1 -1 -1 -2 -1 1 0 -3 -2 0 -4 -1 5 0 -2 -3 1 0 -2 0 -3 -2 2 -1 -3 -2 -1 -1 -3 -2 -3 -4 -2 0 6 1 -3 0 0 0 1 -3 -3 0 -2 -3 -2 1 0 -4 -2 -3 -4 -2 -2 1 6 -3 0 2 -1 -1 -3 -4 -1 -3 -3 -1 0 -1 -4 -3 -3 -4 0 -3 -3 -3 9 -3 -4 -3 -3 -1 -1 -3 -1 -2 -3 -1 -1 -2 -2 -1 -4 -1 1 0 0 -3 5 2 -2 0 -3 -2 1 0 -3 -1 0 -1 -2 -1 -2 -4 -1 0 0 2 -4 2 5 -2 0 -3 -3 1 -2 -3 -1 0 -1 -3 -2 -2 -4 0 -2 0 -1 -3 -2 -2 6 -2 -4 -4 -2 -3 -3 -2 0 -2 -2 -3 -3 -4 -2 0 1 -1 -3 0 0 -2 8 -3 -3 -1 -2 -1 -2 -1 -2 -2 2 -3 -4 -1 -3 -3 -3 -1 -3 -3 -4 -3 4 2 -3 1 0 -3 -2 -1 -3 -1 3 -4 -1 -2 -3 -4 -1 -2 -3 -4 -3 2 4 -2 2 0 -3 -2 -1 -2 -1 1 -4 -1 2 0 -1 -3 1 1 -2 -1 -3 -2 5 -1 -3 -1 0 -1 -3 -2 -2 -4 -1 -1 -2 -3 -1 0 -2 -3 -2 1 2 -1 5 0 -2 -1 -1 -1 -1 1 -4 -2 -3 -3 -3 -2 -3 -3 -3 -1 0 0 -3 0 6 -4 -2 -2 1 3 -1 -4 -1 -2 -2 -1 -3 -1 -1 -2 -2 -3 -3 -1 -2 -4 7 -1 -1 -4 -3 -2 -4 1 -1 1 0 -1 0 0 0 -1 -2 -2 0 -1 -2 -1 4 1 -3 -2 -2 -4 0 -1 0 -1 -1 -1 -1 -2 -2 -1 -1 -1 -1 -2 -1 1 5 -2 -2 0 -4 -3 -3 -4 -4 -2 -2 -3 -2 -2 -3 -2 -3 -1 1 -4 -3 -2 11 2 -3 -4 -2 -2 -2 -3 -2 -1 -2 -3 2 -1 -1 -2 -1 3 -3 -2 -2 2 7 -1 -4 0 -3 -3 -3 -1 -2 -2 -3 -3 3 1 -2 1 -1 -2 -2 0 -3 -1 4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 1 wise-2.4.1/wisecfg/BLOSUM80.bla0000644000175000001440000000403207313404522015330 0ustar philippusers# Matrix made by matblas from blosum80_3.iij # * column uses minimum score # BLOSUM Clustered Scoring Matrix in 1/3 Bit Units # Blocks Database = /data/blocks_5.0/blocks.dat # Cluster Percentage: >= 80 # Entropy = 0.9868, Expected = -0.7442 A R N D C Q E G H I L K M F P S T W Y V B Z X * 7 -3 -3 -3 -1 -2 -2 0 -3 -3 -3 -1 -2 -4 -1 2 0 -5 -4 -1 -3 -2 -1 -8 -3 9 -1 -3 -6 1 -1 -4 0 -5 -4 3 -3 -5 -3 -2 -2 -5 -4 -4 -2 0 -2 -8 -3 -1 9 2 -5 0 -1 -1 1 -6 -6 0 -4 -6 -4 1 0 -7 -4 -5 5 -1 -2 -8 -3 -3 2 10 -7 -1 2 -3 -2 -7 -7 -2 -6 -6 -3 -1 -2 -8 -6 -6 6 1 -3 -8 -1 -6 -5 -7 13 -5 -7 -6 -7 -2 -3 -6 -3 -4 -6 -2 -2 -5 -5 -2 -6 -7 -4 -8 -2 1 0 -1 -5 9 3 -4 1 -5 -4 2 -1 -5 -3 -1 -1 -4 -3 -4 -1 5 -2 -8 -2 -1 -1 2 -7 3 8 -4 0 -6 -6 1 -4 -6 -2 -1 -2 -6 -5 -4 1 6 -2 -8 0 -4 -1 -3 -6 -4 -4 9 -4 -7 -7 -3 -5 -6 -5 -1 -3 -6 -6 -6 -2 -4 -3 -8 -3 0 1 -2 -7 1 0 -4 12 -6 -5 -1 -4 -2 -4 -2 -3 -4 3 -5 -1 0 -2 -8 -3 -5 -6 -7 -2 -5 -6 -7 -6 7 2 -5 2 -1 -5 -4 -2 -5 -3 4 -6 -6 -2 -8 -3 -4 -6 -7 -3 -4 -6 -7 -5 2 6 -4 3 0 -5 -4 -3 -4 -2 1 -7 -5 -2 -8 -1 3 0 -2 -6 2 1 -3 -1 -5 -4 8 -3 -5 -2 -1 -1 -6 -4 -4 -1 1 -2 -8 -2 -3 -4 -6 -3 -1 -4 -5 -4 2 3 -3 9 0 -4 -3 -1 -3 -3 1 -5 -3 -2 -8 -4 -5 -6 -6 -4 -5 -6 -6 -2 -1 0 -5 0 10 -6 -4 -4 0 4 -2 -6 -6 -3 -8 -1 -3 -4 -3 -6 -3 -2 -5 -4 -5 -5 -2 -4 -6 12 -2 -3 -7 -6 -4 -4 -2 -3 -8 2 -2 1 -1 -2 -1 -1 -1 -2 -4 -4 -1 -3 -4 -2 7 2 -6 -3 -3 0 -1 -1 -8 0 -2 0 -2 -2 -1 -2 -3 -3 -2 -3 -1 -1 -4 -3 2 8 -5 -3 0 -1 -2 -1 -8 -5 -5 -7 -8 -5 -4 -6 -6 -4 -5 -4 -6 -3 0 -7 -6 -5 16 3 -5 -8 -5 -5 -8 -4 -4 -4 -6 -5 -3 -5 -6 3 -3 -2 -4 -3 4 -6 -3 -3 3 11 -3 -5 -4 -3 -8 -1 -4 -5 -6 -2 -4 -4 -6 -5 4 1 -4 1 -2 -4 -3 0 -5 -3 7 -6 -4 -2 -8 -3 -2 5 6 -6 -1 1 -2 -1 -6 -7 -1 -5 -6 -4 0 -1 -8 -5 -6 6 0 -3 -8 -2 0 -1 1 -7 5 6 -4 0 -6 -5 1 -3 -6 -2 -1 -2 -5 -4 -4 0 6 -1 -8 -1 -2 -2 -3 -4 -2 -2 -3 -2 -2 -2 -2 -2 -3 -3 -1 -1 -5 -3 -2 -3 -1 -2 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 1 wise-2.4.1/wisecfg/tm.pri0000644000175000001440000000513207313404523014636 0ustar philippusers# # # Ok - something hacked around for the Transmembrane model # # This is an example of a Brown-Haussler mixture Dirichlet prior. # Mix # Strategy (mixture Dirichlet) Amino # type of prior (Amino or Nucleic) # Transitions 2 # 2 component - first component an ungappy region. 0.3 # with probability = 1.0 10. 0.015 0.015 # m->m, m->i, m->d alpha's 10. 1.170 0.060 # i->m, i->i, i->d alpha's 10. 0.060 0.300 # d->m, d->i, d->d alpha's 0.7 # with probability = 1.0 2.970 0.015 0.015 # m->m, m->i, m->d alpha's 1.770 1.170 0.060 # i->m, i->i, i->d alpha's 2.640 0.060 0.300 # d->m, d->i, d->d alpha's # A C D E F G H I K L M N P Q R S T V W Y # ok # # 1st column meant to be a pretty heavy hyrdophobic prior thing. # # Match emissions # A C D E F G H I K L M N P Q R S T V W Y # 11 # 11 components 0.031 # A C D E F G H I K L M N P Q R S T V W Y 20. 15. 0.2 0.2 20. 4. 4. 20. 0.2 20. 20. 20. 4. 1. 0.2 4. 4. 20. 15. 15. 0.001 22.379 0.175 0.818 1.110 0.292 1.928 0.175 0.234 0.467 0.409 0.117 0.643 0.993 0.351 0.292 25.184 1.811 0.643 0.117 0.292 0.025 4.468 0.194 1.632 7.266 0.466 13.443 0.272 0.583 1.049 1.243 0.194 0.622 0.777 2.487 0.466 1.399 0.699 0.932 0.117 0.505 0.091 0.788 0.158 0.158 0.237 6.150 0.237 0.079 16.873 0.237 27.991 2.917 0.237 0.237 0.237 0.237 0.237 0.473 20.421 0.158 0.788 0.024 1.313 0.303 0.808 0.707 0.606 0.808 0.303 0.707 0.606 1.717 0.303 0.505 87.087 0.606 0.505 1.515 0.909 1.010 0.202 0.505 0.701 0.160 0.042 0.126 0.146 0.070 0.120 0.054 0.094 0.166 0.138 0.056 0.090 0.062 0.094 0.080 0.150 0.126 0.122 0.038 0.070 0.015 1.017 0.113 87.577 16.950 0.565 0.565 0.113 0.452 0.791 0.339 0.226 1.017 0.565 0.452 0.339 0.565 0.339 0.452 0.001 0.791 0.041 0.994 0.339 2.031 1.185 0.804 1.269 1.016 0.402 0.741 0.592 0.444 4.401 0.529 0.592 0.508 1.502 1.164 0.571 0.360 1.671 0.024 26.730 0.286 0.800 1.885 0.800 0.971 0.228 1.142 2.056 3.770 0.343 0.742 1.142 0.685 0.571 1.199 1.713 11.252 0.171 0.514 0.017 1.170 0.177 1.489 0.745 1.028 0.957 0.177 0.674 2.092 1.347 0.142 1.170 0.603 0.496 17.053 2.801 0.957 1.560 0.177 0.638 0.030 0.001 0.001 0.001 0.001 0.001 5793.873 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 ## Insert emissions 1 # Single component 1.0 # with probability 1.0 17430 6690 9370 9910 7950 17720 6720 7380 16100 17070 2950 8090 10140 7650 8180 13920 11710 12940 2100 5980 wise-2.4.1/wisecfg/wise.per0000644000175000001440000000410307313404523015156 0ustar philippusers! this is the wise config file ! for you to fool around with Remember ! lines are comments ! and keys should go flush with the left hand margin ! ! All wise.cfg's at the moment should have interactive key ! interactive ! ! This is the linkfile designation (for searchwise/swise) ! linkfile wise.links ! ! The next lines show a UNIX style background system ! queuecommand nice nohup csh addamperstand ! ! viewlength 20 ! ! view command for pairwise.... viewer more ! !viewbackground ! ! !The next two keys give default codon and matrix files !I'm using here the fact that pairwise/searchwise will open files !from WISECONFIGDIR if it can't open the file as the straight filename ! codondefault codon.table matrixdefault blosum62.bla ! ! ! The next lines give default for all situations gap and ext ! and other parameters ! gapdefault 1900 extdefault 200 framedefault 2500 frameextdefault 2000 stopdefault 500 ! !The next lines gives default specific for profiles or protein sequences !I've found these values by rule of thumb. These values will superceed ! the defaults above ! gap_pro 2200 ext_pro 200 gap_seq 700 ext_seq 70 ! !This gives the number of cells to report in PairWise ! reportrate 10000 ! !This tells the screen length in PairWise/Opensearch help files ! screenlength 20 ! !These give help files ! localhtmlhelp http://www.sanger.ac.uk/~birney/wise/help/ ! ! This gives the SRS link and library links ! srslink http://www.sanger.ac.uk/srs/srsc? srslibrary +-l+swissprot+-l+embl+-l+swissnew+-l+emnew ! ! This gives the sort of extensions to append to output file ! in searchwise ! outputappend .out htmlappend .html alignhtmlappend _aln.html alignappend .aln ! pairmainhelp pairmain.hlp pairalignhelp pairaln.hlp confighelp pairconfig.hlp ! protopmenuhelp buildprofile.hlp promatrixmenuhelp pwmatrix.hlp proweightmenuhelp pwweights.hlp progapmenuhelp pwgap.hlp ! searchmainhelp searchmain.hlp searchparahelp searchaln.hlp searchsubmithelp searchsubmit.hlp ! ! ! stagger 500 highscore 250 align 50 ! deletecom ! ! ! hard_linkage wise-2.4.1/wisecfg/wise.20000644000175000001440000000127707313404523014542 0ustar philippusers! Wise links files ! For use on molbiol ! modifed by ewan Nov 10th ! EMBL_FULL WiseDataDir:em.in ! EMBL_PRI WiseDataDir:empri.in ! EMBL_VER WiseDataDir:emver.in ! swiss swiss.in protein !tremblnr trembl.in protein !rrm rrm.in protein !rrmDNA rrmdna.in dna embl em.in dna EMBL_Est est.in dna !EMBL_without_est EMmEst.in dna EMBL_fun fun.in dna EMBL_inv inv.in dna EMBL_mam mam.in dna EMBL_org org.in dna EMBL_pat patent.in dna EMBL_phg phg.in dna EMBL_pln pln.in dna EMBL_pri pri.in dna EMBL_pro pro.in dna EMBL_rod rod.in dna EMBL_sts sts.in dna EMBL_syn syn.in dna EMBL_unc unc.in dna EMBL_vrl vrl.in dna EMBL_vrt vrt.in dna !SH2_Est sh2est.in dna !test test.in dna !test2 test2.in dna wise-2.4.1/wisecfg/gon120.bla0000644000175000001440000000621107313404522015166 0ustar philippusers# benner-gonnet matrix 2/95 # pam := 120 # print (DayhoffM (NewLogPAM1, pam)); # DayMatrix(Peptide, pam=120, Simil: max=16.556, min=-9.624, max offdiag=5.460, # del=-22.183-1.396*(k-1)) A R N D C Q E G H I L K M F P S T W Y V B Z X * 5.9 -2.3 -2.0 -1.8 -0.1 -1.2 -0.9 -0.3 -2.6 -2.7 -3.0 -1.9 -1.7 -4.8 -0.6 1.6 0.2 -6.8 -4.8 0.0 0.0 0.0 0.0 -9.6 -2.3 8.3 -1.0 -2.7 -4.5 1.6 -1.0 -3.0 -0.1 -5.3 -4.4 3.6 -3.8 -6.8 -3.0 -1.5 -1.6 -3.0 -3.7 -4.4 0.0 0.0 0.0 -9.6 -2.0 -1.0 8.0 2.6 -4.1 0.1 -0.1 -0.7 1.4 -5.5 -6.1 0.5 -4.6 -5.8 -3.2 1.0 0.0 -6.8 -2.8 -5.0 0.0 0.0 0.0 -9.6 -1.8 -2.7 2.6 8.2 -6.9 0.1 3.5 -1.4 -0.7 -8.0 -8.2 -0.8 -6.4 -8.7 -2.8 -0.5 -1.3 -9.6 -5.3 -6.5 0.0 0.0 0.0 -9.6 -0.1 -4.5 -4.1 -6.9 14.4 -5.6 -6.8 -4.5 -3.1 -3.6 -3.9 -6.4 -2.6 -2.6 -6.8 -0.7 -2.1 -2.9 -2.0 -1.1 0.0 0.0 0.0 -9.6 -1.2 1.6 0.1 0.1 -5.6 7.4 2.5 -3.0 1.7 -4.3 -3.0 2.0 -1.4 -5.3 -1.4 -0.7 -0.9 -4.9 -3.8 -3.6 0.0 0.0 0.0 -9.6 -0.9 -1.0 -0.1 3.5 -6.8 2.5 7.2 -3.1 -0.6 -5.5 -5.7 1.1 -4.0 -7.8 -2.2 -0.9 -1.5 -7.8 -5.6 -3.8 0.0 0.0 0.0 -9.6 -0.3 -3.0 -0.7 -1.4 -4.5 -3.0 -3.1 9.0 -3.7 -8.7 -8.2 -3.4 -6.5 -9.2 -4.1 -0.6 -3.5 -6.6 -7.4 -6.5 0.0 0.0 0.0 -9.6 -2.6 -0.1 1.4 -0.7 -3.1 1.7 -0.6 -3.7 11.0 -4.8 -4.2 -0.2 -2.8 -1.4 -3.1 -1.4 -1.4 -2.8 2.6 -4.7 0.0 0.0 0.0 -9.6 -2.7 -5.3 -5.5 -8.0 -3.6 -4.3 -5.5 -8.7 -4.8 7.2 2.8 -4.4 2.9 -0.3 -5.6 -4.4 -1.7 -4.6 -3.1 4.2 0.0 0.0 0.0 -9.6 -3.0 -4.4 -6.1 -8.2 -3.9 -3.0 -5.7 -8.2 -4.2 2.8 6.6 -4.4 3.4 1.5 -4.4 -4.7 -3.4 -2.9 -2.0 1.3 0.0 0.0 0.0 -9.6 -1.9 3.6 0.5 -0.8 -6.4 2.0 1.1 -3.4 -0.2 -4.4 -4.4 6.9 -2.7 -6.7 -2.4 -1.0 -0.6 -6.8 -4.4 -3.9 0.0 0.0 0.0 -9.6 -1.7 -3.8 -4.6 -6.4 -2.6 -1.4 -4.0 -6.5 -2.8 2.9 3.4 -2.7 9.5 1.1 -5.6 -2.9 -1.6 -3.1 -2.2 1.0 0.0 0.0 0.0 -9.6 -4.8 -6.8 -5.8 -8.7 -2.6 -5.3 -7.8 -9.2 -1.4 -0.3 1.5 -6.7 1.1 10.2 -7.2 -5.8 -4.7 2.7 5.5 -1.7 0.0 0.0 0.0 -9.6 -0.6 -3.0 -3.2 -2.8 -6.8 -1.4 -2.2 -4.1 -3.1 -5.6 -4.4 -2.4 -5.6 -7.2 10.5 -0.5 -1.0 -8.9 -5.9 -4.2 0.0 0.0 0.0 -9.6 1.6 -1.5 1.0 -0.5 -0.7 -0.7 -0.9 -0.6 -1.4 -4.4 -4.7 -1.0 -2.9 -5.8 -0.5 6.0 2.6 -5.7 -3.5 -2.8 0.0 0.0 0.0 -9.6 0.2 -1.6 0.0 -1.3 -2.1 -0.9 -1.5 -3.5 -1.4 -1.7 -3.4 -0.6 -1.6 -4.7 -1.0 2.6 6.4 -6.7 -4.2 -0.3 0.0 0.0 0.0 -9.6 -6.8 -3.0 -6.8 -9.6 -2.9 -4.9 -7.8 -6.6 -2.8 -4.6 -2.9 -6.8 -3.1 2.7 -8.9 -5.7 -6.7 16.6 3.3 -5.9 0.0 0.0 0.0 -9.6 -4.8 -3.7 -2.8 -5.3 -2.0 -3.8 -5.6 -7.4 2.6 -3.1 -2.0 -4.4 -2.2 5.5 -5.9 -3.5 -4.2 3.3 11.1 -3.3 0.0 0.0 0.0 -9.6 0.0 -4.4 -5.0 -6.5 -1.1 -3.6 -3.8 -6.5 -4.7 4.2 1.3 -3.9 1.0 -1.7 -4.2 -2.8 -0.3 -5.9 -3.3 6.5 0.0 0.0 0.0 -9.6 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -9.6 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -9.6 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 -9.6 1 wise-2.4.1/wisecfg/gon160.bla0000644000175000001440000000474407313404522015203 0ustar philippusers# benner-gonnet matrix # pam := 160 # print (DayhoffM (NewLogPAM1, pam)); # DayMatrix(Peptide, pam=160, Simil: max=15.808, min=-7.776, max offdiag=5.560, # del=-21.255-1.396*(k-1)) A R N D C Q E G H I L K M F P S T W Y V * 4.6 -1.6 -1.2 -1.1 0.3 -0.7 -0.4 0.2 -1.8 -1.8 -2.2 -1.2 -1.2 -3.8 -0.1 1.6 0.5 -5.5 -3.7 0.1 -7.8 -1.6 7.1 -0.4 -1.6 -3.5 1.7 -0.3 -2.1 0.3 -4.1 -3.5 3.5 -2.9 -5.3 -2.1 -0.9 -0.9 -2.4 -2.9 -3.4 -7.8 -1.2 -0.4 6.5 2.6 -3.1 0.5 0.5 -0.2 1.5 -4.4 -4.8 0.8 -3.6 -4.7 -2.2 1.1 0.3 -5.5 -2.2 -3.8 -7.8 -1.1 -1.6 2.6 7.0 -5.3 0.6 3.4 -0.7 -0.1 -6.2 -6.5 -0.1 -5.0 -7.0 -1.9 0.0 -0.6 -7.8 -4.2 -4.9 -7.8 0.3 -3.5 -3.1 -5.3 13.5 -4.2 -5.2 -3.4 -2.3 -2.5 -2.9 -4.8 -1.9 -1.8 -5.2 -0.2 -1.4 -2.1 -1.3 -0.6 -7.8 -0.7 1.7 0.5 0.6 -4.2 5.6 2.3 -2.1 1.7 -3.2 -2.4 2.0 -1.2 -4.1 -0.8 -0.2 -0.4 -4.0 -2.9 -2.7 -7.8 -0.4 -0.3 0.5 3.4 -5.2 2.3 5.9 -2.1 -0.1 -4.3 -4.5 1.3 -3.1 -6.2 -1.4 -0.3 -0.8 -6.4 -4.4 -3.0 -7.8 0.2 -2.1 -0.2 -0.7 -3.4 -2.1 -2.1 8.2 -2.7 -7.0 -6.7 -2.4 -5.2 -7.6 -3.0 -0.1 -2.4 -5.5 -6.0 -5.2 -7.8 -1.8 0.3 1.5 -0.1 -2.3 1.7 -0.1 -2.7 9.3 -3.7 -3.2 0.2 -2.1 -0.7 -2.2 -0.8 -0.8 -1.9 2.7 -3.5 -7.8 -1.8 -4.1 -4.4 -6.2 -2.5 -3.2 -4.3 -7.0 -3.7 5.9 3.0 -3.5 2.9 0.3 -4.3 -3.3 -1.2 -3.4 -2.0 4.0 -7.8 -2.2 -3.5 -4.8 -6.5 -2.9 -2.4 -4.5 -6.7 -3.2 3.0 5.7 -3.4 3.4 1.9 -3.5 -3.6 -2.4 -2.0 -1.1 1.7 -7.8 -1.2 3.5 0.8 -0.1 -4.8 2.0 1.3 -2.4 0.2 -3.5 -3.4 5.5 -2.1 -5.3 -1.6 -0.4 -0.2 -5.4 -3.5 -3.0 -7.8 -1.2 -2.9 -3.6 -5.0 -1.9 -1.2 -3.1 -5.2 -2.1 2.9 3.4 -2.1 7.6 1.4 -4.2 -2.3 -1.1 -2.2 -1.3 1.4 -7.8 -3.8 -5.3 -4.7 -7.0 -1.8 -4.1 -6.2 -7.6 -0.7 0.3 1.9 -5.3 1.4 9.1 -5.8 -4.5 -3.6 3.2 5.6 -0.8 -7.8 -0.1 -2.1 -2.2 -1.9 -5.2 -0.8 -1.4 -3.0 -2.2 -4.3 -3.5 -1.6 -4.2 -5.8 9.6 0.0 -0.4 -7.4 -4.8 -3.2 -7.8 1.6 -0.9 1.1 0.0 -0.2 -0.2 -0.3 -0.1 -0.8 -3.3 -3.6 -0.4 -2.3 -4.5 0.0 4.4 2.3 -4.7 -2.8 -2.0 -7.8 0.5 -0.9 0.3 -0.6 -1.4 -0.4 -0.8 -2.4 -0.8 -1.2 -2.4 -0.2 -1.1 -3.6 -0.4 2.3 5.0 -5.4 -3.2 0.0 -7.8 -5.5 -2.4 -5.5 -7.8 -2.1 -4.0 -6.4 -5.5 -1.9 -3.4 -2.0 -5.4 -2.2 3.2 -7.4 -4.7 -5.4 15.8 3.8 -4.5 -7.8 -3.7 -2.9 -2.2 -4.2 -1.3 -2.9 -4.4 -6.0 2.7 -2.0 -1.1 -3.5 -1.3 5.6 -4.8 -2.8 -3.2 3.8 10.0 -2.4 -7.8 0.1 -3.4 -3.8 -4.9 -0.6 -2.7 -3.0 -5.2 -3.5 4.0 1.7 -3.0 1.4 -0.8 -3.2 -2.0 0.0 -4.5 -2.4 5.3 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 -7.8 1 wise-2.4.1/wisecfg/worm.gf0000644000175000001440000003527007313404523015012 0ustar philippusers# Splice sites and intron regions information for GeneWise-21 # Tue Jan 14 16:50:39 IST 1997 # Created by Mor Amitai (mor@compugen.co.il) # dataset : C.Elegans data from the Sanger Centre. given by Ewan Birney # preliminary results. For Ewan's use only # Consensi are read from top down. The value, for a sequence, # is the number in the line of the first consensus that # matches the sequence. # Note: the set of sequences that are represented by a consensus # are all the sequences that match this consensus and none of the # previous consensi # # the numbers in types 5SS, 3SS, CDS, and the emissions are the number of # occurrences of each sequence in the database. # In case of a consensus this is the number of occurrences of sequences # that are represented by the consensus in the database divided by the # number of sequences that are represented by the consensus. # *stay_prob is the probability of the transition from the state to itself. # No_Spacer_Prob is the probability of transition from Pyrimidine directly # to 3SS (no spacer). type 5SS center 3 phase all begin consensus AAAGTGAGTT 61 GATGTAAGTT 51 A-TGTAAGTT 28.25 -AAGTGAGTT 28 -AAGTAAGTT 24.75 A-AGTGAGTT 22.3333 AA-GTGAGTT 22 TTGGT-AGTT 20.25 AAGGTTTGT- 19.75 -AGGTAATTT 19.25 T-TGTAAGTT 19 A-AGTAAGTT 18.3333 AT-GTGAGTT 17 GA-GTGAGTT 17 -AGGTAAATT 16.75 A-GGTTAGTT 16.75 AAGGTAA-AA 13.5 AAGGTAA-AT 13.25 T--GTAAGTT 10.4 -A-GTAAGTT 11.1429 -T-GTAAGTT 10.3 --GGTGAGTT 10.1667 --AGTGAGTT 9.22222 -C-GTAAGTT 8.8 -T-GTGAGTT 8.33333 --GGTTAGTT 8 AA-GTAAG-A 7.73333 -AGGTTTGT- 7.41667 -AGGTGAG-A 7.0625 CAGGTAA-A- 6.5625 AA-GTA-GTT 6.5 -A-GTTAGTT 6.41667 -G-GTAAGTT 6.4 -AGGTATTT- 6 AA-GTAAG-T 5.54545 -AGGTAAA-A 5.5 -AAGTAAGT- 5.45455 -A-GTAAGAA 5.36364 --GGTATGTT 5.26667 -TGGTGAGT- 5.25 -AAGTGAGT- 5.16667 -ATGTAAGT- 5.09091 AAGGT-AGT- 5.09091 -AGGTGAGA- 4.75 -TGGTAAGT- 4.58333 -AGGTAATT- 4.5 -AGGTATGT- 4.41667 --GGTAAGAT 4.28571 --GGTAAGAA 4.25 ---GTGAGTT 4.2 --GGTTGGTT 3.5625 -AGGTTTGA- 3.4375 A--GTAAGT- 3.28571 AAGGTAT-A- 3.125 -AGGT-AGT- 2.61111 --GGTAA-TT 2.575 T--GTAAGT- 2.5 --GGTT-GTT 2.42857 -A-GTA-GTT 2.42424 -AGGTAAG-- 2.23529 ---GTTAGTT 2.16667 ---GTAAGAT 2.04444 A--GTGAGT- 1.97436 A--GTA-GTT 1.9697 -AGGTA--TT 1.84375 -AGGTAA-A- 1.82143 C--GTAAGT- 1.80556 AA-GTGAG-- 1.7619 AAGGTA---A 1.7234 --GGTGAG-A 1.64286 G--GTAAGT- 1.63889 T--GTA-GTT 1.63636 -TGGTAAG-- 1.625 CAGGTA---A 1.54902 --GGTGAG-T 1.54762 AAGGTA---T 1.52632 AAGGTT-G-- 1.46 AA-GT-A-TT 1.45833 CAGGTA---T 1.42857 A--GTAAGA- 1.37838 ---GTGAGTG 1.35897 -AGGTG-GT- 1.16667 --GGTATG-A 1.07407 -AGGTT-TT- 0.952381 -A-GTAAG-- 0.794118 -AGGTAA--- 0.790698 --GGTA-GT- 0.734375 -A-GT-AGT- 0.731183 --GGT-AGT- 0.696629 -AGGTA-G-- 0.66 ---GTAAG-A 0.643478 -AGGT-AG-- 0.59375 --GGTA-G-T 0.58871 --GGTAA--A 0.583333 AA-GTA-G-- 0.555556 -AGGTAT--- 0.532787 -A-GT--GTT 0.525 --GGTT-GT- 0.515873 -A-GTGAG-- 0.481481 --GGTAA-A- 0.466667 -AGGT-A-T- 0.466667 -A-GTAA-T- 0.407407 ---GTGAG-A 0.4 -AGGTTT--- 0.39 A-GGTA--T- 0.362319 ---GTATGT- 0.326797 ---GTAAG-- 0.221854 -AAGTA--A- 0.219298 ---GT--GTT 0.209402 --GGTA-G-- 0.1875 --GGT-AG-- 0.155556 --GGTA--T- 0.15493 -AGGT---A- 0.1375 A--GTAA--- 0.116838 -A-GTA--T- 0.109053 ---GTT-GT- 0.0944444 -AAGT-A--- 0.0761905 ---GT--GAT 0.0670886 -AGGT----- 0.0541575 --GGTA---- 0.0411523 ---GTA-G-- 0.037037 ---GTAA--- 0.0363757 ---GT-A-T- 0.0309423 A--GT----T 0.0201761 ---GTG-G-- 0.0192593 ---GT--G-- 0.00953471 ---GT---T- 0.0090535 ---GT----- 0.00283019 end consensus type 5SS center 3 phase 0 begin consensus GATGTAAGTT 43 AA-GTGAGTT 15.25 A-TGTAAGTT 14.75 AAGGTTTGT- 13.5 GA-GTGAGTT 11.25 AAGGTAA-TT 11 CAGGTAA-TT 10.25 A-AGTAAGTT 9.5 -AGGTTAGTT 9 -TGGTGAGTT 9 AAGGTAA-AT 8.75 GC-GTAAGTT 8.5 T-TGTAAGTT 8.5 -AGGTATTTT 7.75 A--GTGAGTT 5.90909 --GGTAAGTT 4.92308 -A-GTAAGTT 5.25 --GGTTAGTT 4.66667 AAGGTAA--A 4.5 -AGGTTTGT- 4.25 --GGTGAGTT 4.125 -A-GTAAGAA 3.73333 AAGGTT-GT- 3.54545 -AGGTGAGA- 3.5 -ATGTAAGT- 3.41667 --GGTATGTT 3.3125 GAGGTAA-T- 3.26667 CA-GT-AGTT 3.2 -AGGTAAAA- 3.14286 -TGGTGAGT- 2.75 CAGGTAA--A 2.71429 -AGGTGAG-A 2.66667 -ATGTA-GTT 2.66667 AAGGTAT-T- 2.5 AAGGTT-GA- 2.4375 CAGGTAT-T- 2.35714 ---GTAAGTT 2.29167 --GGTAAGAT 2.26667 ---GTGAGTT 1.7 -A-GT-AGTT 1.47619 AA-GTAAG-- 1.40816 -AGGTGAG-- 1.40625 --TGTAAGT- 1.38889 --GGTAAG-A 1.32075 --GGTT-GTT 1.21429 -A-GTGAGT- 1.16667 --GGTAA-TT 1.12821 AAGGTAT--- 1.125 A--GTA-GTT 1.09756 CAGGTA---T 1.05556 AAGGTA---T 1 CAGGT--GT- 1 GAGGTA--T- 0.956522 A-GGTA-GT- 0.871795 AAGGT-A-T- 0.866667 CAGGTA--A- 0.857143 GA-GTAAG-- 0.829787 -AGGTTTG-- 0.818182 A--GTAAGA- 0.809524 --GGTGAG-A 0.795455 -A-GTGAGA- 0.75 -TGGTA-G-T 0.74 GAGGTAT--- 0.729167 --GGT-AGTG 0.695652 --AGTAAG-A 0.607843 -AGGTTTT-- 0.546875 ---GT-AGTT 0.488095 ---GTAAGT- 0.45 ---GTA-GTT 0.415929 ---GTGAGT- 0.413793 AAGGTA---- 0.40566 CAGGTA---- 0.375 GAGGTA---- 0.367188 -AGGTT-G-- 0.337838 --GGT-AG-T 0.289855 -A-GT-A-TT 0.28655 ---GTAAG-T 0.282051 --GGTAA-T- 0.264957 --GGTATG-- 0.264368 AA-GT--GT- 0.259887 --GGTAA-A- 0.244186 A--GTAA--A 0.212644 -ATGTA-G-- 0.171123 -A-GTGA--A 0.15493 --GGT--GT- 0.107914 -AGGTT---- 0.0951684 --GGTA-G-- 0.0941176 -A-GT-AG-- 0.0711297 --GGTA--T- 0.0663812 -AAGTA---- 0.0590164 ---GTT-GT- 0.0509259 --TGTAA--- 0.0499376 -AGGTG---- 0.0425532 --GGTA---- 0.0223793 ---GT-AG-- 0.0221502 ---GTA-G-- 0.0173088 ---GT-A-T- 0.0157715 A--GT----T 0.0103437 ---GT--G-- 0.00594251 ---GT---T- 0.00467836 ---GT----- 0.00116399 end consensus type 5SS center 3 phase 1 begin consensus A-AGTGAGTT 9.25 TT-GTAAGTT 9.25 -TGGTGAGTT 8.25 A-TGTAAGTT 8 -T-GTAAGTT 5.09091 --AGTGAGTT 4.33333 A--GTAAGTT 3.66667 --GGTTAGTT 3.125 -AGGTAA-TT 2.66667 TTGGTAAG-- 2.2 --GGTTTGTT 2.1875 CA-GTAAGT- 2.06667 T--GTAAGTT 2.81818 --GGTGAGTA 1.9375 ---GTGAGTT 1.70455 -AGGTAA-A- 1.17188 A--GTAAGT- 1.16667 --AGT-AGTT 1 -TGGTAAG-- 0.928571 AA-GTAAG-- 0.909091 --GGTA-GTT 0.884615 ---GTAAGTA 0.878049 --GGTGAGA- 0.796875 A--GTGAGT- 0.727273 AAGGTAT--- 0.714286 -TGGTT-GT- 0.696429 --AGTA-GTT 0.6875 ---GTAAGAT 0.679245 -AGGTT-GT- 0.660714 ---GTAAGT- 0.521739 --GGTATG-A 0.516667 -AGGTAA--- 0.403846 --GGTGAG-- 0.342105 --GGTA--TT 0.316384 A--GT--GTT 0.283333 ---GTAAG-A 0.245283 -AGGTA-G-- 0.228758 -TGGTA-G-- 0.207317 -A-GTGAG-- 0.19883 -AGGTT-G-- 0.1875 -TGGTAA--- 0.183333 -AGGTG--T- 0.130802 -AGGTA---- 0.109091 ---GT-AGT- 0.103792 ---GTAAG-- 0.103774 ---GT--GTT 0.0700637 -A-GTA--T- 0.0614035 -AGGTT---- 0.0442708 ---GTATG-- 0.0401554 --GGTA---- 0.0193694 --GGT--G-- 0.0173797 A--GT-A--- 0.0144654 ---GT-A--- 0.0048218 ---GT--G-- 0.00395005 ---GT----- 0.00155651 end consensus type 5SS center 3 phase 2 begin consensus -AAGTGAGTT 17.25 -AAGTAAGTT 13.75 -GAGTGAGTT 8.5 TG-GTAAGTT 7.75 A--GTAAGTT 4.26667 T--GTAAGTT 4.09091 -A-GTGAGTT 3.58333 T--GTGAGTT 3.09091 -AAGTAAGT- 3.08333 -AAGTGAGT- 3 A--GTGAGTT 2.90909 -A-GTTAGTT 2.6875 -AGGTAA-TT 2.5 -A-GTAAGAA 2.4375 -A-GTAAGAT 2.1875 -A-GTATGTT 2.125 A--GTAAGT- 1.24444 --TGTAAGT- 1.13636 --AGT-AGTT 1.13158 -AGGTGAG-- 1.03333 -AGGTAA--A 0.983051 -AGGTT-GT- 0.966667 --CGT-AGTT 0.857143 -G-GTA-GTT 0.7 --GGTAAGA- 0.660714 --GGTT-GTT 0.645833 -AGGTA-TT- 0.642857 T--GT-AGTA 0.581818 ---GTAAGT- 0.5 ---GTA-GTT 0.429688 ---GTGAGT- 0.427711 -A-GTAAG-- 0.381944 -AGGTAA--- 0.298387 -AGGTA-G-- 0.272222 A--GTAAG-- 0.25 -A-GT--GTT 0.228571 -AAGTA-G-- 0.2 ---GTAA-TT 0.194444 ---GTGAG-A 0.194444 ---GTTAGT- 0.19209 -AGGTTT--- 0.158333 ---GT-AGAT 0.153488 -AGGTA---- 0.100379 ---GTAAG-- 0.097561 --GGTAA--- 0.0759259 -A-GT-A-T- 0.0700549 --GGT--GT- 0.0628019 AA-GTA---- 0.052381 ---GTATG-- 0.0413437 --GGT--G-- 0.0202815 -A-GT-A--- 0.0149254 ---GT---TT 0.0146813 ---GT---T- 0.00532449 ---GTA---- 0.00401891 ---GT----- 0.00131086 end consensus type 3SS center 3 phase all begin consensus CAGAAA 372 CAGATT 316 CAGATG 290 CAGATC 263 CAGGAA 253 CAGAAT 246 CAGAAC 221 CAGGTT 218 CAGATA 215 CAGAGA 200 CAGGAT 175 CAGAAG 167 CAGACA 160 CAGCAA 158 CAGACT 151 CAGGT- 148.667 CAGGAG 139 CAGCTC 129 CAGAGT 127 CAGGCT 125 CAGGCA 124 CAGCTT 116 CAG-TC 115 CAGAGC 112 CAGGGA 112 CAGACG 109 CAGCCA 106 CAG-TT 100 CAGGAC 100 CAGCTG 96 CAGCAT 95 CAGACC 90 CAGTGA 89 CAGCTA 85 CAGGGT 85 CAGCAC 80 TAGAAA 80 CAGGCC 77 CAG-TG 73 CAGAGG 72 CAG-CA 70 TAGGAA 66 CAGGCG 65 CAG-AC 62 CAGTTA 62 CAG-AT 61 CAGTG- 60.3333 CAGCGT 55 TAGGTT 53 TAGAAT 51 CAGCCG 50 TAGAT- 49.25 CAGTC- 43 TAGGT- 40.6667 CAGC-- 37 TAGG-T 32.3333 TAGAC- 24.75 TAG-AC 19.25 TAG-CA 19 TAG-GA 17.5 TAGCT- 16 -AGGGC 15 AAGGT- 14.25 TAG-A- 13 AAGAT- 12.5 TAG--T 10 TAG--- 7.9375 AAGA-- 5.25 AAGG-- 4.63636 AAG--- 1.84375 -AG--- 1.60606 end consensus type 3SS center 3 phase 0 begin consensus CAGAAA 167 CAGATT 160 CAGGTT 160 CAGATG 145 CAGATC 143 CAGGAA 139 CAGAAT 113 CAGGAT 111 CAGAAC 100 CAGGT- 86.3333 CAGGCT 82 CAGGCA 80 CAGA-A 79.3333 CAGCTT 79 CAGGGA 79 CAGGAG 77 CAGCAA 75 CAGCTC 72 CAGACT 70 CAGCCA 64 CAGGGT 59 CAGAAG 58 CAG-TC 57 CAGAGT 49 CAG-AC 48.6667 CAGGCC 48 CAG-TT 45 CAGACC 45 TAGGAA 41 CAGAGC 39 CAGCAT 34 CAGGCG 33 CAGTTG 33 TAGAAA 33 TAGGAT 33 TAGGT- 26.75 CAG-TA 26 TAGAT- 23.25 CAGT-T 21.6667 CAG-C- 19.7143 CAG-GC 16.6667 CAGC-- 15.2 TAGAA- 14.6667 TAGG-- 12.2 TAGAC- 10 AAGGT- 9.5 TAG-T- 6.375 TAG--A 5.85714 CAG-GG 10 TAG--T 4.57143 AAGG-- 3.16667 AAGA-- 2.875 -AG--- 0.575221 end consensus type 3SS center 3 phase 1 begin consensus CAGATG 88 CAGAAA 86 CAGGAA 80 CAGGTG 60 CAGAA- 56.6667 CAGAT- 56.3333 CAGCTG 55 CAGACG 53 CAGGAG 52 CAGCAA 43 CAGGAT 43 CAG-TC 37.3333 CAGACT 33 CAG-T- 26.8571 CAGT-A 23.6667 CAG-CA 24.6667 CAG-AT 24 CAGAG- 22 CAG-CG 21.3333 CAGTG- 19.6667 CAG-AC 19 CAG-CT 15 TAG-AA 12.75 TAGAT- 12.5 CAG-CC 11.25 CAGCG- 11.75 TAGGT- 9.25 CAGGG- 8 TAGA-- 6 TAG-T- 4.375 TAGG-- 4.27273 -AGCA- 2.75 TAG--- 2.10526 -AG-A- 1.44 AAG--- 0.875 -AG--- 0.145833 end consensus type 3SS center 3 phase 2 begin consensus CAGAAA 119 CAGAGA 114 CAGATT 100 CAGAAT 79 CAGAAC 76 CAGAT- 66.3333 CAGTGA 60 CAGAG- 49 CAGCAA 40 CAGAAG 38 CAGAC- 36.5 CAG--A 23.1 CAGTG- 24 CAG--T 20 TAGA-A 17.5 CAG-TG 16.3333 CAG--C 14.5455 TAGA-T 12.5 CAG--G 8.875 TAGA-C 8.5 TAGG-A 8.5 TAG-T- 4.33333 AAGA-- 2.5 TAG--- 2.5 AAG--- 0.6875 -AG--- 0.15625 end consensus type CDS phase all begin consensus AAA 84633.000000 AAC 46592.000000 AAG 60437.000000 AAT 62516.000000 ACA 46370.000000 ACC 24553.000000 ACG 26490.000000 ACT 35930.000000 AGA 58310.000000 AGC 33692.000000 AGG 25680.000000 AGT 32467.000000 ATA 28413.000000 ATC 49079.000000 ATG 55085.000000 ATT 57612.000000 CAA 70444.000000 CAC 32088.000000 CAG 36967.000000 CAT 39211.000000 CCA 41062.000000 CCC 12109.000000 CCG 20902.000000 CCT 16745.000000 CGA 38937.000000 CGC 16213.000000 CGG 19184.000000 CGT 23512.000000 CTA 19576.000000 CTC 36258.000000 CTG 35452.000000 CTT 37193.000000 GAA 78165.000000 GAC 30372.000000 GAG 41478.000000 GAT 54272.000000 GCA 33687.000000 GCC 21235.000000 GCG 14088.000000 GCT 33925.000000 GGA 53236.000000 GGC 16915.000000 GGG 11380.000000 GGT 18746.000000 GTA 18214.000000 GTC 27126.000000 GTG 28827.000000 GTT 37436.000000 TAA 21016.000000 TAC 24215.000000 TAG 11205.000000 TAT 34251.000000 TCA 57624.000000 TCC 32884.000000 TCG 36367.000000 TCT 41910.000000 TGA 53826.000000 TGC 36079.000000 TGG 43985.000000 TGT 36905.000000 TTA 24513.000000 TTC 56201.000000 TTG 51452.000000 TTT 46581.000000 end consensus type CDS phase 0 begin consensus AAA 29214.000000 AAC 14368.000000 AAG 21430.000000 AAT 23711.000000 ACA 15287.000000 ACC 7556.000000 ACG 6113.000000 ACT 15236.000000 AGA 13083.000000 AGC 6073.000000 AGG 2390.000000 AGT 9505.000000 ATA 5289.000000 ATC 14308.000000 ATG 19502.000000 ATT 24404.000000 CAA 23759.000000 CAC 6982.000000 CAG 11123.000000 CAT 11541.000000 CCA 22932.000000 CCC 2834.000000 CCG 6380.000000 CCT 7320.000000 CGA 9565.000000 CGC 4160.000000 CGG 2879.000000 CGT 10219.000000 CTA 5048.000000 CTC 11747.000000 CTG 8079.000000 CTT 18194.000000 GAA 35701.000000 GAC 13432.000000 GAG 19257.000000 GAT 31475.000000 GCA 16802.000000 GCC 10031.000000 GCG 5651.000000 GCT 20774.000000 GGA 28462.000000 GGC 4276.000000 GGG 2708.000000 GGT 9185.000000 GTA 7376.000000 GTC 10825.000000 GTG 10041.000000 GTT 20526.000000 TAA 0.000000 TAC 10158.000000 TAG 0.000000 TAT 12776.000000 TCA 16414.000000 TCC 7520.000000 TCG 9109.000000 TCT 14215.000000 TGA 0.000000 TGC 6122.000000 TGG 7942.000000 TGT 8393.000000 TTA 6535.000000 TTC 18524.000000 TTG 15014.000000 TTT 14468.000000 end consensus type CDS phase 1 begin consensus AAA 27124.000000 AAC 17085.000000 AAG 28251.000000 AAT 16214.000000 ACA 16360.000000 ACC 5893.000000 ACG 13413.000000 ACT 9274.000000 AGA 18727.000000 AGC 12003.000000 AGG 12559.000000 AGT 8521.000000 ATA 16240.000000 ATC 19315.000000 ATG 28352.000000 ATT 15596.000000 CAA 24103.000000 CAC 13923.000000 CAG 18346.000000 CAT 15063.000000 CCA 10417.000000 CCC 4057.000000 CCG 9508.000000 CCT 3959.000000 CGA 9972.000000 CGC 4083.000000 CGG 7638.000000 CGT 5560.000000 CTA 8897.000000 CTC 15780.000000 CTG 22899.000000 CTT 9969.000000 GAA 18216.000000 GAC 8305.000000 GAG 14912.000000 GAT 9677.000000 GCA 6876.000000 GCC 4330.000000 GCG 5051.000000 GCT 4374.000000 GGA 5662.000000 GGC 3760.000000 GGG 3721.000000 GGT 2776.000000 GTA 6705.000000 GTC 9254.000000 GTG 14905.000000 GTT 6438.000000 TAA 7340.000000 TAC 4898.000000 TAG 5780.000000 TAT 6230.000000 TCA 20217.000000 TCC 9131.000000 TCG 15798.000000 TCT 10258.000000 TGA 18951.000000 TGC 9200.000000 TGG 15809.000000 TGT 8676.000000 TTA 11663.000000 TTC 21772.000000 TTG 29546.000000 TTT 14611.000000 end consensus type CDS phase 2 begin consensus AAA 28295.000000 AAC 15139.000000 AAG 10756.000000 AAT 22591.000000 ACA 14723.000000 ACC 11104.000000 ACG 6964.000000 ACT 11420.000000 AGA 26500.000000 AGC 15616.000000 AGG 10731.000000 AGT 14441.000000 ATA 6884.000000 ATC 15456.000000 ATG 7231.000000 ATT 17612.000000 CAA 22582.000000 CAC 11183.000000 CAG 7498.000000 CAT 12607.000000 CCA 7713.000000 CCC 5218.000000 CCG 5014.000000 CCT 5466.000000 CGA 19400.000000 CGC 7970.000000 CGG 8667.000000 CGT 7733.000000 CTA 5631.000000 CTC 8731.000000 CTG 4474.000000 CTT 9030.000000 GAA 24248.000000 GAC 8635.000000 GAG 7309.000000 GAT 13120.000000 GCA 10009.000000 GCC 6874.000000 GCG 3386.000000 GCT 8777.000000 GGA 19112.000000 GGC 8879.000000 GGG 4951.000000 GGT 6785.000000 GTA 4133.000000 GTC 7047.000000 GTG 3881.000000 GTT 10472.000000 TAA 13676.000000 TAC 9159.000000 TAG 5425.000000 TAT 15245.000000 TCA 20993.000000 TCC 16233.000000 TCG 11460.000000 TCT 17437.000000 TGA 34875.000000 TGC 20757.000000 TGG 20234.000000 TGT 19836.000000 TTA 6315.000000 TTC 15905.000000 TTG 6892.000000 TTT 17502.000000 end consensus type Intron_Corr_Term phase all 93.3478 type Intron_Corr_Term phase 0 194.143 type Intron_Corr_Term phase 1 362.18 type Intron_Corr_Term phase 2 357.052 type Intron_emission begin consensus A 572525.000000 C 267017.000000 G 250100.000000 T 588809.000000 end consensus type Pyrimidine_emission begin consensus A 0.000000 C 0.000000 G 0.000000 T 22799.000000 end consensus type Spacer_emission begin consensus A 117.000000 C 183.000000 G 73.000000 T 172.000000 end consensus type Central_Intron_Stay_Prob 0.994723 type Pyrimidine_Stay_Prob 0.719098 type No_Spacer_Prob 0.687177 type Spacer_Stay_Prob 0.163615 wise-2.4.1/test_data/0000755000175000001440000000000010670453645014033 5ustar philippuserswise-2.4.1/test_data/human.genomic0000644000175000001440000001253407313404500016475 0ustar philippusers>HSHNRNPA GGGATTGAGAGTGATCACTCACGCTAACGTCTGCCCTGTTCCTGTATGGTGAGGCCGCAC CACAAGCCACCACCGCCGCCGCCTTCTGCGCAACGCCAACCGCCCGCCAAAACGGATCCT TCCCTGCGCCTGCGCAACCAATCTTGGGACCGGACCTTTTTTCTCCGCCCACTACGCATG CGCAAAGCTAGGACAAACTCCCGCCAACACGCAGGCGCCGTAGGTTCACTGCCTACTCCT GCCCGCCATTTCACGTGTTCTCAGAGGCAGGTGGAACTTCTTAATGCGCCTGCGCAAAAC TCGCCATTTTACTACACGTGCGGTCAACAAGAGTTCATTGCAAAAAAATTGTTACCTCCT AGCTGCTTGTCTAATACATAGTGTTAATCATGCTTTGCCAAGCGACTTGACTGTAATATT TGCGCGTGGAAGATTAAAAAGATGTTAAACACCCAAGGTAGATTCAAATGTGAATGATTG GTCGGTTGGCCAATCAGACTGGTTAACAATAACATTACTCGGGAACCAATGGACTCCAAG GGGTGGAGACGGCGTAGAACGACCGAAGGAATGACGTTACACAGCAATGTGGCACCACAG GCCAATAGCAGGGGGAAGCGATTTCAAGTATCCAATCAGAGCTGTTCTAGGGCGGAGTCT ACCAATGCCGAAAGCGAGGAGGCGGGGTAAAAAAGAGAGGGCGAAGGTAGGCTGGCAGAT ACGTTCGTCAGCTTGCTCCTTTCTGCCCGTGGACGCCGCCGAAGAAGCATCGTTAAAGTC TCTCTTCACCCTGCCGTCATGTCTAAGTCAGAGGTGAGTTAGGCGCGCTTTCCCACTTGA ATTTTTTCCTCTCCCTTTCCTGAATCGGTAAGATGCTGCTGGGTTTCGTTCCTTGCACCA GCCCATTCTACAGTTCCTTCGGTCGCTGCCACGGCCTACCCCTCCCAAAGTTCAAGTCGC CATTTTGTCCTCTTGATCGCCATGAGGCCGCTCTCCGCCAACCATGTGTTATCATGCGGG ACTCGTTACTCGTAGCAAAATTCTTAGGCACACAGGATCTTTGTCTTTTTTTAAACCTTG CCTTGGTGAGCGAGTTTTCTAAAGAGCGATTAGTCCCATTGTGGAGATGCACCCCTACCG CCCAAGCCTTTGTTGCGCGTGCGTCGGAAGGCGACTAGGGACGCATGCGCTTGCGATTTC CTAGCACTCCCAACTCCAGCATACGGCCTCCCTTGATAGGCAGAAGCACGTGTCTTGTTG CGACCTGAACGAACAATAAGTGCTAGGTACACAGTTGGTGTCTAGTTTTTCTTTTCCTCG ATGGAAATTGTTTCGTGTTGTAGCCCATTTAACACTTCCCCCTCCCCCCACTCTAGTCTC CTAAAGAGCCCGAACAGCTGAGGAAGCTCTTCATTGGAGGGTTGAGCTTTGAAACAACTG ATGAGAGCCTGAGGAGCCATTTTGAGCAATGGGGAACGCTCACGGACTGTGTGGTAAGAT TTGGAAGGGACAAAGCAGTAAAACAGCCGATTTCCTTGGCTTATCTTGGTGCAGTCTTCT CCGAATGCTTATGAAAGTAGTTAATAGCATTATAGTTAGAGCTTTGTTGGCAAAGGAACG TCCTGCTTTGATTTTAAAAGCTAACCTCTTAAATCTAAGGGTAGTGGGAAACTGGACGAA CTTTTTATAAAAGGCTGGTGTAAAGTTTCCTATTGCCCTATTCAAAGTTAAAATAACAAA AGCTTTTGCGGTCAGACTTTGTGTTACATAAATTAACACTGTTCTCAGGTAATGAGAGAT CCAAACACCAAGCGCTCTAGGGGCTTTGGGTTTGTCACATATGCCACTGTGGAGGAGGTG GATGCAGCTATGAATGCAAGGCCACACAAGGTGGATGGAAGAGTTGTGGAACCAAAGAGA GCTGTCTCCAGAGAAGTGAGTGGGTTTTTTTTCTTCTTCTTCTTAAACTTACTTGGATAT GTGCTGCTATGAACTTAAGATTCGGGAGTTTTCTAAACTTACCAAAATTTTTTATTCGAG TATAGGCTTTGCTAATCTAAACCTATGGTTTTTCTCCTATTAGGATTCTCAAAGACCAGG TGCCCACTTAACTGTGAAAAAGATATTTGTTGGTGGCATTAAAGAAGACACTGAAGAACA TCACCTAAGAGATTATTTTGAACAGTATGGAAAAATTGAAGTGATTGAAATCATGACTGA CCGAGGCAGTGGCAAGAAAAGGGGCTTTGCCTTTGTAACCTTTGACGACCATGACTCCGT GGATAAGATTGTCAGTAAGTATCAGATAGTGGCATTTAGTAAGGGTTCCACAATCTGTAT GGCATTCTAAACCCTGATACCATGTTGTATCTATGTTTTTTTTTTAGTTCAGAAATACCA TACTGTGAATGGCCACAACTGTGAAGTTAGAAAAGCCCTGTCAAAGCAAGAGATGGCTAG TGCTTCATCCAGCCAAAGAGGTATGCTTGTTGCTTAATTAAACCTTAAAGGTAACTTTGA GTTACTCCAGTATGAATGATTTAATGCTTAAACTTCATGTCTTAAGGTCGAAGTGGTTCT GGAAACTTTGGTGGTGGTCGTGGAGGTGGTTTCGGTGGGAATGACAACTTCGGTCGTGGA GGAAACTTCAGTGGTCGTGGTATGTATGGTTTATCTACATGTAGTTCTGACTTCTCACCA TCTTTGCTATGAAGATTTTACAGTACGGGAACTGCATTCAGAATGTCACTTTAAGTCCAA GTCATACTTAAAACTTGAAACTTTTTCTTACAGGTGGCTTTGGTGGCAGCCGTGGTGGTG GTGGATATGGTGGCAGTGGGGATGGCTATAATGGATTTGGCAATGATGGTAAGTTTTTTA GGAATAAGTAGAGAAAAATTCCTGGCAACCTGGATCTTTAGAATAGGTTAGTAGAGACTA AAATTCTGGTGCATGTCAAACTCAACTTTGCCCATAACACGCATGCTGTGAGCAGGCCTT CAGCCGTTACACTTGCACAAGTTTTCATTGTCAAATACTTTTGTCTTATTGAGAAGAATT GTATTCTTGTAGGTGGTTATGGAGGAGGCGGCCCTGGTTACTCTGGAGGAAGCAGAGGCT ATGGAAGTGGTGGACAGGGTTATGGAAACCAGGGCAGTGGCTATGGCGGGAGTGGCAGCT ATGACAGCTATAACAACGGAGGCGGAGGCGGCTTTGGCGGTGGTAGTGGTAGGTATCCAG TGATCCAAGTACTTGGTGTGACAGCTAGATTAGCCTTTTAGAGCTTGGGTTCTGGTGCTG TTGAAGCATTGTGTGGTACACTGCATGGTATATTAAAAACAAATGGGCTTGCTATGCTAC CTCCTCCTAGCTTTAAGCTGGGGCCGCCTCACTCCCAAATAGTAGAGATAAGTGGATAGT GTTGTCTTTGAGTTAGATTAGTATCATAGAAGGATTTAGTATTTTAACTCCTTTGGGACC TTAGGCGCTTAGTTGATGTATCCAAGATACTTCTGCTTGCTGTGGCCCTGGATCCGTGAA GGCCTTCAAGGCTGAAGGGTATGCTTGTGCCACTCTGAAAATCTCTTTATTTTATGTCAT GGTGAGTTAGGCCAGTTTTCTTTGTATTACTGGATTATTCAACTGAATGCCTTTCCCAGA GAATGAAATGCAAAGATTGGAGTCACCATAGTTTGGGAGAAAGGAAGGCTGATAACTCAA CCTTATTTTATTCTGACTGCTAAACAGAATTGGAAACTAACATCATCCTCAGGTAACAGA TAAAGGCCCTCTTTCCCATTCATAGGAAGCAATTTTGGAGGTGGTGGAAGCTACAATGAT TTTGGGAATTACAACAATCAGTCTTCAAATTTTGGACCCATGAAGGGAGGAAATTTTGGA GGCAGAAGCTCTGGCCCCTATGGCGGTGGAGGCCAATACTTTGCAAAACCACGAAACCAA GGTATGGTATCTATGTAATTTTGGATAATGTCAAAAGAGTGTCTGTAGCTACTGCTGGGA AGAAAGCCCTTTAACTGCTATGTCTGGGCAGCAAAACGTTTATAGTTTAGAACCTTCAGA AAGTGATAATTTGATCACAAATTAGAAAAATCATGGGACCTCTTTACCACCTCCCTTGTA GTAGGGCCATTTTTAAATGGCCAGACACTTGAATTTAACTTTTATTATCCCAAATATGAA AACATTACTGTTGGCACTTTGAAACTTTAAAAGAAAAATTGTACTTTTCAGGTGGCTATG GCGGTTCCAGCAGCAGCAGTAGCTATGGCAGTGGCAGAAGATTTTAATTAGGTAAGTAAG CACCTTTTTGTGTGTTGACATAATTTTTTAAATTGCTGATGAACCCAATAACCCTAATGT AGCTGAGCAGTGCAACATAGTTAACATTATAATTGCAGTAATTGTGGATATAAAGTTAAT ATTCAGATCAGCAAAATTTGTGGGAAACAAACTTGATATTGGATTGTAGCCTTGAGTCTT AATATGTTTAGATTAACAACTCTATTCCATATTGTTCAACAGGAAACAAAGCTTAGCAGG AGAGGAGAGCCAGAGAAGTGACAGGGAAGCTACAGGTTACAACAGATTTGTGAACTCAGC CAAGCACAGTGGTGGCAGGGCCTAGCTGCTACAAAGAAGACATGTTTTAGACAAATACTC ATGTGTATGGGCAAAAAACTCGAGGACTGTATTTGTGACTAATTGTATAACAGGTTATTT TAGTTTCTGTTCTGTGGAAAGTGTAAAGCATTCCAACAAAGGGTTTTAATGTAGATTTTT TTTTTTGCACCCCATGCTGTTGATTGCTAAATGTAACAGTCTGATCGTGACGCTGAATAA ATGTCTTTTTTTTAATGTGCTGTGTAAAGTTAGTCTACTCTTAAGCCATCTTGGTAAATT TCCCCAACAGTGTGAAGTTAGAATTCCTTCAGGGTGATGCCAGGTTCTATTTGGAATTTA TATACAACCTGCTTGGGTGGAGAAGCCATTGTCTTCGGAAACCTTGGTGTAGTTGAACTG ATAGTTACTGTTGTGACCTGAAGTTCACCATTAAAAGGGATTACCCAAGCAAAATCATGG AATGGTTATAAAAGTGATTGTTGGCACATCCTATGCAATATATCTAAATTGAATAATGGT ACCAGATAAAATTATAGATGGGAATGAAGCTTGTGTATCCATTATCATGTGTAATCAATA AACGATTTAATTCTCTTGAATGAAATGACAACTGTATGGATTTGGGACTGGCAGAGATTT GGACTTTCCCTACCCACTCCCCCTGATAATAATGTTGAATGCTTCTATCACAATTCAAGT TCAAAGCTCTGCTAGGGAATAGAAACTA wise-2.4.1/test_data/vav_promoter.human0000644000175000001440000000102110011413266017562 0ustar philippusers>vav_promoter_human GTTTTGTGGGCCTTGGGGAGGACTTGGGCTTGTCCCTGGAGGAAAGTGGGAGCCATAGAG AGTTGTGGGCAGAAGAAGGG TGTGCCCTGACTCAGATGCTCACAGGCAACCTCTGGTGGTGGCTGCAGGGAGGACAGACT GTGGGGTACGGGGGCTGGAGTCAGAAGACCAGCTGAGTGATGACGGGGCTGGACCAGACA GAGGAGGGGGTGAGAAGTGGGTGAATTCTGGGTATATTTCAGAGTGTCACTGCCGCCGTC TGCATATGGAGGAAGCTCACCCATCTCATAGTCTAGCTGGCCTGACTCCCCCAGCCCCCC AACTCCCCATGCCCAGGCCTGTGTCGAGTGGGCGGAAGAAAGAGATGTCAGATTCTGCAT GGAAGGCGTGGGGTGGGGCTGGGCTGCAGGTGCTCCCCCAGCTCCCCCCCGCCCCATGGC TCCTCCTCCTCCACCCCCTCTCAGGGCGACAGTTACAGGCAAAGAAGAGGAAGTGGTAGC wise-2.4.1/test_data/fugu.gen0000644000175000001440000004140007644554022015471 0ustar philippusers>Fugu rubripes|SINFRUG00000126632 and 3000bp 5'/3' flanking TCCCTCTCTATGGGTTCCTCCCTATCGGTTCCTCTAACCAAAACCATAACAACACACACA CACACACACACACACACACACACAAAATAGCAGTATCTGGGCCAGTGTGTTGTGTATTTA CCTGCGATAGAGAAAATGTGCTGACCATGAGTGTGTGTGTTTGGCACCTCGCGCGTGCCC TGCACCTCAGCGGTGTGTGTTGACACAGTGATTACCGGGCAGCTGGTACATATTGGCGTG AGCTCCGCCCTGCATTTACTGTTGTAATTAGTTCCTGTCCCAAATAAGCGGCAGGAATTT TAATAGAGAACCTCTGGCCTGCCGTCGTCTTGCTCCACAGACCCTCACACACATAAAACC AACCTGTGAGGGAGTCTCCCTTGAGGCTGCAGTGTTAATTTGAATCATTCATTTTTACTC CTTAAATCAAACGGAGAGCATGACAACAAATGCAGCTTACAGTCGGGGCTCACAGTGACT CGTTAAAGGGCGAAGACTGGCGCCTTGTGACCTGACATGGCCCAGCCATGACCCTTTAAC ACTTCAAGGGTGCAGAGGCTCGGTGGGGGGACAAGCGAAAGTTAATATCTGTCACTTAAA TGCTCGTTAGTGCTTCTGGCACAGCCGCGTCTACGTTTTTGCGCACCAGTGCTGCGTTTA AGTGCCATTTAGAAGATCGGAAATATCAATACTGAACATAGGATTGCTGTGCGCGCTGTT GAAAGTTTGAGGAATGTAAATGTGTGTTTAGTTAACATTTCCTCTGCTCTGGTGTCTCTG CAGGTGAAGAAATCACACAGTGAGTCTCATGTTCCAGACCCTTCAGACGCCAGGTAGTGT GTGTGCGCGTTGTGTGTGTGTGTGTTTCTTTCTTGTACATTTCTCATGCATTTTTAAAAC TATTTGAATACACGTAAATGTTCATCCGTCACTCAAGTTAATAACAACACACATTTTAAA GTTATTAATTATTTATTTCATCATGTGCGATCTAAAAAAAATCGTAATATTTTTAATTTT ATTTAAAGCAAAAAGCTACATTTTAAATCAAATGACTGGTGCACATTAGCGGGGGAGAAA TACTTGTCAGCATGGAACTCCAGTTTAGGAACTATCAGTACTTCTGATCAATCCGTTTAT TTAGGGCAAAAACTGCAAGCAATTAATCTTTCCAGTCAGAATTTAAATAATGGAAATGTG CCAGAAATTCTGAGGCTCCAGCTTTGAAAATGATACGATTCGACCCTTTTTTAGCAGAAG GGGCGCAAAAAGACATTTTAAGAGGCCGCCGTGGGCGCTGTGGCGGCTGTTGTCTGCTTC CTCGGTGTTTTGACGTTTCAGACAATCAGATGTGTTTCGCAAAAATAACAGCTGATAAAA CAATAATCCTCAGCGGCGGCTTTATTTTCTTTAATACTCTGTCGATTTTTGCAAACTCCG TCGGAGATCAGGCGTAATGTGAAAAGCAGAGGAGCGTTTATGAAACACCAACTGCTGCCA TCGCCTCCCGAGACTGCTGAAATAAAGAGGAAAGCAAGTAGGGGGGGGGGGATTATTTCC TGCTGTGGCGAGACAAAAGAGAAGTATGGACGGAGAGAGAGAAAAGAAGAAAATAATCTG TTTTTGCAAGTTTTTCTTTGAGATTTTTGAGACTTTGAGTGAAGTCCTCTACCATTACGT GCTGTTGACATTAAAACAGCGCTAGTTGTCCTTCAAAATGTCCCCTGGGAGCAGAATTAA TGTTTAGCTATAAATAAAAACAGAAGAATTGAGAGACTTGAGTTGATTTAGTCTGTTTAT CTTCTGTTGTTTTGCACCTCTAAGTCTTTGACATCTGCTGAAAGTTATATGTTTATACCT GTCAGGCCCACTGTGGGCCGCAGTCATGCGCAACGATGCTATCTGCCCATAGCATTCAGA TGGCCTCCCTCCAGACCGCAACACACACACACACACACACACATGCATGCACACACACAC ACACACACAGAGAGCAGCAGCCCNCATTTTTTNAANGCTCCGTCCATCTCTGNAAATTCT NGCTTAGATGTGTCACANAAAAGCACAAGTGTGNCCGGCCTGNGGGCACACACACACACA CACACACACACACACACACACACNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNATTCAGATGGCCTCCCTCCAGACCGCAACACACACACACACACACAC ACACACATGCATGCACACACACATGCATGCACACACACACACACACACACACACACACAC ACACACACACACAGAGCAGCAGCCCGCATTTTTTTAATGCTCCGTCCATCTCTGTCAATT CTTGCTTTGATGTGTCACACAAAAGCACAAGTGTGACCGGCCTGTGGGCACACACACACA CACTCACACATGCGCGCACACACACACACACACACACACGCATACACACTCTCTGGTTTC ATGCATTTGGGAAAAATGGTTAAAGACACTTCACACCTCACTTGACGGGCTATGGCGTCT GTCTACAGTATCAGTTGCCGTGGCGACACCATCTCCAGAAATACAATAAACACTGATATC AATATTTAAGGCCAACGCGAGCGCCGACGCTGAATATATATTTCCGTCCACAAGCGCACG CAGATCAACTTCTCCTTGTGTCGCGCTCACACATGCGGAACATCCTGTGGAACCGAAGCG TGCTGGCACGATGGGGGTTTGCACCAGAGCCCGGAATTACTCACACATTCAGGTTCTCCG TGAAAGAGCCGACAGGCCCGCGGACAATGTCTAATGCCCGAGAACACATGCTCACGTATG CTAACCGACGCCCATTACATTTTCACTTGTGCACGCACAGTATTTGTGTGCAAACGCGCC GCCTCTCACTCCGGCGGGAAGTCTTGACATAATATATGGGCTGCAGATTCCCAGCTGTGG GAGCGTACAGCCGCAGAGCTGCTCTCCGGTCAGAAATCGCAGTTGTTGTTTCATCTCTCC TCCTGCAGGTCTATGGACATGCAGGACCTAGCTAGTCCTCATAACCGAGTGGGAGGCGCA GATTCCACAGGCTCCAAACTGGACAAGAGCAACCTCGGCAGCCCTTCCATCACCTCCAAT GGATTAGGAGGTGAGACGGAAAAGCATGACCAAAGACCCAAACACTTCAATGAAGCCAGC AGCATTAAAGCGCCCAACACGTCTCGTCACGCGTTGTGGCTAGTTTGGCTGCGTCTACAC CTTAAAATGTCAACTTATTGGCCCAATTCTCATCTATATTTCCATTTTGAACCCTTGGCT CCTTAAAATCTTTGAAATTCTGCTGGTTTCCTGGAGGTTAATGTTGTTTGTACAGATATT AAAGTATCAATCACTGCATTAAATGAGTAAAATTCCCTCAGTTATTGCTGTCTAGCATCA AGCACTTTTAGACCGCACCTCCACATGTTGCGCTAGCACTTACCGACGTCTCATTCGCTG AAGTAACGCAGAAGATAGATCAGCTCTGAGCACCTCTGCTGCTCCTGCCGATTAATGTGG GAAAGATCTGCTCAGTTATTTATCACAATTGGCTCCAGCACACACACACACACACACACA CACACACACACACACACATTTTCATTTCCCTGAAAAGCAGCTGATGCTGAAACGTAAACC CAGTGCTGTCAGTCATCAAGCATAGACAAGGGTTTTTTTTTCTGGAGCATTTTGGAGAAA TGGAAGGAGACGTGGAAACACACCCCAGATGCTGGCAGGAGGACGCGGGTAAACCTCTGG AGAACACACATAAACATGCGGTGAAACACTTCTGCTCTCCCCAGCTAAGCTCTTGGCAAA CATTGTGTGTATATGAGTAAATACGAGGCCGACGTCCCACTGGAAACTATGTCCTCCAAC GGAGAATGAAAGCGCCACCGCTCTCTTCACTGTCAACACCAGCCTCCCTTTCATCCCTTT CTCCTTCGCTTTTCACCCGCTGTTCTGGTTCCAGCTGACTGTTTGTTCTCGCCCGCACTC AGTTTTGATCTGATGTAACATCGCTGGTCGGAGGGCCTTAGTTTGATCCCCGGCTGATTT AACCAGAAATGGAAAAAAAGAGCTTTGAATCGCATTGTAATGGAAAACATGCCATTTCGG TCAACTCGCGTGTCAGCTGACACCCTAGTCACAGAAATAGTTTCGTTCAGAGAGGACCTA ATGGGCCATATTAGAGCACATTAAATCATTTTTGATGAGCTTGCGGCTAATGGTTTGAGC AGACCGTGCCAGGACAACACGCTCACAGCCAAAACAAACTACATACCCAGCATTCTCCCT ACCTGACATCAGCTGGAGCTCGGGCCCAGGGGCCATCTCAATGGCAACTCATTTGTCTCC ATTAGGGCTCGTCCGGTGGGTCCTAACGACCCCCGGGAGGATAGATGCAGTTGTCCCGGA TGAAATCATGGCGGCAGAGCACCGCTGATGATGGATTCTACTCATGTTGAGAGAAAATCG GATGGACAGTGTTTTAACGTTAGCAGGTGCTCCCCTCGTTAGCGACGTGCTTTTTTATCC CGTGCGAGGAGCCGGATCGATACATCATCACGCTGCATTTCCAGTGGATTAAGTTCCACT TGGCAGCACAGAGCTTCTCCTTTTATAAAGCACAGGCTTCAGAATGAATGTGTTAAAGTG GAGAAGCCAATCTGTTTCACGTCTGTTCGCAACCAGGCTCATTAGCATTTAGCAGTGTGA CTAATGATTGTGTCAGATGTGAAATAAAAATATCACTGATAGTAAAATTATACTTGTTTG TTTTTTAAATGATGATAATTACTCAGGGTGTTTCATTATTACCACGTTCCAACCTTGCAC CCTTTTAGGTGAGAGCATGACAGTCCTAAACACGGCTGATTGGTTGTTGGGCTGCAGCAG CCCCTCCCCCGCATCGGCCTCCAAAGACTATGGTACAGAGGCGCACGCGTACGATTCATA GTTGCACGAGAAGTTTGCTGTTCTCTGCAATCTGATGTTTTGGTTTTGCAAGAGTGGGTT TTCTGTTTGACTTGCAGTGCTGTGATATGAAGCTGTTGCATGGTTTGAAGAATGATGTCA CAGAAAAATAAACCTTTAATAAAGGTTTGAGAGGAAAAGCCTGTATATTAAGAAGTAAAG AAACTCACTTTTTCACTAGGACACCTTTTTAGCATACAGAGGCTTTTCTAATTATGTGTT TCTAATTAAAAACTTCATCATTGATAGGTCCATAAATAGTTTAGTTCATTCTTCTAATGC ATGGATAAAGGGAAAAAATGGATTTAAGGTGAAAGGGGCCTGCAGACACAAACTAGAGGG ACTCTGCTGCTCCTGTTGCTGTTCTCTCGTGTGTGTGTGTGTGTGTGTGTGTGCGCGCGC GTGGGCACGCAGGTGTGTGTGTTTGTGATGGCAGCCAGTCACCTGATGCACTGCTCTTTC TGCCGTCCTTTAGTAAAAACAGAGCCTTTGAACAACAGCGACACGGCCACCACAACAGGG GACGCAGTCCTGGACACCTACGCCGGGATCAAGGTAACACAAGGGCGTCGGCACAAATGC ACGGTTTTCAGCAACACACGACAGCGTCCCTCTCAGCTCAGCAGTGGCGGGTCTGCTGAG AGCTTTAATCTGATGATGCATCGGTTGTCATCATCAGAGCCTGGCACAGGTGTGTGAGGA CGAGGGAGAGAGTGTTTTTGGGCACCTTTTCACACACGTCGCACAGATGCGAAGGGTTTT GGTTCCGTCTGCGGCTCAAACTGGTTCAGATGAGGTTGGCTGTACCGCTGCAGCCGACCT GGAGGCCTTGGACGTGCACGGAAAACAGAAAAATGGAATTGTCGTTGTTGAAGTTGCTAA AGATTGTTGTTTTTGTTCAGTGATCACCAGCAGCGGATACAGCCCCCGTTCAGCCCACCA GTACTCTCCTCCCCTCTACCCCTCCAAGTACGTCTGTCCCGTGCACGCGCATATGTGGTT AAAATGGTAAATGCTGCTACTTCACCTGCTGTTTCCTCCCCTCCTCCAGGCCCTACCCCC ATATTCTGTCCACGCCGGCAGCCCCTCCCATGCCGACGTACGCTGGCCAGCCCCAGTTCA GCAGCATGCAGCAGTCGTCCGTCTACACCGCCTACTCCCAGACAGGACAGCCATACGGCT TGTCTACCTATGGTACGCACACCCCGACCTCCTCCTTCGGCATTAAAACGGAGAAATGTT CCTACTTTACATGATCTGAAATGATCCCGGGGTTAAATGCCATGTTTCTGCACAATTGGA ACACTTCTTCTTCTATGGTTTAGCAACTTTTTCCAGTGCAAAAGGTCCCTGCCCCTACCC TCAGGCCCAATAGTTGAGCCAAAATTCTTCAGGTCCCCACCAAAGTTATCTGTGATATTT CTTTGACCTCTTCCACGTCCTCCCACTGTGTTTCATGGAAATCCACCCATCGGTTGTTGC TATAATCCCCCTCCCAGTCCAACCATTAGCTGTCTGAGCGGAGCCAGAATGACAGCATCA AGTTTAGAGAAAACATTGTGAAAATATTCAACAGTTTGGATGAGTGTTGCAAAGATAGGC TGTTCTTTTCATTCCAGACCTCGGCGTGATGCTGCCAGGCATTAAGACAGAGGGCGGTCT GTCCCAGAGTCAGTCCCCCCTGCAGACGGGGCTCAGCTACAGCCCCAGCTTCAGCGCACC TCAGCCTGGCCAGACGGCATACTCGCCCTATCAGATGCCAGGTCAGCTGGGGACAGACTT TCAGCCCCAACTGGTGACAGTTGGGTTCGAAAGCATTAAAGAACTTGTTTTTCTTGGGTC CAAAGGTTCCAGCTTCAATCCCTCCTCGGGCCTGTACGCCACCAACAACTCGGTGTCCAA CCCTGCCAACTACACCACCGCGCAGCAGGTAACTGCCACAGTTTTTCTCATTGCCGCCGC CTCATGACTTAAACACGGAACAATGGCTTTGTTCTAAATATATCCATATGATGAATTGTG CTGCGGTGGCGGAATACTTTTTATTTTAATGTTCCCCCATGATGGATGTGGCTTTACGGG GAGAAACCGCGCTTAATGTGGCTGAAATTAAAGGGAAATACAGTATCTGTGCGCGTAGGA CCGCGCACGGACGCGAGCTCTCGCGCACTGGTGCTGCACTTTGCAGAGATCGACGACGCG GTGACAGTTTTTAAGAGCTGACTCATAAAAACTTCCATCTCGACTAAAAGCCGCGGCAGG AGGTTTTGATTGTCCTGGAGATATAAAACGTAGAATCGTGGAAGAAGAAAAGAAAGAGTG GGAGCACGTAAAAACCCTCCGACGGCCACTTTCAAACTCTTTGAGCCCAACGTTGCTAAT TTCCTGTTTTCTGCGGCTCTTTTGTCCTGCTGCGTGGAGATTAGAGGGAAATGGTCACAG AGTGGTTAGTGTACTCAACATTAGAGCTGCAGATCTGTCACTCAGACCAGACAACAAAAA GCAGAAAACTCTGTGGCGACTGATGCAAAATTCAGCATAAAATATACAAAAAATGAAATT TTCCACTGTTTGTCTCTGCAGGATTATCCCTCCTATACAACATTTGGCCAAAACCAGTAT GCCCAGTATTATTCTGCCTCCACTTATGGGACTTACATGACCTCCAACAGCATTGATGGC ACAGGTTCAACGGCGGCCTACCAGCTCCAGGATCCCGCCGCTGCCGCCGCCATGACGGGT CAGGCTGCCGAGCTTCACCCAGGTGGGAAAACGTTTTTGGAGTGGTGGCGTTTACGTTCG CCCGGAACTGGAAAGTCGCCTGAATGTTAAGCTGAAGAAAGTGGAGGAGAGAAAGCAGCA AAATGTCCAAAGAAATGGTTTTTCCTCGGATTATTTTGGCCATAACTCAGAGTCCGATGA AAGGACCTTATCATTCCCCTGTCATCAACACTCTCCCTCTCTGTTTCTCGCTATTGTGTG TGTGTGTGTGTGTGTGTGTGTGTGCGTGTGTGTGTGTGTGTGTGTGTGTGTGTTTTGTCC ATTCTCTGGCTGCCTTCTCCCTCTCTGATGGAGACATAACAATATGGGAGCTAAAGCTAA GTCTGCTTCTAGTTAGCAGGGTACACATGGCATCAGGAGGGTGTGCGCGTGCACGCTCGT GCACACTTCTGCAGGGCTGTGTTATCTTTGTAAGAAGTGATGCATCTCTCCTGTCACCTT TAGCTTTTATTAGCATTAGGGTGCTCTTTAATCCCGGACACAATCCCAACAATCCTCTGG GATTATCTCACGTTCGCTGACTTTTGTTTGTTTTGCTCTTTAGGACGTTAAATGATGACG TTTGTTCTGTCTTTCAGGGGACTTTGACACAGTTCAGAGTCCGTCCACGCCTATCAAAGA GCTGGATGAGCGGGCGTGCCGGAGCGGGGGATCTAAATCCCGAGGCAGGTCCCGCAAGAA CAACCCCTCCCCTCCTCCAGACAGCGACCTGGAGGTGAGAACCTGCAGCTCCGACCCAAC AATCTGTCGGAAATGCAGCATTCCCAGGCATCAATGAAGTCTGCTGAAGTATCCGTGCTA AAAGAGCTGGACCTTTTCCTCCTTTTCTCTCCAGAGGGTCTTCGTGTGGGATCTGGATGA GACCATCATCGTCTTCCACTCTCTGCTCACAGGCTCCTACGCGCAGAAGTACGGAAAGGT AAAATCATCACCAGTTCCCACAGCCGTGCCGCAGGATGACTGTCGGGTATCCCGGATTAC GTCTGGGACAAAACAGGCCTGATTTTGTTTGAGCGAGAGGCGATGAAACGAGACACCGAA ATCACCACAGATGGCGATTTATGACCGGATCGTCAAACTCCGCATAAGCCTGATGAACAT TCCACATGTGGGGATTATTTTCTGTCAGGCTCTGACTTGGGCAGCATTATGGCGTTAACT ATATAAGGACACCTCGCCTTCCCAAGGTTTAGGTGCATTCTTTGGGCTGAAATTTGGTGA AGTTTGAGCAAAAACAAAGCTGTTGGTTGAGTTTAGGCAACAGAGATTCGTGGGTGTGTT TACACAGCACAAATTCTCCATCACGGTTGACAACTGAAATTACACGGTTATGTTTAGGCA ATACTGAGCCTGAATGGGATTAGTTACCACAACTACTTAATTACATTTGCAAAACTAAAA CTCTTGGTTATGGTTAGAAAAACGATGGTTAAGGTTAGAAGAAATTGTCTTTTCGCAACT TCGAAAGCAACCAAGACCGTGGCGTTTCCTCAGGACGGCGTTCCTCAGGGTCACGTGTTG CTGAAACAGTTCAGAGAGCTGGAGCCAAAATCAAACGCTGATTAAAAGGATTTTCCCCTG CTGTGATTATGGATTTTGGCATAAAGAATTGTTGCTAATGTGCAATTATGAGATTACCTG ATATGAGCCATCAGAATTCTGGGTAATCTGAAAAGTTCCCCTACTCCAGCAAACCCTTAG AACCTGGTCGAGCCTCTAATGACCCTTCAAATTAAACTCCCGATGGCAGTTTAGTGTTTT TATTTTCCTATTTACTTTTGCCTTCCTTTCAGGCTTCATTATGAGCTCATTTGGTGGTCT CACCTCCTCATATAACAGCAACTCTGTTTATGTTCCCTCTGATTTTAAGAACCTCCAGCT CTGATGACCTCATCGCGTGTCCAAAGGCTGCACATTGTTATGTGGTGATGTCATTTCCTG TGTAGGCGTCTGACTCGTACAGGTTACAGCTCCCCTCTCGACCAAACTGTCATCAAACAC ACACACACTCACAGAGTTTGGACCCAGACCCGGTAGCCTCGGCGTTTTTACAGATGCCTT TTGTGGGCACTGATGTTCTTCCGATTTGCCTGCAGCCATAGAATTTAATGTTCAGCAAGT GGTATTTAAGGGGTTTAAGAAAAGGCTCTGGTGTGTTGTAAACTGTATGTGTGTGTGCAG GAGTGTGTGTCTCTGTGGAGGACTCATGAGCCCCTGTGGTTAATCCAGCTCCGTTTATTT ACAGTAGAGGAACTCGGAATACCGAAGGATATTATCACAAATGAAGTCCTGGCACGTGAG GACAAAGTCGTACTTTTCCTCTCTACTGAAAGAAGATGGGAATGTTTTTTCACCTCATTT GCTGCCGCTGCCCTCAAGAAATAAAGCAGCAGCTGTGTGTGTTCGCCACCCGGCCAAAGT CGTGTTTACACGGTCGACATGGGAACCATAAGTTCTCGCTCAGACTCCGAGGATATTTTT GCTGCTCCTCATTTATCAGCACGGGAGTTAATTAGGGATAATTAGGGACTTTTCAGCGTA GCAGTAATAACAACAGAGGCGGAGAGTGGGATTGTTTTAGGTAATCCAGTAATGCTATCG CAGGTCGGTGATTAATGGGATTATTTAAAAACACTGGAAAAATGTCCCTTCTGGCGCTGA CAAATGCATCACACTGTGACTGACACGGCAGCAGGNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNTAATGATCTCGAGCTGAGACACACACACACACACA CACACACACACACACACACACACACACACACACACACACACACACACACACACACACACA CGGCTTTTATCCTAAACGCGCTTACTGCCCCCTGATGGTCAAAGGCGGTATGACACACCA CGTAAGAGCATTTGATTGATTTTTAACACCTCCCCAATGTGTCATCAGCCAGCGTTTGTC TGGTTGCCCTTTTTTTCTACTTCATTGTGTTATAATCATGAATAACAGTAACTTATTTAA AGTTTACACGTTGCATTGTTTTCTTTTTATTTTATCTGTGTGATTCCAGGAGTGTGATCA GGTACATATTGATGATGTCTCATCTGATGACAATGGCCAAGACTTAAGGTGAGCGTTTAA TGTATTCAAGTAACACCCATAATTCTTTGATCGTTTTTGTTCCAACAGAGCAGATTTTTC AAATAAAACATATCATTATTATCGACAGTACTTACAGTTTTGCAACTGATGGCTTCCATG CAGCTGCAACCAGCGCCAACCTGTGCCTGGCTACGGGTGTCCGCGGCGGGGTTGACTGGA TGAGGAAACTGGCCTTCCGCTACCGACGAGTCAAAGAATTGTATACCACGTACAAAAACA ATGTGGGGGGTAAGCCAGCCTGACAGGAATGTGAAGACGTGCAGGGAGTGGACGCTTTTG TGTGCATCCGATTGTGAAATGAGAACACATTCAGACTCAGATCCATCTTCAGGTCTGCTG GGCCCGGCTAAGAGAGACGCCTGGCTGCAGCTCAGAGCGGAGGTGGAGGCTCTGACCGAC TCCTGGCTCACACACGCGCTCAAGTCCCTGTCCATCATCAGTTCCAGGTGCCCCTCTATG GTGTATTTACGCTCCGTATCGCTGGTGGTGCCTGCCGTGCACCCTCCTGACACATCTGAT GTCTGTCTGCATCCCACAGGAGTAACTGTGTAAATGTGCTGGTGACCACCACCCAGCTCA TACCGGCACTGGCAAAGGTCCTCCTGTATAGTCTGGGAGCTGTTTTCCCTATTGAGAACA TTTACAGCGCAACAAAGATAGGTAAGACGCACACATTCCTCCAAAGACAGTGTTATTCAT GGTAAATGATCACTTGATTGCTAATATTTAGCCTCTAACAGAATTAATAGTATCTTTTTA ATGTGCTTAACCTTTATAGAACCTTTATTTTGTTTGTATCCTAACAGTGTGGGAACAGTT CGAATAGACATCCAACACTTTTTAGCCCCACGGCTGATATTGTTTCTGTTCCATCTTCTC CTGTTATTGCAGAGTTTATTCAGCCAGTTGTAATTGAAAACACTCATCAGGTGATTTTAT TCAGTAAACCCGGTTTGGCTGCATGCGGGACAATAAACAGACTCTCTAGAATGTTTCGAT GTGTAAAGATTGGCCATGTCACAGCTGTCCGGACTAGTAAATGTTCCCACAATTCTCATT TTTCTGACGTATCTACAGTCTTTTTGTTTTTTTTTCTCTACATAATTAATCTTTGAGGTC ATAAATACATCCAGCAACTTTGGATGATGACTTTTGGAGCTGGGAGAAAAGCTGTGAGTC AAATTAGCTTAGCATCTTGACCCCCAATCTTCCTCTGAGTGAGCCTGATTGATTGCAGCT GCTGGACTGAGCGTTGTAGCATCTGGAGCTGCAACACAAACACTCACCTGCAGCTGAGAG AAAATGGCTCCATCAAAGATCAACCAAAAAAAAATAAAAAAGAGCCGTAAGCATGTCTGC AATAAATTAGAATCTGTTTAAGTTCAGGTGTCCGTGTTTATCGTCATCATGAACTGAGAG GCAGCTGTCCAACAAGAAAACTGATCCAGATGTTGAAGCTCTGTGCTGTGCCGTAACAAA ACTAGGCTGTTTTTACCGCGACCTTTAACCCCCGAGGTCACAGCTACTGTCAGAATTACA ACCTAAATCCAAATTAAAGGTAAAAGAACACTGAAAGATGTTTATTTTTTGTAAATTCTT AAGTCATCGAGTTAAAAAGAATCAAAGCATCTTGTGAAAGTGAGTATTTGGAGGCTATTT TGATCTGACACTAGTGAGGAAAACAAAAAGAAACTCTTCTTTTGGACACATTAAAAAAGG ATTAATATGCGAGTATTTTGTACATCCTCTCCCCTTCATTCATCATGCACACACACACAC ACACACGCGCGTGCGCACACACACAGGTCAGTCGCTCTTTGTGCCTCACTTGCATCTAAA TGAATCCTGTGAAAGCCCGTCTGTTTGTCTCCAGGCAAAGAGAGCTGTTTTGAGCGTATA GTCTCCCGTTTTGGCACTAACATTACATATGTTGTGATTGGCGATGGGAAGGATGAAGAG CATGCAGCCAGCCAGGTAAACATACGGCTCCTGAACTCTGACCCCTCTGACCATGTGACC CTCCTTCCTCCCCTTGTTTATTTGTGTTTTTGCAGGAAAAGAGAGTTGCTTTGAGCGCAT TATGCAAAGGTTTGGCAGGAAAGTAGTATATGTTGTAGTTGGGGATGGTGTGGAAGAGGA GCAGGCAGCCAAAAAGGTAATGGACCCGTGCCCTCCATCATGACCCTGCCAGCTCTGATT GGACCGAGCCTCCTTTTCTGTGCTGTCATAGAGGGTTTTGTGTTGGTTGTTTTTCTGTTG CTTTGTTTTCTTGTGCTGAGAGTGAAAAGCTACAATTGATGCCGTTTAAGCACCAAACCA GTGACAGCGGTGCAACTGAAATGTTTGCTTTTGTTAATATAAAACCCATTCTTCTTCTGT GGTGCTGGGTTTTATTCTTCATGCTGGGTGCTGGGATTGTGAAAGGAACACTCTGGCATT ATGGGATATGTGTGTAATCACATTCTTGCTGTGGGGTGAAAGTAGAATTTCTGCATCCAA AGCTGAAGCAGCCAGATGAAACATGCCGTTGAACATCGGAACAGGAATTTAATCTAATTT AATTAAATGTTTTAAGCAACATTTGAAAGCATGGCGTACTTTTACTCAACACTCAGTGCA GAGGCAGTGATACACCTCCCAAAATGCCAAACTCCTCCTGTAAGCCAGAGTAGAGCTGCA TGGGTTTCGTTTGCGGTGCCATAAATATTGCTGTAGTGTCATTTGCATGCCTGTAGGTGG CGGTATGCAGCGGCCACCGTCTGCTTTCACTGACGCTTGTGTCCACTCCGCAGCACAACA TGCCCTTCTGGAGGATATCCAGTCACTCTGACCTGCTGGCACTACACCAAGCACTGGAGT TCGAGTACCTGTAACTATTACGGCAATATGGACTTGAACCATCAACCATGGACACGGTCG ACTGGGCAGCCCTCTTATTTAATACACTGCAAAAGTTTGAATTTTTTTTTTTTTTTTTAA ATGTCTGGATTACAAACTGAATGGTCTTAAAAGGAGGGGTGAGACAGGAGACTCAGCCGG GGGGGTTAGATCGCTAACCAGTCTAGGTCCAGCAGGGGCCTAACACTGGGAGATGGACGC TGTGGACCCCCCTCCCCGTCCCTGCAGCTGGAGCAGACTGGACAGCCTGGAAACGATCCT ACCGGGACAAACGTTTTTAACCGTGCATCACCCGGGTTTCTAGCAGGCCTGTTTGGATCA CACCCAGGATAAGCTTGGGCGGCGTTTTATGTACTGGTGTTAATACCCGTTTTGTATGTT TTTCTTCCTGGTGGTACAAGCATCTGTAAATTATTTACAATATAGTTAAAGGGTAGTGGA TGTTTAACTTAAAATTTGGGTTCTCTATTCTGGACTTTTGTAATTTGGGGGCAGGGGTGG GGTCAGAGATGTGCACCAAGTGTTTGAATGCTTTTTTTTTTCCCTCCTTAAAATCTGTAG ATAAAGAACTTATCCAACTGTGCGTGTCTTCTTCTCCCTTAAAAACCACACAGATCGAGT GTTTATCACCTTCGTGGCTTCATTTATACAGCACCCAGATATTAATGGTCCTGAAACTGG TTTTCCCCATTAGTCCCATGTTTTACCAGCTCCGATGGCCAGAGGGATAGAAACACAAAT TAGCCACTTTTGTGTGCATATTTTGACATTTTATTTCTTGCTCTTGAAGTACTCCTCAAT CACGTCCTTGGCCTGTGACTCCTTGCCATAATCCTGTAAGGCGGAATGGCAAAAATTAGC ATCTTTCTCACAATAACTGGAAATGAATTTTAGCAGCAAATGCCATTGTTTCATATGTAG CCGTTCTTAGGGACCCCAGTCACCACAGAGAGGTGGCGGGGCTCGTACCCTGGCCGTCCT ATAGCCATTCGTTAAACAGCTGCATGTCATCAACAACAAGCACCTGCACTTGCCTGGCAT GAAGATTCCTTTAACATCAGTTTTAGCCCCATGTGTGTTGAAGAATGTTTACCTTGACTA CGACGCAGCTGCAGCCCACCACCTTGCGGGGTTTGCCCTCACGGTCGATCTTGCACAGCC CGACCCACTCGCCAAGCTTCTTGTTGTCATCGACCTAAAGATAACAGCTTGTATAAGCCT TATTTCCTTACTTTCAGCATAAATGAAAGGTGCATTTGACAAGTAATAACATAAAATACA CGTTAAGCTATTAAAAAAAAAAAACCTTCAGAGCGTAGATTTGAGTAGGGGAAATGTGCA TCTCAGACAACATTGGGTAACAGTGGCACTTTCCTCACAATATTCAGTAGAGGGAGCCAG ATCATCATCAGTGATGCAGACCAGGTGACACTAAACCAGCCTGGTCTAGTTTATTTACCT TTATCAGGTTGATCTGATGCTCAGCGCAGAGGGCCTCCACCAGCTTGACGTACATGGGCT CGTCACAATTGGCAGCAAGGGCGCACAGATGGGCCTGACGCCTGCAATATATAACCAAAC ACTTTAAAACACTGATCCAATGAACGTTGCATGTTAAAAAAAAACTAGACATATCTCAGA CAAAAATTGGGTAACAATGGCAGACTTCTACATTGAAACTCAGTAGAGGGAGCCAAGACA TCATCAGCGATAAACGCGTGAATATAGCGTGCAGTAGGTCAAAACATACTTGTCTAGAGC CTTGGCAGCTTCGCGGATACCGCGGGCAAGGCCATCGTGGATGAGGGCAGTCTTCAGCAC TTCTGGGAGAGCAGTGTTGACATCCATGACACCTCCAGCAGCAACGCTGTGATCAAAGTG TTAGATGTTCAGACAGGAGCCAAAGAAGCCGAACAATTTAGGGTAACACAACGGAGCTTC CAGCAGGTCAGAACACAGATCTCACTCATTGGAGAGTGAAGGGGTATCCGACAAAAGATT TAAGTCATCATTCAAATGCCGGGAGCTCACGTTTTTAAAGGTTTTACAATTGTTGTCAAT TAATCTACAGTAAAAGCTGAAACACCTATGAATTACAGATAGAAGCTTAACAATGCCAGA CATCTGCCTTGCACTAAATTCAACAGTTGTAATTACATTTAATGACACATTTTCCAATCG AACCAATGTATTCCAAGTACTTTTGAGAGAATCGTTGAACCACCATAAACATTTGGAAAT ATTTATGCGCAACCCACTGTCAGTGGTTTGATGCTGTATAATCCTTATGTTACTTCGCAT ACACAAGTAATCCGTCGTTTTAGACCCCAGCACGAGTTTATAAGCTAACCTTATAAACTC GAACCTTTCAATGATCGATATTAATGGACTGACTGCAGGTACCCGAAACCAGGCGAGCTA GCTAGTAGCCCATGCTACTTAGAATACAGTTTAAGTCGCCCCTTCAAAGAAGACCAACTC GGAATTAAGATTCATCTTATTTACATTATAACATCTACTGCATTTTTGCAAGTCTTTTTT TTTTTTTTTTTAAAACACCAATGCATTATAGCGTCACTCACCCTTCCTCGGCCATTGTTG TTTCAAGATGGATGTTTGACTTAAAAGTTCTGAAATAACAACAAACAATGAAAGAATATG CATTACTGGTCATAAAGATGTTATTGTAGTGATTGTATAAGTTGAGATGCTTGATAAATC TTGTGGAGTGTGTCGCAGATTCGAAAACGTACCAAAGCCTGCGATCGGGCATCGACTAAA GAGGACGTCATCAGGGTGCGACACCGCTTTAATACCACAAAGGCCATCCGCCAGCTTACT TTGGTGCCCAACTTATTGCCTGTAACATTCGCCTTTATCAAAGTACCGTTACTACGAATC GGCCATTGTGTCTTGTTTTAGTTTTTTCTCTTTAGTTATTTTTACCATTATTCGTAATTT TTTTTTAAAAA wise-2.4.1/test_data/vav_promoter.mouse0000644000175000001440000000102110011413266017602 0ustar philippusers>vav_promoter_mouse AACAGGGCCTTGTGGGGTGC AGGAAAGACATGAGTTTTGGCCCCAAAGCAAGGTTGAACCAGGAGGGTTATGGGTGGTGG AAGAATGGTTGAGACTTGACTCAGTGTTCAGTGGTCCCTTTTGGCTGCTGCAGGGGCAAA AGGCTGTGAGAGATCAGGGCCGTAGACTGGGGACCAGGAGGAGACAGGAGGTGACAGCCT AGGTGCCTACGGCTGGATGAGATAGTGGCACCTTAGTTCAGCAGGTGCCCAGGTCTGCTC AGTGTAGGTGGAGAAAGACGAGGTCACACCAGTGAGTGGAAGCTGTGAGGGCGTAACTGC AGATGCTGCTCCCCCTCCGCCCCACAGCTCCTCCCCACCCCCACCCCGGGGCGACAGTTA CAGTCACAGAAGAGGAAGTGGTGTTGTAGTTGTCCCCACTGGGGCAGGCGGCGGCGGTGG TGAAGGAACGAGGGTGCACGGGGCCTCCCCGAGGGGCCAAGTGAGAGGCCGGCAGCCACC wise-2.4.1/test_data/rpo_human.gen0000644000175000001440000004244707571667333016540 0ustar philippusers>5.32372381-32389772 TTGAGGTGGGTGAAGTGGGGTAGGAAGACCATTTCTGGGAAAATGGGCCAGAGTATTGAT CTTTTTCATTATGACCCCTTCGCTTCATTAGAGTAAACATTTATTGAACAAACGCAAAGC TTGGCGCTTGTCACTCATGTTTTATTGGCGTTTTCCTTTTTTTTAATTTTTTTTTAAGCT ATCTCCTACAGGAAGGATATTAGCTCTTTCATTCTCTCAAGGGTCAGATGTAATCTTCCA ACATCTGACTTTCGCGTCACCCATTTAGGAAGAGACGCGGTCCCTTTAAGGCCCTGGAAA GGGTCTAAGTGTTGGTTTCTGTGGGGAGGCCACGCCCCATCACGTGACCGCAGCCCCAGC GCGGCGGGGCCGGCGTCTCCTGGCTGCCGTCACTTCCGGTTCTCTGTCAGTCGCGAGCGA ACGACCAAGAGGGTGTTCGACTGCTAGAGCCGAGCGAAGCGTGAGTGCGCGGGACCCCCT ACCCCTACTCCTCGGGGCCCCCACCCTCCCAGCCGGGCCGTGAGCTGCCTTCGGCCCTCC ACTCCTCTCGCCGGCAATGGCCGCGGGAAATGGCGGCTCTGCCTTACCTCCCCCTTCCCC TCGGCGTCCCCGGCCCCCTTCTCCGTTTCTGACTCCACGCCTGACGCGCTGTGGGCCCTT CCGCGGTAGACTCCTGTCCCCGGGGAGCCGAGTCGAGGCGGCGGGCGCTGCGGCCCGGGG CGGTAGATTGAGGGCGGCCGGGGAGTGAGGAGTCGCGGGGAGAGAGTCGCGGCGTCCCCG GGACAATGCGGCGGCGGCCTGCCTAGGTGGGGCGCGTGCGGTTACCTACTCTTCCCCCGC CCCTCGCCCTGAGCGGGGCGCTCTGGAGACTGGGAGAGCGGATGCGGGCGGGAGGGGGCC GGGGGAAGAACGGCTGATGTGCAGGGGGAGGGAACGCTTCGAGAGAAGAAAATGGCGCTT GGTGCAAATCCCGCCCCTTCCCACGCCGTCTTCTCCGCACTTCGCCGCCTCCCACGCCCC CTCCGACCAACCTGTCTCCCCTCGCCCGAGCGGCTGCTAGCCACGGGGTTCTAGCGGCTT GCTGGGGCCGCGCGACCCCTTCCCTGGTCTTGTGCTTGTCACCTTCCTGTTATACCGAAG TCGTGTGCCCTTCAGTCCTGGTTCATTTTCACCTCGTTTTTTTCTGATCTTTCCCTCAAT CAGCAAAGGCTGAAGATTTCGTTTCTCTTTTTAAAGTTGCGTTTTGTATAAATTCTACAA TAGTGGTTTCAGTATCAGTTACTTGAATTACAAGCTGCTTCTCCCCCCACCCCCACATTG GAACAGGCTCATTAAGGTAAATATATATTTGTTAAAAGTTTAGAGGCTGGTTTTAGTTAC CGTTACCTTTCTTCTCCAGTGGACTTCTTTGGGTTGAGTACCAGGTGGTTCTTTGAAAAA TTCTTAGGCCCCCAGGCAGTTTTTGATAACAGACGGTAGTTATGATCGACAGTTTCAAAG TGAAAAATTATGTTCAATTTAATTACCTTTTTAAAAAATATCTTTTTGTCGTATTAATTA GCATAAAAAACTTAACTAAATTGATTTTAGAGATGAGGTTGCAAAATGGAGCAGAAACAG GAAAAACGGATAAAACGTGGTCATGAACATTGCTTTTCCCTTCTGAATTTACCCTTGAAG ACATTACCAGTTAAAATCAGATTGAGCTTTTTGAATTTAATGGCTAGGATTGGGGTGGCC CACTTCTTTTTCCTTGACCTCCTATTTTGGAACATATGCAATGTCAGTGCTAATGCAAGT TTCATCTAGAGAGCTAGATTATTTATGATTTTTTTTTAAGGAGGAATTTTAAGTCTTTTT TTCTTGTATTAAACAAATACAGTGTGTGATGTGTTTATTAGGCCCTTTAACGCATACAGA AATTAGCTAATTTATGCCTAGTGTTCCATTATTGGAACGCTAAGCATGTGGGAGTTATTT ATGTGCTACTGCTCAAGATCATCGCCAAGGTCTGCTTGCATAAATTCAAAAAATTGCAAC CTCTGGCATAAATGGGTTAATAGGACCTAATCTCTTCTGAGATGGGGAGAGCAAAAGATA TTTTGATAATCAGCGTTTTATGACCTGGTGTTATAAGTGCCTTGAATAGAGGTATCCACG TATCTTGGAATTCCTTGAAATTTGGGGCTTAGGCTTACTGATAGTTTGCTTTCTGCAAAC TTGCACTCAGGCACTCAGTAAACACCCACTTGTAAGCAAGGCACTAAGTTATCTATGTCT CTGGGGGGACCTGGGAAGTTACCAGCATGGTAGGAATTTGCGGGAAGGTTTTGCACCTCC CATAAATAGGTTTTGCACCTCCCATAAATAGGTTCTTCAAATTTTAATTATGTTCCAGAG TAGAAAAATCTGTGTAAAATGTAATGAATTGCTGTGAATTGTGTAAGATTTTTTTTTTTT TTTGAGATGGAGTCTTGCTTTGTTGCCCAGGCCGGAGTGCAATGATGTGACCTTGTGTCA CTGCAACCTCTGCCTCCGGTGTTGAAGCGATTCTCCTGCCTCAGTCTCCCGAATTGCTGG GACTACAGGTGTGCCACCGTGCCCTGTTAATTTTTGTATTTTTAGTGGAGATAGGGTTTC ACCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCTGCTTTGGCCT CCTAAAGTTTTGGGATTACAGGCGTGAACCATCGTTCCCGGCCTGAATTGCGTATAATTT TGTGTACTCTTGAATTAGTACCTGTCGTTATTTTGGTGATACGGCCAAAAAGTCAAAATA TGAATAAAATATTATGTAAAAATTAATTAGATGTCACATTTGCATAGTACAGCTAGTTCC CTGTTGTGTAAATGTTGGGGTCAGTTCCCCATAGTGAATAATTTTACGTTAGTTCCAATC TCGTTGATGAGAAGTCTAAAGCAGTAATAGTAGAATTACATTTCTTCTGGTTTTAATAGT AATTGTTGTCTGCTGCCTTCTTGCAGTTTACCCTACCCATAGTGTGTAATGCCATTAAAA CGAAGTATAGAAAGATCCATTGGCCTGGAGAAAGGTTAGAGGTGTAGGAGTGTATGACAT TTAGTTCATTGTTCTTACTGGGTTCAGCACATTGCACCCTGCGTGTTATTTGCAACTTAA AAGGGTATAGATTAAAACTTGTGCTCAGTGTAACAACTCAGTACCACAAAAATGGTAGAA TGAACCGTGGAACTTGTCCTTGATTTTTTTCTTTGATTGGGGGAGAGCTAAGTTGAAAGT AGTAGAGTACCTTATTAATTATTTTTGTAATGTATTTTTCTTTCAGGATGCCTAAATCAA AGGAACTTGTTTCTTCAAGCTCTTCTGGCAGTGATTCTGACAGTGAGGTTGACAAAAAGG TGACTACTGCTGCACCAAGTCATTTTGGTGATACTCAACAATATTGTCCATATCCCATTC TGAAGGATAGTAAAAGGTGTATTAACATCTTAAAATGAGGATCTAGCTGGGCGCGGTGGC TCATGCCTGTTATCCTACTTCTTTGGGAGGCCGAGGTGGCAGGATTGCTTGAGGCCAAGA GTTCAAGACCAACCAGGCTAACATAGCAAGAACCTGTCTCTTTAAAAAAATAAATAAATA AAAAATAAAAAATAAGAATGTGAATGGGTATTTCTGGAGGTACGGTTGGTCTCTGGACCA CTTGACTAGAAGTGCCTAGGATGCTTTTTGCACATTCATACTCATAGGCCCTAAATCAGA CTTAACAAGTCTTCTGTTGAGCATCATTAGGAACCCTAAAGTTGCAGAAACACTGCCTTG CATCCTAGGGTCATAGAATTCTAAGTAGGCCAAAGTCACTATTTGCCGTTATTTAGAAAT TTACCAGATTTTTTTTTGTAAAATGTTAATTTTTTTTTTTAAAGACAGGGTCTTACTCTC TTGCCGAGGCTGGAGTGTGGTGGCACCATCATGGCTCACTGCAGCCTCGACCTCCTGGTC TCAAGCAGTCCTCCCACCTCTGCCTCCAGAGTAGCTGGGACTACAGGCATCATGCCTGGT TAATTAAAAAAAAAATGTTTTTGTAGGGACCAGGTATTGCTGTGTTGCTAAGGCTGGTCT CAAACTCCTGGCCTCAGGCAATTCTTCTGCCTCAGACTCCCAAAGTGCTGGGATTACAGG TGTGAGCCATCATGAGTGGCCATAAAATGTTAATTTTGACAGTTCTCTTAGTTACTGGTG TTTATTCTGCACATAAGGTTTTCTGAATTTTAGACTTGGTACATTTTTAAGTTTGTACTA AGTTTGTGCTCTGGTCCCTTCCATTTAATTAAATCAGCACGCAGTAAAGCTAACTTGAAA CCCATTGACAAGATAGGCTTTTTCTGCATTAGATGACAGCTGCACCGTAATTGGTGAATT TCGCTAAATTGAGCATCTCAGTGGAGCATAACTGAGCGTCTCACTCTGCGGTCAAGTCTT CCGTGCAGAATTGTCTTTTATCGCATAGAACTTTACATATCTGAAGAGATATTTATATCC TAGAAATAGAATAAGTTGGTCGTGTTTTTCCTAATTAGTATATATCCTTTGTAAAATAGT AAGTAATGACTAGCACTGGTAGACCTGTGATTTCCGAAAGTTTATTCAAAAGAAGCAGGC TCCCTATCTTTTTTTTTTCCTCCTGAAGCTTAGCAATTTTAGCTAAAAGAAAAGGGGAGA GCGTATGGGAGATTGGAGAAGTTGCAACCTTAAAGTATAAATATAGAATATAACAACACA TGGAAGGGTAAAATAAGGCTTCAAAGACTATACTTGAGTAAATTTCTTAATTTTAAAATT TGCACCCTATATAGTATTTGAGTATGTTGATGTAACACATGTGTATTGAGCTTTTATTTG CCAGACATGCACTATTCCACAGGGAATACTTAGAGCCTGATTTATAGAATAATTGCTTTC TGCATATTGAGCTAACTTTTTGTTTGTCCCAAATAGTAATATTACTCTTGTAAACACTTA ACCTTGTATACCACATTTTTCATTTCATGTTTTACATGTATATAATATTTTTCCTAGCTT CATCTAATTTGGTAACATTCAATTAATTTAGTAACATTAAAATATTTATACTATTCCATC AAGAAGGAACATGACTGCCCTCTTCTGTTTGGGTTGGGTATTGTAGTGGTTTTTATGGGT TAGCTCTTTTTGAGAATGCGACTTTCTAATAAGCTTTTAAAATAATGCTGTTTTTAAAAC AACGTTGTGATTTTTGAAAGCTAGTCTAACACATAGCTGTCTACAATGATTTTTTTTTTT TTTGTAATGAGGAAGTTCTTGAGTTGCTGGCTGTCAGTGCCCAGTGCAAAATAGCTCTCT AAAGATTTGCCTAATTGTAAATTCCTTTTTTTTTAATTTTTTATTTTGAGATGAAGTTTT GCTTTTGTTGCCCAGGCTGGAGTGTAATGGCGCGATCTCGGCTCACTGCAACCTTCGCGT CCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTTCCGAGTAGCTGGGATTACAGGCGTGTG CCACCACGCCTGGCTAATTTTTTTTTTTTTTTTTTTTTTTGAGATGGAGTATCGCTCTGT TGCCCAGGCTGGAGTGCAATGGCACGATCTCGGCTCACTGCAACCTCAGCCTCCTGGATT CAAGCAGTTCTCTGCCTCAGCCTCCCTAGTAGCTGGGATTATAGGTGCCCACCACCACGC CTGGCTAACTTTTTTTGTATTTTTAGTGGAGATGGGGTTTCACCATGTGGCCAGGCTGGT CTCGAACTCCTGACCTCAAGTGATCCTCCCGCCTCGGACTCCCAAAGTGCTGGGATTACA GGTGTGAGCTACCGCGCCCGGCCCATAAATTCCTTAAGCCAGCATAAATTCCTTTTGGAA TAGGCAGGACATAAATAAACATATCCTGGAAATGGAATAAGTTGGTTATATTCTTTTTAA TTAGTATATCTGCTTCGTAAAATAAGTAACTGACTAGCCTTAGTAGACTGTGGTTTCCAG GTTTATTCAGAAGTAGCAAGATCCCTCCATTTTTTTTTCTACCAAAGAAATCGTATGTGG GATCCCAAACCACAAAATAACCGTTCCTGTGGTTAATACTACTATAATGCCTGAAGTGTC TTTTGGGATCCTGAGAACAGAGTTTGAAAACATTACTAGACAGAAGGATTGGTTAGATTC ATAGTTTTGTTGTTGAGTGAAACTTGCTTATGTATATATTTATGATATTTTGGATGTAGT CTTTTGATTGTTTAAATCTTAAAAAGTAATGGGATCTTTTGACACTGGGGTATGTTTTAT TTTTATGTGTGCAAATTTTAACCATATTCTTTTCTAGTTAAAGAGGAAAAAGCAAGTTGC TCCAGAAAAACCTGTAAAGAAACAAAAGACAGGTGAGACTTCGAGAGCCCTGTCATCTTC TAAACAGAGCAGCAGCAGCAGAGATGATAACATGTTTCAGGTAAAGTTGGCTATTTTTTT TTTTTTTTTTTTTGACATGGAGTCATGCTCTGTCACCCAGGCTGGAGTGCAGTGGCGCCA TCTCGGCTCACTGCAACCTCAGCCTCCTGAGTTCAAGCAGTTCTCTGCCTCAGCCTCCCG AGTAGCTAGGATTACAGGCATCCGCCACCAGACCTGGCTAATTTTTGTATTTTTAGTAGA GATGGGGTTTCACCATCTTGGCCAGGCTGGTCTTGAACTCCTGACCTTGTGATCCAACTG CCTCAGCCTCCAAAAGTGCTGGGTTTACAGGTGTGAGCCACCATGCCTTGCCAAAGTTGG CTGTTTCTTTAGATTCAGAGGAATTATTATCTGGCTTGATCTGAAGAATGTTAAAAGTAC TATGATCTGATAATTGCCTAATATGTATGTTACAATCTTCTTAACTAGGGACATTTATTA AAATAGAACAAACTAGTAAAAGTATTTTGTACGATGCTGGATTATTGTTAAAGTCTCTAA AGTCTAGTTTTGCTGTATTTAAACCAATGCAAATTTAATTGAGAACTGCACATTTTGAAA GCAACTTGGAGGAGGCAGGTCAAGTGTTGGGACAGTAAAGTATGAATAGATTATTATGGG ACAGGAAGCAGCAATGTGACATGCCTAATTTTGGCCTGATGAGCAACAGAAAAGGGGAAT GGGTTGAATAGATAAAGTGAAGGAAGTTCATTAGAGGGACTTGATGAAATCACCTAGAGA GGACTCGTATAGCTTTTTCTCTTGGGTTTCCTGTCTTGTTTTAGGGAGACTTGACACTGG CATCTTTGTACAAGAAGGATTTGTGAGGAAGGGATGTTGGGGAATAAATGAATGCAGGTG AGATTGCTTAGGTAATTGTAGGCTTTAATCTGTATGTGAGGTGATAAGGGCTTAGATGGT TTTTCCTAAAGAAGAAATTATGCCAATTACAAGATACAGGTTAGGAAGAATGGACCAGAG GAATTAGGCAGTCAGTGAAGATGTGGACTTGATTGTGGATGTGATTGAAAAAAAAAATGG TGTTGCTTCTGTAGCACCTGAAGGGCTTAGTTGGGAAATGTTCATGTGGGATTATCAGCA TGGTTGACTAAAGCTGCCTACTGAAGTATTAAACAGAGGAAGAACAGGAAGCAGATGAGG GGATGTCTTGGGTTATATTCAGATAGAGAATGGAAGGAAAAAGAGGATGTAGGTTAAGAG AGAGGGTGAAGGAAAATTAGAAGAGTGCAGTAATGGGAGCAAGAAAAGGATGAGTGTTTC CAGGAGCTATAAGTATTAGTTGAAACCAAAAAGTTGGGTGGAACGAGACTACAATTTTTT TTTTGAGACAGGGTCTCTGCTCTGTCACCCAGGCTGGAGTGCAGTGGTGTGATCTCTGCT CACTGCAACTTCCGCTTCCTGGGCTCAAATGATCCTCCTGCCTCAGCCTCCTGAGTAACT GGGACTACAGGCAATGCTCCATGACGCCTGGCAAATTTTCTTTGTTGTTGGTAGAAACAG TATTGCCCAGGCTGGTCTTGAACTCCTGAGCTCAAGTGATGCGCCCACCTTGGCTTCTGA AAGTGCTGGGATTACAGGCGTGAGCCACCGTGACTGGCCAAGACTGTAGACATTTATATG ACTAGAAAGTAAGGCTAACACATGTATATTTTGACCTGTTGATAACTTTGAAAGGTGGAG TGCCAAGATTAAGGTGAGAATGGGAAAATTTAAGTTTTTTTTTTCCTATTGCTTATTTTT GCCTTGTTATACTTCTAGGTAAAAAAGATAGACAAAGTGCAGATGAACTATTTAGTTCAG AACACACATTTTAGAGATTCTGTTCTGTTAAGAGGAGTTTTGTGAAAACTAGATCTAATT TTAGGAATTTTCTCACCAGAAAAACGGAGCTTCATTTCTTAAACCCTCATCTGGAAAGAT TCCTAAGCCTCCTAAGGCTGACATTGCACCTTTTGAAAGCCTGCCTCTAGGAGGAACATA GGTCATCTTTTCTTTTTTTTTTTTTTGAGACGGAGTCTCGCTCTGTCACCAGGCTGGAGT GCAGTAGCACGAATCTCGGCTCACTGCAACCTCCGCCTCCTGGGTTCAAGAGATTCTCCT GCCTCAGTCTCCTGAGTAGCTGGGACTACAGGCATGCGCCACCACCCCCAGCCAATTTTT GTATTTTTAGTAGAGACGGGATTTCACCTGGTTGGCCAGGATGGTCTCGATCTCTTGACC TCGCCATCTGCCTGCCTTGGCCTCCCAAAGTGCTGGGATTACAGGTGTGAGCCACGGCGC CCAGCCTAGGCCTTATTTTCAGAGTGGCTTTCATGGATCTAGTAGTGTAGGCATTATGAA ATAATATGATACTTAATTTCATTGCCATTACAGCTTGATGTACATCAAACATCAATACAT AAGCAGTTCTCTAAATGTATTAAAGAGTTGTACCAAAGAAAAATCAATAGACTTATCTTT TAAAGTCTGAAGTGATTGGGGCAGAATCGTGACTAGAGAGAAGATACTAGAGATGCTTAC TTCCTGGTTCCTTCAGCTCTGATTTTGAAGAACTTTCTTCCATAGGGATGTAGTCTACCT GAGGTGACATCTGTGATAGTAAAGAGACTGGAGAATTATCTCATAATTATTTAGTACCTG TGTCTTGAAAGGTCAGAATAGTTGAGGCAGGAAACTTTAATCCATATTTTTCTTCAGAGT TAGGCACAAAGGGTCAGTAATACTGCTTTAGTTTATTTGATGATTTAAGGATACTTGATA CTTTTAAATTATTTAATTTAAAATGATTATAACTGGTCATTTTAATCTGGGGCAGGAGTC CATAGAATTGTTTTTTAATTTGAGTTTTCTTTTTTGTGTTTGAAGGAATTATTCATAACC TTTATCACAGGGGTCCCTCCTGCACAGGAGGTGAGCGGTGTGTGAGTGAACATTGCAGCC CGAGCTCTGCCTCCTGTCAGATCAGCAGCGGCATTAGATTCTCATAGGAGCGCGAACCCT ATTGTGAACTGCGCATGCAAGGGATCTAGGTTGTGCGTTCCTTATTCCTTATGAGAATCT AATGCCTGATGGTGGGATAATTTTTATCCTGAAACGATCACCTTTCCCCTTCCCTACCTG CTGTGGAAAAATTGTCTTCCGTGAGACTGGTCCCTGGTGCCAAAAAGGTTAGGAACCACT GCTTTATCAGATCTTCAGAGGGGACAGGGAATCAAATTCGTATAAGAATCACAGTTCTTT ATGATGTATATGCTATTTTTTGCTGCTAATCTCCAGATTTTGTGGATATAAAATATATTG TCATCTGATTTTATTTTTTTCCAATAAAATGTGATTTCAGTGATCTTTATTTTTTCTATC TTTAAGTAATATATCCCTATACTACTATCTCATCACTTGTTTAATTTTTGCTAATAAGAA TTTGTCAGTTTTACTCTTTTTTTCCCCCCAAGGGAGAGGCAGCTGTTGGGCAGATTCCTT TTTTTTTTAAAAAAAAAAATGTTTTTGAGGTATAGTTTATGTCCAATAAAACGCACACAT TTAAAAGCATACCTTGATAGGCTGTGGTAAATGTACACGCCTTTGTGGCCAGACCATTTT CATCACCCCAGGAAGTTCCTCTTGGCTTTACAGTCATTGCTCATGTCCTAGGTAATCACT GATCTTATTTCTACCACTATAGATTTATGTTGTCTCTTCTAGAACTTTGTATAAATGGAT ACATGCAGTCTATTTTTTGTGTCTGGCTTTTGCTCAGTATAATGTGTTGAGATTAGTTCT TGTTGCATATATCAGTAATTTTATTGCTGAGTAGTATTTTGTATGATAATACTACAACTT GTAAATCCATTCACCTTGGGTGGACATTGGGATTGTATCAAGTCTTGGGCTATTAGGAAT ACAACTGCTGTGAATATTCTTGTACAAGTCATTTTGTGGACATTTTTTCCCTTTTGGGTA AATACCAGATACATTTGCTGAGTCGTAGGGTAAATGTGTAACTGTATAAGACACTGTCAA ACCATTTTCCATAGTAGCTGTAGCATTTTACACAGCCATCGGTACTACTTAGGAGATTCC AGTTGCTCCACATCCTCGCTAGATATTGTCAGTCTTTTAAGTTTTTTTCTTTTTAGTTAC ATTGAATGTATAATGGTAGCTCATGGTGGTTTTACTTTCCATTTCCCTCATGTACATGTC TTAATTCATTGTACATCTTTAGTGTGTTTATTGGTTATTTTTATATCTTTTGTGAAGAGT ATCTTTTGGCCACTTAAAATGCCAGGTCATTTGAGTTGTAACACTTTATATATTTTGTCA GATGTAAGTATAATTAATATTTTTTTTAGACTTCAGGGAAACTTTAGTTTTCAAAGCAAT CTAGTTCAAAAATGAGTGGAGGTTAACAGAGAGGAAAATATGAAACCAGAGAGAATCAAA CAGACAGAATAAGGGGGGACTGGCAGTTGGTCAGGGGCGTCTGTGACAGATCTTCTCTCT CTTGGAAATGAGGTCCTCACGGATTCTGGTCAGTTCATCATTTTCTTCACGTCCACGGTT CTGCTTCTTCCTCAGGCTCTCCTCGAAGGCCAAGACCCCTGTGGCTCCAACTTGAGTGAA TATTTTCTTTAGGTTTCTGGTTTACCTTTTTATTTTCTGAAGCATCTTTTTAAAAAAGGC TTTAGTGTGATTGTCTATTCTATCGATTTTTCTCCTTTTTTGCTTAATGCTTATTTTCTG TCCAAGACGTATTTTGCCTACCATGGCCACAAAAATTTTTGCCAGTGTTTTTTCCTAGAA GTTTTATAGTTTTAGTTTTCACATTTAGGTCTATAATTCATGTAGAATTAATTTCTCTGT GTATGATGTAAGATAGAGATTTAGAGTCTTCCCCACCCCAAATGCAGATAGCCTGTTGTT TCAACACCATTTGTTGAAAAGAGTATTCTTATTCCTTTGAATTACCTTGGATTTTACCCC CTCCCCCCAAAAAAATCAGTGAATATATCCAATGCGTGTGTATTTTTTGACTCCGTTGTG TTCCACTGACCTCTTATGTCTGTCTTTACTCCAGTACTGCATTGTCTTCCCTTACTATAT TATAGTGAGTCTTGGAAAGTGCTAAGAGACACTTTGTTGAGGAAAGCCTGTTCTTTTCTC TGGAATTTGTAATTTGTGGTAAGCAGATATATAAGATTTTTGAAAAATAATTTTCTGTGA ATATTTTTAAGTTCTCAATCTGACTGTGAGTGAGGTGCATTAAAGATGTTATTTGAAGTG AACATGAAAAGGAAAAACTTGGTTGTTATTGACTGGAACTCTGGATTCGTATATTCAGAA TGGTTGGTGAAGCAGTGTAGCTAGTTGCATCTGTGGATTCCTCTTGGTTGTAGTTTGTAC TGCAAAATATTGCTTCCTAATGATTTTTTTTTTTGCTGGTAAAAACCATAAAAGTATATT CACATTGTTGTGAAACAGATTGCCGAAACTGTTTCATCTTGCAAAACTGAACCTCTGTGG CCATTAAACAACAGTTCCCCTTCTCCCAGCCCTGGTAACCACCATTCTACTTTTTGTTCC TGTGAACTTGACATCATGTAAGTGGAATCATAAAGTATTACCTTTTTCCTTTTTATGACT GGCTTATTTCATTGACGTAGTATGTAACAGGATTTCCTTTTTTAAAAGCTAATTGATATT CCATTGTGTGTCTATTCCACCCCCCCTCTCCCATTTTGTTTATCAGTTCATCTCTGGGTG GATATTTGTGTTGTTTCCACTTCTTGGCTCTTGTGAATAATGCTGCTATGAACATGGGTG TGCAGATGTCTCTTGGAGTCTGTGCTTTCAATTTTTTGGGATATATATTCAGAAGTAGGA TTGCTGGATCATATGATAGTTTAAACAGCAATTTCCTTTGGTTGCAGTTTTGATACTGAG AGTAGTACAGTTGACCCTTGAACAATGCAGGGTCAAAATGCAAGGCACCAACCCCTGTGC AGTTGAAAATCTGGTTATAACTTTTGACTTTGTCAAAACTGCTAAGTATAGCCTACTGTT GACTGGTAGCCTTAACAGTAACATAAACAGTTAACATATATTTGTATGTTATATGTATTA TATACTGTATTCTTACAATAAAGTAAGCTAGAGAAAAGAAAATATTACTAAGAAAATCAT AAGGGAGAAAAATTACATTTTACTGTACTGTATGGTGTTTATCAATAACATTAGTTTACG TTGTCTGTTTATAAGATATGTCATCTGTTAATAAAATATGTCATCTGTTAGAAATTGTAG GCAACCACAGCTGCAGATTTCAGTCCGTGGTACATATCAAGCAATTCAACTTTTTTATTT TTATTTTTATTTTTATTTTTTTGCATTTTAAAATTAAAGACAGGATCTTGCTGTGTTGCC CAGATTGGATTCAAGCTCCTGGGCTCAAGTGATCCTCCGGCCTCAGCCTCCTGAGTAGCT GGGATCATAGGCATGCACCACTGCTTCTGGCAGTTTTTTTCTTGTGATGTCATGCCTTCT CTCTGCTTCTTGGGAGCACTTTCAGCATCACTAGGGGCACTTTGTATAGGACTCATGGTG TTATTTAAAGTTTATGGTATTGCAGTAATCATGATGAAAAATAATGTGAAAACCGTGAGA GATCACTTTTTACTGCAATACGCAATTTGTTGGAGACATGAACTGCTCAGCAGAGATGAT TAGCATCACATGGTGTTTTACACAAGGTGTTTTAAGCAGATACTTGTAACATTTGAGTAC ACTGAGATAACAGGAAGTGGCTATGAAGTTAACACTAGTACACTACTGTAGTTAATTTTA TGCAGTTATGAATTAATACTCCATCTTTGTTTACATTTCTCTCTAACTTCATATAATAGA TTTGTATGTTTTATGATAGTAAGTGATAAAATAACCTCATATCTAGGTATGTTTTATGCA TTCATGACATACCTAACTTTTTCTTAATGTTTTCGTTATTTCTAGGCTATGCAGTTGTTC TGTGAGTTTTTTCAAATTGTCAAGTCTGCAAAAATTTTTCCAGTATATTTATTGAAAAAA ATATGCATATAAGTGGGACCTGCACAGTTCAGAGCCATGTTGTTCAAGGGTCAGCAGTAG TCATTTTCATGATTAGATGTAGAGTGAGCATGCAGCAAGTTGTGAATATGAATACAATTG AAACAGATACCACTCTTGAAAGGAGCACCTCTTTTTATGTTTGTTTCTTTTGCAGATTGG GAAAATGAGGTACGTTAGTGTTCGCGATTTTAAAGGCAAAGTGCTAATTGATATTAGAGA ATATTGGATGGATCCTGAAGGTGAAATGAAACCAGGAAGAAAAGGTGAGGTCTAATTACT TGAATTTTATTACAGTGTTAGGACTAAACGACAACTTTTCTGAGTAGCTTACTTGAAATG TTGGCAGGACACACGGGGCAAGGAAGAGTCTTACTCAATTGATTCTCTATCTTCTGTAGT TATTTTGGACATGATACTTAACATTTTTTTAATGAGATGTCTTAATACAGCTTTTGGGAA TAAAACCCAGAAAAGTAACACCCCTAATATCACTTCAGTTGGCTGCTAATTTACTTGAAC AATTTTTAAAAAGGTTTATGCAATTCTGAAGCAGATTAGGCACTATCTGGGAACTTGTAA AATCAGGAATGGAAAATCTTGGTTTACAATGCTTCCTTTTGATTCAGCTCCTAAAAGCTA TTCTTTAGGGCATTACTCTTCAAGCGGATCTCTGCTTTCCTTCCATTTGTGCTTCATCCA GTCCCAAGCCTCTTAGCATTGTAGAAACATATTTTGTATAATTCACCAAACAGCTAGAGA AGGTGAGCCAACCTAAATTTGTATATTTGGATTGCTGCTCTAGGTTGACCCTCAGCTAAA GAAAAATGCTTCCTTATTTAGTTTTATTCTGCCTGCCTGTTAGTTTGAAAGGTACCACTT GTTTGCTTCATGCAGTTTTTTTTTTTTTGGTTAAACTCAGCCTCTATATGTGTTTATATG CTTTCATATTTTCTTCAAGTCACTTCTGGATTGGTAATTCACGTACCAGAGTGGCCGATG CCATATTTCTTGTTTATTCTTTTTTTTCAATTTCATGGCCTTCCAGCAGTTTTCTGGGAA TACTTTCTGCCAGTTCTTGTTTACTTCTCTGTTTATATGCGTCGGTATTGGAATGCTAGA ACGTTAAAGTACAAAATATAGAAAATATAAAATTTCTGTTCATACTTTTACATCTTAAAC TGGAAAGACATATCTCACATTTTTTAACCATTTATGTGTTAGGTGATATGCTAAGTTCAT TATTCATGTTACTTAATCATTTACAACAACTCTTTGGCGTATAGATGCCATTTTACTGGT GAGGAAACTAAGGCTTACAAGGTGATGTAGTTCTTTTTTAAGGGTCATACACTTAGTGAA AGTGAGGCTGGAATTTTAACCCTGATAGGGTGACCCTAGAGTGCAGTTACCCGGGTATAC TCTCTGAGGAGTCCTGTATGAATCACGTCCTGGGAATTTTTCCAAAGTGAAATGAATGCT TCTGGAAGAACTCAGCACAATTGGCTTGAATTCCTGTGGAAATTTTGGGCAAATATTGGA ACCAGCTGGAAATATAGTAATGGGGTATCACATGCCAAATCTGGACCTGACCATTTTAGC CTGATAGTTGACGGGTATTAGTAAGATGTGTCTTCAAACCCTTATTTATTCTCATTGGTT ACAATAGGTACTATGCAGGATGCACTGTGGAAAGTAAGACTGGATATGAGATTGATAATG CTCAGTAAATTGTGATGATATGTAATTAACAAATGTAAGAGATATGATTTTCAGTATTGT AGCATTGTGTCCAAGTGGCAATTTTTTTTTTTTTTTTAGATGGAGTCTTGCTCTCTTGCC CAGGCTGGAGTGCAGTGGCATGATCTTGGCTCACTGTAACTTCCACCTCCCAGGTTCGAG CAATTCTCCTGTCTCAGCCTCTTGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCCG GCTAATTTTTGTATTTTTAGTAGAGATGGGGTTTCACCATGTTGGGCCAGGCTGGTCTTG AACTCCTGACCTCAAGTGATCCACCCGCCTTGGCCTCCCAAAGTGCTGGGATTACAGGTG TGAGCCACCGCGCCCAGCCTAAAGTGGCAATTTTGATAAAACAGTATTCTAGTTGGAAGT ATGAAAATCCTCAACGCTTAAATAGATTTTCACCTTTGAATTTTTAAACTTTGTTTTAGG TATTTCTTTAAATCCAGAACAATGGAGCCAGCTGAAGGAACAGATTTCTGACATTGATGA TGCAGTAAGAAAACTGTAAAATTCGAGCCATATAAATAAAACCTGTACTGTTCTAGTTGT TTTAATCTGTCTTTTTACATTGGCTTTTGTTTTCTAAATGTTCTCCAAGCTATTGTATGT TTGGATTGCAGAAGAATTTGTAAGATGAATACTTTTTTTTAATGTGCATTATTAAAAATA TTGAGTGAAGCTAATTGTCAACTTTATTAAGGATTACTTTGTCTGCCCACCACCTAGTGT AAAATAAAATCAAGTAATACAATCTTAACTGTTGTGGCCTTTTTTGATCATAAGAGTTGG TACTGTTTAAGGCCAAAAGTAACAGTTTTTATAGATCTTTTAGTTTCAACTCAGCTTTTA CAATAAAAAGGATTTGTATTGCATTGAGTTTATAAACTTTTGGTTTGTGAACTTCATATT TGATCTTTTCTCTTCCAATCAAATGTCTAGGCTTGTTTGACTTCCACCCCCAATGGTTTT TCACTCTTTTTATTTACTTCATTTTCCTTTAATAACTTAATCTCTTCATGTTCAGTTTTT ACTTCACTCTTTATTCTTTTCTTTGATTATGGTATGCTTATTTGGAAAGTCAGTGAAACT GTCAAAATGTTATCTCAATAAGATACTTATATGAGAACTACAATCACCGAATCTACTGTA TTCAATATTAGCAGATCTAATTTGATAAACAACATGGCTTGTGTGAAAACTGAGCAGGTG TTTGTTTACCCATAGTGTTCTGTGTAGTTATTGCTTAGTCTGCAGAAAATAATGACTTAG ATGAGATGTCTGACTTGCTTTCACTTATTAAACATGTTCACCATGGGATGATGTCTGTAA CATCAGATATTGTTCAACTAGACTAGGATTTAATAAAAATTGTGAAAGCTTACTGGCCTA ACATTTTATTTTATAATATTGGGTATGAATTATATGTAGCCAGAGATGTCATTAAGCTTT ACTGTTATAGTAGGTAATATGGTTAGTTTGTAGGGAAAAGAGCATATGAGCACATGCTTG TGTATTTTGGCCTTTGCCCCAGTAGAACAGACCAATGGCATTCTAGACTTGATGATACTA AGTTTTAGCAGACACTAGTAAGTGGTTTGTATTTAACCATACTGATGAAGCAGACAGATT GAGGCACAGATTTTAGTGGCTTTGTGGCAATAAATAGGGCATGGTGTGCCTTAGGAAAAG AATGTTTATAAAGGGAATTATAACTGAAATTAAAGGAGGCGGCAGTGAAGAGGAAATAAT TCTCTTCTATCTAAATGATATACATATGATATTTTGAGATTTTTATAACAGCAGTGGAAC ACAATTCTAGGTAGAGTAGAAAAAGGAAAGTTTTAAAGACATATAAAAGATTCTTGTTGA CAAATTATTTTTGGTAGCAAATCTCAAATGGTTACCTGCTATTAAGGTCTGCCATATTAG AGTTTTGCACTATTTTGCTACCAAGTTTGATTCATACATCTAAAACATTTTG wise-2.4.1/test_data/rpo_human.pep0000644000175000001440000000043210670452661016525 0ustar philippusers>P15_HUMAN P53999 CAA56200.1 AAA20980.1 AAH10537.1 AAH18189.1 AAH22339.1 Desc: Activated RNA polymerase II transcriptional coactivator p15 (PC4) (p14). MPKSKELVSSSSSGSDSDSEVDKKLKRKKQVAPEKPVKKQKTGETSRALSSSKQSSSSRDD NMFQIGKMRYVSVRDFKGKVLIDIREYWMDPEGEMKPGRKGISLNPEQWSQLKEQISDID DAVRKL wise-2.4.1/test_data/fugu_human.pep0000644000175000001440000000125307644554022016676 0ustar philippusers>ENST00000265604 ENSG00000112319 MEDSQDLNEQSVKKTCTESDVSQSQNSRSMEMQDLASPHTLVGGGDTPGSSKLEKSNLSS TSVTTNGTGGENMTVLNTADWLLSCNTPSSATMSLLAVKTEPLNSSETTATTGDGALDTF TGSVITSSGYSPRSAHQYSPQLYPSKPYPHILSTPAAQTMSAYAGQTQYSGMQQPAVYTA YSQTGQPYSLPTYDLGVMLPAIKTESGLSQTQSPLQSGCLSYSPGFSTPQPGQTPYSYQM PGSSFAPSSTIYANNSVSNSTNFSGSQQDYPSYTAFGQNQYAQYYSASTYGAYMTSNNTA DGTPSSTSTYQLQESLPGLTNQPGEFDTMQSPSTPIKDLDERTCRSSGSKSRGRGRKNNP SPPPDSDLERVFVWDLDETIIVFHSLLTGSYAQKYGKDPPMAVTLGLRMEEMIFNLADTH LFFNDLEECDQVHIDDVSSDDNGQDLSTYSFATDGFHAAASSANLCLPTGVRGGVDWMRK LAFRYRRVKELYNTYKNNVGGLLGPAKRDAWLQLRAEIEGLTDSWLTNALKSLSIISTRS NCINVLVTTTQLIPALAKVLLYSLGGAFPIENIYSATKIGKESCFERIMQRFGRKVVYVV IGDGVEEEQAAKKHNMPFWRISSHSDLLALHQALELEYL wise-2.4.1/test_data/rua1.pep0000644000175000001440000000072607523540465015416 0ustar philippusers>RU1A_HUMAN P09012 AAA61245.1 AAA61245.1 AAA61245.1 AAA61245.1 AAA61245.1 AAA61245.1 CAA29653.1 AAH00405.1 AAH08290.1 Desc: U1 small nuclear ribonucleoprotein A (U1 snRNP A protein). MAVPETRPNHTIYINNLNEKIKKDELKKSLYAIFSQFGQILDILVSRSLKMRGQAFVIFK EVSSATNALRSMQGFPFYDKPMRIQYAKTDSDIIAKMKGTFVERDRKREKRKPKSQETPA TKKAVQGGGATPVVGAVQGPVPGMPPMTQAPRIMHHMPGQPPYMPPPGMIPPPGLAPGQI PPGAMPPQQLMPGQMPPAQPLSENPPNHILFLTNLPEETNELMLSMLFNQFPGFKEVRLV PGRHDIAFVEFDNEVQAGAARDALQGFKITQNNAMKISFAKK wise-2.4.1/test_data/README0000644000175000001440000000673107313404500014704 0ustar philippusers Here are some examples that you might want to try out. The executables of course should be installed before hand somewhere in your path. Or you can call them as ../bin/genewise etc if you haven't installed them. If you get warnings like Warning Error Could not open codon.table then you haven't set the WISECONFIGDIR enviroment variable. You can set it now by going setenv WISECONFIGDIR ../wisecfg Print out the wise2 documentation (docs/wise2.ps) and read the 'Introduction for the impatient user' Here are some examples: a) Comparing a protein sequence to a genomic clone genewise road.pep hngen.fa (the protein is from drosophila) b) Comparing a protein HMM to a genomic clone genewise -hmmer rrm.HMM hngen.fa c) Try the following options on either a) or b) -kbyte XXXX where XXXX is the maximum amount of memory on your machine -genes - gives gene prediction output -trans - gives translations of the predicted genes -embl - give EMBL format Feature table output do genewise -help and have a look at other formats you could make d) try genewise -hmmer rrm.HMM hngen.fa -alg 2193L for the most complicated algorithm genewise has to offer. For comparisons using ESTs a) protein to est estwise road.pep hn_est.fa Notice the frameshift with the ! in the translation b) profile HMM to est estwise -hmmer rrm.HMM hn_est.fa For database comparisons a) an dna sequence against a database of profile HMMs estwisedb -pfam db.hmm vav.dna or genewisedb -pfam db.hmm vav.dna ---------------------------------------------------------------- Using dba. dba (Dna Block aligner) compares two DNA sequences trying to find co-linear blocks of homology with the potential of a small number of gaps but with large intervening sequences between the blocks of variable length. The idea is to be able to find regulatory regions in non coding sequences from different species. For example, using the first intron from keratin18 genes from mouse and human gives the following output: adnah:[/wise2/example]<53>: ../bin/dba keratin_intron.human keratin_intron.mouse score = 72.52 56 140 109 192 69% 3 gaps, MATCH_A 321 395 358 431 89% 1 gaps, MATCH_C 401 496 467 559 70% 3 gaps, MATCH_A 560 579 593 613 95% 1 gaps, MATCH_D 622 691 646 712 80% 5 gaps, MATCH_B This indicates that there are 5 blocks of homology. The blocks are parameterised into homology levels being (when run using the default parameters) A approx 60-70% identity B approx 70-80% identity C approx 80-90% identity D approx 90-100% identity The approximation is due to the fact that the models are parameterised probabilistically with gaps being taken into account. The probabilites for the different blocks are by default A 0.65 B 0.75 C 0.85 D 0.95 (each probability representing the probability of finding a idenity pair in the block). By and large blocks around the identity range will fall into the correct homology block, but the interplay of the parameters about block probability means that the calculated %idenity need not fall into the expected block type. The -align option is very verbose and probably not that useful. dba has been intergrated into the alfresco java viewer. In alfresco you can interactively decide what regions to compare and shows the results integrated with other analysis, eg repeats. Alfresco (and dba) was written by Niclas Jareborg. A web site for it is at http://www.sanger.ac.uk/Software/Alfresco wise-2.4.1/test_data/Q8NAN2.dna0000644000175000001440000031145607646472464015451 0ustar philippusers>1.77640312-77741812 CGCCTCCTGGGTTCAAGCGATTCTCTTCCCTCAGACTCCCGAGTAGCTGGGATTACAGGC ACCTGTCACCATGCCCGGCTAATTTCTGTATTTTTAGTAGAGATGGGGTTTCACCATATT GGCCAGGCTGGTCTCAAACTCCTGACCTCAGGTGATCCGTCTACCTCGGCCTCCTAAAGT GTTGGGATTACAGGCGTAAACCAACATGCCTGGCCTTTTTTTTTTTTTTTAGAGACCCAG GCTGGAGTGCAGTGGTGGAATCACAGCTCACCGCAGCCTCTAACTTCTGGGCTCAAGCGA TCCTCCTGCCACAGCTTCTCTGAGTAGCTGGGACTACAGGCATGCAACAACACACCTGGC TAATTTTTTAGTTTTTGTAGAAATGGGGTCTTATTATGTTGCCTGGGTTGGTCTCAAACT CCTGGGCTTAAGCATCCTCCCACTTCGGCCTCCCAGAGAGTAGGGATTATAGGCATGAGC CATTGTGCCCAGCCTCTTTTTGTACAGCATTGTAAAGATTTTGGTTTTTACTCTAACATG GGTGGTCTCTGGTAGGTTTTGAACAACATAGTGACATGATCTGACATGTTTACTCTCTCT AGCTTAAGTGCTGCACATACACCAAATGAGGCAAGAGAAGAAGCAGGGAGATCAATTAAT TAGGAGGCTTCCACAATAATCGGAATGAGGAATGGGGATTTGGGCCAAAGTGATAGTTGT GAAGGTAGTGAGAAATACCTGGCATATTTTTTTTTCCTTGTTGCCTTTTTAGGTAGAAAT GGTAGGATTTTTTTTTTTTTTTTTTTTGTAACTGAATGTGAGGTGTGAGGAAAGGAGGTT TTGGGCCTTTGATCTGGAAGAATGGAGTTGTAATTTACTCAGATAGGGAAGGTTGTGGGA AGAGGAGGTTTAGGCAGGGGTGGTAAGGAGCTCAGTTTTGACATGCTAAGTTTGAGATTA CTAAAAATCCAAGATCTGCCCATTTGTATAAGCATTACTTGTATACTTATCACGAGTGAT TAGGTTTGTTCTATGTCAGTTGCACGGTTTTGAAATTATACAAAGTAAACATTTAAAAAA TGAAATTATAGGCCAGACATGGTGGCTCACACCTGTAAGCCCAGTGCTGTGGGAGGCCAA GGTAGGCAGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCATGATGGCGAAACCC CGTCTACTAAAAATACAAAAATTAGCCGGGCATGGTGGTACGTGCCTGTAATCCCAGCTA CTCAGGAGGCTGAGGCAGGAGAATCGCTTGAACCCAGGAGGCGGAGGCTGCAGTGAGCCC AGATCGTGCCAAAAAAAAAAATAAAGAAAGAAATTATAAAAGCAAAAATAAAGTTATAGT TTTTTATAAAAGCTGAGTTGAATGCTTTGAAAAGACTTGATAAAGGCAAATAGCTTACAA AAATTACCACCAAGCTAGGTGTGGAGAAGACAAATGTAAAAGATTGGGTACAAAATTGTA CAAATCTAGGGAGATTCTGCAGTCAGTGCTTTTTAATGTACCTTTTCTCTCCTTTAAAAG TAAGGAAAACTCGAAATTCCAGATGATGATTTAGGGCAGGGGCCCCCAAACCCCAGGCTG CACAGCAGGAGGTGAGGACTGGCGAGTGAGCATTACCACCTGAGCTCTGCCTCCTGTCAG ATCAACGATGGCATTAGATTCTCATAGGAGCGCAAACCCTATTATGAACTGTGCATGTAA GGGATCTAGGTTGTGCACTCCTTAGGAGAATCTAATCCCTGATGATCTGTGATGGACCAG TTTCATCCCAAAACTATCCACCACAGCCACCCCCGAACCGTCCATGGAAAAATTGTCTTC CCCAAAACTGGCCCCTGGTGCCAAAAAGGTTGGAGACCACTGATTTAGCGGTTTAGTTTA TGTAACAAAGATATCTTGAAATATCGAGTGAATCCATACTCCCAACTAAAGGCCTTGATA CTATATCAAAAGATTGGCCAAAGAAAGTACATTCATTCATTTAACATTAAAATGTCAACC AGGCATGGTAGCTCAAGCCTGTAATCCCAGAACTTTGGGAGGCTGAGGTGGGAGGATCAC TTGAGGACAGGAGTTCAAGACCAGCCTGGGAAACATACCAAGACTTCCTCTCTACTAAAC AATAAAAATAATCCAGGTGTGGTGGCATGTGGCTGTAGCCCCAGCTACTCAGGAGGCTGA GGCAGAAGAATCACTTGAGCCCAGGAGTTAGAAGTTGCAGTGAGAACCACTGCACTCCAG CCTGGGTAAGGGAGAGAGAAAAACCTTATCTCCTAAAAAAAAAAAAAAAAAAAAAAAAAG TAATTTGTCTACATCATTATGTATAATTTATTATGATTCCCTGCCATGGTATCCAGCCAC CAAGACAACCCCAAATGTTCCACCTCTTGGTACTCGCATCCTGTGTAATCCCCTCCCACA TTGTGTCAGTGTTGGTCTGTGTTACCAATGGCAGAAGTGGCAACACTTCCACATCTAGGT TATAAAAGACATTGTGTCTTTTACCTTGCTATTTCTTGGATTATTTATCTGGGAGGAAGC CAGCTGCCACGTCTTTTTTTTTTTTTTTTTCTGTAGAGACAGGGTCTCATTTTGTGGCCA GGCTGGTTTCACACTTACAGGCTCAAACAAACATTCCTCCTGCCTCAGCCTCCCAAAGCG CTGGGATTACAGGCATGAGCCACCATGCTCATGCCTTAAAAGACATGCTGGCCAGCTGTC ATGTCTTAAAAGACACTCAGGCAGCTGAGAGGTCTAGTTGGTAGGAACTAAGGTCTCTTG CCAATGGCAAGGGACTGAGGCCTCCTGAAAACAGACATGTGAATGAGAAAACCTTAGAAG TGAGTCTTCCAGCCCCAATCAGGCCTTCAGATGACTGCAACTTCAGGAGAGAACCACCAG ACTAAGCCATTCCTGAATTCCCAGCCCTCAGAAACTGTGTAAGATCATGTTTGTTGTTTC GAGCTGCTAAAATTTTAGGATAATTTGTTGTATTGTAACAGATTGTGAATATAATTGCTT TAACATTTATTATCCATCTTCATCTTCTACCACATTATTTTATTGGTCCTTTGTAAAACT CCTGGGGCCATTCTTTTTCTTTCTTTTTTTTTTTAAAGATGGATTCTCGCTCTGTTGCCC AGGCTGGAGTGCAATGGCGTGATCTCAGCTCACTGCAACCTCTGCCTCCCAGGTTCAAGC AATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGACTACAGGCACGCAATGCCACGCCCGG CTCATTTTTTGTATTTTAGTGGAGGTGGGGTTTCACTGTGTTGCCCAGGCTGGTCGCGAA CTTCTGAGCTCAGGCAATCCACCCGCCTCAGCCTCCCAAAGTGCTGGGATTACACGCCGT GAGCCACCGCACCTGGCCCCTGGGACCATTCTCACACAGAGTTATTATTAAATAAGAATT AGCAAAGTTCAGAAAGTCATATATTTCAAGTGCTTTCTAATTCAAAGTGCTTCTCTATAT TCAAGTACTATGGTATCATTTCAAACATAGCAAATTATAAAAGTTCTGTAATTTCCTAAA TATAAATGTACTTTGTGAAAGGCTTCTGTGACACACATAAAAGACATATTTGATGTACCA GTTGCTTTGCTGTGGCTTTTAAGTAAAGAATAAAAAGTGTCATAGAAGGAAGGCTGTTTT TCTTCTCTGTAGTAGAATACAGTCCTTCCCTGCCCAGATGATGGTTACTGTAGAGTTTTC ACTGTTCAGATATAGAAAAAGCCAAAGAAAGAACCTTAGCAGACAGAAGAGTTTGTGTAG CCTGATCAAAGATGTCAGTAGCGTAAGAAGAGAAAGAGATCAAGGGAGAAGAAGTGGCAG GATAAAGTATCAGAGAATACAGGGCATAGGAAGAAACACTGCAGAAAAAACCAGAAGTCA AAAGCAGCATAAGAACAGTTAGTTTAGAAAGATTAACAAAGTGATTTATAAAGATTTCCA GCAAAGCCCTATAAAGTCTAACAATAGGGCACTAAGATGTTTGCAGAGAAGCATTTTAAA TATACATAAGAATTCAGAGACAGATGTTTAAAGTGCAAAACATTAAGTTCAGATCCTGAA CATTAAGTTCAGGATCAAAGAAGATGCATGAGACAACAGAGTATGGCAGATAATGACAAA ACAGAAAATGAGAATGAGATGCTGCTCTAGTTTCCCATTGCACTCCAACCCTGTATCCTA GCTAAGGAAAGATTCTATTCATGTTTATATGGTTTTCTTATCAATATATTTCACTTTATA TGTTTAATAATTCTAAAAATATAACTATATTTATCTATATCATATATAATTATTCTAAAA TAAACCCATTTGTTAAAAGTCTCAAACTAAGAATCTGTTTTCATATCCAGGTGACTTCCA TCTGGTGACTATGGTGGTATCCAGGTGGCACCCCTCTCCTTGACTAAATATATCTGAACC CTTTTGTTTTTTGGTTTTGAGACTGAGTCTCACTCTGTTGCCCAGGCTGGAGTGCAGTGG CGTGATCTCAGCTCACTACAACCTCCACCTCCTGGGTTCAAGCAATTCTCCTGCCTCAGC CTTCCAAGAACCTGGGATTACAGGTGTGCGCCACCATGCCTGGCTAATTTTTGTATTTTT AATAGGGACAGGGTTTCGCCATGTTGGCCAGGCTGGTCTCAAACTCCTGACCTCAAGTGA TCTGCCTTGCTCGGCCTCCCAACATGCTGGGATTACAGGCATGAGCCACTGCACCCGGCC ATATATCTGAAGCCTTTTGAAGAATTGATGAGAAGAGAGGTTCAGGTCATATATGAATAG TAATGATGCATATACATCAATATATCAATATAAGTTTATATTATGCTTGATGGCATTATC ATCCAAACACTTAAATTAAAATACAAGTATTTTCACTTTATTCATCACAAAACTGTCTTT TTCCCCATATCAGTACATGGAGAAACAATAAATTTTTAATCTTTGTTTTCATTTTTTATT TTTTTGAGACAGAGTTTCGCTCTTGTTGCCCAGGCTGGAGTGCAATGGTGCACTCTTGGC TCACTGCGACCTCTGCCTCCCAGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCAAGTAGC TGGGATTACAGGTGCCCACCACCATGCCCAGATAATTTTTGTATTTTTAGTAGAGACGGG GTTTCACCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGATGATCCACCCGCCTC GGCCTCCTAAAGTGCTGGGATTACAGGCATGAGCCACCGCACCCGGCCTTTTATTTTTTA TTTTAATGATAAAGTTTTATATTTGATTATAATGCTTCTGCAGTTGTCCTGTTCTCTATG CCATATATATGGGTCTTATGGAGACTGAATATTCTCATACAGGATCTGATGAGACAAGTG TGACTTCATAATTATATATTAACATTGTTTAAAATATTCAATACATCAGCAAGACGTACC ATCACTTTTTTATTTGGCAGTAATAGTAATACATCCATGTTACAGTGCTTATTTTGGCTA AAGAGCCAGTGCAATTTTTTCTGCTACTGTAGTGTTTTACTTTTACACAAATTAATGAGT ACAGTCCTTACATTTAGGAGACAGAAACATTTACTGACATCAGCTAAGTAAAGCTAATAC ATGGTTGTTCACAAACTAAACAAAACAATAACATAATATACTCATTAGGAACAAAGTAGG GATGTTCTTATTTCCACTAATCACAGATTATATAAATTCTTAAATTTCACATACATATTT CTAAATCTAAGCAAAAAAATTAGAATTCAGCTTAATTCCTATAATCATTTTGAAATTTAC ATCAAATAATTTCTGAATATATATTCACATTAAAATAAAAGTAAATGGGTTATATAAACA TAATTTAAAATTTCTGATTATGAAAAGTTATAGAGAAGTACATTAAATGTTACTTTGGCA TTCCTATTTCCTAGGCTTACAGGAATTATTAAGAATTCCTTTGTAATGCAAATAATCACT CTCTTGGAAATTAAATTTAAGTAGAAAATGTTACATTTTAAGGCAAGAAAACATTTGTAA ATATTTTTATAAAGGCATTTAATTCAACAAATTAACGGAATCATAGTAAATGGATGCAAA TAAAGAATATTACTTTATGAGAAAGACAAAGTTCTTTGGAGCTTACTGTGACAGTATGGA AAACTTGTCTTCTTTTTTAAAAGATAATTCCATTTTGATACTTAATAAACATAATGTTAA CCTTCAAGAAGAAATAAGCACTCTTAGTTGAACAAAAATGTAGGGAAATTAAAATACAAA AAATGAAATTAAAAGAAATACCAAATGTAAATTGCCTCAAAATTTATCTTCTTTCTTCTA GAAAAAAGGATATTTTCTCAGGAGTGACTTAATTGAAGTCCCTCTTATAATTTACATATG GAAGTGGATGGTAGAGCTCATGGTGGCAAGGGCAATTCCATGATTAAGTGTTTAAACAGG GTTTACCCTAAAAGGCTCTAAACTAATCATTTTTAAAGACATTGCTTTTGCTATTTAACC CAATTTTAAGGCAAATGGAAACCGTTACATATGTCTTTTTTTTTTTTTTTTTTTTTTTTT TTTTTTTGAGACAGAGTTTTACTCTTGTTGCCCAGGCTGGAGTGCAATGGCACGATCTCG GCTAACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCTCGAGTA GCTGGGATTACAGGCATGCGCCACCATGCCTGGCTAATTTTTGTATTTTTAGTAGAGATG GGGTTTCACCATGTTGGTCAGGCTGGTCTCAAACTCCTGACCTCAGGTTATCTGCCCACT TGGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACTGCTCCTGGCCTGTTATATAT GTCTTAAGTACCCTTCTGCATGCAGTCAGAAATGTTCTTTTCAAGAGGACATTTCCTTTA AAAAGTTCAAGTTTCTTATCTTACGATAAAGAGATATTTCCTATACTTATTGTCCTAAAA TTCTATTTGGTCACTCTTACCTCTTTTGTGAAAGGCCACATCTTGCTAAAGTAGCAGCTA CTGAACTGACCAGAAACAAACTCAAACACTGAATTTGACAAACCAACCTGCTGAATATAA GCAACTTTTTCTAAGATGAAATGTAAAAAAGAAAAAGAAAAAACAAAAAGCAACACCTTC TAGAAAGCCATTCATCTTATCTCATAAAATTAATTCCCCAGAGTTATCTCATGTAGTAGC AGCATTATCAAATAGTGCAATTCTTCAAAATTGATTTCAAATAATATCTTTCTAAAATAA ATTACATTTACTTACAGCTTTGCTTATAAAACCACAGCTTAAAACACTTAGCCCTCAAAT GGGTAAATTACTATAAGCAATAACTGTCTTGTCTACATGGTAATGAAATGCACGTGCACG CACACATGTGTGTGTGAAGGCCAAAGATACCGCAACAAGGTAAAAACATGTAATATTAAA TAAAAAGTAAACAGTACATAATGGAATTTTTAGTTTTGGTACTTCTAATCATATTCCCGT CAATAATAAGAACTATAAATAGGTAATTGTTAAATTAAGCATCTATGTAAGAAAAGGCAA GGAGCTATATACTAAAGAACAGTGATAATTTGTATGTTTCATGCTATATAACCTATAAAG TACATGCAAAACAGCATGATCCTGAATTCCATATTTTATAGTTAATTTACATAAATGTGG CACATACAGAAAATTACAAATCTTAAAAGATTATGCTTTTCCCGCCCACTTTTTTCATCT TCTATTTATTAATCAGAAACTAGGCACTTTAATCTAAAAATTCGCTTTTTAAAAATGCAT TTTAGGAGTAAGACATGGTGACACATGCCTCTGGTATGAGGAGTTGGAGACTGCAGTGAG CTATGTATGATAGCACACTGCACTCCAGCCTGGGCAATAGAGCGAGACCCCATCTCTTAA AAGAAGGCAAAAAACAATGCATTTTAGGTCCTTTTGTGCAACTCACTCCTAAAATGACTA AAGCCCGTTTTAGGGGCAAAATCAACAAATCTCATCTACTTACATACTGAGTTAGTCACT CCAAATAAGTGGTATATTATTTAGAAACAAAATTAATACAACTCTGAAAGCATTTAATAT ACTCTTATAGAAGAACTCCACCCATAAAAACAATTCATTTGTTTGTAGATTTATCATAAT GAACATGAAATATATACTTCCACATCATTAAAAAATATTTTTGTTTTACATTCCAGGGAG GAAAAAACTCTTCTTTAAAATGTCAATAAGATTCAAACTATGAATATTTTTAAAACATGG GCATAATATGACAAATTCCCACTGGGCTGAGTTTTCTGTGGGAATAACTAAAAGGAAGGA GAAAGGAGAAATTATTTCACTGTACCAAGTTTCATACCTTCAGATGTTGACAGTCTTCAA ATAACACTAAATTTTAAATTGCCTTTATTAATTAATAAATGTTATCTTTTTAATCAATAC TCATTCCAGGGGAAAATGCTCTAATGTATAAAAAGAAAGTTCTTCAGTCTCTTTGTAACT TACAGGACCAACAGTAACATATTTTGGAAACTACAGTTAATATAAATTTGTAAATTGTAA ATTTCTCAATGTCAATTCATTTAAATGCTGTATTTGTTTTATTTATTCACTTCTGAGATA GGGTCTTGCTGTCGCCCAGGCTGGAGTGCAGTGATGCAATCACAGCTCATGACAGCCTTG ACCTTCTGGACTCAAGTGATCCTCCCACCTCAGCCTCCCAAGTAGCTGGGACCACAGACA CATGCCACCACACCCAACTAATTAATTTAATTTAATTAATTTATTTTTTGAGACAGAGTC TCACTTTGTTGCCCAGGCTGGAGTGCAGTGGTGCGATCTCGGCTCACTGCAGCCTCCACT TCCTGGGTTCAAGCAATACTCCTGTGTCAGCCTCCCGAGTAGCTGGGACTACAGGCGCCC GCCACCACACCTGGCTAATTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATATTGGGG AGGCTGGTCTCGAACACCTGACCTCAGGTGATCCGCCCACCTTGGCCTCCCAAAGTGCTA GGATTACAGGCATGAACCACCACACCCAGCCTATTTTTATTTTTTAAAAAAATTTTAATA TTTCCATGGAACTCTGCTTGATACCAGCTAATTTATTTTTATGTTTTTGTAGAGACAGGC ATCTCCTTATGTTGTCCAGGCTAGTCTCAACCTCCTGGCCTCAAACTGTCCTCCTGCCTC AGCCTCCCAATGTATTACAGGCATGAGCCACTGCAAGTGGCCCATTTAAATGTTCTATAA CAATATTCAGTGATTACAATTTCTTTGATTCAAATACATAAGCAAATGCACAAGCAATAA TGTATGCAGTACATATTAAACATCATTACTGCCTAAACTTGATTAAACAAATGAATAACT TTATAATTAAAAATATGTTTCTAGGCAAAGTTAAATATATTGACATTAGAAGTAATATAT TCTTGCATGTGTGGGCCACAAAGACCTTGGCTAAAGTGTACATTTTAAAGGTGCAAAGCA TAAAAACAGAGCTTTTGAGAATGACAGCTTCAAGAAGACAAACCAATTAACTCCCAAATA TTGGCTTCAATTCAAGCGATATTTCTGTAAAATATACATTTCATGACTTCAATTATTACC TAATGAATGCAAAAAGCCACTATGACTACACTACACAGGAATTCAATGACAGAACTTCTG TATAAATACAGTACAGTTGCTCATTTTTTAGTAGATTTTTTTTTCCTCCCTGAATCCACA TGCATCAATTCTGTTAACTTTGTAATATATGTTACAAAATCAATAGTTACCTTAAAATAT TTCATAGCACACTCAAATTGTATGATTCTTATGGTACTTATTGTACTTTGGCTTCCAGTA GCCCAGTGGACATAACATGACCATGACTGCTTAGACAACTACTTGTATGCCTCAGGGCAT CTGCTTCAAGATAGGCCATTAAAAGCTCAGTGCGGCGAATGAGTAACTGCATGAGGTCTT CAGCTAAAGTCTCTGTACTTGAATAGCGCACCTTCTCAAAGTCAAAAATGTCTTTGAGAA ATAAAAGAACTTGATTCTGGAAAATGAACATAAATTGGCATTTATTAGACCAAAATTAAG TTACATTGAGAAAGCTTCTAATATTATAATGAGCACTGAATCAGGACTCAGAAGACCTGA CTTCCAGTGCTAGTTTCATATCTCATTAGAAAAGGGACCTTGCACAAGTGATTTAACCTT TCCTTTTTGGGGGCTCATTTTCTTTTTCTGTGAAATAGGGCTAATACCACCCACCCTACT TACTACTCAGGGATGACATGATGATCAAAAAAGATAACCTATGTGATACCATGAAAAGGT GGGGAAACATTTAAAAAAAGATAATCTATAAGAAGTGCCTGTAAACTCTAAAGCACTGTT TAAATGTAAGGGGTTATAGTCCTTTCCCTTCAATGTGACCTTTGAGCATTGCCTCTACTC TAAGACAGAAGAATAAACTATTTCCAGTAATAGTTTTAAATAAATAATAATAAAATAATA CGTTATAATTTTAAATGTGCTTTTTTTATTTGTACAAGAAAAACCCTTAAGGCACATGAA AAATAAAGAACATTTCAGGTCTCAAATCAGTGGTAGATCCTGAAGGATATTTCATTTCAG TAAGTTATTATATACACTGAAACTCACTGTAAGCAAACTGTATACGAATAAGTATTAAGT CTCAGCTATTATGTCACCATAATAGAAAAAAAGTAATTTCAAAGAGCGAAAAACAGGAAT ATTTAATTTCTATCTTCTTTCTTAATAACGTATCTTCCAAACGTTATTAAGAAGTACTAA GAAGACACACTTCATTGATTCACTGGATTTTATATCTGAAAGGGTCATTAGCGATCAACC TGTTAGGCTCCCTCGTTTTATAGATAAAAGGAACATCAAAGAATGATTTGCCCCAAGTCA GAATGCTCACTGATGACAGACTTAATTCCCAACCCCTAAAACACATACCTTACATTTGGG TGGTCAAGTAAACTACAAAAATCAACGTGTTCTGAATGACAGTAAAATACACATTTTCTA AACCATTTATAAAAATATTACCTTGACAGCACATAAACATAATTTTAAAAAATGAATGGT ATAGTAAAACATCCAAACTTTCAAATTCATACTCAATTATGTTTACTTTTATTTGCTCCT TGAAATGCAGCCTAAACTCAAGACTATTACATAGCGAGACTTTCCTTGTCACTTTGCCAG CCAGAAAATTCTATAAGGAGCTATAACTTGTATTTTGGCAAACTAAAACTGCTGACATTG GGAGATAACATTAAACCCCCATTTTATTTCTCACAACTTGGATTTTATCATTCATCTCAC CTTTAACCACAACTTATTCTATATTACCACATGTGCAATAAAGGTGGATATTGTTTGTAA GTTTCAAAAGTGCCCAGGTATGAAAAACCAACTATCTACATTGATTTGACTGTCACATGG CAACACCATGCAAGACCATGTATCCCTTGCATTAGGGAATTGATAAGGTGAATGGATATG CTGAGTCTACTCCAGAATAAAGCACCAAATCTATAAAATACTGGTCCATTATAATAATAG TGGTATTATAAAATGCCAAAAATATTTAACACTGACATTTAAATGCTGAATTTAGGTGAC TTTTATAACTTTACTCTTAAATAACATTTGTTCTTCTACAAAAGCAAAACAAAACAGAAT AAAACCGTATCTCCTTTTTGATTTAGAAAAAAAAGAGAAATGATTCAATGACTGAACATA CCTTAAAAAAGCAACATAAATCATACAGAGAATTTCTAGGACCCAAAAAGCCCCAGGCTA GGACAGGACTGATGTGTTCACAAATGGCATAAAAATGGGCAAAAAATCCATCTGGGATCT GCTGGGAAGTAAAGGAGAATCAAGTTACTTCTACCTTCTTGTTACTTGCTTTCTCTAGTA CAGAAACTGAAGTTGCTATTCATTATATGACCAGTGGGAGTTTAAGAAAATTTGTTTTTT AGAACCAGAGTCTAGCAACACCTCAAACTCCTGGCCTCAAGCAATCCCCCGGCTTTAGCA TCCTAAGCAGTGGGGACTACAGGCAGGCACTATAGTGCAGGGCTCATGACTAGCTCTTTT TGAGGGCAAACCAAGAGTCAGTCATGAGCCATGCTATTAAGAAAGTTAATAAGGTTACAA GTAACCTTTAGAGTCATAGAATGTTTTATGTAGATTTCATATCCTAGCCAACAGTTTCAT ATGTGCTGAGACACATTTCTGTATTTGTTGTTTGTTTTTTTGAGACAGGGTCTCACTCTG TAGCCCAGGGTGAAGTGCACTGGTGCAGTCATGGCTCACTGCAGCCTCAACTTCCCAAGC TTGAGTGATCCTCCCACCTCAAAATTCCAGGTAGCTGGAACCACACGTGCACGCCACCCC TCCTGGCTAATTTTTTCTATTTTTAGTAGAAACAGGTCTCACTATGTTGCTCAGGCTGGT CTTGAACTCCTGGGCTCAAGCAATCCTCCCTACTTTGCCTCCCAAAGTGCTGGGATTACA GGCGTGAGCTGCCACACCCCGCCCTTAAAAGTTGTTTTTACCTCATAAAAATGCTTCATA AAAAAGCAATCCAGCCAGGCATGGTGGCTCATGCCTATAATCCCAACACTTTTGGGAGGC CAAGGCAGGTGGATCACTTGACCCTTAGGAGTTCGAGACCAGCCTGGGCAACATGGTGAA ACCTTGTCTCTACAAAAAATACAAAAGTTAGCCAGGCATGGTGGTGTGTACCTATAGTCC TAGCTACTCAGGAGACTGAGGTGGGAGGATCATTTGAGCCCAGGAATTGGATGGTGCAGT GAGCCAAGATAATGCCACTGTACTCCAGCCTGGGTGACAAAGTAAGACTCTGTCTCAAAA AAAAAAGGGCAATCATATTAGCTTTGCAACGAAGCAACAACAAGAATGCTACAGTGTTCC TTAGTTGTATAAGTTTTATGGGATTATTAAGACTATCAAAGTTTTAGCTATTTAAAAGCC CAACTCAATCACTTAATTATATTAACTGACCAAAAAAAAACTAGTAAAATGATTAAGCTA AATTACTCTTACTAGAATCCTAACTTTTAATTAAGGAACCCTATATTATTTAAGCATTTA ATTGTGTAATTGCCTCTTCCTGTGAAGTATTAGTCAATATAGCTGTGTTTTAGGAAACTC TATATTTATAACTTTTTGAATTTCCCTTGTTAAATAACACACTGTGGGATTTGTTATACA GCACTGACTACAGAAAACTACACCTTAAGATTCTGTCTCCTGGGGGGCGGGGGTTATTTT CTATTTTACAGTCTCCAAGACAATCTTCTAAACCTCATTTTCTTTTCTTTTTTTTTTTCT GAGACGGAGTCTCACTCTGTCGCCCAGGCTGGAGTGCAGTGGCACCATCTTGGCTCACTG CAACCTCTGCCTCCCGGGTTCAAGCAATTCTCCTGCCTCAGCCTCCTGAGTAGCTGGGAT TACAAGCGTGCACCACCATGCCCAGCTAATTTTTGAGTTTTTAGTAGAGACGGGGTTTCG CCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCACCCTCTTTGGCCTC CCAAAGTGCTAGGATTACATGCAAGAGCCACTGTGCCGGGCCTAAACCTCATTTTTAAAA TATAAGATAGCAGCAGTTACCATTTAATGAGTACCCATTATATTCTAGAAAATGTGCTGC CCTCTCCCTCTCCCTCTCCCTCTCCCTCTCCCTCTCCCTCTCCCTCTCCCTCTCCCCCTT CCCACGGTCTCCTTCCACGGTCTCCCTCTGATGCCGAGCCAAAGCTGGACGGTACTGCTG CCATCTCGGCTCACTGCAACCTCCCTGCCTGATTCTCCTGCCTCAGCCTGCCGAGTGCCT GCGACTGCAGGCGCGCACCGCCACGCCTGACTGGTTTTCGTGTTTTTTTTGGTGGAGACG GGGTTTTGCTGTGTTGGCCGGGCTGGTCTCCAGCTCCTAACCGCGAGTGATCCGCCGGCC TCGGCCTCCCGAGGTGCCGGGATTGCAGACGGAGTCTCGTTCACTCAGTGCTCAATGGTG CCCAGGCTGGAGTGCAGTGGCGTGATCTCGGCTCGCTACAACCTCCACCTCCCAGCCGCC TGCCTTGGCCCCCCAAAGTGCCGAGATTGCAGCCTCTGCCCAGCCGCCACCCCGTCTGGG AAGTGAGGAGCGTCTCTGCCTGGCCCCCCATCGTCTAGGATATGAGGAGCCTCTCTGCCT GGCTGCCCAGTCTGGAAAGTGAGGAGCGTCTCTGCCCGGCCGCCATCCCATCTAGGAAGC GAGGAGCGCCTCTTCCCCGCCGCCATCCCATCTAGGAAGTGAGGAGCGTCTCTGCCCGGC CGCCCATCGTCTGAGATGTGGGGAGCACCTCTGCCCCGCCGCCCTGTCTGGGATGTGAGG AGCGCCTCTGCTGGGCCGCAACCCTGTCTGGGAGGTGAGGAGCGTCTCTGCCCGGCCGCC CCGTCTGAGAAGTGAGGAAACCCTCTGCCTGGCAACCGCCCCGTCTGAGAAGTGAGGAGC CCCTCCGTCCGGCAGCCACCCCGTCTGGGAAGTGAGGAGCGTCTCCGCCCGGCAGCCACC CCGACCGGGAGGGAGGTGGGGGGGGGGGTCAGCCCCCCGCCCGGCCAGCCGCCCCGTCCG GGAGGTGAGGGGCTCCTCTGCCCGGCCGCCCCTACTGGGAAGTGAGGAGCCCCTCTGCCC GGCCAGTCGCCCCGTCCAGGAGGGAGGTGGGGGGGTCAGCCCCCCGCCCGGCCAGCCGCC CAGTCCGGGAGGTGAGGGGCGCCTCTGCCCGGCCGCCCCTACTGGGAAGTGAGGAGCCCC TCTGCCCGGCCAGTCGCCCCATCCGGGAGGGAGGTGGGGGGGTCAGCCCCCCGCCCGGCC AGCCGCCCCGTCCGGGAGGGAGGTGGGCGGGGTCAGCCCCCCGCCCGGCCAGCCGCCCCG TCCGGGAGGGAGGTGGGGGGATCAGCCCCCCGCCTGGCCAGCCGCCCCGTCCGGGAGGTG AGGGGCGCCTCTGCCCGGCCGCCCCTACTGGGAAGTGAGGAGCCCCTCTGCCCGGCCAGC CGCCCCGTCCGGGAGGCAGGCGGGGGGGGGGTCGGCCAGCCGCCCTGTCCGGGAGGGAGG TGGGGGGGTCAGCCCCCCGCCCGGCCGGCCGCCCCGTCCGGGAGGTGAGGGGCGCCTCTG CCCGGCCGCCCCTACTGGGAAGTGAGGACCCCTCTGCCTGGCCAGCCGCCTCGTCCGGGA GGGTGGTGGGGGGGTCAGCCCCCCGCCCGGCCAGCCGCCCCATCCGGGAGGTGAGGGGCG CTTCTGCCCGGCCGCCCCTACTGGGAAGTGAGGAGCCCCTCTGCCCGGCCACGACCCCGT CTGGGAGGTGTGCCCAGCGGCTCATTGGGGATGGGCCATGATGACAATGGCGGTTTTGTG GAATAGAAAGGCAGGAAGAGTGGGGAAAAAATTGAGAAATCGGATGGTTGCCGGGTCTGT GTGGATAGAAGTAGACATGGGAGACTTTTCATTTTGTTCTGTACTAAGAAAAATTCTTCT GCCTTGGGATCCTGTTGATCTGTGACCTTATCCCCAACCCTGTGCTCTCTGAAACATGTG CTGTGTCCACTCAGGGTTAAATGGATTAAGGGCGGTGCAAGATGTGCTTTGTTAAACAGA TGCTTGAAGGCAGCATGCTCGTTAAGAGTCATCACCACTCCCTAATCTTAAGTACCCAGG GACACAAACACTGCGGAAGGCTGCAGGGTCCTCTGCCTAGGAAAACCAGAGACCTTTGTT CACTTGTTTATCTACTGACCTTCCCTCCCTTCCCTCCACTATTGTCCTATGACCCTGCCA AATCCCCCTCTGCGAGAAACACCCAAGAATGATCAATAAAAAAAATAAATAAATAAATTA AAAAAAAAAAGAAAATGTGCTAGTTTCTATTTAATTTACTATAACATTCCTTCAAAAGTA TGTCATGTTAACATCATTTTAAACATGTGAAAAGTGATATTGGAGAGGGGTTAAATAAAC TGCCCTAATTCACACACAGCTAGTTAGTGAGGGCCAAAAAGTATGTTCTACATATAGTAA AGTTCTAAATACCATACAGACTTGAAGTGTATTATGAATTCAGAGAAGTGGGAACTTAGT GTGGGCTGAAGCAGACTAGATAAATTTCAGCAAGGAATAATGTGAGCTGAGCTCAATGAT GGGTAAGATTTATTTAAGTACAGAGGGAATTTGGCATTTCAGGTATAGGAAATAGTTCCC AAGAGGTGAGACATATAGGTATCTATGGATATAGAAAGTTATAGGTTGGGCGCAGTGGCT CAGGCCTGAAATCCCAGCACTTTGGGAGGCCAAGGCAGGTGGATGACTTGAAGCTGGGAG TTTGAGATTAGCCTGGCCAACATGATGAAACCCCATCTTTGCCAAAAATATACAAATTAG CCGGACATGGTGGCAAGCGCCTGTAATCCCAGCTACTTGAAAGGCTGAGGCAGAAGAATC GCTTGAACCTGGGAGGCAGAGGTTGTAGTGAGCTGAGATCATGCCATTGCACTCCAGCCT GGGCGACAGAGTGAGACTCCGTCTCAAAAAGAAAAAAAAGTACAATATTTATTCTAAGAA GTAGAAAAATAAAGTTAGACATGTTAATAATATATCATTATTATTATAACTACCACTTAC TAAACTCTTTAAATGTTTAATGTTTAAATTAAGCTTGCTGATATCATCGCTTTCATCCTT ACCGCAGTCCTATTAAGTAGGCATTAACACCATTTTGCAAATGGGAAAACTGAGGGTAAG CTGATGGTCAGTAACTTACTGTAATCATGCTAGCTAGTGTGAGAATCAAACCCATGTATA CAAGTCTGTTCCTAGTCCTAACGTTAGAGTTCATCATCATCAAGGAAACCTGCTTAAAAT ATGGGTCTCTGGAATCATTTTAAATAAGAATTATTCAAATACAGGGGCTCCAGAATTATT TCTACCAGCACATTCTAAAGATGCTGTGAGGACTATACTTTAAAATCACTGCAACTGGCA ATACTGTCTCAAAGTTATAAGATTGAAAAATATGGATATGATAAAATACTACAGGTCCTT GGGTAAATAATAATGTTGTAACAGTCAATACTTGCTTAATGCACTATGCCAAGCACTGTT CTAAGCACTTCACATTGAATCTTCAAGAAACCCTATGAGGGCTAGGCACAGTGGCTCACG CCTGTAATCCCAACACTTTGGGAGGCCGAGACTGGAAGATCACTTGAGGCCAGGAGTTTG AGGCCAGCCTGGGCAACACAGCAAGAGCTCATCTGTACACAAAAATAAAAAATCAGCCAG GCATGGTGGTGTGCACCTGTAGTCCTAGCAACTCAGGGAGGATGAGGCAGAAAGATTGCT TTAGCCCAGGAGTTATAGAGGCTGCAGTGAGCTATGATCATGCCACGGCACTCCAGCCTG AATGACAGAGCAAGACCCTATCTCTAAAACAAAACAAAACACTATGAGGTAGATACTATT ACTATTCTATTTTTAGAGATAAGGAAACTGAGGCATAGAGAGGGTAAGCAACTTGCCTAA GGTCACATAGCTAGTATGTGGCATTTGAACCCAGTAGTCTCACTCCAGAGTCCTTGCCCT TTACTACTAGGAGTGTATGAGGAAAACAATGCTTAGCAGGTAAGACAGGTTACAGGGTGT GAGGCGTGAAGGCAGGATATAAACTCTGAGACTTTTTATTTGTAGGGGCTCCAAACTGAA TAAAGCAGCTATTAGAATCAAATCTTTATTTCTTAATTGGATTAAACGAAGGGAATCCAC TATATTAAAGAACTGTAAAAAAATACTGGCCAGGTGCAGTGGCTTACACCTGTAATCCCA GCACTTTGGGAGGCCAAGGCGGGCGGATAACCTGAGGTCAGGAGTTTGAGACCAGCCTGG CCAACATGGTGAAACCCCATCTCTACTAAAAATAAAAAAATTAGCCGGGTGTGGTGGCAC CTACGGTCCCAGCTACTTGGGAAGCTGAGGCAGAAGAATCGCTTGAACCCGGGAAGCAAA GATTGCAGTGAGCCAGGATCGCGCCACCACACTCCAGCCTGGACAACAGAGACAGACTGT CTCAAAAAAAAAAAAAAAAAATTAATATCATTAAGAGAAAAAACAAAAACCTAAAACTTA TCAGAGCTGTTTCCAACTCGAAACCCCTCTCCCAGTTAGCTGAAATACCATGCATGCCTC AATACTAAGGATGAGAAAGAAGGCCTTCAAAAAAGAAGCCAACCCACTACCAGTAAGTCA CTCATCTAGCCTGAGGGACAGTCCCTCCTACCCCTCCTACAGCTGCCAATTCCCACCGGA GAAGTGACTCAGAAGCTGCTTTGACAGAATCCTTAAATGATTTAACAAAGGAATTCAGGA CATAACGAATTTTACCTTCATCTGTTGTCTTTTCTGTTTCAGCACCGACCAACAACTTGA AGCCACAGCCTAAATACATGCAGAGAAAAGAAAGATTTATATATAGCTATATAAACATTT CCATTTTTATTAGAAATTCAAAGTTTATGGGTCTAAAACGTTCAATACATTCATTACTAA TAAGAACTAGTCGGCCGGGCACAGTGGCTCACATCTGTAATCCCAGCACTTTGGGAAGCC GAGGCGGGTGGATCATGAGGTCAAGAGATGGAGACCATCCTGGCCAAGACGGTGAAACCC CATCTCTACTAAAAATGCAAAACAAAATTAGCTGGGCATGGTGGCGCATGCCTGTAGACC CAGATACTCGGGAGGCTGAGGCAGGAGAATTGCTTGAACCCGGGAGGCGGAGGTTATAGT AAACAGAGATCGCGCCACTGCACTCCAGCCTAGCGACAGAGCAAGACTTTGTCTCAAAAC AAACAAACAAACAAAAAACAAAACTAGTCAGGGTCCTCACATTGTTTGAAAATATTAATG AAAAGGTATTTCATTTTTATAAATTTTTAAATCATGAGCAAAGTTGTATGTTGCAAGGGC AAAAAAAAAAAAGTAAAATAATATTTAAAAAATTAAACACAAAGCCACTAAAGGAAAAAG ACTGCACTCTGGAACAAAGGAGATTCAATTTTCAGAGTTTTAAAGTTCTGTTCCTTAAGG GAAAAAAGTGAAAATATGTGTATATAGAATTCACATACACAAATAAATATTCTATGTGTA ATAATAAAGTAATTTTTCTTCTTCTTTTTTTTTGAGACAGGGTTTCACTCCCATTGCCTA GGCTGAAGTGCAAAGGAGTGATCTCAGTTCACTGCAACCTCCGCCTCCAAGGCTCAAGTG AACCTCCCACCTCAGCCTCCTGAGTAACTGAAACCACAGGCACACACCACTGCACCTGGC AAATTTTTGTATTTTTTTTATAGAGACGAGGTGTCACTATGTTGCCCAGGCTGGTCTCAA ACTCCTGAGCTCAAGTAATCGGCCTGCTTCGGCCTTCCAAAGTGCTGGGATTACAGGCAT GAGTCACTGTACCTGGCCTAAAGTAATTTTTTTTCAAGAATAGTACTATTGGAATATTTG TGAATAGAGCTAACAGTTTGATCNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNGATCTGGAAAAGATTCA GTTAAAATTGAAAAAAATCTCTTTAATTTGTTCACTTAAAAGAAGGACCTAATAACTAAA CTTACTCTTAATCTAACCTATTTCTAAATACTATCAAGAGAATATCATTTCACTCTTTCA ATGACAAGCTAGCCCAATTTGATTTTTTAAAAAATATCTTAAATGTTGTAATTTATTACT CACTACTCTGAAGATCTCAGGTAAACAATATTACCCCAAAGTCAATAGGAGCAGAAAATA ATTCAACCCCGTTAATATTTTTTGAGCAATTAAGGATTAATTCACGCAACTGAATCTTCT GTCTGAATCACAGCAAGATTTTTTACAGGGATGATTAAACTGAGCTTTAAAAAAAACTAT CTGGAAATCTGAGGAAATAGAAGCTAAATCCATTTCTAAATACTTTCTAAATAAGCCATT TTATTCACAAATTATTTAACAAATATTTCTTCAGAATCTTAAAGTACCAGGACTGTGTTA TAAATTAAAATCTTACTGTAATTCTATTCTATGAGCACATAATAAGTGCCTACAACCAAT CAGGAAGCACTATGTATACAGAGGTCACAGATCTTGCATTTTGCGTATACTCTTCTATTT CCCTCAAGCAGTGTGCTAAGAGTGGAGACAGATATATTGGCAAATAATTACAGCATAATG TGATAAATACAGTTATACAAGTACTAAGTTATATAAGTACTAACATCAGAGCAAGAAGCG ATTAACTTTCTCTTGGGAGACAAACACTATTAAATACCTAAAAGCAAAGGAACTCTAAAA TAAAGCTAAAGGCTTGGAATGTTGAGAGCTGGAAAGAATGTCACTTTCAACCCTCCAACA ACAAAATAAAGTATTCTGACTCCATCAGAATACGGAGATCAGAGGGCAACCAATTGCCCC CTAAACTAACGAGACAGGCATTTGCAGAGAGGTAAGACATTAGCATTGGCTTACACGGAC AAGACATAGCATGACGTTAGCAAGAAGAGGTCAGCAAGCATCGTTTCAAATCTGGTGGAG AAAGAATACACTGTTGAGAGGCTGGAGAGAGGTGCTGCAAATGTAGGTGAAATCCACACC TTTCTTGCATATCTTATCATCAAGAATCACCAGGCACTCGTAGAAAATACTGAAAGAGTC CTACAAAAGTCTCCCTAATGGTACAGAGGGAGGGAAACAGCAGCTTCTGTGGAGGGCATG AACCAGCACCATAACCTTTCTCCTCTATCCCCATTAAAGAACAAAAGCCTTAAACTGTGG ATGCATCTTTAACTTTAGAGAGAAATTTATGCCATTAAATGCTTATATTAAAAAAGGAAA GATATCAAATCAGTAATCTAAGCTTTCGACTTAAGATTCTAGAAAAAGAAGTACAAATTC AACCTAAAACAAGCAGGATATAGGAAGCATTATAAAGATTAAAGCAGAAATCAATAAGAC CAACAGCTGGTTTTTTTTTTTGGAAGGAAAACTAATAAAACCTCTAGCCAGTCTTATTAA GAAAAAAAAGCAAGAATGACACAAATTACCAAAATCAGAAAAAAAAGAGGAGGAGTCATT ACTGCAGACCTCACAAAGGTCTGTAAAAAGGATCCTATAAACAATTCTATGACCACAAAG GACAAAATCAAAACTCACTCGGAAAAAAAAACAGGTAACACAAGCAGTTAAATATCTATT AAAGAAATTGAATAGGTAGTTAAAAACCTTCCAACAAGGAAAACTGAAGGCCAAATTACA CCAAGTAGTTAAAGAAGAAACAGTATCAATTTCACAATGAGGATACGTCCTAATCATGTT ATCAATCTAGTCCAGATGCTGTTTGACTTATAATGGGGTTATAGCCAATAAACCCATCCT AAGTTTAAAAACATAAGTCAGAAATTGATTTAATAAACCCAAACTACCAAACATCATGGC TTAAACTAGCCTATCTTAAACATGCTCAGAACACTTATTAATACATTAGTCTACATTTGG GCAAAATCATGTAACACAAAGCCTTTTTATGAGAAAGTCTTAGATGTCTCAAGTAATTTA TTGAATACCGTACATTATGTCAAATTTGCAATGGTTGTGCATCATCTTGAAGTCAAAAAA TTGTTAAGTTGGGGACAGTTAATATCAAAGCCAGACAAAGACATCACAAAAAATAAAACT ATAGGTTAATATCCCTCATTGATAGATGCAAAAAATCTTCCACAAAATATTAACAAATAA AATCCATCAATATATTAAAAAATATATAAATAACCAAGTGGTATACATCCTAGGAATGCA AATCTGGTTCAACATTTAAAAATCAATGTAACTTACCATAATATCAGCTAAAGAAAGCCA TAATATTATCTCAACAGATGTGAAAAGAACACTTTAAAACATTCAACATCCATTTATGAC TACTTAAAAACTCCCAGCAAATTAGGAATAGAAGGTGTAGTAGGTTGAATAGTGTCCCAG AATGATTCATGTCCACCTGGAACATCAGAATGTGATCATATTTGAAAATAGGGTCTTTGC TGATATAATTAAAGTAAGAATTCAGATGAGACCATACTGGATTAGGGTGTGCCCTCAATC CAATGAGAGTATCTTTGTAAGCCATAAATACACAAAGGGGAAGGCCATGTAAAGACACTG AAGCTATGCTGTGATATGGTTTGGCTACATCCCCACCCAAATCTCATCTTGAATTGTAGC GCCCATAATTCCCACGTGTTGTGAGTTGGCCCCCGTGGGAGATAATTGAATCATAGGGGC AGTTTCCTACTGTCCTCATGGTAGAGAATATGTCTCACAAGAGCTGATGCTTTTATAAGG GGAAACTCCTTTCGCTTGGCTCTCACTTCTCTCTTGTCTGCCGCCATGGAAGACGCACCT TTTGCCTTCTACCATAATTGTGAGGCCTCACCAGCCATGTGGAACTGTGAGTCCATTAAA CCTCTTTTTCTTTATAAATTATCCAGTCTCAGGTATGTCTTTATCAGCAGAGTGAGAACT GACTAATCCATGCTGCTACAGCCAAGAATGTCTGGAGTCACCAGAAGCTGGAAAAGGCAA GGAAGGATTCTCCCCTAGAACCTTCAGAGGAAGTGTGGCTCTGCTACACTGTGATTTCAG CCTCCATAATTAAAAAATTAAATTTCTATTGTTGTAAGTCACCAAGTTTGTAGTAATTTG TTATGGTAACTCTGGGGAACTAACACAAAAGGGAAATTCCTCCATCTGATAAAGGGTATT TATTTTAAAAACCTGTAGCTAAGATCATGCTTAATGGTGAAAAACTAAATGCTTTCCCCA TAAGATCATGAACAAGGCAAGGATGTCATTTCACCAATGTCGTATTAGAAGTACTAGCCA GTACAAAAAATTAAGAAACAGGAATAAAAGGAATACATATTAGAAAGGAAGAAGTAAAAC TATTCACATATGATACAGCTGTCTATAAAGTTACAAAGAATCTACAAAAAAGCTCCTATA ACTAGTAGGTAAGTTTCACAAGATAACAGAATACAAAGTCAATATACAATATCAACTGTA TTTCTGTATAAAAGCAATAAGCAACCGGAATTTGAATTTCAAAAAGTAATACTATTTATA ATAGCACCAAGAAAAAGAAAAGGAAAATACTAGAGCTAAATCTAATAAAATCTGTGCTAG GTAACAATGAAACACAAAAGATATCAAAGAAGATAAAAGGAGAGAGACATCATATTCATG GATTATAGGAATTTTTCTCTCCAATTTGATCTACATAAACAACATAATCCAAATAAAAAA CCCAGAAAAATTTTTGTAGTTACTGATAAGCTTATTTTTAAAAAATTAAGAAAAGGCAAA AGAACTAGAGGAACCAAAACAATTTTAAAAAGAACAAAGTTGCAGAACTCAAAATAGCTG AATTCAAGACTTAACTGTAAAGCAACAGGCAATACAGTGTGGACGTATAGATCAATACAG TAGAATAGACAGCCTGCAAGAAACACACACAAACATATAGTCAATCTATTTTTGTCAAAG GTAGAAAGAAAATCCAAAGAAGAAATTTCTAGAAGAAAACACAGGAGAAAATATGTATGA CCTCATAATCACCTAAAATCAGAAACAACCTGGATGCCCTTCAACAGGTGAACAGATAAA CTGTAGTACATTCATACAATGGAATGTTACTCATCAACAAAAAAGGACAAACTATTCAGA CAAACAACAATGTGGATGAATTTCAAATGCATTATGGTAAAAGGAAAAAGCCAATTTCAA AAGATTATACGTTGTTTAATTCCATTTATGTGACATTTGTGGGTAAAGATAAAACTACAG GGACAGAAAACATCAATGGCAGCTAGCGGTCAGAGGTGACCACAAAGGGGCAGCACACGG GAACTCTGGGGATGAAGAACTGTTCTGTTTGGTGCTGTGGTGATGGACACATGATTGCAC AGCTGTAAAAACACACAGAACTGGGCACAACAAAGAACAAATTGTGCTCCATGTCAATTG AAAAAAAATCAACCAGGATATGGGATCACAGATGGATCCAAAGATAAATCACAGGCTGTG AAAAGTAAATCAAACTTTGTTCCAAATGAAGCACACTGAAAGGTGTGAGGAAGAAAGGCG CTGACCTAAGTGACAGTGTTTTGCCTGGATATTGTAAGACTACAGACAAAAAGAGTTAGA CATAAATACTGTAACCTGTTGGTAAATTTGTTTCTCAAAGGAGTACTGGGGCCAACTGCA GTGGTACCTGCCTGTAGTCTCAGCTATTTGGAAAACTGAGGCAGGAGAATAAGTTGAGCC CAGGGGTTCGAGGTTGCAGTGAGCTACTATCGCACCACTGCACTCCAGCCTGTGTGACAA AGTGAGACTCCATCTCTTAAAAAAAAAAAAAAAATTAAGACCAGGCACGGTGGGCTCACG CCTGTAATCCCAGTACTTTGGGAGGCCAAGGCGGGTGGATCACGAGGTCAGGAGATCGAG ACCATCCTGGCTAATATGGTGAAACCCCGTCTCTACTAAAAATACAAAAAAATTAGCCGG CATGGTGGCGGTCGCCTGTAGTCCCAGCTACTTGGGAGGCTGAGGCAGGAGAATGGCGTG AACCCAGGAGGCAGAGCTTGCAGTGAGCCGAGATCATGCCACTGTGCTCCAACCTGGGTG ACAGAGAGAGACTCCATCTCAAAAAAAAAAAAAATTAAGTTGAATTTTAAAAAGAGGAGT ATTGGGGTGCAAATTCTGAAATTTCTTTATGTGTACACTAGATATTATAATAAGTAAATA TATTATGAGTAATACACTATAGTTAATGAGAGCCAGGTGTCTCACTGCTGAATAAACACG TCACAAATGATCCAACTAGGAATGCTAAAATGAAATATCTGTTGTTGGATTGAAGTCAGA AGTATCAATATGACCAGCACTTTGGGAGGCTGAGGCGGGTGGATAGCTTGAGGTCAGGAG TTCCAGACTGGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAAAAAA TTAGCCAGGCATGGTGGCGCACACCTATAATCCCAGCTACTCAGGAGGCTGAGGCAGGAG AATCGCTTGAACCCAGGAGGCAGAGGTTGCAGTGAGCCGAGATCATGCCACTACACTCCA GCCTCAACGACAGAGTGAGAATCTCTCCAAAAAAAAAAAAAAAAGAAAGTAATATACCAG GCCCAGCATGGTGGCTCACACCTCTGGGAGGACAAGGTGGAGAGATCACTTGAGCCGGAG TTTGAGACCAGCCTGGGCAACATGGTGAAGCTCCATCTCTAACAAAAATACAAAAATTGG CAGGGTATGGCAGTGGGTGCCCACAGTCCCAGCTACTTGGAGGCTGAGGTAGGGGGATTG CTTGAGCCGAGCAGTAAGTCATGATTGTGCCACTGCACTCCTGCCTGGGCAACAGAGCAA GAAACTATCTCAAAAAAAAAAAGAAAAGAAAAAGAAAAATATTCCAAATAATAAATGTAG AAGTAATGAAGGAAATAGAAAATCACCAATAAACACTTCAGTAAGAACTGCTGGCTGGGT GCAGTGGCTCACACCTGTAAATCCCAGCACTTTGAGAGGCCGAGGCAGGTGGATCACCTG AGGTCAGCCGTTTAAGACCAGCCTGACCAGTATGGTGAAACCCCATCTTTACTAAAAATA CAAAAATTAGCTGGGCATGGTGGCATGCGCCTGTAGTCCCAGCTACTCGGGTGGCTGAGA CAGGAGAATTGCTTGAACCCGGGAGGTGGAGATTGCAGTGAGCCGAGATCACGCCACTGC ACTCCGGCCTGGGCAACAGAGCAAGGGTGCATCTTAAAAAAAAAACAAAAAACTCCTGAA GGCAGCATCAAGAAATAAGTACTAAAGTAAGATATCTTACAGTGTCAAAGTCTCTACCTC CAAACTTCTTATTTACAAAGGAGAAAAAGTGGAAAAGTGTGGCAGACACATCCTTAACTA AATGATCAAGGGGTGTGTGTGTGTGCCTTTTTTCAAAAGACAGGGTCTCGCTCTGTTGCC CAGGCTAGCGTGCAGTGTGCAATCACAGCTCACCAGAGCCTTAAACTCCAGGGCTCAAGC GATCCTCCCACTTTAGCCTCCAGAGTAGCTGGGACTACAGACATGCATCACTGTGTTCAA GTAATCCTCCCACCTTGTCATGCCAAAGTGCTGGGATTATAGGAATGAGACACCATGCCT GACCAGTGATCAAAGCTACTATCACCAGTAACAAGGCACACAGACATCATCATGTATCCC CTGATATTGTGACATCTTGCCAAAAATGCATAACTTGAATCCAACCCTGAGAAAACATAA GACACACTCAACTGAGGGACATTCTGCAAAATACCTATCCTATATATTTCAAAAGCAGCA GGTCATATAAACCAAGGAAAACTGAAAGAACTGTCACAGATTGGAGAAGACTAAGGAAAC CTGACAACTAAATGCAATGTGGGAACCTAGATAAGATCCTGAAGGATATAAGGTGGAAAA AAGTAATAAAACCTAAATAAAGTCTATAGTGTAGTTAAGAATATTACTTACAAAATTAAG ATTACAATGTTAATCTTAGTTTTGATAGTTGTATTAGAGTTATAACAGACATTAATATTA AGATGTTAATACAAAGCATACACGAGAATTCTATGTACAATCTTTGCAACTCTTTGGTAA ATAAAATTCTTTCAAAATAAAAGTTTAAGGCCGGGCGCGGTGGCTCATGGCTGTAATCCC AACACTTTGGGAGGCTGAGGCGGGCAGATCACTTGAGGTCAGGAGTTCGAGACCAGCCTG GCCAACATGGCGAAACCCCACCTCTACAAAAAATAATAAAAAATTAGCCAGGTGCGGTGG TGCTCACCTGTAATCCCAACCACTTGGGAGGCTGAAGCACGAGAATTGCTTGAACCCAGG AGGTAGAGGTTGCAGTGAGCTGAGATCACGCCACTGCACTCCAGCCTGGGCGACAGAGTG AGACCCTGTCTCAAAAAAAAAAAAAAAAAAAAAGATAAAATTTTAGTAAAGCAGCCAGGC ACAGTGGTTCACGCCTGTAATCCCAGCACTTTGGGAGGCTGAGGTGGGCAGATCACTTGA AGTCAGGTAGACCAGCCTGGGCAACATGGTGAAACCCCATCTCTATTAAAAATACAAAAA AAAAAAAAAATTAGCTGGGCATGGTGGCGCATGCCTGTAGTCCCAGCTACTCAGGAGGCT GAGGCATGAGAATCACTTGAGCCTGGGAGGCAGAGGTTGCAGCGAGCCAAGATTGTGCCA CTGCATTCCAGTCTGGATGATAGAGGGAATCCTTTCTCAAAACAAAACAAAACAAACAAG CAAACAAACAAACAAAAAAAACCTCTCAGGATTCAACAGTAAAAAAAGCAAATAGGCTGG GCACCATGGCTCATGCCTATAATCCCAGCACTTTGTGAGGCCAAAGCGGACAGACTGCTT GAGCTCAGGAGTTCCAGACCAGCCTGGGCAACATGGTGAGACCCCGTCTCTACAAAAAAT ACAAAAATTAGCCAGGCATGGTGGTGCATGCCTGCGTCACAGCTAATGAGGAGACTAAAG TGAGAGAATTGCTTGAGCCCAGAAGATTGAGGCTACAATGAGCCGATATCACACCACTGC ACTCCAGCCCGGGCAACAGAGAGACCCTGTCTTTAAAAAACAAAAAACATACAAACAAAA AAAACAGGCCGGGTGCTGTGGCTCATGCCTGTAATCCCAGTACTTTGGGAGGCTGAGGCG GGCAGATCACCTAAGGTCAGGAGTTCAAGACCAGGCTGGCCAACGTGGTAAAACCCCGTC TCTACTAAAAATACAAAAAAATTAGCCGGGCATAGTGCTGCATGCCTGTAATCTCAGCTA TTCAGGAGGCTGAGACAGGAGAATCACTTGAACCCGGGAGGCAGAGGTTGCAGTGAGCTG AGATCGCGCCACTGCACTCCAGCCTGGGCTACAAGGGTGAGACTCCATCTCAAAAAAAAA AAAAAAAAAAGCAAACAATCCAATTTAGAAAATGGGCAAAGGACATGAAGAGACATTTCA TTTCATTGAAGATGATATACAGATGGCAAACACACACAAACCCAAGAAGATGTTCAACAT CATTAGCCAATTGGGAAATGCAAATTAAGACCACAGTGAGATACCAGTACAAAACTATTA GTGTAACTGAGTATTTCAGCTTTGAAATGCATTTTAAAACTTTTTTTATCCTTTTTCTCT AGTCTTAAGATGTAACCTTGAAACAAACTGTAGAAACTTTGTGTCCTAAGTCTTAAAATA TGGCCTTGAAATCTTCTTTGAACTCTGCTCCCCTCTCTTTCCCACCAGACACTCCCTTGC ACCATGCACACTTACCTAACTGCATGCTTGTTAAGAAATTCCAGGGGCTACAACAACCCA GGCAAAAAGACCCAGCGGTGGAATGAATTCTCCTCTACAGGGAGATTACCTCAAAACTGA TAATCTGTAACTCAGCAGCAAATAAAATGGCACCAGCCTGTACTCCAGGCAGACAATAAT TCGAGATAGTCCTTGGAACAACACATAGGAACCTGCATCCTGTGTTACTCTTATGTTTCC CATACCAAGTCTCCTCTTTTTAAACCCCTTCCCTCAGCCTAACACTTGAAATGGTCTTTT GGAGACATAAGCCTAGCCTATCCCAACTGCTAGCATTTCAATAAAGTTGCTTTCCTTTCA CCACTCTTTCTTTCTCATGTTTTGGTCCTCAAGCAGTGAGCAGCCAGACTTTTGTTCAGT TATATTAGAACATCTAAAATAATTATTTTGAAGTGACAATACCAAATGCTGGTGAGAATA TGGGAAAACTAGACTTCTCATACTTTGATGGTAGTAATGTAAAATGATACAGCCAATAAT TAATTTTGTAATTTCTTTAAAAACTAAGTATTGGGCCAGGCGCAGTGGCTCATGCCTGTA ATCCCACCACTTTGGGAGGCTGAGGCAGGTAGATCACTTGAGGTCAGGAGTTCAAGACCA GCCTGGCCAAGATGGTGAAACCCTGTCTCTACTAAAAATACAAAAATTAGCCAGGCATGG TGGTGTGCGCCTGTAATCCCACCAAATCAGGAGGCTGAGGCACAAGAACCACTTGAACCC AGGAGACTGAGGTTGCAATGAGCCAAGATCACACCACTGCACTCCAGTCTGGGTGACAGA GCAAGACTCTGTTTAAAAAAAAAAAAAAAAAAAAAAACTTAAATATCTACTTCTGAGCAT TTATCCCAGAAAAATAAAAACATGTCCACACAAACACCTACAAGCAAATGTTTAAAGCAG GTTTATTTTGTAATATTAAATGACCCTCAGTAAATGAATGGTTAACAAATTGTGGTACAT CCATACATACCATGGAGTACAAAATAAAAAGGAACAAACTGGTAATACATTCAACAGCTT TGCTGGAACTCAAGGGCATTATGCTGAGTGAAAAAAGGCCAATTTCAAAAGGTAACAGCC TGTGTGACTCCATTTATATAGCAGTTTTTTGTTTTTTTTTTTTTTTTTTTTTTAAGAGAC AGGGTCTTGCTCTGTTGCCAGGCTGGAGTGCAATAATGCAATCAGAGCTTAATACATCCT TGAAATTCTGGGCTCAAGTGATCCTCTCTTCTCAGCCTCCTCAGCTAGAACTATAGGCAC CTACCACCATGCCCAGCTTATATTTATTTTTATTTTTGTAGTGACAAGGTCTCACTATAT TGCCTAGGCTGGTCTCAAACTCTTGGTCTCAAGCAATCCTCCTGCCAGCCAAAGTGCTGG GATTACAGGAATAAACCACTGTTCTCAGCCTTATATAGCAGTCTTGAAATGACAAAACTA TAGATGGAAAACAGATTAGGGTTCACCAGGGATTAGGAATGGTGCGAGGGGCCAGGCACA GTGGCTCACACCTGTAATCCCAGCACTTTGGGAGGCTGAGGCGGGTGGATAACTTGAGGT CAGGAGTTTGGGACGAACCTGGCCAACATGGTGAAACCCCATCTCTACTAAAAATACAAA AGATTAGCCGGGCATGATGGTGGGCACCTGTAATCTCAGCTACTCATGGGGCTGAGGCAG GAGAATCGCTTGAACCTGGGATGTGGAGGTTGCAAGTGAGCCAAGATCGCACCATTGCAC TCCTACCTGGGCAACAGGAGCAAAACTCTGTCTCAAAAAAAAAAAAAAGGAATGGTGCAA AGAAAGGTGGGGGCCGGGCGCAGTGGTTCATGCCTGTAATCCCAGCACTTTGGGAGGCCG AGGCGGGCAGATCACGAGGTGAGGAGATCAAGACCATCCTGGCTAACATGGTGAAACCCC GTCTCTACTAAAAATACAAAAAATTAGCCGGGTGTGGTGGCGGGAGCCTGTAGTCCCAGC TACTCAGGAGACTGAGGCAGGAGAATCACTTGAACCCGGGAGGCGGAGCTTGCAGTGAGC TGAGACTGCGTCACTGTGCTCCAGCCTGGAGGACAGAGACAAAAAAAGAAAGGTGTGAGT GTGATTATAAAGAGGATGCAAGAGGTAAATCTTTAAGGTGATAGAAGAGTTCTGGATCTT GATAGAGGCTGTGGTTACATAAATCTATGCATATGATAAAATGGCTTGGCATAGAATTAT ATACATACATTGTCACTGTCAATTTCTTGATTGTGATATTGTACTATAGTCATATAAAAT GTAACCATTGGGGGAAATGGGATAAAAGGTACACTGGGCCTTGCTGTATAATTTTTGCAA CTTCCTATGAATCTATAATTATTTCAAAATAAAGTTTTTAAAAATAAGCTGTACCAACCT AGTTTCTAATCCAGAATAATTCAAACCAAAGAACTTTTGGGAGGGTTTTATAATTGGATT GTTTTCCTTCTCACAACTATTCACTGTAATCTGAATTGACTCATGGTACCTAGTTTGTTG TCTTTATCATTTTACACTAAAGGGGTCCTTGAAGAAGTGGTTGATTCTAGGTATGGAGCA GGAAAAGTACAAGATAAGCCTGTGCCATTTTATACTAGATAGCAAGGATTACGAGGGTTT TATCAAGAGCACTCAGGAACCAACCTGAATAGACTCTCACTGGCCAAATATGAGATCATT TGAGCATAAATAAGAATAAATAAATGCAATGGTTTAAAACATCAAATACAATTAAATCCA TAAGATCAAAACGATTTTTAAAAAACTTTCATTGATTGGCTGTGAAGGATACTACAGAAC CATCTTGTTATTTTAAAATCTGGTTAAAAAAAGAGAAAGAGAGAGAAAGCCAAACACGGT GGCTCACACCCATTATCCTAGCACTTTGGGAGGCCAATACGGGAGGATCGCTTGAATCCA GGAGTTTGAGACCAGCCTGGGCAAGATGGTAAAACCCTGTCTCTACAAAAAATAAAAAAA ATTAGCTGGGTGTGTTGGTACACTCCTGTAGTACAAGCTACTTGGGAGGCTAAGGTGGAA GGATCACCTGAGCCTGGGAGGATTCAGCTGCAGTGAGCCATGACTTACTGCCGGGATTTG CAGCCCGGGCAACAAAGCAAGACCTCGTCTCAAAGAAAAAAAAAAAAAAAAAAAAGCAAC CGCCCCCCACAATTCCATTTAGATTATTATCCAAAAGAATACAATACTTAGGAATTAACC AAAGATGTGAAAGACTTCTACAATTTAAAAATATATATATATACACGTTGCTGAAAGAAA TTAAAGAAAACATGAATAAACAGAAACACATCCCATGTTCATAGATTAGAAGACTTAACA TTGTTAAGATGTCAATACTACCCAAAGCAATCTACAGATTCAATGCAGTCTCTATCAAAA TCCCAATGATTTTTTGGCAGAAATAGAAAAACCCATCCTAAATGTCATACGGAATCTCAA GGGACTTAGAATAGCCAAAATAAACTTGAAAAAGAAGAACAAAGCTGGAGGACTCACATT TCCTAATTTCAAAACTCACTATAAAGCGACAGTAATCAAAACAGTAAGGTACTGGCATCA AGGGCACAGAAATAAAACCTCACATATATCATCAAATGATTTTCCACAGGGGTGCAAGAC CATTCAGTCGGAAATGGAGAGTTTTTTCAACAAATGGTATAGGGAAAACTGGACCCTTAC CTAATAATACATACAAAAATTAACTCAAAATGGATCAAAGACCTAAATATAAGTCCTAAA ACCCTAAGAAGCTTCACAACATCGGATTTGGCAATGACTTCTTAAATATGACAATGAAGA CACAGGCAACAAAAAAAAGATACAAACAAGACTTGATGAAAATTTTAAAATTTTGTGCAT CAAAAGACACCATCAACAGAATAAAAAAGTAATTCACAGGGTTGGGCACCGTGGTTCATG CCTGTAATCCCAGCACTTTGGAGGCCAAGGTGGGTGGATCGCTTAAGGTCAGGAGTTCGA GACCAGCCTAGCCAACATAGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGGCCAG GTACACTGGCTCATGCCTATAATCCCAGCACTTTGGGAGGCCAAGGCAGGCGGATCACTT GACGTCAGGAGTTCAAGACCAGCCTGGCCAACATGGTGAAACCCCATCTCTATTAAAAAT ACAAAAATTAGCCAGGCATGCTGGCACATGCCTATAATCCCAGCTACTTGGGAAGCTGAG GCAGAAGAATTGCTTGAACCCAGGAGGCGGAGGTTGCAGTGAGCGGAGGTTGCAGTGAGC CGAGATTGCGCCATTGCACTCTAACCTGGGTGAAGAAGCGAGACTCTGTCTAAAAAAAAG AAAAAATACAAAAATTAGCCAGGTGTGGTGGCAGGCACCTGTAATACCAGCTACTCGGGA GGCTGAGGCAGGAGAATTGCTTGAACCCAGGAGGCAGAGGTTGCAGTGAGCCAAGACTGC ACCACTACACTCCAGCTTGGGTGACAGAGTGAGACTCCATCTCAAAAAAAAAAAAAAAGA AAAGAAAAGTAATTCACAGAATTGGAGAAATATATGGAAATCATATAACTAACAAGGAAT TAATATCCAGACTATACAGAGAACTAAAACTCCACGAGAACAAAACAATTTCAAAAATGG GCAAAGGGGCCAGGCACAAGTGGCTCACACCTGTAATCCCAACACTTTGGGAGGCGGAGG CGGGCAGATCACCTGAGGTCAGGAGTTCCAGACGAGCCTGGCCAGCATGGCAAAACCCTG ACTCTATTAAAAATACAAAAATTAGCCAGGTATGGTGGCAGGCGCCTGTAATCTCAGCTA CTCAGGAGGCTAAGGCAGGGAGAATTGCTTGAACCCAGGAGGCCGAGGCTGCAGTGAGCA GTGAGATTGCACCACTGCATTCCAGCCCATGCAACAGAGTGAGATTCTGTCTTACAAAAA AAAAAAAAAAGGGCAAAGGACTAAAATATACATTTCTTCAAAGGATACATATAAATGGTC AATAAGCACATGAGAAGATGCTCAACATCATCAGGGAAATACAAATCAAAACCAGAAGGA TATACTACCTTTGATATGGTTTGGCTGTGTCCCCACCCAAATCTCATCTTGAATTCCCAT GTGTTGTGAGAGGGACCCAGTGGCAGGTAATTGAATCATGGGGACAAGTCCTTCCCTTGC TGTTCTCATGACAGCGCATAAGTCTCACGAGATCTGATGGTTTGATAAGGGGAAACCCAT TTCATTTGGCTCTCACTCTCTCTTGCGGCTGCCATGTGAGACGTGCCTTTCACCTTCCGC CATGATTGTGAGGCCTCCCCAGCTACATGGAACTGTAAGTCCAATAAAGCTTTCTTTTGT AAATTGCCCAGTCTCAGGTATGTCTTTATCAGCAGCATGAAAATGGACTAATACAGTAAA TTGGTACCAGTAGAGTGGGGTGCTGCTGAAAAGATACCCAAAAATGTGGATGTGACTTTG GAACGGGATAACAGGCAGAGGTTCAAATAGTTTGGAGGGCTCAGAAGAAGAGAGGAAAAT GTGGGAAAGTTTGGAACTTCCTAGAGTCTTGTTGAATGGCTTTGCTCAAAATGCTGATAG TGATATGAATAATAAAGTGAGGCTGAGGTGGTCTCAGATGGAGATGAGGAACTCATTGGG AACTGGCACAAAGGTGACTCTTACTATATTTTAGCAAAGAGACTGGTGGCATTTTGCCCC TGACCTAGAAATCTGTGAAACATTGAACTTGAGAGAGATGATTTAGGGTATCTAGCAGAA GAAACCTCTAAGCAGCAAAGCATTCAAGAGGTGACTTGGGTGCTGTTAAAGGCATTCAGT TTTATAAGGGATGCAGAGCACAAAAGTTTGGAAAATTTGCAACCTGACAATGCCATAGAA AAGAAAATTCCATTTTCTGAGAAGTTCAAGCAGGCTGCAGAAATTTGCATAAGTAAAGAG AAGCCAAATGTTAATCCCCAAGATAATGGGGAAAATGTCTCCAGGGCATGTCAGAGGTCT TCACGGCAGCCCCTCCCATCACCAGCCAGGAGGCCTAGGAGGAAAAAGTGGTTTCAGGGG CCAGGCCCAGTGTCCCCGTGCTGTGTGCAGCCTAGGGACTTGGTGCCCTGCATCCCAGCC ACTCTAGCCATGGTTGAAAGGGGCCACCATAGAGCTTGGGCTGTGGCTTCAGAGGGTGCA AGCCACAAGCCTTAGCAACTTCCACATGGTGTTGAGGCTGCCAGTGCACAGAAATCAAGA ATTGGAGTTTGGGAACCTCCACCTAGATTTCAGAAGATGTATGGAAATGCCTGGATGCCC AGGCAGAAGTTTGCTGCAGGGGTGGGCCCTCATGGAGAACCTCTGCTAGGGCAGTACAGA AGGGAAACATGGAGTCGGAGGCCCCACACAGAGTCCCTACTGGGGCACCGCCTAGTGCAG CTGTGAGAAGAGGGCCACCGTCCTCCAGACCCCAGAATGATAGATCCACCAACAGCTTGC ACCATACACCTGGGAAAGCCACAGACATTCAATGCCAGCCCATAAAAGCAGCCGGGAGGG AGGCTGTACCCTGCAAAGCCACAAGGGCAGAGCTACCTACGACCATGGGAACCCACCTCT TGCATCAGCATGACCTGGATGTGAGACATGGAGTCAAAAGAGATCATTTTGGAACTTTAA TATTTGACTGCCCTGGCCGGGTGCAGTGGCTCACACCTGTAATCCCAGTACTTTGGGAGG CCAAGGCAGGCAGATCACCTGAGGTCAGCAGTTCAAGACCAGCCTGACCAACATGGAGAA ACCCCATCTCTACTAAAAATACAAAACTAGCCAGGCGTGGTGGCACATGTCTGTAATCCC AGCTACTCAGGAGGCTGAGGCAGGAGAATCGCTTGAACTCGGGAGGCAGAGGTTGCGGTG AGCCAAGATTGTACCATTGCACTTCAGCCTGGGCAACAAGAGCCAAACTCCCTCTCAAAA AAAAAAAAAAATTTTTGACTGCCCTGCTGGATTTCAAACTTGCATGGGGCCTGTAGCTCC TTTGTTTTGGCCAATTTTTCCCATTCGGAATAGCCATATTTACCCAATGCCCATACCCCC ATTCTATCTAGGAAGTAACTAATTTGCTTTTGATTTTACAGGCTTATAGGTGGAAGGGAC TTGCCTTGTCTCAGATGAGACTTTGGACTGTGGACTTTTGAGTTAATGCTGAAATGAGTC AAGACTTTGAGGGACTGTTGGGAAGGCATGATTGCTTCTGAAATGTGAGGACATGAGATT TGGGAGGGGCCAGGAGCAGAATGATATGGTTTGGCTGTGTCCCCACCCAAATCTCATCTT GAATTCCCACGTGTTGTGGGAGGGACCCAATGGTAGGTAACTGAATCATGGGGACAAGTC CTTCCCTTGCTGTTCTCATGATAATGAGTAAGTGTCACAATATCTGACAGTTTCAAAAAT GGGAGTTTTTTTGCACAAGCTCTTGTCTGCCGCCATATGAGATGTGATTTTCACCTTCCA CCATGATTGTGAGACCTCCCCAGCCATGTGGAACTGTGAGTCCAATAAACGTCTTTCTTT TGTAAATTGCCCAGTCTTGGGTATATCTTTATCAGCAGCATGAAAACGGACTAATATAAC CTCATACCTATTAGGATGGCTACTATCAATGAAATAGAAAATAACAAGCATTGATGAGGA TGTGGAAAAACTGTGCACTATGTGGAAAAACTGTGCACTATTGGTAGAAACGTAAAGTGG TACAGCTACTGTGAAAAACAGTATGGCAGTTCCTCAAAAAATTAAAAATAGGGCTGGGTG AACCAGCTGACACCTATAATCCCAGTACTTTAGGAGGTCAAAGTGAGAGGATGATTTGAG GCCAGGAGTTCAAGACCAGCCTGGTCAACATGCTGAGACTCTGTCTCTTCAAAAAATTTA AAAACTGGTGGAGAGATGGTGGCACATGCCTGTAGTCCCAGCTACTTGAGAGGCTGAAGT GGGAGGATTGCTTGACCCCAGGAGTTTGAGGCTGCAGTGAGCTATGATCTTGCCACTGTA CTCCAAAGCAAGACCCTGCCTCTAAAAAATAATAATAAATAAATAAATACATAAATAAAT AAATTTAATTAAAAGTAGAATTACTGTATGATCCAGCAATTTCACTTGACACAAAATAAT TAAAAGCAGGATCTCAAAGAGATATTTGTATGTCCATGTTTATAGCAGCATTATTCACAA TAGCAAAAACATGGACGCAATCCAATGTCCATCAACAAACACACACATAAGCAAAATGTA GTATATCCACACAACGAAATATTATTCTACCTTAAAAAGAAAGGAAATGCTGACATATGC TACAACATGGATGAACCTTGAGGACATTATGCTAAGTAAAGTGAGCTAGTCACAAAAAAA TTCTGTAGGGTTCTACTTGTGAGGTACCTGGTCGAATTCATACAGACAGGAAACAGAATG GTGGTGGGGAATGACGGGAAGGAGGTACAGTAAGATGTTGATAAACAGTTGTAGAGTTTG AGTTTTGCAAGATGAAAAAAATTCTGGATATTGTTTGTACAACAATGTGAATGTACTTAA GGCTAATGAACTATACACTTAAAAATGATCAAAATGGTCAATTTTATGTTATTTGTACCT TACCACAATAAAATTTAAAGGATTGTTAATAGTGAGAACAGGCCTACTGGAATAACATAA TTCACTGAAAGTAATAATAATGGACTATGTAAGTTTGCTTAAGACAGAAAAAAATTTTTA AGTAACATAACCTTTTTTTAAGAGTTACAATAACCAAAACCAAAAACAAAAACCCGTGAA ATAACCAAGTAGGTTTTTTAACTACTGTAATAAATATTTTGACTGTACTATATAGAAACC TCAAATAAAACTGAAATAATGTAAACAAAATATGCTCTGAGCAATAAGCTTAATATTCAA CTTCCTGTTTGCTTCTTTTATTTACCTGGGAGAGAGAATAGTACCAAGTCAGAGGAAGAT CAAACACTCTTAGCGCTGCTGTCTTCAAGGAAAACTGTGATTCACTTACTGTTTCTTCTG ACATGGCTCCTCTTCTAATCTTCATTAAATGAAACATAAAAAAAATTAGCCACAAAGATT TCTGGTTACTTTACCAATGAAAGGTACAAACTGAAAATTTAATTCTATCAGCTTATTTTT GCAGTCAATTATTGATGACATTACACTTGAGCTAAAATTATATTTATTAATCACCAAACG CGTAAAAGAAACAATAAGCTATCCTTCCTGTAGGAGATAGCATAAAAAATAAGAAGTTAA AAAAAAAAAAAAGCTAGATTTAAACTTTGAGTCCGGGTAGCAAATTTTCCTTAGGAAATT GCGAGTTCTAGATTCTCTCTTTTCTGGTTACATAAAAATTTAACACTTTTTAGGGAGTAA TTTAAAATTTACTTCTCATTCATTTGGTTTCCTTCATATAACTGCGGGGGTGAGAGTAGG TGGCAGGCAGGTTGCTGAATGGAATCTGGAACAGAATCTTGGGGCTAGAACCTCAGAGTT CACTGACTGAACTCCAGAACTCACGCATTTATTCTCCTATTGTCTCATTTTAAAGATCTT CAAAGAAATGCCACATATATGCTATATGATTTTGGTATAGTTTTAATGCGTATTATTTCT CTTAAACAAAAAAAGAAAAGTCAGATGAGTACAGAGAAGCAGTTGACACACAAAGAGAGG TCATTAAGGCAGTGGTTCAGGGTCTGGGTCTCTGCTTTATAGAGCCAGAAACGTAATTTT ACCACTGTACCCAGTTGAACACATGTTAAACAAATTTACATGGTATTGATGCATAAATCA CTTTACAAGTTTATCTATTTATAATAAAGAAATAAACGATCTAGTGTACATATTCTATCA AAACATACCATCCCTGAAATAAAAGACCATAGGAAGCTGAACTAATAAGTCAAAAATGTT GCCTGATGAGTGCAAAAATCAAGAGTCCTGAGGAATATTTCATTCAGGCCAAGAAAACGC CTAAGCATTATCTCTAATGCACAAGAGAATGGGCTTCTCTAATAACCACAATGTTTATGT CTACCAAATTTATTATTTCTTTTATTTGGGTAGTGCTGTATATTACATAACAGAATATAA AAATTACCAGCAATCCCTCTATAAAAGTTTATTTGCGGCTGGGCACAGTGAGTGGCTCAT GCCTGAGCACTTTGGGAGTGACTTTGGGAGGCCGAGATGGGTGGATTGCTTGAGTCCATG AACCCAGGAGTTCGAGACCAGCCTGGGAAACATGGTGAAACCCTGCCTACACCAAAAAAA AAAAAAATTATTTGCTACACTTTTTTAGGCCCTTCATTTCTGCATACATTTCTATGTTCT CTTTTTCTATACTCCAATAGACTATCCCCTTCTGTTAATACCCACCTGTTTTCAGACAAG TGTCAAAACCACTGATTAAGTAGTGGTTTCCTTTAAAATCAAACACAGCAATACCTCTTA GGGTGGGTTACTACTACTGATGCTTCCCTTAATCCTTACTAGGGATACAGCAGTATAAAC TTAATCCCCCCTACCAGTGTTCTAAGTACAACTTTTAGATTCAGTATAGTTAGTTCTACT TGACATACATTTATTTCAGTCAACAACCTGTGATAGAGACATATGATTAAAAAGTACAGA GGAAACCATGAACAGTTAAGAAAGTGAAAAATGGTCCTCTGGAGAATAAGACAAGGGATA TAGAAAAGCTGGGCAAAGAATGACTGCTTTTCCTTATAAGTCTGTTTGTAATACTTGATT TTTAAAAACCTGCCTACATGTATTACTTTTTTAATATTACTACAGTAAAAAGGAAGTGGG GGGAAGCTCATTTATTCTTCCCCCTCCCTAAATATTAACACATTTTATTTTGAGAAACAT TTTTACTAATTAGATTCTGGATCATTAAGCAATCTATGCTACTGCATTTAAAAAACGTAT TGAGTAATTCACCCAAAGTAATTTTCCCTATAATGGAGCATTCCAAATTTTTAAGCAGAA TAGAAAGAAAATAAAGCAAACACTTTAATTGGCTGCAGAGATATTCTTAAAAGATTATGA CAAACCTCGGCCAGGCGTGGTGGCTCACGCCTGTAATCCCAGCATTTTGGGAGGCCGAGG TGGGTGGATCAGTTGAGGTCAAGAGTTCAAGACCAGCCTGGCCAATATAGCGAAACCCCA TCTCTACTACAAATACAAAAAAATTAGCCAGGAGTGATGTCGGGCGCCTGTAATCCCAGC TACTCGGAAGGCTGAGGTAGGAGAACTTCTAGAACCCTAGGGGCGGAGGTTGCAGTGAGC AGAGATCACGCCATTGCACTCCAGCCTGGGCGACAGAGCCAGACTCCGCCTCAAAAAAAA AAAAAAAAGAAAAAAGAAAAAATATTATGACAAACCTCTATTTTTGCATTCTAACTACCT CATTCTTTTTCATTTAATATTACTGAGGAAGTTGATTCCAAACCTAATCATTATTCATTG AAAAACTAAAGAAAAAAAAACAAAAAACTAGTCATTTCATTTGCTTTCAGAAGCATAATA AAAATAAACATGAAGGGGGTTTCATGATTATTCAAATTTATAGACGGAATCTATAAAACA TAACCAAAAATATTGTCCTGTGTGATATTACTTGCTCCTCTACATTCCAACTACTGGGGA ATTAAAAATAAGTGTCATAAACAGTTTCTTAGACATCTTAAAATTCTATCCTGCAACTTT GACTTTATAATCCAACAGGAAGGAAAGTCTGAAGTATCAAAAAGAAAATTGACGTGAAGC ACAAATCTATATAACCTAACTCTGACACTTTGAACAGAGCAAACATGTTTAGCTGCAATA ACAACAACAATAAAACAACAATAATAAAGGTTTCAAAGTCCTGTGCAAAAACAAGCTGAG TCTTCCCTCTGGAAAATAGATAATTTAACAACTTTACAGAAGGACCTGACACCACAATAC TCCCGTGCTAAATTATTCTCTTAAAGCACCTGCAAAGCAGAGTAATCTTTCACATCCAAA AGCCACTCCCTGCTCAAAACCACCCGCATCCAAGCCGAACCTGAGACCTCACCAGCTGCC CTACCTCCAGCGCGCTCTCCCCCGACCCCACAGCAGCCCCTCGCGGAGCTCTCCTCTGCT GTCTTCCTTTTTCTTTGCCAAGAACACCAGAAAAGGGGGTCCCTCCAGCTCGGCCGTCCA GACCCTTCCTCTGGCTCAGAGCAGTGGCGAGCCCATCCCAATTCCGCGCTTCCTTTGCAG GCCTCCCTCTGGCGTGGGGACCCTCCTGCTTTCCTATGCAAGTACTAACCAGGCCCGACC CTGCTTAGCTTCTGAGATGAGACGAGGTCGGGGGTGTTCAGGGTGGCACGGCCGTAGACC CTCTGGCTTTCCGCCGCTCCACCTGGCACTCCGAGAGCTAACGCCAGCGATGGAGTCCGC GCCACCCCTGCCCCGAGGCCTCTGCCCCAACTGCGTGGCCGCTCAACTCTCCGCTTCCTC CCGCCCGCCTCTCCACCCCACCCCGCCCCTGGCCCTGTACCTGGAGCTCCAGGCCAGGTA CAGCTGGCCTGCCCACGCCAGCTTCCCAGCTGATGCCTGGCGCTGAGCAGCAGTCTGACA TGGAGAAGGCGGAGTCCTTCCGGGGTCAGGAGTGCGAAGGTGGAGAGAAAGTGGAGGGGG CCTTCCAGGCTTTCTGCGTGAGGGACTACGTGTGAAGCAGCTCCCGCCATTTTTGTTTAG GGTAGAGGCTCCTTCCTCGTCAAGTGGATGCAAAAACTATATTCGAAGAATTGCATCCTT TTACAAACCGGTAAAAAAAAAAAAAAAAAACTAGTATTGTAGTTCGTAACCTGTCGGGGG ATCTAGAACGGTTGTCAATCTGGTAAAAATTATGGAGGGTTTCCCCTGGAAAAAAAAAAA TGTGTATACACATGCTCATTACATTAAAGAAAAAAAAGTTACACAATTTCAAAACCCTGA AAACAAGATTAAGAACTTCTACCACAGGCCCTCAGCCCTCAGATGAATGAGTGTTAAGAG GCATTCCAATCCGGTATAGATGATGCATTTATTATTGATTTCATGTCCTCTTTACCTTTT TTTCTGTGTTTCCCACTGAATTAGGCAACCGAAGAATATTGAATGTGGCAATTTATTGGC AGAGTAGTCACCTCTCTCAGGTTCTAATACATAGTAAACTAATAGGGGGCCGGGTTAGGA AAAAATAACAACAACAAAACCCAAGGTACTGTTTCTACGTTCAGTCTTCAGTCAAAACAT TCCATCAGAACTGCAGATTTAGGCGGGGCACGGTGGCTGAAGCCTGTAATCCCAGCACTT TGGCGGGCCAAGGCGGGCAGATCACTTGAGGTCAGGAGTTCAAGACCAGCCTGGCCAACA TGGCGAAACCCCATCTCTACTAAAAGTACAAAAATTAGCCAGGCACCTGCCTGTAATCCC AGCTACTCGGGAGGCTGAGGCAGGAAAATCGCTTGAACCCGGGAGGCGGAGGTTGTGTGA GCCCAGATAGTGCTACTGCACCCCAACCTGGGTGACTAGAGTGAGACTCTGTCTCAAAAC AAAAAACAAAACAAAACAAAACAAAACAAAAAAACTGCAGATTTAAGAATTCCAGTTGCT GAGCATATTTGTGGTGAAAAGCCAAAATAATTCTGTTTTCAAAATTCCCATTTAACCAAA TGGAAAATAGAATAGTAGTACCAATTTATGATATTATTAGATTAATAATAACTAACGATC CACAGACTGGGTTTTATGTGAAAATATTTTGCACTTATAGGGTAAATGGAGCTCTTGAGA CTTGAAGAACCTGAAATTTGTAAGGCTATTTTCATTTATTTTCCCAATTTCCTCCTCTTT CCCATTTCCCACAGCTTCCAAACATTCAACGTAATGAGAATAGCAGTAATGATGATGACT ACCACTCAACACAACTTTCCTGAGACCATATTATCTCCTTAATTCCACAATAAACATTAT GAGAAAAATAGTATTACACGGTGGGTACAGAGTTTATTCTTTAGCATGAGAATAAGATAT GTCACATTTAGGCCAAGTGAGGTGGCTCACATCTGTAATCCCAACACTTTGTGGGGCCGA TGAGGGAGGATCCCTTGAGGTAAGAAGTTCGAGATTAGCCTGGGCAATAGCAAGACCCTC ATTTCTACAAAATAATAATAAAATATATAAAATAGAAATATCACATTTAATTTATGTTTA TAAACCAAATGTAATTTGCTGTAAGCCTCCCTTCTTCTGGTTTGGCAGAGTACTGCACTC AATCTTAGCCATTATTGGATATATTAGTTAACATATTCGCTACAAGTAAAAGAAAACCAA ACAAGTAGTGGTTTAAACCAGAAGGACAGGGGACTCAATGTCTTCTGATATTGGAGACAA GGAAAAAAAAATTGGAGCCTGGATTAATTCTGAAGGCCAGTACCTCCCCCAGATAACCAA GCCATCGTGTAATGCTCACTAAACCAGAGAATGGAGTTCATGGAGTACTACCAGTTGTTT CTTCTGTACAAGTACTGCAATACATGCTACAGCAACCATTAATGAATTTAGGGGATCCTA TCTGCATAATATCAAAACAAAACTGTGAAGTCAGACTGCCTGGGTTTGAATCCTTTCTTG GCCACTTACTAGATGCATTGTTAAAGGAAAAGAAACACAAAGCTATTTTTCTGTAGTTTC AACACTTCTGACTCCAAATGTGTGGAGGTTTTTCCCCACCAAACAAGTCTCCAATTATTT CTTATTATAAACTCCACTCTTTAATTTAGTGTCTACCAACTGGGTGTTGTACAGTTAAAT TTAATTCAATACTATGCACCAAACCCTTAAGGGCTCAGTCCTACAAGACTGCCCCCACTT CAGATACCAATTGCAAATCCCAGGTTGTCACTTGTACTTCTGACCAACCAGCTATAAATC AGGAATTCCCACAATCTTCTCCTCCCATCCCAAACCAGTCTATTGATTTATAACAGAAGA TATTACAAAGGATACAGATGAACAGCCGGATGAAGAGGTACATAAAACAAGATCTGGAAG GATCCTAAGTGCAGGAACTTCTGTCCCCATGGAATCAGGGTGTATGACCTTTTTGGGATA TGGATGTGTTCACCAACTCAGAAGCTCTTAGAACCCCGTACTTCAGGGATTTCTGTGGAG GCTTCATAATGTTGTTACCAGAAAGGGGTACCAATCCAGATCCCAAGAGAGGGTGCTTGG ATTTCGCACAAGAAAGAATTCAGGGCAAGTCCACAGTCCAAAGCAAAAGCAAGTTTAAGA CAGTGAAGTGGTGAATGTCCACTTACTCTATAGACAGAGTAGGGCGTTCCCAAAAGGAAG AAGAGGAATGCATCCACTCTAGGTACAATATTCATTTATAGAGGAGTTAAAAAAAAAAAG ATCATGGGAAGATGTGCTCTGCTACGAGGGTTTGTGGTAAAAGATTAATTTTCTTAATTA CCATATTTTGCAAGAATTAATATTATTATCTTTAAAGCAAAATTAGGAATGCTTTTGCTC TCAAGGTATCAGGGACATCAGGACACTCCCAAGTCTGGGTCTGTTTAGTAAACATTATCA ATCTGTTCCCTTAACTGTAAATGTTTAGAAGCTAGAAATGCCTAACTTTCTGGGAATGCA GCCCAGCAAGTCCCAGCCTCATTTTCCTAGCCCGCACTCAAAACGGAGTCGCTCTGGTTT GAACCCTCTGACAATGTAACCATAATTGATTATTAACTCAATCTTCAACTACTCTCTCCT CCACAGAGGATAGGGTAGGTATGGGGCCAACATTTTTAAGCTTCTAATCATAGCTTGAAT TTGCTGGTGACCAGCCCCTATCCTGAAGCTATCCAGGAGCCCAACAAGAATATTAGAAAA AAAGACACTCCTATCAACCGGGAAATTCCAAGAGATTTAGGAGCTCTGTGTCAGGACTGG GGACAGAGAGCAAATATATATCTTTTCTTTCTTTGTTTCTTTTCCTTCTGTCTGTCTCGT TTGCCTGCCTGCCTGCCCGCCCGCCTTCCTTCCTTCCTTCCTTCCTTCCTTCCTTCCTTC CTTCCTTCTTTCTTTCTTTGTCTCTTTCTCTCTTTCTTTCTTTCTTGCTTTGATACAGGA TCTCACTTTATTGCCCAGGCTGCACTGAAGTAGTGTGATCATAGCTCACTGCAGCCTAGA ACTCCTGGGCTCAAGTGATCTTCCTGCTTCAGTCTTCTGAGTGGCCAGGACTACAGGCAC TTGCCACCATGCCCAGTTAATTTTTAAAATTTTAGTAGAGACAATGTCTCCCTATGTTGC CAGGGCCTGGTCTCAAACTCCTGGGCTCAAGTGATCCTCCCACCTCAGCCTCCCAAAATG TTGGGATTATAGGTGTGAGACACAGTGCCTGGCCCAAATATGTATTTTTTATGTCACAGT GGTCTTCAGCAAGGTACTTACCCTTTTCATGTCTCAATTTCCTCCTGGCATGTTAGAAAG ACAAATATAGGCCTGGCACTGTGGCTCACACCTGGAGGCCGAGGTGAGCAGATCATTTGA GGTTAGGAGCTCGAGACCAGTCTGGTCAACATGGTGAAACCCCATCTGTACTAAAAATAC AAAATTAGCCAGATGTGGTGGTGCGTGCCTGTAATTCCAGCTACTCGGGAGGCTGAGGTA GGAGAATCGTTTGAATCCAGGAGGCAGAGGTTGCAGTGAGCCAAGATCACGCCGCTGCTC TCCAGCCTAGGCAACAGAGCAGGACTCTGTCTCAAAAAATAAAAAGAAAAAGAAAGACAA ATATAGTAATGCTTAGAAAGAACTAAGAATCTTATGGAAAATTTTTTTTTTTTGGAGACG AAGTCTCGCTCTGTTGCCCAGGGTGGAATGCAGTGGCACGATCTCGGCTCACTGCGACCT CCACCTCCCGGGTTCAAGCAATTCTCCTGCCTCAGCCTCCCAAGTAGCTGAGACTACAGG CGCATGCTGCCATGCCAAGCTAATTTTTTGTATTTTAGTAGAGACAGGGTTTCACTGTGT TGCCTGAGCTGTTCTCAGACTCCTGAACTCAGGCAGTACGCCTGCCTTGGCCTCCCAAAA TGCTAGGATTACAGGTGTGAGCCAACGCACCCAGCTCTTATGGAAATTTTTCACTTGAGT ACTTGGACCTCCATAGGATCCAAGGAGGCAACTGTATTTCAATATAGTTGGTTTGCCTTG TAATCCCATGTATTTGTTTTATGCACATAGAAGCATTACTTTGAAAAGGGGGTCCCAGAC TCTACCAGAAAGCCAAGAGGTCCATAAAAAAAAAAGGTTAAGAATGTAGAACAGACTGCT AAGACCGCGTCCACCCCGCGAGCACAGAGCTCCGCTGCCCTTCCACATCTGTGTGATGGT GGGCATGGGTCAAAAGGACTCCTACGAGGGTGATGAGGCCCAGAGCAAGAGAGGTATCCT GACCCTGAAGTACCCCATAGAGCACAGCATCATCACCAACTGGGATGACATGGAGAAGAT CTGGCACCACAACTTCTACAACGAGCCGCGTGTGGCTCCAAGGAGCACCCGTAGTGCCGA CTGAGGCCCCCCTGAACTCCAAGGCCAATCACGAGAAGATGACCCATATCATGTTTGAGA CCTTCAACACCCCAGCCATGTACATGGCCATCCAGGCCATGCTGTCCCTGTACGCTTCTG GCCACATCGTGATGGACTCCAGCGACAGGGTCACCCACACTGTGCCCATCTACGAGGGGT AGGCCCTCCTCCAGGCCACCCTGTTTCTGGACCTGGCTGACCAGGACCTGACTGATTACC TCATAAAGATCCTCGTGGAGCGCCGCTACAGCTTCACCACCACCGCCCAGTGGGAAATCG TGCATGGCATCAAGGAGAAGCTGTGCTACGTCACCCTGGACTTGGATCAGGAGATGGCCA CGGTGGCCTCCAGCTCCTCCCTGGAGAAGAGCTACTAGCTGCCCAACAGCCAGGTCATCA CTATCGGCAAGGAGCGGTTCCACTGCCCCAAGGTGCTCTTCCAGTCTTCCTTCCTGGGCA TGGAATCCTGTGGCATCCAAGAAACTACCTTCAACTCCATCATGAAGTGTGATGTGCACA TATGCAAAGACCTCTACGCCAACACAGTGCTGTCTGGCGGCACTACCATGTACCCTGGCA TCGCTGACAGGATGCAGAAGGCGATCACCACCCTGGGGCCCAGCACGATGGAGATCAAGA TCATTGCTCCTCCCGAGAGTAGATACTCCATGTGGATCAGTGGCTCCATCCTGGCCTTGC TGTCCACCTTCCAGCAGATGTGGATCAGCAAGCAGGAATACAATTAGTCCAGCCCCTCCA GCCCCTCCGTTGTCCACCGCAAATGCTTCTAAGCAGACTTTTACTTAGTTGCATTACACC CTTTCTTGACAAAAGCTAACTTGCATGGAAAACAAGATGAGATTGGCATGACTTTTTTTA TTTTTATTTTTTTTTTGAGGGGGTGTCTTGACTCAGTATTTTAAAACTGGAACGGTGAAG GTGAGAGTAGTCAGTTGGAGTGAGCAAGTGAGCATCCCCCAAAGTTCTACAGTGTGGCCC AGGACTTTGATTGTACATTGTTCTTTTTTTTAATAGTCATTCCAAATATCGTGAGATGCA TTGTTACAGGAAGTCCCTTGCCCTCCTAAAAGTCACCCCACTTCTCTCTAAGGAGAACGG CCCAGTCCTCTCCTGAGTCCACACAGGGGAGGTGACAGCATTGCTATCATGTAAATTATG TAATGCAAATTTTTTTTTTGAAATGGAGTCTCGCTCTGTGGCCGATACTGGAGTGCAGTG GTGCAATCTTGGCGCACTGCAAGCTCCGTCGCTTGGGTTCACGCCCTTCTCCTGCCTCAG CCTCCCGAGTAGCTGGGACTACAGGCGCCTGCCACCACGCTCGGCTAATTTTTTGTATTT TTAGTAGAGATGGGGTTTCACTGTGTTAGCCAGGATGGTCTTGATCTCCTGACCTTGTGA TCTGCCTGCCTCAGCCTCCCAAAGTGCTGGGATTACAGGTGTGAGCCACCGTGCCCCGCC GCAAAATTTTTTTAATCTTTGCCTTAATACTTTTTTATTTTGTTTTATTTTGAATGATCA GCCTTTGTGGCCCCCTTTTGTGTCCCCCAACTTGAGATGTATGATGAAGGCTTTTGGTTT CCCTGGGAGTGAGTGGAGGCAGCCAGGGCTTACCTGTATACTGACTTGAGACCAGTTGAA TAAAAGTGCACACCTTAAAAAAAAAAAAAAAGAACATAGAACAATCCTGGCACATATTTC TAAGATATATGGCATATTAAATGAGACCCTTCAGTGCGTCTTTTAACAGAGGCTCCAAAG CTGAGAAAAATAAATGTGAAGTACCCTGAGCATTCTAAAAGAGGATGCCAGACCATCCCC ATAGGACATGCTGGAAGACTGTGAAGCCAGTTTAGCAATCCTCAGTTCTCACACACCTCC CAGGAATGATATGTCAGGATTGATGAAAGAAGGTTGTAGAATAAACATGCCTGGAAGGGC CAGGCTTGGTGGCTCATGCCTGTAGTCCCAGCACTTTGGGAGGCTGAGGCAGGTGGATCA CTTTGAGCCCAGGAGTTCAAGACCAGCTTGGGCAACATGATGAAAACCAGTCTCTGTAAA AATGCAAAAACTAGCTGGGTGTGGCTGGGCACACCTGTAGTGTCAGCTACTCGGGAGGTT GCGGTGGGAGGATGACATGGGAGGGTGATGGCATGAGCCCAGGAGATGGAGGTTGCAGTG ATCCAAGATCGTGCTACTGTACTCCAGCCTGGGTGACAGAGCCAGACCCTGTCTCAAAAA AAAAAAAAAAAAGCCTGGGAGACAGTTTTCTGGAGTGCTGTGCATTTTTGTTCCCCTTCC CCAGGAGTGGGAAGAAGAGAGTGCTTATCCCACGCCATCTCCACCTCAAGCCAAGTAAAG GAACTTTAAGAAATTCAGACAGGTTGACTCTGTGCCCTGGATTTATGTTACCTGGAAAAG TCTAAAAGCAATAGGCTATCTAGAGAAGCCTTTGATGGCAGAACAGAGAGAGAGAGAGGC CTACAACAGAAGGGGCCTGTACTTGCAACTTTGCAAGAAAAATTTTCCTGTGGACCATGT GAGTGTCACAGAATGTAGCCAGGCTTGAATTATATTAGAAGGTTGTATCTTCAAACCAGG TTTAAATTGACCATCTAAATGTTCAGCCACAGGTTTTTTTGTCCAGGATTGGGGAATGAA ACAGTAAGAGGTCCCCAGCAAAGGAGACAGTCATTGAGGAACATACAAAAGGGACAAGAA AAGAGCCAGCATCTAGGAGTGAGCCACATGCAGAAGGTACCAAAGTCAGACTTGTTTTTA TTTATTTATTTAGATAGAATCTCGCTCGCTCTGTCACCCAGGCTGGAGTGCAGTGGCACA ATCTTGGCTCACTGTAACCTCCACCCCCTGGGTTTGAGTGATTCTCCTTCCTCAGCCTCC CAAGTAGCTGGGACTACAGACTCATGCCACCACATCCAGCTAATTTTTCTTTCTTTCTTT TTCTTTTTTTTGAGATGGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGTGGTC TCGGCTCACTGCAAGCTCCTCCTCCCGGGTTCAGGACATTCTCCTGCCTCGGCCTCCCGA GTAGCTGGGACTACAGGCGTCCGCCACCATGCCAAGCTAATTTTTTGTATTTTTAGTAGA GACGGGGTTTCACCATGTTAGCCAGGATGGTCTTGATCTCCTGATCTTGTGATCTGCCCC CCCTTGGCCTCCCAAAGTGCTGGGATTACAGGCATGAGCCACCGCATCTGGCCCTAATTT TTGTATTTTTAGTAGAGATGGGTTTCACTATGTTGGTCAGGCTGATCTCAAACTCCTGAC CTCAAGTGATCTGCCCACCTCGGCCTCCCAAAGTGCTGGGATTACAGTCGTGAGCCACCG TGCCCAGCATCAAAGTCAGATTTAATTGCACTGGTTGGGTATATCTGATACTTTATTTAG AATAGTTAGGGTCGGCCGGGCGCGGTGGATCACAGCTATAATCCCAGCACTTTGGGAGGC CGAGGACGGGCGGATCACAAGGTCAGGAGAGCCAGACCATCCTGGCTAACACCGTGAAAC CCCGTCTGTACTAAAAATACAAAAAATTAGTCAGGCGTGTTGACGGAGGCCTGTAGTCCC AGCTACTCGGGAGGCTGAGGCAGGAGAATGGCGTGAACCTGGGTGGCGGGGCTTGCAGTG AGCTGAGATCGCGCCACTGCATTCCAGCCTGGGCAACAGAGCGAGACTCCGTCTCGAAAA AAAAAAAACTAAGAATAGTTAGGGTCACTGCTCATTCCATCTGAAACAATATGTGGCCAA TGTACTTCATGAATGATTGATTAGTGGAAACAACATTTATCAAGTGACGACATTAAGCCT GAAGAAAGAAGTCTAGCACATTGAGGTTGTAAAAGCAATTATATCACCTAAGTAGATGAA CACTTTTAGGTAATTTGTAGCTCCAATTACTTTTTCTACTAACTGCAAAAACTTGGCAGT CCCCAGAAATACCTCAGGGCCTCCTTTCAAATATATACAATGCTATAGGTCACATATTGG CCATTATAGCTTTAGTCTCACTAACCTCTGAAAGTATTTTACAGGACCCTTCTATGAGTC AGAACTAAGCTAACCAAGGCATCTAGAACTCAAAGTATGGTTTTAGATGCTAATTTAGAA CATCTATTCAGAGTATAGTGGTATGTACATATCCAAATACTACAGATTCAGTTCCTCAAA ACGTTAAATACAGAGTTAGCATATGGTCCAGCAATTCTACTCCTAGGTAATACCCAAGAG AAATGAAACATACGTTCATACCAAAACTTGTACATGAATATGCATAGCAGCATTATTCTT TTTTTTTTTTTTGAGACATAGTCTCACTCTGTCACCCAGGCTGGAGTGCAGTGGCACGAT CTCGGCTCACTGCAACCTCTGTTTCCCAGGCCCAAGTGATTCTCCCATCTCAGCCTCACG AGTAGCTGGGATTACAGGCACCCGCCATCATGCCAGCTAATTTTTGAATTTTTAGTAGAG AGTGGGTTTCACCATGTTGGCCAGGCTGGTCTCAAACTCCTCGCCTCAAGTGATCCTCCA GCCTGGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGACATCGTGCCTTGCCTAGCAGC ATTTTTCTTTTCTTTTTTTTTTTTTTGAGATGGAATCTCACTCTGTTGCCCAGGCTGGAG AGCAGTGGTGCAATCTCGGCTCACTGCAAGCTCTGCCTCCCGGGTTCACACCATTCTCCC GCGTCAGCCTCCCGAGTAGCTGGGACTACAGGCGCCTACCACCATGCCTGGCTAATTTTG TTTTTGTATTTTTAGTAGAGACAGATTTTCACCGTGTTAGCCAGGATGGTCTCTATCTCC TGACCTCATGATCCACCCGCCTCGGCCTCCCAAAGTGCTGGGATTACAGATGTGAGCCAC CACGCCCGGCCTCAGCAGTATTCTTAATGGCCAAAACATAG wise-2.4.1/test_data/Q8NAN2.pep0000644000175000001440000000130207646472464015455 0ustar philippusers>Q8NAN2 Q8NAN2 BAC03880.1 Desc: Hypothetical protein FLJ35093. MSDCCSAPGISWEAGVGRPAVPGLELQIRRGAMSEETVSESQFSLKTAALRVFDLPLTWY YSLSQIKFSPVAKKLFVVTAVSAISVIFLAHHFKRKRGKKKGKILPWEPEHLILEYTKRA ASDKGSSCSSSRQNLTLSLSSTKDKGSQVCNYANGGLFSKYSGSAQSLASVQSVNSCHSC ACGNSNSWDKADEDDIKLVNIPVTTPENLYLMGMELFEEALRRWEQALTFRNRQAEDEAC GSIKLGAGDAIAEENVDDIISTEFIHKLEALLQRAYRLQEEFEATLGASDPNSLADDIDK DTDITMKGNVEDFGLRDTLSIASTDSFASAAELAEHREVRHTYSLESLCHCPFYEEAMHL VEEGKIYSRVLRTEMLECLGDSDFLAKLHCIRQAFQVILSESANRIFLAESGRKILSALI VKARKNPKKFEDVFDEMIYFLEQTDHWGSTEMELAARGVKNLNFYDVVLDFILMDSFEDL ENPPTSIQNVVNNRWLNSSFKETAVASSCWSVLKQKRQQMKIPDGFFAHFYAICEHISPV LAWGFLGPRNSLYDLCCFFKNQVLLFLKDIFDFEKVRYSSTETLAEDLMQLLIRRTELLM AYLEADALRHTSSCLSSHGHVMSTGLLEAKVQ wise-2.4.1/test_data/dummy_hox.dna0000644000175000001440000000630010011413266016507 0ustar philippusers>mm3_dna TCCAGTCTGTGCCAGTTAGGGTGCCCTACATACAAACTGTGCCAGTCACTGTGCCTCTCA CACAGCCTATGCCTGTTACTGTGCCACAGGCTCAGTCTATGCCTGTTCCTGTGCCCCACA TGCAGCCTATGCAAATCGACGTGCCTCAAACACAGCCTATGCCAGCTCCTGTGTCCAGTG CACAACATAGAGCAGTTAACGAGCCTAGCATACCACATATGCCAGTGCCTGGTGAACTGC CTACATCAGTCCTGATGGCCTGTGACTCATCCATACCAATAGCAGTGCCCCCGCATACGG CCAGTTTTGGTGTCCACTGTACAGCCTGTGCCAGTGCTGGTGCCCCACCGCCCCCTCCGG GACGGATTTACAGAGCCACAGCTGCAGGAGCTGGAACAGGTTTTCCAGAGAAACCACTAT CTCCGTGCTGAAGAAGGGTAAGCACAGTGAGACGTCAGTGCTTTAAGGAGGGAGCAAGCT GGTACAGAGGCCTCTGACCCTCTGGCAGCTGTCCTTCTTGTCTTCATTTATTAGAAACTT TAAATTACATTTTAAGTGTTCTTATTGCCTGGGCTTTTTTTTTCATCCGGGGTGGAGGCA TGATATGTGCCCnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnCTCTGCTGCAAGCAGGATTATCTGCTGAG TAAACTTGCCTGCCTCCACATTGCCTTCTAGAACTAAGGCTAAAACTAAGAGCAGTCTTC CAGCCTGCCAGACCCTGCCTTGCTGTCCCAGGGCTCTGGGATGGGAGTGGGAGCTATGCT AAAGGCTGTGCAGCTTGTAGTATCTACTTGGAGCAAGTAAAACCTTTGTCAGAGTCTCTT GATAGTACCCTGCTAATGAATCACACTCACTTGTACAAAGTGAGTGTCCCAGAGGTTAGG AGATTGAGACAAATATTTTCTTAAATATAAACTGTCCTTTATGCTTTACTTCATCTGTGG TGCCAAATATTGAATATCTGTCATTTTTTTTTTGTCTCAGAAAACAGCTGGCAAGGGGAA CGGGTGTGACTGAGGCCAAGTTGCAGGTGAGTAAGAAACAAAAAGCCATTGATATCCCAG CCATTGGAGAACTTCCTTCAGGGCTCAGATATGGTTGTTCTGTTCCTGAAGTTACACTGT TCATTTTGTGTCACTGTATGTCAAAATGACTAATTTTATACAGTTCTTTTAAAnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnTTGnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnTAGTAGG CTTCTCAAAATAATTTTTTCAGACCTGTGGTCTTTGTGGGTAGAAAATTAGGTCAGAAGG CTCACTATGCAGTTTGGGCACAATTCACATGGAATGTACCTTGCTGGGACAATATAGGGA AGTTCCCAGGCAGAGCTCAGCACCCAGAAAACTGAAGTTGAACAGGGACCTGGGGTGTGG GAATGTAGGAAGGACACATTCTAAAAGGCTAGTCCTCAGGCTAGTGCCTACTGAAACCAT GCAGATAAGGACACCCATCAAGATAACTCTCGTGACCACACAGGTGCATCTGCCCAAAAG TGCTGATAAGAAACTTCAGAGGGCTCCAGAGTAGAGATATAAACCAGGTGTGCAGTGCTT GGTTGATTGTCCGGGAACTATTTTGCAATGCTCGGGCCAGAAGCCTGGGGCTCCCACGTT CTAGGCAAACCGGCGCTCAGTACCAGGCCTTCAGCCCCTCACAGAATTACAGCAGTGTGA CACCAGGGTCTTCTGAGCAAGATAATATTAATATAAATTCTATTGATGTAAAGTATAGAG GGCAACTAATATTACATGATGTGGTTTCTGATGTATAATCCTGATTATGATACAGAACTA ATCCCTGTTCCCTCTCATTGTAGAGATGGTTTAAGAAGAGGAGAGTGCAGTTCAGGAGAG AACACAGTCAGTCAAGGATGAATGATGATGCCCCACCCAGGACCCACTCCACCTCTCTGA AGATGGCGCAGGAGCCCTAGTGTACCACCCTTGACCAGGAGCCACTTGCTTGCTTCCACC AAAGTGTTATTGCATCTTTATTCCCTAAGCACTTGAATGTGAAATAAATAGATTCTCAGG TTTATTTGCCTCAGGTGTCTTCTGGATTGGTATGGTAGGGGTGGCCCTGGTCAAGGAAAT GCCATTTATGTATTTAATAATTAACnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnGnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnn wise-2.4.1/test_data/rrm.HMM0000755000175000001440000007040607313404503015175 0ustar philippusersHMMER2.0 NAME SEED DESC LENG 77 ALPH Amino RF no CS no COM hmmbuild -F HMM SEED COM hmmcalibrate --seed 0 HMM NSEQ 90 DATE Tue Jul 28 13:08:41 1998 XT -8455 -4 -1000 -1000 -8455 -4 -8455 -4 NULT -4 -8455 NULE 595 -1558 85 338 -294 453 -1158 197 249 902 -1085 -142 -21 -313 45 531 201 384 -1998 -644 EVD -46.934628 0.231361 HMM A C D E F G H I K L M N P Q R S T V W Y m->m m->i m->d i->m i->i d->m d->d b->m m->e -16 * -6492 1 -1085 390 -8597 -8255 -5793 -8424 -8268 2395 -8202 2081 -1198 -8080 -8115 -8020 -8297 -7789 -5911 1826 -7524 -7140 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -10 -11651 -12693 -894 -1115 -701 -1378 -16 * 2 -2141 -3785 -6293 -2252 3225 -2495 -727 -639 -2421 -540 -675 -5146 -5554 -4879 -1183 -2536 -1929 266 75 3171 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -10 -11651 -12693 -894 -1115 -701 -1378 * * 3 -2542 457 -8584 -8273 -6055 -8452 -8531 2304 -8255 -320 101 -8104 -8170 -8220 -8440 -7840 -5878 3144 -7857 -7333 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -10 -11651 -12694 -894 -1115 -701 -1378 * * 4 -1506 -5144 -1922 -559 -1843 2471 -3303 -2213 1099 -5160 -4233 371 -4738 -531 1150 168 497 -4766 -5327 -1476 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -10 -11651 -12694 -894 -1115 -701 -1378 * * 5 -3724 -5184 300 -3013 -1656 1803 -3353 -5245 -1569 -2686 -4276 3495 -1963 -1331 -1055 -1472 -3664 -4803 -5369 -2 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -10 -11652 -12694 -894 -1115 -701 -1378 * * 6 -1569 -6106 -8967 -8363 555 -8530 -7279 653 -8092 2953 -79 -8220 -7908 -1643 -7682 -7771 -6460 -60 -6191 -6283 - -151 -504 230 45 -380 399 101 -621 211 -470 -713 278 399 48 91 360 113 -364 -299 -254 - -188 -3120 -12694 -1602 -577 -701 -1378 * * 7 -410 -5129 -216 -2987 -1709 -957 689 -5188 -396 -5144 -4224 729 3053 -2862 -3409 354 1293 -1368 -5321 -4644 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 8 -3674 -5118 -992 638 420 -4652 175 -2051 404 -1039 -936 15 1755 167 146 -275 197 -1473 1889 1976 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 9 -408 -5134 2416 1299 -951 -67 -768 -1296 -2889 -1844 -4224 1083 -969 -1439 -1854 540 -315 -2305 -5320 -60 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 10 586 1804 -6294 -623 -1627 -1671 -4374 1029 -2223 -162 1172 -5147 -5554 -1870 -5058 -2327 1741 1687 -4242 686 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 11 -2134 -5144 845 -1187 -1652 -1667 -3303 -5216 -514 -795 -4233 1026 -1874 -543 -620 574 2956 -4766 -5327 -4644 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 12 -3671 -5144 1091 2489 -1652 -2235 -614 -2170 736 -1364 -4233 -448 -197 1030 -116 -639 -1350 -4766 1408 -424 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 13 -139 -5144 1643 2050 -5465 -1429 503 -5216 529 -3223 -1448 -672 -4738 1874 72 318 -2111 -4766 -5327 -4644 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 14 -122 -5142 2117 1852 -5462 -1085 -933 -2288 33 -526 -556 -741 -4738 1222 -3392 -175 -13 -2228 -371 -4643 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12694 -894 -1115 -701 -1378 * * 15 -7174 -6526 -9596 -9028 -233 -9481 -8154 1634 -8870 2831 -817 -9215 -8388 -7557 -8326 -8917 -7014 708 -6536 -6798 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -29 -11652 -6305 -894 -1115 -701 -1378 * * 16 -654 -5013 -1860 728 725 -2293 -688 -1185 1801 -278 -4116 -790 -4754 -2884 1825 -463 -1785 -443 -228 1361 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11634 -12676 -894 -1115 -1520 -619 * * 17 156 -5127 2135 1476 -5448 -1490 -3286 -5199 301 -1956 -539 -894 -1058 1509 523 -467 301 -4749 -5310 -4627 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11634 -12676 -894 -1115 -355 -2197 * * 18 -49 -3785 -6295 -483 1590 -5504 919 1218 -2312 1809 48 -5147 -5554 -4880 -2068 -1575 -765 -208 -55 1201 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11652 -12695 -894 -1115 -701 -1378 * * 19 -2248 972 -6369 -5735 4218 -2298 -4439 -1757 -5331 -309 167 -5219 -5618 -4948 -5129 -4658 -1929 -3250 -4292 -388 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -11653 -12695 -894 -1115 -701 -1378 * * 20 255 -5143 -3519 977 -5463 1064 -3304 -2365 1047 -2653 -4232 -150 -4738 556 446 1868 -1288 -2163 -5326 -1696 - -147 -500 232 42 -381 398 105 -627 212 -464 -721 275 393 45 95 360 117 -367 -295 -250 - -30 -6298 -12695 -2206 -352 -701 -1378 * * 21 -1055 -5144 363 870 -1814 -296 88 -2404 1818 -5160 -4233 811 1390 1737 -1608 -672 -664 -2375 -5327 -1696 - -149 -500 232 45 -377 398 105 -627 212 -467 -721 278 393 45 98 358 117 -370 -295 -250 - -101 -4064 -12695 -35 -5398 -701 -1378 * * 22 -394 1434 -6258 -2307 2972 -2527 18 850 -2195 -1152 -2991 -1854 -5549 -852 -5045 -2353 -3896 -124 -189 2915 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11653 -12695 -894 -1115 -701 -1378 * * 23 -686 -7736 -1743 -713 -8353 3518 -5401 -8354 -5879 -8207 -7642 -312 -61 -5106 -6911 -1501 -6164 -7685 -8411 -7292 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11653 -12695 -894 -1115 -701 -1378 * * 24 -1108 -5144 202 908 -1789 -9 -90 -1263 1341 -1905 -4233 -889 1908 170 58 -98 -240 -190 -5327 -4644 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11653 -12695 -894 -1115 -701 -1378 * * 25 -3958 -549 -6303 -1346 278 -5505 -4377 2725 -2224 -925 -753 -5151 -2077 -4885 -5062 -2366 -1362 2525 -4242 -488 - -147 -500 232 45 -381 398 105 -627 212 -466 -721 275 396 45 95 359 117 -370 -295 -250 - -181 -4722 -3786 -436 -1938 -701 -1378 * * 26 -1474 -441 -3586 1371 -4982 -2414 -3303 -26 1318 142 13 193 -4719 -534 -233 -510 590 1465 -5027 -4420 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -30 -11544 -6304 -894 -1115 -978 -1022 * * 27 -252 -5076 1198 1096 -5397 75 696 -1292 -903 -5092 -4165 1380 -4669 -1298 633 1609 -628 -2391 -5259 -408 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11580 -12622 -894 -1115 -146 -3376 * * 28 1071 1843 -6303 -5667 722 -2648 -4376 2229 -2340 233 704 -1807 -5555 -4884 -5062 -1098 -1943 1558 -4241 -1380 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11653 -12695 -894 -1115 -701 -1378 * * 29 -3674 -5121 814 520 -935 -4651 -961 -1319 1431 -346 -888 797 -4744 589 1471 -313 15 -53 -490 25 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11653 -12696 -894 -1115 -701 -1378 * * 30 -1650 -3784 -6302 -5666 -660 -5505 -883 2173 -2226 1326 2112 -5150 -2048 -4884 -1867 -1552 -1875 1962 -4242 -3899 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11654 -12696 -894 -1115 -701 -1378 * * 31 -1062 1014 -6187 -2356 294 -5488 -892 1176 270 -8 1951 -1951 1337 -4822 -158 103 -2109 1363 -4252 -389 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -11654 -12696 -894 -1115 -701 -1378 * * 32 -2113 -485 -887 -660 -313 -2330 4 216 1012 -767 -210 897 318 -1357 1259 -194 786 -575 -384 1141 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -385 -11654 -2146 -894 -1115 -701 -1378 * * 33 -3418 -4896 3351 -318 -5215 -38 -454 -4967 425 -1472 -3988 1322 -4470 -2584 -1616 -1737 -3359 -1060 -5078 -4391 - -149 -500 233 43 -381 398 105 -627 210 -466 -710 275 396 48 96 359 117 -370 -295 -250 - -6445 -6022 -52 -1512 -623 -3426 -141 * * 34 -917 -1040 -1721 -1348 -308 -2080 3449 2217 -869 -531 -149 -1289 -2221 -942 -992 -1266 -896 -117 -927 -176 - -149 -500 233 43 -381 398 112 -626 210 -466 -721 275 394 49 96 359 117 -370 -295 -250 - -1925 -466 -7803 -81 -4198 -4405 -70 * * 35 -967 -1693 -1132 1236 -1732 -2031 -688 1976 1397 -1583 -848 -833 -2123 -387 -642 -1032 -898 -1161 -1951 1843 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -22 -7816 -8858 -894 -1115 -4785 -53 * * 36 -956 -2397 1003 1096 1076 -1925 -592 -2444 1146 -2406 -1491 1168 -2022 -138 -688 -841 883 -2011 -2588 1366 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -8245 -9287 -894 -1115 -4786 -53 * * 37 -1195 -2633 -1023 1475 -2947 -2157 1927 -2685 1620 -219 -1727 1082 -2254 -361 -866 -1079 1430 -2252 -2815 -2147 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -8564 -9606 -894 -1115 -4748 -55 * * 38 148 -2828 622 702 -3148 140 -984 -2899 -575 -2845 -1922 -943 1895 1141 -1086 298 1312 -2450 -3015 -2329 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -8826 -9868 -894 -1115 -1050 -952 * * 39 -728 -4361 -876 -277 -4682 -1609 -2520 -1531 1841 -4377 528 -738 1309 667 1725 185 220 -1588 -4544 -799 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -47 -10802 -5465 -894 -1115 -1242 -792 * * 40 260 -4712 -766 1352 182 -593 -2877 -1008 128 -553 -3801 1185 -530 1095 -445 -108 -231 124 -4896 -1159 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11194 -12236 -894 -1115 -2259 -338 * * 41 -3332 -4804 -266 -1353 -1285 -574 1070 -1856 94 -1034 -3893 692 -712 -1013 -797 -43 2997 -4426 -4988 -4305 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11291 -12333 -894 -1115 -2412 -300 * * 42 -700 -4862 333 -817 -5182 2524 -526 -1783 1384 -1745 -1075 843 -4458 -1046 -289 -1110 -1656 -1990 -5046 -1079 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11354 -12396 -894 -1115 -1798 -489 * * 43 -1173 -4941 -1557 -979 -604 -1468 897 -5013 1954 -1803 138 307 -249 945 2036 159 -396 -2175 -5125 -1380 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11438 -12480 -894 -1115 -2153 -367 * * 44 -761 520 -3503 -1614 -70 -1372 716 -1913 -458 -751 -273 1054 1094 -2810 -251 2278 206 -4308 -4988 -4372 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11480 -12522 -894 -1115 -924 -1080 * * 45 -1321 -5058 -425 -2897 -779 -2289 -317 -5123 2371 -1002 9 253 -678 -469 2287 -733 -567 -1327 -5244 -1405 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11573 -12615 -894 -1115 -133 -3507 * * 46 -3719 -474 -1497 -3192 -1667 3251 -869 -2155 -912 -2777 -3939 410 137 -1344 -4 -3684 -3658 -1329 -5082 -4493 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11655 -12697 -894 -1115 -701 -1378 * * 47 -3885 489 -2062 -1402 3077 -5253 102 -857 -811 -1171 40 -1665 -5319 82 -1004 -890 -625 -88 -201 2651 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11655 -12698 -894 -1115 -701 -1378 * * 48 2530 2194 -7362 -7062 -5394 2351 -5850 -614 -6668 -2653 -4600 -5981 -6144 -6241 -6416 -2409 -2154 -359 -5895 -5591 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11656 -12698 -894 -1115 -701 -1378 * * 49 -2230 -3786 -6302 -5666 4039 -5506 -4377 -646 -2109 -1078 -2988 -5151 -5556 -4884 -1887 -2366 -1143 -672 -4243 1795 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11656 -12698 -894 -1115 -701 -1378 * * 50 -1604 877 -8576 -8264 -6059 -8440 -8511 1855 -8244 -398 -860 -8092 -8163 -8212 -8428 -7826 -5871 3314 -7851 -7323 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11656 -12698 -894 -1115 -701 -1378 * * 51 -580 -5144 386 2159 -5465 -4645 -873 -1019 675 -3028 -4233 265 -4738 606 423 -82 1329 -935 -5327 -1448 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11656 -12698 -894 -1115 -701 -1378 * * 52 -7789 -427 -8717 -8877 4014 -8544 -4968 -5805 -8477 -2591 903 -7303 -8291 -7255 -7885 -7792 -7647 -1406 -4199 2905 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11656 -12698 -894 -1115 -701 -1378 * * 53 294 -5144 1172 1873 -905 -1521 942 -1481 948 -2782 -4233 -271 -458 -130 -424 -612 571 -932 -5327 -4644 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11656 -12698 -894 -1115 -701 -1378 * * 54 -3672 -5145 1936 61 -5467 -4646 -792 -5217 217 -5161 -4234 1953 -4739 -97 -7 1513 1248 -2330 -5329 -1478 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11656 -12698 -894 -1115 -701 -1378 * * 55 -1002 -5136 -1209 1439 -1656 -2269 1514 -739 1051 -828 10 -1550 1188 501 -508 130 -1282 403 -5321 13 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11656 -12699 -894 -1115 -701 -1378 * * 56 -141 -5143 1634 2314 -5463 -1920 -848 -1167 -1176 -2873 -1145 -776 -610 -1383 1036 196 -1750 -567 -388 -1421 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11657 -12699 -894 -1115 -701 -1378 * * 57 397 -643 2370 785 -1819 93 -852 -2168 -2927 -2707 -1041 -291 -2126 422 -3428 1295 -683 -1543 -5269 -636 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11657 -12699 -894 -1115 -701 -1378 * * 58 3055 -3784 -6300 -5664 -618 -5504 -4376 -1075 -5259 -1172 1495 -5149 -5554 -1856 -2150 -501 -298 32 -4242 -1298 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11657 -12699 -894 -1115 -701 -1378 * * 59 209 -573 1015 1604 -5465 -1967 -792 -304 1161 -1413 -4233 571 -1837 1303 -112 -2225 746 -2280 -5327 -4644 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11657 -12699 -894 -1115 -701 -1378 * * 60 993 -5141 565 -83 -1740 -4645 693 -2288 2343 -1443 -1038 178 -4739 -566 595 -98 -1095 -1488 -5325 -378 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11657 -12699 -894 -1115 -701 -1378 * * 61 3262 2020 -6694 -6082 -688 -5928 -4850 -126 -5698 -2502 -659 -5582 -5963 -5332 -5512 -1610 -4263 -115 -4698 -4352 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11657 -12700 -894 -1115 -701 -1378 * * 62 -1537 -3785 -6300 -5664 -787 -5505 -4376 2170 652 1595 832 -5150 -5555 -869 -1636 -2575 -3898 1605 -4242 -1299 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11658 -12700 -894 -1115 -701 -1378 * * 63 57 -5144 1386 1323 -5465 -2265 -3303 -780 812 -1898 -4233 131 -4738 1747 1061 108 -1766 -898 -5327 -793 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -326 -11658 -2388 -894 -1115 -701 -1378 * * 64 1233 705 146 1044 -1391 -414 -504 -4926 814 -1850 -873 617 -4450 472 -255 605 234 -2178 137 -4356 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -11349 -12391 -894 -1115 -123 -3612 * * 65 -376 872 -6218 -1442 516 -5480 -4348 -3270 -294 2248 2716 -5104 -5531 -342 -2307 -4562 -1171 -333 -4233 564 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -11642 -12685 -894 -1115 -382 -2105 * * 66 -2168 -5145 1779 -1715 -5466 -1556 1109 -5217 -347 -5161 -4234 3166 -102 1099 -928 -614 -1767 -4767 -5328 -411 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -11658 -12700 -894 -1115 -701 -1378 * * 67 -1458 -5144 -1823 269 -984 2974 159 -5216 311 -5160 -4233 840 -4738 -1432 -954 -817 -981 -4766 -5328 -610 - -148 -501 232 42 -379 397 104 -627 216 -467 -722 274 395 48 95 358 116 -365 -296 -251 - -173 -3301 -12701 -21 -6139 -701 -1378 * * 68 -674 -5080 -1102 -629 453 -1645 1132 200 1615 -1342 445 -3310 -4756 952 1120 -19 662 -1561 -5281 955 - -149 -500 232 43 -381 398 105 -627 210 -466 -721 275 396 45 95 359 120 -366 -295 -250 - -36 -6244 -12701 -1519 -619 -701 -1378 * * 69 -3696 -785 -17 1147 150 -1499 -3377 542 1043 -698 460 -737 -351 445 -584 -975 753 88 793 482 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -11659 -12701 -894 -1115 -701 -1378 * * 70 -3956 -3787 -1147 -2465 2322 -2554 -4371 1615 -2185 1495 -818 -5139 -2094 -4870 -2110 -2380 -1416 1282 -4244 800 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -11659 -12701 -894 -1115 -701 -1378 * * 71 -1015 -904 926 187 -880 1153 -650 -5215 676 -787 923 1723 -676 247 420 -1029 -1336 -4766 -5327 275 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -11659 -12701 -894 -1115 -701 -1378 * * 72 -2168 -5150 604 -1055 -5471 2762 -702 -5222 -918 -2141 -4239 1981 -4742 -142 -1740 262 -2027 -4772 -5333 -4650 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -11660 -12702 -894 -1115 -701 -1378 * * 73 -1412 853 -3523 -1170 -883 -4647 1925 -5199 1786 -1944 -937 587 -4740 633 2508 -313 -306 -4755 -5321 -528 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -11660 -12702 -894 -1115 -701 -1378 * * 74 -302 -498 -1750 1022 -866 -4653 -3313 -1357 1140 -1447 -4209 233 1336 -200 700 -1400 1160 451 -5307 -378 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -11660 -12702 -894 -1115 -701 -1378 * * 75 -1686 925 -1227 -5667 -1443 -2425 -4376 2317 -5261 1910 668 -5151 -2133 -1674 -5061 -2536 -2111 1191 -5 -3899 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -11660 -12702 -894 -1115 -701 -1378 * * 76 -2255 -5128 -302 363 -784 -2353 1397 -2058 1512 -314 -275 -1693 -1201 -571 1807 -524 252 -175 -256 793 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -11660 -12703 -894 -1115 -701 -1378 * * 77 -626 879 -2198 -5620 -1457 -5498 -4367 1846 -2705 -312 -2992 -5128 -1361 -1689 -695 -1594 53 2770 -4246 -3903 - * * * * * * * * * * * * * * * * * * * * - * * * * * * * * 0 // wise-2.4.1/test_data/hn_est.fa0000644000175000001440000000075707313404500015616 0ustar philippusers>hs_est GAGAGGGCGAAGGTAGGCTGGCAGATACGTTCGTCAGCTTGCTCCTTTCTGCCCGTGGAC GCCGCCGAAGAAGCATCGTTAAAGTCTCTCTTCACCCTGCCGTCATGTCTAAGTCAGAGT CTCCTAAAGAGCCCGAACAGCTGAGGAAGCTCTTCATTGGAGGGTTGAGCTTTGAAACAA CTGATGAGAGCCTGAGGAGCCATTTTGAGCAATGGGGAACGCTCACGGACTGTGTGGTAA GAGAGATCCAAACACCAAGCGCTCTAGGGGCTTTGGGTTTGTCACATATGCCACTGTGG AGGAGGTGGATGCAGCTATGAATGCAAGGCCACACAAGGTGGATGGAAGAGTTGTGGAAC CAAAGAGAGCTGTCTCCAGAGAAGATTCTCAAAGACCAGGTGCCCACTTAACTGTGAAAA AGATATTTGTTGGTGGCATTAAAGAAGACACTGAAGAACATCACCTAAGAGATTATTTTG wise-2.4.1/test_data/rpo_fugu.gen0000644000175000001440000000342207571667333016364 0ustar philippusers>SINFRUG00000074967 TCTCTTACTTCAGCTAACCTTTATTCCTGTCCAGGGCAGACCCCCACCACTGTAGGTTCT CCTCCACATGCTTCCTGCCCTCACGATGGATCAAGGGGTCATCTGCAGTCATCGTGGTCC GCGGAGATTCCTGTCTAACCTCATCTGTCATCCTTTCGACCATAATGACCACATATTCAA ATTTGTTTATATAAACATGACTAAGGATTATGATATTGTGCTGTAATAGTGCCAGCTTGT GGAGGTCAGGTTCTTGTACCACTCTGATTTAGACTGTAGGTAATTCTGAGTTATCCTCTG AGTTAGAATTTATGATCATATTGCATGCATGCATTTCCTTTTTTAATATATGAGGTGGTT CTTTTATATTAATTATTGCAATTATTTGTCTTTTTTTTTCAAGGCTAAGAGAAAGAAGAC GAGTCAGTCAGAAAAACCATCCAAGAAGCCAAAGAGCGGAGAGAGCTCAAAGCCAGGTGG TTCTTCTAAAGGCAGCGGTAATGGAGATGACAACATGTTCCAGGTGGGAGACGCTTTAGC TGTTCAACTGAAAGTGGGTTGGAGGAATGTGATGAGACAGTTCTGTGCAGTGGTCCCACT ATAATCAGGAGCCAATTCTGAACAGTTCTAGTTTTATTTTAGTGCTGCACATCCGAAAAT TTGCCAGTCAATCTGTCAAGTCAAACCATGTACCCAAATGTTATAGAAAACCTCAGAGTT CCTTTAAAGAGCCTCCAATTCTAACTTCCTTTCACTTAAATGTTACAGGCTTTTGACTTA AGACAATGTTTTTGTCAGCTAAAGTTTTTACTTACCTGACACCTATTCACACACTTGATG CAGGATGGCAACAGTTCATCAGCTAAGATCATCACTCACATTCATAAGCCAAATTCTTAT AGTTCTAGGTAGACAGACATAGAGATCAGGGGAATATCAGGGCTGTAAAATAGACCCAAC CAGTGGAACCTTAACAGCTGCCACCTTTCTATTGCATCAGTGACTGATGAGGCTCACTGT GCTAACATTGGAAGCAGGTCATTGATTGCGTGCATGAAATCAGGACAAAAATAAATTGTG TTAACACCTCTGAGGCTTTAAAACTTGCTAAATCTAAACTCCATCGCATAAAGTAAATCA CAAAGCTGTTAAATAATGTGAGCAAACGAATGATGGTGAAATGACAATCAAAGGAGGGCA ACGTTAAACCACCAGTCCTAAAGTCAAATAAACATTTTGCTCCTTACAGATTGGAAAGAT GCGATATGTGAGTGTCAGAGACTTTAAAGGGAAAGTCCTGATTGACATCAGAGAGTACTG GATGAACCAGGATGGAGAGATGAAACCTGGGAAAAAAGGTAATCGTTCAATACTGACATT CAATCGGTGTAATTACATGGTGAAACAAATATATTTACTTCAGACACATGTAGAAATCAT CCTTAAAGTAAAGTATACTAACGGTGTGAGTCTCCTGCATTAACTCTGCAGTCAGAAATG TGTCGGACCCTTAAACCATTTCATATTTGTTATGCTTCAATCTATAGTAAAAATGTAAAA AAAAAAAAAAATCTTCACTCAGTACCAGTAAAATAATACAGTGAAAATAGGAATTTTAAC TTTTTCAAATGTGTTAAATGCCCATTTATCAGCTGTAAGATGTTGGTAATGGAGACAGAT GTCAAAAGAGCTGACCTGAAAGGTCCTCGGGTTGAAAAGTCCTGGGGGTCAAAAAACTGC CTCCAGAGTTCAGAGACTAT wise-2.4.1/test_data/xeno.cdna0000644000175000001440000000256207346730061015634 0ustar philippusers>EM:XLHNRNPA M31041 X.laevis ribonucleoprotein A1a protein, complete cds. ggagtcaccatgcacaagtccgaggcacccaacgagccagagcaacttcgcaagctgttc attggaggcttgagttttgaaaccacagatgaaagtctccgcgagcactttgagcaatgg ggcacccttacagactgtgtggttatgagggatccaaactcaaaacgttcccgtggcttt ggatttgttacatacttatctacagatgaagtagatgctgccatgactgctcgcccacat aaagtggatgggcgagtggttgaacctaaaagggctgtctctagagaggattcctctagg cctggtgcacacctcaccgtaaagaaaatctttgtaggtggtatcaaggaggacacagaa gaagatcatttacgagaatatttcgagcaatatggcaaaattgaagttatagagataatg actgaccgaggcagtggcaagaaaagaggctttgcatttgtcacatttgaagatcatgat tccgttgacaagattgtcatccagaaatatcacaccgtcaacaaccacaattctcaagtg cggaaggcactctccaaacaggaaatggcaagtgtttctggcagtcagagagaacgtggt ggctctggaaactatggaagccgtggtgggtttggtaatgataactttggtggtcgtggt ggcaactttggtggcaacagaggaggagggggtggatttggtaatcgaggttatggtgga gacggctacaatggtgatggccaattatggtggcagccctccctactcgggtggaaccga ggctatggtgctggccaaggaggtggatatggtgctggccaaggaggtggatatggtggt ggtggccaaggaggtggatatggtggaaatggaggatacgatggttataatggcggaggc agtggcttcagtggctctggtggtaactttggtagcagtgggggatataacgactttggc aactacaacagtcagtcatcatccaactttggcccaatgaaaggtggaaattatggtggt ggcagaaattctggaccatatggaggtggctatggcggagggtctgctagcagcagtagc ggatatggcggtgggaggaggttttaatttttccacaggggaatatccatctacatgatt aaacgaaacgtggaccttggtttgtgaagcagtgttcagatacaggttttaaggttaact gatgtgacggatctgaccaacttcaaatttcacagctactgtgtagctctgttttgtttt tttgttcttttccaaaataaagtttttatgattctcta wise-2.4.1/test_data/epo.pep0000644000175000001440000000066007557456631015336 0ustar philippusers>EPO_HUMAN P01588 Q9UHA0 Q9UEZ5 Q9UDZ0 CAA26095.1 CAA26094.1 AAA52400.1 AAC78791.1 AAF23132.1 AAF23132.1 AAF23132.1 AAF23133.1 AAF23133.1 AAF17572.1 AAF23134.1 AAF23134.1 AAF23134.1 AAD13964.1 Desc: Erythropoietin precursor (Epoetin). MGVHECPAWLWLLLSLLSLPLGLPVLGAPPRLICDSRVLERYLLEAKEAENITTGCAEHC SLNENITVPDTKVNFYAWKRMEVGQQAVEVWQGLALLSEAVLRGQALLVNSSQPWEPLQL HVDKAVSGLRSLTTLLRALGAQKEAISPPDAASAAPLRTITADTFRKLFRVYSNFLRGKL KLYTGEACRTGDR wise-2.4.1/test_data/road.pep0000644000175000001440000000060107313404503015450 0ustar philippusers>roa1_drome MVNSNQNQNGNSNGHDDDFPQDSITEPEHMRKLFIGGLDYRTTDENLKAH FEKWGNIVDVVVMKDPRTKRSRGFGFITYSHSSMIDEAQKSRPHKIDGRV VEPKRAVPRQDIDSPNAGATVKKLFVGALKDDHDEQSIRDYFQHFGNIVD INIVIDKETGKKRGFAFVEFDDYDPVDKVVLQKQHQLNGKMVDVKKALPK QNDQQGGGGGRGGPGGRAGGNRGNMGGGNYGNQNGGGNWNNGGNNWGNNR GGNDNWGNNSFGGGGGGGGGYGGGNNSWGNNNPWDNGNGGGNFGGGGNNW NNGGNDFGGYQQNYGGGPQRGGGNFNNNRMQPYQGGGGFKAGGGNQGNYG GNNQGFNNGGNNRRY wise-2.4.1/test_data/rpo_h_f.anchor0000644000175000001440000010511507571671427016654 0ustar philippusers>5.32372381-32389772 TTGAGGTGGGTGAAGTGGGGTAGGAAGACCATTTCTGGGAAAATGGGCCAGAGTATTGAT CTTTTTCATTATGACCCCTTCGCTTCATTAGAGTAAACATTTATTGAACAAACGCAAAGC TTGGCGCTTGTCACTCATGTTTTATTGGCGTTTTCCTTTTTTTTAATTTTTTTTTAAGCT ATCTCCTACAGGAAGGATATTAGCTCTTTCATTCTCTCAAGGGTCAGATGTAATCTTCCA ACATCTGACTTTCGCGTCACCCATTTAGGAAGAGACGCGGTCCCTTTAAGGCCCTGGAAA GGGTCTAAGTGTTGGTTTCTGTGGGGAGGCCACGCCCCATCACGTGACCGCAGCCCCAGC GCGGCGGGGCCGGCGTCTCCTGGCTGCCGTCACTTCCGGTTCTCTGTCAGTCGCGAGCGA ACGACCAAGAGGGTGTTCGACTGCTAGAGCCGAGCGAAGCGTGAGTGCGCGGGACCCCCT ACCCCTACTCCTCGGGGCCCCCACCCTCCCAGCCGGGCCGTGAGCTGCCTTCGGCCCTCC ACTCCTCTCGCCGGCAATGGCCGCGGGAAATGGCGGCTCTGCCTTACCTCCCCCTTCCCC TCGGCGTCCCCGGCCCCCTTCTCCGTTTCTGACTCCACGCCTGACGCGCTGTGGGCCCTT CCGCGGTAGACTCCTGTCCCCGGGGAGCCGAGTCGAGGCGGCGGGCGCTGCGGCCCGGGG CGGTAGATTGAGGGCGGCCGGGGAGTGAGGAGTCGCGGGGAGAGAGTCGCGGCGTCCCCG GGACAATGCGGCGGCGGCCTGCCTAGGTGGGGCGCGTGCGGTTACCTACTCTTCCCCCGC CCCTCGCCCTGAGCGGGGCGCTCTGGAGACTGGGAGAGCGGATGCGGGCGGGAGGGGGCC GGGGGAAGAACGGCTGATGTGCAGGGGGAGGGAACGCTTCGAGAGAAGAAAATGGCGCTT GGTGCAAATCCCGCCCCTTCCCACGCCGTCTTCTCCGCACTTCGCCGCCTCCCACGCCCC CTCCGACCAACCTGTCTCCCCTCGCCCGAGCGGCTGCTAGCCACGGGGTTCTAGCGGCTT GCTGGGGCCGCGCGACCCCTTCCCTGGTCTTGTGCTTGTCACCTTCCTGTTATACCGAAG TCGTGTGCCCTTCAGTCCTGGTTCATTTTCACCTCGTTTTTTTCTGATCTTTCCCTCAAT CAGCAAAGGCTGAAGATTTCGTTTCTCTTTTTAAAGTTGCGTTTTGTATAAATTCTACAA TAGTGGTTTCAGTATCAGTTACTTGAATTACAAGCTGCTTCTCCCCCCACCCCCACATTG GAACAGGCTCATTAAGGTAAATATATATTTGTTAAAAGTTTAGAGGCTGGTTTTAGTTAC CGTTACCTTTCTTCTCCAGTGGACTTCTTTGGGTTGAGTACCAGGTGGTTCTTTGAAAAA TTCTTAGGCCCCCAGGCAGTTTTTGATAACAGACGGTAGTTATGATCGACAGTTTCAAAG TGAAAAATTATGTTCAATTTAATTACCTTTTTAAAAAATATCTTTTTGTCGTATTAATTA GCATAAAAAACTTAACTAAATTGATTTTAGAGATGAGGTTGCAAAATGGAGCAGAAACAG GAAAAACGGATAAAACGTGGTCATGAACATTGCTTTTCCCTTCTGAATTTACCCTTGAAG ACATTACCAGTTAAAATCAGATTGAGCTTTTTGAATTTAATGGCTAGGATTGGGGTGGCC CACTTCTTTTTCCTTGACCTCCTATTTTGGAACATATGCAATGTCAGTGCTAATGCAAGT TTCATCTAGAGAGCTAGATTATTTATGATTTTTTTTTAAGGAGGAATTTTAAGTCTTTTT TTCTTGTATTAAACAAATACAGTGTGTGATGTGTTTATTAGGCCCTTTAACGCATACAGA AATTAGCTAATTTATGCCTAGTGTTCCATTATTGGAACGCTAAGCATGTGGGAGTTATTT ATGTGCTACTGCTCAAGATCATCGCCAAGGTCTGCTTGCATAAATTCAAAAAATTGCAAC CTCTGGCATAAATGGGTTAATAGGACCTAATCTCTTCTGAGATGGGGAGAGCAAAAGATA TTTTGATAATCAGCGTTTTATGACCTGGTGTTATAAGTGCCTTGAATAGAGGTATCCACG TATCTTGGAATTCCTTGAAATTTGGGGCTTAGGCTTACTGATAGTTTGCTTTCTGCAAAC TTGCACTCAGGCACTCAGTAAACACCCACTTGTAAGCAAGGCACTAAGTTATCTATGTCT CTGGGGGGACCTGGGAAGTTACCAGCATGGTAGGAATTTGCGGGAAGGTTTTGCACCTCC CATAAATAGGTTTTGCACCTCCCATAAATAGGTTCTTCAAATTTTAATTATGTTCCAGAG TAGAAAAATCTGTGTAAAATGTAATGAATTGCTGTGAATTGTGTAAGATTTTTTTTTTTT TTTGAGATGGAGTCTTGCTTTGTTGCCCAGGCCGGAGTGCAATGATGTGACCTTGTGTCA CTGCAACCTCTGCCTCCGGTGTTGAAGCGATTCTCCTGCCTCAGTCTCCCGAATTGCTGG GACTACAGGTGTGCCACCGTGCCCTGTTAATTTTTGTATTTTTAGTGGAGATAGGGTTTC ACCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCTGCTTTGGCCT CCTAAAGTTTTGGGATTACAGGCGTGAACCATCGTTCCCGGCCTGAATTGCGTATAATTT TGTGTACTCTTGAATTAGTACCTGTCGTTATTTTGGTGATACGGCCAAAAAGTCAAAATA TGAATAAAATATTATGTAAAAATTAATTAGATGTCACATTTGCATAGTACAGCTAGTTCC CTGTTGTGTAAATGTTGGGGTCAGTTCCCCATAGTGAATAATTTTACGTTAGTTCCAATC TCGTTGATGAGAAGTCTAAAGCAGTAATAGTAGAATTACATTTCTTCTGGTTTTAATAGT AATTGTTGTCTGCTGCCTTCTTGCAGTTTACCCTACCCATAGTGTGTAATGCCATTAAAA CGAAGTATAGAAAGATCCATTGGCCTGGAGAAAGGTTAGAGGTGTAGGAGTGTATGACAT TTAGTTCATTGTTCTTACTGGGTTCAGCACATTGCACCCTGCGTGTTATTTGCAACTTAA AAGGGTATAGATTAAAACTTGTGCTCAGTGTAACAACTCAGTACCACAAAAATGGTAGAA TGAACCGTGGAACTTGTCCTTGATTTTTTTCTTTGATTGGGGGAGAGCTAAGTTGAAAGT AGTAGAGTACCTTATTAATTATTTTTGTAATGTATTTTTCTTTCAGGATGCCTAAATCAA AGGAACTTGTTTCTTCAAGCTCTTCTGGCAGTGATTCTGACAGTGAGGTTGACAAAAAGG TGACTACTGCTGCACCAAGTCATTTTGGTGATACTCAACAATATTGTCCATATCCCATTC TGAAGGATAGTAAAAGGTGTATTAACATCTTAAAATGAGGATCTAGCTGGGCGCGGTGGC TCATGCCTGTTATCCTACTTCTTTGGGAGGCCGAGGTGGCAGGATTGCTTGAGGCCAAGA GTTCAAGACCAACCAGGCTAACATAGCAAGAACCTGTCTCTTTAAAAAAATAAATAAATA AAAAATAAAAAATAAGAATGTGAATGGGTATTTCTGGAGGTACGGTTGGTCTCTGGACCA CTTGACTAGAAGTGCCTAGGATGCTTTTTGCACATTCATACTCATAGGCCCTAAATCAGA CTTAACAAGTCTTCTGTTGAGCATCATTAGGAACCCTAAAGTTGCAGAAACACTGCCTTG CATCCTAGGGTCATAGAATTCTAAGTAGGCCAAAGTCACTATTTGCCGTTATTTAGAAAT TTACCAGATTTTTTTTTGTAAAATGTTAATTTTTTTTTTTAAAGACAGGGTCTTACTCTC TTGCCGAGGCTGGAGTGTGGTGGCACCATCATGGCTCACTGCAGCCTCGACCTCCTGGTC TCAAGCAGTCCTCCCACCTCTGCCTCCAGAGTAGCTGGGACTACAGGCATCATGCCTGGT TAATTAAAAAAAAAATGTTTTTGTAGGGACCAGGTATTGCTGTGTTGCTAAGGCTGGTCT CAAACTCCTGGCCTCAGGCAATTCTTCTGCCTCAGACTCCCAAAGTGCTGGGATTACAGG TGTGAGCCATCATGAGTGGCCATAAAATGTTAATTTTGACAGTTCTCTTAGTTACTGGTG TTTATTCTGCACATAAGGTTTTCTGAATTTTAGACTTGGTACATTTTTAAGTTTGTACTA AGTTTGTGCTCTGGTCCCTTCCATTTAATTAAATCAGCACGCAGTAAAGCTAACTTGAAA CCCATTGACAAGATAGGCTTTTTCTGCATTAGATGACAGCTGCACCGTAATTGGTGAATT TCGCTAAATTGAGCATCTCAGTGGAGCATAACTGAGCGTCTCACTCTGCGGTCAAGTCTT CCGTGCAGAATTGTCTTTTATCGCATAGAACTTTACATATCTGAAGAGATATTTATATCC TAGAAATAGAATAAGTTGGTCGTGTTTTTCCTAATTAGTATATATCCTTTGTAAAATAGT AAGTAATGACTAGCACTGGTAGACCTGTGATTTCCGAAAGTTTATTCAAAAGAAGCAGGC TCCCTATCTTTTTTTTTTCCTCCTGAAGCTTAGCAATTTTAGCTAAAAGAAAAGGGGAGA GCGTATGGGAGATTGGAGAAGTTGCAACCTTAAAGTATAAATATAGAATATAACAACACA TGGAAGGGTAAAATAAGGCTTCAAAGACTATACTTGAGTAAATTTCTTAATTTTAAAATT TGCACCCTATATAGTATTTGAGTATGTTGATGTAACACATGTGTATTGAGCTTTTATTTG CCAGACATGCACTATTCCACAGGGAATACTTAGAGCCTGATTTATAGAATAATTGCTTTC TGCATATTGAGCTAACTTTTTGTTTGTCCCAAATAGTAATATTACTCTTGTAAACACTTA ACCTTGTATACCACATTTTTCATTTCATGTTTTACATGTATATAATATTTTTCCTAGCTT CATCTAATTTGGTAACATTCAATTAATTTAGTAACATTAAAATATTTATACTATTCCATC AAGAAGGAACATGACTGCCCTCTTCTGTTTGGGTTGGGTATTGTAGTGGTTTTTATGGGT TAGCTCTTTTTGAGAATGCGACTTTCTAATAAGCTTTTAAAATAATGCTGTTTTTAAAAC AACGTTGTGATTTTTGAAAGCTAGTCTAACACATAGCTGTCTACAATGATTTTTTTTTTT TTTGTAATGAGGAAGTTCTTGAGTTGCTGGCTGTCAGTGCCCAGTGCAAAATAGCTCTCT AAAGATTTGCCTAATTGTAAATTCCTTTTTTTTTAATTTTTTATTTTGAGATGAAGTTTT GCTTTTGTTGCCCAGGCTGGAGTGTAATGGCGCGATCTCGGCTCACTGCAACCTTCGCGT CCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTTCCGAGTAGCTGGGATTACAGGCGTGTG CCACCACGCCTGGCTAATTTTTTTTTTTTTTTTTTTTTTTGAGATGGAGTATCGCTCTGT TGCCCAGGCTGGAGTGCAATGGCACGATCTCGGCTCACTGCAACCTCAGCCTCCTGGATT CAAGCAGTTCTCTGCCTCAGCCTCCCTAGTAGCTGGGATTATAGGTGCCCACCACCACGC CTGGCTAACTTTTTTTGTATTTTTAGTGGAGATGGGGTTTCACCATGTGGCCAGGCTGGT CTCGAACTCCTGACCTCAAGTGATCCTCCCGCCTCGGACTCCCAAAGTGCTGGGATTACA GGTGTGAGCTACCGCGCCCGGCCCATAAATTCCTTAAGCCAGCATAAATTCCTTTTGGAA TAGGCAGGACATAAATAAACATATCCTGGAAATGGAATAAGTTGGTTATATTCTTTTTAA TTAGTATATCTGCTTCGTAAAATAAGTAACTGACTAGCCTTAGTAGACTGTGGTTTCCAG GTTTATTCAGAAGTAGCAAGATCCCTCCATTTTTTTTTCTACCAAAGAAATCGTATGTGG GATCCCAAACCACAAAATAACCGTTCCTGTGGTTAATACTACTATAATGCCTGAAGTGTC TTTTGGGATCCTGAGAACAGAGTTTGAAAACATTACTAGACAGAAGGATTGGTTAGATTC ATAGTTTTGTTGTTGAGTGAAACTTGCTTATGTATATATTTATGATATTTTGGATGTAGT CTTTTGATTGTTTAAATCTTAAAAAGTAATGGGATCTTTTGACACTGGGGTATGTTTTAT TTTTATGTGTGCAAATTTTAACCATATTCTTTTCTAGTTAAAGAGGAAAAAGCAAGTTGC TCCAGAAAAACCTGTAAAGAAACAAAAGACAGGTGAGACTTCGAGAGCCCTGTCATCTTC TAAACAGAGCAGCAGCAGCAGAGATGATAACATGTTTCAGGTAAAGTTGGCTATTTTTTT TTTTTTTTTTTTTGACATGGAGTCATGCTCTGTCACCCAGGCTGGAGTGCAGTGGCGCCA TCTCGGCTCACTGCAACCTCAGCCTCCTGAGTTCAAGCAGTTCTCTGCCTCAGCCTCCCG AGTAGCTAGGATTACAGGCATCCGCCACCAGACCTGGCTAATTTTTGTATTTTTAGTAGA GATGGGGTTTCACCATCTTGGCCAGGCTGGTCTTGAACTCCTGACCTTGTGATCCAACTG CCTCAGCCTCCAAAAGTGCTGGGTTTACAGGTGTGAGCCACCATGCCTTGCCAAAGTTGG CTGTTTCTTTAGATTCAGAGGAATTATTATCTGGCTTGATCTGAAGAATGTTAAAAGTAC TATGATCTGATAATTGCCTAATATGTATGTTACAATCTTCTTAACTAGGGACATTTATTA AAATAGAACAAACTAGTAAAAGTATTTTGTACGATGCTGGATTATTGTTAAAGTCTCTAA AGTCTAGTTTTGCTGTATTTAAACCAATGCAAATTTAATTGAGAACTGCACATTTTGAAA GCAACTTGGAGGAGGCAGGTCAAGTGTTGGGACAGTAAAGTATGAATAGATTATTATGGG ACAGGAAGCAGCAATGTGACATGCCTAATTTTGGCCTGATGAGCAACAGAAAAGGGGAAT GGGTTGAATAGATAAAGTGAAGGAAGTTCATTAGAGGGACTTGATGAAATCACCTAGAGA GGACTCGTATAGCTTTTTCTCTTGGGTTTCCTGTCTTGTTTTAGGGAGACTTGACACTGG CATCTTTGTACAAGAAGGATTTGTGAGGAAGGGATGTTGGGGAATAAATGAATGCAGGTG AGATTGCTTAGGTAATTGTAGGCTTTAATCTGTATGTGAGGTGATAAGGGCTTAGATGGT TTTTCCTAAAGAAGAAATTATGCCAATTACAAGATACAGGTTAGGAAGAATGGACCAGAG GAATTAGGCAGTCAGTGAAGATGTGGACTTGATTGTGGATGTGATTGAAAAAAAAAATGG TGTTGCTTCTGTAGCACCTGAAGGGCTTAGTTGGGAAATGTTCATGTGGGATTATCAGCA TGGTTGACTAAAGCTGCCTACTGAAGTATTAAACAGAGGAAGAACAGGAAGCAGATGAGG GGATGTCTTGGGTTATATTCAGATAGAGAATGGAAGGAAAAAGAGGATGTAGGTTAAGAG AGAGGGTGAAGGAAAATTAGAAGAGTGCAGTAATGGGAGCAAGAAAAGGATGAGTGTTTC CAGGAGCTATAAGTATTAGTTGAAACCAAAAAGTTGGGTGGAACGAGACTACAATTTTTT TTTTGAGACAGGGTCTCTGCTCTGTCACCCAGGCTGGAGTGCAGTGGTGTGATCTCTGCT CACTGCAACTTCCGCTTCCTGGGCTCAAATGATCCTCCTGCCTCAGCCTCCTGAGTAACT GGGACTACAGGCAATGCTCCATGACGCCTGGCAAATTTTCTTTGTTGTTGGTAGAAACAG TATTGCCCAGGCTGGTCTTGAACTCCTGAGCTCAAGTGATGCGCCCACCTTGGCTTCTGA AAGTGCTGGGATTACAGGCGTGAGCCACCGTGACTGGCCAAGACTGTAGACATTTATATG ACTAGAAAGTAAGGCTAACACATGTATATTTTGACCTGTTGATAACTTTGAAAGGTGGAG TGCCAAGATTAAGGTGAGAATGGGAAAATTTAAGTTTTTTTTTTCCTATTGCTTATTTTT GCCTTGTTATACTTCTAGGTAAAAAAGATAGACAAAGTGCAGATGAACTATTTAGTTCAG AACACACATTTTAGAGATTCTGTTCTGTTAAGAGGAGTTTTGTGAAAACTAGATCTAATT TTAGGAATTTTCTCACCAGAAAAACGGAGCTTCATTTCTTAAACCCTCATCTGGAAAGAT TCCTAAGCCTCCTAAGGCTGACATTGCACCTTTTGAAAGCCTGCCTCTAGGAGGAACATA GGTCATCTTTTCTTTTTTTTTTTTTTGAGACGGAGTCTCGCTCTGTCACCAGGCTGGAGT GCAGTAGCACGAATCTCGGCTCACTGCAACCTCCGCCTCCTGGGTTCAAGAGATTCTCCT GCCTCAGTCTCCTGAGTAGCTGGGACTACAGGCATGCGCCACCACCCCCAGCCAATTTTT GTATTTTTAGTAGAGACGGGATTTCACCTGGTTGGCCAGGATGGTCTCGATCTCTTGACC TCGCCATCTGCCTGCCTTGGCCTCCCAAAGTGCTGGGATTACAGGTGTGAGCCACGGCGC CCAGCCTAGGCCTTATTTTCAGAGTGGCTTTCATGGATCTAGTAGTGTAGGCATTATGAA ATAATATGATACTTAATTTCATTGCCATTACAGCTTGATGTACATCAAACATCAATACAT AAGCAGTTCTCTAAATGTATTAAAGAGTTGTACCAAAGAAAAATCAATAGACTTATCTTT TAAAGTCTGAAGTGATTGGGGCAGAATCGTGACTAGAGAGAAGATACTAGAGATGCTTAC TTCCTGGTTCCTTCAGCTCTGATTTTGAAGAACTTTCTTCCATAGGGATGTAGTCTACCT GAGGTGACATCTGTGATAGTAAAGAGACTGGAGAATTATCTCATAATTATTTAGTACCTG TGTCTTGAAAGGTCAGAATAGTTGAGGCAGGAAACTTTAATCCATATTTTTCTTCAGAGT TAGGCACAAAGGGTCAGTAATACTGCTTTAGTTTATTTGATGATTTAAGGATACTTGATA CTTTTAAATTATTTAATTTAAAATGATTATAACTGGTCATTTTAATCTGGGGCAGGAGTC CATAGAATTGTTTTTTAATTTGAGTTTTCTTTTTTGTGTTTGAAGGAATTATTCATAACC TTTATCACAGGGGTCCCTCCTGCACAGGAGGTGAGCGGTGTGTGAGTGAACATTGCAGCC CGAGCTCTGCCTCCTGTCAGATCAGCAGCGGCATTAGATTCTCATAGGAGCGCGAACCCT ATTGTGAACTGCGCATGCAAGGGATCTAGGTTGTGCGTTCCTTATTCCTTATGAGAATCT AATGCCTGATGGTGGGATAATTTTTATCCTGAAACGATCACCTTTCCCCTTCCCTACCTG CTGTGGAAAAATTGTCTTCCGTGAGACTGGTCCCTGGTGCCAAAAAGGTTAGGAACCACT GCTTTATCAGATCTTCAGAGGGGACAGGGAATCAAATTCGTATAAGAATCACAGTTCTTT ATGATGTATATGCTATTTTTTGCTGCTAATCTCCAGATTTTGTGGATATAAAATATATTG TCATCTGATTTTATTTTTTTCCAATAAAATGTGATTTCAGTGATCTTTATTTTTTCTATC TTTAAGTAATATATCCCTATACTACTATCTCATCACTTGTTTAATTTTTGCTAATAAGAA TTTGTCAGTTTTACTCTTTTTTTCCCCCCAAGGGAGAGGCAGCTGTTGGGCAGATTCCTT TTTTTTTTAAAAAAAAAAATGTTTTTGAGGTATAGTTTATGTCCAATAAAACGCACACAT TTAAAAGCATACCTTGATAGGCTGTGGTAAATGTACACGCCTTTGTGGCCAGACCATTTT CATCACCCCAGGAAGTTCCTCTTGGCTTTACAGTCATTGCTCATGTCCTAGGTAATCACT GATCTTATTTCTACCACTATAGATTTATGTTGTCTCTTCTAGAACTTTGTATAAATGGAT ACATGCAGTCTATTTTTTGTGTCTGGCTTTTGCTCAGTATAATGTGTTGAGATTAGTTCT TGTTGCATATATCAGTAATTTTATTGCTGAGTAGTATTTTGTATGATAATACTACAACTT GTAAATCCATTCACCTTGGGTGGACATTGGGATTGTATCAAGTCTTGGGCTATTAGGAAT ACAACTGCTGTGAATATTCTTGTACAAGTCATTTTGTGGACATTTTTTCCCTTTTGGGTA AATACCAGATACATTTGCTGAGTCGTAGGGTAAATGTGTAACTGTATAAGACACTGTCAA ACCATTTTCCATAGTAGCTGTAGCATTTTACACAGCCATCGGTACTACTTAGGAGATTCC AGTTGCTCCACATCCTCGCTAGATATTGTCAGTCTTTTAAGTTTTTTTCTTTTTAGTTAC ATTGAATGTATAATGGTAGCTCATGGTGGTTTTACTTTCCATTTCCCTCATGTACATGTC TTAATTCATTGTACATCTTTAGTGTGTTTATTGGTTATTTTTATATCTTTTGTGAAGAGT ATCTTTTGGCCACTTAAAATGCCAGGTCATTTGAGTTGTAACACTTTATATATTTTGTCA GATGTAAGTATAATTAATATTTTTTTTAGACTTCAGGGAAACTTTAGTTTTCAAAGCAAT CTAGTTCAAAAATGAGTGGAGGTTAACAGAGAGGAAAATATGAAACCAGAGAGAATCAAA CAGACAGAATAAGGGGGGACTGGCAGTTGGTCAGGGGCGTCTGTGACAGATCTTCTCTCT CTTGGAAATGAGGTCCTCACGGATTCTGGTCAGTTCATCATTTTCTTCACGTCCACGGTT CTGCTTCTTCCTCAGGCTCTCCTCGAAGGCCAAGACCCCTGTGGCTCCAACTTGAGTGAA TATTTTCTTTAGGTTTCTGGTTTACCTTTTTATTTTCTGAAGCATCTTTTTAAAAAAGGC TTTAGTGTGATTGTCTATTCTATCGATTTTTCTCCTTTTTTGCTTAATGCTTATTTTCTG TCCAAGACGTATTTTGCCTACCATGGCCACAAAAATTTTTGCCAGTGTTTTTTCCTAGAA GTTTTATAGTTTTAGTTTTCACATTTAGGTCTATAATTCATGTAGAATTAATTTCTCTGT GTATGATGTAAGATAGAGATTTAGAGTCTTCCCCACCCCAAATGCAGATAGCCTGTTGTT TCAACACCATTTGTTGAAAAGAGTATTCTTATTCCTTTGAATTACCTTGGATTTTACCCC CTCCCCCCAAAAAAATCAGTGAATATATCCAATGCGTGTGTATTTTTTGACTCCGTTGTG TTCCACTGACCTCTTATGTCTGTCTTTACTCCAGTACTGCATTGTCTTCCCTTACTATAT TATAGTGAGTCTTGGAAAGTGCTAAGAGACACTTTGTTGAGGAAAGCCTGTTCTTTTCTC TGGAATTTGTAATTTGTGGTAAGCAGATATATAAGATTTTTGAAAAATAATTTTCTGTGA ATATTTTTAAGTTCTCAATCTGACTGTGAGTGAGGTGCATTAAAGATGTTATTTGAAGTG AACATGAAAAGGAAAAACTTGGTTGTTATTGACTGGAACTCTGGATTCGTATATTCAGAA TGGTTGGTGAAGCAGTGTAGCTAGTTGCATCTGTGGATTCCTCTTGGTTGTAGTTTGTAC TGCAAAATATTGCTTCCTAATGATTTTTTTTTTTGCTGGTAAAAACCATAAAAGTATATT CACATTGTTGTGAAACAGATTGCCGAAACTGTTTCATCTTGCAAAACTGAACCTCTGTGG CCATTAAACAACAGTTCCCCTTCTCCCAGCCCTGGTAACCACCATTCTACTTTTTGTTCC TGTGAACTTGACATCATGTAAGTGGAATCATAAAGTATTACCTTTTTCCTTTTTATGACT GGCTTATTTCATTGACGTAGTATGTAACAGGATTTCCTTTTTTAAAAGCTAATTGATATT CCATTGTGTGTCTATTCCACCCCCCCTCTCCCATTTTGTTTATCAGTTCATCTCTGGGTG GATATTTGTGTTGTTTCCACTTCTTGGCTCTTGTGAATAATGCTGCTATGAACATGGGTG TGCAGATGTCTCTTGGAGTCTGTGCTTTCAATTTTTTGGGATATATATTCAGAAGTAGGA TTGCTGGATCATATGATAGTTTAAACAGCAATTTCCTTTGGTTGCAGTTTTGATACTGAG AGTAGTACAGTTGACCCTTGAACAATGCAGGGTCAAAATGCAAGGCACCAACCCCTGTGC AGTTGAAAATCTGGTTATAACTTTTGACTTTGTCAAAACTGCTAAGTATAGCCTACTGTT GACTGGTAGCCTTAACAGTAACATAAACAGTTAACATATATTTGTATGTTATATGTATTA TATACTGTATTCTTACAATAAAGTAAGCTAGAGAAAAGAAAATATTACTAAGAAAATCAT AAGGGAGAAAAATTACATTTTACTGTACTGTATGGTGTTTATCAATAACATTAGTTTACG TTGTCTGTTTATAAGATATGTCATCTGTTAATAAAATATGTCATCTGTTAGAAATTGTAG GCAACCACAGCTGCAGATTTCAGTCCGTGGTACATATCAAGCAATTCAACTTTTTTATTT TTATTTTTATTTTTATTTTTTTGCATTTTAAAATTAAAGACAGGATCTTGCTGTGTTGCC CAGATTGGATTCAAGCTCCTGGGCTCAAGTGATCCTCCGGCCTCAGCCTCCTGAGTAGCT GGGATCATAGGCATGCACCACTGCTTCTGGCAGTTTTTTTCTTGTGATGTCATGCCTTCT CTCTGCTTCTTGGGAGCACTTTCAGCATCACTAGGGGCACTTTGTATAGGACTCATGGTG TTATTTAAAGTTTATGGTATTGCAGTAATCATGATGAAAAATAATGTGAAAACCGTGAGA GATCACTTTTTACTGCAATACGCAATTTGTTGGAGACATGAACTGCTCAGCAGAGATGAT TAGCATCACATGGTGTTTTACACAAGGTGTTTTAAGCAGATACTTGTAACATTTGAGTAC ACTGAGATAACAGGAAGTGGCTATGAAGTTAACACTAGTACACTACTGTAGTTAATTTTA TGCAGTTATGAATTAATACTCCATCTTTGTTTACATTTCTCTCTAACTTCATATAATAGA TTTGTATGTTTTATGATAGTAAGTGATAAAATAACCTCATATCTAGGTATGTTTTATGCA TTCATGACATACCTAACTTTTTCTTAATGTTTTCGTTATTTCTAGGCTATGCAGTTGTTC TGTGAGTTTTTTCAAATTGTCAAGTCTGCAAAAATTTTTCCAGTATATTTATTGAAAAAA ATATGCATATAAGTGGGACCTGCACAGTTCAGAGCCATGTTGTTCAAGGGTCAGCAGTAG TCATTTTCATGATTAGATGTAGAGTGAGCATGCAGCAAGTTGTGAATATGAATACAATTG AAACAGATACCACTCTTGAAAGGAGCACCTCTTTTTATGTTTGTTTCTTTTGCAGATTGG GAAAATGAGGTACGTTAGTGTTCGCGATTTTAAAGGCAAAGTGCTAATTGATATTAGAGA ATATTGGATGGATCCTGAAGGTGAAATGAAACCAGGAAGAAAAGGTGAGGTCTAATTACT TGAATTTTATTACAGTGTTAGGACTAAACGACAACTTTTCTGAGTAGCTTACTTGAAATG TTGGCAGGACACACGGGGCAAGGAAGAGTCTTACTCAATTGATTCTCTATCTTCTGTAGT TATTTTGGACATGATACTTAACATTTTTTTAATGAGATGTCTTAATACAGCTTTTGGGAA TAAAACCCAGAAAAGTAACACCCCTAATATCACTTCAGTTGGCTGCTAATTTACTTGAAC AATTTTTAAAAAGGTTTATGCAATTCTGAAGCAGATTAGGCACTATCTGGGAACTTGTAA AATCAGGAATGGAAAATCTTGGTTTACAATGCTTCCTTTTGATTCAGCTCCTAAAAGCTA TTCTTTAGGGCATTACTCTTCAAGCGGATCTCTGCTTTCCTTCCATTTGTGCTTCATCCA GTCCCAAGCCTCTTAGCATTGTAGAAACATATTTTGTATAATTCACCAAACAGCTAGAGA AGGTGAGCCAACCTAAATTTGTATATTTGGATTGCTGCTCTAGGTTGACCCTCAGCTAAA GAAAAATGCTTCCTTATTTAGTTTTATTCTGCCTGCCTGTTAGTTTGAAAGGTACCACTT GTTTGCTTCATGCAGTTTTTTTTTTTTTGGTTAAACTCAGCCTCTATATGTGTTTATATG CTTTCATATTTTCTTCAAGTCACTTCTGGATTGGTAATTCACGTACCAGAGTGGCCGATG CCATATTTCTTGTTTATTCTTTTTTTTCAATTTCATGGCCTTCCAGCAGTTTTCTGGGAA TACTTTCTGCCAGTTCTTGTTTACTTCTCTGTTTATATGCGTCGGTATTGGAATGCTAGA ACGTTAAAGTACAAAATATAGAAAATATAAAATTTCTGTTCATACTTTTACATCTTAAAC TGGAAAGACATATCTCACATTTTTTAACCATTTATGTGTTAGGTGATATGCTAAGTTCAT TATTCATGTTACTTAATCATTTACAACAACTCTTTGGCGTATAGATGCCATTTTACTGGT GAGGAAACTAAGGCTTACAAGGTGATGTAGTTCTTTTTTAAGGGTCATACACTTAGTGAA AGTGAGGCTGGAATTTTAACCCTGATAGGGTGACCCTAGAGTGCAGTTACCCGGGTATAC TCTCTGAGGAGTCCTGTATGAATCACGTCCTGGGAATTTTTCCAAAGTGAAATGAATGCT TCTGGAAGAACTCAGCACAATTGGCTTGAATTCCTGTGGAAATTTTGGGCAAATATTGGA ACCAGCTGGAAATATAGTAATGGGGTATCACATGCCAAATCTGGACCTGACCATTTTAGC CTGATAGTTGACGGGTATTAGTAAGATGTGTCTTCAAACCCTTATTTATTCTCATTGGTT ACAATAGGTACTATGCAGGATGCACTGTGGAAAGTAAGACTGGATATGAGATTGATAATG CTCAGTAAATTGTGATGATATGTAATTAACAAATGTAAGAGATATGATTTTCAGTATTGT AGCATTGTGTCCAAGTGGCAATTTTTTTTTTTTTTTTAGATGGAGTCTTGCTCTCTTGCC CAGGCTGGAGTGCAGTGGCATGATCTTGGCTCACTGTAACTTCCACCTCCCAGGTTCGAG CAATTCTCCTGTCTCAGCCTCTTGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCCG GCTAATTTTTGTATTTTTAGTAGAGATGGGGTTTCACCATGTTGGGCCAGGCTGGTCTTG AACTCCTGACCTCAAGTGATCCACCCGCCTTGGCCTCCCAAAGTGCTGGGATTACAGGTG TGAGCCACCGCGCCCAGCCTAAAGTGGCAATTTTGATAAAACAGTATTCTAGTTGGAAGT ATGAAAATCCTCAACGCTTAAATAGATTTTCACCTTTGAATTTTTAAACTTTGTTTTAGG TATTTCTTTAAATCCAGAACAATGGAGCCAGCTGAAGGAACAGATTTCTGACATTGATGA TGCAGTAAGAAAACTGTAAAATTCGAGCCATATAAATAAAACCTGTACTGTTCTAGTTGT TTTAATCTGTCTTTTTACATTGGCTTTTGTTTTCTAAATGTTCTCCAAGCTATTGTATGT TTGGATTGCAGAAGAATTTGTAAGATGAATACTTTTTTTTAATGTGCATTATTAAAAATA TTGAGTGAAGCTAATTGTCAACTTTATTAAGGATTACTTTGTCTGCCCACCACCTAGTGT AAAATAAAATCAAGTAATACAATCTTAACTGTTGTGGCCTTTTTTGATCATAAGAGTTGG TACTGTTTAAGGCCAAAAGTAACAGTTTTTATAGATCTTTTAGTTTCAACTCAGCTTTTA CAATAAAAAGGATTTGTATTGCATTGAGTTTATAAACTTTTGGTTTGTGAACTTCATATT TGATCTTTTCTCTTCCAATCAAATGTCTAGGCTTGTTTGACTTCCACCCCCAATGGTTTT TCACTCTTTTTATTTACTTCATTTTCCTTTAATAACTTAATCTCTTCATGTTCAGTTTTT ACTTCACTCTTTATTCTTTTCTTTGATTATGGTATGCTTATTTGGAAAGTCAGTGAAACT GTCAAAATGTTATCTCAATAAGATACTTATATGAGAACTACAATCACCGAATCTACTGTA TTCAATATTAGCAGATCTAATTTGATAAACAACATGGCTTGTGTGAAAACTGAGCAGGTG TTTGTTTACCCATAGTGTTCTGTGTAGTTATTGCTTAGTCTGCAGAAAATAATGACTTAG ATGAGATGTCTGACTTGCTTTCACTTATTAAACATGTTCACCATGGGATGATGTCTGTAA CATCAGATATTGTTCAACTAGACTAGGATTTAATAAAAATTGTGAAAGCTTACTGGCCTA ACATTTTATTTTATAATATTGGGTATGAATTATATGTAGCCAGAGATGTCATTAAGCTTT ACTGTTATAGTAGGTAATATGGTTAGTTTGTAGGGAAAAGAGCATATGAGCACATGCTTG TGTATTTTGGCCTTTGCCCCAGTAGAACAGACCAATGGCATTCTAGACTTGATGATACTA AGTTTTAGCAGACACTAGTAAGTGGTTTGTATTTAACCATACTGATGAAGCAGACAGATT GAGGCACAGATTTTAGTGGCTTTGTGGCAATAAATAGGGCATGGTGTGCCTTAGGAAAAG AATGTTTATAAAGGGAATTATAACTGAAATTAAAGGAGGCGGCAGTGAAGAGGAAATAAT TCTCTTCTATCTAAATGATATACATATGATATTTTGAGATTTTTATAACAGCAGTGGAAC ACAATTCTAGGTAGAGTAGAAAAAGGAAAGTTTTAAAGACATATAAAAGATTCTTGTTGA CAAATTATTTTTGGTAGCAAATCTCAAATGGTTACCTGCTATTAAGGTCTGCCATATTAG AGTTTTGCACTATTTTGCTACCAAGTTTGATTCATACATCTAAAACATTTTG >SINFRUG00000074967 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTTAT ATTAATTATTGCAATTATTTGTCTTTTT-TTTTCAAGGCTAAGAGAAAGAAGAGAGTCAG TC-AGAAAAACCATCCAAGAAGCCAAAGAGCGGAGAGAGCTCAA-AGCCAGGTGGTTTTC TAAA--G-GCAGCGGTAATGGAGATGACAACATGTTCCAGGT~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TACAGATTGG AAAGATGCGATATGTGAGTGTCAGAGACTTTAAAGGGAAAGTCCTGATTGACATCAGAGA GTACTGGATGAACCAGGATGGAGAGATGAAACCTGGGAAAAAAGGT~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ wise-2.4.1/test_data/rpo_rat.gen0000644000175000001440000002463507571672477016222 0ustar philippusers>RNOR01068417 TCTTAGTGTGAGTGGAATTAAGTACATTTCTTTTGGTTTTAAAGTAATTTTTCTCAGCTG CTTTCTTGTAGTCTACCCACAAATTTTATAGCCCCTCTACAATCAGTTGTTAAAAAGACC CATTGACTTTGAGAAGGGTAAAGGAATGTGCACATGGCTTTTATTTCTTTGTCTTGACTG GGCTTAGAGTATTTGGCTGTGCTTGTTATTTGCAATTTAGACATGTGTTCAATGTAATGA CTCCAGTACTACAGAAAGGCAGAATGAGCCTTGGAAGTTATTTTGTTTTTTCTGTTTGTT TGTTTTTGTTGTTTTTGGTTTTTTTGGACTGGGAGAGCTAAGATGAAGGTACTAAAACTA CTTGTAAATTATTCATGTGATGTCTTTTTCTTTCAGAATGCCTAAATCAAAGGAACTTGT TTCTTCGAGCTCTTCAGGCAGTGATTCTGACAGCGAAGTTGAAAAAAAGGTGACTTTCCT GTACCAAGTTCTTTTATAGTACAAAATGAATGGTGCATTAATTGCTCTATAATGCCGACA CTGAGTTTTGAAGGGAAAGGCCTGTCAGTCTTTTTAGATAGGTTTTTCTATGCATCCTAA ACTTCTCCAACCACCTCAGAGTTCCCTGAGGGCTGGGATAGTGTTACCAGTGCTGGACTC AGAATGTAAGAGAGAGAATCTGCAAGGGTATTCTGTAACAATAAATGACAAATGGAGTCC TTGAGTAGAATATTAGATTCTAGACTCATTTGCAGGCCTTACGTCAGATTGAGAGGTCTC TGTATTGTACTTGGGGTTCAGCCTAGCAGCCCAGTGCATTCCAGGAAAGTACTTGCCGTA TCTTTAGCCTTCTTTTTACTTTTTATTTGTGACAGGGTCTCAATAAGTTGTTGGGCTGCC TTGGACTTTTGTCCTCATGCCTGATCCAGCTCAGACTAAAGGTGCTCCACCTTTAGTAAC CAGAAGTCAACAGAAATGCTTTCTTAGACTCTAAAGGACCAGAATTCTAATTAAGCCAAG GGCACATTATTTAGAAATCTGTGTCATTCAAAAATCTGATCCTCTAGCCTGCTGCTCAGT GAGCTTGGTCTCGTTCTTCCACGTGGTAGGAGAAGAGACCTCATTATTCCAAGTTTGCCT TCTAACCTCATGTACCCACATACAGGCTTCTCAAGCACAACAATCACAAAATGACAGTAA TAAAATTTCCCCAATCTATAGTTAGTAAGTCACTATTGAGCTGCATGAAGTTTTGAATGA AAACATTAACGTTGACAGGTTTCTCAGTCACTGCTCTCCTTTACCCAAATTACTGAATTT TAGTTTTGGTACATTTTAACATTAACAGTTATTTGCTTTTAGTAAATAAAGTCATTCAGC ACAACAAACACAAAATTAGCTATTTTGTCAGATAAGCTTTTTCTGTGTTAGGTGATCGCT GTTTTGTCAACCTCATTCCACTCAGCTGATCACTGCAGTGAAGTGTGACGGAGCAGTTCA TCTTGTGGTCAAGACTTCCTTCCACACAGCTGTCTCTTAATAGAAATTTATATCTGAATA AACATTCATATCCTAGAAATGGAACAAATTGTATTCTCCCTCTTCGTTGACTTGCTTTGT TGAGAATATGAAGTTAGTACACCTGTAGTTTACAGATGTGTAAAAGCAGCAGGCAAGCCA GTTTCCCAGGTCAGTTAGTAGAGTGCTAGCCTCACACTCAGGAAGTCCCAGGTTTGATCA CCCCTCAGTGGAGATGGAAGCAGGAAGGTCAGAAGTTCAAGGTCACCTGGGATACTGGGG ACCCTGTTTTATTTATTTATTTAAAGCAACAACCCCCTCTTTTTTTTTTTTTTTTTTTTT GGGGGGGGGGCCTCTGTACTAAGAAAAGGGAGCTCTCTAGGAAAATTTAGGAAAGTTGTA GCCTACAAATGTAAAGATAGGCTATAGTATCATAATTTTCAAATAAGGCTTCAAACATCA TACATAGCTGTACTTGAAGTCTTTAGAACTTGGGGCATGCACCAGTCTAGAGGATTGCCT TCTTCCTGAGCTGATTTTGTAGCTTGTCTCCCATAGTACTATTAATCCTATAAACATTTA CATTAAATACATCCACAGCTTTCATAGTGTGTTCTTATCCTAGCCTTAACAAATTTAATT AGTAGGTTTAGTAATATTAAACTAGTTTTTACTTGTCCACTAAGGAGGAGCATGCCTGCC CTCTACTGTTGGGGTTGGGAACTTAATGTGGGTTTTGTTTTGTTTTTTAATTTTTATTTT TTTATTTTTTAGCTCAGTTTGAGAATAAGGCTATATAAAATTCTTTTATACTAGTGCTGC TTCTAAAATATTATGAAGTTGAGTGCTAGTCTTATCACTGTCTATCTTCAATATTCTTAG TGCTGCTGAGGTTTTTGAGTTGTTGATTTTCAGTGCCTGGCATAAGATATCCGCTTCCTT TACCTGGGCATACGCTTCCCCCTGAGATAGAGTTTCATTATGTAGCCCTGACTGACCTCG GGCTTGCTATATAGTCCAGGCTGGAAGCATACATTCTTGGAAACAGTCCAGATTCCTTTT AGAATAGACAAGGAATTATAGTAAGTATTCGTGTTTTAGTCTGAATACATTGGTTATGTT TGTTTTTTGTGTGATCTTCAGCTTTGCTGTCCCAACCTTAGTCAGGCTACAGGGTTACCA GTATGCTTTGTCTCTTTAAAAAGTAAGAGAGTAAGAGGAGAGCTTTGGGCAGACTTGGGG TTTCCACAATTTATGTATACAGAGGGTACAGGCTGCTTCTTCTTACAGAGAGTGCTATGT GGGTTCTAGTCCACAAGCTGACTTTTAATATCTGAGATATCTTTGAGGATATTGAGAATA GAGTGTAAAAACACATCATTAGTTATGTGAAGACTAGATTCATAGTTAACATTTTTTAAT GCACATTTTTTTAAATAAGTCAAAATTTGACTACCTCTTTAATGAAGTGCTTTGAAGTTC ACATGTGTGTATTCTTAACTTTACCTTTTTTTTTTTTTTTTTAAGTTAAAGAGGAAAAAG CAAGTTGTTCCAGAGAAACCTGTGAAGAAGCAAAAGCCTGGTGAGAGTTCTAGAGCACTG GCATCCTCCAAGCAGAGTAGCAGCAGCAGAGATGATAACATGTTCCAGGTAAAGTCAGAT TGCAGTTAGTCCAGTGGGATAGACCCTTGATCTGATAGCACACCACAGTCTGTGTTGTAA TCTTCTTGACCTGTGTTTATTAACAATTGAGTAGGAAGTGAAGGTAATTTGTTCATTTCT GGGCTATTGGTAAAATCTAGAAGTCTAGTTTTACTATATTTAAATGATACAAATCTAAAG GTTTCAGAAAGCACCCCCCCCCCCCAAAAAAAAAAAAAAAGAAAAGAAAAAAGAGAAAGA TTTAGAACTGTATATTTGGGAAGCATATTTGAGTGAGTAAGGTTGAGTATTTGACTGGAA AGTGTAAATTTGATGGCCTAACTTAGGTTTCATAAGAAACAGAAGGCTGGGGACATAGTG TAGGTGTATAGTGCTGGAGTAGCATGTTTAGGCCTGGAGTCTGAGCTTAAGGAAAGGGGA GCAGGTAGGATAGATAGAGTGAGATGTAAACCCAGGGAGGGCTGCTTGGCATCTTGACTT TATTGTGTGTTTTTAGCAACTCAGTATATGCTTCACTGCAAACCCTGTTCTGTGAGGTGA TCATTGTGAGTAAAAAATGATGCTGTGAGATTGTGGAGGCAATTATAGACTTTATTTATA TTGATAAGGAAGAGATAGTGATGCTTACAAAGATGGTGATGAAGAAGGACCAGCCTTGAG TGAGGTAGACCTGATAGTGAATGTGGCCACTGAGGACAGTCTCCTGTAGCACCTGGGGGT CTTGGCTGGGAATTGCTTTTGTTGGCTTTTACATATGCTTGACTAAATAGCCAACCACTG AAGAACACAGAAAACAAAGAGAGGAGGTGATAGCAGGTTATGAGAGATTTGCAAATGGAT GATGAAAGAAGAAAGGATTAAATTGATAAAATGGAGAAAGAAAACTCAAAATAGTGGAGG AAAGAAAGAGACAAAATATAGATTAACTATTATAGGTTTCAATTCTTTGACTTCCGTATA ATTTCAGGGCAAAGGTTAGTTTGATAGAGAATATATAGATGAAGGTATGAGATGAGGAAT TTAAAAGAATGATATTACTGATTCAAATGCGTAATAAATTGGATGCTTACTGTGCTCTGT ATTTCATTCAGGCTTTGCCAGTTTCCAGTATTCCACATGGAATGGGATCTGTAACCTTGT GGAATTTAAGGGGACTGTGATTACACACATAATAAAAATTACAATAAGTCCTGAGAAGTA GTGGGCAGATAGAGTAGGCGTGAGAATCTCATTAAAAGAAGTGGCATCTAAGTCTTAGGA TGTGAAGGTTAAGCCAGCTGTGCAAAGTGTGTGGATAAAGAAAGCATTTTCAAGAGCAGG AAATTGAGTTAATATCTTGAAGTTGGAAGGAGCTTGGGTTGTATATGAATTATAGAGCCC TTGTGGTTGAAGCCTGGGAATTCTTGCTGAGATTCAGAAGTCTATTTGGTGAAGACCTTC CAGAGCCATTTGACTTTTAAGTACAACAACAAACTGGGGCAGGACACATGTACAACTGTA TAGAGTATTTCCTAGCGCTTTGGAATGTCCAGTTCCATAACTGTGTCTCAGCTATCCTTT CATCACTGGTGCTAATGCTGTGCTCTCCTCTTTACTTATAGAACAATGACTCCTTTGACC TGGTGGGGGGTGGGGTCTGAGGTGAGGGTCTTTTATAGCTCTGGCTGACTTGGCAGTCAC TAAGTAGAACAGGCTAGATTTGAGTTTTTAGCAGTCCTCTGCCTCTCCTCAAATGCAAAG GTTGTAGACATGTACTGCCATGGCTTTTAAAGGTTCTGTTTTGCTAGAGACTTTTGAGAA ACGGGGTTTATTTTTAGGGGATGATTTTCTCACTTAAAAAAGAGCCTTGGTTCCTTGGTT CTTTTTTTTTTTTTTGTTTGTTTGTTTGGTTTCTTGAGACAAGGTTTCTTTAAGTAGCCC TGGCTGCCCTAGAGCTAGCTAGCTCTAGTCTATAGAGCAGAGCCAGTCATAGACTCACAG AGATCCACCTGTAGCTTACACCTCCAATTCTGCCTGTTAGGAAGACTTGTCTCAGCCAGT GTTCTATTGCTGTGCAGAGACACCATGACAGCAGCAGCTCTTAGAAAAGCATTGAATCGG AGCTGGCTTACAGTTTAGAGGTTTAGTCCCTTGTTACCTTGGCAAGAAGCATGGTGGCAG GTAGGAAGATGTCTTACTGGAGAGTAGCTGAATTATACATTTGGATCCATGGGCAGCTGG GACAGAGAGACACTGGGCCTGGCTTGAGCTTCGGAAACCTCAAGAGTTCACTCCAGTGAC ACACTTCCTCCAACAAGGCTGCACCTCCTCTTTCAAGACTGTGTTCCCTAATCCTTTAAA ATGATGCCACTCCTTAAGAGCCTAAGGAGGCCAATTTCATTCAAATCATGACAACCGGCT TTCCTTTGAATACTTTGGCTCCTTCCCAGATAACTTGGTCAGTTTATTAAATGTATGTCT TATTTCTGGGCTGCATTCTTAAACTCTTGACCTAAGTCTGGCTGCTTTAGTACCATACTG TCCTTATATTTACTGAATTTAGGAAGTGGAGAAACTAAAAAAAACACATAGCTTGTGTTA AGCCACCAGTATAAATACTTTTTTTTTCTTAAAAGACAGGGTCTCAGTATGTAGGCCCGT CTCTTAGTTACGGTTTTTATTGCTGTGAAAAAGACTCTATGATCATGGCCACTCTATATA TAAAGGAATACTTTTAATTGGGACTGGCTTACAGTTTCAGAGGTTTAGTCCATTATCAAC ATGGTGGTATGCAGGAAAGACATGGTGCTGGAGGAGTAGTCGAGAGCTCTGTATCTTAAT CTGAAGGCAGCAAAAGCTACTGTGATCAACACTGGGTGTAGCTTGAGTATGAGACTTCAA AGCCCAGCCCCCATCCCCACAAGTATGTGCAGTGCTGCAGGACATGTGATCACACTGTGA TCCCTGAGGTTGTGTTATTTACTGGAAAACCTGCTTTTTAGTTGTATGGCTCAGCCTTAG CACATACCTTTAATCAAAGCACTTTCTACTTGAATATTGTAAACAGGATTAAAGTCAACC ATAGTTCAAGGGGGCAGAGCAAACAACCAGTTGACAGGAAGTGACCATAGGATCTTTAAA AAACCATAGAGAGTAAGAGGGAGTTAGGAGGACAGGTAGATGCAAAGGAAGTAGAAGGGA GGGACATTGAATTTGAAGGAGTTTGTTTGAAATGGTGTGAAAGAAGAGGCCATTTCTGGT CGGACTTTGGCTGAGGAGGAAGTACAACTGGTTGCTTTCTCTGCCTCTCTGAGCTAGCTG TTTTTCATCCTAGCATCTGGCTCCCAAGACTTCATTGGTAAAATCAAATAATTGTGATTT TTTTAAAAAATAACAATAACAACAACAGTATACACTTCCTCCAATAAGGTCATACCAACT CTAACAAGGCCACACTTCCCAATAGCTCCAGTTCTGTGGGCTAAGCATTCAAGCTCATAA GATGGTGGCTGTTCCTGTTCACCTCCACAATCTGGGTGACTGGGACTTGTTGTGAGTGAA CCAAGCTGACCTTGAACACAGCTGCCTACCTCCAAGGGGGTTAATTTTTGATGTCTTTGA GTTTACTGTGTTAGGCTGTAGGCATCTAATTTAGGTTGAATCGGATAGTACTGCTGTTAT TCTATGAGTGGCTTATTTCCCTTAGCACCATGCTATAGCATAGACAGGATTGCCTATATG AAGGCTGAATAGTGTTCCATTGCATGTGTAAGCTACAGTATTTGTGTCCTTATTTAAGGA TAGATTTGTGGGTTGCTTCTACTTCTTAGCTATTATGAATAGTGCAATTAGGACATGTAT GATTTTTGGGGGGGGGGGGGAGACCCTACTGCCAGTTGTTTTGGATGTGCTGCAATGTGC TGCCTCCAAGTCAGTTAAACACATACATATACAATCTATAGGATTGGTATAAATTGTCTT ACTAAAGTACATTCTGATGCTCACACAGAGTCTTCTGAATATGCATTTCTCAGAATACCC GGTCTGTTAAATATATATCTTTTCCCCAAAGTGAGATTATTGGAACATGTTATGTTTCGA CTTTTGTCAAAGGACATCCATTCTATTTACTGTGTTAATTTTATTAATATTCATACATTT TAAAGAGAAGCTAAAGAAAGAAAGATAGCTCAATAAGCAGAAATTGCTTGTACAAACATG AGGACCTGAGCTTTAATGCTCAGCACCCACCTTAGGTAGTTGGATTTGGCTGCAGATGGC TATAATCCCAGCACTGAGGGGCAGAAATGGCAGATTCTGAGTACTCTGTGCCTGCTAACT TAACAGTGAGCCTCTAGTTTAGTGAGCGAGATCTCAAGGGCAGGTAGAGAATGCTAGAGA ATCTCAGCTGAAGTCATTCTCTCGACATCATATGTGGACATACATGCATGCACACACACC ACCCTGTTACAGTTGAATACTTATTCCAGGATTATAAGTGTAAGTCATGAATATAAATTC AAAACCTCTCTCTATGCATTTTCTTTTTCCCTCTTTGCTAGATTGGAAAGATGAGATATG TCAGTGTTCGGGACTTTAAAGGAAAAATTCTAATTGATATTAGAGAATATTGGATGGACT CAGAAGGTGAAATGAAACCAGGGAGAAAAGGTGAGGTTTTATTTCTTCAGTTTGATGTTA ATGTTGATTAAATACTTATCTTAAACTGTTACAGGGTATACAGGTTAAGGAGTGGCCTTA CTTGGTTGATCCTTTTGTAATCAATTTGTAATGAAACCTAGGAAAACATCCTGATGTCAC GTTGAATTGATCACTAACTTTAACTTCATTTTTCTGAGGCAGGTTGGGCACTACTTGGGA AACTGTAAAATGAGAAACAGAAAACTCCTGGTTTAGTGTTTGCTTTGGACTCAGATCCAG CAGGATGTTCTTTAATCCTTAAAGGTCTCTGTCCTCTTAGTATTGGTGCTTTGCCCAGTT CCAGGCCTCTTAGCAAGGACAGTTTATTTTGTTACCAAGTAGCTAGAAAGCATTTGTGCC AACTTGTATTTGGTTTTCTTGTGACAAGATATGACACAAAAGCAACTTAAGGGAGGAAGG GTTTATTCTGACCCAGTCTGAAGGTGGAAGGCAGCTGCTCACATGGGGCCCAGTCAGGAC GTGGAGAGGTGAGTGTGCTGGGACTTGGCTTGGTGTCACTTAGGCCTTAGGTGGGGCCAC TCAACATTCAGGATGGGTCTTCCCTCATCAGTTTAACCTGTTTGCAGACACCCTCTTCAA CACTCACAGAGGTATGTTTATGATGCTTCTAAATCTATCAAGCTGATGGTCAAGGTGAAC TGTTAATAACTTGTCACTTGTGCTTCTGGGAGCAACACCAGTGAGACCTGTAGACAGAGG CGTGCACACAGTAGAAGGGGACTGGCTGGAAGAGGCAGGTGGTGAACAGGAGTGGGAAAT GGGGCATTAGGAAGGAGTGGAGGGAGGAGTACATTATATACATGTAGGAAAATGCCATGG TGATTATGCTAATGCACTTTGAAAAAAGAGTAACCACTACTTAAATTTATATAGTTCTGT GCTCTAGGATTATTCAGTTGATGAAAATGCTTTCTTGGGCCAGTAAGGTATGGTGCCTCA GCAGGTGAAGGCACTTGGTGCCAAGCCCCTTATGATCCCCAGGACACATGTGGTGGAAGG AGAGAGTGGGTACTGCCTACCCTGTTGTAAATACTGTGGCGGGGGAGGGGGAGTGATGAT AGGATACAAGCACGCATGTGTGCACCCATTCAGTGAATAAATGTGACAGATTTTTAATAA AAGGAAAAAAATGCTTCCTTCTAATACTATTTTGTCTGTTTTTAAAGGTTTTACTTCTTT CATGCAGTTCTCAAGTTTGTTTTAGAAACTTCCTTTTTATGCTTACTGATTATTTCTTTC TGGGTTTTCATTCAGGATTTTCCACAGTGGCTAACCCTAGATTTTATTCTTGCAAATGTT TCCTGAAGGAATTCAGTTAGCCTCAAAGGCTTCCTACTGCTGCCTATTGTGTTCTCCTTT GCAGTTTCATGGCCTCTGAGCAGTTTTCTAAAAAATACATTGTTTGCTTGTGTTGGATGT TAGGCTAAGGTTTCATATTACCTGATTTAATGTATCAACCATTCTTTGATGTGTAAATCT CATTTACTAATTAAGAAACTGAATCTAGAAAATGCAGCTAGTGATGAAGCTGAGCATTGC TCTTGAGAGCATGATTCCAGAGTGCACTCATGCCTGTATCTGAATTCTGCATTCTCCCAT GTCCCTTTTGAGCCACTCTAAGGAGTGCCCCAAAATGGACGCTTACAGAAGAACTTAGCA TAGAGCTGAACACCTTGAAATTTGGTGGAAATATGGAACAAATGTTGGAAGAGACAGGAT GTAAAACTGTCAACATCTTATGCCAAATTTAGGTCATTTTAGACTGTACATATTTGTGAA ATATCTTCAGATTATTATCAGTTCTTATTGGTCAAAATAGGCATTGTGTTGGAAGTTAAA CTGGATATAAAAATTGAACCTGTGCCTAACAAATGTAAGATTTTAATATCAATATAGATC TCTCACAAAACTTCAACATTCTAGTGTTGTGCCATTCAAAAGGGCAGTTTGGGAACTGAA GTAGCTCTGTAATAGAGCGCGTATGTGGCATGCATGAGGTCTGGGTTCTGTCTTCAATGC TAAAAAATCCACATAAGCAAATGACAGTTTTGATAAAAAATTTGGGCATATCAAAATCCC CCAAAAGACTTGATTTTCACCTTGTATTTCTTAAACCTTGTTTAGGTATTTCTTTAAACA TGGAACAATGGAGCCAGCTGAAGGAACAGATCTCTGACATAGATGACGCAGTAAGAAAGC TGTAAAGTCTGAGCCATATCAAGCCTGTACTGTCGTAGCTGTTTTACTCTGTCTTTTCAC ATTGGCTTTTGTTTTCTAAATGTTGTTTTCCACGCTGTTGTATATTTGGATTGCAGAACA ATTTGTAAGACAAATACTTTTTTTTAATGTGCATTATTAAAATGTTCTAAGTGAAGCTAA TTGTCAACTTTATTAAAGAGGATTGCTTTGTGCCCCTTACCTAGTGTAAAATAAAGTCAG ATCATTACAATCTTAACTGTGGTAGCCTTTTTTGATAAAAAAAAATAAACTAGTTACTGT TTAAGGCCCAAAAAACAACCTTTGTAGGCACGTTGTTGAGTCAGCTTACATTCAGAAGGA TGTATTACATTGAGCTCTTAGATT wise-2.4.1/test_data/db.hmm0000644000175000001440000014420707313404500015115 0ustar philippusersHMMER2.0 NAME SH2 DESC Src homology domain 2 LENG 79 ALPH Amino RF no CS no COM hmmbuild -f ./SH2/HMM ./SH2/SEED COM hmmcalibrate --seed 0 ./SH2/HMM NSEQ 58 DATE Fri Feb 27 03:57:43 1998 XT -8455 -4 -1000 -1000 -8455 -4 -8455 -4 NULT -4 -8455 NULE 595 -1558 85 338 -294 453 -1158 197 249 902 -1085 -142 -21 -313 45 531 201 384 -1998 -644 EVD -7.995754 0.799646 HMM A C D E F G H I K L M N P Q R S T V W Y m->m m->i m->d i->m i->i d->m d->d b->m m->e -33 * -5459 1 -7236 -6151 -7608 -1460 211 -7493 -3675 -6106 -7520 -1974 -5505 -6101 -7346 -6241 -6882 -6742 -7084 -6270 6026 1349 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -1033 -7285 2 -1694 -5990 -7523 -7809 3279 -7334 -3682 282 -7382 -5323 -5353 -320 -7232 -6178 -6788 -6576 -6786 -5989 -2936 3857 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7276 3 -1302 98 -302 -4672 2259 -4519 4007 -858 -4269 -1175 1007 -1278 -4569 -3894 -4073 -1737 -2913 -213 1776 1102 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7267 4 -1696 -5051 -1085 -1251 -5397 3225 -3063 -5159 694 -5078 -4201 -2854 22 -2636 677 -1556 -3503 -4700 -5232 -4522 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7257 5 16 -4184 262 -814 686 -2174 695 -4255 2139 -1932 -3273 1337 235 -780 -442 312 -973 -1583 -4367 294 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7248 6 -3550 -3310 -5950 -5356 -3371 -5229 -4181 3204 -4991 1046 1310 -771 -5242 -4638 -4821 -2099 -1439 979 -4012 -3662 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7238 7 -2712 -4184 -952 -320 -4505 -53 -2345 -4255 -151 -1260 -7 122 424 329 -2433 2301 1640 -3806 -4368 -3685 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7229 8 -2074 -5958 -6742 -4882 -7054 976 -3718 -6264 677 -5853 -5216 -4634 -5822 -3300 3805 -5334 -5090 -6045 -101 -5632 - -150 -501 233 42 -373 399 104 -628 211 -467 -722 276 392 44 100 359 116 -365 -296 -251 - -212 -3659 -4304 -1684 -538 -701 -1378 -7319 -7219 9 647 -4118 -298 1003 -4439 -788 741 -1079 1215 -4134 -3207 215 -1589 1630 -317 470 -4 -623 802 -3619 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10524 -11566 -894 -1115 -243 -2690 -7319 -7209 10 -1509 -4188 1622 2632 -4509 -1418 -2347 -667 267 -4204 -3278 -1373 -3781 2005 -1030 -1440 -2654 -3810 -4372 -559 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7200 11 3325 -4216 -6178 -5845 -6062 -4560 -5158 -5689 -1206 -5929 -5126 -4938 -5244 -5024 -1017 -446 -2008 749 -6204 -6003 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11641 -894 -1115 -701 -1378 -7319 -7190 12 -1811 -4188 -1167 3438 -935 -3728 73 -4223 -1996 -4194 -3284 -657 -3829 375 -2502 -2650 -1029 -811 -4383 -529 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11642 -894 -1115 -701 -1378 -7319 -7180 13 -496 -4184 676 1029 -4505 -1418 679 -4256 1517 -4200 -300 198 -3778 1201 1830 -183 -513 -1882 -4367 -868 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10599 -11642 -894 -1115 -701 -1378 -7319 -7170 14 -633 -2957 -4427 -3832 -2932 -4370 432 156 -476 2332 1704 -3697 -4430 1065 326 -1384 -2885 -2383 -3393 519 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -11 -10600 -11642 -894 -1115 -701 -1378 -7319 -7160 15 -6143 -5498 -8565 -8001 -3625 -8435 -7123 -268 -7843 3292 -2382 -8182 -7357 -6530 -7298 -7874 -5985 -1460 -5506 -5762 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10600 -11642 -894 -1115 -701 -1378 -7319 -7150 16 -2729 -4016 -928 -2106 -4264 -1062 -2402 -1320 896 1300 2084 281 -3826 1390 1151 -481 -78 -1536 -4244 111 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -49 -10600 -5282 -894 -1115 -701 -1378 -7319 -7140 17 267 -4150 -221 505 -4471 -122 -2311 -1514 507 -860 -622 1535 -501 1422 -287 677 -38 -1869 -4334 -287 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -1583 -10562 -603 -894 -1115 -1507 -626 -7319 -7129 18 -109 -2533 -1496 134 -2721 1006 -1191 102 -852 -2495 -1669 -1223 2296 -798 26 619 -1402 -2084 -2815 1321 - -149 -483 232 46 -381 398 105 -624 210 -467 -714 275 393 45 95 358 120 -370 -295 -250 - -169 -3284 -10036 -1922 -442 -1039 -962 -7319 -7119 19 -168 -3624 -295 1199 -68 1871 -1823 -1063 -354 -3635 -461 -1803 -3256 291 846 -810 564 -165 -3816 -3141 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -9980 -11023 -894 -1115 -504 -1762 -7319 -7109 20 -1395 -4051 -278 -723 -4371 1575 -2211 -4122 1514 -681 767 1742 550 344 -150 -1256 -852 -1749 -4234 -3551 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10448 -11490 -894 -1115 -1525 -616 -7319 -7098 21 -1303 -4079 -2464 700 -1602 -3589 1433 -694 1661 -4094 597 -972 1666 751 1030 -190 142 -1149 -4265 -3584 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10489 -11531 -894 -1115 -186 -3045 -7319 -7087 22 -1296 -4184 2519 951 -4505 -3685 848 -4256 -726 -1766 -3273 1051 594 -300 418 -432 122 -826 -4367 -3685 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10600 -11642 -894 -1115 -701 -1378 -7319 -7077 23 -5971 427 -7965 -8333 -7548 3798 -7312 -8622 -8266 -8444 -7920 -7298 -6954 -7936 -7776 -6253 -6413 -7608 623 -7381 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10600 -11642 -894 -1115 -701 -1378 -7319 -7066 24 657 -23 1098 -699 -4418 -941 -364 -4149 -290 -417 -126 -2348 -3794 -1913 -2458 1590 2151 -3731 -4324 -3658 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10600 -11642 -894 -1115 -701 -1378 -7319 -7055 25 -7274 -6182 -7628 -7991 4417 -7490 -3715 -6170 -7556 -5469 -5569 -6138 -7360 -6280 -6916 -6780 -7127 -6327 -2962 1866 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10600 -11643 -894 -1115 -701 -1378 -7319 -7044 26 -6133 -5488 -8556 -7989 -3625 -8436 -7117 159 -7831 3112 1066 -8170 -7353 -6525 -7290 -7870 -5974 105 -5506 -5766 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10600 -11643 -894 -1115 -701 -1378 -7319 -7033 27 -946 -4360 -7581 -7272 -5013 -7453 -7549 2420 -7258 687 -3691 -7109 -7162 -7212 -7441 -6846 -4873 2920 -6837 -6329 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -10601 -11643 -894 -1115 -701 -1378 -7319 -7022 28 -8779 -7380 -8290 -8499 -8796 -7334 -7688 -9818 -7760 -9142 -9056 -8481 -7754 -8187 4273 -9233 -8869 -9515 -7500 -8689 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10601 -11643 -894 -1115 -701 -1378 -7319 -7011 29 -1430 -4182 1605 2386 1016 -3701 -2364 -1877 554 -1404 -3274 -2340 988 1341 -2456 -2613 -2669 -3799 -4371 -3693 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10601 -11643 -894 -1115 -701 -1378 -7319 -7000 30 -811 1038 -6983 -7288 -6924 -4490 -6231 -6742 -6774 -7000 -6027 -5325 -5305 -6315 906 3454 -1341 -5420 -7134 -7122 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10601 -11643 -894 -1115 -701 -1378 -7319 -6989 31 -1497 -4184 1338 2327 -4504 -3685 -435 -1510 -466 -1266 -3273 -861 -3778 218 805 1115 -421 -1387 -4367 -3684 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -229 -10601 -2852 -894 -1115 -701 -1378 -7319 -6977 32 -2544 -4015 -2384 -207 -4338 -151 -43 -4087 -120 -4031 -3105 966 -911 -1712 1160 2073 1899 -3638 -4197 -3516 - -149 -500 233 43 -381 398 105 -627 212 -466 -721 277 393 45 96 360 117 -370 -295 -250 - -233 -3704 -3951 -63 -4547 -114 -3722 -7319 -6966 33 -572 309 -784 245 -317 -1172 1400 -1251 1429 -2572 -3199 630 -3705 832 -810 678 1524 -3732 -4294 193 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10518 -11560 -894 -1115 -635 -1490 -7319 -6954 34 -550 -4118 -110 249 -4419 -3673 -2333 9 941 -272 -3212 -2316 2854 1226 -1206 -2581 -941 -990 -4313 -3642 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -76 -10574 -4563 -894 -1115 -411 -2013 -7319 -6943 35 -1439 -5086 -697 -3749 -7091 3546 -4834 -7007 -5343 -7054 -6292 1125 -5310 -4596 -6061 -1596 -4536 -5954 -7225 -6509 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10540 -11582 -894 -1115 -275 -2526 -7319 -6931 36 -277 615 2110 1083 -4505 976 321 -4256 -946 -1376 -3273 -1051 -3778 930 -2432 1066 -474 -3806 -4368 -3685 - -149 -500 233 43 -381 398 105 -627 210 -466 -721 275 396 45 98 360 117 -370 -295 -250 - -45 -5474 -11643 -1505 -626 -701 -1378 -7319 -6919 37 -6384 -5646 -7740 -7748 2831 -7543 -4219 635 -7397 -853 -3608 -6441 -7203 -6242 -6861 -6801 -6258 -1299 -3431 4057 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10601 -11644 -894 -1115 -701 -1378 -7319 -6907 38 1171 -293 -6607 -6454 -4954 -4640 -5326 -1155 -6079 -4711 -4106 -5174 -5272 -5638 -5815 1859 2339 1756 -5487 -5205 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -10602 -11644 -894 -1115 -701 -1378 -7319 -6895 39 -5548 726 -8073 -7590 265 -7859 -6933 1805 -7445 2761 -2626 -7548 -7172 -6550 -7142 -7215 -5460 267 -5654 -5732 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10602 -11644 -894 -1115 -701 -1378 -7319 -6883 40 -607 1053 -6978 -7296 -6850 -1653 -6236 -6659 -6912 -6927 -5967 -5324 -5300 -6345 -6517 3325 1269 -5383 -7086 -517 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10602 -11644 -894 -1115 -701 -1378 -7319 -6870 41 -3195 -3008 -5527 -4904 1429 -1639 -23 -442 -4502 808 -2142 -4377 -4782 -4107 -4296 -3834 -3134 2949 2848 -2915 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10602 -11644 -894 -1115 -701 -1378 -7319 -6858 42 -1468 248 -5289 -4655 407 -4516 -283 -988 1333 256 638 -4153 -4566 -3884 2425 -64 -2912 892 1339 25 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10602 -11644 -894 -1115 -701 -1378 -7319 -6845 43 -6 776 1857 -226 1013 -3780 1648 -1280 -813 -1628 -340 -865 -3870 -505 211 -788 658 -590 1629 781 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10602 -11644 -894 -1115 -701 -1378 -7319 -6833 44 -2711 -4184 1808 311 563 1017 -2343 -1202 727 -4200 -3273 1521 -1611 1203 -208 -676 -2650 -3806 1464 -1375 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10602 -11644 -894 -1115 -701 -1378 -7319 -6820 45 -444 -4183 1973 -338 -1263 2075 -2344 -4253 -89 -4198 -177 192 -3778 -545 -302 260 -1633 -176 -4366 -3684 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -1303 -10602 -773 -894 -1115 -701 -1378 -7319 -6807 46 -1654 -3126 892 585 -3447 -681 1000 -197 297 -3142 -2215 839 1662 1550 22 -1534 288 -630 -3309 -2627 - -153 -497 237 44 -390 408 102 -627 214 -471 -725 275 395 55 92 362 115 -376 -303 -254 - -2642 -353 -4387 -2167 -363 -31 -5570 -7319 -6794 47 -971 -13 -81 370 -4479 -1026 1314 -1276 1291 -1680 -3248 646 -3753 1074 1578 140 -359 295 -4342 -3659 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -10574 -11616 -894 -1115 -1351 -718 -7319 -6781 48 -1452 -432 -5317 -4685 672 -4530 -3411 1174 -4285 -2655 -2016 885 -180 -3912 -1700 -3617 -1465 3088 -3280 -2937 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10574 -11616 -894 -1115 -406 -2028 -7319 -6768 49 -2712 -4179 -2561 170 -1276 -1378 783 -1651 2633 -1190 -3269 -721 -3779 1595 924 -1219 376 -3800 -4364 94 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10603 -11645 -894 -1115 -701 -1378 -7319 -6755 50 -4519 -5497 -4305 -1190 -5973 -5163 5152 -5554 -2301 -1967 -4630 -909 -1026 -1110 -725 -4396 -4332 -5267 762 -4996 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -79 -10603 -4520 -894 -1115 -701 -1378 -7319 -6741 51 -4742 2555 -6657 -6333 2540 -6098 -3678 1238 -5936 -4026 -3628 -967 -6082 -5296 -5631 -5238 -4677 -460 -3072 3759 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10539 -11581 -894 -1115 -267 -2566 -7319 -6728 52 -2757 -3861 -754 -2226 -4050 -3797 1181 712 1918 -607 -367 -2504 -1264 691 2362 -2720 -284 20 -4128 -3537 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10603 -11645 -894 -1115 -701 -1378 -7319 -6714 53 -4514 -4096 -7081 -6634 -723 -6661 -6001 3505 152 -1714 -3321 -6310 -1202 -6188 -6387 -5894 -4487 1567 -5642 -5244 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10603 -11645 -894 -1115 -701 -1378 -7319 -6700 54 -2716 1077 -1059 -351 -948 -3699 838 -636 1214 -274 745 1226 -1112 2092 1332 -1343 -2655 -1397 -4330 -270 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10603 -11646 -894 -1115 -701 -1378 -7319 -6687 55 -907 54 -2567 146 6 -3690 -192 -4224 970 -2095 -3257 392 -378 993 1394 1190 674 -768 338 -98 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -10604 -11646 -894 -1115 -701 -1378 -7319 -6672 56 -878 -4177 1291 47 -4495 -3687 116 -4243 -878 1318 314 174 -3780 101 -388 -279 1620 -188 -4362 -3681 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -10604 -11646 -894 -1115 -701 -1378 -7319 -6658 57 332 189 1866 1165 -4505 773 -2343 -4255 197 -1252 -463 423 626 549 -809 -1409 -1018 -3806 -4367 -1198 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -10604 -11646 -894 -1115 -701 -1378 -7319 -6644 58 -892 -4184 1591 318 -4505 149 -2343 -4256 -126 -4200 -968 2412 -1002 438 227 -172 944 -3806 -4368 -3685 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -246 -10604 -2777 -894 -1115 -701 -1378 -7319 -6629 59 -1329 174 -757 767 -525 2620 -2154 -3997 337 -1733 798 -682 -3586 -1699 10 -197 -1000 -3565 -4143 -1070 - -147 -503 230 42 -379 400 102 -621 212 -463 -713 275 398 42 93 358 117 -372 -298 -252 - -1238 -2595 -1320 -1857 -466 -1204 -821 -7319 -6615 60 -2057 -3525 -1901 -329 -3850 2119 1363 -3597 2009 -3538 -2614 31 -3118 745 -334 -879 654 -3149 -3701 -3025 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -9783 -10825 -894 -1115 -268 -2562 -7319 -6600 61 -2879 -2722 -5113 -4484 1276 -4414 111 -726 -386 437 -50 -1066 -4465 -709 -1083 -567 -2819 801 569 3513 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -10506 -11548 -894 -1115 -203 -2932 -7319 -6585 62 -748 210 -33 -4661 2244 -4517 -3387 -154 -1257 -1249 -79 -4156 -4567 -3888 -4068 -270 -499 -393 -3259 3581 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -10605 -11647 -894 -1115 -701 -1378 -7319 -6570 63 -2973 218 -5314 -4678 -1099 -467 -3391 2396 -1381 1000 153 -899 -4570 -3897 1386 -3604 -2913 1112 -3257 275 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -10605 -11647 -894 -1115 -701 -1378 -7319 -6555 64 712 -2898 -660 -4025 1011 361 -3235 260 -1186 -326 1009 -963 -432 -3491 -3780 856 1583 -803 -3342 273 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -10605 -11647 -894 -1115 -701 -1378 -7319 -6539 65 -549 -4184 645 1588 -4504 1660 -2343 -4255 -796 -1102 -3273 -31 7 -633 -121 -737 680 -1389 1630 -3684 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -83 -10605 -4486 -894 -1115 -701 -1378 -7319 -6524 66 -298 -4130 161 1056 -4451 1605 -2289 -4202 438 -4146 -3219 1419 -3723 -486 1808 -200 -2596 -1076 -4313 -3630 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -10539 -11581 -894 -1115 -263 -2587 -7319 -6508 67 -303 -4160 360 616 -4470 -3691 1917 -168 227 -456 -107 -2331 414 761 868 -549 38 706 -4350 -821 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -44 -10605 -5784 -894 -1115 -701 -1378 -7319 -6492 68 -324 4 -2598 -866 -1217 -822 -2358 -1795 1616 -1175 -3151 -812 -534 59 1409 -76 1405 -857 -4263 1318 - -147 -500 232 42 -381 398 105 -627 210 -464 -721 280 393 45 95 358 119 -370 -295 -250 - -168 -3344 -11621 -393 -2067 -419 -1990 -7319 -6476 69 -1440 109 -6019 -5504 4127 -5317 790 -1078 -5097 -1202 -2848 -900 -5345 -4612 -4854 -4418 -3802 -3095 -3088 1330 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -10606 -11648 -894 -1115 -701 -1378 -7319 -6459 70 70 1646 1226 358 -4499 205 -2344 -1253 -1926 -1839 -967 1545 818 358 611 882 -2650 -3801 -4364 -3683 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -10606 -11648 -894 -1115 -701 -1378 -7319 -6443 71 -1218 -638 414 -2097 -4295 -423 60 -1827 -2008 -1801 -3145 661 -3822 -1962 -1116 2452 1944 -3625 -4262 -3621 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -10606 -11648 -894 -1115 -701 -1378 -7319 -6426 72 -5783 -5235 -8195 -7617 -622 -7885 -6643 2054 -7396 2608 728 -7587 -377 -6310 -6953 -7193 -5650 329 -5352 -5508 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -10606 -11648 -894 -1115 -701 -1378 -7319 -6409 73 565 -4171 -705 -967 -4486 -776 593 -4232 -547 -1032 481 806 1543 1630 -2437 396 -601 -211 1435 480 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -10607 -11649 -894 -1115 -701 -1378 -7319 -6392 74 -124 -4175 1926 2547 -4488 -3694 34 -4234 -1939 -1173 -965 -2332 -1002 1851 -2445 -2602 -968 -3793 -4363 -558 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -10607 -11649 -894 -1115 -701 -1378 -7319 -6375 75 -6325 -5649 -8690 -8081 -1212 -8579 -7091 722 -7904 3142 1192 -8327 -7377 -6484 -7287 -8024 -6133 -3977 -5433 -5722 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -10607 -11649 -894 -1115 -701 -1378 -7319 -6358 76 -4820 1167 -7506 -7182 -5010 -7339 -7316 2750 -1473 -382 -3707 -6991 -7082 -7096 -7302 -6706 -4811 2853 -6723 -6200 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -10607 -11649 -894 -1115 -701 -1378 -7319 -6340 77 -637 -4183 785 1664 -4504 -1528 1202 -4255 -758 -1224 539 723 -3778 1529 -403 388 -89 -1208 373 418 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -10607 -11650 -894 -1115 -701 -1378 -7319 -6322 78 -1788 -3481 -1154 -1203 1121 -5023 4200 -3007 -4546 -831 -2689 -4410 -5074 -4179 -4480 -4114 -3550 -1166 -3181 3272 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -20 -10608 -11650 -894 -1115 -701 -1378 -7319 -6304 79 -7240 -6153 -7608 -7964 271 -7493 3287 -6121 -7510 -1085 -5521 -6100 -7346 -1027 -6876 -6742 -7088 -6279 -2920 4367 - * * * * * * * * * * * * * * * * * * * * - * * * * * * * -7319 0 // HMMER2.0 NAME SH3 DESC Src homology domain 3 LENG 57 ALPH Amino RF no CS no COM hmmbuild ./SH3/HMM ./SH3/SEED COM hmmcalibrate --seed 0 ./SH3/HMM NSEQ 62 DATE Fri Feb 27 03:59:03 1998 XT -8455 -4 -1000 -1000 -8455 -4 -8455 -4 NULT -4 -8455 NULE 595 -1558 85 338 -294 453 -1158 197 249 902 -1085 -142 -21 -313 45 531 201 384 -1998 -644 EVD -52.971882 0.252059 HMM A C D E F G H I K L M N P Q R S T V W Y m->m m->i m->d i->m i->i d->m d->d b->m m->e -24 * -5907 1 -3122 -328 -13 901 -240 -918 -191 -552 1134 -1425 760 -1227 1409 672 629 -936 610 -1765 -4769 60 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11060 -12102 -894 -1115 -701 -1378 -24 * 2 -460 -189 -5225 -482 144 -4860 -3703 229 994 -73 737 -4333 -1255 1130 384 -1182 716 685 268 1590 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11060 -12102 -894 -1115 -701 -1378 * * 3 1227 31 -5740 -5104 793 -315 -154 -466 -4699 -1548 -2425 -1137 -4993 -4322 -4499 -4027 -1276 2743 -3680 1401 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11060 -12103 -894 -1115 -701 -1378 * * 4 -3430 -3934 -3958 -742 -3998 -4610 -3284 1620 1715 -3824 -571 -3518 -4680 513 1426 -3594 255 1933 -4284 -478 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11061 -12103 -894 -1115 -701 -1378 * * 5 3484 -4656 -7458 -7807 -7386 -2137 -6733 -7193 -7421 -7470 -6495 -5791 -5760 -6840 -7008 -1907 -1500 523 -7611 -7604 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11061 -12103 -894 -1115 -701 -1378 * * 6 -1848 -4148 -5245 -1019 -4171 -5254 -3773 1380 993 2635 -601 -4354 -5279 -93 -1361 -4352 -3911 -3608 -4477 -4144 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -11061 -12103 -894 -1115 -701 -1378 * * 7 -1895 -5464 -7035 -6810 1869 -6878 421 -5148 -1515 -2012 -4738 -1171 -6863 -5815 -6130 -1846 -5749 -5129 -3447 4464 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11061 -12103 -894 -1115 -701 -1378 * * 8 51 -5905 3650 -648 -6183 -1666 -3775 -5988 -1427 -2353 -5055 -1159 412 -3369 -4220 -487 -4270 -5513 -6085 -5289 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11061 -12103 -894 -1115 -701 -1378 * * 9 -7689 -6608 -8065 -8426 3221 -1964 -4131 -6578 -7983 -2490 -5977 -6557 -7800 -6699 -7342 -7194 -7543 -6738 -3377 4175 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11061 -12103 -894 -1115 -701 -1378 * * 10 589 -207 1004 1139 -1080 -4096 -281 -4657 482 -2508 453 254 13 1559 -2843 -904 803 286 -4774 -4093 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11061 -12103 -894 -1115 -701 -1378 * * 11 2645 -4668 -2999 -1386 -5006 865 -2839 -4758 146 -4702 -3779 -905 1188 101 -2936 -107 -717 -4305 -4870 -4186 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11061 -12104 -894 -1115 -701 -1378 * * 12 -1036 -4594 -1274 1053 -4915 -650 75 -557 -94 -4610 230 561 -4188 1671 1341 462 985 116 -4777 -4094 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -11062 -12104 -894 -1115 -701 -1378 * * 13 -539 -4594 1349 1366 -4915 128 689 -2020 -460 -4610 -255 447 -1191 1352 -95 942 424 -4216 -4777 -4095 - -147 -501 239 42 -382 398 105 -627 209 -467 -721 280 393 44 95 360 116 -370 -295 -250 - -156 -3441 -12104 -480 -1820 -701 -1378 * * 14 603 -4597 1634 973 -4918 237 -707 -4669 -387 -4613 -3686 -2732 1764 -642 -1284 1333 -603 -4219 -4780 -4097 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11062 -12104 -894 -1115 -701 -1378 * * 15 -3121 -354 2625 890 -4915 693 -495 -4666 -1099 -4610 239 371 -4188 410 -175 773 -554 -4216 -4777 -909 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11062 -12104 -894 -1115 -701 -1378 * * 16 -5479 -7546 2348 3279 -1087 -5240 804 -7639 -5071 -7471 -6890 -1431 -5822 -1375 -6065 -5086 -1960 -7080 -7672 -6544 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11062 -12104 -894 -1115 -701 -1378 * * 17 -6259 382 -8758 -8253 -4216 -8612 -7559 762 -8118 3028 821 -8321 -7737 -7032 -7716 -8018 -6146 110 -6076 -6255 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11062 -12104 -894 -1115 -701 -1378 * * 18 -220 -4598 -31 -568 -4919 -559 -2757 -4670 -1018 -4614 -3688 -234 668 844 -1384 2366 1517 -4220 -4782 -4099 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11062 -12105 -894 -1115 -701 -1378 * * 19 -2010 -4705 -7443 -6852 3718 -6828 -5727 647 -6526 1251 1075 -6488 -6611 -5937 -6276 -5982 -1651 -201 -5176 -5023 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -11063 -12105 -894 -1115 -701 -1378 * * 20 -489 -328 -1365 191 -4915 -770 -142 -4666 2255 -424 1089 -376 -1484 235 1330 -285 118 -4216 -4777 -884 - -149 -500 233 45 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -42 -5819 -12105 -154 -3303 -701 -1378 * * 21 -416 -4585 -2976 1762 -4902 -4100 -2759 -1470 2527 -2299 -3676 -2737 522 467 1067 -1443 -1233 -924 -4771 -4092 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -11063 -12105 -894 -1115 -701 -1378 * * 22 -2239 -6202 -339 -3798 -7598 3479 -4973 -7538 -1637 -7485 -6801 1360 -5813 -4688 -6238 -2142 -1855 -6697 -7671 -6752 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -11063 -12105 -894 -1115 -701 -1378 * * 23 20 -7666 3352 2184 -7759 -5261 -4725 -7769 -5180 -7590 -7047 -290 -5860 -432 -6230 -1951 -5659 -7197 -7798 -6630 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -11063 -12105 -894 -1115 -701 -1378 * * 24 -834 -3702 -3857 261 225 -4490 -3229 1797 1191 -1495 -77 -1191 -1121 121 -136 -3464 544 1663 -4086 -3638 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -11063 -12106 -894 -1115 -701 -1378 * * 25 -4801 392 -7193 -6595 1097 -6538 -5430 2624 -6252 1210 1902 -6192 -6387 -5719 -6018 -5675 -4729 1170 -4978 1204 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -11064 -12106 -894 -1115 -701 -1378 * * 26 -3184 -124 -449 527 911 -4262 1397 840 407 -524 -393 -1280 -4349 1084 -252 -1461 1263 -449 385 1015 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -11064 -12106 -894 -1115 -701 -1378 * * 27 -5257 -4753 -1826 -7579 -5430 -7748 -7693 2384 -7556 497 -4135 380 -7503 -7493 -7713 -7113 -5247 2897 -7121 -6606 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -11064 -12106 -894 -1115 -701 -1378 * * 28 -3437 989 -5785 -5151 -900 -4991 575 2142 -4748 2073 -2459 -4637 -5039 -4371 -4549 -20 -292 843 -3729 -3386 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -11064 -12106 -894 -1115 -701 -1378 * * 29 226 -4596 1529 1903 -4917 -499 -34 -4668 329 -4612 -3685 1829 -4189 233 -535 316 -1212 -4218 -4779 -4096 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -104 -11064 -4127 -894 -1115 -701 -1378 * * 30 -3043 -4515 1642 84 -1351 -4017 -177 -1640 2370 -4530 372 -480 -4111 418 1197 -526 -814 -772 -4698 -168 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -10979 -12021 -894 -1115 -178 -3109 * * 31 -1878 -4589 973 843 -1206 -1633 381 -901 525 -667 -3679 360 -480 38 -2843 1382 401 714 -4774 -4092 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -93 -11065 -4329 -894 -1115 -701 -1378 * * 32 -956 -4527 2043 1584 -4848 -978 -430 -4599 645 -1994 -3616 1940 306 -674 -2774 -493 -1126 -4149 -4710 -112 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -10991 -12033 -894 -1115 -197 -2970 * * 33 243 -71 1987 1235 -4916 1291 -255 -4666 -665 -4610 -3683 432 -327 -857 -512 680 -1385 -4216 -4778 -4095 - -158 -511 257 56 -387 415 121 -634 206 -476 -720 285 392 44 85 351 106 -376 -289 -247 - -3964 -115 -12107 -533 -1694 -701 -1378 * * 34 -9614 -7906 -8828 -9215 -8808 -7864 -8345 -10446 -9400 -9708 -9742 -9244 -8292 -9282 -8808 -10203 -9727 -10204 6318 -8641 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -11066 -12108 -894 -1115 -701 -1378 * * 35 -1554 1426 -5743 -5107 -54 -4945 -3815 -2716 -4702 -10 -210 -4591 -4995 -4325 -4502 -1080 -642 -1128 5465 1601 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -11066 -12108 -894 -1115 -701 -1378 * * 36 -3127 -4541 -29 1201 270 -4110 -2771 -1680 1988 -162 -275 -1312 -4202 -280 1470 -1517 611 -791 -4739 9 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -20 -11066 -12108 -894 -1115 -701 -1378 * * 37 2093 1737 -7306 -7364 -6135 2366 -6313 -436 -7006 -5802 -5218 -1088 -5821 -6525 -6698 -4441 -4485 1555 -6685 -6458 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -20 -11066 -12108 -894 -1115 -701 -1378 * * 38 -1128 -28 -711 1768 -4910 -4096 -498 -787 1205 -2040 -244 -854 -4189 1223 2256 -1533 -1355 -407 -4775 -4093 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -20 -11066 -12109 -894 -1115 -701 -1378 * * 39 -1879 2192 436 -4270 -855 -4785 -3604 -756 -85 1016 -100 1763 -563 -3792 183 717 -1619 54 -3795 474 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -20 -11067 -12109 -894 -1115 -701 -1378 * * 40 -524 -4581 640 -1307 -1283 -734 382 285 1346 374 -474 1357 -510 539 -102 -775 -427 -937 -4768 -1010 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -405 -11067 -2116 -894 -1115 -701 -1378 * * 41 -177 -4192 1342 -772 -4487 996 -2427 -1658 -747 -778 -79 1436 -3859 -1976 399 111 1120 -79 -4391 -797 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -354 -10683 -2299 -894 -1115 -4079 -88 * * 42 -988 -3986 348 -1803 -4308 1871 -2143 -4059 -621 -4003 -3077 804 -3576 33 197 253 2327 -3609 -4170 -3487 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -369 -10351 -2243 -894 -1115 -4766 -54 * * 43 -943 -3702 -2105 -1552 -4026 1994 598 -3767 173 43 -2794 2183 -3312 -17 902 61 -2187 -3326 -3879 -3210 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -2646 -10005 -277 -894 -1115 -831 -1191 * * 44 -3974 -5739 727 -2118 -6072 3372 -3152 -5928 -455 -5741 -5098 692 -4405 -2816 -349 -3640 -4025 -5421 -5857 -4978 - -149 -500 233 45 -381 398 105 -626 210 -464 -721 275 394 45 96 359 117 -369 -295 -250 - -90 -4457 -10676 -986 -1014 -303 -2401 * * 45 -2963 -4435 -2811 806 -4756 -812 578 -1768 2133 -4451 -219 -154 -4030 2168 1628 -1632 -320 -722 -4619 -3936 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -22 -10893 -11935 -894 -1115 -103 -3864 * * 46 -3152 -4340 -3126 2088 325 -4175 -2848 -655 158 -4310 -559 -2863 -553 1389 1246 -798 963 543 368 -3979 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -22 -11069 -12111 -894 -1115 -701 -1378 * * 47 -5934 -6299 -6851 -7182 -7873 3816 -7112 -8499 -7375 -2691 -7787 -6778 -7046 -1479 -7289 -6153 -6351 -7568 -7602 -7689 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -23 -11069 -12111 -894 -1115 -701 -1378 * * 48 -3409 -279 -5754 -5118 1467 -4957 -3827 1437 -1964 1428 1415 -4603 -5005 -1356 -4513 -4041 -3349 -236 3552 2142 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -23 -11069 -12112 -894 -1115 -701 -1378 * * 49 -1034 -4543 -7500 -7047 2730 -7061 -6272 2428 -6832 -1342 -3693 -6699 -6918 -6549 -6774 -6283 -4924 2285 -5874 -691 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -23 -11070 -12112 -894 -1115 -701 -1378 * * 50 -6811 -6840 -8407 -8777 -8662 -6975 -8007 -9068 -8831 -8989 -8575 -7998 4307 -8553 -8354 -7108 -7237 -1625 -7897 -8683 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -24 -11070 -12112 -894 -1115 -701 -1378 * * 51 1491 165 -3190 -1119 -4444 -938 433 -4106 -33 -937 -3385 -2916 -4295 -2488 -1478 2378 294 113 -4529 -3940 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -24 -11070 -12113 -894 -1115 -701 -1378 * * 52 -1027 -4595 -1049 -982 -4912 -1815 -2768 -4659 -2352 -4610 -208 3568 -1374 31 -2859 750 166 -393 -4782 -4102 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -24 -11071 -12113 -894 -1115 -701 -1378 * * 53 -7624 186 -8053 -8393 2094 -7925 -265 -1333 -7950 -2072 -5897 -6548 -7779 -6681 -7318 -7170 -7476 -6653 -3378 4526 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -25 -11071 -12113 -894 -1115 -701 -1378 * * 54 -5492 -4985 -8103 -7700 -196 -7869 -7352 1285 -7589 682 -332 -7532 -7476 -7140 -7526 -7201 -1489 3271 -6457 -6278 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -25 -11072 -12114 -894 -1115 -701 -1378 * * 55 468 -473 132 2146 -4915 -4095 -2754 -4666 -628 -4610 -3683 -2731 -4189 2213 370 -824 1410 -1037 -4778 -4095 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -26 -11072 -12114 -894 -1115 -701 -1378 * * 56 -1625 -71 183 1142 -4750 -2052 -2793 -65 1001 319 782 -2785 2125 -948 -168 -799 -1082 -851 -4695 -1187 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -26 -11072 -12115 -894 -1115 -701 -1378 * * 57 -1826 -51 -1428 129 -87 -1966 -266 1472 512 -67 424 11 -1458 -783 -481 -203 -1523 1414 -4485 735 - * * * * * * * * * * * * * * * * * * * * - * * * * * * * * 0 // wise-2.4.1/test_data/rpo_h_m.anchor0000644000175000001440000010511707571671427016665 0ustar philippusers>5.32372381-32389772 TTGAGGTGGGTGAAGTGGGGTAGGAAGACCATTTCTGGGAAAATGGGCCAGAGTATTGAT CTTTTTCATTATGACCCCTTCGCTTCATTAGAGTAAACATTTATTGAACAAACGCAAAGC TTGGCGCTTGTCACTCATGTTTTATTGGCGTTTTCCTTTTTTTTAATTTTTTTTTAAGCT ATCTCCTACAGGAAGGATATTAGCTCTTTCATTCTCTCAAGGGTCAGATGTAATCTTCCA ACATCTGACTTTCGCGTCACCCATTTAGGAAGAGACGCGGTCCCTTTAAGGCCCTGGAAA GGGTCTAAGTGTTGGTTTCTGTGGGGAGGCCACGCCCCATCACGTGACCGCAGCCCCAGC GCGGCGGGGCCGGCGTCTCCTGGCTGCCGTCACTTCCGGTTCTCTGTCAGTCGCGAGCGA ACGACCAAGAGGGTGTTCGACTGCTAGAGCCGAGCGAAGCGTGAGTGCGCGGGACCCCCT ACCCCTACTCCTCGGGGCCCCCACCCTCCCAGCCGGGCCGTGAGCTGCCTTCGGCCCTCC ACTCCTCTCGCCGGCAATGGCCGCGGGAAATGGCGGCTCTGCCTTACCTCCCCCTTCCCC TCGGCGTCCCCGGCCCCCTTCTCCGTTTCTGACTCCACGCCTGACGCGCTGTGGGCCCTT CCGCGGTAGACTCCTGTCCCCGGGGAGCCGAGTCGAGGCGGCGGGCGCTGCGGCCCGGGG CGGTAGATTGAGGGCGGCCGGGGAGTGAGGAGTCGCGGGGAGAGAGTCGCGGCGTCCCCG GGACAATGCGGCGGCGGCCTGCCTAGGTGGGGCGCGTGCGGTTACCTACTCTTCCCCCGC CCCTCGCCCTGAGCGGGGCGCTCTGGAGACTGGGAGAGCGGATGCGGGCGGGAGGGGGCC GGGGGAAGAACGGCTGATGTGCAGGGGGAGGGAACGCTTCGAGAGAAGAAAATGGCGCTT GGTGCAAATCCCGCCCCTTCCCACGCCGTCTTCTCCGCACTTCGCCGCCTCCCACGCCCC CTCCGACCAACCTGTCTCCCCTCGCCCGAGCGGCTGCTAGCCACGGGGTTCTAGCGGCTT GCTGGGGCCGCGCGACCCCTTCCCTGGTCTTGTGCTTGTCACCTTCCTGTTATACCGAAG TCGTGTGCCCTTCAGTCCTGGTTCATTTTCACCTCGTTTTTTTCTGATCTTTCCCTCAAT CAGCAAAGGCTGAAGATTTCGTTTCTCTTTTTAAAGTTGCGTTTTGTATAAATTCTACAA TAGTGGTTTCAGTATCAGTTACTTGAATTACAAGCTGCTTCTCCCCCCACCCCCACATTG GAACAGGCTCATTAAGGTAAATATATATTTGTTAAAAGTTTAGAGGCTGGTTTTAGTTAC CGTTACCTTTCTTCTCCAGTGGACTTCTTTGGGTTGAGTACCAGGTGGTTCTTTGAAAAA TTCTTAGGCCCCCAGGCAGTTTTTGATAACAGACGGTAGTTATGATCGACAGTTTCAAAG TGAAAAATTATGTTCAATTTAATTACCTTTTTAAAAAATATCTTTTTGTCGTATTAATTA GCATAAAAAACTTAACTAAATTGATTTTAGAGATGAGGTTGCAAAATGGAGCAGAAACAG GAAAAACGGATAAAACGTGGTCATGAACATTGCTTTTCCCTTCTGAATTTACCCTTGAAG ACATTACCAGTTAAAATCAGATTGAGCTTTTTGAATTTAATGGCTAGGATTGGGGTGGCC CACTTCTTTTTCCTTGACCTCCTATTTTGGAACATATGCAATGTCAGTGCTAATGCAAGT TTCATCTAGAGAGCTAGATTATTTATGATTTTTTTTTAAGGAGGAATTTTAAGTCTTTTT TTCTTGTATTAAACAAATACAGTGTGTGATGTGTTTATTAGGCCCTTTAACGCATACAGA AATTAGCTAATTTATGCCTAGTGTTCCATTATTGGAACGCTAAGCATGTGGGAGTTATTT ATGTGCTACTGCTCAAGATCATCGCCAAGGTCTGCTTGCATAAATTCAAAAAATTGCAAC CTCTGGCATAAATGGGTTAATAGGACCTAATCTCTTCTGAGATGGGGAGAGCAAAAGATA TTTTGATAATCAGCGTTTTATGACCTGGTGTTATAAGTGCCTTGAATAGAGGTATCCACG TATCTTGGAATTCCTTGAAATTTGGGGCTTAGGCTTACTGATAGTTTGCTTTCTGCAAAC TTGCACTCAGGCACTCAGTAAACACCCACTTGTAAGCAAGGCACTAAGTTATCTATGTCT CTGGGGGGACCTGGGAAGTTACCAGCATGGTAGGAATTTGCGGGAAGGTTTTGCACCTCC CATAAATAGGTTTTGCACCTCCCATAAATAGGTTCTTCAAATTTTAATTATGTTCCAGAG TAGAAAAATCTGTGTAAAATGTAATGAATTGCTGTGAATTGTGTAAGATTTTTTTTTTTT TTTGAGATGGAGTCTTGCTTTGTTGCCCAGGCCGGAGTGCAATGATGTGACCTTGTGTCA CTGCAACCTCTGCCTCCGGTGTTGAAGCGATTCTCCTGCCTCAGTCTCCCGAATTGCTGG GACTACAGGTGTGCCACCGTGCCCTGTTAATTTTTGTATTTTTAGTGGAGATAGGGTTTC ACCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCTGCTTTGGCCT CCTAAAGTTTTGGGATTACAGGCGTGAACCATCGTTCCCGGCCTGAATTGCGTATAATTT TGTGTACTCTTGAATTAGTACCTGTCGTTATTTTGGTGATACGGCCAAAAAGTCAAAATA TGAATAAAATATTATGTAAAAATTAATTAGATGTCACATTTGCATAGTACAGCTAGTTCC CTGTTGTGTAAATGTTGGGGTCAGTTCCCCATAGTGAATAATTTTACGTTAGTTCCAATC TCGTTGATGAGAAGTCTAAAGCAGTAATAGTAGAATTACATTTCTTCTGGTTTTAATAGT AATTGTTGTCTGCTGCCTTCTTGCAGTTTACCCTACCCATAGTGTGTAATGCCATTAAAA CGAAGTATAGAAAGATCCATTGGCCTGGAGAAAGGTTAGAGGTGTAGGAGTGTATGACAT TTAGTTCATTGTTCTTACTGGGTTCAGCACATTGCACCCTGCGTGTTATTTGCAACTTAA AAGGGTATAGATTAAAACTTGTGCTCAGTGTAACAACTCAGTACCACAAAAATGGTAGAA TGAACCGTGGAACTTGTCCTTGATTTTTTTCTTTGATTGGGGGAGAGCTAAGTTGAAAGT AGTAGAGTACCTTATTAATTATTTTTGTAATGTATTTTTCTTTCAGGATGCCTAAATCAA AGGAACTTGTTTCTTCAAGCTCTTCTGGCAGTGATTCTGACAGTGAGGTTGACAAAAAGG TGACTACTGCTGCACCAAGTCATTTTGGTGATACTCAACAATATTGTCCATATCCCATTC TGAAGGATAGTAAAAGGTGTATTAACATCTTAAAATGAGGATCTAGCTGGGCGCGGTGGC TCATGCCTGTTATCCTACTTCTTTGGGAGGCCGAGGTGGCAGGATTGCTTGAGGCCAAGA GTTCAAGACCAACCAGGCTAACATAGCAAGAACCTGTCTCTTTAAAAAAATAAATAAATA AAAAATAAAAAATAAGAATGTGAATGGGTATTTCTGGAGGTACGGTTGGTCTCTGGACCA CTTGACTAGAAGTGCCTAGGATGCTTTTTGCACATTCATACTCATAGGCCCTAAATCAGA CTTAACAAGTCTTCTGTTGAGCATCATTAGGAACCCTAAAGTTGCAGAAACACTGCCTTG CATCCTAGGGTCATAGAATTCTAAGTAGGCCAAAGTCACTATTTGCCGTTATTTAGAAAT TTACCAGATTTTTTTTTGTAAAATGTTAATTTTTTTTTTTAAAGACAGGGTCTTACTCTC TTGCCGAGGCTGGAGTGTGGTGGCACCATCATGGCTCACTGCAGCCTCGACCTCCTGGTC TCAAGCAGTCCTCCCACCTCTGCCTCCAGAGTAGCTGGGACTACAGGCATCATGCCTGGT TAATTAAAAAAAAAATGTTTTTGTAGGGACCAGGTATTGCTGTGTTGCTAAGGCTGGTCT CAAACTCCTGGCCTCAGGCAATTCTTCTGCCTCAGACTCCCAAAGTGCTGGGATTACAGG TGTGAGCCATCATGAGTGGCCATAAAATGTTAATTTTGACAGTTCTCTTAGTTACTGGTG TTTATTCTGCACATAAGGTTTTCTGAATTTTAGACTTGGTACATTTTTAAGTTTGTACTA AGTTTGTGCTCTGGTCCCTTCCATTTAATTAAATCAGCACGCAGTAAAGCTAACTTGAAA CCCATTGACAAGATAGGCTTTTTCTGCATTAGATGACAGCTGCACCGTAATTGGTGAATT TCGCTAAATTGAGCATCTCAGTGGAGCATAACTGAGCGTCTCACTCTGCGGTCAAGTCTT CCGTGCAGAATTGTCTTTTATCGCATAGAACTTTACATATCTGAAGAGATATTTATATCC TAGAAATAGAATAAGTTGGTCGTGTTTTTCCTAATTAGTATATATCCTTTGTAAAATAGT AAGTAATGACTAGCACTGGTAGACCTGTGATTTCCGAAAGTTTATTCAAAAGAAGCAGGC TCCCTATCTTTTTTTTTTCCTCCTGAAGCTTAGCAATTTTAGCTAAAAGAAAAGGGGAGA GCGTATGGGAGATTGGAGAAGTTGCAACCTTAAAGTATAAATATAGAATATAACAACACA TGGAAGGGTAAAATAAGGCTTCAAAGACTATACTTGAGTAAATTTCTTAATTTTAAAATT TGCACCCTATATAGTATTTGAGTATGTTGATGTAACACATGTGTATTGAGCTTTTATTTG CCAGACATGCACTATTCCACAGGGAATACTTAGAGCCTGATTTATAGAATAATTGCTTTC TGCATATTGAGCTAACTTTTTGTTTGTCCCAAATAGTAATATTACTCTTGTAAACACTTA ACCTTGTATACCACATTTTTCATTTCATGTTTTACATGTATATAATATTTTTCCTAGCTT CATCTAATTTGGTAACATTCAATTAATTTAGTAACATTAAAATATTTATACTATTCCATC AAGAAGGAACATGACTGCCCTCTTCTGTTTGGGTTGGGTATTGTAGTGGTTTTTATGGGT TAGCTCTTTTTGAGAATGCGACTTTCTAATAAGCTTTTAAAATAATGCTGTTTTTAAAAC AACGTTGTGATTTTTGAAAGCTAGTCTAACACATAGCTGTCTACAATGATTTTTTTTTTT TTTGTAATGAGGAAGTTCTTGAGTTGCTGGCTGTCAGTGCCCAGTGCAAAATAGCTCTCT AAAGATTTGCCTAATTGTAAATTCCTTTTTTTTTAATTTTTTATTTTGAGATGAAGTTTT GCTTTTGTTGCCCAGGCTGGAGTGTAATGGCGCGATCTCGGCTCACTGCAACCTTCGCGT CCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTTCCGAGTAGCTGGGATTACAGGCGTGTG CCACCACGCCTGGCTAATTTTTTTTTTTTTTTTTTTTTTTGAGATGGAGTATCGCTCTGT TGCCCAGGCTGGAGTGCAATGGCACGATCTCGGCTCACTGCAACCTCAGCCTCCTGGATT CAAGCAGTTCTCTGCCTCAGCCTCCCTAGTAGCTGGGATTATAGGTGCCCACCACCACGC CTGGCTAACTTTTTTTGTATTTTTAGTGGAGATGGGGTTTCACCATGTGGCCAGGCTGGT CTCGAACTCCTGACCTCAAGTGATCCTCCCGCCTCGGACTCCCAAAGTGCTGGGATTACA GGTGTGAGCTACCGCGCCCGGCCCATAAATTCCTTAAGCCAGCATAAATTCCTTTTGGAA TAGGCAGGACATAAATAAACATATCCTGGAAATGGAATAAGTTGGTTATATTCTTTTTAA TTAGTATATCTGCTTCGTAAAATAAGTAACTGACTAGCCTTAGTAGACTGTGGTTTCCAG GTTTATTCAGAAGTAGCAAGATCCCTCCATTTTTTTTTCTACCAAAGAAATCGTATGTGG GATCCCAAACCACAAAATAACCGTTCCTGTGGTTAATACTACTATAATGCCTGAAGTGTC TTTTGGGATCCTGAGAACAGAGTTTGAAAACATTACTAGACAGAAGGATTGGTTAGATTC ATAGTTTTGTTGTTGAGTGAAACTTGCTTATGTATATATTTATGATATTTTGGATGTAGT CTTTTGATTGTTTAAATCTTAAAAAGTAATGGGATCTTTTGACACTGGGGTATGTTTTAT TTTTATGTGTGCAAATTTTAACCATATTCTTTTCTAGTTAAAGAGGAAAAAGCAAGTTGC TCCAGAAAAACCTGTAAAGAAACAAAAGACAGGTGAGACTTCGAGAGCCCTGTCATCTTC TAAACAGAGCAGCAGCAGCAGAGATGATAACATGTTTCAGGTAAAGTTGGCTATTTTTTT TTTTTTTTTTTTTGACATGGAGTCATGCTCTGTCACCCAGGCTGGAGTGCAGTGGCGCCA TCTCGGCTCACTGCAACCTCAGCCTCCTGAGTTCAAGCAGTTCTCTGCCTCAGCCTCCCG AGTAGCTAGGATTACAGGCATCCGCCACCAGACCTGGCTAATTTTTGTATTTTTAGTAGA GATGGGGTTTCACCATCTTGGCCAGGCTGGTCTTGAACTCCTGACCTTGTGATCCAACTG CCTCAGCCTCCAAAAGTGCTGGGTTTACAGGTGTGAGCCACCATGCCTTGCCAAAGTTGG CTGTTTCTTTAGATTCAGAGGAATTATTATCTGGCTTGATCTGAAGAATGTTAAAAGTAC TATGATCTGATAATTGCCTAATATGTATGTTACAATCTTCTTAACTAGGGACATTTATTA AAATAGAACAAACTAGTAAAAGTATTTTGTACGATGCTGGATTATTGTTAAAGTCTCTAA AGTCTAGTTTTGCTGTATTTAAACCAATGCAAATTTAATTGAGAACTGCACATTTTGAAA GCAACTTGGAGGAGGCAGGTCAAGTGTTGGGACAGTAAAGTATGAATAGATTATTATGGG ACAGGAAGCAGCAATGTGACATGCCTAATTTTGGCCTGATGAGCAACAGAAAAGGGGAAT GGGTTGAATAGATAAAGTGAAGGAAGTTCATTAGAGGGACTTGATGAAATCACCTAGAGA GGACTCGTATAGCTTTTTCTCTTGGGTTTCCTGTCTTGTTTTAGGGAGACTTGACACTGG CATCTTTGTACAAGAAGGATTTGTGAGGAAGGGATGTTGGGGAATAAATGAATGCAGGTG AGATTGCTTAGGTAATTGTAGGCTTTAATCTGTATGTGAGGTGATAAGGGCTTAGATGGT TTTTCCTAAAGAAGAAATTATGCCAATTACAAGATACAGGTTAGGAAGAATGGACCAGAG GAATTAGGCAGTCAGTGAAGATGTGGACTTGATTGTGGATGTGATTGAAAAAAAAAATGG TGTTGCTTCTGTAGCACCTGAAGGGCTTAGTTGGGAAATGTTCATGTGGGATTATCAGCA TGGTTGACTAAAGCTGCCTACTGAAGTATTAAACAGAGGAAGAACAGGAAGCAGATGAGG GGATGTCTTGGGTTATATTCAGATAGAGAATGGAAGGAAAAAGAGGATGTAGGTTAAGAG AGAGGGTGAAGGAAAATTAGAAGAGTGCAGTAATGGGAGCAAGAAAAGGATGAGTGTTTC CAGGAGCTATAAGTATTAGTTGAAACCAAAAAGTTGGGTGGAACGAGACTACAATTTTTT TTTTGAGACAGGGTCTCTGCTCTGTCACCCAGGCTGGAGTGCAGTGGTGTGATCTCTGCT CACTGCAACTTCCGCTTCCTGGGCTCAAATGATCCTCCTGCCTCAGCCTCCTGAGTAACT GGGACTACAGGCAATGCTCCATGACGCCTGGCAAATTTTCTTTGTTGTTGGTAGAAACAG TATTGCCCAGGCTGGTCTTGAACTCCTGAGCTCAAGTGATGCGCCCACCTTGGCTTCTGA AAGTGCTGGGATTACAGGCGTGAGCCACCGTGACTGGCCAAGACTGTAGACATTTATATG ACTAGAAAGTAAGGCTAACACATGTATATTTTGACCTGTTGATAACTTTGAAAGGTGGAG TGCCAAGATTAAGGTGAGAATGGGAAAATTTAAGTTTTTTTTTTCCTATTGCTTATTTTT GCCTTGTTATACTTCTAGGTAAAAAAGATAGACAAAGTGCAGATGAACTATTTAGTTCAG AACACACATTTTAGAGATTCTGTTCTGTTAAGAGGAGTTTTGTGAAAACTAGATCTAATT TTAGGAATTTTCTCACCAGAAAAACGGAGCTTCATTTCTTAAACCCTCATCTGGAAAGAT TCCTAAGCCTCCTAAGGCTGACATTGCACCTTTTGAAAGCCTGCCTCTAGGAGGAACATA GGTCATCTTTTCTTTTTTTTTTTTTTGAGACGGAGTCTCGCTCTGTCACCAGGCTGGAGT GCAGTAGCACGAATCTCGGCTCACTGCAACCTCCGCCTCCTGGGTTCAAGAGATTCTCCT GCCTCAGTCTCCTGAGTAGCTGGGACTACAGGCATGCGCCACCACCCCCAGCCAATTTTT GTATTTTTAGTAGAGACGGGATTTCACCTGGTTGGCCAGGATGGTCTCGATCTCTTGACC TCGCCATCTGCCTGCCTTGGCCTCCCAAAGTGCTGGGATTACAGGTGTGAGCCACGGCGC CCAGCCTAGGCCTTATTTTCAGAGTGGCTTTCATGGATCTAGTAGTGTAGGCATTATGAA ATAATATGATACTTAATTTCATTGCCATTACAGCTTGATGTACATCAAACATCAATACAT AAGCAGTTCTCTAAATGTATTAAAGAGTTGTACCAAAGAAAAATCAATAGACTTATCTTT TAAAGTCTGAAGTGATTGGGGCAGAATCGTGACTAGAGAGAAGATACTAGAGATGCTTAC TTCCTGGTTCCTTCAGCTCTGATTTTGAAGAACTTTCTTCCATAGGGATGTAGTCTACCT GAGGTGACATCTGTGATAGTAAAGAGACTGGAGAATTATCTCATAATTATTTAGTACCTG TGTCTTGAAAGGTCAGAATAGTTGAGGCAGGAAACTTTAATCCATATTTTTCTTCAGAGT TAGGCACAAAGGGTCAGTAATACTGCTTTAGTTTATTTGATGATTTAAGGATACTTGATA CTTTTAAATTATTTAATTTAAAATGATTATAACTGGTCATTTTAATCTGGGGCAGGAGTC CATAGAATTGTTTTTTAATTTGAGTTTTCTTTTTTGTGTTTGAAGGAATTATTCATAACC TTTATCACAGGGGTCCCTCCTGCACAGGAGGTGAGCGGTGTGTGAGTGAACATTGCAGCC CGAGCTCTGCCTCCTGTCAGATCAGCAGCGGCATTAGATTCTCATAGGAGCGCGAACCCT ATTGTGAACTGCGCATGCAAGGGATCTAGGTTGTGCGTTCCTTATTCCTTATGAGAATCT AATGCCTGATGGTGGGATAATTTTTATCCTGAAACGATCACCTTTCCCCTTCCCTACCTG CTGTGGAAAAATTGTCTTCCGTGAGACTGGTCCCTGGTGCCAAAAAGGTTAGGAACCACT GCTTTATCAGATCTTCAGAGGGGACAGGGAATCAAATTCGTATAAGAATCACAGTTCTTT ATGATGTATATGCTATTTTTTGCTGCTAATCTCCAGATTTTGTGGATATAAAATATATTG TCATCTGATTTTATTTTTTTCCAATAAAATGTGATTTCAGTGATCTTTATTTTTTCTATC TTTAAGTAATATATCCCTATACTACTATCTCATCACTTGTTTAATTTTTGCTAATAAGAA TTTGTCAGTTTTACTCTTTTTTTCCCCCCAAGGGAGAGGCAGCTGTTGGGCAGATTCCTT TTTTTTTTAAAAAAAAAAATGTTTTTGAGGTATAGTTTATGTCCAATAAAACGCACACAT TTAAAAGCATACCTTGATAGGCTGTGGTAAATGTACACGCCTTTGTGGCCAGACCATTTT CATCACCCCAGGAAGTTCCTCTTGGCTTTACAGTCATTGCTCATGTCCTAGGTAATCACT GATCTTATTTCTACCACTATAGATTTATGTTGTCTCTTCTAGAACTTTGTATAAATGGAT ACATGCAGTCTATTTTTTGTGTCTGGCTTTTGCTCAGTATAATGTGTTGAGATTAGTTCT TGTTGCATATATCAGTAATTTTATTGCTGAGTAGTATTTTGTATGATAATACTACAACTT GTAAATCCATTCACCTTGGGTGGACATTGGGATTGTATCAAGTCTTGGGCTATTAGGAAT ACAACTGCTGTGAATATTCTTGTACAAGTCATTTTGTGGACATTTTTTCCCTTTTGGGTA AATACCAGATACATTTGCTGAGTCGTAGGGTAAATGTGTAACTGTATAAGACACTGTCAA ACCATTTTCCATAGTAGCTGTAGCATTTTACACAGCCATCGGTACTACTTAGGAGATTCC AGTTGCTCCACATCCTCGCTAGATATTGTCAGTCTTTTAAGTTTTTTTCTTTTTAGTTAC ATTGAATGTATAATGGTAGCTCATGGTGGTTTTACTTTCCATTTCCCTCATGTACATGTC TTAATTCATTGTACATCTTTAGTGTGTTTATTGGTTATTTTTATATCTTTTGTGAAGAGT ATCTTTTGGCCACTTAAAATGCCAGGTCATTTGAGTTGTAACACTTTATATATTTTGTCA GATGTAAGTATAATTAATATTTTTTTTAGACTTCAGGGAAACTTTAGTTTTCAAAGCAAT CTAGTTCAAAAATGAGTGGAGGTTAACAGAGAGGAAAATATGAAACCAGAGAGAATCAAA CAGACAGAATAAGGGGGGACTGGCAGTTGGTCAGGGGCGTCTGTGACAGATCTTCTCTCT CTTGGAAATGAGGTCCTCACGGATTCTGGTCAGTTCATCATTTTCTTCACGTCCACGGTT CTGCTTCTTCCTCAGGCTCTCCTCGAAGGCCAAGACCCCTGTGGCTCCAACTTGAGTGAA TATTTTCTTTAGGTTTCTGGTTTACCTTTTTATTTTCTGAAGCATCTTTTTAAAAAAGGC TTTAGTGTGATTGTCTATTCTATCGATTTTTCTCCTTTTTTGCTTAATGCTTATTTTCTG TCCAAGACGTATTTTGCCTACCATGGCCACAAAAATTTTTGCCAGTGTTTTTTCCTAGAA GTTTTATAGTTTTAGTTTTCACATTTAGGTCTATAATTCATGTAGAATTAATTTCTCTGT GTATGATGTAAGATAGAGATTTAGAGTCTTCCCCACCCCAAATGCAGATAGCCTGTTGTT TCAACACCATTTGTTGAAAAGAGTATTCTTATTCCTTTGAATTACCTTGGATTTTACCCC CTCCCCCCAAAAAAATCAGTGAATATATCCAATGCGTGTGTATTTTTTGACTCCGTTGTG TTCCACTGACCTCTTATGTCTGTCTTTACTCCAGTACTGCATTGTCTTCCCTTACTATAT TATAGTGAGTCTTGGAAAGTGCTAAGAGACACTTTGTTGAGGAAAGCCTGTTCTTTTCTC TGGAATTTGTAATTTGTGGTAAGCAGATATATAAGATTTTTGAAAAATAATTTTCTGTGA ATATTTTTAAGTTCTCAATCTGACTGTGAGTGAGGTGCATTAAAGATGTTATTTGAAGTG AACATGAAAAGGAAAAACTTGGTTGTTATTGACTGGAACTCTGGATTCGTATATTCAGAA TGGTTGGTGAAGCAGTGTAGCTAGTTGCATCTGTGGATTCCTCTTGGTTGTAGTTTGTAC TGCAAAATATTGCTTCCTAATGATTTTTTTTTTTGCTGGTAAAAACCATAAAAGTATATT CACATTGTTGTGAAACAGATTGCCGAAACTGTTTCATCTTGCAAAACTGAACCTCTGTGG CCATTAAACAACAGTTCCCCTTCTCCCAGCCCTGGTAACCACCATTCTACTTTTTGTTCC TGTGAACTTGACATCATGTAAGTGGAATCATAAAGTATTACCTTTTTCCTTTTTATGACT GGCTTATTTCATTGACGTAGTATGTAACAGGATTTCCTTTTTTAAAAGCTAATTGATATT CCATTGTGTGTCTATTCCACCCCCCCTCTCCCATTTTGTTTATCAGTTCATCTCTGGGTG GATATTTGTGTTGTTTCCACTTCTTGGCTCTTGTGAATAATGCTGCTATGAACATGGGTG TGCAGATGTCTCTTGGAGTCTGTGCTTTCAATTTTTTGGGATATATATTCAGAAGTAGGA TTGCTGGATCATATGATAGTTTAAACAGCAATTTCCTTTGGTTGCAGTTTTGATACTGAG AGTAGTACAGTTGACCCTTGAACAATGCAGGGTCAAAATGCAAGGCACCAACCCCTGTGC AGTTGAAAATCTGGTTATAACTTTTGACTTTGTCAAAACTGCTAAGTATAGCCTACTGTT GACTGGTAGCCTTAACAGTAACATAAACAGTTAACATATATTTGTATGTTATATGTATTA TATACTGTATTCTTACAATAAAGTAAGCTAGAGAAAAGAAAATATTACTAAGAAAATCAT AAGGGAGAAAAATTACATTTTACTGTACTGTATGGTGTTTATCAATAACATTAGTTTACG TTGTCTGTTTATAAGATATGTCATCTGTTAATAAAATATGTCATCTGTTAGAAATTGTAG GCAACCACAGCTGCAGATTTCAGTCCGTGGTACATATCAAGCAATTCAACTTTTTTATTT TTATTTTTATTTTTATTTTTTTGCATTTTAAAATTAAAGACAGGATCTTGCTGTGTTGCC CAGATTGGATTCAAGCTCCTGGGCTCAAGTGATCCTCCGGCCTCAGCCTCCTGAGTAGCT GGGATCATAGGCATGCACCACTGCTTCTGGCAGTTTTTTTCTTGTGATGTCATGCCTTCT CTCTGCTTCTTGGGAGCACTTTCAGCATCACTAGGGGCACTTTGTATAGGACTCATGGTG TTATTTAAAGTTTATGGTATTGCAGTAATCATGATGAAAAATAATGTGAAAACCGTGAGA GATCACTTTTTACTGCAATACGCAATTTGTTGGAGACATGAACTGCTCAGCAGAGATGAT TAGCATCACATGGTGTTTTACACAAGGTGTTTTAAGCAGATACTTGTAACATTTGAGTAC ACTGAGATAACAGGAAGTGGCTATGAAGTTAACACTAGTACACTACTGTAGTTAATTTTA TGCAGTTATGAATTAATACTCCATCTTTGTTTACATTTCTCTCTAACTTCATATAATAGA TTTGTATGTTTTATGATAGTAAGTGATAAAATAACCTCATATCTAGGTATGTTTTATGCA TTCATGACATACCTAACTTTTTCTTAATGTTTTCGTTATTTCTAGGCTATGCAGTTGTTC TGTGAGTTTTTTCAAATTGTCAAGTCTGCAAAAATTTTTCCAGTATATTTATTGAAAAAA ATATGCATATAAGTGGGACCTGCACAGTTCAGAGCCATGTTGTTCAAGGGTCAGCAGTAG TCATTTTCATGATTAGATGTAGAGTGAGCATGCAGCAAGTTGTGAATATGAATACAATTG AAACAGATACCACTCTTGAAAGGAGCACCTCTTTTTATGTTTGTTTCTTTTGCAGATTGG GAAAATGAGGTACGTTAGTGTTCGCGATTTTAAAGGCAAAGTGCTAATTGATATTAGAGA ATATTGGATGGATCCTGAAGGTGAAATGAAACCAGGAAGAAAAGGTGAGGTCTAATTACT TGAATTTTATTACAGTGTTAGGACTAAACGACAACTTTTCTGAGTAGCTTACTTGAAATG TTGGCAGGACACACGGGGCAAGGAAGAGTCTTACTCAATTGATTCTCTATCTTCTGTAGT TATTTTGGACATGATACTTAACATTTTTTTAATGAGATGTCTTAATACAGCTTTTGGGAA TAAAACCCAGAAAAGTAACACCCCTAATATCACTTCAGTTGGCTGCTAATTTACTTGAAC AATTTTTAAAAAGGTTTATGCAATTCTGAAGCAGATTAGGCACTATCTGGGAACTTGTAA AATCAGGAATGGAAAATCTTGGTTTACAATGCTTCCTTTTGATTCAGCTCCTAAAAGCTA TTCTTTAGGGCATTACTCTTCAAGCGGATCTCTGCTTTCCTTCCATTTGTGCTTCATCCA GTCCCAAGCCTCTTAGCATTGTAGAAACATATTTTGTATAATTCACCAAACAGCTAGAGA AGGTGAGCCAACCTAAATTTGTATATTTGGATTGCTGCTCTAGGTTGACCCTCAGCTAAA GAAAAATGCTTCCTTATTTAGTTTTATTCTGCCTGCCTGTTAGTTTGAAAGGTACCACTT GTTTGCTTCATGCAGTTTTTTTTTTTTTGGTTAAACTCAGCCTCTATATGTGTTTATATG CTTTCATATTTTCTTCAAGTCACTTCTGGATTGGTAATTCACGTACCAGAGTGGCCGATG CCATATTTCTTGTTTATTCTTTTTTTTCAATTTCATGGCCTTCCAGCAGTTTTCTGGGAA TACTTTCTGCCAGTTCTTGTTTACTTCTCTGTTTATATGCGTCGGTATTGGAATGCTAGA ACGTTAAAGTACAAAATATAGAAAATATAAAATTTCTGTTCATACTTTTACATCTTAAAC TGGAAAGACATATCTCACATTTTTTAACCATTTATGTGTTAGGTGATATGCTAAGTTCAT TATTCATGTTACTTAATCATTTACAACAACTCTTTGGCGTATAGATGCCATTTTACTGGT GAGGAAACTAAGGCTTACAAGGTGATGTAGTTCTTTTTTAAGGGTCATACACTTAGTGAA AGTGAGGCTGGAATTTTAACCCTGATAGGGTGACCCTAGAGTGCAGTTACCCGGGTATAC TCTCTGAGGAGTCCTGTATGAATCACGTCCTGGGAATTTTTCCAAAGTGAAATGAATGCT TCTGGAAGAACTCAGCACAATTGGCTTGAATTCCTGTGGAAATTTTGGGCAAATATTGGA ACCAGCTGGAAATATAGTAATGGGGTATCACATGCCAAATCTGGACCTGACCATTTTAGC CTGATAGTTGACGGGTATTAGTAAGATGTGTCTTCAAACCCTTATTTATTCTCATTGGTT ACAATAGGTACTATGCAGGATGCACTGTGGAAAGTAAGACTGGATATGAGATTGATAATG CTCAGTAAATTGTGATGATATGTAATTAACAAATGTAAGAGATATGATTTTCAGTATTGT AGCATTGTGTCCAAGTGGCAATTTTTTTTTTTTTTTTAGATGGAGTCTTGCTCTCTTGCC CAGGCTGGAGTGCAGTGGCATGATCTTGGCTCACTGTAACTTCCACCTCCCAGGTTCGAG CAATTCTCCTGTCTCAGCCTCTTGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCCG GCTAATTTTTGTATTTTTAGTAGAGATGGGGTTTCACCATGTTGGGCCAGGCTGGTCTTG AACTCCTGACCTCAAGTGATCCACCCGCCTTGGCCTCCCAAAGTGCTGGGATTACAGGTG TGAGCCACCGCGCCCAGCCTAAAGTGGCAATTTTGATAAAACAGTATTCTAGTTGGAAGT ATGAAAATCCTCAACGCTTAAATAGATTTTCACCTTTGAATTTTTAAACTTTGTTTTAGG TATTTCTTTAAATCCAGAACAATGGAGCCAGCTGAAGGAACAGATTTCTGACATTGATGA TGCAGTAAGAAAACTGTAAAATTCGAGCCATATAAATAAAACCTGTACTGTTCTAGTTGT TTTAATCTGTCTTTTTACATTGGCTTTTGTTTTCTAAATGTTCTCCAAGCTATTGTATGT TTGGATTGCAGAAGAATTTGTAAGATGAATACTTTTTTTTAATGTGCATTATTAAAAATA TTGAGTGAAGCTAATTGTCAACTTTATTAAGGATTACTTTGTCTGCCCACCACCTAGTGT AAAATAAAATCAAGTAATACAATCTTAACTGTTGTGGCCTTTTTTGATCATAAGAGTTGG TACTGTTTAAGGCCAAAAGTAACAGTTTTTATAGATCTTTTAGTTTCAACTCAGCTTTTA CAATAAAAAGGATTTGTATTGCATTGAGTTTATAAACTTTTGGTTTGTGAACTTCATATT TGATCTTTTCTCTTCCAATCAAATGTCTAGGCTTGTTTGACTTCCACCCCCAATGGTTTT TCACTCTTTTTATTTACTTCATTTTCCTTTAATAACTTAATCTCTTCATGTTCAGTTTTT ACTTCACTCTTTATTCTTTTCTTTGATTATGGTATGCTTATTTGGAAAGTCAGTGAAACT GTCAAAATGTTATCTCAATAAGATACTTATATGAGAACTACAATCACCGAATCTACTGTA TTCAATATTAGCAGATCTAATTTGATAAACAACATGGCTTGTGTGAAAACTGAGCAGGTG TTTGTTTACCCATAGTGTTCTGTGTAGTTATTGCTTAGTCTGCAGAAAATAATGACTTAG ATGAGATGTCTGACTTGCTTTCACTTATTAAACATGTTCACCATGGGATGATGTCTGTAA CATCAGATATTGTTCAACTAGACTAGGATTTAATAAAAATTGTGAAAGCTTACTGGCCTA ACATTTTATTTTATAATATTGGGTATGAATTATATGTAGCCAGAGATGTCATTAAGCTTT ACTGTTATAGTAGGTAATATGGTTAGTTTGTAGGGAAAAGAGCATATGAGCACATGCTTG TGTATTTTGGCCTTTGCCCCAGTAGAACAGACCAATGGCATTCTAGACTTGATGATACTA AGTTTTAGCAGACACTAGTAAGTGGTTTGTATTTAACCATACTGATGAAGCAGACAGATT GAGGCACAGATTTTAGTGGCTTTGTGGCAATAAATAGGGCATGGTGTGCCTTAGGAAAAG AATGTTTATAAAGGGAATTATAACTGAAATTAAAGGAGGCGGCAGTGAAGAGGAAATAAT TCTCTTCTATCTAAATGATATACATATGATATTTTGAGATTTTTATAACAGCAGTGGAAC ACAATTCTAGGTAGAGTAGAAAAAGGAAAGTTTTAAAGACATATAAAAGATTCTTGTTGA CAAATTATTTTTGGTAGCAAATCTCAAATGGTTACCTGCTATTAAGGTCTGCCATATTAG AGTTTTGCACTATTTTGCTACCAAGTTTGATTCATACATCTAAAACATTTTG >15.12014047-12028561 ~~~~~~~~~~~~~~~~~~~~~~~GAAAATCATCTGTAGGCAAGTGGGTCAGCACATTGTT TTTTCTCAGAGTAGCTCCATCATTTCAGTACAG~~~~~~~~~~~~~~~~AAGCGCAAAGC TCGGATCTTGTCATTTATGTTTCATTG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CGGCCCCTTTAAGGCCCTGGAAA GGGCCGGC-TGGCGGTTGG-GCGGCGAGGCCACGCCCCCTTACGTGGCCTTCGTGCCATT G-GGCGGAGCCAGGGCCTCTAAGCTGCCGTCATTTCCGGCTCTCTGTCAGTCCGGAG~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CCGGGCGGAGCGTGAGTGCGTGGGACCCCGG GCCCAT--TCCTCGGGGC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~GGGAGCCGAGCCGAGGCGGTGGGCGC~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AGGAGAAAATGGCGCT- GGCGCAAGGCCCTCCTCTT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTAGGTTAATAATGACGTGGTTCTTTGAAGTA ATTTTAGTTCCCCAGACAGCTTTTCGTAATGGGAGATAGATATGGCTGGCTGTTTGCAAG CGAAAGATT-TGTTTATGTGCAATTCCCTCTCAAAAAACAGGTTTGTGTAGTTGTG-TGA CCG-AGCTAGCTTGGGAAACTTGATTTTGGAGGTCGGGTTGTGAAATGGAGCAGTAAGAG GAAAAGCG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GC-AGGATTTGGGTAGCT CACTT-TTG--CCTTGACCTCCTATTTTG~~~~~~~~~~~~~~~~~~~~~~~ATGCCAGT TTGGTCTTTAGAG--AGCTGGGTTATAATTTTTTTG-ATGTAGGAGGTAGGAATTGATGT ATCTT-TCTTGAGCATTTACAGAATCT--TGTGTTTTTTAGGACCTTTAAGCCATGTAGA AGTTAGTAAGTTTAT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GATGGAGAGAGCAGAAGATA GTTTGGTAAATAGCTTTTGCT-ACCTGGTTTTA~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTCACATTTTATATATTTCCCTAAG TAGAAAA-TCAGTGCAAAAT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GAATTGTGTATAACAT TGTGAACTCC-GA-TTGTTGCCTGTTGTTTTGATAGTG-T--GGCCACAAAGTAAAAACA GGTATACAGAAC-ATGTAAAAGTGATTTA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ACATTTCTCTTGATTTTACG-GT CATTATTCTCAGCTGCTTTCTTGTAGTCTACCC-ACAAACTTTATAACCTGTC-TAAAAA TCAGTTGTTAAAAGGCCCATTGACTTTGAGAAGGGTGA-AGGAAT-GT-GCACATGGCTT TTATTTCTTTTTTCTGACTGGGTTCAGAATAATTGGCTGTGCTTGTTGTTTGCAATTTA~ ~~~~~~~~~~~~~~~~~CATGTGTTCTGTGTAACGACTCCGTACCACAAAAA-GGCAGAA TGAGCTGTGGAAGTT~~~~~~~~~~TTTTTCTTTTGGTCTGGGAGAGCTAAGATGAAGGT ACTAAAACACCTTGTAAATTATTCATGTGATGTCTTTTTCTTTCAGAATGCCTAAATCAA AGGAACTTGTTTCTTCAAGCTCTTCAGGCAGTGATTCGGACAGCGAAGTTGAAAAAAAGG TAACTTTTACTCTACCAAGTTCTTTT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GACCCAGCTCAGA CTAAGCAAGTCCTCCATTGAGCACCTCTAGTAACCA-AGAGTCAAAGAAATGCTTCATTA GACTCTAGAGCACTAGAATTCTAATGAGACCAAAGACACTACTTATCATTATTTAGAAAT T~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~TACTGAATTTTAGTTTTGGTACATTTT-AACTTT~~~~~~ ~~~~~~~~~~~~~~~~~~TTTTAGTAAATAAAGTCATCCAACAGCAAATACAAAATTACC CATTTTGTCAGAATAAGCTTTTTCTGTGTTAGGTGATCGTTGTTTTGTCAACT-TCA-TT CCACTCAATTGATCACAGCAGTGAAGTGTGACAGAGCTGTTCACCTTGTGGTCAAGACTT CCTTCCACACCGCTGTGTCTTA--ATAGAAATTTA--TGTCTGAATAGACATTCATATCC TAGAAATTGAACACATTG-TA-T-TCAC-CCTTATTTGTTTACTTGCTTTGTTGAAAA-T AAGTAATTAAT-GCAC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AGAAAAGGG-AGC TC-TATAGGAAAATAGGAAAGTTGGAGCCTATAAATGTACAGATAGACTGTAGTATCATT TATAATTTTGAAATAAGGCTTCAAACATCATA~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~GCTGACTGTGTACTTGTCTCACA--GTACTATTAATTCTGTAAACATTTA CATTAGGGCTCCATAGTTTTCATTTCAT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~TTAGTAATATTAAACTAGTTGTCCT-TTCCACT AAGAAGGAACATGCCTGCCCTCTACTGTTTGGGCTGG~~~~~~~~~~~~~TTTTAACTTT TCGCTCATTTTGAGAATGAGGTCATATGCAATTTTTTTATACTAGTGCTAATTCTAAAA~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TC TTAGTGCTGAAGAAGTTTTTGAGTTGTTGATTTTCAGTGCCTGGTATAAGATAG~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ATACATTC-TTGAGAAAGTACAGATACCTTTTGGAA TAGACA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GTGGTTTCCAA ATTTATACAGAAGT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CTGTTTTAACATCTGAGGAATC TTTGGGGATTTTGAGAGTAGAGTGTAAAAATACTATCATTGTTATGTGAAGACTAGATTC ATAGTT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GTTAAAGAGGAAAAAGCAAGCGGT TCCAGAGAAGCCCGTGAAGAAGCAGAAGCCTGGTGAGACTTCTAGAGCACTGGCATCCTC CAAGCAGAGCAGCAGCAGCAGAGATGACAACATGTTCCAGGTAGAGTCGG~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~GTGAGGGTAATTTGTTCAATTCTGGGCTATTGGTAAAAGCCCAAG AGTCTAGTTTTACTATATTTAAATGA-TACAAAT~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~TTTCTCACTAGGAAAAAAGAGCTT~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~TTTGTTTTTTTTTTTTTT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~TATTTCACTAACGCTATAGCAAGCAGGATTGCCTATATAAAGACTGAATAG-TGTT CCATTGCATGTGTAAGCCA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CATCTAAGGATA GACTTTTGGGTTGCTTCTACTTCTTAGCTATTATGAATAGTG~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CAAGTTGTGAATATAAATTCAA~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GCTGATTGG AAAGATGAGATATGTCAGTGTTCGGGACTTCAAAGGAAAAATTCTAATTGATATTAGAGA ATATTGGATGGATTCAGAAGGTGAAATGAAACCAGGAAGAAAAGGTGAGGTTTTATTTCT TCAGTTTGAT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTAAAATG TTA-CAGGGAATACAGGTTAAGGATTGGCCTTACTTGGTTGATCCTCT~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~TTAT-CAGTTCCTAGGCAGATTAGGCATTACTTTGGAAACTGTAA AATGAGAAGTAGCAAACCCTGGGTTT-AGTGTTTGCTTTGGATTCAGCTCTAGCAAGATG TTCTCTAATACAG-AGTCCTTAAA-GG-TCTCTA-TCCCCTTAGTTTGGTGCTTTGCCCA GTTC-AAGCCTCTTAGCAT-GTAGAAACA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTCCATGGTCCTC-AGCAGTTTTCTG~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTCCCAAAGTGAAATGGATGCT GATGGAAGAACTCAGCACA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTATTGGTC AAAATAGGCATTATGTAGG-TGCACTGTTGGAAGTTAAACTGGATATAAAATTGA~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~ATTTTCACCTT-GTATTTCTAAACCTTGTTT-AGG TATTTCTTTAAA-C-ATGACAATGGAGCCAGCTGAAGGAACAGATCTCTGATATAGATGA CGCAGTAAGAAAGCTGTAAAATC-GAGCCATATCAA-A---CCTGTACTGTTGTAGTTGT ~~~~~~~~~~~~TTTTACATTGGCTTTTGTTTTCTAAATGTTGTTCAAGCTGTTGTATAT TTGGATTGCAGAACAATTTGTAAGACAAATACTTTTTTTTAATGTGCATTATTAAAATGT TCAAGTGAAGCTAATTGTCAAGTTTATTAAAAGTTGCTTTGT--GCCCCCTACCTAGTGT GAAATAAAGTCAGATCATTCAATCTTAACTGTGGTACCCTTTTTTGATCAAAAAAACCAG TTCTGTTTAAGGCCAAAAG-AACA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TA CATTCAGAAGGATTTGTATTACATTGAGTTTCTTAGATT--GCTTTGTGAAATGTATACT CAGCCTTTTTCTTTCCAACCAGAT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CTTATTTAGAAAGTCA~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AACATGACTTATATGAGAACTCCACAAGTG TATGTCTATTCATAGTGCTCTGTGTAGATGTTGCTTAGTTTACAGAACATAGTGACTT-- -TGA--TGTCTGATGAGCTGTCACTCAGTAAACATTTGTGCTA-GGG-TGATGGTTATAA AGTCAGATATTA---AACTAGATTAG-ACTTG-TAAAAAGTGTGAAA-CTTACTGGCCTA -C-TGTTATATTCTAATAATGTGTG-GA-TTCTATGTAGTCAGATGTGGCACTGAGCTCA ACTGTGGTAG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ACAAGTGAC-TTCCAGACTTGATGTTAATA GGTTTGAT-AGACATTTCCAT-TGGTTTTCATTTCATTGTGATGATTAAGCAAGCAGAC- -AGGCACATGTTTTAGGGACATTGCTCCAATGAAAAGGGCATAGTGTTC-TGAGGGAAA- A-TGTTTGCAAAGGAAAGTC-ACCACAC-TGAAGGGAGCTAGCCTTGATGAGAAAGGAAC TTTCTTGAAACTAAATGTTGTGCACATGATATGTTG~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TGCCACTAAGGGCTGCCATATCAG AATT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ wise-2.4.1/test_data/phased_roa1.pep0000644000175000001440000000065310452004606016716 0ustar philippusers>ROA1_HUMAN Human description thingy! MSKSE0SPKEPEQLRKLFIGGLSFETTDESLRSHFEQWGTLTDCV0VMRDPNT KRSRGFGFVTYATVEEVDAAMNARPHKVDGRVVEPKRAVSRE0DSQRPGAH LTVKKIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAFV TFDDHDSVDKIV1IQKYHTVNGHNCEVRKALSKQEMASASSSQR1GRSGSGN FGGGRGGGFGGNDNFGRGGNFSGR1GGFGGSRGGGGYGGSGDGYNGFGND1G GYGGGGPGYSGGSRGYGSGGQGYGNQGSGYGGSGSYDSYNNGGGRGFGGG S1GSNFGGGGSYNDFGNYNNQSSNFGPMKGGNFGGRSSGPYGGGGQYFAKP RNQ1GGYGGSSSSSSYGSGRRF wise-2.4.1/test_data/pep.fa0000644000175000001440000000247110345025225015117 0ustar philippusers>ROA1_HUMAN Human description thingy! SKSESPKEPEQLRKLFIGGLSFETTDESLRSHFEQWGTLTDCVVMRDPNT KRSRGFGFVTYATVEEVDAAMNARPHKVDGRVVEPKRAVSREDSQRPGAH LTVKKIFVGGIKEDTEEHHLRDYFEQYGKIEVIEIMTDRGSGKKRGFAFV TFDDHDSVDKIVIQKYHTVNGHNCEVRKALSKQEMASASSSQRGRSGSGN FGGGRGGGFGGNDNFGRGGNFSGRGGFGGSRGGGGYGGSGDGYNGFGNDG GYGGGGPGYSGGSRGYGSGGQGYGNQGSGYGGSGSYDSYNNGGGRGFGGG SGSNFGGGGSYNDFGNYNNQSSNFGPMKGGNFGGRSSGPYGGGGQYFAKP RNQGGYGGSSSSSSYGSGRRF >Q22037 this here we go! MTDVEIKAENGSGDASLEPENLRKIFVGGLTSNTTDDLMREFYSQFGEITDIIVMRDPTT KRSRGFGFVTFSGKTEVDAAMKQRPHIIDGKTVDPKRAVPRDDKNRSESNVSTKRLYVSG VREDHTEDMLTEYFTKYGTVTKSEIILDKATQKPRGFGFVTFDDHDSVDQCVLQKSHMVN GHRCDVRKGLSKDEMSKAQMNRDRETRGGRSRDGQRGGYNGGGGGGGGWGGPAQRGGPGA YGGPGGGGQGGYGGDYGGGWGQQGGGGQGGWGGPQQQQGGGGWGQQGGGGQGGWGGPQQQ QQGGWGGPQQGGGGGGWGGQGQQQGGWGGQSGAQQWAHAQGGNRNY >ROA1_XENLA P17130 HETEROGENEOUS NUCLEAR RIBONUCLEOPROTEINS A1 HOMOLOG (HNRNP A1) (HELIX-DESTABILIZING PROTEIN) (SINGLE-STRAND BINDING PROTEIN) (HNRNP CORE PROTEIN A1). MHKSEAPNEPEQLRKLFIGGLSFETTDESLREHFEQWGTLTDCVVMRDPNSKRSRGFGFV TYLSTDEVDAAMTARPHKVDGRVVEPKRAVSREDSSRPGAHLTVKKIFVGGIKEDTEEDH LREYFEQYGKIEVIEIMTDRGSGKKRGFAFVTFEDHDSVDKIVIQKYHTVNNHNSQVRKA LSKQEMASVSGSQRERGGSGNYGSRGGFGNDNFGGRGGNFGGNRGGGGGFGNRGYGGDGY NGDGQLWWQPSLLGWNRGYGAGQGGGYGAGQGGGYGGGGQGGGYGGNGGYDGYNGGGSGF SGSGGNFGSSGGYNDFGNYNSQSSSNFGPMKGGNYGGGRNSGPYGGGYGGGSASSSSGYG GGRRF wise-2.4.1/test_data/rpo_mouse.gen0000644000175000001440000003467307571667333016562 0ustar philippusers>15.12014047-12028561 TCGTGGCTAAGGACATTTGTAAGATTTCTTTGACTTTCTGAATTAAATAGTGCGCCTCGC AGGCTTGCTTCCTTTGGATTTTAGCAGCATGAGTCAGATCTTAAAGGTAGAAACGGAAAA TCATCTGTAGGCAAGTGGGTCAGCACATTGTTTTTTCTCAGAGTAGCTCCCATCATTTCA GTACAGCATTTATAGAGCGGTACCATATACAAGCTATTTGCAAGCGCAAAGCTCCGTGGA TCTTGTCATTTATGTTTCATTGACATCTCATTCTCCTTCAGATCAGGCCCAAGCTGCGTG GCATCTCACTGTGGTGCCATCTCCCTCTTTCAGGAGCATTTACTTCAGTATCTGTGGCGG CCCCTTTAAGGCCCTGGAAAGGGCCGGCTGGCGGTTGGGCGGCGAGGCCACGCCCCCTTC ACGTGGCCTTCGTGCCATTGGGCGGAGCCAGGGCCTCTAAGCTGCCGTCATTTCCGGCTC TCTGTCAGTCCGGAGTAGGCGAGCGAGCGAGGCAGAGGTTTTTGGTCGGCCGGAGCGGAG CGTGAGTGCGTGGGACCCCGGGCCCATTCCTCGGGGCTGCGGCCAGGCCGACCCCAGGCT ACCGCGGCCCCCTTCGCTCTCCTTGCCGGTGGGGAGAAAAACGGCAGCTCGGGGGAAGGG CCTCCGCTCTTGCCCGCGTCCCCGCGGGGCCTCGTGTGGCGGCCGCTCTGGGGAGCCGAG CCGAGGCGGTGGGCGCGGGCAGGCAGGCGAACGGCGGGTGATGGCCGCGCGCCCCTCGGA CTGGGTGATGGGGCTCCGGGCGGAGGCGCTAGCGGTCTGCCCTGAGGCTGCGCTCGCCCA CCCCTGTCCGGACCACCGTGCTCGGGAAGCCATCCCTTCCCCACCCTCGGGGGACGCTGG CCCCGCGGGGTCGAGGGGCGGGGGGCGCGCTCGGCAAACATGGCTGGGCTCCGGGGCGAG GAGAAAATGGCGCTGGCGCAAGGCCCTCCTCTTGTGCACGCTCTCGACGCCCCACGCCCC CTTCCTGAGGCCGGCAGTAGCCCCAGCCCTCGCCTCGGGGCTTTCGGGAGCTTCCTGGCC GCGACCCCCACGGTGCCACGCGCCGGCTCGCCCTCGAGAGCCTCGCACTCTGGGATGTTT TCAGTATTCCCCAGCCCCGGGCACCGACTGGTCGGTCTATAAACTACGGTCACCCCTTTT AGTTACCTTTTGCTCGAATTACGAAGCCCCCCGCCCCCCGGCCTCCAAGAAACCACCCCA GTAAAGCCTCATTAAAGTTAAAAGTCCAAGTGTAGGGAACGGGGCTGGCTTTAGTTCCCA GTAACAAACATTGTTTTCTTATTGGGTAGATTTAGGTTAGATAATGACGTGGTTCTTTGA AGTAATTTTAGTTCCCCAGACAGCTTTTCGTAATGGGAGATAGATATGGCTGGCTGTTTG CAAGCGAAAGATTTGTTTATGTGCAATTCCCTCTCAAAAAACAGGCTTTGTGTAGTTGTG TGACCGAGCTAGCTTGGGAAACTTGATTTTGGAGGTCGGGTTGTGAAATGGAGCAGTAAG AGGAAAAGCGAAGGGACTGGTTAGGAGCCTTCTCCCTCCTGAGTTTAGGTATTACCTCTA ACGGACTGGCCAGTTGTGTAGAGTCGTGGGCAGGATTTGGGTAGCTCACTTTTGCCTTGA CCTCCTATTTTGCACATTGAATGCCAGTTTGGTCTTTAGAGAGCTGGGTTATAATTTTTT TGATGTAGGAGGTAGGAATTGATGTATCTTTCTTGAGCATTTACAGAATCTTGTGTTTTT TAGGACCTTTAAGCCATGTAGAAGTTAGTAAGTTTATTTAGATGGAGAGAGCAGAAGATA GTTTGGTAAATAGCTTTTGCTACCTGGTTTTACCATTTGGTGTAAGTATCTTGAAAAGTA GTTAGGACCTGCCTAAGGACTTCTTGAAATGTGGGTTAGACGAGTTGTCTGCCCTTTGTT TTATGCAGTAAATAAACAGCAGGCTCTGCACTGTGTGCCTGTCTGGTGAGTTTTGCCTTG CACATAAAGCCTTCACATTTTATATATTTCCCTAAGTAGAAAATCAGTGCAAAATTATTG TGAATTGTGTATAACATTGTGAACTCCGATTGTTGCCTGTTGTTTTGATAGTGTGGCCAC AAAGTAAAAACTAGTGTATACAGAACATGTAAAAGATGATTTATAAGGGCAAAATTAATT AGGTATTATGCTTACATGGGCAAGCTGTTTATGTTGGAGCTGGTCCCCTCAATGTGAGTG GAATTATGTACATTTCTCTTGATTTTACGGTCATTATTCTCAGCTGCTTTCTTGTAGTCT ACCCACAAACTTTATAACCTGTCTAAAAATCAGTTGTTAAAAAGGCCCATTGACTTTGAG AAGGGTGAAGGAATGTGCACATGGCTTTTATTTCTTTTTTCTGACTGGGTTCAGAATAAT TGGCTGTGCTTGTTGTTTGCAATTTAGACATGTGTTCTGTGTAACGACTCCAGTACCACA AAAAGGCAGAATGAGCTGTGGAAGTTAATTTTTTCTTTTGGTCTGGGAGAGCTAAGATGA AGGTACTAAAACACCTTGTAAATTATTCATGTGATGTCTTTTTCTTTCAGAATGCCTAAA TCAAAGGAACTTGTTTCTTCAAGCTCTTCAGGCAGTGATTCGGACAGCGAAGTTGAAAAA AAGGTAACTTTTACTCTACCAAGTTCTTTTATAGAACAAAATGTATGGTGCATTAATTGC TCTATAATGCTGACATTGAGTTTTGAAGGGAAAGGCCTGTCAGTCTTTTAAAGTAGGTTT TGCTATGCATCCTAGACTTCTCCAAACACCTGGGATTTCCCTGGGGGGTGGGGGTGGGTG GGACGCTGGGATGGTGTTACCAATGCTGGGCTCAGAATGTGAGAGAATCTACAAGGGTAA TTTTGTAAAGATAAATGACTGATGGATTCCTTGAGTAGAATATTAGATTCTAGTCTCATC TGCAGGACTTACATCAGATTTAAGAGGTCTTTGTGTTGTACTTGGGGTTCAGCCTGGCAG CCCAGTGCATCCTAGGCAAGTACTTGCTATATCTTTAGCCTTCTTCTTACTTTTTATTTG CAACAGGGTCTCAGTAAGTTGTTGGGCTGACCTTGTACTTTTGTCCTTCTGCCTCACCCT CAGGATTAGGGACCCAGCTCAGACTAAGCAAGTCCTCCATTGAGCACCTCTAGTAACCAA GAGTCAACAGAAATGCTTCATTAGACTCTAGAGCACTAGAATTCTAATGAGACCAAAGAC ACTACTTATCATTATTTAGAAATTCGTGTCATTCAAAAATCCAGTTGATCTAGCCTGCTG TGGCGCCTCGTGTGAGTTTGATCTCTGTTCTTCCACATGGTAGGAGAAGAGACCCCATTA TACCAAGTTTGTCCTGTAACCTCATGTACCCACATACAGGCACCACACGTGCAACAAATA CAAACTGATGGTAATAACATTTCCAAAGCTCTGTCTGACCTACAGGTATAAGTCACTATT GGGCTGCATGGATTTTTGAATGAAAACATTAATGTTGATAGTTTCTCAGTCATTGCTCCT CTTCAAATTACTGAATTTTAGTTTTGGTACATTTTAACTTTAAAAGTTATTTGCTTTTAG TAAATAAAGTCATCCAACACAGCAAATACAAAATTACCCATTTTGTCAGAATAAGCTTTT TCTGTGTTAGGTGATCGTTGTTTTGTCAACTTCATTCCACTCAATTGATCACAGCAGTGA AGTGTGACAGAGCTGTTCACCTTGTGGTCAAGACTTCCTTCCACACCGCTGTGTCTTAAT AGAAATTTATGTCTGAATAGACATTCATATCCTAGAAATTGAACACATTGTATTCACCCT TATTTGTTTACTTGCTTTGTTGAAAATAAGTAATTAATGCACCTGTGGTTTACAAAGTGT AAAAGCAGCAGGCAAAGCTAGTTTTATAGTTCACTTGGTAGAGTGCTAGTCTAGCACTCA GGAAGTCCCAGGTTTGATCCCCTAGCCATGGGAACGGAAGCAGGAGGGTCAGAAGTTCAA GGTCACCTGGGATAATGGGGACCCTGTTTTATTTATTTAAAGCAGCAACCCCCCCTCTTC TTAAAATTTTTTTTAAAAAAATTTTTGTTATTGTTTAGGTTTTGTTTGTTTTTTTGGCCT CTGTACTCCCTAAGAAAAGGGAGCTCTATAGGAAAACTTAGGAAAGTTGGAGCCTATAAA TGTACAGATAGACTGTAGTATCATTTATAATTTTGAAATAAGGCTTCAAACATCATATAT AGCTGTACTTGAAGTCTTTTCAGAACTTGTAGAGTGTAGCCTCTAAGAGTGAGTGTCACT GACACTGAGGTTACTTGCTGCGTGCACCACTCAGAGGATTGTGTTTTGCTTAGCTGACTG TGTAGCTTGTCTCACAGTACTATTAATTCTGTAAACATTTACATTAGGTGCTTCCATAGT TTTCATTTCATAGCATATTATTGCCCTAGCCTCAACAAATTTAATATACGTTTAGTAATA TTAAACTAGTTTGTCCTTTCCACTAAGAAGGAACATGCCTGCCCTCTACTGTTTGGGCTG GAAACTTAACATGGGTTTTTAAAAATTCTTATTTTTTTAACTTTTCGCTCATTTTGAGAA TGAGGTCATATGCAATTTTTTTATACTAGTGCTAATTCTAAAATATGGGGTTGAGTACAC TAGTCTTACTACTGTCCATCATCAATTCTTAGTGCTGAAGAAGTTTTTGAGTTGTTGATT TTCAGTGCCTGGTATAAGATAGTAACTTCCTTTACCTAGGCATGCTTTTTTATTTTTTCC TCCTAAGAGTTAAATTATGTAGCCCTGACTGGCCTGGAGCTTGCTATGTAGTCCAGGCTG GAAGCATACATTCTTGAGAAAGTACAGATACCTTTTGGAATAGACAAAGAATTAGTAAGT AGTCAGTTTTAGTCATAAATATGTTGGTTTTGTTTGTTTTTTTGTTTGATCTTCAGCTTT CCTGCCTCAACCTTAGTCAGGGTTACAGGATATACCAGTATACTTTGTTTTTAAAAACTT AAAATAATAAGAGGAAAGCTTCTGGTGGATTTGTGGTTTCCAAAAGTTTATACAGAAGTT ATAGGCTGCTTGTCTTTCTCTTTCCAGAGAGTAGTGTGTGGGTTCTAGTTCACAAGATCA CTGTTTTAACATCTGAGGAATCTTTGGGGATTTTGAGAGTAGAGTGTAAAAATACTATCA TTAGTTATGTGAAGACTAGATTCATAGTTAAAAAATTTTAATGTACATATTTTTCATAAG TCAAAAATTTGAGTAACTTTTTAATGAAGTGTTTTGAACTTCACAAGTGTGTGTTCTTGC CTGTTTTAAGTTAAAGAGGAAAAAGCAAGCGGTTCCAGAGAAGCCCGTGAAGAAGCAGAA GCCTGGTGAGACTTCTAGAGCACTGGCATCCTCCAAGCAGAGCAGCAGCAGCAGAGATGA CAACATGTTCCAGGTAGAGTCGGAGGGCACTGAGTCCAGTGGACAGATCCTGATCTGAGC ACACCAGTCTTCCCTTGTATAGTCCTCTTGACCAGAGTAGAAAGTGAGGGTAATTTGTTC AATTCTGGGCTATTGGTAAAAGCCCAGTAGAAGTCTAGTTTTACTATATTTAAATGATAC AAATCCAAAGGTCACAGAAAGCCAAAAAAAGATTTAGAACTATATATTGGAAAGNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNGTAAGTAGATAAAGTGGTGAAAGAAA ACTAAAAGTAGTAGAAGAAAGAAATAGACAAAAAGAAAATGTAGATTAATTATTTAGTTA TAGGTTTCAGTTCTTCGACTTCAGTATAGTTTCGGGGCAAAGGTTGGTTTGATAGAGAAT ATAGGTGAAGGTATGTGATGAGGAATGTAAAAGAATGCTGTTATTGCTTCAAATGGATAT TAAGTTGGATGCTTACAGTGCTCTATTTCATTCAGGCTTTGCCAGGTCCTAGTAATCCAT GTGGAATGTGATCTGTAACCTTGTGGAATTTAAGGGAACCATGATTACATACGCATAGTA AAAATGACAATGGGTCCTGAGAAGTAGTGAACAGATTGAGAGAGTAGGCATGAGAATCTC ATTAAAAAGATAAGGCACCTAAATCTTAAAACGTGATCGGTGCGGTGTGTGGACAAAGGG AGCATTTTCAAGAGCAGGAAATTGAGTTAATACCTTGAAGTGGGAAGGAGCTCGGGTTGT GTATGAACTACAGAGCCTGTGTGGTTGAAGCCTGGGAAGTCTTGCTGATATCAGAAGTCT GGTGGAGATCTTCCAGGGCTATTTGACTTAAGTACAGCGAGTAACTGGGGCAGGATAAAT ATATAATTGACTAGAGTATTTTGTAGTGTTTGTAAAGAAGGGCTTTGGAATATCCAGTTT CATAACTGTATCTTGGCTTTCTTTTACCATCATGCTGTGCGCTTTCCTTTCTACCTCTGG CCTGATGGGGTGGGGGGAGTCTGAATTGAGGGTCTTTTTGTTTGTTTTGTTTTTAATAGC CCTAGCTTACTTGGAAGTCACTATATAGAATAGGCTAATTTGAGTTTTTAGCAATCCTCC TGCCTCTCCTCAAGAGCAGAGGCTGTAGACATGTATTACCATGACTTTTAAAAGTTGTTT TTTGGTAGAGATTTTTGAGAAATGGGGTCTATTTTTAGGGGATGACTTTTTTTTTCTCAC TAGGAAAAAAAGAGCTTTGGTTCATTTTTTGTTGGGTTTCTTGAGACAAGGTTTTTTTGT ATGGCTCTGGCTGCACAACAGAGCTAGTTTTAGACCCACAGAGATCCACCTGTAGCGTAC ACCTACAGTTTTGCCTTTTATGAAGACTTTTGTCTCAGTCAGTGTTCTGTTGCTGTGAAG AGGCACTATACAACTCTTAGAAAAACATTTTCTTGGAGCTGGCTTACAGTTCAGTGGTTT AGTCCCTTGTCACCATGGCAAGAAGCGTGGTGGCAGGTAGGCAAATGACTTGCTGGAGAG TAGCTGAATTCCACGGGCAGCCGGAATGGAGAGACACTGAGTGTGGCTTGAGCTTCTGAA ACCTCAAAGTTCACTCTCACTTCCTCCAAAAAGACTGCACCTACTCTGACAAGGCCAGGT GTCCTAATCCTTTAAAATAATGCCTCTCCTTAAGAGCCTAAGGAGGCCATTTTCATTCAC ATCACAACAGCGGCCCTTCCTTTGAATACTTTGGATCTTTCCTAAATAACTTGGTGAGTT TATTAAATGCATGCCCTATTTTTGGGCTGCATTCTTAATTCTTGTCCTATGTCTGTCTGC TTTAGTACACACTTTCCTTACATGTACTGAATCTAGAAAGTGGGGACATTCAAAAACCAC ATAGTTTGTGTTAAGCCACCAGTATAAATAAGGTTTTTTATTTATTTTTTAAAAATGACA GGGTCTCGGTATGTAGGCCTGTCTCTTAGCTACAGTTTTTGTTGCTGTAAAAGACACTGA TCATGGCAACTCTATGTGTAAAGGAAAACTTTTAATTGGGGCTGGCTTTTATAGTTTCAG AGGTTTTATAGTCTTCAGAGGAAGAGCTGAGAGTTCTGTATCTTAATCTGAAGGCAGCAA AAGCTACTGTGAGCCACACTGGGCATAGTTTGAGTATGAGACCTCAACGCCCACCCCCTA CAAGTGTGTACAGTGTTGTAAGATACTTGATCACACTGTGAACCCTGAGATTGTATTTAC TGGAAAAACCTGTTTTTAGTTGTGTGGCTCAGCCTTAGCACATACCTTTAGTCAAAGCAC TTGCTGCTTGAATATTGTAAACAGGATTAAACAAAGTCAACCATAGGTCAAGAGGCAGAG CAAGTGACAGGAAGTGAGCATAGGATCATTAAGAAACGTAGAGGACAAGAGGAGTCAGGA GGACAGAAATGCACAGGAAGGAGAAGGAGGGACATTGAGTTTGAAGGAATTTGTTTGACA TGGCGTGAGAGAGAGGGCATTCTGGTGGGACTTGGGCTAAGGAGGAAGGTTAGTCAGCTG GGTGCTTTCTCTGCCTCTCTGAGCTAGCAATTTTCCACCCCAGCACCTGGCTCCCAAGAC TTCATTGGTAAAATCAAATAAATGATTGTGATTTTGTTTTGTGTGTTTTGCTTTTTTTTT TTTTTTTTAAACCAACAACAGTACTCACTTCCTCCAATAAGGTCATATGAACTCTAACAA GGCCACACTCCCCAATAGTTGCAGTCCTGTGGGCCAACCATTCCAGCTCATTGGTAGCTA GCTGTTTCTGTTCAGCCAGCACACCCTTGGTAGCCTGGAGCTTGCTATGTGTAAACCAAG CTAACCTTGAACACAGCTGCCTGTTGCTGCCTTCTGAGGTGTTTTACTTTTTGATTTCTC TGAGTTTACTGCATTAGGCTGTAGGCATTTCATTTAGGTTGAATCAGATTGTACTGCTGT TATTTCACTTAACGCTATAGCATAGACAGGATTGCCTATATAAAGACTGAATAGTGTTCC ATTGCATGTGTAAGCCATGTTCTATTTGTGTCCTCATCTAAGGATAGACTTTTGGGTTGC TTCTACTTCTTAGCTATTATGAATAGTGTAATTAAGGATAGTTAAGATCTCTTGGGAGAC TCTACTGCCAGTTGTTTTGGATGTGCAGTTATGTGCCGCAAGTGTCAGTCAATTGAACAC ATACATATAAGTGAGGATACTCTAGGATTGGTACCATGGTGTGTAAGTTGTCTCACTAAG TACATTCTGATGCTCACACAGGAGAATCTTCTGAGTATTCATTTCTCAGAATATGTCCGG TCTGTTAAGTATATGTTTTGCCCTCAAAGCGGGATTATTGGAACATTATGTTTCTATTTT TGTCAAAGGACATCCATTCTATTTACTGTGTTATATTAAATTTCATAATTTTTAAAGTGA GACTGAAGAAAGATAGCTCAATAAGCAGAAATGCTTGTACAAAGAAAGACCAGAGCTTTA ATGCTCAGCACCCCCCTGAGGTAGTTGGATTTGGCTGCAGATGGCTATAATCCCAGCACT GAGGGGCAGAAATGACAGCTCCTGGATACTCTGTGGTCTGCCAACTTAACAGTGAGAGAT CTTTTCAAGGCAAGGCAGAGAATGATAAAGACACTTGAAGTCATTCTGTGGACATACATA CATGCATGCACCCCCCCTTCCAATTGCAGTTGAATACTTATTCCAGGATTATAAGTGCAA GTTGTGAATATAAATTCAAAACCTCTCTTTATGCATTTTCTTTCTCACTCTCTGCTAGAT TGGAAAGATGAGATATGTCAGTGTTCGGGACTTCAAAGGAAAAATTCTAATTGATATTAG AGAATATTGGATGGATTCAGAAGGTGAAATGAAACCAGGAAGAAAAGGTGAGGTTTTATT TCTTCAGTTTGATGTTAATACTGATTGAATGCTTGCCTTAAAATGTTACAGGGAATACAG GTTAAGGATTGGCCTTACTTGGTTGATCCTCTTATAAGCAGTTTGTAATGAAACCTAGGA AAACAGCATCTATTGTCACGTTGAATTGATCACTAACTTTAACTTCATTTTTATCAGTTC CTAGGCAGATTAGGCATTACTTTGGAAACTGTAAAATGAGAAGTAGCAAACTCCTGGGTT TAGTGTTTGCTTTGGATTCAGCTCTAGCAAGATGTTCTCTAATACAGAGTCCTTAAAGGT CTCTATCCCCTTAGTATTGGTGCTTTGCCCAGTTCAAGCCTCTTAGCATGTAGAAACAGT TTATTCTGTTACAAAGTAACTAGAAACCATTTGCACCAACTTATGTTTAGTTTTCTTGTG ACAAAATAGGAGATAAAAGCAACTTAAGGGAAGAAGGGTTTATTCGACCCAGCCAGAAGG CAGCTGCTCACGTGGGGCCCAGTCAGGATGTGGAGAGAAGAGTGTCCTGGGGCTGGGCTT GGTGTCACTGAGGCCTTAGGCGGGTGGGGCCACCCACATTCAGGGCAGGTCTTCTTTCAT CAGTTTAATCTGTCCACAGATACTTGTGGACACTCACAGAGGTGTGTTCATAATGGTTCT AACTAAATCCATTGAGTTGATGGTCAAGATGAACTGTTAACTTGTGCTCCAGGGAGCGTA GACAAAGGCGCGCACATAGTAGAGGAGGGACTGGTTGGGAAGAGGCAGGCGATGGGCAGG AGTGGGAAATGGGGCATAGCAAGGGAGTGGAGGGTGAGATACATTATATACATGCAGGAA AATGTCAGGTGAAACTGTTGTACATGGTCATGTTAAAAAACTTTGAAAAAGATTAACACT ACACTACCTAAATTTATGTAGTTCTATGGGTTGATTTAGTTGAGGAAATGCTTTCTTGGG CCAGTAAGGTATGGTGCCTCAGCAGGTGAAGGCACTTGGTGCCAAGCCGTATGATCCAGG ACCCATGAGGTAAAGGAGAGAATGGATACTACCTATACTGTGGAAAACTCTGTGGCACAG GGGGGCCCATACATGTATGCATGTGTGCACCCATTCAGTGAATAAATGTGTATTCTTTTT TAATAAAAGGAAAAAAATGTGTTCTTCTAGTACTAGTCTGCCCACTGTTAAAGGTGACAC TTCTTTGATGCAGTTTTCAAGTGTGTCTTAGAAGCTTCCTTTTTTATCTTTACTGATTAT TTCTGTCTGAGATTTCATTCAGGATTTTCCACAGTGGCTAATCCTTGATTTCATTCTTGC ATATGTTTCCTAAGGAACTGACTTAGCCTCACAGGCTTCCTTCCTGCTGCTGCCTATTAC ATTCTCATGGTCCCTCAGCAGTTTTCTGAAAAATACATTGTTTGCGTGTATGGGATGTTG GATTGAGGTTTCATTGTACCTGATTTAAATATTATAACCACCCTTTGATGTGGAAGTCAT ATTTACTGATTAAGAAACTGAGTCTAGGAAAGGCAGCTAGGGATGGTGAAGCTGAGTGTC ACTCTTGATAGCACGATTCCAGAGTGCACCCATACCCATCTGAATTGTGCACTCTGCCAT GCCCCTTTTGAGTCACTCTAAGGAGTTTCCCAAAGTGAAATGGATGCTGATGGAAGAACT CAGCACAGAGCTAAACACATTGAAATTTGGTGGAAATATGGAACAAATGTTGGAAGAGAC AGGATATAAAACTGCCAATGTCTGGATATAAATTTGCCAATGCCAAATCTGGTTCTCTAT ATGTTTGTGACAATCTTCGGATTGTTACTGTACTTATTGGTCAAAATAGGCATTATGTAG GTGCACTGTTGGAAGTTAAACTGGATATAAAATTGAACCTATGACTAAAAAATTTAAGAT TTTAATATCAATATAGATCGCTCATAAAAACTTCAATATTCTGGTTGCCATTCAAAAGGC AGCTGGTGTAATAGAGCGTGTATGTGGCGTGCCTGAGATCTGGGTTTTGTTCTCAACACT AAAAATCCACATAAGTGAAATGACAGTTTTGATTCAAATATTTGTATATATCAAAATCCC CCAAAAGGCTTGATTTTCACCTTGTATTTCTTAAACCTTGTTTAGGTATTTCTTTAAACA TGGAACAATGGAGCCAGCTGAAGGAACAGATCTCTGATATAGATGACGCAGTAAGAAAGC TGTAAAATCTGAGCCATATCAAACCTGTACTGTTGTAGTTGTCTTTTTACATTGGCTTTT GTTTTCTAAATGTTGTTTTCCAAGCTGTTGTATATTTGGATTGCAGAACAATTTGTAAGA CAAATACTTTTTTTTAATGTGCATTATTAAAATGTTCTAAGTGAAGCTAATTGTCAAGTT TATTAAAGAGGATTGCTTTGTGCCCCCTACCTAGTGTGTAAAATAAAGTCAGATCATTAC AATCTTAACTGTGGTACCCTTTTTTGATCAAAAAAACCTAGTTACTGTTTAAGGCCAAAA GAACAACTAGGCACACTGTTGAGTCAGCTTACATTCAGAAGGATTTGTATTACATTGAGT TTCTTAGATTGCTTTGTGAAATGTATACTCAGCCTTTTTCTTTCCAACCAGATTTACTGC GTTTTCCTCTCCAGGACTTCTCCCTACCACAATAACTTATCTTTTCTTCAGTTCTCTTAG TGCTCAAGTTTAAATCACTCTTTACTCAGATAGATTACGCTTATTTAGAAAGTCAAACTG TCAGTTTTGTTGCCTCCTAAGTCTACTGTGCTAATTACTAGTATCTGTTTGGCAACATGA CTTATATGAGAACTCCAAGCAAGTGTATGTCATTATTCATAGTGCTCTGTGTAGATGTTG CTTAGTTTACAGAACATAGTGACTTTGATGTCTGATGAGCTGTCACTCAGTAAACATTTG TGCTAGGGTGATGGTTATAAAGTCAGATATTAAACTAGATTAGACTTGTAAAAAGTGTGA AACTTACTGGCCTACTGTTATATTCTAATAATGTGTGGATTCTATGTAGTCAGATGTGGC ACTGAGCTCAACTGTGGTAGGTTCTGTGGGCAGTTTTAGAGTTGACTGTTCTACAGTTAA TCTGGACAAGTGACTTCCAGACTTGATGTTAACTAGGTTTGATAGACATTTCCATTGGTT TTCATTTCAATTGTGATGATTAAGCAAGCAGACAGGCACATGTTTTAGGGACATTGCTCC AATGAAAAGGGCATAGTGTTCTGAGGGAAAATGTTTGCAAAGGAAAGTCACCACACTGAA GGGAGCTAGCCTGTGATGAGAAAGGAACTTTCTTGAAACTAAATGTTGTGCACATGATAT GTTGGTGATAACATTAAGATGGGTCTTCGTAGAATAATAGCTAACAAGGACAATTTATAG ATGTGAAAAAATGCTGCCACTAAGGGCTGCCATATCAGAATTGCACTGTCATACTGAGTC CCACCGTCTAAGCATTTTATAGAACTGTTAAGGATTAAATTTAAAAAACAGTCTGCCAGG CCTCATGTGGTTAACTGTCCTCCCCACAGATACTCTTTAGGTAACTTTTTAGTGTGTTAC TCCAAATTGATACATATATATCAAAGGGTTTAAGATATATACCATAGCTCATTCTTGAGG GATGATCCTCTTATAATGTGTTGCATTTCATTGATTTTATAAAGTATTCCTTATTTGTCA TGTAAAGAAAGGATAGTTAGAACATAAGACTGGTTTGGTGCAGATGAGGGGAGAATAACA GGTAAATTCCTGAGGCCATGTGTTATATGTACATTTCAGCTGTCCGATTGCAGAGATCTG CCGTCTGCTACCTAGGCATTGCTAGCTGCTTAGCATAAAATTCCATGTGGAAAGCTTTCT CGGGCATAATTTGTTAGGTTGATAGCTAAATACATTCACTAATGTTATACCAGAGTTGTT GTTATTTTTCTTTGTGTGTTGAAAAGGAAAATTGAGTTAAAAGAAGAGGAAGGACTTTTC AGATGGAAAAGAAAGGGTACAGTCCTTCTATTTTGCGTTCAGATGCCTTTCTCCTCAGTG TCTTAGTTTCTTTTCTGTTGCTGTGGTGAAGTGCCCTGACAGAAGCAGCCAAGGGAGAAA GGGTTTATCCTGACTCACAGTTCCATGTTCCAGTCCGTTGTCGCATTGTCACAGTGGCAG GAACTCCAGACATCTGGCCACATGGCTCCATAGCCAGGAAGCTGAGAGCTGTGATTGCAT GCTCAGTTCCTTTTTGTCTCATTAACCTGAGCCCAGGAGCTGGAGTTGGCCACAGCAGGC AAGATGATTCTCCAGACATCATGCCTAGAGGCCTATCTTTTGGGTAGTTCTAGATTCTGT TGAACTAATAACCATCATAGTAAGTTTTCTCCCAGGAAGAAGGCTTGACATTTTAAGGCA TAATATCTTATTTTGTAACACTAAAATAATTAGATCTGCTGCCAGGTTTTGCCCTTTAAT ATGCTCCATAGTAAGGCTTCCAAATGGGTTTTCCTCTTAGGGTAAAAAGCCTTTGGCCAA TTTCCACAATCACTGAAAAAGAAAAACTCAGATTTTCTTTTGTTTGCTTCACAAATGCCT AAAATCTTGAGAAATACTACCTCCTTACCTAGTCAAGACGCTGTGATAACCAGTCTGTGC TGCGTAGTGTTGGAGTCAGCAGCGTGGGGAAAACCGTGGGGAAAGAGCATCCTGGTCTGG CTGCAAAGGGAGGAAGGGATTGAACAGTTATGTAAGCGTTCCTGACAGGAACGCTAGCAC AGAGCTTGCCATAGAGCCTGTGAACGTCTTCAGAACCGTTGAGTTATATTTAGGTATCTT TTCTGAATTTCTTTGTGGTTCACTTTTTATAGAAATTAATGTAGTGAAACACTAAAGATT TTTTTCTTAAGAAAGGTATTTTTTTCCAGATAAACTATAATGTAAACATGCATCT wise-2.4.1/test_data/rpo_h_r.anchor0000644000175000001440000010510707571673470016671 0ustar philippusers>5.32372381-32389772 TTGAGGTGGGTGAAGTGGGGTAGGAAGACCATTTCTGGGAAAATGGGCCAGAGTATTGAT CTTTTTCATTATGACCCCTTCGCTTCATTAGAGTAAACATTTATTGAACAAACGCAAAGC TTGGCGCTTGTCACTCATGTTTTATTGGCGTTTTCCTTTTTTTTAATTTTTTTTTAAGCT ATCTCCTACAGGAAGGATATTAGCTCTTTCATTCTCTCAAGGGTCAGATGTAATCTTCCA ACATCTGACTTTCGCGTCACCCATTTAGGAAGAGACGCGGTCCCTTTAAGGCCCTGGAAA GGGTCTAAGTGTTGGTTTCTGTGGGGAGGCCACGCCCCATCACGTGACCGCAGCCCCAGC GCGGCGGGGCCGGCGTCTCCTGGCTGCCGTCACTTCCGGTTCTCTGTCAGTCGCGAGCGA ACGACCAAGAGGGTGTTCGACTGCTAGAGCCGAGCGAAGCGTGAGTGCGCGGGACCCCCT ACCCCTACTCCTCGGGGCCCCCACCCTCCCAGCCGGGCCGTGAGCTGCCTTCGGCCCTCC ACTCCTCTCGCCGGCAATGGCCGCGGGAAATGGCGGCTCTGCCTTACCTCCCCCTTCCCC TCGGCGTCCCCGGCCCCCTTCTCCGTTTCTGACTCCACGCCTGACGCGCTGTGGGCCCTT CCGCGGTAGACTCCTGTCCCCGGGGAGCCGAGTCGAGGCGGCGGGCGCTGCGGCCCGGGG CGGTAGATTGAGGGCGGCCGGGGAGTGAGGAGTCGCGGGGAGAGAGTCGCGGCGTCCCCG GGACAATGCGGCGGCGGCCTGCCTAGGTGGGGCGCGTGCGGTTACCTACTCTTCCCCCGC CCCTCGCCCTGAGCGGGGCGCTCTGGAGACTGGGAGAGCGGATGCGGGCGGGAGGGGGCC GGGGGAAGAACGGCTGATGTGCAGGGGGAGGGAACGCTTCGAGAGAAGAAAATGGCGCTT GGTGCAAATCCCGCCCCTTCCCACGCCGTCTTCTCCGCACTTCGCCGCCTCCCACGCCCC CTCCGACCAACCTGTCTCCCCTCGCCCGAGCGGCTGCTAGCCACGGGGTTCTAGCGGCTT GCTGGGGCCGCGCGACCCCTTCCCTGGTCTTGTGCTTGTCACCTTCCTGTTATACCGAAG TCGTGTGCCCTTCAGTCCTGGTTCATTTTCACCTCGTTTTTTTCTGATCTTTCCCTCAAT CAGCAAAGGCTGAAGATTTCGTTTCTCTTTTTAAAGTTGCGTTTTGTATAAATTCTACAA TAGTGGTTTCAGTATCAGTTACTTGAATTACAAGCTGCTTCTCCCCCCACCCCCACATTG GAACAGGCTCATTAAGGTAAATATATATTTGTTAAAAGTTTAGAGGCTGGTTTTAGTTAC CGTTACCTTTCTTCTCCAGTGGACTTCTTTGGGTTGAGTACCAGGTGGTTCTTTGAAAAA TTCTTAGGCCCCCAGGCAGTTTTTGATAACAGACGGTAGTTATGATCGACAGTTTCAAAG TGAAAAATTATGTTCAATTTAATTACCTTTTTAAAAAATATCTTTTTGTCGTATTAATTA GCATAAAAAACTTAACTAAATTGATTTTAGAGATGAGGTTGCAAAATGGAGCAGAAACAG GAAAAACGGATAAAACGTGGTCATGAACATTGCTTTTCCCTTCTGAATTTACCCTTGAAG ACATTACCAGTTAAAATCAGATTGAGCTTTTTGAATTTAATGGCTAGGATTGGGGTGGCC CACTTCTTTTTCCTTGACCTCCTATTTTGGAACATATGCAATGTCAGTGCTAATGCAAGT TTCATCTAGAGAGCTAGATTATTTATGATTTTTTTTTAAGGAGGAATTTTAAGTCTTTTT TTCTTGTATTAAACAAATACAGTGTGTGATGTGTTTATTAGGCCCTTTAACGCATACAGA AATTAGCTAATTTATGCCTAGTGTTCCATTATTGGAACGCTAAGCATGTGGGAGTTATTT ATGTGCTACTGCTCAAGATCATCGCCAAGGTCTGCTTGCATAAATTCAAAAAATTGCAAC CTCTGGCATAAATGGGTTAATAGGACCTAATCTCTTCTGAGATGGGGAGAGCAAAAGATA TTTTGATAATCAGCGTTTTATGACCTGGTGTTATAAGTGCCTTGAATAGAGGTATCCACG TATCTTGGAATTCCTTGAAATTTGGGGCTTAGGCTTACTGATAGTTTGCTTTCTGCAAAC TTGCACTCAGGCACTCAGTAAACACCCACTTGTAAGCAAGGCACTAAGTTATCTATGTCT CTGGGGGGACCTGGGAAGTTACCAGCATGGTAGGAATTTGCGGGAAGGTTTTGCACCTCC CATAAATAGGTTTTGCACCTCCCATAAATAGGTTCTTCAAATTTTAATTATGTTCCAGAG TAGAAAAATCTGTGTAAAATGTAATGAATTGCTGTGAATTGTGTAAGATTTTTTTTTTTT TTTGAGATGGAGTCTTGCTTTGTTGCCCAGGCCGGAGTGCAATGATGTGACCTTGTGTCA CTGCAACCTCTGCCTCCGGTGTTGAAGCGATTCTCCTGCCTCAGTCTCCCGAATTGCTGG GACTACAGGTGTGCCACCGTGCCCTGTTAATTTTTGTATTTTTAGTGGAGATAGGGTTTC ACCATGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATCCGCCTGCTTTGGCCT CCTAAAGTTTTGGGATTACAGGCGTGAACCATCGTTCCCGGCCTGAATTGCGTATAATTT TGTGTACTCTTGAATTAGTACCTGTCGTTATTTTGGTGATACGGCCAAAAAGTCAAAATA TGAATAAAATATTATGTAAAAATTAATTAGATGTCACATTTGCATAGTACAGCTAGTTCC CTGTTGTGTAAATGTTGGGGTCAGTTCCCCATAGTGAATAATTTTACGTTAGTTCCAATC TCGTTGATGAGAAGTCTAAAGCAGTAATAGTAGAATTACATTTCTTCTGGTTTTAATAGT AATTGTTGTCTGCTGCCTTCTTGCAGTTTACCCTACCCATAGTGTGTAATGCCATTAAAA CGAAGTATAGAAAGATCCATTGGCCTGGAGAAAGGTTAGAGGTGTAGGAGTGTATGACAT TTAGTTCATTGTTCTTACTGGGTTCAGCACATTGCACCCTGCGTGTTATTTGCAACTTAA AAGGGTATAGATTAAAACTTGTGCTCAGTGTAACAACTCAGTACCACAAAAATGGTAGAA TGAACCGTGGAACTTGTCCTTGATTTTTTTCTTTGATTGGGGGAGAGCTAAGTTGAAAGT AGTAGAGTACCTTATTAATTATTTTTGTAATGTATTTTTCTTTCAGGATGCCTAAATCAA AGGAACTTGTTTCTTCAAGCTCTTCTGGCAGTGATTCTGACAGTGAGGTTGACAAAAAGG TGACTACTGCTGCACCAAGTCATTTTGGTGATACTCAACAATATTGTCCATATCCCATTC TGAAGGATAGTAAAAGGTGTATTAACATCTTAAAATGAGGATCTAGCTGGGCGCGGTGGC TCATGCCTGTTATCCTACTTCTTTGGGAGGCCGAGGTGGCAGGATTGCTTGAGGCCAAGA GTTCAAGACCAACCAGGCTAACATAGCAAGAACCTGTCTCTTTAAAAAAATAAATAAATA AAAAATAAAAAATAAGAATGTGAATGGGTATTTCTGGAGGTACGGTTGGTCTCTGGACCA CTTGACTAGAAGTGCCTAGGATGCTTTTTGCACATTCATACTCATAGGCCCTAAATCAGA CTTAACAAGTCTTCTGTTGAGCATCATTAGGAACCCTAAAGTTGCAGAAACACTGCCTTG CATCCTAGGGTCATAGAATTCTAAGTAGGCCAAAGTCACTATTTGCCGTTATTTAGAAAT TTACCAGATTTTTTTTTGTAAAATGTTAATTTTTTTTTTTAAAGACAGGGTCTTACTCTC TTGCCGAGGCTGGAGTGTGGTGGCACCATCATGGCTCACTGCAGCCTCGACCTCCTGGTC TCAAGCAGTCCTCCCACCTCTGCCTCCAGAGTAGCTGGGACTACAGGCATCATGCCTGGT TAATTAAAAAAAAAATGTTTTTGTAGGGACCAGGTATTGCTGTGTTGCTAAGGCTGGTCT CAAACTCCTGGCCTCAGGCAATTCTTCTGCCTCAGACTCCCAAAGTGCTGGGATTACAGG TGTGAGCCATCATGAGTGGCCATAAAATGTTAATTTTGACAGTTCTCTTAGTTACTGGTG TTTATTCTGCACATAAGGTTTTCTGAATTTTAGACTTGGTACATTTTTAAGTTTGTACTA AGTTTGTGCTCTGGTCCCTTCCATTTAATTAAATCAGCACGCAGTAAAGCTAACTTGAAA CCCATTGACAAGATAGGCTTTTTCTGCATTAGATGACAGCTGCACCGTAATTGGTGAATT TCGCTAAATTGAGCATCTCAGTGGAGCATAACTGAGCGTCTCACTCTGCGGTCAAGTCTT CCGTGCAGAATTGTCTTTTATCGCATAGAACTTTACATATCTGAAGAGATATTTATATCC TAGAAATAGAATAAGTTGGTCGTGTTTTTCCTAATTAGTATATATCCTTTGTAAAATAGT AAGTAATGACTAGCACTGGTAGACCTGTGATTTCCGAAAGTTTATTCAAAAGAAGCAGGC TCCCTATCTTTTTTTTTTCCTCCTGAAGCTTAGCAATTTTAGCTAAAAGAAAAGGGGAGA GCGTATGGGAGATTGGAGAAGTTGCAACCTTAAAGTATAAATATAGAATATAACAACACA TGGAAGGGTAAAATAAGGCTTCAAAGACTATACTTGAGTAAATTTCTTAATTTTAAAATT TGCACCCTATATAGTATTTGAGTATGTTGATGTAACACATGTGTATTGAGCTTTTATTTG CCAGACATGCACTATTCCACAGGGAATACTTAGAGCCTGATTTATAGAATAATTGCTTTC TGCATATTGAGCTAACTTTTTGTTTGTCCCAAATAGTAATATTACTCTTGTAAACACTTA ACCTTGTATACCACATTTTTCATTTCATGTTTTACATGTATATAATATTTTTCCTAGCTT CATCTAATTTGGTAACATTCAATTAATTTAGTAACATTAAAATATTTATACTATTCCATC AAGAAGGAACATGACTGCCCTCTTCTGTTTGGGTTGGGTATTGTAGTGGTTTTTATGGGT TAGCTCTTTTTGAGAATGCGACTTTCTAATAAGCTTTTAAAATAATGCTGTTTTTAAAAC AACGTTGTGATTTTTGAAAGCTAGTCTAACACATAGCTGTCTACAATGATTTTTTTTTTT TTTGTAATGAGGAAGTTCTTGAGTTGCTGGCTGTCAGTGCCCAGTGCAAAATAGCTCTCT AAAGATTTGCCTAATTGTAAATTCCTTTTTTTTTAATTTTTTATTTTGAGATGAAGTTTT GCTTTTGTTGCCCAGGCTGGAGTGTAATGGCGCGATCTCGGCTCACTGCAACCTTCGCGT CCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTTCCGAGTAGCTGGGATTACAGGCGTGTG CCACCACGCCTGGCTAATTTTTTTTTTTTTTTTTTTTTTTGAGATGGAGTATCGCTCTGT TGCCCAGGCTGGAGTGCAATGGCACGATCTCGGCTCACTGCAACCTCAGCCTCCTGGATT CAAGCAGTTCTCTGCCTCAGCCTCCCTAGTAGCTGGGATTATAGGTGCCCACCACCACGC CTGGCTAACTTTTTTTGTATTTTTAGTGGAGATGGGGTTTCACCATGTGGCCAGGCTGGT CTCGAACTCCTGACCTCAAGTGATCCTCCCGCCTCGGACTCCCAAAGTGCTGGGATTACA GGTGTGAGCTACCGCGCCCGGCCCATAAATTCCTTAAGCCAGCATAAATTCCTTTTGGAA TAGGCAGGACATAAATAAACATATCCTGGAAATGGAATAAGTTGGTTATATTCTTTTTAA TTAGTATATCTGCTTCGTAAAATAAGTAACTGACTAGCCTTAGTAGACTGTGGTTTCCAG GTTTATTCAGAAGTAGCAAGATCCCTCCATTTTTTTTTCTACCAAAGAAATCGTATGTGG GATCCCAAACCACAAAATAACCGTTCCTGTGGTTAATACTACTATAATGCCTGAAGTGTC TTTTGGGATCCTGAGAACAGAGTTTGAAAACATTACTAGACAGAAGGATTGGTTAGATTC ATAGTTTTGTTGTTGAGTGAAACTTGCTTATGTATATATTTATGATATTTTGGATGTAGT CTTTTGATTGTTTAAATCTTAAAAAGTAATGGGATCTTTTGACACTGGGGTATGTTTTAT TTTTATGTGTGCAAATTTTAACCATATTCTTTTCTAGTTAAAGAGGAAAAAGCAAGTTGC TCCAGAAAAACCTGTAAAGAAACAAAAGACAGGTGAGACTTCGAGAGCCCTGTCATCTTC TAAACAGAGCAGCAGCAGCAGAGATGATAACATGTTTCAGGTAAAGTTGGCTATTTTTTT TTTTTTTTTTTTTGACATGGAGTCATGCTCTGTCACCCAGGCTGGAGTGCAGTGGCGCCA TCTCGGCTCACTGCAACCTCAGCCTCCTGAGTTCAAGCAGTTCTCTGCCTCAGCCTCCCG AGTAGCTAGGATTACAGGCATCCGCCACCAGACCTGGCTAATTTTTGTATTTTTAGTAGA GATGGGGTTTCACCATCTTGGCCAGGCTGGTCTTGAACTCCTGACCTTGTGATCCAACTG CCTCAGCCTCCAAAAGTGCTGGGTTTACAGGTGTGAGCCACCATGCCTTGCCAAAGTTGG CTGTTTCTTTAGATTCAGAGGAATTATTATCTGGCTTGATCTGAAGAATGTTAAAAGTAC TATGATCTGATAATTGCCTAATATGTATGTTACAATCTTCTTAACTAGGGACATTTATTA AAATAGAACAAACTAGTAAAAGTATTTTGTACGATGCTGGATTATTGTTAAAGTCTCTAA AGTCTAGTTTTGCTGTATTTAAACCAATGCAAATTTAATTGAGAACTGCACATTTTGAAA GCAACTTGGAGGAGGCAGGTCAAGTGTTGGGACAGTAAAGTATGAATAGATTATTATGGG ACAGGAAGCAGCAATGTGACATGCCTAATTTTGGCCTGATGAGCAACAGAAAAGGGGAAT GGGTTGAATAGATAAAGTGAAGGAAGTTCATTAGAGGGACTTGATGAAATCACCTAGAGA GGACTCGTATAGCTTTTTCTCTTGGGTTTCCTGTCTTGTTTTAGGGAGACTTGACACTGG CATCTTTGTACAAGAAGGATTTGTGAGGAAGGGATGTTGGGGAATAAATGAATGCAGGTG AGATTGCTTAGGTAATTGTAGGCTTTAATCTGTATGTGAGGTGATAAGGGCTTAGATGGT TTTTCCTAAAGAAGAAATTATGCCAATTACAAGATACAGGTTAGGAAGAATGGACCAGAG GAATTAGGCAGTCAGTGAAGATGTGGACTTGATTGTGGATGTGATTGAAAAAAAAAATGG TGTTGCTTCTGTAGCACCTGAAGGGCTTAGTTGGGAAATGTTCATGTGGGATTATCAGCA TGGTTGACTAAAGCTGCCTACTGAAGTATTAAACAGAGGAAGAACAGGAAGCAGATGAGG GGATGTCTTGGGTTATATTCAGATAGAGAATGGAAGGAAAAAGAGGATGTAGGTTAAGAG AGAGGGTGAAGGAAAATTAGAAGAGTGCAGTAATGGGAGCAAGAAAAGGATGAGTGTTTC CAGGAGCTATAAGTATTAGTTGAAACCAAAAAGTTGGGTGGAACGAGACTACAATTTTTT TTTTGAGACAGGGTCTCTGCTCTGTCACCCAGGCTGGAGTGCAGTGGTGTGATCTCTGCT CACTGCAACTTCCGCTTCCTGGGCTCAAATGATCCTCCTGCCTCAGCCTCCTGAGTAACT GGGACTACAGGCAATGCTCCATGACGCCTGGCAAATTTTCTTTGTTGTTGGTAGAAACAG TATTGCCCAGGCTGGTCTTGAACTCCTGAGCTCAAGTGATGCGCCCACCTTGGCTTCTGA AAGTGCTGGGATTACAGGCGTGAGCCACCGTGACTGGCCAAGACTGTAGACATTTATATG ACTAGAAAGTAAGGCTAACACATGTATATTTTGACCTGTTGATAACTTTGAAAGGTGGAG TGCCAAGATTAAGGTGAGAATGGGAAAATTTAAGTTTTTTTTTTCCTATTGCTTATTTTT GCCTTGTTATACTTCTAGGTAAAAAAGATAGACAAAGTGCAGATGAACTATTTAGTTCAG AACACACATTTTAGAGATTCTGTTCTGTTAAGAGGAGTTTTGTGAAAACTAGATCTAATT TTAGGAATTTTCTCACCAGAAAAACGGAGCTTCATTTCTTAAACCCTCATCTGGAAAGAT TCCTAAGCCTCCTAAGGCTGACATTGCACCTTTTGAAAGCCTGCCTCTAGGAGGAACATA GGTCATCTTTTCTTTTTTTTTTTTTTGAGACGGAGTCTCGCTCTGTCACCAGGCTGGAGT GCAGTAGCACGAATCTCGGCTCACTGCAACCTCCGCCTCCTGGGTTCAAGAGATTCTCCT GCCTCAGTCTCCTGAGTAGCTGGGACTACAGGCATGCGCCACCACCCCCAGCCAATTTTT GTATTTTTAGTAGAGACGGGATTTCACCTGGTTGGCCAGGATGGTCTCGATCTCTTGACC TCGCCATCTGCCTGCCTTGGCCTCCCAAAGTGCTGGGATTACAGGTGTGAGCCACGGCGC CCAGCCTAGGCCTTATTTTCAGAGTGGCTTTCATGGATCTAGTAGTGTAGGCATTATGAA ATAATATGATACTTAATTTCATTGCCATTACAGCTTGATGTACATCAAACATCAATACAT AAGCAGTTCTCTAAATGTATTAAAGAGTTGTACCAAAGAAAAATCAATAGACTTATCTTT TAAAGTCTGAAGTGATTGGGGCAGAATCGTGACTAGAGAGAAGATACTAGAGATGCTTAC TTCCTGGTTCCTTCAGCTCTGATTTTGAAGAACTTTCTTCCATAGGGATGTAGTCTACCT GAGGTGACATCTGTGATAGTAAAGAGACTGGAGAATTATCTCATAATTATTTAGTACCTG TGTCTTGAAAGGTCAGAATAGTTGAGGCAGGAAACTTTAATCCATATTTTTCTTCAGAGT TAGGCACAAAGGGTCAGTAATACTGCTTTAGTTTATTTGATGATTTAAGGATACTTGATA CTTTTAAATTATTTAATTTAAAATGATTATAACTGGTCATTTTAATCTGGGGCAGGAGTC CATAGAATTGTTTTTTAATTTGAGTTTTCTTTTTTGTGTTTGAAGGAATTATTCATAACC TTTATCACAGGGGTCCCTCCTGCACAGGAGGTGAGCGGTGTGTGAGTGAACATTGCAGCC CGAGCTCTGCCTCCTGTCAGATCAGCAGCGGCATTAGATTCTCATAGGAGCGCGAACCCT ATTGTGAACTGCGCATGCAAGGGATCTAGGTTGTGCGTTCCTTATTCCTTATGAGAATCT AATGCCTGATGGTGGGATAATTTTTATCCTGAAACGATCACCTTTCCCCTTCCCTACCTG CTGTGGAAAAATTGTCTTCCGTGAGACTGGTCCCTGGTGCCAAAAAGGTTAGGAACCACT GCTTTATCAGATCTTCAGAGGGGACAGGGAATCAAATTCGTATAAGAATCACAGTTCTTT ATGATGTATATGCTATTTTTTGCTGCTAATCTCCAGATTTTGTGGATATAAAATATATTG TCATCTGATTTTATTTTTTTCCAATAAAATGTGATTTCAGTGATCTTTATTTTTTCTATC TTTAAGTAATATATCCCTATACTACTATCTCATCACTTGTTTAATTTTTGCTAATAAGAA TTTGTCAGTTTTACTCTTTTTTTCCCCCCAAGGGAGAGGCAGCTGTTGGGCAGATTCCTT TTTTTTTTAAAAAAAAAAATGTTTTTGAGGTATAGTTTATGTCCAATAAAACGCACACAT TTAAAAGCATACCTTGATAGGCTGTGGTAAATGTACACGCCTTTGTGGCCAGACCATTTT CATCACCCCAGGAAGTTCCTCTTGGCTTTACAGTCATTGCTCATGTCCTAGGTAATCACT GATCTTATTTCTACCACTATAGATTTATGTTGTCTCTTCTAGAACTTTGTATAAATGGAT ACATGCAGTCTATTTTTTGTGTCTGGCTTTTGCTCAGTATAATGTGTTGAGATTAGTTCT TGTTGCATATATCAGTAATTTTATTGCTGAGTAGTATTTTGTATGATAATACTACAACTT GTAAATCCATTCACCTTGGGTGGACATTGGGATTGTATCAAGTCTTGGGCTATTAGGAAT ACAACTGCTGTGAATATTCTTGTACAAGTCATTTTGTGGACATTTTTTCCCTTTTGGGTA AATACCAGATACATTTGCTGAGTCGTAGGGTAAATGTGTAACTGTATAAGACACTGTCAA ACCATTTTCCATAGTAGCTGTAGCATTTTACACAGCCATCGGTACTACTTAGGAGATTCC AGTTGCTCCACATCCTCGCTAGATATTGTCAGTCTTTTAAGTTTTTTTCTTTTTAGTTAC ATTGAATGTATAATGGTAGCTCATGGTGGTTTTACTTTCCATTTCCCTCATGTACATGTC TTAATTCATTGTACATCTTTAGTGTGTTTATTGGTTATTTTTATATCTTTTGTGAAGAGT ATCTTTTGGCCACTTAAAATGCCAGGTCATTTGAGTTGTAACACTTTATATATTTTGTCA GATGTAAGTATAATTAATATTTTTTTTAGACTTCAGGGAAACTTTAGTTTTCAAAGCAAT CTAGTTCAAAAATGAGTGGAGGTTAACAGAGAGGAAAATATGAAACCAGAGAGAATCAAA CAGACAGAATAAGGGGGGACTGGCAGTTGGTCAGGGGCGTCTGTGACAGATCTTCTCTCT CTTGGAAATGAGGTCCTCACGGATTCTGGTCAGTTCATCATTTTCTTCACGTCCACGGTT CTGCTTCTTCCTCAGGCTCTCCTCGAAGGCCAAGACCCCTGTGGCTCCAACTTGAGTGAA TATTTTCTTTAGGTTTCTGGTTTACCTTTTTATTTTCTGAAGCATCTTTTTAAAAAAGGC TTTAGTGTGATTGTCTATTCTATCGATTTTTCTCCTTTTTTGCTTAATGCTTATTTTCTG TCCAAGACGTATTTTGCCTACCATGGCCACAAAAATTTTTGCCAGTGTTTTTTCCTAGAA GTTTTATAGTTTTAGTTTTCACATTTAGGTCTATAATTCATGTAGAATTAATTTCTCTGT GTATGATGTAAGATAGAGATTTAGAGTCTTCCCCACCCCAAATGCAGATAGCCTGTTGTT TCAACACCATTTGTTGAAAAGAGTATTCTTATTCCTTTGAATTACCTTGGATTTTACCCC CTCCCCCCAAAAAAATCAGTGAATATATCCAATGCGTGTGTATTTTTTGACTCCGTTGTG TTCCACTGACCTCTTATGTCTGTCTTTACTCCAGTACTGCATTGTCTTCCCTTACTATAT TATAGTGAGTCTTGGAAAGTGCTAAGAGACACTTTGTTGAGGAAAGCCTGTTCTTTTCTC TGGAATTTGTAATTTGTGGTAAGCAGATATATAAGATTTTTGAAAAATAATTTTCTGTGA ATATTTTTAAGTTCTCAATCTGACTGTGAGTGAGGTGCATTAAAGATGTTATTTGAAGTG AACATGAAAAGGAAAAACTTGGTTGTTATTGACTGGAACTCTGGATTCGTATATTCAGAA TGGTTGGTGAAGCAGTGTAGCTAGTTGCATCTGTGGATTCCTCTTGGTTGTAGTTTGTAC TGCAAAATATTGCTTCCTAATGATTTTTTTTTTTGCTGGTAAAAACCATAAAAGTATATT CACATTGTTGTGAAACAGATTGCCGAAACTGTTTCATCTTGCAAAACTGAACCTCTGTGG CCATTAAACAACAGTTCCCCTTCTCCCAGCCCTGGTAACCACCATTCTACTTTTTGTTCC TGTGAACTTGACATCATGTAAGTGGAATCATAAAGTATTACCTTTTTCCTTTTTATGACT GGCTTATTTCATTGACGTAGTATGTAACAGGATTTCCTTTTTTAAAAGCTAATTGATATT CCATTGTGTGTCTATTCCACCCCCCCTCTCCCATTTTGTTTATCAGTTCATCTCTGGGTG GATATTTGTGTTGTTTCCACTTCTTGGCTCTTGTGAATAATGCTGCTATGAACATGGGTG TGCAGATGTCTCTTGGAGTCTGTGCTTTCAATTTTTTGGGATATATATTCAGAAGTAGGA TTGCTGGATCATATGATAGTTTAAACAGCAATTTCCTTTGGTTGCAGTTTTGATACTGAG AGTAGTACAGTTGACCCTTGAACAATGCAGGGTCAAAATGCAAGGCACCAACCCCTGTGC AGTTGAAAATCTGGTTATAACTTTTGACTTTGTCAAAACTGCTAAGTATAGCCTACTGTT GACTGGTAGCCTTAACAGTAACATAAACAGTTAACATATATTTGTATGTTATATGTATTA TATACTGTATTCTTACAATAAAGTAAGCTAGAGAAAAGAAAATATTACTAAGAAAATCAT AAGGGAGAAAAATTACATTTTACTGTACTGTATGGTGTTTATCAATAACATTAGTTTACG TTGTCTGTTTATAAGATATGTCATCTGTTAATAAAATATGTCATCTGTTAGAAATTGTAG GCAACCACAGCTGCAGATTTCAGTCCGTGGTACATATCAAGCAATTCAACTTTTTTATTT TTATTTTTATTTTTATTTTTTTGCATTTTAAAATTAAAGACAGGATCTTGCTGTGTTGCC CAGATTGGATTCAAGCTCCTGGGCTCAAGTGATCCTCCGGCCTCAGCCTCCTGAGTAGCT GGGATCATAGGCATGCACCACTGCTTCTGGCAGTTTTTTTCTTGTGATGTCATGCCTTCT CTCTGCTTCTTGGGAGCACTTTCAGCATCACTAGGGGCACTTTGTATAGGACTCATGGTG TTATTTAAAGTTTATGGTATTGCAGTAATCATGATGAAAAATAATGTGAAAACCGTGAGA GATCACTTTTTACTGCAATACGCAATTTGTTGGAGACATGAACTGCTCAGCAGAGATGAT TAGCATCACATGGTGTTTTACACAAGGTGTTTTAAGCAGATACTTGTAACATTTGAGTAC ACTGAGATAACAGGAAGTGGCTATGAAGTTAACACTAGTACACTACTGTAGTTAATTTTA TGCAGTTATGAATTAATACTCCATCTTTGTTTACATTTCTCTCTAACTTCATATAATAGA TTTGTATGTTTTATGATAGTAAGTGATAAAATAACCTCATATCTAGGTATGTTTTATGCA TTCATGACATACCTAACTTTTTCTTAATGTTTTCGTTATTTCTAGGCTATGCAGTTGTTC TGTGAGTTTTTTCAAATTGTCAAGTCTGCAAAAATTTTTCCAGTATATTTATTGAAAAAA ATATGCATATAAGTGGGACCTGCACAGTTCAGAGCCATGTTGTTCAAGGGTCAGCAGTAG TCATTTTCATGATTAGATGTAGAGTGAGCATGCAGCAAGTTGTGAATATGAATACAATTG AAACAGATACCACTCTTGAAAGGAGCACCTCTTTTTATGTTTGTTTCTTTTGCAGATTGG GAAAATGAGGTACGTTAGTGTTCGCGATTTTAAAGGCAAAGTGCTAATTGATATTAGAGA ATATTGGATGGATCCTGAAGGTGAAATGAAACCAGGAAGAAAAGGTGAGGTCTAATTACT TGAATTTTATTACAGTGTTAGGACTAAACGACAACTTTTCTGAGTAGCTTACTTGAAATG TTGGCAGGACACACGGGGCAAGGAAGAGTCTTACTCAATTGATTCTCTATCTTCTGTAGT TATTTTGGACATGATACTTAACATTTTTTTAATGAGATGTCTTAATACAGCTTTTGGGAA TAAAACCCAGAAAAGTAACACCCCTAATATCACTTCAGTTGGCTGCTAATTTACTTGAAC AATTTTTAAAAAGGTTTATGCAATTCTGAAGCAGATTAGGCACTATCTGGGAACTTGTAA AATCAGGAATGGAAAATCTTGGTTTACAATGCTTCCTTTTGATTCAGCTCCTAAAAGCTA TTCTTTAGGGCATTACTCTTCAAGCGGATCTCTGCTTTCCTTCCATTTGTGCTTCATCCA GTCCCAAGCCTCTTAGCATTGTAGAAACATATTTTGTATAATTCACCAAACAGCTAGAGA AGGTGAGCCAACCTAAATTTGTATATTTGGATTGCTGCTCTAGGTTGACCCTCAGCTAAA GAAAAATGCTTCCTTATTTAGTTTTATTCTGCCTGCCTGTTAGTTTGAAAGGTACCACTT GTTTGCTTCATGCAGTTTTTTTTTTTTTGGTTAAACTCAGCCTCTATATGTGTTTATATG CTTTCATATTTTCTTCAAGTCACTTCTGGATTGGTAATTCACGTACCAGAGTGGCCGATG CCATATTTCTTGTTTATTCTTTTTTTTCAATTTCATGGCCTTCCAGCAGTTTTCTGGGAA TACTTTCTGCCAGTTCTTGTTTACTTCTCTGTTTATATGCGTCGGTATTGGAATGCTAGA ACGTTAAAGTACAAAATATAGAAAATATAAAATTTCTGTTCATACTTTTACATCTTAAAC TGGAAAGACATATCTCACATTTTTTAACCATTTATGTGTTAGGTGATATGCTAAGTTCAT TATTCATGTTACTTAATCATTTACAACAACTCTTTGGCGTATAGATGCCATTTTACTGGT GAGGAAACTAAGGCTTACAAGGTGATGTAGTTCTTTTTTAAGGGTCATACACTTAGTGAA AGTGAGGCTGGAATTTTAACCCTGATAGGGTGACCCTAGAGTGCAGTTACCCGGGTATAC TCTCTGAGGAGTCCTGTATGAATCACGTCCTGGGAATTTTTCCAAAGTGAAATGAATGCT TCTGGAAGAACTCAGCACAATTGGCTTGAATTCCTGTGGAAATTTTGGGCAAATATTGGA ACCAGCTGGAAATATAGTAATGGGGTATCACATGCCAAATCTGGACCTGACCATTTTAGC CTGATAGTTGACGGGTATTAGTAAGATGTGTCTTCAAACCCTTATTTATTCTCATTGGTT ACAATAGGTACTATGCAGGATGCACTGTGGAAAGTAAGACTGGATATGAGATTGATAATG CTCAGTAAATTGTGATGATATGTAATTAACAAATGTAAGAGATATGATTTTCAGTATTGT AGCATTGTGTCCAAGTGGCAATTTTTTTTTTTTTTTTAGATGGAGTCTTGCTCTCTTGCC CAGGCTGGAGTGCAGTGGCATGATCTTGGCTCACTGTAACTTCCACCTCCCAGGTTCGAG CAATTCTCCTGTCTCAGCCTCTTGAGTAGCTGGGATTACAGGTGCCCACCACCATGCCCG GCTAATTTTTGTATTTTTAGTAGAGATGGGGTTTCACCATGTTGGGCCAGGCTGGTCTTG AACTCCTGACCTCAAGTGATCCACCCGCCTTGGCCTCCCAAAGTGCTGGGATTACAGGTG TGAGCCACCGCGCCCAGCCTAAAGTGGCAATTTTGATAAAACAGTATTCTAGTTGGAAGT ATGAAAATCCTCAACGCTTAAATAGATTTTCACCTTTGAATTTTTAAACTTTGTTTTAGG TATTTCTTTAAATCCAGAACAATGGAGCCAGCTGAAGGAACAGATTTCTGACATTGATGA TGCAGTAAGAAAACTGTAAAATTCGAGCCATATAAATAAAACCTGTACTGTTCTAGTTGT TTTAATCTGTCTTTTTACATTGGCTTTTGTTTTCTAAATGTTCTCCAAGCTATTGTATGT TTGGATTGCAGAAGAATTTGTAAGATGAATACTTTTTTTTAATGTGCATTATTAAAAATA TTGAGTGAAGCTAATTGTCAACTTTATTAAGGATTACTTTGTCTGCCCACCACCTAGTGT AAAATAAAATCAAGTAATACAATCTTAACTGTTGTGGCCTTTTTTGATCATAAGAGTTGG TACTGTTTAAGGCCAAAAGTAACAGTTTTTATAGATCTTTTAGTTTCAACTCAGCTTTTA CAATAAAAAGGATTTGTATTGCATTGAGTTTATAAACTTTTGGTTTGTGAACTTCATATT TGATCTTTTCTCTTCCAATCAAATGTCTAGGCTTGTTTGACTTCCACCCCCAATGGTTTT TCACTCTTTTTATTTACTTCATTTTCCTTTAATAACTTAATCTCTTCATGTTCAGTTTTT ACTTCACTCTTTATTCTTTTCTTTGATTATGGTATGCTTATTTGGAAAGTCAGTGAAACT GTCAAAATGTTATCTCAATAAGATACTTATATGAGAACTACAATCACCGAATCTACTGTA TTCAATATTAGCAGATCTAATTTGATAAACAACATGGCTTGTGTGAAAACTGAGCAGGTG TTTGTTTACCCATAGTGTTCTGTGTAGTTATTGCTTAGTCTGCAGAAAATAATGACTTAG ATGAGATGTCTGACTTGCTTTCACTTATTAAACATGTTCACCATGGGATGATGTCTGTAA CATCAGATATTGTTCAACTAGACTAGGATTTAATAAAAATTGTGAAAGCTTACTGGCCTA ACATTTTATTTTATAATATTGGGTATGAATTATATGTAGCCAGAGATGTCATTAAGCTTT ACTGTTATAGTAGGTAATATGGTTAGTTTGTAGGGAAAAGAGCATATGAGCACATGCTTG TGTATTTTGGCCTTTGCCCCAGTAGAACAGACCAATGGCATTCTAGACTTGATGATACTA AGTTTTAGCAGACACTAGTAAGTGGTTTGTATTTAACCATACTGATGAAGCAGACAGATT GAGGCACAGATTTTAGTGGCTTTGTGGCAATAAATAGGGCATGGTGTGCCTTAGGAAAAG AATGTTTATAAAGGGAATTATAACTGAAATTAAAGGAGGCGGCAGTGAAGAGGAAATAAT TCTCTTCTATCTAAATGATATACATATGATATTTTGAGATTTTTATAACAGCAGTGGAAC ACAATTCTAGGTAGAGTAGAAAAAGGAAAGTTTTAAAGACATATAAAAGATTCTTGTTGA CAAATTATTTTTGGTAGCAAATCTCAAATGGTTACCTGCTATTAAGGTCTGCCATATTAG AGTTTTGCACTATTTTGCTACCAAGTTTGATTCATACATCTAAAACATTTTG >RNOR01068417 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AGTACATTTCTTTTGGTTTTAA-AGT AATTTTTCTCAGCTGCTTTCTTGTAGTCTACCC-ACAAATT-T-TATAGCCCCTCTACAA TCAGTTGTTAAAAGACCCATTGACTTTGAGAAGGGTAA-AGGAAT-GT-GCACATGGCTT TTATTTCTTTGTCTTGACTGGGCTTAGAGTATTTGGCTGTGCTTGTTATTTGCAATTTA~ ~~~~~~~~~~~~~~~~~CATGTGTTCAATGTAATGACTCCGTACTACAGAAA-GGCAGAA TGAGCCTTGGAAGTTATT-TTGTTTTTTCTGTTTGTTTG~~GGAGAGCTAAGATGAAGGT ACTAAAACAC-TTGTAAATTATTCATGTGATGTCTTTTTCTTTCAGAATGCCTAAATCAA AGGAACTTGTTTCTTCGAGCTCTTCAGGCAGTGATTCTGACAGCGAAGTTGAAAAAAAGG TGACTT-TCCTGTACCAAGTTCTTTT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~ACCTTTAGTAACCAGAAGTCAACAGAAATGCTTTCTTA GACTCTAAAGGACCAGAATTCTAATTAAGCCAAGGGCAC~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~AAACATTAACGTTGACAGGTTTCTCAGTCACTG~~~ ~~~~~~~~~~~~~~~~~~~~TACTGAATTTTAGTTTTGGTACATTTT~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~GATAAGCTTTTTCTGTGTTAGGTGATCGCTGTTTTGTCAACC-TCA-TT CCACTCAGCTGATCACTGCAGTGAAGTGTGACGGAGCAGTTCATCTTGTGGTCAAGACTT CCTTCCACACGCGTCTCTTA----ATAGAAATTTA--TATCTGAATAAACATTCATATCC TAGAAATGGAACAAATTG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~AATAAGGCTTCAAA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~GAGCTGATTTTGTACTTGTCTCCCATAGTACTATTAATCCTATAAACATTTA -CATTAAATAC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~TTAGTAATATTAAACTAGTTTTACTTGTCCACT AAGGAGGAGCATGCCTGCCCTCTACTGTTGGGGTTGGG~~~~~~~~~~~~TTTTATTTTT TAGCTCAGTTTGAGAATAAGGCTATATAAAATTCTTTTATACTAGTGCTGCTTCTAAAAT A---TTATGAAGTT-GAGTGCTAGTCTTATAC-TGTCTATCTTCAAT~~~~~~~~~~~TC TTAGTGCTGCTGAGGTTTTTGAGTTGTTGATTTTCAGTGCC~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ATACATTCTTGGAAACAGTCCAGATTCCTTTTAGAA TAGACAAGAATTATAGAAGTAT-TCGTGTTTTGCTAATACATTGGTTATGTTTGTTTT~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AATATCTGAGATATC TTTGAGGATATTGAGAATAGAGTGTAAAAACACATCATTAGTTATGTGAAGACTAGATTC ATAGTT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~TTTTTTTAAGTTAAAGAGGAAAAAGCAAGTTGT TCCAGAGAAACCTGTGAAGAAGCAAAAGCCTGGTGAGAGTTCTAGAGCACTGGCATCCTC CAAGCAGAGTAGCAGCAGCAGAGATGATAACATGTTCCAGGTAAAGT~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~GATCTGATAGCACACCACAGTCTGTGTTGTAATCTTCTTGACCTGTG---TTTATTA ACATTGAGTAGGA-AGTGAAGGTAATTTGTTCATTTCTGGGCTATTGGTAAAATCTAGAA -GTCTAGTTTTACTATATTTAAATGA-TACAAATCTAA~~~~GAACTGTATATTTGGGAA GCATATTTGAGTAGTAAGGTTGAGTATTTG-ACTGGAAAGTGTAAAT~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GAGCTTAAGGAAAGGGGAGC AGGTAGGATAGATAGAGTGA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~GTGAGGTGATCATTGTGAGTAAAAAATGA-TGCTG-TG AGATTGTGGAGGCAATTATAGACTTTA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~TCCTGTAGCACCTGGGGGTCTTGGCTGGGAATTGCTTTTGTTGGCTTTTACATA TGCTTGACTAAATA-GCCAACCACTGAAGAACACAGAA-AACAA-AGAGAGGAGGTGATA GCAGGTTATGAGAGATTTGCAAATGGATGATGAAAG-AAGAA-AGGAT-TAAATTGATAA A-ATGGAGAAAGAAAACTCAAATAGTGGAGGAAAGAAAGAGACAAAA~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~TTTAAAGGTTCTGTTTTGCTA-GAG-ACTTTTGAGAAA-CGGGGTTTATTT TTAGGGTTTTTCTCACTTAAAAAA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~TCTTTTTTTTTTTTTTG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~TTTTTTAAAAAATAACAT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ATGAGT GGCTTATTTC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GATA GATTTGTGGGTTGCTTCTACTTCTTAGCTATTATGAATAGTGCAATTAGGA-CATG~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ACTGT-GTTAATTTTA T~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTGCTGATTGG AAAGATGAGATATGTCAGTGTTCGGGACTTTAAAGGAAAAATTCTAATTGATATTAGAGA ATATTGGATGGACTCAGAAGGTGAAATGAAACCAGGGAGAAAAGGTGAGGTTTTATTTCT TCAGTTTGAT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~TCTGAGGCAGGTTGGGCACTACTTGGGAAACTGTAA AATGAGAAACAGAAAACCCTGGTTTAG--TGTTTGCTTTGGACTCAGATCCAGCAGGATG TTCTTTA~~~~~~~~~~~~~~~~~~~~~~CTCTGTCCTCTTAGTATTGGTGCTTTGCCCA GTTCCAGGCCTCTTAGCA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~AAAATGCTTCCTT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~TTGCAGTTTCATGGCCTCTGAGCAGTTTTCT~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GTGTTGGATGTTAGGCTAAGGTTCA TATT-ACCTGATTTAATG-TAT-CAACCATTCTTTGATGTGTAAATCTCATTT-ACTAAT TAAGAAACT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AATGGACGCT TACAGAAGAACTTAGCATAGA-G-CT-GAACACCT-TG-AAATTTGGTGGAAATAT-GGA AC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CTTCAGATTATTATCAGTTCTTATTGGTC AAAATAGGCATTGTGTTGGA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~AACAAATGTAAGA~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~ATTTTCACCTT-GTATTTCTAAACCTTGTTT-AGG TATTTCTTTAAACATGGAACAATGGAGCCAGCTGAAGGAACAGATCTCTGACATAGATGA CGCAGTAAGAAAGCTGTAAAGTCTGAGCCATATCAAG----CCTGTACTGTCGTAGCTGT TTTACTCTGTCTTTTCACATTGGCTTTTGTTTTCTAAATGTTGTTCACGCTGTTGTATAT TTGGATTGCAGAACAATTTGTAAGACAAATACTTTTTTTTAATGTGCATTATTAAAATGT TCAAGTGAAGCTAATTGTCAACTTTATTAAAAGTTGCTTTGT--GCCCCTTACCTAGTGT AAAATAAAGTCAGATCATTCAATCTTAACTGTGGTAGCCTTTTTTGAT~~TAA-ACTAGT TACTGTTTAAGGCCCAAAA-AACAACCTTTGTAGGCACGTT-GTTG-AG-TCAGCTT--A CATTCAGAAGGAT--GTATTACATTGAG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ wise-2.4.1/test_data/vav.dna0000644000175000001440000000324107313404504015301 0ustar philippusers>EM:HSVAVONCO X83931 H.sapiens mRNA for VAV oncogene gcagcccgggaggacgtgcagatgaagctggaggaatgttctcagagagccaacaacggg aggttcaccctgcgcgacctgctgatggtgcctatgcagcgagttctcaaatatcacctc cttctccaggagctggtgaaacacacgcaggaggcgatggagaaggagaacctgcggctg gccctggatgccatgagggacctggctcagtgcgtgaacgaggtcaagcgagacaacgag acactgcgacagatcaccaatttccagctgtccattgagaacctggaccagtctctggct cactatggccggcccaagatcgacggggaactcaagatcacctcggtggaacggcgctcc aagatggacaggtatgccttcctgctcgacaaagctctactcatctgtaagcgcagggga gactcctatgacctcaaggactttgtaaacctgcacagcttccaggttcgggatgactct tcaggagaccgagacaacaagaagtggagccacatgttcctcctgatcgaggaccaaggt gcccagggctatgagctgttcttcaagacaagagaattgaagaagaagtggatggagcag tttgagatggccatctccaacatctatccggagaatgccaccgccaacgggcatgacttc cagatgttctcctttgaggagaccacatcctgcaaggcctgtcagatgctgcttagaggt accttctatcagggctaccgctgccatcggtgccgggcatctgcacacaaggagtgtctg gggagggtccctccatgtggccgacatgggcaagatttcccaggaactatgaagaaggac aaactacatcgcagggctcaggacaaaaagaggaatgagctgggtctgcccaagatggag gtgtttcaggaatactacgggcttcctccaccccctggagccattggaccctttctacgg ctcaaccctggagacattgtggagctcacgaaggctgaggctgaacagaactggtgggag ggcagaaatacatctactaatgaaattggctggtttccttgtaacagggtgaagccctat gtccatggccctcctcaggacctgtctgttcatctctggtacgcaggccccatggagcgg gcaggggcagagagcatcctggccaaccgctcggacgggactttcttggtgcggcagagg gtgaaggatgcagcagaatttgccatcagcattaaatataacgtcgaggtcaagcacatt aaaatcatgacagcagaaggactgtaccggatcacagagaaaaaggctttccgggggctt acggagctggtggagttttaccagcagaactctctaaaggattgcttcaagtctctggac accaccttgcagttccccttcaaggagcctgaaaagagaaccatcagcaggccagcagtg ggaagcacaaagtattttggcacagccaaagcccgctatgacttctgcgcccgtgaccgt tcagagctgtcgctcaaggagggtgacatcatcaagatccttaacaagaagggacagcaa ggctggtggcgaggggagatctatggccgggttggctggttccctgccaactacgtg wise-2.4.1/test_data/HOX.HMM0000644000175000001440000005637510011413266015034 0ustar philippusersHMMER2.0 NAME HOX_1 DESC LENG 63 ALPH Amino RF no CS no COM hmmbuild HOX_1.hmm2 HOX_1.msf COM hmmcalibrate HOX_1.hmm2 NSEQ 263 DATE Fri Mar 10 10:23:02 2000 XT -8455 -4 -1000 -1000 -8455 -4 -8455 -4 NULT -4 -8455 NULE 595 -1558 85 338 -294 453 -1158 197 249 902 -1085 -142 -21 -313 45 531 201 384 -1998 -644 EVD -48.005875 0.270973 HMM A C D E F G H I K L M N P Q R S T V W Y m->m m->i m->d i->m i->i d->m d->d b->m m->e -7 * -7632 1 -165 -2374 -584 -1040 -3398 336 -527 -1356 1379 -2122 314 191 917 1009 966 667 242 -2366 -787 -5744 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -12804 -13846 -894 -1115 -701 -1378 -7 * 2 -1499 -709 -1970 -16 -571 -1892 -1481 -2492 2104 -2129 -634 -1493 479 56 2627 -894 -625 -3658 -1799 -5744 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -12804 -13846 -894 -1115 -701 -1378 * * 3 -2861 -4565 -3040 -1842 -3224 -1098 -944 -1189 2206 -1997 -2137 -671 -1023 -2575 2995 -962 -134 -1518 -4298 -2674 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -12809 -13851 -894 -1115 -701 -1378 * * 4 -332 -2327 -2773 -748 -822 -959 -60 -975 1606 -1375 -844 228 1330 28 842 411 263 -842 -1066 106 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -12809 -13851 -894 -1115 -701 -1378 * * 5 -1901 -4540 -1127 -2145 -5398 -1230 -1576 -3396 619 -4362 -1081 -4132 -2281 -3744 3764 -3282 -2473 -2315 467 -315 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -12 -12809 -13851 -894 -1115 -701 -1378 * * 6 -1645 1429 -2038 -1546 -802 -426 -2253 -1158 -719 -1520 -1641 -1220 -2514 508 -169 -360 2900 -453 461 64 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -132 -12809 -3664 -894 -1115 -701 -1378 * * 7 548 133 -6862 -6253 -1157 -6436 361 43 -83 -595 -497 696 271 -1882 1115 1119 1094 432 -1618 -4937 - -150 -504 229 48 -377 396 101 -623 210 -466 -725 282 393 44 103 355 114 -367 -284 -248 - -218 -3327 -4947 -748 -1306 -48 -4932 * * 8 -1610 -2173 -1813 -3083 3348 -2160 -9 194 -175 365 -756 -2553 -594 -1755 -1458 -3248 -1569 -4474 1036 1872 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -12765 -13807 -894 -1115 -651 -1462 * * 9 -799 -6234 -1290 -1403 -6554 -1471 -595 -3278 -388 -1391 -5323 504 -20 -2692 -1730 1840 2680 -3399 -6417 -1051 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -12794 -13836 -894 -1115 -1995 -417 * * 10 -126 -6234 899 439 -6555 -1276 -22 -1914 800 -1731 -146 194 1743 572 333 514 -594 -874 -6417 -1887 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -12794 -13836 -894 -1115 -1995 -417 * * 11 -236 -1000 966 2080 -1051 -2500 1172 -1439 -394 -1783 -999 80 -1859 529 -380 120 -544 -972 -1135 726 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -12794 -13836 -894 -1115 -851 -1166 * * 12 223 -6217 -1785 -128 -2810 -5750 -980 -1054 -1654 -1718 -5309 -1564 -5843 3919 -2102 -988 -1615 -1057 -6407 -613 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -12802 -13844 -894 -1115 -1473 -644 * * 13 -1805 -969 -2930 -2324 -3207 -3745 -1167 1348 -281 1970 -1959 -1282 -6222 -1897 854 -1054 556 880 -5755 -5305 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -12802 -13844 -894 -1115 -1473 -644 * * 14 203 -1418 430 966 -953 -1347 1360 -3067 172 -345 -399 -53 -119 1354 978 38 -1092 -1577 -55 -1351 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -12802 -13844 -894 -1115 -368 -2150 * * 15 602 -2325 -3177 1645 59 -1472 -2093 673 -226 -392 -4 -2895 -1915 436 55 -1420 330 927 -6263 -801 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -12810 -13852 -894 -1115 -701 -1378 * * 16 -8488 -431 -10845 -10238 -2005 -10720 -9207 -3059 -10056 3290 983 -10459 -9540 -8646 -9442 -10155 -4197 -6165 -7582 -2666 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -13 -12810 -13852 -894 -1115 -701 -1378 * * 17 -1850 -6249 -1410 3073 -2822 -3217 0 -3574 1093 -1821 -2095 -610 -3125 857 363 -3176 -2227 -5871 -6433 -16 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -12810 -13852 -894 -1115 -701 -1378 * * 18 868 -2502 142 448 -6570 -2486 42 -1658 1819 -2494 179 582 -2983 1075 1364 -149 -698 -2153 -6433 -5750 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -12810 -13852 -894 -1115 -701 -1378 * * 19 363 -146 -3542 1409 308 -2986 894 -506 -158 -757 238 -2522 -6049 -971 -181 358 -709 192 2431 1543 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -12810 -13853 -894 -1115 -701 -1378 * * 20 -9106 -8171 -9731 -9998 4260 -9559 -2080 -2468 -3572 -704 -7486 -8242 -9428 -2935 -8961 -8790 -8973 -3560 -603 1918 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -12811 -13853 -894 -1115 -701 -1378 * * 21 842 -1901 -401 1291 -1870 -2133 1821 -2686 831 -86 171 281 -5845 1883 -127 -1423 -1921 -1702 -6429 -977 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -14 -12811 -13853 -894 -1115 -701 -1378 * * 22 -1027 -121 139 746 -140 -2265 566 -261 1391 -1151 -384 -90 -3031 1128 1340 -393 -27 -1033 -6429 -413 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -22 -12811 -7549 -894 -1115 -701 -1378 * * 23 -3799 2097 538 -866 -1237 -1083 1568 -3892 -124 -3952 -5330 2768 -5836 1164 -1579 88 990 -2256 -6425 -2062 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -12803 -8342 -894 -1115 -1483 -639 * * 24 -334 -857 -1380 -1383 -3191 -2805 1625 -3863 1292 -2240 437 168 2040 1697 872 -293 -752 -1950 -1645 -1789 - -156 -511 230 43 -387 394 115 -627 212 -466 -692 292 411 34 93 355 117 -378 -284 -246 - -206 -3078 -7659 -1738 -514 -288 -2468 * * 25 -2666 -6205 -2840 -1985 384 -5754 942 -6247 210 -2710 -1925 489 -5847 -779 -305 -1207 -462 -2624 481 4094 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -12804 -13846 -894 -1115 -1433 -668 * * 26 -3554 -5613 -8195 -3354 -1843 -7446 -6317 -129 -7183 1436 -846 -7096 3616 -6734 -3161 -6548 -5770 -602 -6048 -5773 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -12804 -13846 -894 -1115 -1433 -668 * * 27 -1613 555 1757 -1357 -6560 -511 -1273 -3227 -2861 -3081 -5329 752 -1759 -2554 -3228 2212 1851 -1959 -6424 -5742 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -12805 -13847 -894 -1115 -380 -2110 * * 28 338 -1399 -436 44 -3149 -588 -341 -255 1018 -1261 -720 -1598 678 -244 1604 374 -646 299 -1502 -2802 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -12812 -13854 -894 -1115 -701 -1378 * * 29 934 -6248 658 1434 -539 -2413 171 -1805 257 -1613 -463 -713 604 1572 -190 52 -1621 -2085 -2114 -635 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -22 -12812 -7644 -894 -1115 -701 -1378 * * 30 -674 -6240 1004 2266 -6560 -2603 -2440 -1102 319 -1814 907 -4379 -5837 1243 1335 -1864 443 -1252 -6424 -5742 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -15 -12805 -13847 -894 -1115 -377 -2121 * * 31 -2594 -433 -7419 -6783 -1411 -6624 -5495 955 1308 209 302 -6269 -6674 -1467 3214 -2511 -5017 -1324 -2037 -388 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -12812 -13854 -894 -1115 -701 -1378 * * 32 -139 -19 139 2173 -2681 -2667 -2322 117 66 -1089 -1088 -1100 -5851 1439 535 -548 -142 -793 -1194 -695 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -12812 -13854 -894 -1115 -701 -1378 * * 33 -681 -6248 -174 2309 -2081 -5750 603 -2937 953 -2211 -544 -257 -5844 1541 923 -413 -492 -2186 -605 -886 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -12813 -13855 -894 -1115 -701 -1378 * * 34 -8441 -7782 -10795 -10196 -2528 -10649 -9126 2022 -10008 2832 109 -10371 -9516 -8630 -9412 -10066 -8255 -983 409 -771 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -12813 -13855 -894 -1115 -701 -1378 * * 35 2987 -5213 -3202 -3111 -5218 -1465 -5056 -2376 -3146 -2483 -255 -5380 -6356 -5003 -936 1454 -733 -586 -5624 -5214 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -12813 -13855 -894 -1115 -701 -1378 * * 36 785 -1113 37 1016 -3446 -1829 197 -1065 1410 -2148 -694 286 -5844 1509 1078 -127 -1204 -873 -6431 -3113 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -16 -12813 -13855 -894 -1115 -701 -1378 * * 37 -175 -1222 -907 1362 -1746 -5761 -1050 -584 1310 -585 209 -443 -5854 1630 645 475 -253 -1012 -854 -1923 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -12813 -13855 -894 -1115 -701 -1378 * * 38 -2815 1050 -7424 -3633 -1771 -6626 -5497 529 -6383 2472 120 -6272 -6676 -6006 -6183 -1572 2046 -1014 -5363 -1455 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -12813 -13856 -894 -1115 -701 -1378 * * 39 -2878 -6249 -14 -905 -6571 2483 1029 -6321 358 -4591 -779 2111 -3163 108 88 -180 -4715 -5871 -349 -3132 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -12814 -13856 -894 -1115 -701 -1378 * * 40 -1859 -1665 -7402 -2113 -3140 -6621 -1267 50 -1967 2869 1897 -3209 -6671 -1086 -2238 -3545 -2531 -1160 -1047 -1340 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -17 -12814 -13856 -894 -1115 -701 -1378 * * 41 -1665 -231 23 -653 -3264 -1426 -84 -6319 -800 -2709 -1633 -182 1215 147 -1458 1787 2202 -2694 -349 -1870 - -161 -494 217 43 -396 397 101 -606 225 -456 -711 275 391 49 108 353 114 -357 -322 -253 - -166 -3372 -13856 -3337 -150 -701 -1378 * * 42 -1438 -1632 82 2450 -1465 -2944 -4418 -2099 713 -987 -945 -1823 886 291 390 -3343 -391 101 -6412 -170 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -12814 -13856 -894 -1115 -701 -1378 * * 43 88 -92 -21 155 -2001 -1941 -685 -1541 859 -1517 -2727 -496 -1339 -543 2238 578 1019 -2112 -6431 -1248 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -12814 -13857 -894 -1115 -701 -1378 * * 44 -2747 -6249 -724 -112 -2907 -5750 -1521 -6320 -1244 -2692 -5338 -171 -5843 3604 1174 -1270 -19 731 -6432 -5750 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -12815 -13857 -894 -1115 -701 -1378 * * 45 -7037 -6512 -9745 -9446 -7262 -9636 -9821 2616 -9445 -1249 -5925 -9288 -9349 -9449 -9660 -9039 -3052 3201 -9124 -8564 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -12815 -13857 -894 -1115 -701 -1378 * * 46 -832 -835 -993 -1188 -1717 -2958 -538 -1418 2454 -6264 -816 230 -5843 2165 997 -45 -62 -1534 -6432 -1637 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -18 -12815 -13857 -894 -1115 -701 -1378 * * 47 -2384 -5955 -2909 -1053 -1471 -2679 -1026 2040 -144 -2532 -2173 1833 -5939 -1635 -1060 -1288 423 2084 -6216 -905 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -12815 -13857 -894 -1115 -701 -1378 * * 48 -9446 -8353 -9807 -10170 -93 -9691 -2065 -8330 -9725 -7631 -7730 -8296 -9544 -8438 -9083 -8940 -3720 -8486 6219 -827 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -12816 -13858 -894 -1115 -701 -1378 * * 49 -9148 -8203 -10002 -10190 4547 -9886 -6227 -6826 -9803 -2421 -1958 -8601 -9546 -8489 -9167 -9159 -8982 -2664 -5436 -1533 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 361 117 -369 -294 -249 - -26 -7686 -13858 -165 -3213 -701 -1378 * * 50 -1265 1529 -2034 -1441 -6569 -1854 -1168 -305 888 -6264 -214 -703 -5843 3645 -1030 150 -1163 -3278 -1182 -5749 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -19 -12816 -13858 -894 -1115 -701 -1378 * * 51 -1338 -6247 -779 -832 -6567 -3884 -1194 -3365 -1290 -3834 -2389 4101 -5844 -1651 -1519 -3535 -1401 -3925 -1182 -5749 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -20 -12816 -13858 -894 -1115 -701 -1378 * * 52 12 -2233 -4646 -3077 -6516 -5763 708 -6254 913 -3844 -190 -1546 -5855 355 3518 -2051 -536 -3350 -1234 -2660 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -20 -12817 -13859 -894 -1115 -701 -1378 * * 53 -4480 -8202 -8762 -3316 -9187 -8084 -5832 -8387 -210 -4155 -7332 -1538 -7973 -884 4096 -3977 -7247 -8193 -1537 -3234 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -20 -12817 -13859 -894 -1115 -701 -1378 * * 54 2060 405 -6821 -6219 -1246 -2570 -1003 -1261 6 -2246 2370 -1788 -3159 917 735 -766 9 -788 -510 1106 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -20 -12817 -13859 -894 -1115 -701 -1378 * * 55 -885 -6211 -4645 -1774 -3256 -3449 -2061 -3357 3068 -1989 -1281 -1949 -5854 -791 2376 -1462 -894 -3244 -6405 -873 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -21 -12817 -13860 -894 -1115 -701 -1378 * * 56 -129 1418 286 773 -954 -2661 1484 -931 -610 107 546 -2118 -2187 1072 -1344 161 -2020 -1752 3510 -37 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -21 -12818 -13860 -894 -1115 -701 -1378 * * 57 -1261 -6215 -1696 -1322 -2809 -499 -4420 -1666 2898 -1507 -2116 -2120 -3415 -1904 2529 -2372 -4719 -2708 441 -2513 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -21 -12813 -13855 -894 -1115 -701 -1378 * * 58 -1981 -6238 -2531 -2794 -2074 -1818 432 -996 2286 -1241 -5328 552 -2309 -167 2549 -841 -543 -1790 1063 -2531 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -22 -12814 -13856 -894 -1115 -701 -1378 * * 59 -625 -1499 -93 389 -6564 -856 345 -555 693 -602 941 400 -480 1748 664 411 -98 -843 -1288 -5745 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -22 -12814 -13856 -894 -1115 -701 -1378 * * 60 -420 -1015 -554 801 -2551 -256 598 -115 883 -1119 536 616 -2612 1444 374 400 -228 -1024 318 -2674 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -22 -12798 -13840 -894 -1115 -701 -1378 * * 61 -463 -1052 -1222 199 -1332 -598 214 3 1386 -281 -101 385 -289 1063 1047 -377 -657 -623 -6405 -830 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -23 -12791 -13833 -894 -1115 -701 -1378 * * 62 54 -1208 34 827 -1223 -543 483 -1532 970 -586 376 -271 9 -212 1100 257 -295 -344 -1219 -5720 - -149 -500 233 43 -381 399 106 -626 210 -466 -720 275 394 45 96 359 117 -369 -294 -249 - -23 -12782 -13824 -894 -1115 -701 -1378 * * 63 -101 -1443 -84 640 -921 -319 626 -1168 986 -589 971 -213 -530 834 314 368 -450 -978 344 -761 - * * * * * * * * * * * * * * * * * * * * - * * * * * * * * 0 // wise-2.4.1/test_data/rpo_human.intron0000644000175000001440000000006010670452661017247 0ustar philippusers# # example intron file # 24 0 #25 0 65 0 101 1 wise-2.4.1/test_data/xeno.pep0000644000175000001440000000104010303567047015500 0ustar philippusers>ROA1_XENLA P17130 HETEROGENEOUS NUCLEAR RIBONUCLEOPROTEINS A1 HOMOLOG (HNRNP A1) (HELIX-DESTABILIZING PROTEIN) (SINGLE-STRAND BINDING PROTEIN) (HNRNP CORE PROTEIN A1). MHKSE0APNEPEQLRKLFIGGLSFETTDESLREHFEQWGTLTDCV0VMRDPNSKRSRGFGFV TYLSTDEVDAAMTARPHKVDGRVVEPKRAVSRE0DSSRPGAHLTVKKIFVGGIKEDTEEDH LREYFEQYGKIEVIEIMTDRGSGKKRGFAFVTFEDHDSVDKIVIQKYHTVNNHNSQVRKA LSKQEMASVSGSQRERGGSGNYGSRGGFGNDNFGGRGGNFGGNRGGGGGFGNRGYGGDGY NGDGQLWWQPSLLGWNRGYGAGQGGGYGAGQGGGYGGGGQGGGYGGNGGYDGYNGGGSGF SGSGGNFGSSGGYNDFGNYNSQSSSNFGPMKGGNYGGGRNSGPYGGGYGGGSASSSSGYG GGRRF wise-2.4.1/test_data/jason.dna0000644000175000001440000002743707577355654015663 0ustar philippusers>Contig4084 tagcagggagaggaaatactaacagtccaaaagatatgtgcgaatgttggagtctcccaa gcTGTACAATGTGGGCGCAGACTACCAGGAGGGCGATGACGCGCTCGTTCAGAAGCGAGG TGAGTAACATTAGCAAAGTCTGTATAATACCTCACTGATTCACTCGCAGCCGATCTGATC CATTCCGCTGCTGTCCTTCTCGAAAAGGGAGGTCTCGTTCGCTATGACCGTGCTACTGGT GTCTTCCAGTCTACCGACCTTGGCCGTATTGCCTCGCACTACTACATTGCGTACTCTTCA ATGTCCGTGTACAACAAGCACCTTAAGCCTAATATGACTATGATCGACCTCTTCCGAGTG TTCGCTTTGAGCAACGAGTTCAGACTGATCCCTGTCAGGCAAGAAGAAAAACTCGAGTTG GCCAAGCTGCTTGAGAGGGTGCCGATACCCGTGAAGGAGGGTGTGGACGAATCTGTGGCC AAGGTGAATGTGCTTTTGCAAGCGTATATCTCACAGCTTAAGCTCTCCGGATTCGACATC GTCACGGACATGGTTTTCATCCAACAATCTGCTGGCCGTATCATCCGCGCCATGTTTGAA ATCTGTCTCAAAAAGGGCTGGGCTCAACCGATGCGAGCTGCTCTTGACCTGTGTAAAATG GTTGAGAGAAGGATGTGGAAGTCTATGACTCCGCTCAGGCAATTCCCTAGGATCAACCGT GAGATTGTTCAGCGTGCGGAAAGGAAGGACTTCCCTTGGTACAGGTACTTTGACCTTGAC GCCGCTGAACTAGGAGAGTTGATCGGCTTGCCCAAGAGCGGAGCCTACATCCAGTCTCTT GTTCACAAGTTCCCCCGACTCGATCTTCAAGCTCATGTCCTGCCCCTCACTCGATCTCTT CTCAAGATCAACGTCACTCTTACTCCTGACTTCCAGTGGGATCGTAATGTACATGGCGCC AGTCAAGCATTTTGGATCATCGTGGAGGACGTGGATGGCGAGAATGTTCTTTATCACGAC CAGTTTATCTTACGAGAGAGGTTCGCGGAGGATGAGCATTATGTGACCATCACCGTCCCC ATCTCTGAGCCTGTACCTCCCAACTACTATCTGTCTGTCATTTCtGATAGGTGGTTACAA GCGGAGAGCAAGTTACCCATCTCGTTCGCTCATTTGATCAGGCCCGAACCATTTCCTCCT CACACCCCTTTGCTTGAACTCCAACCTTTGCCGATTACAGCGCTTCATAACAAGGCTTTT GAGTCTCTTTATCCTTTCGAGCACTTCAACAAGATCCAAACCCAAGTCTTCCAGGCCCTT TTCACTACTGACGACAATGTCTTCATCGGTGCGCCTACAGGAAGCGGAAAAACTATTTGT GCGGAGTTTGCGTTGTTGAGACTTTGGAGCAAGAAGGGTAAGGATGTGCCGAGGGCGGTA TGCATCGAGCCTTACCAGGAAATGGTGGATACTCGAGTGGCGGAATGGTCTAACAAGTTT GAGGGACTGGAGAAGGTGATCGTCGCCCTCACCGGGGAATCGACGGCCGATCTGGCGCTA TTGCGAAAAGCGGATGTTGTTGTCTGTACTCCTTCACAGTGGGATTTGCTTTCTCGAAGA TGGAAGACAAGGAAGGATGTGCAGAACATTGGGCTGCTGATTGCCGATGAGCTTCAATTA ATCGGCGGTGATGTGGGTTCTACCTACGAGGTGATTGTTTCCAGAACGAGATATGTATCT CAACAGACGGGGATCACCACCAGAATTGTAGCCTGCAGTGTGAGCTTAAGCAATGCTAGG GATTTGGGTGATTGGATCGGAGCTAGTAGCCAAACCGTGTTTAACTTTTCTCCTGCCGCT CGACCTCTCCCTCTCGAGGTGCATTTGCAGTCTTTCAACGTGCCTCACTTCCCCTCTCTC ATGCTTGCTATGGCCAAACCCGCCTATCTCTCTATGGTGGAACACTCTGCTGGCCGGCCG ACCATCTGCTTCGTTGCCTCGCGCAAGCAATGTAAGCTCACTGCCAACGATATCCTTACG TACTGCCTTGCGGATGACGATGAGACTCGATTCCTCAATGTTGAGAGAGAAGATTTGGAG CCGCACTTGGAGAGATTGAGCGACGAGGATTTGAAGGAGACCTTGAGGTACGGTATTGGA TACTATCACGAGGCTCTGAGCAAGTTGGACAAAAAGATTGTCACTACATTGTTCGAGGAG GGAGCTATCAAGGTGCTTGTGGCCTCTAAGGTAAGTTCGAATCGATTCCTCCTGACTGAA CATGAGTTAATAATGTGCTAGGACACTGCTTGGAGTCTCCCTTCGACTGCTTATATGGTC ATCATCATGGGTGTCCAATATTTCGATGGCCAGGAGCACCGATACGTTGATTATGCCATC GCCGATATCCTCCAAATGATGGGCCGAGCTTGTCGCCCAACGATTGACACCTCTTCGCGG TGCGTGTTGATGTGTCAGCAGACCCGAAAGGACTTCTTCAAAAAGTTCTTAAACGAGGCA TTGCCGGTCGAGTCAAGTTTACCGAGCTTCTTGCACGATCACTTCAACGCCGAGATTGTA GCGAGGACTATCGAGAATAAGCAGGATGCTGTTGATTGGTGTACTTGGACCTGGTTCTAC AGGAGGTTAATGCAGAATCCCGGAGTGAGTATCAAGCCTGAGTCGCTAAAAGTGCGATAG CTGATAGCAAAATCAGTTTTACAACCTACAGGGCACCACACCTACTCATATTGGCGAATA CCTATCTGAACTTGTCGAAACCACCTTGAATGACTTGGTCAACTCGGATTGCATTATCAT CCAAGACGATATGGACACCCTCCCCAACAACTTAGGTATGATTGCATCCTTTTACTACAT CTCATACATCACCGTCGAAATCTTCTCTCAATCCATCAAAGAAACTACCAAACTCAAGGG CTTGCTTGAAATTGTCTCTTCAGCGCATGAGTTTGAGACCGTTCCGATCAGGCACCATGA AGACACTCTTCTTGAGAGGATTTACGACCGTGTGCCTGTTAAGGTTGCCAAAGTCGATTA CAGCTCACCCTATTTCAAAACTTTCCTCCTGCTTCAAGCTCATTTCAGCCGCACGACCCT TCCTCCCGACTTGGCTATCGATCAATCTACTATTCTTGGCAAGATAATCGGTCTTCTTTC AGCCGCTGTGGATGTTATGTCCAGCAAGAGTTTGCTTGGATGTTTGGGTGCGATGGACCT TAGTCAAATGTGTGTGCAGGCGATGTGGGATAGGGATTCACCTTTGAAGCAGGTGCCCTA CTTTGACGCCGACGTCCTTGGGAGATTCAAGGCCAAGGGTTTGGACTCCGTGTATGACAT CATGGAGCTGGAAGATGATGAAAGGAATGATTTGTTGAGGATGAATGACAGACAGCTGTA CGTTTTCTTTTCCTTTCAGAATCTAGAAACAAATTACTAATGGGATTGCAGTGCGCGAGT TGCCAAGTTCGTCAATTCTTATCCTAATATTGAGGTTTCTTACCACGTCGAAGACGCCTC TTCTCTTACCTCTTCCGACCCTGTCGTGCTCAATATTACCCTGGATCGCGAAGCTGACGA AGGCAACCCTGAAGACCAAGTGGCCGATGCACCCCACTTCCCTCATAAGAAGATGGTCTC ATGGTGGCTCGTGGTGGGTGACGAAAAGACCAAATCGTTGTACGCGATCAAGAAGGTCAC TGTTAAAGCGACACTTAAGACTAAGCTTGAATTCACACTCCCTGAAGGAGAGTGGAACTT GAAGCTGTTCTTGATCTGTGATAGCTATGCAGGAGCGGACCAGGACTTTGATATCGAGAC TCTTAAGGTAGTGGAAGGGGAGAGCTCTGACGAGGAGTCATCAGAGGAGGAGATGGAGGT GGATAATTAGAGATGTGTTTTTTTATTTGAAATCTAAAGTGAAAAGTGTAATTGATACCC ATTCCCCATGCATGCGTTTCTGAAGATCCATTATACTATAAGCTACAAGGATTGTCGTTC ACTCTCTGAGTAAATCATGAGAATTTATCGCATGTAATAGCTGCCCAAATTGTACGTAGC CCATAATGATAGAAGGGGCCTTAGTAACAAGGGGCAGTCAACAAGCACAAGAAGACTTTT AATAACTTGTCGAGCCAGATTACAATCTCCGCATCATCTCCGGTAGGCTCTTCACGCGCC TTAGCGAAACCTTTTGCCTCCTGAAATCTTCATTAATGAATGAACACATCCTCCGCCGGT CCCAAACGTCTCCTGCACCATGTTTATAGTAGCACGCCTTGTCGTACATTGTTGGATCCA CTTCCGACGATTTGTCTGTCAAGGGACTGGCTGTCGAGCGTCCTTTAGATTTCGGCATCG CCGAATCATCTGACCCATTTGAACTTGATGACGGATCAGAAAACTGACTAACCAGCCCTT GTCCATTTTTTTCTAGGGTAATTGAACTCTGCATAACCGCATTGAGCGGTACTGGAAACC TCCAAGTTCTATTCGCCCATTGGGGACTTGTCCCCGAAAGAGAGGATTTGGAAGAGGATC GAGAAGTAGCGGAGAAGACGGATCTTCCTGATTGGCGATATGATAAATGGCGACTGACCA GGAAAGATGCTGTTCCTGGAGAACGGCGTGGTCTGATAGGAGGTATTTCTAGATTGATAT TGATTTCGGTAGATAAAGTATGGTCACTTTGTTGACGTCGCAAAGTACTCTCGTCTGCCA GCTTTGCTTGTATTAAATCCTCCGATGTTTTCGTCTCCTCCAACTCTTCGTCATTTGACG TCTTCCTGCGCACTGTCAAGAATAGATGCTTGAACTTGTCGCTTAATCGGCGAGCGTGGC CTTTATTAAATCTGATTGCATCGACAGATTGCGGGATATGTCGTGCGGAAAGCGGCTGTT CGGGTCCAAGAGTTGTGTCTGATCCGCAGGCGATGAGCGCTTCTCGATGCATGAGTGCCC TCCTGGTTTGCTCTGTCGCATGCTGCTGCTGTAGGATGTATGAAGGCGCTGTGGCCGGAG ATGTTTTGCAATATAGCGCATGGTTCGGATGCTTGACAGGCAGCGGCTGATGTATTTGTG AAAGTTTGGAAGCAGGCAGAGATGTGTCAACTTTGAGATGAGGACGAGGAGGTCGGGACT TAGGACCTAGAAGAGATGTCATATGCGAATGGTGGGGTGAAGGATGAGATGGACGCTCAA CGGGGCGAGTGGCAATGGTACAAGAGGCGGCAAACGGGTGATCAGGGGGGAGCGAAGCCG CTAAATTTTGAGAGTCTTGAGATACCATCATCACAAGGAACGCTCTTTCACGGTACTTTG GTGCACAGAGATGATGTTGCAGCCCTTGGTATGCAGGGCATGAGGATCGAGCCGGATATG TATCATAATGGAGTCGTTTAACGTCTGCTTTGTTTTTTTATAACCAAATGACATGACAGA GCGCGATGACAAATGGAGATGTTTGACATCTAGACATCCTTTGATGGTGTATGATAGGGA ACCGAGAAGATTGCTGGAGGTGACACATGTAGATTGCGCTCACGGAGAACAGTTGCTTTC AAAGGAATGTACCTAAGCGACGATCTTGGTGTGTCACAGGGTCGTCAATCTTTGCCCACA AACGAGATAATGGACCAAAGAGAGGATGTATTCAGTGCCTTTATGGCATAGAATCGCTTT ACAGATAGTGCGGACTCGGACTCAATAGTCAGCCCAATCTGGTCGCCATGTGCGGTCGTA ATTCACCAGCTTTGGTTGAAATGCGGCAATGAACTGCCGAAGCCTTACATCAATAGACGA TCCAAGTCACATAGACGCAAGACGCACCTCCATTCCAGTCTCCCCTAGTCCAACACCTTC CGCTCCTCCTGCGGGTCCAGCAAACATATCCCCCTCCGCAAAGAGACCTGTCAGACTCCA AGACTGAAACCTTCTGATCAAAGCGCACACTAGAGTGCAACTTCCTTTGCCAGTATCATC ATGGACCAGCAGGGGATAATTTCTCTTGTCCAATAGAACCTTCAGTAGAGCCTCCATGCG TTCTTTGCCTTCTGGAGTGTACAAATCGGATTCATTGCTGAAGTCGAAGCGGTACAGTTC GAGATTTTGCGATTGAACGAAATCGAGCGAGTCTTGCCGGTAAGGATCAGATCCTTCGAC ATAGATGATGCCCTTGAGTTTGAGCCTTTTGAGAAAAGGGAAGTTTTTGCGGTTGGGATG TCCTGAACGGTATACGCCTGGAGCAACAAGCGAGAAGTTGATGGGCGGAACAACCACTGA TGGACCGTCGTCAACCATTGTTACCCCGGGCGTCACCCTAGTTGGCATCGTGCCGGTCAC TTGGGTGATGGCGTTTTAGTTGGGAGAGGACTGCTCGGAGAACCTGAAAGAATATCGCGA GCAAATGACAAATGATATGGAATGGTGAATGCTCATGGATGCTGACGTAAGTCTTTTGAA ATGAAAGGAAAAAGAACGAATACATGTGTATCACATCACTTAAGCAGCGATTTCGTGAGG AGATTCTCACCGTGTCGAGTGTCAACAAAACATCAACCTGGGCTTGTGTTGCAGTGGTAG CATTCTAGACTTCGAGGTCGTGAACTGGAGTTTATCTAGCGGTCGCGGGTTCAAATCCCG TCGAGCCTTCGTTACTTTTTTCTTTTTCTTTTGTCCAGGGCTCTTCCTCAACAAGCGGAC GCGTCGCGCGTTTTCATTTTTACTCCACAGTGTATCACCATTTTGATTTCCCTTGTGCAA CTTTTTCCTTCTCCTCTCATTCTCTACGAGGTTCAAGATGGAAGAAGATAAAGATATAGC TGCTATCGATGCCGAGATAGCCAAGTTGATGGCGCAGAAAGCGGCAAAGGCGGCGATGAA AGAAAAGGACCGACTTGCTCGAGAGCAAGAGGAAGCACATGTTCTTGTCCAAGCCACGCC CAAGAAGAAGGGTAAGAAGACACGTCcCGCTATCTAaAGTGACTGACATATGATCACAGA ACAAAAGCAGTCTGATTCTCTTTTTCAAGCACCTTCTCAACCCAAATTCGTCTCCGCCTC ATCTCTTCTCCCGCATGAGCGAAAGCCGGCGCAAGAGCTACCGCCATTACCTATCGTACC GTCTACCATGGCAGCCAAGATGGCCGCTCTCAAGCAGCGTCCAAATTATGTAAAATCTTC CCGACAAACTTCAGCCTCTTTCTCAGCGTCTGTGAGCAATAGTTCACATCTAAGCTCAAA ACCTTCGTCGTGTCGTCCTGACAAGTTAAATTGTGAGCGATCTCGGAGCTCTTCGCTAGA GGTGGAAGATAAGAAGCCGGTGATTAGGAGAGATGAAGAAGATAGCACATTAATTGAGGA ACTAGAGCTAGGACCGAAACAGTTTGGACCGGATCCTGAGGGCGAAGATGAGTGGCTCGG CGTGGAACCAAACTCAAACATCCGTCTAAAGTAAGTCAAAGCGAGTCAGTGATGTTTTTT GTAGGCTAATTTGCCTCCCAAGGAAACGTGTCATGCCCCACGCAGATCTTCAAGAATTCC TGACAGGCCGATATTACCTACCTCCGTCAAAATTATATTCCGTCGTTCGCCTTTCTCGCG ATGGAACGTCATACGACGTTCCAGCCGACGATGAATGGGTCACTATAGCAGTAGTCGCAC AAAGAGGCCCCATTAAGATTAGCGGTATGAAGGAGAAACGGGTGGGGAGTGATCGGGAAG ATAATAATGATAATGATAATGATGATGATAATGATGATAGTGAgGATGAGGCGGATTATT CCGATTCTGATGATCAGGACGGGgAGGGCAGTGGTGACATTAAGGACCTGATTGGAGAGA AAGGAAGGTCTTTTGAAAAACCGAAGATTACGAAGAAAAAGAAAGTCAAAGAAAGCTCAA GCAAAGATGATTGGAAAAAGCATCGTGAACCTCGAAAATATATCAACTTCACTCTCTGCG CCATGCCTCACCGCAGCCGCAATGCCTCCGCTCCCAGTGGCGACGCTCTCCTTCATCTGT TACTTTTCGAAGCCGACCATGTTGTACGTATAGAGCATGGAAATGGCGAGGTGACCAAGT CGTACCGAGGAGGTTCGGGAGGCGCTTATGAAAAGTGGTGCAATTTGCCTGAAGGTAGCG TGATTGCTATATTGAACCCTCGCATCTGGCGTAATCTCAAGGTATGTGCGCTCGTTTATC TTGCATCTGATGCATAAAATTGATTTGAATCTAGGGCCAACATGCCAAACCGCATCCTAT GGAGTTCCCTTTGGGTTTGAATCCTGTCTCTGATGACTCGATTGCTGTCATCGGCCAAGC TCGAGACCTAGGGCGCTGCACGGCAGTCCAAAGGGATGGAAGCCGGTGCAAATCTTGGGT GGATCTGTGGGTGATGCCCCAGACTTCGGTGGATAGACTGACTCTTCTATTAGGAGACAG AATCCGATTTGCGAATATCATGTACATGCTGCTGTCAGGAAGAACAAATCAGGCAGAGGC GAGTTTACAGCTAGGTATGTCAGATTTCATCTATTGCTGGGACCTCGCATGACAGACTTA TTGCCGGAGTACAGTACCAATTCTTTTACAATAATCAATGGCACCCGAACTGCGAAATTA AACAACAGGAAAGGCCTTCTACCACCAGCAGGTGCGAGACCCGCCGCACGTGGCCCTGAC AACGGCGGTGGAGGCGGAACATACATCGTCGGCGGAGGCGTAATTAACACGGGCACATTC GGTGACGAAAACATCGCCGGACGGCTTGGCAGGAGTCGTGCGGAAAAGAAGAAGAGGAGG CAACAGAAGAAGGAGGCAGAGAAGGAGTTTCAGGTGCTGTATGAAAGGGAAAGGGGAATA GGAGGTGGGACGACGGGGGGTATGTATCTGGAGGCTTTGAAGAGGAAGCACAAGAAAGAG GAGAGTTTGTCAGAAGGGGATGAAGATGAGCTGGAAAGAAAGCCTGTATTTTCGGCGGAG GCAATCAAGAGGATTGGATATGATCCGTCGGCGAAGAGAGGGCAGTTTAGTAAGGAGGAG GACCAGAAGCGGGTAAGCGCATCACTAAGCATTGGGTCGAAATTCATGTCGCTGATAACG TTATACAGATGGGAACCATTGCAACTCTCGAAGAATTGAGTACAGGGTGCCGTATGGAGC GTGCTGCCAAGCGGCTAAAAGAAGGAAAGCTCGCTGGCAAAACCTTACTATCAGAACGAC AAAGCACCCCATTGTTGCAAGGCACCTCAAACCCTTCTCAGCCCCGACATATCGATACTC TTACAACTGCCGGACGGAATAAGGATAATAACAAAGTAAATATGGATCAGTTTAACATCG CAAAACAGCCGCATGGCCCGAAGATCCGTCTTCCTAGACCACCTCTCAATCGCGACGGAG ATGACGACATGATAGACCTTGATTAAAGACGCTTGTTGTAACTTCGATATAACCACACTG TTGAGCATTTCGTTATCGCATTTGTAGCATCTTCCTTCAGTATTACCTCTACAGCGACTC ATTTACACCATGCATCGAGTTTCAGGTTTACCTAGCTTTCTGATATCTCCTATGAAGCCA TATATAGCTTTATTCCTTTTTGACTGGATCGTAGGCCTGCACTTCAATTTCAACCCGCAT ATCATCTTCTCCTAGCCGGGTGACGCCAACGCAGGTCCACAGGGGCTGATGATTTGGCAT GTATTTGCGAAAGTTTCGAACCATGGCCTCGAGGGCTTCGTTATTGATGGGAACATGATA AGAGTTGACACGGAACACCTTGTAGCATCATCAGCTTTAATCGTCATTACGTCGAGAAGT CGAGTGAAGTAGTAGCCACCTCACCTGTTCCCAGCCTTTGCCGCCAGCTGTAGTCAAAGT AAGCTCGACGTTCTTGAAAGCTTGATCAATCTGGGCATTGATCTCCTTATAGAATTCGAA AGTGTCGGGATCCCAGCCACCTTTTTGTGAATCGTAAGTTACCACTGGTTACGGCTTTTG AGATCTACATACCTTGACCAGAACAATGAATGGTATCGCCCAGTCGTACAGCTTGGGAGT AATGGTGCGACTTGGCGGCTTTCTCACCGTAGCCCTTGTAGTTATAGTAGGTAAGATCCG ACATTATTCAGGAAGCTGTTTATGTGTCTCGCTTTCGGGATGAGGGCAGTGAATTATTGG AAGGAAGGTTGCCTTACATATGTATCTATATCGCCAAAGCCGAATTACTCGCCAGTCTCT GCTCGGATGAGTAAACCGGCGGAAGAGGCAGGGGCGGAAGGTCGGGCGAGGGGCGCATTT GTGAAATTCGAAGTGAAATTCCGCTTCCGGTATTTCACAAATCCGCTGCCTGCTCCTCCG CAAGTTAACATCAGAACAAACGATACGCGGAAGTAATCAATAATTATTAAGCAAGTAGTT CCACCATCACTGTTGTGGGAATTTTTCGCGTGGACAGGTCCGGGGCACGCAACTGGTTCG GCATGGACCTTGCGTGGTGTCGGAGGAGGCGTGCACCTAAACGTGAACACAACAAGGCAC GCGGCTGGAAAAGCGTAGAAAGTAGCATGGAAAATAGGCGTTGCATGCAGGCTGCCCTTT GTTTGGTTCACGCTACGTCCACGCAACTGGCCGGCGCACGCAGATGCACGCTGCATGCAC GTCCTATGGCCATTCAACTGTGCACTCAACCAAACAAGTCGTCGCTGTCAGCAGCGAAAT TCTTTTCATCCATTTCCAATTTACATAAATACCTCCCCTCATCCACATTTGCCTTTAACC TTCCACATAAGCATCTCCATCCCTACTATAAAGCCCCTGTCCGCAACCTCATCTCCAAGC GTCTGCAATCTCATCTCCAAGCGTAAGCTGCAATTCTTACAAAATATGGGAGAAGCTGAC AAGTGGCGATGACTCAGCGTGTGAATCAGCCAGACTATCTCAATCTTCGACCTAGCTTAA ACGCTTCTTTCGGTGAAAATGCCTCGAAGTAGTAATCTCAGGACGTCCAGGTGAGAACTA GTCGTGTACTTGCGTTTCCTAATTGAGGACCTGACTGAAAGGCCTATTATACCACTCTAG CTCGTTGGGCAACCCCCACCGTAGGACAAACGATGTCATCGAGGTAGCATCTATAGGACC AGAAGAGACCTTGGTGAGTGTCCGGAAGAGGATATGAACCGTGTAGCTGCAACAATGGGT TAACCTATGGTCATCGTAGCCCCAAATAGCTGTCGTGCGCTGCCGATGTGCATTATGTCC TAGAGGTGGACGCGCGATGCAGTATAGGACCTGGCTCAATCACCGCATAAGCTTGGAGTT CTCCGAGGCCGACAATCAGCCCTTATCCTCTTCGTCCGGGGAAGACGATGTCGCTGTCCC TACCCTTCCATCTGTATCCCTTTCCGATGATTCCGTCTCCGGTGACATCTCGATCCCTCG ATCCTCTCCCCCTGCTGGCCAGTTCATGTCTTCATCCGATGATGCTTACCCTCCTCCTCT TTCAGGTCAGGAGACTTCACAAAGCGGTCTTGAAAGAGAGTTTATGGATATCGATGATGG GCGAAGTTATGATGATCTTCCTGTCATCATGATGGATGAGTCCCTTCTTGAAACAGGCTT TGAGGGTGATGGATATGGAGGTGTCATCCGTGATCGTCTTAGCCATCAGCttCGCAGATG gccTACCGAAGTTCCCGAATCCTTGATCCCtccttACtCGTGTCGgcaacccAGccctTA TCaAGaCgaaaCCATcttccgcaccGAATCAattAcaaggAGTATGcctctActtcccac cGTCTtCTcaatcttcctcaccgctTTTGTAgg wise-2.4.1/test_data/jason.pep0000644000175000001440000000446507577355654015701 0ustar philippusers>BRR2 : PUTATIVE U5 SNRNP-SPECIFIC PROTEIN; DEAD/DEAH BOX RNA HELICASE; REQUIRED FOR PRE-MRNA SPLICING; SIMILAR TO S. CEREVISIAE BRR2: Q9UT24; MSSAHPKGDSKEPPKHGNSKEKPNYGQSQYSYSAMSNLVTQADRRFVSRRDAEPTGEPES LVNRVSIADMGSRARIEKPSTLPLELTQEVQEVRLPRKDAESLEIGIRQPEREKRSSAIL KYFDSFEILKYNPLTDETREVYDYILSFIQQYLGDQSPEILRSAADLIIELLKDSSLDEQ GRKKQIEEVLSTELPQDRFSQLVNLGNRLTDYTVEQEEELNEEGVNESGVPVLFNEADEE EEAVEAMEEDEVAEDEDVVLETSISQEEEKKNIENPDTEVTFISADTKKVTEIPTVHPRE IDAFWLQREIAKYFADAVVCQEKTNQAFEALSADYDLGELENELMSIFDYEHFYLVQLLT KNRWTIVSCTMLKRAATDEERLGVEEQIRAAGRSWILEALRPGAITIPDDGLNELNNNVV EKAEPAPVSEIPLSKTLTSHKIVPKHQVDLENYVFTEGSRLMSNKAVKLPEGSFRRTGKG YEEIHVPAPNKAVLGADERLVKIKELPEWSHQAFLNTQSLNRIQSHLYPIAFGTDENILL CAPTGAGKTNVAMLCILNELQKHLREDLSFNLQNFKIVYIAPLKALVQEMVNNFSKRLTP YNIRVAELTGDSQLTKQQISETQIIVTTPEKWDIITRKANDLSYVNLVRLVIIDEVHLLH DERGPVLESIVARIFRHQEETLEQVRLVGLSATLPNYTDVASFLHVDPKKGLFYFDSTYR PCPLKQEFIGITEKTPFKRMQTTNEACYEKVMQHAGKNQVLIFVHSRKETAKTARFIRDK ALEEETIGHLLRSDAASREILRAEADSTSDENLKDLLPYGFAIHHAGMRREDRQTSEDLF ADGTIQVLVSTATLAWGVNLPAHTVIIKGTQVYSPEKGIWTELSPQDVLQMLGRAGRPQF DTYGEGIIITAHSELQYYLSLMNQQLPIESQFMRRLADCLNAEVSLGTVRSIEDGVDWLG YTYLYVRMLRSPALYSVGPEYDDDKYLVQKRADLLHSAAILLEKCKLLVYNRQSGTLTAT ELGKVAASYYVTHNSMAIYNRLLMQTTSFIELFRVFSFSDEFKHIPVREEEKVELAKLLE RVPIPIRERLDEPAAKINALLQSYISRQRLDGFALVADMVYVTQSAGRIMRAIFEISLRR GWSSVATLSLDTCKMIEKRLWPTMSPLRQFPNCPSEVIRRVEKKEFPWQRYFDLDPAELG ELVGVPKEGRRVYNMVQSFPRLSVEAHVQPITRSLVRVELVINSQFNWDDHLSGTSEAFW ILVEDVDGDRLLHYEQFFLLKKYKDDEHIVNFTVPLLEPLPPCYFIKIVSDRWLHSITKV PLSFQRLIMPEKFPAPTPLLDLQNAPVSSLNNPSFISLYPNFKFFNKIQTQVFNSVYKTN DSVFIGAPNGSGKTVCAELALLHHWSQEDYGTAVYIAPIQEIVDRRYEEWYGKFSDLGDG KVLVKLTGERSQDLKLIQVADLIFCTPSQWDSLSKRWRSMRSIQKVDFYICDELQLLGGF YGPLYEIVISRIRYMAVQLEKNIRVVGLSVSVANARDLGEWLGTSPQCIFNFSPKDRPNP LTIHLQSFSITHFPSLMLAMSKPIYRSLKNFISQRKSTIVFTPDRKVAKQLAFDLVTFSM ADEDEYLFSLMENEAFNKVEDAALQQSLKHGIAYISEITSSNDQNIVQYLYRHGLIKVLI ASRDVIYSLKAKSNAVIVMGTQYYDGKEHRYIDYPISELLQMLGFTASIGSSELSQVILM TVTTKKEYYKKFLNEPLPMESHLQVWLHDAFVSEISTQTIESKQDAVDWLTWSYMYRRLV ANPAYYGLQDITHESVSEFLSDLVETTMNDLSEARLITVDDEDDSCVALNLAMIASHYGI TYITMQTFALSLSERTKMKGLLEIVTSAAEYEQLPIRKYEDIVLERIHSRLPVRLSNPNY EDPHTKSFILLAAHFSRFELPPGLVIDQKFILTRVHNLLGACVDTLSSEGHLIACIRPME MSQMVTQALWDRDSPLKQIPYFDDALIERCNKEGVHDVFDIIDLDDEKRTELLHMDNAHL AKCAEFINKYPDIDIDFEIEDSEDVHANSPSVLIVQLTRELEEDEEVDTTVIAPYFPAQK TEHWWLVISDDKTLLAIKKITLGRSLTTKMEFVPPAMGTLKYKLSCFSDSYMGVDYEKEF ECNVLEPLDTEMEDGE wise-2.4.1/test_data/keratin_intron.human0000644000175000001440000000147407313404503020106 0ustar philippusers>EM:HSKER101 [2995-3735] M24842 Human keratin 18 (K18) gene, complete cds. AGGTAAGGGGTAGGAGGGACCTCAACTCCCAGCCTTGTCTGACCCTCCAATTATACACTCC TTTGCCTCTTTCCGTCATTCCATAACCACCCCAACCCCTACTCCACCGGGAGGGGGTTGG GCATACCTGGATTTCCATCCGCGCACCTAGCCACAGGGTCCCTAAGAGCAGCAGCAGCTA GGCATGGGAGGGCTCTTTCCCAGGAGAGAGGGGGAAGGGGACAGGGTTGAGAGCTTTACA GAGGAAGTGGACAGCATGGAGGGAGGTAAGGAAAGGCCTGTAAAGAGGAGGAGACACTGG CTCTGGCGGAATGGGGACTATTGGAGGGTTAAGCGGATGTGGCTAAGGCTGAGTCATCTA GGAGTAAACAAGAGGCCTTCCTTTGGGAGGAGCCAATCCAGGGTGTAGGGGGCCCAGAGT GACCAGGTGCACTAGGGAAAAAATGCCAGGAGAGGGCCAGGAAGAGGACTTGTTAGTAGC GACTCACTTCTGGGCAGGCAGGCCAGCCAGCTAGCCAGCCTGCTGAGGCTTCCCAAGAGG GGCAGAGTGCTGGGATCTGGGAATCCAGGAAAGGAGGGAATGGGGTGGGGCTAGATGAAA AGGGATAGGTGTCCAGGGAGAGCCTCTGGCTATTCCTGGGACCAGGAAGTTTTCACTAGG ATACATAACACTTTTTACACACTCACCCCACCCATCCCTGGCTTTCTATTCATGGAACAA CCTCTCTCTACAATCCCTCCwise-2.4.1/test_data/keratin_intron.mouse0000644000175000001440000000157707313404503020132 0ustar philippusers>EM:MMENDOBA [2729-3525] M22832 Mus musculus cytokeratin (endoB) gene, complete cds. ACCTGAGGGCTCAGGTAAGGGGCCTAAGGGGGGAGGGGCAGTAGCTCCGGGCTGTTCTGTC TATCCAGTGTGCCCACACCCCCAAACTTCAATAGAGTGTGGGCTGTTGACTCCCTCCACT CTTTCCACATTCACCACATCCCCCCACACACACTCTATGGGACGGAGTTAGGAATACTCT GGACTCTCACCCACAACCTGTAGGAATTCCAAGCGTAGTGGTTACACACGCGAGCCGGCT TCCCCCAAGCAGTGTAGTGGGAAGAGAACAGGATTGGAAAAAAAATAAAATAAAAAGGTG TGTGTGGGGGAATCATAAAATGAACTCAGACACTCACTTCTTTTCCAGTAGGAACAGTTA GAGGGTTAAGCGGATGTGGCTAAGGGTGAGTCATCTAGGAGTAAACAGGAGCTTACCTGT AGGAGGGGCCAGCGGGACAAGTGGGGGGGGGGCGCGTCCCAGGACGGGGGGGGGGGGGGG GGGGGTTAGCAGGTGCACCTGGAGAAGATGCCAGGAGAGGATCAGAGAAATCTTGTTGGA AGCTGCTCTTTTGTAAGCAATCCAGATAGTGCAGGCCCTGGCAGAGGGGCAAGGAATCCA GGAAGGGAGAGGAGGCTCAGGTGGGAAGGGAAGACAGAAATACACGCCTCTGACTGTTCC TGGGACTGGGATGGATTCACTGAAACACAAGACGTGTTTTCTCATCCCCCACTTCTCCAC ACACACACACACACACACACACACACACACACCCTCATGTGACCCGGAACTCTCAAAGCG ACTCTCTCCACTTTAAwise-2.4.1/test_data/epo.genomic0000644000175000001440000000612707557456631016177 0ustar philippusers>static0 GCCTCAACCCAGGCGTCCTGCCCCTGCTCTGACCCCGGGTGGCCCCTACCCCTGGCGACC CCTCACGCACACAGCCTCTCCCCCACCCCCACCCGCGCACGCACACATGCAGATAACAGC CCCGACCCCCGGCCAGAGCCGCAGAGTCCCTGGGCCACCCCGGCCGCTCGCTGCGCTGCG CCGCACCGCGCTGTCCTCCCGGAGCCGGACCGGGGCCACCGCGCCCGCTCTGCTCCGACA CCGCGCCCCCTGGACAGCCGCCCTCTCCTCCAGGCCCGTGGGGCTGGCCCTGCACCGCCG AGCTTCCCGGGATGAGGGCCCCCGGTGTGGTCACCCGGCGCGCCCCAGGTCGCTGAGGGA CCCCGGCCAGGCGCGGAGATGGGGGTGCACGGTGAGTACTCGCGGGCTGGGCGCTCCCGC CCGCCCGGGTCCCTGTTTGAGCGGGGATTTAGCGCCCCGGCTATTGGCCAGGAGGTGGCT GGGTTCAAGGACCGGCGACTTGTCAAGGACCCCGGAAGGGGGAGGGGGGTGGGGCAGCCT CCACGTGCCAGCGGGGACTTGGGGGAGTCCTTGGGGATGGCAAAAACCTGACCTGTGAAG GGGACACAGTTTGGGGGTTGAGGGGAAGAAGGTTTGGGGGTTCTGCTGTGCCAGTGGAGA GGAAGCTGATAAGCTGATAACCTGGGCGCTGGAGCCACCACTTATCTGCCAGAGGGGAAG CCTCTGTCACACCAGGATTGAAGTTTGGCCGGAGAAGTGGATGCTGGTAGCTGGGGGTGG GGTGTGCACACGGCAGCAGGATTGAATGAAGGCCAGGGAGGCAGCACCTGAGTGCTTGCA TGGTTGGGGACAGGAAGGACGAGCTGGGGCAGAGACGTGGGGATGAAGGAAGCTGTCCTT CCACAGCCACCCTTCTCCCTCCCCGCCTGACTCTCAGCCTGGCTATCTGTTCTAGAATGT CCTGCCTGGCTGTGGCTTCTCCTGTCCCTGCTGTCGCTCCCTCTGGGCCTCCCAGTCCTG GGCGCCCCACCACGCCTCATCTGTGACAGCCGAGTCCTGGAGAGGTACCTCTTGGAGGCC AAGGAGGCCGAGAATATCACGGTGAGACCCCTTCCCCAGCACATTCCACAGAACTCACGC TCAGGGCTTCAGGGAACTCCTCCCAGATCCAGGAACCTGGCACTTGGTTTGGGGTGGAGT TGGGAAGCTAGACACTGCCCCCCTACATAAGAATAAGTCTGGTGGCCCCAAACCATACCT GGAAACTAGGCAAGGAGCAAAGCCAGCAGATCCTACGGCCTGTGGGCCAGGGCCAGAGCC TTCAGGGACCCTTGACTCCCCGGGCTGTGTGCATTTCAGACGGGCTGTGCTGAACACTGC AGCTTGAATGAGAATATCACTGTCCCAGACACCAAAGTTAATTTCTATGCCTGGAAGAGG ATGGAGGTGAGTTCCTTTTTTTTTTTTTTTCCTTTCTTTTGGAGAATCTCATTTGCGAGC CTGATTTTGGATGAAAGGGAGAATGATCGAGGGAAAGGTAAAATGGAGCAGCAGAGATGA GGCTGCCTGGGCGCAGAGGCTCACGTCTATAATCCCAGGCTGAGATGGCCGAGATGGGAG AATTGCTTGAGCCCTGGAGTTTCAGACCAACCTAGGCAGCATAGTGAGATCCCCCATCTC TACAAACATTTAAAAAAATTAGTCAGGTGAGGTGGTGCATGGTGGTAGTCCCAGATATTT GGAAGGCTGAGGCGGGAGGATCGCTTGAGCCCAGGAATTTGAGGCTGCAGTGAGCTGTGA TCACACCACTGCACTCCAGCCTCAGTGACAGAGTGAGGCCCTGTCTCAAAAAAGAAAAGA AAAAAGAAAAATAATGAGGGCTGTATGGAATACATTCATTATTCATTCACTCACTCACTC ACTCACTCATTCATTCATTCATTCATTCAACAAGTCTTATTGCATACCTTCTGTTTGCTC AGCTTGGTGCTTGGGGCTGCTGAGGGGCAGGAGGGAGAGGGTGACATGGGTCAGCTGACT CCCAGAGTCCACTCCCTGTAGGTCGGGCAGCAGGCCGTAGAAGTCTGGCAGGGCCTGGCC CTGCTGTCGGAAGCTGTCCTGCGGGGCCAGGCCCTGTTGGTCAACTCTTCCCAGCCGTGG GAGCCCCTGCAGCTGCATGTGGATAAAGCCGTCAGTGGCCTTCGCAGCCTCACCACTCTG CTTCGGGCTCTGGGAGCCCAGGTGAGTAGGAGCGGACACTTCTGCTTGCCCTTTCTGTAA GAAGGGGAGAAGGGTCTTGCTAAGGAGTACAGGAACTGTCCGTATTCCTTCCCTTTCTGT GGCACTGCAGCGACCTCCTGTTTTCTCCTTGGCAGAAGGAAGCCATCTCCCCTCCAGATG CGGCCTCAGCTGCTCCACTCCGAACAATCACTGCTGACACTTTCCGCAAACTCTTCCGAG TCTACTCCAATTTCCTCCGGGGAAAGCTGAAGCTGTACACAGGGGAGGCCTGCAGGACAG GGGACAGATGACCAGGTGTGTCCACCTGGGCATATCCACCACCTCCCTCACCAACATTGC TTGTGCCACACCCTCCCCCGCCACTCCTGAACCCCGTCGAGGGGCTCTCAGCTCAGCGCC AGCCTGTCCCATGGACACTCCAGTGCCAGCAATGACATCTCAGGGGCCAGAGGAACTGTC CAGAGAGCAACTCTGAGATCTAAGGATGTCACAGGGCCAACTTGAGGGCCCAGAGCAGGA AGCATTCAGAGAGCAGCTTTAAACTCAGGGACAGAGCCATGCTGGGAAGACGCCTGAGCT CACTCGGCACCCTGCAAAATTTGATGCCAGGACACGCTTTGGAGGCGATTTACCTGTTTT CGCACCTACCATCAGGGACAGGATGACCTGGATAACTTAGGTGGCAAGCTGTGACTTCTC CAGGTCTCACGGGCATGGGCACTCCCTTGGTGGCAAGAGCCCCCTTGACACCGGGGTGGT GGGAACCATGAAGACAGGATGGGGGCTGGCCTCTGGCTCTCATGGGGTCCAAGTTTTGTG TATTCTTCAACCTCATTGACAAGAACTGAAACCACCAA wise-2.4.1/test_data/alignwise.gen0000644000175000001440000112363307616001600016503 0ustar philippusers>Homo sapiens TGTGTTGCATATGTGCCAAAAATGGGTGGTAAGAGTGGCTGAGGTATTGACTCCTTTCAT GGTTGAGCAAGTCAGACTCCTTGGACCTGGCTCCTCTCCCCTCAAGCAGTGGCCTCGGTT TGTGTCAGTGGGCTAAACAGATGAAGAGGGGAATTAAGTCCGGGCTCGATGGCTCATGCC TGTAATCCTAGCACTTTGGGAGGCCGAGGCAGGTGGATCACTTGAGGTCAGAAGTTCAAG ACCAACCTGGAAACCCTGTTGCTACTAAAAATACAAAAACTTAGCTGGGCCTGGTGGCAG GCGCCTGTAATCTCAGCTACTGGGGAGGCTGAGGCAGGAGAATCACTTGAACCCAGGAGG TGGAGGTTGCAGTGAACCAAGATTGTGCCACTGCACTCCAGCCTGGCCGATAGAGTGAGA CTCCATCTCAAAAAAAGAAAAAGGAGAATTAAAAATATGAATAAGGGGCTGGGCGTGGTG GCTCACGCCTGTAATCCCAGCACTTTGGGAAACAGAGACATGGATCACTTGAGGCCAGGA GTTCAAGACCAACCTGTCCAACATCGTGAAACTCCGTCTCTACTAAAAATACAAAAATTA GCTGGGTGTGGTGTTGCATGCCTGTAGTACCAGCTACTTGGGAGGCTAAGGCAGGAGAAT CACTTGAACCTGGGAGGTGTAGGCTACAGTGAACTGAGATCACACCACTGCCCTCCAGCC TGGGTGACAGAGTAAGACTCTGCATCAAAAAAAAAAAAAAAATAATAATAATAATAATAA CCAAATAGAATATCTAGAAATGAAAAGGTAATTTACATTGAGAACTTGCTGTAAGAGTTA AATAGGGGTTAGACATAGCTGAAGAAAGAATTGACAAACTGAAAGAGCTGAGGAAATTAC CCAGAACGTACCACAAAGAACAAAGCAGATGAAAAATATAAAAGATATTTAGAGATACAG AGGACAGAGTCCTTGGTTTCTCCTGAAATGTATCTAGGATTGAAATTTCTGGGTAGAAAA TTAAAATTGTAGTGAATGCAGATGTTCAGCTTTAAAAAAGAAAAAAAAGACAACAGGGGT CCAGGATATATCTAAACATCAAAAAGGGAGAATAGAGAGTTGGAGAGATTTCCTTCTGCT CACTCTTATTCCACATTTTTTTCTCTACTGGTTTGAAAGATATTATTTTAAAAAATCAGG CCAGGAGCATTTGAAAGATATTATTTTAAAAAATCAGGCCAGGAGCAGTGGCTTACGCCT GTAATCCCATCACTTTGGGAGGCCGACGCAGGTGTTCACTTGAGGTCAGGAGTTCGAGAC CAGCCTGGCCAACATGTTGAAACCCCGTATCTACTAAAAATACAAAAATTAGCGGGGCAT GGTGGCATGTACCTGTAGTCCCAGCTACTTTGGAGGCTGAGGCAGGAGAGTCGCTTGAAC TTGGGAGGTGGAGGTTGCTGTGACCTGAGATCGCACCGCTGCACTCCAGCTTGGGCAACA GAGTGAGACTTTGTCTCAAAAAAAGTAATAAATAAATAAACACATCATGGAAAATTGGGT GTCCATTTCCTCAAGCATTTGTCCTTATTTTTTTTGGAGACGGAGTCTCACTCTGTCTCC CATACTGGAATGCCGTGGCACAATCTCGGCTCACTGCAACCTCCGCCTCCTGGGTTCAAG CAATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGATTACAGACATGGGCCACCACGCATG GCTAATTTTTGAATTTTTAGTTGAGATGGGGTTTCACCATATTGGCCAGGCTGGCCTAAA ACTCCTGACTTCAAGTGATCCACCCGCCTCAGCCTCGCAAAGTGCTGGGATTACAGGCGT CTTATATTTCAATTAAGTTTGCTTTAAAATAATACAATATAATATAAATATAGTATATCA TGATCAATTTAGGCTTACTTTAGGAATGCAAGGATGCATTGATATTAGAAAATCTATAAA TATCATCTACCATATTGCATGTTAAAAAGAAAATCCTTATAATGTTGGTAGCTGCAAGAG TTTGATAAAATTCCACATTAATTCATGGTAATAAGAAAATGAGGAACAGAAAGGAGTATC TTTAAACTCACAGTGTGGCACAGACAAAGTTCACCAAATATTCCACAGGCTCCCCAGAAT TTCCCATTCTCTTTTACAGTTAGATTGGGGCCAATGACTAGTTCTGTCCTGTAGACTATG AACTAGAGTGACGTGTCACTTTTAGATGAAGGCAGTTGAGCCAATGTTCCTCCTCCGTCC CTCTCTTCTCTTGCTCCAGTGACCTTGGAGGCTGTGTATTGCAGATGGCATAGATTAAAG ATGGAGTAAGGATGCTTCACTCTCATCAGACTTTGTGTAAGCAAGAACTAAATCCTTACA GTGTTAAGCCTCTTAAGATTTCAGAGTGTATGTGTTACTACAGTATAGCCTGTCTTACTC TAACTAATATAAAGGGCATCTACCAAAAAACTACAGCAACTCTCCTATTCAGTGGTGAGA AGTTAGCATCATTTTCTGTAAAATCAGCAATAAGAACAAGGATGACTGCTATTTCTTCTT GTATTTAGCAGTGCAGTAAAACAAGTAAGGATTGGAATGGAAGAAACAACAGTAATAATT TGCAGATAAATTATTTACATGTTGGCTGGGCACAGTGGCTCACACCTGTAATCCCAGCAC TTTTGGGAGGCCGAAGCAGACAGATCACTTGAGGTCAGGAGTTCGAGACAAGCCTAGCCA ACATGGTAAAACCCTGTTTCCACTAAAAATACAAAAAAAATTAGCCGGGCATGGTGGTGC GTGCCTGTAATCCCAGTTATTTGGGAGGCTGAGGCAGGAGAATTGCTTGAACCTGGGAGG CAGGGGTTGCAGTGAGCCAAGATTGCACCACTGCACTACAGCCTGGGTGACAGAGCAAGA CTCTGTCTAAAAAAGAAAAAATTATTTACATGTAAACTTTCTATGTATAAATAAATAAGT TGCTTATAAGAAGTGTATATTTAAAATCAGTTGCATTCCTGTCTGCCAGCAACAAAAAGT TAGAAAACGTAATTTTTAAAAAGGTGCCATTCACAATTTCATTAAAAAGTATTAACATAT GGTACCTAGGAATAAATTTAGCAAAAGAAGTATAAAATTTTTATAGAGAAAATTACTAAA GCTTATTGATAGACCTTAAAGAAGATCTTAATACTTGGAGAGTAATGAAAACTCAGTAAT ATATTACTTCTCCCCAAGTTGATCTCTAAGAGTGAAAAAAATTTTGGTCAAAATCCCGGG AGGGTTTTTAAGGAATTCCTCAGGCTGATTCCTAAGTATGTGTAGAAGAGGAAAGAGCCA AGGATAGCAAAACCTCTTAAAGGAGAAGAATAAAGTGGAGACATTGACCTAGCAGATATC AAGATTTGTGAAGTTTTAGTAATTAAGACAAAGTGGTATTGGCCAGGGACAGACAAATTG TCTAACAGAACAGTAATGAGTCTCCAGAAATAGACCCACTCGTTAATGAAAATTGGACAC GTGACATAGGAGCTTTCATATTAATGTAAAAAGGATGATCTTTCCAGTAAATGGTGCTAG GGCAATTGTTCAATCGGGGATAAATGATATGTACTTAACCAGTTTTTATAATAAGACTTC AGTTGAGTTTTTTATTTTCTTAATTAAATTTTTTATTTTTATTTTTTATTTTTTTGAGAT GGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCAGTCTTGGCTCACTGCGAGC TCTGCCTCCCGGGTTCAGGCCATTCTCCCGCCTCGGCCTCCTGAGTAGCTGGGCCTACAG GTGCCCACCACCATGCCCGGCTAATTTTTTGTATTTTTTAGTAGAGACGGGTTTCACCAT GTTAGCCAGGATGGTCTCGATTTCCTGACCTTGTGATCCGCCCACCTCGGCCTCCCAAAG TGCTGGGATTACAGGTGTGAGCCATCGTGCCTGGCCTATTTTCTCAATTAAATTTTTAAA AATGTTTATTTAATTTTTTTTAGAGCCAGAGTCTTGCTATGCTGCCCAGGCTGGGATACA GTGGTTATTCACAGGCACAGTAATAGTGCATACAGCCTCAAACTTCTGGGCTAAAGTGAT CCTCCAGCTTCAGCCTCCTAGGTAGCTCGGACCATAGGCGCATGCCAATATACCTGGCCT GGTTGAATTTTATGTCATTTTAAAATACTATATATAGGTAACCTACTTTAATGATATACT TTTATTTATTTATTTATTTGAGACGGAGTTTCGCTCTTGTTGCCCAGGCTGGAGTGCAAT GGTGCGATCTCGGCTTACCGCAACCTCTGTGTCCTGAGTTCAAGTGATTCTGCTGCATCA GCCTGCCGAGTAGCTGGGATTACAGGCATGTGCCACCACGCCTGACTAATTTTATATTTT TAGTAGAGATGGGGTTTCTCCATGTTGGTCAGGCTGATCTCGAACTCCTGACCTCAGGTG ATCCACCTGCCTTGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACTGCACTCGGC CAATGATATACTTTTAAAAAGTAAGCCCAAGAAAATGACAACTTAGGAAAAATATTTCCA ACATGTATAAGAGACAAATTGTTTAGATCCTAATTTATGAAGAACTCTTAAAAATTAATA AGAAAAAAGATGGACCATTATCATTTTCCTTTCCTGATTAACTGATATTTTAAAACATTT TCTCACCCAGCAGCTACAGTGACATTGTGCGGATTTATAAAAGGTAAAAGGCTTGTTTGT CTTTTGTACTTTAAGCATGTCCCAGGTGGATGTGGATTCAGGAATTGAAAACATGGAGGT TGATGAAAATGATCGAAGAGAAAAGCGGAGCCTCAGTGATAAGGTTGGTAAGCGATGAAG CCCTTGGTACAGGTAATAGAAATAAACACATTTCATGTCTTGTATCTGTAGAGTCTGTTA GATTGGGGCCACCCGAAATCAGGAAGTCCTAGGCAGGTGATTATTTTTATTCTTTTGAGG AAAAATGAATAACCTAGATTACCCTTATTCATGAAAGTGTAACTCAGTCCTTTGATCTGA TAATATCCATCTGTTTTTGGTTCAGGGCCATGATTTTATCAGTAAATTTAGGTTGTAATA GGAACTAATTTAGAGCAAATTAGAATTCTTTCTGTTGGTCTTTTGCTTTTTTTTTTTTTT TTTTTTTTTTTTTTGAGACAGAGTCTCGCTCTGTCGCCCAGGCTGGAGTGCAGTGGTGCG ATCTCGGCTCACTGCAAGCTCCGCCTCCCAGGTTCACACCATTCTCCTGCCTCAGCTTCC CAAGTAGCTGGGACTACAGGCGCCCGCCACCACGCCCAGCTAATTTTTTGTATTTTTAGT AGAGATGGGTTTTCACCGTGTTAGCCAGGATGGTCTTGATCTATTGACCTTATGATCCAC CTGCCTTGGCTTCCCAAAGTGTGGGATTACAGGCGTGAGCCACTGCGCCTGGCCTGGTCT TTTGCTTTTAAGCAAGTAGATCATCACATCTTTAGCAGTATTCTGAGGAAAATGACTGGG AATTGAAGCAAGAATATGTAGAATCTAGTCGCAAGTAGAAGGTTTTGGAAAACATGAAGC CTTTATATTTGAATATCACCTGAGCTTAGTGCTCTGCATTTAGGGTGTGTGTGTGTGTGT GTGTGTGTGTATTAATATAGATAATTACATCACTTTCTGTTTAGTAAATTATTAGGAATC CTTTAGCAACACATGTTAATGATTATTGGAAGTTGCACTGTAAACAAAAATAAAGACAAA CAAAGGAAAAAATAAGAAGTTGCACTGTAGCCTCCTAGTGGTGCAGTGCTTTATTTTGTA TAGTTCTTTAATGTTTACAAAATTCTTTTTTATATGCTGTTTTATCTGTGGTGGTATGTA ATGAGAAATGTTACAATTTTGAAAAATTCCTGGAGGAAAATTGGTCATGCACCTGGAGTG TTAACCTGGTCCTATGGAATTCAGAAAAGTAAATAGATAGGATATGTACATCCTCTGTCA CATATTTTTCCTTGGTGACTTTTGATAATGACTTTGCTCTTTTTTTTTTTTTTTTTTTTT TTTTTTTTTTTTTTTTGAGACAGGGCCTCACTCTGTTGCCCAGGCTGGAGTGCAATGGCG TGATCTTGGTTCACCACAACCTCCGCCTCCTGGGTTCAAGCGATTCTCCTGCCTCAGCCT CCCAAGTAGCTCCGAGTAGCCAGGCCCGCAACCGCGCCTGGCTAATTTTTGTATTTTTAG TAGAGACAGGGTTTCACCATGTTGGCCAGGCTGGTCTTGAGCTCCTGACCTCAGGTGATC CACTGGCCTCGGCCTTCCAGAATGCTGGGATTACAGGTGTGAGCCACCACGCCCGGCCAT CTTTGCTCTTTTATGCTCCCCATAGATTGTATTGTAAGCTCATGAGACTTAGATGTTGTA ACTTTGATGTTATAGGAATAGGCTTACTTTTCCCCTAATCAGTGGGTGAATGGTTTCATG CATTTTTAAAATATCATCACTAATAATGAATTAAATCAGAATAACGTATTCCTATTGAAA CACCTAACTCATACCTCTTATTTGAAATTAACCTGCAAATCTTCTTCTTCACCAGGAGCC TTCCTCGGGCCCTGAAGTGTCTGAAGAGCAGGCCTTACAGCTGGTCTGTAAGATCTTCCG TGTCTCTTGGAAGGACCGGGACAGAGATGTCATCTTTCTTTCTTCTCTTTCTGCACAGTT TAAGCAGAACCCAAAAGAAGGTAGGAATCTAGCTCAGCAGTCTTACTGCAGAGTACTCGA CAAGAAAATAAGATGTGAGATCTTTGCCCTCTGTTATCCACATTCACTCCATCTTGCTCT TGGGTTGTATTTTTGATGACAGGGATACTTCTTGATGAGGACACAATTGTTTAGCCACTT TCTTCCCTTTCCACTGATCTTATCGATAACTTATTTTTCATTTCCATGATTTCTATAATA CTATGTAAATAGGTTAATGGTCTCCATTTTCTCAGGGTTGAAGTTTTTCTCTTTGTAGTA AGAAGGTGCTTAGAGCATTACCTCCTCTTTATTTATTTATTTATTTATTTATTTATTTAT TTATTTATTTATTTATTTTGAGATGGAATCTCACCCTATCACCAGGCTGGAGTGCAGTGG CATGATCTCAGCTGACTGCAACTTCTGCCTCCCGAGTTCAAGTGATTCTTCTGCCTCGGC CACTGGAGTAGCTGGGACTACAGGCGTGCACCACCACGCCCAGCTAATTTTTGTAGTTTT TTTTGTTTGTTTTGTTTTTGTTTTTTTTTTTTTTTTTGAGACAGAGTCTTGCTCTGGCAC CAGGCTGGAGTGCAGTGGCGCAGTCTTGGCTCACTGCAACTCCCACCTCCTGGGTTCAAG CAATTCTCCAGCCTCAGCCTCCCGAGTTGGGATTACAGGCATGCGCCACCACACCCAGCT AATTCTTGTATTTTTAGTAGAGACAGGGTTTCACCATGTTGGCCAGGACGGTCTCGATCT CCTGATCTCGTGATCCGCCCGCCTTGGCCTCCCAAAGTGCTGGGATTACAGGCATGAGCC ACCGTGCCTGGCCTCATTTTTGTAGTTTTAGTAGAGACAGGATTTCACCATGTTGGCCAG GATGGTCTCGATCTCTTGACCTCGTGATCTGCCTGCCTCGGCCTCCCAAAGTGCTGGGAT TACAGGCTTGAGCCACCGAGCCTGGCCTTACCTCCTCTTATGAAGTATAGATATAGTGGG TGGTCTCCAGGGATCCTGAGAGAAGTGTTCTGTATGAGCTATACCTGCTTTAAGTGCCTA TGAAGCCATGTATAGACGGTGGAATTGGTCTATTTGGTTAAATTGCTTAGCAAGATAGAA CATAATGACATTTTGCTGTGTTTCTGATATTCCACTTTAAGAGGCCAAGCTTGTAACAAA ATAATAAAACTCTTAGCAAGATATCAGCATCATAGGGCACTATCCTTTTTCTTTACAGTA GTCATTTGGAACGCAGAAGAGGTATGGGAGGTGTGCTGGAGTGGTTTTTTTGGCCTATCA CTGGAATGTAACTTCCCTCATGGTAGGGATTTTTGTCTGTTTTACTCATTGATGTATCCC TAGAAGGATATCTTGCACAAAATAGTCCCTCAATAGATAGATTTTAAATGGATGCGTGAA TATCAAGGAGATCACCTTTCTCTTTTCTATGCTGCCTATCTTCTGAGGAGGGAAAAAAAA AGTCCTTTGTATTTCTGGAGGATAGATAAGACTATTTCTGATTTTACTTATTAACTCTGC TAATGGAGCAGACCATGTATTTGAAACTCTGCTACTTGTTATTCTTATTATAAATCTTAA GATTCTCTGTCTTACACATGTAAGTGGCAAATCTGTCTTACACATGTAAGTGGCAATTTT AAATAACCAAATCAGATAAAATTTCCATGAGTTAAAACTTTTGTTAAAACAAGTGTCTTA CACATGTTAAGTGGCAACTCTGTCTTACACATGTAAGTGGCAATTTTAAATAACCAAATC AGATAAAATTTCCATGAGTTAAAACTTTTGTTTAGTGGTATTTAAAATGTATCTAAAGAC CAACAGTAAATCAACTGGGAGCTGCAAAGAATAAGAAGGAAGCTAGAATGTAGCATTTGC TCCTGAAAGCCACATGGTGACTAGATGTTGGACCCTTCATAAAATCTTTTGAACCTTGGA CTTAATAGTTTTATTACTATCTATAAAACATATCTAGACTAAGAAATATTAACCCAGTTG CATTTGTAGTATAATAAAGTAACCTCTATAGTTGGGAGTAGCTTCTTTTTACAATTAATA TACATCAGCGGTAACTCTCAATGACTGTACCCCAACTTTCTTTTTAATAAACTTTTAATT TTGGAATAGTTTCAGTTAGTGCAGGGAGTTCCTATATATACTTTACCCAGTTTCCCCTGA CGTTAATATCTTATATAACCATGGTACATTTGTCAAAACTAAGAAATTACTACTAACTAA ACACAAGGCTTTATTTAGGTTTTCCACTAATATCCTTTTACCATTCCAGAATCTAATCCA GGATACTGCATCGAACCATTTGGGGTCAGCTGGCTTATTCAAGGGCTGTGTAACCTGTGT TCGAACTGTGTGTAACCTGTTCTTTGTTCTGCCTTTCCAACAGTATTCTCCGATTTTAAG GACTTGATTGGCCAGATTTTAATGGAAGTGCTAATGATGTCCACTCAGACCAGAGATGAA AACCCATTTGCCAGTCTGACAGCCACATCACAGCCAATTGCTGCAGCAGCACGGTCACCA GACAGAAATCTCTTGCTAAACACTGGCTCCAATCCAGGAACAAGCCCCATGTTCTGCAGC GTGGCTTCCTTTGGTGCCAGCTCTTTGTCTAGGTCAGTGTGGTTCTCTTTGCACATCTTA CTGGTAGTAAAATAACTGTGAACTACGTAGGAGAAGGGAATGTTTGTTGACAGTGTTAAT CAGTGTCATACAGGGTATGGCATATATCATATTTGGGGAGGTGGATTTAGTCATTGGAAG TGGAATTCTCTTTTCTAGATTATTATTTTTTGGCTCTCTATGGTTAAGATATTGCTAGAT GAAATTTTAGAAGCAGTTGGCTGTGTATACTACATCATTCTTCGAATGGGGACTTTATCG TCTTGTAAGTATAGCCTCTAGATCAATAGGGCAATTAGATTATAATTATTTAGATGTTTA TCTGCTAGATATACTTGAACTGAAATGATTCTCCTTTAAAAGCTTGATATTTTCTGTTTT AGTTAGTTATCTCAAGTTTTTCTTTGATTTTTCTCTTCTTTCCTCCCTTTCTCAACTAAT TTAGCCTCTATGAAAGTAGTCCGGCTCCCACTCCCAGTTTCTGGAGCTCTGTTCCCGTGA TGGGCCCGTCTCTTGCCTCACCTTCCCGTGCAGCCAGCCAGTTGGCTGTGCCTTCCACTC CCCTCAGTCCTCACAGTGCAGCCTCTGGAACTGCTGCGGGAAGCCAGCCTTCATCCCCGC GGTATCGCCCCTACACTGTCACTCACCCATGGGCGTCCTCAGGCGTCTCCATTCTGTCGA GCTCCCCAAGTCCCCCTGCCCTCGCCAGTAGCCCCCAAGCAGTGCCCGCCAGCAGTTCCA GACAGAGGCCCAGCAGCACGGGTCCACCCCTACCACCCGCCTCACCCAGTGCCACGAGCA GACGCCCCTCCTCCCTGAGGATCTCTCCTAGGTATTTATCCCACAGGAGAGTTGCATGTG TGTTTGCGGTGCAGGGAAAGGAGATTAACACGGTTTGGAAGAAGTGCTGTGTGACACTGA CTCTGTTAAATTGTTGTTTTGGGTTATTAACCTGTGTGGCTAACTAGTTTGGTAGGCACG TACTCTGAGTCCATGCTTCTGCCAGGCTCTAATCATGCTGGAAAGTTTGGGTTGCTCTAT TCTATTGTGAATCCCTTTCTTCCCTTTGAGAGTTGGGGCACACAGGAACCCTTTTTGGCC TTTTGTCCTGTTGCCAGTGGTAGTTGAAATGCTATCAGACCAAGCAGGTGTGGGAGCAAA TCTGGGCCTGGTGTTTTTTACTTCTGGTGAGTGGGGTGGGTCGGTTCATGTCCTGACGTG TTGAGTTTTAGTTATATGTAAGTTCAGTCTCTTAGAAGGAAGCAGTATCAGAATTCCACT AATCCAGTGGCCCCTTCTCTCAAATGTACCTGTATGTGTTTCTATAATTTAGGTGAATTA TGTTTCTGCATGTCAGTGGCCAAAAGTTTTAGTGTATGGTTTATTTAAAAGGACAGCAGT TGCAAAAGCTTCTCCCCGTCTTGTTTTTTCTTTGTTCTCTGATGGCCTTTTTTGCTTTTG TTGTGGTAGTATGTACGACAATCCTTTCTCCTTCCTCTTCCTCGCACTTTCTGGGGACAG TAGTGATGAAGAAGATGAAGAAGAAGATGATGATGATGGTGATGGTGATGATGAAGGTGG TGGTGGTGGTGATGATTTTTCTTGTGTCCAGTTTGGGTCCAGGTATCAGAGGAATGGAGT CTTACCCCTGCATGTGCGTAGATGCTTAGGAACTAACTTCTATAAGCTCTAACAAGGGGC GTGCTTTGAATCCAGGCAGGATAGGGTCAAATGAGGTGGGCTCCAGAGTATATTGATGTG TTCAGACCTTCTCATGGGATAAAGTAGCACATAGGAGAATTTTCTTTTTTTCTTTCTTTC TTTCTTTTTTTTTTTTTTTTTTGAGGCAGAGTTCTGCTCTTGTTGCCCAGGCCGGAGTGC AATGGCGCAATCTCGGCTCACGGCAACTTCCTCCTCCTGGGTTCAAGTGATTCTCCTGCC TCAGACTCCCAAGTAGCTGGGATTACAGGCACCCGCCACCATGCCCGGCTAATTTTTGTA TTTTTAGTAGAGACAGGGTTTTGCCAGGTTGGCCAGGCTGGTCTCGAACTCCTGACCTCA AGTGATCTGCCCGTCTTGGCCTCCCAAAATGTTGGGATTACAGGAGTGAGTCACTGTGTC TGGCCCCAGAATTTTCAGAGTTGTCGCCTGGCAAGTTTGGAGGAAAACTTTATGTATAAT CATTTTTCAAAAGCATGAAAACAGATTAAAGATCAGTCATCAAGTTTATCCACCTTTAGA TCTAAAATGAGGGACCCTTCATTTATCTATTGCGAGAATGTTATTGTGAACTACCAGATG TGACAACTTGTACTCTCTGAGGCATGTTTTCTTAAGTACAGTTGCATGAATTGCTGCTAT TTAGTAACGGGAGAGGGGCTGGGATTTGGGGGAGGTGTGTGTGTGTGTGTGTGTGCGTGC GTGCTCCCTTCCCACCCCCTCCCAGCCTCCACCGCCCCCCTGTTCACCCCCATTGAGCTC AGTCTGGGCAATCCATCGAAGAACATATGAGGTCATACCATCTGCATAACTGTGACTTTG CTTTCATGTCTAGCCTTAAATTTCTCTTAGCACCTCCTGGACCTCAGTGAAGCCAGACCC CATTTGTTTAAAGAGCCTTTGAAATGACCGCAGAGGCTGAAACATAGTTCCGGATGTTGC TGAATGTTTACCCCTGGAAACCGAGTGAAAAGCACTACTTGGGTTGTGTAGGTGACTTTG AGCAAGAGAATATAATAGCACCTTCTTTCTAATCCTCTGACTCATTGTCTTACAATTTTG CTCTTAAATTGAAGTTTCCTGTGGACTGAGTTGGTGTTTGTGCCCAGCACTGTTCAAAAA TAACTCCAGGCTATAAATAGAGACTGCAGTAGGAGTTAGGTACACTTCATTCAATTCGAT GGTGTTCAGAAGAATCATTAGAGAATACGTAAAGAGACAGAGGAATGTTGATGCAAGGTT GAATATTGATTCAGGAAGGTTGATATTTGTATTACGCTGAACATTTTATCACCATTTCTC AAGTAAATTTCCCAAAGGTGAAAGTGTCTTTTTCACGTAGATAAAATCCTATTGCATGAT TATAGTAATAAAGCAGGCATCCTTCCTAGGAACCAGTTTCCACATGGTAAAAGTGCTGTG TTACCTGTTTTACTGTAAATTTTCTGTGGGAGAAATTCTCTCTCCCTGGCCTATTTAGTT GTGACTTTCTCTAACAACCGTATCAGATTGTGTGCTGCTTTTACTAATACCTCTCTTTCT GGACTTCTAACACCCCAGCCTTGCCTCAGATCTAAATTCTCTCCCTACTAGGAGGAATAA AATGTACCAAGTGTATAAAAATAGCTGCAAATACTCATGGAGCATTGTGCGCCAGATGTG GTGTCAGCTCTGTCCATGTATCAGCCCCTTTACTCCTCGCTGTAGCCTGCTGTGAGGAAG TGGCAGGGGGAACGGGGGGGCCGGGGGGACAGACAAGAGGGTCAAAATCATAGAAATGCA TTCAGACTTGAGCATCCTGAATCCAGACTCATGTTCACCACCGCACCGTGCTGCCACCCA CTTTTCCATTTCTGCCCAAATAGGTCTTGTTTGTTCTTGTTCCTTACTACTGTTTTTGCT GCCGAGAGTCTGTGCATCTACTCGGTTCCTTTGGCAGGGAAGTGCCAGCATTTCACTCCT TAATTACAAAATGCCATCCCAGTCAGTTGATATGTCCCTTGTTGGCCGTTACAGTGAACT GTGATCATCCAGATTTTGGCAGCTTATAGGTTCTTAGTTGATATAAAAAAGAATGCCAAA GCATGGGTAAAAATACATGACATAACTATGTAAACAAGTAGAAGAACTTAGGGTTCTTCT AAGTAGGGTCAGAGCCAAGATGAGCTAGCAAAAAACCTTGTTACTTTTTTTTTTTTGAGA CGGAGTCTTGCTTTGTCACCCAAGCTGGAGTGCAGTGGAGCGATCTCGGCTCACTGCAAC CTCCACCTCCTGGGTTTAAGCAATTCTCGTGCCTCAGCCTCCCAAGTAGCTGGGATTACA GGTGCATGCCACCACACCTGGCTAATTTTTGTATTTTTAGCAGAGACAGGATTTCACCAT GTTGGCCAGAGTGGTCTCAAACTCCACACCTCAGGTGATCTGCCCACCTCGGCCTCCCAG AGTCTCAAACTTCTGACCTCAGGTGGTCCGCCCACCTCGGCCTCCCAAATTGCTGGGATT ACAGGCGTGAGCCACTGCGTCCAGCCAAAACCTTGTTACTTTGAGCAGTCAGCAAAGAAA TAGTACTTTATCCTTCCCCCTTTCTCATTGATCTTCCCAGAATTTTTTTACTCTGAAGTA AGCAATTTTAACACTCACTTCTTGCCTGGTAAGACTAATGTCATAGAAGAAAGAATCATC AGGGGTTGGATCGCTCTCTCCATCTGCTGGCCCAGTGGATTCGATGTCTTATAAATCTTT TTGGAAGTAGTTGGGACATACATTTATATGTTAAGTATTTATAGGGGTGATGATAAGGAT TAATTTTAAAAAGGTAAAACATTCCTTCTGTAATGTTTTGCAGACTTCTGAGAAAAGAAC TGTTTGAGATATAAAGAACTGCTTTTTGCGCGAGTGGCATAAATGAGTGAAGTGAGAATT ACCGTGTGTGAAAAGATAACTGTTGGGTGGTGGGCTTAATGCATGGGTGATGAAATAATC TGTACAGCAAACCTCCTGTAACAGACCTTCATATGTACCCCCAAACCTAAAATAAAAGTT AATAAAAATCAATAAATCAATAAATAAAAGCTGGAAGTTGATCTGAAAAAAAAAATTACC CCATGGTAAAGGTACCGCAGAAGTTATCCGGAGGAAAATGTTTCTAATTGTTTCCTAGGA AGTTGATGACTAGAAAGAAATTTGGTGGTTTTGTGTTTGTTTTTTAACTGTAAATATTTC AGTGAAGGAGGTCAAATCTTGAATGTCACAAGCCTTATATGAGTAGAGAAAGGGAAAATT AGTGAATAGTGAAAAACGTTGACATTGACTCTCCTGTTTTTGCTGATTGTCACTGCTTGG GGTTGAAACATAGAAACAGTGGAAAAGAAATCATTCTGGCTGGGCACAGTGGCAAGCACA GGTAATCCTATCACTTTGGAGGCCGAGGTGGGAGGCTTGTCTGAGCCCACGAGTTAGAGG CTGCAGTGAGTCGTGATCATGCCACTGCACTCCAGCCTGGGTGATAGAGTGAAACCCTGT CCCTCTCTTCTCTCTGTCTCTCTCTGTCTCTCTCTGTCTTTCTCTGTCTCTGACACACAC ACACACACACACACACACACACACACACACACACACACACAGTCTTTCCACCATATCTAT CCCTAAGATCCCCCAGTGATTTCCCTTCTCACACAGAGTAAAATCCAAAGCCTCTGACCA TGGTCTACAAGGCCCTGCATCTCACGTACACTCCACATACTACACACACACACACCACGC GCTACACACACACCCCCACACCAAGCATACATGCACATACGTGCCCCATTCTAACTTAAT CTCCCTCTACTTGTCTACTTCCCCTAACTCATGTACTGGACTCCTGTTCTTTGCACGTAA TACTCCCTCCTGCCTTAGGCCTTTGTACTTGTTTCTCCCCTTCGGACCACTCTCCCCACT AGACAGCTGTATGGCCGGCTCCCTCACTCTCCTCAGGTCTATCAGAGGGTGGCCACTGAC CTCATTGTCTCAAACATTATATAGAACACACACGCACCCATGCACGCACACCGTCGTTCT TCATCCGCCTGGTTCCGTGCACTATTCCAGGACCTACAGCAGTGCCTAGAACACAGAACA TCCATTAGCAACATTTGTTTAATGAATTTATAGTGCCTAAACCTGCACAACTCTGACTTT GCCTTGCTATTAGAAAATGCAAGGCCAGGCGCGGTGGCTCACACCTGTAATCCCAGCACT TTGAGAGGCCGAGGTGGGCGGATCACTTGAGGTCAGGAGTTCAAGACAAGCCTGGCCAAC ATGGCGAAACCTCTTCTTTACTAAAAATACAAAAATTAGCTAGGCATGATGGCATGTGCC TATAATCCCAGCTACTAGAGAGGCTGAGGCAGGAGAATCACTTGAATCCGGGAGGCAGAG GTTGCAGTGAGCCAAGATCACACCACTGCACTCCAGCCTGGGCAACACAGCAAGACTCTG TCTCAAAAAAAAAAAAAGAAAGAAAATGCAAATTCCAAAGGCTGCATTTGAGAAGTCAGT AAATGGGAGAGTAATTATAGAAGAAACTGAAACAGAGTCGCTTTAAGAGCAAGTTTTGTT AGTGCATTTAAAATGGGATTCAGTCTGCACAGATCGGATGCACGTGTAATCCCTAGGCAC ATTTACATTGTGTTTTCAGAAGGATGCAGCTCTGTTTCTATTATGTGAAGTAATTACTTG GTTACATTGGACTGCTAATGTAGTTATCAGAAAGTGGTTTGCATATTCTCCCAGAGGGAG GTATAATTTTCTAGATGCTCTTAGGACTTCAATATGACATATTTCCAAGATTTTAGGATG TCACAGTTGTAAAAGCATCATGAATTTTGTACAGCTGAGGGAAAATATTAAATACTACTT TAAATATTTAGAAATATTTCTTTTTTGTTTTGTTTTGTCTTGTTTTAGACGGAGTCTCGC TCTGTCTCCCGGGCTGGAGTGCAGTGGCGCGATCTCAGCTCACTGTAACCTCCATCTCCC AGGTTCAAGTGATTCACCTGCCTCAGCCTCCCAGGTAGCTGGGATTACAGGCACCCGCCA CCATGCCTGGCTAATTTTTGTATTTTTAGTAGAGACAGGATTTTATCACATTGGCCAGGC TGGTCTTGCACGCCTGACCTCAAGTGATCTGCCCCCCTCAGCCTCCCAAAGTGTAGAAAT ATTTCTCCATAGCATAAATTTATGCATGTACTATATTCCGCTTTCTCCTTCAGTATCACA CTCAAAATTTGAATCTACCTCTTTCAGTTTGAATCTAAAAATTCTTGTAAATCAGTTTTT GACCATTGACACTTAACGCTTGTATTAGTGAAACTGGCCACTTTTCTTACTTGTGATCAT GATTTACTCTGGCACCTTTAGGATTAATATTATAATTTTGAAACACATTGACAAATACTG AGGTTGATGCTACATTTCCTGTTTGGTTAAAGCTTTGTTTAACTCCCCCCATCTGCCGCC TTGCAAGTCAGCTTGTTTGGTGCCTGGCTGGTGATCACTGTGTTAGTCCATTTGCATTGC CATACAGAAAGGGTAATTTATAATGAAAAGAGGTTTAATTGGCTCATGGTACCTCAGGCT GTTCAAGAAGCATGACACCAGCATCTGCTTCTTGTGAGGGCCTCAGAAAGCTTCCAGTCA TGGCAGGAGGTGAAAGGGGAGCAGGCAGGTCACATGGCGAGAGCAGGAGCAACAGAGAGG AGGAGGATGTCCCAGACTCTTTTAAACAACCAGATCTCACGTGAACTCACTGAGTGAGAA CTCACTCATCACCAGGGGGATGTTGCTAAGGCATTGGTGAGGGATCTGCCCCCATGATCC AGTCACCTCCCACTAGGCCCGTGCTCCAACACTGGGGACTGCATTTCAATGTGAGATTTG GACAAACATCCCAACCATATCAATCACCAAAACACACTGAGCTCTTTTAGCTTTGAACAT TCTCTCATAGATCCTGAGTGCCTTTCCTTGCATTGCCTGGCACAAGAAAAGCAATCGTCT ACATAGTCTTCTACATACATTGTCACTTTTCATGTGTGAGTGCACGGTTTGTGAAAATAT TTCAAGTGGCAGTGAGGGTTTCAAATTTAAGTTAAAATGAAGTCGGATGTATTGCTAGGA ATGGGAGTAATTTCAGTGGCAGTTGCATGAGCCAGCGCCATCTAAGCCTGCTGAGTTCAC AGGCACGCTCACATGCTGGCTGGGGGTGCTGCATCAGACTGAGGCCTGGCAGCTGGCAAG GACCTATTGACATCAAACATAAGATGCTTTTCGGCCGGACGCAGTGGCTCACGCCTGTAA TCCTAGCCCTTTGGGAGGCCGAAATGGGTAGATCATGAGGTCAGGAGATCGAGATCATCC TGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCAGGCATGGTGG CGTGTGCCTGTAGTCCCAGCTGCTCAGGAGGCTGAGGCAGGAGAATCGCTTGAACCTGGG ATGCAGAGGTTGCAGTGAGCCGAGATTGTGCCACTGCACTCCAGCCTGGGTGACAGAGCG AGACTCCGTCTCAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAGATGCGTTTCTTCCCAGA AATGTAAAGATGTGAGAAGAATGGGGCTTATTATCAAGAAATAGAGTTTCATATTTTCAT TTTAAACATGAAGAAGATCTATTTTCATTGTCATCTGCAAGAGCTGTTCATAGGAAAATT ACCCTCAATTGTGTGTAGGTACAAGCCTGTTTTAGCAAAGTTCATCCTTGCAAAGTGCAG TGAATATAGTCACTGAGTTATGAATGTTAGCAGCAGAGGAGGGATCGCAGGTCTTGAAAC TAACTAAAATTGCTACAAGCAAAGATAGATATTTATTTTTTCCTTTCGGGGGGTTCCCTG CACTTCTCTCATTGGTTGATGGCTTTTTCTGTTTGTTCTAGTGTGTGTTTTTCCTGTGCT TTATTACAGTACTCACTTTTCAGTTATCAAGCCAGTCAGCAGATACCAGATCCTGCCATT AATTAATAAAGTATACCAAAAAATTAGTTGCTATAAAGACACAATAATTGGCCAGGTGCT GTGGCTCACACCTGTAATCCCAGCACTTTGTGAGGCTGAGGCAGATGGATCATTTGAGGT CAGGAGTTTGAGACTATCCCGGCCAACATGGTAAAACACTGTCTCTACTAAAAATACAAA AATTAGCTGTACATGGTGGCGAGCGCCTGTAGTCCCAGCTACTTGGGAGGCTGAGGCACA AGAATTGCTTGAACCCAGAAGGCGGAGTTTGCACTGAGCAGAGATCACACCACTGCTCTC CAACCTGGATGACAGAGCGAGACTCCATCTCAAAAAAAAAGACACAATAATTAATTGCCT TTGTTTGTTAAGGGATCCCACACGGACCTGCCCAGCCTTGTCATGACTCTGGCGAGGGCT TTGTAGGTGGCTTAGTTACCTACTCAGTCGGCAGGGAGTTGGCTGCCTTGTTCCTTTGAC TGCTTCTCAGCCTCATTGTCTCCCTTTGCTTTCACCTGTCAGGCCTATGTTATAGGTTGT TGGAGTTCAAATTTACTAGACTCTGGGCTGAACGCCTTGAATTTCAAAGTAGCATTGTTT CTCCTTCTTACTGAAATACTTTAATACCATACTTTTTTTTTTTTTTTTTTTAATAGCAGG CCAGGCTGGTCTCGAACTCCTGACCTCAAGTGATCTGCCCGCCTTGGCCTCCCAAAAGTG CTGGGATTACAGGCATGAGCCACCGTGCCCAGCAAATATCATAGTCGCTCTCTTGCCCAG GCTGGAGTGCAGTTGTGTGATCTCAGCTCACAGCAGCCTCTGCCTCCCGGGATTTAAGAG ATTCTCCTGCCTCAGCCTCCCAAGTAGCTGGGATTACAGGCACACGCCACCATGCCTGGC TAATTTTTTTGTATTTTTAGTTGAGATAGGGTTTCACCATGTTGGTCAGGCTGGTCTCCA ACTCCTATACCTCAAGTGATCCACCTACCTTAGCCTCCCAAAGTGCTGGGATTACAGGCT TGAGCCACCGCGTTTGGCCAATATCATACCTGTATTCCAAGGTCAATTATGTGTAGTTTT CCAAAGTCTAAGGACAATGATGTCCATACAGACATGTGTCCTTTAACGAGAGGGATACAT TCTGAGAAATGGATCGTTAGGCAGATTGGTCATTGTGTGAACATCATAGAGTATACTTAC ACAACCTAGATCATACAGCCTACTACACACCTAGGCTATGTGATATATAGCCTGTTTCTC TTAGGCTACAAACCTGTACTGCATGTTAGTGTACTGAACACTCTAGGCAATTAGATGCTT ATGCCAATTATGGTGAGTATTTGTGTATCTAAACATGTCTAAACATAGAAAAGATACAGT AAAAATATGGCATTATAACCTTGTGGGACCACTAGGGTATATTTGGTCCATCACAGAGTG AAATGTTGTTATGTGGCGCATGTGTTACAAATGTGTTCCAAAATTAGTTATGCATATCTA TCTGTCTGTAAAACATGTCAATTCCTCTTGGTCCTGTTAGTTTCTAGACATTAATTGTGT GTCCTGGGTTGAAGTAGGGATGTGTCTCTCACATTCCTGATGTTCCCATACTTTTTTTCT TTTATTTTAGGACAGCGTCTCTCTTTGTCGCCCAGGCAGGAGTGCAGTGGCATGATCTCG GATCACTGCAACAACCTCCTCCCACGGTCAAGTGATTCTTGTGCCTCAGCCTCCTGAGTG GCTGGGATTACAGACGTGTGCCACCACGCCCAACAAATTTTTGTATTTTTAGTAGAAACA GGGTTTCGCCCTGTTGGTCAGGCTGGTCTTGAACTCCTGGCCTCAAGTGATCCACCTGCC TTGGTGTACGAAAGTGCTGGGATTACAGGCATGAGCTACCATACCCGGCCATATTACCAT CCTTTATCATCTTCTGTATGTAGGTTTTTTGCCAAGTTTATGTTTTCTCATTTTCTTCAT TTCAGTACTCCTTACTTTTTCCTGTCGTAATTAATCCGTATGTGTCTTTTATGTATATCA AATCCGTTTGTGAGTTAAACACCAGATTTGTTATGTGGCCTGTCAATGGTTGATTTTAAC TTTGTTTAATGTCCTCAAATTTAACCCTTGTGCTTATGTTTGGTTTTTATCTCAGAGGAT AGTTACTACTAACATAACAGTGCTTCACAGTATAGACTGCTGATATTTTACAAAGCACCT CCACATTATTTCATTAAAACCCCACTGCAAAAGAGATGGAGGTTCTAGCTTCAGGTAACA AGTAAGCAGTGGGGTTGAGACTAGAACCCACGTCTGGTTACTCCTAGTACAATATTTTTG TTTTGTCTTTTACTATACTACTTTACCTTTTTCACTGATAGTTTTAGAGTTTTTATGTCG ATAGCAAATATGTTCATGTCTCCTCCTAACTGGAGAGTTTCTTAACCTTTGGTTCTATTG CCAAATGTTAGATGAGGGCTTTTGAGATCCATGGTAGAAGTCACAAAGATGAGGGCTATT TTGTCAGTCCCTTATAACTTTTCCCCCAAAGAGTTTGATTACAGCAGTAGCATAGTCTGG CTTTAACCTACAGCCCTCTGAGTGATGCCATTCTTTTTGGTTAAAGTACCTGTGATGTCC CTTCCAATGCTTAACACTTGGTACCAGTTCTTAGTGCTTCTGGTTTTCTAAGTTGCCACC TGCAGTAAGAAGCAGCCCTTCTTAGGTCCCTGAAATGTTACCAAAAGTTACTATTGTTGG CTTTGGAGCAGGTGAAACAAGCAGTCAGGGTGGATCTTGGCCGCATGGGTGTTTGTGCTT TGTTATGTGTACAGGGATCCTAACAGGCTTTCTGCTGCAGAAATGCAAACTCTGCCAAAA ATAATCAAGAGATAAGAATCAGAATTTCTTCTTGTCTTCTCTGAAGTTTGGGAGCCTCTG GTGGAGCAAGTAATTGGGATTCCTACAGTGACCATTTCACCATTGAAACCTGCAAAGAGA CAGATATGCTGAACTACCTCATCGAGTGTTTCGACCGAGTTGGAATAGAGGAAAAAAAAG CACCAAAGGTAATATGAAATGGATTAACTTAAAAAAAAAAAAGCCTAGTTATTTGTTTGA TTATCCCCACCCCTGGAGCATTCATTGATTTATTCAATCAGTAAAGCAATTATTGAGCAT TTGCCATGTGCCAGGCACAATACTAGGAACTTAGGATGTGTCGATGAACAAAACAGAGAT CCCTGCCCTCGTGGAACTCACATTCTAATAGAGACAGAGCCAAGGTTTGAACCTAGATGG CCTGGCTTCAGAGTCCTCTCTTGACCACACTGTAGCTCGGTACCGCCAGTGACTCATATG GCCCTGATAATTCTACTGCTTTGTTATAATAACCAACATTATAGAGCCTCTGTAGATTGC CAAGGACTGTGCCAGGTCGACATTAGCTTGTATCCTCAGTTGCTCTGTTAGTGCAGTGGA ACCCGGTATAACATAGGCATTCTTTTTTCAACGTATGACTAAGCAAATGACTCTCAGAGA GATTAAGTACTTGTCCAGAATCACGTAAATAATAAGTTGCAAGGCTGGGCTTAAACTCAG TAAGCTACCCTTTTCCCATCACTTCTCTTGACTGGCTTCATTGTTTTCTCATTTTATTCC TATTTCATTTTCTGATTTTAATTTTACGTTAGAAACGAACCTCGTTGCCCACTGGTTAGT TTCATATTTGTAAAGGGCCTTCTTTGGGCTTTGTTGTACTTAGCCTTAGTGGAAGCGAAA TGAGTGGGCATGTCTCCAAGGTTTTTTGTTTTTTTTGTTTTTTGAGATGGAGTCTCGTTC TCTCACCCAGGCTGGAGTGCAGTGGCGCTATCTCAGCTCACTGCAACCTCCACCTCCTAG GTTCAAGCAATTCTCCTGCCTCAGCCTCCTGAGTAGCTGGGATTACAGGCACCTGCCACC ACACCCAGCTAATTTTTTTTTTTTCTTTTGAGACGGAGTTTCACTCTTGTTGCCCAGGCT GGAGTACAATGGCACAATCTCGGCTCACCGCAACCTCTGCCTCCTGGGTTCAAGTGATTC TCCTGCCTCAGCCTCCCGAGTAGCTGAGATTACAGGCATGAGCCACCATGCCCGGCTAAT TTTGTATTTTTAGTAGAGATGGGGTTTCTCCATATTAGTCAGGCTGGTCTCTAACTCCCG ACCTCATGTGATCTGCCCACCTTGGCCTCCCAAAGTGCTGGGATTACAAGTGTGAACCAC TGCACCCGGCACACCCAGCTAATTTTTATGTTTTTTTTAGTGGAGATGGGGTTTCACCAT GTTGGCCAGGCTGGTCTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTGAGATGGAGTC TCACTCTGTCACCAGGCTGGAGTGCAGTGGTGCAATCTTGGCTCACTGCAATCTCTGCCT CCTGGGTTCAAGTGATTCCCCTGCCTCAGCCTCCTGAGTAGCTGGGACTACAGGCGTGCA CCACCATGTCTGGCTAATTTTTTGTCTTTTAGTAGAGATGGGGTTTCACCATGTTGGCCA GGATGGCGTCGATCTCCTGACCTTGTGATCCGCCCTTCTTGGCCTCCCAAAGTGCTGAGA TTACAGGCGTGAGCCACCGTGCCCGGCCCAGGCTAGTCTTAAACTTCTGACCTCAAGTGA TTTGCTTGCCTTGGCCTCCCAGAGTGCTGGAATTACAGGTGTGAGCCACCGCGCCTGGCC TCTAAGGTTCTTAAGTATAAGTTTGGTCACCTCAAACTTACGCTTCTTTCTTCTCTGACA TCAGTTTCTGCAGAGGCAGTACACTTGGAAGGCACAGTTACTGTAGCTCGTTCACTAAGA ATAAAGGAAGAGGAAAGCACGCTGTTTACTGATGGTCCATCCCTTTTAACTCTTATTTTT AACAGCATGGAATTGTATTGTTTGTTTCTTGTCGTCCTCACTTCCACCTTTCCTTTTCAG ATGTGCAGCCAGCCAGCAGTCAGCCAGCTTCTGAGCAACATCCGCTCACAGTGCATATCC CATACTGCTTTAGTACTACAAGGCTCCCTAACACAGCCCAGGTATGAAGACCCGTGACGT GCTTGACATTAGCAGGCAGAGAGCCCTAGCCGTCAGTGGACATCAGGCTCTCTGGCCATT CTTGCACCACCTTAGATAACTCCCTTCCTCACCTGTAAAATGAAGGTCCCTTTCCTTCGC TAAAATACTATGAAAATAAACACTCCTTTCTTCCTCATCTTCTAAAGTAGTACAAAGCAT ATTTTAAAAAGAAATTAGTTATGTTTTAAGAATTCTGCCTGCTTTTTGAAATAGACCATT GTTGAACTATGTGGACAAGCATGGCAGAAAATTAGTAACTGACTATACAGCAACTGCCTG AAGTTGGTGGAGGTATTTGATAAAATGTGTAGATCATCACCTTCCATGTATAACACGGTC AATTTCTGTTACTGAGTAATAAACAATAGTAATGGAATGGATAGTTTAGGAATCAACCAA AGTGCTACATTATTTGCTTCTGAGAATCCTATAAAGGTTGCAAATTTTTGTTTTTATTTT GTTTTTAAAAATTTTTTTTCTTTGCCTCTCAGTCTTCTAAAGGTAGCAAGTTTTTAAAAA GGATGTGTATTTCATTTCTTTTATATAAAAAATATCTAAAGGGAAAAGCTTACATTTAAA AGTTTAGGCCGAGCATGGTGGCTCACACCTGTAATCCCAGCACTTTGGGAGGCTGAGGCT GGCGGATCACCTGAGGTCAGGAGTTTGAGACTAGCCTGGCCAACATGGCAAAATTCCGTC TCTACTAAAAATACAAAAGACTTAGCTGGGCATTGTGGCATGTGCCTGTAATCCCAGCCA CCTGGGAGGCTGAGGCCAGAGAATCGTTTGAACCCAGGAGGTGGAGGTTGCAGCCGAGAT CGTGCCACTGCACTCCAGCCTGAGTGACAGAGCAGGACTCTGTCTCAAAAAATAAAAATT AATAAAATAATAAAAAATTAAAAGTTTACAGGCCAGGCTCATGCCTGTAATCCTATCACT TTGAGAGGCCAAGGCAGATGGATTGCCTGAGCTCAGGACTTCATGACCAGCCTGGGCAAC ATGGTGAAACCCTATCTCTACTAAAAATACAAAAAATTAGCTGGGCATGGTGGCACGCAC CTGTAATCCCAACTACTGGGGAGGCTGAGGCACGAGAATTGCTTGAACCCGGGAGGTGGA GGTTGCAGTGAGCTGAGATCACGCCACTTCACTCCAGCCTGGGCAACAGAGCAAGACTGT CTCAAAAAATAATAATAATACTAAATAAATAAAAATTCACAAACATAACATTACATTTAT TTATTCTAGGTGTTCTTATGTTATTTTGTATGCCATAACCATATGTTTTTGAAACTTTTC AAAAAGAAGGAAAATTATATACATGTACCAAAACTTTAAAAAACGTTCCTTGATTAAAAT TAATAAGCCCTCAGCCACTACTAATATTTTTTCCCCCAATTTAGATGAGGCATAAAGAAA CATATAATACGGCCAGGCGTGGTGGCTTACATCTGTAATCCCAGCACTTTGGGAGGCCAA GGCAGGTGGATCACCTGAGGTTAGGAGTTTGGGACCAACATGGTGAAACCCCATCTCTAC TAAAAATACAAAAATTAGCCAGGCGTGGTGGCAGGCGCCTGTAGTCCCAGCTACTTGGGA GGCTGAGCAGGAGAATCACTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAAATTGCG CCACCATACTCCAGCCTGGGCAACAGAGCGAGACTCCATCTCTAAAAAACAACAAACAAC AACAAAAAAAACATATAATACTTCTTTTTTATTTTTATTTATTTATTTATTTTTAAGAGA CAGAATCTCACTCTGTTGTCTAGGCTGGAGTGCTCACTATAACCTCAAACTCCTGGGCTC AGGCAGTCCTCCTGCCTCAGCCTTCCAAGTAGCCAGGACTCCAGGCACACACCATCTTGC CCAGTTGATATTTTCATCTTTTGTAGAGACAGAGTCTTGCTGTGTTGCCCAGACTGGTCT TCAACTCTGGGCCTCAAGTGATCCTCCCACCTCAGCCTGCCAAAGTGCTGGTATTGCAGG CGTGAGCCACCGTGCCTGGCCATGCTTCCTTTTTTCAGTGCTTCATTTTTAAAGGGCTCT ATGTAGGAAAAGATGAATTCTTTGAAAATTCCCATAGTGTCTCATTAAAAAGACCAAAAA GTGATTACTATTGGTAAGAAGGGTTAGCTTTCGCCTGAAACTATTTTGCAGAATATTTGG GAGATGTCAAGTTTGACTTTTGACTGGGCAGTTGTTGCTGACATGACATTTCACGTGCCT CTGTAGTGAGTTGACTTCATCACCGTCCCTAATGTTCATGGGTCCACAGGTCCTTGCAGC AGCCGTCCTTCCTAGTGCCGTATATGCTGTGTAGGAATCTCCCATATGGCTTCATTCAGG AACTGGTGAGAACCACTCACCAGGATGAAGAAGTGTTCAAGCAGGTACGGTCGTATGAGT TTGCTCTTGCAAATTTTAGCCTGAGAGCCTCTATGTCGAGGCTAATTTCTGACCATTGAA AACTTTTGCCTGAATTCGAACATCCATGTGTTATTAGAGAGAAGGCCTACCCAATATTCT TTTGAGGAAATCAGATTGACAGCTGCATTGTTCAAATCATGTGCCCATTTCAACGAATCA GTCAAACATCTATCTTCTAAACAAGGTCTGCACTAGGTGCTTCGGGCAATATGAAAAAAA TATGTAAGGCCCCGTTCCTGATTTCAAGGAGCTTTTAAAACAAGAATACCCAGAGACGGC ATAAGGCATGATATGCATTTGCCAGATAAGTAGTGTCAAAAATTCATTCTCTGAGTTTGT AAGATTAACTTAATGACCATATTAGCTCATTGGCAGCCTGCATGCCATATAGAATCTTTG TCTTCTTCCCACTAGGAAAGATGTCTCATATCTTCCTAATTATTTCATTTGGTATTTATA CATTGTTTTGGTATCTCATTGTGTAAAGCCAGGTGAAAATGCAGATATGTAGTGCTTAAA AATAAAGCTGTGTACGTAGTCTTGAAGGTTTCTTCCAAGGTGAAACTTTGTTGTTAACAT TGCTGTTTGAAGGACCTGTTTGGGAAAGTAAGCACTTTGCCTTTAGCAACTGTCACACAA GTTTTTTCCCTGATGAAAGGGCTTTTATCAAATTTTCTTACAGTTTGCTGTATCATCACT TCCTTTTTTGTGACTACAGAGAATAACAGAGGCAATAGCTATAATTGGTATGATTCCTTT CACTCTGTTTTATACCTAAGATTATTTATAACTGTTAATTTTAAGACCTTTGAATTCTTG GGAATTGTGTTTTCAGCAGTCTTCAAAATATTTGTAAAAGAAGCAGCCAGGATCCAAGAA TAAAAATTCCAGTTAGTGTTGTGTATTCTGTCTGGAATTCACTAGCTGTTTATCTTAGGT GATGATCTTACTGACTAATGGAAATATTAATGGCAACATAGTGAGCTTTTCTTCTCTAGA AGGGTAAGTGAACTCTCAGGAAAATAAATCACTGTCGGCCGGGCGCAGTGGCTCACGCCT GTAATCTCAACACTTTGGGAGGCTGAGGCGGATGGATCGCCTGAGGTCAGGAGTTCGAGA CCAGCCTGGCCAGCGTGGTGAAACCCGGTCTCTACTAAAAATGCAAAAATTAACTGGGTG TGGTGACGGGTGTCTGTAATCCCAGCTACTTGGGAGGCTGAGGTAGGAGAATTGCTTGAA CCAAGGAGACGAGGTTGCAGTGAGCCGAGATTACACCACTGCATTCCAGCCTGGGTGACA GAGCAAGACTGTCTCAAAAAAAAAAAAAAAAAAAAAAAAAATTACTGTCTTGGAAGGTTT GAGTGATGCACTACATTAAAGAGGTAATGGGTAGTAATTAGAATACTTTTCCTATTCAAG AAGATACCATTTGAGGAATCGAGTAGTTCTCTCTATATAAAATCAGCCCAGTGACCAGCT GAAAGGGGTATATTGAGCCTACTTTATTCATAAACAAACTTACACAAGAGGTTATGAAAT GACCTCTGGGTGTTTTTTGTTTGTTTGTTTCCCCATCACCAGCTTTGGACAGAGAAGTCC TGCATTTTTTAAATTAAGATGAAATTCATATAACATCAAACCACCGTTGTTGTTTTGTTT TGTTTTGTTTTGTTTTTTGAGATGGAATTTTGCTCTTGTTGCCCAGGCCTAAGTGCAATG GCATGATCTCGGCTCACTGCAACCTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTTAG CCTCCCAAGTAGCTGGGATTACAGGCGCCTGCCACCACACCCAGCTAATTTTTTGTATTT TTATTAGAGACGGGGTTTCACCATGTTGGCCAGACTGGTGTTGAATTCCTGATGTCAGGT GATCCACCCGCCTCAGCCGCCCAAAGTGCTGGGATTACAGGCATGAGCCAGCACACCTGG CCTCAAGCCATCATTTTGAAGTGTACAATTCAGTGGCATTTACTACATTCACAGTGTTAT ACGACCACCACAGACCTGTTTATTCTATTAATTAATTAATTAATTTTGAGGGTGAGTCTC TCTCTGTTACCCAGGCTGGAGTGCAGTGGCGCCGTCTCAGCTCACTGCAACTTCCACCTT CTGGGTTCGAGCGATTCTCCTGCCTCAGCCTCCCAAGTAGCTGGGATTATAGGAGCGTAC CACCATGCCCAGCTAATTTTTGTATTTTTAGTAGAGATGAAGTTTTGTCATGTTGGCCAG GCTGGTCTTGAACTCTTGGCCTCAAGGCTGGTCTTGAACTCTTGGCCTCAAGTGGTCCGC CCACCTCGGCCTCCCAAAATGCTGGGATTACAAGTGTGAACCACAGCGCCTGGCCCAGAC CTGTTTGTTTTTAATCCCAGAATTCTGCTGACTTTTCAGCCACTCAGTGTTGAATACTCT TTGTCTTTTCTTATGTGCTACCATGTGTTTTATCTAGAGAGGAATGATAACTGGGATGGA GCTGTTGGACTGCAAAGCAGCATTTTACCTTTTTGTCTTGAAAGAGTGGCAAATGTGAAT TATTAAATCTTTGACTGAAATATCTACCTCCTTTTAATGTTTGAGAAATGTTCACAGATA AATAAATAGCAGCTAGAATTTAGGACTGGAGGTGGATACTTACAGTATTTTTAATCAGTG CTAGGAGGTATTCATTTGAAAATTGAAGAATTATTTAAAATATATAGGTCAGGCCAGGCA TGGTGGCTCACGCCTGTAATCCTAGCACTTTGGGAGGCCGAGGCAGGTGGATCGCCTGAG CTCAGGAGTTCGAGACCAGGCTGGGCAACATGGCAAAACCCCATCTCTACTCAAAATACA AAAAATTAGCTGGCGCAGAAGTGCATGCCTGTAGTCCCAGCTACTTGGGAGGCTGAGGCA GGAGAATCTCTTGAACCCGAGTGATGGAGGCTGCATTTAGCTGAGATCGCGCCACTGCAC TCCAGCCTGTGCGACAGAGTGAAATTGTGTCTGGAAAAAAGAAAAAGAAAAAGAAAAAGA TTATGCTTAGTAATATTTTACCTGTGCAATGCACAAAAGGATAACTATACAAGAAAGTGT AATTATATTTTACTTGTAGCCTCCCTAAAAAAATTTGGAGATTTTTCAGGACAACCAGTT ATGAACTAATTTTTGGTGATTCTGGAACCTCTGTTTGTCTTTTCTTCCTCATTACAATGT TGGCATTCCCCAGCTCCACACCTGAGTGTTACTTCTCCATTTTTATCTGGCATATGAGAG CAAGTTACATCTACCTTGATTGTTGGTATTGCAGAAACCATAGAATGATCTCTTCCAGAG CTGTATTGATATCTCACAACACTCCACGGACACTTTGTCATCCAGGGCACCTGTGTTTTA TACTGTGCTCTTTAAATTATTAAGGTGCTCATGGAATGAAATTAGTAGGAAAGGGAATTT TTCAAGTTTTCTAGTGGCTACATAGTATACTCCTATTACAACTTGTTGGCATTCAGATTG TCAGCTGTTGTTTACAACATTTCTATTTAATGTTATTAGCCTTGAATCCCAACCAACTCC CTAAATGTGTTGATCAGTGCTTGCATTGTGAAATTTGAAGATGAGCTAGGCTGAGTAAAT CTTACATGGTGTTACCTGGTATTAATCATAAATGTATAAAAGCAGATTTGAGTTCCTTTA AGTGCCAATAGCAGGTTAATGTATTAATTACACTATATGTGGAGGTAAGGCTTTCTAACT AAAGCTTTCTTTGTAAATTTCAACATTTACCAACTAGCTCTTTGCTCTAATTTAAGTTTA ATGTAGTAATAATGTTGATTGTTGGCCTGTTTATCTTGTTTTCCTCAAAATAAATGGGGA AAAGCTTTTAAAAAATATTGATAGAGGGCCAAGCGCGGTAGCTCATGCCTGTGATCCCAG CACTTTGGGAGGCTGAGGCGGGTGGATCACGAGGTCAGGAGTTCGAAACCAGCGTGGCCA ACAAAGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCAGGTGTGGTGGCACATG CCTGTAATCCCAGCTGGCTCGGGAGGCTGAGGCAGGAGAATCACTTGAACCCCAGAGGCA CAGGTTGCAGTGAGCCAAGACTGTGCCATTGCACTCCAGTCTGGGTGACAGAGCGAGACT CCGTCTCAATATAGATAGATAGATAGATAGATAGATAGATAGATAGATAGATAGATAGAT AGAAAGGAGGAAATATTGGAACATTTAATTGAATTTTTTAACAGGTTATAGATGCTTGGT AATCAAGAACATATTAGTTGCTGAGATGTGCAGAATTTAATTGAGTAGAGCAACGACTCC TGGAGAGTTCTTCAACAGGCTCCAAATGTATGGGTTTTGTTGAATTACTGGGTTTTGTTG AATTACTGGGGGTCCTGTCAGAGTATTAGAGTTCACCAAACTCCTCTTACTTCTGGAGAA TTCAGCTGTATTACTTTATGGTTAGACTTGTCAAAGAACAGGTCAACACTCTGGCTGAAT TCTAGACTTTTATATGCAAAAAAGCTTTTCCCTGGGGAAGGAATGAAATTTGGACATTCA GTTCTAGCACCTTATTTGACATACTTCCCACTCTTAGATTCTCTTAAACTTATATTTCTG ATTTTGTTTTTTTTCTTATAGATATTTATCCCCATTTTACAAGGCCTGGCTCTTGCTGCC AAAGAGTGCTCCCTCGACAGTGACTACTTTAAATACCCCCTCATGGTAAAACTTTGTTCT TTTTCTTTAACTCATTCAATAGATGTTTTTCTTTCAGATTATTTTGACATATACTTTTCT TTCAGGTCCATGAGATCAACCTTGTTTTCAAATTTAAAACATGAAATCACTGTGTTGGCC ATGCAGAGTGTTTGGTGTGCAGTGAGATGCATCAGTGAAGACAGTTAGCAGCCTGGTACA TCTTCCACCTATCCAAGTCCTAGACAGGAGTTAAATGCACTTATTACAATGTACTTTGTA TAGCTTATGAAAAAGATAACTTATCTCCTAGCAATGAGCATACCATAGTTGGGATGAAAT TTTGTTACTTAAAAAAAAAAAACCTATTAAAAATGCAAATAAAAAAGGCAAAGCTGTACA TACTAAGAAAATGAATACAATTTTATCTTTATGTGTTTACTTTGTGCAGAAAATCTCAGT GTAGCTCTCTTGTTCACCCTCCCTGTTTCCTAAGGTCATATTTACTTGGGAAGTAGAAAT CTGCTTAGCTCTTTAACGCACTTAGAGCAGGCATACATTGTGGACAGAAGCTTCAGCTAG ATTCCCATGGGGAGGCTTGAATGTTGTGAAAATGCTGAAACTAGAATGAAAATTAGAAGC TCCTTTCTGTTCTGAATTCGCTTATTTGAAATTTTGGGAGAAAAGTATTTTGAAGTGTTA CTGAATATTTTCGTTGCAGAAGTGTAAAGGAAAAAATATCAAAATGAAATTAGTTTATTC TATGTATAAATTAAGTCTTATGTAAATTGAGACCATGGTTGTTTTTCTTACTGTATTTAT TTCTTTTACTTATTCCACTGATTGGATTCCATTATACCATGAATTCATTACTGACGATCT GTTCTGTGCTAGACACTGGTGATACAGAAGCTAGGAAGACAAGGTCCCTCTCCTCAAGGC ACTCATAATCTACTGCAAAAATAAGAGCTACAGCGCAACAGTTGAACAGATACTGTGATA AATGTTAAAACAGAGCTGTACACAAAGGGTGTATTTATCTATTTAAAAAATTCAAACCTG TCATGGCACTAAAAGGCTACAAGAATGCTGGGAAATTAGAAGGTGAAACCAGAATTCCTA CTTTAAAAAATAATTTTAAGTGGATTTATGCCAGAGCTCTTTCCATTGTACATGTTATTG GGGCTCCTGGTAAAATTATTTGAATCCTTATGTATTGTTCTCCCTGTGGCAGATAAAAGG AAGTGGAATAATCTGATTGTTTGAGTTCAGTGATGAAATATTTTAGTGAACACTAATTAT CACCATATTATGTAGATGTTCCTTCATGGGACTGTTGGCTTTTGGGTTGTGGTGTGAATT AGCTTGATGTTTCAGTGAGGAGCTTTTAGCATCTGATATCACCAAAATGTCCTTTTGTTC AAAAGACAGAGGCCTCCATTGTGGTAGACAGTGATTTCATTTTGTGCCATTATTGATGCT TGCATAATAACGAGGACACAGTGAGTGAGAGGGTACAATAATGAGAGGCAGGAAGCGGAA GACTGTTGAAGCTAAAATCAGAAATCATTGTGATCATTCTCTAGGTCAGTGGATCCTGCT GTGCCATACGTTGGAATCACCTTGGAATCAGCTGGGGATCTTTAAAGGTGTTTCTGCCTG GCTCCCCACCCCAGACCTTGTGATTTAATTCACCAGGGGTGTGGCATGGCATTGGGGTTT CCAAAGGCTTCCCATGTGATCCTAATATGCAGCCACGTTTGTGAACTCCTGCACTAGGCA GTGAGAACGCTTCCTTCTGAGTTGAGGCTGCCTGAACCTCAAAGGCATCTCAACGTTGTG TCAATGCCTAAATGCACTCTTCGGCTCATGTAGCAACTTCTAGAGCTGCGTCCGAATCAC AGAGGAAATTAACTGTTGAAAATAATGTTTGATTGAGTTACCATGGGCATGCTAAATTAT GTTTATGTCCCTAAAAAGTGTTTTTCATCGTTCTCTAATGTTAGGATGGTTGGATGTCTG AAGGAAAGTGTTGGAATTCTTAAAAGTACTAGAAATCTTGAAACCAAGTTATGTTTTTAA ATATGTTTTGAATTTGATAGCTTATTAAATTGTAATTATTTATAGTCATGTTTAACACTG GCAAGAGGAGCCATCTAAAGTTTATGAAATAAATCTTTTTGACATGGAAAGATATGAAGT GGAAAAACTTTTTTGTAAAAAACATATATAGATACAGTACACAAAAATATATCTGAAAAC TGTTGCTCAAAATATCAATAGAGGTTATCTTTGAGGGTAAAGCTTGAGTAATTTTTAGTT TCATTTTATATTTCTGTTTTATTTCAAGTTTTCACATTGCATGTGTTTTAGTTTATTAAT CAGAAAAAGTAGTGAAGCTGCTGCCATTTCAGAGGGAATGCATGTGTGCCATTTTAGAGG GAACGAATTTATAGCAGCAGTTAAAACTGTTTCTTTATGCTACAAATGACAGTCAGTTTA AGATGAAATGCATTTAAATGACTCTGATCTTATTTCTAGGCACTAGGTGAGCTCTGTGAA ACCAAGTTTGGGAAGACACACCCTGTGTGCAATTTGGTAAGCACTCACCTGATGGGCTTG CACATTTTCAGTGAATATATCATAACCCAGAAGGCATTCCTCTAGTGAGATGGCCTGGAA AATGTCTCTTGAAGGACATTTAGGTGTAGGCGGAGGTAACGTGTCTGGGAGGCTCTCAAC TGTTACATTTTTGTTAGACACGTTATATCCTGCATTACAGTTGTTCATTTCTATGATTTT TTTCCCTTTTTTTTCTAAGAATCTCACTCTGTCACCCAGGCTGGATGGAGTGCAGTGGTG GGATCTTGGCACACTGCAGCCTACGCCTCCTGGGTTCAAGTGAGTCTCGTGCCTCAGCCT CCCAAGTAGCTGGGAATACAGGCATGCATTACCATGCGAGGCTAATTTTTTTGTATTTTT AGTAGAGATGGAGTTTTACCATGTTGGCCAGGCTGGTCTCGAACTACTGACCTCAGGTGA TCCACCCGCCTCAGCCTCCCAAAGTGTTGGGTTACAGGCGTGAGCCACCGCACCGGGCCT GTTTTTTTTCCCTTGACAAGTATTGTACAACTAAACTAACAAGAGGTATGGAAAAGTTAT TCGAGTCCTTTGGTGGTATAAGAAGAGTTCATTTGAACTTCATCCAATAGTATCCTGAAA CTTAAACATTCTTTTTTTTGAGACAGAGTCTCACTCTGTCACCCAGGCTGGAGCGCAGTG GCGCAATCTCAGCTCACTGCAACCTCTGCCTCCTGGGTTCAAGCGATTCTCTTGGCCTCA GCCTCCCCAGTAGCTGGGATTACAGGCGCACACCACCACGCCCGGCTAATTTTTGTATTT TTAGTAGAGACGGGGTTTCTCCATGTTGGCCAGGGTTGTCTCGGACTCCTGACCTCAGGT GACCCACCCCCACCCACACTGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACCAT GCCTGGCTGAAACATAAAAGTTTTAATAATATCTTGTGAAAATACAGAGGAGCTGGAGAG TTTTCATTACATTTTTACCCCACCGGCCTGTTCAGCGGCTTGACTGGCTCTTCCATCTTC TGCCTAGGTTGCTTCTTTGCGGTTGTGGTTGCCGAAATCCTTAAGTCCTGGCTGTGGGCG GGAGCTGCAGAGACTCTCTTACTTAGGGGCTTTCTTTAGCTTCTCAGTCTTTGCAGAAGA TGATGTAAGTATAGTGGCTACTTGTACTTTGCTGCCCTTTTATTCAGATTCTTTCCCAAA TGTGCATTATATGTTGACTGCATTTTTTCCTTCTCTTTCCAGGTTAAAGTGGTTGAAAAA TACTTCTCAGGGCCTGCCATTACCCTGGAAAACACTCGTGTGGTTAGCCAATCATTGCAG CATTACTTAGAGCTCGGAAGGGTAAGTGTTCAGAAAACAAATCCAGAGGAAGTATCAAAG ATGAGCTCCAGATACAGAGCTTTTATTTTGTAGACTGGACTATGCCCAGTAGACAAACGG CTAACAAAAGCCAATTCGATCTTACATAAAAAAGATAAACTATAAGTAAGTAGCCTGTGT CTTGAATAACAGGTTGTAACAACAGCAGTATGCTGCCTTTGTATGTAGCATCACTGGGAA CTGGTCCTAAGCTTAGTGGCCCGGCTCCTCCTCCAGCTGGCCCTTAGGCATTTACACTGT GAGGGTGAGCAAGGATTGTTAGTTTGCACACACCCTCACTGACTTGCTTATCCCAAATGC AGATTAATATGTCTTCAATTCTCAAACTTAAAGGCAGAGAAGGGCCGGGTGTGATGGCTC ATGCCTGTAATCCCAACACTTTGGGAGGCCGAGTGGGGTGGATCACCTGAGGTCAGGAGT TTGAGAACAGCCTGGCCAACATGACGAAACCCCGTCTCTACTAAAAATACAAAAATTAGC CAGGCATGGCAGCGCGTGCCTGTAATCCCAGCTACCTAGCTACTCGGGAGGCTGAGGCAC AAGGATCACTTGAACCCAGGAGGTGGAGGTTGCAGTGAGCCAAGATCACGCCACTGCACA TCAGCCTGGGCGACAGAGCAAGACTCCATCTCAAAAAAAAGAAACAGGCAAAGAAGTTAC AGGCTTGGGTAACTAAGGTAATTTTGATCATGGGAAAGAAGTAACAAAGCCTATTTTATT AAAACTGTAACTGCCGGCTGGGCGTGTTGGCTAATGCCTGTAATCCCAACACTTTGGGAG GCTGAGATGGGCTGATCACGAGGTCAGGAAGTCATCCTGGCCAACATGGTGAAACCTCGT CACTGCTAAAAATACAAAAATTGGCCAAGGCAGGTGGATCACGAGGTCAGCAGTTTGAGA CCAGCCTGACCAACATGGTGAAACCCCATCTCTACTAAAATACAAAAAAAATTAGCTGGG CATGGTGGCGGGTGCCTGTAATCCCAGCGACTTGGGAGGCTGAGGCAGGAGAATCGCTTG AAACCGGGAGGCGGAGGTTGCACTGAGCCGAGATGTGCCACTGCACTTTAGCCTGGGCAA TAAGAGCAAAACTCCGTCTCAAAAAAAAAAACAACAAAAATGCAAAAACTAGCTGGGTGT GGCGGCGTGTGCCTGTAATCCCAACTACTCGGGAGGCTGAGGCAGGAGAATGGCTTGAAC CTGGGAGGCGCAGGTTGCAGTGAGCTGAGATTGCACCACTGCACTCCAGCCTGGCAACAG AGCTAGACTCTGTCTCAAAAAAAAACAAAAAACTGTAACTGCCTACCTCCCCCACTCCAT ATTCTGCTTTCATGCTCATTACTTTGACATAGTTGGATGTGGATATTTCTTATATTCTTT CACTCAGGCTCTTCTAAAATGAGTAGAAGTGGGAGAGGAGAGAACGTGGGAAGTAGGCTA GCTGTTCGTGAAGTCAAAAAGGAATCATGTGCAAAATAGTTTTAATTTGTTTCTTCTTTT TAAAAATAAATTTCAGCAAGAGCTTTTTAAGATTCTGCATAGTATTTTGTTAAATGGCGA AACCCGTGAGGCTGCTCTCAGTTACATGGCGGCTGTCGTCAATGCCAATATGAAGAAAGC ACAGATGCAGGTAGGATTCCTACAGACTGCTTTTCGCTGTTTGTCAAATTCATTCATCTG ACCCAGATTTAGTCAGCACCTACCAGGCACTGTTCTAGGAGTGGGGGTACAGTATTGAAC AAGGTAGACGAGCTTCCTGCTTTTGTGGAGCCCATGTTCCACAGAATAAACAAGTAGACA TATAAATACATGATTTTAGACAGTTGTATAATCAGTGAAGAAAATAGAGCAAAGTAAATG ACATGAGAAGAACTGTAGGTACCAGAAGGAAGATCTGAAGGTGATTTTTGATTGGGTGGC AGGAAAGGCCTCCCTGAGGAGGTGACATTTGTTTCATAGGAAGGAGCCAGCCATTGTAGT GGCTGAGAAAAGAGCTATCCAATGTGGAAACGAAGCAGCTTTGGTACAAGCCCAGCACGC AGGCTTTTGTGGCTGGAGAAGAGTGAACAGGAGGGAATGTCGGGTCCTGGAGTTAGTGGA TAGGCAGGGCGCCATCGGGTTAGGTTTACGTGATCAGAACTGTCATGGGAGGGTTTTCAG CAGGGAAACCACAAAAGCTGCTATGTAGACGGACCAAAACAGAAGGGGGCAGCCAGGAAC AGACCCAAGGGGGCAGCCAGGAACAGACCCAAGAAGGCAGCTGCAAGGGCGTGAGTGCTT CGGTCCGGGTGAGACAGGCCAGTGGCTGCAGCTGCTTTGCCAGAGGAGAAAAGGGCATCC TTCCTTGACTAGTAATAAATAATGAATGAATGATGTGATGTGTATACTCAGAAGCAAAAA TCATGTAGAGAGAAGAGCACAGATCTTGTGATTTCTGATCGTGGTTCCACCGTTTACTAA CTGCGGGACCTTAGACAGTGACTCCTCTGTGCCTCCATTTCCTCATCTGCTAAGCTGCGG TACTACTGGTACTGGGTTTATTATATATAAAGCTGTTAGAGTGGTGCCTGGTACACAGTG ATCACTCAACCAATATTAACTATCATTCTTATCATTGTTGTATTATTATTTTTTTCTTAA CAGAGGTAATCAAGTTACATTGTTATATTGCTAATGCAGGAGCATGCTGATGCTGTCACC TAGAGAAACAATGTCACATGATAAGAAGTGGAGCAACTTGTTTTGATGCTCTTGAGGGAA ATAAAGAGGAGAAAGAGGCCGGGCATGGTGGCTCACGCCTGTAATCTCAGCACTTTGGGA GGCCGAGGTGGGAGGATCACTTGAGCCCAGGCATTTGAGACCAGCCCTGGCGACATAATG AGACCCCATCTCTACAAAATATACAAAAGTCATCTGGGCATGGTGGCTGGTGCATGCCTA TAGTTTCAGCTACTTGGGAGGCTGAGGCAAGAGGATCACTTGAGCCAGGGAGGTCGAGAC CAGCCTGGGCAACATAGGGAGACCCTGTCTCTACAAAAAAAATAAAAAATTAGCCAGTAT AGTGGCATAGACCTGTAGACCCAGTTATTCAGGAGGCTGAAGTGGGAGGATCACTTAAGC CCGGGAGGTTGAGGCTGCAGTGAGCTATGTTTGCACCACTGCACTACAGCCTGGGCAACA GAGTAAAACCCTGTCTCAAAAAAAAAAAAGAAAGAAAGAAAGAAACATTTATTGTGTTTC TACTTACTAATTTTGAGCCTCAGGCAAATCACTTCAGGGTCTCTGAGTCTTTATTTCCTC CTGCATAAAATGTTAACAGCAGTATTACTGACCTGTAAGAATTATCGTGATGGTTCAGTA AAAGAATGTATAAAATGGCCAAGCGTGGTGGCTCATGCCTGTAATCCCAGCAATTTGGGA GGCCGAGACGGGCGTATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAATATGGTG AAACCCCATCTCTACTAAAAATACAAAAAATTTGCCGGGCGTGGTGGCGGGTGCCTGTAA TCCCAGCTACTCGGGAGGCTGAGGCAAGAGAATCACTTGAACCCGGGAGGCGGAGGTTGT AGTGAGCGAGGATCGTGCCACTGCATTCTAGCCTGGGCAACAAGAGTGGAACTCCATCTC AAAAAAAAGAAAAGAAAAGAAAAGAATGTATAAAATGCCTCTTATATAAATAATAATTAT ATAATAGGCGGTATTCAACAAGTAGCACCTGCTAATATAGAATTAATGGAATGACAGTGG TGATGAGATATATGTCTTCTCATTGACTTTAGGATACAGTTATGTTTGAAAGTTCAGTCT GCTTTCTTACAAAGTTTGCCAAAATTTCTATTCATGTTATTTTAAATACTTTTTCTTGGC TGGTCACAGTGGCTCACACCTGTAATCCCAGCACTTTGGGAAGCTGAGGTGGGCGGATCA CTTTAGGTCCCAGCTACTTGGGAGGCTAAGGTGGGAGGATTGCTTGAGCCTGGGAGGTGG AGGTTGCAGCCAAGATCACACCCCTTCGCTCCAGCCTGGGCAACAGAGTGAGACCCCATC TCAAAAAAAATTTTTTTTAATGTTTAAAAATACTTTTTCTTTTCAACTTTCACAGACAGA TGATAGATTGGTGTCTACAGATGGATTTATGCTGAATTTCCTTTGGGTACTGCAGCAGCT AAGTACAAAAATCAAGTTAGAAACAGTTGATCCCACGTATATTTTTCACCCAAGATGTCG GATTACTCTTCCCAATGATGAGACGCGTGTGAATGCAACGATGGAAGATGTGAATGACTG GCTGACTGAACTCTGTGAGTACTGTGTTCGTGACTCGGTCATTAAAACACTGCCCTCTTG TCTGTGTGCTAGTAGTTCCTCACAGATTGTTACCACCTCACCATAAAATGAACTTAAGAG ATAGAGAAACATAATAAAAATTAATACAGTAGGCCTGGCGTGGTGACTCATACCTATAAT CCCAGCACTTTGGGAGGCCGAGGCAGGTGGATCACGAGGTCAGGAGTTCAAGACCAGCCT GACCACCGTGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCTGGGCATGGTGGC ACACGCCTGTAATCCCAGCACTTTGGGAGGCTGAGGTGGGCAGATCAAAAGGTCCGGAGT TCATGACCAGCCTGATCACCATGGTGAAACCCCATCTCTACTAAAAATACAAAAATTAGC GGGTGTGGTGGCACGCACCTGTAATCCCAGCTACTCAGGAGGCTGAGGCAGGAGAATTGT GTGAACCCAGGAGGCTGAGCTTGCAGTGAGCCATGATCACGGCACTGCACTCCAGCCTGG GCAACAGAGTGAGACTCTGTCTCAAAAAAAAAAAAAAAACAGATACAAATTGAAAAAAAA AATCAAGTTATCATAATATATCTATAAAAAAGCCAAAACCAAAGTGATAAAATAGAATGT AAGTTTTTGAAGAAGTAGGTGATATTTAATCAATTTATTTAACCTATCTGAAGTGAATTC TGGTGATTCATAGCAAAAAATATAATACTGTTGTTCTCAATAATTCTACTTTTCAGGTTA TATTCCCAAAGTTGGAGGAAAAAGGAATAATTTTGTTTACATAAATCCTCCCAGTAGTAA CATTATTTATAATAGAAAAAAATTAGAAAAAAGAAATATGCAGGGAAACGGCTCTGGAAT CAGTAGTTTATTAACATAATTTAATACCATTTCGAGATTTAAATATTTCTGTATTGTGTT GAAAAATGGAGATTTTATACAATACATCAGTAAGGAACATCACCAAAGATTGTTGATGGG CTGGGAATGGTGGCTCACATCCATAATCCCAGCACTTTTGGAAGCTGAGGTGGGAGGAGA GCTTGAGCCCAGGAGTTCAAGACCAGCCTGGGCAAAATAAGGAAACCCCATGTCTACAAA GAAAAAAATTAGCCCAGCATGGTGGCACATGCCTGTGTTCCCAGCCACCCAGGAGACTGA GGCAGGAGGATTGCCTGAGCCCAGGAAATTGAGGCTGCAGTGATCTGTGATCTTACCACT GCACTGCACTGCAGCCTAGGTGACACTAGGTGACAGAGTAAGACCCTCTTAAAAAAAAAA AAAAAAAAAGATTGTGATGGACATCTGTATGCACATTTAACGAGGTAGGACAGAATACGG TGGTCCTTGAATGGAGCTAACAGGAATTCTCTTCTTCTTGTAGTATTGTTTAAGTTTATA ATTGCAAAAGTATCCTTAAACTTCTGGCGGGGCATGGTGGCTCACGCCTGTAATCCCAGC ACTTTGGGAGGCCAAGGAGGGTAGATTGCCTGAGGTCAGGAGTTCGAGACCAGTCTGAGC AACATGGTGAAACCTCGTCTCTCCTAAAAATGCAAAAGTAGCCAGGTGTGGTAGCACACG CCTGTAATCCCAGCTTACTAGGGAGGCTGAGGCAGGAGAATCACTTGAACCTGGGAGGCG GAATTTGCAGTAAGCCAAGATCGTGCCATTGCACTTCTGCCTGGGTGACGAGAGCAAAAG TCCATCTCAAATAAATAAATAAATAAATAAACAAATAAAAAGTATCTTTAAACTTCATAA AAATTCAAATGTAATTTTCTCTTCTGAATTCAGCTTTTTCTCTGATTGAGACATGTAATA GATTTTATTTAGGGAATGATGTTATTTTTCCTAGATGGCGATCAGCCTCCATTTTCTGAG CCGAAATTCCCTACGGAGTGCTTCTTTCTCACCCTGCATGCTCACCACCTCTCTATTCTG CCTAGTTGCCGTCGCTATATCCGCAGACTCCGGGCTATCCGGGAGCTCAATAGGTATGTG CCATGATACCGTGTCCTGGGATTGCCTGAGTTACCACTTTTTCTCAGGGGCAGGCAATTC CATTGTGAACAGTAGTTTTGAATGTTGGGGGAGGTATGTACGTTATATAGTGTTCTGTCT GCCTCCACCGCCACATCCATGTTGCTCAGTTGTCCAGAGTTCTTTACCTGGTGAAGTGAT CCAAACCTTGATTTCTGAGAGTTCTGAACCCTGGATATTTCACTCTGTTTATGGTTACTA CAGACTTCCATTAACTTTTCCCACTGGGCATACATTACCAGGAGGCACTTCAAACTTTAA AAGTTTAAAGGATCCCCTGGGTTTCAGACATACCCCTTCTTCCCTGGACTGTGAAAAAGT AACCATGGTTTCCCTTGATAACCAGGATCATTTACTCCTGCCTACATGTAATTCTCTTTT TGGCTTGTTCTGTGGCATGAGGGGTCCAAAATGGCCAGATAGCAGCCTCAAATTTCCAAT TCATTAGCACCATGGTTGTGTTTCTTACTCTAAGCATTTTTTCCTGTGTACTAACACCAA CAAACAGAAGTCACAGGAACACAGAAGCAAATATTTTTGAGCAGGTTATCTGGAATAATA ATGATGCCACTTCTGCTTTTTGGTCTAGAACCTGCGTAGTCTGTCTATGAGAGAAACTGA ATCATATTTATATCTCTGTATCTACCTTGCTTAAATCACTTACTAATTCTTTTTTTTTTT TTTTTTTTTTTTTTTTTTTTGAGACGGAGTCTCGCTCTGTTGCCCAGGCTGGAGTGCAGT GGTACGATCTCAGCTCGGTGCAACCTCTGCCTCCCAGGTTCAAGCGATTCTCCTGCTTCA GCCTCCCGAGTAGCTGGGATTACAGATGTGCACCACCACGCCTGGCCAATTTTTTTTTTT TTTTTGATGGAGTCTCACTCTGTAGTCCAGGCTGGAGTCCAATGGCATGATCTCGGCTCA CTGTAATCTCTGCCGCCTGGGTTCAAGCAATTCTCCTGTCTCAGTCTCCTGAGTAGCTGG GACTACAGGCGCCCACCACCACACCCAGCTAATTTTTTGTATTTTTAGTAGAGACGGGGT TTCACCGTGTTAGCCAGGATAGTCTTGATCTCCTGACCTCGTGATCCGCCCGCCTCAGCC TCCCAAAGTGCTGGAATTACAGGCGTGAGCCCATGCACCTGGCCCAATTTTTTGTATTTT TTGTAGAGACGGGGTTTCTCCATGTTGGTCAGGCTGGTCTCAAATTCCTGACCTCAGGCG ATCCGACTGCCTCCGCCTCCCAAAGTGCTGAGATTACAGGTGTGAGCCACCGTGCCTGGC CTAAAATCACTTACTAATTCTAATAGTTAACTCTGCAAATTCTTTATGATTTACTTTCTA CACATAATCATGTCTATAAATGATGACAATTTTATTTCTTTTACTTTTTTTTTCATGCCT TAGTGCCCAGGCTGTAATTTTTAGTACAATGTTGAATAGAAATAACCTTGAAATTTCCAT CTTGTTTCAGTTGGTGGAGGAAAGCTTTCTATATATCCTCAGTTACCAGATTAAGAAAAT TTCCTTTTATTTCAATAGTTAGTTCCCTTAGCACTGGTTGAATTTTATTAAATACTTTTG CCATATCTGTTGAGGAGACTAGACTTTTTTCTTCTCTATTCTGTTAATGTGGTTGAATTA TATCAGTTGGTTTTCTGTTATTAAACCAGTCTTTCTTTCCTGGAGTAAACTTAACTTTTA TATTAATGTTTTTATATCTAATTGGATATACAATTTGCTAATATTCTGTTTAGGATTTTT GCATCTGTTCAAAAGAAAGCCTGACCTGTAATTTTCATTTCTTGTTAAGTGCATCTCAAA TTTTGGTATCAAGGTTATGCTGCCTTATAGAAGAAACTGGGGGCTGGGCACAGTGGCTTA CGCCTGTAATCCCAACACTTTGGGAGGCCGAGGCAGACGGATCACCTGAGGTCAGGAGTT GGATGCTAGCCTGGCCAACATAGTGAAAACCCGTCTCTACTACAAAAATTAGCTGGGCAT GGTTGGCGCATGCCTGTAATCCCAGCTACTTGGGAGGCTATAGCAGGAGAGTCGCTTGAA CCCGGGAGGCGGAGGTTGTAGTGAGCCAAGACCGAGCCACTGTACTCCAGCCTGAGCAAG AGTGAGACTCTGTCTCAACAAAAGAAAAAAAAAAAGAAAGAACTGGAGAATATTCTCCTG TTTTTTATGTTCCCTGGAAGAGTTTATTGTATAAGAATTATGTTGTTTCTTCCTTAAATG TCAGAAAAAATTCAGTGATGAAGTTGTCAGGGCTTAAGAGTTTTCTGTGTGGGGATGTTT TTAATTATGGATTTAAGACAGTTAATATATATAAGACTATTTAGATTTTCATTACATCTT GTGTCAGTTTTTCTAAAGTTTGAAAATGTTTTGGCATGAAGTTGTTCATAATATCCTTTT ATCATTTTAATGTCTGTAGGATCCTTATTATTTCTGCTTTTATTTATTTATTTTAGTTTT TGAGAGGAGGTTCACTCTTGTTGCCCAGGCTTGTTGCCCAGGCAGGAGTGCAATGGTGCA ATCTTGGCTCACCTCAACCTCTGCCTCCCAGGTTCAAGTGATTCTCCTGCCTCAGCCTCC TGAGTAGCTGGGATTACAGGCATGTGCCACCACGCCCAGCTAATTTTGTATTTTTAGTAG AGACAGGGTTTCTCCATGTTGGTCAGGCTGGTCTCGAACTCCTGACCTCAGGTGATTTGC CTGCCTAGGCCTTGCTGGGATTACAGGTGTGAGCCACTGCACCCGGCCCATTTTAATTGG CTTTCTACTGCCTCTTGAGATGGATATTTAGATCATCCTTTCCAACCCTTTCGCTTATGT GTATATTTAAGACTATTTTGTTTCCCTCTTAGTGTGACCTTAGCTGCATCCCTCATTTTT GTTATATCATATCTTATTACTCAGTTCAAAATGTTTTCTAATTTTTGTTTGTTCTTATGT AACCTGTGGGTTATTTCAAAATATATTATTTAAATTCTAGGTTCTTAGGGTATTTGTCTA TGTATCTTTTGTTAATTGATTTCTAGATAAATTCCATCATGGTAAGAAAATATATTTTAT GTGATTTGTGTCTTTTGAAGTTTATTGAAATTTACTTTATAGCCTTTTACATTAGTAGAC CTGAAAAGACTGCTATCTGTGTTGTTTTTACAGTGTTCCACATATATTATTTAGGTCAAG TTTGTTAATTTTCTGTTCAAGTTTTCCTTATATCTAATGATTTTATCAGCTTATAATATC AATCACTGAGAGAAGCTTATAAAAAATTCAAACTATGATTGTGGATTTATCTGTTTCTTT ATCCTCCGATGGATTACCTCCTGGGATACAGTCACTCCCGCTGGCTTTAGAGGGTCCATT TCAATGGAACCATCTAGAACCTTTGCTCCTGGCTTGCAGCAGATAGCCTTTATTGTGCTT TCCAGAGACATTTATGTTCACCTCATCTGTGTATTTTTCAATGCTGTGATTTAAGAAGTA TCTTCTAGGACATAGTTGGGGTGTGTATATGCGTATTGGAAAGAGGATTATCTGAGCAAA TCACATAAAGTAAATCCACCTTAATTTTCCAAGCTCTTTAAGTTTTGAATCATTTCCTCT GAATTAGATCAAAGAATATTTGGCAACTCAGCTTCATTCAGTATAGGTCACTGTCAATTC AAAGTTTGGGTCAACTAGTTGGTTGCATAATATGAACCTCTCCCAACTCAGAATAATACT GAATTCAGGGTCTCTGGTAGGTATAATCATGTCAGTGATTTTAGCCCTACATAGAAGTAT ATCAGCATTTTCTTCTCTTGCTGATCAAGCATCCTCAGAATCCATTCCCATACATAATCC TACATAACCGTCATGTTTCTGCAGTACATATGTGGTTGGTAGAGTAATGGCATCTCAAAG GTGCCCACATCCTGGTCTCGGAACCTGTGAATATGTTATCTAACTTGATTAAAGGGACTT TGCAGCTGTGATATCAGGTTCATGATCTTGAGGTGGGGAGATTATCCTGGATTATGTGGG TAGGTCCAGTGTCATTGCAAAGGTCTTCATAAGAGGGAATCAGGAGGGTCACAGGGAGAG ACGGAATGTGATGGGGAAGCAGAGGTTGGAGTGGTTTGGGGTCATGAGCCAATCCGGTAA CCTCTGGAAGCTGGAAAAGGCGAGGAAACTTGTTCTCCCCTAGAGCCTCCAGAAGGAACC ATCCCTGCTGACCCCTTTTAGACTTCCAGAACTCTAAGACTATAATTGTGTGGTTTGGAG CCACTGAGGTTGTGGTAACTTGTTACAGCAGCAATAGAAAACTAGCATAACACATTAGCA AATCTTGCCATTTTTTTTCTTCAAATATGTGCTTCTGTTGCATCCAATTTTGTAATAATG CCATAAGGACAGTCCTTGATCTGACTCTAGCTGTGGTTCTGGAAGCGAAGAGGGATGATG GGTTAGAACCTAGGGGAAAATAGCATTACCCTGCAAGGTGACTATCTCTGATGAGGTCAT TATAGAAACTGCTTCTGCTAGCAAGCAAGGCTCAGGGAATTTAGAGATTTAGGTACTTGG AGTCAGCTAGTTCTCCCAAACTCCTCCATTTGAACTCTTTGGGTCCCAGTCTTTGCCTTA ACTTTCAGATAAGAGGTCCAGCAAAGTTATTAATTTCTTCTGTACTGTAATTTGTAGAAC TGGAGCTGCTCCTTTCCTTTAACAACAGTCTTAGAAACTCCTGATTAATTCACATTTCCT GGAGATAAGAATTTAAAATCTGAAGCCTGTCATTTTTTTTTTTCTATAAGCTCCACCACA TAATTAGAGGTAGCCACTCCACATCCTCATTCCAGATCACCAGGGATCATGTATATAGCT GTTTTTCTACTCAGAGCCTTGGGCTACCAGTGTTCCATCCTCAAATACTAATTGTATCTT CACCATGCAGCCCAATCAAAGAACTGATCCCAGAGCCCCATTTTTTTCATGAAGGCCTGT TACCTATAAACTCTTGTGATACCCGTAGCCATATAGGTCATTATCTTAGTTTCCTATGAC TGCAACAACAAATTACCACAACTTTAGTCACTTAAAACAACACATATTACAGTTCTGAAG GTCAGGAGTCCTAAAATCGGCCCAGCGCAGTGGCTCACGCCTGTAATCCCAACACTGGGA GGCCGAGGTGGGCAGATCACATGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTG AAACCTCGTCACTACTAAAAATACAAAAATTAGCCGGTCATGGTAGTGCATGCATGTAGT CCCAGCTACTCAAGAGGTTGAGGCAGGAGAATCGCTTGAACACGGGAGACGGAGGTTGCA GTGAGCTGAGATTGCGCCACTGCACTCCAGCCTGGGAGACAGAGCGAGACTGTCTCAAAA AAAGAAGATGAAGGTTGCATTCCCTGCAGAGGCTCTAGGGGAGAATCTCCTTTGCCTTTT CCATCTTCTGAAAGCTGCCTACGTTCCTCTGCTCCTTATCACCCCCCACCCCACCCCACC TTACTGTATTTTCAAAGCCAGCAACATAGTATCTTTAGATCTCCTTCGCTTGCCTGGTGT ATCGCAGCACTTTGGGAGGCTGAGGTGGGTGGATCACTTGAAGTCAGGAGTTTGAGACCC GCCTGGCCAACATGGTGAAACCCTTTTCTACCAAAAAATACAAAAATTAGCCAGGCATGG TAACGCACCCCTGTAGTCGCCACTACTCAGGAGGCTGAGGTACGAGAATTATTTGAACCC AGGAGGTAGAGGTTGCAATGAGCTGAGATCGTGCCACTGCACTCCAGGGCAACAGAGTGA GAGACCCTGTCTCAAAAAAGCAAAAAACAAGGCTGGGCACGTGTCTGACACCTGTAATCC CATCACTTTGGGAGGCCAAGGCAGGTGGATCATTTGAGGTCAGAAGTTCGAGATCAGCCT GGCCAACATGTTGAAACCCCATCTCTACTAAAAATATAAGTTAGCCAGGCCTGGTGGCAG GTGTCTATAATTCCAGCTACTTGGGAGGCTGTGGCAGGAGAATCGCTTCAACCCGGGAGT CAGAGGTTGCAGTGAGCCAGATGATGCCAGTTTACTCCAGCCTGGGCAATAGAGTGAGGC TCAGTCTAAAAAAAAAAGACAACAACAAGATCTCCTTCTCTCTCTGACCTTTGCTTCCAT TGTCCCATTGTCACATCTCCTTCTCTGTCTCTGAGTCCTTTTTTCTCTTAGAAGGACCTT TGTGATTATATTGGGCCCTCCAAAATCATCCAAGATACTCTTCCCATCTCAAATCCATAC CCTTAATCACATCTACAACGTCCCTTTCGCCATGGGAGATCACATGTTCACAGGTTCCCT CGAAGGATTCGGATGCGACAAGTTTGGAGGAGCCATTCTTTTGTCTACCATACTCATGTT TCAGTTGTAGACGAAAGAATCCAATTCTTCTGGGATAAGCAGAAAGGGGAACTAGTTGGT TTACTGAATCATTGGAATGGCTATAATAGAAGATTCCCAGAGCTATACTTTGAACAAGGA AGCTGCTTCGGAGGTCAGCCTGACAGCACAGCCTCTGCCACAGCTTCAGCCAAAACCCCT CTACCACTGTACTTCCAGAAGGATCATGCAATCACGCAGTCACTTCACAGTACTCACTCT GCCTTCAGTGAGGGTTCATCTTGGTGAAAACTAGGTCTTACAGAAATGCTGGCAGGAGGG GAGTCTAGGAAATGTAGCTTTTGGAGATTTAGCAGCCTCTAGTATTACACACAACATCAT GATAGAAAGGGGTTGAAATAGTGTTAAGAGAGTCGGTCTTCAAAATATGCAGCCTATTAG GTGATGGGGAAGCCTTTTACTGCAGAGACAGATGGTGTTTGAGCAGACACCTGAGGGGAG TGAAGGAGCAAAGCCAGAGATAACCTCAGAGAAGAGCATTGCGAGCAGAGGGAACAGTTG TAAAGGACGATGCCGTTAGTAAAATAGCCTTTTGTTTTGGGTAATTGAATAGGCAAAGTA ACCTCGAATTTTCATGAGAGACTTCTTTTTTTCCCTCCCAGAAAAATAAGGGAACAATGT ACTTTCTTGCAACAAAAAAGATGATTATATTCACCAAATCTGTAGTGCCATCCATTCAAA GACACATCATTGTTTTAGGAACCAATAAAAAAGAAAAATATGGCCCGACGCAGTGGCTCA TGCCTGTAATCCCAGCACTTTGGGAGGCTGGGGCAGGCAGACCACAAGGTCAGGAGTTTG AGACCAGCCTGCCCAACATAGTGAAACCTCATCTCTACTAAAAATAGAAAAAATTAGCTG GGCATGGTGGTGAGCACCTGTAATCCCAGCTACTTGGGAGTTTGAGGCAGGAGAATCACT TGAACCCAGGAGGCGGAGGTTGCAGTGAGCTGAGATTGCAGCACTGCACTCCAGCCTGGT GACAGAGCGAGACTCTGTCTTAAAAAAAAAAAAAAAAGAAAGAAAGAAAGAAAAATGCTG CCAATTAAACTATGATTTGCCGCTGGTTGTAAGATATACTCTGATTTTAAAGATGTTACA ATGCGAAAACAAACAACTGCGTGTGAGAGTCAGTGAAATGAGCAAGATGAATGGGTAAGA TGGATCCGGCTGTTTTCTTTCATTTGACTGTTAGTCTTTGATTTCAGAACTGTAGAAGAT TTGAAAAATAATGAAAGCCAATGGAAAGATTCCCCACTGGCAACTAGACACCGCGAAATG CTGAAGCGCTGTAAAACTCAGCTTAAGGTTTGTATAGCTAAGTGGAATAATTATAGACCA GCCTCATAGTGATAATTTTCCCAACAGAATATATGCCTTGAGTGAGCAGTTTAGTGTCCT CACTTTTTCTTTGTTATTCTTTTCCCTTCCAATAAAATAGTATATTTTAAAACTTGTTGA TACCTTACTTATATGTGTATATAATGATTTCAGTCTCAGGACAGAATATGGATAGATATG CTTCTGCTGTGATTATGAATTCTTAATGGGTTTTATGATTCTCAGTTTAACATCACCTCC CTTGGCCGGGCGCAGTGGCTCACACCTGTAATCCCAGCACTTTGGGAGGCCTAGGCGGGC GGATCACGAGGTCAGGAGATGGAGACCATCCTGGCTAACACGGTGAAACCCCGTCTCTAC TAAAAATACAAAAAAAAATTAGCCGGGCGTGATGGCGGGCGCCTGTAGTCCCAGCTACTC AGGAGGCTAAGGCAGGAGAATGGCATGAACCCAGGAGGCAGAGCTTGCAGTGAGCCAAGA TGGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAAAAAAAGA CAACAACAACAAAAATCACCTCTCCTTCCCTGCCTTATGCAGGGCCCTCCTCACCTGCTG TCTCCCACCCCTCGCCCCAACACTCATCCAGTATATCTAGCCATGCATTTCCATGATATT TGACAAAGAGTATCTGTGGTAGTGGAAAGATCTCTTTCCTTTGCCCCTCATTCTTTCTTT TTAATTGAAATTGATTCATCACACAAAACCTAACTATAGATGGGAATATTCTTGCTGGTG AGACATAGCTAAAAACATATGCCAGCTGACATTGTACAAATAAAGCATAGATAGCAAATT TATGCATTTTTCTTCTATTCATGTTCCAGTTATAAACCTGAGTGTTAGCTGGTCATGCAT TCTGTTGAACAGTAGGATAATATGTGGAAAGTTTACCTGACATAGCTTTCTAGTACCAGT TAAGATTTCAGTTTTATTTACTAATAGACTAGACTTCTTCAAGATGCACAATTAACAAGG GGCCCTTATCTGGGGTCTGTGCACCCCCCTAAGCAGTCCACAGATGTGTTTCAAGGGGAT CTATAAACTGCTTAAATTGCCAGGCATGGTGGCTCACACCAGTAATCCCAGCACTTTGAG AGGCCGAGGCAGGCAGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGT GAAACCCCGTCTCTACTAAAAATACAAAAATTAACTGGGTGTGGTGGCACACGACTGAAA TCTCTGCCATTCGGGAGACTGAGGCAGGAGAATTGCTTGAACCTGGTAGGCAGAGGTTGC AGTGAGCCAAGATCGCGCCACTGCACTTCAGCCTGGGCAACAGAGCAAGACTCTGTCTCA AAATAAATAAATAAGAAACATAAAAACTGCTTAAATGTATACATCAGTGTGTGCATGCAT GTGTGTGTAATTCTGTCAACAGGCCTCTAGGTAGGAATTCCATCCTTAGTGGCCAGCATT TTGCCCGAGGGCAGCTCGTAAGAGGCGACACTGGAATTCAGACACTGATTGTTTGGCTTT TTCCCACTAACCACCCTGACACCCAAAGGGCCTCCCTGTCGCCACCCTCTCCTCATCAGG TTATTTACTTGTGACTGTTGGAACTCAACATTTTGAGCTTTAACTGTGTGCTAGACCTGG TGGTACTCGGTGGTTTGCTTGCCACGCCTTTGTTTTTCTCAGGAAAAAGGTCTTGAGACA CAACCAGCATCTTATAGCTAGTTAGGAGATGAAGCTCTAGAAGCTCTGGAACCCAAATTT CCCATCTCCTGGCCCCAGTCCCTGCCCAGTCCCCCTGTAGGGACTTAGCTACTGACTGAT CTTTGGGTGGGGACATCCCTGCTTCCACAGAAACTGGTACGGTGCAAGGCCTGTGCTGAT GCTGGCCTACTTGACGAGAGCTTCCTGAGAAGATGTCTGAATTTTTATGGCCTTCTCATT CAGCTGCTGCTCCGCATCCTGGACCCCGCATATCCCGAGTGAGTGTGCTTCTTCCTGTTT CCCTTGTCCCTCCTTGGCTGGGCTCTGTTGTCTTTATTGTCCTTCAAAGTTGATAACTAA AACCAAAACCCTTTCTTTATCAAGAATTCACTTCTCTGCAAGGCGCAGTGGTTCACGCCT GTAATCCCAGCACTTTGGGGGAGGCTGAGGCAGATGGATAACTTGAGGTCAGGAGTTCAA GACCAGCCTGGCCAACATGGCGAAACCGTGTCTCTACTAAAAATACAAAAATTAGCCGGG CTTGGTGGCAGATGCCTGCAGTCATAGCTACTCAGGAGGCTGAGGCATGAGAATCGTTTG AACCCGGGAGGCGGAGGTTGCATTGAGCCGAGATCATGCTACTGCACTCCAGCCTGGGCG ACAGAGCGAGACTCTGTCCCCACCCAAAAAAAAAGATAATTCACTTCTCAGTTTCCAGAT TGCATTTATATAGATTATGTAGTTATATTGATAGGTGTTTTCCCTGTAATTAGTTACAAT AATAGGCAAATGTCAACACCTGTTATTTTAATTTTGACAAGTTTTCTTTAAAATTTGCTA TAAAGTCTTTGATTGATAGAAAGAGAAATCTATAAATTGGAAGCCAAAAGCTGGAGATAA TATTAGGCCCTCCTAAGCACTGGGTCCAGGAATACCCACCTAATTCAGAGAGTGAGCTAA GAACATTGTTGATCACTTTGTCATCAACTGGTCATCTCCTCCAGGCAAACCATTTTTGTT TTATTTATTATTATTATTATTTTACTGTTATGAAGTCTCTGGTTCACTGATGTTGGTGAG ATTGGCCCAAGACCCGTGAAGGCGTGGAAAATATTATTTAAAATATGTGTGTAGGCCGGG TGCGGTGGCTCACGCCTATAATCCCAGCACTTTGGGAGGCCAGGGCGGGTGGATCACATG GTCAGGAGATCGAGACCATCTTTGCTAACACGGTGAAACCCCGTCTCTACTAAAAATACA AAAAATTAGCTGGGCGCTGTGGCGGGTGCCTGTAGTCCCAGCTACTCGGGAGGCTGAGGC AGGAGAATGGCGTGAACCTGGGAGGCGGAGCTTCCGGTGAGCGGAGATCACGTCTCTGCA CTCCAGCCTGGGTGACGAGCAAGACTCCATCTCAAAAAAAAAAAAAAATGTGTGTAGCTC TGTTGTTTCCGTTTGAGTTGCACAAAATGACCAAATAGGACCTTTTTATTTCCTTCCCAT TTTACTTATTGCATTAACCTTAGCAAGAAGTCAAGAAGGCTGGGCGTGGTGGCTCACGTC TGTAATCCCAGTACTTTGGAAGGCTGAGGCAGGCGGATCACTTGAGGTCAGGAGTTCGAG ACCATCCTGGCCAACGTGGTGAAACACCGTCTCTACTAAAAATACAAAAATTAGCCAGGT GTGGTGGTGGGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCACAAGAATTGCTTGA ACCCAGGAGGCAGAGGTTGCAGTGAGCCGAGATCACGCCACTGTACTCCAGCCTGGGTGA CAGGGTGAGACTCTGTCTCAAAAAAAAAAAAAAAATCAAGAAAAGGGCCAGGTGTGGTGG CTCACACCTGTAATCCCAGCACTTTGGGAGGCCAAGATGGGTGGATCACTTGAGGTCAGG AGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCTGTCTCTATTGAAAATACAAAAATT AGCCAGGTATGGTGGCACGTGCCTGTAATCTCAGCTATTCGGGAGGCTGAGACATGATAA TCGATTGAACTGGGGAGGTGGAGGTTGCAGTGAGCCAAGATTGCACCACTGCACTCCAGC CTGGGTGACAGAGTGAGACTCCATCTCAGGGGAGAAAAAAAAGAAATCAAGAAAAGGAAA ACATTTCACACATACCCTTGCATATGCACTGTCTTCATTATTCCCTGTTCATTTCTGGTT GTAGTTTCTTTGCCTACATATTTATTACATAGTATTACAGAATGATTTTCTTCCCCAAAT GAAATACTTATCCGATGGTAATGTAATACTCCTTGTAGTTTGATGTACCATAATTTCATT TAATAAATTGTCCTTTTTTTCTCTTTGACAGTATAACACTGCCTTTAAATTCAGATGTCC CCAAGGTATTTGCAGCGTTGCCTGAGTTTTATGTAGAAGATGTTGCAGAATTTTTATTTT TTATTGTACAGTAAGTGCCTTTAATATTTTACATAGTTCTAATATGTTTTTATGCATAAT AGTATAATATTCTGAGCTATGTTGCAAACCTCCATTTCATGCCTGAAATTTGATGTAACT GTTTTAACTGAATGCTGCCTAGAGACTGGAAAAAATAAATCCAACTGTGGCATCAGTCCA ATTCCAATAATATCTCAAAGACAGAGGCAGGATTAACAGTGCAGATAATGTATTCCTTGA AAATTGAGTTGAATTTCTAATAGTTAAATATGTGTTTCTGAGCAACAGAAGGAGGAAACA GTTTATAAATGTCTGAATGAACATCCCAAAACCAGAAATATCCACATCTATATTTTGTAC TAAAATTTGTCTCAATTGTAAAATTGGAGAATGCTTACCAAGAAATGGTTTGAATTTCTA ACTGGTATTGTAGGGTTTTAATTTTTTTTTCAAATCCTTATTTGGTTTATCAAATTAACA TTTTATTTCTAAAACATTACAGGTTAGAAGAATTACAATTTCAATCCCTTGGCACCATGA TAGCACCTATGACTAGCTGAGGGAGTGGTATGTGAAGTCTATTGTGAAAAGTAAAAGTCA TGCTGGGCACTGTGGCTCATGCTTGTAGTCCCAGACATGCAGGAGGATTGCTTGAGCCTA GTTCAAGACCAGTCTGGGCAATGCAGCAAGTCTGCATCTCTTTAAAAAATAAATAAATAA ATAGTATAGGTCCCCAGTCACAGAATACAAATTGTGAAAGTTTTGTAACAAACAACAGGA AAAAAACAAAATTAGTATAAATGATTTTAAAATAAGGGCCAAAAGTAAATGGAGCAAGTT AATATTGCTGTCATAAAAGCTGCCTTTAAAAAAAAGCCCAAATCAAGGCAGAGGTTGCAA TGAGCAGAGATCATGCCACTACACTCCAACCTGGGCAACATACACAAAAAAACCCAAATC ATTGGTGACACGTGATTTTGATTGGTATGAAATTTTAAAAGTGACTCAAAAACGTGGTTT ATTTGTTGAAAAACCAACCTTGGAATTTAAGCAACTCAAGTCACATTTTAAAATTTGTTC TATGCACAGTGATACAAAAGACACCTATTTGAAAAATTTCATTTATTCTCATTTTCAGCA GAGATTAAAAAAAAACTATCAAAATTTTTATGTTTTGGTAGTGATGATCTTTTGTGAAGT TTATCTGATTTGATCATAGGTTTTGTTTATAGTTAATATAACATGCTACAGCCAGTAACC ATGTTTGGTTTTAAATCTGTCTTGTTACAGTGTGAATAGTCACTGTAGGCTGGGTGCAAT GGCTCATGCCTGTAATCCCAGCACTTTGGGAGGCCAAGGTGGGCAAATCACGAGGTCAAA AGATCAAGACCATCCTGGCCAACATGGTGAAACCCCATCTCTACTAAAAATACAAAAGTT AGCTGGGCATGGTGGCAGGCACCTGTAGTCCCAGCTACTCAGGAGGCTGAGGCAGGAGAA TCGCTTGAACTTTGGAGGCGGAGGTTTCAGTGAGCCGAGATTGTGCCACTGCACTCCAGC CTGGGCAACACAGCGAGGCTCCATCTCAAGAAAAAAAAAAAAAAATAGGCTGGGCGCAGT GGCTCATGCCTGTAATCCCACCATTTTGGGAGGTCGAGGCGGGCGGATCACGAGGTCAGG AGATCGAGACCATCCTGGCTAACATGGTGAAACCCCATCTCTACTAAAAATACAAAAAAA ATTAGCCGGGCATGGTGGCAGGTGCCTGTAGTCCCAGCTACTCGGGAGGCTGAGGCAGGA GAATGGCGTGAACCTGGGAGGCGGAGCTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC AGCCTGGGCGACAGAGCGAGACTCTGTCTCAAAAAAAAAAAAAAGTCACTGTAAACTGAA TGAGTTCAAGGGCACTCCCAAACCTACTTATCCTGCCTTCCCCTCCTCACTTACTGACAC CAGCCTTCACCCAAGATGAGTTTCTCAGCAGTTTCTCAGCGGTCTCTTTCTTGCTCTTCT TGCCTCTGTTCAGATACTCTCCCCAGGCGCTTTATGAGCCCTGTACTCAGGATATTGTGA TGTTCCTTGTTGTGATGTTGTGCAACCAGAACTACATCCGAAACCCATATTTGGTGGCCA AACTGGTAGAAGTCATGTTTATGACCAACCCTGCTGTTCAGCCACGAACCCAGAAGTTTT TTGAAATGATTGAGAACCATCCTCTCTCCACCAAGTTGTTGGTACCTTCCCTGATGAAGT TTTATACAGGTAGGTTGCTGGAACACAGTGTAGCACATGGCAGGCCAACTTAGGTAAGGT CATCTAAAGCTAGTGGACGACGTTGCTCTAAGCCTGTTACCTAATATCCTGCTACCTGTG TGTATAGCCTACTAACCTGTGGCCTGCAGAGGATGTACTTTTGGTTCTTCTTGCCCTGAG TAGTTAGGAATAGGACAACCATTCCACCTACTGGTCTCTGATGATTCAGCAGGAACTACT GAAAGTCAGATGATTGGCACCGAGACCCAGGGTATCAAGAGCACAAGTTGGTAGTGTTAT CTGAATGGAATTATCTGGTTCATTTTACCTTTGAACTTACAGCATTTGTTTTTTAACACT ATCCTATAACCCACTTTCCAAAGTGTGGGTGAAACAGGGAGCTTGTTAAAAATGCATATT CTTGGTCCGGGTGCGGTGGCTCATGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGG CGGATCACAAGGTCAGGAGTTCAAGACCAGCCTGGCCAGTATGGTGAAACCCCATCTCTA CTAAAAATAGAAAAAAAAATTAAATTAGCCGGGCATGGTTGCAGGTGCCTGTAGTCCCAG GGCGGTTGAGGGAGGAGAATTGCTTGAACCCGGGAGGCAGAAGTTGCAGTGAGCCGAGAT CCCGCCACTGTATTCCAGCCTGGGCAAGAGAACAAGACTCCGTCTCAAATAATAATAATA ATAATAATAATAATAATAATAATACCACTTTTCACCTGTCAAATTTATTTCTTAAGTTGA AAATACCTGGTACAAACATGGTTGTGGAGAAGTAAGCTAACCTGCAAAAAAACCTGCTTA ATCTACCCTATAGCCAGTGTGCAGATTTAGTGCTATGAAACTCTCATGAGAATGCAAATT TAAAGCCTTTCTGAAAGGCAGTTTAGCAGCCCACACCAAGAGCCTTAAAAATGCTTTTAT CGGGGCCAGGTGCGGTGGCTCATACCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGT GGATCACCTGAGATCAGGAATTTGTGACCAGCCTGGCCAACATGGAGAAACCCCGTCTCT ACTAAAAATACAAAAATTAGCTGGGTGTGGCGGGCGGCGCCTGTCATCCCAGCTACTCAG GAGGCCGAGGCACGAGAATCGAGTGAACCTAGGAGGCAGAGGTTGCATTGAACTGAGATC ACACCAGTGTGCTCCAGCCTAGGAGAAAGGGCAAGACTCCGTCTCAAAAAAGAAAAAAAA AAAGCACTGGGATAACAAATAGTAGGTGCAGGAAGTAGCCATCTTCTATCCCTCAGTCTG GGGACCCAAGGGAAGAGCCTGGGGATCTCAGAACCCAGCTGCCCTGATGAGGGCTTGGAC GGAGCTAGGACCCAGTCCTCTGTGGAAGGCCCTTGGCCAGTAGGTGCTGGTGTCTCTCTC GGGGGTTGTGCACGGTTGCTAGCTCTGGGGGTACGAGACAAAGCTGAAAATTGGAACCAA CTGCTACTGCTGACAGTAAGTGCAAGGTCCTAAGTCCCTTGTTTCTCCTTCAGTTTTCCA GTTCTCCTGCAGCACCCCCTATTGGCAACCCTAGAGAGGGCGGGCTGCCAAAGGAAAGAT TCTGCAGTGCCAGCCCCAGAATCACAAAGCCAACTACAAAGAGTGCATGTGGGCTGGGCA CGGTGACTCCAGCTAATAATCCTAGCACTTTAGGAGGCCAAGGTGGGAGGATTGTTTGAG CCTAAGAGTTGGAGACCAGCCTGGGCAACATGGCGAGACCCCATCTCTACGAAAAATTTA AAAATTAGATGCCTGTTGTCCCAGCTACTAAGGAGGCAGAGGTGGGAGGAAGGCTTGAGC CCAGGAGTTCAAGGCTGCAGTGAGCTATGATCTTGCTGCTGCGTTCCAGCCTGTGAAACA AAGCAAGACCCTGTTTCTAAAAAAAAAAAAAAAAAAAAAAAAAAAAGGGTAAAAAGACTG GGTTTCGGCCAGGCACAGTAGCTTACACTTGTAATCCCAGCACTTTGGGAGGCCAAGGCA GTGGATCACCTGAGGTCAGGAGTTCGAGACTAGCCTGACCAAAATGGTGAATCCTAGTCT CTACTAAAAGTAAAAGGCCGGGCGTGGTGGCTCACGCCTGTAATCCCAGCATTTTGGAAG ACTGAGGTGGGTGGATCACAAGGTCAAGAGATCGAGATGAGCCTCGCCAACATGGTGAAA CCCCGTCTCTACTAAAAATACAAAAATTAGGCCTGGCACAGTGGCTCACGCTGTAATCCC AGCACTTTGGGAGGCTGAGGTGGGCGAATCACCTGAGGTCGGGAGTTCAAAACCAGCCTG ACCAACATGGTGAAACCCTGTCTCTACTAAAAATACAAAATTAGCCTGGCATGGTGGCAC ATGCCTGTAATCCCAGCTACTTGGGAGGCTGAGGCAGGAGAATCACTTGAACCCGCGAGG CAGAGGTTACGGTGAGCCAAGATCGCGCCATTGTAATCCAGCCTGGGCAACAAGAGCAAA ACTCCGTCTCAAAAACAAAAATTAGCTGGACATGGTGGCATGTGCCTGTAGTCCCAGCTA CTCGGGAGGCTGAGGCAGGAGAATCTCTTGAACCCGGGAGGCAGAGGTTGCAATGAGCCA AGATCGCGCTACTGCACTTCAGCCTGGTGACAGAGCAAGACTTCATCTCAAAAACAAAAC AAAAAACAAAACAAAACAAAATTAGCCGGGTGACGCATGCGTGTAATCCCAGCAACTTGA GAAGCTGAGGCAGGAGAATAGCTTGAACCCGGGAGGTGGAGGTTGTAGTTAGCCGAGATC TAAAAAAATTTTAAAAAAAAAGAGTGGATTTGGAGCTACGAGACAACAGCTGAATAGCTA TACTCTGACATAAGAATTTAATTTCTTGAAATTTATTCAATGGAAATAATTACGAATGTT TGTAAGTGATGTTCTCCACAGCATTATTTATAAAGCAGTGCAGTGAAAATAATAAAAACA ACTGGCCGGGCTCAGTGACTCACGCCTGTAATCCCAGCACTTTGGGAGGCTGAGGCAGGA GGATCACCTGAGGTCAGGAGTTGGAGGCTTAGTCTGGCCAAAATGGTGAAACCCCGTCTC TACTAAAAATACAAAAAAATTTAGCTGGGCGTAGTGGTGCACACCTATAGTCCCAGCTTC TCTGGAGTCTAAGGCAGATGAATCACTTGAATCAGGGAGGCAGAGGTTGCAGTGAGCCAA GATCGTGCCATTGCACTCCAGCCTGGGCTACAAGAGCAAATCTCCATCTCAAAAAAAAAA AAAAGGAATGTAGGGAAGGACATATACCAAAATAGTAACAGCGCATTGGTTATTTTTGAA TGGTAGCATTATAAATAGTTTTTATTTTTATTTTATTATCTGAACTTCTTAATTTTTCTA CAGTAAACATGTATTGTTAGTAGTAAAGACAAAACAATTTTAGTTAAATTTATTTTGTAG TCAGTGTTCTGGGCCTGTCACTGTGGCTTCAGGAGAGAGAGAGAGAGAGAGAGTGTGTGT GTGTGTGTGTGTGTGTGTTTGTGTATTTGTGTTTACACAACAGAACTGGGCCTGTTGCCT ATAAGACGAGTGCTGGGCCTAGTGGAGTCCTGCTGGGAATGTTCCAGAAGGAATTGGGTG GGGGTTGTTCTCTCTTTCCTCTTTGCCATGTGTGCCCTCTGGCCTGGACCACCTCTTCAG TCATAGATGGATGACATCTGTACTAATAATAGCCACCACTTATTGAATGCTTACTAATCC TTTCACTTAATCCCCACGGCAGTCCTAAAGATAGTACTATAAATACATCCACTTTACAAA TGAGGAAACTGAAGCTTAAAAGGGTCAAGAAGCTTGCTGAAGGTCAGTGGCTAGCAAGTG GCAGCAACCTCGCAGATGCCCTTTAGCACAGGTCCCCCTGGCTACTGTGCTGGTCTTCCT ACAGCTACTAAGGGACCGGTGTGAGGGTACCCCTGAGGGAGGCATCACAGACATAGTCCC CAGTGCTCATCACCTCCATGTGAAGACCTGGCTGATTAGGTCCTGGTCCCTGAGCAGATG GGACCCTCAGATATAAATTAAAAGTTGCCACACACAAGATCAGTATGTGGAACAAGCTCC TCTTAACACCACAGAGATAGTATTCTAGCTTAGAAAATGCTCAAGTTAGGCTGGGCGTGG TGGCTCACGCCTGTAATCCTAGCACTTTGGGAGTCCGAGACAGGTGAATCACTTGAGGCC AGGAGTTTGAGACCAGCCTGGCCAACATGGCGAAACCCTGTCTCTACTAAAAATACAAAA GATTATCCGGGTGTGGTGGTGGGGGCCTGTAATGCCAGCTACTTGGGAGGCTGAGGCTGG GGAATTGCTTGAACCGGGACCTGGGAGGTGGAGGTCGCAGTGAGCCAAGATCTTGCCACT GTACTCCAGCCTGGGCTACAGAGTGAGACTCCATCTCAAAAAAAAAAAAAAAGAAAGAAG GCAGCAAGAATACCTGGGGGGAGGAGGGAGAGGTTCAACACAAGTCTAGTCCACCTACGG CCTTCTAGAACAAGGACCTGGGAATTAGAACTTGGGCTGGTATGACTTTGAGGGAACAGT AGAAGTGAATAAGAAGAAAAAAAAACTGTTGGGAGAAATGTATATTGTTTTGTTTCATTT TCTTTTCTTTTTTTTTTTTTTTTTTGAGCTAGGGTCTTGCTCTGTCACCCACGCTAGAGT GTAGTGGTACAATTACAGCACCATGCACTCTTGACCTCCCGGGCTCAAGTGATCCTCCTA CCTCAGCCTCCCCTGTAGCTGGGACTGCAGGCATGTGCCACCACACCCAGCTAATTTTTG TGGTTTTTGTAGAGACGGGGTTTCACGATGTTCACCAGGCTGGTCTCAAACTCCTGAGCT CAAGTGATCTGCCCACCCGGGCCTCCTGAAGTGCTGGAAATACAGATGCGGGGCCCTGCT GAGATACATATTGCTACATAATAAATTAACATTTACTTAGTCTCTACTATATTCAGAATT GGGTGCAGATATTGGGGCATTTTAGATGATATGAGGCGTTGGGTTGGTCCTCCTGTATCT TCCTCTTGTAGGCTATCCTTATGTCAACACTCCACACTTTAGCTCATGCTTTTATACAAT TAATAAATGACATTTAGTTTATTTTAAGGAAAGGTTACTTAATGAATATACATAAGTACT TTCGGATCTTAGTATGATAGGTGTTAATTATCTTATTTTATTTTTAAATAGCTGTTTCCT TTTTTGGTCACACACAAAAAAATGTGTTCTTTGGAAAATACAGAAAATATCAAAGACAAG GTATAGTGGCTCACACCTGTAATCTCAGTACTTTGGAAGGACGATGTAGGAGGATCGCTT GAGGCAGGAATTTGAAACCAGCCTAGGCAACATAGTGAGACCCCATCTGTAAAAAAATTA AAAGTGAAAAAAAAAATTTTTGAGACAGAGTCTTGCTTTGTCGCCCAGGCTGGAGTGCAG TGGCATGATCTTGGCTCACTGCAACCTCTGTATCTGGATTCAAGCAATTCTCCTGCTTCA GCCTCCTGAGTAGCTGGAATTATGGGCACACACCACCATGCCCTGCTAGTTTTTGTATTT TTATTAATAGTAGAGGCGGGGTTTTGCTATGTTGGCCAGGCTGGTCTCGAACTCCTGGCC TCAAGTGATCTGCCTGCCTCGGCCTCCCAAAGTGCTGGGATTATAGGCGAGAGCCACCAC GCTCAGCCATAAAAAATAAGCCACGCGTGGTGGATACACCTCCAGTCCCAGCTACTTGGG ATGCTGAGGTGGGAGGATCACTTGAGCCCGAGAGGTTGAGGCTGCAGTGAGCCATTATTC ACACCACTGCACTTTACCCTGGGTGACAGGGCAAGACCCTGTCTCCAAAAAAATAATAAT AAAATAGTTGGGCACGGTGGCTCACACCTGTAATCCCAGCACTTTGGGAGGCCAAGGTGG GTGGATCATGAGGCCAAGAGATCGAGACAATCCTGGCCAATATGGTGAAACCCCATCTTT ACTAAAAATACAAAAATTAGCAGGGCGTGGTGGCGCATGTCTATAGTCCCAGCTACTAGG GAGGCTGAGGCAGGAGAATTGCTTGAACCCCGAGGCAGAGGTTGCAGTGAGCTGAGATCG TGCTACTGCACTCCAGCCTGGCGACAGAGCGGGACTCTGTCTCAAAAATAATAATAATAA TAATAAAATTTGTCATGAATTCTGAAATTTCTCATGCCTAAGCTTTTGCCATTTGGACAA ACAAGTTTGATTTTTATCCCTCTTTAATAGATTTAGGGATGATAGACACATTGGTGTTTT TTCAACACCAAAAATGGTCAATAGATAGACACATTTAGTAAATACATGGCCCTCAATAAA ATTAAACCTAACTTTTTATCCGCTGAAGTATGTCCATTTGAGGTGCCATAGAATTTCTGT AAATTAATAACTTAAAATTAGGTGGGGGGAGTATGATAATTCAGCTTTTGGTCATTGGTA AGTTGATGTTGTCCTAATGATGGGAGTTTTCCTAGCCCCGTTCCTTTAGGTGTTGTGTCA TTGTCAAATCTTCATTGTGAAACTTTTGTCTTTAAAAGCAGCTTATAATTTCTGTCGTGC CCTACATGCAAAAGAAGTGCAAAATTTCACCAGCTCTCTGATTTTGCAGGTTTACATTCA CTCAGTATCATTGTTGGGGCAATAACTGGATTTGGAAAGCAAGAAAATACATATCCCTCA GTACCTTTGTCTTTCTTCTTTAGATGTTGAGCATACCGGAGCCACCAGTGAGTTTTATGA CAAGTTCACAATTCGCTATCATATTAGCACCATTTTTAAAAGCCTTTGGCAAAACATAGC TCACCATGGCACCTTTATGGAGGAGTTCAAGTGAGTATGGGGCCCCTCGTGTCACAACTT GCTTTCTTGCAAATCGCAGGTAGGATTGCAGCTTAAAAGCATGCACAGCTGGGTTCTTGT TGACTGTTTGCTTGGTCTCAGACTCCTTTGAGTTTACCACAAGATGCCACTAAATGTGGG CAGGATTTTTTAAATGGCTTTACTTGCAAGATATTGCTGAATTTTAGATTTGTCAAGATA CTTTGGGGGTGGTACACAAGCGAAGATTGTATAGGGCAGGGCGTGGTGGCTCACGCCTGT AATCCCAGCACTTTGGGAGGCAGAGGCGGGCGGATCACTTGAGGTCAGGAGTTCAAAACC AGCCTGGCCAACATGGTGAAACCCCATCTCTATTAAAAATACAAAACATTAACTGGGTGT GGTGGCGCACGTCTGTTATCCTAGCTACTTGGGAAGCTGAGGCAGGAGAATCACTTGAAC CCGGGAGGCAGAATTTGCAGTGAGCCGAGATTGTGCCAGTGCTCTCCAGCCTGGGTGACA GAGCGAGACTCCGTCTCAAAAAAAAAAAAAAAAAGGAAAAGAAAAGATCCTATAAATATG CTGAGATGATGGGTTAAGTGTTTTTTTGGTGTTTTCTACGATGACAGTGTTAAATGAAGT TGTCAGAATGAGTGAAATGAAATCTTAGTTCCTGAATGTTGGAAGGACTTTAGATTTTGC AACAATTAGGTCAGAGTTGTCATTTAAAGTATCATTCTTTGTGGTAAGGCCCTAAACCTT AATTAAAGACTTTTCATATACCTACCTGAAATCTGAGTGACTGCTTAAACCTGGACATTA GTAATTCCATCTAAATTATCTGTCAGTGCCTAAAAACAAAAGGGAGATGAAGATGCTGAA CTCTTGAATTATTCTTCAAAAATTTTATCCCATCTAAGGGCCGGGCGTGGTGGCTCATGC CTGTAATCCCAGCACTTTGGGAGGCCGAGCAGGGCGGATCAGGAGGTCAGGAGATCGAGA CCATCCTGGCTAACATGGTGAAACCCCGTCTCTACTAAAAATACCAAAAAATTAGCCAGG CATGGTGGTGGGCGCGGTGGCGGGCGCCTGTAGTCCCAGCTACTCAGGAGGCTGAGGCAG GAGAATGGCGTGAACCTGGGAGGCGGAGCTTGCAGTGAGCCGAGATGGTGCCACTGCACT CCAGCCTGGGCGACAGAGTGAGACTCCGTCTCAAATAAATAAATAAATAAATAAAAATTT TATCCCACCTACTTGGATCTTTTGCAACCCATGTTAGATCTTTGATCAAATCTAGCTATA CTTGTTAACCGAATTACTAGTCAATAATATACAAATTACCAGTGGAATAACTATTTGCCA GATAGATTTCTGTGAAGCAAACTTTTTAACTTTTTGTTTCCATAAACTGCTCTTATGGTC AGAATTGTGTTCCAGCTAAAGCCTGGCACGAGGCAGGCCCATGGCTTGGTCTGAATGGTG CTGATTGGAGCGCTTGTCCTGAACTTGCCATGTTCCTGAGATCGAGGCCTCCTGCACTTG TTCACAGGAACTTCTCTTCTCCAGCATGGGCTTACCACCCCGTAGTTGCACAGTTGTAGA CCCTGAAGTGTAGCTTCTTTTTTTCTCTACGAATCTGGCATCTCCAGAGTCTAACAGAGG TAGGCCAAGCTATTTCAGTTCACCAGCAAGTTCTCATTATAACACGATCTGCAGAACAGT TCCTTAGATTGGAGGCTTCCAGTTTTAAAGTAAGTTAATATCCCACTTTATCAATATTAC AGGTTCCAATTTTTCTTCCATGCGTCAGTCTTTGTGATAAGGAATAACTATATCAGTTGT TTTCTTATCTGTTGTATGTGGTTAATTATTTGCATTTTCTTGGTATATTGGTGAGTATAT GCGTTTTTCCTGTTCTAGTCTGGAAGAAGTGTTTTCTCTCCTTAAAAACATTGAGGGAGT GAGCTAGGGGTGTGCTGGTAAGCCTGCTCTGGGAAGCAGGGTGGGGGAGTCAGCATTTGC TGGTTTTCCATGGTGTGACTGTTTCCTCTGTTGCCCAATTTAAGGTGCCAGGGGAATCTG GTTATAAAATTCTGGAATATTTAGCACTTGACTGTCATCAGCCGTGCAAGGTGGCTCCAA ATACCACTGGAATGAGCTTATCATAAACAATTTAAAAGAATAACAAAATCCAGGCCAGGT GTGGTGGCTCATCTCTGTAATCCCAACATTTTGAGGGGCTGAGGTGGGAGGAACGCTTGA GCCCAGGAGTTTGAGACCAGCCCTGGCAACATAACAAGTCCCTGTCTCTACAAAAAATAC AAAAGCTGGGCGTGGTGGTGTGTGCCTGTAGTTCCAGCTACTTAGGAGGCTGAGGCAGGA AGATTGCTTGAGCCCTGGAGGTCGAGGATGCAGTGAGCTGTGATTGTGCCACTGCATTCC AGGCTGGGCGACAGAGTGAGACCCTGTCTCAAAAAGAAACAAGATTAACATAATCTAAAG AGAAGCTTGGTGGTCCTTGAATTCCATAGTGCCTGACTTGTGCCAGGGTAGCCAGGCTTT TAGGGTGAGATAGTTGCAGTCTGGGTGGAGGTGCTTGTTCCCTGGGATTTGCTGTGGCAT TTTGCTTCAGGGAGATGTATGACCATGTACAATATAATTGCCTTTCCAGCTCCGGGAAGC AGTTTGTTCGCTATATAAACATGTTGATAAACGACACGACGTTTTTGCTCGATGAAAGTC TGGAGTCTCTGAAGCGAATCCATGAAGTGCAGGAAGAGATGAAGAACAAAGAACAGTGGG ACCAGTTGCCCCGGGTGAGGACGTGGTCCAGAGGCTTGGACAGCTTTGCAGGCCATCTGC CTCCACACACGGGCAGAGCTGCTTTGGGGCTGCATTTGTGGGTCTGATGATATGCGATCT GACATGCTGGGATTTTCCTTCCATGAAATCATATTGCAGGATTGGAATAGGAAAATTCTT AAATACCTTATCTGAAGCTAAGAAATGGGTTGAGAAGTCTTTGAAAATGTACACTGAAAA CTTTCTCTGCCTTTTTAATTTTAAAGGGCTTTTTTGGAGATGAGCTTTTATTGTCTGAAT ATATTAATATTCATGAACATAATTAGGAAAGAAATCTCTAGAATTATGTCTGCTGGACAA GAATTTGATTTGTTCCTATGGGCTTCTCTAGGCAACTGTGTGAATCACTCAGGATCCTGG CGGGGTGTTTTTTCCCTTTCAGTTGATCTTGGGTTTTATATTCAGTTATTAATAGAAAAG AGGCCTGGCTTGCCAGGTTCCATGGAAAGCACGTGCCGTGCCAGTACCAGTGCTCTTTCC TGACGTGCGTAGCAGCCACTGAGATACTTCCTTGGTCGCTTATGAGGCCCTTGACAGTTG CTGGTGACTTCTTAGATTGGCTTAGGTTTATTGATTCTGTTCTTGGAATTGTCAGGCTCA GAATCAGAACTGATTTCCATAAGGGGTTCTCATGTCAAAGTGGGGACTGCTTTTTCTTCA CTTTTTCTTTTTTTTTTTTTTTTGAGACGGAGTTTCACTCTTGTCGCCCACGCAGGAGTA CAGTGGTGCGATCTCTTCTCACTGCAATCCCCGCTTCTCCGGTTGAAGCGATTTTCGTGC CTCAGCCTTCTGAATAGCTGGGATTACAGGCGCCTGCCACCACACCTGGCTAGTTTTTGT ATTTTGTTTGTTTGTTTTTGAGACGGAGTCTTGCTCTTTCACCCATGCTGGAGTGCAGTG GCACGATCTCAGCTCACTGCAATCTTTGCCTCCTGGGTACAAGTGATTCTCCTGCCTCAG CCTCCCAAGTAGTTGGGACTACAGGCACCTGCCACTACGCCTGGCTTATTTTTTGTATTT TTAGTAGAGATGGGGTTTCACCGTGTTAGCCAGGATGGTCTCGATCTCCTGACCTTGTGA TCCGCCTTCCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCATTGCACCCGGAC AATTTTTGTATTTTTAGTAGTGACGGGGTTTCACCATGTTGGCCAGGCCTGTCTTGGACT CCTGACCTCAGGTGATCCATCCGCCTCAGCCTCCCAAAGTGCTGGGACTACAGGCGTGAG TCACCGCGCCCAGACTTTTTTTTTTTTTTTTTCTTTTTTAATTTCAACTTTTATTTTAGA TTCAGGGGATGGGGTACATGTGCAGGTTTGTTACATGGGTATACCGTGATGCTGAGGCTT TATGATTCAGCCTGTCACCCAGGGAGTGAGCATAATACCTAATAGGTAGTTTTCAACCCT CACTCCTCCCTCACTCCCCTCCCTTGTAGTCCCCAGTGTCTGTTATTCCCGTCTCCGTCC ATGTGTACCAATGTTTAGCTCCCATTTATACCTGCTTTTCTTCTTATGTATTAAAGTTCT ACCCATTCTCTGAGTAAGGTCCTATCCAAATACTCCCTCAGGTTTGTCTTCGCCAATCAG CATAGCTGAAAATTCTCACCTTTCTCCTTACTTCTGTAACACCCACTTTATACCATTCAC AGTGCTTGGTATGCCCAGCTTATATTTTATTTACTTATTTGTTTTTTATTATTATTAATA AATAAAGACAGAGTGTTGATCTGTCGCCTTGGCTGGAGTGCACTGGCAGGATCATAGCAC ACCACAGCCTCAACCTCCTGGACTCAAGTGATCCTCCTGCCTCAGCCTTTGTAGATCCAA AGAGCTGGATCTACAAGCATGTACCACCACGCTTGGCTAATTAAAAAAATTTTTTTTATA GAGACAAAGTCTCACATGCTTGCTTCAGCAGCACGTATACTAACATTGGAACAATGCAGA GAAGATTACCATGGCCCCTGCTCGAGGATGACATGCAAATTCATAAAGCATTCCATCCTT TAAAAATAAATATTAGGCCAGGGGTGGTGGCTCACGCCTGTAATCCCAGCACTTTGGAAG GCCGAGGCGAGTGGATCACAATGTCAAGAGATCAAGAACATCCTGGCCAACATGGTGAAA CCCCGTCTCTACTAAAAATACAAAAATTAGCTGGGTGTGGTGGCACGCCGCTGTAGTCCC AGCTACTTGAGAGGCTGAGGCAGGATAATTGCTTGAACCCGGGAGGCGGAGGTTGCAGTG AGCCAAGATCGCACCACTGCACTCCAGCCTGGGCGACAGAGTGAGACTCCGTCTCAAATA AATAAATAAATATTAAAGAGAGAGAGTCTTGCTAGTTTTCCCAAGCTGGTCTTATATTTT ATTTACTTACTATTTTTATTATTAAATTATTTTTTATTTTATTTTATTTTATTTTTTGAG ACAGAGTCTCACTCTGTCACCCAGGTTGGAGTGCAGTGGCGCAATCTTGGCTCAATTTAT GCCTGCTGGGATTACAGGCGTGCACCACCACGTCCGGCTAATTTTTGTATTTTTAGTAGA GATGGGGTTTTGCCACATTGGCCAGGCTGGTCTTGAACTCCTGGCCTCAAGCAATCCACC CACCTCAGCCTCCCAAAGTGCGGGGGTTACAGACATGAGCCACCATGCCCAGCCTTATTA TTATTTTTTAATAGAAACAGAGTCTTGACCGGGCACAGTGGCTCATGCCTGTAATATCAG CACTTTGGGAGGCCGAGGCCGGCAGATCACCTGAGGCCAGGAGTTTGAGACCAGCCTGGC CAACATGGTGAAACCCAGTGTCTACTAAAAATACAAAATTTAGCCAGGCATGGTGACAGG TGCCTGTAATCCCAGCTATTTGGAAGGCTGAGGTGGGAGAATCACTTGAACCCAGGAGGC AGAGGTTGCAGTGAGCTGATACCATGCCACTACATTTCACATTTCAGCCTGGGCAACAGA GCGAGACTCCGTCTCAAAAAAGAAAAAAAAAAAGAAAGAAAGAGTCTTGCTCTGTCACCC AGGCTGGAGTGCAATGACAGATCTTAGCTCACTACAGCCTACAACCTCCTGGCCTCAAGC AGTCCTCCCACCTCAGCCTCCCAAAATGCTGGGATTATAGTTGTGAGCCACCATGGCTGG CCAGCGTATATTTTAGATGTTGGAATGCAGGTCTATAGCACATTCTCGTATTCATAGTCA GTACTTAATAGCATTTGTTTATGAGCCAACTGAACAAATAATATTGATTTTTCCTGTGTT AATGGATGAAAAAGGCCCAAATAATTCCCACAATTGCTATTTCAGAAATAATTTTTATTT GGCTTTGAAGTCACTTTCTACCTCCCACTGCCCTGGCTGTTCCTGCTCATCTCCCTGACG TCTGAGCTTGGTGAGCTCCAGCACTCAGCCCTTAGGCTTCAATTTCTTTCCCACTCATGC TCTCTAGGTTAGTGTTTCTCAACGAGGGCACTAGTTGGAATTTTGAGCCTAGTGGAATTT GGTATAATAATAACTCATGATGAGAAACCATCCCATATATTGCAGGACATTTAGGATCTC TGTTTCCTGCCATTTAATGTCAGGGATGTACCCTCCTACCCCCAGCCTTCAGGCAACGAG AAACACTGCCACACATAACCTGATGTCCCCCGGTGAACATCACTGCTTGGTGAGCTCAGG TATACCAAGGCATTAAATACCTGTGTTCTAAAGACTCCAGAATATATCTCCCTGGCTCAG ATCTGACTGCAGACTTGCAGACCAAGTATTTGTCTAATCAGTGTCTCAAACTCACTGTGT CCAAAACGGAACCCTTGATGTTGTCCACATCTCCTGCCTGAGTCTGCCCAATCTCAGTAA ATGGCGCCTTCATTCTACCAGCTGCTCAGGCTCGATGCTTTGGAGTTGCTCTTGATTTCT CTGCGTCTCTCAGCAAATGCCTCTAAGCTCTGTCTTAAAATATATCCATTATCTGACCTC TTCTCAGCACCTCCAGACCGTTGGCATCTCTTACCTGGGTTATTGCAGTAGCCCACTGCT TGGTCTTCAACCTCCACTCTTGAGCATGTCCATATCAGGGATGGTGTTAAACATCTCAGT CTGATCAACATCACCACTCAGCTCAGCCATTTTGGGCTTCCCTTATCACTCAGAGCCAAA TCCTGTGGTGAGAGCAGCCTACAGCACGCAGGAGGACCTGGCCCCACAATGTGTTTCTGC TCTCAGCTTTGGACAGTCTCTTCTCCACTCACTCTACCCCAGCCAGACTCACCTCCTGGC CCTTCCACTGACACGTGAGGGCCTTTACACCTGCTCTTCCCCCTACCTGGAATGCTCTTC CCTCAGATTTTCCGACTCCTTCAGATATACCCTCCCTCAGGGATACCTTCCCTGACCACC CTTTCCAGAATAGCATTCCCTGACTCCTGACCCTGCTTCATTTTTCCTCATCACTGTCAG ACTTACTGTGTGTCTGTCTGGGTATTTGTTTCTATGAAGCAGATCCTCCCTAACGGAATC TAAGCTGCATGAGAGCTGGGAGCCTTTTTATTCTATCTCCAGTGCCCAAAGGCTGTAGAA GGGCCTGTTGAGACACCCAGGTACACATTTAGGTAGTTCACGCCTGGCTGTTCTTGTGTC TTTCCTGGCTCTGCCTTTCTTTCAGTAGGCTCATTCTTGACCAGGGAACGGCAGGCCCCC CAGTATCCCTGCAGAATCTCCATCAAGCACAGACTGGAGCACTTTCCCAGAGGGCACTCA CCGGCCAGCTTCAGCTCTGCCAGCTGTGTTCCTTTCCCAACAAGAAAAGGCCTCTGAACA GATGTAAGAATTGAGGCTTTTCCTGATGGGTCTGTGTTTGACCCATTTCAGAGCCTGCAG TGCAGTACCTGATTGTATCCATGAGTCAAACAGCTCTTATTATCTCCTCCCCAGCCCATG GCAGAGTTGAAGGAGGAAAGTGCGCCAGAGGTAAGCGTGCTGACAGTTCTGTGGTGTGAC AGCCTCACAGTTTGGAAAGACAAAATTTTAAAAGCTTAGTAGTCCACAGGCACTTGTAGA GGCAGAGAGGCAGACCCGATAGGCCTCAATACGGTGGCACACTGCATCTCATAGTTTTAA AATAATGAAGACTGGCTGAGCACGGTGGCTTACACTTGTAATCCCAGCACTTTGGGAGGC CTAGGTGGGCAGATCAGTTGAGGTCAGGAGTTTGAGACCAGCCTGATCAACATAGTGAAA CCCCATCTCTACTAAAAATACAAAAATTAGGCCAGGCGCATTGGCTCACGCCTGTAATCC CAGCTCTTTGGGAGGTTGAAGTGGATGGATCACCTGAGGTCAGGAGTTCAAGACCAGCCT GGCCAACATGGCGAAACCCCAATCTTTACCAAAAATACAAAAATTAGTCAAGCATGGTGG CACGCACGTGTAATCCCAGCTACTCAGGAGGCTGAGGCAGGAGAATGGCTCGAACCCGGG AGGCAGAGATTGCAGTGAGCCAAGATCGCGCCACTGCACTCCAGCCTGGGCAACAGAGTG AGACCCTGTCTCAAAAAAAATAAATAAATCACACACACACACACACACACACACACACAA AAAAAAAAAATTAGCTGGGCATGGTGGTCCACTCCTGTAATCCCAGCTACTTGGGAGGCT GAGACATGAGAATCACTTGAACCTGGGAGGCGGAGGTTACAGTGAGCCGAGATTGTGCCA CTGCACTCTAGCCTGGGTGACAGAGGAAGACTCCATCTCAAAAAAAAATAACAATAATAA TAGAGGGCCGGGCACGGTGGCTTACGCCTGTAATCCCAACACTTCGGGAGGCCAAGGCAG GCTGATCACCTGACGTCAGGAGTTCGAGACCAGCCTGACCAACATGGAGAAACCCCGTCT CTACTAAAAATACAGAATTAGCCGGGCATGGTGACACATGCCTGTAGTCCCAGCTACTCG GGATGCTGAGGCAGAAGAATCACTTGAACCTGGGAGGCGGAGGTTCCGGTGAGCCGAGAT CGCGCCATTGCACTCCAGCCTGGGCAACAAGCGAAACTCCGTCTCAAAAAATAATAATAA TAATAATAATAATAATAATAATGACTAAGTAAAAGTTATTATTAAGGGAAATAAACTACC CTTTCTTAGTGCCATGATGTGTGTCAGATACTATGTTCCATTATCTTATTTCATCCTGAA TAGAAGTTGATGGTGACTTTTTTTTTTTTTTTTTTTTTTGAGACGGAGTCTCACTCTGTC ACTAGGCTGGAGTACAGTGGCGCGATCTCAGCTCACTGCAGCCTCAGCCTTCTGGGTTCA AGCAGTTCTCCTGCCTCAGCCTCCCAAGTAGCTGGGACTACAGCCACGCACCACCACCCC CAGCTAATTTTTGTATTTTTAGTAGCGACGGGGTTTCACCATGTTGGCCAGGGTGGTCTC GATCTCGACCTCGTGATTCGCCCACCTTGGCTTCGCAAAGTGCTGGGATTACACGCGTGA GCCACCACGCCCGGCAGATGGTGACTTCTTTTATCATTGAGGAAGCAGAGTTAAATAAGG CACCAACATCACCTGGCTGGAAGTCTCAAAGAGCTCCGATGCTGAAAGGATGAAACTTCA GTTATCTGGGACATGTGGCAGGCGGTTCTGTCATTCCCTAAGCATGTTGGGTTTATCACG CACTTTCCAGTTATGTGCTTGGCGCTTTGCTGAGCTGATGACCAGGACCGAGCCTTACTC AGCGTCTGTTCGATGTGTCCTAGGATCAGCAGCAGGCTCGTCAGTCTCAGCTTGCTCAGG ATGAGCGTGTGTCCCGCTCTTACCTCGCCCTGGCCACCGAAACCGTGGACATGTTCCACA TCCTCACGAAGCAGGTCCAGAAGCCCTTCCTCAGACCGGTGAGTAGAAACCCGGGGCTCT GTTTGGTGGTTTGGACTCCACATTCAGACTCTCTCACTTATAACTTTAGCAGTTGTTGAA GTTCTGGAAATTTTAGGATCACAGTCATCAATAAGTGAAATTCTGTGACTGATTTTGTTC CCAGTTATGCTAATTGATACCAGACTCTGTTGATGGACTGAAGAGCAGATGTCTGATGTC ACCACATAGTCTACAGCCACTTCCAAATGCCTTACTGCACTTTGTGCTTAGACAGTACAT TGGATTATTCATGTTGATGTCATGACATATTTTTACCATTATTGATTCCTATATTTTACT TATAGAAAAAGCATAAGGTGCCGGGTGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG GAGCCCAAGGCGGGCAGATCACGAGGTCAGGAGATGGAGACCATCCTGGCTAACACAGTG AAACCCCATCTCTACTAAAAGTACAAAAAATTAGCTGGGCGTGGTGGTGGGCACCTGTAG TCCCAGCTACTCAGGAGGCTGAGGCAGGAGAATGGCGTGAACCCGGGAGGCAGAGCTGGC AGTGAGCCGAGATGGTGCCACTGCACTCCAGCCTGGGCGACAGAGTGAGACTCCATCTCA AAAAAAAAAAAAAAAGAAGAAGAAAAAGCATAAGGTAACAGCTGTTGACAATGGAAGGAT ATTAAGTAGAATAATTGAGACCGTGTAAAATCTTTGGCTCTCTTAGCTGTACCTTTGTTA CACTCAGGAAGCCAAAGGTTAATGGGAGCCGGCCATCACTAGGGTTTATGGTGGATTGCA AATAGTCAGAATGTTTGTTCTCAACTAGTAAGACCTGGTTCCTATTTCTAAAATTGAAAC TGAGCAGCATCACTGAAGATTTCTGCCCTGCTTCAGCCACCCCCACCACAAAGTTGAAAA GTTTTATGGTGTGGCCAGGACAAGGGTAGTGAGGAAGGCAAGACGGGGACCTAAGATTCG GTAGCCATTTGCCTATGTGGAGACATGTTTACTTTACAATGGAATATGACGTTACTGCAT ATTTCCCCTGATTTTCTGTATTTGCTCTTACCTTCGTTATGTGACTCTCTGTTATGTGAC TCCTGTCATCAGCAGAGGCACTATTGCCACTCCCTGGCCTGGGGACAACTCTTTTCCACT CTTTTAACTTTCCACCTCATGTCTCTTCATAAACAGATTTCAGTGCAAGAGCCATGGAAC ACGAAACAAAACAGCTCAGACACTGGCCTCCCTTAAAAGTTTGCAAAGTGCAAGGCCATG GAGCATGAAACAAAACAGCTCACTGGCCAGACACTGGCCTCCCTTCAAGGTTTGCAGAAT TCTGTGAAGGCCAGATAGTAAATAGTTGATTAATTCCTTTGTAACAAGGTCAACACCCAC CTATTTTGTACACTTGTTGGGAAGACTAAGCGAAAACACACATAGAAGTACCTGGCATAA GGCCAAGCACGGTGGCTCATGCCTGTAATCCCAGCACTTTGAGAGGCCAAGAAGGGTGGA TCACCTGAGGTCAGGAGTTCCAGACCAGCCTGGCCAACATGGCGAAACCCCGTCTCTACT AAAAATACAAAAATTAGCCAGGCGTGGTAGTGCATGCCTGTAATCCCAGCTACTTGGGAA GCTGTGGCAGGAGAATCACTTGAACCCAAAAGGCAGAGGTCGCAGTGAGCCGAGATCACG CCACTCCAACCTGGGTAACAGAGCAAGACTCTTCTCAAAAATAAATAAATAAATTTATTT TAAGGCCTGCTCATAGACCTGAGCCATCTGTACACTGTAGCCCTGTTCTTTTGGCCCCAG CCTGTGCCTGTGCCTGCTGTGATGTTTTCATTTCCTTTGCTACACTATTTACTATCTGGC CTTTGCAGACAAAGTGTAAAGGCATTTCATTTTGCAAACCTTTAAGGTTTGCATTTTCAC CTTCTTTACTGACTAGCTCAGATCTCTCCTACTTCAAACAGAATGACCAACTCTGTCCTG TTATGACTCTTTTATTTCACAGCTTCTCAACAGTGAAATACAGGAGTACTCTGTGCAAAA GCAAATTCTTGAAAAGCTAAGTATATGTTGAATTTGTATAAATCCAGTTATTACATTTCA TGAAAACCTTGTGACTTAAAGGAATGCTTTCGTGACTCCCTTTTATGGCCAGTGTTTAAT GCTCTCTAAGCCACATCTTCCTGTTTCAGGTTTGCTTAAAACCATGTATGCCCAACCGTA GTGGGTACTGAGTCACCTTGTGAGATTACAGCATAGATTATTACTATTTTCCAGGTGTTT CATTTAAGTTTACTCTGTCTCATTGACTAGATTTAAAACTATTCAAGGCATAACTTTTAT CTTCTTTCCTTGCATTACTTTGTTATTTGTATCTGATAAGTACATAAGAATGACACAGAC TGAACTGCCAGGGGCTTTTAACATTTATGGGGAAAAAAGTTTATGAAATACTGGCTGGAA GAGCTGACTCAAAACTTTTTTTGCTCAGATAATGGTAAGATTTGTATAATTTTCTCTCTT TTACTTGTTTCTCAATGAATTTGGAGTGATACTTTTTTTAATTAAAAGCATAAATGTAAA GAAAAGTTTGGCTTCTTTTGGTATTTATAAATAAATATTTCATCAGCCTGCAACATTCCA TTAAGTATTAGAATTATCAGATCAGAAATGGGGAGTAAAGTTGAAATATAATGTTGTCTT TCTTCAGCTTATGATACACAGCACCTGTAAGGATTCTTTGAAGATTAATCCAACCAATTC CTGTTCCTCCACTGAAATGGGAGTTTTTGGTCCTTTTCACTTGTCTCAACAGCATGAATT GTCCTATTATCCTGTGATTTCCTAGGAGCTTGGACCCCGATTGGCTGCAATGCTGAACTT TAATCTTCAGCAACTTTGTGGCCCCAAGTGCCGTGACCTGAAAGTTGAAAACCCTGAGAA ATACGGCTTTGAACCAAAGAAGCTGTTGGACCAACTGACGGATATTTACTTACAGCTGGA CTGTGCTCGGTTCGCGAAAGCCATTGCTGACGACCAGGTCAGTGAGTTGAGTTGGTCTCT CTGTGAGTTTACTGGCAGATTTGGAGATAATAACCACAGTGGCCAGGGAACTCGTCTGGT GTAAATGAAGATGAGTGGGTTGTTTTCCTTTGAGTGTGAAGAGCAGATTTGGGCTGGGCG CGGTGGCTCAGGCCTGTAATCCCAACATTCTGGGAGGCCAAGGCAGGGGGATTGCTTGAG GCCAGACTGCAGTGAGCCGTGATTGCACCACCACACTCCAGAATGGGTGAGAGAGTGAGA TCCTGTCTCAAAAACACGGTGGCTCACGCCTGTAATCCCAACACTTTGGGAGGTCGAGGC GGGCAGATCAAGAGGTCAGGAGTTTGAGACCAGCCTGGCTAACATGGTGAAACCCCATCT CTACTAAAGATACAAAAAATTACCTCAGTGTGGTGGTGCATGCCTGTAATCACAGCTACT CGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCAGGAGGCAGAGGTTTCAGTGAGCTGAG ATTGTGCCACTGCACTCCAGCCTGGGCAACAGGGTGAGACTCTGTCTCAAAATAAATAAA TAAGTAAGTAAGTAAGTAAAAAACAAAAGTAAAGAGCAGGTTTGGCGCTCTGAGCCCTCT CCAGTTGAGTTCTTACCCCATCTTTTTAAGGGCCTTCTTGACAAATCCATTACATTTCTG AAAAGAGCCCGGTTTCTCAAGGGATCAGAATCTTCTTTCCTAGTCTCCTGCTAGAGTGCT GTTATTTTTGGGGTTGTCCAGATTAAAAATCTTGTGTGGTTTTCTTTACATTCTTCCCTC TCCTTTATTCCGTGGGTCTCCTGTGAGCAGATCTGTCTGTGTGTGCTTCATTTCCACAGC CACCGATTTAGGCTAAGCTGTCCCTGCGTGATCTTCTAGTCATCCCATAAAGGGCTGGCC CCCTCCATGGTCCGTTCTGCCTCATTTTCAACGTCCTCACAGCTAATGTTTATTAACTGT ACACCTCATTTCACCCACTTTTCGTATCTCCACCCATTTAGTCCTCACAAAATCCTTTGA GGTAGGTTCTGTAAAGTCTTTGTTTTAAAGTGAGGAAAGAGGCACAGAGAGGTTAAATAG CTTGCTCGAGGTCACAGAGTTAGTGTGGGACAGAGGCATGATCCATGTCCAGGCAGCCTG GCCTTGAACCCATATCCTCAGTCTCTCTGCTGTCCACTTAAAATGCCCACAAAGAACCAT GCTTGTCTCTGTGTCTCTGTCTTTGTTCACACTACTTATCCAAATACTATTCATGGCTCA AGTTAATCATCAGTAGGCATTCTAGAAGGTTCTTTACCCATATCTCATCCAAAGGAGTAA TATTACAATAGAAGCATTGTAGGTACTTTTTTTTAATGACAGCTTTATTGAGCTATAACT CACATATGTAGGTGCTTTCTGATGTAGCAGGGGAAGTGGTCTTAACAAAGGATTTGCAGT GAAAAAATACATAGTCATGTGCTGTTTCTGTCGATGCTGGACCACAAAGACCATGTGGCC CCATCATATTATAATACCGTATTTTCACTGTACCTTTTCTGTGTTTAGAATACTCACCAT TGTGTTACAACTGCCGACAGGATTCAGTACAGTCCCACACTGTACAGTTTTGTAGCCTAG GAGCAATAGGCTATACCATAGAGCCTCGACGTGGTGTAGGCCACGCCATCTAGGTTTGTG TAAGTAAATTCTATGATGTTTACACAGCAACGAAATTGCCTAACAAGACATTTCTCAGAG CGACACATGACTGTGTGTCTAAAGCAGTTTTATCATACAAAGTAGTGGCTCGTAAGAGGG TTAGGAAATTTTAGTTACTTGTAGATGTTAAAATATATACTGCTGGCCGAGCGCGGTGGC TCATGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGTGGATCACAAGGTCAGGAGA TCACGACCATCCTGGCTAACACGGTGAAACCCCGTCTCTACTAAAAAAAATACAAAAAAA TTAGCCGGGCGTGGTGGCGGGCGCCTGTAGTCCCAGCTACTCGGGAGGCTGAGGCAGGAG AATGGCGTGAACCCAGGAGGCAGAGCTTGCAGTGAGCGGAGATCGAGCCACTGCACTCCA GCCTGGGCGACAGAGCAAGACTGTCTCAAAAAAAAAAAAAAATTATATATATATATACAC ACACACACACAAACACTGCTTTACTAGCCCCCGACTATATAATACTGCACTGATTTAGAA ACAGAAAGCAAGTCATAGCCTGCAGTGAGGGAAAGAAAAGGGAAGCACTTACCCATTGAG GTGGGGTCCACACCTGACTGTAGCTGGCGTCTCCAGCCCAGCCAGAGGTCGGTGTGGAAA GCCCCAGGGCTCTTCCATCGTTGCCGTAGAGAGACTTGGAAGAGCTGTTTAGTGTGCGCC CTCTCCAGGGTGGTTGTGCTGTGGCTGCCACATCACAGGCGCTTAACGTAACACACAGAA GGTTTCGGTGTGGGTGGGCACAGCACGCCCAGTGAGGTGATGCAAAGCAACTGGGTGACA AAGGAATGCTTTGAGCGGCCTTTGTTTGGTGACCAACCACACATTGCATTGCCTGGTCAT GCCTTAGATTATGGTGGTGGCCTCTGGTGGCACCTGGCTTGGGTTGTAGACAGCAGTTTC TGGCACAGTGACACACGGGGCTCCTTGAATGTCTAAATAGTCCTGTTCTTCCAGAGTGGT GAAACAAACACACATGTGCCAGTGACACATGGAGAGAAAAGCATATTTTAAGAAGTGTTG GGGCTGGGCGCAGTGGCTGACACCTGTAATCCCAGCACTTTGGGAGGCCAAGGTGGGTGG ATCATGAGGTCAGGAGTTCGAGACCAGCCTGGCCAAGATGATGAAACCCCATCTCTACTA AAAATACAAAAATTAGCCGGGCACAGTGGAAGGCGGCTGTAATTCCAGCTACTCGGAGGC TGAGGCAGGAGAATAGCTTGAACCCGGGAGGCAGAGGTTGCAGTGAGCTGAGATCGCACC GCTGCATTCCAGCCTGGGTGACAGAGCAAGACTCCATATCAAAAAAAAAAAAAAGAAGAA GTATTGGGCTGGGTGCGGTGGCTCACACCTGTAATCCCAGCACTTTGGGGAGCCGAGGCG GGCAGATCACCTGAGGTCAGGAGTTTGAGACCAGCCTGGCTAACATGGTGAAACCCTGTT TCTACTAAAAATACAAAAAATTAGCCGGGCATGGTGGTGTGCGCCTGTAATCCCAGCTAC TCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCTGGGAGGTGGAGGTTGCAGTGAGCCGA GATCGTGCCATTGCACTCCAGCTTGGGCAACAAGAGCGAAACTCCGTCTCAAAAAAAAAA AAAAAAAAAAGTGTTTTTGCTTCCTTTCACAGTGTGGTGTGTGTGCTGATTGTTGGGTAT TTTCTATTTATATTGGCCATAAGCTGATTAGGGGCCTGCTTACTTGATTGTTTTAGAAGA GAGCTTTGGTGGGGCAGGGGGCGGTAAGTGCAGAAGGATGGATGGTTGGCAAGCACTGGG GAAGAGGTTGTAAAATTGCATTTTCTTCTTTGGAAGCAGCAGTATCTTAGTTTGCTTTGG TATGTCTTAGTTTGGTTTGGTATGTCTTGTTTTCCGGGAAAGACAAAGGAAGAGGAAAAT GACAGCTTTGCAGGTAAAGAAACTGAGAGGCTTCTCTCCCTCTATACCAAGAGTAGGCTG AAGACCCATGTCCAGAAGGCTGACAGAAAGGTGCCTGGGTGAAGAGCCACTGAGCTTGAT GCTCAGGAATCTGAGGGCAGAGCTCCATGCCAGAGAAGTGGGATACCACATTGGTCCTGG GAGCCAAGAGGACCAGGATAGGGAGATGTTAAAGTGGCCTAGACTGTGTCTTTATGGGCA GACGCCAGTTCCATGGACAGACTGCATATCTGTCGTCCATGAAGCATTGTCTGTTAACAC CATTTTCCATTAAAAAAGAAAAAAAATTCAGCACCTACTTAGAAAATAAAAAAAAATAGC CGGGTGCAGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCAAGGCGGGCGGATCA CAAGGTCAGGAGATCGAGACCGTCCTGGCTAACACGGTGAAACCCCATCTCTACTAAAAA TACAAAAAATTAGCCAGGCGTGGTGGCGGGCGCCCGTAGACCCAGCTACTCGGGAGGCTG AGGCAGGAGAATGGCGTGAACCTGGGAGGTGGAGCTTGCAGTGAGCCGAGATCGCGCCAC TGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAATAAATAAATAAATAAATAA ATAAAAAAGAAAATAAAAAAAATAAAAATCCCATCAGTCACACTTCCCCCATGCAGTCAG TCTTTCCTAAGTAATTGCTCCCTCCTCTAACCTACCAGAATATGAGTCTGCGTCTCACAA ATGTAATGCTTCATTTTCTTGTTATTTTTTTCTTCTTTAATGAGGTAAGATTAATATATA ACGTAGAAGTAACCATTTAAAAGTGTACCATTTTGTGGCATGTAGTACAGTCACAGCGTT GCACAGCCACCACCTCTACCTAGTTCCACTACATGTATCACCCCAAAAGGAAAACCCTTA AAGCAGTCGCTGTCTAGACCCCCTTGCCCCAGCCCCTGGCAACCACAAATCTGCTGTCTC TCTTTTCCTATTTTTGGATTTACCTATTCACCTCTCCGGGATATTTCATATAAACGGACT TATACAGTGTGTAACCTTCTATGTCTGGCTTCCTTCACTTAGCATCATGTTTCAAGGTTC ATTTGTGTTGTAGAATGTATCAGTATTTCATTCCTTTTTAAGGCTGAATAATATTTCATT GTATGGATATACCACCATTTGTTTATCCTCATCCATTGATAGACATTTGGGTTGTCTCCA GCCTTTGGCTCTTGCAAATAGTGCTGCTATGAACATTTGTGTAAAAGTATTTAAACACCT GTTTTCAGTTACTTTGGGTCTACACTTGGGAGTGGGATTGTTGGTCATGTGGTAATTCCA TGTTTAACTTTTTGAGGGATGCCAGAATGTTTTCTACAGCTGCCGCCCATTTGACATTCC CACTGGCAATGTATAAGGTTTAAGTTTCCATTCTTTTTCATTTTTTTTCTTTGGTTTAGT TTATATTCTTTCCATCATGAAGTTTAAAAATTAAACATGTTAATTTGTTTTTGTTTCTTA AATACTCATCCTAGTGGGAGTGACGTGGTATTTCATTGCGGTTTTGATTTGTATTTCCCT AATGTCAAATACCATTGGACACCTTTTCATGTGCTTGCTGGCCATTTTTATATTTTCTTG GGAGCAATGTCTATTCATGTTCTTTGCCCATTTTTTAATTGGGTTGTTTGTGTTTTTGTT GTTGAGTTGGAAGAGTTCTTTTTTTCTTTTTCTTTTTTTTTTTTTTTTTTTGAGATGGAG TCTCCCTCTGTTGCCCAGGCTGGAGTGCAGTGGTGCGATCTCAGCCTACTGCAACCTCCA CCTCCCAGATTCAAGCAATTCTCTTGCCTCAGCCTCCCAAATAGCTGGGACTACAGGCGT GCACCATCACGCCTGGCTAATTTTTTTTGTATTTTTAGTAGAGACGGGGTTTCACCATGT TAGCCAGGATGGTCTCGATCTCCTGACCTCATGATCTGCCTGCCTTGGCCTCCCAAAGTG CTGGGATTACAGGCGTGAGCCACCGCGCCCAACCAGAAGAGTTCTTTATGTATTCTGGAT GCTAGGTCATATCAGATGATACATGTATCATTGGATATATGATTTGCAGATATTCTTGTG TTAGTCCATTGCATCACTATACAGAAATACCCAAGGCTAGGTACTTTATGAAGAAAAGAG GTTTAGGCCGAGCACAGTGGCTCACGCCTGTAATCCCACCACTTTGGGAGGCCAAGGTGG GCAGATCACTTGAGGTCAGGAGATCGAGACCAGCCTGGCCAACATGGCAAAACCCTGTCT CTACTAAAAATACAAAAAAATTAGCCAGCCGTGGTGGCGCACACCTGAAATCCCAGCTAC TCAGGAGGTGGAGGCTTCAGTGAGCCGAGAGCGTGCCTCTGCACTCCAGCCTGGGTGACA AAGCGAGACTCCGTCTCAAAAATTAAAATTAAAATTAACTGGGCATAGTGGCATGCACCT GTAGTCCCAGCTACTTGGGTGGCTAAGGTGAGAGGATTGCTTGAGCCCAGGAGTTTGAGG CTGCAGTGAGCCATGATTGCACCACTGCACTCCAGCCTGAGTGACAGAATGAGACTCTGT CTCAAAATATATATATATATTTATAGTAAAACATATATGGCAAAAACACTGGCCACTTGT TTTGCGATGGTGATACAAATACAAATATATATCATCACTAAGCAAGTGGCCAGTGTTTTT GCCATATATGTTTTACTATAAATACAAACTACAGCATACTTTACTGTTTGGCATGGCAGT GATTTTTATGAATTAGGCACCTGTGAGGTAGATGTTACTCTGCCCATTTTACACTCAAAG AACCTGGGCTTAGGAGGGTTCAGATTTGCCTACGACTGCACAGCTGGTAGGTGGTAGAGC CAGAATTCAAGTTCAGATTTGTCTGGGTCCACGGTGGGCGCCTGACCTCCACTCCACAAC TTCCCTTCCTGGGGACATAAATCGTGTCTGTTCCCAGGCCTATTCATCAGTTCACCAGGG TGGTCTAACGTCCATGGAGCCCCTGACATGTGCTAGTGCTGAACTAAATGAGCTTGAAGA AGCTTGAAAGTGAACAGGAGAAGGCTCCTCTAGAGTATGAACAATAGTGGATTGTTTTTA CCATGCTTACCTTTGTGGAAGAGAGCTGAAATTTTCACCTCTTCTTTCTTATAGGCTGCC AGGGCACAGTGCCCCCCAAGGACTGAAATAGACTAGATTTCCTTCTCTTTTTAATGTTTA AACTTTAAAAGAAATGCGTGCTAGCTGTAAAAATTCAAAAAAAAAGCCCGTCTGCCTCAG TCCTGCAGCCCTCTCCAGAGGGAGTGACCTCGTACAGTTTGGCACATATTATTCCAGTCT TTATCCATTTGTAAGCATAAAAAGTGCATACTTTTATGAGGCTATAAATGCATAAAGACG GATATATAAAATATATAAGTGTATATATAATTTTAGGGCTTTTTTAGTGGGGGAAAATCC ACAAATGGATAATACTTTGGATATTTTCTGCAGCTCGCTTTTTTCCACCTGACGTACATT TACGTCTCACATTGCCATTCCTCCTTTGCAGAGATCCTACAGTAAGGAATTGTTTGAAGA AGTTATTTCAAAGATGCGGAAGGCAGGGATCAAATCCACAATAGCAATAGAAAAATTTAA GCTGCTCGCCGAGAAAGTGGAGGAGATAGTGGCCAAGAACGCACGCGCAGAAATCGACTA CAGCGACGCTCCTGATGAGTTCAGAGGCAAGTGGACTCGTCGTTTTCATGCTGATTTCTT TTGAGTTAACTGGAAATCGATAACATTACAAGAGGACGTCCTGTGCAATTAATTTTTTAA TGGTGTGCTAGAGCTGCTTTTTGAGACAATCTGTCTTAAATTACATTTGCCTATTTTTAG CTCATATTGTAAATTGAGAGGAAGAAACATCCTTAGCTTAGCCTGACTTAAAGCCAGATA ACAACCCTGAAGATTCTAAGGGCAGGGCTGCCTTTGCAAGTGGGGATTCACATTTTCAAA GAATTCCCAGAAGTCCTAAGACAAAGAATTCCAGCCTGCCGTCCTCGCCACGGAGCCTGT GGGGCCTGCTGCTGGGTCTGTCCCAGGCTTTCTTCTCTGTTCCCTCCCCCCAGCAGTAGC TGACAAAGAAGCGCCTTCCCCTTACAAAAGGCAATGTATATGCCTTTATTGAAGGCTGAT TTCCTTCTAAACCTGGGGGCCTCACAGGGGCCCTTTGATTGCTGTTCCTTTGGATAGATT TTTCGCTGGTAGAACGGGCTTTGTTTTCTTTTTCAGTCGTGGGCTCTCAGTAGATTAGAG TTTGCTTTGCTTTGTCCCCGCAGACCCTCTGATGGACACCCTCATGACAGACCCCGTGCG GCTGCCCTCTGGCACCATCATGGACCGCTCCATCATCCTGCGGCACCTGCTCAACTCCCC CACGGACCCCTTCAACCGGCAGACGCTGACAGAGAGCATGCTGGAACCAGGTAGAGGAGG GTGCAGTTTGAGGTGCAGCGCTGGCGTCAGTACCAAGAGATAAAGCCCAAGTCACATATT GGAGATGAAGCAGAAGGGAAATTTATCAAATGCAGAAACTACCTACTTTATGACACTCTG TAGCAAAGACCCAAAACACTCTTGGCCCTTTTTCCCTGCAGACATCCAGTCCCTCCCTCT CATGTCCCAGTCCTTCTGGAGTCTTCGGCTCAATGAGGGAAAGAATGGCCTTTTCTTCCC ATTTATACAGAGCGACAAGCATCCTCTCTCAGGAAGAGCCCTCCCATCTGGGGCATTAAT CCTCCTTTTTTTCTTTTCTCAGTGCCAGAACTGAAAGAGCAGATTCAGGCGTGGATGAGA GAGAAACAGAACAGCGATCACTAAACCGTTCCGCCGCCCACCCTCTGCTAGACACAGCCA AGGCCAACGAGGCAAGCAGAAGCAGCGGCCGCAGCGAAGCTGCCGTTCATGTGTTGGAGG CCAAATGTGGCAAACCAACCCCAGGCCCACCCAGAGCGAGCAAACGCTGAGACCTGAAAG GACATGGATGAGAAGAGGAGCCCGCTTCCTGTACATATATTTAAGTGACAAACACGGTCA AAAGCTTAAGGGACAGGTTTTATGGTTGCTTGTGTAATAAAGCATGTCCTTCGTATGTCA CAGTTTGGGGCAACGGAAGTCTTTTAGTGATGGCTAATGGGTCTGGGCAGCATCCCTTCA TGAATTTTTTTTTAATCCAATATCCGTTGATTTGATTGTGATTAGAGAACCTTGGACATT TTGCTGCTAAAGAATCTTTTTTCCCCTCTCCCCCTTCCTGACCCTACTTGCACTGCTGTG GATTTTTTTAAGAGAAGCAAAAACAAAAGTAAACTCCTTTCCCTGGCCCTCCAAACATAT ATTCTGTGAGATAACTGTGCCTGCTACCAAGTGTTAATCCTGGGATCGTATTTTTATATC ATATTCACATATTTGTTTTTTTAATTGGTGTTAGATGACATGATTAATAAAAAAGGCAAG ATATTTTCAGAATTTGAATTTCAGTTTTTTTTTTCTTTTGAAATGTCCCTTTAAGATTTT TTTATTCTAAACAAAATAAAGAAAATCCTGCTGCTCTGGTCCTTGTGATAAGCCTCTCTT CGGCATCTGAGGAGCAGCTGCAGCAAAATCTAGGGGTGTAAGTGTATCAGGACTTATGTG ACTTATATTTTGGGGAGATGAGGGTTGGGTTTTTTTTTTAATGCTACGTGACAGTTTGAA ACCTTCACAGTTATCCTCTGGGGGTAAATCAATTCTTCAACCCTTGGGTGTGTGAGTTTG AGGCAGGGTCATTTGTGTGATGTGTTTGGCCTTACCAAAGCAAAAGAGGGTGCAAGAATG TGGGAGTATGTCTGCCGGTTTCAACACACACAGACAAACACAGCCACACGCGCACACAAG TATAAGACTTTTTGTATTACTGCTCCCTACTTAACATACTTGAATTCTCAAATTTCCTTT GGGGTAAAAAAAAAAAAAGGATTTGAAACCATAAAGTGTTCTGAAGAAATTAAGTCTATA AAAAGCATACTTTCTTTTTTCTTTTCCTTTTTTCCCTCCACAGACAATGTCCTCTGTTCA ATTCCTAACGCAAACTACAATAAATGGTGACACACGTTCAGAAGAAATCTTCTTTGAGTC TCTTCTCTTTTGTGGAAAAAAAAAAAGGGCAGGGCGGGTGGGTAAACAAGAGCCAAGTGA GTTTGCATGTGGTGAATGATCTTTCCTGGATCCAATTAGGAGCTGCTATTTTTAAAAGAA AACTTTCTTATTCATGTCAGTCTCGACATTTGGTTCTCATTTCACTGTTTGCTGATTTGA GGGGGTAAGCTTTGTCATATTCAGTCTTCTGCCTTTCTTGAGTTTCTTCTGCTTTATCTC AAGTATCTTCCCTGACCTTCAAGATTCTTCCTCAGGCCGGGCCCGGTGGCTCACGCCTGT AATCCCAGCACTTTGGGAGGCTGAGGCGGATGGATCACCTGACGTCAGGAATTCGAGACC AGCCTGGCCAGCATGGTGAAACCCCATCTCTACTAAAAATACAAAAAATTAGCCGGGCGT AGTGGCAGCGCCTGTAGTCCCAGCTACTCGGGAGGCTGAGACAGGAGAATTGCTTGAACC TGGGAGGTGGAGGTTGCAGTGAGCCGAGATGACGTCATCACACTCCAGCCTGGGTGACAG CGAGACTCCGTCTCAAAAAAGAAAAAATATATATTTATATATATTTACATATATATTTAT TTATATATATTTATATATATATATATAACATGGCCAGGTGCGGTGGCTCACGCCTGTAAT CCCAGCACTTTGGGAGGCCAAGGCAGGTGTATCGTCTGAGGTCAGGAGTTCTAGACCAGC CTGGCCAACATGGTGAAACCCCATCTCAACTGAAAATACAAAAATTAGCTGGGCGTGGTG GTGGGTGCCTATAATCCCAGCTACTCGGGGGGCCGAGGCAGGAGAATTGCTTGAACCCAG GAGGTGGAGGTTGCAGTGAGCTGAGATCGCGCCATCGCACTCCAGCCTAGGGGACAAGAG TGAGACTTCGTCTCAAAAAATAGATAGATAGATAGACACAATAAATAAGGAAAAAGTTCA TGATAGCAAAAATTTTAGGCAATATAAGCAAAAAGAAAAAAAATCCATATTCTCACCATG CAGAAGATTCTGTTTAATTGGGTTTACTTTTTACTAAACTTACATATCTAAGCTTAGTGC CTGTAGAATTAGGATACTGACTGGCATCTTGCCTAATTTTGTTTGTGTGGTTATCTGACC AGTGTGTACTGCTTGTCTCCTCTCCATCCCAGATTCCAAACTCTTATTTTAATCCTCCAG TTGTCCCCGTGAATGTAATAAAATGCTGCTTTATACCGCCATATGCACTTGTCGTTTTGA ATAATTCAGAGGTTTCAAGGACCTGCCGGATAGGACAGAGACACAGTCAGTCTCCTGCCT GTACTATCTATAGGGGGAAGATGATTTGGGTTTCCATTTTTAGAGTCTCAAGAGTTGCTG TTTTGTGTTTGTCTGCAGTCTCTTAATTGTGGATATTGAAATAAATCCCAAAATATATTA AAAGTAGGTCTTGGCTAAAAGGAAGATTGTCAAATAAGAGAATCAGATTGGCAGAAGAGA AATGATCCTTGAGAGAAAGATGATTAAAATCTGCCTTGTGTTGTGACTCAGTGTTGTGTA GATTTTAAAAAGATATTGATTGAATATCTTTTGAAAAAAAAGCTGAGCACACCGTTCACT TTTTGTAACCTCTGGGTTTGGTACATCGAGTAGTGAATTTCACAGCAATTTGATTGGAGT GCTAAAGTGACATGAATAGGCCTCATTTGAGTAGGTACTTTTTTTTGTTTTTTGGTTTTT TTCAGACGGAGTCTCGCTCCGTCACCCAGGCTGGAGTGCAGTGGCGCAATTTTGGCTCAT TGCAACCTCCACCTTCCAGGTTCAAGTGATTCTCCTGCCTTAGCCTCCCGAGTAGCTGGG ACTAGAGCACATGCCACCATGTCCAGCTAATTTTTTTTTTTTTTTTTTTTTTTTTTTAGT AGAGATGGGGTTTCACCATGTTGGCCAGGCTGGTCTTGAACTCCAGACCTCAAGTGATCC ACCTGCCTCAGCCTCCCGAAGTGCTGGGATTACAGGCATGAGCCACCACACCAGGCCTCA AGGTACGTTTTTGATTGAAGGAGACACAGTAGCCTATGAGCTTGATGCTGGTGTCAGATA GTGTTGGTGAAGAAAGTCATTCTGAATTGGTGATGATCATTTGCATTTCATGAGCATATT CTATGTGCAAGCCACTCTTACATGTATTAATTTTTTTTTTTTTTTTGAGACAGAGTCTCG CTCTGTCGCCCAGGCTGGAGTGCAGTGGCGCGATCTCGGCTCACTGCAAGCTCCGCCTCC CAAGTTCACGCCATTCTCCTGCCTCAGCCTCCCGAGTAGCTGGGACTACAGGTGTCCGCC ACCATGCCCAGCTAATTTTTTGTATTTTTAGTAGAGACAGGGTTTCACCGTGTTAGCCAG GGTGGTCTCGATCTCCTGACCTCGTGATCCACCTGCCTTGGCCTCCCAAAGTGCTGGGAT TACAGACAAGAGCCACCGCACCCGGCCACATATATTAATTAATTTAACCCTCCACAACCA TAATGTAGTGGAACTGGCACATGAATCTAGGCCATCTGGCCTTTCCAGCCTCATCTCTTC CCGACTCCTGCTGTATGGCAGAGTTCCAGAATGCTAGAAGTTCAGAATAGCTCAGAATGC CCAAGGAGAAGCAGCATAGCATTTTGGAAGGGACTTTGGCCTTGAGATCAGCTCTAGACC TAACCCCCATTTTAAACAATTAGATAACTTCAATATCACAGCTTTCATTCGTTACTAGCC ACTCACGTTGACCCCAGATGTATATCTCAAACCTCCACTTCTCTCCTGTACTGTACACAC TGGCCATCTCAGATGACTAAAAGGTCCTCAGACTTAACATATCCCAACCTGAACTCTGTA CATTTCACCCCACGCCCGCTCCTCTTAGTCTCCTCATCACAGTAAATGACAACTCCATCC TTCCAAGTCGCTCAGGCCACAAACCTTCGAGTCATCCTTGACTCCGCTGTTGTGCTCTCC TCCTATGTCCAATCTGTCCACAAATCTCTCTGCTCAGCTGGGTGCAGTGGCTCACGCCTG CAATCCTAGCACTTTGGGAGACCAAGGTGGGTGGATCACCTGAGGGCAGGAGTTCGAGAC CAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCTGGGCAT GGTGGCGGGCTTCTGTAATCCCAGCTGCTTGGGAGGCTGAGGCACAAGAATCACTTGAAC CCGGGAGGCGGAGGTTGCAGTGAGCTGAGATCGGGCCACTGTACTCCAGCCTGGGCTACA AAGTGAGACTCTGTCTAAACAAACAAAAAAATCCCTCTGTTCTACCTACAAAATGTATCC CAGAACTCGACGACTACTCCCCAGGTCCCCTCCTGTCACTTTGGTTTGAGTTGCTGCTGC TGGCTCTCTCCTGGATTATTCCAACAGCATCACTGGTCCTCCTGCCTCTCCCCTTAACCT CCTTTCTCAGAAAAGCAGGTAGGATGATCTTGTTAAAACTTTGGCTGGGCGTGGTGGCTC ACACCTGTAATCCCAGCACTTTGGGAGGCTGAGGTGGGCGGATCACCTGAGGTCAAGAGT TTGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTATTAAAAATACAAAAATCAGC TGGATGTGGTGGTGTACGCCTATAATCCCAGCTACTCAGAAGGCTGAGGCAAGAGAATCG CTTGAACCCAGGAGGCGGAGATTGCAGTGAGCCAAGATTGTGCCACTGTACTCCAGCCTG GGTGACAGAGTGACACTCTGTCTCAAAAAAAAAAAAAAAAAAAACCAAAAAAAAAACAAC TATAGCTAGGCGTGGTGGCATGCACCTGTGGACCCAGCTACTCAGGGGCTTTGGCAGGAG GATTGCTTGAGTCCAGGAAGTTGAGGCTGCAGTGAGCCGAGATTACACCACTGTACTCCA ACCTGGGTGACAAAGTGGGGACCCTATCTCAAGAAAAAGATGCTGGGTGCGGTGACTCAC GCCTGTAATCCCAACACTTTGGGAGGCCGAGATGGGCAGATCACGTGAGGTCAGGAGTTC GAGACCAGCCTGGTCAACATGGTGAAACCCAGTCTCTACTAAAAATACAAAATTAGCCAA GCATGGTGATGCGTGCCTGTACAAGTCCCAGCTACTTGGGAGGCTGAGGCAGAATTGCTT GAACCTGGGAGGCAGAGGTTGCAGTGACCCGAGATTGTGTGCCATTGAACTTCAGCGTGG GCAAAAAAAGAGCAAAAATTGCGTCTCAAAAAAAAAAAAAAGAAAAAAGAAAGAAAGGGG CTGGAAAAAAAACCCTAAAGCCAGGTGTGGTGTTGCACGCCTGTAGTCCCAGCACTTCCA GAGATCGAGGTGGGAGGATCGCCTGAGCCCAGAAATTCAAGGCTGCTGGAGCAGAAGCTC CAGCAAATGCAAGGGGCTATGATCTAGCCACCACACTCCAGCCTGGGTGACAGACTGAGA CTCCATCTCAAAAAAAAAAAAAAAAGAAAGAAAGAAATCCTTACAATAACCTGGAAGGCA AAACGCTCACCTCGCATTCTCTCTGATCTCATCTCCTACAACACTCCCCTTACTCCAAAA ACTCAGCCATTCTGGCCTCATTGCTCTCCACCCCTGCTAGGGCACTAGACTACTTCCTCT ATGAAGAATCCTCTTCCCACAGATATACATATGGGTCAGTCACTCCCTTATTTGCTTTAG ATCTTTACTCAAATATCACCTTGGTGAGTCCTTCCCTGTCCACCCTATTTAAAAATGTAA TTTATTCACCTAACCTTGGTATCCCTTGCTATTCCCTTTCTTTGCATTTTCTCCTTGGCA TTTATCACTATCTAACATGCTATATCTATTATGTACTTTACAGTCCACTTCCCCCCACTA GAATGTAAGCCCGGGGTGGGGGGGGGCAGAGATTTTTTTCTGTATCCTTGGCACCTATAA GTGTGCCTGGCAAATATATGTGTTGAATGAATTAATCTCTTCATATATTTGTTACTCTAG TTGTATCAGTTATTTATTGCTGCATAACAAAATCACCCCAAAATGGAGTGGCTTGGTTCA ATAACAGTGATTTTATCCCCCACAGTTCTGGAAGATCCAAGAGCAAGCTTCCAAGAGGAC CAGACAGAAGCTGTGTATTGCCCTTTTACAGCCTAGGCTTGGAAGTCACATAGTGTCACT TCAGCAGCAGTCACAAGCCTGCCTGGATTGAAGGGGAAGAAATGCAGAACCCGCCTCATG CTGGGAGGGAGGTCAACGTCACTCTGTGAGAAGAGCTTCTGGGATGGGAGACGTCGTTCT GACCATCTTGCAAATAACATTTGCCACGTTCCTCCTCTGGCAACAATTTACATTCTTCAT ATCTGCAAAATGATGCCTTATTTCCTTCCCGTGAGATTCCCAAACCGCATCCCATCAGGG CATCCGCTTCAAGTCCAGCATCTCATCATTGAAATCAAGTCCAGCTGCAGATGAGGCTTC TCAGATGGGATTCTTTGAACGTAGTTCCTTGAGTGTTAATCTTACGGATTTAAAGATCTG TTAATGAAAGATACAAGTTACCTACACACACATGCACACACACACACACCACGTGCACAC ATACACCACACACCACATAGACACACACGTGCACACACACACCACATGCACACACAACAT GTGCACACACACCATGCATGCAATGATGGGACAGGCATGGGAAAACCATTCTGGATGATC CTGTTCAAAAAGGTGGAAAATGGTACCCCACAGGAGTCACTGGTCCATAGTATTAATAAT TCTGAGATCCAACCAGGCATATGTCACCAGTTCCTTGTTCAGGGCTCAGTCCTACAGCCC AGGAATTGTTCACCAAGCCTCTCAGCTCCACCCTCTTGGCTCTTTTTGTCCTCTGAATCT TTTCTTCCTTTTCCATAAAACAAAAAACAAAAACTGAGCTTGCAATTAAGCCTTCTCAGT ACATTTCCTGCTTATTAAAAAAATATATACATATGTTGCAGTAACGCCGGGTGCGGTGGC TCACGCCTATAATCCCAGCACTTTGGGAGGCCGAGGTGGGTGGATCACAAAGTCAGGAGT TCAAGAGCAGCCTAGCCAAGATGGTAAAACCCCCGTTTCTACTAAAAATATAAAAAATTA GCCAGGTGTGGTGGTAGGCACCTGTAATCCCAGCTACTCAGGAGGGTGAGGCAGAGAATT GCTTGAACCTGGGAGGCGGAGGTTGCAGTGAGCTGAGATGGAGCCACTGCACTCCAGACT GGGTGACAGAGCAAGACTCCATCTCAAAAAAAATATATATATAATATAATATTATATAAT ATTATATATTATAATAATATATATAATATATATTATATAATAATATATAATATATATTAT ATTATAATATATAATATATTATATAATAATATATATTATATAATATATAATAATATATAT AATACATATTATTTAATAATATATAATATATATTATATAATAATATATAATATATATTAT ATAATAATATACATTATATTATATAATATATAATATATATAATATATATTATATAATAAT ATATAATATATATTATAGAATGATATATTAGATATTATATAATTATATATATAATATTAT ATATTATATAATAATATATAATATATATTATATAATTATATATATAATATTATATATTAT ATAATTATATATAATATATTATATAATTATATATATAATATTATATATTATATAATTATA TATAATATATATTATATAATTATATATATAATACTATATATTATATAATTATATATAATA CTATATATTATATAATTTATATAATTATATATATTATATATTATATAATTATATATATTA TATATTATATAATAACATATATATTATATATTATATAATAACATATATATTATATATTAT ATAATACATATATATTATATATTATATAATACATTATTATATAATATATAATATATATTA TATAATGCATTATTATATAATAAATATTATAATATTATATATATATAGGGGTTTAAAAGT CTCTTTTGATGTTGTACTTTCTCTGTCCTGTCCCTTTTCATTTAAGCTGGAGGCAGTTTG ACCAGACCAATTACCTTAAAATGTTGTGGGTTTTCTATGAATCTTGCTGGAGTTTGCTCT GTTAGGCAAAAGCCGCAGCTACAAGTCTCTTCTGGATAAACTTTTCTCTATTTTGGATTA CTTGTGTAACTCTTAAATCTTTCTGAGGTCTTAATAAAGGATTCTGAAGTCAGGCTTTTT TTTTTTTTTTTTTTGAGACTGAGTCTCACTCTGTCACCAGGCTGGAGTGCAGTGGCGTGA TCTCAGCTCACTGCAACCTCCGCCTCCCAGGTTCAAGTGATTCTCTTGCCTCAGCCTCCC GAGAAGCTGGGACTACAGGTATGAGCCACCACTCCCAGCTAATTTTTGTATTTTTAGTAG AGACGGGGTTTCACCATGTAGGCCAGACTGGTCTCGAACTGCTGACCTCAGGTGATCCCC CTGCCTCAGGCTCCCAAAGTCCTGAGATTACAGGCGTGAGCCACCGCACCCGGCCTGCGG TCACATTTTTTACCCCATCTTTAGATATCGTCCCGAAAGTGCACTGTTTTTGATTTCTGA CCAGAAGCCATTTCTTAATTTTTTAAATTTTTTTTTTTTTTTGCCAGTTCATCTCACATT TTTCTACAGGCAATGAAAGAAGCCAAATGGTATTTCATTATTCTGCCTTCACATCTCCTG ACATAGATCATTGAGTTCACTTGGCAGATTTTCTCCTTTCCAAGTCACCGCAGACAACGG TGTTGACAAAATCTCCACCTCTAAGTAACAGAGGTCCCCTTTCCTGCAGTTTCCAACAGT ATTTACTCACTTTCCTATAAGCCTCACTAACGGTGTTCTCAATACATTTTTATCCTCTGC CTACTAACTCCATCCCAAAGCCAATGCCACATGCATTATACTTTGTTTCAACAGCACCCA CTTCCAAAGACCTAAATCTTAATCGCCCAAATCTAGTGGCTTAAAACAGAATCTATTAAT ATCTATCATGGGCTGGGTGCAGTGGCTCACCCCTATAATCCCAGCACTTTGCTTTGGGAG GCCGAGGCGGGCAGATCACCTGAGGTCAGGTGTTCAAGACCAGCCTGGCCAACATGGTAA AACCCCGTTTCTACAAAAAGTACAAAAATTAGCCAGGCATGATGGTGGGTGCCTGTAACC CCAGCTACTTGGGAGGCTGAGGCGGGAGAATCGCTTAAACCCAGGAGGCAGAGGTTGCAG TGAGCCGAGATCACACCACTGCACTCCAGCCTGGGCGACAGACTCCGTCTCAAAAAAAAA AAGAAATTGTTAATGTCTATCATGGTTTTGGGGTTGACTGAGCTCACTGGGCTGTTCTCA CTCAGGGATCTTACACTGTTACCGTCAGATGGTGGCTGAGGCTAGAGTCACCCTTAGGGC TTCCTCACTCACATCTGGCTGTTGGCTGGCACACCCAGGTGTGCCCTCTCTGGAGCTAGG TTCCGAGAGCTAGCACCCTGAGAAGACCAGGCAGAAGCTGGGTTTCTATGGCCCAGCAGC CCAGAGGTCTTATGGTATCACTTCTGCTGTGGCCACAGGCATGCTCGGTTTCCAGGAGAG GAAACACAGACCCCACCTCTCAGTAGGGAGGAGTCTCAATGCCATGTTTCAAGAATAGCA CGGAGGACTGGAGGTCTTGTTGCAGCTGTCTTAGAAACTAGAACTAGCCACACAGGTTTC TCCCTTTGTAAACTATCTATCCTTCTGTATGTGCTTTTCTGCCCTTTCTCTCGTGTTTTT TAGGTTTTTGTTTGTATTATTCTAGAACTTACTTCCTAGTCAGTTTTATTTTAATTATTT TATTTATTTATTTATTTATTTATTTATTTAGAGACAGGGTCTCACTCTGTTGCCCAGGCT GGAGTGCAGTGGCATGATCACAGATCACTGCAGCCTCAACTTCCCAGGCTCCAGCGATCC TCCCACCTCAGCCTCCTGAGTAGCTGGCACTACAGGTGTGCACCACCACGCCTGGCTAAT TTTTTGTATTTTTTGTGGAGATGGAGTTTCACTATGTTGCCCACTCTGGTCTCAAACTCC TGGGCTCAAGCAATCCTCCTGCCTCGGCCTCCCAAAGTGCTAGGATTATAGGTGTGAGCC CTTGTGCCTGGCCCACCTTTTCTTTGTTTTGTTGTTGTTGTTGTTTGTTTGTTTGTTTTG TTGTTGTTTATCTTTGGGCCCCATCTTTTTATTATAAAGTGTAACACCTGGCTGGGAGCA GTGGCTCACACCTGTAATCCTAGCACTTTCAGAGGCCGAAGCAGGCAGATCACGAGGTCA AGTGATCGAGACCATCCTGGCCAACATGGTGAAACCCCATCTCTACTAAAAATACAAAAA TTAGCTGGGCATGGTGGCGTGCGCCTGTAGTCCCAGCTACTCAGGAGGCTGAGGCAGGAG AATCGCTTGAACCCAGGAGGCGGAGGTTGCAGTGAGCTGAGATCGCGCCATTGCACTCCA GCCTGGTGATAGAGCAAGACTCCATCTCAAATAATAATAATTATAATAATAATAATAATA AATAAAGTATAACACCTATGTTAGGCCATTCTCGCATTGCTATAAAGCAAGCTTGTCCAA CCTGGGGCCCGTGGGCTGCAGGCAGCCCAGGACAGCTCTGAATGTGGCCCAGCGTAAATT CATGAACTTCCTTAAAACATTATGAGATTTTTTTTGCGATTTTTTTTTTTTTTTTTAGCT CATCAGCTATCGTTAGTGTTAGTGTATTTTATGTGTGGCCCAAGACAATTCTTCTTCTTC CAATGTGGTCCAGGAAAGCCAAAAGATTGGACACCTCTGCAGTGTAAAGGAATATATGAG GCTGGGTGATTTATAAAGAAAAGAGATTGAATTGGCTCATGGTTCTGCAGGCTGTACAAG GGTGGCACCGGTGTCTGCTTGGTGTTTGGGGAGCCCTCGGGGAGCTTTTACTCATGGTGG GAGGTAAAGGGGGAGCAGACACTTCACAGAGAAACAGCAGGAGCAAGGTGCGGAGAGGCG CCACTTACTCTTAAAACAACCAGATCTGGTAAGAACTCACTCACTATCACAAGTAGAGAT GGCACCAAGCCACGAGGGATCCCTCCATGGCCCAAACACCTCCCACCAAGCCTCACCTCC AACACTGGAGATTACATTTCAATATGAGGTTTCGGCAGGGACAAATATCCAAGCTATTTC AACACTTAGTCAGCAAAATGAATGAAACATAGATGTACAATTCGGTAAATTATTATATGT GAGGCACAGTGGCTCATGCCTGTAATCCCAGCACTTTGGGAGGCAGAGGCAGGCGGATCA CATGAGGGCAGGAGTTCGAGACCAGCCTGGCCAACATGGTTAAACCCCGTCTCTACTAAA AACACAAAAATTTGCAGGGTGTGGTGGTGCACGCCTGTAATCCTAGCTACTCCAGAGGCT GAGGCAAGAGAATTGCTTGAACTTGGGAAGTGGAGGTTGCAGTGAGCTGAGATTGCGCCA TTGCACTCCAGCCTGGGTGACAGAGTAAGACTCTGTCACCCAGGCTGGGTGTGGTGGCTC ATGCCTGTAATCTCAGCACTTTGGGAGGCCAGGGCGGGTGGATCACAAGGTCAGGAGATC GAGACCATCCTGGCTAACATGGTGAAACCCCGTCTCTACTAAAATTACAAAAAATTAGCC GGGCGTAGTGGCAGGCGCCTGTAGTCCCAGCTACTCGGGAGGCTGAGGTAGGAGAATGGC GTGAACCCGGGAGGCGAAGCTTACAGGGAACCGAGATAGCGCCACTGCATTCCAGCCTGG GTGAAAGAGCAAAACTCCGTATCAAAAAAAAAAAAAAAAGGCTTATTCTATTACTTGTTA CTAATAGCATCTCTTATCTCTTTGAAGATATTTATTATGCTTATTTAAAACTTCTGTTGT GTCCAGTCCATTCATTCTGCTTCCCCTGATATAAACTGCTCAGTTTATTGTCTCCAATTT CTGGCCATTTGCTCCTCAGATGTCTGGTTATTTTCCTGGGGCTGCTAATCCCCTGGGTGT TACAACCCACCTGGATGGCAACAGCAGTGTGTACTGAGCAAGGTCAAGGCTCAGGCCCTA AGCTGTGCCCTCCTGGTGAGCGTGTGTGTGGACACGCCTGGTGAGCTGGAGGTGGACAGA GTTTGTGGCATTAAATTGTAGGCCATAATTCCCCATGTGCCGTCCCCACACGTCACCCTG CCGTTCAAGAAACCTTCCTGTGTCTCTCCTCCAGCACTGCTCTTTTCCAAGAGTCTTTTA CATTTATTTTGTTTTATTTTATTTATTTTTGAGACAGCGTCTCACTCTGTTGCCCAGGCT GGTGTGCAGTGGCACAATCACGGTTCACTGCAGCCTTGACCTCTAGAGCTCAAGTGATCT TCCCACTTCAGCCCCCTGAGTAGCTGGGACCACAGACACACGCCATCATGCCTAGCTAAT TTTTTTTTTTTTTTGAGACAGTCTTGCTCTGTCTCACCCAGGCTGGAATGCAATGGTGCA ATCTCAGCTCACTGCATCCTCCACCTCCCGGGTTCAAGTGATTCTCCTGTCTCAGCCTCC CGAGTAGCTGGGACTACAGGCTTGTGCCACCACACTCAACTAATTTTGTATTTTTAGTAG GGATGGGGTTTCACCATGTTGGCCAGGCTGGTCTTGAACTCCTGACCTCAGGTGATCCAC CCTTCTTGGCCTTCCAAAGTGCTGGGATTACAGGCGTAAGCCACCGTGCCCGGCCTCATT TTTGTATTTTTTTGTAGAGACAGGGTTTCACTACGTTGCCCAGGCTAGTCTCCAACTCCT GGACTCAAGTGATTTTCCCGCCTTGGCCTCCCAAAGTGCTGGGTTTACAGGTGTGAGCCA CCACTCCTGGCCTTACATTTGTTTTAATCAGCTGGTCCTTAGGGAATGGAGAGAAGGGGG ACACTTTGCGTCAGCCTATCTATTGATGTCAGCCATCTCTCCGCTCCTGTCAACACAGTC AGACATCTGTGCCTCCCTGGAACTCCTCCTGCACCCTGGGTTGCTTTTGACAGGTGCAGG ATTATAGGGTGATGGGGGCAGGCAGAAGACACGTCCGCCTCTCCCAGCTTCCCTTCCGCC CAGAGCTGCACCCATTCTTTTCCAAGCTGCCACCACCTCCTCTCCCAGAACCCAAATGCC TCTTTCTCCTCAGGATCTCTCAGTCTCTATGTGGTTTCTCAGTTCCATCTGCTTCCTTCT CTGTTCTGGCCTCTCCACTTCAGTGGTGTAGATTACAACTCCATCTGGCCGGGCTTAGAG GCTCATGCCTATAATCCCCACCACTTTGGGAGGCTGAGGTGGGTAGATCACTTGAGGTCA GGAGTTCGACACCAGCCTGCCCAACATGGTGAAACCCCATCTCTACTAAAAATACAAAAA TTAGCCAGGCATGGTGGCACGCGCCTGTAATCCCAGCTACCTAGGAGGCTGAGGCAGGAG AATCACTTGAACCCGGGAGGCAGAGGTTGCAGTGAGCCAAGATGACGCCACTGCACTATA GCTTGGGTGACAGAGTGAGACTCCATCTCAAAACAAACAAACAAACAAACACCCTCCATC TAATAATCCCGAGAACCTTGTGGTAGATACTCACTCTACAGATGAAGAAACCAAAATTCA GAGAGGTTATGTTACTTGCCTGTGACCACACAGCCTCTCATTGAAATCACTGCAGCTCAG CCTTTTCTCCCTGCCCCCAAATGCTATAAGCCACTCTTGGGAGAATAAAGAAACACCAGC GAGAGCTTTGCTTCCGTCTTTCCAACCCCTGTGGGATACCAGGATGAATAAAGAAACTGT AGTGTTGCCGATTTCCAGCAGGCAGTCTCTAAATCTTCCGTCCTTCTGTATCGCGTATTG CTTTTTATGATGGTTTAAATTATTTATGCTGTTTTGTTGAAAGCTAAGCACGTTGGAGAA ATGGCCAGTAATGGAAAAGTAAAAAGGGGGCAGGCAGACTGTATTGTGGTCGAACGTGGT ATCTCCAACCTTGCGAGACCTCGAAAGTCTGTTGGTGTAGAGAGAGAGAGAGAGAGAGTG TGTGTGTGTGTGTGTGTGTGTGAGAGAGAGAGAGAGAGAGAGAGAAAAGGAAAGAGAGAG AGAGCTGGTTGATGCTCAGGGCTTATCTGGTCACTAGGTCTCTGGTCTCTGTTCCCTGCA CTGATGGGTTTGCAGCCTCTTTGGAGATTATTTCTCTACCTTTCAGTCTTTTTGTAAAAT GAGCATGTTACCTGTCAATATCACAGGTGTAGAAAGAAATTGCTGATGTCATCGCTTTTT TAAAAACTTTGAGCTCTTGTAAGGAAATGCCTGCTATAAATAAGCAGGGTTAATTTTTAG TTACAAACACAGTCAATTGTTTATATAAATATTATAGATCTAAATGCTTGGGCTGGGCAC AGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCTGAGGCAGGCAGATCACTTCAGG TCAGGAATTCAAGACCAGCCTGGCCAACATGGTGAAACCCCATCTTTACTAAAAATACAA AAATTAGCCAGGCGTGGTTGTACTGCCTGTCATCCCAGCTACTCGGGAGGCTGAGGCAGG AGAATCGCTTGAACCTGGGAGTCGGAGGTTGCAGTGAGCCAAGATCGCACCACTGCACTC CAGCCTGGGTGACAGAGGAAGACTCCATCTCAAAAAAAAATTAAATTAAAAATAAATAAA TGCCTAGCTTCTTCCTTAGAGTTGCCTTGTCTTAGAGGGCTGTGTTTCACTGTCTTTGCT TACAATCTAGGGAGGCCTTCAGTGATGCAAAAACGTTTTTCTTTTTATTTGAAAGAGAGT CTCACTCTGTCGCCCAGGCTGGTCTCGAACTCCTGACCTCAAGTGATCCACCCACCTCAG CCTCCCAAAGTGCTGGGATTACAAGTGTGAGTCACAGCGCCCTGCCAGGGTTTTTTTGTT GTTGTTATTTTGAGACAGGGTCTCTGTTGCCCAGGCTGGAGTGCAGTGGCACAATCATGG CTCACTGCAGCCTCAACCTACTGGCCTCAAGCGATTCTCCCACCACGCCGGCTAATTTTT AAATTGTTTGTAGAGACAGGTTCTCCCTATGTTGCCCAGGCGGGTCTCAAACACCTGGGA TCAAGCAAGCCCCCTGCCTTGCCTTCCCAAAGTGTTAGGATTACACATGTGAGCCACCAT GCCTGACACATTTCTCTTTACCATGGGCTAGAGTGCAGCGGTGCCATCATGGCTCATTAC AGCCTGGACCTCCCAGGATCAGACAATTCTCGCGCCTCAGCCTCCTGAGTAAATGGGACT ACAGGACTACAGGTGCACTTCACTATGCCTGGCTAATTTTCTTTTCTTTCTTTCTTTTTT TTTTTTTTTTTGAGACGAAGTCTCACTCTGTCACCAGGATGGAATGCAGTGGCGCAATCT GGACTCACTGCAACCTCCACCTCCAGGTTCAAGTGATTTTCCTGCTTCAGCCTCCCAAGA AGCAGCTGGGACTACAGGTGCATACCACCACGCCCAGCTAATTTTTTTTGCATTTTTAGT AGAGACAGGGTTTCACTATGTTGGCCAGGATGGTCTCGATCTCTTGACCTCGTGATCTGA CTGTCTTGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCTACCATGCCCGGCCATGCC TGACTAATTTTTTAAATTATTTTCGTAGACACAGGGTCTCCCTATGTTGCCCAGGCTGGT CTCGAACTCCTGGACTCCAAGTGATTTGCCTAACTCAGCCTCCAAAGTGCTGGGATTACA GGCATGAACGACTGTGCCCAGCACCAGTTGATTTCTTTAGGATGATTGAGAAATCCTGTG GCAGCCAAAGGAGCCTCATCTGCAGGTCTCTCCATGCCTAT >Mus musculus ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CATGTAACTCTGATGTTGAG ACTTGGGTTGTGTAG-ACCAGGCTGGCCTTGCGTTCCCTGTGTCACTGCCTGGCTAGATG GTTTTATGCATT-TAAAAATTCCTTGTTAAT-AAAT--GAATCA-G-AT-CAGAACAAAA TGTCTTAATCATGTCTTCTACTACAGATTAACCT-CACATCCTCC-C--CACTAGGAGCC TTCTTCAGGTCCTGAGGTGTCTGAAGAGCAAGCCTTACAGCTGGTCTGTAAGATCTTCCG TGTCTCCTGGAAGGACCGCGACAGAGATGTCATCTTCCTTTCTTCTCTCTCTGCGCAGTT TAAACAGAACCCAAAAGAAGGTGGGACTCTTTGTCAG-AG-CA-ACTCCATA~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTTT TCTTTTGTTTTTTGTTTTTGTTTGTTTGTTTTTTTTTGAGACAGGGT-TT-CTCTGGTA- -ATCCTGGC-TGTCCTGGAACTCACTTTGTAGAC--CAAG-CTGGCCT--TGAACTCAGA CA-TCCTCCTGCCTCTGCCTCCCGAGTTGGGATTAAAGGCATGCGCCACCACGCCCGGC- A-TGCTTGGACTTTT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ACATTATCTAACC AGATGAAACTGCCACGAAC-AGGGCTTTGGTTCAGTGATATCCAGAATGTGTCCATAGAT CAACAGTGA-TCAACTAGGATCTGCAAAGAATGAGAAAGGAGCTAGACTGTAGAATCTGC TTTAGAAT-CCAGAGGGTGGCTC-A-GTTGGAGCCTTCAGAGGCCCTTAGGAGCCTTGGA CTCTGTAAAGTGTGTGCTGGCTGAGAAACATAGCTAG-CTGC-ATGTGTTA-CGGTGTTG TAT--GTAGTA-AGGGCAG-ATCTGGTAGCGATGGCTCCTTCTACAGTTAACATTTATCA -ACAGTAGCTCTGACTCACTCTAACTGTTCAATAAGTTTAATTTTGGGATAGTTTTAATT TTAGAAAAGATTGAGGCCGTCCCGAGAGCTCATGCATACGCTTCCCTCAGTGTCCTCTCA TGT-AGCATCTTAAATAAATATAAAATAATTTTTAGAAA-AA-AAATTACTGGGAACCAC AC-CAGAGCTTT-TTTGGGTTT-CAGCTAAAATCCTTTCACTCTTG-AGAATCCAATCCA GGATCCCGCACCGAATCAGATGGGGTCTT-TGGCTTATT--AGGATGGTATAAG-TGAG- --GACCTATGAATAACCTGCTTTTCACTCTGCCTTCCCAACAGTGTTCTCTGATTTTAAG GATCTGATTGGCCAGATTTTAATGGAAGTACTGATGATGTCAACTCAGACACGAGATGAA AATCCATTTGCCAGTCTGACAGCCACATCCCAGCCCATCGCCACGGCAGCTCGGTCACCA GACCGCAATCTCATGCTGAACACTGGCTCCAGTTCAGGAACAAGCCCCATGTTCTGCAAC ATGGGCTCCTTCAGCACCAGCTCGTTGTCTAGGTCAGTGTGGTTCTCT--GCTG-TCTCA CTGGTGG-AAAACAGCTGTGA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~CAGTCCCTCACACCCA-TGG-TGTAGCCCCG--CAGGTGG TGTGCCT-TCCCATCCCTCAGCACCCAGTGTAGCCCCGCAGGCGGCTGTGCCTTCCCCAC CCCTCAGCCCTCATAGTACAGCTTCTGGAAATGCTGCCGGAAGCCAGCCCTCATCCCCGA GGTATCGGCCCTATACTGTCACGCACCCTTGGGGGTCTTCAC-CTTCCCCACCCCA-CGA TC-CTCCAT-TCTGGCTAGC-TCCCCAGTTCCCCCCACGCAGTGTCCCCGGGCTGTACCT GCCAGCTCCCCAGCAG-AGGCCCCCAGCAGGGTC-CCCGCCTT-CCCACTGCCTCGCCCA GT-GCCCCAGCAGAC-GTCCCTCTC-CCTGCGGATCTCTCCTAG-GTATATTTGCAGGAG AGCT-GCG-TGT-GTGTTTGCAG--TG-CAGGGAGAGGAAATAACACGGTTTGGAAAGAA CTCTGTTGAACTGACCTCTTGAATTCTGGGAGTCGCTGGGTTATTAACCTG-TATGCTCG CAAGCTGTGGT-AGGCATGCGCCTGCCTCCA-TGATTCTGGCAGCCTTTTGTC-CACGAG GA-AGTGAGACGCCCTTCCTCCCCTGTCATTCCTCCTGT-CATCTGCACACAAAAAC-CA AGCACTCCACCTTCTTCTG-T-GATCTAGTCCTCGGAGACCTGGCAGGTTTTG-AG-AAA TGGGGCCCAGGTGCTTTTTACTGCCGGTGTCTGCTCTTTCTATGATCCTG-CGTTTCGTC TTGAGTCTGA-TTGCATGTA-GTTCAGTCTCTCAGAAAGCAGCAGCCGCAGC---CCAGG AATCTGGTGGCCCCTTTT-TCAAATGTCCCTGG--GTGTTTCTGTAACTCAGGACG-TTG TGTTTCTGCATGTCAGTG-CGTACAGCTTCCGAGTGTGATTTACTTTAAATGACAGCCGC AGCAGCAGCTTCCTCCTGTTCCCTCTATCCTCTGTCC-CTGATGACCTTTTTTGCTTTTG TTGTGGTAGTATGTCCAACAGCCCTTTCTCCTTCCTCTTCCTCGAACTTTCTGGGGACAG TAGTGATGATGATGAAGAAGAAGATGAGGAGGA-GTTGGTGAAGGTGGTGGTGATGATGA TTTTTCT--T-ATGTCCAGT-TTGGGTCCAGGT~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GG AAATGTGAGATTCATTAGAGAAGAAAC--ACACAGGATC-CTGTAAGAGCAGGTGTTGTT ATTGCATTTGAAATGTAATTTGGTCTGCCTGGACATGAGATGTGTGTTATTTTTGAGAAT ATTTTCATTGT--TTGG-GAT--ATTCTGTTACACTCCTGTTCTAGGAGGTAGTTACCTG ATTACACCTCACAG-TGCTG-ACTGATCAGACTGTGATGTCGTTATTAGAA-A-ATGCTG GTGTAAGTTTTTAACTGCTCTTGGGACTTAAATATGAAACGTTTCTAGGATCTTAGGATG TCAGAGCTGTGCAAGGATCATGAGTGTGG-AG-GCTG-GGGA~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~AGTGGTGCCACTCGTTTTGGCTCATGAACCTGTGGTGACC CAGCC--TGCTCAACGCTCAGCAGCAGTTTCTAGTCCTTCCGATTTG-TAAGTTAGCATC CCCAGCAAGGC-CAGGTCGCCCTGACAGGCTAGGGTGTTTCCCAGACAT-C-ATTGTTGG CCTGGGCGCAGACAAAGCA-GCAATGAGC-TGCAGTGTGGCTGCATGGGGAATTGTGCTT CACCGTGGGTGCAGGCTTC-TAACCGGCTTTGTGCTCTAGAAA-GCTGTCTCTAGGAGTG GTACTGAAGAGGAAAGCATTGTAATCTGTT-TTCTCTTCTCCAAAGTTTGGGAGCCTCTG GTGGAGCAAGTAACTGGGATTCGTACAGTGACCATTTCACCATTGAAACCTGCAAAGAGA CGGACATGCTGAACTACCTCATCGAGTGTTTTGACCGAGTTGGAATAGAGGAAAAAAAAG CACCAAAGGTACT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~TTTTTGGTTCTT-TA-TGCTGACTGTTGTCTCTC-TTCTCAG ATGTGCAGCCAGCCAGCAGTCAGCCAGCTTCTGAGCAACATCCGCTCGCAGTGCATCTCC CACACCGCACTAGTGCTACAAGGTTCCCTCACACAGCCCAGGTATGACGACGACACTCGT GCTTG-CTTTGGGTGGGAGGGAGGCC-AGCGCTCAGTGCCTGTCAGCCGC-CAGTTG-TT -TTATACCATGGT-GAGAACTC--TGGGTC--CTGTATTGTGACTGTCTCT~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~CATCACAGCCCTTGCTCTTCCTGCATCTGCAGGTCCTTGCAAC AGCCATCCTTCCTCGTGCCGTACATGCTCTGCAGGAACCTCCCGTACGGCTTCATTCAAG AGCTGGTGAGGACCACTCACCAGGATGAAGAGGTGTTCAAGCAGGTATGCTC~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~TGAGGTTTCTTTGGAGAG-AATGCGAAG-GAAAGGGA -CTGGAG-ACCCCAGACCA-CGTCCTGCCTTTTAC-CTAACAGGTGCGGCAACTATGACC TGGTAAGTCCTTGACTGGAATTTCTACTTCCTCT-AATGTTTGAGTGATGTTTCCAAATG AACAAACAGAAGTTAGAACTTAAGTAAGG-GCTGGAGA-TTAGCGTAGCTTCTATCTCCC CT-GGAGGTCTT-ACTTGGAAATAAAAGAGTAACGTTTAGTATGCAGGTCACAACAAGTA TGGTGCCT-AGGCAGGCAAGC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~TGTGGTTCTCTTTCTTACAGATCTTTATCCCCATTTTACAAGGCCTGGCGCTGGCTGCC AAAGAGTGCTCCTTGGAAAGCGACTACTTTAAGTACCCCCTCATGGTAAAAGCTCAATCT TTCTTTTTAATTGATATA-TAAATAATCCCCT--CATGGTAAAA-G-CATATTCTTTTTT TTCAGATC--TGTGTTTAACCTTGTTTT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~AAGCATTTGCAGTGGGAATGAAAGCTGTTCCTTGCTGTCACACATGACAGTGTGAGAC AGAAGACATGCAGTGAT-TCTTTCCCTTCTTGTTTCTAGGCACTGGGTGAACTCTGTGAA ACCAAGTTTGGGAAGACACACCCTATGTGCAATTTGGTAAGTGTCCACCGGGTGAGTCTG CACATGATCTCTG--T----CA-ACCGCA-AAGGCAGTTTTAAAGT-AGATCGCCAA-AG ACT-TCTCTTGAAAGACATTTGTATGTGGGCGGGGCTACCCTCTGT~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~CAGCTGCCT-TTGAA-G-CTTACCTGGGCCCTCTGTCCTG TGTCTAGGTCGCTTCTTTACCCCTGTGGTTGCCGAAGTCCTTAAGCCCTGGTTCTGGGCG GGAGCTGCAGAGACTCTCCTACTTAGGGGCCTTCTTTAGCTTCTCAGTCTTCGCAGAGGA CGATGTAAGTATAGTG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ATTCCTTGCCCAC TGTGCTCTTTGTGTTGCCTGCGTCC---CCTTCTCTT-CCAGGCAAAGGTGGTTGAGAAA TACTTCTCAGGGCCTGCCATTACCCTGGAGAACACACGCGTGGTCAGCCAGTCACTACAG CATTACCTGGAGCTGGGACGGGTAGGTGTTGAGA~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GTAAAAAAGAAATCAATTGTTTTTTCATTT TGAAAATAA-TTT-AGCAAGAACTTTTCAAGATTCTACATAGTATTTTGTTAAATGGCGA AACTCGTGAAGCGGCTCTCAGCTACATGGCGGCCCTTGTCAATGCCAACATGAAGAAAGC CCAGATGCAGGTAGGAGTCCC-CA-AGTGCTTTCAGTTACTCATTAAACTGTTTCTCCAG TGC-AGATGTACTTTGCGCCTCCCAGGCTGCGTTCTGGGGGTTGGGAAGCAGTACAGAAC AAGACGGGCAAGCATCCTGCTTCTGTGCAGCCCGAGGTCT-CAGGC--AGGGGGTGGCCA TGCAAGCACAGCATCC-AGGCAGTAGTAG--TCGCTGATGGAAGT~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GGGTCCTGCAGCAGCT AAGTACAAAAATCAAGTTAGAAACAGTTGACCCCACTTACATATTCCACCCAAGATGTCG GATCACTCTCCCGAATGATGAGACACGGATAAATGCAACGATGGAGGATGTGAATGAGCG GCTGACAGAGCTCTGTGAGTGATGTGGGCCTGGCCCTCTCAT~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CACAC AAATGCACACGAAATATTCTAGGCTCA--TAA-CTGTTTCACTGAAGGATTCATGTT-T- GTTTGTTTGTTTGTT-TGCT-TT-TCTTTG-TAGATGGTGATCAGCCTCCATTTTCTGAG CCAAAATTCCCTACGGAATGTTTCTTTCTCACCCTGCATGCTCATCACCTCTCTATTCTG CCTAGTTGTCGTCGCTACATTCGCCGACTTCGAGCCATCCGCGAGCTCAATAGGTATGTG CCACGCTCGC-TCTCCTGGC-TTGC-TG--TTACTGCTGCCTA-CAGGCACAAGGAGTTG G-TTGTGGTCAGAATGTCTGAGAGTAGGCTGTGGCAT-TAC~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~CAAAGTACTTCCTGTGAGA--CAGTTAGGTTCGAGAGTTGAATGGACCAGG TGGTTTCATTTCATTTGATTGTTAAGA-TGTTTGTTTTTAATTTTAGAACCGTGGAAGAT TTGAAAAATAATGAAAGCCAGTGGAAAGATTCCCCACTGGCCACCAGACACCGTGAAATG CTGAAGCGCTGTAAAACTCAGCTTAAGGTTTGTACAGTTGATTGACATAATTATGGCCCA GCTTCTTAATAGCAATCCCCTTGCCAGAGTATGCACCCTGAGCAAGCACTCTA-TGTCC- CTGTTTTTCTTTGTTGTTCTTTTCTCT-CAAGTACCACAGGACTTGTTGCTACCT-TGCA TAT-TTCCGTATCTCATTATTTAA--ATCTCAG-CAGAGAACACAC-ATGTGTATATCCG GTTGAGTCGTTAGTAAGTGTTCT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CTGA TGGCCCTCTGTCAGTGGCTTGCATGGCCTATCTTCCTGTT-GTCTTTAT-TCTGAAAACA GAAAGACCCTGACACAACCACC-AGGTCCCGAGGCTAGGCAAGCTACCGAACCTAGACTT CTCATCTCCTGGCCCC--TCACTGCCTACTCATGCTCAGGGGCCATGGC-ACTGACTAAT CTTCGGGCGGGGCCATCC-T-CTTCCACAGAAACTGGTACGGTGCAAGGCCTGTGCTGAC GCTGGCTTACTTGACGAGAGCTTCCTAAGAAGATGCCTGAATTTTTATGGCCTTCTCATT CAGCTGATGCTGCGCATCCTGGACCCTGCATATCCTGAGTAAGTGTGCTCTTTGCCGTG- CC-TCGTCTCACGGTGGCTACGGGCTATTGTCTTGAGTCTAACTAAACCTTGAGAATT~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CAAGAAAAGAAGA TGAGG-CAAACACTTACAAA-ACACGCCCAGGCTTCCTCATCCTTTCTGCACA-CTGCGG GTAGTCG-TTTGCCTGTGCACTT-TTACACAGTGTTACACAGTGAGGG-CTGCTCTTTCC -ACATGGGG--CATTTGGAAGTACAACACCCCAGGTAATCAG-TGTTCCATGATAGCATT TG-TAAATTGTGGGGTTTTTCTCCTCTACAGCGTAACACTGCCTTTGAATTCAGAAGTCC CCAAGGTATTTGCAGCATTGCCTGAGTTTTATGTCGAAGATGTTGCTGAATTTTTATTTT TTATTGTACAGTAAGTACTTCCCGTACTGTA--T-GTTCT--TCTGCTTATACAC-TG-T -GCCTGGTCCTCTGAGCTGTGT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~AGCAGCT-CTCCGAGA-CTCAC-CATG-TGTTTT CTCCTCTTTACAGATACTCTCCTCAGGTGCTTTATGAGCCCTGCACTCAGGACATTGTCA TGTTCCTCGTTGTGATGCTGTGCAACCAGAACTACATCCGAAACCCTTACCTAGTGGCCA AGCTGGTGGAGGTCATGTTCATGACCAACCCTTCTGTCCAGCCGAGAACTCAGAAGTTCT TTGAGATGATTGAGAACCATCCTCTCTCTACCAAACTGCTGGTGCCGTCCCTCATGAAGT TCTATACAGGTGGGTTTCAGGTAGGCCCTGGGGTATGTGGTAATGTA-CTTACCCAAGGT TGTTTCA-G--AGCG-A--ACTTAAATCTAAATCTGTGACCTAAT-TCCAAATAGATAAA TAAATAACCTGCTAAGCTTTAACAT-CTGCTTATGTAAATCAC-TTC--CTAGCCCC-AG C--TCAGGCACAGGCTGTCCATGCCTCCTCCCGGCCTCTGA-GAGTC-GCACTGGCCACT GCGTGTCGGCTCCGTTG-ATTTACACTGTTCGTTTTGTTAGTCCAAGCTGAT-GTTTTAT CTGAGTTGT-TAACCTGGTTCATTTG-CTGTTGAGTTTACAGTATCTGATATATAACACC ATCCTGTGGCTGCCTTTTCAAAGAGATGG---AACAGGGAGAGTTTGATATATGCAT-T- CTAGGTC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTCTCTCTGTCGTGGAGCACATCCTCTG GCCT-GAGCCCTTCCATG-GTCATGGTAAT-GACACCTTTTAAT-AATAGTTGCCACTTG TGTCACTTGATCCGAATAGCCATGGAAAAGATGGTACTATAAATACGTCCATTTTCTAAG TGAGGAAACTGGAGCTTAGAAAGGTCAGGATGCTTGCGAAAGGTTAAGGCCT-GTGAGTG GCAGGTGC-TCGCAGCTGGACTCTAGCA-AG-TGTGCCTGGCTGCTCTTCTGGCCTTCAC CCTGCT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTTCTCCTGTGC CTTCCGTCTGAGACACGGGTAGCGCTTC-CCAGCTCACTGACTGAGAACGGGTACACTGT CCCCGTGTCACTGAGACAGCCATGTCTGCATCTGGAAGGTCAGGATGTG--TGTC--TGA GTCCCTTTGTCTTTCCTCCTTAGATGTCGAGCATACTGGAGCCACCAGCGAGTTCTATGA CAAGTTCACAATTCGCTATCACATTAGCACTATTTTTAAAAGCCTTTGGCAAAACATAGC TCACCATGGCACCTTCATGGAGGAGTTCAAGTGAGTATTGGGGCC-TGATGGCACAGCTT GCTCTCAGGCAGAGCACAGGTGGGAGGGGAGCTTGAAAGCCCGCCCAGC-GGCTCCCTGT GG-CTGCTTTCT-G-TCTCTGCCTCTCTCAAGTA-ACCACAAGACACTGCTCAGCGTGGA CA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TCAGCATTTGC TGCTTTTC-ACAGTGTAACAATGTAAATAGTTGCCAAGTTTAAACTGCCAAGGAAGTCAG CTCAGGGAATTCTGGACTATGTATCCGCTGGCTCCTACCAGCCCCACAGTGTGG-TCCAG CTGCCACTTGAGTGAGCTTGTCACAGTGAATGGGAA-GAG---CAG--TG-AGGCAAGCT -TGGTGGCGCCTGTCTGTCATCCCAGCGCTGTGATACGAGGAGGAGAGTAGTTCGATTCA GCCTGGG-GTAGGAGGA-AGACCTTTCT-CAAAACCACCACCAGGGAGTA-ACAAAATCT AA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~ATTTGCAGTGTCAGGGGAG-T-CTTGGTACCTGGGAGTTACATTCTCTC TCTGCC-CAGCCAGGTGT-TCACCACACACTGTCTTGTTGCCCTTTCAGTTCTGGAAAGC AGTTCGTTCGGTATATCAATATGCTAATAAATGACACGACCTTTTTACTGGACGAAAGTC TGGAGTCTCTGAAGCGGATCCATGAAGTGCAAGAAGAGATGAAGAACAAAGAACAGTGGG ACCAGCTGCCTCGGGTGAGAACCGCCTCT-GCGCCT-GTACGGCTCTGGGGGGCGGGGGG GTCGGCACACTGGCTGACTTTCTGTGGGGC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TT ACTTGA-GACAAATACTATTATTCTTCCCTTAATGGATTTTTTTTT--TAAGCACAAGTT GCCTCTAAGGTCTATTCACAGACAGCTTTTCCTTGACCCTTGACCCTGAGGTTCCTGGCG CCTTTCCTTCCTCA--TCCATCCCCCAGCCTCCAAGCAATGGTAGCTC-CAGACTCAGTC -CTCTACTTTAA-GTATCCCCGCCCCTGCCCTTGG-GTAATTTTCTGTGGGGCACTAACA GGTGTAAGCATATCTC-TG-TAAGAAACTGTTGCATTTAACACCAGCCATGTGTG-TCTC TGTTTTCAGTCTGTCCATCTCCTTCATCTACCCTCC-ACCCCCAACCCTCTCACACAGCC AAACACTCCTGCACGTTCCCTGATG-CCTCTGCTGAAG-TCACTGCCAGGTGATCTCATC TTTTCCAGGGCTTTAAATATCTGTATTTTAAAGACTGCAAAATATGGCTGCCTG-CTTAG AGC-G-CTCCTGCCT-GCAGGCCT-G-AGCAGTGTGGCCTGCTTTGCTT--TGGCTGTGC CCTAATTGCCTCAGTTGAC-TTGTCCTTATCTCCTCTCTGAGTCACAATGACCTTAATCA ATGGCAGCTTCATTCTACCATTTCCTGGTGCCCG-TGATTAGTCTGTGCCCCTCCCCTGT CTGCGTCTTTTATCTCATGGG-CTAAGCTTTAG-TTCAGTGGTGGGCGCTCTGGGTTCAC TCCCCAGTACCTTCA-ACAGATGTGGTCTGTCCCCCTGGA-ATGGCAGTA-CTTAG-GAT TGGGCAGGAAGGTCAGGACGAGTGTGTGTGCCTCTTCCTTCTCCT-TCCAAG-TCACATT CTGATTACCCTCATTGTT--GCACAGC-ATACTCGTAGTCCCACCTCAC-CAGTGCCATA GCCAA-GG-GAT-GCC-CCTTCT-CACACAA-AGG-CTTGGTATC-CTA-GCGGGCATG- TC-CACTTTTCGCCCTTAGCTCC-CAACCCCCTGACCCCCAGTCT-ACTC-CCTCCATCT AATCCCCCCTCCAGCT-ACTCCCCCC-CTCCAGCACCTCCCCCT-CCAGCTA--CTCCCC CCTG-GCCTTTCCCACTCCTTTTGATTCACGGCCCCTCTTCCC-ACAGTGC-TGTTGACC CAGACT-GAAAACCTGGCTGGGGCTTCTGACCCCACATCATTCTTGACC-TGACTCCCCA A-TTCCTGTCAGCCTTTTTGTGTGTCTATT-CAAGGGGTGTGATACTTTATTAAGCAATC TCAACAGAGTGGGAGCTCTGAGCCATTGTGTGCT-TCTCCCATGCCTAAGGACTCCATAA GGGAAAGATGGGATACTCAGACTCACACTGAGGCCATTGAGGCCTGGCTGTTCCTGGGCC CTTCCTGGTGCAGC-TTCCTCTCAATAGGCTCATTCTTGCCCAGGGAAGGGCAG-CTCAC CAGCC-CACTGCAGAGTCTCCACCAGGCACGGAGTGCAGCAGCAGCCCAGAGGGAACTTG CTGGGCTGTAGCTGCCATTCCAGCTGTTTGCCCTTCCC~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~CTTGGCCAAGTGCTGAGTAGCCGGCTGGTACTGAGATTTCTTT GGCAACTGTTTGATGTTTCCCAGGATCAGCAGCAGGCCCGGCAGTCTCAGCTTGCTCAGG ACGAGCGTGTTTCCCGTTCTTATCTTGCCCTGGCAACTGAAACCGTGGACATGTTCCATC TCCTCACCAAGCAAGTCCAGAAGCCGTTCCTGAGGCCAGTGAGTAGAAACTGGGGGCT-T GTGTGATCTTTAAGGGTCTGGGTACAGACT-TATAACTCA~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~CCACTGGGGTAGGAGCTTCTGGGCCTGG--ACTT-TG-CAGCAGCTTGGACC GTCCTGTTGTCCT-TCATTTCCTAGGAGCTTGGTCCCCGATTAGCAGCCATGCTGAACTT TAACCTGCAGCAGCTCTGCGGACCCAAGTGCCGGGACCTGAAAGTTGAAAACCCAGAGAA GTATGGTTTTGAGCCAAAGAAGCTGTTGGACCAACTGACAGATATTTATTTACAATTGGA CTGTGCTCGCTTTGCTAAAGCCATCGCCGATGACCAGGTGAGC-ACT-GAGGAGGCCCAT CTCTCAGGAGGCTGGCA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TGTTTTCTTCTCAAGTGTATT CTCATCTTACGTGACC-TTCCTTGTGTGCAGCGATCCTACAGCAAGGAACTGTTTGAAGA AGTCATTTCAAAGATGCGGAAGGCGGGAATCAAATCCACCATCGCAATAGAGAAGTTTAA ACTTCTTGCAGAGAAAGTGGAGGAAATCGTGGCAAAGAATGCGCGGGCAGAAATAGACTA CAGCGATGCCCCGGACGAGTTCAGAGGCAAGT---C-CG-CATGCTCATGCAGTGTAACT TGGAGT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AG TGTGTTCTGCTCTGTCTCCACAGACCCTCTGATGGACACCCTGATGACCGATCCCGTGAG ACTGCCCTCTGGCACCGTCATGGACCGTTCTATCATCCTGCGGCATCTGCTCAACTCCCC CACCGACCCCTTCAACCGCCAGATGCTGACTGAGAGCATGCTGGAGCCAGGTAGAGGAGG GTGCAGCCAGACGTGCGG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GGAAGAGCC-TGTCATCCGGGTCATTCAT CC-CCTGTGTTTCTCC-CTCAGTGCCAGAGCTAAAGGAGCAGATTCAGGCCTGGATGAGA GAGAAACAGAGCAGTGACCACTGAGGCC--CCATCGCTCCTCCGCTGGAAG-C-C-GCCA CG-CCAGCCAGCCAGGCCGCAGCAGCGGCCGCAGCGCATCTGCC--TCGAG-GCTGCAGC TCCAGCCTGT-AA-CCAGATGT-GGCCAATCCTGAGAGCCCACCCG-TGTGACCAAACAG GAGATCGAGGGGATGACGAGAAGGATTCCTGTACATATATTTAAGTGACAA-CA--GTCA AA-GCTTGAGGGACGAGTTT-ACGATGGCTTGTGTAGTAAAGCGCACCCTTCGCCTGTCG CACCTGGGGGCAGCGGAAGTGTTT-AGTGA---CAAGTGGGTCTGGGCAGCTTCCCCTGA -GC-TTACGTTTTGTTTTGTTTT--GTTTTTTCGAT-GTGAATAGAGAAC~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~TCTCCCC-TCCCTCACCCTACTTGCACTGCTGTG GGTTTTTTAAAGAGAAACAGAACCA---G--A-CTCCTTTCCC-GGCCCTCCAAACATGT ATTCTGTGCGATAACTGTGCCTGCGAC-AAGTGTTAATCTTGGGATCGTATTTTTATATC ATATTCACATACTTGTTTTTTTAATTGGTGTTAGATGACATGATTAATAAAAAAGGCAAG ATATTTTCAGAATTTGAATTTCAGTTTTTTTTT-CTTTTGAAATAGCCCTTTTAAATTTT TTTATTATAAACAAAATGAAGAGAACCCTGTGGC-CTGGTCCTTCTAGCAACCCTCAGTT AAG-ATCTGAGGGACAGGTGCAGCAGCAGCT--GGCTGGA-GTGGATCAGGACTCCTGTG ACTCGTGGGGTGGGGAGGTGAGGGGTGTGTTTGTTTTTTGTTGTTTTGTGTTTGTTTTAA TCCTTGACAATTCCACTATGCGGTTACCTCTGAGGATAAGTTCCTCAGCCCGGG-GTTTT TTATATGCTGTGTCCTTTTGGG-GTTTGACCTTACAAAAAAAAAAAAGGGTGCAAGAATG TGGAAATCTGTCTGCTTGTTT-A-CATGGCCCGACAA-CACCACCT-AGGCGCACGCGAG CAGAAGCCCTCTTGTATTACCGCTCCCTACGCAACATACTTGAATTCTTGAGTTCCCTTT GGGGTGAGAAA-------GGATTTGAAACCATAAAGTGTTTTAAAGAAATGAACTCTTCA GAAA-CAGACTTCCTTTTTTCCTTTC-TCCTCTGC-TCCACAGCCTGTGCTCTGT~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~TACTCTAAGCCACTCTTATTTGTATAAAGAAACACGAGC AAGGACCTTGCTCCAGTCTTTCCAAAGCCCCTGGGATCCCAGGGCCAGTGGAGGATTTGT GATATTGCTGGTTTCCAGCAG--AGTCTCTAAATCTTCTGACCTTTTGTATCGTGTATCG CTTTGTA-G-TGGTTTAAATTATTCATGCTGTTTTGTTGAAAGCTAAGCATGTTGGCCAC -TGAGG-GAAGGGGAGAAGTGGAA--GGCACAGGCATTGTGGGAGGTTGAGGCTCTTGGC ATTGCGAAGCTTA--AGAC-TCTTG-GT--GAAGGGGT-GTGTGTGTGTGTGTGTGTGTG TGTGTGTGTATGT-TGA-TCAGACACAGACAGACAGAGA~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >Rattus norvegicus ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TT TCCTGCCCAGTGTCAATTGATTCTTGGTGCGGAGTTTTAGAAGAGAAAAGGCATGTTTCT CTTCTGTATTTAAAGCATGTCCCAGGTGGATGTGGATTCTGGAATCGAGAATATGGAGGT GGACGAGAACGACCGAAGAGAAAAACGGAGCCTGAGTGACAAGGTCAGTGAGGGAGAAAG ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~TATCATTACAAATA-TCATTTTAATAA-ATTAACGAATTGTGACA-AAA TGTGTTAGTCATGTCTTCTACTGCAGATTAACCT-CACATC--CTTCCT-ACTAGGAGCC TTCTTCAGGTCCTGAAGTGTCTGAAGAGCAGGCCTTACAGCTGGTCTGTAAGATCTTCCG TGTCTCCTGGAAGGACCGCGACAGAGATGTCATCTTCCTTTCTTCTCTCTCTGCGCAGTT TAAACAGAACCCAAAAGAAGGTGGGGCTCTGTCAGAGCAG~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AGAATTTAATCCA GGATACACCACCGAGTCAGTCTGGCTCTTTTGGCT-ATTAGAGGACCGTCTA-CATGAG- --GACCCATGAGTAACCTGCCTTTTATTCTGCCTTCCCAACAGTGTTCTCTGATTTTAAG GATCTGATTGGCCAGATTTTAATGGAAGTGCTGATGATGTCCACTCAGACACGAGATGAA AATCCGTTTGCCAGTCTGACGGCCACATCCCAGCCCATCGCCACGGCAGCTCGGTCACCA GACAGAAACCTCATGCTGAACACAGGCTCCAGTTCGGGGACAAGTCCCATGTTCTGCAGC TTGGGTTCCTTCAGCGCCAGCTCACTCTCCAGGTCAGTGTGACTCTCT--GCTCACCTG- CTGGTCATGAAACAGCCATGAAGGACTTATGCCAGTGGAGTGCTTGTTG~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~TCCCAGTCCCTCACCCTCAAAGTGCAGCCACGCTCCCCTGA -GTCCCCACATGTCGCCCCACAGGCGGCTGT-GCCTTCCCCGTCCCTCAGC--TCC-CAC AGCACAGTTCTGTCATTGCTACCGGAAGC-CAGCCGTCATCCCCGAGGTATCGGCCCCAC CGTCACGCACCTGTGGGGTCT-TCACCT-TGCCCCACTCCACGATCCTCCATTCTTGCTA ACCCCCCAGGCTTCCCTGCCCACTCAAGTAGTCCCCGGGCAGTACCTGCCAGCTCCTCCA GACAGAGGCCCCGCAGCA-GGGCCCCCGCCTTCCACCCGCCTCGCCCAGTGCTGCCAGCA GACGTCCCTCCTCCCTGCGGATCTCTCCTAGGTATTTATTTT-CAGGAGAGCTGCGTGTG TGTTTGCAGTGCAGGGAGAGGAAATTAACATGGTTTGGAAGAACTGCTGTGTGACACTGA CTCAGTTGAATTCTGGGATTGGGTTATTAACCTGTGTCGCTGGCTAGCTTGGTGGACACG TGCCCTGCCTCCATGATTCTAGCAGGCTTTGGTCACGA-GGAA-GTGAAGACCTCTGTTT TCTCTCCCTCCTCCCTATCATCATCCTCCT-GTTGTCGCAC-CA--AACCCAAAGAAGCA TCTTTTTCTGTGACCTATCC-ATCAGTCCTTCC-TCAGAGACTGT-GGTGTGTTTTGAAA TCGGGGCTCACAGGATGC--CTTTTTGA-ACTGGGCCAGGTCTGCTCTT-TCTTGA-GTC ATGCGTTTATGTCTTGTGTCTGATT-GCATGT-AGTTCCAGTC--TCTCAGAAAGCCAGC AGCCCAGGAATCCGGTGGCCCCCTTTTTCATGTCTGCGTGACTCTGTACCACGGGAGTTG TGCTTCTGCATGTCAGCG-CGTTCAGTTCTAGTGTGACGTCTACCTTGAATGACGGCC-- TGCGGCGGCAGCAGCACTTCCTCCTGTTTCCTGCTTTCCTC-TGTCCCTGATGACCTTTT CTGCTTTTGT-TGTGGTAGTATG-TACGACAGTCCTTTTCCTCCCTCTTCCTCGC-ACTT TC-TGGGGAAGTAG-TGAAGAAGAAGAAGAAGAAGATGAGGAGGATGATGATGAAGGTGG TGGTGATG---ATGATTTTTCTTGTGTCCAGTTTGGGTCCAGGTATCACAG-AATGGAGT CTGACCC-TGCATGTGCTTAGGTGCTTAGGGACTAACGT-TAGAAGCGCTGCTTAGGGCT CTGCTTTGAGTCCAGACAGGGCAGAGGCTCGC-AGGCGTGCACTCGAGTAGAATGACACA TCC-GACATTCTAAAGTGGTAAGAAAACTTATCCGAGTATTT~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~CCAGGCTGTTCACAGAGACTCCAGGTGTAAATAGCGAC--TGCAGTAAAGTGGGT GAGCTTCATT-GAGT--TT-GAGGCTCC-TGAGGAGAGAGAGGAATGTTGATGCAGGGGT GACTATTGATTCCAAAAGATCAATGTTTGTATTAAGTTGAATATTTTATTATCTGTTCCC AAGTAAATATCCCAAAGGGGAATGTGTCTTTCTTGTGCCTGTAACGTCCCATTGGC-GAC TGT--TCACACAGTAGACATC-TG--TAGGGATG-GCCTCCACATGGTAAAA-TACT--- TCATCTGTTTTGA-GTTATCTGTGGGTGAAATGTTTGGTTTATTCTTTAACAAGTCACAC GTG-CTTTTACTAATAACCTTTTTAGATTCTGTGCTGCCTTGCCTGAGGTC-CAGGTTCT GTGCTTCTAGCTGCAGTGTGTTGTTTAAGGCCTG--TGCTCTCTCTG-TGTG-GGACTTA AATGGAG-AAGCGGG-AACCCTAGCT-CAGGT--TC-TGCCCCTCTACCCGACTGTTGTG GCCTTTG-TGTGTTCCCGTCACTGCTGCTCTGGTTCTTGCTGTGGTCTTCTGT~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~TTTTAAACTTCAGATAGTGTT-CAGATTTTCAT TTTAAACACCAAGTT-ATGT-TTT-CACTGACATATGTGAGAGCTCCTCA-AGGAAAATT ACTGCGAATTACACATAGGAGCAGGGCTGTATTAGCAAAGC-CGTC-TTGGATGATGCAG TAAACATGATCAGGTAAAACTCAG-GTT-GCTGTGGGTCAGGCAG-GCTTTTCCTGAGAC TTTCCAGGATTGCTACAA-CACAGGTTGAGAAGGTTTGTGTCCTGTTGGGTGCATGCCTG GGCTTTTCCCAGTTCTCGCTT-CTGTTTG-GCTGGTT~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TGTGCTCTAGAAA-GCTGTCTCTAGAAGTG GTCCCGAAGAGAACAGCATTGTAATGTGTTTTT-TCTTCCCCAAAGTTTGGGAGCCTCTG GTGGAGCAAGTACCTGGGATTCTTACAGTGACCATTTCACCATTGAAACCTGCAAAGAGA CGGACATGCTGAACTACCTCATCGAGTGCTTTGACCGAGTTGGAATAGAGGAAAAAAAAG CACCAAAGGTACCGTGATGTGGATTTACCAGGAAGAAAGCAAACCTACTGACACATGTGC TGATCCCTGCCCCAGGGACAGCTGTT-AGGTAC-CAGGCAGTGTA-CGAGCA----GCTT TGGCCCTGTCTGAGACAGAATCC-AGTC-CTTAG-AGCTCAC-ACCACCATGAGACAGAT GGTCACCAT-GTAGATGTCACCATGTGATGGTCACAGTGG-ATGGTGTGC-CAGAGCTCT GCTGTTATCGGAGGCCTCGCTTGCAGTC-CTGTCGCTGTCTGCCGTCTGT-ACTGAG-TG GGCCTGATAGTTG--CTGGTGTGTCA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~TTCT-GTATTC-TGACTGTTGTCTCTC-TTCTCAG ATGTGCAGCCAGCCAGCAGTCAGCCAGCTTCTGAGCAACATCCGCTCGCAGTGCATCTCC CACACCGCGCTAGTGCTACAAGGGTCCCTCACACAGCCCAGGTATGGTGACAC-T-ACGT GCTTGCCGGGGGTGGGTAGGGAGGGCCAGCTCTCAGTGGCTGTCAG-CTGCCTCTG-ATT -TT-CAGCACGTT-GATAATTC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TCATTGACCAG-TCAGCACCCAGG---AAT TCTACAATTTTATAGGCAGAAAATGGTTTGTCTGGGGGAGGGA-GAGACGAGCGCATGGA CCACAAGCAAGCTGTCGG-CAGAGCACGCGTGCTT-GCTTCCCTCACACCTA-ATGTTTG -TGCT-TCTCTTT-CTTACAGATCTTTATCCCCATTTTACAAGGCCTGGCGCGTGCTGCC AAAGAGTGCTCCTTGGATAGCGACTACTTTAAGTACCCCCTCATGGTAAAGCTTAAT-CT TCTTCTGTAATTGA---AATATAAGTGCCCCCCTCGTGGTAAACGCTGGT-TCCTTTTCT TTCAGATG--TGTGTTTAACTGTCTTTTCTTTTTT~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTGTTGTT TGCTTGTTTTTTTGTGTTTTAGTTCAAGGTGTGTCTGTGTGTGTGTGTGTGTGTGTGTGT GTGTGTGTGT-GTGAAGTAGTtaacctATTA-AGGC--TG-ATGGCTTCCCAGGGAGCTT CCAAGCATGTGTAG-AGGAGATGAAACTGTC-CTGTGTGTCACAAGTGGCA--CAGTGTG AGACGAAATGCAGTGAC-TCTTTCCCCTCTTGTTTCTAGGCACTGGGTGAACTCTGTGAA ACCAAGTTCGGGAAGACACACCCTATGTGCAATTTGGTAAG~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~CCAGCCACCTCAGCAGCCTAACTGTCCCT-CTGTGCTG TGTCTAGGTCGCCTCCTTACCCCTGTGGTTGCCGAAGTCCTTAAGCCCTGGTTCTGGGCG GGAGCTGCAGAGACTCTCCTACTTAGGGGCCTTCTTTAGCTTCTCTGTCTTCGCAGAGGA CGATGTAAGTACA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~TGCTTCCCCTTTCAGGCAAAGGTGGTTGAGAAA TACTTCTCAGGGCCTGCCATTACCCTGGAGAACACCCGTGTGGTCAGCCAGTCACTACAG CATTACCTGGAGCTGGGACGGGTAGGTGTTCAGAGAAGGACTCCAGAGGAAGGGCCCATT AT-AGGTCCAG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AAAAGGTTATCAATTGTTTTTTCATTT TGAAAATAA-TTT-AGCAAGAGCTTTTCAAGATTCTGCATAGTATTTTGTTAAACGGCGA AACTCGTGAAGCAGCACTCAGTTACATGGCAGCCATTGTCAATGCCAATATGAAGAAAGC GCAGATGCAGGTAGGAGTCCCA-AG--TGCTTTCAGTTCCTCATTGAACCCGTTTCTCAG GGCCAGACATACTTAGCACGTCCCAGGCTGTGTTCTGGGAGTTGGGAAGCAGCATGGA-C GAGACCGGCAAGCACCCTGCTGTCGTGCAGGTCTTG~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CTGTCACAGGCAGA TGATCGGTTGGTGTCTACAGACGGGTTCATGCTGAATCTCCTTTGGGTCCTGCAGCAGCT AAGTACAAAAATCAAGTTAGAAACGGTCGACCCCACTTACATATTCCACCCGAGATGTCG GATCACTCTGCCAAACGATGAGACACGGATAAATGCAACGATGGAGGATGTGAACGAGTG GCTGACAGAGCTCTGTGAGTAC-GTG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~ATATGCACACAAATA-T-TCTT-AACCT--ATTT TCCTTCAGAGTTGATTTTTTCTTAAGACTTGAACTGATTCACTGAAGGGTTCATGTT-TG TTTTTTGTTTGTTGTTTGTTGTTTTTTTTCTTAGATGGAGATCAGCCTCCATTTTCTGAG CCAAAATTCCCTACAGAATGCTTCTTTCTCACCCTGCACGCTCACCATCTCTCTATCCTG CCTAGTTGTCGTCGCTACATTCGCCGGCTCCGAGCCATCCGTGAGCTCAATAGGTACGTG TCCTGCTCCC-TGTCCTGGC--TGGC-G-GTTA--ACTGCTGCTGAGGCACACGGAGTTG GCT-GTGGGCAGTATGTGTGA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~TCTTTAGGATGTTTGTTTGTTTTTAATTTCAGAACCGTGGAAGAT TTGAAAAATAATGAAAGCCAGTGGAAAGATTCCCCACTGGCCACCAGACACCGCGAAATG CTGAAGCGCTGTAAAACTCAGCTTAAGGTTTGTATAGCTGATTGGCATCGTCGTGGCCC- GTTTCCCAGTAGTAATCTCCTCACCAGAATAAACGCCCTGAGCGCGT-GCTCAGTGTCC- CTGTTTTTCTTGGTTGTTCTTTTCTCT-C--A--AGGTA--ACATGGGACTA-TTGTTGA TACCTTGCCTATTTCTGTATCCAGTCATTTAAATCTAAGCAGAGAACATACATGGCTATG C~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TGAGGCTATCGGAGATGTTGAACCTAGATTT CTCATCTCCTAGCCCC--TCCCTGCCTACTGGAGCTGAGGGGCCCTGGCATCGCACTAAT CTACTGGTGGGGGCATC--TACTTCCACAGAAACTGGTACGGTGCAAGGCCTGTGCTGAC GCTGGCTTACTTGACGAGAGCTTCCTAAGAAGATGTCTGAATTTTTATGGCCTTCTCATT CAGCTGATGCTGCGCGTCCTGGACCCTGCATATCCTGAGTGAGTG-GCTCCT-CCTCTG- CC-TCCTCCCTC-TTCGCTGGGCTCTGTTGTCTTAATTGTTGTTTA----TCATAACTGA AGCCTTA-CCCT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~AAGAAGTCAAGATGAGGTAA ACACTT-ACCCAAGCTCGGCCAAGT-CTCCCTCATCCTTTCTGCATGT-C-TAAA-GGTC ACAGTTG-TTTGCCCGTGTGCATTTTACAGAGTGTTACAGTAAGGGCTGCTTTTCCAGA- GTGGGG-T-ATTT-A--GCAGTACAGCAC-CCTGGTAATGAGC-GTGCCATGACGTCATT TG-TAAGTTGTGCTTTTTTTCTCCTCTACAGCATAACACTGCCTTTAAATTCAGAAGTCC CCAAGGTATTTGCAGCATTGCCTGAGTTTTATGTAGAAGATGTTGCTGAATTTTTATTTT TTATTGTACAGTAAGTAC-TCCAATGCTGT-C-T-GCTCTTTTGTGATGTAATGCGTGGT GCCAGGAGCTTGTTA-C-ATTTACCACACCTC-ACTTAA-GTCTGATGTT--ATGTAACG CTTTTACCTGAA--CTGCTCGGAAATTGGAGAAA~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CTGCAGTACCCTCCTCTGCTG-TGCCAT CT-CCTTCCCTGACGGCGAGCT-CTCGGTGGTGCGTCCGGTGGCTCAC-CGTGC-CTTCT TGCCTCTG--CAGATACTCTCCTCAGGTGCTTTATGAGCCCTGCACTCAGGACATTGTGA TGTTCCTCGTTGTGATGCTGTGCAACCAGAACTACATCCGAAACCCTTACCTAGTGGCCA AGCTCGTGGAGGTCATGTTTATGACCAACCCCTCTGTTCAGCCGAGAACTCAGAAGTTTT TTGAGATGATTGAGAACCATCCTCTCTCTACCAAATTGCTGGTACCGTCCCTCATGAAGT TCTATACAGGTAGGTTT-TGGAGTGCCTTGTGGTG-ATGTACTGAGA-CG-AGGTT-GTT AATCTAAATCT-GTGACCTAAATT-CACAAATAG-GTAAATAAATATCCTGCCATC~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTCCCTCAGTCATGGAACTC-TGTGCCG TCTGACCTGGCTCTCATG-GTCATGGTAAT-GACACCTTTTAAT-AATGCT-ACCACTTG TGTCACTTGATCCGAGTAGCTGTCGAAAAGATGGTACTATAAATACCTCCATTTTATAAG TGAGGAAACTCGAGCTTAGAAAGGTCAGGAAGCTCGCTGAAGGTTAATGGCAAGTCAGTG ACAGGTGCCCAGCAGCTGGCCCT-AGCACAAGTGCGGCTGACG-CTCTGCTGCTCTTCC- ACAGTTACTAAG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTGCTCGTTGTCCTGC- CTT-GTATGGTCGTTGCAGTGATAACTTCATCCGAAAGGTCAGAAAGGATGTGTGCCTGA GTCCCTTTGTCTTTCCTCCCTAGACGTCGAGCATACTGGAGCCACCAGCGAGTTCTATGA CAAGTTCACAATTCGCTATCACATCAGCACTATTTTTAAAAGCCTTTGGCAAAACATAGC TCACCATGGCACCTTCATGGAGGAGTTCAAGTGAGTACTGGGCCCCGA-TGGCACGGCTT GCT--CTGGCAAATCCCAGGTGGGAG-GCTGCTGAAC-GCCTTCGCAGA-GGATTCCTGG -GACTGTCCTCTTG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~CAGCCAGATGTTT-ACCACACACTGTCTCATTGCCCTTTCAGTTCTGGAAAGC AGTTCGTTCGGTATATCAACATGCTGATAAATGACACGACCTTTTTACTGGACGAAAGTC TGGAGTCTCTGAAGCGGATCCATGAAGTGCAAGAGGAGATGAAGAACCAAGAGCAGTGGG ACCAGCTGCCCCGGGTGAGGGCGCCGCGCTCTGCATGGGGCTGGCTGGC-GGC--TCTCC CTGC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CTCTCAGCCTCTGCAGTGTAAGCCG ACCTTTCCCCTT-TACACTTGGCGCATTG-TGAGCAGACGACTGGTGCAGAGATCTCCTT GGCAACTGTTTGATGTTTCCTAGGATCAGCAGCAGGCCCGGCAGTCTCAGCTTGCTCAGG ACGAGCGTGTTTCCCGTTCCTATCTCGCCCTGGCGACTGAAACCGTGGACATGTTCCATC TCCTCACCAAGCAAGTCCAGAAGCCGTTCCTGAGGCCAGTGAGTAGAAACTGGGGGCTTT GTTATCTGGGGTG~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTCATCTCTATACACCATACCA CTCCGTTATAGGGTTTTCAGATCAGTAGTGGTGACACACGTTGGATTCCA--GT-G-CTT TCTTTAGCGTGTGTTGCTCAGCACAATTCGGGATTCTTTGAAGATTAAAC-AGCTGATTC CCAGGCCTCCACTGAGGTGGGAGCTTCTGGTCCCTGAC-CTTC-C-CAGCAGCTTGAACT GTCCTGTTATCCCCC-ATTTCCTAGGAACTTGGTCCCCGGTTAGCAGCCATGCTGAACTT TAACCTGCAGCAGCTCTGCGGGCCCAAGTGCCGGGACCTCAAAGTGGAAAACCCAGAGAA GTACGGTTTTGAGCCAAAGAAGCTGTTGGACCAACTGACGGATATCTACTTACAGCTGGA CTGTGCTCGCTTTGCTAAAGCCATCGCTGATGACCAGGTGAG~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GTCCTGCTC-AAGTGAGCCTGGGGA A--TGGGCGGTGACGAATCCAAAGCTCCTCTA-AGTGTGAACAGTCATGGAGCAGTGGTA C-ATGTTTGCTTTTTTCTGTGCTCACAGAAAACTCGAATTTACCTTTCTCATGGGCTCCC AGGGCATAGTGCCTGACACGAACTCAACCC--C-A-ATTTCCTTCTCTTTTTTATGGCTA AATTTTAAAATAAATGCTTTTTAGCTCCTGAAGT-CTAAAAACTT-CGTGTTTTCTTGGG TCTTGCAGCTTTCTCCTGACACAC-GA--T-G-ACC--TTGGCACATGTGATTGT-GTCT CTGTGTGTCTGTGACTATATCCAGTACACCCTT~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TTTTTTCTTCTCAAGTGTGTT CTCATCTCTTGTGACCTTCCCTCATCTACAGCGATCCTACAGCAAGGAACTGTTCGAAGA AGTCATTTCAAAGATGCGGAAGGCAGGAATCAAATCCACCATCGCAATAGAAAAGTTTAA GCTTCTTGCAGAGAAAGTGGAGGAAATCGTGGCAAAGAATGCTCGGGCGGAAATAGACTA CAGTGACGCCCCGGACGAGTTCAGAGGCAAGTCCGCATGTCATGCCCAAGCCCACATCTT TGGTGT-AACTTGAAGTGTGTGACATCACAC-AGGGCGTCTTGGTCACT~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ATCTGCCATCATCGT--GCTGCT TTCCC-CTACAGGAAGGGAC-TCG--GGGGCTGCTGGCTCCCAGTGCCCCTG-A--GATG TCTCCCTGGTAGAAACCG-TCTGTTTTGCTCTTCGGGGTTACCCCCCCAGTGGGTTAGC- -TTGCTTTGCTCTGTGTCCACAGACCCTCTGATGGACACCCTGATGACTGATCCCGTGAG ACTGCCCTCTGGGACCATCATGGACCGTTCTATCATCCTGCGGCATCTGCTCAACTCCCC CACCGACCCCTTCAACCGCCAGATGCTGACTGAGAGCATGCTGGAGCCAGGTAG-G-AGG CC-CAGCTCGCCTTGCTGCGCCGAC--CAGTGTCAGG~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GAAGGGCCTGCCCACCTGGGCTGTTAAC CC-CCTGTCTCTCTCC-CTCAGTGCCAGAGCTAAAGGAGCAGATTCAGGCCTGGATGAGA GAGAAGCAGAGCAGTGACCACTAAGT-GTCCCATCCCCCATCCTCAGCTGGAAGCCGCCA -G-CCAGCCAGCCAGGCCAAAGCAGCATCCGCCTCGAAGCTGCT-TCCAACCGATGGAG- -CAGATCCTGAGAACCCACCCCAGGCAGATCCTGAGA-ACCCACCCCGGTGACCAGCAGG GAGATGGAGGACATGACGAAGAGGATTCCTGTACATATATTTAAGTGACAA-CA--GTCA A--GCTTGAGGGACGAATTTTCCA-TGGCTTGTGTAGTAAAGCGCGCCCTTCGCCTGTCG CCCCTGGGGGCAGCGGAAGTGTTT-AGTGACG---AGTGGGTCTGGGCAGCTTCCCCTGA TTACGTTTTTGTT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CCCCTCCCTCACCC-ACTGGCACTGCTGTG GGATTTTTAAAGAGA--CACAGACCCA-G--A-CTCCTTTCCC-GGCCCTCCAAACATGT ATTCTGTGAGGTAACTGTGCCTGCGACGAAGTGTTAA-CCTGGGATCGTATTTTTATATC ATATTCACAGACTTGTTTTTTTAATTGGTGTTAGATGACATGATTAATAAAAAAGGCAAG ATATTTTCAGAATTTGAATTTCAGTTTTTTTTTTCTTTTGAAATAGCCCTTTAA-ATTTT TTTATTATAAACAAAATGAAGAGAACCCTGTGGGCCTGGTCCTTCTACCACCCCTCAGTT ATG-ATCTGAGAAGCAGGTGCGACAGCAGCT--GGCTGGA-GTGAATCAGGACTCGTGTG TTTTGTTTTCTGTGGTTTTTTTTTTTTTTTTTTTTTTTTAATCCTATGTGACAATTCCAA TCCTAAGCCGTTATCCTCTGAGGATGAATAAGTTCCTCAACCCTGGGTTGTGTGTGTTTG GGGTTTGGCCTTACCAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAGGGTGCAAGAATG TGGAAATCTGTCTGCTTGTTT-A-CATGCCCGGACAAACACCACCACGTAACCACGTAGG CGCACGAGCAGAAGTACTACCGCTCCCTACGCAACATACTTGAATTCTTAAATTTCCTTT GGGGTGAAAAA-------GGATTTGAAACCATAAAGTGTTTTAAAGAAATGAAATCTTCA GAAA-CATACTTTTTCTCCTCTTTTCCTTCCTCCCCTCTTCACAGTCTGTGCTCTGTTCA GTTCCCAACACAAACGACAATAAACGGTGATGCCCATTCAGAAGGAACCTTCTGTGA--C TCGTCTCTTT-GTGGAAAGAAATGGGGGGGAAGGCTGG~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~